@sheetxl/io
Version:
IO - Import/Export Libraries for SheetXL.
1,487 lines • 72.4 kB
JavaScript
/**
* @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.
*/
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, CommonUtils as h, Theme as u, JSONStableStringify as d, StyleCollection as p, Workbook as g, OutOfBoundsError as f } from "@sheetxl/sdk";
import { CommonUtils as m } from "@sheetxl/utils";
const T = ":A-Z_a-zÀ-ÖØ-öø-˿Ͱ-ͽͿ-⁰-Ⰰ-、-豈-﷏ﷰ-�𐀀-", y = new RegExp(`^[${T}][${`-${T}.0-9·̀-ͯ‿-⁀`}]*$`, "u"), b = [32, 10, 13, 9];
function x(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 w = "A-Z_a-zÀ-ÖØ-öø-˿Ͱ-ͽͿ--⁰-Ⰰ-、-豈-﷏ﷰ-�𐀀-", v = new RegExp(`^[${w}][${`-${w}.0-9·̀-ͯ‿-⁀`}]*$`, "u");
function S(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 C = function(t2) {
return 32 === t2 || 10 === t2 || 13 === t2 || 9 === t2;
}, k = function(t2) {
return t2 >= 32 && t2 <= 55295 || 10 === t2 || 13 === t2 || 9 === t2 || t2 >= 57344 && t2 <= 65533 || t2 >= 65536 && t2 <= 1114111;
}, A = x, D = function(t2) {
return x(t2) || t2 >= 48 && t2 <= 57 || 45 === t2 || 46 === t2 || 183 === t2 || t2 >= 768 && t2 <= 879 || t2 >= 8255 && t2 <= 8256;
}, E = b, P = y, O = function(t2) {
return t2 >= 1 && t2 <= 55295 || t2 >= 57344 && t2 <= 65533 || t2 >= 65536 && t2 <= 1114111;
}, I = S, V = function(t2) {
return S(t2) || 45 === t2 || 46 === t2 || t2 >= 48 && t2 <= 57 || 183 === t2 || t2 >= 768 && t2 <= 879 || t2 >= 8255 && t2 <= 8256;
}, L = v, N = "http://www.w3.org/XML/1998/namespace", R = "http://www.w3.org/2000/xmlns/", $ = { __proto__: null, xml: N, xmlns: R }, M = { __proto__: null, amp: "&", gt: ">", lt: "<", quot: '"', apos: "'" }, j = -1, H = -2, F = 13, X = 33, B = 10, W = 60, _ = 61, q = 62, z = 63, U = 93, G = (t2) => 34 === t2 || 39 === t2, Z = [34, 39], Q = [...Z, 91, q], J = [...Z, W, U], K = [_, z, ...E], Y = [...E, q, 38, W];
function tt(t2, e2, s2) {
switch (e2) {
case "xml":
s2 !== N && t2.fail(`xml prefix must be bound to ${N}.`);
break;
case "xmlns":
s2 !== R && t2.fail(`xmlns prefix must be bound to ${R}.`);
}
switch (s2) {
case R:
t2.fail("" === e2 ? `the default namespace may not be set to ${s2}.` : `may not assign a prefix (even "xmlns") to the URI ${R}.`);
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 et = (t2) => L.test(t2), st = (t2) => P.test(t2), it = { 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 ot {
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 = I, this.nameCheck = V, this.isName = et, this.processAttribs = this.processAttribsNS, this.pushAttrib = this.pushAttribNS, this.ns = { __proto__: null, ...$ };
const t3 = this.opt.additionalNamespaces;
null != t3 && (!function(t4, e3) {
for (const s2 of Object.keys(e3)) tt(t4, s2, e3[s2]);
}(this, t3), Object.assign(this.ns, t3));
} else this.nameStartCheck = A, this.nameCheck = D, this.isName = st, 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 ? F : 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(M), this.readyHandler?.();
}
get position() {
return this.chunkPosition + this.i;
}
get columnIndex() {
return this.position - this.positionAtNewLine;
}
on(t2, e2) {
this[it[t2]] = e2;
}
off(t2) {
this[it[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; assign an onready handler.");
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 j;
const s2 = t2.charCodeAt(e2);
if (this.column++, s2 < 55296) {
if (s2 >= 32 || 9 === s2) return s2;
switch (s2) {
case B:
return this.line++, this.column = 0, this.positionAtNewLine = this.position, B;
case 13:
return t2.charCodeAt(e2 + 1) === B && (this.i = e2 + 2), this.line++, this.column = 0, this.positionAtNewLine = this.position, H;
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 j;
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 B:
return this.line++, this.column = 0, this.positionAtNewLine = this.position, B;
case 13: {
const s3 = t2.charCodeAt(e2 + 1);
s3 !== B && 133 !== s3 || (this.i = e2 + 2);
}
case 133:
case 8232:
return this.line++, this.column = 0, this.positionAtNewLine = this.position, H;
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 === H ? B : 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 === H, r2 = o2 ? B : i2;
if (r2 === j || 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 H:
this.text += `${s2.slice(e2, this.prevI)}
`, e2 = this.i, i2 = B;
break;
case j:
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 === j) return this.name += t2.slice(e2), j;
if (!D(s2)) return this.name += t2.slice(e2, this.prevI), s2 === H ? B : s2;
}
}
skipSpaces() {
for (; ; ) {
const t2 = this.getCodeNorm();
if (t2 === j || !C(t2)) return t2;
}
}
setXMLVersion(t2) {
this.currentXMLVersion = t2, "1.0" === t2 ? (this.isChar = k, this.getCode = this.getCode10) : (this.isChar = O, 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 W:
if (this.state = 15, 0 !== this.text.length) throw new Error("no-empty text at start");
break;
case j:
break;
default:
this.unget(), this.state = F, this.xmlDeclPossible = false;
}
}
sDoctype() {
const t2 = this.captureTo(Q);
switch (t2) {
case q:
this.doctypeHandler?.(this.text), this.text = "", this.state = F, this.doctype = true;
break;
case j:
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(J);
t2 !== j && (this.text += String.fromCodePoint(t2), t2 === U ? this.state = 2 : t2 === W ? 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 z:
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 === q ? this.state = 4 : (this.fail("malformed comment."), this.state = 8);
}
sDTDPI() {
this.captureToChar(z) && (this.text += "?", this.state = 12);
}
sDTDPIEnding() {
const t2 = this.getCodeNorm();
this.text += String.fromCodePoint(t2), t2 === q && (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 H:
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 === F && void 0 === this.textHandler || (this.text += o2);
break t;
}
case j:
this.entity += e2.slice(t2);
break t;
}
}
sOpenWaka() {
const t2 = this.getCode();
if (A(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 z:
this.state = 23;
break;
default:
this.fail("disallowed character in tag name"), this.state = F, 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 !== q ? (this.fail("malformed comment."), this.text += `--${String.fromCodePoint(t2)}`, this.state = 17) : this.state = F;
}
sCData() {
this.captureToChar(U) && (this.state = 21);
}
sCDataEnding() {
const t2 = this.getCodeNorm();
t2 === U ? this.state = 22 : (this.text += `]${String.fromCodePoint(t2)}`, this.state = 20);
}
sCDataEnding2() {
const t2 = this.getCodeNorm();
switch (t2) {
case q:
this.cdataHandler?.(this.text), this.text = "", this.state = F;
break;
case U:
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 === z || C(t2) ? (this.fail("processing instruction without a target."), this.state = t2 === z ? 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 === j) return void (this.piTarget += t2.slice(e2));
if (!this.nameCheck(s2)) {
this.piTarget += t2.slice(e2, this.prevI);
const i2 = s2 === z;
i2 || C(s2) ? "xml" === this.piTarget ? (this.xmlDeclPossible || this.fail("an XML declaration must be at the start of the document."), this.state = i2 ? X : 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 === z ? this.state = 26 : C(t2) || (this.text = String.fromCodePoint(t2));
} else this.captureToChar(z) && (this.state = 26);
}
sPIEnding() {
const t2 = this.getCodeNorm();
if (t2 === q) {
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 = F;
} else t2 === z ? this.text += "?" : (this.text += `?${String.fromCodePoint(t2)}`, this.state = 25);
this.xmlDeclPossible = false;
}
sXMLDeclNameStart() {
const t2 = this.skipSpaces();
t2 !== z ? t2 !== j && (this.state = 28, this.name = String.fromCodePoint(t2)) : this.state = X;
}
sXMLDeclName() {
const t2 = this.captureTo(K);
if (t2 === z) return this.state = X, this.name += this.text, this.text = "", void this.fail("XML declaration is incomplete.");
if (C(t2) || t2 === _) {
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 === _ ? 30 : 29;
}
}
sXMLDeclEq() {
const t2 = this.getCodeNorm();
if (t2 === z) return this.state = X, void this.fail("XML declaration is incomplete.");
C(t2) || (t2 !== _ && this.fail("value required."), this.state = 30);
}
sXMLDeclValueStart() {
const t2 = this.getCodeNorm();
if (t2 === z) return this.state = X, void this.fail("XML declaration is incomplete.");
C(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, z]);
if (t2 === z) return this.state = X, this.text = "", void this.fail("XML declaration is incomplete.");
if (t2 === j) 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 !== z ? (C(t2) || (this.fail("whitespace required."), this.unget()), this.state = 27) : this.state = X;
}
sXMLDeclEnding() {
this.getCodeNorm() === q ? ("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 = F) : this.fail("The character ? is disallowed anywhere in XML declarations."), this.xmlDeclPossible = false;
}
sOpenTag() {
const t2 = this.captureNameChars();
if (t2 === j) 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 q:
this.openTag();
break;
case 47:
this.state = 35;
break;
default:
C(t2) || this.fail("disallowed character in tag name."), this.state = 36;
}
}
sOpenTagSlash() {
this.getCode() === q ? this.openSelfClosingTag() : (this.fail("forward-slash in opening tag not followed by >."), this.state = 36);
}
sAttrib() {
const t2 = this.skipSpaces();
t2 !== j && (A(t2) ? (this.unget(), this.state = 37) : t2 === q ? this.openTag() : 47 === t2 ? this.state = 35 : this.fail("disallowed character in attribute name."));
}
sAttribName() {
const t2 = this.captureNameChars();
t2 === _ ? this.state = 39 : C(t2) ? this.state = 38 : t2 === q ? (this.fail("attribute without value."), this.pushAttrib(this.name, this.name), this.name = this.text = "", this.openTag()) : t2 !== j && this.fail("disallowed character in attribute name.");
}
sAttribNameSawWhite() {
const t2 = this.skipSpaces();
switch (t2) {
case j:
return;
case _:
this.state = 39;
break;
default:
this.fail("attribute without value."), this.text = "", this.name = "", t2 === q ? this.openTag() : A(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) : C(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 B:
case H:
case 9:
this.text += `${e2.slice(s2, this.prevI)} `, s2 = this.i;
break;
case W:
return this.text += e2.slice(s2, this.prevI), void this.fail("disallowed character.");
case j:
return void (this.text += e2.slice(s2));
}
}
sAttribValueClosed() {
const t2 = this.getCodeNorm();
C(t2) ? this.state = 36 : t2 === q ? this.openTag() : 47 === t2 ? this.state = 35 : A(t2) ? (this.fail("no whitespace between attributes."), this.unget(), this.state = 37) : this.fail("disallowed character in attribute name.");
}
sAttribValueUnquoted() {
const t2 = this.captureTo(Y);
switch (t2) {
case 38:
this.state = 14, this.entityReturnState = 42;
break;
case W:
this.fail("disallowed character.");
break;
case j:
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 === q ? this.openTag() : this.state = 36;
}
}
sCloseTag() {
const t2 = this.captureNameChars();
t2 === q ? this.closeTag() : C(t2) ? this.state = 44 : t2 !== j && this.fail("disallowed character in closing tag.");
}
sCloseTagSawWhite() {
switch (this.skipSpaces()) {
case q:
this.closeTag();
break;
case j:
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 W:
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 = F, void 0 !== i2 && (this.text += s2.slice(t2, this.prevI)), e2 = 0;
break t;
case U:
switch (e2) {
case 0:
e2 = 1;
break;
case 1:
e2 = 2;
break;
case 2:
break;
default:
throw new Error("impossible state");
}
break;
case q:
2 === e2 && this.fail('the string "]]>" is disallowed in char data.'), e2 = 0;
break;
case H:
void 0 !== i2 && (this.text += `${s2.slice(t2, this.prevI)}
`), t2 = this.i, e2 = 0;
break;
case j:
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 W:
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 = F, void 0 !== s2 && (this.text += e2.slice(t2, this.prevI)), i2 = true;
break t;
case H:
void 0 !== s2 && (this.text += `${e2.slice(t2, this.prevI)}
`), t2 = this.i;
break;
case j:
void 0 !== s2 && (this.text += e2.slice(t2));
break t;
default:
C(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, tt(this, i2, t3);
} else if ("xmlns" === t2) {
const t3 = e2.trim();
this.topNS[""] = t3, tt(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 !== F && 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 ? R : "", 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 = F, 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 = F, this.name = "";
}
closeTag() {
const { tags: t2, name: e2 } = this;
if (this.state = F, 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.");
}
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 rt, nt;
(nt = rt || (rt = {})).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" }, nt.parseStream = async (t2, e2, s2) => {
const i2 = new ot({ position: false, ...s2 });
let o2;
if (e2.onOpenTagStart && i2.on(nt.Events.OpenTagStart, e2.onOpenTagStart), e2.onOpenTag && i2.on(nt.Events.OpenTag, e2.onOpenTag), e2.onCloseTag && i2.on(nt.Events.CloseTag, e2.onCloseTag), e2.onAttribute && i2.on(nt.Events.Attribute, e2.onAttribute), e2.onText && i2.on(nt.Events.Text, e2.onText), e2.onError && i2.on(nt.Events.Error, e2.onError), e2.onEnd) {
e2.onEnd;
const t3 = () => {
o2 = e2.onEnd();
};
i2.on(nt.Events.End, t3);
}
for (; ; ) {
const { value: e3, done: s3 } = await t2.read();
if (s3) break;
i2.write(e3);
}
return i2.close(), o2;
};
const at = (t2) => true === t2 || "1" === t2 || "on" === t2 || "true" === t2 || false !== t2 && "0" !== t2 && "off" !== t2 && "false" !== t2 && null, lt = (t2) => {
const e2 = parseInt(t2);
return isNaN(e2) ? null : e2;
}, ct = (t2) => {
const e2 = parseFloat(t2);
return isNaN(e2) ? null : e2;
}, ht = null;
class ut {
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 dt = (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;
}, pt = (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;
}, gt = (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 = pt(l2, (t4) => e2.files[t4], s2, i2, o2);
r2.set(l2, c2);
}
return r2;
}, ft = 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();
}, mt = ["lt1", "dk1", "lt2", "dk2", "accent1", "accent2", "accent3", "accent4", "accent5", "accent6", "hlink", "folHlink"], Tt = (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 = mt[a2]);
let l2 = t2("tint");
if (l2 && (i2 += ` ${s.AdjustmentType.ETint} ${parseFloat(l2)}`), i2) return i2;
}, yt = (t2) => {
if (!t2) return t2;
return t2.replace(/^\{([\s\S]+)\}$/, "$1");
}, bt = (t2) => t2 ? m.roundAccurately(parseFloat(t2) / 12700, 4) : null, xt = (t2) => t2 ? m.roundAccurately(parseFloat(t2) / 9525, 1) : null, wt = (t2) => parseFloat(t2) / 1e3, vt = (t2) => parseFloat(t2) / 6e4, St = (t2) => "true" === t2 || "1" === t2;
class Ct {
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 kt = (t2, e2, s2) => {
if (t2[0].value[0] === t2[1].value[0]) return e2;
}, At = { colStart: 0, colEnd: 0, rowStart: 0, rowEnd: 0 }, Dt = (t2, s2, i2, o2, c2, h2) => {
let u2 = false, d2 = false, p2 = [], g2 = false, f2 = null, m2 = null, T2 = null, y2 = null, b2 = null, x2 = null;
const w2 = h2?.get("richData") ?? [], v2 = r.normalizeA1ToR1C1, S2 = n.createConflatingRanges(), C2 = /* @__PURE__ */ new Map(), k2 = [];
let A2 = null;
const D2 = n.createConflatingRanges();
let E2, P2 = false, O2 = -1, I2 = -1, V2 = null, L2 = null;
const N2 = [];
let R2 = null, $2 = -2, M2 = 0, j2 = "", H2 = "", F2 = "", X2 = "", B2 = "", W2 = "", _2 = "", q2 = "", z2 = "", U2 = "", G2 = "", Z2 = "", Q2 = "", J2 = "", K2 = true, Y2 = null;
return { ...i2, onEnd: () => {
N2.length > 0 && (s2.rows = N2);
let e2 = S2.done(kt);
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 = D2.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 (k2.length > 0 && (s2.dynamicArray = [...k2]), p2.length > 0) {
p2.sort(n.createRangeComparator(a.Orientation.Column));
const t3 = [];
let e3 = null, i3 = -1, o4 = -1, r2 = -1, l3 = -1, c4 = null;
const h4 = p2.length;
h4 > 0 && (e3 = p2[0], i3 = e3.colStart, o4 = e3.colEnd, r2 = e3.rowEnd, l3 = e3.value, t3.push(e3));
for (let s3 = 1; s3 < h4; s3++) c4 = p2[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 s3 = e2.indexOf(":");
if (-1 !== s3 && (e2 = e2.slice(s3 + 1)), E2) {
const s4 = t3.attributes;
switch (e2) {
case "v":
d2 = true;
break;
case "f":
switch (s4.t ?? null) {
case null:
case "normal":
g2 = true;
break;
case "shared":
const t4 = s4.si;
m2 = s4.ref, f2 = t4;
break;
case "array":
g2 = true, m2 = s4.ref, A2 = [m2, false];
break;
case "datatable":
g2 = true, m2 = s4.ref, g2 = true;
}
void 0 !== s4.ca && D2.append(O2, I2);
break;
case "is":
return void (P2 = true);
}
return void (P2 && c2?.onOpenTag(t3));
}
if (u2) {
if ("c" === e2) {
E2 = t3;
const e3 = t3.attributes.r;
I2 = r.fastStringToCol(e3);
const s4 = t3.attributes.t;
void 0 === s4 ? L2 = null : (L2 = s4, "str" === L2 && (P2 = true));
let i3 = t3.attributes.s;
void 0 !== i3 && (i3 = parseInt(i3), Y2 && Y2.value === i3 && Y2.colEnd + 1 === I2 ? Y2.colEnd = I2 : (Y2 = { colStart: I2, rowStart: O2, colEnd: I2, rowEnd: O2, value: i3 }, p2.push(Y2)));
}
} else {
if ("row" === e2) {
u2 = true;
const e3 = t3.attributes.r;
if (O2 = parseInt(e3) - 1, M2 = 0, H2 = t3.attributes.customHeight, void 0 !== H2 && (M2 |= Ct.CustomHeight), H2 !== z2 && (K2 = true, z2 = H2), j2 = t3.attributes.ht, void 0 !== j2 && (M2 |= Ct.Ht), j2 !== q2 && (K2 = true, q2 = j2), F2 = t3.attributes.hidden, void 0 !== F2 && (M2 |= Ct.Hidden), F2 !== U2 && (K2 = true, U2 = F2), B2 = t3.attributes.s, void 0 !== B2 && (M2 |= Ct.S), B2 !== Z2 && (K2 = true, Z2 = B2), X2 = t3.attributes.customFormat, void 0 !== X2 && (M2 |= Ct.CustomFormat), X2 !== G2 && (K2 = true, G2 = X2), W2 = t3.attributes.outlineLevel, void 0 !== W2 && (M2 |= Ct.OutlineLevel), W2 !== Q2 && (K2 = true, Q2 = W2), _2 = t3.attributes.collapsed, void 0 !== _2 && (M2 |= Ct.Collapsed), _2 !== J2 && (K2 = true, J2 = _2), 0 !== M2) if ($2 + 1 !== O2 || K2) {
const t4 = void 0 !== H2 && ("1" === H2 || "true" === H2), e4 = void 0 !== X2 && ("1" === X2 || "true" === X2);
R2 = { min: O2, max: O2, sz: t4 && void 0 !== j2 ? parseFloat(j2) : -1, csz: t4, h: void 0 !== F2 && ("1" === F2 || "true" === F2), s: t4 && void 0 !== B2 && "0" !== B2 ? parseInt(B2) : 0, cs: e4, l: void 0 === W2 || "0" === W2 ? 0 : parseInt(W2), cl: void 0 !== _2 && ("1" === _2 || "true" === _2) }, N2.push(R2);
} else R2.max = O2;
return $2 = O2, void (K2 = false);
}
i2?.onOpenTag(t3);
}
}, onCloseTag: (e2) => {
if (E2) {
let s3 = e2.name;
const i3 = s3.indexOf(":");
if (-1 !== i3 && (s3 = s3.slice(i3 + 1)), P2) if ("is" === s3 || "v" === s3) {
const e3 = c2?.onEnd();
null !== e3 && t2.addValue(O2, I2, "" + e3);
} else c2?.onCloseTag?.(e2);
return d2 && (d2 = false), void ("c" === s3 && (E2 = null, P2 = false));
}
if (u2) return u2 = false, void (Y2 = null);
i2?.onCloseTag(e2);
}, onText: (s3) => {
if (s3 = s3.trim(), d2) {
switch (V2 = null, L2) {
case null:
case "n":
V2 = parseFloat(s3);
break;
case "b":
V2 = "1" === s3 || "true" === s3;
break;
case "s":
V2 = s3;
break;
case "e":
if ("#VALUE!" === s3) {
const t4 = E2.attributes.vm;
if (void 0 !== t4) {
const s4 = w2[parseInt(t4) - 1];
if (s4 && s4.isFormulaError) {
V2 = { t: e.Error, v: s4.getCode() };
break;
}
}
}
const t3 = l.getBuiltInByLabel(s3);
t3 ? V2 = { t: e.Error, v: t3.getCode() } : (V2 = s3, o2?.(`Unknown formula error '${s3}' in cell ${r.cellToString({ colIndex: I2, rowIndex: O2 })}`));
break;
case "str":
case "inlineStr":
P2 = true;
}
null !== V2 && t2.addValue(O2, I2, V2);
}
if (A2 && ("e" === L2 && (A2[1] = true), k2.push(A2), A2 = null), f2) if (b2 === f2) y2 = x2;
else {
if (y2 = C2.get(f2), !y2) {
const t3 = [];
T2 = v2(s3, O2, I2, t3), y2 = [T2, t3, s3], C2.set(f2, y2);
}
b2 = f2, x2 = y2;
}
if (g2) {
const t3 = [];
T2 = v2(s3, O2, I2, t3), y2 = [T2, t3, s3];
}
if (y2) return S2.append(O2, I2, y2), y2 = null, g2 = false, f2 = null, void (m2 = null);
P2 ? c2?.onText(s3) : u2 || i2?.onText(s3);
} };
}, Et = Object.freeze(Object.defineProperty({ __proto__: null, fromBufferXLSX: async (t2, e2) => {
const { password: s2, onWarning: n2, constructorOptions: a2 = {}, ...l2 } = e2 ?? {}, p2 = import("xlsx"), m2 = import("./CHVn6XGQfP3RI4rb.mjs");
let T2 = null;
try {
T2 = new DOMParser();
} catch (t3) {
}
let y2 = null;
T2 || (y2 = import("@xmldom/xmldom"));
let b2 = null, x2 = null, w2 = null;
try {
const t3 = await Promise.all([p2, m2, y2]);
b2 = t3[0], x2 = t3[1], w2 = t3[2];
} catch (t3) {
throw new Error("Unable to load XLSX parser.", { cause: t3 });
}
try {
const e3 = b2.read(t2, { type: "array", sheets: [], cellStyles: false, bookFiles: true });
if (!e3.Directory) throw new Error("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 x2.FromOOXMLConverter(), l3 = T2 ?? new w2.DOMParser(), p3 = a2?.resources ?? new c(), f2 = p3.beginPersist(), m3 = {}, y3 = /* @__PURE__ */ new Set(), v2 = /* @__PURE__ */ new Map();
v2.set("richTypes", []);
const S2 = /* @__PURE__ */ new Map(), C2 = [], k2 = (t3) => e3.files[t3], A2 = (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 = pt(t4, e5, s4, i3, o3);
if (!r3) return null;
const n3 = /* @__PURE__ */ new Map(), a3 = Object.keys(r3), l4 = a3.length;
for (let t5 = 0; t5 < l4; t5++) {
const e6 = a3[t5], s5 = r3[e6];
n3.set(e6, s5);
}
return n3;
})(o2, k2, l3, s3, E2), e4.set(o2, r2)), r2;
}, D2 = (t3, e4, a3, c2 = S2) => {
let u2 = A2(e4, c2).get(t3), d2 = u2?.target;
if (!d2) return null;
if ("External" === u2.targetMode) return u2.target;
const g2 = e4.lastIndexOf("/"), T3 = e4.substring(0, g2 + 1);
d2.startsWith("/") || (d2 = T3 + d2), d2 = ((t4) => {
const e5 = t4.split(/\/+/), s4 = e5.reduce((t5, e6, s5) => ("." === e6 ? t5.splice(s5, 1) : ".." === e6 && t5.splice(s5 - 1, 2), t5), e5);
return s4.join("/");
})(d2);
const b3 = s3?.getVisitorParamsState().get("dxfs");
let x3 = c2.get(d2);
if (!x3) {
const t4 = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet";
if (u2.type === t4) {
const t5 = {};
x3 = t5;
const e5 = async () => {
const e6 = ((t6, e7, s5, n3, a5, l5, c3) => {
const h2 = new ut(), u4 = new i.TransposedBuilder();
let d3 = null;
h2.registerVisitor({ from: "autoFilter", to: "filter", openTag: (t7) => {
t7.copyTo("ref", ht);
} }), h2.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", at);
}, 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;
} }), h2.registerVisitor({ from: "cfRule", to: "rule", openTag: (t7) => {
const e8 = t7.getParent();
t7.copyToObject(e8, "type", ht), t7.copyToObject(e8, "priority", lt), t7.copyToObject(e8, "stopIfTrue", at);
const s6 = t7.getAttribute("dxfId", lt);
if (null !== s6) {
let i2 = n3?.get(s6);
i2 || (l5?.(`Unable to load conditional color. Invalid dxfI: '${s6}' at '${t7.getPath()}'.`), i2 = {}), e8.style = i2;
}
t7.copyToObject(e8, "aboveAverage", at), t7.copyToObject(e8, "equalAverage", at), t7.copyToObject(e8, "stdDev", lt), t7.copyToObject(e8, "bottom", at), t7.copyToObject(e8, "percent", at), t7.copyToObject(e8, "rank", lt), t7.copyToObject(e8, "operator", ht), t7.copyToObject(e8, "text", ht), t7.copyToObject(e8, "timePeriod", ht);
} }), h2.registerVisitor({ from: "colorScale", to: "colorScale" }), h2.registerVisitor({ from: "dataBar", to: "dataBar", openTag: (t7) => {
t7.copyTo("maxLength", lt), t7.copyTo("minLength", lt), t7.copyTo("showValue", at);
} }), h2.registerVisitor({ from: "iconSet", to: "iconSet", openTag: (t7) => {
t7.copyTo("iconSet", ht), t7.copyTo("reverse", at), t7.copyTo("showValue", at);
} }), h2.registerVisitor({ from: "formula", to: null, text: (t7, e8) => {
const s6 = e8.getParent();
let i2 = s6.formulas;
i2 || (i2 = [], s6.formulas = i2), i2.push(t7);
} }), h2.registerVisitor({ from: "cfvo", to: {}, openTag: (t7) => {
const e8 = t7.getParent();
e8.conditions || (e8.conditions = []), e8.conditions.push(t7.getSource()), t7.copyTo("type", ht), t7.copyTo("value", ct, "val"), t7.copyTo("gte", at);
} }), h2.registerVisitor({ from: "color", to: {}, openTag: (t7) => {
const e8 = t7.getParent();
e8.colors || (e8.colors = []);
const s6 = Tt((e9) => t7.getAttribute(e9));
e8.colors.push(s6);
} }), h2.registerVisitor({ from: "filterColumn", to: "filterColumn", openTag: (t7) => {
const e8 = t7.getParent();
e8.fields || (e8.fields = []), e8.fields.push(t7.getSource()), t7.copyTo("offset", lt, "colId"), t7.copyTo("hiddenButton", at), t7.copyTo("showButton", at);
} }), h2.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", at), t7.copyTo("styleId", lt, "dxfId");
} }), h2.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", ht, "type"), t7.copyTo("val", ct), t7.copyTo("maxVal", ct, "maxVal");
} }), h2.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", lt), t7.copyTo("iconSet", ht);
} }), h2.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", ct), t7.copyTo("percent", at), t7.copyTo("top", at), t7.copyTo("val", ct);
} }), h2.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", at), t7.copyTo("calendarType", ht);
} }), h2.registerVisitor({ from: "dateGroupItem", to: "dateGroupItem", openTag: (t7) => {
const e8 = t7.getParent();
e8.dateGroups || (e8.dateGroups = []), e8.dateGroups.push(t7.getSource()), t7.copyTo("group", ht, "dateTimeGrouping"), t7.copyTo("day", lt), t7.copyTo("hour", lt), t7.copyTo("minute", lt), t7.copyTo("month", lt), t7.copyTo("second", lt), t7.copyTo("year", lt);
} }), h2.registerVisitor({ from: "filter", to: "filter", openTag: (t7) => {
const e8 = t7.getParent();
e8.items || (e8.items = []), e8.items.push(t7.getAttribute("val", ct));
} }), h2.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", at);
} }), h2.registerVisitor({ from: "customFilter", to: "customFilter", openTag: (t7) => {
const e8 = t7.getParent();
e8.filters || (e8.filters = []), e8.filters.push(t7.getSource()), t7.copyTo("operator", ht), t7.copyTo("value", ct, "val");
} }), h2.registerVisitor({ from: "sortState", to: "sort", openTag: (t7) => {
t7.copyTo("ref", ht);
} }), h2.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", ht, "sortBy"), t7.copyTo("dxfId", ht, "sortBy"), t7.copyTo("iconSet", ht), t7.copyTo("customList", ht);
const i2 = t7.getAttribute("ref");
if (i2) {
const t8 = r.fastStringToRange(i2, At).colStart, o2 = r.fastStringToRange(e8.ref, At), n4 = o2.colStart;
s6.offset = o2 ? t8 - n4 : t8;
}
s6.reverse = t7.getAttribute("descending", at) ?? false;
} }), h2.registerVisitor({ from: "AlternateContent", to: null });
const p5 = (t7) => {
d3 = t7.getSource(), t7.copyTo("topLeft", ht, "topLeftCell");
const e8 = St(t7.getAttribute("defaultGridColor")), s6 = t7.getAttribute("colorId");
null === s6 || e8 || (t7.getSource().gridLineColor = "index" + parseFloat(s6)), t7.copyTo("showZeros", at), t7.copyTo("showFormulas", at), t7.copyTo("zoomScale", lt), t7.copyTo("showRowHeaders", at, "showRowColHeaders"), t7.copyTo("showColumnHeaders", at, "showRowColHeaders"), t7.copyTo("showRowGridlines", at, "showGridLines"), t7.copyTo("showColumnGridlines", at, "showGridLines");
};
h2.registerVisitor({ from: "sheetView", to: "view", openTag: (t7) => {
p5(t7);
}, closeTag: () => {
d3 = null;
} }), h2.registerVisitor({ from: "customSheetViews", to: "customSheetViews", openTag: (t7) => {
t7.setSource([]);
} }), h2.registerVisitor({ from: "customSheetView", to: [], openTag: (t7) => {
p5(t7);
}, closeTag: () => {
d3 = null;
} }), h2.registerVisitor({ from: "selection", to: "selection", openTag: (t7) => {
if (!d3) return;
t7.copyTo("cell", ht, "activeCell"), t7.copyTo("rangeIndex", lt, "activeCellId");
const e8 = t7.getAttribute("activeCell"), s6 = t7.getAttribute("sqref");
s6 && s6 !== e8 && (t7.getSource().ranges = s6.split(" "));
} }), h2.registerVisitor({ from: "pane", to: "pane", openTag: (t7) => {
if (d3 && "frozen" === t7.getAttribute("state")) {
const e8 = {};
d3.freezePanes = e8, t7.copyToObject(e8, "topLeft", ht, "topLeftCell");
const s6 = d3.topLeft ? r.fastStringToCell(d3.topLeft) : { colIndex: 0, rowIndex: 0 }, i2 = { colIndex: 0, rowIndex: 0 };
t7.copyToObject(i2, "colIndex", lt, "xSplit"), t7.copyToObject(i2, "rowIndex", lt, "ySplit");
const o2 = { colIndex: s6.colIndex + i2.colIndex, rowIndex: s6.rowIndex + i2.rowIndex };
e8.coords = r.cellToString(o2);
}
} }), h2.registerVisitor({ from: "tabColor", to: null, openTag: (e8) => {
const s6 = Tt((t7) => e8.getAttribute(t7));
s6 && (t6.tabColor = s6);
} }), h2.registerVisitor({ from: "pageSetUpPr", to: "pageSetUpPr", openTag: (t7) => {
} }), h2.registerVisitor({ from: "outlinePr", to: "outlinePr", openTag: (t7) => {
} }), h2.registerVisitor({ from: "pageMargins", to: "pageMargins", openTag: (t7) => {
} }), h2.registerVisitor({ from: "pageSetup", to: "pageSetup", openTag: (t7) => {
} }), h2.registerVisitor({ from: "printOptions", to: "printOptions", openTag: (t7) => {
} }), h2.registerVisitor({ from: "mergeCells", to: "merges", openTag: (t7) => {
t7.setSource([]);
} }), h2.registerVisitor({ from: "mergeCell", to: [], openTag: (t7) => {
const e8 = t7.getAttribute("ref");
t7.setSource(e8);
} }), h2.registerVisitor({ from: "hyperlinks", to: "hyperlinks", openTag: (t7) => {
t7.setSource([]);
} }), h2.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 n4 = t7.getAttribute("location");
if (n4 && (r2 && r2 !== n4 && console.warn("display and location are different", r2, n4), o2 += "#" + n4), !o2) return void console.warn("No address found for hyperlink. r:id", s6);
let a6;
const l6 = t7.getAttribute("tooltip");
a6 = l6 ? { address: o2, tooltip: l6 } : o2, t7.setSource({ r: i2, v: a6 });
} }), h2.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);
} }), h2.registerVisitor({ from: "tableParts", to: "tables", openTag: (t7) => {
t7.setSource([]);
} }), h2.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);
} }), h2.registerVisitor({ from: "worksheet", to: "worksheet", openTag: (t7) => {
} }), h2.registerVisitor({ from: "sheetProtection", to: "protection", openTag: (t7) => {
let e8 = false;
if (t7.hasAttribute("sheet") && at(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", ht, "hashValue"), t7.copyToObject(i2, "algorithm", ht, "algorithmName"), t7.copyToObject(i2, "salt", ht, "saltValue"), t7.copyToObject(i2, "spinCount", lt), Object.keys(i2).length > 0 && (t7.getSource().password = i2);
} }), h2.registerVisitor({ from: "protectedRanges", to: "protectedRanges", openTag: (t7) => {
t7.setSource({});
} }), h2.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", ht, "hashValue"), t7.copyToObject(s6, "algorithm", ht, "algorithmName"), t7.copyToObject(s6, "salt", ht, "saltValue"), t7.copyToObject(s6, "spinCount", lt), Object.keys(s6).length > 0 && (t7.getSource().password = s6);
} }), h2.registerVisitor({ from: "sheetFormatPr", to: "sheetFormatPr", openTag: (e8) => {
e8.copyToObject(t6, "defaultColSize", ct, "defaultColWidth"), e8.copyToObject(t6, "outlineLevelCol", lt, "outlineLevelCol");
const s6 = e8.getAttribute("customHeight");
"1" !== s6 && "true" !== s6 || e8.copyToObject(t6, "defaultRowSize", ct, "defaultRowHeight"), e8.copyToObject(t6, "outlineLevelRow", lt, "outlineLevelRow");
} }), h2.registerVisitor({ from: "cols", to: "cols", openTag: (t7) => {
t7.setSource([]);
} }), h2.registerVisitor({ from: "col", to: [], openTag: (t7) => {
t7.copyTo("min", (t8) => parseInt(t8) - 1), t7.copyTo("max", (t8) => parseInt(t8) - 1), t7.copyTo("sz", ct, "width"), t7.copyTo("cs", at, "customWidth"), t7.copyTo("h", at, "hidden"), t7.copyTo("l", lt, "outlineLevel"), t7.copyTo("s", lt, "style");
} }), h2.registerVisitor({ from: "oleObjects", to: null, openTag: (t7) => {
t7.warn("'OLE Objects' are not supported.");
} });
let g3 = null;
const f3 = { onOpenTag: (t7) => {
null === g3 && (g3 = "");
}, onText: (t7) => {
g3 += t7;
}, onEnd: () => {
const t7 = s5(g3);
return g3 = null, t7;
}, onError: (t7) => {
} };
return Dt(u4, t6, h2.createEventHandler(t6, a5, l5), l5, f3, c3);
})(t5, (t6, e7 = false) => D2(t6, d2, e7) ?? null, N2, b3, () => {
}, (t6) => {
n2 && (t6 = d2 + ": " + t6, n2?.(t6));
}, v2), s4 = dt(d2, k2), a4 = await ft(s4);
try {
await rt.parseStream(a4, e6, { xmlns: false });
} catch (t6) {
throw console.warn(`Error parsing sheet: '${d2}'`, t6), new Error(`Error parsing sheet: '${d2}'`, { cause: t6 });
}
const l4 = A2(d2, c2);
let u3, p4 = /* @__PURE__ */ new Map();
if (l4) {
const e7 = "http://schemas.microsoft.com/office/2017/10/relationships/threadedComment";
let s5;
l4.forEach((t6, s6) => {
if (t6.type === e7) {
const t7 = D2(s6, d2, false, c2);
u3 = t7?.comments, u3 && u3.forEach((t8) => {
p4.set(t8.id, t8);
});
}
});
const i2 = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments";
if (l4.forEach((t6, e8) => {
if (t6.type === i2) {
const t7 = D2(e8, d2, false, c2);
s5 = t7;
}
}), s5 || u3) {
const e8 = u3 ?? [], i3 = s5?.comments;
if (i3) {
const t6 = s5?.authors;
for (let s6 = 0; s6 < i3.length; s6++) {
const o2 = i3[s6];
let r2 = void 0 !== o2.authorId ? t6[o2.authorId] : void 0;
if ((!r2 || r2.startsWith("tc=")) && (r2 = yt(r2.substring(3)), p4.has(r2))) continue;
let n3 = R2.get(r2);
n3 || (n3 = $2.get(r2)), n3 || (n3 = { id: h.uuidV4(), displayName: r2 }, $2.set(n3.displayName, n3), R2.set(n3.id, n3)), r2 = n3?.id ?? null;
const a5 = { id: h.uuidV4(), personId: r2, ref: o2.ref, done: false, asNote: true, content: o2.content };
e8.push(a5);
}
}
t5.comments = e8;
}
}
};
C2.push(e5());
} else x3 = a3 ? dt(d2, k2, (t5) => {
const e5 = p3.add({ buffer: t5 });
return e5.addReference(m3), y3.add(e5), f2.toResourceId(e5);
}, E2) : pt(d2, k2, l3, s3, E2);
}
return x3;
}, E2 = { paramMap: v2, getRefs: A2, getRef: D2, parsedRefs: S2, onWarning: n2, addPerson: (t3) => null }, P2 = [];
let O2 = 0;
e3.Strings && (O2 = parseInt(e3.Strings.Unique ?? e3.Strings.length ?? 0));
const I2 = e3.Strings ?? [];
for (let t3 = 0; t3 < O2; t3++) P2.push(I2[t3]?.t ?? "");
const V2 = /* @__PURE__ */ new Map();
let L2 = O2;
const N2 = (t3) => {
const e4 = V2.get(t3);
if (void 0 !== e4) return e4;
const s4 = L2;
return V2.set(t3, L2++), P2.push(t3), s4;
}, R2 = (gt("richstructure", e3, l3, s3, E2), gt("richdata", e3, l3, s3, E2), /* @__PURE__ */ new Map()), $2 = /* @__PURE__ */ new Map(), M2 = gt("people", e3, l3, s3);
let j2 = null;
if (M2.size > 0 && (j2 = M2.entries().next()?.value?.[1]?.persons, j2)) {
const t3 = j2.length;
for (let e4 = 0; e4 < t3; e4++) {
const t4 = j2[e4];
R2.set(t4.id, t4), R2.set(t4.displayName, t4);
}
}
const H2 = gt("themes", e3, l3, s3, E2);
let F2 = null;
if (H2 && H2.entries) {
let t3 = H2.entries().next();
t3?.value?.[1] && (F2 = t3.value[1]);
}
const X2 = new u(F2), B2 = gt("styles", e3, l3, s3, E2);
let W2 = B2.entries().next()?.value[1];
if (W2) {
W2 = JSON.parse(d(W2));
}
const _2 = gt("workbooks", e3, l3, s3, E2);
await Promise.all(C2);
const q2 = { ..._2.entries().next().value[1], styles: W2, theme: X2.toJSON() };
P2.length > 0 && (q2.strings = P2), j2 && j2.length > 0 && (q2.people = j2);
const z2 = { ...a2, resources: p3, json: q2 }, U2 = new g(z2);
return y3.forEach((t3) => {
t3.deleteReference(m3);
}), f2.endPersist(), U2;
} catch (t3) {
let e3 = "Unable to parse XLSX.";
throw t3 instanceof f && (e3 = "Unable to open XLSX. There are too many rows or columns."), new Error(e3, { cause: t3 });
}
}, toBufferXLSX: 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()) };
for (let i4 = 0; i4 < e2.length; i4++) {
const o3 = e2[i4];
for (let e3 = t2.length; e3 <= o3.min - 1; e3++) t2.push(s3);
const r3 = {};
void 0 !== o3.sz && (r3.width = o3.sz), void 0 !== o3.h && (r3.hidden = o3.h), void 0 !== o3.l && (r3.level = o3.l);
for (let e3 = o3.min; e3 <= o3.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 {
wt as a,
St as b,
xt as c,
Tt as d,
Et as i,
vt as p,
yt as r,
bt as t
};