@wix/vibe-forms-app-plugin 0.1.1 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -2,6 +2,2711 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
+ var fs = require('fs');
6
+ var path = require('path');
7
+
8
+ function _interopNamespace(e) {
9
+ if (e && e.__esModule) return e;
10
+ var n = Object.create(null);
11
+ if (e) {
12
+ Object.keys(e).forEach(function (k) {
13
+ if (k !== 'default') {
14
+ var d = Object.getOwnPropertyDescriptor(e, k);
15
+ Object.defineProperty(n, k, d.get ? d : {
16
+ enumerable: true,
17
+ get: function () { return e[k]; }
18
+ });
19
+ }
20
+ });
21
+ }
22
+ n.default = e;
23
+ return Object.freeze(n);
24
+ }
25
+
26
+ var fs__namespace = /*#__PURE__*/_interopNamespace(fs);
27
+ var path__namespace = /*#__PURE__*/_interopNamespace(path);
28
+
29
+ var __create = Object.create;
30
+ var __defProp = Object.defineProperty;
31
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
32
+ var __getOwnPropNames = Object.getOwnPropertyNames;
33
+ var __getProtoOf = Object.getPrototypeOf;
34
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
35
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
36
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
37
+ }) : x)(function(x) {
38
+ if (typeof require !== "undefined") return require.apply(this, arguments);
39
+ throw Error('Dynamic require of "' + x + '" is not supported');
40
+ });
41
+ var __commonJS = (cb, mod) => function __require2() {
42
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
43
+ };
44
+ var __copyProps = (to, from, except, desc) => {
45
+ if (from && typeof from === "object" || typeof from === "function") {
46
+ for (let key of __getOwnPropNames(from))
47
+ if (!__hasOwnProp.call(to, key) && key !== except)
48
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
49
+ }
50
+ return to;
51
+ };
52
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
53
+ // If the importer is in node compatibility mode or this is not an ESM
54
+ // file that has been converted to a CommonJS file using a Babel-
55
+ // compatible transform (i.e. "__esModule" has not been set), then set
56
+ // "default" to the CommonJS "module.exports" for node compatibility.
57
+ !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
58
+ mod
59
+ ));
60
+
61
+ // ../../../node_modules/adm-zip/util/constants.js
62
+ var require_constants = __commonJS({
63
+ "../../../node_modules/adm-zip/util/constants.js"(exports, module) {
64
+ module.exports = {
65
+ /* The local file header */
66
+ LOCHDR: 30,
67
+ // LOC header size
68
+ LOCSIG: 67324752,
69
+ // "PK\003\004"
70
+ LOCVER: 4,
71
+ // version needed to extract
72
+ LOCFLG: 6,
73
+ // general purpose bit flag
74
+ LOCHOW: 8,
75
+ // compression method
76
+ LOCTIM: 10,
77
+ // modification time (2 bytes time, 2 bytes date)
78
+ LOCCRC: 14,
79
+ // uncompressed file crc-32 value
80
+ LOCSIZ: 18,
81
+ // compressed size
82
+ LOCLEN: 22,
83
+ // uncompressed size
84
+ LOCNAM: 26,
85
+ // filename length
86
+ LOCEXT: 28,
87
+ // extra field length
88
+ /* The Data descriptor */
89
+ EXTSIG: 134695760,
90
+ // "PK\007\008"
91
+ EXTHDR: 16,
92
+ // EXT header size
93
+ EXTCRC: 4,
94
+ // uncompressed file crc-32 value
95
+ EXTSIZ: 8,
96
+ // compressed size
97
+ EXTLEN: 12,
98
+ // uncompressed size
99
+ /* The central directory file header */
100
+ CENHDR: 46,
101
+ // CEN header size
102
+ CENSIG: 33639248,
103
+ // "PK\001\002"
104
+ CENVEM: 4,
105
+ // version made by
106
+ CENVER: 6,
107
+ // version needed to extract
108
+ CENFLG: 8,
109
+ // encrypt, decrypt flags
110
+ CENHOW: 10,
111
+ // compression method
112
+ CENTIM: 12,
113
+ // modification time (2 bytes time, 2 bytes date)
114
+ CENCRC: 16,
115
+ // uncompressed file crc-32 value
116
+ CENSIZ: 20,
117
+ // compressed size
118
+ CENLEN: 24,
119
+ // uncompressed size
120
+ CENNAM: 28,
121
+ // filename length
122
+ CENEXT: 30,
123
+ // extra field length
124
+ CENCOM: 32,
125
+ // file comment length
126
+ CENDSK: 34,
127
+ // volume number start
128
+ CENATT: 36,
129
+ // internal file attributes
130
+ CENATX: 38,
131
+ // external file attributes (host system dependent)
132
+ CENOFF: 42,
133
+ // LOC header offset
134
+ /* The entries in the end of central directory */
135
+ ENDHDR: 22,
136
+ // END header size
137
+ ENDSIG: 101010256,
138
+ // "PK\005\006"
139
+ ENDSUB: 8,
140
+ // number of entries on this disk
141
+ ENDTOT: 10,
142
+ // total number of entries
143
+ ENDSIZ: 12,
144
+ // central directory size in bytes
145
+ ENDOFF: 16,
146
+ // offset of first CEN header
147
+ ENDCOM: 20,
148
+ // zip file comment length
149
+ END64HDR: 20,
150
+ // zip64 END header size
151
+ END64SIG: 117853008,
152
+ // zip64 Locator signature, "PK\006\007"
153
+ END64START: 4,
154
+ // number of the disk with the start of the zip64
155
+ END64OFF: 8,
156
+ // relative offset of the zip64 end of central directory
157
+ END64NUMDISKS: 16,
158
+ // total number of disks
159
+ ZIP64SIG: 101075792,
160
+ // zip64 signature, "PK\006\006"
161
+ ZIP64HDR: 56,
162
+ // zip64 record minimum size
163
+ ZIP64LEAD: 12,
164
+ // leading bytes at the start of the record, not counted by the value stored in ZIP64SIZE
165
+ ZIP64SIZE: 4,
166
+ // zip64 size of the central directory record
167
+ ZIP64VEM: 12,
168
+ // zip64 version made by
169
+ ZIP64VER: 14,
170
+ // zip64 version needed to extract
171
+ ZIP64DSK: 16,
172
+ // zip64 number of this disk
173
+ ZIP64DSKDIR: 20,
174
+ // number of the disk with the start of the record directory
175
+ ZIP64SUB: 24,
176
+ // number of entries on this disk
177
+ ZIP64TOT: 32,
178
+ // total number of entries
179
+ ZIP64SIZB: 40,
180
+ // zip64 central directory size in bytes
181
+ ZIP64OFF: 48,
182
+ // offset of start of central directory with respect to the starting disk number
183
+ ZIP64EXTRA: 56,
184
+ // extensible data sector
185
+ /* Compression methods */
186
+ STORED: 0,
187
+ // no compression
188
+ SHRUNK: 1,
189
+ // shrunk
190
+ REDUCED1: 2,
191
+ // reduced with compression factor 1
192
+ REDUCED2: 3,
193
+ // reduced with compression factor 2
194
+ REDUCED3: 4,
195
+ // reduced with compression factor 3
196
+ REDUCED4: 5,
197
+ // reduced with compression factor 4
198
+ IMPLODED: 6,
199
+ // imploded
200
+ // 7 reserved for Tokenizing compression algorithm
201
+ DEFLATED: 8,
202
+ // deflated
203
+ ENHANCED_DEFLATED: 9,
204
+ // enhanced deflated
205
+ PKWARE: 10,
206
+ // PKWare DCL imploded
207
+ // 11 reserved by PKWARE
208
+ BZIP2: 12,
209
+ // compressed using BZIP2
210
+ // 13 reserved by PKWARE
211
+ LZMA: 14,
212
+ // LZMA
213
+ // 15-17 reserved by PKWARE
214
+ IBM_TERSE: 18,
215
+ // compressed using IBM TERSE
216
+ IBM_LZ77: 19,
217
+ // IBM LZ77 z
218
+ AES_ENCRYPT: 99,
219
+ // WinZIP AES encryption method
220
+ /* General purpose bit flag */
221
+ // values can obtained with expression 2**bitnr
222
+ FLG_ENC: 1,
223
+ // Bit 0: encrypted file
224
+ FLG_COMP1: 2,
225
+ // Bit 1, compression option
226
+ FLG_COMP2: 4,
227
+ // Bit 2, compression option
228
+ FLG_DESC: 8,
229
+ // Bit 3, data descriptor
230
+ FLG_ENH: 16,
231
+ // Bit 4, enhanced deflating
232
+ FLG_PATCH: 32,
233
+ // Bit 5, indicates that the file is compressed patched data.
234
+ FLG_STR: 64,
235
+ // Bit 6, strong encryption (patented)
236
+ // Bits 7-10: Currently unused.
237
+ FLG_EFS: 2048,
238
+ // Bit 11: Language encoding flag (EFS)
239
+ // Bit 12: Reserved by PKWARE for enhanced compression.
240
+ // Bit 13: encrypted the Central Directory (patented).
241
+ // Bits 14-15: Reserved by PKWARE.
242
+ FLG_MSK: 4096,
243
+ // mask header values
244
+ /* Load type */
245
+ FILE: 2,
246
+ BUFFER: 1,
247
+ NONE: 0,
248
+ /* 4.5 Extensible data fields */
249
+ EF_ID: 0,
250
+ EF_SIZE: 2,
251
+ /* Header IDs */
252
+ ID_ZIP64: 1,
253
+ ID_AVINFO: 7,
254
+ ID_PFS: 8,
255
+ ID_OS2: 9,
256
+ ID_NTFS: 10,
257
+ ID_OPENVMS: 12,
258
+ ID_UNIX: 13,
259
+ ID_FORK: 14,
260
+ ID_PATCH: 15,
261
+ ID_X509_PKCS7: 20,
262
+ ID_X509_CERTID_F: 21,
263
+ ID_X509_CERTID_C: 22,
264
+ ID_STRONGENC: 23,
265
+ ID_RECORD_MGT: 24,
266
+ ID_X509_PKCS7_RL: 25,
267
+ ID_IBM1: 101,
268
+ ID_IBM2: 102,
269
+ ID_POSZIP: 18064,
270
+ EF_ZIP64_OR_32: 4294967295,
271
+ EF_ZIP64_OR_16: 65535,
272
+ EF_ZIP64_SUNCOMP: 0,
273
+ EF_ZIP64_SCOMP: 8,
274
+ EF_ZIP64_RHO: 16,
275
+ EF_ZIP64_DSN: 24
276
+ };
277
+ }
278
+ });
279
+
280
+ // ../../../node_modules/adm-zip/util/errors.js
281
+ var require_errors = __commonJS({
282
+ "../../../node_modules/adm-zip/util/errors.js"(exports) {
283
+ var errors = {
284
+ /* Header error messages */
285
+ INVALID_LOC: "Invalid LOC header (bad signature)",
286
+ INVALID_CEN: "Invalid CEN header (bad signature)",
287
+ INVALID_END: "Invalid END header (bad signature)",
288
+ /* Descriptor */
289
+ DESCRIPTOR_NOT_EXIST: "No descriptor present",
290
+ DESCRIPTOR_UNKNOWN: "Unknown descriptor format",
291
+ DESCRIPTOR_FAULTY: "Descriptor data is malformed",
292
+ /* ZipEntry error messages*/
293
+ NO_DATA: "Nothing to decompress",
294
+ BAD_CRC: "CRC32 checksum failed {0}",
295
+ FILE_IN_THE_WAY: "There is a file in the way: {0}",
296
+ UNKNOWN_METHOD: "Invalid/unsupported compression method",
297
+ /* Inflater error messages */
298
+ AVAIL_DATA: "inflate::Available inflate data did not terminate",
299
+ INVALID_DISTANCE: "inflate::Invalid literal/length or distance code in fixed or dynamic block",
300
+ TO_MANY_CODES: "inflate::Dynamic block code description: too many length or distance codes",
301
+ INVALID_REPEAT_LEN: "inflate::Dynamic block code description: repeat more than specified lengths",
302
+ INVALID_REPEAT_FIRST: "inflate::Dynamic block code description: repeat lengths with no first length",
303
+ INCOMPLETE_CODES: "inflate::Dynamic block code description: code lengths codes incomplete",
304
+ INVALID_DYN_DISTANCE: "inflate::Dynamic block code description: invalid distance code lengths",
305
+ INVALID_CODES_LEN: "inflate::Dynamic block code description: invalid literal/length code lengths",
306
+ INVALID_STORE_BLOCK: "inflate::Stored block length did not match one's complement",
307
+ INVALID_BLOCK_TYPE: "inflate::Invalid block type (type == 3)",
308
+ /* ADM-ZIP error messages */
309
+ CANT_EXTRACT_FILE: "Could not extract the file",
310
+ CANT_OVERRIDE: "Target file already exists",
311
+ DISK_ENTRY_TOO_LARGE: "Number of disk entries is too large",
312
+ NO_ZIP: "No zip file was loaded",
313
+ NO_ENTRY: "Entry doesn't exist",
314
+ DIRECTORY_CONTENT_ERROR: "A directory cannot have content",
315
+ FILE_NOT_FOUND: 'File not found: "{0}"',
316
+ NOT_IMPLEMENTED: "Not implemented",
317
+ INVALID_FILENAME: "Invalid filename",
318
+ INVALID_FORMAT: "Invalid or unsupported zip format. No END header found",
319
+ INVALID_PASS_PARAM: "Incompatible password parameter",
320
+ WRONG_PASSWORD: "Wrong Password",
321
+ /* ADM-ZIP */
322
+ COMMENT_TOO_LONG: "Comment is too long",
323
+ // Comment can be max 65535 bytes long (NOTE: some non-US characters may take more space)
324
+ EXTRA_FIELD_PARSE_ERROR: "Extra field parsing error"
325
+ };
326
+ function E(message) {
327
+ return function(...args) {
328
+ if (args.length) {
329
+ message = message.replace(/\{(\d)\}/g, (_, n) => args[n] || "");
330
+ }
331
+ return new Error("ADM-ZIP: " + message);
332
+ };
333
+ }
334
+ for (const msg of Object.keys(errors)) {
335
+ exports[msg] = E(errors[msg]);
336
+ }
337
+ }
338
+ });
339
+
340
+ // ../../../node_modules/adm-zip/util/utils.js
341
+ var require_utils = __commonJS({
342
+ "../../../node_modules/adm-zip/util/utils.js"(exports, module) {
343
+ var fsystem = __require("fs");
344
+ var pth = __require("path");
345
+ var Constants = require_constants();
346
+ var Errors = require_errors();
347
+ var isWin = typeof process === "object" && "win32" === process.platform;
348
+ var is_Obj = (obj) => typeof obj === "object" && obj !== null;
349
+ var crcTable = new Uint32Array(256).map((t, c) => {
350
+ for (let k = 0; k < 8; k++) {
351
+ if ((c & 1) !== 0) {
352
+ c = 3988292384 ^ c >>> 1;
353
+ } else {
354
+ c >>>= 1;
355
+ }
356
+ }
357
+ return c >>> 0;
358
+ });
359
+ function Utils(opts) {
360
+ this.sep = pth.sep;
361
+ this.fs = fsystem;
362
+ if (is_Obj(opts)) {
363
+ if (is_Obj(opts.fs) && typeof opts.fs.statSync === "function") {
364
+ this.fs = opts.fs;
365
+ }
366
+ }
367
+ }
368
+ module.exports = Utils;
369
+ Utils.prototype.makeDir = function(folder) {
370
+ const self = this;
371
+ function mkdirSync2(fpath) {
372
+ let resolvedPath = fpath.split(self.sep)[0];
373
+ fpath.split(self.sep).forEach(function(name) {
374
+ if (!name || name.substr(-1, 1) === ":") return;
375
+ resolvedPath += self.sep + name;
376
+ var stat;
377
+ try {
378
+ stat = self.fs.statSync(resolvedPath);
379
+ } catch (e) {
380
+ self.fs.mkdirSync(resolvedPath);
381
+ }
382
+ if (stat && stat.isFile()) throw Errors.FILE_IN_THE_WAY(`"${resolvedPath}"`);
383
+ });
384
+ }
385
+ mkdirSync2(folder);
386
+ };
387
+ Utils.prototype.writeFileTo = function(path2, content, overwrite, attr) {
388
+ const self = this;
389
+ if (self.fs.existsSync(path2)) {
390
+ if (!overwrite) return false;
391
+ var stat = self.fs.statSync(path2);
392
+ if (stat.isDirectory()) {
393
+ return false;
394
+ }
395
+ }
396
+ var folder = pth.dirname(path2);
397
+ if (!self.fs.existsSync(folder)) {
398
+ self.makeDir(folder);
399
+ }
400
+ var fd;
401
+ try {
402
+ fd = self.fs.openSync(path2, "w", 438);
403
+ } catch (e) {
404
+ self.fs.chmodSync(path2, 438);
405
+ fd = self.fs.openSync(path2, "w", 438);
406
+ }
407
+ if (fd) {
408
+ try {
409
+ self.fs.writeSync(fd, content, 0, content.length, 0);
410
+ } finally {
411
+ self.fs.closeSync(fd);
412
+ }
413
+ }
414
+ self.fs.chmodSync(path2, attr || 438);
415
+ return true;
416
+ };
417
+ Utils.prototype.writeFileToAsync = function(path2, content, overwrite, attr, callback) {
418
+ if (typeof attr === "function") {
419
+ callback = attr;
420
+ attr = void 0;
421
+ }
422
+ const self = this;
423
+ self.fs.exists(path2, function(exist) {
424
+ if (exist && !overwrite) return callback(false);
425
+ self.fs.stat(path2, function(err, stat) {
426
+ if (exist && stat.isDirectory()) {
427
+ return callback(false);
428
+ }
429
+ var folder = pth.dirname(path2);
430
+ self.fs.exists(folder, function(exists) {
431
+ if (!exists) self.makeDir(folder);
432
+ self.fs.open(path2, "w", 438, function(err2, fd) {
433
+ if (err2) {
434
+ self.fs.chmod(path2, 438, function() {
435
+ self.fs.open(path2, "w", 438, function(err3, fd2) {
436
+ self.fs.write(fd2, content, 0, content.length, 0, function() {
437
+ self.fs.close(fd2, function() {
438
+ self.fs.chmod(path2, attr || 438, function() {
439
+ callback(true);
440
+ });
441
+ });
442
+ });
443
+ });
444
+ });
445
+ } else if (fd) {
446
+ self.fs.write(fd, content, 0, content.length, 0, function() {
447
+ self.fs.close(fd, function() {
448
+ self.fs.chmod(path2, attr || 438, function() {
449
+ callback(true);
450
+ });
451
+ });
452
+ });
453
+ } else {
454
+ self.fs.chmod(path2, attr || 438, function() {
455
+ callback(true);
456
+ });
457
+ }
458
+ });
459
+ });
460
+ });
461
+ });
462
+ };
463
+ Utils.prototype.findFiles = function(path2) {
464
+ const self = this;
465
+ function findSync(dir, pattern, recursive) {
466
+ let files = [];
467
+ self.fs.readdirSync(dir).forEach(function(file) {
468
+ const path3 = pth.join(dir, file);
469
+ const stat = self.fs.statSync(path3);
470
+ {
471
+ files.push(pth.normalize(path3) + (stat.isDirectory() ? self.sep : ""));
472
+ }
473
+ if (stat.isDirectory() && recursive) files = files.concat(findSync(path3, pattern, recursive));
474
+ });
475
+ return files;
476
+ }
477
+ return findSync(path2, void 0, true);
478
+ };
479
+ Utils.prototype.findFilesAsync = function(dir, cb) {
480
+ const self = this;
481
+ let results = [];
482
+ self.fs.readdir(dir, function(err, list) {
483
+ if (err) return cb(err);
484
+ let list_length = list.length;
485
+ if (!list_length) return cb(null, results);
486
+ list.forEach(function(file) {
487
+ file = pth.join(dir, file);
488
+ self.fs.stat(file, function(err2, stat) {
489
+ if (err2) return cb(err2);
490
+ if (stat) {
491
+ results.push(pth.normalize(file) + (stat.isDirectory() ? self.sep : ""));
492
+ if (stat.isDirectory()) {
493
+ self.findFilesAsync(file, function(err3, res) {
494
+ if (err3) return cb(err3);
495
+ results = results.concat(res);
496
+ if (!--list_length) cb(null, results);
497
+ });
498
+ } else {
499
+ if (!--list_length) cb(null, results);
500
+ }
501
+ }
502
+ });
503
+ });
504
+ });
505
+ };
506
+ Utils.prototype.getAttributes = function() {
507
+ };
508
+ Utils.prototype.setAttributes = function() {
509
+ };
510
+ Utils.crc32update = function(crc, byte) {
511
+ return crcTable[(crc ^ byte) & 255] ^ crc >>> 8;
512
+ };
513
+ Utils.crc32 = function(buf) {
514
+ if (typeof buf === "string") {
515
+ buf = Buffer.from(buf, "utf8");
516
+ }
517
+ let len = buf.length;
518
+ let crc = -1;
519
+ for (let off = 0; off < len; ) crc = Utils.crc32update(crc, buf[off++]);
520
+ return ~crc >>> 0;
521
+ };
522
+ Utils.methodToString = function(method) {
523
+ switch (method) {
524
+ case Constants.STORED:
525
+ return "STORED (" + method + ")";
526
+ case Constants.DEFLATED:
527
+ return "DEFLATED (" + method + ")";
528
+ default:
529
+ return "UNSUPPORTED (" + method + ")";
530
+ }
531
+ };
532
+ Utils.canonical = function(path2) {
533
+ if (!path2) return "";
534
+ const safeSuffix = pth.posix.normalize("/" + path2.split("\\").join("/"));
535
+ return pth.join(".", safeSuffix);
536
+ };
537
+ Utils.zipnamefix = function(path2) {
538
+ if (!path2) return "";
539
+ const safeSuffix = pth.posix.normalize("/" + path2.split("\\").join("/"));
540
+ return pth.posix.join(".", safeSuffix);
541
+ };
542
+ Utils.findLast = function(arr, callback) {
543
+ if (!Array.isArray(arr)) throw new TypeError("arr is not array");
544
+ const len = arr.length >>> 0;
545
+ for (let i = len - 1; i >= 0; i--) {
546
+ if (callback(arr[i], i, arr)) {
547
+ return arr[i];
548
+ }
549
+ }
550
+ return void 0;
551
+ };
552
+ Utils.sanitize = function(prefix, name) {
553
+ prefix = pth.resolve(pth.normalize(prefix));
554
+ var parts = name.split("/");
555
+ for (var i = 0, l = parts.length; i < l; i++) {
556
+ var path2 = pth.normalize(pth.join(prefix, parts.slice(i, l).join(pth.sep)));
557
+ if (path2.indexOf(prefix) === 0) {
558
+ return path2;
559
+ }
560
+ }
561
+ return pth.normalize(pth.join(prefix, pth.basename(name)));
562
+ };
563
+ Utils.toBuffer = function toBuffer(input, encoder) {
564
+ if (Buffer.isBuffer(input)) {
565
+ return input;
566
+ } else if (input instanceof Uint8Array) {
567
+ return Buffer.from(input);
568
+ } else {
569
+ return typeof input === "string" ? encoder(input) : Buffer.alloc(0);
570
+ }
571
+ };
572
+ Utils.readBigUInt64LE = function(buffer, index) {
573
+ var slice = Buffer.from(buffer.slice(index, index + 8));
574
+ slice.swap64();
575
+ return parseInt(`0x${slice.toString("hex")}`);
576
+ };
577
+ Utils.fromDOS2Date = function(val) {
578
+ return new Date((val >> 25 & 127) + 1980, Math.max((val >> 21 & 15) - 1, 0), Math.max(val >> 16 & 31, 1), val >> 11 & 31, val >> 5 & 63, (val & 31) << 1);
579
+ };
580
+ Utils.fromDate2DOS = function(val) {
581
+ let date = 0;
582
+ let time = 0;
583
+ if (val.getFullYear() > 1979) {
584
+ date = (val.getFullYear() - 1980 & 127) << 9 | val.getMonth() + 1 << 5 | val.getDate();
585
+ time = val.getHours() << 11 | val.getMinutes() << 5 | val.getSeconds() >> 1;
586
+ }
587
+ return date << 16 | time;
588
+ };
589
+ Utils.isWin = isWin;
590
+ Utils.crcTable = crcTable;
591
+ }
592
+ });
593
+
594
+ // ../../../node_modules/adm-zip/util/fattr.js
595
+ var require_fattr = __commonJS({
596
+ "../../../node_modules/adm-zip/util/fattr.js"(exports, module) {
597
+ var pth = __require("path");
598
+ module.exports = function(path2, { fs: fs2 }) {
599
+ var _path = path2 || "", _obj = newAttr(), _stat = null;
600
+ function newAttr() {
601
+ return {
602
+ directory: false,
603
+ readonly: false,
604
+ hidden: false,
605
+ executable: false,
606
+ mtime: 0,
607
+ atime: 0
608
+ };
609
+ }
610
+ if (_path && fs2.existsSync(_path)) {
611
+ _stat = fs2.statSync(_path);
612
+ _obj.directory = _stat.isDirectory();
613
+ _obj.mtime = _stat.mtime;
614
+ _obj.atime = _stat.atime;
615
+ _obj.executable = (73 & _stat.mode) !== 0;
616
+ _obj.readonly = (128 & _stat.mode) === 0;
617
+ _obj.hidden = pth.basename(_path)[0] === ".";
618
+ } else {
619
+ console.warn("Invalid path: " + _path);
620
+ }
621
+ return {
622
+ get directory() {
623
+ return _obj.directory;
624
+ },
625
+ get readOnly() {
626
+ return _obj.readonly;
627
+ },
628
+ get hidden() {
629
+ return _obj.hidden;
630
+ },
631
+ get mtime() {
632
+ return _obj.mtime;
633
+ },
634
+ get atime() {
635
+ return _obj.atime;
636
+ },
637
+ get executable() {
638
+ return _obj.executable;
639
+ },
640
+ decodeAttributes: function() {
641
+ },
642
+ encodeAttributes: function() {
643
+ },
644
+ toJSON: function() {
645
+ return {
646
+ path: _path,
647
+ isDirectory: _obj.directory,
648
+ isReadOnly: _obj.readonly,
649
+ isHidden: _obj.hidden,
650
+ isExecutable: _obj.executable,
651
+ mTime: _obj.mtime,
652
+ aTime: _obj.atime
653
+ };
654
+ },
655
+ toString: function() {
656
+ return JSON.stringify(this.toJSON(), null, " ");
657
+ }
658
+ };
659
+ };
660
+ }
661
+ });
662
+
663
+ // ../../../node_modules/adm-zip/util/decoder.js
664
+ var require_decoder = __commonJS({
665
+ "../../../node_modules/adm-zip/util/decoder.js"(exports, module) {
666
+ module.exports = {
667
+ efs: true,
668
+ encode: (data) => Buffer.from(data, "utf8"),
669
+ decode: (data) => data.toString("utf8")
670
+ };
671
+ }
672
+ });
673
+
674
+ // ../../../node_modules/adm-zip/util/index.js
675
+ var require_util = __commonJS({
676
+ "../../../node_modules/adm-zip/util/index.js"(exports, module) {
677
+ module.exports = require_utils();
678
+ module.exports.Constants = require_constants();
679
+ module.exports.Errors = require_errors();
680
+ module.exports.FileAttr = require_fattr();
681
+ module.exports.decoder = require_decoder();
682
+ }
683
+ });
684
+
685
+ // ../../../node_modules/adm-zip/headers/entryHeader.js
686
+ var require_entryHeader = __commonJS({
687
+ "../../../node_modules/adm-zip/headers/entryHeader.js"(exports, module) {
688
+ var Utils = require_util();
689
+ var Constants = Utils.Constants;
690
+ module.exports = function() {
691
+ var _verMade = 20, _version = 10, _flags = 0, _method = 0, _time = 0, _crc = 0, _compressedSize = 0, _size = 0, _fnameLen = 0, _extraLen = 0, _comLen = 0, _diskStart = 0, _inattr = 0, _attr = 0, _offset = 0;
692
+ _verMade |= Utils.isWin ? 2560 : 768;
693
+ _flags |= Constants.FLG_EFS;
694
+ const _localHeader = {
695
+ extraLen: 0
696
+ };
697
+ const uint32 = (val) => Math.max(0, val) >>> 0;
698
+ const uint8 = (val) => Math.max(0, val) & 255;
699
+ _time = Utils.fromDate2DOS(/* @__PURE__ */ new Date());
700
+ return {
701
+ get made() {
702
+ return _verMade;
703
+ },
704
+ set made(val) {
705
+ _verMade = val;
706
+ },
707
+ get version() {
708
+ return _version;
709
+ },
710
+ set version(val) {
711
+ _version = val;
712
+ },
713
+ get flags() {
714
+ return _flags;
715
+ },
716
+ set flags(val) {
717
+ _flags = val;
718
+ },
719
+ get flags_efs() {
720
+ return (_flags & Constants.FLG_EFS) > 0;
721
+ },
722
+ set flags_efs(val) {
723
+ if (val) {
724
+ _flags |= Constants.FLG_EFS;
725
+ } else {
726
+ _flags &= ~Constants.FLG_EFS;
727
+ }
728
+ },
729
+ get flags_desc() {
730
+ return (_flags & Constants.FLG_DESC) > 0;
731
+ },
732
+ set flags_desc(val) {
733
+ if (val) {
734
+ _flags |= Constants.FLG_DESC;
735
+ } else {
736
+ _flags &= ~Constants.FLG_DESC;
737
+ }
738
+ },
739
+ get method() {
740
+ return _method;
741
+ },
742
+ set method(val) {
743
+ switch (val) {
744
+ case Constants.STORED:
745
+ this.version = 10;
746
+ case Constants.DEFLATED:
747
+ default:
748
+ this.version = 20;
749
+ }
750
+ _method = val;
751
+ },
752
+ get time() {
753
+ return Utils.fromDOS2Date(this.timeval);
754
+ },
755
+ set time(val) {
756
+ this.timeval = Utils.fromDate2DOS(val);
757
+ },
758
+ get timeval() {
759
+ return _time;
760
+ },
761
+ set timeval(val) {
762
+ _time = uint32(val);
763
+ },
764
+ get timeHighByte() {
765
+ return uint8(_time >>> 8);
766
+ },
767
+ get crc() {
768
+ return _crc;
769
+ },
770
+ set crc(val) {
771
+ _crc = uint32(val);
772
+ },
773
+ get compressedSize() {
774
+ return _compressedSize;
775
+ },
776
+ set compressedSize(val) {
777
+ _compressedSize = uint32(val);
778
+ },
779
+ get size() {
780
+ return _size;
781
+ },
782
+ set size(val) {
783
+ _size = uint32(val);
784
+ },
785
+ get fileNameLength() {
786
+ return _fnameLen;
787
+ },
788
+ set fileNameLength(val) {
789
+ _fnameLen = val;
790
+ },
791
+ get extraLength() {
792
+ return _extraLen;
793
+ },
794
+ set extraLength(val) {
795
+ _extraLen = val;
796
+ },
797
+ get extraLocalLength() {
798
+ return _localHeader.extraLen;
799
+ },
800
+ set extraLocalLength(val) {
801
+ _localHeader.extraLen = val;
802
+ },
803
+ get commentLength() {
804
+ return _comLen;
805
+ },
806
+ set commentLength(val) {
807
+ _comLen = val;
808
+ },
809
+ get diskNumStart() {
810
+ return _diskStart;
811
+ },
812
+ set diskNumStart(val) {
813
+ _diskStart = uint32(val);
814
+ },
815
+ get inAttr() {
816
+ return _inattr;
817
+ },
818
+ set inAttr(val) {
819
+ _inattr = uint32(val);
820
+ },
821
+ get attr() {
822
+ return _attr;
823
+ },
824
+ set attr(val) {
825
+ _attr = uint32(val);
826
+ },
827
+ // get Unix file permissions
828
+ get fileAttr() {
829
+ return (_attr || 0) >> 16 & 4095;
830
+ },
831
+ get offset() {
832
+ return _offset;
833
+ },
834
+ set offset(val) {
835
+ _offset = uint32(val);
836
+ },
837
+ get encrypted() {
838
+ return (_flags & Constants.FLG_ENC) === Constants.FLG_ENC;
839
+ },
840
+ get centralHeaderSize() {
841
+ return Constants.CENHDR + _fnameLen + _extraLen + _comLen;
842
+ },
843
+ get realDataOffset() {
844
+ return _offset + Constants.LOCHDR + _localHeader.fnameLen + _localHeader.extraLen;
845
+ },
846
+ get localHeader() {
847
+ return _localHeader;
848
+ },
849
+ loadLocalHeaderFromBinary: function(input) {
850
+ var data = input.slice(_offset, _offset + Constants.LOCHDR);
851
+ if (data.readUInt32LE(0) !== Constants.LOCSIG) {
852
+ throw Utils.Errors.INVALID_LOC();
853
+ }
854
+ _localHeader.version = data.readUInt16LE(Constants.LOCVER);
855
+ _localHeader.flags = data.readUInt16LE(Constants.LOCFLG);
856
+ _localHeader.method = data.readUInt16LE(Constants.LOCHOW);
857
+ _localHeader.time = data.readUInt32LE(Constants.LOCTIM);
858
+ _localHeader.crc = data.readUInt32LE(Constants.LOCCRC);
859
+ _localHeader.compressedSize = data.readUInt32LE(Constants.LOCSIZ);
860
+ _localHeader.size = data.readUInt32LE(Constants.LOCLEN);
861
+ _localHeader.fnameLen = data.readUInt16LE(Constants.LOCNAM);
862
+ _localHeader.extraLen = data.readUInt16LE(Constants.LOCEXT);
863
+ const extraStart = _offset + Constants.LOCHDR + _localHeader.fnameLen;
864
+ const extraEnd = extraStart + _localHeader.extraLen;
865
+ return input.slice(extraStart, extraEnd);
866
+ },
867
+ loadFromBinary: function(data) {
868
+ if (data.length !== Constants.CENHDR || data.readUInt32LE(0) !== Constants.CENSIG) {
869
+ throw Utils.Errors.INVALID_CEN();
870
+ }
871
+ _verMade = data.readUInt16LE(Constants.CENVEM);
872
+ _version = data.readUInt16LE(Constants.CENVER);
873
+ _flags = data.readUInt16LE(Constants.CENFLG);
874
+ _method = data.readUInt16LE(Constants.CENHOW);
875
+ _time = data.readUInt32LE(Constants.CENTIM);
876
+ _crc = data.readUInt32LE(Constants.CENCRC);
877
+ _compressedSize = data.readUInt32LE(Constants.CENSIZ);
878
+ _size = data.readUInt32LE(Constants.CENLEN);
879
+ _fnameLen = data.readUInt16LE(Constants.CENNAM);
880
+ _extraLen = data.readUInt16LE(Constants.CENEXT);
881
+ _comLen = data.readUInt16LE(Constants.CENCOM);
882
+ _diskStart = data.readUInt16LE(Constants.CENDSK);
883
+ _inattr = data.readUInt16LE(Constants.CENATT);
884
+ _attr = data.readUInt32LE(Constants.CENATX);
885
+ _offset = data.readUInt32LE(Constants.CENOFF);
886
+ },
887
+ localHeaderToBinary: function() {
888
+ var data = Buffer.alloc(Constants.LOCHDR);
889
+ data.writeUInt32LE(Constants.LOCSIG, 0);
890
+ data.writeUInt16LE(_version, Constants.LOCVER);
891
+ data.writeUInt16LE(_flags, Constants.LOCFLG);
892
+ data.writeUInt16LE(_method, Constants.LOCHOW);
893
+ data.writeUInt32LE(_time, Constants.LOCTIM);
894
+ data.writeUInt32LE(_crc, Constants.LOCCRC);
895
+ data.writeUInt32LE(_compressedSize, Constants.LOCSIZ);
896
+ data.writeUInt32LE(_size, Constants.LOCLEN);
897
+ data.writeUInt16LE(_fnameLen, Constants.LOCNAM);
898
+ data.writeUInt16LE(_localHeader.extraLen, Constants.LOCEXT);
899
+ return data;
900
+ },
901
+ centralHeaderToBinary: function() {
902
+ var data = Buffer.alloc(Constants.CENHDR + _fnameLen + _extraLen + _comLen);
903
+ data.writeUInt32LE(Constants.CENSIG, 0);
904
+ data.writeUInt16LE(_verMade, Constants.CENVEM);
905
+ data.writeUInt16LE(_version, Constants.CENVER);
906
+ data.writeUInt16LE(_flags, Constants.CENFLG);
907
+ data.writeUInt16LE(_method, Constants.CENHOW);
908
+ data.writeUInt32LE(_time, Constants.CENTIM);
909
+ data.writeUInt32LE(_crc, Constants.CENCRC);
910
+ data.writeUInt32LE(_compressedSize, Constants.CENSIZ);
911
+ data.writeUInt32LE(_size, Constants.CENLEN);
912
+ data.writeUInt16LE(_fnameLen, Constants.CENNAM);
913
+ data.writeUInt16LE(_extraLen, Constants.CENEXT);
914
+ data.writeUInt16LE(_comLen, Constants.CENCOM);
915
+ data.writeUInt16LE(_diskStart, Constants.CENDSK);
916
+ data.writeUInt16LE(_inattr, Constants.CENATT);
917
+ data.writeUInt32LE(_attr, Constants.CENATX);
918
+ data.writeUInt32LE(_offset, Constants.CENOFF);
919
+ return data;
920
+ },
921
+ toJSON: function() {
922
+ const bytes = function(nr) {
923
+ return nr + " bytes";
924
+ };
925
+ return {
926
+ made: _verMade,
927
+ version: _version,
928
+ flags: _flags,
929
+ method: Utils.methodToString(_method),
930
+ time: this.time,
931
+ crc: "0x" + _crc.toString(16).toUpperCase(),
932
+ compressedSize: bytes(_compressedSize),
933
+ size: bytes(_size),
934
+ fileNameLength: bytes(_fnameLen),
935
+ extraLength: bytes(_extraLen),
936
+ commentLength: bytes(_comLen),
937
+ diskNumStart: _diskStart,
938
+ inAttr: _inattr,
939
+ attr: _attr,
940
+ offset: _offset,
941
+ centralHeaderSize: bytes(Constants.CENHDR + _fnameLen + _extraLen + _comLen)
942
+ };
943
+ },
944
+ toString: function() {
945
+ return JSON.stringify(this.toJSON(), null, " ");
946
+ }
947
+ };
948
+ };
949
+ }
950
+ });
951
+
952
+ // ../../../node_modules/adm-zip/headers/mainHeader.js
953
+ var require_mainHeader = __commonJS({
954
+ "../../../node_modules/adm-zip/headers/mainHeader.js"(exports, module) {
955
+ var Utils = require_util();
956
+ var Constants = Utils.Constants;
957
+ module.exports = function() {
958
+ var _volumeEntries = 0, _totalEntries = 0, _size = 0, _offset = 0, _commentLength = 0;
959
+ return {
960
+ get diskEntries() {
961
+ return _volumeEntries;
962
+ },
963
+ set diskEntries(val) {
964
+ _volumeEntries = _totalEntries = val;
965
+ },
966
+ get totalEntries() {
967
+ return _totalEntries;
968
+ },
969
+ set totalEntries(val) {
970
+ _totalEntries = _volumeEntries = val;
971
+ },
972
+ get size() {
973
+ return _size;
974
+ },
975
+ set size(val) {
976
+ _size = val;
977
+ },
978
+ get offset() {
979
+ return _offset;
980
+ },
981
+ set offset(val) {
982
+ _offset = val;
983
+ },
984
+ get commentLength() {
985
+ return _commentLength;
986
+ },
987
+ set commentLength(val) {
988
+ _commentLength = val;
989
+ },
990
+ get mainHeaderSize() {
991
+ return Constants.ENDHDR + _commentLength;
992
+ },
993
+ loadFromBinary: function(data) {
994
+ if ((data.length !== Constants.ENDHDR || data.readUInt32LE(0) !== Constants.ENDSIG) && (data.length < Constants.ZIP64HDR || data.readUInt32LE(0) !== Constants.ZIP64SIG)) {
995
+ throw Utils.Errors.INVALID_END();
996
+ }
997
+ if (data.readUInt32LE(0) === Constants.ENDSIG) {
998
+ _volumeEntries = data.readUInt16LE(Constants.ENDSUB);
999
+ _totalEntries = data.readUInt16LE(Constants.ENDTOT);
1000
+ _size = data.readUInt32LE(Constants.ENDSIZ);
1001
+ _offset = data.readUInt32LE(Constants.ENDOFF);
1002
+ _commentLength = data.readUInt16LE(Constants.ENDCOM);
1003
+ } else {
1004
+ _volumeEntries = Utils.readBigUInt64LE(data, Constants.ZIP64SUB);
1005
+ _totalEntries = Utils.readBigUInt64LE(data, Constants.ZIP64TOT);
1006
+ _size = Utils.readBigUInt64LE(data, Constants.ZIP64SIZE);
1007
+ _offset = Utils.readBigUInt64LE(data, Constants.ZIP64OFF);
1008
+ _commentLength = 0;
1009
+ }
1010
+ },
1011
+ toBinary: function() {
1012
+ var b = Buffer.alloc(Constants.ENDHDR + _commentLength);
1013
+ b.writeUInt32LE(Constants.ENDSIG, 0);
1014
+ b.writeUInt32LE(0, 4);
1015
+ b.writeUInt16LE(_volumeEntries, Constants.ENDSUB);
1016
+ b.writeUInt16LE(_totalEntries, Constants.ENDTOT);
1017
+ b.writeUInt32LE(_size, Constants.ENDSIZ);
1018
+ b.writeUInt32LE(_offset, Constants.ENDOFF);
1019
+ b.writeUInt16LE(_commentLength, Constants.ENDCOM);
1020
+ b.fill(" ", Constants.ENDHDR);
1021
+ return b;
1022
+ },
1023
+ toJSON: function() {
1024
+ const offset = function(nr, len) {
1025
+ let offs = nr.toString(16).toUpperCase();
1026
+ while (offs.length < len) offs = "0" + offs;
1027
+ return "0x" + offs;
1028
+ };
1029
+ return {
1030
+ diskEntries: _volumeEntries,
1031
+ totalEntries: _totalEntries,
1032
+ size: _size + " bytes",
1033
+ offset: offset(_offset, 4),
1034
+ commentLength: _commentLength
1035
+ };
1036
+ },
1037
+ toString: function() {
1038
+ return JSON.stringify(this.toJSON(), null, " ");
1039
+ }
1040
+ };
1041
+ };
1042
+ }
1043
+ });
1044
+
1045
+ // ../../../node_modules/adm-zip/headers/index.js
1046
+ var require_headers = __commonJS({
1047
+ "../../../node_modules/adm-zip/headers/index.js"(exports) {
1048
+ exports.EntryHeader = require_entryHeader();
1049
+ exports.MainHeader = require_mainHeader();
1050
+ }
1051
+ });
1052
+
1053
+ // ../../../node_modules/adm-zip/methods/deflater.js
1054
+ var require_deflater = __commonJS({
1055
+ "../../../node_modules/adm-zip/methods/deflater.js"(exports, module) {
1056
+ module.exports = function(inbuf) {
1057
+ var zlib = __require("zlib");
1058
+ var opts = { chunkSize: (parseInt(inbuf.length / 1024) + 1) * 1024 };
1059
+ return {
1060
+ deflate: function() {
1061
+ return zlib.deflateRawSync(inbuf, opts);
1062
+ },
1063
+ deflateAsync: function(callback) {
1064
+ var tmp = zlib.createDeflateRaw(opts), parts = [], total = 0;
1065
+ tmp.on("data", function(data) {
1066
+ parts.push(data);
1067
+ total += data.length;
1068
+ });
1069
+ tmp.on("end", function() {
1070
+ var buf = Buffer.alloc(total), written = 0;
1071
+ buf.fill(0);
1072
+ for (var i = 0; i < parts.length; i++) {
1073
+ var part = parts[i];
1074
+ part.copy(buf, written);
1075
+ written += part.length;
1076
+ }
1077
+ callback && callback(buf);
1078
+ });
1079
+ tmp.end(inbuf);
1080
+ }
1081
+ };
1082
+ };
1083
+ }
1084
+ });
1085
+
1086
+ // ../../../node_modules/adm-zip/methods/inflater.js
1087
+ var require_inflater = __commonJS({
1088
+ "../../../node_modules/adm-zip/methods/inflater.js"(exports, module) {
1089
+ var version = +(process.versions ? process.versions.node : "").split(".")[0] || 0;
1090
+ module.exports = function(inbuf, expectedLength) {
1091
+ var zlib = __require("zlib");
1092
+ const option = version >= 15 && expectedLength > 0 ? { maxOutputLength: expectedLength } : {};
1093
+ return {
1094
+ inflate: function() {
1095
+ return zlib.inflateRawSync(inbuf, option);
1096
+ },
1097
+ inflateAsync: function(callback) {
1098
+ var tmp = zlib.createInflateRaw(option), parts = [], total = 0;
1099
+ tmp.on("data", function(data) {
1100
+ parts.push(data);
1101
+ total += data.length;
1102
+ });
1103
+ tmp.on("end", function() {
1104
+ var buf = Buffer.alloc(total), written = 0;
1105
+ buf.fill(0);
1106
+ for (var i = 0; i < parts.length; i++) {
1107
+ var part = parts[i];
1108
+ part.copy(buf, written);
1109
+ written += part.length;
1110
+ }
1111
+ callback && callback(buf);
1112
+ });
1113
+ tmp.end(inbuf);
1114
+ }
1115
+ };
1116
+ };
1117
+ }
1118
+ });
1119
+
1120
+ // ../../../node_modules/adm-zip/methods/zipcrypto.js
1121
+ var require_zipcrypto = __commonJS({
1122
+ "../../../node_modules/adm-zip/methods/zipcrypto.js"(exports, module) {
1123
+ var { randomFillSync } = __require("crypto");
1124
+ var Errors = require_errors();
1125
+ var crctable = new Uint32Array(256).map((t, crc) => {
1126
+ for (let j = 0; j < 8; j++) {
1127
+ if (0 !== (crc & 1)) {
1128
+ crc = crc >>> 1 ^ 3988292384;
1129
+ } else {
1130
+ crc >>>= 1;
1131
+ }
1132
+ }
1133
+ return crc >>> 0;
1134
+ });
1135
+ var uMul = (a, b) => Math.imul(a, b) >>> 0;
1136
+ var crc32update = (pCrc32, bval) => {
1137
+ return crctable[(pCrc32 ^ bval) & 255] ^ pCrc32 >>> 8;
1138
+ };
1139
+ var genSalt = () => {
1140
+ if ("function" === typeof randomFillSync) {
1141
+ return randomFillSync(Buffer.alloc(12));
1142
+ } else {
1143
+ return genSalt.node();
1144
+ }
1145
+ };
1146
+ genSalt.node = () => {
1147
+ const salt = Buffer.alloc(12);
1148
+ const len = salt.length;
1149
+ for (let i = 0; i < len; i++) salt[i] = Math.random() * 256 & 255;
1150
+ return salt;
1151
+ };
1152
+ var config = {
1153
+ genSalt
1154
+ };
1155
+ function Initkeys(pw) {
1156
+ const pass = Buffer.isBuffer(pw) ? pw : Buffer.from(pw);
1157
+ this.keys = new Uint32Array([305419896, 591751049, 878082192]);
1158
+ for (let i = 0; i < pass.length; i++) {
1159
+ this.updateKeys(pass[i]);
1160
+ }
1161
+ }
1162
+ Initkeys.prototype.updateKeys = function(byteValue) {
1163
+ const keys = this.keys;
1164
+ keys[0] = crc32update(keys[0], byteValue);
1165
+ keys[1] += keys[0] & 255;
1166
+ keys[1] = uMul(keys[1], 134775813) + 1;
1167
+ keys[2] = crc32update(keys[2], keys[1] >>> 24);
1168
+ return byteValue;
1169
+ };
1170
+ Initkeys.prototype.next = function() {
1171
+ const k = (this.keys[2] | 2) >>> 0;
1172
+ return uMul(k, k ^ 1) >> 8 & 255;
1173
+ };
1174
+ function make_decrypter(pwd) {
1175
+ const keys = new Initkeys(pwd);
1176
+ return function(data) {
1177
+ const result = Buffer.alloc(data.length);
1178
+ let pos = 0;
1179
+ for (let c of data) {
1180
+ result[pos++] = keys.updateKeys(c ^ keys.next());
1181
+ }
1182
+ return result;
1183
+ };
1184
+ }
1185
+ function make_encrypter(pwd) {
1186
+ const keys = new Initkeys(pwd);
1187
+ return function(data, result, pos = 0) {
1188
+ if (!result) result = Buffer.alloc(data.length);
1189
+ for (let c of data) {
1190
+ const k = keys.next();
1191
+ result[pos++] = c ^ k;
1192
+ keys.updateKeys(c);
1193
+ }
1194
+ return result;
1195
+ };
1196
+ }
1197
+ function decrypt(data, header, pwd) {
1198
+ if (!data || !Buffer.isBuffer(data) || data.length < 12) {
1199
+ return Buffer.alloc(0);
1200
+ }
1201
+ const decrypter = make_decrypter(pwd);
1202
+ const salt = decrypter(data.slice(0, 12));
1203
+ const verifyByte = (header.flags & 8) === 8 ? header.timeHighByte : header.crc >>> 24;
1204
+ if (salt[11] !== verifyByte) {
1205
+ throw Errors.WRONG_PASSWORD();
1206
+ }
1207
+ return decrypter(data.slice(12));
1208
+ }
1209
+ function _salter(data) {
1210
+ if (Buffer.isBuffer(data) && data.length >= 12) {
1211
+ config.genSalt = function() {
1212
+ return data.slice(0, 12);
1213
+ };
1214
+ } else if (data === "node") {
1215
+ config.genSalt = genSalt.node;
1216
+ } else {
1217
+ config.genSalt = genSalt;
1218
+ }
1219
+ }
1220
+ function encrypt(data, header, pwd, oldlike = false) {
1221
+ if (data == null) data = Buffer.alloc(0);
1222
+ if (!Buffer.isBuffer(data)) data = Buffer.from(data.toString());
1223
+ const encrypter = make_encrypter(pwd);
1224
+ const salt = config.genSalt();
1225
+ salt[11] = header.crc >>> 24 & 255;
1226
+ if (oldlike) salt[10] = header.crc >>> 16 & 255;
1227
+ const result = Buffer.alloc(data.length + 12);
1228
+ encrypter(salt, result);
1229
+ return encrypter(data, result, 12);
1230
+ }
1231
+ module.exports = { decrypt, encrypt, _salter };
1232
+ }
1233
+ });
1234
+
1235
+ // ../../../node_modules/adm-zip/methods/index.js
1236
+ var require_methods = __commonJS({
1237
+ "../../../node_modules/adm-zip/methods/index.js"(exports) {
1238
+ exports.Deflater = require_deflater();
1239
+ exports.Inflater = require_inflater();
1240
+ exports.ZipCrypto = require_zipcrypto();
1241
+ }
1242
+ });
1243
+
1244
+ // ../../../node_modules/adm-zip/zipEntry.js
1245
+ var require_zipEntry = __commonJS({
1246
+ "../../../node_modules/adm-zip/zipEntry.js"(exports, module) {
1247
+ var Utils = require_util();
1248
+ var Headers = require_headers();
1249
+ var Constants = Utils.Constants;
1250
+ var Methods = require_methods();
1251
+ module.exports = function(options, input) {
1252
+ var _centralHeader = new Headers.EntryHeader(), _entryName = Buffer.alloc(0), _comment = Buffer.alloc(0), _isDirectory = false, uncompressedData = null, _extra = Buffer.alloc(0), _extralocal = Buffer.alloc(0), _efs = true;
1253
+ const opts = options;
1254
+ const decoder = typeof opts.decoder === "object" ? opts.decoder : Utils.decoder;
1255
+ _efs = decoder.hasOwnProperty("efs") ? decoder.efs : false;
1256
+ function getCompressedDataFromZip() {
1257
+ if (!input || !(input instanceof Uint8Array)) {
1258
+ return Buffer.alloc(0);
1259
+ }
1260
+ _extralocal = _centralHeader.loadLocalHeaderFromBinary(input);
1261
+ return input.slice(_centralHeader.realDataOffset, _centralHeader.realDataOffset + _centralHeader.compressedSize);
1262
+ }
1263
+ function crc32OK(data) {
1264
+ if (!_centralHeader.flags_desc) {
1265
+ if (Utils.crc32(data) !== _centralHeader.localHeader.crc) {
1266
+ return false;
1267
+ }
1268
+ } else {
1269
+ const descriptor = {};
1270
+ const dataEndOffset = _centralHeader.realDataOffset + _centralHeader.compressedSize;
1271
+ if (input.readUInt32LE(dataEndOffset) == Constants.LOCSIG || input.readUInt32LE(dataEndOffset) == Constants.CENSIG) {
1272
+ throw Utils.Errors.DESCRIPTOR_NOT_EXIST();
1273
+ }
1274
+ if (input.readUInt32LE(dataEndOffset) == Constants.EXTSIG) {
1275
+ descriptor.crc = input.readUInt32LE(dataEndOffset + Constants.EXTCRC);
1276
+ descriptor.compressedSize = input.readUInt32LE(dataEndOffset + Constants.EXTSIZ);
1277
+ descriptor.size = input.readUInt32LE(dataEndOffset + Constants.EXTLEN);
1278
+ } else if (input.readUInt16LE(dataEndOffset + 12) === 19280) {
1279
+ descriptor.crc = input.readUInt32LE(dataEndOffset + Constants.EXTCRC - 4);
1280
+ descriptor.compressedSize = input.readUInt32LE(dataEndOffset + Constants.EXTSIZ - 4);
1281
+ descriptor.size = input.readUInt32LE(dataEndOffset + Constants.EXTLEN - 4);
1282
+ } else {
1283
+ throw Utils.Errors.DESCRIPTOR_UNKNOWN();
1284
+ }
1285
+ if (descriptor.compressedSize !== _centralHeader.compressedSize || descriptor.size !== _centralHeader.size || descriptor.crc !== _centralHeader.crc) {
1286
+ throw Utils.Errors.DESCRIPTOR_FAULTY();
1287
+ }
1288
+ if (Utils.crc32(data) !== descriptor.crc) {
1289
+ return false;
1290
+ }
1291
+ }
1292
+ return true;
1293
+ }
1294
+ function decompress(async, callback, pass) {
1295
+ if (typeof callback === "undefined" && typeof async === "string") {
1296
+ pass = async;
1297
+ async = void 0;
1298
+ }
1299
+ if (_isDirectory) {
1300
+ if (async && callback) {
1301
+ callback(Buffer.alloc(0), Utils.Errors.DIRECTORY_CONTENT_ERROR());
1302
+ }
1303
+ return Buffer.alloc(0);
1304
+ }
1305
+ var compressedData = getCompressedDataFromZip();
1306
+ if (compressedData.length === 0) {
1307
+ if (async && callback) callback(compressedData);
1308
+ return compressedData;
1309
+ }
1310
+ if (_centralHeader.encrypted) {
1311
+ if ("string" !== typeof pass && !Buffer.isBuffer(pass)) {
1312
+ throw Utils.Errors.INVALID_PASS_PARAM();
1313
+ }
1314
+ compressedData = Methods.ZipCrypto.decrypt(compressedData, _centralHeader, pass);
1315
+ }
1316
+ var data = Buffer.alloc(_centralHeader.size);
1317
+ switch (_centralHeader.method) {
1318
+ case Utils.Constants.STORED:
1319
+ compressedData.copy(data);
1320
+ if (!crc32OK(data)) {
1321
+ if (async && callback) callback(data, Utils.Errors.BAD_CRC());
1322
+ throw Utils.Errors.BAD_CRC();
1323
+ } else {
1324
+ if (async && callback) callback(data);
1325
+ return data;
1326
+ }
1327
+ case Utils.Constants.DEFLATED:
1328
+ var inflater = new Methods.Inflater(compressedData, _centralHeader.size);
1329
+ if (!async) {
1330
+ const result = inflater.inflate(data);
1331
+ result.copy(data, 0);
1332
+ if (!crc32OK(data)) {
1333
+ throw Utils.Errors.BAD_CRC(`"${decoder.decode(_entryName)}"`);
1334
+ }
1335
+ return data;
1336
+ } else {
1337
+ inflater.inflateAsync(function(result) {
1338
+ result.copy(result, 0);
1339
+ if (callback) {
1340
+ if (!crc32OK(result)) {
1341
+ callback(result, Utils.Errors.BAD_CRC());
1342
+ } else {
1343
+ callback(result);
1344
+ }
1345
+ }
1346
+ });
1347
+ }
1348
+ break;
1349
+ default:
1350
+ if (async && callback) callback(Buffer.alloc(0), Utils.Errors.UNKNOWN_METHOD());
1351
+ throw Utils.Errors.UNKNOWN_METHOD();
1352
+ }
1353
+ }
1354
+ function compress(async, callback) {
1355
+ if ((!uncompressedData || !uncompressedData.length) && Buffer.isBuffer(input)) {
1356
+ if (async && callback) callback(getCompressedDataFromZip());
1357
+ return getCompressedDataFromZip();
1358
+ }
1359
+ if (uncompressedData.length && !_isDirectory) {
1360
+ var compressedData;
1361
+ switch (_centralHeader.method) {
1362
+ case Utils.Constants.STORED:
1363
+ _centralHeader.compressedSize = _centralHeader.size;
1364
+ compressedData = Buffer.alloc(uncompressedData.length);
1365
+ uncompressedData.copy(compressedData);
1366
+ if (async && callback) callback(compressedData);
1367
+ return compressedData;
1368
+ default:
1369
+ case Utils.Constants.DEFLATED:
1370
+ var deflater = new Methods.Deflater(uncompressedData);
1371
+ if (!async) {
1372
+ var deflated = deflater.deflate();
1373
+ _centralHeader.compressedSize = deflated.length;
1374
+ return deflated;
1375
+ } else {
1376
+ deflater.deflateAsync(function(data) {
1377
+ compressedData = Buffer.alloc(data.length);
1378
+ _centralHeader.compressedSize = data.length;
1379
+ data.copy(compressedData);
1380
+ callback && callback(compressedData);
1381
+ });
1382
+ }
1383
+ deflater = null;
1384
+ break;
1385
+ }
1386
+ } else if (async && callback) {
1387
+ callback(Buffer.alloc(0));
1388
+ } else {
1389
+ return Buffer.alloc(0);
1390
+ }
1391
+ }
1392
+ function readUInt64LE(buffer, offset) {
1393
+ return (buffer.readUInt32LE(offset + 4) << 4) + buffer.readUInt32LE(offset);
1394
+ }
1395
+ function parseExtra(data) {
1396
+ try {
1397
+ var offset = 0;
1398
+ var signature, size, part;
1399
+ while (offset + 4 < data.length) {
1400
+ signature = data.readUInt16LE(offset);
1401
+ offset += 2;
1402
+ size = data.readUInt16LE(offset);
1403
+ offset += 2;
1404
+ part = data.slice(offset, offset + size);
1405
+ offset += size;
1406
+ if (Constants.ID_ZIP64 === signature) {
1407
+ parseZip64ExtendedInformation(part);
1408
+ }
1409
+ }
1410
+ } catch (error) {
1411
+ throw Utils.Errors.EXTRA_FIELD_PARSE_ERROR();
1412
+ }
1413
+ }
1414
+ function parseZip64ExtendedInformation(data) {
1415
+ var size, compressedSize, offset, diskNumStart;
1416
+ if (data.length >= Constants.EF_ZIP64_SCOMP) {
1417
+ size = readUInt64LE(data, Constants.EF_ZIP64_SUNCOMP);
1418
+ if (_centralHeader.size === Constants.EF_ZIP64_OR_32) {
1419
+ _centralHeader.size = size;
1420
+ }
1421
+ }
1422
+ if (data.length >= Constants.EF_ZIP64_RHO) {
1423
+ compressedSize = readUInt64LE(data, Constants.EF_ZIP64_SCOMP);
1424
+ if (_centralHeader.compressedSize === Constants.EF_ZIP64_OR_32) {
1425
+ _centralHeader.compressedSize = compressedSize;
1426
+ }
1427
+ }
1428
+ if (data.length >= Constants.EF_ZIP64_DSN) {
1429
+ offset = readUInt64LE(data, Constants.EF_ZIP64_RHO);
1430
+ if (_centralHeader.offset === Constants.EF_ZIP64_OR_32) {
1431
+ _centralHeader.offset = offset;
1432
+ }
1433
+ }
1434
+ if (data.length >= Constants.EF_ZIP64_DSN + 4) {
1435
+ diskNumStart = data.readUInt32LE(Constants.EF_ZIP64_DSN);
1436
+ if (_centralHeader.diskNumStart === Constants.EF_ZIP64_OR_16) {
1437
+ _centralHeader.diskNumStart = diskNumStart;
1438
+ }
1439
+ }
1440
+ }
1441
+ return {
1442
+ get entryName() {
1443
+ return decoder.decode(_entryName);
1444
+ },
1445
+ get rawEntryName() {
1446
+ return _entryName;
1447
+ },
1448
+ set entryName(val) {
1449
+ _entryName = Utils.toBuffer(val, decoder.encode);
1450
+ var lastChar = _entryName[_entryName.length - 1];
1451
+ _isDirectory = lastChar === 47 || lastChar === 92;
1452
+ _centralHeader.fileNameLength = _entryName.length;
1453
+ },
1454
+ get efs() {
1455
+ if (typeof _efs === "function") {
1456
+ return _efs(this.entryName);
1457
+ } else {
1458
+ return _efs;
1459
+ }
1460
+ },
1461
+ get extra() {
1462
+ return _extra;
1463
+ },
1464
+ set extra(val) {
1465
+ _extra = val;
1466
+ _centralHeader.extraLength = val.length;
1467
+ parseExtra(val);
1468
+ },
1469
+ get comment() {
1470
+ return decoder.decode(_comment);
1471
+ },
1472
+ set comment(val) {
1473
+ _comment = Utils.toBuffer(val, decoder.encode);
1474
+ _centralHeader.commentLength = _comment.length;
1475
+ if (_comment.length > 65535) throw Utils.Errors.COMMENT_TOO_LONG();
1476
+ },
1477
+ get name() {
1478
+ var n = decoder.decode(_entryName);
1479
+ return _isDirectory ? n.substr(n.length - 1).split("/").pop() : n.split("/").pop();
1480
+ },
1481
+ get isDirectory() {
1482
+ return _isDirectory;
1483
+ },
1484
+ getCompressedData: function() {
1485
+ return compress(false, null);
1486
+ },
1487
+ getCompressedDataAsync: function(callback) {
1488
+ compress(true, callback);
1489
+ },
1490
+ setData: function(value) {
1491
+ uncompressedData = Utils.toBuffer(value, Utils.decoder.encode);
1492
+ if (!_isDirectory && uncompressedData.length) {
1493
+ _centralHeader.size = uncompressedData.length;
1494
+ _centralHeader.method = Utils.Constants.DEFLATED;
1495
+ _centralHeader.crc = Utils.crc32(value);
1496
+ _centralHeader.changed = true;
1497
+ } else {
1498
+ _centralHeader.method = Utils.Constants.STORED;
1499
+ }
1500
+ },
1501
+ getData: function(pass) {
1502
+ if (_centralHeader.changed) {
1503
+ return uncompressedData;
1504
+ } else {
1505
+ return decompress(false, null, pass);
1506
+ }
1507
+ },
1508
+ getDataAsync: function(callback, pass) {
1509
+ if (_centralHeader.changed) {
1510
+ callback(uncompressedData);
1511
+ } else {
1512
+ decompress(true, callback, pass);
1513
+ }
1514
+ },
1515
+ set attr(attr) {
1516
+ _centralHeader.attr = attr;
1517
+ },
1518
+ get attr() {
1519
+ return _centralHeader.attr;
1520
+ },
1521
+ set header(data) {
1522
+ _centralHeader.loadFromBinary(data);
1523
+ },
1524
+ get header() {
1525
+ return _centralHeader;
1526
+ },
1527
+ packCentralHeader: function() {
1528
+ _centralHeader.flags_efs = this.efs;
1529
+ _centralHeader.extraLength = _extra.length;
1530
+ var header = _centralHeader.centralHeaderToBinary();
1531
+ var addpos = Utils.Constants.CENHDR;
1532
+ _entryName.copy(header, addpos);
1533
+ addpos += _entryName.length;
1534
+ _extra.copy(header, addpos);
1535
+ addpos += _centralHeader.extraLength;
1536
+ _comment.copy(header, addpos);
1537
+ return header;
1538
+ },
1539
+ packLocalHeader: function() {
1540
+ let addpos = 0;
1541
+ _centralHeader.flags_efs = this.efs;
1542
+ _centralHeader.extraLocalLength = _extralocal.length;
1543
+ const localHeaderBuf = _centralHeader.localHeaderToBinary();
1544
+ const localHeader = Buffer.alloc(localHeaderBuf.length + _entryName.length + _centralHeader.extraLocalLength);
1545
+ localHeaderBuf.copy(localHeader, addpos);
1546
+ addpos += localHeaderBuf.length;
1547
+ _entryName.copy(localHeader, addpos);
1548
+ addpos += _entryName.length;
1549
+ _extralocal.copy(localHeader, addpos);
1550
+ addpos += _extralocal.length;
1551
+ return localHeader;
1552
+ },
1553
+ toJSON: function() {
1554
+ const bytes = function(nr) {
1555
+ return "<" + (nr && nr.length + " bytes buffer" || "null") + ">";
1556
+ };
1557
+ return {
1558
+ entryName: this.entryName,
1559
+ name: this.name,
1560
+ comment: this.comment,
1561
+ isDirectory: this.isDirectory,
1562
+ header: _centralHeader.toJSON(),
1563
+ compressedData: bytes(input),
1564
+ data: bytes(uncompressedData)
1565
+ };
1566
+ },
1567
+ toString: function() {
1568
+ return JSON.stringify(this.toJSON(), null, " ");
1569
+ }
1570
+ };
1571
+ };
1572
+ }
1573
+ });
1574
+
1575
+ // ../../../node_modules/adm-zip/zipFile.js
1576
+ var require_zipFile = __commonJS({
1577
+ "../../../node_modules/adm-zip/zipFile.js"(exports, module) {
1578
+ var ZipEntry = require_zipEntry();
1579
+ var Headers = require_headers();
1580
+ var Utils = require_util();
1581
+ module.exports = function(inBuffer, options) {
1582
+ var entryList = [], entryTable = {}, _comment = Buffer.alloc(0), mainHeader = new Headers.MainHeader(), loadedEntries = false;
1583
+ const temporary = /* @__PURE__ */ new Set();
1584
+ const opts = options;
1585
+ const { noSort, decoder } = opts;
1586
+ if (inBuffer) {
1587
+ readMainHeader(opts.readEntries);
1588
+ } else {
1589
+ loadedEntries = true;
1590
+ }
1591
+ function makeTemporaryFolders() {
1592
+ const foldersList = /* @__PURE__ */ new Set();
1593
+ for (const elem of Object.keys(entryTable)) {
1594
+ const elements = elem.split("/");
1595
+ elements.pop();
1596
+ if (!elements.length) continue;
1597
+ for (let i = 0; i < elements.length; i++) {
1598
+ const sub = elements.slice(0, i + 1).join("/") + "/";
1599
+ foldersList.add(sub);
1600
+ }
1601
+ }
1602
+ for (const elem of foldersList) {
1603
+ if (!(elem in entryTable)) {
1604
+ const tempfolder = new ZipEntry(opts);
1605
+ tempfolder.entryName = elem;
1606
+ tempfolder.attr = 16;
1607
+ tempfolder.temporary = true;
1608
+ entryList.push(tempfolder);
1609
+ entryTable[tempfolder.entryName] = tempfolder;
1610
+ temporary.add(tempfolder);
1611
+ }
1612
+ }
1613
+ }
1614
+ function readEntries() {
1615
+ loadedEntries = true;
1616
+ entryTable = {};
1617
+ if (mainHeader.diskEntries > (inBuffer.length - mainHeader.offset) / Utils.Constants.CENHDR) {
1618
+ throw Utils.Errors.DISK_ENTRY_TOO_LARGE();
1619
+ }
1620
+ entryList = new Array(mainHeader.diskEntries);
1621
+ var index = mainHeader.offset;
1622
+ for (var i = 0; i < entryList.length; i++) {
1623
+ var tmp = index, entry = new ZipEntry(opts, inBuffer);
1624
+ entry.header = inBuffer.slice(tmp, tmp += Utils.Constants.CENHDR);
1625
+ entry.entryName = inBuffer.slice(tmp, tmp += entry.header.fileNameLength);
1626
+ if (entry.header.extraLength) {
1627
+ entry.extra = inBuffer.slice(tmp, tmp += entry.header.extraLength);
1628
+ }
1629
+ if (entry.header.commentLength) entry.comment = inBuffer.slice(tmp, tmp + entry.header.commentLength);
1630
+ index += entry.header.centralHeaderSize;
1631
+ entryList[i] = entry;
1632
+ entryTable[entry.entryName] = entry;
1633
+ }
1634
+ temporary.clear();
1635
+ makeTemporaryFolders();
1636
+ }
1637
+ function readMainHeader(readNow) {
1638
+ var i = inBuffer.length - Utils.Constants.ENDHDR, max = Math.max(0, i - 65535), n = max, endStart = inBuffer.length, endOffset = -1, commentEnd = 0;
1639
+ const trailingSpace = typeof opts.trailingSpace === "boolean" ? opts.trailingSpace : false;
1640
+ if (trailingSpace) max = 0;
1641
+ for (i; i >= n; i--) {
1642
+ if (inBuffer[i] !== 80) continue;
1643
+ if (inBuffer.readUInt32LE(i) === Utils.Constants.ENDSIG) {
1644
+ endOffset = i;
1645
+ commentEnd = i;
1646
+ endStart = i + Utils.Constants.ENDHDR;
1647
+ n = i - Utils.Constants.END64HDR;
1648
+ continue;
1649
+ }
1650
+ if (inBuffer.readUInt32LE(i) === Utils.Constants.END64SIG) {
1651
+ n = max;
1652
+ continue;
1653
+ }
1654
+ if (inBuffer.readUInt32LE(i) === Utils.Constants.ZIP64SIG) {
1655
+ endOffset = i;
1656
+ endStart = i + Utils.readBigUInt64LE(inBuffer, i + Utils.Constants.ZIP64SIZE) + Utils.Constants.ZIP64LEAD;
1657
+ break;
1658
+ }
1659
+ }
1660
+ if (endOffset == -1) throw Utils.Errors.INVALID_FORMAT();
1661
+ mainHeader.loadFromBinary(inBuffer.slice(endOffset, endStart));
1662
+ if (mainHeader.commentLength) {
1663
+ _comment = inBuffer.slice(commentEnd + Utils.Constants.ENDHDR);
1664
+ }
1665
+ if (readNow) readEntries();
1666
+ }
1667
+ function sortEntries() {
1668
+ if (entryList.length > 1 && !noSort) {
1669
+ entryList.sort((a, b) => a.entryName.toLowerCase().localeCompare(b.entryName.toLowerCase()));
1670
+ }
1671
+ }
1672
+ return {
1673
+ /**
1674
+ * Returns an array of ZipEntry objects existent in the current opened archive
1675
+ * @return Array
1676
+ */
1677
+ get entries() {
1678
+ if (!loadedEntries) {
1679
+ readEntries();
1680
+ }
1681
+ return entryList.filter((e) => !temporary.has(e));
1682
+ },
1683
+ /**
1684
+ * Archive comment
1685
+ * @return {String}
1686
+ */
1687
+ get comment() {
1688
+ return decoder.decode(_comment);
1689
+ },
1690
+ set comment(val) {
1691
+ _comment = Utils.toBuffer(val, decoder.encode);
1692
+ mainHeader.commentLength = _comment.length;
1693
+ },
1694
+ getEntryCount: function() {
1695
+ if (!loadedEntries) {
1696
+ return mainHeader.diskEntries;
1697
+ }
1698
+ return entryList.length;
1699
+ },
1700
+ forEach: function(callback) {
1701
+ this.entries.forEach(callback);
1702
+ },
1703
+ /**
1704
+ * Returns a reference to the entry with the given name or null if entry is inexistent
1705
+ *
1706
+ * @param entryName
1707
+ * @return ZipEntry
1708
+ */
1709
+ getEntry: function(entryName) {
1710
+ if (!loadedEntries) {
1711
+ readEntries();
1712
+ }
1713
+ return entryTable[entryName] || null;
1714
+ },
1715
+ /**
1716
+ * Adds the given entry to the entry list
1717
+ *
1718
+ * @param entry
1719
+ */
1720
+ setEntry: function(entry) {
1721
+ if (!loadedEntries) {
1722
+ readEntries();
1723
+ }
1724
+ entryList.push(entry);
1725
+ entryTable[entry.entryName] = entry;
1726
+ mainHeader.totalEntries = entryList.length;
1727
+ },
1728
+ /**
1729
+ * Removes the file with the given name from the entry list.
1730
+ *
1731
+ * If the entry is a directory, then all nested files and directories will be removed
1732
+ * @param entryName
1733
+ * @returns {void}
1734
+ */
1735
+ deleteFile: function(entryName, withsubfolders = true) {
1736
+ if (!loadedEntries) {
1737
+ readEntries();
1738
+ }
1739
+ const entry = entryTable[entryName];
1740
+ const list = this.getEntryChildren(entry, withsubfolders).map((child) => child.entryName);
1741
+ list.forEach(this.deleteEntry);
1742
+ },
1743
+ /**
1744
+ * Removes the entry with the given name from the entry list.
1745
+ *
1746
+ * @param {string} entryName
1747
+ * @returns {void}
1748
+ */
1749
+ deleteEntry: function(entryName) {
1750
+ if (!loadedEntries) {
1751
+ readEntries();
1752
+ }
1753
+ const entry = entryTable[entryName];
1754
+ const index = entryList.indexOf(entry);
1755
+ if (index >= 0) {
1756
+ entryList.splice(index, 1);
1757
+ delete entryTable[entryName];
1758
+ mainHeader.totalEntries = entryList.length;
1759
+ }
1760
+ },
1761
+ /**
1762
+ * Iterates and returns all nested files and directories of the given entry
1763
+ *
1764
+ * @param entry
1765
+ * @return Array
1766
+ */
1767
+ getEntryChildren: function(entry, subfolders = true) {
1768
+ if (!loadedEntries) {
1769
+ readEntries();
1770
+ }
1771
+ if (typeof entry === "object") {
1772
+ if (entry.isDirectory && subfolders) {
1773
+ const list = [];
1774
+ const name = entry.entryName;
1775
+ for (const zipEntry of entryList) {
1776
+ if (zipEntry.entryName.startsWith(name)) {
1777
+ list.push(zipEntry);
1778
+ }
1779
+ }
1780
+ return list;
1781
+ } else {
1782
+ return [entry];
1783
+ }
1784
+ }
1785
+ return [];
1786
+ },
1787
+ /**
1788
+ * How many child elements entry has
1789
+ *
1790
+ * @param {ZipEntry} entry
1791
+ * @return {integer}
1792
+ */
1793
+ getChildCount: function(entry) {
1794
+ if (entry && entry.isDirectory) {
1795
+ const list = this.getEntryChildren(entry);
1796
+ return list.includes(entry) ? list.length - 1 : list.length;
1797
+ }
1798
+ return 0;
1799
+ },
1800
+ /**
1801
+ * Returns the zip file
1802
+ *
1803
+ * @return Buffer
1804
+ */
1805
+ compressToBuffer: function() {
1806
+ if (!loadedEntries) {
1807
+ readEntries();
1808
+ }
1809
+ sortEntries();
1810
+ const dataBlock = [];
1811
+ const headerBlocks = [];
1812
+ let totalSize = 0;
1813
+ let dindex = 0;
1814
+ mainHeader.size = 0;
1815
+ mainHeader.offset = 0;
1816
+ let totalEntries = 0;
1817
+ for (const entry of this.entries) {
1818
+ const compressedData = entry.getCompressedData();
1819
+ entry.header.offset = dindex;
1820
+ const localHeader = entry.packLocalHeader();
1821
+ const dataLength = localHeader.length + compressedData.length;
1822
+ dindex += dataLength;
1823
+ dataBlock.push(localHeader);
1824
+ dataBlock.push(compressedData);
1825
+ const centralHeader = entry.packCentralHeader();
1826
+ headerBlocks.push(centralHeader);
1827
+ mainHeader.size += centralHeader.length;
1828
+ totalSize += dataLength + centralHeader.length;
1829
+ totalEntries++;
1830
+ }
1831
+ totalSize += mainHeader.mainHeaderSize;
1832
+ mainHeader.offset = dindex;
1833
+ mainHeader.totalEntries = totalEntries;
1834
+ dindex = 0;
1835
+ const outBuffer = Buffer.alloc(totalSize);
1836
+ for (const content of dataBlock) {
1837
+ content.copy(outBuffer, dindex);
1838
+ dindex += content.length;
1839
+ }
1840
+ for (const content of headerBlocks) {
1841
+ content.copy(outBuffer, dindex);
1842
+ dindex += content.length;
1843
+ }
1844
+ const mh = mainHeader.toBinary();
1845
+ if (_comment) {
1846
+ _comment.copy(mh, Utils.Constants.ENDHDR);
1847
+ }
1848
+ mh.copy(outBuffer, dindex);
1849
+ inBuffer = outBuffer;
1850
+ loadedEntries = false;
1851
+ return outBuffer;
1852
+ },
1853
+ toAsyncBuffer: function(onSuccess, onFail, onItemStart, onItemEnd) {
1854
+ try {
1855
+ if (!loadedEntries) {
1856
+ readEntries();
1857
+ }
1858
+ sortEntries();
1859
+ const dataBlock = [];
1860
+ const centralHeaders = [];
1861
+ let totalSize = 0;
1862
+ let dindex = 0;
1863
+ let totalEntries = 0;
1864
+ mainHeader.size = 0;
1865
+ mainHeader.offset = 0;
1866
+ const compress2Buffer = function(entryLists) {
1867
+ if (entryLists.length > 0) {
1868
+ const entry = entryLists.shift();
1869
+ const name = entry.entryName + entry.extra.toString();
1870
+ if (onItemStart) onItemStart(name);
1871
+ entry.getCompressedDataAsync(function(compressedData) {
1872
+ if (onItemEnd) onItemEnd(name);
1873
+ entry.header.offset = dindex;
1874
+ const localHeader = entry.packLocalHeader();
1875
+ const dataLength = localHeader.length + compressedData.length;
1876
+ dindex += dataLength;
1877
+ dataBlock.push(localHeader);
1878
+ dataBlock.push(compressedData);
1879
+ const centalHeader = entry.packCentralHeader();
1880
+ centralHeaders.push(centalHeader);
1881
+ mainHeader.size += centalHeader.length;
1882
+ totalSize += dataLength + centalHeader.length;
1883
+ totalEntries++;
1884
+ compress2Buffer(entryLists);
1885
+ });
1886
+ } else {
1887
+ totalSize += mainHeader.mainHeaderSize;
1888
+ mainHeader.offset = dindex;
1889
+ mainHeader.totalEntries = totalEntries;
1890
+ dindex = 0;
1891
+ const outBuffer = Buffer.alloc(totalSize);
1892
+ dataBlock.forEach(function(content) {
1893
+ content.copy(outBuffer, dindex);
1894
+ dindex += content.length;
1895
+ });
1896
+ centralHeaders.forEach(function(content) {
1897
+ content.copy(outBuffer, dindex);
1898
+ dindex += content.length;
1899
+ });
1900
+ const mh = mainHeader.toBinary();
1901
+ if (_comment) {
1902
+ _comment.copy(mh, Utils.Constants.ENDHDR);
1903
+ }
1904
+ mh.copy(outBuffer, dindex);
1905
+ inBuffer = outBuffer;
1906
+ loadedEntries = false;
1907
+ onSuccess(outBuffer);
1908
+ }
1909
+ };
1910
+ compress2Buffer(Array.from(this.entries));
1911
+ } catch (e) {
1912
+ onFail(e);
1913
+ }
1914
+ }
1915
+ };
1916
+ };
1917
+ }
1918
+ });
1919
+
1920
+ // ../../../node_modules/adm-zip/adm-zip.js
1921
+ var require_adm_zip = __commonJS({
1922
+ "../../../node_modules/adm-zip/adm-zip.js"(exports, module) {
1923
+ var Utils = require_util();
1924
+ var pth = __require("path");
1925
+ var ZipEntry = require_zipEntry();
1926
+ var ZipFile = require_zipFile();
1927
+ var get_Bool = (...val) => Utils.findLast(val, (c) => typeof c === "boolean");
1928
+ var get_Str = (...val) => Utils.findLast(val, (c) => typeof c === "string");
1929
+ var get_Fun = (...val) => Utils.findLast(val, (c) => typeof c === "function");
1930
+ var defaultOptions = {
1931
+ // option "noSort" : if true it disables files sorting
1932
+ noSort: false,
1933
+ // read entries during load (initial loading may be slower)
1934
+ readEntries: false,
1935
+ // default method is none
1936
+ method: Utils.Constants.NONE,
1937
+ // file system
1938
+ fs: null
1939
+ };
1940
+ module.exports = function(input, options) {
1941
+ let inBuffer = null;
1942
+ const opts = Object.assign(/* @__PURE__ */ Object.create(null), defaultOptions);
1943
+ if (input && "object" === typeof input) {
1944
+ if (!(input instanceof Uint8Array)) {
1945
+ Object.assign(opts, input);
1946
+ input = opts.input ? opts.input : void 0;
1947
+ if (opts.input) delete opts.input;
1948
+ }
1949
+ if (Buffer.isBuffer(input)) {
1950
+ inBuffer = input;
1951
+ opts.method = Utils.Constants.BUFFER;
1952
+ input = void 0;
1953
+ }
1954
+ }
1955
+ Object.assign(opts, options);
1956
+ const filetools = new Utils(opts);
1957
+ if (typeof opts.decoder !== "object" || typeof opts.decoder.encode !== "function" || typeof opts.decoder.decode !== "function") {
1958
+ opts.decoder = Utils.decoder;
1959
+ }
1960
+ if (input && "string" === typeof input) {
1961
+ if (filetools.fs.existsSync(input)) {
1962
+ opts.method = Utils.Constants.FILE;
1963
+ opts.filename = input;
1964
+ inBuffer = filetools.fs.readFileSync(input);
1965
+ } else {
1966
+ throw Utils.Errors.INVALID_FILENAME();
1967
+ }
1968
+ }
1969
+ const _zip = new ZipFile(inBuffer, opts);
1970
+ const { canonical, sanitize, zipnamefix } = Utils;
1971
+ function getEntry(entry) {
1972
+ if (entry && _zip) {
1973
+ var item;
1974
+ if (typeof entry === "string") item = _zip.getEntry(pth.posix.normalize(entry));
1975
+ if (typeof entry === "object" && typeof entry.entryName !== "undefined" && typeof entry.header !== "undefined") item = _zip.getEntry(entry.entryName);
1976
+ if (item) {
1977
+ return item;
1978
+ }
1979
+ }
1980
+ return null;
1981
+ }
1982
+ function fixPath(zipPath) {
1983
+ const { join: join2, normalize, sep } = pth.posix;
1984
+ return join2(".", normalize(sep + zipPath.split("\\").join(sep) + sep));
1985
+ }
1986
+ function filenameFilter(filterfn) {
1987
+ if (filterfn instanceof RegExp) {
1988
+ return /* @__PURE__ */ (function(rx) {
1989
+ return function(filename) {
1990
+ return rx.test(filename);
1991
+ };
1992
+ })(filterfn);
1993
+ } else if ("function" !== typeof filterfn) {
1994
+ return () => true;
1995
+ }
1996
+ return filterfn;
1997
+ }
1998
+ const relativePath = (local, entry) => {
1999
+ let lastChar = entry.slice(-1);
2000
+ lastChar = lastChar === filetools.sep ? filetools.sep : "";
2001
+ return pth.relative(local, entry) + lastChar;
2002
+ };
2003
+ return {
2004
+ /**
2005
+ * Extracts the given entry from the archive and returns the content as a Buffer object
2006
+ * @param {ZipEntry|string} entry ZipEntry object or String with the full path of the entry
2007
+ * @param {Buffer|string} [pass] - password
2008
+ * @return Buffer or Null in case of error
2009
+ */
2010
+ readFile: function(entry, pass) {
2011
+ var item = getEntry(entry);
2012
+ return item && item.getData(pass) || null;
2013
+ },
2014
+ /**
2015
+ * Returns how many child elements has on entry (directories) on files it is always 0
2016
+ * @param {ZipEntry|string} entry ZipEntry object or String with the full path of the entry
2017
+ * @returns {integer}
2018
+ */
2019
+ childCount: function(entry) {
2020
+ const item = getEntry(entry);
2021
+ if (item) {
2022
+ return _zip.getChildCount(item);
2023
+ }
2024
+ },
2025
+ /**
2026
+ * Asynchronous readFile
2027
+ * @param {ZipEntry|string} entry ZipEntry object or String with the full path of the entry
2028
+ * @param {callback} callback
2029
+ *
2030
+ * @return Buffer or Null in case of error
2031
+ */
2032
+ readFileAsync: function(entry, callback) {
2033
+ var item = getEntry(entry);
2034
+ if (item) {
2035
+ item.getDataAsync(callback);
2036
+ } else {
2037
+ callback(null, "getEntry failed for:" + entry);
2038
+ }
2039
+ },
2040
+ /**
2041
+ * Extracts the given entry from the archive and returns the content as plain text in the given encoding
2042
+ * @param {ZipEntry|string} entry - ZipEntry object or String with the full path of the entry
2043
+ * @param {string} encoding - Optional. If no encoding is specified utf8 is used
2044
+ *
2045
+ * @return String
2046
+ */
2047
+ readAsText: function(entry, encoding) {
2048
+ var item = getEntry(entry);
2049
+ if (item) {
2050
+ var data = item.getData();
2051
+ if (data && data.length) {
2052
+ return data.toString(encoding || "utf8");
2053
+ }
2054
+ }
2055
+ return "";
2056
+ },
2057
+ /**
2058
+ * Asynchronous readAsText
2059
+ * @param {ZipEntry|string} entry ZipEntry object or String with the full path of the entry
2060
+ * @param {callback} callback
2061
+ * @param {string} [encoding] - Optional. If no encoding is specified utf8 is used
2062
+ *
2063
+ * @return String
2064
+ */
2065
+ readAsTextAsync: function(entry, callback, encoding) {
2066
+ var item = getEntry(entry);
2067
+ if (item) {
2068
+ item.getDataAsync(function(data, err) {
2069
+ if (err) {
2070
+ callback(data, err);
2071
+ return;
2072
+ }
2073
+ if (data && data.length) {
2074
+ callback(data.toString(encoding || "utf8"));
2075
+ } else {
2076
+ callback("");
2077
+ }
2078
+ });
2079
+ } else {
2080
+ callback("");
2081
+ }
2082
+ },
2083
+ /**
2084
+ * Remove the entry from the file or the entry and all it's nested directories and files if the given entry is a directory
2085
+ *
2086
+ * @param {ZipEntry|string} entry
2087
+ * @returns {void}
2088
+ */
2089
+ deleteFile: function(entry, withsubfolders = true) {
2090
+ var item = getEntry(entry);
2091
+ if (item) {
2092
+ _zip.deleteFile(item.entryName, withsubfolders);
2093
+ }
2094
+ },
2095
+ /**
2096
+ * Remove the entry from the file or directory without affecting any nested entries
2097
+ *
2098
+ * @param {ZipEntry|string} entry
2099
+ * @returns {void}
2100
+ */
2101
+ deleteEntry: function(entry) {
2102
+ var item = getEntry(entry);
2103
+ if (item) {
2104
+ _zip.deleteEntry(item.entryName);
2105
+ }
2106
+ },
2107
+ /**
2108
+ * Adds a comment to the zip. The zip must be rewritten after adding the comment.
2109
+ *
2110
+ * @param {string} comment
2111
+ */
2112
+ addZipComment: function(comment) {
2113
+ _zip.comment = comment;
2114
+ },
2115
+ /**
2116
+ * Returns the zip comment
2117
+ *
2118
+ * @return String
2119
+ */
2120
+ getZipComment: function() {
2121
+ return _zip.comment || "";
2122
+ },
2123
+ /**
2124
+ * Adds a comment to a specified zipEntry. The zip must be rewritten after adding the comment
2125
+ * The comment cannot exceed 65535 characters in length
2126
+ *
2127
+ * @param {ZipEntry} entry
2128
+ * @param {string} comment
2129
+ */
2130
+ addZipEntryComment: function(entry, comment) {
2131
+ var item = getEntry(entry);
2132
+ if (item) {
2133
+ item.comment = comment;
2134
+ }
2135
+ },
2136
+ /**
2137
+ * Returns the comment of the specified entry
2138
+ *
2139
+ * @param {ZipEntry} entry
2140
+ * @return String
2141
+ */
2142
+ getZipEntryComment: function(entry) {
2143
+ var item = getEntry(entry);
2144
+ if (item) {
2145
+ return item.comment || "";
2146
+ }
2147
+ return "";
2148
+ },
2149
+ /**
2150
+ * Updates the content of an existing entry inside the archive. The zip must be rewritten after updating the content
2151
+ *
2152
+ * @param {ZipEntry} entry
2153
+ * @param {Buffer} content
2154
+ */
2155
+ updateFile: function(entry, content) {
2156
+ var item = getEntry(entry);
2157
+ if (item) {
2158
+ item.setData(content);
2159
+ }
2160
+ },
2161
+ /**
2162
+ * Adds a file from the disk to the archive
2163
+ *
2164
+ * @param {string} localPath File to add to zip
2165
+ * @param {string} [zipPath] Optional path inside the zip
2166
+ * @param {string} [zipName] Optional name for the file
2167
+ * @param {string} [comment] Optional file comment
2168
+ */
2169
+ addLocalFile: function(localPath2, zipPath, zipName, comment) {
2170
+ if (filetools.fs.existsSync(localPath2)) {
2171
+ zipPath = zipPath ? fixPath(zipPath) : "";
2172
+ const p = pth.win32.basename(pth.win32.normalize(localPath2));
2173
+ zipPath += zipName ? zipName : p;
2174
+ const _attr = filetools.fs.statSync(localPath2);
2175
+ const data = _attr.isFile() ? filetools.fs.readFileSync(localPath2) : Buffer.alloc(0);
2176
+ if (_attr.isDirectory()) zipPath += filetools.sep;
2177
+ this.addFile(zipPath, data, comment, _attr);
2178
+ } else {
2179
+ throw Utils.Errors.FILE_NOT_FOUND(localPath2);
2180
+ }
2181
+ },
2182
+ /**
2183
+ * Callback for showing if everything was done.
2184
+ *
2185
+ * @callback doneCallback
2186
+ * @param {Error} err - Error object
2187
+ * @param {boolean} done - was request fully completed
2188
+ */
2189
+ /**
2190
+ * Adds a file from the disk to the archive
2191
+ *
2192
+ * @param {(object|string)} options - options object, if it is string it us used as localPath.
2193
+ * @param {string} options.localPath - Local path to the file.
2194
+ * @param {string} [options.comment] - Optional file comment.
2195
+ * @param {string} [options.zipPath] - Optional path inside the zip
2196
+ * @param {string} [options.zipName] - Optional name for the file
2197
+ * @param {doneCallback} callback - The callback that handles the response.
2198
+ */
2199
+ addLocalFileAsync: function(options2, callback) {
2200
+ options2 = typeof options2 === "object" ? options2 : { localPath: options2 };
2201
+ const localPath2 = pth.resolve(options2.localPath);
2202
+ const { comment } = options2;
2203
+ let { zipPath, zipName } = options2;
2204
+ const self = this;
2205
+ filetools.fs.stat(localPath2, function(err, stats) {
2206
+ if (err) return callback(err, false);
2207
+ zipPath = zipPath ? fixPath(zipPath) : "";
2208
+ const p = pth.win32.basename(pth.win32.normalize(localPath2));
2209
+ zipPath += zipName ? zipName : p;
2210
+ if (stats.isFile()) {
2211
+ filetools.fs.readFile(localPath2, function(err2, data) {
2212
+ if (err2) return callback(err2, false);
2213
+ self.addFile(zipPath, data, comment, stats);
2214
+ return setImmediate(callback, void 0, true);
2215
+ });
2216
+ } else if (stats.isDirectory()) {
2217
+ zipPath += filetools.sep;
2218
+ self.addFile(zipPath, Buffer.alloc(0), comment, stats);
2219
+ return setImmediate(callback, void 0, true);
2220
+ }
2221
+ });
2222
+ },
2223
+ /**
2224
+ * Adds a local directory and all its nested files and directories to the archive
2225
+ *
2226
+ * @param {string} localPath - local path to the folder
2227
+ * @param {string} [zipPath] - optional path inside zip
2228
+ * @param {(RegExp|function)} [filter] - optional RegExp or Function if files match will be included.
2229
+ */
2230
+ addLocalFolder: function(localPath2, zipPath, filter) {
2231
+ filter = filenameFilter(filter);
2232
+ zipPath = zipPath ? fixPath(zipPath) : "";
2233
+ localPath2 = pth.normalize(localPath2);
2234
+ if (filetools.fs.existsSync(localPath2)) {
2235
+ const items = filetools.findFiles(localPath2);
2236
+ const self = this;
2237
+ if (items.length) {
2238
+ for (const filepath of items) {
2239
+ const p = pth.join(zipPath, relativePath(localPath2, filepath));
2240
+ if (filter(p)) {
2241
+ self.addLocalFile(filepath, pth.dirname(p));
2242
+ }
2243
+ }
2244
+ }
2245
+ } else {
2246
+ throw Utils.Errors.FILE_NOT_FOUND(localPath2);
2247
+ }
2248
+ },
2249
+ /**
2250
+ * Asynchronous addLocalFolder
2251
+ * @param {string} localPath
2252
+ * @param {callback} callback
2253
+ * @param {string} [zipPath] optional path inside zip
2254
+ * @param {RegExp|function} [filter] optional RegExp or Function if files match will
2255
+ * be included.
2256
+ */
2257
+ addLocalFolderAsync: function(localPath2, callback, zipPath, filter) {
2258
+ filter = filenameFilter(filter);
2259
+ zipPath = zipPath ? fixPath(zipPath) : "";
2260
+ localPath2 = pth.normalize(localPath2);
2261
+ var self = this;
2262
+ filetools.fs.open(localPath2, "r", function(err) {
2263
+ if (err && err.code === "ENOENT") {
2264
+ callback(void 0, Utils.Errors.FILE_NOT_FOUND(localPath2));
2265
+ } else if (err) {
2266
+ callback(void 0, err);
2267
+ } else {
2268
+ var items = filetools.findFiles(localPath2);
2269
+ var i = -1;
2270
+ var next = function() {
2271
+ i += 1;
2272
+ if (i < items.length) {
2273
+ var filepath = items[i];
2274
+ var p = relativePath(localPath2, filepath).split("\\").join("/");
2275
+ p = p.normalize("NFD").replace(/[\u0300-\u036f]/g, "").replace(/[^\x20-\x7E]/g, "");
2276
+ if (filter(p)) {
2277
+ filetools.fs.stat(filepath, function(er0, stats) {
2278
+ if (er0) callback(void 0, er0);
2279
+ if (stats.isFile()) {
2280
+ filetools.fs.readFile(filepath, function(er1, data) {
2281
+ if (er1) {
2282
+ callback(void 0, er1);
2283
+ } else {
2284
+ self.addFile(zipPath + p, data, "", stats);
2285
+ next();
2286
+ }
2287
+ });
2288
+ } else {
2289
+ self.addFile(zipPath + p + "/", Buffer.alloc(0), "", stats);
2290
+ next();
2291
+ }
2292
+ });
2293
+ } else {
2294
+ process.nextTick(() => {
2295
+ next();
2296
+ });
2297
+ }
2298
+ } else {
2299
+ callback(true, void 0);
2300
+ }
2301
+ };
2302
+ next();
2303
+ }
2304
+ });
2305
+ },
2306
+ /**
2307
+ * Adds a local directory and all its nested files and directories to the archive
2308
+ *
2309
+ * @param {object | string} options - options object, if it is string it us used as localPath.
2310
+ * @param {string} options.localPath - Local path to the folder.
2311
+ * @param {string} [options.zipPath] - optional path inside zip.
2312
+ * @param {RegExp|function} [options.filter] - optional RegExp or Function if files match will be included.
2313
+ * @param {function|string} [options.namefix] - optional function to help fix filename
2314
+ * @param {doneCallback} callback - The callback that handles the response.
2315
+ *
2316
+ */
2317
+ addLocalFolderAsync2: function(options2, callback) {
2318
+ const self = this;
2319
+ options2 = typeof options2 === "object" ? options2 : { localPath: options2 };
2320
+ localPath = pth.resolve(fixPath(options2.localPath));
2321
+ let { zipPath, filter, namefix } = options2;
2322
+ if (filter instanceof RegExp) {
2323
+ filter = /* @__PURE__ */ (function(rx) {
2324
+ return function(filename) {
2325
+ return rx.test(filename);
2326
+ };
2327
+ })(filter);
2328
+ } else if ("function" !== typeof filter) {
2329
+ filter = function() {
2330
+ return true;
2331
+ };
2332
+ }
2333
+ zipPath = zipPath ? fixPath(zipPath) : "";
2334
+ if (namefix == "latin1") {
2335
+ namefix = (str) => str.normalize("NFD").replace(/[\u0300-\u036f]/g, "").replace(/[^\x20-\x7E]/g, "");
2336
+ }
2337
+ if (typeof namefix !== "function") namefix = (str) => str;
2338
+ const relPathFix = (entry) => pth.join(zipPath, namefix(relativePath(localPath, entry)));
2339
+ const fileNameFix = (entry) => pth.win32.basename(pth.win32.normalize(namefix(entry)));
2340
+ filetools.fs.open(localPath, "r", function(err) {
2341
+ if (err && err.code === "ENOENT") {
2342
+ callback(void 0, Utils.Errors.FILE_NOT_FOUND(localPath));
2343
+ } else if (err) {
2344
+ callback(void 0, err);
2345
+ } else {
2346
+ filetools.findFilesAsync(localPath, function(err2, fileEntries) {
2347
+ if (err2) return callback(err2);
2348
+ fileEntries = fileEntries.filter((dir) => filter(relPathFix(dir)));
2349
+ if (!fileEntries.length) callback(void 0, false);
2350
+ setImmediate(
2351
+ fileEntries.reverse().reduce(function(next, entry) {
2352
+ return function(err3, done) {
2353
+ if (err3 || done === false) return setImmediate(next, err3, false);
2354
+ self.addLocalFileAsync(
2355
+ {
2356
+ localPath: entry,
2357
+ zipPath: pth.dirname(relPathFix(entry)),
2358
+ zipName: fileNameFix(entry)
2359
+ },
2360
+ next
2361
+ );
2362
+ };
2363
+ }, callback)
2364
+ );
2365
+ });
2366
+ }
2367
+ });
2368
+ },
2369
+ /**
2370
+ * Adds a local directory and all its nested files and directories to the archive
2371
+ *
2372
+ * @param {string} localPath - path where files will be extracted
2373
+ * @param {object} props - optional properties
2374
+ * @param {string} [props.zipPath] - optional path inside zip
2375
+ * @param {RegExp|function} [props.filter] - optional RegExp or Function if files match will be included.
2376
+ * @param {function|string} [props.namefix] - optional function to help fix filename
2377
+ */
2378
+ addLocalFolderPromise: function(localPath2, props) {
2379
+ return new Promise((resolve, reject) => {
2380
+ this.addLocalFolderAsync2(Object.assign({ localPath: localPath2 }, props), (err, done) => {
2381
+ if (err) reject(err);
2382
+ if (done) resolve(this);
2383
+ });
2384
+ });
2385
+ },
2386
+ /**
2387
+ * Allows you to create a entry (file or directory) in the zip file.
2388
+ * If you want to create a directory the entryName must end in / and a null buffer should be provided.
2389
+ * Comment and attributes are optional
2390
+ *
2391
+ * @param {string} entryName
2392
+ * @param {Buffer | string} content - file content as buffer or utf8 coded string
2393
+ * @param {string} [comment] - file comment
2394
+ * @param {number | object} [attr] - number as unix file permissions, object as filesystem Stats object
2395
+ */
2396
+ addFile: function(entryName, content, comment, attr) {
2397
+ entryName = zipnamefix(entryName);
2398
+ let entry = getEntry(entryName);
2399
+ const update = entry != null;
2400
+ if (!update) {
2401
+ entry = new ZipEntry(opts);
2402
+ entry.entryName = entryName;
2403
+ }
2404
+ entry.comment = comment || "";
2405
+ const isStat = "object" === typeof attr && attr instanceof filetools.fs.Stats;
2406
+ if (isStat) {
2407
+ entry.header.time = attr.mtime;
2408
+ }
2409
+ var fileattr = entry.isDirectory ? 16 : 0;
2410
+ let unix = entry.isDirectory ? 16384 : 32768;
2411
+ if (isStat) {
2412
+ unix |= 4095 & attr.mode;
2413
+ } else if ("number" === typeof attr) {
2414
+ unix |= 4095 & attr;
2415
+ } else {
2416
+ unix |= entry.isDirectory ? 493 : 420;
2417
+ }
2418
+ fileattr = (fileattr | unix << 16) >>> 0;
2419
+ entry.attr = fileattr;
2420
+ entry.setData(content);
2421
+ if (!update) _zip.setEntry(entry);
2422
+ return entry;
2423
+ },
2424
+ /**
2425
+ * Returns an array of ZipEntry objects representing the files and folders inside the archive
2426
+ *
2427
+ * @param {string} [password]
2428
+ * @returns Array
2429
+ */
2430
+ getEntries: function(password) {
2431
+ _zip.password = password;
2432
+ return _zip ? _zip.entries : [];
2433
+ },
2434
+ /**
2435
+ * Returns a ZipEntry object representing the file or folder specified by ``name``.
2436
+ *
2437
+ * @param {string} name
2438
+ * @return ZipEntry
2439
+ */
2440
+ getEntry: function(name) {
2441
+ return getEntry(name);
2442
+ },
2443
+ getEntryCount: function() {
2444
+ return _zip.getEntryCount();
2445
+ },
2446
+ forEach: function(callback) {
2447
+ return _zip.forEach(callback);
2448
+ },
2449
+ /**
2450
+ * Extracts the given entry to the given targetPath
2451
+ * If the entry is a directory inside the archive, the entire directory and it's subdirectories will be extracted
2452
+ *
2453
+ * @param {string|ZipEntry} entry - ZipEntry object or String with the full path of the entry
2454
+ * @param {string} targetPath - Target folder where to write the file
2455
+ * @param {boolean} [maintainEntryPath=true] - If maintainEntryPath is true and the entry is inside a folder, the entry folder will be created in targetPath as well. Default is TRUE
2456
+ * @param {boolean} [overwrite=false] - If the file already exists at the target path, the file will be overwriten if this is true.
2457
+ * @param {boolean} [keepOriginalPermission=false] - The file will be set as the permission from the entry if this is true.
2458
+ * @param {string} [outFileName] - String If set will override the filename of the extracted file (Only works if the entry is a file)
2459
+ *
2460
+ * @return Boolean
2461
+ */
2462
+ extractEntryTo: function(entry, targetPath, maintainEntryPath, overwrite, keepOriginalPermission, outFileName) {
2463
+ overwrite = get_Bool(false, overwrite);
2464
+ keepOriginalPermission = get_Bool(false, keepOriginalPermission);
2465
+ maintainEntryPath = get_Bool(true, maintainEntryPath);
2466
+ outFileName = get_Str(keepOriginalPermission, outFileName);
2467
+ var item = getEntry(entry);
2468
+ if (!item) {
2469
+ throw Utils.Errors.NO_ENTRY();
2470
+ }
2471
+ var entryName = canonical(item.entryName);
2472
+ var target = sanitize(targetPath, outFileName && !item.isDirectory ? outFileName : maintainEntryPath ? entryName : pth.basename(entryName));
2473
+ if (item.isDirectory) {
2474
+ var children = _zip.getEntryChildren(item);
2475
+ children.forEach(function(child) {
2476
+ if (child.isDirectory) return;
2477
+ var content2 = child.getData();
2478
+ if (!content2) {
2479
+ throw Utils.Errors.CANT_EXTRACT_FILE();
2480
+ }
2481
+ var name = canonical(child.entryName);
2482
+ var childName = sanitize(targetPath, maintainEntryPath ? name : pth.basename(name));
2483
+ const fileAttr2 = keepOriginalPermission ? child.header.fileAttr : void 0;
2484
+ filetools.writeFileTo(childName, content2, overwrite, fileAttr2);
2485
+ });
2486
+ return true;
2487
+ }
2488
+ var content = item.getData(_zip.password);
2489
+ if (!content) throw Utils.Errors.CANT_EXTRACT_FILE();
2490
+ if (filetools.fs.existsSync(target) && !overwrite) {
2491
+ throw Utils.Errors.CANT_OVERRIDE();
2492
+ }
2493
+ const fileAttr = keepOriginalPermission ? entry.header.fileAttr : void 0;
2494
+ filetools.writeFileTo(target, content, overwrite, fileAttr);
2495
+ return true;
2496
+ },
2497
+ /**
2498
+ * Test the archive
2499
+ * @param {string} [pass]
2500
+ */
2501
+ test: function(pass) {
2502
+ if (!_zip) {
2503
+ return false;
2504
+ }
2505
+ for (var entry in _zip.entries) {
2506
+ try {
2507
+ if (entry.isDirectory) {
2508
+ continue;
2509
+ }
2510
+ var content = _zip.entries[entry].getData(pass);
2511
+ if (!content) {
2512
+ return false;
2513
+ }
2514
+ } catch (err) {
2515
+ return false;
2516
+ }
2517
+ }
2518
+ return true;
2519
+ },
2520
+ /**
2521
+ * Extracts the entire archive to the given location
2522
+ *
2523
+ * @param {string} targetPath Target location
2524
+ * @param {boolean} [overwrite=false] If the file already exists at the target path, the file will be overwriten if this is true.
2525
+ * Default is FALSE
2526
+ * @param {boolean} [keepOriginalPermission=false] The file will be set as the permission from the entry if this is true.
2527
+ * Default is FALSE
2528
+ * @param {string|Buffer} [pass] password
2529
+ */
2530
+ extractAllTo: function(targetPath, overwrite, keepOriginalPermission, pass) {
2531
+ keepOriginalPermission = get_Bool(false, keepOriginalPermission);
2532
+ pass = get_Str(keepOriginalPermission, pass);
2533
+ overwrite = get_Bool(false, overwrite);
2534
+ if (!_zip) throw Utils.Errors.NO_ZIP();
2535
+ _zip.entries.forEach(function(entry) {
2536
+ var entryName = sanitize(targetPath, canonical(entry.entryName));
2537
+ if (entry.isDirectory) {
2538
+ filetools.makeDir(entryName);
2539
+ return;
2540
+ }
2541
+ var content = entry.getData(pass);
2542
+ if (!content) {
2543
+ throw Utils.Errors.CANT_EXTRACT_FILE();
2544
+ }
2545
+ const fileAttr = keepOriginalPermission ? entry.header.fileAttr : void 0;
2546
+ filetools.writeFileTo(entryName, content, overwrite, fileAttr);
2547
+ try {
2548
+ filetools.fs.utimesSync(entryName, entry.header.time, entry.header.time);
2549
+ } catch (err) {
2550
+ throw Utils.Errors.CANT_EXTRACT_FILE();
2551
+ }
2552
+ });
2553
+ },
2554
+ /**
2555
+ * Asynchronous extractAllTo
2556
+ *
2557
+ * @param {string} targetPath Target location
2558
+ * @param {boolean} [overwrite=false] If the file already exists at the target path, the file will be overwriten if this is true.
2559
+ * Default is FALSE
2560
+ * @param {boolean} [keepOriginalPermission=false] The file will be set as the permission from the entry if this is true.
2561
+ * Default is FALSE
2562
+ * @param {function} callback The callback will be executed when all entries are extracted successfully or any error is thrown.
2563
+ */
2564
+ extractAllToAsync: function(targetPath, overwrite, keepOriginalPermission, callback) {
2565
+ callback = get_Fun(overwrite, keepOriginalPermission, callback);
2566
+ keepOriginalPermission = get_Bool(false, keepOriginalPermission);
2567
+ overwrite = get_Bool(false, overwrite);
2568
+ if (!callback) {
2569
+ return new Promise((resolve, reject) => {
2570
+ this.extractAllToAsync(targetPath, overwrite, keepOriginalPermission, function(err) {
2571
+ if (err) {
2572
+ reject(err);
2573
+ } else {
2574
+ resolve(this);
2575
+ }
2576
+ });
2577
+ });
2578
+ }
2579
+ if (!_zip) {
2580
+ callback(Utils.Errors.NO_ZIP());
2581
+ return;
2582
+ }
2583
+ targetPath = pth.resolve(targetPath);
2584
+ const getPath = (entry) => sanitize(targetPath, pth.normalize(canonical(entry.entryName)));
2585
+ const getError = (msg, file) => new Error(msg + ': "' + file + '"');
2586
+ const dirEntries = [];
2587
+ const fileEntries = [];
2588
+ _zip.entries.forEach((e) => {
2589
+ if (e.isDirectory) {
2590
+ dirEntries.push(e);
2591
+ } else {
2592
+ fileEntries.push(e);
2593
+ }
2594
+ });
2595
+ for (const entry of dirEntries) {
2596
+ const dirPath = getPath(entry);
2597
+ const dirAttr = keepOriginalPermission ? entry.header.fileAttr : void 0;
2598
+ try {
2599
+ filetools.makeDir(dirPath);
2600
+ if (dirAttr) filetools.fs.chmodSync(dirPath, dirAttr);
2601
+ filetools.fs.utimesSync(dirPath, entry.header.time, entry.header.time);
2602
+ } catch (er) {
2603
+ callback(getError("Unable to create folder", dirPath));
2604
+ }
2605
+ }
2606
+ fileEntries.reverse().reduce(function(next, entry) {
2607
+ return function(err) {
2608
+ if (err) {
2609
+ next(err);
2610
+ } else {
2611
+ const entryName = pth.normalize(canonical(entry.entryName));
2612
+ const filePath = sanitize(targetPath, entryName);
2613
+ entry.getDataAsync(function(content, err_1) {
2614
+ if (err_1) {
2615
+ next(err_1);
2616
+ } else if (!content) {
2617
+ next(Utils.Errors.CANT_EXTRACT_FILE());
2618
+ } else {
2619
+ const fileAttr = keepOriginalPermission ? entry.header.fileAttr : void 0;
2620
+ filetools.writeFileToAsync(filePath, content, overwrite, fileAttr, function(succ) {
2621
+ if (!succ) {
2622
+ next(getError("Unable to write file", filePath));
2623
+ }
2624
+ filetools.fs.utimes(filePath, entry.header.time, entry.header.time, function(err_2) {
2625
+ if (err_2) {
2626
+ next(getError("Unable to set times", filePath));
2627
+ } else {
2628
+ next();
2629
+ }
2630
+ });
2631
+ });
2632
+ }
2633
+ });
2634
+ }
2635
+ };
2636
+ }, callback)();
2637
+ },
2638
+ /**
2639
+ * Writes the newly created zip file to disk at the specified location or if a zip was opened and no ``targetFileName`` is provided, it will overwrite the opened zip
2640
+ *
2641
+ * @param {string} targetFileName
2642
+ * @param {function} callback
2643
+ */
2644
+ writeZip: function(targetFileName, callback) {
2645
+ if (arguments.length === 1) {
2646
+ if (typeof targetFileName === "function") {
2647
+ callback = targetFileName;
2648
+ targetFileName = "";
2649
+ }
2650
+ }
2651
+ if (!targetFileName && opts.filename) {
2652
+ targetFileName = opts.filename;
2653
+ }
2654
+ if (!targetFileName) return;
2655
+ var zipData = _zip.compressToBuffer();
2656
+ if (zipData) {
2657
+ var ok = filetools.writeFileTo(targetFileName, zipData, true);
2658
+ if (typeof callback === "function") callback(!ok ? new Error("failed") : null, "");
2659
+ }
2660
+ },
2661
+ /**
2662
+ *
2663
+ * @param {string} targetFileName
2664
+ * @param {object} [props]
2665
+ * @param {boolean} [props.overwrite=true] If the file already exists at the target path, the file will be overwriten if this is true.
2666
+ * @param {boolean} [props.perm] The file will be set as the permission from the entry if this is true.
2667
+
2668
+ * @returns {Promise<void>}
2669
+ */
2670
+ writeZipPromise: function(targetFileName, props) {
2671
+ const { overwrite, perm } = Object.assign({ overwrite: true }, props);
2672
+ return new Promise((resolve, reject) => {
2673
+ if (!targetFileName && opts.filename) targetFileName = opts.filename;
2674
+ if (!targetFileName) reject("ADM-ZIP: ZIP File Name Missing");
2675
+ this.toBufferPromise().then((zipData) => {
2676
+ const ret = (done) => done ? resolve(done) : reject("ADM-ZIP: Wasn't able to write zip file");
2677
+ filetools.writeFileToAsync(targetFileName, zipData, overwrite, perm, ret);
2678
+ }, reject);
2679
+ });
2680
+ },
2681
+ /**
2682
+ * @returns {Promise<Buffer>} A promise to the Buffer.
2683
+ */
2684
+ toBufferPromise: function() {
2685
+ return new Promise((resolve, reject) => {
2686
+ _zip.toAsyncBuffer(resolve, reject);
2687
+ });
2688
+ },
2689
+ /**
2690
+ * Returns the content of the entire zip file as a Buffer object
2691
+ *
2692
+ * @prop {function} [onSuccess]
2693
+ * @prop {function} [onFail]
2694
+ * @prop {function} [onItemStart]
2695
+ * @prop {function} [onItemEnd]
2696
+ * @returns {Buffer}
2697
+ */
2698
+ toBuffer: function(onSuccess, onFail, onItemStart, onItemEnd) {
2699
+ if (typeof onSuccess === "function") {
2700
+ _zip.toAsyncBuffer(onSuccess, onFail, onItemStart, onItemEnd);
2701
+ return null;
2702
+ }
2703
+ return _zip.compressToBuffer();
2704
+ }
2705
+ };
2706
+ };
2707
+ }
2708
+ });
2709
+
5
2710
  // ../../../node_modules/dedent/dist/dedent.mjs
