UNPKG

@sheetxl/io

Version:

IO - Import/Export Libraries for SheetXL.

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