opfs-worker 0.3.3 → 0.4.2

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