UNPKG

@sheetxl/io

Version:

IO - Import/Export Libraries for SheetXL.

1,728 lines 77.8 kB
/**
 * @license @sheetxl/io - IO - Import/Export Libraries for SheetXL. - v0.7.27
 *
 * (C) 2025-present SheetXL Inc. & Michael T. Ford
 * License: The license can be found at https://www.sheetxl.com/license.
 */
import { CommonUtils as t } from "@sheetxl/utils";
import { p as e, t as s, a as r, b as o, c as i, d as n, r as l } from "./Bl-w2fv5_elyht4Z.mjs";
import { IFont as a, IAutoFilter as c, Sort as u, IRange as h, AddressUtils as p, IFill as g, IBorder as d, IStyle as m, ITextFrame as b, FormulaError as f } from "@sheetxl/sdk";
class A {
  constructor(t2) {
    this.list = t2;
  }
  get length() {
    return this.list.length;
  }
  item(t2) {
    return this.list[t2];
  }
  forEach(t2, e2) {
    for (let e3 = 0; e3 < this.list.length; e3++) t2(this.list[e3], e3, this);
  }
}
const y = (t2) => true === t2 || "1" === t2 || "on" === t2 || "true" === t2 || false !== t2 && "0" !== t2 && "off" !== t2 && "false" !== t2 && null, v = (t2) => {
  const e2 = parseInt(t2);
  return isNaN(e2) ? null : e2;
}, F = (t2) => {
  const e2 = parseFloat(t2);
  return isNaN(e2) ? null : e2;
}, C = /* @__PURE__ */ new Map();
class w {
  constructor(t2, e2, s2, r2, o2, i2 = null, n2) {
    const l2 = (t3, e3, s3) => n2?.getRef?.(t3, e3, s3, n2?.parsedRefs), a2 = (t3) => n2?.getRefs?.(t3, n2?.parsedRefs);
    this._parent = t2, this.sharedShared = e2, this.currentPath = s2, this.elemRoot = r2, this.jsonRoot = o2, t2 ? (this._fileLocation = t2._fileLocation, this._getRef = t2._getRef, this._getRefs = t2._getRefs) : (i2 && (this._fileLocation = i2), l2 && a2 && (this._getRef = l2), a2 && (this._getRefs = a2), this._onWarning = n2?.onWarning, this._addPerson = n2?.addPerson);
  }
  getRef(t2, e2 = false) {
    return this._getRef?.(t2, this._fileLocation, e2) ?? null;
  }
  getRelationships() {
    return this._getRefs(this._fileLocation) ?? C;
  }
  getPath() {
    return this.currentPath;
  }
  getElemRoot() {
    return this.elemRoot;
  }
  getJsonRoot() {
    return this.jsonRoot;
  }
  warn(t2) {
    this._onWarning ? this._onWarning(t2) : this._parent ? this._parent?.warn?.(t2) : console.warn(t2);
  }
  addPerson(t2) {
    return this._addPerson ? this._addPerson(t2) : this._parent ? this._parent?._addPerson?.(t2) : null;
  }
  getVisitorParamsState() {
    return this.sharedShared.getVisitorParamsState();
  }
  evaluate(t2, e2) {
    if (!t2) return e2;
    let s2 = [e2];
    const r2 = t2.split("/");
    for (let t3 = 0; t3 < r2.length; t3++) {
      const e3 = r2[t3];
      if ("" === e3 || "." === e3) continue;
      let o2 = [];
      for (let t4 = 0; t4 < s2.length; t4++) {
        const r3 = s2[t4], i2 = r3.childNodes;
        for (let t5 = 0; i2 && t5 < i2.length; t5++) {
          const s3 = r3.childNodes[t5];
          s3.localName !== e3 && "*" !== e3 || o2.push(s3);
        }
      }
      s2 = o2;
    }
    return 1 === s2.length ? s2[0] : 0 === s2.length ? null : new A(s2);
  }
  getFromPath(e2, s2) {
    return t.getFromPath(e2, s2);
  }
  setToPath(e2, s2, r2) {
    return t.setToPath(e2, s2, r2);
  }
  getValAttrAsString(t2, e2) {
    let s2 = this.evaluate(t2, e2);
    return s2 && s2.hasAttribute("val") ? s2.getAttribute("val") ?? null : null;
  }
  getValAttrAsBoolean(t2, e2, s2 = false) {
    let r2 = this.evaluate(t2, e2);
    if (!r2) return null;
    const o2 = r2.hasAttribute("val") ? r2.getAttribute("val") : void 0;
    return null == o2 ? s2 : "1" === o2 || "on" === o2 || "true" === o2 || "0" !== o2 && "off" !== o2 && "false" !== o2 && s2;
  }
  getValAttrAsInteger(t2, e2) {
    let s2 = this.evaluate(t2, e2);
    return s2 && s2.hasAttribute("val") ? parseInt(s2.getAttribute("val")) ?? null : null;
  }
  getValAttrAsFloat(t2, e2) {
    let s2 = this.evaluate(t2, e2);
    return s2 && s2.hasAttribute("val") ? parseFloat(s2.getAttribute("val")) ?? null : null;
  }
  get BOOLEAN_COPY() {
    return y;
  }
  get INT_COPY() {
    return v;
  }
  get FLOAT_COPY() {
    return F;
  }
  copyFromAttribute(t2, e2, s2, r2 = e2, o2 = null) {
    if (!t2 || !s2 || !t2.hasAttribute(e2)) return;
    let i2 = t2.getAttribute(e2);
    if (o2) if (Array.isArray(o2)) for (let t3 = 0; t3 < o2.length; t3++) {
      if (null == i2) return;
      if (i2 = o2[t3](i2), null == i2) return;
    }
    else {
      if (null == i2) return;
      if (i2 = o2(i2), null == i2) return;
    }
    this.setToPath(s2, r2, i2);
  }
}
class P {
  constructor(t2) {
    this.jsonKey = t2;
  }
  visit(t2, e2, s2) {
    const r2 = {};
    return s2[this.jsonKey] = r2, r2;
  }
}
class N {
  visit(t2, e2, s2) {
    if (!e2) return;
    const r2 = e2.childNodes;
    for (let e3 = 0; e3 < r2.length; e3++) {
      const o2 = r2.item(e3);
      1 === o2.nodeType && "Relationship" === o2.localName && this.processRelationship(t2, o2, s2);
    }
    return s2;
  }
  processRelationship(t2, e2, s2) {
    const r2 = {};
    t2.copyFromAttribute(e2, "Target", r2, "target"), t2.copyFromAttribute(e2, "Type", r2, "type"), t2.copyFromAttribute(e2, "TargetMode", r2, "targetMode");
    s2[e2.getAttribute("Id")] = r2;
  }
}
const O = (s2, r2) => {
  if (s2 || !s2.hasAttribute("rot")) return;
  const o2 = s2.getAttribute("rot"), i2 = t.roundAccurately(e(o2), 2);
  -1e3 !== i2 && (r2.rotation = i2);
}, S = (t2, e2, s2, r2, o2) => {
  const i2 = t2.getValAttrAsString(r2, e2);
  null !== i2 && (s2[o2] = i2);
}, T = (t2, e2, s2, r2, o2 = r2, i2 = null) => {
  const n2 = t2.getValAttrAsBoolean(r2, e2, i2);
  null !== n2 && (s2[o2] = n2);
}, V = (t2, e2, s2, r2, o2) => {
  const i2 = t2.getValAttrAsInteger(r2, e2);
  null !== i2 && (s2[o2] = i2);
}, k = (t2, e2, s2, r2, o2, i2 = 1) => {
  const n2 = t2.getValAttrAsFloat(r2, e2);
  null !== n2 && (s2[o2] = n2 * i2);
};
class x {
  visit(t2, e2, s2) {
    return T(t2, e2, s2, "roundedCorners", "roundedCorners"), V(t2, e2, s2, ".//AlternateContent/Fallback/style", "styleId"), s2.range = null, s2;
  }
  afterVisit(t2, e2, s2) {
    let r2 = {};
    s2.types = r2;
    let o2 = {}, i2 = 0, n2 = {}, l2 = 0, a2 = t2.getVisitorParamsState().get("axes");
    const c2 = t2.getVisitorParamsState().get("types");
    for (let t3 = 0; t3 < c2.length; t3++) {
      const e3 = c2[t3];
      if (e3.xAxisId) {
        const r3 = e3.xAxisId, n3 = a2.get(r3);
        o2[t3 + ""] = n3, e3.offsetXAxis = t3, delete e3.xAxisId, s2.xAxes = o2, o2.length = ++i2;
      }
      if (e3.yAxisId) {
        const r3 = e3.yAxisId, o3 = a2.get(r3);
        n2[t3 + ""] = o3, e3.offsetYAxis = t3, delete e3.yAxisId, s2.yAxes = n2, n2.length = ++l2;
      }
      r2[t3 + ""] = e3;
    }
    r2.length = c2.length;
    const u2 = t2.getVisitorParamsState().get("series");
    if (!u2 || 0 === u2.length) return;
    const h2 = {};
    s2.series = h2;
    for (let t3 = 0; t3 < u2.length; t3++) h2[t3 + ""] = u2[t3];
    h2.length = u2.length;
  }
}
class L {
  visit(t2, e2, s2) {
    return T(t2, e2, s2, "plotVisOnly", "plotVisOnly"), S(t2, e2, s2, "dispBlanksAs", "dispBlanksAs"), T(t2, e2, s2, ".//extLst/ext/dataDisplayOptions16/dispNaAsBlank", "dispNaAsBlank"), T(t2, e2, s2, "showDLblsOverMax", "showDLblsOverMax"), s2;
  }
  afterVisit(t2, e2, s2) {
    try {
      const r2 = t2.getValAttrAsBoolean("autoTitleDeleted", e2), o2 = t2.evaluate("title", e2);
      t2.setToPath(s2, "title.shown", !(true === r2 || !o2));
      const i2 = t2.evaluate("legend", e2);
      t2.setToPath(s2, "legend.shown", null !== i2);
    } catch (t3) {
      throw new Error("Unexpected Error parsing Chart: " + t3);
    }
  }
}
class I {
  visit(t2, e2, s2) {
    let r2 = {};
    return s2.plotArea = r2, r2;
  }
}
class B {
  EnumMappings() {
  }
  static fromOoxmlGradientType(t2) {
    return "circle" === t2 ? "radial" : t2;
  }
  static fromOoxmlLineCap(t2) {
    if ("rnd" === t2) return "round";
    if ("flat" === t2) return "butt";
    if ("sq" === t2) return "square";
    throw new Error("Invalid lineCap type: " + t2);
  }
  static fromOoxmlCompound(t2) {
    return "sng" === t2 ? "single" : t2;
  }
  static fromOoxmlAlignment(t2) {
    return "ctr" === t2 ? "center" : t2;
  }
}
class _ {
  visit(t2, e2, s2) {
  }
  processStroke(t2, e2, o2) {
    const i2 = {}, n2 = t2.evaluate("ln", e2);
    if (n2) {
      n2.hasAttribute("algn") && (i2.align = B.fromOoxmlAlignment(n2.getAttribute("algn"))), n2.hasAttribute("cap") && (i2.lineCap = B.fromOoxmlLineCap(n2.getAttribute("cap"))), n2.hasAttribute("cmpd") && (i2.compound = B.fromOoxmlCompound(n2.getAttribute("cmpd"))), n2.hasAttribute("w") && (i2.width = s(n2.getAttribute("w")));
      const e3 = t2.evaluate("miter", n2);
      e3 && (i2.lineJoin = "miter", e3.hasAttribute("lim") && (i2.miter = parseFloat(e3.getAttribute("lim"))));
      t2.evaluate("bevel", n2) && (i2.lineJoin = "bevel");
      t2.evaluate("round", n2) && (i2.lineJoin = "round");
      const l2 = t2.evaluate("custDash", n2);
      if (l2) {
        const e4 = t2.evaluate("ds", l2);
        if (e4 && e4.length > 0) {
          let t3 = "";
          for (let s2 = 0; s2 < e4.length; s2++) {
            const o3 = e4.item(s2);
            t3 += r(o3.getAttribute("d")) + "," + r(o3.getAttribute("sp"));
          }
          i2.dash = t3;
        }
      }
      const a2 = t2.evaluate("prstDash", n2);
      a2 && a2.hasAttribute("val") && (i2.dash = a2.getAttribute("val")), this.parseEndElement(t2, n2, i2, "headEnd", "head"), this.parseEndElement(t2, n2, i2, "tailEnd", "tail");
      const c2 = this.processFill(t2, n2, o2);
      i2.fill = c2;
    }
    return i2;
  }
  parseEndElement(t2, e2, s2, r2, o2) {
    const i2 = t2.evaluate(r2, e2);
    if (i2 && (i2.hasAttribute("type") && (s2[o2 + "Type"] = i2.getAttribute("type")), i2.hasAttribute("len") || i2.hasAttribute("w"))) {
      const t3 = i2.getAttribute("len") ? i2.getAttribute("len") : "med", e3 = i2.getAttribute("w") ? i2.getAttribute("w") : "med";
      s2[o2 + "Size"] = t3 + "-" + e3;
    }
  }
  processFill(t2, e2, s2) {
    const r2 = {};
    if (t2.evaluate("noFill", e2)) return r2.none = true, r2;
    const i2 = t2.evaluate("solidFill", e2);
    if (i2) {
      const e3 = this.processAdjColor(t2, i2);
      return e3 && (r2.solid = e3), r2;
    }
    const n2 = t2.evaluate("gradFill", e2);
    if (n2) {
      n2.hasAttribute("rotWithShape") && (r2.isRotated = "1" === n2.getAttribute("rotWithShape"));
      const e3 = this.processGradFill(t2, n2);
      return r2.gradient = e3, r2;
    }
    const l2 = t2.evaluate("pattFill", e2);
    if (l2) {
      const e3 = this.processPatternFill(t2, l2);
      return r2.pattern = e3, r2;
    }
    const a2 = t2.evaluate("blipFill", e2);
    if (a2) {
      a2.hasAttribute("rotWithShape") && (r2.isRotated = o(a2.getAttribute("rotWithShape"))), a2.hasAttribute("dpi") && (r2.dpi = a2.getAttribute("dpi"));
      const e3 = this.processImageFill(t2, a2);
      return r2.image = e3, r2;
    }
    return r2.none = true, r2;
  }
  processGradFill(t2, s2) {
    const i2 = {}, n2 = t2.evaluate("lin", s2);
    if (n2) {
      if (i2.type = "linear", n2.hasAttribute("ang")) {
        const t3 = e(n2.getAttribute("ang"));
        i2.angle = t3;
      }
      if (n2.hasAttribute("scaled")) {
        const t3 = o(n2.getAttribute("scaled"));
        i2.scaled = t3;
      }
    }
    const l2 = {};
    s2.hasAttribute("flip") && (l2.mirror = s2.getAttribute("flip")), Object.keys(l2).length > 0 && (i2.tile = l2);
    const a2 = t2.evaluate("path", s2);
    if (a2) {
      a2.hasAttribute("path") && (i2.type = B.fromOoxmlGradientType(a2.getAttribute("path")));
      const e2 = t2.evaluate("fillToRect", a2);
      e2 && (i2.fillTo = this.getRect(e2));
    }
    const c2 = t2.evaluate("tileRect", s2);
    c2 && (i2.tile.bounds = this.getRect(c2));
    const u2 = [], h2 = t2.evaluate("gsLst/gs", s2);
    for (let e2 = 0; h2 && e2 < h2.length; e2++) {
      const s3 = h2.item(e2), o2 = { offset: r(s3.getAttribute("pos")), color: this.processAdjColor(t2, s3) };
      u2.push(o2);
    }
    return u2.length > 0 && (i2.stops = u2), i2;
  }
  getRect(t2) {
    const e2 = {};
    return t2.hasAttribute("t") && (e2.t = r(t2.getAttribute("t"))), t2.hasAttribute("l") && (e2.l = r(t2.getAttribute("l"))), t2.hasAttribute("b") && (e2.b = r(t2.getAttribute("b"))), t2.hasAttribute("r") && (e2.r = r(t2.getAttribute("r"))), 0 === Object.keys(e2).length ? null : e2;
  }
  processImageFill(t2, e2) {
    const s2 = { ref: "https://www.sheetxl.com/logo-color-padded-white.jpg", tile: false };
    return s2;
  }
  processPatternFill(t2, e2) {
    const s2 = {}, r2 = e2.getAttribute("prst");
    s2.type = r2;
    const o2 = t2.evaluate("bgClr", e2);
    if (o2) {
      const e3 = this.processAdjColor(t2, o2);
      e3 && (s2.background = e3);
    }
    const i2 = t2.evaluate("fgClr", e2);
    if (i2) {
      let e3 = this.processAdjColor(t2, i2);
      e3 && (s2.foreground = e3);
    }
    return s2;
  }
  processAdjColor(t2, e2) {
    const s2 = t2.evaluate("hslClr", e2);
    if (s2) return this.processHslClr(t2, s2);
    const r2 = t2.evaluate("prstClr", e2);
    if (r2) return this.processClrWithValAttribute(t2, r2);
    const o2 = t2.evaluate("schemeClr", e2);
    if (o2) return this.processClrWithValAttribute(t2, o2);
    const i2 = t2.evaluate("sysClr", e2);
    if (i2) {
      return this.processClrWithValAttribute(t2, i2);
    }
    const n2 = t2.evaluate("scrgbClr", e2);
    if (n2) return this.processScrgbClrElement(t2, n2);
    const l2 = t2.evaluate("srgbClr", e2);
    return l2 ? this.processSrgbClrElement(t2, l2) : null;
  }
  processScrgbClrElement(t2, e2) {
    let s2 = "lrgba(" + r(e2.getAttribute("r")) + "," + r(e2.getAttribute("g")) + "," + r(e2.getAttribute("b")) + ")";
    return s2 += this.processAdjustments(t2, e2), s2;
  }
  processSrgbClrElement(t2, e2) {
    let s2 = e2.getAttribute("val");
    return s2 += this.processAdjustments(t2, e2), s2;
  }
  processHslClr(t2, s2) {
    let o2 = "hsl(" + e(s2.getAttribute("hue")) + "," + r(s2.getAttribute("sat")) + "," + r(s2.getAttribute("lum")) + ")";
    return o2 += this.processAdjustments(t2, s2), o2;
  }
  processClrWithValAttribute(t2, e2) {
    const s2 = e2.getAttribute("val");
    if (!s2) return;
    let r2 = s2;
    return r2 += this.processAdjustments(t2, e2), r2;
  }
  processAdjustments(t2, e2) {
    let s2 = "";
    const r2 = e2.childNodes;
    for (let o2 = 0; o2 < r2.length; o2++) {
      const i2 = r2.item(o2);
      if (1 === i2.nodeType) {
        let r3 = i2.localName;
        s2 += "hue" === r3 || "hueOff" === r3 || "hueMod" === r3 ? this.processAdjustmentElement(t2, e2, r3, 6e4) : "gray" === r3 || "comp" === r3 || "inv" === r3 || "gamma" === r3 || "invGamma" === r3 ? this.processAdjustmentElement(t2, e2, r3, 1) : this.processAdjustmentElement(t2, e2, r3);
      }
    }
    return s2;
  }
  processAdjustmentElement(t2, e2, s2, r2 = 1e3) {
    const o2 = t2.evaluate(s2, e2);
    if (!o2) return "";
    const i2 = o2.getAttribute("val");
    if (!i2) return ` ${s2}`;
    return ` ${s2} ${!i2 || parseFloat(i2) / r2}`;
  }
}
class j extends _ {
  visit(t2, e2, s2) {
    try {
      const r2 = t2.evaluate("xfrm", e2);
      if (r2) {
        O(r2, s2);
        const e3 = { x: 0, y: 0, width: 0, height: 0 }, o3 = t2.evaluate("off", r2);
        o3 && (e3.x = i(o3.getAttribute("x")) ?? 0, e3.y = i(o3.getAttribute("y")) ?? 0);
        const n3 = t2.evaluate("ext", r2);
        o3 && (e3.width = i(n3.getAttribute("cx")) ?? 0, e3.height = i(n3.getAttribute("cy")) ?? 0), s2.bounds = e3;
      }
      const o2 = t2.evaluate("prstGeom", e2);
      if (o2?.hasAttribute("prst")) s2.geometry = o2?.getAttribute("prst");
      else {
        t2.evaluate("customGeom", e2) && console.warn("customGeom not supported yet");
      }
      const n2 = this.processFill(t2, e2, s2);
      n2 && Object.keys(n2).length > 0 && (s2.fill = n2);
      const l2 = this.processStroke(t2, e2, s2);
      return l2 && Object.keys(l2).length > 0 && (s2.stroke = l2), s2;
    } catch (t3) {
      throw console.warn(t3), new Error("Unexpected Error parsing Shape Properties element");
    }
  }
}
class R {
  visit(t2, e2, s2) {
    let r2 = {};
    if (S(t2, e2, r2, "grouping", "grouping"), T(t2, e2, r2, "varyColors", "varyColors"), k(t2, e2, r2, "gapWidth", "gapWidth", 0.01), k(t2, e2, r2, "overlap", "overlap", 0.01), this.parseType(t2, e2, r2), V(t2, e2, r2, "bubbleScale", "bubbleScale"), T(t2, e2, r2, "showNegBubbles", "showNegativeBubbleValues"), T(t2, e2, r2, "sizeRepresents", "bubbleSizeRepresentsWidth"), V(t2, e2, r2, "firstSliceAng", "startAngle"), V(t2, e2, r2, "holeSize", "holeSize"), S(t2, e2, r2, "scatterStyle", "scatterStyle"), this.parseAxisIds(t2, e2, r2), Object.keys(r2).length > 0) {
      let e3 = t2.getVisitorParamsState().get("types");
      e3 || (e3 = [], t2.getVisitorParamsState().set("types", e3)), e3.push(r2);
    }
    return r2;
  }
  parseType(t2, e2, s2) {
    switch (e2.localName) {
      case "areaChart":
        s2.type = "area";
        break;
      case "bubbleChart":
        s2.type = "bubble";
        break;
      case "doughnutChart":
      case "ofPieType":
      case "pieChart":
        s2.type = "pie";
        break;
      case "lineChart":
        s2.type = "line";
        break;
      case "scatterChart":
        s2.type = "scatter";
    }
  }
  parseAxisIds(t2, e2, s2) {
    const r2 = t2.evaluate("axId", e2);
    if (!r2 || 0 === r2.length) return;
    const o2 = r2.item(0).getAttribute("val");
    s2.xAxisId = o2;
    const i2 = r2.item(1).getAttribute("val");
    s2.yAxisId = i2;
  }
}
class E extends R {
  parseType(t2, e2, s2) {
    const r2 = t2.getValAttrAsString("barDir", e2);
    r2 && (s2.type = "col" === r2 ? "column" : "bar");
  }
}
class Y {
  constructor(t2) {
    this.jsonKey = t2;
  }
  visit(t2, e2, s2) {
    let r2 = {}, o2 = r2, i2 = t2.getValAttrAsString("idx", e2);
    null !== i2 && (o2 = {}, o2[i2] = r2);
    const n2 = t2.getValAttrAsBoolean("delete", e2);
    this.parseNumFormat(t2, e2, r2), true === n2 ? (r2.showBubbleSize = false, r2.showCatName = false, r2.showLeaderLines = false, r2.showPercentage = false, r2.showSerName = false, r2.showVal = false, r2.showLegendKey = false) : (T(t2, e2, r2, "showBubbleSize", "showBubbleSize"), T(t2, e2, r2, "showCatName", "showCatName"), T(t2, e2, r2, "showLeaderLines", "showLeaderLines"), T(t2, e2, r2, "showPercent", "showPercentage"), T(t2, e2, r2, "showSerName", "showSerName"), T(t2, e2, r2, "showVal", "showVal"), T(t2, e2, r2, "showLegendKey", "showLegendKey"));
    const l2 = t2.evaluate("separator", e2);
    return null !== l2 && (r2.separator = l2.textContent), S(t2, e2, r2, "dLblPos", "position"), s2[this.jsonKey] = o2, r2;
  }
  parseNumFormat(t2, e2, s2) {
    const r2 = t2.evaluate("numFmt", e2);
    if (r2) {
      const t3 = r2.getAttribute("formatCode");
      s2.formatCode = t3, r2.hasAttribute("sourceLinked") && (s2.sourceLinked = "1" === r2.getAttribute("sourceLinked"));
    }
  }
}
const D = (t2, e2, s2) => {
  if (true === t2.getValAttrAsBoolean("invertIfNegative", e2)) {
    if (t2.evaluate("extLst/ext/invertSolidFillFmt", e2)) {
      if (s2.fill && s2.fillNegative) {
        const e3 = t2.getFromPath(s2, "fill.solid.adjs");
        e3 && t2.setToPath(s2, "fillNegative.solid.adjs", e3);
      }
    } else {
      const t3 = { val: "FFFFFF" }, e3 = {};
      e3.solid = t3, s2.fillNegative = e3;
      const r2 = { val: "000000" }, o2 = {};
      o2.solid = r2;
      const i2 = {};
      i2.fill = o2, s2.strokeNegative = i2;
    }
  }
};
class M {
  visit(t2, e2, s2) {
    const r2 = {};
    V(t2, e2, r2, "explosion", "explosion");
    let o2 = t2.evaluate("cat/*/f", e2);
    o2 || (o2 = t2.evaluate("xVal/*/f", e2));
    let i2 = null;
    null !== o2 && null !== o2.firstChild && (i2 = o2.firstChild.nodeValue), o2 || (o2 = t2.evaluate("cat/strLit", e2), o2 || (o2 = t2.evaluate("cat/numLit", e2)), o2 && (i2 = this.parsePointsAsString(t2, o2))), null !== i2 && (r2.xRange = i2);
    let n2 = t2.evaluate("val/*/f", e2);
    n2 || (n2 = t2.evaluate("yVal/*/f", e2));
    let l2 = null;
    n2 && n2.firstChild && (l2 = n2.firstChild.nodeValue), n2 || (n2 = t2.evaluate("val/numLit", e2), null !== n2 && (l2 = this.parsePointsAsString(t2, n2))), null !== l2 && (r2.valRange = l2), this.parseTitleRangeOrValue(t2, e2, r2), V(t2, e2, r2, "idx", "idx"), T(t2, e2, r2, "smooth", "smooth");
    const a2 = t2.getVisitorParamsState().get("types").length - 1;
    r2.offsetChart = a2;
    let c2 = t2.getVisitorParamsState().get("series");
    return c2 || (c2 = [], t2.getVisitorParamsState().set("series", c2)), c2.push(r2), r2;
  }
  parseTitleRangeOrValue(t2, e2, s2) {
    const r2 = t2.evaluate("tx/strRef/f", e2);
    if (null !== r2) {
      const e3 = r2.firstChild.nodeValue;
      t2.setToPath(s2, "title.range", e3);
    } else {
      const r3 = t2.evaluate("tx/v", e2);
      null !== r3 && t2.setToPath(s2, "title.text.simpleRun", r3.firstChild.nodeValue);
    }
  }
  parsePointsAsString(t2, e2) {
    let s2 = "{";
    const r2 = t2.getValAttrAsInteger("ptCount", e2), o2 = t2.evaluate("pt", e2), i2 = [];
    for (let s3 = 0; o2 && r2 && s3 < r2; s3++) {
      let r3 = null, o3 = t2.evaluate("pt[@idx='" + s3 + "']/v", e2);
      o3 instanceof Node && (r3 = o3.textContent), i2[s3] = r3;
    }
    for (let t3 = 0; t3 < i2.length; t3++) t3 > 0 && (s2 += ","), void 0 !== i2[t3] && (s2 += i2[t3]);
    return s2 += "}", s2;
  }
  afterVisit(t2, e2, s2) {
    D(t2, e2, s2);
    let r2 = t2.getFromPath(s2, "points");
    if (r2) {
      const e3 = Object.keys(r2);
      for (let o2 = 0; o2 < e3.length; o2++) {
        const i2 = e3[o2], n2 = t2.getFromPath(r2, i2);
        if (!n2) continue;
        let l2 = t2.getFromPath(n2, "markers");
        l2 && (t2.setToPath(s2, "markers.points." + i2, l2), delete n2.markers);
      }
    }
  }
}
class U {
  DataPointVisitor() {
  }
  visit(t2, e2, s2) {
    let r2 = t2.getFromPath(s2, "points"), o2 = null;
    r2 ? o2 = r2 : (o2 = {}, t2.setToPath(s2, "points", o2));
    let i2 = {}, n2 = t2.getValAttrAsString("idx", e2);
    return null !== n2 && (o2[n2] = i2), T(t2, e2, i2, "bubble3D", "bubble3D"), V(t2, e2, i2, "explosion", "explosion"), D(t2, e2, i2), i2;
  }
}
class z {
  visit(t2, e2, s2) {
    const r2 = e2.parentNode.localName;
    if ("ser" === r2 || "dPt" === r2) {
      const r3 = {}, o2 = t2.getValAttrAsString("size", e2);
      null !== o2 && (r3.size = o2);
      const i2 = t2.getValAttrAsString("symbol", e2);
      return i2 && (r3.type = i2), s2.markers = r3, r3;
    }
    return null;
  }
}
class G {
  visit(t2, e2, s2) {
    let r2 = {};
    this.parseScaling(t2, e2, r2), k(t2, e2, r2, "majorUnit", "majorUnits"), k(t2, e2, r2, "minorUnit", "minorUnits"), T(t2, e2, r2, "delete", "shown"), this.parseOrientation(t2, e2, r2), this.parseNumFormat(t2, e2, r2), S(t2, e2, r2, "majorTickMark", "majorTickMarks"), S(t2, e2, r2, "minorTickMark", "minorTickMarks"), S(t2, e2, r2, "crosses", "crosses"), k(t2, e2, r2, "crossesAt", "crosses"), S(t2, e2, r2, "crossBetween", "crossBetween"), this.parseLabelAlign(t2, e2, r2), V(t2, e2, r2, "lblOffset", "labelOffset"), S(t2, e2, r2, "tickLblPos", "labelPosition");
    const o2 = t2.getValAttrAsInteger("noMultiLvlLbl", e2);
    r2.labelMultiLevel = null !== o2 && 0 === o2, V(t2, e2, r2, "tickMarkSkip", "tickMarkSkip"), V(t2, e2, r2, "tickLblSkip", "labelInterval"), this.parseDisplayCustOrBuiltInUnit(e2, t2, r2), this.parseTimeUnits(t2, e2, r2, "majorUnitDates", "majorTimeUnit", "majorUnit"), this.parseTimeUnits(t2, e2, r2, "minorUnitDates", "minorTimeUnit", "minorUnit"), S(t2, e2, r2, "baseTimeUnit", "baseUnitDates"), t2.getVisitorParamsState().get("axes") || t2.getVisitorParamsState().set("axes", /* @__PURE__ */ new Map());
    const i2 = t2.getValAttrAsString("axId", e2);
    return t2.getVisitorParamsState().get("axes").set(i2, r2), r2;
  }
  parseTimeUnits(t2, e2, s2, r2, o2, i2) {
    const n2 = {};
    let l2 = t2.getValAttrAsString(o2, e2);
    if (null !== l2) {
      n2.dem = l2;
      let s3 = t2.getValAttrAsString(i2, e2);
      n2.amt = s3;
    }
    Object.keys(n2).length > 0 && (s2[r2] = n2);
  }
  parseDisplayCustOrBuiltInUnit(t2, e2, s2) {
    let r2 = e2.getValAttrAsString("dispUnits/builtInUnit", t2);
    r2 || (r2 = e2.getValAttrAsString("dispUnits/custUnit", t2)), r2 && (s2.displayUnits = r2);
  }
  parseLabelAlign(t2, e2, s2) {
    let r2 = t2.getValAttrAsString("lblAlgn", e2);
    null !== r2 && ("ctr" === r2 ? s2.labelAlign = "center" : "l" === r2 ? s2.labelAlign = "left" : "r" === r2 && (s2.labelAlign = "right"));
  }
  parseOrientation(t2, e2, s2) {
    const r2 = t2.getValAttrAsString("AxPos", e2);
    null !== r2 && ("b" === r2 ? s2.orientation = "bottom" : "l" === r2 ? s2.orientation = "left" : "r" === r2 ? s2.orientation = "right" : "t" === r2 && (s2.orientation = "top"));
  }
  parseNumFormat(t2, e2, s2) {
    const r2 = {}, o2 = t2.evaluate("numFmt", e2);
    null !== o2 && (o2.hasAttribute("formatCode") && (r2.formatCode = o2.getAttribute("formatCode")), o2.hasAttribute("sourceLinked") && (r2.sourceLinked = "1" === o2.getAttribute("sourceLinked"))), Object.keys(r2).length > 0 && (s2.labels = r2);
  }
  parseScaling(t2, e2, s2) {
    const r2 = t2.getValAttrAsString("scaling/orientation", e2);
    null !== r2 && (s2.inverted = "minMax" !== r2);
    const o2 = t2.getValAttrAsFloat("scaling/logBase", e2);
    null !== o2 && (s2.logBase = o2, s2.scaleType = "log"), k(t2, e2, s2, "scaling/max", "max"), k(t2, e2, s2, "scaling/min", "min");
  }
  afterVisit(t2, e2, s2) {
    s2.fill && s2.labels && (s2.labels.fill = s2.fill, delete s2.fill);
    let r2 = t2.getValAttrAsBoolean("delete", e2);
    null !== r2 && (t2.setToPath(s2, "labels.shown", true !== r2), t2.setToPath(s2, "shown", true !== r2));
    const o2 = t2.getFromPath(s2, "dispUnits.displayUnitsLabel");
    o2 && (t2.setToPath(s2, "displayUnitsLabel", o2), delete s2.dispUnits);
    const i2 = t2.evaluate("title", e2);
    t2.setToPath(s2, "title.shown", null !== i2);
    const n2 = t2.evaluate("minorGridlines", e2);
    t2.setToPath(s2, "gridLinesMinor.shown", null !== n2);
    const l2 = t2.evaluate("majorGridlines", e2);
    t2.setToPath(s2, "gridLinesMajor.shown", null !== l2);
  }
}
class W {
  constructor(t2 = "text") {
    this._jsonKey = t2;
  }
  getTextPath() {
    return this._jsonKey;
  }
  visit(t2, e2, s2) {
    let r2 = t2.getFromPath(s2, this.getTextPath());
    return r2 || (r2 = {}), this.parseTextElement(t2, e2, r2, false), Object.keys(r2).length > 0 && t2.setToPath(s2, this.getTextPath(), r2), s2;
  }
  parseTextElement(t2, e2, s2, r2) {
    const o2 = t2.evaluate("p/pPr/defRPr", e2) ?? t2.evaluate("defRPr", e2);
    o2 && (this.parseTextProperties(t2, o2, s2), new j().visit(t2, o2, s2));
    let i2 = [], n2 = t2.evaluate("p/r", e2) ?? t2.evaluate("r", e2);
    const l2 = (e3) => {
      const s3 = {};
      let r3 = t2.evaluate("t", e3);
      const o3 = t2.evaluate("rPr", e3);
      o3 && this.parseTextProperties(t2, o3, s3), r3 ? s3.text = r3.firstChild.textContent ?? "" : e3.textContent && (s3.text = e3.textContent ?? ""), i2.push(s3);
    };
    if (void 0 !== n2?.length) for (let t3 = 0; n2 && t3 < n2.length; t3++) l2(n2.item(t3));
    else l2(n2 || e2);
    i2.length > 0 && (s2.runs = i2);
    const a2 = t2.evaluate("bodyPr", e2);
    a2 && O(a2, s2);
  }
  parseTextProperties(t2, e2, s2) {
    if (!e2) return;
    e2.hasAttribute("sz") && (s2.size = parseFloat(e2.getAttribute("sz")) / 100), e2.hasAttribute("b") && (s2.weight = "1" === e2.getAttribute("b") ? 700 : 400), e2.hasAttribute("i") && (s2.italic = "1" === e2.getAttribute("i")), e2.hasAttribute("u") && (s2.underline = e2.getAttribute("u")), e2.hasAttribute("strike") && (s2.strike = e2.getAttribute("strike"));
    const r2 = t2.evaluate("latin", e2);
    if (r2) {
      if (!r2.getAttribute("typeface").startsWith("+")) {
        const t3 = s2.font ?? {};
        if (r2.hasAttribute("typeface") && (t3.family = r2.getAttribute("typeface")), r2.hasAttribute("panose")) {
          const e3 = r2.getAttribute("panose");
          e3 && (t3.fallbacks = [a.getPanoseFallback(e3)]);
        }
        r2.hasAttribute("pitchFamily") && (t3.pitch = r2.getAttribute("pitchFamily")), r2.hasAttribute("charset") && (t3.charset = r2.getAttribute("charset")), Object.keys(t3).length > 0 && (s2.font = t3);
      }
    }
  }
}
class X {
  visit(t2, e2, s2) {
    let r2 = t2.getVisitorParamsState().get("series")[t2.getValAttrAsInteger("idx", e2)];
    if (r2) {
      let s3 = t2.getFromPath(r2, "title");
      s3 || (s3 = {}, t2.setToPath(r2, "title", s3));
      let o2 = s3, i2 = t2.getValAttrAsBoolean("delete", e2);
      return null !== i2 && (o2.shown = !i2), o2;
    }
    return s2;
  }
}
class $ {
  visit(t2, e2, s2) {
    const r2 = {};
    return T(t2, e2, r2, "overlay", "overlay"), S(t2, e2, r2, "legendPos", "position"), s2.legend = r2, r2;
  }
}
class K extends j {
  visit(t2, e2, s2) {
    const r2 = this.processFill(t2, e2, s2);
    Object.keys(r2).length > 0 && (s2.fillNegative = r2);
    const o2 = this.processStroke(t2, e2, s2);
    return Object.keys(o2).length > 0 && (s2.strokeNegative = o2), s2;
  }
}
class H extends W {
  constructor(t2 = "title") {
    super(t2);
  }
  parseTitleRangeOrValue(t2, e2, s2) {
    let r2 = t2.evaluate("tx/strRef/f", e2) ?? null;
    if (r2) {
      const e3 = r2.firstElementChild.nodeValue;
      t2.setToPath(s2, "range", e3);
    }
  }
  visit(t2, e2, s2) {
    const r2 = {};
    T(t2, e2, r2, "overlay", "overlay"), s2[this._jsonKey] = r2;
    let o2 = t2.getFromPath(r2, this.getTextPath());
    o2 || (o2 = {}), this.parseTitleRangeOrValue(t2, e2, r2);
    const i2 = t2.evaluate("txPr", e2);
    i2 && this.parseTextElement(t2, i2, o2, false);
    const n2 = t2.evaluate("tx/rich", e2);
    return n2 && this.parseTextElement(t2, n2, o2, true), Object.keys(o2).length > 0 && t2.setToPath(r2, this.getTextPath(), o2), r2;
  }
  afterVisit(t2, e2, s2) {
    if (s2?.text) {
      const t3 = s2.text?.rotation ?? null;
      null !== t3 && (s2.rotation = parseInt(t3), delete s2.title.rotation);
    }
  }
}
class J {
  visit(t2, e2, s2) {
    const r2 = t2.evaluate("manualLayout", e2);
    if (r2) {
      let e3 = {};
      k(t2, r2, e3, "x", "x"), k(t2, r2, e3, "y", "y"), k(t2, r2, e3, "w", "w"), k(t2, r2, e3, "h", "h"), S(t2, r2, e3, "xMode", "xMode"), S(t2, r2, e3, "yMode", "yMode"), S(t2, r2, e3, "wMode", "wMode"), S(t2, r2, e3, "hMode", "hMode"), Object.keys(e3).length > 0 && (s2.manualLayout = e3);
    }
    return s2;
  }
}
class q {
  visit(t2, e2, s2) {
    return s2.name = e2.getAttribute("name"), s2;
  }
}
class Q extends _ {
  visit(t2, e2, s2) {
    const r2 = {};
    r2.name = e2.getAttribute("name");
    const o2 = e2.childNodes;
    for (let s3 = 0; s3 < o2.length; s3++) {
      const i2 = o2.item(s3);
      if (1 === i2.nodeType) {
        let s4 = i2.localName;
        const o3 = t2.evaluate(s4, e2), n2 = this.processAdjColor(t2, o3);
        r2[s4] = n2;
      }
    }
    return Object.keys(r2).length > 0 && (s2.colors = r2), r2;
  }
}
class Z {
  visit(t2, e2, s2) {
    const r2 = {};
    r2.name = e2.getAttribute("name");
    const o2 = t2.evaluate("majorFont", e2), i2 = this.processFontElement(t2, o2, {});
    r2.majorFont = i2.family, i2.fallbacks && (r2.majorFallbacks = i2.fallbacks);
    const n2 = t2.evaluate("minorFont", e2), l2 = this.processFontElement(t2, n2, {});
    return r2.minorFont = l2.family, i2.fallbacks && (r2.minorFallbacks = l2.fallbacks), s2.fonts = r2, r2;
  }
  processFontElement(t2, e2, s2) {
    if (!e2) return;
    const r2 = t2.evaluate("latin", e2);
    if (!r2) return;
    const o2 = r2.getAttribute("typeface");
    o2 && (s2.family = o2);
    const i2 = r2.getAttribute("panose");
    return i2 && (s2.fallbacks = [a.getPanoseFallback(i2)]), s2;
  }
}
class tt {
  visit(t2, e2, s2) {
    if (!e2) return;
    const r2 = {}, o2 = e2.getAttribute("r:id");
    if (o2) {
      const e3 = t2.getRef(o2);
      "string" == typeof e3 && (r2.address = e3);
    }
    return t2.copyFromAttribute(e2, "tooltip", r2), t2.copyFromAttribute(e2, "history", r2, "history", t2.BOOLEAN_COPY), t2.copyFromAttribute(e2, "tgtFrame", r2, "target"), s2.hyperlink = r2, r2;
  }
}
class et {
  visit(t2, e2, s2) {
    if (!e2) return;
    const r2 = {};
    return t2.copyFromAttribute(e2, "ref", r2), this.processFilterColumns(t2, e2, r2), Object.keys(r2).length > 0 && (s2.filter = r2), r2;
  }
  processColorFilter(t2, e2) {
    const s2 = { type: c.Type.Color };
    return t2.copyFromAttribute(e2, "cellColor", s2, "cellColor", t2.BOOLEAN_COPY), t2.copyFromAttribute(e2, "dxfId", s2, "styleId", t2.INT_COPY), s2;
  }
  processCustomFilter(t2, e2) {
    const s2 = {};
    return t2.copyFromAttribute(e2, "operator", s2, "operator", t2.BOOLEAN_COPY), t2.copyFromAttribute(e2, "val", s2, "val"), s2;
  }
  processCustomFilters(t2, e2) {
    const s2 = { type: c.Type.Custom };
    t2.copyFromAttribute(e2, "and", s2, "and", t2.BOOLEAN_COPY);
    const r2 = e2.childNodes;
    s2.filters = [];
    for (let e3 = 0; e3 < r2.length; e3++) {
      const o2 = r2.item(e3);
      if (1 !== o2.nodeType) continue;
      let i2 = null;
      "customFilter" === o2.localName && (i2 = this.processCustomFilter(t2, o2)), i2 && s2.filters.push(i2);
    }
    return s2;
  }
  processDynamicFilter(t2, e2) {
    const s2 = { type: c.Type.Dynamic };
    return t2.copyFromAttribute(e2, "type", s2, "dynamicType"), t2.copyFromAttribute(e2, "val", s2, "val", t2.INT_COPY), t2.copyFromAttribute(e2, "maxVal", s2, "maxVal", t2.INT_COPY), s2;
  }
  processDateGroupItem(t2, e2) {
    const s2 = {};
    return t2.copyFromAttribute(e2, "dateTimeGrouping", s2, "group"), t2.copyFromAttribute(e2, "day", s2, "day", t2.INT_COPY), t2.copyFromAttribute(e2, "hour", s2, "hour", t2.INT_COPY), t2.copyFromAttribute(e2, "minute", s2, "minute", t2.INT_COPY), t2.copyFromAttribute(e2, "month", s2, "month", t2.INT_COPY), t2.copyFromAttribute(e2, "second", s2, "second", t2.INT_COPY), t2.copyFromAttribute(e2, "year", s2, "year", t2.INT_COPY), s2;
  }
  processFilterItem(t2, e2) {
    if (e2.hasAttribute("val")) return e2.getAttribute("val");
  }
  processFilters(t2, e2) {
    const s2 = { type: c.Type.Items };
    t2.copyFromAttribute(e2, "blank", s2, "blank", t2.BOOLEAN_COPY), t2.copyFromAttribute(e2, "calendarType", s2, "calendarType");
    let r2 = [], o2 = [];
    const i2 = e2.childNodes;
    for (let e3 = 0; e3 < i2.length; e3++) {
      const s3 = i2.item(e3);
      if (1 === s3.nodeType) {
        if ("dateGroupItem" === s3.localName) {
          const e4 = this.processDateGroupItem(t2, s3);
          e4 && r2.push(e4);
        } else if ("filter" === s3.localName) {
          const e4 = this.processFilterItem(t2, s3);
          void 0 !== e4 && o2.push(e4);
        }
      }
    }
    return r2.length > 0 && (s2.dateGroups = r2), o2.length > 0 && (s2.items = o2), s2;
  }
  processIcon(t2, e2) {
    const s2 = { type: c.Type.Icon };
    return t2.copyFromAttribute(e2, "iconId", s2, "iconId", t2.INT_COPY), t2.copyFromAttribute(e2, "iconSet", s2), s2;
  }
  processTop10(t2, e2) {
    const s2 = { type: c.Type.Top10 };
    return t2.copyFromAttribute(e2, "filterVal", s2, "filterVal", t2.FLOAT_COPY), t2.copyFromAttribute(e2, "percent", s2, "percent", t2.BOOLEAN_COPY), t2.copyFromAttribute(e2, "top", s2, "top", t2.BOOLEAN_COPY), t2.copyFromAttribute(e2, "val", s2, "val", t2.FLOAT_COPY), s2;
  }
  processFilterCriteria(t2, e2, s2) {
    if (!e2) return;
    const r2 = e2.childNodes, o2 = [];
    for (let e3 = 0; e3 < r2.length; e3++) {
      const s3 = r2.item(e3);
      if (1 !== s3.nodeType) continue;
      let i2 = null;
      "colorFilter" === s3.localName ? i2 = this.processColorFilter(t2, s3) : "customFilters" === s3.localName ? i2 = this.processCustomFilters(t2, s3) : "dynamicFilter" === s3.localName ? i2 = this.processDynamicFilter(t2, s3) : "filters" === s3.localName ? i2 = this.processFilters(t2, s3) : "iconFilter" === s3.localName ? i2 = this.processIcon(t2, s3) : "top10" === s3.localName && (i2 = this.processTop10(t2, s3)), i2 && o2.push(i2);
    }
    return o2.length > 0 && (s2.criteria = o2), o2;
  }
  processFilterColumn(t2, e2) {
    if (!e2) return null;
    const s2 = {};
    if (!e2.hasAttribute("colId")) return;
    s2.offset = parseInt(e2.getAttribute("colId"));
    let r2 = false;
    return e2.hasAttribute("hiddenButton") && (r2 = o(e2.getAttribute("hiddenButton"))), r2 && (s2.hiddenButton = true), e2.hasAttribute("showButton") && (s2.showButton = o(e2.getAttribute("showButton"))), this.processFilterCriteria(t2, e2, s2), s2;
  }
  processFilterColumns(t2, e2, s2) {
    if (!e2) return;
    const r2 = e2.childNodes, o2 = [];
    for (let e3 = 0; e3 < r2.length; e3++) {
      const s3 = r2.item(e3);
      if (1 === s3.nodeType && "filterColumn" === s3.localName) {
        const e4 = this.processFilterColumn(t2, s3);
        e4 && o2.push(e4);
      }
    }
    return o2.length > 0 && (s2.fields = o2), o2;
  }
}
class st {
  visit(t2, e2, s2) {
    if (!e2) return;
    const r2 = {};
    if (t2.copyFromAttribute(e2, "ref", r2), e2.hasAttribute("caseSensitive")) {
      const t3 = o(e2.getAttribute("caseSensitive"));
      r2.collatorOptions = t3 ? u.CaseSensitiveOptions : u.CaseInsensitiveOptions;
    }
    const i2 = e2.getAttribute("sortMethod");
    if (null != i2 && "none" !== i2 && ("stroke" === i2 ? r2.collatorOptions = { ...r2.collatorOptions, collation: "stroke" } : "pinYin" === i2 && (r2.collatorOptions = { ...r2.collatorOptions, collation: "pinyin" })), e2.hasAttribute("columnSort")) {
      o(e2.getAttribute("columnSort")) && (r2.orientation = h.Orientation.Column);
    }
    const n2 = p.fastStringToRange(r2.ref);
    return this.processSortConditions(t2, e2, r2, n2), Object.keys(r2).length > 0 && (s2.sort = r2), r2;
  }
  processSortCondition(t2, e2, s2) {
    if (!e2) return null;
    const r2 = {};
    if (e2.hasAttribute("ref")) {
      if (e2.hasAttribute("ref")) {
        const t3 = e2.getAttribute("ref"), o2 = p.fastStringToRange(t3);
        r2.offset = s2 ? o2.colStart - s2.colStart : o2.colStart;
      }
      return r2.reverse = false, e2.hasAttribute("descending") && (r2.reverse = o(e2.getAttribute("descending"))), t2.copyFromAttribute(e2, "sortBy", r2, "sortOn"), t2.copyFromAttribute(e2, "dxfId", r2), t2.copyFromAttribute(e2, "iconSet", r2), t2.copyFromAttribute(e2, "customList", r2), r2;
    }
    console.warn("no ref for sort conditional", t2.getPath());
  }
  processSortConditions(t2, e2, s2, r2) {
    if (!e2) return;
    const o2 = e2.childNodes, i2 = [];
    for (let e3 = 0; e3 < o2.length; e3++) {
      const s3 = o2.item(e3);
      if (1 === s3.nodeType && "sortCondition" === s3.localName) {
        const e4 = this.processSortCondition(t2, s3, r2);
        e4 && i2.push(e4);
      }
    }
    return i2.length > 0 && (s2.fields = i2), i2;
  }
}
class rt {
  visit(t2, e2, s2) {
  }
  processDataBarColor(t2, e2, s2, r2, o2 = "dk1") {
    if (!e2) return;
    const i2 = n((t3) => e2.getAttribute(t3), o2);
    return i2 && (s2[r2] = i2), s2;
  }
  processFonts(t2, e2, s2) {
    if (!e2) return;
    const r2 = e2.childNodes;
    let o2 = 0;
    for (let e3 = 0; e3 < r2.length; e3++) {
      const i2 = r2.item(e3);
      if (1 === i2.nodeType && "font" === i2.localName) {
        const e4 = {};
        this.processFont(t2, i2, e4), s2[o2++] = e4;
      }
    }
    return s2;
  }
  processFont(t2, e2, s2) {
    t2.getValAttrAsBoolean("b", e2, true) && (s2.weight = 700), t2.getValAttrAsBoolean("i", e2, true) && (s2.style = a.Style.Italic), t2.getValAttrAsBoolean("strike", e2, true) && (s2.strike = true);
    const r2 = t2.evaluate("u", e2);
    if (r2) {
      const t3 = r2.getAttribute("val");
      s2.underline = t3 || a.UnderlineStyle.Single;
    }
    S(t2, e2, s2, "vertAlign", "verticalAlign"), "superscript" === s2.verticalAlign ? s2.verticalAlign = a.VerticalAlignment.Super : "subscript" === s2.verticalAlign && (s2.verticalAlign = a.VerticalAlignment.Sub), k(t2, e2, s2, "sz", "size");
    const o2 = t2.evaluate("color", e2);
    this.processDataBarColor(t2, o2, s2, "fill"), s2.fill || (s2.fill = "dk1"), S(t2, e2, s2, "name", "family"), S(t2, e2, s2, "rFont", "family");
    const i2 = t2.evaluate("family", e2);
    if (i2) {
      const t3 = i2.getAttribute("val");
      if (t3) switch (t3) {
        case "1":
          s2.fallbacks = ["serif"];
          break;
        case "2":
          s2.fallbacks = ["sans-serif"];
          break;
        case "3":
          s2.fallbacks = ["monospace"];
          break;
        case "4":
          s2.fallbacks = ["cursive"];
          break;
        case "5":
          s2.fallbacks = ["fantasy"];
      }
    }
    S(t2, e2, s2, "scheme", "scheme"), T(t2, e2, s2, "shadow", "shadow", true), T(t2, e2, s2, "outline", "outline", true);
    t2.getValAttrAsBoolean("condense", e2, true) && (s2.letterSpacing = -1);
    return t2.getValAttrAsBoolean("extend", e2, true) && (s2.letterSpacing = 1), S(t2, e2, s2, "charset", "charset"), s2;
  }
  processFills(t2, e2, s2) {
    if (!e2) return;
    const r2 = e2.childNodes;
    let o2 = 0;
    for (let e3 = 0; e3 < r2.length; e3++) {
      const i2 = r2.item(e3);
      1 === i2.nodeType && "fill" === i2.localName && this.processFill(t2, i2, s2, o2++);
    }
    return s2;
  }
  processFill(t2, e2, s2, r2) {
    const o2 = { type: g.Type.None }, i2 = e2.childNodes;
    let n2 = false;
    for (let e3 = 0; !n2 && e3 < i2.length; e3++) {
      const s3 = i2.item(e3);
      1 === s3.nodeType && ("gradientFill" === s3.localName ? (this.processGradientFill(t2, s3, o2), n2 = true) : "patternFill" === s3.localName && (this.processPatternFill(t2, s3, o2), n2 = true));
    }
    return s2[r2] = o2, s2;
  }
  processGradientFill(t2, e2, s2) {
    if (!e2) return;
    s2.type = g.Type.Gradient;
    const r2 = [];
    s2.stops = r2, s2.angle = 90 + (e2.hasAttribute("degree") ? parseFloat(e2.getAttribute("degree")) : 0);
    const o2 = e2.getAttribute("type");
    o2 && (s2.gradientType = o2);
    const i2 = (t3) => {
      if (!t3) return 0;
      const e3 = parseFloat(t3);
      return isNaN(e3) ? 0 : e3;
    };
    (e2.hasAttribute("left") || e2.hasAttribute("top") || e2.hasAttribute("right") || e2.hasAttribute("bottom")) && (s2.fillTo = { left: i2(e2.getAttribute("left")), top: i2(e2.getAttribute("top")), right: i2(e2.getAttribute("right")), bottom: i2(e2.getAttribute("bottom")) });
    const n2 = e2.childNodes;
    for (let e3 = 0; e3 < n2.length; e3++) {
      const s3 = n2.item(e3);
      if (1 === s3.nodeType && "stop" === s3.localName) {
        const e4 = {};
        r2.push(e4);
        const o3 = parseFloat(s3.getAttribute("position"));
        e4.offset = o3;
        const i3 = t2.evaluate("color", s3);
        this.processDataBarColor(t2, i3, e4, "color");
      }
    }
    return s2;
  }
  processPatternFill(t2, e2, s2) {
    if (!e2) return;
    const r2 = t2.getVisitorParamsState().get("processingDXFs"), o2 = e2.getAttribute("patternType") || (r2 ? g.BuiltInSheetPattern.Solid : g.BuiltInSheetPattern.None);
    if (o2 === g.BuiltInSheetPattern.None) return { none: true };
    s2.type = g.Type.Pattern, o2 && (s2.patternType = o2);
    let i2 = "foreground", n2 = "background";
    const l2 = s2.patternType === g.BuiltInSheetPattern.Solid && r2;
    let a2 = l2 ? "dk1" : "lt1", c2 = l2 ? "lt1" : "dk1";
    if (l2) {
      const t3 = i2;
      i2 = n2, n2 = t3;
    }
    const u2 = t2.evaluate("fgColor", e2);
    this.processDataBarColor(t2, u2, s2, i2, a2);
    const h2 = t2.evaluate("bgColor", e2);
    return this.processDataBarColor(t2, h2, s2, n2, c2), l2 && (s2.foreground || (s2.foreground = "lt1"), s2.background || (s2.background = "dk1")), s2;
  }
  processBorders(t2, e2, s2, r2) {
    if (!e2) return;
    const o2 = e2.childNodes;
    let i2 = 0;
    for (let e3 = 0; e3 < o2.length; e3++) {
      const n2 = o2.item(e3);
      1 === n2.nodeType && "border" === n2.localName && this.processBorder(t2, n2, s2, i2++, r2);
    }
    return s2;
  }
  processBorder(t2, e2, s2, r2, o2) {
    if (!e2) return;
    const i2 = {};
    return this.processBorderStroke(t2, e2, i2, d.Edge.Left), this.processBorderStroke(t2, e2, i2, d.Edge.Right), o2 ? (i2.right || i2.left) && (i2.right ? i2.vertical = { ...i2.right } : i2.vertical = { ...i2.left }) : this.processBorderStroke(t2, e2, i2, d.Edge.Vertical), this.processBorderStroke(t2, e2, i2, d.Edge.Top), this.processBorderStroke(t2, e2, i2, d.Edge.Bottom), o2 ? (i2.bottom || i2.top) && (i2.bottom ? i2.horizontal = { ...i2.bottom } : i2.horizontal = { ...i2.top }) : this.processBorderStroke(t2, e2, i2, d.Edge.Horizontal), s2[r2] = i2, s2;
  }
  processBorderStroke(t2, e2, s2, r2) {
    if (!e2) return;
    const o2 = t2.evaluate(r2, e2);
    if (!o2) return;
    const i2 = {};
    o2.hasAttribute("style") && (i2.style = o2.getAttribute("style"));
    const n2 = t2.evaluate("color", o2);
    return n2 && this.processDataBarColor(t2, n2, i2, "color"), Object.keys(i2).length > 0 ? s2[r2] = i2 : null;
  }
}
class ot extends rt {
  visit(t2, e2, s2) {
    this.processNumFmts(t2, t2.evaluate("numFmts", e2), null), t2.getVisitorParamsState().set("colorsToProcess", /* @__PURE__ */ new Set());
    const r2 = { fills: {}, fonts: {}, borders: {} };
    this.processFonts(t2, t2.evaluate("fonts", e2), r2.fonts), this.processFills(t2, t2.evaluate("fills", e2), r2.fills), this.processBorders(t2, t2.evaluate("borders", e2), r2.borders, true), r2.fills[0] = { type: g.Type.None }, r2.fills[1] = { type: g.Type.Pattern, patternType: g.BuiltInSheetPattern.Gray125 }, r2.borders[0] = { bottom: { style: d.StrokeStyle.None }, left: { style: d.StrokeStyle.None }, right: { style: d.StrokeStyle.None }, top: { style: d.StrokeStyle.None } };
    const o2 = [];
    this.processXFs(t2, t2.evaluate("cellStyleXfs", e2), o2, r2, null, false);
    const i2 = /* @__PURE__ */ new Map();
    if (o2.length > 0) {
      const r3 = [];
      this.processCellStyles(t2, t2.evaluate("cellStyles", e2), r3, o2, i2), s2.named = r3;
    }
    const n2 = [];
    this.processXFs(t2, t2.evaluate("cellXfs", e2), n2, r2, i2), Object.keys(n2).length > 0 && (s2.direct = n2);
    const l2 = [];
    return this.processDXFs(t2, t2.evaluate("dxfs", e2), l2), this.processTableStyles(t2, t2.evaluate("tableStyles", e2), s2, l2), this.processIndexColors(t2, t2.evaluate("colors/indexedColors", e2), s2), this.processMruColors(t2, t2.evaluate("colors/mruColors", e2), s2), s2;
  }
  processIndexColors(t2, e2, s2) {
    if (!e2) return;
    const r2 = [], o2 = e2.childNodes;
    for (let e3 = 0; e3 < o2.length; e3++) {
      const s3 = o2.item(e3);
      if (1 === s3.nodeType && "rgbColor" === s3.localName) {
        const e4 = { color: null };
        this.processDataBarColor(t2, s3, e4, "color"), e4.color && r2.push(e4.color);
      }
    }
    s2.indexedColors = r2;
  }
  processMruColors(t2, e2, s2) {
    if (!e2) return;
    const r2 = [], o2 = e2.childNodes;
    for (let e3 = 0; e3 < o2.length; e3++) {
      const s3 = o2.item(e3);
      if (1 === s3.nodeType && "color" === s3.localName) {
        const e4 = { color: null };
        this.processDataBarColor(t2, s3, e4, "color"), e4.color && r2.push(e4.color);
      }
    }
    r2.length > 0 && (s2.mruColors = r2);
  }
  processNumFmts(t2, e2, s2) {
    if (!e2) return;
    const r2 = /* @__PURE__ */ new Map();
    if (t2.getVisitorParamsState().set("numFmts", r2), !e2) return;
    const o2 = e2.childNodes;
    for (let t3 = 0; t3 < o2.length; t3++) {
      const e3 = o2.item(t3);
      if (1 === e3.nodeType && "numFmt" === e3.localName) {
        const t4 = e3.getAttribute("numFmtId"), s3 = e3.getAttribute("formatCode");
        if (t4 && s3) {
          const e4 = s3.replace(/\\(.)/g, "$1");
          r2.set(parseInt(t4), e4);
        }
      }
    }
  }
  processXFs(t2, e2, s2, r2, o2 = null, i2 = true) {
    if (!e2) return;
    const n2 = e2.childNodes;
    for (let e3 = 0; e3 < n2.length; e3++) {
      const l2 = n2.item(e3);
      if (1 === l2.nodeType && "xf" === l2.localName) {
        const e4 = {};
        this.processXF(t2, l2, e4, r2, o2, i2), s2.push(e4);
      }
    }
  }
  processXF(t2, e2, s2, r2, i2, n2) {
    if (!e2) return;
    const l2 = e2.getAttribute("xfId");
    if (l2 && i2) {
      const t3 = i2.get(parseInt(l2));
      t3 && t3 !== m.BuiltInName.Normal && (s2.named = t3);
    }
    const a2 = (t3) => !(!n2 && e2.hasAttribute(t3)) || o(e2.getAttribute(t3)), c2 = n2 ? "0" : void 0;
    if (a2("applyFont")) {
      const t3 = r2.fonts[e2.getAttribute("fontId") ?? c2];
      void 0 !== t3 && (s2.font = t3);
    }
    if (a2("applyFill")) {
      const t3 = r2.fills[e2.getAttribute("fillId") ?? c2];
      void 0 !== t3 && Object.keys(t3).length > 0 && (s2.fill = t3);
    }
    if (a2("applyBorder")) {
      const t3 = r2.borders[e2.getAttribute("borderId") ?? c2];
      void 0 !== t3 && (s2.border = t3);
    }
    if (a2("applyNumberFormat")) {
      const r3 = e2.getAttribute("numFmtId") ?? c2;
      if (void 0 !== r3) {
        const e3 = parseInt(r3);
        let o2;
        const i3 = t2.getVisitorParamsState();
        if (i3) {
          const t3 = i3.get("numFmts");
          t3 && (o2 = t3.get(e3)), s2.numberFormat = o2 ?? e3;
        } else console.warn("no visitor params state");
      }
    }
    a2("applyAlignment") && this.processAlignment(t2, t2.evaluate("alignment", e2), s2), a2("applyProtection") && this.processProtection(t2, t2.evaluate("protection", e2), s2);
    const u2 = o(e2.getAttribute("quotePrefix"));
    u2 && (s2.quotePrefix = u2);
  }
  processAlignment(t2, e2, s2) {
    const r2 = {};
    if (e2?.hasAttribute("horizontal") ? r2.horizontal = e2.getAttribute("horizontal") : r2.horizontal = b.HorizontalAlignment.General, e2?.hasAttribute("vertical") ? r2.vertical = e2.getAttribute("vertical") : r2.vertical = b.VerticalAlignment.Bottom, e2?.hasAttribute("indent") ? r2.indent = parseInt(e2.getAttribute("indent")) : r2.indent = 0, e2?.hasAttribute("relativeIndent") ? r2.relativeIndent = parseInt(e2.getAttribute("relativeIndent")) : r2.relativeIndent = 0, o(e2?.getAttribute("wrapText")) ? r2.overflow = b.Overflow.Wrap : r2.overflow = b.Overflow.Visible, o(e2?.getAttribute("shrinkToFit")) && (r2.overflow = b.Overflow.Shrink), e2?.hasAttribute("textRotation")) {
      let t3 = parseFloat(e2.getAttribute("textRotation"));
      t3 > 0 && t3 <= 90 ? t3 = 360 - t3 : t3 > 90 && t3 <= 180 ? t3 -= 90 : 255 === t3 && (t3 = 0, r2.stacked = true), r2.rotation = t3;
    } else r2.rotation = 0;
    e2?.hasAttribute("justifyLastLine") && (r2.justifyLastLine = o(e2.getAttribute("justifyLastLine")));
    const i2 = e2?.getAttribute("readingOrder");
    return i2 && ("0" === i2 ? r2.readingDirection = b.ReadingDirection.Auto : "1" === i2 ? r2.readingDirection = b.ReadingDirection.LeftToRight : "2" === i2 ? r2.readingDirection = b.ReadingDirection.RightToLeft : console.warn(`invalid readingOrder: ${i2}`)), Object.keys(r2).length > 0 && (s2.alignment = r2), s2;
  }
  processProtection(t2, e2, s2) {
    if (!e2) return;
    const r2 = {}, i2 = e2.getAttribute("locked");
    i2 && !o(i2) && (r2.edit = true);
    const n2 = e2.getAttribute("hidden");
    return n2 && o(n2) && (r2.formulaHidden = true), Object.keys(r2).length > 0 && (s2.protection = r2), s2;
  }
  processDXF(t2, e2, s2) {
    if (!e2) return;
    const r2 = e2.childNodes;
    for (let e3 = 0; e3 < r2.length; e3++) {
      const o2 = r2.item(e3);
      if (1 === o2.nodeType && "font" === o2.localName) {
        const e4 = {};
        this.processFont(t2, o2, e4), s2.font = e4;
      } else if (1 === o2.nodeType && "fill" === o2.localName) {
        const e4 = [];
        this.processFill(t2, o2, e4, 0), e4.length > 0 && e4[0] && (s2.fill = e4[0]);
      } else if (1 === o2.nodeType && "border" === o2.localName) {
        const e4 = [];
        this.processBorder(t2, o2, e4, 0, false), e4.length > 0 && e4[0] && (s2.border = e4[0]);
      }
    }
  }
  processDXFs(t2, e2, s2) {
    if (!e2) return;
    t2.getVisitorParamsState().set("processingDXFs", true);
    const r2 = /* @__PURE__ */ new Map();
    t2.getVisitorParamsState().set("dxfs", r2);
    const o2 = e2.childNodes;
    for (let e3 = 0; e3 < o2.length; e3++) {
      const i2 = o2.item(e3);
      if (1 === i2.nodeType && "dxf" === i2.localName) {
        const e4 = {};
        this.processDXF(t2, i2, e4);
        const o3 = s2.length;
        r2.set(o3, e4), s2.push(e4);
      }
    }
    t2.getVisitorParamsState().delete("processingDXFs");
  }
  processTableStyle(t2, e2, s2, r2, i2 = false) {
    const n2 = e2.getAttribute("name"), l2 = { name: n2 };
    e2.hasAttribute("table") && (l2.table = o(e2.getAttribute("table"))), e2.hasAttribute("pivot") && (l2.pivot = o(e2.getAttribute("pivot"))), i2 && !l2.pivot && r2.unshift(null);
    const a2 = e2.childNodes;
    for (let t3 = 0; t3 < a2.length; t3++) {
      const e3 = a2.item(t3);
      if (1 === e3.nodeType && "tableStyleElement" === e3.localName) {
        const t4 = e3.getAttribute("type"), s3 = e3.getAttribute("dxfId");
        let o2 = r2?.[s3];
        o2 || (console.warn("invalid dfx id", s3), o2 = {}), l2[t4] = o2;
        let i3 = null;
        e3.hasAttribute("size") && (i3 = parseInt(e3.getAttribute("size"))), i3 && !isNaN(i3) && (o2.size = i3);
      }
    }
    delete l2.name, s2[n2] = l2;
  }
  processTableStyles(t2, e2, s2, r2, o2) {
    if (!e2) return;
    const i2 = {}, n2 = e2.getAttribute("defaultTableStyle");
    n2 && (i2.defaultTableStyle = n2);
    const l2 = e2.getAttribute("defaultPivotStyle");
    l2 && (i2.defaultPivotStyle = l2);
    const a2 = e2.childNodes, c2 = {};
    for (let e3 = 0; e3 < a2.length; e3++) {
      const s3 = a2.item(e3);
      1 === s3.nodeType && "tableStyle" === s3.localName && this.processTableStyle(t2, s3, c2, r2, o2);
    }
    return Object.keys(c2).length > 0 && (i2.styles = c2), Object.keys(i2).length > 0 && (s2.tables = i2), s2;
  }
  processCellStyles(t2, e2, s2, r2, i2) {
    if (!e2) return;
    const n2 = e2.childNodes;
    for (let t3 = 0; t3 < n2.length; t3++) {
      const e3 = n2.item(t3);
      if (1 === e3.nodeType && "cellStyle" === e3.localName) {
        const t4 = parseInt(e3.getAttribute("xfId")), n3 = e3.getAttribute("name");
        i2.set(t4, n3);
        if (!r2[t4]) continue;
        const l2 = { name: n3, style: r2[t4] };
        e3.getAttribute("hidden") && (l2.hidden = o(e3.getAttribute("hidden"))), e3.getAttribute("iLevel") && (l2.iLevel = parseInt(e3.getAttribute("iLevel"))), s2.push(l2);
      }
    }
  }
  afterVisit(t2, e2, s2) {
  }
}
class it extends rt {
  visit(t2, e2, s2) {
    return this.processSheetRefs(t2, t2.evaluate("sheets", e2), s2), this.processBookViews(t2, t2.evaluate("bookViews", e2), s2), this.processDefinedNames(t2, t2.evaluate("definedNames", e2), s2), this.processCalcPr(t2, t2.evaluate("calcPr", e2), s2), this.processWorkbookProtection(t2, t2.evaluate("workbookProtection", e2), s2), this.processWorkbookPr(t2, t2.evaluate("workbookPr", e2), s2), s2;
  }
  processPassword(t2, e2, s2, r2 = "password") {
    if (!e2) return;
    const o2 = {};
    t2.copyFromAttribute(e2, "algorithmName", o2, "algorithmName"), t2.copyFromAttribute(e2, "hashValue", o2, "hashValue"), t2.copyFromAttribute(e2, "saltValue", o2, "saltValue", t2.BOOLEAN_COPY), t2.copyFromAttribute(e2, "spinCount", o2, "spinCount", t2.INT_COPY), Object.keys(o2).length > 0 && (s2[r2] = o2);
  }
  processWorkbookProtection(t2, e2, s2) {
    if (!e2) return;
    const r2 = {};
    this.processPassword(t2, t2.evaluate("workbookPassword", e2), r2), this.processPassword(t2, t2.evaluate("revisionsPassword", e2), r2, "revisionsPassword");
    const o2 = (t3) => true !== t3 && "1" !== t3 && "on" !== t3 && "true" !== t3 && (false === t3 || "0" === t3 || "off" === t3 || "false" === t3 || null);
    return t2.copyFromAttribute(e2, "lockStructure", r2, "structure", o2), t2.copyFromAttribute(e2, "lockWindows", r2, "windows", o2), t2.copyFromAttribute(e2, "lockRevision", r2, "revision", o2), s2.protection = r2, s2;
  }
  processCalcPr(t2, e2, s2) {
    if (!e2) return;
    s2.calc = {};
  }
  processSheetRefs(t2, e2, s2) {
    if (!e2) return;
    const r2 = [], o2 = e2.childNodes;
    for (let e3 = 0; e3 < o2.length; e3++) {
      const s3 = o2.item(e3);
      1 === s3.nodeType && "sheet" === s3.localName && this.processSheetRef(t2, s3, r2);
    }
    s2.sheets = r2;
  }
  processSheetRef(t2, e2, s2) {
    const r2 = {};
    t2.copyFromAttribute(e2, "name", r2, "name"), t2.copyFromAttribute(e2, "state", r2, "visibility");
    const o2 = e2.getAttribute("r:id"), i2 = t2.getRef(o2);
    i2 && (r2.sheet = i2), s2.push(r2);
  }
  processBookViews(t2, e2, s2) {
    if (!e2) return;
    const r2 = e2.childNodes;
    let o2 = 0;
    for (let i2 = 0; o2 < 1 && i2 < e2.childNodes.length; i2++) {
      const e3 = r2.item(i2);
      1 === e3.nodeType && "workbookView" === e3.localName && (this.processWorkbookView(t2, e3, s2), o2++);
    }
  }
  processWorkbookView(t2, e2, s2) {
    if (!e2) return;
    const r2 = {};
    t2.copyFromAttribute(e2, "activeTab", r2, "activeSheetId", [t2.INT_COPY, (t3) => t3 + 1]), e2.hasAttribute("activeTab") || (r2.activeSheetId = 1), t2.copyFromAttribute(e2, "showHorizontalScroll", r2, "showHorizontalScrollbar", t2.BOOLEAN_COPY), t2.copyFromAttribute(e2, "showVerticalScroll", r2, "showVerticalScrollbar", t2.BOOLEAN_COPY), t2.copyFromAttribute(e2, "showSheetTabs", r2, "showTabs", t2.BOOLEAN_COPY), t2.copyFromAttribute(e2, "tabRatio", r2, "tabRatio", [t2.FLOAT_COPY, (t3) => t3]), Object.keys(r2).length > 0 && (s2.view = r2);
  }
  processDefineName(t2, e2, s2, r2) {
    if (!e2) return;
    const o2 = {}, i2 = e2.firstChild;
    if (i2 && 3 === i2.nodeType && (o2.ref = i2.textContent), t2.copyFromAttribute(e2, "name", o2), t2.copyFromAttribute(e2, "comment", o2), t2.copyFromAttribute(e2, "hidden", o2, "hidden", t2.BOOLEAN_COPY), e2.hasAttribute("localSheetId")) {
      const t3 = e2.getAttribute("localSheetId");
      if (!r2[t3]?.name) return void console.warn(`Defined name '${e2.getAttribute("name")}' references a sheet with localSheetId '${t3}' which does not exist.`);
      o2.scope = r2[t3].name;
    }
    t2.copyFromAttribute(e2, "customMenu", o2), t2.copyFromAttribute(e2, "description", o2), t2.copyFromAttribute(e2, "statusBar", o2), t2.copyFromAttribute(e2, "help", o2), t2.copyFromAttribute(e2, "shortcutKey", o2), t2.copyFromAttribute(e2, "function", o2, "function", t2.BOOLEAN_COPY), t2.copyFromAttribute(e2, "functionGroupId", o2, "functionGroupId", t2.INT_COPY), t2.copyFromAttribute(e2, "publishToServer", o2, "publishToServer", t2.BOOLEAN_COPY), t2.copyFromAttribute(e2, "vbProcedure", o2, "vbProcedure", t2.BOOLEAN_COPY), t2.copyFromAttribute(e2, "xlm", o2, "xlm", t2.BOOLEAN_COPY), Object.keys(o2).length > 0 && s2.push(o2);
  }
  processDefinedNames(t2, e2, s2) {
    if (!e2) return;
    const r2 = [], o2 = e2.childNodes;
    for (let e3 = 0; e3 < o2.length; e3++) {
      const i2 = o2.item(e3);
      1 === i2.nodeType && "definedName" === i2.localName && this.processDefineName(t2, i2, r2, s2.sheets);
    }
    r2.length > 0 && (s2.names = r2);
  }
  processWorkbookPr(t2, e2, s2) {
    e2 && t2.copyFromAttribute(e2, "date1904", s2, "date1904", t2.BOOLEAN_COPY);
  }
  afterVisit(t2, e2, s2) {
  }
}
class nt {
  visit(t2, e2, s2) {
    return t2.copyFromAttribute(e2, "name", s2), t2.copyFromAttribute(e2, "displayName", s2), t2.copyFromAttribute(e2, "ref", s2), t2.copyFromAttribute(e2, "headerRowCount", s2, "headerRowCount", t2.INT_COPY), t2.copyFromAttribute(e2, "totalsRowCount", s2, "totalsRowCount", t2.INT_COPY), this.processTableColumns(t2, e2, s2), this.processTableStyleInfo(t2, e2, s2), s2;
  }
  processTableStyleInfo(t2, e2, s2) {
    if (!e2) return;
    const r2 = e2.childNodes, o2 = {};
    for (let e3 = 0; e3 < r2.length; e3++) {
      const s3 = r2.item(e3);
      1 === s3.nodeType && "tableStyleInfo" === s3.localName && (t2.copyFromAttribute(s3, "name", o2), t2.copyFromAttribute(s3, "showColumnStripes", o2, "showColumnStripes", t2.BOOLEAN_COPY), t2.copyFromAttribute(s3, "showFirstColumn", o2, "showFirstColumn", t2.BOOLEAN_COPY), t2.copyFromAttribute(s3, "showLastColumn", o2, "showLastColumn", t2.BOOLEAN_COPY), t2.copyFromAttribute(s3, "showRowStripes", o2, "showRowStripes", t2.BOOLEAN_COPY));
    }
    Object.keys(o2).length > 0 && (s2.styleOptions = o2);
  }
  processTableColumn(t2, e2, s2) {
    if (!e2) return null;
    const r2 = e2.childNodes;
    for (let e3 = 0; e3 < r2.length; e3++) {
      const o2 = r2.item(e3);
      if (1 === o2.nodeType && "tableColumn" === o2.localName) {
        const e4 = {};
        t2.copyFromAttribute(o2, "name", e4), t2.copyFromAttribute(o2, "uniqueName", e4), s2.push(e4);
      }
    }
    return s2;
  }
  processTableColumns(t2, e2, s2) {
    const r2 = e2.childNodes, o2 = [];
    for (let e3 = 0; e3 < r2.length; e3++) {
      const s3 = r2.item(e3);
      1 === s3.nodeType && "tableColumns" === s3.localName && this.processTableColumn(t2, s3, o2);
    }
    o2.length > 0 && (s2.columns = o2);
  }
}
class lt {
  visit(t2, e2, s2) {
    return s2;
  }
}
class at {
  visit(t2, e2, s2) {
    if (!e2) return;
    const r2 = {};
    return t2.copyFromAttribute(e2, "editAs", r2, "anchorType"), r2.anchor = {}, this.processOffsetCoord(t2, t2.evaluate("from", e2), r2.anchor, "from"), this.processOffsetCoord(t2, t2.evaluate("to", e2), r2.anchor, "to"), s2.movables || (s2.movables = []), s2.movables.push(r2), r2;
  }
  processOffsetCoord(t2, e2, s2, r2) {
    if (!e2) return;
    const o2 = { c: 0, r: 0, x: 0, y: 0 };
    return t2.evaluate("col", e2) && (o2.c = parseInt(t2.evaluate("col", e2).textContent)), t2.evaluate("row", e2) && (o2.r = parseInt(t2.evaluate("row", e2).textContent)), t2.evaluate("colOff", e2) && (o2.x = i(t2.evaluate("colOff", e2).textContent)), t2.evaluate("rowOff", e2) && (o2.y = i(t2.evaluate("rowOff", e2).textContent)), "from" === r2 ? s2.tl = o2 : s2.br = o2, s2;
  }
}
class ct {
  visit(t2, e2, s2) {
    if (!e2) return;
    const r2 = t2.evaluate("*/cNvPr", e2);
    return r2 && (t2.copyFromAttribute(r2, "name", s2), t2.copyFromAttribute(r2, "desc", s2), t2.copyFromAttribute(r2, "hidden", s2, "hidden", t2.BOOLEAN_COPY), t2.copyFromAttribute(r2, "id", s2)), s2;
  }
}
class ut extends ct {
  visit(t2, e2, s2) {
    if (!e2) return;
    s2 = super.visit(t2, e2, s2);
    const r2 = t2.evaluate("nvGraphicFramePr/cNvGraphicFramePr", e2);
    if (r2) {
      const e3 = t2.evaluate("graphicFrameLocks", r2);
      if (e3) {
        e3.hasAttribute("noChangeAspect") && (s2.lockAspect = "1" === e3.getAttribute("noChangeAspect"));
        const t3 = {};
        Object.keys(t3).length > 0 && (s2.locks = t3);
      }
    }
    let o2 = { type: "graphicFrame", json: {} };
    const i2 = t2.evaluate("graphic/graphicData", e2).childNodes;
    for (let e3 = 0; e3 < i2.length; e3++) {
      const s3 = i2.item(e3);
      if (1 === s3.nodeType) try {
        let e4 = s3.localName;
        "chart" === e4 && (e4 = "chart"), o2.type = e4;
        const r3 = s3.getAttribute("r:id");
        r3 && (o2.json = t2.getRef(r3));
      } catch (t3) {
        console.warn("Unable to parse graphicFrame", t3);
      }
    }
    return o2 && (s2.content = o2), o2;
  }
}
class ht extends ct {
  visit(t2, e2, s2) {
    if (!e2) return;
    s2 = super.visit(t2, e2, s2);
    const r2 = t2.evaluate("nvSpPr/cNvSpPr", e2);
    if (r2) {
      const e3 = t2.evaluate("spLocks", r2);
      if (e3) {
        e3.hasAttribute("noChangeAspect") && (s2.lockAspect = "1" === e3.getAttribute("noChangeAspect"));
        const t3 = {};
        Object.keys(t3).length > 0 && (s2.locks = t3);
      }
    }
    t2.warn(`Unable to import '${s2.name}', shapes are not supported.`);
    const o2 = {};
    return s2.content = { type: "sp", json: o2 }, o2;
  }
}
class pt extends ct {
  visit(t2, e2, s2) {
    if (!e2) return;
    const r2 = super.visit(t2, e2, s2), o2 = t2.evaluate("nvPicPr/cNvPicPr", e2);
    if (o2) {
      t2.copyFromAttribute(e2, "preferRelativeResize", r2, "preferRelativeResize", t2.BOOLEAN_COPY);
      const s3 = t2.evaluate("picLocks", o2);
      if (s3) {
        s3.hasAttribute("noChangeAspect") && (r2.lockAspect = "1" === s3.getAttribute("noChangeAspect"));
        const e3 = {};
        t2.copyFromAttribute(s3, "noChangeArrowheads", r2, "noChangeArrowheads", t2.BOOLEAN_COPY), t2.copyFromAttribute(s3, "noChangeShapeType", r2, "noChangeShapeType", t2.BOOLEAN_COPY), t2.copyFromAttribute(s3, "noEditPoints", r2, "noEditPoints", t2.BOOLEAN_COPY), t2.copyFromAttribute(s3, "noAdjustHandles", r2, "noAdjustHandles", t2.BOOLEAN_COPY), t2.copyFromAttribute(s3, "noCrop", r2, "noCrop", t2.BOOLEAN_COPY), t2.copyFromAttribute(s3, "noGrp", r2, "noGrp", t2.BOOLEAN_COPY), t2.copyFromAttribute(s3, "noMove", r2, "noMove", t2.BOOLEAN_COPY), t2.copyFromAttribute(s3, "noResize", r2, "noResize", t2.BOOLEAN_COPY), t2.copyFromAttribute(s3, "noRot", r2, "noRot", t2.BOOLEAN_COPY), t2.copyFromAttribute(s3, "noSelect", r2, "noSelect", t2.BOOLEAN_COPY), Object.keys(e3).length > 0 && (r2.locks = e3);
      }
    }
    const i2 = t2.evaluate("blipFill/blip", e2);
    let n2;
    if (i2) {
      const e3 = i2.getAttribute("r:embed") ?? i2.getAttribute("embed");
      if (!e3) return void console.warn("no rId found for blip", i2);
      n2 = t2.getRef(e3, true);
    }
    const l2 = { resId: n2 };
    return s2.content = { type: "picture", json: l2 }, r2;
  }
}
class gt extends ht {
  visit(t2, e2, s2) {
    if (!e2) return;
    s2 = super.visit(t2, e2, s2);
    const r2 = t2.evaluate("nvGrpSpPr/cNvGrpSpPr", e2);
    if (r2) {
      const e3 = t2.evaluate("grpSpLocks", r2);
      if (e3) {
        e3.hasAttribute("noChangeAspect") && (s2.lockAspect = "1" === e3.getAttribute("noChangeAspect"));
        const t3 = {};
        Object.keys(t3).length > 0 && (s2.locks = t3);
      }
    }
    t2.warn(`Unable to import '${s2.name}', group shapes are not supported.`);
    const o2 = {};
    return s2.content = { type: "grpSp", json: o2 }, o2;
  }
}
class dt extends ht {
  visit(t2, e2, s2) {
    if (!e2) return;
    s2 = super.visit(t2, e2, s2);
    const r2 = t2.evaluate("nvCxnSpPr/cNvCxnSpPr", e2);
    if (r2) {
      const e3 = t2.evaluate("cxnSpLocks", r2);
      if (e3) {
        e3.hasAttribute("noChangeAspect") && (s2.lockAspect = "1" === e3.getAttribute("noChangeAspect"));
        const t3 = {};
        Object.keys(t3).length > 0 && (s2.locks = t3);
      }
    }
    t2.warn(`Unable to import '${s2.name}', connection shapes are not supported.`);
    const o2 = {};
    return s2.content = { type: "cxnSp", json: o2 }, o2;
  }
}
const mt = "richTypes";
class bt {
  visit(t2, e2, s2) {
    let r2 = t2.getVisitorParamsState().get(mt);
    r2 || (r2 = [], t2.getVisitorParamsState().set(mt, r2));
    const o2 = e2.childNodes, i2 = o2.length;
    for (let e3 = 0; e3 < i2; e3++) {
      const s3 = o2.item(e3);
      if (1 === s3.nodeType && "s" === s3.localName) {
        const e4 = { type: s3.getAttribute("t") ?? "n", keys: [] };
        this.processKeys(t2, s3, e4), r2.push(e4);
      }
    }
    return s2.richTypes = r2, r2;
  }
  processKeys(t2, e2, s2) {
    const r2 = e2.childNodes, o2 = r2.length, i2 = s2.keys;
    for (let t3 = 0; t3 < o2; t3++) {
      const e3 = r2.item(t3);
      if (1 === e3.nodeType && "k" === e3.localName) {
        const t4 = e3.getAttribute("n"), s3 = e3.getAttribute("t");
        i2.push([t4, s3]);
      }
    }
  }
}
const ft = "richData";
class At {
  visit(t2, e2, s2) {
    let r2 = t2.getVisitorParamsState().get("richTypes");
    if (!r2) return void t2.warn("RichValueFound but not type.");
    let o2 = t2.getVisitorParamsState().get(ft);
    o2 || (o2 = [], t2.getVisitorParamsState().set(ft, o2));
    const i2 = e2.childNodes, n2 = i2.length;
    for (let e3 = 0; e3 < n2; e3++) {
      const s3 = i2.item(e3);
      if (1 === s3.nodeType && "rv" === s3.localName) {
        const e4 = r2[s3.getAttribute("s")], i3 = { type: e4.type };
        this.processValues(t2, s3, i3, e4);
        const n3 = this.mapType(t2, i3);
        o2.push(n3);
      }
    }
    return s2.richData = o2, o2;
  }
  mapType(t2, e2) {
    if ("_error" === e2.type) {
      const t3 = e2.errorType;
      if (t3) try {
        e2 = f.getBuiltInById(t3 + 1);
      } catch (t4) {
      }
    }
    return e2;
  }
  processValues(t2, e2, s2, r2) {
    const o2 = e2.childNodes, i2 = o2.length;
    r2.type;
    const n2 = r2.keys;
    for (let e3 = 0; e3 < i2; e3++) {
      const r3 = o2.item(e3);
      if (1 === r3.nodeType && "v" === r3.localName) {
        const o3 = n2[e3];
        if (!o3) return void t2.warn("Invalid richData");
        const i3 = o3[0], l2 = o3[1];
        let a2 = r3.textContent;
        "i" === l2 && (a2 = Number(a2)), s2[i3] = a2;
      }
    }
  }
}
class yt {
  visit(t2, e2, s2) {
    if (!e2) return;
    const r2 = [];
    this.processAuthors(t2, t2.evaluate("authors", e2), r2), r2.length > 0 && (s2.authors = r2);
    return s2.comments = [], s2;
  }
  processAuthors(t2, e2, s2) {
    if (!e2) return;
    const r2 = e2.childNodes;
    for (let t3 = 0; t3 < r2.length; t3++) {
      const e3 = r2.item(t3);
      if (1 === e3.nodeType && "author" === e3.localName) {
        const t4 = e3.firstChild;
        t4 && 3 === t4.nodeType && s2.push(t4.textContent);
      }
    }
  }
}
class vt {
  visit(t2, e2, s2) {
    if (!e2) return;
    const r2 = {};
    return t2.copyFromAttribute(e2, "ref", r2), t2.copyFromAttribute(e2, "authorId", r2, "authorId", t2.INT_COPY), r2.asNote = true, s2.comments || (s2.comments = []), s2.comments.push(r2), r2;
  }
}
class Ft {
  visit(t2, e2, s2) {
    if (!e2) return;
    const r2 = [];
    return s2.comments = r2, r2;
  }
}
class Ct {
  visit(t2, e2, s2) {
    if (!e2) return;
    const r2 = {};
    return t2.copyFromAttribute(e2, "id", r2, "id", l), t2.copyFromAttribute(e2, "personId", r2, "personId", l), t2.copyFromAttribute(e2, "ref", r2), t2.copyFromAttribute(e2, "parentId", r2, "parentId", l), t2.copyFromAttribute(e2, "dT", r2), e2.hasAttribute("done") && (r2.done = o(e2.getAttribute("done"))), s2.push(r2), r2;
  }
}
class wt {
  visit(t2, e2, s2) {
    const r2 = [], o2 = e2.childNodes;
    for (let e3 = 0; e3 < o2.length; e3++) {
      const s3 = o2.item(e3);
      if (1 === s3.nodeType && "person" === s3.localName) {
        const e4 = {};
        t2.copyFromAttribute(s3, "id", e4, "id", l), t2.copyFromAttribute(s3, "displayName", e4), t2.copyFromAttribute(s3, "userId", e4, "userId", l), t2.copyFromAttribute(s3, "providerId", e4), r2.push(e4);
      }
    }
    return r2.length > 0 && (s2.persons = r2), r2;
  }
}
const Pt = {};
class Nt {
  constructor(t2, e2) {
    this.path = t2, this.visitor = e2;
  }
}
class Ot {
  constructor() {
    this.visitorsByXmlTagName = /* @__PURE__ */ new Map(), this.scopedVisitorsByXmlTagName = /* @__PURE__ */ new Map(), this.visitorParamsState = null, this.registerVisitor("Relationships", new N()), this.registerVisitor("spPr", new j()), this.registerVisitor("txBody", new W()), this.registerVisitor("txPr", new W()), this.registerVisitor("c:chartSpace", new x()), this.registerVisitor("c:chartSpace", new L(), "chart"), this.registerVisitor("c:plotArea", new I()), this.registerVisitor("c:barChart", new E()), this.registerVisitor("c:doughnutChart", new R()), this.registerVisitor("c:lineChart", new R()), this.registerVisitor("c:ofPieType", new R()), this.registerVisitor("c:pieChart", new R()), this.registerVisitor("c:scatterChart", new R()), this.registerVisitor("c:barChart", new Y("dataLabels"), "dLbls"), this.registerVisitor("c:doughnutChart", new Y("dataLabels"), "dLbls"), this.registerVisitor("c:lineChart", new Y("dataLabels"), "dLbls"), this.registerVisitor("c:ofPieType", new Y("dataLabels"), "dLbls"), this.registerVisitor("c:pieChart", new Y("dataLabels"), "dLbls"), this.registerVisitor("c:scatterChart", new Y("dataLabels"), "dLbls"), this.registerVisitor("c:ser", new M()), this.registerVisitor("c:dPt", new U()), this.registerVisitor("c:marker", new z()), this.registerVisitor("c:catAx", new G()), this.registerVisitor("c:valAx", new G()), this.registerVisitor("c:dateAx", new G()), this.registerVisitor("c:majorGridlines", new P("gridLinesMajor")), this.registerVisitor("c:minorGridlines", new P("gridLinesMinor")), this.registerVisitor("c:chartSpace", null, "txPr"), this.registerVisitor("c:catAx", new W("labels.text"), "txPr"), this.registerVisitor("c:valAx", new W("labels.text"), "txPr"), this.registerVisitor("c:dateAx", new W("labels.text"), "txPr"), this.registerVisitor("c:legend", new $()), this.registerVisitor("c:legend", new W("labels.text"), "txPr"), this.registerVisitor("c:legendEntry", new X()), this.registerVisitor("c:ser", new K(), "extLst/ext/invertSolidFillFmt/spPr"), this.registerVisitor("c:ser", new Y("labels"), "dLbls"), this.registerVisitor("c:dLbl", new Y("points")), this.registerVisitor("c:title", new H()), this.registerVisitor("c:title", null, "tx/rich"), this.registerVisitor("c:title", null, "txPr"), this.registerVisitor("c:layout", new J()), this.registerVisitor("c:dispUnits", new P("dispUnits")), this.registerVisitor("c:dispUnitsLbl", new H("displayUnitsLabel")), this.registerVisitor("c:dispUnitsLbl", new W(), "tx/rich"), this.registerVisitor("a:theme", new q()), this.registerVisitor("a:theme", new Q(), "themeElements/clrScheme"), this.registerVisitor("a:theme", new Z(), "themeElements/fontScheme"), this.registerVisitor("autoFilter", new et()), this.registerVisitor("sortState", new st()), this.registerVisitor("s:workbook", new it()), this.registerVisitor("styleSheet", new ot()), this.registerVisitor("table", new nt()), this.registerVisitor("hlinkClick", new tt()), this.registerVisitor("wsDr", new lt()), this.registerVisitor("twoCellAnchor", new at()), this.registerVisitor("oneCellAnchor", new at()), this.registerVisitor("absoluteAnchor", new at()), this.registerVisitor("graphicFrame", new ut()), this.registerVisitor("sp", new ht()), this.registerVisitor("grpSp", new gt()), this.registerVisitor("cxnSp", new dt()), this.registerVisitor("pic", new pt()), this.registerVisitor("rvStructures", new bt()), this.registerVisitor("rvData", new At()), this.registerVisitor("comments", new yt()), this.registerVisitor("commentList", new vt(), "comment"), this.registerVisitor("comment", new W("content"), "text"), this.registerVisitor("ThreadedComments", new Ft()), this.registerVisitor("threadedComment", new Ct()), this.registerVisitor("threadedComment", new W("content"), "text"), this.registerVisitor("personList", new wt());
  }
  registerVisitor(t2, e2, s2 = null) {
    -1 === t2.indexOf(":") && (t2 = "*:" + t2);
    const r2 = t2.split(":"), o2 = r2.length > 1 ? r2[1] : r2[0];
    if (!s2) return this.visitorsByXmlTagName.set(o2, e2), void this.visitorsByXmlTagName.set(t2, e2);
    let i2 = this.scopedVisitorsByXmlTagName.get(o2);
    i2 || (i2 = [], this.scopedVisitorsByXmlTagName.set(o2, i2), this.scopedVisitorsByXmlTagName.set(t2, i2)), i2.push(new Nt(s2, e2));
  }
  getVisitorParamsState() {
    return this.visitorParamsState;
  }
  convert(t2, e2, s2 = Pt) {
    const r2 = t2.documentElement;
    this.visitorParamsState && !s2?.paramMap || (this.visitorParamsState = s2?.paramMap ?? /* @__PURE__ */ new Map());
    const o2 = {};
    let i2 = this.visitorsByXmlTagName.get(r2.nodeName);
    if (i2 || (i2 = this.visitorsByXmlTagName.get(r2.localName)), !i2) throw new Error(`A visitor for the root element: '${r2.nodeName}' or '${r2.localName}' must be registered.`);
    const n2 = "/" + r2.localName, l2 = new w(null, this, n2, r2, o2, e2, s2), a2 = [];
    this._doWalk(i2, l2, a2, r2, o2, e2, s2);
    for (let t3 = 0; t3 < a2.length; t3++) {
      const e3 = a2[t3];
      try {
        e3.visitor?.afterVisit?.(e3.context, e3.elemParent, e3.jsonParent);
      } catch (t4) {
        console.warn(`Error in afterVisit: ${e3.context.getPath()}`, t4);
      }
    }
    return o2;
  }
  _walkScoped(t2, e2, s2, r2, o2, i2, n2) {
    const l2 = this.scopedVisitorsByXmlTagName.get(t2);
    for (let a2 = 0; l2 && a2 < l2.length; a2++) {
      const c2 = l2[a2];
      let u2 = null;
      try {
        u2 = e2.evaluate(c2.path, r2);
      } catch (e3) {
        console.warn(`"Invalid path '${c2.path}' for '${t2}'.`);
      }
      if (!u2) continue;
      const h2 = (t3) => {
        let l3 = t3.localName, a3 = t3.parentNode;
        for (; a3 && a3 !== r2; ) l3 = a3.localName + "/" + l3, a3 = a3.parentNode;
        const u3 = e2.getPath() + "/" + l3;
        if (c2.visitor) {
          const r3 = new w(e2, this, u3, e2.getElemRoot(), e2.getJsonRoot(), i2, n2);
          this._doWalk(c2.visitor, r3, s2, t3, o2, i2, n2);
        }
      };
      if (u2.length > 0) {
        const t3 = u2;
        for (let e3 = 0; e3 < t3.length; e3++) h2(t3.item(e3));
      } else h2(u2);
    }
  }
  _doWalk(t2, e2, s2, r2, o2, i2, n2) {
    let l2 = null;
    t2 && (s2.push({ visitor: t2, context: e2, elemParent: r2, jsonParent: o2 }), l2 = t2.visit(e2, r2, o2)), l2 || (l2 = o2);
    const a2 = r2.localName;
    this._walkScoped(a2, e2, s2, r2, l2, i2, n2);
    const c2 = r2.childNodes;
    for (let t3 = 0; t3 < c2.length; t3++) {
      const r3 = c2.item(t3);
      if (1 === r3.nodeType) {
        const t4 = r3, a3 = t4.localName, c3 = this.visitorsByXmlTagName.get(a3), u2 = e2.getPath() + "/" + a3, h2 = new w(e2, this, u2, e2.getElemRoot(), e2.getJsonRoot(), i2, n2);
        this._doWalk(c3, h2, s2, t4, l2 ?? o2, i2, n2);
      }
    }
    return l2;
  }
}
export {
  Ot as FromOOXMLConverter,
  Ot as default
};