clanka 0.24.5 → 0.25.1

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.
@@ -1,3880 +0,0 @@
1
- import ys from "node:stream";
2
- import { StringDecoder } from "node:string_decoder";
3
- import * as Qi from "node:fs";
4
- import { posix, win32 } from "node:path";
5
- import { fileURLToPath } from "node:url";
6
- import { lstatSync, readdir, readdirSync, readlinkSync, realpathSync } from "fs";
7
- import { EventEmitter } from "node:events";
8
- import { channel, tracingChannel } from "node:diagnostics_channel";
9
- import { lstat, readdir as readdir$1, readlink, realpath } from "node:fs/promises";
10
- // node_modules/.pnpm/glob@14.0.4/node_modules/glob/dist/esm/index.min.js
11
- var re = (r, t, e) => {
12
- let s = r instanceof RegExp ? We(r, e) : r, i = t instanceof RegExp ? We(t, e) : t, n = s !== null && i != null && js(s, i, e);
13
- return n && {
14
- start: n[0],
15
- end: n[1],
16
- pre: e.slice(0, n[0]),
17
- body: e.slice(n[0] + s.length, n[1]),
18
- post: e.slice(n[1] + i.length)
19
- };
20
- };
21
- var We = (r, t) => {
22
- let e = t.match(r);
23
- return e ? e[0] : null;
24
- };
25
- var js = (r, t, e) => {
26
- let s, i, n, o, h, a = e.indexOf(r), l = e.indexOf(t, a + 1), c = a;
27
- if (a >= 0 && l > 0) {
28
- if (r === t) return [a, l];
29
- for (s = [], n = e.length; c >= 0 && !h;) {
30
- if (c === a) s.push(c), a = e.indexOf(r, c + 1);
31
- else if (s.length === 1) {
32
- let f = s.pop();
33
- f !== void 0 && (h = [f, l]);
34
- } else i = s.pop(), i !== void 0 && i < n && (n = i, o = l), l = e.indexOf(t, c + 1);
35
- c = a < l && a >= 0 ? a : l;
36
- }
37
- s.length && o !== void 0 && (h = [n, o]);
38
- }
39
- return h;
40
- };
41
- var $e = "\0SLASH" + Math.random() + "\0";
42
- var Ie = "\0OPEN" + Math.random() + "\0";
43
- var le = "\0CLOSE" + Math.random() + "\0";
44
- var Be = "\0COMMA" + Math.random() + "\0";
45
- var Ue = "\0PERIOD" + Math.random() + "\0";
46
- var Ws = new RegExp($e, "g");
47
- var $s = new RegExp(Ie, "g");
48
- var Is = new RegExp(le, "g");
49
- var Bs = new RegExp(Be, "g");
50
- var Us = new RegExp(Ue, "g");
51
- var Gs = /\\\\/g;
52
- var Hs = /\\{/g;
53
- var qs = /\\}/g;
54
- var Ks = /\\,/g;
55
- var Xs = /\\\./g;
56
- var Vs = 1e5;
57
- var Ys = 4e6;
58
- var Js = 1e3;
59
- var Zs = 1e3;
60
- function oe(r) {
61
- return isNaN(r) ? r.charCodeAt(0) : parseInt(r, 10);
62
- }
63
- function Qs(r) {
64
- return r.replace(Gs, $e).replace(Hs, Ie).replace(qs, le).replace(Ks, Be).replace(Xs, Ue);
65
- }
66
- function ti(r) {
67
- return r.replace(Ws, "\\").replace($s, "{").replace(Is, "}").replace(Bs, ",").replace(Us, ".");
68
- }
69
- function he(r, t) {
70
- for (let e = 0; e < t.length; e++) r.push(t[e]);
71
- }
72
- function ei(r) {
73
- let t = [], e = "";
74
- for (;;) {
75
- let s = re("{", "}", r);
76
- if (!s) {
77
- let a = r.split(",");
78
- return a[0] = e + a[0], he(t, a), t;
79
- }
80
- let { pre: i, body: n, post: o } = s, h = i.split(",");
81
- if (h[0] = e + h[0], h[h.length - 1] += "{" + n + "}", !o.length) return he(t, h), t;
82
- e = h.pop(), he(t, h), r = o;
83
- }
84
- }
85
- function Ge(r, t = {}) {
86
- if (!r) return [];
87
- let { max: e = Vs, maxLength: s = Ys, maxDepth: i = Js, maxRewrites: n = Zs } = t;
88
- return r.slice(0, 2) === "{}" && (r = "\\{\\}" + r.slice(2)), ae(Qs(r), e, s, i, 0, n, !0).map(ti);
89
- }
90
- function si(r) {
91
- return "{" + r + "}";
92
- }
93
- function ii(r) {
94
- return /^-?0\d/.test(r);
95
- }
96
- function ni(r, t) {
97
- return r <= t;
98
- }
99
- function ri(r, t) {
100
- return r >= t;
101
- }
102
- function ct(r, t, e, s, i, n) {
103
- let o = [], h = 0;
104
- for (let a = 0; a < r.length; a++) for (let l = 0; l < e.length; l++) {
105
- if (o.length >= s) return o;
106
- let c = r[a] + t + e[l];
107
- if (!(n && !c)) {
108
- if (h + c.length > i) return o;
109
- o.push(c), h += c.length;
110
- }
111
- }
112
- return o;
113
- }
114
- function oi(r, t, e, s) {
115
- let i = r.split(/\.\./), n = [];
116
- if (i[0] === void 0 || i[1] === void 0) return n;
117
- let o = oe(i[0]), h = oe(i[1]), a = Math.max(i[0].length, i[1].length), l = i.length === 3 && i[2] !== void 0 ? Math.max(Math.abs(oe(i[2])), 1) : 1, c = ni;
118
- h < o && (l *= -1, c = ri);
119
- let u = i.some(ii), p = 0;
120
- for (let g = o; c(g, h) && n.length < e; g += l) {
121
- let d;
122
- if (t) d = String.fromCharCode(g), d === "\\" && (d = "");
123
- else if (d = String(g), u) {
124
- let w = a - d.length;
125
- if (w > 0) {
126
- let m = new Array(w + 1).join("0");
127
- g < 0 ? d = "-" + m + d.slice(1) : d = m + d;
128
- }
129
- }
130
- if (p + d.length > s) break;
131
- n.push(d), p += d.length;
132
- }
133
- return n;
134
- }
135
- function ae(r, t, e, s, i, n, o) {
136
- if (i > s) return [r];
137
- let h = [""], a = 0, l = !1, c = !0;
138
- for (;;) {
139
- let f = re("{", "}", r);
140
- if (!f) return ct(h, r, [""], t, e, l);
141
- let u = f.pre;
142
- if (/\$$/.test(u)) {
143
- if (h = ct(h, u + "{" + f.body + "}", [""], t, e, l && !f.post.length), c = !1, !f.post.length) break;
144
- r = f.post;
145
- continue;
146
- }
147
- let p = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(f.body), g = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(f.body), d = p || g, w = f.body.indexOf(",") >= 0;
148
- if (!d && !w) {
149
- if (a < n && f.post.match(/,(?!,).*\}/)) {
150
- a++, r = f.pre + "{" + f.body + le + f.post, o = !0;
151
- continue;
152
- }
153
- return ct(h, u + "{" + f.body + "}" + f.post, [""], t, e, l);
154
- }
155
- c && (l = o && !d, c = !1);
156
- let m;
157
- if (d) m = oi(f.body, g, t, e);
158
- else {
159
- let b = ei(f.body);
160
- if (b.length === 1 && b[0] !== void 0 && (b = ae(b[0], t, e, s, i + 1, n, !1).map(si), b.length === 1)) {
161
- if (h = ct(h, u + b[0], [""], t, e, l && !f.post.length), !f.post.length) break;
162
- r = f.post;
163
- continue;
164
- }
165
- let x = l && !f.post.length && !u;
166
- for (let y = 0; x && y < h.length; y++) h[y] && (x = !1);
167
- m = [];
168
- let S = 0;
169
- t: for (let y = 0; y < b.length; y++) {
170
- let q = ae(b[y], t, e, s, i + 1, n, !1);
171
- for (let W = 0; W < q.length; W++) {
172
- let B = q[W];
173
- if (!(x && !B)) {
174
- if (m.length >= t || S + B.length > e) break t;
175
- m.push(B), S += B.length;
176
- }
177
- }
178
- }
179
- }
180
- if (h = ct(h, u, m, t, e, l && !f.post.length), !f.post.length) break;
181
- r = f.post;
182
- }
183
- return h;
184
- }
185
- var fe = (r, t) => r === t ? {
186
- t: "lit",
187
- ch: String(r)
188
- } : {
189
- t: "class",
190
- re: new RegExp(`^[${r}-${t}]$`)
191
- };
192
- var ce = (r, t) => t.map((e) => [fe(r, r), ...e]);
193
- var ft = (r, t) => {
194
- if (!r) return [[]];
195
- let e = +r[0], s = +t[0], i = r.slice(1), n = t.slice(1);
196
- if (e === s) return ce(e, ft(i, n));
197
- let o = "0".repeat(i.length), h = "9".repeat(i.length), a = [];
198
- i !== o && a.push(...ce(e++, ft(i, h)));
199
- let l = n === h ? [] : ce(s--, ft(o, n));
200
- return e <= s && a.push([fe(e, s), ...Array.from(i, () => fe(0, 9))]), a.push(...l), a;
201
- };
202
- var He = (r, t, e) => {
203
- if (e) return ft(String(r).padStart(e, "0"), String(t).padStart(e, "0"));
204
- let s = [];
205
- for (let i = String(r).length; i <= String(t).length; i++) {
206
- let n = Math.max(r, i === 1 ? 0 : 10 ** (i - 1)), o = Math.min(t, 10 ** i - 1);
207
- s.push(...ft(String(n), String(o)));
208
- }
209
- return s;
210
- };
211
- var qe = (r, t) => {
212
- let e = Number(r), s = Number(t);
213
- if (!Number.isSafeInteger(e) || !Number.isSafeInteger(s)) return;
214
- e > s && ([e, s] = [s, e]);
215
- let n = /^-?0\d/.test(r) || /^-?0\d/.test(t) ? Math.max(r.length, t.length) : 0, o = [];
216
- if (e < 0) {
217
- let h = He(Math.max(-s, 1), -e, n && n - 1);
218
- o.push(...h.map((a) => [{
219
- t: "lit",
220
- ch: "-"
221
- }, ...a]));
222
- }
223
- return s >= 0 && o.push(...He(Math.max(e, 0), s, n)), o;
224
- };
225
- var hi = {
226
- "[:alnum:]": ["\\p{L}\\p{Nl}\\p{Nd}"],
227
- "[:alpha:]": ["\\p{L}\\p{Nl}"],
228
- "[:ascii:]": ["\\x00-\\x7f"],
229
- "[:blank:]": ["\\p{Zs}\\t"],
230
- "[:cntrl:]": ["\\p{Cc}"],
231
- "[:digit:]": ["\\p{Nd}"],
232
- "[:graph:]": ["\\p{Z}\\p{C}", !0],
233
- "[:lower:]": ["\\p{Ll}"],
234
- "[:print:]": ["\\p{C}", !0],
235
- "[:punct:]": ["\\p{P}\\p{S}"],
236
- "[:space:]": ["\\p{Z}\\t\\r\\n\\v\\f"],
237
- "[:upper:]": ["\\p{Lu}"],
238
- "[:word:]": ["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}"],
239
- "[:xdigit:]": ["A-Fa-f0-9"]
240
- };
241
- var ut = (r) => r.replace(/[[\]\\-]/g, "\\$&");
242
- var ue = /$./;
243
- var Ke = (r, t, e = !1, s) => {
244
- let i = (m) => {
245
- let b = s ? m.normalize(s) : m;
246
- return [...b].length === 1 ? b : m;
247
- }, n = t;
248
- if (r.charAt(n) !== "[") throw new Error("not in a brace expression");
249
- let o = [], h = [], a = n + 1, l = !1, c = !1, f = !1, u = n, p = "";
250
- t: for (; a < r.length;) {
251
- let m = String.fromCodePoint(r.codePointAt(a));
252
- if ((m === "!" || m === "^") && a === n + 1) {
253
- f = !0, a++;
254
- continue;
255
- }
256
- if (m === "]" && l && !c) {
257
- u = a + 1;
258
- break;
259
- }
260
- if (l = !0, m === "\\" && !c) {
261
- c = !0, a++;
262
- continue;
263
- }
264
- if (m === "[" && !c) {
265
- for (let [x, [S, y]] of Object.entries(hi)) if (r.startsWith(x, a)) {
266
- if (p) return [ue, r.length - n];
267
- a += x.length, y ? h.push(S) : o.push(S);
268
- continue t;
269
- }
270
- }
271
- c = !1;
272
- let b = i(m);
273
- if (p) {
274
- b.codePointAt(0) > p.codePointAt(0) ? o.push(ut(p) + "-" + ut(b)) : b === p && o.push(ut(b)), p = "", a += m.length;
275
- continue;
276
- }
277
- if (r.startsWith("-]", a + m.length)) {
278
- o.push(ut(b + "-")), a += m.length + 1;
279
- continue;
280
- }
281
- if (r.startsWith("-", a + m.length)) {
282
- p = b, a += m.length + 1;
283
- continue;
284
- }
285
- o.push(ut(b)), a += m.length;
286
- }
287
- if (u < a) return [ue, 0];
288
- if (!o.length && !h.length) return [ue, r.length - n];
289
- let g = "[" + (f ? "^" : "") + o.join("") + "]", d = "[" + (f ? "" : "^") + h.join("") + "]", w = "^" + (o.length && h.length ? "(" + g + "|" + d + ")" : o.length ? g : d);
290
- return [new RegExp(w, e ? "iu" : "u"), u - n];
291
- };
292
- var de = {
293
- t: "match",
294
- id: 0
295
- };
296
- var ai = "!?+*@";
297
- var Z = (r) => ({
298
- t: "lit",
299
- ch: r
300
- });
301
- var li = (r) => r.replace(/[\\^$.*+?()[\]{}|/]/g, "\\$&");
302
- var Je = (r) => new RegExp(`^${li(r)}$`, "iu");
303
- var Dt = new Map();
304
- var Ze = (r) => {
305
- let t = Dt.get(r);
306
- return t || (t = Je(r), Dt.size >= 1e3 && Dt.clear(), Dt.set(r, t)), t;
307
- };
308
- var ge = (r, t) => {
309
- if (t === r.ch) return !0;
310
- if (!r.re) return !1;
311
- let e = t.charCodeAt(0);
312
- if (e >= 128) return r.re.test(t);
313
- let s = r.ascii ??= new Uint8Array(128);
314
- return s[e] ||= r.re.test(t) ? 1 : 2, s[e] === 1;
315
- };
316
- var ci = (r, t, e, s, i) => {
317
- let n = [];
318
- for (let o = 0; o < r.length;) {
319
- let h = String.fromCodePoint(r.codePointAt(o));
320
- if (i) {
321
- let a = h === "\\" && r.startsWith(i, o + 1) ? 1 : 0;
322
- if (a || h === i) {
323
- let l = o + a + i.length, c = r.indexOf(i, l), f = /^(-?\d+)\.\.(-?\d+)$/.exec(r.slice(l, c)), u = c !== -1 && f && qe(f[1], f[2]);
324
- if (u) {
325
- n.push({
326
- t: "ext",
327
- type: "@",
328
- alts: u
329
- }), o = c + i.length;
330
- continue;
331
- }
332
- }
333
- }
334
- if (h === "\\") {
335
- let a = r.codePointAt(o + 1), l = a === void 0 ? h : String.fromCodePoint(a);
336
- n.push(Z(l)), o += 1 + l.length;
337
- continue;
338
- }
339
- if (h === "[") {
340
- let [a, l] = Ke(r, o, t, s);
341
- if (l) {
342
- n.push({
343
- t: "class",
344
- re: a
345
- }), o += l;
346
- continue;
347
- }
348
- }
349
- if (!e && ai.includes(h) && r[o + 1] === "(") {
350
- n.push({
351
- t: "open",
352
- type: h
353
- }), o += 2;
354
- continue;
355
- }
356
- n.push(!e && h === "|" ? { t: "bar" } : !e && h === ")" ? { t: "close" } : h === "*" ? { t: "star" } : h === "?" ? { t: "any" } : Z(h)), o += h.length;
357
- }
358
- return n;
359
- };
360
- var fi = (r) => {
361
- let t = new Map(), e = [];
362
- return r.forEach((s, i) => {
363
- s.t === "open" ? e.push(i) : s.t === "close" && e.length && t.set(e.pop(), i);
364
- }), t;
365
- };
366
- var Qe = (r, t, e, s, i) => {
367
- let n = [], o = [n];
368
- for (let h = e; h < s; h++) {
369
- let a = r[h], l = t.get(h);
370
- if (a.t === "open" && l !== void 0) {
371
- let c = Qe(r, t, h + 1, l, !1);
372
- n.push({
373
- t: "ext",
374
- type: a.type,
375
- alts: c
376
- }), h = l;
377
- } else a.t === "bar" && !i ? o.push(n = []) : a.t === "open" ? n.push(Z(a.type), Z("(")) : a.t === "bar" ? n.push(Z("|")) : a.t === "close" ? n.push(Z(")")) : n.push(a);
378
- }
379
- return o;
380
- };
381
- var ts = (r, t) => {
382
- let e = [], s = "", i = () => {
383
- for (let n of s.normalize(t)) e.push(Z(n));
384
- s = "";
385
- };
386
- for (let n of r) {
387
- if (n.t === "lit") {
388
- s += n.ch;
389
- continue;
390
- }
391
- i(), e.push(n.t === "ext" ? {
392
- ...n,
393
- alts: n.alts.map((o) => ts(o, t))
394
- } : n);
395
- }
396
- return i(), e;
397
- };
398
- var ui = (r, t) => {
399
- let e = 1, s = (h) => ({
400
- t: "split",
401
- id: e++,
402
- out: h
403
- }), i = (h, a) => h.reduceRight((l, c) => n(c, l), a), n = (h, a) => {
404
- switch (h.t) {
405
- case "lit":
406
- let u = t ? Ze(h.ch) : void 0;
407
- return {
408
- t: "lit",
409
- id: e++,
410
- ch: h.ch,
411
- re: u,
412
- next: a
413
- };
414
- case "any":
415
- case "star": return {
416
- t: h.t,
417
- id: e++,
418
- next: a
419
- };
420
- case "class": return {
421
- t: "class",
422
- id: e++,
423
- re: h.re,
424
- next: a
425
- };
426
- }
427
- let l = (u) => h.alts.map((p) => i(p, u));
428
- switch (h.type) {
429
- case "@": return s(l(a));
430
- case "?": return s([a, ...l(a)]);
431
- case "!": return {
432
- t: "neg",
433
- id: e++,
434
- sub: s(l(de)),
435
- next: a
436
- };
437
- }
438
- let c = s([]), f = s(l(c));
439
- return c.out.push(a, f), h.type === "*" ? c : f;
440
- };
441
- return [i(r, de), e];
442
- };
443
- var di = (r) => {
444
- let t = [], e = new Set(), s = (n) => n.t === "match" ? "match" : String(n.id), i = (n, o) => {
445
- if (n.t === "match" || e.has(n)) return;
446
- e.add(n);
447
- let h = (a) => t.push(`${o}${n.id}: ${a}`);
448
- switch (n.t) {
449
- case "split":
450
- h(`split -> ${n.out.map(s).join(", ")}`);
451
- for (let a of n.out) i(a, o);
452
- return;
453
- case "neg": return h(`!(${s(n.sub)}) -> ${s(n.next)}`), i(n.sub, o + " "), i(n.next, o);
454
- case "lit":
455
- h(`${JSON.stringify(n.ch)} -> ${s(n.next)}`);
456
- break;
457
- case "class":
458
- h(`${n.re} -> ${s(n.next)}`);
459
- break;
460
- default: h(`${n.t === "any" ? "?" : "*"} -> ${s(n.next)}`);
461
- }
462
- i(n.next, o);
463
- };
464
- return i(r, ""), [`start -> ${s(r)}`, ...t].join(`
465
- `);
466
- };
467
- var pe = class {
468
- gen;
469
- threads = [];
470
- match = !1;
471
- runs = [];
472
- ids = [];
473
- constructor(t) {
474
- this.gen = t;
475
- }
476
- get dead() {
477
- return !this.threads.length && !this.match && !this.runs.length;
478
- }
479
- };
480
- var es = (r, t) => r.ids.length !== t.ids.length || r.runs.length !== t.runs.length || r.ids.some((e, s) => e !== t.ids[s]) ? !1 : r.runs.every((e) => t.runs.some((s) => s.neg === e.neg && es(s.state, e.state)));
481
- var Xe = (r) => ({
482
- has: new Float64Array(r),
483
- seen: new Float64Array(r),
484
- gen: 0
485
- });
486
- var dt = class {
487
- dots;
488
- dotStart;
489
- #t;
490
- constructor(t, e, s) {
491
- this.dots = t, this.dotStart = e, this.#t = s;
492
- }
493
- state() {
494
- return new pe(++this.#t.gen);
495
- }
496
- done(t) {
497
- return t.ids = t.threads.map((e) => e.id).sort((e, s) => e - s), t.match && t.ids.unshift(de.id), t;
498
- }
499
- #n(t, e) {
500
- let { seen: s } = this.#t;
501
- return s[e.id] === t.gen ? !1 : (s[e.id] = t.gen, !0);
502
- }
503
- #i(t, e) {
504
- let { has: s } = this.#t;
505
- return s[e.id] === t.gen ? !1 : (s[e.id] = t.gen, t.threads.push(e), !0);
506
- }
507
- restricted(t, e) {
508
- return e && (this.dots || this.dotStart && t === 0);
509
- }
510
- add(t, e, s, i) {
511
- switch (e.t) {
512
- case "split":
513
- if (!this.#n(t, e)) return;
514
- for (let o of e.out) this.add(t, o, s, i);
515
- return;
516
- case "neg":
517
- if (!this.#n(t, e)) return;
518
- let n = this.state();
519
- return this.add(n, e.sub, s, !1), this.done(n), this.addRun(t, {
520
- t: "run",
521
- neg: e,
522
- state: n
523
- }, s, i);
524
- case "star":
525
- if (this.restricted(s, i)) return;
526
- this.#i(t, e) && this.add(t, e.next, s, i);
527
- return;
528
- case "match":
529
- t.match = !0;
530
- return;
531
- default: this.#i(t, e);
532
- }
533
- }
534
- addRun(t, e, s, i) {
535
- for (let n of t.runs) if (n.neg === e.neg && es(n.state, e.state)) return;
536
- t.runs.push(e), e.state.match || this.add(t, e.neg.next, s, i);
537
- }
538
- step(t, e, s, i) {
539
- let n = this.state();
540
- for (let o of t.threads) switch (o.t) {
541
- case "lit":
542
- ge(o, e) && this.add(n, o.next, s + 1, i);
543
- break;
544
- case "any":
545
- this.restricted(s, i) || this.add(n, o.next, s + 1, i);
546
- break;
547
- case "class":
548
- !this.restricted(s, i) && o.re.test(e) && this.add(n, o.next, s + 1, i);
549
- break;
550
- case "star": this.restricted(s, i) || this.add(n, o, s + 1, i);
551
- }
552
- if (!this.restricted(s, i)) for (let o of t.runs) {
553
- if (o.state.dead) {
554
- this.addRun(n, o, s + 1, i);
555
- continue;
556
- }
557
- let h = this.step(o.state, e, s, !1);
558
- this.addRun(n, {
559
- t: "run",
560
- neg: o.neg,
561
- state: h
562
- }, s + 1, i);
563
- }
564
- return this.done(n);
565
- }
566
- };
567
- var ss = (r) => {
568
- let t = r.ids.join();
569
- if (!r.runs.length) return t;
570
- return `${t}|${r.runs.map((s) => `${s.neg.id}(${ss(s.state)})`).sort().join("|")}`;
571
- };
572
- var pi = 1 << 18;
573
- var me = class {
574
- #t;
575
- #n = new Map();
576
- #i = 0;
577
- #o;
578
- #r;
579
- #d;
580
- #u;
581
- constructor(t, e) {
582
- this.#t = t, this.#d = new dt(!1, !1, e), this.#u = new dt(!1, !0, e);
583
- }
584
- #f(t) {
585
- return {
586
- state: t,
587
- match: t.match,
588
- dead: t.dead,
589
- next: new Map()
590
- };
591
- }
592
- #h(t) {
593
- let e = ss(t), s = this.#n.get(e);
594
- if (s) return s;
595
- this.#i > pi && this.#m();
596
- let i = this.#f(t);
597
- return this.#n.set(e, i), this.#i += e.length + 1, i;
598
- }
599
- #m() {
600
- this.#n.clear(), this.#i = 0, this.#o = void 0, this.#r = void 0;
601
- }
602
- start(t) {
603
- if (t) {
604
- if (this.#r) return this.#r;
605
- let s = this.#u.state();
606
- return this.#u.add(s, this.#t, 0, !0), this.#r = this.#f(this.#u.done(s));
607
- }
608
- if (this.#o) return this.#o;
609
- let e = this.#d.state();
610
- return this.#d.add(e, this.#t, 0, !0), this.#o = this.#h(this.#d.done(e));
611
- }
612
- next(t, e) {
613
- let s = e.charCodeAt(0), i = s < 128 ? void 0 : t.next.get(e);
614
- if (i) return i;
615
- let n = t === this.#r ? this.#h(this.#u.step(t.state, e, 0, !0)) : this.#h(this.#d.step(t.state, e, 1, !0));
616
- return s < 128 ? (t.ascii || (t.ascii = new Array(128), this.#i += 128), t.ascii[s] = n) : t.next.set(e, n), this.#i++, n;
617
- }
618
- };
619
- var mi = (r) => {
620
- let t = [];
621
- for (let e = r; e.t !== "match"; e = e.next) {
622
- if (e.t === "split" || e.t === "neg") return;
623
- t.push(e);
624
- }
625
- return t;
626
- };
627
- var gi = (r, t, e, s) => {
628
- let i = 0, n = e, o = -1, h = 0;
629
- for (; n < s;) {
630
- let a = r[i];
631
- if (a?.t === "star") {
632
- o = i++, h = n;
633
- continue;
634
- }
635
- let l = t[n];
636
- if (a && (a.t === "any" || a.t === "lit" && ge(a, l) || a.t === "class" && a.re.test(l))) {
637
- i++, n++;
638
- continue;
639
- }
640
- if (o === -1) return !1;
641
- i = o + 1, n = ++h;
642
- }
643
- for (; r[i]?.t === "star";) i++;
644
- return i === r.length;
645
- };
646
- var is = (r) => {
647
- let t = 0, e = 0;
648
- for (let s of r) {
649
- let [i, n] = wi(s);
650
- t += i, e += n;
651
- }
652
- return [t, e];
653
- };
654
- var wi = (r) => {
655
- if (r.t === "star") return [0, 1 / 0];
656
- if (r.t !== "ext") return [1, 1];
657
- if (r.type === "!") return [0, 1 / 0];
658
- let t = r.alts.map(is), e = Math.min(...t.map((n) => n[0])), s = Math.max(...t.map((n) => n[1])), i = s === 0 ? 0 : 1 / 0;
659
- return r.type === "@" ? [e, s] : r.type === "?" ? [0, s] : r.type === "*" ? [0, i] : [e, i];
660
- };
661
- var Ve = (r, t, e) => {
662
- for (let s = 0; s < r.length; s++) if (!ge(r[s], t[e + s])) return !1;
663
- return !0;
664
- };
665
- var bi = /[/\ud800-\udfff]/;
666
- var yi = /[\ud800-\udfff]/;
667
- var Nt = (r) => yi.test(r) ? [...r] : r;
668
- var Ye = (r) => {
669
- if (r.includes("/")) throw new Error("can only match a single path portion, got: " + r);
670
- };
671
- var pt = class {
672
- pattern;
673
- options;
674
- #t;
675
- #n;
676
- #i;
677
- #o;
678
- #r;
679
- #d = !1;
680
- #u;
681
- #f;
682
- #h = !1;
683
- #m = 0;
684
- #l = 1 / 0;
685
- #a = [];
686
- #s = [];
687
- #b;
688
- #E;
689
- #y = !1;
690
- #g;
691
- #w;
692
- constructor(t, e = {}) {
693
- if (t.includes("/")) throw new Error("can only match a single path portion, got pattern: " + t);
694
- this.pattern = t, this.options = e;
695
- let { nocase: s = !1, noext: i = !1, normalize: n } = e;
696
- this.#w = n === !0 ? "NFC" : n || void 0;
697
- let o = /^[?*+@]\(\)$/.test(t), h = ci(t, s, i || o, this.#w, e.rangeMark), [a] = Qe(h, fi(h), 0, h.length, !0);
698
- this.#w && (a = ts(a, this.#w));
699
- let [l, c] = ui(a, s);
700
- if (this.#t = l, this.#n = c, a.every((f) => f.t === "lit")) this.#r = a.map((f) => f.ch).join(""), this.#d = s;
701
- else {
702
- let f = (g) => g.t !== "lit" ? void 0 : s ? {
703
- ch: g.ch,
704
- re: Ze(g.ch)
705
- } : { ch: g.ch };
706
- for (let g of a) {
707
- let d = f(g);
708
- if (!d) break;
709
- this.#a.push(d);
710
- }
711
- for (let g = a.length - 1; g >= 0; g--) {
712
- let d = f(a[g]);
713
- if (!d) break;
714
- this.#s.unshift(d);
715
- }
716
- this.#y = !!(this.#a.length || this.#s.length), s || (this.#b = this.#a.map((g) => g.ch).join(""), this.#E = this.#s.map((g) => g.ch).join("")), this.#f = mi(this.#t)?.slice(this.#a.length, -this.#s.length || void 0), this.#h = !!this.#f?.every((g) => g.t === "star" || g.t === "any");
717
- let [u, p] = is(a);
718
- this.#m = u, this.#l = p;
719
- }
720
- }
721
- test(t) {
722
- return this.#w ? (Ye(t), this.#p(t.normalize(this.#w))) : bi.test(t) ? (Ye(t), this.#p(t, [...t])) : this.#p(t, t);
723
- }
724
- testUnchecked(t) {
725
- return this.#p(this.#w ? t.normalize(this.#w) : t);
726
- }
727
- #p(t, e) {
728
- if (this.#r !== void 0) return this.#d ? (this.#u ??= Je(this.#r)).test(t) : t === this.#r;
729
- let s = this.#m, i = this.#l;
730
- if (e === void 0) {
731
- let c = t.length, f = c + 1 >> 1;
732
- if (c < s || f > i) return !1;
733
- (f < s || c > i) && (e = Nt(t));
734
- }
735
- if (e !== void 0 && (e.length < s || e.length > i)) return !1;
736
- let n = this.#a.length;
737
- if (this.#y) if (this.#b !== void 0 && this.#E !== void 0) {
738
- if (!t.startsWith(this.#b) || !t.endsWith(this.#E)) return !1;
739
- } else {
740
- e ??= Nt(t);
741
- let c = e.length - this.#s.length;
742
- if (!Ve(this.#a, e, 0) || !Ve(this.#s, e, c)) return !1;
743
- }
744
- let o = !this.options.dot && t.startsWith(".");
745
- if (this.#f) {
746
- if (t === "." || t === ".." || o && !n) return !1;
747
- if (this.#h) return !0;
748
- e ??= Nt(t);
749
- let c = e.length - this.#s.length;
750
- return gi(this.#f, e, n, c);
751
- }
752
- if (e ??= Nt(t), t === "." || t === "..") {
753
- this.#i ??= Xe(this.#n);
754
- let c = this.#o ??= new dt(!0, !1, this.#i), f = c.state();
755
- c.add(f, this.#t, 0, !0);
756
- let u = c.done(f);
757
- for (let p = 0; p < e.length; p++) u = c.step(u, e[p], p, !0);
758
- return u.match;
759
- }
760
- this.#i ??= Xe(this.#n);
761
- let h = this.#g ??= new me(this.#t, this.#i), a = h.start(o), l = e === t;
762
- for (let c = 0; c < e.length; c++) {
763
- if (a.dead) return !1;
764
- let f = l ? t.charCodeAt(c) : e[c].charCodeAt(0);
765
- a = a.ascii?.[f] ?? h.next(a, e[c]);
766
- }
767
- return a.match;
768
- }
769
- toString() {
770
- return di(this.#t);
771
- }
772
- };
773
- var mt = (r) => {
774
- if (typeof r != "string") throw new TypeError("invalid pattern");
775
- if (r.length > 65536) throw new TypeError("pattern is too long");
776
- };
777
- var K = (r, { windowsPathsNoEscape: t = !1, magicalBraces: e = !1 } = {}) => e ? t ? r.replace(/[?*()[\]{}]/g, "[$&]") : r.replace(/[?*()[\]\\{}]/g, "\\$&") : t ? r.replace(/[?*()[\]]/g, "[$&]") : r.replace(/[?*()[\]\\]/g, "\\$&");
778
- var st = (r, { windowsPathsNoEscape: t = !1, magicalBraces: e = !0 } = {}) => e ? t ? r.replace(/\[([^/\\])\]/g, "$1") : r.replace(/((?!\\).|^)\[([^/\\])\]/g, "$1$2").replace(/\\([^/])/g, "$1") : t ? r.replace(/\[([^/\\{}])\]/g, "$1") : r.replace(/((?!\\).|^)\[([^/\\{}])\]/g, "$1$2").replace(/\\([^/{}])/g, "$1");
779
- var T = (r, t, e = {}) => (mt(t), !e.nocomment && t.charAt(0) === "#" ? !1 : xi(t, e).match(r));
780
- var it = new Map();
781
- var Si = 256;
782
- var xi = (r, t) => {
783
- let e = r + "\0" + JSON.stringify(t), s = it.get(e);
784
- return s ? it.delete(e) : (s = new D(r, { ...t }), it.size >= Si && it.delete(it.keys().next().value)), it.set(e, s), s;
785
- };
786
- var ls = typeof process == "object" && process ? process.env?.__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix";
787
- var ns = {
788
- win32: { sep: "\\" },
789
- posix: { sep: "/" }
790
- };
791
- T.sep = ls === "win32" ? ns.win32.sep : ns.posix.sep;
792
- var v = Symbol("globstar **");
793
- T.GLOBSTAR = v;
794
- var Ei = (r, t = {}) => (e) => T(e, r, t);
795
- T.filter = Ei;
796
- var U = (r, t = {}) => Object.assign({}, r, t);
797
- var ki = (r) => {
798
- if (!r || typeof r != "object" || !Object.keys(r).length) return T;
799
- let t = T;
800
- return Object.assign((s, i, n = {}) => t(s, i, U(r, n)), {
801
- Minimatch: class extends t.Minimatch {
802
- constructor(i, n = {}) {
803
- super(i, U(r, n));
804
- }
805
- static defaults(i) {
806
- return t.defaults(U(r, i)).Minimatch;
807
- }
808
- },
809
- unescape: (s, i = {}) => t.unescape(s, U(r, i)),
810
- escape: (s, i = {}) => t.escape(s, U(r, i)),
811
- filter: (s, i = {}) => t.filter(s, U(r, i)),
812
- defaults: (s) => t.defaults(U(r, s)),
813
- braceExpand: (s, i = {}) => t.braceExpand(s, U(r, i)),
814
- match: (s, i, n = {}) => t.match(s, i, U(r, n)),
815
- sep: t.sep,
816
- GLOBSTAR: v
817
- });
818
- };
819
- T.defaults = ki;
820
- var xe = (r, t = {}) => (mt(r), t.nobrace || !/\{(?:(?!\{).)*\}/.test(r) ? [r] : Ge(r, { max: t.braceExpandMax }));
821
- T.braceExpand = xe;
822
- var Ci = 100;
823
- var Ai = /(?<![\\$])\{(-?\d+)\.\.(-?\d+)\}/g;
824
- var Mi = (r, t, e = {}) => {
825
- let s = new D(t, e);
826
- return r = r.filter((i) => s.match(i)), s.options.nonull && !r.length && r.push(t), r;
827
- };
828
- T.match = Mi;
829
- var rs = /[?*]|[+@!]\(.*?\)|\[|\]/;
830
- var cs = (r, t) => {
831
- let e = t + 1;
832
- (r.charAt(e) === "!" || r.charAt(e) === "^") && e++;
833
- let s = !1;
834
- for (; e < r.length; e++) {
835
- let i = r.charAt(e);
836
- if (i === "]" && s) return e;
837
- s = !0, i === "\\" && e++;
838
- }
839
- return -1;
840
- };
841
- var Ri = (r, t) => {
842
- if (!t && (r === "+()" || r === "@()")) return r;
843
- let e = "";
844
- for (let s = 0; s < r.length; s++) {
845
- let i = r.charAt(s);
846
- if (i === "\\") e += r.charAt(++s) || i;
847
- else {
848
- if (i === "*" || i === "?") return;
849
- if (i === "[") {
850
- let n = cs(r, s);
851
- if (n === -1) {
852
- e += i;
853
- continue;
854
- }
855
- let o = r.slice(s + 1, n);
856
- if (o.startsWith("\\") && (o = o.slice(1)), [...o].length !== 1 || "!^".includes(r.charAt(s + 1))) return;
857
- e += o, s = n;
858
- } else {
859
- if (!t && "+@!".includes(i) && r.charAt(s + 1) === "(" && r.includes(")", s + 2)) return;
860
- e += i;
861
- }
862
- }
863
- }
864
- return e;
865
- };
866
- var Oi = (r) => {
867
- if (/^[?*+@]\(\)$/.test(r) || r.includes("[:")) return !1;
868
- let t = 0;
869
- for (let e = 0; e < r.length; e++) {
870
- let s = r.charAt(e);
871
- if (s === "\\") {
872
- if (++e === r.length) return !1;
873
- } else if (s === "[") {
874
- let i = cs(r, e);
875
- i !== -1 && (e = i);
876
- } else if ("+@!?*".includes(s) && r.charAt(e + 1) === "(") t++, e++;
877
- else if (s === ")") {
878
- if (!t--) return !1;
879
- } else if (s === "|" && !t) return !1;
880
- }
881
- return !t;
882
- };
883
- var we;
884
- var os;
885
- var X = (r, t) => typeof r == "string" ? t === r : t !== "" && r.testUnchecked(t);
886
- var hs = (r, t, e, s, i) => X(r, t) ? e : s !== void 0 && X(r, s) ? i : -1;
887
- var ve = (r) => r === "." || r === "..";
888
- var be = (r) => typeof r == "string" && /^[a-z]:$/i.test(r);
889
- var zt = (r) => typeof r == "string" && /^unc$/i.test(r);
890
- var ye = (r) => {
891
- if (r[0] !== "" || r[1] !== "") return -1;
892
- let t = r[2] !== "?" ? 2 : zt(r[3]) ? 4 : -1, e = r[t], s = r[t + 1];
893
- return t !== -1 && e !== void 0 && e !== "" && e !== v && s !== void 0 && s !== "" && s !== v ? t : -1;
894
- };
895
- var Pt = (r, t) => !ve(r) && (t || !r.startsWith("."));
896
- var gt = (r, t, e, s, i) => {
897
- for (let n = t; n < e;) {
898
- if (r.charCodeAt(n) === 46) {
899
- if (!s) return !0;
900
- let h = r.charCodeAt(n + 1) === 46 ? n + 2 : n + 1;
901
- if (h >= e || Lt(r.charCodeAt(h), i)) return !0;
902
- }
903
- let o = Ee(r, n, i);
904
- if (o === -1) return !1;
905
- for (n = o + 1; n < e && Lt(r.charCodeAt(n), i);) n++;
906
- }
907
- return !1;
908
- };
909
- var Lt = (r, t) => t === "/" ? r === 47 : t === "\\" ? r === 92 : r === 47 || r === 92;
910
- var Ee = (r, t, e) => {
911
- if (e !== "both") return r.indexOf(e, t);
912
- let s = r.indexOf("/", t), i = r.indexOf("\\", t);
913
- return s === -1 ? i : i === -1 ? s : Math.min(s, i);
914
- };
915
- var as = (r, t, e) => e !== "both" ? r.lastIndexOf(e, t) : Math.max(r.lastIndexOf("/", t), r.lastIndexOf("\\", t));
916
- var Se = {};
917
- var D = class {
918
- options;
919
- set;
920
- pattern;
921
- windowsPathsNoEscape;
922
- nonegate;
923
- negate;
924
- comment;
925
- empty;
926
- preserveMultipleSlashes;
927
- partial;
928
- globSet;
929
- globParts;
930
- nocase;
931
- isWindows;
932
- platform;
933
- windowsNoMagicRoot;
934
- maxGlobstarRecursion;
935
- #t;
936
- #n;
937
- #i;
938
- #o;
939
- #r = [];
940
- #d = [];
941
- #u = [];
942
- #f = new Map();
943
- #h = !1;
944
- #m;
945
- #l = new WeakMap();
946
- constructor(t, e = {}) {
947
- mt(t), e = e || {}, this.options = e, this.maxGlobstarRecursion = e.maxGlobstarRecursion ?? 200, this.pattern = t, this.platform = e.platform || ls, this.isWindows = this.platform === "win32";
948
- let s = "allowWindowsEscape";
949
- this.windowsPathsNoEscape = !!e.windowsPathsNoEscape || e[s] === !1, this.windowsPathsNoEscape && (this.pattern = this.pattern.replace(/\\/g, "/")), this.preserveMultipleSlashes = !!e.preserveMultipleSlashes, 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.#t = !this.preserveMultipleSlashes, this.#i = (e.optimizationLevel ?? 1) >= 2;
950
- let i = e.normalize;
951
- this.#o = i === !0 ? "NFC" : i || void 0, this.make();
952
- let n = this.set.map((o) => this.#s(o));
953
- this.#u = this.set.map((o, h) => this.#t && o.length - 1 > n[h]), this.#r = this.set.map((o, h) => {
954
- let a = this.#u[h] ? o.length - 1 : o.length, l = o.slice(n[h] + 1, a).filter((c) => typeof c == "string" && !!c);
955
- return [...new Set(l)];
956
- }), this.#n = this.#r.some((o) => o.length), this.#d = this.set.map((o, h) => {
957
- let [a, l, c] = o;
958
- if (this.#u[h] && o.length === 2 && a === v && l !== v) return "tail";
959
- if (this.#u[h] && e.matchBase && o.length === 1 && a !== v && a !== "") return "base";
960
- if (!(!this.#t || n[h] !== -1)) {
961
- if (o.length === 3 && a === v && c === v && l !== v && l !== "" && this.maxGlobstarRecursion > 0) return "mid";
962
- if (o.length === 2 && l === v && a !== v && a !== "") return "head";
963
- }
964
- });
965
- }
966
- #a(t) {
967
- return this.#o ? t.normalize(this.#o) : t;
968
- }
969
- #s(t) {
970
- if (!this.isWindows) return -1;
971
- if (be(t[0])) return 0;
972
- if (t[0] === "" && t[1] === "" && t[2] === "?" && be(t[3])) return 3;
973
- let s = ye(t);
974
- return s === -1 ? -1 : s + 1;
975
- }
976
- hasMagic() {
977
- if (this.options.magicalBraces && this.set.length > 1) return !0;
978
- for (let t of this.set) for (let e of t) if (typeof e != "string") return !0;
979
- return !1;
980
- }
981
- make() {
982
- let t = this.pattern, e = this.options;
983
- if (!e.nocomment && t.charAt(0) === "#") {
984
- this.comment = !0;
985
- return;
986
- }
987
- if (!t) {
988
- this.empty = !0;
989
- return;
990
- }
991
- this.parseNegate(), this.globSet = [...new Set(this.#M())];
992
- let s = this.globSet.map((n) => this.#e(n));
993
- this.globParts = this.preprocess(s), this.#h = !0;
994
- let i = this.globParts.map((n, o, h) => {
995
- if (this.isWindows && this.windowsNoMagicRoot) {
996
- let a = n[2] === "?" && zt(n[3]) ? 6 : 4, l = n[0] === "" && n[1] === "" && (n[2] === "?" || !rs.test(n[2])) && n.slice(3, a).every((f) => !rs.test(f)), c = /^[a-z]:/i.test(n[0]);
997
- if (l) return [...n.slice(0, a).map((f) => this.#a(f)), ...n.slice(a).map((f) => this.parse(f))];
998
- if (c) return [this.#a(n[0]), ...n.slice(1).map((f) => this.parse(f))];
999
- }
1000
- return n.map((a) => this.parse(a));
1001
- });
1002
- if (this.set = i.filter((n) => n.indexOf(!1) === -1), this.isWindows) for (let n = 0; n < this.set.length; n++) {
1003
- let o = this.set[n];
1004
- o[0] === "" && o[1] === "" && this.globParts[n][2] === "?" && (be(o[3]) || zt(this.globParts[n][3])) && (zt(this.globParts[n][3]) && (o[3] = "UNC"), o[2] = "?");
1005
- }
1006
- e.noext || this.mergeRows(), this.#h = !1, this.set.forEach((n, o) => {
1007
- for (let h = 0; h < n.length; h++) n[h] === Se && (n[h] = this.parse(this.globParts[o][h]));
1008
- });
1009
- }
1010
- mergeRows() {
1011
- let t = !0;
1012
- for (; t;) {
1013
- t = !1;
1014
- let e = Math.max(0, ...this.set.map((s) => s.length));
1015
- for (let s = 0; s < e; s++) {
1016
- let i = new Map();
1017
- this.set.forEach((o, h) => {
1018
- if (!(o[s] instanceof pt || o[s] === Se) || !Oi(this.globParts[h][s])) return;
1019
- let a = [...this.globParts[h]];
1020
- a[s] = "";
1021
- let l = `${o.length}/${a.join("/")}`, c = i.get(l);
1022
- c ? c.push(h) : i.set(l, [h]);
1023
- });
1024
- let n = new Set();
1025
- for (let o of i.values()) {
1026
- if (o.length < 2) continue;
1027
- let [h, ...a] = o, c = `@(${o.map((f) => this.globParts[f][s]).join("|")})`;
1028
- this.globParts[h][s] = c, this.set[h][s] = this.parse(c);
1029
- for (let f of a) n.add(f);
1030
- }
1031
- n.size && (t = !0, this.set = this.set.filter((o, h) => !n.has(h)), this.globParts = this.globParts.filter((o, h) => !n.has(h)));
1032
- }
1033
- }
1034
- }
1035
- preprocess(t) {
1036
- if (this.options.noglobstar) for (let s of t) for (let i = 0; i < s.length; i++) s[i] === "**" && (s[i] = "*");
1037
- let { optimizationLevel: e = 1 } = this.options;
1038
- return e >= 2 ? (t = this.firstPhasePreProcess(t), t = this.secondPhasePreProcess(t)) : e >= 1 ? t = this.levelOneOptimize(t) : t = this.adjascentGlobstarOptimize(t), t;
1039
- }
1040
- adjascentGlobstarOptimize(t) {
1041
- return t.map((e) => {
1042
- let s = -1;
1043
- for (; (s = e.indexOf("**", s + 1)) !== -1;) {
1044
- let i = s;
1045
- for (; e[i + 1] === "**";) i++;
1046
- i !== s && e.splice(s, i - s);
1047
- }
1048
- return e;
1049
- });
1050
- }
1051
- levelOneOptimize(t) {
1052
- return t.map((e) => {
1053
- let s = this.#s(e) + 1;
1054
- return e = e.reduce((i, n) => {
1055
- let o = i[i.length - 1];
1056
- return n === "**" && o === "**" ? i : n === ".." && i.length > s && o && o !== ".." && o !== "." && o !== "**" ? (i.pop(), i) : (i.push(n), i);
1057
- }, []), e.length === 0 ? [""] : e;
1058
- });
1059
- }
1060
- #b(t) {
1061
- let e = !this.isWindows || !t.includes("\\") ? "/" : t.includes("/") ? "both" : "\\", s = this.#t ? 0 : -1, i = "", n = 0, o, h = 0, a = !!this.options.dot;
1062
- t: for (let l = 0; l < this.set.length; l++) {
1063
- let c = this.set[l], f = c[c.length - 1], u = s !== -1 && this.#u[l] && f !== v;
1064
- if (u && s === 0) {
1065
- let d = as(t, t.length, e);
1066
- if (n = d + 1, i = t.slice(n), i === "" && d >= 0) {
1067
- let m = d;
1068
- for (; m > 0 && Lt(t.charCodeAt(m - 1), e);) m--;
1069
- h = m === 0 ? 0 : as(t, m - 1, e) + 1, o = t.slice(h, m);
1070
- }
1071
- let w = this.#i && (ve(i) || i === "" && o !== void 0 && ve(o));
1072
- s = w ? -1 : 1, u = !w;
1073
- }
1074
- let p = -1;
1075
- if (u && typeof f == "string" && (p = hs(f, i, n, o, h), p === -1)) continue;
1076
- if (this.#n) {
1077
- for (let d of this.#r[l]) if (!t.includes(d)) continue t;
1078
- }
1079
- if (u && typeof f == "object" && (p = hs(f, i, n, o, h), p === -1)) continue;
1080
- let g = this.#d[l];
1081
- if (g === "base" && u) return "yes";
1082
- if (g === "tail" && u) {
1083
- if (this.#i && gt(t, 0, p, !0, e)) return "maybe";
1084
- if (!gt(t, 0, p, a, e)) return "yes";
1085
- continue;
1086
- }
1087
- if (g === "mid" || g === "head") {
1088
- let d = this.#y(t, c, g === "head", a, e);
1089
- if (d !== "no") return d;
1090
- continue;
1091
- }
1092
- return "maybe";
1093
- }
1094
- return "no";
1095
- }
1096
- #E(t, e, s) {
1097
- let i = !!this.options.dot, n = t.length;
1098
- if (s === "head") {
1099
- if (n < 2 || !X(e[0], t[0])) return !1;
1100
- for (let h = 1; h < n; h++) if (!Pt(t[h], i)) return !1;
1101
- return !0;
1102
- }
1103
- let o = e[1];
1104
- if (s === "tail") {
1105
- let h = n - 1;
1106
- if (!X(o, t[h]) && (t[h] !== "" || n === 1 || !X(o, t[--h]))) return !1;
1107
- for (let a = 0; a < h; a++) if (!Pt(t[a], i)) return !1;
1108
- return !0;
1109
- }
1110
- for (let h = 0; h < n; h++) {
1111
- if (X(o, t[h]) && h + 1 < n) {
1112
- let a = h + 1;
1113
- for (; a < n && Pt(t[a], i);) a++;
1114
- if (a === n) return !0;
1115
- }
1116
- if (!Pt(t[h], i)) return !1;
1117
- }
1118
- return !1;
1119
- }
1120
- #y(t, e, s, i, n) {
1121
- if (this.#i && gt(t, 0, t.length, !0, n)) return "maybe";
1122
- let o = e[s ? 0 : 1], h = 0;
1123
- for (let a = Ee(t, h, n); a !== -1; a = Ee(t, h, n)) {
1124
- let l = a + 1;
1125
- for (; l < t.length && Lt(t.charCodeAt(l), n);) l++;
1126
- if ((typeof o == "string" ? a - h === o.length && t.startsWith(o, h) : a > h && o.testUnchecked(t.slice(h, a))) && !gt(t, l, t.length, i, n)) return "yes";
1127
- if (s || gt(t, h, l, i, n)) return "no";
1128
- h = l;
1129
- }
1130
- return "no";
1131
- }
1132
- #g(t) {
1133
- let e = we;
1134
- return e?.f === t && e.isWindows === this.isWindows && e.preserveMultipleSlashes === this.preserveMultipleSlashes && e.normalize === this.#o ? e : void 0;
1135
- }
1136
- #w(t) {
1137
- let { isWindows: e, preserveMultipleSlashes: s } = this, i = this.#e(e ? t.split("\\").join("/") : t), n = this.#o;
1138
- return n && (i = i.map((o) => o.normalize(n))), we = {
1139
- f: t,
1140
- isWindows: e,
1141
- preserveMultipleSlashes: s,
1142
- normalize: n,
1143
- parts: i
1144
- }, we;
1145
- }
1146
- #p(t) {
1147
- let e = [...t], s = !1;
1148
- do {
1149
- if (s = !1, !this.preserveMultipleSlashes) {
1150
- for (let o = 1; o < e.length - 1; o++) {
1151
- let h = e[o];
1152
- o === 1 && h === "" && e[0] === "" || (h === "." || h === "") && (s = !0, e.splice(o, 1), o--);
1153
- }
1154
- e[0] === "." && e.length === 2 && (e[1] === "." || e[1] === "") && (s = !0, e.pop());
1155
- }
1156
- let i = this.#s(e) + 1, n = i;
1157
- for (; (n = e.indexOf("..", n + 1)) !== -1;) {
1158
- let o = e[n - 1];
1159
- o && o !== "." && o !== ".." && o !== "**" && (s = !0, e.splice(n - 1, 2), n = Math.max(n - 2, i));
1160
- }
1161
- } while (s);
1162
- return e.length === 0 ? [""] : e;
1163
- }
1164
- firstPhasePreProcess(t) {
1165
- let { braceExpandMax: e = 1e5 } = this.options, s = 0, i = 1e6, n = !1;
1166
- do {
1167
- n = !1;
1168
- for (let o of t) {
1169
- let h = -1;
1170
- for (; (h = o.indexOf("**", h + 1)) !== -1;) {
1171
- let c = h;
1172
- for (; o[c + 1] === "**";) c++;
1173
- c > h && o.splice(h + 1, c - h);
1174
- let f = o[h + 1], u = o[h + 2], p = o[h + 3];
1175
- if (f !== ".." || !u || u === "." || u === ".." || !p || p === "." || p === "..") continue;
1176
- let g = o.length - 1;
1177
- if (t.length >= e || s + g > i) throw new RangeError("optimizationLevel 2: too many patterns from '**/..'");
1178
- n = !0, o.splice(h, 1);
1179
- let d = o.slice(0);
1180
- d[h] = "**", s += g, t.push(d), h--;
1181
- }
1182
- if (!this.preserveMultipleSlashes) {
1183
- for (let c = 1; c < o.length - 1; c++) {
1184
- let f = o[c];
1185
- c === 1 && f === "" && o[0] === "" || (f === "." || f === "") && (n = !0, o.splice(c, 1), c--);
1186
- }
1187
- o[0] === "." && o.length === 2 && (o[1] === "." || o[1] === "") && (n = !0, o.pop());
1188
- }
1189
- let a = this.#s(o) + 1, l = a;
1190
- for (; (l = o.indexOf("..", l + 1)) !== -1;) {
1191
- let c = o[l - 1];
1192
- if (c && c !== "." && c !== ".." && c !== "**") {
1193
- n = !0;
1194
- let u = l === 1 && o[l + 1] === "**" ? ["."] : [];
1195
- o.splice(l - 1, 2, ...u), o.length === 0 && o.push(""), l = Math.max(l - 2, a);
1196
- }
1197
- }
1198
- }
1199
- } while (n);
1200
- return t;
1201
- }
1202
- secondPhasePreProcess(t) {
1203
- let e = new Set(), s = t.filter((o) => {
1204
- let h = o.join("/");
1205
- return e.has(h) ? !1 : (e.add(h), !0);
1206
- }), i = new Map();
1207
- for (let o of s) {
1208
- let h = [];
1209
- for (let a = 0; a < o.length; a++) o[a] === "*" && h.push(a);
1210
- h.length && i.set(h.join(","), h);
1211
- }
1212
- if (!i.size || s.length * i.size > 1e5) return s;
1213
- let { dot: n } = this.options;
1214
- return s.filter((o) => {
1215
- for (let h of i.values()) {
1216
- if (h[h.length - 1] >= o.length) continue;
1217
- let a = [...o], l = !0, c = !1;
1218
- for (let f of h) {
1219
- let u = o[f];
1220
- if (u !== "*") {
1221
- if (!u || u === "**" || !n && u.startsWith(".")) {
1222
- l = !1;
1223
- break;
1224
- }
1225
- a[f] = "*", c = !0;
1226
- }
1227
- }
1228
- if (l && c && e.has(a.join("/"))) return !1;
1229
- }
1230
- return !0;
1231
- });
1232
- }
1233
- parseNegate() {
1234
- if (this.nonegate) return;
1235
- let t = this.pattern, e = !1, s = 0;
1236
- for (let i = 0; i < t.length && t.charAt(i) === "!"; i++) e = !e, s++;
1237
- s && (this.pattern = t.slice(s)), this.negate = e;
1238
- }
1239
- #k(t, e, s, i) {
1240
- let n = 0, o = 0, h = this.isWindows ? ye(e) : -1, a = h === -1 ? -1 : ye(s);
1241
- if (a !== -1) {
1242
- let l = s[a], c = s[a + 1];
1243
- typeof l != "string" || typeof c != "string" ? (n = h, o = a) : e[h].toLowerCase() === l.toLowerCase() && e[h + 1].toLowerCase() === c.toLowerCase() && (n = h + 2, o = a + 2);
1244
- } else if (this.isWindows) {
1245
- let l = typeof t[0] == "string" && /^[a-z]:$/i.test(t[0]), c = !l && t[0] === "" && t[1] === "" && t[2] === "?" && /^[a-z]:$/i.test(t[3]), f = typeof s[0] == "string" && /^[a-z]:$/i.test(s[0]), u = !f && s[0] === "" && s[1] === "" && s[2] === "?" && typeof s[3] == "string" && /^[a-z]:$/i.test(s[3]), p = c ? 3 : l ? 0 : void 0, g = u ? 3 : f ? 0 : void 0;
1246
- if (typeof p == "number" && typeof g == "number") {
1247
- let [d, w] = [t[p], s[g]];
1248
- d.toLowerCase() === w.toLowerCase() && (o = g + 1, n = p + 1);
1249
- }
1250
- }
1251
- return t = e, s.includes(v) ? this.#C(t, s, i, n, o) : this.#S(t, s, i, n, o);
1252
- }
1253
- #C(t, e, s, i, n) {
1254
- let { head: o, body: h, tail: a, segments: l } = this.#x(e, s, n);
1255
- if (o.length) {
1256
- let f = i + o.length;
1257
- if (!this.#S(t, o, s, i, 0, f)) return !1;
1258
- i += o.length, n += o.length;
1259
- }
1260
- let c = 0;
1261
- if (a.length) {
1262
- if (a.length + i > t.length) return !1;
1263
- let f = t.length - a.length;
1264
- if (this.#S(t, a, s, f, 0)) c = a.length;
1265
- else {
1266
- if (t[t.length - 1] !== "" || i + a.length === t.length || (f--, !this.#S(t, a, s, f, 0))) return !1;
1267
- c = a.length + 1;
1268
- }
1269
- }
1270
- if (!h.length) {
1271
- let f = !!c;
1272
- for (let u = i; u < t.length - c; u++) {
1273
- let p = String(t[u]);
1274
- if (f = !0, p === "." || p === ".." || !this.options.dot && p.startsWith(".")) return !1;
1275
- }
1276
- return s || f;
1277
- }
1278
- return !!this.#v(t, l, t.length - c, i, 0, s, 0, !!c, new Set());
1279
- }
1280
- #x(t, e, s) {
1281
- let i = this.#l.get(t);
1282
- i || (i = [], this.#l.set(t, i));
1283
- let n = s * 2 + (e ? 1 : 0), o = i[n];
1284
- if (o) return o;
1285
- let h = t.indexOf(v, s), a = t.lastIndexOf(v), l = t.slice(s, h), c = t.slice(h + 1, e ? void 0 : a), f = e ? [] : t.slice(a + 1), u = [[[], 0]], p = u[0], g = 0, d = [0];
1286
- for (let m of c) m === v ? (d.push(g), p = [[], 0], u.push(p)) : (p[0].push(m), g++);
1287
- u.forEach((m, b) => {
1288
- m[1] = g - d[b];
1289
- });
1290
- let w = {
1291
- head: l,
1292
- body: c,
1293
- tail: f,
1294
- segments: u
1295
- };
1296
- return i[n] = w, w;
1297
- }
1298
- #v(t, e, s, i, n, o, h, a, l) {
1299
- let c = e[n];
1300
- if (!c) {
1301
- if (o) return i >= s || i === s - 1 && t[i] === "";
1302
- for (let g = i; g < s; g++) {
1303
- a = !0;
1304
- let d = t[g];
1305
- if (d === "." || d === ".." || !this.options.dot && d.startsWith(".")) return !1;
1306
- }
1307
- return a;
1308
- }
1309
- let [f, u] = c, p = o ? s : s - u;
1310
- for (; i <= p;) {
1311
- let g = n * (t.length + 1) + i;
1312
- if (l.has(g)) return !1;
1313
- if (l.add(g), this.#S(t, f, o, i, 0, i + f.length) && h < this.maxGlobstarRecursion) {
1314
- let m = this.#v(t, e, s, i + f.length, n + 1, o, h + 1, a, l);
1315
- if (m !== !1) return m;
1316
- }
1317
- if (i === p) break;
1318
- let w = t[i];
1319
- if (w === "." || w === ".." || !this.options.dot && w.startsWith(".")) return !1;
1320
- i++;
1321
- }
1322
- return o || null;
1323
- }
1324
- #S(t, e, s, i, n, o = t.length) {
1325
- let h, a, l, c;
1326
- for (h = i, a = n, c = Math.min(o, t.length), l = e.length; h < c && a < l; h++, a++) {
1327
- let f = e[a], u = t[h];
1328
- if (f === !1 || f === v || !X(f, u)) return !1;
1329
- }
1330
- if (h === c && a === l) return !0;
1331
- if (h === c) return s;
1332
- if (a === l) return h === c - 1 && t[h] === "";
1333
- throw new Error("wtf?");
1334
- }
1335
- braceExpand() {
1336
- return xe(this.pattern, this.options);
1337
- }
1338
- #M() {
1339
- let { pattern: t } = this;
1340
- if (this.options.nobrace) return this.braceExpand();
1341
- let e = 57344;
1342
- for (; t.includes(String.fromCharCode(e));) if (++e > 63743) return this.braceExpand();
1343
- let s = String.fromCharCode(e), i = !1, n = t.replace(Ai, (h, a, l) => {
1344
- let c = Number(a), f = Number(l);
1345
- return !Number.isSafeInteger(c) || !Number.isSafeInteger(f) || Math.abs(c - f) + 1 < Ci ? h : (i = !0, `${s}${a}..${l}${s}`);
1346
- });
1347
- if (!i) return this.braceExpand();
1348
- let o = xe(n, this.options);
1349
- for (let h of o) for (let a of h.split("/")) {
1350
- let l = a.indexOf("[");
1351
- if (l !== -1 && l < a.lastIndexOf(s)) return this.braceExpand();
1352
- }
1353
- return this.#m = s, o;
1354
- }
1355
- parse(t) {
1356
- mt(t);
1357
- let e = this.options;
1358
- if (t === "**") return v;
1359
- if (t === "") return "";
1360
- let { nocase: s, nocaseMagicOnly: i, noext: n = !1, dot: o, normalize: h } = e, a = this.#m, l = a && t.includes(a) ? void 0 : Ri(t, n);
1361
- if (l !== void 0 && !(s && !i && t.toUpperCase() !== t.toLowerCase())) return this.#a(l);
1362
- if (this.#h) return Se;
1363
- let c = this.#f.get(t);
1364
- return c || (c = new pt(t, {
1365
- nocase: s,
1366
- noext: n,
1367
- dot: o,
1368
- normalize: h,
1369
- ...a && { rangeMark: a }
1370
- }), this.#f.set(t, c)), c;
1371
- }
1372
- #e(t) {
1373
- return this.preserveMultipleSlashes ? t.split("/") : this.isWindows && /^\/\/[^/]+/.test(t) ? ["", ...t.split(/\/+/)] : t.split(/\/+/);
1374
- }
1375
- match(t, e = this.partial) {
1376
- if (this.comment) return !1;
1377
- if (this.empty) return t === "";
1378
- if (t === "/" && e) return !0;
1379
- let s = this.options, i = this.#g(t);
1380
- if (!i) {
1381
- if (!e && !this.#o && (this.#t || this.#n) && os !== t) {
1382
- os = t;
1383
- let l = this.#b(t);
1384
- if (l === "no") return s.flipNegate ? !1 : this.negate;
1385
- if (l === "yes") return s.flipNegate ? !0 : !this.negate;
1386
- }
1387
- i = this.#w(t);
1388
- }
1389
- let n = i.parts, o = this.#i ? i.resolved ??= this.#p(n) : n, h = this.set, a = n[n.length - 1];
1390
- if (!a) for (let l = n.length - 2; !a && l >= 0; l--) a = n[l];
1391
- for (let l = 0; l < h.length; l++) {
1392
- let c = h[l], f = e ? void 0 : this.#d[l];
1393
- if (f === "base" ? X(c[0], a) : f ? this.#E(o, c, f) : s.matchBase && c.length === 1 ? this.#k([a], [a], c, e) : this.#k(n, o, c, e)) return s.flipNegate ? !0 : !this.negate;
1394
- }
1395
- return s.flipNegate ? !1 : this.negate;
1396
- }
1397
- static defaults(t) {
1398
- return T.defaults(t).Minimatch;
1399
- }
1400
- };
1401
- T.Minimatch = D;
1402
- T.escape = K;
1403
- T.unescape = st;
1404
- var M = channel("lru-cache:metrics");
1405
- var wt = tracingChannel("lru-cache");
1406
- var _i = typeof performance == "object" && performance && typeof performance.now == "function" ? performance : Date;
1407
- var ke = () => M.hasSubscribers || wt.hasSubscribers;
1408
- var us = new Set();
1409
- var fs = typeof process == "object" && process ? process : {};
1410
- var Di = (r, t, e, s) => {
1411
- typeof fs.emitWarning == "function" ? fs.emitWarning(r, t, e, s) : console.error(`[${e}] ${t}: ${r}`);
1412
- };
1413
- var Ni = (r) => !us.has(r);
1414
- var V = (r) => !!r && r === Math.floor(r) && r > 0 && isFinite(r);
1415
- var ds = (r) => V(r) ? r <= Math.pow(2, 8) ? Uint8Array : r <= Math.pow(2, 16) ? Uint16Array : r <= Math.pow(2, 32) ? Uint32Array : r <= Number.MAX_SAFE_INTEGER ? jt : null : null;
1416
- var jt = class extends Array {
1417
- constructor(r) {
1418
- super(r), this.fill(0);
1419
- }
1420
- };
1421
- var Pi = class bt {
1422
- heap;
1423
- length;
1424
- static #t = !1;
1425
- static create(t) {
1426
- let e = ds(t);
1427
- if (!e) return [];
1428
- bt.#t = !0;
1429
- let s = new bt(t, e);
1430
- return bt.#t = !1, s;
1431
- }
1432
- constructor(t, e) {
1433
- if (!bt.#t) throw new TypeError("instantiate Stack using Stack.create(n)");
1434
- this.heap = new e(t), this.length = 0;
1435
- }
1436
- push(t) {
1437
- this.heap[this.length++] = t;
1438
- }
1439
- pop() {
1440
- return this.heap[--this.length];
1441
- }
1442
- };
1443
- var yt = class ps {
1444
- #t;
1445
- #n;
1446
- #i;
1447
- #o;
1448
- #r;
1449
- #d;
1450
- #u;
1451
- #f;
1452
- get perf() {
1453
- return this.#f;
1454
- }
1455
- ttl;
1456
- ttlResolution;
1457
- ttlAutopurge;
1458
- updateAgeOnGet;
1459
- updateAgeOnHas;
1460
- allowStale;
1461
- noDisposeOnSet;
1462
- noUpdateTTL;
1463
- maxEntrySize;
1464
- sizeCalculation;
1465
- noDeleteOnFetchRejection;
1466
- noDeleteOnStaleGet;
1467
- allowStaleOnFetchAbort;
1468
- allowStaleOnFetchRejection;
1469
- ignoreFetchAbort;
1470
- backgroundFetchSize;
1471
- #h;
1472
- #m;
1473
- #l;
1474
- #a;
1475
- #s;
1476
- #b;
1477
- #E;
1478
- #y;
1479
- #g;
1480
- #w;
1481
- #p;
1482
- #k;
1483
- #C;
1484
- #x;
1485
- #v;
1486
- #S;
1487
- #M;
1488
- #e;
1489
- #T;
1490
- static unsafeExposeInternals(t) {
1491
- return {
1492
- starts: t.#C,
1493
- ttls: t.#x,
1494
- autopurgeTimers: t.#v,
1495
- sizes: t.#k,
1496
- keyMap: t.#l,
1497
- keyList: t.#a,
1498
- valList: t.#s,
1499
- next: t.#b,
1500
- prev: t.#E,
1501
- get head() {
1502
- return t.#y;
1503
- },
1504
- get tail() {
1505
- return t.#g;
1506
- },
1507
- free: t.#w,
1508
- isBackgroundFetch: (e) => t.#c(e),
1509
- backgroundFetch: (e, s, i, n) => t.#L(e, s, i, n),
1510
- moveToTail: (e) => t.#X(e),
1511
- indexes: (e) => t.#O(e),
1512
- rindexes: (e) => t.#F(e),
1513
- isStale: (e) => t.#A(e)
1514
- };
1515
- }
1516
- get max() {
1517
- return this.#t;
1518
- }
1519
- get maxSize() {
1520
- return this.#n;
1521
- }
1522
- get calculatedSize() {
1523
- return this.#m;
1524
- }
1525
- get size() {
1526
- return this.#h;
1527
- }
1528
- get fetchMethod() {
1529
- return this.#d;
1530
- }
1531
- get memoMethod() {
1532
- return this.#u;
1533
- }
1534
- get dispose() {
1535
- return this.#i;
1536
- }
1537
- get onInsert() {
1538
- return this.#o;
1539
- }
1540
- get disposeAfter() {
1541
- return this.#r;
1542
- }
1543
- constructor(t) {
1544
- let { max: e = 0, ttl: s, ttlResolution: i = 1, ttlAutopurge: n, updateAgeOnGet: o, updateAgeOnHas: h, allowStale: a, dispose: l, onInsert: c, disposeAfter: f, noDisposeOnSet: u, noUpdateTTL: p, maxSize: g = 0, maxEntrySize: d = 0, sizeCalculation: w, fetchMethod: m, memoMethod: b, noDeleteOnFetchRejection: x, noDeleteOnStaleGet: S, allowStaleOnFetchRejection: y, allowStaleOnFetchAbort: q, ignoreFetchAbort: W, backgroundFetchSize: B = 1, perf: et } = t;
1545
- if (this.backgroundFetchSize = B, et !== void 0 && typeof et?.now != "function") throw new TypeError("perf option must have a now() method if specified");
1546
- if (this.#f = et ?? _i, e !== 0 && !V(e)) throw new TypeError("max option must be a nonnegative integer");
1547
- let ie = e ? ds(e) : Array;
1548
- if (!ie) throw new Error("invalid max value: " + e);
1549
- if (this.#t = e, this.#n = g, this.maxEntrySize = d || this.#n, this.sizeCalculation = w, this.sizeCalculation) {
1550
- if (!this.#n && !this.maxEntrySize) throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");
1551
- if (typeof this.sizeCalculation != "function") throw new TypeError("sizeCalculation set to non-function");
1552
- }
1553
- if (b !== void 0 && typeof b != "function") throw new TypeError("memoMethod must be a function if defined");
1554
- if (this.#u = b, m !== void 0 && typeof m != "function") throw new TypeError("fetchMethod must be a function if specified");
1555
- if (this.#d = m, this.#M = !!m, this.#l = new Map(), this.#a = Array.from({ length: e }).fill(void 0), this.#s = Array.from({ length: e }).fill(void 0), this.#b = new ie(e), this.#E = new ie(e), this.#y = 0, this.#g = 0, this.#w = Pi.create(e), this.#h = 0, this.#m = 0, typeof l == "function" && (this.#i = l), typeof c == "function" && (this.#o = c), typeof f == "function" ? (this.#r = f, this.#p = []) : (this.#r = void 0, this.#p = void 0), this.#S = !!this.#i, this.#T = !!this.#o, this.#e = !!this.#r, this.noDisposeOnSet = !!u, this.noUpdateTTL = !!p, this.noDeleteOnFetchRejection = !!x, this.allowStaleOnFetchRejection = !!y, this.allowStaleOnFetchAbort = !!q, this.ignoreFetchAbort = !!W, this.maxEntrySize !== 0) {
1556
- if (this.#n !== 0 && !V(this.#n)) throw new TypeError("maxSize must be a positive integer if specified");
1557
- if (!V(this.maxEntrySize)) throw new TypeError("maxEntrySize must be a positive integer if specified");
1558
- this.#G();
1559
- }
1560
- if (this.allowStale = !!a, this.noDeleteOnStaleGet = !!S, this.updateAgeOnGet = !!o, this.updateAgeOnHas = !!h, this.ttlResolution = V(i) || i === 0 ? i : 1, this.ttlAutopurge = !!n, this.ttl = s || 0, this.ttl) {
1561
- if (!V(this.ttl)) throw new TypeError("ttl must be a positive integer if specified");
1562
- this.#_();
1563
- }
1564
- if (this.#t === 0 && this.ttl === 0 && this.#n === 0) throw new TypeError("At least one of max, maxSize, or ttl is required");
1565
- if (!this.ttlAutopurge && !this.#t && !this.#n) {
1566
- let ne = "LRU_CACHE_UNBOUNDED";
1567
- Ni(ne) && (us.add(ne), Di("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.", "UnboundedCacheWarning", ne, ps));
1568
- }
1569
- }
1570
- getRemainingTTL(t) {
1571
- return this.#l.has(t) ? 1 / 0 : 0;
1572
- }
1573
- #_() {
1574
- let t = new jt(this.#t), e = new jt(this.#t);
1575
- this.#x = t, this.#C = e;
1576
- let s = this.ttlAutopurge ? Array.from({ length: this.#t }) : void 0;
1577
- this.#v = s, this.#W = (a, l, c = this.#f.now()) => {
1578
- e[a] = l !== 0 ? c : 0, t[a] = l, i(a, l);
1579
- }, this.#R = (a) => {
1580
- e[a] = t[a] !== 0 ? this.#f.now() : 0, i(a, t[a]);
1581
- };
1582
- let i = this.ttlAutopurge ? (a, l) => {
1583
- if (s?.[a] && (clearTimeout(s[a]), s[a] = void 0), l && l !== 0 && s) {
1584
- let c = setTimeout(() => {
1585
- this.#A(a) ? (this.#j(this.#a[a], "expire"), s[a] = void 0) : i(a, h(a));
1586
- }, l + 1);
1587
- c.unref && c.unref(), s[a] = c;
1588
- }
1589
- } : () => {};
1590
- this.#D = (a, l) => {
1591
- if (t[l]) {
1592
- let c = t[l], f = e[l];
1593
- if (!c || !f) return;
1594
- a.ttl = c, a.start = f, a.now = n || o();
1595
- a.remainingTTL = c - (a.now - f);
1596
- }
1597
- };
1598
- let n = 0, o = () => {
1599
- let a = this.#f.now();
1600
- if (this.ttlResolution > 0) {
1601
- n = a;
1602
- let l = setTimeout(() => n = 0, this.ttlResolution);
1603
- l.unref && l.unref();
1604
- }
1605
- return a;
1606
- };
1607
- this.getRemainingTTL = (a) => {
1608
- let l = this.#l.get(a);
1609
- return l === void 0 ? 0 : h(l);
1610
- };
1611
- let h = (a) => {
1612
- let l = t[a], c = e[a];
1613
- if (!l || !c) return 1 / 0;
1614
- return l - ((n || o()) - c);
1615
- };
1616
- this.#A = (a) => {
1617
- let l = e[a], c = t[a];
1618
- return !!c && !!l && (n || o()) - l > c;
1619
- };
1620
- }
1621
- #R = () => {};
1622
- #D = () => {};
1623
- #W = () => {};
1624
- #A = () => !1;
1625
- #G() {
1626
- let t = new jt(this.#t);
1627
- this.#m = 0, this.#k = t, this.#P = (e) => {
1628
- this.#m -= t[e], t[e] = 0;
1629
- }, this.#$ = (e, s, i, n) => {
1630
- if (!V(i)) {
1631
- if (this.#c(s)) return this.backgroundFetchSize;
1632
- if (n) {
1633
- if (typeof n != "function") throw new TypeError("sizeCalculation must be a function");
1634
- if (i = n(s, e), !V(i)) throw new TypeError("sizeCalculation return invalid (expect positive integer)");
1635
- } else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");
1636
- }
1637
- return i;
1638
- }, this.#N = (e, s, i) => {
1639
- if (t[e] = s, this.#n) {
1640
- let n = this.#n - t[e];
1641
- for (; this.#m > n;) this.#U(!0);
1642
- }
1643
- this.#m += t[e], i && (i.entrySize = s, i.totalCalculatedSize = this.#m);
1644
- };
1645
- }
1646
- #P = (t) => {};
1647
- #N = (t, e, s) => {};
1648
- #$ = (t, e, s, i) => {
1649
- if (s || i) throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");
1650
- return 0;
1651
- };
1652
- *#O({ allowStale: t = this.allowStale } = {}) {
1653
- if (this.#h) for (let e = this.#g; this.#I(e) && ((t || !this.#A(e)) && (yield e), e !== this.#y);) e = this.#E[e];
1654
- }
1655
- *#F({ allowStale: t = this.allowStale } = {}) {
1656
- if (this.#h) for (let e = this.#y; this.#I(e) && ((t || !this.#A(e)) && (yield e), e !== this.#g);) e = this.#b[e];
1657
- }
1658
- #I(t) {
1659
- return t !== void 0 && this.#l.get(this.#a[t]) === t;
1660
- }
1661
- *entries() {
1662
- for (let t of this.#O()) this.#s[t] !== void 0 && this.#a[t] !== void 0 && !this.#c(this.#s[t]) && (yield [this.#a[t], this.#s[t]]);
1663
- }
1664
- *rentries() {
1665
- for (let t of this.#F()) this.#s[t] !== void 0 && this.#a[t] !== void 0 && !this.#c(this.#s[t]) && (yield [this.#a[t], this.#s[t]]);
1666
- }
1667
- *keys() {
1668
- for (let t of this.#O()) {
1669
- let e = this.#a[t];
1670
- e !== void 0 && !this.#c(this.#s[t]) && (yield e);
1671
- }
1672
- }
1673
- *rkeys() {
1674
- for (let t of this.#F()) {
1675
- let e = this.#a[t];
1676
- e !== void 0 && !this.#c(this.#s[t]) && (yield e);
1677
- }
1678
- }
1679
- *values() {
1680
- for (let t of this.#O()) this.#s[t] !== void 0 && !this.#c(this.#s[t]) && (yield this.#s[t]);
1681
- }
1682
- *rvalues() {
1683
- for (let t of this.#F()) this.#s[t] !== void 0 && !this.#c(this.#s[t]) && (yield this.#s[t]);
1684
- }
1685
- [Symbol.iterator]() {
1686
- return this.entries();
1687
- }
1688
- [Symbol.toStringTag] = "LRUCache";
1689
- find(t, e = {}) {
1690
- for (let s of this.#O()) {
1691
- let i = this.#s[s], n = this.#c(i) ? i.__staleWhileFetching : i;
1692
- if (n !== void 0 && t(n, this.#a[s], this)) return this.#K(this.#a[s], e);
1693
- }
1694
- }
1695
- forEach(t, e = this) {
1696
- for (let s of this.#O()) {
1697
- let i = this.#s[s], n = this.#c(i) ? i.__staleWhileFetching : i;
1698
- n !== void 0 && t.call(e, n, this.#a[s], this);
1699
- }
1700
- }
1701
- rforEach(t, e = this) {
1702
- for (let s of this.#F()) {
1703
- let i = this.#s[s], n = this.#c(i) ? i.__staleWhileFetching : i;
1704
- n !== void 0 && t.call(e, n, this.#a[s], this);
1705
- }
1706
- }
1707
- purgeStale() {
1708
- let t = !1;
1709
- for (let e of this.#F({ allowStale: !0 })) this.#A(e) && (this.#j(this.#a[e], "expire"), t = !0);
1710
- return t;
1711
- }
1712
- info(t) {
1713
- let e = this.#l.get(t);
1714
- if (e === void 0) return;
1715
- let s = this.#s[e], i = this.#c(s) ? s.__staleWhileFetching : s;
1716
- if (i === void 0) return;
1717
- let n = { value: i };
1718
- if (this.#x && this.#C) {
1719
- let o = this.#x[e], h = this.#C[e];
1720
- if (o && h) n.ttl = o - (this.#f.now() - h), n.start = Date.now();
1721
- }
1722
- return this.#k && (n.size = this.#k[e]), n;
1723
- }
1724
- dump() {
1725
- let t = [];
1726
- for (let e of this.#O({ allowStale: !0 })) {
1727
- let s = this.#a[e], i = this.#s[e], n = this.#c(i) ? i.__staleWhileFetching : i;
1728
- if (n === void 0 || s === void 0) continue;
1729
- let o = { value: n };
1730
- if (this.#x && this.#C) {
1731
- o.ttl = this.#x[e];
1732
- let h = this.#f.now() - this.#C[e];
1733
- o.start = Math.floor(Date.now() - h);
1734
- }
1735
- this.#k && (o.size = this.#k[e]), t.unshift([s, o]);
1736
- }
1737
- return t;
1738
- }
1739
- load(t) {
1740
- this.clear();
1741
- for (let [e, s] of t) {
1742
- if (s.start) {
1743
- let i = Date.now() - s.start;
1744
- s.start = this.#f.now() - i;
1745
- }
1746
- this.#z(e, s.value, s);
1747
- }
1748
- }
1749
- set(t, e, s = {}) {
1750
- let { status: i = M.hasSubscribers ? {} : void 0 } = s;
1751
- s.status = i, i && (i.op = "set", i.key = t, e !== void 0 && (i.value = e), i.cache = this);
1752
- let n = this.#z(t, e, s);
1753
- return i && M.hasSubscribers && M.publish(i), n;
1754
- }
1755
- #z(t, e, s, i) {
1756
- let { ttl: n = this.ttl, start: o, noDisposeOnSet: h = this.noDisposeOnSet, sizeCalculation: a = this.sizeCalculation, status: l } = s, c = this.#c(e);
1757
- if (e === void 0) return l && (l.set = "deleted"), this.delete(t), this;
1758
- let { noUpdateTTL: f = this.noUpdateTTL } = s;
1759
- l && !c && (l.value = e);
1760
- let u = this.#$(t, e, s.size || 0, a, l);
1761
- if (this.maxEntrySize && u > this.maxEntrySize) return this.#j(t, "set"), l && (l.set = "miss", l.maxEntrySizeExceeded = !0), this;
1762
- let p = this.#h === 0 ? void 0 : this.#l.get(t);
1763
- if (p === void 0) p = this.#h === 0 ? this.#g : this.#w.length !== 0 ? this.#w.pop() : this.#h === this.#t ? this.#U(!1) : this.#h, this.#a[p] = t, this.#s[p] = e, this.#l.set(t, p), this.#b[this.#g] = p, this.#E[p] = this.#g, this.#g = p, this.#h++, this.#N(p, u, l), l && (l.set = "add"), f = !1, this.#T && !c && this.#o?.(e, t, "add");
1764
- else {
1765
- this.#X(p);
1766
- let g = this.#s[p];
1767
- if (e !== g) {
1768
- if (!h) if (this.#c(g)) {
1769
- g !== i && g.__abortController.abort(new Error("replaced"));
1770
- let { __staleWhileFetching: d } = g;
1771
- d !== void 0 && d !== e && (this.#S && this.#i?.(d, t, "set"), this.#e && this.#p?.push([
1772
- d,
1773
- t,
1774
- "set"
1775
- ]));
1776
- } else this.#S && this.#i?.(g, t, "set"), this.#e && this.#p?.push([
1777
- g,
1778
- t,
1779
- "set"
1780
- ]);
1781
- if (this.#P(p), this.#N(p, u, l), this.#s[p] = e, !c) {
1782
- let d = g && this.#c(g) ? g.__staleWhileFetching : g, w = d === void 0 ? "add" : e !== d ? "replace" : "update";
1783
- l && (l.set = w, d !== void 0 && (l.oldValue = d)), this.#T && this.onInsert?.(e, t, w);
1784
- }
1785
- } else c || (l && (l.set = "update"), this.#T && this.onInsert?.(e, t, "update"));
1786
- }
1787
- if (n !== 0 && !this.#x && this.#_(), this.#x && (f || this.#W(p, n, o), l && this.#D(l, p)), !h && this.#e && this.#p) {
1788
- let g = this.#p, d;
1789
- for (; d = g?.shift();) this.#r?.(...d);
1790
- }
1791
- return this;
1792
- }
1793
- pop() {
1794
- try {
1795
- for (; this.#h;) {
1796
- let t = this.#s[this.#y];
1797
- if (this.#U(!0), this.#c(t)) {
1798
- if (t.__staleWhileFetching) return t.__staleWhileFetching;
1799
- } else if (t !== void 0) return t;
1800
- }
1801
- } finally {
1802
- if (this.#e && this.#p) {
1803
- let t = this.#p, e;
1804
- for (; e = t?.shift();) this.#r?.(...e);
1805
- }
1806
- }
1807
- }
1808
- #U(t) {
1809
- let e = this.#y, s = this.#a[e], i = this.#s[e], n = this.#c(i);
1810
- n && i.__abortController.abort(new Error("evicted"));
1811
- let o = n ? i.__staleWhileFetching : i;
1812
- return (this.#S || this.#e) && o !== void 0 && (this.#S && this.#i?.(o, s, "evict"), this.#e && this.#p?.push([
1813
- o,
1814
- s,
1815
- "evict"
1816
- ])), this.#P(e), this.#v?.[e] && (clearTimeout(this.#v[e]), this.#v[e] = void 0), t && (this.#a[e] = void 0, this.#s[e] = void 0, this.#w.push(e)), this.#h === 1 ? (this.#y = this.#g = 0, this.#w.length = 0) : this.#y = this.#b[e], this.#l.delete(s), this.#h--, e;
1817
- }
1818
- has(t, e = {}) {
1819
- let { status: s = M.hasSubscribers ? {} : void 0 } = e;
1820
- e.status = s, s && (s.op = "has", s.key = t, s.cache = this);
1821
- let i = this.#V(t, e);
1822
- return M.hasSubscribers && M.publish(s), i;
1823
- }
1824
- #V(t, e = {}) {
1825
- let { updateAgeOnHas: s = this.updateAgeOnHas, status: i } = e, n = this.#l.get(t);
1826
- if (n !== void 0) {
1827
- let o = this.#s[n];
1828
- if (this.#c(o) && o.__staleWhileFetching === void 0) return !1;
1829
- if (this.#A(n)) i && (i.has = "stale", this.#D(i, n));
1830
- else return s && this.#R(n), i && (i.has = "hit", this.#D(i, n)), !0;
1831
- } else i && (i.has = "miss");
1832
- return !1;
1833
- }
1834
- peek(t, e = {}) {
1835
- let { status: s = ke() ? {} : void 0 } = e;
1836
- s && (s.op = "peek", s.key = t, s.cache = this), e.status = s;
1837
- let i = this.#H(t, e);
1838
- return M.hasSubscribers && M.publish(s), i;
1839
- }
1840
- #H(t, e) {
1841
- let { status: s, allowStale: i = this.allowStale } = e, n = this.#l.get(t);
1842
- if (n === void 0 || !i && this.#A(n)) {
1843
- s && (s.peek = n === void 0 ? "miss" : "stale");
1844
- return;
1845
- }
1846
- let o = this.#s[n], h = this.#c(o) ? o.__staleWhileFetching : o;
1847
- return s && (h !== void 0 ? (s.peek = "hit", s.value = h) : s.peek = "miss"), h;
1848
- }
1849
- #L(t, e, s, i) {
1850
- let n = e === void 0 ? void 0 : this.#s[e];
1851
- if (this.#c(n)) return n;
1852
- let o = new AbortController(), { signal: h } = s;
1853
- h?.addEventListener("abort", () => o.abort(h.reason), { signal: o.signal });
1854
- let a = {
1855
- signal: o.signal,
1856
- options: s,
1857
- context: i
1858
- }, l = (d, w = !1) => {
1859
- let { aborted: m } = o.signal, b = s.ignoreFetchAbort && d !== void 0, x = s.ignoreFetchAbort || !!(s.allowStaleOnFetchAbort && d !== void 0);
1860
- if (s.status && (m && !w ? (s.status.fetchAborted = !0, s.status.fetchError = o.signal.reason, b && (s.status.fetchAbortIgnored = !0)) : s.status.fetchResolved = !0), m && !b && !w) return f(o.signal.reason, x);
1861
- let S = p, y = this.#s[e];
1862
- return (y === p || y === void 0 && b && w) && (d === void 0 ? S.__staleWhileFetching !== void 0 ? this.#s[e] = S.__staleWhileFetching : this.#j(t, "fetch") : (s.status && (s.status.fetchUpdated = !0), this.#z(t, d, a.options, S))), d;
1863
- }, c = (d) => (s.status && (s.status.fetchRejected = !0, s.status.fetchError = d), f(d, !1)), f = (d, w) => {
1864
- let { aborted: m } = o.signal, b = m && s.allowStaleOnFetchAbort, x = b || s.allowStaleOnFetchRejection, S = x || s.noDeleteOnFetchRejection, y = p;
1865
- if (this.#s[e] === p && (!S || !w && y.__staleWhileFetching === void 0 ? this.#j(t, "fetch") : b || (this.#s[e] = y.__staleWhileFetching)), x) return s.status && y.__staleWhileFetching !== void 0 && (s.status.returnedStale = !0), y.__staleWhileFetching;
1866
- if (y.__returned === y) throw d;
1867
- }, u = (d, w) => {
1868
- let m = this.#d?.(t, n, a);
1869
- o.signal.addEventListener("abort", () => {
1870
- (!s.ignoreFetchAbort || s.allowStaleOnFetchAbort) && (d(void 0), s.allowStaleOnFetchAbort && (d = (b) => l(b, !0)));
1871
- }), m && m instanceof Promise ? m.then((b) => d(b === void 0 ? void 0 : b), w) : m !== void 0 && d(m);
1872
- };
1873
- s.status && (s.status.fetchDispatched = !0);
1874
- let p = new Promise(u).then(l, c), g = Object.assign(p, {
1875
- __abortController: o,
1876
- __staleWhileFetching: n,
1877
- __returned: void 0
1878
- });
1879
- return e === void 0 ? (this.#z(t, g, {
1880
- ...a.options,
1881
- status: void 0
1882
- }), e = this.#l.get(t)) : this.#s[e] = g, g;
1883
- }
1884
- #c(t) {
1885
- if (!this.#M) return !1;
1886
- let e = t;
1887
- return !!e && e instanceof Promise && e.hasOwnProperty("__staleWhileFetching") && e.__abortController instanceof AbortController;
1888
- }
1889
- fetch(t, e = {}) {
1890
- let s = wt.hasSubscribers, { status: i = ke() ? {} : void 0 } = e;
1891
- e.status = i, i && e.context && (i.context = e.context);
1892
- let n = this.#q(t, e);
1893
- return i && s && (i.trace = !0, wt.tracePromise(() => n, i).catch(() => {})), n;
1894
- }
1895
- async #q(t, e = {}) {
1896
- let { allowStale: s = this.allowStale, updateAgeOnGet: i = this.updateAgeOnGet, noDeleteOnStaleGet: n = this.noDeleteOnStaleGet, ttl: o = this.ttl, noDisposeOnSet: h = this.noDisposeOnSet, size: a = 0, sizeCalculation: l = this.sizeCalculation, noUpdateTTL: c = this.noUpdateTTL, noDeleteOnFetchRejection: f = this.noDeleteOnFetchRejection, allowStaleOnFetchRejection: u = this.allowStaleOnFetchRejection, ignoreFetchAbort: p = this.ignoreFetchAbort, allowStaleOnFetchAbort: g = this.allowStaleOnFetchAbort, context: d, forceRefresh: w = !1, status: m, signal: b } = e;
1897
- if (m && (m.op = "fetch", m.key = t, w && (m.forceRefresh = !0), m.cache = this), !this.#M) return m && (m.fetch = "get"), this.#K(t, {
1898
- allowStale: s,
1899
- updateAgeOnGet: i,
1900
- noDeleteOnStaleGet: n,
1901
- status: m
1902
- });
1903
- let x = {
1904
- allowStale: s,
1905
- updateAgeOnGet: i,
1906
- noDeleteOnStaleGet: n,
1907
- ttl: o,
1908
- noDisposeOnSet: h,
1909
- size: a,
1910
- sizeCalculation: l,
1911
- noUpdateTTL: c,
1912
- noDeleteOnFetchRejection: f,
1913
- allowStaleOnFetchRejection: u,
1914
- allowStaleOnFetchAbort: g,
1915
- ignoreFetchAbort: p,
1916
- status: m,
1917
- signal: b
1918
- }, S = this.#l.get(t);
1919
- if (S === void 0) {
1920
- m && (m.fetch = "miss");
1921
- let y = this.#L(t, S, x, d);
1922
- return y.__returned = y;
1923
- } else {
1924
- let y = this.#s[S];
1925
- if (this.#c(y)) {
1926
- let et = s && y.__staleWhileFetching !== void 0;
1927
- return m && (m.fetch = "inflight", et && (m.returnedStale = !0)), et ? y.__staleWhileFetching : y.__returned = y;
1928
- }
1929
- let q = this.#A(S);
1930
- if (!w && !q) return m && (m.fetch = "hit"), this.#X(S), i && this.#R(S), m && this.#D(m, S), y;
1931
- let W = this.#L(t, S, x, d), B = W.__staleWhileFetching !== void 0 && s;
1932
- return m && (m.fetch = q ? "stale" : "refresh", B && q && (m.returnedStale = !0)), B ? W.__staleWhileFetching : W.__returned = W;
1933
- }
1934
- }
1935
- forceFetch(t, e = {}) {
1936
- let s = wt.hasSubscribers, { status: i = ke() ? {} : void 0 } = e;
1937
- e.status = i, i && e.context && (i.context = e.context);
1938
- let n = this.#B(t, e);
1939
- return i && s && (i.trace = !0, wt.tracePromise(() => n, i).catch(() => {})), n;
1940
- }
1941
- async #B(t, e = {}) {
1942
- let s = await this.#q(t, e);
1943
- if (s === void 0) throw new Error("fetch() returned undefined");
1944
- return s;
1945
- }
1946
- memo(t, e = {}) {
1947
- let { status: s = M.hasSubscribers ? {} : void 0 } = e;
1948
- e.status = s, s && (s.op = "memo", s.key = t, e.context && (s.context = e.context), s.cache = this);
1949
- let i = this.#Z(t, e);
1950
- return s && (s.value = i), M.hasSubscribers && M.publish(s), i;
1951
- }
1952
- #Z(t, e = {}) {
1953
- let s = this.#u;
1954
- if (!s) throw new Error("no memoMethod provided to constructor");
1955
- let { context: i, status: n, forceRefresh: o, ...h } = e;
1956
- n && o && (n.forceRefresh = !0);
1957
- let a = this.#K(t, h), l = o || a === void 0;
1958
- if (n && (n.memo = l ? "miss" : "hit", l || (n.value = a)), !l) return a;
1959
- let c = s(t, a, {
1960
- options: h,
1961
- context: i
1962
- });
1963
- return n && (n.value = c), this.#z(t, c, h), c;
1964
- }
1965
- get(t, e = {}) {
1966
- let { status: s = M.hasSubscribers ? {} : void 0 } = e;
1967
- e.status = s, s && (s.op = "get", s.key = t, s.cache = this);
1968
- let i = this.#K(t, e);
1969
- return s && (i !== void 0 && (s.value = i), M.hasSubscribers && M.publish(s)), i;
1970
- }
1971
- #K(t, e = {}) {
1972
- let { allowStale: s = this.allowStale, updateAgeOnGet: i = this.updateAgeOnGet, noDeleteOnStaleGet: n = this.noDeleteOnStaleGet, status: o } = e, h = this.#l.get(t);
1973
- if (h === void 0) {
1974
- o && (o.get = "miss");
1975
- return;
1976
- }
1977
- let a = this.#s[h], l = this.#c(a);
1978
- return o && this.#D(o, h), this.#A(h) ? l ? (o && (o.get = "stale-fetching"), s && a.__staleWhileFetching !== void 0 ? (o && (o.returnedStale = !0), a.__staleWhileFetching) : void 0) : (n || this.#j(t, "expire"), o && (o.get = "stale"), s ? (o && (o.returnedStale = !0), a) : void 0) : (o && (o.get = l ? "fetching" : "hit"), this.#X(h), i && this.#R(h), l ? a.__staleWhileFetching : a);
1979
- }
1980
- #Y(t, e) {
1981
- this.#E[e] = t, this.#b[t] = e;
1982
- }
1983
- #X(t) {
1984
- t !== this.#g && (t === this.#y ? this.#y = this.#b[t] : this.#Y(this.#E[t], this.#b[t]), this.#Y(this.#g, t), this.#g = t);
1985
- }
1986
- delete(t) {
1987
- return this.#j(t, "delete");
1988
- }
1989
- #j(t, e) {
1990
- M.hasSubscribers && M.publish({
1991
- op: "delete",
1992
- delete: e,
1993
- key: t,
1994
- cache: this
1995
- });
1996
- let s = !1;
1997
- if (this.#h !== 0) {
1998
- let i = this.#l.get(t);
1999
- if (i !== void 0) if (this.#v?.[i] && (clearTimeout(this.#v[i]), this.#v[i] = void 0), s = !0, this.#h === 1) this.#J(e);
2000
- else {
2001
- this.#P(i);
2002
- let n = this.#s[i];
2003
- if (this.#c(n) ? n.__abortController.abort(new Error("deleted")) : (this.#S || this.#e) && (this.#S && this.#i?.(n, t, e), this.#e && this.#p?.push([
2004
- n,
2005
- t,
2006
- e
2007
- ])), this.#l.delete(t), this.#a[i] = void 0, this.#s[i] = void 0, i === this.#g) this.#g = this.#E[i];
2008
- else if (i === this.#y) this.#y = this.#b[i];
2009
- else {
2010
- let o = this.#E[i];
2011
- this.#b[o] = this.#b[i];
2012
- let h = this.#b[i];
2013
- this.#E[h] = this.#E[i];
2014
- }
2015
- this.#h--, this.#w.push(i);
2016
- }
2017
- }
2018
- if (this.#e && this.#p?.length) {
2019
- let i = this.#p, n;
2020
- for (; n = i?.shift();) this.#r?.(...n);
2021
- }
2022
- return s;
2023
- }
2024
- clear() {
2025
- return this.#J("delete");
2026
- }
2027
- #J(t) {
2028
- for (let e of this.#F({ allowStale: !0 })) {
2029
- let s = this.#s[e];
2030
- if (this.#c(s)) s.__abortController.abort(new Error("deleted"));
2031
- else {
2032
- let i = this.#a[e];
2033
- this.#S && this.#i?.(s, i, t), this.#e && this.#p?.push([
2034
- s,
2035
- i,
2036
- t
2037
- ]);
2038
- }
2039
- }
2040
- if (this.#l.clear(), this.#s.fill(void 0), this.#a.fill(void 0), this.#x && this.#C) {
2041
- this.#x.fill(0), this.#C.fill(0);
2042
- for (let e of this.#v ?? []) e !== void 0 && clearTimeout(e);
2043
- this.#v?.fill(void 0);
2044
- }
2045
- if (this.#k && this.#k.fill(0), this.#y = 0, this.#g = 0, this.#w.length = 0, this.#m = 0, this.#h = 0, this.#e && this.#p) {
2046
- let e = this.#p, s;
2047
- for (; s = e?.shift();) this.#r?.(...s);
2048
- }
2049
- }
2050
- };
2051
- var ms = typeof process == "object" && process ? process : {
2052
- stdout: null,
2053
- stderr: null
2054
- };
2055
- var Li = (r) => !!r && typeof r == "object" && (r instanceof J || r instanceof ys || ji(r) || Wi(r));
2056
- var ji = (r) => !!r && typeof r == "object" && r instanceof EventEmitter && typeof r.pipe == "function" && r.pipe !== ys.Writable.prototype.pipe;
2057
- var Wi = (r) => !!r && typeof r == "object" && r instanceof EventEmitter && typeof r.write == "function" && typeof r.end == "function";
2058
- var G = Symbol("EOF");
2059
- var H = Symbol("maybeEmitEnd");
2060
- var Y = Symbol("emittedEnd");
2061
- var Wt = Symbol("emittingEnd");
2062
- var St = Symbol("emittedError");
2063
- var $t = Symbol("closed");
2064
- var gs = Symbol("read");
2065
- var It = Symbol("flush");
2066
- var ws = Symbol("flushChunk");
2067
- var z = Symbol("encoding");
2068
- var nt = Symbol("decoder");
2069
- var k = Symbol("flowing");
2070
- var xt = Symbol("paused");
2071
- var rt = Symbol("resume");
2072
- var C = Symbol("buffer");
2073
- var F = Symbol("pipes");
2074
- var A = Symbol("bufferLength");
2075
- var Ce = Symbol("bufferPush");
2076
- var Bt = Symbol("bufferShift");
2077
- var R = Symbol("objectMode");
2078
- var E = Symbol("destroyed");
2079
- var Ae = Symbol("error");
2080
- var Me = Symbol("emitData");
2081
- var bs = Symbol("emitEnd");
2082
- var Re = Symbol("emitEnd2");
2083
- var $ = Symbol("async");
2084
- var Oe = Symbol("abort");
2085
- var Ut = Symbol("aborted");
2086
- var vt = Symbol("signal");
2087
- var Q = Symbol("dataListeners");
2088
- var _ = Symbol("discarded");
2089
- var Et = (r) => Promise.resolve().then(r);
2090
- var $i = (r) => r();
2091
- var Ii = (r) => r === "end" || r === "finish" || r === "prefinish";
2092
- var Bi = (r) => r instanceof ArrayBuffer || !!r && typeof r == "object" && r.constructor && r.constructor.name === "ArrayBuffer" && r.byteLength >= 0;
2093
- var Ui = (r) => !Buffer.isBuffer(r) && ArrayBuffer.isView(r);
2094
- var Gt = class {
2095
- src;
2096
- dest;
2097
- opts;
2098
- ondrain;
2099
- constructor(t, e, s) {
2100
- this.src = t, this.dest = e, this.opts = s, this.ondrain = () => t[rt](), this.dest.on("drain", this.ondrain);
2101
- }
2102
- unpipe() {
2103
- this.dest.removeListener("drain", this.ondrain);
2104
- }
2105
- proxyErrors(t) {}
2106
- end() {
2107
- this.unpipe(), this.opts.end && this.dest.end();
2108
- }
2109
- };
2110
- var Fe = class extends Gt {
2111
- unpipe() {
2112
- this.src.removeListener("error", this.proxyErrors), super.unpipe();
2113
- }
2114
- constructor(t, e, s) {
2115
- super(t, e, s), this.proxyErrors = (i) => this.dest.emit("error", i), t.on("error", this.proxyErrors);
2116
- }
2117
- };
2118
- var Gi = (r) => !!r.objectMode;
2119
- var Hi = (r) => !r.objectMode && !!r.encoding && r.encoding !== "buffer";
2120
- var J = class extends EventEmitter {
2121
- [k] = !1;
2122
- [xt] = !1;
2123
- [F] = [];
2124
- [C] = [];
2125
- [R];
2126
- [z];
2127
- [$];
2128
- [nt];
2129
- [G] = !1;
2130
- [Y] = !1;
2131
- [Wt] = !1;
2132
- [$t] = !1;
2133
- [St] = null;
2134
- [A] = 0;
2135
- [E] = !1;
2136
- [vt];
2137
- [Ut] = !1;
2138
- [Q] = 0;
2139
- [_] = !1;
2140
- writable = !0;
2141
- readable = !0;
2142
- constructor(...t) {
2143
- let e = t[0] || {};
2144
- if (super(), e.objectMode && typeof e.encoding == "string") throw new TypeError("Encoding and objectMode may not be used together");
2145
- Gi(e) ? (this[R] = !0, this[z] = null) : Hi(e) ? (this[z] = e.encoding, this[R] = !1) : (this[R] = !1, this[z] = null), this[$] = !!e.async, this[nt] = this[z] ? new StringDecoder(this[z]) : null, e && e.debugExposeBuffer === !0 && Object.defineProperty(this, "buffer", { get: () => this[C] }), e && e.debugExposePipes === !0 && Object.defineProperty(this, "pipes", { get: () => this[F] });
2146
- let { signal: s } = e;
2147
- s && (this[vt] = s, s.aborted ? this[Oe]() : s.addEventListener("abort", () => this[Oe]()));
2148
- }
2149
- get bufferLength() {
2150
- return this[A];
2151
- }
2152
- get encoding() {
2153
- return this[z];
2154
- }
2155
- set encoding(t) {
2156
- throw new Error("Encoding must be set at instantiation time");
2157
- }
2158
- setEncoding(t) {
2159
- throw new Error("Encoding must be set at instantiation time");
2160
- }
2161
- get objectMode() {
2162
- return this[R];
2163
- }
2164
- set objectMode(t) {
2165
- throw new Error("objectMode must be set at instantiation time");
2166
- }
2167
- get async() {
2168
- return this[$];
2169
- }
2170
- set async(t) {
2171
- this[$] = this[$] || !!t;
2172
- }
2173
- [Oe]() {
2174
- this[Ut] = !0, this.emit("abort", this[vt]?.reason), this.destroy(this[vt]?.reason);
2175
- }
2176
- get aborted() {
2177
- return this[Ut];
2178
- }
2179
- set aborted(t) {}
2180
- write(t, e, s) {
2181
- if (this[Ut]) return !1;
2182
- if (this[G]) throw new Error("write after end");
2183
- if (this[E]) return this.emit("error", Object.assign(new Error("Cannot call write after a stream was destroyed"), { code: "ERR_STREAM_DESTROYED" })), !0;
2184
- typeof e == "function" && (s = e, e = "utf8"), e || (e = "utf8");
2185
- let i = this[$] ? Et : $i;
2186
- if (!this[R] && !Buffer.isBuffer(t)) {
2187
- if (Ui(t)) t = Buffer.from(t.buffer, t.byteOffset, t.byteLength);
2188
- else if (Bi(t)) t = Buffer.from(t);
2189
- else if (typeof t != "string") throw new Error("Non-contiguous data written to non-objectMode stream");
2190
- }
2191
- return this[R] ? (this[k] && this[A] !== 0 && this[It](!0), this[k] ? this.emit("data", t) : this[Ce](t), this[A] !== 0 && this.emit("readable"), s && i(s), this[k]) : t.length ? (typeof t == "string" && (e !== this[z] || this[nt]?.lastNeed) && (t = Buffer.from(t, e)), Buffer.isBuffer(t) && this[z] && (t = this[nt].write(t)), this[k] && this[A] !== 0 && this[It](!0), this[k] ? this.emit("data", t) : this[Ce](t), this[A] !== 0 && this.emit("readable"), s && i(s), this[k]) : (this[A] !== 0 && this.emit("readable"), s && i(s), this[k]);
2192
- }
2193
- read(t) {
2194
- if (this[E]) return null;
2195
- if (this[_] = !1, this[A] === 0 || t === 0 || t && t > this[A]) return this[H](), null;
2196
- this[R] && (t = null), this[C].length > 1 && !this[R] && (this[C] = [this[z] ? this[C].join("") : Buffer.concat(this[C], this[A])]);
2197
- let e = this[gs](t || null, this[C][0]);
2198
- return this[H](), e;
2199
- }
2200
- [gs](t, e) {
2201
- if (this[R]) this[Bt]();
2202
- else {
2203
- let s = e;
2204
- t === s.length || t === null ? this[Bt]() : typeof s == "string" ? (this[C][0] = s.slice(t), e = s.slice(0, t), this[A] -= t) : (this[C][0] = s.subarray(t), e = s.subarray(0, t), this[A] -= t);
2205
- }
2206
- return this.emit("data", e), !this[C].length && !this[G] && this.emit("drain"), e;
2207
- }
2208
- end(t, e, s) {
2209
- return typeof t == "function" && (s = t, t = void 0), typeof e == "function" && (s = e, e = "utf8"), t !== void 0 && this.write(t, e), s && this.once("end", s), this[G] = !0, this.writable = !1, (this[k] || !this[xt]) && this[H](), this;
2210
- }
2211
- [rt]() {
2212
- this[E] || (!this[Q] && !this[F].length && (this[_] = !0), this[xt] = !1, this[k] = !0, this.emit("resume"), this[C].length ? this[It]() : this[G] ? this[H]() : this.emit("drain"));
2213
- }
2214
- resume() {
2215
- return this[rt]();
2216
- }
2217
- pause() {
2218
- this[k] = !1, this[xt] = !0, this[_] = !1;
2219
- }
2220
- get destroyed() {
2221
- return this[E];
2222
- }
2223
- get flowing() {
2224
- return this[k];
2225
- }
2226
- get paused() {
2227
- return this[xt];
2228
- }
2229
- [Ce](t) {
2230
- this[R] ? this[A] += 1 : this[A] += t.length, this[C].push(t);
2231
- }
2232
- [Bt]() {
2233
- return this[R] ? this[A] -= 1 : this[A] -= this[C][0].length, this[C].shift();
2234
- }
2235
- [It](t = !1) {
2236
- do;
2237
- while (this[ws](this[Bt]()) && this[C].length);
2238
- !t && !this[C].length && !this[G] && this.emit("drain");
2239
- }
2240
- [ws](t) {
2241
- return this.emit("data", t), this[k];
2242
- }
2243
- pipe(t, e) {
2244
- if (this[E]) return t;
2245
- this[_] = !1;
2246
- let s = this[Y];
2247
- return e = e || {}, t === ms.stdout || t === ms.stderr ? e.end = !1 : e.end = e.end !== !1, e.proxyErrors = !!e.proxyErrors, s ? e.end && t.end() : (this[F].push(e.proxyErrors ? new Fe(this, t, e) : new Gt(this, t, e)), this[$] ? Et(() => this[rt]()) : this[rt]()), t;
2248
- }
2249
- unpipe(t) {
2250
- let e = this[F].find((s) => s.dest === t);
2251
- e && (this[F].length === 1 ? (this[k] && this[Q] === 0 && (this[k] = !1), this[F] = []) : this[F].splice(this[F].indexOf(e), 1), e.unpipe());
2252
- }
2253
- addListener(t, e) {
2254
- return this.on(t, e);
2255
- }
2256
- on(t, e) {
2257
- let s = super.on(t, e);
2258
- if (t === "data") this[_] = !1, this[Q]++, !this[F].length && !this[k] && this[rt]();
2259
- else if (t === "readable" && this[A] !== 0) super.emit("readable");
2260
- else if (Ii(t) && this[Y]) super.emit(t), this.removeAllListeners(t);
2261
- else if (t === "error" && this[St]) {
2262
- let i = e;
2263
- this[$] ? Et(() => i.call(this, this[St])) : i.call(this, this[St]);
2264
- }
2265
- return s;
2266
- }
2267
- removeListener(t, e) {
2268
- return this.off(t, e);
2269
- }
2270
- off(t, e) {
2271
- let s = super.off(t, e);
2272
- return t === "data" && (this[Q] = this.listeners("data").length, this[Q] === 0 && !this[_] && !this[F].length && (this[k] = !1)), s;
2273
- }
2274
- removeAllListeners(t) {
2275
- let e = super.removeAllListeners(t);
2276
- return (t === "data" || t === void 0) && (this[Q] = 0, !this[_] && !this[F].length && (this[k] = !1)), e;
2277
- }
2278
- get emittedEnd() {
2279
- return this[Y];
2280
- }
2281
- [H]() {
2282
- !this[Wt] && !this[Y] && !this[E] && this[C].length === 0 && this[G] && (this[Wt] = !0, this.emit("end"), this.emit("prefinish"), this.emit("finish"), this[$t] && this.emit("close"), this[Wt] = !1);
2283
- }
2284
- emit(t, ...e) {
2285
- let s = e[0];
2286
- if (t !== "error" && t !== "close" && t !== E && this[E]) return !1;
2287
- if (t === "data") return !this[R] && !s ? !1 : this[$] ? (Et(() => this[Me](s)), !0) : this[Me](s);
2288
- if (t === "end") return this[bs]();
2289
- if (t === "close") {
2290
- if (this[$t] = !0, !this[Y] && !this[E]) return !1;
2291
- let n = super.emit("close");
2292
- return this.removeAllListeners("close"), n;
2293
- } else if (t === "error") {
2294
- this[St] = s, super.emit(Ae, s);
2295
- let n = !this[vt] || this.listeners("error").length ? super.emit("error", s) : !1;
2296
- return this[H](), n;
2297
- } else if (t === "resume") {
2298
- let n = super.emit("resume");
2299
- return this[H](), n;
2300
- } else if (t === "finish" || t === "prefinish") {
2301
- let n = super.emit(t);
2302
- return this.removeAllListeners(t), n;
2303
- }
2304
- let i = super.emit(t, ...e);
2305
- return this[H](), i;
2306
- }
2307
- [Me](t) {
2308
- for (let s of this[F]) s.dest.write(t) === !1 && this.pause();
2309
- let e = this[_] ? !1 : super.emit("data", t);
2310
- return this[H](), e;
2311
- }
2312
- [bs]() {
2313
- return this[Y] ? !1 : (this[Y] = !0, this.readable = !1, this[$] ? (Et(() => this[Re]()), !0) : this[Re]());
2314
- }
2315
- [Re]() {
2316
- if (this[nt]) {
2317
- let e = this[nt].end();
2318
- if (e) {
2319
- for (let s of this[F]) s.dest.write(e);
2320
- this[_] || super.emit("data", e);
2321
- }
2322
- }
2323
- for (let e of this[F]) e.end();
2324
- let t = super.emit("end");
2325
- return this.removeAllListeners("end"), t;
2326
- }
2327
- async collect() {
2328
- let t = Object.assign([], { dataLength: 0 });
2329
- this[R] || (t.dataLength = 0);
2330
- let e = this.promise();
2331
- return this.on("data", (s) => {
2332
- t.push(s), this[R] || (t.dataLength += s.length);
2333
- }), await e, t;
2334
- }
2335
- async concat() {
2336
- if (this[R]) throw new Error("cannot concat in objectMode");
2337
- let t = await this.collect();
2338
- return this[z] ? t.join("") : Buffer.concat(t, t.dataLength);
2339
- }
2340
- async promise() {
2341
- return new Promise((t, e) => {
2342
- this.on(E, () => e(new Error("stream destroyed"))), this.on("error", (s) => e(s)), this.on("end", () => t());
2343
- });
2344
- }
2345
- [Symbol.asyncIterator]() {
2346
- this[_] = !1;
2347
- let t = !1, e = async () => (this.pause(), t = !0, {
2348
- value: void 0,
2349
- done: !0
2350
- });
2351
- return {
2352
- next: () => {
2353
- if (t) return e();
2354
- let i = this.read();
2355
- if (i !== null) return Promise.resolve({
2356
- done: !1,
2357
- value: i
2358
- });
2359
- if (this[G]) return e();
2360
- let n, o, h = (f) => {
2361
- this.off("data", a), this.off("end", l), this.off(E, c), e(), o(f);
2362
- }, a = (f) => {
2363
- this.off("error", h), this.off("end", l), this.off(E, c), this.pause(), n({
2364
- value: f,
2365
- done: !!this[G]
2366
- });
2367
- }, l = () => {
2368
- this.off("error", h), this.off("data", a), this.off(E, c), e(), n({
2369
- done: !0,
2370
- value: void 0
2371
- });
2372
- }, c = () => h(new Error("stream destroyed"));
2373
- return new Promise((f, u) => {
2374
- o = u, n = f, this.once(E, c), this.once("error", h), this.once("end", l), this.once("data", a);
2375
- });
2376
- },
2377
- throw: e,
2378
- return: e,
2379
- [Symbol.asyncIterator]() {
2380
- return this;
2381
- },
2382
- [Symbol.asyncDispose]: async () => {}
2383
- };
2384
- }
2385
- [Symbol.iterator]() {
2386
- this[_] = !1;
2387
- let t = !1, e = () => (this.pause(), this.off(Ae, e), this.off(E, e), this.off("end", e), t = !0, {
2388
- done: !0,
2389
- value: void 0
2390
- }), s = () => {
2391
- if (t) return e();
2392
- let i = this.read();
2393
- return i === null ? e() : {
2394
- done: !1,
2395
- value: i
2396
- };
2397
- };
2398
- return this.once("end", e), this.once(Ae, e), this.once(E, e), {
2399
- next: s,
2400
- throw: e,
2401
- return: e,
2402
- [Symbol.iterator]() {
2403
- return this;
2404
- },
2405
- [Symbol.dispose]: () => {}
2406
- };
2407
- }
2408
- destroy(t) {
2409
- if (this[E]) return t ? this.emit("error", t) : this.emit(E), this;
2410
- this[E] = !0, this[_] = !0, this[C].length = 0, this[A] = 0;
2411
- let e = this;
2412
- return typeof e.close == "function" && !this[$t] && e.close(), t ? this.emit("error", t) : this.emit(E), this;
2413
- }
2414
- static get isStream() {
2415
- return Li;
2416
- }
2417
- };
2418
- var tn = realpathSync.native;
2419
- var Ct = {
2420
- lstatSync,
2421
- readdir,
2422
- readdirSync,
2423
- readlinkSync,
2424
- realpathSync: tn,
2425
- promises: {
2426
- lstat,
2427
- readdir: readdir$1,
2428
- readlink,
2429
- realpath
2430
- }
2431
- };
2432
- var Cs = (r) => !r || r === Ct || r === Qi ? Ct : {
2433
- ...Ct,
2434
- ...r,
2435
- promises: {
2436
- ...Ct.promises,
2437
- ...r.promises
2438
- }
2439
- };
2440
- var on = /^\\\\\?\\([a-z]:)\\?$/i;
2441
- var hn = /^\\\\\?\\UNC\\([^\\]+\\[^\\]+)\\?$/i;
2442
- var an = /^\\\\[^\\?]+\\[^\\]+$/;
2443
- var Ss = (r) => r.replace(/\//g, "\\").replace(on, "$1\\").replace(hn, "\\\\$1\\").replace(an, "$&\\");
2444
- var ln = /^[\\/]{2}\?[\\/]unc[\\/][^\\/]+[\\/][^\\/]+(?:[\\/]|$)/i;
2445
- var cn = /^[\\/]{2}\?[\\/](?=[a-z]:)/i;
2446
- var fn = /^[\\/]{2}\?[\\/]unc(?=[\\/][^\\/]+[\\/][^\\/])/i;
2447
- var un = /[\\/]/;
2448
- var P = 0;
2449
- var As = 1;
2450
- var Ms = 2;
2451
- var I = 4;
2452
- var Rs = 6;
2453
- var Os = 8;
2454
- var tt = 10;
2455
- var Fs = 12;
2456
- var N = 15;
2457
- var kt = ~N;
2458
- var _e = 16;
2459
- var xs = 32;
2460
- var At = 64;
2461
- var L = 128;
2462
- var Ht = 256;
2463
- var Kt = 512;
2464
- var vs = At | L | Kt;
2465
- var dn = 1023;
2466
- var De = (r) => r.isFile() ? Os : r.isDirectory() ? I : r.isSymbolicLink() ? tt : r.isCharacterDevice() ? Ms : r.isBlockDevice() ? Rs : r.isSocket() ? Fs : r.isFIFO() ? As : P;
2467
- var Es = new yt({ max: 4096 });
2468
- var Mt = (r) => {
2469
- let t = Es.get(r);
2470
- if (t) return t;
2471
- let e = r.normalize("NFKD");
2472
- return Es.set(r, e), e;
2473
- };
2474
- var ks = new yt({ max: 4096 });
2475
- var qt = (r) => {
2476
- let t = ks.get(r);
2477
- if (t) return t;
2478
- let e = Mt(r.toLowerCase());
2479
- return ks.set(r, e), e;
2480
- };
2481
- var Xt = class extends yt {
2482
- constructor() {
2483
- super({ max: 256 });
2484
- }
2485
- };
2486
- var Pe = class extends yt {
2487
- constructor(t = 16384) {
2488
- super({
2489
- maxSize: t,
2490
- sizeCalculation: (e) => e.length + 1
2491
- });
2492
- }
2493
- };
2494
- var Ts = Symbol("PathScurry setAsCwd");
2495
- var O = class {
2496
- name;
2497
- root;
2498
- roots;
2499
- parent;
2500
- nocase;
2501
- isCWD = !1;
2502
- #t;
2503
- #n;
2504
- get dev() {
2505
- return this.#n;
2506
- }
2507
- #i;
2508
- get mode() {
2509
- return this.#i;
2510
- }
2511
- #o;
2512
- get nlink() {
2513
- return this.#o;
2514
- }
2515
- #r;
2516
- get uid() {
2517
- return this.#r;
2518
- }
2519
- #d;
2520
- get gid() {
2521
- return this.#d;
2522
- }
2523
- #u;
2524
- get rdev() {
2525
- return this.#u;
2526
- }
2527
- #f;
2528
- get blksize() {
2529
- return this.#f;
2530
- }
2531
- #h;
2532
- get ino() {
2533
- return this.#h;
2534
- }
2535
- #m;
2536
- get size() {
2537
- return this.#m;
2538
- }
2539
- #l;
2540
- get blocks() {
2541
- return this.#l;
2542
- }
2543
- #a;
2544
- get atimeMs() {
2545
- return this.#a;
2546
- }
2547
- #s;
2548
- get mtimeMs() {
2549
- return this.#s;
2550
- }
2551
- #b;
2552
- get ctimeMs() {
2553
- return this.#b;
2554
- }
2555
- #E;
2556
- get birthtimeMs() {
2557
- return this.#E;
2558
- }
2559
- #y;
2560
- get atime() {
2561
- return this.#y;
2562
- }
2563
- #g;
2564
- get mtime() {
2565
- return this.#g;
2566
- }
2567
- #w;
2568
- get ctime() {
2569
- return this.#w;
2570
- }
2571
- #p;
2572
- get birthtime() {
2573
- return this.#p;
2574
- }
2575
- #k;
2576
- #C;
2577
- #x;
2578
- #v;
2579
- #S;
2580
- #M;
2581
- #e;
2582
- #T;
2583
- #_;
2584
- #R;
2585
- get parentPath() {
2586
- return (this.parent || this).fullpath();
2587
- }
2588
- get path() {
2589
- return this.parentPath;
2590
- }
2591
- constructor(t, e = P, s, i, n, o, h) {
2592
- this.name = t, this.#k = n ? qt(t) : Mt(t), this.#e = e & dn, this.nocase = n, this.roots = i, this.root = s || this, this.#T = o, this.#x = h.fullpath, this.#S = h.relative, this.#M = h.relativePosix, this.parent = h.parent, this.parent ? this.#t = this.parent.#t : this.#t = Cs(h.fs);
2593
- }
2594
- get fs() {
2595
- return this.#t;
2596
- }
2597
- depth() {
2598
- return this.#C !== void 0 ? this.#C : this.parent ? this.#C = this.parent.depth() + 1 : this.#C = 0;
2599
- }
2600
- childrenCache() {
2601
- return this.#T;
2602
- }
2603
- resolve(t) {
2604
- if (!t) return this;
2605
- let e = this.getRootString(t), i = t.substring(e.length).split(this.splitSep);
2606
- return e ? this.getRoot(e).#D(i) : this.#D(i);
2607
- }
2608
- #D(t) {
2609
- let e = this;
2610
- for (let s of t) e = e.child(s);
2611
- return e;
2612
- }
2613
- children() {
2614
- let t = this.#T.get(this);
2615
- if (t) return t;
2616
- let e = Object.assign([], { provisional: 0 });
2617
- return this.#T.set(this, e), this.#e &= ~_e, e;
2618
- }
2619
- child(t, e) {
2620
- if (t === "" || t === ".") return this;
2621
- if (t === "..") return this.parent || this;
2622
- let s = this.children(), i = this.nocase ? qt(t) : Mt(t);
2623
- for (let a of s) if (a.#k === i) return a;
2624
- let n = this.parent ? this.sep : "", o = this.#x ? this.#x + n + t : void 0, h = this.newChild(t, P, {
2625
- ...e,
2626
- parent: this,
2627
- fullpath: o
2628
- });
2629
- return this.canReaddir() || (h.#e |= L), s.push(h), h;
2630
- }
2631
- relative() {
2632
- if (this.isCWD) return "";
2633
- if (this.#S !== void 0) return this.#S;
2634
- let t = this.name, e = this.parent;
2635
- if (!e) return this.#S = this.name;
2636
- let s = e.relative();
2637
- return s + (!s || !e.parent ? "" : this.sep) + t;
2638
- }
2639
- relativePosix() {
2640
- if (this.sep === "/") return this.relative();
2641
- if (this.isCWD) return "";
2642
- if (this.#M !== void 0) return this.#M;
2643
- let t = this.name, e = this.parent;
2644
- if (!e) return this.#M = this.fullpathPosix();
2645
- let s = e.relativePosix();
2646
- return s + (!s || !e.parent ? "" : "/") + t;
2647
- }
2648
- fullpath() {
2649
- if (this.#x !== void 0) return this.#x;
2650
- let t = this.name, e = this.parent;
2651
- if (!e) return this.#x = this.name;
2652
- let i = e.fullpath() + (e.parent ? this.sep : "") + t;
2653
- return this.#x = i;
2654
- }
2655
- fullpathPosix() {
2656
- if (this.#v !== void 0) return this.#v;
2657
- if (this.sep === "/") return this.#v = this.fullpath();
2658
- if (!this.parent) {
2659
- let i = this.fullpath().replace(/\\/g, "/");
2660
- return /^[a-z]:\//i.test(i) ? this.#v = `//?/${i}` : this.#v = i;
2661
- }
2662
- let t = this.parent, e = t.fullpathPosix(), s = e + (!e || !t.parent ? "" : "/") + this.name;
2663
- return this.#v = s;
2664
- }
2665
- isUnknown() {
2666
- return (this.#e & N) === P;
2667
- }
2668
- isType(t) {
2669
- return this[`is${t}`]();
2670
- }
2671
- getType() {
2672
- return this.isUnknown() ? "Unknown" : this.isDirectory() ? "Directory" : this.isFile() ? "File" : this.isSymbolicLink() ? "SymbolicLink" : this.isFIFO() ? "FIFO" : this.isCharacterDevice() ? "CharacterDevice" : this.isBlockDevice() ? "BlockDevice" : this.isSocket() ? "Socket" : "Unknown";
2673
- }
2674
- isFile() {
2675
- return (this.#e & N) === Os;
2676
- }
2677
- isDirectory() {
2678
- return (this.#e & N) === I;
2679
- }
2680
- isCharacterDevice() {
2681
- return (this.#e & N) === Ms;
2682
- }
2683
- isBlockDevice() {
2684
- return (this.#e & N) === Rs;
2685
- }
2686
- isFIFO() {
2687
- return (this.#e & N) === As;
2688
- }
2689
- isSocket() {
2690
- return (this.#e & N) === Fs;
2691
- }
2692
- isSymbolicLink() {
2693
- return (this.#e & tt) === tt;
2694
- }
2695
- lstatCached() {
2696
- return this.#e & xs ? this : void 0;
2697
- }
2698
- readlinkCached() {
2699
- return this.#_;
2700
- }
2701
- realpathCached() {
2702
- return this.#R;
2703
- }
2704
- readdirCached() {
2705
- let t = this.children();
2706
- return t.slice(0, t.provisional);
2707
- }
2708
- canReadlink() {
2709
- if (this.#_) return !0;
2710
- if (!this.parent) return !1;
2711
- let t = this.#e & N;
2712
- return !(t !== P && t !== tt || this.#e & Ht || this.#e & L);
2713
- }
2714
- calledReaddir() {
2715
- return !!(this.#e & _e);
2716
- }
2717
- isENOENT() {
2718
- return !!(this.#e & L);
2719
- }
2720
- isNamed(t) {
2721
- return this.nocase ? this.#k === qt(t) : this.#k === Mt(t);
2722
- }
2723
- async readlink() {
2724
- let t = this.#_;
2725
- if (t) return t;
2726
- if (this.canReadlink() && this.parent) try {
2727
- let e = await this.#t.promises.readlink(this.fullpath()), s = (await this.parent.realpath())?.resolve(e);
2728
- if (s) return this.#_ = s;
2729
- } catch (e) {
2730
- this.#F(e.code);
2731
- return;
2732
- }
2733
- }
2734
- readlinkSync() {
2735
- let t = this.#_;
2736
- if (t) return t;
2737
- if (this.canReadlink() && this.parent) try {
2738
- let e = this.#t.readlinkSync(this.fullpath()), s = this.parent.realpathSync()?.resolve(e);
2739
- if (s) return this.#_ = s;
2740
- } catch (e) {
2741
- this.#F(e.code);
2742
- return;
2743
- }
2744
- }
2745
- #W(t) {
2746
- this.#e |= _e;
2747
- for (let e = t.provisional; e < t.length; e++) {
2748
- let s = t[e];
2749
- s && s.#A();
2750
- }
2751
- }
2752
- #A() {
2753
- this.#e & L || (this.#e = (this.#e | L) & kt, this.#G());
2754
- }
2755
- #G() {
2756
- let t = this.children();
2757
- t.provisional = 0;
2758
- for (let e of t) e.#A();
2759
- }
2760
- #P() {
2761
- this.#e |= Kt, this.#N();
2762
- }
2763
- #N() {
2764
- if (this.#e & At) return;
2765
- let t = this.#e;
2766
- (t & N) === I && (t &= kt), this.#e = t | At, this.#G();
2767
- }
2768
- #$(t = "") {
2769
- t === "ENOTDIR" || t === "EPERM" ? this.#N() : t === "ENOENT" ? this.#A() : this.children().provisional = 0;
2770
- }
2771
- #O(t = "") {
2772
- t === "ENOTDIR" ? this.parent.#N() : t === "ENOENT" && this.#A();
2773
- }
2774
- #F(t = "") {
2775
- let e = this.#e;
2776
- e |= Ht, t === "ENOENT" && (e |= L), (t === "EINVAL" || t === "UNKNOWN") && (e &= kt), this.#e = e, t === "ENOTDIR" && this.parent && this.parent.#N();
2777
- }
2778
- #I(t, e) {
2779
- return this.#U(t, e) || this.#z(t, e);
2780
- }
2781
- #z(t, e) {
2782
- let s = De(t), i = this.newChild(t.name, s, { parent: this }), n = i.#e & N;
2783
- return n !== I && n !== tt && n !== P && (i.#e |= At), e.unshift(i), e.provisional++, i;
2784
- }
2785
- #U(t, e) {
2786
- for (let s = e.provisional; s < e.length; s++) {
2787
- let i = e[s];
2788
- if ((this.nocase ? qt(t.name) : Mt(t.name)) === i.#k) return this.#V(t, i, s, e);
2789
- }
2790
- }
2791
- #V(t, e, s, i) {
2792
- let n = e.name;
2793
- return e.#e = e.#e & kt | De(t), n !== t.name && (e.name = t.name), s !== i.provisional && (s === i.length - 1 ? i.pop() : i.splice(s, 1), i.unshift(e)), i.provisional++, e;
2794
- }
2795
- async lstat() {
2796
- if ((this.#e & L) === 0) try {
2797
- return this.#H(await this.#t.promises.lstat(this.fullpath())), this;
2798
- } catch (t) {
2799
- this.#O(t.code);
2800
- }
2801
- }
2802
- lstatSync() {
2803
- if ((this.#e & L) === 0) try {
2804
- return this.#H(this.#t.lstatSync(this.fullpath())), this;
2805
- } catch (t) {
2806
- this.#O(t.code);
2807
- }
2808
- }
2809
- #H(t) {
2810
- let { atime: e, atimeMs: s, birthtime: i, birthtimeMs: n, blksize: o, blocks: h, ctime: a, ctimeMs: l, dev: c, gid: f, ino: u, mode: p, mtime: g, mtimeMs: d, nlink: w, rdev: m, size: b, uid: x } = t;
2811
- this.#y = e, this.#a = s, this.#p = i, this.#E = n, this.#f = o, this.#l = h, this.#w = a, this.#b = l, this.#n = c, this.#d = f, this.#h = u, this.#i = p, this.#g = g, this.#s = d, this.#o = w, this.#u = m, this.#m = b, this.#r = x;
2812
- let S = De(t);
2813
- this.#e = this.#e & kt | S | xs, S !== P && S !== I && S !== tt && (this.#e |= At);
2814
- }
2815
- #L = [];
2816
- #c = !1;
2817
- #q(t) {
2818
- this.#c = !1;
2819
- let e = this.#L.slice();
2820
- this.#L.length = 0, e.forEach((s) => s(null, t));
2821
- }
2822
- readdirCB(t, e = !1) {
2823
- if (!this.canReaddir()) {
2824
- e ? t(null, []) : queueMicrotask(() => t(null, []));
2825
- return;
2826
- }
2827
- let s = this.children();
2828
- if (this.calledReaddir()) {
2829
- let n = s.slice(0, s.provisional);
2830
- e ? t(null, n) : queueMicrotask(() => t(null, n));
2831
- return;
2832
- }
2833
- if (this.#L.push(t), this.#c) return;
2834
- this.#c = !0;
2835
- let i = this.fullpath();
2836
- this.#t.readdir(i, { withFileTypes: !0 }, (n, o) => {
2837
- if (n) this.#$(n.code), s.provisional = 0;
2838
- else {
2839
- for (let h of o) this.#I(h, s);
2840
- this.#W(s);
2841
- }
2842
- this.#q(s.slice(0, s.provisional));
2843
- });
2844
- }
2845
- #B;
2846
- async readdir() {
2847
- if (!this.canReaddir()) return [];
2848
- let t = this.children();
2849
- if (this.calledReaddir()) return t.slice(0, t.provisional);
2850
- let e = this.fullpath();
2851
- if (this.#B) await this.#B;
2852
- else {
2853
- let s = () => {};
2854
- this.#B = new Promise((i) => s = i);
2855
- try {
2856
- for (let i of await this.#t.promises.readdir(e, { withFileTypes: !0 })) this.#I(i, t);
2857
- this.#W(t);
2858
- } catch (i) {
2859
- this.#$(i.code), t.provisional = 0;
2860
- }
2861
- this.#B = void 0, s();
2862
- }
2863
- return t.slice(0, t.provisional);
2864
- }
2865
- readdirSync() {
2866
- if (!this.canReaddir()) return [];
2867
- let t = this.children();
2868
- if (this.calledReaddir()) return t.slice(0, t.provisional);
2869
- let e = this.fullpath();
2870
- try {
2871
- for (let s of this.#t.readdirSync(e, { withFileTypes: !0 })) this.#I(s, t);
2872
- this.#W(t);
2873
- } catch (s) {
2874
- this.#$(s.code), t.provisional = 0;
2875
- }
2876
- return t.slice(0, t.provisional);
2877
- }
2878
- canReaddir() {
2879
- if (this.#e & vs) return !1;
2880
- let t = N & this.#e;
2881
- return t === P || t === I || t === tt;
2882
- }
2883
- shouldWalk(t, e) {
2884
- return (this.#e & I) === I && !(this.#e & vs) && !t.has(this) && (!e || e(this));
2885
- }
2886
- async realpath() {
2887
- if (this.#R) return this.#R;
2888
- if (!((Kt | Ht | L) & this.#e)) try {
2889
- let t = await this.#t.promises.realpath(this.fullpath());
2890
- return this.#R = this.resolve(t);
2891
- } catch {
2892
- this.#P();
2893
- }
2894
- }
2895
- realpathSync() {
2896
- if (this.#R) return this.#R;
2897
- if (!((Kt | Ht | L) & this.#e)) try {
2898
- let t = this.#t.realpathSync(this.fullpath());
2899
- return this.#R = this.resolve(t);
2900
- } catch {
2901
- this.#P();
2902
- }
2903
- }
2904
- [Ts](t) {
2905
- if (t === this) return;
2906
- t.isCWD = !1, this.isCWD = !0;
2907
- let e = new Set([]), s = [], i = this;
2908
- for (; i && i.parent;) e.add(i), i.#S = s.join(this.sep), i.#M = s.join("/"), i = i.parent, s.push("..");
2909
- for (i = t; i && i.parent && !e.has(i);) i.#S = void 0, i.#M = void 0, i = i.parent;
2910
- }
2911
- };
2912
- var Vt = class r extends O {
2913
- sep = "\\";
2914
- splitSep = un;
2915
- constructor(t, e = P, s, i, n, o, h) {
2916
- super(t, e, s, i, n, o, h);
2917
- }
2918
- newChild(t, e = P, s = {}) {
2919
- return new r(t, e, this.root, this.roots, this.nocase, this.childrenCache(), s);
2920
- }
2921
- getRootString(t) {
2922
- return ln.exec(t)?.[0] ?? win32.parse(t).root;
2923
- }
2924
- getRoot(t) {
2925
- if (t = Ss(t.toUpperCase()), t === this.root.name || /^[\\/]$/.test(t)) return this.root;
2926
- for (let [e, s] of Object.entries(this.roots)) if (this.sameRoot(t, e)) return this.roots[t] = s;
2927
- return this.roots[t] = new ot(t, {
2928
- nocase: this.nocase,
2929
- fs: this.fs
2930
- }).root;
2931
- }
2932
- sameRoot(t, e = this.root.name) {
2933
- return Ss(t.toUpperCase()) === e;
2934
- }
2935
- };
2936
- var Yt = class r extends O {
2937
- splitSep = "/";
2938
- sep = "/";
2939
- constructor(t, e = P, s, i, n, o, h) {
2940
- super(t, e, s, i, n, o, h);
2941
- }
2942
- getRootString(t) {
2943
- return t.startsWith("/") ? "/" : "";
2944
- }
2945
- getRoot(t) {
2946
- return this.root;
2947
- }
2948
- newChild(t, e = P, s = {}) {
2949
- return new r(t, e, this.root, this.roots, this.nocase, this.childrenCache(), s);
2950
- }
2951
- };
2952
- var Jt = class {
2953
- root;
2954
- rootPath;
2955
- roots;
2956
- cwd;
2957
- #t;
2958
- #n;
2959
- #i;
2960
- nocase;
2961
- #o;
2962
- constructor(t = process.cwd(), e, s, { nocase: i, childrenCacheSize: n = 16384, fs: o = Ct } = {}) {
2963
- this.#o = Cs(o), (t instanceof URL || t.startsWith("file://")) && (t = fileURLToPath(t));
2964
- let h = e.resolve(t);
2965
- this.roots = Object.create(null), this.rootPath = this.parseRootPath(h), this.#t = new Xt(), this.#n = new Xt(), this.#i = new Pe(n);
2966
- let a = h.substring(this.rootPath.length).split(s);
2967
- if (a.length === 1 && !a[0] && a.pop(), i === void 0) throw new TypeError("must provide nocase setting to PathScurryBase ctor");
2968
- this.nocase = i, this.root = this.newRoot(this.#o), this.roots[this.rootPath] = this.root;
2969
- let l = this.root, c = a.length - 1, f = e.sep, u = this.rootPath, p = !1;
2970
- for (let g of a) {
2971
- let d = c--;
2972
- l = l.child(g, {
2973
- relative: new Array(d).fill("..").join(f),
2974
- relativePosix: new Array(d).fill("..").join("/"),
2975
- fullpath: u += (p ? "" : f) + g
2976
- }), p = !0;
2977
- }
2978
- this.cwd = l;
2979
- }
2980
- depth(t = this.cwd) {
2981
- return typeof t == "string" && (t = this.cwd.resolve(t)), t.depth();
2982
- }
2983
- childrenCache() {
2984
- return this.#i;
2985
- }
2986
- resolve(...t) {
2987
- let e = "";
2988
- for (let n = t.length - 1; n >= 0; n--) {
2989
- let o = t[n];
2990
- if (!(!o || o === ".") && (e = e ? `${o}/${e}` : o, this.isAbsolute(o))) break;
2991
- }
2992
- let s = this.#t.get(e);
2993
- if (s !== void 0) return s;
2994
- let i = this.cwd.resolve(e).fullpath();
2995
- return this.#t.set(e, i), i;
2996
- }
2997
- resolvePosix(...t) {
2998
- let e = "";
2999
- for (let n = t.length - 1; n >= 0; n--) {
3000
- let o = t[n];
3001
- if (!(!o || o === ".") && (e = e ? `${o}/${e}` : o, this.isAbsolute(o))) break;
3002
- }
3003
- let s = this.#n.get(e);
3004
- if (s !== void 0) return s;
3005
- let i = this.cwd.resolve(e).fullpathPosix();
3006
- return this.#n.set(e, i), i;
3007
- }
3008
- relative(t = this.cwd) {
3009
- return typeof t == "string" && (t = this.cwd.resolve(t)), t.relative();
3010
- }
3011
- relativePosix(t = this.cwd) {
3012
- return typeof t == "string" && (t = this.cwd.resolve(t)), t.relativePosix();
3013
- }
3014
- basename(t = this.cwd) {
3015
- return typeof t == "string" && (t = this.cwd.resolve(t)), t.name;
3016
- }
3017
- dirname(t = this.cwd) {
3018
- return typeof t == "string" && (t = this.cwd.resolve(t)), (t.parent || t).fullpath();
3019
- }
3020
- async readdir(t = this.cwd, e = { withFileTypes: !0 }) {
3021
- typeof t == "string" ? t = this.cwd.resolve(t) : t instanceof O || (e = t, t = this.cwd);
3022
- let { withFileTypes: s } = e;
3023
- if (t.canReaddir()) {
3024
- let i = await t.readdir();
3025
- return s ? i : i.map((n) => n.name);
3026
- } else return [];
3027
- }
3028
- readdirSync(t = this.cwd, e = { withFileTypes: !0 }) {
3029
- typeof t == "string" ? t = this.cwd.resolve(t) : t instanceof O || (e = t, t = this.cwd);
3030
- let { withFileTypes: s = !0 } = e;
3031
- return t.canReaddir() ? s ? t.readdirSync() : t.readdirSync().map((i) => i.name) : [];
3032
- }
3033
- async lstat(t = this.cwd) {
3034
- return typeof t == "string" && (t = this.cwd.resolve(t)), t.lstat();
3035
- }
3036
- lstatSync(t = this.cwd) {
3037
- return typeof t == "string" && (t = this.cwd.resolve(t)), t.lstatSync();
3038
- }
3039
- async readlink(t = this.cwd, { withFileTypes: e } = { withFileTypes: !1 }) {
3040
- typeof t == "string" ? t = this.cwd.resolve(t) : t instanceof O || (e = t.withFileTypes, t = this.cwd);
3041
- let s = await t.readlink();
3042
- return e ? s : s?.fullpath();
3043
- }
3044
- readlinkSync(t = this.cwd, { withFileTypes: e } = { withFileTypes: !1 }) {
3045
- typeof t == "string" ? t = this.cwd.resolve(t) : t instanceof O || (e = t.withFileTypes, t = this.cwd);
3046
- let s = t.readlinkSync();
3047
- return e ? s : s?.fullpath();
3048
- }
3049
- async realpath(t = this.cwd, { withFileTypes: e } = { withFileTypes: !1 }) {
3050
- typeof t == "string" ? t = this.cwd.resolve(t) : t instanceof O || (e = t.withFileTypes, t = this.cwd);
3051
- let s = await t.realpath();
3052
- return e ? s : s?.fullpath();
3053
- }
3054
- realpathSync(t = this.cwd, { withFileTypes: e } = { withFileTypes: !1 }) {
3055
- typeof t == "string" ? t = this.cwd.resolve(t) : t instanceof O || (e = t.withFileTypes, t = this.cwd);
3056
- let s = t.realpathSync();
3057
- return e ? s : s?.fullpath();
3058
- }
3059
- async walk(t = this.cwd, e = {}) {
3060
- typeof t == "string" ? t = this.cwd.resolve(t) : t instanceof O || (e = t, t = this.cwd);
3061
- let { withFileTypes: s = !0, follow: i = !1, filter: n, walkFilter: o } = e, h = [];
3062
- (!n || n(t)) && h.push(s ? t : t.fullpath());
3063
- let a = new Set(), l = (f, u) => {
3064
- a.add(f), f.readdirCB((p, g) => {
3065
- if (p) return u(p);
3066
- let d = g.length;
3067
- if (!d) return u();
3068
- let w = () => {
3069
- --d === 0 && u();
3070
- };
3071
- for (let m of g) (!n || n(m)) && h.push(s ? m : m.fullpath()), i && m.isSymbolicLink() ? m.realpath().then((b) => b?.isUnknown() ? b.lstat() : b).then((b) => b?.shouldWalk(a, o) ? l(b, w) : w()) : m.shouldWalk(a, o) ? l(m, w) : w();
3072
- }, !0);
3073
- }, c = t;
3074
- return new Promise((f, u) => {
3075
- l(c, (p) => {
3076
- if (p) return u(p);
3077
- f(h);
3078
- });
3079
- });
3080
- }
3081
- walkSync(t = this.cwd, e = {}) {
3082
- typeof t == "string" ? t = this.cwd.resolve(t) : t instanceof O || (e = t, t = this.cwd);
3083
- let { withFileTypes: s = !0, follow: i = !1, filter: n, walkFilter: o } = e, h = [];
3084
- (!n || n(t)) && h.push(s ? t : t.fullpath());
3085
- let a = new Set([t]);
3086
- for (let l of a) {
3087
- let c = l.readdirSync();
3088
- for (let f of c) {
3089
- (!n || n(f)) && h.push(s ? f : f.fullpath());
3090
- let u = f;
3091
- if (f.isSymbolicLink()) {
3092
- if (!(i && (u = f.realpathSync()))) continue;
3093
- u.isUnknown() && u.lstatSync();
3094
- }
3095
- u.shouldWalk(a, o) && a.add(u);
3096
- }
3097
- }
3098
- return h;
3099
- }
3100
- [Symbol.asyncIterator]() {
3101
- return this.iterate();
3102
- }
3103
- iterate(t = this.cwd, e = {}) {
3104
- return typeof t == "string" ? t = this.cwd.resolve(t) : t instanceof O || (e = t, t = this.cwd), this.stream(t, e)[Symbol.asyncIterator]();
3105
- }
3106
- [Symbol.iterator]() {
3107
- return this.iterateSync();
3108
- }
3109
- *iterateSync(t = this.cwd, e = {}) {
3110
- typeof t == "string" ? t = this.cwd.resolve(t) : t instanceof O || (e = t, t = this.cwd);
3111
- let { withFileTypes: s = !0, follow: i = !1, filter: n, walkFilter: o } = e;
3112
- (!n || n(t)) && (yield s ? t : t.fullpath());
3113
- let h = new Set([t]);
3114
- for (let a of h) {
3115
- let l = a.readdirSync();
3116
- for (let c of l) {
3117
- (!n || n(c)) && (yield s ? c : c.fullpath());
3118
- let f = c;
3119
- if (c.isSymbolicLink()) {
3120
- if (!(i && (f = c.realpathSync()))) continue;
3121
- f.isUnknown() && f.lstatSync();
3122
- }
3123
- f.shouldWalk(h, o) && h.add(f);
3124
- }
3125
- }
3126
- }
3127
- stream(t = this.cwd, e = {}) {
3128
- typeof t == "string" ? t = this.cwd.resolve(t) : t instanceof O || (e = t, t = this.cwd);
3129
- let { withFileTypes: s = !0, follow: i = !1, filter: n, walkFilter: o } = e, h = new J({ objectMode: !0 });
3130
- (!n || n(t)) && h.write(s ? t : t.fullpath());
3131
- let a = new Set(), l = [t], c = 0, f = () => {
3132
- let u = !1;
3133
- for (; !u;) {
3134
- let p = l.shift();
3135
- if (!p) {
3136
- c === 0 && h.end();
3137
- return;
3138
- }
3139
- c++, a.add(p);
3140
- let g = (w, m, b = !1) => {
3141
- if (w) return h.emit("error", w);
3142
- if (i && !b) {
3143
- let x = [];
3144
- for (let S of m) S.isSymbolicLink() && x.push(S.realpath().then((y) => y?.isUnknown() ? y.lstat() : y));
3145
- if (x.length) {
3146
- Promise.all(x).then(() => g(null, m, !0));
3147
- return;
3148
- }
3149
- }
3150
- for (let x of m) x && (!n || n(x)) && (h.write(s ? x : x.fullpath()) || (u = !0));
3151
- c--;
3152
- for (let x of m) {
3153
- let S = x.realpathCached() || x;
3154
- S.shouldWalk(a, o) && l.push(S);
3155
- }
3156
- u && !h.flowing ? h.once("drain", f) : d || f();
3157
- }, d = !0;
3158
- p.readdirCB(g, !0), d = !1;
3159
- }
3160
- };
3161
- return f(), h;
3162
- }
3163
- streamSync(t = this.cwd, e = {}) {
3164
- typeof t == "string" ? t = this.cwd.resolve(t) : t instanceof O || (e = t, t = this.cwd);
3165
- let { withFileTypes: s = !0, follow: i = !1, filter: n, walkFilter: o } = e, h = new J({ objectMode: !0 }), a = new Set();
3166
- (!n || n(t)) && h.write(s ? t : t.fullpath());
3167
- let l = [t], c = 0, f = () => {
3168
- let u = !1;
3169
- for (; !u;) {
3170
- let p = l.shift();
3171
- if (!p) {
3172
- c === 0 && h.end();
3173
- return;
3174
- }
3175
- c++, a.add(p);
3176
- let g = p.readdirSync();
3177
- for (let d of g) (!n || n(d)) && (h.write(s ? d : d.fullpath()) || (u = !0));
3178
- c--;
3179
- for (let d of g) {
3180
- let w = d;
3181
- if (d.isSymbolicLink()) {
3182
- if (!(i && (w = d.realpathSync()))) continue;
3183
- w.isUnknown() && w.lstatSync();
3184
- }
3185
- w.shouldWalk(a, o) && l.push(w);
3186
- }
3187
- }
3188
- u && !h.flowing && h.once("drain", f);
3189
- };
3190
- return f(), h;
3191
- }
3192
- chdir(t = this.cwd) {
3193
- let e = this.cwd;
3194
- this.cwd = typeof t == "string" ? this.cwd.resolve(t) : t, this.cwd[Ts](e);
3195
- }
3196
- };
3197
- var ot = class extends Jt {
3198
- sep = "\\";
3199
- constructor(t = process.cwd(), e = {}) {
3200
- let { nocase: s = !0 } = e;
3201
- typeof t == "string" && !t.startsWith("file://") && (t = t.replace(cn, "").replace(fn, "\\")), super(t, win32, "\\", {
3202
- ...e,
3203
- nocase: s
3204
- }), this.nocase = s;
3205
- for (let i = this.cwd; i; i = i.parent) i.nocase = this.nocase;
3206
- }
3207
- parseRootPath(t) {
3208
- return win32.parse(t).root.toUpperCase();
3209
- }
3210
- newRoot(t) {
3211
- return new Vt(this.rootPath, I, void 0, this.roots, this.nocase, this.childrenCache(), { fs: t });
3212
- }
3213
- isAbsolute(t) {
3214
- return t.startsWith("/") || t.startsWith("\\") || /^[a-z]:(\/|\\)/i.test(t);
3215
- }
3216
- };
3217
- var ht = class extends Jt {
3218
- sep = "/";
3219
- constructor(t = process.cwd(), e = {}) {
3220
- let { nocase: s = !1 } = e;
3221
- super(t, posix, "/", {
3222
- ...e,
3223
- nocase: s
3224
- }), this.nocase = s;
3225
- }
3226
- parseRootPath(t) {
3227
- return "/";
3228
- }
3229
- newRoot(t) {
3230
- return new Yt(this.rootPath, I, void 0, this.roots, this.nocase, this.childrenCache(), { fs: t });
3231
- }
3232
- isAbsolute(t) {
3233
- return t.startsWith("/");
3234
- }
3235
- };
3236
- var Rt = class extends ht {
3237
- constructor(t = process.cwd(), e = {}) {
3238
- let { nocase: s = !0 } = e;
3239
- super(t, {
3240
- ...e,
3241
- nocase: s
3242
- });
3243
- }
3244
- };
3245
- process.platform;
3246
- var _s = process.platform === "win32" ? ot : process.platform === "darwin" ? Rt : ht;
3247
- var pn = (r) => r.length >= 1;
3248
- var mn = (r) => r.length >= 1;
3249
- var gn = Symbol.for("nodejs.util.inspect.custom");
3250
- var at = class r {
3251
- #t;
3252
- #n;
3253
- #i;
3254
- length;
3255
- #o;
3256
- #r;
3257
- #d;
3258
- #u;
3259
- #f;
3260
- #h;
3261
- #m = !0;
3262
- constructor(t, e, s, i) {
3263
- if (!pn(t)) throw new TypeError("empty pattern list");
3264
- if (!mn(e)) throw new TypeError("empty glob list");
3265
- if (e.length !== t.length) throw new TypeError("mismatched pattern list and glob list lengths");
3266
- if (this.length = t.length, s < 0 || s >= this.length) throw new TypeError("index out of range");
3267
- if (this.#t = t, this.#n = e, this.#i = s, this.#o = i, this.#i === 0) {
3268
- if (this.isUNC()) {
3269
- let n = this.#l() ? 6 : 4, o = this.#t.slice(0, n), h = this.#n.slice(0, n), a = this.#t.slice(n), l = this.#n.slice(n);
3270
- a[0] === "" && (a.shift(), l.shift());
3271
- let c = [...o, ""].join("/"), f = [...h, ""].join("/");
3272
- this.#t = [c, ...a], this.#n = [f, ...l], this.length = this.#t.length;
3273
- } else if (this.isDrive() || this.isAbsolute()) {
3274
- let [n, ...o] = this.#t, [h, ...a] = this.#n;
3275
- o[0] === "" && (o.shift(), a.shift());
3276
- let l = `${n}/`, c = `${h}/`;
3277
- this.#t = [l, ...o], this.#n = [c, ...a], this.length = this.#t.length;
3278
- }
3279
- }
3280
- }
3281
- [gn]() {
3282
- return `Pattern <${this.#n.slice(this.#i).join("/")}>`;
3283
- }
3284
- pattern() {
3285
- return this.#t[this.#i];
3286
- }
3287
- isString() {
3288
- return typeof this.#t[this.#i] == "string";
3289
- }
3290
- isGlobstar() {
3291
- return this.#t[this.#i] === v;
3292
- }
3293
- isMatcher() {
3294
- return typeof this.#t[this.#i] == "object";
3295
- }
3296
- globString() {
3297
- return this.#d = this.#d || (this.#i === 0 ? this.isAbsolute() ? this.#n[0] + this.#n.slice(1).join("/") : this.#n.join("/") : this.#n.slice(this.#i).join("/"));
3298
- }
3299
- hasMore() {
3300
- return this.length > this.#i + 1;
3301
- }
3302
- rest() {
3303
- return this.#r !== void 0 ? this.#r : this.hasMore() ? (this.#r = new r(this.#t, this.#n, this.#i + 1, this.#o), this.#r.#h = this.#h, this.#r.#f = this.#f, this.#r.#u = this.#u, this.#r) : this.#r = null;
3304
- }
3305
- #l() {
3306
- let t = this.#t;
3307
- return t[2] === "?" && typeof t[3] == "string" && /^unc$/i.test(t[3]);
3308
- }
3309
- isUNC() {
3310
- let t = this.#t, e = this.#l() ? 4 : 2;
3311
- return this.#f !== void 0 ? this.#f : this.#f = this.#o === "win32" && this.#i === 0 && t[0] === "" && t[1] === "" && typeof t[e] == "string" && !!t[e] && typeof t[e + 1] == "string" && !!t[e + 1];
3312
- }
3313
- isDrive() {
3314
- let t = this.#t;
3315
- return this.#u !== void 0 ? this.#u : this.#u = this.#o === "win32" && this.#i === 0 && this.length > 1 && typeof t[0] == "string" && /^[a-z]:$/i.test(t[0]);
3316
- }
3317
- isAbsolute() {
3318
- let t = this.#t;
3319
- return this.#h !== void 0 ? this.#h : this.#h = t[0] === "" && t.length > 1 || this.isDrive() || this.isUNC();
3320
- }
3321
- root() {
3322
- let t = this.#t[0];
3323
- return typeof t == "string" && this.isAbsolute() && this.#i === 0 ? t : "";
3324
- }
3325
- checkFollowGlobstar() {
3326
- return !(this.#i === 0 || !this.isGlobstar() || !this.#m);
3327
- }
3328
- markFollowGlobstar() {
3329
- return this.#i === 0 || !this.isGlobstar() || !this.#m ? !1 : (this.#m = !1, !0);
3330
- }
3331
- };
3332
- var wn = typeof process == "object" && process && typeof process.platform == "string" ? process.platform : "linux";
3333
- var lt = class {
3334
- relative;
3335
- relativeChildren;
3336
- absolute;
3337
- absoluteChildren;
3338
- platform;
3339
- mmopts;
3340
- slashRoot;
3341
- constructor(t, { nobrace: e, nocase: s, noext: i, noglobstar: n, normalize: o, platform: h = wn, root: a, windowsPathsNoEscape: l, allowWindowsEscape: c }, f) {
3342
- this.relative = [], this.absolute = [], this.relativeChildren = [], this.absoluteChildren = [], this.platform = h, l = !!l || c === !1, this.mmopts = {
3343
- dot: !0,
3344
- nobrace: e,
3345
- nocase: s,
3346
- noext: i,
3347
- noglobstar: n,
3348
- normalize: o,
3349
- optimizationLevel: 2,
3350
- platform: h,
3351
- nocomment: !0,
3352
- nonegate: !0,
3353
- windowsPathsNoEscape: l
3354
- };
3355
- let u = f?.resolve(a ?? "/").fullpath() ?? "/";
3356
- this.slashRoot = K(u.replace(/\\/g, "/").replace(/\/$/, ""), { windowsPathsNoEscape: l });
3357
- for (let p of t) this.add(p);
3358
- }
3359
- add(t) {
3360
- let e = new D(t, this.mmopts);
3361
- for (let s = 0; s < e.set.length; s++) {
3362
- let i = e.set[s], n = e.globParts[s];
3363
- if (!i || !n) throw new Error("invalid pattern object");
3364
- for (; i[0] === "." && n[0] === ".";) i.shift(), n.shift();
3365
- let o = new at(i, n, 0, this.platform), a = new D(o.root() === "/" ? `${this.slashRoot}/${o.rest()?.globString() ?? ""}` : o.globString(), this.mmopts), l = n[n.length - 1] === "**", c = o.isAbsolute();
3366
- c ? this.absolute.push(a) : this.relative.push(a), l && (c ? this.absoluteChildren.push(a) : this.relativeChildren.push(a));
3367
- }
3368
- }
3369
- ignored(t) {
3370
- let e = t.fullpath(), s = `${e}/`, i = t.relative() || ".", n = `${i}/`;
3371
- for (let o of this.relative) if (o.match(i) || o.match(n)) return !0;
3372
- for (let o of this.absolute) if (o.match(e) || o.match(s)) return !0;
3373
- return !1;
3374
- }
3375
- childrenIgnored(t) {
3376
- let e = `${t.fullpath()}/`, s = `${t.relative() || "."}/`;
3377
- for (let i of this.relativeChildren) if (i.match(s)) return !0;
3378
- for (let i of this.absoluteChildren) if (i.match(e)) return !0;
3379
- return !1;
3380
- }
3381
- };
3382
- var ze = class r {
3383
- parent;
3384
- store;
3385
- constructor(t) {
3386
- this.parent = t;
3387
- }
3388
- copy() {
3389
- return new r(this);
3390
- }
3391
- #t(t) {
3392
- let e = this.store?.get(t);
3393
- return e || !this.parent ? e : this.parent.#t(t);
3394
- }
3395
- hasWalked(t, e) {
3396
- return !!this.#t(t.fullpath())?.has(e.globString());
3397
- }
3398
- storeWalked(t, e) {
3399
- let s = t.fullpath(), i = this.#t(s);
3400
- i ? i.add(e.globString()) : (this.store ??= new Map()).set(s, new Set([e.globString()]));
3401
- }
3402
- };
3403
- var Ot = class r {
3404
- static ABSOLUTE = 2;
3405
- static IF_DIR = 1;
3406
- store = new Map();
3407
- add(t, e, s) {
3408
- let i = (e ? r.ABSOLUTE : 0) | (s ? r.IF_DIR : 0), n = this.store.get(t);
3409
- this.store.set(t, n === void 0 ? i : i & n);
3410
- }
3411
- };
3412
- var Le = class {
3413
- store = new Map();
3414
- add(t, e) {
3415
- if (!t.canReaddir()) return;
3416
- let s = this.store.get(t);
3417
- s ? s.find((i) => i.globString() === e.globString()) || s.push(e) : this.store.set(t, [e]);
3418
- }
3419
- get(t) {
3420
- let e = this.store.get(t);
3421
- if (!e) throw new Error("attempting to walk unknown path");
3422
- return e;
3423
- }
3424
- entries() {
3425
- return this.keys().map((t) => [t, this.store.get(t)]);
3426
- }
3427
- keys() {
3428
- return [...this.store.keys()].filter((t) => t.canReaddir());
3429
- }
3430
- };
3431
- var Ft = class r {
3432
- hasWalkedCache;
3433
- matches = new Ot();
3434
- subwalks = new Le();
3435
- patterns;
3436
- follow;
3437
- dot;
3438
- opts;
3439
- constructor(t, e) {
3440
- this.opts = t, this.follow = !!t.follow, this.dot = !!t.dot, this.hasWalkedCache = e ? e.copy() : new ze();
3441
- }
3442
- processPatterns(t, e) {
3443
- this.patterns = e;
3444
- let s = e.map((i) => [t, i]);
3445
- for (let [i, n] of s) {
3446
- this.hasWalkedCache.storeWalked(i, n);
3447
- let o = n.root(), h = n.isAbsolute() && this.opts.absolute !== !1;
3448
- if (o) {
3449
- i = i.resolve(o === "/" && this.opts.root !== void 0 ? this.opts.root : o);
3450
- let f = n.rest();
3451
- if (f) n = f;
3452
- else {
3453
- this.matches.add(i, !0, !1);
3454
- continue;
3455
- }
3456
- }
3457
- if (i.isENOENT()) continue;
3458
- let a, l, c = !1;
3459
- for (; typeof (a = n.pattern()) == "string" && (l = n.rest());) i = i.resolve(a), n = l, c = !0;
3460
- if (a = n.pattern(), l = n.rest(), c) {
3461
- if (this.hasWalkedCache.hasWalked(i, n)) continue;
3462
- this.hasWalkedCache.storeWalked(i, n);
3463
- }
3464
- if (typeof a == "string") {
3465
- let f = a === ".." || a === "" || a === ".";
3466
- this.matches.add(i.resolve(a), h, f);
3467
- continue;
3468
- } else if (a === v) {
3469
- (!i.isSymbolicLink() || this.follow || n.checkFollowGlobstar()) && this.subwalks.add(i, n);
3470
- let f = l?.pattern(), u = l?.rest();
3471
- if (!l || (f === "" || f === ".") && !u) this.matches.add(i, h, f === "" || f === ".");
3472
- else if (f === "..") {
3473
- let p = i.parent || i;
3474
- u ? this.hasWalkedCache.hasWalked(p, u) || this.subwalks.add(p, u) : this.matches.add(p, h, !0);
3475
- }
3476
- } else typeof a == "object" && this.subwalks.add(i, n);
3477
- }
3478
- return this;
3479
- }
3480
- subwalkTargets() {
3481
- return this.subwalks.keys();
3482
- }
3483
- child() {
3484
- return new r(this.opts, this.hasWalkedCache);
3485
- }
3486
- filterEntries(t, e) {
3487
- let s = this.subwalks.get(t), i = this.child();
3488
- for (let n of e) for (let o of s) {
3489
- let h = o.isAbsolute(), a = o.pattern(), l = o.rest();
3490
- a === v ? i.testGlobstar(n, o, l, h) : typeof a == "object" ? i.testMatcher(n, a, l, h) : i.testString(n, a, l, h);
3491
- }
3492
- return i;
3493
- }
3494
- testGlobstar(t, e, s, i) {
3495
- if ((this.dot || !t.name.startsWith(".")) && (e.hasMore() || this.matches.add(t, i, !1), t.canReaddir() && (this.follow || !t.isSymbolicLink() ? this.subwalks.add(t, e) : t.isSymbolicLink() && (s && e.checkFollowGlobstar() ? this.subwalks.add(t, s) : e.markFollowGlobstar() && this.subwalks.add(t, e)))), s) {
3496
- let n = s.pattern();
3497
- if (typeof n == "string" && n !== ".." && n !== "" && n !== ".") this.testString(t, n, s.rest(), i);
3498
- else if (n === "..") {
3499
- let o = t.parent || t;
3500
- this.subwalks.add(o, s);
3501
- } else typeof n == "object" && this.testMatcher(t, n, s.rest(), i);
3502
- }
3503
- }
3504
- testMatcher(t, e, s, i) {
3505
- e.testUnchecked(t.name) && (s ? this.subwalks.add(t, s) : this.matches.add(t, i, !1));
3506
- }
3507
- testString(t, e, s, i) {
3508
- t.isNamed(e) && (s ? this.subwalks.add(t, s) : this.matches.add(t, i, !1));
3509
- }
3510
- };
3511
- var { ABSOLUTE: Zt, IF_DIR: Qt } = Ot, bn = (r, t, e) => typeof r == "string" ? new lt([r], t, e) : Array.isArray(r) ? new lt(r, t, e) : r, te = class {
3512
- path;
3513
- patterns;
3514
- opts;
3515
- seen = new Set();
3516
- paused = !1;
3517
- aborted = !1;
3518
- #t = [];
3519
- #n;
3520
- #i;
3521
- signal;
3522
- maxDepth;
3523
- includeChildMatches;
3524
- constructor(t, e, s) {
3525
- if (this.patterns = t, this.path = e, this.opts = s, this.#i = !s.posix && s.platform === "win32" ? "\\" : "/", this.includeChildMatches = s.includeChildMatches !== !1, (s.ignore || !this.includeChildMatches) && (this.#n = bn(s.ignore ?? [], s, e), !this.includeChildMatches && typeof this.#n.add != "function")) throw new Error("cannot ignore child matches, ignore lacks add() method.");
3526
- this.maxDepth = s.maxDepth || 1 / 0, s.signal && (this.signal = s.signal, this.signal.addEventListener("abort", () => {
3527
- this.#t.length = 0;
3528
- }));
3529
- }
3530
- #o(t) {
3531
- return this.seen.has(t) || !!this.#n?.ignored?.(t);
3532
- }
3533
- #r(t) {
3534
- return !!this.#n?.childrenIgnored?.(t);
3535
- }
3536
- pause() {
3537
- this.paused = !0;
3538
- }
3539
- resume() {
3540
- if (this.signal?.aborted) return;
3541
- this.paused = !1;
3542
- let t;
3543
- for (; !this.paused && (t = this.#t.shift());) t();
3544
- }
3545
- onResume(t) {
3546
- this.paused ? this.#t.push(t) : t();
3547
- }
3548
- async matchCheck(t, e) {
3549
- if (e && this.opts.nodir) return;
3550
- let s, i;
3551
- if (this.opts.realpath) {
3552
- if (s = t.realpathCached() || await t.realpath(), !s) return;
3553
- i = s;
3554
- } else i = t;
3555
- let o = i.isUnknown() || this.opts.stat ? await i.lstat() : i;
3556
- if (this.opts.follow && this.opts.nodir && o?.isSymbolicLink()) {
3557
- let h = await o.realpath();
3558
- h && (h.isUnknown() || this.opts.stat) && await h.lstat();
3559
- }
3560
- return this.matchCheckTest(o, e);
3561
- }
3562
- matchCheckTest(t, e) {
3563
- return t && (this.maxDepth === 1 / 0 || t.depth() <= this.maxDepth) && (!e || t.canReaddir()) && (!this.opts.nodir || !t.isDirectory()) && (!this.opts.nodir || !this.opts.follow || !t.isSymbolicLink() || !t.realpathCached()?.isDirectory()) && !this.#o(t) ? t : void 0;
3564
- }
3565
- matchCheckSync(t, e) {
3566
- if (e && this.opts.nodir) return;
3567
- let s, i;
3568
- if (this.opts.realpath) {
3569
- if (s = t.realpathCached() || t.realpathSync(), !s) return;
3570
- i = s;
3571
- } else i = t;
3572
- let o = i.isUnknown() || this.opts.stat ? i.lstatSync() : i;
3573
- if (this.opts.follow && this.opts.nodir && o?.isSymbolicLink()) {
3574
- let h = o.realpathSync();
3575
- h && (h?.isUnknown() || this.opts.stat) && h.lstatSync();
3576
- }
3577
- return this.matchCheckTest(o, e);
3578
- }
3579
- matchFinish(t, e) {
3580
- this.#o(t) || this.#d(t, e);
3581
- }
3582
- #d(t, e) {
3583
- if (!this.includeChildMatches && this.#n?.add) {
3584
- let n = `${t.relativePosix()}/**`;
3585
- this.#n.add(n);
3586
- }
3587
- let s = this.opts.absolute === void 0 ? e : this.opts.absolute;
3588
- this.seen.add(t);
3589
- let i = this.opts.mark && t.isDirectory() ? this.#i : "";
3590
- if (this.opts.withFileTypes) this.matchEmit(t);
3591
- else if (s) {
3592
- let n = this.opts.posix ? t.fullpathPosix() : t.fullpath();
3593
- this.matchEmit(n + i);
3594
- } else {
3595
- let n = this.opts.posix ? t.relativePosix() : t.relative(), o = this.opts.dotRelative && !n.startsWith(`..${this.#i}`) ? `.${this.#i}` : "";
3596
- this.matchEmit(n ? o + n + i : `.${i}`);
3597
- }
3598
- }
3599
- async match(t, e, s) {
3600
- let i = await this.matchCheck(t, s);
3601
- i && this.matchFinish(i, e);
3602
- }
3603
- matchSync(t, e, s) {
3604
- let i = this.matchCheckSync(t, s);
3605
- i && this.#d(i, e);
3606
- }
3607
- walkCB(t, e, s) {
3608
- if (this.signal?.aborted) return s();
3609
- this.walkCB2(t, e, new Ft(this.opts), s);
3610
- }
3611
- walkCB2(t, e, s, i) {
3612
- if (this.#r(t) || this.signal?.aborted) return i();
3613
- if (this.paused) {
3614
- this.onResume(() => this.walkCB2(t, e, s, i));
3615
- return;
3616
- }
3617
- s.processPatterns(t, e);
3618
- let n = 1, o = () => {
3619
- --n === 0 && i();
3620
- };
3621
- for (let [h, a] of s.matches.store) this.#o(h) || (n++, this.match(h, !!(a & Zt), !!(a & Qt)).then(() => o()));
3622
- for (let h of s.subwalkTargets()) {
3623
- if (this.maxDepth !== 1 / 0 && h.depth() >= this.maxDepth) continue;
3624
- n++;
3625
- let a = h.readdirCached();
3626
- h.calledReaddir() ? this.walkCB3(h, a, s, o) : h.readdirCB((l, c) => this.walkCB3(h, c, s, o), !0);
3627
- }
3628
- o();
3629
- }
3630
- walkCB3(t, e, s, i) {
3631
- let n = s.filterEntries(t, e), o = 1, h = () => {
3632
- --o === 0 && i();
3633
- };
3634
- for (let [a, l] of n.matches.store) this.#o(a) || (o++, this.match(a, !!(l & Zt), !!(l & Qt)).then(() => h()));
3635
- for (let [a, l] of n.subwalks.entries()) o++, this.walkCB2(a, l, n.child(), h);
3636
- h();
3637
- }
3638
- walkCBSync(t, e, s) {
3639
- if (this.signal?.aborted) return s();
3640
- this.walkCB2Sync(t, e, new Ft(this.opts), s);
3641
- }
3642
- walkCB2Sync(t, e, s, i) {
3643
- if (this.#r(t) || this.signal?.aborted) return i();
3644
- if (this.paused) {
3645
- this.onResume(() => this.walkCB2Sync(t, e, s, i));
3646
- return;
3647
- }
3648
- s.processPatterns(t, e);
3649
- let n = 1, o = () => {
3650
- --n === 0 && i();
3651
- };
3652
- for (let [h, a] of s.matches.store) this.#o(h) || this.matchSync(h, !!(a & Zt), !!(a & Qt));
3653
- for (let h of s.subwalkTargets()) {
3654
- if (this.maxDepth !== 1 / 0 && h.depth() >= this.maxDepth) continue;
3655
- n++;
3656
- let a = h.readdirSync();
3657
- this.walkCB3Sync(h, a, s, o);
3658
- }
3659
- o();
3660
- }
3661
- walkCB3Sync(t, e, s, i) {
3662
- let n = s.filterEntries(t, e), o = 1, h = () => {
3663
- --o === 0 && i();
3664
- };
3665
- for (let [a, l] of n.matches.store) this.#o(a) || this.matchSync(a, !!(l & Zt), !!(l & Qt));
3666
- for (let [a, l] of n.subwalks.entries()) o++, this.walkCB2Sync(a, l, n.child(), h);
3667
- h();
3668
- }
3669
- }, Tt = class extends te {
3670
- matches = [];
3671
- constructor(t, e, s) {
3672
- super(t, e, s);
3673
- }
3674
- matchEmit(t) {
3675
- this.matches.push(t);
3676
- }
3677
- async walk() {
3678
- if (this.signal?.aborted) throw this.signal.reason;
3679
- return this.path.isUnknown() && await this.path.lstat(), await new Promise((t, e) => {
3680
- this.walkCB(this.path, this.patterns, () => {
3681
- this.signal?.aborted ? e(this.signal.reason) : t(this.matches);
3682
- });
3683
- }), this.matches;
3684
- }
3685
- walkSync() {
3686
- if (this.signal?.aborted) throw this.signal.reason;
3687
- return this.path.isUnknown() && this.path.lstatSync(), this.walkCBSync(this.path, this.patterns, () => {
3688
- if (this.signal?.aborted) throw this.signal.reason;
3689
- }), this.matches;
3690
- }
3691
- }, _t = class extends te {
3692
- results;
3693
- constructor(t, e, s) {
3694
- super(t, e, s), this.results = new J({
3695
- signal: this.signal,
3696
- objectMode: !0
3697
- }), this.results.on("drain", () => this.resume()), this.results.on("resume", () => this.resume());
3698
- }
3699
- matchEmit(t) {
3700
- this.results.write(t), this.results.flowing || this.pause();
3701
- }
3702
- stream() {
3703
- let t = this.path;
3704
- return t.isUnknown() ? t.lstat().then(() => {
3705
- this.walkCB(t, this.patterns, () => this.results.end());
3706
- }) : this.walkCB(t, this.patterns, () => this.results.end()), this.results;
3707
- }
3708
- streamSync() {
3709
- return this.path.isUnknown() && this.path.lstatSync(), this.walkCBSync(this.path, this.patterns, () => this.results.end()), this.results;
3710
- }
3711
- };
3712
- var Sn = typeof process == "object" && process && typeof process.platform == "string" ? process.platform : "linux";
3713
- var j = class {
3714
- absolute;
3715
- cwd;
3716
- root;
3717
- dot;
3718
- dotRelative;
3719
- follow;
3720
- ignore;
3721
- magicalBraces;
3722
- mark;
3723
- matchBase;
3724
- maxDepth;
3725
- nobrace;
3726
- nocase;
3727
- nodir;
3728
- noext;
3729
- noglobstar;
3730
- pattern;
3731
- platform;
3732
- realpath;
3733
- scurry;
3734
- stat;
3735
- signal;
3736
- windowsPathsNoEscape;
3737
- withFileTypes;
3738
- includeChildMatches;
3739
- opts;
3740
- patterns;
3741
- constructor(t, e) {
3742
- if (!e) throw new TypeError("glob options required");
3743
- if (this.withFileTypes = !!e.withFileTypes, this.signal = e.signal, this.follow = !!e.follow, this.dot = !!e.dot, this.dotRelative = !!e.dotRelative, this.nodir = !!e.nodir, this.mark = !!e.mark, e.cwd ? (e.cwd instanceof URL || e.cwd.startsWith("file://")) && (e.cwd = fileURLToPath(e.cwd)) : this.cwd = "", this.cwd = e.cwd || "", this.root = e.root, this.magicalBraces = !!e.magicalBraces, this.nobrace = !!e.nobrace, this.noext = !!e.noext, this.realpath = !!e.realpath, this.absolute = e.absolute, this.includeChildMatches = e.includeChildMatches !== !1, this.noglobstar = !!e.noglobstar, this.matchBase = !!e.matchBase, this.maxDepth = typeof e.maxDepth == "number" ? e.maxDepth : 1 / 0, this.stat = !!e.stat, this.ignore = e.ignore, this.withFileTypes && this.absolute !== void 0) throw new Error("cannot set absolute and withFileTypes:true");
3744
- let s = typeof t == "string" ? [t] : t;
3745
- if (this.windowsPathsNoEscape = !!e.windowsPathsNoEscape || e.allowWindowsEscape === !1, this.windowsPathsNoEscape && (s = s.map((l) => l.replace(/\\/g, "/"))), this.matchBase) {
3746
- if (e.noglobstar) throw new TypeError("base matching requires globstar");
3747
- s = s.map((l) => l.includes("/") ? l : `./**/${l}`);
3748
- }
3749
- if (this.pattern = s, this.platform = e.platform || Sn, this.opts = {
3750
- ...e,
3751
- platform: this.platform
3752
- }, e.scurry) {
3753
- if (this.scurry = e.scurry, e.nocase !== void 0 && e.nocase !== e.scurry.nocase) throw new Error("nocase option contradicts provided scurry option");
3754
- } else {
3755
- let l = e.platform === "win32" ? ot : e.platform === "darwin" ? Rt : e.platform ? ht : _s;
3756
- this.scurry = new l(this.cwd, {
3757
- nocase: e.nocase,
3758
- fs: e.fs
3759
- });
3760
- }
3761
- this.nocase = this.scurry.nocase;
3762
- let i = this.platform === "darwin" || this.platform === "win32", n = {
3763
- braceExpandMax: 1e4,
3764
- ...e,
3765
- dot: this.dot,
3766
- matchBase: this.matchBase,
3767
- nobrace: this.nobrace,
3768
- nocase: this.nocase,
3769
- nocaseMagicOnly: i,
3770
- nocomment: !0,
3771
- noext: this.noext,
3772
- nonegate: !0,
3773
- optimizationLevel: 2,
3774
- platform: this.platform,
3775
- windowsPathsNoEscape: this.windowsPathsNoEscape
3776
- }, [h, a] = this.pattern.map((l) => new D(l, n)).reduce((l, c) => (l[0].push(...c.set), l[1].push(...c.globParts), l), [[], []]);
3777
- this.patterns = h.map((l, c) => {
3778
- let f = a[c];
3779
- if (!f) throw new Error("invalid pattern object");
3780
- return new at(l, f, 0, this.platform);
3781
- });
3782
- }
3783
- async walk() {
3784
- return await new Tt(this.patterns, this.scurry.cwd, {
3785
- ...this.opts,
3786
- maxDepth: this.maxDepth !== 1 / 0 ? this.maxDepth + this.scurry.cwd.depth() : 1 / 0,
3787
- platform: this.platform,
3788
- nocase: this.nocase,
3789
- includeChildMatches: this.includeChildMatches
3790
- }).walk();
3791
- }
3792
- walkSync() {
3793
- return new Tt(this.patterns, this.scurry.cwd, {
3794
- ...this.opts,
3795
- maxDepth: this.maxDepth !== 1 / 0 ? this.maxDepth + this.scurry.cwd.depth() : 1 / 0,
3796
- platform: this.platform,
3797
- nocase: this.nocase,
3798
- includeChildMatches: this.includeChildMatches
3799
- }).walkSync();
3800
- }
3801
- stream() {
3802
- return new _t(this.patterns, this.scurry.cwd, {
3803
- ...this.opts,
3804
- maxDepth: this.maxDepth !== 1 / 0 ? this.maxDepth + this.scurry.cwd.depth() : 1 / 0,
3805
- platform: this.platform,
3806
- nocase: this.nocase,
3807
- includeChildMatches: this.includeChildMatches
3808
- }).stream();
3809
- }
3810
- streamSync() {
3811
- return new _t(this.patterns, this.scurry.cwd, {
3812
- ...this.opts,
3813
- maxDepth: this.maxDepth !== 1 / 0 ? this.maxDepth + this.scurry.cwd.depth() : 1 / 0,
3814
- platform: this.platform,
3815
- nocase: this.nocase,
3816
- includeChildMatches: this.includeChildMatches
3817
- }).streamSync();
3818
- }
3819
- iterateSync() {
3820
- return this.streamSync()[Symbol.iterator]();
3821
- }
3822
- [Symbol.iterator]() {
3823
- return this.iterateSync();
3824
- }
3825
- iterate() {
3826
- return this.stream()[Symbol.asyncIterator]();
3827
- }
3828
- [Symbol.asyncIterator]() {
3829
- return this.iterate();
3830
- }
3831
- };
3832
- var je = (r, t = {}) => {
3833
- for (let e of Array.isArray(r) ? r : [r]) if (new D(e, t).hasMagic()) return !0;
3834
- return !1;
3835
- };
3836
- function ee(r, t = {}) {
3837
- return new j(r, t).streamSync();
3838
- }
3839
- function Ps(r, t = {}) {
3840
- return new j(r, t).stream();
3841
- }
3842
- function zs(r, t = {}) {
3843
- return new j(r, t).walkSync();
3844
- }
3845
- async function Ds(r, t = {}) {
3846
- return new j(r, t).walk();
3847
- }
3848
- function se(r, t = {}) {
3849
- return new j(r, t).iterateSync();
3850
- }
3851
- function Ls(r, t = {}) {
3852
- return new j(r, t).iterate();
3853
- }
3854
- var xn = ee;
3855
- var vn = Object.assign(Ps, { sync: ee });
3856
- var En = se;
3857
- var kn = Object.assign(Ls, { sync: se });
3858
- var Cn = Object.assign(zs, {
3859
- stream: ee,
3860
- iterate: se
3861
- });
3862
- var Ns = Object.assign(Ds, {
3863
- glob: Ds,
3864
- globSync: zs,
3865
- sync: Cn,
3866
- globStream: Ps,
3867
- stream: vn,
3868
- globStreamSync: ee,
3869
- streamSync: xn,
3870
- globIterate: Ls,
3871
- iterate: kn,
3872
- globIterateSync: se,
3873
- iterateSync: En,
3874
- Glob: j,
3875
- hasMagic: je,
3876
- escape: K,
3877
- unescape: st
3878
- });
3879
- Ns.glob = Ns;
3880
- export { j as Glob, lt as Ignore, K as escape, Ns as glob, Ls as globIterate, se as globIterateSync, Ps as globStream, ee as globStreamSync, zs as globSync, je as hasMagic, kn as iterate, En as iterateSync, vn as stream, xn as streamSync, Cn as sync, st as unescape };