bun-plugin-dtsx 0.21.0 → 0.21.1

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