opfs-worker 1.2.3 → 1.2.4

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,1329 @@
1
+ class g extends Error {
2
+ constructor(t, e, n, i) {
3
+ super(t, { cause: i }), this.code = e, this.path = n, this.name = "OPFSError";
4
+ }
5
+ }
6
+ class it extends g {
7
+ constructor(t) {
8
+ super("OPFS is not supported in this browser", "OPFS_NOT_SUPPORTED", void 0, t);
9
+ }
10
+ }
11
+ class we extends g {
12
+ constructor(t) {
13
+ super("OPFS is not mounted", "OPFS_NOT_MOUNTED", void 0, t);
14
+ }
15
+ }
16
+ class ye extends g {
17
+ constructor(t, e, n) {
18
+ super(t, "INVALID_PATH", e, n);
19
+ }
20
+ }
21
+ class Ee extends g {
22
+ constructor(t, e) {
23
+ super(`File not found: ${t}`, "FILE_NOT_FOUND", t, e);
24
+ }
25
+ }
26
+ class Se extends g {
27
+ constructor(t, e) {
28
+ super(`Directory not found: ${t}`, "DIRECTORY_NOT_FOUND", t, e);
29
+ }
30
+ }
31
+ class xe extends g {
32
+ constructor(t, e, n) {
33
+ super(`Permission denied for ${e} on: ${t}`, "PERMISSION_DENIED", t, n);
34
+ }
35
+ }
36
+ class Ne extends g {
37
+ constructor(t, e, n) {
38
+ super(t, "STORAGE_ERROR", e, n);
39
+ }
40
+ }
41
+ class Oe extends g {
42
+ constructor(t, e, n) {
43
+ super(`Operation timed out: ${t}`, "TIMEOUT_ERROR", e, n);
44
+ }
45
+ }
46
+ function be(s, t, e, n) {
47
+ const i = `${s.toUpperCase()}_FAILED`;
48
+ return new g(`Failed to ${s} file descriptor: ${t}`, i, e, n);
49
+ }
50
+ function rt(s, t) {
51
+ const e = t?.path, n = t?.isDirectory;
52
+ switch (s.name) {
53
+ case "InvalidStateError":
54
+ return new g(`File is busy: ${e || "unknown"}`, "EBUSY", e, s);
55
+ case "QuotaExceededError":
56
+ return new g(`No space left on device: ${e || "unknown"}`, "ENOSPC", e, s);
57
+ case "NotFoundError":
58
+ return new g(`No such file or directory: ${e || "unknown"}`, "ENOENT", e, s);
59
+ case "TypeMismatchError":
60
+ return n !== void 0 ? n ? new g(`Not a directory: ${e || "unknown"}`, "ENOTDIR", e, s) : new g(`Is a directory: ${e || "unknown"}`, "EISDIR", e, s) : new g(`Type mismatch: ${e || "unknown"}`, "EINVAL", e, s);
61
+ case "NotAllowedError":
62
+ case "SecurityError":
63
+ return new g(`Permission denied: ${e || "unknown"}`, "EACCES", e, s);
64
+ case "InvalidModificationError":
65
+ return new g(`Invalid modification: ${e || "unknown"}`, "EINVAL", e, s);
66
+ case "AbortError":
67
+ return new g(`Operation aborted: ${e || "unknown"}`, "EINTR", e, s);
68
+ case "OperationError":
69
+ return new g(`Operation failed: ${e || "unknown"}`, "EIO", e, s);
70
+ case "TypeError":
71
+ return new g(`Operation not supported: ${e || "unknown"}`, "ENOTSUP", e, s);
72
+ default:
73
+ return new g(`I/O error: ${e || "unknown"}`, "EIO", e, s);
74
+ }
75
+ }
76
+ const ot = [
77
+ // Images
78
+ ".jpg",
79
+ ".jpeg",
80
+ ".png",
81
+ ".gif",
82
+ ".bmp",
83
+ ".webp",
84
+ ".ico",
85
+ ".tiff",
86
+ ".tga",
87
+ // Audio
88
+ ".mp3",
89
+ ".wav",
90
+ ".ogg",
91
+ ".flac",
92
+ ".aac",
93
+ ".wma",
94
+ ".m4a",
95
+ // Video
96
+ ".mp4",
97
+ ".avi",
98
+ ".mov",
99
+ ".wmv",
100
+ ".flv",
101
+ ".webm",
102
+ ".mkv",
103
+ ".m4v",
104
+ // Documents
105
+ ".pdf",
106
+ ".doc",
107
+ ".docx",
108
+ ".xls",
109
+ ".xlsx",
110
+ ".ppt",
111
+ ".pptx",
112
+ // Archives
113
+ ".zip",
114
+ ".rar",
115
+ ".7z",
116
+ ".tar",
117
+ ".gz",
118
+ ".bz2",
119
+ // Executables
120
+ ".exe",
121
+ ".dll",
122
+ ".so",
123
+ ".dylib",
124
+ // Other binary formats
125
+ ".dat",
126
+ ".db",
127
+ ".sqlite",
128
+ ".bin",
129
+ ".obj",
130
+ ".fbx",
131
+ ".3ds"
132
+ ];
133
+ function Ae(s) {
134
+ const t = s.lastIndexOf(".");
135
+ if (t <= 0)
136
+ return !0;
137
+ const e = s.slice(t).toLowerCase();
138
+ return ot.includes(e);
139
+ }
140
+ function ct(s, t = "utf-8") {
141
+ switch (t) {
142
+ case "utf8":
143
+ case "utf-8":
144
+ return new TextEncoder().encode(s);
145
+ case "utf16le":
146
+ case "utf-16le":
147
+ case "ucs2":
148
+ case "ucs-2":
149
+ return at(s);
150
+ case "ascii":
151
+ return ut(s);
152
+ case "latin1":
153
+ return lt(s);
154
+ case "binary":
155
+ return Uint8Array.from(s, (e) => e.charCodeAt(0));
156
+ case "base64":
157
+ return Uint8Array.from(atob(s), (e) => e.charCodeAt(0));
158
+ case "hex":
159
+ if (!/^[\da-f]+$/i.test(s) || s.length % 2 !== 0)
160
+ throw new g("Invalid hex string", "INVALID_HEX_FORMAT");
161
+ return Uint8Array.from(s.match(/.{1,2}/g).map((e) => parseInt(e, 16)));
162
+ default:
163
+ return console.warn("Encoding not supported, falling back to UTF-8"), new TextEncoder().encode(s);
164
+ }
165
+ }
166
+ function ve(s, t = "utf-8") {
167
+ switch (t) {
168
+ case "utf8":
169
+ case "utf-8":
170
+ return new TextDecoder().decode(s);
171
+ case "utf16le":
172
+ case "utf-16le":
173
+ case "ucs2":
174
+ case "ucs-2":
175
+ return ht(s);
176
+ case "latin1":
177
+ return String.fromCharCode(...s);
178
+ case "ascii":
179
+ return String.fromCharCode(...s.map((e) => e & 127));
180
+ case "base64":
181
+ return btoa(String.fromCharCode(...s));
182
+ case "hex":
183
+ return Array.from(s).map((e) => e.toString(16).padStart(2, "0")).join("");
184
+ default:
185
+ return console.warn("Unsupported encoding, falling back to UTF-8"), new TextDecoder().decode(s);
186
+ }
187
+ }
188
+ function at(s) {
189
+ const t = new Uint8Array(s.length * 2);
190
+ for (let e = 0; e < s.length; e++) {
191
+ const n = s.charCodeAt(e);
192
+ t[e * 2] = n & 255, t[e * 2 + 1] = n >> 8;
193
+ }
194
+ return t;
195
+ }
196
+ function ht(s) {
197
+ s.length % 2 !== 0 && (console.warn("Invalid UTF-16LE buffer length, truncating last byte"), s = s.slice(0, s.length - 1));
198
+ const t = new Uint16Array(s.buffer, s.byteOffset, s.byteLength / 2);
199
+ return String.fromCharCode(...t);
200
+ }
201
+ function lt(s) {
202
+ const t = new Uint8Array(s.length);
203
+ for (let e = 0; e < s.length; e++)
204
+ t[e] = s.charCodeAt(e) & 255;
205
+ return t;
206
+ }
207
+ function ut(s) {
208
+ const t = new Uint8Array(s.length);
209
+ for (let e = 0; e < s.length; e++)
210
+ t[e] = s.charCodeAt(e) & 127;
211
+ return t;
212
+ }
213
+ var ft = /* @__PURE__ */ ((s) => (s.Added = "added", s.Changed = "changed", s.Removed = "removed", s))(ft || {});
214
+ const G = (s, t, e) => {
215
+ const n = s instanceof RegExp ? j(s, e) : s, i = t instanceof RegExp ? j(t, e) : t, r = n !== null && i != null && pt(n, i, e);
216
+ return r && {
217
+ start: r[0],
218
+ end: r[1],
219
+ pre: e.slice(0, r[0]),
220
+ body: e.slice(r[0] + n.length, r[1]),
221
+ post: e.slice(r[1] + i.length)
222
+ };
223
+ }, j = (s, t) => {
224
+ const e = t.match(s);
225
+ return e ? e[0] : null;
226
+ }, pt = (s, t, e) => {
227
+ let n, i, r, o, a, h = e.indexOf(s), l = e.indexOf(t, h + 1), c = h;
228
+ if (h >= 0 && l > 0) {
229
+ if (s === t)
230
+ return [h, l];
231
+ for (n = [], r = e.length; c >= 0 && !a; ) {
232
+ if (c === h)
233
+ n.push(c), h = e.indexOf(s, c + 1);
234
+ else if (n.length === 1) {
235
+ const p = n.pop();
236
+ p !== void 0 && (a = [p, l]);
237
+ } else
238
+ i = n.pop(), i !== void 0 && i < r && (r = i, o = l), l = e.indexOf(t, c + 1);
239
+ c = h < l && h >= 0 ? h : l;
240
+ }
241
+ n.length && o !== void 0 && (a = [r, o]);
242
+ }
243
+ return a;
244
+ }, H = "\0SLASH" + Math.random() + "\0", V = "\0OPEN" + Math.random() + "\0", L = "\0CLOSE" + Math.random() + "\0", Z = "\0COMMA" + Math.random() + "\0", Y = "\0PERIOD" + Math.random() + "\0", dt = new RegExp(H, "g"), gt = new RegExp(V, "g"), mt = new RegExp(L, "g"), wt = new RegExp(Z, "g"), yt = new RegExp(Y, "g"), Et = /\\\\/g, St = /\\{/g, xt = /\\}/g, Nt = /\\,/g, Ot = /\\./g;
245
+ function D(s) {
246
+ return isNaN(s) ? s.charCodeAt(0) : parseInt(s, 10);
247
+ }
248
+ function bt(s) {
249
+ return s.replace(Et, H).replace(St, V).replace(xt, L).replace(Nt, Z).replace(Ot, Y);
250
+ }
251
+ function At(s) {
252
+ return s.replace(dt, "\\").replace(gt, "{").replace(mt, "}").replace(wt, ",").replace(yt, ".");
253
+ }
254
+ function J(s) {
255
+ if (!s)
256
+ return [""];
257
+ const t = [], e = G("{", "}", s);
258
+ if (!e)
259
+ return s.split(",");
260
+ const { pre: n, body: i, post: r } = e, o = n.split(",");
261
+ o[o.length - 1] += "{" + i + "}";
262
+ const a = J(r);
263
+ return r.length && (o[o.length - 1] += a.shift(), o.push.apply(o, a)), t.push.apply(t, o), t;
264
+ }
265
+ function vt(s) {
266
+ return s ? (s.slice(0, 2) === "{}" && (s = "\\{\\}" + s.slice(2)), T(bt(s), !0).map(At)) : [];
267
+ }
268
+ function $t(s) {
269
+ return "{" + s + "}";
270
+ }
271
+ function Tt(s) {
272
+ return /^-?0\d/.test(s);
273
+ }
274
+ function Mt(s, t) {
275
+ return s <= t;
276
+ }
277
+ function Pt(s, t) {
278
+ return s >= t;
279
+ }
280
+ function T(s, t) {
281
+ const e = [], n = G("{", "}", s);
282
+ if (!n)
283
+ return [s];
284
+ const i = n.pre, r = n.post.length ? T(n.post, !1) : [""];
285
+ if (/\$$/.test(n.pre))
286
+ for (let o = 0; o < r.length; o++) {
287
+ const a = i + "{" + n.body + "}" + r[o];
288
+ e.push(a);
289
+ }
290
+ else {
291
+ const o = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(n.body), a = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(n.body), h = o || a, l = n.body.indexOf(",") >= 0;
292
+ if (!h && !l)
293
+ return n.post.match(/,(?!,).*\}/) ? (s = n.pre + "{" + n.body + L + n.post, T(s)) : [s];
294
+ let c;
295
+ if (h)
296
+ c = n.body.split(/\.\./);
297
+ else if (c = J(n.body), c.length === 1 && c[0] !== void 0 && (c = T(c[0], !1).map($t), c.length === 1))
298
+ return r.map((f) => n.pre + c[0] + f);
299
+ let p;
300
+ if (h && c[0] !== void 0 && c[1] !== void 0) {
301
+ const f = D(c[0]), u = D(c[1]), m = Math.max(c[0].length, c[1].length);
302
+ let d = c.length === 3 && c[2] !== void 0 ? Math.abs(D(c[2])) : 1, S = Mt;
303
+ u < f && (d *= -1, S = Pt);
304
+ const A = c.some(Tt);
305
+ p = [];
306
+ for (let x = f; S(x, u); x += d) {
307
+ let w;
308
+ if (a)
309
+ w = String.fromCharCode(x), w === "\\" && (w = "");
310
+ else if (w = String(x), A) {
311
+ const v = m - w.length;
312
+ if (v > 0) {
313
+ const P = new Array(v + 1).join("0");
314
+ x < 0 ? w = "-" + P + w.slice(1) : w = P + w;
315
+ }
316
+ }
317
+ p.push(w);
318
+ }
319
+ } else {
320
+ p = [];
321
+ for (let f = 0; f < c.length; f++)
322
+ p.push.apply(p, T(c[f], !1));
323
+ }
324
+ for (let f = 0; f < p.length; f++)
325
+ for (let u = 0; u < r.length; u++) {
326
+ const m = i + p[f] + r[u];
327
+ (!t || h || m) && e.push(m);
328
+ }
329
+ }
330
+ return e;
331
+ }
332
+ const Rt = 1024 * 64, C = (s) => {
333
+ if (typeof s != "string")
334
+ throw new TypeError("invalid pattern");
335
+ if (s.length > Rt)
336
+ throw new TypeError("pattern is too long");
337
+ }, Ct = {
338
+ "[:alnum:]": ["\\p{L}\\p{Nl}\\p{Nd}", !0],
339
+ "[:alpha:]": ["\\p{L}\\p{Nl}", !0],
340
+ "[:ascii:]": ["\\x00-\\x7f", !1],
341
+ "[:blank:]": ["\\p{Zs}\\t", !0],
342
+ "[:cntrl:]": ["\\p{Cc}", !0],
343
+ "[:digit:]": ["\\p{Nd}", !0],
344
+ "[:graph:]": ["\\p{Z}\\p{C}", !0, !0],
345
+ "[:lower:]": ["\\p{Ll}", !0],
346
+ "[:print:]": ["\\p{C}", !0],
347
+ "[:punct:]": ["\\p{P}", !0],
348
+ "[:space:]": ["\\p{Z}\\t\\r\\n\\v\\f", !0],
349
+ "[:upper:]": ["\\p{Lu}", !0],
350
+ "[:word:]": ["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}", !0],
351
+ "[:xdigit:]": ["A-Fa-f0-9", !1]
352
+ }, $ = (s) => s.replace(/[[\]\\-]/g, "\\$&"), It = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), U = (s) => s.join(""), Dt = (s, t) => {
353
+ const e = t;
354
+ if (s.charAt(e) !== "[")
355
+ throw new Error("not in a brace expression");
356
+ const n = [], i = [];
357
+ let r = e + 1, o = !1, a = !1, h = !1, l = !1, c = e, p = "";
358
+ t: for (; r < s.length; ) {
359
+ const d = s.charAt(r);
360
+ if ((d === "!" || d === "^") && r === e + 1) {
361
+ l = !0, r++;
362
+ continue;
363
+ }
364
+ if (d === "]" && o && !h) {
365
+ c = r + 1;
366
+ break;
367
+ }
368
+ if (o = !0, d === "\\" && !h) {
369
+ h = !0, r++;
370
+ continue;
371
+ }
372
+ if (d === "[" && !h) {
373
+ for (const [S, [b, A, x]] of Object.entries(Ct))
374
+ if (s.startsWith(S, r)) {
375
+ if (p)
376
+ return ["$.", !1, s.length - e, !0];
377
+ r += S.length, x ? i.push(b) : n.push(b), a = a || A;
378
+ continue t;
379
+ }
380
+ }
381
+ if (h = !1, p) {
382
+ d > p ? n.push($(p) + "-" + $(d)) : d === p && n.push($(d)), p = "", r++;
383
+ continue;
384
+ }
385
+ if (s.startsWith("-]", r + 1)) {
386
+ n.push($(d + "-")), r += 2;
387
+ continue;
388
+ }
389
+ if (s.startsWith("-", r + 1)) {
390
+ p = d, r += 2;
391
+ continue;
392
+ }
393
+ n.push($(d)), r++;
394
+ }
395
+ if (c < r)
396
+ return ["", !1, 0, !1];
397
+ if (!n.length && !i.length)
398
+ return ["$.", !1, s.length - e, !0];
399
+ if (i.length === 0 && n.length === 1 && /^\\?.$/.test(n[0]) && !l) {
400
+ const d = n[0].length === 2 ? n[0].slice(-1) : n[0];
401
+ return [It(d), !1, c - e, !1];
402
+ }
403
+ const f = "[" + (l ? "^" : "") + U(n) + "]", u = "[" + (l ? "" : "^") + U(i) + "]";
404
+ return [n.length && i.length ? "(" + f + "|" + u + ")" : n.length ? f : u, a, c - e, !0];
405
+ }, M = (s, { windowsPathsNoEscape: t = !1 } = {}) => t ? s.replace(/\[([^\/\\])\]/g, "$1") : s.replace(/((?!\\).|^)\[([^\/\\])\]/g, "$1$2").replace(/\\([^\/])/g, "$1"), Lt = /* @__PURE__ */ new Set(["!", "?", "+", "*", "@"]), W = (s) => Lt.has(s), kt = "(?!(?:^|/)\\.\\.?(?:$|/))", R = "(?!\\.)", Ft = /* @__PURE__ */ new Set(["[", "."]), jt = /* @__PURE__ */ new Set(["..", "."]), Ut = new Set("().*{}+?[]^$\\!"), Wt = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), k = "[^/]", z = k + "*?", _ = k + "+?";
406
+ class E {
407
+ type;
408
+ #s;
409
+ #n;
410
+ #r = !1;
411
+ #t = [];
412
+ #e;
413
+ #o;
414
+ #a;
415
+ #c = !1;
416
+ #i;
417
+ #h;
418
+ // set to true if it's an extglob with no children
419
+ // (which really means one child of '')
420
+ #u = !1;
421
+ constructor(t, e, n = {}) {
422
+ this.type = t, t && (this.#n = !0), this.#e = e, this.#s = this.#e ? this.#e.#s : this, this.#i = this.#s === this ? n : this.#s.#i, this.#a = this.#s === this ? [] : this.#s.#a, t === "!" && !this.#s.#c && this.#a.push(this), this.#o = this.#e ? this.#e.#t.length : 0;
423
+ }
424
+ get hasMagic() {
425
+ if (this.#n !== void 0)
426
+ return this.#n;
427
+ for (const t of this.#t)
428
+ if (typeof t != "string" && (t.type || t.hasMagic))
429
+ return this.#n = !0;
430
+ return this.#n;
431
+ }
432
+ // reconstructs the pattern
433
+ toString() {
434
+ return this.#h !== void 0 ? this.#h : this.type ? this.#h = this.type + "(" + this.#t.map((t) => String(t)).join("|") + ")" : this.#h = this.#t.map((t) => String(t)).join("");
435
+ }
436
+ #p() {
437
+ if (this !== this.#s)
438
+ throw new Error("should only call on root");
439
+ if (this.#c)
440
+ return this;
441
+ this.toString(), this.#c = !0;
442
+ let t;
443
+ for (; t = this.#a.pop(); ) {
444
+ if (t.type !== "!")
445
+ continue;
446
+ let e = t, n = e.#e;
447
+ for (; n; ) {
448
+ for (let i = e.#o + 1; !n.type && i < n.#t.length; i++)
449
+ for (const r of t.#t) {
450
+ if (typeof r == "string")
451
+ throw new Error("string part in extglob AST??");
452
+ r.copyIn(n.#t[i]);
453
+ }
454
+ e = n, n = e.#e;
455
+ }
456
+ }
457
+ return this;
458
+ }
459
+ push(...t) {
460
+ for (const e of t)
461
+ if (e !== "") {
462
+ if (typeof e != "string" && !(e instanceof E && e.#e === this))
463
+ throw new Error("invalid part: " + e);
464
+ this.#t.push(e);
465
+ }
466
+ }
467
+ toJSON() {
468
+ const t = this.type === null ? this.#t.slice().map((e) => typeof e == "string" ? e : e.toJSON()) : [this.type, ...this.#t.map((e) => e.toJSON())];
469
+ return this.isStart() && !this.type && t.unshift([]), this.isEnd() && (this === this.#s || this.#s.#c && this.#e?.type === "!") && t.push({}), t;
470
+ }
471
+ isStart() {
472
+ if (this.#s === this)
473
+ return !0;
474
+ if (!this.#e?.isStart())
475
+ return !1;
476
+ if (this.#o === 0)
477
+ return !0;
478
+ const t = this.#e;
479
+ for (let e = 0; e < this.#o; e++) {
480
+ const n = t.#t[e];
481
+ if (!(n instanceof E && n.type === "!"))
482
+ return !1;
483
+ }
484
+ return !0;
485
+ }
486
+ isEnd() {
487
+ if (this.#s === this || this.#e?.type === "!")
488
+ return !0;
489
+ if (!this.#e?.isEnd())
490
+ return !1;
491
+ if (!this.type)
492
+ return this.#e?.isEnd();
493
+ const t = this.#e ? this.#e.#t.length : 0;
494
+ return this.#o === t - 1;
495
+ }
496
+ copyIn(t) {
497
+ typeof t == "string" ? this.push(t) : this.push(t.clone(this));
498
+ }
499
+ clone(t) {
500
+ const e = new E(this.type, t);
501
+ for (const n of this.#t)
502
+ e.copyIn(n);
503
+ return e;
504
+ }
505
+ static #l(t, e, n, i) {
506
+ let r = !1, o = !1, a = -1, h = !1;
507
+ if (e.type === null) {
508
+ let u = n, m = "";
509
+ for (; u < t.length; ) {
510
+ const d = t.charAt(u++);
511
+ if (r || d === "\\") {
512
+ r = !r, m += d;
513
+ continue;
514
+ }
515
+ if (o) {
516
+ u === a + 1 ? (d === "^" || d === "!") && (h = !0) : d === "]" && !(u === a + 2 && h) && (o = !1), m += d;
517
+ continue;
518
+ } else if (d === "[") {
519
+ o = !0, a = u, h = !1, m += d;
520
+ continue;
521
+ }
522
+ if (!i.noext && W(d) && t.charAt(u) === "(") {
523
+ e.push(m), m = "";
524
+ const S = new E(d, e);
525
+ u = E.#l(t, S, u, i), e.push(S);
526
+ continue;
527
+ }
528
+ m += d;
529
+ }
530
+ return e.push(m), u;
531
+ }
532
+ let l = n + 1, c = new E(null, e);
533
+ const p = [];
534
+ let f = "";
535
+ for (; l < t.length; ) {
536
+ const u = t.charAt(l++);
537
+ if (r || u === "\\") {
538
+ r = !r, f += u;
539
+ continue;
540
+ }
541
+ if (o) {
542
+ l === a + 1 ? (u === "^" || u === "!") && (h = !0) : u === "]" && !(l === a + 2 && h) && (o = !1), f += u;
543
+ continue;
544
+ } else if (u === "[") {
545
+ o = !0, a = l, h = !1, f += u;
546
+ continue;
547
+ }
548
+ if (W(u) && t.charAt(l) === "(") {
549
+ c.push(f), f = "";
550
+ const m = new E(u, c);
551
+ c.push(m), l = E.#l(t, m, l, i);
552
+ continue;
553
+ }
554
+ if (u === "|") {
555
+ c.push(f), f = "", p.push(c), c = new E(null, e);
556
+ continue;
557
+ }
558
+ if (u === ")")
559
+ return f === "" && e.#t.length === 0 && (e.#u = !0), c.push(f), f = "", e.push(...p, c), l;
560
+ f += u;
561
+ }
562
+ return e.type = null, e.#n = void 0, e.#t = [t.substring(n - 1)], l;
563
+ }
564
+ static fromGlob(t, e = {}) {
565
+ const n = new E(null, void 0, e);
566
+ return E.#l(t, n, 0, e), n;
567
+ }
568
+ // returns the regular expression if there's magic, or the unescaped
569
+ // string if not.
570
+ toMMPattern() {
571
+ if (this !== this.#s)
572
+ return this.#s.toMMPattern();
573
+ const t = this.toString(), [e, n, i, r] = this.toRegExpSource();
574
+ if (!(i || this.#n || this.#i.nocase && !this.#i.nocaseMagicOnly && t.toUpperCase() !== t.toLowerCase()))
575
+ return n;
576
+ const a = (this.#i.nocase ? "i" : "") + (r ? "u" : "");
577
+ return Object.assign(new RegExp(`^${e}$`, a), {
578
+ _src: e,
579
+ _glob: t
580
+ });
581
+ }
582
+ get options() {
583
+ return this.#i;
584
+ }
585
+ // returns the string match, the regexp source, whether there's magic
586
+ // in the regexp (so a regular expression is required) and whether or
587
+ // not the uflag is needed for the regular expression (for posix classes)
588
+ // TODO: instead of injecting the start/end at this point, just return
589
+ // the BODY of the regexp, along with the start/end portions suitable
590
+ // for binding the start/end in either a joined full-path makeRe context
591
+ // (where we bind to (^|/), or a standalone matchPart context (where
592
+ // we bind to ^, and not /). Otherwise slashes get duped!
593
+ //
594
+ // In part-matching mode, the start is:
595
+ // - if not isStart: nothing
596
+ // - if traversal possible, but not allowed: ^(?!\.\.?$)
597
+ // - if dots allowed or not possible: ^
598
+ // - if dots possible and not allowed: ^(?!\.)
599
+ // end is:
600
+ // - if not isEnd(): nothing
601
+ // - else: $
602
+ //
603
+ // In full-path matching mode, we put the slash at the START of the
604
+ // pattern, so start is:
605
+ // - if first pattern: same as part-matching mode
606
+ // - if not isStart(): nothing
607
+ // - if traversal possible, but not allowed: /(?!\.\.?(?:$|/))
608
+ // - if dots allowed or not possible: /
609
+ // - if dots possible and not allowed: /(?!\.)
610
+ // end is:
611
+ // - if last pattern, same as part-matching mode
612
+ // - else nothing
613
+ //
614
+ // Always put the (?:$|/) on negated tails, though, because that has to be
615
+ // there to bind the end of the negated pattern portion, and it's easier to
616
+ // just stick it in now rather than try to inject it later in the middle of
617
+ // the pattern.
618
+ //
619
+ // We can just always return the same end, and leave it up to the caller
620
+ // to know whether it's going to be used joined or in parts.
621
+ // And, if the start is adjusted slightly, can do the same there:
622
+ // - if not isStart: nothing
623
+ // - if traversal possible, but not allowed: (?:/|^)(?!\.\.?$)
624
+ // - if dots allowed or not possible: (?:/|^)
625
+ // - if dots possible and not allowed: (?:/|^)(?!\.)
626
+ //
627
+ // But it's better to have a simpler binding without a conditional, for
628
+ // performance, so probably better to return both start options.
629
+ //
630
+ // Then the caller just ignores the end if it's not the first pattern,
631
+ // and the start always gets applied.
632
+ //
633
+ // But that's always going to be $ if it's the ending pattern, or nothing,
634
+ // so the caller can just attach $ at the end of the pattern when building.
635
+ //
636
+ // So the todo is:
637
+ // - better detect what kind of start is needed
638
+ // - return both flavors of starting pattern
639
+ // - attach $ at the end of the pattern when creating the actual RegExp
640
+ //
641
+ // Ah, but wait, no, that all only applies to the root when the first pattern
642
+ // is not an extglob. If the first pattern IS an extglob, then we need all
643
+ // that dot prevention biz to live in the extglob portions, because eg
644
+ // +(*|.x*) can match .xy but not .yx.
645
+ //
646
+ // So, return the two flavors if it's #root and the first child is not an
647
+ // AST, otherwise leave it to the child AST to handle it, and there,
648
+ // use the (?:^|/) style of start binding.
649
+ //
650
+ // Even simplified further:
651
+ // - Since the start for a join is eg /(?!\.) and the start for a part
652
+ // is ^(?!\.), we can just prepend (?!\.) to the pattern (either root
653
+ // or start or whatever) and prepend ^ or / at the Regexp construction.
654
+ toRegExpSource(t) {
655
+ const e = t ?? !!this.#i.dot;
656
+ if (this.#s === this && this.#p(), !this.type) {
657
+ const h = this.isStart() && this.isEnd(), l = this.#t.map((u) => {
658
+ const [m, d, S, b] = typeof u == "string" ? E.#d(u, this.#n, h) : u.toRegExpSource(t);
659
+ return this.#n = this.#n || S, this.#r = this.#r || b, m;
660
+ }).join("");
661
+ let c = "";
662
+ if (this.isStart() && typeof this.#t[0] == "string" && !(this.#t.length === 1 && jt.has(this.#t[0]))) {
663
+ const m = Ft, d = (
664
+ // dots are allowed, and the pattern starts with [ or .
665
+ e && m.has(l.charAt(0)) || // the pattern starts with \., and then [ or .
666
+ l.startsWith("\\.") && m.has(l.charAt(2)) || // the pattern starts with \.\., and then [ or .
667
+ l.startsWith("\\.\\.") && m.has(l.charAt(4))
668
+ ), S = !e && !t && m.has(l.charAt(0));
669
+ c = d ? kt : S ? R : "";
670
+ }
671
+ let p = "";
672
+ return this.isEnd() && this.#s.#c && this.#e?.type === "!" && (p = "(?:$|\\/)"), [
673
+ c + l + p,
674
+ M(l),
675
+ this.#n = !!this.#n,
676
+ this.#r
677
+ ];
678
+ }
679
+ const n = this.type === "*" || this.type === "+", i = this.type === "!" ? "(?:(?!(?:" : "(?:";
680
+ let r = this.#f(e);
681
+ if (this.isStart() && this.isEnd() && !r && this.type !== "!") {
682
+ const h = this.toString();
683
+ return this.#t = [h], this.type = null, this.#n = void 0, [h, M(this.toString()), !1, !1];
684
+ }
685
+ let o = !n || t || e || !R ? "" : this.#f(!0);
686
+ o === r && (o = ""), o && (r = `(?:${r})(?:${o})*?`);
687
+ let a = "";
688
+ if (this.type === "!" && this.#u)
689
+ a = (this.isStart() && !e ? R : "") + _;
690
+ else {
691
+ const h = this.type === "!" ? (
692
+ // !() must match something,but !(x) can match ''
693
+ "))" + (this.isStart() && !e && !t ? R : "") + z + ")"
694
+ ) : this.type === "@" ? ")" : this.type === "?" ? ")?" : this.type === "+" && o ? ")" : this.type === "*" && o ? ")?" : `)${this.type}`;
695
+ a = i + r + h;
696
+ }
697
+ return [
698
+ a,
699
+ M(r),
700
+ this.#n = !!this.#n,
701
+ this.#r
702
+ ];
703
+ }
704
+ #f(t) {
705
+ return this.#t.map((e) => {
706
+ if (typeof e == "string")
707
+ throw new Error("string type in extglob ast??");
708
+ const [n, i, r, o] = e.toRegExpSource(t);
709
+ return this.#r = this.#r || o, n;
710
+ }).filter((e) => !(this.isStart() && this.isEnd()) || !!e).join("|");
711
+ }
712
+ static #d(t, e, n = !1) {
713
+ let i = !1, r = "", o = !1;
714
+ for (let a = 0; a < t.length; a++) {
715
+ const h = t.charAt(a);
716
+ if (i) {
717
+ i = !1, r += (Ut.has(h) ? "\\" : "") + h;
718
+ continue;
719
+ }
720
+ if (h === "\\") {
721
+ a === t.length - 1 ? r += "\\\\" : i = !0;
722
+ continue;
723
+ }
724
+ if (h === "[") {
725
+ const [l, c, p, f] = Dt(t, a);
726
+ if (p) {
727
+ r += l, o = o || c, a += p - 1, e = e || f;
728
+ continue;
729
+ }
730
+ }
731
+ if (h === "*") {
732
+ n && t === "*" ? r += _ : r += z, e = !0;
733
+ continue;
734
+ }
735
+ if (h === "?") {
736
+ r += k, e = !0;
737
+ continue;
738
+ }
739
+ r += Wt(h);
740
+ }
741
+ return [r, M(t), !!e, o];
742
+ }
743
+ }
744
+ const zt = (s, { windowsPathsNoEscape: t = !1 } = {}) => t ? s.replace(/[?*()[\]]/g, "[$&]") : s.replace(/[?*()[\]\\]/g, "\\$&"), y = (s, t, e = {}) => (C(t), !e.nocomment && t.charAt(0) === "#" ? !1 : new I(t, e).match(s)), _t = /^\*+([^+@!?\*\[\(]*)$/, Bt = (s) => (t) => !t.startsWith(".") && t.endsWith(s), qt = (s) => (t) => t.endsWith(s), Gt = (s) => (s = s.toLowerCase(), (t) => !t.startsWith(".") && t.toLowerCase().endsWith(s)), Ht = (s) => (s = s.toLowerCase(), (t) => t.toLowerCase().endsWith(s)), Vt = /^\*+\.\*+$/, Zt = (s) => !s.startsWith(".") && s.includes("."), Yt = (s) => s !== "." && s !== ".." && s.includes("."), Jt = /^\.\*+$/, Xt = (s) => s !== "." && s !== ".." && s.startsWith("."), Qt = /^\*+$/, Kt = (s) => s.length !== 0 && !s.startsWith("."), te = (s) => s.length !== 0 && s !== "." && s !== "..", ee = /^\?+([^+@!?\*\[\(]*)?$/, se = ([s, t = ""]) => {
745
+ const e = X([s]);
746
+ return t ? (t = t.toLowerCase(), (n) => e(n) && n.toLowerCase().endsWith(t)) : e;
747
+ }, ne = ([s, t = ""]) => {
748
+ const e = Q([s]);
749
+ return t ? (t = t.toLowerCase(), (n) => e(n) && n.toLowerCase().endsWith(t)) : e;
750
+ }, ie = ([s, t = ""]) => {
751
+ const e = Q([s]);
752
+ return t ? (n) => e(n) && n.endsWith(t) : e;
753
+ }, re = ([s, t = ""]) => {
754
+ const e = X([s]);
755
+ return t ? (n) => e(n) && n.endsWith(t) : e;
756
+ }, X = ([s]) => {
757
+ const t = s.length;
758
+ return (e) => e.length === t && !e.startsWith(".");
759
+ }, Q = ([s]) => {
760
+ const t = s.length;
761
+ return (e) => e.length === t && e !== "." && e !== "..";
762
+ }, K = typeof process == "object" && process ? typeof process.env == "object" && process.env && process.env.__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix", B = {
763
+ win32: { sep: "\\" },
764
+ posix: { sep: "/" }
765
+ }, oe = K === "win32" ? B.win32.sep : B.posix.sep;
766
+ y.sep = oe;
767
+ const O = Symbol("globstar **");
768
+ y.GLOBSTAR = O;
769
+ const ce = "[^/]", ae = ce + "*?", he = "(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?", le = "(?:(?!(?:\\/|^)\\.).)*?", ue = (s, t = {}) => (e) => y(e, s, t);
770
+ y.filter = ue;
771
+ const N = (s, t = {}) => Object.assign({}, s, t), fe = (s) => {
772
+ if (!s || typeof s != "object" || !Object.keys(s).length)
773
+ return y;
774
+ const t = y;
775
+ return Object.assign((n, i, r = {}) => t(n, i, N(s, r)), {
776
+ Minimatch: class extends t.Minimatch {
777
+ constructor(i, r = {}) {
778
+ super(i, N(s, r));
779
+ }
780
+ static defaults(i) {
781
+ return t.defaults(N(s, i)).Minimatch;
782
+ }
783
+ },
784
+ AST: class extends t.AST {
785
+ /* c8 ignore start */
786
+ constructor(i, r, o = {}) {
787
+ super(i, r, N(s, o));
788
+ }
789
+ /* c8 ignore stop */
790
+ static fromGlob(i, r = {}) {
791
+ return t.AST.fromGlob(i, N(s, r));
792
+ }
793
+ },
794
+ unescape: (n, i = {}) => t.unescape(n, N(s, i)),
795
+ escape: (n, i = {}) => t.escape(n, N(s, i)),
796
+ filter: (n, i = {}) => t.filter(n, N(s, i)),
797
+ defaults: (n) => t.defaults(N(s, n)),
798
+ makeRe: (n, i = {}) => t.makeRe(n, N(s, i)),
799
+ braceExpand: (n, i = {}) => t.braceExpand(n, N(s, i)),
800
+ match: (n, i, r = {}) => t.match(n, i, N(s, r)),
801
+ sep: t.sep,
802
+ GLOBSTAR: O
803
+ });
804
+ };
805
+ y.defaults = fe;
806
+ const tt = (s, t = {}) => (C(s), t.nobrace || !/\{(?:(?!\{).)*\}/.test(s) ? [s] : vt(s));
807
+ y.braceExpand = tt;
808
+ const pe = (s, t = {}) => new I(s, t).makeRe();
809
+ y.makeRe = pe;
810
+ const de = (s, t, e = {}) => {
811
+ const n = new I(t, e);
812
+ return s = s.filter((i) => n.match(i)), n.options.nonull && !s.length && s.push(t), s;
813
+ };
814
+ y.match = de;
815
+ const q = /[?*]|[+@!]\(.*?\)|\[|\]/, ge = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
816
+ class I {
817
+ options;
818
+ set;
819
+ pattern;
820
+ windowsPathsNoEscape;
821
+ nonegate;
822
+ negate;
823
+ comment;
824
+ empty;
825
+ preserveMultipleSlashes;
826
+ partial;
827
+ globSet;
828
+ globParts;
829
+ nocase;
830
+ isWindows;
831
+ platform;
832
+ windowsNoMagicRoot;
833
+ regexp;
834
+ constructor(t, e = {}) {
835
+ C(t), e = e || {}, this.options = e, this.pattern = t, this.platform = e.platform || K, this.isWindows = this.platform === "win32", this.windowsPathsNoEscape = !!e.windowsPathsNoEscape || e.allowWindowsEscape === !1, this.windowsPathsNoEscape && (this.pattern = this.pattern.replace(/\\/g, "/")), this.preserveMultipleSlashes = !!e.preserveMultipleSlashes, this.regexp = null, this.negate = !1, this.nonegate = !!e.nonegate, this.comment = !1, this.empty = !1, this.partial = !!e.partial, this.nocase = !!this.options.nocase, this.windowsNoMagicRoot = e.windowsNoMagicRoot !== void 0 ? e.windowsNoMagicRoot : !!(this.isWindows && this.nocase), this.globSet = [], this.globParts = [], this.set = [], this.make();
836
+ }
837
+ hasMagic() {
838
+ if (this.options.magicalBraces && this.set.length > 1)
839
+ return !0;
840
+ for (const t of this.set)
841
+ for (const e of t)
842
+ if (typeof e != "string")
843
+ return !0;
844
+ return !1;
845
+ }
846
+ debug(...t) {
847
+ }
848
+ make() {
849
+ const t = this.pattern, e = this.options;
850
+ if (!e.nocomment && t.charAt(0) === "#") {
851
+ this.comment = !0;
852
+ return;
853
+ }
854
+ if (!t) {
855
+ this.empty = !0;
856
+ return;
857
+ }
858
+ this.parseNegate(), this.globSet = [...new Set(this.braceExpand())], e.debug && (this.debug = (...r) => console.error(...r)), this.debug(this.pattern, this.globSet);
859
+ const n = this.globSet.map((r) => this.slashSplit(r));
860
+ this.globParts = this.preprocess(n), this.debug(this.pattern, this.globParts);
861
+ let i = this.globParts.map((r, o, a) => {
862
+ if (this.isWindows && this.windowsNoMagicRoot) {
863
+ const h = r[0] === "" && r[1] === "" && (r[2] === "?" || !q.test(r[2])) && !q.test(r[3]), l = /^[a-z]:/i.test(r[0]);
864
+ if (h)
865
+ return [...r.slice(0, 4), ...r.slice(4).map((c) => this.parse(c))];
866
+ if (l)
867
+ return [r[0], ...r.slice(1).map((c) => this.parse(c))];
868
+ }
869
+ return r.map((h) => this.parse(h));
870
+ });
871
+ if (this.debug(this.pattern, i), this.set = i.filter((r) => r.indexOf(!1) === -1), this.isWindows)
872
+ for (let r = 0; r < this.set.length; r++) {
873
+ const o = this.set[r];
874
+ o[0] === "" && o[1] === "" && this.globParts[r][2] === "?" && typeof o[3] == "string" && /^[a-z]:$/i.test(o[3]) && (o[2] = "?");
875
+ }
876
+ this.debug(this.pattern, this.set);
877
+ }
878
+ // various transforms to equivalent pattern sets that are
879
+ // faster to process in a filesystem walk. The goal is to
880
+ // eliminate what we can, and push all ** patterns as far
881
+ // to the right as possible, even if it increases the number
882
+ // of patterns that we have to process.
883
+ preprocess(t) {
884
+ if (this.options.noglobstar)
885
+ for (let n = 0; n < t.length; n++)
886
+ for (let i = 0; i < t[n].length; i++)
887
+ t[n][i] === "**" && (t[n][i] = "*");
888
+ const { optimizationLevel: e = 1 } = this.options;
889
+ return e >= 2 ? (t = this.firstPhasePreProcess(t), t = this.secondPhasePreProcess(t)) : e >= 1 ? t = this.levelOneOptimize(t) : t = this.adjascentGlobstarOptimize(t), t;
890
+ }
891
+ // just get rid of adjascent ** portions
892
+ adjascentGlobstarOptimize(t) {
893
+ return t.map((e) => {
894
+ let n = -1;
895
+ for (; (n = e.indexOf("**", n + 1)) !== -1; ) {
896
+ let i = n;
897
+ for (; e[i + 1] === "**"; )
898
+ i++;
899
+ i !== n && e.splice(n, i - n);
900
+ }
901
+ return e;
902
+ });
903
+ }
904
+ // get rid of adjascent ** and resolve .. portions
905
+ levelOneOptimize(t) {
906
+ return t.map((e) => (e = e.reduce((n, i) => {
907
+ const r = n[n.length - 1];
908
+ return i === "**" && r === "**" ? n : i === ".." && r && r !== ".." && r !== "." && r !== "**" ? (n.pop(), n) : (n.push(i), n);
909
+ }, []), e.length === 0 ? [""] : e));
910
+ }
911
+ levelTwoFileOptimize(t) {
912
+ Array.isArray(t) || (t = this.slashSplit(t));
913
+ let e = !1;
914
+ do {
915
+ if (e = !1, !this.preserveMultipleSlashes) {
916
+ for (let i = 1; i < t.length - 1; i++) {
917
+ const r = t[i];
918
+ i === 1 && r === "" && t[0] === "" || (r === "." || r === "") && (e = !0, t.splice(i, 1), i--);
919
+ }
920
+ t[0] === "." && t.length === 2 && (t[1] === "." || t[1] === "") && (e = !0, t.pop());
921
+ }
922
+ let n = 0;
923
+ for (; (n = t.indexOf("..", n + 1)) !== -1; ) {
924
+ const i = t[n - 1];
925
+ i && i !== "." && i !== ".." && i !== "**" && (e = !0, t.splice(n - 1, 2), n -= 2);
926
+ }
927
+ } while (e);
928
+ return t.length === 0 ? [""] : t;
929
+ }
930
+ // First phase: single-pattern processing
931
+ // <pre> is 1 or more portions
932
+ // <rest> is 1 or more portions
933
+ // <p> is any portion other than ., .., '', or **
934
+ // <e> is . or ''
935
+ //
936
+ // **/.. is *brutal* for filesystem walking performance, because
937
+ // it effectively resets the recursive walk each time it occurs,
938
+ // and ** cannot be reduced out by a .. pattern part like a regexp
939
+ // or most strings (other than .., ., and '') can be.
940
+ //
941
+ // <pre>/**/../<p>/<p>/<rest> -> {<pre>/../<p>/<p>/<rest>,<pre>/**/<p>/<p>/<rest>}
942
+ // <pre>/<e>/<rest> -> <pre>/<rest>
943
+ // <pre>/<p>/../<rest> -> <pre>/<rest>
944
+ // **/**/<rest> -> **/<rest>
945
+ //
946
+ // **/*/<rest> -> */**/<rest> <== not valid because ** doesn't follow
947
+ // this WOULD be allowed if ** did follow symlinks, or * didn't
948
+ firstPhasePreProcess(t) {
949
+ let e = !1;
950
+ do {
951
+ e = !1;
952
+ for (let n of t) {
953
+ let i = -1;
954
+ for (; (i = n.indexOf("**", i + 1)) !== -1; ) {
955
+ let o = i;
956
+ for (; n[o + 1] === "**"; )
957
+ o++;
958
+ o > i && n.splice(i + 1, o - i);
959
+ let a = n[i + 1];
960
+ const h = n[i + 2], l = n[i + 3];
961
+ if (a !== ".." || !h || h === "." || h === ".." || !l || l === "." || l === "..")
962
+ continue;
963
+ e = !0, n.splice(i, 1);
964
+ const c = n.slice(0);
965
+ c[i] = "**", t.push(c), i--;
966
+ }
967
+ if (!this.preserveMultipleSlashes) {
968
+ for (let o = 1; o < n.length - 1; o++) {
969
+ const a = n[o];
970
+ o === 1 && a === "" && n[0] === "" || (a === "." || a === "") && (e = !0, n.splice(o, 1), o--);
971
+ }
972
+ n[0] === "." && n.length === 2 && (n[1] === "." || n[1] === "") && (e = !0, n.pop());
973
+ }
974
+ let r = 0;
975
+ for (; (r = n.indexOf("..", r + 1)) !== -1; ) {
976
+ const o = n[r - 1];
977
+ if (o && o !== "." && o !== ".." && o !== "**") {
978
+ e = !0;
979
+ const h = r === 1 && n[r + 1] === "**" ? ["."] : [];
980
+ n.splice(r - 1, 2, ...h), n.length === 0 && n.push(""), r -= 2;
981
+ }
982
+ }
983
+ }
984
+ } while (e);
985
+ return t;
986
+ }
987
+ // second phase: multi-pattern dedupes
988
+ // {<pre>/*/<rest>,<pre>/<p>/<rest>} -> <pre>/*/<rest>
989
+ // {<pre>/<rest>,<pre>/<rest>} -> <pre>/<rest>
990
+ // {<pre>/**/<rest>,<pre>/<rest>} -> <pre>/**/<rest>
991
+ //
992
+ // {<pre>/**/<rest>,<pre>/**/<p>/<rest>} -> <pre>/**/<rest>
993
+ // ^-- not valid because ** doens't follow symlinks
994
+ secondPhasePreProcess(t) {
995
+ for (let e = 0; e < t.length - 1; e++)
996
+ for (let n = e + 1; n < t.length; n++) {
997
+ const i = this.partsMatch(t[e], t[n], !this.preserveMultipleSlashes);
998
+ if (i) {
999
+ t[e] = [], t[n] = i;
1000
+ break;
1001
+ }
1002
+ }
1003
+ return t.filter((e) => e.length);
1004
+ }
1005
+ partsMatch(t, e, n = !1) {
1006
+ let i = 0, r = 0, o = [], a = "";
1007
+ for (; i < t.length && r < e.length; )
1008
+ if (t[i] === e[r])
1009
+ o.push(a === "b" ? e[r] : t[i]), i++, r++;
1010
+ else if (n && t[i] === "**" && e[r] === t[i + 1])
1011
+ o.push(t[i]), i++;
1012
+ else if (n && e[r] === "**" && t[i] === e[r + 1])
1013
+ o.push(e[r]), r++;
1014
+ else if (t[i] === "*" && e[r] && (this.options.dot || !e[r].startsWith(".")) && e[r] !== "**") {
1015
+ if (a === "b")
1016
+ return !1;
1017
+ a = "a", o.push(t[i]), i++, r++;
1018
+ } else if (e[r] === "*" && t[i] && (this.options.dot || !t[i].startsWith(".")) && t[i] !== "**") {
1019
+ if (a === "a")
1020
+ return !1;
1021
+ a = "b", o.push(e[r]), i++, r++;
1022
+ } else
1023
+ return !1;
1024
+ return t.length === e.length && o;
1025
+ }
1026
+ parseNegate() {
1027
+ if (this.nonegate)
1028
+ return;
1029
+ const t = this.pattern;
1030
+ let e = !1, n = 0;
1031
+ for (let i = 0; i < t.length && t.charAt(i) === "!"; i++)
1032
+ e = !e, n++;
1033
+ n && (this.pattern = t.slice(n)), this.negate = e;
1034
+ }
1035
+ // set partial to true to test if, for example,
1036
+ // "/a/b" matches the start of "/*/b/*/d"
1037
+ // Partial means, if you run out of file before you run
1038
+ // out of pattern, then that's fine, as long as all
1039
+ // the parts match.
1040
+ matchOne(t, e, n = !1) {
1041
+ const i = this.options;
1042
+ if (this.isWindows) {
1043
+ const d = typeof t[0] == "string" && /^[a-z]:$/i.test(t[0]), S = !d && t[0] === "" && t[1] === "" && t[2] === "?" && /^[a-z]:$/i.test(t[3]), b = typeof e[0] == "string" && /^[a-z]:$/i.test(e[0]), A = !b && e[0] === "" && e[1] === "" && e[2] === "?" && typeof e[3] == "string" && /^[a-z]:$/i.test(e[3]), x = S ? 3 : d ? 0 : void 0, w = A ? 3 : b ? 0 : void 0;
1044
+ if (typeof x == "number" && typeof w == "number") {
1045
+ const [v, P] = [t[x], e[w]];
1046
+ v.toLowerCase() === P.toLowerCase() && (e[w] = v, w > x ? e = e.slice(w) : x > w && (t = t.slice(x)));
1047
+ }
1048
+ }
1049
+ const { optimizationLevel: r = 1 } = this.options;
1050
+ r >= 2 && (t = this.levelTwoFileOptimize(t)), this.debug("matchOne", this, { file: t, pattern: e }), this.debug("matchOne", t.length, e.length);
1051
+ for (var o = 0, a = 0, h = t.length, l = e.length; o < h && a < l; o++, a++) {
1052
+ this.debug("matchOne loop");
1053
+ var c = e[a], p = t[o];
1054
+ if (this.debug(e, c, p), c === !1)
1055
+ return !1;
1056
+ if (c === O) {
1057
+ this.debug("GLOBSTAR", [e, c, p]);
1058
+ var f = o, u = a + 1;
1059
+ if (u === l) {
1060
+ for (this.debug("** at the end"); o < h; o++)
1061
+ if (t[o] === "." || t[o] === ".." || !i.dot && t[o].charAt(0) === ".")
1062
+ return !1;
1063
+ return !0;
1064
+ }
1065
+ for (; f < h; ) {
1066
+ var m = t[f];
1067
+ if (this.debug(`
1068
+ globstar while`, t, f, e, u, m), this.matchOne(t.slice(f), e.slice(u), n))
1069
+ return this.debug("globstar found match!", f, h, m), !0;
1070
+ if (m === "." || m === ".." || !i.dot && m.charAt(0) === ".") {
1071
+ this.debug("dot detected!", t, f, e, u);
1072
+ break;
1073
+ }
1074
+ this.debug("globstar swallow a segment, and continue"), f++;
1075
+ }
1076
+ return !!(n && (this.debug(`
1077
+ >>> no match, partial?`, t, f, e, u), f === h));
1078
+ }
1079
+ let d;
1080
+ if (typeof c == "string" ? (d = p === c, this.debug("string match", c, p, d)) : (d = c.test(p), this.debug("pattern match", c, p, d)), !d)
1081
+ return !1;
1082
+ }
1083
+ if (o === h && a === l)
1084
+ return !0;
1085
+ if (o === h)
1086
+ return n;
1087
+ if (a === l)
1088
+ return o === h - 1 && t[o] === "";
1089
+ throw new Error("wtf?");
1090
+ }
1091
+ braceExpand() {
1092
+ return tt(this.pattern, this.options);
1093
+ }
1094
+ parse(t) {
1095
+ C(t);
1096
+ const e = this.options;
1097
+ if (t === "**")
1098
+ return O;
1099
+ if (t === "")
1100
+ return "";
1101
+ let n, i = null;
1102
+ (n = t.match(Qt)) ? i = e.dot ? te : Kt : (n = t.match(_t)) ? i = (e.nocase ? e.dot ? Ht : Gt : e.dot ? qt : Bt)(n[1]) : (n = t.match(ee)) ? i = (e.nocase ? e.dot ? ne : se : e.dot ? ie : re)(n) : (n = t.match(Vt)) ? i = e.dot ? Yt : Zt : (n = t.match(Jt)) && (i = Xt);
1103
+ const r = E.fromGlob(t, this.options).toMMPattern();
1104
+ return i && typeof r == "object" && Reflect.defineProperty(r, "test", { value: i }), r;
1105
+ }
1106
+ makeRe() {
1107
+ if (this.regexp || this.regexp === !1)
1108
+ return this.regexp;
1109
+ const t = this.set;
1110
+ if (!t.length)
1111
+ return this.regexp = !1, this.regexp;
1112
+ const e = this.options, n = e.noglobstar ? ae : e.dot ? he : le, i = new Set(e.nocase ? ["i"] : []);
1113
+ let r = t.map((h) => {
1114
+ const l = h.map((c) => {
1115
+ if (c instanceof RegExp)
1116
+ for (const p of c.flags.split(""))
1117
+ i.add(p);
1118
+ return typeof c == "string" ? ge(c) : c === O ? O : c._src;
1119
+ });
1120
+ return l.forEach((c, p) => {
1121
+ const f = l[p + 1], u = l[p - 1];
1122
+ c !== O || u === O || (u === void 0 ? f !== void 0 && f !== O ? l[p + 1] = "(?:\\/|" + n + "\\/)?" + f : l[p] = n : f === void 0 ? l[p - 1] = u + "(?:\\/|" + n + ")?" : f !== O && (l[p - 1] = u + "(?:\\/|\\/" + n + "\\/)" + f, l[p + 1] = O));
1123
+ }), l.filter((c) => c !== O).join("/");
1124
+ }).join("|");
1125
+ const [o, a] = t.length > 1 ? ["(?:", ")"] : ["", ""];
1126
+ r = "^" + o + r + a + "$", this.negate && (r = "^(?!" + r + ").+$");
1127
+ try {
1128
+ this.regexp = new RegExp(r, [...i].join(""));
1129
+ } catch {
1130
+ this.regexp = !1;
1131
+ }
1132
+ return this.regexp;
1133
+ }
1134
+ slashSplit(t) {
1135
+ return this.preserveMultipleSlashes ? t.split("/") : this.isWindows && /^\/\/[^\/]+/.test(t) ? ["", ...t.split(/\/+/)] : t.split(/\/+/);
1136
+ }
1137
+ match(t, e = this.partial) {
1138
+ if (this.debug("match", t, this.pattern), this.comment)
1139
+ return !1;
1140
+ if (this.empty)
1141
+ return t === "";
1142
+ if (t === "/" && e)
1143
+ return !0;
1144
+ const n = this.options;
1145
+ this.isWindows && (t = t.split("\\").join("/"));
1146
+ const i = this.slashSplit(t);
1147
+ this.debug(this.pattern, "split", i);
1148
+ const r = this.set;
1149
+ this.debug(this.pattern, "set", r);
1150
+ let o = i[i.length - 1];
1151
+ if (!o)
1152
+ for (let a = i.length - 2; !o && a >= 0; a--)
1153
+ o = i[a];
1154
+ for (let a = 0; a < r.length; a++) {
1155
+ const h = r[a];
1156
+ let l = i;
1157
+ if (n.matchBase && h.length === 1 && (l = [o]), this.matchOne(l, h, e))
1158
+ return n.flipNegate ? !0 : !this.negate;
1159
+ }
1160
+ return n.flipNegate ? !1 : this.negate;
1161
+ }
1162
+ static defaults(t) {
1163
+ return y.defaults(t).Minimatch;
1164
+ }
1165
+ }
1166
+ y.AST = E;
1167
+ y.Minimatch = I;
1168
+ y.escape = zt;
1169
+ y.unescape = M;
1170
+ function Me() {
1171
+ if (!("storage" in navigator) || !("getDirectory" in navigator.storage))
1172
+ throw new it();
1173
+ }
1174
+ async function me(s, t, e) {
1175
+ return typeof navigator < "u" && navigator.locks?.request ? navigator.locks.request(`opfs:${s.replace(/\/+/g, "/")}`, { mode: t }, e) : e();
1176
+ }
1177
+ function F(s) {
1178
+ return Array.isArray(s) ? s : (s.startsWith("~/") ? s.slice(2) : s).split("/").filter(Boolean);
1179
+ }
1180
+ function et(s) {
1181
+ return typeof s == "string" ? s ?? "/" : `/${s.join("/")}`;
1182
+ }
1183
+ function st(s) {
1184
+ const t = F(s);
1185
+ return t[t.length - 1] || "";
1186
+ }
1187
+ function Pe(s) {
1188
+ const t = F(s);
1189
+ return t.pop(), et(t);
1190
+ }
1191
+ function nt(s) {
1192
+ return !s || s === "/" ? "/" : s.startsWith("~/") ? `/${s.slice(2)}` : s.startsWith("/") ? s : `/${s}`;
1193
+ }
1194
+ function Re(s, t = !1) {
1195
+ return s = s.replace(/\/$/, ""), t && !s.includes("*") ? `${s}/**` : s;
1196
+ }
1197
+ function Ce(s, t) {
1198
+ return y(s, t, {
1199
+ dot: !0,
1200
+ matchBase: !0
1201
+ });
1202
+ }
1203
+ function Ie(s, t) {
1204
+ if (!t || Array.isArray(t) && t.length === 0)
1205
+ return !1;
1206
+ const e = nt(s);
1207
+ return (Array.isArray(t) ? t : [t]).some((i) => y(e, i, { dot: !0 }));
1208
+ }
1209
+ function De(s) {
1210
+ const t = nt(s), e = F(t), n = [];
1211
+ for (const i of e)
1212
+ if (!(i === "." || i === ""))
1213
+ if (i === "..") {
1214
+ if (n.length === 0)
1215
+ continue;
1216
+ n.pop();
1217
+ } else
1218
+ n.push(i);
1219
+ return et(n);
1220
+ }
1221
+ function Le(s) {
1222
+ const t = st(s), e = t.lastIndexOf(".");
1223
+ return e <= 0 || e === t.length - 1 ? "" : t.slice(e);
1224
+ }
1225
+ function ke(s, t = "utf-8") {
1226
+ return typeof s == "string" ? ct(s, t) : s instanceof Uint8Array ? s : new Uint8Array(s);
1227
+ }
1228
+ async function Fe(s, t = "SHA-1", e = 50 * 1024 * 1024) {
1229
+ if (s instanceof File && (s = await s.arrayBuffer()), s.byteLength > e)
1230
+ throw new Error(`File size ${s.byteLength} bytes exceeds maximum allowed size ${e} bytes`);
1231
+ const n = new Uint8Array(s), i = await crypto.subtle.digest(t, n);
1232
+ return Array.from(new Uint8Array(i)).map((o) => o.toString(16).padStart(2, "0")).join("");
1233
+ }
1234
+ function je(s, t) {
1235
+ if (s.length !== t.length)
1236
+ return !1;
1237
+ for (let e = 0; e < s.length; e++)
1238
+ if (s[e] !== t[e])
1239
+ return !1;
1240
+ return !0;
1241
+ }
1242
+ async function Ue(s) {
1243
+ const t = await s.arrayBuffer();
1244
+ return new Uint8Array(t);
1245
+ }
1246
+ async function We(s, t, e = {}) {
1247
+ const n = st(t);
1248
+ return me(t, "exclusive", async () => {
1249
+ const i = e.recursive ?? !1, r = e.force ?? !1;
1250
+ try {
1251
+ await s.removeEntry(n, { recursive: i });
1252
+ } catch (o) {
1253
+ if (o.name === "NotFoundError") {
1254
+ if (!r)
1255
+ throw new g(`No such file or directory: ${t}`, "ENOENT", void 0, o);
1256
+ } else throw o.name === "InvalidModificationError" ? new g(`Directory not empty: ${t}. Use recursive option to force removal.`, "ENOTEMPTY", void 0, o) : o.name === "TypeMismatchError" && !i ? new g(`Cannot remove directory without recursive option: ${t}`, "EISDIR", void 0, o) : new g(`Failed to remove entry: ${t}`, "RM_FAILED", void 0, o);
1257
+ }
1258
+ });
1259
+ }
1260
+ function ze(s, t, e, n) {
1261
+ if (!Number.isInteger(t) || !Number.isInteger(e))
1262
+ throw new g("Invalid offset or length", "EINVAL");
1263
+ if (t < 0 || e < 0)
1264
+ throw new g("Negative offset or length not allowed", "EINVAL");
1265
+ if (t + e > s)
1266
+ throw new g("Operation would overflow buffer", "ERANGE");
1267
+ if (n != null && (!Number.isInteger(n) || n < 0))
1268
+ throw new g("Invalid position", "EINVAL");
1269
+ }
1270
+ function _e(s, t, e) {
1271
+ try {
1272
+ t.flush(), t.close();
1273
+ } catch (n) {
1274
+ console.warn(`Warning: Failed to properly close file descriptor ${s} (${e}):`, n);
1275
+ }
1276
+ }
1277
+ function Be(s, t, e) {
1278
+ if (s >= e)
1279
+ return { isEOF: !0, actualLength: 0 };
1280
+ const n = Math.min(t, e - s);
1281
+ return n <= 0 ? { isEOF: !0, actualLength: 0 } : { isEOF: !1, actualLength: n };
1282
+ }
1283
+ async function qe(s, t) {
1284
+ try {
1285
+ return await s.createSyncAccessHandle();
1286
+ } catch (e) {
1287
+ throw rt(e, { path: t, isDirectory: !1 });
1288
+ }
1289
+ }
1290
+ export {
1291
+ _e as A,
1292
+ Be as B,
1293
+ qe as C,
1294
+ Se as D,
1295
+ ot as E,
1296
+ Ee as F,
1297
+ g as O,
1298
+ ye as P,
1299
+ Ne as S,
1300
+ Oe as T,
1301
+ ft as W,
1302
+ it as a,
1303
+ we as b,
1304
+ xe as c,
1305
+ ve as d,
1306
+ ct as e,
1307
+ be as f,
1308
+ Me as g,
1309
+ st as h,
1310
+ Ae as i,
1311
+ et as j,
1312
+ Pe as k,
1313
+ Re as l,
1314
+ rt as m,
1315
+ nt as n,
1316
+ Ce as o,
1317
+ Ie as p,
1318
+ Le as q,
1319
+ De as r,
1320
+ F as s,
1321
+ ke as t,
1322
+ Fe as u,
1323
+ je as v,
1324
+ me as w,
1325
+ Ue as x,
1326
+ We as y,
1327
+ ze as z
1328
+ };
1329
+ //# sourceMappingURL=helpers-BwklIUit.js.map