{"version":3,"file":"load-BG5-CtPk.mjs","names":[],"sources":["../src/styles/stylesheet-reader.ts","../src/io/load.ts"],"sourcesContent":["// xl/styles.xml → Stylesheet reader.\n//\n// The reader preserves slot ordering exactly — cellXfs[3] in the source xlsx\n// must come back as cellXfs[3] in the loaded Workbook because every `<c s=\"3\">`\n// reference depends on the index, not on the value's identity. That rules out\n// the `addFont` / `addCellXf` dedup helpers (which collapse equal values);\n// instead we push raw entries and rebuild the `_*IdByKey` maps at the end so\n// subsequent edits go back through dedup.\n\nimport { fromTree } from '../schema/serialize';\nimport { OpenXmlSchemaError } from '../utils/exceptions';\nimport { stableStringify } from '../utils/stable-stringify';\nimport { qname, SHEET_MAIN_NS } from '../xml/namespaces';\nimport { parseXml } from '../xml/parser';\nimport { findChild, findChildren, type XmlNode } from '../xml/tree';\nimport { AlignmentSchema } from './alignment.schema';\nimport type { Border } from './borders';\nimport { BorderSchema } from './borders.schema';\nimport type { DifferentialStyle, StylesheetWithDxfs } from './differential';\nimport type { Fill } from './fills';\nimport { fillFromTree } from './fills.schema';\nimport type { Font } from './fonts';\nimport { FontSchema } from './fonts.schema';\nimport type { StylesheetNamedStyle } from './named-styles';\nimport type { NumberFormat } from './numbers';\nimport { NumberFormatSchema } from './numbers.schema';\nimport { ProtectionSchema } from './protection.schema';\nimport { type CellXf, makeStylesheet, type Stylesheet } from './stylesheet';\n\nconst STYLESHEET_TAG = qname(SHEET_MAIN_NS, 'styleSheet');\nconst FONTS_TAG = qname(SHEET_MAIN_NS, 'fonts');\nconst FILLS_TAG = qname(SHEET_MAIN_NS, 'fills');\nconst BORDERS_TAG = qname(SHEET_MAIN_NS, 'borders');\nconst NUMFMTS_TAG = qname(SHEET_MAIN_NS, 'numFmts');\nconst NUMFMT_TAG = qname(SHEET_MAIN_NS, 'numFmt');\nconst CELLXFS_TAG = qname(SHEET_MAIN_NS, 'cellXfs');\nconst CELLSTYLEXFS_TAG = qname(SHEET_MAIN_NS, 'cellStyleXfs');\nconst CELLSTYLES_TAG = qname(SHEET_MAIN_NS, 'cellStyles');\nconst CELLSTYLE_TAG = qname(SHEET_MAIN_NS, 'cellStyle');\nconst DXFS_TAG = qname(SHEET_MAIN_NS, 'dxfs');\nconst DXF_TAG = qname(SHEET_MAIN_NS, 'dxf');\nconst XF_TAG = qname(SHEET_MAIN_NS, 'xf');\nconst FONT_TAG = qname(SHEET_MAIN_NS, 'font');\nconst FILL_TAG = qname(SHEET_MAIN_NS, 'fill');\nconst BORDER_TAG = qname(SHEET_MAIN_NS, 'border');\nconst NUMFMT_INNER_TAG = qname(SHEET_MAIN_NS, 'numFmt');\nconst ALIGNMENT_TAG = qname(SHEET_MAIN_NS, 'alignment');\nconst PROTECTION_TAG = qname(SHEET_MAIN_NS, 'protection');\n\n/**\n * Parse `xl/styles.xml` and return a fully-populated {@link Stylesheet}. Slot\n * ordering is preserved verbatim; the dedup index Maps are rebuilt after the\n * fact so future `addFont` / `addCellXf` calls keep working.\n */\nexport function parseStylesheetXml(bytes: Uint8Array | string): Stylesheet {\n  const root = parseXml(bytes);\n  if (root.name !== STYLESHEET_TAG) {\n    throw new OpenXmlSchemaError(`parseStylesheetXml: root is \"${root.name}\", expected styleSheet`);\n  }\n\n  // Start from a Stylesheet whose default-pool entries we'll wholesale replace\n  // with the XML's actual contents.\n  const ss = makeStylesheet();\n  ss.fonts.length = 0;\n  ss.fills.length = 0;\n  ss.borders.length = 0;\n\n  for (const fontEl of findInSection(root, FONTS_TAG, FONT_TAG)) {\n    ss.fonts.push(fromTree(fontEl, FontSchema));\n  }\n  for (const fillEl of findInSection(root, FILLS_TAG, FILL_TAG)) {\n    ss.fills.push(fillFromTree(fillEl));\n  }\n  for (const borderEl of findInSection(root, BORDERS_TAG, BORDER_TAG)) {\n    ss.borders.push(fromTree(borderEl, BorderSchema));\n  }\n\n  // numFmts is a Map<id, code>; id is on the element so a sparse Map works.\n  for (const numFmtEl of findInSection(root, NUMFMTS_TAG, NUMFMT_TAG)) {\n    const nf = parseNumFmt(numFmtEl);\n    ss.numFmts.set(nf.numFmtId, nf.formatCode);\n  }\n\n  for (const xfEl of findInSection(root, CELLSTYLEXFS_TAG, XF_TAG)) {\n    ss.cellStyleXfs.push(parseCellXf(xfEl));\n  }\n  for (const xfEl of findInSection(root, CELLXFS_TAG, XF_TAG)) {\n    ss.cellXfs.push(parseCellXf(xfEl));\n  }\n\n  // cellStyles → ss.namedStyles\n  const cellStylesEl = findChild(root, CELLSTYLES_TAG);\n  if (cellStylesEl) {\n    const named: StylesheetNamedStyle[] = [];\n    for (const cs of findChildren(cellStylesEl, CELLSTYLE_TAG)) {\n      const name = cs.attrs['name'];\n      const xfId = parseIntAttr(cs.attrs['xfId'], 'xfId');\n      if (name === undefined || xfId === undefined) continue;\n      const entry: StylesheetNamedStyle = {\n        name,\n        xfId,\n        ...(cs.attrs['builtinId'] !== undefined ? { builtinId: parseIntAttr(cs.attrs['builtinId'], 'builtinId') ?? 0 } : {}),\n        ...(cs.attrs['iLevel'] !== undefined ? { iLevel: parseIntAttr(cs.attrs['iLevel'], 'iLevel') ?? 0 } : {}),\n        ...(parseBoolAttr(cs.attrs['hidden']) === true ? { hidden: true } : {}),\n        ...(parseBoolAttr(cs.attrs['customBuiltin']) === true ? { customBuiltin: true } : {}),\n      };\n      named.push(entry);\n    }\n    if (named.length > 0) {\n      ss.namedStyles = named;\n      ss._namedStyleByName = new Map(named.map((n) => [n.name, n]));\n    }\n  }\n\n  // dxfs → ss.dxfs\n  const dxfsEl = findChild(root, DXFS_TAG);\n  if (dxfsEl) {\n    const dxfs: DifferentialStyle[] = [];\n    for (const dxfEl of findChildren(dxfsEl, DXF_TAG)) {\n      const fontEl = findChild(dxfEl, FONT_TAG);\n      const numFmtEl = findChild(dxfEl, NUMFMT_INNER_TAG);\n      const fillEl = findChild(dxfEl, FILL_TAG);\n      const alignmentEl = findChild(dxfEl, ALIGNMENT_TAG);\n      const borderEl = findChild(dxfEl, BORDER_TAG);\n      const protectionEl = findChild(dxfEl, PROTECTION_TAG);\n      const dxf: DifferentialStyle = {\n        ...(fontEl ? { font: fromTree(fontEl, FontSchema) } : {}),\n        ...(numFmtEl ? { numFmt: fromTree(numFmtEl, NumberFormatSchema) } : {}),\n        ...(fillEl ? { fill: fillFromTree(fillEl) } : {}),\n        ...(alignmentEl ? { alignment: fromTree(alignmentEl, AlignmentSchema) } : {}),\n        ...(borderEl ? { border: fromTree(borderEl, BorderSchema) } : {}),\n        ...(protectionEl ? { protection: fromTree(protectionEl, ProtectionSchema) } : {}),\n      };\n      dxfs.push(Object.freeze(dxf));\n    }\n    if (dxfs.length > 0) {\n      const w = ss as StylesheetWithDxfs;\n      w.dxfs = dxfs;\n      w._dxfIdByKey = new Map(dxfs.map((d, i) => [stableStringify(d), i]));\n    }\n  }\n\n  rebuildIndexes(ss);\n  return ss;\n}\n\n/** Drill from `<styleSheet>` into a numbered section and yield every matching child. */\nfunction findInSection(root: XmlNode, sectionTag: string, itemTag: string): XmlNode[] {\n  const section = findChild(root, sectionTag);\n  if (!section) return [];\n  return findChildren(section, itemTag);\n}\n\nconst parseNumFmt = (node: XmlNode): NumberFormat => {\n  const idAttr = node.attrs['numFmtId'];\n  const code = node.attrs['formatCode'];\n  if (idAttr === undefined) {\n    throw new OpenXmlSchemaError('styles: <numFmt> missing @numFmtId');\n  }\n  if (code === undefined) {\n    throw new OpenXmlSchemaError(`styles: <numFmt numFmtId=\"${idAttr}\"> missing @formatCode`);\n  }\n  const numFmtId = Number.parseInt(idAttr, 10);\n  if (!Number.isInteger(numFmtId) || numFmtId < 0) {\n    throw new OpenXmlSchemaError(`styles: <numFmt numFmtId=\"${idAttr}\"> is not a non-negative integer`);\n  }\n  return { numFmtId, formatCode: code };\n};\n\nconst parseIntAttr = (raw: string | undefined, label: string): number | undefined => {\n  if (raw === undefined) return undefined;\n  const n = Number.parseInt(raw, 10);\n  if (!Number.isInteger(n) || n < 0) {\n    throw new OpenXmlSchemaError(`styles: <xf ${label}=\"${raw}\"> is not a non-negative integer`);\n  }\n  return n;\n};\n\nconst parseBoolAttr = (raw: string | undefined): boolean | undefined => {\n  if (raw === undefined) return undefined;\n  if (raw === '1' || raw === 'true') return true;\n  if (raw === '0' || raw === 'false') return false;\n  return undefined;\n};\n\nconst parseCellXf = (node: XmlNode): CellXf => {\n  const fontId = parseIntAttr(node.attrs['fontId'], 'fontId') ?? 0;\n  const fillId = parseIntAttr(node.attrs['fillId'], 'fillId') ?? 0;\n  const borderId = parseIntAttr(node.attrs['borderId'], 'borderId') ?? 0;\n  const numFmtId = parseIntAttr(node.attrs['numFmtId'], 'numFmtId') ?? 0;\n  const xfId = parseIntAttr(node.attrs['xfId'], 'xfId');\n\n  const applyFont = parseBoolAttr(node.attrs['applyFont']);\n  const applyFill = parseBoolAttr(node.attrs['applyFill']);\n  const applyBorder = parseBoolAttr(node.attrs['applyBorder']);\n  const applyNumberFormat = parseBoolAttr(node.attrs['applyNumberFormat']);\n  const applyAlignment = parseBoolAttr(node.attrs['applyAlignment']);\n  const applyProtection = parseBoolAttr(node.attrs['applyProtection']);\n  const pivotButton = parseBoolAttr(node.attrs['pivotButton']);\n  const quotePrefix = parseBoolAttr(node.attrs['quotePrefix']);\n\n  const alignmentEl = findChild(node, ALIGNMENT_TAG);\n  const protectionEl = findChild(node, PROTECTION_TAG);\n\n  return {\n    fontId,\n    fillId,\n    borderId,\n    numFmtId,\n    ...(xfId !== undefined ? { xfId } : {}),\n    ...(alignmentEl ? { alignment: fromTree(alignmentEl, AlignmentSchema) } : {}),\n    ...(protectionEl ? { protection: fromTree(protectionEl, ProtectionSchema) } : {}),\n    ...(applyFont !== undefined ? { applyFont } : {}),\n    ...(applyFill !== undefined ? { applyFill } : {}),\n    ...(applyBorder !== undefined ? { applyBorder } : {}),\n    ...(applyNumberFormat !== undefined ? { applyNumberFormat } : {}),\n    ...(applyAlignment !== undefined ? { applyAlignment } : {}),\n    ...(applyProtection !== undefined ? { applyProtection } : {}),\n    ...(pivotButton !== undefined ? { pivotButton } : {}),\n    ...(quotePrefix !== undefined ? { quotePrefix } : {}),\n  };\n};\n\n/** Repopulate the `_*IdByKey` maps from the freshly-loaded pool entries. */\nfunction rebuildIndexes(ss: Stylesheet): void {\n  ss._fontIdByKey = buildKeyIndex<Font>(ss.fonts);\n  ss._fillIdByKey = buildKeyIndex<Fill>(ss.fills);\n  ss._borderIdByKey = buildKeyIndex<Border>(ss.borders);\n  ss._xfIdByKey = buildKeyIndex<CellXf>(ss.cellXfs);\n  ss._styleXfIdByKey = buildKeyIndex<CellXf>(ss.cellStyleXfs);\n  ss._numFmtIdByCode = new Map();\n  for (const [id, code] of ss.numFmts) ss._numFmtIdByCode.set(code, id);\n}\n\nconst buildKeyIndex = <T>(arr: ReadonlyArray<T>): Map<string, number> => {\n  const m = new Map<string, number>();\n  for (let i = 0; i < arr.length; i++) {\n    const key = stableStringify(arr[i] as T);\n    if (!m.has(key)) m.set(key, i);\n  }\n  return m;\n};\n","// Public `loadWorkbook` entry point.\n//\n// **This is the minimum-skeleton stage**: open zip → parse manifest → resolve\n// workbook part path → parse the `<sheets>` list → for each sheet, allocate an\n// empty Worksheet (title + sheetId + state). Reading the actual cell content /\n// styles / sharedStrings / theme / docProps happens in the next iterations of\n// the loop.\n//\n// The skeleton is enough to round-trip through openpyxl's `genuine/empty.xlsx`\n// fixture (3 empty sheets) and to give the rest of phase 3 a stable scaffolding\n// to layer onto.\n\nimport { findUserShapesRId, parseChartXml } from '../chart/chart-xml';\nimport { isChartExBytes, parseChartExXml } from '../chart/cx/chartex-xml';\nimport { parseUserShapesXml } from '../chart/user-shapes-xml';\nimport { parseChartsheetXml } from '../chartsheet/chartsheet-xml';\nimport { parseDrawingXml } from '../drawing/drawing-xml';\nimport { loadImage } from '../drawing/image';\nimport type { XlsxSource } from '../io/source';\nimport { corePropsFromBytes } from '../packaging/core';\nimport { customPropsFromBytes } from '../packaging/custom';\nimport { extendedPropsFromBytes } from '../packaging/extended';\nimport { manifestFromBytes } from '../packaging/manifest';\nimport { findById, indexRelsById, relsFromBytes } from '../packaging/relationships';\nimport { parseStylesheetXml } from '../styles/stylesheet-reader';\nimport { OpenXmlSchemaError } from '../utils/exceptions';\nimport type { DefinedName } from '../workbook/defined-names';\nimport { makeDefinedName } from '../workbook/defined-names';\nimport { parseSharedStringsXml, type SharedStringsTable } from '../workbook/shared-strings';\nimport { createWorkbook, type SheetRef, type SheetState, type Workbook } from '../workbook/workbook';\nimport { parseCommentsXml } from '../worksheet/comments-xml';\nimport { parseWorksheetXml } from '../worksheet/reader';\nimport { parseTableXml } from '../worksheet/table-xml';\nimport {\n  ARC_APP,\n  ARC_CONTENT_TYPES,\n  ARC_CORE,\n  ARC_CUSTOM,\n  ARC_ROOT_RELS,\n  ARC_SHARED_STRINGS,\n  ARC_STYLE,\n  ARC_THEME,\n  ARC_WORKBOOK,\n  parseQName,\n  REL_NS,\n  SHEET_MAIN_NS,\n} from '../xml/namespaces';\nimport { parseXml } from '../xml/parser';\nimport { findChild, findChildren, type XmlNode } from '../xml/tree';\nimport type { DecompressionLimits } from '../zip/decompression-guard';\nimport { openZip, type ZipArchive } from '../zip/reader';\n\n/**\n * Options for {@link loadWorkbook}. Earlier drafts exposed `readOnly` /\n * `keepLinks` / `keepVba` / `dataOnly` / `richText` placeholders that the\n * loader silently ignored; those were removed to keep the surface honest.\n * Future toggles land here once their behavior is implemented.\n */\nexport interface LoadOptions {\n  /**\n   * Decompression-bomb safeguards applied while inflating zip entries.\n   * Defaults to limits that fit any legitimate xlsx; pass `false` to disable\n   * (only safe for fully trusted sources). See\n   * {@link DecompressionLimits} for the individual knobs.\n   */\n  decompressionLimits?: DecompressionLimits | false;\n}\n\n/** Office Document relationship type — the package-root pointer to `xl/workbook.xml`. */\nconst OFFICE_DOC_REL_TYPE = `${REL_NS}/officeDocument`;\n\n/**\n * Resolve an OPC relationship target against its source part path.\n *\n * - Targets starting with `/` are package-absolute.\n * - Otherwise the target is relative to the source part's parent directory.\n * - `..` segments collapse normally.\n */\nexport function resolveRelTarget(sourcePartPath: string, target: string): string {\n  if (target.startsWith('/')) return target.slice(1);\n  const lastSlash = sourcePartPath.lastIndexOf('/');\n  const parentDir = lastSlash >= 0 ? sourcePartPath.slice(0, lastSlash + 1) : '';\n  const joined = parentDir + target;\n  return normalizePath(joined);\n}\n\nfunction normalizePath(path: string): string {\n  const segments = path.split('/');\n  const out: string[] = [];\n  for (const seg of segments) {\n    if (seg === '' || seg === '.') continue;\n    if (seg === '..') {\n      // Pop the last accumulated segment when one exists; when `out` is\n      // empty (a relative target with more `..` than ancestors) the pop is\n      // a no-op so the climb is silently absorbed at the package root. The\n      // archive.has() check on the resolved path catches any escape attempt\n      // because the entry simply won't exist outside the package — there's\n      // no filesystem traversal to worry about, only a missing-entry error.\n      out.pop();\n      continue;\n    }\n    out.push(seg);\n  }\n  return out.join('/');\n}\n\n/** Sibling rels-part path for a given part. `xl/workbook.xml` → `xl/_rels/workbook.xml.rels`. */\nfunction relsPathFor(partPath: string): string {\n  const i = partPath.lastIndexOf('/');\n  if (i < 0) return `_rels/${partPath}.rels`;\n  return `${partPath.slice(0, i)}/_rels/${partPath.slice(i + 1)}.rels`;\n}\n\ninterface SheetEntry {\n  /** Display name (`sheet/@name`). */\n  name: string;\n  /** Workbook-scope sheetId (`sheet/@sheetId`). */\n  sheetId: number;\n  /** Workbook rels Id (`sheet/@r:id`). */\n  rId: string;\n  /** Visibility state — defaults to `'visible'` when the attribute is absent. */\n  state: SheetState;\n}\n\nconst SHEET_TAG = `{${SHEET_MAIN_NS}}sheet`;\nconst SHEETS_TAG = `{${SHEET_MAIN_NS}}sheets`;\nconst DEFINED_NAMES_TAG = `{${SHEET_MAIN_NS}}definedNames`;\nconst DEFINED_NAME_TAG = `{${SHEET_MAIN_NS}}definedName`;\nconst RID_ATTR = `{${REL_NS}}id`;\n\n/** Extract the `<definedNames>/<definedName>` entries from a parsed `xl/workbook.xml`. */\nfunction parseDefinedNames(workbookRoot: XmlNode): DefinedName[] {\n  const wrapper = findChild(workbookRoot, DEFINED_NAMES_TAG);\n  if (!wrapper) return [];\n  const out: DefinedName[] = [];\n  for (const node of findChildren(wrapper, DEFINED_NAME_TAG)) {\n    const name = node.attrs['name'];\n    if (!name) throw new OpenXmlSchemaError(\"workbook.xml: <definedName> is missing 'name'\");\n    const value = node.text ?? '';\n    const opts: Partial<DefinedName> & { name: string; value: string } = { name, value };\n    const scopeAttr = node.attrs['localSheetId'];\n    if (scopeAttr !== undefined) {\n      const scope = Number.parseInt(scopeAttr, 10);\n      if (Number.isInteger(scope) && scope >= 0) opts.scope = scope;\n    }\n    if (node.attrs['hidden'] === '1' || node.attrs['hidden'] === 'true') opts.hidden = true;\n    if (node.attrs['comment'] !== undefined) opts.comment = node.attrs['comment'];\n    out.push(makeDefinedName(opts));\n  }\n  return out;\n}\n\nconst WORKBOOK_PR_TAG = `{${SHEET_MAIN_NS}}workbookPr`;\nconst WORKBOOK_PROTECTION_TAG = `{${SHEET_MAIN_NS}}workbookProtection`;\nconst BOOK_VIEWS_TAG = `{${SHEET_MAIN_NS}}bookViews`;\nconst WORKBOOK_VIEW_TAG = `{${SHEET_MAIN_NS}}workbookView`;\nconst CUSTOM_WORKBOOK_VIEWS_TAG = `{${SHEET_MAIN_NS}}customWorkbookViews`;\nconst CUSTOM_WORKBOOK_VIEW_TAG = `{${SHEET_MAIN_NS}}customWorkbookView`;\nconst CALC_PR_TAG = `{${SHEET_MAIN_NS}}calcPr`;\nconst FILE_VERSION_TAG = `{${SHEET_MAIN_NS}}fileVersion`;\nconst FILE_SHARING_TAG = `{${SHEET_MAIN_NS}}fileSharing`;\nconst OLE_SIZE_TAG = `{${SHEET_MAIN_NS}}oleSize`;\nconst FILE_RECOVERY_PR_TAG = `{${SHEET_MAIN_NS}}fileRecoveryPr`;\nconst PIVOT_CACHES_TAG = `{${SHEET_MAIN_NS}}pivotCaches`;\nconst PIVOT_CACHE_TAG = `{${SHEET_MAIN_NS}}pivotCache`;\nconst EXTERNAL_REFERENCES_TAG = `{${SHEET_MAIN_NS}}externalReferences`;\nconst EXTERNAL_REFERENCE_TAG = `{${SHEET_MAIN_NS}}externalReference`;\nconst SMART_TAG_PR_TAG = `{${SHEET_MAIN_NS}}smartTagPr`;\nconst SMART_TAG_TYPES_TAG = `{${SHEET_MAIN_NS}}smartTagTypes`;\nconst SMART_TAG_TYPE_TAG = `{${SHEET_MAIN_NS}}smartTagType`;\nconst FUNCTION_GROUPS_TAG = `{${SHEET_MAIN_NS}}functionGroups`;\nconst FUNCTION_GROUP_TAG = `{${SHEET_MAIN_NS}}functionGroup`;\n\n/**\n * Parse the `<workbookPr date1904>` flag. Mac-origin workbooks set\n * `date1904=\"true\"`; everything else uses the Windows 1900 epoch. The value\n * drives Date / Duration cell serial conversion in worksheet/writer.ts and\n * reader.ts.\n */\nfunction parseDate1904(workbookRoot: XmlNode): boolean {\n  const pr = findChild(workbookRoot, WORKBOOK_PR_TAG);\n  if (!pr) return false;\n  const v = pr.attrs['date1904'];\n  return v === '1' || v === 'true';\n}\n\n/** Extract the `<sheets>/<sheet>` entries from a parsed `xl/workbook.xml`. */\nexport function parseSheetEntries(workbookRoot: XmlNode): SheetEntry[] {\n  const sheets = findChild(workbookRoot, SHEETS_TAG);\n  if (!sheets) return [];\n  const out: SheetEntry[] = [];\n  for (const node of findChildren(sheets, SHEET_TAG)) {\n    const name = node.attrs['name'];\n    const sheetIdAttr = node.attrs['sheetId'];\n    const rId = node.attrs[RID_ATTR];\n    if (!name) throw new OpenXmlSchemaError(\"workbook.xml: <sheet> is missing 'name'\");\n    if (!sheetIdAttr) throw new OpenXmlSchemaError(`workbook.xml: <sheet name=\"${name}\"> is missing 'sheetId'`);\n    if (!rId) throw new OpenXmlSchemaError(`workbook.xml: <sheet name=\"${name}\"> is missing 'r:id'`);\n    const sheetId = Number.parseInt(sheetIdAttr, 10);\n    if (!Number.isInteger(sheetId) || sheetId < 1) {\n      throw new OpenXmlSchemaError(\n        `workbook.xml: <sheet name=\"${name}\"> sheetId \"${sheetIdAttr}\" is not a positive integer`,\n      );\n    }\n    const stateAttr = node.attrs['state'];\n    let state: SheetState = 'visible';\n    if (stateAttr === 'hidden' || stateAttr === 'veryHidden') state = stateAttr;\n    out.push({ name, sheetId, rId, state });\n  }\n  return out;\n}\n\n/**\n * Load a workbook from any {@link XlsxSource}. Currently produces a scaffold\n * Workbook: each Worksheet is empty (no cells / styles / shared strings / theme\n * yet). The next phase-3 iterations layer those in atop the same skeleton.\n */\nexport async function loadWorkbook(source: XlsxSource, opts: LoadOptions = {}): Promise<Workbook> {\n  const archive = await openZip(\n    source,\n    opts.decompressionLimits === undefined ? {} : { decompressionLimits: opts.decompressionLimits },\n  );\n  try {\n    return loadWorkbookFromArchive(archive);\n  } finally {\n    archive.close();\n  }\n}\n\n/** Internal: same as {@link loadWorkbook} but operating on an already-opened archive. */\nfunction loadWorkbookFromArchive(archive: ZipArchive): Workbook {\n  // 1. Manifest — resolves which override entries the package declares.\n  if (!archive.has(ARC_CONTENT_TYPES)) {\n    throw new OpenXmlSchemaError(`loadWorkbook: missing \"${ARC_CONTENT_TYPES}\"`);\n  }\n  const manifest = manifestFromBytes(archive.read(ARC_CONTENT_TYPES));\n\n  // 2. Root rels → resolve the office-document relationship to the workbook part path.\n  if (!archive.has(ARC_ROOT_RELS)) {\n    throw new OpenXmlSchemaError(`loadWorkbook: missing \"${ARC_ROOT_RELS}\"`);\n  }\n  const rootRels = relsFromBytes(archive.read(ARC_ROOT_RELS));\n  const officeRel = rootRels.rels.find((r) => r.type === OFFICE_DOC_REL_TYPE);\n  if (!officeRel) {\n    throw new OpenXmlSchemaError('loadWorkbook: root rels missing officeDocument relationship');\n  }\n  const workbookPath = resolveRelTarget('', officeRel.target);\n  if (workbookPath !== ARC_WORKBOOK) {\n    // Most xlsx files put the workbook at xl/workbook.xml. We accept any path\n    // the rels point at as long as the archive holds it.\n    if (!archive.has(workbookPath)) {\n      throw new OpenXmlSchemaError(`loadWorkbook: workbook part \"${workbookPath}\" not found in archive`);\n    }\n  }\n\n  // 3. workbook.xml — parse to extract sheet metadata only.\n  const wbRoot = parseXml(archive.read(workbookPath));\n  if (parseQName(wbRoot.name).local !== 'workbook') {\n    throw new OpenXmlSchemaError(`loadWorkbook: ${workbookPath} root is \"${wbRoot.name}\", expected workbook`);\n  }\n  const sheetEntries = parseSheetEntries(wbRoot);\n  const definedNamesFromXml = parseDefinedNames(wbRoot);\n\n  // 4. workbook.xml.rels — needed to resolve each sheet's rId to a part path.\n  const wbRelsPath = relsPathFor(workbookPath);\n  // openpyxl tolerates a missing workbook.xml.rels (it implies no sheets); in\n  // practice every Excel file has one. We require it so a malformed package\n  // surfaces as an OpenXmlSchemaError, not a silently-empty workbook.\n  if (sheetEntries.length > 0 && !archive.has(wbRelsPath)) {\n    throw new OpenXmlSchemaError(`loadWorkbook: workbook has sheets but rels part \"${wbRelsPath}\" is missing`);\n  }\n  const wbRels = archive.has(wbRelsPath) ? relsFromBytes(archive.read(wbRelsPath)) : { rels: [] };\n\n  // 4b. sharedStrings.xml — optional. The workbook rels can also point at a\n  // non-default location; for the minimum-skeleton stage we look at the\n  // canonical `xl/sharedStrings.xml` path first, then fall back to the rels\n  // entry if present.\n  let sharedStrings: SharedStringsTable | undefined;\n  if (archive.has(ARC_SHARED_STRINGS)) {\n    sharedStrings = parseSharedStringsXml(archive.read(ARC_SHARED_STRINGS));\n  } else {\n    const sstRel = wbRels.rels.find((r) => r.type === `${REL_NS}/sharedStrings`);\n    if (sstRel) {\n      const sstPath = resolveRelTarget(workbookPath, sstRel.target);\n      if (archive.has(sstPath)) {\n        sharedStrings = parseSharedStringsXml(archive.read(sstPath));\n      }\n    }\n  }\n  // The worksheet reader takes plain strings; rich-text SST entries are\n  // flattened to their concatenated text body so cell values stay simple.\n  // (Rich-text fidelity round-trip on read needs a sst entry → cell-value\n  // bridge that produces a rich-text cell; for now Excel re-write still works\n  // because we only flatten on read, not on write.)\n  const sst: ReadonlyArray<string> = (sharedStrings?.entries ?? []).map((e) =>\n    typeof e === 'string' ? e : e.runs.map((r) => r.text).join(''),\n  );\n\n  // 4c. styles.xml — optional. Same default-or-rels lookup as sst.\n  let styles: ReturnType<typeof parseStylesheetXml> | undefined;\n  if (archive.has(ARC_STYLE)) {\n    styles = parseStylesheetXml(archive.read(ARC_STYLE));\n  } else {\n    const stylesRel = wbRels.rels.find((r) => r.type === `${REL_NS}/styles`);\n    if (stylesRel) {\n      const stylesPath = resolveRelTarget(workbookPath, stylesRel.target);\n      if (archive.has(stylesPath)) {\n        styles = parseStylesheetXml(archive.read(stylesPath));\n      }\n    }\n  }\n\n  // 4d. docProps/{core,app,custom}.xml — package-level metadata. Each part is\n  // optional; absent ones leave the matching Workbook field undefined. We walk\n  // both the canonical path and the root rels so non-default layouts (rare but\n  // legal) still resolve.\n  const properties = archive.has(ARC_CORE) ? corePropsFromBytes(archive.read(ARC_CORE)) : undefined;\n  const appProperties = archive.has(ARC_APP) ? extendedPropsFromBytes(archive.read(ARC_APP)) : undefined;\n  const customProperties = archive.has(ARC_CUSTOM) ? customPropsFromBytes(archive.read(ARC_CUSTOM)) : undefined;\n\n  // 4e. xl/theme/theme1.xml — kept verbatim. Excel renders with this exact\n  // payload; round-tripping the bytes avoids drift.\n  const themeXml: Uint8Array | undefined = (() => {\n    if (archive.has(ARC_THEME)) return archive.read(ARC_THEME);\n    const themeRel = wbRels.rels.find((r) => r.type === `${REL_NS}/theme`);\n    if (themeRel) {\n      const themePath = resolveRelTarget(workbookPath, themeRel.target);\n      if (archive.has(themePath)) return archive.read(themePath);\n    }\n    return undefined;\n  })();\n\n  // 5. Build the Workbook. We bypass `addWorksheet` because that allocates\n  // sheetIds via `allocateSheetId`; load preserves the IDs from XML.\n  const wb = createWorkbook({ date1904: parseDate1904(wbRoot) });\n  if (styles) wb.styles = styles;\n  if (properties) wb.properties = properties;\n  if (appProperties) wb.appProperties = appProperties;\n  if (customProperties) wb.customProperties = customProperties;\n  if (themeXml) wb.themeXml = themeXml;\n  if (definedNamesFromXml.length > 0) wb.definedNames = definedNamesFromXml;\n  const seenTitles = new Set<string>();\n  for (const entry of sheetEntries) {\n    if (seenTitles.has(entry.name)) {\n      throw new OpenXmlSchemaError(`loadWorkbook: duplicate sheet name \"${entry.name}\"`);\n    }\n    seenTitles.add(entry.name);\n    const rel = findById(wbRels, entry.rId);\n    if (!rel) {\n      throw new OpenXmlSchemaError(`loadWorkbook: sheet \"${entry.name}\" rId \"${entry.rId}\" has no matching rels entry`);\n    }\n    const sheetPath = resolveRelTarget(workbookPath, rel.target);\n    if (!archive.has(sheetPath)) {\n      throw new OpenXmlSchemaError(`loadWorkbook: sheet part \"${sheetPath}\" not found in archive`);\n    }\n    const sheetRelsPath = relsPathFor(sheetPath);\n    const sheetRels = archive.has(sheetRelsPath) ? relsFromBytes(archive.read(sheetRelsPath)) : undefined;\n    // Build an id → rel index once; the loadTable / loadComments / loadDrawing\n    // callbacks are invoked once per cross-reference in the worksheet body and\n    // a linear find() inside each would be O(rels × refs). Sheets with many\n    // hyperlinks / tables / drawings (e.g. dashboard workbooks) make that\n    // accumulation visible.\n    const sheetRelsById = sheetRels ? indexRelsById(sheetRels) : undefined;\n    const loadTable = sheetRelsById\n      ? (relId: string) => {\n          const tRel = sheetRelsById.get(relId);\n          if (!tRel) return undefined;\n          const tablePath = resolveRelTarget(sheetPath, tRel.target);\n          if (!archive.has(tablePath)) return undefined;\n          return parseTableXml(archive.read(tablePath));\n        }\n      : undefined;\n    const loadComments = sheetRelsById\n      ? (relId: string) => {\n          const cRel = sheetRelsById.get(relId);\n          if (!cRel) return undefined;\n          const cPath = resolveRelTarget(sheetPath, cRel.target);\n          if (!archive.has(cPath)) return undefined;\n          return parseCommentsXml(archive.read(cPath));\n        }\n      : undefined;\n    const loadDrawing = sheetRelsById\n      ? (relId: string) => {\n          const dRel = sheetRelsById.get(relId);\n          if (!dRel) return undefined;\n          const dPath = resolveRelTarget(sheetPath, dRel.target);\n          if (!archive.has(dPath)) return undefined;\n          const drawing = parseDrawingXml(archive.read(dPath));\n          // Phase-2: resolve drawing-rels to populate chart payloads.\n          const dRelsPath = relsPathFor(dPath);\n          if (archive.has(dRelsPath)) {\n            const dRels = relsFromBytes(archive.read(dRelsPath));\n            const dRelsById = indexRelsById(dRels);\n            for (const item of drawing.items) {\n              if (item.content.kind === 'chart') {\n                const chartRId = item.content.chart.rId;\n                if (!chartRId) continue;\n                const chartRel = dRelsById.get(chartRId);\n                if (!chartRel) continue;\n                const chartPath = resolveRelTarget(dPath, chartRel.target);\n                if (archive.has(chartPath)) {\n                  const chartBytes = archive.read(chartPath);\n                  if (isChartExBytes(chartBytes)) {\n                    item.content.chart.cxSpace = parseChartExXml(chartBytes);\n                  } else {\n                    const space = parseChartXml(chartBytes);\n                    // Resolve <c:userShapes r:id=\"...\"> via the chart's own\n                    // rels file (xl/charts/_rels/chartN.xml.rels).\n                    const userShapesRId = findUserShapesRId(chartBytes);\n                    if (userShapesRId) {\n                      const chartRelsPath = relsPathFor(chartPath);\n                      if (archive.has(chartRelsPath)) {\n                        const chartRelsObj = relsFromBytes(archive.read(chartRelsPath));\n                        const usRel = indexRelsById(chartRelsObj).get(userShapesRId);\n                        if (usRel) {\n                          const usPath = resolveRelTarget(chartPath, usRel.target);\n                          if (archive.has(usPath)) {\n                            try {\n                              space.userShapes = parseUserShapesXml(archive.read(usPath));\n                            } catch {\n                              // Tolerate parse failures (Excel sometimes emits\n                              // chartDrawing parts with namespaces / shapes\n                              // outside our model).\n                            }\n                          }\n                        }\n                      }\n                    }\n                    item.content.chart.space = space;\n                  }\n                }\n              } else if (item.content.kind === 'picture') {\n                const picRId = item.content.picture.rId;\n                if (!picRId) continue;\n                const picRel = dRelsById.get(picRId);\n                if (!picRel) continue;\n                const imgPath = resolveRelTarget(dPath, picRel.target);\n                if (archive.has(imgPath)) {\n                  try {\n                    item.content.picture.image = loadImage(archive.read(imgPath));\n                  } catch {\n                    // Unknown / unsupported format — leave bytes-less; callers\n                    // can read via the rId + archive directly if they need the\n                    // raw payload.\n                  }\n                }\n              }\n            }\n          }\n          return drawing;\n        }\n      : undefined;\n    // Distinguish worksheet vs chartsheet by inspecting the workbook-rels\n    // entry's relationship type.\n    const isChartsheet = rel.type === `${REL_NS}/chartsheet`;\n    if (isChartsheet) {\n      const chartsheet = parseChartsheetXml(archive.read(sheetPath), entry.name);\n      // Inline drawing reference from the chartsheet XML.\n      if (sheetRels) {\n        // Find the drawing rel and resolve it the same way worksheets do.\n        const drawingRel = sheetRels.rels.find((r) => r.type === `${REL_NS}/drawing`);\n        if (drawingRel && loadDrawing) {\n          const d = loadDrawing(drawingRel.id);\n          if (d) chartsheet.drawing = d;\n        }\n      }\n      const ref: SheetRef = {\n        kind: 'chartsheet',\n        sheet: chartsheet,\n        sheetId: entry.sheetId,\n        state: entry.state,\n        rId: entry.rId,\n      };\n      wb.sheets.push(ref);\n      continue;\n    }\n    const ws = parseWorksheetXml(archive.read(sheetPath), entry.name, {\n      sharedStrings: sst,\n      ...(sheetRels ? { rels: sheetRels } : {}),\n      ...(loadTable ? { loadTable } : {}),\n      ...(loadComments ? { loadComments } : {}),\n      ...(loadDrawing ? { loadDrawing } : {}),\n    });\n    if (sheetRels) {\n      const extras = captureSheetRelsExtras(sheetRels);\n      if (extras.length > 0) ws.relsExtras = extras;\n    }\n    const ref: SheetRef = {\n      kind: 'worksheet',\n      sheet: ws,\n      sheetId: entry.sheetId,\n      state: entry.state,\n      rId: entry.rId,\n    };\n    wb.sheets.push(ref);\n  }\n\n  captureWorkbookXmlExtras(wbRoot, wb);\n  captureWorkbookRelsExtras(wbRels, wb);\n\n  // Pass-through: capture parts we don't model (VBA / pivot / activeX / OLE /\n  // customUI / customXml / etc.) so re-saving doesn't drop them.\n  capturePassthrough(archive, manifest, wb);\n  return wb;\n}\n\nconst SHEET_MODELED_REL_TYPES: ReadonlySet<string> = new Set([\n  `${REL_NS}/hyperlink`,\n  `${REL_NS}/table`,\n  `${REL_NS}/comments`,\n  `${REL_NS}/vmlDrawing`,\n  `${REL_NS}/drawing`,\n]);\n\n/**\n * Capture per-sheet rels entries that don't match a modeled type. The writer\n * re-emits these verbatim alongside the freshly allocated modeled rels so\n * captured passthrough parts (pivotTable / queryTable / slicer /\n * printerSettings / oleObject / customProperty / threadedComment) remain\n * reachable from the worksheet after a round-trip.\n */\nfunction captureSheetRelsExtras(\n  sheetRels: import('../packaging/relationships').Relationships,\n): Array<{ id: string; type: string; target: string }> {\n  const extras: Array<{ id: string; type: string; target: string }> = [];\n  for (const rel of sheetRels.rels) {\n    if (SHEET_MODELED_REL_TYPES.has(rel.type)) continue;\n    extras.push({ id: rel.id, type: rel.type, target: rel.target });\n  }\n  return extras;\n}\n\n/**\n * Walk top-level children of `<workbook>` and split anything that isn't\n * `<sheets>` or `<definedNames>` into the before/after halves the writer\n * inserts around the modeled elements. Order is preserved within each half so\n * things like `<fileVersion>`, `<workbookPr>`, `<bookViews>`, `<calcPr>`,\n * `<pivotCaches>`, `<extLst>` round-trip in document order.\n */\nfunction captureWorkbookXmlExtras(wbRoot: XmlNode, wb: Workbook): void {\n  const beforeSheets: XmlNode[] = [];\n  const afterSheets: XmlNode[] = [];\n  let seenSheets = false;\n  for (const child of wbRoot.children) {\n    if (child.name === SHEETS_TAG) {\n      seenSheets = true;\n      continue;\n    }\n    if (child.name === DEFINED_NAMES_TAG) continue;\n    // Lift <workbookProtection> into the typed workbook field instead of\n    // stashing it as a passthrough XmlNode (B5 partial).\n    if (child.name === WORKBOOK_PROTECTION_TAG) {\n      wb.workbookProtection = parseWorkbookProtection(child);\n      continue;\n    }\n    // Lift <workbookPr> into the typed workbook field. The date1904 attribute\n    // is already mirrored onto wb.date1904; everything else stops leaking into\n    // bodyExtras.\n    if (child.name === WORKBOOK_PR_TAG) {\n      const wp = parseWorkbookProperties(child);\n      if (wp) wb.workbookProperties = wp;\n      continue;\n    }\n    // Lift <fileSharing> into the typed workbook field.\n    if (child.name === FILE_SHARING_TAG) {\n      const fs: import('../workbook/file-sharing').FileSharing = {};\n      const a = child.attrs;\n      const flag = (raw: string | undefined): boolean | undefined => {\n        if (raw === '1' || raw === 'true') return true;\n        if (raw === '0' || raw === 'false') return false;\n        return undefined;\n      };\n      const ror = flag(a['readOnlyRecommended']);\n      if (ror !== undefined) fs.readOnlyRecommended = ror;\n      if (a['userName'] !== undefined) fs.userName = a['userName'];\n      if (a['reservationPassword'] !== undefined) fs.reservationPassword = a['reservationPassword'];\n      if (a['algorithmName'] !== undefined) fs.algorithmName = a['algorithmName'];\n      if (a['hashValue'] !== undefined) fs.hashValue = a['hashValue'];\n      if (a['saltValue'] !== undefined) fs.saltValue = a['saltValue'];\n      if (a['spinCount'] !== undefined) {\n        const n = Number.parseInt(a['spinCount'], 10);\n        if (Number.isInteger(n)) fs.spinCount = n;\n      }\n      if (Object.keys(fs).length > 0) wb.fileSharing = fs;\n      continue;\n    }\n    // Lift <fileVersion> into the typed workbook field.\n    if (child.name === FILE_VERSION_TAG) {\n      const fv: import('../workbook/file-version').FileVersion = {};\n      if (child.attrs['appName'] !== undefined) fv.appName = child.attrs['appName'];\n      if (child.attrs['lastEdited'] !== undefined) fv.lastEdited = child.attrs['lastEdited'];\n      if (child.attrs['lowestEdited'] !== undefined) fv.lowestEdited = child.attrs['lowestEdited'];\n      if (child.attrs['rupBuild'] !== undefined) fv.rupBuild = child.attrs['rupBuild'];\n      if (child.attrs['codeName'] !== undefined) fv.codeName = child.attrs['codeName'];\n      if (Object.keys(fv).length > 0) wb.fileVersion = fv;\n      continue;\n    }\n    // Lift <bookViews> into the typed workbook field.\n    if (child.name === BOOK_VIEWS_TAG) {\n      const views: import('../workbook/views').WorkbookView[] = [];\n      for (const v of findChildren(child, WORKBOOK_VIEW_TAG)) views.push(parseWorkbookView(v));\n      if (views.length > 0) wb.bookViews = views;\n      continue;\n    }\n    // Lift <customWorkbookViews> into the typed workbook field.\n    if (child.name === CUSTOM_WORKBOOK_VIEWS_TAG) {\n      const cws: import('../workbook/views').CustomWorkbookView[] = [];\n      for (const v of findChildren(child, CUSTOM_WORKBOOK_VIEW_TAG)) {\n        const parsed = parseCustomWorkbookView(v);\n        if (parsed) cws.push(parsed);\n      }\n      if (cws.length > 0) wb.customWorkbookViews = cws;\n      continue;\n    }\n    // Lift <calcPr> into the typed workbook field.\n    if (child.name === CALC_PR_TAG) {\n      const cp = parseCalcProperties(child);\n      if (cp) wb.calcProperties = cp;\n      continue;\n    }\n    // Lift <oleSize ref=\"…\"/> as a single typed string attribute.\n    if (child.name === OLE_SIZE_TAG) {\n      const ref = child.attrs['ref'];\n      if (ref) wb.oleSize = ref;\n      continue;\n    }\n    // Lift <smartTagPr embed=\"1\" show=\"all\"/>.\n    if (child.name === SMART_TAG_PR_TAG) {\n      const out: import('../workbook/smart-tags').SmartTagProperties = {};\n      const a = child.attrs;\n      if (a['embed'] === '1' || a['embed'] === 'true') out.embed = true;\n      else if (a['embed'] === '0' || a['embed'] === 'false') out.embed = false;\n      if (a['show'] === 'all' || a['show'] === 'noIndicator') out.show = a['show'];\n      if (Object.keys(out).length > 0) wb.smartTagPr = out;\n      continue;\n    }\n    // Lift <smartTagTypes><smartTagType .../></smartTagTypes>.\n    if (child.name === SMART_TAG_TYPES_TAG) {\n      const tags: import('../workbook/smart-tags').SmartTagType[] = [];\n      for (const t of findChildren(child, SMART_TAG_TYPE_TAG)) {\n        const entry: import('../workbook/smart-tags').SmartTagType = {};\n        if (t.attrs['namespaceUri'] !== undefined) entry.namespaceUri = t.attrs['namespaceUri'];\n        if (t.attrs['name'] !== undefined) entry.name = t.attrs['name'];\n        if (t.attrs['url'] !== undefined) entry.url = t.attrs['url'];\n        if (Object.keys(entry).length > 0) tags.push(entry);\n      }\n      if (tags.length > 0) wb.smartTagTypes = tags;\n      continue;\n    }\n    // Lift <functionGroups builtInGroupCount=…><functionGroup\n    // name=…/></functionGroups>.\n    if (child.name === FUNCTION_GROUPS_TAG) {\n      const fg: import('../workbook/function-groups').FunctionGroups = { groups: [] };\n      const bicgRaw = child.attrs['builtInGroupCount'];\n      if (bicgRaw !== undefined) {\n        const n = Number.parseInt(bicgRaw, 10);\n        if (Number.isInteger(n)) fg.builtInGroupCount = n;\n      }\n      for (const g of findChildren(child, FUNCTION_GROUP_TAG)) {\n        const name = g.attrs['name'];\n        if (name) fg.groups.push({ name });\n      }\n      if (fg.groups.length > 0 || fg.builtInGroupCount !== undefined) wb.functionGroups = fg;\n      continue;\n    }\n    // Lift <externalReferences><externalReference\n    // r:id=…/></externalReferences>.\n    if (child.name === EXTERNAL_REFERENCES_TAG) {\n      const refs: Array<{ rId: string }> = [];\n      for (const er of findChildren(child, EXTERNAL_REFERENCE_TAG)) {\n        const rId = er.attrs[`{${REL_NS}}id`];\n        if (rId) refs.push({ rId });\n      }\n      if (refs.length > 0) wb.externalReferences = refs;\n      continue;\n    }\n    // Lift <pivotCaches><pivotCache cacheId=… r:id=…/></pivotCaches>.\n    if (child.name === PIVOT_CACHES_TAG) {\n      const caches: Array<{ cacheId: number; rId: string }> = [];\n      for (const pc of findChildren(child, PIVOT_CACHE_TAG)) {\n        const cacheIdAttr = pc.attrs['cacheId'];\n        const rId = pc.attrs[`{${REL_NS}}id`];\n        if (cacheIdAttr === undefined || !rId) continue;\n        const cacheId = Number.parseInt(cacheIdAttr, 10);\n        if (!Number.isInteger(cacheId)) continue;\n        caches.push({ cacheId, rId });\n      }\n      if (caches.length > 0) wb.pivotCaches = caches;\n      continue;\n    }\n    // Lift <fileRecoveryPr> into the typed workbook field.\n    if (child.name === FILE_RECOVERY_PR_TAG) {\n      const fp: import('../workbook/file-recovery').FileRecoveryProperties = {};\n      const a = child.attrs;\n      const flag = (raw: string | undefined): boolean | undefined => {\n        if (raw === '1' || raw === 'true') return true;\n        if (raw === '0' || raw === 'false') return false;\n        return undefined;\n      };\n      const ar = flag(a['autoRecover']);\n      if (ar !== undefined) fp.autoRecover = ar;\n      const cs = flag(a['crashSave']);\n      if (cs !== undefined) fp.crashSave = cs;\n      const del = flag(a['dataExtractLoad']);\n      if (del !== undefined) fp.dataExtractLoad = del;\n      const rl = flag(a['repairLoad']);\n      if (rl !== undefined) fp.repairLoad = rl;\n      if (Object.keys(fp).length > 0) wb.fileRecoveryPr = fp;\n      continue;\n    }\n    if (seenSheets) afterSheets.push(child);\n    else beforeSheets.push(child);\n  }\n  if (beforeSheets.length > 0 || afterSheets.length > 0) {\n    wb.workbookXmlExtras = { beforeSheets, afterSheets };\n  }\n}\n\nconst SHOW_OBJECTS_MODES: ReadonlyArray<import('../workbook/workbook-properties').ShowObjectsMode> = [\n  'all',\n  'placeholders',\n  'none',\n];\nconst UPDATE_LINKS_MODES: ReadonlyArray<import('../workbook/workbook-properties').UpdateLinksMode> = [\n  'userSet',\n  'never',\n  'always',\n];\n\nconst parseWorkbookProperties = (\n  node: XmlNode,\n): import('../workbook/workbook-properties').WorkbookProperties | undefined => {\n  const out: import('../workbook/workbook-properties').WorkbookProperties = {};\n  const a = node.attrs;\n  const flag = (raw: string | undefined): boolean | undefined => {\n    if (raw === '1' || raw === 'true') return true;\n    if (raw === '0' || raw === 'false') return false;\n    return undefined;\n  };\n  const intAttr = (k: string): number | undefined => {\n    if (a[k] === undefined) return undefined;\n    const n = Number.parseInt(a[k], 10);\n    return Number.isInteger(n) ? n : undefined;\n  };\n\n  const bools = [\n    'date1904',\n    'dateCompatibility',\n    'showBorderUnselectedTables',\n    'filterPrivacy',\n    'promptedSolutions',\n    'showInkAnnotation',\n    'backupFile',\n    'saveExternalLinkValues',\n    'hidePivotFieldList',\n    'showPivotChartFilter',\n    'allowRefreshQuery',\n    'publishItems',\n    'checkCompatibility',\n    'autoCompressPictures',\n    'refreshAllConnections',\n  ] as const satisfies ReadonlyArray<keyof import('../workbook/workbook-properties').WorkbookProperties>;\n  for (const k of bools) {\n    const v = flag(a[k]);\n    if (v !== undefined) out[k] = v;\n  }\n\n  const showObjects = a['showObjects'];\n  if (showObjects && SHOW_OBJECTS_MODES.includes(showObjects as import('../workbook/workbook-properties').ShowObjectsMode)) {\n    out.showObjects = showObjects as import('../workbook/workbook-properties').ShowObjectsMode;\n  }\n  const updateLinks = a['updateLinks'];\n  if (updateLinks && UPDATE_LINKS_MODES.includes(updateLinks as import('../workbook/workbook-properties').UpdateLinksMode)) {\n    out.updateLinks = updateLinks as import('../workbook/workbook-properties').UpdateLinksMode;\n  }\n  if (a['codeName'] !== undefined) out.codeName = a['codeName'];\n  const dtv = intAttr('defaultThemeVersion');\n  if (dtv !== undefined) out.defaultThemeVersion = dtv;\n\n  return Object.keys(out).length > 0 ? out : undefined;\n};\n\nconst CALC_MODES: ReadonlyArray<import('../workbook/calc-properties').CalcMode> = [\n  'manual',\n  'auto',\n  'autoNoTable',\n];\nconst REF_MODES: ReadonlyArray<import('../workbook/calc-properties').RefMode> = ['A1', 'R1C1'];\n\nconst parseCalcProperties = (\n  node: XmlNode,\n): import('../workbook/calc-properties').CalcProperties | undefined => {\n  const out: import('../workbook/calc-properties').CalcProperties = {};\n  const a = node.attrs;\n  const flag = (raw: string | undefined): boolean | undefined => {\n    if (raw === '1' || raw === 'true') return true;\n    if (raw === '0' || raw === 'false') return false;\n    return undefined;\n  };\n  const intAttr = (k: string): number | undefined => {\n    if (a[k] === undefined) return undefined;\n    const n = Number.parseInt(a[k], 10);\n    return Number.isInteger(n) ? n : undefined;\n  };\n  const floatAttr = (k: string): number | undefined => {\n    if (a[k] === undefined) return undefined;\n    const n = Number.parseFloat(a[k]);\n    return Number.isFinite(n) ? n : undefined;\n  };\n\n  const calcId = intAttr('calcId');\n  if (calcId !== undefined) out.calcId = calcId;\n  const calcMode = a['calcMode'];\n  if (calcMode && CALC_MODES.includes(calcMode as import('../workbook/calc-properties').CalcMode)) {\n    out.calcMode = calcMode as import('../workbook/calc-properties').CalcMode;\n  }\n  const fcol = flag(a['fullCalcOnLoad']);\n  if (fcol !== undefined) out.fullCalcOnLoad = fcol;\n  const refMode = a['refMode'];\n  if (refMode && REF_MODES.includes(refMode as import('../workbook/calc-properties').RefMode)) {\n    out.refMode = refMode as import('../workbook/calc-properties').RefMode;\n  }\n  const iterate = flag(a['iterate']);\n  if (iterate !== undefined) out.iterate = iterate;\n  const iterateCount = intAttr('iterateCount');\n  if (iterateCount !== undefined) out.iterateCount = iterateCount;\n  const iterateDelta = floatAttr('iterateDelta');\n  if (iterateDelta !== undefined) out.iterateDelta = iterateDelta;\n  const fullPrecision = flag(a['fullPrecision']);\n  if (fullPrecision !== undefined) out.fullPrecision = fullPrecision;\n  const calcCompleted = flag(a['calcCompleted']);\n  if (calcCompleted !== undefined) out.calcCompleted = calcCompleted;\n  const calcOnSave = flag(a['calcOnSave']);\n  if (calcOnSave !== undefined) out.calcOnSave = calcOnSave;\n  const concurrentCalc = flag(a['concurrentCalc']);\n  if (concurrentCalc !== undefined) out.concurrentCalc = concurrentCalc;\n  const concurrentManualCount = intAttr('concurrentManualCount');\n  if (concurrentManualCount !== undefined) out.concurrentManualCount = concurrentManualCount;\n  const forceFullCalc = flag(a['forceFullCalc']);\n  if (forceFullCalc !== undefined) out.forceFullCalc = forceFullCalc;\n\n  return Object.keys(out).length > 0 ? out : undefined;\n};\n\nconst SHOW_COMMENTS_MODES: ReadonlyArray<import('../workbook/views').CustomViewShowComments> = [\n  'commNone',\n  'commIndicator',\n  'commIndAndComment',\n];\nconst SHOW_OBJECTS_CV_MODES: ReadonlyArray<import('../workbook/views').CustomViewShowObjects> = [\n  'all',\n  'placeholders',\n  'none',\n];\n\nconst parseCustomWorkbookView = (\n  node: XmlNode,\n): import('../workbook/views').CustomWorkbookView | undefined => {\n  const a = node.attrs;\n  const name = a['name'];\n  const guid = a['guid'];\n  if (!name || !guid) return undefined;\n  const flag = (raw: string | undefined): boolean | undefined => {\n    if (raw === '1' || raw === 'true') return true;\n    if (raw === '0' || raw === 'false') return false;\n    return undefined;\n  };\n  const intAttr = (k: string): number | undefined => {\n    if (a[k] === undefined) return undefined;\n    const n = Number.parseInt(a[k], 10);\n    return Number.isInteger(n) ? n : undefined;\n  };\n  const ww = intAttr('windowWidth') ?? 0;\n  const wh = intAttr('windowHeight') ?? 0;\n  const asid = intAttr('activeSheetId') ?? 0;\n  const out: import('../workbook/views').CustomWorkbookView = {\n    name,\n    guid,\n    windowWidth: ww,\n    windowHeight: wh,\n    activeSheetId: asid,\n  };\n\n  const boolKeys = [\n    'autoUpdate',\n    'changesSavedWin',\n    'onlySync',\n    'personalView',\n    'includePrintSettings',\n    'includeHiddenRowCol',\n    'maximized',\n    'minimized',\n    'showHorizontalScroll',\n    'showVerticalScroll',\n    'showSheetTabs',\n    'showFormulaBar',\n    'showStatusbar',\n  ] as const satisfies ReadonlyArray<keyof import('../workbook/views').CustomWorkbookView>;\n  for (const k of boolKeys) {\n    const v = flag(a[k]);\n    if (v !== undefined) out[k] = v;\n  }\n  const intKeys = [\n    'mergeInterval',\n    'xWindow',\n    'yWindow',\n    'tabRatio',\n  ] as const satisfies ReadonlyArray<keyof import('../workbook/views').CustomWorkbookView>;\n  for (const k of intKeys) {\n    const v = intAttr(k);\n    if (v !== undefined) out[k] = v;\n  }\n\n  const sc = a['showComments'];\n  if (sc && SHOW_COMMENTS_MODES.includes(sc as import('../workbook/views').CustomViewShowComments)) {\n    out.showComments = sc as import('../workbook/views').CustomViewShowComments;\n  }\n  const so = a['showObjects'];\n  if (so && SHOW_OBJECTS_CV_MODES.includes(so as import('../workbook/views').CustomViewShowObjects)) {\n    out.showObjects = so as import('../workbook/views').CustomViewShowObjects;\n  }\n  return out;\n};\n\nconst VISIBILITIES: ReadonlyArray<import('../workbook/views').WorkbookViewVisibility> = [\n  'visible',\n  'hidden',\n  'veryHidden',\n];\n\nconst parseWorkbookView = (node: XmlNode): import('../workbook/views').WorkbookView => {\n  const out: import('../workbook/views').WorkbookView = {};\n  const a = node.attrs;\n  const flag = (raw: string | undefined): boolean | undefined => {\n    if (raw === '1' || raw === 'true') return true;\n    if (raw === '0' || raw === 'false') return false;\n    return undefined;\n  };\n  const intAttr = (k: string): number | undefined => {\n    if (a[k] === undefined) return undefined;\n    const n = Number.parseInt(a[k], 10);\n    return Number.isInteger(n) ? n : undefined;\n  };\n\n  const visibility = a['visibility'];\n  if (visibility && VISIBILITIES.includes(visibility as import('../workbook/views').WorkbookViewVisibility)) {\n    out.visibility = visibility as import('../workbook/views').WorkbookViewVisibility;\n  }\n  const minimized = flag(a['minimized']);\n  if (minimized !== undefined) out.minimized = minimized;\n  const shScroll = flag(a['showHorizontalScroll']);\n  if (shScroll !== undefined) out.showHorizontalScroll = shScroll;\n  const svScroll = flag(a['showVerticalScroll']);\n  if (svScroll !== undefined) out.showVerticalScroll = svScroll;\n  const sst = flag(a['showSheetTabs']);\n  if (sst !== undefined) out.showSheetTabs = sst;\n  const xWindow = intAttr('xWindow');\n  if (xWindow !== undefined) out.xWindow = xWindow;\n  const yWindow = intAttr('yWindow');\n  if (yWindow !== undefined) out.yWindow = yWindow;\n  const ww = intAttr('windowWidth');\n  if (ww !== undefined) out.windowWidth = ww;\n  const wh = intAttr('windowHeight');\n  if (wh !== undefined) out.windowHeight = wh;\n  const tr = intAttr('tabRatio');\n  if (tr !== undefined) out.tabRatio = tr;\n  const fs = intAttr('firstSheet');\n  if (fs !== undefined) out.firstSheet = fs;\n  const at = intAttr('activeTab');\n  if (at !== undefined) out.activeTab = at;\n  const adg = flag(a['autoFilterDateGrouping']);\n  if (adg !== undefined) out.autoFilterDateGrouping = adg;\n  return out;\n};\n\nconst parseWorkbookProtection = (node: XmlNode): import('../workbook/protection').WorkbookProtection => {\n  const out: import('../workbook/protection').WorkbookProtection = {};\n  const a = node.attrs;\n  const flag = (raw: string | undefined): boolean | undefined => {\n    if (raw === '1' || raw === 'true') return true;\n    if (raw === '0' || raw === 'false') return false;\n    return undefined;\n  };\n  if (a['workbookPassword'] !== undefined) out.workbookPassword = a['workbookPassword'];\n  if (a['workbookPasswordCharacterSet'] !== undefined)\n    out.workbookPasswordCharacterSet = a['workbookPasswordCharacterSet'];\n  if (a['workbookAlgorithmName'] !== undefined) out.workbookAlgorithmName = a['workbookAlgorithmName'];\n  if (a['workbookHashValue'] !== undefined) out.workbookHashValue = a['workbookHashValue'];\n  if (a['workbookSaltValue'] !== undefined) out.workbookSaltValue = a['workbookSaltValue'];\n  if (a['workbookSpinCount'] !== undefined) {\n    const n = Number.parseInt(a['workbookSpinCount'], 10);\n    if (Number.isInteger(n)) out.workbookSpinCount = n;\n  }\n  if (a['revisionsPassword'] !== undefined) out.revisionsPassword = a['revisionsPassword'];\n  if (a['revisionsPasswordCharacterSet'] !== undefined)\n    out.revisionsPasswordCharacterSet = a['revisionsPasswordCharacterSet'];\n  if (a['revisionsAlgorithmName'] !== undefined) out.revisionsAlgorithmName = a['revisionsAlgorithmName'];\n  if (a['revisionsHashValue'] !== undefined) out.revisionsHashValue = a['revisionsHashValue'];\n  if (a['revisionsSaltValue'] !== undefined) out.revisionsSaltValue = a['revisionsSaltValue'];\n  if (a['revisionsSpinCount'] !== undefined) {\n    const n = Number.parseInt(a['revisionsSpinCount'], 10);\n    if (Number.isInteger(n)) out.revisionsSpinCount = n;\n  }\n  const ls = flag(a['lockStructure']);\n  if (ls !== undefined) out.lockStructure = ls;\n  const lw = flag(a['lockWindows']);\n  if (lw !== undefined) out.lockWindows = lw;\n  const lr = flag(a['lockRevision']);\n  if (lr !== undefined) out.lockRevision = lr;\n  return out;\n};\n\n/**\n * Capture workbook-rels entries that don't match a modeled type so the writer\n * can re-emit them with their original Id (and any captured `<pivotCaches\n * r:id=\"…\"/>` etc. still resolves after a round-trip). Modeled non-sheet rels\n * (sst / styles / theme / vbaProject) keep their original Id via\n * `wb.workbookRelOriginalIds` so the writer can prefer those over freshly\n * allocated ones.\n */\nfunction captureWorkbookRelsExtras(\n  wbRels: import('../packaging/relationships').Relationships,\n  wb: Workbook,\n): void {\n  const SHEET_RELS = new Set([`${REL_NS}/worksheet`, `${REL_NS}/chartsheet`]);\n  const original: NonNullable<Workbook['workbookRelOriginalIds']> = {};\n  const extras: Array<{ id: string; type: string; target: string }> = [];\n  for (const rel of wbRels.rels) {\n    if (SHEET_RELS.has(rel.type)) continue;\n    if (rel.type === `${REL_NS}/sharedStrings`) {\n      original.sharedStrings = rel.id;\n      continue;\n    }\n    if (rel.type === `${REL_NS}/styles`) {\n      original.styles = rel.id;\n      continue;\n    }\n    if (rel.type === `${REL_NS}/theme`) {\n      original.theme = rel.id;\n      continue;\n    }\n    if (rel.type === `${REL_NS}/vbaProject`) {\n      original.vbaProject = rel.id;\n      continue;\n    }\n    extras.push({ id: rel.id, type: rel.type, target: rel.target });\n  }\n  if (Object.keys(original).length > 0) wb.workbookRelOriginalIds = original;\n  if (extras.length > 0) wb.workbookRelsExtras = extras;\n}\n\nconst PASSTHROUGH_PREFIXES: ReadonlyArray<string> = [\n  'xl/activeX/',\n  'xl/ctrlProps/',\n  'xl/embeddings/',\n  'xl/externalLinks/',\n  // xl/model/ — Power Pivot data model (`xl/model/item.data` etc.).\n  'xl/model/',\n  'xl/persons/',\n  'xl/pivotCache/',\n  'xl/pivotTables/',\n  'xl/printerSettings/',\n  'xl/queryTables/',\n  'xl/richData/',\n  'xl/slicerCaches/',\n  'xl/slicers/',\n  'xl/threadedComments/',\n  'xl/timelineCaches/',\n  'xl/timelines/',\n  'xl/workbookCache/',\n  'customUI/',\n  'customXml/',\n];\n\n/**\n * Excel emits both form-control VMLs and comment VMLs at\n * `xl/drawings/vmlDrawingN.vml`. Filename alone can't tell them apart, but\n * ECMA-376 §17.18.51 requires comment shapes to carry `<x:ClientData\n * ObjectType=\"Note\">`, so a byte-search for that marker decides which path the\n * file belongs on:\n *\n *  - With marker → comment VML; the comments writer regenerates\n * these from `Worksheet.legacyComments`, so we must not capture them as\n * passthrough (would duplicate the entry on save).\n *  - Without marker → control / OLE / shape VML; capture as\n * passthrough so form controls survive load → save → load.\n */\nconst COMMENT_VML_MARKER = 'ObjectType=\"Note\"';\n// Latin-1 is a 1-to-1 byte-to-character mapping for the 0–255 range, so a\n// String.indexOf scan on the decoded view returns the same answer as a byte\n// search but takes advantage of V8's native StringPrototypeIndexOf — orders\n// of magnitude faster than the JS loop the previous implementation used on\n// multi-megabyte VML drawings.\nconst LATIN1_DECODER = new TextDecoder('latin1');\n\nconst isVmlDrawing = (path: string): boolean =>\n  path.startsWith('xl/drawings/') && path.endsWith('.vml');\n\nconst containsCommentMarker = (bytes: Uint8Array): boolean =>\n  LATIN1_DECODER.decode(bytes).includes(COMMENT_VML_MARKER);\n\n/**\n * Top-level xl/*.xml files that aren't modeled but Excel relies on (or\n * harmlessly preserves). Captured by exact path; their content types come\n * through the manifest Override map.\n *\n * - `xl/calcChain.xml`     — calculation order hint (Excel rebuilds\n * it on first open if missing, but losing it forces a full recalc).\n * - `xl/connections.xml`   — external data connection metadata.\n * - `xl/persons/`          — threaded-comment author registry\n * (Excel 365). Captured under the prefix list below.\n * - `xl/metadata.xml`      — Excel 365 dynamic-array cell metadata.\n * - `xl/SheetMetadata.xml` — variant casing of the same.\n */\nconst PASSTHROUGH_EXACT_PATHS: ReadonlySet<string> = new Set([\n  'xl/calcChain.xml',\n  'xl/connections.xml',\n  'xl/metadata.xml',\n  'xl/SheetMetadata.xml',\n  // docProps/thumbnail.jpeg — workbook preview image Excel renders in the OS\n  // file browser. JPEG by default; some files use PNG.\n  'docProps/thumbnail.jpeg',\n  'docProps/thumbnail.jpg',\n  'docProps/thumbnail.png',\n  'docProps/thumbnail.wmf',\n  'docProps/thumbnail.emf',\n]);\n\nconst isPassthroughPath = (path: string, bytes?: Uint8Array): boolean => {\n  if (PASSTHROUGH_EXACT_PATHS.has(path)) return true;\n  if (PASSTHROUGH_PREFIXES.some((p) => path.startsWith(p))) return true;\n  if (isVmlDrawing(path) && bytes) {\n    // Comment VML is regenerated; control / shape VML passes through.\n    return !containsCommentMarker(bytes);\n  }\n  return false;\n};\n\n/**\n * Walk the archive after the modeled parts are loaded and capture any remaining\n * content into `wb.passthrough`. The dedicated VBA project binaries land on\n * their own slots so the writer can promote the workbook content type to xlsm.\n */\nfunction capturePassthrough(\n  archive: ZipArchive,\n  manifest: import('../packaging/manifest').Manifest,\n  wb: Workbook,\n): void {\n  const overrides = new Map<string, string>();\n  for (const o of manifest.overrides) {\n    // Manifest paths are package-absolute (`/xl/...`); strip the leading slash.\n    overrides.set(o.partName.replace(/^\\//, ''), o.contentType);\n  }\n  for (const path of archive.list()) {\n    if (path === 'xl/vbaProject.bin') {\n      wb.vbaProject = archive.read(path);\n      continue;\n    }\n    if (path === 'xl/vbaProjectSignature.bin') {\n      wb.vbaSignature = archive.read(path);\n      continue;\n    }\n    // VML drawings need a content peek to distinguish comment-VML (regenerated\n    // from ws.legacyComments) from form-control / shape VML (passthrough). Read\n    // once and reuse for the actual capture.\n    let cached: Uint8Array | undefined;\n    if (isVmlDrawing(path)) cached = archive.read(path);\n    if (!isPassthroughPath(path, cached)) continue;\n    if (!wb.passthrough) wb.passthrough = new Map();\n    wb.passthrough.set(path, cached ?? archive.read(path));\n    const ct = overrides.get(path);\n    if (ct !== undefined) {\n      if (!wb.passthroughContentTypes) wb.passthroughContentTypes = new Map();\n      wb.passthroughContentTypes.set(path, ct);\n    }\n  }\n}\n"],"mappings":";;;;;;;;;;;;AA6BA,MAAM,iBAAiB,MAAM,eAAe,YAAY;AACxD,MAAM,YAAY,MAAM,eAAe,OAAO;AAC9C,MAAM,YAAY,MAAM,eAAe,OAAO;AAC9C,MAAM,cAAc,MAAM,eAAe,SAAS;AAClD,MAAM,cAAc,MAAM,eAAe,SAAS;AAClD,MAAM,aAAa,MAAM,eAAe,QAAQ;AAChD,MAAM,cAAc,MAAM,eAAe,SAAS;AAClD,MAAM,mBAAmB,MAAM,eAAe,cAAc;AAC5D,MAAM,iBAAiB,MAAM,eAAe,YAAY;AACxD,MAAM,gBAAgB,MAAM,eAAe,WAAW;AACtD,MAAM,WAAW,MAAM,eAAe,MAAM;AAC5C,MAAM,UAAU,MAAM,eAAe,KAAK;AAC1C,MAAM,SAAS,MAAM,eAAe,IAAI;AACxC,MAAM,WAAW,MAAM,eAAe,MAAM;AAC5C,MAAM,WAAW,MAAM,eAAe,MAAM;AAC5C,MAAM,aAAa,MAAM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