UNPKG

pgm-utils

Version:

A PGM Utils

795 lines (791 loc) 172 kB
(function(global2, factory) { typeof exports === "object" && typeof module !== "undefined" ? module.exports = factory() : typeof define === "function" && define.amd ? define(factory) : (global2 = typeof globalThis !== "undefined" ? globalThis : global2 || self, global2.PGMUtils = factory()); })(this, (function() { "use strict";var __defProp = Object.defineProperty; var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value); var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {}; function getDefaultExportFromCjs(x) { return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x; } function commonjsRequire(path) { throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.'); } var jszip_min = { exports: {} }; /*! JSZip v3.10.1 - A JavaScript class for generating and reading zip files <http://stuartk.com/jszip> (c) 2009-2016 Stuart Knightley <stuart [at] stuartk.com> Dual licenced under the MIT license or GPLv3. See https://raw.github.com/Stuk/jszip/main/LICENSE.markdown. JSZip uses the library pako released under the MIT license : https://github.com/nodeca/pako/blob/main/LICENSE */ var hasRequiredJszip_min; function requireJszip_min() { if (hasRequiredJszip_min) return jszip_min.exports; hasRequiredJszip_min = 1; (function(module2, exports2) { !(function(e) { module2.exports = e(); })(function() { return (function s(a, o, h) { function u(r, e2) { if (!o[r]) { if (!a[r]) { var t = "function" == typeof commonjsRequire && commonjsRequire; if (!e2 && t) return t(r, true); if (l) return l(r, true); var n = new Error("Cannot find module '" + r + "'"); throw n.code = "MODULE_NOT_FOUND", n; } var i = o[r] = { exports: {} }; a[r][0].call(i.exports, function(e3) { var t2 = a[r][1][e3]; return u(t2 || e3); }, i, i.exports, s, a, o, h); } return o[r].exports; } for (var l = "function" == typeof commonjsRequire && commonjsRequire, e = 0; e < h.length; e++) u(h[e]); return u; })({ 1: [function(e, t, r) { var d = e("./utils"), c = e("./support"), p = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; r.encode = function(e2) { for (var t2, r2, n, i, s, a, o, h = [], u = 0, l = e2.length, f = l, c2 = "string" !== d.getTypeOf(e2); u < e2.length; ) f = l - u, n = c2 ? (t2 = e2[u++], r2 = u < l ? e2[u++] : 0, u < l ? e2[u++] : 0) : (t2 = e2.charCodeAt(u++), r2 = u < l ? e2.charCodeAt(u++) : 0, u < l ? e2.charCodeAt(u++) : 0), i = t2 >> 2, s = (3 & t2) << 4 | r2 >> 4, a = 1 < f ? (15 & r2) << 2 | n >> 6 : 64, o = 2 < f ? 63 & n : 64, h.push(p.charAt(i) + p.charAt(s) + p.charAt(a) + p.charAt(o)); return h.join(""); }, r.decode = function(e2) { var t2, r2, n, i, s, a, o = 0, h = 0, u = "data:"; if (e2.substr(0, u.length) === u) throw new Error("Invalid base64 input, it looks like a data url."); var l, f = 3 * (e2 = e2.replace(/[^A-Za-z0-9+/=]/g, "")).length / 4; if (e2.charAt(e2.length - 1) === p.charAt(64) && f--, e2.charAt(e2.length - 2) === p.charAt(64) && f--, f % 1 != 0) throw new Error("Invalid base64 input, bad content length."); for (l = c.uint8array ? new Uint8Array(0 | f) : new Array(0 | f); o < e2.length; ) t2 = p.indexOf(e2.charAt(o++)) << 2 | (i = p.indexOf(e2.charAt(o++))) >> 4, r2 = (15 & i) << 4 | (s = p.indexOf(e2.charAt(o++))) >> 2, n = (3 & s) << 6 | (a = p.indexOf(e2.charAt(o++))), l[h++] = t2, 64 !== s && (l[h++] = r2), 64 !== a && (l[h++] = n); return l; }; }, { "./support": 30, "./utils": 32 }], 2: [function(e, t, r) { var n = e("./external"), i = e("./stream/DataWorker"), s = e("./stream/Crc32Probe"), a = e("./stream/DataLengthProbe"); function o(e2, t2, r2, n2, i2) { this.compressedSize = e2, this.uncompressedSize = t2, this.crc32 = r2, this.compression = n2, this.compressedContent = i2; } o.prototype = { getContentWorker: function() { var e2 = new i(n.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new a("data_length")), t2 = this; return e2.on("end", function() { if (this.streamInfo.data_length !== t2.uncompressedSize) throw new Error("Bug : uncompressed data size mismatch"); }), e2; }, getCompressedWorker: function() { return new i(n.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize", this.compressedSize).withStreamInfo("uncompressedSize", this.uncompressedSize).withStreamInfo("crc32", this.crc32).withStreamInfo("compression", this.compression); } }, o.createWorkerFrom = function(e2, t2, r2) { return e2.pipe(new s()).pipe(new a("uncompressedSize")).pipe(t2.compressWorker(r2)).pipe(new a("compressedSize")).withStreamInfo("compression", t2); }, t.exports = o; }, { "./external": 6, "./stream/Crc32Probe": 25, "./stream/DataLengthProbe": 26, "./stream/DataWorker": 27 }], 3: [function(e, t, r) { var n = e("./stream/GenericWorker"); r.STORE = { magic: "\0\0", compressWorker: function() { return new n("STORE compression"); }, uncompressWorker: function() { return new n("STORE decompression"); } }, r.DEFLATE = e("./flate"); }, { "./flate": 7, "./stream/GenericWorker": 28 }], 4: [function(e, t, r) { var n = e("./utils"); var o = (function() { for (var e2, t2 = [], r2 = 0; r2 < 256; r2++) { e2 = r2; for (var n2 = 0; n2 < 8; n2++) e2 = 1 & e2 ? 3988292384 ^ e2 >>> 1 : e2 >>> 1; t2[r2] = e2; } return t2; })(); t.exports = function(e2, t2) { return void 0 !== e2 && e2.length ? "string" !== n.getTypeOf(e2) ? (function(e3, t3, r2, n2) { var i = o, s = n2 + r2; e3 ^= -1; for (var a = n2; a < s; a++) e3 = e3 >>> 8 ^ i[255 & (e3 ^ t3[a])]; return -1 ^ e3; })(0 | t2, e2, e2.length, 0) : (function(e3, t3, r2, n2) { var i = o, s = n2 + r2; e3 ^= -1; for (var a = n2; a < s; a++) e3 = e3 >>> 8 ^ i[255 & (e3 ^ t3.charCodeAt(a))]; return -1 ^ e3; })(0 | t2, e2, e2.length, 0) : 0; }; }, { "./utils": 32 }], 5: [function(e, t, r) { r.base64 = false, r.binary = false, r.dir = false, r.createFolders = true, r.date = null, r.compression = null, r.compressionOptions = null, r.comment = null, r.unixPermissions = null, r.dosPermissions = null; }, {}], 6: [function(e, t, r) { var n = null; n = "undefined" != typeof Promise ? Promise : e("lie"), t.exports = { Promise: n }; }, { lie: 37 }], 7: [function(e, t, r) { var n = "undefined" != typeof Uint8Array && "undefined" != typeof Uint16Array && "undefined" != typeof Uint32Array, i = e("pako"), s = e("./utils"), a = e("./stream/GenericWorker"), o = n ? "uint8array" : "array"; function h(e2, t2) { a.call(this, "FlateWorker/" + e2), this._pako = null, this._pakoAction = e2, this._pakoOptions = t2, this.meta = {}; } r.magic = "\b\0", s.inherits(h, a), h.prototype.processChunk = function(e2) { this.meta = e2.meta, null === this._pako && this._createPako(), this._pako.push(s.transformTo(o, e2.data), false); }, h.prototype.flush = function() { a.prototype.flush.call(this), null === this._pako && this._createPako(), this._pako.push([], true); }, h.prototype.cleanUp = function() { a.prototype.cleanUp.call(this), this._pako = null; }, h.prototype._createPako = function() { this._pako = new i[this._pakoAction]({ raw: true, level: this._pakoOptions.level || -1 }); var t2 = this; this._pako.onData = function(e2) { t2.push({ data: e2, meta: t2.meta }); }; }, r.compressWorker = function(e2) { return new h("Deflate", e2); }, r.uncompressWorker = function() { return new h("Inflate", {}); }; }, { "./stream/GenericWorker": 28, "./utils": 32, pako: 38 }], 8: [function(e, t, r) { function A(e2, t2) { var r2, n2 = ""; for (r2 = 0; r2 < t2; r2++) n2 += String.fromCharCode(255 & e2), e2 >>>= 8; return n2; } function n(e2, t2, r2, n2, i2, s2) { var a, o, h = e2.file, u = e2.compression, l = s2 !== O.utf8encode, f = I.transformTo("string", s2(h.name)), c = I.transformTo("string", O.utf8encode(h.name)), d = h.comment, p = I.transformTo("string", s2(d)), m = I.transformTo("string", O.utf8encode(d)), _ = c.length !== h.name.length, g = m.length !== d.length, b = "", v = "", y = "", w = h.dir, k = h.date, x = { crc32: 0, compressedSize: 0, uncompressedSize: 0 }; t2 && !r2 || (x.crc32 = e2.crc32, x.compressedSize = e2.compressedSize, x.uncompressedSize = e2.uncompressedSize); var S = 0; t2 && (S |= 8), l || !_ && !g || (S |= 2048); var z = 0, C = 0; w && (z |= 16), "UNIX" === i2 ? (C = 798, z |= (function(e3, t3) { var r3 = e3; return e3 || (r3 = t3 ? 16893 : 33204), (65535 & r3) << 16; })(h.unixPermissions, w)) : (C = 20, z |= (function(e3) { return 63 & (e3 || 0); })(h.dosPermissions)), a = k.getUTCHours(), a <<= 6, a |= k.getUTCMinutes(), a <<= 5, a |= k.getUTCSeconds() / 2, o = k.getUTCFullYear() - 1980, o <<= 4, o |= k.getUTCMonth() + 1, o <<= 5, o |= k.getUTCDate(), _ && (v = A(1, 1) + A(B(f), 4) + c, b += "up" + A(v.length, 2) + v), g && (y = A(1, 1) + A(B(p), 4) + m, b += "uc" + A(y.length, 2) + y); var E = ""; return E += "\n\0", E += A(S, 2), E += u.magic, E += A(a, 2), E += A(o, 2), E += A(x.crc32, 4), E += A(x.compressedSize, 4), E += A(x.uncompressedSize, 4), E += A(f.length, 2), E += A(b.length, 2), { fileRecord: R.LOCAL_FILE_HEADER + E + f + b, dirRecord: R.CENTRAL_FILE_HEADER + A(C, 2) + E + A(p.length, 2) + "\0\0\0\0" + A(z, 4) + A(n2, 4) + f + b + p }; } var I = e("../utils"), i = e("../stream/GenericWorker"), O = e("../utf8"), B = e("../crc32"), R = e("../signature"); function s(e2, t2, r2, n2) { i.call(this, "ZipFileWorker"), this.bytesWritten = 0, this.zipComment = t2, this.zipPlatform = r2, this.encodeFileName = n2, this.streamFiles = e2, this.accumulate = false, this.contentBuffer = [], this.dirRecords = [], this.currentSourceOffset = 0, this.entriesCount = 0, this.currentFile = null, this._sources = []; } I.inherits(s, i), s.prototype.push = function(e2) { var t2 = e2.meta.percent || 0, r2 = this.entriesCount, n2 = this._sources.length; this.accumulate ? this.contentBuffer.push(e2) : (this.bytesWritten += e2.data.length, i.prototype.push.call(this, { data: e2.data, meta: { currentFile: this.currentFile, percent: r2 ? (t2 + 100 * (r2 - n2 - 1)) / r2 : 100 } })); }, s.prototype.openedSource = function(e2) { this.currentSourceOffset = this.bytesWritten, this.currentFile = e2.file.name; var t2 = this.streamFiles && !e2.file.dir; if (t2) { var r2 = n(e2, t2, false, this.currentSourceOffset, this.zipPlatform, this.encodeFileName); this.push({ data: r2.fileRecord, meta: { percent: 0 } }); } else this.accumulate = true; }, s.prototype.closedSource = function(e2) { this.accumulate = false; var t2 = this.streamFiles && !e2.file.dir, r2 = n(e2, t2, true, this.currentSourceOffset, this.zipPlatform, this.encodeFileName); if (this.dirRecords.push(r2.dirRecord), t2) this.push({ data: (function(e3) { return R.DATA_DESCRIPTOR + A(e3.crc32, 4) + A(e3.compressedSize, 4) + A(e3.uncompressedSize, 4); })(e2), meta: { percent: 100 } }); else for (this.push({ data: r2.fileRecord, meta: { percent: 0 } }); this.contentBuffer.length; ) this.push(this.contentBuffer.shift()); this.currentFile = null; }, s.prototype.flush = function() { for (var e2 = this.bytesWritten, t2 = 0; t2 < this.dirRecords.length; t2++) this.push({ data: this.dirRecords[t2], meta: { percent: 100 } }); var r2 = this.bytesWritten - e2, n2 = (function(e3, t3, r3, n3, i2) { var s2 = I.transformTo("string", i2(n3)); return R.CENTRAL_DIRECTORY_END + "\0\0\0\0" + A(e3, 2) + A(e3, 2) + A(t3, 4) + A(r3, 4) + A(s2.length, 2) + s2; })(this.dirRecords.length, r2, e2, this.zipComment, this.encodeFileName); this.push({ data: n2, meta: { percent: 100 } }); }, s.prototype.prepareNextSource = function() { this.previous = this._sources.shift(), this.openedSource(this.previous.streamInfo), this.isPaused ? this.previous.pause() : this.previous.resume(); }, s.prototype.registerPrevious = function(e2) { this._sources.push(e2); var t2 = this; return e2.on("data", function(e3) { t2.processChunk(e3); }), e2.on("end", function() { t2.closedSource(t2.previous.streamInfo), t2._sources.length ? t2.prepareNextSource() : t2.end(); }), e2.on("error", function(e3) { t2.error(e3); }), this; }, s.prototype.resume = function() { return !!i.prototype.resume.call(this) && (!this.previous && this._sources.length ? (this.prepareNextSource(), true) : this.previous || this._sources.length || this.generatedError ? void 0 : (this.end(), true)); }, s.prototype.error = function(e2) { var t2 = this._sources; if (!i.prototype.error.call(this, e2)) return false; for (var r2 = 0; r2 < t2.length; r2++) try { t2[r2].error(e2); } catch (e3) { } return true; }, s.prototype.lock = function() { i.prototype.lock.call(this); for (var e2 = this._sources, t2 = 0; t2 < e2.length; t2++) e2[t2].lock(); }, t.exports = s; }, { "../crc32": 4, "../signature": 23, "../stream/GenericWorker": 28, "../utf8": 31, "../utils": 32 }], 9: [function(e, t, r) { var u = e("../compressions"), n = e("./ZipFileWorker"); r.generateWorker = function(e2, a, t2) { var o = new n(a.streamFiles, t2, a.platform, a.encodeFileName), h = 0; try { e2.forEach(function(e3, t3) { h++; var r2 = (function(e4, t4) { var r3 = e4 || t4, n3 = u[r3]; if (!n3) throw new Error(r3 + " is not a valid compression method !"); return n3; })(t3.options.compression, a.compression), n2 = t3.options.compressionOptions || a.compressionOptions || {}, i = t3.dir, s = t3.date; t3._compressWorker(r2, n2).withStreamInfo("file", { name: e3, dir: i, date: s, comment: t3.comment || "", unixPermissions: t3.unixPermissions, dosPermissions: t3.dosPermissions }).pipe(o); }), o.entriesCount = h; } catch (e3) { o.error(e3); } return o; }; }, { "../compressions": 3, "./ZipFileWorker": 8 }], 10: [function(e, t, r) { function n() { if (!(this instanceof n)) return new n(); if (arguments.length) throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide."); this.files = /* @__PURE__ */ Object.create(null), this.comment = null, this.root = "", this.clone = function() { var e2 = new n(); for (var t2 in this) "function" != typeof this[t2] && (e2[t2] = this[t2]); return e2; }; } (n.prototype = e("./object")).loadAsync = e("./load"), n.support = e("./support"), n.defaults = e("./defaults"), n.version = "3.10.1", n.loadAsync = function(e2, t2) { return new n().loadAsync(e2, t2); }, n.external = e("./external"), t.exports = n; }, { "./defaults": 5, "./external": 6, "./load": 11, "./object": 15, "./support": 30 }], 11: [function(e, t, r) { var u = e("./utils"), i = e("./external"), n = e("./utf8"), s = e("./zipEntries"), a = e("./stream/Crc32Probe"), l = e("./nodejsUtils"); function f(n2) { return new i.Promise(function(e2, t2) { var r2 = n2.decompressed.getContentWorker().pipe(new a()); r2.on("error", function(e3) { t2(e3); }).on("end", function() { r2.streamInfo.crc32 !== n2.decompressed.crc32 ? t2(new Error("Corrupted zip : CRC32 mismatch")) : e2(); }).resume(); }); } t.exports = function(e2, o) { var h = this; return o = u.extend(o || {}, { base64: false, checkCRC32: false, optimizedBinaryString: false, createFolders: false, decodeFileName: n.utf8decode }), l.isNode && l.isStream(e2) ? i.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")) : u.prepareContent("the loaded zip file", e2, true, o.optimizedBinaryString, o.base64).then(function(e3) { var t2 = new s(o); return t2.load(e3), t2; }).then(function(e3) { var t2 = [i.Promise.resolve(e3)], r2 = e3.files; if (o.checkCRC32) for (var n2 = 0; n2 < r2.length; n2++) t2.push(f(r2[n2])); return i.Promise.all(t2); }).then(function(e3) { for (var t2 = e3.shift(), r2 = t2.files, n2 = 0; n2 < r2.length; n2++) { var i2 = r2[n2], s2 = i2.fileNameStr, a2 = u.resolve(i2.fileNameStr); h.file(a2, i2.decompressed, { binary: true, optimizedBinaryString: true, date: i2.date, dir: i2.dir, comment: i2.fileCommentStr.length ? i2.fileCommentStr : null, unixPermissions: i2.unixPermissions, dosPermissions: i2.dosPermissions, createFolders: o.createFolders }), i2.dir || (h.file(a2).unsafeOriginalName = s2); } return t2.zipComment.length && (h.comment = t2.zipComment), h; }); }; }, { "./external": 6, "./nodejsUtils": 14, "./stream/Crc32Probe": 25, "./utf8": 31, "./utils": 32, "./zipEntries": 33 }], 12: [function(e, t, r) { var n = e("../utils"), i = e("../stream/GenericWorker"); function s(e2, t2) { i.call(this, "Nodejs stream input adapter for " + e2), this._upstreamEnded = false, this._bindStream(t2); } n.inherits(s, i), s.prototype._bindStream = function(e2) { var t2 = this; (this._stream = e2).pause(), e2.on("data", function(e3) { t2.push({ data: e3, meta: { percent: 0 } }); }).on("error", function(e3) { t2.isPaused ? this.generatedError = e3 : t2.error(e3); }).on("end", function() { t2.isPaused ? t2._upstreamEnded = true : t2.end(); }); }, s.prototype.pause = function() { return !!i.prototype.pause.call(this) && (this._stream.pause(), true); }, s.prototype.resume = function() { return !!i.prototype.resume.call(this) && (this._upstreamEnded ? this.end() : this._stream.resume(), true); }, t.exports = s; }, { "../stream/GenericWorker": 28, "../utils": 32 }], 13: [function(e, t, r) { var i = e("readable-stream").Readable; function n(e2, t2, r2) { i.call(this, t2), this._helper = e2; var n2 = this; e2.on("data", function(e3, t3) { n2.push(e3) || n2._helper.pause(), r2 && r2(t3); }).on("error", function(e3) { n2.emit("error", e3); }).on("end", function() { n2.push(null); }); } e("../utils").inherits(n, i), n.prototype._read = function() { this._helper.resume(); }, t.exports = n; }, { "../utils": 32, "readable-stream": 16 }], 14: [function(e, t, r) { t.exports = { isNode: "undefined" != typeof Buffer, newBufferFrom: function(e2, t2) { if (Buffer.from && Buffer.from !== Uint8Array.from) return Buffer.from(e2, t2); if ("number" == typeof e2) throw new Error('The "data" argument must not be a number'); return new Buffer(e2, t2); }, allocBuffer: function(e2) { if (Buffer.alloc) return Buffer.alloc(e2); var t2 = new Buffer(e2); return t2.fill(0), t2; }, isBuffer: function(e2) { return Buffer.isBuffer(e2); }, isStream: function(e2) { return e2 && "function" == typeof e2.on && "function" == typeof e2.pause && "function" == typeof e2.resume; } }; }, {}], 15: [function(e, t, r) { function s(e2, t2, r2) { var n2, i2 = u.getTypeOf(t2), s2 = u.extend(r2 || {}, f); s2.date = s2.date || /* @__PURE__ */ new Date(), null !== s2.compression && (s2.compression = s2.compression.toUpperCase()), "string" == typeof s2.unixPermissions && (s2.unixPermissions = parseInt(s2.unixPermissions, 8)), s2.unixPermissions && 16384 & s2.unixPermissions && (s2.dir = true), s2.dosPermissions && 16 & s2.dosPermissions && (s2.dir = true), s2.dir && (e2 = g(e2)), s2.createFolders && (n2 = _(e2)) && b.call(this, n2, true); var a2 = "string" === i2 && false === s2.binary && false === s2.base64; r2 && void 0 !== r2.binary || (s2.binary = !a2), (t2 instanceof c && 0 === t2.uncompressedSize || s2.dir || !t2 || 0 === t2.length) && (s2.base64 = false, s2.binary = true, t2 = "", s2.compression = "STORE", i2 = "string"); var o2 = null; o2 = t2 instanceof c || t2 instanceof l ? t2 : p.isNode && p.isStream(t2) ? new m(e2, t2) : u.prepareContent(e2, t2, s2.binary, s2.optimizedBinaryString, s2.base64); var h2 = new d(e2, o2, s2); this.files[e2] = h2; } var i = e("./utf8"), u = e("./utils"), l = e("./stream/GenericWorker"), a = e("./stream/StreamHelper"), f = e("./defaults"), c = e("./compressedObject"), d = e("./zipObject"), o = e("./generate"), p = e("./nodejsUtils"), m = e("./nodejs/NodejsStreamInputAdapter"), _ = function(e2) { "/" === e2.slice(-1) && (e2 = e2.substring(0, e2.length - 1)); var t2 = e2.lastIndexOf("/"); return 0 < t2 ? e2.substring(0, t2) : ""; }, g = function(e2) { return "/" !== e2.slice(-1) && (e2 += "/"), e2; }, b = function(e2, t2) { return t2 = void 0 !== t2 ? t2 : f.createFolders, e2 = g(e2), this.files[e2] || s.call(this, e2, null, { dir: true, createFolders: t2 }), this.files[e2]; }; function h(e2) { return "[object RegExp]" === Object.prototype.toString.call(e2); } var n = { load: function() { throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide."); }, forEach: function(e2) { var t2, r2, n2; for (t2 in this.files) n2 = this.files[t2], (r2 = t2.slice(this.root.length, t2.length)) && t2.slice(0, this.root.length) === this.root && e2(r2, n2); }, filter: function(r2) { var n2 = []; return this.forEach(function(e2, t2) { r2(e2, t2) && n2.push(t2); }), n2; }, file: function(e2, t2, r2) { if (1 !== arguments.length) return e2 = this.root + e2, s.call(this, e2, t2, r2), this; if (h(e2)) { var n2 = e2; return this.filter(function(e3, t3) { return !t3.dir && n2.test(e3); }); } var i2 = this.files[this.root + e2]; return i2 && !i2.dir ? i2 : null; }, folder: function(r2) { if (!r2) return this; if (h(r2)) return this.filter(function(e3, t3) { return t3.dir && r2.test(e3); }); var e2 = this.root + r2, t2 = b.call(this, e2), n2 = this.clone(); return n2.root = t2.name, n2; }, remove: function(r2) { r2 = this.root + r2; var e2 = this.files[r2]; if (e2 || ("/" !== r2.slice(-1) && (r2 += "/"), e2 = this.files[r2]), e2 && !e2.dir) delete this.files[r2]; else for (var t2 = this.filter(function(e3, t3) { return t3.name.slice(0, r2.length) === r2; }), n2 = 0; n2 < t2.length; n2++) delete this.files[t2[n2].name]; return this; }, generate: function() { throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide."); }, generateInternalStream: function(e2) { var t2, r2 = {}; try { if ((r2 = u.extend(e2 || {}, { streamFiles: false, compression: "STORE", compressionOptions: null, type: "", platform: "DOS", comment: null, mimeType: "application/zip", encodeFileName: i.utf8encode })).type = r2.type.toLowerCase(), r2.compression = r2.compression.toUpperCase(), "binarystring" === r2.type && (r2.type = "string"), !r2.type) throw new Error("No output type specified."); u.checkSupport(r2.type), "darwin" !== r2.platform && "freebsd" !== r2.platform && "linux" !== r2.platform && "sunos" !== r2.platform || (r2.platform = "UNIX"), "win32" === r2.platform && (r2.platform = "DOS"); var n2 = r2.comment || this.comment || ""; t2 = o.generateWorker(this, r2, n2); } catch (e3) { (t2 = new l("error")).error(e3); } return new a(t2, r2.type || "string", r2.mimeType); }, generateAsync: function(e2, t2) { return this.generateInternalStream(e2).accumulate(t2); }, generateNodeStream: function(e2, t2) { return (e2 = e2 || {}).type || (e2.type = "nodebuffer"), this.generateInternalStream(e2).toNodejsStream(t2); } }; t.exports = n; }, { "./compressedObject": 2, "./defaults": 5, "./generate": 9, "./nodejs/NodejsStreamInputAdapter": 12, "./nodejsUtils": 14, "./stream/GenericWorker": 28, "./stream/StreamHelper": 29, "./utf8": 31, "./utils": 32, "./zipObject": 35 }], 16: [function(e, t, r) { t.exports = e("stream"); }, { stream: void 0 }], 17: [function(e, t, r) { var n = e("./DataReader"); function i(e2) { n.call(this, e2); for (var t2 = 0; t2 < this.data.length; t2++) e2[t2] = 255 & e2[t2]; } e("../utils").inherits(i, n), i.prototype.byteAt = function(e2) { return this.data[this.zero + e2]; }, i.prototype.lastIndexOfSignature = function(e2) { for (var t2 = e2.charCodeAt(0), r2 = e2.charCodeAt(1), n2 = e2.charCodeAt(2), i2 = e2.charCodeAt(3), s = this.length - 4; 0 <= s; --s) if (this.data[s] === t2 && this.data[s + 1] === r2 && this.data[s + 2] === n2 && this.data[s + 3] === i2) return s - this.zero; return -1; }, i.prototype.readAndCheckSignature = function(e2) { var t2 = e2.charCodeAt(0), r2 = e2.charCodeAt(1), n2 = e2.charCodeAt(2), i2 = e2.charCodeAt(3), s = this.readData(4); return t2 === s[0] && r2 === s[1] && n2 === s[2] && i2 === s[3]; }, i.prototype.readData = function(e2) { if (this.checkOffset(e2), 0 === e2) return []; var t2 = this.data.slice(this.zero + this.index, this.zero + this.index + e2); return this.index += e2, t2; }, t.exports = i; }, { "../utils": 32, "./DataReader": 18 }], 18: [function(e, t, r) { var n = e("../utils"); function i(e2) { this.data = e2, this.length = e2.length, this.index = 0, this.zero = 0; } i.prototype = { checkOffset: function(e2) { this.checkIndex(this.index + e2); }, checkIndex: function(e2) { if (this.length < this.zero + e2 || e2 < 0) throw new Error("End of data reached (data length = " + this.length + ", asked index = " + e2 + "). Corrupted zip ?"); }, setIndex: function(e2) { this.checkIndex(e2), this.index = e2; }, skip: function(e2) { this.setIndex(this.index + e2); }, byteAt: function() { }, readInt: function(e2) { var t2, r2 = 0; for (this.checkOffset(e2), t2 = this.index + e2 - 1; t2 >= this.index; t2--) r2 = (r2 << 8) + this.byteAt(t2); return this.index += e2, r2; }, readString: function(e2) { return n.transformTo("string", this.readData(e2)); }, readData: function() { }, lastIndexOfSignature: function() { }, readAndCheckSignature: function() { }, readDate: function() { var e2 = this.readInt(4); return new Date(Date.UTC(1980 + (e2 >> 25 & 127), (e2 >> 21 & 15) - 1, e2 >> 16 & 31, e2 >> 11 & 31, e2 >> 5 & 63, (31 & e2) << 1)); } }, t.exports = i; }, { "../utils": 32 }], 19: [function(e, t, r) { var n = e("./Uint8ArrayReader"); function i(e2) { n.call(this, e2); } e("../utils").inherits(i, n), i.prototype.readData = function(e2) { this.checkOffset(e2); var t2 = this.data.slice(this.zero + this.index, this.zero + this.index + e2); return this.index += e2, t2; }, t.exports = i; }, { "../utils": 32, "./Uint8ArrayReader": 21 }], 20: [function(e, t, r) { var n = e("./DataReader"); function i(e2) { n.call(this, e2); } e("../utils").inherits(i, n), i.prototype.byteAt = function(e2) { return this.data.charCodeAt(this.zero + e2); }, i.prototype.lastIndexOfSignature = function(e2) { return this.data.lastIndexOf(e2) - this.zero; }, i.prototype.readAndCheckSignature = function(e2) { return e2 === this.readData(4); }, i.prototype.readData = function(e2) { this.checkOffset(e2); var t2 = this.data.slice(this.zero + this.index, this.zero + this.index + e2); return this.index += e2, t2; }, t.exports = i; }, { "../utils": 32, "./DataReader": 18 }], 21: [function(e, t, r) { var n = e("./ArrayReader"); function i(e2) { n.call(this, e2); } e("../utils").inherits(i, n), i.prototype.readData = function(e2) { if (this.checkOffset(e2), 0 === e2) return new Uint8Array(0); var t2 = this.data.subarray(this.zero + this.index, this.zero + this.index + e2); return this.index += e2, t2; }, t.exports = i; }, { "../utils": 32, "./ArrayReader": 17 }], 22: [function(e, t, r) { var n = e("../utils"), i = e("../support"), s = e("./ArrayReader"), a = e("./StringReader"), o = e("./NodeBufferReader"), h = e("./Uint8ArrayReader"); t.exports = function(e2) { var t2 = n.getTypeOf(e2); return n.checkSupport(t2), "string" !== t2 || i.uint8array ? "nodebuffer" === t2 ? new o(e2) : i.uint8array ? new h(n.transformTo("uint8array", e2)) : new s(n.transformTo("array", e2)) : new a(e2); }; }, { "../support": 30, "../utils": 32, "./ArrayReader": 17, "./NodeBufferReader": 19, "./StringReader": 20, "./Uint8ArrayReader": 21 }], 23: [function(e, t, r) { r.LOCAL_FILE_HEADER = "PK", r.CENTRAL_FILE_HEADER = "PK", r.CENTRAL_DIRECTORY_END = "PK", r.ZIP64_CENTRAL_DIRECTORY_LOCATOR = "PK\x07", r.ZIP64_CENTRAL_DIRECTORY_END = "PK", r.DATA_DESCRIPTOR = "PK\x07\b"; }, {}], 24: [function(e, t, r) { var n = e("./GenericWorker"), i = e("../utils"); function s(e2) { n.call(this, "ConvertWorker to " + e2), this.destType = e2; } i.inherits(s, n), s.prototype.processChunk = function(e2) { this.push({ data: i.transformTo(this.destType, e2.data), meta: e2.meta }); }, t.exports = s; }, { "../utils": 32, "./GenericWorker": 28 }], 25: [function(e, t, r) { var n = e("./GenericWorker"), i = e("../crc32"); function s() { n.call(this, "Crc32Probe"), this.withStreamInfo("crc32", 0); } e("../utils").inherits(s, n), s.prototype.processChunk = function(e2) { this.streamInfo.crc32 = i(e2.data, this.streamInfo.crc32 || 0), this.push(e2); }, t.exports = s; }, { "../crc32": 4, "../utils": 32, "./GenericWorker": 28 }], 26: [function(e, t, r) { var n = e("../utils"), i = e("./GenericWorker"); function s(e2) { i.call(this, "DataLengthProbe for " + e2), this.propName = e2, this.withStreamInfo(e2, 0); } n.inherits(s, i), s.prototype.processChunk = function(e2) { if (e2) { var t2 = this.streamInfo[this.propName] || 0; this.streamInfo[this.propName] = t2 + e2.data.length; } i.prototype.processChunk.call(this, e2); }, t.exports = s; }, { "../utils": 32, "./GenericWorker": 28 }], 27: [function(e, t, r) { var n = e("../utils"), i = e("./GenericWorker"); function s(e2) { i.call(this, "DataWorker"); var t2 = this; this.dataIsReady = false, this.index = 0, this.max = 0, this.data = null, this.type = "", this._tickScheduled = false, e2.then(function(e3) { t2.dataIsReady = true, t2.data = e3, t2.max = e3 && e3.length || 0, t2.type = n.getTypeOf(e3), t2.isPaused || t2._tickAndRepeat(); }, function(e3) { t2.error(e3); }); } n.inherits(s, i), s.prototype.cleanUp = function() { i.prototype.cleanUp.call(this), this.data = null; }, s.prototype.resume = function() { return !!i.prototype.resume.call(this) && (!this._tickScheduled && this.dataIsReady && (this._tickScheduled = true, n.delay(this._tickAndRepeat, [], this)), true); }, s.prototype._tickAndRepeat = function() { this._tickScheduled = false, this.isPaused || this.isFinished || (this._tick(), this.isFinished || (n.delay(this._tickAndRepeat, [], this), this._tickScheduled = true)); }, s.prototype._tick = function() { if (this.isPaused || this.isFinished) return false; var e2 = null, t2 = Math.min(this.max, this.index + 16384); if (this.index >= this.max) return this.end(); switch (this.type) { case "string": e2 = this.data.substring(this.index, t2); break; case "uint8array": e2 = this.data.subarray(this.index, t2); break; case "array": case "nodebuffer": e2 = this.data.slice(this.index, t2); } return this.index = t2, this.push({ data: e2, meta: { percent: this.max ? this.index / this.max * 100 : 0 } }); }, t.exports = s; }, { "../utils": 32, "./GenericWorker": 28 }], 28: [function(e, t, r) { function n(e2) { this.name = e2 || "default", this.streamInfo = {}, this.generatedError = null, this.extraStreamInfo = {}, this.isPaused = true, this.isFinished = false, this.isLocked = false, this._listeners = { data: [], end: [], error: [] }, this.previous = null; } n.prototype = { push: function(e2) { this.emit("data", e2); }, end: function() { if (this.isFinished) return false; this.flush(); try { this.emit("end"), this.cleanUp(), this.isFinished = true; } catch (e2) { this.emit("error", e2); } return true; }, error: function(e2) { return !this.isFinished && (this.isPaused ? this.generatedError = e2 : (this.isFinished = true, this.emit("error", e2), this.previous && this.previous.error(e2), this.cleanUp()), true); }, on: function(e2, t2) { return this._listeners[e2].push(t2), this; }, cleanUp: function() { this.streamInfo = this.generatedError = this.extraStreamInfo = null, this._listeners = []; }, emit: function(e2, t2) { if (this._listeners[e2]) for (var r2 = 0; r2 < this._listeners[e2].length; r2++) this._listeners[e2][r2].call(this, t2); }, pipe: function(e2) { return e2.registerPrevious(this); }, registerPrevious: function(e2) { if (this.isLocked) throw new Error("The stream '" + this + "' has already been used."); this.streamInfo = e2.streamInfo, this.mergeStreamInfo(), this.previous = e2; var t2 = this; return e2.on("data", function(e3) { t2.processChunk(e3); }), e2.on("end", function() { t2.end(); }), e2.on("error", function(e3) { t2.error(e3); }), this; }, pause: function() { return !this.isPaused && !this.isFinished && (this.isPaused = true, this.previous && this.previous.pause(), true); }, resume: function() { if (!this.isPaused || this.isFinished) return false; var e2 = this.isPaused = false; return this.generatedError && (this.error(this.generatedError), e2 = true), this.previous && this.previous.resume(), !e2; }, flush: function() { }, processChunk: function(e2) { this.push(e2); }, withStreamInfo: function(e2, t2) { return this.extraStreamInfo[e2] = t2, this.mergeStreamInfo(), this; }, mergeStreamInfo: function() { for (var e2 in this.extraStreamInfo) Object.prototype.hasOwnProperty.call(this.extraStreamInfo, e2) && (this.streamInfo[e2] = this.extraStreamInfo[e2]); }, lock: function() { if (this.isLocked) throw new Error("The stream '" + this + "' has already been used."); this.isLocked = true, this.previous && this.previous.lock(); }, toString: function() { var e2 = "Worker " + this.name; return this.previous ? this.previous + " -> " + e2 : e2; } }, t.exports = n; }, {}], 29: [function(e, t, r) { var h = e("../utils"), i = e("./ConvertWorker"), s = e("./GenericWorker"), u = e("../base64"), n = e("../support"), a = e("../external"), o = null; if (n.nodestream) try { o = e("../nodejs/NodejsStreamOutputAdapter"); } catch (e2) { } function l(e2, o2) { return new a.Promise(function(t2, r2) { var n2 = [], i2 = e2._internalType, s2 = e2._outputType, a2 = e2._mimeType; e2.on("data", function(e3, t3) { n2.push(e3), o2 && o2(t3); }).on("error", function(e3) { n2 = [], r2(e3); }).on("end", function() { try { var e3 = (function(e4, t3, r3) { switch (e4) { case "blob": return h.newBlob(h.transformTo("arraybuffer", t3), r3); case "base64": return u.encode(t3); default: return h.transformTo(e4, t3); } })(s2, (function(e4, t3) { var r3, n3 = 0, i3 = null, s3 = 0; for (r3 = 0; r3 < t3.length; r3++) s3 += t3[r3].length; switch (e4) { case "string": return t3.join(""); case "array": return Array.prototype.concat.apply([], t3); case "uint8array": for (i3 = new Uint8Array(s3), r3 = 0; r3 < t3.length; r3++) i3.set(t3[r3], n3), n3 += t3[r3].length; return i3; case "nodebuffer": return Buffer.concat(t3); default: throw new Error("concat : unsupported type '" + e4 + "'"); } })(i2, n2), a2); t2(e3); } catch (e4) { r2(e4); } n2 = []; }).resume(); }); } function f(e2, t2, r2) { var n2 = t2; switch (t2) { case "blob": case "arraybuffer": n2 = "uint8array"; break; case "base64": n2 = "string"; } try { this._internalType = n2, this._outputType = t2, this._mimeType = r2, h.checkSupport(n2), this._worker = e2.pipe(new i(n2)), e2.lock(); } catch (e3) { this._worker = new s("error"), this._worker.error(e3); } } f.prototype = { accumulate: function(e2) { return l(this, e2); }, on: function(e2, t2) { var r2 = this; return "data" === e2 ? this._worker.on(e2, function(e3) { t2.call(r2, e3.data, e3.meta); }) : this._worker.on(e2, function() { h.delay(t2, arguments, r2); }), this; }, resume: function() { return h.delay(this._worker.resume, [], this._worker), this; }, pause: function() { return this._worker.pause(), this; }, toNodejsStream: function(e2) { if (h.checkSupport("nodestream"), "nodebuffer" !== this._outputType) throw new Error(this._outputType + " is not supported by this method"); return new o(this, { objectMode: "nodebuffer" !== this._outputType }, e2); } }, t.exports = f; }, { "../base64": 1, "../external": 6, "../nodejs/NodejsStreamOutputAdapter": 13, "../support": 30, "../utils": 32, "./ConvertWorker": 24, "./GenericWorker": 28 }], 30: [function(e, t, r) { if (r.base64 = true, r.array = true, r.string = true, r.arraybuffer = "undefined" != typeof ArrayBuffer && "undefined" != typeof Uint8Array, r.nodebuffer = "undefined" != typeof Buffer, r.uint8array = "undefined" != typeof Uint8Array, "undefined" == typeof ArrayBuffer) r.blob = false; else { var n = new ArrayBuffer(0); try { r.blob = 0 === new Blob([n], { type: "application/zip" }).size; } catch (e2) { try { var i = new (self.BlobBuilder || self.WebKitBlobBuilder || self.MozBlobBuilder || self.MSBlobBuilder)(); i.append(n), r.blob = 0 === i.getBlob("application/zip").size; } catch (e3) { r.blob = false; } } } try { r.nodestream = !!e("readable-stream").Readable; } catch (e2) { r.nodestream = false; } }, { "readable-stream": 16 }], 31: [function(e, t, s) { for (var o = e("./utils"), h = e("./support"), r = e("./nodejsUtils"), n = e("./stream/GenericWorker"), u = new Array(256), i = 0; i < 256; i++) u[i] = 252 <= i ? 6 : 248 <= i ? 5 : 240 <= i ? 4 : 224 <= i ? 3 : 192 <= i ? 2 : 1; u[254] = u[254] = 1; function a() { n.call(this, "utf-8 decode"), this.leftOver = null; } function l() { n.call(this, "utf-8 encode"); } s.utf8encode = function(e2) { return h.nodebuffer ? r.newBufferFrom(e2, "utf-8") : (function(e3) { var t2, r2, n2, i2, s2, a2 = e3.length, o2 = 0; for (i2 = 0; i2 < a2; i2++) 55296 == (64512 & (r2 = e3.charCodeAt(i2))) && i2 + 1 < a2 && 56320 == (64512 & (n2 = e3.charCodeAt(i2 + 1))) && (r2 = 65536 + (r2 - 55296 << 10) + (n2 - 56320), i2++), o2 += r2 < 128 ? 1 : r2 < 2048 ? 2 : r2 < 65536 ? 3 : 4; for (t2 = h.uint8array ? new Uint8Array(o2) : new Array(o2), i2 = s2 = 0; s2 < o2; i2++) 55296 == (64512 & (r2 = e3.charCodeAt(i2))) && i2 + 1 < a2 && 56320 == (64512 & (n2 = e3.charCodeAt(i2 + 1))) && (r2 = 65536 + (r2 - 55296 << 10) + (n2 - 56320), i2++), r2 < 128 ? t2[s2++] = r2 : (r2 < 2048 ? t2[s2++] = 192 | r2 >>> 6 : (r2 < 65536 ? t2[s2++] = 224 | r2 >>> 12 : (t2[s2++] = 240 | r2 >>> 18, t2[s2++] = 128 | r2 >>> 12 & 63), t2[s2++] = 128 | r2 >>> 6 & 63), t2[s2++] = 128 | 63 & r2); return t2; })(e2); }, s.utf8decode = function(e2) { return h.nodebuffer ? o.transformTo("nodebuffer", e2).toString("utf-8") : (function(e3) { var t2, r2, n2, i2, s2 = e3.length, a2 = new Array(2 * s2); for (t2 = r2 = 0; t2 < s2; ) if ((n2 = e3[t2++]) < 128) a2[r2++] = n2; else if (4 < (i2 = u[n2])) a2[r2++] = 65533, t2 += i2 - 1; else { for (n2 &= 2 === i2 ? 31 : 3 === i2 ? 15 : 7; 1 < i2 && t2 < s2; ) n2 = n2 << 6 | 63 & e3[t2++], i2--; 1 < i2 ? a2[r2++] = 65533 : n2 < 65536 ? a2[r2++] = n2 : (n2 -= 65536, a2[r2++] = 55296 | n2 >> 10 & 1023, a2[r2++] = 56320 | 1023 & n2); } return a2.length !== r2 && (a2.subarray ? a2 = a2.subarray(0, r2) : a2.length = r2), o.applyFromCharCode(a2); })(e2 = o.transformTo(h.uint8array ? "uint8array" : "array", e2)); }, o.inherits(a, n), a.prototype.processChunk = function(e2) { var t2 = o.transformTo(h.uint8array ? "uint8array" : "array", e2.data); if (this.leftOver && this.leftOver.length) { if (h.uint8array) { var r2 = t2; (t2 = new Uint8Array(r2.length + this.leftOver.length)).set(this.leftOver, 0), t2.set(r2, this.leftOver.length); } else t2 = this.leftOver.concat(t2); this.leftOver = null; } var n2 = (function(e3, t3) { var r3; for ((t3 = t3 || e3.length) > e3.length && (t3 = e3.length), r3 = t3 - 1; 0 <= r3 && 128 == (192 & e3[r3]); ) r3--; return r3 < 0 ? t3 : 0 === r3 ? t3 : r3 + u[e3[r3]] > t3 ? r3 : t3; })(t2), i2 = t2; n2 !== t2.length && (h.uint8array ? (i2 = t2.subarray(0, n2), this.leftOver = t2.subarray(n2, t2.length)) : (i2 = t2.slice(0, n2), this.leftOver = t2.slice(n2, t2.length))), this.push({ data: s.utf8decode(i2), meta: e2.meta }); }, a.prototype.flush = function() { this.leftOver && this.leftOver.length && (this.push({ data: s.utf8decode(this.leftOver), meta: {} }), this.leftOver = null); }, s.Utf8DecodeWorker = a, o.inherits(l, n), l.prototype.processChunk = function(e2) { this.push({ data: s.utf8encode(e2.data), meta: e2.meta }); }, s.Utf8EncodeWorker = l; }, { "./nodejsUtils": 14, "./stream/GenericWorker": 28, "./support": 30, "./utils": 32 }], 32: [function(e, t, a) { var o = e("./support"), h = e("./base64"), r = e("./nodejsUtils"), u = e("./external"); function n(e2) { return e2; } function l(e2, t2) { for (var r2 = 0; r2 < e2.length; ++r2) t2[r2] = 255 & e2.charCodeAt(r2); return t2; } e("setimmediate"), a.newBlob = function(t2, r2) { a.checkSupport("blob"); try { return new Blob([t2], { type: r2 }); } catch (e2) { try { var n2 = new (self.BlobBuilder || self.WebKitBlobBuilder || self.MozBlobBuilder || self.MSBlobBuilder)(); return n2.append(t2), n2.getBlob(r2); } catch (e3) { throw new Error("Bug : can't construct the Blob."); } } }; var i = { stringifyByChunk: function(e2, t2, r2) { var n2 = [], i2 = 0, s2 = e2.length; if (s2 <= r2) return String.fromCharCode.apply(null, e2); for (; i2 < s2; ) "array" === t2 || "nodebuffer" === t2 ? n2.push(String.fromCharCode.apply(null, e2.slice(i2, Math.min(i2 + r2, s2)))) : n2.push(String.fromCharCode.apply(null, e2.subarray(i2, Math.min(i2 + r2, s2)))), i2 += r2; return n2.join(""); }, stringifyByChar: function(e2) { for (var t2 = "", r2 = 0; r2 < e2.length; r2++) t2 += String.fromCharCode(e2[r2]); return t2; }, applyCanBeUsed: { uint8array: (function() { try { return o.uint8array && 1 === String.fromCharCode.apply(null, new Uint8Array(1)).length; } catch (