@storybook/react-native-web-vite 11.0.0-alpha.4 → 11.0.0-alpha.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1846 @@
1
+ import CJS_COMPAT_NODE_URL_pgrik10hrqk from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_pgrik10hrqk from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_pgrik10hrqk from "node:module";
4
+
5
+ var __filename = CJS_COMPAT_NODE_URL_pgrik10hrqk.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_pgrik10hrqk.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_pgrik10hrqk.createRequire(import.meta.url);
8
+
9
+ // ------------------------------------------------------------
10
+ // end of CJS compatibility banner, injected by Storybook's esbuild configuration
11
+ // ------------------------------------------------------------
12
+ import {
13
+ __commonJS,
14
+ __require,
15
+ __toESM
16
+ } from "./chunk-GLJIOED3.js";
17
+
18
+ // ../../../node_modules/ms/index.js
19
+ var require_ms = __commonJS({
20
+ "../../../node_modules/ms/index.js"(exports, module) {
21
+ var s = 1e3, m = s * 60, h = m * 60, d = h * 24, w = d * 7, y = d * 365.25;
22
+ module.exports = function(val, options) {
23
+ options = options || {};
24
+ var type = typeof val;
25
+ if (type === "string" && val.length > 0)
26
+ return parse3(val);
27
+ if (type === "number" && isFinite(val))
28
+ return options.long ? fmtLong(val) : fmtShort(val);
29
+ throw new Error(
30
+ "val is not a non-empty string or a valid number. val=" + JSON.stringify(val)
31
+ );
32
+ };
33
+ function parse3(str) {
34
+ if (str = String(str), !(str.length > 100)) {
35
+ var match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(
36
+ str
37
+ );
38
+ if (match) {
39
+ var n = parseFloat(match[1]), type = (match[2] || "ms").toLowerCase();
40
+ switch (type) {
41
+ case "years":
42
+ case "year":
43
+ case "yrs":
44
+ case "yr":
45
+ case "y":
46
+ return n * y;
47
+ case "weeks":
48
+ case "week":
49
+ case "w":
50
+ return n * w;
51
+ case "days":
52
+ case "day":
53
+ case "d":
54
+ return n * d;
55
+ case "hours":
56
+ case "hour":
57
+ case "hrs":
58
+ case "hr":
59
+ case "h":
60
+ return n * h;
61
+ case "minutes":
62
+ case "minute":
63
+ case "mins":
64
+ case "min":
65
+ case "m":
66
+ return n * m;
67
+ case "seconds":
68
+ case "second":
69
+ case "secs":
70
+ case "sec":
71
+ case "s":
72
+ return n * s;
73
+ case "milliseconds":
74
+ case "millisecond":
75
+ case "msecs":
76
+ case "msec":
77
+ case "ms":
78
+ return n;
79
+ default:
80
+ return;
81
+ }
82
+ }
83
+ }
84
+ }
85
+ function fmtShort(ms) {
86
+ var msAbs = Math.abs(ms);
87
+ return msAbs >= d ? Math.round(ms / d) + "d" : msAbs >= h ? Math.round(ms / h) + "h" : msAbs >= m ? Math.round(ms / m) + "m" : msAbs >= s ? Math.round(ms / s) + "s" : ms + "ms";
88
+ }
89
+ function fmtLong(ms) {
90
+ var msAbs = Math.abs(ms);
91
+ return msAbs >= d ? plural(ms, msAbs, d, "day") : msAbs >= h ? plural(ms, msAbs, h, "hour") : msAbs >= m ? plural(ms, msAbs, m, "minute") : msAbs >= s ? plural(ms, msAbs, s, "second") : ms + " ms";
92
+ }
93
+ function plural(ms, msAbs, n, name) {
94
+ var isPlural = msAbs >= n * 1.5;
95
+ return Math.round(ms / n) + " " + name + (isPlural ? "s" : "");
96
+ }
97
+ }
98
+ });
99
+
100
+ // ../../../node_modules/debug/src/common.js
101
+ var require_common = __commonJS({
102
+ "../../../node_modules/debug/src/common.js"(exports, module) {
103
+ function setup(env) {
104
+ createDebug2.debug = createDebug2, createDebug2.default = createDebug2, createDebug2.coerce = coerce, createDebug2.disable = disable, createDebug2.enable = enable, createDebug2.enabled = enabled, createDebug2.humanize = require_ms(), createDebug2.destroy = destroy, Object.keys(env).forEach((key) => {
105
+ createDebug2[key] = env[key];
106
+ }), createDebug2.names = [], createDebug2.skips = [], createDebug2.formatters = {};
107
+ function selectColor(namespace) {
108
+ let hash = 0;
109
+ for (let i = 0; i < namespace.length; i++)
110
+ hash = (hash << 5) - hash + namespace.charCodeAt(i), hash |= 0;
111
+ return createDebug2.colors[Math.abs(hash) % createDebug2.colors.length];
112
+ }
113
+ createDebug2.selectColor = selectColor;
114
+ function createDebug2(namespace) {
115
+ let prevTime, enableOverride = null, namespacesCache, enabledCache;
116
+ function debug2(...args) {
117
+ if (!debug2.enabled)
118
+ return;
119
+ let self = debug2, curr = Number(/* @__PURE__ */ new Date()), ms = curr - (prevTime || curr);
120
+ self.diff = ms, self.prev = prevTime, self.curr = curr, prevTime = curr, args[0] = createDebug2.coerce(args[0]), typeof args[0] != "string" && args.unshift("%O");
121
+ let index = 0;
122
+ args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => {
123
+ if (match === "%%")
124
+ return "%";
125
+ index++;
126
+ let formatter = createDebug2.formatters[format];
127
+ if (typeof formatter == "function") {
128
+ let val = args[index];
129
+ match = formatter.call(self, val), args.splice(index, 1), index--;
130
+ }
131
+ return match;
132
+ }), createDebug2.formatArgs.call(self, args), (self.log || createDebug2.log).apply(self, args);
133
+ }
134
+ return debug2.namespace = namespace, debug2.useColors = createDebug2.useColors(), debug2.color = createDebug2.selectColor(namespace), debug2.extend = extend, debug2.destroy = createDebug2.destroy, Object.defineProperty(debug2, "enabled", {
135
+ enumerable: !0,
136
+ configurable: !1,
137
+ get: () => enableOverride !== null ? enableOverride : (namespacesCache !== createDebug2.namespaces && (namespacesCache = createDebug2.namespaces, enabledCache = createDebug2.enabled(namespace)), enabledCache),
138
+ set: (v) => {
139
+ enableOverride = v;
140
+ }
141
+ }), typeof createDebug2.init == "function" && createDebug2.init(debug2), debug2;
142
+ }
143
+ function extend(namespace, delimiter) {
144
+ let newDebug = createDebug2(this.namespace + (typeof delimiter > "u" ? ":" : delimiter) + namespace);
145
+ return newDebug.log = this.log, newDebug;
146
+ }
147
+ function enable(namespaces) {
148
+ createDebug2.save(namespaces), createDebug2.namespaces = namespaces, createDebug2.names = [], createDebug2.skips = [];
149
+ let split = (typeof namespaces == "string" ? namespaces : "").trim().replace(/\s+/g, ",").split(",").filter(Boolean);
150
+ for (let ns of split)
151
+ ns[0] === "-" ? createDebug2.skips.push(ns.slice(1)) : createDebug2.names.push(ns);
152
+ }
153
+ function matchesTemplate(search, template) {
154
+ let searchIndex = 0, templateIndex = 0, starIndex = -1, matchIndex = 0;
155
+ for (; searchIndex < search.length; )
156
+ if (templateIndex < template.length && (template[templateIndex] === search[searchIndex] || template[templateIndex] === "*"))
157
+ template[templateIndex] === "*" ? (starIndex = templateIndex, matchIndex = searchIndex, templateIndex++) : (searchIndex++, templateIndex++);
158
+ else if (starIndex !== -1)
159
+ templateIndex = starIndex + 1, matchIndex++, searchIndex = matchIndex;
160
+ else
161
+ return !1;
162
+ for (; templateIndex < template.length && template[templateIndex] === "*"; )
163
+ templateIndex++;
164
+ return templateIndex === template.length;
165
+ }
166
+ function disable() {
167
+ let namespaces = [
168
+ ...createDebug2.names,
169
+ ...createDebug2.skips.map((namespace) => "-" + namespace)
170
+ ].join(",");
171
+ return createDebug2.enable(""), namespaces;
172
+ }
173
+ function enabled(name) {
174
+ for (let skip of createDebug2.skips)
175
+ if (matchesTemplate(name, skip))
176
+ return !1;
177
+ for (let ns of createDebug2.names)
178
+ if (matchesTemplate(name, ns))
179
+ return !0;
180
+ return !1;
181
+ }
182
+ function coerce(val) {
183
+ return val instanceof Error ? val.stack || val.message : val;
184
+ }
185
+ function destroy() {
186
+ console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
187
+ }
188
+ return createDebug2.enable(createDebug2.load()), createDebug2;
189
+ }
190
+ module.exports = setup;
191
+ }
192
+ });
193
+
194
+ // ../../../node_modules/debug/src/browser.js
195
+ var require_browser = __commonJS({
196
+ "../../../node_modules/debug/src/browser.js"(exports, module) {
197
+ exports.formatArgs = formatArgs;
198
+ exports.save = save;
199
+ exports.load = load;
200
+ exports.useColors = useColors;
201
+ exports.storage = localstorage();
202
+ exports.destroy = /* @__PURE__ */ (() => {
203
+ let warned = !1;
204
+ return () => {
205
+ warned || (warned = !0, console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."));
206
+ };
207
+ })();
208
+ exports.colors = [
209
+ "#0000CC",
210
+ "#0000FF",
211
+ "#0033CC",
212
+ "#0033FF",
213
+ "#0066CC",
214
+ "#0066FF",
215
+ "#0099CC",
216
+ "#0099FF",
217
+ "#00CC00",
218
+ "#00CC33",
219
+ "#00CC66",
220
+ "#00CC99",
221
+ "#00CCCC",
222
+ "#00CCFF",
223
+ "#3300CC",
224
+ "#3300FF",
225
+ "#3333CC",
226
+ "#3333FF",
227
+ "#3366CC",
228
+ "#3366FF",
229
+ "#3399CC",
230
+ "#3399FF",
231
+ "#33CC00",
232
+ "#33CC33",
233
+ "#33CC66",
234
+ "#33CC99",
235
+ "#33CCCC",
236
+ "#33CCFF",
237
+ "#6600CC",
238
+ "#6600FF",
239
+ "#6633CC",
240
+ "#6633FF",
241
+ "#66CC00",
242
+ "#66CC33",
243
+ "#9900CC",
244
+ "#9900FF",
245
+ "#9933CC",
246
+ "#9933FF",
247
+ "#99CC00",
248
+ "#99CC33",
249
+ "#CC0000",
250
+ "#CC0033",
251
+ "#CC0066",
252
+ "#CC0099",
253
+ "#CC00CC",
254
+ "#CC00FF",
255
+ "#CC3300",
256
+ "#CC3333",
257
+ "#CC3366",
258
+ "#CC3399",
259
+ "#CC33CC",
260
+ "#CC33FF",
261
+ "#CC6600",
262
+ "#CC6633",
263
+ "#CC9900",
264
+ "#CC9933",
265
+ "#CCCC00",
266
+ "#CCCC33",
267
+ "#FF0000",
268
+ "#FF0033",
269
+ "#FF0066",
270
+ "#FF0099",
271
+ "#FF00CC",
272
+ "#FF00FF",
273
+ "#FF3300",
274
+ "#FF3333",
275
+ "#FF3366",
276
+ "#FF3399",
277
+ "#FF33CC",
278
+ "#FF33FF",
279
+ "#FF6600",
280
+ "#FF6633",
281
+ "#FF9900",
282
+ "#FF9933",
283
+ "#FFCC00",
284
+ "#FFCC33"
285
+ ];
286
+ function useColors() {
287
+ if (typeof window < "u" && window.process && (window.process.type === "renderer" || window.process.__nwjs))
288
+ return !0;
289
+ if (typeof navigator < "u" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))
290
+ return !1;
291
+ let m;
292
+ return typeof document < "u" && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance || // Is firebug? http://stackoverflow.com/a/398120/376773
293
+ typeof window < "u" && window.console && (window.console.firebug || window.console.exception && window.console.table) || // Is firefox >= v31?
294
+ // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
295
+ typeof navigator < "u" && navigator.userAgent && (m = navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)) && parseInt(m[1], 10) >= 31 || // Double check webkit in userAgent just in case we are in a worker
296
+ typeof navigator < "u" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/);
297
+ }
298
+ function formatArgs(args) {
299
+ if (args[0] = (this.useColors ? "%c" : "") + this.namespace + (this.useColors ? " %c" : " ") + args[0] + (this.useColors ? "%c " : " ") + "+" + module.exports.humanize(this.diff), !this.useColors)
300
+ return;
301
+ let c = "color: " + this.color;
302
+ args.splice(1, 0, c, "color: inherit");
303
+ let index = 0, lastC = 0;
304
+ args[0].replace(/%[a-zA-Z%]/g, (match) => {
305
+ match !== "%%" && (index++, match === "%c" && (lastC = index));
306
+ }), args.splice(lastC, 0, c);
307
+ }
308
+ exports.log = console.debug || console.log || (() => {
309
+ });
310
+ function save(namespaces) {
311
+ try {
312
+ namespaces ? exports.storage.setItem("debug", namespaces) : exports.storage.removeItem("debug");
313
+ } catch {
314
+ }
315
+ }
316
+ function load() {
317
+ let r;
318
+ try {
319
+ r = exports.storage.getItem("debug") || exports.storage.getItem("DEBUG");
320
+ } catch {
321
+ }
322
+ return !r && typeof process < "u" && "env" in process && (r = process.env.DEBUG), r;
323
+ }
324
+ function localstorage() {
325
+ try {
326
+ return localStorage;
327
+ } catch {
328
+ }
329
+ }
330
+ module.exports = require_common()(exports);
331
+ var { formatters } = module.exports;
332
+ formatters.j = function(v) {
333
+ try {
334
+ return JSON.stringify(v);
335
+ } catch (error) {
336
+ return "[UnexpectedJSONParseError]: " + error.message;
337
+ }
338
+ };
339
+ }
340
+ });
341
+
342
+ // ../../../node_modules/has-flag/index.js
343
+ var require_has_flag = __commonJS({
344
+ "../../../node_modules/has-flag/index.js"(exports, module) {
345
+ "use strict";
346
+ module.exports = (flag, argv = process.argv) => {
347
+ let prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--", position = argv.indexOf(prefix + flag), terminatorPosition = argv.indexOf("--");
348
+ return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
349
+ };
350
+ }
351
+ });
352
+
353
+ // ../../../node_modules/supports-color/index.js
354
+ var require_supports_color = __commonJS({
355
+ "../../../node_modules/supports-color/index.js"(exports, module) {
356
+ "use strict";
357
+ var os2 = __require("os"), tty = __require("tty"), hasFlag = require_has_flag(), { env } = process, forceColor;
358
+ hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never") ? forceColor = 0 : (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) && (forceColor = 1);
359
+ "FORCE_COLOR" in env && (env.FORCE_COLOR === "true" ? forceColor = 1 : env.FORCE_COLOR === "false" ? forceColor = 0 : forceColor = env.FORCE_COLOR.length === 0 ? 1 : Math.min(parseInt(env.FORCE_COLOR, 10), 3));
360
+ function translateLevel(level) {
361
+ return level === 0 ? !1 : {
362
+ level,
363
+ hasBasic: !0,
364
+ has256: level >= 2,
365
+ has16m: level >= 3
366
+ };
367
+ }
368
+ function supportsColor(haveStream, streamIsTTY) {
369
+ if (forceColor === 0)
370
+ return 0;
371
+ if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor"))
372
+ return 3;
373
+ if (hasFlag("color=256"))
374
+ return 2;
375
+ if (haveStream && !streamIsTTY && forceColor === void 0)
376
+ return 0;
377
+ let min = forceColor || 0;
378
+ if (env.TERM === "dumb")
379
+ return min;
380
+ if (process.platform === "win32") {
381
+ let osRelease = os2.release().split(".");
382
+ return Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586 ? Number(osRelease[2]) >= 14931 ? 3 : 2 : 1;
383
+ }
384
+ if ("CI" in env)
385
+ return ["TRAVIS", "CIRCLECI", "APPVEYOR", "GITLAB_CI", "GITHUB_ACTIONS", "BUILDKITE"].some((sign) => sign in env) || env.CI_NAME === "codeship" ? 1 : min;
386
+ if ("TEAMCITY_VERSION" in env)
387
+ return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
388
+ if (env.COLORTERM === "truecolor")
389
+ return 3;
390
+ if ("TERM_PROGRAM" in env) {
391
+ let version = parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
392
+ switch (env.TERM_PROGRAM) {
393
+ case "iTerm.app":
394
+ return version >= 3 ? 3 : 2;
395
+ case "Apple_Terminal":
396
+ return 2;
397
+ }
398
+ }
399
+ return /-256(color)?$/i.test(env.TERM) ? 2 : /^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM) || "COLORTERM" in env ? 1 : min;
400
+ }
401
+ function getSupportLevel(stream) {
402
+ let level = supportsColor(stream, stream && stream.isTTY);
403
+ return translateLevel(level);
404
+ }
405
+ module.exports = {
406
+ supportsColor: getSupportLevel,
407
+ stdout: translateLevel(supportsColor(!0, tty.isatty(1))),
408
+ stderr: translateLevel(supportsColor(!0, tty.isatty(2)))
409
+ };
410
+ }
411
+ });
412
+
413
+ // ../../../node_modules/debug/src/node.js
414
+ var require_node = __commonJS({
415
+ "../../../node_modules/debug/src/node.js"(exports, module) {
416
+ var tty = __require("tty"), util = __require("util");
417
+ exports.init = init;
418
+ exports.log = log;
419
+ exports.formatArgs = formatArgs;
420
+ exports.save = save;
421
+ exports.load = load;
422
+ exports.useColors = useColors;
423
+ exports.destroy = util.deprecate(
424
+ () => {
425
+ },
426
+ "Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."
427
+ );
428
+ exports.colors = [6, 2, 3, 4, 5, 1];
429
+ try {
430
+ let supportsColor = require_supports_color();
431
+ supportsColor && (supportsColor.stderr || supportsColor).level >= 2 && (exports.colors = [
432
+ 20,
433
+ 21,
434
+ 26,
435
+ 27,
436
+ 32,
437
+ 33,
438
+ 38,
439
+ 39,
440
+ 40,
441
+ 41,
442
+ 42,
443
+ 43,
444
+ 44,
445
+ 45,
446
+ 56,
447
+ 57,
448
+ 62,
449
+ 63,
450
+ 68,
451
+ 69,
452
+ 74,
453
+ 75,
454
+ 76,
455
+ 77,
456
+ 78,
457
+ 79,
458
+ 80,
459
+ 81,
460
+ 92,
461
+ 93,
462
+ 98,
463
+ 99,
464
+ 112,
465
+ 113,
466
+ 128,
467
+ 129,
468
+ 134,
469
+ 135,
470
+ 148,
471
+ 149,
472
+ 160,
473
+ 161,
474
+ 162,
475
+ 163,
476
+ 164,
477
+ 165,
478
+ 166,
479
+ 167,
480
+ 168,
481
+ 169,
482
+ 170,
483
+ 171,
484
+ 172,
485
+ 173,
486
+ 178,
487
+ 179,
488
+ 184,
489
+ 185,
490
+ 196,
491
+ 197,
492
+ 198,
493
+ 199,
494
+ 200,
495
+ 201,
496
+ 202,
497
+ 203,
498
+ 204,
499
+ 205,
500
+ 206,
501
+ 207,
502
+ 208,
503
+ 209,
504
+ 214,
505
+ 215,
506
+ 220,
507
+ 221
508
+ ]);
509
+ } catch {
510
+ }
511
+ exports.inspectOpts = Object.keys(process.env).filter((key) => /^debug_/i.test(key)).reduce((obj, key) => {
512
+ let prop = key.substring(6).toLowerCase().replace(/_([a-z])/g, (_, k) => k.toUpperCase()), val = process.env[key];
513
+ return /^(yes|on|true|enabled)$/i.test(val) ? val = !0 : /^(no|off|false|disabled)$/i.test(val) ? val = !1 : val === "null" ? val = null : val = Number(val), obj[prop] = val, obj;
514
+ }, {});
515
+ function useColors() {
516
+ return "colors" in exports.inspectOpts ? !!exports.inspectOpts.colors : tty.isatty(process.stderr.fd);
517
+ }
518
+ function formatArgs(args) {
519
+ let { namespace: name, useColors: useColors2 } = this;
520
+ if (useColors2) {
521
+ let c = this.color, colorCode = "\x1B[3" + (c < 8 ? c : "8;5;" + c), prefix = ` ${colorCode};1m${name} \x1B[0m`;
522
+ args[0] = prefix + args[0].split(`
523
+ `).join(`
524
+ ` + prefix), args.push(colorCode + "m+" + module.exports.humanize(this.diff) + "\x1B[0m");
525
+ } else
526
+ args[0] = getDate() + name + " " + args[0];
527
+ }
528
+ function getDate() {
529
+ return exports.inspectOpts.hideDate ? "" : (/* @__PURE__ */ new Date()).toISOString() + " ";
530
+ }
531
+ function log(...args) {
532
+ return process.stderr.write(util.formatWithOptions(exports.inspectOpts, ...args) + `
533
+ `);
534
+ }
535
+ function save(namespaces) {
536
+ namespaces ? process.env.DEBUG = namespaces : delete process.env.DEBUG;
537
+ }
538
+ function load() {
539
+ return process.env.DEBUG;
540
+ }
541
+ function init(debug2) {
542
+ debug2.inspectOpts = {};
543
+ let keys = Object.keys(exports.inspectOpts);
544
+ for (let i = 0; i < keys.length; i++)
545
+ debug2.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]];
546
+ }
547
+ module.exports = require_common()(exports);
548
+ var { formatters } = module.exports;
549
+ formatters.o = function(v) {
550
+ return this.inspectOpts.colors = this.useColors, util.inspect(v, this.inspectOpts).split(`
551
+ `).map((str) => str.trim()).join(" ");
552
+ };
553
+ formatters.O = function(v) {
554
+ return this.inspectOpts.colors = this.useColors, util.inspect(v, this.inspectOpts);
555
+ };
556
+ }
557
+ });
558
+
559
+ // ../../../node_modules/debug/src/index.js
560
+ var require_src = __commonJS({
561
+ "../../../node_modules/debug/src/index.js"(exports, module) {
562
+ typeof process > "u" || process.type === "renderer" || process.browser === !0 || process.__nwjs ? module.exports = require_browser() : module.exports = require_node();
563
+ }
564
+ });
565
+
566
+ // ../../../node_modules/globrex/index.js
567
+ var require_globrex = __commonJS({
568
+ "../../../node_modules/globrex/index.js"(exports, module) {
569
+ var isWin = process.platform === "win32", SEP = isWin ? "\\\\+" : "\\/", SEP_ESC = isWin ? "\\\\" : "/", GLOBSTAR = "((?:[^/]*(?:/|$))*)", WILDCARD = "([^/]*)", GLOBSTAR_SEGMENT = `((?:[^${SEP_ESC}]*(?:${SEP_ESC}|$))*)`, WILDCARD_SEGMENT = `([^${SEP_ESC}]*)`;
570
+ function globrex(glob, { extended = !1, globstar = !1, strict = !1, filepath = !1, flags = "" } = {}) {
571
+ let regex = "", segment = "", path8 = { regex: "", segments: [] }, inGroup = !1, inRange = !1, ext = [];
572
+ function add(str, { split, last, only } = {}) {
573
+ only !== "path" && (regex += str), filepath && only !== "regex" && (path8.regex += str === "\\/" ? SEP : str, split ? (last && (segment += str), segment !== "" && (flags.includes("g") || (segment = `^${segment}$`), path8.segments.push(new RegExp(segment, flags))), segment = "") : segment += str);
574
+ }
575
+ let c, n;
576
+ for (let i = 0; i < glob.length; i++) {
577
+ if (c = glob[i], n = glob[i + 1], ["\\", "$", "^", ".", "="].includes(c)) {
578
+ add(`\\${c}`);
579
+ continue;
580
+ }
581
+ if (c === "/") {
582
+ add(`\\${c}`, { split: !0 }), n === "/" && !strict && (regex += "?");
583
+ continue;
584
+ }
585
+ if (c === "(") {
586
+ if (ext.length) {
587
+ add(c);
588
+ continue;
589
+ }
590
+ add(`\\${c}`);
591
+ continue;
592
+ }
593
+ if (c === ")") {
594
+ if (ext.length) {
595
+ add(c);
596
+ let type = ext.pop();
597
+ add(type === "@" ? "{1}" : type === "!" ? "([^/]*)" : type);
598
+ continue;
599
+ }
600
+ add(`\\${c}`);
601
+ continue;
602
+ }
603
+ if (c === "|") {
604
+ if (ext.length) {
605
+ add(c);
606
+ continue;
607
+ }
608
+ add(`\\${c}`);
609
+ continue;
610
+ }
611
+ if (c === "+") {
612
+ if (n === "(" && extended) {
613
+ ext.push(c);
614
+ continue;
615
+ }
616
+ add(`\\${c}`);
617
+ continue;
618
+ }
619
+ if (c === "@" && extended && n === "(") {
620
+ ext.push(c);
621
+ continue;
622
+ }
623
+ if (c === "!") {
624
+ if (extended) {
625
+ if (inRange) {
626
+ add("^");
627
+ continue;
628
+ }
629
+ if (n === "(") {
630
+ ext.push(c), add("(?!"), i++;
631
+ continue;
632
+ }
633
+ add(`\\${c}`);
634
+ continue;
635
+ }
636
+ add(`\\${c}`);
637
+ continue;
638
+ }
639
+ if (c === "?") {
640
+ if (extended) {
641
+ n === "(" ? ext.push(c) : add(".");
642
+ continue;
643
+ }
644
+ add(`\\${c}`);
645
+ continue;
646
+ }
647
+ if (c === "[") {
648
+ if (inRange && n === ":") {
649
+ i++;
650
+ let value = "";
651
+ for (; glob[++i] !== ":"; ) value += glob[i];
652
+ value === "alnum" ? add("(\\w|\\d)") : value === "space" ? add("\\s") : value === "digit" && add("\\d"), i++;
653
+ continue;
654
+ }
655
+ if (extended) {
656
+ inRange = !0, add(c);
657
+ continue;
658
+ }
659
+ add(`\\${c}`);
660
+ continue;
661
+ }
662
+ if (c === "]") {
663
+ if (extended) {
664
+ inRange = !1, add(c);
665
+ continue;
666
+ }
667
+ add(`\\${c}`);
668
+ continue;
669
+ }
670
+ if (c === "{") {
671
+ if (extended) {
672
+ inGroup = !0, add("(");
673
+ continue;
674
+ }
675
+ add(`\\${c}`);
676
+ continue;
677
+ }
678
+ if (c === "}") {
679
+ if (extended) {
680
+ inGroup = !1, add(")");
681
+ continue;
682
+ }
683
+ add(`\\${c}`);
684
+ continue;
685
+ }
686
+ if (c === ",") {
687
+ if (inGroup) {
688
+ add("|");
689
+ continue;
690
+ }
691
+ add(`\\${c}`);
692
+ continue;
693
+ }
694
+ if (c === "*") {
695
+ if (n === "(" && extended) {
696
+ ext.push(c);
697
+ continue;
698
+ }
699
+ let prevChar = glob[i - 1], starCount = 1;
700
+ for (; glob[i + 1] === "*"; )
701
+ starCount++, i++;
702
+ let nextChar = glob[i + 1];
703
+ globstar ? starCount > 1 && // multiple "*"'s
704
+ (prevChar === "/" || prevChar === void 0) && // from the start of the segment
705
+ (nextChar === "/" || nextChar === void 0) ? (add(GLOBSTAR, { only: "regex" }), add(GLOBSTAR_SEGMENT, { only: "path", last: !0, split: !0 }), i++) : (add(WILDCARD, { only: "regex" }), add(WILDCARD_SEGMENT, { only: "path" })) : add(".*");
706
+ continue;
707
+ }
708
+ add(c);
709
+ }
710
+ flags.includes("g") || (regex = `^${regex}$`, segment = `^${segment}$`, filepath && (path8.regex = `^${path8.regex}$`));
711
+ let result = { regex: new RegExp(regex, flags) };
712
+ return filepath && (path8.segments.push(new RegExp(segment, flags)), path8.regex = new RegExp(path8.regex, flags), path8.globstar = new RegExp(flags.includes("g") ? GLOBSTAR_SEGMENT : `^${GLOBSTAR_SEGMENT}$`, flags), result.path = path8), result;
713
+ }
714
+ module.exports = globrex;
715
+ }
716
+ });
717
+
718
+ // ../../../node_modules/vite-tsconfig-paths/dist/index.js
719
+ var import_debug = __toESM(require_src(), 1), import_globrex = __toESM(require_globrex(), 1);
720
+ import * as fs22 from "fs";
721
+ import * as vite2 from "vite";
722
+ import { createWriteStream, statSync, writeFileSync } from "fs";
723
+ import * as os from "os";
724
+ import * as path7 from "path";
725
+ import * as vite from "vite";
726
+ import * as fs4 from "fs";
727
+ import { readdir as readdir2 } from "fs/promises";
728
+ import { isAbsolute as isAbsolute2, join as join2, relative as relative2 } from "path";
729
+ import { inspect } from "util";
730
+
731
+ // ../../../node_modules/tsconfck/src/find.js
732
+ import path2 from "node:path";
733
+ import fs2 from "node:fs";
734
+
735
+ // ../../../node_modules/tsconfck/src/util.js
736
+ import path from "node:path";
737
+ import { promises as fs } from "node:fs";
738
+ var POSIX_SEP_RE = new RegExp("\\" + path.posix.sep, "g"), NATIVE_SEP_RE = new RegExp("\\" + path.sep, "g"), PATTERN_REGEX_CACHE = /* @__PURE__ */ new Map(), GLOB_ALL_PATTERN = "**/*", TS_EXTENSIONS = [".ts", ".tsx", ".mts", ".cts"], JS_EXTENSIONS = [".js", ".jsx", ".mjs", ".cjs"], TSJS_EXTENSIONS = TS_EXTENSIONS.concat(JS_EXTENSIONS), TS_EXTENSIONS_RE_GROUP = `\\.(?:${TS_EXTENSIONS.map((ext) => ext.substring(1)).join("|")})`, TSJS_EXTENSIONS_RE_GROUP = `\\.(?:${TSJS_EXTENSIONS.map((ext) => ext.substring(1)).join(
739
+ "|"
740
+ )})`, IS_POSIX = path.posix.sep === path.sep;
741
+ function makePromise() {
742
+ let resolve3, reject;
743
+ return { promise: new Promise((res, rej) => {
744
+ resolve3 = res, reject = rej;
745
+ }), resolve: resolve3, reject };
746
+ }
747
+ async function loadTS() {
748
+ try {
749
+ return import("typescript").then((m) => m.default);
750
+ } catch (e) {
751
+ throw console.error('typescript must be installed to use "native" functions'), e;
752
+ }
753
+ }
754
+ async function resolveTSConfigJson(filename, cache) {
755
+ if (path.extname(filename) !== ".json")
756
+ return;
757
+ let tsconfig = path.resolve(filename);
758
+ return cache && (cache.hasParseResult(tsconfig) || cache.hasParseResult(filename)) ? tsconfig : fs.stat(tsconfig).then((stat) => {
759
+ if (stat.isFile() || stat.isFIFO())
760
+ return tsconfig;
761
+ throw new Error(`${filename} exists but is not a regular file.`);
762
+ });
763
+ }
764
+ var isInNodeModules = IS_POSIX ? (dir) => dir.includes("/node_modules/") : (dir) => dir.match(/[/\\]node_modules[/\\]/), posix2native = IS_POSIX ? (filename) => filename : (filename) => filename.replace(POSIX_SEP_RE, path.sep), native2posix = IS_POSIX ? (filename) => filename : (filename) => filename.replace(NATIVE_SEP_RE, path.posix.sep), resolve2posix = IS_POSIX ? (dir, filename) => dir ? path.resolve(dir, filename) : path.resolve(filename) : (dir, filename) => native2posix(
765
+ dir ? path.resolve(posix2native(dir), posix2native(filename)) : path.resolve(posix2native(filename))
766
+ );
767
+ function resolveReferencedTSConfigFiles(result, options) {
768
+ let dir = path.dirname(result.tsconfigFile);
769
+ return result.tsconfig.references.map((ref) => {
770
+ let refPath = ref.path.endsWith(".json") ? ref.path : path.join(ref.path, options?.configName ?? "tsconfig.json");
771
+ return resolve2posix(dir, refPath);
772
+ });
773
+ }
774
+ function resolveSolutionTSConfig(filename, result) {
775
+ let extensions = result.tsconfig.compilerOptions?.allowJs ? TSJS_EXTENSIONS : TS_EXTENSIONS;
776
+ if (result.referenced && extensions.some((ext) => filename.endsWith(ext)) && !isIncluded(filename, result)) {
777
+ let solutionTSConfig = result.referenced.find(
778
+ (referenced) => isIncluded(filename, referenced)
779
+ );
780
+ if (solutionTSConfig)
781
+ return solutionTSConfig;
782
+ }
783
+ return result;
784
+ }
785
+ function isIncluded(filename, result) {
786
+ let dir = native2posix(path.dirname(result.tsconfigFile)), files = (result.tsconfig.files || []).map((file) => resolve2posix(dir, file)), absoluteFilename = resolve2posix(null, filename);
787
+ if (files.includes(filename))
788
+ return !0;
789
+ let allowJs = result.tsconfig.compilerOptions?.allowJs;
790
+ return isGlobMatch(
791
+ absoluteFilename,
792
+ dir,
793
+ result.tsconfig.include || (result.tsconfig.files ? [] : [GLOB_ALL_PATTERN]),
794
+ allowJs
795
+ ) ? !isGlobMatch(absoluteFilename, dir, result.tsconfig.exclude || [], allowJs) : !1;
796
+ }
797
+ function isGlobMatch(filename, dir, patterns, allowJs) {
798
+ let extensions = allowJs ? TSJS_EXTENSIONS : TS_EXTENSIONS;
799
+ return patterns.some((pattern) => {
800
+ let lastWildcardIndex = pattern.length, hasWildcard = !1, hasExtension = !1, hasSlash = !1, lastSlashIndex = -1;
801
+ for (let i = pattern.length - 1; i > -1; i--) {
802
+ let c = pattern[i];
803
+ if (hasWildcard || (c === "*" || c === "?") && (lastWildcardIndex = i, hasWildcard = !0), hasSlash || (c === "." ? hasExtension = !0 : c === "/" && (lastSlashIndex = i, hasSlash = !0)), hasWildcard && hasSlash)
804
+ break;
805
+ }
806
+ if (!hasExtension && (!hasWildcard || lastWildcardIndex < lastSlashIndex) && (pattern += `${pattern.endsWith("/") ? "" : "/"}${GLOB_ALL_PATTERN}`, lastWildcardIndex = pattern.length - 1, hasWildcard = !0), lastWildcardIndex < pattern.length - 1 && !filename.endsWith(pattern.slice(lastWildcardIndex + 1)) || pattern.endsWith("*") && !extensions.some((ext) => filename.endsWith(ext)))
807
+ return !1;
808
+ if (pattern === GLOB_ALL_PATTERN)
809
+ return filename.startsWith(`${dir}/`);
810
+ let resolvedPattern = resolve2posix(dir, pattern), firstWildcardIndex = -1;
811
+ for (let i = 0; i < resolvedPattern.length; i++)
812
+ if (resolvedPattern[i] === "*" || resolvedPattern[i] === "?") {
813
+ firstWildcardIndex = i, hasWildcard = !0;
814
+ break;
815
+ }
816
+ if (firstWildcardIndex > 1 && !filename.startsWith(resolvedPattern.slice(0, firstWildcardIndex - 1)))
817
+ return !1;
818
+ if (hasWildcard) {
819
+ if (firstWildcardIndex + GLOB_ALL_PATTERN.length === resolvedPattern.length - (pattern.length - 1 - lastWildcardIndex) && resolvedPattern.slice(firstWildcardIndex, firstWildcardIndex + GLOB_ALL_PATTERN.length) === GLOB_ALL_PATTERN)
820
+ return !0;
821
+ } else return filename === resolvedPattern;
822
+ if (PATTERN_REGEX_CACHE.has(resolvedPattern))
823
+ return PATTERN_REGEX_CACHE.get(resolvedPattern).test(filename);
824
+ let regex = pattern2regex(resolvedPattern, allowJs);
825
+ return PATTERN_REGEX_CACHE.set(resolvedPattern, regex), regex.test(filename);
826
+ });
827
+ }
828
+ function pattern2regex(resolvedPattern, allowJs) {
829
+ let regexStr = "^";
830
+ for (let i = 0; i < resolvedPattern.length; i++) {
831
+ let char = resolvedPattern[i];
832
+ if (char === "?") {
833
+ regexStr += "[^\\/]";
834
+ continue;
835
+ }
836
+ if (char === "*") {
837
+ if (resolvedPattern[i + 1] === "*" && resolvedPattern[i + 2] === "/") {
838
+ i += 2, regexStr += "(?:[^\\/]*\\/)*";
839
+ continue;
840
+ }
841
+ regexStr += "[^\\/]*";
842
+ continue;
843
+ }
844
+ "/.+^${}()|[]\\".includes(char) && (regexStr += "\\"), regexStr += char;
845
+ }
846
+ return resolvedPattern.endsWith("*") && (regexStr += allowJs ? TSJS_EXTENSIONS_RE_GROUP : TS_EXTENSIONS_RE_GROUP), regexStr += "$", new RegExp(regexStr);
847
+ }
848
+ function replaceTokens(result) {
849
+ result.tsconfig && (result.tsconfig = JSON.parse(
850
+ JSON.stringify(result.tsconfig).replaceAll(/"\${configDir}/g, `"${native2posix(path.dirname(result.tsconfigFile))}`)
851
+ ));
852
+ }
853
+
854
+ // ../../../node_modules/tsconfck/src/find.js
855
+ async function find(filename, options) {
856
+ let dir = path2.dirname(path2.resolve(filename));
857
+ if (options?.ignoreNodeModules && isInNodeModules(dir))
858
+ return null;
859
+ let cache = options?.cache, configName = options?.configName ?? "tsconfig.json";
860
+ if (cache?.hasConfigPath(dir, configName))
861
+ return cache.getConfigPath(dir, configName);
862
+ let {
863
+ /** @type {Promise<string|null>} */
864
+ promise,
865
+ resolve: resolve3,
866
+ reject
867
+ } = makePromise();
868
+ return options?.root && !path2.isAbsolute(options.root) && (options.root = path2.resolve(options.root)), findUp(dir, { promise, resolve: resolve3, reject }, options), promise;
869
+ }
870
+ function findUp(dir, { resolve: resolve3, reject, promise }, options) {
871
+ let { cache, root, configName } = options ?? {};
872
+ if (cache)
873
+ if (cache.hasConfigPath(dir, configName)) {
874
+ let cached;
875
+ try {
876
+ cached = cache.getConfigPath(dir, configName);
877
+ } catch (e) {
878
+ reject(e);
879
+ return;
880
+ }
881
+ cached?.then ? cached.then(resolve3).catch(reject) : resolve3(cached);
882
+ } else
883
+ cache.setConfigPath(dir, promise, configName);
884
+ let tsconfig = path2.join(dir, options?.configName ?? "tsconfig.json");
885
+ fs2.stat(tsconfig, (err, stats) => {
886
+ if (stats && (stats.isFile() || stats.isFIFO()))
887
+ resolve3(tsconfig);
888
+ else if (err?.code !== "ENOENT")
889
+ reject(err);
890
+ else {
891
+ let parent;
892
+ root === dir || (parent = path2.dirname(dir)) === dir ? resolve3(null) : findUp(parent, { promise, resolve: resolve3, reject }, options);
893
+ }
894
+ });
895
+ }
896
+
897
+ // ../../../node_modules/tsconfck/src/find-all.js
898
+ import path3 from "node:path";
899
+ import { readdir } from "node:fs";
900
+ var sep = path3.sep;
901
+ async function findAll(dir, options) {
902
+ let state = {
903
+ files: [],
904
+ calls: 0,
905
+ skip: options?.skip,
906
+ err: !1,
907
+ configNames: options?.configNames ?? ["tsconfig.json"]
908
+ };
909
+ return new Promise((resolve3, reject) => {
910
+ walk(path3.resolve(dir), state, (err, files) => err ? reject(err) : resolve3(files));
911
+ });
912
+ }
913
+ function walk(dir, state, done) {
914
+ state.err || (state.calls++, readdir(dir, { withFileTypes: !0 }, (err, entries = []) => {
915
+ if (!state.err)
916
+ if (err && !(err.code === "ENOENT" || err.code === "EACCES" || err.code === "EPERM"))
917
+ state.err = !0, done(err);
918
+ else {
919
+ for (let ent of entries)
920
+ ent.isDirectory() && !state.skip?.(ent.name) ? walk(`${dir}${sep}${ent.name}`, state, done) : ent.isFile() && state.configNames.includes(ent.name) && state.files.push(`${dir}${sep}${ent.name}`);
921
+ --state.calls === 0 && (state.err || done(null, state.files));
922
+ }
923
+ }));
924
+ }
925
+
926
+ // ../../../node_modules/tsconfck/src/to-json.js
927
+ function toJson(tsconfigJson) {
928
+ let stripped = stripDanglingComma(stripJsonComments(stripBom(tsconfigJson)));
929
+ return stripped.trim() === "" ? "{}" : stripped;
930
+ }
931
+ function stripDanglingComma(pseudoJson) {
932
+ let insideString = !1, offset = 0, result = "", danglingCommaPos = null;
933
+ for (let i = 0; i < pseudoJson.length; i++) {
934
+ let currentCharacter = pseudoJson[i];
935
+ if (currentCharacter === '"' && (isEscaped(pseudoJson, i) || (insideString = !insideString)), insideString) {
936
+ danglingCommaPos = null;
937
+ continue;
938
+ }
939
+ if (currentCharacter === ",") {
940
+ danglingCommaPos = i;
941
+ continue;
942
+ }
943
+ danglingCommaPos && (currentCharacter === "}" || currentCharacter === "]" ? (result += pseudoJson.slice(offset, danglingCommaPos) + " ", offset = danglingCommaPos + 1, danglingCommaPos = null) : currentCharacter.match(/\s/) || (danglingCommaPos = null));
944
+ }
945
+ return result + pseudoJson.substring(offset);
946
+ }
947
+ function isEscaped(jsonString, quotePosition) {
948
+ let index = quotePosition - 1, backslashCount = 0;
949
+ for (; jsonString[index] === "\\"; )
950
+ index -= 1, backslashCount += 1;
951
+ return !!(backslashCount % 2);
952
+ }
953
+ function strip(string, start, end) {
954
+ return string.slice(start, end).replace(/\S/g, " ");
955
+ }
956
+ var singleComment = /* @__PURE__ */ Symbol("singleComment"), multiComment = /* @__PURE__ */ Symbol("multiComment");
957
+ function stripJsonComments(jsonString) {
958
+ let isInsideString = !1, isInsideComment = !1, offset = 0, result = "";
959
+ for (let index = 0; index < jsonString.length; index++) {
960
+ let currentCharacter = jsonString[index], nextCharacter = jsonString[index + 1];
961
+ !isInsideComment && currentCharacter === '"' && (isEscaped(jsonString, index) || (isInsideString = !isInsideString)), !isInsideString && (!isInsideComment && currentCharacter + nextCharacter === "//" ? (result += jsonString.slice(offset, index), offset = index, isInsideComment = singleComment, index++) : isInsideComment === singleComment && currentCharacter + nextCharacter === `\r
962
+ ` ? (index++, isInsideComment = !1, result += strip(jsonString, offset, index), offset = index) : isInsideComment === singleComment && currentCharacter === `
963
+ ` ? (isInsideComment = !1, result += strip(jsonString, offset, index), offset = index) : !isInsideComment && currentCharacter + nextCharacter === "/*" ? (result += jsonString.slice(offset, index), offset = index, isInsideComment = multiComment, index++) : isInsideComment === multiComment && currentCharacter + nextCharacter === "*/" && (index++, isInsideComment = !1, result += strip(jsonString, offset, index + 1), offset = index + 1));
964
+ }
965
+ return result + (isInsideComment ? strip(jsonString.slice(offset)) : jsonString.slice(offset));
966
+ }
967
+ function stripBom(string) {
968
+ return string.charCodeAt(0) === 65279 ? string.slice(1) : string;
969
+ }
970
+
971
+ // ../../../node_modules/tsconfck/src/parse.js
972
+ import path4 from "node:path";
973
+ import { promises as fs3 } from "node:fs";
974
+ import { createRequire } from "module";
975
+ var not_found_result = {
976
+ tsconfigFile: null,
977
+ tsconfig: {}
978
+ };
979
+ async function parse(filename, options) {
980
+ let cache = options?.cache;
981
+ if (cache?.hasParseResult(filename))
982
+ return getParsedDeep(filename, cache, options);
983
+ let {
984
+ resolve: resolve3,
985
+ reject,
986
+ /** @type {Promise<import('./public.d.ts').TSConfckParseResult>}*/
987
+ promise
988
+ } = makePromise();
989
+ cache?.setParseResult(filename, promise, !0);
990
+ try {
991
+ let tsconfigFile = await resolveTSConfigJson(filename, cache) || await find(filename, options);
992
+ if (!tsconfigFile)
993
+ return resolve3(not_found_result), promise;
994
+ let result;
995
+ filename !== tsconfigFile && cache?.hasParseResult(tsconfigFile) ? result = await getParsedDeep(tsconfigFile, cache, options) : (result = await parseFile(tsconfigFile, cache, filename === tsconfigFile), await Promise.all([parseExtends(result, cache), parseReferences(result, options)])), replaceTokens(result), resolve3(resolveSolutionTSConfig(filename, result));
996
+ } catch (e) {
997
+ reject(e);
998
+ }
999
+ return promise;
1000
+ }
1001
+ async function getParsedDeep(filename, cache, options) {
1002
+ let result = await cache.getParseResult(filename);
1003
+ if (result.tsconfig.extends && !result.extended || result.tsconfig.references && !result.referenced) {
1004
+ let promise = Promise.all([
1005
+ parseExtends(result, cache),
1006
+ parseReferences(result, options)
1007
+ ]).then(() => result);
1008
+ return cache.setParseResult(filename, promise, !0), promise;
1009
+ }
1010
+ return result;
1011
+ }
1012
+ async function parseFile(tsconfigFile, cache, skipCache) {
1013
+ if (!skipCache && cache?.hasParseResult(tsconfigFile) && !cache.getParseResult(tsconfigFile)._isRootFile_)
1014
+ return cache.getParseResult(tsconfigFile);
1015
+ let promise = fs3.readFile(tsconfigFile, "utf-8").then(toJson).then((json) => {
1016
+ let parsed = JSON.parse(json);
1017
+ return applyDefaults(parsed, tsconfigFile), {
1018
+ tsconfigFile,
1019
+ tsconfig: normalizeTSConfig(parsed, path4.dirname(tsconfigFile))
1020
+ };
1021
+ }).catch((e) => {
1022
+ throw new TSConfckParseError(
1023
+ `parsing ${tsconfigFile} failed: ${e}`,
1024
+ "PARSE_FILE",
1025
+ tsconfigFile,
1026
+ e
1027
+ );
1028
+ });
1029
+ return !skipCache && (!cache?.hasParseResult(tsconfigFile) || !cache.getParseResult(tsconfigFile)._isRootFile_) && cache?.setParseResult(tsconfigFile, promise), promise;
1030
+ }
1031
+ function normalizeTSConfig(tsconfig, dir) {
1032
+ let baseUrl = tsconfig.compilerOptions?.baseUrl;
1033
+ return baseUrl && !baseUrl.startsWith("${") && !path4.isAbsolute(baseUrl) && (tsconfig.compilerOptions.baseUrl = resolve2posix(dir, baseUrl)), tsconfig;
1034
+ }
1035
+ async function parseReferences(result, options) {
1036
+ if (!result.tsconfig.references)
1037
+ return;
1038
+ let referencedFiles = resolveReferencedTSConfigFiles(result, options), referenced = await Promise.all(
1039
+ referencedFiles.map((file) => parseFile(file, options?.cache))
1040
+ );
1041
+ await Promise.all(referenced.map((ref) => parseExtends(ref, options?.cache))), referenced.forEach((ref) => {
1042
+ ref.solution = result, replaceTokens(ref);
1043
+ }), result.referenced = referenced;
1044
+ }
1045
+ async function parseExtends(result, cache) {
1046
+ if (!result.tsconfig.extends)
1047
+ return;
1048
+ let extended = [
1049
+ { tsconfigFile: result.tsconfigFile, tsconfig: JSON.parse(JSON.stringify(result.tsconfig)) }
1050
+ ], pos = 0, extendsPath = [], currentBranchDepth = 0;
1051
+ for (; pos < extended.length; ) {
1052
+ let extending = extended[pos];
1053
+ if (extendsPath.push(extending.tsconfigFile), extending.tsconfig.extends) {
1054
+ currentBranchDepth += 1;
1055
+ let resolvedExtends;
1056
+ Array.isArray(extending.tsconfig.extends) ? resolvedExtends = extending.tsconfig.extends.reverse().map((ex) => resolveExtends(ex, extending.tsconfigFile)) : resolvedExtends = [resolveExtends(extending.tsconfig.extends, extending.tsconfigFile)];
1057
+ let circularExtends = resolvedExtends.find(
1058
+ (tsconfigFile) => extendsPath.includes(tsconfigFile)
1059
+ );
1060
+ if (circularExtends) {
1061
+ let circle = extendsPath.concat([circularExtends]).join(" -> ");
1062
+ throw new TSConfckParseError(
1063
+ `Circular dependency in "extends": ${circle}`,
1064
+ "EXTENDS_CIRCULAR",
1065
+ result.tsconfigFile
1066
+ );
1067
+ }
1068
+ extended.splice(
1069
+ pos + 1,
1070
+ 0,
1071
+ ...await Promise.all(resolvedExtends.map((file) => parseFile(file, cache)))
1072
+ );
1073
+ } else
1074
+ extendsPath.splice(-currentBranchDepth), currentBranchDepth = 0;
1075
+ pos = pos + 1;
1076
+ }
1077
+ result.extended = extended;
1078
+ for (let ext of result.extended.slice(1))
1079
+ extendTSConfig(result, ext);
1080
+ }
1081
+ function resolveExtends(extended, from) {
1082
+ [".", ".."].includes(extended) && (extended = extended + "/tsconfig.json");
1083
+ let req = createRequire(from), error;
1084
+ try {
1085
+ return req.resolve(extended);
1086
+ } catch (e) {
1087
+ error = e;
1088
+ }
1089
+ if (extended[0] !== "." && !path4.isAbsolute(extended))
1090
+ try {
1091
+ return req.resolve(`${extended}/tsconfig.json`);
1092
+ } catch (e) {
1093
+ error = e;
1094
+ }
1095
+ throw new TSConfckParseError(
1096
+ `failed to resolve "extends":"${extended}" in ${from}`,
1097
+ "EXTENDS_RESOLVE",
1098
+ from,
1099
+ error
1100
+ );
1101
+ }
1102
+ var EXTENDABLE_KEYS = [
1103
+ "compilerOptions",
1104
+ "files",
1105
+ "include",
1106
+ "exclude",
1107
+ "watchOptions",
1108
+ "compileOnSave",
1109
+ "typeAcquisition",
1110
+ "buildOptions"
1111
+ ];
1112
+ function extendTSConfig(extending, extended) {
1113
+ let extendingConfig = extending.tsconfig, extendedConfig = extended.tsconfig, relativePath = native2posix(
1114
+ path4.relative(path4.dirname(extending.tsconfigFile), path4.dirname(extended.tsconfigFile))
1115
+ );
1116
+ for (let key of Object.keys(extendedConfig).filter((key2) => EXTENDABLE_KEYS.includes(key2)))
1117
+ if (key === "compilerOptions") {
1118
+ extendingConfig.compilerOptions || (extendingConfig.compilerOptions = {});
1119
+ for (let option of Object.keys(extendedConfig.compilerOptions))
1120
+ Object.prototype.hasOwnProperty.call(extendingConfig.compilerOptions, option) || (extendingConfig.compilerOptions[option] = rebaseRelative(
1121
+ option,
1122
+ extendedConfig.compilerOptions[option],
1123
+ relativePath
1124
+ ));
1125
+ } else if (extendingConfig[key] === void 0)
1126
+ if (key === "watchOptions") {
1127
+ extendingConfig.watchOptions = {};
1128
+ for (let option of Object.keys(extendedConfig.watchOptions))
1129
+ extendingConfig.watchOptions[option] = rebaseRelative(
1130
+ option,
1131
+ extendedConfig.watchOptions[option],
1132
+ relativePath
1133
+ );
1134
+ } else
1135
+ extendingConfig[key] = rebaseRelative(key, extendedConfig[key], relativePath);
1136
+ }
1137
+ var REBASE_KEYS = [
1138
+ // root
1139
+ "files",
1140
+ "include",
1141
+ "exclude",
1142
+ // compilerOptions
1143
+ "baseUrl",
1144
+ "rootDir",
1145
+ "rootDirs",
1146
+ "typeRoots",
1147
+ "outDir",
1148
+ "outFile",
1149
+ "declarationDir",
1150
+ // watchOptions
1151
+ "excludeDirectories",
1152
+ "excludeFiles"
1153
+ ];
1154
+ function rebaseRelative(key, value, prependPath) {
1155
+ return REBASE_KEYS.includes(key) ? Array.isArray(value) ? value.map((x) => rebasePath(x, prependPath)) : rebasePath(value, prependPath) : value;
1156
+ }
1157
+ function rebasePath(value, prependPath) {
1158
+ return path4.isAbsolute(value) || value.startsWith("${configDir}") ? value : path4.posix.normalize(path4.posix.join(prependPath, value));
1159
+ }
1160
+ var TSConfckParseError = class _TSConfckParseError extends Error {
1161
+ /**
1162
+ * error code
1163
+ * @type {string}
1164
+ */
1165
+ code;
1166
+ /**
1167
+ * error cause
1168
+ * @type { Error | undefined}
1169
+ */
1170
+ cause;
1171
+ /**
1172
+ * absolute path of tsconfig file where the error happened
1173
+ * @type {string}
1174
+ */
1175
+ tsconfigFile;
1176
+ /**
1177
+ *
1178
+ * @param {string} message - error message
1179
+ * @param {string} code - error code
1180
+ * @param {string} tsconfigFile - path to tsconfig file
1181
+ * @param {Error?} cause - cause of this error
1182
+ */
1183
+ constructor(message, code, tsconfigFile, cause) {
1184
+ super(message), Object.setPrototypeOf(this, _TSConfckParseError.prototype), this.name = _TSConfckParseError.name, this.code = code, this.cause = cause, this.tsconfigFile = tsconfigFile;
1185
+ }
1186
+ };
1187
+ function applyDefaults(tsconfig, tsconfigFile) {
1188
+ isJSConfig(tsconfigFile) && (tsconfig.compilerOptions = {
1189
+ ...DEFAULT_JSCONFIG_COMPILER_OPTIONS,
1190
+ ...tsconfig.compilerOptions
1191
+ });
1192
+ }
1193
+ var DEFAULT_JSCONFIG_COMPILER_OPTIONS = {
1194
+ allowJs: !0,
1195
+ maxNodeModuleJsDepth: 2,
1196
+ allowSyntheticDefaultImports: !0,
1197
+ skipLibCheck: !0,
1198
+ noEmit: !0
1199
+ };
1200
+ function isJSConfig(configFileName) {
1201
+ return path4.basename(configFileName) === "jsconfig.json";
1202
+ }
1203
+
1204
+ // ../../../node_modules/tsconfck/src/find-native.js
1205
+ import path5 from "node:path";
1206
+ async function findNative(filename, options) {
1207
+ let dir = native2posix(path5.dirname(path5.resolve(filename)));
1208
+ if (options?.ignoreNodeModules && isInNodeModules(dir))
1209
+ return null;
1210
+ let cache = options?.cache, root = options?.root ? native2posix(path5.resolve(options.root)) : void 0, configName = options?.configName ?? "tsconfig.json";
1211
+ if (cache?.hasConfigPath(dir, configName))
1212
+ return cache.getConfigPath(dir, configName);
1213
+ let ts = await loadTS(), { findConfigFile, sys } = ts, tsconfigFile = findConfigFile(dir, sys.fileExists, configName);
1214
+ return (!tsconfigFile || is_out_of_root(tsconfigFile, root)) && (tsconfigFile = null), cache && cache_result(tsconfigFile, dir, cache, root, configName), tsconfigFile;
1215
+ }
1216
+ function is_out_of_root(tsconfigFile, root) {
1217
+ return root && !tsconfigFile.startsWith(root);
1218
+ }
1219
+ function cache_result(tsconfigFile, fileDir, cache, root, configName) {
1220
+ let tsconfigDir = tsconfigFile ? path5.dirname(tsconfigFile) : root, directories = [], dir = fileDir;
1221
+ for (; dir; ) {
1222
+ directories.push(dir);
1223
+ let parent = path5.dirname(dir);
1224
+ if (tsconfigDir === dir || parent === dir)
1225
+ break;
1226
+ dir = parent;
1227
+ }
1228
+ directories.forEach((d) => {
1229
+ cache.setConfigPath(d, Promise.resolve(tsconfigFile), configName);
1230
+ });
1231
+ }
1232
+
1233
+ // ../../../node_modules/tsconfck/src/parse-native.js
1234
+ import path6 from "node:path";
1235
+ var notFoundResult = {
1236
+ tsconfigFile: null,
1237
+ tsconfig: {},
1238
+ result: null
1239
+ };
1240
+ async function parseNative(filename, options) {
1241
+ let cache = options?.cache;
1242
+ if (cache?.hasParseResult(filename))
1243
+ return cache.getParseResult(filename);
1244
+ let {
1245
+ resolve: resolve3,
1246
+ reject,
1247
+ /** @type {Promise<import('./public.d.ts').TSConfckParseNativeResult>}*/
1248
+ promise
1249
+ } = makePromise();
1250
+ cache?.setParseResult(filename, promise);
1251
+ try {
1252
+ let tsconfigFile = await resolveTSConfigJson(filename, cache) || await findNative(filename, options);
1253
+ if (!tsconfigFile)
1254
+ return resolve3(notFoundResult), promise;
1255
+ let result;
1256
+ if (filename !== tsconfigFile && cache?.hasParseResult(tsconfigFile))
1257
+ result = await cache.getParseResult(tsconfigFile);
1258
+ else {
1259
+ let ts = await loadTS();
1260
+ result = await parseFile2(tsconfigFile, ts, options, filename === tsconfigFile), await parseReferences2(result, ts, options), cache?.setParseResult(tsconfigFile, Promise.resolve(result));
1261
+ }
1262
+ return resolve3(resolveSolutionTSConfig(filename, result)), promise;
1263
+ } catch (e) {
1264
+ return reject(e), promise;
1265
+ }
1266
+ }
1267
+ function parseFile2(tsconfigFile, ts, options, skipCache) {
1268
+ let cache = options?.cache;
1269
+ if (!skipCache && cache?.hasParseResult(tsconfigFile))
1270
+ return cache.getParseResult(tsconfigFile);
1271
+ let posixTSConfigFile = native2posix(tsconfigFile), { parseJsonConfigFileContent, readConfigFile, sys } = ts, { config, error } = readConfigFile(posixTSConfigFile, sys.readFile);
1272
+ if (error)
1273
+ throw new TSConfckParseNativeError(error, tsconfigFile, null);
1274
+ let host = {
1275
+ useCaseSensitiveFileNames: !1,
1276
+ readDirectory: sys.readDirectory,
1277
+ fileExists: sys.fileExists,
1278
+ readFile: sys.readFile
1279
+ };
1280
+ options?.ignoreSourceFiles && (config.files = [], config.include = []);
1281
+ let nativeResult = parseJsonConfigFileContent(
1282
+ config,
1283
+ host,
1284
+ path6.dirname(posixTSConfigFile),
1285
+ void 0,
1286
+ posixTSConfigFile
1287
+ );
1288
+ checkErrors(nativeResult, tsconfigFile);
1289
+ let result = {
1290
+ tsconfigFile,
1291
+ tsconfig: result2tsconfig(nativeResult, ts, tsconfigFile),
1292
+ result: nativeResult
1293
+ };
1294
+ return skipCache || cache?.setParseResult(tsconfigFile, Promise.resolve(result)), result;
1295
+ }
1296
+ async function parseReferences2(result, ts, options) {
1297
+ if (!result.tsconfig.references)
1298
+ return;
1299
+ let referencedFiles = resolveReferencedTSConfigFiles(result, options);
1300
+ result.referenced = await Promise.all(
1301
+ referencedFiles.map((file) => parseFile2(file, ts, options))
1302
+ ), result.referenced.forEach((ref) => ref.solution = result);
1303
+ }
1304
+ function checkErrors(nativeResult, tsconfigFile) {
1305
+ let ignoredErrorCodes = [
1306
+ // see https://github.com/microsoft/TypeScript/blob/main/src/compiler/diagnosticMessages.json
1307
+ 18002,
1308
+ // empty files list
1309
+ 18003
1310
+ // no inputs
1311
+ ], criticalError = nativeResult.errors?.find(
1312
+ (error) => error.category === 1 && !ignoredErrorCodes.includes(error.code)
1313
+ );
1314
+ if (criticalError)
1315
+ throw new TSConfckParseNativeError(criticalError, tsconfigFile, nativeResult);
1316
+ }
1317
+ function result2tsconfig(result, ts, tsconfigFile) {
1318
+ let tsconfig = JSON.parse(JSON.stringify(result.raw)), ignoredOptions = ["configFilePath", "pathsBasePath"];
1319
+ if (result.options && Object.keys(result.options).some((o) => !ignoredOptions.includes(o))) {
1320
+ tsconfig.compilerOptions = {
1321
+ ...result.options
1322
+ };
1323
+ for (let ignored of ignoredOptions)
1324
+ delete tsconfig.compilerOptions[ignored];
1325
+ }
1326
+ let compilerOptions = tsconfig.compilerOptions;
1327
+ if (compilerOptions) {
1328
+ compilerOptions.lib != null && (compilerOptions.lib = compilerOptions.lib.map(
1329
+ (x) => x.replace(/^lib\./, "").replace(/\.d\.ts$/, "")
1330
+ ));
1331
+ let enumProperties = [
1332
+ { name: "importsNotUsedAsValues", enumeration: ts.ImportsNotUsedAsValues },
1333
+ { name: "module", enumeration: ts.ModuleKind },
1334
+ {
1335
+ name: "moduleResolution",
1336
+ enumeration: {
1337
+ ...ts.ModuleResolutionKind,
1338
+ 2: "node"
1339
+ /*ts.ModuleResolutionKind uses "Node10" but in tsconfig it is just node"*/
1340
+ }
1341
+ },
1342
+ {
1343
+ name: "newLine",
1344
+ enumeration: { 0: "crlf", 1: "lf" }
1345
+ /*ts.NewLineKind uses different names*/
1346
+ },
1347
+ { name: "target", enumeration: ts.ScriptTarget }
1348
+ ];
1349
+ for (let prop of enumProperties)
1350
+ compilerOptions[prop.name] != null && typeof compilerOptions[prop.name] == "number" && (compilerOptions[prop.name] = prop.enumeration[compilerOptions[prop.name]].toLowerCase());
1351
+ compilerOptions.target === "latest" && (compilerOptions.target = "esnext");
1352
+ }
1353
+ result.watchOptions && (tsconfig.watchOptions = {
1354
+ ...result.watchOptions
1355
+ });
1356
+ let watchOptions = tsconfig.watchOptions;
1357
+ if (watchOptions) {
1358
+ let enumProperties = [
1359
+ { name: "watchFile", enumeration: ts.WatchFileKind },
1360
+ { name: "watchDirectory", enumeration: ts.WatchDirectoryKind },
1361
+ { name: "fallbackPolling", enumeration: ts.PollingWatchKind }
1362
+ ];
1363
+ for (let prop of enumProperties)
1364
+ if (watchOptions[prop.name] != null && typeof watchOptions[prop.name] == "number") {
1365
+ let enumVal = prop.enumeration[watchOptions[prop.name]];
1366
+ watchOptions[prop.name] = enumVal.charAt(0).toLowerCase() + enumVal.slice(1);
1367
+ }
1368
+ }
1369
+ tsconfig.compileOnSave === !1 && delete tsconfig.compileOnSave;
1370
+ let parseResult = { tsconfig, tsconfigFile };
1371
+ return replaceTokens(parseResult), parseResult.tsconfig;
1372
+ }
1373
+ var TSConfckParseNativeError = class _TSConfckParseNativeError extends Error {
1374
+ /**
1375
+ *
1376
+ * @param {TSDiagnosticError} diagnostic - diagnostics of ts
1377
+ * @param {string} tsconfigFile - file that errored
1378
+ * @param {any?} result - parsed result, if any
1379
+ */
1380
+ constructor(diagnostic, tsconfigFile, result) {
1381
+ super(diagnostic.messageText), Object.setPrototypeOf(this, _TSConfckParseNativeError.prototype), this.name = _TSConfckParseNativeError.name, this.code = `TS ${diagnostic.code}`, this.diagnostic = diagnostic, this.result = result, this.tsconfigFile = tsconfigFile;
1382
+ }
1383
+ /**
1384
+ * code of typescript diagnostic, prefixed with "TS "
1385
+ * @type {string}
1386
+ */
1387
+ code;
1388
+ /**
1389
+ * full ts diagnostic that caused this error
1390
+ * @type {TSDiagnosticError}
1391
+ */
1392
+ diagnostic;
1393
+ /**
1394
+ * absolute path of tsconfig file where the error happened
1395
+ * @type {string}
1396
+ */
1397
+ tsconfigFile;
1398
+ /**
1399
+ * native result if present, contains all errors in result.errors
1400
+ * @type {any|undefined}
1401
+ */
1402
+ result;
1403
+ };
1404
+
1405
+ // ../../../node_modules/vite-tsconfig-paths/dist/index.js
1406
+ import { resolve as resolve2 } from "path";
1407
+ var debug = (0, import_debug.default)("vite-tsconfig-paths");
1408
+ process.env.TEST === "vite-tsconfig-paths" && import_debug.default.enable("vite-tsconfig-paths");
1409
+ function createLogFile(logFilePath) {
1410
+ let mtime;
1411
+ try {
1412
+ mtime = statSync(logFilePath).mtime.getTime();
1413
+ } catch {
1414
+ }
1415
+ (!mtime || Date.now() - mtime > 1e4) && (debug("Clearing log file:", logFilePath), writeFileSync(logFilePath, ""));
1416
+ let logFile = createWriteStream(logFilePath, {
1417
+ flags: "a",
1418
+ encoding: "utf-8"
1419
+ });
1420
+ return {
1421
+ write(...event) {
1422
+ logFile.write(event[0] + ": " + JSON.stringify(event[1]) + `
1423
+ `);
1424
+ }
1425
+ };
1426
+ }
1427
+ var isWindows = os.platform() == "win32", normalize = (p) => {
1428
+ let output = vite.normalizePath(p);
1429
+ return isWindows && output[1] === ":" && (output = output[0].toUpperCase() + output.substring(1)), output;
1430
+ }, parse22 = path7.parse, resolve = isWindows ? (...paths) => normalize(path7.win32.resolve(...paths)) : path7.posix.resolve, isAbsolute = isWindows ? path7.win32.isAbsolute : path7.posix.isAbsolute, join = path7.posix.join, relative = path7.posix.relative, basename = path7.posix.basename, dirname2 = path7.dirname, relativeImportRE = /^\.\.?(\/|$)/;
1431
+ function resolvePathMappings(paths, base) {
1432
+ let sortedPatterns = Object.keys(paths).sort(
1433
+ (a, b) => getPrefixLength(b) - getPrefixLength(a)
1434
+ ), resolved = [];
1435
+ for (let pattern of sortedPatterns) {
1436
+ let relativePaths = paths[pattern];
1437
+ pattern = escapeStringRegexp(pattern).replace(/\*/g, "(.+)"), resolved.push({
1438
+ pattern: new RegExp("^" + pattern + "$"),
1439
+ paths: relativePaths.map((relativePath) => resolve2(base, relativePath))
1440
+ });
1441
+ }
1442
+ return resolved;
1443
+ }
1444
+ function getPrefixLength(pattern) {
1445
+ let prefixLength = pattern.indexOf("*");
1446
+ return pattern.substr(0, prefixLength).length;
1447
+ }
1448
+ function escapeStringRegexp(string) {
1449
+ return string.replace(/[|\\{}()[\]^$+?.]/g, "\\$&").replace(/-/g, "\\x2d");
1450
+ }
1451
+ var notApplicable = [void 0, !1], notFound = [void 0, !0], emptyDirectory = {
1452
+ projects: Object.freeze([]),
1453
+ lazyDiscovery: !1
1454
+ };
1455
+ function createTsconfigResolvers({
1456
+ projectRoot,
1457
+ workspaceRoot,
1458
+ skip = () => !1,
1459
+ logFile,
1460
+ logger,
1461
+ ...opts
1462
+ }) {
1463
+ let initializing, directoryCache, resolversByProject, isFirstParseError = !0, hasTypeScriptDep = !1;
1464
+ if (opts.parseNative)
1465
+ try {
1466
+ let pkgJson = fs4.readFileSync(
1467
+ join2(workspaceRoot, "package.json"),
1468
+ "utf8"
1469
+ ), pkg = JSON.parse(pkgJson);
1470
+ hasTypeScriptDep = "typescript" in { ...pkg.dependencies, ...pkg.devDependencies };
1471
+ } catch (e) {
1472
+ if (e.code != "ENOENT")
1473
+ throw e;
1474
+ }
1475
+ let configNames = opts.configNames || ["tsconfig.json", "jsconfig.json"];
1476
+ debug(
1477
+ "Only tsconfig files with a name in this list are discoverable:",
1478
+ configNames
1479
+ );
1480
+ let parseProject = async (tsconfigFile) => {
1481
+ tsconfigFile = normalize(tsconfigFile);
1482
+ try {
1483
+ return hasTypeScriptDep ? await parseNative(tsconfigFile) : await parse(tsconfigFile);
1484
+ } catch (error) {
1485
+ return opts.ignoreConfigErrors ? (debug("[!] Failed to parse tsconfig file at %s", tsconfigFile), isFirstParseError && debug("Remove the `ignoreConfigErrors` option to see the error.")) : (logger.error(
1486
+ '[tsconfig-paths] An error occurred while parsing "' + tsconfigFile + '". See below for details.' + (isFirstParseError ? " To disable this message, set the `ignoreConfigErrors` option to true." : ""),
1487
+ { error }
1488
+ ), logger.hasErrorLogged(error) || console.error(error)), isFirstParseError = !1, null;
1489
+ }
1490
+ }, onBeforeAddProject, onParseError, addProject = (project, data) => {
1491
+ let tsconfigFile = project.tsconfigFile, dir = normalize(dirname2(tsconfigFile));
1492
+ if (data ?? (data = directoryCache.get(dir)), data?.projects.some((p) => p.tsconfigFile === tsconfigFile))
1493
+ return;
1494
+ onBeforeAddProject?.(project), project.referenced && (project.referenced.forEach((projectRef) => {
1495
+ addProject(projectRef);
1496
+ }), data = directoryCache.get(dir));
1497
+ let resolver = createResolver(project, opts, logFile);
1498
+ resolver && resolversByProject.set(project, resolver), (!data || data === emptyDirectory) && directoryCache.set(
1499
+ dir,
1500
+ data = {
1501
+ projects: [],
1502
+ lazyDiscovery: null
1503
+ }
1504
+ ), data.projects.push(project);
1505
+ }, loadProject = async (tsconfigFile, data) => {
1506
+ let project = await parseProject(tsconfigFile);
1507
+ project ? addProject(project, data) : onParseError?.(tsconfigFile);
1508
+ }, sortProjects = (projects) => {
1509
+ projects.sort(
1510
+ (left, right) => left.tsconfigFile.localeCompare(right.tsconfigFile)
1511
+ );
1512
+ }, processConfigFile = async (dir, name, data = directoryCache.get(dir)) => {
1513
+ if (!data)
1514
+ return;
1515
+ let file = join(dir, name);
1516
+ data.projects.some((p) => p.tsconfigFile === file) || await loadProject(file, data);
1517
+ }, loadEagerProjects = async () => {
1518
+ let projectPaths;
1519
+ if (opts.projects)
1520
+ projectPaths = opts.projects.map((file) => (file.endsWith(".json") || (file = join2(file, "tsconfig.json")), resolve(projectRoot, file)));
1521
+ else {
1522
+ if (opts.projectDiscovery === "lazy")
1523
+ return;
1524
+ projectPaths = await findAll(workspaceRoot, {
1525
+ configNames,
1526
+ skip
1527
+ });
1528
+ }
1529
+ debug("Eagerly parsing these projects:", projectPaths), await Promise.all(Array.from(new Set(projectPaths), (p) => loadProject(p)));
1530
+ for (let data of directoryCache.values())
1531
+ sortProjects(data.projects);
1532
+ }, resetResolvers = () => {
1533
+ directoryCache = /* @__PURE__ */ new Map(), resolversByProject = /* @__PURE__ */ new WeakMap(), initializing = loadEagerProjects();
1534
+ }, discoverProjects = async (dir, data) => {
1535
+ debug("Searching directory for tsconfig files:", dir);
1536
+ let names = await readdir2(dir).catch(() => []);
1537
+ await Promise.all(
1538
+ names.filter((name) => configNames.includes(name)).map((name) => processConfigFile(dir, name, data))
1539
+ ), data.projects.length ? (sortProjects(data.projects), debug.enabled && debug(
1540
+ `Directory "${dir}" contains the following tsconfig files:`,
1541
+ data.projects.map((p) => basename(p.tsconfigFile))
1542
+ )) : (directoryCache.set(dir, emptyDirectory), debug("No tsconfig files found in directory:", dir));
1543
+ };
1544
+ return {
1545
+ reset: resetResolvers,
1546
+ get: async function* (importer) {
1547
+ var _a;
1548
+ await initializing;
1549
+ let dir = normalize(importer), { root } = parse22(dir);
1550
+ for (; dir !== (dir = dirname2(dir)) && dir !== root; ) {
1551
+ let data = directoryCache.get(dir);
1552
+ if (opts.projectDiscovery === "lazy") {
1553
+ if (!data) {
1554
+ if (skip(basename(dir))) {
1555
+ directoryCache.set(dir, emptyDirectory);
1556
+ continue;
1557
+ }
1558
+ directoryCache.set(
1559
+ dir,
1560
+ data = {
1561
+ projects: [],
1562
+ lazyDiscovery: null
1563
+ }
1564
+ );
1565
+ }
1566
+ await ((_a = data.lazyDiscovery) != null ? _a : data.lazyDiscovery = discoverProjects(dir, data));
1567
+ } else if (!data)
1568
+ continue;
1569
+ for (let project of data.projects) {
1570
+ let resolver = resolversByProject.get(project);
1571
+ resolver && (yield resolver);
1572
+ }
1573
+ }
1574
+ },
1575
+ watch: (watcher) => {
1576
+ onBeforeAddProject = (project) => {
1577
+ var _a;
1578
+ watcher.add(project.tsconfigFile), (_a = project.extended) == null || _a.forEach((parent) => {
1579
+ watcher.add(parent.tsconfigFile);
1580
+ });
1581
+ }, onParseError = (tsconfigFile) => {
1582
+ watcher.add(tsconfigFile);
1583
+ }, watcher.on("all", (event, file) => {
1584
+ let normalizedFile = normalize(file);
1585
+ !normalizedFile.endsWith(".json") || !isAbsolute(normalizedFile) || (event === "add" ? configNames.includes(basename(normalizedFile)) && processConfigFile(
1586
+ dirname2(normalizedFile),
1587
+ basename(normalizedFile)
1588
+ ).catch(console.error) : (event === "change" || event === "unlink") && invalidateConfigFile(
1589
+ dirname2(normalizedFile),
1590
+ basename(normalizedFile),
1591
+ event
1592
+ ));
1593
+ });
1594
+ function invalidateConfigFile(dir, name, event) {
1595
+ let data = directoryCache.get(dir);
1596
+ if (!data)
1597
+ return;
1598
+ let file = join(dir, name), index = data.projects.findIndex(
1599
+ (project) => project.tsconfigFile === file
1600
+ );
1601
+ if (index !== -1) {
1602
+ let project = data.projects[index];
1603
+ debug(
1604
+ `Unloading project because of ${event} event:`,
1605
+ project.tsconfigFile
1606
+ ), resolversByProject.delete(project), data.projects.splice(index, 1), event === "change" && (opts.projectDiscovery === "lazy" ? data.lazyDiscovery = null : loadProject(project.tsconfigFile, data).then(() => {
1607
+ sortProjects(data.projects);
1608
+ }).catch(console.error));
1609
+ }
1610
+ }
1611
+ }
1612
+ };
1613
+ }
1614
+ function createResolver(project, opts, logFile) {
1615
+ var _a, _b, _c, _d, _e;
1616
+ let configPath = project.tsconfigFile, config = project.tsconfig;
1617
+ if (debug("Config loaded:", inspect({ configPath, config }, !1, 10, !0)), ((_a = config.files) == null ? void 0 : _a.length) == 0 && !((_b = config.include) != null && _b.length))
1618
+ return debug(
1619
+ `[!] Skipping "${configPath}" as no files can be matched since "files" is empty and "include" is missing or empty.`
1620
+ ), null;
1621
+ let compilerOptions = config.compilerOptions || {}, { baseUrl, paths } = compilerOptions, resolveWithBaseUrl = baseUrl ? async (viteResolve, id, importer) => {
1622
+ if (id[0] === "/")
1623
+ return;
1624
+ let absoluteId = join2(baseUrl, id), resolvedId = await viteResolve(absoluteId, importer);
1625
+ if (resolvedId)
1626
+ return resolvedId.endsWith(".json") && !id.endsWith(".json") ? void 0 : (logFile?.write("resolvedWithBaseUrl", {
1627
+ importer,
1628
+ id,
1629
+ resolvedId,
1630
+ configPath
1631
+ }), resolvedId);
1632
+ } : void 0, resolveId;
1633
+ if (paths) {
1634
+ let pathsRootDir = resolvePathsRootDir(project), pathMappings = resolvePathMappings(paths, pathsRootDir), resolveWithPaths = async (viteResolve, id, importer) => {
1635
+ let candidates = logFile ? [] : null;
1636
+ for (let mapping of pathMappings) {
1637
+ let match = id.match(mapping.pattern);
1638
+ if (match)
1639
+ for (let pathTemplate of mapping.paths) {
1640
+ let starCount = 0, mappedId = pathTemplate.replace(/\*/g, () => {
1641
+ let matchIndex = Math.min(++starCount, match.length - 1);
1642
+ return match[matchIndex];
1643
+ });
1644
+ candidates?.push(mappedId);
1645
+ let resolvedId = await viteResolve(mappedId, importer);
1646
+ if (resolvedId)
1647
+ return logFile?.write("resolvedWithPaths", {
1648
+ importer,
1649
+ id,
1650
+ resolvedId,
1651
+ configPath
1652
+ }), resolvedId;
1653
+ }
1654
+ }
1655
+ logFile?.write("notFound", {
1656
+ importer,
1657
+ id,
1658
+ candidates,
1659
+ configPath
1660
+ });
1661
+ };
1662
+ resolveWithBaseUrl ? resolveId = async (viteResolve, id, importer) => {
1663
+ var _a2;
1664
+ return (_a2 = await resolveWithPaths(viteResolve, id, importer)) != null ? _a2 : await resolveWithBaseUrl(viteResolve, id, importer);
1665
+ } : resolveId = resolveWithPaths;
1666
+ } else if (resolveWithBaseUrl)
1667
+ resolveId = resolveWithBaseUrl;
1668
+ else
1669
+ return debug(`[!] Skipping "${configPath}" as no paths or baseUrl are defined.`), null;
1670
+ let configDir = normalize(dirname2(configPath)), outDir = compilerOptions.outDir && normalize(compilerOptions.outDir);
1671
+ outDir && isAbsolute(outDir) && (outDir = relative(configDir, outDir));
1672
+ let isIncludedRelative = getIncluder(
1673
+ (_c = config.include) == null ? void 0 : _c.map((p) => ensureRelative(configDir, p)),
1674
+ (_d = config.exclude) == null ? void 0 : _d.map((p) => ensureRelative(configDir, p)),
1675
+ outDir
1676
+ ), isImporterSupported = opts.loose ? () => !0 : (_e = opts.importerFilter) != null ? _e : (() => {
1677
+ let extensionFilter = compilerOptions.allowJs || basename(configPath).startsWith("jsconfig.") ? /\.(astro|mdx|svelte|vue|[mc]?[jt]sx?)$/ : /\.[mc]?tsx?$/;
1678
+ return (importer) => extensionFilter.test(importer);
1679
+ })(), resolutionCache = /* @__PURE__ */ new Map(), hashQueryPattern = /[#?].+$/, queryPattern = /\?.+$/, dtsPattern = /\.d\.ts(\?|$)/;
1680
+ return async (viteResolve, id, importer) => {
1681
+ var _a2;
1682
+ let importerFile = normalize(importer.replace(hashQueryPattern, ""));
1683
+ if (!isImporterSupported(importerFile))
1684
+ return logFile?.write("unsupportedExtension", { importer, id }), notApplicable;
1685
+ let relativeImporterFile = relative(configDir, importerFile);
1686
+ if (!isIncludedRelative(relativeImporterFile))
1687
+ return logFile?.write("configMismatch", { importer, id, configPath }), notApplicable;
1688
+ let query = (_a2 = queryPattern.exec(id)) == null ? void 0 : _a2[0];
1689
+ query && (id = id.slice(0, -query.length));
1690
+ let resolvedId = resolutionCache.get(id);
1691
+ if (resolvedId)
1692
+ logFile?.write("resolvedFromCache", {
1693
+ importer,
1694
+ id,
1695
+ resolvedId,
1696
+ configPath
1697
+ });
1698
+ else {
1699
+ if (resolvedId = await resolveId(viteResolve, id, importer), !resolvedId)
1700
+ return notFound;
1701
+ resolutionCache.set(id, resolvedId);
1702
+ }
1703
+ return dtsPattern.test(resolvedId) ? (logFile?.write("resolvedToDeclarationFile", {
1704
+ importer,
1705
+ id,
1706
+ resolvedId,
1707
+ configPath
1708
+ }), notApplicable) : (query && (resolvedId += query), [resolvedId, !0]);
1709
+ };
1710
+ }
1711
+ function resolvePathsRootDir(project) {
1712
+ var _a, _b;
1713
+ if (project.result) {
1714
+ let { options } = project.result;
1715
+ return options && typeof options.pathsBasePath == "string" ? options.pathsBasePath : dirname2(project.tsconfigFile);
1716
+ }
1717
+ let baseUrl = (_a = project.tsconfig.compilerOptions) == null ? void 0 : _a.baseUrl;
1718
+ if (baseUrl)
1719
+ return baseUrl;
1720
+ let projectWithPaths = (_b = project.extended) == null ? void 0 : _b.find(
1721
+ (project2) => {
1722
+ var _a2;
1723
+ return (_a2 = project2.tsconfig.compilerOptions) == null ? void 0 : _a2.paths;
1724
+ }
1725
+ );
1726
+ return dirname2((projectWithPaths ?? project).tsconfigFile);
1727
+ }
1728
+ var defaultInclude = ["**/*"], defaultExclude = [
1729
+ "**/node_modules",
1730
+ "**/bower_components",
1731
+ "**/jspm_packages"
1732
+ ];
1733
+ function getIncluder(includePaths = defaultInclude, excludePaths = defaultExclude, outDir) {
1734
+ if (outDir && (excludePaths = excludePaths.concat(outDir)), includePaths.length || excludePaths.length) {
1735
+ let includers = [], excluders = [];
1736
+ return includePaths.forEach(addCompiledGlob, includers), excludePaths.forEach(addCompiledGlob, excluders), debug.enabled && debug("Compiled tsconfig globs:", {
1737
+ include: {
1738
+ globs: includePaths,
1739
+ regexes: includers
1740
+ },
1741
+ exclude: {
1742
+ globs: excludePaths,
1743
+ regexes: excluders
1744
+ }
1745
+ }), (id) => {
1746
+ id = id.replace(/\?.+$/, ""), relativeImportRE.test(id) || (id = "./" + id);
1747
+ let test = (glob) => glob.test(id);
1748
+ return includers.some(test) && !excluders.some(test);
1749
+ };
1750
+ }
1751
+ return () => !0;
1752
+ }
1753
+ function addCompiledGlob(glob) {
1754
+ let endsWithGlob = glob.split("/").pop().includes("*"), relativeGlob = relativeImportRE.test(glob) ? glob : "./" + glob;
1755
+ endsWithGlob ? this.push(compileGlob(relativeGlob)) : (this.push(compileGlob(relativeGlob + "/**")), /\.\w+$/.test(glob) && this.push(compileGlob(relativeGlob)));
1756
+ }
1757
+ function compileGlob(glob) {
1758
+ return (0, import_globrex.default)(glob, {
1759
+ extended: !0,
1760
+ globstar: !0
1761
+ }).regex;
1762
+ }
1763
+ function ensureRelative(dir, path22) {
1764
+ return isAbsolute2(path22) ? relative2(dir, path22) : path22;
1765
+ }
1766
+ var src_default = (opts = {}) => {
1767
+ let tsconfigResolvers, isFirstBuild = !0, logFile = opts.logFile ? createLogFile(
1768
+ opts.logFile === !0 ? "vite-tsconfig-paths.log" : opts.logFile
1769
+ ) : null;
1770
+ return debug("Plugin options:", opts), {
1771
+ name: "vite-tsconfig-paths",
1772
+ enforce: "pre",
1773
+ configResolved(config) {
1774
+ let projectRoot, workspaceRoot;
1775
+ opts.root ? projectRoot = workspaceRoot = resolve(config.root, opts.root) : (projectRoot = normalize(config.root), workspaceRoot = normalize(vite2.searchForWorkspaceRoot(config.root))), debug("Project root: ", projectRoot), debug("Workspace root:", workspaceRoot), tsconfigResolvers = createTsconfigResolvers({
1776
+ ...opts,
1777
+ projectRoot,
1778
+ workspaceRoot,
1779
+ logFile,
1780
+ logger: config.logger,
1781
+ skip(dir) {
1782
+ return dir === ".git" || dir === "node_modules" ? !0 : typeof opts.skip == "function" ? opts.skip(dir) : !1;
1783
+ }
1784
+ }), tsconfigResolvers.reset();
1785
+ },
1786
+ configureServer(server) {
1787
+ tsconfigResolvers.watch(server.watcher);
1788
+ },
1789
+ buildStart() {
1790
+ if (isFirstBuild) {
1791
+ isFirstBuild = !1;
1792
+ return;
1793
+ }
1794
+ tsconfigResolvers.reset();
1795
+ },
1796
+ async resolveId(id, importer, options) {
1797
+ if (!importer) {
1798
+ logFile?.write("emptyImporter", { importer, id });
1799
+ return;
1800
+ }
1801
+ if (relativeImportRE.test(id)) {
1802
+ logFile?.write("relativeId", { importer, id });
1803
+ return;
1804
+ }
1805
+ if (id.includes("\0")) {
1806
+ logFile?.write("virtualId", { importer, id });
1807
+ return;
1808
+ }
1809
+ let importerFile = importer;
1810
+ if (importer[0] === "\0") {
1811
+ let index = importer.indexOf("?");
1812
+ if (index !== -1) {
1813
+ let query = normalize(importer.slice(index + 1));
1814
+ if (isAbsolute(query) && fs22.existsSync(query))
1815
+ debug("Rewriting virtual importer to real file:", importer), importerFile = query;
1816
+ else {
1817
+ logFile?.write("virtualImporter", { importer, id });
1818
+ return;
1819
+ }
1820
+ } else {
1821
+ logFile?.write("virtualImporter", { importer, id });
1822
+ return;
1823
+ }
1824
+ }
1825
+ let resolveOptions = { ...options, skipSelf: !0 }, viteResolve = async (id2, importer2) => {
1826
+ var _a;
1827
+ return (_a = await this.resolve(id2, importer2, resolveOptions)) == null ? void 0 : _a.id;
1828
+ };
1829
+ for await (let resolveId of tsconfigResolvers.get(importerFile)) {
1830
+ let [resolved, matched] = await resolveId(
1831
+ viteResolve,
1832
+ id,
1833
+ importerFile
1834
+ );
1835
+ if (resolved)
1836
+ return resolved;
1837
+ if (matched)
1838
+ break;
1839
+ }
1840
+ }
1841
+ };
1842
+ };
1843
+
1844
+ export {
1845
+ src_default
1846
+ };