UNPKG

@sheetxl/io

Version:

IO - Import/Export Libraries for SheetXL.

1,504 lines 73.1 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 { NumberFormat as t, ScalarType as e, IColor as s, Tuple as i, IAutoFilter as o, AddressUtils as r, CoordUtils as n, IRange as a, FormulaError as l, ResourceCollection as c, Theme as h, JSONStableStringify as u, Workbook as d, OutOfBoundsError as p } from "@sheetxl/sdk";
import { CommonUtils as g, ExpectedError as f } from "@sheetxl/utils";
const m = ":A-Z_a-zÀ-ÖØ-öø-˿Ͱ-ͽͿ-῿‌‍⁰-↏Ⰰ-⿯、-퟿豈-﷏ﷰ-�𐀀-󯿿", T = new RegExp(`^[${m}][${`-${m}.0-9·̀-ͯ‿-⁀`}]*$`, "u"), y = [32, 10, 13, 9];
function b(t2) {
  return t2 >= 65 && t2 <= 90 || t2 >= 97 && t2 <= 122 || 58 === t2 || 95 === t2 || 8204 === t2 || 8205 === t2 || t2 >= 192 && t2 <= 214 || t2 >= 216 && t2 <= 246 || t2 >= 248 && t2 <= 767 || t2 >= 880 && t2 <= 893 || t2 >= 895 && t2 <= 8191 || t2 >= 8304 && t2 <= 8591 || t2 >= 11264 && t2 <= 12271 || t2 >= 12289 && t2 <= 55295 || t2 >= 63744 && t2 <= 64975 || t2 >= 65008 && t2 <= 65533 || t2 >= 65536 && t2 <= 983039;
}
const x = "A-Z_a-zÀ-ÖØ-öø-˿Ͱ-ͽͿ-῿‌-‍⁰-↏Ⰰ-⿯、-퟿豈-﷏ﷰ-�𐀀-󯿿", w = new RegExp(`^[${x}][${`-${x}.0-9·̀-ͯ‿-⁀`}]*$`, "u");
function v(t2) {
  return t2 >= 65 && t2 <= 90 || 95 === t2 || t2 >= 97 && t2 <= 122 || t2 >= 192 && t2 <= 214 || t2 >= 216 && t2 <= 246 || t2 >= 248 && t2 <= 767 || t2 >= 880 && t2 <= 893 || t2 >= 895 && t2 <= 8191 || t2 >= 8204 && t2 <= 8205 || t2 >= 8304 && t2 <= 8591 || t2 >= 11264 && t2 <= 12271 || t2 >= 12289 && t2 <= 55295 || t2 >= 63744 && t2 <= 64975 || t2 >= 65008 && t2 <= 65533 || t2 >= 65536 && t2 <= 983039;
}
const S = function(t2) {
  return 32 === t2 || 10 === t2 || 13 === t2 || 9 === t2;
}, C = function(t2) {
  return t2 >= 32 && t2 <= 55295 || 10 === t2 || 13 === t2 || 9 === t2 || t2 >= 57344 && t2 <= 65533 || t2 >= 65536 && t2 <= 1114111;
}, k = b, A = function(t2) {
  return b(t2) || t2 >= 48 && t2 <= 57 || 45 === t2 || 46 === t2 || 183 === t2 || t2 >= 768 && t2 <= 879 || t2 >= 8255 && t2 <= 8256;
}, D = y, E = T, P = function(t2) {
  return t2 >= 1 && t2 <= 55295 || t2 >= 57344 && t2 <= 65533 || t2 >= 65536 && t2 <= 1114111;
}, O = v, I = function(t2) {
  return v(t2) || 45 === t2 || 46 === t2 || t2 >= 48 && t2 <= 57 || 183 === t2 || t2 >= 768 && t2 <= 879 || t2 >= 8255 && t2 <= 8256;
}, V = w, N = "http://www.w3.org/XML/1998/namespace", L = "http://www.w3.org/2000/xmlns/", R = { __proto__: null, xml: N, xmlns: L }, $ = { __proto__: null, amp: "&", gt: ">", lt: "<", quot: '"', apos: "'" }, M = -1, j = -2, H = 13, F = 33, X = 10, B = 60, W = 61, _ = 62, q = 63, z = 93, G = (t2) => 34 === t2 || 39 === t2, U = [34, 39], Z = [...U, 91, _], Q = [...U, B, z], J = [W, q, ...D], K = [...D, _, 38, B];
function Y(t2, e2, s2) {
  switch (e2) {
    case "xml":
      s2 !== N && t2.fail(`xml prefix must be bound to ${N}.`);
      break;
    case "xmlns":
      s2 !== L && t2.fail(`xmlns prefix must be bound to ${L}.`);
  }
  switch (s2) {
    case L:
      t2.fail("" === e2 ? `the default namespace may not be set to ${s2}.` : `may not assign a prefix (even "xmlns") to the URI ${L}.`);
      break;
    case N:
      switch (e2) {
        case "xml":
          break;
        case "":
          t2.fail(`the default namespace may not be set to ${s2}.`);
          break;
        default:
          t2.fail("may not assign the xml namespace to another prefix.");
      }
  }
}
const tt = (t2) => V.test(t2), et = (t2) => E.test(t2), st = { xmldecl: "xmlDeclHandler", text: "textHandler", processinginstruction: "piHandler", doctype: "doctypeHandler", comment: "commentHandler", opentagstart: "openTagStartHandler", attribute: "attributeHandler", opentag: "openTagHandler", closetag: "closeTagHandler", cdata: "cdataHandler", error: "errorHandler", end: "endHandler", ready: "readyHandler" };
class it {
  constructor(t2) {
    this.i = 0, this.prevI = 0, this.opt = t2 ?? {}, this.fragmentOpt = !!this.opt.fragment;
    const e2 = this.xmlnsOpt = !!this.opt.xmlns;
    if (this.trackPosition = false !== this.opt.position, this.fileName = this.opt.fileName, e2) {
      this.nameStartCheck = O, this.nameCheck = I, this.isName = tt, this.processAttribs = this.processAttribsNS, this.pushAttrib = this.pushAttribNS, this.ns = { __proto__: null, ...R };
      const t3 = this.opt.additionalNamespaces;
      null != t3 && (!(function(t4, e3) {
        for (const s2 of Object.keys(e3)) Y(t4, s2, e3[s2]);
      })(this, t3), Object.assign(this.ns, t3));
    } else this.nameStartCheck = k, this.nameCheck = A, this.isName = et, this.processAttribs = this.processAttribsPlain, this.pushAttrib = this.pushAttribPlain;
    this.stateTable = [this.sBegin, this.sBeginWhitespace, this.sDoctype, this.sDoctypeQuote, this.sDTD, this.sDTDQuoted, this.sDTDOpenWaka, this.sDTDOpenWakaBang, this.sDTDComment, this.sDTDCommentEnding, this.sDTDCommentEnded, this.sDTDPI, this.sDTDPIEnding, this.sText, this.sEntity, this.sOpenWaka, this.sOpenWakaBang, this.sComment, this.sCommentEnding, this.sCommentEnded, this.sCData, this.sCDataEnding, this.sCDataEnding2, this.sPIFirstChar, this.sPIRest, this.sPIBody, this.sPIEnding, this.sXMLDeclNameStart, this.sXMLDeclName, this.sXMLDeclEq, this.sXMLDeclValueStart, this.sXMLDeclValue, this.sXMLDeclSeparator, this.sXMLDeclEnding, this.sOpenTag, this.sOpenTagSlash, this.sAttrib, this.sAttribName, this.sAttribNameSawWhite, this.sAttribValue, this.sAttribValueQuoted, this.sAttribValueClosed, this.sAttribValueUnquoted, this.sCloseTag, this.sCloseTagSawWhite], this._init();
  }
  get closed() {
    return this._closed;
  }
  _init() {
    this.openWakaBang = "", this.text = "", this.name = "", this.piTarget = "", this.entity = "", this.q = null, this.tags = [], this.tag = null, this.topNS = null, this.chunk = "", this.chunkPosition = 0, this.i = 0, this.prevI = 0, this.carriedFromPrevious = void 0, this.forbiddenState = 0, this.attribList = [];
    const { fragmentOpt: t2 } = this;
    this.state = t2 ? H : 0, this.reportedTextBeforeRoot = this.reportedTextAfterRoot = this.closedRoot = this.sawRoot = t2, this.xmlDeclPossible = !t2, this.xmlDeclExpects = ["version"], this.entityReturnState = void 0;
    let { defaultXMLVersion: e2 } = this.opt;
    if (void 0 === e2) {
      if (true === this.opt.forceXMLVersion) throw new Error("forceXMLVersion set but defaultXMLVersion is not set");
      e2 = "1.0";
    }
    this.setXMLVersion(e2), this.positionAtNewLine = 0, this.doctype = false, this._closed = false, this.xmlDecl = { version: void 0, encoding: void 0, standalone: void 0 }, this.line = 1, this.column = 0, this.ENTITIES = Object.create($), this.readyHandler?.();
  }
  get position() {
    return this.chunkPosition + this.i;
  }
  get columnIndex() {
    return this.position - this.positionAtNewLine;
  }
  on(t2, e2) {
    this[st[t2]] = e2;
  }
  off(t2) {
    this[st[t2]] = void 0;
  }
  makeError(t2) {
    let e2 = this.fileName ?? "";
    return this.trackPosition && (e2.length > 0 && (e2 += ":"), e2 += `${this.line}:${this.column}`), e2.length > 0 && (e2 += ": "), new Error(e2 + t2);
  }
  fail(t2) {
    const e2 = this.makeError(t2), s2 = this.errorHandler;
    if (void 0 === s2) throw e2;
    return s2(e2), this;
  }
  write(t2) {
    if (this.closed) return this.fail("cannot write after close.");
    let e2 = false;
    null === t2 ? (e2 = true, t2 = "") : "object" == typeof t2 && (t2 = t2.toString()), void 0 !== this.carriedFromPrevious && (t2 = `${this.carriedFromPrevious}${t2}`, this.carriedFromPrevious = void 0);
    let s2 = t2.length;
    const i2 = t2.charCodeAt(s2 - 1);
    !e2 && (13 === i2 || i2 >= 55296 && i2 <= 56319) && (this.carriedFromPrevious = t2[s2 - 1], s2--, t2 = t2.slice(0, s2));
    const { stateTable: o2 } = this;
    for (this.chunk = t2, this.i = 0; this.i < s2; ) o2[this.state].call(this);
    return this.chunkPosition += s2, e2 ? this.end() : this;
  }
  close() {
    return this.write(null);
  }
  getCode10() {
    const t2 = this.chunk, e2 = this.i;
    if (this.prevI = e2, this.i++, e2 >= t2.length) return M;
    const s2 = t2.charCodeAt(e2);
    if (this.column++, s2 < 55296) {
      if (s2 >= 32 || 9 === s2) return s2;
      switch (s2) {
        case X:
          return this.line++, this.column = 0, this.positionAtNewLine = this.position, X;
        case 13:
          return t2.charCodeAt(e2 + 1) === X && (this.i = e2 + 2), this.line++, this.column = 0, this.positionAtNewLine = this.position, j;
        default:
          return this.fail("disallowed character."), s2;
      }
    }
    if (s2 > 56319) return s2 >= 57344 && s2 <= 65533 || this.fail("disallowed character."), s2;
    const i2 = 65536 + 1024 * (s2 - 55296) + (t2.charCodeAt(e2 + 1) - 56320);
    return this.i = e2 + 2, i2 > 1114111 && this.fail("disallowed character."), i2;
  }
  getCode11() {
    const { chunk: t2, i: e2 } = this;
    if (this.prevI = e2, this.i = e2 + 1, e2 >= t2.length) return M;
    const s2 = t2.charCodeAt(e2);
    if (this.column++, s2 < 55296) {
      if (s2 > 31 && s2 < 127 || s2 > 159 && 8232 !== s2 || 9 === s2) return s2;
      switch (s2) {
        case X:
          return this.line++, this.column = 0, this.positionAtNewLine = this.position, X;
        case 13: {
          const s3 = t2.charCodeAt(e2 + 1);
          s3 !== X && 133 !== s3 || (this.i = e2 + 2);
        }
        case 133:
        case 8232:
          return this.line++, this.column = 0, this.positionAtNewLine = this.position, j;
        default:
          return this.fail("disallowed character."), s2;
      }
    }
    if (s2 > 56319) return s2 >= 57344 && s2 <= 65533 || this.fail("disallowed character."), s2;
    const i2 = 65536 + 1024 * (s2 - 55296) + (t2.charCodeAt(e2 + 1) - 56320);
    return this.i = e2 + 2, i2 > 1114111 && this.fail("disallowed character."), i2;
  }
  getCodeNorm() {
    const t2 = this.getCode();
    return t2 === j ? X : t2;
  }
  unGet() {
    this.i = this.prevI, this.column--;
  }
  captureTo(t2) {
    let { i: e2 } = this;
    const { chunk: s2 } = this;
    for (; ; ) {
      const i2 = this.getCode(), o2 = i2 === j, r2 = o2 ? X : i2;
      if (r2 === M || t2.includes(r2)) return this.text += s2.slice(e2, this.prevI), r2;
      o2 && (this.text += `${s2.slice(e2, this.prevI)}
`, e2 = this.i);
    }
  }
  captureToChar(t2) {
    let { i: e2 } = this;
    const { chunk: s2 } = this;
    for (; ; ) {
      let i2 = this.getCode();
      switch (i2) {
        case j:
          this.text += `${s2.slice(e2, this.prevI)}
`, e2 = this.i, i2 = X;
          break;
        case M:
          return this.text += s2.slice(e2), false;
      }
      if (i2 === t2) return this.text += s2.slice(e2, this.prevI), true;
    }
  }
  captureNameChars() {
    const { chunk: t2, i: e2 } = this;
    for (; ; ) {
      const s2 = this.getCode();
      if (s2 === M) return this.name += t2.slice(e2), M;
      if (!A(s2)) return this.name += t2.slice(e2, this.prevI), s2 === j ? X : s2;
    }
  }
  skipSpaces() {
    for (; ; ) {
      const t2 = this.getCodeNorm();
      if (t2 === M || !S(t2)) return t2;
    }
  }
  setXMLVersion(t2) {
    this.currentXMLVersion = t2, "1.0" === t2 ? (this.isChar = C, this.getCode = this.getCode10) : (this.isChar = P, this.getCode = this.getCode11);
  }
  sBegin() {
    65279 === this.chunk.charCodeAt(0) && (this.i++, this.column++), this.state = 1;
  }
  sBeginWhitespace() {
    const t2 = this.i, e2 = this.skipSpaces();
    switch (this.prevI !== t2 && (this.xmlDeclPossible = false), e2) {
      case B:
        if (this.state = 15, 0 !== this.text.length) throw new Error("no-empty text at start");
        break;
      case M:
        break;
      default:
        this.unGet(), this.state = H, this.xmlDeclPossible = false;
    }
  }
  sDoctype() {
    const t2 = this.captureTo(Z);
    switch (t2) {
      case _:
        this.doctypeHandler?.(this.text), this.text = "", this.state = H, this.doctype = true;
        break;
      case M:
        break;
      default:
        this.text += String.fromCodePoint(t2), 91 === t2 ? this.state = 4 : G(t2) && (this.state = 3, this.q = t2);
    }
  }
  sDoctypeQuote() {
    const t2 = this.q;
    this.captureToChar(t2) && (this.text += String.fromCodePoint(t2), this.q = null, this.state = 2);
  }
  sDTD() {
    const t2 = this.captureTo(Q);
    t2 !== M && (this.text += String.fromCodePoint(t2), t2 === z ? this.state = 2 : t2 === B ? this.state = 6 : G(t2) && (this.state = 5, this.q = t2));
  }
  sDTDQuoted() {
    const t2 = this.q;
    this.captureToChar(t2) && (this.text += String.fromCodePoint(t2), this.state = 4, this.q = null);
  }
  sDTDOpenWaka() {
    const t2 = this.getCodeNorm();
    switch (this.text += String.fromCodePoint(t2), t2) {
      case 33:
        this.state = 7, this.openWakaBang = "";
        break;
      case q:
        this.state = 11;
        break;
      default:
        this.state = 4;
    }
  }
  sDTDOpenWakaBang() {
    const t2 = String.fromCodePoint(this.getCodeNorm()), e2 = this.openWakaBang += t2;
    this.text += t2, "-" !== e2 && (this.state = "--" === e2 ? 8 : 4, this.openWakaBang = "");
  }
  sDTDComment() {
    this.captureToChar(45) && (this.text += "-", this.state = 9);
  }
  sDTDCommentEnding() {
    const t2 = this.getCodeNorm();
    this.text += String.fromCodePoint(t2), this.state = 45 === t2 ? 10 : 8;
  }
  sDTDCommentEnded() {
    const t2 = this.getCodeNorm();
    this.text += String.fromCodePoint(t2), t2 === _ ? this.state = 4 : (this.fail("malformed comment."), this.state = 8);
  }
  sDTDPI() {
    this.captureToChar(q) && (this.text += "?", this.state = 12);
  }
  sDTDPIEnding() {
    const t2 = this.getCodeNorm();
    this.text += String.fromCodePoint(t2), t2 === _ && (this.state = 4);
  }
  sText() {
    0 !== this.tags.length ? this.handleTextInRoot() : this.handleTextOutsideRoot();
  }
  sEntity() {
    let { i: t2 } = this;
    const { chunk: e2 } = this;
    t: for (; ; ) switch (this.getCode()) {
      case j:
        this.entity += `${e2.slice(t2, this.prevI)}
`, t2 = this.i;
        break;
      case 59: {
        const { entityReturnState: s2 } = this, i2 = this.entity + e2.slice(t2, this.prevI);
        let o2;
        this.state = s2, "" === i2 ? (this.fail("empty entity name."), o2 = "&;") : (o2 = this.parseEntity(i2), this.entity = ""), s2 === H && void 0 === this.textHandler || (this.text += o2);
        break t;
      }
      case M:
        this.entity += e2.slice(t2);
        break t;
    }
  }
  sOpenWaka() {
    const t2 = this.getCode();
    if (k(t2)) this.state = 34, this.unGet(), this.xmlDeclPossible = false;
    else switch (t2) {
      case 47:
        this.state = 43, this.xmlDeclPossible = false;
        break;
      case 33:
        this.state = 16, this.openWakaBang = "", this.xmlDeclPossible = false;
        break;
      case q:
        this.state = 23;
        break;
      default:
        this.fail("disallowed character in tag name"), this.state = H, this.xmlDeclPossible = false;
    }
  }
  sOpenWakaBang() {
    switch (this.openWakaBang += String.fromCodePoint(this.getCodeNorm()), this.openWakaBang) {
      case "[CDATA[":
        this.sawRoot || this.reportedTextBeforeRoot || (this.fail("text data outside of root node."), this.reportedTextBeforeRoot = true), this.closedRoot && !this.reportedTextAfterRoot && (this.fail("text data outside of root node."), this.reportedTextAfterRoot = true), this.state = 20, this.openWakaBang = "";
        break;
      case "--":
        this.state = 17, this.openWakaBang = "";
        break;
      case "DOCTYPE":
        this.state = 2, (this.doctype || this.sawRoot) && this.fail("inappropriately located doctype declaration."), this.openWakaBang = "";
        break;
      default:
        this.openWakaBang.length >= 7 && this.fail("incorrect syntax.");
    }
  }
  sComment() {
    this.captureToChar(45) && (this.state = 18);
  }
  sCommentEnding() {
    const t2 = this.getCodeNorm();
    45 === t2 ? (this.state = 19, this.commentHandler?.(this.text), this.text = "") : (this.text += `-${String.fromCodePoint(t2)}`, this.state = 17);
  }
  sCommentEnded() {
    const t2 = this.getCodeNorm();
    t2 !== _ ? (this.fail("malformed comment."), this.text += `--${String.fromCodePoint(t2)}`, this.state = 17) : this.state = H;
  }
  sCData() {
    this.captureToChar(z) && (this.state = 21);
  }
  sCDataEnding() {
    const t2 = this.getCodeNorm();
    t2 === z ? this.state = 22 : (this.text += `]${String.fromCodePoint(t2)}`, this.state = 20);
  }
  sCDataEnding2() {
    const t2 = this.getCodeNorm();
    switch (t2) {
      case _:
        this.cdataHandler?.(this.text), this.text = "", this.state = H;
        break;
      case z:
        this.text += "]";
        break;
      default:
        this.text += `]]${String.fromCodePoint(t2)}`, this.state = 20;
    }
  }
  sPIFirstChar() {
    const t2 = this.getCodeNorm();
    this.nameStartCheck(t2) ? (this.piTarget += String.fromCodePoint(t2), this.state = 24) : t2 === q || S(t2) ? (this.fail("processing instruction without a target."), this.state = t2 === q ? 26 : 25) : (this.fail("disallowed character in processing instruction name."), this.piTarget += String.fromCodePoint(t2), this.state = 24);
  }
  sPIRest() {
    const { chunk: t2, i: e2 } = this;
    for (; ; ) {
      const s2 = this.getCodeNorm();
      if (s2 === M) return void (this.piTarget += t2.slice(e2));
      if (!this.nameCheck(s2)) {
        this.piTarget += t2.slice(e2, this.prevI);
        const i2 = s2 === q;
        i2 || S(s2) ? "xml" === this.piTarget ? (this.xmlDeclPossible || this.fail("an XML declaration must be at the start of the document."), this.state = i2 ? F : 27) : this.state = i2 ? 26 : 25 : (this.fail("disallowed character in processing instruction name."), this.piTarget += String.fromCodePoint(s2));
        break;
      }
    }
  }
  sPIBody() {
    if (0 === this.text.length) {
      const t2 = this.getCodeNorm();
      t2 === q ? this.state = 26 : S(t2) || (this.text = String.fromCodePoint(t2));
    } else this.captureToChar(q) && (this.state = 26);
  }
  sPIEnding() {
    const t2 = this.getCodeNorm();
    if (t2 === _) {
      const { piTarget: t3 } = this;
      "xml" === t3.toLowerCase() && this.fail("the XML declaration must appear at the start of the document."), this.piHandler?.({ target: t3, body: this.text }), this.piTarget = this.text = "", this.state = H;
    } else t2 === q ? this.text += "?" : (this.text += `?${String.fromCodePoint(t2)}`, this.state = 25);
    this.xmlDeclPossible = false;
  }
  sXMLDeclNameStart() {
    const t2 = this.skipSpaces();
    t2 !== q ? t2 !== M && (this.state = 28, this.name = String.fromCodePoint(t2)) : this.state = F;
  }
  sXMLDeclName() {
    const t2 = this.captureTo(J);
    if (t2 === q) return this.state = F, this.name += this.text, this.text = "", void this.fail("XML declaration is incomplete.");
    if (S(t2) || t2 === W) {
      if (this.name += this.text, this.text = "", !this.xmlDeclExpects.includes(this.name)) switch (this.name.length) {
        case 0:
          this.fail("did not expect any more name/value pairs.");
          break;
        case 1:
          this.fail(`expected the name ${this.xmlDeclExpects[0]}.`);
          break;
        default:
          this.fail(`expected one of ${this.xmlDeclExpects.join(", ")}`);
      }
      this.state = t2 === W ? 30 : 29;
    }
  }
  sXMLDeclEq() {
    const t2 = this.getCodeNorm();
    if (t2 === q) return this.state = F, void this.fail("XML declaration is incomplete.");
    S(t2) || (t2 !== W && this.fail("value required."), this.state = 30);
  }
  sXMLDeclValueStart() {
    const t2 = this.getCodeNorm();
    if (t2 === q) return this.state = F, void this.fail("XML declaration is incomplete.");
    S(t2) || (G(t2) ? this.q = t2 : (this.fail("value must be quoted."), this.q = 32), this.state = 31);
  }
  sXMLDeclValue() {
    const t2 = this.captureTo([this.q, q]);
    if (t2 === q) return this.state = F, this.text = "", void this.fail("XML declaration is incomplete.");
    if (t2 === M) return;
    const e2 = this.text;
    switch (this.text = "", this.name) {
      case "version": {
        this.xmlDeclExpects = ["encoding", "standalone"];
        const t3 = e2;
        this.xmlDecl.version = t3, /^1\.[0-9]+$/.test(t3) ? this.opt.forceXMLVersion || this.setXMLVersion(t3) : this.fail("version number must match /^1\\.[0-9]+$/.");
        break;
      }
      case "encoding":
        /^[A-Za-z][A-Za-z0-9._-]*$/.test(e2) || this.fail("encoding value must match /^[A-Za-z0-9][A-Za-z0-9._-]*$/."), this.xmlDeclExpects = ["standalone"], this.xmlDecl.encoding = e2;
        break;
      case "standalone":
        "yes" !== e2 && "no" !== e2 && this.fail('standalone value must match "yes" or "no".'), this.xmlDeclExpects = [], this.xmlDecl.standalone = e2;
    }
    this.name = "", this.state = 32;
  }
  sXMLDeclSeparator() {
    const t2 = this.getCodeNorm();
    t2 !== q ? (S(t2) || (this.fail("whitespace required."), this.unGet()), this.state = 27) : this.state = F;
  }
  sXMLDeclEnding() {
    this.getCodeNorm() === _ ? ("xml" !== this.piTarget ? this.fail("processing instructions are not allowed before root.") : "version" !== this.name && this.xmlDeclExpects.includes("version") && this.fail("XML declaration must contain a version."), this.xmlDeclHandler?.(this.xmlDecl), this.name = "", this.piTarget = this.text = "", this.state = H) : this.fail("The character ? is disallowed anywhere in XML declarations."), this.xmlDeclPossible = false;
  }
  sOpenTag() {
    const t2 = this.captureNameChars();
    if (t2 === M) return;
    const e2 = this.tag = { name: this.name, attributes: /* @__PURE__ */ Object.create(null) };
    switch (this.name = "", this.xmlnsOpt && (this.topNS = e2.ns = /* @__PURE__ */ Object.create(null)), this.openTagStartHandler?.(e2), this.sawRoot = true, !this.fragmentOpt && this.closedRoot && this.fail("documents may contain only one root."), t2) {
      case _:
        this.openTag();
        break;
      case 47:
        this.state = 35;
        break;
      default:
        S(t2) || this.fail("disallowed character in tag name."), this.state = 36;
    }
  }
  sOpenTagSlash() {
    this.getCode() === _ ? this.openSelfClosingTag() : (this.fail("forward-slash in opening tag not followed by >."), this.state = 36);
  }
  sAttrib() {
    const t2 = this.skipSpaces();
    t2 !== M && (k(t2) ? (this.unGet(), this.state = 37) : t2 === _ ? this.openTag() : 47 === t2 ? this.state = 35 : this.fail("disallowed character in attribute name."));
  }
  sAttribName() {
    const t2 = this.captureNameChars();
    t2 === W ? this.state = 39 : S(t2) ? this.state = 38 : t2 === _ ? (this.fail("attribute without value."), this.pushAttrib(this.name, this.name), this.name = this.text = "", this.openTag()) : t2 !== M && this.fail("disallowed character in attribute name.");
  }
  sAttribNameSawWhite() {
    const t2 = this.skipSpaces();
    switch (t2) {
      case M:
        return;
      case W:
        this.state = 39;
        break;
      default:
        this.fail("attribute without value."), this.text = "", this.name = "", t2 === _ ? this.openTag() : k(t2) ? (this.unGet(), this.state = 37) : (this.fail("disallowed character in attribute name."), this.state = 36);
    }
  }
  sAttribValue() {
    const t2 = this.getCodeNorm();
    G(t2) ? (this.q = t2, this.state = 40) : S(t2) || (this.fail("unquoted attribute value."), this.state = 42, this.unGet());
  }
  sAttribValueQuoted() {
    const { q: t2, chunk: e2 } = this;
    let { i: s2 } = this;
    for (; ; ) switch (this.getCode()) {
      case t2:
        return this.pushAttrib(this.name, this.text + e2.slice(s2, this.prevI)), this.name = this.text = "", this.q = null, void (this.state = 41);
      case 38:
        return this.text += e2.slice(s2, this.prevI), this.state = 14, void (this.entityReturnState = 40);
      case X:
      case j:
      case 9:
        this.text += `${e2.slice(s2, this.prevI)} `, s2 = this.i;
        break;
      case B:
        return this.text += e2.slice(s2, this.prevI), void this.fail("disallowed character.");
      case M:
        return void (this.text += e2.slice(s2));
    }
  }
  sAttribValueClosed() {
    const t2 = this.getCodeNorm();
    S(t2) ? this.state = 36 : t2 === _ ? this.openTag() : 47 === t2 ? this.state = 35 : k(t2) ? (this.fail("no whitespace between attributes."), this.unGet(), this.state = 37) : this.fail("disallowed character in attribute name.");
  }
  sAttribValueUnquoted() {
    const t2 = this.captureTo(K);
    switch (t2) {
      case 38:
        this.state = 14, this.entityReturnState = 42;
        break;
      case B:
        this.fail("disallowed character.");
        break;
      case M:
        break;
      default:
        this.text.includes("]]>") && this.fail('the string "]]>" is disallowed in char data.'), this.pushAttrib(this.name, this.text), this.name = this.text = "", t2 === _ ? this.openTag() : this.state = 36;
    }
  }
  sCloseTag() {
    const t2 = this.captureNameChars();
    t2 === _ ? this.closeTag() : S(t2) ? this.state = 44 : t2 !== M && this.fail("disallowed character in closing tag.");
  }
  sCloseTagSawWhite() {
    switch (this.skipSpaces()) {
      case _:
        this.closeTag();
        break;
      case M:
        break;
      default:
        this.fail("disallowed character in closing tag.");
    }
  }
  handleTextInRoot() {
    let { i: t2, forbiddenState: e2 } = this;
    const { chunk: s2, textHandler: i2 } = this;
    t: for (; ; ) switch (this.getCode()) {
      case B:
        if (this.state = 15, void 0 !== i2) {
          const { text: e3 } = this, o2 = s2.slice(t2, this.prevI);
          0 !== e3.length ? (i2(e3 + o2), this.text = "") : 0 !== o2.length && i2(o2);
        }
        e2 = 0;
        break t;
      case 38:
        this.state = 14, this.entityReturnState = H, void 0 !== i2 && (this.text += s2.slice(t2, this.prevI)), e2 = 0;
        break t;
      case z:
        switch (e2) {
          case 0:
            e2 = 1;
            break;
          case 1:
            e2 = 2;
            break;
          case 2:
            break;
          default:
            throw new Error("impossible state");
        }
        break;
      case _:
        2 === e2 && this.fail('the string "]]>" is disallowed in char data.'), e2 = 0;
        break;
      case j:
        void 0 !== i2 && (this.text += `${s2.slice(t2, this.prevI)}
`), t2 = this.i, e2 = 0;
        break;
      case M:
        void 0 !== i2 && (this.text += s2.slice(t2));
        break t;
      default:
        e2 = 0;
    }
    this.forbiddenState = e2;
  }
  handleTextOutsideRoot() {
    let { i: t2 } = this;
    const { chunk: e2, textHandler: s2 } = this;
    let i2 = false;
    t: for (; ; ) {
      const o2 = this.getCode();
      switch (o2) {
        case B:
          if (this.state = 15, void 0 !== s2) {
            const { text: i3 } = this, o3 = e2.slice(t2, this.prevI);
            0 !== i3.length ? (s2(i3 + o3), this.text = "") : 0 !== o3.length && s2(o3);
          }
          break t;
        case 38:
          this.state = 14, this.entityReturnState = H, void 0 !== s2 && (this.text += e2.slice(t2, this.prevI)), i2 = true;
          break t;
        case j:
          void 0 !== s2 && (this.text += `${e2.slice(t2, this.prevI)}
`), t2 = this.i;
          break;
        case M:
          void 0 !== s2 && (this.text += e2.slice(t2));
          break t;
        default:
          S(o2) || (i2 = true);
      }
    }
    i2 && (this.sawRoot || this.reportedTextBeforeRoot || (this.fail("text data outside of root node."), this.reportedTextBeforeRoot = true), this.closedRoot && !this.reportedTextAfterRoot && (this.fail("text data outside of root node."), this.reportedTextAfterRoot = true));
  }
  pushAttribNS(t2, e2) {
    const { prefix: s2, local: i2 } = this.qName(t2), o2 = { name: t2, prefix: s2, local: i2, value: e2 };
    if (this.attribList.push(o2), this.attributeHandler?.(o2), "xmlns" === s2) {
      const t3 = e2.trim();
      "1.0" === this.currentXMLVersion && "" === t3 && this.fail("invalid attempt to undefine prefix in XML 1.0"), this.topNS[i2] = t3, Y(this, i2, t3);
    } else if ("xmlns" === t2) {
      const t3 = e2.trim();
      this.topNS[""] = t3, Y(this, "", t3);
    }
  }
  pushAttribPlain(t2, e2) {
    const s2 = { name: t2, value: e2 };
    this.attribList.push(s2), this.attributeHandler?.(s2);
  }
  end() {
    this.sawRoot || this.fail("document must contain a root element.");
    const { tags: t2 } = this;
    for (; t2.length > 0; ) {
      const e3 = t2.pop();
      this.fail(`unclosed tag: ${e3.name}`);
    }
    0 !== this.state && this.state !== H && this.fail("unexpected end.");
    const { text: e2 } = this;
    return 0 !== e2.length && (this.textHandler?.(e2), this.text = ""), this._closed = true, this.endHandler?.(), this._init(), this;
  }
  resolve(t2) {
    let e2 = this.topNS[t2];
    if (void 0 !== e2) return e2;
    const { tags: s2 } = this;
    for (let i2 = s2.length - 1; i2 >= 0; i2--) if (e2 = s2[i2].ns[t2], void 0 !== e2) return e2;
    return e2 = this.ns[t2], void 0 !== e2 ? e2 : this.opt.resolvePrefix?.(t2);
  }
  qName(t2) {
    const e2 = t2.indexOf(":");
    if (-1 === e2) return { prefix: "", local: t2 };
    const s2 = t2.slice(e2 + 1), i2 = t2.slice(0, e2);
    return ("" === i2 || "" === s2 || s2.includes(":")) && this.fail(`malformed name: ${t2}.`), { prefix: i2, local: s2 };
  }
  processAttribsNS() {
    const { attribList: t2 } = this, e2 = this.tag;
    {
      const { prefix: t3, local: s3 } = this.qName(e2.name);
      e2.prefix = t3, e2.local = s3;
      const i3 = e2.uri = this.resolve(t3) ?? "";
      "" !== t3 && ("xmlns" === t3 && this.fail('tags may not have "xmlns" as prefix.'), "" === i3 && (this.fail(`unbound namespace prefix: ${JSON.stringify(t3)}.`), e2.uri = t3));
    }
    if (0 === t2.length) return;
    const { attributes: s2 } = e2, i2 = /* @__PURE__ */ new Set();
    for (const e3 of t2) {
      const { name: t3, prefix: o2, local: r2 } = e3;
      let n2, a2;
      "" === o2 ? (n2 = "xmlns" === t3 ? L : "", a2 = t3) : (n2 = this.resolve(o2), void 0 === n2 && (this.fail(`unbound namespace prefix: ${JSON.stringify(o2)}.`), n2 = o2), a2 = `{${n2}}${r2}`), i2.has(a2) && this.fail(`duplicate attribute: ${a2}.`), i2.add(a2), e3.uri = n2, s2[t3] = e3;
    }
    this.attribList = [];
  }
  processAttribsPlain() {
    const { attribList: t2 } = this, e2 = this.tag.attributes;
    for (const { name: s2, value: i2 } of t2) void 0 !== e2[s2] && this.fail(`duplicate attribute: ${s2}.`), e2[s2] = i2;
    this.attribList = [];
  }
  openTag() {
    this.processAttribs();
    const { tags: t2 } = this, e2 = this.tag;
    e2.isSelfClosing = false, this.openTagHandler?.(e2), t2.push(e2), this.state = H, this.name = "";
  }
  openSelfClosingTag() {
    this.processAttribs();
    const { tags: t2 } = this, e2 = this.tag;
    e2.isSelfClosing = true, this.openTagHandler?.(e2), this.closeTagHandler?.(e2);
    null === (this.tag = t2[t2.length - 1] ?? null) && (this.closedRoot = true), this.state = H, this.name = "";
  }
  closeTag() {
    const { tags: t2, name: e2 } = this;
    if (this.state = H, this.name = "", "" === e2) return this.fail("weird empty close tag."), void (this.text += "</>");
    const s2 = this.closeTagHandler;
    let i2 = t2.length;
    for (; i2-- > 0; ) {
      const i3 = this.tag = t2.pop();
      if (this.topNS = i3.ns, s2?.(i3), i3.name === e2) break;
      this.fail(`unexpected close tag: ${e2}.`);
    }
    0 === i2 ? this.closedRoot = true : i2 < 0 && (this.fail(`unmatched closing tag: ${e2}.`), this.text += `</${e2}>`);
  }
  parseEntity(t2) {
    if ("#" !== t2[0]) {
      const e3 = this.ENTITIES[t2];
      return void 0 !== e3 ? e3 : (this.fail(this.isName(t2) ? "undefined entity." : "disallowed character in entity name."), `&${t2};`);
    }
    let e2 = NaN;
    return "x" === t2[1] && /^#x[0-9a-f]+$/i.test(t2) ? e2 = parseInt(t2.slice(2), 16) : /^#[0-9]+$/.test(t2) && (e2 = parseInt(t2.slice(1), 10)), this.isChar(e2) ? String.fromCodePoint(e2) : (this.fail("malformed character entity."), `&${t2};`);
  }
}
var ot, rt;
(rt = ot || (ot = {})).Events = { XmlDecl: "xmldecl", Text: "text", ProcessingInstruction: "processinginstruction", Doctype: "doctype", Comment: "comment", OpenTagStart: "opentagstart", Attribute: "attribute", OpenTag: "opentag", CloseTag: "closetag", CDdata: "cdata", Error: "error", End: "end", Ready: "ready" }, rt.parseStream = async (t2, e2, s2) => {
  const i2 = new it({ position: false, ...s2 });
  let o2;
  if (e2.onOpenTagStart && i2.on(rt.Events.OpenTagStart, e2.onOpenTagStart), e2.onOpenTag && i2.on(rt.Events.OpenTag, e2.onOpenTag), e2.onCloseTag && i2.on(rt.Events.CloseTag, e2.onCloseTag), e2.onAttribute && i2.on(rt.Events.Attribute, e2.onAttribute), e2.onText && i2.on(rt.Events.Text, e2.onText), e2.onError && i2.on(rt.Events.Error, e2.onError), e2.onEnd) {
    e2.onEnd;
    const t3 = () => {
      o2 = e2.onEnd();
    };
    i2.on(rt.Events.End, t3);
  }
  for (; ; ) {
    const { value: e3, done: s3 } = await t2.read();
    if (s3) break;
    i2.write(e3);
  }
  return i2.close(), o2;
};
const nt = (t2) => true === t2 || "1" === t2 || "on" === t2 || "true" === t2 || false !== t2 && "0" !== t2 && "off" !== t2 && "false" !== t2 && null, at = (t2) => {
  const e2 = parseInt(t2);
  return isNaN(e2) ? null : e2;
}, lt = (t2) => {
  const e2 = parseFloat(t2);
  return isNaN(e2) ? null : e2;
}, ct = null;
class ht {
  constructor() {
    this._registeredVisitors = /* @__PURE__ */ new Map();
  }
  registerVisitor(t2) {
    this._registeredVisitors.set(t2.from, t2);
  }
  createEventHandler(t2, e2, s2) {
    const i2 = this._registeredVisitors, o2 = [];
    let r2 = null, n2 = null, a2 = null, l2 = null;
    const c2 = [], h2 = { key: null, source: t2 };
    let u2 = null, d2 = false;
    const p2 = (t3, e3) => {
      let s3 = a2.attributes[t3];
      if (e3) if (Array.isArray(e3)) for (let t4 = 0; t4 < e3.length; t4++) {
        if (null == s3) return;
        if (s3 = e3[t4](s3), null == s3) return;
      }
      else {
        if (null == s3) return;
        if (s3 = e3(s3), null == s3) return;
      }
      return s3;
    }, g2 = { getSource: () => u2.source, setSource: (t3) => {
      u2.source = t3;
    }, setKey: (t3) => {
      u2.key = t3;
    }, getFrom: () => a2, getAttribute: (t3, e3) => p2(t3, e3) ?? null, hasAttribute: (t3) => null !== g2.getAttribute(t3), getParent: () => c2[c2.length - 2].source, getPath: () => {
      const t3 = [];
      for (let e3 = 0; e3 < o2.length; e3++) t3.push(o2[e3].local);
      return t3.join("\\");
    }, parseAttribute: p2, copyToObject: (t3, e3, s3, i3) => {
      const o3 = p2(i3 ?? e3, s3);
      void 0 !== o3 && (t3[e3] = o3);
    }, copyTo: (t3, e3, s3) => {
      const i3 = p2(s3 ?? t3, e3);
      void 0 !== i3 && (u2.source[t3] = i3);
    }, warn: (t3) => {
      s2 ? s2?.(t3) : console.warn(t3);
    } };
    return { onOpenTag: (t3) => {
      let e3 = t3.name;
      const s3 = e3.indexOf(":");
      -1 !== s3 && (e3 = e3.slice(s3 + 1));
      const p3 = i2.get(e3);
      if (r2 = { local: e3, visitor: p3, tag: t3, destination: null }, d2) return o2.push(r2), n2 = e3, void (a2 = t3);
      l2 = r2?.visitor ?? null, p3 && (u2 = 0 === o2.length ? h2 : null !== l2?.to ? { key: null, source: {} } : null, r2.destination = u2, u2 && c2.push(u2)), o2.push(r2), n2 = e3, a2 = t3, d2 = null === l2?.to, l2?.openTag?.(g2);
    }, onCloseTag: (t3) => {
      let e3 = t3.name;
      const i3 = e3.indexOf(":");
      if (-1 !== i3 && (e3 = e3.slice(i3 + 1)), e3 !== n2) throw new Error(`mismatch open/close tag: '${e3}'/'${n2}'`);
      d2 || l2?.closeTag?.(g2);
      const p3 = o2.pop() ?? null;
      r2 = o2[o2.length - 1] ?? null;
      const f2 = p3?.destination;
      if (f2) {
        c2.pop(), u2 = c2[c2.length - 1] ?? h2;
        const t4 = p3.visitor;
        t4 && t4.to && void 0 !== f2.source && (Array.isArray(t4.to) ? u2.source.push ? u2.source.push(f2.source) : s2?.(`Unable to parse array for ${t4.from} at ${g2.getPath()}`) : f2.key ? u2.source[f2.key] = f2.source : "string" == typeof t4.to && (u2.source[t4.to] = f2.source));
      }
      n2 = r2?.local ?? null, a2 = r2?.tag ?? null, l2 = r2?.visitor ?? null, d2 = !r2?.destination;
    }, onText: (t3) => {
      l2?.text?.(t3, g2);
    }, onEnd: e2 };
  }
}
const ut = (t2, e2, s2, i2 = null) => {
  if (!t2) return null;
  let o2 = t2;
  o2.startsWith("/") && (o2 = o2.substring(1));
  let r2 = i2?.parsedRefs?.get(t2);
  if (void 0 !== r2) return r2;
  const n2 = e2(o2);
  if (!n2) return null;
  let a2 = n2.content;
  try {
    s2 && (a2 = s2(a2));
  } catch (t3) {
    console.warn(t3);
  }
  return i2?.parsedRefs?.set(t2, a2), a2;
}, dt = (t2, e2, s2, i2, o2 = null) => {
  if (!t2) return null;
  let r2 = t2;
  r2.startsWith("/") && (r2 = r2.substring(1));
  let n2 = o2?.parsedRefs?.get(t2);
  if (void 0 !== n2) return n2;
  const a2 = e2(r2);
  if (!a2) return null;
  const l2 = a2.content;
  try {
    const e3 = new TextDecoder().decode(l2), r3 = s2.parseFromString(e3, "text/xml"), n3 = i2.convert(r3, t2, o2);
    return o2?.parsedRefs?.set(t2, n3), n3;
  } catch (t3) {
    console.warn(t3);
  }
  return null;
}, pt = (t2, e2, s2, i2, o2 = null) => {
  const r2 = /* @__PURE__ */ new Map();
  let n2 = e2.Directory[t2];
  const a2 = n2 ? n2.length : 0;
  for (let t3 = 0; t3 < a2; t3++) {
    const a3 = n2[t3];
    if (!a3) continue;
    let l2 = a3;
    l2.startsWith("/") && (l2 = l2.substring(1));
    const c2 = dt(l2, (t4) => e2.files[t4], s2, i2, o2);
    r2.set(l2, c2);
  }
  return r2;
}, gt = async (t2, e2 = 8388608) => {
  await (async () => {
    if ("undefined" == typeof ReadableStream) if ("undefined" == typeof window) {
      const { ReadableStream: t3 } = await import("web-streams-polyfill");
      globalThis.ReadableStream = t3;
    } else console.warn("Browser does not support ReadableStream; consider loading a polyfill.");
  })();
  const s2 = new TextDecoder("utf-8");
  let i2 = 0;
  const o2 = t2 instanceof Uint8Array ? t2 : new Uint8Array(t2);
  return new ReadableStream({ pull(t3) {
    if (i2 >= o2.byteLength) return void t3.close();
    const r2 = o2.subarray(i2, Math.min(i2 + e2, o2.byteLength)), n2 = s2.decode(r2, { stream: i2 + e2 < o2.byteLength });
    t3.enqueue(n2), i2 += r2.length;
  } }).getReader();
}, ft = ["lt1", "dk1", "lt2", "dk2", "accent1", "accent2", "accent3", "accent4", "accent5", "accent6", "hlink", "folHlink"], mt = (t2, e2 = "dk1") => {
  let i2;
  const o2 = t2("auto");
  void 0 === o2 || "1" !== o2 && "true" !== o2 || (i2 = e2);
  const r2 = t2("indexed");
  r2 && (i2 = `index${r2}`);
  const n2 = t2("rgb");
  n2 && (i2 = n2.toLowerCase(), 8 !== n2.length || n2.startsWith("FF") || (i2 = "FF" + n2.substring(2, n2.length)));
  const a2 = t2("theme");
  a2 && (i2 = ft[a2]);
  let l2 = t2("tint");
  if (l2 && (i2 += ` ${s.AdjustmentType.ETint} ${parseFloat(l2)}`), i2) return i2;
}, Tt = (t2) => {
  if (!t2) return t2;
  return t2.replace(/^\{([\s\S]+)\}$/, "$1");
}, yt = (t2) => t2 ? g.roundAccurately(parseFloat(t2) / 12700, 4) : null, bt = (t2) => t2 ? g.roundAccurately(parseFloat(t2) / 9525, 1) : null, xt = (t2) => parseFloat(t2) / 1e3, wt = (t2) => parseFloat(t2) / 6e4, vt = (t2) => "true" === t2 || "1" === t2;
class St {
  static {
    this.Collapsed = 1;
  }
  static {
    this.CustomFormat = 2;
  }
  static {
    this.CustomHeight = 4;
  }
  static {
    this.Hidden = 8;
  }
  static {
    this.Ht = 16;
  }
  static {
    this.OutlineLevel = 32;
  }
  static {
    this.Ph = 64;
  }
  static {
    this.R = 128;
  }
  static {
    this.S = 256;
  }
  static {
    this.Spans = 512;
  }
  static {
    this.ThickBot = 1024;
  }
  static {
    this.ThickTop = 2048;
  }
}
const Ct = (t2, e2, s2) => {
  if (t2[0].value[0] === t2[1].value[0]) return e2;
}, kt = { colStart: 0, colEnd: 0, rowStart: 0, rowEnd: 0 }, At = (t2, s2, i2, o2, c2, h2, u2) => {
  let d2 = false, p2 = false, g2 = [], f2 = false, m2 = null, T2 = null, y2 = null, b2 = null, x2 = null, w2 = null;
  const v2 = u2?.get("richData") ?? [], S2 = r.normalizeA1ToR1C1, C2 = n.createConflatingRanges(), k2 = /* @__PURE__ */ new Map(), A2 = [];
  let D2 = null;
  const E2 = n.createConflatingRanges();
  let P2, O2 = false, I2 = -1, V2 = -1, N2 = null, L2 = null;
  const R2 = [];
  let $2 = null, M2 = -2, j2 = 0, H2 = "", F2 = "", X2 = "", B2 = "", W2 = "", _2 = "", q2 = "", z2 = "", G2 = "", U2 = "", Z2 = "", Q2 = "", J2 = "", K2 = "", Y2 = true, tt2 = null, et2 = false, st2 = false, it2 = null, ot2 = 0;
  return { ...i2, onEnd: () => {
    R2.length > 0 && (s2.rows = R2);
    let e2 = C2.done(Ct);
    const o3 = e2.length;
    if (o3 > 0) {
      const t3 = new Array(o3);
      for (let s3 = 0; s3 < o3; s3++) {
        const i3 = e2[s3], o4 = r.rangeToString(i3), n2 = i3.value[1], a2 = r.resolveRelativeToA1(n2, i3.rowStart, i3.colStart);
        t3[s3] = [o4, a2];
      }
      s2.formulas = t3;
    }
    const l2 = E2.done(true), c3 = l2.length;
    if (c3 > 0) {
      const t3 = new Array(c3);
      for (let e3 = 0; e3 < c3; e3++) {
        const s3 = l2[e3], i3 = r.rangeToString(s3);
        t3[e3] = i3;
      }
      s2.volatile = t3;
    }
    if (A2.length > 0 && (s2.dynamicArray = [...A2]), g2.length > 0) {
      g2.sort(n.createRangeComparator(a.Orientation.Column));
      const t3 = [];
      let e3 = null, i3 = -1, o4 = -1, r2 = -1, l3 = -1, c4 = null;
      const h4 = g2.length;
      h4 > 0 && (e3 = g2[0], i3 = e3.colStart, o4 = e3.colEnd, r2 = e3.rowEnd, l3 = e3.value, t3.push(e3));
      for (let s3 = 1; s3 < h4; s3++) c4 = g2[s3], l3 !== c4.value || i3 !== c4.colStart || o4 !== c4.colEnd || r2 + 1 !== c4.rowEnd ? (t3.push(c4), e3 = c4, i3 = e3.colStart, o4 = e3.colEnd, r2 = e3.rowEnd, l3 = e3.value) : (r2 = c4.rowEnd, e3.rowEnd = r2);
      let u3 = [];
      for (let e4 = 0; e4 < t3.length; e4++) {
        const s3 = t3[e4];
        u3.push({ r: { colStart: s3.colStart, colEnd: s3.colEnd, rowStart: s3.rowStart, rowEnd: s3.rowEnd }, v: s3.value });
      }
      s2.directStyles = u3;
    }
    const h3 = t2.build();
    if (h3) {
      const t3 = h3.tuples;
      s2.data = t3;
    }
    i2?.onEnd?.();
  }, onOpenTag: (t3) => {
    let e2 = t3.name;
    const o3 = e2.indexOf(":");
    if (-1 !== o3 && (e2 = e2.slice(o3 + 1)), ot2++, ot2 % 196608 == 0 && c2(ot2), P2) {
      const s3 = t3.attributes;
      switch (e2) {
        case "v":
          p2 = true;
          break;
        case "f":
          switch (s3.t ?? null) {
            case null:
            case "normal":
              f2 = true;
              break;
            case "shared":
              const t4 = s3.si;
              T2 = s3.ref, m2 = t4;
              break;
            case "array":
              f2 = true, T2 = s3.ref, D2 = [T2, false];
              break;
            case "datatable":
              f2 = true, T2 = s3.ref, f2 = true;
          }
          void 0 !== s3.ca && E2.append(I2, V2);
          break;
        case "is":
          return void (O2 = true);
      }
      return void (O2 && h2?.onOpenTag(t3));
    }
    if (d2) {
      if ("c" === e2) {
        P2 = t3;
        const e3 = t3.attributes.r;
        V2 = r.fastStringToCol(e3);
        const s3 = t3.attributes.t;
        void 0 === s3 ? L2 = null : (L2 = s3, "str" === L2 && (O2 = true));
        let i3 = t3.attributes.s;
        void 0 === i3 && (null !== it2 || st2) && (i3 = "0"), void 0 !== i3 && (i3 = parseInt(i3), tt2 && tt2.value === i3 && tt2.colEnd + 1 === V2 ? tt2.colEnd = V2 : (tt2 = { colStart: V2, rowStart: I2, colEnd: V2, rowEnd: I2, value: i3 }, g2.push(tt2)));
      }
    } else {
      if ("row" === e2) {
        d2 = true;
        const e3 = t3.attributes.r;
        if (I2 = parseInt(e3) - 1, j2 = 0, F2 = t3.attributes.customHeight, void 0 !== F2 && (j2 |= St.CustomHeight), F2 !== G2 && (Y2 = true, G2 = F2), H2 = t3.attributes.ht, void 0 !== H2 && (j2 |= St.Ht), H2 !== z2 && (Y2 = true, z2 = H2), X2 = t3.attributes.hidden, void 0 !== X2 && (j2 |= St.Hidden), X2 !== U2 && (Y2 = true, U2 = X2), W2 = t3.attributes.s, void 0 !== W2 && (j2 |= St.S), W2 !== Q2 && (Y2 = true, Q2 = W2), B2 = t3.attributes.customFormat, void 0 !== B2 && (j2 |= St.CustomFormat), B2 !== Z2 && (Y2 = true, Z2 = B2), _2 = t3.attributes.outlineLevel, void 0 !== _2 && (j2 |= St.OutlineLevel), _2 !== J2 && (Y2 = true, J2 = _2), q2 = t3.attributes.collapsed, void 0 !== q2 && (j2 |= St.Collapsed), q2 !== K2 && (Y2 = true, K2 = q2), 0 !== j2) if (M2 + 1 !== I2 || Y2) {
          const t4 = void 0 !== F2 && ("1" === F2 || "true" === F2);
          it2 = void 0 !== B2 && ("1" === B2 || "true" === B2) && void 0 !== W2 ? W2 : null, $2 = { min: I2, max: I2, sz: void 0 === H2 ? -1 : parseFloat(H2), csz: t4, h: void 0 !== X2 && ("1" === X2 || "true" === X2), s: null === it2 ? void 0 : "0" === it2 ? 0 : parseInt(it2), l: void 0 === _2 || "0" === _2 ? 0 : parseInt(_2), cl: void 0 !== q2 && ("1" === q2 || "true" === q2) }, R2.push($2);
        } else $2.max = I2;
        return M2 = I2, void (Y2 = false);
      }
      if (!et2 && "sheetData" === e2) {
        et2 = true;
        const t4 = s2.cols, e3 = t4 ? t4.length : 0;
        for (let s3 = 0; !st2 && s3 < e3; s3++) {
          t4[s3].s && (st2 = true);
        }
      }
      i2?.onOpenTag(t3);
    }
  }, onCloseTag: (e2) => {
    if (P2) {
      let s3 = e2.name;
      const i3 = s3.indexOf(":");
      if (-1 !== i3 && (s3 = s3.slice(i3 + 1)), O2) if ("is" === s3 || "v" === s3) {
        const e3 = h2?.onEnd();
        null !== e3 && t2.addValue(I2, V2, "" + e3);
      } else h2?.onCloseTag?.(e2);
      return p2 && (p2 = false), void ("c" === s3 && (P2 = null, O2 = false));
    }
    if (d2) return d2 = false, void (tt2 = null);
    i2?.onCloseTag(e2);
  }, onText: (s3) => {
    if (s3 = s3.trim(), p2) {
      switch (N2 = null, L2) {
        case null:
        case "n":
          N2 = parseFloat(s3);
          break;
        case "b":
          N2 = "1" === s3 || "true" === s3;
          break;
        case "s":
          N2 = s3;
          break;
        case "e":
          if ("#VALUE!" === s3) {
            const t4 = P2.attributes.vm;
            if (void 0 !== t4) {
              const s4 = v2[parseInt(t4) - 1];
              if (s4 && s4.isFormulaError) {
                N2 = { t: e.Error, v: s4.getCode() };
                break;
              }
            }
          }
          const t3 = l.getBuiltInByLabel(s3);
          t3 ? N2 = { t: e.Error, v: t3.getCode() } : (N2 = s3, o2?.(`Unknown formula error '${s3}' in cell ${r.cellToString({ colIndex: V2, rowIndex: I2 })}`));
          break;
        case "str":
        case "inlineStr":
          O2 = true;
      }
      null !== N2 && t2.addValue(I2, V2, N2);
    }
    if (D2 && ("e" === L2 && (D2[1] = true), A2.push(D2), D2 = null), m2) if (x2 === m2) b2 = w2;
    else {
      if (b2 = k2.get(m2), !b2) {
        const t3 = [];
        y2 = S2(s3, I2, V2, t3), b2 = [y2, t3, s3], k2.set(m2, b2);
      }
      x2 = m2, w2 = b2;
    }
    if (f2) {
      const t3 = [];
      y2 = S2(s3, I2, V2, t3), b2 = [y2, t3, s3];
    }
    if (b2) return C2.append(I2, V2, b2), b2 = null, f2 = false, m2 = null, void (T2 = null);
    O2 ? h2?.onText(s3) : d2 || i2?.onText(s3);
  } };
}, Dt = Object.freeze(Object.defineProperty({ __proto__: null, readBufferXLSX: async (t2, e2) => {
  const { password: s2, createWorkbookOptions: n2 = {}, ...a2 } = e2 ?? {}, l2 = [], m2 = e2?.progress, T2 = m2?.onProgress;
  let y2 = 0;
  const b2 = import("xlsx"), x2 = import("./HvcdKjWsnxE2cGeB.mjs");
  let w2 = null;
  try {
    w2 = new DOMParser();
  } catch (t3) {
  }
  let v2 = null;
  w2 || (v2 = import("@xmldom/xmldom"));
  let S2 = null, C2 = null, k2 = null;
  try {
    const t3 = await Promise.all([b2, x2, v2]);
    S2 = t3[0], C2 = t3[1], k2 = t3[2];
  } catch (t3) {
    throw new Error("Unable to load XLSX parser.", { cause: t3 });
  }
  try {
    const e3 = S2.read(t2, { type: "array", sheets: [], cellStyles: false, bookFiles: true });
    if (!e3.Directory) throw new f("Unable to parse as an Excel document. Try to save as '.xlsx' and try again.");
    e3.Directory.richstructure = ["/xl/richData/rdrichvaluestructure.xml"], e3.Directory.richdata = ["/xl/richData/rdrichvalue.xml"];
    const s3 = new C2.FromOOXMLConverter(), a3 = w2 ?? new k2.DOMParser(), p2 = n2?.resources ?? new c(), b3 = p2.beginPersist(), x3 = {}, v3 = /* @__PURE__ */ new Set(), A2 = /* @__PURE__ */ new Map();
    A2.set("richTypes", []);
    const D2 = /* @__PURE__ */ new Map(), E2 = [], P2 = (t3) => e3.files[t3], O2 = (t3, e4) => {
      const i2 = t3.lastIndexOf("/"), o2 = t3.substring(0, i2 + 1) + "_rels/" + t3.substring(i2 + 1, t3.length) + ".rels";
      let r2 = e4.get(o2);
      return r2 || (r2 = ((t4, e5, s4, i3, o3 = null) => {
        if (!t4) return null;
        const r3 = dt(t4, e5, s4, i3, o3);
        if (!r3) return null;
        const n3 = /* @__PURE__ */ new Map(), a4 = Object.keys(r3), l3 = a4.length;
        for (let t5 = 0; t5 < l3; t5++) {
          const e6 = a4[t5], s5 = r3[e6];
          n3.set(e6, s5);
        }
        return n3;
      })(o2, P2, a3, s3, V2), e4.set(o2, r2)), r2;
    }, I2 = (t3, e4, n3, c2 = D2) => {
      let h2 = O2(e4, c2).get(t3), u2 = h2?.target;
      if (!u2) return null;
      if ("External" === h2.targetMode) return h2.target;
      const d2 = e4.lastIndexOf("/"), f2 = e4.substring(0, d2 + 1);
      u2.startsWith("/") || (u2 = f2 + u2), u2 = ((t4) => {
        const e5 = t4.split(/\/+/);
        return e5.reduce((t5, e6, s4) => ("." === e6 ? t5.splice(s4, 1) : ".." === e6 && t5.splice(s4 - 1, 2), t5), e5).join("/");
      })(u2);
      const m3 = s3?.getVisitorParamsState().get("dxfs");
      let w3 = c2.get(u2);
      if (!w3) {
        const t4 = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet";
        if (h2.type === t4) {
          const t5 = {};
          w3 = t5;
          const e5 = async () => {
            const e6 = ((t6, e7, s5, n5, a5, l3, c3, h4) => {
              const u3 = new ht(), d4 = new i.TransposedBuilder();
              let p3 = null;
              u3.registerVisitor({ from: "autoFilter", to: "filter", openTag: (t7) => {
                t7.copyTo("ref", ct);
              } }), u3.registerVisitor({ from: "conditionalFormatting", to: {}, openTag: (t7) => {
                const e8 = t7.getParent();
                e8.conditionals || (e8.conditionals = []), e8.conditionals.push(t7.getSource());
                const s6 = t7.getAttribute("sqref");
                s6 && (t7.getSource().ref = s6.split(" ").join(",")), t7.copyTo("pivot", nt);
              }, closeTag: (t7) => {
                const e8 = t7.getSource();
                if (e8.rule) {
                  const t8 = Object.keys(e8.rule);
                  for (let s6 = 0; s6 < t8.length; s6++) {
                    const i2 = t8[s6];
                    "rule" !== i2 && (e8[i2] = e8.rule[i2]);
                  }
                }
                delete e8.rule;
              } }), u3.registerVisitor({ from: "cfRule", to: "rule", openTag: (t7) => {
                const e8 = t7.getParent();
                t7.copyToObject(e8, "type", ct), t7.copyToObject(e8, "priority", at), t7.copyToObject(e8, "stopIfTrue", nt);
                const s6 = t7.getAttribute("dxfId", at);
                if (null !== s6) {
                  let i2 = n5?.get(s6);
                  i2 || (l3?.(`Unable to load conditional color. Invalid dxfI: '${s6}' at '${t7.getPath()}'.`), i2 = {}), e8.style = i2;
                }
                t7.copyToObject(e8, "aboveAverage", nt), t7.copyToObject(e8, "equalAverage", nt), t7.copyToObject(e8, "stdDev", at), t7.copyToObject(e8, "bottom", nt), t7.copyToObject(e8, "percent", nt), t7.copyToObject(e8, "rank", at), t7.copyToObject(e8, "operator", ct), t7.copyToObject(e8, "text", ct), t7.copyToObject(e8, "timePeriod", ct);
              } }), u3.registerVisitor({ from: "colorScale", to: "colorScale" }), u3.registerVisitor({ from: "dataBar", to: "dataBar", openTag: (t7) => {
                t7.copyTo("maxLength", at), t7.copyTo("minLength", at), t7.copyTo("showValue", nt);
              } }), u3.registerVisitor({ from: "iconSet", to: "iconSet", openTag: (t7) => {
                t7.copyTo("iconSet", ct), t7.copyTo("reverse", nt), t7.copyTo("showValue", nt);
              } }), u3.registerVisitor({ from: "formula", to: null, text: (t7, e8) => {
                const s6 = e8.getParent();
                let i2 = s6.formulas;
                i2 || (i2 = [], s6.formulas = i2), i2.push(t7);
              } }), u3.registerVisitor({ from: "cfvo", to: {}, openTag: (t7) => {
                const e8 = t7.getParent();
                e8.conditions || (e8.conditions = []), e8.conditions.push(t7.getSource()), t7.copyTo("type", ct), t7.copyTo("value", lt, "val"), t7.copyTo("gte", nt);
              } }), u3.registerVisitor({ from: "color", to: {}, openTag: (t7) => {
                const e8 = t7.getParent();
                e8.colors || (e8.colors = []);
                const s6 = mt((e9) => t7.getAttribute(e9));
                e8.colors.push(s6);
              } }), u3.registerVisitor({ from: "filterColumn", to: "filterColumn", openTag: (t7) => {
                const e8 = t7.getParent();
                e8.fields || (e8.fields = []), e8.fields.push(t7.getSource()), t7.copyTo("offset", at, "colId"), t7.copyTo("hiddenButton", nt), t7.copyTo("showButton", nt);
              } }), u3.registerVisitor({ from: "colorFilter", to: "colorFilter", openTag: (t7) => {
                const e8 = t7.getParent();
                e8.criteria || (e8.criteria = []), e8.criteria.push(t7.getSource()), t7.getSource().type = o.Type.Color, t7.copyTo("cellColor", nt), t7.copyTo("styleId", at, "dxfId");
              } }), u3.registerVisitor({ from: "dynamicFilter", to: "dynamicFilter", openTag: (t7) => {
                const e8 = t7.getParent();
                e8.criteria || (e8.criteria = []), e8.criteria.push(t7.getSource()), t7.getSource().type = o.Type.Dynamic, t7.copyTo("dynamicType", ct, "type"), t7.copyTo("val", lt), t7.copyTo("maxVal", lt, "maxVal");
              } }), u3.registerVisitor({ from: "iconFilter", to: "iconFilter", openTag: (t7) => {
                const e8 = t7.getParent();
                e8.criteria || (e8.criteria = []), e8.criteria.push(t7.getSource()), t7.getSource().type = o.Type.Icon, t7.copyTo("iconId", at), t7.copyTo("iconSet", ct);
              } }), u3.registerVisitor({ from: "top10", to: "top10", openTag: (t7) => {
                const e8 = t7.getParent();
                e8.criteria || (e8.criteria = []), e8.criteria.push(t7.getSource()), t7.getSource().type = o.Type.Top10, t7.copyTo("filterVal", lt), t7.copyTo("percent", nt), t7.copyTo("top", nt), t7.copyTo("val", lt);
              } }), u3.registerVisitor({ from: "filters", to: "filters", openTag: (t7) => {
                const e8 = t7.getParent();
                e8.criteria || (e8.criteria = []), e8.criteria.push(t7.getSource()), t7.getSource().type = o.Type.Items, t7.copyTo("blank", nt), t7.copyTo("calendarType", ct);
              } }), u3.registerVisitor({ from: "dateGroupItem", to: "dateGroupItem", openTag: (t7) => {
                const e8 = t7.getParent();
                e8.dateGroups || (e8.dateGroups = []), e8.dateGroups.push(t7.getSource()), t7.copyTo("group", ct, "dateTimeGrouping"), t7.copyTo("day", at), t7.copyTo("hour", at), t7.copyTo("minute", at), t7.copyTo("month", at), t7.copyTo("second", at), t7.copyTo("year", at);
              } }), u3.registerVisitor({ from: "filter", to: "filter", openTag: (t7) => {
                const e8 = t7.getParent();
                e8.items || (e8.items = []), e8.items.push(t7.getAttribute("val", lt));
              } }), u3.registerVisitor({ from: "customFilters", to: "customFilters", openTag: (t7) => {
                const e8 = t7.getParent();
                e8.criteria || (e8.criteria = []), e8.criteria.push(t7.getSource()), t7.getSource().type = o.Type.Custom, t7.copyTo("and", nt);
              } }), u3.registerVisitor({ from: "customFilter", to: "customFilter", openTag: (t7) => {
                const e8 = t7.getParent();
                e8.filters || (e8.filters = []), e8.filters.push(t7.getSource()), t7.copyTo("operator", ct), t7.copyTo("value", lt, "val");
              } }), u3.registerVisitor({ from: "sortState", to: "sort", openTag: (t7) => {
                t7.copyTo("ref", ct);
              } }), u3.registerVisitor({ from: "sortCondition", to: "sortCondition", openTag: (t7) => {
                const e8 = t7.getParent();
                e8.fields || (e8.fields = []);
                const s6 = t7.getSource();
                e8.fields.push(s6), t7.copyTo("sortOn", ct, "sortBy"), t7.copyTo("dxfId", ct, "sortBy"), t7.copyTo("iconSet", ct), t7.copyTo("customList", ct);
                const i2 = t7.getAttribute("ref");
                if (i2) {
                  const t8 = r.fastStringToRange(i2, kt).colStart, o2 = r.fastStringToRange(e8.ref, kt), n6 = o2.colStart;
                  s6.offset = o2 ? t8 - n6 : t8;
                }
                s6.reverse = t7.getAttribute("descending", nt) ?? false;
              } }), u3.registerVisitor({ from: "AlternateContent", to: null });
              const g2 = (t7) => {
                p3 = t7.getSource(), t7.copyTo("topLeft", ct, "topLeftCell");
                const e8 = vt(t7.getAttribute("defaultGridColor")), s6 = t7.getAttribute("colorId");
                null === s6 || e8 || (t7.getSource().gridLineColor = "index" + parseFloat(s6)), t7.copyTo("showZeros", nt), t7.copyTo("showFormulas", nt), t7.copyTo("zoomScale", at), t7.copyTo("showRowHeaders", nt, "showRowColHeaders"), t7.copyTo("showColumnHeaders", nt, "showRowColHeaders"), t7.copyTo("showRowGridlines", nt, "showGridLines"), t7.copyTo("showColumnGridlines", nt, "showGridLines");
              };
              u3.registerVisitor({ from: "sheetView", to: "view", openTag: (t7) => {
                g2(t7);
              }, closeTag: () => {
                p3 = null;
              } }), u3.registerVisitor({ from: "customSheetViews", to: "customSheetViews", openTag: (t7) => {
                t7.setSource([]);
              } }), u3.registerVisitor({ from: "customSheetView", to: [], openTag: (t7) => {
                g2(t7);
              }, closeTag: () => {
                p3 = null;
              } }), u3.registerVisitor({ from: "selection", to: "selection", openTag: (t7) => {
                if (!p3) return;
                t7.copyTo("cell", ct, "activeCell"), t7.copyTo("rangeIndex", at, "activeCellId");
                const e8 = t7.getAttribute("activeCell"), s6 = t7.getAttribute("sqref");
                s6 && s6 !== e8 && (t7.getSource().ranges = s6.split(" "));
              } }), u3.registerVisitor({ from: "pane", to: "pane", openTag: (t7) => {
                if (p3 && "frozen" === t7.getAttribute("state")) {
                  const e8 = {};
                  p3.freezePanes = e8, t7.copyToObject(e8, "topLeft", ct, "topLeftCell");
                  const s6 = p3.topLeft ? r.fastStringToCell(p3.topLeft) : { colIndex: 0, rowIndex: 0 }, i2 = { colIndex: 0, rowIndex: 0 };
                  t7.copyToObject(i2, "colIndex", at, "xSplit"), t7.copyToObject(i2, "rowIndex", at, "ySplit");
                  const o2 = { colIndex: s6.colIndex + i2.colIndex, rowIndex: s6.rowIndex + i2.rowIndex };
                  e8.coords = r.cellToString(o2);
                }
              } }), u3.registerVisitor({ from: "tabColor", to: null, openTag: (e8) => {
                const s6 = mt((t7) => e8.getAttribute(t7));
                s6 && (t6.tabColor = s6);
              } }), u3.registerVisitor({ from: "pageSetUpPr", to: "pageSetUpPr", openTag: (t7) => {
              } }), u3.registerVisitor({ from: "outlinePr", to: "outlinePr", openTag: (t7) => {
              } }), u3.registerVisitor({ from: "pageMargins", to: "pageMargins", openTag: (t7) => {
              } }), u3.registerVisitor({ from: "pageSetup", to: "pageSetup", openTag: (t7) => {
              } }), u3.registerVisitor({ from: "printOptions", to: "printOptions", openTag: (t7) => {
              } }), u3.registerVisitor({ from: "mergeCells", to: "merges", openTag: (t7) => {
                t7.setSource([]);
              } }), u3.registerVisitor({ from: "mergeCell", to: [], openTag: (t7) => {
                const e8 = t7.getAttribute("ref");
                t7.setSource(e8);
              } }), u3.registerVisitor({ from: "hyperlinks", to: "hyperlinks", openTag: (t7) => {
                t7.setSource([]);
              } }), u3.registerVisitor({ from: "hyperlink", to: [], openTag: (t7) => {
                const s6 = t7.getAttribute("r:id"), i2 = t7.getAttribute("ref");
                if (!i2) return void console.warn("No ref found for hyperlink");
                t7.setKey(i2);
                let o2 = s6 ? e7(s6) : "";
                if ("string" != typeof o2) return void console.warn("Invalid address ", o2);
                const r2 = t7.getAttribute("location");
                o2.endsWith("\\") && (o2 = o2.substring(0, o2.length - 1));
                const n6 = t7.getAttribute("location");
                if (n6 && (r2 && r2 !== n6 && console.warn("display and location are different", r2, n6), o2 += "#" + n6), !o2) return void console.warn("No address found for hyperlink. r:id", s6);
                let a6;
                const l4 = t7.getAttribute("tooltip");
                a6 = l4 ? { address: o2, tooltip: l4 } : o2, t7.setSource({ r: i2, v: a6 });
              } }), u3.registerVisitor({ from: "drawing", to: "movables", openTag: (t7) => {
                const s6 = t7.getAttribute("r:id");
                if (!s6) return;
                const i2 = e7(s6);
                i2 ? t7.setSource(i2.movables) : console.warn("no drawing found for rId", s6);
              } }), u3.registerVisitor({ from: "tableParts", to: "tables", openTag: (t7) => {
                t7.setSource([]);
              } }), u3.registerVisitor({ from: "tablePart", to: [], openTag: (t7) => {
                const s6 = t7.getAttribute("r:id");
                if (!s6) return;
                const i2 = e7(s6);
                i2 ? t7.setSource(i2) : console.warn("no table found for rId", s6);
              } }), u3.registerVisitor({ from: "worksheet", to: "worksheet", openTag: (t7) => {
              } }), u3.registerVisitor({ from: "sheetProtection", to: "protection", openTag: (t7) => {
                let e8 = false;
                if (t7.hasAttribute("sheet") && nt(t7.getAttribute("sheet")) && (e8 = true), !e8) return void t7.setSource(void 0);
                const s6 = (t8) => true === t8 || "1" === t8 || "on" === t8 || "true" === t8 || false === t8 || "0" === t8 || "off" === t8 || "false" === t8 || null;
                t7.copyTo("autoFilter", s6), t7.copyTo("deleteColumns", s6), t7.copyTo("formatCells", s6), t7.copyTo("formatColumns", s6), t7.copyTo("formatRows", s6), t7.copyTo("insertColumns", s6), t7.copyTo("insertHyperlinks", s6), t7.copyTo("insertRows", s6), t7.copyTo("objects", s6), t7.copyTo("pivotTables", s6), t7.copyTo("scenarios", s6), t7.copyTo("selectUnlockedCells", s6), t7.copyTo("selectUnlockedCells", s6), t7.copyTo("sort", s6);
                const i2 = {};
                t7.copyToObject(i2, "hash", ct, "hashValue"), t7.copyToObject(i2, "algorithm", ct, "algorithmName"), t7.copyToObject(i2, "salt", ct, "saltValue"), t7.copyToObject(i2, "spinCount", at), Object.keys(i2).length > 0 && (t7.getSource().password = i2);
              } }), u3.registerVisitor({ from: "protectedRanges", to: "protectedRanges", openTag: (t7) => {
                t7.setSource({});
              } }), u3.registerVisitor({ from: "protectedRange", to: {}, openTag: (t7) => {
                const e8 = t7.getAttribute("sqref");
                t7.setKey(e8), t7.copyTo("name"), t7.copyTo("securityDescriptor");
                const s6 = {};
                t7.copyToObject(s6, "hash", ct, "hashValue"), t7.copyToObject(s6, "algorithm", ct, "algorithmName"), t7.copyToObject(s6, "salt", ct, "saltValue"), t7.copyToObject(s6, "spinCount", at), Object.keys(s6).length > 0 && (t7.getSource().password = s6);
              } }), u3.registerVisitor({ from: "sheetFormatPr", to: "sheetFormatPr", openTag: (e8) => {
                e8.copyToObject(t6, "defaultColSize", lt, "defaultColWidth"), e8.copyToObject(t6, "outlineLevelCol", at, "outlineLevelCol");
                const s6 = e8.getAttribute("customHeight");
                "1" !== s6 && "true" !== s6 || e8.copyToObject(t6, "defaultRowSize", lt, "defaultRowHeight"), e8.copyToObject(t6, "outlineLevelRow", at, "outlineLevelRow");
              } }), u3.registerVisitor({ from: "cols", to: "cols", openTag: (t7) => {
                t7.setSource([]);
              } }), u3.registerVisitor({ from: "col", to: [], openTag: (t7) => {
                t7.copyTo("min", (t8) => parseInt(t8) - 1), t7.copyTo("max", (t8) => parseInt(t8) - 1), t7.copyTo("sz", lt, "width"), t7.copyTo("csz", nt, "customWidth"), t7.copyTo("h", nt, "hidden"), t7.copyTo("l", at, "outlineLevel"), t7.copyTo("s", at, "style");
              } }), u3.registerVisitor({ from: "oleObjects", to: null, openTag: (t7) => {
                t7.warn("'OLE Objects' are not supported.");
              } });
              let f3 = null;
              const m4 = { onOpenTag: (t7) => {
                null === f3 && (f3 = "");
              }, onText: (t7) => {
                f3 += t7;
              }, onEnd: () => {
                const t7 = s5(f3);
                return f3 = null, t7;
              }, onError: (t7) => {
              } };
              return At(d4, t6, u3.createEventHandler(t6, a5, l3), l3, c3, m4, h4);
            })(t5, (t6, e7 = false) => I2(t6, u2, e7) ?? null, j2, m3, () => {
            }, (t6, e7) => {
              e7 = e7 ? `${e7} (${u2})` : u2, l2.push([t6, e7]);
            }, (t6) => {
              y2 += t6, T2?.(y2);
            }, A2), s4 = ut(u2, P2), n4 = await gt(s4);
            try {
              await ot.parseStream(n4, e6, { xmlns: false });
            } catch (t6) {
              throw console.warn(`Error parsing sheet: '${u2}'`, t6), new Error(`Error parsing sheet: '${u2}'`, { cause: t6 });
            }
            const a4 = O2(u2, c2);
            let h3, d3 = /* @__PURE__ */ new Map();
            if (a4) {
              const e7 = "http://schemas.microsoft.com/office/2017/10/relationships/threadedComment";
              let s5;
              a4.forEach((t6, s6) => {
                if (t6.type === e7) {
                  const t7 = I2(s6, u2, false, c2);
                  h3 = t7?.comments, h3 && h3.forEach((t8) => {
                    d3.set(t8.id, t8);
                  });
                }
              });
              const i2 = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments";
              if (a4.forEach((t6, e8) => {
                if (t6.type === i2) {
                  const t7 = I2(e8, u2, false, c2);
                  s5 = t7;
                }
              }), s5 || h3) {
                const e8 = h3 ?? [], i3 = s5?.comments;
                if (i3) {
                  const t6 = s5?.authors, o2 = i3.length;
                  for (let s6 = 0; s6 < o2; s6++) {
                    const o3 = i3[s6];
                    if (!o3) continue;
                    let r2 = t6 && void 0 !== o3.authorId ? t6[o3.authorId] : o3.authorId;
                    if (r2 && r2.startsWith("tc=") && (r2 = Tt(r2.substring(3)), d3.has(r2))) continue;
                    let n5 = null;
                    r2 && (n5 = H2.get(r2)), n5 || (n5 = F2.get(r2)), n5 || (n5 = { id: g.uuidV4(), displayName: r2 }, F2.set(n5.displayName, n5), H2.set(n5.id, n5)), r2 = n5?.id ?? null;
                    const a5 = { id: g.uuidV4(), personId: r2, ref: o3.ref, done: false, asNote: true, content: o3.content };
                    e8.push(a5);
                  }
                }
                t5.comments = e8;
              }
            }
          };
          E2.push(e5());
        } else w3 = n3 ? ut(u2, P2, (t5) => {
          const e5 = p2.add({ buffer: t5 });
          return e5.addReference(x3), v3.add(e5), b3.toResourceId(e5);
        }, V2) : dt(u2, P2, a3, s3, V2);
      }
      return w3;
    }, V2 = { paramMap: A2, getRefs: O2, getRef: I2, parsedRefs: D2, addPerson: (t3) => null }, N2 = [];
    let L2 = 0;
    e3.Strings && (L2 = parseInt(e3.Strings.Unique ?? e3.Strings.length ?? 0));
    const R2 = e3.Strings ?? [];
    for (let t3 = 0; t3 < L2; t3++) N2.push(R2[t3]?.t ?? "");
    const $2 = /* @__PURE__ */ new Map();
    let M2 = L2;
    const j2 = (t3) => {
      const e4 = $2.get(t3);
      if (void 0 !== e4) return e4;
      const s4 = M2;
      return $2.set(t3, M2++), N2.push(t3), s4;
    }, H2 = (pt("richstructure", e3, a3, s3, V2), pt("richdata", e3, a3, s3, V2), /* @__PURE__ */ new Map()), F2 = /* @__PURE__ */ new Map(), X2 = pt("people", e3, a3, s3);
    let B2 = null;
    if (X2.size > 0 && (B2 = X2.entries().next()?.value?.[1]?.persons, B2)) {
      const t3 = B2.length;
      for (let e4 = 0; e4 < t3; e4++) {
        const t4 = B2[e4];
        H2.set(t4.id, t4), H2.set(t4.displayName, t4);
      }
    }
    const W2 = pt("themes", e3, a3, s3, V2);
    let _2 = null;
    if (W2 && W2.entries) {
      let t3 = W2.entries().next();
      t3?.value?.[1] && (_2 = t3.value[1]);
    }
    const q2 = new h(_2), z2 = pt("styles", e3, a3, s3, V2);
    let G2 = z2.entries().next()?.value[1];
    G2 && (G2 = JSON.parse(u(G2)));
    const U2 = pt("workbooks", e3, a3, s3, V2);
    await Promise.all(E2);
    const Z2 = { ...U2.entries().next().value[1], styles: G2, theme: q2.toJSON() };
    N2.length > 0 && (Z2.strings = N2), B2 && B2.length > 0 && (Z2.people = B2);
    const Q2 = { ...n2, resources: p2, json: Z2 }, J2 = new d(Q2);
    if (v3.forEach((t3) => {
      t3.deleteReference(x3);
    }), b3.endPersist(), l2.length) {
      const t3 = m2?.onWarning;
      if (t3) for (const e4 of l2) {
        const [s4, i2] = e4;
        t3(s4, i2);
      }
    }
    return J2;
  } catch (t3) {
    let e3 = "Unable to parse XLSX.";
    throw t3 instanceof p && (e3 = "Unable to open XLSX. There are too many rows or columns."), new Error(e3, { cause: t3 });
  }
}, writeBufferXLSX: async (s2, i2) => {
  const o2 = await import("xlsx"), r2 = await s2.toJSON(true), n2 = o2.utils.book_new();
  for (let i3 = 0; i3 < r2.sheets.length; i3++) {
    const a2 = r2.sheets[i3], l2 = o2.utils.json_to_sheet([{}]);
    o2.utils.book_append_sheet(n2, l2, a2.name);
    const c2 = a2.sheet, h2 = s2.getSheetAt(i3), u2 = h2.getUsedRange();
    if (u2 ? (l2["!ref"] = u2.getA1(), u2.forEach((s3, i4) => {
      const o3 = { t: "z" }, r3 = i4.getCell().getStyle();
      if (!r3.isNormal()) {
        let e2 = r3.getNumberFormat();
        e2 !== t.Type.General && (e2 === t.Type.ShortDate ? e2 = "m/d/yyyy" : e2 === t.Type.MediumDate ? e2 = "d-mmm-yy" : e2 === t.Type.LongDate ? e2 = "[$-x-sysdate]dddd, mmmm dd, yyyy" : e2 === t.Type.ShortTime ? e2 = "h:mm" : e2 === t.Type.MediumTime ? e2 = "h:mm AM/PM" : e2 === t.Type.LongTime && (e2 = "h:mm:ss AM/PM"), o3.z = e2);
      }
      if (null !== s3) switch (i4.getType()) {
        case e.Number:
          o3.t = "n", o3.v = s3;
          break;
        case e.String:
          o3.t = "s", o3.v = s3;
          break;
        case e.Boolean:
          o3.t = "b", o3.v = s3;
          break;
        case e.Error:
          o3.t = "e", o3.v = s3.toString();
        case e.RichData:
      }
      l2[i4.getA1()] = o3;
    })) : l2["!ref"] = "A1:A1", c2.merges?.length > 0) {
      const t2 = [];
      l2["!merges"] = t2;
      for (let e2 = 0; e2 < c2.merges.length; e2++) t2.push(o2.utils.decode_range(c2.merges[e2]));
    }
    if (c2.cols?.length > 0) {
      const t2 = [];
      l2["!cols"] = t2;
      const e2 = c2.cols, s3 = { width: c2.defaultColSize ?? h2.getColumnWidthAsFontUnit(h2.getColumnHeaders().getDefaultSize()) }, i4 = e2.length;
      for (let o3 = 0; o3 < i4; o3++) {
        const i5 = e2[o3];
        for (let e3 = t2.length; e3 <= i5.min - 1; e3++) t2.push(s3);
        const r3 = {};
        void 0 !== i5.sz && (r3.width = i5.sz), void 0 !== i5.h && (r3.hidden = i5.h), void 0 !== i5.l && (r3.level = i5.l);
        for (let e3 = i5.min; e3 <= i5.max; e3++) t2.push(r3);
      }
    }
  }
  o2.write(n2, { type: "array", bookType: "xlsx" });
  return o2.write(n2, { type: "array", bookType: "xlsx" });
} }, Symbol.toStringTag, { value: "Module" }));
export {
  Dt as H,
  xt as a,
  vt as b,
  bt as c,
  mt as d,
  wt as p,
  Tt as r,
  yt as t
};