bun-plugin-dtsx 0.21.0 → 0.21.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/index.js +2137 -1146
  2. package/package.json +4 -14
  3. package/dist/index.d.ts +0 -8
package/dist/index.js CHANGED
@@ -1,303 +1,298 @@
1
1
  // @bun
2
- // src/index.ts
3
- import process2 from "process";
4
-
5
2
  // node_modules/@stacksjs/dtsx/dist/index.js
6
- import { existsSync as Aq } from "fs";
7
- import { resolve as xq } from "path";
8
- import I1 from "process";
9
- import { readdir as _q, readFile as Rq } from "fs/promises";
10
- import { extname as Eq, join as g1 } from "path";
11
- import Sq from "process";
12
- import { readFile as gq } from "fs/promises";
13
- import { mkdir as kZ, rm as vZ } from "fs/promises";
14
- import { dirname as mZ, join as uZ, parse as hZ, relative as dZ } from "path";
15
- import Nq, { posix as N1 } from "path";
16
- var Lq = Object.create;
17
- var { getPrototypeOf: Pq, defineProperty: b1, getOwnPropertyNames: Tq } = Object;
18
- var Oq = Object.prototype.hasOwnProperty;
19
- var X1 = (q, Z, $) => {
20
- $ = q != null ? Lq(Pq(q)) : {};
21
- let J = Z || !q || !q.__esModule ? b1($, "default", { value: q, enumerable: true }) : $;
22
- for (let j of Tq(q))
23
- if (!Oq.call(J, j))
24
- b1(J, j, { get: () => q[j], enumerable: true });
25
- return J;
3
+ import l1 from "process";
4
+ import { resolve as nq } from "path";
5
+ import rq from "process";
6
+ import { mkdir as hZ, rm as uZ } from "fs/promises";
7
+ import { dirname as mZ, join as dZ, parse as cZ, relative as lZ } from "path";
8
+ import Dq, { posix as I1 } from "path";
9
+ import { readdir as vZ } from "fs/promises";
10
+ import { extname as gZ, join as hq } from "path";
11
+ var lq = Object.create;
12
+ var { getPrototypeOf: pq, defineProperty: d1, getOwnPropertyNames: iq } = Object;
13
+ var sq = Object.prototype.hasOwnProperty;
14
+ var K1 = (q, $, J) => {
15
+ J = q != null ? lq(pq(q)) : {};
16
+ let Z = $ || !q || !q.__esModule ? d1(J, "default", { value: q, enumerable: true }) : J;
17
+ for (let Y of iq(q))
18
+ if (!sq.call(Z, Y))
19
+ d1(Z, Y, { get: () => q[Y], enumerable: true });
20
+ return Z;
26
21
  };
27
- var _ = (q, Z) => () => (Z || q((Z = { exports: {} }).exports, Z), Z.exports);
28
- var f1 = _((c1) => {
29
- Object.defineProperty(c1, "__esModule", { value: true });
30
- c1.normalizePath = c1.convertSlashes = c1.cleanPath = undefined;
31
- var D1 = import.meta.require("path");
32
- function d1(q) {
33
- let Z = D1.normalize(q);
34
- if (Z.length > 1 && Z[Z.length - 1] === D1.sep)
35
- Z = Z.substring(0, Z.length - 1);
36
- return Z;
22
+ var y = (q, $) => () => ($ || q(($ = { exports: {} }).exports, $), $.exports);
23
+ var A1 = y((Q0) => {
24
+ Object.defineProperty(Q0, "__esModule", { value: true });
25
+ Q0.normalizePath = Q0.convertSlashes = Q0.cleanPath = undefined;
26
+ var E1 = import.meta.require("path");
27
+ function j0(q) {
28
+ let $ = E1.normalize(q);
29
+ if ($.length > 1 && $[$.length - 1] === E1.sep)
30
+ $ = $.substring(0, $.length - 1);
31
+ return $;
37
32
  }
38
- c1.cleanPath = d1;
39
- var kq = /[\\/]/g;
40
- function l1(q, Z) {
41
- return q.replace(kq, Z);
33
+ Q0.cleanPath = j0;
34
+ var v$ = /[\\/]/g;
35
+ function X0(q, $) {
36
+ return q.replace(v$, $);
42
37
  }
43
- c1.convertSlashes = l1;
44
- function vq(q, Z) {
45
- let { resolvePaths: $, normalizePath: J, pathSeparator: j } = Z, z = process.platform === "win32" && q.includes("/") || q.startsWith(".");
46
- if ($)
47
- q = D1.resolve(q);
48
- if (J || z)
49
- q = d1(q);
38
+ Q0.convertSlashes = X0;
39
+ function g$(q, $) {
40
+ let { resolvePaths: J, normalizePath: Z, pathSeparator: Y } = $, j = process.platform === "win32" && q.includes("/") || q.startsWith(".");
41
+ if (J)
42
+ q = E1.resolve(q);
43
+ if (Z || j)
44
+ q = j0(q);
50
45
  if (q === ".")
51
46
  return "";
52
- let U = q[q.length - 1] !== j;
53
- return l1(U ? q + j : q, j);
47
+ let Q = q[q.length - 1] !== Y;
48
+ return X0(Q ? q + Y : q, Y);
54
49
  }
55
- c1.normalizePath = vq;
50
+ Q0.normalizePath = g$;
56
51
  });
57
- var a1 = _((r1) => {
58
- Object.defineProperty(r1, "__esModule", { value: true });
59
- r1.build = r1.joinDirectoryPath = r1.joinPathWithBasePath = undefined;
60
- var hq = import.meta.require("path"), dq = f1();
61
- function n1(q, Z) {
62
- return Z + q;
63
- }
64
- r1.joinPathWithBasePath = n1;
65
- function lq(q, Z) {
66
- return function($, J) {
67
- if (J.startsWith(q))
68
- return J.replace(q, "") + $;
52
+ var K0 = y((G0) => {
53
+ Object.defineProperty(G0, "__esModule", { value: true });
54
+ G0.build = G0.joinDirectoryPath = G0.joinPathWithBasePath = undefined;
55
+ var m$ = import.meta.require("path"), d$ = A1();
56
+ function z0(q, $) {
57
+ return $ + q;
58
+ }
59
+ G0.joinPathWithBasePath = z0;
60
+ function c$(q, $) {
61
+ return function(J, Z) {
62
+ if (Z.startsWith(q))
63
+ return Z.replace(q, "") + J;
69
64
  else
70
- return dq.convertSlashes(hq.relative(q, J), Z.pathSeparator) + Z.pathSeparator + $;
65
+ return d$.convertSlashes(m$.relative(q, Z), $.pathSeparator) + $.pathSeparator + J;
71
66
  };
72
67
  }
73
- function cq(q) {
68
+ function l$(q) {
74
69
  return q;
75
70
  }
76
- function iq(q, Z, $) {
77
- return Z + q + $;
71
+ function p$(q, $, J) {
72
+ return $ + q + J;
78
73
  }
79
- r1.joinDirectoryPath = iq;
80
- function nq(q, Z) {
81
- let { relativePaths: $, includeBasePath: J } = Z;
82
- return $ && q ? lq(q, Z) : J ? n1 : cq;
74
+ G0.joinDirectoryPath = p$;
75
+ function i$(q, $) {
76
+ let { relativePaths: J, includeBasePath: Z } = $;
77
+ return J && q ? c$(q, $) : Z ? z0 : l$;
83
78
  }
84
- r1.build = nq;
79
+ G0.build = i$;
85
80
  });
86
- var e1 = _((s1) => {
87
- Object.defineProperty(s1, "__esModule", { value: true });
88
- s1.build = undefined;
89
- function aq(q) {
90
- return function(Z, $) {
91
- $.push(Z.substring(q.length) || ".");
81
+ var M0 = y((B0) => {
82
+ Object.defineProperty(B0, "__esModule", { value: true });
83
+ B0.build = undefined;
84
+ function r$(q) {
85
+ return function($, J) {
86
+ J.push($.substring(q.length) || ".");
92
87
  };
93
88
  }
94
- function sq(q) {
95
- return function(Z, $, J) {
96
- let j = Z.substring(q.length) || ".";
97
- if (J.every((z) => z(j, true)))
98
- $.push(j);
89
+ function o$(q) {
90
+ return function($, J, Z) {
91
+ let Y = $.substring(q.length) || ".";
92
+ if (Z.every((j) => j(Y, true)))
93
+ J.push(Y);
99
94
  };
100
95
  }
101
- var oq = (q, Z) => {
102
- Z.push(q || ".");
103
- }, eq = (q, Z, $) => {
104
- let J = q || ".";
105
- if ($.every((j) => j(J, true)))
106
- Z.push(J);
107
- }, tq = () => {
96
+ var a$ = (q, $) => {
97
+ $.push(q || ".");
98
+ }, t$ = (q, $, J) => {
99
+ let Z = q || ".";
100
+ if (J.every((Y) => Y(Z, true)))
101
+ $.push(Z);
102
+ }, e$ = () => {
108
103
  };
109
- function q$(q, Z) {
110
- let { includeDirs: $, filters: J, relativePaths: j } = Z;
111
- if (!$)
112
- return tq;
113
- if (j)
114
- return J && J.length ? sq(q) : aq(q);
115
- return J && J.length ? eq : oq;
116
- }
117
- s1.build = q$;
104
+ function qJ(q, $) {
105
+ let { includeDirs: J, filters: Z, relativePaths: Y } = $;
106
+ if (!J)
107
+ return e$;
108
+ if (Y)
109
+ return Z && Z.length ? o$(q) : r$(q);
110
+ return Z && Z.length ? t$ : a$;
111
+ }
112
+ B0.build = qJ;
118
113
  });
119
- var $0 = _((t1) => {
120
- Object.defineProperty(t1, "__esModule", { value: true });
121
- t1.build = undefined;
122
- var $$ = (q, Z, $, J) => {
123
- if (J.every((j) => j(q, false)))
124
- $.files++;
125
- }, Z$ = (q, Z, $, J) => {
126
- if (J.every((j) => j(q, false)))
127
- Z.push(q);
128
- }, J$ = (q, Z, $, J) => {
129
- $.files++;
130
- }, j$ = (q, Z) => {
131
- Z.push(q);
132
- }, V$ = () => {
114
+ var H0 = y((V0) => {
115
+ Object.defineProperty(V0, "__esModule", { value: true });
116
+ V0.build = undefined;
117
+ var $J = (q, $, J, Z) => {
118
+ if (Z.every((Y) => Y(q, false)))
119
+ J.files++;
120
+ }, JJ = (q, $, J, Z) => {
121
+ if (Z.every((Y) => Y(q, false)))
122
+ $.push(q);
123
+ }, ZJ = (q, $, J, Z) => {
124
+ J.files++;
125
+ }, YJ = (q, $) => {
126
+ $.push(q);
127
+ }, jJ = () => {
133
128
  };
134
- function Y$(q) {
135
- let { excludeFiles: Z, filters: $, onlyCounts: J } = q;
136
- if (Z)
137
- return V$;
138
- if ($ && $.length)
139
- return J ? $$ : Z$;
140
- else if (J)
141
- return J$;
129
+ function XJ(q) {
130
+ let { excludeFiles: $, filters: J, onlyCounts: Z } = q;
131
+ if ($)
132
+ return jJ;
133
+ if (J && J.length)
134
+ return Z ? $J : JJ;
135
+ else if (Z)
136
+ return ZJ;
142
137
  else
143
- return j$;
138
+ return YJ;
144
139
  }
145
- t1.build = Y$;
140
+ V0.build = XJ;
146
141
  });
147
- var j0 = _((Z0) => {
148
- Object.defineProperty(Z0, "__esModule", { value: true });
149
- Z0.build = undefined;
150
- var W$ = (q) => {
142
+ var _0 = y((I0) => {
143
+ Object.defineProperty(I0, "__esModule", { value: true });
144
+ I0.build = undefined;
145
+ var QJ = (q) => {
151
146
  return q;
152
- }, z$ = () => {
147
+ }, UJ = () => {
153
148
  return [""].slice(0, 0);
154
149
  };
155
- function U$(q) {
156
- return q.group ? z$ : W$;
150
+ function zJ(q) {
151
+ return q.group ? UJ : QJ;
157
152
  }
158
- Z0.build = U$;
153
+ I0.build = zJ;
159
154
  });
160
- var W0 = _((V0) => {
161
- Object.defineProperty(V0, "__esModule", { value: true });
162
- V0.build = undefined;
163
- var X$ = (q, Z, $) => {
164
- q.push({ directory: Z, files: $, dir: Z });
165
- }, B$ = () => {
155
+ var P0 = y((O0) => {
156
+ Object.defineProperty(O0, "__esModule", { value: true });
157
+ O0.build = undefined;
158
+ var GJ = (q, $, J) => {
159
+ q.push({ directory: $, files: J, dir: $ });
160
+ }, FJ = () => {
166
161
  };
167
- function Q$(q) {
168
- return q.group ? X$ : B$;
162
+ function KJ(q) {
163
+ return q.group ? GJ : FJ;
169
164
  }
170
- V0.build = Q$;
165
+ O0.build = KJ;
171
166
  });
172
- var X0 = _((t) => {
173
- var F$ = t && t.__importDefault || function(q) {
167
+ var A0 = y((J1) => {
168
+ var BJ = J1 && J1.__importDefault || function(q) {
174
169
  return q && q.__esModule ? q : { default: q };
175
170
  };
176
- Object.defineProperty(t, "__esModule", { value: true });
177
- t.build = undefined;
178
- var F1 = F$(import.meta.require("fs")), z0 = import.meta.require("path"), K$ = function(q, Z, $) {
179
- let { queue: J, options: { suppressErrors: j } } = Z;
180
- J.enqueue(), F1.default.realpath(q, (z, U) => {
181
- if (z)
182
- return J.dequeue(j ? null : z, Z);
183
- F1.default.stat(U, (B, M) => {
184
- if (B)
185
- return J.dequeue(j ? null : B, Z);
186
- if (M.isDirectory() && U0(q, U, Z))
187
- return J.dequeue(null, Z);
188
- $(M, U), J.dequeue(null, Z);
171
+ Object.defineProperty(J1, "__esModule", { value: true });
172
+ J1.build = undefined;
173
+ var M1 = BJ(import.meta.require("fs")), f0 = import.meta.require("path"), wJ = function(q, $, J) {
174
+ let { queue: Z, options: { suppressErrors: Y } } = $;
175
+ Z.enqueue(), M1.default.realpath(q, (j, Q) => {
176
+ if (j)
177
+ return Z.dequeue(Y ? null : j, $);
178
+ M1.default.stat(Q, (X, U) => {
179
+ if (X)
180
+ return Z.dequeue(Y ? null : X, $);
181
+ if (U.isDirectory() && E0(q, Q, $))
182
+ return Z.dequeue(null, $);
183
+ J(U, Q), Z.dequeue(null, $);
189
184
  });
190
185
  });
191
- }, G$ = function(q, Z, $) {
192
- let { queue: J, options: { suppressErrors: j } } = Z;
193
- J.enqueue();
186
+ }, MJ = function(q, $, J) {
187
+ let { queue: Z, options: { suppressErrors: Y } } = $;
188
+ Z.enqueue();
194
189
  try {
195
- let z = F1.default.realpathSync(q), U = F1.default.statSync(z);
196
- if (U.isDirectory() && U0(q, z, Z))
190
+ let j = M1.default.realpathSync(q), Q = M1.default.statSync(j);
191
+ if (Q.isDirectory() && E0(q, j, $))
197
192
  return;
198
- $(U, z);
199
- } catch (z) {
200
- if (!j)
201
- throw z;
193
+ J(Q, j);
194
+ } catch (j) {
195
+ if (!Y)
196
+ throw j;
202
197
  }
203
198
  };
204
- function M$(q, Z) {
199
+ function VJ(q, $) {
205
200
  if (!q.resolveSymlinks || q.excludeSymlinks)
206
201
  return null;
207
- return Z ? G$ : K$;
208
- }
209
- t.build = M$;
210
- function U0(q, Z, $) {
211
- if ($.options.useRealPaths)
212
- return N$(Z, $);
213
- let J = z0.dirname(q), j = 1;
214
- while (J !== $.root && j < 2) {
215
- let z = $.symlinks.get(J);
216
- if (!!z && (z === Z || z.startsWith(Z) || Z.startsWith(z)))
217
- j++;
202
+ return $ ? MJ : wJ;
203
+ }
204
+ J1.build = VJ;
205
+ function E0(q, $, J) {
206
+ if (J.options.useRealPaths)
207
+ return NJ($, J);
208
+ let Z = f0.dirname(q), Y = 1;
209
+ while (Z !== J.root && Y < 2) {
210
+ let j = J.symlinks.get(Z);
211
+ if (!!j && (j === $ || j.startsWith($) || $.startsWith(j)))
212
+ Y++;
218
213
  else
219
- J = z0.dirname(J);
214
+ Z = f0.dirname(Z);
220
215
  }
221
- return $.symlinks.set(q, Z), j > 1;
216
+ return J.symlinks.set(q, $), Y > 1;
222
217
  }
223
- function N$(q, Z) {
224
- return Z.visited.includes(q + Z.options.pathSeparator);
218
+ function NJ(q, $) {
219
+ return $.visited.includes(q + $.options.pathSeparator);
225
220
  }
226
221
  });
227
- var F0 = _((B0) => {
228
- Object.defineProperty(B0, "__esModule", { value: true });
229
- B0.build = undefined;
230
- var w$ = (q) => {
222
+ var x0 = y((T0) => {
223
+ Object.defineProperty(T0, "__esModule", { value: true });
224
+ T0.build = undefined;
225
+ var HJ = (q) => {
231
226
  return q.counts;
232
- }, y$ = (q) => {
227
+ }, IJ = (q) => {
233
228
  return q.groups;
234
- }, I$ = (q) => {
229
+ }, WJ = (q) => {
235
230
  return q.paths;
236
- }, D$ = (q) => {
231
+ }, _J = (q) => {
237
232
  return q.paths.slice(0, q.options.maxFiles);
238
- }, f$ = (q, Z, $) => {
239
- return K1(Z, $, q.counts, q.options.suppressErrors), null;
240
- }, H$ = (q, Z, $) => {
241
- return K1(Z, $, q.paths, q.options.suppressErrors), null;
242
- }, C$ = (q, Z, $) => {
243
- return K1(Z, $, q.paths.slice(0, q.options.maxFiles), q.options.suppressErrors), null;
244
- }, L$ = (q, Z, $) => {
245
- return K1(Z, $, q.groups, q.options.suppressErrors), null;
233
+ }, OJ = (q, $, J) => {
234
+ return V1($, J, q.counts, q.options.suppressErrors), null;
235
+ }, RJ = (q, $, J) => {
236
+ return V1($, J, q.paths, q.options.suppressErrors), null;
237
+ }, PJ = (q, $, J) => {
238
+ return V1($, J, q.paths.slice(0, q.options.maxFiles), q.options.suppressErrors), null;
239
+ }, fJ = (q, $, J) => {
240
+ return V1($, J, q.groups, q.options.suppressErrors), null;
246
241
  };
247
- function K1(q, Z, $, J) {
248
- if (q && !J)
249
- Z(q, $);
242
+ function V1(q, $, J, Z) {
243
+ if (q && !Z)
244
+ $(q, J);
250
245
  else
251
- Z(null, $);
246
+ $(null, J);
252
247
  }
253
- function P$(q, Z) {
254
- let { onlyCounts: $, group: J, maxFiles: j } = q;
255
- if ($)
256
- return Z ? w$ : f$;
257
- else if (J)
258
- return Z ? y$ : L$;
259
- else if (j)
260
- return Z ? D$ : C$;
248
+ function EJ(q, $) {
249
+ let { onlyCounts: J, group: Z, maxFiles: Y } = q;
250
+ if (J)
251
+ return $ ? HJ : OJ;
252
+ else if (Z)
253
+ return $ ? IJ : fJ;
254
+ else if (Y)
255
+ return $ ? _J : PJ;
261
256
  else
262
- return Z ? I$ : H$;
257
+ return $ ? WJ : RJ;
263
258
  }
264
- B0.build = P$;
259
+ T0.build = EJ;
265
260
  });
266
- var M0 = _((q1) => {
267
- var T$ = q1 && q1.__importDefault || function(q) {
261
+ var D0 = y((Z1) => {
262
+ var AJ = Z1 && Z1.__importDefault || function(q) {
268
263
  return q && q.__esModule ? q : { default: q };
269
264
  };
270
- Object.defineProperty(q1, "__esModule", { value: true });
271
- q1.build = undefined;
272
- var K0 = T$(import.meta.require("fs")), G0 = { withFileTypes: true }, O$ = (q, Z, $, J, j) => {
273
- if (J < 0)
265
+ Object.defineProperty(Z1, "__esModule", { value: true });
266
+ Z1.build = undefined;
267
+ var y0 = AJ(import.meta.require("fs")), C0 = { withFileTypes: true }, TJ = (q, $, J, Z, Y) => {
268
+ if (Z < 0)
274
269
  return q.queue.dequeue(null, q);
275
- q.visited.push(Z), q.counts.directories++, q.queue.enqueue(), K0.default.readdir(Z || ".", G0, (z, U = []) => {
276
- j(U, $, J), q.queue.dequeue(q.options.suppressErrors ? null : z, q);
270
+ q.visited.push($), q.counts.directories++, q.queue.enqueue(), y0.default.readdir($ || ".", C0, (j, Q = []) => {
271
+ Y(Q, J, Z), q.queue.dequeue(q.options.suppressErrors ? null : j, q);
277
272
  });
278
- }, _$ = (q, Z, $, J, j) => {
279
- if (J < 0)
273
+ }, SJ = (q, $, J, Z, Y) => {
274
+ if (Z < 0)
280
275
  return;
281
- q.visited.push(Z), q.counts.directories++;
282
- let z = [];
276
+ q.visited.push($), q.counts.directories++;
277
+ let j = [];
283
278
  try {
284
- z = K0.default.readdirSync(Z || ".", G0);
285
- } catch (U) {
279
+ j = y0.default.readdirSync($ || ".", C0);
280
+ } catch (Q) {
286
281
  if (!q.options.suppressErrors)
287
- throw U;
282
+ throw Q;
288
283
  }
289
- j(z, $, J);
284
+ Y(j, J, Z);
290
285
  };
291
- function R$(q) {
292
- return q ? _$ : O$;
286
+ function xJ(q) {
287
+ return q ? SJ : TJ;
293
288
  }
294
- q1.build = R$;
289
+ Z1.build = xJ;
295
290
  });
296
- var I0 = _((w0) => {
297
- Object.defineProperty(w0, "__esModule", { value: true });
298
- w0.Queue = undefined;
291
+ var v0 = y((L0) => {
292
+ Object.defineProperty(L0, "__esModule", { value: true });
293
+ L0.Queue = undefined;
299
294
 
300
- class N0 {
295
+ class k0 {
301
296
  onQueueEmpty;
302
297
  count = 0;
303
298
  constructor(q) {
@@ -306,18 +301,18 @@ var I0 = _((w0) => {
306
301
  enqueue() {
307
302
  this.count++;
308
303
  }
309
- dequeue(q, Z) {
304
+ dequeue(q, $) {
310
305
  if (--this.count <= 0 || q)
311
- this.onQueueEmpty(q, Z);
306
+ this.onQueueEmpty(q, $);
312
307
  }
313
308
  }
314
- w0.Queue = N0;
309
+ L0.Queue = k0;
315
310
  });
316
- var C0 = _((f0) => {
317
- Object.defineProperty(f0, "__esModule", { value: true });
318
- f0.Counter = undefined;
311
+ var m0 = y((h0) => {
312
+ Object.defineProperty(h0, "__esModule", { value: true });
313
+ h0.Counter = undefined;
319
314
 
320
- class D0 {
315
+ class g0 {
321
316
  _files = 0;
322
317
  _directories = 0;
323
318
  set files(q) {
@@ -336,42 +331,42 @@ var C0 = _((f0) => {
336
331
  return this._directories;
337
332
  }
338
333
  }
339
- f0.Counter = D0;
334
+ h0.Counter = g0;
340
335
  });
341
- var L1 = _((n) => {
342
- var E$ = n && n.__createBinding || (Object.create ? function(q, Z, $, J) {
343
- if (J === undefined)
344
- J = $;
345
- var j = Object.getOwnPropertyDescriptor(Z, $);
346
- if (!j || ("get" in j ? !Z.__esModule : j.writable || j.configurable))
347
- j = { enumerable: true, get: function() {
348
- return Z[$];
336
+ var x1 = y((i) => {
337
+ var yJ = i && i.__createBinding || (Object.create ? function(q, $, J, Z) {
338
+ if (Z === undefined)
339
+ Z = J;
340
+ var Y = Object.getOwnPropertyDescriptor($, J);
341
+ if (!Y || ("get" in Y ? !$.__esModule : Y.writable || Y.configurable))
342
+ Y = { enumerable: true, get: function() {
343
+ return $[J];
349
344
  } };
350
- Object.defineProperty(q, J, j);
351
- } : function(q, Z, $, J) {
352
- if (J === undefined)
353
- J = $;
354
- q[J] = Z[$];
355
- }), S$ = n && n.__setModuleDefault || (Object.create ? function(q, Z) {
356
- Object.defineProperty(q, "default", { enumerable: true, value: Z });
357
- } : function(q, Z) {
358
- q.default = Z;
359
- }), o = n && n.__importStar || function(q) {
345
+ Object.defineProperty(q, Z, Y);
346
+ } : function(q, $, J, Z) {
347
+ if (Z === undefined)
348
+ Z = J;
349
+ q[Z] = $[J];
350
+ }), CJ = i && i.__setModuleDefault || (Object.create ? function(q, $) {
351
+ Object.defineProperty(q, "default", { enumerable: true, value: $ });
352
+ } : function(q, $) {
353
+ q.default = $;
354
+ }), a = i && i.__importStar || function(q) {
360
355
  if (q && q.__esModule)
361
356
  return q;
362
- var Z = {};
357
+ var $ = {};
363
358
  if (q != null) {
364
- for (var $ in q)
365
- if ($ !== "default" && Object.prototype.hasOwnProperty.call(q, $))
366
- E$(Z, q, $);
359
+ for (var J in q)
360
+ if (J !== "default" && Object.prototype.hasOwnProperty.call(q, J))
361
+ yJ($, q, J);
367
362
  }
368
- return S$(Z, q), Z;
363
+ return CJ($, q), $;
369
364
  };
370
- Object.defineProperty(n, "__esModule", { value: true });
371
- n.Walker = undefined;
372
- var L0 = import.meta.require("path"), H1 = f1(), C1 = o(a1()), A$ = o(e1()), x$ = o($0()), b$ = o(j0()), g$ = o(W0()), k$ = o(X0()), v$ = o(F0()), m$ = o(M0()), u$ = I0(), h$ = C0();
365
+ Object.defineProperty(i, "__esModule", { value: true });
366
+ i.Walker = undefined;
367
+ var d0 = import.meta.require("path"), T1 = A1(), S1 = a(K0()), DJ = a(M0()), kJ = a(H0()), LJ = a(_0()), bJ = a(P0()), vJ = a(A0()), gJ = a(x0()), hJ = a(D0()), uJ = v0(), mJ = m0();
373
368
 
374
- class P0 {
369
+ class c0 {
375
370
  root;
376
371
  isSynchronous;
377
372
  state;
@@ -383,114 +378,114 @@ var L1 = _((n) => {
383
378
  resolveSymlink;
384
379
  walkDirectory;
385
380
  callbackInvoker;
386
- constructor(q, Z, $) {
387
- this.isSynchronous = !$, this.callbackInvoker = v$.build(Z, this.isSynchronous), this.root = H1.normalizePath(q, Z), this.state = { root: this.root.slice(0, -1), paths: [""].slice(0, 0), groups: [], counts: new h$.Counter, options: Z, queue: new u$.Queue((J, j) => this.callbackInvoker(j, J, $)), symlinks: new Map, visited: [""].slice(0, 0) }, this.joinPath = C1.build(this.root, Z), this.pushDirectory = A$.build(this.root, Z), this.pushFile = x$.build(Z), this.getArray = b$.build(Z), this.groupFiles = g$.build(Z), this.resolveSymlink = k$.build(Z, this.isSynchronous), this.walkDirectory = m$.build(this.isSynchronous);
381
+ constructor(q, $, J) {
382
+ this.isSynchronous = !J, this.callbackInvoker = gJ.build($, this.isSynchronous), this.root = T1.normalizePath(q, $), this.state = { root: this.root.slice(0, -1), paths: [""].slice(0, 0), groups: [], counts: new mJ.Counter, options: $, queue: new uJ.Queue((Z, Y) => this.callbackInvoker(Y, Z, J)), symlinks: new Map, visited: [""].slice(0, 0) }, this.joinPath = S1.build(this.root, $), this.pushDirectory = DJ.build(this.root, $), this.pushFile = kJ.build($), this.getArray = LJ.build($), this.groupFiles = bJ.build($), this.resolveSymlink = vJ.build($, this.isSynchronous), this.walkDirectory = hJ.build(this.isSynchronous);
388
383
  }
389
384
  start() {
390
385
  return this.walkDirectory(this.state, this.root, this.root, this.state.options.maxDepth, this.walk), this.isSynchronous ? this.callbackInvoker(this.state, null) : null;
391
386
  }
392
- walk = (q, Z, $) => {
393
- let { paths: J, options: { filters: j, resolveSymlinks: z, excludeSymlinks: U, exclude: B, maxFiles: M, signal: K, useRealPaths: F, pathSeparator: T } } = this.state;
394
- if (K && K.aborted || M && J.length > M)
387
+ walk = (q, $, J) => {
388
+ let { paths: Z, options: { filters: Y, resolveSymlinks: j, excludeSymlinks: Q, exclude: X, maxFiles: U, signal: z, useRealPaths: G, pathSeparator: V } } = this.state;
389
+ if (z && z.aborted || U && Z.length > U)
395
390
  return;
396
- this.pushDirectory(Z, J, j);
391
+ this.pushDirectory($, Z, Y);
397
392
  let H = this.getArray(this.state.paths);
398
- for (let P = 0;P < q.length; ++P) {
399
- let N = q[P];
400
- if (N.isFile() || N.isSymbolicLink() && !z && !U) {
401
- let G = this.joinPath(N.name, Z);
402
- this.pushFile(G, H, this.state.counts, j);
403
- } else if (N.isDirectory()) {
404
- let G = C1.joinDirectoryPath(N.name, Z, this.state.options.pathSeparator);
405
- if (B && B(N.name, G))
393
+ for (let W = 0;W < q.length; ++W) {
394
+ let I = q[W];
395
+ if (I.isFile() || I.isSymbolicLink() && !j && !Q) {
396
+ let _ = this.joinPath(I.name, $);
397
+ this.pushFile(_, H, this.state.counts, Y);
398
+ } else if (I.isDirectory()) {
399
+ let _ = S1.joinDirectoryPath(I.name, $, this.state.options.pathSeparator);
400
+ if (X && X(I.name, _))
406
401
  continue;
407
- this.walkDirectory(this.state, G, G, $ - 1, this.walk);
408
- } else if (N.isSymbolicLink() && this.resolveSymlink) {
409
- let G = C1.joinPathWithBasePath(N.name, Z);
410
- this.resolveSymlink(G, this.state, (h, C) => {
411
- if (h.isDirectory()) {
412
- if (C = H1.normalizePath(C, this.state.options), B && B(N.name, C))
402
+ this.walkDirectory(this.state, _, _, J - 1, this.walk);
403
+ } else if (I.isSymbolicLink() && this.resolveSymlink) {
404
+ let _ = S1.joinPathWithBasePath(I.name, $);
405
+ this.resolveSymlink(_, this.state, (S, E) => {
406
+ if (S.isDirectory()) {
407
+ if (E = T1.normalizePath(E, this.state.options), X && X(I.name, E))
413
408
  return;
414
- this.walkDirectory(this.state, C, F ? C : G + T, $ - 1, this.walk);
409
+ this.walkDirectory(this.state, E, G ? E : _ + V, J - 1, this.walk);
415
410
  } else {
416
- C = F ? C : G;
417
- let I = L0.basename(C), g = H1.normalizePath(L0.dirname(C), this.state.options);
418
- C = this.joinPath(I, g), this.pushFile(C, H, this.state.counts, j);
411
+ E = G ? E : _;
412
+ let A = d0.basename(E), m = T1.normalizePath(d0.dirname(E), this.state.options);
413
+ E = this.joinPath(A, m), this.pushFile(E, H, this.state.counts, Y);
419
414
  }
420
415
  });
421
416
  }
422
417
  }
423
- this.groupFiles(this.state.groups, Z, H);
418
+ this.groupFiles(this.state.groups, $, H);
424
419
  };
425
420
  }
426
- n.Walker = P0;
421
+ i.Walker = c0;
427
422
  });
428
- var R0 = _((O0) => {
429
- Object.defineProperty(O0, "__esModule", { value: true });
430
- O0.callback = O0.promise = undefined;
431
- var d$ = L1();
432
- function l$(q, Z) {
433
- return new Promise(($, J) => {
434
- T0(q, Z, (j, z) => {
435
- if (j)
436
- return J(j);
437
- $(z);
423
+ var s0 = y((p0) => {
424
+ Object.defineProperty(p0, "__esModule", { value: true });
425
+ p0.callback = p0.promise = undefined;
426
+ var dJ = x1();
427
+ function cJ(q, $) {
428
+ return new Promise((J, Z) => {
429
+ l0(q, $, (Y, j) => {
430
+ if (Y)
431
+ return Z(Y);
432
+ J(j);
438
433
  });
439
434
  });
440
435
  }
441
- O0.promise = l$;
442
- function T0(q, Z, $) {
443
- new d$.Walker(q, Z, $).start();
436
+ p0.promise = cJ;
437
+ function l0(q, $, J) {
438
+ new dJ.Walker(q, $, J).start();
444
439
  }
445
- O0.callback = T0;
440
+ p0.callback = l0;
446
441
  });
447
- var A0 = _((E0) => {
448
- Object.defineProperty(E0, "__esModule", { value: true });
449
- E0.sync = undefined;
450
- var i$ = L1();
451
- function n$(q, Z) {
452
- return new i$.Walker(q, Z).start();
453
- }
454
- E0.sync = n$;
442
+ var o0 = y((n0) => {
443
+ Object.defineProperty(n0, "__esModule", { value: true });
444
+ n0.sync = undefined;
445
+ var pJ = x1();
446
+ function iJ(q, $) {
447
+ return new pJ.Walker(q, $).start();
448
+ }
449
+ n0.sync = iJ;
455
450
  });
456
- var v0 = _((g0) => {
457
- Object.defineProperty(g0, "__esModule", { value: true });
458
- g0.APIBuilder = undefined;
459
- var x0 = R0(), r$ = A0();
451
+ var $q = y((e0) => {
452
+ Object.defineProperty(e0, "__esModule", { value: true });
453
+ e0.APIBuilder = undefined;
454
+ var a0 = s0(), sJ = o0();
460
455
 
461
- class b0 {
456
+ class t0 {
462
457
  root;
463
458
  options;
464
- constructor(q, Z) {
465
- this.root = q, this.options = Z;
459
+ constructor(q, $) {
460
+ this.root = q, this.options = $;
466
461
  }
467
462
  withPromise() {
468
- return x0.promise(this.root, this.options);
463
+ return a0.promise(this.root, this.options);
469
464
  }
470
465
  withCallback(q) {
471
- x0.callback(this.root, this.options, q);
466
+ a0.callback(this.root, this.options, q);
472
467
  }
473
468
  sync() {
474
- return r$.sync(this.root, this.options);
469
+ return sJ.sync(this.root, this.options);
475
470
  }
476
471
  }
477
- g0.APIBuilder = b0;
472
+ e0.APIBuilder = t0;
478
473
  });
479
- var J1 = _((y8, u0) => {
480
- var m0 = { DOT_LITERAL: "\\.", PLUS_LITERAL: "\\+", QMARK_LITERAL: "\\?", SLASH_LITERAL: "\\/", ONE_CHAR: "(?=.)", QMARK: "[^/]", END_ANCHOR: "(?:\\/|$)", DOTS_SLASH: "\\.{1,2}(?:\\/|$)", NO_DOT: "(?!\\.)", NO_DOTS: "(?!(?:^|\\/)\\.{1,2}(?:\\/|$))", NO_DOT_SLASH: "(?!\\.{0,1}(?:\\/|$))", NO_DOTS_SLASH: "(?!\\.{1,2}(?:\\/|$))", QMARK_NO_DOT: "[^.\\/]", STAR: "[^/]*?", START_ANCHOR: "(?:^|\\/)", SEP: "/" }, p$ = { ...m0, SLASH_LITERAL: "[\\\\/]", QMARK: "[^\\\\/]", STAR: "[^\\\\/]*?", DOTS_SLASH: "\\.{1,2}(?:[\\\\/]|$)", NO_DOT: "(?!\\.)", NO_DOTS: "(?!(?:^|[\\\\/])\\.{1,2}(?:[\\\\/]|$))", NO_DOT_SLASH: "(?!\\.{0,1}(?:[\\\\/]|$))", NO_DOTS_SLASH: "(?!\\.{1,2}(?:[\\\\/]|$))", QMARK_NO_DOT: "[^.\\\\/]", START_ANCHOR: "(?:^|[\\\\/])", END_ANCHOR: "(?:[\\\\/]|$)", SEP: "\\" }, a$ = { alnum: "a-zA-Z0-9", alpha: "a-zA-Z", ascii: "\\x00-\\x7F", blank: " \\t", cntrl: "\\x00-\\x1F\\x7F", digit: "0-9", graph: "\\x21-\\x7E", lower: "a-z", print: "\\x20-\\x7E ", punct: '\\-!"#$%&\'()\\*+,./:;<=>?@[\\]^_`{|}~', space: " \\t\\r\\n\\v\\f", upper: "A-Z", word: "A-Za-z0-9_", xdigit: "A-Fa-f0-9" };
481
- u0.exports = { MAX_LENGTH: 65536, POSIX_REGEX_SOURCE: a$, REGEX_BACKSLASH: /\\(?![*+?^${}(|)[\]])/g, REGEX_NON_SPECIAL_CHARS: /^[^@![\].,$*+?^{}()|\\/]+/, REGEX_SPECIAL_CHARS: /[-*+?.^${}(|)[\]]/, REGEX_SPECIAL_CHARS_BACKREF: /(\\?)((\W)(\3*))/g, REGEX_SPECIAL_CHARS_GLOBAL: /([-*+?.^${}(|)[\]])/g, REGEX_REMOVE_BACKSLASH: /(?:\[.*?[^\\]\]|\\(?=.))/g, REPLACEMENTS: { "***": "*", "**/**": "**", "**/**/**": "**" }, CHAR_0: 48, CHAR_9: 57, CHAR_UPPERCASE_A: 65, CHAR_LOWERCASE_A: 97, CHAR_UPPERCASE_Z: 90, CHAR_LOWERCASE_Z: 122, CHAR_LEFT_PARENTHESES: 40, CHAR_RIGHT_PARENTHESES: 41, CHAR_ASTERISK: 42, CHAR_AMPERSAND: 38, CHAR_AT: 64, CHAR_BACKWARD_SLASH: 92, CHAR_CARRIAGE_RETURN: 13, CHAR_CIRCUMFLEX_ACCENT: 94, CHAR_COLON: 58, CHAR_COMMA: 44, CHAR_DOT: 46, CHAR_DOUBLE_QUOTE: 34, CHAR_EQUAL: 61, CHAR_EXCLAMATION_MARK: 33, CHAR_FORM_FEED: 12, CHAR_FORWARD_SLASH: 47, CHAR_GRAVE_ACCENT: 96, CHAR_HASH: 35, CHAR_HYPHEN_MINUS: 45, CHAR_LEFT_ANGLE_BRACKET: 60, CHAR_LEFT_CURLY_BRACE: 123, CHAR_LEFT_SQUARE_BRACKET: 91, CHAR_LINE_FEED: 10, CHAR_NO_BREAK_SPACE: 160, CHAR_PERCENT: 37, CHAR_PLUS: 43, CHAR_QUESTION_MARK: 63, CHAR_RIGHT_ANGLE_BRACKET: 62, CHAR_RIGHT_CURLY_BRACE: 125, CHAR_RIGHT_SQUARE_BRACKET: 93, CHAR_SEMICOLON: 59, CHAR_SINGLE_QUOTE: 39, CHAR_SPACE: 32, CHAR_TAB: 9, CHAR_UNDERSCORE: 95, CHAR_VERTICAL_LINE: 124, CHAR_ZERO_WIDTH_NOBREAK_SPACE: 65279, extglobChars(q) {
474
+ var j1 = y((I8, Zq) => {
475
+ var Jq = { DOT_LITERAL: "\\.", PLUS_LITERAL: "\\+", QMARK_LITERAL: "\\?", SLASH_LITERAL: "\\/", ONE_CHAR: "(?=.)", QMARK: "[^/]", END_ANCHOR: "(?:\\/|$)", DOTS_SLASH: "\\.{1,2}(?:\\/|$)", NO_DOT: "(?!\\.)", NO_DOTS: "(?!(?:^|\\/)\\.{1,2}(?:\\/|$))", NO_DOT_SLASH: "(?!\\.{0,1}(?:\\/|$))", NO_DOTS_SLASH: "(?!\\.{1,2}(?:\\/|$))", QMARK_NO_DOT: "[^.\\/]", STAR: "[^/]*?", START_ANCHOR: "(?:^|\\/)", SEP: "/" }, nJ = { ...Jq, SLASH_LITERAL: "[\\\\/]", QMARK: "[^\\\\/]", STAR: "[^\\\\/]*?", DOTS_SLASH: "\\.{1,2}(?:[\\\\/]|$)", NO_DOT: "(?!\\.)", NO_DOTS: "(?!(?:^|[\\\\/])\\.{1,2}(?:[\\\\/]|$))", NO_DOT_SLASH: "(?!\\.{0,1}(?:[\\\\/]|$))", NO_DOTS_SLASH: "(?!\\.{1,2}(?:[\\\\/]|$))", QMARK_NO_DOT: "[^.\\\\/]", START_ANCHOR: "(?:^|[\\\\/])", END_ANCHOR: "(?:[\\\\/]|$)", SEP: "\\" }, rJ = { alnum: "a-zA-Z0-9", alpha: "a-zA-Z", ascii: "\\x00-\\x7F", blank: " \\t", cntrl: "\\x00-\\x1F\\x7F", digit: "0-9", graph: "\\x21-\\x7E", lower: "a-z", print: "\\x20-\\x7E ", punct: '\\-!"#$%&\'()\\*+,./:;<=>?@[\\]^_`{|}~', space: " \\t\\r\\n\\v\\f", upper: "A-Z", word: "A-Za-z0-9_", xdigit: "A-Fa-f0-9" };
476
+ Zq.exports = { MAX_LENGTH: 65536, POSIX_REGEX_SOURCE: rJ, REGEX_BACKSLASH: /\\(?![*+?^${}(|)[\]])/g, REGEX_NON_SPECIAL_CHARS: /^[^@![\].,$*+?^{}()|\\/]+/, REGEX_SPECIAL_CHARS: /[-*+?.^${}(|)[\]]/, REGEX_SPECIAL_CHARS_BACKREF: /(\\?)((\W)(\3*))/g, REGEX_SPECIAL_CHARS_GLOBAL: /([-*+?.^${}(|)[\]])/g, REGEX_REMOVE_BACKSLASH: /(?:\[.*?[^\\]\]|\\(?=.))/g, REPLACEMENTS: { "***": "*", "**/**": "**", "**/**/**": "**" }, CHAR_0: 48, CHAR_9: 57, CHAR_UPPERCASE_A: 65, CHAR_LOWERCASE_A: 97, CHAR_UPPERCASE_Z: 90, CHAR_LOWERCASE_Z: 122, CHAR_LEFT_PARENTHESES: 40, CHAR_RIGHT_PARENTHESES: 41, CHAR_ASTERISK: 42, CHAR_AMPERSAND: 38, CHAR_AT: 64, CHAR_BACKWARD_SLASH: 92, CHAR_CARRIAGE_RETURN: 13, CHAR_CIRCUMFLEX_ACCENT: 94, CHAR_COLON: 58, CHAR_COMMA: 44, CHAR_DOT: 46, CHAR_DOUBLE_QUOTE: 34, CHAR_EQUAL: 61, CHAR_EXCLAMATION_MARK: 33, CHAR_FORM_FEED: 12, CHAR_FORWARD_SLASH: 47, CHAR_GRAVE_ACCENT: 96, CHAR_HASH: 35, CHAR_HYPHEN_MINUS: 45, CHAR_LEFT_ANGLE_BRACKET: 60, CHAR_LEFT_CURLY_BRACE: 123, CHAR_LEFT_SQUARE_BRACKET: 91, CHAR_LINE_FEED: 10, CHAR_NO_BREAK_SPACE: 160, CHAR_PERCENT: 37, CHAR_PLUS: 43, CHAR_QUESTION_MARK: 63, CHAR_RIGHT_ANGLE_BRACKET: 62, CHAR_RIGHT_CURLY_BRACE: 125, CHAR_RIGHT_SQUARE_BRACKET: 93, CHAR_SEMICOLON: 59, CHAR_SINGLE_QUOTE: 39, CHAR_SPACE: 32, CHAR_TAB: 9, CHAR_UNDERSCORE: 95, CHAR_VERTICAL_LINE: 124, CHAR_ZERO_WIDTH_NOBREAK_SPACE: 65279, extglobChars(q) {
482
477
  return { "!": { type: "negate", open: "(?:(?!(?:", close: `))${q.STAR})` }, "?": { type: "qmark", open: "(?:", close: ")?" }, "+": { type: "plus", open: "(?:", close: ")+" }, "*": { type: "star", open: "(?:", close: ")*" }, "@": { type: "at", open: "(?:", close: ")" } };
483
478
  }, globChars(q) {
484
- return q === true ? p$ : m0;
479
+ return q === true ? nJ : Jq;
485
480
  } };
486
481
  });
487
- var j1 = _((qZ) => {
488
- var { REGEX_BACKSLASH: s$, REGEX_REMOVE_BACKSLASH: o$, REGEX_SPECIAL_CHARS: e$, REGEX_SPECIAL_CHARS_GLOBAL: t$ } = J1();
482
+ var X1 = y((qZ) => {
483
+ var { REGEX_BACKSLASH: oJ, REGEX_REMOVE_BACKSLASH: aJ, REGEX_SPECIAL_CHARS: tJ, REGEX_SPECIAL_CHARS_GLOBAL: eJ } = j1();
489
484
  qZ.isObject = (q) => q !== null && typeof q === "object" && !Array.isArray(q);
490
- qZ.hasRegexChars = (q) => e$.test(q);
485
+ qZ.hasRegexChars = (q) => tJ.test(q);
491
486
  qZ.isRegexChar = (q) => q.length === 1 && qZ.hasRegexChars(q);
492
- qZ.escapeRegex = (q) => q.replace(t$, "\\$1");
493
- qZ.toPosixSlashes = (q) => q.replace(s$, "/");
487
+ qZ.escapeRegex = (q) => q.replace(eJ, "\\$1");
488
+ qZ.toPosixSlashes = (q) => q.replace(oJ, "/");
494
489
  qZ.isWindows = () => {
495
490
  if (typeof navigator !== "undefined" && navigator.platform) {
496
491
  let q = navigator.platform.toLowerCase();
@@ -501,109 +496,109 @@ var j1 = _((qZ) => {
501
496
  return false;
502
497
  };
503
498
  qZ.removeBackslashes = (q) => {
504
- return q.replace(o$, (Z) => {
505
- return Z === "\\" ? "" : Z;
499
+ return q.replace(aJ, ($) => {
500
+ return $ === "\\" ? "" : $;
506
501
  });
507
502
  };
508
- qZ.escapeLast = (q, Z, $) => {
509
- let J = q.lastIndexOf(Z, $);
510
- if (J === -1)
503
+ qZ.escapeLast = (q, $, J) => {
504
+ let Z = q.lastIndexOf($, J);
505
+ if (Z === -1)
511
506
  return q;
512
- if (q[J - 1] === "\\")
513
- return qZ.escapeLast(q, Z, J - 1);
514
- return `${q.slice(0, J)}\\${q.slice(J)}`;
507
+ if (q[Z - 1] === "\\")
508
+ return qZ.escapeLast(q, $, Z - 1);
509
+ return `${q.slice(0, Z)}\\${q.slice(Z)}`;
515
510
  };
516
- qZ.removePrefix = (q, Z = {}) => {
517
- let $ = q;
518
- if ($.startsWith("./"))
519
- $ = $.slice(2), Z.prefix = "./";
520
- return $;
511
+ qZ.removePrefix = (q, $ = {}) => {
512
+ let J = q;
513
+ if (J.startsWith("./"))
514
+ J = J.slice(2), $.prefix = "./";
515
+ return J;
521
516
  };
522
- qZ.wrapOutput = (q, Z = {}, $ = {}) => {
523
- let J = $.contains ? "" : "^", j = $.contains ? "" : "$", z = `${J}(?:${q})${j}`;
524
- if (Z.negated === true)
525
- z = `(?:^(?!${z}).*$)`;
526
- return z;
517
+ qZ.wrapOutput = (q, $ = {}, J = {}) => {
518
+ let Z = J.contains ? "" : "^", Y = J.contains ? "" : "$", j = `${Z}(?:${q})${Y}`;
519
+ if ($.negated === true)
520
+ j = `(?:^(?!${j}).*$)`;
521
+ return j;
527
522
  };
528
- qZ.basename = (q, { windows: Z } = {}) => {
529
- let $ = q.split(Z ? /[\\/]/ : "/"), J = $[$.length - 1];
530
- if (J === "")
531
- return $[$.length - 2];
532
- return J;
523
+ qZ.basename = (q, { windows: $ } = {}) => {
524
+ let J = q.split($ ? /[\\/]/ : "/"), Z = J[J.length - 1];
525
+ if (Z === "")
526
+ return J[J.length - 2];
527
+ return Z;
533
528
  };
534
529
  });
535
- var s0 = _((D8, a0) => {
536
- var l0 = j1(), { CHAR_ASTERISK: P1, CHAR_AT: XZ, CHAR_BACKWARD_SLASH: V1, CHAR_COMMA: BZ, CHAR_DOT: T1, CHAR_EXCLAMATION_MARK: O1, CHAR_FORWARD_SLASH: p0, CHAR_LEFT_CURLY_BRACE: _1, CHAR_LEFT_PARENTHESES: R1, CHAR_LEFT_SQUARE_BRACKET: QZ, CHAR_PLUS: FZ, CHAR_QUESTION_MARK: c0, CHAR_RIGHT_CURLY_BRACE: KZ, CHAR_RIGHT_PARENTHESES: i0, CHAR_RIGHT_SQUARE_BRACKET: GZ } = J1(), n0 = (q) => {
537
- return q === p0 || q === V1;
538
- }, r0 = (q) => {
530
+ var Bq = y((_8, Kq) => {
531
+ var Xq = X1(), { CHAR_ASTERISK: y1, CHAR_AT: GZ, CHAR_BACKWARD_SLASH: Q1, CHAR_COMMA: FZ, CHAR_DOT: C1, CHAR_EXCLAMATION_MARK: D1, CHAR_FORWARD_SLASH: Fq, CHAR_LEFT_CURLY_BRACE: k1, CHAR_LEFT_PARENTHESES: L1, CHAR_LEFT_SQUARE_BRACKET: KZ, CHAR_PLUS: BZ, CHAR_QUESTION_MARK: Qq, CHAR_RIGHT_CURLY_BRACE: wZ, CHAR_RIGHT_PARENTHESES: Uq, CHAR_RIGHT_SQUARE_BRACKET: MZ } = j1(), zq = (q) => {
532
+ return q === Fq || q === Q1;
533
+ }, Gq = (q) => {
539
534
  if (q.isPrefix !== true)
540
535
  q.depth = q.isGlobstar ? 1 / 0 : 1;
541
- }, MZ = (q, Z) => {
542
- let $ = Z || {}, J = q.length - 1, j = $.parts === true || $.scanToEnd === true, z = [], U = [], B = [], M = q, K = -1, F = 0, T = 0, H = false, P = false, N = false, G = false, h = false, C = false, I = false, g = false, i = false, v = false, x = 0, m, w, y = { value: "", depth: 0, isGlob: false }, W = () => K >= J, d = () => M.charCodeAt(K + 1), b = () => {
543
- return m = w, M.charCodeAt(++K);
536
+ }, VZ = (q, $) => {
537
+ let J = $ || {}, Z = q.length - 1, Y = J.parts === true || J.scanToEnd === true, j = [], Q = [], X = [], U = q, z = -1, G = 0, V = 0, H = false, W = false, I = false, _ = false, S = false, E = false, A = false, m = false, t = false, h = false, g = 0, c, O, P = { value: "", depth: 0, isGlob: false }, B = () => z >= Z, d = () => U.charCodeAt(z + 1), b = () => {
538
+ return c = O, U.charCodeAt(++z);
544
539
  };
545
- while (K < J) {
546
- w = b();
547
- let L;
548
- if (w === V1) {
549
- if (I = y.backslashes = true, w = b(), w === _1)
550
- C = true;
540
+ while (z < Z) {
541
+ O = b();
542
+ let T;
543
+ if (O === Q1) {
544
+ if (A = P.backslashes = true, O = b(), O === k1)
545
+ E = true;
551
546
  continue;
552
547
  }
553
- if (C === true || w === _1) {
554
- x++;
555
- while (W() !== true && (w = b())) {
556
- if (w === V1) {
557
- I = y.backslashes = true, b();
548
+ if (E === true || O === k1) {
549
+ g++;
550
+ while (B() !== true && (O = b())) {
551
+ if (O === Q1) {
552
+ A = P.backslashes = true, b();
558
553
  continue;
559
554
  }
560
- if (w === _1) {
561
- x++;
555
+ if (O === k1) {
556
+ g++;
562
557
  continue;
563
558
  }
564
- if (C !== true && w === T1 && (w = b()) === T1) {
565
- if (H = y.isBrace = true, N = y.isGlob = true, v = true, j === true)
559
+ if (E !== true && O === C1 && (O = b()) === C1) {
560
+ if (H = P.isBrace = true, I = P.isGlob = true, h = true, Y === true)
566
561
  continue;
567
562
  break;
568
563
  }
569
- if (C !== true && w === BZ) {
570
- if (H = y.isBrace = true, N = y.isGlob = true, v = true, j === true)
564
+ if (E !== true && O === FZ) {
565
+ if (H = P.isBrace = true, I = P.isGlob = true, h = true, Y === true)
571
566
  continue;
572
567
  break;
573
568
  }
574
- if (w === KZ) {
575
- if (x--, x === 0) {
576
- C = false, H = y.isBrace = true, v = true;
569
+ if (O === wZ) {
570
+ if (g--, g === 0) {
571
+ E = false, H = P.isBrace = true, h = true;
577
572
  break;
578
573
  }
579
574
  }
580
575
  }
581
- if (j === true)
576
+ if (Y === true)
582
577
  continue;
583
578
  break;
584
579
  }
585
- if (w === p0) {
586
- if (z.push(K), U.push(y), y = { value: "", depth: 0, isGlob: false }, v === true)
580
+ if (O === Fq) {
581
+ if (j.push(z), Q.push(P), P = { value: "", depth: 0, isGlob: false }, h === true)
587
582
  continue;
588
- if (m === T1 && K === F + 1) {
589
- F += 2;
583
+ if (c === C1 && z === G + 1) {
584
+ G += 2;
590
585
  continue;
591
586
  }
592
- T = K + 1;
587
+ V = z + 1;
593
588
  continue;
594
589
  }
595
- if ($.noext !== true) {
596
- if ((w === FZ || w === XZ || w === P1 || w === c0 || w === O1) === true && d() === R1) {
597
- if (N = y.isGlob = true, G = y.isExtglob = true, v = true, w === O1 && K === F)
598
- i = true;
599
- if (j === true) {
600
- while (W() !== true && (w = b())) {
601
- if (w === V1) {
602
- I = y.backslashes = true, w = b();
590
+ if (J.noext !== true) {
591
+ if ((O === BZ || O === GZ || O === y1 || O === Qq || O === D1) === true && d() === L1) {
592
+ if (I = P.isGlob = true, _ = P.isExtglob = true, h = true, O === D1 && z === G)
593
+ t = true;
594
+ if (Y === true) {
595
+ while (B() !== true && (O = b())) {
596
+ if (O === Q1) {
597
+ A = P.backslashes = true, O = b();
603
598
  continue;
604
599
  }
605
- if (w === i0) {
606
- N = y.isGlob = true, v = true;
600
+ if (O === Uq) {
601
+ I = P.isGlob = true, h = true;
607
602
  break;
608
603
  }
609
604
  }
@@ -612,46 +607,46 @@ var s0 = _((D8, a0) => {
612
607
  break;
613
608
  }
614
609
  }
615
- if (w === P1) {
616
- if (m === P1)
617
- h = y.isGlobstar = true;
618
- if (N = y.isGlob = true, v = true, j === true)
610
+ if (O === y1) {
611
+ if (c === y1)
612
+ S = P.isGlobstar = true;
613
+ if (I = P.isGlob = true, h = true, Y === true)
619
614
  continue;
620
615
  break;
621
616
  }
622
- if (w === c0) {
623
- if (N = y.isGlob = true, v = true, j === true)
617
+ if (O === Qq) {
618
+ if (I = P.isGlob = true, h = true, Y === true)
624
619
  continue;
625
620
  break;
626
621
  }
627
- if (w === QZ) {
628
- while (W() !== true && (L = b())) {
629
- if (L === V1) {
630
- I = y.backslashes = true, b();
622
+ if (O === KZ) {
623
+ while (B() !== true && (T = b())) {
624
+ if (T === Q1) {
625
+ A = P.backslashes = true, b();
631
626
  continue;
632
627
  }
633
- if (L === GZ) {
634
- P = y.isBracket = true, N = y.isGlob = true, v = true;
628
+ if (T === MZ) {
629
+ W = P.isBracket = true, I = P.isGlob = true, h = true;
635
630
  break;
636
631
  }
637
632
  }
638
- if (j === true)
633
+ if (Y === true)
639
634
  continue;
640
635
  break;
641
636
  }
642
- if ($.nonegate !== true && w === O1 && K === F) {
643
- g = y.negated = true, F++;
637
+ if (J.nonegate !== true && O === D1 && z === G) {
638
+ m = P.negated = true, G++;
644
639
  continue;
645
640
  }
646
- if ($.noparen !== true && w === R1) {
647
- if (N = y.isGlob = true, j === true) {
648
- while (W() !== true && (w = b())) {
649
- if (w === R1) {
650
- I = y.backslashes = true, w = b();
641
+ if (J.noparen !== true && O === L1) {
642
+ if (I = P.isGlob = true, Y === true) {
643
+ while (B() !== true && (O = b())) {
644
+ if (O === L1) {
645
+ A = P.backslashes = true, O = b();
651
646
  continue;
652
647
  }
653
- if (w === i0) {
654
- v = true;
648
+ if (O === Uq) {
649
+ h = true;
655
650
  break;
656
651
  }
657
652
  }
@@ -659,687 +654,687 @@ var s0 = _((D8, a0) => {
659
654
  }
660
655
  break;
661
656
  }
662
- if (N === true) {
663
- if (v = true, j === true)
657
+ if (I === true) {
658
+ if (h = true, Y === true)
664
659
  continue;
665
660
  break;
666
661
  }
667
662
  }
668
- if ($.noext === true)
669
- G = false, N = false;
670
- let S = M, V = "", Y = "";
671
- if (F > 0)
672
- V = M.slice(0, F), M = M.slice(F), T -= F;
673
- if (S && N === true && T > 0)
674
- S = M.slice(0, T), Y = M.slice(T);
675
- else if (N === true)
676
- S = "", Y = M;
663
+ if (J.noext === true)
664
+ _ = false, I = false;
665
+ let k = U, F = "", K = "";
666
+ if (G > 0)
667
+ F = U.slice(0, G), U = U.slice(G), V -= G;
668
+ if (k && I === true && V > 0)
669
+ k = U.slice(0, V), K = U.slice(V);
670
+ else if (I === true)
671
+ k = "", K = U;
677
672
  else
678
- S = M;
679
- if (S && S !== "" && S !== "/" && S !== M) {
680
- if (n0(S.charCodeAt(S.length - 1)))
681
- S = S.slice(0, -1);
682
- }
683
- if ($.unescape === true) {
684
- if (Y)
685
- Y = l0.removeBackslashes(Y);
686
- if (S && I === true)
687
- S = l0.removeBackslashes(S);
688
- }
689
- let l = { prefix: V, input: q, start: F, base: S, glob: Y, isBrace: H, isBracket: P, isGlob: N, isExtglob: G, isGlobstar: h, negated: g, negatedExtglob: i };
690
- if ($.tokens === true) {
691
- if (l.maxDepth = 0, !n0(w))
692
- U.push(y);
693
- l.tokens = U;
694
- }
695
- if ($.parts === true || $.tokens === true) {
696
- let L;
697
- for (let R = 0;R < z.length; R++) {
698
- let p = L ? L + 1 : F, c = z[R], s = q.slice(p, c);
699
- if ($.tokens) {
700
- if (R === 0 && F !== 0)
701
- U[R].isPrefix = true, U[R].value = V;
673
+ k = U;
674
+ if (k && k !== "" && k !== "/" && k !== U) {
675
+ if (zq(k.charCodeAt(k.length - 1)))
676
+ k = k.slice(0, -1);
677
+ }
678
+ if (J.unescape === true) {
679
+ if (K)
680
+ K = Xq.removeBackslashes(K);
681
+ if (k && A === true)
682
+ k = Xq.removeBackslashes(k);
683
+ }
684
+ let l = { prefix: F, input: q, start: G, base: k, glob: K, isBrace: H, isBracket: W, isGlob: I, isExtglob: _, isGlobstar: S, negated: m, negatedExtglob: t };
685
+ if (J.tokens === true) {
686
+ if (l.maxDepth = 0, !zq(O))
687
+ Q.push(P);
688
+ l.tokens = Q;
689
+ }
690
+ if (J.parts === true || J.tokens === true) {
691
+ let T;
692
+ for (let C = 0;C < j.length; C++) {
693
+ let n = T ? T + 1 : G, p = j[C], o = q.slice(n, p);
694
+ if (J.tokens) {
695
+ if (C === 0 && G !== 0)
696
+ Q[C].isPrefix = true, Q[C].value = F;
702
697
  else
703
- U[R].value = s;
704
- r0(U[R]), l.maxDepth += U[R].depth;
698
+ Q[C].value = o;
699
+ Gq(Q[C]), l.maxDepth += Q[C].depth;
705
700
  }
706
- if (R !== 0 || s !== "")
707
- B.push(s);
708
- L = c;
701
+ if (C !== 0 || o !== "")
702
+ X.push(o);
703
+ T = p;
709
704
  }
710
- if (L && L + 1 < q.length) {
711
- let R = q.slice(L + 1);
712
- if (B.push(R), $.tokens)
713
- U[U.length - 1].value = R, r0(U[U.length - 1]), l.maxDepth += U[U.length - 1].depth;
705
+ if (T && T + 1 < q.length) {
706
+ let C = q.slice(T + 1);
707
+ if (X.push(C), J.tokens)
708
+ Q[Q.length - 1].value = C, Gq(Q[Q.length - 1]), l.maxDepth += Q[Q.length - 1].depth;
714
709
  }
715
- l.slashes = z, l.parts = B;
710
+ l.slashes = j, l.parts = X;
716
711
  }
717
712
  return l;
718
713
  };
719
- a0.exports = MZ;
714
+ Kq.exports = VZ;
720
715
  });
721
- var t0 = _((f8, e0) => {
722
- var G1 = J1(), r = j1(), { MAX_LENGTH: M1, POSIX_REGEX_SOURCE: NZ, REGEX_NON_SPECIAL_CHARS: wZ, REGEX_SPECIAL_CHARS_BACKREF: yZ, REPLACEMENTS: o0 } = G1, IZ = (q, Z) => {
723
- if (typeof Z.expandRange === "function")
724
- return Z.expandRange(...q, Z);
716
+ var Vq = y((O8, Mq) => {
717
+ var N1 = j1(), s = X1(), { MAX_LENGTH: H1, POSIX_REGEX_SOURCE: NZ, REGEX_NON_SPECIAL_CHARS: HZ, REGEX_SPECIAL_CHARS_BACKREF: IZ, REPLACEMENTS: wq } = N1, WZ = (q, $) => {
718
+ if (typeof $.expandRange === "function")
719
+ return $.expandRange(...q, $);
725
720
  q.sort();
726
- let $ = `[${q.join("-")}]`;
721
+ let J = `[${q.join("-")}]`;
727
722
  try {
728
- new RegExp($);
729
- } catch (J) {
730
- return q.map((j) => r.escapeRegex(j)).join("..");
723
+ new RegExp(J);
724
+ } catch (Z) {
725
+ return q.map((Y) => s.escapeRegex(Y)).join("..");
731
726
  }
732
- return $;
733
- }, $1 = (q, Z) => {
734
- return `Missing ${q}: "${Z}" - use "\\\\${Z}" to match literal characters`;
735
- }, E1 = (q, Z) => {
727
+ return J;
728
+ }, Y1 = (q, $) => {
729
+ return `Missing ${q}: "${$}" - use "\\\\${$}" to match literal characters`;
730
+ }, b1 = (q, $) => {
736
731
  if (typeof q !== "string")
737
732
  throw new TypeError("Expected a string");
738
- q = o0[q] || q;
739
- let $ = { ...Z }, J = typeof $.maxLength === "number" ? Math.min(M1, $.maxLength) : M1, j = q.length;
740
- if (j > J)
741
- throw new SyntaxError(`Input length: ${j}, exceeds maximum allowed length: ${J}`);
742
- let z = { type: "bos", value: "", output: $.prepend || "" }, U = [z], B = $.capture ? "" : "?:", M = G1.globChars($.windows), K = G1.extglobChars(M), { DOT_LITERAL: F, PLUS_LITERAL: T, SLASH_LITERAL: H, ONE_CHAR: P, DOTS_SLASH: N, NO_DOT: G, NO_DOT_SLASH: h, NO_DOTS_SLASH: C, QMARK: I, QMARK_NO_DOT: g, STAR: i, START_ANCHOR: v } = M, x = (Q) => {
743
- return `(${B}(?:(?!${v}${Q.dot ? N : F}).)*?)`;
744
- }, m = $.dot ? "" : G, w = $.dot ? I : g, y = $.bash === true ? x($) : i;
745
- if ($.capture)
746
- y = `(${y})`;
747
- if (typeof $.noext === "boolean")
748
- $.noextglob = $.noext;
749
- let W = { input: q, index: -1, start: 0, dot: $.dot === true, consumed: "", output: "", prefix: "", backtrack: false, negated: false, brackets: 0, braces: 0, parens: 0, quotes: 0, globstar: false, tokens: U };
750
- q = r.removePrefix(q, W), j = q.length;
751
- let d = [], b = [], S = [], V = z, Y, l = () => W.index === j - 1, L = W.peek = (Q = 1) => q[W.index + Q], R = W.advance = () => q[++W.index] || "", p = () => q.slice(W.index + 1), c = (Q = "", O = 0) => {
752
- W.consumed += Q, W.index += O;
753
- }, s = (Q) => {
754
- W.output += Q.output != null ? Q.output : Q.value, c(Q.value);
755
- }, Hq = () => {
756
- let Q = 1;
757
- while (L() === "!" && (L(2) !== "(" || L(3) === "?"))
758
- R(), W.start++, Q++;
759
- if (Q % 2 === 0)
733
+ q = wq[q] || q;
734
+ let J = { ...$ }, Z = typeof J.maxLength === "number" ? Math.min(H1, J.maxLength) : H1, Y = q.length;
735
+ if (Y > Z)
736
+ throw new SyntaxError(`Input length: ${Y}, exceeds maximum allowed length: ${Z}`);
737
+ let j = { type: "bos", value: "", output: J.prepend || "" }, Q = [j], X = J.capture ? "" : "?:", U = N1.globChars(J.windows), z = N1.extglobChars(U), { DOT_LITERAL: G, PLUS_LITERAL: V, SLASH_LITERAL: H, ONE_CHAR: W, DOTS_SLASH: I, NO_DOT: _, NO_DOT_SLASH: S, NO_DOTS_SLASH: E, QMARK: A, QMARK_NO_DOT: m, STAR: t, START_ANCHOR: h } = U, g = (N) => {
738
+ return `(${X}(?:(?!${h}${N.dot ? I : G}).)*?)`;
739
+ }, c = J.dot ? "" : _, O = J.dot ? A : m, P = J.bash === true ? g(J) : t;
740
+ if (J.capture)
741
+ P = `(${P})`;
742
+ if (typeof J.noext === "boolean")
743
+ J.noextglob = J.noext;
744
+ let B = { input: q, index: -1, start: 0, dot: J.dot === true, consumed: "", output: "", prefix: "", backtrack: false, negated: false, brackets: 0, braces: 0, parens: 0, quotes: 0, globstar: false, tokens: Q };
745
+ q = s.removePrefix(q, B), Y = q.length;
746
+ let d = [], b = [], k = [], F = j, K, l = () => B.index === Y - 1, T = B.peek = (N = 1) => q[B.index + N], C = B.advance = () => q[++B.index] || "", n = () => q.slice(B.index + 1), p = (N = "", x = 0) => {
747
+ B.consumed += N, B.index += x;
748
+ }, o = (N) => {
749
+ B.output += N.output != null ? N.output : N.value, p(N.value);
750
+ }, dq = () => {
751
+ let N = 1;
752
+ while (T() === "!" && (T(2) !== "(" || T(3) === "?"))
753
+ C(), B.start++, N++;
754
+ if (N % 2 === 0)
760
755
  return false;
761
- return W.negated = true, W.start++, true;
762
- }, W1 = (Q) => {
763
- W[Q]++, S.push(Q);
764
- }, e = (Q) => {
765
- W[Q]--, S.pop();
766
- }, f = (Q) => {
767
- if (V.type === "globstar") {
768
- let O = W.braces > 0 && (Q.type === "comma" || Q.type === "brace"), X = Q.extglob === true || d.length && (Q.type === "pipe" || Q.type === "paren");
769
- if (Q.type !== "slash" && Q.type !== "paren" && !O && !X)
770
- W.output = W.output.slice(0, -V.output.length), V.type = "star", V.value = "*", V.output = y, W.output += V.output;
756
+ return B.negated = true, B.start++, true;
757
+ }, z1 = (N) => {
758
+ B[N]++, k.push(N);
759
+ }, e = (N) => {
760
+ B[N]--, k.pop();
761
+ }, f = (N) => {
762
+ if (F.type === "globstar") {
763
+ let x = B.braces > 0 && (N.type === "comma" || N.type === "brace"), M = N.extglob === true || d.length && (N.type === "pipe" || N.type === "paren");
764
+ if (N.type !== "slash" && N.type !== "paren" && !x && !M)
765
+ B.output = B.output.slice(0, -F.output.length), F.type = "star", F.value = "*", F.output = P, B.output += F.output;
771
766
  }
772
- if (d.length && Q.type !== "paren")
773
- d[d.length - 1].inner += Q.value;
774
- if (Q.value || Q.output)
775
- s(Q);
776
- if (V && V.type === "text" && Q.type === "text") {
777
- V.output = (V.output || V.value) + Q.value, V.value += Q.value;
767
+ if (d.length && N.type !== "paren")
768
+ d[d.length - 1].inner += N.value;
769
+ if (N.value || N.output)
770
+ o(N);
771
+ if (F && F.type === "text" && N.type === "text") {
772
+ F.output = (F.output || F.value) + N.value, F.value += N.value;
778
773
  return;
779
774
  }
780
- Q.prev = V, U.push(Q), V = Q;
781
- }, z1 = (Q, O) => {
782
- let X = { ...K[O], conditions: 1, inner: "" };
783
- X.prev = V, X.parens = W.parens, X.output = W.output;
784
- let D = ($.capture ? "(" : "") + X.open;
785
- W1("parens"), f({ type: Q, value: O, output: W.output ? "" : P }), f({ type: "paren", extglob: true, value: R(), output: D }), d.push(X);
786
- }, Cq = (Q) => {
787
- let O = Q.close + ($.capture ? ")" : ""), X;
788
- if (Q.type === "negate") {
789
- let D = y;
790
- if (Q.inner && Q.inner.length > 1 && Q.inner.includes("/"))
791
- D = x($);
792
- if (D !== y || l() || /^\)+$/.test(p()))
793
- O = Q.close = `)$))${D}`;
794
- if (Q.inner.includes("*") && (X = p()) && /^\.[^\\/.]+$/.test(X)) {
795
- let E = E1(X, { ...Z, fastpaths: false }).output;
796
- O = Q.close = `)${E})${D})`;
775
+ N.prev = F, Q.push(N), F = N;
776
+ }, G1 = (N, x) => {
777
+ let M = { ...z[x], conditions: 1, inner: "" };
778
+ M.prev = F, M.parens = B.parens, M.output = B.output;
779
+ let R = (J.capture ? "(" : "") + M.open;
780
+ z1("parens"), f({ type: N, value: x, output: B.output ? "" : W }), f({ type: "paren", extglob: true, value: C(), output: R }), d.push(M);
781
+ }, cq = (N) => {
782
+ let x = N.close + (J.capture ? ")" : ""), M;
783
+ if (N.type === "negate") {
784
+ let R = P;
785
+ if (N.inner && N.inner.length > 1 && N.inner.includes("/"))
786
+ R = g(J);
787
+ if (R !== P || l() || /^\)+$/.test(n()))
788
+ x = N.close = `)$))${R}`;
789
+ if (N.inner.includes("*") && (M = n()) && /^\.[^\\/.]+$/.test(M)) {
790
+ let D = b1(M, { ...$, fastpaths: false }).output;
791
+ x = N.close = `)${D})${R})`;
797
792
  }
798
- if (Q.prev.type === "bos")
799
- W.negatedExtglob = true;
793
+ if (N.prev.type === "bos")
794
+ B.negatedExtglob = true;
800
795
  }
801
- f({ type: "paren", extglob: true, value: Y, output: O }), e("parens");
796
+ f({ type: "paren", extglob: true, value: K, output: x }), e("parens");
802
797
  };
803
- if ($.fastpaths !== false && !/(^[*!]|[/()[\]{}"])/.test(q)) {
804
- let Q = false, O = q.replace(yZ, (X, D, E, u, k, w1) => {
798
+ if (J.fastpaths !== false && !/(^[*!]|[/()[\]{}"])/.test(q)) {
799
+ let N = false, x = q.replace(IZ, (M, R, D, u, v, W1) => {
805
800
  if (u === "\\")
806
- return Q = true, X;
801
+ return N = true, M;
807
802
  if (u === "?") {
808
- if (D)
809
- return D + u + (k ? I.repeat(k.length) : "");
810
- if (w1 === 0)
811
- return w + (k ? I.repeat(k.length) : "");
812
- return I.repeat(E.length);
803
+ if (R)
804
+ return R + u + (v ? A.repeat(v.length) : "");
805
+ if (W1 === 0)
806
+ return O + (v ? A.repeat(v.length) : "");
807
+ return A.repeat(D.length);
813
808
  }
814
809
  if (u === ".")
815
- return F.repeat(E.length);
810
+ return G.repeat(D.length);
816
811
  if (u === "*") {
817
- if (D)
818
- return D + u + (k ? y : "");
819
- return y;
812
+ if (R)
813
+ return R + u + (v ? P : "");
814
+ return P;
820
815
  }
821
- return D ? X : `\\${X}`;
816
+ return R ? M : `\\${M}`;
822
817
  });
823
- if (Q === true)
824
- if ($.unescape === true)
825
- O = O.replace(/\\/g, "");
818
+ if (N === true)
819
+ if (J.unescape === true)
820
+ x = x.replace(/\\/g, "");
826
821
  else
827
- O = O.replace(/\\+/g, (X) => {
828
- return X.length % 2 === 0 ? "\\\\" : X ? "\\" : "";
822
+ x = x.replace(/\\+/g, (M) => {
823
+ return M.length % 2 === 0 ? "\\\\" : M ? "\\" : "";
829
824
  });
830
- if (O === q && $.contains === true)
831
- return W.output = q, W;
832
- return W.output = r.wrapOutput(O, W, Z), W;
825
+ if (x === q && J.contains === true)
826
+ return B.output = q, B;
827
+ return B.output = s.wrapOutput(x, B, $), B;
833
828
  }
834
829
  while (!l()) {
835
- if (Y = R(), Y === "\0")
830
+ if (K = C(), K === "\0")
836
831
  continue;
837
- if (Y === "\\") {
838
- let X = L();
839
- if (X === "/" && $.bash !== true)
832
+ if (K === "\\") {
833
+ let M = T();
834
+ if (M === "/" && J.bash !== true)
840
835
  continue;
841
- if (X === "." || X === ";")
836
+ if (M === "." || M === ";")
842
837
  continue;
843
- if (!X) {
844
- Y += "\\", f({ type: "text", value: Y });
838
+ if (!M) {
839
+ K += "\\", f({ type: "text", value: K });
845
840
  continue;
846
841
  }
847
- let D = /^\\+/.exec(p()), E = 0;
848
- if (D && D[0].length > 2) {
849
- if (E = D[0].length, W.index += E, E % 2 !== 0)
850
- Y += "\\";
842
+ let R = /^\\+/.exec(n()), D = 0;
843
+ if (R && R[0].length > 2) {
844
+ if (D = R[0].length, B.index += D, D % 2 !== 0)
845
+ K += "\\";
851
846
  }
852
- if ($.unescape === true)
853
- Y = R();
847
+ if (J.unescape === true)
848
+ K = C();
854
849
  else
855
- Y += R();
856
- if (W.brackets === 0) {
857
- f({ type: "text", value: Y });
850
+ K += C();
851
+ if (B.brackets === 0) {
852
+ f({ type: "text", value: K });
858
853
  continue;
859
854
  }
860
855
  }
861
- if (W.brackets > 0 && (Y !== "]" || V.value === "[" || V.value === "[^")) {
862
- if ($.posix !== false && Y === ":") {
863
- let X = V.value.slice(1);
864
- if (X.includes("[")) {
865
- if (V.posix = true, X.includes(":")) {
866
- let D = V.value.lastIndexOf("["), E = V.value.slice(0, D), u = V.value.slice(D + 2), k = NZ[u];
867
- if (k) {
868
- if (V.value = E + k, W.backtrack = true, R(), !z.output && U.indexOf(V) === 1)
869
- z.output = P;
856
+ if (B.brackets > 0 && (K !== "]" || F.value === "[" || F.value === "[^")) {
857
+ if (J.posix !== false && K === ":") {
858
+ let M = F.value.slice(1);
859
+ if (M.includes("[")) {
860
+ if (F.posix = true, M.includes(":")) {
861
+ let R = F.value.lastIndexOf("["), D = F.value.slice(0, R), u = F.value.slice(R + 2), v = NZ[u];
862
+ if (v) {
863
+ if (F.value = D + v, B.backtrack = true, C(), !j.output && Q.indexOf(F) === 1)
864
+ j.output = W;
870
865
  continue;
871
866
  }
872
867
  }
873
868
  }
874
869
  }
875
- if (Y === "[" && L() !== ":" || Y === "-" && L() === "]")
876
- Y = `\\${Y}`;
877
- if (Y === "]" && (V.value === "[" || V.value === "[^"))
878
- Y = `\\${Y}`;
879
- if ($.posix === true && Y === "!" && V.value === "[")
880
- Y = "^";
881
- V.value += Y, s({ value: Y });
870
+ if (K === "[" && T() !== ":" || K === "-" && T() === "]")
871
+ K = `\\${K}`;
872
+ if (K === "]" && (F.value === "[" || F.value === "[^"))
873
+ K = `\\${K}`;
874
+ if (J.posix === true && K === "!" && F.value === "[")
875
+ K = "^";
876
+ F.value += K, o({ value: K });
882
877
  continue;
883
878
  }
884
- if (W.quotes === 1 && Y !== '"') {
885
- Y = r.escapeRegex(Y), V.value += Y, s({ value: Y });
879
+ if (B.quotes === 1 && K !== '"') {
880
+ K = s.escapeRegex(K), F.value += K, o({ value: K });
886
881
  continue;
887
882
  }
888
- if (Y === '"') {
889
- if (W.quotes = W.quotes === 1 ? 0 : 1, $.keepQuotes === true)
890
- f({ type: "text", value: Y });
883
+ if (K === '"') {
884
+ if (B.quotes = B.quotes === 1 ? 0 : 1, J.keepQuotes === true)
885
+ f({ type: "text", value: K });
891
886
  continue;
892
887
  }
893
- if (Y === "(") {
894
- W1("parens"), f({ type: "paren", value: Y });
888
+ if (K === "(") {
889
+ z1("parens"), f({ type: "paren", value: K });
895
890
  continue;
896
891
  }
897
- if (Y === ")") {
898
- if (W.parens === 0 && $.strictBrackets === true)
899
- throw new SyntaxError($1("opening", "("));
900
- let X = d[d.length - 1];
901
- if (X && W.parens === X.parens + 1) {
902
- Cq(d.pop());
892
+ if (K === ")") {
893
+ if (B.parens === 0 && J.strictBrackets === true)
894
+ throw new SyntaxError(Y1("opening", "("));
895
+ let M = d[d.length - 1];
896
+ if (M && B.parens === M.parens + 1) {
897
+ cq(d.pop());
903
898
  continue;
904
899
  }
905
- f({ type: "paren", value: Y, output: W.parens ? ")" : "\\)" }), e("parens");
900
+ f({ type: "paren", value: K, output: B.parens ? ")" : "\\)" }), e("parens");
906
901
  continue;
907
902
  }
908
- if (Y === "[") {
909
- if ($.nobracket === true || !p().includes("]")) {
910
- if ($.nobracket !== true && $.strictBrackets === true)
911
- throw new SyntaxError($1("closing", "]"));
912
- Y = `\\${Y}`;
903
+ if (K === "[") {
904
+ if (J.nobracket === true || !n().includes("]")) {
905
+ if (J.nobracket !== true && J.strictBrackets === true)
906
+ throw new SyntaxError(Y1("closing", "]"));
907
+ K = `\\${K}`;
913
908
  } else
914
- W1("brackets");
915
- f({ type: "bracket", value: Y });
909
+ z1("brackets");
910
+ f({ type: "bracket", value: K });
916
911
  continue;
917
912
  }
918
- if (Y === "]") {
919
- if ($.nobracket === true || V && V.type === "bracket" && V.value.length === 1) {
920
- f({ type: "text", value: Y, output: `\\${Y}` });
913
+ if (K === "]") {
914
+ if (J.nobracket === true || F && F.type === "bracket" && F.value.length === 1) {
915
+ f({ type: "text", value: K, output: `\\${K}` });
921
916
  continue;
922
917
  }
923
- if (W.brackets === 0) {
924
- if ($.strictBrackets === true)
925
- throw new SyntaxError($1("opening", "["));
926
- f({ type: "text", value: Y, output: `\\${Y}` });
918
+ if (B.brackets === 0) {
919
+ if (J.strictBrackets === true)
920
+ throw new SyntaxError(Y1("opening", "["));
921
+ f({ type: "text", value: K, output: `\\${K}` });
927
922
  continue;
928
923
  }
929
924
  e("brackets");
930
- let X = V.value.slice(1);
931
- if (V.posix !== true && X[0] === "^" && !X.includes("/"))
932
- Y = `/${Y}`;
933
- if (V.value += Y, s({ value: Y }), $.literalBrackets === false || r.hasRegexChars(X))
925
+ let M = F.value.slice(1);
926
+ if (F.posix !== true && M[0] === "^" && !M.includes("/"))
927
+ K = `/${K}`;
928
+ if (F.value += K, o({ value: K }), J.literalBrackets === false || s.hasRegexChars(M))
934
929
  continue;
935
- let D = r.escapeRegex(V.value);
936
- if (W.output = W.output.slice(0, -V.value.length), $.literalBrackets === true) {
937
- W.output += D, V.value = D;
930
+ let R = s.escapeRegex(F.value);
931
+ if (B.output = B.output.slice(0, -F.value.length), J.literalBrackets === true) {
932
+ B.output += R, F.value = R;
938
933
  continue;
939
934
  }
940
- V.value = `(${B}${D}|${V.value})`, W.output += V.value;
935
+ F.value = `(${X}${R}|${F.value})`, B.output += F.value;
941
936
  continue;
942
937
  }
943
- if (Y === "{" && $.nobrace !== true) {
944
- W1("braces");
945
- let X = { type: "brace", value: Y, output: "(", outputIndex: W.output.length, tokensIndex: W.tokens.length };
946
- b.push(X), f(X);
938
+ if (K === "{" && J.nobrace !== true) {
939
+ z1("braces");
940
+ let M = { type: "brace", value: K, output: "(", outputIndex: B.output.length, tokensIndex: B.tokens.length };
941
+ b.push(M), f(M);
947
942
  continue;
948
943
  }
949
- if (Y === "}") {
950
- let X = b[b.length - 1];
951
- if ($.nobrace === true || !X) {
952
- f({ type: "text", value: Y, output: Y });
944
+ if (K === "}") {
945
+ let M = b[b.length - 1];
946
+ if (J.nobrace === true || !M) {
947
+ f({ type: "text", value: K, output: K });
953
948
  continue;
954
949
  }
955
- let D = ")";
956
- if (X.dots === true) {
957
- let E = U.slice(), u = [];
958
- for (let k = E.length - 1;k >= 0; k--) {
959
- if (U.pop(), E[k].type === "brace")
950
+ let R = ")";
951
+ if (M.dots === true) {
952
+ let D = Q.slice(), u = [];
953
+ for (let v = D.length - 1;v >= 0; v--) {
954
+ if (Q.pop(), D[v].type === "brace")
960
955
  break;
961
- if (E[k].type !== "dots")
962
- u.unshift(E[k].value);
956
+ if (D[v].type !== "dots")
957
+ u.unshift(D[v].value);
963
958
  }
964
- D = IZ(u, $), W.backtrack = true;
959
+ R = WZ(u, J), B.backtrack = true;
965
960
  }
966
- if (X.comma !== true && X.dots !== true) {
967
- let E = W.output.slice(0, X.outputIndex), u = W.tokens.slice(X.tokensIndex);
968
- X.value = X.output = "\\{", Y = D = "\\}", W.output = E;
969
- for (let k of u)
970
- W.output += k.output || k.value;
961
+ if (M.comma !== true && M.dots !== true) {
962
+ let D = B.output.slice(0, M.outputIndex), u = B.tokens.slice(M.tokensIndex);
963
+ M.value = M.output = "\\{", K = R = "\\}", B.output = D;
964
+ for (let v of u)
965
+ B.output += v.output || v.value;
971
966
  }
972
- f({ type: "brace", value: Y, output: D }), e("braces"), b.pop();
967
+ f({ type: "brace", value: K, output: R }), e("braces"), b.pop();
973
968
  continue;
974
969
  }
975
- if (Y === "|") {
970
+ if (K === "|") {
976
971
  if (d.length > 0)
977
972
  d[d.length - 1].conditions++;
978
- f({ type: "text", value: Y });
973
+ f({ type: "text", value: K });
979
974
  continue;
980
975
  }
981
- if (Y === ",") {
982
- let X = Y, D = b[b.length - 1];
983
- if (D && S[S.length - 1] === "braces")
984
- D.comma = true, X = "|";
985
- f({ type: "comma", value: Y, output: X });
976
+ if (K === ",") {
977
+ let M = K, R = b[b.length - 1];
978
+ if (R && k[k.length - 1] === "braces")
979
+ R.comma = true, M = "|";
980
+ f({ type: "comma", value: K, output: M });
986
981
  continue;
987
982
  }
988
- if (Y === "/") {
989
- if (V.type === "dot" && W.index === W.start + 1) {
990
- W.start = W.index + 1, W.consumed = "", W.output = "", U.pop(), V = z;
983
+ if (K === "/") {
984
+ if (F.type === "dot" && B.index === B.start + 1) {
985
+ B.start = B.index + 1, B.consumed = "", B.output = "", Q.pop(), F = j;
991
986
  continue;
992
987
  }
993
- f({ type: "slash", value: Y, output: H });
988
+ f({ type: "slash", value: K, output: H });
994
989
  continue;
995
990
  }
996
- if (Y === ".") {
997
- if (W.braces > 0 && V.type === "dot") {
998
- if (V.value === ".")
999
- V.output = F;
1000
- let X = b[b.length - 1];
1001
- V.type = "dots", V.output += Y, V.value += Y, X.dots = true;
991
+ if (K === ".") {
992
+ if (B.braces > 0 && F.type === "dot") {
993
+ if (F.value === ".")
994
+ F.output = G;
995
+ let M = b[b.length - 1];
996
+ F.type = "dots", F.output += K, F.value += K, M.dots = true;
1002
997
  continue;
1003
998
  }
1004
- if (W.braces + W.parens === 0 && V.type !== "bos" && V.type !== "slash") {
1005
- f({ type: "text", value: Y, output: F });
999
+ if (B.braces + B.parens === 0 && F.type !== "bos" && F.type !== "slash") {
1000
+ f({ type: "text", value: K, output: G });
1006
1001
  continue;
1007
1002
  }
1008
- f({ type: "dot", value: Y, output: F });
1003
+ f({ type: "dot", value: K, output: G });
1009
1004
  continue;
1010
1005
  }
1011
- if (Y === "?") {
1012
- if (!(V && V.value === "(") && $.noextglob !== true && L() === "(" && L(2) !== "?") {
1013
- z1("qmark", Y);
1006
+ if (K === "?") {
1007
+ if (!(F && F.value === "(") && J.noextglob !== true && T() === "(" && T(2) !== "?") {
1008
+ G1("qmark", K);
1014
1009
  continue;
1015
1010
  }
1016
- if (V && V.type === "paren") {
1017
- let D = L(), E = Y;
1018
- if (V.value === "(" && !/[!=<:]/.test(D) || D === "<" && !/<([!=]|\w+>)/.test(p()))
1019
- E = `\\${Y}`;
1020
- f({ type: "text", value: Y, output: E });
1011
+ if (F && F.type === "paren") {
1012
+ let R = T(), D = K;
1013
+ if (F.value === "(" && !/[!=<:]/.test(R) || R === "<" && !/<([!=]|\w+>)/.test(n()))
1014
+ D = `\\${K}`;
1015
+ f({ type: "text", value: K, output: D });
1021
1016
  continue;
1022
1017
  }
1023
- if ($.dot !== true && (V.type === "slash" || V.type === "bos")) {
1024
- f({ type: "qmark", value: Y, output: g });
1018
+ if (J.dot !== true && (F.type === "slash" || F.type === "bos")) {
1019
+ f({ type: "qmark", value: K, output: m });
1025
1020
  continue;
1026
1021
  }
1027
- f({ type: "qmark", value: Y, output: I });
1022
+ f({ type: "qmark", value: K, output: A });
1028
1023
  continue;
1029
1024
  }
1030
- if (Y === "!") {
1031
- if ($.noextglob !== true && L() === "(") {
1032
- if (L(2) !== "?" || !/[!=<:]/.test(L(3))) {
1033
- z1("negate", Y);
1025
+ if (K === "!") {
1026
+ if (J.noextglob !== true && T() === "(") {
1027
+ if (T(2) !== "?" || !/[!=<:]/.test(T(3))) {
1028
+ G1("negate", K);
1034
1029
  continue;
1035
1030
  }
1036
1031
  }
1037
- if ($.nonegate !== true && W.index === 0) {
1038
- Hq();
1032
+ if (J.nonegate !== true && B.index === 0) {
1033
+ dq();
1039
1034
  continue;
1040
1035
  }
1041
1036
  }
1042
- if (Y === "+") {
1043
- if ($.noextglob !== true && L() === "(" && L(2) !== "?") {
1044
- z1("plus", Y);
1037
+ if (K === "+") {
1038
+ if (J.noextglob !== true && T() === "(" && T(2) !== "?") {
1039
+ G1("plus", K);
1045
1040
  continue;
1046
1041
  }
1047
- if (V && V.value === "(" || $.regex === false) {
1048
- f({ type: "plus", value: Y, output: T });
1042
+ if (F && F.value === "(" || J.regex === false) {
1043
+ f({ type: "plus", value: K, output: V });
1049
1044
  continue;
1050
1045
  }
1051
- if (V && (V.type === "bracket" || V.type === "paren" || V.type === "brace") || W.parens > 0) {
1052
- f({ type: "plus", value: Y });
1046
+ if (F && (F.type === "bracket" || F.type === "paren" || F.type === "brace") || B.parens > 0) {
1047
+ f({ type: "plus", value: K });
1053
1048
  continue;
1054
1049
  }
1055
- f({ type: "plus", value: T });
1050
+ f({ type: "plus", value: V });
1056
1051
  continue;
1057
1052
  }
1058
- if (Y === "@") {
1059
- if ($.noextglob !== true && L() === "(" && L(2) !== "?") {
1060
- f({ type: "at", extglob: true, value: Y, output: "" });
1053
+ if (K === "@") {
1054
+ if (J.noextglob !== true && T() === "(" && T(2) !== "?") {
1055
+ f({ type: "at", extglob: true, value: K, output: "" });
1061
1056
  continue;
1062
1057
  }
1063
- f({ type: "text", value: Y });
1058
+ f({ type: "text", value: K });
1064
1059
  continue;
1065
1060
  }
1066
- if (Y !== "*") {
1067
- if (Y === "$" || Y === "^")
1068
- Y = `\\${Y}`;
1069
- let X = wZ.exec(p());
1070
- if (X)
1071
- Y += X[0], W.index += X[0].length;
1072
- f({ type: "text", value: Y });
1061
+ if (K !== "*") {
1062
+ if (K === "$" || K === "^")
1063
+ K = `\\${K}`;
1064
+ let M = HZ.exec(n());
1065
+ if (M)
1066
+ K += M[0], B.index += M[0].length;
1067
+ f({ type: "text", value: K });
1073
1068
  continue;
1074
1069
  }
1075
- if (V && (V.type === "globstar" || V.star === true)) {
1076
- V.type = "star", V.star = true, V.value += Y, V.output = y, W.backtrack = true, W.globstar = true, c(Y);
1070
+ if (F && (F.type === "globstar" || F.star === true)) {
1071
+ F.type = "star", F.star = true, F.value += K, F.output = P, B.backtrack = true, B.globstar = true, p(K);
1077
1072
  continue;
1078
1073
  }
1079
- let Q = p();
1080
- if ($.noextglob !== true && /^\([^?]/.test(Q)) {
1081
- z1("star", Y);
1074
+ let N = n();
1075
+ if (J.noextglob !== true && /^\([^?]/.test(N)) {
1076
+ G1("star", K);
1082
1077
  continue;
1083
1078
  }
1084
- if (V.type === "star") {
1085
- if ($.noglobstar === true) {
1086
- c(Y);
1079
+ if (F.type === "star") {
1080
+ if (J.noglobstar === true) {
1081
+ p(K);
1087
1082
  continue;
1088
1083
  }
1089
- let X = V.prev, D = X.prev, E = X.type === "slash" || X.type === "bos", u = D && (D.type === "star" || D.type === "globstar");
1090
- if ($.bash === true && (!E || Q[0] && Q[0] !== "/")) {
1091
- f({ type: "star", value: Y, output: "" });
1084
+ let M = F.prev, R = M.prev, D = M.type === "slash" || M.type === "bos", u = R && (R.type === "star" || R.type === "globstar");
1085
+ if (J.bash === true && (!D || N[0] && N[0] !== "/")) {
1086
+ f({ type: "star", value: K, output: "" });
1092
1087
  continue;
1093
1088
  }
1094
- let k = W.braces > 0 && (X.type === "comma" || X.type === "brace"), w1 = d.length && (X.type === "pipe" || X.type === "paren");
1095
- if (!E && X.type !== "paren" && !k && !w1) {
1096
- f({ type: "star", value: Y, output: "" });
1089
+ let v = B.braces > 0 && (M.type === "comma" || M.type === "brace"), W1 = d.length && (M.type === "pipe" || M.type === "paren");
1090
+ if (!D && M.type !== "paren" && !v && !W1) {
1091
+ f({ type: "star", value: K, output: "" });
1097
1092
  continue;
1098
1093
  }
1099
- while (Q.slice(0, 3) === "/**") {
1100
- let U1 = q[W.index + 4];
1101
- if (U1 && U1 !== "/")
1094
+ while (N.slice(0, 3) === "/**") {
1095
+ let F1 = q[B.index + 4];
1096
+ if (F1 && F1 !== "/")
1102
1097
  break;
1103
- Q = Q.slice(3), c("/**", 3);
1098
+ N = N.slice(3), p("/**", 3);
1104
1099
  }
1105
- if (X.type === "bos" && l()) {
1106
- V.type = "globstar", V.value += Y, V.output = x($), W.output = V.output, W.globstar = true, c(Y);
1100
+ if (M.type === "bos" && l()) {
1101
+ F.type = "globstar", F.value += K, F.output = g(J), B.output = F.output, B.globstar = true, p(K);
1107
1102
  continue;
1108
1103
  }
1109
- if (X.type === "slash" && X.prev.type !== "bos" && !u && l()) {
1110
- W.output = W.output.slice(0, -(X.output + V.output).length), X.output = `(?:${X.output}`, V.type = "globstar", V.output = x($) + ($.strictSlashes ? ")" : "|$)"), V.value += Y, W.globstar = true, W.output += X.output + V.output, c(Y);
1104
+ if (M.type === "slash" && M.prev.type !== "bos" && !u && l()) {
1105
+ B.output = B.output.slice(0, -(M.output + F.output).length), M.output = `(?:${M.output}`, F.type = "globstar", F.output = g(J) + (J.strictSlashes ? ")" : "|$)"), F.value += K, B.globstar = true, B.output += M.output + F.output, p(K);
1111
1106
  continue;
1112
1107
  }
1113
- if (X.type === "slash" && X.prev.type !== "bos" && Q[0] === "/") {
1114
- let U1 = Q[1] !== undefined ? "|$" : "";
1115
- W.output = W.output.slice(0, -(X.output + V.output).length), X.output = `(?:${X.output}`, V.type = "globstar", V.output = `${x($)}${H}|${H}${U1})`, V.value += Y, W.output += X.output + V.output, W.globstar = true, c(Y + R()), f({ type: "slash", value: "/", output: "" });
1108
+ if (M.type === "slash" && M.prev.type !== "bos" && N[0] === "/") {
1109
+ let F1 = N[1] !== undefined ? "|$" : "";
1110
+ B.output = B.output.slice(0, -(M.output + F.output).length), M.output = `(?:${M.output}`, F.type = "globstar", F.output = `${g(J)}${H}|${H}${F1})`, F.value += K, B.output += M.output + F.output, B.globstar = true, p(K + C()), f({ type: "slash", value: "/", output: "" });
1116
1111
  continue;
1117
1112
  }
1118
- if (X.type === "bos" && Q[0] === "/") {
1119
- V.type = "globstar", V.value += Y, V.output = `(?:^|${H}|${x($)}${H})`, W.output = V.output, W.globstar = true, c(Y + R()), f({ type: "slash", value: "/", output: "" });
1113
+ if (M.type === "bos" && N[0] === "/") {
1114
+ F.type = "globstar", F.value += K, F.output = `(?:^|${H}|${g(J)}${H})`, B.output = F.output, B.globstar = true, p(K + C()), f({ type: "slash", value: "/", output: "" });
1120
1115
  continue;
1121
1116
  }
1122
- W.output = W.output.slice(0, -V.output.length), V.type = "globstar", V.output = x($), V.value += Y, W.output += V.output, W.globstar = true, c(Y);
1117
+ B.output = B.output.slice(0, -F.output.length), F.type = "globstar", F.output = g(J), F.value += K, B.output += F.output, B.globstar = true, p(K);
1123
1118
  continue;
1124
1119
  }
1125
- let O = { type: "star", value: Y, output: y };
1126
- if ($.bash === true) {
1127
- if (O.output = ".*?", V.type === "bos" || V.type === "slash")
1128
- O.output = m + O.output;
1129
- f(O);
1120
+ let x = { type: "star", value: K, output: P };
1121
+ if (J.bash === true) {
1122
+ if (x.output = ".*?", F.type === "bos" || F.type === "slash")
1123
+ x.output = c + x.output;
1124
+ f(x);
1130
1125
  continue;
1131
1126
  }
1132
- if (V && (V.type === "bracket" || V.type === "paren") && $.regex === true) {
1133
- O.output = Y, f(O);
1127
+ if (F && (F.type === "bracket" || F.type === "paren") && J.regex === true) {
1128
+ x.output = K, f(x);
1134
1129
  continue;
1135
1130
  }
1136
- if (W.index === W.start || V.type === "slash" || V.type === "dot") {
1137
- if (V.type === "dot")
1138
- W.output += h, V.output += h;
1139
- else if ($.dot === true)
1140
- W.output += C, V.output += C;
1131
+ if (B.index === B.start || F.type === "slash" || F.type === "dot") {
1132
+ if (F.type === "dot")
1133
+ B.output += S, F.output += S;
1134
+ else if (J.dot === true)
1135
+ B.output += E, F.output += E;
1141
1136
  else
1142
- W.output += m, V.output += m;
1143
- if (L() !== "*")
1144
- W.output += P, V.output += P;
1137
+ B.output += c, F.output += c;
1138
+ if (T() !== "*")
1139
+ B.output += W, F.output += W;
1145
1140
  }
1146
- f(O);
1141
+ f(x);
1147
1142
  }
1148
- while (W.brackets > 0) {
1149
- if ($.strictBrackets === true)
1150
- throw new SyntaxError($1("closing", "]"));
1151
- W.output = r.escapeLast(W.output, "["), e("brackets");
1143
+ while (B.brackets > 0) {
1144
+ if (J.strictBrackets === true)
1145
+ throw new SyntaxError(Y1("closing", "]"));
1146
+ B.output = s.escapeLast(B.output, "["), e("brackets");
1152
1147
  }
1153
- while (W.parens > 0) {
1154
- if ($.strictBrackets === true)
1155
- throw new SyntaxError($1("closing", ")"));
1156
- W.output = r.escapeLast(W.output, "("), e("parens");
1148
+ while (B.parens > 0) {
1149
+ if (J.strictBrackets === true)
1150
+ throw new SyntaxError(Y1("closing", ")"));
1151
+ B.output = s.escapeLast(B.output, "("), e("parens");
1157
1152
  }
1158
- while (W.braces > 0) {
1159
- if ($.strictBrackets === true)
1160
- throw new SyntaxError($1("closing", "}"));
1161
- W.output = r.escapeLast(W.output, "{"), e("braces");
1153
+ while (B.braces > 0) {
1154
+ if (J.strictBrackets === true)
1155
+ throw new SyntaxError(Y1("closing", "}"));
1156
+ B.output = s.escapeLast(B.output, "{"), e("braces");
1162
1157
  }
1163
- if ($.strictSlashes !== true && (V.type === "star" || V.type === "bracket"))
1158
+ if (J.strictSlashes !== true && (F.type === "star" || F.type === "bracket"))
1164
1159
  f({ type: "maybe_slash", value: "", output: `${H}?` });
1165
- if (W.backtrack === true) {
1166
- W.output = "";
1167
- for (let Q of W.tokens)
1168
- if (W.output += Q.output != null ? Q.output : Q.value, Q.suffix)
1169
- W.output += Q.suffix;
1160
+ if (B.backtrack === true) {
1161
+ B.output = "";
1162
+ for (let N of B.tokens)
1163
+ if (B.output += N.output != null ? N.output : N.value, N.suffix)
1164
+ B.output += N.suffix;
1170
1165
  }
1171
- return W;
1166
+ return B;
1172
1167
  };
1173
- E1.fastpaths = (q, Z) => {
1174
- let $ = { ...Z }, J = typeof $.maxLength === "number" ? Math.min(M1, $.maxLength) : M1, j = q.length;
1175
- if (j > J)
1176
- throw new SyntaxError(`Input length: ${j}, exceeds maximum allowed length: ${J}`);
1177
- q = o0[q] || q;
1178
- let { DOT_LITERAL: z, SLASH_LITERAL: U, ONE_CHAR: B, DOTS_SLASH: M, NO_DOT: K, NO_DOTS: F, NO_DOTS_SLASH: T, STAR: H, START_ANCHOR: P } = G1.globChars($.windows), N = $.dot ? F : K, G = $.dot ? T : K, h = $.capture ? "" : "?:", C = { negated: false, prefix: "" }, I = $.bash === true ? ".*?" : H;
1179
- if ($.capture)
1180
- I = `(${I})`;
1181
- let g = (m) => {
1182
- if (m.noglobstar === true)
1183
- return I;
1184
- return `(${h}(?:(?!${P}${m.dot ? M : z}).)*?)`;
1185
- }, i = (m) => {
1186
- switch (m) {
1168
+ b1.fastpaths = (q, $) => {
1169
+ let J = { ...$ }, Z = typeof J.maxLength === "number" ? Math.min(H1, J.maxLength) : H1, Y = q.length;
1170
+ if (Y > Z)
1171
+ throw new SyntaxError(`Input length: ${Y}, exceeds maximum allowed length: ${Z}`);
1172
+ q = wq[q] || q;
1173
+ let { DOT_LITERAL: j, SLASH_LITERAL: Q, ONE_CHAR: X, DOTS_SLASH: U, NO_DOT: z, NO_DOTS: G, NO_DOTS_SLASH: V, STAR: H, START_ANCHOR: W } = N1.globChars(J.windows), I = J.dot ? G : z, _ = J.dot ? V : z, S = J.capture ? "" : "?:", E = { negated: false, prefix: "" }, A = J.bash === true ? ".*?" : H;
1174
+ if (J.capture)
1175
+ A = `(${A})`;
1176
+ let m = (c) => {
1177
+ if (c.noglobstar === true)
1178
+ return A;
1179
+ return `(${S}(?:(?!${W}${c.dot ? U : j}).)*?)`;
1180
+ }, t = (c) => {
1181
+ switch (c) {
1187
1182
  case "*":
1188
- return `${N}${B}${I}`;
1183
+ return `${I}${X}${A}`;
1189
1184
  case ".*":
1190
- return `${z}${B}${I}`;
1185
+ return `${j}${X}${A}`;
1191
1186
  case "*.*":
1192
- return `${N}${I}${z}${B}${I}`;
1187
+ return `${I}${A}${j}${X}${A}`;
1193
1188
  case "*/*":
1194
- return `${N}${I}${U}${B}${G}${I}`;
1189
+ return `${I}${A}${Q}${X}${_}${A}`;
1195
1190
  case "**":
1196
- return N + g($);
1191
+ return I + m(J);
1197
1192
  case "**/*":
1198
- return `(?:${N}${g($)}${U})?${G}${B}${I}`;
1193
+ return `(?:${I}${m(J)}${Q})?${_}${X}${A}`;
1199
1194
  case "**/*.*":
1200
- return `(?:${N}${g($)}${U})?${G}${I}${z}${B}${I}`;
1195
+ return `(?:${I}${m(J)}${Q})?${_}${A}${j}${X}${A}`;
1201
1196
  case "**/.*":
1202
- return `(?:${N}${g($)}${U})?${z}${B}${I}`;
1197
+ return `(?:${I}${m(J)}${Q})?${j}${X}${A}`;
1203
1198
  default: {
1204
- let w = /^(.*?)\.(\w+)$/.exec(m);
1205
- if (!w)
1199
+ let O = /^(.*?)\.(\w+)$/.exec(c);
1200
+ if (!O)
1206
1201
  return;
1207
- let y = i(w[1]);
1208
- if (!y)
1202
+ let P = t(O[1]);
1203
+ if (!P)
1209
1204
  return;
1210
- return y + z + w[2];
1205
+ return P + j + O[2];
1211
1206
  }
1212
1207
  }
1213
- }, v = r.removePrefix(q, C), x = i(v);
1214
- if (x && $.strictSlashes !== true)
1215
- x += `${U}?`;
1216
- return x;
1208
+ }, h = s.removePrefix(q, E), g = t(h);
1209
+ if (g && J.strictSlashes !== true)
1210
+ g += `${Q}?`;
1211
+ return g;
1217
1212
  };
1218
- e0.exports = E1;
1213
+ Mq.exports = b1;
1219
1214
  });
1220
- var Zq = _((H8, $q) => {
1221
- var DZ = s0(), S1 = t0(), qq = j1(), fZ = J1(), HZ = (q) => q && typeof q === "object" && !Array.isArray(q), A = (q, Z, $ = false) => {
1215
+ var Iq = y((R8, Hq) => {
1216
+ var _Z = Bq(), v1 = Vq(), Nq = X1(), OZ = j1(), RZ = (q) => q && typeof q === "object" && !Array.isArray(q), L = (q, $, J = false) => {
1222
1217
  if (Array.isArray(q)) {
1223
- let F = q.map((H) => A(H, Z, $));
1218
+ let G = q.map((H) => L(H, $, J));
1224
1219
  return (H) => {
1225
- for (let P of F) {
1226
- let N = P(H);
1227
- if (N)
1228
- return N;
1220
+ for (let W of G) {
1221
+ let I = W(H);
1222
+ if (I)
1223
+ return I;
1229
1224
  }
1230
1225
  return false;
1231
1226
  };
1232
1227
  }
1233
- let J = HZ(q) && q.tokens && q.input;
1234
- if (q === "" || typeof q !== "string" && !J)
1228
+ let Z = RZ(q) && q.tokens && q.input;
1229
+ if (q === "" || typeof q !== "string" && !Z)
1235
1230
  throw new TypeError("Expected pattern to be a non-empty string");
1236
- let j = Z || {}, z = j.windows, U = J ? A.compileRe(q, Z) : A.makeRe(q, Z, false, true), B = U.state;
1237
- delete U.state;
1238
- let M = () => false;
1239
- if (j.ignore) {
1240
- let F = { ...Z, ignore: null, onMatch: null, onResult: null };
1241
- M = A(j.ignore, F, $);
1242
- }
1243
- let K = (F, T = false) => {
1244
- let { isMatch: H, match: P, output: N } = A.test(F, U, Z, { glob: q, posix: z }), G = { glob: q, state: B, regex: U, posix: z, input: F, output: N, match: P, isMatch: H };
1245
- if (typeof j.onResult === "function")
1246
- j.onResult(G);
1231
+ let Y = $ || {}, j = Y.windows, Q = Z ? L.compileRe(q, $) : L.makeRe(q, $, false, true), X = Q.state;
1232
+ delete Q.state;
1233
+ let U = () => false;
1234
+ if (Y.ignore) {
1235
+ let G = { ...$, ignore: null, onMatch: null, onResult: null };
1236
+ U = L(Y.ignore, G, J);
1237
+ }
1238
+ let z = (G, V = false) => {
1239
+ let { isMatch: H, match: W, output: I } = L.test(G, Q, $, { glob: q, posix: j }), _ = { glob: q, state: X, regex: Q, posix: j, input: G, output: I, match: W, isMatch: H };
1240
+ if (typeof Y.onResult === "function")
1241
+ Y.onResult(_);
1247
1242
  if (H === false)
1248
- return G.isMatch = false, T ? G : false;
1249
- if (M(F)) {
1250
- if (typeof j.onIgnore === "function")
1251
- j.onIgnore(G);
1252
- return G.isMatch = false, T ? G : false;
1243
+ return _.isMatch = false, V ? _ : false;
1244
+ if (U(G)) {
1245
+ if (typeof Y.onIgnore === "function")
1246
+ Y.onIgnore(_);
1247
+ return _.isMatch = false, V ? _ : false;
1253
1248
  }
1254
- if (typeof j.onMatch === "function")
1255
- j.onMatch(G);
1256
- return T ? G : true;
1249
+ if (typeof Y.onMatch === "function")
1250
+ Y.onMatch(_);
1251
+ return V ? _ : true;
1257
1252
  };
1258
- if ($)
1259
- K.state = B;
1260
- return K;
1253
+ if (J)
1254
+ z.state = X;
1255
+ return z;
1261
1256
  };
1262
- A.test = (q, Z, $, { glob: J, posix: j } = {}) => {
1257
+ L.test = (q, $, J, { glob: Z, posix: Y } = {}) => {
1263
1258
  if (typeof q !== "string")
1264
1259
  throw new TypeError("Expected input to be a string");
1265
1260
  if (q === "")
1266
1261
  return { isMatch: false, output: "" };
1267
- let z = $ || {}, U = z.format || (j ? qq.toPosixSlashes : null), B = q === J, M = B && U ? U(q) : q;
1268
- if (B === false)
1269
- M = U ? U(q) : q, B = M === J;
1270
- if (B === false || z.capture === true)
1271
- if (z.matchBase === true || z.basename === true)
1272
- B = A.matchBase(q, Z, $, j);
1262
+ let j = J || {}, Q = j.format || (Y ? Nq.toPosixSlashes : null), X = q === Z, U = X && Q ? Q(q) : q;
1263
+ if (X === false)
1264
+ U = Q ? Q(q) : q, X = U === Z;
1265
+ if (X === false || j.capture === true)
1266
+ if (j.matchBase === true || j.basename === true)
1267
+ X = L.matchBase(q, $, J, Y);
1273
1268
  else
1274
- B = Z.exec(M);
1275
- return { isMatch: Boolean(B), match: B, output: M };
1269
+ X = $.exec(U);
1270
+ return { isMatch: Boolean(X), match: X, output: U };
1276
1271
  };
1277
- A.matchBase = (q, Z, $) => {
1278
- return (Z instanceof RegExp ? Z : A.makeRe(Z, $)).test(qq.basename(q));
1272
+ L.matchBase = (q, $, J) => {
1273
+ return ($ instanceof RegExp ? $ : L.makeRe($, J)).test(Nq.basename(q));
1279
1274
  };
1280
- A.isMatch = (q, Z, $) => A(Z, $)(q);
1281
- A.parse = (q, Z) => {
1275
+ L.isMatch = (q, $, J) => L($, J)(q);
1276
+ L.parse = (q, $) => {
1282
1277
  if (Array.isArray(q))
1283
- return q.map(($) => A.parse($, Z));
1284
- return S1(q, { ...Z, fastpaths: false });
1278
+ return q.map((J) => L.parse(J, $));
1279
+ return v1(q, { ...$, fastpaths: false });
1285
1280
  };
1286
- A.scan = (q, Z) => DZ(q, Z);
1287
- A.compileRe = (q, Z, $ = false, J = false) => {
1288
- if ($ === true)
1281
+ L.scan = (q, $) => _Z(q, $);
1282
+ L.compileRe = (q, $, J = false, Z = false) => {
1283
+ if (J === true)
1289
1284
  return q.output;
1290
- let j = Z || {}, z = j.contains ? "" : "^", U = j.contains ? "" : "$", B = `${z}(?:${q.output})${U}`;
1285
+ let Y = $ || {}, j = Y.contains ? "" : "^", Q = Y.contains ? "" : "$", X = `${j}(?:${q.output})${Q}`;
1291
1286
  if (q && q.negated === true)
1292
- B = `^(?!${B}).*$`;
1293
- let M = A.toRegex(B, Z);
1294
- if (J === true)
1295
- M.state = q;
1296
- return M;
1287
+ X = `^(?!${X}).*$`;
1288
+ let U = L.toRegex(X, $);
1289
+ if (Z === true)
1290
+ U.state = q;
1291
+ return U;
1297
1292
  };
1298
- A.makeRe = (q, Z = {}, $ = false, J = false) => {
1293
+ L.makeRe = (q, $ = {}, J = false, Z = false) => {
1299
1294
  if (!q || typeof q !== "string")
1300
1295
  throw new TypeError("Expected a non-empty string");
1301
- let j = { negated: false, fastpaths: true };
1302
- if (Z.fastpaths !== false && (q[0] === "." || q[0] === "*"))
1303
- j.output = S1.fastpaths(q, Z);
1304
- if (!j.output)
1305
- j = S1(q, Z);
1306
- return A.compileRe(j, Z, $, J);
1296
+ let Y = { negated: false, fastpaths: true };
1297
+ if ($.fastpaths !== false && (q[0] === "." || q[0] === "*"))
1298
+ Y.output = v1.fastpaths(q, $);
1299
+ if (!Y.output)
1300
+ Y = v1(q, $);
1301
+ return L.compileRe(Y, $, J, Z);
1307
1302
  };
1308
- A.toRegex = (q, Z) => {
1303
+ L.toRegex = (q, $) => {
1309
1304
  try {
1310
- let $ = Z || {};
1311
- return new RegExp(q, $.flags || ($.nocase ? "i" : ""));
1312
- } catch ($) {
1313
- if (Z && Z.debug === true)
1314
- throw $;
1305
+ let J = $ || {};
1306
+ return new RegExp(q, J.flags || (J.nocase ? "i" : ""));
1307
+ } catch (J) {
1308
+ if ($ && $.debug === true)
1309
+ throw J;
1315
1310
  return /$^/;
1316
1311
  }
1317
1312
  };
1318
- A.constants = fZ;
1319
- $q.exports = A;
1313
+ L.constants = OZ;
1314
+ Hq.exports = L;
1320
1315
  });
1321
- var Y1 = _((C8, Vq) => {
1322
- var Jq = Zq(), CZ = j1();
1323
- function jq(q, Z, $ = false) {
1324
- if (Z && (Z.windows === null || Z.windows === undefined))
1325
- Z = { ...Z, windows: CZ.isWindows() };
1326
- return Jq(q, Z, $);
1327
- }
1328
- Object.assign(jq, Jq);
1329
- Vq.exports = jq;
1316
+ var U1 = y((P8, Oq) => {
1317
+ var Wq = Iq(), PZ = X1();
1318
+ function _q(q, $, J = false) {
1319
+ if ($ && ($.windows === null || $.windows === undefined))
1320
+ $ = { ...$, windows: PZ.isWindows() };
1321
+ return Wq(q, $, J);
1322
+ }
1323
+ Object.assign(_q, Wq);
1324
+ Oq.exports = _q;
1330
1325
  });
1331
- var Bq = _((Uq) => {
1332
- Object.defineProperty(Uq, "__esModule", { value: true });
1333
- Uq.Builder = undefined;
1334
- var LZ = import.meta.require("path"), Yq = v0(), Wq = null;
1326
+ var Tq = y((Eq) => {
1327
+ Object.defineProperty(Eq, "__esModule", { value: true });
1328
+ Eq.Builder = undefined;
1329
+ var fZ = import.meta.require("path"), Rq = $q(), Pq = null;
1335
1330
  try {
1336
- import.meta.require.resolve("picomatch"), Wq = Y1();
1331
+ import.meta.require.resolve("picomatch"), Pq = U1();
1337
1332
  } catch (q) {
1338
1333
  }
1339
1334
 
1340
- class zq {
1335
+ class fq {
1341
1336
  globCache = {};
1342
- options = { maxDepth: 1 / 0, suppressErrors: true, pathSeparator: LZ.sep, filters: [] };
1337
+ options = { maxDepth: 1 / 0, suppressErrors: true, pathSeparator: fZ.sep, filters: [] };
1343
1338
  globFunction;
1344
1339
  constructor(q) {
1345
1340
  this.options = { ...this.options, ...q }, this.globFunction = this.options.globFunction;
@@ -1393,329 +1388,1326 @@ var Bq = _((Uq) => {
1393
1388
  return this.options.onlyCounts = true, this;
1394
1389
  }
1395
1390
  crawl(q) {
1396
- return new Yq.APIBuilder(q || ".", this.options);
1391
+ return new Rq.APIBuilder(q || ".", this.options);
1397
1392
  }
1398
1393
  withGlobFunction(q) {
1399
1394
  return this.globFunction = q, this;
1400
1395
  }
1401
- crawlWithOptions(q, Z) {
1402
- return this.options = { ...this.options, ...Z }, new Yq.APIBuilder(q || ".", this.options);
1396
+ crawlWithOptions(q, $) {
1397
+ return this.options = { ...this.options, ...$ }, new Rq.APIBuilder(q || ".", this.options);
1403
1398
  }
1404
1399
  glob(...q) {
1405
1400
  if (this.globFunction)
1406
1401
  return this.globWithOptions(q);
1407
1402
  return this.globWithOptions(q, ...[{ dot: true }]);
1408
1403
  }
1409
- globWithOptions(q, ...Z) {
1410
- let $ = this.globFunction || Wq;
1411
- if (!$)
1412
- throw new Error("Please specify a glob function to use glob matching.");
1413
- var J = this.globCache[q.join("\0")];
1404
+ globWithOptions(q, ...$) {
1405
+ let J = this.globFunction || Pq;
1414
1406
  if (!J)
1415
- J = $(q, ...Z), this.globCache[q.join("\0")] = J;
1416
- return this.options.filters.push((j) => J(j)), this;
1407
+ throw new Error("Please specify a glob function to use glob matching.");
1408
+ var Z = this.globCache[q.join("\0")];
1409
+ if (!Z)
1410
+ Z = J(q, ...$), this.globCache[q.join("\0")] = Z;
1411
+ return this.options.filters.push((Y) => Z(Y)), this;
1417
1412
  }
1418
1413
  }
1419
- Uq.Builder = zq;
1414
+ Eq.Builder = fq;
1420
1415
  });
1421
- var Fq = _((Qq) => {
1422
- Object.defineProperty(Qq, "__esModule", { value: true });
1416
+ var xq = y((Sq) => {
1417
+ Object.defineProperty(Sq, "__esModule", { value: true });
1423
1418
  });
1424
- var Kq = _((a) => {
1425
- var PZ = a && a.__createBinding || (Object.create ? function(q, Z, $, J) {
1426
- if (J === undefined)
1427
- J = $;
1428
- var j = Object.getOwnPropertyDescriptor(Z, $);
1429
- if (!j || ("get" in j ? !Z.__esModule : j.writable || j.configurable))
1430
- j = { enumerable: true, get: function() {
1431
- return Z[$];
1419
+ var yq = y((r) => {
1420
+ var EZ = r && r.__createBinding || (Object.create ? function(q, $, J, Z) {
1421
+ if (Z === undefined)
1422
+ Z = J;
1423
+ var Y = Object.getOwnPropertyDescriptor($, J);
1424
+ if (!Y || ("get" in Y ? !$.__esModule : Y.writable || Y.configurable))
1425
+ Y = { enumerable: true, get: function() {
1426
+ return $[J];
1432
1427
  } };
1433
- Object.defineProperty(q, J, j);
1434
- } : function(q, Z, $, J) {
1435
- if (J === undefined)
1436
- J = $;
1437
- q[J] = Z[$];
1438
- }), TZ = a && a.__exportStar || function(q, Z) {
1439
- for (var $ in q)
1440
- if ($ !== "default" && !Object.prototype.hasOwnProperty.call(Z, $))
1441
- PZ(Z, q, $);
1428
+ Object.defineProperty(q, Z, Y);
1429
+ } : function(q, $, J, Z) {
1430
+ if (Z === undefined)
1431
+ Z = J;
1432
+ q[Z] = $[J];
1433
+ }), AZ = r && r.__exportStar || function(q, $) {
1434
+ for (var J in q)
1435
+ if (J !== "default" && !Object.prototype.hasOwnProperty.call($, J))
1436
+ EZ($, q, J);
1442
1437
  };
1443
- Object.defineProperty(a, "__esModule", { value: true });
1444
- a.fdir = undefined;
1445
- var OZ = Bq();
1446
- Object.defineProperty(a, "fdir", { enumerable: true, get: function() {
1447
- return OZ.Builder;
1438
+ Object.defineProperty(r, "__esModule", { value: true });
1439
+ r.fdir = undefined;
1440
+ var TZ = Tq();
1441
+ Object.defineProperty(r, "fdir", { enumerable: true, get: function() {
1442
+ return TZ.Builder;
1448
1443
  } });
1449
- TZ(Fq(), a);
1444
+ AZ(xq(), r);
1450
1445
  });
1451
- async function k1(q, Z) {
1452
- await Bun.write(q, Z);
1446
+ function _1(q, ...$) {
1447
+ if (!$.length)
1448
+ return q;
1449
+ let J = $.shift();
1450
+ if (B1(q) && B1(J)) {
1451
+ for (let Z in J)
1452
+ if (Object.prototype.hasOwnProperty.call(J, Z)) {
1453
+ let Y = J[Z];
1454
+ if (B1(Y) && B1(q[Z]))
1455
+ q[Z] = _1(q[Z], Y);
1456
+ else
1457
+ q[Z] = Y;
1458
+ }
1459
+ }
1460
+ return _1(q, ...$);
1453
1461
  }
1454
- async function y1(q) {
1455
- let Z = q ?? Z1.root, $ = await _q(Z, { withFileTypes: true }), J = await Promise.all($.map((j) => {
1456
- let z = g1(Z, j.name);
1457
- return j.isDirectory() ? y1(z) : z;
1458
- }));
1459
- return Array.prototype.concat(...J).filter((j) => Eq(j) === ".ts");
1462
+ function B1(q) {
1463
+ return q && typeof q === "object" && !Array.isArray(q);
1460
1464
  }
1461
- async function v1(q) {
1465
+ async function c1({ name: q, cwd: $, defaultConfig: J }) {
1466
+ let Z = $ ?? rq.cwd(), Y = nq(Z, `${q}.config`);
1462
1467
  try {
1463
- let Z = q?.tsconfigPath || g1(q?.root ?? Sq.cwd(), "tsconfig.json"), $ = await Rq(Z, "utf-8");
1464
- return JSON.parse($).compilerOptions?.isolatedDeclarations === true;
1465
- } catch (Z) {
1466
- return console.log("Error reading tsconfig.json:", Z), false;
1468
+ let j = await import(Y), Q = j.default || j;
1469
+ return _1(J, Q);
1470
+ } catch (j) {
1471
+ return console.error(`Error loading config from ${Y}:`, j), J;
1467
1472
  }
1468
1473
  }
1469
- function m1(q) {
1470
- let J = q.split("\n").map((j) => {
1471
- if (j = j.trimEnd(), j.startsWith("export interface") || j.startsWith("export type")) {
1472
- let z = j.split("{");
1473
- if (z.length > 1)
1474
- return `${z[0].trim()} {${z[1]}`;
1474
+ var q1 = await c1({ name: "dts", cwd: l1.cwd(), defaultConfig: { cwd: l1.cwd(), root: "./src", entrypoints: ["**/*.ts"], outdir: "./dist", keepComments: true, clean: true, tsconfigPath: "./tsconfig.json", verbose: false } });
1475
+ function O1(q) {
1476
+ if (w("params", `Cleaning parameters: ${q}`), !q.trim())
1477
+ return "";
1478
+ let $ = [], J = "", Z = 0, Y = false, j = "", Q = false;
1479
+ for (let U of q) {
1480
+ if (U === '"' || U === "\'" || U === "`") {
1481
+ if (!Y)
1482
+ Y = true, j = U;
1483
+ else if (U === j)
1484
+ Y = false;
1485
+ }
1486
+ if (!Y) {
1487
+ if (U === "{")
1488
+ Q = true, Z++;
1489
+ if (U === "}")
1490
+ Q = false, Z--;
1491
+ if (U === "<" || U === "(")
1492
+ Z++;
1493
+ if (U === ">" || U === ")")
1494
+ Z--;
1495
+ if (U === "," && Z === 0 && !Q) {
1496
+ if (J.trim())
1497
+ $.push(p1(J));
1498
+ J = "";
1499
+ continue;
1500
+ }
1475
1501
  }
1476
- if (j.endsWith(";"))
1477
- j = j.slice(0, -1);
1478
- return j;
1479
- }).join("\n");
1480
- return J = J.replace(/\n{3,}/g, "\n\n"), J = J.replace(/\/\*\*\n([^*]*)(\n \*\/)/g, (j, z) => {
1481
- return `/**\n${z.split("\n").map((B) => ` *${B.trim() ? ` ${B.trim()}` : ""}`).join("\n")}\n */`;
1482
- }), `${J.trim()}\n`;
1502
+ J += U;
1503
+ }
1504
+ if (J.trim())
1505
+ $.push(p1(J));
1506
+ let X = $.join(", ");
1507
+ return w("params", `Cleaned parameters: ${X}`), X;
1508
+ }
1509
+ function p1(q) {
1510
+ w("param-clean", `Cleaning parameter: ${q}`);
1511
+ let $ = q.match(/^([^:]+):\s*([^=]+)(?:=\s*.+)?$/);
1512
+ if ($) {
1513
+ let [, Z, Y] = $, j = Y.replace(/\s*&\s*/g, " & ").replace(/\s{2,}/g, " ").trim(), Q = `${Z.trim()}: ${j}`;
1514
+ return w("param-clean", `Cleaned to: ${Q}`), Q;
1515
+ }
1516
+ let J = q.match(/^([^=]+)=\s*(.+)$/);
1517
+ if (J) {
1518
+ let [, Z, Y] = J, j = G$(Y.trim()), Q = `${Z.trim()}: ${j}`;
1519
+ return w("param-clean", `Inferred type: ${Q}`), Q;
1520
+ }
1521
+ return q.trim();
1522
+ }
1523
+ async function o1(q) {
1524
+ try {
1525
+ let $ = await Bun.file(q).text();
1526
+ return oq($);
1527
+ } catch ($) {
1528
+ throw console.error("Failed to extract types:", $), new Error("Failed to extract and generate .d.ts file");
1529
+ }
1530
+ }
1531
+ function oq(q) {
1532
+ let $ = X$();
1533
+ q.split("\n").forEach((Z) => {
1534
+ if (Z.includes("import "))
1535
+ q0(Z, $.importTracking);
1536
+ }), A$(q, $), $.dtsLines.forEach((Z) => {
1537
+ if (Z.trim() && !Z.startsWith("import"))
1538
+ D$(Z, $.importTracking), k$(Z, $.importTracking);
1539
+ });
1540
+ let J = J$($.importTracking);
1541
+ return $.dtsLines = [...J.map((Z) => `${Z};`), "", ...$.dtsLines.filter((Z) => !Z.trim().startsWith("import"))], Y$($);
1542
+ }
1543
+ function aq(q) {
1544
+ w("signature-start", `Processing declaration: ${q}`);
1545
+ let $ = S$(q);
1546
+ w("signature-clean", `Clean declaration: ${$}`);
1547
+ let J = tq($), Z = $.slice($.indexOf(J) + J.length).trim();
1548
+ w("signature-content", `Content after name: ${Z}`);
1549
+ let { generics: Y, rest: j } = eq(Z);
1550
+ Z = j.trim(), w("signature-after-generics", `Remaining content: ${Z}`);
1551
+ let { params: Q, rest: X } = q$(Z);
1552
+ Z = X.trim(), w("signature-after-params", `Remaining content: ${Z}`);
1553
+ let { returnType: U } = $$(Z);
1554
+ w("signature-return", `Extracted return type: ${U}`);
1555
+ let z = { name: J, generics: Y, params: Q, returnType: U };
1556
+ return w("signature-final", `Final signature object: ${JSON.stringify(z, null, 2)}`), z;
1557
+ }
1558
+ function tq(q) {
1559
+ let $ = q.match(/^(?:export\s+)?(?:async\s+)?function\s*\*?\s*([^(<\s]+)/);
1560
+ if (!$)
1561
+ throw new Error("Invalid function declaration");
1562
+ return $[1];
1483
1563
  }
1484
- function u1(q) {
1564
+ function eq(q) {
1565
+ let $ = "";
1566
+ if (q.startsWith("<")) {
1567
+ let J = 1, Z = 0, Y = "<", j = false, Q = "";
1568
+ w("generics-input", `Starting generic extraction with: ${q}`);
1569
+ for (let X = 1;X < q.length; X++) {
1570
+ let U = q[X], z = X < q.length - 1 ? q[X + 1] : "", G = X > 0 ? q[X - 1] : "";
1571
+ if (w("generics-char", `Processing char: ${U}, next char: ${z}, depth: ${J}, pos: ${X}`), (U === '"' || U === "\'" || U === "`") && G !== "\\") {
1572
+ if (!j)
1573
+ j = true, Q = U, w("generics-string", `Entering string with ${Q}`);
1574
+ else if (U === Q)
1575
+ j = false, w("generics-string", "Exiting string");
1576
+ }
1577
+ if (!j) {
1578
+ if (U === "<")
1579
+ J++, w("generics-depth", `Increasing depth to ${J} at pos ${X}`);
1580
+ else if (U === ">") {
1581
+ if (J--, w("generics-depth", `Decreasing depth to ${J} at pos ${X}`), J === 0 && z === ">") {
1582
+ Y += ">>", Z = X + 1, w("generics-complete", `Found double closing bracket at pos ${X}, final buffer: ${Y}`);
1583
+ break;
1584
+ } else if (J === 0) {
1585
+ Y += ">", Z = X, w("generics-complete", `Found single closing bracket at pos ${X}, final buffer: ${Y}`);
1586
+ break;
1587
+ }
1588
+ }
1589
+ }
1590
+ if (J > 0)
1591
+ Y += U, w("generics-buffer", `Current buffer: ${Y}`);
1592
+ }
1593
+ if (Y)
1594
+ $ = Y, q = q.slice(Z + 1), w("generics-success", `Successfully extracted generics: ${$}`), w("generics-rest", `Remaining text: ${q}`);
1595
+ else
1596
+ w("generics-fail", `Failed to extract generics from: ${q}`);
1597
+ }
1598
+ return { generics: $, rest: q };
1599
+ }
1600
+ function q$(q) {
1601
+ let $ = "";
1602
+ if (q.includes("(")) {
1603
+ let J = q.indexOf("("), Z = 1, Y = J + 1, j = "";
1604
+ w("params-extraction-start", `Starting params extraction from pos ${Y}: ${q}`);
1605
+ for (;Y < q.length; Y++) {
1606
+ let Q = q[Y];
1607
+ if (Q === "(")
1608
+ Z++;
1609
+ if (Q === ")") {
1610
+ if (Z--, Z === 0) {
1611
+ w("params-depth-zero", `Found closing parenthesis at pos ${Y}`);
1612
+ break;
1613
+ }
1614
+ }
1615
+ j += Q;
1616
+ }
1617
+ $ = j.trim(), q = q.slice(Y + 1).trim(), w("signature-params", `Extracted params: ${$}`);
1618
+ }
1619
+ return { params: $, rest: q };
1620
+ }
1621
+ function $$(q) {
1622
+ let $ = "void";
1623
+ if (q.startsWith(":")) {
1624
+ w("return-start", `Starting return type extraction with: ${q}`), q = q.slice(1).trim();
1625
+ let J = 0, Z = "", Y = 0, j = false, Q = "", X = false;
1626
+ w("return-extraction", "Starting character-by-character extraction");
1627
+ while (Y < q.length && !X) {
1628
+ let U = q[Y], z = Y > 0 ? q[Y - 1] : "";
1629
+ if (w("return-char", `Pos ${Y}: Char "${U}", Depth ${J}, InString ${j}, Buffer length ${Z.length}`), (U === '"' || U === "\'" || U === "`") && z !== "\\") {
1630
+ if (!j)
1631
+ j = true, Q = U, w("return-string", `Entering string with ${Q}`);
1632
+ else if (U === Q)
1633
+ j = false, w("return-string", "Exiting string");
1634
+ }
1635
+ if (!j) {
1636
+ if (U === "{" || U === "<" || U === "(")
1637
+ J++, w("return-depth", `Opening bracket, increasing depth to ${J}`);
1638
+ else if (U === "}" || U === ">" || U === ")") {
1639
+ if (J--, w("return-depth", `Closing bracket, decreasing depth to ${J}`), J === 0 && U === "}") {
1640
+ if (Z += U, q.slice(Y + 1).trim()[0] === "{") {
1641
+ w("return-end", `Found end of return type at pos ${Y}, next char is function body`), X = true;
1642
+ break;
1643
+ }
1644
+ }
1645
+ }
1646
+ if (J === 0 && U === ";") {
1647
+ w("return-end", "Found semicolon at depth 0"), X = true;
1648
+ break;
1649
+ }
1650
+ }
1651
+ Z += U, w("return-buffer", `Updated buffer: ${Z}`), Y++;
1652
+ }
1653
+ $ = Z.trim(), w("return-final", `Final extracted return type: ${$}`);
1654
+ }
1655
+ return { returnType: $ };
1656
+ }
1657
+ function f1(q) {
1658
+ w("extract-function", `Extracting function type from: ${q}`);
1659
+ let $ = q.trim(), J = 0, Z = $.length;
1660
+ if (!$.startsWith("(")) {
1661
+ let H = $.match(/^function\s*\w*\s*\((.*?)\)/s);
1662
+ if (H) {
1663
+ let [, W] = H, I = O1(W || ""), _ = $.match(/\):\s*([^{;]+)(?:[{;]|$)/), S = _ ? L$(_[1]) : "unknown";
1664
+ return `(${I}) => ${S}`;
1665
+ }
1666
+ return null;
1667
+ }
1668
+ J++;
1669
+ let Y = 1, j = J, Q = false, X = "";
1670
+ for (;J < Z; J++) {
1671
+ let H = $[J], W = J > 0 ? $[J - 1] : "";
1672
+ if (Q) {
1673
+ if (H === X && W !== "\\")
1674
+ Q = false;
1675
+ else if (H === "\\")
1676
+ J++;
1677
+ } else if (H === '"' || H === "\'" || H === "`")
1678
+ Q = true, X = H;
1679
+ else if (H === "(")
1680
+ Y++;
1681
+ else if (H === ")") {
1682
+ if (Y--, Y === 0)
1683
+ break;
1684
+ }
1685
+ }
1686
+ if (Y !== 0)
1687
+ return w("extract-function", "Unbalanced parentheses in function parameters"), null;
1688
+ let U = J, z = $.slice(j, U);
1689
+ J++;
1690
+ while (J < Z && /\s/.test($[J]))
1691
+ J++;
1692
+ let G = "unknown";
1693
+ if ($[J] === ":") {
1694
+ J++;
1695
+ while (J < Z && /\s/.test($[J]))
1696
+ J++;
1697
+ let H = J;
1698
+ while (J < Z && !$.startsWith("=>", J) && $[J] !== "{")
1699
+ J++;
1700
+ let W = J;
1701
+ G = $.slice(H, W).trim();
1702
+ }
1703
+ while (J < Z && /\s/.test($[J]))
1704
+ J++;
1705
+ if ($.startsWith("=>", J))
1706
+ J += 2;
1707
+ else
1708
+ return w("extract-function", 'Function expression missing "=>"'), null;
1709
+ let V = O1(z || "");
1710
+ return w("extract-function", `Extracted function type: (${V}) => ${G}`), `(${V}) => ${G}`;
1711
+ }
1712
+ function J$(q) {
1713
+ let $ = [], J = new Set;
1714
+ w("import-gen", `Generating optimized imports. ${q.exportedTypes.size} exported types`);
1715
+ for (let [Z, Y] of q.typeImports) {
1716
+ w("import-type-check", `Checking types from ${Z}: ${Array.from(Y).join(", ")}`);
1717
+ let j = Array.from(Y).filter((Q) => {
1718
+ let X = q.exportedTypes.has(Q) || q.usedTypes.has(Q);
1719
+ return w("import-type-filter", `Type ${Q}: exported=${q.exportedTypes.has(Q)}, used=${q.usedTypes.has(Q)}`), X;
1720
+ }).map((Q) => {
1721
+ let X = q.valueAliases.get(Q);
1722
+ return X ? `${Q} as ${X}` : Q;
1723
+ }).sort();
1724
+ if (j.length > 0) {
1725
+ let Q = `import type { ${j.join(", ")} } from '${Z}'`;
1726
+ if (!J.has(Q))
1727
+ $.push(Q), J.add(Q), w("import-add-type", `Added type import: ${Q}`);
1728
+ }
1729
+ }
1730
+ for (let [Z, Y] of q.valueImports) {
1731
+ let j = new Map, Q = Array.from(Y).filter((X) => {
1732
+ let U = Array.from(q.valueAliases.entries()).find(([G, V]) => V === X)?.[0], z = q.exportedValues.has(X) || q.usedValues.has(X) || X === q.defaultExportValue || U && (q.exportedValues.has(U) || U === q.defaultExportValue);
1733
+ if (z && U)
1734
+ j.set(X, U);
1735
+ return z;
1736
+ }).map((X) => {
1737
+ let U = j.get(X);
1738
+ return U ? `${X} as ${U}` : X;
1739
+ }).sort();
1740
+ if (Q.length > 0) {
1741
+ let X = `import { ${Q.join(", ")} } from '${Z}'`;
1742
+ if (!J.has(X))
1743
+ $.push(X), J.add(X), w("import-add-value", `Added value import: ${X}`);
1744
+ }
1745
+ }
1746
+ return $.sort();
1747
+ }
1748
+ function Z$(q) {
1749
+ let $ = q.trim();
1750
+ if (!$.startsWith("{"))
1751
+ return null;
1752
+ let J = 0, Z = false, Y = "";
1753
+ for (let j = 0;j < $.length; j++) {
1754
+ let Q = $[j], X = j > 0 ? $[j - 1] : "";
1755
+ if ((Q === '"' || Q === "\'" || Q === "`") && X !== "\\") {
1756
+ if (!Z)
1757
+ Z = true, Y = Q;
1758
+ else if (Q === Y)
1759
+ Z = false;
1760
+ continue;
1761
+ }
1762
+ if (!Z) {
1763
+ if (Q === "{")
1764
+ J++;
1765
+ else if (Q === "}") {
1766
+ if (J--, J === 0)
1767
+ return $.slice(0, j + 1);
1768
+ }
1769
+ }
1770
+ }
1771
+ return null;
1772
+ }
1773
+ function Y$(q) {
1774
+ let $ = new Set;
1775
+ q.dtsLines.filter((j) => j.startsWith("import")).forEach((j) => $.add(j.replace(/;+$/, "")));
1776
+ let J = q.dtsLines.filter((j) => !j.startsWith("import")).map((j) => {
1777
+ let Q = j.trim();
1778
+ if (!Q)
1779
+ return "";
1780
+ if (Q.startsWith("export *") || Q.endsWith(";"))
1781
+ return Q;
1782
+ if (Q.startsWith("export type"))
1783
+ return `${Q};`;
1784
+ return Q.replace(/;+$/, ";");
1785
+ }), Z = Array.from(q.defaultExports).map((j) => j.trim().replace(/;+$/, ";"));
1786
+ return `${[...Array.from($).map((j) => `${j};`), "", ...J.filter(Boolean), "", ...Z].map((j) => j.replace(/\/\*[\s\S]*?\*\/|\/\/.*/g, "")).filter((j) => j.trim() || j === "").join("\n")}`.trim();
1787
+ }
1788
+ function j$(q) {
1789
+ let $ = q.split("\n"), J = 0;
1790
+ while (J < $.length) {
1791
+ let Z = $[J].trim();
1792
+ if (Z.startsWith("//") || Z.startsWith("/*") || Z.startsWith("*") || Z === "")
1793
+ J++;
1794
+ else
1795
+ break;
1796
+ }
1797
+ return $.slice(J).join("\n");
1798
+ }
1799
+ function X$() {
1800
+ return { dtsLines: [], imports: [], usedTypes: new Set, typeSources: new Map, defaultExport: null, exportAllStatements: [], currentDeclaration: "", lastCommentBlock: "", bracketCount: 0, isMultiLineDeclaration: false, moduleImports: new Map, availableTypes: new Map, availableValues: new Map, currentIndentation: "", declarationBuffer: null, importTracking: Q$(), defaultExports: new Set, currentScope: "top" };
1801
+ }
1802
+ function Q$() {
1803
+ return { typeImports: new Map, valueImports: new Map, usedTypes: new Set, usedValues: new Set, exportedTypes: new Set, exportedValues: new Set, valueAliases: new Map, importSources: new Map, typeExportSources: new Map, defaultExportValue: undefined };
1804
+ }
1805
+ function i1(q, $, J) {
1485
1806
  let Z = q.split("\n");
1486
- return Z.map(($, J) => {
1487
- if (J === 0)
1488
- return "/**";
1489
- if (J === Z.length - 1)
1490
- return " */";
1491
- return ` * ${$.replace(/^\s*\*?\s?/, "").trim()}`;
1492
- }).join("\n");
1807
+ if (Z.length === 1)
1808
+ return `${$}${q}${J ? "" : " |"}`;
1809
+ let Y = [], j = false, Q = 0;
1810
+ return Z.forEach((U) => {
1811
+ let z = U.trim();
1812
+ if (z.startsWith("Array<"))
1813
+ Q = 0;
1814
+ if (z === "}" || z.startsWith("> |") || z === ">")
1815
+ j = Q === 1;
1816
+ if (z && !z.startsWith("Array<") && !z.endsWith(">") && !z.startsWith("{") && !z.endsWith("}"))
1817
+ Q++;
1818
+ }), Z.map((U, z) => {
1819
+ let G = U.trim();
1820
+ if (!G)
1821
+ return "";
1822
+ let V = $;
1823
+ if (z > 0) {
1824
+ let _ = Y.reduce((S, E) => S + E.depth, 0);
1825
+ if (V = $ + " ".repeat(_), G.match(/^['"]/))
1826
+ V += " ";
1827
+ if ((G.startsWith("}") || G.startsWith(">") || G.startsWith("> |")) && Y.length > 0)
1828
+ V = $ + " ".repeat(Math.max(0, _ - 1));
1829
+ }
1830
+ let H = G.match(/[{<[]/g) || [], W = G.match(/[}\]>]/g) || [];
1831
+ if (H.forEach((_) => {
1832
+ let S = G.startsWith("Array") && _ === "<";
1833
+ Y.push({ char: _, indent: V, isArray: S, depth: 1, isSingleElement: j });
1834
+ }), W.length > 0) {
1835
+ for (let _ = 0;_ < W.length; _++)
1836
+ if (Y.length > 0)
1837
+ Y.pop();
1838
+ }
1839
+ let I = false;
1840
+ if (!J && z === Z.length - 1 && !G.endsWith(" |") && !G.endsWith(";"))
1841
+ I = true;
1842
+ if (G === "}") {
1843
+ if ([...Y].reverse().find((S) => S.isArray)?.isSingleElement)
1844
+ I = false;
1845
+ }
1846
+ if (G.endsWith(" |"))
1847
+ I = false;
1848
+ return `${V}${G}${I ? " |" : ""}`;
1849
+ }).filter(Boolean).join("\n");
1493
1850
  }
1494
- function Q1(q, ...Z) {
1495
- if (!Z.length)
1496
- return q;
1497
- let $ = Z.shift();
1498
- if (B1(q) && B1($)) {
1499
- for (let J in $)
1500
- if (Object.prototype.hasOwnProperty.call($, J)) {
1501
- let j = $[J];
1502
- if (B1(j) && B1(q[J]))
1503
- q[J] = Q1(q[J], j);
1504
- else
1505
- q[J] = j;
1851
+ function U$(q) {
1852
+ let $ = q.split("\n").map((Z) => Z.trim()).join(" ");
1853
+ if (/^['"`].*['"`]$/.test($))
1854
+ return $;
1855
+ if (!Number.isNaN(Number($)))
1856
+ return $;
1857
+ if ($ === "true" || $ === "false")
1858
+ return $;
1859
+ let J = $.match(/\([^)]*\)\s*:\s*([^=>{]+)/);
1860
+ if (J)
1861
+ return J[1].trim();
1862
+ if ($.includes("=>"))
1863
+ return "(...args: any[]) => unknown";
1864
+ return "unknown";
1865
+ }
1866
+ function w1(q, $, J = false) {
1867
+ let Z = q.slice(1, -1).trim(), Y = q.trim().endsWith("as const");
1868
+ if (!Z)
1869
+ return Y ? "readonly unknown[]" : "unknown[]";
1870
+ let j = Y0(Z);
1871
+ if (Y || j.some((z) => z.includes("as const"))) {
1872
+ let z = j.map((G) => {
1873
+ let V = G.trim().replace(/\s*as\s*const\s*$/, "").trim();
1874
+ return a1(V, $);
1875
+ });
1876
+ if (B$(z))
1877
+ return `readonly [\n${z.map((V, H) => i1(V, " ", H === z.length - 1)).join("\n")}\n ]`;
1878
+ return `readonly [${z.join(", ")}]`;
1879
+ }
1880
+ let X = j.map((z) => {
1881
+ let G = z.trim();
1882
+ if (G.startsWith("["))
1883
+ return w1(G, $);
1884
+ else if (G.startsWith("{"))
1885
+ return $1(G, $);
1886
+ else if (G.includes("=>") || G.includes("function")) {
1887
+ let V = f1(G);
1888
+ return V ? `(${V})` : "((...args: any[]) => unknown)";
1889
+ } else
1890
+ return w$(G);
1891
+ }).filter(Boolean);
1892
+ if (X.some((z) => z.includes("\n") || z.includes("{") || z.length > 40 || X.join(" | ").length > 60) && J)
1893
+ return `Array<\n${X.map((G, V) => i1(G, " ", V === X.length - 1)).join("\n")}\n >`;
1894
+ return `Array<${X.join(" | ")}>`;
1895
+ }
1896
+ function $1(q, $, J = 0) {
1897
+ let Z = Z$(q);
1898
+ if (!Z)
1899
+ return "Record<string, unknown>";
1900
+ let Y = " ".repeat(J), j = " ".repeat(J + 1), Q = Y, X = C$(Z, $, J);
1901
+ if (!X.length)
1902
+ return "{}";
1903
+ return `{\n${X.map(({ key: z, value: G }) => {
1904
+ return `${j}${z}: ${G}`;
1905
+ }).join(";\n")}\n${Q}}`;
1906
+ }
1907
+ function a1(q, $) {
1908
+ if (/^['"`].*['"`]$/.test(q))
1909
+ return `'${q.replace(/\]\s*as\s*cons.*$/, "").replace(/^['"`]|['"`]$/g, "")}'`;
1910
+ if (q.startsWith("[")) {
1911
+ let Z = q.slice(1, -1).trim();
1912
+ return `readonly [${Y0(Z).map((Q) => {
1913
+ let X = Q.trim();
1914
+ if (X.includes("] as cons") || X.includes("] as const"))
1915
+ X = X.replace(/\]\s*as\s*cons.*$/, "").replace(/\]\s*as\s*const.*$/, "").trim();
1916
+ if (X.startsWith("["))
1917
+ return a1(X, $);
1918
+ if (X.startsWith("{"))
1919
+ return $1(X, $).replace(/^\{/, "{ readonly").replace(/;\s+/g, "; readonly ");
1920
+ if (/^['"`].*['"`]$/.test(X))
1921
+ return `'${X.replace(/^['"`]|['"`]$/g, "")}'`;
1922
+ if (!Number.isNaN(Number(X)))
1923
+ return X;
1924
+ if (X === "true" || X === "false")
1925
+ return X;
1926
+ return `'${X.replace(/\]\s*as\s*cons.*$/, "").replace(/\]\s*as\s*const.*$/, "").replace(/^['"`]|['"`]$/g, "").trim()}'`;
1927
+ }).join(", ")}]`;
1928
+ }
1929
+ return `'${q.replace(/\]\s*as\s*cons.*$/, "").replace(/\]\s*as\s*const.*$/, "").replace(/^['"`]|['"`]$/g, "").trim()}'`;
1930
+ }
1931
+ function z$(q, $) {
1932
+ if (q.startsWith("{"))
1933
+ return $1(q, $);
1934
+ if (q.startsWith("["))
1935
+ return w1(q, $, true);
1936
+ return q;
1937
+ }
1938
+ function G$(q) {
1939
+ if (/^['"`].*['"`]$/.test(q))
1940
+ return "string";
1941
+ if (!Number.isNaN(Number(q)))
1942
+ return "number";
1943
+ if (q === "true" || q === "false")
1944
+ return "boolean";
1945
+ if (q.startsWith("["))
1946
+ return "unknown[]";
1947
+ if (q.startsWith("{"))
1948
+ return "object";
1949
+ if (q === "null")
1950
+ return "null";
1951
+ if (q === "undefined")
1952
+ return "undefined";
1953
+ return "unknown";
1954
+ }
1955
+ function t1(q) {
1956
+ return q.trim().startsWith("export default");
1957
+ }
1958
+ function F$(q) {
1959
+ if (K$(q))
1960
+ return false;
1961
+ let $ = q.trim();
1962
+ if (/^(?:export\s+)?(?:async\s+)?function\s*\*?\s*[a-zA-Z_$][\w$]*/.test($))
1963
+ return true;
1964
+ return $.startsWith("export ") || $.startsWith("interface ") || $.startsWith("type ") || $.startsWith("const ") || $.startsWith("function ") || $.startsWith("async function ") || $.startsWith("declare ") || $.startsWith("declare module") || /^export\s+(?:interface|type|const|function\*?|async\s+function\*?)/.test($);
1965
+ }
1966
+ function K$(q) {
1967
+ return q.includes("\\") || q.includes("[^") || q.includes("(?:") || q.includes("(?=") || q.includes("(?!") || q.includes("\\s*") || q.includes("\\w+") || q.includes("\\d+") || q.includes("(?<") || q.includes("(?!") || q.includes("(?<=") || q.includes("(?<!");
1968
+ }
1969
+ function e1(q, $) {
1970
+ let J = q.trim();
1971
+ return $.currentScope === "function" && (J.startsWith("const ") || J.startsWith("let ") || J.startsWith("var ") || /^(?:const|let|var)\s+[a-zA-Z_$][\w$]*\s*(?::|=)/.test(J));
1972
+ }
1973
+ function B$(q) {
1974
+ return q.some(($) => $.includes("\n") || $.includes("{") || $.length > 40 || q.join(" | ").length > 60);
1975
+ }
1976
+ function w$(q) {
1977
+ if (q.includes("=>") || q.match(/\bfunction\b/))
1978
+ return "((...args: any[]) => unknown)";
1979
+ if (q.match(/\w+\s*\([^)]*\)/))
1980
+ return "unknown";
1981
+ if (q.startsWith("new "))
1982
+ return "unknown";
1983
+ if (q.includes("."))
1984
+ return "unknown";
1985
+ if (/^[a-z_$][\w$]*$/i.test(q) && !["unknown", "string", "number", "boolean", "null", "undefined", "any", "never", "void"].includes(q) && !/^['"`]|^\d/.test(q) && q !== "true" && q !== "false")
1986
+ return "unknown";
1987
+ return q;
1988
+ }
1989
+ function R1(q, $, J) {
1990
+ w("block-processing", "Starting block processing");
1991
+ let Z = [], Y = 0, j = 0, Q = 0, X = false, U = q.length;
1992
+ w("block-scan", `Total available lines: ${U}`);
1993
+ while (Q < U) {
1994
+ let V = q[Q], H = V.trim(), W = (V.match(/\{/g) || []).length, I = (V.match(/\}/g) || []).length, _ = (V.match(/</g) || []).length, S = (V.match(/>/g) || []).length;
1995
+ if (w("block-scan-details", `Scanning line ${Q + 1}: "${H}" Current depths - Bracket: ${Y}, Angle: ${j} Found body: ${X} Changes - Curly: +${W}/-${I}, Angle: +${_}/-${S}`), Z.push(V), Y += W - I, j += _ - S, H.includes("{"))
1996
+ X = true, w("block-scan", `Found body start at line ${Q + 1}`);
1997
+ if (w("block-collection", `Line ${Q + 1}: "${H}" Updated depths - Bracket: ${Y}, Angle: ${j} Found body: ${X}`), Y === 0 && (j === 0 || X) && H.endsWith("}") && X) {
1998
+ w("block-scan", `Found complete block at line ${Q + 1}`);
1999
+ break;
2000
+ }
2001
+ Q++;
2002
+ }
2003
+ let z = Z.join("\n");
2004
+ w("block-scan", `Collected block:\n${z}`);
2005
+ let G = j$(z).trim();
2006
+ if (w("block-processing", `Full block content:\n${G}`), !G) {
2007
+ w("block-processing", "Empty declaration block");
2008
+ return;
2009
+ }
2010
+ if (e1(G, J)) {
2011
+ w("block-processing", "Skipping variable declaration inside function");
2012
+ return;
2013
+ }
2014
+ if (G.startsWith("interface") || G.startsWith("export interface")) {
2015
+ if (w("block-processing", "Processing interface declaration using interface block processor"), N$(G, z, J)) {
2016
+ w("block-processing", "Interface successfully processed");
2017
+ return;
2018
+ }
2019
+ }
2020
+ if (G.includes("\n\nexport function") || G.includes("\n\nfunction")) {
2021
+ let V = b$(G);
2022
+ if (V.length > 1) {
2023
+ w("block-processing", `Found ${V.length} function declarations to process`), V.forEach((H) => {
2024
+ let W = H.split("\n");
2025
+ R1(W, $, J);
2026
+ });
2027
+ return;
2028
+ }
2029
+ }
2030
+ if (V$(G, J))
2031
+ return;
2032
+ if (M$(G, q, J))
2033
+ return;
2034
+ if (H$(G, z, J))
2035
+ return;
2036
+ if (I$(G, J))
2037
+ return;
2038
+ if (W$(G, J))
2039
+ return;
2040
+ if (_$(G, z, J))
2041
+ return;
2042
+ if (E$(G, z, J))
2043
+ return;
2044
+ w("processing", `Unhandled declaration type: ${G.split("\n")[0]}`);
2045
+ }
2046
+ function M$(q, $, J) {
2047
+ if (!q.match(/^(?:export\s+)?(const|let|var)\s+/))
2048
+ return false;
2049
+ if (e1(q, J))
2050
+ return w("variable-processing", "Skipping variable inside function"), true;
2051
+ let Y = q.startsWith("export");
2052
+ if (J.currentScope === "top") {
2053
+ let j = $.join("\n");
2054
+ J.dtsLines.push(J0(j, Y, J));
2055
+ } else
2056
+ w("block-processing", "Skipping variable declared inside a function");
2057
+ return true;
2058
+ }
2059
+ function V$(q, $) {
2060
+ if (w("function-processing", `Processing potential function block: ${q.slice(0, 100)}...`), /^(?:export\s+)?(?:async\s+)?function\s*\*/.test(q)) {
2061
+ w("block-processing", "Processing generator function declaration");
2062
+ let z = x$(q);
2063
+ if (z)
2064
+ return $.dtsLines.push(z), true;
2065
+ }
2066
+ if (!/^(?:export\s+)?(?:async\s+)?function\s+[a-zA-Z_$][\w$]*/.test(q))
2067
+ return false;
2068
+ w("block-processing", "Processing function declaration");
2069
+ let J = q.split(/[\n;]/).map((z) => z.trim()).filter((z) => z.startsWith("export function") || z.startsWith("function"));
2070
+ if (J.length > 1)
2071
+ return J.forEach((z) => {
2072
+ if (!z.endsWith("{")) {
2073
+ let G = P1(z, $.usedTypes, z.startsWith("export"));
2074
+ if (G)
2075
+ $.dtsLines.push(G);
2076
+ }
2077
+ }), true;
2078
+ let Z = 0, Y = 0, j = 0;
2079
+ for (let z = 0;z < q.length; z++) {
2080
+ let G = q[z];
2081
+ if (G === "(")
2082
+ Y++;
2083
+ if (G === ")")
2084
+ Y--;
2085
+ if (G === "<")
2086
+ j++;
2087
+ if (G === ">")
2088
+ j--;
2089
+ if (G === "{") {
2090
+ if (Y === 0 && j === 0) {
2091
+ Z = z;
2092
+ break;
1506
2093
  }
2094
+ }
1507
2095
  }
1508
- return Q1(q, ...Z);
2096
+ if (Z === 0)
2097
+ Z = q.length;
2098
+ let Q = q.slice(0, Z).trim();
2099
+ w("signature-extraction", `Extracted signature: ${Q}`);
2100
+ let X = Q.startsWith("export"), U = P1(Q, $.usedTypes, X);
2101
+ if (U)
2102
+ w("function-processed", `Generated declaration: ${U}`), $.dtsLines.push(U);
2103
+ return true;
1509
2104
  }
1510
- function B1(q) {
1511
- return q && typeof q === "object" && !Array.isArray(q);
2105
+ function N$(q, $, J) {
2106
+ if (w("interface-processing", `Starting interface processing with declaration: ${q.slice(0, 100)}...`), !q.startsWith("interface") && !q.startsWith("export interface"))
2107
+ return w("interface-processing", "Not an interface declaration, skipping"), false;
2108
+ let Z = $.split("\n"), Y = 0, j = 0, Q = [], X = true, U = false;
2109
+ w("interface-processing", `Processing ${Z.length} lines`);
2110
+ for (let H = 0;H < Z.length; H++) {
2111
+ let W = Z[H], I = W.trim(), _ = (W.match(/\{/g) || []).length, S = (W.match(/\}/g) || []).length, E = (W.match(/</g) || []).length, A = (W.match(/>/g) || []).length;
2112
+ if (Y += _ - S, j += E - A, I.includes("{"))
2113
+ U = true;
2114
+ if (w("interface-depth", `Line ${H + 1}: "${I}" Bracket depth: ${Y}, Angle depth: ${j}, Has started body: ${U}`), X) {
2115
+ let m = I.startsWith("export") ? "export declare" : "declare";
2116
+ Q.push(W.replace(/^(\s*)(?:export\s+)?interface/, `$1${m} interface`)), X = false;
2117
+ } else
2118
+ Q.push(W);
2119
+ }
2120
+ let z = Q.join("\n"), G = z.includes("{") && z.includes("}");
2121
+ if (Y === 0 && (j === 0 || z.includes(">")) && G)
2122
+ return w("interface-processing", `Successfully processed interface:\n${z}`), J.dtsLines.push(z), true;
2123
+ return w("interface-processing", `Interface processing incomplete. Bracket depth: ${Y}, Angle depth: ${j}, Has started body: ${U}`), false;
1512
2124
  }
1513
- async function bq({ name: q, cwd: Z, defaultConfig: $ }) {
1514
- let J = Z ?? I1.cwd(), j = xq(J, `${q}.config`);
1515
- if (Aq(j))
1516
- try {
1517
- let z = await import(j), U = z.default || z;
1518
- return Q1($, U);
1519
- } catch (z) {
1520
- console.error(`Error loading config from ${j}:`, z);
2125
+ function H$(q, $, J) {
2126
+ if (!q.startsWith("type") && !q.startsWith("export type"))
2127
+ return false;
2128
+ let Z = q.startsWith("export");
2129
+ return J.dtsLines.push($0($, Z)), true;
2130
+ }
2131
+ function I$(q, $) {
2132
+ if (!t1(q))
2133
+ return false;
2134
+ let J = q.replace(/^export\s+default\s+/, "").replace(/;$/, "");
2135
+ $.importTracking.defaultExportValue = J;
2136
+ let Z = q.endsWith(";") ? q : `${q};`;
2137
+ return $.defaultExports.add(Z), true;
2138
+ }
2139
+ function W$(q, $) {
2140
+ if (!q.startsWith("export *"))
2141
+ return false;
2142
+ return $.exportAllStatements.push(q), $.dtsLines.push(q), true;
2143
+ }
2144
+ function _$(q, $, J) {
2145
+ if (!q.startsWith("export"))
2146
+ return false;
2147
+ if (R$(q, J))
2148
+ return true;
2149
+ if (P$(q, J))
2150
+ return true;
2151
+ if (f$(q, J))
2152
+ return true;
2153
+ if (q.startsWith("export {"))
2154
+ return J.dtsLines.push($), true;
2155
+ return w("processing", `Unhandled exported declaration type: ${q.split("\n")[0]}`), true;
2156
+ }
2157
+ function O$(q, $) {
2158
+ w("export-processing", `Processing export: ${q}`);
2159
+ let J = q.match(/export\s*\{([^}]+)\}(?:\s*from\s*['"]([^'"]+)['"])?/);
2160
+ if (!J) {
2161
+ w("export-error", "Failed to match export pattern");
2162
+ return;
2163
+ }
2164
+ let [, Z, Y] = J;
2165
+ w("export-found", `Found exports: ${Z}, source: ${Y || "local"}`), Z.split(",").forEach((j) => {
2166
+ let [Q, X] = j.trim().split(/\s+as\s+/).map((U) => U.trim());
2167
+ if (Q.startsWith("type ")) {
2168
+ let U = Q.replace(/^type\s+/, "").trim(), z = X || U;
2169
+ if ($.importTracking.exportedTypes.add(z), Y)
2170
+ $.importTracking.typeExportSources.set(z, Y);
2171
+ w("export-type-processed", `Added exported type: ${z}`);
2172
+ } else {
2173
+ let U = X || Q;
2174
+ $.importTracking.exportedValues.add(U), w("export-value-processed", `Added exported value: ${U}`);
1521
2175
  }
1522
- return $;
2176
+ });
1523
2177
  }
1524
- var Z1 = await bq({ name: "dts", cwd: I1.cwd(), defaultConfig: { cwd: I1.cwd(), root: "./src", entrypoints: ["**/*.ts"], outdir: "./dist", keepComments: true, clean: true, tsconfigPath: "./tsconfig.json" } });
1525
- async function h1(q) {
1526
- let Z = await gq(q, "utf-8"), $ = "", J = new Set, j = new Map, z = /export\s*(?:\*|\{[^}]*\})\s*from\s*['"][^'"]+['"]/g, U = Z.match(z) || [];
1527
- $ += `${U.join("\n")}\n`;
1528
- let B = /import\s+(?:(type)\s+)?(?:(\{[^}]+\})|(\w+))(?:\s*,\s*(?:(\{[^}]+\})|(\w+)))?\s+from\s+['"]([^'"]+)['"]/g;
1529
- Array.from(Z.matchAll(B)).forEach(([, H, P, N, G, h, C]) => {
1530
- if (!j.has(C))
1531
- j.set(C, new Set);
1532
- let I = (g, i) => {
1533
- if (g)
1534
- g.replace(/[{}]/g, "").split(",").map((x) => {
1535
- let [m, w] = x.split(" as ").map((y) => y.trim());
1536
- return { name: m.replace(/^type\s+/, ""), alias: w || m.replace(/^type\s+/, "") };
1537
- }).forEach(({ name: x }) => {
1538
- j.get(C).add(x);
1539
- });
1540
- };
1541
- if (I(P, !!H), I(G, !!H), N)
1542
- j.get(C).add(N);
1543
- if (h)
1544
- j.get(C).add(h);
2178
+ function R$(q, $) {
2179
+ if (!q.startsWith("export class") && !q.startsWith("export abstract class"))
2180
+ return false;
2181
+ let J = `export declare ${q.replace(/^export\s+/, "")}`;
2182
+ return $.dtsLines.push(J), true;
2183
+ }
2184
+ function P$(q, $) {
2185
+ if (!q.startsWith("export enum") && !q.startsWith("export const enum"))
2186
+ return false;
2187
+ let J = `export declare ${q.replace(/^export\s+/, "")}`;
2188
+ return $.dtsLines.push(J), true;
2189
+ }
2190
+ function f$(q, $) {
2191
+ if (!q.startsWith("export namespace"))
2192
+ return false;
2193
+ let J = `export declare ${q.replace(/^export\s+/, "")}`;
2194
+ return $.dtsLines.push(J), true;
2195
+ }
2196
+ function E$(q, $, J) {
2197
+ if (!q.startsWith("declare module"))
2198
+ return false;
2199
+ let Z = Z0($);
2200
+ return J.dtsLines.push(Z), true;
2201
+ }
2202
+ function A$(q, $) {
2203
+ let J = q.split("\n"), Z = [], Y = [], j = 0, Q = 0, X = false;
2204
+ $.currentScope = "top", w("source-processing", `Processing source file with ${J.length} lines`);
2205
+ for (let U = 0;U < J.length; U++) {
2206
+ let z = J[U], G = z.trim();
2207
+ if (w("source-scan", `First pass - Line ${U + 1}: ${G}`), z.includes("import "))
2208
+ q0(z, $.importTracking), w("import", `Processed import: ${z}`);
2209
+ if (G.startsWith("export type {")) {
2210
+ w("type-export", `Found type export: ${G}`), T$(G, $), $.dtsLines.push(z);
2211
+ continue;
2212
+ }
2213
+ if (G.startsWith("export {")) {
2214
+ w("mixed-export", `Found mixed export: ${G}`), O$(G, $), $.dtsLines.push(z);
2215
+ continue;
2216
+ }
2217
+ }
2218
+ for (let U = 0;U < J.length; U++) {
2219
+ let z = J[U], G = z.trim();
2220
+ if (G.startsWith("import ") || G.startsWith("export type {") || G.startsWith("export {"))
2221
+ continue;
2222
+ if (G.startsWith("/*") || G.startsWith("//")) {
2223
+ Y.push(z);
2224
+ continue;
2225
+ }
2226
+ let V = (z.match(/\{/g) || []).length, H = (z.match(/\}/g) || []).length, W = (z.match(/</g) || []).length, I = (z.match(/>/g) || []).length;
2227
+ if (!X && F$(G)) {
2228
+ w("declaration", `Found declaration start: ${G}`), X = true, Z = [z], j = V - H, Q = W - I;
2229
+ continue;
2230
+ }
2231
+ if (X) {
2232
+ Z.push(z), j += V - H, Q += W - I;
2233
+ let _ = j === 0 && Q === 0 && G.endsWith("}"), S = U < J.length - 1 ? J[U + 1]?.trim() : "";
2234
+ if (!(j > 0 || Q > 0 || S && !S.startsWith("export") && !S.startsWith("interface")) || _)
2235
+ w("declaration-complete", `Declaration complete at line ${U + 1}`), R1(Z, Y, $), Z = [], Y = [], X = false, j = 0, Q = 0;
2236
+ }
2237
+ }
2238
+ if (Z.length > 0)
2239
+ R1(Z, Y, $);
2240
+ }
2241
+ function q0(q, $) {
2242
+ w("import-processing", `Processing import line: ${q}`);
2243
+ let J = q.match(/import\s+type\s*(?:\{([^}]+)\}|([^;\s]+))\s*from\s*['"]([^'"]+)['"]/);
2244
+ if (J) {
2245
+ let [, Y, j, Q] = J, X = Y || j;
2246
+ if (w("import-type", `Found type imports from ${Q}: ${X}`), !$.typeImports.has(Q))
2247
+ $.typeImports.set(Q, new Set);
2248
+ if (X)
2249
+ X.split(",").forEach((U) => {
2250
+ let [z, G] = U.trim().split(/\s+as\s+/).map((V) => V.trim());
2251
+ if ($.typeImports.get(Q).add(z), $.typeExportSources.set(z, Q), w("import-type-tracking", `Tracking type ${z} from ${Q}`), G)
2252
+ $.valueAliases.set(G, z), w("import-alias", `Registered type alias: ${z} as ${G}`);
2253
+ });
2254
+ return;
2255
+ }
2256
+ let Z = q.match(/import\s*\{([^}]+)\}\s*from\s*['"]([^'"]+)['"]/);
2257
+ if (Z) {
2258
+ let [, Y, j] = Z;
2259
+ if (w("import-value", `Found value imports from ${j}: ${Y}`), !$.valueImports.has(j))
2260
+ $.valueImports.set(j, new Set);
2261
+ Y.split(",").forEach((Q) => {
2262
+ let [X, U] = Q.trim().split(/\s+as\s+/).map((z) => z.trim());
2263
+ if (X.startsWith("type ")) {
2264
+ let z = X.replace(/^type\s+/, "").trim();
2265
+ if (!$.typeImports.has(j))
2266
+ $.typeImports.set(j, new Set);
2267
+ $.typeImports.get(j).add(z), $.typeExportSources.set(z, j), w("import-type-in-value", `Found inline type import: ${z} from ${j}`);
2268
+ } else if ($.valueImports.get(j).add(X), $.importSources.set(X, j), U) {
2269
+ if ($.valueAliases.set(U, X), U === $.defaultExportValue)
2270
+ $.usedValues.add(X);
2271
+ $.valueImports.get(j).add(X), w("import-alias", `Registered value alias: ${X} as ${U}`);
2272
+ }
2273
+ });
2274
+ }
2275
+ }
2276
+ function $0(q, $ = true) {
2277
+ let J = q.split("\n");
2278
+ if (J[0].trim().startsWith("export type {"))
2279
+ return q;
2280
+ let Y = $ ? "export declare" : "declare";
2281
+ return [J[0].replace(/^(\s*)(?:export\s+)?type(?!\s*\{)/, `$1${Y} type`), ...J.slice(1)].join("\n");
2282
+ }
2283
+ function T$(q, $) {
2284
+ w("type-export-processing", `Processing type export: ${q}`);
2285
+ let J = q.match(/export\s+type\s*\{([^}]+)\}(?:\s*from\s*['"]([^'"]+)['"])?/);
2286
+ if (!J) {
2287
+ w("type-export-error", "Failed to match type export pattern");
2288
+ return;
2289
+ }
2290
+ let [, Z, Y] = J;
2291
+ w("type-export-found", `Found types: ${Z}, source: ${Y || "local"}`), Z.split(",").forEach((j) => {
2292
+ let [Q, X] = j.trim().split(/\s+as\s+/).map((z) => z.trim()), U = X || Q;
2293
+ if ($.importTracking.exportedTypes.add(U), Y)
2294
+ $.importTracking.typeExportSources.set(U, Y);
2295
+ w("type-export-processed", `Added exported type: ${U}`);
1545
2296
  });
1546
- let K = Z.split("\n"), F = 0;
1547
- while (F < K.length) {
1548
- let H = "", P = "";
1549
- if (K[F].trim().startsWith("/**")) {
1550
- while (F < K.length && !K[F].includes("*/"))
1551
- H += `${K[F]}\n`, F++;
1552
- H += `${K[F]}\n`, F++;
1553
- }
1554
- if (F < K.length && K[F].trim().startsWith("export")) {
1555
- P = K[F], F++;
1556
- while (F < K.length && !K[F].trim().startsWith("export") && !K[F].trim().startsWith("/**"))
1557
- P += `\n${K[F]}`, F++;
1558
- }
1559
- if (P) {
1560
- let N = H ? u1(H.trim()) : "", G = P.trim();
1561
- if (G.startsWith("export function") || G.startsWith("export async function")) {
1562
- G = G.replace(/^export\s+(async\s+)?function/, "export declare function");
1563
- let I = G.match(/^.*?\)/);
1564
- if (I) {
1565
- let g = I[0].slice(I[0].indexOf("(") + 1, -1);
1566
- g = g.replace(/\s*=[^,)]+/g, "");
1567
- let i = G.match(/\):\s*([^{]+)/);
1568
- G = `export declare function ${G.split("function")[1].split("(")[0].trim()}(${g})${i ? `: ${i[1].trim()}` : ""};`;
2297
+ }
2298
+ function J0(q, $, J) {
2299
+ let Z = q.includes("let ") ? "let" : q.includes("var ") ? "var" : "const", Y = q.match(/(?:export\s+)?(?:const|let|var)\s+([^:\s]+)\s*:\s*([^=]+)=/);
2300
+ if (Y) {
2301
+ let [, V, H] = Y;
2302
+ return `${$ ? "export " : ""}declare ${Z} ${V}: ${H.trim()};`;
2303
+ }
2304
+ let j = q.match(/(?:export\s+)?(?:const|let|var)\s+([^=\s]+)\s*=\s*([\s\S]+)$/);
2305
+ if (!j)
2306
+ return q;
2307
+ let [, Q, X] = j, U = X.trim(), z = U.match(/^\(\s*.*?\)\s*:\s*([^=>\s{]).*=>/);
2308
+ if (z) {
2309
+ let V = z[1];
2310
+ return `${$ ? "export " : ""}declare ${Z} ${Q}: ${V};`;
2311
+ }
2312
+ let G;
2313
+ if (U.includes("as const")) {
2314
+ let V = U.replace(/\s*as\s*const\s*$/, "");
2315
+ G = z$(V, J);
2316
+ } else if (U.startsWith("{"))
2317
+ G = $1(U, J);
2318
+ else if (U.startsWith("["))
2319
+ G = w1(U, J);
2320
+ else if (U.includes("=>") || U.includes("function"))
2321
+ G = f1(U) || "(...args: any[]) => unknown";
2322
+ else
2323
+ G = U$(U);
2324
+ return `${$ ? "export " : ""}declare ${Z} ${Q}: ${G};`;
2325
+ }
2326
+ function P1(q, $, J = true) {
2327
+ w("process-function-start", `Starting to process: ${q}`);
2328
+ let Z = q.split("\n").map((X) => X.trim()).join(" ").replace(/\s+/g, " ").replace(/;$/, "");
2329
+ w("process-function-normalized", `Normalized declaration: ${Z}`);
2330
+ let Y = aq(Z);
2331
+ if (w("process-function-signature", `Extracted signature: ${JSON.stringify(Y, null, 2)}`), !Y.params && Z.includes("("))
2332
+ w("process-function-warning", "Found parentheses but no params extracted");
2333
+ if (Y.returnType === "void" && Z.includes("):"))
2334
+ w("process-function-warning", "Found return type indicator but extracted void");
2335
+ let Q = [J ? "export " : "", "declare function ", Y.name, Y.generics, `(${Y.params})`, Y.returnType ? `: ${Y.returnType}` : "", ";"].filter(Boolean).join("");
2336
+ return w("process-function-final", `Final declaration: ${Q}`), Q;
2337
+ }
2338
+ function S$(q) {
2339
+ let $ = q.split("\n"), J = 0;
2340
+ while (J < $.length) {
2341
+ let Z = $[J].trim();
2342
+ if (!Z.startsWith("//") && !Z.startsWith("/*") && !Z.startsWith("*") && Z !== "")
2343
+ break;
2344
+ J++;
2345
+ }
2346
+ return $.slice(J).join("\n").trim();
2347
+ }
2348
+ function x$(q) {
2349
+ w("generator-function", `Processing generator function: ${q}`);
2350
+ let $ = q.replace(/^export\s+/, "").replace(/^async\s+/, "").trim(), J = $.match(/function\*\s+([^(<\s]+)/);
2351
+ if (!J)
2352
+ return w("generator-function", "Failed to match generator function name"), "";
2353
+ let [, Z] = J, Y = $.slice($.indexOf(Z) + Z.length).trim(), j = "";
2354
+ if (Y.startsWith("<")) {
2355
+ let U = 1, z = 1;
2356
+ for (;z < Y.length && U > 0; z++) {
2357
+ if (Y[z] === "<")
2358
+ U++;
2359
+ if (Y[z] === ">")
2360
+ U--;
2361
+ }
2362
+ j = Y.slice(0, z), Y = Y.slice(z).trim();
2363
+ }
2364
+ let Q = "";
2365
+ if (Y.startsWith("(")) {
2366
+ let U = 1, z = 1;
2367
+ for (;z < Y.length && U > 0; z++) {
2368
+ if (Y[z] === "(")
2369
+ U++;
2370
+ if (Y[z] === ")")
2371
+ U--;
2372
+ }
2373
+ Q = Y.slice(1, z - 1).trim(), Y = Y.slice(z).trim();
2374
+ }
2375
+ let X = "any";
2376
+ if (Y.startsWith(":")) {
2377
+ Y = Y.slice(1).trim();
2378
+ let U = Y.match(/([^{;]+)/);
2379
+ if (U)
2380
+ X = U[1].trim();
2381
+ }
2382
+ return ["export declare function ", Z, j ? `${j}` : "", `(${Q})`, ": ", X].filter(Boolean).join("").concat(";");
2383
+ }
2384
+ function Z0(q) {
2385
+ let $ = q.split("\n"), J = " ", Z = 0;
2386
+ return $.map((j, Q) => {
2387
+ let X = j.trim();
2388
+ if (!X)
2389
+ return "";
2390
+ if (X.startsWith("}"))
2391
+ Z--;
2392
+ let U = " ".repeat(Math.max(0, Z)), z = Q === 0 ? X : `${U}${X}`;
2393
+ if (X.endsWith("{"))
2394
+ Z++;
2395
+ if (X.includes("}") && X.includes("{"))
2396
+ Z = Math.max(0, Z);
2397
+ return z;
2398
+ }).join("\n");
2399
+ }
2400
+ function s1(q) {
2401
+ let $ = /^(?:async\s+)?(\w+)\s*(<[^>]*>)?\s*\(([^)]*)\)\s*(?::\s*([^ {][^;{]*))?/, J = q.match($);
2402
+ if (!J)
2403
+ return { name: q.split("(")[0].trim().replace(/^async\s+/, ""), signature: "() => unknown" };
2404
+ let [, Z, Y = "", j, Q = "void"] = J, X = Q.trim();
2405
+ if (/^async\s+/.test(q) && !/^Promise<.*>$/.test(X))
2406
+ X = `Promise<${X}>`;
2407
+ let z = O1(j || ""), G = [Y ? `${Y}` : "", `(${z})`, "=>", X].filter(Boolean).join(" ").trim();
2408
+ return { name: Z, signature: G };
2409
+ }
2410
+ function C$(q, $, J = 0) {
2411
+ let Z = [], Y = q.slice(1, -1).trim();
2412
+ if (!Y)
2413
+ return Z;
2414
+ let j = "", Q = 0, X = false, U = "", z = "", G = true, V = false;
2415
+ for (let H = 0;H < Y.length; H++) {
2416
+ let W = Y[H], I = H > 0 ? Y[H - 1] : "";
2417
+ if ((W === '"' || W === "\'" || W === "`") && I !== "\\") {
2418
+ if (!X)
2419
+ X = true, U = W;
2420
+ else if (W === U)
2421
+ X = false;
2422
+ }
2423
+ if (!X) {
2424
+ if (W === "{" || W === "[" || W === "(")
2425
+ Q++;
2426
+ else if (W === "}" || W === "]" || W === ")")
2427
+ Q--;
2428
+ else if (Q === 0) {
2429
+ if (W === ":" && !V) {
2430
+ V = true, z = j.trim(), j = "", G = false;
2431
+ continue;
2432
+ } else if ((W === "," || W === ";") && !G) {
2433
+ if (z) {
2434
+ let _ = j.trim();
2435
+ if (z.includes("(") || z.match(/^\s*(?:async\s+)?\w+\s*(?:<[^>]+>)?\s*\(/)) {
2436
+ let { name: E, signature: A } = s1(z);
2437
+ Z.push({ key: E, value: A });
2438
+ } else {
2439
+ let E = n1(_, J + 1, $);
2440
+ Z.push({ key: r1(z), value: E });
2441
+ }
2442
+ }
2443
+ j = "", z = "", G = true, V = false;
2444
+ continue;
1569
2445
  }
1570
- } else if (G.startsWith("export const") || G.startsWith("export let") || G.startsWith("export var"))
1571
- G = G.replace(/^export\s+(const|let|var)/, "export declare $1"), G = `${G.split("=")[0].trim()};`;
1572
- $ += `${N}\n${G}\n\n`;
1573
- let h = /\b([A-Z]\w+)(?:<[^>]*>)?/g;
1574
- Array.from(G.matchAll(h)).forEach(([, I]) => J.add(I));
1575
- }
1576
- if (!P && !H)
1577
- F++;
1578
- }
1579
- let T = "";
1580
- if (j.forEach((H, P) => {
1581
- let N = [...H].filter((G) => J.has(G));
1582
- if (N.length > 0)
1583
- T += `import type { ${N.join(", ")} } from '${P}'\n`;
1584
- }), T)
1585
- $ = `${T}\n${$}`;
1586
- return m1($);
1587
- }
1588
- var wq = X1(Kq(), 1);
1589
- var A1 = X1(Y1(), 1);
1590
- var yq = X1(Y1(), 1);
1591
- var _Z = /\\(?![()[\]{}!+@])/g;
1592
- function RZ(q) {
1593
- return Iq(q);
1594
- }
1595
- function EZ(q) {
1596
- return Dq(q).replace(_Z, "/");
1597
- }
1598
- var _8 = process.platform === "win32" ? EZ : RZ;
1599
- var SZ = /(?<!\\)([()[\]{}*?|]|^!|[!+@](?=\()|\\(?![()[\]{}!*+?@|]))/g;
1600
- var AZ = /(?<!\\)([()[\]{}]|^!|[!+@](?=\())/g;
1601
- var Iq = (q) => q.replace(SZ, "\\$&");
1602
- var Dq = (q) => q.replace(AZ, "\\$&");
1603
- var R8 = process.platform === "win32" ? Dq : Iq;
1604
- function xZ(q, Z) {
1605
- if ((Z == null ? undefined : Z.caseSensitiveMatch) === false)
2446
+ }
2447
+ }
2448
+ j += W;
2449
+ }
2450
+ if (z && !G && j.trim()) {
2451
+ let H = j.trim();
2452
+ if (z.includes("(") || z.match(/^\s*(?:async\s+)?\w+\s*(?:<[^>]+>)?\s*\(/)) {
2453
+ let { name: I, signature: _ } = s1(z);
2454
+ Z.push({ key: I, value: _ });
2455
+ } else {
2456
+ let I = n1(H, J + 1, $);
2457
+ Z.push({ key: r1(z), value: I });
2458
+ }
2459
+ }
2460
+ return Z;
2461
+ }
2462
+ function n1(q, $, J) {
2463
+ let Z = q.trim();
2464
+ if (Z.startsWith("{") && Z.includes("(") && Z.includes(")") && Z.includes(":"))
2465
+ return $1(Z, J, $);
2466
+ if (Z.startsWith("["))
2467
+ return w1(Z, J, true);
2468
+ if (Z.startsWith("{"))
2469
+ return $1(Z, J, $);
2470
+ if (Z.includes("=>") || Z.includes("function"))
2471
+ return f1(Z) || "(...args: any[]) => unknown";
2472
+ if (/^(['"`]).*\1$/.test(Z) || !Number.isNaN(Number(Z)) || Z === "true" || Z === "false")
2473
+ return Z;
2474
+ return "unknown";
2475
+ }
2476
+ function D$(q, $) {
2477
+ let J = /(?:extends|implements|:|<)\s*([A-Z][a-zA-Z0-9]*(?:<[^>]+>)?)/g, Z;
2478
+ while ((Z = J.exec(q)) !== null) {
2479
+ let Y = Z[1].split("<")[0];
2480
+ $.usedTypes.add(Y);
2481
+ }
2482
+ }
2483
+ function k$(q, $) {
2484
+ let J = q.match(/export\s*\{([^}]+)\}/);
2485
+ if (J)
2486
+ J[1].split(",").map((j) => j.trim()).forEach((j) => {
2487
+ let [Q] = j.split(/\s+as\s+/);
2488
+ $.exportedValues.add(Q.trim());
2489
+ });
2490
+ let Z = [/export\s+declare\s+\{\s*([^}\s]+)(?:\s*,\s*[^}\s]+)*\s*\}/g, /export\s+declare\s+(?:const|function|class)\s+([a-zA-Z_$][\w$]*)/g, /export\s+\{\s*([^}\s]+)(?:\s*,\s*[^}\s]+)*\s*\}/g];
2491
+ for (let Y of Z) {
2492
+ let j;
2493
+ while ((j = Y.exec(q)) !== null)
2494
+ j[1].split(",").map((X) => X.trim()).forEach((X) => {
2495
+ if (!["type", "interface", "declare", "extends", "implements", "function", "const", "let", "var"].includes(X))
2496
+ $.usedValues.add(X);
2497
+ });
2498
+ }
2499
+ }
2500
+ function w(q, $) {
2501
+ if (q1.verbose)
2502
+ console.debug(`[dtsx:${q}] ${$}`);
2503
+ }
2504
+ function L$(q) {
2505
+ return q.replace(/\s+/g, " ").replace(/\s*([<>])\s*/g, "$1").replace(/\s*,\s*/g, ", ").trim();
2506
+ }
2507
+ function r1(q) {
2508
+ let $ = q.replace(/^['"`]|['"`]$/g, "");
2509
+ if (!/^[a-z_$][\w$]*$/i.test($))
2510
+ return `'${$}'`;
2511
+ return $;
2512
+ }
2513
+ function Y0(q) {
2514
+ let $ = [], J = "", Z = 0, Y = false, j = "";
2515
+ for (let X = 0;X < q.length; X++) {
2516
+ let U = q[X], z = X > 0 ? q[X - 1] : "";
2517
+ if ((U === '"' || U === "\'" || U === "`") && z !== "\\") {
2518
+ if (!Y)
2519
+ Y = true, j = U;
2520
+ else if (U === j)
2521
+ Y = false;
2522
+ }
2523
+ if (!Y) {
2524
+ if (U === "[" || U === "{" || U === "(")
2525
+ Z++;
2526
+ else if (U === "]" || U === "}" || U === ")")
2527
+ Z--;
2528
+ else if (U === "," && Z === 0) {
2529
+ let G = J.trim();
2530
+ if (G)
2531
+ $.push(G);
2532
+ J = "";
2533
+ continue;
2534
+ }
2535
+ }
2536
+ J += U;
2537
+ }
2538
+ let Q = J.trim();
2539
+ if (Q)
2540
+ $.push(Q);
2541
+ return $;
2542
+ }
2543
+ function b$(q) {
2544
+ let $ = [], J = q.split("\n"), Z = [];
2545
+ for (let Y = 0;Y < J.length; Y++) {
2546
+ let j = J[Y].trim();
2547
+ if ((j.startsWith("export function") || j.startsWith("function")) && Z.length > 0)
2548
+ $.push(Z.join("\n")), Z = [];
2549
+ Z.push(J[Y]);
2550
+ }
2551
+ if (Z.length > 0)
2552
+ $.push(Z.join("\n"));
2553
+ return $;
2554
+ }
2555
+ var kq = K1(yq(), 1);
2556
+ var h1 = K1(U1(), 1);
2557
+ var Lq = K1(U1(), 1);
2558
+ var SZ = /\\(?![()[\]{}!+@])/g;
2559
+ function xZ(q) {
2560
+ return bq(q);
2561
+ }
2562
+ function yZ(q) {
2563
+ return vq(q).replace(SZ, "/");
2564
+ }
2565
+ var S8 = process.platform === "win32" ? yZ : xZ;
2566
+ var CZ = /(?<!\\)([()[\]{}*?|]|^!|[!+@](?=\()|\\(?![()[\]{}!*+?@|]))/g;
2567
+ var DZ = /(?<!\\)([()[\]{}]|^!|[!+@](?=\())/g;
2568
+ var bq = (q) => q.replace(CZ, "\\$&");
2569
+ var vq = (q) => q.replace(DZ, "\\$&");
2570
+ var x8 = process.platform === "win32" ? vq : bq;
2571
+ function kZ(q, $) {
2572
+ if (($ == null ? undefined : $.caseSensitiveMatch) === false)
1606
2573
  return true;
1607
- let $ = yq.default.scan(q);
1608
- return $.isGlob || $.negated;
2574
+ let J = Lq.default.scan(q);
2575
+ return J.isGlob || J.negated;
1609
2576
  }
1610
- function Gq(q, Z, $, J, j) {
1611
- var z;
1612
- let U = q;
2577
+ function g1(q, $, J, Z, Y) {
2578
+ var j;
2579
+ let Q = q;
1613
2580
  if (q.endsWith("/"))
1614
- U = q.slice(0, -1);
1615
- if (!U.endsWith("*") && Z)
1616
- U += "/**";
1617
- if (Nq.isAbsolute(U.replace(/\\(?=[()[\]{}!*+?@|])/g, "")))
1618
- U = N1.relative($, U);
2581
+ Q = q.slice(0, -1);
2582
+ if (!Q.endsWith("*") && $)
2583
+ Q += "/**";
2584
+ if (Dq.isAbsolute(Q.replace(/\\(?=[()[\]{}!*+?@|])/g, "")))
2585
+ Q = I1.relative(J, Q);
1619
2586
  else
1620
- U = N1.normalize(U);
1621
- let B = /^(\/?\.\.)+/.exec(U);
1622
- if (B == null ? undefined : B[0]) {
1623
- let M = N1.join($, B[0]);
1624
- if (J.root.length > M.length)
1625
- J.root = M, J.depthOffset = -(B[0].length + 1) / 3;
1626
- } else if (!j && J.depthOffset >= 0) {
1627
- let M = U.split("/");
1628
- (z = J.commonPath) != null || (J.commonPath = M);
1629
- let K = [];
1630
- for (let F = 0;F < Math.min(J.commonPath.length, M.length); F++) {
1631
- let T = M[F];
1632
- if (T === "**" && !M[F + 1]) {
1633
- K.pop();
2587
+ Q = I1.normalize(Q);
2588
+ let X = /^(\/?\.\.)+/.exec(Q);
2589
+ if (X == null ? undefined : X[0]) {
2590
+ let U = I1.join(J, X[0]);
2591
+ if (Z.root.length > U.length)
2592
+ Z.root = U, Z.depthOffset = -(X[0].length + 1) / 3;
2593
+ } else if (!Y && Z.depthOffset >= 0) {
2594
+ let U = Q.split("/");
2595
+ (j = Z.commonPath) != null || (Z.commonPath = U);
2596
+ let z = [];
2597
+ for (let G = 0;G < Math.min(Z.commonPath.length, U.length); G++) {
2598
+ let V = U[G];
2599
+ if (V === "**" && !U[G + 1]) {
2600
+ z.pop();
1634
2601
  break;
1635
2602
  }
1636
- if (T !== J.commonPath[F] || xZ(T) || F === M.length - 1)
2603
+ if (V !== Z.commonPath[G] || kZ(V) || G === U.length - 1)
1637
2604
  break;
1638
- K.push(T);
2605
+ z.push(V);
1639
2606
  }
1640
- J.depthOffset = K.length, J.commonPath = K, J.root = K.length > 0 ? `${$}/${K.join("/")}` : $;
2607
+ Z.depthOffset = z.length, Z.commonPath = z, Z.root = z.length > 0 ? `${J}/${z.join("/")}` : J;
1641
2608
  }
1642
- return U;
2609
+ return Q;
1643
2610
  }
1644
- function bZ({ patterns: q, ignore: Z = [], expandDirectories: $ = true }, J, j) {
2611
+ function LZ({ patterns: q, ignore: $ = [], expandDirectories: J = true }, Z, Y) {
1645
2612
  if (typeof q === "string")
1646
2613
  q = [q];
1647
- if (typeof Z === "string")
1648
- Z = [Z];
1649
- let z = [], U = Z.map((B) => Gq(B, $, J, j, true));
1650
- if (!q)
1651
- return { match: ["**/*"], ignore: U };
1652
- for (let B of q)
1653
- if (B = Gq(B, $, J, j, false), B.startsWith("!") && B[1] !== "(")
1654
- U.push(B.slice(1));
1655
- else
1656
- z.push(B);
1657
- return { match: z, ignore: U };
2614
+ else if (!q)
2615
+ q = ["**/*"];
2616
+ if (typeof $ === "string")
2617
+ $ = [$];
2618
+ let j = [], Q = [];
2619
+ for (let X of $)
2620
+ if (!X.startsWith("!") || X[1] === "(") {
2621
+ let U = g1(X, J, Z, Y, true);
2622
+ Q.push(U);
2623
+ }
2624
+ for (let X of q)
2625
+ if (!X.startsWith("!") || X[1] === "(") {
2626
+ let U = g1(X, J, Z, Y, false);
2627
+ j.push(U);
2628
+ } else if (X[1] !== "!" || X[2] === "(") {
2629
+ let U = g1(X.slice(1), J, Z, Y, true);
2630
+ Q.push(U);
2631
+ }
2632
+ return { match: j, ignore: Q };
1658
2633
  }
1659
- function x1(q, Z, $) {
1660
- return N1.relative(Z, `${$}/${q}`);
2634
+ function u1(q, $, J) {
2635
+ return I1.relative($, `${J}/${q}`);
1661
2636
  }
1662
- function Mq(q, Z, $, J, j) {
1663
- let z = j ? q.slice($.length + 1) || "." : q;
1664
- if ($ === Z)
1665
- return J && z !== "." ? z.slice(0, -1) : z;
1666
- return x1(z, Z, $);
2637
+ function Cq(q, $, J, Z, Y) {
2638
+ let j = Y ? q.slice(J.length + 1) || "." : q;
2639
+ if (J === $)
2640
+ return Z && j !== "." ? j.slice(0, -1) : j;
2641
+ return u1(j, $, J);
1667
2642
  }
1668
- function gZ(q, Z, $) {
1669
- let J = { root: Z, commonPath: null, depthOffset: 0 }, j = bZ(q, Z, J), z = A1.default(j.match, { dot: q.dot, nocase: q.caseSensitiveMatch === false, ignore: j.ignore }), U = A1.default(j.ignore, { dot: q.dot, nocase: q.caseSensitiveMatch === false }), B = { filters: [(K, F) => z(Mq(K, Z, J.root, F, q.absolute))], exclude: (K, F) => U(Mq(F, Z, J.root, true, true)), pathSeparator: "/", relativePaths: true };
2643
+ function bZ(q, $, J) {
2644
+ let Z = { root: $, commonPath: null, depthOffset: 0 }, Y = LZ(q, $, Z), j = h1.default(Y.match, { dot: q.dot, nocase: q.caseSensitiveMatch === false, ignore: Y.ignore }), Q = h1.default(Y.ignore, { dot: q.dot, nocase: q.caseSensitiveMatch === false }), X = { filters: [(z, G) => j(Cq(z, $, Z.root, G, q.absolute))], exclude: (z, G) => Q(Cq(G, $, Z.root, true, true)), pathSeparator: "/", relativePaths: true, resolveSymlinks: true };
1670
2645
  if (q.deep)
1671
- B.maxDepth = Math.round(q.deep - J.depthOffset);
2646
+ X.maxDepth = Math.round(q.deep - Z.depthOffset);
1672
2647
  if (q.absolute)
1673
- B.relativePaths = false, B.resolvePaths = true, B.includeBasePath = true;
2648
+ X.relativePaths = false, X.resolvePaths = true, X.includeBasePath = true;
1674
2649
  if (q.followSymbolicLinks === false)
1675
- B.resolveSymlinks = false, B.excludeSymlinks = true;
2650
+ X.resolveSymlinks = false, X.excludeSymlinks = true;
1676
2651
  if (q.onlyDirectories)
1677
- B.excludeFiles = true, B.includeDirs = true;
2652
+ X.excludeFiles = true, X.includeDirs = true;
1678
2653
  else if (q.onlyFiles === false)
1679
- B.includeDirs = true;
1680
- J.root = J.root.replace(/\\/g, "");
1681
- let M = new wq.fdir(B).crawl(J.root);
1682
- if (Z === J.root || q.absolute)
1683
- return $ ? M.sync() : M.withPromise();
1684
- return $ ? M.sync().map((K) => x1(K, Z, J.root) + (!K || K.endsWith("/") ? "/" : "")) : M.withPromise().then((K) => K.map((F) => x1(F, Z, J.root) + (!F || F.endsWith("/") ? "/" : "")));
1685
- }
1686
- async function fq(q, Z) {
1687
- if (q && (Z == null ? undefined : Z.patterns))
2654
+ X.includeDirs = true;
2655
+ Z.root = Z.root.replace(/\\/g, "");
2656
+ let U = new kq.fdir(X).crawl(Z.root);
2657
+ if ($ === Z.root || q.absolute)
2658
+ return J ? U.sync() : U.withPromise();
2659
+ return J ? U.sync().map((z) => u1(z, $, Z.root) + (!z || z.endsWith("/") ? "/" : "")) : U.withPromise().then((z) => z.map((G) => u1(G, $, Z.root) + (!G || G.endsWith("/") ? "/" : "")));
2660
+ }
2661
+ async function gq(q, $) {
2662
+ if (q && ($ == null ? undefined : $.patterns))
1688
2663
  throw new Error("Cannot pass patterns as both an argument and an option");
1689
- let $ = Array.isArray(q) || typeof q === "string" ? { ...Z, patterns: q } : q, J = $.cwd ? Nq.resolve($.cwd).replace(/\\/g, "/") : process.cwd().replace(/\\/g, "/");
1690
- return gZ($, J, false);
2664
+ let J = Array.isArray(q) || typeof q === "string" ? { ...$, patterns: q } : q, Z = J.cwd ? Dq.resolve(J.cwd).replace(/\\/g, "/") : process.cwd().replace(/\\/g, "/");
2665
+ return bZ(J, Z, false);
2666
+ }
2667
+ async function uq(q, $) {
2668
+ await Bun.write(q, $);
2669
+ }
2670
+ async function m1(q) {
2671
+ let $ = q ?? q1.root, J = await vZ($, { withFileTypes: true }), Z = await Promise.all(J.map((Y) => {
2672
+ let j = hq($, Y.name);
2673
+ return Y.isDirectory() ? m1(j) : j;
2674
+ }));
2675
+ return Array.prototype.concat(...Z).filter((Y) => gZ(Y) === ".ts");
2676
+ }
2677
+ async function mq(q) {
2678
+ try {
2679
+ return (await import(q?.tsconfigPath || hq(q?.cwd ?? "./", "tsconfig.json"))).compilerOptions?.isolatedDeclarations === true;
2680
+ } catch ($) {
2681
+ return console.log("Error reading tsconfig.json:", $), false;
2682
+ }
1691
2683
  }
1692
- async function lZ(q) {
2684
+ async function pZ(q) {
1693
2685
  try {
1694
- if (!await v1(q)) {
2686
+ if (!await mq(q)) {
1695
2687
  console.error("Error: isolatedModules must be set to true in your tsconfig.json. Ensure `tsc --noEmit` does not output any errors.");
1696
2688
  return;
1697
2689
  }
1698
2690
  if (q?.clean)
1699
- await vZ(q.outdir, { recursive: true, force: true });
1700
- let $;
2691
+ await uZ(q.outdir, { recursive: true, force: true });
2692
+ let J;
1701
2693
  if (q?.entrypoints)
1702
- $ = await fq(q.entrypoints, { cwd: q.root ?? q.cwd, absolute: true });
2694
+ J = await gq(q.entrypoints, { cwd: q.root ?? `${q.cwd}/src`, absolute: true });
1703
2695
  else
1704
- $ = await y1(q?.root);
1705
- for (let J of $) {
1706
- let j = await h1(J);
1707
- if (j) {
1708
- let z = dZ(q?.root ?? "./src", J), U = hZ(z), B = uZ(q?.outdir ?? "./dist", `${U.name}.d.ts`);
1709
- await kZ(mZ(B), { recursive: true }), await k1(B, j);
2696
+ J = await m1(q?.root ?? `${q?.cwd}/src`);
2697
+ for (let Z of J) {
2698
+ let Y = await o1(Z);
2699
+ if (Y) {
2700
+ let j = lZ(q?.root ?? "./src", Z), Q = cZ(j), X = dZ(q?.outdir ?? "./dist", `${Q.name}.d.ts`);
2701
+ await hZ(mZ(X), { recursive: true }), await uq(X, Y);
1710
2702
  } else
1711
- console.warn(`No declarations extracted for ${J}`);
2703
+ console.warn(`No declarations extracted for ${Z}`);
1712
2704
  }
1713
- } catch (Z) {
1714
- console.error("Error generating declarations:", Z);
2705
+ } catch ($) {
2706
+ console.error("Error generating declarations:", $);
1715
2707
  }
1716
2708
  }
1717
- async function v8(q) {
1718
- await lZ({ ...Z1, ...q });
2709
+ async function d8(q) {
2710
+ await pZ({ ...q1, ...q });
1719
2711
  }
1720
2712
 
1721
2713
  // src/index.ts
@@ -1723,20 +2715,18 @@ function dts(options) {
1723
2715
  return {
1724
2716
  name: "bun-plugin-dtsx",
1725
2717
  async setup(build) {
1726
- const cwd = options?.cwd ?? process2.cwd();
1727
- const root = options?.root ?? build.config.root;
1728
- const entrypoints = options?.entrypoints ?? build.config.entrypoints;
1729
- const outdir = options?.outdir ?? build.config.outdir;
1730
- const keepComments = options?.keepComments ?? true;
1731
- const clean = options?.clean ?? false;
1732
- const tsconfigPath = options?.tsconfigPath ?? "./tsconfig.json";
1733
- await v8({
2718
+ const cwd = options?.cwd;
2719
+ const root = options?.root || build.config.root;
2720
+ const entrypoints = options?.entrypoints;
2721
+ const outdir = options?.outdir || build.config.outdir;
2722
+ const clean = options?.clean;
2723
+ const tsconfigPath = options?.tsconfigPath;
2724
+ await d8({
1734
2725
  ...options,
1735
2726
  cwd,
1736
2727
  root,
1737
2728
  entrypoints,
1738
2729
  outdir,
1739
- keepComments,
1740
2730
  clean,
1741
2731
  tsconfigPath
1742
2732
  });
@@ -1745,6 +2735,7 @@ function dts(options) {
1745
2735
  }
1746
2736
  var src_default = dts;
1747
2737
  export {
2738
+ d8 as generate,
1748
2739
  dts,
1749
2740
  src_default as default
1750
2741
  };