@fangyb/ahchat-bridge 0.1.23 → 0.1.24

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.
@@ -0,0 +1,4974 @@
1
+ import {
2
+ __commonJS,
3
+ __esm,
4
+ __require,
5
+ __toESM
6
+ } from "./chunk-2ESYSVXG.js";
7
+
8
+ // ../../node_modules/.pnpm/ieee754@1.2.1/node_modules/ieee754/index.js
9
+ var require_ieee754 = __commonJS({
10
+ "../../node_modules/.pnpm/ieee754@1.2.1/node_modules/ieee754/index.js"(exports) {
11
+ "use strict";
12
+ exports.read = function(buffer, offset, isLE, mLen, nBytes) {
13
+ var e, m;
14
+ var eLen = nBytes * 8 - mLen - 1;
15
+ var eMax = (1 << eLen) - 1;
16
+ var eBias = eMax >> 1;
17
+ var nBits = -7;
18
+ var i = isLE ? nBytes - 1 : 0;
19
+ var d = isLE ? -1 : 1;
20
+ var s = buffer[offset + i];
21
+ i += d;
22
+ e = s & (1 << -nBits) - 1;
23
+ s >>= -nBits;
24
+ nBits += eLen;
25
+ for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8) {
26
+ }
27
+ m = e & (1 << -nBits) - 1;
28
+ e >>= -nBits;
29
+ nBits += mLen;
30
+ for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8) {
31
+ }
32
+ if (e === 0) {
33
+ e = 1 - eBias;
34
+ } else if (e === eMax) {
35
+ return m ? NaN : (s ? -1 : 1) * Infinity;
36
+ } else {
37
+ m = m + Math.pow(2, mLen);
38
+ e = e - eBias;
39
+ }
40
+ return (s ? -1 : 1) * m * Math.pow(2, e - mLen);
41
+ };
42
+ exports.write = function(buffer, value, offset, isLE, mLen, nBytes) {
43
+ var e, m, c;
44
+ var eLen = nBytes * 8 - mLen - 1;
45
+ var eMax = (1 << eLen) - 1;
46
+ var eBias = eMax >> 1;
47
+ var rt = mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0;
48
+ var i = isLE ? 0 : nBytes - 1;
49
+ var d = isLE ? 1 : -1;
50
+ var s = value < 0 || value === 0 && 1 / value < 0 ? 1 : 0;
51
+ value = Math.abs(value);
52
+ if (isNaN(value) || value === Infinity) {
53
+ m = isNaN(value) ? 1 : 0;
54
+ e = eMax;
55
+ } else {
56
+ e = Math.floor(Math.log(value) / Math.LN2);
57
+ if (value * (c = Math.pow(2, -e)) < 1) {
58
+ e--;
59
+ c *= 2;
60
+ }
61
+ if (e + eBias >= 1) {
62
+ value += rt / c;
63
+ } else {
64
+ value += rt * Math.pow(2, 1 - eBias);
65
+ }
66
+ if (value * c >= 2) {
67
+ e++;
68
+ c /= 2;
69
+ }
70
+ if (e + eBias >= eMax) {
71
+ m = 0;
72
+ e = eMax;
73
+ } else if (e + eBias >= 1) {
74
+ m = (value * c - 1) * Math.pow(2, mLen);
75
+ e = e + eBias;
76
+ } else {
77
+ m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen);
78
+ e = 0;
79
+ }
80
+ }
81
+ for (; mLen >= 8; buffer[offset + i] = m & 255, i += d, m /= 256, mLen -= 8) {
82
+ }
83
+ e = e << mLen | m;
84
+ eLen += mLen;
85
+ for (; eLen > 0; buffer[offset + i] = e & 255, i += d, e /= 256, eLen -= 8) {
86
+ }
87
+ buffer[offset + i - d] |= s * 128;
88
+ };
89
+ }
90
+ });
91
+
92
+ // ../../node_modules/.pnpm/@borewit+text-codec@0.2.2/node_modules/@borewit/text-codec/lib/index.js
93
+ function utf8Decoder() {
94
+ if (typeof globalThis.TextDecoder === "undefined")
95
+ return void 0;
96
+ return _utf8Decoder !== null && _utf8Decoder !== void 0 ? _utf8Decoder : _utf8Decoder = new globalThis.TextDecoder("utf-8");
97
+ }
98
+ function textDecode(bytes, encoding = "utf-8") {
99
+ switch (encoding.toLowerCase()) {
100
+ case "utf-8":
101
+ case "utf8": {
102
+ const dec = utf8Decoder();
103
+ return dec ? dec.decode(bytes) : decodeUTF8(bytes);
104
+ }
105
+ case "utf-16le":
106
+ return decodeUTF16LE(bytes);
107
+ case "us-ascii":
108
+ case "ascii":
109
+ return decodeASCII(bytes);
110
+ case "latin1":
111
+ case "iso-8859-1":
112
+ return decodeLatin1(bytes);
113
+ case "windows-1252":
114
+ return decodeWindows1252(bytes);
115
+ default:
116
+ throw new RangeError(`Encoding '${encoding}' not supported`);
117
+ }
118
+ }
119
+ function flushChunk(parts, chunk) {
120
+ if (chunk.length === 0)
121
+ return;
122
+ parts.push(String.fromCharCode.apply(null, chunk));
123
+ chunk.length = 0;
124
+ }
125
+ function pushCodeUnit(parts, chunk, codeUnit) {
126
+ chunk.push(codeUnit);
127
+ if (chunk.length >= CHUNK)
128
+ flushChunk(parts, chunk);
129
+ }
130
+ function pushCodePoint(parts, chunk, cp) {
131
+ if (cp <= 65535) {
132
+ pushCodeUnit(parts, chunk, cp);
133
+ return;
134
+ }
135
+ cp -= 65536;
136
+ pushCodeUnit(parts, chunk, 55296 + (cp >> 10));
137
+ pushCodeUnit(parts, chunk, 56320 + (cp & 1023));
138
+ }
139
+ function decodeUTF8(bytes) {
140
+ const parts = [];
141
+ const chunk = [];
142
+ let i = 0;
143
+ if (bytes.length >= 3 && bytes[0] === 239 && bytes[1] === 187 && bytes[2] === 191) {
144
+ i = 3;
145
+ }
146
+ while (i < bytes.length) {
147
+ const b1 = bytes[i];
148
+ if (b1 <= 127) {
149
+ pushCodeUnit(parts, chunk, b1);
150
+ i++;
151
+ continue;
152
+ }
153
+ if (b1 < 194 || b1 > 244) {
154
+ pushCodeUnit(parts, chunk, REPLACEMENT);
155
+ i++;
156
+ continue;
157
+ }
158
+ if (b1 <= 223) {
159
+ if (i + 1 >= bytes.length) {
160
+ pushCodeUnit(parts, chunk, REPLACEMENT);
161
+ i++;
162
+ continue;
163
+ }
164
+ const b22 = bytes[i + 1];
165
+ if ((b22 & 192) !== 128) {
166
+ pushCodeUnit(parts, chunk, REPLACEMENT);
167
+ i++;
168
+ continue;
169
+ }
170
+ const cp2 = (b1 & 31) << 6 | b22 & 63;
171
+ pushCodeUnit(parts, chunk, cp2);
172
+ i += 2;
173
+ continue;
174
+ }
175
+ if (b1 <= 239) {
176
+ if (i + 2 >= bytes.length) {
177
+ pushCodeUnit(parts, chunk, REPLACEMENT);
178
+ i++;
179
+ continue;
180
+ }
181
+ const b22 = bytes[i + 1];
182
+ const b32 = bytes[i + 2];
183
+ const valid2 = (b22 & 192) === 128 && (b32 & 192) === 128 && !(b1 === 224 && b22 < 160) && // overlong
184
+ !(b1 === 237 && b22 >= 160);
185
+ if (!valid2) {
186
+ pushCodeUnit(parts, chunk, REPLACEMENT);
187
+ i++;
188
+ continue;
189
+ }
190
+ const cp2 = (b1 & 15) << 12 | (b22 & 63) << 6 | b32 & 63;
191
+ pushCodeUnit(parts, chunk, cp2);
192
+ i += 3;
193
+ continue;
194
+ }
195
+ if (i + 3 >= bytes.length) {
196
+ pushCodeUnit(parts, chunk, REPLACEMENT);
197
+ i++;
198
+ continue;
199
+ }
200
+ const b2 = bytes[i + 1];
201
+ const b3 = bytes[i + 2];
202
+ const b4 = bytes[i + 3];
203
+ const valid = (b2 & 192) === 128 && (b3 & 192) === 128 && (b4 & 192) === 128 && !(b1 === 240 && b2 < 144) && // overlong
204
+ !(b1 === 244 && b2 > 143);
205
+ if (!valid) {
206
+ pushCodeUnit(parts, chunk, REPLACEMENT);
207
+ i++;
208
+ continue;
209
+ }
210
+ const cp = (b1 & 7) << 18 | (b2 & 63) << 12 | (b3 & 63) << 6 | b4 & 63;
211
+ pushCodePoint(parts, chunk, cp);
212
+ i += 4;
213
+ }
214
+ flushChunk(parts, chunk);
215
+ return parts.join("");
216
+ }
217
+ function decodeUTF16LE(bytes) {
218
+ const parts = [];
219
+ const chunk = [];
220
+ const len = bytes.length;
221
+ let i = 0;
222
+ while (i + 1 < len) {
223
+ const u1 = bytes[i] | bytes[i + 1] << 8;
224
+ i += 2;
225
+ if (u1 >= 55296 && u1 <= 56319) {
226
+ if (i + 1 < len) {
227
+ const u2 = bytes[i] | bytes[i + 1] << 8;
228
+ if (u2 >= 56320 && u2 <= 57343) {
229
+ pushCodeUnit(parts, chunk, u1);
230
+ pushCodeUnit(parts, chunk, u2);
231
+ i += 2;
232
+ } else {
233
+ pushCodeUnit(parts, chunk, REPLACEMENT);
234
+ }
235
+ } else {
236
+ pushCodeUnit(parts, chunk, REPLACEMENT);
237
+ }
238
+ continue;
239
+ }
240
+ if (u1 >= 56320 && u1 <= 57343) {
241
+ pushCodeUnit(parts, chunk, REPLACEMENT);
242
+ continue;
243
+ }
244
+ pushCodeUnit(parts, chunk, u1);
245
+ }
246
+ if (i < len) {
247
+ pushCodeUnit(parts, chunk, REPLACEMENT);
248
+ }
249
+ flushChunk(parts, chunk);
250
+ return parts.join("");
251
+ }
252
+ function decodeASCII(bytes) {
253
+ const parts = [];
254
+ for (let i = 0; i < bytes.length; i += CHUNK) {
255
+ const end = Math.min(bytes.length, i + CHUNK);
256
+ const codes = new Array(end - i);
257
+ for (let j = i, k = 0; j < end; j++, k++) {
258
+ codes[k] = bytes[j] & 127;
259
+ }
260
+ parts.push(String.fromCharCode.apply(null, codes));
261
+ }
262
+ return parts.join("");
263
+ }
264
+ function decodeLatin1(bytes) {
265
+ const parts = [];
266
+ for (let i = 0; i < bytes.length; i += CHUNK) {
267
+ const end = Math.min(bytes.length, i + CHUNK);
268
+ const codes = new Array(end - i);
269
+ for (let j = i, k = 0; j < end; j++, k++) {
270
+ codes[k] = bytes[j];
271
+ }
272
+ parts.push(String.fromCharCode.apply(null, codes));
273
+ }
274
+ return parts.join("");
275
+ }
276
+ function decodeWindows1252(bytes) {
277
+ const parts = [];
278
+ let out = "";
279
+ for (let i = 0; i < bytes.length; i++) {
280
+ const b = bytes[i];
281
+ const extra = b >= 128 && b <= 159 ? WINDOWS_1252_EXTRA[b] : void 0;
282
+ out += extra !== null && extra !== void 0 ? extra : String.fromCharCode(b);
283
+ if (out.length >= CHUNK) {
284
+ parts.push(out);
285
+ out = "";
286
+ }
287
+ }
288
+ if (out)
289
+ parts.push(out);
290
+ return parts.join("");
291
+ }
292
+ var WINDOWS_1252_EXTRA, WINDOWS_1252_REVERSE, _utf8Decoder, CHUNK, REPLACEMENT;
293
+ var init_lib = __esm({
294
+ "../../node_modules/.pnpm/@borewit+text-codec@0.2.2/node_modules/@borewit/text-codec/lib/index.js"() {
295
+ "use strict";
296
+ WINDOWS_1252_EXTRA = {
297
+ 128: "\u20AC",
298
+ 130: "\u201A",
299
+ 131: "\u0192",
300
+ 132: "\u201E",
301
+ 133: "\u2026",
302
+ 134: "\u2020",
303
+ 135: "\u2021",
304
+ 136: "\u02C6",
305
+ 137: "\u2030",
306
+ 138: "\u0160",
307
+ 139: "\u2039",
308
+ 140: "\u0152",
309
+ 142: "\u017D",
310
+ 145: "\u2018",
311
+ 146: "\u2019",
312
+ 147: "\u201C",
313
+ 148: "\u201D",
314
+ 149: "\u2022",
315
+ 150: "\u2013",
316
+ 151: "\u2014",
317
+ 152: "\u02DC",
318
+ 153: "\u2122",
319
+ 154: "\u0161",
320
+ 155: "\u203A",
321
+ 156: "\u0153",
322
+ 158: "\u017E",
323
+ 159: "\u0178"
324
+ };
325
+ WINDOWS_1252_REVERSE = {};
326
+ for (const [code, char] of Object.entries(WINDOWS_1252_EXTRA)) {
327
+ WINDOWS_1252_REVERSE[char] = Number.parseInt(code, 10);
328
+ }
329
+ CHUNK = 32 * 1024;
330
+ REPLACEMENT = 65533;
331
+ }
332
+ });
333
+
334
+ // ../../node_modules/.pnpm/token-types@6.1.2/node_modules/token-types/lib/index.js
335
+ function dv(array) {
336
+ return new DataView(array.buffer, array.byteOffset);
337
+ }
338
+ var ieee754, UINT8, UINT16_LE, UINT16_BE, UINT32_LE, UINT32_BE, INT32_BE, UINT64_LE, StringType;
339
+ var init_lib2 = __esm({
340
+ "../../node_modules/.pnpm/token-types@6.1.2/node_modules/token-types/lib/index.js"() {
341
+ "use strict";
342
+ ieee754 = __toESM(require_ieee754(), 1);
343
+ init_lib();
344
+ UINT8 = {
345
+ len: 1,
346
+ get(array, offset) {
347
+ return dv(array).getUint8(offset);
348
+ },
349
+ put(array, offset, value) {
350
+ dv(array).setUint8(offset, value);
351
+ return offset + 1;
352
+ }
353
+ };
354
+ UINT16_LE = {
355
+ len: 2,
356
+ get(array, offset) {
357
+ return dv(array).getUint16(offset, true);
358
+ },
359
+ put(array, offset, value) {
360
+ dv(array).setUint16(offset, value, true);
361
+ return offset + 2;
362
+ }
363
+ };
364
+ UINT16_BE = {
365
+ len: 2,
366
+ get(array, offset) {
367
+ return dv(array).getUint16(offset);
368
+ },
369
+ put(array, offset, value) {
370
+ dv(array).setUint16(offset, value);
371
+ return offset + 2;
372
+ }
373
+ };
374
+ UINT32_LE = {
375
+ len: 4,
376
+ get(array, offset) {
377
+ return dv(array).getUint32(offset, true);
378
+ },
379
+ put(array, offset, value) {
380
+ dv(array).setUint32(offset, value, true);
381
+ return offset + 4;
382
+ }
383
+ };
384
+ UINT32_BE = {
385
+ len: 4,
386
+ get(array, offset) {
387
+ return dv(array).getUint32(offset);
388
+ },
389
+ put(array, offset, value) {
390
+ dv(array).setUint32(offset, value);
391
+ return offset + 4;
392
+ }
393
+ };
394
+ INT32_BE = {
395
+ len: 4,
396
+ get(array, offset) {
397
+ return dv(array).getInt32(offset);
398
+ },
399
+ put(array, offset, value) {
400
+ dv(array).setInt32(offset, value);
401
+ return offset + 4;
402
+ }
403
+ };
404
+ UINT64_LE = {
405
+ len: 8,
406
+ get(array, offset) {
407
+ return dv(array).getBigUint64(offset, true);
408
+ },
409
+ put(array, offset, value) {
410
+ dv(array).setBigUint64(offset, value, true);
411
+ return offset + 8;
412
+ }
413
+ };
414
+ StringType = class {
415
+ constructor(len, encoding) {
416
+ this.len = len;
417
+ this.encoding = encoding;
418
+ }
419
+ get(data, offset = 0) {
420
+ const bytes = data.subarray(offset, offset + this.len);
421
+ return textDecode(bytes, this.encoding);
422
+ }
423
+ };
424
+ }
425
+ });
426
+
427
+ // ../../node_modules/.pnpm/strtok3@10.3.5/node_modules/strtok3/lib/stream/Errors.js
428
+ var defaultMessages, EndOfStreamError, AbortError;
429
+ var init_Errors = __esm({
430
+ "../../node_modules/.pnpm/strtok3@10.3.5/node_modules/strtok3/lib/stream/Errors.js"() {
431
+ "use strict";
432
+ defaultMessages = "End-Of-Stream";
433
+ EndOfStreamError = class extends Error {
434
+ constructor() {
435
+ super(defaultMessages);
436
+ this.name = "EndOfStreamError";
437
+ }
438
+ };
439
+ AbortError = class extends Error {
440
+ constructor(message = "The operation was aborted") {
441
+ super(message);
442
+ this.name = "AbortError";
443
+ }
444
+ };
445
+ }
446
+ });
447
+
448
+ // ../../node_modules/.pnpm/strtok3@10.3.5/node_modules/strtok3/lib/stream/Deferred.js
449
+ var init_Deferred = __esm({
450
+ "../../node_modules/.pnpm/strtok3@10.3.5/node_modules/strtok3/lib/stream/Deferred.js"() {
451
+ "use strict";
452
+ }
453
+ });
454
+
455
+ // ../../node_modules/.pnpm/strtok3@10.3.5/node_modules/strtok3/lib/stream/AbstractStreamReader.js
456
+ var AbstractStreamReader;
457
+ var init_AbstractStreamReader = __esm({
458
+ "../../node_modules/.pnpm/strtok3@10.3.5/node_modules/strtok3/lib/stream/AbstractStreamReader.js"() {
459
+ "use strict";
460
+ init_Errors();
461
+ AbstractStreamReader = class {
462
+ constructor() {
463
+ this.endOfStream = false;
464
+ this.interrupted = false;
465
+ this.peekQueue = [];
466
+ }
467
+ async peek(uint8Array, mayBeLess = false) {
468
+ const bytesRead = await this.read(uint8Array, mayBeLess);
469
+ this.peekQueue.push(uint8Array.subarray(0, bytesRead));
470
+ return bytesRead;
471
+ }
472
+ async read(buffer, mayBeLess = false) {
473
+ if (buffer.length === 0) {
474
+ return 0;
475
+ }
476
+ let bytesRead = this.readFromPeekBuffer(buffer);
477
+ if (!this.endOfStream) {
478
+ bytesRead += await this.readRemainderFromStream(buffer.subarray(bytesRead), mayBeLess);
479
+ }
480
+ if (bytesRead === 0 && !mayBeLess) {
481
+ throw new EndOfStreamError();
482
+ }
483
+ return bytesRead;
484
+ }
485
+ /**
486
+ * Read chunk from stream
487
+ * @param buffer - Target Uint8Array (or Buffer) to store data read from stream in
488
+ * @returns Number of bytes read
489
+ */
490
+ readFromPeekBuffer(buffer) {
491
+ let remaining = buffer.length;
492
+ let bytesRead = 0;
493
+ while (this.peekQueue.length > 0 && remaining > 0) {
494
+ const peekData = this.peekQueue.pop();
495
+ if (!peekData)
496
+ throw new Error("peekData should be defined");
497
+ const lenCopy = Math.min(peekData.length, remaining);
498
+ buffer.set(peekData.subarray(0, lenCopy), bytesRead);
499
+ bytesRead += lenCopy;
500
+ remaining -= lenCopy;
501
+ if (lenCopy < peekData.length) {
502
+ this.peekQueue.push(peekData.subarray(lenCopy));
503
+ }
504
+ }
505
+ return bytesRead;
506
+ }
507
+ async readRemainderFromStream(buffer, mayBeLess) {
508
+ let bytesRead = 0;
509
+ while (bytesRead < buffer.length && !this.endOfStream) {
510
+ if (this.interrupted) {
511
+ throw new AbortError();
512
+ }
513
+ const chunkLen = await this.readFromStream(buffer.subarray(bytesRead), mayBeLess);
514
+ if (chunkLen === 0)
515
+ break;
516
+ bytesRead += chunkLen;
517
+ }
518
+ if (!mayBeLess && bytesRead < buffer.length) {
519
+ throw new EndOfStreamError();
520
+ }
521
+ return bytesRead;
522
+ }
523
+ };
524
+ }
525
+ });
526
+
527
+ // ../../node_modules/.pnpm/strtok3@10.3.5/node_modules/strtok3/lib/stream/StreamReader.js
528
+ var init_StreamReader = __esm({
529
+ "../../node_modules/.pnpm/strtok3@10.3.5/node_modules/strtok3/lib/stream/StreamReader.js"() {
530
+ "use strict";
531
+ init_Errors();
532
+ init_Deferred();
533
+ init_AbstractStreamReader();
534
+ }
535
+ });
536
+
537
+ // ../../node_modules/.pnpm/strtok3@10.3.5/node_modules/strtok3/lib/stream/WebStreamReader.js
538
+ var WebStreamReader;
539
+ var init_WebStreamReader = __esm({
540
+ "../../node_modules/.pnpm/strtok3@10.3.5/node_modules/strtok3/lib/stream/WebStreamReader.js"() {
541
+ "use strict";
542
+ init_AbstractStreamReader();
543
+ WebStreamReader = class extends AbstractStreamReader {
544
+ constructor(reader) {
545
+ super();
546
+ this.reader = reader;
547
+ }
548
+ async abort() {
549
+ return this.close();
550
+ }
551
+ async close() {
552
+ this.reader.releaseLock();
553
+ }
554
+ };
555
+ }
556
+ });
557
+
558
+ // ../../node_modules/.pnpm/strtok3@10.3.5/node_modules/strtok3/lib/stream/WebStreamByobReader.js
559
+ var WebStreamByobReader;
560
+ var init_WebStreamByobReader = __esm({
561
+ "../../node_modules/.pnpm/strtok3@10.3.5/node_modules/strtok3/lib/stream/WebStreamByobReader.js"() {
562
+ "use strict";
563
+ init_WebStreamReader();
564
+ WebStreamByobReader = class extends WebStreamReader {
565
+ /**
566
+ * Read from stream
567
+ * @param buffer - Target Uint8Array (or Buffer) to store data read from stream in
568
+ * @param mayBeLess - If true, may fill the buffer partially
569
+ * @protected Bytes read
570
+ */
571
+ async readFromStream(buffer, mayBeLess) {
572
+ if (buffer.length === 0)
573
+ return 0;
574
+ const result = await this.reader.read(new Uint8Array(buffer.length), { min: mayBeLess ? void 0 : buffer.length });
575
+ if (result.done) {
576
+ this.endOfStream = result.done;
577
+ }
578
+ if (result.value) {
579
+ buffer.set(result.value);
580
+ return result.value.length;
581
+ }
582
+ return 0;
583
+ }
584
+ };
585
+ }
586
+ });
587
+
588
+ // ../../node_modules/.pnpm/strtok3@10.3.5/node_modules/strtok3/lib/stream/WebStreamDefaultReader.js
589
+ var WebStreamDefaultReader;
590
+ var init_WebStreamDefaultReader = __esm({
591
+ "../../node_modules/.pnpm/strtok3@10.3.5/node_modules/strtok3/lib/stream/WebStreamDefaultReader.js"() {
592
+ "use strict";
593
+ init_Errors();
594
+ init_AbstractStreamReader();
595
+ WebStreamDefaultReader = class extends AbstractStreamReader {
596
+ constructor(reader) {
597
+ super();
598
+ this.reader = reader;
599
+ this.buffer = null;
600
+ }
601
+ /**
602
+ * Copy chunk to target, and store the remainder in this.buffer
603
+ */
604
+ writeChunk(target, chunk) {
605
+ const written = Math.min(chunk.length, target.length);
606
+ target.set(chunk.subarray(0, written));
607
+ if (written < chunk.length) {
608
+ this.buffer = chunk.subarray(written);
609
+ } else {
610
+ this.buffer = null;
611
+ }
612
+ return written;
613
+ }
614
+ /**
615
+ * Read from stream
616
+ * @param buffer - Target Uint8Array (or Buffer) to store data read from stream in
617
+ * @param mayBeLess - If true, may fill the buffer partially
618
+ * @protected Bytes read
619
+ */
620
+ async readFromStream(buffer, mayBeLess) {
621
+ if (buffer.length === 0)
622
+ return 0;
623
+ let totalBytesRead = 0;
624
+ if (this.buffer) {
625
+ totalBytesRead += this.writeChunk(buffer, this.buffer);
626
+ }
627
+ while (totalBytesRead < buffer.length && !this.endOfStream) {
628
+ const result = await this.reader.read();
629
+ if (result.done) {
630
+ this.endOfStream = true;
631
+ break;
632
+ }
633
+ if (result.value) {
634
+ totalBytesRead += this.writeChunk(buffer.subarray(totalBytesRead), result.value);
635
+ }
636
+ }
637
+ if (!mayBeLess && totalBytesRead === 0 && this.endOfStream) {
638
+ throw new EndOfStreamError();
639
+ }
640
+ return totalBytesRead;
641
+ }
642
+ abort() {
643
+ this.interrupted = true;
644
+ return this.reader.cancel();
645
+ }
646
+ async close() {
647
+ await this.abort();
648
+ this.reader.releaseLock();
649
+ }
650
+ };
651
+ }
652
+ });
653
+
654
+ // ../../node_modules/.pnpm/strtok3@10.3.5/node_modules/strtok3/lib/stream/WebStreamReaderFactory.js
655
+ function makeWebStreamReader(stream) {
656
+ try {
657
+ const reader = stream.getReader({ mode: "byob" });
658
+ if (reader instanceof ReadableStreamDefaultReader) {
659
+ return new WebStreamDefaultReader(reader);
660
+ }
661
+ return new WebStreamByobReader(reader);
662
+ } catch (error) {
663
+ if (error instanceof TypeError) {
664
+ return new WebStreamDefaultReader(stream.getReader());
665
+ }
666
+ throw error;
667
+ }
668
+ }
669
+ var init_WebStreamReaderFactory = __esm({
670
+ "../../node_modules/.pnpm/strtok3@10.3.5/node_modules/strtok3/lib/stream/WebStreamReaderFactory.js"() {
671
+ "use strict";
672
+ init_WebStreamByobReader();
673
+ init_WebStreamDefaultReader();
674
+ }
675
+ });
676
+
677
+ // ../../node_modules/.pnpm/strtok3@10.3.5/node_modules/strtok3/lib/stream/index.js
678
+ var init_stream = __esm({
679
+ "../../node_modules/.pnpm/strtok3@10.3.5/node_modules/strtok3/lib/stream/index.js"() {
680
+ "use strict";
681
+ init_Errors();
682
+ init_StreamReader();
683
+ init_WebStreamByobReader();
684
+ init_WebStreamDefaultReader();
685
+ init_WebStreamReaderFactory();
686
+ }
687
+ });
688
+
689
+ // ../../node_modules/.pnpm/strtok3@10.3.5/node_modules/strtok3/lib/AbstractTokenizer.js
690
+ var AbstractTokenizer;
691
+ var init_AbstractTokenizer = __esm({
692
+ "../../node_modules/.pnpm/strtok3@10.3.5/node_modules/strtok3/lib/AbstractTokenizer.js"() {
693
+ "use strict";
694
+ init_stream();
695
+ AbstractTokenizer = class {
696
+ /**
697
+ * Constructor
698
+ * @param options Tokenizer options
699
+ * @protected
700
+ */
701
+ constructor(options) {
702
+ this.numBuffer = new Uint8Array(8);
703
+ this.position = 0;
704
+ this.onClose = options?.onClose;
705
+ if (options?.abortSignal) {
706
+ options.abortSignal.addEventListener("abort", () => {
707
+ this.abort();
708
+ });
709
+ }
710
+ }
711
+ /**
712
+ * Read a token from the tokenizer-stream
713
+ * @param token - The token to read
714
+ * @param position - If provided, the desired position in the tokenizer-stream
715
+ * @returns Promise with token data
716
+ */
717
+ async readToken(token, position = this.position) {
718
+ const uint8Array = new Uint8Array(token.len);
719
+ const len = await this.readBuffer(uint8Array, { position });
720
+ if (len < token.len)
721
+ throw new EndOfStreamError();
722
+ return token.get(uint8Array, 0);
723
+ }
724
+ /**
725
+ * Peek a token from the tokenizer-stream.
726
+ * @param token - Token to peek from the tokenizer-stream.
727
+ * @param position - Offset where to begin reading within the file. If position is null, data will be read from the current file position.
728
+ * @returns Promise with token data
729
+ */
730
+ async peekToken(token, position = this.position) {
731
+ const uint8Array = new Uint8Array(token.len);
732
+ const len = await this.peekBuffer(uint8Array, { position });
733
+ if (len < token.len)
734
+ throw new EndOfStreamError();
735
+ return token.get(uint8Array, 0);
736
+ }
737
+ /**
738
+ * Read a numeric token from the stream
739
+ * @param token - Numeric token
740
+ * @returns Promise with number
741
+ */
742
+ async readNumber(token) {
743
+ const len = await this.readBuffer(this.numBuffer, { length: token.len });
744
+ if (len < token.len)
745
+ throw new EndOfStreamError();
746
+ return token.get(this.numBuffer, 0);
747
+ }
748
+ /**
749
+ * Read a numeric token from the stream
750
+ * @param token - Numeric token
751
+ * @returns Promise with number
752
+ */
753
+ async peekNumber(token) {
754
+ const len = await this.peekBuffer(this.numBuffer, { length: token.len });
755
+ if (len < token.len)
756
+ throw new EndOfStreamError();
757
+ return token.get(this.numBuffer, 0);
758
+ }
759
+ /**
760
+ * Ignore number of bytes, advances the pointer in under tokenizer-stream.
761
+ * @param length - Number of bytes to ignore. Must be ≥ 0.
762
+ * @return resolves the number of bytes ignored, equals length if this available, otherwise the number of bytes available
763
+ */
764
+ async ignore(length) {
765
+ if (length < 0) {
766
+ throw new RangeError("ignore length must be \u2265 0 bytes");
767
+ }
768
+ if (this.fileInfo.size !== void 0) {
769
+ const bytesLeft = this.fileInfo.size - this.position;
770
+ if (length > bytesLeft) {
771
+ this.position += bytesLeft;
772
+ return bytesLeft;
773
+ }
774
+ }
775
+ this.position += length;
776
+ return length;
777
+ }
778
+ async close() {
779
+ await this.abort();
780
+ await this.onClose?.();
781
+ }
782
+ normalizeOptions(uint8Array, options) {
783
+ if (!this.supportsRandomAccess() && options && options.position !== void 0 && options.position < this.position) {
784
+ throw new Error("`options.position` must be equal or greater than `tokenizer.position`");
785
+ }
786
+ return {
787
+ ...{
788
+ mayBeLess: false,
789
+ offset: 0,
790
+ length: uint8Array.length,
791
+ position: this.position
792
+ },
793
+ ...options
794
+ };
795
+ }
796
+ abort() {
797
+ return Promise.resolve();
798
+ }
799
+ };
800
+ }
801
+ });
802
+
803
+ // ../../node_modules/.pnpm/strtok3@10.3.5/node_modules/strtok3/lib/ReadStreamTokenizer.js
804
+ var maxBufferSize, ReadStreamTokenizer;
805
+ var init_ReadStreamTokenizer = __esm({
806
+ "../../node_modules/.pnpm/strtok3@10.3.5/node_modules/strtok3/lib/ReadStreamTokenizer.js"() {
807
+ "use strict";
808
+ init_AbstractTokenizer();
809
+ init_stream();
810
+ maxBufferSize = 256e3;
811
+ ReadStreamTokenizer = class extends AbstractTokenizer {
812
+ /**
813
+ * Constructor
814
+ * @param streamReader stream-reader to read from
815
+ * @param options Tokenizer options
816
+ */
817
+ constructor(streamReader, options) {
818
+ super(options);
819
+ this.streamReader = streamReader;
820
+ this.fileInfo = options?.fileInfo ?? {};
821
+ }
822
+ /**
823
+ * Read buffer from tokenizer
824
+ * @param uint8Array - Target Uint8Array to fill with data read from the tokenizer-stream
825
+ * @param options - Read behaviour options
826
+ * @returns Promise with number of bytes read
827
+ */
828
+ async readBuffer(uint8Array, options) {
829
+ const normOptions = this.normalizeOptions(uint8Array, options);
830
+ const skipBytes = normOptions.position - this.position;
831
+ if (skipBytes > 0) {
832
+ await this.ignore(skipBytes);
833
+ return this.readBuffer(uint8Array, options);
834
+ }
835
+ if (skipBytes < 0) {
836
+ throw new Error("`options.position` must be equal or greater than `tokenizer.position`");
837
+ }
838
+ if (normOptions.length === 0) {
839
+ return 0;
840
+ }
841
+ const bytesRead = await this.streamReader.read(uint8Array.subarray(0, normOptions.length), normOptions.mayBeLess);
842
+ this.position += bytesRead;
843
+ if ((!options || !options.mayBeLess) && bytesRead < normOptions.length) {
844
+ throw new EndOfStreamError();
845
+ }
846
+ return bytesRead;
847
+ }
848
+ /**
849
+ * Peek (read ahead) buffer from tokenizer
850
+ * @param uint8Array - Uint8Array (or Buffer) to write data to
851
+ * @param options - Read behaviour options
852
+ * @returns Promise with number of bytes peeked
853
+ */
854
+ async peekBuffer(uint8Array, options) {
855
+ const normOptions = this.normalizeOptions(uint8Array, options);
856
+ let bytesRead = 0;
857
+ if (normOptions.position) {
858
+ const skipBytes = normOptions.position - this.position;
859
+ if (skipBytes > 0) {
860
+ const skipBuffer = new Uint8Array(normOptions.length + skipBytes);
861
+ bytesRead = await this.peekBuffer(skipBuffer, { mayBeLess: normOptions.mayBeLess });
862
+ uint8Array.set(skipBuffer.subarray(skipBytes));
863
+ return bytesRead - skipBytes;
864
+ }
865
+ if (skipBytes < 0) {
866
+ throw new Error("Cannot peek from a negative offset in a stream");
867
+ }
868
+ }
869
+ if (normOptions.length > 0) {
870
+ try {
871
+ bytesRead = await this.streamReader.peek(uint8Array.subarray(0, normOptions.length), normOptions.mayBeLess);
872
+ } catch (err) {
873
+ if (options?.mayBeLess && err instanceof EndOfStreamError) {
874
+ return 0;
875
+ }
876
+ throw err;
877
+ }
878
+ if (!normOptions.mayBeLess && bytesRead < normOptions.length) {
879
+ throw new EndOfStreamError();
880
+ }
881
+ }
882
+ return bytesRead;
883
+ }
884
+ /**
885
+ * @param length Number of bytes to ignore. Must be ≥ 0.
886
+ */
887
+ async ignore(length) {
888
+ if (length < 0) {
889
+ throw new RangeError("ignore length must be \u2265 0 bytes");
890
+ }
891
+ const bufSize = Math.min(maxBufferSize, length);
892
+ const buf = new Uint8Array(bufSize);
893
+ let totBytesRead = 0;
894
+ while (totBytesRead < length) {
895
+ const remaining = length - totBytesRead;
896
+ const bytesRead = await this.readBuffer(buf, { length: Math.min(bufSize, remaining) });
897
+ if (bytesRead < 0) {
898
+ return bytesRead;
899
+ }
900
+ totBytesRead += bytesRead;
901
+ }
902
+ return totBytesRead;
903
+ }
904
+ abort() {
905
+ return this.streamReader.abort();
906
+ }
907
+ async close() {
908
+ return this.streamReader.close();
909
+ }
910
+ supportsRandomAccess() {
911
+ return false;
912
+ }
913
+ };
914
+ }
915
+ });
916
+
917
+ // ../../node_modules/.pnpm/strtok3@10.3.5/node_modules/strtok3/lib/BufferTokenizer.js
918
+ var BufferTokenizer;
919
+ var init_BufferTokenizer = __esm({
920
+ "../../node_modules/.pnpm/strtok3@10.3.5/node_modules/strtok3/lib/BufferTokenizer.js"() {
921
+ "use strict";
922
+ init_stream();
923
+ init_AbstractTokenizer();
924
+ BufferTokenizer = class extends AbstractTokenizer {
925
+ /**
926
+ * Construct BufferTokenizer
927
+ * @param uint8Array - Uint8Array to tokenize
928
+ * @param options Tokenizer options
929
+ */
930
+ constructor(uint8Array, options) {
931
+ super(options);
932
+ this.uint8Array = uint8Array;
933
+ this.fileInfo = { ...options?.fileInfo ?? {}, ...{ size: uint8Array.length } };
934
+ }
935
+ /**
936
+ * Read buffer from tokenizer
937
+ * @param uint8Array - Uint8Array to tokenize
938
+ * @param options - Read behaviour options
939
+ * @returns {Promise<number>}
940
+ */
941
+ async readBuffer(uint8Array, options) {
942
+ if (options?.position) {
943
+ this.position = options.position;
944
+ }
945
+ const bytesRead = await this.peekBuffer(uint8Array, options);
946
+ this.position += bytesRead;
947
+ return bytesRead;
948
+ }
949
+ /**
950
+ * Peek (read ahead) buffer from tokenizer
951
+ * @param uint8Array
952
+ * @param options - Read behaviour options
953
+ * @returns {Promise<number>}
954
+ */
955
+ async peekBuffer(uint8Array, options) {
956
+ const normOptions = this.normalizeOptions(uint8Array, options);
957
+ const bytes2read = Math.min(this.uint8Array.length - normOptions.position, normOptions.length);
958
+ if (!normOptions.mayBeLess && bytes2read < normOptions.length) {
959
+ throw new EndOfStreamError();
960
+ }
961
+ uint8Array.set(this.uint8Array.subarray(normOptions.position, normOptions.position + bytes2read));
962
+ return bytes2read;
963
+ }
964
+ close() {
965
+ return super.close();
966
+ }
967
+ supportsRandomAccess() {
968
+ return true;
969
+ }
970
+ setPosition(position) {
971
+ this.position = position;
972
+ }
973
+ };
974
+ }
975
+ });
976
+
977
+ // ../../node_modules/.pnpm/strtok3@10.3.5/node_modules/strtok3/lib/BlobTokenizer.js
978
+ var BlobTokenizer;
979
+ var init_BlobTokenizer = __esm({
980
+ "../../node_modules/.pnpm/strtok3@10.3.5/node_modules/strtok3/lib/BlobTokenizer.js"() {
981
+ "use strict";
982
+ init_stream();
983
+ init_AbstractTokenizer();
984
+ BlobTokenizer = class extends AbstractTokenizer {
985
+ /**
986
+ * Construct BufferTokenizer
987
+ * @param blob - Uint8Array to tokenize
988
+ * @param options Tokenizer options
989
+ */
990
+ constructor(blob, options) {
991
+ super(options);
992
+ this.blob = blob;
993
+ this.fileInfo = { ...options?.fileInfo ?? {}, ...{ size: blob.size, mimeType: blob.type } };
994
+ }
995
+ /**
996
+ * Read buffer from tokenizer
997
+ * @param uint8Array - Uint8Array to tokenize
998
+ * @param options - Read behaviour options
999
+ * @returns {Promise<number>}
1000
+ */
1001
+ async readBuffer(uint8Array, options) {
1002
+ if (options?.position) {
1003
+ this.position = options.position;
1004
+ }
1005
+ const bytesRead = await this.peekBuffer(uint8Array, options);
1006
+ this.position += bytesRead;
1007
+ return bytesRead;
1008
+ }
1009
+ /**
1010
+ * Peek (read ahead) buffer from tokenizer
1011
+ * @param buffer
1012
+ * @param options - Read behaviour options
1013
+ * @returns {Promise<number>}
1014
+ */
1015
+ async peekBuffer(buffer, options) {
1016
+ const normOptions = this.normalizeOptions(buffer, options);
1017
+ const bytes2read = Math.min(this.blob.size - normOptions.position, normOptions.length);
1018
+ if (!normOptions.mayBeLess && bytes2read < normOptions.length) {
1019
+ throw new EndOfStreamError();
1020
+ }
1021
+ const arrayBuffer = await this.blob.slice(normOptions.position, normOptions.position + bytes2read).arrayBuffer();
1022
+ buffer.set(new Uint8Array(arrayBuffer));
1023
+ return bytes2read;
1024
+ }
1025
+ close() {
1026
+ return super.close();
1027
+ }
1028
+ supportsRandomAccess() {
1029
+ return true;
1030
+ }
1031
+ setPosition(position) {
1032
+ this.position = position;
1033
+ }
1034
+ };
1035
+ }
1036
+ });
1037
+
1038
+ // ../../node_modules/.pnpm/strtok3@10.3.5/node_modules/strtok3/lib/core.js
1039
+ function fromWebStream(webStream, options) {
1040
+ const webStreamReader = makeWebStreamReader(webStream);
1041
+ const _options = options ?? {};
1042
+ const chainedClose = _options.onClose;
1043
+ _options.onClose = async () => {
1044
+ await webStreamReader.close();
1045
+ if (chainedClose) {
1046
+ return chainedClose();
1047
+ }
1048
+ };
1049
+ return new ReadStreamTokenizer(webStreamReader, _options);
1050
+ }
1051
+ function fromBuffer(uint8Array, options) {
1052
+ return new BufferTokenizer(uint8Array, options);
1053
+ }
1054
+ function fromBlob(blob, options) {
1055
+ return new BlobTokenizer(blob, options);
1056
+ }
1057
+ var init_core = __esm({
1058
+ "../../node_modules/.pnpm/strtok3@10.3.5/node_modules/strtok3/lib/core.js"() {
1059
+ "use strict";
1060
+ init_stream();
1061
+ init_ReadStreamTokenizer();
1062
+ init_BufferTokenizer();
1063
+ init_BlobTokenizer();
1064
+ init_stream();
1065
+ init_AbstractTokenizer();
1066
+ }
1067
+ });
1068
+
1069
+ // ../../node_modules/.pnpm/ms@2.1.3/node_modules/ms/index.js
1070
+ var require_ms = __commonJS({
1071
+ "../../node_modules/.pnpm/ms@2.1.3/node_modules/ms/index.js"(exports, module) {
1072
+ "use strict";
1073
+ var s = 1e3;
1074
+ var m = s * 60;
1075
+ var h = m * 60;
1076
+ var d = h * 24;
1077
+ var w = d * 7;
1078
+ var y = d * 365.25;
1079
+ module.exports = function(val, options) {
1080
+ options = options || {};
1081
+ var type = typeof val;
1082
+ if (type === "string" && val.length > 0) {
1083
+ return parse(val);
1084
+ } else if (type === "number" && isFinite(val)) {
1085
+ return options.long ? fmtLong(val) : fmtShort(val);
1086
+ }
1087
+ throw new Error(
1088
+ "val is not a non-empty string or a valid number. val=" + JSON.stringify(val)
1089
+ );
1090
+ };
1091
+ function parse(str) {
1092
+ str = String(str);
1093
+ if (str.length > 100) {
1094
+ return;
1095
+ }
1096
+ var match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(
1097
+ str
1098
+ );
1099
+ if (!match) {
1100
+ return;
1101
+ }
1102
+ var n = parseFloat(match[1]);
1103
+ var type = (match[2] || "ms").toLowerCase();
1104
+ switch (type) {
1105
+ case "years":
1106
+ case "year":
1107
+ case "yrs":
1108
+ case "yr":
1109
+ case "y":
1110
+ return n * y;
1111
+ case "weeks":
1112
+ case "week":
1113
+ case "w":
1114
+ return n * w;
1115
+ case "days":
1116
+ case "day":
1117
+ case "d":
1118
+ return n * d;
1119
+ case "hours":
1120
+ case "hour":
1121
+ case "hrs":
1122
+ case "hr":
1123
+ case "h":
1124
+ return n * h;
1125
+ case "minutes":
1126
+ case "minute":
1127
+ case "mins":
1128
+ case "min":
1129
+ case "m":
1130
+ return n * m;
1131
+ case "seconds":
1132
+ case "second":
1133
+ case "secs":
1134
+ case "sec":
1135
+ case "s":
1136
+ return n * s;
1137
+ case "milliseconds":
1138
+ case "millisecond":
1139
+ case "msecs":
1140
+ case "msec":
1141
+ case "ms":
1142
+ return n;
1143
+ default:
1144
+ return void 0;
1145
+ }
1146
+ }
1147
+ function fmtShort(ms) {
1148
+ var msAbs = Math.abs(ms);
1149
+ if (msAbs >= d) {
1150
+ return Math.round(ms / d) + "d";
1151
+ }
1152
+ if (msAbs >= h) {
1153
+ return Math.round(ms / h) + "h";
1154
+ }
1155
+ if (msAbs >= m) {
1156
+ return Math.round(ms / m) + "m";
1157
+ }
1158
+ if (msAbs >= s) {
1159
+ return Math.round(ms / s) + "s";
1160
+ }
1161
+ return ms + "ms";
1162
+ }
1163
+ function fmtLong(ms) {
1164
+ var msAbs = Math.abs(ms);
1165
+ if (msAbs >= d) {
1166
+ return plural(ms, msAbs, d, "day");
1167
+ }
1168
+ if (msAbs >= h) {
1169
+ return plural(ms, msAbs, h, "hour");
1170
+ }
1171
+ if (msAbs >= m) {
1172
+ return plural(ms, msAbs, m, "minute");
1173
+ }
1174
+ if (msAbs >= s) {
1175
+ return plural(ms, msAbs, s, "second");
1176
+ }
1177
+ return ms + " ms";
1178
+ }
1179
+ function plural(ms, msAbs, n, name) {
1180
+ var isPlural = msAbs >= n * 1.5;
1181
+ return Math.round(ms / n) + " " + name + (isPlural ? "s" : "");
1182
+ }
1183
+ }
1184
+ });
1185
+
1186
+ // ../../node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/common.js
1187
+ var require_common = __commonJS({
1188
+ "../../node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/common.js"(exports, module) {
1189
+ "use strict";
1190
+ function setup(env) {
1191
+ createDebug.debug = createDebug;
1192
+ createDebug.default = createDebug;
1193
+ createDebug.coerce = coerce;
1194
+ createDebug.disable = disable;
1195
+ createDebug.enable = enable;
1196
+ createDebug.enabled = enabled;
1197
+ createDebug.humanize = require_ms();
1198
+ createDebug.destroy = destroy;
1199
+ Object.keys(env).forEach((key) => {
1200
+ createDebug[key] = env[key];
1201
+ });
1202
+ createDebug.names = [];
1203
+ createDebug.skips = [];
1204
+ createDebug.formatters = {};
1205
+ function selectColor(namespace) {
1206
+ let hash = 0;
1207
+ for (let i = 0; i < namespace.length; i++) {
1208
+ hash = (hash << 5) - hash + namespace.charCodeAt(i);
1209
+ hash |= 0;
1210
+ }
1211
+ return createDebug.colors[Math.abs(hash) % createDebug.colors.length];
1212
+ }
1213
+ createDebug.selectColor = selectColor;
1214
+ function createDebug(namespace) {
1215
+ let prevTime;
1216
+ let enableOverride = null;
1217
+ let namespacesCache;
1218
+ let enabledCache;
1219
+ function debug2(...args) {
1220
+ if (!debug2.enabled) {
1221
+ return;
1222
+ }
1223
+ const self = debug2;
1224
+ const curr = Number(/* @__PURE__ */ new Date());
1225
+ const ms = curr - (prevTime || curr);
1226
+ self.diff = ms;
1227
+ self.prev = prevTime;
1228
+ self.curr = curr;
1229
+ prevTime = curr;
1230
+ args[0] = createDebug.coerce(args[0]);
1231
+ if (typeof args[0] !== "string") {
1232
+ args.unshift("%O");
1233
+ }
1234
+ let index = 0;
1235
+ args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => {
1236
+ if (match === "%%") {
1237
+ return "%";
1238
+ }
1239
+ index++;
1240
+ const formatter = createDebug.formatters[format];
1241
+ if (typeof formatter === "function") {
1242
+ const val = args[index];
1243
+ match = formatter.call(self, val);
1244
+ args.splice(index, 1);
1245
+ index--;
1246
+ }
1247
+ return match;
1248
+ });
1249
+ createDebug.formatArgs.call(self, args);
1250
+ const logFn = self.log || createDebug.log;
1251
+ logFn.apply(self, args);
1252
+ }
1253
+ debug2.namespace = namespace;
1254
+ debug2.useColors = createDebug.useColors();
1255
+ debug2.color = createDebug.selectColor(namespace);
1256
+ debug2.extend = extend;
1257
+ debug2.destroy = createDebug.destroy;
1258
+ Object.defineProperty(debug2, "enabled", {
1259
+ enumerable: true,
1260
+ configurable: false,
1261
+ get: () => {
1262
+ if (enableOverride !== null) {
1263
+ return enableOverride;
1264
+ }
1265
+ if (namespacesCache !== createDebug.namespaces) {
1266
+ namespacesCache = createDebug.namespaces;
1267
+ enabledCache = createDebug.enabled(namespace);
1268
+ }
1269
+ return enabledCache;
1270
+ },
1271
+ set: (v) => {
1272
+ enableOverride = v;
1273
+ }
1274
+ });
1275
+ if (typeof createDebug.init === "function") {
1276
+ createDebug.init(debug2);
1277
+ }
1278
+ return debug2;
1279
+ }
1280
+ function extend(namespace, delimiter) {
1281
+ const newDebug = createDebug(this.namespace + (typeof delimiter === "undefined" ? ":" : delimiter) + namespace);
1282
+ newDebug.log = this.log;
1283
+ return newDebug;
1284
+ }
1285
+ function enable(namespaces) {
1286
+ createDebug.save(namespaces);
1287
+ createDebug.namespaces = namespaces;
1288
+ createDebug.names = [];
1289
+ createDebug.skips = [];
1290
+ const split = (typeof namespaces === "string" ? namespaces : "").trim().replace(/\s+/g, ",").split(",").filter(Boolean);
1291
+ for (const ns of split) {
1292
+ if (ns[0] === "-") {
1293
+ createDebug.skips.push(ns.slice(1));
1294
+ } else {
1295
+ createDebug.names.push(ns);
1296
+ }
1297
+ }
1298
+ }
1299
+ function matchesTemplate(search, template) {
1300
+ let searchIndex = 0;
1301
+ let templateIndex = 0;
1302
+ let starIndex = -1;
1303
+ let matchIndex = 0;
1304
+ while (searchIndex < search.length) {
1305
+ if (templateIndex < template.length && (template[templateIndex] === search[searchIndex] || template[templateIndex] === "*")) {
1306
+ if (template[templateIndex] === "*") {
1307
+ starIndex = templateIndex;
1308
+ matchIndex = searchIndex;
1309
+ templateIndex++;
1310
+ } else {
1311
+ searchIndex++;
1312
+ templateIndex++;
1313
+ }
1314
+ } else if (starIndex !== -1) {
1315
+ templateIndex = starIndex + 1;
1316
+ matchIndex++;
1317
+ searchIndex = matchIndex;
1318
+ } else {
1319
+ return false;
1320
+ }
1321
+ }
1322
+ while (templateIndex < template.length && template[templateIndex] === "*") {
1323
+ templateIndex++;
1324
+ }
1325
+ return templateIndex === template.length;
1326
+ }
1327
+ function disable() {
1328
+ const namespaces = [
1329
+ ...createDebug.names,
1330
+ ...createDebug.skips.map((namespace) => "-" + namespace)
1331
+ ].join(",");
1332
+ createDebug.enable("");
1333
+ return namespaces;
1334
+ }
1335
+ function enabled(name) {
1336
+ for (const skip of createDebug.skips) {
1337
+ if (matchesTemplate(name, skip)) {
1338
+ return false;
1339
+ }
1340
+ }
1341
+ for (const ns of createDebug.names) {
1342
+ if (matchesTemplate(name, ns)) {
1343
+ return true;
1344
+ }
1345
+ }
1346
+ return false;
1347
+ }
1348
+ function coerce(val) {
1349
+ if (val instanceof Error) {
1350
+ return val.stack || val.message;
1351
+ }
1352
+ return val;
1353
+ }
1354
+ function destroy() {
1355
+ console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
1356
+ }
1357
+ createDebug.enable(createDebug.load());
1358
+ return createDebug;
1359
+ }
1360
+ module.exports = setup;
1361
+ }
1362
+ });
1363
+
1364
+ // ../../node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/browser.js
1365
+ var require_browser = __commonJS({
1366
+ "../../node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/browser.js"(exports, module) {
1367
+ "use strict";
1368
+ exports.formatArgs = formatArgs;
1369
+ exports.save = save;
1370
+ exports.load = load;
1371
+ exports.useColors = useColors;
1372
+ exports.storage = localstorage();
1373
+ exports.destroy = /* @__PURE__ */ (() => {
1374
+ let warned = false;
1375
+ return () => {
1376
+ if (!warned) {
1377
+ warned = true;
1378
+ console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
1379
+ }
1380
+ };
1381
+ })();
1382
+ exports.colors = [
1383
+ "#0000CC",
1384
+ "#0000FF",
1385
+ "#0033CC",
1386
+ "#0033FF",
1387
+ "#0066CC",
1388
+ "#0066FF",
1389
+ "#0099CC",
1390
+ "#0099FF",
1391
+ "#00CC00",
1392
+ "#00CC33",
1393
+ "#00CC66",
1394
+ "#00CC99",
1395
+ "#00CCCC",
1396
+ "#00CCFF",
1397
+ "#3300CC",
1398
+ "#3300FF",
1399
+ "#3333CC",
1400
+ "#3333FF",
1401
+ "#3366CC",
1402
+ "#3366FF",
1403
+ "#3399CC",
1404
+ "#3399FF",
1405
+ "#33CC00",
1406
+ "#33CC33",
1407
+ "#33CC66",
1408
+ "#33CC99",
1409
+ "#33CCCC",
1410
+ "#33CCFF",
1411
+ "#6600CC",
1412
+ "#6600FF",
1413
+ "#6633CC",
1414
+ "#6633FF",
1415
+ "#66CC00",
1416
+ "#66CC33",
1417
+ "#9900CC",
1418
+ "#9900FF",
1419
+ "#9933CC",
1420
+ "#9933FF",
1421
+ "#99CC00",
1422
+ "#99CC33",
1423
+ "#CC0000",
1424
+ "#CC0033",
1425
+ "#CC0066",
1426
+ "#CC0099",
1427
+ "#CC00CC",
1428
+ "#CC00FF",
1429
+ "#CC3300",
1430
+ "#CC3333",
1431
+ "#CC3366",
1432
+ "#CC3399",
1433
+ "#CC33CC",
1434
+ "#CC33FF",
1435
+ "#CC6600",
1436
+ "#CC6633",
1437
+ "#CC9900",
1438
+ "#CC9933",
1439
+ "#CCCC00",
1440
+ "#CCCC33",
1441
+ "#FF0000",
1442
+ "#FF0033",
1443
+ "#FF0066",
1444
+ "#FF0099",
1445
+ "#FF00CC",
1446
+ "#FF00FF",
1447
+ "#FF3300",
1448
+ "#FF3333",
1449
+ "#FF3366",
1450
+ "#FF3399",
1451
+ "#FF33CC",
1452
+ "#FF33FF",
1453
+ "#FF6600",
1454
+ "#FF6633",
1455
+ "#FF9900",
1456
+ "#FF9933",
1457
+ "#FFCC00",
1458
+ "#FFCC33"
1459
+ ];
1460
+ function useColors() {
1461
+ if (typeof window !== "undefined" && window.process && (window.process.type === "renderer" || window.process.__nwjs)) {
1462
+ return true;
1463
+ }
1464
+ if (typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
1465
+ return false;
1466
+ }
1467
+ let m;
1468
+ return typeof document !== "undefined" && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance || // Is firebug? http://stackoverflow.com/a/398120/376773
1469
+ typeof window !== "undefined" && window.console && (window.console.firebug || window.console.exception && window.console.table) || // Is firefox >= v31?
1470
+ // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
1471
+ typeof navigator !== "undefined" && navigator.userAgent && (m = navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)) && parseInt(m[1], 10) >= 31 || // Double check webkit in userAgent just in case we are in a worker
1472
+ typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/);
1473
+ }
1474
+ function formatArgs(args) {
1475
+ args[0] = (this.useColors ? "%c" : "") + this.namespace + (this.useColors ? " %c" : " ") + args[0] + (this.useColors ? "%c " : " ") + "+" + module.exports.humanize(this.diff);
1476
+ if (!this.useColors) {
1477
+ return;
1478
+ }
1479
+ const c = "color: " + this.color;
1480
+ args.splice(1, 0, c, "color: inherit");
1481
+ let index = 0;
1482
+ let lastC = 0;
1483
+ args[0].replace(/%[a-zA-Z%]/g, (match) => {
1484
+ if (match === "%%") {
1485
+ return;
1486
+ }
1487
+ index++;
1488
+ if (match === "%c") {
1489
+ lastC = index;
1490
+ }
1491
+ });
1492
+ args.splice(lastC, 0, c);
1493
+ }
1494
+ exports.log = console.debug || console.log || (() => {
1495
+ });
1496
+ function save(namespaces) {
1497
+ try {
1498
+ if (namespaces) {
1499
+ exports.storage.setItem("debug", namespaces);
1500
+ } else {
1501
+ exports.storage.removeItem("debug");
1502
+ }
1503
+ } catch (error) {
1504
+ }
1505
+ }
1506
+ function load() {
1507
+ let r;
1508
+ try {
1509
+ r = exports.storage.getItem("debug") || exports.storage.getItem("DEBUG");
1510
+ } catch (error) {
1511
+ }
1512
+ if (!r && typeof process !== "undefined" && "env" in process) {
1513
+ r = process.env.DEBUG;
1514
+ }
1515
+ return r;
1516
+ }
1517
+ function localstorage() {
1518
+ try {
1519
+ return localStorage;
1520
+ } catch (error) {
1521
+ }
1522
+ }
1523
+ module.exports = require_common()(exports);
1524
+ var { formatters } = module.exports;
1525
+ formatters.j = function(v) {
1526
+ try {
1527
+ return JSON.stringify(v);
1528
+ } catch (error) {
1529
+ return "[UnexpectedJSONParseError]: " + error.message;
1530
+ }
1531
+ };
1532
+ }
1533
+ });
1534
+
1535
+ // ../../node_modules/.pnpm/has-flag@4.0.0/node_modules/has-flag/index.js
1536
+ var require_has_flag = __commonJS({
1537
+ "../../node_modules/.pnpm/has-flag@4.0.0/node_modules/has-flag/index.js"(exports, module) {
1538
+ "use strict";
1539
+ module.exports = (flag, argv = process.argv) => {
1540
+ const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
1541
+ const position = argv.indexOf(prefix + flag);
1542
+ const terminatorPosition = argv.indexOf("--");
1543
+ return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
1544
+ };
1545
+ }
1546
+ });
1547
+
1548
+ // ../../node_modules/.pnpm/supports-color@8.1.1/node_modules/supports-color/index.js
1549
+ var require_supports_color = __commonJS({
1550
+ "../../node_modules/.pnpm/supports-color@8.1.1/node_modules/supports-color/index.js"(exports, module) {
1551
+ "use strict";
1552
+ var os = __require("os");
1553
+ var tty = __require("tty");
1554
+ var hasFlag = require_has_flag();
1555
+ var { env } = process;
1556
+ var flagForceColor;
1557
+ if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) {
1558
+ flagForceColor = 0;
1559
+ } else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) {
1560
+ flagForceColor = 1;
1561
+ }
1562
+ function envForceColor() {
1563
+ if ("FORCE_COLOR" in env) {
1564
+ if (env.FORCE_COLOR === "true") {
1565
+ return 1;
1566
+ }
1567
+ if (env.FORCE_COLOR === "false") {
1568
+ return 0;
1569
+ }
1570
+ return env.FORCE_COLOR.length === 0 ? 1 : Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3);
1571
+ }
1572
+ }
1573
+ function translateLevel(level) {
1574
+ if (level === 0) {
1575
+ return false;
1576
+ }
1577
+ return {
1578
+ level,
1579
+ hasBasic: true,
1580
+ has256: level >= 2,
1581
+ has16m: level >= 3
1582
+ };
1583
+ }
1584
+ function supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
1585
+ const noFlagForceColor = envForceColor();
1586
+ if (noFlagForceColor !== void 0) {
1587
+ flagForceColor = noFlagForceColor;
1588
+ }
1589
+ const forceColor = sniffFlags ? flagForceColor : noFlagForceColor;
1590
+ if (forceColor === 0) {
1591
+ return 0;
1592
+ }
1593
+ if (sniffFlags) {
1594
+ if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor")) {
1595
+ return 3;
1596
+ }
1597
+ if (hasFlag("color=256")) {
1598
+ return 2;
1599
+ }
1600
+ }
1601
+ if (haveStream && !streamIsTTY && forceColor === void 0) {
1602
+ return 0;
1603
+ }
1604
+ const min = forceColor || 0;
1605
+ if (env.TERM === "dumb") {
1606
+ return min;
1607
+ }
1608
+ if (process.platform === "win32") {
1609
+ const osRelease = os.release().split(".");
1610
+ if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
1611
+ return Number(osRelease[2]) >= 14931 ? 3 : 2;
1612
+ }
1613
+ return 1;
1614
+ }
1615
+ if ("CI" in env) {
1616
+ if (["TRAVIS", "CIRCLECI", "APPVEYOR", "GITLAB_CI", "GITHUB_ACTIONS", "BUILDKITE", "DRONE"].some((sign) => sign in env) || env.CI_NAME === "codeship") {
1617
+ return 1;
1618
+ }
1619
+ return min;
1620
+ }
1621
+ if ("TEAMCITY_VERSION" in env) {
1622
+ return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
1623
+ }
1624
+ if (env.COLORTERM === "truecolor") {
1625
+ return 3;
1626
+ }
1627
+ if ("TERM_PROGRAM" in env) {
1628
+ const version = Number.parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
1629
+ switch (env.TERM_PROGRAM) {
1630
+ case "iTerm.app":
1631
+ return version >= 3 ? 3 : 2;
1632
+ case "Apple_Terminal":
1633
+ return 2;
1634
+ }
1635
+ }
1636
+ if (/-256(color)?$/i.test(env.TERM)) {
1637
+ return 2;
1638
+ }
1639
+ if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
1640
+ return 1;
1641
+ }
1642
+ if ("COLORTERM" in env) {
1643
+ return 1;
1644
+ }
1645
+ return min;
1646
+ }
1647
+ function getSupportLevel(stream, options = {}) {
1648
+ const level = supportsColor(stream, {
1649
+ streamIsTTY: stream && stream.isTTY,
1650
+ ...options
1651
+ });
1652
+ return translateLevel(level);
1653
+ }
1654
+ module.exports = {
1655
+ supportsColor: getSupportLevel,
1656
+ stdout: getSupportLevel({ isTTY: tty.isatty(1) }),
1657
+ stderr: getSupportLevel({ isTTY: tty.isatty(2) })
1658
+ };
1659
+ }
1660
+ });
1661
+
1662
+ // ../../node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/node.js
1663
+ var require_node = __commonJS({
1664
+ "../../node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/node.js"(exports, module) {
1665
+ "use strict";
1666
+ var tty = __require("tty");
1667
+ var util = __require("util");
1668
+ exports.init = init;
1669
+ exports.log = log;
1670
+ exports.formatArgs = formatArgs;
1671
+ exports.save = save;
1672
+ exports.load = load;
1673
+ exports.useColors = useColors;
1674
+ exports.destroy = util.deprecate(
1675
+ () => {
1676
+ },
1677
+ "Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."
1678
+ );
1679
+ exports.colors = [6, 2, 3, 4, 5, 1];
1680
+ try {
1681
+ const supportsColor = require_supports_color();
1682
+ if (supportsColor && (supportsColor.stderr || supportsColor).level >= 2) {
1683
+ exports.colors = [
1684
+ 20,
1685
+ 21,
1686
+ 26,
1687
+ 27,
1688
+ 32,
1689
+ 33,
1690
+ 38,
1691
+ 39,
1692
+ 40,
1693
+ 41,
1694
+ 42,
1695
+ 43,
1696
+ 44,
1697
+ 45,
1698
+ 56,
1699
+ 57,
1700
+ 62,
1701
+ 63,
1702
+ 68,
1703
+ 69,
1704
+ 74,
1705
+ 75,
1706
+ 76,
1707
+ 77,
1708
+ 78,
1709
+ 79,
1710
+ 80,
1711
+ 81,
1712
+ 92,
1713
+ 93,
1714
+ 98,
1715
+ 99,
1716
+ 112,
1717
+ 113,
1718
+ 128,
1719
+ 129,
1720
+ 134,
1721
+ 135,
1722
+ 148,
1723
+ 149,
1724
+ 160,
1725
+ 161,
1726
+ 162,
1727
+ 163,
1728
+ 164,
1729
+ 165,
1730
+ 166,
1731
+ 167,
1732
+ 168,
1733
+ 169,
1734
+ 170,
1735
+ 171,
1736
+ 172,
1737
+ 173,
1738
+ 178,
1739
+ 179,
1740
+ 184,
1741
+ 185,
1742
+ 196,
1743
+ 197,
1744
+ 198,
1745
+ 199,
1746
+ 200,
1747
+ 201,
1748
+ 202,
1749
+ 203,
1750
+ 204,
1751
+ 205,
1752
+ 206,
1753
+ 207,
1754
+ 208,
1755
+ 209,
1756
+ 214,
1757
+ 215,
1758
+ 220,
1759
+ 221
1760
+ ];
1761
+ }
1762
+ } catch (error) {
1763
+ }
1764
+ exports.inspectOpts = Object.keys(process.env).filter((key) => {
1765
+ return /^debug_/i.test(key);
1766
+ }).reduce((obj, key) => {
1767
+ const prop = key.substring(6).toLowerCase().replace(/_([a-z])/g, (_, k) => {
1768
+ return k.toUpperCase();
1769
+ });
1770
+ let val = process.env[key];
1771
+ if (/^(yes|on|true|enabled)$/i.test(val)) {
1772
+ val = true;
1773
+ } else if (/^(no|off|false|disabled)$/i.test(val)) {
1774
+ val = false;
1775
+ } else if (val === "null") {
1776
+ val = null;
1777
+ } else {
1778
+ val = Number(val);
1779
+ }
1780
+ obj[prop] = val;
1781
+ return obj;
1782
+ }, {});
1783
+ function useColors() {
1784
+ return "colors" in exports.inspectOpts ? Boolean(exports.inspectOpts.colors) : tty.isatty(process.stderr.fd);
1785
+ }
1786
+ function formatArgs(args) {
1787
+ const { namespace: name, useColors: useColors2 } = this;
1788
+ if (useColors2) {
1789
+ const c = this.color;
1790
+ const colorCode = "\x1B[3" + (c < 8 ? c : "8;5;" + c);
1791
+ const prefix = ` ${colorCode};1m${name} \x1B[0m`;
1792
+ args[0] = prefix + args[0].split("\n").join("\n" + prefix);
1793
+ args.push(colorCode + "m+" + module.exports.humanize(this.diff) + "\x1B[0m");
1794
+ } else {
1795
+ args[0] = getDate() + name + " " + args[0];
1796
+ }
1797
+ }
1798
+ function getDate() {
1799
+ if (exports.inspectOpts.hideDate) {
1800
+ return "";
1801
+ }
1802
+ return (/* @__PURE__ */ new Date()).toISOString() + " ";
1803
+ }
1804
+ function log(...args) {
1805
+ return process.stderr.write(util.formatWithOptions(exports.inspectOpts, ...args) + "\n");
1806
+ }
1807
+ function save(namespaces) {
1808
+ if (namespaces) {
1809
+ process.env.DEBUG = namespaces;
1810
+ } else {
1811
+ delete process.env.DEBUG;
1812
+ }
1813
+ }
1814
+ function load() {
1815
+ return process.env.DEBUG;
1816
+ }
1817
+ function init(debug2) {
1818
+ debug2.inspectOpts = {};
1819
+ const keys = Object.keys(exports.inspectOpts);
1820
+ for (let i = 0; i < keys.length; i++) {
1821
+ debug2.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]];
1822
+ }
1823
+ }
1824
+ module.exports = require_common()(exports);
1825
+ var { formatters } = module.exports;
1826
+ formatters.o = function(v) {
1827
+ this.inspectOpts.colors = this.useColors;
1828
+ return util.inspect(v, this.inspectOpts).split("\n").map((str) => str.trim()).join(" ");
1829
+ };
1830
+ formatters.O = function(v) {
1831
+ this.inspectOpts.colors = this.useColors;
1832
+ return util.inspect(v, this.inspectOpts);
1833
+ };
1834
+ }
1835
+ });
1836
+
1837
+ // ../../node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/index.js
1838
+ var require_src = __commonJS({
1839
+ "../../node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/index.js"(exports, module) {
1840
+ "use strict";
1841
+ if (typeof process === "undefined" || process.type === "renderer" || process.browser === true || process.__nwjs) {
1842
+ module.exports = require_browser();
1843
+ } else {
1844
+ module.exports = require_node();
1845
+ }
1846
+ }
1847
+ });
1848
+
1849
+ // ../../node_modules/.pnpm/@tokenizer+inflate@0.4.1/node_modules/@tokenizer/inflate/lib/ZipToken.js
1850
+ var Signature, DataDescriptor, LocalFileHeaderToken, EndOfCentralDirectoryRecordToken, FileHeader;
1851
+ var init_ZipToken = __esm({
1852
+ "../../node_modules/.pnpm/@tokenizer+inflate@0.4.1/node_modules/@tokenizer/inflate/lib/ZipToken.js"() {
1853
+ "use strict";
1854
+ init_lib2();
1855
+ Signature = {
1856
+ LocalFileHeader: 67324752,
1857
+ DataDescriptor: 134695760,
1858
+ CentralFileHeader: 33639248,
1859
+ EndOfCentralDirectory: 101010256
1860
+ };
1861
+ DataDescriptor = {
1862
+ get(array) {
1863
+ return {
1864
+ signature: UINT32_LE.get(array, 0),
1865
+ compressedSize: UINT32_LE.get(array, 8),
1866
+ uncompressedSize: UINT32_LE.get(array, 12)
1867
+ };
1868
+ },
1869
+ len: 16
1870
+ };
1871
+ LocalFileHeaderToken = {
1872
+ get(array) {
1873
+ const flags = UINT16_LE.get(array, 6);
1874
+ return {
1875
+ signature: UINT32_LE.get(array, 0),
1876
+ minVersion: UINT16_LE.get(array, 4),
1877
+ dataDescriptor: !!(flags & 8),
1878
+ compressedMethod: UINT16_LE.get(array, 8),
1879
+ compressedSize: UINT32_LE.get(array, 18),
1880
+ uncompressedSize: UINT32_LE.get(array, 22),
1881
+ filenameLength: UINT16_LE.get(array, 26),
1882
+ extraFieldLength: UINT16_LE.get(array, 28),
1883
+ filename: null
1884
+ };
1885
+ },
1886
+ len: 30
1887
+ };
1888
+ EndOfCentralDirectoryRecordToken = {
1889
+ get(array) {
1890
+ return {
1891
+ signature: UINT32_LE.get(array, 0),
1892
+ nrOfThisDisk: UINT16_LE.get(array, 4),
1893
+ nrOfThisDiskWithTheStart: UINT16_LE.get(array, 6),
1894
+ nrOfEntriesOnThisDisk: UINT16_LE.get(array, 8),
1895
+ nrOfEntriesOfSize: UINT16_LE.get(array, 10),
1896
+ sizeOfCd: UINT32_LE.get(array, 12),
1897
+ offsetOfStartOfCd: UINT32_LE.get(array, 16),
1898
+ zipFileCommentLength: UINT16_LE.get(array, 20)
1899
+ };
1900
+ },
1901
+ len: 22
1902
+ };
1903
+ FileHeader = {
1904
+ get(array) {
1905
+ const flags = UINT16_LE.get(array, 8);
1906
+ return {
1907
+ signature: UINT32_LE.get(array, 0),
1908
+ minVersion: UINT16_LE.get(array, 6),
1909
+ dataDescriptor: !!(flags & 8),
1910
+ compressedMethod: UINT16_LE.get(array, 10),
1911
+ compressedSize: UINT32_LE.get(array, 20),
1912
+ uncompressedSize: UINT32_LE.get(array, 24),
1913
+ filenameLength: UINT16_LE.get(array, 28),
1914
+ extraFieldLength: UINT16_LE.get(array, 30),
1915
+ fileCommentLength: UINT16_LE.get(array, 32),
1916
+ relativeOffsetOfLocalHeader: UINT32_LE.get(array, 42),
1917
+ filename: null
1918
+ };
1919
+ },
1920
+ len: 46
1921
+ };
1922
+ }
1923
+ });
1924
+
1925
+ // ../../node_modules/.pnpm/@tokenizer+inflate@0.4.1/node_modules/@tokenizer/inflate/lib/ZipHandler.js
1926
+ function signatureToArray(signature) {
1927
+ const signatureBytes = new Uint8Array(UINT32_LE.len);
1928
+ UINT32_LE.put(signatureBytes, 0, signature);
1929
+ return signatureBytes;
1930
+ }
1931
+ function indexOf(buffer, portion) {
1932
+ const bufferLength = buffer.length;
1933
+ const portionLength = portion.length;
1934
+ if (portionLength > bufferLength)
1935
+ return -1;
1936
+ for (let i = 0; i <= bufferLength - portionLength; i++) {
1937
+ let found = true;
1938
+ for (let j = 0; j < portionLength; j++) {
1939
+ if (buffer[i + j] !== portion[j]) {
1940
+ found = false;
1941
+ break;
1942
+ }
1943
+ }
1944
+ if (found) {
1945
+ return i;
1946
+ }
1947
+ }
1948
+ return -1;
1949
+ }
1950
+ function mergeArrays(chunks) {
1951
+ const totalLength = chunks.reduce((acc, curr) => acc + curr.length, 0);
1952
+ const mergedArray = new Uint8Array(totalLength);
1953
+ let offset = 0;
1954
+ for (const chunk of chunks) {
1955
+ mergedArray.set(chunk, offset);
1956
+ offset += chunk.length;
1957
+ }
1958
+ return mergedArray;
1959
+ }
1960
+ var import_debug, debug, syncBufferSize, ddSignatureArray, eocdSignatureBytes, ZipHandler;
1961
+ var init_ZipHandler = __esm({
1962
+ "../../node_modules/.pnpm/@tokenizer+inflate@0.4.1/node_modules/@tokenizer/inflate/lib/ZipHandler.js"() {
1963
+ "use strict";
1964
+ init_lib2();
1965
+ import_debug = __toESM(require_src(), 1);
1966
+ init_ZipToken();
1967
+ debug = (0, import_debug.default)("tokenizer:inflate");
1968
+ syncBufferSize = 256 * 1024;
1969
+ ddSignatureArray = signatureToArray(Signature.DataDescriptor);
1970
+ eocdSignatureBytes = signatureToArray(Signature.EndOfCentralDirectory);
1971
+ ZipHandler = class _ZipHandler {
1972
+ constructor(tokenizer) {
1973
+ this.tokenizer = tokenizer;
1974
+ this.syncBuffer = new Uint8Array(syncBufferSize);
1975
+ }
1976
+ async isZip() {
1977
+ return await this.peekSignature() === Signature.LocalFileHeader;
1978
+ }
1979
+ peekSignature() {
1980
+ return this.tokenizer.peekToken(UINT32_LE);
1981
+ }
1982
+ async findEndOfCentralDirectoryLocator() {
1983
+ const randomReadTokenizer = this.tokenizer;
1984
+ const chunkLength = Math.min(16 * 1024, randomReadTokenizer.fileInfo.size);
1985
+ const buffer = this.syncBuffer.subarray(0, chunkLength);
1986
+ await this.tokenizer.readBuffer(buffer, { position: randomReadTokenizer.fileInfo.size - chunkLength });
1987
+ for (let i = buffer.length - 4; i >= 0; i--) {
1988
+ if (buffer[i] === eocdSignatureBytes[0] && buffer[i + 1] === eocdSignatureBytes[1] && buffer[i + 2] === eocdSignatureBytes[2] && buffer[i + 3] === eocdSignatureBytes[3]) {
1989
+ return randomReadTokenizer.fileInfo.size - chunkLength + i;
1990
+ }
1991
+ }
1992
+ return -1;
1993
+ }
1994
+ async readCentralDirectory() {
1995
+ if (!this.tokenizer.supportsRandomAccess()) {
1996
+ debug("Cannot reading central-directory without random-read support");
1997
+ return;
1998
+ }
1999
+ debug("Reading central-directory...");
2000
+ const pos = this.tokenizer.position;
2001
+ const offset = await this.findEndOfCentralDirectoryLocator();
2002
+ if (offset > 0) {
2003
+ debug("Central-directory 32-bit signature found");
2004
+ const eocdHeader = await this.tokenizer.readToken(EndOfCentralDirectoryRecordToken, offset);
2005
+ const files = [];
2006
+ this.tokenizer.setPosition(eocdHeader.offsetOfStartOfCd);
2007
+ for (let n = 0; n < eocdHeader.nrOfEntriesOfSize; ++n) {
2008
+ const entry = await this.tokenizer.readToken(FileHeader);
2009
+ if (entry.signature !== Signature.CentralFileHeader) {
2010
+ throw new Error("Expected Central-File-Header signature");
2011
+ }
2012
+ entry.filename = await this.tokenizer.readToken(new StringType(entry.filenameLength, "utf-8"));
2013
+ await this.tokenizer.ignore(entry.extraFieldLength);
2014
+ await this.tokenizer.ignore(entry.fileCommentLength);
2015
+ files.push(entry);
2016
+ debug(`Add central-directory file-entry: n=${n + 1}/${files.length}: filename=${files[n].filename}`);
2017
+ }
2018
+ this.tokenizer.setPosition(pos);
2019
+ return files;
2020
+ }
2021
+ this.tokenizer.setPosition(pos);
2022
+ }
2023
+ async unzip(fileCb) {
2024
+ const entries = await this.readCentralDirectory();
2025
+ if (entries) {
2026
+ return this.iterateOverCentralDirectory(entries, fileCb);
2027
+ }
2028
+ let stop = false;
2029
+ do {
2030
+ const zipHeader = await this.readLocalFileHeader();
2031
+ if (!zipHeader)
2032
+ break;
2033
+ const next = fileCb(zipHeader);
2034
+ stop = !!next.stop;
2035
+ let fileData;
2036
+ await this.tokenizer.ignore(zipHeader.extraFieldLength);
2037
+ if (zipHeader.dataDescriptor && zipHeader.compressedSize === 0) {
2038
+ const chunks = [];
2039
+ let len = syncBufferSize;
2040
+ debug("Compressed-file-size unknown, scanning for next data-descriptor-signature....");
2041
+ let nextHeaderIndex = -1;
2042
+ while (nextHeaderIndex < 0 && len === syncBufferSize) {
2043
+ len = await this.tokenizer.peekBuffer(this.syncBuffer, { mayBeLess: true });
2044
+ nextHeaderIndex = indexOf(this.syncBuffer.subarray(0, len), ddSignatureArray);
2045
+ const size = nextHeaderIndex >= 0 ? nextHeaderIndex : len;
2046
+ if (next.handler) {
2047
+ const data = new Uint8Array(size);
2048
+ await this.tokenizer.readBuffer(data);
2049
+ chunks.push(data);
2050
+ } else {
2051
+ await this.tokenizer.ignore(size);
2052
+ }
2053
+ }
2054
+ debug(`Found data-descriptor-signature at pos=${this.tokenizer.position}`);
2055
+ if (next.handler) {
2056
+ await this.inflate(zipHeader, mergeArrays(chunks), next.handler);
2057
+ }
2058
+ } else {
2059
+ if (next.handler) {
2060
+ debug(`Reading compressed-file-data: ${zipHeader.compressedSize} bytes`);
2061
+ fileData = new Uint8Array(zipHeader.compressedSize);
2062
+ await this.tokenizer.readBuffer(fileData);
2063
+ await this.inflate(zipHeader, fileData, next.handler);
2064
+ } else {
2065
+ debug(`Ignoring compressed-file-data: ${zipHeader.compressedSize} bytes`);
2066
+ await this.tokenizer.ignore(zipHeader.compressedSize);
2067
+ }
2068
+ }
2069
+ debug(`Reading data-descriptor at pos=${this.tokenizer.position}`);
2070
+ if (zipHeader.dataDescriptor) {
2071
+ const dataDescriptor = await this.tokenizer.readToken(DataDescriptor);
2072
+ if (dataDescriptor.signature !== 134695760) {
2073
+ throw new Error(`Expected data-descriptor-signature at position ${this.tokenizer.position - DataDescriptor.len}`);
2074
+ }
2075
+ }
2076
+ } while (!stop);
2077
+ }
2078
+ async iterateOverCentralDirectory(entries, fileCb) {
2079
+ for (const fileHeader of entries) {
2080
+ const next = fileCb(fileHeader);
2081
+ if (next.handler) {
2082
+ this.tokenizer.setPosition(fileHeader.relativeOffsetOfLocalHeader);
2083
+ const zipHeader = await this.readLocalFileHeader();
2084
+ if (zipHeader) {
2085
+ await this.tokenizer.ignore(zipHeader.extraFieldLength);
2086
+ const fileData = new Uint8Array(fileHeader.compressedSize);
2087
+ await this.tokenizer.readBuffer(fileData);
2088
+ await this.inflate(zipHeader, fileData, next.handler);
2089
+ }
2090
+ }
2091
+ if (next.stop)
2092
+ break;
2093
+ }
2094
+ }
2095
+ async inflate(zipHeader, fileData, cb) {
2096
+ if (zipHeader.compressedMethod === 0) {
2097
+ return cb(fileData);
2098
+ }
2099
+ if (zipHeader.compressedMethod !== 8) {
2100
+ throw new Error(`Unsupported ZIP compression method: ${zipHeader.compressedMethod}`);
2101
+ }
2102
+ debug(`Decompress filename=${zipHeader.filename}, compressed-size=${fileData.length}`);
2103
+ const uncompressedData = await _ZipHandler.decompressDeflateRaw(fileData);
2104
+ return cb(uncompressedData);
2105
+ }
2106
+ static async decompressDeflateRaw(data) {
2107
+ const input = new ReadableStream({
2108
+ start(controller) {
2109
+ controller.enqueue(data);
2110
+ controller.close();
2111
+ }
2112
+ });
2113
+ const ds = new DecompressionStream("deflate-raw");
2114
+ const output = input.pipeThrough(ds);
2115
+ try {
2116
+ const response = new Response(output);
2117
+ const buffer = await response.arrayBuffer();
2118
+ return new Uint8Array(buffer);
2119
+ } catch (err) {
2120
+ const message = err instanceof Error ? `Failed to deflate ZIP entry: ${err.message}` : "Unknown decompression error in ZIP entry";
2121
+ throw new TypeError(message);
2122
+ }
2123
+ }
2124
+ async readLocalFileHeader() {
2125
+ const signature = await this.tokenizer.peekToken(UINT32_LE);
2126
+ if (signature === Signature.LocalFileHeader) {
2127
+ const header = await this.tokenizer.readToken(LocalFileHeaderToken);
2128
+ header.filename = await this.tokenizer.readToken(new StringType(header.filenameLength, "utf-8"));
2129
+ return header;
2130
+ }
2131
+ if (signature === Signature.CentralFileHeader) {
2132
+ return false;
2133
+ }
2134
+ if (signature === 3759263696) {
2135
+ throw new Error("Encrypted ZIP");
2136
+ }
2137
+ throw new Error("Unexpected signature");
2138
+ }
2139
+ };
2140
+ }
2141
+ });
2142
+
2143
+ // ../../node_modules/.pnpm/@tokenizer+inflate@0.4.1/node_modules/@tokenizer/inflate/lib/GzipHandler.js
2144
+ var GzipHandler;
2145
+ var init_GzipHandler = __esm({
2146
+ "../../node_modules/.pnpm/@tokenizer+inflate@0.4.1/node_modules/@tokenizer/inflate/lib/GzipHandler.js"() {
2147
+ "use strict";
2148
+ GzipHandler = class {
2149
+ constructor(tokenizer) {
2150
+ this.tokenizer = tokenizer;
2151
+ }
2152
+ inflate() {
2153
+ const tokenizer = this.tokenizer;
2154
+ return new ReadableStream({
2155
+ async pull(controller) {
2156
+ const buffer = new Uint8Array(1024);
2157
+ const size = await tokenizer.readBuffer(buffer, { mayBeLess: true });
2158
+ if (size === 0) {
2159
+ controller.close();
2160
+ return;
2161
+ }
2162
+ controller.enqueue(buffer.subarray(0, size));
2163
+ }
2164
+ }).pipeThrough(new DecompressionStream("gzip"));
2165
+ }
2166
+ };
2167
+ }
2168
+ });
2169
+
2170
+ // ../../node_modules/.pnpm/@tokenizer+inflate@0.4.1/node_modules/@tokenizer/inflate/lib/index.js
2171
+ var init_lib3 = __esm({
2172
+ "../../node_modules/.pnpm/@tokenizer+inflate@0.4.1/node_modules/@tokenizer/inflate/lib/index.js"() {
2173
+ "use strict";
2174
+ init_ZipHandler();
2175
+ init_GzipHandler();
2176
+ }
2177
+ });
2178
+
2179
+ // ../../node_modules/.pnpm/uint8array-extras@1.5.0/node_modules/uint8array-extras/index.js
2180
+ function isType(value, typeConstructor, typeStringified) {
2181
+ if (!value) {
2182
+ return false;
2183
+ }
2184
+ if (value.constructor === typeConstructor) {
2185
+ return true;
2186
+ }
2187
+ return objectToString.call(value) === typeStringified;
2188
+ }
2189
+ function isUint8Array(value) {
2190
+ return isType(value, Uint8Array, uint8ArrayStringified);
2191
+ }
2192
+ function assertUint8Array(value) {
2193
+ if (!isUint8Array(value)) {
2194
+ throw new TypeError(`Expected \`Uint8Array\`, got \`${typeof value}\``);
2195
+ }
2196
+ }
2197
+ function concatUint8Arrays(arrays, totalLength) {
2198
+ if (arrays.length === 0) {
2199
+ return new Uint8Array(0);
2200
+ }
2201
+ totalLength ??= arrays.reduce((accumulator, currentValue) => accumulator + currentValue.length, 0);
2202
+ const returnValue = new Uint8Array(totalLength);
2203
+ let offset = 0;
2204
+ for (const array of arrays) {
2205
+ assertUint8Array(array);
2206
+ returnValue.set(array, offset);
2207
+ offset += array.length;
2208
+ }
2209
+ return returnValue;
2210
+ }
2211
+ function getUintBE(view) {
2212
+ const { byteLength } = view;
2213
+ if (byteLength === 6) {
2214
+ return view.getUint16(0) * 2 ** 32 + view.getUint32(2);
2215
+ }
2216
+ if (byteLength === 5) {
2217
+ return view.getUint8(0) * 2 ** 32 + view.getUint32(1);
2218
+ }
2219
+ if (byteLength === 4) {
2220
+ return view.getUint32(0);
2221
+ }
2222
+ if (byteLength === 3) {
2223
+ return view.getUint8(0) * 2 ** 16 + view.getUint16(1);
2224
+ }
2225
+ if (byteLength === 2) {
2226
+ return view.getUint16(0);
2227
+ }
2228
+ if (byteLength === 1) {
2229
+ return view.getUint8(0);
2230
+ }
2231
+ }
2232
+ var objectToString, uint8ArrayStringified, cachedDecoders, cachedEncoder, byteToHexLookupTable;
2233
+ var init_uint8array_extras = __esm({
2234
+ "../../node_modules/.pnpm/uint8array-extras@1.5.0/node_modules/uint8array-extras/index.js"() {
2235
+ "use strict";
2236
+ objectToString = Object.prototype.toString;
2237
+ uint8ArrayStringified = "[object Uint8Array]";
2238
+ cachedDecoders = {
2239
+ utf8: new globalThis.TextDecoder("utf8")
2240
+ };
2241
+ cachedEncoder = new globalThis.TextEncoder();
2242
+ byteToHexLookupTable = Array.from({ length: 256 }, (_, index) => index.toString(16).padStart(2, "0"));
2243
+ }
2244
+ });
2245
+
2246
+ // ../../node_modules/.pnpm/file-type@22.0.1/node_modules/file-type/source/tokens.js
2247
+ function stringToBytes(string, encoding) {
2248
+ if (encoding === "utf-16le") {
2249
+ const bytes = [];
2250
+ for (let index = 0; index < string.length; index++) {
2251
+ const code = string.charCodeAt(index);
2252
+ bytes.push(code & 255, code >> 8 & 255);
2253
+ }
2254
+ return bytes;
2255
+ }
2256
+ if (encoding === "utf-16be") {
2257
+ const bytes = [];
2258
+ for (let index = 0; index < string.length; index++) {
2259
+ const code = string.charCodeAt(index);
2260
+ bytes.push(code >> 8 & 255, code & 255);
2261
+ }
2262
+ return bytes;
2263
+ }
2264
+ return [...string].map((character) => character.charCodeAt(0));
2265
+ }
2266
+ function tarHeaderChecksumMatches(arrayBuffer, offset = 0) {
2267
+ const readSum = Number.parseInt(new StringType(6).get(arrayBuffer, 148).replace(new RegExp("\\0.*$", "v"), "").trim(), 8);
2268
+ if (Number.isNaN(readSum)) {
2269
+ return false;
2270
+ }
2271
+ let sum = 8 * 32;
2272
+ for (let index = offset; index < offset + 148; index++) {
2273
+ sum += arrayBuffer[index];
2274
+ }
2275
+ for (let index = offset + 156; index < offset + 512; index++) {
2276
+ sum += arrayBuffer[index];
2277
+ }
2278
+ return readSum === sum;
2279
+ }
2280
+ var uint32SyncSafeToken;
2281
+ var init_tokens = __esm({
2282
+ "../../node_modules/.pnpm/file-type@22.0.1/node_modules/file-type/source/tokens.js"() {
2283
+ "use strict";
2284
+ init_lib2();
2285
+ uint32SyncSafeToken = {
2286
+ get: (buffer, offset) => buffer[offset + 3] & 127 | (buffer[offset + 2] & 127) << 7 | (buffer[offset + 1] & 127) << 14 | (buffer[offset] & 127) << 21,
2287
+ len: 4
2288
+ };
2289
+ }
2290
+ });
2291
+
2292
+ // ../../node_modules/.pnpm/file-type@22.0.1/node_modules/file-type/source/supported.js
2293
+ var extensions, mimeTypes;
2294
+ var init_supported = __esm({
2295
+ "../../node_modules/.pnpm/file-type@22.0.1/node_modules/file-type/source/supported.js"() {
2296
+ "use strict";
2297
+ extensions = [
2298
+ "jpg",
2299
+ "png",
2300
+ "apng",
2301
+ "gif",
2302
+ "webp",
2303
+ "flif",
2304
+ "xcf",
2305
+ "cr2",
2306
+ "cr3",
2307
+ "orf",
2308
+ "arw",
2309
+ "dng",
2310
+ "nef",
2311
+ "rw2",
2312
+ "raf",
2313
+ "tif",
2314
+ "bmp",
2315
+ "icns",
2316
+ "jxr",
2317
+ "psd",
2318
+ "indd",
2319
+ "zip",
2320
+ "tar",
2321
+ "rar",
2322
+ "gz",
2323
+ "bz2",
2324
+ "7z",
2325
+ "dmg",
2326
+ "mp4",
2327
+ "mid",
2328
+ "mkv",
2329
+ "webm",
2330
+ "mov",
2331
+ "avi",
2332
+ "mpg",
2333
+ "mp2",
2334
+ "mp3",
2335
+ "m4a",
2336
+ "oga",
2337
+ "ogg",
2338
+ "ogv",
2339
+ "opus",
2340
+ "flac",
2341
+ "wav",
2342
+ "spx",
2343
+ "amr",
2344
+ "pdf",
2345
+ "epub",
2346
+ "elf",
2347
+ "macho",
2348
+ "exe",
2349
+ "swf",
2350
+ "rtf",
2351
+ "wasm",
2352
+ "woff",
2353
+ "woff2",
2354
+ "eot",
2355
+ "ttf",
2356
+ "otf",
2357
+ "ttc",
2358
+ "ico",
2359
+ "flv",
2360
+ "ps",
2361
+ "xz",
2362
+ "sqlite",
2363
+ "nes",
2364
+ "crx",
2365
+ "xpi",
2366
+ "cab",
2367
+ "deb",
2368
+ "ar",
2369
+ "rpm",
2370
+ "Z",
2371
+ "lz",
2372
+ "cfb",
2373
+ "mxf",
2374
+ "mts",
2375
+ "blend",
2376
+ "bpg",
2377
+ "docx",
2378
+ "pptx",
2379
+ "xlsx",
2380
+ "3gp",
2381
+ "3g2",
2382
+ "j2c",
2383
+ "jp2",
2384
+ "jpm",
2385
+ "jpx",
2386
+ "mj2",
2387
+ "aif",
2388
+ "qcp",
2389
+ "odt",
2390
+ "ods",
2391
+ "odp",
2392
+ "xml",
2393
+ "mobi",
2394
+ "heic",
2395
+ "cur",
2396
+ "ktx",
2397
+ "ape",
2398
+ "wv",
2399
+ "dcm",
2400
+ "ics",
2401
+ "glb",
2402
+ "pcap",
2403
+ "dsf",
2404
+ "lnk",
2405
+ "alias",
2406
+ "voc",
2407
+ "ac3",
2408
+ "m4v",
2409
+ "m4p",
2410
+ "m4b",
2411
+ "f4v",
2412
+ "f4p",
2413
+ "f4b",
2414
+ "f4a",
2415
+ "mie",
2416
+ "asf",
2417
+ "ogm",
2418
+ "ogx",
2419
+ "mpc",
2420
+ "arrow",
2421
+ "shp",
2422
+ "aac",
2423
+ "mp1",
2424
+ "it",
2425
+ "s3m",
2426
+ "xm",
2427
+ "skp",
2428
+ "avif",
2429
+ "eps",
2430
+ "lzh",
2431
+ "pgp",
2432
+ "asar",
2433
+ "stl",
2434
+ "chm",
2435
+ "3mf",
2436
+ "zst",
2437
+ "jxl",
2438
+ "vcf",
2439
+ "jls",
2440
+ "pst",
2441
+ "dwg",
2442
+ "parquet",
2443
+ "class",
2444
+ "arj",
2445
+ "cpio",
2446
+ "ace",
2447
+ "avro",
2448
+ "icc",
2449
+ "fbx",
2450
+ "vsdx",
2451
+ "vtt",
2452
+ "apk",
2453
+ "drc",
2454
+ "lz4",
2455
+ "potx",
2456
+ "xltx",
2457
+ "dotx",
2458
+ "xltm",
2459
+ "ott",
2460
+ "ots",
2461
+ "otp",
2462
+ "odg",
2463
+ "otg",
2464
+ "xlsm",
2465
+ "docm",
2466
+ "dotm",
2467
+ "potm",
2468
+ "pptm",
2469
+ "jar",
2470
+ "jmp",
2471
+ "rm",
2472
+ "sav",
2473
+ "ppsm",
2474
+ "ppsx",
2475
+ "tar.gz",
2476
+ "reg",
2477
+ "dat",
2478
+ "key",
2479
+ "numbers",
2480
+ "pages"
2481
+ ];
2482
+ mimeTypes = [
2483
+ "image/jpeg",
2484
+ "image/png",
2485
+ "image/gif",
2486
+ "image/webp",
2487
+ "image/flif",
2488
+ "image/x-xcf",
2489
+ "image/x-canon-cr2",
2490
+ "image/x-canon-cr3",
2491
+ "image/tiff",
2492
+ "image/bmp",
2493
+ "image/vnd.ms-photo",
2494
+ "image/vnd.adobe.photoshop",
2495
+ "application/x-indesign",
2496
+ "application/epub+zip",
2497
+ "application/x-xpinstall",
2498
+ "application/vnd.ms-powerpoint.slideshow.macroenabled.12",
2499
+ "application/vnd.oasis.opendocument.text",
2500
+ "application/vnd.oasis.opendocument.spreadsheet",
2501
+ "application/vnd.oasis.opendocument.presentation",
2502
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
2503
+ "application/vnd.openxmlformats-officedocument.presentationml.presentation",
2504
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
2505
+ "application/vnd.openxmlformats-officedocument.presentationml.slideshow",
2506
+ "application/zip",
2507
+ "application/x-tar",
2508
+ "application/x-rar-compressed",
2509
+ "application/gzip",
2510
+ "application/x-bzip2",
2511
+ "application/x-7z-compressed",
2512
+ "application/x-apple-diskimage",
2513
+ "application/vnd.apache.arrow.file",
2514
+ "video/mp4",
2515
+ "audio/midi",
2516
+ "video/matroska",
2517
+ "video/webm",
2518
+ "video/quicktime",
2519
+ "video/vnd.avi",
2520
+ "audio/wav",
2521
+ "audio/qcelp",
2522
+ "audio/x-ms-asf",
2523
+ "video/x-ms-asf",
2524
+ "application/vnd.ms-asf",
2525
+ "video/mpeg",
2526
+ "video/3gpp",
2527
+ "audio/mpeg",
2528
+ "audio/mp4",
2529
+ // RFC 4337
2530
+ "video/ogg",
2531
+ "audio/ogg",
2532
+ "audio/ogg; codecs=opus",
2533
+ "application/ogg",
2534
+ "audio/flac",
2535
+ "audio/ape",
2536
+ "audio/wavpack",
2537
+ "audio/amr",
2538
+ "application/pdf",
2539
+ "application/x-elf",
2540
+ "application/x-mach-binary",
2541
+ "application/x-msdownload",
2542
+ "application/x-shockwave-flash",
2543
+ "application/rtf",
2544
+ "application/wasm",
2545
+ "font/woff",
2546
+ "font/woff2",
2547
+ "application/vnd.ms-fontobject",
2548
+ "font/ttf",
2549
+ "font/otf",
2550
+ "font/collection",
2551
+ "image/x-icon",
2552
+ "video/x-flv",
2553
+ "application/postscript",
2554
+ "application/eps",
2555
+ "application/x-xz",
2556
+ "application/x-sqlite3",
2557
+ "application/x-nintendo-nes-rom",
2558
+ "application/x-google-chrome-extension",
2559
+ "application/vnd.ms-cab-compressed",
2560
+ "application/x-deb",
2561
+ "application/x-unix-archive",
2562
+ "application/x-rpm",
2563
+ "application/x-compress",
2564
+ "application/lzip",
2565
+ "application/x-cfb",
2566
+ "application/x-mie",
2567
+ "application/mxf",
2568
+ "video/mp2t",
2569
+ "application/x-blender",
2570
+ "image/bpg",
2571
+ "image/j2c",
2572
+ "image/jp2",
2573
+ "image/jpx",
2574
+ "image/jpm",
2575
+ "image/mj2",
2576
+ "audio/aiff",
2577
+ "application/xml",
2578
+ "application/x-mobipocket-ebook",
2579
+ "image/heif",
2580
+ "image/heif-sequence",
2581
+ "image/heic",
2582
+ "image/heic-sequence",
2583
+ "image/icns",
2584
+ "image/ktx",
2585
+ "application/dicom",
2586
+ "audio/x-musepack",
2587
+ "text/calendar",
2588
+ "text/vcard",
2589
+ "text/vtt",
2590
+ "model/gltf-binary",
2591
+ "application/vnd.tcpdump.pcap",
2592
+ "audio/x-dsf",
2593
+ // Non-standard
2594
+ "application/x-ms-shortcut",
2595
+ // Informal, used by freedesktop.org shared-mime-info
2596
+ "application/x-ft-apple.alias",
2597
+ "audio/x-voc",
2598
+ "audio/vnd.dolby.dd-raw",
2599
+ "audio/x-m4a",
2600
+ "image/apng",
2601
+ "image/x-olympus-orf",
2602
+ "image/x-sony-arw",
2603
+ "image/x-adobe-dng",
2604
+ "image/x-nikon-nef",
2605
+ "image/x-panasonic-rw2",
2606
+ "image/x-fujifilm-raf",
2607
+ "video/x-m4v",
2608
+ "video/3gpp2",
2609
+ "application/x-esri-shape",
2610
+ "audio/aac",
2611
+ "audio/x-it",
2612
+ "audio/x-s3m",
2613
+ "audio/x-xm",
2614
+ "video/MP1S",
2615
+ "video/MP2P",
2616
+ "application/vnd.sketchup.skp",
2617
+ "image/avif",
2618
+ "application/x-lzh-compressed",
2619
+ "application/pgp-encrypted",
2620
+ "application/x-asar",
2621
+ "model/stl",
2622
+ "application/vnd.ms-htmlhelp",
2623
+ "model/3mf",
2624
+ "image/jxl",
2625
+ "application/zstd",
2626
+ "image/jls",
2627
+ "application/vnd.ms-outlook",
2628
+ "image/vnd.dwg",
2629
+ "application/vnd.apache.parquet",
2630
+ "application/java-vm",
2631
+ "application/x-arj",
2632
+ "application/x-cpio",
2633
+ "application/x-ace-compressed",
2634
+ "application/avro",
2635
+ "application/vnd.iccprofile",
2636
+ "application/x-ft-fbx",
2637
+ "application/vnd.visio",
2638
+ "application/vnd.android.package-archive",
2639
+ "application/x-ft-draco",
2640
+ "application/x-lz4",
2641
+ // Informal, used by freedesktop.org shared-mime-info
2642
+ "application/vnd.openxmlformats-officedocument.presentationml.template",
2643
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.template",
2644
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.template",
2645
+ "application/vnd.ms-excel.template.macroenabled.12",
2646
+ "application/vnd.oasis.opendocument.text-template",
2647
+ "application/vnd.oasis.opendocument.spreadsheet-template",
2648
+ "application/vnd.oasis.opendocument.presentation-template",
2649
+ "application/vnd.oasis.opendocument.graphics",
2650
+ "application/vnd.oasis.opendocument.graphics-template",
2651
+ "application/vnd.ms-excel.sheet.macroenabled.12",
2652
+ "application/vnd.ms-word.document.macroenabled.12",
2653
+ "application/vnd.ms-word.template.macroenabled.12",
2654
+ "application/vnd.ms-powerpoint.template.macroenabled.12",
2655
+ "application/vnd.ms-powerpoint.presentation.macroenabled.12",
2656
+ "application/java-archive",
2657
+ "application/vnd.rn-realmedia",
2658
+ "application/x-spss-sav",
2659
+ "application/x-ms-regedit",
2660
+ "application/x-ft-windows-registry-hive",
2661
+ "application/x-jmp-data",
2662
+ "application/vnd.apple.keynote",
2663
+ "application/vnd.apple.numbers",
2664
+ "application/vnd.apple.pages"
2665
+ ];
2666
+ }
2667
+ });
2668
+
2669
+ // ../../node_modules/.pnpm/file-type@22.0.1/node_modules/file-type/source/parser.js
2670
+ function getSafeBound(value, maximum, reason) {
2671
+ if (!Number.isFinite(value) || value < 0 || value > maximum) {
2672
+ throw new ParserHardLimitError(`${reason} has invalid size ${value} (maximum ${maximum} bytes)`);
2673
+ }
2674
+ return value;
2675
+ }
2676
+ async function safeIgnore(tokenizer, length, { maximumLength = maximumUntrustedSkipSizeInBytes, reason = "skip" } = {}) {
2677
+ const safeLength = getSafeBound(length, maximumLength, reason);
2678
+ await tokenizer.ignore(safeLength);
2679
+ }
2680
+ async function safeReadBuffer(tokenizer, buffer, options, { maximumLength = buffer.length, reason = "read" } = {}) {
2681
+ const length = options?.length ?? buffer.length;
2682
+ const safeLength = getSafeBound(length, maximumLength, reason);
2683
+ return tokenizer.readBuffer(buffer, {
2684
+ ...options,
2685
+ length: safeLength
2686
+ });
2687
+ }
2688
+ function checkBytes(buffer, headers, options) {
2689
+ options = {
2690
+ offset: 0,
2691
+ ...options
2692
+ };
2693
+ for (const [index, header] of headers.entries()) {
2694
+ if (options.mask) {
2695
+ if (header !== (options.mask[index] & buffer[index + options.offset])) {
2696
+ return false;
2697
+ }
2698
+ } else if (header !== buffer[index + options.offset]) {
2699
+ return false;
2700
+ }
2701
+ }
2702
+ return true;
2703
+ }
2704
+ function hasUnknownFileSize(tokenizer) {
2705
+ const fileSize = tokenizer.fileInfo.size;
2706
+ return !Number.isFinite(fileSize) || fileSize === Number.MAX_SAFE_INTEGER;
2707
+ }
2708
+ function hasExceededUnknownSizeScanBudget(tokenizer, startOffset, maximumBytes) {
2709
+ return hasUnknownFileSize(tokenizer) && tokenizer.position - startOffset > maximumBytes;
2710
+ }
2711
+ var maximumUntrustedSkipSizeInBytes, ParserHardLimitError;
2712
+ var init_parser = __esm({
2713
+ "../../node_modules/.pnpm/file-type@22.0.1/node_modules/file-type/source/parser.js"() {
2714
+ "use strict";
2715
+ maximumUntrustedSkipSizeInBytes = 16 * 1024 * 1024;
2716
+ ParserHardLimitError = class extends Error {
2717
+ };
2718
+ }
2719
+ });
2720
+
2721
+ // ../../node_modules/.pnpm/file-type@22.0.1/node_modules/file-type/source/detectors/zip.js
2722
+ async function decompressDeflateRawWithLimit(data, { maximumLength = maximumZipEntrySizeInBytes } = {}) {
2723
+ const input = new ReadableStream({
2724
+ start(controller) {
2725
+ controller.enqueue(data);
2726
+ controller.close();
2727
+ }
2728
+ });
2729
+ const output = input.pipeThrough(new DecompressionStream("deflate-raw"));
2730
+ const reader = output.getReader();
2731
+ const chunks = [];
2732
+ let totalLength = 0;
2733
+ try {
2734
+ for (; ; ) {
2735
+ const { done, value } = await reader.read();
2736
+ if (done) {
2737
+ break;
2738
+ }
2739
+ totalLength += value.length;
2740
+ if (totalLength > maximumLength) {
2741
+ await reader.cancel();
2742
+ throw new Error(`ZIP entry decompressed data exceeds ${maximumLength} bytes`);
2743
+ }
2744
+ chunks.push(value);
2745
+ }
2746
+ } finally {
2747
+ reader.releaseLock();
2748
+ }
2749
+ const uncompressedData = new Uint8Array(totalLength);
2750
+ let offset = 0;
2751
+ for (const chunk of chunks) {
2752
+ uncompressedData.set(chunk, offset);
2753
+ offset += chunk.length;
2754
+ }
2755
+ return uncompressedData;
2756
+ }
2757
+ function mergeByteChunks(chunks, totalLength) {
2758
+ const merged = new Uint8Array(totalLength);
2759
+ let offset = 0;
2760
+ for (const chunk of chunks) {
2761
+ merged.set(chunk, offset);
2762
+ offset += chunk.length;
2763
+ }
2764
+ return merged;
2765
+ }
2766
+ function getMaximumZipBufferedReadLength(tokenizer) {
2767
+ const fileSize = tokenizer.fileInfo.size;
2768
+ const remainingBytes = Number.isFinite(fileSize) ? Math.max(0, fileSize - tokenizer.position) : Number.MAX_SAFE_INTEGER;
2769
+ return Math.min(remainingBytes, maximumZipBufferedReadSizeInBytes);
2770
+ }
2771
+ function isRecoverableZipError(error) {
2772
+ if (error instanceof EndOfStreamError) {
2773
+ return true;
2774
+ }
2775
+ if (error instanceof ParserHardLimitError) {
2776
+ return true;
2777
+ }
2778
+ if (!(error instanceof Error)) {
2779
+ return false;
2780
+ }
2781
+ if (recoverableZipErrorMessages.has(error.message)) {
2782
+ return true;
2783
+ }
2784
+ if (recoverableZipErrorCodes.has(error.code)) {
2785
+ return true;
2786
+ }
2787
+ for (const prefix of recoverableZipErrorMessagePrefixes) {
2788
+ if (error.message.startsWith(prefix)) {
2789
+ return true;
2790
+ }
2791
+ }
2792
+ return false;
2793
+ }
2794
+ function canReadZipEntryForDetection(zipHeader, maximumSize = maximumZipEntrySizeInBytes) {
2795
+ const sizes = [zipHeader.compressedSize, zipHeader.uncompressedSize];
2796
+ for (const size of sizes) {
2797
+ if (!Number.isFinite(size) || size < 0 || size > maximumSize) {
2798
+ return false;
2799
+ }
2800
+ }
2801
+ return true;
2802
+ }
2803
+ function createIWorkZipDetectionState() {
2804
+ return {
2805
+ hasDocumentEntry: false,
2806
+ hasMasterSlideEntry: false,
2807
+ hasTablesEntry: false,
2808
+ hasCalculationEngineEntry: false
2809
+ };
2810
+ }
2811
+ function updateIWorkZipDetectionStateFromFilename(iWorkState, filename) {
2812
+ if (filename === "Index/Document.iwa") {
2813
+ iWorkState.hasDocumentEntry = true;
2814
+ }
2815
+ if (filename.startsWith("Index/MasterSlide")) {
2816
+ iWorkState.hasMasterSlideEntry = true;
2817
+ }
2818
+ if (filename.startsWith("Index/Tables/")) {
2819
+ iWorkState.hasTablesEntry = true;
2820
+ }
2821
+ if (filename === "Index/CalculationEngine.iwa") {
2822
+ iWorkState.hasCalculationEngineEntry = true;
2823
+ }
2824
+ }
2825
+ function getIWorkFileTypeFromZipEntries(iWorkState) {
2826
+ if (!iWorkState.hasDocumentEntry) {
2827
+ return;
2828
+ }
2829
+ if (iWorkState.hasMasterSlideEntry) {
2830
+ return { ext: "key", mime: "application/vnd.apple.keynote" };
2831
+ }
2832
+ if (iWorkState.hasTablesEntry) {
2833
+ return { ext: "numbers", mime: "application/vnd.apple.numbers" };
2834
+ }
2835
+ return { ext: "pages", mime: "application/vnd.apple.pages" };
2836
+ }
2837
+ function getFileTypeFromMimeType(mimeType) {
2838
+ mimeType = mimeType.toLowerCase();
2839
+ switch (mimeType) {
2840
+ case "application/epub+zip":
2841
+ return { ext: "epub", mime: mimeType };
2842
+ case "application/vnd.oasis.opendocument.text":
2843
+ return { ext: "odt", mime: mimeType };
2844
+ case "application/vnd.oasis.opendocument.text-template":
2845
+ return { ext: "ott", mime: mimeType };
2846
+ case "application/vnd.oasis.opendocument.spreadsheet":
2847
+ return { ext: "ods", mime: mimeType };
2848
+ case "application/vnd.oasis.opendocument.spreadsheet-template":
2849
+ return { ext: "ots", mime: mimeType };
2850
+ case "application/vnd.oasis.opendocument.presentation":
2851
+ return { ext: "odp", mime: mimeType };
2852
+ case "application/vnd.oasis.opendocument.presentation-template":
2853
+ return { ext: "otp", mime: mimeType };
2854
+ case "application/vnd.oasis.opendocument.graphics":
2855
+ return { ext: "odg", mime: mimeType };
2856
+ case "application/vnd.oasis.opendocument.graphics-template":
2857
+ return { ext: "otg", mime: mimeType };
2858
+ case "application/vnd.openxmlformats-officedocument.presentationml.slideshow":
2859
+ return { ext: "ppsx", mime: mimeType };
2860
+ case "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":
2861
+ return { ext: "xlsx", mime: mimeType };
2862
+ case "application/vnd.ms-excel.sheet.macroenabled":
2863
+ return { ext: "xlsm", mime: "application/vnd.ms-excel.sheet.macroenabled.12" };
2864
+ case "application/vnd.openxmlformats-officedocument.spreadsheetml.template":
2865
+ return { ext: "xltx", mime: mimeType };
2866
+ case "application/vnd.ms-excel.template.macroenabled":
2867
+ return { ext: "xltm", mime: "application/vnd.ms-excel.template.macroenabled.12" };
2868
+ case "application/vnd.ms-powerpoint.slideshow.macroenabled":
2869
+ return { ext: "ppsm", mime: "application/vnd.ms-powerpoint.slideshow.macroenabled.12" };
2870
+ case "application/vnd.openxmlformats-officedocument.wordprocessingml.document":
2871
+ return { ext: "docx", mime: mimeType };
2872
+ case "application/vnd.ms-word.document.macroenabled":
2873
+ return { ext: "docm", mime: "application/vnd.ms-word.document.macroenabled.12" };
2874
+ case "application/vnd.openxmlformats-officedocument.wordprocessingml.template":
2875
+ return { ext: "dotx", mime: mimeType };
2876
+ case "application/vnd.ms-word.template.macroenabledtemplate":
2877
+ return { ext: "dotm", mime: "application/vnd.ms-word.template.macroenabled.12" };
2878
+ case "application/vnd.openxmlformats-officedocument.presentationml.template":
2879
+ return { ext: "potx", mime: mimeType };
2880
+ case "application/vnd.ms-powerpoint.template.macroenabled":
2881
+ return { ext: "potm", mime: "application/vnd.ms-powerpoint.template.macroenabled.12" };
2882
+ case "application/vnd.openxmlformats-officedocument.presentationml.presentation":
2883
+ return { ext: "pptx", mime: mimeType };
2884
+ case "application/vnd.ms-powerpoint.presentation.macroenabled":
2885
+ return { ext: "pptm", mime: "application/vnd.ms-powerpoint.presentation.macroenabled.12" };
2886
+ case "application/vnd.ms-visio.drawing":
2887
+ return { ext: "vsdx", mime: "application/vnd.visio" };
2888
+ case "application/vnd.ms-package.3dmanufacturing-3dmodel+xml":
2889
+ return { ext: "3mf", mime: "model/3mf" };
2890
+ default:
2891
+ }
2892
+ }
2893
+ function createOpenXmlZipDetectionState() {
2894
+ return {
2895
+ hasContentTypesEntry: false,
2896
+ hasParsedContentTypesEntry: false,
2897
+ isParsingContentTypes: false,
2898
+ hasUnparseableContentTypes: false,
2899
+ hasWordDirectory: false,
2900
+ hasPresentationDirectory: false,
2901
+ hasSpreadsheetDirectory: false,
2902
+ hasThreeDimensionalModelEntry: false
2903
+ };
2904
+ }
2905
+ function updateOpenXmlZipDetectionStateFromFilename(openXmlState, filename) {
2906
+ if (filename.startsWith("word/")) {
2907
+ openXmlState.hasWordDirectory = true;
2908
+ }
2909
+ if (filename.startsWith("ppt/")) {
2910
+ openXmlState.hasPresentationDirectory = true;
2911
+ }
2912
+ if (filename.startsWith("xl/")) {
2913
+ openXmlState.hasSpreadsheetDirectory = true;
2914
+ }
2915
+ if (filename.startsWith("3D/") && filename.endsWith(".model")) {
2916
+ openXmlState.hasThreeDimensionalModelEntry = true;
2917
+ }
2918
+ }
2919
+ function getOpenXmlFileTypeFromDirectoryNames(openXmlState) {
2920
+ if (openXmlState.hasWordDirectory) {
2921
+ return {
2922
+ ext: "docx",
2923
+ mime: "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
2924
+ };
2925
+ }
2926
+ if (openXmlState.hasPresentationDirectory) {
2927
+ return {
2928
+ ext: "pptx",
2929
+ mime: "application/vnd.openxmlformats-officedocument.presentationml.presentation"
2930
+ };
2931
+ }
2932
+ if (openXmlState.hasSpreadsheetDirectory) {
2933
+ return {
2934
+ ext: "xlsx",
2935
+ mime: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
2936
+ };
2937
+ }
2938
+ if (openXmlState.hasThreeDimensionalModelEntry) {
2939
+ return {
2940
+ ext: "3mf",
2941
+ mime: "model/3mf"
2942
+ };
2943
+ }
2944
+ }
2945
+ function getOpenXmlFileTypeFromZipEntries(openXmlState) {
2946
+ if (!openXmlState.hasContentTypesEntry || openXmlState.hasUnparseableContentTypes || openXmlState.isParsingContentTypes || openXmlState.hasParsedContentTypesEntry) {
2947
+ return;
2948
+ }
2949
+ return getOpenXmlFileTypeFromDirectoryNames(openXmlState);
2950
+ }
2951
+ function getOpenXmlMimeTypeFromContentTypesXml(xmlContent) {
2952
+ const endPosition = xmlContent.indexOf('.main+xml"');
2953
+ if (endPosition === -1) {
2954
+ const mimeType = "application/vnd.ms-package.3dmanufacturing-3dmodel+xml";
2955
+ if (xmlContent.includes(`ContentType="${mimeType}"`)) {
2956
+ return mimeType;
2957
+ }
2958
+ return;
2959
+ }
2960
+ const truncatedContent = xmlContent.slice(0, endPosition);
2961
+ const firstQuotePosition = truncatedContent.lastIndexOf('"');
2962
+ return truncatedContent.slice(firstQuotePosition + 1);
2963
+ }
2964
+ function findZipDataDescriptorOffset(buffer, bytesConsumed) {
2965
+ if (buffer.length < zipDataDescriptorLengthInBytes) {
2966
+ return -1;
2967
+ }
2968
+ const lastPossibleDescriptorOffset = buffer.length - zipDataDescriptorLengthInBytes;
2969
+ for (let index = 0; index <= lastPossibleDescriptorOffset; index++) {
2970
+ if (UINT32_LE.get(buffer, index) === zipDataDescriptorSignature && UINT32_LE.get(buffer, index + 8) === bytesConsumed + index) {
2971
+ return index;
2972
+ }
2973
+ }
2974
+ return -1;
2975
+ }
2976
+ async function readZipDataDescriptorEntryWithLimit(zipHandler, { shouldBuffer, maximumLength = maximumZipEntrySizeInBytes } = {}) {
2977
+ const { syncBuffer } = zipHandler;
2978
+ const { length: syncBufferLength } = syncBuffer;
2979
+ const chunks = [];
2980
+ let bytesConsumed = 0;
2981
+ for (; ; ) {
2982
+ const length = await zipHandler.tokenizer.peekBuffer(syncBuffer, { mayBeLess: true });
2983
+ const dataDescriptorOffset = findZipDataDescriptorOffset(syncBuffer.subarray(0, length), bytesConsumed);
2984
+ const retainedLength = dataDescriptorOffset >= 0 ? 0 : length === syncBufferLength ? Math.min(zipDataDescriptorOverlapLengthInBytes, length - 1) : 0;
2985
+ const chunkLength = dataDescriptorOffset >= 0 ? dataDescriptorOffset : length - retainedLength;
2986
+ if (chunkLength === 0) {
2987
+ break;
2988
+ }
2989
+ bytesConsumed += chunkLength;
2990
+ if (bytesConsumed > maximumLength) {
2991
+ throw new Error(`ZIP entry compressed data exceeds ${maximumLength} bytes`);
2992
+ }
2993
+ if (shouldBuffer) {
2994
+ const data = new Uint8Array(chunkLength);
2995
+ await zipHandler.tokenizer.readBuffer(data);
2996
+ chunks.push(data);
2997
+ } else {
2998
+ await zipHandler.tokenizer.ignore(chunkLength);
2999
+ }
3000
+ if (dataDescriptorOffset >= 0) {
3001
+ break;
3002
+ }
3003
+ }
3004
+ if (!hasUnknownFileSize(zipHandler.tokenizer)) {
3005
+ zipHandler.knownSizeDescriptorScannedBytes += bytesConsumed;
3006
+ }
3007
+ if (!shouldBuffer) {
3008
+ return;
3009
+ }
3010
+ return mergeByteChunks(chunks, bytesConsumed);
3011
+ }
3012
+ function getRemainingZipScanBudget(zipHandler, startOffset) {
3013
+ if (hasUnknownFileSize(zipHandler.tokenizer)) {
3014
+ return Math.max(0, maximumUntrustedSkipSizeInBytes - (zipHandler.tokenizer.position - startOffset));
3015
+ }
3016
+ return Math.max(0, maximumZipEntrySizeInBytes - zipHandler.knownSizeDescriptorScannedBytes);
3017
+ }
3018
+ async function readZipEntryData(zipHandler, zipHeader, { shouldBuffer, maximumDescriptorLength = maximumZipEntrySizeInBytes } = {}) {
3019
+ if (zipHeader.dataDescriptor && zipHeader.compressedSize === 0) {
3020
+ return readZipDataDescriptorEntryWithLimit(zipHandler, {
3021
+ shouldBuffer,
3022
+ maximumLength: maximumDescriptorLength
3023
+ });
3024
+ }
3025
+ if (!shouldBuffer) {
3026
+ await safeIgnore(zipHandler.tokenizer, zipHeader.compressedSize, {
3027
+ maximumLength: hasUnknownFileSize(zipHandler.tokenizer) ? maximumZipEntrySizeInBytes : zipHandler.tokenizer.fileInfo.size,
3028
+ reason: "ZIP entry compressed data"
3029
+ });
3030
+ return;
3031
+ }
3032
+ const maximumLength = getMaximumZipBufferedReadLength(zipHandler.tokenizer);
3033
+ if (!Number.isFinite(zipHeader.compressedSize) || zipHeader.compressedSize < 0 || zipHeader.compressedSize > maximumLength) {
3034
+ throw new Error(`ZIP entry compressed data exceeds ${maximumLength} bytes`);
3035
+ }
3036
+ const fileData = new Uint8Array(zipHeader.compressedSize);
3037
+ await zipHandler.tokenizer.readBuffer(fileData);
3038
+ return fileData;
3039
+ }
3040
+ async function detectZip(tokenizer) {
3041
+ let fileType;
3042
+ const openXmlState = createOpenXmlZipDetectionState();
3043
+ const iWorkState = createIWorkZipDetectionState();
3044
+ try {
3045
+ await new ZipHandler(tokenizer).unzip((zipHeader) => {
3046
+ updateOpenXmlZipDetectionStateFromFilename(openXmlState, zipHeader.filename);
3047
+ updateIWorkZipDetectionStateFromFilename(iWorkState, zipHeader.filename);
3048
+ if (iWorkState.hasDocumentEntry && (iWorkState.hasMasterSlideEntry || iWorkState.hasTablesEntry)) {
3049
+ fileType = getIWorkFileTypeFromZipEntries(iWorkState);
3050
+ return { stop: true };
3051
+ }
3052
+ const isOpenXmlContentTypesEntry = zipHeader.filename === "[Content_Types].xml";
3053
+ const openXmlFileTypeFromEntries = getOpenXmlFileTypeFromZipEntries(openXmlState);
3054
+ if (!isOpenXmlContentTypesEntry && openXmlFileTypeFromEntries) {
3055
+ fileType = openXmlFileTypeFromEntries;
3056
+ return {
3057
+ stop: true
3058
+ };
3059
+ }
3060
+ switch (zipHeader.filename) {
3061
+ case "META-INF/mozilla.rsa":
3062
+ fileType = {
3063
+ ext: "xpi",
3064
+ mime: "application/x-xpinstall"
3065
+ };
3066
+ return {
3067
+ stop: true
3068
+ };
3069
+ case "META-INF/MANIFEST.MF":
3070
+ fileType = {
3071
+ ext: "jar",
3072
+ mime: "application/java-archive"
3073
+ };
3074
+ return {
3075
+ stop: true
3076
+ };
3077
+ case "mimetype":
3078
+ if (!canReadZipEntryForDetection(zipHeader, maximumZipTextEntrySizeInBytes)) {
3079
+ return {};
3080
+ }
3081
+ return {
3082
+ async handler(fileData) {
3083
+ const mimeType = new TextDecoder("utf-8").decode(fileData).trim();
3084
+ fileType = getFileTypeFromMimeType(mimeType);
3085
+ },
3086
+ stop: true
3087
+ };
3088
+ case "[Content_Types].xml": {
3089
+ openXmlState.hasContentTypesEntry = true;
3090
+ if (!canReadZipEntryForDetection(zipHeader, maximumZipTextEntrySizeInBytes)) {
3091
+ openXmlState.hasUnparseableContentTypes = true;
3092
+ return {};
3093
+ }
3094
+ openXmlState.isParsingContentTypes = true;
3095
+ return {
3096
+ async handler(fileData) {
3097
+ const xmlContent = new TextDecoder("utf-8").decode(fileData);
3098
+ const mimeType = getOpenXmlMimeTypeFromContentTypesXml(xmlContent);
3099
+ if (mimeType) {
3100
+ fileType = getFileTypeFromMimeType(mimeType);
3101
+ }
3102
+ openXmlState.hasParsedContentTypesEntry = true;
3103
+ openXmlState.isParsingContentTypes = false;
3104
+ },
3105
+ stop: true
3106
+ };
3107
+ }
3108
+ default:
3109
+ if (new RegExp("classes\\d*\\.dex", "v").test(zipHeader.filename)) {
3110
+ fileType = {
3111
+ ext: "apk",
3112
+ mime: "application/vnd.android.package-archive"
3113
+ };
3114
+ return { stop: true };
3115
+ }
3116
+ return {};
3117
+ }
3118
+ });
3119
+ } catch (error) {
3120
+ if (!isRecoverableZipError(error)) {
3121
+ throw error;
3122
+ }
3123
+ if (openXmlState.isParsingContentTypes) {
3124
+ openXmlState.isParsingContentTypes = false;
3125
+ openXmlState.hasUnparseableContentTypes = true;
3126
+ }
3127
+ if (!fileType && error instanceof EndOfStreamError && !openXmlState.hasContentTypesEntry) {
3128
+ fileType = getOpenXmlFileTypeFromDirectoryNames(openXmlState);
3129
+ }
3130
+ }
3131
+ const iWorkFileType = hasUnknownFileSize(tokenizer) && iWorkState.hasDocumentEntry && !iWorkState.hasMasterSlideEntry && !iWorkState.hasTablesEntry && !iWorkState.hasCalculationEngineEntry ? void 0 : getIWorkFileTypeFromZipEntries(iWorkState);
3132
+ return fileType ?? getOpenXmlFileTypeFromZipEntries(openXmlState) ?? iWorkFileType ?? {
3133
+ ext: "zip",
3134
+ mime: "application/zip"
3135
+ };
3136
+ }
3137
+ var maximumZipEntrySizeInBytes, maximumZipEntryCount, maximumZipBufferedReadSizeInBytes, maximumZipTextEntrySizeInBytes, recoverableZipErrorMessages, recoverableZipErrorMessagePrefixes, recoverableZipErrorCodes, zipDataDescriptorSignature, zipDataDescriptorLengthInBytes, zipDataDescriptorOverlapLengthInBytes;
3138
+ var init_zip = __esm({
3139
+ "../../node_modules/.pnpm/file-type@22.0.1/node_modules/file-type/source/detectors/zip.js"() {
3140
+ "use strict";
3141
+ init_lib2();
3142
+ init_core();
3143
+ init_lib3();
3144
+ init_parser();
3145
+ maximumZipEntrySizeInBytes = 1024 * 1024;
3146
+ maximumZipEntryCount = 1024;
3147
+ maximumZipBufferedReadSizeInBytes = 2 ** 31 - 1;
3148
+ maximumZipTextEntrySizeInBytes = maximumZipEntrySizeInBytes;
3149
+ recoverableZipErrorMessages = /* @__PURE__ */ new Set([
3150
+ "Unexpected signature",
3151
+ "Encrypted ZIP",
3152
+ "Expected Central-File-Header signature"
3153
+ ]);
3154
+ recoverableZipErrorMessagePrefixes = [
3155
+ "ZIP entry count exceeds ",
3156
+ "Unsupported ZIP compression method:",
3157
+ "ZIP entry compressed data exceeds ",
3158
+ "ZIP entry decompressed data exceeds ",
3159
+ "Expected data-descriptor-signature at position "
3160
+ ];
3161
+ recoverableZipErrorCodes = /* @__PURE__ */ new Set([
3162
+ "Z_BUF_ERROR",
3163
+ "Z_DATA_ERROR",
3164
+ "ERR_INVALID_STATE"
3165
+ ]);
3166
+ zipDataDescriptorSignature = 134695760;
3167
+ zipDataDescriptorLengthInBytes = 16;
3168
+ zipDataDescriptorOverlapLengthInBytes = zipDataDescriptorLengthInBytes - 1;
3169
+ ZipHandler.prototype.inflate = async function(zipHeader, fileData, callback) {
3170
+ if (zipHeader.compressedMethod === 0) {
3171
+ return callback(fileData);
3172
+ }
3173
+ if (zipHeader.compressedMethod !== 8) {
3174
+ throw new Error(`Unsupported ZIP compression method: ${zipHeader.compressedMethod}`);
3175
+ }
3176
+ const uncompressedData = await decompressDeflateRawWithLimit(fileData, { maximumLength: maximumZipEntrySizeInBytes });
3177
+ return callback(uncompressedData);
3178
+ };
3179
+ ZipHandler.prototype.unzip = async function(fileCallback) {
3180
+ let stop = false;
3181
+ let zipEntryCount = 0;
3182
+ const zipScanStart = this.tokenizer.position;
3183
+ this.knownSizeDescriptorScannedBytes = 0;
3184
+ do {
3185
+ if (hasExceededUnknownSizeScanBudget(this.tokenizer, zipScanStart, maximumUntrustedSkipSizeInBytes)) {
3186
+ throw new ParserHardLimitError(`ZIP stream probing exceeds ${maximumUntrustedSkipSizeInBytes} bytes`);
3187
+ }
3188
+ const zipHeader = await this.readLocalFileHeader();
3189
+ if (!zipHeader) {
3190
+ break;
3191
+ }
3192
+ zipEntryCount++;
3193
+ if (zipEntryCount > maximumZipEntryCount) {
3194
+ throw new Error(`ZIP entry count exceeds ${maximumZipEntryCount}`);
3195
+ }
3196
+ const next = fileCallback(zipHeader);
3197
+ stop = Boolean(next.stop);
3198
+ await this.tokenizer.ignore(zipHeader.extraFieldLength);
3199
+ const fileData = await readZipEntryData(this, zipHeader, {
3200
+ shouldBuffer: Boolean(next.handler),
3201
+ maximumDescriptorLength: Math.min(maximumZipEntrySizeInBytes, getRemainingZipScanBudget(this, zipScanStart))
3202
+ });
3203
+ if (next.handler) {
3204
+ await this.inflate(zipHeader, fileData, next.handler);
3205
+ }
3206
+ if (zipHeader.dataDescriptor) {
3207
+ const dataDescriptor = new Uint8Array(zipDataDescriptorLengthInBytes);
3208
+ await this.tokenizer.readBuffer(dataDescriptor);
3209
+ if (UINT32_LE.get(dataDescriptor, 0) !== zipDataDescriptorSignature) {
3210
+ throw new Error(`Expected data-descriptor-signature at position ${this.tokenizer.position - dataDescriptor.length}`);
3211
+ }
3212
+ }
3213
+ if (hasExceededUnknownSizeScanBudget(this.tokenizer, zipScanStart, maximumUntrustedSkipSizeInBytes)) {
3214
+ throw new ParserHardLimitError(`ZIP stream probing exceeds ${maximumUntrustedSkipSizeInBytes} bytes`);
3215
+ }
3216
+ } while (!stop);
3217
+ };
3218
+ }
3219
+ });
3220
+
3221
+ // ../../node_modules/.pnpm/file-type@22.0.1/node_modules/file-type/source/detectors/ebml.js
3222
+ async function detectEbml(tokenizer) {
3223
+ async function readField() {
3224
+ const msb = await tokenizer.peekNumber(UINT8);
3225
+ let mask = 128;
3226
+ let ic = 0;
3227
+ while ((msb & mask) === 0 && mask !== 0) {
3228
+ ++ic;
3229
+ mask >>= 1;
3230
+ }
3231
+ const id = new Uint8Array(ic + 1);
3232
+ await safeReadBuffer(tokenizer, id, void 0, {
3233
+ maximumLength: id.length,
3234
+ reason: "EBML field"
3235
+ });
3236
+ return id;
3237
+ }
3238
+ async function readElement() {
3239
+ const idField = await readField();
3240
+ const lengthField = await readField();
3241
+ lengthField[0] ^= 128 >> lengthField.length - 1;
3242
+ const nrLength = Math.min(6, lengthField.length);
3243
+ const idView = new DataView(idField.buffer);
3244
+ const lengthView = new DataView(lengthField.buffer, lengthField.length - nrLength, nrLength);
3245
+ return {
3246
+ id: getUintBE(idView),
3247
+ len: getUintBE(lengthView)
3248
+ };
3249
+ }
3250
+ async function readChildren(children) {
3251
+ let ebmlElementCount = 0;
3252
+ while (children > 0) {
3253
+ ebmlElementCount++;
3254
+ if (ebmlElementCount > maximumEbmlElementCount) {
3255
+ return;
3256
+ }
3257
+ if (hasExceededUnknownSizeScanBudget(tokenizer, ebmlScanStart, maximumUntrustedSkipSizeInBytes)) {
3258
+ return;
3259
+ }
3260
+ const previousPosition = tokenizer.position;
3261
+ const element = await readElement();
3262
+ if (element.id === 17026) {
3263
+ if (element.len > maximumEbmlDocumentTypeSizeInBytes) {
3264
+ return;
3265
+ }
3266
+ const documentTypeLength = getSafeBound(element.len, maximumEbmlDocumentTypeSizeInBytes, "EBML DocType");
3267
+ const rawValue = await tokenizer.readToken(new StringType(documentTypeLength));
3268
+ return rawValue.replaceAll(new RegExp("\\0.*$", "gv"), "");
3269
+ }
3270
+ if (hasUnknownFileSize(tokenizer) && (!Number.isFinite(element.len) || element.len < 0 || element.len > maximumEbmlElementPayloadSizeInBytes)) {
3271
+ return;
3272
+ }
3273
+ await safeIgnore(tokenizer, element.len, {
3274
+ maximumLength: hasUnknownFileSize(tokenizer) ? maximumEbmlElementPayloadSizeInBytes : tokenizer.fileInfo.size,
3275
+ reason: "EBML payload"
3276
+ });
3277
+ --children;
3278
+ if (tokenizer.position <= previousPosition) {
3279
+ return;
3280
+ }
3281
+ }
3282
+ }
3283
+ const rootElement = await readElement();
3284
+ const ebmlScanStart = tokenizer.position;
3285
+ const documentType = await readChildren(rootElement.len);
3286
+ switch (documentType) {
3287
+ case "webm":
3288
+ return {
3289
+ ext: "webm",
3290
+ mime: "video/webm"
3291
+ };
3292
+ case "matroska":
3293
+ return {
3294
+ ext: "mkv",
3295
+ mime: "video/matroska"
3296
+ };
3297
+ default:
3298
+ }
3299
+ }
3300
+ var maximumEbmlDocumentTypeSizeInBytes, maximumEbmlElementPayloadSizeInBytes, maximumEbmlElementCount;
3301
+ var init_ebml = __esm({
3302
+ "../../node_modules/.pnpm/file-type@22.0.1/node_modules/file-type/source/detectors/ebml.js"() {
3303
+ "use strict";
3304
+ init_lib2();
3305
+ init_uint8array_extras();
3306
+ init_parser();
3307
+ maximumEbmlDocumentTypeSizeInBytes = 64;
3308
+ maximumEbmlElementPayloadSizeInBytes = 1024 * 1024;
3309
+ maximumEbmlElementCount = 256;
3310
+ }
3311
+ });
3312
+
3313
+ // ../../node_modules/.pnpm/file-type@22.0.1/node_modules/file-type/source/detectors/png.js
3314
+ function isPngAncillaryChunk(type) {
3315
+ return (type.codePointAt(0) & 32) !== 0;
3316
+ }
3317
+ async function detectPng(tokenizer) {
3318
+ const pngFileType = {
3319
+ ext: "png",
3320
+ mime: "image/png"
3321
+ };
3322
+ const apngFileType = {
3323
+ ext: "apng",
3324
+ mime: "image/apng"
3325
+ };
3326
+ await tokenizer.ignore(8);
3327
+ async function readChunkHeader() {
3328
+ return {
3329
+ length: await tokenizer.readToken(INT32_BE),
3330
+ type: await tokenizer.readToken(new StringType(4, "latin1"))
3331
+ };
3332
+ }
3333
+ const isUnknownPngStream = hasUnknownFileSize(tokenizer);
3334
+ const pngScanStart = tokenizer.position;
3335
+ let pngChunkCount = 0;
3336
+ let hasSeenImageHeader = false;
3337
+ do {
3338
+ pngChunkCount++;
3339
+ if (pngChunkCount > maximumPngChunkCount) {
3340
+ break;
3341
+ }
3342
+ if (hasExceededUnknownSizeScanBudget(tokenizer, pngScanStart, maximumPngStreamScanBudgetInBytes)) {
3343
+ break;
3344
+ }
3345
+ const previousPosition = tokenizer.position;
3346
+ const chunk = await readChunkHeader();
3347
+ if (chunk.length < 0) {
3348
+ return;
3349
+ }
3350
+ if (chunk.type === "IHDR") {
3351
+ if (chunk.length !== 13) {
3352
+ return;
3353
+ }
3354
+ hasSeenImageHeader = true;
3355
+ }
3356
+ switch (chunk.type) {
3357
+ case "IDAT":
3358
+ return pngFileType;
3359
+ case "acTL":
3360
+ return apngFileType;
3361
+ default:
3362
+ if (!hasSeenImageHeader && chunk.type !== "CgBI") {
3363
+ return;
3364
+ }
3365
+ if (isUnknownPngStream && chunk.length > maximumPngChunkSizeInBytes) {
3366
+ return hasSeenImageHeader && isPngAncillaryChunk(chunk.type) ? pngFileType : void 0;
3367
+ }
3368
+ try {
3369
+ await safeIgnore(tokenizer, chunk.length + 4, {
3370
+ maximumLength: isUnknownPngStream ? maximumPngChunkSizeInBytes + 4 : tokenizer.fileInfo.size,
3371
+ reason: "PNG chunk payload"
3372
+ });
3373
+ } catch (error) {
3374
+ if (!isUnknownPngStream && (error instanceof ParserHardLimitError || error instanceof EndOfStreamError)) {
3375
+ return pngFileType;
3376
+ }
3377
+ throw error;
3378
+ }
3379
+ }
3380
+ if (tokenizer.position <= previousPosition) {
3381
+ break;
3382
+ }
3383
+ } while (tokenizer.position + 8 < tokenizer.fileInfo.size);
3384
+ return pngFileType;
3385
+ }
3386
+ var maximumPngChunkCount, maximumPngStreamScanBudgetInBytes, maximumPngChunkSizeInBytes;
3387
+ var init_png = __esm({
3388
+ "../../node_modules/.pnpm/file-type@22.0.1/node_modules/file-type/source/detectors/png.js"() {
3389
+ "use strict";
3390
+ init_lib2();
3391
+ init_core();
3392
+ init_parser();
3393
+ maximumPngChunkCount = 512;
3394
+ maximumPngStreamScanBudgetInBytes = 16 * 1024 * 1024;
3395
+ maximumPngChunkSizeInBytes = 1024 * 1024;
3396
+ }
3397
+ });
3398
+
3399
+ // ../../node_modules/.pnpm/file-type@22.0.1/node_modules/file-type/source/detectors/asf.js
3400
+ async function detectAsf(tokenizer) {
3401
+ let isMalformedAsf = false;
3402
+ try {
3403
+ async function readHeader() {
3404
+ const guid = new Uint8Array(16);
3405
+ await safeReadBuffer(tokenizer, guid, void 0, {
3406
+ maximumLength: guid.length,
3407
+ reason: "ASF header GUID"
3408
+ });
3409
+ return {
3410
+ id: guid,
3411
+ size: Number(await tokenizer.readToken(UINT64_LE))
3412
+ };
3413
+ }
3414
+ await safeIgnore(tokenizer, 30, {
3415
+ maximumLength: 30,
3416
+ reason: "ASF header prelude"
3417
+ });
3418
+ const isUnknownFileSize = hasUnknownFileSize(tokenizer);
3419
+ const asfHeaderScanStart = tokenizer.position;
3420
+ let asfHeaderObjectCount = 0;
3421
+ while (tokenizer.position + 24 < tokenizer.fileInfo.size) {
3422
+ asfHeaderObjectCount++;
3423
+ if (asfHeaderObjectCount > maximumAsfHeaderObjectCount) {
3424
+ break;
3425
+ }
3426
+ if (hasExceededUnknownSizeScanBudget(tokenizer, asfHeaderScanStart, maximumUntrustedSkipSizeInBytes)) {
3427
+ break;
3428
+ }
3429
+ const previousPosition = tokenizer.position;
3430
+ const header = await readHeader();
3431
+ let payload = header.size - 24;
3432
+ if (!Number.isFinite(payload) || payload < 0) {
3433
+ isMalformedAsf = true;
3434
+ break;
3435
+ }
3436
+ if (checkBytes(header.id, [145, 7, 220, 183, 183, 169, 207, 17, 142, 230, 0, 192, 12, 32, 83, 101])) {
3437
+ const typeId = new Uint8Array(16);
3438
+ payload -= await safeReadBuffer(tokenizer, typeId, void 0, {
3439
+ maximumLength: typeId.length,
3440
+ reason: "ASF stream type GUID"
3441
+ });
3442
+ if (checkBytes(typeId, [64, 158, 105, 248, 77, 91, 207, 17, 168, 253, 0, 128, 95, 92, 68, 43])) {
3443
+ return {
3444
+ ext: "asf",
3445
+ mime: "audio/x-ms-asf"
3446
+ };
3447
+ }
3448
+ if (checkBytes(typeId, [192, 239, 25, 188, 77, 91, 207, 17, 168, 253, 0, 128, 95, 92, 68, 43])) {
3449
+ return {
3450
+ ext: "asf",
3451
+ mime: "video/x-ms-asf"
3452
+ };
3453
+ }
3454
+ break;
3455
+ }
3456
+ if (isUnknownFileSize && payload > maximumAsfHeaderPayloadSizeInBytes) {
3457
+ isMalformedAsf = true;
3458
+ break;
3459
+ }
3460
+ await safeIgnore(tokenizer, payload, {
3461
+ maximumLength: isUnknownFileSize ? maximumAsfHeaderPayloadSizeInBytes : tokenizer.fileInfo.size,
3462
+ reason: "ASF header payload"
3463
+ });
3464
+ if (tokenizer.position <= previousPosition) {
3465
+ isMalformedAsf = true;
3466
+ break;
3467
+ }
3468
+ }
3469
+ } catch (error) {
3470
+ if (error instanceof EndOfStreamError || error instanceof ParserHardLimitError) {
3471
+ if (hasUnknownFileSize(tokenizer)) {
3472
+ isMalformedAsf = true;
3473
+ }
3474
+ } else {
3475
+ throw error;
3476
+ }
3477
+ }
3478
+ if (isMalformedAsf) {
3479
+ return;
3480
+ }
3481
+ return {
3482
+ ext: "asf",
3483
+ mime: "application/vnd.ms-asf"
3484
+ };
3485
+ }
3486
+ var maximumAsfHeaderObjectCount, maximumAsfHeaderPayloadSizeInBytes;
3487
+ var init_asf = __esm({
3488
+ "../../node_modules/.pnpm/file-type@22.0.1/node_modules/file-type/source/detectors/asf.js"() {
3489
+ "use strict";
3490
+ init_lib2();
3491
+ init_core();
3492
+ init_parser();
3493
+ maximumAsfHeaderObjectCount = 512;
3494
+ maximumAsfHeaderPayloadSizeInBytes = 1024 * 1024;
3495
+ }
3496
+ });
3497
+
3498
+ // ../../node_modules/.pnpm/file-type@22.0.1/node_modules/file-type/source/index.js
3499
+ function normalizeSampleSize(sampleSize) {
3500
+ if (!Number.isFinite(sampleSize)) {
3501
+ return reasonableDetectionSizeInBytes;
3502
+ }
3503
+ return Math.max(1, Math.trunc(sampleSize));
3504
+ }
3505
+ function normalizeMpegOffsetTolerance(mpegOffsetTolerance) {
3506
+ if (!Number.isFinite(mpegOffsetTolerance)) {
3507
+ return 0;
3508
+ }
3509
+ return Math.max(0, Math.min(maximumMpegOffsetTolerance, Math.trunc(mpegOffsetTolerance)));
3510
+ }
3511
+ function getKnownFileSizeOrMaximum(fileSize) {
3512
+ if (!Number.isFinite(fileSize)) {
3513
+ return Number.MAX_SAFE_INTEGER;
3514
+ }
3515
+ return Math.max(0, fileSize);
3516
+ }
3517
+ function importAtRuntime(specifier) {
3518
+ return import(specifier);
3519
+ }
3520
+ function toDefaultStream(stream) {
3521
+ return stream.pipeThrough(new TransformStream());
3522
+ }
3523
+ function readWithSignal(reader, signal) {
3524
+ if (signal === void 0) {
3525
+ return reader.read();
3526
+ }
3527
+ signal.throwIfAborted();
3528
+ return Promise.race([
3529
+ reader.read(),
3530
+ new Promise((_resolve, reject) => {
3531
+ signal.addEventListener("abort", () => {
3532
+ reject(signal.reason);
3533
+ reader.cancel(signal.reason).catch(() => {
3534
+ });
3535
+ }, { once: true });
3536
+ })
3537
+ ]);
3538
+ }
3539
+ function createByteLimitedReadableStream(stream, maximumBytes) {
3540
+ const reader = stream.getReader();
3541
+ let emittedBytes = 0;
3542
+ let sourceDone = false;
3543
+ let sourceCanceled = false;
3544
+ const cancelSource = async (reason) => {
3545
+ if (sourceDone || sourceCanceled) {
3546
+ return;
3547
+ }
3548
+ sourceCanceled = true;
3549
+ await reader.cancel(reason);
3550
+ };
3551
+ return new ReadableStream({
3552
+ async pull(controller) {
3553
+ if (emittedBytes >= maximumBytes) {
3554
+ controller.close();
3555
+ await cancelSource();
3556
+ return;
3557
+ }
3558
+ const { done, value } = await reader.read();
3559
+ if (done || !value) {
3560
+ sourceDone = true;
3561
+ controller.close();
3562
+ return;
3563
+ }
3564
+ const remainingBytes = maximumBytes - emittedBytes;
3565
+ if (value.length > remainingBytes) {
3566
+ controller.enqueue(value.subarray(0, remainingBytes));
3567
+ emittedBytes += remainingBytes;
3568
+ controller.close();
3569
+ await cancelSource();
3570
+ return;
3571
+ }
3572
+ controller.enqueue(value);
3573
+ emittedBytes += value.length;
3574
+ },
3575
+ async cancel(reason) {
3576
+ await cancelSource(reason);
3577
+ }
3578
+ });
3579
+ }
3580
+ async function fileTypeFromStream(stream, options) {
3581
+ return new FileTypeParser(options).fromStream(stream);
3582
+ }
3583
+ async function fileTypeFromBuffer(input, options) {
3584
+ return new FileTypeParser(options).fromBuffer(input);
3585
+ }
3586
+ async function fileTypeFromBlob(blob, options) {
3587
+ return new FileTypeParser(options).fromBlob(blob);
3588
+ }
3589
+ async function fileTypeFromTokenizer(tokenizer, options) {
3590
+ return new FileTypeParser(options).fromTokenizer(tokenizer);
3591
+ }
3592
+ async function fileTypeStream(webStream, options) {
3593
+ return new FileTypeParser(options).toDetectionStream(webStream, options);
3594
+ }
3595
+ async function fileTypeFromFile(path, options) {
3596
+ return new FileTypeParser(options).fromFile(path);
3597
+ }
3598
+ var reasonableDetectionSizeInBytes, maximumMpegOffsetTolerance, maximumNestedGzipDetectionSizeInBytes, maximumNestedGzipProbeDepth, unknownSizeGzipProbeTimeoutInMilliseconds, maximumId3HeaderSizeInBytes, maximumTiffTagCount, maximumDetectionReentryCount, maximumTiffStreamIfdOffsetInBytes, maximumTiffIfdOffsetInBytes, FileTypeParser, supportedExtensions, supportedMimeTypes;
3599
+ var init_source = __esm({
3600
+ "../../node_modules/.pnpm/file-type@22.0.1/node_modules/file-type/source/index.js"() {
3601
+ init_lib2();
3602
+ init_core();
3603
+ init_lib3();
3604
+ init_uint8array_extras();
3605
+ init_tokens();
3606
+ init_supported();
3607
+ init_parser();
3608
+ init_zip();
3609
+ init_ebml();
3610
+ init_png();
3611
+ init_asf();
3612
+ reasonableDetectionSizeInBytes = 4100;
3613
+ maximumMpegOffsetTolerance = reasonableDetectionSizeInBytes - 2;
3614
+ maximumNestedGzipDetectionSizeInBytes = maximumUntrustedSkipSizeInBytes;
3615
+ maximumNestedGzipProbeDepth = 1;
3616
+ unknownSizeGzipProbeTimeoutInMilliseconds = 100;
3617
+ maximumId3HeaderSizeInBytes = maximumUntrustedSkipSizeInBytes;
3618
+ maximumTiffTagCount = 512;
3619
+ maximumDetectionReentryCount = 256;
3620
+ maximumTiffStreamIfdOffsetInBytes = 1024 * 1024;
3621
+ maximumTiffIfdOffsetInBytes = maximumUntrustedSkipSizeInBytes;
3622
+ FileTypeParser = class _FileTypeParser {
3623
+ constructor(options) {
3624
+ const normalizedMpegOffsetTolerance = normalizeMpegOffsetTolerance(options?.mpegOffsetTolerance);
3625
+ this.options = {
3626
+ ...options,
3627
+ mpegOffsetTolerance: normalizedMpegOffsetTolerance
3628
+ };
3629
+ this.detectors = [
3630
+ ...this.options.customDetectors ?? [],
3631
+ { id: "core", detect: this.detectConfident },
3632
+ { id: "core.imprecise", detect: this.detectImprecise }
3633
+ ];
3634
+ this.tokenizerOptions = {
3635
+ abortSignal: this.options.signal
3636
+ };
3637
+ this.gzipProbeDepth = 0;
3638
+ }
3639
+ getTokenizerOptions() {
3640
+ return {
3641
+ ...this.tokenizerOptions
3642
+ };
3643
+ }
3644
+ createTokenizerFromWebStream(stream) {
3645
+ return fromWebStream(toDefaultStream(stream), this.getTokenizerOptions());
3646
+ }
3647
+ async parseTokenizer(tokenizer, detectionReentryCount = 0) {
3648
+ this.detectionReentryCount = detectionReentryCount;
3649
+ const initialPosition = tokenizer.position;
3650
+ for (const detector of this.detectors) {
3651
+ let fileType;
3652
+ try {
3653
+ fileType = await detector.detect(tokenizer);
3654
+ } catch (error) {
3655
+ if (error instanceof EndOfStreamError) {
3656
+ return;
3657
+ }
3658
+ if (error instanceof ParserHardLimitError) {
3659
+ return;
3660
+ }
3661
+ throw error;
3662
+ }
3663
+ if (fileType) {
3664
+ return fileType;
3665
+ }
3666
+ if (initialPosition !== tokenizer.position) {
3667
+ return void 0;
3668
+ }
3669
+ }
3670
+ }
3671
+ async fromTokenizer(tokenizer) {
3672
+ try {
3673
+ return await this.parseTokenizer(tokenizer);
3674
+ } finally {
3675
+ await tokenizer.close();
3676
+ }
3677
+ }
3678
+ async fromBuffer(input) {
3679
+ if (!(input instanceof Uint8Array || input instanceof ArrayBuffer)) {
3680
+ throw new TypeError(`Expected the \`input\` argument to be of type \`Uint8Array\` or \`ArrayBuffer\`, got \`${typeof input}\``);
3681
+ }
3682
+ const buffer = input instanceof Uint8Array ? input : new Uint8Array(input);
3683
+ if (!(buffer?.length > 1)) {
3684
+ return;
3685
+ }
3686
+ return this.fromTokenizer(fromBuffer(buffer, this.getTokenizerOptions()));
3687
+ }
3688
+ async fromBlob(blob) {
3689
+ this.options.signal?.throwIfAborted();
3690
+ const tokenizer = fromBlob(blob, this.getTokenizerOptions());
3691
+ return this.fromTokenizer(tokenizer);
3692
+ }
3693
+ async fromStream(stream) {
3694
+ this.options.signal?.throwIfAborted();
3695
+ const tokenizer = this.createTokenizerFromWebStream(stream);
3696
+ return this.fromTokenizer(tokenizer);
3697
+ }
3698
+ async fromFile(path) {
3699
+ this.options.signal?.throwIfAborted();
3700
+ const [{ default: fsPromises }, { FileTokenizer }] = await Promise.all([
3701
+ importAtRuntime("node:fs/promises"),
3702
+ importAtRuntime("strtok3")
3703
+ ]);
3704
+ const fileHandle = await fsPromises.open(path, fsPromises.constants.O_RDONLY | fsPromises.constants.O_NONBLOCK);
3705
+ const fileStat = await fileHandle.stat();
3706
+ if (!fileStat.isFile()) {
3707
+ await fileHandle.close();
3708
+ return;
3709
+ }
3710
+ const tokenizer = new FileTokenizer(fileHandle, {
3711
+ ...this.getTokenizerOptions(),
3712
+ fileInfo: { path, size: fileStat.size }
3713
+ });
3714
+ return this.fromTokenizer(tokenizer);
3715
+ }
3716
+ async toDetectionStream(stream, options) {
3717
+ this.options.signal?.throwIfAborted();
3718
+ const sampleSize = normalizeSampleSize(options?.sampleSize ?? reasonableDetectionSizeInBytes);
3719
+ let detectedFileType;
3720
+ let streamEnded = false;
3721
+ const reader = stream.getReader();
3722
+ const chunks = [];
3723
+ let totalSize = 0;
3724
+ try {
3725
+ while (totalSize < sampleSize) {
3726
+ const { value, done } = await readWithSignal(reader, this.options.signal);
3727
+ if (done || !value) {
3728
+ streamEnded = true;
3729
+ break;
3730
+ }
3731
+ chunks.push(value);
3732
+ totalSize += value.length;
3733
+ }
3734
+ if (!streamEnded && totalSize === sampleSize) {
3735
+ const { value, done } = await readWithSignal(reader, this.options.signal);
3736
+ if (done || !value) {
3737
+ streamEnded = true;
3738
+ } else {
3739
+ chunks.push(value);
3740
+ totalSize += value.length;
3741
+ }
3742
+ }
3743
+ } finally {
3744
+ reader.releaseLock();
3745
+ }
3746
+ if (totalSize > 0) {
3747
+ const sample = chunks.length === 1 ? chunks[0] : concatUint8Arrays(chunks);
3748
+ try {
3749
+ detectedFileType = await this.fromBuffer(sample.subarray(0, sampleSize));
3750
+ } catch (error) {
3751
+ if (!(error instanceof EndOfStreamError)) {
3752
+ throw error;
3753
+ }
3754
+ detectedFileType = void 0;
3755
+ }
3756
+ if (!streamEnded && detectedFileType?.ext === "pages") {
3757
+ detectedFileType = {
3758
+ ext: "zip",
3759
+ mime: "application/zip"
3760
+ };
3761
+ }
3762
+ }
3763
+ const transformStream = new TransformStream({
3764
+ start(controller) {
3765
+ for (const chunk of chunks) {
3766
+ controller.enqueue(chunk);
3767
+ }
3768
+ },
3769
+ transform(chunk, controller) {
3770
+ controller.enqueue(chunk);
3771
+ }
3772
+ });
3773
+ const newStream = stream.pipeThrough(transformStream);
3774
+ newStream.fileType = detectedFileType;
3775
+ return newStream;
3776
+ }
3777
+ async detectGzip(tokenizer) {
3778
+ if (this.gzipProbeDepth >= maximumNestedGzipProbeDepth) {
3779
+ return {
3780
+ ext: "gz",
3781
+ mime: "application/gzip"
3782
+ };
3783
+ }
3784
+ const gzipHandler = new GzipHandler(tokenizer);
3785
+ const limitedInflatedStream = createByteLimitedReadableStream(gzipHandler.inflate(), maximumNestedGzipDetectionSizeInBytes);
3786
+ const hasUnknownSize = hasUnknownFileSize(tokenizer);
3787
+ let timeout;
3788
+ let probeSignal;
3789
+ let probeParser;
3790
+ let compressedFileType;
3791
+ if (hasUnknownSize) {
3792
+ const timeoutController = new AbortController();
3793
+ timeout = setTimeout(() => {
3794
+ timeoutController.abort(new DOMException(`Operation timed out after ${unknownSizeGzipProbeTimeoutInMilliseconds} ms`, "TimeoutError"));
3795
+ }, unknownSizeGzipProbeTimeoutInMilliseconds);
3796
+ probeSignal = this.options.signal === void 0 ? timeoutController.signal : AbortSignal.any([this.options.signal, timeoutController.signal]);
3797
+ probeParser = new _FileTypeParser({
3798
+ ...this.options,
3799
+ signal: probeSignal
3800
+ });
3801
+ probeParser.gzipProbeDepth = this.gzipProbeDepth + 1;
3802
+ } else {
3803
+ this.gzipProbeDepth++;
3804
+ }
3805
+ try {
3806
+ compressedFileType = await (probeParser ?? this).fromStream(limitedInflatedStream);
3807
+ } catch (error) {
3808
+ if (error?.name === "AbortError" && probeSignal?.reason?.name !== "TimeoutError") {
3809
+ throw error;
3810
+ }
3811
+ } finally {
3812
+ clearTimeout(timeout);
3813
+ if (!hasUnknownSize) {
3814
+ this.gzipProbeDepth--;
3815
+ }
3816
+ }
3817
+ if (compressedFileType?.ext === "tar") {
3818
+ return {
3819
+ ext: "tar.gz",
3820
+ mime: "application/gzip"
3821
+ };
3822
+ }
3823
+ return {
3824
+ ext: "gz",
3825
+ mime: "application/gzip"
3826
+ };
3827
+ }
3828
+ check(header, options) {
3829
+ return checkBytes(this.buffer, header, options);
3830
+ }
3831
+ checkString(header, options) {
3832
+ return this.check(stringToBytes(header, options?.encoding), options);
3833
+ }
3834
+ // Detections with a high degree of certainty in identifying the correct file type
3835
+ detectConfident = async (tokenizer) => {
3836
+ this.buffer = new Uint8Array(reasonableDetectionSizeInBytes);
3837
+ if (tokenizer.fileInfo.size === void 0) {
3838
+ tokenizer.fileInfo.size = Number.MAX_SAFE_INTEGER;
3839
+ }
3840
+ this.tokenizer = tokenizer;
3841
+ if (hasUnknownFileSize(tokenizer)) {
3842
+ await tokenizer.peekBuffer(this.buffer, { length: 3, mayBeLess: true });
3843
+ if (this.check([31, 139, 8])) {
3844
+ return this.detectGzip(tokenizer);
3845
+ }
3846
+ }
3847
+ await tokenizer.peekBuffer(this.buffer, { length: 32, mayBeLess: true });
3848
+ if (this.check([66, 77])) {
3849
+ return {
3850
+ ext: "bmp",
3851
+ mime: "image/bmp"
3852
+ };
3853
+ }
3854
+ if (this.check([11, 119])) {
3855
+ return {
3856
+ ext: "ac3",
3857
+ mime: "audio/vnd.dolby.dd-raw"
3858
+ };
3859
+ }
3860
+ if (this.check([120, 1])) {
3861
+ return {
3862
+ ext: "dmg",
3863
+ mime: "application/x-apple-diskimage"
3864
+ };
3865
+ }
3866
+ if (this.check([77, 90])) {
3867
+ return {
3868
+ ext: "exe",
3869
+ mime: "application/x-msdownload"
3870
+ };
3871
+ }
3872
+ if (this.check([37, 33])) {
3873
+ await tokenizer.peekBuffer(this.buffer, { length: 24, mayBeLess: true });
3874
+ if (this.checkString("PS-Adobe-", { offset: 2 }) && this.checkString(" EPSF-", { offset: 14 })) {
3875
+ return {
3876
+ ext: "eps",
3877
+ mime: "application/eps"
3878
+ };
3879
+ }
3880
+ return {
3881
+ ext: "ps",
3882
+ mime: "application/postscript"
3883
+ };
3884
+ }
3885
+ if (this.check([31, 160]) || this.check([31, 157])) {
3886
+ return {
3887
+ ext: "Z",
3888
+ mime: "application/x-compress"
3889
+ };
3890
+ }
3891
+ if (this.check([199, 113])) {
3892
+ return {
3893
+ ext: "cpio",
3894
+ mime: "application/x-cpio"
3895
+ };
3896
+ }
3897
+ if (this.check([96, 234])) {
3898
+ return {
3899
+ ext: "arj",
3900
+ mime: "application/x-arj"
3901
+ };
3902
+ }
3903
+ if (this.check([239, 187, 191])) {
3904
+ if (this.detectionReentryCount >= maximumDetectionReentryCount) {
3905
+ return;
3906
+ }
3907
+ this.detectionReentryCount++;
3908
+ await this.tokenizer.ignore(3);
3909
+ return this.detectConfident(tokenizer);
3910
+ }
3911
+ if (this.check([71, 73, 70])) {
3912
+ return {
3913
+ ext: "gif",
3914
+ mime: "image/gif"
3915
+ };
3916
+ }
3917
+ if (this.check([73, 73, 188])) {
3918
+ return {
3919
+ ext: "jxr",
3920
+ mime: "image/vnd.ms-photo"
3921
+ };
3922
+ }
3923
+ if (this.check([31, 139, 8])) {
3924
+ return this.detectGzip(tokenizer);
3925
+ }
3926
+ if (this.check([66, 90, 104])) {
3927
+ return {
3928
+ ext: "bz2",
3929
+ mime: "application/x-bzip2"
3930
+ };
3931
+ }
3932
+ if (this.checkString("ID3")) {
3933
+ await safeIgnore(tokenizer, 6, {
3934
+ maximumLength: 6,
3935
+ reason: "ID3 header prefix"
3936
+ });
3937
+ const id3HeaderLength = await tokenizer.readToken(uint32SyncSafeToken);
3938
+ const isUnknownFileSize = hasUnknownFileSize(tokenizer);
3939
+ if (!Number.isFinite(id3HeaderLength) || id3HeaderLength < 0 || isUnknownFileSize && (id3HeaderLength > maximumId3HeaderSizeInBytes || tokenizer.position + id3HeaderLength > maximumId3HeaderSizeInBytes)) {
3940
+ return;
3941
+ }
3942
+ if (tokenizer.position + id3HeaderLength > tokenizer.fileInfo.size) {
3943
+ if (isUnknownFileSize) {
3944
+ return;
3945
+ }
3946
+ return {
3947
+ ext: "mp3",
3948
+ mime: "audio/mpeg"
3949
+ };
3950
+ }
3951
+ try {
3952
+ await safeIgnore(tokenizer, id3HeaderLength, {
3953
+ maximumLength: isUnknownFileSize ? maximumId3HeaderSizeInBytes : tokenizer.fileInfo.size,
3954
+ reason: "ID3 payload"
3955
+ });
3956
+ } catch (error) {
3957
+ if (error instanceof EndOfStreamError) {
3958
+ return;
3959
+ }
3960
+ throw error;
3961
+ }
3962
+ if (this.detectionReentryCount >= maximumDetectionReentryCount) {
3963
+ return;
3964
+ }
3965
+ this.detectionReentryCount++;
3966
+ return this.parseTokenizer(tokenizer, this.detectionReentryCount);
3967
+ }
3968
+ if (this.checkString("MP+")) {
3969
+ return {
3970
+ ext: "mpc",
3971
+ mime: "audio/x-musepack"
3972
+ };
3973
+ }
3974
+ if ((this.buffer[0] === 67 || this.buffer[0] === 70) && this.check([87, 83], { offset: 1 })) {
3975
+ return {
3976
+ ext: "swf",
3977
+ mime: "application/x-shockwave-flash"
3978
+ };
3979
+ }
3980
+ if (this.check([255, 216, 255])) {
3981
+ if (this.check([247], { offset: 3 })) {
3982
+ return {
3983
+ ext: "jls",
3984
+ mime: "image/jls"
3985
+ };
3986
+ }
3987
+ return {
3988
+ ext: "jpg",
3989
+ mime: "image/jpeg"
3990
+ };
3991
+ }
3992
+ if (this.check([79, 98, 106, 1])) {
3993
+ return {
3994
+ ext: "avro",
3995
+ mime: "application/avro"
3996
+ };
3997
+ }
3998
+ if (this.checkString("FLIF")) {
3999
+ return {
4000
+ ext: "flif",
4001
+ mime: "image/flif"
4002
+ };
4003
+ }
4004
+ if (this.checkString("8BPS")) {
4005
+ return {
4006
+ ext: "psd",
4007
+ mime: "image/vnd.adobe.photoshop"
4008
+ };
4009
+ }
4010
+ if (this.checkString("MPCK")) {
4011
+ return {
4012
+ ext: "mpc",
4013
+ mime: "audio/x-musepack"
4014
+ };
4015
+ }
4016
+ if (this.checkString("FORM")) {
4017
+ return {
4018
+ ext: "aif",
4019
+ mime: "audio/aiff"
4020
+ };
4021
+ }
4022
+ if (this.checkString("icns", { offset: 0 })) {
4023
+ return {
4024
+ ext: "icns",
4025
+ mime: "image/icns"
4026
+ };
4027
+ }
4028
+ if (this.check([80, 75, 3, 4])) {
4029
+ return detectZip(tokenizer);
4030
+ }
4031
+ if (this.checkString("OggS")) {
4032
+ await tokenizer.ignore(28);
4033
+ const type = new Uint8Array(8);
4034
+ await tokenizer.readBuffer(type);
4035
+ if (checkBytes(type, [79, 112, 117, 115, 72, 101, 97, 100])) {
4036
+ return {
4037
+ ext: "opus",
4038
+ mime: "audio/ogg; codecs=opus"
4039
+ };
4040
+ }
4041
+ if (checkBytes(type, [128, 116, 104, 101, 111, 114, 97])) {
4042
+ return {
4043
+ ext: "ogv",
4044
+ mime: "video/ogg"
4045
+ };
4046
+ }
4047
+ if (checkBytes(type, [1, 118, 105, 100, 101, 111, 0])) {
4048
+ return {
4049
+ ext: "ogm",
4050
+ mime: "video/ogg"
4051
+ };
4052
+ }
4053
+ if (checkBytes(type, [127, 70, 76, 65, 67])) {
4054
+ return {
4055
+ ext: "oga",
4056
+ mime: "audio/ogg"
4057
+ };
4058
+ }
4059
+ if (checkBytes(type, [83, 112, 101, 101, 120, 32, 32])) {
4060
+ return {
4061
+ ext: "spx",
4062
+ mime: "audio/ogg"
4063
+ };
4064
+ }
4065
+ if (checkBytes(type, [1, 118, 111, 114, 98, 105, 115])) {
4066
+ return {
4067
+ ext: "ogg",
4068
+ mime: "audio/ogg"
4069
+ };
4070
+ }
4071
+ return {
4072
+ ext: "ogx",
4073
+ mime: "application/ogg"
4074
+ };
4075
+ }
4076
+ if (this.check([80, 75]) && (this.buffer[2] === 3 || this.buffer[2] === 5 || this.buffer[2] === 7) && (this.buffer[3] === 4 || this.buffer[3] === 6 || this.buffer[3] === 8)) {
4077
+ return {
4078
+ ext: "zip",
4079
+ mime: "application/zip"
4080
+ };
4081
+ }
4082
+ if (this.checkString("MThd")) {
4083
+ return {
4084
+ ext: "mid",
4085
+ mime: "audio/midi"
4086
+ };
4087
+ }
4088
+ if (this.checkString("wOFF") && (this.check([0, 1, 0, 0], { offset: 4 }) || this.checkString("OTTO", { offset: 4 }))) {
4089
+ return {
4090
+ ext: "woff",
4091
+ mime: "font/woff"
4092
+ };
4093
+ }
4094
+ if (this.checkString("wOF2") && (this.check([0, 1, 0, 0], { offset: 4 }) || this.checkString("OTTO", { offset: 4 }))) {
4095
+ return {
4096
+ ext: "woff2",
4097
+ mime: "font/woff2"
4098
+ };
4099
+ }
4100
+ if (this.check([212, 195, 178, 161]) || this.check([161, 178, 195, 212])) {
4101
+ return {
4102
+ ext: "pcap",
4103
+ mime: "application/vnd.tcpdump.pcap"
4104
+ };
4105
+ }
4106
+ if (this.checkString("DSD ")) {
4107
+ return {
4108
+ ext: "dsf",
4109
+ mime: "audio/x-dsf"
4110
+ // Non-standard
4111
+ };
4112
+ }
4113
+ if (this.checkString("LZIP")) {
4114
+ return {
4115
+ ext: "lz",
4116
+ mime: "application/lzip"
4117
+ };
4118
+ }
4119
+ if (this.checkString("fLaC")) {
4120
+ return {
4121
+ ext: "flac",
4122
+ mime: "audio/flac"
4123
+ };
4124
+ }
4125
+ if (this.check([66, 80, 71, 251])) {
4126
+ return {
4127
+ ext: "bpg",
4128
+ mime: "image/bpg"
4129
+ };
4130
+ }
4131
+ if (this.checkString("wvpk")) {
4132
+ return {
4133
+ ext: "wv",
4134
+ mime: "audio/wavpack"
4135
+ };
4136
+ }
4137
+ if (this.checkString("%PDF")) {
4138
+ return {
4139
+ ext: "pdf",
4140
+ mime: "application/pdf"
4141
+ };
4142
+ }
4143
+ if (this.check([0, 97, 115, 109])) {
4144
+ return {
4145
+ ext: "wasm",
4146
+ mime: "application/wasm"
4147
+ };
4148
+ }
4149
+ if (this.check([73, 73])) {
4150
+ const fileType = await this.readTiffHeader(false);
4151
+ if (fileType) {
4152
+ return fileType;
4153
+ }
4154
+ }
4155
+ if (this.check([77, 77])) {
4156
+ const fileType = await this.readTiffHeader(true);
4157
+ if (fileType) {
4158
+ return fileType;
4159
+ }
4160
+ }
4161
+ if (this.checkString("MAC ")) {
4162
+ return {
4163
+ ext: "ape",
4164
+ mime: "audio/ape"
4165
+ };
4166
+ }
4167
+ if (this.check([26, 69, 223, 163])) {
4168
+ return detectEbml(tokenizer);
4169
+ }
4170
+ if (this.checkString("SQLi")) {
4171
+ return {
4172
+ ext: "sqlite",
4173
+ mime: "application/x-sqlite3"
4174
+ };
4175
+ }
4176
+ if (this.check([78, 69, 83, 26])) {
4177
+ return {
4178
+ ext: "nes",
4179
+ mime: "application/x-nintendo-nes-rom"
4180
+ };
4181
+ }
4182
+ if (this.checkString("Cr24")) {
4183
+ return {
4184
+ ext: "crx",
4185
+ mime: "application/x-google-chrome-extension"
4186
+ };
4187
+ }
4188
+ if (this.checkString("MSCF") || this.checkString("ISc(")) {
4189
+ return {
4190
+ ext: "cab",
4191
+ mime: "application/vnd.ms-cab-compressed"
4192
+ };
4193
+ }
4194
+ if (this.check([237, 171, 238, 219])) {
4195
+ return {
4196
+ ext: "rpm",
4197
+ mime: "application/x-rpm"
4198
+ };
4199
+ }
4200
+ if (this.check([197, 208, 211, 198])) {
4201
+ return {
4202
+ ext: "eps",
4203
+ mime: "application/eps"
4204
+ };
4205
+ }
4206
+ if (this.check([40, 181, 47, 253])) {
4207
+ return {
4208
+ ext: "zst",
4209
+ mime: "application/zstd"
4210
+ };
4211
+ }
4212
+ if (this.check([127, 69, 76, 70])) {
4213
+ return {
4214
+ ext: "elf",
4215
+ mime: "application/x-elf"
4216
+ };
4217
+ }
4218
+ if (this.check([33, 66, 68, 78])) {
4219
+ return {
4220
+ ext: "pst",
4221
+ mime: "application/vnd.ms-outlook"
4222
+ };
4223
+ }
4224
+ if (this.checkString("PAR1") || this.checkString("PARE")) {
4225
+ return {
4226
+ ext: "parquet",
4227
+ mime: "application/vnd.apache.parquet"
4228
+ };
4229
+ }
4230
+ if (this.checkString("ttcf")) {
4231
+ return {
4232
+ ext: "ttc",
4233
+ mime: "font/collection"
4234
+ };
4235
+ }
4236
+ if (this.check([254, 237, 250, 206]) || this.check([254, 237, 250, 207]) || this.check([206, 250, 237, 254]) || this.check([207, 250, 237, 254])) {
4237
+ return {
4238
+ ext: "macho",
4239
+ mime: "application/x-mach-binary"
4240
+ };
4241
+ }
4242
+ if (this.check([4, 34, 77, 24])) {
4243
+ return {
4244
+ ext: "lz4",
4245
+ mime: "application/x-lz4"
4246
+ // Informal, used by freedesktop.org shared-mime-info
4247
+ };
4248
+ }
4249
+ if (this.checkString("regf")) {
4250
+ return {
4251
+ ext: "dat",
4252
+ mime: "application/x-ft-windows-registry-hive"
4253
+ };
4254
+ }
4255
+ if (this.checkString("$FL2") || this.checkString("$FL3")) {
4256
+ return {
4257
+ ext: "sav",
4258
+ mime: "application/x-spss-sav"
4259
+ };
4260
+ }
4261
+ if (this.check([79, 84, 84, 79, 0])) {
4262
+ return {
4263
+ ext: "otf",
4264
+ mime: "font/otf"
4265
+ };
4266
+ }
4267
+ if (this.checkString("#!AMR")) {
4268
+ return {
4269
+ ext: "amr",
4270
+ mime: "audio/amr"
4271
+ };
4272
+ }
4273
+ if (this.checkString(String.raw`{\rtf`)) {
4274
+ return {
4275
+ ext: "rtf",
4276
+ mime: "application/rtf"
4277
+ };
4278
+ }
4279
+ if (this.check([70, 76, 86, 1])) {
4280
+ return {
4281
+ ext: "flv",
4282
+ mime: "video/x-flv"
4283
+ };
4284
+ }
4285
+ if (this.checkString("IMPM")) {
4286
+ return {
4287
+ ext: "it",
4288
+ mime: "audio/x-it"
4289
+ };
4290
+ }
4291
+ if (this.checkString("-lh0-", { offset: 2 }) || this.checkString("-lh1-", { offset: 2 }) || this.checkString("-lh2-", { offset: 2 }) || this.checkString("-lh3-", { offset: 2 }) || this.checkString("-lh4-", { offset: 2 }) || this.checkString("-lh5-", { offset: 2 }) || this.checkString("-lh6-", { offset: 2 }) || this.checkString("-lh7-", { offset: 2 }) || this.checkString("-lzs-", { offset: 2 }) || this.checkString("-lz4-", { offset: 2 }) || this.checkString("-lz5-", { offset: 2 }) || this.checkString("-lhd-", { offset: 2 })) {
4292
+ return {
4293
+ ext: "lzh",
4294
+ mime: "application/x-lzh-compressed"
4295
+ };
4296
+ }
4297
+ if (this.check([0, 0, 1, 186])) {
4298
+ if (this.check([33], { offset: 4, mask: [241] })) {
4299
+ return {
4300
+ ext: "mpg",
4301
+ // May also be .ps, .mpeg
4302
+ mime: "video/MP1S"
4303
+ };
4304
+ }
4305
+ if (this.check([68], { offset: 4, mask: [196] })) {
4306
+ return {
4307
+ ext: "mpg",
4308
+ // May also be .mpg, .m2p, .vob or .sub
4309
+ mime: "video/MP2P"
4310
+ };
4311
+ }
4312
+ }
4313
+ if (this.checkString("ITSF")) {
4314
+ return {
4315
+ ext: "chm",
4316
+ mime: "application/vnd.ms-htmlhelp"
4317
+ };
4318
+ }
4319
+ if (this.check([202, 254, 186, 190])) {
4320
+ const machOArchitectureCount = UINT32_BE.get(this.buffer, 4);
4321
+ const javaClassFileMajorVersion = UINT16_BE.get(this.buffer, 6);
4322
+ if (machOArchitectureCount > 0 && machOArchitectureCount <= 30) {
4323
+ return {
4324
+ ext: "macho",
4325
+ mime: "application/x-mach-binary"
4326
+ };
4327
+ }
4328
+ if (javaClassFileMajorVersion > 30) {
4329
+ return {
4330
+ ext: "class",
4331
+ mime: "application/java-vm"
4332
+ };
4333
+ }
4334
+ }
4335
+ if (this.checkString(".RMF")) {
4336
+ return {
4337
+ ext: "rm",
4338
+ mime: "application/vnd.rn-realmedia"
4339
+ };
4340
+ }
4341
+ if (this.checkString("DRACO")) {
4342
+ return {
4343
+ ext: "drc",
4344
+ mime: "application/x-ft-draco"
4345
+ };
4346
+ }
4347
+ if (this.check([253, 55, 122, 88, 90, 0])) {
4348
+ return {
4349
+ ext: "xz",
4350
+ mime: "application/x-xz"
4351
+ };
4352
+ }
4353
+ if (this.checkString("<?xml ")) {
4354
+ return {
4355
+ ext: "xml",
4356
+ mime: "application/xml"
4357
+ };
4358
+ }
4359
+ if (this.check([55, 122, 188, 175, 39, 28])) {
4360
+ return {
4361
+ ext: "7z",
4362
+ mime: "application/x-7z-compressed"
4363
+ };
4364
+ }
4365
+ if (this.check([82, 97, 114, 33, 26, 7]) && (this.buffer[6] === 0 || this.buffer[6] === 1)) {
4366
+ return {
4367
+ ext: "rar",
4368
+ mime: "application/x-rar-compressed"
4369
+ };
4370
+ }
4371
+ if (this.checkString("solid ")) {
4372
+ return {
4373
+ ext: "stl",
4374
+ mime: "model/stl"
4375
+ };
4376
+ }
4377
+ if (this.checkString("AC")) {
4378
+ const version = new StringType(4, "latin1").get(this.buffer, 2);
4379
+ if (new RegExp("^\\d+$", "v").test(version) && version >= 1e3 && version <= 1050) {
4380
+ return {
4381
+ ext: "dwg",
4382
+ mime: "image/vnd.dwg"
4383
+ };
4384
+ }
4385
+ }
4386
+ if (this.checkString("070707")) {
4387
+ return {
4388
+ ext: "cpio",
4389
+ mime: "application/x-cpio"
4390
+ };
4391
+ }
4392
+ if (this.checkString("BLENDER")) {
4393
+ return {
4394
+ ext: "blend",
4395
+ mime: "application/x-blender"
4396
+ };
4397
+ }
4398
+ if (this.checkString("!<arch>")) {
4399
+ await tokenizer.ignore(8);
4400
+ const string = await tokenizer.readToken(new StringType(13, "ascii"));
4401
+ if (string === "debian-binary") {
4402
+ return {
4403
+ ext: "deb",
4404
+ mime: "application/x-deb"
4405
+ };
4406
+ }
4407
+ return {
4408
+ ext: "ar",
4409
+ mime: "application/x-unix-archive"
4410
+ };
4411
+ }
4412
+ if (this.checkString("WEBVTT") && // One of LF, CR, tab, space, or end of file must follow "WEBVTT" per the spec (see `fixture/fixture-vtt-*.vtt` for examples). Note that `\0` is technically the null character (there is no such thing as an EOF character). However, checking for `\0` gives us the same result as checking for the end of the stream.
4413
+ ["\n", "\r", " ", " ", "\0"].some((char7) => this.checkString(char7, { offset: 6 }))) {
4414
+ return {
4415
+ ext: "vtt",
4416
+ mime: "text/vtt"
4417
+ };
4418
+ }
4419
+ if (this.check([137, 80, 78, 71, 13, 10, 26, 10])) {
4420
+ return detectPng(tokenizer);
4421
+ }
4422
+ if (this.check([65, 82, 82, 79, 87, 49, 0, 0])) {
4423
+ return {
4424
+ ext: "arrow",
4425
+ mime: "application/vnd.apache.arrow.file"
4426
+ };
4427
+ }
4428
+ if (this.check([103, 108, 84, 70, 2, 0, 0, 0])) {
4429
+ return {
4430
+ ext: "glb",
4431
+ mime: "model/gltf-binary"
4432
+ };
4433
+ }
4434
+ if (this.check([102, 114, 101, 101], { offset: 4 }) || this.check([109, 100, 97, 116], { offset: 4 }) || this.check([109, 111, 111, 118], { offset: 4 }) || this.check([119, 105, 100, 101], { offset: 4 })) {
4435
+ return {
4436
+ ext: "mov",
4437
+ mime: "video/quicktime"
4438
+ };
4439
+ }
4440
+ if (this.check([73, 73, 82, 79, 8, 0, 0, 0, 24])) {
4441
+ return {
4442
+ ext: "orf",
4443
+ mime: "image/x-olympus-orf"
4444
+ };
4445
+ }
4446
+ if (this.checkString("gimp xcf ")) {
4447
+ return {
4448
+ ext: "xcf",
4449
+ mime: "image/x-xcf"
4450
+ };
4451
+ }
4452
+ if (this.checkString("ftyp", { offset: 4 }) && (this.buffer[8] & 96) !== 0) {
4453
+ const brandMajor = new StringType(4, "latin1").get(this.buffer, 8).replace("\0", " ").trim();
4454
+ switch (brandMajor) {
4455
+ case "avif":
4456
+ case "avis":
4457
+ return { ext: "avif", mime: "image/avif" };
4458
+ case "mif1":
4459
+ return { ext: "heic", mime: "image/heif" };
4460
+ case "msf1":
4461
+ return { ext: "heic", mime: "image/heif-sequence" };
4462
+ case "heic":
4463
+ case "heix":
4464
+ return { ext: "heic", mime: "image/heic" };
4465
+ case "hevc":
4466
+ case "hevx":
4467
+ return { ext: "heic", mime: "image/heic-sequence" };
4468
+ case "qt":
4469
+ return { ext: "mov", mime: "video/quicktime" };
4470
+ case "M4V":
4471
+ case "M4VH":
4472
+ case "M4VP":
4473
+ return { ext: "m4v", mime: "video/x-m4v" };
4474
+ case "M4P":
4475
+ return { ext: "m4p", mime: "video/mp4" };
4476
+ case "M4B":
4477
+ return { ext: "m4b", mime: "audio/mp4" };
4478
+ case "M4A":
4479
+ return { ext: "m4a", mime: "audio/x-m4a" };
4480
+ case "F4V":
4481
+ return { ext: "f4v", mime: "video/mp4" };
4482
+ case "F4P":
4483
+ return { ext: "f4p", mime: "video/mp4" };
4484
+ case "F4A":
4485
+ return { ext: "f4a", mime: "audio/mp4" };
4486
+ case "F4B":
4487
+ return { ext: "f4b", mime: "audio/mp4" };
4488
+ case "crx":
4489
+ return { ext: "cr3", mime: "image/x-canon-cr3" };
4490
+ default:
4491
+ if (brandMajor.startsWith("3g")) {
4492
+ if (brandMajor.startsWith("3g2")) {
4493
+ return { ext: "3g2", mime: "video/3gpp2" };
4494
+ }
4495
+ return { ext: "3gp", mime: "video/3gpp" };
4496
+ }
4497
+ return { ext: "mp4", mime: "video/mp4" };
4498
+ }
4499
+ }
4500
+ if (this.checkString("REGEDIT4\r\n")) {
4501
+ return {
4502
+ ext: "reg",
4503
+ mime: "application/x-ms-regedit"
4504
+ };
4505
+ }
4506
+ if (this.check([82, 73, 70, 70])) {
4507
+ if (this.checkString("WEBP", { offset: 8 })) {
4508
+ return {
4509
+ ext: "webp",
4510
+ mime: "image/webp"
4511
+ };
4512
+ }
4513
+ if (this.check([65, 86, 73], { offset: 8 })) {
4514
+ return {
4515
+ ext: "avi",
4516
+ mime: "video/vnd.avi"
4517
+ };
4518
+ }
4519
+ if (this.check([87, 65, 86, 69], { offset: 8 })) {
4520
+ return {
4521
+ ext: "wav",
4522
+ mime: "audio/wav"
4523
+ };
4524
+ }
4525
+ if (this.check([81, 76, 67, 77], { offset: 8 })) {
4526
+ return {
4527
+ ext: "qcp",
4528
+ mime: "audio/qcelp"
4529
+ };
4530
+ }
4531
+ }
4532
+ if (this.check([73, 73, 85, 0, 24, 0, 0, 0, 136, 231, 116, 216])) {
4533
+ return {
4534
+ ext: "rw2",
4535
+ mime: "image/x-panasonic-rw2"
4536
+ };
4537
+ }
4538
+ if (this.check([48, 38, 178, 117, 142, 102, 207, 17, 166, 217])) {
4539
+ return detectAsf(tokenizer);
4540
+ }
4541
+ if (this.check([171, 75, 84, 88, 32, 49, 49, 187, 13, 10, 26, 10])) {
4542
+ return {
4543
+ ext: "ktx",
4544
+ mime: "image/ktx"
4545
+ };
4546
+ }
4547
+ if ((this.check([126, 16, 4]) || this.check([126, 24, 4])) && this.check([48, 77, 73, 69], { offset: 4 })) {
4548
+ return {
4549
+ ext: "mie",
4550
+ mime: "application/x-mie"
4551
+ };
4552
+ }
4553
+ if (this.check([39, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], { offset: 2 })) {
4554
+ return {
4555
+ ext: "shp",
4556
+ mime: "application/x-esri-shape"
4557
+ };
4558
+ }
4559
+ if (this.check([255, 79, 255, 81])) {
4560
+ return {
4561
+ ext: "j2c",
4562
+ mime: "image/j2c"
4563
+ };
4564
+ }
4565
+ if (this.check([0, 0, 0, 12, 106, 80, 32, 32, 13, 10, 135, 10])) {
4566
+ await tokenizer.ignore(20);
4567
+ const type = await tokenizer.readToken(new StringType(4, "ascii"));
4568
+ switch (type) {
4569
+ case "jp2 ":
4570
+ return {
4571
+ ext: "jp2",
4572
+ mime: "image/jp2"
4573
+ };
4574
+ case "jpx ":
4575
+ return {
4576
+ ext: "jpx",
4577
+ mime: "image/jpx"
4578
+ };
4579
+ case "jpm ":
4580
+ return {
4581
+ ext: "jpm",
4582
+ mime: "image/jpm"
4583
+ };
4584
+ case "mjp2":
4585
+ return {
4586
+ ext: "mj2",
4587
+ mime: "image/mj2"
4588
+ };
4589
+ default:
4590
+ return;
4591
+ }
4592
+ }
4593
+ if (this.check([255, 10]) || this.check([0, 0, 0, 12, 74, 88, 76, 32, 13, 10, 135, 10])) {
4594
+ return {
4595
+ ext: "jxl",
4596
+ mime: "image/jxl"
4597
+ };
4598
+ }
4599
+ if (this.check([254, 255])) {
4600
+ if (this.checkString("<?xml ", { offset: 2, encoding: "utf-16be" })) {
4601
+ return {
4602
+ ext: "xml",
4603
+ mime: "application/xml"
4604
+ };
4605
+ }
4606
+ return void 0;
4607
+ }
4608
+ if (this.check([208, 207, 17, 224, 161, 177, 26, 225])) {
4609
+ return {
4610
+ ext: "cfb",
4611
+ mime: "application/x-cfb"
4612
+ };
4613
+ }
4614
+ await tokenizer.peekBuffer(this.buffer, { length: Math.min(256, tokenizer.fileInfo.size), mayBeLess: true });
4615
+ if (this.check([97, 99, 115, 112], { offset: 36 })) {
4616
+ return {
4617
+ ext: "icc",
4618
+ mime: "application/vnd.iccprofile"
4619
+ };
4620
+ }
4621
+ if (this.checkString("**ACE", { offset: 7 }) && this.checkString("**", { offset: 12 })) {
4622
+ return {
4623
+ ext: "ace",
4624
+ mime: "application/x-ace-compressed"
4625
+ };
4626
+ }
4627
+ if (this.checkString("BEGIN:")) {
4628
+ if (this.checkString("VCARD", { offset: 6 })) {
4629
+ return {
4630
+ ext: "vcf",
4631
+ mime: "text/vcard"
4632
+ };
4633
+ }
4634
+ if (this.checkString("VCALENDAR", { offset: 6 })) {
4635
+ return {
4636
+ ext: "ics",
4637
+ mime: "text/calendar"
4638
+ };
4639
+ }
4640
+ }
4641
+ if (this.checkString("FUJIFILMCCD-RAW")) {
4642
+ return {
4643
+ ext: "raf",
4644
+ mime: "image/x-fujifilm-raf"
4645
+ };
4646
+ }
4647
+ if (this.checkString("Extended Module:")) {
4648
+ return {
4649
+ ext: "xm",
4650
+ mime: "audio/x-xm"
4651
+ };
4652
+ }
4653
+ if (this.checkString("Creative Voice File")) {
4654
+ return {
4655
+ ext: "voc",
4656
+ mime: "audio/x-voc"
4657
+ };
4658
+ }
4659
+ if (this.check([4, 0, 0, 0]) && this.buffer.length >= 16) {
4660
+ const jsonSize = new DataView(this.buffer.buffer).getUint32(12, true);
4661
+ if (jsonSize > 12 && this.buffer.length >= jsonSize + 16) {
4662
+ try {
4663
+ const header = new TextDecoder().decode(this.buffer.subarray(16, jsonSize + 16));
4664
+ const json = JSON.parse(header);
4665
+ if (json.files) {
4666
+ return {
4667
+ ext: "asar",
4668
+ mime: "application/x-asar"
4669
+ };
4670
+ }
4671
+ } catch {
4672
+ }
4673
+ }
4674
+ }
4675
+ if (this.check([6, 14, 43, 52, 2, 5, 1, 1, 13, 1, 2, 1, 1, 2])) {
4676
+ return {
4677
+ ext: "mxf",
4678
+ mime: "application/mxf"
4679
+ };
4680
+ }
4681
+ if (this.checkString("SCRM", { offset: 44 })) {
4682
+ return {
4683
+ ext: "s3m",
4684
+ mime: "audio/x-s3m"
4685
+ };
4686
+ }
4687
+ if (this.check([71]) && this.check([71], { offset: 188 })) {
4688
+ return {
4689
+ ext: "mts",
4690
+ mime: "video/mp2t"
4691
+ };
4692
+ }
4693
+ if (this.check([71], { offset: 4 }) && this.check([71], { offset: 196 })) {
4694
+ return {
4695
+ ext: "mts",
4696
+ mime: "video/mp2t"
4697
+ };
4698
+ }
4699
+ if (this.check([66, 79, 79, 75, 77, 79, 66, 73], { offset: 60 })) {
4700
+ return {
4701
+ ext: "mobi",
4702
+ mime: "application/x-mobipocket-ebook"
4703
+ };
4704
+ }
4705
+ if (this.check([68, 73, 67, 77], { offset: 128 })) {
4706
+ return {
4707
+ ext: "dcm",
4708
+ mime: "application/dicom"
4709
+ };
4710
+ }
4711
+ if (this.check([76, 0, 0, 0, 1, 20, 2, 0, 0, 0, 0, 0, 192, 0, 0, 0, 0, 0, 0, 70])) {
4712
+ return {
4713
+ ext: "lnk",
4714
+ mime: "application/x-ms-shortcut"
4715
+ // Informal, used by freedesktop.org shared-mime-info
4716
+ };
4717
+ }
4718
+ if (this.check([98, 111, 111, 107, 0, 0, 0, 0, 109, 97, 114, 107, 0, 0, 0, 0])) {
4719
+ return {
4720
+ ext: "alias",
4721
+ mime: "application/x-ft-apple.alias"
4722
+ };
4723
+ }
4724
+ if (this.checkString("Kaydara FBX Binary \0")) {
4725
+ return {
4726
+ ext: "fbx",
4727
+ mime: "application/x-ft-fbx"
4728
+ };
4729
+ }
4730
+ if (this.check([76, 80], { offset: 34 }) && (this.check([0, 0, 1], { offset: 8 }) || this.check([1, 0, 2], { offset: 8 }) || this.check([2, 0, 2], { offset: 8 }))) {
4731
+ return {
4732
+ ext: "eot",
4733
+ mime: "application/vnd.ms-fontobject"
4734
+ };
4735
+ }
4736
+ if (this.check([6, 6, 237, 245, 216, 29, 70, 229, 189, 49, 239, 231, 254, 116, 183, 29])) {
4737
+ return {
4738
+ ext: "indd",
4739
+ mime: "application/x-indesign"
4740
+ };
4741
+ }
4742
+ if (this.check([255, 255, 0, 0, 7, 0, 0, 0, 4, 0, 0, 0, 1, 0, 1, 0]) || this.check([0, 0, 255, 255, 0, 0, 0, 7, 0, 0, 0, 4, 0, 1, 0, 1])) {
4743
+ return {
4744
+ ext: "jmp",
4745
+ mime: "application/x-jmp-data"
4746
+ };
4747
+ }
4748
+ await tokenizer.peekBuffer(this.buffer, { length: Math.min(512, tokenizer.fileInfo.size), mayBeLess: true });
4749
+ if (this.checkString("ustar", { offset: 257 }) && (this.checkString("\0", { offset: 262 }) || this.checkString(" ", { offset: 262 })) || this.check([0, 0, 0, 0, 0, 0], { offset: 257 }) && tarHeaderChecksumMatches(this.buffer)) {
4750
+ return {
4751
+ ext: "tar",
4752
+ mime: "application/x-tar"
4753
+ };
4754
+ }
4755
+ if (this.check([255, 254])) {
4756
+ const encoding = "utf-16le";
4757
+ if (this.checkString("<?xml ", { offset: 2, encoding })) {
4758
+ return {
4759
+ ext: "xml",
4760
+ mime: "application/xml"
4761
+ };
4762
+ }
4763
+ if (this.check([255, 14], { offset: 2 }) && this.checkString("SketchUp Model", { offset: 4, encoding })) {
4764
+ return {
4765
+ ext: "skp",
4766
+ mime: "application/vnd.sketchup.skp"
4767
+ };
4768
+ }
4769
+ if (this.checkString("Windows Registry Editor Version 5.00\r\n", { offset: 2, encoding })) {
4770
+ return {
4771
+ ext: "reg",
4772
+ mime: "application/x-ms-regedit"
4773
+ };
4774
+ }
4775
+ return void 0;
4776
+ }
4777
+ if (this.checkString("-----BEGIN PGP MESSAGE-----")) {
4778
+ return {
4779
+ ext: "pgp",
4780
+ mime: "application/pgp-encrypted"
4781
+ };
4782
+ }
4783
+ };
4784
+ // Detections with limited supporting data, resulting in a higher likelihood of false positives
4785
+ detectImprecise = async (tokenizer) => {
4786
+ this.buffer = new Uint8Array(reasonableDetectionSizeInBytes);
4787
+ const fileSize = getKnownFileSizeOrMaximum(tokenizer.fileInfo.size);
4788
+ await tokenizer.peekBuffer(this.buffer, { length: Math.min(8, fileSize), mayBeLess: true });
4789
+ if (this.check([0, 0, 1, 186]) || this.check([0, 0, 1, 179])) {
4790
+ return {
4791
+ ext: "mpg",
4792
+ mime: "video/mpeg"
4793
+ };
4794
+ }
4795
+ if (this.check([0, 1, 0, 0, 0])) {
4796
+ return {
4797
+ ext: "ttf",
4798
+ mime: "font/ttf"
4799
+ };
4800
+ }
4801
+ if (this.check([0, 0, 1, 0])) {
4802
+ return {
4803
+ ext: "ico",
4804
+ mime: "image/x-icon"
4805
+ };
4806
+ }
4807
+ if (this.check([0, 0, 2, 0])) {
4808
+ return {
4809
+ ext: "cur",
4810
+ mime: "image/x-icon"
4811
+ };
4812
+ }
4813
+ await tokenizer.peekBuffer(this.buffer, { length: Math.min(2 + this.options.mpegOffsetTolerance, fileSize), mayBeLess: true });
4814
+ if (this.buffer.length >= 2 + this.options.mpegOffsetTolerance) {
4815
+ for (let depth = 0; depth <= this.options.mpegOffsetTolerance; ++depth) {
4816
+ const type = this.scanMpeg(depth);
4817
+ if (type) {
4818
+ return type;
4819
+ }
4820
+ }
4821
+ }
4822
+ };
4823
+ async readTiffTag(bigEndian) {
4824
+ const tagId = await this.tokenizer.readToken(bigEndian ? UINT16_BE : UINT16_LE);
4825
+ await this.tokenizer.ignore(10);
4826
+ switch (tagId) {
4827
+ case 50341:
4828
+ return {
4829
+ ext: "arw",
4830
+ mime: "image/x-sony-arw"
4831
+ };
4832
+ case 50706:
4833
+ return {
4834
+ ext: "dng",
4835
+ mime: "image/x-adobe-dng"
4836
+ };
4837
+ default:
4838
+ }
4839
+ }
4840
+ async readTiffIFD(bigEndian) {
4841
+ const numberOfTags = await this.tokenizer.readToken(bigEndian ? UINT16_BE : UINT16_LE);
4842
+ if (numberOfTags > maximumTiffTagCount) {
4843
+ return;
4844
+ }
4845
+ if (hasUnknownFileSize(this.tokenizer) && 2 + numberOfTags * 12 > maximumTiffIfdOffsetInBytes) {
4846
+ return;
4847
+ }
4848
+ for (let n = 0; n < numberOfTags; ++n) {
4849
+ const fileType = await this.readTiffTag(bigEndian);
4850
+ if (fileType) {
4851
+ return fileType;
4852
+ }
4853
+ }
4854
+ }
4855
+ async readTiffHeader(bigEndian) {
4856
+ const tiffFileType = {
4857
+ ext: "tif",
4858
+ mime: "image/tiff"
4859
+ };
4860
+ const version = (bigEndian ? UINT16_BE : UINT16_LE).get(this.buffer, 2);
4861
+ const ifdOffset = (bigEndian ? UINT32_BE : UINT32_LE).get(this.buffer, 4);
4862
+ if (version === 42) {
4863
+ if (ifdOffset >= 6) {
4864
+ if (this.checkString("CR", { offset: 8 })) {
4865
+ return {
4866
+ ext: "cr2",
4867
+ mime: "image/x-canon-cr2"
4868
+ };
4869
+ }
4870
+ if (ifdOffset >= 8) {
4871
+ const someId1 = (bigEndian ? UINT16_BE : UINT16_LE).get(this.buffer, 8);
4872
+ const someId2 = (bigEndian ? UINT16_BE : UINT16_LE).get(this.buffer, 10);
4873
+ if (someId1 === 28 && someId2 === 254 || someId1 === 31 && someId2 === 11) {
4874
+ return {
4875
+ ext: "nef",
4876
+ mime: "image/x-nikon-nef"
4877
+ };
4878
+ }
4879
+ }
4880
+ }
4881
+ if (hasUnknownFileSize(this.tokenizer) && ifdOffset > maximumTiffStreamIfdOffsetInBytes) {
4882
+ return tiffFileType;
4883
+ }
4884
+ const maximumTiffOffset = hasUnknownFileSize(this.tokenizer) ? maximumTiffIfdOffsetInBytes : this.tokenizer.fileInfo.size;
4885
+ try {
4886
+ await safeIgnore(this.tokenizer, ifdOffset, {
4887
+ maximumLength: maximumTiffOffset,
4888
+ reason: "TIFF IFD offset"
4889
+ });
4890
+ } catch (error) {
4891
+ if (error instanceof EndOfStreamError) {
4892
+ return;
4893
+ }
4894
+ throw error;
4895
+ }
4896
+ let fileType;
4897
+ try {
4898
+ fileType = await this.readTiffIFD(bigEndian);
4899
+ } catch (error) {
4900
+ if (error instanceof EndOfStreamError) {
4901
+ return;
4902
+ }
4903
+ throw error;
4904
+ }
4905
+ return fileType ?? tiffFileType;
4906
+ }
4907
+ if (version === 43) {
4908
+ return tiffFileType;
4909
+ }
4910
+ }
4911
+ /**
4912
+ Scan check MPEG 1 or 2 Layer 3 header, or 'layer 0' for ADTS (MPEG sync-word 0xFFE).
4913
+
4914
+ @param offset - Offset to scan for sync-preamble.
4915
+ @returns {{ext: string, mime: string}}
4916
+ */
4917
+ scanMpeg(offset) {
4918
+ if (this.check([255, 224], { offset, mask: [255, 224] })) {
4919
+ if (this.check([16], { offset: offset + 1, mask: [22] })) {
4920
+ if (this.check([8], { offset: offset + 1, mask: [8] })) {
4921
+ return {
4922
+ ext: "aac",
4923
+ mime: "audio/aac"
4924
+ };
4925
+ }
4926
+ return {
4927
+ ext: "aac",
4928
+ mime: "audio/aac"
4929
+ };
4930
+ }
4931
+ if (this.check([2], { offset: offset + 1, mask: [6] })) {
4932
+ return {
4933
+ ext: "mp3",
4934
+ mime: "audio/mpeg"
4935
+ };
4936
+ }
4937
+ if (this.check([4], { offset: offset + 1, mask: [6] })) {
4938
+ return {
4939
+ ext: "mp2",
4940
+ mime: "audio/mpeg"
4941
+ };
4942
+ }
4943
+ if (this.check([6], { offset: offset + 1, mask: [6] })) {
4944
+ return {
4945
+ ext: "mp1",
4946
+ mime: "audio/mpeg"
4947
+ };
4948
+ }
4949
+ }
4950
+ }
4951
+ };
4952
+ supportedExtensions = new Set(extensions);
4953
+ supportedMimeTypes = new Set(mimeTypes);
4954
+ }
4955
+ });
4956
+ init_source();
4957
+ export {
4958
+ FileTypeParser,
4959
+ fileTypeFromBlob,
4960
+ fileTypeFromBuffer,
4961
+ fileTypeFromFile,
4962
+ fileTypeFromStream,
4963
+ fileTypeFromTokenizer,
4964
+ fileTypeStream,
4965
+ normalizeSampleSize,
4966
+ reasonableDetectionSizeInBytes,
4967
+ supportedExtensions,
4968
+ supportedMimeTypes
4969
+ };
4970
+ /*! Bundled license information:
4971
+
4972
+ ieee754/index.js:
4973
+ (*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> *)
4974
+ */