single-file-core 1.5.126 → 1.5.127
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/core/lib/processor-helper-common.js +16 -20
- package/doc/singlefile-archive.md +21 -12
- package/package.json +2 -2
- package/processors/compression/compression-packager.js +3 -7
- package/processors/compression/compression.js +101 -44
- package/test/sfz-harness/font-face-composite.js +135 -0
- package/test/sfz-harness/format-rules.js +14 -7
- package/test/sfz-harness/pages-archive.js +79 -1
- package/test/sfz-harness/stored-trigger.js +46 -1
- package/test/sfz-harness/trigger-seeds.json +46 -46
- package/vendor/zip/z-worker.js +1 -1
- package/vendor/zip/zip.js +649 -165
- package/vendor/zip/zip.min.js +1 -1
- package/zip-build/package-lock.json +4 -4
- package/zip-build/package.json +1 -1
- package/zip-build/reserved-property-names.json +23 -2
|
@@ -15,12 +15,13 @@
|
|
|
15
15
|
import "./dom-stub.js";
|
|
16
16
|
import { makePageData, makeOptions, runProcess } from "./common.js";
|
|
17
17
|
import { createPagesArchive } from "../../processors/compression/compression-packager.js";
|
|
18
|
-
import { ZipReader, BlobReader, TextWriter } from "../../vendor/zip/zip.js";
|
|
18
|
+
import { ZipReader, ZipWriter, BlobReader, TextReader, TextWriter, Uint8ArrayWriter } from "../../vendor/zip/zip.js";
|
|
19
19
|
|
|
20
20
|
// a title as it comes back from a crawl: the quote closes the href it is written into, the angle
|
|
21
21
|
// bracket opens an element, and the ampersand is what a naive escaper double-encodes
|
|
22
22
|
const HOSTILE_TITLE = "Intro & \"start\" <b>";
|
|
23
23
|
const SYMLINK_UNIX_MODE = 0o120777;
|
|
24
|
+
const SOURCE_DATE = new Date("2021-03-04T05:06:08Z");
|
|
24
25
|
|
|
25
26
|
let failed = false;
|
|
26
27
|
|
|
@@ -89,6 +90,42 @@ const pages = [
|
|
|
89
90
|
(await readEntry(entries, "pages/2/styles.css")).includes("font-family"), true);
|
|
90
91
|
}
|
|
91
92
|
|
|
93
|
+
// Every entry is copied with passThrough, i.e. its stored bytes are written back without being
|
|
94
|
+
// decompressed, so everything that DESCRIBES those bytes has to travel with them. Forwarding a
|
|
95
|
+
// subset does not make a partial copy, it makes a corrupt one: the writer cannot tell that a
|
|
96
|
+
// compression method it did not choose describes data it is about to store verbatim.
|
|
97
|
+
//
|
|
98
|
+
// The pages the rest of this file uses cannot show that, because they are written by the same
|
|
99
|
+
// writer with the same defaults as the archive they are copied into, so every value the copy
|
|
100
|
+
// drops is replaced by the one it had. This page carries values the packager's own defaults do
|
|
101
|
+
// not produce. It is the first page, so it is copied to the root under its own names.
|
|
102
|
+
{
|
|
103
|
+
const metadataPages = [await makeMetadataPage(), pages[1]];
|
|
104
|
+
const sourceEntries = await readArchive(await metadataPages[0].getData());
|
|
105
|
+
const entries = await readArchive(await createPagesArchive(metadataPages, packagerOptions()));
|
|
106
|
+
const copied = [...sourceEntries.keys()].filter(filename => entries.has(filename));
|
|
107
|
+
check("every entry of the first page is copied", copied.length, sourceEntries.size);
|
|
108
|
+
for (const property of ["comment", "compressionMethod", "uncompressedSize", "crc32", "filenameUTF8", "externalFileAttributes", "versionMadeBy", "internalFileAttributes", "uid", "gid", "directory"]) {
|
|
109
|
+
check("a copied entry keeps its " + property,
|
|
110
|
+
copied.every(filename => entries.get(filename)[property] === sourceEntries.get(filename)[property]), true);
|
|
111
|
+
}
|
|
112
|
+
for (const property of ["lastModDate", "creationDate", "lastAccessDate"]) {
|
|
113
|
+
check("a copied entry keeps its " + property,
|
|
114
|
+
copied.every(filename => dateOf(entries.get(filename)[property]) === dateOf(sourceEntries.get(filename)[property])), true);
|
|
115
|
+
}
|
|
116
|
+
// the level bits say how hard the deflater tried, and a copy that drops them reports the
|
|
117
|
+
// packager's default instead of the level the entry was actually written at
|
|
118
|
+
check("a copied entry keeps the deflate level it was written at",
|
|
119
|
+
copied.every(filename => entries.get(filename).bitFlag.level === sourceEntries.get(filename).bitFlag.level), true);
|
|
120
|
+
// zip.js rebuilds the fields it interprets itself, so what has to survive is the rest
|
|
121
|
+
check("a copied entry keeps an extra field zip.js does not interpret",
|
|
122
|
+
extraFieldOf(entries.get("styles.css")), extraFieldOf(sourceEntries.get("styles.css")));
|
|
123
|
+
const sameBytes = await Promise.all(copied.map(async filename => equalData(
|
|
124
|
+
await readRawData(entries.get(filename)),
|
|
125
|
+
await readRawData(sourceEntries.get(filename)))));
|
|
126
|
+
check("a copied entry holds the bytes it was read from", sameBytes.every(Boolean), true);
|
|
127
|
+
}
|
|
128
|
+
|
|
92
129
|
{
|
|
93
130
|
const entries = await readArchive(await createPagesArchive(pages, packagerOptions({ tocPage: true })));
|
|
94
131
|
const toc = await readEntry(entries, "sfz-toc.html");
|
|
@@ -150,6 +187,39 @@ async function makePage(seed, { url, title, originalUrls }) {
|
|
|
150
187
|
return { url, title, originalUrls, getData: async () => bytes };
|
|
151
188
|
}
|
|
152
189
|
|
|
190
|
+
// a page archive holding, on purpose, nothing the packager's own writer would produce by default:
|
|
191
|
+
// a directory record, a name that needs the language encoding flag, a stored entry beside one
|
|
192
|
+
// deflated at the highest level, unix ownership, an extra field zip.js does not interpret, and
|
|
193
|
+
// dates outside the one the packager pins on its writer
|
|
194
|
+
async function makeMetadataPage() {
|
|
195
|
+
const zipWriter = new ZipWriter(new Uint8ArrayWriter(), { lastModDate: SOURCE_DATE });
|
|
196
|
+
await zipWriter.add("folder/", null, { directory: true, comment: "a folder" });
|
|
197
|
+
await zipWriter.add("styles.css", new TextReader("body{font-family:serif}"), {
|
|
198
|
+
level: 9,
|
|
199
|
+
comment: "https://example.com/café.css",
|
|
200
|
+
creationDate: SOURCE_DATE,
|
|
201
|
+
lastAccessDate: SOURCE_DATE,
|
|
202
|
+
internalFileAttributes: 1,
|
|
203
|
+
msDosCompatible: false,
|
|
204
|
+
unixMode: 0o100755,
|
|
205
|
+
uid: 501,
|
|
206
|
+
gid: 20,
|
|
207
|
+
extraField: new Map([[0x7777, new Uint8Array([1, 2, 3, 4])]])
|
|
208
|
+
});
|
|
209
|
+
await zipWriter.add("café.txt", new TextReader("un café"), { level: 0 });
|
|
210
|
+
const bytes = await zipWriter.close();
|
|
211
|
+
return { url: "https://example.com/metadata.html", title: "Metadata", getData: async () => bytes };
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
function dateOf(value) {
|
|
215
|
+
return value === undefined ? undefined : value.getTime();
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
function extraFieldOf(entry) {
|
|
219
|
+
const value = entry.extraField && entry.extraField.get(0x7777);
|
|
220
|
+
return value ? value.data.join(",") : undefined;
|
|
221
|
+
}
|
|
222
|
+
|
|
153
223
|
function packagerOptions(overrides = {}) {
|
|
154
224
|
return {
|
|
155
225
|
selfExtractingArchive: true,
|
|
@@ -170,6 +240,14 @@ function readEntry(entries, filename) {
|
|
|
170
240
|
return entries.get(filename).getData(new TextWriter());
|
|
171
241
|
}
|
|
172
242
|
|
|
243
|
+
function readRawData(entry) {
|
|
244
|
+
return entry.getData(new Uint8ArrayWriter(), { passThrough: true, checkCrc32: false });
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
function equalData(dataLeft, dataRight) {
|
|
248
|
+
return dataLeft.length == dataRight.length && dataLeft.every((value, index) => value == dataRight[index]);
|
|
249
|
+
}
|
|
250
|
+
|
|
173
251
|
function check(label, actual, expected) {
|
|
174
252
|
const ok = actual === expected;
|
|
175
253
|
console.log(`${ok ? "PASS" : "FAIL"} ${label}: ${actual}${ok ? "" : " (expected " + expected + ")"}`);
|
|
@@ -33,7 +33,7 @@ function check(label, actual, expected) {
|
|
|
33
33
|
const options = makeOptions();
|
|
34
34
|
const pageData = makePageData(2, 64 * 1024);
|
|
35
35
|
pageData.resources.images.push(storedResource("photo.jpg",
|
|
36
|
-
["-->", "</
|
|
36
|
+
["-->", "</script>", "</style>", "</noframes>", "</noembed>", "</iframe>", "</xmp>", "]]>"]));
|
|
37
37
|
const result = await runProcess(pageData, options);
|
|
38
38
|
check("all closers exhaust to", result.fallbackTag, "<plaintext>");
|
|
39
39
|
check("all closers keep extraction", result.extractionDisabled, false);
|
|
@@ -47,4 +47,49 @@ function check(label, actual, expected) {
|
|
|
47
47
|
check("stored '</xmp>' alone stays on comment path", result.fallbackTag, null);
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
+
// the rung patterns are matched over the archive BYTES rather than a decoded string, so these
|
|
51
|
+
// four pin the parts of that match a byte scan is easy to get wrong: closers are matched
|
|
52
|
+
// case-insensitively, a closer only counts when a tag-name terminator follows it, and the
|
|
53
|
+
// comment closer is '-->' or '--!>' and nothing else in between
|
|
54
|
+
|
|
55
|
+
{
|
|
56
|
+
const options = makeOptions();
|
|
57
|
+
const pageData = makePageData(4, 64 * 1024);
|
|
58
|
+
pageData.resources.images.push(storedResource("photo.jpg", ["-->", "</SCRIPT>"]));
|
|
59
|
+
const result = await runProcess(pageData, options);
|
|
60
|
+
check("an upper-case closer counts, so '</SCRIPT>' escalates to", result.fallbackTag, "<style type=sfz-data>");
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
{
|
|
64
|
+
const options = makeOptions();
|
|
65
|
+
const pageData = makePageData(5, 64 * 1024);
|
|
66
|
+
pageData.resources.images.push(storedResource("photo.jpg", ["-->", "</script\tsrc"]));
|
|
67
|
+
const result = await runProcess(pageData, options);
|
|
68
|
+
check("a tab terminates a closer, so '</script\\t' escalates to", result.fallbackTag, "<style type=sfz-data>");
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
{
|
|
72
|
+
const options = makeOptions();
|
|
73
|
+
const pageData = makePageData(6, 64 * 1024);
|
|
74
|
+
pageData.resources.images.push(storedResource("photo.jpg", ["-->", "</scriptx"]));
|
|
75
|
+
const result = await runProcess(pageData, options);
|
|
76
|
+
check("'</scriptx' is not a closer, so it stops at", result.fallbackTag, "<script type=sfz-data>");
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
{
|
|
80
|
+
const options = makeOptions();
|
|
81
|
+
const pageData = makePageData(7, 64 * 1024);
|
|
82
|
+
pageData.resources.images.push(storedResource("photo.jpg", ["--!>"]));
|
|
83
|
+
const result = await runProcess(pageData, options);
|
|
84
|
+
check("'--!>' closes a comment, so it falls back to", result.fallbackTag, "<script type=sfz-data>");
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
{
|
|
88
|
+
const options = makeOptions();
|
|
89
|
+
const pageData = makePageData(8, 64 * 1024);
|
|
90
|
+
pageData.resources.images.push(storedResource("photo.jpg", ["--?>"]));
|
|
91
|
+
const result = await runProcess(pageData, options);
|
|
92
|
+
check("'--?>' does not close a comment", result.fallbackTag, null);
|
|
93
|
+
}
|
|
94
|
+
|
|
50
95
|
Deno.exit(failed ? 1 : 0);
|
|
@@ -3,118 +3,118 @@
|
|
|
3
3
|
"seeds": [
|
|
4
4
|
{
|
|
5
5
|
"seed": 68,
|
|
6
|
-
"fallbackTag": "<
|
|
7
|
-
"pageSize":
|
|
6
|
+
"fallbackTag": "<script type=sfz-data>",
|
|
7
|
+
"pageSize": 723106
|
|
8
8
|
},
|
|
9
9
|
{
|
|
10
10
|
"seed": 154,
|
|
11
|
-
"fallbackTag": "<
|
|
12
|
-
"pageSize":
|
|
11
|
+
"fallbackTag": "<script type=sfz-data>",
|
|
12
|
+
"pageSize": 724555
|
|
13
13
|
},
|
|
14
14
|
{
|
|
15
15
|
"seed": 176,
|
|
16
|
-
"fallbackTag": "<
|
|
17
|
-
"pageSize":
|
|
16
|
+
"fallbackTag": "<script type=sfz-data>",
|
|
17
|
+
"pageSize": 724734
|
|
18
18
|
},
|
|
19
19
|
{
|
|
20
20
|
"seed": 184,
|
|
21
|
-
"fallbackTag": "<
|
|
22
|
-
"pageSize":
|
|
21
|
+
"fallbackTag": "<script type=sfz-data>",
|
|
22
|
+
"pageSize": 724449
|
|
23
23
|
},
|
|
24
24
|
{
|
|
25
25
|
"seed": 212,
|
|
26
|
-
"fallbackTag": "<
|
|
27
|
-
"pageSize":
|
|
26
|
+
"fallbackTag": "<script type=sfz-data>",
|
|
27
|
+
"pageSize": 723683
|
|
28
28
|
},
|
|
29
29
|
{
|
|
30
30
|
"seed": 223,
|
|
31
|
-
"fallbackTag": "<
|
|
32
|
-
"pageSize":
|
|
31
|
+
"fallbackTag": "<script type=sfz-data>",
|
|
32
|
+
"pageSize": 724277
|
|
33
33
|
},
|
|
34
34
|
{
|
|
35
35
|
"seed": 224,
|
|
36
|
-
"fallbackTag": "<
|
|
37
|
-
"pageSize":
|
|
36
|
+
"fallbackTag": "<script type=sfz-data>",
|
|
37
|
+
"pageSize": 724265
|
|
38
38
|
},
|
|
39
39
|
{
|
|
40
40
|
"seed": 232,
|
|
41
|
-
"fallbackTag": "<
|
|
42
|
-
"pageSize":
|
|
41
|
+
"fallbackTag": "<script type=sfz-data>",
|
|
42
|
+
"pageSize": 723856
|
|
43
43
|
},
|
|
44
44
|
{
|
|
45
45
|
"seed": 256,
|
|
46
|
-
"fallbackTag": "<
|
|
47
|
-
"pageSize":
|
|
46
|
+
"fallbackTag": "<script type=sfz-data>",
|
|
47
|
+
"pageSize": 722938
|
|
48
48
|
},
|
|
49
49
|
{
|
|
50
50
|
"seed": 282,
|
|
51
|
-
"fallbackTag": "<
|
|
52
|
-
"pageSize":
|
|
51
|
+
"fallbackTag": "<script type=sfz-data>",
|
|
52
|
+
"pageSize": 724570
|
|
53
53
|
},
|
|
54
54
|
{
|
|
55
55
|
"seed": 288,
|
|
56
|
-
"fallbackTag": "<
|
|
57
|
-
"pageSize":
|
|
56
|
+
"fallbackTag": "<script type=sfz-data>",
|
|
57
|
+
"pageSize": 725625
|
|
58
58
|
},
|
|
59
59
|
{
|
|
60
60
|
"seed": 343,
|
|
61
|
-
"fallbackTag": "<
|
|
62
|
-
"pageSize":
|
|
61
|
+
"fallbackTag": "<script type=sfz-data>",
|
|
62
|
+
"pageSize": 724582
|
|
63
63
|
},
|
|
64
64
|
{
|
|
65
65
|
"seed": 351,
|
|
66
|
-
"fallbackTag": "<
|
|
67
|
-
"pageSize":
|
|
66
|
+
"fallbackTag": "<script type=sfz-data>",
|
|
67
|
+
"pageSize": 724787
|
|
68
68
|
},
|
|
69
69
|
{
|
|
70
70
|
"seed": 372,
|
|
71
|
-
"fallbackTag": "<
|
|
72
|
-
"pageSize":
|
|
71
|
+
"fallbackTag": "<script type=sfz-data>",
|
|
72
|
+
"pageSize": 723867
|
|
73
73
|
},
|
|
74
74
|
{
|
|
75
75
|
"seed": 379,
|
|
76
|
-
"fallbackTag": "<
|
|
77
|
-
"pageSize":
|
|
76
|
+
"fallbackTag": "<script type=sfz-data>",
|
|
77
|
+
"pageSize": 725136
|
|
78
78
|
},
|
|
79
79
|
{
|
|
80
80
|
"seed": 383,
|
|
81
|
-
"fallbackTag": "<
|
|
82
|
-
"pageSize":
|
|
81
|
+
"fallbackTag": "<script type=sfz-data>",
|
|
82
|
+
"pageSize": 725078
|
|
83
83
|
},
|
|
84
84
|
{
|
|
85
85
|
"seed": 404,
|
|
86
|
-
"fallbackTag": "<
|
|
87
|
-
"pageSize":
|
|
86
|
+
"fallbackTag": "<script type=sfz-data>",
|
|
87
|
+
"pageSize": 723429
|
|
88
88
|
},
|
|
89
89
|
{
|
|
90
90
|
"seed": 426,
|
|
91
|
-
"fallbackTag": "<
|
|
92
|
-
"pageSize":
|
|
91
|
+
"fallbackTag": "<script type=sfz-data>",
|
|
92
|
+
"pageSize": 724508
|
|
93
93
|
},
|
|
94
94
|
{
|
|
95
95
|
"seed": 441,
|
|
96
|
-
"fallbackTag": "<
|
|
97
|
-
"pageSize":
|
|
96
|
+
"fallbackTag": "<script type=sfz-data>",
|
|
97
|
+
"pageSize": 724645
|
|
98
98
|
},
|
|
99
99
|
{
|
|
100
100
|
"seed": 445,
|
|
101
|
-
"fallbackTag": "<
|
|
102
|
-
"pageSize":
|
|
101
|
+
"fallbackTag": "<script type=sfz-data>",
|
|
102
|
+
"pageSize": 724563
|
|
103
103
|
},
|
|
104
104
|
{
|
|
105
105
|
"seed": 475,
|
|
106
|
-
"fallbackTag": "<
|
|
107
|
-
"pageSize":
|
|
106
|
+
"fallbackTag": "<script type=sfz-data>",
|
|
107
|
+
"pageSize": 723429
|
|
108
108
|
},
|
|
109
109
|
{
|
|
110
110
|
"seed": 495,
|
|
111
|
-
"fallbackTag": "<
|
|
112
|
-
"pageSize":
|
|
111
|
+
"fallbackTag": "<script type=sfz-data>",
|
|
112
|
+
"pageSize": 723247
|
|
113
113
|
},
|
|
114
114
|
{
|
|
115
115
|
"seed": 500,
|
|
116
|
-
"fallbackTag": "<
|
|
117
|
-
"pageSize":
|
|
116
|
+
"fallbackTag": "<script type=sfz-data>",
|
|
117
|
+
"pageSize": 724039
|
|
118
118
|
}
|
|
119
119
|
]
|
|
120
120
|
}
|
package/vendor/zip/z-worker.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(){"use strict";const{Array:t,Object:e,Number:n,Math:r,Error:s,Uint8Array:o,Uint16Array:c,Uint32Array:a,Int32Array:i,Map:u,DataView:l,Promise:f,TextEncoder:w,crypto:h,postMessage:p,TransformStream:d,ReadableStream:y,WritableStream:m,CompressionStream:S,DecompressionStream:g}=self,v=void 0,k="undefined",z="function",C=new o,b=[[],[],[],[],[],[],[],[]];for(let t=0;256>t;t++){let e=t;for(let t=0;8>t;t++)e=1&e?e>>>1^3988292384:e>>>1;b[0][t]=e}for(let t=0;256>t;t++)for(let e=1;8>e;e++){const n=b[e-1][t];b[e][t]=n>>>8^b[0][255&n]}const[I,A,x,P,M,B,D,F]=b;class R{constructor(t){this.o=t||-1}append(t){let e=0|this.o;const n=0|t.length;let r=0;if(n>=8&&t.buffer){const s=new l(t.buffer,t.byteOffset,n),o=n-8;for(;o>=r;r+=8){const t=e^s.getInt32(r,!0),n=s.getInt32(r+4,!0);e=F[255&t]^D[t>>>8&255]^B[t>>>16&255]^M[t>>>24&255]^P[255&n]^x[n>>>8&255]^A[n>>>16&255]^I[n>>>24&255]}}for(;n>r;r++)e=e>>>8^I[255&(e^t[r])];this.o=e}get(){return~this.o}}class _ extends d{constructor(){let t;const e=new R;super({transform(t,n){e.append(t),n.enqueue(t)},flush(){const n=new o(4);new l(n.buffer).setUint32(0,e.get()),t.value=n}}),t=this}}function T(t,e){const n=new o(t.length+e.length);return n.set(t),n.set(e,t.length),n}function U(t){return new l(t.buffer,t.byteOffset,t.byteLength)}const V={concat(t,e){if(0===t.length||0===e.length)return t.concat(e);const n=t[t.length-1],r=V.l(n);return 32===r?t.concat(e):V.h(e,r,0|n,t.slice(0,t.length-1))},bitLength(t){const e=t.length;if(0===e)return 0;const n=t[e-1];return 32*(e-1)+V.l(n)},m(t,e){if(32*t.length<e)return t;const n=(t=t.slice(0,r.ceil(e/32))).length;return e&=31,n>0&&e&&(t[n-1]=V.S(e,t[n-1]&2147483648>>e-1,1)),t},S:(t,e,n)=>32===t?e:(n?0|e:e<<32-t)+1099511627776*t,l:t=>r.round(t/1099511627776)||32,h(t,e,n,r){for(void 0===r&&(r=[]);e>=32;e-=32)r.push(n),n=0;if(0===e)return r.concat(t);for(let s=0;s<t.length;s++)r.push(n|t[s]>>>e),n=t[s]<<32-e;const s=t.length?t[t.length-1]:0,o=V.l(s);return r.push(V.S(e+o&31,e+o>32?n:r.pop(),1)),r}},K={bytes:{v(t){const e=V.bitLength(t)/8,n=new o(e);let r;for(let s=0;e>s;s++)3&s||(r=t[s/4]),n[s]=r>>>24,r<<=8;return n},C(t){const e=[];let n,r=0;for(n=0;n<t.length;n++)r=r<<8|t[n],3&~n||(e.push(r),r=0);return 3&n&&e.push(V.S(8*(3&n),r)),e}}},E=class{constructor(t){const e=this;e.blockSize=512,e.I=[1732584193,4023233417,2562383102,271733878,3285377520],e.A=[1518500249,1859775393,2400959708,3395469782],t?(e.P=t.P.slice(0),e.M=t.M.slice(0),e.B=t.B):e.reset()}reset(){const t=this;return t.P=t.I.slice(0),t.M=[],t.B=0,t}update(t){const e=this;"string"==typeof t&&(t=K.D.C(t));const n=e.M=V.concat(e.M,t),r=e.B,o=e.B=r+V.bitLength(t);if(o>9007199254740991)throw new s("Cannot hash more than 2^53 - 1 bits");const c=new a(n);let i=0;for(let t=e.blockSize+r-(e.blockSize+r&e.blockSize-1);o>=t;t+=e.blockSize)e.F(c.subarray(16*i,16*(i+1))),i+=1;return n.splice(0,16*i),e}R(){const t=this;let e=t.M;const n=t.P;e=V.concat(e,[V.S(1,1)]);for(let t=e.length+2;15&t;t++)e.push(0);for(e.push(r.floor(t.B/4294967296)),e.push(0|t.B);e.length;)t.F(e.splice(0,16));return t.reset(),n}_(t,e,n,r){return t>19?t>39?t>59?t>79?void 0:e^n^r:e&n|e&r|n&r:e^n^r:e&n|~e&r}T(t,e){return e<<t|e>>>32-t}F(e){const n=this,s=n.P,o=t(80);for(let t=0;16>t;t++)o[t]=e[t];let c=s[0],a=s[1],i=s[2],u=s[3],l=s[4];for(let t=0;79>=t;t++){16>t||(o[t]=n.T(1,o[t-3]^o[t-8]^o[t-14]^o[t-16]));const e=n.T(5,c)+n._(t,a,i,u)+l+o[t]+n.A[r.floor(t/20)]|0;l=u,u=i,i=n.T(30,a),a=c,c=e}s[0]=s[0]+c|0,s[1]=s[1]+a|0,s[2]=s[2]+i|0,s[3]=s[3]+u|0,s[4]=s[4]+l|0}},O={importKey:t=>new O.U(K.bytes.C(t)),V(t,e,n,r){if(n=n||1e4,0>r||0>n)throw new s("invalid params to pbkdf2");const o=1+(r>>5)<<2;let c,a,i,u,f;const w=new ArrayBuffer(o),h=new l(w);let p=0;const d=V;for(e=K.bytes.C(e),f=1;(o||1)>p;f++){for(c=a=t.encrypt(d.concat(e,[f])),i=1;n>i;i++)for(a=t.encrypt(a),u=0;u<a.length;u++)c[u]^=a[u];for(i=0;(o||1)>p&&i<c.length;i++)h.setInt32(p,c[i]),p+=4}return w.slice(0,r/8)},U:class{constructor(t){const e=this,n=e.K=E,r=[[],[]];e.O=[new n,new n];const s=e.O[0].blockSize/32;t.length>s&&(t=(new n).update(t).R());for(let e=0;s>e;e++)r[0][e]=909522486^t[e],r[1][e]=1549556828^t[e];e.O[0].update(r[0]),e.O[1].update(r[1]),e.W=new n(e.O[0])}reset(){const t=this;t.W=new t.K(t.O[0]),t.j=!1}update(t){this.j=!0,this.W.update(t)}digest(){const t=this,e=t.W.R(),n=new t.K(t.O[1]).update(e).R();return t.reset(),n}encrypt(t){if(this.j)throw new s("encrypt on already updated hmac called!");return this.update(t),this.digest(t)}}},W=typeof h!=k&&typeof h.getRandomValues==z,j="Invalid password",H="zipjs-abort-check-password";function L(t){if(W)return h.getRandomValues(t);throw new s("Crypto API not supported")}const N=16,q={name:"PBKDF2"},G=e.assign({hash:{name:"HMAC"}},q),J=e.assign({iterations:1e3,hash:{name:"SHA-1"}},q),Q=["deriveBits"],X=[8,12,16],Y=[16,24,32],Z=10,$=[0,0,0,0],tt=typeof h!=k,et=tt&&h.subtle,nt=tt&&typeof et!=k,rt=K.bytes,st=class{constructor(t){const e=this;e.H=[[[],[],[],[],[]],[[],[],[],[],[]]],e.H[0][0][0]||e.L();const n=e.H[0][4],r=e.H[1],o=t.length;let c,a,i,u=1;if(4!==o&&6!==o&&8!==o)throw new s("invalid aes key size");for(e.A=[a=t.slice(0),i=[]],c=o;4*o+28>c;c++){let t=a[c-1];(c%o===0||8===o&&c%o===4)&&(t=n[t>>>24]<<24^n[t>>16&255]<<16^n[t>>8&255]<<8^n[255&t],c%o===0&&(t=t<<8^t>>>24^u<<24,u=u<<1^283*(u>>7))),a[c]=a[c-o]^t}for(let t=0;c;t++,c--){const e=a[3&t?c:c-4];i[t]=4>=c||4>t?e:r[0][n[e>>>24]]^r[1][n[e>>16&255]]^r[2][n[e>>8&255]]^r[3][n[255&e]]}}encrypt(t){return this.N(t,0)}decrypt(t){return this.N(t,1)}L(){const t=this.H[0],e=this.H[1],n=t[4],r=e[4],s=[],o=[];let c,a,i,u;for(let t=0;256>t;t++)o[(s[t]=t<<1^283*(t>>7))^t]=t;for(let l=c=0;!n[l];l^=a||1,c=o[c]||1){let o=c^c<<1^c<<2^c<<3^c<<4;o=o>>8^255&o^99,n[l]=o,r[o]=l,u=s[i=s[a=s[l]]];let f=16843009*u^65537*i^257*a^16843008*l,w=257*s[o]^16843008*o;for(let n=0;4>n;n++)t[n][l]=w=w<<24^w>>>8,e[n][o]=f=f<<24^f>>>8}for(let n=0;5>n;n++)t[n]=t[n].slice(0),e[n]=e[n].slice(0)}N(t,e){if(4!==t.length)throw new s("invalid aes block size");const n=this.A[e],r=n.length/4-2,o=[0,0,0,0],c=this.H[e],a=c[0],i=c[1],u=c[2],l=c[3],f=c[4];let w,h,p,d=t[0]^n[0],y=t[e?3:1]^n[1],m=t[2]^n[2],S=t[e?1:3]^n[3],g=4;for(let t=0;r>t;t++)w=a[d>>>24]^i[y>>16&255]^u[m>>8&255]^l[255&S]^n[g],h=a[y>>>24]^i[m>>16&255]^u[S>>8&255]^l[255&d]^n[g+1],p=a[m>>>24]^i[S>>16&255]^u[d>>8&255]^l[255&y]^n[g+2],S=a[S>>>24]^i[d>>16&255]^u[y>>8&255]^l[255&m]^n[g+3],g+=4,d=w,y=h,m=p;for(let t=0;4>t;t++)o[e?3&-t:t]=f[d>>>24]<<24^f[y>>16&255]<<16^f[m>>8&255]<<8^f[255&S]^n[g++],w=d,d=y,y=m,m=S,S=w;return o}},ot=class{constructor(t,e){this.G=t,this.J=e,this.X=e}reset(){this.X=this.J}update(t){return this.Y(this.G,t,this.X)}Z(t){if(255&~(t>>24))t+=1<<24;else{let e=t>>16&255,n=t>>8&255,r=255&t;255===e?(e=0,255===n?(n=0,255===r?r=0:++r):++n):++e,t=0,t+=e<<16,t+=n<<8,t+=r}return t}$(t){0===(t[0]=this.Z(t[0]))&&(t[1]=this.Z(t[1]))}Y(t,e,n){let r;if(!(r=e.length))return[];const s=V.bitLength(e);for(let s=0;r>s;s+=4){this.$(n);const r=t.encrypt(n);e[s]^=r[0],e[s+1]^=r[1],e[s+2]^=r[2],e[s+3]^=r[3]}return V.m(e,s)}},ct=O.U;let at=tt&&nt&&typeof et.importKey==z,it=tt&&nt&&typeof et.deriveBits==z;class ut extends d{constructor({password:t,rawPassword:e,encryptionStrength:n,checkPasswordOnly:r,checkAuthenticationCode:c=!0}){super({start(){ft(this,t,e,n)},async transform(t,e){const n=this,{password:c,strength:a,et:i,ready:u}=n;c?(await(async(t,e,n,r)=>{const o=await ht(t,e,n,dt(r,0,X[e])),c=dt(r,X[e]);if(o[0]!=c[0]||o[1]!=c[1])throw new s(j)})(n,a,c,dt(t,0,X[a]+2)),t=dt(t,X[a]+2),r?e.error(new s(H)):i()):await u;const l=new o(t.length-Z-(t.length-Z)%N);e.enqueue(wt(n,t,l,0,Z,!0))},async flush(t){const{nt:e,st:n,ot:r,ready:o}=this;if(n&&e){await o;const a=dt(r,0,r.length-Z),i=dt(r,r.length-Z);let u=C;if(a.length){const t=mt(rt,a);n.update(t);const r=e.update(t);u=yt(rt,r)}const l=dt(yt(rt,n.digest()),0,Z);let f=r.length<Z?1:0;for(let t=0;Z>t;t++)f|=l[t]^i[t];if(f&&c)throw new s("Invalid authentication code");t.enqueue(u)}}})}}class lt extends d{constructor({password:t,rawPassword:e,encryptionStrength:n}){super({start(){ft(this,t,e,n)},async transform(t,e){const n=this,{password:r,strength:s,et:c,ready:a}=n;let i=C;r?(i=await(async(t,e,n)=>{const r=L(new o(X[e]));return T(r,await ht(t,e,n,r))})(n,s,r),c()):await a;const u=new o(i.length+t.length-t.length%N);u.set(i,0),e.enqueue(wt(n,t,u,i.length,0))},async flush(t){const{nt:e,st:n,ot:r,ready:s}=this;if(n&&e){await s;let o=C;if(r.length){const t=e.update(mt(rt,r));n.update(t),o=yt(rt,t)}const c=yt(rt,n.digest()).slice(0,Z);t.enqueue(T(o,c))}}})}}function ft(t,n,r,s){e.assign(t,{ready:new f(e=>t.et=e),password:pt(n,r),strength:s-1,ot:C})}function wt(t,e,n,r,s,c){const{nt:a,st:i,ot:u}=t;u.length&&(e=T(u,e));const l=e.length-s;let f;for(n=((t,e)=>{if(e&&e>t.length){const n=t;(t=new o(e)).set(n,0)}return t})(n,r+(l-l%N)),f=0;l-N>=f;f+=N){const t=mt(rt,dt(e,f,f+N));c&&i.update(t);const s=a.update(t);c||i.update(s),n.set(yt(rt,s),f+r)}return t.ot=dt(e,f),n}async function ht(n,r,s,c){n.password=null;const a=await(async(t,e,n,r,s)=>{if(!at)return O.importKey(e);try{return await et.importKey("raw",e,n,!1,s)}catch{return at=!1,O.importKey(e)}})(0,s,G,0,Q),i=await(async(t,e,n)=>{if(!it)return O.V(e,t.salt,J.iterations,n);try{return await et.deriveBits(t,e,n)}catch{return it=!1,O.V(e,t.salt,J.iterations,n)}})(e.assign({salt:c},J),a,8*(2*Y[r]+2)),u=new o(i),l=mt(rt,dt(u,0,Y[r])),f=mt(rt,dt(u,Y[r],2*Y[r])),w=dt(u,2*Y[r]);return e.assign(n,{keys:{key:l,ct:f,passwordVerification:w},nt:new ot(new st(l),t.from($)),st:new ct(f)}),w}function pt(t,e){return e===v?(t=>{if(typeof w==k){const e=new o((t=unescape(encodeURIComponent(t))).length);for(let n=0;n<e.length;n++)e[n]=t.charCodeAt(n);return e}return(new w).encode(t)})(t):e}function dt(t,e,n){return t.subarray(e,n)}function yt(t,e){return t.v(e)}function mt(t,e){return t.C(e)}class St extends d{constructor({password:t,rawPassword:e,passwordVerification:n,checkPasswordOnly:r}){super({start(){vt(this,t,e,n)},transform(t,e){const n=this;if(n.password||n.rawPassword){const e=kt(n,t.subarray(0,12));if(n.password=n.rawPassword=null,0!=(e[11]^n.passwordVerification))throw new s(j);t=t.subarray(12)}r?e.error(new s(H)):e.enqueue(kt(n,t))}})}}class gt extends d{constructor({password:t,rawPassword:e,passwordVerification:n}){super({start(){vt(this,t,e,n)},transform(t,e){const n=this;let r,s;if(n.password||n.rawPassword){n.password=n.rawPassword=null;const e=L(new o(12));e[11]=n.passwordVerification,r=new o(t.length+e.length),r.set(zt(n,e),0),s=12}else r=new o(t.length),s=0;r.set(zt(n,t),s),e.enqueue(r)}})}}function vt(t,n,r,s){e.assign(t,{password:n,rawPassword:r,passwordVerification:s}),((t,n,r)=>{const s=[305419896,591751049,878082192];if(e.assign(t,{keys:s,it:new R(s[0]),ut:new R(s[2])}),r)for(let e=0;e<r.length;e++)Ct(t,r[e]);else for(let e=0;e<n.length;e++)Ct(t,n.charCodeAt(e))})(t,n,r)}function kt(t,e){const n=new o(e.length);for(let r=0;r<e.length;r++)n[r]=bt(t)^e[r],Ct(t,n[r]);return n}function zt(t,e){const n=new o(e.length);for(let r=0;r<e.length;r++)n[r]=bt(t)^e[r],Ct(t,e[r]);return n}function Ct(t,e){let[,n]=t.keys;t.it.append([e]);const s=~t.it.get();n=At(r.imul(At(n+It(s)),134775813)+1),t.ut.append([n>>>24]);const o=~t.ut.get();t.keys=[s,n,o]}function bt(t){const e=2|t.keys[2];return It(r.imul(e,1^e)>>>8)}function It(t){return 255&t}function At(t){return 4294967295&t}function xt(t){if(t instanceof y)return t;const e=t.getReader();return new y({async pull(t){const{value:n,done:r}=await e.read();r?t.close():t.enqueue(n)},cancel:t=>e.cancel(t)})}const Pt=new u;function Mt(t){return Pt.get(t)}const Bt="Invalid uncompressed size",Dt="deflate-raw",Ft="gzip",Rt=[31,139,8];class _t extends d{constructor(t,{chunkSize:e,CompressionStreamFallback:n,CompressionStream:r}){super({});const{compressed:s,encrypted:o,useCompressionStream:c,zipCrypto:a,computeCrc32:i,level:u,deflate64:f,format:w,compressionMethod:h,inputSize:p}=t,d=this;let y,m,S,g=super.readable;const v=w&&Mt(w),k=i&&s&&!f&&!v&&(!o||a)&&!(!c||!r);if(o&&!a||!i||k||(y=new _,g=Wt(g,y)),s)if(v)g=jt(g,Et(v.CompressionStream,w,{level:u,chunkSize:e,compressionMethod:h,uncompressedSize:p}));else if(k)S=new Tt,g=jt(g,new r(Ft)),g=Wt(g,S);else try{g=Ot(g,c,{level:u,chunkSize:e},r,n)}catch(t){let e;try{e=new r(Ft)}catch{throw t}g=jt(g,e),g=Wt(g,new Tt)}o&&(a?g=Wt(g,new gt(t)):(m=new lt(t),g=Wt(g,m))),Kt(d,g,()=>{o&&!a||!i||(d.crc32=k?S.crc32:new l(y.value.buffer).getUint32(0))})}}class Tt extends d{constructor(){let t,e=10,n=new o(0);super({transform(t,s){if(e){const n=r.min(e,t.length);if(e-=n,!(t=t.subarray(n)).length)return}const o=n.length+t.length;if(8>=o)return void(n=T(n,t));const c=o-8,a=r.min(c,n.length);s.enqueue(T(n.subarray(0,a),t.subarray(0,c-a))),n=T(n.subarray(a),t.subarray(c-a))},flush(){const e=U(n);t.crc32=e.getUint32(0,!0),t.uncompressedSize=e.getUint32(4,!0)}}),t=this}}class Ut extends d{constructor(t,{chunkSize:e,DecompressionStreamFallback:n,DecompressionStream:r}){super({});const{zipCrypto:c,encrypted:a,checkCrc32:i,crc32:u,compressed:w,useCompressionStream:h,deflate64:p,format:m,compressionMethod:S,rawBitFlag:g,outputSize:k}=t;let z,C,b=super.readable;if(a&&(c?b=Wt(b,new St(t)):(C=new ut(t),b=Wt(b,C))),w){const t=m&&Mt(m);if(t)b=jt(b,Et(t.DecompressionStream,m,{chunkSize:e,compressionMethod:S,rawBitFlag:g,uncompressedSize:k}));else try{b=Ot(b,h,{chunkSize:e,deflate64:p},r,n)}catch(t){if(p||k===v)throw t;let e;try{e=new r(Ft)}catch{throw t}b=((t,e,n)=>{const r=new R;let c,a,i,u=0,l=!1;const w=new f((t,e)=>{a=t,i=e});w.catch(()=>{}),n||a();const h=new d({start(t){const e=new o(10);e.set(Rt),t.enqueue(e)},transform(t,e){e.enqueue(t)},async flush(t){l=!0,y();try{await w}finally{m()}const e=new o(8),s=U(e);s.setUint32(0,r.get(),!0),s.setUint32(4,n,!0),t.enqueue(e)},cancel(t){i(t)}}),p=new d({transform(t,e){r.append(t),u+=t.length,n>u?l&&y():a(),e.enqueue(t)},cancel(t){i(t)}});return t=Wt(t,h),Wt(t=jt(t,e),p);function y(){m(),c=setTimeout(()=>i(new s(Bt)),5e3)}function m(){clearTimeout(c)}})(b,e,k)}b=(t=>{const e=t.getReader();return new y({async pull(t){let n;try{n=await e.read()}catch(t){if(t&&t.message)throw t;const e=new s("Invalid compressed data");throw e.cause=t,e}const{value:r,done:o}=n;o?t.close():t.enqueue(r)},cancel:t=>e.cancel(t)})})(b)}i&&(z=new _,b=Wt(b,z)),Kt(this,b,()=>{if(i){const t=new l(z.value.buffer);if(u!=t.getUint32(0,!1))throw new s("Invalid CRC32")}})}}const Vt=new u;function Kt(t,n,r){n=Wt(n,new d({flush:r})),e.defineProperty(t,"readable",{get:()=>n})}function Et(t,e,n){if(!t)throw new s("Compression method not supported");return new t(e,n)}function Ot(t,e,n,r,s){const o=e&&r?r:s||r,c=n.deflate64?"deflate64-raw":Dt;let a;try{a=new o(c,n)}catch(t){if(!e||!s||o==s)throw t;a=new s(c,n)}return jt(t,a)}function Wt(t,e){return xt(t).pipeThrough(e)}function jt(t,e){const n=e.writable.getWriter(),r=t.getReader();return(async()=>{try{for(;;){await n.ready;const t=await r.read();if(t.done){await n.close();break}await n.write(t.value)}}catch(t){await(async(t,e)=>{try{await t.abort(e)}catch{}})(n,t),await(async(t,e)=>{try{await t.cancel(e)}catch{}})(r,t)}})(),e.readable}const Ht="data",Lt="close",Nt="deflate";class qt extends d{constructor(t,n){super({});const r=this,{codecType:o}=t;let c;o.startsWith(Nt)?c=_t:o.startsWith("inflate")&&(c=Ut),r.outputSize=0;let a=0;const i=new c(t,n),u=super.readable,l=new d({transform(t,e){t&&t.length&&(a+=t.length,e.enqueue(t))},flush(){e.assign(r,{inputSize:a})}}),f=new d({transform(e,n){if(e&&e.length&&(n.enqueue(e),r.outputSize+=e.length,t.outputSize!==v&&r.outputSize>t.outputSize))throw new s(Bt)},flush(){const{crc32:t}=i;e.assign(r,{crc32:t,inputSize:a})}});e.defineProperty(r,"readable",{get:()=>u.pipeThrough(l).pipeThrough(i).pipeThrough(f)})}}class Gt extends d{constructor(t){const e=[];let r=0;function s(){const n=new o(t);let s=0;for(;t>s;){const r=e[0],o=t-s;r.length>o?(n.set(r.subarray(0,o),s),e[0]=r.subarray(o),s+=o):(n.set(r,s),s+=r.length,e.shift())}return r-=t,n}n.isFinite(t)&&t>=1||(t=65536),super({transform(n,o){for(e.push(n),r+=n.length;r>t;)o.enqueue(s())},flush(t){r&&t.enqueue(((t,e)=>{const n=new o(e);let r=0;for(const e of t)n.set(e,r),r+=e.length;return n})(e,r))}})}}let Jt=2;try{typeof navigator!=k&&navigator.hardwareConcurrency&&(Jt=navigator.hardwareConcurrency)}catch{}const Qt=new u,Xt=new u;let Yt,Zt=0;async function $t(t){let e,o;try{const{options:c,config:a}=t;if(c.format)try{await(async(t,e)=>{!Pt.has(t)&&e&&((t,e)=>{const{CompressionStream:n,DecompressionStream:r}=e;if(typeof n!=z&&typeof r!=z)throw new s("Invalid codec module");Pt.set(t,{CompressionStream:n,DecompressionStream:r})})(t,await(import(e)))})(c.format,c.codecURI)}catch(t){throw t.codecImportFailed=!0,t}if(a.CompressionStream=self.CompressionStream,a.DecompressionStream=self.DecompressionStream,c.compressed&&!c.format)if(c.useCompressionStream){if(!((t,e)=>{if(!t)return!1;let n=Vt.get(t);n||(n=new u,Vt.set(t,n));let r=n.get(e);if(r===v){try{new t(e),r=!0}catch{r=!1}n.set(e,r)}return r})(c.codecType.startsWith(Nt)?a.CompressionStream:a.DecompressionStream,Dt))try{await self.initModule(t.config)}catch{}}else try{await self.initModule(t.config)}catch{c.useCompressionStream=!0}!a.CompressionStreamFallback&&a.CompressionStreamZlib&&(a.CompressionStreamFallback=a.CompressionStreamZlib),!a.DecompressionStreamFallback&&a.DecompressionStreamZlib&&(a.DecompressionStreamFallback=a.DecompressionStreamZlib);const i={highWaterMark:1},l=t.readable?xt(t.readable):new y({async pull(t){const e=new f(t=>Qt.set(Zt,t));te({type:"pull",messageId:Zt}),Zt=(Zt+1)%n.MAX_SAFE_INTEGER;const{value:r,done:s}=await e;t.enqueue(r),s&&t.close()}},i);o=t.writable?(t=>{if(t instanceof m)return t;const e=t.getWriter();return new m({write:t=>e.write(t),close:()=>e.close(),abort:t=>e.abort(t)})})(t.writable):new m({async write(t){let e;const r=new f(t=>e=t);Xt.set(Zt,e),te({type:Ht,value:t,messageId:Zt}),Zt=(Zt+1)%n.MAX_SAFE_INTEGER,await r}},i),e=new qt(c,a),Yt=new AbortController;const{signal:w}=Yt;await l.pipeThrough(e).pipeThrough(new Gt((t=>{return s="string"==typeof(e=s=t.chunkSize)&&e.trim()?n(e):e,n.isInteger(s)&&s>=1?r.max(s,64):65536;var e,s})(a))).pipeTo(o,{signal:w,preventClose:!0,preventAbort:!0}),await o.getWriter().close();const{crc32:h,inputSize:p,outputSize:d}=e;te({type:Lt,result:{crc32:h,inputSize:p,outputSize:d}})}catch(t){if(t.outputSize=e?e.outputSize:0,o&&!o.locked)try{await o.getWriter().close()}catch{}ee(t)}}function te(t){const{value:e}=t;if(e)if(e.length)try{t.value=(n=e,n.byteOffset||n.byteLength!=n.buffer.byteLength?new o(n):n).buffer,p(t,[t.value])}catch{p(t)}else p(t);else p(t);var n}function ee(t=new s("Unknown error")){const{message:e,stack:n,code:r,name:o,outputSize:c,cause:a,codecImportFailed:i}=t,u={message:e,stack:n,code:r,name:o,outputSize:c};a&&(u.cause={name:a.name,message:a.message}),i&&(u.codecImportFailed=!0),p({error:u})}addEventListener("message",({data:t})=>{const{type:e,messageId:n,value:r,done:s}=t;try{if("start"==e&&$t(t),e==Ht){const t=Qt.get(n);Qt.delete(n),t({value:r||new o,done:s})}if("ack"==e){const t=Xt.get(n);Xt.delete(n),t()}e==Lt&&Yt.abort()}catch(t){ee(t)}}),p({type:"ready"}),((t={})=>{const{init:e}=t,n=t.CompressionStreamFallback||t.CompressionStreamZlib,r=t.DecompressionStreamFallback||t.DecompressionStreamZlib;self.initModule=async t=>{e&&await e(t),n&&(t.CompressionStreamFallback=n),r&&(t.DecompressionStreamFallback=r)}})()}();
|
|
1
|
+
!function(){"use strict";const{Array:t,Object:e,Number:n,Math:r,Error:s,Uint8Array:o,Uint16Array:c,Uint32Array:a,Int32Array:i,Map:u,DataView:f,Promise:l,TextEncoder:w,crypto:h,postMessage:p,TransformStream:d,ReadableStream:y,WritableStream:m,CompressionStream:S,DecompressionStream:g}=self,v=void 0,k="undefined",z="function",C=new o,b=[[],[],[],[],[],[],[],[]];for(let t=0;256>t;t++){let e=t;for(let t=0;8>t;t++)e=1&e?e>>>1^3988292384:e>>>1;b[0][t]=e}for(let t=0;256>t;t++)for(let e=1;8>e;e++){const n=b[e-1][t];b[e][t]=n>>>8^b[0][255&n]}const[I,A,x,P,M,B,D,F]=b;class R{constructor(t){this.o=t||-1}append(t){let e=0|this.o;const n=0|t.length;let r=0;if(n>=8&&t.buffer){const s=new f(t.buffer,t.byteOffset,n),o=n-8;for(;o>=r;r+=8){const t=e^s.getInt32(r,!0),n=s.getInt32(r+4,!0);e=F[255&t]^D[t>>>8&255]^B[t>>>16&255]^M[t>>>24&255]^P[255&n]^x[n>>>8&255]^A[n>>>16&255]^I[n>>>24&255]}}for(;n>r;r++)e=e>>>8^I[255&(e^t[r])];this.o=e}get(){return~this.o}}class V extends d{constructor(){let t;const e=new R;super({transform(t,n){e.append(t),n.enqueue(t)},flush(){const n=new o(4);new f(n.buffer).setUint32(0,e.get()),t.value=n}}),t=this}}function _(t,e){const n=new o(t.length+e.length);return n.set(t),n.set(e,t.length),n}function T(t){return new f(t.buffer,t.byteOffset,t.byteLength)}const U={concat(t,e){if(0===t.length||0===e.length)return t.concat(e);const n=t[t.length-1],r=U.l(n);return 32===r?t.concat(e):U.h(e,r,0|n,t.slice(0,t.length-1))},bitLength(t){const e=t.length;if(0===e)return 0;const n=t[e-1];return 32*(e-1)+U.l(n)},m(t,e){if(32*t.length<e)return t;const n=(t=t.slice(0,r.ceil(e/32))).length;return e&=31,n>0&&e&&(t[n-1]=U.S(e,t[n-1]&2147483648>>e-1,1)),t},S:(t,e,n)=>32===t?e:(n?0|e:e<<32-t)+1099511627776*t,l:t=>r.round(t/1099511627776)||32,h(t,e,n,r){for(void 0===r&&(r=[]);e>=32;e-=32)r.push(n),n=0;if(0===e)return r.concat(t);for(let s=0;s<t.length;s++)r.push(n|t[s]>>>e),n=t[s]<<32-e;const s=t.length?t[t.length-1]:0,o=U.l(s);return r.push(U.S(e+o&31,e+o>32?n:r.pop(),1)),r}},K={bytes:{v(t){const e=U.bitLength(t)/8,n=new o(e);let r;for(let s=0;e>s;s++)3&s||(r=t[s/4]),n[s]=r>>>24,r<<=8;return n},C(t){const e=[];let n,r=0;for(n=0;n<t.length;n++)r=r<<8|t[n],3&~n||(e.push(r),r=0);return 3&n&&e.push(U.S(8*(3&n),r)),e}}},j=class{constructor(t){const e=this;e.blockSize=512,e.I=[1732584193,4023233417,2562383102,271733878,3285377520],e.A=[1518500249,1859775393,2400959708,3395469782],t?(e.P=t.P.slice(0),e.M=t.M.slice(0),e.B=t.B):e.reset()}reset(){const t=this;return t.P=t.I.slice(0),t.M=[],t.B=0,t}update(t){const e=this;"string"==typeof t&&(t=K.D.C(t));const n=e.M=U.concat(e.M,t),r=e.B,o=e.B=r+U.bitLength(t);if(o>9007199254740991)throw new s("Cannot hash more than 2^53 - 1 bits");const c=new a(n);let i=0;for(let t=e.blockSize+r-(e.blockSize+r&e.blockSize-1);o>=t;t+=e.blockSize)e.F(c.subarray(16*i,16*(i+1))),i+=1;return n.splice(0,16*i),e}R(){const t=this;let e=t.M;const n=t.P;e=U.concat(e,[U.S(1,1)]);for(let t=e.length+2;15&t;t++)e.push(0);for(e.push(r.floor(t.B/4294967296)),e.push(0|t.B);e.length;)t.F(e.splice(0,16));return t.reset(),n}V(t,e,n,r){return t>19?t>39?t>59?t>79?void 0:e^n^r:e&n|e&r|n&r:e^n^r:e&n|~e&r}_(t,e){return e<<t|e>>>32-t}F(e){const n=this,s=n.P,o=t(80);for(let t=0;16>t;t++)o[t]=e[t];let c=s[0],a=s[1],i=s[2],u=s[3],f=s[4];for(let t=0;79>=t;t++){16>t||(o[t]=n._(1,o[t-3]^o[t-8]^o[t-14]^o[t-16]));const e=n._(5,c)+n.V(t,a,i,u)+f+o[t]+n.A[r.floor(t/20)]|0;f=u,u=i,i=n._(30,a),a=c,c=e}s[0]=s[0]+c|0,s[1]=s[1]+a|0,s[2]=s[2]+i|0,s[3]=s[3]+u|0,s[4]=s[4]+f|0}},E={importKey:t=>new E.T(K.bytes.C(t)),U(t,e,n,r){if(n=n||1e4,0>r||0>n)throw new s("invalid params to pbkdf2");const o=1+(r>>5)<<2;let c,a,i,u,l;const w=new ArrayBuffer(o),h=new f(w);let p=0;const d=U;for(e=K.bytes.C(e),l=1;(o||1)>p;l++){for(c=a=t.encrypt(d.concat(e,[l])),i=1;n>i;i++)for(a=t.encrypt(a),u=0;u<a.length;u++)c[u]^=a[u];for(i=0;(o||1)>p&&i<c.length;i++)h.setInt32(p,c[i]),p+=4}return w.slice(0,r/8)},T:class{constructor(t){const e=this,n=e.K=j,r=[[],[]];e.j=[new n,new n];const s=e.j[0].blockSize/32;t.length>s&&(t=(new n).update(t).R());for(let e=0;s>e;e++)r[0][e]=909522486^t[e],r[1][e]=1549556828^t[e];e.j[0].update(r[0]),e.j[1].update(r[1]),e.O=new n(e.j[0])}reset(){const t=this;t.O=new t.K(t.j[0]),t.W=!1}update(t){this.W=!0,this.O.update(t)}digest(){const t=this,e=t.O.R(),n=new t.K(t.j[1]).update(e).R();return t.reset(),n}encrypt(t){if(this.W)throw new s("encrypt on already updated hmac called!");return this.update(t),this.digest(t)}}},O=typeof h!=k&&typeof h.getRandomValues==z,W="Invalid password",H="zipjs-abort-check-password";function L(t){if(O)return h.getRandomValues(t);throw new s("Crypto API not supported")}const N=16,q={name:"PBKDF2"},G=e.assign({hash:{name:"HMAC"}},q),J=e.assign({iterations:1e3,hash:{name:"SHA-1"}},q),Q=["deriveBits"],X=[8,12,16],Y=[16,24,32],Z=10,$=[0,0,0,0],tt=typeof h!=k,et=tt&&h.subtle,nt=tt&&typeof et!=k,rt=K.bytes,st=class{constructor(t){const e=this;e.H=[[[],[],[],[],[]],[[],[],[],[],[]]],e.H[0][0][0]||e.L();const n=e.H[0][4],r=e.H[1],o=t.length;let c,a,i,u=1;if(4!==o&&6!==o&&8!==o)throw new s("invalid aes key size");for(e.A=[a=t.slice(0),i=[]],c=o;4*o+28>c;c++){let t=a[c-1];(c%o===0||8===o&&c%o===4)&&(t=n[t>>>24]<<24^n[t>>16&255]<<16^n[t>>8&255]<<8^n[255&t],c%o===0&&(t=t<<8^t>>>24^u<<24,u=u<<1^283*(u>>7))),a[c]=a[c-o]^t}for(let t=0;c;t++,c--){const e=a[3&t?c:c-4];i[t]=4>=c||4>t?e:r[0][n[e>>>24]]^r[1][n[e>>16&255]]^r[2][n[e>>8&255]]^r[3][n[255&e]]}}encrypt(t){return this.N(t,0)}decrypt(t){return this.N(t,1)}L(){const t=this.H[0],e=this.H[1],n=t[4],r=e[4],s=[],o=[];let c,a,i,u;for(let t=0;256>t;t++)o[(s[t]=t<<1^283*(t>>7))^t]=t;for(let f=c=0;!n[f];f^=a||1,c=o[c]||1){let o=c^c<<1^c<<2^c<<3^c<<4;o=o>>8^255&o^99,n[f]=o,r[o]=f,u=s[i=s[a=s[f]]];let l=16843009*u^65537*i^257*a^16843008*f,w=257*s[o]^16843008*o;for(let n=0;4>n;n++)t[n][f]=w=w<<24^w>>>8,e[n][o]=l=l<<24^l>>>8}for(let n=0;5>n;n++)t[n]=t[n].slice(0),e[n]=e[n].slice(0)}N(t,e){if(4!==t.length)throw new s("invalid aes block size");const n=this.A[e],r=n.length/4-2,o=[0,0,0,0],c=this.H[e],a=c[0],i=c[1],u=c[2],f=c[3],l=c[4];let w,h,p,d=t[0]^n[0],y=t[e?3:1]^n[1],m=t[2]^n[2],S=t[e?1:3]^n[3],g=4;for(let t=0;r>t;t++)w=a[d>>>24]^i[y>>16&255]^u[m>>8&255]^f[255&S]^n[g],h=a[y>>>24]^i[m>>16&255]^u[S>>8&255]^f[255&d]^n[g+1],p=a[m>>>24]^i[S>>16&255]^u[d>>8&255]^f[255&y]^n[g+2],S=a[S>>>24]^i[d>>16&255]^u[y>>8&255]^f[255&m]^n[g+3],g+=4,d=w,y=h,m=p;for(let t=0;4>t;t++)o[e?3&-t:t]=l[d>>>24]<<24^l[y>>16&255]<<16^l[m>>8&255]<<8^l[255&S]^n[g++],w=d,d=y,y=m,m=S,S=w;return o}},ot=class{constructor(t,e){this.G=t,this.J=e,this.X=e}reset(){this.X=this.J}update(t){return this.Y(this.G,t,this.X)}Z(t){if(255&~(t>>24))t+=1<<24;else{let e=t>>16&255,n=t>>8&255,r=255&t;255===e?(e=0,255===n?(n=0,255===r?r=0:++r):++n):++e,t=0,t+=e<<16,t+=n<<8,t+=r}return t}$(t){0===(t[0]=this.Z(t[0]))&&(t[1]=this.Z(t[1]))}Y(t,e,n){let r;if(!(r=e.length))return[];const s=U.bitLength(e);for(let s=0;r>s;s+=4){this.$(n);const r=t.encrypt(n);e[s]^=r[0],e[s+1]^=r[1],e[s+2]^=r[2],e[s+3]^=r[3]}return U.m(e,s)}},ct=E.T;let at=tt&&nt&&typeof et.importKey==z,it=tt&&nt&&typeof et.deriveBits==z;class ut extends d{constructor({password:t,rawPassword:e,encryptionStrength:n,checkPasswordOnly:r,checkAuthenticationCode:c=!0}){super({start(){lt(this,t,e,n)},async transform(t,e){const n=this,{password:c,strength:a,et:i,ready:u}=n;c?(await(async(t,e,n,r)=>{const o=await ht(t,e,n,dt(r,0,X[e])),c=dt(r,X[e]);if(o[0]!=c[0]||o[1]!=c[1])throw new s(W)})(n,a,c,dt(t,0,X[a]+2)),t=dt(t,X[a]+2),r?e.error(new s(H)):i()):await u;const f=new o(t.length-Z-(t.length-Z)%N);e.enqueue(wt(n,t,f,0,Z,!0))},async flush(t){const{nt:e,st:n,ot:r,ready:o}=this;if(n&&e){await o;const a=dt(r,0,r.length-Z),i=dt(r,r.length-Z);let u=C;if(a.length){const t=mt(rt,a);n.update(t);const r=e.update(t);u=yt(rt,r)}const f=dt(yt(rt,n.digest()),0,Z);let l=r.length<Z?1:0;for(let t=0;Z>t;t++)l|=f[t]^i[t];if(l&&c)throw new s("Invalid authentication code");t.enqueue(u)}}})}}class ft extends d{constructor({password:t,rawPassword:e,encryptionStrength:n}){super({start(){lt(this,t,e,n)},async transform(t,e){const n=this,{password:r,strength:s,et:c,ready:a}=n;let i=C;r?(i=await(async(t,e,n)=>{const r=L(new o(X[e]));return _(r,await ht(t,e,n,r))})(n,s,r),c()):await a;const u=new o(i.length+t.length-t.length%N);u.set(i,0),e.enqueue(wt(n,t,u,i.length,0))},async flush(t){const{nt:e,st:n,ot:r,ready:s}=this;if(n&&e){await s;let o=C;if(r.length){const t=e.update(mt(rt,r));n.update(t),o=yt(rt,t)}const c=yt(rt,n.digest()).slice(0,Z);t.enqueue(_(o,c))}}})}}function lt(t,n,r,s){e.assign(t,{ready:new l(e=>t.et=e),password:pt(n,r),strength:s-1,ot:C})}function wt(t,e,n,r,s,c){const{nt:a,st:i,ot:u}=t;u.length&&(e=_(u,e));const f=e.length-s;let l;for(n=((t,e)=>{if(e&&e>t.length){const n=t;(t=new o(e)).set(n,0)}return t})(n,r+(f-f%N)),l=0;f-N>=l;l+=N){const t=mt(rt,dt(e,l,l+N));c&&i.update(t);const s=a.update(t);c||i.update(s),n.set(yt(rt,s),l+r)}return t.ot=dt(e,l),n}async function ht(n,r,s,c){n.password=null;const a=await(async(t,e,n,r,s)=>{if(!at)return E.importKey(e);try{return await et.importKey("raw",e,n,!1,s)}catch{return at=!1,E.importKey(e)}})(0,s,G,0,Q),i=await(async(t,e,n)=>{if(!it)return E.U(e,t.salt,J.iterations,n);try{return await et.deriveBits(t,e,n)}catch{return it=!1,E.U(e,t.salt,J.iterations,n)}})(e.assign({salt:c},J),a,8*(2*Y[r]+2)),u=new o(i),f=mt(rt,dt(u,0,Y[r])),l=mt(rt,dt(u,Y[r],2*Y[r])),w=dt(u,2*Y[r]);return e.assign(n,{keys:{key:f,ct:l,passwordVerification:w},nt:new ot(new st(f),t.from($)),st:new ct(l)}),w}function pt(t,e){return e===v?(t=>{if(typeof w==k){const e=new o((t=unescape(encodeURIComponent(t))).length);for(let n=0;n<e.length;n++)e[n]=t.charCodeAt(n);return e}return(new w).encode(t)})(t):e}function dt(t,e,n){return t.subarray(e,n)}function yt(t,e){return t.v(e)}function mt(t,e){return t.C(e)}class St extends d{constructor({password:t,rawPassword:e,passwordVerification:n,checkPasswordOnly:r}){super({start(){vt(this,t,e,n)},transform(t,e){const n=this;if(n.password||n.rawPassword){const e=kt(n,t.subarray(0,12));if(n.password=n.rawPassword=null,0!=(e[11]^n.passwordVerification))throw new s(W);t=t.subarray(12)}r?e.error(new s(H)):e.enqueue(kt(n,t))}})}}class gt extends d{constructor({password:t,rawPassword:e,passwordVerification:n}){super({start(){vt(this,t,e,n)},transform(t,e){const n=this;let r,s;if(n.password||n.rawPassword){n.password=n.rawPassword=null;const e=L(new o(12));e[11]=n.passwordVerification,r=new o(t.length+e.length),r.set(zt(n,e),0),s=12}else r=new o(t.length),s=0;r.set(zt(n,t),s),e.enqueue(r)}})}}function vt(t,n,r,s){e.assign(t,{password:n,rawPassword:r,passwordVerification:s}),((t,n,r)=>{const s=[305419896,591751049,878082192];if(e.assign(t,{keys:s,it:new R(s[0]),ut:new R(s[2])}),r)for(let e=0;e<r.length;e++)Ct(t,r[e]);else for(let e=0;e<n.length;e++)Ct(t,n.charCodeAt(e))})(t,n,r)}function kt(t,e){const n=new o(e.length);for(let r=0;r<e.length;r++)n[r]=bt(t)^e[r],Ct(t,n[r]);return n}function zt(t,e){const n=new o(e.length);for(let r=0;r<e.length;r++)n[r]=bt(t)^e[r],Ct(t,e[r]);return n}function Ct(t,e){let[,n]=t.keys;t.it.append([e]);const s=~t.it.get();n=At(r.imul(At(n+It(s)),134775813)+1),t.ut.append([n>>>24]);const o=~t.ut.get();t.keys=[s,n,o]}function bt(t){const e=2|t.keys[2];return It(r.imul(e,1^e)>>>8)}function It(t){return 255&t}function At(t){return 4294967295&t}function xt(t){if(t instanceof y)return t;const e=t.getReader();return new y({async pull(t){const{value:n,done:r}=await e.read();r?t.close():t.enqueue(n)},cancel:t=>e.cancel(t)})}const Pt=new u;function Mt(t){return Pt.get(t)}const Bt="Invalid uncompressed size",Dt="deflate-raw",Ft="gzip",Rt=[31,139,8];class Vt extends d{constructor(t,{chunkSize:e,CompressionStreamFallback:n,CompressionStream:r}){super({});const{compressed:s,encrypted:o,useCompressionStream:c,zipCrypto:a,computeCrc32:i,level:u,deflate64:l,format:w,compressionMethod:h,inputSize:p}=t,d=this;let y,m,S,g=super.readable;const v=w&&Mt(w),k=i&&s&&!l&&!v&&(!o||a)&&!(!c||!r);if(o&&!a||!i||k||(y=new V,g=Ot(g,y)),s)if(v)g=Wt(g,jt(v.CompressionStream,w,{level:u,chunkSize:e,compressionMethod:h,uncompressedSize:p}));else if(k)S=new _t,g=Wt(g,new r(Ft)),g=Ot(g,S);else try{g=Et(g,c,{level:u,chunkSize:e},r,n)}catch(t){let e;try{e=new r(Ft)}catch{throw t}g=Wt(g,e),g=Ot(g,new _t)}o&&(a?g=Ot(g,new gt(t)):(m=new ft(t),g=Ot(g,m))),Kt(d,g,()=>{o&&!a||!i||(d.crc32=k?S.crc32:new f(y.value.buffer).getUint32(0))})}}class _t extends d{constructor(){let t,e=10,n=new o(0);super({transform(t,s){if(e){const n=r.min(e,t.length);if(e-=n,!(t=t.subarray(n)).length)return}const o=n.length+t.length;if(8>=o)return void(n=_(n,t));const c=o-8,a=r.min(c,n.length);s.enqueue(_(n.subarray(0,a),t.subarray(0,c-a))),n=_(n.subarray(a),t.subarray(c-a))},flush(){const e=T(n);t.crc32=e.getUint32(0,!0),t.uncompressedSize=e.getUint32(4,!0)}}),t=this}}class Tt extends d{constructor(t,{chunkSize:e,DecompressionStreamFallback:n,DecompressionStream:r}){super({});const{zipCrypto:c,encrypted:a,checkCrc32:i,crc32:u,compressed:w,useCompressionStream:h,deflate64:p,format:m,compressionMethod:S,rawBitFlag:g,outputSize:k}=t;let z,C,b=super.readable;if(a&&(c?b=Ot(b,new St(t)):(C=new ut(t),b=Ot(b,C))),w){const t=m&&Mt(m);if(t)b=Wt(b,jt(t.DecompressionStream,m,{chunkSize:e,compressionMethod:S,rawBitFlag:g,uncompressedSize:k}));else try{b=Et(b,h,{chunkSize:e,deflate64:p},r,n)}catch(t){if(p||k===v)throw t;let e;try{e=new r(Ft)}catch{throw t}b=((t,e,n)=>{const r=new R;let c,a,i,u=0,f=!1;const w=new l((t,e)=>{a=t,i=e});w.catch(()=>{}),n||a();const h=new d({start(t){const e=new o(10);e.set(Rt),t.enqueue(e)},transform(t,e){e.enqueue(t)},async flush(t){f=!0,y();try{await w}finally{m()}const e=new o(8),s=T(e);s.setUint32(0,r.get(),!0),s.setUint32(4,n,!0),t.enqueue(e)},cancel(t){i(t)}}),p=new d({transform(t,e){r.append(t),u+=t.length,n>u?f&&y():a(),e.enqueue(t)},cancel(t){i(t)}});return t=Ot(t,h),Ot(t=Wt(t,e),p);function y(){m(),c=setTimeout(()=>i(new s(Bt)),5e3)}function m(){clearTimeout(c)}})(b,e,k)}b=(t=>{const e=t.getReader();return new y({async pull(t){let n;try{n=await e.read()}catch(t){if(t&&t.message)throw t;const e=new s("Invalid compressed data");throw e.cause=t,e}const{value:r,done:o}=n;o?t.close():t.enqueue(r)},cancel:t=>e.cancel(t)})})(b)}i&&(z=new V,b=Ot(b,z)),Kt(this,b,()=>{if(i){const t=new f(z.value.buffer);if(u!=t.getUint32(0,!1))throw new s("Invalid CRC32")}})}}const Ut=new u;function Kt(t,n,r){n=Ot(n,new d({flush:r})),e.defineProperty(t,"readable",{get:()=>n})}function jt(t,e,n){if(!t)throw new s("Compression method not supported");return new t(e,n)}function Et(t,e,n,r,s){const o=e&&r?r:s||r,c=n.deflate64?"deflate64-raw":Dt;let a;try{a=new o(c,n)}catch(t){if(!e||!s||o==s)throw t;a=new s(c,n)}return Wt(t,a)}function Ot(t,e){return xt(t).pipeThrough(e)}function Wt(t,e){const n=e.writable.getWriter(),r=t.getReader();return(async()=>{try{for(;;){await n.ready;const t=await r.read();if(t.done){await n.close();break}await n.write(t.value)}}catch(t){await(async(t,e)=>{try{await t.abort(e)}catch{}})(n,t),await(async(t,e)=>{try{await t.cancel(e)}catch{}})(r,t)}})(),e.readable}const Ht="data",Lt="close",Nt="deflate";class qt extends d{constructor(t,n){super({});const r=this,{codecType:o}=t;let c;o.startsWith(Nt)?c=Vt:o.startsWith("inflate")&&(c=Tt),r.outputSize=0;let a=0;const i=new c(t,n),u=super.readable,f=new d({transform(t,e){t&&t.length&&(a+=t.length,e.enqueue(t))},flush(){e.assign(r,{inputSize:a})}}),l=new d({transform(e,n){if(e&&e.length&&(n.enqueue(e),r.outputSize+=e.length,t.outputSize!==v&&r.outputSize>t.outputSize))throw new s(Bt)},flush(){const{crc32:t}=i;e.assign(r,{crc32:t,inputSize:a})}});e.defineProperty(r,"readable",{get:()=>u.pipeThrough(f).pipeThrough(i).pipeThrough(l)})}}class Gt extends d{constructor(t){const r=[];let s=0,c=0;function a(){const e=new o(t);let n=0;for(;t>n;){const s=r[0],o=t-n;s.length>o?(e.set(s.subarray(0,o),n),r[0]=s.subarray(o),n+=o):(e.set(s,n),n+=s.length,r.shift())}return s-=t,e}n.isFinite(t)&&t>=1||(t=65536),super({transform(e,n){for(r.push(e),s+=e.length;s>t;)c+=t,n.enqueue(a())},flush(t){s&&(c+=s,t.enqueue(((t,e)=>{const n=new o(e);let r=0;for(const e of t)n.set(e,r),r+=e.length;return n})(r,s)))}}),e.defineProperty(this,"outputSize",{get:()=>c})}}let Jt=2;try{typeof navigator!=k&&navigator.hardwareConcurrency&&(Jt=navigator.hardwareConcurrency)}catch{}function Qt(t){return!!t&&"object"==typeof t}const Xt=new u,Yt=new u,Zt=(()=>{try{return structuredClone(new s)instanceof s}catch{return!1}})();let $t,te=0;async function ee(t){let e,o,c;try{const{options:a,config:i}=t;if(a.format)try{await(async(t,e)=>{!Pt.has(t)&&e&&((t,e)=>{const{CompressionStream:n,DecompressionStream:r}=e;if(typeof n!=z&&typeof r!=z)throw new s("Invalid codec module");Pt.set(t,{CompressionStream:n,DecompressionStream:r})})(t,await(import(e)))})(a.format,a.codecURI)}catch(t){if(Qt(t))try{t.codecImportFailed=!0}catch{}throw t}if(i.CompressionStream=self.CompressionStream,i.DecompressionStream=self.DecompressionStream,a.compressed&&!a.format)if(a.useCompressionStream){if(!((t,e)=>{if(!t)return!1;let n=Ut.get(t);n||(n=new u,Ut.set(t,n));let r=n.get(e);if(r===v){try{new t(e),r=!0}catch{r=!1}n.set(e,r)}return r})(a.codecType.startsWith(Nt)?i.CompressionStream:i.DecompressionStream,Dt))try{await self.initModule(t.config)}catch{}}else try{await self.initModule(t.config)}catch{a.useCompressionStream=!0}!i.CompressionStreamFallback&&i.CompressionStreamZlib&&(i.CompressionStreamFallback=i.CompressionStreamZlib),!i.DecompressionStreamFallback&&i.DecompressionStreamZlib&&(i.DecompressionStreamFallback=i.DecompressionStreamZlib);const f={highWaterMark:1},w=t.readable?xt(t.readable):new y({async pull(t){const e=new l(t=>Xt.set(te,t));ne({type:"pull",messageId:te}),te=(te+1)%n.MAX_SAFE_INTEGER;const{value:r,done:s}=await e;t.enqueue(r),s&&t.close()}},f);c=t.writable?(t=>{if(t instanceof m)return t;const e=t.getWriter();return new m({write:t=>e.write(t),close:()=>e.close(),abort:t=>e.abort(t)})})(t.writable):new m({async write(t){let e;const r=new l(t=>e=t);Yt.set(te,e),ne({type:Ht,value:t,messageId:te}),te=(te+1)%n.MAX_SAFE_INTEGER,await r}},f),e=new qt(a,i),o=new Gt((t=>{return s="string"==typeof(e=s=t.chunkSize)&&e.trim()?n(e):e,n.isInteger(s)&&s>=1?r.max(s,64):65536;var e,s})(i)),$t=new AbortController;const{signal:h}=$t;await w.pipeThrough(e).pipeThrough(o).pipeTo(c,{signal:h,preventClose:!0,preventAbort:!0}),await c.getWriter().close();const{crc32:p,inputSize:d,outputSize:S}=e;ne({type:Lt,result:{crc32:p,inputSize:d,outputSize:S}})}catch(t){const e=o?o.outputSize:0;if(Qt(t))try{t.outputSize=e}catch{}if(c&&!c.locked)try{await c.getWriter().close()}catch{}re(t,e)}}function ne(t){const{value:e}=t;if(e)if(e.length)try{t.value=(n=e,n.byteOffset||n.byteLength!=n.buffer.byteLength?new o(n):n).buffer,p(t,[t.value])}catch{p(t)}else p(t);else p(t);var n}function re(t,e){const{message:n,stack:r,code:o,name:c,outputSize:a,cause:i,codecImportFailed:u}=((t=new s("Unknown error"))=>Qt(t)?t:new s(t+""))(t),f={message:n,stack:r,code:o,name:c,outputSize:a===v?e:a};if(i&&(f.cause={name:i.name,message:i.message}),u&&(f.codecImportFailed=!0),Zt)try{return void p({error:f,errorValue:{value:t}})}catch{}p({error:f})}addEventListener("message",({data:t})=>{const{type:e,messageId:n,value:r,done:s}=t;try{if("start"==e&&ee(t),e==Ht){const t=Xt.get(n);Xt.delete(n),t({value:r||new o,done:s})}if("ack"==e){const t=Yt.get(n);Yt.delete(n),t()}e==Lt&&$t.abort()}catch(t){re(t)}}),p({type:"ready"}),((t={})=>{const{init:e}=t,n=t.CompressionStreamFallback||t.CompressionStreamZlib,r=t.DecompressionStreamFallback||t.DecompressionStreamZlib;self.initModule=async t=>{e&&await e(t),n&&(t.CompressionStreamFallback=n),r&&(t.DecompressionStreamFallback=r)}})()}();
|