tinker-token-usage 0.1.3 → 0.1.5

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,1501 +0,0 @@
1
- var ae = Object.defineProperty;
2
- var ce = (t, s, e) => s in t ? ae(t, s, { enumerable: !0, configurable: !0, writable: !0, value: e }) : t[s] = e;
3
- var D = (t, s, e) => ce(t, typeof s != "symbol" ? s + "" : s, e);
4
- import * as le from "fs";
5
- import J from "fs";
6
- import Nt, { sep as Bt, basename as pe, dirname as bt, resolve as fe, normalize as he, relative as ge, posix as V } from "path";
7
- import { fileURLToPath as Ae } from "url";
8
- import { createRequire as ye } from "module";
9
- var Ht = /* @__PURE__ */ ye(import.meta.url);
10
- function _e(t) {
11
- let s = he(t);
12
- return s.length > 1 && s[s.length - 1] === Bt && (s = s.substring(0, s.length - 1)), s;
13
- }
14
- const Re = /[\\/]/g;
15
- function Ft(t, s) {
16
- return t.replace(Re, s);
17
- }
18
- const de = /^[a-z]:[\\/]$/i;
19
- function Se(t) {
20
- return t === "/" || de.test(t);
21
- }
22
- function At(t, s) {
23
- const { resolvePaths: e, normalizePath: n, pathSeparator: o } = s, r = process.platform === "win32" && t.includes("/") || t.startsWith(".");
24
- if (e && (t = fe(t)), (n || r) && (t = _e(t)), t === ".") return "";
25
- const c = t[t.length - 1] !== o;
26
- return Ft(c ? t + o : t, o);
27
- }
28
- function Mt(t, s) {
29
- return s + t;
30
- }
31
- function Ee(t, s) {
32
- return function(e, n) {
33
- return n.startsWith(t) ? n.slice(t.length) + e : Ft(ge(t, n), s.pathSeparator) + s.pathSeparator + e;
34
- };
35
- }
36
- function be(t) {
37
- return t;
38
- }
39
- function me(t, s, e) {
40
- return s + t + e;
41
- }
42
- function Ce(t, s) {
43
- const { relativePaths: e, includeBasePath: n } = s;
44
- return e && t ? Ee(t, s) : n ? Mt : be;
45
- }
46
- function $e(t) {
47
- return function(s, e) {
48
- e.push(s.substring(t.length) || ".");
49
- };
50
- }
51
- function xe(t) {
52
- return function(s, e, n) {
53
- const o = s.substring(t.length) || ".";
54
- n.every((r) => r(o, !0)) && e.push(o);
55
- };
56
- }
57
- const ve = (t, s) => {
58
- s.push(t || ".");
59
- }, He = (t, s, e) => {
60
- const n = t || ".";
61
- e.every((o) => o(n, !0)) && s.push(n);
62
- }, we = () => {
63
- };
64
- function Le(t, s) {
65
- const { includeDirs: e, filters: n, relativePaths: o } = s;
66
- return e ? o ? n && n.length ? xe(t) : $e(t) : n && n.length ? He : ve : we;
67
- }
68
- const Pe = (t, s, e, n) => {
69
- n.every((o) => o(t, !1)) && e.files++;
70
- }, Te = (t, s, e, n) => {
71
- n.every((o) => o(t, !1)) && s.push(t);
72
- }, ke = (t, s, e, n) => {
73
- e.files++;
74
- }, Oe = (t, s) => {
75
- s.push(t);
76
- }, De = () => {
77
- };
78
- function Ie(t) {
79
- const { excludeFiles: s, filters: e, onlyCounts: n } = t;
80
- return s ? De : e && e.length ? n ? Pe : Te : n ? ke : Oe;
81
- }
82
- const Ne = (t) => t, Be = () => [""].slice(0, 0);
83
- function Fe(t) {
84
- return t.group ? Be : Ne;
85
- }
86
- const Me = (t, s, e) => {
87
- t.push({
88
- directory: s,
89
- files: e,
90
- dir: s
91
- });
92
- }, Ge = () => {
93
- };
94
- function We(t) {
95
- return t.group ? Me : Ge;
96
- }
97
- const Ue = function(t, s, e) {
98
- const { queue: n, fs: o, options: { suppressErrors: r } } = s;
99
- n.enqueue(), o.realpath(t, (c, l) => {
100
- if (c) return n.dequeue(r ? null : c, s);
101
- o.stat(l, (h, R) => {
102
- if (h) return n.dequeue(r ? null : h, s);
103
- if (R.isDirectory() && Gt(t, l, s)) return n.dequeue(null, s);
104
- e(R, l), n.dequeue(null, s);
105
- });
106
- });
107
- }, Ke = function(t, s, e) {
108
- const { queue: n, fs: o, options: { suppressErrors: r } } = s;
109
- n.enqueue();
110
- try {
111
- const c = o.realpathSync(t), l = o.statSync(c);
112
- if (l.isDirectory() && Gt(t, c, s)) return;
113
- e(l, c);
114
- } catch (c) {
115
- if (!r) throw c;
116
- }
117
- };
118
- function qe(t, s) {
119
- return !t.resolveSymlinks || t.excludeSymlinks ? null : s ? Ke : Ue;
120
- }
121
- function Gt(t, s, e) {
122
- if (e.options.useRealPaths) return Xe(s, e);
123
- let n = bt(t), o = 1;
124
- for (; n !== e.root && o < 2; ) {
125
- const r = e.symlinks.get(n);
126
- !!r && (r === s || r.startsWith(s) || s.startsWith(r)) ? o++ : n = bt(n);
127
- }
128
- return e.symlinks.set(t, s), o > 1;
129
- }
130
- function Xe(t, s) {
131
- return s.visited.includes(t + s.options.pathSeparator);
132
- }
133
- const Qe = (t) => t.counts, je = (t) => t.groups, ze = (t) => t.paths, Ye = (t) => t.paths.slice(0, t.options.maxFiles), Ze = (t, s, e) => (pt(s, e, t.counts, t.options.suppressErrors), null), Ve = (t, s, e) => (pt(s, e, t.paths, t.options.suppressErrors), null), Je = (t, s, e) => (pt(s, e, t.paths.slice(0, t.options.maxFiles), t.options.suppressErrors), null), ts = (t, s, e) => (pt(s, e, t.groups, t.options.suppressErrors), null);
134
- function pt(t, s, e, n) {
135
- s(t && !n ? t : null, e);
136
- }
137
- function es(t, s) {
138
- const { onlyCounts: e, group: n, maxFiles: o } = t;
139
- return e ? s ? Qe : Ze : n ? s ? je : ts : o ? s ? Ye : Je : s ? ze : Ve;
140
- }
141
- const Wt = { withFileTypes: !0 }, ss = (t, s, e, n, o) => {
142
- if (t.queue.enqueue(), n < 0) return t.queue.dequeue(null, t);
143
- const { fs: r } = t;
144
- t.visited.push(s), t.counts.directories++, r.readdir(s || ".", Wt, (c, l = []) => {
145
- o(l, e, n), t.queue.dequeue(t.options.suppressErrors ? null : c, t);
146
- });
147
- }, ns = (t, s, e, n, o) => {
148
- const { fs: r } = t;
149
- if (n < 0) return;
150
- t.visited.push(s), t.counts.directories++;
151
- let c = [];
152
- try {
153
- c = r.readdirSync(s || ".", Wt);
154
- } catch (l) {
155
- if (!t.options.suppressErrors) throw l;
156
- }
157
- o(c, e, n);
158
- };
159
- function rs(t) {
160
- return t ? ns : ss;
161
- }
162
- var os = class {
163
- constructor(t) {
164
- D(this, "count", 0);
165
- this.onQueueEmpty = t;
166
- }
167
- enqueue() {
168
- return this.count++, this.count;
169
- }
170
- dequeue(t, s) {
171
- this.onQueueEmpty && (--this.count <= 0 || t) && (this.onQueueEmpty(t, s), t && (s.controller.abort(), this.onQueueEmpty = void 0));
172
- }
173
- }, is = class {
174
- constructor() {
175
- D(this, "_files", 0);
176
- D(this, "_directories", 0);
177
- }
178
- set files(t) {
179
- this._files = t;
180
- }
181
- get files() {
182
- return this._files;
183
- }
184
- set directories(t) {
185
- this._directories = t;
186
- }
187
- get directories() {
188
- return this._directories;
189
- }
190
- /**
191
- * @deprecated use `directories` instead
192
- */
193
- /* c8 ignore next 3 */
194
- get dirs() {
195
- return this._directories;
196
- }
197
- }, us = class {
198
- constructor() {
199
- D(this, "aborted", !1);
200
- }
201
- abort() {
202
- this.aborted = !0;
203
- }
204
- }, Ut = class {
205
- constructor(t, s, e) {
206
- D(this, "root");
207
- D(this, "isSynchronous");
208
- D(this, "state");
209
- D(this, "joinPath");
210
- D(this, "pushDirectory");
211
- D(this, "pushFile");
212
- D(this, "getArray");
213
- D(this, "groupFiles");
214
- D(this, "resolveSymlink");
215
- D(this, "walkDirectory");
216
- D(this, "callbackInvoker");
217
- D(this, "walk", (t, s, e) => {
218
- const { paths: n, options: { filters: o, resolveSymlinks: r, excludeSymlinks: c, exclude: l, maxFiles: h, signal: R, useRealPaths: g, pathSeparator: E }, controller: A } = this.state;
219
- if (A.aborted || R && R.aborted || h && n.length > h) return;
220
- const b = this.getArray(this.state.paths);
221
- for (let d = 0; d < t.length; ++d) {
222
- const $ = t[d];
223
- if ($.isFile() || $.isSymbolicLink() && !r && !c) {
224
- const x = this.joinPath($.name, s);
225
- this.pushFile(x, b, this.state.counts, o);
226
- } else if ($.isDirectory()) {
227
- let x = me($.name, s, this.state.options.pathSeparator);
228
- if (l && l($.name, x)) continue;
229
- this.pushDirectory(x, n, o), this.walkDirectory(this.state, x, x, e - 1, this.walk);
230
- } else if (this.resolveSymlink && $.isSymbolicLink()) {
231
- let x = Mt($.name, s);
232
- this.resolveSymlink(x, this.state, (w, y) => {
233
- if (w.isDirectory()) {
234
- if (y = At(y, this.state.options), l && l($.name, g ? y : x + E)) return;
235
- this.walkDirectory(this.state, y, g ? y : x + E, e - 1, this.walk);
236
- } else {
237
- y = g ? y : x;
238
- const W = pe(y), Q = At(bt(y), this.state.options);
239
- y = this.joinPath(W, Q), this.pushFile(y, b, this.state.counts, o);
240
- }
241
- });
242
- }
243
- }
244
- this.groupFiles(this.state.groups, s, b);
245
- });
246
- this.isSynchronous = !e, this.callbackInvoker = es(s, this.isSynchronous), this.root = At(t, s), this.state = {
247
- root: Se(this.root) ? this.root : this.root.slice(0, -1),
248
- paths: [""].slice(0, 0),
249
- groups: [],
250
- counts: new is(),
251
- options: s,
252
- queue: new os((n, o) => this.callbackInvoker(o, n, e)),
253
- symlinks: /* @__PURE__ */ new Map(),
254
- visited: [""].slice(0, 0),
255
- controller: new us(),
256
- fs: s.fs || le
257
- }, this.joinPath = Ce(this.root, s), this.pushDirectory = Le(this.root, s), this.pushFile = Ie(s), this.getArray = Fe(s), this.groupFiles = We(s), this.resolveSymlink = qe(s, this.isSynchronous), this.walkDirectory = rs(this.isSynchronous);
258
- }
259
- start() {
260
- return this.pushDirectory(this.root, this.state.paths, this.state.options.filters), this.walkDirectory(this.state, this.root, this.root, this.state.options.maxDepth, this.walk), this.isSynchronous ? this.callbackInvoker(this.state, null) : null;
261
- }
262
- };
263
- function as(t, s) {
264
- return new Promise((e, n) => {
265
- Kt(t, s, (o, r) => {
266
- if (o) return n(o);
267
- e(r);
268
- });
269
- });
270
- }
271
- function Kt(t, s, e) {
272
- new Ut(t, s, e).start();
273
- }
274
- function cs(t, s) {
275
- return new Ut(t, s).start();
276
- }
277
- var wt = class {
278
- constructor(t, s) {
279
- this.root = t, this.options = s;
280
- }
281
- withPromise() {
282
- return as(this.root, this.options);
283
- }
284
- withCallback(t) {
285
- Kt(this.root, this.options, t);
286
- }
287
- sync() {
288
- return cs(this.root, this.options);
289
- }
290
- };
291
- let qt = null;
292
- try {
293
- Ht.resolve("picomatch"), qt = Ht("picomatch");
294
- } catch {
295
- }
296
- var ls = class {
297
- constructor(t) {
298
- D(this, "globCache", {});
299
- D(this, "options", {
300
- maxDepth: 1 / 0,
301
- suppressErrors: !0,
302
- pathSeparator: Bt,
303
- filters: []
304
- });
305
- D(this, "globFunction");
306
- this.options = {
307
- ...this.options,
308
- ...t
309
- }, this.globFunction = this.options.globFunction;
310
- }
311
- group() {
312
- return this.options.group = !0, this;
313
- }
314
- withPathSeparator(t) {
315
- return this.options.pathSeparator = t, this;
316
- }
317
- withBasePath() {
318
- return this.options.includeBasePath = !0, this;
319
- }
320
- withRelativePaths() {
321
- return this.options.relativePaths = !0, this;
322
- }
323
- withDirs() {
324
- return this.options.includeDirs = !0, this;
325
- }
326
- withMaxDepth(t) {
327
- return this.options.maxDepth = t, this;
328
- }
329
- withMaxFiles(t) {
330
- return this.options.maxFiles = t, this;
331
- }
332
- withFullPaths() {
333
- return this.options.resolvePaths = !0, this.options.includeBasePath = !0, this;
334
- }
335
- withErrors() {
336
- return this.options.suppressErrors = !1, this;
337
- }
338
- withSymlinks({ resolvePaths: t = !0 } = {}) {
339
- return this.options.resolveSymlinks = !0, this.options.useRealPaths = t, this.withFullPaths();
340
- }
341
- withAbortSignal(t) {
342
- return this.options.signal = t, this;
343
- }
344
- normalize() {
345
- return this.options.normalizePath = !0, this;
346
- }
347
- filter(t) {
348
- return this.options.filters.push(t), this;
349
- }
350
- onlyDirs() {
351
- return this.options.excludeFiles = !0, this.options.includeDirs = !0, this;
352
- }
353
- exclude(t) {
354
- return this.options.exclude = t, this;
355
- }
356
- onlyCounts() {
357
- return this.options.onlyCounts = !0, this;
358
- }
359
- crawl(t) {
360
- return new wt(t || ".", this.options);
361
- }
362
- withGlobFunction(t) {
363
- return this.globFunction = t, this;
364
- }
365
- /**
366
- * @deprecated Pass options using the constructor instead:
367
- * ```ts
368
- * new fdir(options).crawl("/path/to/root");
369
- * ```
370
- * This method will be removed in v7.0
371
- */
372
- /* c8 ignore next 4 */
373
- crawlWithOptions(t, s) {
374
- return this.options = {
375
- ...this.options,
376
- ...s
377
- }, new wt(t || ".", this.options);
378
- }
379
- glob(...t) {
380
- return this.globFunction ? this.globWithOptions(t) : this.globWithOptions(t, { dot: !0 });
381
- }
382
- globWithOptions(t, ...s) {
383
- const e = this.globFunction || qt;
384
- if (!e) throw new Error("Please specify a glob function to use glob matching.");
385
- var n = this.globCache[t.join("\0")];
386
- return n || (n = e(t, ...s), this.globCache[t.join("\0")] = n), this.options.filters.push((o) => n(o)), this;
387
- }
388
- };
389
- function ps(t) {
390
- return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t;
391
- }
392
- var rt = {};
393
- const q = "\\\\/", Lt = `[^${q}]`, z = "\\.", fs = "\\+", hs = "\\?", ft = "\\/", gs = "(?=.)", Xt = "[^/]", Ct = `(?:${ft}|$)`, Qt = `(?:^|${ft})`, $t = `${z}{1,2}${Ct}`, As = `(?!${z})`, ys = `(?!${Qt}${$t})`, _s = `(?!${z}{0,1}${Ct})`, Rs = `(?!${$t})`, ds = `[^.${ft}]`, Ss = `${Xt}*?`, Es = "/", jt = {
394
- DOT_LITERAL: z,
395
- PLUS_LITERAL: fs,
396
- QMARK_LITERAL: hs,
397
- SLASH_LITERAL: ft,
398
- ONE_CHAR: gs,
399
- QMARK: Xt,
400
- END_ANCHOR: Ct,
401
- DOTS_SLASH: $t,
402
- NO_DOT: As,
403
- NO_DOTS: ys,
404
- NO_DOT_SLASH: _s,
405
- NO_DOTS_SLASH: Rs,
406
- QMARK_NO_DOT: ds,
407
- STAR: Ss,
408
- START_ANCHOR: Qt,
409
- SEP: Es
410
- }, bs = {
411
- ...jt,
412
- SLASH_LITERAL: `[${q}]`,
413
- QMARK: Lt,
414
- STAR: `${Lt}*?`,
415
- DOTS_SLASH: `${z}{1,2}(?:[${q}]|$)`,
416
- NO_DOT: `(?!${z})`,
417
- NO_DOTS: `(?!(?:^|[${q}])${z}{1,2}(?:[${q}]|$))`,
418
- NO_DOT_SLASH: `(?!${z}{0,1}(?:[${q}]|$))`,
419
- NO_DOTS_SLASH: `(?!${z}{1,2}(?:[${q}]|$))`,
420
- QMARK_NO_DOT: `[^.${q}]`,
421
- START_ANCHOR: `(?:^|[${q}])`,
422
- END_ANCHOR: `(?:[${q}]|$)`,
423
- SEP: "\\"
424
- }, ms = {
425
- alnum: "a-zA-Z0-9",
426
- alpha: "a-zA-Z",
427
- ascii: "\\x00-\\x7F",
428
- blank: " \\t",
429
- cntrl: "\\x00-\\x1F\\x7F",
430
- digit: "0-9",
431
- graph: "\\x21-\\x7E",
432
- lower: "a-z",
433
- print: "\\x20-\\x7E ",
434
- punct: "\\-!\"#$%&'()\\*+,./:;<=>?@[\\]^_`{|}~",
435
- space: " \\t\\r\\n\\v\\f",
436
- upper: "A-Z",
437
- word: "A-Za-z0-9_",
438
- xdigit: "A-Fa-f0-9"
439
- };
440
- var ht = {
441
- MAX_LENGTH: 1024 * 64,
442
- POSIX_REGEX_SOURCE: ms,
443
- // regular expressions
444
- REGEX_BACKSLASH: /\\(?![*+?^${}(|)[\]])/g,
445
- REGEX_NON_SPECIAL_CHARS: /^[^@![\].,$*+?^{}()|\\/]+/,
446
- REGEX_SPECIAL_CHARS: /[-*+?.^${}(|)[\]]/,
447
- REGEX_SPECIAL_CHARS_BACKREF: /(\\?)((\W)(\3*))/g,
448
- REGEX_SPECIAL_CHARS_GLOBAL: /([-*+?.^${}(|)[\]])/g,
449
- REGEX_REMOVE_BACKSLASH: /(?:\[.*?[^\\]\]|\\(?=.))/g,
450
- // Replace globs with equivalent patterns to reduce parsing time.
451
- REPLACEMENTS: {
452
- __proto__: null,
453
- "***": "*",
454
- "**/**": "**",
455
- "**/**/**": "**"
456
- },
457
- // Digits
458
- CHAR_0: 48,
459
- /* 0 */
460
- CHAR_9: 57,
461
- /* 9 */
462
- // Alphabet chars.
463
- CHAR_UPPERCASE_A: 65,
464
- /* A */
465
- CHAR_LOWERCASE_A: 97,
466
- /* a */
467
- CHAR_UPPERCASE_Z: 90,
468
- /* Z */
469
- CHAR_LOWERCASE_Z: 122,
470
- /* z */
471
- CHAR_LEFT_PARENTHESES: 40,
472
- /* ( */
473
- CHAR_RIGHT_PARENTHESES: 41,
474
- /* ) */
475
- CHAR_ASTERISK: 42,
476
- /* * */
477
- // Non-alphabetic chars.
478
- CHAR_AMPERSAND: 38,
479
- /* & */
480
- CHAR_AT: 64,
481
- /* @ */
482
- CHAR_BACKWARD_SLASH: 92,
483
- /* \ */
484
- CHAR_CARRIAGE_RETURN: 13,
485
- /* \r */
486
- CHAR_CIRCUMFLEX_ACCENT: 94,
487
- /* ^ */
488
- CHAR_COLON: 58,
489
- /* : */
490
- CHAR_COMMA: 44,
491
- /* , */
492
- CHAR_DOT: 46,
493
- /* . */
494
- CHAR_DOUBLE_QUOTE: 34,
495
- /* " */
496
- CHAR_EQUAL: 61,
497
- /* = */
498
- CHAR_EXCLAMATION_MARK: 33,
499
- /* ! */
500
- CHAR_FORM_FEED: 12,
501
- /* \f */
502
- CHAR_FORWARD_SLASH: 47,
503
- /* / */
504
- CHAR_GRAVE_ACCENT: 96,
505
- /* ` */
506
- CHAR_HASH: 35,
507
- /* # */
508
- CHAR_HYPHEN_MINUS: 45,
509
- /* - */
510
- CHAR_LEFT_ANGLE_BRACKET: 60,
511
- /* < */
512
- CHAR_LEFT_CURLY_BRACE: 123,
513
- /* { */
514
- CHAR_LEFT_SQUARE_BRACKET: 91,
515
- /* [ */
516
- CHAR_LINE_FEED: 10,
517
- /* \n */
518
- CHAR_NO_BREAK_SPACE: 160,
519
- /* \u00A0 */
520
- CHAR_PERCENT: 37,
521
- /* % */
522
- CHAR_PLUS: 43,
523
- /* + */
524
- CHAR_QUESTION_MARK: 63,
525
- /* ? */
526
- CHAR_RIGHT_ANGLE_BRACKET: 62,
527
- /* > */
528
- CHAR_RIGHT_CURLY_BRACE: 125,
529
- /* } */
530
- CHAR_RIGHT_SQUARE_BRACKET: 93,
531
- /* ] */
532
- CHAR_SEMICOLON: 59,
533
- /* ; */
534
- CHAR_SINGLE_QUOTE: 39,
535
- /* ' */
536
- CHAR_SPACE: 32,
537
- /* */
538
- CHAR_TAB: 9,
539
- /* \t */
540
- CHAR_UNDERSCORE: 95,
541
- /* _ */
542
- CHAR_VERTICAL_LINE: 124,
543
- /* | */
544
- CHAR_ZERO_WIDTH_NOBREAK_SPACE: 65279,
545
- /* \uFEFF */
546
- /**
547
- * Create EXTGLOB_CHARS
548
- */
549
- extglobChars(t) {
550
- return {
551
- "!": { type: "negate", open: "(?:(?!(?:", close: `))${t.STAR})` },
552
- "?": { type: "qmark", open: "(?:", close: ")?" },
553
- "+": { type: "plus", open: "(?:", close: ")+" },
554
- "*": { type: "star", open: "(?:", close: ")*" },
555
- "@": { type: "at", open: "(?:", close: ")" }
556
- };
557
- },
558
- /**
559
- * Create GLOB_CHARS
560
- */
561
- globChars(t) {
562
- return t === !0 ? bs : jt;
563
- }
564
- };
565
- (function(t) {
566
- const {
567
- REGEX_BACKSLASH: s,
568
- REGEX_REMOVE_BACKSLASH: e,
569
- REGEX_SPECIAL_CHARS: n,
570
- REGEX_SPECIAL_CHARS_GLOBAL: o
571
- } = ht;
572
- t.isObject = (r) => r !== null && typeof r == "object" && !Array.isArray(r), t.hasRegexChars = (r) => n.test(r), t.isRegexChar = (r) => r.length === 1 && t.hasRegexChars(r), t.escapeRegex = (r) => r.replace(o, "\\$1"), t.toPosixSlashes = (r) => r.replace(s, "/"), t.isWindows = () => {
573
- if (typeof navigator < "u" && navigator.platform) {
574
- const r = navigator.platform.toLowerCase();
575
- return r === "win32" || r === "windows";
576
- }
577
- return typeof process < "u" && process.platform ? process.platform === "win32" : !1;
578
- }, t.removeBackslashes = (r) => r.replace(e, (c) => c === "\\" ? "" : c), t.escapeLast = (r, c, l) => {
579
- const h = r.lastIndexOf(c, l);
580
- return h === -1 ? r : r[h - 1] === "\\" ? t.escapeLast(r, c, h - 1) : `${r.slice(0, h)}\\${r.slice(h)}`;
581
- }, t.removePrefix = (r, c = {}) => {
582
- let l = r;
583
- return l.startsWith("./") && (l = l.slice(2), c.prefix = "./"), l;
584
- }, t.wrapOutput = (r, c = {}, l = {}) => {
585
- const h = l.contains ? "" : "^", R = l.contains ? "" : "$";
586
- let g = `${h}(?:${r})${R}`;
587
- return c.negated === !0 && (g = `(?:^(?!${g}).*$)`), g;
588
- }, t.basename = (r, { windows: c } = {}) => {
589
- const l = r.split(c ? /[\\/]/ : "/"), h = l[l.length - 1];
590
- return h === "" ? l[l.length - 2] : h;
591
- };
592
- })(rt);
593
- const Pt = rt, {
594
- CHAR_ASTERISK: yt,
595
- /* * */
596
- CHAR_AT: Cs,
597
- /* @ */
598
- CHAR_BACKWARD_SLASH: st,
599
- /* \ */
600
- CHAR_COMMA: $s,
601
- /* , */
602
- CHAR_DOT: _t,
603
- /* . */
604
- CHAR_EXCLAMATION_MARK: Rt,
605
- /* ! */
606
- CHAR_FORWARD_SLASH: zt,
607
- /* / */
608
- CHAR_LEFT_CURLY_BRACE: dt,
609
- /* { */
610
- CHAR_LEFT_PARENTHESES: St,
611
- /* ( */
612
- CHAR_LEFT_SQUARE_BRACKET: xs,
613
- /* [ */
614
- CHAR_PLUS: vs,
615
- /* + */
616
- CHAR_QUESTION_MARK: Tt,
617
- /* ? */
618
- CHAR_RIGHT_CURLY_BRACE: Hs,
619
- /* } */
620
- CHAR_RIGHT_PARENTHESES: kt,
621
- /* ) */
622
- CHAR_RIGHT_SQUARE_BRACKET: ws
623
- /* ] */
624
- } = ht, Ot = (t) => t === zt || t === st, Dt = (t) => {
625
- t.isPrefix !== !0 && (t.depth = t.isGlobstar ? 1 / 0 : 1);
626
- }, Ls = (t, s) => {
627
- const e = s || {}, n = t.length - 1, o = e.parts === !0 || e.scanToEnd === !0, r = [], c = [], l = [];
628
- let h = t, R = -1, g = 0, E = 0, A = !1, b = !1, d = !1, $ = !1, x = !1, w = !1, y = !1, W = !1, Q = !1, B = !1, N = 0, G, _, m = { value: "", depth: 0, isGlob: !1 };
629
- const a = () => R >= n, M = () => h.charCodeAt(R + 1), O = () => (G = _, h.charCodeAt(++R));
630
- for (; R < n; ) {
631
- _ = O();
632
- let v;
633
- if (_ === st) {
634
- y = m.backslashes = !0, _ = O(), _ === dt && (w = !0);
635
- continue;
636
- }
637
- if (w === !0 || _ === dt) {
638
- for (N++; a() !== !0 && (_ = O()); ) {
639
- if (_ === st) {
640
- y = m.backslashes = !0, O();
641
- continue;
642
- }
643
- if (_ === dt) {
644
- N++;
645
- continue;
646
- }
647
- if (w !== !0 && _ === _t && (_ = O()) === _t) {
648
- if (A = m.isBrace = !0, d = m.isGlob = !0, B = !0, o === !0)
649
- continue;
650
- break;
651
- }
652
- if (w !== !0 && _ === $s) {
653
- if (A = m.isBrace = !0, d = m.isGlob = !0, B = !0, o === !0)
654
- continue;
655
- break;
656
- }
657
- if (_ === Hs && (N--, N === 0)) {
658
- w = !1, A = m.isBrace = !0, B = !0;
659
- break;
660
- }
661
- }
662
- if (o === !0)
663
- continue;
664
- break;
665
- }
666
- if (_ === zt) {
667
- if (r.push(R), c.push(m), m = { value: "", depth: 0, isGlob: !1 }, B === !0) continue;
668
- if (G === _t && R === g + 1) {
669
- g += 2;
670
- continue;
671
- }
672
- E = R + 1;
673
- continue;
674
- }
675
- if (e.noext !== !0 && (_ === vs || _ === Cs || _ === yt || _ === Tt || _ === Rt) === !0 && M() === St) {
676
- if (d = m.isGlob = !0, $ = m.isExtglob = !0, B = !0, _ === Rt && R === g && (Q = !0), o === !0) {
677
- for (; a() !== !0 && (_ = O()); ) {
678
- if (_ === st) {
679
- y = m.backslashes = !0, _ = O();
680
- continue;
681
- }
682
- if (_ === kt) {
683
- d = m.isGlob = !0, B = !0;
684
- break;
685
- }
686
- }
687
- continue;
688
- }
689
- break;
690
- }
691
- if (_ === yt) {
692
- if (G === yt && (x = m.isGlobstar = !0), d = m.isGlob = !0, B = !0, o === !0)
693
- continue;
694
- break;
695
- }
696
- if (_ === Tt) {
697
- if (d = m.isGlob = !0, B = !0, o === !0)
698
- continue;
699
- break;
700
- }
701
- if (_ === xs) {
702
- for (; a() !== !0 && (v = O()); ) {
703
- if (v === st) {
704
- y = m.backslashes = !0, O();
705
- continue;
706
- }
707
- if (v === ws) {
708
- b = m.isBracket = !0, d = m.isGlob = !0, B = !0;
709
- break;
710
- }
711
- }
712
- if (o === !0)
713
- continue;
714
- break;
715
- }
716
- if (e.nonegate !== !0 && _ === Rt && R === g) {
717
- W = m.negated = !0, g++;
718
- continue;
719
- }
720
- if (e.noparen !== !0 && _ === St) {
721
- if (d = m.isGlob = !0, o === !0) {
722
- for (; a() !== !0 && (_ = O()); ) {
723
- if (_ === St) {
724
- y = m.backslashes = !0, _ = O();
725
- continue;
726
- }
727
- if (_ === kt) {
728
- B = !0;
729
- break;
730
- }
731
- }
732
- continue;
733
- }
734
- break;
735
- }
736
- if (d === !0) {
737
- if (B = !0, o === !0)
738
- continue;
739
- break;
740
- }
741
- }
742
- e.noext === !0 && ($ = !1, d = !1);
743
- let T = h, i = "", u = "";
744
- g > 0 && (i = h.slice(0, g), h = h.slice(g), E -= g), T && d === !0 && E > 0 ? (T = h.slice(0, E), u = h.slice(E)) : d === !0 ? (T = "", u = h) : T = h, T && T !== "" && T !== "/" && T !== h && Ot(T.charCodeAt(T.length - 1)) && (T = T.slice(0, -1)), e.unescape === !0 && (u && (u = Pt.removeBackslashes(u)), T && y === !0 && (T = Pt.removeBackslashes(T)));
745
- const U = {
746
- prefix: i,
747
- input: t,
748
- start: g,
749
- base: T,
750
- glob: u,
751
- isBrace: A,
752
- isBracket: b,
753
- isGlob: d,
754
- isExtglob: $,
755
- isGlobstar: x,
756
- negated: W,
757
- negatedExtglob: Q
758
- };
759
- if (e.tokens === !0 && (U.maxDepth = 0, Ot(_) || c.push(m), U.tokens = c), e.parts === !0 || e.tokens === !0) {
760
- let v;
761
- for (let L = 0; L < r.length; L++) {
762
- const j = v ? v + 1 : g, K = r[L], Y = t.slice(j, K);
763
- e.tokens && (L === 0 && g !== 0 ? (c[L].isPrefix = !0, c[L].value = i) : c[L].value = Y, Dt(c[L]), U.maxDepth += c[L].depth), (L !== 0 || Y !== "") && l.push(Y), v = K;
764
- }
765
- if (v && v + 1 < t.length) {
766
- const L = t.slice(v + 1);
767
- l.push(L), e.tokens && (c[c.length - 1].value = L, Dt(c[c.length - 1]), U.maxDepth += c[c.length - 1].depth);
768
- }
769
- U.slashes = r, U.parts = l;
770
- }
771
- return U;
772
- };
773
- var Ps = Ls;
774
- const ct = ht, X = rt, {
775
- MAX_LENGTH: lt,
776
- POSIX_REGEX_SOURCE: Ts,
777
- REGEX_NON_SPECIAL_CHARS: ks,
778
- REGEX_SPECIAL_CHARS_BACKREF: Os,
779
- REPLACEMENTS: Yt
780
- } = ct, Ds = (t, s) => {
781
- if (typeof s.expandRange == "function")
782
- return s.expandRange(...t, s);
783
- t.sort();
784
- const e = `[${t.join("-")}]`;
785
- try {
786
- new RegExp(e);
787
- } catch {
788
- return t.map((o) => X.escapeRegex(o)).join("..");
789
- }
790
- return e;
791
- }, tt = (t, s) => `Missing ${t}: "${s}" - use "\\\\${s}" to match literal characters`, xt = (t, s) => {
792
- if (typeof t != "string")
793
- throw new TypeError("Expected a string");
794
- t = Yt[t] || t;
795
- const e = { ...s }, n = typeof e.maxLength == "number" ? Math.min(lt, e.maxLength) : lt;
796
- let o = t.length;
797
- if (o > n)
798
- throw new SyntaxError(`Input length: ${o}, exceeds maximum allowed length: ${n}`);
799
- const r = { type: "bos", value: "", output: e.prepend || "" }, c = [r], l = e.capture ? "" : "?:", h = ct.globChars(e.windows), R = ct.extglobChars(h), {
800
- DOT_LITERAL: g,
801
- PLUS_LITERAL: E,
802
- SLASH_LITERAL: A,
803
- ONE_CHAR: b,
804
- DOTS_SLASH: d,
805
- NO_DOT: $,
806
- NO_DOT_SLASH: x,
807
- NO_DOTS_SLASH: w,
808
- QMARK: y,
809
- QMARK_NO_DOT: W,
810
- STAR: Q,
811
- START_ANCHOR: B
812
- } = h, N = (f) => `(${l}(?:(?!${B}${f.dot ? d : g}).)*?)`, G = e.dot ? "" : $, _ = e.dot ? y : W;
813
- let m = e.bash === !0 ? N(e) : Q;
814
- e.capture && (m = `(${m})`), typeof e.noext == "boolean" && (e.noextglob = e.noext);
815
- const a = {
816
- input: t,
817
- index: -1,
818
- start: 0,
819
- dot: e.dot === !0,
820
- consumed: "",
821
- output: "",
822
- prefix: "",
823
- backtrack: !1,
824
- negated: !1,
825
- brackets: 0,
826
- braces: 0,
827
- parens: 0,
828
- quotes: 0,
829
- globstar: !1,
830
- tokens: c
831
- };
832
- t = X.removePrefix(t, a), o = t.length;
833
- const M = [], O = [], T = [];
834
- let i = r, u;
835
- const U = () => a.index === o - 1, v = a.peek = (f = 1) => t[a.index + f], L = a.advance = () => t[++a.index] || "", j = () => t.slice(a.index + 1), K = (f = "", H = 0) => {
836
- a.consumed += f, a.index += H;
837
- }, Y = (f) => {
838
- a.output += f.output != null ? f.output : f.value, K(f.value);
839
- }, ie = () => {
840
- let f = 1;
841
- for (; v() === "!" && (v(2) !== "(" || v(3) === "?"); )
842
- L(), a.start++, f++;
843
- return f % 2 === 0 ? !1 : (a.negated = !0, a.start++, !0);
844
- }, ot = (f) => {
845
- a[f]++, T.push(f);
846
- }, Z = (f) => {
847
- a[f]--, T.pop();
848
- }, C = (f) => {
849
- if (i.type === "globstar") {
850
- const H = a.braces > 0 && (f.type === "comma" || f.type === "brace"), p = f.extglob === !0 || M.length && (f.type === "pipe" || f.type === "paren");
851
- f.type !== "slash" && f.type !== "paren" && !H && !p && (a.output = a.output.slice(0, -i.output.length), i.type = "star", i.value = "*", i.output = m, a.output += i.output);
852
- }
853
- if (M.length && f.type !== "paren" && (M[M.length - 1].inner += f.value), (f.value || f.output) && Y(f), i && i.type === "text" && f.type === "text") {
854
- i.output = (i.output || i.value) + f.value, i.value += f.value;
855
- return;
856
- }
857
- f.prev = i, c.push(f), i = f;
858
- }, it = (f, H) => {
859
- const p = { ...R[H], conditions: 1, inner: "" };
860
- p.prev = i, p.parens = a.parens, p.output = a.output;
861
- const S = (e.capture ? "(" : "") + p.open;
862
- ot("parens"), C({ type: f, value: H, output: a.output ? "" : b }), C({ type: "paren", extglob: !0, value: L(), output: S }), M.push(p);
863
- }, ue = (f) => {
864
- let H = f.close + (e.capture ? ")" : ""), p;
865
- if (f.type === "negate") {
866
- let S = m;
867
- if (f.inner && f.inner.length > 1 && f.inner.includes("/") && (S = N(e)), (S !== m || U() || /^\)+$/.test(j())) && (H = f.close = `)$))${S}`), f.inner.includes("*") && (p = j()) && /^\.[^\\/.]+$/.test(p)) {
868
- const P = xt(p, { ...s, fastpaths: !1 }).output;
869
- H = f.close = `)${P})${S})`;
870
- }
871
- f.prev.type === "bos" && (a.negatedExtglob = !0);
872
- }
873
- C({ type: "paren", extglob: !0, value: u, output: H }), Z("parens");
874
- };
875
- if (e.fastpaths !== !1 && !/(^[*!]|[/()[\]{}"])/.test(t)) {
876
- let f = !1, H = t.replace(Os, (p, S, P, F, I, gt) => F === "\\" ? (f = !0, p) : F === "?" ? S ? S + F + (I ? y.repeat(I.length) : "") : gt === 0 ? _ + (I ? y.repeat(I.length) : "") : y.repeat(P.length) : F === "." ? g.repeat(P.length) : F === "*" ? S ? S + F + (I ? m : "") : m : S ? p : `\\${p}`);
877
- return f === !0 && (e.unescape === !0 ? H = H.replace(/\\/g, "") : H = H.replace(/\\+/g, (p) => p.length % 2 === 0 ? "\\\\" : p ? "\\" : "")), H === t && e.contains === !0 ? (a.output = t, a) : (a.output = X.wrapOutput(H, a, s), a);
878
- }
879
- for (; !U(); ) {
880
- if (u = L(), u === "\0")
881
- continue;
882
- if (u === "\\") {
883
- const p = v();
884
- if (p === "/" && e.bash !== !0 || p === "." || p === ";")
885
- continue;
886
- if (!p) {
887
- u += "\\", C({ type: "text", value: u });
888
- continue;
889
- }
890
- const S = /^\\+/.exec(j());
891
- let P = 0;
892
- if (S && S[0].length > 2 && (P = S[0].length, a.index += P, P % 2 !== 0 && (u += "\\")), e.unescape === !0 ? u = L() : u += L(), a.brackets === 0) {
893
- C({ type: "text", value: u });
894
- continue;
895
- }
896
- }
897
- if (a.brackets > 0 && (u !== "]" || i.value === "[" || i.value === "[^")) {
898
- if (e.posix !== !1 && u === ":") {
899
- const p = i.value.slice(1);
900
- if (p.includes("[") && (i.posix = !0, p.includes(":"))) {
901
- const S = i.value.lastIndexOf("["), P = i.value.slice(0, S), F = i.value.slice(S + 2), I = Ts[F];
902
- if (I) {
903
- i.value = P + I, a.backtrack = !0, L(), !r.output && c.indexOf(i) === 1 && (r.output = b);
904
- continue;
905
- }
906
- }
907
- }
908
- (u === "[" && v() !== ":" || u === "-" && v() === "]") && (u = `\\${u}`), u === "]" && (i.value === "[" || i.value === "[^") && (u = `\\${u}`), e.posix === !0 && u === "!" && i.value === "[" && (u = "^"), i.value += u, Y({ value: u });
909
- continue;
910
- }
911
- if (a.quotes === 1 && u !== '"') {
912
- u = X.escapeRegex(u), i.value += u, Y({ value: u });
913
- continue;
914
- }
915
- if (u === '"') {
916
- a.quotes = a.quotes === 1 ? 0 : 1, e.keepQuotes === !0 && C({ type: "text", value: u });
917
- continue;
918
- }
919
- if (u === "(") {
920
- ot("parens"), C({ type: "paren", value: u });
921
- continue;
922
- }
923
- if (u === ")") {
924
- if (a.parens === 0 && e.strictBrackets === !0)
925
- throw new SyntaxError(tt("opening", "("));
926
- const p = M[M.length - 1];
927
- if (p && a.parens === p.parens + 1) {
928
- ue(M.pop());
929
- continue;
930
- }
931
- C({ type: "paren", value: u, output: a.parens ? ")" : "\\)" }), Z("parens");
932
- continue;
933
- }
934
- if (u === "[") {
935
- if (e.nobracket === !0 || !j().includes("]")) {
936
- if (e.nobracket !== !0 && e.strictBrackets === !0)
937
- throw new SyntaxError(tt("closing", "]"));
938
- u = `\\${u}`;
939
- } else
940
- ot("brackets");
941
- C({ type: "bracket", value: u });
942
- continue;
943
- }
944
- if (u === "]") {
945
- if (e.nobracket === !0 || i && i.type === "bracket" && i.value.length === 1) {
946
- C({ type: "text", value: u, output: `\\${u}` });
947
- continue;
948
- }
949
- if (a.brackets === 0) {
950
- if (e.strictBrackets === !0)
951
- throw new SyntaxError(tt("opening", "["));
952
- C({ type: "text", value: u, output: `\\${u}` });
953
- continue;
954
- }
955
- Z("brackets");
956
- const p = i.value.slice(1);
957
- if (i.posix !== !0 && p[0] === "^" && !p.includes("/") && (u = `/${u}`), i.value += u, Y({ value: u }), e.literalBrackets === !1 || X.hasRegexChars(p))
958
- continue;
959
- const S = X.escapeRegex(i.value);
960
- if (a.output = a.output.slice(0, -i.value.length), e.literalBrackets === !0) {
961
- a.output += S, i.value = S;
962
- continue;
963
- }
964
- i.value = `(${l}${S}|${i.value})`, a.output += i.value;
965
- continue;
966
- }
967
- if (u === "{" && e.nobrace !== !0) {
968
- ot("braces");
969
- const p = {
970
- type: "brace",
971
- value: u,
972
- output: "(",
973
- outputIndex: a.output.length,
974
- tokensIndex: a.tokens.length
975
- };
976
- O.push(p), C(p);
977
- continue;
978
- }
979
- if (u === "}") {
980
- const p = O[O.length - 1];
981
- if (e.nobrace === !0 || !p) {
982
- C({ type: "text", value: u, output: u });
983
- continue;
984
- }
985
- let S = ")";
986
- if (p.dots === !0) {
987
- const P = c.slice(), F = [];
988
- for (let I = P.length - 1; I >= 0 && (c.pop(), P[I].type !== "brace"); I--)
989
- P[I].type !== "dots" && F.unshift(P[I].value);
990
- S = Ds(F, e), a.backtrack = !0;
991
- }
992
- if (p.comma !== !0 && p.dots !== !0) {
993
- const P = a.output.slice(0, p.outputIndex), F = a.tokens.slice(p.tokensIndex);
994
- p.value = p.output = "\\{", u = S = "\\}", a.output = P;
995
- for (const I of F)
996
- a.output += I.output || I.value;
997
- }
998
- C({ type: "brace", value: u, output: S }), Z("braces"), O.pop();
999
- continue;
1000
- }
1001
- if (u === "|") {
1002
- M.length > 0 && M[M.length - 1].conditions++, C({ type: "text", value: u });
1003
- continue;
1004
- }
1005
- if (u === ",") {
1006
- let p = u;
1007
- const S = O[O.length - 1];
1008
- S && T[T.length - 1] === "braces" && (S.comma = !0, p = "|"), C({ type: "comma", value: u, output: p });
1009
- continue;
1010
- }
1011
- if (u === "/") {
1012
- if (i.type === "dot" && a.index === a.start + 1) {
1013
- a.start = a.index + 1, a.consumed = "", a.output = "", c.pop(), i = r;
1014
- continue;
1015
- }
1016
- C({ type: "slash", value: u, output: A });
1017
- continue;
1018
- }
1019
- if (u === ".") {
1020
- if (a.braces > 0 && i.type === "dot") {
1021
- i.value === "." && (i.output = g);
1022
- const p = O[O.length - 1];
1023
- i.type = "dots", i.output += u, i.value += u, p.dots = !0;
1024
- continue;
1025
- }
1026
- if (a.braces + a.parens === 0 && i.type !== "bos" && i.type !== "slash") {
1027
- C({ type: "text", value: u, output: g });
1028
- continue;
1029
- }
1030
- C({ type: "dot", value: u, output: g });
1031
- continue;
1032
- }
1033
- if (u === "?") {
1034
- if (!(i && i.value === "(") && e.noextglob !== !0 && v() === "(" && v(2) !== "?") {
1035
- it("qmark", u);
1036
- continue;
1037
- }
1038
- if (i && i.type === "paren") {
1039
- const S = v();
1040
- let P = u;
1041
- (i.value === "(" && !/[!=<:]/.test(S) || S === "<" && !/<([!=]|\w+>)/.test(j())) && (P = `\\${u}`), C({ type: "text", value: u, output: P });
1042
- continue;
1043
- }
1044
- if (e.dot !== !0 && (i.type === "slash" || i.type === "bos")) {
1045
- C({ type: "qmark", value: u, output: W });
1046
- continue;
1047
- }
1048
- C({ type: "qmark", value: u, output: y });
1049
- continue;
1050
- }
1051
- if (u === "!") {
1052
- if (e.noextglob !== !0 && v() === "(" && (v(2) !== "?" || !/[!=<:]/.test(v(3)))) {
1053
- it("negate", u);
1054
- continue;
1055
- }
1056
- if (e.nonegate !== !0 && a.index === 0) {
1057
- ie();
1058
- continue;
1059
- }
1060
- }
1061
- if (u === "+") {
1062
- if (e.noextglob !== !0 && v() === "(" && v(2) !== "?") {
1063
- it("plus", u);
1064
- continue;
1065
- }
1066
- if (i && i.value === "(" || e.regex === !1) {
1067
- C({ type: "plus", value: u, output: E });
1068
- continue;
1069
- }
1070
- if (i && (i.type === "bracket" || i.type === "paren" || i.type === "brace") || a.parens > 0) {
1071
- C({ type: "plus", value: u });
1072
- continue;
1073
- }
1074
- C({ type: "plus", value: E });
1075
- continue;
1076
- }
1077
- if (u === "@") {
1078
- if (e.noextglob !== !0 && v() === "(" && v(2) !== "?") {
1079
- C({ type: "at", extglob: !0, value: u, output: "" });
1080
- continue;
1081
- }
1082
- C({ type: "text", value: u });
1083
- continue;
1084
- }
1085
- if (u !== "*") {
1086
- (u === "$" || u === "^") && (u = `\\${u}`);
1087
- const p = ks.exec(j());
1088
- p && (u += p[0], a.index += p[0].length), C({ type: "text", value: u });
1089
- continue;
1090
- }
1091
- if (i && (i.type === "globstar" || i.star === !0)) {
1092
- i.type = "star", i.star = !0, i.value += u, i.output = m, a.backtrack = !0, a.globstar = !0, K(u);
1093
- continue;
1094
- }
1095
- let f = j();
1096
- if (e.noextglob !== !0 && /^\([^?]/.test(f)) {
1097
- it("star", u);
1098
- continue;
1099
- }
1100
- if (i.type === "star") {
1101
- if (e.noglobstar === !0) {
1102
- K(u);
1103
- continue;
1104
- }
1105
- const p = i.prev, S = p.prev, P = p.type === "slash" || p.type === "bos", F = S && (S.type === "star" || S.type === "globstar");
1106
- if (e.bash === !0 && (!P || f[0] && f[0] !== "/")) {
1107
- C({ type: "star", value: u, output: "" });
1108
- continue;
1109
- }
1110
- const I = a.braces > 0 && (p.type === "comma" || p.type === "brace"), gt = M.length && (p.type === "pipe" || p.type === "paren");
1111
- if (!P && p.type !== "paren" && !I && !gt) {
1112
- C({ type: "star", value: u, output: "" });
1113
- continue;
1114
- }
1115
- for (; f.slice(0, 3) === "/**"; ) {
1116
- const ut = t[a.index + 4];
1117
- if (ut && ut !== "/")
1118
- break;
1119
- f = f.slice(3), K("/**", 3);
1120
- }
1121
- if (p.type === "bos" && U()) {
1122
- i.type = "globstar", i.value += u, i.output = N(e), a.output = i.output, a.globstar = !0, K(u);
1123
- continue;
1124
- }
1125
- if (p.type === "slash" && p.prev.type !== "bos" && !F && U()) {
1126
- a.output = a.output.slice(0, -(p.output + i.output).length), p.output = `(?:${p.output}`, i.type = "globstar", i.output = N(e) + (e.strictSlashes ? ")" : "|$)"), i.value += u, a.globstar = !0, a.output += p.output + i.output, K(u);
1127
- continue;
1128
- }
1129
- if (p.type === "slash" && p.prev.type !== "bos" && f[0] === "/") {
1130
- const ut = f[1] !== void 0 ? "|$" : "";
1131
- a.output = a.output.slice(0, -(p.output + i.output).length), p.output = `(?:${p.output}`, i.type = "globstar", i.output = `${N(e)}${A}|${A}${ut})`, i.value += u, a.output += p.output + i.output, a.globstar = !0, K(u + L()), C({ type: "slash", value: "/", output: "" });
1132
- continue;
1133
- }
1134
- if (p.type === "bos" && f[0] === "/") {
1135
- i.type = "globstar", i.value += u, i.output = `(?:^|${A}|${N(e)}${A})`, a.output = i.output, a.globstar = !0, K(u + L()), C({ type: "slash", value: "/", output: "" });
1136
- continue;
1137
- }
1138
- a.output = a.output.slice(0, -i.output.length), i.type = "globstar", i.output = N(e), i.value += u, a.output += i.output, a.globstar = !0, K(u);
1139
- continue;
1140
- }
1141
- const H = { type: "star", value: u, output: m };
1142
- if (e.bash === !0) {
1143
- H.output = ".*?", (i.type === "bos" || i.type === "slash") && (H.output = G + H.output), C(H);
1144
- continue;
1145
- }
1146
- if (i && (i.type === "bracket" || i.type === "paren") && e.regex === !0) {
1147
- H.output = u, C(H);
1148
- continue;
1149
- }
1150
- (a.index === a.start || i.type === "slash" || i.type === "dot") && (i.type === "dot" ? (a.output += x, i.output += x) : e.dot === !0 ? (a.output += w, i.output += w) : (a.output += G, i.output += G), v() !== "*" && (a.output += b, i.output += b)), C(H);
1151
- }
1152
- for (; a.brackets > 0; ) {
1153
- if (e.strictBrackets === !0) throw new SyntaxError(tt("closing", "]"));
1154
- a.output = X.escapeLast(a.output, "["), Z("brackets");
1155
- }
1156
- for (; a.parens > 0; ) {
1157
- if (e.strictBrackets === !0) throw new SyntaxError(tt("closing", ")"));
1158
- a.output = X.escapeLast(a.output, "("), Z("parens");
1159
- }
1160
- for (; a.braces > 0; ) {
1161
- if (e.strictBrackets === !0) throw new SyntaxError(tt("closing", "}"));
1162
- a.output = X.escapeLast(a.output, "{"), Z("braces");
1163
- }
1164
- if (e.strictSlashes !== !0 && (i.type === "star" || i.type === "bracket") && C({ type: "maybe_slash", value: "", output: `${A}?` }), a.backtrack === !0) {
1165
- a.output = "";
1166
- for (const f of a.tokens)
1167
- a.output += f.output != null ? f.output : f.value, f.suffix && (a.output += f.suffix);
1168
- }
1169
- return a;
1170
- };
1171
- xt.fastpaths = (t, s) => {
1172
- const e = { ...s }, n = typeof e.maxLength == "number" ? Math.min(lt, e.maxLength) : lt, o = t.length;
1173
- if (o > n)
1174
- throw new SyntaxError(`Input length: ${o}, exceeds maximum allowed length: ${n}`);
1175
- t = Yt[t] || t;
1176
- const {
1177
- DOT_LITERAL: r,
1178
- SLASH_LITERAL: c,
1179
- ONE_CHAR: l,
1180
- DOTS_SLASH: h,
1181
- NO_DOT: R,
1182
- NO_DOTS: g,
1183
- NO_DOTS_SLASH: E,
1184
- STAR: A,
1185
- START_ANCHOR: b
1186
- } = ct.globChars(e.windows), d = e.dot ? g : R, $ = e.dot ? E : R, x = e.capture ? "" : "?:", w = { negated: !1, prefix: "" };
1187
- let y = e.bash === !0 ? ".*?" : A;
1188
- e.capture && (y = `(${y})`);
1189
- const W = (G) => G.noglobstar === !0 ? y : `(${x}(?:(?!${b}${G.dot ? h : r}).)*?)`, Q = (G) => {
1190
- switch (G) {
1191
- case "*":
1192
- return `${d}${l}${y}`;
1193
- case ".*":
1194
- return `${r}${l}${y}`;
1195
- case "*.*":
1196
- return `${d}${y}${r}${l}${y}`;
1197
- case "*/*":
1198
- return `${d}${y}${c}${l}${$}${y}`;
1199
- case "**":
1200
- return d + W(e);
1201
- case "**/*":
1202
- return `(?:${d}${W(e)}${c})?${$}${l}${y}`;
1203
- case "**/*.*":
1204
- return `(?:${d}${W(e)}${c})?${$}${y}${r}${l}${y}`;
1205
- case "**/.*":
1206
- return `(?:${d}${W(e)}${c})?${r}${l}${y}`;
1207
- default: {
1208
- const _ = /^(.*?)\.(\w+)$/.exec(G);
1209
- if (!_) return;
1210
- const m = Q(_[1]);
1211
- return m ? m + r + _[2] : void 0;
1212
- }
1213
- }
1214
- }, B = X.removePrefix(t, w);
1215
- let N = Q(B);
1216
- return N && e.strictSlashes !== !0 && (N += `${c}?`), N;
1217
- };
1218
- var Is = xt;
1219
- const Ns = Ps, mt = Is, Zt = rt, Bs = ht, Fs = (t) => t && typeof t == "object" && !Array.isArray(t), k = (t, s, e = !1) => {
1220
- if (Array.isArray(t)) {
1221
- const g = t.map((A) => k(A, s, e));
1222
- return (A) => {
1223
- for (const b of g) {
1224
- const d = b(A);
1225
- if (d) return d;
1226
- }
1227
- return !1;
1228
- };
1229
- }
1230
- const n = Fs(t) && t.tokens && t.input;
1231
- if (t === "" || typeof t != "string" && !n)
1232
- throw new TypeError("Expected pattern to be a non-empty string");
1233
- const o = s || {}, r = o.windows, c = n ? k.compileRe(t, s) : k.makeRe(t, s, !1, !0), l = c.state;
1234
- delete c.state;
1235
- let h = () => !1;
1236
- if (o.ignore) {
1237
- const g = { ...s, ignore: null, onMatch: null, onResult: null };
1238
- h = k(o.ignore, g, e);
1239
- }
1240
- const R = (g, E = !1) => {
1241
- const { isMatch: A, match: b, output: d } = k.test(g, c, s, { glob: t, posix: r }), $ = { glob: t, state: l, regex: c, posix: r, input: g, output: d, match: b, isMatch: A };
1242
- return typeof o.onResult == "function" && o.onResult($), A === !1 ? ($.isMatch = !1, E ? $ : !1) : h(g) ? (typeof o.onIgnore == "function" && o.onIgnore($), $.isMatch = !1, E ? $ : !1) : (typeof o.onMatch == "function" && o.onMatch($), E ? $ : !0);
1243
- };
1244
- return e && (R.state = l), R;
1245
- };
1246
- k.test = (t, s, e, { glob: n, posix: o } = {}) => {
1247
- if (typeof t != "string")
1248
- throw new TypeError("Expected input to be a string");
1249
- if (t === "")
1250
- return { isMatch: !1, output: "" };
1251
- const r = e || {}, c = r.format || (o ? Zt.toPosixSlashes : null);
1252
- let l = t === n, h = l && c ? c(t) : t;
1253
- return l === !1 && (h = c ? c(t) : t, l = h === n), (l === !1 || r.capture === !0) && (r.matchBase === !0 || r.basename === !0 ? l = k.matchBase(t, s, e, o) : l = s.exec(h)), { isMatch: !!l, match: l, output: h };
1254
- };
1255
- k.matchBase = (t, s, e) => (s instanceof RegExp ? s : k.makeRe(s, e)).test(Zt.basename(t));
1256
- k.isMatch = (t, s, e) => k(s, e)(t);
1257
- k.parse = (t, s) => Array.isArray(t) ? t.map((e) => k.parse(e, s)) : mt(t, { ...s, fastpaths: !1 });
1258
- k.scan = (t, s) => Ns(t, s);
1259
- k.compileRe = (t, s, e = !1, n = !1) => {
1260
- if (e === !0)
1261
- return t.output;
1262
- const o = s || {}, r = o.contains ? "" : "^", c = o.contains ? "" : "$";
1263
- let l = `${r}(?:${t.output})${c}`;
1264
- t && t.negated === !0 && (l = `^(?!${l}).*$`);
1265
- const h = k.toRegex(l, s);
1266
- return n === !0 && (h.state = t), h;
1267
- };
1268
- k.makeRe = (t, s = {}, e = !1, n = !1) => {
1269
- if (!t || typeof t != "string")
1270
- throw new TypeError("Expected a non-empty string");
1271
- let o = { negated: !1, fastpaths: !0 };
1272
- return s.fastpaths !== !1 && (t[0] === "." || t[0] === "*") && (o.output = mt.fastpaths(t, s)), o.output || (o = mt(t, s)), k.compileRe(o, s, e, n);
1273
- };
1274
- k.toRegex = (t, s) => {
1275
- try {
1276
- const e = s || {};
1277
- return new RegExp(t, e.flags || (e.nocase ? "i" : ""));
1278
- } catch (e) {
1279
- if (s && s.debug === !0) throw e;
1280
- return /$^/;
1281
- }
1282
- };
1283
- k.constants = Bs;
1284
- var Ms = k;
1285
- const Vt = Ms, Gs = rt;
1286
- function Jt(t, s, e = !1) {
1287
- return s && (s.windows === null || s.windows === void 0) && (s = { ...s, windows: Gs.isWindows() }), Vt(t, s, e);
1288
- }
1289
- Object.assign(Jt, Vt);
1290
- var Ws = Jt;
1291
- const nt = /* @__PURE__ */ ps(Ws), te = Array.isArray, vt = process.platform === "win32", Us = /^(\/?\.\.)+$/;
1292
- function Ks(t, s = {}) {
1293
- const e = t.length, n = Array(e), o = Array(e), r = !s.noglobstar;
1294
- for (let c = 0; c < e; c++) {
1295
- const l = ee(t[c]);
1296
- n[c] = l;
1297
- const h = l.length, R = Array(h);
1298
- for (let g = 0; g < h; g++) R[g] = nt(l[g], s);
1299
- o[c] = R;
1300
- }
1301
- return (c) => {
1302
- const l = c.split("/");
1303
- if (l[0] === ".." && Us.test(c)) return !0;
1304
- for (let h = 0; h < t.length; h++) {
1305
- const R = n[h], g = o[h], E = l.length, A = Math.min(E, R.length);
1306
- let b = 0;
1307
- for (; b < A; ) {
1308
- const d = R[b];
1309
- if (d.includes("/")) return !0;
1310
- if (!g[b](l[b])) break;
1311
- if (r && d === "**") return !0;
1312
- b++;
1313
- }
1314
- if (b === E) return !0;
1315
- }
1316
- return !1;
1317
- };
1318
- }
1319
- const qs = /^[A-Z]:\/$/i, Xs = vt ? (t) => qs.test(t) : (t) => t === "/";
1320
- function It(t, s, e) {
1321
- if (t === s || s.startsWith(`${t}/`)) {
1322
- if (e) {
1323
- const o = Xs(t) ? t.length : t.length + 1;
1324
- return (r, c) => r.slice(o, c ? -1 : void 0) || ".";
1325
- }
1326
- const n = s.slice(t.length + 1);
1327
- return n ? (o, r) => {
1328
- if (o === ".") return n;
1329
- const c = `${n}/${o}`;
1330
- return r ? c.slice(0, -1) : c;
1331
- } : (o, r) => r && o !== "." ? o.slice(0, -1) : o;
1332
- }
1333
- return e ? (n) => V.relative(t, n) || "." : (n) => V.relative(t, `${s}/${n}`) || ".";
1334
- }
1335
- function Qs(t, s) {
1336
- if (s.startsWith(`${t}/`)) {
1337
- const e = s.slice(t.length + 1);
1338
- return (n) => `${e}/${n}`;
1339
- }
1340
- return (e) => {
1341
- const n = V.relative(t, `${s}/${e}`);
1342
- return e.endsWith("/") && n !== "" ? `${n}/` : n || ".";
1343
- };
1344
- }
1345
- const js = { parts: !0 };
1346
- function ee(t) {
1347
- var s;
1348
- const e = nt.scan(t, js);
1349
- return !((s = e.parts) === null || s === void 0) && s.length ? e.parts : [t];
1350
- }
1351
- const zs = /\\(?![()[\]{}!+@])/g;
1352
- function Ys(t) {
1353
- return se(t);
1354
- }
1355
- function Zs(t) {
1356
- return ne(t).replace(zs, "/");
1357
- }
1358
- const fn = vt ? Zs : Ys, Vs = new RegExp("(?<!\\\\)([()[\\]{}*?|]|^!|[!+@](?=\\()|\\\\(?![()[\\]{}!*+?@|]))", "g"), Js = new RegExp("(?<!\\\\)([()[\\]{}]|^!|[!+@](?=\\())", "g"), se = (t) => t.replace(Vs, "\\$&"), ne = (t) => t.replace(Js, "\\$&"), tn = vt ? ne : se;
1359
- function en(t, s) {
1360
- if ((s == null ? void 0 : s.caseSensitiveMatch) === !1) return !0;
1361
- const e = nt.scan(t);
1362
- return e.isGlob || e.negated;
1363
- }
1364
- function et(...t) {
1365
- console.log(`[tinyglobby ${(/* @__PURE__ */ new Date()).toLocaleTimeString("es")}]`, ...t);
1366
- }
1367
- const sn = /^(\/?\.\.)+/, nn = /\\(?=[()[\]{}!*+?@|])/g, at = /\\/g;
1368
- function Et(t, s, e, n, o) {
1369
- let r = t;
1370
- t.endsWith("/") && (r = t.slice(0, -1)), !r.endsWith("*") && s && (r += "/**");
1371
- const c = tn(e);
1372
- Nt.isAbsolute(r.replace(nn, "")) ? r = V.relative(c, r) : r = V.normalize(r);
1373
- const l = sn.exec(r), h = ee(r);
1374
- if (l != null && l[0]) {
1375
- const g = (l[0].length + 1) / 3;
1376
- let E = 0;
1377
- const A = c.split("/");
1378
- for (; E < g && h[E + g] === A[A.length + E - g]; )
1379
- r = r.slice(0, (g - E - 1) * 3) + r.slice((g - E) * 3 + h[E + g].length + 1) || ".", E++;
1380
- const b = V.join(e, l[0].slice(E * 3));
1381
- !b.startsWith(".") && n.root.length > b.length && (n.root = b, n.depthOffset = -g + E);
1382
- }
1383
- if (!o && n.depthOffset >= 0) {
1384
- var R;
1385
- (R = n.commonPath) !== null && R !== void 0 || (n.commonPath = h);
1386
- const g = [], E = Math.min(n.commonPath.length, h.length);
1387
- for (let A = 0; A < E; A++) {
1388
- const b = h[A];
1389
- if (b === "**" && !h[A + 1]) {
1390
- g.pop();
1391
- break;
1392
- }
1393
- if (b !== n.commonPath[A] || en(b) || A === h.length - 1) break;
1394
- g.push(b);
1395
- }
1396
- n.depthOffset = g.length, n.commonPath = g, n.root = g.length > 0 ? V.join(e, ...g) : e;
1397
- }
1398
- return r;
1399
- }
1400
- function rn({ patterns: t = ["**/*"], ignore: s = [], expandDirectories: e = !0 }, n, o) {
1401
- typeof t == "string" && (t = [t]), typeof s == "string" && (s = [s]);
1402
- const r = [], c = [];
1403
- for (const l of s)
1404
- l && (l[0] !== "!" || l[1] === "(") && c.push(Et(l, e, n, o, !0));
1405
- for (const l of t)
1406
- l && (l[0] !== "!" || l[1] === "(" ? r.push(Et(l, e, n, o, !1)) : (l[1] !== "!" || l[2] === "(") && c.push(Et(l.slice(1), e, n, o, !0)));
1407
- return {
1408
- match: r,
1409
- ignore: c
1410
- };
1411
- }
1412
- function re(t, s) {
1413
- for (let e = t.length - 1; e >= 0; e--) {
1414
- const n = t[e];
1415
- t[e] = s(n);
1416
- }
1417
- return t;
1418
- }
1419
- function on(t) {
1420
- return t ? t instanceof URL ? Ae(t).replace(at, "/") : Nt.resolve(t).replace(at, "/") : process.cwd().replace(at, "/");
1421
- }
1422
- function oe(t, s = {}) {
1423
- const e = process.env.TINYGLOBBY_DEBUG ? {
1424
- ...s,
1425
- debug: !0
1426
- } : s, n = on(e.cwd);
1427
- if (e.debug && et("globbing with:", {
1428
- patterns: t,
1429
- options: e,
1430
- cwd: n
1431
- }), Array.isArray(t) && t.length === 0) return [{
1432
- sync: () => [],
1433
- withPromise: async () => []
1434
- }, !1];
1435
- const o = {
1436
- root: n,
1437
- commonPath: null,
1438
- depthOffset: 0
1439
- }, r = rn({
1440
- ...e,
1441
- patterns: t
1442
- }, n, o);
1443
- e.debug && et("internal processing patterns:", r);
1444
- const c = {
1445
- dot: e.dot,
1446
- nobrace: e.braceExpansion === !1,
1447
- nocase: e.caseSensitiveMatch === !1,
1448
- noextglob: e.extglob === !1,
1449
- noglobstar: e.globstar === !1,
1450
- posix: !0
1451
- }, l = nt(r.match, {
1452
- ...c,
1453
- ignore: r.ignore
1454
- }), h = nt(r.ignore, c), R = Ks(r.match, c), g = It(n, o.root, e.absolute), E = e.absolute ? g : It(n, o.root, !0), A = {
1455
- filters: [e.debug ? ($, x) => {
1456
- const w = g($, x), y = l(w);
1457
- return y && et(`matched ${w}`), y;
1458
- } : ($, x) => l(g($, x))],
1459
- exclude: e.debug ? ($, x) => {
1460
- const w = E(x, !0), y = w !== "." && !R(w) || h(w);
1461
- return et(y ? `skipped ${x}` : `crawling ${x}`), y;
1462
- } : ($, x) => {
1463
- const w = E(x, !0);
1464
- return w !== "." && !R(w) || h(w);
1465
- },
1466
- fs: e.fs ? {
1467
- readdir: e.fs.readdir || J.readdir,
1468
- readdirSync: e.fs.readdirSync || J.readdirSync,
1469
- realpath: e.fs.realpath || J.realpath,
1470
- realpathSync: e.fs.realpathSync || J.realpathSync,
1471
- stat: e.fs.stat || J.stat,
1472
- statSync: e.fs.statSync || J.statSync
1473
- } : void 0,
1474
- pathSeparator: "/",
1475
- relativePaths: !0,
1476
- resolveSymlinks: !0,
1477
- signal: e.signal
1478
- };
1479
- e.deep !== void 0 && (A.maxDepth = Math.round(e.deep - o.depthOffset)), e.absolute && (A.relativePaths = !1, A.resolvePaths = !0, A.includeBasePath = !0), e.followSymbolicLinks === !1 && (A.resolveSymlinks = !1, A.excludeSymlinks = !0), e.onlyDirectories ? (A.excludeFiles = !0, A.includeDirs = !0) : e.onlyFiles === !1 && (A.includeDirs = !0), o.root = o.root.replace(at, "");
1480
- const b = o.root;
1481
- e.debug && et("internal properties:", o);
1482
- const d = n !== b && !e.absolute && Qs(n, o.root);
1483
- return [new ls(A).crawl(b), d];
1484
- }
1485
- async function hn(t, s) {
1486
- if (t && (s != null && s.patterns)) throw new Error("Cannot pass patterns as both an argument and an option");
1487
- const e = te(t) || typeof t == "string", n = e ? s : t, o = e ? t : t.patterns, [r, c] = oe(o, n);
1488
- return c ? re(await r.withPromise(), c) : r.withPromise();
1489
- }
1490
- function gn(t, s) {
1491
- if (t && (s != null && s.patterns)) throw new Error("Cannot pass patterns as both an argument and an option");
1492
- const e = te(t) || typeof t == "string", n = e ? s : t, o = e ? t : t.patterns, [r, c] = oe(o, n);
1493
- return c ? re(r.sync(), c) : r.sync();
1494
- }
1495
- export {
1496
- fn as convertPathToPattern,
1497
- tn as escapePath,
1498
- hn as glob,
1499
- gn as globSync,
1500
- en as isDynamicPattern
1501
- };