@office-open/xlsx 0.9.7 → 0.9.8

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-D6f14vKV.mjs","names":["buildRstXml","hashPassword","buildRstXml"],"sources":["../src/parts/shared-strings.ts","../src/parts/styles.ts","../src/parts/worksheet.ts","../src/parts/calc-chain.ts","../src/parts/chartsheet.ts","../src/parts/comments.ts","../src/parts/drawing.ts","../src/parts/external-link.ts","../src/parts/pivot/pivot-utils.ts","../src/parts/pivot-table.ts","../src/parts/pivot-cache.ts","../src/parts/table.ts","../src/parts/workbook.ts","../src/parts/content-types.ts","../src/parts/media.ts","../src/context.ts"],"sourcesContent":["/**\n * Shared Strings Table — generates xl/sharedStrings.xml.\n *\n * XLSX stores repeated string values in a central table to reduce file size.\n * Cells reference strings by index into this table.\n *\n * @module\n */\nimport type { CustomDescriptor } from \"@office-open/core/descriptor\";\nimport { escapeXml, findChild, attr, attrNum, textOf } from \"@office-open/xml\";\nimport type { Element as XmlElement } from \"@office-open/xml\";\n\nimport type { RichTextOptions } from \"./worksheet\";\n\n/** String or rich text entry in the SST. */\ntype SstEntry = string | RichTextOptions;\n\n/**\n * Build rich text run properties XML (CT_RPrElt).\n * Exported for reuse by Comments and other components.\n */\nexport function buildRPrXml(\n pr: NonNullable<RichTextOptions[\"runs\"]>[number][\"properties\"],\n): string {\n if (!pr) return \"\";\n const parts: string[] = [];\n if (pr.font) parts.push(`<rFont val=\"${escapeXml(pr.font)}\"/>`);\n if (pr.charset !== undefined) parts.push(`<charset val=\"${pr.charset}\"/>`);\n if (pr.family !== undefined) parts.push(`<family val=\"${pr.family}\"/>`);\n if (pr.bold) parts.push(\"<b/>\");\n if (pr.italic) parts.push(\"<i/>\");\n if (pr.strike) parts.push(\"<strike/>\");\n if (pr.outline) parts.push(\"<outline/>\");\n if (pr.shadow) parts.push(\"<shadow/>\");\n if (pr.condense) parts.push(\"<condense/>\");\n if (pr.extend) parts.push(\"<extend/>\");\n if (pr.color) {\n // ST_UnsignedIntHex requires 8 hex chars (AARRGGBB).\n // Auto-prefix FF (fully opaque) when user provides 6-char RGB.\n const rgb = pr.color.length === 6 ? `FF${pr.color}` : pr.color;\n parts.push(`<color rgb=\"${escapeXml(rgb)}\"/>`);\n }\n if (pr.size !== undefined) parts.push(`<sz val=\"${pr.size}\"/>`);\n if (pr.underline) {\n if (pr.underline === \"none\") {\n parts.push(\"<u/>\");\n } else {\n parts.push(`<u val=\"${pr.underline}\"/>`);\n }\n }\n if (pr.vertAlign) parts.push(`<vertAlign val=\"${pr.vertAlign}\"/>`);\n if (pr.scheme) parts.push(`<scheme val=\"${pr.scheme}\"/>`);\n return parts.length > 0 ? `<rPr>${parts.join(\"\")}</rPr>` : \"\";\n}\n\n/** Build a CT_Rst XML string from RichTextOptions. */\nexport function buildRstXml(rst: RichTextOptions): string {\n const parts: string[] = [];\n if (rst.runs && rst.runs.length > 0) {\n for (const run of rst.runs) {\n const rPr = buildRPrXml(run.properties);\n parts.push(`<r>${rPr}<t>${escapeXml(run.text)}</t></r>`);\n }\n } else if (rst.text !== undefined) {\n parts.push(`<t>${escapeXml(rst.text)}</t>`);\n }\n // rPh (phonetics)\n if (rst.phonetics) {\n for (const ph of rst.phonetics) {\n parts.push(`<rPh sb=\"${ph.sb}\" eb=\"${ph.eb}\"><t>${escapeXml(ph.text)}</t></rPh>`);\n }\n }\n return parts.join(\"\");\n}\n\nexport class SharedStrings {\n private entries: SstEntry[] = [];\n /** Dedup map for plain strings only. Rich text is not deduped. */\n private indexMap = new Map<string, number>();\n\n /**\n * Register a plain string and return its index.\n * Returns existing index if the string is already registered.\n */\n public register(s: string): number {\n const existing = this.indexMap.get(s);\n if (existing !== undefined) return existing;\n\n const idx = this.entries.length;\n this.entries.push(s);\n this.indexMap.set(s, idx);\n return idx;\n }\n\n /**\n * Register a rich text entry and return its index.\n * Rich text is not deduped (each call creates a new entry).\n */\n public registerRich(rst: RichTextOptions): number {\n const idx = this.entries.length;\n this.entries.push(rst);\n return idx;\n }\n\n public get count(): number {\n return this.entries.length;\n }\n\n /** Return a serializable snapshot for the descriptor. */\n public toDescriptorOptions(): { entries: SstEntry[]; uniqueCount: number } {\n return { entries: this.entries, uniqueCount: this.indexMap.size };\n }\n\n /** Serialize to xl/sharedStrings.xml content (without XML declaration). */\n public serialize(): string {\n const p: string[] = [\n '<sst xmlns=\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\"',\n ` count=\"${this.entries.length}\" uniqueCount=\"${this.indexMap.size}\">`,\n ];\n for (const entry of this.entries) {\n if (typeof entry === \"string\") {\n p.push(`<si><t>${escapeXml(entry)}</t></si>`);\n } else {\n // Rich text (CT_Rst)\n p.push(`<si>${buildRstXml(entry)}</si>`);\n }\n }\n p.push(\"</sst>\");\n return p.join(\"\");\n }\n}\n\n// ── Descriptor Types ──\n\n/** Serializable snapshot of the shared string table. */\nexport interface SharedStringsDocOptions {\n /** All entries (plain strings and rich text), in registration order. */\n entries: (string | RichTextOptions)[];\n /** Number of unique plain-string entries (for uniqueCount attribute). */\n uniqueCount: number;\n}\n\n// ── Descriptor ──\n\nexport const sharedStringsDesc: CustomDescriptor<SharedStringsDocOptions> = {\n kind: \"custom\",\n\n stringify(opts, _ctx) {\n if (opts.entries.length === 0) return undefined;\n\n const p: string[] = [\n '<sst xmlns=\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\"',\n ` count=\"${opts.entries.length}\" uniqueCount=\"${opts.uniqueCount}\">`,\n ];\n\n for (const entry of opts.entries) {\n if (typeof entry === \"string\") {\n p.push(`<si><t>${escapeXml(entry)}</t></si>`);\n } else {\n p.push(`<si>${buildRstXml(entry)}</si>`);\n }\n }\n\n p.push(\"</sst>\");\n return p.join(\"\");\n },\n\n parse(el, _ctx) {\n const entries: (string | RichTextOptions)[] = [];\n\n for (const si of el.elements ?? []) {\n if (si.name !== \"si\") continue;\n\n // Simple: <si><t>text</t></si>\n const t = findChild(si, \"t\");\n if (t) {\n entries.push(textOf(t) ?? \"\");\n continue;\n }\n\n // Rich text: <si><r>...</r>...</si>\n const runs: { text: string; properties?: Record<string, unknown> }[] = [];\n for (const r of si.elements ?? []) {\n if (r.name !== \"r\") continue;\n const rt = findChild(r, \"t\");\n if (rt) {\n const rPrEl = findChild(r, \"rPr\");\n const run: Record<string, unknown> = { text: textOf(rt) ?? \"\" };\n if (rPrEl) run.properties = parseRPr(rPrEl);\n runs.push(run as (typeof runs)[number]);\n }\n }\n\n // Phonetics: <rPh sb=\"...\" eb=\"...\"><t>...</t></rPh>\n const phonetics: { sb: number; eb: number; text: string }[] = [];\n for (const rPh of si.elements ?? []) {\n if (rPh.name !== \"rPh\") continue;\n const sb = attrNum(rPh, \"sb\") ?? 0;\n const eb = attrNum(rPh, \"eb\") ?? 0;\n const rPhT = findChild(rPh, \"t\");\n phonetics.push({ sb, eb, text: rPhT ? (textOf(rPhT) ?? \"\") : \"\" });\n }\n\n if (runs.length > 0) {\n const entry: Record<string, unknown> = { runs };\n if (phonetics.length > 0) entry.phonetics = phonetics;\n entries.push(entry as RichTextOptions);\n }\n }\n\n return {\n entries,\n uniqueCount: entries.length,\n } as unknown as SharedStringsDocOptions;\n },\n};\n\n/** Parse CT_RPrElt (run properties inside shared strings r element). */\nfunction parseRPr(el: XmlElement): Record<string, unknown> {\n const result: Record<string, unknown> = {};\n for (const child of el.elements ?? []) {\n switch (child.name) {\n case \"rFont\":\n result.font = attr(child, \"val\") ?? undefined;\n break;\n case \"charset\":\n result.charset = attrNum(child, \"val\");\n break;\n case \"family\":\n result.family = attrNum(child, \"val\");\n break;\n case \"b\":\n result.bold = attr(child, \"val\") !== \"0\";\n break;\n case \"i\":\n result.italic = attr(child, \"val\") !== \"0\";\n break;\n case \"strike\":\n result.strike = true;\n break;\n case \"outline\":\n result.outline = true;\n break;\n case \"shadow\":\n result.shadow = true;\n break;\n case \"condense\":\n result.condense = true;\n break;\n case \"extend\":\n result.extend = true;\n break;\n case \"color\": {\n const rgb = attr(child, \"rgb\");\n if (rgb) {\n result.color = rgb.length === 8 ? rgb.slice(2) : rgb;\n } else {\n const indexed = attrNum(child, \"indexed\");\n if (indexed !== undefined) result.color = String(indexed);\n else {\n const theme = attr(child, \"theme\");\n if (theme !== undefined) result.color = `theme:${theme}`;\n }\n }\n break;\n }\n case \"sz\":\n result.size = attrNum(child, \"val\");\n break;\n case \"u\": {\n const uVal = attr(child, \"val\");\n result.underline = uVal ?? true;\n break;\n }\n case \"vertAlign\":\n result.vertAlign = attr(child, \"val\") ?? undefined;\n break;\n case \"scheme\":\n result.scheme = attr(child, \"val\") ?? undefined;\n break;\n }\n }\n return result;\n}\n","/**\n * Styles component — generates xl/styles.xml.\n *\n * XLSX uses an index-based style system: cells reference style entries\n * via the `s` attribute, which is an index into `cellXfs`.\n *\n * @module\n */\nimport type { CustomDescriptor } from \"@office-open/core/descriptor\";\nimport { attrs, escapeXml, findChild, attr, attrNum, stringify } from \"@office-open/xml\";\nimport type { Element as XmlElement } from \"@office-open/xml\";\n\n// ── Sub-style option interfaces ──\n\nexport interface FontOptions {\n bold?: boolean;\n italic?: boolean;\n underline?: boolean;\n strike?: boolean;\n size?: number;\n color?: string;\n font?: string;\n /** Character set (CT_Font/charset @val) */\n charset?: number;\n /** Font family (CT_Font/family @val) */\n family?: number;\n /** Condense (macOS, CT_Font/condense) */\n condense?: boolean;\n /** Extend (macOS, CT_Font/extend) */\n extend?: boolean;\n /** Vertical alignment: superscript/subscript (CT_Font/vertAlign @val) */\n vertAlign?: \"superscript\" | \"subscript\" | \"baseline\";\n /** Font scheme (CT_Font/scheme @val) */\n scheme?: \"major\" | \"minor\" | \"none\";\n /** Font shadow (CT_Font/shadow) */\n shadow?: boolean;\n /** Font outline (CT_Font/outline) */\n outline?: boolean;\n}\n\n/** Gradient stop (CT_GradientStop) */\nexport interface GradientStopOptions {\n /** Position (0.0–1.0) */\n position: number;\n /** RGB color hex without alpha, e.g. \"FF0000\" */\n color: string;\n}\n\nexport interface FillOptions {\n type?: \"solid\" | \"pattern\" | \"gradient\";\n color?: string;\n patternType?: string;\n /** Background color for pattern fill (CT_PatternFill/bgColor) */\n bgColor?: string;\n /** Background color indexed (CT_Color @indexed) */\n colorIndexed?: number;\n /** Gradient stops (CT_GradientFill/stop) */\n stops?: GradientStopOptions[];\n /** Gradient type (CT_GradientFill @type) */\n gradientType?: \"linear\" | \"path\";\n /** Gradient degree for linear (CT_GradientFill @degree) */\n gradientDegree?: number;\n /** Gradient left position for path (CT_GradientFill @left) */\n gradientLeft?: number;\n /** Gradient right position for path (CT_GradientFill @right) */\n gradientRight?: number;\n /** Gradient top position for path (CT_GradientFill @top) */\n gradientTop?: number;\n /** Gradient bottom position for path (CT_GradientFill @bottom) */\n gradientBottom?: number;\n}\n\nexport interface BorderOptions {\n style?: \"thin\" | \"medium\" | \"thick\" | \"dotted\" | \"dashed\" | \"hair\" | \"none\";\n color?: string;\n}\n\nexport interface BorderSideOptions {\n top?: BorderOptions;\n bottom?: BorderOptions;\n left?: BorderOptions;\n right?: BorderOptions;\n diagonal?: BorderOptions;\n /** Diagonal up (CT_Border @diagonalUp) — on the parent border element */\n diagonalUp?: boolean;\n /** Diagonal down (CT_Border @diagonalDown) — on the parent border element */\n diagonalDown?: boolean;\n /** Leading edge border (CT_Border/start, for RTL support) */\n start?: BorderOptions;\n /** Trailing edge border (CT_Border/end, for RTL support) */\n end?: BorderOptions;\n /** Vertical inner border (CT_Border/vertical, for cell range borders) */\n vertical?: BorderOptions;\n /** Horizontal inner border (CT_Border/horizontal, for cell range borders) */\n horizontal?: BorderOptions;\n}\n\nexport interface AlignmentOptions {\n horizontal?: \"left\" | \"center\" | \"right\" | \"fill\" | \"justify\";\n vertical?: \"top\" | \"center\" | \"bottom\";\n wrapText?: boolean;\n textRotation?: number;\n indent?: number;\n /** Relative indent (CT_CellAlignment @relativeIndent) */\n relativeIndent?: number;\n /** Justify last line (CT_CellAlignment @justifyLastLine) */\n justifyLastLine?: boolean;\n /** Shrink to fit (CT_CellAlignment @shrinkToFit) */\n shrinkToFit?: boolean;\n /** Reading order (CT_CellAlignment @readingOrder) */\n readingOrder?: number;\n}\n\nexport interface StyleOptions {\n font?: FontOptions;\n fill?: FillOptions;\n border?: BorderSideOptions;\n numFmt?: string;\n alignment?: AlignmentOptions;\n /** Quote prefix (CT_Xf @quotePrefix) */\n quotePrefix?: boolean;\n /** Pivot button (CT_Xf @pivotButton) */\n pivotButton?: boolean;\n /** Apply protection (CT_Xf @applyProtection) */\n applyProtection?: boolean;\n /** Cell protection (CT_CellProtection) */\n protection?: CellProtectionOptions;\n}\n\n/** Cell-level protection settings (CT_CellProtection) */\nexport interface CellProtectionOptions {\n /** Cell is locked (CT_CellProtection @locked) */\n locked?: boolean;\n /** Cell formula is hidden (CT_CellProtection @hidden) */\n hidden?: boolean;\n}\n\n/** Indexed color entry (CT_RgbColor) */\nexport interface IndexedColorOptions {\n /** RGB hex value, e.g. \"FF000000\" */\n rgb: string;\n}\n\n/** Colors palette (CT_Colors) */\nexport interface ColorsOptions {\n /** Indexed color palette (CT_IndexedColors) */\n indexedColors?: IndexedColorOptions[];\n /** Most recently used colors (CT_MRUColors) */\n mruColors?: string[];\n}\n\n/** Differential format — used by conditional formatting to specify what changes. */\nexport interface DxfOptions {\n font?: FontOptions;\n fill?: FillOptions;\n border?: BorderSideOptions;\n numFmt?: string;\n}\n\n// ── Style key helpers for deduplication ──\n\nfunction fontKey(f: FontOptions): string {\n return `b${f.bold ? 1 : 0}i${f.italic ? 1 : 0}u${f.underline ? 1 : 0}s${f.strike ? 1 : 0}z${f.size ?? 0}c${f.color ?? \"\"}n${f.font ?? \"\"}cs${f.charset ?? \"\"}fm${f.family ?? \"\"}co${f.condense ? 1 : 0}ex${f.extend ? 1 : 0}va${f.vertAlign ?? \"\"}sc${f.scheme ?? \"\"}sh${f.shadow ? 1 : 0}ol${f.outline ? 1 : 0}`;\n}\n\nfunction fillKey(f: FillOptions): string {\n return `t${f.type ?? \"\"}c${f.color ?? \"\"}p${f.patternType ?? \"\"}bg${f.bgColor ?? \"\"}g${f.stops?.map((s) => `${s.position}_${s.color}`).join(\"|\") ?? \"\"}`;\n}\n\nfunction borderKey(b: BorderSideOptions): string {\n const sk = (o?: BorderOptions) => `${o?.style ?? \"\"}_${o?.color ?? \"\"}`;\n return `t${sk(b.top)}b${sk(b.bottom)}l${sk(b.left)}r${sk(b.right)}d${sk(b.diagonal)}du${b.diagonalUp ? 1 : 0}dd${b.diagonalDown ? 1 : 0}st${sk(b.start)}en${sk(b.end)}v${sk(b.vertical)}h${sk(b.horizontal)}`;\n}\n\n// ── Built-in number format IDs ──\n\nconst BUILTIN_NUMFMTS: Record<string, number> = {\n General: 0,\n \"0\": 1,\n \"0.00\": 2,\n \"#,##0\": 3,\n \"#,##0.00\": 4,\n \"0%\": 9,\n \"0.00%\": 10,\n \"0.00E+00\": 11,\n \"mm-dd-yy\": 14,\n \"d-mmm-yy\": 15,\n \"d-mmm\": 16,\n \"mmm-yy\": 17,\n \"h:mm AM/PM\": 18,\n \"h:mm:ss AM/PM\": 19,\n \"h:mm\": 20,\n \"h:mm:ss\": 21,\n \"m/d/yy h:mm\": 22,\n \"#,##0 ;(#,##0)\": 37,\n \"#,##0 ;[Red](#,##0)\": 38,\n \"#,##0.00;(#,##0.00)\": 39,\n \"#,##0.00;[Red](#,##0.00)\": 40,\n \"mm:ss\": 45,\n \"[h]:mm:ss\": 46,\n \"mmss.0\": 47,\n \"##0.0E+0\": 48,\n \"@\": 49,\n};\n\n/** Table style element type (ST_TableStyleType). */\nexport type TableStyleElementType =\n | \"wholeTable\"\n | \"headerRow\"\n | \"totalRow\"\n | \"firstColumn\"\n | \"lastColumn\"\n | \"firstRowStripe\"\n | \"secondRowStripe\"\n | \"firstColumnStripe\"\n | \"secondColumnStripe\"\n | \"firstHeaderCell\"\n | \"lastHeaderCell\"\n | \"firstTotalCell\"\n | \"lastTotalCell\"\n | \"subtotalRow1\"\n | \"subtotalRow2\"\n | \"subtotalRow3\"\n | \"subtotalColumn1\"\n | \"subtotalColumn2\"\n | \"subtotalColumn3\"\n | \"blankRow\"\n | \"firstColumnSubheading\"\n | \"secondColumnSubheading\"\n | \"thirdColumnSubheading\"\n | \"firstRowSubheading\"\n | \"secondRowSubheading\"\n | \"thirdRowSubheading\"\n | \"pageFieldLabels\"\n | \"pageFieldValues\";\n\n/** Table style element (CT_TableStyleElement). */\nexport interface TableStyleElementOptions {\n /** Element type */\n type: TableStyleElementType;\n /** Differential format index (dxf) */\n dxfId?: number;\n /** Button style (for pivot tables) */\n button?: boolean;\n}\n\n/** Custom table/pivot table style (CT_TableStyle). */\n/** Style sheet extension (CT_Extension) */\nexport interface StyleExtensionOptions {\n /** Extension URI (required) */\n uri: string;\n /** Extension content (raw XML fragment) */\n content?: string;\n}\n\nexport interface CustomTableStyleOptions {\n /** Style name (must be unique) */\n name: string;\n /** Pivot style (vs table style) */\n pivot?: boolean;\n /** Table style elements */\n elements?: TableStyleElementOptions[];\n}\n\n/** Custom cell style (CT_CellStyle) */\nexport interface CustomCellStyleOptions {\n /** Style name */\n name: string;\n /** XF index to apply */\n xfId: number;\n /** Built-in ID */\n builtinId?: number;\n /** Custom built-in (CT_CellStyle @customBuiltin) */\n customBuiltin?: boolean;\n /** Outline level (CT_CellStyle @iLevel) */\n iLevel?: number;\n /** Hidden style (CT_CellStyle @hidden) */\n hidden?: boolean;\n}\n\n/** Cell XF entry exposed by Styles.toDescriptorOptions(). */\nexport interface CellXfEntry {\n fontId: number;\n fillId: number;\n borderId: number;\n numFmtId: number;\n alignment?: AlignmentOptions;\n quotePrefix?: boolean;\n pivotButton?: boolean;\n applyProtection?: boolean;\n protection?: CellProtectionOptions;\n}\n\n/** Snapshot of Styles internal state for descriptor-based XML generation. */\nexport interface StylesState {\n customNumFmts: ReadonlyMap<string, number>;\n fonts: FontOptions[];\n fills: FillOptions[];\n borders: BorderSideOptions[];\n cellXfs: CellXfEntry[];\n dxfs: DxfOptions[];\n colors?: ColorsOptions;\n tableStyles?: CustomTableStyleOptions[];\n customCellStyles?: CustomCellStyleOptions[];\n styleExtensions?: StyleExtensionOptions[];\n}\n\n/**\n * Indexed XF reference produced by {@link stylesDesc}.parse — index-based\n * (fontId/fillId/…) rather than resolved objects, consumed by callers that\n * resolve indices into fonts/fills/borders arrays.\n */\nexport interface IndexedXfEntry {\n fontId?: number;\n fillId?: number;\n borderId?: number;\n numFmtId?: number;\n alignment?: AlignmentOptions;\n protection?: CellProtectionOptions;\n quotePrefix?: boolean;\n pivotButton?: boolean;\n}\n\n/** Table styles block (CT_TableStyles) produced by {@link stylesDesc}.parse. */\nexport interface TableStylesInfo {\n count?: number;\n defaultTableStyle?: string;\n defaultPivotStyle?: string;\n tableStyles?: CustomTableStyleOptions[];\n}\n\n/** Result of {@link stylesDesc}.parse (xl/styles.xml → structured data). */\nexport interface StylesParseResult {\n customNumFmts?: Record<string, number>;\n fonts?: FontOptions[];\n fills?: FillOptions[];\n borders?: BorderSideOptions[];\n cellStyleXfs?: IndexedXfEntry[];\n cellXfs?: IndexedXfEntry[];\n customCellStyles?: CustomCellStyleOptions[];\n dxfs?: DxfOptions[];\n tableStylesInfo?: TableStylesInfo;\n colors?: ColorsOptions;\n styleExtensions?: StyleExtensionOptions[];\n}\n\nexport class Styles {\n private fonts: FontOptions[] = [\n { size: 11, font: \"Calibri\" }, // default font (index 0)\n ];\n private fontKeys = new Map<string, number>();\n\n private fills: FillOptions[] = [\n { patternType: \"none\" }, // default fill (index 0)\n { patternType: \"gray125\" }, // required fill (index 1)\n ];\n private fillKeys = new Map<string, number>();\n\n private borders: BorderSideOptions[] = [\n {}, // default empty border (index 0)\n ];\n private borderKeys = new Map<string, number>();\n\n private customNumFmts = new Map<string, number>();\n private nextCustomNumFmtId = 164; // custom numFmts start at 164\n\n private cellXfs: Array<{\n fontId: number;\n fillId: number;\n borderId: number;\n numFmtId: number;\n alignment?: AlignmentOptions;\n quotePrefix?: boolean;\n pivotButton?: boolean;\n applyProtection?: boolean;\n protection?: CellProtectionOptions;\n }> = [\n { fontId: 0, fillId: 0, borderId: 0, numFmtId: 0 }, // default xf (index 0)\n ];\n private cellXfKeys = new Map<string, number>();\n\n private dxfs: DxfOptions[] = [];\n\n private colors?: ColorsOptions;\n private tableStyles?: CustomTableStyleOptions[];\n /** Custom cell styles (CT_CellStyles) */\n private customCellStyles?: CustomCellStyleOptions[];\n /** Style sheet extensions (CT_ExtensionList) */\n private styleExtensions?: StyleExtensionOptions[];\n\n public constructor() {\n // Pre-register default font/fill/border keys\n this.fontKeys.set(fontKey(this.fonts[0]), 0);\n this.fillKeys.set(fillKey(this.fills[0]), 0);\n this.fillKeys.set(fillKey(this.fills[1]), 1);\n this.borderKeys.set(borderKey(this.borders[0]), 0);\n this.cellXfKeys.set(this.cellXfKey(this.cellXfs[0]), 0);\n }\n\n /**\n * Register a style and return its index (for the cell `s` attribute).\n * Deduplicates across fonts, fills, borders, numFmts, and cellXfs.\n */\n public register(opts: StyleOptions): number {\n const fontId = this.registerFont(opts.font);\n const fillId = this.registerFill(opts.fill);\n const borderId = this.registerBorder(opts.border);\n const numFmtId = this.registerNumFmt(opts.numFmt);\n\n const xf = {\n fontId,\n fillId,\n borderId,\n numFmtId,\n alignment: opts.alignment,\n quotePrefix: opts.quotePrefix,\n pivotButton: opts.pivotButton,\n applyProtection: opts.applyProtection,\n protection: opts.protection,\n };\n\n const key = this.cellXfKey(xf);\n const existing = this.cellXfKeys.get(key);\n if (existing !== undefined) return existing;\n\n const idx = this.cellXfs.length;\n this.cellXfs.push(xf);\n this.cellXfKeys.set(key, idx);\n return idx;\n }\n\n /**\n * Register a differential format and return its index (dxfId).\n * Used by conditional formatting rules.\n */\n public registerDxf(opts: DxfOptions): number {\n const idx = this.dxfs.length;\n this.dxfs.push(opts);\n return idx;\n }\n\n /**\n * Set color palette (indexed colors and MRU colors).\n */\n public setColors(opts: ColorsOptions): void {\n this.colors = opts;\n }\n\n public setTableStyles(styles: CustomTableStyleOptions[]): void {\n this.tableStyles = styles;\n }\n\n public setExtensions(extensions: StyleExtensionOptions[]): void {\n this.styleExtensions = extensions;\n }\n\n public setCustomCellStyles(styles: CustomCellStyleOptions[]): void {\n this.customCellStyles = styles;\n }\n\n /**\n * Expose internal state for descriptor-based XML generation.\n * The descriptor reads this snapshot to produce xl/styles.xml.\n */\n public toDescriptorOptions(): StylesState {\n return {\n customNumFmts: new Map(this.customNumFmts),\n fonts: [...this.fonts],\n fills: [...this.fills],\n borders: [...this.borders],\n cellXfs: [...this.cellXfs],\n dxfs: [...this.dxfs],\n colors: this.colors,\n tableStyles: this.tableStyles,\n customCellStyles: this.customCellStyles,\n styleExtensions: this.styleExtensions,\n };\n }\n\n private registerFont(opts?: FontOptions): number {\n if (!opts) return 0;\n const key = fontKey(opts);\n const existing = this.fontKeys.get(key);\n if (existing !== undefined) return existing;\n\n const idx = this.fonts.length;\n this.fonts.push(opts);\n this.fontKeys.set(key, idx);\n return idx;\n }\n\n private registerFill(opts?: FillOptions): number {\n if (!opts) return 0;\n const key = fillKey(opts);\n const existing = this.fillKeys.get(key);\n if (existing !== undefined) return existing;\n\n const idx = this.fills.length;\n this.fills.push(opts);\n this.fillKeys.set(key, idx);\n return idx;\n }\n\n private registerBorder(opts?: BorderSideOptions): number {\n if (!opts) return 0;\n const key = borderKey(opts);\n const existing = this.borderKeys.get(key);\n if (existing !== undefined) return existing;\n\n const idx = this.borders.length;\n this.borders.push(opts);\n this.borderKeys.set(key, idx);\n return idx;\n }\n\n private registerNumFmt(fmt?: string): number {\n if (!fmt) return 0;\n const builtin = BUILTIN_NUMFMTS[fmt];\n if (builtin !== undefined) return builtin;\n\n const existing = this.customNumFmts.get(fmt);\n if (existing !== undefined) return existing;\n\n const id = this.nextCustomNumFmtId++;\n this.customNumFmts.set(fmt, id);\n return id;\n }\n\n private cellXfKey(xf: {\n fontId: number;\n fillId: number;\n borderId: number;\n numFmtId: number;\n alignment?: AlignmentOptions;\n quotePrefix?: boolean;\n pivotButton?: boolean;\n applyProtection?: boolean;\n protection?: CellProtectionOptions;\n }): string {\n const a = xf.alignment;\n const ak = a\n ? `h${a.horizontal ?? \"\"}v${a.vertical ?? \"\"}w${a.wrapText ? 1 : 0}r${a.textRotation ?? \"\"}i${a.indent ?? \"\"}ri${a.relativeIndent ?? \"\"}jl${a.justifyLastLine ? 1 : 0}st${a.shrinkToFit ? 1 : 0}ro${a.readingOrder ?? \"\"}`\n : \"\";\n const pr = xf.protection;\n const pk = pr ? `l${pr.locked ?? \"\"}h${pr.hidden ?? \"\"}` : \"\";\n return `${xf.fontId}|${xf.fillId}|${xf.borderId}|${xf.numFmtId}|${ak}|qp${xf.quotePrefix ? 1 : 0}|pb${xf.pivotButton ? 1 : 0}|${pk}`;\n }\n\n // ── XML generation ──\n\n /**\n * Zero-allocation fast path: directly concatenate XML string.\n * Bypasses the IXmlableObject intermediate tree entirely.\n */\n /** Serialize to xl/styles.xml content (without XML declaration). */\n public serialize(): string {\n const p: string[] = [\n '<styleSheet xmlns=\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\">',\n ];\n\n // numFmts\n if (this.customNumFmts.size > 0) {\n p.push(`<numFmts count=\"${this.customNumFmts.size}\">`);\n for (const [fmt, id] of this.customNumFmts) {\n p.push(`<numFmt numFmtId=\"${id}\" formatCode=\"${escapeXml(fmt)}\"/>`);\n }\n p.push(\"</numFmts>\");\n }\n\n // fonts\n p.push(`<fonts count=\"${this.fonts.length}\">`);\n for (const f of this.fonts) {\n p.push(`<font>${this.fontXmlStr(f)}</font>`);\n }\n p.push(\"</fonts>\");\n\n // fills\n p.push(`<fills count=\"${this.fills.length}\">`);\n for (const f of this.fills) {\n if (f.type === \"gradient\" && f.stops && f.stops.length > 0) {\n const gfAttrs: Record<string, string | number | boolean | undefined> = {};\n if (f.gradientType && f.gradientType !== \"linear\") gfAttrs.type = f.gradientType;\n if (f.gradientDegree !== undefined) gfAttrs.degree = f.gradientDegree;\n if (f.gradientLeft !== undefined) gfAttrs.left = f.gradientLeft;\n if (f.gradientRight !== undefined) gfAttrs.right = f.gradientRight;\n if (f.gradientTop !== undefined) gfAttrs.top = f.gradientTop;\n if (f.gradientBottom !== undefined) gfAttrs.bottom = f.gradientBottom;\n const stopParts = f.stops\n .map((s) => `<stop position=\"${s.position}\"><color rgb=\"FF${s.color}\"/></stop>`)\n .join(\"\");\n p.push(`<fill><gradientFill${attrs(gfAttrs)}>${stopParts}</gradientFill></fill>`);\n } else {\n const patternAttrs = attrs({ patternType: f.patternType ?? \"solid\" });\n const fgColor = f.color\n ? `<fgColor rgb=\"FF${f.color}\"/>`\n : f.colorIndexed !== undefined\n ? `<fgColor indexed=\"${f.colorIndexed}\"/>`\n : \"\";\n const bgColor = f.bgColor ? `<bgColor rgb=\"FF${f.bgColor}\"/>` : \"\";\n const colorContent = fgColor + bgColor;\n p.push(\n colorContent\n ? `<fill><patternFill${patternAttrs}>${colorContent}</patternFill></fill>`\n : `<fill><patternFill${patternAttrs}/></fill>`,\n );\n }\n }\n p.push(\"</fills>\");\n\n // borders\n p.push(`<borders count=\"${this.borders.length}\">`);\n for (const b of this.borders) {\n const bAttrs: string[] = [];\n if (b.diagonalUp) bAttrs.push('diagonalUp=\"1\"');\n if (b.diagonalDown) bAttrs.push('diagonalDown=\"1\"');\n const bAttr = bAttrs.length ? ` ${bAttrs.join(\" \")}` : \"\";\n p.push(`<border${bAttr}>${this.borderXmlStr(b)}</border>`);\n }\n p.push(\"</borders>\");\n\n // cellStyleXfs\n p.push(\n '<cellStyleXfs count=\"1\"><xf numFmtId=\"0\" fontId=\"0\" fillId=\"0\" borderId=\"0\"/></cellStyleXfs>',\n );\n\n // cellXfs\n p.push(`<cellXfs count=\"${this.cellXfs.length}\">`);\n for (const xf of this.cellXfs) {\n const xAttrs: Record<string, string | number | boolean | undefined> = {\n numFmtId: xf.numFmtId,\n fontId: xf.fontId,\n fillId: xf.fillId,\n borderId: xf.borderId,\n xfId: 0,\n };\n if (xf.alignment) xAttrs.applyAlignment = 1;\n if (xf.fontId > 0) xAttrs.applyFont = 1;\n if (xf.fillId > 0) xAttrs.applyFill = 1;\n if (xf.borderId > 0) xAttrs.applyBorder = 1;\n if (xf.numFmtId > 0) xAttrs.applyNumberFormat = 1;\n if (xf.quotePrefix) xAttrs.quotePrefix = 1;\n if (xf.pivotButton) xAttrs.pivotButton = 1;\n if (xf.applyProtection) xAttrs.applyProtection = 1;\n if (xf.protection) xAttrs.applyProtection = xAttrs.applyProtection ?? 1;\n\n const alignStr = xf.alignment ? this.alignmentXmlStr(xf.alignment) : \"\";\n const protStr = xf.protection ? this.protectionXmlStr(xf.protection) : \"\";\n const inner = alignStr + protStr;\n p.push(inner ? `<xf${attrs(xAttrs)}>${inner}</xf>` : `<xf${attrs(xAttrs)}/>`);\n }\n p.push(\"</cellXfs>\");\n\n // cellStyles\n if (this.customCellStyles && this.customCellStyles.length > 0) {\n // Normal (builtinId=0) is the implicit default; only auto-add it when the\n // caller's list doesn't already include it, so a parsed list containing\n // Normal round-trips instead of producing a duplicate.\n const hasNormal = this.customCellStyles.some(\n (cs) => cs.builtinId === 0 && cs.name === \"Normal\",\n );\n const csAttrs: string[] = [`count=\"${this.customCellStyles.length + (hasNormal ? 0 : 1)}\"`];\n const csParts: string[] = [`<cellStyles ${csAttrs.join(\" \")}>`];\n if (!hasNormal) csParts.push('<cellStyle name=\"Normal\" xfId=\"0\" builtinId=\"0\"/>');\n for (const cs of this.customCellStyles) {\n const attrs: string[] = [`name=\"${escapeXml(cs.name)}\"`, `xfId=\"${cs.xfId}\"`];\n if (cs.builtinId !== undefined) attrs.push(`builtinId=\"${cs.builtinId}\"`);\n if (cs.customBuiltin) attrs.push('customBuiltin=\"1\"');\n if (cs.iLevel !== undefined) attrs.push(`iLevel=\"${cs.iLevel}\"`);\n if (cs.hidden) attrs.push('hidden=\"1\"');\n csParts.push(`<cellStyle ${attrs.join(\" \")}/>`);\n }\n csParts.push(\"</cellStyles>\");\n p.push(csParts.join(\"\"));\n } else {\n p.push(\n '<cellStyles count=\"1\"><cellStyle name=\"Normal\" xfId=\"0\" builtinId=\"0\"/></cellStyles>',\n );\n }\n\n // dxfs\n if (this.dxfs.length > 0) {\n p.push(`<dxfs count=\"${this.dxfs.length}\">`);\n for (const dxf of this.dxfs) {\n const dParts: string[] = [];\n if (dxf.font) dParts.push(`<font>${this.fontXmlStr(dxf.font)}</font>`);\n if (dxf.fill) {\n const bgColor = dxf.fill.color ? `<bgColor rgb=\"FF${dxf.fill.color}\"/>` : \"\";\n const patAttrs = attrs({ patternType: dxf.fill.patternType ?? \"solid\" });\n dParts.push(`<fill><patternFill${patAttrs}>${bgColor}</patternFill></fill>`);\n }\n if (dxf.numFmt) dParts.push(`<numFmt formatCode=\"${escapeXml(dxf.numFmt)}\"/>`);\n if (dxf.border) dParts.push(`<border>${this.borderXmlStr(dxf.border)}</border>`);\n if (dParts.length > 0) {\n p.push(`<dxf>${dParts.join(\"\")}</dxf>`);\n } else {\n p.push(\"<dxf/>\");\n }\n }\n p.push(\"</dxfs>\");\n } else {\n p.push('<dxfs count=\"0\"/>');\n }\n // tableStyles (CT_TableStyles)\n if (this.tableStyles && this.tableStyles.length > 0) {\n const tsParts: string[] = [\n `<tableStyles count=\"${this.tableStyles.length}\" defaultTableStyle=\"TableStyleMedium2\" defaultPivotStyle=\"PivotStyleLight16\">`,\n ];\n for (const ts of this.tableStyles) {\n const tsAttrs: string[] = [`name=\"${escapeXml(ts.name)}\"`];\n if (ts.pivot) tsAttrs.push('pivot=\"1\"');\n if (ts.elements && ts.elements.length > 0) {\n tsParts.push(`<tableStyle ${tsAttrs.join(\" \")}>`);\n for (const el of ts.elements) {\n const elAttrs: string[] = [`type=\"${el.type}\"`];\n if (el.dxfId !== undefined) elAttrs.push(`dxfId=\"${el.dxfId}\"`);\n if (el.button) elAttrs.push('button=\"1\"');\n tsParts.push(`<tableStyleElement ${elAttrs.join(\" \")}/>`);\n }\n tsParts.push(\"</tableStyle>\");\n } else {\n tsParts.push(`<tableStyle ${tsAttrs.join(\" \")}/>`);\n }\n }\n tsParts.push(\"</tableStyles>\");\n p.push(tsParts.join(\"\"));\n } else {\n p.push(\n '<tableStyles count=\"0\" defaultTableStyle=\"TableStyleMedium2\" defaultPivotStyle=\"PivotStyleLight16\"/>',\n );\n }\n\n // colors (optional color palette)\n if (this.colors) {\n const c = this.colors;\n const colorParts: string[] = [\"<colors>\"];\n if (c.indexedColors && c.indexedColors.length > 0) {\n colorParts.push(\"<indexedColors>\");\n for (const ic of c.indexedColors) {\n colorParts.push(`<rgbColor rgb=\"${ic.rgb}\"/>`);\n }\n colorParts.push(\"</indexedColors>\");\n }\n if (c.mruColors && c.mruColors.length > 0) {\n colorParts.push(\"<mruColors>\");\n for (const mc of c.mruColors) {\n colorParts.push(`<color rgb=\"FF${mc}\"/>`);\n }\n colorParts.push(\"</mruColors>\");\n }\n colorParts.push(\"</colors>\");\n p.push(colorParts.join(\"\"));\n }\n\n // extLst — style sheet extensions\n if (this.styleExtensions && this.styleExtensions.length > 0) {\n const extParts: string[] = [\"<extLst>\"];\n for (const ext of this.styleExtensions) {\n if (ext.content) {\n extParts.push(`<ext uri=\"${ext.uri}\">${ext.content}</ext>`);\n } else {\n extParts.push(`<ext uri=\"${ext.uri}\"/>`);\n }\n }\n extParts.push(\"</extLst>\");\n p.push(extParts.join(\"\"));\n } else {\n p.push(\"<extLst/>\");\n }\n\n p.push(\"</styleSheet>\");\n return p.join(\"\");\n }\n\n private fontXmlStr(f: FontOptions): string {\n const parts: string[] = [];\n if (f.bold) parts.push(\"<b/>\");\n if (f.italic) parts.push(\"<i/>\");\n if (f.underline) parts.push(\"<u/>\");\n if (f.strike) parts.push(\"<strike/>\");\n if (f.outline) parts.push(\"<outline/>\");\n if (f.shadow) parts.push(\"<shadow/>\");\n if (f.condense) parts.push(\"<condense/>\");\n if (f.extend) parts.push(\"<extend/>\");\n if (f.size) parts.push(`<sz val=\"${f.size}\"/>`);\n if (f.color) parts.push(`<color rgb=\"FF${f.color}\"/>`);\n if (f.font) parts.push(`<name val=\"${escapeXml(f.font)}\"/>`);\n if (f.charset !== undefined) parts.push(`<charset val=\"${f.charset}\"/>`);\n if (f.family !== undefined) parts.push(`<family val=\"${f.family}\"/>`);\n if (f.vertAlign) parts.push(`<vertAlign val=\"${f.vertAlign}\"/>`);\n if (f.scheme) parts.push(`<scheme val=\"${f.scheme}\"/>`);\n return parts.join(\"\");\n }\n\n private borderXmlStr(b: BorderSideOptions): string {\n const parts: string[] = [];\n const renderSide = (name: string, opts: BorderOptions | undefined, required = true) => {\n if (opts && opts.style && opts.style !== \"none\") {\n const colorStr = opts.color ? `<color rgb=\"FF${opts.color}\"/>` : \"\";\n parts.push(`<${name} style=\"${opts.style}\">${colorStr}</${name}>`);\n } else if (required) {\n parts.push(`<${name}/>`);\n }\n };\n for (const side of [\n \"left\",\n \"right\",\n \"top\",\n \"bottom\",\n \"diagonal\",\n \"vertical\",\n \"horizontal\",\n ] as const) {\n renderSide(side, b[side] as BorderOptions | undefined);\n }\n // start/end not in transitional XSD — only emit when styled\n renderSide(\"start\", b.start, false);\n renderSide(\"end\", b.end, false);\n return parts.join(\"\");\n }\n\n private alignmentXmlStr(a: AlignmentOptions): string {\n const aAttrs: Record<string, string | number | boolean | undefined> = {};\n if (a.horizontal) aAttrs.horizontal = a.horizontal;\n if (a.vertical) aAttrs.vertical = a.vertical;\n if (a.wrapText) aAttrs.wrapText = 1;\n if (a.textRotation !== undefined) aAttrs.textRotation = a.textRotation;\n if (a.indent !== undefined) aAttrs.indent = a.indent;\n if (a.relativeIndent !== undefined) aAttrs.relativeIndent = a.relativeIndent;\n if (a.justifyLastLine) aAttrs.justifyLastLine = 1;\n if (a.shrinkToFit) aAttrs.shrinkToFit = 1;\n if (a.readingOrder !== undefined) aAttrs.readingOrder = a.readingOrder;\n return `<alignment${attrs(aAttrs)}/>`;\n }\n\n private protectionXmlStr(pr: CellProtectionOptions): string {\n const prAttrs: Record<string, string | number | boolean | undefined> = {};\n if (pr.locked !== undefined) prAttrs.locked = pr.locked ? 1 : 0;\n if (pr.hidden !== undefined) prAttrs.hidden = pr.hidden ? 1 : 0;\n return `<protection${attrs(prAttrs)}/>`;\n }\n}\n\n// ── Descriptor Types ──\n\nexport interface StylesDocOptions {\n /** The Styles accumulator instance (for stringify). */\n styles: Styles;\n}\n\n// ── Descriptor ──\n\nexport const stylesDesc: CustomDescriptor<StylesDocOptions> = {\n kind: \"custom\",\n\n stringify(opts, _ctx) {\n return opts.styles.serialize();\n },\n\n parse(el, _ctx) {\n const result: StylesParseResult = {};\n\n // numFmts\n const numFmtsEl = findChild(el, \"numFmts\");\n if (numFmtsEl) {\n const numFmts: Record<string, number> = {};\n for (const nf of numFmtsEl.elements ?? []) {\n if (nf.name !== \"numFmt\") continue;\n const id = attrNum(nf, \"numFmtId\");\n const code = attr(nf, \"formatCode\");\n if (id !== undefined && code) numFmts[code] = id;\n }\n result.customNumFmts = numFmts;\n }\n\n // fonts\n const fontsEl = findChild(el, \"fonts\");\n if (fontsEl) {\n const fonts: FontOptions[] = [];\n for (const f of fontsEl.elements ?? []) {\n if (f.name !== \"font\") continue;\n fonts.push(parseFont(f));\n }\n result.fonts = fonts;\n }\n\n // fills\n const fillsEl = findChild(el, \"fills\");\n if (fillsEl) {\n const fills: FillOptions[] = [];\n for (const f of fillsEl.elements ?? []) {\n if (f.name !== \"fill\") continue;\n fills.push(parseFill(f));\n }\n result.fills = fills;\n }\n\n // borders\n const bordersEl = findChild(el, \"borders\");\n if (bordersEl) {\n const borders: BorderSideOptions[] = [];\n for (const b of bordersEl.elements ?? []) {\n if (b.name !== \"border\") continue;\n borders.push(parseBorder(b));\n }\n result.borders = borders;\n }\n\n // cellStyleXfs\n const cellStyleXfsEl = findChild(el, \"cellStyleXfs\");\n if (cellStyleXfsEl) {\n const xfs: IndexedXfEntry[] = [];\n for (const xf of cellStyleXfsEl.elements ?? []) {\n if (xf.name !== \"xf\") continue;\n const style: IndexedXfEntry = {};\n const fontId = attrNum(xf, \"fontId\");\n const fillId = attrNum(xf, \"fillId\");\n const borderId = attrNum(xf, \"borderId\");\n const numFmtId = attrNum(xf, \"numFmtId\");\n if (fontId !== undefined) style.fontId = fontId;\n if (fillId !== undefined) style.fillId = fillId;\n if (borderId !== undefined) style.borderId = borderId;\n if (numFmtId !== undefined) style.numFmtId = numFmtId;\n xfs.push(style);\n }\n result.cellStyleXfs = xfs;\n }\n\n // cellXfs\n const cellXfsEl = findChild(el, \"cellXfs\");\n if (cellXfsEl) {\n const xfs: IndexedXfEntry[] = [];\n for (const xf of cellXfsEl.elements ?? []) {\n if (xf.name !== \"xf\") continue;\n const fontId = attrNum(xf, \"fontId\") ?? 0;\n const fillId = attrNum(xf, \"fillId\") ?? 0;\n const borderId = attrNum(xf, \"borderId\") ?? 0;\n const numFmtId = attrNum(xf, \"numFmtId\") ?? 0;\n\n const alignmentEl = findChild(xf, \"alignment\");\n const alignment = alignmentEl ? parseAlignment(alignmentEl) : undefined;\n\n const protectionEl = findChild(xf, \"protection\");\n const protection = protectionEl ? parseProtection(protectionEl) : undefined;\n\n const style: IndexedXfEntry = {};\n if (fontId > 0) style.fontId = fontId;\n if (fillId > 0) style.fillId = fillId;\n if (borderId > 0) style.borderId = borderId;\n if (numFmtId > 0) style.numFmtId = numFmtId;\n if (alignment) style.alignment = alignment;\n if (protection) style.protection = protection;\n if (attr(xf, \"quotePrefix\") === \"1\") style.quotePrefix = true;\n if (attr(xf, \"pivotButton\") === \"1\") style.pivotButton = true;\n\n xfs.push(style);\n }\n result.cellXfs = xfs;\n }\n\n // cellStyles\n const cellStylesEl = findChild(el, \"cellStyles\");\n if (cellStylesEl) {\n const styles: CustomCellStyleOptions[] = [];\n for (const cs of cellStylesEl.elements ?? []) {\n if (cs.name !== \"cellStyle\") continue;\n const style: Partial<CustomCellStyleOptions> = {};\n if (attr(cs, \"name\")) style.name = attr(cs, \"name\");\n const xfId = attrNum(cs, \"xfId\");\n if (xfId !== undefined) style.xfId = xfId;\n const builtinId = attrNum(cs, \"builtinId\");\n if (builtinId !== undefined) style.builtinId = builtinId;\n if (attr(cs, \"customBuiltin\") === \"1\") style.customBuiltin = true;\n if (attr(cs, \"hidden\") === \"1\") style.hidden = true;\n const iLevel = attrNum(cs, \"iLevel\");\n if (iLevel !== undefined) style.iLevel = iLevel;\n styles.push(style as CustomCellStyleOptions);\n }\n result.customCellStyles = styles;\n }\n\n // dxfs\n const dxfsEl = findChild(el, \"dxfs\");\n if (dxfsEl) {\n const dxfs: DxfOptions[] = [];\n for (const dxf of dxfsEl.elements ?? []) {\n if (dxf.name !== \"dxf\") continue;\n const d: DxfOptions = {};\n const fontEl = findChild(dxf, \"font\");\n if (fontEl) d.font = parseFont(fontEl);\n const fillEl = findChild(dxf, \"fill\");\n if (fillEl) d.fill = parseFill(fillEl);\n const borderEl = findChild(dxf, \"border\");\n if (borderEl) d.border = parseBorder(borderEl);\n const numFmtEl = findChild(dxf, \"numFmt\");\n if (numFmtEl && attr(numFmtEl, \"formatCode\")) d.numFmt = attr(numFmtEl, \"formatCode\");\n dxfs.push(d);\n }\n result.dxfs = dxfs;\n }\n\n // tableStyles\n const tableStylesEl = findChild(el, \"tableStyles\");\n if (tableStylesEl?.attributes) {\n const ts: TableStylesInfo = {};\n if (attr(tableStylesEl, \"count\") !== undefined)\n ts.count = attrNum(tableStylesEl, \"count\") ?? 0;\n if (attr(tableStylesEl, \"defaultTableStyle\"))\n ts.defaultTableStyle = attr(tableStylesEl, \"defaultTableStyle\");\n if (attr(tableStylesEl, \"defaultPivotStyle\"))\n ts.defaultPivotStyle = attr(tableStylesEl, \"defaultPivotStyle\");\n const customStyles: CustomTableStyleOptions[] = [];\n for (const tse of tableStylesEl.elements ?? []) {\n if (tse.name !== \"tableStyle\") continue;\n const style: Partial<CustomTableStyleOptions> = {};\n if (attr(tse, \"name\")) style.name = attr(tse, \"name\");\n if (attr(tse, \"pivot\") === \"1\") style.pivot = true;\n const elements: TableStyleElementOptions[] = [];\n for (const tsee of tse.elements ?? []) {\n if (tsee.name !== \"tableStyleElement\") continue;\n const elOpts: Partial<TableStyleElementOptions> = {};\n if (attr(tsee, \"type\")) elOpts.type = attr(tsee, \"type\") as TableStyleElementType;\n const dxfId = attrNum(tsee, \"dxfId\");\n if (dxfId !== undefined) elOpts.dxfId = dxfId;\n if (attr(tsee, \"button\") === \"1\") elOpts.button = true;\n elements.push(elOpts as TableStyleElementOptions);\n }\n if (elements.length > 0) style.elements = elements;\n customStyles.push(style as CustomTableStyleOptions);\n }\n if (customStyles.length > 0) ts.tableStyles = customStyles;\n result.tableStylesInfo = ts;\n }\n\n // colors\n const colorsEl = findChild(el, \"colors\");\n if (colorsEl) {\n const colors: ColorsOptions = {};\n const icEl = findChild(colorsEl, \"indexedColors\");\n if (icEl) {\n const indexed: IndexedColorOptions[] = [];\n for (const rgb of icEl.elements ?? []) {\n if (rgb.name === \"rgbColor\" && attr(rgb, \"rgb\")) {\n indexed.push({ rgb: attr(rgb, \"rgb\")! });\n }\n }\n colors.indexedColors = indexed;\n }\n const mruEl = findChild(colorsEl, \"mruColors\");\n if (mruEl) {\n const mru: string[] = [];\n for (const c of mruEl.elements ?? []) {\n if (c.name === \"color\") {\n const rgb = attr(c, \"rgb\");\n if (rgb) mru.push(rgb.length === 8 ? rgb.slice(2) : rgb);\n }\n }\n colors.mruColors = mru;\n }\n result.colors = colors;\n }\n\n // styleExtensions (extLst)\n const extLstEl = findChild(el, \"extLst\");\n if (extLstEl) {\n const exts: StyleExtensionOptions[] = [];\n for (const ext of extLstEl.elements ?? []) {\n if (ext.name !== \"ext\") continue;\n const uri = attr(ext, \"uri\");\n if (uri) {\n // Reconstruct the inner XML of the <ext> element verbatim\n const content = (ext.elements ?? []).map((e) => stringify(e)).join(\"\");\n exts.push({ uri, content: content || undefined });\n }\n }\n result.styleExtensions = exts;\n }\n\n return result as unknown as StylesDocOptions;\n },\n};\n\n// ── Parse helpers ──\n\nfunction parseFont(el: XmlElement): FontOptions {\n const result: Record<string, unknown> = {};\n for (const child of el.elements ?? []) {\n switch (child.name) {\n case \"b\":\n result.bold = true;\n break;\n case \"i\":\n result.italic = true;\n break;\n case \"u\":\n result.underline = true;\n break;\n case \"strike\":\n result.strike = true;\n break;\n case \"outline\":\n result.outline = true;\n break;\n case \"shadow\":\n result.shadow = true;\n break;\n case \"condense\":\n result.condense = true;\n break;\n case \"extend\":\n result.extend = true;\n break;\n case \"sz\":\n result.size = attrNum(child, \"val\");\n break;\n case \"color\":\n result.color = parseColorHex(child);\n break;\n case \"name\":\n result.font = attr(child, \"val\") ?? undefined;\n break;\n case \"charset\":\n result.charset = attrNum(child, \"val\");\n break;\n case \"family\":\n result.family = attrNum(child, \"val\");\n break;\n case \"vertAlign\":\n result.vertAlign = (attr(child, \"val\") as FontOptions[\"vertAlign\"]) ?? undefined;\n break;\n case \"scheme\":\n result.scheme = (attr(child, \"val\") as FontOptions[\"scheme\"]) ?? undefined;\n break;\n }\n }\n return result as unknown as FontOptions;\n}\n\nfunction parseFill(el: XmlElement): FillOptions {\n const patternFill = findChild(el, \"patternFill\");\n if (patternFill) {\n const result: FillOptions = {};\n const patternType = attr(patternFill, \"patternType\");\n if (patternType) result.patternType = patternType;\n const fg = findChild(patternFill, \"fgColor\");\n if (fg) result.color = parseColorHex(fg);\n const bg = findChild(patternFill, \"bgColor\");\n if (bg) result.bgColor = parseColorHex(bg);\n const indexed = fg ? attrNum(fg, \"indexed\") : undefined;\n if (indexed !== undefined) result.colorIndexed = indexed;\n return result;\n }\n\n const gradientFill = findChild(el, \"gradientFill\");\n if (gradientFill) {\n const result: FillOptions = { type: \"gradient\" };\n const gType = attr(gradientFill, \"type\");\n if (gType) result.gradientType = gType as FillOptions[\"gradientType\"];\n const degree = attrNum(gradientFill, \"degree\");\n if (degree !== undefined) result.gradientDegree = degree;\n const left = attrNum(gradientFill, \"left\");\n if (left !== undefined) result.gradientLeft = left;\n const right = attrNum(gradientFill, \"right\");\n if (right !== undefined) result.gradientRight = right;\n const top = attrNum(gradientFill, \"top\");\n if (top !== undefined) result.gradientTop = top;\n const bottom = attrNum(gradientFill, \"bottom\");\n if (bottom !== undefined) result.gradientBottom = bottom;\n const stops: GradientStopOptions[] = [];\n for (const s of gradientFill.elements ?? []) {\n if (s.name !== \"stop\") continue;\n const pos = attrNum(s, \"position\");\n const color = findChild(s, \"color\");\n if (pos !== undefined && color) {\n stops.push({ position: pos, color: parseColorHex(color) ?? \"\" });\n }\n }\n if (stops.length > 0) result.stops = stops;\n return result;\n }\n\n return {};\n}\n\nfunction parseBorder(el: XmlElement): BorderSideOptions {\n const result: Record<string, unknown> = {};\n if (attr(el, \"diagonalUp\") === \"1\") result.diagonalUp = true;\n if (attr(el, \"diagonalDown\") === \"1\") result.diagonalDown = true;\n\n for (const side of [\n \"left\",\n \"right\",\n \"top\",\n \"bottom\",\n \"diagonal\",\n \"start\",\n \"end\",\n \"vertical\",\n \"horizontal\",\n ] as const) {\n const sideEl = findChild(el, side);\n if (sideEl) {\n const opts: Record<string, unknown> = {};\n const style = attr(sideEl, \"style\");\n if (style) opts.style = style as BorderOptions[\"style\"];\n const color = findChild(sideEl, \"color\");\n if (color) opts.color = parseColorHex(color);\n if (Object.keys(opts).length > 0) result[side] = opts;\n }\n }\n\n return result as unknown as BorderSideOptions;\n}\n\nfunction parseAlignment(el: XmlElement): AlignmentOptions {\n const result: AlignmentOptions = {};\n const h = attr(el, \"horizontal\");\n if (h) result.horizontal = h as AlignmentOptions[\"horizontal\"];\n const v = attr(el, \"vertical\");\n if (v) result.vertical = v as AlignmentOptions[\"vertical\"];\n if (attr(el, \"wrapText\") === \"1\") result.wrapText = true;\n const rotation = attrNum(el, \"textRotation\");\n if (rotation !== undefined) result.textRotation = rotation;\n const indent = attrNum(el, \"indent\");\n if (indent !== undefined) result.indent = indent;\n const relativeIndent = attrNum(el, \"relativeIndent\");\n if (relativeIndent !== undefined) result.relativeIndent = relativeIndent;\n if (attr(el, \"justifyLastLine\") === \"1\") result.justifyLastLine = true;\n if (attr(el, \"shrinkToFit\") === \"1\") result.shrinkToFit = true;\n const readingOrder = attrNum(el, \"readingOrder\");\n if (readingOrder !== undefined) result.readingOrder = readingOrder;\n return result;\n}\n\nfunction parseProtection(el: XmlElement): CellProtectionOptions {\n const result: Record<string, unknown> = {};\n const locked = attr(el, \"locked\");\n if (locked !== undefined) result.locked = locked !== \"0\";\n const hidden = attr(el, \"hidden\");\n if (hidden !== undefined) result.hidden = hidden !== \"0\";\n return result as unknown as CellProtectionOptions;\n}\n\nfunction parseColorHex(el: XmlElement): string | undefined {\n const rgb = attr(el, \"rgb\");\n if (rgb) {\n // Strip alpha prefix if present (FF000000 → 000000)\n return rgb.length === 8 ? rgb.slice(2) : rgb;\n }\n return undefined;\n}\n","/**\n * Worksheet XML generation — pure functions for xl/worksheets/sheet{n}.xml.\n *\n * All interfaces and the zero-allocation string concatenation fast path\n * are preserved. The `Worksheet` class has been replaced by `buildWorksheetXml()`.\n *\n * @module\n */\n\nimport { derivePasswordHash } from \"@office-open/core\";\nimport type { ChartSpaceOptions } from \"@office-open/core\";\nimport type { CustomDescriptor } from \"@office-open/core/descriptor\";\nimport { attrs, attrsRaw, escapeXml, selfCloseElement } from \"@office-open/xml\";\nimport type { Element as XmlElement } from \"@office-open/xml\";\nimport { findChild, attr, attrNum, textOf } from \"@office-open/xml\";\n\nimport type { XlsxReadContext } from \"../context\";\nimport type { PivotTableOptions } from \"./pivot\";\nimport { buildRstXml } from \"./shared-strings\";\nimport type { SharedStrings } from \"./shared-strings\";\nimport type { Styles, StyleOptions } from \"./styles\";\nimport type { TableOptions } from \"./table\";\n\n// ── Option interfaces ──\n\nexport interface ColumnOptions {\n min: number;\n max: number;\n width?: number;\n hidden?: boolean;\n customWidth?: boolean;\n outlineLevel?: number;\n collapsed?: boolean;\n /** Best-fit column width (CT_Col @bestFit) */\n bestFit?: boolean;\n /** Phonetic text for CJK (CT_Col @phonetic) */\n phonetic?: boolean;\n}\n\nexport interface RowOptions {\n cells?: CellOptions[];\n height?: number;\n hidden?: boolean;\n rowNumber?: number;\n /** Spans for the row, e.g. \"1:15\" (CT_Row @spans) */\n spans?: string;\n /** Custom format applied (CT_Row @customFormat) */\n customFormat?: boolean;\n /** Thick top border (CT_Row @thickTop) */\n thickTop?: boolean;\n /** Thick bottom border (CT_Row @thickBot) */\n thickBot?: boolean;\n /** Phonetic text (CT_Row @ph) */\n ph?: boolean;\n}\n\n/** Rich text run properties (CT_RPrElt). */\nexport interface RichTextRunPropertiesOptions {\n /** Font name (CT_FontName → rFont) */\n font?: string;\n /** Character set (CT_IntProperty) */\n charset?: number;\n /** Font family (CT_IntProperty) */\n family?: number;\n /** Bold */\n bold?: boolean;\n /** Italic */\n italic?: boolean;\n /** Strikethrough */\n strike?: boolean;\n /** Outline */\n outline?: boolean;\n /** Shadow */\n shadow?: boolean;\n /** Condense */\n condense?: boolean;\n /** Extend */\n extend?: boolean;\n /** Font color (hex RGB, e.g. \"FF0000\") */\n color?: string;\n /** Font size in points */\n size?: number;\n /** Underline type */\n underline?: \"single\" | \"double\" | \"singleAccounting\" | \"doubleAccounting\" | \"none\";\n /** Vertical alignment */\n vertAlign?: \"superscript\" | \"subscript\" | \"baseline\";\n /** Font scheme */\n scheme?: \"major\" | \"minor\" | \"none\";\n}\n\n/** A single rich text run (CT_RElt). */\nexport interface RichTextRunOptions {\n /** Run properties (optional = inherits from parent) */\n properties?: RichTextRunPropertiesOptions;\n /** Run text content */\n text: string;\n}\n\n/** Phonetics run for CJK (CT_PhoneticRun → rPh). */\nexport interface PhoneticRunOptions {\n /** Start byte offset in base text */\n sb: number;\n /** End byte offset in base text */\n eb: number;\n /** Phonetic text */\n text: string;\n}\n\n/** Rich text content (CT_Rst). Either plain text or rich runs. */\nexport interface RichTextOptions {\n /** Plain text (mutually exclusive with runs) */\n text?: string;\n /** Rich text runs (mutually exclusive with text) */\n runs?: RichTextRunOptions[];\n /** Phonetic runs for CJK (CT_PhoneticRun) */\n phonetics?: PhoneticRunOptions[];\n}\n\nexport interface CellOptions {\n value?: string | number | boolean | Date | RichTextOptions | null;\n reference?: string;\n /** Direct style index (for pre-resolved styles) */\n styleIndex?: number;\n /** Style options (resolved to index at compile time) */\n style?: StyleOptions;\n /** Formula options. When set, value becomes the cached result. */\n formula?: FormulaOptions;\n}\n\n/** Cell formula type (maps to ST_CellFormulaType). */\nexport const FormulaType = {\n NORMAL: \"normal\",\n ARRAY: \"array\",\n SHARED: \"shared\",\n} as const;\n\nexport type FormulaType = (typeof FormulaType)[keyof typeof FormulaType];\n\n/** Options for a cell formula (maps to CT_CellFormula). */\nexport interface FormulaOptions {\n /** Formula expression, e.g. \"SUM(A1:B1)\" */\n formula: string;\n /** Formula type (default: \"normal\") */\n type?: FormulaType;\n /** Reference range for array/shared formulas, e.g. \"C1:C10\" */\n reference?: string;\n /** Shared formula group index (required for shared formulas) */\n sharedIndex?: number;\n /** Always calculate array (CT_CellFormula @aca) */\n aca?: boolean;\n /** 2-D data table (CT_CellFormula @dt2D) */\n dt2D?: boolean;\n /** Data table row (CT_CellFormula @dtr) */\n dtr?: boolean;\n /** Delete input cell 1 (CT_CellFormula @del1) */\n del1?: boolean;\n /** Delete input cell 2 (CT_CellFormula @del2) */\n del2?: boolean;\n /** Input cell 1 reference (CT_CellFormula @r1) */\n r1?: string;\n /** Input cell 2 reference (CT_CellFormula @r2) */\n r2?: string;\n /** Calculate cell (CT_CellFormula @ca) */\n ca?: boolean;\n /** Array formula context (CT_CellFormula @bx) */\n bx?: boolean;\n}\n\n/** Input cell for a what-if scenario (maps to CT_InputCells). */\nexport interface ScenarioCellOptions {\n /** Cell reference, e.g. \"B2\" */\n r: string;\n /** Cell value for this scenario */\n val: string | number;\n /** Whether the value is deleted */\n deleted?: boolean;\n /** Whether undone (CT_InputCells @undone) */\n undone?: boolean;\n}\n\n/** A single what-if scenario (maps to CT_Scenario). */\nexport interface ScenarioDefinition {\n /** Scenario name */\n name: string;\n /** Input cells with their values for this scenario */\n inputCells: ScenarioCellOptions[];\n /** Sort/order count */\n count?: number;\n /** Creator user name */\n user?: string;\n /** Comment */\n comment?: string;\n /** Whether the scenario is hidden */\n hidden?: boolean;\n /** Whether the scenario is locked */\n locked?: boolean;\n}\n\n/** Scenarios for what-if analysis (maps to CT_Scenarios). */\nexport interface ScenarioOptions {\n /** Named scenarios */\n scenarios: ScenarioDefinition[];\n /** Current scenario index (0-based) */\n current?: number;\n /** Show scenario index (0-based) */\n show?: number;\n}\n\nexport interface MergeCellOptions {\n from: { row: number; col: number };\n to: { row: number; col: number };\n}\n\nexport interface SheetProtectionOptions {\n /** Plain-text password — legacy Excel hash is computed automatically */\n password?: string;\n /** Modern encryption: algorithm name (e.g. \"SHA-512\") */\n algorithmName?: string;\n /** Modern encryption: base64-encoded hash value */\n hashValue?: string;\n /** Modern encryption: base64-encoded salt value */\n saltValue?: string;\n /** Modern encryption: spin count for hash iteration */\n spinCount?: number;\n /** Set true to enable sheet protection (required for protection flags to take effect) */\n sheet?: boolean;\n objects?: boolean;\n scenarios?: boolean;\n formatCells?: boolean;\n formatColumns?: boolean;\n formatRows?: boolean;\n insertColumns?: boolean;\n insertRows?: boolean;\n insertHyperlinks?: boolean;\n deleteColumns?: boolean;\n deleteRows?: boolean;\n selectLockedCells?: boolean;\n sort?: boolean;\n autoFilter?: boolean;\n pivotTables?: boolean;\n selectUnlockedCells?: boolean;\n}\n\n/** A named protected range within a sheet (CT_ProtectedRange) */\nexport interface ProtectedRangeOptions {\n /** Range reference (required), e.g. \"A1:C10\" */\n sqref: string;\n /** Range name (required) */\n name: string;\n /** Plain-text password — legacy hash computed automatically */\n password?: string;\n /** Modern encryption: algorithm name */\n algorithmName?: string;\n /** Modern encryption: base64-encoded hash value */\n hashValue?: string;\n /** Modern encryption: base64-encoded salt value */\n saltValue?: string;\n /** Modern encryption: spin count */\n spinCount?: number;\n /** Security descriptor (SID string) */\n securityDescriptor?: string;\n}\n\nexport interface FreezePaneOptions {\n /** Row split position (1-based, freezes rows above) */\n row?: number;\n /** Column split position (1-based, freezes columns to the left) */\n col?: number;\n}\n\nexport interface WorksheetImageOptions {\n data: Uint8Array;\n type: \"png\" | \"jpg\";\n col: number;\n row: number;\n}\n\nexport interface WorksheetChartOptions extends ChartSpaceOptions {\n /** 1-based column position for the chart */\n col: number;\n /** 1-based row position for the chart */\n row: number;\n}\n\nexport interface SheetViewOptions {\n showGridLines?: boolean;\n showRowColHeaders?: boolean;\n showZeros?: boolean;\n zoomScale?: number;\n tabSelected?: boolean;\n rightToLeft?: boolean;\n /** Window protection (CT_SheetView @windowProtection) */\n windowProtection?: boolean;\n /** Show formulas instead of values (CT_SheetView @showFormulas) */\n showFormulas?: boolean;\n /** Show ruler (CT_SheetView @showRuler) */\n showRuler?: boolean;\n /** Show outline symbols (CT_SheetView @showOutlineSymbols) */\n showOutlineSymbols?: boolean;\n /** Default grid color (CT_SheetView @defaultGridColor) */\n defaultGridColor?: boolean;\n /** Show white space (CT_SheetView @showWhiteSpace) */\n showWhiteSpace?: boolean;\n /** View type (CT_SheetView @view) */\n view?: \"normal\" | \"pageBreakPreview\" | \"pageLayout\";\n /** Tab color ID (CT_SheetView @colorId) */\n colorId?: number;\n /** Zoom scale for normal view (CT_SheetView @zoomScaleNormal) */\n zoomScaleNormal?: number;\n /** Zoom scale for sheet layout view (CT_SheetView @zoomScaleSheetLayoutView) */\n zoomScaleSheetLayoutView?: number;\n /** Zoom scale for page layout view (CT_SheetView @zoomScalePageLayoutView) */\n zoomScalePageLayoutView?: number;\n /** Pivot selections (CT_PivotSelection) */\n pivotSelections?: PivotSelectionOptions[];\n}\n\n/** Pivot selection in sheet view (CT_PivotSelection) */\nexport interface PivotSelectionOptions {\n /** Pane (default: \"topLeft\") */\n pane?: \"bottomRight\" | \"topRight\" | \"bottomLeft\" | \"topLeft\";\n /** Show header (default: false) */\n showHeader?: boolean;\n /** Label selected (default: false) */\n label?: boolean;\n /** Data selected (default: false) */\n data?: boolean;\n /** Extendable (default: false) */\n extendable?: boolean;\n /** Selection count */\n count?: number;\n /** Axis */\n axis?: \"axisRow\" | \"axisCol\" | \"axisPage\" | \"axisValues\";\n /** Dimension */\n dimension?: number;\n /** Start index */\n start?: number;\n /** Min index */\n min?: number;\n /** Max index */\n max?: number;\n /** Active row */\n activeRow?: number;\n /** Active column */\n activeCol?: number;\n /** Previous row */\n previousRow?: number;\n /** Previous column */\n previousCol?: number;\n /** Clicked row */\n click?: number;\n /** Relationship ID (maps to r:id in XML) */\n rId?: string;\n}\n\nexport type HyperlinkTarget =\n | { type: \"external\"; url: string }\n | { type: \"internal\"; location: string };\n\nexport interface HyperlinkOptions {\n /** Cell reference, e.g. \"A1\" */\n cell: string;\n /** Hyperlink target */\n target: HyperlinkTarget;\n /** Tooltip text */\n tooltip?: string;\n /** Display text */\n display?: string;\n}\n\nexport interface HeaderFooterOptions {\n oddHeader?: string;\n oddFooter?: string;\n evenHeader?: string;\n evenFooter?: string;\n firstHeader?: string;\n firstFooter?: string;\n differentOddEven?: boolean;\n differentFirst?: boolean;\n /** Scale header/footer with document (CT_HeaderFooter @scaleWithDoc) */\n scaleWithDoc?: boolean;\n /** Align with page margins (CT_HeaderFooter @alignWithMargins) */\n alignWithMargins?: boolean;\n}\n\nexport type PageOrientation = \"default\" | \"portrait\" | \"landscape\";\n\nexport interface PageSetupOptions {\n paperSize?: number;\n orientation?: PageOrientation;\n scale?: number;\n fitToWidth?: number;\n fitToHeight?: number;\n pageOrder?: \"downThenOver\" | \"overThenDown\";\n useFirstPageNumber?: boolean;\n firstPageNumber?: number;\n /** Paper height (CT_PageSetup @paperHeight) */\n paperHeight?: number;\n /** Paper width (CT_PageSetup @paperWidth) */\n paperWidth?: number;\n /** Use printer defaults (CT_PageSetup @usePrinterDefaults) */\n usePrinterDefaults?: boolean;\n /** Black and white printing (CT_PageSetup @blackAndWhite) */\n blackAndWhite?: boolean;\n /** Draft quality printing (CT_PageSetup @draft) */\n draft?: boolean;\n /** Print cell comments mode (CT_PageSetup @cellComments) */\n cellComments?: \"none\" | \"asDisplayed\" | \"atEnd\";\n /** Print error display mode (CT_PageSetup @errors) */\n errors?: \"displayed\" | \"blank\" | \"dash\" | \"NA\";\n /** Auto page breaks (CT_PageSetUpPr @autoPageBreaks) */\n autoPageBreaks?: boolean;\n /** Fit to page (CT_PageSetUpPr @fitToPage) */\n fitToPage?: boolean;\n}\n\nexport interface TabColorOptions {\n /** RGB color string, e.g. \"FF0000\" */\n rgb?: string;\n /** Theme color index (0-based) */\n theme?: number;\n /** Tint value (-1.0 to 1.0) */\n tint?: number;\n /** Indexed color (CT_Color @indexed) */\n indexed?: number;\n}\n\n/** Object anchor (CT_ObjectAnchor). */\nexport interface ObjectAnchorOptions {\n /** Move with cells (default: false) */\n moveWithCells?: boolean;\n /** Size with cells (default: false) */\n sizeWithCells?: boolean;\n}\n\n/** Comment property (CT_CommentPr). */\nexport interface CommentPropertiesOptions {\n /** Locked */\n locked?: boolean;\n /** Default size */\n defaultSize?: boolean;\n /** Print */\n print?: boolean;\n /** Disabled */\n disabled?: boolean;\n /** Auto fill */\n autoFill?: boolean;\n /** Auto line */\n autoLine?: boolean;\n /** Alt text */\n altText?: string;\n /** Text horizontal alignment */\n textHAlign?: \"left\" | \"center\" | \"right\" | \"justify\" | \"distributed\";\n /** Text vertical alignment */\n textVAlign?: \"top\" | \"center\" | \"bottom\" | \"justify\" | \"distributed\";\n /** Lock text */\n lockText?: boolean;\n /** Justify last line */\n justLastX?: boolean;\n /** Auto scale */\n autoScale?: boolean;\n /** Object anchor position */\n anchor?: ObjectAnchorOptions;\n}\n\nexport interface CommentOptions {\n /** Cell reference, e.g. \"A1\" */\n cell: string;\n /** Author name */\n author: string;\n /** Comment text (plain string or rich text) */\n text: string | RichTextOptions;\n /** Comment properties (CT_CommentPr) */\n commentPr?: CommentPropertiesOptions;\n}\n\nexport type DataValidationType =\n | \"none\"\n | \"whole\"\n | \"decimal\"\n | \"list\"\n | \"date\"\n | \"time\"\n | \"textLength\"\n | \"custom\";\nexport type DataValidationOperator =\n | \"between\"\n | \"notBetween\"\n | \"equal\"\n | \"notEqual\"\n | \"greaterThan\"\n | \"lessThan\"\n | \"greaterThanOrEqual\"\n | \"lessThanOrEqual\";\n\nexport interface DataValidationOptions {\n /** Cell range, e.g. \"A1:A10\" */\n sqref: string;\n type?: DataValidationType;\n operator?: DataValidationOperator;\n formula1?: string;\n formula2?: string;\n allowBlank?: boolean;\n showErrorMessage?: boolean;\n errorTitle?: string;\n error?: string;\n showInputMessage?: boolean;\n promptTitle?: string;\n prompt?: string;\n /** Error style (CT_DataValidation @errorStyle) */\n errorStyle?: \"stop\" | \"warning\" | \"information\";\n /** IME mode (CT_DataValidation @imeMode) */\n imeMode?:\n | \"noControl\"\n | \"on\"\n | \"off\"\n | \"disabled\"\n | \"hiragana\"\n | \"fullKatakana\"\n | \"halfKatakana\"\n | \"fullAlpha\"\n | \"halfAlpha\"\n | \"fullHangul\"\n | \"halfHangul\";\n /** Show drop-down (CT_DataValidation @showDropDown — note inverted semantics in OOXML) */\n showDropDown?: boolean;\n}\n\nexport type ConditionalFormatType =\n | \"cellIs\"\n | \"containsText\"\n | \"expression\"\n | \"top10\"\n | \"aboveAverage\"\n | \"colorScale\"\n | \"dataBar\"\n | \"iconSet\";\nexport type ConditionalFormatOperator =\n | \"lessThan\"\n | \"lessThanOrEqual\"\n | \"equal\"\n | \"notEqual\"\n | \"greaterThanOrEqual\"\n | \"greaterThan\"\n | \"between\"\n | \"notBetween\"\n | \"containsText\"\n | \"notContains\"\n | \"beginsWith\"\n | \"endsWith\";\n\n/** Conditional format value object type (ST_CfvoType) */\nexport type CfvoType = \"num\" | \"percent\" | \"max\" | \"min\" | \"formula\" | \"percentile\";\n\n/** Conditional format value object */\nexport interface CfvoOptions {\n type: CfvoType;\n val?: string | number;\n /** Greater than or equal (default: true) */\n gte?: boolean;\n}\n\n/** Icon set type (ST_IconSetType) */\nexport type IconSetType =\n | \"3Arrows\"\n | \"3ArrowsGray\"\n | \"3Flags\"\n | \"3TrafficLights1\"\n | \"3TrafficLights2\"\n | \"3Signs\"\n | \"3Symbols\"\n | \"3Symbols2\"\n | \"4Arrows\"\n | \"4ArrowsGray\"\n | \"4RedToBlack\"\n | \"4Rating\"\n | \"4TrafficLights\"\n | \"5Arrows\"\n | \"5ArrowsGray\"\n | \"5Rating\"\n | \"5Quarters\";\n\n/** Color scale rule configuration */\nexport interface ColorScaleOptions {\n /** Conditional format values (minimum 2, typically 2 or 3) */\n cfvo: CfvoOptions[];\n /** Colors for each value (same count as cfvo) — RGB hex without alpha, e.g. \"FF0000\" */\n colors: string[];\n}\n\n/** Data bar rule configuration */\nexport interface DataBarOptions {\n /** Minimum and maximum value objects (exactly 2) */\n cfvo: [CfvoOptions, CfvoOptions];\n /** Bar color — RGB hex without alpha, e.g. \"638EC6\" */\n color: string;\n /** Minimum bar length as percentage (default: 10) */\n minLength?: number;\n /** Maximum bar length as percentage (default: 90) */\n maxLength?: number;\n /** Whether to show cell values (default: true) */\n showValue?: boolean;\n}\n\n/** Icon set rule configuration */\nexport interface IconSetOptions {\n /** Conditional format values (minimum 2) */\n cfvo: CfvoOptions[];\n /** Icon set type (default: \"3TrafficLights1\") */\n iconSet?: IconSetType;\n /** Whether to show cell values (default: true) */\n showValue?: boolean;\n /** Whether values are percentages (default: true) */\n percent?: boolean;\n /** Whether to reverse icon order (default: false) */\n reverse?: boolean;\n}\n\nexport interface ConditionalFormatRule {\n type: ConditionalFormatType;\n operator?: ConditionalFormatOperator;\n /** Formula(s) — up to 3 */\n formulas?: string[];\n priority?: number;\n /** Reference to a dxf (differential format) in the styles table */\n dxfId?: number;\n /** Color scale configuration (when type is \"colorScale\") */\n colorScale?: ColorScaleOptions;\n /** Data bar configuration (when type is \"dataBar\") */\n dataBar?: DataBarOptions;\n /** Icon set configuration (when type is \"iconSet\") */\n iconSet?: IconSetOptions;\n /** Stop if true — skip remaining rules (CT_CfRule @stopIfTrue) */\n stopIfTrue?: boolean;\n /** Time period for date-based highlighting (CT_CfRule @timePeriod) */\n timePeriod?:\n | \"today\"\n | \"yesterday\"\n | \"tomorrow\"\n | \"last7Days\"\n | \"thisMonth\"\n | \"lastMonth\"\n | \"nextMonth\"\n | \"thisWeek\"\n | \"lastWeek\"\n | \"nextWeek\";\n /** Rank for top/bottom rules (CT_CfRule @rank) */\n rank?: number;\n /** Equal average flag (CT_CfRule @equalAverage) */\n equalAverage?: boolean;\n}\n\nexport interface ConditionalFormatOptions {\n /** Cell range, e.g. \"A1:A10\" */\n sqref: string;\n rules: ConditionalFormatRule[];\n}\n\nexport interface Top10FilterOptions {\n colId: number;\n top?: boolean;\n percent?: boolean;\n val: number;\n /** Filter value (CT_Top10 @filterVal) */\n filterVal?: number;\n /** Hide auto-filter button (CT_FilterColumn @hiddenButton) */\n hiddenButton?: boolean;\n /** Show filter button (CT_FilterColumn @showButton) */\n showButton?: boolean;\n}\n\nexport interface CustomFilterOptions {\n colId: number;\n operator?:\n | \"equal\"\n | \"notEqual\"\n | \"greaterThan\"\n | \"greaterThanOrEqual\"\n | \"lessThan\"\n | \"lessThanOrEqual\";\n val?: string;\n and?: boolean;\n val2?: string;\n /** Hide auto-filter button (CT_FilterColumn @hiddenButton) */\n hiddenButton?: boolean;\n /** Show filter button (CT_FilterColumn @showButton) */\n showButton?: boolean;\n}\n\nexport interface SortCondition {\n /** Cell reference for the sort column, e.g. \"B1\" */\n ref: string;\n descending?: boolean;\n /** Sort by (CT_SortCondition @sortBy) */\n sortBy?: \"value\" | \"cellColor\" | \"fontColor\" | \"icon\";\n /** Custom sort list (CT_SortCondition @customList) */\n customList?: string;\n /** Icon set index (CT_SortCondition @iconId) */\n iconId?: number;\n}\n\nexport interface AutoFilterOptions {\n /** Range, e.g. \"A1:D10\" */\n ref: string;\n top10?: Top10FilterOptions[];\n customFilters?: CustomFilterOptions[];\n sort?: SortCondition[];\n /** Sort state options */\n sortState?: SortStateOptions;\n /** Color filters (CT_ColorFilter) */\n colorFilters?: ColorFilterOptions[];\n /** Icon filters (CT_IconFilter) */\n iconFilters?: IconFilterOptions[];\n /** Dynamic filters (CT_DynamicFilter) */\n dynamicFilters?: DynamicFilterOptions[];\n /** Date group items in filters (CT_DateGroupItem) */\n dateGroupItems?: DateGroupFilterOptions[];\n /** Simple filters with values (CT_Filters) */\n filters?: FilterItemsOptions[];\n}\n\n/** Color filter (CT_ColorFilter) */\nexport interface ColorFilterOptions {\n /** Column ID */\n colId: number;\n /** Cell color RGB (dxfId used if not set) */\n dxfId?: number;\n /** Filter by cell color (CT_ColorFilter @cellColor) */\n cellColor?: boolean;\n}\n\n/** Icon filter (CT_IconFilter) */\nexport interface IconFilterOptions {\n /** Column ID */\n colId: number;\n /** Icon set index (CT_IconFilter @iconSet) */\n iconSet: number;\n /** Icon ID within set (CT_IconFilter @iconId) */\n iconId?: number;\n}\n\n/** Filter items (CT_Filters) */\nexport interface FilterItemsOptions {\n /** Column ID */\n colId: number;\n /** Blank filter (CT_Filters @blank) */\n blank?: boolean;\n /** Calendar type (CT_Filters @calendarType) */\n calendarType?: string;\n /** Filter values */\n values?: string[];\n}\n\n/** Dynamic filter (CT_DynamicFilter) */\nexport interface DynamicFilterOptions {\n /** Column ID */\n colId: number;\n /** Dynamic filter type (CT_DynamicFilter @type) */\n type:\n | \"null\"\n | \"aboveAverage\"\n | \"belowAverage\"\n | \"tomorrow\"\n | \"today\"\n | \"yesterday\"\n | \"nextWeek\"\n | \"thisWeek\"\n | \"lastWeek\"\n | \"nextMonth\"\n | \"thisMonth\"\n | \"lastMonth\"\n | \"nextQuarter\"\n | \"thisQuarter\"\n | \"lastQuarter\"\n | \"nextYear\"\n | \"thisYear\"\n | \"lastYear\"\n | \"yearToDate\"\n | \"Q1\"\n | \"Q2\"\n | \"Q3\"\n | \"Q4\"\n | \"M1\"\n | \"M2\"\n | \"M3\"\n | \"M4\"\n | \"M5\"\n | \"M6\"\n | \"M7\"\n | \"M8\"\n | \"M9\"\n | \"M10\"\n | \"M11\"\n | \"M12\";\n /** Max value (CT_DynamicFilter @val) */\n val?: number;\n /** Max value as date ISO string (CT_DynamicFilter @maxVal) */\n maxVal?: number;\n /** Value ISO date string (CT_DynamicFilter @valIso) */\n valIso?: string;\n /** Max value ISO date string (CT_DynamicFilter @maxValIso) */\n maxValIso?: string;\n}\n\n/** Date group filter item (CT_DateGroupItem) */\nexport interface DateGroupFilterOptions {\n /** Column ID */\n colId: number;\n /** Date grouping level (CT_DateGroupItem @dateTimeGrouping) */\n dateTimeGrouping: \"year\" | \"month\" | \"day\" | \"hour\" | \"minute\" | \"second\";\n /** Year (CT_DateGroupItem @year) */\n year?: number;\n /** Month (1-12, CT_DateGroupItem @month) */\n month?: number;\n /** Day (1-31, CT_DateGroupItem @day) */\n day?: number;\n /** Hour (0-23, CT_DateGroupItem @hour) */\n hour?: number;\n /** Minute (0-59, CT_DateGroupItem @minute) */\n minute?: number;\n /** Second (0-59, CT_DateGroupItem @second) */\n second?: number;\n}\n\n/** Sort state configuration (CT_SortState) */\nexport interface SortStateOptions {\n /** Column sort mode (CT_SortState @columnSort) */\n columnSort?: boolean;\n /** Case sensitive sorting (CT_SortState @caseSensitive) */\n caseSensitive?: boolean;\n /** Sort method (CT_SortState @sortMethod) */\n sortMethod?: \"pinYin\" | \"stroke\";\n}\n\n/** Print options (CT_PrintOptions) */\nexport interface PrintOptions {\n /** Center horizontally on page */\n horizontalCentered?: boolean;\n /** Center vertically on page */\n verticalCentered?: boolean;\n /** Print row/column headings */\n headings?: boolean;\n /** Print grid lines */\n gridLines?: boolean;\n /** Grid lines set flag */\n gridLinesSet?: boolean;\n}\n\n/** Sheet format properties (CT_SheetFormatPr) */\nexport interface SheetFormatPropertiesOptions {\n /** Base column width (CT_SheetFormatPr @baseColWidth) */\n baseColWidth?: number;\n /** Default column width (CT_SheetFormatPr @defaultColWidth) */\n defaultColWidth?: number;\n /** Default row height */\n defaultRowHeight?: number;\n /** Zero height rows hidden (CT_SheetFormatPr @zeroHeight) */\n zeroHeight?: boolean;\n /** Thick top borders (CT_SheetFormatPr @thickTop) */\n thickTop?: boolean;\n /** Thick bottom borders (CT_SheetFormatPr @thickBottom) */\n thickBottom?: boolean;\n /** Outline level row (CT_SheetFormatPr @outlineLevelRow) */\n outlineLevelRow?: number;\n /** Outline level column (CT_SheetFormatPr @outlineLevelCol) */\n outlineLevelCol?: number;\n}\n\n/** Sheet properties extended options (CT_SheetPr attributes) */\nexport interface SheetPropertiesOptions {\n /** Sync horizontal scroll (CT_SheetPr @syncHorizontal) */\n syncHorizontal?: boolean;\n /** Sync vertical scroll (CT_SheetPr @syncVertical) */\n syncVertical?: boolean;\n /** Sync reference (CT_SheetPr @syncRef) */\n syncRef?: string;\n /** Transition evaluation mode (CT_SheetPr @transitionEvaluation) */\n transitionEvaluation?: boolean;\n /** Transition entry mode (CT_SheetPr @transitionEntry) */\n transitionEntry?: boolean;\n /** Published to server (CT_SheetPr @published) */\n published?: boolean;\n /** Filter mode (CT_SheetPr @filterMode) */\n filterMode?: boolean;\n /** Enable format conditions calculation (CT_SheetPr @enableFormatConditionsCalculation) */\n enableFormatConditionsCalculation?: boolean;\n /** Outline apply styles (CT_OutlinePr @applyStyles) */\n outlineApplyStyles?: boolean;\n /** Outline show symbols (CT_OutlinePr @showOutlineSymbols) */\n outlineShowSymbols?: boolean;\n /** Outline summary rows below detail (CT_OutlinePr @summaryBelow) */\n outlineSummaryBelow?: boolean;\n /** Outline summary columns right of detail (CT_OutlinePr @summaryRight) */\n outlineSummaryRight?: boolean;\n}\n\n/** An ignored error entry — suppresses specific Excel error checks for a range. */\nexport interface IgnoredErrorOptions {\n /** Cell range, e.g. \"A1:A10\" (required) */\n sqref: string;\n evalError?: boolean;\n twoDigitTextYear?: boolean;\n numberStoredAsText?: boolean;\n formula?: boolean;\n formulaRange?: boolean;\n unlockedFormula?: boolean;\n emptyCellReference?: boolean;\n listDataValidation?: boolean;\n calculatedColumn?: boolean;\n}\n\n/** Phonetic properties for CJK text (CT_PhoneticPr) */\nexport interface PhoneticPropertiesOptions {\n /** Font ID from the styles table (required) */\n fontId: number;\n /** Phonetic type (default: \"fullwidthKatakana\") */\n type?: \"fullwidthKatakana\" | \"halfwidthKatakana\" | \"Hiragana\" | \"noConversion\";\n /** Alignment (default: \"left\") */\n alignment?: \"left\" | \"center\" | \"distributed\";\n}\n\n/** Background image for a worksheet */\nexport interface SheetBackgroundImageOptions {\n data: Uint8Array;\n type: \"png\" | \"jpg\";\n}\n\n/** Page break entry (CT_Break) */\nexport interface PageBreakOptions {\n /** Row or column ID (1-based) */\n id: number;\n /** Min value (CT_Break @min) */\n min?: number;\n /** Max value (CT_Break @max) */\n max?: number;\n /** Manual break (CT_Break @man) */\n manual?: boolean;\n /** Pivot break (CT_Break @pt) */\n pivot?: boolean;\n}\n\n/** Selection in sheet view (CT_Selection) */\nexport interface SelectionOptions {\n /** Pane (CT_Selection @pane) */\n pane?: \"bottomRight\" | \"topRight\" | \"bottomLeft\" | \"topLeft\";\n /** Active cell (CT_Selection @activeCell) */\n activeCell?: string;\n /** Active cell index (CT_Selection @activeCellId) */\n activeCellId?: number;\n /** Selected range (CT_Selection @sqref) */\n sqref?: string;\n}\n\n/** Custom sheet view (CT_CustomSheetView) */\nexport interface CustomSheetViewOptions {\n /** GUID identifier (required, CT_CustomSheetView @guid) */\n guid: string;\n /** Zoom scale (CT_CustomSheetView @scale) */\n scale?: number;\n /** Show page breaks (CT_CustomSheetView @showPageBreaks) */\n showPageBreaks?: boolean;\n /** Show formulas (CT_CustomSheetView @showFormulas) */\n showFormulas?: boolean;\n /** Show grid lines (CT_CustomSheetView @showGridLines) */\n showGridLines?: boolean;\n /** Show row/column headers (CT_CustomSheetView @showRowCol) */\n showRowColHeaders?: boolean;\n /** Show outline symbols (CT_CustomSheetView @outlineSymbols) */\n outlineSymbols?: boolean;\n /** Show zero values (CT_CustomSheetView @zeroValues) */\n zeroValues?: boolean;\n /** Fit to page (CT_CustomSheetView @fitToPage) */\n fitToPage?: boolean;\n /** Print area (CT_CustomSheetView @printArea) */\n printArea?: boolean;\n /** Filter applied (CT_CustomSheetView @filter) */\n filter?: boolean;\n /** Show auto filter (CT_CustomSheetView @showAutoFilter) */\n showAutoFilter?: boolean;\n /** Hidden rows (CT_CustomSheetView @hiddenRows) */\n hiddenRows?: boolean;\n /** Hidden columns (CT_CustomSheetView @hiddenColumns) */\n hiddenColumns?: boolean;\n /** Sheet state (CT_CustomSheetView @state) */\n state?: \"visible\" | \"hidden\" | \"veryHidden\";\n /** Filter unique (CT_CustomSheetView @filterUnique) */\n filterUnique?: boolean;\n /** View type (CT_CustomSheetView @view) */\n view?: \"normal\" | \"pageBreakPreview\" | \"pageLayout\";\n}\n\n/** Cell watch entry (CT_CellWatch) */\nexport interface CellWatchOptions {\n /** Cell reference, e.g. \"A1\" */\n r: string;\n}\n\n/** Data consolidation (CT_DataConsolidate) */\nexport interface DataConsolidateOptions {\n /** Consolidation function (CT_DataConsolidate @function) */\n function?:\n | \"average\"\n | \"count\"\n | \"countNums\"\n | \"max\"\n | \"min\"\n | \"product\"\n | \"stdDev\"\n | \"stdDevp\"\n | \"sum\"\n | \"var\"\n | \"varp\";\n /** Use top row labels (CT_DataConsolidate @startLabels) */\n topLabels?: boolean;\n /** Use left column labels (CT_DataConsolidate @leftLabels) */\n leftLabels?: boolean;\n /** Use labels in first row (CT_DataConsolidate @startLabels alias) */\n startLabels?: boolean;\n /** Link to source data (CT_DataConsolidate @link) */\n link?: boolean;\n /** Source data references */\n refs?: string[];\n}\n\n/** Drawing in header/footer (CT_DrawingHF) */\nexport interface DrawingHfOptions {\n /** Relationship ID for the drawing (required) */\n rId: string;\n lho?: number;\n lhe?: number;\n lhf?: number;\n cho?: number;\n che?: number;\n chf?: number;\n rho?: number;\n rhe?: number;\n rhf?: number;\n lfo?: number;\n lfe?: number;\n lff?: number;\n cfo?: number;\n cfe?: number;\n cff?: number;\n rfo?: number;\n rfe?: number;\n rff?: number;\n}\n\nexport interface WorksheetOptions {\n name?: string;\n rows?: RowOptions[];\n columns?: ColumnOptions[];\n mergeCells?: MergeCellOptions[];\n freezePanes?: FreezePaneOptions;\n protection?: SheetProtectionOptions;\n /** Named protected ranges within this sheet */\n protectedRanges?: ProtectedRangeOptions[];\n /** What-if scenarios */\n scenarios?: ScenarioOptions;\n /** Auto-filter configuration */\n autoFilter?: string | AutoFilterOptions;\n images?: WorksheetImageOptions[];\n charts?: WorksheetChartOptions[];\n dataValidations?: DataValidationOptions[];\n /** Disable data validation prompts (CT_DataValidations @disablePrompts) */\n dataValidationsDisablePrompts?: boolean;\n conditionalFormats?: ConditionalFormatOptions[];\n hyperlinks?: HyperlinkOptions[];\n comments?: CommentOptions[];\n headerFooter?: HeaderFooterOptions;\n pageSetup?: PageSetupOptions;\n tabColor?: TabColorOptions;\n sheetView?: SheetViewOptions;\n pivotTables?: PivotTableOptions[];\n /** Tables (list objects) for this worksheet */\n tables?: TableOptions[];\n /** Ignored errors — suppress specific Excel error checks for cell ranges */\n ignoredErrors?: IgnoredErrorOptions[];\n /** Phonetic properties for CJK text */\n phoneticPr?: PhoneticPropertiesOptions;\n /** Background image for the worksheet */\n backgroundImage?: SheetBackgroundImageOptions;\n /** Print options (CT_PrintOptions) */\n printOptions?: PrintOptions;\n /** Sheet format properties (CT_SheetFormatPr) */\n sheetFormatPr?: SheetFormatPropertiesOptions;\n /** Sheet extended properties (CT_SheetPr attributes) */\n sheetPr?: SheetPropertiesOptions;\n /** Row page breaks (CT_PageBreaks) */\n rowBreaks?: PageBreakOptions[];\n /** Column page breaks (CT_PageBreaks) */\n colBreaks?: PageBreakOptions[];\n /** Custom sheet views (CT_CustomSheetViews) */\n customSheetViews?: CustomSheetViewOptions[];\n /** Cell watches (CT_CellWatches) */\n cellWatches?: CellWatchOptions[];\n /** Data consolidation (CT_DataConsolidate) */\n dataConsolidate?: DataConsolidateOptions;\n /** OLE embedded range (CT_OleSize) */\n oleSize?: string;\n /** Drawing in header/footer (CT_DrawingHF) */\n drawingHF?: DrawingHfOptions;\n /** Legacy drawing for header/footer r:id (CT_LegacyDrawingHF) */\n legacyDrawingHF?: string;\n /** Selection in sheet view (CT_Selection) */\n selection?: SelectionOptions;\n /** Sheet calc properties (CT_SheetCalcPr) */\n sheetCalcPr?: SheetCalculationPropertiesOptions;\n /** Extension list (extLst) */\n ext?: string;\n /** Control objects (CT_Controls) */\n controls?: ControlOptions[];\n /** Custom sheet properties (CT_CustomProperties) */\n customProperties?: CustomPropertyOptions[];\n /** OLE objects (CT_OleObjects) */\n oleObjects?: OleObjectOptions[];\n /** Web publish items (CT_WebPublishItems) */\n webPublishItems?: WebPublishItemOptions[];\n}\n\n/** Sheet calc properties (CT_SheetCalcPr) */\nexport interface SheetCalculationPropertiesOptions {\n /** Full calc on load (CT_SheetCalcPr @fullCalcOnLoad) */\n fullCalcOnLoad?: boolean;\n}\n\n/** Form control object (CT_Control) */\nexport interface ControlOptions {\n /** Shape ID (CT_Control @shapeId) */\n shapeId: number;\n /** Control r:id (CT_ControlPr @r:id) */\n rId: string;\n /** Control name (CT_ControlPr @name) */\n name?: string;\n /** Locked (CT_ControlPr @locked) */\n locked?: boolean;\n /** UI-locked (CT_ControlPr @uiObject) */\n uiObject?: boolean;\n /** Recalc always (CT_ControlPr @recalcAlways) */\n recalcAlways?: boolean;\n /** Linked cell (CT_ControlPr @linkedCell) */\n linkedCell?: string;\n /** List fill range (CT_ControlPr @listFillRange) */\n listFillRange?: string;\n /** Control formula (CT_ControlPr @cf) */\n cf?: string;\n}\n\n/** Custom property (CT_CustomProperty) */\nexport interface CustomPropertyOptions {\n /** Property name */\n name: string;\n /** Relationship ID to binary data */\n rId: string;\n}\n\n/** OLE object (CT_OleObject) */\nexport interface OleObjectOptions {\n /** Program ID (CT_OleObject @progId) */\n progId?: string;\n /** Display aspect (CT_OleObject @dvAspect) */\n dvAspect?: \"DVASPECT_CONTENT\" | \"DVASPECT_ICON\";\n /** Linked source (CT_OleObject @link) */\n link?: string;\n /** OLE update mode (CT_OleObject @oleUpdate) */\n oleUpdate?: \"OLEUPDATE_ALWAYS\" | \"OLEUPDATE_ONCALL\";\n /** Auto load (CT_OleObject @autoLoad) */\n autoLoad?: boolean;\n /** Shape ID (CT_OleObject @shapeId) */\n shapeId: number;\n /** Relationship ID (CT_OleObject @r:id) */\n rId?: string;\n /** Object properties (CT_ObjectPr) */\n objectPr?: OleObjectPropertiesOptions;\n}\n\n/** OLE object properties (CT_ObjectPr) */\nexport interface OleObjectPropertiesOptions {\n /** Locked */\n locked?: boolean;\n /** Default size */\n defaultSize?: boolean;\n /** Print */\n print?: boolean;\n /** Disabled */\n disabled?: boolean;\n /** UI object */\n uiObject?: boolean;\n /** Auto fill */\n autoFill?: boolean;\n /** Auto line */\n autoLine?: boolean;\n /** Auto picture */\n autoPict?: boolean;\n /** Macro */\n macro?: string;\n /** Alt text */\n altText?: string;\n /** DDE */\n dde?: boolean;\n /** Relationship ID */\n rId?: string;\n}\n\n/** Web publish item (CT_WebPublishItem) */\nexport interface WebPublishItemOptions {\n /** Item ID */\n id: number;\n /** HTML div ID */\n divId: string;\n /** Source type */\n sourceType:\n | \"sheet\"\n | \"printArea\"\n | \"autoFilter\"\n | \"range\"\n | \"chart\"\n | \"pivotTable\"\n | \"query\"\n | \"label\";\n /** Source cell reference */\n sourceRef?: string;\n /** Source object name */\n sourceObject?: string;\n /** Destination file path */\n destinationFile: string;\n /** Title */\n title?: string;\n /** Auto republish */\n autoRepublish?: boolean;\n}\n\n// ── Worksheet XML builder context ──\n\n/** Minimal context needed by buildWorksheetXml. */\nexport interface WorksheetContext {\n sharedStrings?: SharedStrings;\n styles?: Styles;\n}\n\n// ── Pure functions ──\n\n// Re-exported for use by the compiler (defined below in this file).\nexport { stringifyWorksheet as buildWorksheetXml };\n// ── Descriptor ──\n\nexport const worksheetDesc: CustomDescriptor<WorksheetOptions> = {\n kind: \"custom\",\n\n /**\n * NOT intended for direct use by the compiler.\n * The compiler calls `stringifyWorksheet(opts, ctx)` instead, which has\n * access to the SharedStrings and Styles accumulators.\n * This method exists to satisfy the CustomDescriptor interface for the read path.\n */\n stringify(_opts, _ctx) {\n throw new Error(\n \"Use stringifyWorksheet(opts, ctx) for the write path. worksheetDesc.stringify() is not supported.\",\n );\n },\n\n parse(el, ctx) {\n const result: Record<string, unknown> = {};\n let pageSetUpPrCache: Record<string, unknown> | undefined;\n\n // Resolve shared strings from context (XlsxReadContext)\n const strings: string[] =\n ctx && \"sharedStrings\" in ctx ? (ctx as XlsxReadContext).sharedStrings : [];\n\n // Sheet properties\n const sheetPrEl = findChild(el, \"sheetPr\");\n if (sheetPrEl) {\n const sp: Record<string, unknown> = {};\n if (attr(sheetPrEl, \"syncHorizontal\") === \"1\") sp.syncHorizontal = true;\n if (attr(sheetPrEl, \"syncVertical\") === \"1\") sp.syncVertical = true;\n if (attr(sheetPrEl, \"syncRef\")) sp.syncRef = attr(sheetPrEl, \"syncRef\");\n if (attr(sheetPrEl, \"transitionEvaluation\") === \"1\") sp.transitionEvaluation = true;\n if (attr(sheetPrEl, \"transitionEntry\") === \"1\") sp.transitionEntry = true;\n if (attr(sheetPrEl, \"published\") === \"1\") sp.published = true;\n if (attr(sheetPrEl, \"filterMode\") === \"1\") sp.filterMode = true;\n if (attr(sheetPrEl, \"enableFormatConditionsCalculation\") === \"1\")\n sp.enableFormatConditionsCalculation = true;\n\n const outlinePr = findChild(sheetPrEl, \"outlinePr\");\n if (outlinePr) {\n if (attr(outlinePr, \"applyStyles\") === \"1\") sp.outlineApplyStyles = true;\n if (attr(outlinePr, \"showOutlineSymbols\") === \"0\") sp.outlineShowSymbols = false;\n if (attr(outlinePr, \"summaryBelow\") === \"0\") sp.outlineSummaryBelow = false;\n if (attr(outlinePr, \"summaryRight\") === \"0\") sp.outlineSummaryRight = false;\n }\n\n // pageSetUpPr (inside sheetPr) — stash on result.pageSetup; merged into\n // the <pageSetup> parse below, which owns result.pageSetup.\n const pageSetUpPr = findChild(sheetPrEl, \"pageSetUpPr\");\n if (pageSetUpPr) {\n const psup: Record<string, unknown> = {};\n if (attr(pageSetUpPr, \"fitToPage\") === \"1\") psup.fitToPage = true;\n if (attr(pageSetUpPr, \"autoPageBreaks\") === \"1\") psup.autoPageBreaks = true;\n if (Object.keys(psup).length > 0) pageSetUpPrCache = psup;\n }\n if (Object.keys(sp).length > 0) result.sheetPr = sp;\n\n // Tab color\n const tabColorEl = findChild(sheetPrEl, \"tabColor\");\n if (tabColorEl) {\n const tc: Record<string, unknown> = {};\n if (attr(tabColorEl, \"rgb\")) tc.rgb = attr(tabColorEl, \"rgb\");\n if (attrNum(tabColorEl, \"theme\") !== undefined) tc.theme = attrNum(tabColorEl, \"theme\");\n if (attrNum(tabColorEl, \"tint\") !== undefined) tc.tint = attrNum(tabColorEl, \"tint\");\n if (attrNum(tabColorEl, \"indexed\") !== undefined)\n tc.indexed = attrNum(tabColorEl, \"indexed\");\n result.tabColor = tc;\n }\n }\n\n // Sheet views\n const sheetViewsEl = findChild(el, \"sheetViews\");\n if (sheetViewsEl) {\n const svEl = findChild(sheetViewsEl, \"sheetView\");\n if (svEl) {\n const sv: Record<string, unknown> = {};\n if (attr(svEl, \"showGridLines\") === \"0\") sv.showGridLines = false;\n if (attr(svEl, \"showRowColHeaders\") === \"0\") sv.showRowColHeaders = false;\n if (attr(svEl, \"showZeros\") === \"0\") sv.showZeros = false;\n const zs = attrNum(svEl, \"zoomScale\");\n if (zs !== undefined) sv.zoomScale = zs;\n if (attr(svEl, \"tabSelected\") !== undefined)\n sv.tabSelected = attr(svEl, \"tabSelected\") !== \"0\";\n if (attr(svEl, \"rightToLeft\") === \"1\") sv.rightToLeft = true;\n if (attr(svEl, \"windowProtection\") === \"1\") sv.windowProtection = true;\n if (attr(svEl, \"showFormulas\") === \"1\") sv.showFormulas = true;\n if (attr(svEl, \"showRuler\") === \"0\") sv.showRuler = false;\n if (attr(svEl, \"showOutlineSymbols\") === \"0\") sv.showOutlineSymbols = false;\n if (attr(svEl, \"defaultGridColor\") === \"0\") sv.defaultGridColor = false;\n if (attr(svEl, \"showWhiteSpace\") === \"0\") sv.showWhiteSpace = false;\n if (attr(svEl, \"view\")) sv.view = attr(svEl, \"view\");\n const colorId = attrNum(svEl, \"colorId\");\n if (colorId !== undefined) sv.colorId = colorId;\n const zsn = attrNum(svEl, \"zoomScaleNormal\");\n if (zsn !== undefined) sv.zoomScaleNormal = zsn;\n const zssl = attrNum(svEl, \"zoomScaleSheetLayoutView\");\n if (zssl !== undefined) sv.zoomScaleSheetLayoutView = zssl;\n const zspl = attrNum(svEl, \"zoomScalePageLayoutView\");\n if (zspl !== undefined) sv.zoomScalePageLayoutView = zspl;\n result.sheetView = sv;\n\n // Freeze pane\n const paneEl = findChild(svEl, \"pane\");\n if (paneEl && attr(paneEl, \"state\") === \"frozen\") {\n const fp: Record<string, unknown> = {};\n const ys = attrNum(paneEl, \"ySplit\");\n if (ys && ys > 0) fp.row = ys;\n const xs = attrNum(paneEl, \"xSplit\");\n if (xs && xs > 0) fp.col = xs;\n if (Object.keys(fp).length > 0) result.freezePanes = fp;\n }\n }\n }\n\n // Sheet format properties\n const sfpEl = findChild(el, \"sheetFormatPr\");\n if (sfpEl) {\n const sfp: Record<string, unknown> = {};\n const bcw = attrNum(sfpEl, \"baseColWidth\");\n if (bcw !== undefined) sfp.baseColWidth = bcw;\n const dcw = attrNum(sfpEl, \"defaultColWidth\");\n if (dcw !== undefined) sfp.defaultColWidth = dcw;\n const drh = attrNum(sfpEl, \"defaultRowHeight\");\n if (drh !== undefined) sfp.defaultRowHeight = drh;\n if (attr(sfpEl, \"zeroHeight\") === \"1\") sfp.zeroHeight = true;\n if (attr(sfpEl, \"thickTop\") === \"1\") sfp.thickTop = true;\n if (attr(sfpEl, \"thickBottom\") === \"1\") sfp.thickBottom = true;\n const olr = attrNum(sfpEl, \"outlineLevelRow\");\n if (olr !== undefined) sfp.outlineLevelRow = olr;\n const olc = attrNum(sfpEl, \"outlineLevelCol\");\n if (olc !== undefined) sfp.outlineLevelCol = olc;\n result.sheetFormatPr = sfp;\n }\n\n // Columns\n const colsEl = findChild(el, \"cols\");\n if (colsEl) {\n const columns: Record<string, unknown>[] = [];\n for (const colEl of colsEl.elements ?? []) {\n if (colEl.name !== \"col\") continue;\n const col: Record<string, unknown> = {};\n col.min = attrNum(colEl, \"min\") ?? 0;\n col.max = attrNum(colEl, \"max\") ?? 0;\n const w = attrNum(colEl, \"width\");\n if (w !== undefined) col.width = w;\n if (attr(colEl, \"hidden\") === \"1\") col.hidden = true;\n if (attr(colEl, \"customWidth\") === \"1\") col.customWidth = true;\n const ol = attrNum(colEl, \"outlineLevel\");\n if (ol !== undefined) col.outlineLevel = ol;\n if (attr(colEl, \"collapsed\") === \"1\") col.collapsed = true;\n if (attr(colEl, \"bestFit\") === \"1\") col.bestFit = true;\n if (attr(colEl, \"phonetic\") === \"1\") col.phonetic = true;\n columns.push(col);\n }\n if (columns.length > 0) result.columns = columns;\n }\n\n // Sheet protection\n const protEl = findChild(el, \"sheetProtection\");\n if (protEl?.attributes) {\n const prot: Record<string, unknown> = {};\n if (attr(protEl, \"password\")) prot.password = attr(protEl, \"password\");\n if (attr(protEl, \"algorithmName\")) prot.algorithmName = attr(protEl, \"algorithmName\");\n if (attr(protEl, \"hashValue\")) prot.hashValue = attr(protEl, \"hashValue\");\n if (attr(protEl, \"saltValue\")) prot.saltValue = attr(protEl, \"saltValue\");\n if (attrNum(protEl, \"spinCount\") !== undefined) prot.spinCount = attrNum(protEl, \"spinCount\");\n if (attr(protEl, \"sheet\") === \"1\") prot.sheet = true;\n if (attr(protEl, \"objects\") === \"1\") prot.objects = true;\n if (attr(protEl, \"scenarios\") === \"1\") prot.scenarios = true;\n if (attr(protEl, \"formatCells\") === \"0\") prot.formatCells = false;\n if (attr(protEl, \"formatColumns\") === \"0\") prot.formatColumns = false;\n if (attr(protEl, \"formatRows\") === \"0\") prot.formatRows = false;\n if (attr(protEl, \"insertColumns\") === \"0\") prot.insertColumns = false;\n if (attr(protEl, \"insertRows\") === \"0\") prot.insertRows = false;\n if (attr(protEl, \"insertHyperlinks\") === \"0\") prot.insertHyperlinks = false;\n if (attr(protEl, \"deleteColumns\") === \"0\") prot.deleteColumns = false;\n if (attr(protEl, \"deleteRows\") === \"0\") prot.deleteRows = false;\n if (attr(protEl, \"selectLockedCells\") === \"1\") prot.selectLockedCells = true;\n if (attr(protEl, \"sort\") === \"0\") prot.sort = false;\n if (attr(protEl, \"autoFilter\") === \"0\") prot.autoFilter = false;\n if (attr(protEl, \"pivotTables\") === \"0\") prot.pivotTables = false;\n if (attr(protEl, \"selectUnlockedCells\") === \"1\") prot.selectUnlockedCells = true;\n result.protection = prot;\n }\n\n // Protected ranges\n const prEl = findChild(el, \"protectedRanges\");\n if (prEl) {\n const ranges: Record<string, unknown>[] = [];\n for (const rEl of prEl.elements ?? []) {\n if (rEl.name !== \"protectedRange\") continue;\n const r: Record<string, unknown> = {};\n r.sqref = attr(rEl, \"sqref\") ?? \"\";\n r.name = attr(rEl, \"name\") ?? \"\";\n if (attr(rEl, \"password\")) r.password = attr(rEl, \"password\");\n if (attr(rEl, \"algorithmName\")) r.algorithmName = attr(rEl, \"algorithmName\");\n if (attr(rEl, \"hashValue\")) r.hashValue = attr(rEl, \"hashValue\");\n if (attr(rEl, \"saltValue\")) r.saltValue = attr(rEl, \"saltValue\");\n if (attrNum(rEl, \"spinCount\") !== undefined) r.spinCount = attrNum(rEl, \"spinCount\");\n const sdEl = findChild(rEl, \"securityDescriptor\");\n if (sdEl) r.securityDescriptor = textOf(sdEl);\n ranges.push(r);\n }\n if (ranges.length > 0) result.protectedRanges = ranges;\n }\n\n // Auto filter\n const afEl = findChild(el, \"autoFilter\");\n if (afEl) {\n result.autoFilter = attr(afEl, \"ref\") ?? \"\";\n }\n\n // Merge cells\n const mcEl = findChild(el, \"mergeCells\");\n if (mcEl) {\n const merges: Record<string, unknown>[] = [];\n for (const mEl of mcEl.elements ?? []) {\n if (mEl.name !== \"mergeCell\") continue;\n const ref = attr(mEl, \"ref\") ?? \"\";\n const parts = ref.split(\":\");\n if (parts.length === 2) {\n const from = parseCellRef(parts[0]);\n const to = parseCellRef(parts[1]);\n if (from && to) merges.push({ from, to });\n }\n }\n if (merges.length > 0) result.mergeCells = merges;\n }\n\n // Conditional formatting\n const cfEls = el.elements?.filter((e) => e.name === \"conditionalFormatting\") ?? [];\n if (cfEls.length > 0) {\n const cfs: Record<string, unknown>[] = [];\n for (const cfEl of cfEls) {\n const sqref = attr(cfEl, \"sqref\") ?? \"\";\n const rules: Record<string, unknown>[] = [];\n for (const ruleEl of cfEl.elements ?? []) {\n if (ruleEl.name !== \"cfRule\") continue;\n const rule: Record<string, unknown> = {};\n rule.type = attr(ruleEl, \"type\");\n rule.priority = attrNum(ruleEl, \"priority\") ?? 1;\n if (attr(ruleEl, \"operator\")) rule.operator = attr(ruleEl, \"operator\");\n const dxfId = attrNum(ruleEl, \"dxfId\");\n if (dxfId !== undefined) rule.dxfId = dxfId;\n if (attr(ruleEl, \"stopIfTrue\") === \"1\") rule.stopIfTrue = true;\n if (attr(ruleEl, \"timePeriod\")) rule.timePeriod = attr(ruleEl, \"timePeriod\");\n const rank = attrNum(ruleEl, \"rank\");\n if (rank !== undefined) rule.rank = rank;\n if (attr(ruleEl, \"equalAverage\") === \"1\") rule.equalAverage = true;\n\n // Color scale\n const csEl = findChild(ruleEl, \"colorScale\");\n if (csEl) {\n const cfvo: Record<string, unknown>[] = [];\n const colors: string[] = [];\n for (const child of csEl.elements ?? []) {\n if (child.name === \"cfvo\") cfvo.push(parseCfvo(child));\n if (child.name === \"color\") {\n const rgb = attr(child, \"rgb\");\n if (rgb) colors.push(rgb.length === 8 ? rgb.slice(2) : rgb);\n }\n }\n rule.colorScale = { cfvo, colors };\n }\n\n // Data bar\n const dbEl = findChild(ruleEl, \"dataBar\");\n if (dbEl) {\n const cfvo: Record<string, unknown>[] = [];\n let color = \"\";\n for (const child of dbEl.elements ?? []) {\n if (child.name === \"cfvo\") cfvo.push(parseCfvo(child));\n if (child.name === \"color\") {\n const rgb = attr(child, \"rgb\");\n if (rgb) color = rgb.length === 8 ? rgb.slice(2) : rgb;\n }\n }\n rule.dataBar = { cfvo: cfvo as [any, any], color };\n }\n\n // Icon set\n const isEl = findChild(ruleEl, \"iconSet\");\n if (isEl) {\n const cfvo: Record<string, unknown>[] = [];\n for (const child of isEl.elements ?? []) {\n if (child.name === \"cfvo\") cfvo.push(parseCfvo(child));\n }\n const iconSet: Record<string, unknown> = { cfvo };\n if (attr(isEl, \"iconSet\")) iconSet.iconSet = attr(isEl, \"iconSet\");\n if (attr(isEl, \"showValue\") === \"0\") iconSet.showValue = false;\n if (attr(isEl, \"percent\") === \"0\") iconSet.percent = false;\n if (attr(isEl, \"reverse\") === \"1\") iconSet.reverse = true;\n rule.iconSet = iconSet;\n }\n\n // Formulas\n const formulas: string[] = [];\n for (const child of ruleEl.elements ?? []) {\n if (child.name === \"formula\") formulas.push(textOf(child) ?? \"\");\n }\n if (formulas.length > 0) rule.formulas = formulas;\n\n rules.push(rule);\n }\n cfs.push({ sqref, rules });\n }\n result.conditionalFormats = cfs;\n }\n\n // Data validations\n const dvEl = findChild(el, \"dataValidations\");\n if (dvEl) {\n const dvs: Record<string, unknown>[] = [];\n for (const dEl of dvEl.elements ?? []) {\n if (dEl.name !== \"dataValidation\") continue;\n const dv: Record<string, unknown> = {};\n dv.sqref = attr(dEl, \"sqref\") ?? \"\";\n if (attr(dEl, \"type\")) dv.type = attr(dEl, \"type\");\n if (attr(dEl, \"operator\")) dv.operator = attr(dEl, \"operator\");\n if (attr(dEl, \"allowBlank\") === \"1\") dv.allowBlank = true;\n if (attr(dEl, \"showErrorMessage\") === \"1\") dv.showErrorMessage = true;\n if (attr(dEl, \"showInputMessage\") === \"1\") dv.showInputMessage = true;\n if (attr(dEl, \"errorTitle\")) dv.errorTitle = attr(dEl, \"errorTitle\");\n if (attr(dEl, \"error\")) dv.error = attr(dEl, \"error\");\n if (attr(dEl, \"promptTitle\")) dv.promptTitle = attr(dEl, \"promptTitle\");\n if (attr(dEl, \"prompt\")) dv.prompt = attr(dEl, \"prompt\");\n if (attr(dEl, \"errorStyle\")) dv.errorStyle = attr(dEl, \"errorStyle\");\n if (attr(dEl, \"imeMode\")) dv.imeMode = attr(dEl, \"imeMode\");\n if (attr(dEl, \"showDropDown\") === \"1\") dv.showDropDown = true;\n\n const f1El = findChild(dEl, \"formula1\");\n if (f1El) dv.formula1 = textOf(f1El);\n const f2El = findChild(dEl, \"formula2\");\n if (f2El) dv.formula2 = textOf(f2El);\n\n dvs.push(dv);\n }\n result.dataValidations = dvs;\n }\n\n // Hyperlinks\n const hlEl = findChild(el, \"hyperlinks\");\n if (hlEl) {\n const hyperlinks: Record<string, unknown>[] = [];\n for (const hEl of hlEl.elements ?? []) {\n if (hEl.name !== \"hyperlink\") continue;\n const hl: Record<string, unknown> = {};\n hl.cell = attr(hEl, \"ref\") ?? \"\";\n const rId = hEl.attributes?.[\"r:id\"] as string | undefined;\n const location = attr(hEl, \"location\");\n if (rId) hl.target = { type: \"external\", url: rId };\n else if (location) hl.target = { type: \"internal\", location };\n if (attr(hEl, \"tooltip\")) hl.tooltip = attr(hEl, \"tooltip\");\n if (attr(hEl, \"display\")) hl.display = attr(hEl, \"display\");\n hyperlinks.push(hl);\n }\n result.hyperlinks = hyperlinks;\n }\n\n // Print options\n const poEl = findChild(el, \"printOptions\");\n if (poEl) {\n const po: Record<string, unknown> = {};\n if (attr(poEl, \"horizontalCentered\") === \"1\") po.horizontalCentered = true;\n if (attr(poEl, \"verticalCentered\") === \"1\") po.verticalCentered = true;\n if (attr(poEl, \"headings\") === \"1\") po.headings = true;\n if (attr(poEl, \"gridLines\") === \"1\") po.gridLines = true;\n if (attr(poEl, \"gridLinesSet\") === \"0\") po.gridLinesSet = false;\n result.printOptions = po;\n }\n\n // Page setup\n const psEl = findChild(el, \"pageSetup\");\n if (psEl) {\n const ps: Record<string, unknown> = {};\n const pz = attrNum(psEl, \"paperSize\");\n if (pz !== undefined) ps.paperSize = pz;\n if (attr(psEl, \"orientation\")) ps.orientation = attr(psEl, \"orientation\");\n const sc = attrNum(psEl, \"scale\");\n if (sc !== undefined) ps.scale = sc;\n const ftw = attrNum(psEl, \"fitToWidth\");\n if (ftw !== undefined) ps.fitToWidth = ftw;\n const fth = attrNum(psEl, \"fitToHeight\");\n if (fth !== undefined) ps.fitToHeight = fth;\n if (attr(psEl, \"pageOrder\")) ps.pageOrder = attr(psEl, \"pageOrder\");\n if (attr(psEl, \"useFirstPageNumber\") === \"1\") ps.useFirstPageNumber = true;\n const fpn = attrNum(psEl, \"firstPageNumber\");\n if (fpn !== undefined) ps.firstPageNumber = fpn;\n if (pageSetUpPrCache) Object.assign(ps, pageSetUpPrCache);\n result.pageSetup = ps;\n } else if (pageSetUpPrCache) {\n result.pageSetup = pageSetUpPrCache;\n }\n\n // Header/footer\n const hfEl = findChild(el, \"headerFooter\");\n if (hfEl) {\n const hf: Record<string, unknown> = {};\n if (attr(hfEl, \"differentOddEven\") === \"1\") hf.differentOddEven = true;\n if (attr(hfEl, \"differentFirst\") === \"1\") hf.differentFirst = true;\n if (attr(hfEl, \"scaleWithDoc\") === \"0\") hf.scaleWithDoc = false;\n if (attr(hfEl, \"alignWithMargins\") === \"0\") hf.alignWithMargins = false;\n const oh = findChild(hfEl, \"oddHeader\");\n if (oh) hf.oddHeader = textOf(oh);\n const of2 = findChild(hfEl, \"oddFooter\");\n if (of2) hf.oddFooter = textOf(of2);\n const eh = findChild(hfEl, \"evenHeader\");\n if (eh) hf.evenHeader = textOf(eh);\n const ef = findChild(hfEl, \"evenFooter\");\n if (ef) hf.evenFooter = textOf(ef);\n const fh = findChild(hfEl, \"firstHeader\");\n if (fh) hf.firstHeader = textOf(fh);\n const ff = findChild(hfEl, \"firstFooter\");\n if (ff) hf.firstFooter = textOf(ff);\n result.headerFooter = hf;\n }\n\n // Ignored errors\n const ieEl = findChild(el, \"ignoredErrors\");\n if (ieEl) {\n const errors: Record<string, unknown>[] = [];\n for (const eEl of ieEl.elements ?? []) {\n if (eEl.name !== \"ignoredError\") continue;\n const ie: Record<string, unknown> = {};\n ie.sqref = attr(eEl, \"sqref\") ?? \"\";\n if (attr(eEl, \"evalError\") === \"1\") ie.evalError = true;\n if (attr(eEl, \"twoDigitTextYear\") === \"1\") ie.twoDigitTextYear = true;\n if (attr(eEl, \"numberStoredAsText\") === \"1\") ie.numberStoredAsText = true;\n if (attr(eEl, \"formula\") === \"1\") ie.formula = true;\n if (attr(eEl, \"formulaRange\") === \"1\") ie.formulaRange = true;\n if (attr(eEl, \"unlockedFormula\") === \"1\") ie.unlockedFormula = true;\n if (attr(eEl, \"emptyCellReference\") === \"1\") ie.emptyCellReference = true;\n if (attr(eEl, \"listDataValidation\") === \"1\") ie.listDataValidation = true;\n if (attr(eEl, \"calculatedColumn\") === \"1\") ie.calculatedColumn = true;\n errors.push(ie);\n }\n result.ignoredErrors = errors;\n }\n\n // Phonetic properties\n const ppEl = findChild(el, \"phoneticPr\");\n if (ppEl) {\n const pp: Record<string, unknown> = {};\n pp.fontId = attrNum(ppEl, \"fontId\") ?? 0;\n if (attr(ppEl, \"type\")) pp.type = attr(ppEl, \"type\");\n if (attr(ppEl, \"alignment\")) pp.alignment = attr(ppEl, \"alignment\");\n result.phoneticPr = pp;\n }\n\n // Sheet calc properties\n const scEl = findChild(el, \"sheetCalcPr\");\n if (scEl) {\n const sc: Record<string, unknown> = {};\n if (attr(scEl, \"fullCalcOnLoad\") === \"1\") sc.fullCalcOnLoad = true;\n result.sheetCalcPr = sc;\n }\n\n // Sheet data (rows and cells)\n const sheetDataEl = findChild(el, \"sheetData\");\n if (sheetDataEl) {\n const rows: Record<string, unknown>[] = [];\n for (const rowEl of sheetDataEl.elements ?? []) {\n if (rowEl.name !== \"row\") continue;\n const row: Record<string, unknown> = {};\n const rowNumber = attrNum(rowEl, \"r\");\n if (rowNumber !== undefined) row.rowNumber = rowNumber;\n const ht = attrNum(rowEl, \"ht\");\n if (ht !== undefined) row.height = ht;\n if (attr(rowEl, \"hidden\") === \"1\") row.hidden = true;\n if (attr(rowEl, \"spans\")) row.spans = attr(rowEl, \"spans\");\n if (attr(rowEl, \"customFormat\") === \"1\") row.customFormat = true;\n if (attr(rowEl, \"thickTop\") === \"1\") row.thickTop = true;\n if (attr(rowEl, \"thickBot\") === \"1\") row.thickBot = true;\n if (attr(rowEl, \"ph\") === \"1\") row.ph = true;\n\n const cells: Record<string, unknown>[] = [];\n for (const cellEl of rowEl.elements ?? []) {\n if (cellEl.name !== \"c\") continue;\n const cell: Record<string, unknown> = {};\n const ref = attr(cellEl, \"r\");\n if (ref) cell.reference = ref;\n const type = attr(cellEl, \"t\");\n const styleIdx = attrNum(cellEl, \"s\");\n if (styleIdx !== undefined) {\n // Resolve to a concrete StyleOptions so re-stringify registers it in\n // the fresh Styles table (whose indices may differ). Keep styleIndex\n // as a fallback when the styles table cannot be resolved.\n const resolved =\n ctx && \"resolveStyle\" in ctx\n ? (ctx as XlsxReadContext).resolveStyle(styleIdx)\n : undefined;\n if (resolved) {\n cell.style = resolved;\n } else {\n cell.styleIndex = styleIdx;\n }\n }\n\n // Cell value\n const vEl = findChild(cellEl, \"v\");\n const isEl = findChild(cellEl, \"is\");\n\n if (type === \"s\" && vEl) {\n // Shared string\n const idx = parseInt(textOf(vEl) ?? \"\", 10);\n cell.value = strings[idx] ?? \"\";\n } else if (type === \"b\" && vEl) {\n cell.value = textOf(vEl) === \"1\";\n } else if (type === \"inlineStr\" && isEl) {\n const t = findChild(isEl, \"t\");\n cell.value = textOf(t) ?? \"\";\n } else if (vEl) {\n const raw = textOf(vEl) ?? \"\";\n const num = Number(raw);\n cell.value = isNaN(num) ? raw : num;\n }\n\n // Formula\n const fEl = findChild(cellEl, \"f\");\n if (fEl) {\n const formula: Record<string, unknown> = { formula: textOf(fEl) ?? \"\" };\n const ft = attr(fEl, \"t\");\n if (ft && ft !== \"normal\") formula.type = ft;\n const fRef = attr(fEl, \"ref\");\n if (fRef) formula.reference = fRef;\n const fSi = attrNum(fEl, \"si\");\n if (fSi !== undefined) formula.sharedIndex = fSi;\n if (attr(fEl, \"aca\") === \"1\") formula.aca = true;\n if (attr(fEl, \"ca\") === \"1\") formula.ca = true;\n if (attr(fEl, \"bx\") === \"1\") formula.bx = true;\n cell.formula = formula as unknown as FormulaOptions;\n }\n\n cells.push(cell);\n }\n\n row.cells = cells;\n rows.push(row);\n }\n if (rows.length > 0) result.rows = rows;\n }\n\n return result as unknown as WorksheetOptions;\n },\n};\n\n// ── Stringify implementation ──\n\n/**\n * Build the complete worksheet XML string.\n *\n * Zero-allocation fast path: directly concatenates XML string,\n * bypassing the IXmlableObject intermediate tree entirely.\n */\nexport function stringifyWorksheet(opts: WorksheetOptions, ctx: WorksheetContext): string {\n const sharedStrings = ctx.sharedStrings;\n const styles = ctx.styles;\n\n const rows = opts.rows ?? [];\n const columns = opts.columns ?? [];\n const mergeCells = opts.mergeCells ?? [];\n const protectedRanges = opts.protectedRanges ?? [];\n const ignoredErrors = opts.ignoredErrors ?? [];\n const rowBreaks = opts.rowBreaks ?? [];\n const colBreaks = opts.colBreaks ?? [];\n const customSheetViews = opts.customSheetViews ?? [];\n const cellWatches = opts.cellWatches ?? [];\n const controls = opts.controls ?? [];\n const customProperties = opts.customProperties ?? [];\n const oleObjects = opts.oleObjects ?? [];\n const webPublishItems = opts.webPublishItems ?? [];\n\n const p: string[] = [\n '<worksheet xmlns=\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\"' +\n ' xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\"' +\n ' xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\"' +\n ' mc:Ignorable=\"x14ac xr xr2 xr3\"' +\n ' xmlns:x14ac=\"http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac\"' +\n ' xmlns:xr=\"http://schemas.microsoft.com/office/spreadsheetml/2014/revision\"' +\n ' xmlns:xr2=\"http://schemas.microsoft.com/office/spreadsheetml/2015/revision2\"' +\n ' xmlns:xr3=\"http://schemas.microsoft.com/office/spreadsheetml/2016/revision3\">',\n ];\n\n // Sheet properties (tabColor, outlinePr go here)\n const hasTabColor = !!opts.tabColor;\n const hasOutline = columns.some((c) => c.outlineLevel !== undefined);\n const sp = opts.sheetPr;\n const hasSheetPrAttrs =\n sp &&\n (sp.syncHorizontal ||\n sp.syncVertical ||\n sp.syncRef ||\n sp.transitionEvaluation ||\n sp.transitionEntry ||\n sp.published ||\n sp.filterMode ||\n sp.enableFormatConditionsCalculation);\n const hasPageSetUpPr =\n !!opts.pageSetup?.fitToWidth ||\n !!opts.pageSetup?.fitToHeight ||\n !!opts.pageSetup?.autoPageBreaks;\n if (hasTabColor || hasOutline || hasSheetPrAttrs || hasPageSetUpPr) {\n const prParts: string[] = [];\n const prAttrs: Record<string, string | number | boolean | undefined> = {};\n if (sp?.syncHorizontal) prAttrs.syncHorizontal = 1;\n if (sp?.syncVertical) prAttrs.syncVertical = 1;\n if (sp?.syncRef) prAttrs.syncRef = sp.syncRef;\n if (sp?.transitionEvaluation) prAttrs.transitionEvaluation = 1;\n if (sp?.transitionEntry) prAttrs.transitionEntry = 1;\n if (sp?.published) prAttrs.published = 1;\n if (sp?.filterMode) prAttrs.filterMode = 1;\n if (sp?.enableFormatConditionsCalculation) prAttrs.enableFormatConditionsCalculation = 1;\n if (opts.tabColor) {\n const tc = opts.tabColor;\n const tcAttrs: Record<string, string | number | boolean | undefined> = {};\n if (tc.rgb) tcAttrs.rgb = tc.rgb;\n if (tc.theme !== undefined) tcAttrs.theme = tc.theme;\n if (tc.tint !== undefined) tcAttrs.tint = tc.tint;\n if (tc.indexed !== undefined) tcAttrs.indexed = tc.indexed;\n prParts.push(`<tabColor${attrs(tcAttrs)}/>`);\n }\n if (hasOutline) {\n const outAttrs: Record<string, string | number | boolean | undefined> = {\n summaryBelow: 1,\n summaryRight: 1,\n };\n if (sp?.outlineSummaryBelow === false) outAttrs.summaryBelow = 0;\n if (sp?.outlineSummaryRight === false) outAttrs.summaryRight = 0;\n if (sp?.outlineApplyStyles) outAttrs.applyStyles = 1;\n if (sp?.outlineShowSymbols === false) outAttrs.showOutlineSymbols = 0;\n prParts.push(`<outlinePr${attrs(outAttrs)}/>`);\n }\n // pageSetUpPr (inside sheetPr when fitToPage or autoPageBreaks needed)\n if (\n opts.pageSetup?.fitToWidth ||\n opts.pageSetup?.fitToHeight ||\n opts.pageSetup?.autoPageBreaks\n ) {\n const psupAttrs: Record<string, string | number | boolean | undefined> = {};\n if (opts.pageSetup?.fitToWidth || opts.pageSetup?.fitToHeight) psupAttrs.fitToPage = 1;\n if (opts.pageSetup?.autoPageBreaks) psupAttrs.autoPageBreaks = 1;\n prParts.push(`<pageSetUpPr${attrs(psupAttrs)}/>`);\n }\n const prAttrStr = Object.keys(prAttrs).length > 0 ? attrs(prAttrs) : \"\";\n p.push(`<sheetPr${prAttrStr}>${prParts.join(\"\")}</sheetPr>`);\n }\n\n // Dimension — defines the used range of the sheet\n const maxRow = rows.length;\n let maxCol = 0;\n for (const row of rows) {\n if (row.cells && row.cells.length > maxCol) maxCol = row.cells.length;\n }\n if (maxRow > 0 && maxCol > 0) {\n const dimRef = `A1:${defaultCellRef(maxRow, maxCol)}`;\n p.push(`<dimension ref=\"${dimRef}\"/>`);\n }\n\n // Sheet views\n const pivotSelXml = opts.sheetView?.pivotSelections\n ? opts.sheetView.pivotSelections.map((ps) => buildPivotSelectionXml(ps)).join(\"\")\n : \"\";\n if (opts.freezePanes) {\n const fp = opts.freezePanes;\n const ySplit = fp.row ? fp.row : 0;\n const xSplit = fp.col ? fp.col : 0;\n const topRow = fp.row ? fp.row + 1 : 1;\n const leftCol = fp.col ? fp.col + 1 : 1;\n const topLeftCell = defaultCellRef(topRow, leftCol);\n const activePane =\n ySplit > 0 && xSplit > 0 ? \"bottomRight\" : ySplit > 0 ? \"bottomLeft\" : \"topRight\";\n const svAttrs = buildSheetViewAttrs(opts.sheetView);\n p.push(\n `<sheetViews><sheetView${svAttrs}>`,\n `<pane ySplit=\"${ySplit}\" xSplit=\"${xSplit}\" topLeftCell=\"${topLeftCell}\" activePane=\"${activePane}\" state=\"frozen\"/>`,\n opts.selection ? buildSelectionXml(opts.selection) : \"\",\n pivotSelXml,\n \"</sheetView></sheetViews>\",\n );\n } else {\n const svAttrs = buildSheetViewAttrs(opts.sheetView);\n const innerXml = (opts.selection ? buildSelectionXml(opts.selection) : \"\") + pivotSelXml;\n if (innerXml) {\n p.push(`<sheetViews><sheetView${svAttrs}>${innerXml}</sheetView></sheetViews>`);\n } else {\n p.push(`<sheetViews><sheetView${svAttrs}/></sheetViews>`);\n }\n }\n\n // Sheet format — default row height\n if (opts.sheetFormatPr) {\n const sfp = opts.sheetFormatPr;\n const sfpAttrs: Record<string, string | number | boolean | undefined> = {};\n if (sfp.baseColWidth !== undefined) sfpAttrs.baseColWidth = sfp.baseColWidth;\n if (sfp.defaultColWidth !== undefined) sfpAttrs.defaultColWidth = sfp.defaultColWidth;\n sfpAttrs.defaultRowHeight = sfp.defaultRowHeight ?? 15;\n if (sfp.zeroHeight) sfpAttrs.zeroHeight = 1;\n if (sfp.thickTop) sfpAttrs.thickTop = 1;\n if (sfp.thickBottom) sfpAttrs.thickBottom = 1;\n if (sfp.outlineLevelRow !== undefined) sfpAttrs.outlineLevelRow = sfp.outlineLevelRow;\n if (sfp.outlineLevelCol !== undefined) sfpAttrs.outlineLevelCol = sfp.outlineLevelCol;\n p.push(`<sheetFormatPr${attrs(sfpAttrs)}/>`);\n } else {\n p.push('<sheetFormatPr defaultRowHeight=\"15\"/>');\n }\n\n // Column definitions\n if (columns.length > 0) {\n p.push(\"<cols>\");\n for (const col of columns) {\n const colAttrs: Record<string, string | number | boolean | undefined> = {\n min: col.min,\n max: col.max,\n };\n if (col.width !== undefined) {\n colAttrs.width = col.width;\n colAttrs.customWidth = 1;\n }\n if (col.hidden) {\n colAttrs.hidden = 1;\n }\n if (col.outlineLevel !== undefined) {\n colAttrs.outlineLevel = col.outlineLevel;\n }\n if (col.collapsed) {\n colAttrs.collapsed = 1;\n }\n if (col.bestFit) {\n colAttrs.bestFit = 1;\n }\n if (col.phonetic) {\n colAttrs.phonetic = 1;\n }\n p.push(selfCloseElement(\"col\", attrs(colAttrs)));\n }\n p.push(\"</cols>\");\n }\n\n // Sheet data (rows + cells) — the hot path\n p.push(\"<sheetData>\");\n for (let i = 0; i < rows.length; i++) {\n const rowOpts = rows[i];\n const rowNumber = rowOpts.rowNumber ?? i + 1;\n const rowAttrs: Record<string, string | number | boolean | undefined> = { r: rowNumber };\n if (rowOpts.height !== undefined) {\n rowAttrs.ht = rowOpts.height;\n rowAttrs.customHeight = 1;\n }\n if (rowOpts.hidden) {\n rowAttrs.hidden = 1;\n }\n if (rowOpts.spans) rowAttrs.spans = rowOpts.spans;\n if (rowOpts.customFormat) rowAttrs.customFormat = 1;\n if (rowOpts.thickTop) rowAttrs.thickTop = 1;\n if (rowOpts.thickBot) rowAttrs.thickBot = 1;\n if (rowOpts.ph) rowAttrs.ph = 1;\n\n if (rowOpts.cells) {\n p.push(`<row${attrsRaw(rowAttrs)}>`);\n for (let j = 0; j < rowOpts.cells.length; j++) {\n const cell = rowOpts.cells[j];\n const ref = cell.reference ?? defaultCellRef(rowNumber, j + 1);\n const cellStr = buildCellString(ref, cell, sharedStrings, styles);\n if (cellStr) p.push(cellStr);\n }\n p.push(\"</row>\");\n } else {\n p.push(`<row${attrsRaw(rowAttrs)}/>`);\n }\n }\n p.push(\"</sheetData>\");\n\n // Sheet calc properties (after sheetData per XSD sequence)\n if (opts.sheetCalcPr) {\n const scAttrs: string[] = [];\n if (opts.sheetCalcPr.fullCalcOnLoad) scAttrs.push('fullCalcOnLoad=\"1\"');\n p.push(`<sheetCalcPr${scAttrs.length ? \" \" + scAttrs.join(\" \") : \"\"}/>`);\n }\n\n // Row breaks (after sheetCalcPr per XSD sequence)\n if (rowBreaks.length > 0) {\n const brkParts = rowBreaks.map((b) => {\n const bAttrs: Record<string, string | number | boolean | undefined> = { id: b.id };\n if (b.min !== undefined) bAttrs.min = b.min;\n if (b.max !== undefined) bAttrs.max = b.max;\n if (b.manual) bAttrs.man = 1;\n if (b.pivot) bAttrs.pt = 1;\n return `<brk${attrs(bAttrs)}/>`;\n });\n p.push(\n `<rowBreaks count=\"${rowBreaks.length}\" manualBreakCount=\"${rowBreaks.filter((b) => b.manual).length}\">${brkParts.join(\"\")}</rowBreaks>`,\n );\n }\n\n // Column breaks\n if (colBreaks.length > 0) {\n const brkParts = colBreaks.map((b) => {\n const bAttrs: Record<string, string | number | boolean | undefined> = { id: b.id };\n if (b.min !== undefined) bAttrs.min = b.min;\n if (b.max !== undefined) bAttrs.max = b.max;\n if (b.manual) bAttrs.man = 1;\n if (b.pivot) bAttrs.pt = 1;\n return `<brk${attrs(bAttrs)}/>`;\n });\n p.push(\n `<colBreaks count=\"${colBreaks.length}\" manualBreakCount=\"${colBreaks.filter((b) => b.manual).length}\">${brkParts.join(\"\")}</colBreaks>`,\n );\n }\n\n // Custom properties (CT_CustomProperties, after colBreaks per XSD sequence)\n if (customProperties.length > 0) {\n const cpParts: string[] = [\"<customProperties>\"];\n for (const cp of customProperties) {\n cpParts.push(`<customPr name=\"${escapeXml(cp.name)}\" r:id=\"${escapeXml(cp.rId)}\"/>`);\n }\n cpParts.push(\"</customProperties>\");\n p.push(cpParts.join(\"\"));\n }\n\n // OLE size\n if (opts.oleSize) {\n p.push(`<oleSize ref=\"${escapeXml(opts.oleSize)}\"/>`);\n }\n\n // Custom sheet views (after oleSize per XSD sequence)\n if (customSheetViews.length > 0) {\n p.push(\"<customSheetViews>\");\n for (const csv of customSheetViews) {\n const csvAttrs: Record<string, string | number | boolean | undefined> = { guid: csv.guid };\n if (csv.scale !== undefined) csvAttrs.scale = csv.scale;\n if (csv.showPageBreaks) csvAttrs.showPageBreaks = 1;\n if (csv.showFormulas) csvAttrs.showFormulas = 1;\n if (csv.showGridLines === false) csvAttrs.showGridLines = 0;\n if (csv.showRowColHeaders === false) csvAttrs.showRowCol = 0;\n if (csv.outlineSymbols === false) csvAttrs.outlineSymbols = 0;\n if (csv.zeroValues === false) csvAttrs.zeroValues = 0;\n if (csv.fitToPage) csvAttrs.fitToPage = 1;\n if (csv.printArea) csvAttrs.printArea = 1;\n if (csv.filter) csvAttrs.filter = 1;\n if (csv.showAutoFilter) csvAttrs.showAutoFilter = 1;\n if (csv.hiddenRows) csvAttrs.hiddenRows = 1;\n if (csv.hiddenColumns) csvAttrs.hiddenColumns = 1;\n if (csv.state && csv.state !== \"visible\") csvAttrs.state = csv.state;\n if (csv.filterUnique) csvAttrs.filterUnique = 1;\n if (csv.view && csv.view !== \"normal\") csvAttrs.view = csv.view;\n p.push(`<customSheetView${attrs(csvAttrs)}/>`);\n }\n p.push(\"</customSheetViews>\");\n }\n\n // Cell watches\n if (cellWatches.length > 0) {\n p.push(\"<cellWatches>\");\n for (const cw of cellWatches) {\n p.push(`<cellWatch r=\"${escapeXml(cw.r)}\"/>`);\n }\n p.push(\"</cellWatches>\");\n }\n\n // Data consolidation\n if (opts.dataConsolidate) {\n const dc = opts.dataConsolidate;\n const dcAttrs: Record<string, string | number | boolean | undefined> = {};\n if (dc.function && dc.function !== \"sum\") dcAttrs.function = dc.function;\n if (dc.topLabels) dcAttrs.topLabels = 1;\n if (dc.leftLabels) dcAttrs.leftLabels = 1;\n if (dc.startLabels) dcAttrs.startLabels = 1;\n if (dc.link) dcAttrs.link = 1;\n const refsInner = dc.refs?.map((r) => `<dataRef ref=\"${escapeXml(r)}\"/>`).join(\"\") ?? \"\";\n const refsXml = refsInner ? `<dataRefs>${refsInner}</dataRefs>` : \"\";\n if (refsXml || Object.keys(dcAttrs).length > 0) {\n p.push(`<dataConsolidate${attrs(dcAttrs)}>${refsXml}</dataConsolidate>`);\n }\n }\n\n // Sheet protection (after sheetData, before protectedRanges per XSD sequence)\n if (opts.protection) {\n const prot = opts.protection;\n const protAttrs: Record<string, string | number | boolean | undefined> = {};\n if (prot.password) protAttrs.password = hashPassword(prot.password);\n // Auto-derive modern hash when password provided without explicit hashValue\n let derived: ReturnType<typeof derivePasswordHash> | undefined;\n if (prot.password !== undefined && prot.hashValue === undefined) {\n derived = derivePasswordHash(prot.password);\n }\n protAttrs.algorithmName = prot.algorithmName ?? derived?.algorithmName;\n protAttrs.hashValue = prot.hashValue ?? derived?.hashValue;\n protAttrs.saltValue = prot.saltValue ?? derived?.saltValue;\n if (prot.spinCount !== undefined) protAttrs.spinCount = prot.spinCount;\n else if (derived) protAttrs.spinCount = derived.spinCount;\n if (prot.sheet) protAttrs.sheet = 1;\n if (prot.objects) protAttrs.objects = 1;\n if (prot.scenarios) protAttrs.scenarios = 1;\n if (prot.formatCells === false) protAttrs.formatCells = 0;\n if (prot.formatColumns === false) protAttrs.formatColumns = 0;\n if (prot.formatRows === false) protAttrs.formatRows = 0;\n if (prot.insertColumns === false) protAttrs.insertColumns = 0;\n if (prot.insertRows === false) protAttrs.insertRows = 0;\n if (prot.insertHyperlinks === false) protAttrs.insertHyperlinks = 0;\n if (prot.deleteColumns === false) protAttrs.deleteColumns = 0;\n if (prot.deleteRows === false) protAttrs.deleteRows = 0;\n if (prot.selectLockedCells) protAttrs.selectLockedCells = 1;\n if (prot.sort === false) protAttrs.sort = 0;\n if (prot.autoFilter === false) protAttrs.autoFilter = 0;\n if (prot.pivotTables === false) protAttrs.pivotTables = 0;\n if (prot.selectUnlockedCells) protAttrs.selectUnlockedCells = 1;\n p.push(selfCloseElement(\"sheetProtection\", attrs(protAttrs)));\n }\n\n // Protected ranges (after sheetProtection per XSD sequence)\n if (protectedRanges.length > 0) {\n const prParts: string[] = [\"<protectedRanges>\"];\n for (const pr of protectedRanges) {\n const prAttrs: Record<string, string | number | boolean | undefined> = {\n name: pr.name,\n sqref: pr.sqref,\n };\n if (pr.password) prAttrs.password = hashPassword(pr.password);\n // Auto-derive modern hash when password provided without explicit hashValue\n let prDerived: ReturnType<typeof derivePasswordHash> | undefined;\n if (pr.password !== undefined && pr.hashValue === undefined) {\n prDerived = derivePasswordHash(pr.password);\n }\n prAttrs.algorithmName = pr.algorithmName ?? prDerived?.algorithmName;\n prAttrs.hashValue = pr.hashValue ?? prDerived?.hashValue;\n prAttrs.saltValue = pr.saltValue ?? prDerived?.saltValue;\n if (pr.spinCount !== undefined) prAttrs.spinCount = pr.spinCount;\n else if (prDerived) prAttrs.spinCount = prDerived.spinCount;\n const hasSecurityDescriptor = !!pr.securityDescriptor;\n if (hasSecurityDescriptor) {\n prParts.push(\n `<protectedRange${attrs(prAttrs)}><securityDescriptor>${escapeXml(pr.securityDescriptor!)}</securityDescriptor></protectedRange>`,\n );\n } else {\n prParts.push(selfCloseElement(\"protectedRange\", attrs(prAttrs)));\n }\n }\n prParts.push(\"</protectedRanges>\");\n p.push(prParts.join(\"\"));\n }\n\n // Scenarios (what-if analysis)\n if (opts.scenarios) {\n const scParts: string[] = [\"<scenarios\"];\n const scAttrs: Record<string, string | number> = {};\n if (opts.scenarios.current !== undefined) scAttrs.current = opts.scenarios.current;\n if (opts.scenarios.show !== undefined) scAttrs.show = opts.scenarios.show;\n scParts[0] = `<scenarios${attrs(scAttrs)}>`;\n\n for (const scenario of opts.scenarios.scenarios) {\n const sAttrs: Record<string, string | number | boolean | undefined> = {\n name: scenario.name,\n };\n if (scenario.count !== undefined) sAttrs.count = scenario.count;\n if (scenario.user) sAttrs.user = scenario.user;\n if (scenario.comment) sAttrs.comment = scenario.comment;\n if (scenario.hidden) sAttrs.hidden = true;\n if (scenario.locked) sAttrs.locked = true;\n\n const sParts: string[] = [`<scenario${attrs(sAttrs)}>`];\n for (const cell of scenario.inputCells) {\n const icAttrs: Record<string, string | number | boolean | undefined> = {\n r: cell.r,\n val: String(cell.val),\n };\n if (cell.deleted) icAttrs.deleted = true;\n if (cell.undone) icAttrs.undone = true;\n sParts.push(`<inputCells${attrs(icAttrs)}/>`);\n }\n sParts.push(\"</scenario>\");\n scParts.push(sParts.join(\"\"));\n }\n scParts.push(\"</scenarios>\");\n p.push(scParts.join(\"\"));\n }\n\n // Auto filter\n if (opts.autoFilter) {\n if (typeof opts.autoFilter === \"string\") {\n p.push(selfCloseElement(\"autoFilter\", attrs({ ref: opts.autoFilter })));\n } else {\n const af = opts.autoFilter;\n const inner: string[] = [];\n for (const t10 of af.top10 ?? []) {\n const fcAttrs: Record<string, string | number | boolean | undefined> = {\n colId: t10.colId,\n };\n if (t10.hiddenButton) fcAttrs.hiddenButton = 1;\n if (t10.showButton === false) fcAttrs.showButton = 0;\n const t10Attrs: Record<string, string | number | boolean | undefined> = { val: t10.val };\n if (t10.top === false) t10Attrs.top = 0;\n if (t10.percent) t10Attrs.percent = 1;\n if (t10.filterVal !== undefined) t10Attrs.filterVal = t10.filterVal;\n inner.push(`<filterColumn${attrs(fcAttrs)}><top10${attrs(t10Attrs)}/></filterColumn>`);\n }\n for (const cf of af.customFilters ?? []) {\n const fcAttrs: Record<string, string | number | boolean | undefined> = {\n colId: cf.colId,\n };\n if (cf.hiddenButton) fcAttrs.hiddenButton = 1;\n if (cf.showButton === false) fcAttrs.showButton = 0;\n const cfAttrs: Record<string, string | number | boolean | undefined> = {};\n if (cf.and) cfAttrs.and = 1;\n const filters: string[] = [];\n if (cf.val !== undefined) {\n const fAttrs: Record<string, string | number | boolean | undefined> = { val: cf.val };\n if (cf.operator) fAttrs.operator = cf.operator;\n filters.push(selfCloseElement(\"customFilter\", attrs(fAttrs)));\n }\n if (cf.val2 !== undefined) {\n filters.push(selfCloseElement(\"customFilter\", attrs({ val: cf.val2 })));\n }\n if (filters.length > 0) {\n inner.push(\n `<filterColumn${attrs(fcAttrs)}><customFilters${attrs(cfAttrs)}>${filters.join(\"\")}</customFilters></filterColumn>`,\n );\n }\n }\n // Simple filters (CT_Filters)\n for (const fi of af.filters ?? []) {\n const fcAttrs: Record<string, string | number | boolean | undefined> = {\n colId: fi.colId,\n };\n const filtersAttrs: Record<string, string | number | boolean | undefined> = {};\n if (fi.blank) filtersAttrs.blank = 1;\n if (fi.calendarType) filtersAttrs.calendarType = fi.calendarType;\n const valParts = (fi.values ?? []).map((v) => `<filter val=\"${escapeXml(v)}\"/>`);\n inner.push(\n `<filterColumn${attrs(fcAttrs)}><filters${attrs(filtersAttrs)}>${valParts.join(\"\")}</filters></filterColumn>`,\n );\n }\n if (af.sort && af.sort.length > 0) {\n const sortParts: string[] = [];\n for (const sc of af.sort) {\n const scAttrs: Record<string, string | number | boolean | undefined> = { ref: sc.ref };\n if (sc.descending) scAttrs.descending = 1;\n if (sc.sortBy) scAttrs.sortBy = sc.sortBy;\n if (sc.customList) scAttrs.customList = sc.customList;\n if (sc.iconId !== undefined) scAttrs.iconId = sc.iconId;\n sortParts.push(selfCloseElement(\"sortCondition\", attrs(scAttrs)));\n }\n const ssAttrs: Record<string, string | number | boolean | undefined> = { ref: af.ref };\n if (af.sortState?.columnSort) ssAttrs.columnSort = 1;\n if (af.sortState?.caseSensitive) ssAttrs.caseSensitive = 1;\n if (af.sortState?.sortMethod) ssAttrs.sortMethod = af.sortState.sortMethod;\n inner.push(`<sortState${attrs(ssAttrs)}>${sortParts.join(\"\")}</sortState>`);\n }\n // Color filters\n for (const cf of af.colorFilters ?? []) {\n const cfAttrs: Record<string, string | number | boolean | undefined> = {};\n if (cf.dxfId !== undefined) cfAttrs.dxfId = cf.dxfId;\n if (cf.cellColor === false) cfAttrs.cellColor = 0;\n inner.push(\n `<filterColumn colId=\"${cf.colId}\"><colorFilter${attrs(cfAttrs)}/></filterColumn>`,\n );\n }\n // Icon filters\n for (const if_ of af.iconFilters ?? []) {\n const ifAttrs: Record<string, string | number | boolean | undefined> = {\n iconSet: if_.iconSet,\n };\n if (if_.iconId !== undefined) ifAttrs.iconId = if_.iconId;\n inner.push(\n `<filterColumn colId=\"${if_.colId}\"><iconFilter${attrs(ifAttrs)}/></filterColumn>`,\n );\n }\n // Dynamic filters\n for (const df of af.dynamicFilters ?? []) {\n const dfAttrs: Record<string, string | number | boolean | undefined> = { type: df.type };\n if (df.val !== undefined) dfAttrs.val = df.val;\n if (df.maxVal !== undefined) dfAttrs.maxVal = df.maxVal;\n if (df.valIso !== undefined) dfAttrs.valIso = df.valIso;\n if (df.maxValIso !== undefined) dfAttrs.maxValIso = df.maxValIso;\n inner.push(\n `<filterColumn colId=\"${df.colId}\"><dynamicFilter${attrs(dfAttrs)}/></filterColumn>`,\n );\n }\n // Date group filters\n for (const dg of af.dateGroupItems ?? []) {\n const dgAttrs: Record<string, string | number | boolean | undefined> = {\n dateTimeGrouping: dg.dateTimeGrouping,\n };\n if (dg.year !== undefined) dgAttrs.year = dg.year;\n if (dg.month !== undefined) dgAttrs.month = dg.month;\n if (dg.day !== undefined) dgAttrs.day = dg.day;\n if (dg.hour !== undefined) dgAttrs.hour = dg.hour;\n if (dg.minute !== undefined) dgAttrs.minute = dg.minute;\n if (dg.second !== undefined) dgAttrs.second = dg.second;\n inner.push(\n `<filterColumn colId=\"${dg.colId}\"><dateGroupItem${attrs(dgAttrs)}/></filterColumn>`,\n );\n }\n if (inner.length > 0) {\n p.push(`<autoFilter ref=\"${af.ref}\">`, ...inner, \"</autoFilter>\");\n } else {\n p.push(selfCloseElement(\"autoFilter\", attrs({ ref: af.ref })));\n }\n }\n }\n\n // Merge cells\n if (mergeCells.length > 0) {\n p.push(`<mergeCells count=\"${mergeCells.length}\">`);\n for (const mc of mergeCells) {\n const fromRef = defaultCellRef(mc.from.row, mc.from.col);\n const toRef = defaultCellRef(mc.to.row, mc.to.col);\n p.push(selfCloseElement(\"mergeCell\", attrs({ ref: `${fromRef}:${toRef}` })));\n }\n p.push(\"</mergeCells>\");\n }\n\n // Phonetic properties (after mergeCells per XSD sequence)\n if (opts.phoneticPr) {\n const pp = opts.phoneticPr;\n const ppAttrs: Record<string, string | number> = { fontId: pp.fontId };\n if (pp.type && pp.type !== \"fullwidthKatakana\") ppAttrs.type = pp.type;\n if (pp.alignment && pp.alignment !== \"left\") ppAttrs.alignment = pp.alignment;\n p.push(selfCloseElement(\"phoneticPr\", attrs(ppAttrs)));\n }\n\n // Conditional formatting\n const conditionalFormats = opts.conditionalFormats ?? [];\n if (conditionalFormats.length > 0) {\n for (const cf of conditionalFormats) {\n p.push(`<conditionalFormatting sqref=\"${cf.sqref}\">`);\n for (let ri = 0; ri < cf.rules.length; ri++) {\n const rule = cf.rules[ri];\n const ruleAttrs: Record<string, string | number | boolean | undefined> = {\n type: rule.type,\n priority: rule.priority ?? ri + 1,\n };\n if (rule.operator) ruleAttrs.operator = rule.operator;\n if (rule.dxfId !== undefined) ruleAttrs.dxfId = rule.dxfId;\n if (rule.stopIfTrue) ruleAttrs.stopIfTrue = 1;\n if (rule.timePeriod) ruleAttrs.timePeriod = rule.timePeriod;\n if (rule.rank !== undefined) ruleAttrs.rank = rule.rank;\n if (rule.equalAverage) ruleAttrs.equalAverage = 1;\n\n // Color scale\n if (rule.type === \"colorScale\" && rule.colorScale) {\n const cs = rule.colorScale;\n const inner: string[] = [];\n for (const v of cs.cfvo) {\n inner.push(buildCfvoXml(v));\n }\n for (const c of cs.colors) {\n inner.push(`<color rgb=\"FF${c}\"/>`);\n }\n p.push(`<cfRule${attrs(ruleAttrs)}><colorScale>${inner.join(\"\")}</colorScale></cfRule>`);\n }\n // Data bar\n else if (rule.type === \"dataBar\" && rule.dataBar) {\n const db = rule.dataBar;\n const inner: string[] = [];\n for (const v of db.cfvo) {\n inner.push(buildCfvoXml(v));\n }\n inner.push(`<color rgb=\"FF${db.color}\"/>`);\n const dbAttrs: Record<string, string | number | boolean | undefined> = {};\n if (db.minLength !== undefined && db.minLength !== 10) dbAttrs.minLength = db.minLength;\n if (db.maxLength !== undefined && db.maxLength !== 90) dbAttrs.maxLength = db.maxLength;\n if (db.showValue === false) dbAttrs.showValue = 0;\n const attrStr = Object.keys(dbAttrs).length > 0 ? attrs(dbAttrs) : \"\";\n p.push(\n `<cfRule${attrs(ruleAttrs)}><dataBar${attrStr}>${inner.join(\"\")}</dataBar></cfRule>`,\n );\n }\n // Icon set\n else if (rule.type === \"iconSet\" && rule.iconSet) {\n const is = rule.iconSet;\n const inner: string[] = [];\n for (const v of is.cfvo) {\n inner.push(buildCfvoXml(v));\n }\n const isAttrs: Record<string, string | number | boolean | undefined> = {};\n if (is.iconSet !== undefined && is.iconSet !== \"3TrafficLights1\")\n isAttrs.iconSet = is.iconSet;\n if (is.showValue === false) isAttrs.showValue = 0;\n if (is.percent === false) isAttrs.percent = 0;\n if (is.reverse) isAttrs.reverse = 1;\n const attrStr = Object.keys(isAttrs).length > 0 ? attrs(isAttrs) : \"\";\n p.push(\n `<cfRule${attrs(ruleAttrs)}><iconSet${attrStr}>${inner.join(\"\")}</iconSet></cfRule>`,\n );\n }\n // Standard rules (cellIs, containsText, expression, top10, aboveAverage)\n else {\n if (rule.formulas && rule.formulas.length > 0) {\n const formulaParts = rule.formulas.map((f) => `<formula>${escapeXml(f)}</formula>`);\n p.push(`<cfRule${attrs(ruleAttrs)}>`, ...formulaParts, \"</cfRule>\");\n } else {\n p.push(selfCloseElement(\"cfRule\", attrs(ruleAttrs)));\n }\n }\n }\n p.push(\"</conditionalFormatting>\");\n }\n }\n\n // Data validations\n const dataValidations = opts.dataValidations ?? [];\n if (dataValidations.length > 0) {\n const dvContainerAttrs: Record<string, string | number | boolean | undefined> = {\n count: dataValidations.length,\n };\n if (opts.dataValidationsDisablePrompts) dvContainerAttrs.disablePrompts = 1;\n p.push(`<dataValidations${attrs(dvContainerAttrs)}>`);\n for (const dv of dataValidations) {\n const dvAttrs: Record<string, string | number | boolean | undefined> = { sqref: dv.sqref };\n if (dv.type && dv.type !== \"none\") dvAttrs.type = dv.type;\n if (dv.operator) dvAttrs.operator = dv.operator;\n if (dv.allowBlank) dvAttrs.allowBlank = 1;\n if (dv.showErrorMessage) dvAttrs.showErrorMessage = 1;\n if (dv.showInputMessage) dvAttrs.showInputMessage = 1;\n if (dv.errorTitle) dvAttrs.errorTitle = dv.errorTitle;\n if (dv.error) dvAttrs.error = dv.error;\n if (dv.promptTitle) dvAttrs.promptTitle = dv.promptTitle;\n if (dv.prompt) dvAttrs.prompt = dv.prompt;\n if (dv.errorStyle) dvAttrs.errorStyle = dv.errorStyle;\n if (dv.imeMode) dvAttrs.imeMode = dv.imeMode;\n if (dv.showDropDown) dvAttrs.showDropDown = 1;\n const inner: string[] = [];\n if (dv.formula1 !== undefined) inner.push(`<formula1>${escapeXml(dv.formula1)}</formula1>`);\n if (dv.formula2 !== undefined) inner.push(`<formula2>${escapeXml(dv.formula2)}</formula2>`);\n if (inner.length > 0) {\n p.push(`<dataValidation${attrs(dvAttrs)}>`, ...inner, \"</dataValidation>\");\n } else {\n p.push(selfCloseElement(\"dataValidation\", attrs(dvAttrs)));\n }\n }\n p.push(\"</dataValidations>\");\n }\n\n // Hyperlinks — r:id numbering must match worksheet rels order (compiler handles rels)\n const hyperlinks = opts.hyperlinks ?? [];\n if (hyperlinks.length > 0) {\n p.push(\"<hyperlinks>\");\n let hlIdx = 0;\n for (const hl of hyperlinks) {\n const hlAttrs: Record<string, string | number | boolean | undefined> = { ref: hl.cell };\n if (hl.target.type === \"external\") {\n hlIdx++;\n hlAttrs[\"r:id\"] = `rId${hlIdx}`;\n } else {\n hlAttrs.location = hl.target.location;\n }\n if (hl.tooltip) hlAttrs.tooltip = hl.tooltip;\n if (hl.display) hlAttrs.display = hl.display;\n p.push(selfCloseElement(\"hyperlink\", attrs(hlAttrs)));\n }\n p.push(\"</hyperlinks>\");\n }\n\n // Print options\n if (opts.printOptions) {\n const po = opts.printOptions;\n const poAttrs: Record<string, string | number | boolean | undefined> = {};\n if (po.horizontalCentered) poAttrs.horizontalCentered = 1;\n if (po.verticalCentered) poAttrs.verticalCentered = 1;\n if (po.headings) poAttrs.headings = 1;\n if (po.gridLines) poAttrs.gridLines = 1;\n if (po.gridLinesSet === false) poAttrs.gridLinesSet = 0;\n p.push(selfCloseElement(\"printOptions\", attrs(poAttrs)));\n }\n\n p.push('<pageMargins left=\"0.75\" right=\"0.75\" top=\"1\" bottom=\"1\" header=\"0.5\" footer=\"0.5\"/>');\n\n // Page setup\n if (opts.pageSetup) {\n const ps = opts.pageSetup;\n const psAttrs: Record<string, string | number | boolean | undefined> = {};\n if (ps.paperSize !== undefined) psAttrs.paperSize = ps.paperSize;\n if (ps.orientation && ps.orientation !== \"default\") psAttrs.orientation = ps.orientation;\n if (ps.scale !== undefined) psAttrs.scale = ps.scale;\n if (ps.fitToWidth !== undefined) psAttrs.fitToWidth = ps.fitToWidth;\n if (ps.fitToHeight !== undefined) psAttrs.fitToHeight = ps.fitToHeight;\n if (ps.pageOrder && ps.pageOrder !== \"downThenOver\") psAttrs.pageOrder = ps.pageOrder;\n if (ps.useFirstPageNumber) psAttrs.useFirstPageNumber = 1;\n if (ps.firstPageNumber !== undefined) psAttrs.firstPageNumber = ps.firstPageNumber;\n if (ps.paperHeight !== undefined) psAttrs.paperHeight = ps.paperHeight;\n if (ps.paperWidth !== undefined) psAttrs.paperWidth = ps.paperWidth;\n if (ps.usePrinterDefaults) psAttrs.usePrinterDefaults = 1;\n if (ps.blackAndWhite) psAttrs.blackAndWhite = 1;\n if (ps.draft) psAttrs.draft = 1;\n if (ps.cellComments && ps.cellComments !== \"none\") psAttrs.cellComments = ps.cellComments;\n if (ps.errors && ps.errors !== \"displayed\") psAttrs.errors = ps.errors;\n p.push(selfCloseElement(\"pageSetup\", attrs(psAttrs)));\n }\n\n // Header/footer\n if (opts.headerFooter) {\n const hf = opts.headerFooter;\n const hfAttrs: Record<string, string | number | boolean | undefined> = {};\n if (hf.differentOddEven) hfAttrs.differentOddEven = 1;\n if (hf.differentFirst) hfAttrs.differentFirst = 1;\n if (hf.scaleWithDoc === false) hfAttrs.scaleWithDoc = 0;\n if (hf.alignWithMargins === false) hfAttrs.alignWithMargins = 0;\n const inner: string[] = [];\n if (hf.oddHeader) inner.push(`<oddHeader>${escapeXml(hf.oddHeader)}</oddHeader>`);\n if (hf.oddFooter) inner.push(`<oddFooter>${escapeXml(hf.oddFooter)}</oddFooter>`);\n if (hf.evenHeader) inner.push(`<evenHeader>${escapeXml(hf.evenHeader)}</evenHeader>`);\n if (hf.evenFooter) inner.push(`<evenFooter>${escapeXml(hf.evenFooter)}</evenFooter>`);\n if (hf.firstHeader) inner.push(`<firstHeader>${escapeXml(hf.firstHeader)}</firstHeader>`);\n if (hf.firstFooter) inner.push(`<firstFooter>${escapeXml(hf.firstFooter)}</firstFooter>`);\n if (inner.length > 0) {\n p.push(`<headerFooter${attrs(hfAttrs)}>`, ...inner, \"</headerFooter>\");\n } else if (hfAttrs.differentOddEven || hfAttrs.differentFirst) {\n p.push(selfCloseElement(\"headerFooter\", attrs(hfAttrs)));\n }\n }\n\n // Drawing in header/footer (after headerFooter per XSD sequence)\n if (opts.drawingHF) {\n const dhf = opts.drawingHF;\n const dhfAttrs: Record<string, string | number | boolean | undefined> = { \"r:id\": dhf.rId };\n if (dhf.lho !== undefined) dhfAttrs.lho = dhf.lho;\n if (dhf.lhe !== undefined) dhfAttrs.lhe = dhf.lhe;\n if (dhf.lhf !== undefined) dhfAttrs.lhf = dhf.lhf;\n if (dhf.cho !== undefined) dhfAttrs.cho = dhf.cho;\n if (dhf.che !== undefined) dhfAttrs.che = dhf.che;\n if (dhf.chf !== undefined) dhfAttrs.chf = dhf.chf;\n if (dhf.rho !== undefined) dhfAttrs.rho = dhf.rho;\n if (dhf.rhe !== undefined) dhfAttrs.rhe = dhf.rhe;\n if (dhf.rhf !== undefined) dhfAttrs.rhf = dhf.rhf;\n if (dhf.lfo !== undefined) dhfAttrs.lfo = dhf.lfo;\n if (dhf.lfe !== undefined) dhfAttrs.lfe = dhf.lfe;\n if (dhf.lff !== undefined) dhfAttrs.lff = dhf.lff;\n if (dhf.cfo !== undefined) dhfAttrs.cfo = dhf.cfo;\n if (dhf.cfe !== undefined) dhfAttrs.cfe = dhf.cfe;\n if (dhf.cff !== undefined) dhfAttrs.cff = dhf.cff;\n if (dhf.rfo !== undefined) dhfAttrs.rfo = dhf.rfo;\n if (dhf.rfe !== undefined) dhfAttrs.rfe = dhf.rfe;\n if (dhf.rff !== undefined) dhfAttrs.rff = dhf.rff;\n p.push(selfCloseElement(\"drawingHF\", attrs(dhfAttrs)));\n }\n\n // Legacy drawing in header/footer\n if (opts.legacyDrawingHF) {\n p.push(`<legacyDrawingHF r:id=\"${escapeXml(opts.legacyDrawingHF)}\"/>`);\n }\n\n // Ignored errors (after headerFooter per XSD sequence)\n if (ignoredErrors.length > 0) {\n const ieParts: string[] = [\"<ignoredErrors>\"];\n for (const ie of ignoredErrors) {\n const ieAttrs: Record<string, string | number | boolean | undefined> = {\n sqref: ie.sqref,\n };\n if (ie.evalError) ieAttrs.evalError = 1;\n if (ie.twoDigitTextYear) ieAttrs.twoDigitTextYear = 1;\n if (ie.numberStoredAsText) ieAttrs.numberStoredAsText = 1;\n if (ie.formula) ieAttrs.formula = 1;\n if (ie.formulaRange) ieAttrs.formulaRange = 1;\n if (ie.unlockedFormula) ieAttrs.unlockedFormula = 1;\n if (ie.emptyCellReference) ieAttrs.emptyCellReference = 1;\n if (ie.listDataValidation) ieAttrs.listDataValidation = 1;\n if (ie.calculatedColumn) ieAttrs.calculatedColumn = 1;\n ieParts.push(selfCloseElement(\"ignoredError\", attrs(ieAttrs)));\n }\n ieParts.push(\"</ignoredErrors>\");\n p.push(ieParts.join(\"\"));\n }\n\n // Background picture placeholder — compiler replaces with <picture r:id=\"rIdN\"/>\n if (opts.backgroundImage) {\n p.push(\"<!--BACKGROUND_PICTURE-->\");\n }\n\n // OLE objects (CT_OleObjects, after picture per XSD sequence)\n if (oleObjects.length > 0) {\n const oleParts: string[] = [\"<oleObjects>\"];\n for (const ole of oleObjects) {\n const oleAttrs: string[] = [`shapeId=\"${ole.shapeId}\"`];\n if (ole.progId) oleAttrs.push(`progId=\"${escapeXml(ole.progId)}\"`);\n if (ole.dvAspect && ole.dvAspect !== \"DVASPECT_CONTENT\")\n oleAttrs.push(`dvAspect=\"${ole.dvAspect}\"`);\n if (ole.link) oleAttrs.push(`link=\"${escapeXml(ole.link)}\"`);\n if (ole.oleUpdate) oleAttrs.push(`oleUpdate=\"${ole.oleUpdate}\"`);\n if (ole.autoLoad) oleAttrs.push('autoLoad=\"1\"');\n if (ole.rId) oleAttrs.push(`r:id=\"${escapeXml(ole.rId)}\"`);\n // objectPr (CT_ObjectPr, optional child)\n if (ole.objectPr) {\n const opr = ole.objectPr;\n const oprAttrs: string[] = [];\n if (opr.locked === false) oprAttrs.push('locked=\"0\"');\n if (opr.defaultSize === false) oprAttrs.push('defaultSize=\"0\"');\n if (opr.print === false) oprAttrs.push('print=\"0\"');\n if (opr.disabled) oprAttrs.push('disabled=\"1\"');\n if (opr.uiObject) oprAttrs.push('uiObject=\"1\"');\n if (opr.autoFill === false) oprAttrs.push('autoFill=\"0\"');\n if (opr.autoLine === false) oprAttrs.push('autoLine=\"0\"');\n if (opr.autoPict === false) oprAttrs.push('autoPict=\"0\"');\n if (opr.macro) oprAttrs.push(`macro=\"${escapeXml(opr.macro)}\"`);\n if (opr.altText) oprAttrs.push(`altText=\"${escapeXml(opr.altText)}\"`);\n if (opr.dde) oprAttrs.push('dde=\"1\"');\n if (opr.rId) oprAttrs.push(`r:id=\"${escapeXml(opr.rId)}\"`);\n oleParts.push(\n `<oleObject ${oleAttrs.join(\" \")}><objectPr${oprAttrs.length ? \" \" + oprAttrs.join(\" \") : \"\"}/></oleObject>`,\n );\n } else {\n oleParts.push(`<oleObject ${oleAttrs.join(\" \")}/>`);\n }\n }\n oleParts.push(\"</oleObjects>\");\n p.push(oleParts.join(\"\"));\n }\n\n // Controls (CT_Controls, after oleObjects per XSD sequence)\n if (controls.length > 0) {\n const ctrlParts: string[] = [\"<controls>\"];\n for (const c of controls) {\n const cAttrs: string[] = [`shapeId=\"${c.shapeId}\"`, `r:id=\"${escapeXml(c.rId)}\"`];\n if (c.name) cAttrs.push(`name=\"${escapeXml(c.name)}\"`);\n // controlPr (optional)\n const prAttrs: string[] = [];\n if (c.locked === false) prAttrs.push('locked=\"0\"');\n if (c.uiObject) prAttrs.push('uiObject=\"1\"');\n if (c.recalcAlways) prAttrs.push('recalcAlways=\"1\"');\n if (c.linkedCell) prAttrs.push(`linkedCell=\"${escapeXml(c.linkedCell)}\"`);\n if (c.listFillRange) prAttrs.push(`listFillRange=\"${escapeXml(c.listFillRange)}\"`);\n if (c.cf) prAttrs.push(`cf=\"${escapeXml(c.cf)}\"`);\n if (prAttrs.length > 0) {\n ctrlParts.push(\n `<control ${cAttrs.join(\" \")}><controlPr${prAttrs.length ? \" \" + prAttrs.join(\" \") : \"\"}/></control>`,\n );\n } else {\n ctrlParts.push(`<control ${cAttrs.join(\" \")}/>`);\n }\n }\n ctrlParts.push(\"</controls>\");\n p.push(ctrlParts.join(\"\"));\n }\n\n // Web publish items (CT_WebPublishItems, after controls per XSD sequence)\n if (webPublishItems.length > 0) {\n const wpParts: string[] = [`<webPublishItems count=\"${webPublishItems.length}\">`];\n for (const wpi of webPublishItems) {\n const wpiAttrs: string[] = [\n `id=\"${wpi.id}\"`,\n `divId=\"${escapeXml(wpi.divId)}\"`,\n `sourceType=\"${wpi.sourceType}\"`,\n `destinationFile=\"${escapeXml(wpi.destinationFile)}\"`,\n ];\n if (wpi.sourceRef) wpiAttrs.push(`sourceRef=\"${escapeXml(wpi.sourceRef)}\"`);\n if (wpi.sourceObject) wpiAttrs.push(`sourceObject=\"${escapeXml(wpi.sourceObject)}\"`);\n if (wpi.title) wpiAttrs.push(`title=\"${escapeXml(wpi.title)}\"`);\n if (wpi.autoRepublish) wpiAttrs.push('autoRepublish=\"1\"');\n wpParts.push(`<webPublishItem ${wpiAttrs.join(\" \")}/>`);\n }\n wpParts.push(\"</webPublishItems>\");\n p.push(wpParts.join(\"\"));\n }\n\n // Extension list (extLst, last per XSD sequence)\n if (opts.ext) {\n p.push(`<extLst>${opts.ext}</extLst>`);\n }\n\n p.push(\"</worksheet>\");\n return p.join(\"\");\n}\n\n// ── Stringify helpers ──\n\nfunction buildCfvoXml(cfvo: CfvoOptions): string {\n const a: Record<string, string | number | boolean | undefined> = { type: cfvo.type };\n if (cfvo.val !== undefined) a.val = cfvo.val;\n if (cfvo.gte === false) a.gte = 0;\n return `<cfvo${attrs(a)}/>`;\n}\n\nfunction buildSheetViewAttrs(sv?: SheetViewOptions): string {\n const svMap: Record<string, string | number | boolean | undefined> = {\n workbookViewId: 0,\n };\n if (sv?.tabSelected !== undefined) svMap.tabSelected = sv.tabSelected ? 1 : 0;\n else svMap.tabSelected = 1;\n if (sv?.showGridLines === false) svMap.showGridLines = 0;\n if (sv?.showRowColHeaders === false) svMap.showRowColHeaders = 0;\n if (sv?.showZeros === false) svMap.showZeros = 0;\n if (sv?.zoomScale !== undefined) svMap.zoomScale = sv.zoomScale;\n if (sv?.rightToLeft) svMap.rightToLeft = 1;\n if (sv?.windowProtection) svMap.windowProtection = 1;\n if (sv?.showFormulas) svMap.showFormulas = 1;\n if (sv?.showRuler === false) svMap.showRuler = 0;\n if (sv?.showOutlineSymbols === false) svMap.showOutlineSymbols = 0;\n if (sv?.defaultGridColor === false) svMap.defaultGridColor = 0;\n if (sv?.showWhiteSpace === false) svMap.showWhiteSpace = 0;\n if (sv?.view) svMap.view = sv.view;\n if (sv?.colorId !== undefined) svMap.colorId = sv.colorId;\n if (sv?.zoomScaleNormal !== undefined) svMap.zoomScaleNormal = sv.zoomScaleNormal;\n if (sv?.zoomScaleSheetLayoutView !== undefined)\n svMap.zoomScaleSheetLayoutView = sv.zoomScaleSheetLayoutView;\n if (sv?.zoomScalePageLayoutView !== undefined)\n svMap.zoomScalePageLayoutView = sv.zoomScalePageLayoutView;\n return attrs(svMap);\n}\n\nfunction buildSelectionXml(sel: SelectionOptions): string {\n const selAttrs: Record<string, string | number | boolean | undefined> = {};\n if (sel.pane) selAttrs.pane = sel.pane;\n if (sel.activeCell) selAttrs.activeCell = sel.activeCell;\n if (sel.activeCellId !== undefined) selAttrs.activeCellId = sel.activeCellId;\n if (sel.sqref) selAttrs.sqref = sel.sqref;\n return `<selection${attrs(selAttrs)}/>`;\n}\n\nfunction buildPivotSelectionXml(_ps: PivotSelectionOptions): string {\n // pivotSelection is optional; omit if no meaningful pivotArea can be constructed.\n // An empty <pivotArea/> causes Excel to reject the file.\n return \"\";\n}\n\nfunction hashPassword(password: string): string {\n let hash = 0;\n for (let i = 0; i < password.length; i++) {\n const c = password.charCodeAt(i);\n hash = ((hash >> 14) & 1) + ((hash << 1) & 0x7fff);\n hash ^= c;\n hash = hash & 0x4000 ? hash ^ 0x1 : hash;\n }\n hash = ((hash >> 14) & 1) + ((hash << 1) & 0x7fff);\n hash = ((hash >> 14) & 1) + ((hash << 1) & 0x7fff);\n hash ^= password.length;\n return hash.toString(16).toUpperCase().padStart(4, \"0\");\n}\n\nfunction buildFormulaString(fOpts: FormulaOptions): string {\n const fAttrs: Record<string, string | number | boolean | undefined> = {};\n if (fOpts.type && fOpts.type !== FormulaType.NORMAL) fAttrs.t = fOpts.type;\n if (fOpts.reference) fAttrs.ref = fOpts.reference;\n if (fOpts.sharedIndex !== undefined) fAttrs.si = fOpts.sharedIndex;\n if (fOpts.aca) fAttrs.aca = 1;\n if (fOpts.dt2D) fAttrs.dt2D = 1;\n if (fOpts.dtr) fAttrs.dtr = 1;\n if (fOpts.del1) fAttrs.del1 = 1;\n if (fOpts.del2) fAttrs.del2 = 1;\n if (fOpts.r1) fAttrs.r1 = fOpts.r1;\n if (fOpts.r2) fAttrs.r2 = fOpts.r2;\n if (fOpts.ca) fAttrs.ca = 1;\n if (fOpts.bx) fAttrs.bx = 1;\n\n const hasContent = fOpts.formula !== undefined && fOpts.formula !== \"\";\n\n if (hasContent) {\n return `<f${attrs(fAttrs)}>${escapeXml(fOpts.formula)}</f>`;\n }\n if (Object.keys(fAttrs).length > 0) {\n return selfCloseElement(\"f\", attrs(fAttrs));\n }\n return \"\";\n}\n\nfunction buildCellString(\n ref: string,\n cell: CellOptions,\n sharedStrings?: SharedStrings,\n styles?: Styles,\n): string {\n const cellAttrs: Record<string, string | number | boolean | undefined> = { r: ref };\n\n // Resolve style\n if (cell.style !== undefined && styles) {\n cellAttrs.s = styles.register(cell.style);\n } else if (cell.styleIndex !== undefined) {\n cellAttrs.s = cell.styleIndex;\n }\n\n const value = cell.value;\n\n // Formula path — formula takes precedence; value is the cached result.\n if (cell.formula) {\n const fStr = buildFormulaString(cell.formula);\n let vStr = \"\";\n if (value === null || value === undefined) {\n return `<c${attrsRaw(cellAttrs)}>${fStr}</c>`;\n }\n if (typeof value === \"number\") {\n vStr = `<v>${value}</v>`;\n } else if (typeof value === \"boolean\") {\n cellAttrs.t = \"b\";\n vStr = `<v>${value ? 1 : 0}</v>`;\n } else if (typeof value === \"string\") {\n cellAttrs.t = \"str\";\n vStr = `<v>${escapeXml(value)}</v>`;\n } else if (value instanceof Date) {\n vStr = `<v>${dateToSerialNumber(value)}</v>`;\n }\n if (vStr) {\n return `<c${attrsRaw(cellAttrs)}>${fStr}${vStr}</c>`;\n }\n return `<c${attrsRaw(cellAttrs)}>${fStr}</c>`;\n }\n\n if (value === null || value === undefined) {\n if (cell.styleIndex !== undefined) {\n return selfCloseElement(\"c\", attrsRaw(cellAttrs));\n }\n return \"\";\n }\n\n // Rich text value (RichTextOptions)\n if (typeof value === \"object\" && !(value instanceof Date)) {\n if (sharedStrings) {\n cellAttrs.t = \"s\";\n const idx = sharedStrings.registerRich(value);\n return `<c${attrsRaw(cellAttrs)}><v>${idx}</v></c>`;\n }\n cellAttrs.t = \"inlineStr\";\n return `<c${attrsRaw(cellAttrs)}><is>${buildRstXml(value)}</is></c>`;\n }\n\n if (typeof value === \"string\") {\n if (sharedStrings) {\n cellAttrs.t = \"s\";\n const idx = sharedStrings.register(value);\n return `<c${attrsRaw(cellAttrs)}><v>${idx}</v></c>`;\n }\n cellAttrs.t = \"inlineStr\";\n return `<c${attrsRaw(cellAttrs)}><is><t>${escapeXml(value)}</t></is></c>`;\n }\n\n if (typeof value === \"number\") {\n return `<c${attrsRaw(cellAttrs)}><v>${value}</v></c>`;\n }\n\n if (typeof value === \"boolean\") {\n cellAttrs.t = \"b\";\n return `<c${attrsRaw(cellAttrs)}><v>${value ? 1 : 0}</v></c>`;\n }\n\n if (value instanceof Date) {\n const serial = dateToSerialNumber(value);\n return `<c${attrsRaw(cellAttrs)}><v>${serial}</v></c>`;\n }\n\n return \"\";\n}\n\nfunction defaultCellRef(row: number, col: number): string {\n return columnToLetter(col) + row;\n}\n\nfunction columnToLetter(col: number): string {\n let result = \"\";\n let n = col;\n while (n > 0) {\n const remainder = (n - 1) % 26;\n result = String.fromCharCode(65 + remainder) + result;\n n = Math.floor((n - 1) / 26);\n }\n return result;\n}\n\nfunction dateToSerialNumber(date: Date): number {\n const epoch = new Date(1899, 11, 30);\n const msPerDay = 86400000;\n return (date.getTime() - epoch.getTime()) / msPerDay;\n}\n\n// ── Parse helpers ──\n\nfunction parseCfvo(el: XmlElement): Record<string, unknown> {\n const result: Record<string, unknown> = {};\n result.type = attr(el, \"type\") ?? \"num\";\n const val = attr(el, \"val\");\n if (val !== undefined) result.val = isNaN(Number(val)) ? val : Number(val);\n if (attr(el, \"gte\") === \"0\") result.gte = false;\n return result;\n}\n\nfunction parseCellRef(ref: string): { row: number; col: number } | undefined {\n const match = ref.match(/^([A-Z]+)(\\d+)$/);\n if (!match) return undefined;\n const colStr = match[1];\n const row = parseInt(match[2], 10);\n let col = 0;\n for (let i = 0; i < colStr.length; i++) {\n col = col * 26 + (colStr.charCodeAt(i) - 64);\n }\n return { row, col };\n}\n","/**\n * Calculation Chain types and descriptor.\n *\n * Reference: OOXML transitional, sml.xsd, CT_CalcChain / CT_CalcCell\n *\n * @module\n */\n\nimport type { CustomDescriptor } from \"@office-open/core/descriptor\";\nimport { attrs } from \"@office-open/xml\";\n\n// ── Types ──\n\nexport interface CalcCell {\n /** Cell reference, e.g. \"A1\" */\n reference: string;\n /** Sheet index (1-based) */\n sheetIndex: number;\n /** Array formula */\n array?: boolean;\n}\n\nexport interface CalcChainOptions {\n cells: CalcCell[];\n}\n\n// ── Descriptor ──\n\nexport const calcChainDesc: CustomDescriptor<CalcChainOptions> = {\n kind: \"custom\",\n\n stringify(opts, _ctx) {\n const parts: string[] = [\n '<calcChain xmlns=\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\">',\n ];\n for (const cell of opts.cells) {\n const cellAttrs: Record<string, string | number | boolean> = {\n r: cell.reference,\n i: cell.sheetIndex,\n };\n if (cell.array) cellAttrs.a = true;\n parts.push(`<c${attrs(cellAttrs)}/>`);\n }\n parts.push(\"</calcChain>\");\n return parts.join(\"\");\n },\n\n parse(el, _ctx) {\n const result: Record<string, unknown> = {};\n const cells: CalcCell[] = [];\n for (const child of el.elements ?? []) {\n if (child.name !== \"c\") continue;\n const r = child.attributes?.[\"r\"];\n const i = child.attributes?.[\"i\"];\n if (r && i) {\n const cell: CalcCell = {\n reference: String(r),\n sheetIndex: Number(i),\n };\n if (child.attributes?.[\"a\"]) cell.array = true;\n cells.push(cell);\n }\n }\n result.cells = cells;\n return result as unknown as CalcChainOptions;\n },\n};\n","/**\n * Chartsheet types and descriptor for SpreadsheetML documents.\n *\n * A chartsheet is a worksheet that contains only a chart (no cells).\n *\n * Reference: OOXML transitional, sml.xsd, CT_Chartsheet\n *\n * @module\n */\n\nimport type { CustomDescriptor } from \"@office-open/core/descriptor\";\nimport { attrs, escapeXml, findChild } from \"@office-open/xml\";\n\n// ── Types ──\n\nexport interface ChartsheetPageMargins {\n left?: number;\n right?: number;\n top?: number;\n bottom?: number;\n header?: number;\n footer?: number;\n}\n\nexport interface ChartsheetPageSetup {\n /** Paper size (1=Letter, 9=A4, etc.) */\n paperSize?: number;\n /** Orientation (\"default\" | \"portrait\" | \"landscape\") */\n orientation?: string;\n /** Horizontal DPI */\n horizontalDpi?: number;\n /** Vertical DPI */\n verticalDpi?: number;\n /** Copies to print */\n copies?: number;\n}\n\nexport interface ChartsheetProtectionOptions {\n /** Content is protected */\n content?: boolean;\n /** Objects are protected */\n objects?: boolean;\n}\n\nexport interface ChartsheetHeaderFooterOptions {\n /** Different first page header/footer */\n differentFirst?: boolean;\n /** Different odd/even page headers/footers */\n differentOddEven?: boolean;\n /** Odd page header */\n oddHeader?: string;\n /** Odd page footer */\n oddFooter?: string;\n}\n\nexport interface ChartsheetOptions {\n /** Sheet name */\n name?: string;\n /** Tab color (hex ARGB, e.g. \"FF4472C4\") */\n tabColor?: string;\n /** Page margins */\n pageMargins?: ChartsheetPageMargins;\n /** Page setup */\n pageSetup?: ChartsheetPageSetup;\n /** Header/footer */\n headerFooter?: ChartsheetHeaderFooterOptions;\n /** Sheet protection */\n sheetProtection?: ChartsheetProtectionOptions;\n /** Published to server (CT_ChartsheetPr @published) */\n published?: boolean;\n /** Zoom to fit (CT_ChartsheetView @zoomToFit) */\n zoomToFit?: boolean;\n /** Chart definition (type, title, series, etc.) */\n chart: {\n type: string;\n title?: string;\n categories?: string[];\n series: {\n name: string;\n values: number[];\n }[];\n };\n}\n\n// ── Descriptor Types ──\n\nexport interface ChartsheetDescriptorOptions extends ChartsheetOptions {\n /** Relationship ID for the drawing (set by compiler) */\n drawingRId: string;\n}\n\n// ── Descriptor ──\n\nexport const chartsheetDesc: CustomDescriptor<ChartsheetDescriptorOptions> = {\n kind: \"custom\",\n\n stringify(opts, _ctx) {\n const p: string[] = [\n '<chartsheet xmlns=\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\"' +\n ' xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\">',\n ];\n\n // sheetPr (optional)\n if (opts.tabColor || opts.published) {\n const prAttrs: string[] = [];\n if (opts.tabColor) prAttrs.push(`<tabColor${attrs({ rgb: opts.tabColor })}/>`);\n const spAttr = opts.published ? ' published=\"1\"' : \"\";\n p.push(`<sheetPr${spAttr}>${prAttrs.join(\"\")}</sheetPr>`);\n }\n\n // sheetViews (required)\n const svAttrs: string[] = ['workbookViewId=\"0\"'];\n if (opts.zoomToFit) svAttrs.push('zoomToFit=\"1\"');\n p.push(`<sheetViews><sheetView ${svAttrs.join(\" \")}/></sheetViews>`);\n\n // sheetProtection (optional)\n if (opts.sheetProtection) {\n const sp = opts.sheetProtection;\n const spAttrs: string[] = [];\n if (sp.content) spAttrs.push(` content=\"1\"`);\n if (sp.objects) spAttrs.push(` objects=\"1\"`);\n if (spAttrs.length > 0) {\n p.push(`<sheetProtection${spAttrs.join(\"\")}/>`);\n }\n }\n\n // pageMargins (optional)\n if (opts.pageMargins) {\n const pm = opts.pageMargins;\n p.push(\n `<pageMargins${attrs({\n left: pm.left ?? 0.7,\n right: pm.right ?? 0.7,\n top: pm.top ?? 0.75,\n bottom: pm.bottom ?? 0.75,\n header: pm.header ?? 0.3,\n footer: pm.footer ?? 0.3,\n })}/>`,\n );\n }\n\n // pageSetup (optional)\n if (opts.pageSetup) {\n const ps = opts.pageSetup;\n p.push(\n `<pageSetup${attrs({\n paperSize: ps.paperSize,\n orientation: ps.orientation,\n horizontalDpi: ps.horizontalDpi,\n verticalDpi: ps.verticalDpi,\n copies: ps.copies,\n })}/>`,\n );\n }\n\n // headerFooter (optional)\n if (opts.headerFooter) {\n const hf = opts.headerFooter;\n const hfParts: string[] = [];\n if (hf.differentFirst) hfParts.push(` differentFirst=\"1\"`);\n if (hf.differentOddEven) hfParts.push(` differentOddEven=\"1\"`);\n const hfContent: string[] = [];\n if (hf.oddHeader) hfContent.push(`<oddHeader>${escapeXml(hf.oddHeader)}</oddHeader>`);\n if (hf.oddFooter) hfContent.push(`<oddFooter>${escapeXml(hf.oddFooter)}</oddFooter>`);\n p.push(`<headerFooter${hfParts.join(\"\")}>${hfContent.join(\"\")}</headerFooter>`);\n }\n\n // drawing (required)\n p.push(`<drawing r:id=\"${escapeXml(opts.drawingRId)}\"/>`);\n\n p.push(\"</chartsheet>\");\n return p.join(\"\");\n },\n\n parse(el, _ctx) {\n const result: Record<string, unknown> = {};\n\n // sheetPr\n const sheetPr = findChild(el, \"sheetPr\");\n if (sheetPr) {\n if (sheetPr.attributes?.[\"published\"] === \"1\") result.published = true;\n const tabColor = findChild(sheetPr, \"tabColor\");\n if (tabColor?.attributes?.[\"rgb\"]) result.tabColor = tabColor.attributes[\"rgb\"];\n }\n\n // sheetView\n const sheetViews = findChild(el, \"sheetViews\");\n if (sheetViews) {\n const sv = findChild(sheetViews, \"sheetView\");\n if (sv?.attributes?.[\"zoomToFit\"] === \"1\") result.zoomToFit = true;\n }\n\n return result as unknown as ChartsheetDescriptorOptions;\n },\n};\n","/**\n * Comments + VML notes descriptor for XLSX.\n *\n * Generates both xl/comments{n}.xml and xl/drawings/vmlDrawing{n}.vml\n * from the same CommentOptions array. Follows PPTX CustomDescriptor pattern.\n *\n * @module\n */\n\nimport type { CustomDescriptor } from \"@office-open/core/descriptor\";\nimport { findChild, attr, textOf } from \"@office-open/xml\";\nimport type { Element as XmlElement } from \"@office-open/xml\";\nimport { escapeXml } from \"@office-open/xml\";\n\nimport type {\n CommentOptions,\n RichTextOptions,\n RichTextRunOptions,\n RichTextRunPropertiesOptions,\n} from \"./worksheet\";\n\n// ── Comments descriptor (xl/comments{n}.xml) ──\n\nexport interface CommentsDocOptions {\n comments: CommentOptions[];\n}\n\nexport const commentsDesc: CustomDescriptor<CommentsDocOptions> = {\n kind: \"custom\",\n\n stringify(opts, _ctx) {\n if (opts.comments.length === 0) return undefined;\n const authors = collectAuthors(opts.comments);\n const p: string[] = [\n `<comments xmlns=\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\">`,\n `<authors>`,\n ];\n\n for (const author of authors) {\n p.push(`<author>${escapeXml(author)}</author>`);\n }\n\n p.push(\"</authors><commentList>\");\n\n for (const entry of opts.comments) {\n const authorId = authors.indexOf(entry.author);\n const textXml =\n typeof entry.text === \"string\"\n ? `<t>${escapeXml(entry.text)}</t>`\n : buildRstXml(entry.text);\n p.push(\n `<comment ref=\"${entry.cell}\" authorId=\"${authorId}\"><text>${textXml}</text></comment>`,\n );\n }\n\n p.push(\"</commentList></comments>\");\n return p.join(\"\");\n },\n\n parse(el, _ctx) {\n const comments: CommentOptions[] = [];\n const authors: string[] = [];\n\n const authorsEl = findChild(el, \"authors\");\n if (authorsEl) {\n for (const a of authorsEl.elements ?? []) {\n if (a.name === \"author\") authors.push(textOf(a) ?? \"\");\n }\n }\n\n const listEl = findChild(el, \"commentList\");\n if (listEl) {\n for (const c of listEl.elements ?? []) {\n if (c.name !== \"comment\") continue;\n const ref = attr(c, \"ref\") ?? \"\";\n const authorId = Number(attr(c, \"authorId\") ?? 0);\n const textEl = findChild(c, \"text\");\n const text = textEl ? parseRst(textEl) : \"\";\n comments.push({\n cell: ref,\n author: authors[authorId] ?? \"\",\n text,\n });\n }\n }\n\n return { comments } as CommentsDocOptions;\n },\n};\n\n// ── VML notes descriptor (xl/drawings/vmlDrawing{n}.vml) ──\n\nexport const vmlNotesDesc: CustomDescriptor<CommentsDocOptions> = {\n kind: \"custom\",\n\n stringify(opts, _ctx) {\n if (opts.comments.length === 0) return undefined;\n\n const p: string[] = [\n '<xml xmlns:v=\"urn:schemas-microsoft-com:vml\" xmlns:o=\"urn:schemas-microsoft-com:office:office\" xmlns:x=\"urn:schemas-microsoft-com:office:excel\">',\n '<o:shapelayout v:ext=\"edit\"><o:idmap v:ext=\"edit\" data=\"1\"/></o:shapelayout>',\n '<v:shapetype id=\"_x0000_t202\" coordsize=\"21600,21600\" o:spt=\"202\" path=\"m,l,21600r21600,l21600,xe\">',\n '<v:stroke joinstyle=\"miter\"/>',\n '<v:path gradientshapeok=\"t\" o:connecttype=\"rect\"/>',\n \"</v:shapetype>\",\n ];\n\n for (let i = 0; i < opts.comments.length; i++) {\n const c = opts.comments[i];\n const col = c.cell.charCodeAt(0) - 65;\n const row = parseInt(c.cell.slice(1), 10) - 1;\n const anchor = `${col}, 0, ${row}, 0, ${col + 2}, 0, ${row + 2}, 0`;\n p.push(\n `<v:shape id=\"_x0000_s${1025 + i}\" type=\"#_x0000_t202\" ` +\n `style=\"position:absolute;margin-left:59.25pt;margin-top:1.5pt;width:108pt;height:59.25pt;` +\n `z-index:1;visibility:hidden\" fillcolor=\"infoBackground [80]\" strokecolor=\"none [81]\" o:insetmode=\"auto\">`,\n `<v:fill color2=\"infoBackground [80]\"/>`,\n `<v:shadow color=\"none [81]\" obscured=\"t\"/>`,\n `<v:path o:connecttype=\"none\"/>`,\n `<v:textbox style=\"mso-direction-alt:auto\"><div style=\"text-align:left\"></div></v:textbox>`,\n `<x:ClientData ObjectType=\"Note\"><x:MoveWithCells/><x:SizeWithCells/>`,\n `<x:Anchor>${anchor}</x:Anchor>`,\n `<x:AutoFill>False</x:AutoFill>`,\n `<x:Row>${row}</x:Row>`,\n `<x:Column>${col}</x:Column>`,\n `</x:ClientData>`,\n `</v:shape>`,\n );\n }\n\n p.push(\"</xml>\");\n return p.join(\"\");\n },\n\n parse(_el, _ctx) {\n // VML parsing is not commonly needed — return empty\n return { comments: [] } as CommentsDocOptions;\n },\n};\n\n// ── Helpers ──\n\nfunction collectAuthors(comments: CommentOptions[]): string[] {\n const seen = new Set<string>();\n const result: string[] = [];\n for (const entry of comments) {\n if (!seen.has(entry.author)) {\n seen.add(entry.author);\n result.push(entry.author);\n }\n }\n return result.length > 0 ? result : [\"\"];\n}\n\n/** Build rich text (CT_Rst) XML from runs. */\nfunction buildRstXml(rst: RichTextOptions): string {\n const runs = rst.runs ?? [];\n const parts: string[] = [];\n for (const run of runs) {\n const props = run.properties;\n if (!props) {\n parts.push(`<r><t>${escapeXml(run.text)}</t></r>`);\n continue;\n }\n const rPr: string[] = [];\n if (props.bold) rPr.push(\"<b/>\");\n if (props.italic) rPr.push(\"<i/>\");\n if (props.underline) rPr.push(`<u val=\"${props.underline}\"/>`);\n if (props.strike) rPr.push(\"<strike/>\");\n if (props.size) rPr.push(`<sz val=\"${props.size}\"/>`);\n if (props.color) rPr.push(`<color rgb=\"${props.color}\"/>`);\n if (props.font) rPr.push(`<rFont val=\"${props.font}\"/>`);\n const rPrXml = rPr.length ? `<rPr>${rPr.join(\"\")}</rPr>` : \"\";\n parts.push(`<r>${rPrXml}<t>${escapeXml(run.text)}</t></r>`);\n }\n return parts.join(\"\");\n}\n\n/** Parse rich text element into a plain string or rich runs. */\nfunction parseRst(textEl: XmlElement): string | RichTextOptions {\n const runs: RichTextRunOptions[] = [];\n const parts: string[] = [];\n let hasRuns = false;\n for (const child of textEl.elements ?? []) {\n if (child.name === \"t\") {\n parts.push(textOf(child) ?? \"\");\n } else if (child.name === \"r\") {\n hasRuns = true;\n const t = findChild(child, \"t\");\n const run: RichTextRunOptions = { text: t ? (textOf(t) ?? \"\") : \"\" };\n const rPr = findChild(child, \"rPr\");\n if (rPr) {\n const props: RichTextRunPropertiesOptions = {};\n if (findChild(rPr, \"b\")) props.bold = true;\n if (findChild(rPr, \"i\")) props.italic = true;\n const uEl = findChild(rPr, \"u\");\n if (uEl)\n props.underline =\n (attr(uEl, \"val\") as RichTextRunPropertiesOptions[\"underline\"]) ?? \"single\";\n if (findChild(rPr, \"strike\")) props.strike = true;\n const szEl = findChild(rPr, \"sz\");\n if (szEl) {\n const sz = Number(attr(szEl, \"val\"));\n if (!Number.isNaN(sz)) props.size = sz;\n }\n const colorEl = findChild(rPr, \"color\");\n if (colorEl && attr(colorEl, \"rgb\")) props.color = attr(colorEl, \"rgb\");\n const rFontEl = findChild(rPr, \"rFont\");\n if (rFontEl && attr(rFontEl, \"val\")) props.font = attr(rFontEl, \"val\");\n run.properties = props;\n }\n runs.push(run);\n }\n }\n if (hasRuns) return { runs };\n return parts.join(\"\");\n}\n","/**\n * XLSX Drawing — image and chart anchor types and descriptor.\n *\n * Generates xl/drawings/drawing{n}.xml using the spreadsheetDrawing\n * namespace for anchoring images and charts to worksheet cells.\n *\n * @module\n */\n\nimport type { CustomDescriptor } from \"@office-open/core/descriptor\";\nimport { findChild } from \"@office-open/xml\";\nimport type { Element as XmlElement } from \"@office-open/xml\";\n\n// ── Types (used by compiler) ──\n\nexport interface ImageOptions {\n /** 1-based column */\n col: number;\n /** Column offset in EMU (default 0) */\n colOffset?: number;\n /** 1-based row */\n row: number;\n /** Row offset in EMU (default 0) */\n rowOffset?: number;\n /** Relationship ID for the image */\n rId: string;\n /** Lock anchor with sheet (default true) */\n locksWithSheet?: boolean;\n /** Print with sheet (default true) */\n printsWithSheet?: boolean;\n}\n\nexport interface ChartAnchorOptions {\n /** 1-based column */\n col: number;\n /** Column offset in EMU (default 0) */\n colOffset?: number;\n /** 1-based row */\n row: number;\n /** Row offset in EMU (default 0) */\n rowOffset?: number;\n /** Relationship ID for the chart */\n rId: string;\n /** Lock anchor with sheet (default true) */\n locksWithSheet?: boolean;\n /** Print with sheet (default true) */\n printsWithSheet?: boolean;\n}\n\n// ── Descriptor Types ──\n\nexport interface DrawingImageOptions {\n /** 1-based column */\n col: number;\n /** Column offset in EMU (default 0) */\n colOffset?: number;\n /** 1-based row */\n row: number;\n /** Row offset in EMU (default 0) */\n rowOffset?: number;\n /** Relationship ID for the image */\n rId: string;\n /** Lock anchor with sheet (default true) */\n locksWithSheet?: boolean;\n /** Print with sheet (default true) */\n printsWithSheet?: boolean;\n}\n\nexport interface DrawingChartOptions {\n /** 1-based column */\n col: number;\n /** Column offset in EMU (default 0) */\n colOffset?: number;\n /** 1-based row */\n row: number;\n /** Row offset in EMU (default 0) */\n rowOffset?: number;\n /** Relationship ID for the chart */\n rId: string;\n /** Lock anchor with sheet (default true) */\n locksWithSheet?: boolean;\n /** Print with sheet (default true) */\n printsWithSheet?: boolean;\n}\n\nexport interface DrawingOptions {\n images?: DrawingImageOptions[];\n charts?: DrawingChartOptions[];\n}\n\n// ── Constants ──\n\nconst XDR_NS = \"http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing\";\nconst A_NS = \"http://schemas.openxmlformats.org/drawingml/2006/main\";\nconst R_NS = \"http://schemas.openxmlformats.org/officeDocument/2006/relationships\";\nconst C_URI = \"http://schemas.openxmlformats.org/drawingml/2006/chart\";\n\n// ── Descriptor ──\n\nexport const drawingDesc: CustomDescriptor<DrawingOptions> = {\n kind: \"custom\",\n\n stringify(opts, _ctx) {\n const images = opts.images ?? [];\n const charts = opts.charts ?? [];\n if (images.length === 0 && charts.length === 0) return undefined;\n\n const p: string[] = [`<wsDr xmlns=\"${XDR_NS}\" xmlns:a=\"${A_NS}\" xmlns:r=\"${R_NS}\">`];\n let id = 1;\n\n for (const img of images) {\n p.push(\n `<twoCellAnchor editAs=\"oneCell\"><from><col>${img.col - 1}</col><colOff>${img.colOffset ?? 0}</colOff><row>${img.row - 1}</row><rowOff>${img.rowOffset ?? 0}</rowOff></from>`,\n `<to><col>${img.col}</col><colOff>0</colOff><row>${img.row}</row><rowOff>0</rowOff></to>`,\n `<pic><nvPicPr><cNvPr id=\"${id}\" name=\"Picture ${id}\"/><cNvPicPr preferRelativeResize=\"1\"/></nvPicPr>`,\n `<blipFill><a:blip r:embed=\"${img.rId}\"/><a:stretch><a:fillRect/></a:stretch></blipFill>`,\n `<spPr><a:xfrm><a:off x=\"0\" y=\"0\"/><a:ext cx=\"400000\" cy=\"300000\"/></a:xfrm><a:prstGeom prst=\"rect\"><a:avLst/></a:prstGeom></spPr></pic>`,\n `<clientData fLocksWithSheet=\"${img.locksWithSheet !== false ? 1 : 0}\" fPrintsWithSheet=\"${img.printsWithSheet !== false ? 1 : 0}\"/></twoCellAnchor>`,\n );\n id++;\n }\n\n for (const chart of charts) {\n p.push(\n `<twoCellAnchor editAs=\"oneCell\"><from><col>${chart.col - 1}</col><colOff>${chart.colOffset ?? 0}</colOff><row>${chart.row - 1}</row><rowOff>${chart.rowOffset ?? 0}</rowOff></from>`,\n `<to><col>${chart.col + 8}</col><colOff>0</colOff><row>${chart.row + 15}</row><rowOff>0</rowOff></to>`,\n `<graphicFrame><nvGraphicFramePr><cNvPr id=\"${id}\" name=\"Chart ${id}\"/><cNvGraphicFramePr><a:graphicFrameLocks noGrp=\"1\"/></cNvGraphicFramePr></nvGraphicFramePr>`,\n `<xfrm><a:off x=\"0\" y=\"0\"/><a:ext cx=\"0\" cy=\"0\"/></xfrm>`,\n `<a:graphic><a:graphicData uri=\"${C_URI}\"><c:chart xmlns:c=\"http://schemas.openxmlformats.org/drawingml/2006/chart\" xmlns:r=\"${R_NS}\" r:id=\"${chart.rId}\"/></a:graphicData></a:graphic></graphicFrame>`,\n `<clientData fLocksWithSheet=\"${chart.locksWithSheet !== false ? 1 : 0}\" fPrintsWithSheet=\"${chart.printsWithSheet !== false ? 1 : 0}\"/></twoCellAnchor>`,\n );\n id++;\n }\n\n p.push(\"</wsDr>\");\n return p.join(\"\");\n },\n\n parse(el, _ctx) {\n const result: Record<string, unknown> = {};\n const images: DrawingImageOptions[] = [];\n const charts: DrawingChartOptions[] = [];\n\n for (const anchor of el.elements ?? []) {\n if (anchor.name !== \"twoCellAnchor\") continue;\n const from = findChild(anchor, \"from\");\n findChild(anchor, \"to\"); // consumed but not used\n if (!from) continue;\n\n const col = readNumChild(from, \"col\") + 1;\n const colOffset = readNumChild(from, \"colOff\") || undefined;\n const row = readNumChild(from, \"row\") + 1;\n const rowOffset = readNumChild(from, \"rowOff\") || undefined;\n\n // Check if this is a picture or graphicFrame\n const pic = findChild(anchor, \"pic\");\n if (pic) {\n const blip = findChild(findChild(pic, \"blipFill\") ?? pic, \"a:blip\");\n const rId = blip?.attributes?.[\"r:embed\"] as string | undefined;\n if (rId) {\n const clientData = findChild(anchor, \"clientData\");\n images.push({\n col,\n colOffset,\n row,\n rowOffset,\n rId,\n locksWithSheet: clientData?.attributes?.[\"fLocksWithSheet\"] !== \"0\",\n printsWithSheet: clientData?.attributes?.[\"fPrintsWithSheet\"] !== \"0\",\n });\n }\n continue;\n }\n\n const graphicFrame = findChild(anchor, \"graphicFrame\");\n if (graphicFrame) {\n const graphicData = findChild(\n findChild(graphicFrame, \"a:graphic\") ?? graphicFrame,\n \"a:graphicData\",\n );\n const chartEl = graphicData ? findChild(graphicData, \"c:chart\") : undefined;\n const rId = chartEl?.attributes?.[\"r:id\"] as string | undefined;\n if (rId) {\n const clientData = findChild(anchor, \"clientData\");\n charts.push({\n col,\n colOffset,\n row,\n rowOffset,\n rId,\n locksWithSheet: clientData?.attributes?.[\"fLocksWithSheet\"] !== \"0\",\n printsWithSheet: clientData?.attributes?.[\"fPrintsWithSheet\"] !== \"0\",\n });\n }\n }\n }\n\n if (images.length > 0) result.images = images;\n if (charts.length > 0) result.charts = charts;\n return result as unknown as DrawingOptions;\n },\n};\n\n// ── Helpers ──\n\nfunction readNumChild(el: XmlElement, tag: string): number {\n const child = findChild(el, tag);\n if (!child?.elements?.length) return 0;\n const n = Number(child.elements[0]?.text ?? \"\");\n return Number.isNaN(n) ? 0 : n;\n}\n","/**\n * External Link types and descriptor for SpreadsheetML documents.\n *\n * Reference: OOXML transitional, sml.xsd, CT_ExternalLink\n *\n * @module\n */\n\nimport type { CustomDescriptor } from \"@office-open/core/descriptor\";\nimport { attrs, escapeXml, findChild } from \"@office-open/xml\";\n\n// ── Types ──\n\nexport interface ExternalDefinedNameOptions {\n name: string;\n refersTo?: string;\n sheetId?: number;\n /** Publish to server (CT_DefinedName @publishToServer) */\n publishToServer?: boolean;\n /** VBA procedure (CT_DefinedName @vbProcedure) */\n vbProcedure?: boolean;\n /** Workbook parameter (CT_DefinedName @workbookParameter) */\n workbookParameter?: boolean;\n /** XLM macro (CT_DefinedName @xlm) */\n xlm?: boolean;\n}\n\nexport interface ExternalCellOptions {\n /** Cell reference, e.g. \"A1\" */\n reference: string;\n /** Cell data type */\n type?: string;\n /** Cell value */\n value?: string;\n}\n\nexport interface ExternalBookOptions {\n /** Target path of the external workbook */\n target?: string;\n /** Sheet names from the external workbook */\n sheetNames?: string[];\n /** Defined names from the external workbook */\n definedNames?: ExternalDefinedNameOptions[];\n /** Cached sheet data from the external workbook */\n sheetDataSet?: ExternalSheetDataOptions[];\n}\n\nexport interface ExternalRowOptions {\n /** Row number (1-based) */\n rowNumber: number;\n cells?: ExternalCellOptions[];\n}\n\nexport interface ExternalSheetDataOptions {\n sheetId: number;\n refreshError?: boolean;\n rows?: ExternalRowOptions[];\n}\n\nexport interface ExternalLinkOptions {\n /** External book configuration */\n externalBook?: ExternalBookOptions;\n /** Relationship ID for the external book (set by compiler) */\n bookRId?: string;\n /** OLE link configuration (CT_OleLink) */\n oleLink?: OleLinkOptions;\n /** Relationship ID for the OLE link (set by compiler) */\n oleRId?: string;\n}\n\nexport interface OleItemOptions {\n /** OLE item name (required) */\n name: string;\n /** Whether to advise events */\n advise?: boolean;\n /** Whether preferred */\n prefer?: boolean;\n}\n\nexport interface OleLinkOptions {\n /** OLE items */\n oleItems?: OleItemOptions[];\n}\n\n// ── Descriptor ──\n\nexport const externalLinkDesc: CustomDescriptor<ExternalLinkOptions> = {\n kind: \"custom\",\n\n stringify(opts, _ctx) {\n const p: string[] = [\n '<externalLink xmlns=\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\"' +\n ' xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\">',\n ];\n\n if (opts.externalBook) {\n const book = opts.externalBook;\n const bookParts: string[] = [];\n\n if (book.sheetNames && book.sheetNames.length > 0) {\n bookParts.push(\"<sheetNames>\");\n for (const name of book.sheetNames) {\n bookParts.push(`<sheetName val=\"${escapeXml(name)}\"/>`);\n }\n bookParts.push(\"</sheetNames>\");\n }\n\n if (book.definedNames && book.definedNames.length > 0) {\n bookParts.push(\"<definedNames>\");\n for (const dn of book.definedNames) {\n const dnAttrs: Record<string, string | number | boolean | undefined> = { name: dn.name };\n if (dn.refersTo !== undefined) dnAttrs.refersTo = dn.refersTo;\n if (dn.sheetId !== undefined) dnAttrs.sheetId = dn.sheetId;\n if (dn.publishToServer) dnAttrs.publishToServer = 1;\n if (dn.vbProcedure) dnAttrs.vbProcedure = 1;\n if (dn.workbookParameter) dnAttrs.workbookParameter = 1;\n if (dn.xlm) dnAttrs.xlm = 1;\n bookParts.push(`<definedName${attrs(dnAttrs)}/>`);\n }\n bookParts.push(\"</definedNames>\");\n }\n\n if (book.sheetDataSet && book.sheetDataSet.length > 0) {\n bookParts.push(\"<sheetDataSet>\");\n for (const sd of book.sheetDataSet) {\n const sdAttrs: Record<string, string | number | boolean | undefined> = {\n sheetId: sd.sheetId,\n };\n if (sd.refreshError) sdAttrs.refreshError = 1;\n bookParts.push(`<sheetData${attrs(sdAttrs)}>`);\n\n if (sd.rows) {\n for (const row of sd.rows) {\n bookParts.push(`<row r=\"${row.rowNumber}\">`);\n if (row.cells) {\n for (const cell of row.cells) {\n const cellAttrs: Record<string, string | number | undefined> = {\n r: cell.reference,\n };\n if (cell.type !== undefined) cellAttrs.t = cell.type;\n if (cell.value !== undefined) {\n bookParts.push(\n `<cell${attrs(cellAttrs)}><v>${escapeXml(cell.value)}</v></cell>`,\n );\n } else {\n bookParts.push(`<cell${attrs(cellAttrs)}/>`);\n }\n }\n }\n bookParts.push(\"</row>\");\n }\n }\n bookParts.push(\"</sheetData>\");\n }\n bookParts.push(\"</sheetDataSet>\");\n }\n\n const ridAttr = opts.bookRId ? ` r:id=\"${opts.bookRId}\"` : \"\";\n p.push(\n `<externalBook${ridAttr}${bookParts.length > 0 ? `>${bookParts.join(\"\")}</externalBook>` : \"/>\"}`,\n );\n }\n\n // oleLink (CT_OleLink)\n if (opts.oleLink) {\n const oleRId = opts.oleRId ? ` r:id=\"${escapeXml(opts.oleRId)}\"` : \"\";\n const oleChildren: string[] = [];\n if (opts.oleLink.oleItems && opts.oleLink.oleItems.length > 0) {\n const itemParts: string[] = [`<oleItems>`];\n for (const item of opts.oleLink.oleItems) {\n const itemAttrs: string[] = [`name=\"${escapeXml(item.name)}\"`];\n if (item.advise) itemAttrs.push('advise=\"1\"');\n if (item.prefer) itemAttrs.push('prefer=\"1\"');\n itemParts.push(`<oleItem ${itemAttrs.join(\" \")}/>`);\n }\n itemParts.push(\"</oleItems>\");\n oleChildren.push(itemParts.join(\"\"));\n }\n if (oleChildren.length > 0) {\n p.push(`<oleLink${oleRId}>${oleChildren.join(\"\")}</oleLink>`);\n } else {\n p.push(`<oleLink${oleRId}/>`);\n }\n }\n\n p.push(\"</externalLink>\");\n return p.join(\"\");\n },\n\n parse(el, _ctx) {\n const result: Record<string, unknown> = {};\n\n const bookEl = findChild(el, \"externalBook\");\n if (bookEl) {\n const book: Record<string, unknown> = {};\n if (bookEl.attributes?.[\"r:id\"]) result.bookRId = bookEl.attributes[\"r:id\"];\n\n // sheetNames\n const sheetNamesEl = findChild(bookEl, \"sheetNames\");\n if (sheetNamesEl) {\n const names: string[] = [];\n for (const child of sheetNamesEl.elements ?? []) {\n if (child.name === \"sheetName\" && child.attributes?.[\"val\"]) {\n names.push(String(child.attributes[\"val\"]));\n }\n }\n if (names.length > 0) book.sheetNames = names;\n }\n\n // definedNames\n const definedNamesEl = findChild(bookEl, \"definedNames\");\n if (definedNamesEl) {\n const dns: Record<string, unknown>[] = [];\n for (const child of definedNamesEl.elements ?? []) {\n if (child.name !== \"definedName\") continue;\n const dn: Record<string, unknown> = {};\n if (child.attributes?.[\"name\"]) dn.name = String(child.attributes[\"name\"]);\n if (child.attributes?.[\"refersTo\"]) dn.refersTo = String(child.attributes[\"refersTo\"]);\n if (child.attributes?.[\"sheetId\"] !== undefined)\n dn.sheetId = Number(child.attributes[\"sheetId\"]);\n if (child.attributes?.[\"publishToServer\"]) dn.publishToServer = true;\n if (child.attributes?.[\"vbProcedure\"]) dn.vbProcedure = true;\n if (child.attributes?.[\"workbookParameter\"]) dn.workbookParameter = true;\n if (child.attributes?.[\"xlm\"]) dn.xlm = true;\n dns.push(dn);\n }\n if (dns.length > 0) book.definedNames = dns;\n }\n\n // sheetDataSet\n const sheetDataSetEl = findChild(bookEl, \"sheetDataSet\");\n if (sheetDataSetEl) {\n const sds: Record<string, unknown>[] = [];\n for (const sdChild of sheetDataSetEl.elements ?? []) {\n if (sdChild.name !== \"sheetData\") continue;\n const sd: Record<string, unknown> = {};\n if (sdChild.attributes?.[\"sheetId\"] !== undefined)\n sd.sheetId = Number(sdChild.attributes[\"sheetId\"]);\n if (sdChild.attributes?.[\"refreshError\"]) sd.refreshError = true;\n\n const rows: Record<string, unknown>[] = [];\n for (const rowChild of sdChild.elements ?? []) {\n if (rowChild.name !== \"row\") continue;\n const row: Record<string, unknown> = {};\n if (rowChild.attributes?.[\"r\"] !== undefined)\n row.rowNumber = Number(rowChild.attributes[\"r\"]);\n\n const cells: Record<string, unknown>[] = [];\n for (const cellChild of rowChild.elements ?? []) {\n if (cellChild.name !== \"cell\") continue;\n const cell: Record<string, unknown> = {};\n if (cellChild.attributes?.[\"r\"]) cell.reference = String(cellChild.attributes[\"r\"]);\n if (cellChild.attributes?.[\"t\"]) cell.type = String(cellChild.attributes[\"t\"]);\n const vEl = findChild(cellChild, \"v\");\n if (vEl && vEl.elements?.[0]?.text !== undefined) {\n cell.value = String(vEl.elements[0].text);\n }\n cells.push(cell);\n }\n if (cells.length > 0) row.cells = cells;\n rows.push(row);\n }\n if (rows.length > 0) sd.rows = rows;\n sds.push(sd);\n }\n if (sds.length > 0) book.sheetDataSet = sds;\n }\n\n result.externalBook = book;\n }\n\n // oleLink\n const oleEl = findChild(el, \"oleLink\");\n if (oleEl) {\n const ole: Record<string, unknown> = {};\n if (oleEl.attributes?.[\"r:id\"]) result.oleRId = oleEl.attributes[\"r:id\"];\n\n const oleItemsEl = findChild(oleEl, \"oleItems\");\n if (oleItemsEl) {\n const items: Record<string, unknown>[] = [];\n for (const child of oleItemsEl.elements ?? []) {\n if (child.name !== \"oleItem\") continue;\n const item: Record<string, unknown> = {};\n if (child.attributes?.[\"name\"]) item.name = String(child.attributes[\"name\"]);\n if (child.attributes?.[\"advise\"]) item.advise = true;\n if (child.attributes?.[\"prefer\"]) item.prefer = true;\n items.push(item);\n }\n if (items.length > 0) ole.oleItems = items;\n }\n\n result.oleLink = ole;\n }\n\n return result as unknown as ExternalLinkOptions;\n },\n};\n","/**\n * Pivot table utility types and helper functions.\n *\n * @module\n */\n\n/** Aggregation function for data fields (maps to ST_DataConsolidateFunction). */\nexport const ConsolidateFunction = {\n SUM: \"sum\",\n COUNT: \"count\",\n AVERAGE: \"average\",\n MAX: \"max\",\n MIN: \"min\",\n PRODUCT: \"product\",\n COUNT_NUMS: \"countNums\",\n STD_DEV: \"stdDev\",\n STD_DEV_P: \"stdDevp\",\n VAR: \"var\",\n VAR_P: \"varp\",\n} as const;\n\nexport type ConsolidateFunction = (typeof ConsolidateFunction)[keyof typeof ConsolidateFunction];\n\n/** A data field definition for pivot table aggregation. */\nexport interface PivotDataField {\n /** Source column name to aggregate */\n field: string;\n /** Aggregation function (default: \"sum\") */\n summarize?: ConsolidateFunction;\n /** Custom name for the data field (default: \"Sum of {field}\") */\n name?: string;\n /** Show data as (CT_DataField @showDataAs) */\n showDataAs?: string;\n /** Base field index for \"show data as\" calculations */\n baseField?: number;\n /** Base item index for \"show data as\" calculations */\n baseItem?: number;\n /** Sort by tuple items (CT_Tuples in sortByTuple) */\n sortByTupleItems?: number[];\n}\n\n/** Per-field overrides for pivotField XML attributes (CT_PivotField). */\nexport interface PivotFieldOverrideOptions {\n /** Field name to match (required) */\n field: string;\n /** All drilled (CT_PivotField @allDrilled) */\n allDrilled?: boolean;\n /** Auto show (CT_PivotField @autoShow) */\n autoShow?: boolean;\n /** Count subtotal (CT_PivotField @countSubtotal) */\n countSubtotal?: boolean;\n /** Data source sort (CT_PivotField @dataSourceSort) */\n dataSourceSort?: boolean;\n /** Default attribute drill state (CT_PivotField @defaultAttributeDrillState) */\n defaultAttributeDrillState?: boolean;\n /** Hidden level (CT_PivotField @hiddenLevel) */\n hiddenLevel?: boolean;\n /** Hide new items (CT_PivotField @hideNewItems) */\n hideNewItems?: boolean;\n /** Insert blank row (CT_PivotField @insertBlankRow) */\n insertBlankRow?: boolean;\n /** Insert page break (CT_PivotField @insertPageBreak) */\n insertPageBreak?: boolean;\n /** Item page count (CT_PivotField @itemPageCount) */\n itemPageCount?: boolean;\n /** Measure filter (CT_PivotField @measureFilter) */\n measureFilter?: boolean;\n /** Non auto sort default (CT_PivotField @nonAutoSortDefault) */\n nonAutoSortDefault?: boolean;\n /** Product subtotal (CT_PivotField @productSubtotal) */\n productSubtotal?: boolean;\n /** Rank by (CT_PivotField @rankBy) */\n rankBy?: number;\n /** Server field (CT_PivotField @serverField) */\n serverField?: boolean;\n /** Show drop downs (CT_PivotField @showDropDowns) */\n showDropDowns?: boolean;\n /** Show property as caption (CT_PivotField @showPropAsCaption) */\n showPropAsCaption?: boolean;\n /** Show property cell (CT_PivotField @showPropCell) */\n showPropCell?: boolean;\n /** Show property tip (CT_PivotField @showPropTip) */\n showPropTip?: boolean;\n /** StdDevP subtotal (CT_PivotField @stdDevPSubtotal) */\n stdDevPSubtotal?: boolean;\n /** StdDev subtotal (CT_PivotField @stdDevSubtotal) */\n stdDevSubtotal?: boolean;\n /** Subtotal caption (CT_PivotField @subtotalCaption) */\n subtotalCaption?: string;\n /** Top auto show (CT_PivotField @topAutoShow) */\n topAutoShow?: boolean;\n /** Unique member property (CT_PivotField @uniqueMemberProperty) */\n uniqueMemberProperty?: boolean;\n /** VarP subtotal (CT_PivotField @varPSubtotal) */\n varPSubtotal?: boolean;\n /** Var subtotal (CT_PivotField @varSubtotal) */\n varSubtotal?: boolean;\n /** Show detail for default item (CT_Item @sd) */\n defaultItemSd?: boolean;\n}\n\n/** Pivot filter type (ST_PivotFilterType) */\nexport const PivotFilterType = {\n UNKNOWN: \"unknown\",\n COUNT: \"count\",\n PERCENT: \"percent\",\n SUM: \"sum\",\n CAPTION_EQUAL: \"captionEqual\",\n CAPTION_NOT_EQUAL: \"captionNotEqual\",\n CAPTION_BEGINS_WITH: \"captionBeginsWith\",\n CAPTION_NOT_BEGINS_WITH: \"captionNotBeginsWith\",\n CAPTION_ENDS_WITH: \"captionEndsWith\",\n CAPTION_NOT_ENDS_WITH: \"captionNotEndsWith\",\n CAPTION_CONTAINS: \"captionContains\",\n CAPTION_NOT_CONTAINS: \"captionNotContains\",\n CAPTION_GREATER_THAN: \"captionGreaterThan\",\n CAPTION_GREATER_THAN_OR_EQUAL: \"captionGreaterThanOrEqual\",\n CAPTION_LESS_THAN: \"captionLessThan\",\n CAPTION_LESS_THAN_OR_EQUAL: \"captionLessThanOrEqual\",\n CAPTION_BETWEEN: \"captionBetween\",\n CAPTION_NOT_BETWEEN: \"captionNotBetween\",\n VALUE_EQUAL: \"valueEqual\",\n VALUE_NOT_EQUAL: \"valueNotEqual\",\n VALUE_GREATER_THAN: \"valueGreaterThan\",\n VALUE_GREATER_THAN_OR_EQUAL: \"valueGreaterThanOrEqual\",\n VALUE_LESS_THAN: \"valueLessThan\",\n VALUE_LESS_THAN_OR_EQUAL: \"valueLessThanOrEqual\",\n VALUE_BETWEEN: \"valueBetween\",\n VALUE_NOT_BETWEEN: \"valueNotBetween\",\n DATE_EQUAL: \"dateEqual\",\n DATE_NOT_EQUAL: \"dateNotEqual\",\n DATE_OLDER_THAN: \"dateOlderThan\",\n DATE_OLDER_THAN_OR_EQUAL: \"dateOlderThanOrEqual\",\n DATE_NEWER_THAN: \"dateNewerThan\",\n DATE_NEWER_THAN_OR_EQUAL: \"dateNewerThanOrEqual\",\n DATE_BETWEEN: \"dateBetween\",\n DATE_NOT_BETWEEN: \"dateNotBetween\",\n TOMORROW: \"tomorrow\",\n TODAY: \"today\",\n YESTERDAY: \"yesterday\",\n NEXT_WEEK: \"nextWeek\",\n THIS_WEEK: \"thisWeek\",\n LAST_WEEK: \"lastWeek\",\n NEXT_MONTH: \"nextMonth\",\n THIS_MONTH: \"thisMonth\",\n LAST_MONTH: \"lastMonth\",\n NEXT_QUARTER: \"nextQuarter\",\n THIS_QUARTER: \"thisQuarter\",\n LAST_QUARTER: \"lastQuarter\",\n NEXT_YEAR: \"nextYear\",\n THIS_YEAR: \"thisYear\",\n LAST_YEAR: \"lastYear\",\n YEAR_TO_DATE: \"yearToDate\",\n Q1: \"Q1\",\n Q2: \"Q2\",\n Q3: \"Q3\",\n Q4: \"Q4\",\n M1: \"M1\",\n M2: \"M2\",\n M3: \"M3\",\n M4: \"M4\",\n M5: \"M5\",\n M6: \"M6\",\n M7: \"M7\",\n M8: \"M8\",\n M9: \"M9\",\n M10: \"M10\",\n M11: \"M11\",\n M12: \"M12\",\n} as const;\n\nexport type PivotFilterType = (typeof PivotFilterType)[keyof typeof PivotFilterType];\n\n/** A single pivot filter (CT_PivotFilter) */\nexport interface PivotFilterOptions {\n /** Field index to filter on (required) */\n fld: number;\n /** Filter type (required) */\n type: PivotFilterType;\n /** Filter ID — unique within this pivot table (required) */\n id: number;\n /** Measure field index for OLAP filters */\n mpFld?: number;\n /** Evaluation order */\n evalOrder?: number;\n /** Measure hierarchy */\n iMeasureHier?: number;\n /** Measure field */\n iMeasureFld?: number;\n /** Filter name */\n name?: string;\n /** Filter description */\n description?: string;\n /** First string value for caption/date filters */\n stringValue1?: string;\n /** Second string value for between filters */\n stringValue2?: string;\n}\n\n/** Options for a single pivot table on a worksheet. */\nexport interface PivotTableOptions {\n /** Pivot table name (default: \"PivotTable{N}\") */\n name?: string;\n /** Source data range, e.g. \"A1:D11\" — must be on the same or a different sheet */\n source: string;\n /** Source sheet name (default: current sheet) */\n sourceSheet?: string;\n /** Target cell for the pivot table output (default: \"A3\") */\n location?: string;\n /** Field names to use as row labels */\n rows: string[];\n /** Field names to use as column labels */\n columns?: string[];\n /** Data fields with aggregation settings */\n data: PivotDataField[];\n /** Pivot style name (default: \"PivotStyleLight16\") */\n style?: string;\n /** Pivot filters (CT_PivotFilters) */\n filters?: PivotFilterOptions[];\n /** Field names to use as page/report filters */\n pages?: string[];\n /** Page field captions (maps by index to pages array) */\n pageCaptions?: string[];\n /** Data fields on rows instead of columns (CT_PivotTableDefinition @dataOnRows) */\n dataOnRows?: boolean;\n /** Grand total caption text */\n grandTotalCaption?: string;\n /** Error caption text */\n errorCaption?: string;\n /** Show error messages */\n showError?: boolean;\n /** Missing caption text */\n missingCaption?: string;\n /** Show missing items */\n showMissing?: boolean;\n /** Custom page style name */\n pageStyle?: string;\n /** Custom pivot table style name */\n pivotTableStyle?: string;\n /** Tag string */\n tag?: string;\n /** Show items with no data */\n showItems?: boolean;\n /** Edit data in-place */\n editData?: boolean;\n /** Disable field list */\n disableFieldList?: boolean;\n /** Show calculated members */\n showCalcMbrs?: boolean;\n /** Visual totals */\n visualTotals?: boolean;\n /** Show multiple labels */\n showMultipleLabel?: boolean;\n /** Show data drop-down */\n showDataDropDown?: boolean;\n /** Show drill indicators */\n showDrill?: boolean;\n /** Print drill indicators */\n printDrill?: boolean;\n /** Show member property tips */\n showMemberPropertyTips?: boolean;\n /** Show data tips */\n showDataTips?: boolean;\n /** Enable layout wizard */\n enableWizard?: boolean;\n /** Enable drill-down */\n enableDrill?: boolean;\n /** Enable field properties */\n enableFieldProperties?: boolean;\n /** Number of page fields per row/column */\n pageWrap?: number;\n /** Page layout over then down */\n pageOverThenDown?: boolean;\n /** Subtotal hidden items */\n subtotalHiddenItems?: boolean;\n /** Field print titles */\n fieldPrintTitles?: boolean;\n /** Merge item labels */\n mergeItem?: boolean;\n /** Show drop zones */\n showDropZones?: boolean;\n /** Show empty row */\n showEmptyRow?: boolean;\n /** Show empty column */\n showEmptyCol?: boolean;\n /** Show headers */\n showHeaders?: boolean;\n /** Published to server */\n published?: boolean;\n /** Grid drop zones */\n gridDropZones?: boolean;\n /** Multiple field filters */\n multipleFieldFilters?: boolean;\n /** Row header caption */\n rowHeaderCaption?: string;\n /** Column header caption */\n colHeaderCaption?: string;\n /** Sort field list ascending */\n fieldListSortAscending?: boolean;\n /** MDX subqueries enabled */\n mdxSubqueries?: boolean;\n /** Custom list sort */\n customListSort?: boolean;\n /** Asterisk totals (CT_PivotTableDefinition @asteriskTotals) */\n asteriskTotals?: boolean;\n /** Data position (CT_PivotTableDefinition @dataPosition) */\n dataPosition?: number;\n /** Immersive (CT_PivotTableDefinition @immersive) */\n immersive?: boolean;\n /** Vacated style (CT_PivotTableDefinition @vacatedStyle) */\n vacatedStyle?: string;\n /** Calculated items (CT_CalculatedItems) */\n calculatedItems?: CalculatedItemOptions[];\n /** Calculated members (CT_CalculatedMembers) */\n calculatedMembers?: CalculatedMemberOptions[];\n /** Pivot hierarchies (CT_PivotHierarchies) */\n pivotHierarchies?: PivotHierarchyOptions[];\n /** Conditional formats (CT_ConditionalFormats for pivot) */\n pivotConditionalFormats?: PivotConditionalFormatOptions[];\n /** Chart formats (CT_ChartFormats) */\n chartFormats?: ChartFormatOptions[];\n /** Auto sort scope (CT_AutoSortScope) */\n autoSortScope?: PivotAreaOptions;\n /** Member properties per field (CT_MemberProperties → mps/mp) */\n memberProperties?: MemberPropertyOptions[];\n /** Pivot format areas (CT_Formats → format) */\n formats?: PivotFormatOptions[];\n /** Row hierarchy usage (CT_RowHierarchiesUsage) */\n rowHierarchiesUsage?: HierarchyUsageOptions[];\n /** Column hierarchy usage (CT_ColHierarchiesUsage) */\n colHierarchiesUsage?: HierarchyUsageOptions[];\n /** Location column page count (CT_Location @colPageCount) */\n locationColPageCount?: number;\n /** Location row page count (CT_Location @rowPageCount) */\n locationRowPageCount?: number;\n /** Per-field overrides for pivotField (CT_PivotField attributes) */\n fieldOverrides?: PivotFieldOverrideOptions[];\n}\n\n/** Pivot format (CT_Format). */\nexport interface PivotFormatOptions {\n /** Action type (default: \"formatting\") */\n action?: \"formatting\" | \"drill\" | \"formula\" | \"blank\" | \"subtotal\" | \"report\";\n /** Differential format index */\n dxfId?: number;\n /** Pivot area */\n pivotArea: PivotAreaOptions;\n}\n\n/** Calculated item in a pivot table (CT_CalculatedItem) */\nexport interface CalculatedItemOptions {\n /** Field index */\n field?: number;\n /** Formula */\n formula?: string;\n /** Pivot area reference */\n pivotArea?: PivotAreaOptions;\n}\n\n/** Calculated member in a pivot table (CT_CalculatedMember) */\nexport interface CalculatedMemberOptions {\n /** Name (required) */\n name: string;\n /** MDX expression (required) */\n mdx: string;\n /** Member name */\n memberName?: string;\n /** Hierarchy */\n hierarchy?: string;\n /** Parent member */\n parent?: string;\n /** Solve order (default: 0) */\n solveOrder?: number;\n /** Is a set (default: false) */\n set?: boolean;\n}\n\n/** Pivot hierarchy (CT_PivotHierarchy) */\nexport interface PivotHierarchyOptions {\n /** Outline mode (default: false) */\n outline?: boolean;\n /** Allow multiple item selection (default: false) */\n multipleItemSelectionAllowed?: boolean;\n /** Subtotal on top (default: false) */\n subtotalTop?: boolean;\n /** Show in field list (default: true) */\n showInFieldList?: boolean;\n /** Drag to row (default: true) */\n dragToRow?: boolean;\n /** Drag to column (default: true) */\n dragToCol?: boolean;\n /** Drag to page (default: true) */\n dragToPage?: boolean;\n /** Drag to data (default: false) */\n dragToData?: boolean;\n /** Drag off (default: true) */\n dragOff?: boolean;\n /** Include new items in filter (default: false) */\n includeNewItemsInFilter?: boolean;\n /** Caption */\n caption?: string;\n /** Members */\n members?: MemberOptions[];\n /** Member properties (CT_MemberProperties → mps/mp) */\n memberProperties?: MemberPropertyOptions[];\n}\n\n/** Member in pivot hierarchy (CT_Member) */\nexport interface MemberOptions {\n /** Member name (required) */\n name: string;\n /** Level (CT_Member @level) */\n level?: number;\n}\n\n/** Member property (CT_MemberProperty) */\nexport interface MemberPropertyOptions {\n /** Field index */\n field: number;\n /** Property name */\n name?: string;\n /** Show cell? */\n showCell?: boolean;\n /** Show tip? */\n showTip?: boolean;\n /** Show as caption (CT_MemberProperty @showAsCaption) */\n showAsCaption?: boolean;\n /** Name length (CT_MemberProperty @nameLen) */\n nameLen?: number;\n /** Property position (CT_MemberProperty @pPos) */\n pPos?: number;\n /** Property length (CT_MemberProperty @pLen) */\n pLen?: number;\n}\n\n/** Pivot area for conditional formats, chart formats, etc. (CT_PivotArea) */\nexport interface PivotAreaOptions {\n /** Field index */\n field?: number;\n /** Area type (default: \"normal\") */\n type?: \"none\" | \"normal\" | \"data\" | \"all\" | \"origin\" | \"button\" | \"topEnd\" | \"topRight\";\n /** Data only (default: true) */\n dataOnly?: boolean;\n /** Label only (default: false) */\n labelOnly?: boolean;\n /** Grand row (default: false) */\n grandRow?: boolean;\n /** Grand column (default: false) */\n grandCol?: boolean;\n /** Cache index (default: false) */\n cacheIndex?: boolean;\n /** Outline (default: true) */\n outline?: boolean;\n /** Offset reference */\n offset?: string;\n /** Collapsed levels are subtotals (default: false) */\n collapsedLevelsAreSubtotals?: boolean;\n /** Axis */\n axis?: \"axisRow\" | \"axisCol\" | \"axisPage\" | \"axisValues\";\n /** Field position */\n fieldPosition?: number;\n /** References */\n references?: PivotAreaReferenceOptions[];\n}\n\n/** Pivot area reference (CT_PivotAreaReference) */\nexport interface PivotAreaReferenceOptions {\n /** Field index */\n field?: number;\n /** Count */\n count?: number;\n /** Selected (default: true) */\n selected?: boolean;\n /** By position (default: false) */\n byPosition?: boolean;\n /** Relative (default: false) */\n relative?: boolean;\n /** Default subtotal */\n defaultSubtotal?: boolean;\n /** Sum subtotal */\n sumSubtotal?: boolean;\n /** CountA subtotal */\n countASubtotal?: boolean;\n /** Average subtotal */\n avgSubtotal?: boolean;\n /** Max subtotal */\n maxSubtotal?: boolean;\n /** Min subtotal */\n minSubtotal?: boolean;\n /** Count subtotal (CT_Reference @countSubtotal) */\n countSubtotal?: boolean;\n /** Product subtotal (CT_Reference @productSubtotal) */\n productSubtotal?: boolean;\n /** StdDevP subtotal (CT_Reference @stdDevPSubtotal) */\n stdDevPSubtotal?: boolean;\n /** StdDev subtotal (CT_Reference @stdDevSubtotal) */\n stdDevSubtotal?: boolean;\n /** VarP subtotal (CT_Reference @varPSubtotal) */\n varPSubtotal?: boolean;\n /** Var subtotal (CT_Reference @varSubtotal) */\n varSubtotal?: boolean;\n /** X indices */\n x?: number[];\n}\n\n/** Pivot conditional format (CT_ConditionalFormat for pivot) */\nexport interface PivotConditionalFormatOptions {\n /** Scope (default: \"selection\") */\n scope?: \"selection\" | \"data\" | \"field\";\n /** Type (default: \"none\") */\n type?: \"none\" | \"all\" | \"row\" | \"column\";\n /** Priority (required) */\n priority: number;\n /** Pivot areas */\n pivotAreas?: PivotAreaOptions[];\n}\n\n/** Chart format for pivot table (CT_ChartFormat) */\nexport interface ChartFormatOptions {\n /** Chart index (required) */\n chart: number;\n /** Format index (required) */\n format: number;\n /** Is series (default: false) */\n series?: boolean;\n /** Pivot area */\n pivotArea?: PivotAreaOptions;\n}\n\n/** Cache hierarchy for OLAP pivot caches (CT_CacheHierarchy) */\nexport interface CacheHierarchyOptions {\n /** Unique name (required) */\n uniqueName: string;\n /** Caption */\n caption?: string;\n /** Is measure (default: false) */\n measure?: boolean;\n /** Is set (default: false) */\n set?: boolean;\n /** Parent set index */\n parentSet?: number;\n /** Icon set (default: 0) */\n iconSet?: number;\n /** Is attribute (default: false) */\n attribute?: boolean;\n /** Is time dimension (default: false) */\n time?: boolean;\n /** Key attribute (default: false) */\n keyAttribute?: boolean;\n /** Default member unique name */\n defaultMemberUniqueName?: string;\n /** All unique name */\n allUniqueName?: string;\n /** All caption */\n allCaption?: string;\n /** Dimension unique name */\n dimensionUniqueName?: string;\n /** Display folder */\n displayFolder?: string;\n /** Measure group */\n measureGroup?: string;\n /** Is measures (default: false) */\n measures?: boolean;\n /** Count (required) */\n count: number;\n /** One field (default: false) */\n oneField?: boolean;\n /** Hidden (default: false) */\n hidden?: boolean;\n /** Member value datatype (CT_CacheHierarchy @memberValueDatatype) */\n memberValueDatatype?: \"string\" | \"number\" | \"integer\" | \"boolean\" | \"error\";\n /** Unbalanced (CT_CacheHierarchy @unbalanced) */\n unbalanced?: boolean;\n /** Unbalanced group (CT_CacheHierarchy @unbalancedGroup) */\n unbalancedGroup?: boolean;\n /** Group levels (CT_GroupLevels) */\n groupLevels?: GroupLevelOptions[];\n /** Fields usage (CT_FieldsUsage) */\n fieldsUsage?: FieldUsageOptions[];\n}\n\n/** KPI definition for pivot cache (CT_PCDKPI) */\nexport interface KpiOptions {\n /** Unique name (required) */\n uniqueName: string;\n /** Caption */\n caption?: string;\n /** Display folder */\n displayFolder?: string;\n /** Measure group */\n measureGroup?: string;\n /** Parent */\n parent?: string;\n /** Value expression (required) */\n value: string;\n /** Goal expression */\n goal?: string;\n /** Status expression */\n status?: string;\n /** Trend expression */\n trend?: string;\n /** Weight expression */\n weight?: string;\n /** Time expression */\n time?: string;\n}\n\n/** Measure group (CT_MeasureGroup) */\nexport interface MeasureGroupOptions {\n /** Name (required) */\n name: string;\n /** Caption (required) */\n caption: string;\n}\n\n/** Set definition (CT_Set) */\nexport interface SetOptions {\n /** Count */\n count?: number;\n /** Max rank (required) */\n maxRank: number;\n /** Set definition MDX (required) */\n setDefinition: string;\n /** Sort type (default: \"none\") */\n sortType?:\n | \"none\"\n | \"ascending\"\n | \"descending\"\n | \"ascendingAlpha\"\n | \"descendingAlpha\"\n | \"ascendingNatural\"\n | \"descendingNatural\";\n /** Query failed (default: false) */\n queryFailed?: boolean;\n}\n\n/** Server format (CT_ServerFormat) */\nexport interface ServerFormatOptions {\n /** Culture */\n culture?: string;\n /** Format string */\n format?: string;\n}\n\n/** Field group for pivot cache (CT_FieldGroup) */\nexport interface FieldGroupOptions {\n /** Parent field index */\n parent?: number;\n /** Base field index */\n base?: number;\n /** Range properties */\n rangePr?: RangePropertiesOptions;\n /** Discrete properties */\n discretePr?: number[];\n /** Group items names */\n groupItems?: string[];\n}\n\n/** Range properties for field grouping (CT_RangePr) */\nexport interface RangePropertiesOptions {\n /** Auto start (default: true) */\n autoStart?: boolean;\n /** Auto end (default: true) */\n autoEnd?: boolean;\n /** Group by (default: \"range\") */\n groupBy?: \"range\" | \"seconds\" | \"minutes\" | \"hours\" | \"days\" | \"months\" | \"quarters\" | \"years\";\n /** Start number */\n startNum?: number;\n /** End number */\n endNum?: number;\n /** Start date ISO string */\n startDate?: string;\n /** End date ISO string */\n endDate?: string;\n /** Group interval (default: 1) */\n groupInterval?: number;\n}\n\n/** Pivot dimension (CT_PivotDimension) */\nexport interface PivotDimensionOptions {\n /** Is measure (default: false) */\n measure?: boolean;\n /** Name (required) */\n name: string;\n /** Unique name (required) */\n uniqueName: string;\n /** Caption (required) */\n caption: string;\n}\n\n/** Range set for consolidation source (CT_RangeSet) */\nexport interface RangeSetOptions {\n /** Index for page field 1 */\n i1?: number;\n /** Index for page field 2 */\n i2?: number;\n /** Index for page field 3 */\n i3?: number;\n /** Index for page field 4 */\n i4?: number;\n /** Cell reference */\n ref?: string;\n /** Named range */\n name?: string;\n /** Sheet name */\n sheet?: string;\n /** Relationship ID to external workbook */\n rId?: string;\n}\n\n/** Page item for consolidation (CT_PageItem) */\nexport interface ConsolidationPageItemOptions {\n /** Page item name */\n name: string;\n}\n\n/** Page for consolidation (CT_PCDSCPage) */\nexport interface ConsolidationPageOptions {\n /** Page items */\n items?: ConsolidationPageItemOptions[];\n}\n\n/** Consolidation source (CT_Consolidation) */\nexport interface ConsolidationOptions {\n /** Auto page (default: true) */\n autoPage?: boolean;\n /** Pages (max 4) */\n pages?: ConsolidationPageOptions[];\n /** Range sets (required) */\n rangeSets: RangeSetOptions[];\n}\n\n/** Tuple cache entry (CT_PCDSDTCEntries choice: m/n/e/s) */\nexport interface TupleCacheEntryOptions {\n /** Entry type */\n type: \"m\" | \"n\" | \"e\" | \"s\";\n /** Value (required for n/s, optional for e) */\n value?: number | string;\n}\n\n/** Deleted field (CT_DeletedField) */\nexport interface DeletedFieldOptions {\n /** Field name */\n name: string;\n}\n\n/** Group member (CT_GroupMember) */\nexport interface GroupMemberOptions {\n /** Unique name (required) */\n uniqueName: string;\n /** Is group */\n group?: boolean;\n}\n\n/** Level group (CT_LevelGroup) */\nexport interface LevelGroupOptions {\n /** Name (required) */\n name: string;\n /** Unique name (required) */\n uniqueName: string;\n /** Caption (required) */\n caption: string;\n /** Unique parent */\n uniqueParent?: string;\n /** Group ID */\n id?: number;\n /** Members */\n members: GroupMemberOptions[];\n}\n\n/** Group level (CT_GroupLevel) */\nexport interface GroupLevelOptions {\n /** Unique name (required) */\n uniqueName: string;\n /** Caption (required) */\n caption: string;\n /** User-defined */\n user?: boolean;\n /** Custom roll-up */\n customRollUp?: boolean;\n /** Groups */\n groups?: LevelGroupOptions[];\n}\n\n/** Field usage (CT_FieldUsage) */\nexport interface FieldUsageOptions {\n /** Field index */\n value: number;\n}\n\n/** Hierarchy usage (CT_HierarchyUsage) */\nexport interface HierarchyUsageOptions {\n /** Hierarchy usage value (required) */\n hierarchyUsage: number;\n}\n\n/** Query cache entry (CT_Query) */\nexport interface QueryCacheEntryOptions {\n /** MDX query string (required) */\n mdx: string;\n /** Tuples */\n tpls?: TupleOptions[];\n}\n\n/** Tuple (CT_Tuple) */\nexport interface TupleOptions {\n /** Tuple items (field indices) */\n items?: number[];\n}\n\n/** Member property map (CT_X, used as mpMap child) */\nexport interface MpMapOptions {\n /** Field index */\n x: number;\n}\n\n/** Measure dimension map (CT_MeasureDimensionMap) */\nexport interface MeasureDimensionMapOptions {\n /** Measure group index */\n measureGroup?: number;\n /** Dimension index */\n dimension?: number;\n}\n\n/** OLAP properties for pivot cache (CT_OlapPr) */\nexport interface OLAPPropertiesOptions {\n /** Local cube connection string */\n local?: string;\n /** Local connection string */\n localConnection?: string;\n /** Send locale info to OLAP server */\n sendLocale?: boolean;\n /** Row dimensions */\n rowDrillCount?: number;\n /** Column dimensions */\n colDrillCount?: number;\n /** Local refresh (CT_OlapPr @localRefresh) */\n localRefresh?: boolean;\n /** Use server fill formatting */\n serverFill?: boolean;\n /** Use server number formatting */\n serverNumberFormat?: boolean;\n /** Use server font formatting */\n serverFont?: boolean;\n /** Use server font color */\n serverFontColor?: boolean;\n}\n\n/** Parsed source data for pivot cache generation. */\nexport interface PivotSourceData {\n fieldNames: string[];\n records: (string | number | null | Date)[][];\n}\n\n/**\n * Extract unique values from source data for a given field index.\n */\nexport function collectUniqueValues(\n records: (string | number | null | Date)[][],\n fieldIdx: number,\n): (string | number | null | Date)[] {\n const seen = new Set<string>();\n const result: (string | number | null | Date)[] = [];\n for (const row of records) {\n const val = row[fieldIdx];\n const key = val instanceof Date ? val.toISOString() : String(val);\n if (!seen.has(key)) {\n seen.add(key);\n result.push(val);\n }\n }\n return result;\n}\n\n/**\n * Check if a field is numeric (all non-empty values are numbers).\n */\nexport function isNumericField(\n records: (string | number | null | Date)[][],\n fieldIdx: number,\n): boolean {\n for (const row of records) {\n const val = row[fieldIdx];\n if (typeof val === \"string\" && val !== \"\") return false;\n }\n return true;\n}\n\n/**\n * Aggregate values using the specified function.\n */\nexport function aggregate(values: number[], func: ConsolidateFunction): number {\n if (values.length === 0) return 0;\n switch (func) {\n case \"sum\":\n return values.reduce((a, b) => a + b, 0);\n case \"count\":\n case \"countNums\":\n return values.length;\n case \"average\":\n return values.reduce((a, b) => a + b, 0) / values.length;\n case \"max\":\n // Two-arg reduce: Math.max is associative, so Math.max(a,b,c) ===\n // Math.max(Math.max(a,b),c) for all values incl. NaN/Infinity — fully\n // equivalent to Math.max(...values) without spreading onto the stack.\n return values.reduce((a, b) => Math.max(a, b));\n case \"min\":\n return values.reduce((a, b) => Math.min(a, b));\n case \"product\":\n return values.reduce((a, b) => a * b, 1);\n case \"var\":\n return sampleVariance(values);\n case \"varp\":\n return populationVariance(values);\n case \"stdDev\":\n return Math.sqrt(sampleVariance(values));\n case \"stdDevp\":\n return Math.sqrt(populationVariance(values));\n default:\n return values.reduce((a, b) => a + b, 0);\n }\n}\n\nfunction populationVariance(values: number[]): number {\n const mean = values.reduce((a, b) => a + b, 0) / values.length;\n return values.reduce((sum, v) => sum + (v - mean) ** 2, 0) / values.length;\n}\n\nfunction sampleVariance(values: number[]): number {\n if (values.length < 2) return 0;\n const mean = values.reduce((a, b) => a + b, 0) / values.length;\n return values.reduce((sum, v) => sum + (v - mean) ** 2, 0) / (values.length - 1);\n}\n\n// ── PivotCacheDefinition types (extracted from pivot-cache-definition-xml) ──\n\nexport interface CacheFieldExtraAttrs {\n /** Database field (CT_CacheField @databaseField) */\n databaseField?: boolean;\n /** Level (CT_CacheField @level) */\n level?: number;\n /** Mapping count (CT_CacheField @mappingCount) */\n mappingCount?: number;\n /** Member property field (CT_CacheField @memberPropertyField) */\n memberPropertyField?: number;\n /** Property name (CT_CacheField @propertyName) */\n propertyName?: string;\n /** Server field (CT_CacheField @serverField) */\n serverField?: boolean;\n /** Unique list (CT_CacheField @uniqueList) */\n uniqueList?: boolean;\n /** Shared items contains mixed types (CT_SharedItems @containsMixedTypes) */\n containsMixedTypes?: boolean;\n /** Shared items contains non-date (CT_SharedItems @containsNonDate) */\n containsNonDate?: boolean;\n /** Shared items long text (CT_SharedItems @longText) */\n longText?: boolean;\n /** Shared items max date (CT_SharedItems @maxDate) */\n maxDate?: string;\n /** Shared items min date (CT_SharedItems @minDate) */\n minDate?: string;\n}\n\nexport interface PivotCacheDefinitionOptions {\n /** Cache is invalid (CT_PivotCacheDefinition @invalid) */\n invalid?: boolean;\n /** Save data with cache (CT_PivotCacheDefinition @saveData) */\n saveData?: boolean;\n /** Optimize memory usage (CT_PivotCacheDefinition @optimizeMemory) */\n optimizeMemory?: boolean;\n /** Enable refresh (CT_PivotCacheDefinition @enableRefresh) */\n enableRefresh?: boolean;\n /** User who last refreshed */\n refreshedBy?: string;\n /** Date of last refresh (decimal) */\n refreshedDate?: number;\n /** Date of last refresh (ISO 8601) */\n refreshedDateIso?: string;\n /** Background query (CT_PivotCacheDefinition @backgroundQuery) */\n backgroundQuery?: boolean;\n /** Missing items limit */\n missingItemsLimit?: number;\n /** Upgrade on refresh */\n upgradeOnRefresh?: boolean;\n /** Support subquery */\n supportSubquery?: boolean;\n /** Support advanced drill */\n supportAdvancedDrill?: boolean;\n /** Cache hierarchies (CT_CacheHierarchies) */\n cacheHierarchies?: CacheHierarchyOptions[];\n /** KPIs (CT_PCDKPIs) */\n kpis?: KpiOptions[];\n /** Measure groups (CT_MeasureGroups) */\n measureGroups?: MeasureGroupOptions[];\n /** Dimensions (CT_Dimensions) */\n dimensions?: PivotDimensionOptions[];\n /** Sets (CT_Sets in tupleCache) */\n sets?: SetOptions[];\n /** Server formats (CT_ServerFormats) */\n serverFormats?: ServerFormatOptions[];\n /** Field groups per field index (CT_FieldGroup inside cacheField) */\n fieldGroups?: ReadonlyMap<number, FieldGroupOptions>;\n /** Consolidation source (alternative to worksheetSource) */\n consolidation?: ConsolidationOptions;\n /** Tuple cache entries (CT_PCDSDTCEntries) */\n entries?: TupleCacheEntryOptions[];\n /** Query cache (CT_QueryCache in tupleCache) */\n queryCache?: QueryCacheEntryOptions[];\n /** Member property map per cache field (mpMap) */\n mpMaps?: MpMapOptions[];\n /** Measure dimension maps (CT_MeasureDimensionMaps) */\n measureDimensionMaps?: MeasureDimensionMapOptions[];\n /** Per-field cache field overrides (mapped by field index) */\n cacheFieldOverrides?: ReadonlyMap<number, CacheFieldExtraAttrs>;\n /** OLAP properties (CT_OlapPr) */\n olapPr?: OLAPPropertiesOptions;\n}\n","/**\n * PivotTable descriptor for XLSX — generates xl/pivotTables/pivotTable{N}.xml.\n *\n * Implements CT_pivotTableDefinition from sml.xsd.\n * Direct stringify/parse — no intermediate class.\n *\n * @module\n */\n\nimport type { CustomDescriptor } from \"@office-open/core/descriptor\";\nimport { attrs, escapeXml, textOf } from \"@office-open/xml\";\nimport type { Element as XmlElement } from \"@office-open/xml\";\nimport { findChild, attr, attrNum } from \"@office-open/xml\";\n\nimport type {\n PivotTableOptions,\n PivotSourceData,\n PivotDataField,\n PivotHierarchyOptions,\n PivotAreaOptions,\n PivotFieldOverrideOptions,\n PivotAreaReferenceOptions,\n} from \"./pivot/pivot-utils\";\nimport { collectUniqueValues } from \"./pivot/pivot-utils\";\n\n// ── Types ──\n\nexport interface PivotTableDescriptorOptions {\n options: PivotTableOptions;\n sourceData: PivotSourceData;\n cacheId: number;\n}\n\n// ── Descriptor ──\n\nexport const pivotTableDesc: CustomDescriptor<PivotTableDescriptorOptions> = {\n kind: \"custom\",\n\n stringify(opts, _ctx) {\n return stringifyPivotTable(opts.options, opts.sourceData, opts.cacheId);\n },\n\n parse(el, _ctx) {\n const result: Record<string, unknown> = {};\n\n // Root element attributes\n if (attr(el, \"name\")) result.name = attr(el, \"name\");\n if (attr(el, \"cacheId\") !== undefined) result.cacheId = attrNum(el, \"cacheId\") ?? 0;\n if (attr(el, \"dataOnRows\") === \"1\") result.dataOnRows = true;\n if (attr(el, \"showHeaders\") === \"0\") result.showHeaders = false;\n if (attr(el, \"showEmptyRow\") === \"1\") result.showEmptyRow = true;\n if (attr(el, \"showEmptyCol\") === \"1\") result.showEmptyCol = true;\n if (attr(el, \"grandTotalCaption\")) result.grandTotalCaption = attr(el, \"grandTotalCaption\");\n if (attr(el, \"errorCaption\")) result.errorCaption = attr(el, \"errorCaption\");\n if (attr(el, \"showError\") === \"1\") result.showError = true;\n if (attr(el, \"missingCaption\")) result.missingCaption = attr(el, \"missingCaption\");\n if (attr(el, \"showMissing\") === \"0\") result.showMissing = false;\n if (attr(el, \"pageStyle\")) result.pageStyle = attr(el, \"pageStyle\");\n if (attr(el, \"pivotTableStyle\")) result.pivotTableStyle = attr(el, \"pivotTableStyle\");\n if (attr(el, \"tag\")) result.tag = attr(el, \"tag\");\n if (attr(el, \"showItems\") === \"0\") result.showItems = false;\n if (attr(el, \"editData\") === \"1\") result.editData = true;\n if (attr(el, \"disableFieldList\") === \"1\") result.disableFieldList = true;\n if (attr(el, \"showCalcMbrs\") === \"0\") result.showCalcMbrs = false;\n if (attr(el, \"visualTotals\") === \"1\") result.visualTotals = true;\n if (attr(el, \"showMultipleLabel\") === \"0\") result.showMultipleLabel = false;\n if (attr(el, \"showDataDropDown\") === \"0\") result.showDataDropDown = false;\n if (attr(el, \"showDrill\") === \"0\") result.showDrill = false;\n if (attr(el, \"printDrill\") === \"1\") result.printDrill = true;\n if (attr(el, \"showMemberPropertyTips\") === \"1\") result.showMemberPropertyTips = true;\n if (attr(el, \"showDataTips\") === \"0\") result.showDataTips = false;\n if (attr(el, \"enableWizard\") === \"0\") result.enableWizard = false;\n if (attr(el, \"enableDrill\") === \"0\") result.enableDrill = false;\n if (attr(el, \"enableFieldProperties\") === \"0\") result.enableFieldProperties = false;\n const pageWrap = attrNum(el, \"pageWrap\");\n if (pageWrap !== undefined) result.pageWrap = pageWrap;\n if (attr(el, \"pageOverThenDown\") === \"1\") result.pageOverThenDown = true;\n if (attr(el, \"subtotalHiddenItems\") === \"1\") result.subtotalHiddenItems = true;\n if (attr(el, \"fieldPrintTitles\") === \"1\") result.fieldPrintTitles = true;\n if (attr(el, \"mergeItem\") === \"1\") result.mergeItem = true;\n if (attr(el, \"showDropZones\") === \"0\") result.showDropZones = false;\n if (attr(el, \"published\") === \"1\") result.published = true;\n if (attr(el, \"gridDropZones\") === \"0\") result.gridDropZones = false;\n if (attr(el, \"multipleFieldFilters\") === \"0\") result.multipleFieldFilters = false;\n if (attr(el, \"rowHeaderCaption\")) result.rowHeaderCaption = attr(el, \"rowHeaderCaption\");\n if (attr(el, \"colHeaderCaption\")) result.colHeaderCaption = attr(el, \"colHeaderCaption\");\n if (attr(el, \"fieldListSortAscending\") === \"1\") result.fieldListSortAscending = true;\n if (attr(el, \"mdxSubqueries\") === \"1\") result.mdxSubqueries = true;\n if (attr(el, \"customListSort\") === \"0\") result.customListSort = false;\n if (attr(el, \"asteriskTotals\") === \"1\") result.asteriskTotals = true;\n const dataPosition = attrNum(el, \"dataPosition\");\n if (dataPosition !== undefined) result.dataPosition = dataPosition;\n if (attr(el, \"immersive\") === \"1\") result.immersive = true;\n if (attr(el, \"vacatedStyle\")) result.vacatedStyle = attr(el, \"vacatedStyle\");\n if (attr(el, \"dataCaption\")) result.dataCaption = attr(el, \"dataCaption\");\n\n // Location — store ref as string, plus extended counts\n const locEl = findChild(el, \"location\");\n if (locEl) {\n if (attr(locEl, \"ref\")) result.location = attr(locEl, \"ref\");\n const rpc = attrNum(locEl, \"rowPageCount\");\n if (rpc !== undefined) result.locationRowPageCount = rpc;\n const cpc = attrNum(locEl, \"colPageCount\");\n if (cpc !== undefined) result.locationColPageCount = cpc;\n }\n\n // PivotFields\n const pfEl = findChild(el, \"pivotFields\");\n if (pfEl) {\n const fields: Record<string, unknown>[] = [];\n for (const fEl of pfEl.elements ?? []) {\n if (fEl.name !== \"pivotField\") continue;\n const field: Record<string, unknown> = {};\n const axis = attr(fEl, \"axis\");\n if (axis) field.axis = axis;\n if (attr(fEl, \"showAll\") === \"0\") field.showAll = false;\n else if (attr(fEl, \"showAll\") === \"1\") field.showAll = true;\n if (attr(fEl, \"dataField\") === \"1\") field.dataField = true;\n if (attr(fEl, \"hierarchy\")) field.hierarchy = attr(fEl, \"hierarchy\");\n if (attr(fEl, \"dragToRow\") === \"0\") field.dragToRow = false;\n if (attr(fEl, \"dragToCol\") === \"0\") field.dragToCol = false;\n if (attr(fEl, \"dragToPage\") === \"0\") field.dragToPage = false;\n if (attr(fEl, \"dragToData\") === \"1\") field.dragToData = true;\n if (attr(fEl, \"dragOff\") === \"0\") field.dragOff = false;\n if (attr(fEl, \"showDropDowns\") === \"0\") field.showDropDowns = false;\n if (attr(fEl, \"insertBlankRow\") === \"1\") field.insertBlankRow = true;\n if (attr(fEl, \"showPropCell\") === \"1\") field.showPropCell = true;\n if (attr(fEl, \"showPropTip\") === \"1\") field.showPropTip = true;\n if (attr(fEl, \"showPropAsCaption\") === \"1\") field.showPropAsCaption = true;\n if (attr(fEl, \"compact\") === \"0\") field.compact = false;\n if (attr(fEl, \"outline\") === \"1\") field.outline = true;\n if (attr(fEl, \"subtotalTop\") === \"0\") field.subtotalTop = false;\n if (attr(fEl, \"includeNewItemsInFilter\") === \"1\") field.includeNewItemsInFilter = true;\n fields.push(field);\n }\n result.pivotFields = fields;\n }\n\n // DataFields\n const dfEl = findChild(el, \"dataFields\");\n if (dfEl) {\n const dataFields: Record<string, unknown>[] = [];\n for (const dEl of dfEl.elements ?? []) {\n if (dEl.name !== \"dataField\") continue;\n const df: Record<string, unknown> = {};\n if (attr(dEl, \"name\")) df.name = attr(dEl, \"name\");\n const fld = attrNum(dEl, \"fld\");\n if (fld !== undefined) df.fld = fld;\n if (attr(dEl, \"subtotal\")) df.subtotal = attr(dEl, \"subtotal\");\n if (attr(dEl, \"showDataAs\")) df.showDataAs = attr(dEl, \"showDataAs\");\n const baseField = attrNum(dEl, \"baseField\");\n if (baseField !== undefined) df.baseField = baseField;\n const baseItem = attrNum(dEl, \"baseItem\");\n if (baseItem !== undefined) df.baseItem = baseItem;\n if (attr(dEl, \"numFmtId\")) df.numFmtId = attr(dEl, \"numFmtId\");\n dataFields.push(df);\n }\n result.dataFields = dataFields;\n }\n\n // Row fields\n const rowFieldsEl = findChild(el, \"rowFields\");\n if (rowFieldsEl) {\n const rowFields: number[] = [];\n for (const f of rowFieldsEl.elements ?? []) {\n if (f.name === \"field\") {\n const x = attrNum(f, \"x\");\n if (x !== undefined) rowFields.push(x);\n }\n }\n result.rowFields = rowFields;\n }\n\n // Col fields\n const colFieldsEl = findChild(el, \"colFields\");\n if (colFieldsEl) {\n const colFields: number[] = [];\n for (const f of colFieldsEl.elements ?? []) {\n if (f.name === \"field\") {\n const x = attrNum(f, \"x\");\n if (x !== undefined) colFields.push(x);\n }\n }\n result.colFields = colFields;\n }\n\n // Page fields\n const pageFieldsEl = findChild(el, \"pageFields\");\n if (pageFieldsEl) {\n const pageFields: Record<string, unknown>[] = [];\n for (const pf of pageFieldsEl.elements ?? []) {\n if (pf.name !== \"pageField\") continue;\n const pfResult: Record<string, unknown> = {};\n const fld = attrNum(pf, \"fld\");\n if (fld !== undefined) pfResult.fld = fld;\n const hier = attrNum(pf, \"hier\");\n if (hier !== undefined) pfResult.hier = hier;\n if (attr(pf, \"cap\")) pfResult.cap = attr(pf, \"cap\");\n pageFields.push(pfResult);\n }\n result.pageFields = pageFields;\n }\n\n // Formats\n const formatsEl = findChild(el, \"formats\");\n if (formatsEl) {\n const formats: Record<string, unknown>[] = [];\n for (const fmtEl of formatsEl.elements ?? []) {\n if (fmtEl.name !== \"format\") continue;\n const fmt: Record<string, unknown> = {};\n if (attr(fmtEl, \"action\")) fmt.action = attr(fmtEl, \"action\");\n const dxfId = attrNum(fmtEl, \"dxfId\");\n if (dxfId !== undefined) fmt.dxfId = dxfId;\n const paEl = findChild(fmtEl, \"pivotArea\");\n if (paEl) fmt.pivotArea = parsePivotArea(paEl);\n formats.push(fmt);\n }\n result.formats = formats;\n }\n\n // ChartFormats\n const chartFormatsEl = findChild(el, \"chartFormats\");\n if (chartFormatsEl) {\n const chartFormats: Record<string, unknown>[] = [];\n for (const cfEl of chartFormatsEl.elements ?? []) {\n if (cfEl.name !== \"chartFormat\") continue;\n const cf: Record<string, unknown> = {};\n const chart = attrNum(cfEl, \"chart\");\n if (chart !== undefined) cf.chart = chart;\n const format = attrNum(cfEl, \"format\");\n if (format !== undefined) cf.format = format;\n if (attr(cfEl, \"series\") === \"1\") cf.series = true;\n const paEl = findChild(cfEl, \"pivotArea\");\n if (paEl) cf.pivotArea = parsePivotArea(paEl);\n chartFormats.push(cf);\n }\n result.chartFormats = chartFormats;\n }\n\n // PivotHierarchies\n const hierarchiesEl = findChild(el, \"pivotHierarchies\");\n if (hierarchiesEl) {\n const hierarchies: Record<string, unknown>[] = [];\n for (const hEl of hierarchiesEl.elements ?? []) {\n if (hEl.name !== \"pivotHierarchy\") continue;\n const h: Record<string, unknown> = {};\n if (attr(hEl, \"outline\") === \"1\") h.outline = true;\n if (attr(hEl, \"multipleItemSelectionAllowed\") === \"1\")\n h.multipleItemSelectionAllowed = true;\n if (attr(hEl, \"subtotalTop\") === \"1\") h.subtotalTop = true;\n if (attr(hEl, \"showInFieldList\") === \"0\") h.showInFieldList = false;\n if (attr(hEl, \"dragToRow\") === \"0\") h.dragToRow = false;\n if (attr(hEl, \"dragToCol\") === \"0\") h.dragToCol = false;\n if (attr(hEl, \"dragToPage\") === \"0\") h.dragToPage = false;\n if (attr(hEl, \"dragToData\") === \"1\") h.dragToData = true;\n if (attr(hEl, \"dragOff\") === \"0\") h.dragOff = false;\n if (attr(hEl, \"includeNewItemsInFilter\") === \"1\") h.includeNewItemsInFilter = true;\n if (attr(hEl, \"caption\")) h.caption = attr(hEl, \"caption\");\n hierarchies.push(h);\n }\n result.pivotHierarchies = hierarchies;\n }\n\n // Filters\n const filtersEl = findChild(el, \"filters\");\n if (filtersEl) {\n const filters: Record<string, unknown>[] = [];\n for (const fEl of filtersEl.elements ?? []) {\n if (fEl.name !== \"filter\") continue;\n const f: Record<string, unknown> = {};\n const fld = attrNum(fEl, \"fld\");\n if (fld !== undefined) f.fld = fld;\n if (attr(fEl, \"type\")) f.type = attr(fEl, \"type\");\n const id = attrNum(fEl, \"id\");\n if (id !== undefined) f.id = id;\n const mpFld = attrNum(fEl, \"mpFld\");\n if (mpFld !== undefined) f.mpFld = mpFld;\n const evalOrder = attrNum(fEl, \"evalOrder\");\n if (evalOrder !== undefined) f.evalOrder = evalOrder;\n filters.push(f);\n }\n result.filters = filters;\n }\n\n // RowHierarchiesUsage\n const rhuEl = findChild(el, \"rowHierarchiesUsage\");\n if (rhuEl) {\n const usage: Record<string, unknown>[] = [];\n for (const u of rhuEl.elements ?? []) {\n if (u.name === \"rowHierarchyUsage\") {\n usage.push({ hierarchyUsage: attrNum(u, \"hierarchyUsage\") ?? 0 });\n }\n }\n result.rowHierarchiesUsage = usage;\n }\n\n // ColHierarchiesUsage\n const chuEl = findChild(el, \"colHierarchiesUsage\");\n if (chuEl) {\n const usage: Record<string, unknown>[] = [];\n for (const u of chuEl.elements ?? []) {\n if (u.name === \"colHierarchyUsage\") {\n usage.push({ hierarchyUsage: attrNum(u, \"hierarchyUsage\") ?? 0 });\n }\n }\n result.colHierarchiesUsage = usage;\n }\n\n // CalculatedItems\n const ciEl = findChild(el, \"calculatedItems\");\n if (ciEl) {\n const items: Record<string, unknown>[] = [];\n for (const iEl of ciEl.elements ?? []) {\n if (iEl.name !== \"calculatedItem\") continue;\n const item: Record<string, unknown> = {};\n const field = attrNum(iEl, \"field\");\n if (field !== undefined) item.field = field;\n const formulaEl = findChild(iEl, \"formula\");\n if (formulaEl) item.formula = textOf(formulaEl);\n const paEl = findChild(iEl, \"pivotArea\");\n if (paEl) item.pivotArea = parsePivotArea(paEl);\n items.push(item);\n }\n result.calculatedItems = items;\n }\n\n // CalculatedMembers\n const cmEl = findChild(el, \"calculatedMembers\");\n if (cmEl) {\n const members: Record<string, unknown>[] = [];\n for (const mEl of cmEl.elements ?? []) {\n if (mEl.name !== \"calculatedMember\") continue;\n const m: Record<string, unknown> = {};\n if (attr(mEl, \"name\")) m.name = attr(mEl, \"name\");\n const mdxEl = findChild(mEl, \"mdx\");\n if (mdxEl) m.mdx = textOf(mdxEl) ?? \"\";\n if (attr(mEl, \"memberName\")) m.memberName = attr(mEl, \"memberName\");\n if (attr(mEl, \"hierarchy\")) m.hierarchy = attr(mEl, \"hierarchy\");\n if (attr(mEl, \"parent\")) m.parent = attr(mEl, \"parent\");\n const solveOrder = attrNum(mEl, \"solveOrder\");\n if (solveOrder !== undefined) m.solveOrder = solveOrder;\n if (attr(mEl, \"set\") === \"1\") m.set = true;\n members.push(m);\n }\n result.calculatedMembers = members;\n }\n\n // Style from pivotTableStyleInfo/@name (the standard location)\n const styleInfoEl = findChild(el, \"pivotTableStyleInfo\");\n if (styleInfoEl) {\n const styleName = attr(styleInfoEl, \"name\");\n if (styleName) result.style = styleName;\n } else if (attr(el, \"styleName\")) {\n result.style = attr(el, \"styleName\");\n }\n\n return result as unknown as PivotTableDescriptorOptions;\n },\n};\n\n// ── Stringify implementation ──\n\nfunction stringifyPivotTable(o: PivotTableOptions, sd: PivotSourceData, cacheId: number): string {\n const fields = sd.fieldNames;\n const rowFieldNames = o.rows;\n const colFieldNames = o.columns ?? [];\n const dataFields = o.data;\n const style = o.style ?? \"PivotStyleLight16\";\n const location = o.location ?? \"A3\";\n const name = o.name ?? \"PivotTable1\";\n\n const rowFieldIndices = rowFieldNames.map((n) => fields.indexOf(n));\n const colFieldIndices = colFieldNames.map((n) => fields.indexOf(n));\n const dataFieldIndices = dataFields.map((df) => fields.indexOf(df.field));\n const pageFieldNames = o.pages ?? [];\n const pageFieldIndices = pageFieldNames.map((n) => fields.indexOf(n));\n\n const pivotFieldsXml = buildPivotFields(\n o,\n sd,\n rowFieldIndices,\n colFieldIndices,\n dataFieldIndices,\n pageFieldIndices,\n );\n const pageFieldsXml = buildPageFields(o, pageFieldIndices);\n const rowFieldsXml = buildRowFields(rowFieldIndices);\n const rowItemsXml = buildRowItems(sd, rowFieldIndices);\n const colFieldsXml = buildColFields(colFieldIndices);\n const colItemsXml = buildColItems(sd, colFieldIndices, dataFields);\n const dataFieldsXml = buildDataFields(dataFields, dataFieldIndices);\n\n const locationRef = computeLocationRef(\n sd,\n location,\n rowFieldIndices,\n colFieldIndices,\n dataFields,\n );\n\n const p: string[] = [];\n const defAttrs: string[] = [\n `name=\"${escapeXml(name)}\"`,\n `cacheId=\"${cacheId}\"`,\n 'dataCaption=\"Values\"',\n 'updatedVersion=\"6\"',\n 'minRefreshableVersion=\"3\"',\n 'createdVersion=\"6\"',\n 'applyNumberFormats=\"0\"',\n 'applyBorderFormats=\"0\"',\n 'applyFontFormats=\"0\"',\n 'applyPatternFormats=\"0\"',\n 'applyAlignmentFormats=\"0\"',\n 'applyWidthHeightFormats=\"1\"',\n 'autoFormatId=\"0\"',\n 'useAutoFormatting=\"1\"',\n 'itemPrintTitles=\"1\"',\n 'indent=\"0\"',\n 'outline=\"1\"',\n 'outlineData=\"1\"',\n 'compact=\"1\"',\n 'compactData=\"1\"',\n 'rowGrandTotals=\"1\"',\n 'colGrandTotals=\"1\"',\n ];\n if (o.dataOnRows) defAttrs.push('dataOnRows=\"1\"');\n if (o.grandTotalCaption) defAttrs.push(`grandTotalCaption=\"${escapeXml(o.grandTotalCaption)}\"`);\n if (o.errorCaption) defAttrs.push(`errorCaption=\"${escapeXml(o.errorCaption)}\"`);\n if (o.showError) defAttrs.push('showError=\"1\"');\n if (o.missingCaption) defAttrs.push(`missingCaption=\"${escapeXml(o.missingCaption)}\"`);\n if (o.showMissing === false) defAttrs.push('showMissing=\"0\"');\n if (o.pageStyle) defAttrs.push(`pageStyle=\"${escapeXml(o.pageStyle)}\"`);\n if (o.pivotTableStyle) defAttrs.push(`pivotTableStyle=\"${escapeXml(o.pivotTableStyle)}\"`);\n if (o.tag) defAttrs.push(`tag=\"${escapeXml(o.tag)}\"`);\n if (o.showItems === false) defAttrs.push('showItems=\"0\"');\n if (o.editData) defAttrs.push('editData=\"1\"');\n if (o.disableFieldList) defAttrs.push('disableFieldList=\"1\"');\n if (o.showCalcMbrs === false) defAttrs.push('showCalcMbrs=\"0\"');\n if (o.visualTotals) defAttrs.push('visualTotals=\"1\"');\n if (o.showMultipleLabel === false) defAttrs.push('showMultipleLabel=\"0\"');\n if (o.showDataDropDown === false) defAttrs.push('showDataDropDown=\"0\"');\n if (o.showDrill === false) defAttrs.push('showDrill=\"0\"');\n if (o.printDrill) defAttrs.push('printDrill=\"1\"');\n if (o.showMemberPropertyTips) defAttrs.push('showMemberPropertyTips=\"1\"');\n if (o.showDataTips === false) defAttrs.push('showDataTips=\"0\"');\n if (o.enableWizard === false) defAttrs.push('enableWizard=\"0\"');\n if (o.enableDrill === false) defAttrs.push('enableDrill=\"0\"');\n if (o.enableFieldProperties === false) defAttrs.push('enableFieldProperties=\"0\"');\n if (o.pageWrap !== undefined) defAttrs.push(`pageWrap=\"${o.pageWrap}\"`);\n if (o.pageOverThenDown) defAttrs.push('pageOverThenDown=\"1\"');\n if (o.subtotalHiddenItems) defAttrs.push('subtotalHiddenItems=\"1\"');\n if (o.fieldPrintTitles) defAttrs.push('fieldPrintTitles=\"1\"');\n if (o.mergeItem) defAttrs.push('mergeItem=\"1\"');\n if (o.showDropZones === false) defAttrs.push('showDropZones=\"0\"');\n if (o.showEmptyRow) defAttrs.push('showEmptyRow=\"1\"');\n if (o.showEmptyCol) defAttrs.push('showEmptyCol=\"1\"');\n if (o.showHeaders === false) defAttrs.push('showHeaders=\"0\"');\n if (o.published) defAttrs.push('published=\"1\"');\n if (o.gridDropZones === false) defAttrs.push('gridDropZones=\"0\"');\n if (o.multipleFieldFilters === false) defAttrs.push('multipleFieldFilters=\"0\"');\n if (o.rowHeaderCaption) defAttrs.push(`rowHeaderCaption=\"${escapeXml(o.rowHeaderCaption)}\"`);\n if (o.colHeaderCaption) defAttrs.push(`colHeaderCaption=\"${escapeXml(o.colHeaderCaption)}\"`);\n if (o.fieldListSortAscending) defAttrs.push('fieldListSortAscending=\"1\"');\n if (o.mdxSubqueries) defAttrs.push('mdxSubqueries=\"1\"');\n if (o.customListSort === false) defAttrs.push('customListSort=\"0\"');\n if (o.asteriskTotals) defAttrs.push('asteriskTotals=\"1\"');\n if (o.dataPosition !== undefined) defAttrs.push(`dataPosition=\"${o.dataPosition}\"`);\n if (o.immersive) defAttrs.push('immersive=\"1\"');\n if (o.vacatedStyle) defAttrs.push(`vacatedStyle=\"${escapeXml(o.vacatedStyle)}\"`);\n\n p.push(\n `<pivotTableDefinition xmlns=\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\" ${defAttrs.join(\" \")}>`,\n );\n\n // location\n const locAttrs: string[] = [\n `ref=\"${escapeXml(locationRef)}\"`,\n `firstHeaderRow=\"1\"`,\n `firstDataRow=\"${colFieldIndices.length + 1}\"`,\n `firstDataCol=\"${rowFieldIndices.length}\"`,\n ];\n if (o.locationColPageCount !== undefined)\n locAttrs.push(`colPageCount=\"${o.locationColPageCount}\"`);\n if (o.locationRowPageCount !== undefined)\n locAttrs.push(`rowPageCount=\"${o.locationRowPageCount}\"`);\n p.push(`<location ${locAttrs.join(\" \")}/>`);\n\n p.push(pivotFieldsXml);\n p.push(rowFieldsXml);\n p.push(rowItemsXml);\n if (colFieldIndices.length > 0) p.push(colFieldsXml);\n p.push(colItemsXml);\n if (pageFieldIndices.length > 0) p.push(pageFieldsXml);\n if (dataFields.length > 0) p.push(dataFieldsXml);\n\n // formats\n if (o.formats && o.formats.length > 0) {\n const fmtParts: string[] = [`<formats count=\"${o.formats.length}\">`];\n for (const fmt of o.formats) {\n const fmtAttrs: string[] = [];\n if (fmt.action && fmt.action !== \"formatting\") fmtAttrs.push(`action=\"${fmt.action}\"`);\n if (fmt.dxfId !== undefined) fmtAttrs.push(`dxfId=\"${fmt.dxfId}\"`);\n fmtParts.push(\n `<format${fmtAttrs.length ? \" \" + fmtAttrs.join(\" \") : \"\"}>${buildPivotAreaXml(fmt.pivotArea)}</format>`,\n );\n }\n fmtParts.push(\"</formats>\");\n p.push(fmtParts.join(\"\"));\n }\n\n // chartFormats\n if (o.chartFormats && o.chartFormats.length > 0) {\n const cfParts: string[] = [`<chartFormats count=\"${o.chartFormats.length}\">`];\n for (const cf of o.chartFormats) {\n const cfAttrs: string[] = [`chart=\"${cf.chart}\"`, `format=\"${cf.format}\"`];\n if (cf.series) cfAttrs.push('series=\"1\"');\n const areaXml = cf.pivotArea ? buildPivotAreaXml(cf.pivotArea) : \"\";\n cfParts.push(`<chartFormat ${cfAttrs.join(\" \")}>${areaXml}</chartFormat>`);\n }\n cfParts.push(\"</chartFormats>\");\n p.push(cfParts.join(\"\"));\n }\n\n // pivotHierarchies\n if (o.pivotHierarchies && o.pivotHierarchies.length > 0) {\n p.push(buildPivotHierarchies(o.pivotHierarchies));\n }\n\n // pivotTableStyleInfo\n p.push(\n `<pivotTableStyleInfo name=\"${escapeXml(style)}\" showRowHeaders=\"1\" showColHeaders=\"1\" showRowStripes=\"0\" showColStripes=\"0\" showLastColumn=\"1\"/>`,\n );\n\n // filters\n if (o.filters && o.filters.length > 0) {\n const fParts: string[] = [`<filters count=\"${o.filters.length}\">`];\n for (const f of o.filters) {\n const fAttrs: Record<string, string | number | boolean | undefined> = {\n fld: f.fld,\n type: f.type,\n id: f.id,\n };\n if (f.mpFld !== undefined) fAttrs.mpFld = f.mpFld;\n if (f.evalOrder !== undefined) fAttrs.evalOrder = f.evalOrder;\n fParts.push(`<filter${attrs(fAttrs)}><autoFilter></autoFilter></filter>`);\n }\n fParts.push(\"</filters>\");\n p.push(fParts.join(\"\"));\n }\n\n // rowHierarchiesUsage\n if (o.rowHierarchiesUsage && o.rowHierarchiesUsage.length > 0) {\n const rhu = o.rowHierarchiesUsage;\n p.push(\n `<rowHierarchiesUsage count=\"${rhu.length}\">${rhu.map((h) => `<rowHierarchyUsage hierarchyUsage=\"${h.hierarchyUsage}\"/>`).join(\"\")}</rowHierarchiesUsage>`,\n );\n }\n\n // colHierarchiesUsage\n if (o.colHierarchiesUsage && o.colHierarchiesUsage.length > 0) {\n const chu = o.colHierarchiesUsage;\n p.push(\n `<colHierarchiesUsage count=\"${chu.length}\">${chu.map((h) => `<colHierarchyUsage hierarchyUsage=\"${h.hierarchyUsage}\"/>`).join(\"\")}</colHierarchiesUsage>`,\n );\n }\n\n p.push(\"</pivotTableDefinition>\");\n return p.join(\"\");\n}\n\n// ── Stringify helpers ──\n\nfunction buildFieldOverrideAttrs(fo: PivotFieldOverrideOptions): string {\n const a: string[] = [];\n if (fo.allDrilled) a.push('allDrilled=\"1\"');\n if (fo.autoShow) a.push('autoShow=\"1\"');\n if (fo.countSubtotal) a.push('countSubtotal=\"1\"');\n if (fo.dataSourceSort) a.push('dataSourceSort=\"1\"');\n if (fo.defaultAttributeDrillState) a.push('defaultAttributeDrillState=\"1\"');\n if (fo.hiddenLevel) a.push('hiddenLevel=\"1\"');\n if (fo.hideNewItems) a.push('hideNewItems=\"1\"');\n if (fo.insertBlankRow) a.push('insertBlankRow=\"1\"');\n if (fo.insertPageBreak) a.push('insertPageBreak=\"1\"');\n if (fo.itemPageCount) a.push('itemPageCount=\"1\"');\n if (fo.measureFilter) a.push('measureFilter=\"1\"');\n if (fo.nonAutoSortDefault) a.push('nonAutoSortDefault=\"1\"');\n if (fo.productSubtotal) a.push('productSubtotal=\"1\"');\n if (fo.rankBy !== undefined) a.push(`rankBy=\"${fo.rankBy}\"`);\n if (fo.serverField) a.push('serverField=\"1\"');\n if (fo.showDropDowns) a.push('showDropDowns=\"1\"');\n if (fo.showPropAsCaption) a.push('showPropAsCaption=\"1\"');\n if (fo.showPropCell) a.push('showPropCell=\"1\"');\n if (fo.showPropTip) a.push('showPropTip=\"1\"');\n if (fo.stdDevPSubtotal) a.push('stdDevPSubtotal=\"1\"');\n if (fo.stdDevSubtotal) a.push('stdDevSubtotal=\"1\"');\n if (fo.subtotalCaption) a.push(`subtotalCaption=\"${escapeXml(fo.subtotalCaption)}\"`);\n if (fo.topAutoShow) a.push('topAutoShow=\"1\"');\n if (fo.uniqueMemberProperty) a.push('uniqueMemberProperty=\"1\"');\n if (fo.varPSubtotal) a.push('varPSubtotal=\"1\"');\n if (fo.varSubtotal) a.push('varSubtotal=\"1\"');\n return a.join(\" \");\n}\n\nfunction buildPivotFields(\n o: PivotTableOptions,\n sd: PivotSourceData,\n rowIndices: number[],\n colIndices: number[],\n dataIndices: number[],\n pageIndices: number[],\n): string {\n const fieldNames = sd.fieldNames;\n const parts: string[] = [`<pivotFields count=\"${fieldNames.length}\">`];\n\n for (let i = 0; i < fieldNames.length; i++) {\n const isRow = rowIndices.includes(i);\n const isCol = colIndices.includes(i);\n const isData = dataIndices.includes(i);\n const isPage = pageIndices.includes(i);\n const override = o.fieldOverrides?.find((fo) => fo.field === fieldNames[i]);\n const extraAttrs = override ? buildFieldOverrideAttrs(override) : \"\";\n\n if (isData) {\n const dataFieldIdx = dataIndices.indexOf(i);\n const df = o.data[dataFieldIdx];\n const dfAttrs: string[] = ['dataField=\"1\"', 'showAll=\"0\"'];\n if (extraAttrs) dfAttrs.push(extraAttrs);\n if (df?.showDataAs) dfAttrs.push(`showDataAs=\"${df.showDataAs}\"`);\n if (df?.baseField !== undefined) dfAttrs.push(`baseField=\"${df.baseField}\"`);\n if (df?.baseItem !== undefined) dfAttrs.push(`baseItem=\"${df.baseItem}\"`);\n if (o.autoSortScope) {\n parts.push(\n `<pivotField ${dfAttrs.join(\" \")}><autoSortScope>${buildPivotAreaXml(o.autoSortScope)}</autoSortScope></pivotField>`,\n );\n } else {\n parts.push(`<pivotField ${dfAttrs.join(\" \")}/>`);\n }\n } else if (isRow) {\n const uniqueVals = collectUniqueValues(sd.records, i);\n const rAttrs = extraAttrs\n ? ` axis=\"axisRow\" showAll=\"0\" ${extraAttrs}`\n : ' axis=\"axisRow\" showAll=\"0\"';\n parts.push(`<pivotField${rAttrs}>`);\n parts.push(`<items count=\"${uniqueVals.length + 1}\">`);\n for (let j = 0; j < uniqueVals.length; j++) parts.push(`<item x=\"${j}\"/>`);\n parts.push(`<item t=\"default\"${override?.defaultItemSd === false ? ' sd=\"0\"' : \"\"}/>`);\n parts.push(\"</items></pivotField>\");\n } else if (isCol) {\n const uniqueVals = collectUniqueValues(sd.records, i);\n const cAttrs = extraAttrs\n ? ` axis=\"axisCol\" showAll=\"0\" ${extraAttrs}`\n : ' axis=\"axisCol\" showAll=\"0\"';\n parts.push(`<pivotField${cAttrs}>`);\n parts.push(`<items count=\"${uniqueVals.length + 1}\">`);\n for (let j = 0; j < uniqueVals.length; j++) parts.push(`<item x=\"${j}\"/>`);\n parts.push(`<item t=\"default\"${override?.defaultItemSd === false ? ' sd=\"0\"' : \"\"}/>`);\n parts.push(\"</items></pivotField>\");\n } else if (isPage) {\n const uniqueVals = collectUniqueValues(sd.records, i);\n const pAttrs = extraAttrs\n ? ` axis=\"axisPage\" showAll=\"0\" ${extraAttrs}`\n : ' axis=\"axisPage\" showAll=\"0\"';\n parts.push(`<pivotField${pAttrs}>`);\n parts.push(`<items count=\"${uniqueVals.length + 1}\">`);\n for (let j = 0; j < uniqueVals.length; j++) parts.push(`<item x=\"${j}\"/>`);\n parts.push(`<item t=\"default\"${override?.defaultItemSd === false ? ' sd=\"0\"' : \"\"}/>`);\n parts.push(\"</items></pivotField>\");\n } else {\n const nAttrs = extraAttrs ? ` showAll=\"0\" ${extraAttrs}` : ' showAll=\"0\"';\n parts.push(`<pivotField${nAttrs}/>`);\n }\n }\n\n parts.push(\"</pivotFields>\");\n return parts.join(\"\");\n}\n\nfunction buildPageFields(o: PivotTableOptions, pageIndices: number[]): string {\n if (pageIndices.length === 0) return \"\";\n const parts: string[] = [`<pageFields count=\"${pageIndices.length}\">`];\n for (let i = 0; i < pageIndices.length; i++) {\n const cap = o.pageCaptions?.[i];\n const capAttr = cap ? ` cap=\"${escapeXml(cap)}\"` : \"\";\n parts.push(`<pageField fld=\"${pageIndices[i]}\" hier=\"${i}\"${capAttr}/>`);\n }\n parts.push(\"</pageFields>\");\n return parts.join(\"\");\n}\n\nfunction buildRowFields(rowIndices: number[]): string {\n if (rowIndices.length === 0) return '<rowFields count=\"0\"/>';\n const parts: string[] = [`<rowFields count=\"${rowIndices.length}\">`];\n for (const idx of rowIndices) parts.push(`<field x=\"${idx}\"/>`);\n parts.push(\"</rowFields>\");\n return parts.join(\"\");\n}\n\nfunction buildRowItems(sd: PivotSourceData, rowIndices: number[]): string {\n if (rowIndices.length === 0) return '<rowItems count=\"1\"><i/></rowItems>';\n\n const allUniqueCounts: number[] = [];\n for (const idx of rowIndices) {\n allUniqueCounts.push(collectUniqueValues(sd.records, idx).length);\n }\n\n if (rowIndices.length === 1) {\n const count = allUniqueCounts[0];\n const parts: string[] = [`<rowItems count=\"${count + 1}\">`];\n for (let i = 0; i < count; i++) parts.push(`<i><x v=\"${i}\"/></i>`);\n parts.push(`<i t=\"grand\"><x/></i>`);\n parts.push(\"</rowItems>\");\n return parts.join(\"\");\n }\n\n const combos = cartesianOfCounts(allUniqueCounts);\n const rowItems: string[] = [];\n for (const combo of combos) {\n rowItems.push(`<i>${combo.map((v) => `<x v=\"${v}\"/>`).join(\"\")}</i>`);\n }\n rowItems.push(`<i t=\"grand\">${rowIndices.map(() => \"<x/>\").join(\"\")}</i>`);\n return `<rowItems count=\"${rowItems.length}\">${rowItems.join(\"\")}</rowItems>`;\n}\n\nfunction buildColFields(colIndices: number[]): string {\n if (colIndices.length === 0) return '<colFields count=\"0\"/>';\n const parts: string[] = [`<colFields count=\"${colIndices.length}\">`];\n for (const idx of colIndices) parts.push(`<field x=\"${idx}\"/>`);\n parts.push(\"</colFields>\");\n return parts.join(\"\");\n}\n\nfunction buildColItems(\n sd: PivotSourceData,\n colIndices: number[],\n dataFields: PivotDataField[],\n): string {\n if (colIndices.length > 0) {\n const allUniqueCounts: number[] = [];\n for (const idx of colIndices) {\n allUniqueCounts.push(collectUniqueValues(sd.records, idx).length);\n }\n const combos = cartesianOfCounts(allUniqueCounts);\n const items: string[] = [];\n for (const combo of combos) {\n items.push(`<i>${combo.map((v) => `<x v=\"${v}\"/>`).join(\"\")}</i>`);\n }\n items.push(`<i t=\"grand\">${colIndices.map(() => \"<x/>\").join(\"\")}</i>`);\n return `<colItems count=\"${items.length}\">${items.join(\"\")}</colItems>`;\n }\n if (dataFields.length > 1) {\n const items = dataFields.map((_, i) => `<i><x v=\"${i}\"/></i>`);\n return `<colItems count=\"${items.length}\">${items.join(\"\")}</colItems>`;\n }\n return '<colItems count=\"1\"><i/></colItems>';\n}\n\nfunction buildDataFields(dataFields: PivotDataField[], dataFieldIndices: number[]): string {\n if (dataFields.length === 0) return '<dataFields count=\"0\"/>';\n const parts: string[] = [`<dataFields count=\"${dataFields.length}\">`];\n for (let i = 0; i < dataFields.length; i++) {\n const df = dataFields[i];\n const subtotal = df.summarize ?? \"sum\";\n const name = df.name ?? `${subtotal === \"sum\" ? \"Sum\" : subtotal} of ${df.field}`;\n const dfAttrs: string[] = [\n `name=\"${escapeXml(name)}\"`,\n `fld=\"${dataFieldIndices[i]}\"`,\n `subtotal=\"${subtotal}\"`,\n ];\n if (df.showDataAs) dfAttrs.push(`showDataAs=\"${df.showDataAs}\"`);\n if (df.baseField !== undefined) dfAttrs.push(`baseField=\"${df.baseField}\"`);\n if (df.baseItem !== undefined) dfAttrs.push(`baseItem=\"${df.baseItem}\"`);\n parts.push(`<dataField ${dfAttrs.join(\" \")}/>`);\n }\n parts.push(\"</dataFields>\");\n return parts.join(\"\");\n}\n\nfunction computeLocationRef(\n sd: PivotSourceData,\n location: string,\n rowFieldIndices: number[],\n colFieldIndices: number[],\n dataFields: PivotDataField[],\n): string {\n const startCell = location.split(\":\")[0];\n const match = startCell.match(/^([A-Z]+)(\\d+)$/);\n if (!match) return location;\n const startCol = match[1];\n const startRow = parseInt(match[2], 10);\n\n let rowCount = 1;\n if (rowFieldIndices.length > 0) {\n rowCount += collectUniqueValues(sd.records, rowFieldIndices[0]).length;\n }\n rowCount += 1;\n\n let colCount = Math.max(rowFieldIndices.length, 1);\n if (colFieldIndices.length > 0) {\n colCount += collectUniqueValues(sd.records, colFieldIndices[0]).length;\n } else if (dataFields.length > 1) {\n colCount += dataFields.length - 1;\n }\n colCount += 1;\n\n const endCol = colIndexToLetter(letterToColIndex(startCol) + colCount - 1);\n const endRow = startRow + rowCount - 1;\n return `${startCol}${startRow}:${endCol}${endRow}`;\n}\n\nfunction buildPivotHierarchies(hierarchies: PivotHierarchyOptions[]): string {\n const parts: string[] = [`<pivotHierarchies count=\"${hierarchies.length}\">`];\n for (const h of hierarchies) {\n const hAttrs: string[] = [];\n if (h.outline) hAttrs.push('outline=\"1\"');\n if (h.multipleItemSelectionAllowed) hAttrs.push('multipleItemSelectionAllowed=\"1\"');\n if (h.subtotalTop) hAttrs.push('subtotalTop=\"1\"');\n if (h.showInFieldList === false) hAttrs.push('showInFieldList=\"0\"');\n if (h.dragToRow === false) hAttrs.push('dragToRow=\"0\"');\n if (h.dragToCol === false) hAttrs.push('dragToCol=\"0\"');\n if (h.dragToPage === false) hAttrs.push('dragToPage=\"0\"');\n if (h.dragToData) hAttrs.push('dragToData=\"1\"');\n if (h.dragOff === false) hAttrs.push('dragOff=\"0\"');\n if (h.includeNewItemsInFilter) hAttrs.push('includeNewItemsInFilter=\"1\"');\n if (h.caption) hAttrs.push(`caption=\"${escapeXml(h.caption)}\"`);\n const inner =\n (h.memberProperties\n ? `<mps count=\"${h.memberProperties.length}\">${h.memberProperties\n .map((mp) => {\n const mpAttrs: string[] = [`field=\"${mp.field}\"`];\n if (mp.name !== undefined) mpAttrs.push(`name=\"${escapeXml(mp.name)}\"`);\n if (mp.showCell) mpAttrs.push('showCell=\"1\"');\n if (mp.showTip) mpAttrs.push('showTip=\"1\"');\n if (mp.showAsCaption) mpAttrs.push('showAsCaption=\"1\"');\n return `<mp ${mpAttrs.join(\" \")}/>`;\n })\n .join(\"\")}</mps>`\n : \"\") +\n (h.members\n ? `<members count=\"${h.members.length}\">${h.members.map((m) => `<member name=\"${escapeXml(m.name)}\"${m.level !== undefined ? ` level=\"${m.level}\"` : \"\"}/>`).join(\"\")}</members>`\n : \"\");\n if (inner) {\n parts.push(`<pivotHierarchy ${hAttrs.join(\" \")}>${inner}</pivotHierarchy>`);\n } else {\n parts.push(`<pivotHierarchy ${hAttrs.join(\" \")}/>`);\n }\n }\n parts.push(\"</pivotHierarchies>\");\n return parts.join(\"\");\n}\n\nfunction buildPivotAreaXml(area: PivotAreaOptions): string {\n const aAttrs: string[] = [];\n if (area.field !== undefined) aAttrs.push(`field=\"${area.field}\"`);\n if (area.type) aAttrs.push(`type=\"${area.type}\"`);\n if (area.dataOnly === false) aAttrs.push('dataOnly=\"0\"');\n if (area.labelOnly) aAttrs.push('labelOnly=\"1\"');\n if (area.grandRow) aAttrs.push('grandRow=\"1\"');\n if (area.grandCol) aAttrs.push('grandCol=\"1\"');\n if (area.cacheIndex) aAttrs.push('cacheIndex=\"1\"');\n if (area.outline === false) aAttrs.push('outline=\"0\"');\n if (area.offset) aAttrs.push(`offset=\"${escapeXml(area.offset)}\"`);\n if (area.collapsedLevelsAreSubtotals) aAttrs.push('collapsedLevelsAreSubtotals=\"1\"');\n if (area.axis) aAttrs.push(`axis=\"${area.axis}\"`);\n if (area.fieldPosition !== undefined) aAttrs.push(`fieldPosition=\"${area.fieldPosition}\"`);\n const refsXml = area.references ? buildPivotAreaReferences(area.references) : \"\";\n if (refsXml) return `<pivotArea ${aAttrs.join(\" \")}>${refsXml}</pivotArea>`;\n return `<pivotArea ${aAttrs.join(\" \")}/>`;\n}\n\nfunction buildPivotAreaReferences(refs: PivotAreaReferenceOptions[]): string {\n const parts: string[] = [`<references count=\"${refs.length}\">`];\n for (const ref of refs) {\n const rAttrs: string[] = [];\n if (ref.field !== undefined) rAttrs.push(`field=\"${ref.field}\"`);\n if (ref.count !== undefined) rAttrs.push(`count=\"${ref.count}\"`);\n if (ref.selected === false) rAttrs.push('selected=\"0\"');\n if (ref.byPosition) rAttrs.push('byPosition=\"1\"');\n if (ref.relative) rAttrs.push('relative=\"1\"');\n if (ref.defaultSubtotal) rAttrs.push('defaultSubtotal=\"1\"');\n const xXml = ref.x ? ref.x.map((v) => `<x v=\"${v}\"/>`).join(\"\") : \"\";\n if (xXml) {\n parts.push(`<reference ${rAttrs.join(\" \")}>${xXml}</reference>`);\n } else {\n parts.push(`<reference ${rAttrs.join(\" \")}/>`);\n }\n }\n parts.push(\"</references>\");\n return parts.join(\"\");\n}\n\nfunction letterToColIndex(letters: string): number {\n let col = 0;\n for (let i = 0; i < letters.length; i++) col = col * 26 + (letters.charCodeAt(i) - 64);\n return col;\n}\n\nfunction colIndexToLetter(col: number): string {\n let result = \"\";\n let n = col;\n while (n > 0) {\n n--;\n result = String.fromCharCode(65 + (n % 26)) + result;\n n = Math.floor(n / 26);\n }\n return result;\n}\n\nfunction cartesianOfCounts(counts: number[]): number[][] {\n if (counts.length === 0) return [[]];\n let result: number[][] = [[]];\n for (const count of counts) {\n const next: number[][] = [];\n for (const prefix of result) {\n for (let i = 0; i < count; i++) next.push([...prefix, i]);\n }\n result = next;\n }\n return result;\n}\n\n// ── Parse helpers ──\n\nfunction parsePivotArea(el: XmlElement): Record<string, unknown> {\n const result: Record<string, unknown> = {};\n const field = attrNum(el, \"field\");\n if (field !== undefined) result.field = field;\n if (attr(el, \"type\")) result.type = attr(el, \"type\");\n if (attr(el, \"dataOnly\") === \"0\") result.dataOnly = false;\n if (attr(el, \"labelOnly\") === \"1\") result.labelOnly = true;\n if (attr(el, \"grandRow\") === \"1\") result.grandRow = true;\n if (attr(el, \"grandCol\") === \"1\") result.grandCol = true;\n if (attr(el, \"cacheIndex\") === \"1\") result.cacheIndex = true;\n if (attr(el, \"outline\") === \"0\") result.outline = false;\n if (attr(el, \"offset\")) result.offset = attr(el, \"offset\");\n if (attr(el, \"collapsedLevelsAreSubtotals\") === \"1\") result.collapsedLevelsAreSubtotals = true;\n if (attr(el, \"axis\")) result.axis = attr(el, \"axis\");\n const fp = attrNum(el, \"fieldPosition\");\n if (fp !== undefined) result.fieldPosition = fp;\n const refsEl = findChild(el, \"references\");\n if (refsEl) {\n const refs: Record<string, unknown>[] = [];\n for (const rEl of refsEl.elements ?? []) {\n if (rEl.name !== \"reference\") continue;\n const ref: Record<string, unknown> = {};\n const rField = attrNum(rEl, \"field\");\n if (rField !== undefined) ref.field = rField;\n const rCount = attrNum(rEl, \"count\");\n if (rCount !== undefined) ref.count = rCount;\n if (attr(rEl, \"selected\") === \"0\") ref.selected = false;\n if (attr(rEl, \"byPosition\") === \"1\") ref.byPosition = true;\n if (attr(rEl, \"relative\") === \"1\") ref.relative = true;\n if (attr(rEl, \"defaultSubtotal\") === \"1\") ref.defaultSubtotal = true;\n const xArr: number[] = [];\n for (const xEl of rEl.elements ?? []) {\n if (xEl.name === \"x\") {\n const v = attrNum(xEl, \"v\");\n if (v !== undefined) xArr.push(v);\n }\n }\n if (xArr.length > 0) ref.x = xArr;\n refs.push(ref);\n }\n result.references = refs;\n }\n return result;\n}\n","/**\n * PivotCache descriptors for XLSX — generates xl/pivotCache/pivotCacheDefinition{N}.xml\n * and xl/pivotCache/pivotCacheRecords{N}.xml.\n *\n * Direct stringify/parse — no intermediate class.\n *\n * @module\n */\n\nimport type { CustomDescriptor } from \"@office-open/core/descriptor\";\nimport { escapeXml, findChild, attr, attrNum } from \"@office-open/xml\";\n\nimport type { PivotCacheDefinitionOptions } from \"./pivot/pivot-utils\";\nimport type { PivotSourceData } from \"./pivot/pivot-utils\";\nimport { collectUniqueValues, isNumericField } from \"./pivot/pivot-utils\";\n\n// ── Types ──\n\nexport interface PivotCacheRecordsDescriptorOptions {\n sourceData: PivotSourceData;\n /** Parsed records (from parse path) */\n records?: Record<string, unknown>[][];\n}\n\nexport interface PivotCacheDefDescriptorOptions {\n sourceRef: string;\n sourceSheet: string;\n sourceData: PivotSourceData;\n recordsRid: string;\n cacheDefOpts?: PivotCacheDefinitionOptions;\n}\n\n// ── Descriptors ──\n\nexport const pivotCacheDefDesc: CustomDescriptor<PivotCacheDefDescriptorOptions> = {\n kind: \"custom\",\n\n stringify(opts, _ctx) {\n return stringifyPivotCacheDef(\n opts.sourceRef,\n opts.sourceSheet,\n opts.sourceData,\n opts.recordsRid,\n opts.cacheDefOpts,\n );\n },\n\n parse(el, _ctx) {\n const result: Record<string, unknown> = {};\n\n // Root element attributes\n if (attr(el, \"invalid\") === \"1\") result.invalid = true;\n if (attr(el, \"saveData\") === \"0\") result.saveData = false;\n if (attr(el, \"optimizeMemory\") === \"1\") result.optimizeMemory = true;\n if (attr(el, \"enableRefresh\") === \"0\") result.enableRefresh = false;\n if (attr(el, \"refreshedBy\")) result.refreshedBy = attr(el, \"refreshedBy\");\n const rd = attrNum(el, \"refreshedDate\");\n if (rd !== undefined) result.refreshedDate = rd;\n if (attr(el, \"refreshedDateIso\")) result.refreshedDateIso = attr(el, \"refreshedDateIso\");\n if (attr(el, \"backgroundQuery\") === \"1\") result.backgroundQuery = true;\n const mil = attrNum(el, \"missingItemsLimit\");\n if (mil !== undefined) result.missingItemsLimit = mil;\n if (attr(el, \"upgradeOnRefresh\") === \"1\") result.upgradeOnRefresh = true;\n if (attr(el, \"supportSubquery\") === \"1\") result.supportSubquery = true;\n if (attr(el, \"supportAdvancedDrill\") === \"1\") result.supportAdvancedDrill = true;\n const recordCount = attrNum(el, \"recordCount\");\n if (recordCount !== undefined) result.recordCount = recordCount;\n\n const csEl = findChild(el, \"cacheSource\");\n if (csEl) {\n result.sourceType = attr(csEl, \"type\");\n const wssEl = findChild(csEl, \"worksheetSource\");\n if (wssEl) {\n const wss: Record<string, unknown> = {};\n if (attr(wssEl, \"ref\")) wss.ref = attr(wssEl, \"ref\");\n if (attr(wssEl, \"sheet\")) wss.sheet = attr(wssEl, \"sheet\");\n result.worksheetSource = wss;\n }\n }\n const cfEl = findChild(el, \"cacheFields\");\n if (cfEl) {\n const fields: Record<string, unknown>[] = [];\n for (const fEl of cfEl.elements ?? []) {\n if (fEl.name !== \"cacheField\") continue;\n const field: Record<string, unknown> = {};\n if (attr(fEl, \"name\")) field.name = attr(fEl, \"name\");\n if (attrNum(fEl, \"numFmtId\") !== undefined) field.numFmtId = attrNum(fEl, \"numFmtId\");\n const siEl = findChild(fEl, \"sharedItems\");\n if (siEl) {\n const items: (string | number)[] = [];\n for (const siChild of siEl.elements ?? []) {\n const v = attr(siChild, \"v\");\n if (v !== undefined) items.push(isNaN(Number(v)) ? v : Number(v));\n }\n field.sharedItems = items;\n }\n fields.push(field);\n }\n result.cacheFields = fields;\n }\n return result as unknown as PivotCacheDefDescriptorOptions;\n },\n};\n\nexport const pivotCacheRecordsDesc: CustomDescriptor<PivotCacheRecordsDescriptorOptions> = {\n kind: \"custom\",\n\n stringify(opts, _ctx) {\n return stringifyPivotCacheRecords(opts.sourceData);\n },\n\n parse(el, _ctx) {\n const records: Record<string, unknown>[][] = [];\n for (const rEl of el.elements ?? []) {\n if (rEl.name !== \"r\") continue;\n const record: Record<string, unknown>[] = [];\n for (const fEl of rEl.elements ?? []) {\n const entry: Record<string, unknown> = {};\n if (fEl.name === \"x\") {\n entry.type = \"string\";\n entry.v = attrNum(fEl, \"v\") ?? 0;\n } else if (fEl.name === \"n\") {\n entry.type = \"number\";\n const v = attr(fEl, \"v\");\n entry.v = v !== undefined ? Number(v) : 0;\n } else if (fEl.name === \"d\") {\n entry.type = \"date\";\n entry.v = attr(fEl, \"v\") ?? \"\";\n } else if (fEl.name === \"m\") {\n entry.type = \"missing\";\n }\n record.push(entry);\n }\n records.push(record);\n }\n return { records } as unknown as PivotCacheDefDescriptorOptions;\n },\n};\n\n// ── Stringify: pivotCacheDefinition ──\n\nfunction stringifyPivotCacheDef(\n sourceRef: string,\n sourceSheet: string,\n sourceData: PivotSourceData,\n recordsRid: string,\n cacheDefOpts?: PivotCacheDefinitionOptions,\n): string {\n const p: string[] = [];\n const rootAttrs: string[] = [\n 'xmlns=\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\"',\n 'xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\"',\n `r:id=\"${escapeXml(recordsRid)}\"`,\n `recordCount=\"${sourceData.records.length}\"`,\n 'createdVersion=\"6\"',\n 'refreshedVersion=\"6\"',\n 'minRefreshableVersion=\"3\"',\n ];\n\n if (cacheDefOpts) {\n const cd = cacheDefOpts;\n if (cd.invalid) rootAttrs.push('invalid=\"1\"');\n if (cd.saveData === false) rootAttrs.push('saveData=\"0\"');\n if (cd.optimizeMemory) rootAttrs.push('optimizeMemory=\"1\"');\n if (cd.enableRefresh === false) rootAttrs.push('enableRefresh=\"0\"');\n if (cd.refreshedBy) rootAttrs.push(`refreshedBy=\"${escapeXml(cd.refreshedBy)}\"`);\n if (cd.refreshedDate !== undefined) rootAttrs.push(`refreshedDate=\"${cd.refreshedDate}\"`);\n if (cd.refreshedDateIso) rootAttrs.push(`refreshedDateIso=\"${escapeXml(cd.refreshedDateIso)}\"`);\n if (cd.backgroundQuery) rootAttrs.push('backgroundQuery=\"1\"');\n if (cd.missingItemsLimit !== undefined)\n rootAttrs.push(`missingItemsLimit=\"${cd.missingItemsLimit}\"`);\n if (cd.upgradeOnRefresh) rootAttrs.push('upgradeOnRefresh=\"1\"');\n if (cd.supportSubquery) rootAttrs.push('supportSubquery=\"1\"');\n if (cd.supportAdvancedDrill) rootAttrs.push('supportAdvancedDrill=\"1\"');\n }\n\n p.push(`<pivotCacheDefinition ${rootAttrs.join(\" \")}>`);\n\n // cacheSource\n if (cacheDefOpts?.consolidation) {\n const con = cacheDefOpts.consolidation;\n const conParts: string[] = ['<cacheSource type=\"consolidation\"><consolidation'];\n if (con.autoPage === false) conParts.push(' autoPage=\"0\"');\n conParts.push(\">\");\n if (con.pages && con.pages.length > 0) {\n conParts.push(`<pages count=\"${con.pages.length}\">`);\n for (const pg of con.pages) {\n const pgItems = pg.items ?? [];\n conParts.push(`<page${pgItems.length ? ` count=\"${pgItems.length}\"` : \"\"}>`);\n for (const pi of pgItems) conParts.push(`<pageItem name=\"${escapeXml(pi.name)}\"/>`);\n conParts.push(\"</page>\");\n }\n conParts.push(\"</pages>\");\n }\n conParts.push(`<rangeSets count=\"${con.rangeSets.length}\">`);\n for (const rs of con.rangeSets) {\n const rsAttrs: string[] = [];\n if (rs.i1 !== undefined) rsAttrs.push(`i1=\"${rs.i1}\"`);\n if (rs.i2 !== undefined) rsAttrs.push(`i2=\"${rs.i2}\"`);\n if (rs.i3 !== undefined) rsAttrs.push(`i3=\"${rs.i3}\"`);\n if (rs.i4 !== undefined) rsAttrs.push(`i4=\"${rs.i4}\"`);\n if (rs.ref) rsAttrs.push(`ref=\"${escapeXml(rs.ref)}\"`);\n if (rs.name) rsAttrs.push(`name=\"${escapeXml(rs.name)}\"`);\n if (rs.sheet) rsAttrs.push(`sheet=\"${escapeXml(rs.sheet)}\"`);\n if (rs.rId) rsAttrs.push(`r:id=\"${escapeXml(rs.rId)}\"`);\n conParts.push(`<rangeSet ${rsAttrs.join(\" \")}/>`);\n }\n conParts.push(\"</rangeSets></consolidation></cacheSource>\");\n p.push(conParts.join(\"\"));\n } else {\n p.push(\n `<cacheSource type=\"worksheet\">` +\n `<worksheetSource ref=\"${escapeXml(sourceRef)}\" sheet=\"${escapeXml(sourceSheet)}\"/>` +\n `</cacheSource>`,\n );\n }\n\n // cacheFields\n const fieldNames = sourceData.fieldNames;\n p.push(`<cacheFields count=\"${fieldNames.length}\">`);\n\n for (let i = 0; i < fieldNames.length; i++) {\n const fieldName = fieldNames[i];\n const numeric = isNumericField(sourceData.records, i);\n const uniqueVals = collectUniqueValues(sourceData.records, i);\n\n if (numeric) {\n let min = Infinity,\n max = -Infinity;\n for (const row of sourceData.records) {\n const v = row[i];\n if (typeof v === \"number\") {\n if (v < min) min = v;\n if (v > max) max = v;\n }\n }\n if (!isFinite(min)) {\n min = 0;\n max = 0;\n }\n const allInteger = sourceData.records.every(\n (row) => typeof row[i] === \"number\" && Number.isInteger(row[i]),\n );\n\n const cfOverride = cacheDefOpts?.cacheFieldOverrides?.get(i);\n const cfExtraAttrs: string[] = [];\n const siExtraAttrs: string[] = [];\n if (cfOverride) {\n if (cfOverride.databaseField) cfExtraAttrs.push('databaseField=\"1\"');\n if (cfOverride.level !== undefined) cfExtraAttrs.push(`level=\"${cfOverride.level}\"`);\n if (cfOverride.mappingCount !== undefined)\n cfExtraAttrs.push(`mappingCount=\"${cfOverride.mappingCount}\"`);\n if (cfOverride.memberPropertyField !== undefined)\n cfExtraAttrs.push(`memberPropertyField=\"${cfOverride.memberPropertyField}\"`);\n if (cfOverride.propertyName)\n cfExtraAttrs.push(`propertyName=\"${escapeXml(cfOverride.propertyName)}\"`);\n if (cfOverride.serverField) cfExtraAttrs.push('serverField=\"1\"');\n if (cfOverride.uniqueList) cfExtraAttrs.push('uniqueList=\"1\"');\n if (cfOverride.containsMixedTypes) siExtraAttrs.push('containsMixedTypes=\"1\"');\n if (cfOverride.containsNonDate) siExtraAttrs.push('containsNonDate=\"1\"');\n if (cfOverride.longText) siExtraAttrs.push('longText=\"1\"');\n }\n\n p.push(\n `<cacheField name=\"${escapeXml(fieldName)}\" ${cfExtraAttrs.length ? cfExtraAttrs.join(\" \") + \" \" : \"\"}numFmtId=\"0\">` +\n `<sharedItems containsSemiMixedTypes=\"0\" containsString=\"0\"` +\n ` containsNumber=\"1\" containsInteger=\"${allInteger ? \"1\" : \"0\"}\"` +\n ` minValue=\"${min}\" maxValue=\"${max}\" count=\"${uniqueVals.length}\"${siExtraAttrs.length ? \" \" + siExtraAttrs.join(\" \") : \"\"}>`,\n );\n for (const v of uniqueVals) {\n if (v === null) p.push(\"<m/>\");\n else if (v instanceof Date) p.push(`<d v=\"${v.toISOString().replace(/\\.\\d{3}Z$/, \"Z\")}\"/>`);\n else p.push(`<n v=\"${v}\"/>`);\n }\n p.push(\"</sharedItems></cacheField>\");\n } else {\n let hasDate = false,\n hasMissing = false;\n for (const v of uniqueVals) {\n if (v instanceof Date) hasDate = true;\n if (v === null) hasMissing = true;\n }\n const siAttrs: string[] = [`count=\"${uniqueVals.length}\"`];\n if (hasDate) siAttrs.push('containsDate=\"1\"');\n if (hasMissing) siAttrs.push('containsBlank=\"1\"');\n\n const cfOverride = cacheDefOpts?.cacheFieldOverrides?.get(i);\n const cfExtraAttrs: string[] = [];\n if (cfOverride) {\n if (cfOverride.databaseField) cfExtraAttrs.push('databaseField=\"1\"');\n if (cfOverride.level !== undefined) cfExtraAttrs.push(`level=\"${cfOverride.level}\"`);\n if (cfOverride.mappingCount !== undefined)\n cfExtraAttrs.push(`mappingCount=\"${cfOverride.mappingCount}\"`);\n if (cfOverride.memberPropertyField !== undefined)\n cfExtraAttrs.push(`memberPropertyField=\"${cfOverride.memberPropertyField}\"`);\n if (cfOverride.propertyName)\n cfExtraAttrs.push(`propertyName=\"${escapeXml(cfOverride.propertyName)}\"`);\n if (cfOverride.serverField) cfExtraAttrs.push('serverField=\"1\"');\n if (cfOverride.uniqueList) cfExtraAttrs.push('uniqueList=\"1\"');\n if (cfOverride.containsMixedTypes) siAttrs.push('containsMixedTypes=\"1\"');\n if (cfOverride.containsNonDate) siAttrs.push('containsNonDate=\"1\"');\n if (cfOverride.longText) siAttrs.push('longText=\"1\"');\n }\n\n p.push(\n `<cacheField name=\"${escapeXml(fieldName)}\" ${cfExtraAttrs.length ? cfExtraAttrs.join(\" \") + \" \" : \"\"}numFmtId=\"0\"><sharedItems ${siAttrs.join(\" \")}>`,\n );\n\n for (const v of uniqueVals) {\n if (v === null) p.push(\"<m/>\");\n else if (v instanceof Date) p.push(`<d v=\"${v.toISOString().replace(/\\.\\d{3}Z$/, \"Z\")}\"/>`);\n else p.push(`<s v=\"${escapeXml(String(v))}\"/>`);\n }\n p.push(\"</sharedItems>\");\n\n // fieldGroup\n const fg = cacheDefOpts?.fieldGroups?.get(i);\n if (fg) {\n const fgParts: string[] = [\"<fieldGroup\"];\n if (fg.parent !== undefined) fgParts.push(` par=\"${fg.parent}\"`);\n if (fg.base !== undefined) fgParts.push(` base=\"${fg.base}\"`);\n fgParts.push(\">\");\n if (fg.rangePr) {\n const rp = fg.rangePr;\n const rpAttrs: string[] = [];\n if (rp.autoStart === false) rpAttrs.push('autoStart=\"0\"');\n if (rp.autoEnd === false) rpAttrs.push('autoEnd=\"0\"');\n if (rp.groupBy && rp.groupBy !== \"range\") rpAttrs.push(`groupBy=\"${rp.groupBy}\"`);\n if (rp.startNum !== undefined) rpAttrs.push(`startNum=\"${rp.startNum}\"`);\n if (rp.endNum !== undefined) rpAttrs.push(`endNum=\"${rp.endNum}\"`);\n if (rp.startDate) rpAttrs.push(`startDate=\"${escapeXml(rp.startDate)}\"`);\n if (rp.endDate) rpAttrs.push(`endDate=\"${escapeXml(rp.endDate)}\"`);\n if (rp.groupInterval !== undefined) rpAttrs.push(`groupInterval=\"${rp.groupInterval}\"`);\n fgParts.push(`<rangePr${rpAttrs.length ? \" \" + rpAttrs.join(\" \") : \"\"}/>`);\n }\n if (fg.discretePr && fg.discretePr.length > 0) {\n fgParts.push(`<discretePr count=\"${fg.discretePr.length}\">`);\n for (const idx of fg.discretePr) fgParts.push(`<x v=\"${idx}\"/>`);\n fgParts.push(\"</discretePr>\");\n }\n if (fg.groupItems && fg.groupItems.length > 0) {\n fgParts.push(`<groupItems count=\"${fg.groupItems.length}\">`);\n for (const gi of fg.groupItems) fgParts.push(`<s v=\"${escapeXml(gi)}\"/>`);\n fgParts.push(\"</groupItems>\");\n }\n fgParts.push(\"</fieldGroup>\");\n p.push(fgParts.join(\"\"));\n }\n\n p.push(\"</cacheField>\");\n }\n }\n p.push(\"</cacheFields>\");\n\n // mpMap\n if (cacheDefOpts?.mpMaps) {\n for (const mp of cacheDefOpts.mpMaps) p.push(`<mpMap x=\"${mp.x}\"/>`);\n }\n\n // olapPr\n if (cacheDefOpts?.olapPr) {\n const ol = cacheDefOpts.olapPr;\n const olAttrs: string[] = [];\n if (ol.local) olAttrs.push(` local=\"${escapeXml(ol.local)}\"`);\n if (ol.localConnection) olAttrs.push(` localConnection=\"${escapeXml(ol.localConnection)}\"`);\n if (ol.sendLocale) olAttrs.push(' sendLocale=\"1\"');\n if (ol.rowDrillCount !== undefined) olAttrs.push(` rowDrillCount=\"${ol.rowDrillCount}\"`);\n if (ol.colDrillCount !== undefined) olAttrs.push(` colDrillCount=\"${ol.colDrillCount}\"`);\n if (ol.localRefresh) olAttrs.push(' localRefresh=\"1\"');\n if (ol.serverFill === false) olAttrs.push(' serverFill=\"0\"');\n if (ol.serverNumberFormat === false) olAttrs.push(' serverNumberFormat=\"0\"');\n if (ol.serverFont === false) olAttrs.push(' serverFont=\"0\"');\n if (ol.serverFontColor === false) olAttrs.push(' serverFontColor=\"0\"');\n if (olAttrs.length > 0) p.push(`<olapPr${olAttrs.join(\"\")}/>`);\n }\n\n // cacheHierarchies\n if (cacheDefOpts?.cacheHierarchies && cacheDefOpts.cacheHierarchies.length > 0) {\n const chs = cacheDefOpts.cacheHierarchies;\n p.push(`<cacheHierarchies count=\"${chs.length}\">`);\n for (const ch of chs) {\n const chAttrs: string[] = [`uniqueName=\"${escapeXml(ch.uniqueName)}\"`, `count=\"${ch.count}\"`];\n if (ch.caption) chAttrs.push(`caption=\"${escapeXml(ch.caption)}\"`);\n if (ch.measure) chAttrs.push('measure=\"1\"');\n if (ch.set) chAttrs.push('set=\"1\"');\n if (ch.parentSet !== undefined) chAttrs.push(`parentSet=\"${ch.parentSet}\"`);\n if (ch.iconSet !== undefined && ch.iconSet !== 0) chAttrs.push(`iconSet=\"${ch.iconSet}\"`);\n if (ch.attribute) chAttrs.push('attribute=\"1\"');\n if (ch.time) chAttrs.push('time=\"1\"');\n if (ch.keyAttribute) chAttrs.push('keyAttribute=\"1\"');\n if (ch.defaultMemberUniqueName)\n chAttrs.push(`defaultMemberUniqueName=\"${escapeXml(ch.defaultMemberUniqueName)}\"`);\n if (ch.allUniqueName) chAttrs.push(`allUniqueName=\"${escapeXml(ch.allUniqueName)}\"`);\n if (ch.allCaption) chAttrs.push(`allCaption=\"${escapeXml(ch.allCaption)}\"`);\n if (ch.dimensionUniqueName)\n chAttrs.push(`dimensionUniqueName=\"${escapeXml(ch.dimensionUniqueName)}\"`);\n if (ch.displayFolder) chAttrs.push(`displayFolder=\"${escapeXml(ch.displayFolder)}\"`);\n if (ch.measureGroup) chAttrs.push(`measureGroup=\"${escapeXml(ch.measureGroup)}\"`);\n if (ch.measures) chAttrs.push('measures=\"1\"');\n if (ch.oneField) chAttrs.push('oneField=\"1\"');\n if (ch.hidden) chAttrs.push('hidden=\"1\"');\n if (ch.memberValueDatatype) chAttrs.push(`memberValueDatatype=\"${ch.memberValueDatatype}\"`);\n if (ch.unbalanced) chAttrs.push('unbalanced=\"1\"');\n if (ch.unbalancedGroup) chAttrs.push('unbalancedGroup=\"1\"');\n\n const hasGL = ch.groupLevels && ch.groupLevels.length > 0;\n const hasFU = ch.fieldsUsage && ch.fieldsUsage.length > 0;\n if (hasGL || hasFU) {\n p.push(`<cacheHierarchy ${chAttrs.join(\" \")}>`);\n if (hasFU) {\n const fuParts = [`<fieldsUsage count=\"${ch.fieldsUsage!.length}\">`];\n for (const fu of ch.fieldsUsage!) fuParts.push(`<fieldUsage v=\"${fu.value}\"/>`);\n fuParts.push(\"</fieldsUsage>\");\n p.push(fuParts.join(\"\"));\n }\n if (hasGL) {\n const glParts = [`<groupLevels count=\"${ch.groupLevels!.length}\">`];\n for (const gl of ch.groupLevels!) {\n const glAttrs = [\n `uniqueName=\"${escapeXml(gl.uniqueName)}\"`,\n `caption=\"${escapeXml(gl.caption)}\"`,\n ];\n if (gl.user) glAttrs.push('user=\"1\"');\n if (gl.customRollUp) glAttrs.push('customRollUp=\"1\"');\n if (gl.groups && gl.groups.length > 0) {\n glParts.push(`<groupLevel ${glAttrs.join(\" \")}><groups count=\"${gl.groups.length}\">`);\n for (const lg of gl.groups) {\n const lgAttrs = [\n `name=\"${escapeXml(lg.name)}\"`,\n `uniqueName=\"${escapeXml(lg.uniqueName)}\"`,\n `caption=\"${escapeXml(lg.caption)}\"`,\n ];\n if (lg.uniqueParent) lgAttrs.push(`uniqueParent=\"${escapeXml(lg.uniqueParent)}\"`);\n if (lg.id !== undefined) lgAttrs.push(`id=\"${lg.id}\"`);\n glParts.push(\n `<group ${lgAttrs.join(\" \")}><groupMembers count=\"${lg.members.length}\">`,\n );\n for (const gm of lg.members) {\n const gmAttrs = [`uniqueName=\"${escapeXml(gm.uniqueName)}\"`];\n if (gm.group) gmAttrs.push('group=\"1\"');\n glParts.push(`<groupMember ${gmAttrs.join(\" \")}/>`);\n }\n glParts.push(\"</groupMembers></group>\");\n }\n glParts.push(\"</groups></groupLevel>\");\n } else {\n glParts.push(`<groupLevel ${glAttrs.join(\" \")}/>`);\n }\n }\n glParts.push(\"</groupLevels>\");\n p.push(glParts.join(\"\"));\n }\n p.push(\"</cacheHierarchy>\");\n } else {\n p.push(`<cacheHierarchy ${chAttrs.join(\" \")}/>`);\n }\n }\n p.push(\"</cacheHierarchies>\");\n }\n\n // kpis\n if (cacheDefOpts?.kpis && cacheDefOpts.kpis.length > 0) {\n p.push(`<kpis count=\"${cacheDefOpts.kpis.length}\">`);\n for (const k of cacheDefOpts.kpis) {\n const kAttrs: string[] = [\n `uniqueName=\"${escapeXml(k.uniqueName)}\"`,\n `value=\"${escapeXml(k.value)}\"`,\n ];\n if (k.caption) kAttrs.push(`caption=\"${escapeXml(k.caption)}\"`);\n if (k.displayFolder) kAttrs.push(`displayFolder=\"${escapeXml(k.displayFolder)}\"`);\n if (k.measureGroup) kAttrs.push(`measureGroup=\"${escapeXml(k.measureGroup)}\"`);\n if (k.parent) kAttrs.push(`parent=\"${escapeXml(k.parent)}\"`);\n if (k.goal) kAttrs.push(`goal=\"${escapeXml(k.goal)}\"`);\n if (k.status) kAttrs.push(`status=\"${escapeXml(k.status)}\"`);\n if (k.trend) kAttrs.push(`trend=\"${escapeXml(k.trend)}\"`);\n if (k.weight) kAttrs.push(`weight=\"${escapeXml(k.weight)}\"`);\n if (k.time) kAttrs.push(`time=\"${escapeXml(k.time)}\"`);\n p.push(`<kpi ${kAttrs.join(\" \")}/>`);\n }\n p.push(\"</kpis>\");\n }\n\n // measureGroups\n if (cacheDefOpts?.measureGroups && cacheDefOpts.measureGroups.length > 0) {\n p.push(`<measureGroups count=\"${cacheDefOpts.measureGroups.length}\">`);\n for (const mg of cacheDefOpts.measureGroups) {\n p.push(`<measureGroup name=\"${escapeXml(mg.name)}\" caption=\"${escapeXml(mg.caption)}\"/>`);\n }\n p.push(\"</measureGroups>\");\n }\n\n // maps\n if (cacheDefOpts?.measureDimensionMaps && cacheDefOpts.measureDimensionMaps.length > 0) {\n p.push(`<maps count=\"${cacheDefOpts.measureDimensionMaps.length}\">`);\n for (const m of cacheDefOpts.measureDimensionMaps) {\n const mAttrs: string[] = [];\n if (m.measureGroup !== undefined) mAttrs.push(`measureGroup=\"${m.measureGroup}\"`);\n if (m.dimension !== undefined) mAttrs.push(`dimension=\"${m.dimension}\"`);\n p.push(`<map ${mAttrs.join(\" \")}/>`);\n }\n p.push(\"</maps>\");\n }\n\n // dimensions\n if (cacheDefOpts?.dimensions && cacheDefOpts.dimensions.length > 0) {\n p.push(`<dimensions count=\"${cacheDefOpts.dimensions.length}\">`);\n for (const d of cacheDefOpts.dimensions) {\n const dAttrs: string[] = [\n `name=\"${escapeXml(d.name)}\"`,\n `uniqueName=\"${escapeXml(d.uniqueName)}\"`,\n `caption=\"${escapeXml(d.caption)}\"`,\n ];\n if (d.measure) dAttrs.push('measure=\"1\"');\n p.push(`<dimension ${dAttrs.join(\" \")}/>`);\n }\n p.push(\"</dimensions>\");\n }\n\n // tupleCache\n const cd = cacheDefOpts;\n const hasEntries = cd?.entries && cd.entries.length > 0;\n const hasSets = cd?.sets && cd.sets.length > 0;\n const hasSF = cd?.serverFormats && cd.serverFormats.length > 0;\n const hasQC = cd?.queryCache && cd.queryCache.length > 0;\n if (hasEntries || hasSets || hasSF || hasQC) {\n p.push(\"<tupleCache>\");\n if (hasEntries) {\n const entParts: string[] = [`<entries count=\"${cd!.entries!.length}\">`];\n for (const ent of cd!.entries!) {\n if (ent.type === \"m\") entParts.push(\"<m/>\");\n else if (ent.value !== undefined) entParts.push(`<${ent.type} v=\"${ent.value}\"/>`);\n }\n entParts.push(\"</entries>\");\n p.push(entParts.join(\"\"));\n }\n if (hasSets) {\n p.push(`<sets count=\"${cd!.sets!.length}\">`);\n for (const s of cd!.sets!) {\n const sAttrs: string[] = [\n `maxRank=\"${s.maxRank}\"`,\n `setDefinition=\"${escapeXml(s.setDefinition)}\"`,\n ];\n if (s.count !== undefined) sAttrs.push(`count=\"${s.count}\"`);\n if (s.sortType && s.sortType !== \"none\") sAttrs.push(`sortType=\"${s.sortType}\"`);\n if (s.queryFailed) sAttrs.push('queryFailed=\"1\"');\n p.push(`<set ${sAttrs.join(\" \")}/>`);\n }\n p.push(\"</sets>\");\n }\n if (hasSF) {\n p.push(`<serverFormats count=\"${cd!.serverFormats!.length}\">`);\n for (const sf of cd!.serverFormats!) {\n const sfAttrs: string[] = [];\n if (sf.culture) sfAttrs.push(`culture=\"${escapeXml(sf.culture)}\"`);\n if (sf.format) sfAttrs.push(`format=\"${escapeXml(sf.format)}\"`);\n p.push(`<serverFormat ${sfAttrs.join(\" \")}/>`);\n }\n p.push(\"</serverFormats>\");\n }\n if (hasQC) {\n p.push(`<queryCache count=\"${cd!.queryCache!.length}\">`);\n for (const q of cd!.queryCache!) {\n const qInner =\n q.tpls && q.tpls.length > 0\n ? `<tpls count=\"${q.tpls.length}\">${q.tpls.map((tpl: { items?: number[] }) => (tpl.items && tpl.items.length > 0 ? `<tpl>${tpl.items.map((x: number) => `<x v=\"${x}\"/>`).join(\"\")}</tpl>` : \"<tpl/>\")).join(\"\")}</tpls>`\n : \"\";\n if (qInner) p.push(`<query mdx=\"${escapeXml(q.mdx)}\">${qInner}</query>`);\n else p.push(`<query mdx=\"${escapeXml(q.mdx)}\"/>`);\n }\n p.push(\"</queryCache>\");\n }\n p.push(\"</tupleCache>\");\n }\n\n p.push(\"</pivotCacheDefinition>\");\n return p.join(\"\");\n}\n\n// ── Stringify: pivotCacheRecords ──\n\nfunction stringifyPivotCacheRecords(sourceData: PivotSourceData): string {\n const numericFields = sourceData.fieldNames.map((_, i) => isNumericField(sourceData.records, i));\n const fieldIndexMaps: Map<string, number>[] = sourceData.fieldNames.map((_, i) => {\n if (numericFields[i]) return new Map<string, number>();\n const unique = collectUniqueValues(sourceData.records, i);\n const map = new Map<string, number>();\n for (let j = 0; j < unique.length; j++) map.set(String(unique[j]), j);\n return map;\n });\n\n const p: string[] = [];\n p.push(\n `<pivotCacheRecords xmlns=\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\" count=\"${sourceData.records.length}\">`,\n );\n\n for (const row of sourceData.records) {\n p.push(\"<r>\");\n for (let i = 0; i < row.length; i++) {\n const val = row[i];\n if (val === null) {\n p.push(\"<m/>\");\n } else if (val instanceof Date) {\n p.push(`<d v=\"${val.toISOString().replace(/\\.\\d{3}Z$/, \"Z\")}\"/>`);\n } else if (numericFields[i]) {\n p.push(`<n v=\"${val}\"/>`);\n } else {\n p.push(`<x v=\"${fieldIndexMaps[i].get(String(val)) ?? 0}\"/>`);\n }\n }\n p.push(\"</r>\");\n }\n\n p.push(\"</pivotCacheRecords>\");\n return p.join(\"\");\n}\n","/**\n * Table types and descriptor for SpreadsheetML documents.\n *\n * Implements CT_Table from sml.xsd (transitional schema).\n *\n * @module\n */\n\nimport type { CustomDescriptor } from \"@office-open/core/descriptor\";\nimport { findChild, attr, attrNum, textOf, escapeXml } from \"@office-open/xml\";\n\n// ── Totals row function (ST_TotalsRowFunction) ──\n\nexport const TotalsRowFunction = {\n NONE: \"none\",\n SUM: \"sum\",\n MIN: \"min\",\n MAX: \"max\",\n AVERAGE: \"average\",\n COUNT: \"count\",\n COUNT_NUMS: \"countNums\",\n STD_DEV: \"stdDev\",\n VAR: \"var\",\n CUSTOM: \"custom\",\n} as const;\n\nexport type TotalsRowFunction = (typeof TotalsRowFunction)[keyof typeof TotalsRowFunction];\n\n// ── Table type (ST_TableType) ──\n\nexport const TableType = {\n WORKSHEET: \"worksheet\",\n XML: \"xml\",\n QUERY_TABLE: \"queryTable\",\n} as const;\n\nexport type TableType = (typeof TableType)[keyof typeof TableType];\n\n// ── Options interfaces ──\n\nexport interface TableStyleInfoOptions {\n /** Table style name, e.g. \"TableStyleMedium9\" */\n name?: string;\n showFirstColumn?: boolean;\n showLastColumn?: boolean;\n showRowStripes?: boolean;\n showColumnStripes?: boolean;\n}\n\nexport interface TableColumnOptions {\n /** Column name (used in header row) */\n name: string;\n /** Totals row function */\n totalsRowFunction?: TotalsRowFunction;\n /** Totals row label (used when totalsRowFunction is \"none\" or \"custom\") */\n totalsRowLabel?: string;\n /** Calculated column formula */\n calculatedColumnFormula?: string;\n /** Totals row formula (CT_TableColumn/totalsRowFormula, used when totalsRowFunction is \"custom\") */\n totalsRowFormula?: string;\n /** Whether totals row formula is array (CT_TableFormula @array) */\n totalsRowFormulaArray?: boolean;\n /** Whether calculated column formula is array (CT_TableFormula @array) */\n calculatedColumnFormulaArray?: boolean;\n /** Unique column name for structured references (CT_TableColumn @uniqueName) */\n uniqueName?: string;\n /** Query table field ID (CT_TableColumn @queryTableFieldId) */\n queryTableFieldId?: number;\n /** Header row differential format index */\n headerRowDxfId?: number;\n /** Data differential format index */\n dataDxfId?: number;\n /** Totals row differential format index */\n totalsRowDxfId?: number;\n /** Header row cell style name */\n headerRowCellStyle?: string;\n /** Data cell style name */\n dataCellStyle?: string;\n /** Totals row cell style name */\n totalsRowCellStyle?: string;\n}\n\nexport interface TableOptions {\n /** Unique table id (1-based, must be unique across the workbook) */\n id: number;\n /** Table name (used in structured references) */\n name?: string;\n /** Display name (required by XSD, defaults to name if not set) */\n displayName: string;\n /** Data range, e.g. \"A1:D10\" */\n ref: string;\n /** Column definitions */\n columns: TableColumnOptions[];\n /** Number of header rows (default: 1) */\n headerRowCount?: number;\n /** Number of totals rows (default: 0) */\n totalsRowCount?: number;\n /** Whether to show totals row (default: true when totalsRowCount > 0) */\n totalsRowShown?: boolean;\n /** Table type (default: \"worksheet\") */\n tableType?: TableType;\n /** Table style */\n style?: TableStyleInfoOptions;\n /** Auto-filter reference (defaults to ref) */\n autoFilter?: string;\n /** Insert row shifts existing rows (CT_Table @insertRowShift) */\n insertRowShift?: boolean;\n /** Published to server (CT_Table @published) */\n published?: boolean;\n /** Header row differential format index */\n headerRowDxfId?: number;\n /** Data differential format index */\n dataDxfId?: number;\n /** Totals row differential format index */\n totalsRowDxfId?: number;\n /** Header row border differential format index */\n headerRowBorderDxfId?: number;\n /** Table border differential format index */\n tableBorderDxfId?: number;\n /** Totals row border differential format index */\n totalsRowBorderDxfId?: number;\n /** Header row cell style name */\n headerRowCellStyle?: string;\n /** Data cell style name */\n dataCellStyle?: string;\n /** Totals row cell style name */\n totalsRowCellStyle?: string;\n}\n\n// ── Helper ──\n\nfunction buildAttrs(attrsMap: Record<string, string | number | boolean | undefined>): string {\n const parts: string[] = [];\n for (const [k, v] of Object.entries(attrsMap)) {\n if (v === undefined) continue;\n parts.push(` ${k}=\"${typeof v === \"string\" ? escapeXml(v) : String(v)}\"`);\n }\n return parts.join(\"\");\n}\n\n// ── Descriptor ──\n\nexport const tableDesc: CustomDescriptor<TableOptions> = {\n kind: \"custom\",\n\n stringify(o, _ctx) {\n const p: string[] = [];\n\n // Root element with attributes\n const rootAttrs: Record<string, string | number | boolean | undefined> = {\n id: o.id,\n name: o.name ?? o.displayName,\n displayName: o.displayName,\n ref: o.ref,\n };\n if (o.tableType && o.tableType !== \"worksheet\") {\n rootAttrs.tableType = o.tableType;\n }\n if (o.headerRowCount !== undefined && o.headerRowCount !== 1) {\n rootAttrs.headerRowCount = o.headerRowCount;\n }\n if (o.totalsRowCount !== undefined && o.totalsRowCount > 0) {\n rootAttrs.totalsRowCount = o.totalsRowCount;\n }\n if (o.totalsRowShown === false) {\n rootAttrs.totalsRowShown = 0;\n }\n if (o.insertRowShift) rootAttrs.insertRowShift = 1;\n if (o.published) rootAttrs.published = 1;\n if (o.headerRowDxfId !== undefined) rootAttrs.headerRowDxfId = o.headerRowDxfId;\n if (o.dataDxfId !== undefined) rootAttrs.dataDxfId = o.dataDxfId;\n if (o.totalsRowDxfId !== undefined) rootAttrs.totalsRowDxfId = o.totalsRowDxfId;\n if (o.headerRowBorderDxfId !== undefined)\n rootAttrs.headerRowBorderDxfId = o.headerRowBorderDxfId;\n if (o.tableBorderDxfId !== undefined) rootAttrs.tableBorderDxfId = o.tableBorderDxfId;\n if (o.totalsRowBorderDxfId !== undefined)\n rootAttrs.totalsRowBorderDxfId = o.totalsRowBorderDxfId;\n if (o.headerRowCellStyle) rootAttrs.headerRowCellStyle = o.headerRowCellStyle;\n if (o.dataCellStyle) rootAttrs.dataCellStyle = o.dataCellStyle;\n if (o.totalsRowCellStyle) rootAttrs.totalsRowCellStyle = o.totalsRowCellStyle;\n\n p.push(\n `<table xmlns=\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\"` +\n ` xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\"` +\n ` mc:Ignorable=\"xr xr2\"` +\n ` xmlns:xr=\"http://schemas.microsoft.com/office/spreadsheetml/2014/revision\"` +\n ` xmlns:xr2=\"http://schemas.microsoft.com/office/spreadsheetml/2015/revision2\"${buildAttrs(rootAttrs)}>`,\n );\n\n // autoFilter (optional, before tableColumns per XSD sequence)\n if (o.autoFilter !== undefined) {\n p.push(`<autoFilter ref=\"${escapeXml(o.autoFilter)}\"/>`);\n }\n\n // tableColumns (required)\n p.push(`<tableColumns count=\"${o.columns.length}\">`);\n for (let i = 0; i < o.columns.length; i++) {\n const col = o.columns[i];\n const colAttrs: Record<string, string | number | boolean | undefined> = {\n id: i + 1,\n name: col.name,\n };\n\n const inner: string[] = [];\n\n // calculatedColumnFormula\n if (col.calculatedColumnFormula !== undefined) {\n const fAttrs = col.calculatedColumnFormulaArray ? ' array=\"1\"' : \"\";\n inner.push(\n `<calculatedColumnFormula${fAttrs}>${escapeXml(col.calculatedColumnFormula)}</calculatedColumnFormula>`,\n );\n }\n\n // totalsRowFormula (when totalsRowFunction is \"custom\")\n if (col.totalsRowFormula !== undefined) {\n const fAttrs = col.totalsRowFormulaArray ? ' array=\"1\"' : \"\";\n inner.push(\n `<totalsRowFormula${fAttrs}>${escapeXml(col.totalsRowFormula)}</totalsRowFormula>`,\n );\n }\n\n if (col.totalsRowFunction !== undefined && col.totalsRowFunction !== TotalsRowFunction.NONE) {\n colAttrs.totalsRowFunction = col.totalsRowFunction;\n }\n if (col.totalsRowLabel !== undefined) {\n colAttrs.totalsRowLabel = col.totalsRowLabel;\n }\n if (col.uniqueName) colAttrs.uniqueName = col.uniqueName;\n if (col.queryTableFieldId !== undefined) colAttrs.queryTableFieldId = col.queryTableFieldId;\n if (col.headerRowDxfId !== undefined) colAttrs.headerRowDxfId = col.headerRowDxfId;\n if (col.dataDxfId !== undefined) colAttrs.dataDxfId = col.dataDxfId;\n if (col.totalsRowDxfId !== undefined) colAttrs.totalsRowDxfId = col.totalsRowDxfId;\n if (col.headerRowCellStyle) colAttrs.headerRowCellStyle = col.headerRowCellStyle;\n if (col.dataCellStyle) colAttrs.dataCellStyle = col.dataCellStyle;\n if (col.totalsRowCellStyle) colAttrs.totalsRowCellStyle = col.totalsRowCellStyle;\n\n if (inner.length > 0) {\n p.push(`<tableColumn${buildAttrs(colAttrs)}>${inner.join(\"\")}</tableColumn>`);\n } else {\n p.push(`<tableColumn${buildAttrs(colAttrs)}/>`);\n }\n }\n p.push(\"</tableColumns>\");\n\n // tableStyleInfo (optional)\n if (o.style) {\n const s = o.style;\n const styleAttrs: Record<string, string | number | boolean | undefined> = {};\n if (s.name !== undefined) styleAttrs.name = s.name;\n if (s.showFirstColumn) styleAttrs.showFirstColumn = 1;\n if (s.showLastColumn) styleAttrs.showLastColumn = 1;\n if (s.showRowStripes !== false) styleAttrs.showRowStripes = 1;\n if (s.showColumnStripes) styleAttrs.showColumnStripes = 1;\n p.push(`<tableStyleInfo${buildAttrs(styleAttrs)}/>`);\n }\n\n p.push(\"</table>\");\n return p.join(\"\");\n },\n\n parse(el, _ctx) {\n const result: Record<string, unknown> = {};\n\n // Root attributes\n const id = attrNum(el, \"id\");\n if (id !== undefined) result.id = id;\n if (attr(el, \"name\")) result.name = attr(el, \"name\");\n if (attr(el, \"displayName\")) result.displayName = attr(el, \"displayName\");\n if (attr(el, \"ref\")) result.ref = attr(el, \"ref\");\n const headerRowCount = attrNum(el, \"headerRowCount\");\n if (headerRowCount !== undefined) result.headerRowCount = headerRowCount;\n const totalsRowCount = attrNum(el, \"totalsRowCount\");\n if (totalsRowCount !== undefined) result.totalsRowCount = totalsRowCount;\n if (attr(el, \"totalsRowShown\") === \"0\") result.totalsRowShown = false;\n if (attr(el, \"tableType\")) result.tableType = attr(el, \"tableType\");\n if (attr(el, \"insertRowShift\") === \"1\") result.insertRowShift = true;\n if (attr(el, \"published\") === \"1\") result.published = true;\n\n // Auto filter\n const afEl = findChild(el, \"autoFilter\");\n if (afEl) result.autoFilter = attr(afEl, \"ref\") ?? \"\";\n\n // Table columns\n const colsEl = findChild(el, \"tableColumns\");\n if (colsEl) {\n const columns: Record<string, unknown>[] = [];\n for (const colEl of colsEl.elements ?? []) {\n if (colEl.name !== \"tableColumn\") continue;\n const col: Record<string, unknown> = {};\n const colId = attrNum(colEl, \"id\");\n if (colId !== undefined) col.id = colId;\n col.name = attr(colEl, \"name\") ?? \"\";\n if (attr(colEl, \"totalsRowFunction\"))\n col.totalsRowFunction = attr(colEl, \"totalsRowFunction\");\n if (attr(colEl, \"totalsRowLabel\")) col.totalsRowLabel = attr(colEl, \"totalsRowLabel\");\n const ccfEl = findChild(colEl, \"calculatedColumnFormula\");\n if (ccfEl) {\n col.calculatedColumnFormula = textOf(ccfEl);\n if (attr(ccfEl, \"array\") === \"1\") col.calculatedColumnFormulaArray = true;\n }\n const trfEl = findChild(colEl, \"totalsRowFormula\");\n if (trfEl) {\n col.totalsRowFormula = textOf(trfEl);\n if (attr(trfEl, \"array\") === \"1\") col.totalsRowFormulaArray = true;\n }\n if (attr(colEl, \"uniqueName\")) col.uniqueName = attr(colEl, \"uniqueName\");\n const qtfId = attrNum(colEl, \"queryTableFieldId\");\n if (qtfId !== undefined) col.queryTableFieldId = qtfId;\n const hrDxfId = attrNum(colEl, \"headerRowDxfId\");\n if (hrDxfId !== undefined) col.headerRowDxfId = hrDxfId;\n const dDxfId = attrNum(colEl, \"dataDxfId\");\n if (dDxfId !== undefined) col.dataDxfId = dDxfId;\n const trDxfId = attrNum(colEl, \"totalsRowDxfId\");\n if (trDxfId !== undefined) col.totalsRowDxfId = trDxfId;\n if (attr(colEl, \"headerRowCellStyle\"))\n col.headerRowCellStyle = attr(colEl, \"headerRowCellStyle\");\n if (attr(colEl, \"dataCellStyle\")) col.dataCellStyle = attr(colEl, \"dataCellStyle\");\n if (attr(colEl, \"totalsRowCellStyle\"))\n col.totalsRowCellStyle = attr(colEl, \"totalsRowCellStyle\");\n columns.push(col);\n }\n result.columns = columns;\n }\n\n // Table style info\n const siEl = findChild(el, \"tableStyleInfo\");\n if (siEl) {\n const style: Record<string, unknown> = {};\n if (attr(siEl, \"name\")) style.name = attr(siEl, \"name\");\n if (attr(siEl, \"showFirstColumn\") === \"1\") style.showFirstColumn = true;\n if (attr(siEl, \"showLastColumn\") === \"1\") style.showLastColumn = true;\n if (attr(siEl, \"showRowStripes\") === \"1\") style.showRowStripes = true;\n if (attr(siEl, \"showColumnStripes\") === \"1\") style.showColumnStripes = true;\n result.style = style;\n }\n\n // Differential format IDs\n const hrDxfId = attrNum(el, \"headerRowDxfId\");\n if (hrDxfId !== undefined) result.headerRowDxfId = hrDxfId;\n const dDxfId = attrNum(el, \"dataDxfId\");\n if (dDxfId !== undefined) result.dataDxfId = dDxfId;\n const trDxfId = attrNum(el, \"totalsRowDxfId\");\n if (trDxfId !== undefined) result.totalsRowDxfId = trDxfId;\n const hrbDxfId = attrNum(el, \"headerRowBorderDxfId\");\n if (hrbDxfId !== undefined) result.headerRowBorderDxfId = hrbDxfId;\n const tbDxfId = attrNum(el, \"tableBorderDxfId\");\n if (tbDxfId !== undefined) result.tableBorderDxfId = tbDxfId;\n const trbDxfId = attrNum(el, \"totalsRowBorderDxfId\");\n if (trbDxfId !== undefined) result.totalsRowBorderDxfId = trbDxfId;\n if (attr(el, \"headerRowCellStyle\")) result.headerRowCellStyle = attr(el, \"headerRowCellStyle\");\n if (attr(el, \"dataCellStyle\")) result.dataCellStyle = attr(el, \"dataCellStyle\");\n if (attr(el, \"totalsRowCellStyle\")) result.totalsRowCellStyle = attr(el, \"totalsRowCellStyle\");\n\n return result as unknown as TableOptions;\n },\n};\n","/**\n * Workbook types and descriptor for SpreadsheetML documents.\n *\n * @module\n */\n\nimport { derivePasswordHash } from \"@office-open/core\";\nimport type { CustomDescriptor } from \"@office-open/core/descriptor\";\nimport { findChild, attr, attrNum, escapeXml } from \"@office-open/xml\";\n\nexport interface SheetDefinition {\n name: string;\n sheetId: number;\n rId: string;\n state?: \"visible\" | \"hidden\" | \"veryHidden\";\n}\n\nexport interface PivotCacheReference {\n cacheId: number;\n rId: string;\n}\n\nexport interface TablePartReference {\n rId: string;\n}\n\n/** Custom workbook view for storing display preferences. */\nexport interface CustomWorkbookViewOptions {\n /** View name */\n name: string;\n /** GUID (e.g. \"{00000000-0000-0000-0000-000000000000}\") */\n guid: string;\n /** Window width in twips */\n windowWidth: number;\n /** Window height in twips */\n windowHeight: number;\n /** Active sheet ID (1-based sheetId) */\n activeSheetId: number;\n /** X position of the window */\n xWindow?: number;\n /** Y position of the window */\n yWindow?: number;\n /** Show formula bar (default true) */\n showFormulaBar?: boolean;\n /** Show status bar (default true) */\n showStatusbar?: boolean;\n /** Show horizontal scroll (default true) */\n showHorizontalScroll?: boolean;\n /** Show vertical scroll (default true) */\n showVerticalScroll?: boolean;\n /** Show sheet tabs (default true) */\n showSheetTabs?: boolean;\n /** Tab ratio (default 600) */\n tabRatio?: number;\n /** Include hidden rows/columns (default true) */\n includeHiddenRowCol?: boolean;\n /** Include print settings (default true) */\n includePrintSettings?: boolean;\n /** Personal view (default false) */\n personalView?: boolean;\n /** Maximized (default false) */\n maximized?: boolean;\n /** Minimized (default false) */\n minimized?: boolean;\n /** Auto update (CT_CustomWorkbookView @autoUpdate) */\n autoUpdate?: boolean;\n /** Merge interval (CT_CustomWorkbookView @mergeInterval) */\n mergeInterval?: number;\n /** Changes saved in window (CT_CustomWorkbookView @changesSavedWin) */\n changesSavedWin?: boolean;\n /** Only sync (CT_CustomWorkbookView @onlySync) */\n onlySync?: boolean;\n /** Show comments (CT_CustomWorkbookView @showComments) */\n showComments?: string;\n}\n\nexport interface WorkbookProtectionOptions {\n /** Lock workbook structure (add/delete/rename/move sheets) */\n lockStructure?: boolean;\n /** Lock workbook windows */\n lockWindows?: boolean;\n /** Lock revisions */\n lockRevision?: boolean;\n /** Plain-text password — legacy Excel hash computed automatically */\n workbookPassword?: string;\n /** Modern encryption: algorithm name (e.g. \"SHA-512\") */\n workbookAlgorithmName?: string;\n /** Modern encryption: base64-encoded hash value */\n workbookHashValue?: string;\n /** Modern encryption: base64-encoded salt value */\n workbookSaltValue?: string;\n /** Modern encryption: spin count */\n workbookSpinCount?: number;\n /** Revisions password (legacy) */\n revisionsPassword?: string;\n /** Revisions modern encryption: algorithm name */\n revisionsAlgorithmName?: string;\n /** Revisions modern encryption: base64-encoded hash value */\n revisionsHashValue?: string;\n /** Revisions modern encryption: base64-encoded salt value */\n revisionsSaltValue?: string;\n /** Revisions modern encryption: spin count */\n revisionsSpinCount?: number;\n /** Workbook password character set (CT_WorkbookProtection @workbookPasswordCharacterSet) */\n workbookPasswordCharacterSet?: string;\n /** Revisions password character set (CT_WorkbookProtection @revisionsPasswordCharacterSet) */\n revisionsPasswordCharacterSet?: string;\n}\n\n/** Workbook conformance level (CT_Workbook @conformance) */\nexport type WorkbookConformance = \"strict\" | \"transitional\";\n\n/** File recovery properties (CT_FileRecoveryPr) */\nexport interface FileRecoveryPropertiesOptions {\n /** Enable auto-recover (default true) */\n autoRecover?: boolean;\n /** Crash save (default false) */\n crashSave?: boolean;\n /** Data extract load (default false) */\n dataExtractLoad?: boolean;\n /** Repair load (default false) */\n repairLoad?: boolean;\n}\n\n/** Web publishing properties (CT_WebPublishing) */\nexport interface WebPublishingOptions {\n /** Use CSS (default true) */\n css?: boolean;\n /** Use thicket format (default true) */\n thicket?: boolean;\n /** Use long file names (default true) */\n longFileNames?: boolean;\n /** Use VML (default false) */\n vml?: boolean;\n /** Allow PNG (default false) */\n allowPng?: boolean;\n /** Target screen size (default \"800x600\") */\n targetScreenSize?: string;\n /** DPI (default 96) */\n dpi?: number;\n /** Code page */\n codePage?: number;\n /** Character set */\n characterSet?: string;\n}\n\n/** File sharing properties (CT_FileSharing) */\nexport interface FileSharingOptions {\n /** Recommend read-only mode (default false) */\n readOnlyRecommended?: boolean;\n /** User name who has the file locked */\n userName?: string;\n /** Legacy reservation password (hex) */\n reservationPassword?: string;\n /** Modern encryption: algorithm name */\n algorithmName?: string;\n /** Modern encryption: base64 hash value */\n hashValue?: string;\n /** Modern encryption: base64 salt value */\n saltValue?: string;\n /** Modern encryption: spin count */\n spinCount?: number;\n}\n\n/** Workbook properties (CT_WorkbookPr) */\nexport interface WorkbookPropertiesOptions {\n /** Use 1904 date system (default false) */\n date1904?: boolean;\n /** Default theme version */\n defaultThemeVersion?: number;\n /** Show objects: \"all\" | \"placeholders\" | \"none\" */\n showObjects?: string;\n /** Hide pivot field list (default false) */\n hidePivotFieldList?: boolean;\n /** Allow refresh queries (default false) */\n allowRefreshQuery?: boolean;\n /** Filter privacy (default false) */\n filterPrivacy?: boolean;\n /** Backup file (default false) */\n backupFile?: boolean;\n /** Code name */\n codeName?: string;\n /** Show border unselected tables (CT_WorkbookPr @showBorderUnselectedTables) */\n showBorderUnselectedTables?: boolean;\n /** Prompted solutions (CT_WorkbookPr @promptedSolutions) */\n promptedSolutions?: boolean;\n /** Show ink annotation (CT_WorkbookPr @showInkAnnotation) */\n showInkAnnotation?: boolean;\n /** Save external link values (CT_WorkbookPr @saveExternalLinkValues) */\n saveExternalLinkValues?: boolean;\n /** Update links mode (CT_WorkbookPr @updateLinks) */\n updateLinks?: string;\n /** Show pivot chart filter (CT_WorkbookPr @showPivotChartFilter) */\n showPivotChartFilter?: boolean;\n /** Publish items (CT_WorkbookPr @publishItems) */\n publishItems?: boolean;\n /** Check compatibility (CT_WorkbookPr @checkCompatibility) */\n checkCompatibility?: boolean;\n /** Auto compress pictures (CT_WorkbookPr @autoCompressPictures) */\n autoCompressPictures?: boolean;\n /** Refresh all connections (CT_WorkbookPr @refreshAllConnections) */\n refreshAllConnections?: boolean;\n}\n\n/** Volatile type entry (CT_VolType) */\nexport interface VolTypeOptions {\n /** Type of volatile dependency (default: \"realTimeData\") */\n type?: \"realTimeData\" | \"olapFunctions\";\n /** Main volatile dependencies (CT_VolMain, required) */\n mains?: VolMainOptions[];\n}\n\n/** Main volatile dependency (CT_VolMain) */\nexport interface VolMainOptions {\n /** First reference (required) */\n first: string;\n /** Volatile topics (CT_VolTopic) */\n topics?: VolTopicOptions[];\n}\n\n/** Volatile topic (CT_VolTopic) */\nexport interface VolTopicOptions {\n /** Topic value (required) */\n value: string;\n /** Value type (default: \"n\") */\n valueType?: string;\n /** String topics (stp elements) */\n stringTopics?: string[];\n /** Topic references (CT_VolTopicRef) */\n refs?: VolTopicRefOptions[];\n}\n\n/** Volatile topic reference (CT_VolTopicRef) */\nexport interface VolTopicRefOptions {\n /** Cell reference (required) */\n reference: string;\n /** Sheet index (required) */\n sheetIndex: number;\n}\n\n/** Web publish object (CT_WebPublishObject) */\nexport interface WebPublishObjectOptions {\n /** Relationship ID to the published item */\n rId: string;\n /** Destination file name */\n destinationFile?: string;\n /** Auto republish (default: false) */\n autoRepublish?: boolean;\n /** Title of the published item */\n title?: string;\n /** Source object reference */\n sourceObject?: string;\n /** App name (default: \"Excel\") */\n appName?: string;\n}\n\n/** Calculation properties (CT_CalcPr) */\nexport interface CalculationPropertiesOptions {\n /** Calculation mode: \"manual\" | \"auto\" | \"autoNoTable\" */\n calcMode?: string;\n /** Calc ID (default 162913) */\n calcId?: number;\n /** Full calc on load (default false) */\n fullCalcOnLoad?: boolean;\n /** Calc on save (default true) */\n calcOnSave?: boolean;\n /** Force full calc */\n forceFullCalc?: boolean;\n /** Concurrent calc (default true) */\n concurrentCalc?: boolean;\n /** Concurrent manual count */\n concurrentManualCount?: number;\n /** Iterate (default false) */\n iterate?: boolean;\n /** Iterate count (default 100) */\n iterateCount?: number;\n /** Iterate delta (default 0.001) */\n iterateDelta?: number;\n /** Reference mode: \"A1\" | \"R1C1\" */\n refMode?: string;\n /** Full precision (default true) */\n fullPrecision?: boolean;\n /** Calc completed (CT_CalcPr @calcCompleted) */\n calcCompleted?: boolean;\n}\n\n/** Workbook view options (CT_BookView) */\nexport interface WorkbookViewOptions {\n /** Active tab index (0-based) */\n activeTab?: number;\n /** Auto filter date grouping (default true) */\n autoFilterDateGrouping?: boolean;\n /** First sheet tab */\n firstSheet?: number;\n /** Show horizontal scroll (default true) */\n showHorizontalScroll?: boolean;\n /** Show sheet tabs (default true) */\n showSheetTabs?: boolean;\n /** Show vertical scroll (default true) */\n showVerticalScroll?: boolean;\n /** Tab ratio (default 600) */\n tabRatio?: number;\n /** Window width in twips */\n windowWidth?: number;\n /** Window height in twips */\n windowHeight?: number;\n /** X position of the window */\n xWindow?: number;\n /** Y position of the window */\n yWindow?: number;\n}\n\n// ── Descriptor Types ──\n\nexport interface WorkbookDescriptorOptions {\n sheets: SheetDefinition[];\n pivotCaches?: PivotCacheReference[];\n protection?: WorkbookProtectionOptions;\n customViews?: CustomWorkbookViewOptions[];\n fileRecoveryPr?: FileRecoveryPropertiesOptions;\n functionGroups?: string[];\n webPublishing?: WebPublishingOptions;\n fileSharing?: FileSharingOptions;\n workbookPr?: WorkbookPropertiesOptions;\n calcPr?: CalculationPropertiesOptions;\n bookView?: WorkbookViewOptions;\n volTypes?: VolTypeOptions[];\n webPublishObjects?: WebPublishObjectOptions[];\n conformance?: WorkbookConformance;\n}\n\n// ── Descriptor ──\n\nexport const workbookDesc: CustomDescriptor<WorkbookDescriptorOptions> = {\n kind: \"custom\",\n\n stringify(opts, _ctx) {\n return stringifyWorkbook(opts);\n },\n\n parse(el, _ctx) {\n const result: Record<string, unknown> = {};\n\n // Sheets\n const sheetsEl = findChild(el, \"sheets\");\n if (sheetsEl) {\n const sheets: SheetDefinition[] = [];\n for (const s of sheetsEl.elements ?? []) {\n if (s.name !== \"sheet\") continue;\n const name = attr(s, \"name\") ?? \"\";\n const sheetId = attrNum(s, \"sheetId\") ?? 0;\n const rId = (s.attributes?.[\"r:id\"] as string | undefined) ?? \"\";\n const state = attr(s, \"state\") as SheetDefinition[\"state\"];\n sheets.push({ name, sheetId, rId, state });\n }\n result.sheets = sheets;\n }\n\n // Pivot caches\n const pivotCachesEl = findChild(el, \"pivotCaches\");\n if (pivotCachesEl) {\n const caches: PivotCacheReference[] = [];\n for (const pc of pivotCachesEl.elements ?? []) {\n if (pc.name !== \"pivotCache\") continue;\n caches.push({\n cacheId: attrNum(pc, \"cacheId\") ?? 0,\n rId: (pc.attributes?.[\"r:id\"] as string) ?? \"\",\n });\n }\n result.pivotCaches = caches;\n }\n\n // Workbook protection\n const protEl = findChild(el, \"workbookProtection\");\n if (protEl?.attributes) {\n const prot: Record<string, unknown> = {};\n if (attr(protEl, \"lockStructure\") === \"1\") prot.lockStructure = true;\n if (attr(protEl, \"lockWindows\") === \"1\") prot.lockWindows = true;\n if (attr(protEl, \"lockRevision\") === \"1\") prot.lockRevision = true;\n if (attr(protEl, \"workbookPassword\"))\n prot.workbookPassword = attr(protEl, \"workbookPassword\");\n if (attr(protEl, \"workbookAlgorithmName\"))\n prot.workbookAlgorithmName = attr(protEl, \"workbookAlgorithmName\");\n if (attr(protEl, \"workbookHashValue\"))\n prot.workbookHashValue = attr(protEl, \"workbookHashValue\");\n if (attr(protEl, \"workbookSaltValue\"))\n prot.workbookSaltValue = attr(protEl, \"workbookSaltValue\");\n if (attr(protEl, \"workbookSpinCount\"))\n prot.workbookSpinCount = attrNum(protEl, \"workbookSpinCount\");\n result.protection = prot;\n }\n\n // Book views\n const bookViewsEl = findChild(el, \"bookViews\");\n if (bookViewsEl) {\n const bvEl = findChild(bookViewsEl, \"workbookView\");\n if (bvEl?.attributes) {\n const bv: Record<string, unknown> = {};\n const xw = attrNum(bvEl, \"xWindow\");\n if (xw !== undefined) bv.xWindow = xw;\n const yw = attrNum(bvEl, \"yWindow\");\n if (yw !== undefined) bv.yWindow = yw;\n const ww = attrNum(bvEl, \"windowWidth\");\n if (ww !== undefined) bv.windowWidth = ww;\n const wh = attrNum(bvEl, \"windowHeight\");\n if (wh !== undefined) bv.windowHeight = wh;\n const at = attrNum(bvEl, \"activeTab\");\n if (at !== undefined) bv.activeTab = at;\n if (attr(bvEl, \"autoFilterDateGrouping\") === \"0\") bv.autoFilterDateGrouping = false;\n const fs = attrNum(bvEl, \"firstSheet\");\n if (fs !== undefined) bv.firstSheet = fs;\n if (attr(bvEl, \"showHorizontalScroll\") === \"0\") bv.showHorizontalScroll = false;\n if (attr(bvEl, \"showVerticalScroll\") === \"0\") bv.showVerticalScroll = false;\n if (attr(bvEl, \"showSheetTabs\") === \"0\") bv.showSheetTabs = false;\n const tr = attrNum(bvEl, \"tabRatio\");\n if (tr !== undefined) bv.tabRatio = tr;\n result.bookView = bv;\n }\n }\n\n // Calc properties\n const calcPrEl = findChild(el, \"calcPr\");\n if (calcPrEl?.attributes) {\n const calc: Record<string, unknown> = {};\n const calcId = attrNum(calcPrEl, \"calcId\");\n if (calcId !== undefined) calc.calcId = calcId;\n if (attr(calcPrEl, \"calcMode\")) calc.calcMode = attr(calcPrEl, \"calcMode\");\n if (attr(calcPrEl, \"fullCalcOnLoad\") === \"1\") calc.fullCalcOnLoad = true;\n if (attr(calcPrEl, \"concurrentCalc\") === \"0\") calc.concurrentCalc = false;\n if (attr(calcPrEl, \"refMode\")) calc.refMode = attr(calcPrEl, \"refMode\");\n if (attr(calcPrEl, \"calcOnSave\") === \"0\") calc.calcOnSave = false;\n if (attr(calcPrEl, \"forceFullCalc\") === \"1\") calc.forceFullCalc = true;\n const cmc = attrNum(calcPrEl, \"concurrentManualCount\");\n if (cmc !== undefined) calc.concurrentManualCount = cmc;\n if (attr(calcPrEl, \"iterate\") === \"1\") calc.iterate = true;\n const ic = attrNum(calcPrEl, \"iterateCount\");\n if (ic !== undefined) calc.iterateCount = ic;\n const id = attrNum(calcPrEl, \"iterateDelta\");\n if (id !== undefined) calc.iterateDelta = id;\n if (attr(calcPrEl, \"fullPrecision\") === \"0\") calc.fullPrecision = false;\n if (attr(calcPrEl, \"calcCompleted\") === \"1\") calc.calcCompleted = true;\n result.calcPr = calc;\n }\n\n // Custom workbook views\n const customViewsEl = findChild(el, \"customWorkbookViews\");\n if (customViewsEl) {\n const views: CustomWorkbookViewOptions[] = [];\n for (const v of customViewsEl.elements ?? []) {\n if (v.name !== \"customWorkbookView\") continue;\n const view: Record<string, unknown> = {\n name: attr(v, \"name\") ?? \"\",\n guid: attr(v, \"guid\") ?? \"\",\n windowWidth: attrNum(v, \"windowWidth\") ?? 0,\n windowHeight: attrNum(v, \"windowHeight\") ?? 0,\n activeSheetId: attrNum(v, \"activeSheetId\") ?? 1,\n };\n const xw = attrNum(v, \"xWindow\");\n if (xw !== undefined) view.xWindow = xw;\n const yw = attrNum(v, \"yWindow\");\n if (yw !== undefined) view.yWindow = yw;\n if (attr(v, \"showFormulaBar\") === \"0\") view.showFormulaBar = false;\n if (attr(v, \"showStatusbar\") === \"0\") view.showStatusbar = false;\n if (attr(v, \"showHorizontalScroll\") === \"0\") view.showHorizontalScroll = false;\n if (attr(v, \"showVerticalScroll\") === \"0\") view.showVerticalScroll = false;\n if (attr(v, \"showSheetTabs\") === \"0\") view.showSheetTabs = false;\n const tabRatio = attrNum(v, \"tabRatio\");\n if (tabRatio !== undefined) view.tabRatio = tabRatio;\n if (attr(v, \"includeHiddenRowCol\") === \"0\") view.includeHiddenRowCol = false;\n if (attr(v, \"includePrintSettings\") === \"0\") view.includePrintSettings = false;\n if (attr(v, \"personalView\") === \"1\") view.personalView = true;\n if (attr(v, \"maximized\") === \"1\") view.maximized = true;\n if (attr(v, \"minimized\") === \"1\") view.minimized = true;\n if (attr(v, \"autoUpdate\") === \"1\") view.autoUpdate = true;\n const mi = attrNum(v, \"mergeInterval\");\n if (mi !== undefined) view.mergeInterval = mi;\n if (attr(v, \"changesSavedWin\") === \"1\") view.changesSavedWin = true;\n if (attr(v, \"onlySync\") === \"1\") view.onlySync = true;\n if (attr(v, \"showComments\")) view.showComments = attr(v, \"showComments\");\n views.push(view as unknown as CustomWorkbookViewOptions);\n }\n if (views.length > 0) result.customViews = views;\n }\n\n // File sharing\n const fileSharingEl = findChild(el, \"fileSharing\");\n if (fileSharingEl?.attributes) {\n const fs: Record<string, unknown> = {};\n if (attr(fileSharingEl, \"readOnlyRecommended\") === \"1\") fs.readOnlyRecommended = true;\n if (attr(fileSharingEl, \"userName\")) fs.userName = attr(fileSharingEl, \"userName\");\n if (attr(fileSharingEl, \"reservationPassword\"))\n fs.reservationPassword = attr(fileSharingEl, \"reservationPassword\");\n if (attr(fileSharingEl, \"algorithmName\"))\n fs.algorithmName = attr(fileSharingEl, \"algorithmName\");\n if (attr(fileSharingEl, \"hashValue\")) fs.hashValue = attr(fileSharingEl, \"hashValue\");\n if (attr(fileSharingEl, \"saltValue\")) fs.saltValue = attr(fileSharingEl, \"saltValue\");\n const sc = attrNum(fileSharingEl, \"spinCount\");\n if (sc !== undefined) fs.spinCount = sc;\n result.fileSharing = fs;\n }\n\n // Web publishing\n const webPublishingEl = findChild(el, \"webPublishing\");\n if (webPublishingEl?.attributes) {\n const wp: Record<string, unknown> = {};\n if (attr(webPublishingEl, \"css\") === \"0\") wp.css = false;\n if (attr(webPublishingEl, \"thicket\") === \"0\") wp.thicket = false;\n if (attr(webPublishingEl, \"longFileNames\") === \"0\") wp.longFileNames = false;\n if (attr(webPublishingEl, \"vml\") === \"1\") wp.vml = true;\n if (attr(webPublishingEl, \"allowPng\") === \"1\") wp.allowPng = true;\n if (attr(webPublishingEl, \"targetScreenSize\"))\n wp.targetScreenSize = attr(webPublishingEl, \"targetScreenSize\");\n if (attrNum(webPublishingEl, \"dpi\") !== undefined) wp.dpi = attrNum(webPublishingEl, \"dpi\");\n if (attrNum(webPublishingEl, \"codePage\") !== undefined)\n wp.codePage = attrNum(webPublishingEl, \"codePage\");\n if (attr(webPublishingEl, \"characterSet\"))\n wp.characterSet = attr(webPublishingEl, \"characterSet\");\n result.webPublishing = wp;\n }\n\n // File recovery\n const fileRecoveryEl = findChild(el, \"fileRecoveryPr\");\n if (fileRecoveryEl?.attributes) {\n const frp: Record<string, unknown> = {};\n if (attr(fileRecoveryEl, \"autoRecover\") === \"0\") frp.autoRecover = false;\n if (attr(fileRecoveryEl, \"crashSave\") === \"1\") frp.crashSave = true;\n if (attr(fileRecoveryEl, \"dataExtractLoad\") === \"1\") frp.dataExtractLoad = true;\n if (attr(fileRecoveryEl, \"repairLoad\") === \"1\") frp.repairLoad = true;\n result.fileRecoveryPr = frp;\n }\n\n // Workbook properties\n const wbPrEl = findChild(el, \"workbookPr\");\n if (wbPrEl?.attributes) {\n const wbPr: Record<string, unknown> = {};\n if (attr(wbPrEl, \"date1904\") === \"1\") wbPr.date1904 = true;\n const dtv = attrNum(wbPrEl, \"defaultThemeVersion\");\n if (dtv !== undefined) wbPr.defaultThemeVersion = dtv;\n if (attr(wbPrEl, \"showObjects\")) wbPr.showObjects = attr(wbPrEl, \"showObjects\");\n if (attr(wbPrEl, \"hidePivotFieldList\") === \"1\") wbPr.hidePivotFieldList = true;\n if (attr(wbPrEl, \"allowRefreshQuery\") === \"1\") wbPr.allowRefreshQuery = true;\n if (attr(wbPrEl, \"filterPrivacy\") === \"1\") wbPr.filterPrivacy = true;\n if (attr(wbPrEl, \"backupFile\") === \"1\") wbPr.backupFile = true;\n if (attr(wbPrEl, \"codeName\")) wbPr.codeName = attr(wbPrEl, \"codeName\");\n if (attr(wbPrEl, \"showBorderUnselectedTables\") === \"1\")\n wbPr.showBorderUnselectedTables = true;\n if (attr(wbPrEl, \"promptedSolutions\") === \"1\") wbPr.promptedSolutions = true;\n if (attr(wbPrEl, \"showInkAnnotation\") === \"0\") wbPr.showInkAnnotation = false;\n if (attr(wbPrEl, \"saveExternalLinkValues\") === \"0\") wbPr.saveExternalLinkValues = false;\n if (attr(wbPrEl, \"updateLinks\")) wbPr.updateLinks = attr(wbPrEl, \"updateLinks\");\n if (attr(wbPrEl, \"showPivotChartFilter\") === \"1\") wbPr.showPivotChartFilter = true;\n if (attr(wbPrEl, \"publishItems\") === \"1\") wbPr.publishItems = true;\n if (attr(wbPrEl, \"checkCompatibility\") === \"1\") wbPr.checkCompatibility = true;\n if (attr(wbPrEl, \"autoCompressPictures\") === \"0\") wbPr.autoCompressPictures = false;\n if (attr(wbPrEl, \"refreshAllConnections\") === \"1\") wbPr.refreshAllConnections = true;\n result.workbookPr = wbPr;\n }\n\n // Function groups\n const fgEl = findChild(el, \"functionGroups\");\n if (fgEl) {\n const names: string[] = [];\n for (const fg of fgEl.elements ?? []) {\n if (fg.name === \"functionGroup\" && attr(fg, \"name\")) {\n names.push(attr(fg, \"name\")!);\n }\n }\n if (names.length > 0) result.functionGroups = names;\n }\n\n // Web publish objects\n const wpoEl = findChild(el, \"webPublishObjects\");\n if (wpoEl) {\n const objs: WebPublishObjectOptions[] = [];\n for (const wo of wpoEl.elements ?? []) {\n if (wo.name !== \"webPublishObject\") continue;\n const obj: Record<string, unknown> = {};\n const rId = wo.attributes?.[\"r:id\"] as string | undefined;\n if (rId) obj.rId = rId;\n if (attr(wo, \"destinationFile\")) obj.destinationFile = attr(wo, \"destinationFile\");\n if (attr(wo, \"autoRepublish\") === \"1\") obj.autoRepublish = true;\n if (attr(wo, \"title\")) obj.title = attr(wo, \"title\");\n if (attr(wo, \"sourceObject\")) obj.sourceObject = attr(wo, \"sourceObject\");\n if (attr(wo, \"appName\")) obj.appName = attr(wo, \"appName\");\n objs.push(obj as unknown as WebPublishObjectOptions);\n }\n if (objs.length > 0) result.webPublishObjects = objs;\n }\n\n // Volatile types (volTypes)\n const vtEl = findChild(el, \"volTypes\");\n if (vtEl) {\n const volTypes: VolTypeOptions[] = [];\n for (const vt of vtEl.elements ?? []) {\n if (vt.name !== \"volType\") continue;\n const volType: Record<string, unknown> = {};\n if (attr(vt, \"type\")) volType.type = attr(vt, \"type\") as VolTypeOptions[\"type\"];\n const mains: VolMainOptions[] = [];\n for (const m of vt.elements ?? []) {\n if (m.name !== \"main\") continue;\n const main: Record<string, unknown> = {};\n if (attr(m, \"first\")) main.first = attr(m, \"first\")!;\n const topics: VolTopicOptions[] = [];\n for (const tp of m.elements ?? []) {\n if (tp.name !== \"tp\") continue;\n const topic: Record<string, unknown> = {};\n const vEl = findChild(tp, \"v\");\n if (vEl) topic.value = vEl.elements?.[0]?.text ?? \"\";\n if (attr(tp, \"t\")) topic.valueType = attr(tp, \"t\");\n const stps: string[] = [];\n const refs: VolTopicRefOptions[] = [];\n for (const inner of tp.elements ?? []) {\n if (inner.name === \"stp\") stps.push(String(inner.elements?.[0]?.text ?? \"\"));\n if (inner.name === \"tr\") {\n const ref: Record<string, unknown> = {};\n if (attr(inner, \"r\")) ref.reference = attr(inner, \"r\")!;\n const sIdx = attrNum(inner, \"s\");\n if (sIdx !== undefined) ref.sheetIndex = sIdx;\n refs.push(ref as unknown as VolTopicRefOptions);\n }\n }\n if (stps.length > 0) topic.stringTopics = stps;\n if (refs.length > 0) topic.refs = refs;\n topics.push(topic as unknown as VolTopicOptions);\n }\n if (topics.length > 0) main.topics = topics;\n mains.push(main as unknown as VolMainOptions);\n }\n if (mains.length > 0) volType.mains = mains;\n volTypes.push(volType as unknown as VolTypeOptions);\n }\n if (volTypes.length > 0) result.volTypes = volTypes;\n }\n\n // Conformance\n if (el.attributes?.[\"conformance\"]) {\n result.conformance = attr(el, \"conformance\") as WorkbookConformance;\n }\n\n return result as unknown as WorkbookDescriptorOptions;\n },\n};\n\n// ── Stringify helpers ──\n\nfunction stringifyWorkbook(opts: WorkbookDescriptorOptions): string {\n const confAttr = opts.conformance ? ` conformance=\"${opts.conformance}\"` : \"\";\n const parts: string[] = [\n '<workbook xmlns=\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\"' +\n ' xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\"' +\n ' xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\"' +\n ' mc:Ignorable=\"x15 xr xr6 xr10 xr2\"' +\n ' xmlns:x15=\"http://schemas.microsoft.com/office/spreadsheetml/2010/11/main\"' +\n ' xmlns:xr=\"http://schemas.microsoft.com/office/spreadsheetml/2014/revision\"' +\n ' xmlns:xr6=\"http://schemas.microsoft.com/office/spreadsheetml/2016/revision6\"' +\n ' xmlns:xr10=\"http://schemas.microsoft.com/office/spreadsheetml/2016/revision10\"' +\n ` xmlns:xr2=\"http://schemas.microsoft.com/office/spreadsheetml/2015/revision2\"${confAttr}>`,\n '<fileVersion appName=\"xl\" lastEdited=\"7\" lowestEdited=\"6\" rupBuild=\"29929\"/>',\n ];\n\n // File sharing (after fileVersion, before workbookPr per XSD sequence)\n if (opts.fileSharing) {\n const fs = opts.fileSharing;\n const fsAttrs: string[] = [];\n if (fs.readOnlyRecommended) fsAttrs.push('readOnlyRecommended=\"1\"');\n if (fs.userName) fsAttrs.push(`userName=\"${escapeXml(fs.userName)}\"`);\n if (fs.reservationPassword) {\n fsAttrs.push(`reservationPassword=\"${escapeXml(fs.reservationPassword)}\"`);\n if (fs.hashValue === undefined) {\n const derived = derivePasswordHash(fs.reservationPassword);\n fsAttrs.push(`algorithmName=\"${escapeXml(derived.algorithmName)}\"`);\n fsAttrs.push(`hashValue=\"${escapeXml(derived.hashValue)}\"`);\n fsAttrs.push(`saltValue=\"${escapeXml(derived.saltValue)}\"`);\n fsAttrs.push(`spinCount=\"${derived.spinCount}\"`);\n }\n }\n if (fs.algorithmName) fsAttrs.push(`algorithmName=\"${escapeXml(fs.algorithmName)}\"`);\n if (fs.hashValue) fsAttrs.push(`hashValue=\"${escapeXml(fs.hashValue)}\"`);\n if (fs.saltValue) fsAttrs.push(`saltValue=\"${escapeXml(fs.saltValue)}\"`);\n if (fs.spinCount !== undefined) fsAttrs.push(`spinCount=\"${fs.spinCount}\"`);\n if (fsAttrs.length > 0) {\n parts.push(`<fileSharing ${fsAttrs.join(\" \")}/>`);\n }\n }\n\n // Workbook properties\n if (opts.workbookPr) {\n const wbPr = opts.workbookPr;\n const wbPrAttrs: string[] = [];\n if (wbPr.date1904) wbPrAttrs.push('date1904=\"1\"');\n if (wbPr.defaultThemeVersion !== undefined)\n wbPrAttrs.push(`defaultThemeVersion=\"${wbPr.defaultThemeVersion}\"`);\n if (wbPr.showObjects) wbPrAttrs.push(`showObjects=\"${escapeXml(wbPr.showObjects)}\"`);\n if (wbPr.hidePivotFieldList) wbPrAttrs.push('hidePivotFieldList=\"1\"');\n if (wbPr.allowRefreshQuery) wbPrAttrs.push('allowRefreshQuery=\"1\"');\n if (wbPr.filterPrivacy) wbPrAttrs.push('filterPrivacy=\"1\"');\n if (wbPr.backupFile) wbPrAttrs.push('backupFile=\"1\"');\n if (wbPr.codeName) wbPrAttrs.push(`codeName=\"${escapeXml(wbPr.codeName)}\"`);\n if (wbPr.showBorderUnselectedTables) wbPrAttrs.push('showBorderUnselectedTables=\"1\"');\n if (wbPr.promptedSolutions) wbPrAttrs.push('promptedSolutions=\"1\"');\n if (wbPr.showInkAnnotation === false) wbPrAttrs.push('showInkAnnotation=\"0\"');\n if (wbPr.saveExternalLinkValues === false) wbPrAttrs.push('saveExternalLinkValues=\"0\"');\n if (wbPr.updateLinks) wbPrAttrs.push(`updateLinks=\"${escapeXml(wbPr.updateLinks)}\"`);\n if (wbPr.showPivotChartFilter) wbPrAttrs.push('showPivotChartFilter=\"1\"');\n if (wbPr.publishItems) wbPrAttrs.push('publishItems=\"1\"');\n if (wbPr.checkCompatibility) wbPrAttrs.push('checkCompatibility=\"1\"');\n if (wbPr.autoCompressPictures === false) wbPrAttrs.push('autoCompressPictures=\"0\"');\n if (wbPr.refreshAllConnections) wbPrAttrs.push('refreshAllConnections=\"1\"');\n parts.push(`<workbookPr${wbPrAttrs.length > 0 ? ` ${wbPrAttrs.join(\" \")}` : \"\"}/>`);\n } else {\n parts.push(\"<workbookPr/>\");\n }\n\n // Workbook protection (after workbookPr, before bookViews per XSD sequence)\n if (opts.protection) {\n const prot = opts.protection;\n const protAttrs: string[] = [];\n if (prot.lockStructure) protAttrs.push('lockStructure=\"1\"');\n if (prot.lockWindows) protAttrs.push('lockWindows=\"1\"');\n if (prot.lockRevision) protAttrs.push('lockRevision=\"1\"');\n if (prot.workbookPassword) {\n protAttrs.push(`workbookPassword=\"${hashPassword(prot.workbookPassword)}\"`);\n if (prot.workbookHashValue === undefined) {\n const wbDerived = derivePasswordHash(prot.workbookPassword);\n protAttrs.push(`workbookAlgorithmName=\"${escapeXml(wbDerived.algorithmName)}\"`);\n protAttrs.push(`workbookHashValue=\"${escapeXml(wbDerived.hashValue)}\"`);\n protAttrs.push(`workbookSaltValue=\"${escapeXml(wbDerived.saltValue)}\"`);\n protAttrs.push(`workbookSpinCount=\"${wbDerived.spinCount}\"`);\n }\n }\n if (prot.workbookAlgorithmName)\n protAttrs.push(`workbookAlgorithmName=\"${escapeXml(prot.workbookAlgorithmName)}\"`);\n if (prot.workbookHashValue)\n protAttrs.push(`workbookHashValue=\"${escapeXml(prot.workbookHashValue)}\"`);\n if (prot.workbookSaltValue)\n protAttrs.push(`workbookSaltValue=\"${escapeXml(prot.workbookSaltValue)}\"`);\n if (prot.workbookSpinCount !== undefined)\n protAttrs.push(`workbookSpinCount=\"${prot.workbookSpinCount}\"`);\n if (prot.revisionsPassword) {\n protAttrs.push(`revisionsPassword=\"${hashPassword(prot.revisionsPassword)}\"`);\n if (prot.revisionsHashValue === undefined) {\n const revDerived = derivePasswordHash(prot.revisionsPassword);\n protAttrs.push(`revisionsAlgorithmName=\"${escapeXml(revDerived.algorithmName)}\"`);\n protAttrs.push(`revisionsHashValue=\"${escapeXml(revDerived.hashValue)}\"`);\n protAttrs.push(`revisionsSaltValue=\"${escapeXml(revDerived.saltValue)}\"`);\n protAttrs.push(`revisionsSpinCount=\"${revDerived.spinCount}\"`);\n }\n }\n if (prot.revisionsAlgorithmName)\n protAttrs.push(`revisionsAlgorithmName=\"${escapeXml(prot.revisionsAlgorithmName)}\"`);\n if (prot.revisionsHashValue)\n protAttrs.push(`revisionsHashValue=\"${escapeXml(prot.revisionsHashValue)}\"`);\n if (prot.revisionsSaltValue)\n protAttrs.push(`revisionsSaltValue=\"${escapeXml(prot.revisionsSaltValue)}\"`);\n if (prot.revisionsSpinCount !== undefined)\n protAttrs.push(`revisionsSpinCount=\"${prot.revisionsSpinCount}\"`);\n if (prot.workbookPasswordCharacterSet)\n protAttrs.push(\n `workbookPasswordCharacterSet=\"${escapeXml(prot.workbookPasswordCharacterSet)}\"`,\n );\n if (prot.revisionsPasswordCharacterSet)\n protAttrs.push(\n `revisionsPasswordCharacterSet=\"${escapeXml(prot.revisionsPasswordCharacterSet)}\"`,\n );\n if (protAttrs.length > 0) {\n parts.push(`<workbookProtection ${protAttrs.join(\" \")}/>`);\n }\n }\n\n // Book views\n if (opts.bookView) {\n const bv = opts.bookView;\n const bvAttrs: string[] = [];\n if (bv.xWindow !== undefined) bvAttrs.push(`xWindow=\"${bv.xWindow}\"`);\n else bvAttrs.push('xWindow=\"0\"');\n if (bv.yWindow !== undefined) bvAttrs.push(`yWindow=\"${bv.yWindow}\"`);\n else bvAttrs.push('yWindow=\"0\"');\n if (bv.windowWidth !== undefined) bvAttrs.push(`windowWidth=\"${bv.windowWidth}\"`);\n else bvAttrs.push('windowWidth=\"28800\"');\n if (bv.windowHeight !== undefined) bvAttrs.push(`windowHeight=\"${bv.windowHeight}\"`);\n else bvAttrs.push('windowHeight=\"12300\"');\n if (bv.activeTab !== undefined) bvAttrs.push(`activeTab=\"${bv.activeTab}\"`);\n if (bv.autoFilterDateGrouping === false) bvAttrs.push('autoFilterDateGrouping=\"0\"');\n if (bv.firstSheet !== undefined) bvAttrs.push(`firstSheet=\"${bv.firstSheet}\"`);\n if (bv.showHorizontalScroll === false) bvAttrs.push('showHorizontalScroll=\"0\"');\n if (bv.showSheetTabs === false) bvAttrs.push('showSheetTabs=\"0\"');\n if (bv.showVerticalScroll === false) bvAttrs.push('showVerticalScroll=\"0\"');\n if (bv.tabRatio !== undefined) bvAttrs.push(`tabRatio=\"${bv.tabRatio}\"`);\n parts.push(`<bookViews><workbookView ${bvAttrs.join(\" \")}/></bookViews>`);\n } else {\n parts.push(\n '<bookViews><workbookView xWindow=\"0\" yWindow=\"0\" windowWidth=\"28800\" windowHeight=\"12300\"/></bookViews>',\n );\n }\n\n parts.push(\"<sheets>\");\n for (const s of opts.sheets) {\n const stateAttr = s.state && s.state !== \"visible\" ? ` state=\"${s.state}\"` : \"\";\n parts.push(\n `<sheet name=\"${escapeXml(s.name)}\" sheetId=\"${s.sheetId}\" r:id=\"${s.rId}\"${stateAttr}/>`,\n );\n }\n parts.push(\"</sheets>\");\n\n // Function groups (after sheets, before externalReferences per XSD)\n const functionGroups = opts.functionGroups ?? [];\n if (functionGroups.length > 0) {\n const fgParts: string[] = [`<functionGroups builtInGroupCount=\"16\">`];\n for (const name of functionGroups) {\n fgParts.push(`<functionGroup name=\"${escapeXml(name)}\"/>`);\n }\n fgParts.push(\"</functionGroups>\");\n parts.push(fgParts.join(\"\"));\n }\n\n // externalReferences placeholder — compiler injects the XML here if needed\n parts.push(\"<!--EXTERNAL_REFS-->\");\n\n // Calculation properties\n if (opts.calcPr) {\n const cp = opts.calcPr;\n const cpAttrs: string[] = [];\n cpAttrs.push(`calcId=\"${cp.calcId ?? 162913}\"`);\n if (cp.calcMode) cpAttrs.push(`calcMode=\"${escapeXml(cp.calcMode)}\"`);\n if (cp.fullCalcOnLoad) cpAttrs.push('fullCalcOnLoad=\"1\"');\n if (cp.calcOnSave === false) cpAttrs.push('calcOnSave=\"0\"');\n if (cp.forceFullCalc) cpAttrs.push('forceFullCalc=\"1\"');\n if (cp.concurrentCalc === false) cpAttrs.push('concurrentCalc=\"0\"');\n if (cp.concurrentManualCount !== undefined)\n cpAttrs.push(`concurrentManualCount=\"${cp.concurrentManualCount}\"`);\n if (cp.iterate) cpAttrs.push('iterate=\"1\"');\n if (cp.iterateCount !== undefined) cpAttrs.push(`iterateCount=\"${cp.iterateCount}\"`);\n if (cp.iterateDelta !== undefined) cpAttrs.push(`iterateDelta=\"${cp.iterateDelta}\"`);\n if (cp.refMode) cpAttrs.push(`refMode=\"${escapeXml(cp.refMode)}\"`);\n if (cp.fullPrecision === false) cpAttrs.push('fullPrecision=\"0\"');\n if (cp.calcCompleted) cpAttrs.push('calcCompleted=\"1\"');\n parts.push(`<calcPr ${cpAttrs.join(\" \")}/>`);\n } else {\n parts.push('<calcPr calcId=\"162913\"/>');\n }\n\n // Custom workbook views (after calcPr, before pivotCaches per XSD)\n if (opts.customViews && opts.customViews.length > 0) {\n parts.push(\"<customWorkbookViews>\");\n for (const v of opts.customViews) {\n const vAttrs: string[] = [\n `name=\"${escapeXml(v.name)}\"`,\n `guid=\"${escapeXml(v.guid)}\"`,\n `windowWidth=\"${v.windowWidth}\"`,\n `windowHeight=\"${v.windowHeight}\"`,\n `activeSheetId=\"${v.activeSheetId}\"`,\n ];\n if (v.xWindow !== undefined) vAttrs.push(`xWindow=\"${v.xWindow}\"`);\n if (v.yWindow !== undefined) vAttrs.push(`yWindow=\"${v.yWindow}\"`);\n if (v.showFormulaBar === false) vAttrs.push('showFormulaBar=\"0\"');\n if (v.showStatusbar === false) vAttrs.push('showStatusbar=\"0\"');\n if (v.showHorizontalScroll === false) vAttrs.push('showHorizontalScroll=\"0\"');\n if (v.showVerticalScroll === false) vAttrs.push('showVerticalScroll=\"0\"');\n if (v.showSheetTabs === false) vAttrs.push('showSheetTabs=\"0\"');\n if (v.tabRatio !== undefined) vAttrs.push(`tabRatio=\"${v.tabRatio}\"`);\n if (v.includeHiddenRowCol === false) vAttrs.push('includeHiddenRowCol=\"0\"');\n if (v.includePrintSettings === false) vAttrs.push('includePrintSettings=\"0\"');\n if (v.personalView) vAttrs.push('personalView=\"1\"');\n if (v.maximized) vAttrs.push('maximized=\"1\"');\n if (v.minimized) vAttrs.push('minimized=\"1\"');\n if (v.autoUpdate) vAttrs.push('autoUpdate=\"1\"');\n if (v.mergeInterval !== undefined) vAttrs.push(`mergeInterval=\"${v.mergeInterval}\"`);\n if (v.changesSavedWin) vAttrs.push('changesSavedWin=\"1\"');\n if (v.onlySync) vAttrs.push('onlySync=\"1\"');\n if (v.showComments) vAttrs.push(`showComments=\"${escapeXml(v.showComments)}\"`);\n parts.push(`<customWorkbookView ${vAttrs.join(\" \")}/>`);\n }\n parts.push(\"</customWorkbookViews>\");\n }\n\n const pivotCaches = opts.pivotCaches ?? [];\n if (pivotCaches.length > 0) {\n parts.push(\"<pivotCaches>\");\n for (const pc of pivotCaches) {\n parts.push(`<pivotCache cacheId=\"${pc.cacheId}\" r:id=\"${pc.rId}\"/>`);\n }\n parts.push(\"</pivotCaches>\");\n }\n\n // Web publishing (after pivotCaches, before fileRecoveryPr per XSD sequence)\n if (opts.webPublishing) {\n const wp = opts.webPublishing;\n const wpAttrs: string[] = [];\n if (wp.css === false) wpAttrs.push('css=\"0\"');\n if (wp.thicket === false) wpAttrs.push('thicket=\"0\"');\n if (wp.longFileNames === false) wpAttrs.push('longFileNames=\"0\"');\n if (wp.vml) wpAttrs.push('vml=\"1\"');\n if (wp.allowPng) wpAttrs.push('allowPng=\"1\"');\n if (wp.targetScreenSize && wp.targetScreenSize !== \"800x600\")\n wpAttrs.push(`targetScreenSize=\"${wp.targetScreenSize}\"`);\n if (wp.dpi !== undefined && wp.dpi !== 96) wpAttrs.push(`dpi=\"${wp.dpi}\"`);\n if (wp.codePage !== undefined) wpAttrs.push(`codePage=\"${wp.codePage}\"`);\n if (wp.characterSet) wpAttrs.push(`characterSet=\"${escapeXml(wp.characterSet)}\"`);\n parts.push(`<webPublishing ${wpAttrs.join(\" \")}/>`);\n }\n\n // File recovery properties (after webPublishing per XSD sequence)\n if (opts.fileRecoveryPr) {\n const frp = opts.fileRecoveryPr;\n const frpAttrs: string[] = [];\n if (frp.autoRecover === false) frpAttrs.push('autoRecover=\"0\"');\n if (frp.crashSave) frpAttrs.push('crashSave=\"1\"');\n if (frp.dataExtractLoad) frpAttrs.push('dataExtractLoad=\"1\"');\n if (frp.repairLoad) frpAttrs.push('repairLoad=\"1\"');\n if (frpAttrs.length > 0) {\n parts.push(`<fileRecoveryPr ${frpAttrs.join(\" \")}/>`);\n }\n }\n\n // Web publish objects (after fileRecoveryPr per XSD sequence)\n if (opts.webPublishObjects && opts.webPublishObjects.length > 0) {\n const wpoParts: string[] = [`<webPublishObjects count=\"${opts.webPublishObjects.length}\">`];\n for (const wpo of opts.webPublishObjects) {\n const wpoAttrs: string[] = [`r:id=\"${escapeXml(wpo.rId)}\"`];\n if (wpo.destinationFile) wpoAttrs.push(`destinationFile=\"${escapeXml(wpo.destinationFile)}\"`);\n if (wpo.autoRepublish) wpoAttrs.push('autoRepublish=\"1\"');\n if (wpo.title) wpoAttrs.push(`title=\"${escapeXml(wpo.title)}\"`);\n if (wpo.sourceObject) wpoAttrs.push(`sourceObject=\"${escapeXml(wpo.sourceObject)}\"`);\n wpoParts.push(`<webPublishObject ${wpoAttrs.join(\" \")}/>`);\n }\n wpoParts.push(\"</webPublishObjects>\");\n parts.push(wpoParts.join(\"\"));\n }\n\n // Volatile dependencies (volTypes)\n if (opts.volTypes && opts.volTypes.length > 0) {\n const vtParts: string[] = [`<volTypes count=\"${opts.volTypes.length}\">`];\n for (const vt of opts.volTypes) {\n const vtType = vt.type ?? \"realTimeData\";\n const mains = vt.mains ?? [];\n if (mains.length > 0) {\n const mainParts: string[] = [];\n for (const m of mains) {\n const tpParts: string[] = [];\n for (const topic of m.topics ?? []) {\n const tpInner: string[] = [`<v>${escapeXml(topic.value)}</v>`];\n for (const stp of topic.stringTopics ?? []) {\n tpInner.push(`<stp>${escapeXml(stp)}</stp>`);\n }\n for (const tr of topic.refs ?? []) {\n tpInner.push(`<tr r=\"${escapeXml(tr.reference)}\" s=\"${tr.sheetIndex}\"/>`);\n }\n const tpAttr =\n topic.valueType && topic.valueType !== \"n\"\n ? ` t=\"${escapeXml(topic.valueType)}\"`\n : \"\";\n tpParts.push(`<tp${tpAttr}>${tpInner.join(\"\")}</tp>`);\n }\n mainParts.push(`<main first=\"${escapeXml(m.first)}\">${tpParts.join(\"\")}</main>`);\n }\n vtParts.push(`<volType type=\"${vtType}\">${mainParts.join(\"\")}</volType>`);\n } else {\n vtParts.push(`<volType type=\"${vtType}\"/>`);\n }\n }\n vtParts.push(\"</volTypes>\");\n parts.push(vtParts.join(\"\"));\n }\n\n parts.push(\"</workbook>\");\n return parts.join(\"\");\n}\n\n// ── Exported helper functions ──\n\n/** Generate tableParts XML fragment for embedding in a worksheet. */\nexport function buildTablePartsXml(tableParts: TablePartReference[]): string {\n if (tableParts.length === 0) return \"\";\n const p: string[] = [`<tableParts count=\"${tableParts.length}\">`];\n for (const tp of tableParts) {\n p.push(`<tablePart r:id=\"${tp.rId}\"/>`);\n }\n p.push(\"</tableParts>\");\n return p.join(\"\");\n}\n\n/** Generate externalReferences XML fragment for embedding in the workbook. */\nexport function buildExternalReferencesXml(refs: { rId: string }[]): string {\n if (refs.length === 0) return \"\";\n const p: string[] = [\"<externalReferences>\"];\n for (const ref of refs) {\n p.push(`<externalReference r:id=\"${ref.rId}\"/>`);\n }\n p.push(\"</externalReferences>\");\n return p.join(\"\");\n}\n\n/** Legacy Excel password hash (XOR-based) */\nfunction hashPassword(password: string): string {\n let hash = 0;\n for (let i = 0; i < password.length; i++) {\n const c = password.charCodeAt(i);\n hash = ((hash >> 14) & 1) + ((hash << 1) & 0x7fff);\n hash ^= c;\n hash = hash & 0x4000 ? hash ^ 0x1 : hash;\n }\n hash = ((hash >> 14) & 1) + ((hash << 1) & 0x7fff);\n hash = ((hash >> 14) & 1) + ((hash << 1) & 0x7fff);\n hash ^= password.length;\n return hash.toString(16).toUpperCase().padStart(4, \"0\");\n}\n","/**\n * Content Types module for XLSX packages.\n *\n * @module\n */\n\nconst XLSX_MAIN = \"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml\";\nconst XLSX_WORKSHEET = \"application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml\";\nconst XLSX_CHARTSHEET =\n \"application/vnd.openxmlformats-officedocument.spreadsheetml.chartsheet+xml\";\nconst XLSX_STYLES = \"application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml\";\nconst XLSX_SHARED_STRINGS =\n \"application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml\";\nconst XLSX_THEME = \"application/vnd.openxmlformats-officedocument.theme+xml\";\nconst XLSX_CHART = \"application/vnd.openxmlformats-officedocument.drawingml.chart+xml\";\n\ntype EntryType = \"Default\" | \"Override\";\n\ninterface ContentEntry {\n type: EntryType;\n contentType: string;\n key: string;\n}\n\nconst STATIC_ENTRIES: ContentEntry[] = [\n {\n type: \"Default\",\n contentType: \"application/vnd.openxmlformats-package.relationships+xml\",\n key: \"rels\",\n },\n { type: \"Default\", contentType: \"application/xml\", key: \"xml\" },\n { type: \"Override\", contentType: XLSX_MAIN, key: \"/xl/workbook.xml\" },\n {\n type: \"Override\",\n contentType: \"application/vnd.openxmlformats-package.core-properties+xml\",\n key: \"/docProps/core.xml\",\n },\n {\n type: \"Override\",\n contentType: \"application/vnd.openxmlformats-officedocument.extended-properties+xml\",\n key: \"/docProps/app.xml\",\n },\n];\n\n// Pre-compiled static XML fragment (module-level constant)\nconst STATIC_XML = STATIC_ENTRIES.map((e) =>\n e.type === \"Default\"\n ? `<Default ContentType=\"${e.contentType}\" Extension=\"${e.key}\"/>`\n : `<Override ContentType=\"${e.contentType}\" PartName=\"${e.key}\"/>`,\n).join(\"\");\n\nexport class ContentTypes {\n private dynamicEntries: ContentEntry[] = [];\n\n public addWorksheet(index: number): void {\n this.dynamicEntries.push({\n type: \"Override\",\n contentType: XLSX_WORKSHEET,\n key: `/xl/worksheets/sheet${index}.xml`,\n });\n }\n\n public addChartsheet(index: number): void {\n this.dynamicEntries.push({\n type: \"Override\",\n contentType: XLSX_CHARTSHEET,\n key: `/xl/chartsheets/sheet${index}.xml`,\n });\n }\n\n public addStyles(): void {\n this.dynamicEntries.push({\n type: \"Override\",\n contentType: XLSX_STYLES,\n key: \"/xl/styles.xml\",\n });\n }\n\n public addSharedStrings(): void {\n this.dynamicEntries.push({\n type: \"Override\",\n contentType: XLSX_SHARED_STRINGS,\n key: \"/xl/sharedStrings.xml\",\n });\n }\n\n public addTheme(index: number = 1): void {\n this.dynamicEntries.push({\n type: \"Override\",\n contentType: XLSX_THEME,\n key: `/xl/theme/theme${index}.xml`,\n });\n }\n\n public addChart(index: number): void {\n this.dynamicEntries.push({\n type: \"Override\",\n contentType: XLSX_CHART,\n key: `/xl/charts/chart${index}.xml`,\n });\n }\n\n public addDrawing(index: number): void {\n this.dynamicEntries.push({\n type: \"Override\",\n contentType: \"application/vnd.openxmlformats-officedocument.drawing+xml\",\n key: `/xl/drawings/drawing${index}.xml`,\n });\n }\n\n public addComments(index: number): void {\n this.dynamicEntries.push({\n type: \"Override\",\n contentType: \"application/vnd.openxmlformats-officedocument.spreadsheetml.comments+xml\",\n key: `/xl/comments${index}.xml`,\n });\n }\n\n public addVmlDrawing(): void {\n if (this.dynamicEntries.some((e) => e.type === \"Default\" && e.key === \"vml\")) return;\n this.dynamicEntries.push({\n type: \"Default\",\n contentType: \"application/vnd.openxmlformats-officedocument.vmlDrawing\",\n key: \"vml\",\n });\n }\n\n public addImageType(extension: \"png\" | \"jpeg\"): void {\n const contentType = extension === \"png\" ? \"image/png\" : \"image/jpeg\";\n if (this.dynamicEntries.some((e) => e.type === \"Default\" && e.key === extension)) return;\n this.dynamicEntries.push({ type: \"Default\", contentType, key: extension });\n }\n\n public addPivotTable(index: number): void {\n this.dynamicEntries.push({\n type: \"Override\",\n contentType: \"application/vnd.openxmlformats-officedocument.spreadsheetml.pivotTable+xml\",\n key: `/xl/pivotTables/pivotTable${index}.xml`,\n });\n }\n\n public addPivotCacheDefinition(index: number): void {\n this.dynamicEntries.push({\n type: \"Override\",\n contentType:\n \"application/vnd.openxmlformats-officedocument.spreadsheetml.pivotCacheDefinition+xml\",\n key: `/xl/pivotCache/pivotCacheDefinition${index}.xml`,\n });\n }\n\n public addPivotCacheRecords(index: number): void {\n this.dynamicEntries.push({\n type: \"Override\",\n contentType:\n \"application/vnd.openxmlformats-officedocument.spreadsheetml.pivotCacheRecords+xml\",\n key: `/xl/pivotCache/pivotCacheRecords${index}.xml`,\n });\n }\n\n public addTable(index: number): void {\n this.dynamicEntries.push({\n type: \"Override\",\n contentType: \"application/vnd.openxmlformats-officedocument.spreadsheetml.table+xml\",\n key: `/xl/tables/table${index}.xml`,\n });\n }\n\n public addExternalLink(index: number): void {\n this.dynamicEntries.push({\n type: \"Override\",\n contentType: \"application/vnd.openxmlformats-officedocument.spreadsheetml.externalLink+xml\",\n key: `/xl/externalLinks/externalLink${index}.xml`,\n });\n }\n\n public addCalcChain(): void {\n this.dynamicEntries.push({\n type: \"Override\",\n contentType: \"application/vnd.openxmlformats-officedocument.spreadsheetml.calcChain+xml\",\n key: \"/xl/calcChain.xml\",\n });\n }\n\n public addDialogsheet(index: number): void {\n this.dynamicEntries.push({\n type: \"Override\",\n contentType: \"application/vnd.openxmlformats-officedocument.spreadsheetml.dialogsheet+xml\",\n key: `/xl/dialogsheets/sheet${index}.xml`,\n });\n }\n\n public addRevisionHeaders(): void {\n this.dynamicEntries.push({\n type: \"Override\",\n contentType:\n \"application/vnd.openxmlformats-officedocument.spreadsheetml.revisionHeaders+xml\",\n key: \"/xl/revisionHeaders.xml\",\n });\n }\n\n public addRevisionLog(index: number): void {\n this.dynamicEntries.push({\n type: \"Override\",\n contentType: \"application/vnd.openxmlformats-officedocument.spreadsheetml.revisionLog+xml\",\n key: `/xl/revisions/revision${index}.xml`,\n });\n }\n\n public addQueryTable(index: number): void {\n this.dynamicEntries.push({\n type: \"Override\",\n contentType: \"application/vnd.openxmlformats-officedocument.spreadsheetml.queryTable+xml\",\n key: `/xl/queryTables/queryTable${index}.xml`,\n });\n }\n\n public addMetadata(): void {\n this.dynamicEntries.push({\n type: \"Override\",\n contentType: \"application/vnd.openxmlformats-officedocument.spreadsheetml.sheetMetadata+xml\",\n key: \"/xl/metadata.xml\",\n });\n }\n\n public serialize(): string {\n const p: string[] = [\n '<Types xmlns=\"http://schemas.openxmlformats.org/package/2006/content-types\">',\n STATIC_XML,\n ];\n for (const e of this.dynamicEntries) {\n if (e.type === \"Default\") {\n p.push(`<Default ContentType=\"${e.contentType}\" Extension=\"${e.key}\"/>`);\n } else {\n p.push(`<Override ContentType=\"${e.contentType}\" PartName=\"${e.key}\"/>`);\n }\n }\n p.push(\"</Types>\");\n return p.join(\"\");\n }\n}\n","/**\n * Media collection for XLSX files — stores image binary data.\n *\n * @module\n */\n\nexport interface MediaData {\n fileName: string;\n type: string;\n data: Uint8Array;\n width: number;\n height: number;\n}\n\nexport class Media {\n private map = new Map<string, MediaData>();\n\n public addImage(key: string, data: MediaData): void {\n this.map.set(key, data);\n }\n\n public get array(): MediaData[] {\n return [...this.map.values()];\n }\n}\n","/**\n * XLSX compile context — write and read contexts for the descriptor pipeline.\n *\n * @module\n */\n\nimport { ChartCollection, Relationships, type RelationshipType } from \"@office-open/core\";\nimport type { ReadContext, WriteContext } from \"@office-open/core/descriptor\";\nimport type { Element } from \"@office-open/xml\";\nimport { ContentTypes } from \"@parts/content-types\";\nimport { Media } from \"@parts/media\";\nimport { SharedStrings } from \"@parts/shared-strings\";\nimport { Styles } from \"@parts/styles\";\nimport type { DxfOptions, StyleOptions, StylesParseResult } from \"@parts/styles\";\nimport type { PivotCacheReference } from \"@parts/workbook\";\n\nimport type { XlsxDocument } from \"./parse\";\n\n// ── Write Context ──\n\n/**\n * XLSX-specific write context.\n *\n * Holds mutable state that accumulates during the compile phase:\n * shared strings, styles, media, charts, content types, and relationships.\n */\nexport class XlsxWriteContext implements WriteContext {\n sharedStrings = new SharedStrings();\n styles = new Styles();\n media = new Media();\n charts = new ChartCollection();\n contentTypes = new ContentTypes();\n workbookRels = new Relationships();\n pivotCacheRefs: PivotCacheReference[] = [];\n\n // ── WriteContext stubs (core interface) ──\n\n public addRelationship(type: RelationshipType, target: string, _mode?: string): string {\n const id = this.workbookRels.relationshipCount + 1;\n this.workbookRels.addRelationship(id, type, target);\n return `rId${id}`;\n }\n\n public addMedia(_data: Uint8Array, _type: string): string {\n // Stub — XLSX media registration goes through Media.addImage() in compiler.\n return \"\";\n }\n\n /**\n * Register a differential format and return its dxfId.\n */\n public registerDxf(opts: DxfOptions): number {\n return this.styles.registerDxf(opts);\n }\n}\n\n// ── Read Context ──\n\n/**\n * XLSX-specific read context.\n *\n * Wraps an {@link XlsxDocument} to implement the core {@link ReadContext}\n * interface used by the descriptor parse pipeline.\n */\nexport class XlsxReadContext implements ReadContext {\n /** Parsed shared strings for resolving cell values. */\n public readonly sharedStrings: string[];\n /** Parsed styles (fonts, fills, borders, cellXfs). Set by parseWorkbook(). */\n public parsedStyles?: StylesParseResult;\n\n constructor(\n private xlsx: XlsxDocument,\n sharedStrings?: string[],\n ) {\n this.sharedStrings = sharedStrings ?? [];\n }\n\n public resolveRelationship(rId: string): string | undefined {\n const wbRels = this.xlsx.doc.get(\"xl/_rels/workbook.xml.rels\");\n if (!wbRels?.elements) return undefined;\n for (const child of wbRels.elements) {\n if (child.name !== \"Relationship\") continue;\n if (child.attributes?.[\"Id\"] === rId) {\n const target = child.attributes[\"Target\"] as string | undefined;\n if (!target) return undefined;\n return target.startsWith(\"/\") ? target.slice(1) : `xl/${target}`;\n }\n }\n return undefined;\n }\n\n /**\n * Resolve a relationship rId from a worksheet-level rels file.\n * Worksheet rels paths: `xl/worksheets/sheet1.xml` → `xl/worksheets/_rels/sheet1.xml.rels`\n */\n public resolveWorksheetRel(wsPath: string, rId: string): string | undefined {\n const relsPath = wsPathToRelsPath(wsPath);\n const rels = this.xlsx.doc.get(relsPath);\n if (!rels?.elements) return undefined;\n for (const child of rels.elements) {\n if (child.name !== \"Relationship\") continue;\n if (child.attributes?.[\"Id\"] === rId) {\n const target = child.attributes[\"Target\"] as string | undefined;\n if (!target) return undefined;\n return resolveWsTarget(wsPath, target);\n }\n }\n return undefined;\n }\n\n /**\n * Get all relationships from a worksheet rels file matching a type fragment.\n * e.g. `getWorksheetRelsByType(path, \"/comments\")` returns all comment relationships.\n */\n public getWorksheetRelsByType(\n wsPath: string,\n typeFragment: string,\n ): Array<{ rId: string; target: string }> {\n const relsPath = wsPathToRelsPath(wsPath);\n const rels = this.xlsx.doc.get(relsPath);\n if (!rels?.elements) return [];\n const result: Array<{ rId: string; target: string }> = [];\n for (const child of rels.elements) {\n if (child.name !== \"Relationship\") continue;\n const type = child.attributes?.[\"Type\"] as string | undefined;\n if (!type || !type.includes(typeFragment)) continue;\n const rId = child.attributes?.[\"Id\"] as string | undefined;\n const target = child.attributes?.[\"Target\"] as string | undefined;\n if (rId && target) {\n result.push({ rId, target: resolveWsTarget(wsPath, target) });\n }\n }\n return result;\n }\n\n public getPart(path: string): Element | undefined {\n return this.xlsx.doc.get(path);\n }\n\n public getRaw(path: string): Uint8Array | undefined {\n return this.xlsx.doc.getRaw(path);\n }\n\n /**\n * Resolve a cell style index to a StyleOptions object by looking up\n * the parsed cellXfs table and substituting font/fill/border/numFmt indices\n * with their resolved values.\n */\n public resolveStyle(styleIndex: number): StyleOptions | undefined {\n const ps = this.parsedStyles;\n if (!ps) return undefined;\n const { cellXfs, fonts, fills, borders, customNumFmts } = ps;\n if (!cellXfs || styleIndex >= cellXfs.length) return undefined;\n const xf = cellXfs[styleIndex];\n const result: StyleOptions = {};\n\n const fontId = xf.fontId;\n if (fontId !== undefined && fonts && fontId < fonts.length) result.font = fonts[fontId];\n const fillId = xf.fillId;\n if (fillId !== undefined && fills && fillId < fills.length) result.fill = fills[fillId];\n const borderId = xf.borderId;\n if (borderId !== undefined && borders && borderId < borders.length)\n result.border = borders[borderId];\n const numFmtId = xf.numFmtId;\n if (numFmtId !== undefined && customNumFmts) {\n for (const [code, id] of Object.entries(customNumFmts)) {\n if (id === numFmtId) {\n result.numFmt = code;\n break;\n }\n }\n }\n if (xf.alignment) result.alignment = xf.alignment;\n if (xf.protection) result.protection = xf.protection;\n if (xf.quotePrefix) result.quotePrefix = xf.quotePrefix;\n if (xf.pivotButton) result.pivotButton = xf.pivotButton;\n\n return result as StyleOptions;\n }\n}\n\n// ── Worksheet rels helpers ──\n\n/** Derive rels path from worksheet path. */\nfunction wsPathToRelsPath(wsPath: string): string {\n // \"xl/worksheets/sheet1.xml\" → \"xl/worksheets/_rels/sheet1.xml.rels\"\n const idx = wsPath.lastIndexOf(\"/\");\n const dir = wsPath.substring(0, idx);\n const file = wsPath.substring(idx + 1);\n return `${dir}/_rels/${file}.rels`;\n}\n\n/** Resolve a relative target from a worksheet rels file to an absolute archive path. */\nfunction resolveWsTarget(wsPath: string, target: string): string {\n if (target.startsWith(\"/\")) return target.slice(1);\n // Target is relative to the worksheet's directory, e.g. \"../comments1.xml\" from \"xl/worksheets/\"\n const wsDir = wsPath.substring(0, wsPath.lastIndexOf(\"/\"));\n const parts = target.split(\"/\");\n const dirParts = wsDir.split(\"/\");\n for (const part of parts) {\n if (part === \"..\") {\n dirParts.pop();\n } else {\n dirParts.push(part);\n }\n }\n return dirParts.join(\"/\");\n}\n"],"mappings":";;;;;;;AAqBA,SAAgB,YACd,IACQ;CACR,IAAI,CAAC,IAAI,OAAO;CAChB,MAAM,QAAkB,CAAC;CACzB,IAAI,GAAG,MAAM,MAAM,KAAK,eAAe,UAAU,GAAG,IAAI,EAAE,IAAI;CAC9D,IAAI,GAAG,YAAY,KAAA,GAAW,MAAM,KAAK,iBAAiB,GAAG,QAAQ,IAAI;CACzE,IAAI,GAAG,WAAW,KAAA,GAAW,MAAM,KAAK,gBAAgB,GAAG,OAAO,IAAI;CACtE,IAAI,GAAG,MAAM,MAAM,KAAK,MAAM;CAC9B,IAAI,GA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