6
2711
  function ownKeys(object, enumerableOnly) {
7
2712
  var keys = Object.keys(object);
@@ -96,9 +2801,13 @@ function createDedent(options) {
96
2801
  }
97
2802
  }
98
2803
 
2804
+ // src/utils.ts
2805
+ var import_adm_zip = __toESM(require_adm_zip());
2806
+
99
2807
  // src/constants.ts
100
2808
  var VERTICAL_NAME = "forms-app";
101
2809
  var FORMS_APP_DEF_ID = "225dd912-7dea-4738-8688-4b8c6955ffc2";
2810
+ var PLUGIN_FILES_ZIP_URL = "https://static.parastorage.com/services/forms-plugin-files/0.2.0/forms-plugin-files-files.zip";
102
2811
 
103
2812
  // src/wix-apis.ts
104
2813
  var isErrorWithRequestId = (error) => {
@@ -642,6 +3351,45 @@ var generateMockData = async (env) => {
642
3351
  console.log(`[${VERTICAL_NAME}-plugin-generateData] Generating mock data...`);
643
3352
  return MOCK_SCHEMA;
644
3353
  };
3354
+ var unzipAndMergePluginFiles = async (env, zipUrl) => {
3355
+ console.log(
3356
+ `[${VERTICAL_NAME}-plugin-install] Unzipping plugin files from dependency...`
3357
+ );
3358
+ const zipPath = path__namespace.join(process.cwd(), "picasso-forms-plugin-files.zip");
3359
+ const targetDir = path__namespace.join(env.CODEGEN_APP_ROOT, "src");
3360
+ try {
3361
+ console.log(
3362
+ `[${VERTICAL_NAME}-plugin-install] downloading zip file to:`,
3363
+ zipPath
3364
+ );
3365
+ await downloadZipFile(zipUrl, zipPath);
3366
+ const zip = new import_adm_zip.default(zipPath);
3367
+ console.log(`[${VERTICAL_NAME}-plugin-install] Unzipping files...`);
3368
+ zip.getEntries().forEach((entry) => {
3369
+ if (!entry.isDirectory) {
3370
+ const entryPath = entry.entryName;
3371
+ const targetPath = path__namespace.join(targetDir, entryPath);
3372
+ const targetDirPath = path__namespace.dirname(targetPath);
3373
+ if (!fs__namespace.existsSync(targetDirPath)) {
3374
+ fs__namespace.mkdirSync(targetDirPath, { recursive: true });
3375
+ }
3376
+ fs__namespace.writeFileSync(targetPath, entry.getData());
3377
+ console.log(
3378
+ `[${VERTICAL_NAME}-plugin-install] Extracted: ${targetPath}`
3379
+ );
3380
+ }
3381
+ });
3382
+ console.log(
3383
+ `[${VERTICAL_NAME}-plugin-install] Plugin files unzipped and merged successfully`
3384
+ );
3385
+ } catch (error) {
3386
+ console.error(
3387
+ `[${VERTICAL_NAME}-plugin-install] Error downloading or unzipping plugin files:`,
3388
+ error
3389
+ );
3390
+ throw error;
3391
+ }
3392
+ };
645
3393
 
646
3394
  // src/forms-app-instructions.ts
647
3395
  var getFormsCodingInstructions = () => dedent_default`
@@ -720,6 +3468,10 @@ var install = async (env) => {
720
3468
  "[forms-app-plugin-install] Installing forms app functionality..."
721
3469
  );
722
3470
  await installFormsApp(env);
3471
+ console.log(
3472
+ `[${VERTICAL_NAME}-plugin-install] Unzipping and merging plugin files...`
3473
+ );
3474
+ await unzipAndMergePluginFiles(env, PLUGIN_FILES_ZIP_URL);
723
3475
  console.log(
724
3476
  "\n\x1B[34m ==== Forms App installation completed ==== \x1B[0m\n"
725
3477
  );