{"version":3,"file":"src-Dy50EzPO.cjs","names":["THEMES","INDEXED_COLORS","tokenTypes","readTransforms","THEMES","PRESET_COLORS","SYSTEM_COLORS","Element","Element","Element","TextNode","CDataNode","Element","ZipArchive"],"sources":["../src/utils/attr.ts","../src/utils/path.ts","../src/utils/convertStyles.ts","../src/utils/mdw.ts","../src/utils/getBinaryFileType.ts","../src/ConversionContext.ts","../src/constants.ts","../src/handler/rels.ts","../src/utils/normalizeFormula.ts","../src/utils/typecast.ts","../src/handler/workbook.ts","../src/handler/sharedstrings.ts","../src/handler/persons.ts","../src/color/readDrawingMLColor.ts","../src/utils/getFirstChild.ts","../src/utils/addProp.ts","../src/handler/theme.ts","../src/handler/appdata.ts","../src/color/readColor.ts","../src/handler/styles.ts","../src/handler/rdstuct.ts","../src/handler/rdvalue.ts","../src/handler/metadata.ts","../src/handler/comments.ts","../src/handler/notes.ts","../src/utils/rle.ts","../src/utils/unescape.ts","../src/RelativeFormula.ts","../src/utils/dateToSerial.ts","../src/errors.ts","../src/utils/parseTimeToSerial.ts","../src/handler/cell.ts","../src/utils/colWidth.ts","../src/utils/fromA1.ts","../src/utils/toA1.ts","../src/handler/worksheet.ts","../src/handler/external.ts","../src/handler/table.ts","../src/utils/parseEnum.ts","../src/handler/pivotTables/parseCacheSharedItem.ts","../src/handler/pivotTables/resolveNumFmt.ts","../src/handler/pivotTables/pivotCacheDefinition.ts","../src/handler/pivotTables/pivotCacheRecords.ts","../src/handler/pivotTables/parseDataFields.ts","../src/handler/pivotTables/parseExtensions.ts","../src/handler/pivotTables/parseFilters.ts","../src/handler/pivotTables/parsePageFields.ts","../src/handler/pivotTables/constants.ts","../src/handler/pivotTables/parsePivotArea.ts","../src/handler/pivotTables/readBoolAttrs.ts","../src/handler/pivotTables/parsePivotFields.ts","../src/handler/pivotTables/parseRowColItems.ts","../src/handler/pivotTables/parseStyle.ts","../src/handler/pivotTable.ts","../src/handler/drawings/readPoint.ts","../src/handler/drawings/readExtent.ts","../src/handler/drawings/readCellPos.ts","../src/handler/drawings/readAnchor.ts","../src/handler/drawings/readTransforms.ts","../src/handler/drawings/readPath.ts","../src/handler/drawings/readFillGradient.ts","../src/handler/drawings/readRelRect.ts","../src/handler/drawings/readFillBlip.ts","../src/handler/drawings/readFill.ts","../src/handler/drawings/readLineProps.ts","../src/utils/hasKeys.ts","../src/handler/drawings/readShapeProperties.ts","../src/handler/drawings/readTextBody.ts","../src/handler/drawings/readGraphicContent.ts","../src/handler/drawing.ts","../src/utils/arrayBufferToDataUri.ts","../src/utils/getMimeType.ts","../src/utils/isLikelyGSExport.ts","../src/handler/charts/utils/valElm.ts","../src/handler/charts/readTextProps.ts","../src/handler/charts/readLayout.ts","../src/handler/charts/readLegend.ts","../src/handler/charts/readDataSource.ts","../src/handler/charts/readText.ts","../src/handler/charts/readTitle.ts","../src/handler/charts/readMarker.ts","../src/handler/charts/readPivotFmts.ts","../src/handler/charts/readDataPoint.ts","../src/handler/charts/utils/isNumDataSource.ts","../src/handler/charts/readErrBars.ts","../src/handler/charts/readNumFmt.ts","../src/handler/charts/readDLbls.ts","../src/handler/charts/readTrendline.ts","../src/handler/charts/readSeries.ts","../src/handler/charts/readAxis.ts","../src/handler/charts/readPlotArea.ts","../src/handler/charts/readChart.ts","../src/handler/charts/readChartData.ts","../src/handler/chart.ts","../src/convertBinary.ts","../src/CSVParser.ts","../src/convertCSV.ts","../src/index.ts"],"sourcesContent":["import type { Element } from '@borgar/simple-xml';\n\nexport function attr<T = string | null> (\n  node: Element,\n  name: string,\n  fallBack: T = null as unknown as T,\n): string | T {\n  if (node.hasAttribute(name)) {\n    return node.getAttribute(name)!;\n  }\n  return fallBack;\n}\n\nexport function numAttr<T = number | null> (\n  node: Element,\n  name: string,\n  fallBack: T = null as unknown as T,\n): number | T {\n  const v = attr(node, name);\n  return v != null && Number.isFinite(+v) ? +v : fallBack;\n}\n\nexport function boolAttr<T = boolean | null> (\n  node: Element,\n  name: string,\n  fallBack: T = null as unknown as T,\n): boolean | T {\n  const v = attr(node, name, fallBack);\n  return v == null ? fallBack : !!+v;\n}\n\nexport function dmlPercentAttr<T = number | null> (\n  node: Element,\n  name: string,\n  fallBack: T = null as unknown as T,\n): number | T {\n  const v = attr(node, name);\n  return v == null ? fallBack : +v * 0.001;\n}\n\nexport function numStrAttr<T = number | null> (\n  node: Element,\n  name: string,\n  fallBack: T = null as unknown as T,\n): number | string | T {\n  const v = attr(node, name);\n  if (v == null) { return fallBack; }\n  if (isFinite(+v)) { return +v; }\n  return v;\n}\n","export function pathDirname (path: string): string {\n  const end = path.lastIndexOf('/');\n  if (path.length && end >= 0) {\n    return (end === 0)\n      ? '/'\n      : path.slice(0, end);\n  }\n  return '.';\n}\n\nexport function pathBasename (path: string): string {\n  if (path) {\n    const end = path.lastIndexOf('/');\n    if (end > -1) {\n      return path.slice(end + 1);\n    }\n  }\n  return path;\n}\n\nfunction normalizeArray (parts: string[], allowAboveRoot: boolean): string[] {\n  const res: string[] = [];\n  for (const part of parts) {\n    if (!part || part === '.') continue;\n    if (part === '..') {\n      if (res.length && res[res.length - 1] !== '..') {\n        res.pop();\n      }\n      else if (allowAboveRoot) {\n        res.push('..');\n      }\n    }\n    else {\n      res.push(part);\n    }\n  }\n  return res;\n}\n\nexport function pathJoin (...paths: string[]): string {\n  for (const segment of paths) {\n    if (typeof segment !== 'string') {\n      throw new TypeError('Arguments to join must be strings');\n    }\n  }\n\n  const joined = paths.join('/');\n  if (!joined) return '.';\n\n  const isAbsolute = joined.startsWith('/');\n  const parts = joined.split('/').filter(Boolean);\n  const normalized = normalizeArray(parts, !isAbsolute);\n\n  let result = normalized.join('/');\n  if (isAbsolute) {\n    result = '/' + result;\n  }\n\n  return result || (isAbsolute ? '/' : '.');\n}\n","import type { StyleDefs } from '../handler/styles.ts';\nimport type { NamedStyle, Color as JSFColor, Style } from '@jsfkit/types';\n\n/** Style values that can (potentially) be omitted. */\ntype SkipValue = string | number | boolean | JSFColor | null;\n\n/**\n * Checks whether a style value should be omitted because it matches the given default. For\n * primitives, strict equality is used. For JSF Color objects, all properties of the skip value\n * must match those on val — but a colour with transforms is never skippable, since the transforms\n * produce a different resolved colour even if the base type and value are the same.\n */\nfunction isSkipValue (val: any, skip: SkipValue): boolean {\n  // Use strict equality if either value is a primitive.\n  if (typeof val !== 'object' || typeof skip !== 'object') {\n    return val === skip;\n  }\n  // Colours with transforms aren't skippable because the transforms produce a different resolved\n  // colour even if the base type and value are the same.\n  if (val.transforms?.length) { return false; }\n  for (const key in skip) {\n    // @ts-expect-error JSFColor is still a JS object at runtime\n    if (val[key] !== skip[key]) { return false; }\n  }\n  return true;\n}\n\nconst addStyle = (obj: Style, key: keyof Style, val: any, skip: SkipValue = null): number => {\n  if (val == null) {\n    return 0;\n  }\n  if (skip != null && isSkipValue(val, skip)) {\n    return 0;\n  }\n  obj[key] = val;\n  return 1;\n};\n\ntype Xf = StyleDefs['cellXf'][number];\n\nfunction convertXf (xf: Xf, styleDefs: StyleDefs): Style {\n  const s: Style = {};\n\n  if (xf.numFmtId) {\n    const numFmt = styleDefs.numFmts[xf.numFmtId];\n    if (typeof numFmt === 'string' && numFmt.toLowerCase() !== 'general') {\n      s.numberFormat = numFmt;\n    }\n  }\n\n  addStyle(s, 'horizontalAlignment', xf.hAlign);\n  addStyle(s, 'verticalAlignment', xf.vAlign, 'bottom');\n  addStyle(s, 'wrapText', !!xf.wrapText, false);\n  addStyle(s, 'shrinkToFit', !!xf.shrinkToFit, false);\n  addStyle(s, 'textRotation', xf.textRotation, 0);\n  addStyle(s, 'pivotButton', !!xf.pivotButton, false);\n\n  if (xf.font) {\n    const font = xf.font;\n    if (font.scheme) {\n      s.fontScheme = font.scheme;\n    }\n    else {\n      addStyle(s, 'fontFamily', font.name);\n    }\n    addStyle(s, 'fontSize', font.size);\n    addStyle(s, 'color', font.color, { type: 'theme', value: 'dk1' });\n    addStyle(s, 'underline', font.underline);\n    addStyle(s, 'bold', font.bold, false);\n    addStyle(s, 'italic', font.italic, false);\n  }\n\n  if (xf.fill) {\n    if (xf.fill.type && xf.fill.type !== 'none') {\n      if (xf.fill.type === 'solid') {\n        // if it's a solid fill, flip the foreground to the background\n        addStyle(s, 'fillColor', xf.fill.fg);\n      }\n      else {\n        addStyle(s, 'fillColor', xf.fill.bg);\n        addStyle(s, 'patternColor', xf.fill.fg);\n        addStyle(s, 'patternStyle', xf.fill.type, 'none');\n      }\n    }\n  }\n\n  if (xf.border) {\n    const { top, bottom, left, right } = xf.border;\n    addStyle(s, 'borderTopStyle', top?.style);\n    addStyle(s, 'borderTopColor', top?.color, { type: 'indexed', value: 64 });\n    addStyle(s, 'borderBottomStyle', bottom?.style);\n    addStyle(s, 'borderBottomColor', bottom?.color, { type: 'indexed', value: 64 });\n    addStyle(s, 'borderLeftStyle', left?.style);\n    addStyle(s, 'borderLeftColor', left?.color, { type: 'indexed', value: 64 });\n    addStyle(s, 'borderRightStyle', right?.style);\n    addStyle(s, 'borderRightColor', right?.color, { type: 'indexed', value: 64 });\n  }\n\n  return s;\n}\n\ntype NamedStyleResult = { namedStyles: Record<string, NamedStyle>, xfIdToName: Map<number, string> };\n\nfunction convertNamedStyles (styleDefs: StyleDefs): NamedStyleResult {\n  const namedStyles: Record<string, NamedStyle> = {};\n  const xfIdToName = new Map<number, string>();\n\n  for (const entry of styleDefs.cellStyles) {\n    const baseStyle = convertXf(styleDefs.cellStyleXfs[entry.xfId], styleDefs);\n\n    const cellStyle: NamedStyle = {\n      name: entry.name,\n      ...baseStyle,\n    };\n    if (entry.builtinId != null) {\n      cellStyle.builtinId = entry.builtinId;\n    }\n\n    namedStyles[entry.name] = cellStyle;\n    xfIdToName.set(entry.xfId, entry.name);\n  }\n\n  return { namedStyles, xfIdToName };\n}\n\nexport function convertStyles (styleDefs: StyleDefs): { styles: Style[], namedStyles: Record<string, NamedStyle> } {\n  const { namedStyles, xfIdToName } = convertNamedStyles(styleDefs);\n\n  const styles: Style[] = [];\n  for (let i = 0; i < styleDefs.cellXf.length; i++) {\n    const s = convertXf(styleDefs.cellXf[i], styleDefs);\n    const xf = styleDefs.cellXf[i];\n    if (xf.xfId != null) {\n      const name = xfIdToName.get(+xf.xfId);\n      if (name != null && name !== 'Normal') {\n        s.extendsStyle = name;\n      }\n    }\n    styles[i] = s;\n  }\n\n  return { styles, namedStyles };\n}\n","/**\n * Maximum Digit Width (MDW) for a workbook's Normal font.\n *\n * Excel records every column width in character units of the workbook Normal font's MDW — the pixel\n * advance of its widest digit, rounded. Converting those widths to pixels therefore needs the Normal\n * font's true MDW, not a fixed constant. `MDW = round(digitAdvance / unitsPerEm * pointSize)`, with\n * `pointSize` used directly as the em size (no 96/72 DPI factor) — the coordinate convention in which\n * Aptos Narrow 12 yields MDW 6.\n *\n * Metrics below are the digit advance / unitsPerEm read from the font files Excel for Mac renders\n * with — its bundled DFonts, except Georgia, which is not Office-bundled and comes from the macOS\n * system copy. Regenerate with `scripts/extract-digit-metrics.py`. Unknown fonts fall back to\n * {@link DEFAULT_MDW}; supply a resolver to cover arbitrary fonts.\n */\n\n/** Resolve an MDW for an arbitrary font. Returning null/undefined defers to the built-in table. */\nexport type MdwResolver = (fontFamily: string, fontSizePt: number) => number | null | undefined;\n\ntype DigitMetric = {\n  advance: number;\n  upm: number;\n};\n\nconst DIGIT_METRICS: Record<string, DigitMetric> = {\n  'aptos narrow': { advance: 1038, upm: 2048 },\n  'aptos': { advance: 1094, upm: 2048 },\n  'calibri': { advance: 1038, upm: 2048 },\n  'calibri light': { advance: 1038, upm: 2048 },\n  'arial': { advance: 1139, upm: 2048 },\n  'times new roman': { advance: 1024, upm: 2048 },\n  'verdana': { advance: 1302, upm: 2048 },\n  'georgia': { advance: 1257, upm: 2048 },\n  'tahoma': { advance: 1118, upm: 2048 },\n};\n\n/** Fallback MDW (Aptos Narrow / Calibri 11–12), used when the Normal font is unknown. */\nexport const DEFAULT_MDW = 6;\n\n/**\n * MDW for a known font at a given point size, or `undefined` if the font has no metrics and no\n * resolver supplies one.\n */\nexport function maxDigitWidth (fontFamily: string, fontSizePt: number, resolve?: MdwResolver): number | undefined {\n  const override = resolve?.(fontFamily, fontSizePt);\n  if (override != null) {\n    return override;\n  }\n  const metric = DIGIT_METRICS[fontFamily.trim().toLowerCase()];\n  if (metric === undefined) {\n    return undefined;\n  }\n  return Math.round((metric.advance / metric.upm) * fontSizePt);\n}\n\n/**\n * MDW for the Normal font, falling back to {@link DEFAULT_MDW} (with a warning) when the font is\n * unknown and no resolver covers it.\n */\nexport function resolveColumnMdw (\n  fontFamily: string,\n  fontSizePt: number,\n  options: { resolveMdw?: MdwResolver; warn?: (message: string) => void } = {},\n): number {\n  const mdw = maxDigitWidth(fontFamily, fontSizePt, options.resolveMdw);\n  if (mdw === undefined) {\n    options.warn?.(\n      `No digit-width metrics for Normal font \"${fontFamily}\" at ${fontSizePt}pt; column widths fall ` +\n      `back to MDW=${DEFAULT_MDW} and may be mis-scaled. Supply options.resolveMdw to handle this font.`,\n    );\n    return DEFAULT_MDW;\n  }\n  return mdw;\n}\n","const CFBF_HEAD = [ 0xD0, 0xCF, 0x11, 0xE0, 0xA1, 0xB1, 0x1A, 0xE1 ];\nconst ZIP_HEAD = [ 0x50, 0x4B, 0x03, 0x04 ];\n\nexport const FT_ZIP = 1;\nexport const FT_CFBF = 2;\n\nexport function getBinaryFileType (buffer: Buffer | ArrayBuffer): null | number {\n  const head = new Uint8Array(buffer);\n  // detect PKZip\n  if (\n    head[0] === ZIP_HEAD[0] &&\n    head[1] === ZIP_HEAD[1] &&\n    head[2] === ZIP_HEAD[2] &&\n    head[3] === ZIP_HEAD[3]) {\n    return FT_ZIP;\n  }\n  // detect CFBF (OLE Compound File)\n  if (CFBF_HEAD.every((d, i) => head[i] === d)) {\n    return FT_CFBF;\n  }\n  return null;\n}\n","import { INDEXED_COLORS, THEMES } from '@jsfkit/utils';\nimport type { Theme, DefinedName, External, Workbook } from '@jsfkit/types';\nimport type { MetaData } from './handler/metadata.ts';\nimport type { RDStruct } from './handler/rdstuct.ts';\nimport type { RDValue } from './handler/rdvalue.ts';\nimport type { Rel } from './handler/rels.ts';\nimport { DEFAULT_MDW } from './utils/mdw.ts';\nimport type { RelativeFormula } from './RelativeFormula.ts';\nimport type { ConversionOptions } from './index.ts';\n\ntype SheetLink = {\n  name: string;\n  rId: string;\n  index: number;\n  hidden: 0 | 1 | 2; // 0: visible, 1: hidden, 2: very hidden\n};\n\ntype RefLink = {\n  rel: Rel;\n  sheetName?: string;\n  type: string;\n};\n\nclass FormulaList {\n  container: Map<string, number>;\n\n  constructor () {\n    this.container = new Map<string, number>();\n  }\n\n  add (formula: string) {\n    if (this.container.has(formula)) {\n      return this.container.get(formula);\n    }\n    const index = this.container.size;\n    this.container.set(formula, index);\n    return index;\n  }\n\n  list () {\n    return this.container.keys();\n  }\n}\n\nexport class ConversionContext {\n  workbook: Workbook | null;\n  sst: string[];\n  options: ConversionOptions;\n  rels: Rel[];\n  drawingRels: Rel[];\n  theme: Theme;\n  indexedColors: string[];\n  nameDefs: Map<string, DefinedName>;\n  richStruct: RDStruct[];\n  richValues: RDValue[];\n  metadata: MetaData;\n  sheetLinks: SheetLink[];\n  externalLinks: External[];\n  filename: string;\n  _formulasR1C1: FormulaList;\n  _shared?: Map<number, RelativeFormula>;\n  _merged?: Record<string, string>;\n  _arrayFormula?: string[];\n  images: RefLink[];\n  isLikelyGSExport: boolean;\n  /**\n   * Excel includes an undocumented number in the workbook properties that hints which\n   * default theme to use if a theme is not included. Values include:\n   * - 0 (or absent): no default theme override\n   * - 123820: Office 2007 theme (uses Calibri)\n   * - 124226: Office 2010 theme (uses Calibri)\n   * - 164011: Office 2013 theme (uses Calibri)\n   * - 166925: Office 2013–2022 theme (uses Calibri)\n   * - 202300: Microsoft 365 (2023+) theme (uses Aptos Narrow)\n   */\n  defaultThemeVersion: string;\n  charts: RefLink[];\n  /** Max Digit Width of the workbook Normal font, used to convert column widths to pixels. */\n  normalMdw: number;\n\n  warn (message: string): void {\n    this.options.warn?.(message);\n  }\n\n  constructor () {\n    this.rels = [];\n    this.options = {};\n    this.workbook = null;\n    this.defaultThemeVersion = '202300';\n    this.theme = THEMES.default;\n    this.nameDefs = new Map();\n    this.indexedColors = [ ...INDEXED_COLORS ];\n    this.richStruct = [];\n    this.richValues = [];\n    this.drawingRels = [];\n    this.sst = [];\n    this.metadata = { cells: [], values: [] };\n    this.sheetLinks = [];\n    this.externalLinks = [];\n    this.filename = '';\n    this._formulasR1C1 = new FormulaList();\n    this.images = [];\n    this.isLikelyGSExport = false;\n    this.charts = [];\n    this.normalMdw = DEFAULT_MDW;\n  }\n}\n","/* eslint-disable @stylistic/array-element-newline */\n\nimport type { PageMargins } from '@jsfkit/types';\n\nexport const REL_PREFIXES = [\n  // standard\n  'http://schemas.microsoft.com/office/2006/relationships/',\n  'http://schemas.microsoft.com/office/2011/relationships/',\n  'http://schemas.microsoft.com/office/2014/relationships/',\n  'http://schemas.microsoft.com/office/2017/06/relationships/',\n  'http://schemas.microsoft.com/office/2017/10/relationships/',\n  'http://schemas.openxmlformats.org/officeDocument/2006/relationships/',\n  'http://schemas.openxmlformats.org/package/2006/relationships/',\n  // strict\n  'http://purl.oclc.org/ooxml/officeDocument/relationships/',\n];\n\n// switching to UK english has moved all $ to kr.\nexport const BUILTIN_FORMATS: Record<number, string> = {\n  0: 'General',\n  1: '0',\n  2: '0.00',\n  3: '#,##0',\n  4: '#,##0.00',\n  // These next four are locale dependent. For example the Icelandic locale uses `#,##0 \"kr.\";-#,##0 \"kr.\"`\n  5: '\"$\"#,##0_);(\"$\"#,##0)',\n  6: '\"$\"#,##0_);[Red](\"$\"#,##0)',\n  7: '\"$\"#,##0.00_);(\"$\"#,##0.00)',\n  8: '\"$\"#,##0.00_);[Red](\"$\"#,##0.00)',\n  9: '0%',\n  10: '0.00%',\n  11: '0.00E+00',\n  12: '# ?/?',\n  13: '# ??/??',\n  // Format 14, Excel's default \"Short Date\" is very locale dependent:\n  // It seem to use OS short date format: \"1/2/09\", \"2.1.1909\", \"02-01-1909\"\n  14: 'm/d/yy',\n  // Next three have locale dependent delimiter, and possibly more:\n  15: 'd-mmm-yy',\n  16: 'd-mmm',\n  17: 'mmm-yy',\n  18: 'h:mm AM/PM',\n  19: 'h:mm:ss AM/PM',\n  20: 'h:mm',\n  21: 'h:mm:ss',\n  37: '#,##0_);(#,##0)',\n  38: '#,##0_);[Red](#,##0)',\n  39: '#,##0.00_);(#,##0.00)',\n  40: '#,##0.00_);[Red](#,##0.00)',\n  41: '_(* #,##0_);_(* \\\\(#,##0\\\\);_(* \"-\"_);_(@_)',\n  42: '_(\"$\"* #,##0_);_(\"$\"* \\\\(#,##0\\\\);_(\"$\"* \"-\"_);_(@_)',\n  43: '_(* #,##0.00_);_(* \\\\(#,##0.00\\\\);_(* \"-\"??_);_(@_)',\n  44: '_(\"$\"* #,##0.00_);_(\"$\"* \\\\(#,##0.00\\\\);_(\"$\"* \"-\"??_);_(@_)',\n  45: 'mm:ss',\n  46: '[h]:mm:ss',\n  47: 'mm:ss.0',\n  48: '##0.0E+0',\n  49: '@',\n  55: 'yyyy/mm/dd',\n};\n\n// formats IDs that point to other IDs\n[ [ 22, 21 ], [ 23, 21 ], [ 24, 21 ], [ 25, 21 ], [ 26, 14 ],\n  [ 27, 37 ], [ 28, 38 ], [ 29, 39 ], [ 30, 40 ], [ 31, 41 ],\n  [ 32, 42 ], [ 33, 43 ], [ 34, 44 ], [ 35, 45 ], [ 36, 46 ] ]\n  .forEach(([ to, from ]) => {\n    BUILTIN_FORMATS[to] = BUILTIN_FORMATS[from];\n  });\n\n// 5.1.12.54 ST_SchemeColorVal (Scheme Color)\nexport const SCHEME_COLORS = {\n  lt1: 0,       // Light Color 1: Main Light Color 1\n  dk1: 1,       // Dark Color 1: Main dark color 1\n  lt2: 2,       // Light Color 2: Main Light Color 2\n  dk2: 3,       // Dark Color 2: Main dark color 2\n  accent1: 4,   // Accent Color 1: Extra scheme color 1\n  accent2: 5,   // Accent Color 2: Extra scheme color 2\n  accent3: 6,   // Accent Color 3: Extra scheme color 3\n  accent4: 7,   // Accent Color 4: Extra scheme color 4\n  accent5: 8,   // Accent Color 5: Extra scheme color 5\n  accent6: 9,   // Accent Color 6: Extra scheme color 6\n  hlink: 10,    // Hyperlink Color: Regular Hyperlink Color\n  folHlink: 11, // Followed Hyperlink Color: Followed Hyperlink Color\n  bg1: 0,       // Background Color 1: Semantic background color\n  bg2: 2,       // Background Color 2: Semantic additional background color\n  tx1: 1,       // Text Color 1: Semantic text color\n  tx2: 3,       // Text Color 2: Semantic additional text color\n  phClr: 0,     // Style Color: A color used in theme definitions which means to use the color of the style.\n};\n\n/** Inverse of {@link SCHEME_COLORS}: maps a zero-based index to the canonical scheme key name. */\nexport const INDEX_TO_SCHEME = [\n  'lt1',      //  0: Light 1\n  'dk1',      //  1: Dark 1\n  'lt2',      //  2: Light 2\n  'dk2',      //  3: Dark 2\n  'accent1',  //  4: Accent 1\n  'accent2',  //  5: Accent 2\n  'accent3',  //  6: Accent 3\n  'accent4',  //  7: Accent 4\n  'accent5',  //  8: Accent 5\n  'accent6',  //  9: Accent 6\n  'hlink',    // 10: Hyperlink\n  'folHlink', // 11: Followed Hyperlink\n];\n\n/**\n * Semantic scheme aliases that map to canonical scheme keys. Used when resolving theme colours\n * to RGBA, since ThemeColorScheme only has the canonical twelve properties.\n */\nexport const SCHEME_ALIASES: Record<string, string> = {\n  bg1: 'lt1',\n  bg2: 'lt2',\n  tx1: 'dk1',\n  tx2: 'dk2',\n  phClr: 'lt1',\n};\n\n// ST_ShapeType simple type (§5.1.12.56).\nexport const SHAPE_TYPE = [\n  'line',\n  'lineInv',\n  'triangle',\n  'rtTriangle',\n  'rect',\n  'diamond',\n  'parallelogram',\n  'trapezoid',\n  'nonIsoscelesTrapezoid',\n  'pentagon',\n  'hexagon',\n  'heptagon',\n  'octagon',\n  'decagon',\n  'dodecagon',\n  'star4',\n  'star5',\n  'star6',\n  'star7',\n  'star8',\n  'star10',\n  'star12',\n  'star16',\n  'star24',\n  'star32',\n  'roundRect',\n  'round1Rect',\n  'round2SameRect',\n  'round2DiagRect',\n  'snipRoundRect',\n  'snip1Rect',\n  'snip2SameRect',\n  'snip2DiagRect',\n  'plaque',\n  'ellipse',\n  'teardrop',\n  'homePlate',\n  'chevron',\n  'pieWedge',\n  'pie',\n  'blockArc',\n  'donut',\n  'noSmoking',\n  'rightArrow',\n  'leftArrow',\n  'upArrow',\n  'downArrow',\n  'stripedRightArrow',\n  'notchedRightArrow',\n  'bentUpArrow',\n  'leftRightArrow',\n  'upDownArrow',\n  'leftUpArrow',\n  'leftRightUpArrow',\n  'quadArrow',\n  'leftArrowCallout',\n  'rightArrowCallout',\n  'upArrowCallout',\n  'downArrowCallout',\n  'leftRightArrowCallout',\n  'upDownArrowCallout',\n  'quadArrowCallout',\n  'bentArrow',\n  'uturnArrow',\n  'circularArrow',\n  'leftCircularArrow',\n  'leftRightCircularArrow',\n  'curvedRightArrow',\n  'curvedLeftArrow',\n  'curvedUpArrow',\n  'curvedDownArrow',\n  'swooshArrow',\n  'cube',\n  'can',\n  'lightningBolt',\n  'heart',\n  'sun',\n  'moon',\n  'smileyFace',\n  'irregularSeal1',\n  'irregularSeal2',\n  'foldedCorner',\n  'bevel',\n  'frame',\n  'halfFrame',\n  'corner',\n  'diagStripe',\n  'chord',\n  'arc',\n  'leftBracket',\n  'rightBracket',\n  'leftBrace',\n  'rightBrace',\n  'bracketPair',\n  'bracePair',\n  'straightConnector1',\n  'bentConnector2',\n  'bentConnector3',\n  'bentConnector4',\n  'bentConnector5',\n  'curvedConnector2',\n  'curvedConnector3',\n  'curvedConnector4',\n  'curvedConnector5',\n  'callout1',\n  'callout2',\n  'callout3',\n  'accentCallout1',\n  'accentCallout2',\n  'accentCallout3',\n  'borderCallout1',\n  'borderCallout2',\n  'borderCallout3',\n  'accentBorderCallout1',\n  'accentBorderCallout2',\n  'accentBorderCallout3',\n  'wedgeRectCallout',\n  'wedgeRoundRectCallout',\n  'wedgeEllipseCallout',\n  'cloudCallout',\n  'cloud',\n  'ribbon',\n  'ribbon2',\n  'ellipseRibbon',\n  'ellipseRibbon2',\n  'leftRightRibbon',\n  'verticalScroll',\n  'horizontalScroll',\n  'wave',\n  'doubleWave',\n  'plus',\n  'flowChartProcess',\n  'flowChartDecision',\n  'flowChartInputOutput',\n  'flowChartPredefinedProcess',\n  'flowChartInternalStorage',\n  'flowChartDocument',\n  'flowChartMultidocument',\n  'flowChartTerminator',\n  'flowChartPreparation',\n  'flowChartManualInput',\n  'flowChartManualOperation',\n  'flowChartConnector',\n  'flowChartPunchedCard',\n  'flowChartPunchedTape',\n  'flowChartSummingJunction',\n  'flowChartOr',\n  'flowChartCollate',\n  'flowChartSort',\n  'flowChartExtract',\n  'flowChartMerge',\n  'flowChartOfflineStorage',\n  'flowChartOnlineStorage',\n  'flowChartMagneticTape',\n  'flowChartMagneticDisk',\n  'flowChartMagneticDrum',\n  'flowChartDisplay',\n  'flowChartDelay',\n  'flowChartAlternateProcess',\n  'flowChartOffpageConnector',\n  'actionButtonBlank',\n  'actionButtonHome',\n  'actionButtonHelp',\n  'actionButtonInformation',\n  'actionButtonForwardNext',\n  'actionButtonBackPrevious',\n  'actionButtonEnd',\n  'actionButtonBeginning',\n  'actionButtonReturn',\n  'actionButtonDocument',\n  'actionButtonSound',\n  'actionButtonMovie',\n  'gear6',\n  'gear9',\n  'funnel',\n  'mathPlus',\n  'mathMinus',\n  'mathMultiply',\n  'mathDivide',\n  'mathEqual',\n  'mathNotEqual',\n  'cornerTabs',\n  'squareTabs',\n  'plaqueTabs',\n  'chartX',\n  'chartStar',\n  'chartPlus',\n];\n\nexport const ERROR_NAMES = [\n  '#BLOCKED!',\n  '#CALC!',\n  '#DIV/0!',\n  '#FIELD!',\n  '#GETTING_DATA',\n  '#N/A',\n  '#NAME?',\n  '#NULL!',\n  '#NUM!',\n  '#REF!',\n  '#SPILL!',\n  '#UNKNOWN!',\n  '#VALUE!',\n];\n\n// Canonical default page margins (inches), per `Worksheet.pageMargins`'s defaults in JSF\nexport const DEFAULT_PAGE_MARGINS: PageMargins = {\n  left: 0.7,\n  right: 0.7,\n  top: 0.75,\n  bottom: 0.75,\n  header: 0.3,\n  footer: 0.3,\n};\n","import { Document } from '@borgar/simple-xml';\nimport { attr } from '../utils/attr.ts';\nimport { REL_PREFIXES } from '../constants.ts';\nimport { pathDirname, pathJoin } from '../utils/path.ts';\n\nexport type Rel = {\n  id: string;\n  type: string;\n  target: string;\n};\n\nexport function handlerRels (dom: Document | null | undefined, basepath = 'xl/workbook.xml'): Rel[] {\n  basepath = pathDirname(basepath);\n  const rels: Rel[] = [];\n  if (dom?.root) {\n    for (const d of dom.root.children) {\n      if (d.tagName === 'Relationship') {\n        const mode = attr(d, 'TargetMode');\n        let type = attr(d, 'Type') || '';\n        let target = attr(d, 'Target') || '';\n        for (const p of REL_PREFIXES) {\n          if (type.startsWith(p)) {\n            type = type.slice(p.length);\n            if (mode !== 'External') {\n              // Absolute paths start from package root; relative paths join with basepath\n              target = target.startsWith('/')\n                ? target.slice(1)\n                : pathJoin(basepath, target);\n            }\n            break;\n          }\n        }\n        rels.push({\n          id: attr(d, 'Id'),\n          type: type,\n          target: target,\n        });\n      }\n    }\n  }\n  return rels;\n}\n","import {\n  isFunction, isReference, parseA1Ref, parseStructRef,\n  tokenTypes, tokenize, parseR1C1Ref,\n  type ReferenceStructXlsx,\n  type ReferenceA1Xlsx,\n  type Token,\n  stringifyTokens,\n  isWhitespace,\n  isRange,\n} from '@borgar/fx/xlsx';\nimport {\n  stringifyA1Ref as stringifyA1RefCtx,\n  stringifyStructRef as stringifyStructRefCtx,\n  stringifyR1C1Ref as stringifyR1C1RefCtx,\n  type ReferenceStruct,\n  type ReferenceA1,\n  type ReferenceName,\n  type ReferenceNameXlsx,\n  type ReferenceR1C1Xlsx,\n  type ReferenceR1C1,\n} from '@borgar/fx';\n\ntype ExternalSubset = { name: string };\ntype ConversionContextSubset = { externalLinks: ExternalSubset[] };\ntype TrimTypes = 'both' | 'head' | 'tail';\n\n/**\n * Updates a reference:\n * - Translates from xlsx reference notation to context notation: [wb1]!A1 => wb!A1\n * - Handles rewriting external ref numbers to names: [1]!A1 => [wb.xlsx]!A1\n */\nfunction updateContext (\n  ref: ReferenceStructXlsx | ReferenceR1C1Xlsx | ReferenceA1Xlsx | ReferenceNameXlsx,\n  externalLinks?: ExternalSubset[] | null,\n): ReferenceStruct | ReferenceR1C1 | ReferenceA1 | ReferenceName {\n  const context: string[] = [];\n  if (ref.workbookName && isFinite(+ref.workbookName)) {\n    const wbIndex = +ref.workbookName - 1;\n    if (externalLinks?.[wbIndex]) {\n      context.push(externalLinks[wbIndex].name);\n    }\n    else {\n      throw new Error('#REF!');\n    }\n  }\n  if (ref.sheetName) {\n    context.push(ref.sheetName);\n  }\n  // @ts-ignore -- we're switching from xlsx to context mode here\n  ref.context = context;\n  return ref;\n}\n\nfunction findSubExpressionEnd (tokens: Token[], startIndex = 0) {\n  const stack = [];\n  for (let i = startIndex; i < tokens.length; i++) {\n    const t = tokens[i];\n    if (t.value === '(' || t.value === '{') {\n      stack.push(t.value);\n    }\n    else if (t.value === ')' || t.value === '}') {\n      const exp = stack.pop();\n      if (\n        (t.value === ')' && exp === '(') ||\n        (t.value === '}' && exp === '{')) {\n        if (!stack.length) {\n          return i;\n        }\n      }\n      else {\n        // paren mismatch\n        break;\n      }\n    }\n  }\n  return -1;\n}\n\nfunction trimExpression (tokens: Token[]): Token[] {\n  const t = tokens.concat();\n  while (isWhitespace(t.at(0))) { t.shift(); }\n  while (isWhitespace(t.at(-1))) { t.pop(); }\n  return t;\n}\n\nfunction updateRangeToken (\n  token: Token,\n  trim: TrimTypes | null,\n  externalLinks?: ExternalSubset[],\n  r1c1 = false,\n): Token {\n  if (r1c1) {\n    const ref = updateContext(parseR1C1Ref(token.value)!, externalLinks);\n    if (trim && 'range' in ref) {\n      ref.range.trim = trim;\n    }\n    token.value = stringifyR1C1RefCtx(ref as ReferenceR1C1 | ReferenceName);\n  }\n  else {\n    const ref = updateContext(parseA1Ref(token.value)!, externalLinks);\n    if (trim && 'range' in ref) {\n      ref.range.trim = trim;\n    }\n    token.value = stringifyA1RefCtx(ref as ReferenceA1 | ReferenceName);\n  }\n  return token;\n}\n\nconst TRIM_OPS: Record<string, TrimTypes> = {\n  '_xlfn._TRO_ALL': 'both',\n  '_TRO_ALL': 'both',\n  '_xlfn._TRO_LEADING': 'head',\n  '_TRO_LEADING': 'head',\n  '_xlfn._TRO_TRAILING': 'tail',\n  '_TRO_TRAILING': 'tail',\n};\n\nexport function normalizeFormulaTokens (tokens: Token[], wb?: ConversionContextSubset | null, r1c1 = false): Token[] {\n  const outTokens = [];\n\n  for (let i = 0; i < tokens.length; i++) {\n    const t = tokens[i];\n\n    if (isFunction(t)) {\n      const isSingle = t.value === '_xlfn.SINGLE' || t.value === 'SINGLE';\n      const isAnchorarray = t.value === '_xlfn.ANCHORARRAY' || t.value === 'ANCHORARRAY';\n      // Excel stores # and @ operators as functions.\n      if (isSingle || isAnchorarray) {\n        const j = findSubExpressionEnd(tokens, i);\n        if (j >= 0) {\n          const subExpression = trimExpression(tokens.slice(i + 2, j));\n          if (isSingle) { outTokens.push({ type: tokenTypes.OPERATOR, value: '@' }); }\n          outTokens.push(...normalizeFormulaTokens(subExpression, wb, r1c1));\n          if (isAnchorarray) { outTokens.push({ type: tokenTypes.OPERATOR, value: '#' }); }\n          i = j;\n        }\n        else {\n          // We cannot determine sub-expression, so preserve the token instead.\n          outTokens.push(t);\n        }\n      }\n      // Excel stores trim range operators as functions.\n      else if (t.value in TRIM_OPS) {\n        const j = findSubExpressionEnd(tokens, i);\n        // If this is a broken expression or we cannot determine\n        // sub-expression, we preserve the token instead.\n        let r = t;\n        if (j >= 0) {\n          const subExpression = trimExpression(tokens.slice(i + 2, j));\n          if (subExpression.length === 1 && isRange(subExpression[0])) {\n            r = updateRangeToken(subExpression[0], TRIM_OPS[t.value], wb?.externalLinks, r1c1);\n            i = j;\n          }\n        }\n        outTokens.push(r);\n      }\n      // Remove Excel internal namespaces from functions.\n      else {\n        t.value = t.value.replace(/^(?:_xlfn\\.|_xludf\\.|_xlws\\.)+/i, '');\n        outTokens.push(t);\n      }\n    }\n    else if (isReference(t)) {\n      if (t.type === tokenTypes.REF_NAMED) {\n        t.value = t.value.replace(/^(?:_xl[pn]m\\.)/ig, '');\n      }\n      // normalize external references\n      // xlsx reference syntax is different from Excel's runtime language syntax\n      // in that external references are braced indexes into a links list, using\n      // `[2]Sheet1!A1`, rather than including a name `[Workbook.xlsx]Sheet1!A1`\n      if (t.value.includes('[')) {\n        try {\n          if (t.type === tokenTypes.REF_STRUCT) {\n            const ref = parseStructRef(t.value)!;\n            // if (ref.table && wb.tables?.length) {\n            //   // TODO: omit the table prefix if current cell is within the table\n            // }\n            t.value = stringifyStructRefCtx(updateContext(ref, wb?.externalLinks));\n          }\n          else {\n            updateRangeToken(t, null, wb?.externalLinks, r1c1);\n          }\n        }\n        catch (err) {\n          t.value = '#REF!';\n        }\n      }\n      outTokens.push(t);\n    }\n    else {\n      outTokens.push(t);\n    }\n  }\n  return outTokens;\n}\n\nexport function normalizeFormula (formula: string, wb?: ConversionContextSubset | null): string {\n  // quickly test if work is actually needed\n  if (!/_xl(?:fn|udf|ws|pm|nm)\\.|(?:[^RC\"]\\[|^\\[|\\.:|:\\.)|ANCHORARRAY|SINGLE|_TRO_(?:ALL|LEADING|TRAILING)/i.test(formula)) {\n    return formula;\n  }\n  const tokens = tokenize(formula.normalize());\n  return stringifyTokens(normalizeFormulaTokens(tokens, wb));\n}\n","export function toInt<T extends string | number | null> (n: T): T extends null ? null : number {\n  return (n == null ? null : Math.floor(+n)) as never;\n}\n\nexport function toNum<T extends string | null> (n: T): T extends null ? null : number {\n  if (n == null) { return null as never; }\n  if (/[.Ee]/.test(n)) { return Number(n) as never; }\n  return toInt(n);\n}\n","import { Document } from '@borgar/simple-xml';\nimport { ConversionContext } from '../ConversionContext.ts';\nimport { attr, boolAttr, numAttr } from '../utils/attr.ts';\nimport { normalizeFormula } from '../utils/normalizeFormula.ts';\nimport { toInt } from '../utils/typecast.ts';\nimport type { DefinedName, Workbook, WorkbookView } from '@jsfkit/types';\n\nfunction isSafeInt (n: number | null | undefined): n is number {\n  return Number.isSafeInteger(n);\n}\n\nconst HIDDEN: Record<string, 0 | 1 | 2> = {\n  visible: 0,\n  hidden: 1,\n  veryHidden: 2,\n};\n\nexport function handlerWorkbook (dom: Document, context: ConversionContext): Workbook {\n  const wb: Workbook = {\n    name: context.filename,\n    sheets: [],\n    names: [],\n    // charts: [],\n    calculationProperties: {\n      iterate: false,\n      iterateCount: 100,\n      iterateDelta: 0.001,\n      epoch: 1900,\n    },\n    styles: [],\n    tables: [],\n    // externals: [],\n  };\n\n  dom.querySelectorAll('sheets > sheet')\n    .forEach(d => {\n      context.sheetLinks.push({\n        name: attr(d, 'name'),\n        index: numAttr(d, 'sheetId'),\n        rId: attr(d, 'r:id'),\n        hidden: HIDDEN[attr(d, 'state', 'visible')] ?? 0,\n      });\n    });\n\n  // FIXME: discard names that appear twice\n  dom.getElementsByTagName('definedName')\n    .forEach(d => {\n      const name: DefinedName = {\n        name: attr(d, 'name'),\n        value: normalizeFormula(d.textContent, context),\n      };\n      const hidden = boolAttr(d, 'hidden');\n      context.nameDefs.set(name.name, name);\n      if (hidden) {\n        return;\n      }\n      const localSheetId = attr(d, 'localSheetId');\n      if (localSheetId) {\n        name.scope = context.sheetLinks[+localSheetId].name;\n      }\n      wb.names!.push(name);\n    });\n\n  const pr = dom.querySelectorAll('workbook > workbookPr')[0];\n  const epoch = (pr && numAttr(pr, 'date1904')) ? 1904 : 1900;\n\n  // if theme is missing later, we can use this to determine which defaults to use\n  context.defaultThemeVersion = pr?.getAttribute('defaultThemeVersion') || '0';\n\n  const calcPr = dom.getElementsByTagName('calcPr')[0];\n  if (calcPr) {\n    const iterate = toInt(attr(calcPr, 'iterate'));\n    if (iterate && isFinite(iterate)) {\n      wb.calculationProperties = {\n        iterate: true,\n        iterateCount: toInt(numAttr(calcPr, 'iterateCount', 100)),\n        iterateDelta: numAttr(calcPr, 'iterateDelta', 0.001),\n        epoch: epoch,\n      };\n    }\n    const calcMode = attr(calcPr, 'calcMode');\n    if (calcMode === 'autoNoTable' || calcMode === 'manual') {\n      wb.calculationProperties!.calcMode = calcMode;\n    }\n    // ECMA-376 §18.2.2: `fullCalcOnLoad` is the writer's request to recalc on load;\n    // `forceFullCalc` is the same prescriptive signal (Excel sets it after a calc-engine version\n    // bump, distinct from fullCalcOnLoad). Either translates to the same consumer action, so\n    // collapse both onto the JSF's single `fullCalcOnLoad` flag.\n    if (boolAttr(calcPr, 'fullCalcOnLoad') || boolAttr(calcPr, 'forceFullCalc')) {\n      wb.calculationProperties!.fullCalcOnLoad = true;\n    }\n  }\n\n  wb.calculationProperties!.epoch = epoch;\n\n  // Store \"active sheet\" (the last-used sheet at save) for each workbook view. Excel supports\n  // multiple workbook views (window arrangements), though most files only have one.\n  const workbookViews = dom.querySelectorAll('bookViews > workbookView');\n  const views: WorkbookView[] = workbookViews.map(view => {\n    const activeSheet = toInt(numAttr(view, 'activeTab'));\n    if (isSafeInt(activeSheet) && activeSheet >= 0) {\n      return { activeSheet };\n    }\n    else {\n      return {};\n    }\n  });\n  // Workbook views can store many settings, but we only extract `activeTab` currently. This means\n  // we may produce views with no useful data (empty objects). We still store the array so that the\n  // indices continue to align with worksheet view references.\n  if (views.length) {\n    wb.views = views;\n  }\n\n  return wb;\n}\n","import { Document } from '@borgar/simple-xml';\nimport type { ConversionContext } from '../ConversionContext.ts';\nimport { numAttr } from '../utils/attr.ts';\n\nexport function handlerSharedStrings (dom: Document, context: ConversionContext): string[] {\n  const sst = dom.querySelectorAll('sst')[0];\n\n  const stringTable = sst.querySelectorAll('si').map(d => {\n    return d.querySelectorAll('t').map(t => t.textContent).join('');\n  });\n\n  const count = numAttr(sst, 'uniqueCount', 0);\n  if (count !== stringTable.length) {\n    context.warn(`String table: got ${stringTable.length} entries, but expected ${count}`);\n  }\n\n  return stringTable;\n}\n","import type { Document } from '@borgar/simple-xml';\nimport type { Person } from '@jsfkit/types';\nimport { attr } from '../utils/attr.ts';\n\nexport function handlerPersons (dom: Document): Person[] {\n  const persons: Person[] = [];\n\n  dom.querySelectorAll('personList > person')\n    .forEach(person => {\n      const id = attr(person, 'id');\n      const displayName = attr(person, 'displayName');\n\n      if (id && displayName) {\n        const p: Person = { id, displayName };\n\n        const userId = attr(person, 'userId');\n        if (userId) {\n          p.userId = userId;\n        }\n\n        const providerId = attr(person, 'providerId');\n        if (providerId) {\n          p.providerId = providerId;\n        }\n\n        persons.push(p);\n      }\n    });\n\n  return persons;\n}\n","import type { Element } from '@borgar/simple-xml';\nimport type { Color, ColorTransform } from '@jsfkit/types';\nimport { attr, numAttr } from '../utils/attr.ts';\n\n/**\n * Reads colour transforms from a DrawingML colour element's children and returns them as a\n * ColorTransform array.\n */\nfunction readTransforms (elm: Element): ColorTransform[] {\n  const transforms: ColorTransform[] = [];\n  elm.children.forEach(opElm => {\n    const tagName = opElm?.tagName;\n    // Booleans --- whole-colour operations.\n    if (tagName === 'comp' || tagName === 'gamma' || tagName === 'invGamma' ||\n        tagName === 'gray' || tagName === 'inv') {\n      transforms.push({ type: tagName });\n    }\n    // Percentage-based operations (OOXML stores these as 1/1000th of a percent)\n    else if (\n      tagName === 'alpha' || tagName === 'alphaMod' || tagName === 'alphaOff' ||\n      tagName === 'blue' || tagName === 'blueMod' || tagName === 'blueOff' ||\n      tagName === 'green' || tagName === 'greenMod' || tagName === 'greenOff' ||\n      tagName === 'red' || tagName === 'redMod' || tagName === 'redOff' ||\n      tagName === 'hueMod' ||\n      tagName === 'sat' || tagName === 'satMod' || tagName === 'satOff' ||\n      tagName === 'lum' || tagName === 'lumMod' || tagName === 'lumOff' ||\n      tagName === 'shade' || tagName === 'tint') {\n      transforms.push({ type: tagName, value: numAttr(opElm, 'val', 0) / 1000 } as ColorTransform);\n    }\n    // Degree-based operations (OOXML stores as 1/60,000th of a degree)\n    else if (tagName === 'hue' || tagName === 'hueOff') {\n      transforms.push({ type: tagName, value: numAttr(opElm, 'val', 0) / 60000 } as ColorTransform);\n    }\n  });\n  return transforms;\n}\n\n/**\n * Converts a DrawingML colour element to a JSF Color.\n */\nexport function readDrawingMLColor (elm: Element): Color | null {\n  const tagName = elm?.tagName;\n  let color: Color | null = null;\n\n  if (tagName === 'sysClr') {\n    const val = attr(elm, 'val');\n    if (val) {\n      color = { type: 'system', value: val } as Color;\n    }\n  }\n  else if (tagName === 'srgbClr') {\n    color = { type: 'srgb', value: attr(elm, 'val', '000000').toUpperCase() };\n  }\n  else if (tagName === 'scrgbClr') {\n    // OOXML scRGB values are stored as 1/1000th of a percent\n    color = {\n      type: 'scrgb',\n      red: numAttr(elm, 'r', 0) / 1000,\n      green: numAttr(elm, 'g', 0) / 1000,\n      blue: numAttr(elm, 'b', 0) / 1000,\n    };\n  }\n  else if (tagName === 'hslClr') {\n    // OOXML stores hue as 1/60,000th of a degree, saturation and lightness as 1/1000th of a percent\n    color = {\n      type: 'hsl',\n      hue: numAttr(elm, 'hue', 0) / 60000,\n      saturation: numAttr(elm, 'sat', 0) / 1000,\n      lightness: numAttr(elm, 'lum', 0) / 1000,\n    };\n  }\n  else if (tagName === 'prstClr') {\n    const val = attr(elm, 'val');\n    if (val) {\n      color = { type: 'preset', value: val } as Color;\n    }\n  }\n  else if (tagName === 'schemeClr') {\n    const val = attr(elm, 'val');\n    if (val) {\n      color = { type: 'theme', value: val } as Color;\n    }\n  }\n\n  if (color) {\n    const transforms = readTransforms(elm);\n    if (transforms.length) {\n      color.transforms = transforms;\n    }\n  }\n\n  return color;\n}\n","import type { Document, Element } from '@borgar/simple-xml';\n\nexport function getFirstChild (\n  parent: Element | Document | null | undefined,\n  tagName?: string | string[],\n): Element | undefined {\n  if (parent) {\n    if (typeof tagName === 'string' || !tagName) {\n      for (const child of parent.children) {\n        if (child.tagName === tagName || tagName === '*' || !tagName) {\n          return child;\n        }\n      }\n    }\n    else if (Array.isArray(tagName)) {\n      for (const child of parent.children) {\n        if (tagName.includes(child.tagName)) {\n          return child;\n        }\n      }\n    }\n  }\n}\n","/**\n * Add a property to an object if it is not \"redundant\".\n *\n * `val` will be added as `obj[key]` if:\n * - It is not `null` or `undefined`\n * - It is not equal to `skip` (assuming that is present)\n *\n * @param obj The object to write to\n * @param key The property name to write as\n * @param val The value to write\n * @param skip Default value that should be skipped if encountered.\n * @returns True if a value was written, else a false.\n */\nexport function addProp<T extends Record<string, any>, K extends keyof T> (\n  obj: T,\n  key: K,\n  val: T[K] | null | undefined,\n  skip: T[K] | null = null,\n): boolean {\n  if (val == null) {\n    return false;\n  }\n  if (skip === val) {\n    return false;\n  }\n  obj[key] = val;\n  return true;\n}\n","import type { Document, Element as XMLElement } from '@borgar/simple-xml';\nimport type { Theme, ThemeColorScheme, ThemeCustomColor, ThemeFontCollection } from '@jsfkit/types';\nimport { readDrawingMLColor } from '../color/readDrawingMLColor.ts';\nimport { attr } from '../utils/attr.ts';\nimport { getFirstChild } from '../utils/getFirstChild.ts';\nimport type { ConversionContext } from '../ConversionContext.ts';\nimport { addProp } from '../utils/addProp.ts';\nimport { THEMES } from '@jsfkit/utils';\n\nconst DEFAULT_FONT = 'Aptos Narrow';\n\n/**\n * Extracts a font collection from the given OOXML element, which should be either a `majorFont` or\n * `minorFont` element.\n *\n * The font collection must contain a `latin` element (although we include a fallback), plus\n * optional `ea` (east Asian) and `cs` (complex script) elements. These three specify a typeface to\n * use for that script.\n */\nfunction extractFontCollection (fontCollection: XMLElement) {\n  const latin = getFirstChild(fontCollection, 'latin');\n  const eastAsian = getFirstChild(fontCollection, 'ea');\n  const complexScript = getFirstChild(fontCollection, 'cs');\n\n  const font: ThemeFontCollection = {\n    latin: {\n      typeface: latin ? attr(latin, 'typeface', DEFAULT_FONT) : DEFAULT_FONT,\n    },\n  };\n  if (eastAsian) {\n    const typeface = attr(eastAsian, 'typeface');\n    if (typeface) {\n      font.eastAsian = { typeface };\n    }\n  }\n  if (complexScript) {\n    const typeface = attr(complexScript, 'typeface');\n    if (typeface) {\n      font.complexScript = { typeface };\n    }\n  }\n  return font;\n}\n\nexport function handlerTheme (dom: Document, context: ConversionContext): Theme {\n  const theme: Theme = structuredClone(THEMES[context.defaultThemeVersion] ?? THEMES.default);\n\n  // get a derivative of context but use our new theme\n  const ctx = Object.create(context);\n  ctx.theme = theme;\n\n  const themeElement = dom.querySelector('theme');\n  if (!themeElement) {\n    // exit early if we have no theme\n    return theme;\n  }\n  const themeName = attr(themeElement, 'name');\n  if (themeName) {\n    theme.name = themeName;\n  }\n\n  const themeElements = themeElement.querySelector('themeElements');\n\n  const clrScheme = getFirstChild(themeElements, 'clrScheme');\n  const clrSchemeName = clrScheme ? attr(clrScheme, 'name') : '';\n  if (clrSchemeName) {\n    theme.colorScheme.name = clrSchemeName;\n  }\n  clrScheme?.children.forEach(child => {\n    const key = child.tagName;\n    const colorElm = child.children[0];\n    if (key in theme.colorScheme && colorElm) {\n      const color = readDrawingMLColor(colorElm);\n      if (color) {\n        addProp(theme.colorScheme, key as keyof ThemeColorScheme, color);\n      }\n    }\n  });\n\n  const fontScheme = getFirstChild(themeElements, 'fontScheme');\n  const fontSchemeName = fontScheme ? attr(fontScheme, 'name') : '';\n  if (fontSchemeName) {\n    theme.fontScheme.name = fontSchemeName;\n  }\n  fontScheme?.children.forEach(d => {\n    if (d.tagName === 'majorFont') {\n      theme.fontScheme.major = extractFontCollection(d);\n    }\n    else if (d.tagName === 'minorFont') {\n      theme.fontScheme.minor = extractFontCollection(d);\n    }\n  });\n\n  // const fmtScheme = getFirstChild(themeElements, 'fmtScheme');\n\n  // const fillStyleLst = getFirstChild(fmtScheme, 'fillStyleLst');\n  // const fillList = [];\n  // fillStyleLst?.children.forEach(d => {\n  //   const fill = readFill(d, ctx);\n  //   if (fill) { fillList.push(fill); }\n  // });\n  // theme.fillList = fillList;\n\n  // const bgFillStyleLst = getFirstChild(fmtScheme, 'bgFillStyleLst');\n  // const bgFillList = [];\n  // bgFillStyleLst?.children.forEach(d => {\n  //   const fill = readFill(d, ctx);\n  //   if (fill) { bgFillList.push(fill); }\n  // });\n  // theme.bgFillList = bgFillList;\n\n  // const lnStyleLst = getFirstChild(fmtScheme, 'lnStyleLst');\n  // const lineList = [];\n  // lnStyleLst?.children.forEach(d => {});\n  // theme.lineList = lineList;\n\n  // const effectStyleLst = getFirstChild(fmtScheme, 'effectStyleLst');\n  // const effectList = [];\n  // effectStyleLst?.children.forEach(d => {});\n  // theme.effectList = effectList;\n\n  // const objectDefaults = dom.querySelector('theme > objectDefaults');\n\n  const custClrLst = getFirstChild(themeElement, 'custClrLst');\n  if (custClrLst) {\n    const customColors: ThemeCustomColor[] = [];\n    custClrLst.children.forEach(custClr => {\n      const colorElm = custClr.children[0];\n      const color = colorElm ? readDrawingMLColor(colorElm) : null;\n      if (color) {\n        const entry: ThemeCustomColor = { color };\n        const name = attr(custClr, 'name');\n        if (name) {\n          entry.name = name;\n        }\n        customColors.push(entry);\n      }\n    });\n    if (customColors.length > 0) {\n      theme.customColors = customColors;\n    }\n  }\n\n  return theme;\n}\n","import type { Document } from '@borgar/simple-xml';\nimport type { Workbook } from '@jsfkit/types';\nimport type { ConversionContext } from '../ConversionContext.ts';\n\n// This doesn't exist as a standalone type in JSF, and Workbook['meta']['app'] can't be accessed\ntype AppMeta = {\n  name?: string;\n  version?: string;\n  variant?: string;\n  confidence?: number;\n};\n\n/**\n * Parse threaded comments from xl/threadedComments{n}.xml.\n *\n * @param dom Parsed XML document from xl/threadedComments{n}.xml\n */\nexport function handlerAppdata (dom: Document | null | undefined, context: ConversionContext): Workbook['meta'] | undefined {\n  const appMeta: AppMeta = {};\n  if (dom) {\n    const appEl = dom.querySelector('Application');\n    if (appEl) {\n      const appText = appEl.textContent || '';\n      // Separate platform variant (e.g. \"Macintosh\") from the app name.\n      // Known pattern: \"Microsoft Macintosh Excel\" -> app \"Microsoft Excel\", appVariant \"Macintosh\"\n      const variantMatch = /^(Microsoft)\\s+(Macintosh|Windows)\\s+(Excel)$/i.exec(appText);\n      if (variantMatch) {\n        appMeta.name = `${variantMatch[1]} ${variantMatch[3]}`;\n        appMeta.variant = variantMatch[2];\n      }\n      else {\n        appMeta.name = appText;\n      }\n    }\n    const versionEl = dom.getElementsByTagName('AppVersion')[0];\n    if (versionEl?.textContent) {\n      appMeta.version = versionEl.textContent;\n    }\n    return { app: appMeta };\n  }\n  else if (context.isLikelyGSExport) {\n    appMeta.name = 'Google Sheets';\n    appMeta.confidence = 0.8;\n    return { app: appMeta };\n  }\n}\n","import type { Element } from '@borgar/simple-xml';\nimport type { Color, Theme } from '@jsfkit/types';\nimport { PRESET_COLORS, SYSTEM_COLORS } from '@jsfkit/utils';\nimport { attr, numAttr } from '../utils/attr.ts';\nimport { SCHEME_COLORS, INDEX_TO_SCHEME } from '../constants.ts';\nimport { readDrawingMLColor } from './readDrawingMLColor.ts';\n\n/**\n * Reads a color element and returns a Color container. This should handle any of the\n * multiple color elements found within an XSLX workbook:\n *\n * Color types found in (workbook) styles:\n * - `<color>`\n * - `<fgColor>`\n * - `<bgColor>`\n *\n * Color types found in DrawingML:\n * - `<schemeClr>`\n * - `<hslClr>`\n * - `<prstClr>`\n * - `<scrgbClr>`\n * - `<srgbClr>`\n * - `<sysClr>`\n */\nexport function readColor (elm: Element | undefined | null, theme: Theme): Color | undefined {\n  if (!elm) { return; }\n  const tagName = elm.tagName;\n  // §3.8.3 - bgColor\n  // §3.8.18 - fgColor\n  // §3.3.1.14 - color\n  if (tagName === 'color' || tagName === 'fgColor' || tagName === 'bgColor') {\n    // Element may have any of the following attributes:\n    // - [auto]    - A boolean value indicating the color is automatic and system color dependent.\n    // - [indexed] - References a color in indexedColors.\n    // - [rgb]     - Standard Alpha Red Green Blue color value (ARGB).\n    // - [theme]   - Index into the <clrScheme> collection, referencing a particular <sysClr> or\n    //               <srgbClr> value expressed in the Theme part.\n    // As well as:\n    // - [tint]    - Specifies the tint value applied to the color (-1.0 .. 1.0)\n    const auto = attr(elm, 'auto');\n    if (auto === '1' || auto === 'true') {\n      return { type: 'auto' };\n    }\n\n    let color: Color | undefined;\n    const argb = attr(elm, 'rgb', ''); // ARGB\n    if (argb) {\n      // Convert ARGB to 6-digit sRGB hex. If the alpha byte is not fully opaque, preserve it as an\n      // alpha transform since SrgbColor has no alpha field.\n      const hex = argb.length === 8 ? argb.slice(2) : argb;\n      color = { type: 'srgb', value: hex.toUpperCase() };\n      if (argb.length === 8) {\n        // NOTE: Yes, Excel removes this when it opens workbooks that have it, but we don't\n        // have tested confirmation yet if this is [always] safe to remove, so we preserve it\n        // leaving it up to consumers to discard the alpha channel at render-time.\n        const alphaPct = parseInt(argb.slice(0, 2), 16) / 255 * 100;\n        if (alphaPct < 100) {\n          color.transforms = [ { type: 'alpha', value: alphaPct } ];\n        }\n      }\n    }\n    else {\n      const indexed = attr(elm, 'indexed', '');\n      if (indexed) {\n        color = { type: 'indexed', value: +indexed };\n      }\n      else {\n        // theme: A zero-based index into the <clrScheme> collection (§20.1.6.2),\n        //        referencing a particular <sysClr> or <srgbClr> value expressed\n        //        in the Theme part.\n        const themeIdx = attr(elm, 'theme');\n        if (themeIdx && theme) {\n          const key = INDEX_TO_SCHEME[+themeIdx];\n          if (key) {\n            color = { type: 'theme', value: key } as Color;\n          }\n        }\n      }\n    }\n\n    if (!color) {\n      return;\n    }\n\n    // Convert the XLSX tint attribute to a shade or tint colour transform. XLSX tint is the\n    // proportion shifted towards white (positive) or black (negative), but the internal\n    // ColorTransform value uses the DrawingML convention: the percentage of the original\n    // colour to retain. So XLSX tint=0.4 (\"add 40% white\") becomes value=60 (\"retain 60%\").\n    const tint = numAttr(elm, 'tint', 0);\n    if (tint < 0) {\n      color.transforms = [ { type: 'shade', value: (1 + tint) * 100 } ];\n    }\n    else if (tint > 0) {\n      color.transforms = [ { type: 'tint', value: (1 - tint) * 100 } ];\n    }\n\n    return color;\n  }\n\n  // DrawingML colour elements — validate, then delegate to readDrawingMLColor()\n\n  // §5.1.2.2.29: Scheme Color - \"specifies a color bound to a user's theme\"\n  else if (tagName === 'schemeClr') {\n    const val = attr(elm, 'val');\n    if (val && val in SCHEME_COLORS) {\n      const jsfColor = readDrawingMLColor(elm);\n      if (jsfColor) {\n        return jsfColor;\n      }\n    }\n  }\n\n  // §5.1.2.2.13: HSL Color Model - \"a perceptual gamma of 2.2 is assumed\"\n  // §5.1.2.2.32: RGB Color Model - Hex Variant\n  // §5.1.2.2.30: RGB Color Model - Percentage Variant\n  else if (tagName === 'hslClr' || tagName === 'srgbClr' || tagName === 'scrgbClr') {\n    const jsfColor = readDrawingMLColor(elm);\n    if (jsfColor) {\n      return jsfColor;\n    }\n  }\n\n  // §5.1.2.2.22: Preset Color\n  else if (tagName === 'prstClr') {\n    const val = attr(elm, 'val');\n    if (val && val in PRESET_COLORS) {\n      const jsfColor = readDrawingMLColor(elm);\n      if (jsfColor) {\n        return jsfColor;\n      }\n    }\n  }\n\n  // §5.1.2.2.33: System Color\n  else if (tagName === 'sysClr') {\n    // §5.1.12.58: Specifies the system color value\n    const val = attr(elm, 'val');\n    if (val && SYSTEM_COLORS[val.toLowerCase()]) {\n      // FIXME: JSF Color has no equivalent of sysClr's lastClr (§5.1.12.28, specifies the colour\n      // value that was last computed by the generating application).\n      const jsfColor = readDrawingMLColor(elm);\n      if (jsfColor) {\n        return jsfColor;\n      }\n    }\n  }\n  else if (tagName) {\n    throw new Error('Unknown color element: ' + tagName);\n  }\n}\n","import type { Document, Element } from '@borgar/simple-xml';\nimport type { Color, Theme } from '@jsfkit/types';\nimport { attr, numAttr } from '../utils/attr.ts';\nimport { BUILTIN_FORMATS } from '../constants.ts';\nimport type { ConversionContext } from '../ConversionContext.ts';\nimport { readColor } from '../color/readColor.ts';\nimport { addProp } from '../utils/addProp.ts';\n\nfunction valOfSubNode (node: Element, subNodeName: string): string | undefined {\n  const subNode = node.querySelectorAll(subNodeName)[0];\n  if (subNode) {\n    return attr(subNode, 'val') ?? undefined;\n  }\n}\n\ntype BorderSide = 'left' | 'right' | 'top' | 'bottom';\ntype Border = { style: string, color?: Color };\ntype Borders = Record<BorderSide, Border | undefined>;\ntype Fill = {\n  type: string,\n  fg?: Color\n  bg?: Color\n};\ntype Font = {\n  size?: number,\n  name?: string,\n  scheme?: 'major' | 'minor',\n  underline?: string,\n  bold: boolean,\n  italic: boolean,\n  color?: Color,\n};\n\nexport type NamedStyleEntry = {\n  name: string;\n  xfId: number;\n  builtinId?: number;\n};\n\nexport type StyleDefs = {\n  cellStyleXfs: Xf[];\n  cellXf: Xf[];\n  cellStyles: NamedStyleEntry[];\n  fill: Fill[];\n  font: Font[];\n  numFmts: Record<number, string>;\n  border: Borders[];\n};\n\ntype Xf = {\n  xfId?: number;\n  numFmtId?: number;\n  numFmt?: string;\n  fillId?: number;\n  fill?: Fill;\n  fontId?: number;\n  font?: Font;\n  borderId?: number;\n  border?: Borders;\n  hAlign?: string;\n  vAlign?: string;\n  wrapText?: boolean;\n  shrinkToFit?: boolean;\n  textRotation?: number;\n  pivotButton?: boolean;\n};\n\nfunction readXf (d: Element, styles: StyleDefs) {\n  const xf: Xf = {};\n\n  const xfId = numAttr(d, 'xfId'); // index into cellStyleXfs\n  if (xfId != null) { xf.xfId = xfId; }\n\n  const numFmtId = attr(d, 'numFmtId');\n  if (numFmtId) {\n    xf.numFmtId = +numFmtId;\n    xf.numFmt = styles.numFmts[+numFmtId];\n  }\n\n  // Spec says you should only read fill if `applyFill` bool is set\n  // but Excel seems to ignore that property and read fill anyway\n  const fillId = attr(d, 'fillId') ?? null;\n  if (fillId) {\n    xf.fillId = +fillId;\n    xf.fill = styles.fill[+fillId];\n  }\n\n  const fontId = attr(d, 'fontId');\n  if (fontId != null) {\n    xf.fontId = +fontId;\n    xf.font = styles.font[+fontId];\n  }\n\n  const borderId = attr(d, 'borderId');\n  if (borderId) {\n    xf.borderId = +borderId;\n    xf.border = styles.border[+borderId];\n  }\n\n  const align = d.querySelectorAll('alignment')[0];\n  if (align) {\n    const hAlign = attr(align, 'horizontal');\n    const vAlign = attr(align, 'vertical');\n    const wrapText = attr(align, 'wrapText');\n    const shrinkToFit = attr(align, 'shrinkToFit');\n    const textRotation = attr(align, 'textRotation');\n    if (hAlign) { xf.hAlign = hAlign; }\n    if (vAlign) { xf.vAlign = vAlign; }\n    if (wrapText) { xf.wrapText = !!+wrapText; }\n    if (shrinkToFit) { xf.shrinkToFit = !!+shrinkToFit; }\n    if (textRotation) { xf.textRotation = +textRotation; }\n  }\n\n  const pivotButton = attr(d, 'pivotButton');\n  if (pivotButton) { xf.pivotButton = !!+pivotButton; }\n\n  return xf;\n}\n\nfunction readBorder (\n  node: Element,\n  side: BorderSide | 'start' | 'end',\n  theme: Theme,\n): Border | undefined {\n  const b = node.querySelectorAll(side)[0];\n  if (b) {\n    const color = readColor(b.querySelectorAll('color')[0], theme);\n    const style = attr(b, 'style');\n    if (style) {\n      return { style: style, color: color };\n    }\n  }\n}\n\nfunction readFont (node: Element, theme: Theme): Font {\n  const u = node.querySelectorAll('u')[0];\n  const b = node.querySelectorAll('b')[0];\n  const i = node.querySelectorAll('i')[0];\n  const name = valOfSubNode(node, 'name');\n  const scheme = valOfSubNode(node, 'scheme');\n  const sz = valOfSubNode(node, 'sz');\n  return {\n    size: sz ? +sz : undefined,\n    name: name === 'Calibri (Body)' ? 'Calibri' : name,\n    scheme: (scheme === 'major' || scheme === 'minor') ? scheme : undefined,\n    underline: u ? attr(u, 'val', 'single') : undefined,\n    bold: !!b,\n    italic: !!i,\n    color: readColor(node.querySelectorAll('color')[0], theme),\n  };\n}\n\nexport function handlerStyles (dom: Document, context: ConversionContext): StyleDefs {\n  const styles: StyleDefs = {\n    cellStyleXfs: [],\n    cellXf: [],\n    cellStyles: [],\n    fill: [],\n    font: [],\n    numFmts: Object.assign({}, BUILTIN_FORMATS),\n    border: [],\n  };\n\n  // update indexed colors for this conversion\n  dom.querySelectorAll('colors > indexedColors > rgbColor')\n    .forEach((node, i) => {\n      context.indexedColors[i] = attr(node, 'rgb');\n    });\n\n  dom.querySelectorAll('numFmts > numFmt')\n    .forEach(node => {\n      const fId = numAttr(node, 'numFmtId');\n      const code = attr(node, 'formatCode');\n      if (fId != null && code != null) {\n        styles.numFmts[fId] = code;\n      }\n    });\n\n  dom.querySelectorAll('fonts > font')\n    .forEach(node => {\n      styles.font.push(readFont(node, context.theme));\n    });\n\n  dom.querySelectorAll('fills > fill > patternFill')\n    .forEach(fp => {\n      const fgColor = fp.querySelector('fgColor');\n      const bgColor = fp.querySelector('bgColor');\n      const fill: Fill = { type: attr(fp, 'patternType', 'none') };\n      if (fgColor) {\n        fill.fg = readColor(fgColor, context.theme);\n      }\n      if (bgColor) {\n        fill.bg = readColor(bgColor, context.theme);\n      }\n      styles.fill.push(fill);\n    });\n\n  dom.querySelectorAll('borders > border')\n    .forEach(d => {\n      const borderDefs: Borders = {\n        left: readBorder(d, 'left', context.theme) || readBorder(d, 'start', context.theme),\n        right: readBorder(d, 'right', context.theme) || readBorder(d, 'end', context.theme),\n        top: readBorder(d, 'top', context.theme),\n        bottom: readBorder(d, 'bottom', context.theme),\n      };\n      styles.border.push(borderDefs);\n    });\n\n  // level 1 (named cell styles)\n  dom.querySelectorAll('cellStyleXfs > xf')\n    .forEach(d => styles.cellStyleXfs.push(readXf(d, styles)));\n  // level 2 (applied formatting)\n  dom.querySelectorAll('cellXfs > xf')\n    .forEach(d => {\n      const xf = readXf(d, styles);\n      if (xf.xfId != null) {\n        const sxf: Xf = styles.cellStyleXfs[xf.xfId];\n        for (const key in sxf) {\n          const k = key as keyof Xf;\n          if (xf[k] == null) {\n            addProp(xf, k, sxf[k]);\n          }\n        }\n      }\n      styles.cellXf.push(xf);\n    });\n\n  // named cell styles (maps names + builtinId to cellStyleXf indices)\n  dom.querySelectorAll('cellStyles > cellStyle')\n    .forEach(d => {\n      const name = attr(d, 'name');\n      const xfId = attr(d, 'xfId');\n      if (name != null && xfId != null) {\n        const entry: NamedStyleEntry = { name, xfId: +xfId };\n        const builtinId = attr(d, 'builtinId');\n        if (builtinId != null) {\n          entry.builtinId = +builtinId;\n        }\n        styles.cellStyles.push(entry);\n      }\n    });\n\n  return styles;\n}\n","import { Document } from '@borgar/simple-xml';\nimport { attr } from '../utils/attr.ts';\n\nexport type RDStructKey = {\n  name: string;\n  type: string;\n};\n\nexport type RDStruct = {\n  type: string;\n  keys: RDStructKey[];\n};\n\nexport function handlerRDStruct (dom: Document): RDStruct[] {\n  const structures: RDStruct[] = [];\n\n  dom.querySelectorAll('rvStructures > s')\n    .forEach(s => {\n      structures.push({\n        type: attr(s, 't'),\n        keys: s.getElementsByTagName('k').map(k => ({\n          name: attr(k, 'n'),\n          type: attr(k, 't'),\n        })),\n      });\n    });\n\n  return structures;\n}\n","import { Document } from '@borgar/simple-xml';\nimport { numAttr } from '../utils/attr.ts';\nimport { ConversionContext } from '../ConversionContext.ts';\n\nexport type RDValue = Record<string, string | number>;\n\nexport function handlerRDValue (dom: Document, context: ConversionContext): RDValue[] {\n  const values: RDValue[] = [];\n  const structures = context.richStruct || [];\n\n  dom.querySelectorAll('rvData > rv')\n    .forEach(rv => {\n      const nth = numAttr(rv, 's', 0);\n      const s = structures[nth];\n      const val: Record<string, string | number> = { _type: s.type };\n\n      rv.getElementsByTagName('v')\n        .forEach((k, i) => {\n          const def = s.keys[i];\n          let v: string | number = k.textContent;\n          // FIXME: what other types exist? (a spec on it does not)\n          if (def.type === 'i') {\n            v = Math.floor(+v);\n          }\n          val[def.name] = v;\n        });\n\n      values.push(val);\n    });\n\n  return values;\n}\n","import type { Document, Element } from '@borgar/simple-xml';\nimport type { ConversionContext } from '../ConversionContext.ts';\nimport { attr, numAttr } from '../utils/attr.ts';\n\ntype MetaTableValue = Record<string, number | string>;\n\ntype MetaTable = {\n  name: string;\n  values: MetaTableValue[];\n};\n\nexport type MetaData = {\n  cells: MetaTableValue[];\n  values: MetaTableValue[];\n};\n\nfunction parseBk (bk: Element, tables: MetaTable[]): MetaTableValue {\n  const rc = bk.getElementsByTagName('rc')[0];\n  const t = numAttr(rc, 't', 0);\n  const v = numAttr(rc, 'v', 0);\n  const r = tables[t - 1];\n  if (!r?.values[v]) {\n    throw new Error(`Can't reach meta-value ${t}/${v} in metadata.xml`);\n  }\n  return r.values[v];\n}\n\nexport function handlerMetaData (dom: Document, context: ConversionContext): MetaData {\n  const tables: MetaTable[] = [];\n\n  dom.getElementsByTagName('futureMetadata')\n    .forEach(fMD => {\n      const table: MetaTableValue[] = [];\n      const metaName = attr(fMD, 'name') ?? '';\n      tables.push({ name: metaName, values: table });\n      fMD.querySelectorAll('bk ext')\n        .forEach(ext => {\n          if (metaName === 'XLDAPR') {\n            const dAP = ext.getElementsByTagName('dynamicArrayProperties')[0];\n            table.push({\n              _type: '_dynamicArray',\n              fCollapsed: numAttr(dAP, 'fCollapsed'),\n              fDynamic: numAttr(dAP, 'fDynamic'),\n            });\n          }\n          else if (metaName === 'XLRICHVALUE') {\n            const rvb = ext.getElementsByTagName('rvb')[0];\n            table.push(context.richValues[numAttr(rvb, 'i', 0)]);\n          }\n        });\n    });\n\n  // Cell metadata contains information about the cell itself.\n  const cells = dom.querySelectorAll('cellMetadata > bk')\n    .map(bk => parseBk(bk, tables));\n\n  // Value metadata is information about the value of a particular cell.\n  // Value metadata properties can be propagated along with the value as\n  // it is referenced in formulas.\n  const values = dom.querySelectorAll('valueMetadata > bk')\n    .map(bk => parseBk(bk, tables));\n\n  return {\n    values: values,\n    cells: cells,\n  };\n}\n","import type { Document } from '@borgar/simple-xml';\nimport type { HyperlinkTextRun, MentionTextRun, ThreadedComment } from '@jsfkit/types';\nimport { attr, numAttr } from '../utils/attr.ts';\n\nfunction isInt (v: unknown): v is number {\n  return Number.isInteger(v);\n}\n\n/**\n * Parse threaded comments from xl/threadedComments{n}.xml.\n *\n * @param dom Parsed XML document from xl/threadedComments{n}.xml\n */\nexport function handlerComments (dom: Document): ThreadedComment[] {\n  const comments: ThreadedComment[] = [];\n\n  dom.getElementsByTagName('threadedComment')\n    .forEach(node => {\n      const id = attr(node, 'id');\n      const ref = attr(node, 'ref');\n      const personId = attr(node, 'personId');\n      const dT = attr(node, 'dT');\n\n      // Short-circuit for invalid comment.\n      if (!id || !ref || !personId) return;\n\n      const textNode = node.getElementsByTagName('text')[0];\n      const text = textNode?.textContent || '';\n\n      const comment: ThreadedComment = {\n        id,\n        ref,\n        personId,\n        text,\n      };\n\n      // Add the time of the comment if there is one.\n      if (dT) {\n        const timestamp = Date.parse(dT);\n        if (!Number.isNaN(timestamp)) {\n          comment.datetime = new Date(timestamp).toISOString();\n        }\n      }\n\n      // A parent id means this is a threaded reply to an earlier comment.\n      const parentId = attr(node, 'parentId');\n      if (parentId) {\n        comment.parentId = parentId;\n      }\n\n      // Excel uses the \"done\" flag to indicate whether a thread is resolved.\n      const done = attr(node, 'done');\n      if (done === '1' || done === 'true') {\n        comment.resolved = true;\n      }\n\n      // Mentions are parts of comment text that provide references to people.\n      const runs: (MentionTextRun | HyperlinkTextRun)[] = [];\n      node.querySelectorAll('mentions > mention')\n        .forEach(mentionNode => {\n          const mentionPersonId = attr(mentionNode, 'mentionpersonId');\n          const start = numAttr(mentionNode, 'startIndex');\n          const length = numAttr(mentionNode, 'length');\n\n          // Skip mentions with invalid data (all fields required).\n          if (mentionPersonId && isInt(start) && isInt(length)) {\n            runs.push({\n              type: 'mention',\n              personId: mentionPersonId,\n              start: start,\n              end: start + length,\n            });\n          }\n        });\n\n      // Hyperlinks. From an extension to threaded comments, represents text in the comment that\n      // should be a clickable link.\n      // <https://learn.microsoft.com/openspecs/office_standards/ms-xlsx/6b0fef4e-008b-44de-b8ae-b16b3ffcd0fe>\n      const extLst = node.getElementsByTagName('extLst')[0];\n      if (extLst) {\n        const ext = extLst.children.find(e => attr(e, 'uri') === '{F7C98A9C-CBB3-438F-8F68-D28B6AF4A901}');\n        if (ext) {\n          ext.getElementsByTagName('hyperlink')\n            .forEach(hyperlinkNode => {\n              const start = numAttr(hyperlinkNode, 'startIndex');\n              const length = numAttr(hyperlinkNode, 'length');\n              const url = attr(hyperlinkNode, 'url');\n\n              // Skip invalid hyperlinks (all fields required).\n              if (url && isInt(start) && isInt(length)) {\n                runs.push({\n                  type: 'hyperlink',\n                  url: url,\n                  start: start,\n                  end: start + length,\n                });\n              }\n            });\n        }\n      }\n      if (runs.length > 0) {\n        comment.runs = runs;\n      }\n\n      comments.push(comment);\n    });\n\n  return comments;\n}\n","import type { Document } from '@borgar/simple-xml';\nimport type { Note } from '@jsfkit/types';\nimport { attr, numAttr } from '../utils/attr.ts';\n\n/**\n * Parse notes from xl/comments{n}.xml.\n *\n * Originally known as comments and since replaced by threaded comments.\n *\n * TODO: Currently rich text and the underlying VML drawing object are discarded during import.\n *\n * @param dom Parsed XML document from xl/comments{n}.xml\n */\nexport function handlerNotes (dom: Document): Note[] {\n  const notes: Note[] = [];\n\n  const authors: string[] = [];\n  dom.querySelectorAll('authors > author')\n    .forEach(author => {\n      authors.push(author.textContent || '');\n    });\n\n  dom.querySelectorAll('commentList > comment')\n    .forEach(commentNode => {\n      const ref = attr(commentNode, 'ref');\n      if (!ref) return;\n\n      const authorId = numAttr(commentNode, 'authorId') ?? -1;\n      const author = authors[authorId] || '';\n\n      // For backwards-compatibility, Excel duplicates threaded comments as notes. They have an\n      // author name in the form \"tc={GUID}\". Skip them during import.\n      if (author.startsWith('tc={')) return;\n\n      // Extract text content from <text> element. Text may be in <text><t> or <text><r><t> (rich\n      // text runs). All the rich text is discarded, only the plain text is stored.\n      const textNodes = commentNode.querySelectorAll('text t');\n      const text = Array.from(textNodes)\n        .map(t => t.textContent || '')\n        .join('');\n\n      notes.push({ ref, author, text });\n    });\n\n  return notes;\n}\n","import type { GridSize } from '@jsfkit/types';\n\n/**\n * Run-length encode a list of grid sizes. When `defaultSize` is given, entries whose size equals\n * it (and that carry no style) are dropped as redundant. Omit it to keep every explicit size: an\n * explicit row height is a PINNED height even when it happens to equal the sheet default, and\n * Excel renders pinned and auto heights differently (auto rows derive from the font).\n */\nexport function rle (list: GridSize[], defaultSize?: number): GridSize[] {\n  let lastItem: GridSize = {\n    start: NaN,\n    end: NaN,\n    size: NaN,\n    s: NaN,\n  };\n  let current: GridSize;\n  return list\n    .sort((a, b) => a.start - b.start)\n    .reduce((newList: GridSize[], item: GridSize) => {\n      const nextInSeq = lastItem.end + 1 === item.start;\n      const sameSize = lastItem.size === item.size;\n      const sameStyle = lastItem.s === item.s;\n      if (nextInSeq && sameSize && sameStyle) {\n        current.end = item.end;\n      }\n      else {\n        current = {\n          start: item.start,\n          end: item.end,\n        };\n        if (item.size != null) {\n          current.size = item.size;\n        }\n        if (item.s != null) {\n          current.s = item.s;\n        }\n        newList.push(current);\n      }\n      lastItem = item;\n      return newList;\n    }, [])\n    .filter(d => {\n      const hasSize = d.size != null && (defaultSize == null || d.size !== defaultSize);\n      const hasStyle = d.s != null;\n      return hasSize || hasStyle;\n    });\n}\n","export function unescape (str: string): string {\n  return str.replace(\n    /_x([\\da-f]{4})_/gi,\n    (m, n) => String.fromCharCode(parseInt(n, 16)),\n  );\n}\n","import { type Token, tokenize, translateTokensToR1C1, translateTokensToA1, stringifyTokens } from '@borgar/fx/xlsx';\n\nexport class RelativeFormula {\n  anchorA1: string;\n  formula: string;\n  relative: Token[] | undefined;\n\n  constructor (formula: string, anchorCell: string) {\n    this.anchorA1 = anchorCell;\n    this.formula = formula;\n  }\n\n  getR1C1Tokens (): Token[] {\n    if (this.relative) {\n      return this.relative;\n    }\n    const tokens = tokenize(this.formula, { allowTernary: true });\n    this.relative = translateTokensToR1C1(tokens, this.anchorA1);\n    return this.relative;\n  }\n\n  translate (offsetCell: string): string {\n    if (offsetCell === this.anchorA1) {\n      // just pass the formula back\n      return this.formula;\n    }\n    const exprA1 = translateTokensToA1(this.getR1C1Tokens(), offsetCell);\n    return stringifyTokens(exprA1);\n  }\n}\n","export function dateToSerial (date: Date): number | null {\n  // Many timezones are offset in seconds but getTimezoneOffset() returns\n  // time \"rounded\" to minutes so it is basically usable. 😿\n  const dt = new Date();\n  dt.setUTCFullYear(\n    date.getFullYear(),\n    date.getMonth(),\n    date.getDate(),\n  );\n  dt.setUTCHours(\n    date.getHours(),\n    date.getMinutes(),\n    date.getSeconds(),\n    date.getMilliseconds(),\n  );\n  // timestamp\n  const ts = dt.valueOf();\n  if (ts != null && isFinite(ts)) {\n    const d = (ts / 864e5);\n    return d - (d <= -25509 ? -25568 : -25569);\n  }\n  return null;\n}\n","export class InvalidFileError extends Error {}\nexport class EncryptionError extends Error {}\nexport class MissingSheetError extends Error {}\nexport class UnsupportedError extends Error {}\n","export function parseTimeToSerial (ts: string): number {\n  const match = /^(\\d{1,2})(?::(\\d{1,2}))?(?::(\\d{1,2}))?(\\.\\d+)?$/.exec(ts);\n  if (match) {\n    const [ , h, m, s, f ] = match;\n    return (+h / 24) + // hours\n           (Number(m) / 1440) + // minutes\n           (Number(s + (f || '')) / 86400); // seconds with fraction\n  }\n  return 0;\n}\n","import { tokenize, translateTokensToR1C1, stringifyTokens, type Token } from '@borgar/fx/xlsx';\nimport { Element } from '@borgar/simple-xml';\nimport { toInt, toNum } from '../utils/typecast.ts';\nimport { attr, boolAttr, numAttr } from '../utils/attr.ts';\nimport { unescape } from '../utils/unescape.ts';\nimport { RelativeFormula } from '../RelativeFormula.ts';\nimport { normalizeFormula, normalizeFormulaTokens } from '../utils/normalizeFormula.ts';\nimport { ConversionContext } from '../ConversionContext.ts';\nimport type { Cell, DataTable } from '@jsfkit/types';\nimport { dateToSerial } from '../utils/dateToSerial.ts';\nimport { UnsupportedError } from '../errors.ts';\nimport { ERROR_NAMES } from '../constants.ts';\nimport { getFirstChild } from '../utils/getFirstChild.ts';\nimport { parseTimeToSerial } from '../utils/parseTimeToSerial.ts';\n\nexport const relevantStyle = (obj?: Record<string, any>): boolean => {\n  if (!obj) {\n    return false;\n  }\n  return !!(\n    // obj['number-format'] ||\n    obj.fillColor ||\n    obj.patternColor ||\n    obj.patternStyle ||\n    obj.borderTopStyle ||\n    obj.borderLeftStyle ||\n    obj.borderBottomStyle ||\n    obj.borderRightStyle\n  );\n};\n\nfunction prepFormula (formula: string | RelativeFormula, cellId: string, context: ConversionContext) {\n  if (formula) {\n    if (context.options.cellFormulas) {\n      if (typeof formula === 'string') {\n        return normalizeFormula(formula, context);\n      }\n      return normalizeFormula(formula.translate(cellId), context);\n    }\n    else {\n      let tokens: Token[];\n      if (typeof formula === 'string') {\n        tokens = tokenize(formula, { allowTernary: true });\n        tokens = translateTokensToR1C1(tokens, cellId);\n        tokens = normalizeFormulaTokens(tokens, context, true);\n      }\n      else {\n        tokens = formula.getR1C1Tokens();\n        tokens = normalizeFormulaTokens(tokens, context, true);\n      }\n      const rc = stringifyTokens(tokens);\n      return context._formulasR1C1.add(rc);\n    }\n  }\n}\n\n// ECMA - 18.3.1.4 (Cell)\nexport function handlerCell (node: Element, address: string, context: ConversionContext): Cell | undefined {\n  const cell: Cell = {};\n  // FIXME: these props are scoped by the sheet but exist on the WB object\n  //        during processing and are wiped per-sheet\n  const sharedF = context._shared!;\n\n  // .t = data type: The possible values for this attribute are defined by the\n  //                 ST_CellType simple type (§18.18.11).\n  let valueType = attr(node, 't', 'n');\n\n  // .s = style index: The index of this cell's style.\n  //                   Style records are stored in the Styles Part.\n  const styleIndex = Math.trunc(numAttr(node, 's', 0));\n  if (styleIndex) {\n    cell.s = styleIndex;\n  }\n\n  const vNode = getFirstChild(node, 'v');\n  let v = vNode ? vNode.textContent : null;\n\n  // .vm = value metadata index: The zero-based index of the value metadata\n  //                             record associated with this cell's value\n  const vm = numAttr(node, 'vm');\n  if (vm && context.metadata) {\n    const meta = context.metadata.values[vm - 1];\n    if (meta._type === '_error') {\n      valueType = 'e';\n      // TODO: some of these may have .subType, does is matter?\n      if (meta.errorType === 8) {\n        v = '#SPILL!';\n      }\n      else if (meta.errorType === 11) {\n        v = '#UNKNOWN!';\n      }\n      else if (meta.errorType === 12) {\n        v = '#FIELD!';\n      }\n      else if (meta.errorType === 13) {\n        v = '#CALC!';\n      }\n    }\n  }\n\n  if (valueType === 'inlineStr') {\n    valueType = 'str';\n    v = node.querySelectorAll('is t').map(d => d.textContent).join('');\n  }\n\n  // ECMA - 18.3.1.40 f (Formula)\n  const fNode = getFirstChild(node, 'f');\n  if (v || valueType === 'str') {\n    if (valueType === 's') {\n      cell.v = context.sst && v != null ? context.sst[toInt(v)] : '';\n    }\n    else if (valueType === 'str') {\n      // Excel marks formula errors with `t=\"e\"`, but Google Sheets uses\n      // `t=\"str\"` with an error-looking cached value (e.g. \"#NAME?\"). For\n      // Google Sheets exports we treat these as errors. For other sources,\n      // `t=\"str\"` means the formula genuinely evaluated to a string — even\n      // one that looks like an error name (e.g. `=A1` where A1 is \"#VALUE!\").\n      if (context.isLikelyGSExport && fNode && v && ERROR_NAMES.includes(v)) {\n        // valueType = 'e';\n        cell.t = 'e';\n        cell.v = v;\n      }\n      else {\n        // valueType = 's';\n        cell.v = v || '';\n      }\n    }\n    else if (valueType === 'b') {\n      cell.v = !!toInt(v);\n    }\n    else if (valueType === 'e') {\n      // FIXME: ensure error is a known error!\n      cell.v = v;\n      cell.t = 'e';\n    }\n    else if (valueType === 'd') {\n      // cell.t = 'd';\n      if (v) {\n        if (!/[T ]/i.test(v) && v.includes(':')) {\n          cell.v = parseTimeToSerial(v);\n        }\n        else {\n          const serialDate = dateToSerial(new Date(Date.parse(v)));\n          if (serialDate != null) {\n            cell.v = serialDate + (\n              // adjust dates if the workbook uses 1904 data system\n              context.workbook?.calculationProperties?.epoch === 1904 ? -1462 : 0\n            );\n          }\n        }\n      }\n    }\n    else if (valueType === 'n') {\n      const val = toNum(v);\n      cell.v = val;\n    }\n    else {\n      throw new UnsupportedError('Missing support for data type: ' + valueType);\n    }\n  }\n\n  if (fNode) {\n    // .t (Formula Type): [ array | dataTable | normal | shared ]\n    const formulaType = attr(fNode, 't', 'normal');\n    // array for array-formula\n    if (formulaType === 'array') {\n      // .ref (Range of Cells): Range of cells which the formula applies to.\n      //   Only required for shared formula, array formula or data table.\n      //   Only written on the master formula, not subsequent formulas belonging\n      //   to the same shared group, array, or data table.\n      //   The possible values for this attribute are defined by the\n      //   ST_Ref simple type (§18.18.62).\n      const cellsRange = attr(fNode, 'ref');\n      if (cellsRange) {\n        cell.F = cellsRange;\n        context._arrayFormula!.push(cellsRange);\n      }\n      // cm=\"1\" on the cell element indicates a dynamic array formula\n      // (referencing XLDAPR metadata). Its absence on an array formula\n      // means CSE (Ctrl+Shift+Enter). Preserving this distinction lets\n      // jsf2xlsx emit cm=\"1\" only on dynamic arrays, not on CSE formulas.\n      if (!numAttr(node, 'cm')) {\n        cell.cse = true;\n      }\n      cell.f = prepFormula(fNode.textContent, address, context);\n    }\n    // shared for shared formula\n    else if (formulaType === 'shared') {\n      // .si (Shared Group Index) - Optional attribute to optimize load\n      //       performance by sharing formulas. the si attribute is used to\n      //       refer to the cell containing the formula. Two formulas are\n      //       considered to be the same when their respective representations\n      //       in R1C1-reference notation, are the same.\n      const shareGroupIndex = numAttr(fNode, 'si');\n      if (shareGroupIndex != null) {\n        if (!sharedF.has(shareGroupIndex)) {\n          const relF = new RelativeFormula(fNode.textContent, address);\n          sharedF.set(shareGroupIndex, relF);\n          cell.f = prepFormula(relF, address, context);\n        }\n        else {\n          cell.f = prepFormula(sharedF.get(shareGroupIndex)!, address, context);\n        }\n      }\n    }\n    // dataTable for data table formula\n    else if (formulaType.toLowerCase() === 'datatable') {\n      const ref = attr(fNode, 'ref');\n      const r1 = attr(fNode, 'r1');\n      if (ref && r1) {\n        const dt: DataTable = { ref, r1 };\n        const dtr = boolAttr(fNode, 'dtr', false);\n        const dt2D = boolAttr(fNode, 'dt2D', false);\n        const r2 = attr(fNode, 'r2');\n        if (dtr) {\n          dt.dtr = true;\n        }\n        if (dt2D) {\n          dt.dt2D = true;\n        }\n        if (r2) {\n          dt.r2 = r2;\n        }\n        cell.dt = dt;\n      }\n    }\n    else {\n      cell.f = prepFormula(fNode.textContent, address, context);\n    }\n  }\n\n  // unescape the strange OOXML character escaping\n  // (seems only used for <32 ASCII codes?)\n  if (typeof cell.v === 'string') {\n    cell.v = unescape(cell.v);\n  }\n\n  // don't emit the cell if it is empty\n  if (\n    cell.v == null &&\n    cell.f == null &&\n    cell.dt == null &&\n    (!cell.s || (context.options.skipStyledEmptyCells && !relevantStyle(context.workbook!.styles?.[cell.s])))\n  ) {\n    return;\n  }\n\n  return cell;\n}\n","/**\n * Convert an OOXML character-based column width to JSF pixels.\n *\n * `mdw` is the workbook Normal font's Max Digit Width. JSF pixels are 72-DPI (1px = 1pt), so\n * `mdw = round(digitAdvance / unitsPerEm * pointSize)` with the point size used directly as the em\n * size; the default 6 is Aptos Narrow 12 / Calibri 11 in that grid. The widely cited \"Calibri 11 = 7\"\n * is the 96-DPI OOXML/Windows rendering value (1pt = 1.333px) and is not JSF's coordinate system —\n * char widths are portable, and Windows Excel re-applies its own MDW when rendering, so the choice\n * cancels on a round-trip as long as read and write share this grid.\n *\n * Padding is ~5 pixels (cell margins + grid lines). Yields integer pixel widths for stability.\n */\nexport function colWidth (chars: number | null | undefined, padding = 0, mdw = 6): number | undefined {\n  if (chars == null || Number.isNaN(chars)) {\n    return undefined;\n  }\n  if (chars <= 0) {\n    return 0;\n  }\n  // Excel's documented approximation\n  return Math.floor(((chars * 256 + Math.floor(128 / mdw)) / 256) * mdw) + padding;\n}\n","import type { RangeA1 } from '@borgar/fx';\n\nconst CHAR_DOLLAR = 36;\nconst CHAR_COLON = 58;\nconst CHAR_A_LC = 97;\nconst CHAR_A_UC = 65;\nconst CHAR_Z_LC = 122;\nconst CHAR_Z_UC = 90;\nconst CHAR_0 = 48;\nconst CHAR_9 = 57;\n\nexport function fromA1 (source: string): RangeA1 | null {\n  let top = 0;\n  let left = 0;\n  let bottom = undefined;\n  let right = undefined;\n\n  const len = source.length;\n  let pos = 0;\n  let check: number;\n\n  // skip dollar\n  if (pos < len && source.charCodeAt(pos) === CHAR_DOLLAR) {\n    pos++;\n  }\n  // get A-Z\n  check = pos;\n  do {\n    const c = source.charCodeAt(pos);\n    if (c >= CHAR_A_UC && c <= CHAR_Z_UC) {\n      left = (left * 26) + (c - CHAR_A_UC + 1);\n    }\n    else if (c >= CHAR_A_LC && c <= CHAR_Z_LC) {\n      left = (left * 26) + (c - CHAR_A_LC + 1);\n    }\n    else {\n      break;\n    }\n    pos++;\n  }\n  while (pos < len);\n  // ref is invalid if no char was read\n  if (check === pos || left <= 0 || left > 16384) {\n    return null;\n  }\n  // skip dollar\n  if (pos < len && source.charCodeAt(pos) === CHAR_DOLLAR) {\n    pos++;\n  }\n  // get 0-9\n  check = pos;\n  do {\n    const c = source.charCodeAt(pos);\n    if (c >= CHAR_0 && c <= CHAR_9) {\n      top = (top * 10) + (c - CHAR_0);\n    }\n    else {\n      break;\n    }\n    pos++;\n  }\n  while (pos < len);\n  // ref is invalid if no char was read\n  if (check === pos || top <= 0 || top > 1048576) {\n    return null;\n  }\n\n  // colon (and second half)\n  if (pos < len && source.charCodeAt(pos) === CHAR_COLON) { // pos must be len-3 because :A1 is minimal\n    pos++;\n    bottom = 0;\n    right = 0;\n\n    // skip dollar\n    if (pos < len && source.charCodeAt(pos) === CHAR_DOLLAR) {\n      pos++;\n    }\n    // get A-Z\n    check = pos;\n    do {\n      const c = source.charCodeAt(pos);\n      if (c >= CHAR_A_UC && c <= CHAR_Z_UC) {\n        right = right * 26 + (c - CHAR_A_UC + 1);\n      }\n      else if (c >= CHAR_A_LC && c <= CHAR_Z_LC) {\n        right = right * 26 + (c - CHAR_A_LC + 1);\n      }\n      else {\n        break;\n      }\n      pos++;\n    }\n    while (pos < len);\n    // ref is invalid if no char was read\n    if (check === pos || right <= 0 || right > 16384) {\n      return null;\n    }\n\n    // skip dollar\n    if (pos < len && source.charCodeAt(pos) === CHAR_DOLLAR) {\n      pos++;\n    }\n    // get 0-9\n    check = pos;\n    do {\n      const c = source.charCodeAt(pos);\n      if (c >= CHAR_0 && c <= CHAR_9) {\n        bottom = bottom * 10 + (c - CHAR_0);\n      }\n      else {\n        break;\n      }\n      pos++;\n    }\n    while (pos < len);\n    // ref is invalid if no char was read\n    if (check === pos || bottom <= 0 || bottom > 1048576) {\n      return null;\n    }\n  }\n\n  // if we're not at the end, this has gone wrong\n  if (pos < len) {\n    return null;\n  }\n\n  if (bottom === undefined) {\n    return {\n      top: top - 1,\n      left: left - 1,\n      bottom: top - 1,\n      right: left - 1,\n    };\n  }\n\n  return {\n    top: Math.min(top, bottom) - 1,\n    left: Math.min(left, right ?? left) - 1,\n    bottom: Math.max(top, bottom) - 1,\n    right: Math.max(left, right ?? left) - 1,\n  };\n}\n","export function toA1 (column: number, row: number): string {\n  let n = column;\n  let c = '';\n  while (n >= 0) {\n    c = String.fromCharCode(n % 26 + 65) + c;\n    n = Math.floor(n / 26) - 1;\n  }\n  return c + (row + 1);\n}\n","import type { GridSize, PageMargins, Worksheet, WorksheetLayoutScales, WorksheetView } from '@jsfkit/types';\nimport { Document, Element } from '@borgar/simple-xml';\nimport { attr, boolAttr, numAttr } from '../utils/attr.ts';\nimport { rle } from '../utils/rle.ts';\nimport { handlerCell, relevantStyle } from './cell.ts';\nimport { ConversionContext } from '../ConversionContext.ts';\nimport type { Rel } from './rels.ts';\nimport { colWidth } from '../utils/colWidth.ts';\nimport { fromA1 } from '../utils/fromA1.ts';\nimport { toA1 } from '../utils/toA1.ts';\nimport { getFirstChild } from '../utils/getFirstChild.ts';\nimport { toInt } from '../utils/typecast.ts';\nimport { addProp } from '../utils/addProp.ts';\nimport { DEFAULT_PAGE_MARGINS } from '../constants.ts';\n\n/**\n * Extracts zoom levels (layout scales) for the different view modes for a sheet.\n *\n * Excel stores separate zoom percentages for normal view, page layout view, and page break preview.\n * Only non-default zoom values are included in the returned object.\n */\nfunction getLayoutScales (sheetView: Element): WorksheetLayoutScales | null {\n  const scales: WorksheetLayoutScales = {};\n  const normalScale = toInt(attr(sheetView, 'zoomScaleNormal'));\n  if (normalScale != null) { scales.normal = normalScale; }\n  const pageLayoutScale = toInt(attr(sheetView, 'zoomScalePageLayoutView'));\n  if (pageLayoutScale != null) { scales.pageLayout = pageLayoutScale; }\n  const pageBreakPreviewScale = toInt(attr(sheetView, 'zoomScaleSheetLayoutView'));\n  if (pageBreakPreviewScale != null) { scales.pageBreakPreview = pageBreakPreviewScale; }\n  return (normalScale ?? pageLayoutScale ?? pageBreakPreviewScale) != null ? scales : null;\n}\n\nfunction gridSize (start: number, end: number, size?: number | null, style?: number | null): GridSize {\n  const item: GridSize = { start, end };\n  if (size != null) {\n    item.size = size;\n  }\n  if (style != null) {\n    item.s = style;\n  }\n  return item;\n}\n\nexport function handlerWorksheet (\n  dom: Document,\n  context: ConversionContext,\n  rels: Rel[],\n  sheetName: string,\n): Worksheet {\n  const sheet: Worksheet = {\n    name: sheetName,\n    cells: {},\n    columns: [],\n    rows: [],\n    merges: [],\n    defaults: {\n      colWidth: colWidth(8, 5, context.normalMdw)!,\n      rowHeight: 16,\n    },\n    // drawings: [],\n    // showGridLines: true,\n    hidden: context.sheetLinks.find(link => link.name === sheetName)?.hidden ?? 0,\n  };\n\n  // Store last selected cell and/or range (both optional) for each of the sheet's view. A sheet\n  // view may be split into four panes, although of course most aren't. But to cover that case we\n  // need to find the active pane then find its active cell. When there's only one pane (i.e. almost\n  // all spreadsheets), you look for the default pane, \"topLeft\".\n  const views: WorksheetView[] = [];\n  const sheetViews = dom.querySelectorAll('sheetViews > sheetView');\n  sheetViews.forEach(sheetView => {\n    const view: WorksheetView = { workbookView: toInt(attr(sheetView, 'workbookViewId')) ?? 0 };\n    const activeLayout = attr(sheetView, 'view');\n    if (activeLayout === 'normal' || activeLayout === 'pageLayout' || activeLayout === 'pageBreakPreview') {\n      view.activeLayout = activeLayout;\n    }\n    const pane = getFirstChild(sheetView, 'pane');\n    const activePane = pane ? attr(pane, 'activePane', 'topLeft') : 'topLeft';\n    const selection = sheetView.children\n      .find(el => el.tagName === 'selection' && attr(el, 'pane', 'topLeft') === activePane);\n    if (selection) {\n      const activeCell = attr(selection, 'activeCell');\n      if (activeCell) {\n        view.activeCell = activeCell;\n      }\n      const activeRanges = attr(selection, 'sqref', '').trim().split(' ').filter(Boolean);\n      if (activeRanges.length > 1 || activeRanges[0] !== activeCell) {\n        view.activeRanges = activeRanges;\n      }\n    }\n    addProp(view, 'showGridLines', boolAttr(sheetView, 'showGridLines'), true);\n    addProp(view, 'layoutScales', getLayoutScales(sheetView));\n\n    // Filter out views that contain only a workbook view id with no actual view state data. An id\n    // alone isn't useful since it's just an index pointer. We only keep views that have at least\n    // one piece of meaningful, non-default, data.\n    if (Object.keys(view).length > 1) {\n      views.push(view);\n    }\n  });\n\n  if (views.length) {\n    sheet.views = views;\n  }\n\n  // read hyperlinks\n  const hyperLinks = new Map<string, string>();\n  dom.querySelectorAll('hyperlinks > hyperlink').forEach(d => {\n    const relId = attr(d, 'r:id');\n    const rel = rels.find(item => item.id === relId);\n    hyperLinks.set(attr(d, 'ref'), rel?.target ?? '');\n  });\n\n  // find default col/row sizes\n  const sheetFormatPr = getFirstChild(dom.root, 'sheetFormatPr');\n  if (sheetFormatPr) {\n    const baseColWidthChars = numAttr(sheetFormatPr, 'baseColWidth', null);\n    const defaultColWidthChars = numAttr(sheetFormatPr, 'defaultColWidth', null);\n    sheet.defaults!.colWidth =\n      colWidth(defaultColWidthChars, 0, context.normalMdw) ??\n      colWidth(baseColWidthChars, 5, context.normalMdw) ??\n      colWidth(8, 5, context.normalMdw)!;\n    const rowHt = numAttr(sheetFormatPr, 'defaultRowHeight', null);\n    if (rowHt != null) {\n      sheet.defaults!.rowHeight = rowHt;\n    }\n  }\n\n  // decode column widths (3.3.1.12)\n  getFirstChild(dom.root, 'cols')?.children.forEach(d => {\n    if (d.tagName !== 'col') { return; }\n    const min = numAttr(d, 'min');\n    const max = numAttr(d, 'max');\n    if (min == null || max == null) { return; }\n    const style = numAttr(d, 'style');\n    const hidden = numAttr(d, 'hidden', 0);\n    const size = colWidth(hidden ? 0 : numAttr(d, 'width'), 0, context.normalMdw);\n    sheet.columns!.push(gridSize(min, max, size, style));\n  });\n\n  context._shared = new Map();\n  context._arrayFormula = [];\n  context._merged = {};\n\n  // list merged cells\n  getFirstChild(dom.root, 'mergeCells')?.children.forEach(d => {\n    if (d.tagName !== 'mergeCell') { return; }\n    const ref = attr(d, 'ref');\n    if (ref) {\n      const pRef = fromA1(ref);\n      if (pRef) {\n        const top = pRef.top ?? 0;\n        const left = pRef.left ?? 0;\n        const bottom = pRef.bottom ?? top;\n        const right = pRef.right ?? left;\n        const anchor = toA1(left, top);\n        for (let c = left; c <= right; c++) {\n          for (let r = top; r <= bottom; r++) {\n            context._merged![toA1(c, r)] = anchor;\n          }\n        }\n        sheet.merges!.push(ref);\n      }\n    }\n  });\n\n  // keep a list of row heights\n  const rows: GridSize[] = [];\n\n  // row id number is optional so we keep track of last used and auto-increment when id is missing.\n  let lastR = 0;\n\n  // parse cells\n  getFirstChild(dom.root, 'sheetData')?.childNodes.forEach(row => {\n    if (!(row instanceof Element) || row.tagName !== 'row') { return; }\n    // .r = Row index. Indicates to which row in the sheet this\n    //                 <row> definition corresponds.\n    const r = numAttr(row, 'r', lastR + 1);\n\n    // .hidden = 1 if the row is hidden\n    // .ht = Row height measured in point size\n    // .customFormat = 1 if the row style should be applied.\n    // .s = Style Index. Index to style record for the row\n    //                   (only applied if customFormat attribute is '1').\n    const isHidden = numAttr(row, 'hidden');\n    const rowStyle = numAttr(row, 's');\n    if (isHidden) {\n      rows.push(gridSize(r, r, 0, rowStyle));\n    }\n    else {\n      // Row height measured in point size\n      const ht = attr(row, 'ht');\n      if (ht != null || rowStyle != null) {\n        rows.push(gridSize(r, r, ht == null ? null : +ht, rowStyle));\n      }\n    }\n\n    // cells: 3.3.1.3\n    let lastId = '';\n    row.childNodes.forEach(d => {\n      if (!(d instanceof Element) || d.nodeName !== 'C') {\n        return;\n      }\n      // the cell reference attribute is optional, but nearly always there\n      let id = attr(d, 'r');\n      if (!id) {\n        // spec does not say what to do when the attribute is missing but\n        // Excel will simply count from the last ID, so we do the same\n        const cellPos = fromA1(lastId ?? 'A' + r)!;\n        id = toA1((cellPos.left || 0) + 1, cellPos.top || 0);\n      }\n      const c = handlerCell(d, id, context);\n      if (context.options.skipMerged && id) {\n        if (context._merged![id] && context._merged![id] !== id) {\n          // check if there are needed styles\n          if (!c || !('s' in c) || (typeof c.s === 'number' && !relevantStyle(context.workbook!.styles![c.s]))) {\n            // this cell is part of a merged range and has no required styles\n            return;\n          }\n        }\n      }\n      if (c) {\n        if (hyperLinks.has(id)) {\n          c.l = hyperLinks.get(id);\n        }\n        sheet.cells[id] = c;\n      }\n      lastId = id;\n    });\n    lastR = r;\n  });\n\n  // run-length encode the row heights\n  sheet.rows = rle(rows);\n\n  // add .F tags to array formula cells\n  context._arrayFormula.forEach(arrayRef => {\n    const arrRef = fromA1(arrayRef);\n    if (arrRef) {\n      const top = arrRef.top ?? 0;\n      const left = arrRef.left ?? 0;\n      const bottom = arrRef.bottom ?? top;\n      const right = arrRef.right ?? left;\n      for (let r = top; r <= bottom; r++) {\n        for (let c = left; c <= right; c++) {\n          const ref = toA1(c, r);\n          if (sheet.cells[ref]) {\n            sheet.cells[ref].F = arrayRef;\n          }\n        }\n      }\n    }\n  });\n\n  // read page print margins\n  const pm = getFirstChild(dom.root, 'pageMargins');\n  if (pm) {\n    const margins: PageMargins = {\n      left: numAttr(pm, 'left'),\n      right: numAttr(pm, 'right'),\n      top: numAttr(pm, 'top'),\n      bottom: numAttr(pm, 'bottom'),\n      header: numAttr(pm, 'header'),\n      footer: numAttr(pm, 'footer'),\n    };\n    if (\n      // OOXML requires every attribute when `<pageMargins>` is present; if any are missing or\n      // non-numeric, treat the element as absent rather than fabricating partial data.\n      (margins.top != null && margins.bottom != null &&\n      margins.left != null && margins.right != null &&\n      margins.header != null && margins.footer != null) &&\n      // Normalise a canonical-default element to absent so the common case keeps the JSF compact.\n      (margins.top != DEFAULT_PAGE_MARGINS.top || margins.bottom != DEFAULT_PAGE_MARGINS.bottom ||\n      margins.left != DEFAULT_PAGE_MARGINS.left || margins.right != DEFAULT_PAGE_MARGINS.right ||\n      margins.header != DEFAULT_PAGE_MARGINS.header || margins.footer != DEFAULT_PAGE_MARGINS.footer)\n    ) {\n      sheet.pageMargins = margins;\n    }\n  }\n\n  // detect linked drawing (graphics within the sheet)\n  const drawing = getFirstChild(dom.root, 'drawing');\n  if (drawing) {\n    const rId = attr(drawing, 'r:id');\n    const rel = rels.find(d => d.id === rId);\n    if (rel) {\n      context.images.push({ sheetName, rel, type: 'drawing' });\n    }\n  }\n\n  // detect linked picture (sheet background \"wallpaper\")\n  const picture = getFirstChild(dom.root, 'picture');\n  if (picture) {\n    const rId = attr(picture, 'r:id');\n    const rel = rels.find(d => d.id === rId);\n    if (rel) {\n      context.images.push({ sheetName, rel, type: 'picture' });\n    }\n    // TODO: set a property on the sheet to link to this image\n  }\n\n  delete context._shared;\n  delete context._arrayFormula;\n  delete context._merged;\n  return sheet;\n}\n","import { Element, type Document } from '@borgar/simple-xml';\nimport { attr, boolAttr, numAttr } from '../utils/attr.ts';\nimport { handlerCell } from './cell.ts';\nimport { normalizeFormula } from '../utils/normalizeFormula.ts';\nimport { ConversionContext } from '../ConversionContext.ts';\nimport type { Rel } from './rels.ts';\nimport type { External, ExternalDefinedName } from '@jsfkit/types';\nimport { fromA1 } from '../utils/fromA1.ts';\nimport { toA1 } from '../utils/toA1.ts';\n\nconst NO_EXTERNALS = { externalLinks: [] };\n\nexport function handlerExternal (dom: Document, fileName: string = '', rels: Rel[] = []): External {\n  const external: External = {\n    name: fileName,\n    sheets: [],\n    names: [],\n  };\n\n  // read sheet names\n  dom.querySelectorAll('sheetNames > sheetName')\n    .forEach(sheetName => {\n      external.sheets.push({\n        name: attr(sheetName, 'val'),\n        cells: {},\n      });\n    });\n\n  // Read alternate URLs from the `<xxl21:alternateUrls>` extension element\n  // (simple-xml strips the prefix so we query by the local name). Each child\n  // carries an `r:id` that resolves against the external-link part's rels:\n  // the rel's Target is the URL. Both children are optional per the schema;\n  // we preserve whichever are present.\n  //\n  // The element itself also carries opaque `driveId` and `itemId` attributes\n  // on OneDrive/SharePoint-sourced links that Excel uses to reach the same\n  // document via the Graph API. We round-trip those verbatim.\n  const altUrlsEl = dom.querySelectorAll('externalBook > alternateUrls')[0];\n  if (altUrlsEl) {\n    const alternateUrls: NonNullable<External['alternateUrls']> = {};\n    const absEl = altUrlsEl.querySelectorAll('absoluteUrl')[0];\n    if (absEl) {\n      const relId = attr(absEl, 'r:id');\n      const target = relId ? rels.find(r => r.id === relId)?.target : undefined;\n      if (target) {\n        alternateUrls.absoluteUrl = target;\n      }\n    }\n    const relEl = altUrlsEl.querySelectorAll('relativeUrl')[0];\n    if (relEl) {\n      const relId = attr(relEl, 'r:id');\n      const target = relId ? rels.find(r => r.id === relId)?.target : undefined;\n      if (target) {\n        alternateUrls.relativeUrl = target;\n      }\n    }\n    const driveId = attr(altUrlsEl, 'driveId');\n    if (driveId) {\n      alternateUrls.driveId = driveId;\n    }\n    const itemId = attr(altUrlsEl, 'itemId');\n    if (itemId) {\n      alternateUrls.itemId = itemId;\n    }\n    if (Object.keys(alternateUrls).length > 0) {\n      external.alternateUrls = alternateUrls;\n    }\n  }\n\n  // read cells and their values\n  //\n  // A sheet named in `<sheetNames>` but missing from `<sheetDataSet>` is distinct\n  // from one with an empty `<sheetData sheetId=\"N\"/>`; track which sheetIds\n  // actually had a `<sheetData>` element so the emitter can tell them apart\n  // when round-tripping.\n  const sheetDataSeen = new Set<number>();\n  const dummyContext = new ConversionContext();\n  dom.querySelectorAll('sheetDataSet > sheetData')\n    .forEach(sheetData => {\n      const sheetIndex = numAttr(sheetData, 'sheetId', 0);\n      sheetDataSeen.add(sheetIndex);\n      if (boolAttr(sheetData, 'refreshError')) {\n        external.sheets[sheetIndex].refreshError = true;\n      }\n      const externalCells = external.sheets[sheetIndex].cells;\n      let lastR = 0;\n      for (const row of sheetData.childNodes) {\n        if (row instanceof Element && row.tagName === 'row') {\n          let lastId = '';\n          const r = numAttr(row, 'r', lastR + 1);\n          for (const cell of row.childNodes) {\n            if (cell instanceof Element && cell.tagName === 'cell') {\n              let id = attr(cell, 'r');\n              if (!id) {\n                const cellPos = fromA1(lastId ?? 'A' + r)!;\n                id = toA1((cellPos.left || 0) + 1, cellPos.top || 0);\n              }\n              // External sheetData carries the cached values the host workbook\n              // consumed; an empty `<cell r=\"X\"/>` still signals \"this cell was\n              // in the captured range\" and we preserve it as an empty object\n              // rather than dropping it the way `handlerCell` does for host\n              // worksheet cells.\n              const c = handlerCell(cell, id, dummyContext) ?? {};\n              if (id) {\n                externalCells[id] = c;\n              }\n              lastId = id;\n            }\n          }\n          lastR = r;\n        }\n      }\n    });\n  external.sheets.forEach((sheet, idx) => {\n    if (!sheetDataSeen.has(idx)) {\n      sheet.noSheetData = true;\n    }\n  });\n\n  // read defined names\n  dom.querySelectorAll('definedNames > definedName')\n    .forEach(definedName => {\n      const nameDef: ExternalDefinedName = {\n        name: attr(definedName, 'name'),\n      };\n      const expr = attr(definedName, 'refersTo');\n      if (expr) {\n        nameDef.value = normalizeFormula(expr, NO_EXTERNALS);\n      }\n      external.names.push(nameDef);\n    });\n\n  return external;\n}\n","import type { Document } from '@borgar/simple-xml';\nimport type { ConversionContext } from '../ConversionContext.ts';\nimport { attr, boolAttr, numAttr } from '../utils/attr.ts';\nimport { normalizeFormula } from '../utils/normalizeFormula.ts';\nimport type { Table, TableColumn, TableStyle, TableStyleName } from '@jsfkit/types';\n\nconst reTableStyleName = /^TableStyle(Dark(\\d|10|11)|Light(1?\\d|20|21)|Medium(1?\\d|2[0-8]))$/;\n\nexport function handlerTable (dom: Document | null | undefined, context: ConversionContext): Table | void {\n  const tableElm = dom?.getElementsByTagName('table')[0];\n  if (!tableElm) { return; }\n\n  const table: Table = {\n    name: attr(tableElm, 'displayName') || attr(tableElm, 'name'),\n    sheet: '',\n    ref: attr(tableElm, 'ref'),\n    headerRowCount: numAttr(tableElm, 'headerRowCount', 1),\n    totalsRowCount: numAttr(tableElm, 'totalsRowCount', 0),\n    totalsRowShown: boolAttr(tableElm, 'totalsRowShown', true) ? undefined : false,\n    columns: [],\n    // alt text: extLst>ext>table[altTextSummary]\n  };\n\n  // todo: table can have a sortState\n\n  const tableStyleInfo = tableElm.getElementsByTagName('tableStyleInfo')[0];\n  if (tableStyleInfo) {\n    // This may be a bit confusing, but here is is:\n    // 1. When there is no <tableStyleInfo /> in the file, the table should be rendered using \"TableStyleMedium2\"\n    // 2. When there is a <tableStyleInfo /> element, its name dictates the style.\n    // 3. When <tableStyleInfo /> is present but does not have a name, no table styles should be used.\n    const tableStyle: TableStyle = {\n      name: null,\n      showRowStripes: true,\n      showColumnStripes: false,\n      showFirstColumn: false,\n      showLastColumn: false,\n    };\n    const name = attr(tableStyleInfo, 'name');\n    if (name && reTableStyleName.test(name)) {\n      tableStyle.name = name as TableStyleName;\n    }\n    tableStyle.showRowStripes = boolAttr(tableStyleInfo, 'showRowStripes', true);\n    tableStyle.showColumnStripes = boolAttr(tableStyleInfo, 'showColumnStripes', false);\n    tableStyle.showFirstColumn = boolAttr(tableStyleInfo, 'showFirstColumn', false);\n    tableStyle.showLastColumn = boolAttr(tableStyleInfo, 'showLastColumn', false);\n\n    // only add the style if it has changes from the defaults\n    if (\n      tableStyle.name !== 'TableStyleMedium2' ||\n      !tableStyle.showRowStripes ||\n      tableStyle.showColumnStripes ||\n      tableStyle.showFirstColumn ||\n      tableStyle.showLastColumn\n    ) {\n      table.style = tableStyle;\n    }\n  }\n\n  tableElm\n    .querySelectorAll('tableColumns > tableColumn')\n    .forEach(node => {\n      const column: TableColumn = {\n        name: attr(node, 'name'),\n        // TODO: totalsRowLabel\n        // totalsRowLabel: attr(node, 'totalsRowLabel'),\n      };\n\n      /*\n      { name: 'FOO',\n        total: { type: 'function', value: 'average' } ??\n        formula: 'XXX'\n      }\n      */\n      // what appears in the totals row can be:\n      // - a built in function:\n      //   `attr(node, 'totalsRowFunction')` => \"average\"\n      // - a custom formula:\n      //   `attr(node, 'totalsRowFunction') === 'custom'`\n      //   f = node.getElementsByTagName('totalsRowFormula').innerText\n      // - a label:\n      //   `attr(node, 'totalsRowLabel')` => \"Total\"\n\n      const f = node.getElementsByTagName('calculatedColumnFormula')[0];\n      if (f) {\n        column.formula = normalizeFormula(f.textContent, context);\n        if (attr(f, 'array') === '1') {\n          column.formulaIsArray = true;\n        }\n      }\n      table.columns.push(column);\n    });\n\n  return table;\n}\n","/**\n * Validate a string against a set of allowed enum values.\n * Returns the value narrowed to `T` if it's in the set, otherwise `undefined`.\n */\nexport function parseEnum<T extends string> (\n  value: string | null | undefined,\n  allowed: ReadonlySet<T>,\n): T | undefined {\n  if (value == null) {\n    return undefined;\n  }\n  return allowed.has(value as T) ? (value as T) : undefined;\n}\n","import type { Element } from '@borgar/simple-xml';\nimport type { PivotCacheSharedItem } from '@jsfkit/types';\nimport { attr, boolAttr, numAttr } from '../../utils/attr.ts';\n\n/** Parse a single `<s>`, `<n>`, `<b>`, `<d>`, `<e>`, or `<m>` element into a shared item. */\nexport function parseCacheSharedItem (elm: Element): PivotCacheSharedItem | undefined {\n  const tag = elm.tagName;\n  let result: PivotCacheSharedItem | undefined;\n  if (tag === 'm') {\n    result = { t: 'z' };\n  }\n  else if (tag === 's') {\n    result = { t: 's', v: attr(elm, 'v') ?? '' };\n  }\n  else if (tag === 'n') {\n    result = { t: 'n', v: numAttr(elm, 'v', 0) };\n  }\n  else if (tag === 'b') {\n    result = { t: 'b', v: boolAttr(elm, 'v', false) };\n  }\n  else if (tag === 'd') {\n    result = { t: 'd', v: attr(elm, 'v') ?? '' };\n  }\n  else if (tag === 'e') {\n    result = { t: 'e', v: attr(elm, 'v') ?? '' };\n  }\n  if (result && boolAttr(elm, 'u') === true) {\n    result.u = true;\n  }\n  return result;\n}\n","import type { Element } from '@borgar/simple-xml';\nimport { numAttr } from '../../utils/attr.ts';\nimport type { NumFmtLookup } from './NumFmtLookup.ts';\n\n/**\n * Resolve an element's `numFmtId` attribute to a format code string via the\n * style table, returning `undefined` when absent, unresolvable, or \"General\".\n */\nexport function resolveNumFmt (el: Element, numFmts?: NumFmtLookup): string | undefined {\n  const id = numAttr(el, 'numFmtId');\n  if (id != null && numFmts) {\n    const fmt = numFmts[id];\n    if (typeof fmt === 'string' && fmt.toLowerCase() !== 'general') {\n      return fmt;\n    }\n  }\n}\n","import type { Document, Element } from '@borgar/simple-xml';\nimport type { PivotCache, PivotCacheBase, PivotCacheConsolidationRangeSet, PivotCacheConsolidationSource, PivotCacheField, PivotCacheFieldGroup, PivotCacheRangePr, PivotCacheSharedItem, PivotCacheSharedItemsMeta, PivotCacheWorksheetSourceName, PivotCacheWorksheetSourceRange, PivotGroupBy } from '@jsfkit/types';\nimport { addProp } from '../../utils/addProp.ts';\nimport { attr, boolAttr, numAttr } from '../../utils/attr.ts';\nimport { parseEnum } from '../../utils/parseEnum.ts';\nimport type { NumFmtLookup } from './NumFmtLookup.ts';\nimport { parseCacheSharedItem } from './parseCacheSharedItem.ts';\nimport { resolveNumFmt } from './resolveNumFmt.ts';\n\ntype CacheMetadata = Pick<PivotCacheBase,\n  'refreshedBy' | 'refreshedDate' | 'refreshOnLoad' | 'enableRefresh' |\n  'upgradeOnRefresh' | 'uid' | 'invalid'\n>;\n\nconst GROUP_BY_VALUES: ReadonlySet<PivotGroupBy> = new Set<PivotGroupBy>([\n  'range', 'seconds', 'minutes', 'hours', 'days', 'months', 'quarters', 'years',\n]);\n\n/** Parse `<s>`, `<n>`, `<b>`, `<d>`, `<e>`, `<m>` children into shared/group items. */\nfunction parseCacheItems (container: Element): PivotCacheSharedItem[] {\n  const items: PivotCacheSharedItem[] = [];\n  for (const child of container.children) {\n    const item = parseCacheSharedItem(child);\n    if (item) { items.push(item); }\n  }\n  return items;\n}\n\nfunction parseFieldGroup (elm: Element): PivotCacheFieldGroup | undefined {\n  const fg: PivotCacheFieldGroup = {};\n  let hasAny = false;\n  const par = numAttr(elm, 'par');\n  if (par != null) { fg.par = par; hasAny = true; }\n  const base = numAttr(elm, 'base');\n  if (base != null) { fg.base = base; hasAny = true; }\n\n  // Numeric/date range grouping parameters (start, end, interval, groupBy)\n  const rangePrEl = elm.querySelector('rangePr');\n  if (rangePrEl) {\n    const rp: PivotCacheRangePr = {};\n    const autoStart = boolAttr(rangePrEl, 'autoStart');\n    if (autoStart === false) { rp.autoStart = false; }\n    const autoEnd = boolAttr(rangePrEl, 'autoEnd');\n    if (autoEnd === false) { rp.autoEnd = false; }\n    addProp(rp, 'groupBy', parseEnum(attr(rangePrEl, 'groupBy'), GROUP_BY_VALUES), 'range');\n    addProp(rp, 'startNum', numAttr(rangePrEl, 'startNum'));\n    addProp(rp, 'endNum', numAttr(rangePrEl, 'endNum'));\n    addProp(rp, 'startDate', attr(rangePrEl, 'startDate'));\n    addProp(rp, 'endDate', attr(rangePrEl, 'endDate'));\n    addProp(rp, 'groupInterval', numAttr(rangePrEl, 'groupInterval'), 1);\n    fg.rangePr = rp;\n    hasAny = true;\n  }\n\n  // Discrete grouping: maps each source item to a group-item index\n  const discretePrEl = elm.querySelector('discretePr');\n  if (discretePrEl) {\n    const indices: number[] = [];\n    for (const x of discretePrEl.getElementsByTagName('x')) {\n      indices.push(numAttr(x, 'v', 0));\n    }\n    if (indices.length > 0) { fg.discretePr = indices; hasAny = true; }\n  }\n\n  // Group item labels (the display values for each group bucket)\n  const groupItemsEl = elm.querySelector('groupItems');\n  if (groupItemsEl) {\n    const items = parseCacheItems(groupItemsEl);\n    if (items.length > 0) { fg.groupItems = items; hasAny = true; }\n  }\n\n  return hasAny ? fg : undefined;\n}\n\nfunction parseSharedItemsMeta (elm: Element): PivotCacheSharedItemsMeta | undefined {\n  const meta: PivotCacheSharedItemsMeta = {};\n  let hasAny = false;\n  const boolMeta = (name: keyof PivotCacheSharedItemsMeta) => {\n    const v = boolAttr(elm, name);\n    if (v != null) { (meta as Record<string, unknown>)[name] = v; hasAny = true; }\n  };\n  const numMeta = (name: keyof PivotCacheSharedItemsMeta) => {\n    const v = numAttr(elm, name);\n    if (v != null) { (meta as Record<string, unknown>)[name] = v; hasAny = true; }\n  };\n  const strMeta = (name: keyof PivotCacheSharedItemsMeta) => {\n    const v = attr(elm, name);\n    if (v != null) { (meta as Record<string, unknown>)[name] = v; hasAny = true; }\n  };\n  boolMeta('containsBlank');\n  boolMeta('containsMixedTypes');\n  boolMeta('containsSemiMixedTypes');\n  boolMeta('containsString');\n  boolMeta('containsNumber');\n  boolMeta('containsInteger');\n  boolMeta('containsDate');\n  boolMeta('containsNonDate');\n  numMeta('minValue');\n  numMeta('maxValue');\n  strMeta('minDate');\n  strMeta('maxDate');\n  return hasAny ? meta : undefined;\n}\n\nfunction parseFields (root: Element, numFmts?: NumFmtLookup): PivotCacheField[] {\n  const fields: PivotCacheField[] = [];\n  for (const cf of root.querySelectorAll('cacheFields > cacheField')) {\n    const name = attr(cf, 'name');\n\n    const field: PivotCacheField = { name: name ?? '' };\n    addProp(field, 'numFmt', resolveNumFmt(cf, numFmts));\n    addProp(field, 'formula', attr(cf, 'formula'));\n    const databaseField = boolAttr(cf, 'databaseField');\n    if (databaseField === false) {\n      field.databaseField = false;\n    }\n\n    const sharedItemsEl = cf.querySelector('sharedItems');\n    if (sharedItemsEl) {\n      const sharedItems = parseCacheItems(sharedItemsEl);\n      if (sharedItems.length > 0) {\n        field.sharedItems = sharedItems;\n      }\n      // The <sharedItems> element carries metadata attributes (containsNumber,\n      // minValue, maxValue, etc.) describing the field's data types and value\n      // ranges. When shared-item children exist, this metadata could be derived\n      // by scanning them, but when the field has no shared items (all values\n      // live only in the cache records) these attributes are the only source\n      // of type/range information for the field.\n      const meta = parseSharedItemsMeta(sharedItemsEl);\n      if (meta) {\n        field.sharedItemsMeta = meta;\n      }\n    }\n    const fieldGroupEl = cf.querySelector('fieldGroup');\n    if (fieldGroupEl) {\n      const fg = parseFieldGroup(fieldGroupEl);\n      if (fg) { field.fieldGroup = fg; }\n    }\n\n    fields.push(field);\n  }\n  return fields;\n}\n\nfunction parseCacheMetadata (root: Element): CacheMetadata {\n  const result: CacheMetadata = {};\n  addProp(result, 'refreshedBy', attr(root, 'refreshedBy'));\n  addProp(result, 'refreshedDate', numAttr(root, 'refreshedDate'));\n  addProp(result, 'refreshOnLoad', boolAttr(root, 'refreshOnLoad'));\n  addProp(result, 'enableRefresh', boolAttr(root, 'enableRefresh'));\n  addProp(result, 'upgradeOnRefresh', boolAttr(root, 'upgradeOnRefresh'));\n  addProp(result, 'uid', attr(root, 'xr:uid'));\n  addProp(result, 'invalid', boolAttr(root, 'invalid'));\n  return result;\n}\n\nexport function handlerPivotCacheDefinition (dom: Document, numFmts?: NumFmtLookup): PivotCache | undefined {\n  const root = dom.querySelector('pivotCacheDefinition');\n  if (!root) { return; }\n\n  const cacheSource = root.querySelector('cacheSource');\n  if (!cacheSource) { return; }\n\n  const sourceType = attr(cacheSource, 'type');\n  const fields = parseFields(root, numFmts);\n\n  const metadata = parseCacheMetadata(root);\n\n  let result: PivotCache | undefined;\n\n  if (sourceType === 'worksheet') {\n    const wsSource = cacheSource.querySelector('worksheetSource');\n    if (!wsSource) { return; }\n    const ref = attr(wsSource, 'ref');\n    const sheet = attr(wsSource, 'sheet');\n    const name = attr(wsSource, 'name');\n    if (ref) {\n      // When both ref and name are present (e.g. a table-backed range), ref takes\n      // precedence and name is dropped. PivotCacheWorksheetSourceRange doesn't have\n      // a name field — the types model range and name sources as disjoint variants.\n      const worksheetSource: PivotCacheWorksheetSourceRange = sheet\n        ? { type: 'range', ref, sheet }\n        : { type: 'range', ref };\n      result = { sourceType: 'worksheet' as const, worksheetSource, fields };\n    }\n    else if (name) {\n      const worksheetSource: PivotCacheWorksheetSourceName = sheet ? { type: 'name', name, sheet } : { type: 'name', name };\n      result = { sourceType: 'worksheet' as const, worksheetSource, fields };\n    }\n  }\n  else if (sourceType === 'external') {\n    const connectionId = numAttr(cacheSource, 'connectionId');\n    if (connectionId == null) { return; }\n    result = { sourceType: 'external' as const, connectionId, fields };\n  }\n  else if (sourceType === 'consolidation') {\n    const consolidationEl = cacheSource.querySelector('consolidation');\n    if (!consolidationEl) { return; }\n    const consolidation: PivotCacheConsolidationSource = { rangeSets: [] };\n    addProp(consolidation, 'autoPage', boolAttr(consolidationEl, 'autoPage'));\n    const pages: string[][] = [];\n    for (const pageEl of consolidationEl.querySelectorAll('pages > page')) {\n      const items: string[] = [];\n      for (const itemEl of pageEl.getElementsByTagName('pageItem')) {\n        items.push(attr(itemEl, 'name') ?? '');\n      }\n      pages.push(items);\n    }\n    if (pages.length > 0) { consolidation.pages = pages; }\n    for (const rsEl of consolidationEl.querySelectorAll('rangeSets > rangeSet')) {\n      const rs: PivotCacheConsolidationRangeSet = {};\n      addProp(rs, 'ref', attr(rsEl, 'ref'));\n      addProp(rs, 'sheet', attr(rsEl, 'sheet'));\n      addProp(rs, 'i1', numAttr(rsEl, 'i1'));\n      addProp(rs, 'i2', numAttr(rsEl, 'i2'));\n      addProp(rs, 'i3', numAttr(rsEl, 'i3'));\n      addProp(rs, 'i4', numAttr(rsEl, 'i4'));\n      consolidation.rangeSets.push(rs);\n    }\n    result = { sourceType: 'consolidation' as const, consolidation, fields };\n  }\n  else if (sourceType === 'scenario') {\n    result = { sourceType: 'scenario' as const, fields };\n  }\n\n  if (result) {\n    Object.assign(result, metadata);\n  }\n  return result;\n}\n","import type { Document } from '@borgar/simple-xml';\nimport type { PivotCacheRecord, PivotCacheRecordValue } from '@jsfkit/types';\nimport { numAttr } from '../../utils/attr.ts';\nimport { parseCacheSharedItem } from './parseCacheSharedItem.ts';\n\nexport function handlerPivotCacheRecords (dom: Document): PivotCacheRecord[] {\n  const root = dom.querySelector('pivotCacheRecords');\n  if (!root) { return []; }\n\n  const records: PivotCacheRecord[] = [];\n  for (const r of root.getElementsByTagName('r')) {\n    const record: PivotCacheRecordValue[] = [];\n    for (const child of r.children) {\n      if (child.tagName === 'x') {\n        record.push({ t: 'x', v: numAttr(child, 'v', 0) });\n      }\n      else {\n        const item = parseCacheSharedItem(child);\n        if (item) { record.push(item); }\n      }\n    }\n    records.push(record);\n  }\n\n  return records;\n}\n","import type { Element } from '@borgar/simple-xml';\nimport type { PivotDataField, PivotDataFieldAggregation, PivotShowDataAs } from '@jsfkit/types';\nimport { addProp } from '../../utils/addProp.ts';\nimport { attr, numAttr } from '../../utils/attr.ts';\nimport { parseEnum } from '../../utils/parseEnum.ts';\nimport type { NumFmtLookup } from './NumFmtLookup.ts';\nimport { resolveNumFmt } from './resolveNumFmt.ts';\n\n// OOXML default for `dataField/@baseItem` (CT_DataField): the \"(not set)\"\n// sentinel. Distinct from `0`, which selects the first base item.\nconst BASE_ITEM_DEFAULT = 1048832;\n\nconst DATA_FIELD_AGGREGATIONS: ReadonlySet<PivotDataFieldAggregation> =\n  new Set<PivotDataFieldAggregation>([\n    'average',\n    'count',\n    'countNums',\n    'max',\n    'min',\n    'product',\n    'stdDev',\n    'stdDevP',\n    'sum',\n    'var',\n    'varP',\n  ]);\n\nconst SHOW_DATA_AS_VALUES: ReadonlySet<PivotShowDataAs> =\n  new Set<PivotShowDataAs>([\n    'normal',\n    'difference',\n    'percent',\n    'percentDiff',\n    'runTotal',\n    'percentOfRow',\n    'percentOfCol',\n    'percentOfTotal',\n    'index',\n    'percentOfParentRow',\n    'percentOfParentCol',\n    'percentOfParent',\n    'percentOfRunningTotal',\n    'rankAscending',\n    'rankDescending',\n  ]);\n\nexport function parseDataFields (root: Element, numFmts?: NumFmtLookup): PivotDataField[] {\n  const dataFields: PivotDataField[] = [];\n  for (const df of root.querySelectorAll('dataFields > dataField')) {\n    const dataField: PivotDataField = {\n      fieldIndex: numAttr(df, 'fld', 0),\n    };\n    addProp(dataField, 'name', attr(df, 'name'));\n    addProp(dataField, 'subtotal', parseEnum(attr(df, 'subtotal'), DATA_FIELD_AGGREGATIONS));\n    addProp(dataField, 'showDataAs', parseEnum(attr(df, 'showDataAs'), SHOW_DATA_AS_VALUES));\n    // JSF stores non-default values; defaults are implicit. `baseField`\n    // defaults to `0` per OOXML, so the explicit `0` Excel emits is elided.\n    // `baseItem` defaults to `1048832` (the \"(not set)\" sentinel), NOT `0` ---\n    // `baseItem=\"0\"` means \"relative to the first item\" and is significant for\n    // the base-item-relative `showDataAs` modes (difference/percent/percentDiff),\n    // so it must be preserved; only the sentinel default is elided.\n    addProp(dataField, 'baseField', numAttr(df, 'baseField'), 0);\n    addProp(dataField, 'baseItem', numAttr(df, 'baseItem'), BASE_ITEM_DEFAULT);\n    addProp(dataField, 'numFmt', resolveNumFmt(df, numFmts));\n    dataFields.push(dataField);\n  }\n  return dataFields;\n}\n","import type { Element } from '@borgar/simple-xml';\nimport type { PivotTable } from '@jsfkit/types';\nimport { boolAttr } from '../../utils/attr.ts';\n\n// URI of the x14 pivotTableDefinition extension (the 2009/9 SpreadsheetML\n// extension that carries post-2007 pivot attributes such as `hideValuesRow`).\nconst X14_PIVOT_TABLE_DEFINITION_URI = '{962EF5D1-5CA2-4c93-8EF4-DBF5C05439D2}';\n\n/**\n * Parse the `x14:pivotTableDefinition` extension from a pivot table's `<extLst>` into the\n * JSF model. The extension lives in an `<ext>` keyed by {@link X14_PIVOT_TABLE_DEFINITION_URI}\n * and carries pivot attributes that postdate the original CT_pivotTableDefinition schema.\n *\n * Only `hideValuesRow` is read for now. Other x14 pivot attributes\n * (`calculatedMembersInFilters`, the deferred conditional-format containers, etc.) have no JSF\n * representation yet; add them here once the model gains the corresponding properties.\n *\n * Returns a partial set of PivotTable properties to merge onto the table, or `undefined` when\n * the extension is absent or carries nothing we model.\n */\nexport function parseExtensions (root: Element): Partial<PivotTable> | undefined {\n  // The element name `pivotTableDefinition` collides with the root, so scope to the ext URI\n  // first and read the (single) child rather than searching by tag name.\n  const ext = root\n    .getElementsByTagName('extLst')[0]\n    ?.children.find(e => e.getAttribute('uri') === X14_PIVOT_TABLE_DEFINITION_URI);\n  const x14 = ext?.children[0];\n\n  const hideValuesRow = x14 && boolAttr(x14, 'hideValuesRow');\n  // OOXML default is false; only convey the non-default value.\n  if (hideValuesRow) {\n    return { hideValuesRow: true };\n  }\n}\n","import type { Element } from '@borgar/simple-xml';\nimport type { PivotAutoFilterColumn, PivotCustomFilterCriterion, PivotFilter, PivotFilterType } from '@jsfkit/types';\nimport { addProp } from '../../utils/addProp.ts';\nimport { attr, boolAttr, numAttr } from '../../utils/attr.ts';\nimport { parseEnum } from '../../utils/parseEnum.ts';\n\ntype CustomFilterOp = NonNullable<PivotCustomFilterCriterion['operator']>;\n\nconst FILTER_TYPES: ReadonlySet<PivotFilterType> = new Set<PivotFilterType>([\n  'unknown',\n  'count',\n  'percent',\n  'sum',\n  'captionEqual',\n  'captionNotEqual',\n  'captionBeginsWith',\n  'captionNotBeginsWith',\n  'captionEndsWith',\n  'captionNotEndsWith',\n  'captionContains',\n  'captionNotContains',\n  'captionGreaterThan',\n  'captionGreaterThanOrEqual',\n  'captionLessThan',\n  'captionLessThanOrEqual',\n  'captionBetween',\n  'captionNotBetween',\n  'valueEqual',\n  'valueNotEqual',\n  'valueGreaterThan',\n  'valueGreaterThanOrEqual',\n  'valueLessThan',\n  'valueLessThanOrEqual',\n  'valueBetween',\n  'valueNotBetween',\n  'dateEqual',\n  'dateNotEqual',\n  'dateOlderThan',\n  'dateOlderThanOrEqual',\n  'dateNewerThan',\n  'dateNewerThanOrEqual',\n  'dateBetween',\n  'dateNotBetween',\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]);\n\nconst CUSTOM_FILTER_OPS: ReadonlySet<CustomFilterOp> = new Set<CustomFilterOp>([\n  'lessThan', 'lessThanOrEqual', 'equal', 'notEqual', 'greaterThanOrEqual', 'greaterThan',\n]);\n\nexport function parseFilters (root: Element): PivotFilter[] {\n  const filters: PivotFilter[] = [];\n  for (const fEl of root.querySelectorAll('filters > filter')) {\n    const type = parseEnum(attr(fEl, 'type'), FILTER_TYPES);\n    if (type == null) { continue; }\n    const filter: PivotFilter = {\n      fieldIndex: numAttr(fEl, 'fld', 0),\n      type,\n      id: numAttr(fEl, 'id', 0),\n    };\n    addProp(filter, 'evalOrder', numAttr(fEl, 'evalOrder'), 0);\n    addProp(filter, 'mpFld', numAttr(fEl, 'mpFld'));\n    addProp(filter, 'iMeasureHier', numAttr(fEl, 'iMeasureHier'));\n    addProp(filter, 'iMeasureFld', numAttr(fEl, 'iMeasureFld'));\n    addProp(filter, 'name', attr(fEl, 'name'));\n    addProp(filter, 'description', attr(fEl, 'description'));\n    addProp(filter, 'stringValue1', attr(fEl, 'stringValue1'));\n    addProp(filter, 'stringValue2', attr(fEl, 'stringValue2'));\n\n    const afEl = fEl.querySelector('autoFilter');\n    if (afEl) {\n      const af: PivotFilter['autoFilter'] = {};\n      addProp(af, 'ref', attr(afEl, 'ref'));\n      const filterColumns: PivotAutoFilterColumn[] = [];\n      for (const fcEl of afEl.getElementsByTagName('filterColumn')) {\n        const fc: PivotAutoFilterColumn = { colId: numAttr(fcEl, 'colId', 0) };\n        const top10El = fcEl.querySelector('top10');\n        if (top10El) {\n          fc.top10 = { val: numAttr(top10El, 'val', 0) };\n          const top = boolAttr(top10El, 'top');\n          if (top === false) { fc.top10.top = false; }\n          const percent = boolAttr(top10El, 'percent');\n          if (percent === true) { fc.top10.percent = true; }\n          addProp(fc.top10, 'filterVal', numAttr(top10El, 'filterVal'));\n        }\n        const customFiltersEl = fcEl.querySelector('customFilters');\n        if (customFiltersEl) {\n          const cfItems: NonNullable<PivotAutoFilterColumn['customFilters']>['filters'] = [];\n          for (const cfItemEl of customFiltersEl.getElementsByTagName('customFilter')) {\n            const f: (typeof cfItems)[number] = {};\n            addProp(f, 'operator', parseEnum(attr(cfItemEl, 'operator'), CUSTOM_FILTER_OPS));\n            addProp(f, 'val', attr(cfItemEl, 'val'));\n            cfItems.push(f);\n          }\n          const cf: NonNullable<PivotAutoFilterColumn['customFilters']> = { filters: cfItems };\n          if (boolAttr(customFiltersEl, 'and') === true) { cf.and = true; }\n          fc.customFilters = cf;\n        }\n        filterColumns.push(fc);\n      }\n      if (filterColumns.length > 0) { af.filterColumns = filterColumns; }\n      filter.autoFilter = af;\n    }\n\n    filters.push(filter);\n  }\n  return filters;\n}\n","import type { Element } from '@borgar/simple-xml';\nimport type { PivotPageField } from '@jsfkit/types';\nimport { addProp } from '../../utils/addProp.ts';\nimport { attr, numAttr } from '../../utils/attr.ts';\n\nexport function parsePageFields (root: Element): PivotPageField[] {\n  const pageFields: PivotPageField[] = [];\n  for (const pf of root.querySelectorAll('pageFields > pageField')) {\n    const pageField: PivotPageField = {\n      fieldIndex: numAttr(pf, 'fld', 0),\n    };\n    addProp(pageField, 'selectedItem', numAttr(pf, 'item'));\n    addProp(pageField, 'name', attr(pf, 'name'));\n    addProp(pageField, 'caption', attr(pf, 'cap'));\n    addProp(pageField, 'hierarchy', numAttr(pf, 'hier'));\n    pageFields.push(pageField);\n  }\n  return pageFields;\n}\n","import type { PivotItemType, PivotSubtotalFunction } from '@jsfkit/types';\n\nexport const SUBTOTAL_FUNCTIONS: PivotSubtotalFunction[] = [\n  'sum',\n  'countA',\n  'avg',\n  'max',\n  'min',\n  'product',\n  'count',\n  'stdDev',\n  'stdDevP',\n  'var',\n  'varP',\n];\n\nexport const ITEM_TYPES: ReadonlySet<PivotItemType> = new Set<PivotItemType>([\n  ...SUBTOTAL_FUNCTIONS, 'data', 'default', 'grand', 'blank',\n]);\n","import type { Element } from '@borgar/simple-xml';\nimport type { PivotArea, PivotAreaAxis, PivotAreaReference, PivotAreaType } from '@jsfkit/types';\nimport { addProp } from '../../utils/addProp.ts';\nimport { attr, boolAttr, numAttr } from '../../utils/attr.ts';\nimport { parseEnum } from '../../utils/parseEnum.ts';\n\nconst AREA_TYPES: ReadonlySet<PivotAreaType> = new Set<PivotAreaType>([\n  'none', 'normal', 'data', 'all', 'origin', 'button', 'topRight',\n]);\n\nconst AXIS_VALUES = new Map<string, PivotAreaAxis>([\n  [ 'axisRow', 'row' ],\n  [ 'axisCol', 'col' ],\n  [ 'axisPage', 'page' ],\n  [ 'axisValues', 'values' ],\n]);\n\n// OOXML types pivotArea/@field and reference/@field as xsd:unsignedInt, so\n// sentinel values -2 and -1 are serialized as 4294967294 and 4294967295.\n// Convert to signed representation for JSF (see PivotFieldIndex).\nfunction toSignedFieldIndex (field: number): number {\n  // Values above 0x7FFFFFFF are unsigned representations of negative sentinels\n  return field > 0x7FFFFFFF ? (field | 0) : field;\n}\n\n/** Parse a `<pivotArea>` element into a PivotArea object. */\nexport function parsePivotArea (elm: Element): PivotArea {\n  const area: PivotArea = {};\n  const type = parseEnum(attr(elm, 'type'), AREA_TYPES);\n  if (type != null && type !== 'normal') { area.type = type; }\n  const field = numAttr(elm, 'field');\n  if (field != null) { area.field = toSignedFieldIndex(field); }\n  if (boolAttr(elm, 'dataOnly') === false) { area.dataOnly = false; }\n  if (boolAttr(elm, 'labelOnly') === true) { area.labelOnly = true; }\n  if (boolAttr(elm, 'grandRow') === true) { area.grandRow = true; }\n  if (boolAttr(elm, 'grandCol') === true) { area.grandCol = true; }\n  if (boolAttr(elm, 'cacheIndex') === true) { area.cacheIndex = true; }\n  if (boolAttr(elm, 'outline') === false) { area.outline = false; }\n  addProp(area, 'offset', attr(elm, 'offset'));\n  if (boolAttr(elm, 'collapsedLevelsAreSubtotals') === true) { area.collapsedLevelsAreSubtotals = true; }\n  const axisStr = attr(elm, 'axis');\n  if (axisStr != null) {\n    const axis = AXIS_VALUES.get(axisStr);\n    if (axis) { area.axis = axis; }\n  }\n  addProp(area, 'fieldPosition', numAttr(elm, 'fieldPosition'), 0);\n\n  // references\n  const refsContainer = elm.querySelector('references');\n  if (refsContainer) {\n    const refs: PivotAreaReference[] = [];\n    for (const refEl of refsContainer.getElementsByTagName('reference')) {\n      const ref: PivotAreaReference = {};\n      const refField = numAttr(refEl, 'field');\n      if (refField != null) { ref.field = toSignedFieldIndex(refField); }\n      if (boolAttr(refEl, 'selected') === false) { ref.selected = false; }\n      if (boolAttr(refEl, 'byPosition') === true) { ref.byPosition = true; }\n      if (boolAttr(refEl, 'relative') === true) { ref.relative = true; }\n      // subtotal flags\n      if (boolAttr(refEl, 'defaultSubtotal') === true) { ref.defaultSubtotal = true; }\n      if (boolAttr(refEl, 'sumSubtotal') === true) { ref.sumSubtotal = true; }\n      if (boolAttr(refEl, 'countASubtotal') === true) { ref.countASubtotal = true; }\n      if (boolAttr(refEl, 'avgSubtotal') === true) { ref.avgSubtotal = true; }\n      if (boolAttr(refEl, 'maxSubtotal') === true) { ref.maxSubtotal = true; }\n      if (boolAttr(refEl, 'minSubtotal') === true) { ref.minSubtotal = true; }\n      if (boolAttr(refEl, 'productSubtotal') === true) { ref.productSubtotal = true; }\n      if (boolAttr(refEl, 'countSubtotal') === true) { ref.countSubtotal = true; }\n      if (boolAttr(refEl, 'stdDevSubtotal') === true) { ref.stdDevSubtotal = true; }\n      if (boolAttr(refEl, 'stdDevPSubtotal') === true) { ref.stdDevPSubtotal = true; }\n      if (boolAttr(refEl, 'varSubtotal') === true) { ref.varSubtotal = true; }\n      if (boolAttr(refEl, 'varPSubtotal') === true) { ref.varPSubtotal = true; }\n      // item indices\n      const indices: number[] = [];\n      for (const x of refEl.getElementsByTagName('x')) {\n        indices.push(numAttr(x, 'v', 0));\n      }\n      if (indices.length > 0) { ref.itemIndices = indices; }\n      refs.push(ref);\n    }\n    if (refs.length > 0) { area.references = refs; }\n  }\n\n  return area;\n}\n","import type { Element } from '@borgar/simple-xml';\nimport { boolAttr } from '../../utils/attr.ts';\n\n/** Set boolean properties on target when the XML attribute has the given non-default value. */\nexport function readBoolAttrs<T extends Record<string, unknown>> (\n  target: T, elm: Element, specs: readonly [keyof T & string, boolean][],\n): void {\n  for (const [ prop, nonDefault ] of specs) {\n    if (boolAttr(elm, prop) === nonDefault) {\n      (target as Record<string, unknown>)[prop] = nonDefault;\n    }\n  }\n}\n","import type { Element } from '@borgar/simple-xml';\nimport type { PivotField, PivotFieldItem, PivotSubtotalFunction } from '@jsfkit/types';\nimport { addProp } from '../../utils/addProp.ts';\nimport { attr, boolAttr, numAttr } from '../../utils/attr.ts';\nimport { parseEnum } from '../../utils/parseEnum.ts';\nimport type { NumFmtLookup } from './NumFmtLookup.ts';\nimport { ITEM_TYPES, SUBTOTAL_FUNCTIONS } from './constants.ts';\nimport { parsePivotArea } from './parsePivotArea.ts';\nimport { readBoolAttrs } from './readBoolAttrs.ts';\nimport { resolveNumFmt } from './resolveNumFmt.ts';\n\nexport function parsePivotFields (root: Element, numFmts?: NumFmtLookup): PivotField[] {\n  const fields: PivotField[] = [];\n  for (const pf of root.querySelectorAll('pivotFields > pivotField')) {\n    const field: PivotField = {};\n    addProp(field, 'name', attr(pf, 'name'));\n    const axis = attr(pf, 'axis');\n    if (axis === 'axisRow') {\n      field.axis = 'row';\n    }\n    else if (axis === 'axisCol') {\n      field.axis = 'col';\n    }\n    else if (axis === 'axisPage') {\n      field.axis = 'page';\n    }\n    // check for explicit subtotal attributes on the field\n    const subtotalFunctions: PivotSubtotalFunction[] = [];\n    for (const fn of SUBTOTAL_FUNCTIONS) {\n      const attrName = fn + 'Subtotal';\n      if (boolAttr(pf, attrName) === true) {\n        subtotalFunctions.push(fn);\n      }\n    }\n    if (subtotalFunctions.length > 0) {\n      field.subtotalFunctions = subtotalFunctions;\n    }\n\n    const sortType = attr(pf, 'sortType');\n    if (sortType === 'ascending' || sortType === 'descending') {\n      field.sortType = sortType;\n    }\n\n    const itemsContainer = pf.querySelector('items');\n    if (itemsContainer) {\n      const items: PivotFieldItem[] = [];\n      for (const item of itemsContainer.getElementsByTagName('item')) {\n        const fi: PivotFieldItem = {};\n        addProp(fi, 'itemIndex', numAttr(item, 'x'));\n        addProp(fi, 'itemType', parseEnum(attr(item, 't'), ITEM_TYPES));\n        const h = boolAttr(item, 'h');\n        if (h === true) {\n          fi.hidden = true;\n        }\n        addProp(fi, 'name', attr(item, 'n'));\n        if (boolAttr(item, 'sd') === false) {\n          fi.expanded = false;\n        }\n        if (boolAttr(item, 'm') === true) {\n          fi.missing = true;\n        }\n        items.push(fi);\n      }\n      if (items.length > 0) {\n        field.items = items;\n      }\n    }\n\n    // Boolean field attributes (non-default values only)\n    readBoolAttrs(field, pf, [\n      [ 'dataField', true ],\n      [ 'showAll', false ],\n      // Layout mode\n      [ 'compact', false ],\n      [ 'outline', false ],\n      [ 'subtotalTop', false ],\n      [ 'insertBlankRow', true ],\n      // Subtotal control\n      [ 'defaultSubtotal', false ],\n      // UI/drag behavior\n      [ 'showDropDowns', false ],\n      [ 'dragToRow', false ],\n      [ 'dragToCol', false ],\n      [ 'dragToPage', false ],\n      [ 'dragToData', false ],\n      [ 'dragOff', false ],\n      [ 'multipleItemSelectionAllowed', true ],\n      [ 'insertPageBreak', true ],\n      [ 'hideNewItems', true ],\n      [ 'includeNewItemsInFilter', true ],\n      // Auto-show\n      [ 'autoShow', true ],\n      [ 'topAutoShow', false ],\n      // Sort\n      [ 'nonAutoSortDefault', true ],\n      // OLAP-specific\n      [ 'hiddenLevel', true ],\n      [ 'allDrilled', true ],\n      [ 'serverField', true ],\n      [ 'measureFilter', true ],\n      [ 'showPropCell', true ],\n      [ 'showPropTip', true ],\n      [ 'showPropAsCaption', true ],\n      [ 'defaultAttributeDrillState', true ],\n    ]);\n\n    addProp(field, 'subtotalCaption', attr(pf, 'subtotalCaption'));\n    addProp(field, 'numFmt', resolveNumFmt(pf, numFmts));\n    addProp(field, 'itemPageCount', numAttr(pf, 'itemPageCount'), 10);\n    addProp(field, 'dataSourceSort', boolAttr(pf, 'dataSourceSort'));\n    addProp(field, 'rankBy', numAttr(pf, 'rankBy'));\n    addProp(field, 'uniqueMemberProperty', attr(pf, 'uniqueMemberProperty'));\n\n    // autoSortScope: pivot area defining the sort key\n    const autoSortScopeEl = pf.querySelector('autoSortScope');\n    if (autoSortScopeEl) {\n      const pivotAreaEl = autoSortScopeEl.querySelector('pivotArea');\n      if (pivotAreaEl) {\n        field.autoSortScope = parsePivotArea(pivotAreaEl);\n      }\n    }\n\n    fields.push(field);\n  }\n  return fields;\n}\n","import type { Element } from '@borgar/simple-xml';\nimport type { PivotRowColItem } from '@jsfkit/types';\nimport { attr, numAttr } from '../../utils/attr.ts';\nimport { parseEnum } from '../../utils/parseEnum.ts';\nimport { ITEM_TYPES } from './constants.ts';\n\nexport function parseRowColItems (root: Element, selector: string): PivotRowColItem[] {\n  const items: PivotRowColItem[] = [];\n  for (const elm of root.querySelectorAll(selector)) {\n    const itemType = parseEnum(attr(elm, 't'), ITEM_TYPES);\n    const repeatedItemCount = numAttr(elm, 'r', 0);\n    const itemIndices: number[] = [];\n    for (const x of elm.getElementsByTagName('x')) {\n      itemIndices.push(numAttr(x, 'v', 0));\n    }\n    const item: PivotRowColItem = {};\n    if (itemIndices.length > 0) {\n      item.itemIndices = itemIndices;\n    }\n    if (itemType != null) {\n      item.itemType = itemType;\n    }\n    if (repeatedItemCount !== 0) {\n      item.repeatedItemCount = repeatedItemCount;\n    }\n    const dataFieldIndex = numAttr(elm, 'i', 0);\n    if (dataFieldIndex !== 0) {\n      item.dataFieldIndex = dataFieldIndex;\n    }\n    items.push(item);\n  }\n  return items;\n}\n","import type { Element } from '@borgar/simple-xml';\nimport type { PivotTableStyle, PivotTableStyleName } from '@jsfkit/types';\nimport { attr, boolAttr } from '../../utils/attr.ts';\n\n// NB: readBoolAttrs can't be used here because the OOXML attribute names\n// (showColHeaders, showColStripes) differ from the JSF property names\n// (showColumnHeaders, showColumnStripes).\nexport function parseStyle (root: Element): PivotTableStyle | undefined {\n  const styleInfo = root.querySelector('pivotTableStyleInfo');\n  if (!styleInfo) { return; }\n  const style: PivotTableStyle = {};\n  const styleName = attr(styleInfo, 'name');\n  if (styleName) {\n    // Cast is intentional: Excel allows user-defined custom pivot styles whose\n    // names aren't in the PivotTableStyleName union. We preserve whatever name\n    // the file contains rather than validating against the built-in list.\n    style.name = styleName as PivotTableStyleName;\n  }\n  const showRowHeaders = boolAttr(styleInfo, 'showRowHeaders');\n  if (showRowHeaders != null) {\n    style.showRowHeaders = showRowHeaders;\n  }\n  const showColHeaders = boolAttr(styleInfo, 'showColHeaders');\n  if (showColHeaders != null) {\n    style.showColumnHeaders = showColHeaders;\n  }\n  const showRowStripes = boolAttr(styleInfo, 'showRowStripes');\n  if (showRowStripes != null) {\n    style.showRowStripes = showRowStripes;\n  }\n  const showColStripes = boolAttr(styleInfo, 'showColStripes');\n  if (showColStripes != null) {\n    style.showColumnStripes = showColStripes;\n  }\n  const showLastColumn = boolAttr(styleInfo, 'showLastColumn');\n  if (showLastColumn != null) {\n    style.showLastColumn = showLastColumn;\n  }\n  return style;\n}\n","import type { Document } from '@borgar/simple-xml';\nimport type { PivotTable } from '@jsfkit/types';\nimport { addProp } from '../utils/addProp.ts';\nimport { attr, boolAttr, numAttr } from '../utils/attr.ts';\nimport type { NumFmtLookup } from './pivotTables/NumFmtLookup.ts';\nimport type { PivotTableWithOptionalCache } from './pivotTables/PivotTableWithOptionalCache.ts';\nimport { parseDataFields } from './pivotTables/parseDataFields.ts';\nimport { parseExtensions } from './pivotTables/parseExtensions.ts';\nimport { parseFilters } from './pivotTables/parseFilters.ts';\nimport { parsePageFields } from './pivotTables/parsePageFields.ts';\nimport { parsePivotFields } from './pivotTables/parsePivotFields.ts';\nimport { parseRowColItems } from './pivotTables/parseRowColItems.ts';\nimport { parseStyle } from './pivotTables/parseStyle.ts';\nimport { readBoolAttrs } from './pivotTables/readBoolAttrs.ts';\n\nexport function handlerPivotTable (dom: Document, numFmts?: NumFmtLookup): PivotTableWithOptionalCache | undefined {\n  const root = dom.querySelector('pivotTableDefinition');\n  if (!root) {\n    return;\n  }\n\n  const name = attr(root, 'name');\n  if (!name) {\n    return;\n  }\n\n  const locationEl = root.querySelector('location');\n  if (!locationEl) {\n    return;\n  }\n\n  const ref = attr(locationEl, 'ref');\n  if (!ref) {\n    return;\n  }\n  const firstHeaderRow = numAttr(locationEl, 'firstHeaderRow', 1);\n  const firstDataRow = numAttr(locationEl, 'firstDataRow', 1);\n  const firstDataCol = numAttr(locationEl, 'firstDataCol', 0);\n\n  const fields = parsePivotFields(root, numFmts);\n\n  const rowFieldIndices: number[] = [];\n  for (const f of root.querySelectorAll('rowFields > field')) {\n    rowFieldIndices.push(numAttr(f, 'x', 0));\n  }\n\n  const colFieldIndices: number[] = [];\n  for (const f of root.querySelectorAll('colFields > field')) {\n    colFieldIndices.push(numAttr(f, 'x', 0));\n  }\n\n  const rowItems = parseRowColItems(root, 'rowItems > i');\n  const colItems = parseRowColItems(root, 'colItems > i');\n\n  const dataFields = parseDataFields(root, numFmts);\n\n  const pageFields = parsePageFields(root);\n\n  const style = parseStyle(root);\n\n  const rowGrandTotals = boolAttr(root, 'rowGrandTotals');\n  const colGrandTotals = boolAttr(root, 'colGrandTotals');\n  const autoRefresh = boolAttr(root, 'autoRefresh');\n\n  const location: PivotTable['location'] = { firstHeaderRow, firstDataRow, firstDataCol };\n  const rowPageCount = numAttr(locationEl, 'rowPageCount', 0);\n  if (rowPageCount !== 0) { location.rowPageCount = rowPageCount; }\n  const colPageCount = numAttr(locationEl, 'colPageCount', 0);\n  if (colPageCount !== 0) { location.colPageCount = colPageCount; }\n\n  const pt = {\n    name,\n    sheet: '', // resolved by caller\n    ref,\n    location,\n    fields,\n  } as PivotTableWithOptionalCache;\n\n  if (rowFieldIndices.length > 0) {\n    pt.rowFieldIndices = rowFieldIndices;\n  }\n  if (colFieldIndices.length > 0) {\n    pt.colFieldIndices = colFieldIndices;\n  }\n  if (dataFields.length > 0) {\n    pt.dataFields = dataFields;\n  }\n  if (pageFields.length > 0) {\n    pt.pageFields = pageFields;\n  }\n  if (rowItems.length > 0) {\n    pt.rowItems = rowItems;\n  }\n  if (colItems.length > 0) {\n    pt.colItems = colItems;\n  }\n  if (style) {\n    pt.style = style;\n  }\n  addProp(pt, 'rowGrandTotals', rowGrandTotals, true);   // OOXML default: true\n  addProp(pt, 'colGrandTotals', colGrandTotals, true);  // OOXML default: true\n  addProp(pt, 'autoRefresh', autoRefresh, false);        // OOXML default: false\n\n  // Boolean table-level attributes (non-default values only)\n  readBoolAttrs(pt, root, [\n    // Layout — stored only when deviating from OOXML default\n    [ 'compact', false ],\n    [ 'outline', true ],\n    [ 'outlineData', true ],\n    [ 'compactData', false ],\n    [ 'gridDropZones', true ],\n    // Data axis\n    [ 'dataOnRows', true ],\n    // Display options\n    [ 'showHeaders', false ],\n    [ 'showEmptyRow', true ],\n    [ 'showEmptyCol', true ],\n    [ 'showDropZones', false ],\n    [ 'showMemberPropertyTips', false ],\n    [ 'enableDrill', false ],\n    [ 'showMultipleLabel', false ],\n    // Captions\n    [ 'showError', true ],\n    [ 'showMissing', false ],\n    // Behavior\n    [ 'subtotalHiddenItems', true ],\n    [ 'fieldPrintTitles', true ],\n    [ 'itemPrintTitles', true ],\n    [ 'mergeItem', true ],\n    [ 'customListSort', false ],\n    [ 'multipleFieldFilters', false ],\n    [ 'showItems', false ],\n    [ 'showCalcMbrs', false ],\n    [ 'preserveFormatting', false ],\n    [ 'pageOverThenDown', true ],\n  ]);\n\n  // AutoFormat attributes (AG_AutoFormat attribute group)\n  addProp(pt, 'autoFormatId', numAttr(root, 'autoFormatId'));\n  addProp(pt, 'useAutoFormatting', boolAttr(root, 'useAutoFormatting'));\n  addProp(pt, 'applyNumberFormats', boolAttr(root, 'applyNumberFormats'));\n  addProp(pt, 'applyBorderFormats', boolAttr(root, 'applyBorderFormats'));\n  addProp(pt, 'applyFontFormats', boolAttr(root, 'applyFontFormats'));\n  addProp(pt, 'applyPatternFormats', boolAttr(root, 'applyPatternFormats'));\n  addProp(pt, 'applyAlignmentFormats', boolAttr(root, 'applyAlignmentFormats'));\n  addProp(pt, 'applyWidthHeightFormats', boolAttr(root, 'applyWidthHeightFormats'));\n\n  addProp(pt, 'indent', numAttr(root, 'indent'), 1);\n  addProp(pt, 'dataPosition', numAttr(root, 'dataPosition'));\n  addProp(pt, 'dataCaption', attr(root, 'dataCaption'));\n  addProp(pt, 'grandTotalCaption', attr(root, 'grandTotalCaption'));\n  addProp(pt, 'errorCaption', attr(root, 'errorCaption'));\n  addProp(pt, 'missingCaption', attr(root, 'missingCaption'));\n  addProp(pt, 'rowHeaderCaption', attr(root, 'rowHeaderCaption'));\n  addProp(pt, 'colHeaderCaption', attr(root, 'colHeaderCaption'));\n  addProp(pt, 'pageWrap', numAttr(root, 'pageWrap'), 0);\n  addProp(pt, 'uid', attr(root, 'xr:uid'));\n\n  const filters = parseFilters(root);\n  if (filters.length > 0) { pt.filters = filters; }\n\n  const calculatedFields: PivotTable['calculatedFields'] = [];\n  for (const cfEl of root.querySelectorAll('calculatedFields > calculatedField')) {\n    const cfName = attr(cfEl, 'name');\n    const cfFormula = attr(cfEl, 'formula');\n    if (cfName != null && cfFormula != null) {\n      calculatedFields.push({ name: cfName, formula: cfFormula });\n    }\n  }\n  if (calculatedFields.length > 0) { pt.calculatedFields = calculatedFields; }\n\n  // x14 pivotTableDefinition extension (e.g. hideValuesRow), carried in the table's <extLst>.\n  Object.assign(pt, parseExtensions(root));\n\n  return pt;\n}\n","import type { Element } from '@borgar/simple-xml';\nimport { numAttr } from '../../utils/attr.ts';\nimport type { Point } from '@jsfkit/types';\n\nexport function readPoint (elm: Element | null, nullIfZero = false): Point | undefined {\n  if (elm) {\n    const r = {\n      x: numAttr(elm, 'x', 0),\n      y: numAttr(elm, 'y', 0),\n    };\n    if (nullIfZero && !r.x && !r.y) {\n      return undefined;\n    }\n    return r;\n  }\n  return undefined;\n}\n","import type { Extent } from '@jsfkit/types';\nimport type { Element } from '@borgar/simple-xml';\nimport { numAttr } from '../../utils/attr.ts';\n\nexport function readExtent (elm: Element | null, nullIfZero = false): Extent | undefined {\n  if (elm) {\n    const r = {\n      cx: numAttr(elm, 'cx', 0),\n      cy: numAttr(elm, 'cy', 0),\n    };\n    if (nullIfZero && !r.cx && !r.cy) {\n      return undefined;\n    }\n    return r;\n  }\n  return undefined;\n}\n","import { Element } from '@borgar/simple-xml';\nimport type { CellOffset } from '@jsfkit/types';\n\nexport function readCellPos (elm: Element | null): CellOffset {\n  const out = {\n    row: 0,\n    rowOff: 0,\n    col: 0,\n    colOff: 0,\n  };\n  if (elm) {\n    for (const node of elm.childNodes) {\n      const tagName = (node instanceof Element) ? node.tagName : '';\n      const val = +(node.textContent || '0');\n      if (tagName in out && isFinite(val)) {\n        // @ts-expect-error we already know tagName exists on out because of the above check\n        out[tagName] = val;\n      }\n    }\n  }\n  return out;\n}\n","import type { Element } from '@borgar/simple-xml';\nimport type { GraphicAnchor } from '@jsfkit/types';\nimport { readPoint } from './readPoint.ts';\nimport { readExtent } from './readExtent.ts';\nimport { readCellPos } from './readCellPos.ts';\n\nexport function readAnchor (element: Element | null): GraphicAnchor | undefined {\n  if (element?.tagName === 'absoluteAnchor') {\n    return {\n      type: 'absolute',\n      pos: readPoint(element.querySelector('pos')) ?? { x: 0, y: 0 },\n      ext: readExtent(element.querySelector('ext')) ?? { cx: 0, cy: 0 },\n    };\n  }\n  else if (element?.tagName === 'oneCellAnchor') {\n    return {\n      type: 'oneCell',\n      from: readCellPos(element.querySelector('from')),\n      ext: readExtent(element.querySelector('ext')) ?? { cx: 0, cy: 0 },\n    };\n  }\n  else if (element?.tagName === 'twoCellAnchor') {\n    return {\n      type: 'twoCell',\n      from: readCellPos(element.querySelector('from')),\n      to: readCellPos(element.querySelector('to')),\n    };\n  }\n}\n","import type { Element } from '@borgar/simple-xml';\nimport { boolAttr, numAttr } from '../../utils/attr.ts';\nimport { readPoint } from './readPoint.ts';\nimport type { Xfrm, XfrmGroup } from '@jsfkit/types';\nimport { readExtent } from './readExtent.ts';\n\nexport function readTransforms (elm: Element | null, group: true): XfrmGroup | undefined;\nexport function readTransforms (elm: Element | null, group?: false): Xfrm | undefined;\nexport function readTransforms (elm: Element | null, group = false): Xfrm | XfrmGroup | undefined {\n  if (elm) {\n    // NB: the more liberal type is being set here to avoid type complexity\n    const out: XfrmGroup = {};\n\n    // flipping\n    const flipH = boolAttr(elm, 'flipH', false);\n    const flipV = boolAttr(elm, 'flipV', false);\n    if (flipH && flipV) { out.flip = 'xy'; }\n    else if (flipH) { out.flip = 'x'; }\n    else if (flipV) { out.flip = 'y'; }\n\n    // rotation\n    const rot = numAttr(elm, 'rot', 0);\n    if (rot) { out.rot = rot; }\n\n    // offsets\n    for (const ch of elm.children) {\n      if (ch.tagName === 'off') {\n        const off = readPoint(ch, true);\n        if (off) { out.off = off; }\n      }\n      else if (ch.tagName === 'ext') {\n        const ext = readExtent(ch);\n        if (ext) { out.ext = ext; }\n      }\n\n      if (group) {\n        if (ch.tagName === 'chOff') {\n          const off = readPoint(ch, true);\n          if (off) { out.chOff = off; }\n        }\n        else if (ch.tagName === 'chExt') {\n          const ext = readExtent(ch);\n          if (ext) { out.chExt = ext; }\n        }\n      }\n    }\n\n    if (out.flip || out.rot || out.off || out.ext) {\n      return out;\n    }\n  }\n}\n","import type { Element } from '@borgar/simple-xml';\nimport type { Path, PathFillMode } from '@jsfkit/types';\nimport { attr, boolAttr, numStrAttr } from '../../utils/attr.ts';\nimport { getFirstChild } from '../../utils/getFirstChild.ts';\n\nexport function readPath (p?: Element | null): Path | undefined {\n  if (p?.tagName !== 'path') return;\n\n  const path: Path = { d: [] };\n\n  // if (boolAttr(p, 'extrusionOk')) { path.extrusionOk = true; }\n  if (boolAttr(p, 'stroke') === false) { path.stroke = false; }\n\n  // fill mode for the path -- ST_PathFillMode\n  const fill = attr(p, 'fill') as PathFillMode;\n  if (fill) { path.fill = fill; }\n\n  // max X/Y coordinate of any point within the path\n  const h = attr(p, 'h');\n  if (h) { path.height = +h; }\n  const w = attr(p, 'w');\n  if (w) { path.width = +w; }\n\n  p.children.forEach(elm => {\n    // close\n    if (elm.tagName === 'close') {\n      path.d.push([ 'Z' ]);\n    }\n    // moveTo\n    else if (elm.tagName === 'moveTo') {\n      const pt = getFirstChild(elm, 'pt');\n      if (pt) {\n        path.d.push([\n          'M',\n          numStrAttr(pt, 'x', 0),\n          numStrAttr(pt, 'y', 0),\n        ]);\n      }\n    }\n    // lnTo\n    else if (elm.tagName === 'lnTo') {\n      const pt = getFirstChild(elm, 'pt');\n      if (pt) {\n        path.d.push([\n          'L',\n          numStrAttr(pt, 'x', 0),\n          numStrAttr(pt, 'y', 0),\n        ]);\n      }\n    }\n    // arcTo\n    else if (elm.tagName === 'arcTo') {\n      path.d.push([\n        'A',\n        numStrAttr(elm, 'stAng', 0),\n        numStrAttr(elm, 'swAng', 0),\n        numStrAttr(elm, 'wR', 0),\n        numStrAttr(elm, 'hR', 0),\n      ]);\n    }\n    // quadBezTo\n    else if (elm.tagName === 'quadBezTo') {\n      const pt0 = elm.children[0];\n      const pt1 = elm.children[1];\n      path.d.push([\n        'Q',\n        numStrAttr(pt0, 'x', 0),\n        numStrAttr(pt0, 'y', 0),\n        numStrAttr(pt1, 'x', 0),\n        numStrAttr(pt1, 'y', 0),\n      ]);\n    }\n    // cubicBezTo\n    else if (elm.tagName === 'cubicBezTo') {\n      const pt0 = elm.children[0];\n      const pt1 = elm.children[1];\n      const pt2 = elm.children[2];\n      path.d.push([\n        'C',\n        numStrAttr(pt0, 'x', 0),\n        numStrAttr(pt0, 'y', 0),\n        numStrAttr(pt1, 'x', 0),\n        numStrAttr(pt1, 'y', 0),\n        numStrAttr(pt2, 'x', 0),\n        numStrAttr(pt2, 'y', 0),\n      ]);\n    }\n  });\n\n  if (path.d.length) {\n    return path as Path;\n  }\n}\n","import type { Element } from '@borgar/simple-xml';\nimport type { FlipAxis, GradientColorStop, GradientLinearFill, GradientPathFill, PathFillType, RelativeRect } from '@jsfkit/types';\nimport { getFirstChild } from '../../utils/getFirstChild.ts';\nimport { attr, boolAttr, dmlPercentAttr, numAttr } from '../../utils/attr.ts';\nimport { readColor } from '../../color/readColor.ts';\nimport type { ConversionContext } from '../../ConversionContext.ts';\n\nexport function readFillGradient (\n  elm: Element | null | undefined,\n  context: ConversionContext,\n): GradientPathFill | GradientLinearFill | undefined {\n  if (!elm) { return; }\n  let colorStops: GradientColorStop[] = [];\n  let fillType: 'linearGradient' | 'pathGradient' = 'linearGradient';\n  let fillAngle = 0;\n  let fillScaled = false;\n  let fillPath: PathFillType = 'circle';\n  let fillToRect: RelativeRect | undefined;\n\n  for (const child of elm.children) {\n    if (child.tagName === 'gsLst') {\n      colorStops = [];\n      child.querySelectorAll('>gs').forEach(gs => {\n        const offset = dmlPercentAttr(gs, 'pos');\n        const color = readColor(getFirstChild(gs), context.theme);\n        if (offset != null && color != null) {\n          colorStops.push({ offset, color });\n        }\n      });\n    }\n    else if (child.tagName === 'lin') {\n      fillType = 'linearGradient';\n      fillAngle = numAttr(child, 'ang');\n      fillScaled = boolAttr(child, 'scaled');\n    }\n    else if (child.tagName === 'path') {\n      fillType = 'pathGradient';\n      fillPath = attr(child, 'path') as PathFillType;\n      const fr = getFirstChild(child, 'fillToRect');\n      if (fr) {\n        fillToRect = {\n          t: dmlPercentAttr(fr, 't'),\n          b: dmlPercentAttr(fr, 'b'),\n          l: dmlPercentAttr(fr, 'l'),\n          r: dmlPercentAttr(fr, 'r'),\n        };\n      }\n    }\n  }\n\n  let fill: GradientPathFill | GradientLinearFill;\n  if (fillType === 'linearGradient') {\n    fill = {\n      type: 'linearGradient',\n      colorStops,\n      angle: fillAngle,\n      scaled: fillScaled,\n    };\n  }\n  else if (fillType === 'pathGradient') {\n    fill = {\n      type: 'pathGradient',\n      colorStops,\n      fillToRect,\n      path: fillPath,\n    };\n  }\n  else {\n    return;\n  }\n\n  // Direction(s) in which to flip the gradient while tiling\n  const flip = attr(elm, 'flip') as FlipAxis | undefined;\n  if (flip) { fill.flip = flip; }\n\n  // If a fill will rotate along with a shape when the shape is rotated\n  const rotWithShape = boolAttr(elm, 'rotWithShape', false);\n  if (rotWithShape) { fill.rotWithShape = rotWithShape; }\n\n  return fill;\n}\n","import type { Element } from '@borgar/simple-xml';\nimport { dmlPercentAttr } from '../../utils/attr.ts';\n\nexport function readRelRect (elm?: Element | null) {\n  if (elm) {\n    const l = dmlPercentAttr(elm, 'l');\n    const t = dmlPercentAttr(elm, 't');\n    const r = dmlPercentAttr(elm, 'r');\n    const b = dmlPercentAttr(elm, 'b');\n    if (l != null || t != null || r != null || b != null) {\n      return {\n        t: (t ?? 0),\n        l: (l ?? 0),\n        b: (b ?? 100),\n        r: (r ?? 100),\n      };\n    }\n  }\n}\n","import type { Element } from '@borgar/simple-xml';\nimport type { BlipFill, FlipAxis, RectAlignment, Tile } from '@jsfkit/types';\nimport type { ConversionContext } from '../../ConversionContext.ts';\nimport { attr, boolAttr, dmlPercentAttr, numAttr } from '../../utils/attr.ts';\nimport { readRelRect } from './readRelRect.ts';\nimport { addProp } from '../../utils/addProp.ts';\n\nexport function readFillBlip (elm: Element | undefined | null, context: ConversionContext) {\n  if (elm?.tagName === 'blipFill') {\n    const out: BlipFill = {\n      type: 'blip',\n      mediaId: '',\n    };\n\n    const blip = elm.querySelector('blip');\n    const rId = blip?.getAttribute('r:embed');\n    if (!rId) { return; }\n    const rel = context.drawingRels.find(d => d.id === rId);\n\n    if (rel?.type !== 'image') { return; }\n    out.mediaId = rel.target;\n    context.images.push({ rel, type: 'picture' });\n\n    // Specifies the DPI (dots per inch) used to calculate the size of the blip.\n    const dpi = numAttr(elm, 'dpi', 0);\n    if (dpi) { out.dpi = dpi; }\n\n    // Specifies that the fill should rotate with the shape.\n    const rotWithShape = boolAttr(elm, 'rotWithShape', false);\n    if (rotWithShape) { out.rotWithShape = rotWithShape; }\n\n    const alphaModFix = blip?.querySelector('> alphaModFix');\n    if (alphaModFix) { out.alpha = dmlPercentAttr(alphaModFix, 'amt', 100); }\n\n    const stretchRect = readRelRect(elm.querySelector('> stretch > fillRect'));\n    if (stretchRect) { out.stretchRect = stretchRect; }\n\n    const srcRect = readRelRect(elm.querySelector('> srcRect'));\n    if (srcRect) { out.srcRect = srcRect; }\n\n    const tileElm = elm.querySelector('tile');\n    if (tileElm) {\n      const tile: Tile = {};\n      // additional horizontal offset after alignment (EMU)\n      addProp(tile, 'tx', numAttr(tileElm, 'tx'));\n      // additional vertical offset after alignment (EMU)\n      addProp(tile, 'ty', numAttr(tileElm, 'ty'));\n      // amount to vertically scale the srcRect\n      addProp(tile, 'sx', dmlPercentAttr(tileElm, 'sx'));\n      // amount to horizontally scale the srcRect\n      addProp(tile, 'sy', dmlPercentAttr(tileElm, 'sy'));\n      // direction(s) in which to flip the source image while tiling\n      addProp(tile, 'flip', attr(tileElm, 'flip') as FlipAxis | undefined);\n      // where to align the first tile with respect to the shape (after sx/sy, but before tx/ty)\n      addProp(tile, 'align', attr(tileElm, 'algn') as RectAlignment | undefined);\n      out.tile = tile;\n    }\n\n    return out;\n  }\n}\n","import type { Element } from '@borgar/simple-xml';\nimport type { NoFill, PatternFill, FillPatternStyle, SolidFill, GroupFill, Fill } from '@jsfkit/types';\nimport { attr } from '../../utils/attr.ts';\nimport { getFirstChild } from '../../utils/getFirstChild.ts';\nimport { readColor } from '../../color/readColor.ts';\nimport { readFillGradient } from './readFillGradient.ts';\nimport { readFillBlip } from './readFillBlip.ts';\nimport type { ConversionContext } from '../../ConversionContext.ts';\n\nexport function readFill (elm: Element | null | undefined, context: ConversionContext): Fill | undefined {\n  if (!elm) { return; }\n  const tagName = elm.tagName;\n\n  // Picture Fill – §5.1.10.14\n  if (tagName === 'blipFill') {\n    // recurse/reuse the reader from readGraphicContent?\n    return readFillBlip(elm, context);\n  }\n\n  // Gradient Fill – §5.1.10.33\n  else if (tagName === 'gradFill') {\n    return readFillGradient(elm, context);\n  }\n\n  // No Fill – §5.1.10.44\n  else if (tagName === 'noFill') {\n    return { type: 'none' } as NoFill;\n  }\n\n  // Group Fill – §5.1.10.35\n  else if (tagName === 'grpFill') {\n    return { type: 'group' } as GroupFill;\n  }\n\n  // Pattern Fill – §5.1.10.47\n  else if (tagName === 'pattFill') {\n    const fill = {\n      type: 'pattern',\n      style: attr(elm, 'prst') as FillPatternStyle | undefined,\n    } as PatternFill;\n    for (const ch of elm.children) {\n      if (ch.tagName === 'fgClr') {\n        fill.fg = readColor(getFirstChild(ch), context.theme);\n      }\n      if (ch.tagName === 'bgClr') {\n        fill.bg = readColor(getFirstChild(ch), context.theme);\n      }\n    }\n    return fill;\n  }\n\n  // Solid Fill – §5.1.10.54\n  else if (tagName === 'solidFill') {\n    const child = elm.children[0];\n    if (child) {\n      return {\n        type: 'solid',\n        bg: readColor(child, context.theme),\n      } as SolidFill;\n    }\n  }\n}\n","import type { Element } from '@borgar/simple-xml';\nimport { attr, dmlPercentAttr, numAttr } from '../../utils/attr.ts';\nimport { readFill } from './readFill.ts';\nimport { addProp } from '../../utils/addProp.ts';\nimport type { DashStop, LineEnd, LineEndType, Line, LineStyle, LineEndSize, LineAlignment, LineCapType, LineCompoundType, LineJoinType } from '@jsfkit/types';\nimport type { ConversionContext } from '../../ConversionContext.ts';\n\nconst HEADSIZE: Record<string, LineEndSize> = { lg: 'lg', med: 'med', sm: 'sm' };\nconst LINEALIGN: Record<string, LineAlignment> = { ctr: 'center', in: 'inside' }; // \"outer\" does not exist in DML\nconst LINECAP: Record<string, LineCapType> = { flat: 'butt', rnd: 'round', sq: 'square' };\nconst LINECMPD: Record<string, LineCompoundType> = { dbl: 'dbl', sng: 'sng', thickThin: 'thickThin', thinThick: 'thinThick', tri: 'tri' };\nconst LINEJOIN: Record<string, LineJoinType> = { bevel: 'bevel', round: 'round', square: 'miter' };\n\nexport function readLineProps (elm: Element, context: ConversionContext): Line | undefined {\n  // If we're here, that means a line should be drawn.\n  // - When <a:ln> is absent → no line is rendered\n  // When w is omitted the width is left UNSET: the effective default depends on where the\n  // line is used (drawing shapes render at 0.75pt, chart SERIES lines resolve through the\n  // chart style to 2.25pt), so consumers apply their own context's default.\n  const line: Line = {};\n  addProp(line, 'width', numAttr(elm, 'w'));\n  addProp(line, 'cmpd', LINECMPD[attr(elm, 'cmpd', 'sng')], 'sng');\n  // ECMA-376: when cap is omitted, a value of square is assumed.\n  addProp(line, 'cap', LINECAP[attr(elm, 'cap', 'sq')], 'butt');\n  addProp(line, 'align', LINEALIGN[attr(elm, 'algn', 'ctr')], 'center');\n\n  elm.children.forEach(child => {\n    if (\n      child.tagName === 'noFill' ||\n      child.tagName === 'gradFill' ||\n      child.tagName === 'solidFill' ||\n      child.tagName === 'pattFill'\n    ) {\n      const fill = readFill(child, context);\n      if (fill && fill.type !== 'blip' && fill.type !== 'group') {\n        addProp(line, 'fill', fill);\n      }\n    }\n    else if (child.tagName === 'prstDash') {\n      // Preset Dash) §5.1.10.48\n      addProp(line, 'style', attr(child, 'val', 'solid') as LineStyle, 'solid');\n    }\n    else if (child.tagName === 'custDash') {\n      // Custom Dash: §5.1.10.21\n      // List of elements that specify two attributes:\n      // - d for the length of the dash relative to line width, and\n      // - sp for length of the space relative to line width.\n      const stops: DashStop[] = [];\n      for (const ds of child.children) {\n        if (ds.tagName !== 'ds') continue;\n        const d = dmlPercentAttr(ds, 'd', 0);\n        const sp = dmlPercentAttr(ds, 'sp', 0);\n        stops.push({ d, sp });\n      }\n      if (stops.length) {\n        line.style = stops;\n      }\n    }\n    else if (child.tagName === 'headEnd') {\n      const head: LineEnd = { type: attr(child, 'type', 'none') as LineEndType };\n      if (head.type !== 'none') {\n        addProp(head, 'width', HEADSIZE[attr(child, 'w') ?? ''], 'med');\n        addProp(head, 'len', HEADSIZE[attr(child, 'len') ?? ''], 'med');\n        line.head = head;\n      }\n    }\n    else if (child.tagName === 'tailEnd') {\n      const tail: LineEnd = { type: attr(child, 'type', 'none') as LineEndType };\n      if (tail.type !== 'none') {\n        addProp(tail, 'width', HEADSIZE[attr(child, 'w') ?? ''], 'med');\n        addProp(tail, 'len', HEADSIZE[attr(child, 'len') ?? ''], 'med');\n        line.tail = tail;\n      }\n    }\n    else if (child.tagName in LINEJOIN) {\n      line.join = LINEJOIN[child.tagName];\n    }\n  });\n\n  if (line.fill?.type === 'none') {\n    return undefined;\n  }\n\n  return line;\n}\n","export function hasKeys (obj: object) {\n  if (obj && typeof obj === 'object') {\n    for (const _ in obj) return true;\n  }\n  return false;\n}\n","import type { Element } from '@borgar/simple-xml';\nimport type { Path, Shape, GuidePoint, BlackWhiteMode, ConnectionPoint, AdjustPoint, AdjustValueHandleXY, AdjustValueHandlePolar, ShapeRect } from '@jsfkit/types';\nimport { readTransforms } from './readTransforms.ts';\nimport { readPath } from './readPath.ts';\nimport { attr, numAttr, numStrAttr } from '../../utils/attr.ts';\nimport type { ConversionContext } from '../../ConversionContext.ts';\nimport { getFirstChild } from '../../utils/getFirstChild.ts';\nimport { SHAPE_TYPE } from '../../constants.ts';\nimport { addProp } from '../../utils/addProp.ts';\nimport { readFill } from './readFill.ts';\nimport { readLineProps } from './readLineProps.ts';\nimport { hasKeys } from '../../utils/hasKeys.ts';\n\nfunction readGuides (elm: Element | null): GuidePoint[] | undefined {\n  if (!elm) { return; }\n  const gds: GuidePoint[] = [];\n  elm.children.forEach(gd => {\n    if (gd.tagName === 'gd') {\n      gds.push({\n        name: attr(gd, 'name'),\n        fmla: attr(gd, 'fmla'),\n      });\n    }\n  });\n  return (gds.length) ? gds : undefined;\n}\n\nfunction readAdjustPoint (posElm: Element): AdjustPoint {\n  if (!posElm) {\n    return { x: 0, y: 0 };\n  }\n  return {\n    x: numStrAttr(posElm, 'x', 0),\n    y: numStrAttr(posElm, 'y', 0),\n  };\n}\n\nexport function readShapeProperties (elm: Element | null | undefined, context: ConversionContext): Shape | undefined {\n  const props: Shape = {};\n\n  if (!elm) {\n    return undefined;\n  }\n\n  const bwMode = attr(elm, 'bwMode') as BlackWhiteMode | undefined;\n  if (bwMode && bwMode !== 'auto') { props.bwMode = bwMode; }\n\n  elm.children.forEach(d => {\n    const { tagName } = d;\n\n    if (tagName === 'xfrm') {\n      addProp(props, 'xfrm', readTransforms(d));\n    }\n\n    else if (\n      tagName === 'blipFill' ||\n      tagName === 'gradFill' ||\n      tagName === 'grpFill' ||\n      tagName === 'noFill' ||\n      tagName === 'solidFill' ||\n      tagName === 'pattFill'\n    ) {\n      addProp(props, 'fill', readFill(d, context));\n    }\n\n    // Custom Geometry – §5.1.11.8\n    else if (tagName === 'custGeom') {\n      // ahLst (List of Shape Adjust Handles) §5.1.11.1\n      const ahLst = getFirstChild(d, 'ahLst');\n      const ahs: (AdjustValueHandleXY | AdjustValueHandlePolar)[] = [];\n      ahLst?.children.forEach(ah => {\n        if (ah.tagName === 'ahPolar') {\n          const posElm = getFirstChild(ah, 'pos');\n          if (posElm) {\n            ahs.push({\n              type: 'polar',\n              // name of guide that will update with the angle from this\n              gdRefAng: attr(ah, 'gdRefAng'),\n              maxAng: numStrAttr(ah, 'maxAng'),\n              minAng: numStrAttr(ah, 'minAng'),\n              // name of guide that will update with the radius from this\n              gdRefR: attr(ah, 'gdRefR'),\n              maxR: numStrAttr(ah, 'maxR'),\n              minR: numStrAttr(ah, 'minR'),\n              pos: readAdjustPoint(posElm),\n            });\n          }\n        }\n        else if (ah.tagName === 'ahXY') {\n          const posElm = getFirstChild(ah, 'pos');\n          if (posElm) {\n            ahs.push({\n              type: 'xy',\n              gdRefX: attr(ah, 'gdRefX'),\n              maxX: numAttr(ah, 'maxX'),\n              minX: numAttr(ah, 'minX'),\n              gdRefY: attr(ah, 'gdRefY'),\n              maxY: numAttr(ah, 'maxY'),\n              minY: numAttr(ah, 'minY'),\n              pos: readAdjustPoint(posElm),\n            });\n          }\n        }\n      });\n      if (ahs.length) { props.ah = ahs; }\n\n      // avLst (List of Shape Adjust Values) §5.1.11.5\n      const av = readGuides(d.querySelector('avLst'));\n      if (av?.length) { props.av = av; }\n\n      // cxnLst (List of Shape Connection Sites) §5.1.11.10\n      const cxnList = d.querySelectorAll('cxnLst > cxn');\n      if (cxnList.length) {\n        const cxns: ConnectionPoint[] = [];\n        cxnList.forEach(cElm => {\n          const posElm = getFirstChild(cElm, 'pos');\n          const pos = posElm && readAdjustPoint(posElm);\n          if (pos) {\n            const pt: ConnectionPoint = { pos };\n            const ang = numStrAttr(cElm, 'ang');\n            if (ang) { pt.ang = ang; }\n            cxns.push(pt);\n          }\n        });\n        if (cxns.length) { props.cxn = cxns; }\n      }\n\n      // gdLst (List of Shape Guides) §5.1.11.12\n      const gd = readGuides(d.querySelector('gdLst'));\n      if (gd?.length) { props.gd = gd; }\n\n      // pathLst (List of Shape Paths) §5.1.11.16\n      const paths: Path[] = [];\n      const pathLst = d.querySelector('pathLst');\n      pathLst?.children.forEach(section => {\n        const p = readPath(section);\n        if (p) { paths.push(p); }\n      });\n      if (paths.length) { props.paths = paths; }\n\n      // rect (Shape Text Rectangle) §5.1.11.22\n      const rectElm = d.querySelector('rect');\n      if (rectElm) {\n        // all attr are required\n        const rect: ShapeRect = {\n          t: attr(rectElm, 't'),\n          b: attr(rectElm, 'b'),\n          l: attr(rectElm, 'l'),\n          r: attr(rectElm, 'r'),\n        };\n        // ...but rect itself is redundant if it is t=t/b=b/r=r/l=l\n        if (rect.t !== 't' || rect.b !== 'b' || rect.l !== 'l' || rect.r !== 'r') {\n          props.rect = rect;\n        }\n      }\n    }\n\n    // Outline – §5.1.2.1.24\n    else if (tagName === 'ln') {\n      addProp(props, 'line', readLineProps(d, context));\n    }\n\n    // Preset geometry – §5.1.11.18\n    else if (tagName === 'prstGeom') {\n      const prst = attr(d, 'prst') ?? '';\n      if (SHAPE_TYPE.includes(prst)) {\n        props.preset = prst;\n      }\n      //  Shape Adjust Values (5.1.11.5)\n      const av = readGuides(d.querySelector('avLst'));\n      if (av?.length) { props.av = av; }\n    }\n\n    // 3D Scene Properties – §5.1.4.1.26\n    else if (tagName === 'scene3d') {\n      // TBD\n    }\n\n    // Apply 3D shape properties – §5.1.7.12\n    else if (tagName === 'sp3d') {\n      // TBD\n    }\n\n    // Effect Container – §5.1.10.25\n    else if (tagName === 'effectDag') {\n      // TBD\n    }\n\n    // Effect Container – §5.1.10.26\n    else if (tagName === 'effectLst') {\n      // TBD\n    }\n  });\n\n  return hasKeys(props) ? props : undefined;\n}\n","import type { Element } from '@borgar/simple-xml';\nimport { attr } from '../../utils/attr.ts';\nimport { addProp } from '../../utils/addProp.ts';\nimport type { Paragraph, TextAnchoring, TextBody, TextHorzOverflow, TextVertOverflow, TextWrapping } from '@jsfkit/types';\n\nexport function readTextBody (elm: Element | null | undefined): TextBody | undefined {\n  if (elm?.tagName === 'txBody') {\n    const text: TextBody = { p: [] };\n\n    elm.children.forEach(child => {\n      if (child.tagName === 'bodyPr') {\n        addProp(text, 'vertOverflow', attr(child, 'vertOverflow') as TextVertOverflow | undefined, 'overflow');\n        addProp(text, 'horzOverflow', attr(child, 'horzOverflow') as TextHorzOverflow | undefined, 'overflow');\n        addProp(text, 'wrap', attr(child, 'wrap') as TextWrapping | undefined, 'square');\n        addProp(text, 'anchor', attr(child, 'anchor') as TextAnchoring | undefined, 't');\n        // | <noAutofit />\n        // | <normAutofit fontScale lnSpcReduction />\n        // | <prstTxWarp />\n        // | <scene3d />\n        // | <sp3d />\n        // | <spAutoFit />\n      }\n      else if (child.tagName === 'lstStyle') {\n        // <lstStyle />\n      }\n      else if (child.tagName === 'p') {\n        const para: Paragraph = { text: child.textContent };\n        text.p.push(para);\n        // TODO: rich text\n        // <p>\n        //   <pPr algn=\"ctr\" />\n        //   <r>\n        //     <rPr sz=\"1600\" b=\"0\" i=\"1\" kern=\"1200\" />\n        //     <t>Image in a cell</t>\n        //   </r>\n        // </p>\n      }\n    });\n\n    if (text.p.length && text.p[0].text.length) {\n      return text;\n    }\n  }\n}\n","import type { Element } from '@borgar/simple-xml';\nimport type { Graphic, GraphicBitmap, GraphicChart, GraphicConnectionShape, GraphicGroup, GraphicShape } from '@jsfkit/types';\nimport { boolAttr } from '../../utils/attr.ts';\nimport { readTransforms } from './readTransforms.ts';\nimport { getFirstChild } from '../../utils/getFirstChild.ts';\nimport { readShapeProperties } from './readShapeProperties.ts';\n// import { readShapeStyle } from './readShapeStyle.ts';\nimport { readTextBody } from './readTextBody.ts';\nimport type { ConversionContext } from '../../ConversionContext.ts';\nimport { addProp } from '../../utils/addProp.ts';\nimport { readFillBlip } from './readFillBlip.ts';\n\nexport function readGraphicContent (parent: Element, context: ConversionContext): Graphic[] {\n  const content: Graphic[] = [];\n\n  parent.children.forEach((d: Element) => {\n    // Group Shape\n    if (d.tagName === 'grpSp') {\n      const out: GraphicGroup = {\n        type: 'group',\n        id: '',\n        name: '',\n        // recurse for children, they should be read like other elements in the current list\n        content: readGraphicContent(d, context),\n      };\n      d.children.forEach(child => {\n        // Non-Visual Shape Properties\n        if (child.tagName === 'nvGrpSpPr') {\n          const cNvPr = child.querySelector('>cNvPr');\n          if (cNvPr) {\n            out.id = cNvPr.getAttribute('id') ?? '';\n            out.name = cNvPr.getAttribute('name') ?? '';\n          }\n        }\n        // Group Shape Properties\n        else if (child.tagName === 'grpSpPr') {\n          const xfrm = readTransforms(child.querySelector('>xfrm'), true);\n          if (xfrm) { out.xfrm = xfrm; }\n        }\n      });\n      // if group has no content, we don't need to add it\n      if (out.content.length) {\n        content.push(out);\n      }\n    }\n\n    // Connection Shape\n    else if (d.tagName === 'cxnSp') {\n      const out: GraphicConnectionShape = {\n        type: 'connectionShape',\n        id: '',\n        name: '',\n      };\n      // Non-Visual Shape Properties\n      const cNvPr = d.querySelector('> nvCxnSpPr > cNvPr');\n      if (cNvPr) {\n        out.id = cNvPr.getAttribute('id') ?? '';\n        out.name = cNvPr.getAttribute('name') ?? '';\n      }\n      addProp(out, 'shape', readShapeProperties(getFirstChild(d, 'spPr'), context));\n      addProp(out, 'text', readTextBody(getFirstChild(d, 'txBody')));\n      // addProp(out, 'style', readShapeStyle(getFirstChild(d, 'style'), context));\n      content.push(out);\n    }\n\n    // Shape\n    else if (d.tagName === 'sp') {\n      const out: GraphicShape = {\n        type: 'shape',\n        id: '',\n        name: '',\n      };\n      // Non-Visual Shape Properties\n      const cNvPr = d.querySelector('cNvPr');\n      if (cNvPr) {\n        out.id = cNvPr.getAttribute('id') ?? '';\n        out.name = cNvPr.getAttribute('name') ?? '';\n      }\n      addProp(out, 'shape', readShapeProperties(getFirstChild(d, 'spPr'), context));\n      addProp(out, 'text', readTextBody(getFirstChild(d, 'txBody')));\n      // addProp(out, 'style', readShapeStyle(getFirstChild(d, 'style'), context));\n      content.push(out);\n    }\n\n    // Picture / Bitmap\n    else if (d.tagName === 'pic') {\n      const out: GraphicBitmap = {\n        type: 'bitmap',\n        id: '',\n        name: '',\n        mediaId: '',\n        noChangeAspect: false,\n      };\n      // Non-Visual Properties\n      const cNvPr = d.querySelector('cNvPr');\n      if (cNvPr) {\n        out.id = cNvPr.getAttribute('id') ?? '';\n        out.name = cNvPr.getAttribute('name') ?? '';\n        const desc = cNvPr.getAttribute('descr');\n        if (desc) { out.desc = desc; }\n      }\n      // Non-Visual Picture Drawing Properties\n      //  todo: Support 5.8.2.6: cNvPicPr[preferRelativeResize]\n      const picLocks = d.querySelector('cNvPicPr > picLocks');\n      if (picLocks) { out.noChangeAspect = boolAttr(picLocks, 'noChangeAspect', false); }\n\n      const blipFillElm = d.querySelector('blipFill');\n      const blipFill = readFillBlip(blipFillElm, context);\n      if (blipFill) {\n        // copy props\n        out.mediaId = blipFill.mediaId;\n        out.alpha = blipFill.alpha;\n        out.stretchRect = blipFill.stretchRect;\n        out.srcRect = blipFill.srcRect;\n        addProp(out, 'shape', readShapeProperties(getFirstChild(d, 'spPr'), context));\n        content.push(out);\n      }\n    }\n\n    // Charts\n    else if (d.tagName === 'graphicFrame') {\n      const out: GraphicChart = { type: 'chart', id: '', name: '', chartId: '' };\n      // Non-Visual Properties\n      const cNvPr = d.querySelector('cNvPr');\n      if (cNvPr) {\n        out.id = cNvPr.getAttribute('id') ?? '';\n        out.name = cNvPr.getAttribute('name') ?? '';\n      }\n      // const graphicFrameLocks = d.querySelector('graphicFrameLocks');\n      // if (graphicFrameLocks) { out.locked = {}; }\n\n      // Specifies a 2D transform to be applied to a Graphic Frame:\n      addProp(out, 'xfrm', readTransforms(d.querySelector('xfrm')));\n      // XXX: can't we discard ext: { cx:0, cy:0 } here? Charts contain <ext cx=\"0\" cy=\"0\" />, but this seems wrong.\n\n      // Chart data\n      const chart = d.querySelector('graphicData > chart');\n      if (chart) {\n        const rId = chart.getAttribute('r:id');\n        if (rId) {\n          const rel = context.drawingRels.find(r => r.id === rId);\n          if (rel?.type === 'chart' || rel?.type === 'chartEx') {\n            out.chartId = rel.target; // or rId?\n            context.charts.push({ rel, type: rel?.type });\n            content.push(out);\n          }\n        }\n      }\n    }\n    else if (d.tagName === 'AlternateContent') {\n      for (const x of d.children) {\n        if (x.tagName === 'Choice' && /^cx[1234]$/i.test(x.attr.Requires)) {\n          const ch = getFirstChild(x);\n          if (ch) {\n            content.push(...readGraphicContent(x, context));\n          }\n        }\n      }\n    }\n  });\n\n  return content;\n}\n","import type { Document, Element } from '@borgar/simple-xml';\nimport type { Drawing } from '@jsfkit/types';\nimport { readAnchor } from './drawings/readAnchor.ts';\nimport { readGraphicContent } from './drawings/readGraphicContent.ts';\nimport type { ConversionContext } from '../ConversionContext.ts';\n\nexport function handlerDrawing (dom: Document | null | undefined, context: ConversionContext): Drawing[] {\n  const drawings: Drawing[] = [];\n\n  if (dom?.root) {\n    // loop across anchors\n    dom.root.children.forEach((anchorElm: Element) => {\n      let drawing: Drawing | null = null;\n\n      const tagName = anchorElm.tagName;\n      if (tagName === 'absoluteAnchor' || tagName === 'oneCellAnchor' || tagName === 'twoCellAnchor') {\n        const anch = readAnchor(anchorElm);\n        if (anch) {\n          drawing = {\n            anchor: anch,\n            content: readGraphicContent(anchorElm, context),\n          };\n        }\n      }\n\n      if (drawing?.content?.length) {\n        drawings.push(drawing);\n      }\n    });\n  }\n\n  return drawings;\n}\n","export function arrayBufferToDataUri (buf: ArrayBuffer | Buffer, mime: string): Promise<string> {\n  // Node.js: Convert ArrayBuffer to Buffer if needed\n  let buffer: Buffer;\n  if (typeof Buffer !== 'undefined' && buf instanceof ArrayBuffer) {\n    buffer = Buffer.from(buf);\n  }\n  else if (typeof Buffer !== 'undefined' && buf instanceof Buffer) {\n    buffer = buf;\n  }\n  // Browser\n  else if (typeof FileReader !== 'undefined' && buf instanceof ArrayBuffer) {\n    const blob = new Blob([ buf ], { type: mime });\n    return new Promise((resolve, reject) => {\n      const r = new FileReader();\n      r.onload = () => resolve(r.result as string);\n      r.onerror = reject;\n      r.readAsDataURL(blob);\n    });\n  }\n  else {\n    return Promise.reject(new Error(\"Can't convert binary.\"));\n  }\n  // Node.js: Create data URI\n  const base64 = buffer.toString('base64');\n  return Promise.resolve(`data:${mime};base64,${base64}`);\n}\n","const IMAGE_MIME_TYPES: Record<string, string> = {\n  '.png': 'image/png',\n  '.jpg': 'image/jpeg',\n  '.jpeg': 'image/jpeg',\n  '.gif': 'image/gif',\n  '.emf': 'image/emf',\n  '.wmf': 'image/wmf',\n  '.wdp': 'image/vnd.ms-photo',\n  '.jxr': 'image/vnd.ms-photo',\n  '.hdp': 'image/vnd.ms-photo',\n  '.bmp': 'image/bmp',\n  '.tif': 'image/tiff',\n  '.tiff': 'image/tiff',\n  '.svg': 'image/svg+xml',\n};\n\nexport function getMimeType (filename: string): string {\n  const idx = filename.lastIndexOf('.');\n  const ext = idx !== -1 ? filename.slice(idx).toLowerCase() : '';\n  return (ext && ext in IMAGE_MIME_TYPES)\n    ? IMAGE_MIME_TYPES[ext]\n    : 'application/octet-stream';\n}\n","import type { ZipArchive } from '@borgar/zip';\n\n/**\n * Heuristic to detect whether an XLSX file was likely exported from Google\n * Sheets rather than saved by Excel, LibreOffice, or another desktop app.\n *\n * This matters because Google Sheets encodes formula errors differently:\n * Excel uses `t=\"e\"` on the cell element, while Google Sheets uses `t=\"str\"`\n * with an error-looking cached value (e.g. `#NAME?`). The converter needs to\n * know the origin to avoid misinterpreting a legitimate string formula result\n * as an error.\n *\n * Signals checked (in order):\n *\n * 1. **`docProps/app.xml` present** → not Google Sheets. Excel and LibreOffice\n *    always write this file (containing `<Application>Microsoft Excel</Application>`\n *    or equivalent). Google Sheets never writes it. Validated against ~3,000 real\n *    XLSX files: 0 false negatives (no Google Sheets file writes app.xml),\n *    and the only \"Google Sheets\" files with app.xml were Excel-originated files\n *    uploaded to Google Sheets (which retain Excel's metadata and don't exhibit\n *    the `t=\"str\"` error quirk).\n *\n * 2. **Neither `docProps/app.xml` nor `docProps/core.xml`** → likely Google\n *    Sheets. Google Sheets writes neither. A rare third-party-generated XLSX\n *    might also lack both; treating it as Google Sheets is a safe false\n *    positive for this heuristic's purpose (the `t=\"str\"` error conversion\n *    is unlikely to cause harm on synthetic files).\n */\nexport function isLikelyGSExport (zip: ZipArchive): boolean {\n  // The presence of docProps/app.xml is the strongest negative signal.\n  // Every version of Excel and LibreOffice writes it; Google Sheets never does.\n  if (zip.has('docProps/app.xml')) {\n    return false;\n  }\n  // Google Sheets also omits docProps/core.xml. Checking both gives extra\n  // confidence, but app.xml alone is sufficient — core.xml just corroborates.\n  if (zip.has('docProps/core.xml')) {\n    return false;\n  }\n  return true;\n}\n","import type { Element } from '@borgar/simple-xml';\nimport type { Percentage } from '@jsfkit/types';\n\nexport function boolValElm (elm: Element, fallback = false): boolean {\n  const v = elm?.getAttribute('val');\n  if (v != null) {\n    return v === '1' || v === 'true';\n  }\n  return fallback;\n}\n\nexport function strValElm<T = string> (elm: Element, fallback: T | null = null): T | null {\n  return (elm?.getAttribute('val') as T) ?? fallback;\n}\n\nexport function numValElm (elm: Element, fallback: number | null = null): number | null {\n  const s = elm?.getAttribute('val');\n  if (s != null && isFinite(+s)) {\n    return +s;\n  }\n  return fallback;\n}\n\n/**\n * Read either a percent string (\"100%\") or a number.\n * Ensure that it is within bounds or reject it in favor of `fallback`.\n */\nexport function xperValElm (\n  elm: Element,\n  min = 0,\n  max = Infinity,\n  fallback: Percentage | null = null,\n): Percentage | null {\n  let s = elm?.getAttribute('val');\n  if (s != null) {\n    if (/^\\d+%$/.test(s)) {\n      s = s.slice(0, -1);\n    }\n    const v = +s;\n    if (isFinite(v) && v >= min && v <= max) {\n      return v;\n    }\n  }\n  return fallback;\n}\n","import type { Element } from '@borgar/simple-xml';\nimport { attr, boolAttr, numAttr } from '../../utils/attr.ts';\nimport { addProp } from '../../utils/addProp.ts';\nimport type { TextAnchoring } from '@jsfkit/types';\nimport { hasKeys } from '../../utils/hasKeys.ts';\nimport type { TextProps } from './types/TextProps.ts';\nimport type { ConversionContext } from '../../ConversionContext.ts';\nimport { readColor } from '../../color/readColor.ts';\nimport { getFirstChild } from '../../utils/getFirstChild.ts';\n\n// Excel uses this value on an axis's bodyPr (and elsewhere?) to mean \"rotation is unset, auto-fit\n// labels at render time\". This isn't part of the OOXML spec, naturally. We discard it so it's\n// treated as an absent rot attribute (i.e. no rotation).\n//\n// XXX: Preserve this signal in JSF so a renderer can distinguish \"author chose 0\" from \"Excel chose\n// auto-fit\".\nconst DML_ROT_UNSET = -60000000;\n\n// XXX: add more props\nexport function readTextProps (elm: Element | null, context: ConversionContext): TextProps | undefined {\n  // A rich text block (c:tx/c:rich) shares txPr's internal shape (bodyPr + a:p/a:pPr/defRPr) and\n  // is where titles usually carry their font styling.\n  if (elm?.tagName === 'txPr' || elm?.tagName === 'rich') {\n    const text: TextProps = {};\n    elm.children.forEach(child => {\n      if (child.tagName === 'bodyPr') {\n        addProp(text, 'anchor', attr(child, 'anchor') as TextAnchoring | undefined, 't');\n\n        // Text rotation.\n        const rot = numAttr(child, 'rot');\n        if (rot != null && rot !== DML_ROT_UNSET) {\n          addProp(text, 'rot', rot, 0);\n        }\n      }\n      // Extract the default text colour from <a:p><a:pPr><a:defRPr><a:solidFill>.\n      else if (child.tagName === 'p') {\n        const pPr = child.children.find(c => c.tagName === 'pPr');\n        // Default Text Run Properties\n        const defRPr = pPr?.children.find(c => c.tagName === 'defRPr');\n        if (defRPr) {\n          // const s: Style;\n          // const u: Underline;\n          addProp(text, 'bold', boolAttr(defRPr, 'b'), false);\n          addProp(text, 'italic', boolAttr(defRPr, 'i'), false);\n          // addProp(text, 'underline', attr(defRPr, 'u'), false); // ST_TextUnderlineType\n          // addProp(text, 'spacing', boolAttr(defRPr, 'spc'), 0); // in points * 100\n          addProp(text, 'size', (numAttr(defRPr, 'sz') ?? 0) / 100, 0);\n          // addProp(text, 'strike', attr(defRPr, 'strike')); // ST_TextStrikeType\n          addProp(text, 'caps', attr(defRPr, 'cap') as 'all' | 'none' | null);\n          // fam | scheme\n\n          for (const c of defRPr.children) {\n            if (c.tagName === 'solidFill') {\n              const colorElm = getFirstChild(c);\n              if (colorElm) {\n                const color = readColor(colorElm, context.theme);\n                addProp(text, 'color', color);\n              }\n            }\n            else if (c.tagName === 'latin') {\n              addProp(text, 'typeface', attr(c, 'typeface'), '');\n            }\n          }\n        }\n      }\n    });\n    return hasKeys(text) ? text : undefined;\n  }\n}\n","import type { Element } from '@borgar/simple-xml';\nimport type { ManualLayout } from './types/ManualLayout.ts';\nimport { hasKeys } from '../../utils/hasKeys.ts';\nimport { getFirstChild } from '../../utils/getFirstChild.ts';\nimport { numValElm, strValElm } from './utils/valElm.ts';\nimport { addProp } from '../../utils/addProp.ts';\n\nexport function readLayout (elm: Element): ManualLayout | undefined {\n  const layout: ManualLayout = {};\n\n  const mlElm = getFirstChild(elm, 'manualLayout');\n  if (mlElm) {\n    for (const child of mlElm.children) {\n      if (child.tagName === 'xMode') {\n        addProp(layout, 'xMode', strValElm<'edge' | 'factor'>(child));\n      }\n      else if (child.tagName === 'yMode') {\n        addProp(layout, 'yMode', strValElm<'edge' | 'factor'>(child));\n      }\n      else if (child.tagName === 'wMode') {\n        addProp(layout, 'wMode', strValElm<'edge' | 'factor'>(child));\n      }\n      else if (child.tagName === 'hMode') {\n        addProp(layout, 'hMode', strValElm<'edge' | 'factor'>(child));\n      }\n      else if (child.tagName === 'layoutTarget') {\n        addProp(layout, 'layoutTarget', strValElm<'inner' | 'outer'>(child));\n      }\n      else if (child.tagName === 'x') {\n        addProp(layout, 'x', numValElm(child));\n      }\n      else if (child.tagName === 'y') {\n        addProp(layout, 'y', numValElm(child));\n      }\n      else if (child.tagName === 'w') {\n        addProp(layout, 'w', numValElm(child));\n      }\n      else if (child.tagName === 'h') {\n        addProp(layout, 'h', numValElm(child));\n      }\n    }\n  }\n\n  return hasKeys(layout) ? layout : undefined;\n}\n","import type { Element } from '@borgar/simple-xml';\nimport type { ConversionContext } from '../../ConversionContext.ts';\nimport { boolValElm, numValElm, strValElm } from './utils/valElm.ts';\nimport { addProp } from '../../utils/addProp.ts';\nimport { attr, boolAttr } from '../../utils/attr.ts';\nimport { readShapeProperties } from '../drawings/readShapeProperties.ts';\nimport type { Legend } from './types/legend/Legend.ts';\nimport type { LegendEntry } from './types/legend/LegendEntry.ts';\nimport type { LegendPos } from './types/legend/LegendPos.ts';\nimport { readTextProps } from './readTextProps.ts';\nimport { readLayout } from './readLayout.ts';\n\nexport function readLegend (element: Element, context: ConversionContext): Legend | undefined {\n  const out: Legend = {};\n\n  // ChartEx: position and overlay are attributes on the element itself\n  const posAttr = attr(element, 'pos');\n  if (posAttr != null) {\n    addProp(out, 'pos', posAttr as LegendPos, 'r' as LegendPos);\n  }\n\n  // Only set from the attribute when it is actually present (ChartEx); classic charts carry\n  // overlay as a child element, handled below.\n  addProp(out, 'overlay', boolAttr(element, 'overlay') ?? undefined, false);\n\n  for (const child of element.children) {\n    if (child.tagName === 'legendPos') {\n      // Always emit pos, even at the schema default 'r': the PRESENCE of legendPos means the\n      // legend is docked (the plot area reserves space for it); a manual layout without\n      // legendPos is an undocked, free-floating legend that overlays the plot.\n      addProp(out, 'pos', strValElm(child, 'r'));\n    }\n    else if (child.tagName === 'legendEntry') {\n      const entry: LegendEntry = { idx: 0 };\n      for (const sub of child.children) {\n        if (sub.tagName === 'idx') {\n          entry.idx = numValElm(sub) ?? 0;\n        }\n        else if (sub.tagName === 'delete') {\n          addProp(entry, 'delete', boolValElm(sub), false);\n        }\n        else if (sub.tagName === 'txPr') {\n          addProp(entry, 'textProps', readTextProps(sub, context));\n        }\n      }\n      (out.legendEntry ??= []).push(entry);\n    }\n    else if (child.tagName === 'layout') {\n      addProp(out, 'layout', readLayout(child));\n    }\n    else if (child.tagName === 'overlay') {\n      // true when omitted: false means that this may not overlap the chart\n      addProp(out, 'overlay', boolValElm(child));\n    }\n    else if (child.tagName === 'spPr') {\n      addProp(out, 'shape', readShapeProperties(child, context));\n    }\n    else if (child.tagName === 'txPr') {\n      addProp(out, 'textProps', readTextProps(child, context));\n    }\n  }\n\n  // Excel treats an omitted c:overlay as \"do not overlap the chart\" (it reserves plot-area\n  // space for the legend), and writes the element explicitly when overlap is on.\n  if (out.overlay == null) {\n    out.overlay = false;\n  }\n\n  return out;\n}\n","import type { Element } from '@borgar/simple-xml';\nimport { getFirstChild } from '../../utils/getFirstChild.ts';\nimport type { NumRef } from './types/data/NumRef.ts';\nimport type { StrRef } from './types/data/StrRef.ts';\nimport type { StrData } from './types/data/StrData.ts';\nimport type { MultiLvlStrRef } from './types/data/MultiLvlStrRef.ts';\nimport type { NumData } from './types/data/NumData.ts';\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nfunction readCacheData (ch: Element, data: NumRef | StrRef) {\n  // const numCache = getFirstChild(ch, 'numCache');\n  // if (numCache) {\n  //   const pts = numCache.children.filter(d => d.tagName === 'pt');\n  //   const ptCount = getFirstChild(numCache, 'ptCount');\n  //   // all these props are optional!\n  //   data.numCache = {\n  //     z: getFirstChild(ch, 'formatCode')?.textContent ?? 'General',\n  //     ptCount: numValElm(ptCount) ?? pts.length,\n  //     pts: pts.map((d: Element) => {\n  //       const value = getFirstChild(d, 'v')?.textContent ?? '0';\n  //       const r = { v: isNumeric ? +value : value };\n  //       const formatCode = getFirstChild(d, 'formatCode');\n  //       if (formatCode) {\n  //         r.z = formatCode.textContent || 'General';\n  //       }\n  //       return r;\n  //     }),\n  //   };\n  // }\n}\n\ntype DataSource = NumRef | NumData | StrRef | StrData | MultiLvlStrRef;\n\nexport function readDataSource (element: Element): DataSource | undefined {\n  let data: DataSource | undefined = undefined;\n  // One of:\n  //   <element name=\"multiLvlStrRef\" type=\"CT_MultiLvlStrRef\" minOccurs=\"1\" maxOccurs=\"1\" />\n  //   <element name=\"numRef\" type=\"CT_NumRef\" minOccurs=\"1\" maxOccurs=\"1\" />\n  //   <element name=\"strRef\" type=\"CT_StrRef\" minOccurs=\"1\" maxOccurs=\"1\" />\n  //   <element name=\"numLit\" type=\"CT_NumData\" minOccurs=\"1\" maxOccurs=\"1\" />\n  //   <element name=\"strLit\" type=\"CT_StrData\" minOccurs=\"1\" maxOccurs=\"1\" />\n  const ch = getFirstChild(element);\n  if (ch?.tagName === 'numRef') {\n    data = { type: 'numRef', f: '' };\n    data.f = getFirstChild(ch, 'f')?.textContent ?? '';\n    // if (context.options.includeCacheData) {\n    //   readCacheData(ch, data);\n    // }\n  }\n  else if (ch?.tagName === 'strRef') {\n    data = { type: 'strRef', f: '' };\n    data.f = getFirstChild(ch, 'f')?.textContent ?? '';\n    // if (context.options.includeCacheData) {\n    //   readCacheData(ch, data);\n    // }\n  }\n  else if (ch?.tagName === 'multiLvlStrRef') {\n    // Multi-level (grouped) category/x references span several columns. Consumers resolve the\n    // cells through `f` like the other ref types; dropping the element would lose the series'\n    // category or x data entirely.\n    data = { type: 'mlStrRef', f: getFirstChild(ch, 'f')?.textContent ?? '' };\n  }\n\n  return data;\n}\n","import { CDataNode, Element, TextNode } from '@borgar/simple-xml';\nimport type { Text } from './types/Text.ts';\nimport { getFirstChild } from '../../utils/getFirstChild.ts';\nimport { readDataSource } from './readDataSource.ts';\n\nfunction getTextContent (elm: Element | null | undefined) {\n  let text = '';\n  if (elm) {\n    for (const child of elm.childNodes) {\n      if (child instanceof TextNode || child instanceof CDataNode) {\n        text += child.value;\n      }\n      else if (child instanceof Element) {\n        text += getTextContent(child);\n      }\n    }\n  }\n  return text;\n}\n\nexport function readText (elm: Element | null): Text | undefined {\n  if (elm?.tagName === 'tx') {\n    const child = getFirstChild(elm);\n    if (child?.tagName === 'rich') {\n      const text: Text = {\n        p: [],\n      };\n      const paragraphs = elm.getElementsByTagName('p');\n      for (const para of paragraphs) {\n        const p = { text: '' };\n        text.p.push(p);\n        const ranges = para.getElementsByTagName('r');\n        ranges.forEach(range => {\n          const t = range.querySelector('t');\n          p.text += getTextContent(t);\n        });\n      }\n      return text;\n    }\n    else if (child?.tagName === 'strRef') {\n      const ds = readDataSource(elm);\n      if (ds?.type === 'strRef') {\n        return ds;\n      }\n    }\n    else if (child?.tagName === 'txData') {\n      // ChartEx title/series text: <cx:txData><cx:v>Title text</cx:v></cx:txData>\n      const v = child.querySelector('v')?.textContent;\n      if (v != null) {\n        return { p: [ { text: v } ] };\n      }\n    }\n  }\n}\n","import type { Element } from '@borgar/simple-xml';\nimport type { ConversionContext } from '../../ConversionContext.ts';\nimport { boolValElm } from './utils/valElm.ts';\nimport { addProp } from '../../utils/addProp.ts';\nimport { readShapeProperties } from '../drawings/readShapeProperties.ts';\nimport type { Title } from './types/Title.ts';\nimport { readText } from './readText.ts';\nimport { readTextProps } from './readTextProps.ts';\nimport { readLayout } from './readLayout.ts';\nimport { getFirstChild } from '../../utils/getFirstChild.ts';\n\nexport function readTitle (element: Element, context: ConversionContext): Title | undefined {\n  const out: Title = {};\n  for (const child of element.children) {\n    if (child.tagName === 'tx') {\n      addProp(out, 'text', readText(child));\n      // Title font styling usually lives on the rich text block rather than a title-level txPr\n      // (which, per schema order, comes later and overwrites this when present).\n      const rich = getFirstChild(child, 'rich');\n      if (rich) {\n        addProp(out, 'textProps', readTextProps(rich, context));\n      }\n    }\n    else if (child.tagName === 'txPr') {\n      addProp(out, 'textProps', readTextProps(child, context));\n    }\n    else if (child.tagName === 'layout') {\n      addProp(out, 'layout', readLayout(child));\n    }\n    else if (child.tagName === 'overlay') {\n      addProp(out, 'overlay', boolValElm(child));\n    }\n    else if (child.tagName === 'spPr') {\n      addProp(out, 'shape', readShapeProperties(child, context));\n    }\n  }\n\n  // overlay is true when omitted but we're flipping the default to false in JSF\n  if (out.overlay == null) {\n    out.overlay = true;\n  }\n\n  return out;\n}\n","import { Element } from '@borgar/simple-xml';\nimport type { ConversionContext } from '../../ConversionContext.ts';\nimport { numValElm, strValElm } from './utils/valElm.ts';\nimport { readShapeProperties } from '../drawings/readShapeProperties.ts';\nimport type { Marker } from './types/marker/Marker.ts';\nimport type { MarkerStyle } from './types/marker/MarkerStyle.ts';\n\nexport function readMarker (element: Element, context: ConversionContext): Marker {\n  const marker: Marker = {};\n  for (const child of element.children) {\n    if (child.tagName === 'symbol') {\n      const val = strValElm<MarkerStyle>(child);\n      if (val) { marker.symbol = val; }\n    }\n    else if (child.tagName === 'size') {\n      const val = numValElm(child);\n      if (val !== null) { marker.size = val; }\n    }\n    else if (child.tagName === 'spPr') {\n      marker.shape = readShapeProperties(child, context);\n    }\n  }\n  return marker;\n}\n","import type { Element } from '@borgar/simple-xml';\nimport type { ConversionContext } from '../../ConversionContext.ts';\nimport { numValElm } from './utils/valElm.ts';\nimport { readMarker } from './readMarker.ts';\nimport { readShapeProperties } from '../drawings/readShapeProperties.ts';\nimport { readTextProps } from './readTextProps.ts';\nimport { getFirstChild } from '../../utils/getFirstChild.ts';\nimport { addProp } from '../../utils/addProp.ts';\nimport type { PivotFmts } from './types/PivotFmts.ts';\nimport type { PivotFmt } from './types/PivotFmt.ts';\n\n/**\n * Read `<c:pivotFmts>`: the per-series/point formats a pivot chart persists across pivot\n * refreshes. Excel regenerates the `<c:ser>` elements from the pivot on load, so these entries\n * are the only formatting that survives — e.g. an explicit \"no markers\" choice lives here.\n * (`dLbl` children are not read yet.)\n */\nexport function readPivotFmts (element: Element, context: ConversionContext): PivotFmts | undefined {\n  const pivotFmt: PivotFmt[] = [];\n  for (const child of element.children) {\n    if (child.tagName !== 'pivotFmt') { continue; }\n    const idx = numValElm(getFirstChild(child, 'idx')!);\n    if (idx == null) { continue; }\n    const fmt: PivotFmt = { idx };\n    const spPr = getFirstChild(child, 'spPr');\n    if (spPr) {\n      addProp(fmt, 'shape', readShapeProperties(spPr, context));\n    }\n    const marker = getFirstChild(child, 'marker');\n    if (marker) {\n      addProp(fmt, 'marker', readMarker(marker, context));\n    }\n    const txPr = getFirstChild(child, 'txPr');\n    if (txPr) {\n      addProp(fmt, 'textProps', readTextProps(txPr, context));\n    }\n    pivotFmt.push(fmt);\n  }\n  return pivotFmt.length ? { pivotFmt } : undefined;\n}\n","import { Element } from '@borgar/simple-xml';\nimport type { ConversionContext } from '../../ConversionContext.ts';\nimport { boolValElm, numValElm } from './utils/valElm.ts';\nimport { readShapeProperties } from '../drawings/readShapeProperties.ts';\nimport type { DataPoint } from './types/seriesEx/DataPoint.ts';\nimport { addProp } from '../../utils/addProp.ts';\n\nexport function readDataPoint (element: Element, context: ConversionContext): DataPoint | undefined {\n  const dp: Partial<DataPoint> = {};\n  for (const child of element.children) {\n    if (child.tagName === 'idx') {\n      const val = numValElm(child);\n      if (val !== null) { dp.idx = val; }\n    }\n    else if (child.tagName === 'spPr') {\n      dp.shape = readShapeProperties(child, context);\n    }\n    else if (child.tagName === 'bubble3D') {\n      addProp(dp, 'bubble3D', boolValElm(child), false);\n    }\n    else if (child.tagName === 'explosion') {\n      addProp(dp, 'explosion', numValElm(child));\n    }\n  }\n  if (dp.idx != null) {\n    return dp as DataPoint;\n  }\n}\n","import type { NumDataSource } from '../types/data/NumDataSource.ts';\n\nexport function isNumDataSource (item: unknown): item is NumDataSource {\n  return (\n    !!item &&\n    typeof item === 'object' &&\n    'type' in item &&\n    (item.type === 'numRef' || item.type === 'numData')\n  );\n}\n","import { Element } from '@borgar/simple-xml';\nimport type { ConversionContext } from '../../ConversionContext.ts';\nimport { boolValElm, numValElm, strValElm } from './utils/valElm.ts';\nimport { addProp } from '../../utils/addProp.ts';\nimport { readShapeProperties } from '../drawings/readShapeProperties.ts';\nimport { readDataSource } from './readDataSource.ts';\nimport type { ErrBars } from './types/errorbars/ErrBars.ts';\nimport type { ErrBarType } from './types/errorbars/ErrBarType.ts';\nimport type { ErrValType } from './types/errorbars/ErrValType.ts';\nimport type { ErrDir } from './types/errorbars/ErrDir.ts';\nimport { isNumDataSource } from './utils/isNumDataSource.ts';\n\nexport function readErrBars (element: Element, context: ConversionContext): ErrBars | undefined {\n  const errBars: Partial<ErrBars> = {};\n\n  for (const child of element.children) {\n    if (child.tagName === 'errBarType') {\n      addProp(errBars, 'errBarType', strValElm<ErrBarType>(child));\n    }\n    else if (child.tagName === 'errValType') {\n      addProp(errBars, 'errValType', strValElm<ErrValType>(child));\n    }\n    else if (child.tagName === 'errDir') {\n      addProp(errBars, 'errDir', strValElm<ErrDir>(child));\n    }\n    else if (child.tagName === 'noEndCap') {\n      addProp(errBars, 'noEndCap', boolValElm(child));\n    }\n    else if (child.tagName === 'plus') {\n      const ds = readDataSource(child);\n      if (isNumDataSource(ds)) {\n        addProp(errBars, 'plus', ds);\n      }\n    }\n    else if (child.tagName === 'minus') {\n      const ds = readDataSource(child);\n      if (isNumDataSource(ds)) {\n        addProp(errBars, 'minus', ds);\n      }\n    }\n    else if (child.tagName === 'val') {\n      addProp(errBars, 'val', numValElm(child));\n    }\n    else if (child.tagName === 'spPr') {\n      errBars.shape = readShapeProperties(child, context);\n    }\n  }\n\n  if (errBars.errBarType && errBars.errValType) {\n    return errBars as ErrBars;\n  }\n}\n","import type { Element } from '@borgar/simple-xml';\nimport { attr, boolAttr } from '../../utils/attr.ts';\nimport type { NumFmt } from './types/NumFmt.ts';\n\nexport function readNumFmt (element: Element): NumFmt | undefined {\n  if (element?.tagName === 'numFmt') {\n    const formatCode = attr(element, 'formatCode');\n    const sourceLinked = boolAttr(element, 'sourceLinked');\n    // Keep General too: a PRESENT numFmt with formatCode=\"General\" sourceLinked=\"1\" is Excel's\n    // \"linked to source\" marker (e.g. a value axis inheriting the source cells' format), which\n    // is distinct from the element being absent entirely (plain General, no inheritance).\n    if (formatCode) {\n      if (sourceLinked === false) {\n        return { formatCode, sourceLinked };\n      }\n      return { formatCode };\n    }\n  }\n}\n","import { Element } from '@borgar/simple-xml';\nimport type { ConversionContext } from '../../ConversionContext.ts';\nimport type { DLbls } from './types/datalabels/DLbls.ts';\nimport type { DLblShared } from './types/datalabels/DLblShared.ts';\nimport type { DLbl } from './types/datalabels/DLbl.ts';\nimport { boolValElm, numValElm, strValElm } from './utils/valElm.ts';\nimport { readShapeProperties } from '../drawings/readShapeProperties.ts';\nimport { addProp } from '../../utils/addProp.ts';\nimport { readNumFmt } from './readNumFmt.ts';\nimport { readTextProps } from './readTextProps.ts';\nimport { readText } from './readText.ts';\nimport type { DLblPos } from './types/datalabels/DLblPos.ts';\nimport { getFirstChild } from '../../utils/getFirstChild.ts';\nimport { readLayout } from './readLayout.ts';\n\nfunction readDLblShared (element: Element, context: ConversionContext): DLblShared {\n  const label: DLblShared = {};\n  for (const child of element.children) {\n    if (child.tagName === 'numFmt') {\n      addProp(label, 'numFmt', readNumFmt(child));\n    }\n    else if (child.tagName === 'spPr') {\n      addProp(label, 'shape', readShapeProperties(child, context));\n    }\n    else if (child.tagName === 'txPr') {\n      addProp(label, 'textProps', readTextProps(child, context));\n    }\n    else if (child.tagName === 'dLblPos') {\n      addProp(label, 'dLblPos', strValElm<DLblPos>(child));\n    }\n    else if (child.tagName === 'showLegendKey') {\n      addProp(label, 'showLegendKey', boolValElm(child), false);\n    }\n    else if (child.tagName === 'showVal') {\n      addProp(label, 'showVal', boolValElm(child), false);\n    }\n    else if (child.tagName === 'showCatName') {\n      addProp(label, 'showCatName', boolValElm(child), false);\n    }\n    else if (child.tagName === 'showSerName') {\n      addProp(label, 'showSerName', boolValElm(child), false);\n    }\n    else if (child.tagName === 'showPercent') {\n      addProp(label, 'showPercent', boolValElm(child), false);\n    }\n    else if (child.tagName === 'showBubbleSize') {\n      addProp(label, 'showBubbleSize', boolValElm(child), false);\n    }\n    else if (child.tagName === 'separator') {\n      label.separator = child.textContent;\n    }\n  }\n  return label;\n}\n\nfunction readDLbl (element: Element, context: ConversionContext): DLbl | undefined {\n  const label: Partial<DLbl> = {};\n\n  for (const child of element.children) {\n    if (child.tagName === 'idx') {\n      addProp(label, 'idx', numValElm(child));\n    }\n    else if (child.tagName === 'delete') {\n      label.delete = boolValElm(child);\n    }\n    else if (child.tagName === 'layout') {\n      addProp(label, 'layout', readLayout(child));\n    }\n    else if (child.tagName === 'tx') {\n      addProp(label, 'text', readText(child));\n    }\n  }\n\n  if (label.idx != null) {\n    const sh = readDLblShared(element, context);\n    if (sh) { Object.assign(label, sh); }\n\n    return label as DLbl;\n  }\n}\n\nexport function readDLbls (element: Element, context: ConversionContext): DLbls {\n  const labels: DLbls = {};\n\n  for (const child of element.children) {\n    if (child.tagName === 'dLbl') {\n      const lbl = readDLbl(child, context);\n      if (lbl) {\n        if (!labels.dLbl) { labels.dLbl = []; }\n        labels.dLbl.push(lbl);\n      }\n    }\n    else if (child.tagName === 'delete') {\n      addProp(labels, 'delete', boolValElm(child));\n    }\n    else if (child.tagName === 'showLeaderLines') {\n      addProp(labels, 'showLeaderLines', boolValElm(child));\n    }\n    else if (child.tagName === 'leaderLines') { // TODO: ChartLines\n      const spPr = getFirstChild(child, 'spPr');\n      const shape = spPr && readShapeProperties(spPr, context);\n      if (shape) {\n        labels.leaderLines = { shape };\n      }\n    }\n  }\n\n  const sh = readDLblShared(element, context);\n  if (sh) { Object.assign(labels, sh); }\n\n  return labels;\n}\n","import type { Element } from '@borgar/simple-xml';\nimport type { ConversionContext } from '../../ConversionContext.ts';\nimport type { Trendline } from './types/trendline/Trendline.ts';\nimport { addProp } from '../../utils/addProp.ts';\nimport { boolValElm, numValElm, strValElm } from './utils/valElm.ts';\nimport type { TrendlineType } from './types/trendline/TrendlineType.ts';\nimport { readShapeProperties } from '../drawings/readShapeProperties.ts';\n\nexport function readTrendline (elm: Element, context: ConversionContext): Trendline {\n  const tl: Trendline = { type: 'linear' };\n\n  for (const child of elm.children) {\n    if (child.tagName === 'name') {\n      tl.name = child.textContent;\n    }\n    else if (child.tagName === 'trendlineType') {\n      addProp(tl, 'type', strValElm<TrendlineType>(child));\n    }\n    else if (child.tagName === 'order') {\n      // min=2, max=6\n      addProp(tl, 'order', numValElm(child), 2);\n    }\n    else if (child.tagName === 'forward') {\n      addProp(tl, 'forward', numValElm(child));\n    }\n    else if (child.tagName === 'backward') {\n      addProp(tl, 'backward', numValElm(child));\n    }\n    else if (child.tagName === 'period') {\n      // min=2\n      addProp(tl, 'period', numValElm(child), 2);\n    }\n    else if (child.tagName === 'intercept') {\n      addProp(tl, 'intercept', numValElm(child));\n    }\n    else if (child.tagName === 'dispRSqr') {\n      addProp(tl, 'dispRSqr', boolValElm(child), false);\n    }\n    else if (child.tagName === 'dispEq') {\n      addProp(tl, 'dispEq', boolValElm(child), false);\n    }\n    else if (child.tagName === 'spPr') {\n      addProp(tl, 'shape', readShapeProperties(child, context));\n    }\n    else if (child.tagName === 'label') { // TODO: TrendlineLbl\n      // console.log(String(child));\n    }\n    else {\n      // console.log(child.tagName);\n    }\n  }\n\n  return tl;\n}\n","import { Element } from '@borgar/simple-xml';\nimport type { ConversionContext } from '../../ConversionContext.ts';\nimport { boolValElm, numValElm } from './utils/valElm.ts';\nimport { addProp } from '../../utils/addProp.ts';\nimport { readShapeProperties } from '../drawings/readShapeProperties.ts';\nimport { readDataSource } from './readDataSource.ts';\nimport type { Series } from './types/series/Series.ts';\nimport { readDataPoint } from './readDataPoint.ts';\nimport { readMarker } from './readMarker.ts';\nimport { readErrBars } from './readErrBars.ts';\nimport { isNumDataSource } from './utils/isNumDataSource.ts';\nimport { readDLbls } from './readDLbls.ts';\nimport { readTrendline } from './readTrendline.ts';\nimport { getFirstChild } from '../../utils/getFirstChild.ts';\n\nexport function readSeries (element: Element, context: ConversionContext): Series | undefined {\n  const out: Partial<Series> = {};\n\n  for (const child of element.children) {\n    if (child.tagName === 'idx') {\n      out.idx = numValElm(child) ?? 0;\n    }\n    else if (child.tagName === 'order') {\n      out.order = numValElm(child) ?? 0;\n    }\n    else if (child.tagName === 'explosion') {\n      addProp(out, 'explosion', numValElm(child), 0);\n    }\n    else if (child.tagName === 'tx') {\n      const ds = readDataSource(child);\n      if (ds?.type === 'strRef') {\n        addProp(out, 'text', ds);\n      }\n      else {\n        const v = getFirstChild(child, 'v');\n        if (v?.tagName === 'v') {\n          out.text = v.textContent;\n        }\n      }\n    }\n    else if (child.tagName === 'spPr') {\n      out.shape = readShapeProperties(child, context);\n    }\n    else if (child.tagName === 'marker') {\n      addProp(out, 'marker', readMarker(child, context));\n    }\n    else if (child.tagName === 'invertIfNegative') {\n      addProp(out, 'invertIfNegative', boolValElm(child), false);\n    }\n    else if (child.tagName === 'pictureOptions') {\n      // console.log(child.toString());\n    }\n    else if (child.tagName === 'dPt') {\n      const dPts = element.querySelectorAll('>dPt');\n      if (dPts.length) {\n        const dPt = [];\n        for (const dpElm of dPts) {\n          const d = readDataPoint(dpElm, context);\n          if (d) { dPt.push(d); }\n        }\n        if (dPt.length) {\n          out.dPt = dPt;\n        }\n      }\n    }\n    else if (child.tagName === 'dLbls') {\n      addProp(out, 'dLbls', readDLbls(child, context));\n    }\n    else if (child.tagName === 'trendline') {\n      const trendlines = element.querySelectorAll('>trendline');\n      if (trendlines.length) {\n        out.trendline = trendlines.map(d => readTrendline(d, context));\n      }\n    }\n    else if (child.tagName === 'errBars') {\n      addProp(out, 'errBars', readErrBars(child, context));\n    }\n\n    // Scatter series use xVal/yVal instead of cat/val.\n    // Both cat and val use the same data source reader, the difference is that the output types can be:\n    // - cat/xVal: [ MultiLvlStrRef, NumRef, StrRef, NumData, StrData ]\n    // - val/yVal: [ NumRef, NumData ]\n    else if (child.tagName === 'cat' || child.tagName === 'xVal') {\n      addProp(out, 'cat', readDataSource(child));\n    }\n    else if (child.tagName === 'val' || child.tagName === 'yVal') {\n      const ds = readDataSource(child);\n      if (isNumDataSource(ds)) {\n        addProp(out, 'val', ds);\n      }\n    }\n\n    else if (child.tagName === 'smooth') {\n      addProp(out, 'smooth', boolValElm(child));\n    }\n\n    // Bubble series add a third numeric dimension carrying the bubble size.\n    else if (child.tagName === 'bubbleSize') {\n      const ds = readDataSource(child);\n      if (isNumDataSource(ds)) {\n        addProp(out, 'bubbleSize', ds);\n      }\n    }\n    else if (child.tagName === 'bubble3D') {\n      addProp(out, 'bubble3D', boolValElm(child), false);\n    }\n\n    // barShape\n    else if (child.tagName === 'shape') {\n      // addProp(out, 'barShape', strValElm(child, 'shape))\n    }\n  }\n\n  return out as Series;\n}\n","import type { AxPos } from './types/axes/AxPos.ts';\nimport type { BuiltInUnit } from './types/axes/BuiltInUnit.ts';\nimport type { CatAx } from './types/axes/CatAx.ts';\nimport type { ConversionContext } from '../../ConversionContext.ts';\nimport type { CrossBetween } from './types/axes/CrossBetween.ts';\nimport type { Crosses } from './types/axes/Crosses.ts';\nimport type { DateAx } from './types/axes/DateAx.ts';\nimport type { DispUnitsLbl } from './types/axes/DispUnitsLbl.ts';\nimport type { Element } from '@borgar/simple-xml';\nimport type { LblAlgn } from './types/axes/LblAlgn.ts';\nimport type { Orientation } from './types/axes/Orientation.ts';\nimport type { Scaling } from './types/axes/Scaling.ts';\nimport type { SerAx } from './types/axes/SerAx.ts';\nimport type { TickLblPos } from './types/axes/TickLblPos.ts';\nimport type { TickMark } from './types/axes/TickMark.ts';\nimport type { TimeUnit } from './types/axes/TimeUnit.ts';\nimport type { ValAx } from './types/axes/ValAx.ts';\nimport { addProp } from '../../utils/addProp.ts';\nimport { boolValElm, numValElm, strValElm, xperValElm } from './utils/valElm.ts';\nimport { hasKeys } from '../../utils/hasKeys.ts';\nimport { readShapeProperties } from '../drawings/readShapeProperties.ts';\nimport { readTitle } from './readTitle.ts';\nimport type { DispUnits } from './types/axes/DispUnits.ts';\nimport { readTextProps } from './readTextProps.ts';\nimport { readText } from './readText.ts';\nimport { readNumFmt } from './readNumFmt.ts';\n\nfunction readScaling (element: Element): Scaling | undefined {\n  const out: Scaling = {};\n  for (const child of element.children) {\n    if (child.tagName === 'logBase') {\n      const logBase = numValElm(child);\n      if (logBase && logBase >= 2 && logBase <= 1000) {\n        out.logBase = logBase;\n      }\n    }\n    else if (child.tagName === 'orientation') {\n      addProp(out, 'orientation', strValElm(child) as Orientation | undefined);\n    }\n    else if (child.tagName === 'max') {\n      addProp(out, 'max', numValElm(child));\n    }\n    else if (child.tagName === 'min') {\n      addProp(out, 'min', numValElm(child));\n    }\n  }\n  return hasKeys(out) ? out : undefined;\n}\n\nfunction readDispUnits (element: Element, context: ConversionContext): DispUnits | undefined {\n  let custUnit: number | null = null;\n  let builtInUnit: BuiltInUnit | null = null;\n  let dispUnitsLbl: DispUnitsLbl | null = null;\n\n  for (const child of element.children) {\n    if (child.tagName === 'custUnit') {\n      custUnit = numValElm(child);\n    }\n    else if (child.tagName === 'builtInUnit') {\n      builtInUnit = strValElm<BuiltInUnit>(child);\n    }\n    else if (child.tagName === 'dispUnitsLbl') {\n      dispUnitsLbl = {};\n      for (const grandchild of child.children) {\n        if (grandchild.tagName === 'layout') {\n          // TODO: readLayout -- see Legend\n        }\n        else if (grandchild.tagName === 'spPr') {\n          addProp(dispUnitsLbl, 'shape', readShapeProperties(grandchild, context));\n        }\n        else if (grandchild.tagName === 'tx') {\n          addProp(dispUnitsLbl, 'text', readText(grandchild));\n        }\n        else if (grandchild.tagName === 'txPr') {\n          addProp(dispUnitsLbl, 'textProps', readTextProps(grandchild, context));\n        }\n      }\n    }\n  }\n  let out: DispUnits | undefined = undefined;\n  if (custUnit) {\n    out = { custUnit };\n  }\n  if (builtInUnit) {\n    return { builtInUnit };\n  }\n  if (out && dispUnitsLbl) {\n    out.dispUnitsLbl = dispUnitsLbl;\n  }\n  return out;\n}\n\nexport function readAxis (element: Element, context: ConversionContext): ValAx | DateAx | SerAx | CatAx | undefined {\n  const axType = element.tagName;\n  if (axType !== 'valAx' && axType !== 'catAx' && axType !== 'serAx' && axType !== 'dateAx') { return; }\n\n  const out: Partial<ValAx | DateAx | SerAx | CatAx> = { type: axType };\n\n  for (const child of element.children) {\n    const tag = child.tagName;\n\n    // specific to ValAx\n    if (out.type === 'valAx') {\n      if (tag === 'crossBetween') {\n        addProp(out, 'crossBetween', strValElm<CrossBetween>(child));\n      }\n      else if (tag === 'majorUnit') {\n        addProp(out, 'majorUnit', numValElm(child));\n      }\n      else if (tag === 'minorUnit') {\n        addProp(out, 'minorUnit', numValElm(child));\n      }\n      else if (tag === 'dispUnits') {\n        addProp(out, 'dispUnits', readDispUnits(child, context));\n      }\n    }\n\n    // specific to CatAx\n    if (out.type === 'catAx') {\n      // XXX: extends SerAx?\n\n      if (tag === 'auto') {\n        addProp(out, 'auto', boolValElm(child), false);\n      }\n      else if (tag === 'lblAlgn') {\n        addProp(out, 'lblAlgn', strValElm<LblAlgn>(child));\n      }\n      else if (tag === 'lblOffset') {\n        // 0-1000, defaults to \"100%\"\n        addProp(out, 'lblOffset', xperValElm(child, 0, 1000, 100), 100);\n      }\n      else if (tag === 'tickLblSkip') {\n        // 1-∞\n        const n = numValElm(child) ?? 0;\n        addProp(out, 'tickLblSkip', n < 1 ? null : n);\n      }\n      else if (tag === 'tickMarkSkip') {\n        // 1-∞\n        const n = numValElm(child) ?? 0;\n        addProp(out, 'tickMarkSkip', n < 1 ? null : n);\n      }\n      else if (tag === 'noMultiLvlLbl') {\n        addProp(out, 'noMultiLvlLbl', boolValElm(child), false);\n      }\n    }\n\n    // specific to SerAx\n    if (out.type === 'serAx') {\n      if (tag === 'tickLblSkip') {\n        // 1-∞\n        const n = numValElm(child)!;\n        addProp(out, 'tickLblSkip', n < 1 ? null : n);\n      }\n      else if (tag === 'tickMarkSkip') {\n        // 1-∞\n        const n = numValElm(child)!;\n        addProp(out, 'tickMarkSkip', n < 1 ? null : n);\n      }\n    }\n\n    // specific to DateAx\n    if (out.type === 'dateAx') {\n      if (tag === 'auto') {\n        addProp(out, 'auto', boolValElm(child), false);\n      }\n      else if (tag === 'lblOffset') {\n        // 0-1000, defaults to \"100%\"\n        addProp(out, 'lblOffset', xperValElm(child, 0, 1000, 100), 100);\n      }\n      else if (tag === 'majorUnit') {\n        addProp(out, 'majorUnit', numValElm(child));\n      }\n      else if (tag === 'minorUnit') {\n        addProp(out, 'minorUnit', numValElm(child));\n      }\n      else if (tag === 'baseTimeUnit') {\n        addProp(out, 'baseTimeUnit', strValElm<TimeUnit>(child, 'days'), 'days');\n      }\n      else if (tag === 'majorTimeUnit') {\n        addProp(out, 'majorTimeUnit', strValElm<TimeUnit>(child, 'days'), 'days');\n      }\n      else if (tag === 'minorTimeUnit') {\n        addProp(out, 'minorTimeUnit', strValElm<TimeUnit>(child, 'days'), 'days');\n      }\n    }\n\n    // shared by all axes\n    if (tag === 'axId') { // required\n      out.axId = numValElm(child)!;\n    }\n    else if (tag === 'scaling') { // un-required\n      addProp(out, 'scaling', readScaling(child));\n    }\n    else if (tag === 'axPos') { // required\n      addProp(out, 'axPos', strValElm<AxPos>(child));\n    }\n    else if (tag === 'crossAx') { // required\n      addProp(out, 'crossAx', numValElm(child));\n    }\n    else if (tag === 'delete') {\n      addProp(out, 'delete', boolValElm(child), false);\n    }\n    else if (tag === 'majorGridlines') {\n      const spPr = child.children.find(c => c.tagName === 'spPr');\n      out.majorGridlines = spPr ? readShapeProperties(spPr, context) ?? {} : {};\n    }\n    else if (tag === 'minorGridlines') {\n      const spPr = child.children.find(c => c.tagName === 'spPr');\n      out.minorGridlines = spPr ? readShapeProperties(spPr, context) ?? {} : {};\n    }\n    else if (tag === 'spPr') {\n      addProp(out, 'shape', readShapeProperties(child, context));\n    }\n    else if (tag === 'txPr') {\n      // XXX: need a reader for TextProps\n      addProp(out, 'textProps', readTextProps(child, context));\n    }\n    else if (tag === 'title') {\n      addProp(out, 'title', readTitle(child, context));\n    }\n    else if (tag === 'majorTickMark') {\n      addProp(out, 'majorTickMark', strValElm<TickMark>(child, 'cross'), 'cross');\n    }\n    else if (tag === 'minorTickMark') {\n      addProp(out, 'minorTickMark', strValElm<TickMark>(child, 'cross'), 'cross');\n    }\n    else if (tag === 'tickLblPos') {\n      addProp(out, 'tickLblPos', strValElm<TickLblPos>(child, 'nextTo'), 'nextTo');\n    }\n    else if (tag === 'crosses' || tag === 'crossesAt') {\n      // property has been merged\n      addProp(out, 'crosses',\n        tag === 'crosses'\n          ? strValElm<Crosses>(child)\n          : numValElm(child));\n    }\n    else if (tag === 'numFmt') {\n      addProp(out, 'numFmt', readNumFmt(child));\n    }\n  }\n\n  // ensure required props are there\n  if (out.axId && out.type && out.axPos && out.crossAx) {\n    return out as (ValAx | DateAx | SerAx | CatAx);\n  }\n}\n","/*\n<complexType name=\"CT_PlotArea\">\n  <sequence>\n    <element name=\"layout\" type=\"CT_Layout\" minOccurs=\"0\" maxOccurs=\"1\" />\n    <choice minOccurs=\"1\" maxOccurs=\"unbounded\">\n      <element name=\"areaChart\" type=\"CT_AreaChart\" minOccurs=\"1\" maxOccurs=\"1\" />\n      <element name=\"area3DChart\" type=\"CT_Area3DChart\" minOccurs=\"1\" maxOccurs=\"1\" />\n      <element name=\"lineChart\" type=\"CT_LineChart\" minOccurs=\"1\" maxOccurs=\"1\" />\n      <element name=\"line3DChart\" type=\"CT_Line3DChart\" minOccurs=\"1\" maxOccurs=\"1\" />\n      <element name=\"stockChart\" type=\"CT_StockChart\" minOccurs=\"1\" maxOccurs=\"1\" />\n      <element name=\"radarChart\" type=\"CT_RadarChart\" minOccurs=\"1\" maxOccurs=\"1\" />\n      <element name=\"scatterChart\" type=\"CT_ScatterChart\" minOccurs=\"1\" maxOccurs=\"1\" />\n      <element name=\"pieChart\" type=\"CT_PieChart\" minOccurs=\"1\" maxOccurs=\"1\" />\n      <element name=\"pie3DChart\" type=\"CT_Pie3DChart\" minOccurs=\"1\" maxOccurs=\"1\" />\n      <element name=\"doughnutChart\" type=\"CT_DoughnutChart\" minOccurs=\"1\" maxOccurs=\"1\" />\n      <element name=\"barChart\" type=\"CT_BarChart\" minOccurs=\"1\" maxOccurs=\"1\" />\n      <element name=\"bar3DChart\" type=\"CT_Bar3DChart\" minOccurs=\"1\" maxOccurs=\"1\" />\n      <element name=\"ofPieChart\" type=\"CT_OfPieChart\" minOccurs=\"1\" maxOccurs=\"1\" />\n      <element name=\"surfaceChart\" type=\"CT_SurfaceChart\" minOccurs=\"1\" maxOccurs=\"1\" />\n      <element name=\"surface3DChart\" type=\"CT_Surface3DChart\" minOccurs=\"1\" maxOccurs=\"1\" />\n      <element name=\"bubbleChart\" type=\"CT_BubbleChart\" minOccurs=\"1\" maxOccurs=\"1\" />\n    </choice>\n    <choice minOccurs=\"0\" maxOccurs=\"unbounded\">\n      <element name=\"valAx\" type=\"CT_ValAx\" minOccurs=\"1\" maxOccurs=\"1\" />\n      <element name=\"catAx\" type=\"CT_CatAx\" minOccurs=\"1\" maxOccurs=\"1\" />\n      <element name=\"dateAx\" type=\"CT_DateAx\" minOccurs=\"1\" maxOccurs=\"1\" />\n      <element name=\"serAx\" type=\"CT_SerAx\" minOccurs=\"1\" maxOccurs=\"1\" />\n    </choice>\n    <element name=\"dTable\" type=\"CT_DTable\" minOccurs=\"0\" maxOccurs=\"1\" />\n    <element name=\"spPr\" type=\"a:CT_ShapeProperties\" minOccurs=\"0\" maxOccurs=\"1\" />\n    <element name=\"extLst\" type=\"CT_ExtensionList\" minOccurs=\"0\" maxOccurs=\"1\" />\n  </sequence>\n</complexType>\n*/\n\nimport { Element } from '@borgar/simple-xml';\nimport type { ConversionContext } from '../../ConversionContext.ts';\nimport { boolValElm, numValElm, strValElm } from './utils/valElm.ts';\nimport { addProp } from '../../utils/addProp.ts';\nimport { readShapeProperties } from '../drawings/readShapeProperties.ts';\nimport { readSeries } from './readSeries.ts';\nimport { readAxis } from './readAxis.ts';\nimport { readLayout } from './readLayout.ts';\nimport { readDLbls } from './readDLbls.ts';\nimport { readNumFmt } from './readNumFmt.ts';\nimport { readTextProps } from './readTextProps.ts';\nimport { readTitle } from './readTitle.ts';\nimport { getFirstChild } from '../../utils/getFirstChild.ts';\nimport type { PlotArea } from './types/PlotArea.ts';\nimport type { Plot } from './types/plots/Plot.ts';\nimport type { WaterfallChart } from './types/plots/WaterfallChart.ts';\nimport type { Series } from './types/series/Series.ts';\nimport type { CatAx } from './types/axes/CatAx.ts';\nimport type { ValAx } from './types/axes/ValAx.ts';\nimport type { TickMark } from './types/axes/TickMark.ts';\nimport type { Shape } from '@jsfkit/types';\n\nexport type FmtOvrsMap = Map<number, Shape>;\nimport type { ChartDataMap } from './readChartData.ts';\nimport { attr, boolAttr, numAttr } from '../../utils/attr.ts';\n\n/**\n * XLSX plot area XML tag to JSF plot area type.\n */\nconst TAG_NAME_TO_CHART_TYPE: Record<string, Plot['type']> = {\n  areaChart: 'area',\n  area3DChart: 'area3d',\n  lineChart: 'line',\n  line3DChart: 'line3d',\n  stockChart: 'stock',\n  radarChart: 'radar',\n  scatterChart: 'scatter',\n  pieChart: 'pie',\n  pie3DChart: 'pie3d',\n  doughnutChart: 'doughnut',\n  barChart: 'bar',\n  bar3DChart: 'bar3d',\n  ofPieChart: 'ofPie',\n  surfaceChart: 'surface',\n  surface3DChart: 'surface3d',\n  bubbleChart: 'bubble',\n};\n\nfunction readPlot (element: Element, context: ConversionContext) {\n  // console.log(element.tagName);\n\n  const out: any = {\n    type: TAG_NAME_TO_CHART_TYPE[element.tagName] ?? element.tagName,\n  };\n\n  addProp(out, 'barDir', strValElm(element.querySelector('barDir')!)); // col | row\n  addProp(out, 'grouping', strValElm(element.querySelector('grouping')!)); // clustered\n\n  // Excel's \"vary colors by point\" default when c:varyColors is ABSENT: ON for pie-likes and\n  // bar charts -- the val attribute defaults to 1 and Excel applies that to the omitted element\n  // (Excel-authored files always write an explicit val=\"0\"; non-Excel producers omit it: both a\n  // Google-Sheets export and an openpyxl single-series bar render vary-by-point in Excel, with\n  // category legends). Other chart types stay OFF until evidenced. Note that Excel's per-point\n  // LEGEND does not key on this flag alone -- a single series with per-point dPt formats gets a\n  // category legend even with an explicit varyColors=0 -- so renderers should not treat false\n  // as \"series legend\". Emit the resolved value so consumers never have to guess.\n  const varyColorsElm = element.querySelector('varyColors');\n  const varyDefault = out.type === 'pie' || out.type === 'pie3d' || out.type === 'doughnut' ||\n    out.type === 'ofPie' || out.type === 'bar' || out.type === 'bar3d';\n  out.varyColors = varyColorsElm ? boolValElm(varyColorsElm, true) : varyDefault;\n  addProp(out, 'gapWidth', numValElm(element.querySelector('gapWidth')!));\n  addProp(out, 'overlap', numValElm(element.querySelector('overlap')!));\n  // Use getFirstChild instead of querySelector to avoid matching series-level <marker> elements.\n  const markerElm = getFirstChild(element, 'marker');\n  if (markerElm) {\n    addProp(out, 'marker', boolValElm(markerElm), false);\n  }\n  addProp(out, 'scatterStyle', strValElm(element.querySelector('scatterStyle')!));\n  addProp(out, 'radarStyle', strValElm(element.querySelector('radarStyle')!));\n\n  // Bubble-chart-specific properties.\n  const bubbleScaleElm = getFirstChild(element, 'bubbleScale');\n  if (bubbleScaleElm) {\n    addProp(out, 'bubbleScale', numValElm(bubbleScaleElm));\n  }\n  const showNegBubblesElm = getFirstChild(element, 'showNegBubbles');\n  if (showNegBubblesElm) {\n    addProp(out, 'showNegBubbles', boolValElm(showNegBubblesElm), false);\n  }\n  const sizeRepresentsElm = getFirstChild(element, 'sizeRepresents');\n  if (sizeRepresentsElm) {\n    addProp(out, 'sizeRepresents', strValElm(sizeRepresentsElm));\n  }\n  const bubble3DElm = getFirstChild(element, 'bubble3D');\n  if (bubble3DElm) {\n    addProp(out, 'bubble3D', boolValElm(bubble3DElm), false);\n  }\n\n  // pie\n  const firstSliceAng = getFirstChild(element, 'firstSliceAng');\n  if (firstSliceAng) {\n    addProp(out, 'firstSliceAng', numValElm(firstSliceAng));\n  }\n  const holeSize = getFirstChild(element, 'holeSize');\n  if (holeSize) {\n    addProp(out, 'holeSize', numValElm(holeSize), 75);\n  }\n\n  out.axId = element.querySelectorAll('axId').map(d => numValElm(d));\n  out.ser = [];\n  const ser = element.querySelectorAll('ser');\n  ser.forEach((s, i) => {\n    out.ser[i] = readSeries(s, context);\n    // console.dir(, { depth: 80 });\n    // const subTags = new Set(s.children.map(d => d.tagName));\n    // console.log('ser', subTags);\n  });\n\n  // Chart-level data labels: the <c:dLbls> child of <c:*Chart>. Use getFirstChild to avoid matching\n  // any series-level <c:dLbls> reachable via the descendant-combinator behaviour of querySelector.\n  const dLblsElm = getFirstChild(element, 'dLbls');\n  if (dLblsElm) {\n    out.dLbls = readDLbls(dLblsElm, context);\n  }\n\n  // ser\n  //   idx (val)\n  //   order (val)\n  //   tx ...\n  //   spPr ...\n  //   invertIfNegative (val)\n  //   cat\n  //     numRef\n  //       f (innerText)\n  //       numCache\n  //         formatCode (innerText)\n  //         ptCount (val)\n  //         pt* [idx=1]\n  //           v\n  //\n\n  // console.log(ser[0].toString());\n\n  // ser*\n  // dLbls\n  // axId\n\n  // console.log(element.toString());\n\n  // axId\n\n  // Object.assign(out, readBarChartShared(element, context));\n\n  // for (const child of element.children) {\n  //   if (child.tagName === 'gapWidth') {\n  //     addProp(out, 'gapWidth', readGapAmount(child, context));\n  //   }\n  //   else if (child.tagName === 'overlap') {\n  //     addProp(out, 'overlap', readOverlap(child, context));\n  //   }\n  //   else if (child.tagName === 'serLines') {\n  //     const serLines_ = element.querySelectorAll('>serLines');\n  //     if (serLines_.length) {\n  //       out.serLines = serLines_.map(child => readChartLines(child, context));\n  //     }\n  //   }\n  //   else if (child.tagName === 'axId') {\n  //     const axId_ = element.querySelectorAll('>axId');\n  //     if (axId_.length === 2) {\n  //       out.axId = axId_.map(child => readUnsignedInt(child, context));\n  //     }\n  //     else {\n  //       throw new Error('Missing required element: axId');\n  //     }\n  //   }\n  // }\n\n  return out;\n}\n\nconst PLOT_HANDLER = {\n  areaChart: 1,\n  area3DChart: 1,\n  lineChart: 1,\n  line3DChart: 1,\n  stockChart: 1,\n  radarChart: 1,\n  scatterChart: 1,\n  pieChart: 1,\n  pie3DChart: 1,\n  doughnutChart: 1,\n  barChart: 1,\n  bar3DChart: 1,\n  ofPieChart: 1,\n  surfaceChart: 1,\n  surface3DChart: 1,\n  bubbleChart: 1,\n};\n\nconst AXIS_NAMES = {\n  valAx: 1,\n  catAx: 1,\n  dateAx: 1,\n  serAx: 1,\n};\n\nfunction readChartExAxis (element: Element, context: ConversionContext, crossAxId: number): CatAx | ValAx | undefined {\n  const axId = numAttr(element, 'id', null);\n  if (axId == null) return undefined;\n\n  const isHidden = boolAttr(element, 'hidden', false) ?? false;\n  const isVal = !!element.querySelector('valScaling');\n\n  const shared = {\n    axId,\n    axPos: isVal ? 'l' : 'b',\n    crossAx: crossAxId,\n    crosses: 'autoZero',\n    ...(isHidden ? { delete: true } : {}),\n  } as const;\n\n  const out: Partial<CatAx | ValAx> = isVal\n    ? { type: 'valAx', ...shared }\n    : { type: 'catAx', ...shared };\n\n  for (const child of element.children) {\n    if (child.tagName === 'valScaling') {\n      const parseVal = (v: string | null): 'auto' | number => (v == null || v === 'auto' ? 'auto' : +v);\n      addProp(out as Partial<ValAx>, 'majorUnit', parseVal(attr(child, 'majorUnit')) === 'auto' ? undefined : +attr(child, 'majorUnit')!);\n      addProp(out as Partial<ValAx>, 'minorUnit', parseVal(attr(child, 'minorUnit')) === 'auto' ? undefined : +attr(child, 'minorUnit')!);\n    }\n    else if (child.tagName === 'majorGridlines') {\n      const spPr = child.querySelector('spPr');\n      if (spPr) { addProp(out, 'majorGridlines', readShapeProperties(spPr, context)); }\n    }\n    else if (child.tagName === 'minorGridlines') {\n      const spPr = child.querySelector('spPr');\n      if (spPr) { addProp(out, 'minorGridlines', readShapeProperties(spPr, context)); }\n    }\n    else if (child.tagName === 'majorTickMarks') {\n      addProp(out, 'majorTickMark', attr(child, 'type') as TickMark | null);\n    }\n    else if (child.tagName === 'minorTickMarks') {\n      addProp(out, 'minorTickMark', attr(child, 'type') as TickMark | null);\n    }\n    else if (child.tagName === 'numFmt') {\n      addProp(out, 'numFmt', readNumFmt(child));\n    }\n    else if (child.tagName === 'spPr') {\n      addProp(out, 'shape', readShapeProperties(child, context));\n    }\n    else if (child.tagName === 'txPr') {\n      addProp(out, 'textProps', readTextProps(child, context));\n    }\n    else if (child.tagName === 'title') {\n      addProp(out, 'title', readTitle(child, context));\n    }\n  }\n\n  return out as CatAx | ValAx;\n}\n\n/**\n * Parse a ChartEx <cx:plotAreaRegion> into a WaterfallChart plot.\n * Groups all series under a single WaterfallChart and collects subtotal\n * indices and axis IDs from the first series (they are chart-level in practice).\n */\nfunction readPlotAreaRegion (\n  element: Element,\n  context: ConversionContext,\n  chartDataMap: ChartDataMap,\n  fmtOvrsMap?: FmtOvrsMap,\n): WaterfallChart | undefined {\n  const seriesElements = element.querySelectorAll('series');\n  if (seriesElements.length === 0) return undefined;\n\n  // Only support waterfall for now; skip other ChartEx layouts.\n  const layoutId = attr(seriesElements[0]!, 'layoutId');\n  if (layoutId !== 'waterfall') return undefined;\n\n  const serArr: Series[] = [];\n  const allSubtotals: number[] = [];\n  const axIdSet: number[] = [];\n  let connectorLines: boolean | undefined;\n\n  for (let i = 0; i < seriesElements.length; i++) {\n    const serElm = seriesElements[i]!;\n\n    // Series name from <cx:tx><cx:txData><cx:v>\n    let seriesText: string | undefined;\n    const txData = serElm.querySelector('tx > txData');\n    if (txData) {\n      seriesText = txData.querySelector('v')?.textContent ?? undefined;\n    }\n\n    // Axis IDs (collect from first series only)\n    if (i === 0) {\n      for (const axElm of serElm.querySelectorAll('axisId')) {\n        const id = numAttr(axElm, 'val', null);\n        if (id != null) axIdSet.push(id);\n      }\n    }\n\n    // Subtotals from <cx:layoutPr><cx:subtotals><cx:idx val=\"N\"/>\n    const layoutPrElm = serElm.querySelector('layoutPr');\n    if (layoutPrElm) {\n      const subtotalsElm = layoutPrElm.querySelector('subtotals');\n      if (subtotalsElm) {\n        for (const idxElm of subtotalsElm.querySelectorAll('idx')) {\n          const v = numAttr(idxElm, 'val', null);\n          if (v != null) allSubtotals.push(v);\n        }\n      }\n      const visibilityElm = layoutPrElm.querySelector('visibility');\n      if (visibilityElm && connectorLines === undefined) {\n        const v = boolAttr(visibilityElm, 'connectorLines');\n        if (v != null) connectorLines = v;\n      }\n    }\n\n    // Resolve data from chartDataMap via dataId\n    const dataIdElm = serElm.querySelector('dataId');\n    const dataId = dataIdElm ? numAttr(dataIdElm, 'val', -1) : -1;\n    const data = dataId >= 0 ? chartDataMap.get(dataId) : undefined;\n\n    const spPrElm = serElm.children.find(c => c.tagName === 'spPr');\n    const shape = spPrElm ? readShapeProperties(spPrElm, context) : undefined;\n    // if (shape == null && fmtOvrsMap != null) {\n    //   const formatIdx = numAttr(serElm, 'formatIdx', null);\n    //   if (formatIdx != null) { shape = fmtOvrsMap.get(formatIdx); }\n    // }\n\n    const ser: Series = {\n      idx: i,\n      order: i,\n      ...(seriesText != null ? { text: seriesText } : {}),\n      ...(shape != null ? { shape } : {}),\n      ...(data?.cat != null ? { cat: data.cat } : {}),\n      ...(data?.val != null ? { val: data.val } : {}),\n    };\n    serArr.push(ser);\n  }\n\n  const axId: [number, number] = [\n    axIdSet[0] ?? 0,\n    axIdSet[1] ?? 1,\n  ];\n\n  const fmtOvrs: { idx: number, shape: Shape }[] = [];\n  if (fmtOvrsMap) {\n    for (const [ idx, shape ] of fmtOvrsMap.entries()) {\n      fmtOvrs.push({ idx, shape });\n    }\n  }\n\n  const plot: WaterfallChart = {\n    type: 'waterfall',\n    ser: serArr,\n    axId,\n    fmtOvrs: fmtOvrs,\n    ...(allSubtotals.length > 0 ? { subtotals: allSubtotals } : {}),\n    ...(connectorLines != null ? { connectorLines } : {}),\n  };\n\n  return plot;\n}\n\n/**\n *\n */\nexport function readPlotArea (\n  element: Element,\n  context: ConversionContext,\n  isChartx = false,\n  chartDataMap?: ChartDataMap,\n  fmtOvrsMap?: FmtOvrsMap,\n): PlotArea | undefined {\n  const out: PlotArea = {\n    plots: [],\n    axes: [],\n  };\n\n  const chartExAxisElements: Element[] = [];\n\n  for (const child of element.children) {\n    if (!isChartx && child.tagName === 'layout') {\n      // Manual plot-area placement (c:manualLayout, incl. layoutTarget inner/outer). Excel\n      // honors this rect directly; renderers should prefer it over automatic layout.\n      addProp(out, 'layout', readLayout(child));\n    }\n    else if (child.tagName === 'spPr') {\n      addProp(out, 'shape', readShapeProperties(child, context));\n    }\n    else if (!isChartx && child.tagName === 'dTable') {\n      // addProp(out, 'dTable', readDTable(child, context));\n    }\n    // Plots\n    else if (!isChartx && child.tagName in PLOT_HANDLER) {\n      const plot = readPlot(child, context);\n      if (plot) { out.plots.push(plot); }\n    }\n    else if (isChartx && child.tagName === 'plotAreaRegion') {\n      const plot = readPlotAreaRegion(child, context, chartDataMap ?? new Map(), fmtOvrsMap);\n      if (plot) { out.plots.push(plot); }\n    }\n    // Axes\n    else if (!isChartx && child.tagName in AXIS_NAMES) {\n      const axis = readAxis(child, context);\n      if (axis) { out.axes.push(axis); }\n    }\n    else if (isChartx && child.tagName === 'axis') {\n      chartExAxisElements.push(child);\n    }\n    else {\n      // console.log(child.tagName);\n    }\n  }\n\n  // Process ChartEx axes with mutual cross-references\n  if (chartExAxisElements.length > 0) {\n    const ids = chartExAxisElements.map(e => numAttr(e, 'id', 0));\n    for (let i = 0; i < chartExAxisElements.length; i++) {\n      // Cross to the first other axis, or self if only one axis.\n      const crossId = ids.find((_, j) => j !== i) ?? ids[i]!;\n      const axis = readChartExAxis(chartExAxisElements[i]!, context, crossId);\n      if (axis) { out.axes.push(axis); }\n    }\n  }\n\n  return out;\n}\n","/*\n<complexType name=\"CT_Chart\">\n  <sequence>\n    <element name=\"title\" type=\"CT_Title\" minOccurs=\"0\" maxOccurs=\"1\" />\n    <element name=\"autoTitleDeleted\" type=\"CT_Boolean\" minOccurs=\"0\" maxOccurs=\"1\" />\n    <element name=\"pivotFmts\" type=\"CT_PivotFmts\" minOccurs=\"0\" maxOccurs=\"1\" />\n    <element name=\"view3D\" type=\"CT_View3D\" minOccurs=\"0\" maxOccurs=\"1\" />\n    <element name=\"floor\" type=\"CT_Surface\" minOccurs=\"0\" maxOccurs=\"1\" />\n    <element name=\"sideWall\" type=\"CT_Surface\" minOccurs=\"0\" maxOccurs=\"1\" />\n    <element name=\"backWall\" type=\"CT_Surface\" minOccurs=\"0\" maxOccurs=\"1\" />\n    <element name=\"plotArea\" type=\"CT_PlotArea\" minOccurs=\"1\" maxOccurs=\"1\" />\n    <element name=\"legend\" type=\"CT_Legend\" minOccurs=\"0\" maxOccurs=\"1\" />\n    <element name=\"plotVisOnly\" type=\"CT_Boolean\" minOccurs=\"0\" maxOccurs=\"1\" />\n    <element name=\"dispBlanksAs\" type=\"CT_DispBlanksAs\" minOccurs=\"0\" maxOccurs=\"1\" />\n    <element name=\"showDLblsOverMax\" type=\"CT_Boolean\" minOccurs=\"0\" maxOccurs=\"1\" />\n    <element name=\"extLst\" type=\"CT_ExtensionList\" minOccurs=\"0\" maxOccurs=\"1\" />\n  </sequence>\n</complexType>\n*/\n\nimport { Element } from '@borgar/simple-xml';\nimport { addProp } from '../../utils/addProp.ts';\nimport type { ConversionContext } from '../../ConversionContext.ts';\nimport { readLegend } from './readLegend.ts';\nimport { boolValElm, strValElm } from './utils/valElm.ts';\nimport { readTitle } from './readTitle.ts';\nimport { readPivotFmts } from './readPivotFmts.ts';\nimport { readPlotArea, type FmtOvrsMap } from './readPlotArea.ts';\nimport type { Chart } from './types/Chart.ts';\nimport type { ChartEx } from './types/ChartEx.ts';\nimport type { ChartDataMap } from './readChartData.ts';\n\nexport function readChart (\n  element: Element, context: ConversionContext, isChartx: true, chartDataMap?: ChartDataMap, fmtOvrsMap?: FmtOvrsMap,\n): ChartEx | undefined;\nexport function readChart (\n  element: Element, context: ConversionContext, isChartx?: false, chartDataMap?: ChartDataMap, fmtOvrsMap?: FmtOvrsMap,\n): Chart | undefined;\nexport function readChart (\n  element: Element, context: ConversionContext, isChartx: boolean, chartDataMap?: ChartDataMap, fmtOvrsMap?: FmtOvrsMap,\n): Chart | ChartEx | undefined;\nexport function readChart (\n  element: Element,\n  context: ConversionContext,\n  isChartx = false,\n  chartDataMap?: ChartDataMap,\n  fmtOvrsMap?: FmtOvrsMap,\n): Chart | ChartEx | undefined {\n  const out: Partial<Omit<Chart, 'type'>> & Partial<Omit<ChartEx, 'type'>> & {\n    type: 'bc' | 'ex',\n  } = {\n    type: 'bc',\n  };\n\n  for (const child of element.children) {\n    if (child.tagName === 'title') {\n      addProp(out, 'title', readTitle(child, context));\n    }\n    else if (child.tagName === 'autoTitleDeleted') {\n      addProp(out, 'autoTitleDeleted', boolValElm(child), false);\n    }\n    else if (child.tagName === 'pivotFmts') {\n      addProp(out, 'pivotFmts', readPivotFmts(child, context));\n    }\n    else if (child.tagName === 'view3D') {\n      // addProp(out, 'view3D', readView3D(child, context));\n    }\n    else if (child.tagName === 'floor') {\n      // addProp(out, 'floor', readSurface(child, context));\n    }\n    else if (child.tagName === 'sideWall') {\n      // addProp(out, 'sideWall', readSurface(child, context));\n    }\n    else if (child.tagName === 'backWall') {\n      // addProp(out, 'backWall', readSurface(child, context));\n    }\n    else if (child.tagName === 'plotArea') {\n      // @ts-expect-error -- need to untangle Chart & ChartEx\n      addProp(out, 'plotArea', readPlotArea(child, context, isChartx, chartDataMap, fmtOvrsMap));\n    }\n    else if (child.tagName === 'legend') {\n      addProp(out, 'legend', readLegend(child, context));\n    }\n    else if (child.tagName === 'plotVisOnly') {\n      addProp(out, 'plotVisOnly', boolValElm(child), false);\n    }\n    else if (child.tagName === 'dispBlanksAs') {\n      // Keeping an explicit \"gap\": presence matters. The ECMA-376 default for an ABSENT\n      // dispBlanksAs element is \"zero\" (legacy charts omit it and Excel plots blanks at 0),\n      // while modern Excel writes \"gap\" explicitly and suppressing it would erase the distinction.\n      addProp(out, 'dispBlanksAs', strValElm(child, 'gap'));\n    }\n    else if (child.tagName === 'showDLblsOverMax') {\n      addProp(out, 'showDLblsOverMax', boolValElm(child), false);\n    }\n  }\n\n  return out as Chart | ChartEx | undefined;\n}\n","import { Element } from '@borgar/simple-xml';\nimport type { ConversionContext } from '../../ConversionContext.ts';\nimport type { StrRef } from './types/data/StrRef.ts';\nimport type { StrData } from './types/data/StrData.ts';\nimport type { NumRef } from './types/data/NumRef.ts';\nimport type { NumData } from './types/data/NumData.ts';\nimport { attr, numAttr } from '../../utils/attr.ts';\n\nexport type ResolvedChartData = {\n  cat?: StrRef | StrData;\n  val?: NumRef | NumData;\n};\n\nexport type ChartDataMap = Map<number, ResolvedChartData>;\n\n/**\n * Resolve a named range reference like \"_xlchart.v1.15\" to the actual cell\n * range formula it maps to (e.g. \"Sheet1!$A$2:$A$6\").\n */\nfunction resolveNamedRange (formula: string, context: ConversionContext): string {\n  return context.nameDefs.get(formula)?.value ?? formula;\n}\n\nfunction readStrDim (element: Element, context: ConversionContext): StrRef | StrData {\n  const lvl = element.querySelector('lvl');\n  if (lvl) {\n    const ptCount = numAttr(lvl, 'ptCount', 0);\n    const pt = lvl.querySelectorAll('pt').map((ptElm, i) => ({\n      idx: numAttr(ptElm, 'idx', i),\n      v: ptElm.textContent ?? '',\n    }));\n    return { type: 'strData', ptCount, pt };\n  }\n\n  const formula = element.querySelector('f')?.textContent?.trim() ?? '';\n  return { type: 'strRef', f: resolveNamedRange(formula, context) };\n}\n\nfunction readNumDim (element: Element, context: ConversionContext): NumRef | NumData {\n  const formatCode = element.querySelector('nf')?.textContent?.trim();\n\n  const lvl = element.querySelector('lvl');\n  if (lvl) {\n    const ptCount = numAttr(lvl, 'ptCount', 0);\n    const pt = lvl.querySelectorAll('pt').map((ptElm, i) => ({\n      idx: numAttr(ptElm, 'idx', i),\n      v: ptElm.textContent ?? '',\n    }));\n    return { type: 'numData', ...(formatCode != null ? { formatCode } : {}), ptCount, pt };\n  }\n\n  const formula = element.querySelector('f')?.textContent?.trim() ?? '';\n  return { type: 'numRef', f: resolveNamedRange(formula, context) };\n}\n\n/**\n * Parse a ChartEx <cx:chartData> element into a map keyed by data id.\n * Each entry holds the category (strDim type=\"cat\") and value (numDim type=\"val\")\n * data sources for a series to look up by its dataId.\n */\nexport function readChartData (element: Element, context: ConversionContext): ChartDataMap {\n  const map: ChartDataMap = new Map();\n\n  for (const child of element.children) {\n    if (child.tagName !== 'data') continue;\n    const id = numAttr(child, 'id', -1);\n    if (id < 0) continue;\n\n    const entry: ResolvedChartData = {};\n    for (const dim of child.children) {\n      const dimType = attr(dim, 'type');\n      if (dim.tagName === 'strDim' && dimType === 'cat') {\n        entry.cat = readStrDim(dim, context);\n      }\n      else if (dim.tagName === 'numDim' && dimType === 'val') {\n        entry.val = readNumDim(dim, context);\n      }\n    }\n    map.set(id, entry);\n  }\n\n  return map;\n}\n","import type { Document } from '@borgar/simple-xml';\nimport type { ConversionContext } from '../ConversionContext.ts';\nimport { boolAttr, numAttr } from '../utils/attr.ts';\nimport { addProp } from '../utils/addProp.ts';\nimport { readShapeProperties } from './drawings/readShapeProperties.ts';\nimport { readTextBody } from './drawings/readTextBody.ts';\nimport { readChart } from './charts/readChart.ts';\nimport type { ChartSpaceEx } from './charts/types/ChartSpaceEx.ts';\nimport type { ChartSpace } from './charts/types/ChartSpace.ts';\nimport { readChartData, type ChartDataMap } from './charts/readChartData.ts';\nimport { type FmtOvrsMap } from './charts/readPlotArea.ts';\n\n/*\n<complexType name=\"CT_ChartSpace\">\n  <sequence>\n    <element name=\"date1904\" type=\"CT_Boolean\" minOccurs=\"0\" maxOccurs=\"1\" />\n    <element name=\"lang\" type=\"CT_TextLanguageID\" minOccurs=\"0\" maxOccurs=\"1\" />\n    <element name=\"roundedCorners\" type=\"CT_Boolean\" minOccurs=\"0\" maxOccurs=\"1\" />\n    <element name=\"style\" type=\"CT_Style\" minOccurs=\"0\" maxOccurs=\"1\" />\n    <element name=\"clrMapOvr\" type=\"a:CT_ColorMapping\" minOccurs=\"0\" maxOccurs=\"1\" />\n    <element name=\"pivotSource\" type=\"CT_PivotSource\" minOccurs=\"0\" maxOccurs=\"1\" />\n    <element name=\"protection\" type=\"CT_Protection\" minOccurs=\"0\" maxOccurs=\"1\" />\n    <element name=\"chart\" type=\"CT_Chart\" minOccurs=\"1\" maxOccurs=\"1\" />\n    <element name=\"spPr\" type=\"a:CT_ShapeProperties\" minOccurs=\"0\" maxOccurs=\"1\" />\n    <element name=\"txPr\" type=\"a:CT_TextBody\" minOccurs=\"0\" maxOccurs=\"1\" />\n    <element name=\"externalData\" type=\"CT_ExternalData\" minOccurs=\"0\" maxOccurs=\"1\" />\n    <element name=\"printSettings\" type=\"CT_PrintSettings\" minOccurs=\"0\" maxOccurs=\"1\" />\n    <element name=\"userShapes\" type=\"CT_RelId\" minOccurs=\"0\" maxOccurs=\"1\" />\n    <element name=\"extLst\" type=\"CT_ExtensionList\" minOccurs=\"0\" maxOccurs=\"1\" />\n  </sequence>\n\n  // ChartSpaceEx\n  <xsd:sequence>\n    <xsd:element name=\"chartData\" type=\"CT_ChartData\" minOccurs=\"1\" maxOccurs=\"1\"/>\n    <xsd:element name=\"chart\" type=\"CT_Chart\" minOccurs=\"1\" maxOccurs=\"1\"/>\n    <xsd:element name=\"spPr\" type=\"a:CT_ShapeProperties\" minOccurs=\"0\" maxOccurs=\"1\"/>\n    <xsd:element name=\"txPr\" type=\"a:CT_TextBody\" minOccurs=\"0\" maxOccurs=\"1\"/>\n    <xsd:element name=\"clrMapOvr\" type=\"a:CT_ColorMapping\" minOccurs=\"0\" maxOccurs=\"1\"/>\n    <xsd:element name=\"fmtOvrs\" type=\"CT_FormatOverrides\" minOccurs=\"0\" maxOccurs=\"1\"/>\n    <xsd:element name=\"printSettings\" type=\"CT_PrintSettings\" minOccurs=\"0\" maxOccurs=\"1\"/>\n    <xsd:element name=\"extLst\" type=\"CT_ExtensionList\" minOccurs=\"0\" maxOccurs=\"1\"/>\n  </xsd:sequence>\n  <xsd:attribute name=\"version\" type=\"xsd:string\" use=\"optional\" default=\"0.0\"/>\n  <xsd:attribute name=\"featureList\" type=\"xsd:string\" use=\"optional\" default=\"\"/>\n  <xsd:attribute name=\"fallbackImg\" type=\"xsd:string\" use=\"optional\" default=\"\"/>\n\n</complexType>\n*/\n\nexport function handlerChart (dom: Document, context: ConversionContext, isChartx: true): ChartSpace | ChartSpaceEx;\nexport function handlerChart (dom: Document, context: ConversionContext, isChartx?: false): ChartSpace;\nexport function handlerChart (dom: Document, context: ConversionContext, isChartx = false): ChartSpace | ChartSpaceEx {\n  const chartSpace: Partial<ChartSpace> | Partial<ChartSpaceEx> = {};\n  // dom.root is assumed to be a <chartSpace> element (5.7.2.29)\n\n  // ChartEx\n  // <xsd:attribute name=\"version\" type=\"xsd:string\" use=\"optional\" default=\"0.0\"/>\n  // <xsd:attribute name=\"featureList\" type=\"xsd:string\" use=\"optional\" default=\"\"/>\n  // <xsd:attribute name=\"fallbackImg\" type=\"xsd:string\" use=\"optional\" default=\"\"/>\n\n  // For ChartEx, chartData and fmtOvrs must be parsed before chart so series can resolve data\n  // references and format overrides by id. Pre-scan for both here, then process children below.\n  let chartDataMap: ChartDataMap = new Map();\n  const fmtOvrsMap: FmtOvrsMap = new Map();\n  if (isChartx) {\n    const chartDataElm = dom.root!.children.find(c => c.tagName === 'chartData');\n    if (chartDataElm) {\n      chartDataMap = readChartData(chartDataElm, context);\n    }\n    const fmtOvrsElm = dom.root!.children.find(c => c.tagName === 'fmtOvrs');\n    if (fmtOvrsElm) {\n      for (const fmtOvr of fmtOvrsElm.children) {\n        if (fmtOvr.tagName !== 'fmtOvr') continue;\n        const idx = numAttr(fmtOvr, 'idx', null);\n        if (idx == null) continue;\n        const spPr = fmtOvr.children.find(c => c.tagName === 'spPr');\n        if (spPr) {\n          const shape = readShapeProperties(spPr, context);\n          if (shape) fmtOvrsMap.set(idx, shape);\n        }\n      }\n    }\n  }\n\n  dom.root!.children.forEach(elm => {\n    const { tagName } = elm;\n    // ChartEx\n    if (isChartx && tagName === 'chartData') {\n      // Already parsed above; skip.\n    }\n    else if (isChartx && tagName === 'fmtOvrs') {\n      // Already pre-parsed above; skip.\n    }\n\n    // Chart\n    else if (!isChartx && tagName === 'date1904') {\n      // addProp(chart, 'epoch', boolAttr(elm, 'val') ? 1904 : null);\n    }\n    else if (!isChartx && tagName === 'lang') {\n      // addProp(chart, 'lang', attr(elm, 'val'), 'en-US');\n    }\n    else if (!isChartx && tagName === 'roundedCorners') {\n      // @ts-expect-error XXX: deal with the types\n      addProp(chartSpace, 'roundedCorners', boolAttr(elm, 'val'), false);\n    }\n    else if (!isChartx && tagName === 'style') {\n      // TODO\n    }\n    else if (isChartx && tagName === 'pivotSource') {\n      // TODO\n    }\n    else if (isChartx && tagName === 'protection') {\n      // TODO\n    }\n    else if (isChartx && tagName === 'userShapes') {\n      // TODO\n    }\n    else if (isChartx && tagName === 'externalData') {\n      // TODO\n    }\n\n    // Both\n    else if (tagName === 'chart') {\n      chartSpace.chart = readChart(elm, context, isChartx, chartDataMap, fmtOvrsMap);\n    }\n    else if (tagName === 'spPr') {\n      // XXX: ignore default? (white fill, black line, ...)\n      addProp(chartSpace, 'shape', readShapeProperties(elm, context));\n    }\n    else if (tagName === 'txPr') {\n      addProp(chartSpace, 'textProps', readTextBody(elm));\n    }\n    else if (tagName === 'clrMapOvr') { // Color map overrides\n      // TODO\n    }\n    else if (tagName === 'printSettings') {\n      // TODO\n    }\n  });\n\n  return chartSpace as ChartSpace | ChartSpaceEx;\n}\n","import { Document, parseXML } from '@borgar/simple-xml';\nimport { ZipArchive } from '@borgar/zip';\nimport { attr } from './utils/attr.ts';\nimport { pathBasename, pathDirname, pathJoin } from './utils/path.ts';\nimport { convertStyles } from './utils/convertStyles.ts';\nimport { resolveColumnMdw } from './utils/mdw.ts';\nimport { FT_CFBF, FT_ZIP, getBinaryFileType } from './utils/getBinaryFileType.ts';\nimport { ConversionContext } from './ConversionContext.ts';\nimport { handlerRels, type Rel } from './handler/rels.ts';\nimport { handlerWorkbook } from './handler/workbook.ts';\nimport { handlerSharedStrings } from './handler/sharedstrings.ts';\nimport { handlerPersons } from './handler/persons.ts';\nimport { handlerTheme } from './handler/theme.ts';\nimport { handlerAppdata } from './handler/appdata.ts';\nimport { handlerStyles } from './handler/styles.ts';\nimport { handlerRDStruct } from './handler/rdstuct.ts';\nimport { handlerRDValue } from './handler/rdvalue.ts';\nimport { handlerMetaData } from './handler/metadata.ts';\nimport { handlerComments } from './handler/comments.ts';\nimport { handlerNotes } from './handler/notes.ts';\nimport { handlerWorksheet } from './handler/worksheet.ts';\nimport { handlerExternal } from './handler/external.ts';\nimport { handlerTable } from './handler/table.ts';\nimport { handlerPivotCacheDefinition } from './handler/pivotTables/pivotCacheDefinition.ts';\nimport { handlerPivotCacheRecords } from './handler/pivotTables/pivotCacheRecords.ts';\nimport { handlerPivotTable } from './handler/pivotTable.ts';\nimport type { Workbook, PivotTable, PivotCache } from '@jsfkit/types';\nimport type { ConversionOptions } from './index.ts';\nimport { EncryptionError, InvalidFileError, MissingSheetError } from './errors.ts';\nimport { handlerDrawing } from './handler/drawing.ts';\nimport { arrayBufferToDataUri } from './utils/arrayBufferToDataUri.ts';\nimport { getMimeType } from './utils/getMimeType.ts';\nimport { isLikelyGSExport } from './utils/isLikelyGSExport.ts';\nimport { handlerChart } from './handler/chart.ts';\nimport { hasKeys } from './utils/hasKeys.ts';\nimport type { ChartSpace } from './handler/charts/types/ChartSpace.ts';\n\nfunction toArrayBuffer (buffer: Buffer): ArrayBuffer {\n  const arrayBuffer = new ArrayBuffer(buffer.length);\n  new Uint8Array(arrayBuffer).set(buffer);\n  return arrayBuffer;\n}\n\nlet CHARTS_ENABLED = false;\n/** @ignore */\nexport type ExtendedWorkbook = Workbook & { charts?: Record<string, ChartSpace> };\n\n/**\n * Default conversion options\n */\nconst DEFAULT_OPTIONS: ConversionOptions = {\n  skipMerged: true,\n  cellFormulas: false,\n  skipStyledEmptyCells: false,\n};\n\n/**\n * Convert an XLSX binary into a JSON format.\n *\n * The returned JSF structure contains most of the data from the original file, although some details\n * may be lost in the conversion process.\n *\n * @param buffer Buffer containing the file to convert\n * @param filename Name of the file being converted\n * @param [options] Conversion options\n * @return A JSON spreadsheet formatted object.\n */\nexport async function convertBinary (\n  buffer: Buffer | ArrayBuffer,\n  filename: string,\n  options?: ConversionOptions,\n): Promise<Workbook> {\n  if (typeof Buffer !== 'undefined' && buffer instanceof Buffer) {\n    buffer = toArrayBuffer(buffer);\n  }\n  if (!(buffer instanceof ArrayBuffer)) {\n    throw new InvalidFileError('Input is not a valid binary');\n  }\n  options = Object.assign({}, DEFAULT_OPTIONS, options);\n\n  const fileType = getBinaryFileType(buffer);\n  if (fileType === FT_CFBF) {\n    throw new EncryptionError('Input file is encrypted');\n  }\n  else if (fileType !== FT_ZIP) {\n    throw new InvalidFileError('Input file type is unsupported');\n  }\n\n  let zip: ZipArchive;\n  try {\n    zip = new ZipArchive(buffer);\n  }\n  catch (err) {\n    throw new InvalidFileError('Input file type is corrupted or unsupported');\n  }\n\n  const getFile = async (f: string) => {\n    try {\n      let fd = await zip.readText(f);\n      if (!fd && f.startsWith('xl/xl/')) {\n        fd = await zip.readText(f.slice(3));\n      }\n      return fd ? parseXML(fd) : null;\n    }\n    catch (err) {\n      throw new InvalidFileError('Input file type is corrupted');\n    }\n  };\n\n  const getBinaryFile = async (f: string) => {\n    try {\n      let fd = await zip.read(f);\n      if (!fd && f.startsWith('xl/xl/')) {\n        fd = await zip.read(f.slice(3));\n      }\n      return fd ?? null;\n    }\n    catch (err) {\n      throw new InvalidFileError('Input file type is corrupted');\n    }\n  };\n\n  const getRels = async (f = '') => {\n    const fDir = pathDirname(f);\n    const fBfn = pathBasename(f);\n    const relsPath = pathJoin(fDir, '_rels', `${fBfn}.rels`);\n    return handlerRels(await getFile(relsPath), f);\n  };\n\n  async function maybeRead<T extends (dom: Document, context: ConversionContext) => any> (\n    context: ConversionContext,\n    type: string,\n    handler: T,\n    fallback: any = null,\n    rels: Rel[] | null = null,\n  ): Promise<ReturnType<T>> {\n    const rel = (rels || context.rels).find(d => d.type === type);\n    if (rel) {\n      const dom = await getFile(rel.target);\n      if (dom) {\n        return handler(dom, context);\n      }\n      else {\n        throw new ReferenceError('Invalid file reference: ' + rel.target);\n      }\n    }\n    return fallback;\n  }\n\n  // manifest\n  const baseRels = await getRels();\n  const wbRel = baseRels.find(d => d.type === 'officeDocument');\n  if (!wbRel) {\n    throw new InvalidFileError('Input is missing a workbook definition');\n  }\n\n  const context = new ConversionContext();\n  context.rels = await getRels(wbRel.target);\n  context.options = options;\n  context.filename = pathBasename(filename);\n  context.isLikelyGSExport = isLikelyGSExport(zip);\n\n  // workbook - read DOM first to get externalReferences order\n  const wbDom = await getFile(wbRel.target);\n  if (!wbDom) {\n    throw new InvalidFileError('Input is missing a workbook');\n  }\n\n  // external links - use order from <externalReferences> in workbook.xml,\n  // not the document order in workbook.xml.rels (which can differ)\n  const extRefRIds = wbDom?.getElementsByTagName('externalReference').map(d => attr(d, 'r:id')) ?? [];\n  for (const rId of extRefRIds) {\n    const rel = context.rels.find(d => d.id === rId);\n    if (rel) {\n      const extRels = await getRels(rel.target);\n      const targetRel = extRels.find(d => d.id === 'rId1');\n      const target = targetRel?.target;\n      if (target) {\n        const exDoc = await getFile(rel.target);\n        if (exDoc) {\n          const exlink = handlerExternal(exDoc, target, extRels);\n          context.externalLinks.push(exlink);\n          if (targetRel.type.endsWith('xlPathMissing')) {\n            exlink.pathMissing = true;\n          }\n        }\n      }\n      else {\n        // TODO: Throw in strict mode?\n      }\n    }\n  }\n\n  // workbook\n  const wb = handlerWorkbook(wbDom, context);\n  context.workbook = wb;\n  // copy external links in\n  if (context.externalLinks.length) {\n    wb.externals = context.externalLinks;\n  }\n\n  // strings\n  context.sst = await maybeRead(context, 'sharedStrings', handlerSharedStrings, []);\n\n  // persons\n  const people = await maybeRead(context, 'person', handlerPersons, []);\n\n  // richData\n  context.richStruct = await maybeRead(context, 'rdRichValueStructure', handlerRDStruct);\n  context.richValues = await maybeRead(context, 'rdRichValue', handlerRDValue);\n\n  // metadata\n  context.metadata = await maybeRead(context, 'sheetMetadata', handlerMetaData);\n\n  // styles — read early so numFmts are available for pivot cache/table parsing\n  const styleDefs = await maybeRead(context, 'styles', handlerStyles);\n\n  // pivot caches (workbook-level) — prefer order from <pivotCaches> in workbook.xml\n  // over the document order in workbook.xml.rels (which can differ)\n  const pivotCacheRIds = wbDom.querySelectorAll('pivotCaches > pivotCache')\n    .map(d => attr(d, 'r:id'));\n  const pivotCacheRels = pivotCacheRIds.length > 0\n    ? pivotCacheRIds.map(rId => context.rels.find(d => d.id === rId)).filter((d): d is Rel => d != null)\n    : context.rels.filter(d => d.type === 'pivotCacheDefinition');\n\n  const cacheResults = await Promise.all(pivotCacheRels.map(async cacheRel => {\n    const [ cacheDom, cacheDefRels ] = await Promise.all([\n      getFile(cacheRel.target),\n      getRels(cacheRel.target),\n    ]);\n    if (!cacheDom) { return null; }\n    const cache = handlerPivotCacheDefinition(cacheDom, styleDefs?.numFmts);\n    if (!cache) { return null; }\n    // read the cache records via the cache definition's rels\n    const recordsRel = cacheDefRels.find(d => d.type === 'pivotCacheRecords');\n    if (recordsRel) {\n      const recordsDom = await getFile(recordsRel.target);\n      if (recordsDom) {\n        const records = handlerPivotCacheRecords(recordsDom);\n        if (records.length > 0) {\n          cache.records = records;\n        }\n      }\n    }\n    return { cache, target: cacheRel.target };\n  }));\n  const cachePathToCache = new Map<string, PivotCache>();\n  for (const result of cacheResults) {\n    if (result) {\n      cachePathToCache.set(result.target, result.cache);\n    }\n  }\n\n  // theme\n  context.theme = await maybeRead(context, 'theme', handlerTheme);\n  wb.theme = context.theme;\n\n  // convert styles to JSF format (styleDefs was read earlier for pivot numFmtId resolution)\n  const { styles, namedStyles } = convertStyles(styleDefs);\n  wb.styles = styles;\n  if (Object.keys(namedStyles).length > 0) {\n    wb.namedStyles = namedStyles;\n  }\n\n  // The Normal font (cellStyleXfs[0], defaulting to the theme minor typeface) sets the MDW that every\n  // column width is recorded against; resolve it once for the worksheet handlers.\n  const normalFont = styleDefs?.cellStyleXfs[0]?.font ?? styleDefs?.font[0];\n  const fontScheme = context.theme?.fontScheme;\n  const normalFamily = (normalFont?.name ||\n    (normalFont?.scheme === 'major'\n      ? fontScheme?.major.latin.typeface\n      : fontScheme?.minor.latin.typeface) ||\n    'Aptos Narrow');\n  context.normalMdw = resolveColumnMdw(normalFamily, normalFont?.size ?? 11, context.options);\n\n  const pivotTables: PivotTable[] = [];\n\n  // worksheets — processed sequentially to avoid shared-state races\n  for (const [ index, sheetLink ] of context.sheetLinks.entries()) {\n    const sheetRel = context.rels.find(d => d.id === sheetLink.rId);\n    if (sheetRel) {\n      const sheetName = sheetLink.name || `Sheet${sheetLink.index}`;\n      const sheetRels = await getRels(sheetRel.target);\n\n      // tables are accessed when external refs are normalized, so they have\n      // to be read before that happens\n      const tableRels = sheetRels.filter(rel => rel.type === 'table');\n      for (const tableRel of tableRels) {\n        const tableDom = await getFile(tableRel.target);\n        const table = handlerTable(tableDom, context);\n        if (table) {\n          table.sheet = sheetName;\n          wb.tables!.push(table);\n        }\n      }\n\n      const pivotTableRels = sheetRels.filter(rel => rel.type === 'pivotTable');\n      await Promise.all(pivotTableRels.map(async ptRel => {\n        const [ ptDom, ptRels ] = await Promise.all([\n          getFile(ptRel.target),\n          getRels(ptRel.target),\n        ]);\n        if (ptDom) {\n          const pt = handlerPivotTable(ptDom, styleDefs?.numFmts);\n          if (pt) {\n            pt.sheet = sheetName;\n            // resolve cache from pivot table's rels -> pivotCacheDefinition\n            const ptCacheRel = ptRels.find(d => d.type === 'pivotCacheDefinition');\n            if (ptCacheRel) {\n              const cache = cachePathToCache.get(ptCacheRel.target);\n              if (cache) { pt.cache = cache; }\n            }\n            // Only include pivot tables whose cache was successfully parsed\n            if (pt.cache != null) {\n              pivotTables.push(pt as PivotTable);\n            }\n            else {\n              context.warn(`Pivot table \"${pt.name}\" on sheet \"${sheetName}\" dropped: cache definition not found (rel target: ${ptCacheRel?.target ?? 'none'})`);\n            }\n          }\n        }\n      }));\n\n      // convert the sheet\n      const sheetFile = await getFile(sheetRel.target);\n      if (!sheetFile) {\n        throw new MissingSheetError('Missing sheet file: ' + sheetRel.target);\n      }\n\n      context.images = [];\n      const sh = handlerWorksheet(sheetFile, context, sheetRels, sheetName);\n\n      // Notes (old school, 90s, sticky notes).\n      const notes = await maybeRead(context, 'comments', handlerNotes, [], sheetRels);\n      if (notes.length > 0) {\n        sh.notes = notes;\n      }\n\n      // Threaded comments (since Excel 2019).\n      const comments = await maybeRead(context, 'threadedComment', handlerComments, [], sheetRels);\n      if (comments.length > 0) {\n        sh.comments = comments;\n      }\n\n      wb.sheets[index] = sh;\n\n      if (context.images.length) {\n        // process drawings (these may contain either charts or images)\n        for (const img of context.images) {\n          if (img.type === 'drawing') {\n            const drawingDom = await getFile(img.rel.target);\n            context.drawingRels = await getRels(img.rel.target);\n            sh.drawings = handlerDrawing(drawingDom, context);\n          }\n        }\n        // process charts\n        if (CHARTS_ENABLED) {\n          const charts: Record<string, ChartSpace> = {};\n          for (const img of context.charts) {\n            if (img.type === 'chart' || img.type === 'chartEx') {\n              // const chartRels = await getRels(img.rel.target);\n              const chartDom = await getFile(img.rel.target);\n              if (chartDom) {\n                // read rel type: chartColorStyle\n                // read rel type: chartStyle\n                const chart = handlerChart(chartDom, context);\n                charts[img.rel.target] = chart;\n              }\n            }\n          }\n          if (hasKeys(charts)) {\n            (wb as ExtendedWorkbook).charts = charts;\n          }\n        }\n\n        // process images\n        let imageCount = 0;\n        const images: Record<string, string> = {};\n        for (const img of context.images) {\n          if (img.type === 'picture') {\n            // sheet.background = ...\n\n            // only do this once per image file\n            if (!images[img.rel.target]) {\n              // img.rel.type should be \"image\"\n              const fileData = await getBinaryFile(img.rel.target);\n              if (fileData) {\n                let imageValue: string | null = null;\n                if (options.imageCallback) {\n                  const ret = await options.imageCallback(fileData, img.rel.target);\n                  if (typeof ret === 'string') { imageValue = ret; }\n                }\n                if (typeof imageValue !== 'string') {\n                  const mime = getMimeType(img.rel.target);\n                  imageValue = await arrayBufferToDataUri(fileData, mime);\n                }\n                images[img.rel.target] = imageValue;\n                imageCount++;\n              }\n            }\n          }\n          if (img.type === 'drawing' && img.rel.type === 'drawing') {\n            const drawingDom = await getFile(img.rel.target);\n            context.drawingRels = await getRels(img.rel.target);\n            let drawings = handlerDrawing(drawingDom, context);\n            // don't emit charts unless we're in \"chart mode\"\n            if (!CHARTS_ENABLED) {\n              drawings = drawings.filter(d => d.content[0]?.type !== 'chart');\n            }\n            sh.drawings = drawings;\n          }\n        }\n        if (imageCount) {\n          wb.images ??= {};\n          Object.assign(wb.images, images);\n        }\n      }\n    }\n    else {\n      // TODO: add strict mode that: throw new Error('No rel found for sheet ' + sheetLink.rId);\n    }\n  }\n\n  // Sort pivot tables by sheet position, then by name within each sheet.\n  // Sheet order is already guaranteed by sequential processing, but rels\n  // order within a sheet is not deterministic by name.\n  if (pivotTables.length > 1) {\n    const sheetOrder = new Map(context.sheetLinks.map((sl, i) => [ sl.name || `Sheet${sl.index}`, i ]));\n    pivotTables.sort((a, b) => {\n      const si = (sheetOrder.get(a.sheet) ?? Infinity) - (sheetOrder.get(b.sheet) ?? Infinity);\n      return si !== 0 ? si : a.name.localeCompare(b.name);\n    });\n  }\n\n  if (pivotTables.length > 0) {\n    wb.pivotTables = pivotTables;\n  }\n\n  // Store people from the workbook.\n  if (people.length > 0) {\n    wb.people = people;\n  }\n\n  if (!options.cellFormulas) {\n    wb.formulas = [ ...context._formulasR1C1.list() ];\n  }\n\n  // appdata/meta\n  const appMeta = handlerAppdata(await getFile('docProps/app.xml'), context);\n  if (appMeta) {\n    wb.meta = appMeta;\n  }\n\n  CHARTS_ENABLED = false;\n  return wb;\n}\n\n/**\n * An experimental version of convertBinary that includes charts the workbook payload.\n *\n * @param buffer Buffer containing the file to convert\n * @param filename Name of the file being converted\n * @param [options] Conversion options\n * @return A JSON spreadsheet formatted object.\n * @ignore\n */\nexport async function convertBinaryFuture (\n  buffer: Buffer | ArrayBuffer,\n  filename: string,\n  options?: ConversionOptions,\n): Promise<ExtendedWorkbook> {\n  CHARTS_ENABLED = true;\n  return convertBinary(buffer, filename, options);\n}\n","import { parseBool, parseDate, parseNumber, parseTime, type ParseData } from 'numfmt';\nimport type { Cell } from '@jsfkit/types';\nimport { toA1 } from './utils/toA1.ts';\n\n// Common things that are not numbers, but shouldn't identify as text when auto-detecting types\nconst reNotString = /^(?:NA|n\\/a|#?N\\/A|N\\.A\\.|NULL|null|nil|#NAME\\?|#(REF|DIV\\/0|VALUE|NUM|NULL)!|NaN|-?Infinity|\\.+|-+)$/;\n\nconst STRING = 't';\nconst NUMBER = 'n';\nconst BOOL = 'b';\nconst DATE = 'd';\n\ntype DataType = typeof STRING | typeof NUMBER | typeof BOOL | typeof DATE;\ntype ColumnData = {\n  [STRING]: number,\n  [NUMBER]: number,\n  [BOOL]: number,\n  [DATE]: number,\n  total: number,\n};\n\nconst lineBreakChains = { '\\r': '\\n', '\\n': '\\r' };\n\nexport class CSVParser {\n  row: number;\n  column: number;\n  height: number;\n  width: number;\n  delimiter: string | undefined;\n  escapeChar: string;\n  locale: string | undefined;\n  skipEmptyLines: boolean;\n  formats: string[];\n  table: Record<string, Cell> | undefined;\n  columns: ColumnData[] | undefined;\n  numfmtOptions: { locale: string; };\n\n  constructor () {\n    this.escapeChar = '\"';\n    this.skipEmptyLines = true;\n    this.formats = [];\n    this.row = 0;\n    this.column = 0;\n    this.width = 0;\n    this.height = 0;\n    this.numfmtOptions = { locale: this.locale ?? 'en-US' };\n  }\n\n  countType (type: DataType) {\n    if (!this.columns) {\n      throw new Error('column have not been inititialized');\n    }\n    const c = this.column;\n    if (!this.columns[c]) {\n      this.columns[c] = {\n        [STRING]: 0,\n        [NUMBER]: 0,\n        [BOOL]: 0,\n        [DATE]: 0,\n        total: 0,\n      };\n    }\n    this.columns[c][type]++;\n    this.columns[c].total++;\n  }\n\n  setFormatIndex (cell: Cell, formatPattern?: string): number {\n    if (formatPattern) {\n      let fmtIdx = this.formats.indexOf(formatPattern);\n      if (fmtIdx === -1) {\n        fmtIdx = this.formats.length;\n        this.formats.push(formatPattern);\n      }\n      cell.s = fmtIdx;\n      return fmtIdx;\n    }\n    return 0;\n  }\n\n  parseValue (\n    valueString: string,\n    knownString: boolean = false,\n  ) {\n    if (!this.table) {\n      throw new Error('table has not been inititialized');\n    }\n    let cell: ParseData | null;\n    const cellID = toA1(this.column, this.row);\n    if (knownString) {\n      this.table[cellID] = { v: valueString };\n      this.countType(STRING);\n    }\n    else if (valueString) {\n      if ((cell = parseNumber(valueString, this.numfmtOptions))) {\n        const outCell: Cell = { v: cell.v };\n        this.setFormatIndex(outCell, cell.z);\n        this.table[cellID] = outCell;\n        this.countType(NUMBER);\n      }\n      else if (\n        (cell = parseDate(valueString, this.numfmtOptions)) ||\n        (cell = parseTime(valueString, this.numfmtOptions))\n      ) {\n        const outCell: Cell = { v: cell.v, t: 'd' };\n        this.setFormatIndex(outCell, cell.z);\n        this.countType(DATE);\n        this.table[cellID] = outCell;\n      }\n      else if ((cell = parseBool(valueString, this.numfmtOptions))) {\n        this.table[cellID] = cell;\n        this.countType(BOOL);\n      }\n      else {\n        // XXX: if valueString starts with a \"=\" maybe emit it as `{ f: valueString }`?\n        this.table[cellID] = { v: valueString };\n        if (!reNotString.test(valueString)) {\n          this.countType(STRING);\n        }\n      }\n    }\n    // keep track of table max size, but only if we actually wrote a value\n    if (this.table[cellID]) {\n      if (this.width < this.column + 1) {\n        this.width = this.column + 1;\n      }\n      if (this.height < this.row + 1) {\n        this.height = this.row + 1;\n      }\n    }\n  }\n\n  parse (stream: string, delimiter?: string | null): Record<string, Cell> {\n    this.row = 0;\n    this.table = {};\n    this.height = 0;\n    this.width = 0;\n    this.formats = [ '' ];\n    this.columns = [];\n    this.numfmtOptions = { locale: this.locale ?? 'en-US' };\n\n    if (!delimiter && this.delimiter) {\n      delimiter = this.delimiter;\n    }\n\n    this.row = 0;\n    this.column = 0;\n    const totalLength = stream.length;\n    const QUOTE = '\"';\n    const ESC = this.escapeChar ?? '\"';\n    let token = '';\n    let pos = 0;\n    let knownString = false;\n    let inString = false;\n    let lockedValue = false;\n    let lineData = 0;\n\n    const flush = () => {\n      this.parseValue(knownString ? token : token.trim(), knownString);\n      token = '';\n      knownString = false;\n      lockedValue = false;\n    };\n\n    do {\n      const next_chr = stream.charAt(pos);\n\n      if (inString) {\n        // we are inside a string\n        if (next_chr === ESC && stream.charAt(pos + 1) === QUOTE) {\n          // escaped quote\n          token += QUOTE;\n          pos += 2;\n          lineData++;\n        }\n        else if (next_chr === QUOTE) {\n          // XXX: we expect EOL or DELIMITER next up (after possible whitespace)\n          // end of string\n          inString = false;\n          lockedValue = true;\n          pos++;\n        }\n        else {\n          token += next_chr;\n          pos++;\n          lineData++;\n        }\n      }\n      else {\n        // autodetect delimiter\n        if (!delimiter && (next_chr === ',' || next_chr === '\\t' || next_chr === ';')) {\n          // If delimiter is not ',' we could be open to switching to a lang that\n          // uses ',' as decimal separator.\n          delimiter = next_chr;\n        }\n\n        if (next_chr === '\\n' || next_chr === '\\r') {\n          flush();\n          pos += (stream.charAt(pos + 1) === lineBreakChains[next_chr]) ? 2 : 1;\n          if (lineData || !this.skipEmptyLines) {\n            this.row++;\n            lineData = 0;\n          }\n          this.column = 0;\n        }\n        else if (next_chr === QUOTE) {\n          if (token) {\n            // this is an unescaped quote in the middle of a token\n            // it is treated as any other character\n            token += next_chr;\n          }\n          else {\n            inString = true;\n          }\n          knownString = true;\n          pos++;\n        }\n        else if (next_chr === delimiter) {\n          pos++;\n          flush();\n          this.column++;\n        }\n        else if (pos >= totalLength) {\n          flush();\n          break;\n        }\n        else if (next_chr === ' ' && (!token || lockedValue)) {\n          // ignorable whitespace\n          pos++;\n        }\n        else {\n          if (lockedValue) {\n            // the case here is `\"foo\"bar`, which we'll retrospectively treat the token as non-quoted\n            // XXX: minor issue still present is that if we get `\"foo\" bar` the whitespace will be lost.\n            token = '\"' + token.replaceAll('\"', ESC + '\"') + '\"';\n            lockedValue = false;\n          }\n          // cell content\n          token += next_chr;\n          lineData++;\n          pos++;\n        }\n      }\n    }\n    while (pos <= totalLength);\n\n    flush();\n\n    return this.table;\n  }\n}\n","import { format } from 'numfmt';\nimport { CSVParser } from './CSVParser.ts';\nimport type { Style, TableColumn, Workbook } from '@jsfkit/types';\nimport { toA1 } from './utils/toA1.ts';\n\n/** CSV convertion options */\nexport type CSVConversionOptions = {\n  /**\n   * The delimiter to use to parse the CSV. Normally this is auto-detected.\n   * @defaultValue null\n   */\n  delimiter?: null | ',' | ';' | '\\t';\n  /**\n   * The character used to escape quotation marks in strings.\n   * @defaultValue '\"'\n   */\n  escapeChar?: null | '\\\\' | '\"';\n  /**\n   * Skip empty lines instead of creating empty rows.\n   * @defaultValue true\n   */\n  skipEmptyLines?: boolean;\n  /**\n   * The name of the sheet to create in the resulting workbook.\n   * @defaultValue 'Sheet1'\n   */\n  sheetName?: string;\n  /**\n   * The locale (as a BCP 47 string) to use when parsing dates and numbers.\n   * @see {https://developer.mozilla.org/en-US/docs/Glossary/BCP_47_language_tag}\n   * @defaultValue 'en-US'\n   */\n  locale?: string;\n  /**\n   * Create a table descriptor object for the data in the sheet.\n   * @defaultValue false\n   */\n  table?: boolean\n};\n\nconst EMPTY_COLUMN = { t: 0, b: 0, n: 0, d: 0, total: 0 };\n\n/**\n * Convert a CSV/TSV into JSF format.\n *\n * The returned JSF structure contains all the data table found in the file presented as\n * a spreadsheet table.\n *\n * @param csvStream A string of CSV data\n * @param name Name of the file being converted, to be used as the workbook name\n * @param [options] Conversion options\n * @return A JSON spreadsheet formatted object.\n */\nexport function convertCSV (\n  csvStream: string,\n  name: string,\n  options: CSVConversionOptions = {},\n): Workbook {\n  const outputTable = !!options.table;\n  const parser = new CSVParser();\n  if (options.skipEmptyLines === false) {\n    parser.skipEmptyLines = false;\n  }\n  if (options.escapeChar) {\n    parser.escapeChar = options.escapeChar;\n  }\n  if (options.locale) {\n    parser.locale = options.locale;\n  }\n  const cells = parser.parse(csvStream, options.delimiter);\n\n  const columns: TableColumn[] = [];\n  for (let col = 0; col < parser.width; col++) {\n    columns[col] = { name: 'Column' + (col + 1), dataType: 'unknown' };\n  }\n\n  let hasHeader = false;\n  if (outputTable) {\n    let likelyHeader = 0;\n    let singleType = 0;\n    for (let col = 0; col < parser.width; col++) {\n      const headCell = cells[toA1(col, 0)] ?? { v: null };\n      const count = parser.columns?.[col] ?? EMPTY_COLUMN;\n      if (count.t === count.total) {\n        // all text column\n        // heading is sniffed by looking for for variations in text length, up to 20 rows\n        // this is the same method Python's CSV parser uses\n        singleType++;\n        columns[col].dataType = 'text';\n        const headLength = String(headCell.v || '').length;\n        for (let row = 1; row < Math.min(20, parser.height); row++) {\n          const cell = cells[toA1(col, row)];\n          if (cell && String(cell.v).length !== headLength) {\n            likelyHeader++;\n            break;\n          }\n        }\n      }\n      else if (count.n === count.total) {\n        // all numbers, unlikely to be a heading\n        columns[col].dataType = 'number';\n        singleType++;\n      }\n      else if (count.b === count.total) {\n        // all booleans, unlikely to be a heading\n        columns[col].dataType = 'boolean';\n        singleType++;\n      }\n      else if (count.d === count.total) {\n        // all dates, unlikely to be a heading\n        columns[col].dataType = 'datetime';\n        singleType++;\n      }\n      else if (\n        count.t === 1 && typeof headCell.v === 'string' ||\n        count.n === 1 && typeof headCell.v === 'number' ||\n        count.b === 1 && typeof headCell.v === 'boolean' ||\n        count.d === 1 && headCell.t === 'd'\n      ) {\n        // this column has only a single variant type which is *very likely* the header\n        likelyHeader += 2;\n        if (count.b === count.total - 1) {\n          columns[col].dataType = 'boolean';\n        }\n        else if (count.n === count.total - 1) {\n          columns[col].dataType = 'number';\n        }\n        else if (count.d === count.total - 1) {\n          columns[col].dataType = 'datetime';\n        }\n        else if (count.t === count.total - 1) {\n          columns[col].dataType = 'text';\n        }\n      }\n    }\n\n    // We have a header if:\n    // - there is more than one row\n    // - there is at least one likely header column\n    // - the number of likely header columns is at least equal to the number of single-type columns\n    hasHeader = parser.height > 1 && likelyHeader >= singleType && likelyHeader > 0;\n    if (hasHeader) {\n      const usedNames = new Set();\n      for (let col = 0; col < parser.width; col++) {\n        const cellRef = toA1(col, 0);\n        const column = columns[col];\n        // ensure there is a cell object at the column header cell location\n        if (!cells[cellRef]) {\n          cells[cellRef] = { v: '' };\n        }\n        // use the cell's value as the column header as is possible\n        const numFormat = parser.formats[cells[cellRef].s ?? -1] || 'General';\n        let newColName = format(numFormat, cells[cellRef].v ?? '') || columns[col].name;\n        // name nust not be over 255 characters\n        newColName = newColName.slice(0, 255);\n        // name must not be duplicated\n        let counter = 1;\n        const orgName = newColName;\n        while (usedNames.has(newColName.toLowerCase())) {\n          newColName = orgName + (++counter);\n        }\n        // don't allow this name again, Excel is case-insensitive but allows whitespace\n        usedNames.add(newColName.toLowerCase());\n        // cell and column should have the same name/value\n        column.name = newColName;\n        cells[cellRef].v = newColName;\n        delete cells[cellRef].t; // cell is to be treated as text\n        delete cells[cellRef].s;\n      }\n    }\n  }\n\n  const sheetName = options.sheetName || 'Sheet1';\n  const table = {\n    name: 'Table1',\n    sheet: sheetName,\n    ref: 'A1:' + toA1(parser.width - 1, parser.height - 1),\n    headerRowCount: hasHeader ? 1 : 0,\n    totalsRowCount: 0,\n    columns: columns,\n  };\n\n  const output: Workbook = {\n    name: name,\n    sheets: [\n      {\n        name: sheetName,\n        cells: cells,\n        hidden: 0,\n        columns: [],\n        rows: [],\n        merges: [],\n        defaults: { colWidth: 65, rowHeight: 16 },\n      },\n    ],\n    names: [],\n    styles: parser.formats.map(pattern => {\n      const fmt: Style = {};\n      if (pattern) {\n        fmt.numberFormat = pattern;\n      }\n      return fmt;\n    }),\n    tables: (outputTable && parser.width && parser.height) ? [ table ] : [],\n  };\n\n  return output;\n}\n","import type { Workbook } from '@jsfkit/types';\nimport { convertBinary } from './convertBinary.ts';\nimport type { MdwResolver } from './utils/mdw.ts';\n\nexport { InvalidFileError, EncryptionError, MissingSheetError, UnsupportedError } from './errors.ts';\n\n/** Convertion options */\nexport type ConversionOptions = {\n  /**\n   * Skip cells that are a part of merges.\n   * @defaultValue true\n   */\n  skipMerged?: boolean;\n  /**\n   * Formulas are attached to cells rather than being included as a separate list.\n   * @defaultValue false\n   */\n  cellFormulas?: boolean;\n  /**\n   * Drop cells that have a style but no value or formula, unless the style is visible (fill, border, etc.).\n   * @defaultValue false\n   */\n  skipStyledEmptyCells?: boolean;\n  /**\n   * Image reading callback. All read images are passed through this callback if it is provided.\n   * This is useful, for example, for extracting the images to disk.\n   *\n   * If the return value is a string, the value will be used in the images record on\n   * the workbook instead of the standard data-URI conversion.\n   */\n  imageCallback?: (data?: ArrayBuffer, filename?: string) => Promise<string | void> | string | void\n  /**\n   * Warning callback. If provided, warnings are passed to this function; otherwise they are silently discarded.\n   */\n  warn?: (message: string) => void;\n  /**\n   * Resolve the Max Digit Width (in pixels) for the workbook's Normal font, used to convert column\n   * widths from OOXML character units to pixels. Returning null/undefined defers to the built-in table\n   * (Aptos Narrow, Calibri, Arial); unknown fonts then fall back to MDW 6 (and warn). Supply this to\n   * size columns correctly for fonts outside the table.\n   */\n  resolveMdw?: MdwResolver;\n};\n\nexport type { MdwResolver } from './utils/mdw.ts';\n\n/**\n * Load and convert an XLSX file into a JSON format.\n *\n * The returned JSF structure contains most of the data from the original file, although some details\n * may be lost in the conversion process.\n *\n * @param filename Target filename to convert\n * @param options Conversion options\n * @param [options.skipMerged] Skip any redundant cells that are a part of merges.\n * @param [options.cellFormulas] Formulas are attached to cells rather than being included separately.\n * @param [options.skipStyledEmptyCells] Drop cells that carry a style but no value/formula/data table.\n * @return A JSON spreadsheet object.\n */\nexport async function convert (\n  filename: string,\n  options?: ConversionOptions,\n): Promise<Workbook> {\n  let fs;\n  try {\n    fs = await import('fs/promises');\n  }\n  // eslint-disable-next-line no-empty\n  catch (_err) {}\n  if (!fs) {\n    throw new Error(\"'fs/promises' is not available, use convertBinary() instead\");\n  }\n  return convertBinary(await fs.readFile(filename), filename, options);\n}\n\nexport { convertCSV, type CSVConversionOptions } from './convertCSV.ts';\nexport { convertBinary } from './convertBinary.ts';\n"],"mappings":";;;;;;;AAEA,SAAgB,KACd,MACA,MACA,WAAc,MACF;CACZ,IAAI,KAAK,aAAa,IAAI,GACxB,OAAO,KAAK,aAAa,IAAI;CAE/B,OAAO;AACT;AAEA,SAAgB,QACd,MACA,MACA,WAAc,MACF;CACZ,MAAM,IAAI,KAAK,MAAM,IAAI;CACzB,OAAO,KAAK,QAAQ,OAAO,SAAS,CAAC,CAAC,IAAI,CAAC,IAAI;AACjD;AAEA,SAAg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;CAAG,CAAE,IAAI,EAAG;CAAG,CAAE,IAAI,EAAG;CAAG,CAAE,IAAI,EAAG;CAAG,CAAE,IAAI,EAAG;CACzD,CAAE,IAAI,EAAG;CAAG,CAAE,IAAI,EAAG;CAAG,CAAE,IAAI,EAAG;CAAG,CAAE,IAAI,EAAG;CAAG,CAAE,IAAI,EAAG;AAAE,CAAC,CAC3D,SAAS,CAAE,IAAI,UAAW;CACzB,gBAAgB,MAAM,gBAAgB;AACxC,CAAC;AAGH,MAAa,gBAAgB;CAC3B,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,SAAS;CACT,SAAS;CACT,SAAS;CACT,SAAS;CACT,SAAS;CACT,SAAS;CACT,OAAO;CACP,UAAU;CACV,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,OAAO;AACT;;AAGA,MAAa,kBAAkB;CAC7B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAeA,MAAa,aAAa;CACxB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;C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