@spinacia_/file-viewer
Version:
A file viewer component.
1,318 lines • 1.95 MB
JavaScript
import { defineComponent as Qt, ref as ml, computed as Rc, watch as lt, onMounted as Xc, onUnmounted as Hs, openBlock as yl, createElementBlock as wl, createBlock as Hc, mergeProps as Sc, createCommentVNode as nc, createVNode as Ps, withDirectives as vs, createElementVNode as O, renderSlot as Bs, vShow as fs, shallowRef as Ot, isRef as As, toRaw as gt, useCssVars as _s, nextTick as IZ, unref as Dt, Fragment as tc, normalizeStyle as wZ, renderList as qs, toDisplayString as xc, pushScopeId as $s, popScopeId as ld } from "vue";
import { renderAsync as RZ } from "docx-preview";
var iZ = {}, Mc = {};
Mc.byteLength = Zd;
Mc.toByteArray = dd;
Mc.fromByteArray = md;
var ql = [], Ul = [], td = typeof Uint8Array < "u" ? Uint8Array : Array, Dc = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
for (var ut = 0, cd = Dc.length; ut < cd; ++ut)
ql[ut] = Dc[ut], Ul[Dc.charCodeAt(ut)] = ut;
Ul[45] = 62;
Ul[95] = 63;
function cs(a) {
var l = a.length;
if (l % 4 > 0)
throw new Error("Invalid string. Length must be a multiple of 4");
var t = a.indexOf("=");
t === -1 && (t = l);
var c = t === l ? 0 : 4 - t % 4;
return [t, c];
}
function Zd(a) {
var l = cs(a), t = l[0], c = l[1];
return (t + c) * 3 / 4 - c;
}
function sd(a, l, t) {
return (l + t) * 3 / 4 - t;
}
function dd(a) {
var l, t = cs(a), c = t[0], Z = t[1], s = new td(sd(a, c, Z)), d = 0, i = Z > 0 ? c - 4 : c, b;
for (b = 0; b < i; b += 4)
l = Ul[a.charCodeAt(b)] << 18 | Ul[a.charCodeAt(b + 1)] << 12 | Ul[a.charCodeAt(b + 2)] << 6 | Ul[a.charCodeAt(b + 3)], s[d++] = l >> 16 & 255, s[d++] = l >> 8 & 255, s[d++] = l & 255;
return Z === 2 && (l = Ul[a.charCodeAt(b)] << 2 | Ul[a.charCodeAt(b + 1)] >> 4, s[d++] = l & 255), Z === 1 && (l = Ul[a.charCodeAt(b)] << 10 | Ul[a.charCodeAt(b + 1)] << 4 | Ul[a.charCodeAt(b + 2)] >> 2, s[d++] = l >> 8 & 255, s[d++] = l & 255), s;
}
function id(a) {
return ql[a >> 18 & 63] + ql[a >> 12 & 63] + ql[a >> 6 & 63] + ql[a & 63];
}
function bd(a, l, t) {
for (var c, Z = [], s = l; s < t; s += 3)
c = (a[s] << 16 & 16711680) + (a[s + 1] << 8 & 65280) + (a[s + 2] & 255), Z.push(id(c));
return Z.join("");
}
function md(a) {
for (var l, t = a.length, c = t % 3, Z = [], s = 16383, d = 0, i = t - c; d < i; d += s)
Z.push(bd(a, d, d + s > i ? i : d + s));
return c === 1 ? (l = a[t - 1], Z.push(
ql[l >> 2] + ql[l << 4 & 63] + "=="
)) : c === 2 && (l = (a[t - 2] << 8) + a[t - 1], Z.push(
ql[l >> 10] + ql[l >> 4 & 63] + ql[l << 2 & 63] + "="
)), Z.join("");
}
var bZ = {};
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
bZ.read = function(a, l, t, c, Z) {
var s, d, i = Z * 8 - c - 1, b = (1 << i) - 1, h = b >> 1, m = -7, W = t ? Z - 1 : 0, G = t ? -1 : 1, N = a[l + W];
for (W += G, s = N & (1 << -m) - 1, N >>= -m, m += i; m > 0; s = s * 256 + a[l + W], W += G, m -= 8)
;
for (d = s & (1 << -m) - 1, s >>= -m, m += c; m > 0; d = d * 256 + a[l + W], W += G, m -= 8)
;
if (s === 0)
s = 1 - h;
else {
if (s === b)
return d ? NaN : (N ? -1 : 1) * (1 / 0);
d = d + Math.pow(2, c), s = s - h;
}
return (N ? -1 : 1) * d * Math.pow(2, s - c);
};
bZ.write = function(a, l, t, c, Z, s) {
var d, i, b, h = s * 8 - Z - 1, m = (1 << h) - 1, W = m >> 1, G = Z === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0, N = c ? 0 : s - 1, M = c ? 1 : -1, X = l < 0 || l === 0 && 1 / l < 0 ? 1 : 0;
for (l = Math.abs(l), isNaN(l) || l === 1 / 0 ? (i = isNaN(l) ? 1 : 0, d = m) : (d = Math.floor(Math.log(l) / Math.LN2), l * (b = Math.pow(2, -d)) < 1 && (d--, b *= 2), d + W >= 1 ? l += G / b : l += G * Math.pow(2, 1 - W), l * b >= 2 && (d++, b /= 2), d + W >= m ? (i = 0, d = m) : d + W >= 1 ? (i = (l * b - 1) * Math.pow(2, Z), d = d + W) : (i = l * Math.pow(2, W - 1) * Math.pow(2, Z), d = 0)); Z >= 8; a[t + N] = i & 255, N += M, i /= 256, Z -= 8)
;
for (d = d << Z | i, h += Z; h > 0; a[t + N] = d & 255, N += M, d /= 256, h -= 8)
;
a[t + N - M] |= X * 128;
};
/*!
* The buffer module from node.js, for the browser.
*
* @author Feross Aboukhadijeh <https://feross.org>
* @license MIT
*/
(function(a) {
const l = Mc, t = bZ, c = typeof Symbol == "function" && typeof Symbol.for == "function" ? Symbol.for("nodejs.util.inspect.custom") : null;
a.Buffer = m, a.SlowBuffer = z, a.INSPECT_MAX_BYTES = 50;
const Z = 2147483647;
a.kMaxLength = Z;
const { Uint8Array: s, ArrayBuffer: d, SharedArrayBuffer: i } = globalThis;
m.TYPED_ARRAY_SUPPORT = b(), !m.TYPED_ARRAY_SUPPORT && typeof console < "u" && typeof console.error == "function" && console.error(
"This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."
);
function b() {
try {
const Y = new s(1), n = { foo: function() {
return 42;
} };
return Object.setPrototypeOf(n, s.prototype), Object.setPrototypeOf(Y, n), Y.foo() === 42;
} catch {
return !1;
}
}
Object.defineProperty(m.prototype, "parent", {
enumerable: !0,
get: function() {
if (m.isBuffer(this))
return this.buffer;
}
}), Object.defineProperty(m.prototype, "offset", {
enumerable: !0,
get: function() {
if (m.isBuffer(this))
return this.byteOffset;
}
});
function h(Y) {
if (Y > Z)
throw new RangeError('The value "' + Y + '" is invalid for option "size"');
const n = new s(Y);
return Object.setPrototypeOf(n, m.prototype), n;
}
function m(Y, n, e) {
if (typeof Y == "number") {
if (typeof n == "string")
throw new TypeError(
'The "string" argument must be of type string. Received type number'
);
return M(Y);
}
return W(Y, n, e);
}
m.poolSize = 8192;
function W(Y, n, e) {
if (typeof Y == "string")
return X(Y, n);
if (d.isView(Y))
return T(Y);
if (Y == null)
throw new TypeError(
"The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type " + typeof Y
);
if (Hl(Y, d) || Y && Hl(Y.buffer, d) || typeof i < "u" && (Hl(Y, i) || Y && Hl(Y.buffer, i)))
return p(Y, n, e);
if (typeof Y == "number")
throw new TypeError(
'The "value" argument must not be of type number. Received type number'
);
const y = Y.valueOf && Y.valueOf();
if (y != null && y !== Y)
return m.from(y, n, e);
const V = o(Y);
if (V) return V;
if (typeof Symbol < "u" && Symbol.toPrimitive != null && typeof Y[Symbol.toPrimitive] == "function")
return m.from(Y[Symbol.toPrimitive]("string"), n, e);
throw new TypeError(
"The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type " + typeof Y
);
}
m.from = function(Y, n, e) {
return W(Y, n, e);
}, Object.setPrototypeOf(m.prototype, s.prototype), Object.setPrototypeOf(m, s);
function G(Y) {
if (typeof Y != "number")
throw new TypeError('"size" argument must be of type number');
if (Y < 0)
throw new RangeError('The value "' + Y + '" is invalid for option "size"');
}
function N(Y, n, e) {
return G(Y), Y <= 0 ? h(Y) : n !== void 0 ? typeof e == "string" ? h(Y).fill(n, e) : h(Y).fill(n) : h(Y);
}
m.alloc = function(Y, n, e) {
return N(Y, n, e);
};
function M(Y) {
return G(Y), h(Y < 0 ? 0 : L(Y) | 0);
}
m.allocUnsafe = function(Y) {
return M(Y);
}, m.allocUnsafeSlow = function(Y) {
return M(Y);
};
function X(Y, n) {
if ((typeof n != "string" || n === "") && (n = "utf8"), !m.isEncoding(n))
throw new TypeError("Unknown encoding: " + n);
const e = R(Y, n) | 0;
let y = h(e);
const V = y.write(Y, n);
return V !== e && (y = y.slice(0, V)), y;
}
function u(Y) {
const n = Y.length < 0 ? 0 : L(Y.length) | 0, e = h(n);
for (let y = 0; y < n; y += 1)
e[y] = Y[y] & 255;
return e;
}
function T(Y) {
if (Hl(Y, s)) {
const n = new s(Y);
return p(n.buffer, n.byteOffset, n.byteLength);
}
return u(Y);
}
function p(Y, n, e) {
if (n < 0 || Y.byteLength < n)
throw new RangeError('"offset" is outside of buffer bounds');
if (Y.byteLength < n + (e || 0))
throw new RangeError('"length" is outside of buffer bounds');
let y;
return n === void 0 && e === void 0 ? y = new s(Y) : e === void 0 ? y = new s(Y, n) : y = new s(Y, n, e), Object.setPrototypeOf(y, m.prototype), y;
}
function o(Y) {
if (m.isBuffer(Y)) {
const n = L(Y.length) | 0, e = h(n);
return e.length === 0 || Y.copy(e, 0, 0, n), e;
}
if (Y.length !== void 0)
return typeof Y.length != "number" || wc(Y.length) ? h(0) : u(Y);
if (Y.type === "Buffer" && Array.isArray(Y.data))
return u(Y.data);
}
function L(Y) {
if (Y >= Z)
throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x" + Z.toString(16) + " bytes");
return Y | 0;
}
function z(Y) {
return +Y != Y && (Y = 0), m.alloc(+Y);
}
m.isBuffer = function(n) {
return n != null && n._isBuffer === !0 && n !== m.prototype;
}, m.compare = function(n, e) {
if (Hl(n, s) && (n = m.from(n, n.offset, n.byteLength)), Hl(e, s) && (e = m.from(e, e.offset, e.byteLength)), !m.isBuffer(n) || !m.isBuffer(e))
throw new TypeError(
'The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array'
);
if (n === e) return 0;
let y = n.length, V = e.length;
for (let I = 0, D = Math.min(y, V); I < D; ++I)
if (n[I] !== e[I]) {
y = n[I], V = e[I];
break;
}
return y < V ? -1 : V < y ? 1 : 0;
}, m.isEncoding = function(n) {
switch (String(n).toLowerCase()) {
case "hex":
case "utf8":
case "utf-8":
case "ascii":
case "latin1":
case "binary":
case "base64":
case "ucs2":
case "ucs-2":
case "utf16le":
case "utf-16le":
return !0;
default:
return !1;
}
}, m.concat = function(n, e) {
if (!Array.isArray(n))
throw new TypeError('"list" argument must be an Array of Buffers');
if (n.length === 0)
return m.alloc(0);
let y;
if (e === void 0)
for (e = 0, y = 0; y < n.length; ++y)
e += n[y].length;
const V = m.allocUnsafe(e);
let I = 0;
for (y = 0; y < n.length; ++y) {
let D = n[y];
if (Hl(D, s))
I + D.length > V.length ? (m.isBuffer(D) || (D = m.from(D)), D.copy(V, I)) : s.prototype.set.call(
V,
D,
I
);
else if (m.isBuffer(D))
D.copy(V, I);
else
throw new TypeError('"list" argument must be an Array of Buffers');
I += D.length;
}
return V;
};
function R(Y, n) {
if (m.isBuffer(Y))
return Y.length;
if (d.isView(Y) || Hl(Y, d))
return Y.byteLength;
if (typeof Y != "string")
throw new TypeError(
'The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type ' + typeof Y
);
const e = Y.length, y = arguments.length > 2 && arguments[2] === !0;
if (!y && e === 0) return 0;
let V = !1;
for (; ; )
switch (n) {
case "ascii":
case "latin1":
case "binary":
return e;
case "utf8":
case "utf-8":
return Ic(Y).length;
case "ucs2":
case "ucs-2":
case "utf16le":
case "utf-16le":
return e * 2;
case "hex":
return e >>> 1;
case "base64":
return zZ(Y).length;
default:
if (V)
return y ? -1 : Ic(Y).length;
n = ("" + n).toLowerCase(), V = !0;
}
}
m.byteLength = R;
function S(Y, n, e) {
let y = !1;
if ((n === void 0 || n < 0) && (n = 0), n > this.length || ((e === void 0 || e > this.length) && (e = this.length), e <= 0) || (e >>>= 0, n >>>= 0, e <= n))
return "";
for (Y || (Y = "utf8"); ; )
switch (Y) {
case "hex":
return dl(this, n, e);
case "utf8":
case "utf-8":
return j(this, n, e);
case "ascii":
return Yl(this, n, e);
case "latin1":
case "binary":
return Il(this, n, e);
case "base64":
return F(this, n, e);
case "ucs2":
case "ucs-2":
case "utf16le":
case "utf-16le":
return ll(this, n, e);
default:
if (y) throw new TypeError("Unknown encoding: " + Y);
Y = (Y + "").toLowerCase(), y = !0;
}
}
m.prototype._isBuffer = !0;
function w(Y, n, e) {
const y = Y[n];
Y[n] = Y[e], Y[e] = y;
}
m.prototype.swap16 = function() {
const n = this.length;
if (n % 2 !== 0)
throw new RangeError("Buffer size must be a multiple of 16-bits");
for (let e = 0; e < n; e += 2)
w(this, e, e + 1);
return this;
}, m.prototype.swap32 = function() {
const n = this.length;
if (n % 4 !== 0)
throw new RangeError("Buffer size must be a multiple of 32-bits");
for (let e = 0; e < n; e += 4)
w(this, e, e + 3), w(this, e + 1, e + 2);
return this;
}, m.prototype.swap64 = function() {
const n = this.length;
if (n % 8 !== 0)
throw new RangeError("Buffer size must be a multiple of 64-bits");
for (let e = 0; e < n; e += 8)
w(this, e, e + 7), w(this, e + 1, e + 6), w(this, e + 2, e + 5), w(this, e + 3, e + 4);
return this;
}, m.prototype.toString = function() {
const n = this.length;
return n === 0 ? "" : arguments.length === 0 ? j(this, 0, n) : S.apply(this, arguments);
}, m.prototype.toLocaleString = m.prototype.toString, m.prototype.equals = function(n) {
if (!m.isBuffer(n)) throw new TypeError("Argument must be a Buffer");
return this === n ? !0 : m.compare(this, n) === 0;
}, m.prototype.inspect = function() {
let n = "";
const e = a.INSPECT_MAX_BYTES;
return n = this.toString("hex", 0, e).replace(/(.{2})/g, "$1 ").trim(), this.length > e && (n += " ... "), "<Buffer " + n + ">";
}, c && (m.prototype[c] = m.prototype.inspect), m.prototype.compare = function(n, e, y, V, I) {
if (Hl(n, s) && (n = m.from(n, n.offset, n.byteLength)), !m.isBuffer(n))
throw new TypeError(
'The "target" argument must be one of type Buffer or Uint8Array. Received type ' + typeof n
);
if (e === void 0 && (e = 0), y === void 0 && (y = n ? n.length : 0), V === void 0 && (V = 0), I === void 0 && (I = this.length), e < 0 || y > n.length || V < 0 || I > this.length)
throw new RangeError("out of range index");
if (V >= I && e >= y)
return 0;
if (V >= I)
return -1;
if (e >= y)
return 1;
if (e >>>= 0, y >>>= 0, V >>>= 0, I >>>= 0, this === n) return 0;
let D = I - V, B = y - e;
const al = Math.min(D, B), sl = this.slice(V, I), hl = n.slice(e, y);
for (let $ = 0; $ < al; ++$)
if (sl[$] !== hl[$]) {
D = sl[$], B = hl[$];
break;
}
return D < B ? -1 : B < D ? 1 : 0;
};
function x(Y, n, e, y, V) {
if (Y.length === 0) return -1;
if (typeof e == "string" ? (y = e, e = 0) : e > 2147483647 ? e = 2147483647 : e < -2147483648 && (e = -2147483648), e = +e, wc(e) && (e = V ? 0 : Y.length - 1), e < 0 && (e = Y.length + e), e >= Y.length) {
if (V) return -1;
e = Y.length - 1;
} else if (e < 0)
if (V) e = 0;
else return -1;
if (typeof n == "string" && (n = m.from(n, y)), m.isBuffer(n))
return n.length === 0 ? -1 : J(Y, n, e, y, V);
if (typeof n == "number")
return n = n & 255, typeof s.prototype.indexOf == "function" ? V ? s.prototype.indexOf.call(Y, n, e) : s.prototype.lastIndexOf.call(Y, n, e) : J(Y, [n], e, y, V);
throw new TypeError("val must be string, number or Buffer");
}
function J(Y, n, e, y, V) {
let I = 1, D = Y.length, B = n.length;
if (y !== void 0 && (y = String(y).toLowerCase(), y === "ucs2" || y === "ucs-2" || y === "utf16le" || y === "utf-16le")) {
if (Y.length < 2 || n.length < 2)
return -1;
I = 2, D /= 2, B /= 2, e /= 2;
}
function al(hl, $) {
return I === 1 ? hl[$] : hl.readUInt16BE($ * I);
}
let sl;
if (V) {
let hl = -1;
for (sl = e; sl < D; sl++)
if (al(Y, sl) === al(n, hl === -1 ? 0 : sl - hl)) {
if (hl === -1 && (hl = sl), sl - hl + 1 === B) return hl * I;
} else
hl !== -1 && (sl -= sl - hl), hl = -1;
} else
for (e + B > D && (e = D - B), sl = e; sl >= 0; sl--) {
let hl = !0;
for (let $ = 0; $ < B; $++)
if (al(Y, sl + $) !== al(n, $)) {
hl = !1;
break;
}
if (hl) return sl;
}
return -1;
}
m.prototype.includes = function(n, e, y) {
return this.indexOf(n, e, y) !== -1;
}, m.prototype.indexOf = function(n, e, y) {
return x(this, n, e, y, !0);
}, m.prototype.lastIndexOf = function(n, e, y) {
return x(this, n, e, y, !1);
};
function r(Y, n, e, y) {
e = Number(e) || 0;
const V = Y.length - e;
y ? (y = Number(y), y > V && (y = V)) : y = V;
const I = n.length;
y > I / 2 && (y = I / 2);
let D;
for (D = 0; D < y; ++D) {
const B = parseInt(n.substr(D * 2, 2), 16);
if (wc(B)) return D;
Y[e + D] = B;
}
return D;
}
function E(Y, n, e, y) {
return lc(Ic(n, Y.length - e), Y, e, y);
}
function H(Y, n, e, y) {
return lc(gs(n), Y, e, y);
}
function g(Y, n, e, y) {
return lc(zZ(n), Y, e, y);
}
function tl(Y, n, e, y) {
return lc(Ks(n, Y.length - e), Y, e, y);
}
m.prototype.write = function(n, e, y, V) {
if (e === void 0)
V = "utf8", y = this.length, e = 0;
else if (y === void 0 && typeof e == "string")
V = e, y = this.length, e = 0;
else if (isFinite(e))
e = e >>> 0, isFinite(y) ? (y = y >>> 0, V === void 0 && (V = "utf8")) : (V = y, y = void 0);
else
throw new Error(
"Buffer.write(string, encoding, offset[, length]) is no longer supported"
);
const I = this.length - e;
if ((y === void 0 || y > I) && (y = I), n.length > 0 && (y < 0 || e < 0) || e > this.length)
throw new RangeError("Attempt to write outside buffer bounds");
V || (V = "utf8");
let D = !1;
for (; ; )
switch (V) {
case "hex":
return r(this, n, e, y);
case "utf8":
case "utf-8":
return E(this, n, e, y);
case "ascii":
case "latin1":
case "binary":
return H(this, n, e, y);
case "base64":
return g(this, n, e, y);
case "ucs2":
case "ucs-2":
case "utf16le":
case "utf-16le":
return tl(this, n, e, y);
default:
if (D) throw new TypeError("Unknown encoding: " + V);
V = ("" + V).toLowerCase(), D = !0;
}
}, m.prototype.toJSON = function() {
return {
type: "Buffer",
data: Array.prototype.slice.call(this._arr || this, 0)
};
};
function F(Y, n, e) {
return n === 0 && e === Y.length ? l.fromByteArray(Y) : l.fromByteArray(Y.slice(n, e));
}
function j(Y, n, e) {
e = Math.min(Y.length, e);
const y = [];
let V = n;
for (; V < e; ) {
const I = Y[V];
let D = null, B = I > 239 ? 4 : I > 223 ? 3 : I > 191 ? 2 : 1;
if (V + B <= e) {
let al, sl, hl, $;
switch (B) {
case 1:
I < 128 && (D = I);
break;
case 2:
al = Y[V + 1], (al & 192) === 128 && ($ = (I & 31) << 6 | al & 63, $ > 127 && (D = $));
break;
case 3:
al = Y[V + 1], sl = Y[V + 2], (al & 192) === 128 && (sl & 192) === 128 && ($ = (I & 15) << 12 | (al & 63) << 6 | sl & 63, $ > 2047 && ($ < 55296 || $ > 57343) && (D = $));
break;
case 4:
al = Y[V + 1], sl = Y[V + 2], hl = Y[V + 3], (al & 192) === 128 && (sl & 192) === 128 && (hl & 192) === 128 && ($ = (I & 15) << 18 | (al & 63) << 12 | (sl & 63) << 6 | hl & 63, $ > 65535 && $ < 1114112 && (D = $));
}
}
D === null ? (D = 65533, B = 1) : D > 65535 && (D -= 65536, y.push(D >>> 10 & 1023 | 55296), D = 56320 | D & 1023), y.push(D), V += B;
}
return A(y);
}
const Q = 4096;
function A(Y) {
const n = Y.length;
if (n <= Q)
return String.fromCharCode.apply(String, Y);
let e = "", y = 0;
for (; y < n; )
e += String.fromCharCode.apply(
String,
Y.slice(y, y += Q)
);
return e;
}
function Yl(Y, n, e) {
let y = "";
e = Math.min(Y.length, e);
for (let V = n; V < e; ++V)
y += String.fromCharCode(Y[V] & 127);
return y;
}
function Il(Y, n, e) {
let y = "";
e = Math.min(Y.length, e);
for (let V = n; V < e; ++V)
y += String.fromCharCode(Y[V]);
return y;
}
function dl(Y, n, e) {
const y = Y.length;
(!n || n < 0) && (n = 0), (!e || e < 0 || e > y) && (e = y);
let V = "";
for (let I = n; I < e; ++I)
V += Es[Y[I]];
return V;
}
function ll(Y, n, e) {
const y = Y.slice(n, e);
let V = "";
for (let I = 0; I < y.length - 1; I += 2)
V += String.fromCharCode(y[I] + y[I + 1] * 256);
return V;
}
m.prototype.slice = function(n, e) {
const y = this.length;
n = ~~n, e = e === void 0 ? y : ~~e, n < 0 ? (n += y, n < 0 && (n = 0)) : n > y && (n = y), e < 0 ? (e += y, e < 0 && (e = 0)) : e > y && (e = y), e < n && (e = n);
const V = this.subarray(n, e);
return Object.setPrototypeOf(V, m.prototype), V;
};
function cl(Y, n, e) {
if (Y % 1 !== 0 || Y < 0) throw new RangeError("offset is not uint");
if (Y + n > e) throw new RangeError("Trying to access beyond buffer length");
}
m.prototype.readUintLE = m.prototype.readUIntLE = function(n, e, y) {
n = n >>> 0, e = e >>> 0, y || cl(n, e, this.length);
let V = this[n], I = 1, D = 0;
for (; ++D < e && (I *= 256); )
V += this[n + D] * I;
return V;
}, m.prototype.readUintBE = m.prototype.readUIntBE = function(n, e, y) {
n = n >>> 0, e = e >>> 0, y || cl(n, e, this.length);
let V = this[n + --e], I = 1;
for (; e > 0 && (I *= 256); )
V += this[n + --e] * I;
return V;
}, m.prototype.readUint8 = m.prototype.readUInt8 = function(n, e) {
return n = n >>> 0, e || cl(n, 1, this.length), this[n];
}, m.prototype.readUint16LE = m.prototype.readUInt16LE = function(n, e) {
return n = n >>> 0, e || cl(n, 2, this.length), this[n] | this[n + 1] << 8;
}, m.prototype.readUint16BE = m.prototype.readUInt16BE = function(n, e) {
return n = n >>> 0, e || cl(n, 2, this.length), this[n] << 8 | this[n + 1];
}, m.prototype.readUint32LE = m.prototype.readUInt32LE = function(n, e) {
return n = n >>> 0, e || cl(n, 4, this.length), (this[n] | this[n + 1] << 8 | this[n + 2] << 16) + this[n + 3] * 16777216;
}, m.prototype.readUint32BE = m.prototype.readUInt32BE = function(n, e) {
return n = n >>> 0, e || cl(n, 4, this.length), this[n] * 16777216 + (this[n + 1] << 16 | this[n + 2] << 8 | this[n + 3]);
}, m.prototype.readBigUInt64LE = bt(function(n) {
n = n >>> 0, Yt(n, "offset");
const e = this[n], y = this[n + 7];
(e === void 0 || y === void 0) && xt(n, this.length - 8);
const V = e + this[++n] * 2 ** 8 + this[++n] * 2 ** 16 + this[++n] * 2 ** 24, I = this[++n] + this[++n] * 2 ** 8 + this[++n] * 2 ** 16 + y * 2 ** 24;
return BigInt(V) + (BigInt(I) << BigInt(32));
}), m.prototype.readBigUInt64BE = bt(function(n) {
n = n >>> 0, Yt(n, "offset");
const e = this[n], y = this[n + 7];
(e === void 0 || y === void 0) && xt(n, this.length - 8);
const V = e * 2 ** 24 + this[++n] * 2 ** 16 + this[++n] * 2 ** 8 + this[++n], I = this[++n] * 2 ** 24 + this[++n] * 2 ** 16 + this[++n] * 2 ** 8 + y;
return (BigInt(V) << BigInt(32)) + BigInt(I);
}), m.prototype.readIntLE = function(n, e, y) {
n = n >>> 0, e = e >>> 0, y || cl(n, e, this.length);
let V = this[n], I = 1, D = 0;
for (; ++D < e && (I *= 256); )
V += this[n + D] * I;
return I *= 128, V >= I && (V -= Math.pow(2, 8 * e)), V;
}, m.prototype.readIntBE = function(n, e, y) {
n = n >>> 0, e = e >>> 0, y || cl(n, e, this.length);
let V = e, I = 1, D = this[n + --V];
for (; V > 0 && (I *= 256); )
D += this[n + --V] * I;
return I *= 128, D >= I && (D -= Math.pow(2, 8 * e)), D;
}, m.prototype.readInt8 = function(n, e) {
return n = n >>> 0, e || cl(n, 1, this.length), this[n] & 128 ? (255 - this[n] + 1) * -1 : this[n];
}, m.prototype.readInt16LE = function(n, e) {
n = n >>> 0, e || cl(n, 2, this.length);
const y = this[n] | this[n + 1] << 8;
return y & 32768 ? y | 4294901760 : y;
}, m.prototype.readInt16BE = function(n, e) {
n = n >>> 0, e || cl(n, 2, this.length);
const y = this[n + 1] | this[n] << 8;
return y & 32768 ? y | 4294901760 : y;
}, m.prototype.readInt32LE = function(n, e) {
return n = n >>> 0, e || cl(n, 4, this.length), this[n] | this[n + 1] << 8 | this[n + 2] << 16 | this[n + 3] << 24;
}, m.prototype.readInt32BE = function(n, e) {
return n = n >>> 0, e || cl(n, 4, this.length), this[n] << 24 | this[n + 1] << 16 | this[n + 2] << 8 | this[n + 3];
}, m.prototype.readBigInt64LE = bt(function(n) {
n = n >>> 0, Yt(n, "offset");
const e = this[n], y = this[n + 7];
(e === void 0 || y === void 0) && xt(n, this.length - 8);
const V = this[n + 4] + this[n + 5] * 2 ** 8 + this[n + 6] * 2 ** 16 + (y << 24);
return (BigInt(V) << BigInt(32)) + BigInt(e + this[++n] * 2 ** 8 + this[++n] * 2 ** 16 + this[++n] * 2 ** 24);
}), m.prototype.readBigInt64BE = bt(function(n) {
n = n >>> 0, Yt(n, "offset");
const e = this[n], y = this[n + 7];
(e === void 0 || y === void 0) && xt(n, this.length - 8);
const V = (e << 24) + // Overflow
this[++n] * 2 ** 16 + this[++n] * 2 ** 8 + this[++n];
return (BigInt(V) << BigInt(32)) + BigInt(this[++n] * 2 ** 24 + this[++n] * 2 ** 16 + this[++n] * 2 ** 8 + y);
}), m.prototype.readFloatLE = function(n, e) {
return n = n >>> 0, e || cl(n, 4, this.length), t.read(this, n, !0, 23, 4);
}, m.prototype.readFloatBE = function(n, e) {
return n = n >>> 0, e || cl(n, 4, this.length), t.read(this, n, !1, 23, 4);
}, m.prototype.readDoubleLE = function(n, e) {
return n = n >>> 0, e || cl(n, 8, this.length), t.read(this, n, !0, 52, 8);
}, m.prototype.readDoubleBE = function(n, e) {
return n = n >>> 0, e || cl(n, 8, this.length), t.read(this, n, !1, 52, 8);
};
function il(Y, n, e, y, V, I) {
if (!m.isBuffer(Y)) throw new TypeError('"buffer" argument must be a Buffer instance');
if (n > V || n < I) throw new RangeError('"value" argument is out of bounds');
if (e + y > Y.length) throw new RangeError("Index out of range");
}
m.prototype.writeUintLE = m.prototype.writeUIntLE = function(n, e, y, V) {
if (n = +n, e = e >>> 0, y = y >>> 0, !V) {
const B = Math.pow(2, 8 * y) - 1;
il(this, n, e, y, B, 0);
}
let I = 1, D = 0;
for (this[e] = n & 255; ++D < y && (I *= 256); )
this[e + D] = n / I & 255;
return e + y;
}, m.prototype.writeUintBE = m.prototype.writeUIntBE = function(n, e, y, V) {
if (n = +n, e = e >>> 0, y = y >>> 0, !V) {
const B = Math.pow(2, 8 * y) - 1;
il(this, n, e, y, B, 0);
}
let I = y - 1, D = 1;
for (this[e + I] = n & 255; --I >= 0 && (D *= 256); )
this[e + I] = n / D & 255;
return e + y;
}, m.prototype.writeUint8 = m.prototype.writeUInt8 = function(n, e, y) {
return n = +n, e = e >>> 0, y || il(this, n, e, 1, 255, 0), this[e] = n & 255, e + 1;
}, m.prototype.writeUint16LE = m.prototype.writeUInt16LE = function(n, e, y) {
return n = +n, e = e >>> 0, y || il(this, n, e, 2, 65535, 0), this[e] = n & 255, this[e + 1] = n >>> 8, e + 2;
}, m.prototype.writeUint16BE = m.prototype.writeUInt16BE = function(n, e, y) {
return n = +n, e = e >>> 0, y || il(this, n, e, 2, 65535, 0), this[e] = n >>> 8, this[e + 1] = n & 255, e + 2;
}, m.prototype.writeUint32LE = m.prototype.writeUInt32LE = function(n, e, y) {
return n = +n, e = e >>> 0, y || il(this, n, e, 4, 4294967295, 0), this[e + 3] = n >>> 24, this[e + 2] = n >>> 16, this[e + 1] = n >>> 8, this[e] = n & 255, e + 4;
}, m.prototype.writeUint32BE = m.prototype.writeUInt32BE = function(n, e, y) {
return n = +n, e = e >>> 0, y || il(this, n, e, 4, 4294967295, 0), this[e] = n >>> 24, this[e + 1] = n >>> 16, this[e + 2] = n >>> 8, this[e + 3] = n & 255, e + 4;
};
function Cl(Y, n, e, y, V) {
LZ(n, y, V, Y, e, 7);
let I = Number(n & BigInt(4294967295));
Y[e++] = I, I = I >> 8, Y[e++] = I, I = I >> 8, Y[e++] = I, I = I >> 8, Y[e++] = I;
let D = Number(n >> BigInt(32) & BigInt(4294967295));
return Y[e++] = D, D = D >> 8, Y[e++] = D, D = D >> 8, Y[e++] = D, D = D >> 8, Y[e++] = D, e;
}
function Zl(Y, n, e, y, V) {
LZ(n, y, V, Y, e, 7);
let I = Number(n & BigInt(4294967295));
Y[e + 7] = I, I = I >> 8, Y[e + 6] = I, I = I >> 8, Y[e + 5] = I, I = I >> 8, Y[e + 4] = I;
let D = Number(n >> BigInt(32) & BigInt(4294967295));
return Y[e + 3] = D, D = D >> 8, Y[e + 2] = D, D = D >> 8, Y[e + 1] = D, D = D >> 8, Y[e] = D, e + 8;
}
m.prototype.writeBigUInt64LE = bt(function(n, e = 0) {
return Cl(this, n, e, BigInt(0), BigInt("0xffffffffffffffff"));
}), m.prototype.writeBigUInt64BE = bt(function(n, e = 0) {
return Zl(this, n, e, BigInt(0), BigInt("0xffffffffffffffff"));
}), m.prototype.writeIntLE = function(n, e, y, V) {
if (n = +n, e = e >>> 0, !V) {
const al = Math.pow(2, 8 * y - 1);
il(this, n, e, y, al - 1, -al);
}
let I = 0, D = 1, B = 0;
for (this[e] = n & 255; ++I < y && (D *= 256); )
n < 0 && B === 0 && this[e + I - 1] !== 0 && (B = 1), this[e + I] = (n / D >> 0) - B & 255;
return e + y;
}, m.prototype.writeIntBE = function(n, e, y, V) {
if (n = +n, e = e >>> 0, !V) {
const al = Math.pow(2, 8 * y - 1);
il(this, n, e, y, al - 1, -al);
}
let I = y - 1, D = 1, B = 0;
for (this[e + I] = n & 255; --I >= 0 && (D *= 256); )
n < 0 && B === 0 && this[e + I + 1] !== 0 && (B = 1), this[e + I] = (n / D >> 0) - B & 255;
return e + y;
}, m.prototype.writeInt8 = function(n, e, y) {
return n = +n, e = e >>> 0, y || il(this, n, e, 1, 127, -128), n < 0 && (n = 255 + n + 1), this[e] = n & 255, e + 1;
}, m.prototype.writeInt16LE = function(n, e, y) {
return n = +n, e = e >>> 0, y || il(this, n, e, 2, 32767, -32768), this[e] = n & 255, this[e + 1] = n >>> 8, e + 2;
}, m.prototype.writeInt16BE = function(n, e, y) {
return n = +n, e = e >>> 0, y || il(this, n, e, 2, 32767, -32768), this[e] = n >>> 8, this[e + 1] = n & 255, e + 2;
}, m.prototype.writeInt32LE = function(n, e, y) {
return n = +n, e = e >>> 0, y || il(this, n, e, 4, 2147483647, -2147483648), this[e] = n & 255, this[e + 1] = n >>> 8, this[e + 2] = n >>> 16, this[e + 3] = n >>> 24, e + 4;
}, m.prototype.writeInt32BE = function(n, e, y) {
return n = +n, e = e >>> 0, y || il(this, n, e, 4, 2147483647, -2147483648), n < 0 && (n = 4294967295 + n + 1), this[e] = n >>> 24, this[e + 1] = n >>> 16, this[e + 2] = n >>> 8, this[e + 3] = n & 255, e + 4;
}, m.prototype.writeBigInt64LE = bt(function(n, e = 0) {
return Cl(this, n, e, -BigInt("0x8000000000000000"), BigInt("0x7fffffffffffffff"));
}), m.prototype.writeBigInt64BE = bt(function(n, e = 0) {
return Zl(this, n, e, -BigInt("0x8000000000000000"), BigInt("0x7fffffffffffffff"));
});
function it(Y, n, e, y, V, I) {
if (e + y > Y.length) throw new RangeError("Index out of range");
if (e < 0) throw new RangeError("Index out of range");
}
function qt(Y, n, e, y, V) {
return n = +n, e = e >>> 0, V || it(Y, n, e, 4), t.write(Y, n, e, y, 23, 4), e + 4;
}
m.prototype.writeFloatLE = function(n, e, y) {
return qt(this, n, e, !0, y);
}, m.prototype.writeFloatBE = function(n, e, y) {
return qt(this, n, e, !1, y);
};
function $t(Y, n, e, y, V) {
return n = +n, e = e >>> 0, V || it(Y, n, e, 8), t.write(Y, n, e, y, 52, 8), e + 8;
}
m.prototype.writeDoubleLE = function(n, e, y) {
return $t(this, n, e, !0, y);
}, m.prototype.writeDoubleBE = function(n, e, y) {
return $t(this, n, e, !1, y);
}, m.prototype.copy = function(n, e, y, V) {
if (!m.isBuffer(n)) throw new TypeError("argument should be a Buffer");
if (y || (y = 0), !V && V !== 0 && (V = this.length), e >= n.length && (e = n.length), e || (e = 0), V > 0 && V < y && (V = y), V === y || n.length === 0 || this.length === 0) return 0;
if (e < 0)
throw new RangeError("targetStart out of bounds");
if (y < 0 || y >= this.length) throw new RangeError("Index out of range");
if (V < 0) throw new RangeError("sourceEnd out of bounds");
V > this.length && (V = this.length), n.length - e < V - y && (V = n.length - e + y);
const I = V - y;
return this === n && typeof s.prototype.copyWithin == "function" ? this.copyWithin(e, y, V) : s.prototype.set.call(
n,
this.subarray(y, V),
e
), I;
}, m.prototype.fill = function(n, e, y, V) {
if (typeof n == "string") {
if (typeof e == "string" ? (V = e, e = 0, y = this.length) : typeof y == "string" && (V = y, y = this.length), V !== void 0 && typeof V != "string")
throw new TypeError("encoding must be a string");
if (typeof V == "string" && !m.isEncoding(V))
throw new TypeError("Unknown encoding: " + V);
if (n.length === 1) {
const D = n.charCodeAt(0);
(V === "utf8" && D < 128 || V === "latin1") && (n = D);
}
} else typeof n == "number" ? n = n & 255 : typeof n == "boolean" && (n = Number(n));
if (e < 0 || this.length < e || this.length < y)
throw new RangeError("Out of range index");
if (y <= e)
return this;
e = e >>> 0, y = y === void 0 ? this.length : y >>> 0, n || (n = 0);
let I;
if (typeof n == "number")
for (I = e; I < y; ++I)
this[I] = n;
else {
const D = m.isBuffer(n) ? n : m.from(n, V), B = D.length;
if (B === 0)
throw new TypeError('The value "' + n + '" is invalid for argument "value"');
for (I = 0; I < y - e; ++I)
this[I + e] = D[I % B];
}
return this;
};
const Ql = {};
function ht(Y, n, e) {
Ql[Y] = class extends e {
constructor() {
super(), Object.defineProperty(this, "message", {
value: n.apply(this, arguments),
writable: !0,
configurable: !0
}), this.name = `${this.name} [${Y}]`, this.stack, delete this.name;
}
get code() {
return Y;
}
set code(V) {
Object.defineProperty(this, "code", {
configurable: !0,
enumerable: !0,
value: V,
writable: !0
});
}
toString() {
return `${this.name} [${Y}]: ${this.message}`;
}
};
}
ht(
"ERR_BUFFER_OUT_OF_BOUNDS",
function(Y) {
return Y ? `${Y} is outside of buffer bounds` : "Attempt to access memory outside buffer bounds";
},
RangeError
), ht(
"ERR_INVALID_ARG_TYPE",
function(Y, n) {
return `The "${Y}" argument must be of type number. Received type ${typeof n}`;
},
TypeError
), ht(
"ERR_OUT_OF_RANGE",
function(Y, n, e) {
let y = `The value of "${Y}" is out of range.`, V = e;
return Number.isInteger(e) && Math.abs(e) > 2 ** 32 ? V = St(String(e)) : typeof e == "bigint" && (V = String(e), (e > BigInt(2) ** BigInt(32) || e < -(BigInt(2) ** BigInt(32))) && (V = St(V)), V += "n"), y += ` It must be ${n}. Received ${V}`, y;
},
RangeError
);
function St(Y) {
let n = "", e = Y.length;
const y = Y[0] === "-" ? 1 : 0;
for (; e >= y + 4; e -= 3)
n = `_${Y.slice(e - 3, e)}${n}`;
return `${Y.slice(0, e)}${n}`;
}
function zc(Y, n, e) {
Yt(n, "offset"), (Y[n] === void 0 || Y[n + e] === void 0) && xt(n, Y.length - (e + 1));
}
function LZ(Y, n, e, y, V, I) {
if (Y > e || Y < n) {
const D = typeof n == "bigint" ? "n" : "";
let B;
throw n === 0 || n === BigInt(0) ? B = `>= 0${D} and < 2${D} ** ${(I + 1) * 8}${D}` : B = `>= -(2${D} ** ${(I + 1) * 8 - 1}${D}) and < 2 ** ${(I + 1) * 8 - 1}${D}`, new Ql.ERR_OUT_OF_RANGE("value", B, Y);
}
zc(y, V, I);
}
function Yt(Y, n) {
if (typeof Y != "number")
throw new Ql.ERR_INVALID_ARG_TYPE(n, "number", Y);
}
function xt(Y, n, e) {
throw Math.floor(Y) !== Y ? (Yt(Y, e), new Ql.ERR_OUT_OF_RANGE("offset", "an integer", Y)) : n < 0 ? new Ql.ERR_BUFFER_OUT_OF_BOUNDS() : new Ql.ERR_OUT_OF_RANGE(
"offset",
`>= 0 and <= ${n}`,
Y
);
}
const Cs = /[^+/0-9A-Za-z-_]/g;
function ks(Y) {
if (Y = Y.split("=")[0], Y = Y.trim().replace(Cs, ""), Y.length < 2) return "";
for (; Y.length % 4 !== 0; )
Y = Y + "=";
return Y;
}
function Ic(Y, n) {
n = n || 1 / 0;
let e;
const y = Y.length;
let V = null;
const I = [];
for (let D = 0; D < y; ++D) {
if (e = Y.charCodeAt(D), e > 55295 && e < 57344) {
if (!V) {
if (e > 56319) {
(n -= 3) > -1 && I.push(239, 191, 189);
continue;
} else if (D + 1 === y) {
(n -= 3) > -1 && I.push(239, 191, 189);
continue;
}
V = e;
continue;
}
if (e < 56320) {
(n -= 3) > -1 && I.push(239, 191, 189), V = e;
continue;
}
e = (V - 55296 << 10 | e - 56320) + 65536;
} else V && (n -= 3) > -1 && I.push(239, 191, 189);
if (V = null, e < 128) {
if ((n -= 1) < 0) break;
I.push(e);
} else if (e < 2048) {
if ((n -= 2) < 0) break;
I.push(
e >> 6 | 192,
e & 63 | 128
);
} else if (e < 65536) {
if ((n -= 3) < 0) break;
I.push(
e >> 12 | 224,
e >> 6 & 63 | 128,
e & 63 | 128
);
} else if (e < 1114112) {
if ((n -= 4) < 0) break;
I.push(
e >> 18 | 240,
e >> 12 & 63 | 128,
e >> 6 & 63 | 128,
e & 63 | 128
);
} else
throw new Error("Invalid code point");
}
return I;
}
function gs(Y) {
const n = [];
for (let e = 0; e < Y.length; ++e)
n.push(Y.charCodeAt(e) & 255);
return n;
}
function Ks(Y, n) {
let e, y, V;
const I = [];
for (let D = 0; D < Y.length && !((n -= 2) < 0); ++D)
e = Y.charCodeAt(D), y = e >> 8, V = e % 256, I.push(V), I.push(y);
return I;
}
function zZ(Y) {
return l.toByteArray(ks(Y));
}
function lc(Y, n, e, y) {
let V;
for (V = 0; V < y && !(V + e >= n.length || V >= Y.length); ++V)
n[V + e] = Y[V];
return V;
}
function Hl(Y, n) {
return Y instanceof n || Y != null && Y.constructor != null && Y.constructor.name != null && Y.constructor.name === n.name;
}
function wc(Y) {
return Y !== Y;
}
const Es = function() {
const Y = "0123456789abcdef", n = new Array(256);
for (let e = 0; e < 16; ++e) {
const y = e * 16;
for (let V = 0; V < 16; ++V)
n[y + V] = Y[e] + Y[V];
}
return n;
}();
function bt(Y) {
return typeof BigInt > "u" ? Qs : Y;
}
function Qs() {
throw new Error("BigInt not supported");
}
})(iZ);
const Pc = iZ.Buffer, vc = iZ.Buffer, ad = "End-Of-Stream";
class pt extends Error {
constructor() {
super(ad);
}
}
class hd {
constructor(l) {
this.position = 0, this.numBuffer = new Uint8Array(8), this.fileInfo = l || {};
}
/**
* Read a token from the tokenizer-stream
* @param token - The token to read
* @param position - If provided, the desired position in the tokenizer-stream
* @returns Promise with token data
*/
async readToken(l, t = this.position) {
const c = vc.alloc(l.len);
if (await this.readBuffer(c, { position: t }) < l.len)
throw new pt();
return l.get(c, 0);
}
/**
* Peek a token from the tokenizer-stream.
* @param token - Token to peek from the tokenizer-stream.
* @param position - Offset where to begin reading within the file. If position is null, data will be read from the current file position.
* @returns Promise with token data
*/
async peekToken(l, t = this.position) {
const c = vc.alloc(l.len);
if (await this.peekBuffer(c, { position: t }) < l.len)
throw new pt();
return l.get(c, 0);
}
/**
* Read a numeric token from the stream
* @param token - Numeric token
* @returns Promise with number
*/
async readNumber(l) {
if (await this.readBuffer(this.numBuffer, { length: l.len }) < l.len)
throw new pt();
return l.get(this.numBuffer, 0);
}
/**
* Read a numeric token from the stream
* @param token - Numeric token
* @returns Promise with number
*/
async peekNumber(l) {
if (await this.peekBuffer(this.numBuffer, { length: l.len }) < l.len)
throw new pt();
return l.get(this.numBuffer, 0);
}
/**
* Ignore number of bytes, advances the pointer in under tokenizer-stream.
* @param length - Number of bytes to ignore
* @return resolves the number of bytes ignored, equals length if this available, otherwise the number of bytes available
*/
async ignore(l) {
if (this.fileInfo.size !== void 0) {
const t = this.fileInfo.size - this.position;
if (l > t)
return this.position += t, t;
}
return this.position += l, l;
}
async close() {
}
normalizeOptions(l, t) {
if (t && t.position !== void 0 && t.position < this.position)
throw new Error("`options.position` must be equal or greater than `tokenizer.position`");
return t ? {
mayBeLess: t.mayBeLess === !0,
offset: t.offset ? t.offset : 0,
length: t.length ? t.length : l.length - (t.offset ? t.offset : 0),
position: t.position ? t.position : this.position
} : {
mayBeLess: !1,
offset: 0,
length: l.length,
position: this.position
};
}
}
class Wd extends hd {
/**
* Construct BufferTokenizer
* @param uint8Array - Uint8Array to tokenize
* @param fileInfo - Pass additional file information to the tokenizer
*/
constructor(l, t) {
super(t), this.uint8Array = l, this.fileInfo.size = this.fileInfo.size ? this.fileInfo.size : l.length;
}
/**
* Read buffer from tokenizer
* @param uint8Array - Uint8Array to tokenize
* @param options - Read behaviour options
* @returns {Promise<number>}
*/
async readBuffer(l, t) {
if (t && t.position) {
if (t.position < this.position)
throw new Error("`options.position` must be equal or greater than `tokenizer.position`");
this.position = t.position;
}
const c = await this.peekBuffer(l, t);
return this.position += c, c;
}
/**
* Peek (read ahead) buffer from tokenizer
* @param uint8Array
* @param options - Read behaviour options
* @returns {Promise<number>}
*/
async peekBuffer(l, t) {
const c = this.normalizeOptions(l, t), Z = Math.min(this.uint8Array.length - c.position, c.length);
if (!c.mayBeLess && Z < c.length)
throw new pt();
return l.set(this.uint8Array.subarray(c.position, c.position + Z), c.offset), Z;
}
async close() {
}
}
function nd(a, l) {
return new Wd(a, l);
}
class SZ {
constructor(l, t) {
this.len = l, this.encoding = t;
}
get(l, t) {
return vc.from(l).toString(this.encoding, t, t + this.len);
}
}
const Gd = 4100, ed = [137, 80, 78, 71, 13, 10, 26, 10], Nd = [255, 216, 255], Xd = [66, 77], Md = [71, 73, 70], Yd = [77, 90], ud = [80, 75, 3, 4], yd = [39, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], Td = [0, 0, 1, 0], mZ = (a) => [...a].map((l) => l.charCodeAt(0)), od = mZ("WEBP"), Vd = mZ("%PDF"), pd = mZ("SCRM"), Ld = (a, l = 0, t = 2) => new Promise((c, Z) => {
const s = new FileReader();
s.onload = () => {
c(s.result);
}, s.onerror = Z, s.readAsArrayBuffer(a.slice(l, t));
}), zd = (a) => new Promise((l, t) => {
const c = new FileReader();
c.onload = () => {
l(c.result);
}, c.onerror = t, c.readAsArrayBuffer(a);
}), kl = async (a, l, t = 0) => {
const c = await Ld(a, t, l.length + t), Z = new Uint8Array(c);
return l.every((s, d) => s === Z[d]);
}, xZ = async (a) => {
if (await kl(a, ed))
return { ext: "png", mime: "image/png" };
if (await kl(a, Nd))
return { ext: "jpg", mime: "image/jpeg" };
if (await kl(a, od, 8))
return { ext: "webp", mime: "image/webp" };
if (await kl(a, Xd))
return { ext: "bmp", mime: "image/bmp" };
if (await kl(a, Md))
return { ext: "gif", mime: "image/gif" };
if (await kl(a, Vd))
return { ext: "pdf", mime: "application/pdf" };
if (await kl(a, Td))
return { ext: "ico", mime: "image/x-icon" };
if (await kl(a, ud)) {
const l = Pc.alloc(Gd), t = new Uint8Array(await zd(a)), c = nd(t);
c.fileInfo.size === void 0 && (c.fileInfo.size = Number.MAX_SAFE_INTEGER), await c.peekBuffer(l, { length: 12, mayBeLess: !0 });
try {
for (; c.position + 30 < c.fileInfo.size; ) {
await c.readBuffer(l, { length: 30 });
const Z = {
compressedSize: l.readUInt32LE(18),
uncompressedSize: l.readUInt32LE(22),
filenameLength: l.readUInt16LE(26),
extraFieldLength: l.readUInt16LE(28),
filename: ""
};
if (Z.filename = await c.readToken(new SZ(Z.filenameLength, "utf-8")), await c.ignore(Z.extraFieldLength), Z.filename === "META-INF/mozilla.rsa")
return { ext: "xpi", mime: "application/x-xpinstall" };
if (Z.filename.endsWith(".rels") || Z.filename.endsWith(".xml"))
switch (Z.filename.split("/")[0]) {
case "_rels":
break;
case "word":
return {
ext: "docx",
mime: "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
};
case "ppt":
return {
ext: "pptx",
mime: "application/vnd.openxmlformats-officedocument.presentationml.presentation"
};
case "xl":
return {
ext: "xlsx",
mime: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
};
default:
break;
}
if (Z.filename.startsWith("xl/"))
return {
ext: "xlsx",
mime: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
};
if (Z.filename.startsWith("3D/") && Z.filename.endsWith(".model"))
return {
ext: "3mf",
mime: "model/3mf"
};
if (Z.filename === "mimetype" && Z.compressedSize === Z.uncompressedSize) {
let s = await c.readToken(new SZ(Z.compressedSize, "utf-8"));
switch (s = s.trim(), s) {
case "application/epub+zip":
return {
ext: "epub",
mime: "application/epub+zip"
};
case "application/vnd.oasis.opendocument.text":
return {
ext: "odt",
mime: "application/vnd.oasis.opendocument.text"
};
case "application/vnd.oasis.opendocument.spreadsheet":
return {
ext: "ods",
mime: "application/vnd.oasis.opendocument.spreadsheet"
};
case "application/vnd.oasis.opendocument.presentation":
return {
ext: "odp",
mime: "application/vnd.oasis.opendocument.presentation"
};
default:
break;
}
}
if (Z.compressedSize === 0) {
let s = -1;
for (; s < 0 && c.position < c.fileInfo.size; )
await c.peekBuffer(l, { mayBeLess: !0 }), s = l.indexOf("504B0304", 0, "hex"), await c.ignore(s >= 0 ? s : l.length);
} else
await c.ignore(Z.compressedSize);
}
} catch (Z) {
if (!(Z instanceof pt))
throw Z;
}
return { ext: "zip", mime: "application/zip" };
}
if (await kl(a, Yd))
return { ext: "exe", mime: "application/x-msdownload" };
if (await kl(a, pd))
return { ext: "s3m", mime: "audio/x-s3m" };
if (await kl(a, yd, 2))
return { ext: "shp", mime: "application/x-esri-shape" };
switch (a.type) {
case "text/plain":
return { ext: "txt", mime: "text/plain" };
case "image/svg+xml":
return { ext: "svg", mime: "image/svg+xml" };
}
return { ext: "unknown", mime: "unknown" };
}, jc = ["png", "jpg", "webp", "bmp", "gif", "svg", "ico"], Jc = ["pdf"], Fc = ["docx"], $m = ["xlsx", "csv"], rc = ["txt"], la = ["zip"];
function Id(a) {
return a && a.__esModule && Object.prototype.hasOwnProperty.call(a, "default") ? a.default : a;
}
var Zs = { exports: {} }, Gl = Zs.exports = {}, fl, Al;
function Bc() {
throw new Error("setTimeout has not been defined");
}
function fc() {
throw new Error("clearTimeout has not been defined");
}
(function() {
try {
typeof setTimeout == "function" ? fl = setTimeout : fl = Bc;
} catch {
fl = Bc;
}
try {
typeof clearTimeout == "function" ? Al = clearTimeout : Al = fc;
} catch {
Al = fc;
}
})();
function ss(a) {
if (fl === setTimeout)
return setTimeout(a, 0);
if ((fl === Bc || !fl) && setTimeout)
return fl = setTimeout, setTimeout(a, 0);
try {
return fl(a, 0);
} catch {
try {
return fl.call(null, a, 0);
} catch