@maltty/cli 1.0.0-rc.0

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 (109) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +88 -0
  3. package/bin/maltty.js +3 -0
  4. package/dist/_format-CeQhQTl5.js +23 -0
  5. package/dist/_format-CeQhQTl5.js.map +1 -0
  6. package/dist/attemptAsync-BdXzRSIT.js +42 -0
  7. package/dist/attemptAsync-BdXzRSIT.js.map +1 -0
  8. package/dist/chunk-DsIazq42.js +26 -0
  9. package/dist/commands/add/command.d.ts +7 -0
  10. package/dist/commands/add/command.d.ts.map +1 -0
  11. package/dist/commands/add/command.js +123 -0
  12. package/dist/commands/add/command.js.map +1 -0
  13. package/dist/commands/add/config.d.ts +7 -0
  14. package/dist/commands/add/config.d.ts.map +1 -0
  15. package/dist/commands/add/config.js +57 -0
  16. package/dist/commands/add/config.js.map +1 -0
  17. package/dist/commands/add/index.d.ts +7 -0
  18. package/dist/commands/add/index.d.ts.map +1 -0
  19. package/dist/commands/add/index.js +7 -0
  20. package/dist/commands/add/index.js.map +1 -0
  21. package/dist/commands/add/middleware.d.ts +7 -0
  22. package/dist/commands/add/middleware.d.ts.map +1 -0
  23. package/dist/commands/add/middleware.js +88 -0
  24. package/dist/commands/add/middleware.js.map +1 -0
  25. package/dist/commands/build.d.ts +15 -0
  26. package/dist/commands/build.d.ts.map +1 -0
  27. package/dist/commands/build.js +246 -0
  28. package/dist/commands/build.js.map +1 -0
  29. package/dist/commands/commands.d.ts +14 -0
  30. package/dist/commands/commands.d.ts.map +1 -0
  31. package/dist/commands/commands.js +189 -0
  32. package/dist/commands/commands.js.map +1 -0
  33. package/dist/commands/dev.d.ts +13 -0
  34. package/dist/commands/dev.d.ts.map +1 -0
  35. package/dist/commands/dev.js +58 -0
  36. package/dist/commands/dev.js.map +1 -0
  37. package/dist/commands/doctor.d.ts +13 -0
  38. package/dist/commands/doctor.d.ts.map +1 -0
  39. package/dist/commands/doctor.js +658 -0
  40. package/dist/commands/doctor.js.map +1 -0
  41. package/dist/commands/init.d.ts +7 -0
  42. package/dist/commands/init.d.ts.map +1 -0
  43. package/dist/commands/init.js +305 -0
  44. package/dist/commands/init.js.map +1 -0
  45. package/dist/commands/run.d.ts +19 -0
  46. package/dist/commands/run.d.ts.map +1 -0
  47. package/dist/commands/run.js +478 -0
  48. package/dist/commands/run.js.map +1 -0
  49. package/dist/commands/stories.d.ts +11 -0
  50. package/dist/commands/stories.d.ts.map +1 -0
  51. package/dist/commands/stories.js +22 -0
  52. package/dist/commands/stories.js.map +1 -0
  53. package/dist/config-helpers-pv_2Spux.js +15 -0
  54. package/dist/config-helpers-pv_2Spux.js.map +1 -0
  55. package/dist/defu-BBwssjW3.js +192 -0
  56. package/dist/defu-BBwssjW3.js.map +1 -0
  57. package/dist/detect-AOq1ehTE.js +61 -0
  58. package/dist/detect-AOq1ehTE.js.map +1 -0
  59. package/dist/dist-DW_gRP7_.js +1119 -0
  60. package/dist/dist-DW_gRP7_.js.map +1 -0
  61. package/dist/dist-Xa07jNxS.js +15617 -0
  62. package/dist/dist-Xa07jNxS.js.map +1 -0
  63. package/dist/index.d.ts +1 -0
  64. package/dist/index.js +46 -0
  65. package/dist/index.js.map +1 -0
  66. package/dist/jiti-CxWlVmZ_.js +5458 -0
  67. package/dist/jiti-CxWlVmZ_.js.map +1 -0
  68. package/dist/json-D7WbuVK1.js +43 -0
  69. package/dist/json-D7WbuVK1.js.map +1 -0
  70. package/dist/json5-z-PGDMyy.js +777 -0
  71. package/dist/json5-z-PGDMyy.js.map +1 -0
  72. package/dist/jsonc-DqZkfC3S.js +401 -0
  73. package/dist/jsonc-DqZkfC3S.js.map +1 -0
  74. package/dist/jsonc-KADMdSjU.js +2 -0
  75. package/dist/lib/templates/command/command.ts.liquid +12 -0
  76. package/dist/lib/templates/config/config.ts.liquid +16 -0
  77. package/dist/lib/templates/middleware/middleware.ts.liquid +9 -0
  78. package/dist/lib/templates/project/gitignore.liquid +3 -0
  79. package/dist/lib/templates/project/maltty.config.ts.liquid +6 -0
  80. package/dist/lib/templates/project/package.json.liquid +30 -0
  81. package/dist/lib/templates/project/src/commands/hello.ts.liquid +12 -0
  82. package/dist/lib/templates/project/src/config.ts.liquid +16 -0
  83. package/dist/lib/templates/project/src/index.ts.liquid +13 -0
  84. package/dist/lib/templates/project/tsconfig.json.liquid +19 -0
  85. package/dist/lib/templates/project/vitest.config.ts.liquid +8 -0
  86. package/dist/main-C_8x2aB3.js +274 -0
  87. package/dist/main-C_8x2aB3.js.map +1 -0
  88. package/dist/manifest-BIKVDJML.js +112 -0
  89. package/dist/manifest-BIKVDJML.js.map +1 -0
  90. package/dist/multipart-parser-MNkxNO83.js +174 -0
  91. package/dist/multipart-parser-MNkxNO83.js.map +1 -0
  92. package/dist/node-C91xGGqn.js +644 -0
  93. package/dist/node-C91xGGqn.js.map +1 -0
  94. package/dist/node-Drmc03fL.js +3973 -0
  95. package/dist/node-Drmc03fL.js.map +1 -0
  96. package/dist/ohash-BPoV4zBH.js +185 -0
  97. package/dist/ohash-BPoV4zBH.js.map +1 -0
  98. package/dist/pnpm-workspace.yaml +26 -0
  99. package/dist/toml-LuHsHQtV.js +646 -0
  100. package/dist/toml-LuHsHQtV.js.map +1 -0
  101. package/dist/utils-DlIJNGLQ.js +1905 -0
  102. package/dist/utils-DlIJNGLQ.js.map +1 -0
  103. package/dist/validate-C_SXBoLq.js +18 -0
  104. package/dist/validate-C_SXBoLq.js.map +1 -0
  105. package/dist/write-CSwG4Stj.js +152 -0
  106. package/dist/write-CSwG4Stj.js.map +1 -0
  107. package/dist/yaml-BS9RDuUr.js +1067 -0
  108. package/dist/yaml-BS9RDuUr.js.map +1 -0
  109. package/package.json +65 -0
@@ -0,0 +1,1905 @@
1
+ import { r as __toESM } from "./chunk-DsIazq42.js";
2
+ import { i as toError, n as err, r as ok, t as attemptAsync } from "./attemptAsync-BdXzRSIT.js";
3
+ import { a as isAbsolute$1, i as extname$2, l as resolve$1, n as basename$1, o as join$1, r as dirname$1, s as normalize, t as defu } from "./defu-BBwssjW3.js";
4
+ import { n, t as r } from "./jsonc-DqZkfC3S.js";
5
+ import path, { isAbsolute, resolve } from "node:path";
6
+ import { readFile, rm } from "node:fs/promises";
7
+ import { z } from "zod";
8
+ import { URL as URL$1, fileURLToPath, pathToFileURL } from "node:url";
9
+ import fs, { existsSync, lstatSync, promises, readFileSync, realpathSync, statSync } from "node:fs";
10
+ import * as nodeUtil from "node:util";
11
+ import { format, inspect } from "node:util";
12
+ import { homedir } from "node:os";
13
+ import assert from "node:assert";
14
+ import process$1 from "node:process";
15
+ import v8 from "node:v8";
16
+ //#region ../utils/dist/tag.js
17
+ /**
18
+ * Property key used to brand objects with a tag string.
19
+ *
20
+ * Defined via `Object.defineProperty` as non-enumerable, non-writable, and
21
+ * non-configurable, so it does not appear in `Object.keys`, `JSON.stringify`,
22
+ * `for...in`, or spread.
23
+ */
24
+ const TAG = "__tag";
25
+ /**
26
+ * Create a shallow copy of `obj` with a non-enumerable {@link TAG} property.
27
+ *
28
+ * The original object is not mutated. The tag is defined as non-enumerable,
29
+ * non-writable, and non-configurable via `Object.defineProperty`.
30
+ *
31
+ * @param obj - The source object to copy and tag.
32
+ * @param tag - The tag string to brand the copy with.
33
+ * @returns A new object with all own enumerable properties of `obj` plus the hidden tag.
34
+ */
35
+ function withTag(obj, tag) {
36
+ const copy = { ...obj };
37
+ Object.defineProperty(copy, TAG, {
38
+ configurable: false,
39
+ enumerable: false,
40
+ value: tag,
41
+ writable: false
42
+ });
43
+ return copy;
44
+ }
45
+ //#endregion
46
+ //#region ../../node_modules/.pnpm/exsolve@1.0.8/node_modules/exsolve/dist/index.mjs
47
+ const nodeBuiltins = [
48
+ "_http_agent",
49
+ "_http_client",
50
+ "_http_common",
51
+ "_http_incoming",
52
+ "_http_outgoing",
53
+ "_http_server",
54
+ "_stream_duplex",
55
+ "_stream_passthrough",
56
+ "_stream_readable",
57
+ "_stream_transform",
58
+ "_stream_wrap",
59
+ "_stream_writable",
60
+ "_tls_common",
61
+ "_tls_wrap",
62
+ "assert",
63
+ "assert/strict",
64
+ "async_hooks",
65
+ "buffer",
66
+ "child_process",
67
+ "cluster",
68
+ "console",
69
+ "constants",
70
+ "crypto",
71
+ "dgram",
72
+ "diagnostics_channel",
73
+ "dns",
74
+ "dns/promises",
75
+ "domain",
76
+ "events",
77
+ "fs",
78
+ "fs/promises",
79
+ "http",
80
+ "http2",
81
+ "https",
82
+ "inspector",
83
+ "inspector/promises",
84
+ "module",
85
+ "net",
86
+ "os",
87
+ "path",
88
+ "path/posix",
89
+ "path/win32",
90
+ "perf_hooks",
91
+ "process",
92
+ "punycode",
93
+ "querystring",
94
+ "readline",
95
+ "readline/promises",
96
+ "repl",
97
+ "stream",
98
+ "stream/consumers",
99
+ "stream/promises",
100
+ "stream/web",
101
+ "string_decoder",
102
+ "sys",
103
+ "timers",
104
+ "timers/promises",
105
+ "tls",
106
+ "trace_events",
107
+ "tty",
108
+ "url",
109
+ "util",
110
+ "util/types",
111
+ "v8",
112
+ "vm",
113
+ "wasi",
114
+ "worker_threads",
115
+ "zlib"
116
+ ];
117
+ const own$1 = {}.hasOwnProperty;
118
+ const classRegExp = /^([A-Z][a-z\d]*)+$/;
119
+ const kTypes = new Set([
120
+ "string",
121
+ "function",
122
+ "number",
123
+ "object",
124
+ "Function",
125
+ "Object",
126
+ "boolean",
127
+ "bigint",
128
+ "symbol"
129
+ ]);
130
+ const messages = /* @__PURE__ */ new Map();
131
+ const nodeInternalPrefix = "__node_internal_";
132
+ let userStackTraceLimit;
133
+ /**
134
+ * Create a list string in the form like 'A and B' or 'A, B, ..., and Z'.
135
+ * We cannot use Intl.ListFormat because it's not available in
136
+ * --without-intl builds.
137
+ *
138
+ * @param {Array<string>} array
139
+ * An array of strings.
140
+ * @param {string} [type]
141
+ * The list type to be inserted before the last element.
142
+ * @returns {string}
143
+ */
144
+ function formatList(array, type = "and") {
145
+ return array.length < 3 ? array.join(` ${type} `) : `${array.slice(0, -1).join(", ")}, ${type} ${array.at(-1)}`;
146
+ }
147
+ /**
148
+ * Utility function for registering the error codes.
149
+ */
150
+ function createError(sym, value, constructor) {
151
+ messages.set(sym, value);
152
+ return makeNodeErrorWithCode(constructor, sym);
153
+ }
154
+ function makeNodeErrorWithCode(Base, key) {
155
+ return function NodeError(...parameters) {
156
+ const limit = Error.stackTraceLimit;
157
+ if (isErrorStackTraceLimitWritable()) Error.stackTraceLimit = 0;
158
+ const error = new Base();
159
+ if (isErrorStackTraceLimitWritable()) Error.stackTraceLimit = limit;
160
+ const message = getMessage(key, parameters, error);
161
+ Object.defineProperties(error, {
162
+ message: {
163
+ value: message,
164
+ enumerable: false,
165
+ writable: true,
166
+ configurable: true
167
+ },
168
+ toString: {
169
+ value() {
170
+ return `${this.name} [${key}]: ${this.message}`;
171
+ },
172
+ enumerable: false,
173
+ writable: true,
174
+ configurable: true
175
+ }
176
+ });
177
+ captureLargerStackTrace(error);
178
+ error.code = key;
179
+ return error;
180
+ };
181
+ }
182
+ function isErrorStackTraceLimitWritable() {
183
+ try {
184
+ if (v8.startupSnapshot.isBuildingSnapshot()) return false;
185
+ } catch {}
186
+ const desc = Object.getOwnPropertyDescriptor(Error, "stackTraceLimit");
187
+ if (desc === void 0) return Object.isExtensible(Error);
188
+ return own$1.call(desc, "writable") && desc.writable !== void 0 ? desc.writable : desc.set !== void 0;
189
+ }
190
+ /**
191
+ * This function removes unnecessary frames from Node.js core errors.
192
+ */
193
+ function hideStackFrames(wrappedFunction) {
194
+ const hidden = nodeInternalPrefix + wrappedFunction.name;
195
+ Object.defineProperty(wrappedFunction, "name", { value: hidden });
196
+ return wrappedFunction;
197
+ }
198
+ const captureLargerStackTrace = hideStackFrames(function(error) {
199
+ const stackTraceLimitIsWritable = isErrorStackTraceLimitWritable();
200
+ if (stackTraceLimitIsWritable) {
201
+ userStackTraceLimit = Error.stackTraceLimit;
202
+ Error.stackTraceLimit = Number.POSITIVE_INFINITY;
203
+ }
204
+ Error.captureStackTrace(error);
205
+ if (stackTraceLimitIsWritable) Error.stackTraceLimit = userStackTraceLimit;
206
+ return error;
207
+ });
208
+ function getMessage(key, parameters, self) {
209
+ const message = messages.get(key);
210
+ assert.ok(message !== void 0, "expected `message` to be found");
211
+ if (typeof message === "function") {
212
+ assert.ok(message.length <= parameters.length, `Code: ${key}; The provided arguments length (${parameters.length}) does not match the required ones (${message.length}).`);
213
+ return Reflect.apply(message, self, parameters);
214
+ }
215
+ const regex = /%[dfijoOs]/g;
216
+ let expectedLength = 0;
217
+ while (regex.exec(message) !== null) expectedLength++;
218
+ assert.ok(expectedLength === parameters.length, `Code: ${key}; The provided arguments length (${parameters.length}) does not match the required ones (${expectedLength}).`);
219
+ if (parameters.length === 0) return message;
220
+ parameters.unshift(message);
221
+ return Reflect.apply(format, null, parameters);
222
+ }
223
+ /**
224
+ * Determine the specific type of a value for type-mismatch errors.
225
+ */
226
+ function determineSpecificType(value) {
227
+ if (value === null || value === void 0) return String(value);
228
+ if (typeof value === "function" && value.name) return `function ${value.name}`;
229
+ if (typeof value === "object") {
230
+ if (value.constructor && value.constructor.name) return `an instance of ${value.constructor.name}`;
231
+ return `${inspect(value, { depth: -1 })}`;
232
+ }
233
+ let inspected = inspect(value, { colors: false });
234
+ if (inspected.length > 28) inspected = `${inspected.slice(0, 25)}...`;
235
+ return `type ${typeof value} (${inspected})`;
236
+ }
237
+ createError("ERR_INVALID_ARG_TYPE", (name, expected, actual) => {
238
+ assert.ok(typeof name === "string", "'name' must be a string");
239
+ if (!Array.isArray(expected)) expected = [expected];
240
+ let message = "The ";
241
+ if (name.endsWith(" argument")) message += `${name} `;
242
+ else {
243
+ const type = name.includes(".") ? "property" : "argument";
244
+ message += `"${name}" ${type} `;
245
+ }
246
+ message += "must be ";
247
+ const types = [];
248
+ const instances = [];
249
+ const other = [];
250
+ for (const value of expected) {
251
+ assert.ok(typeof value === "string", "All expected entries have to be of type string");
252
+ if (kTypes.has(value)) types.push(value.toLowerCase());
253
+ else if (classRegExp.exec(value) === null) {
254
+ assert.ok(value !== "object", "The value \"object\" should be written as \"Object\"");
255
+ other.push(value);
256
+ } else instances.push(value);
257
+ }
258
+ if (instances.length > 0) {
259
+ const pos = types.indexOf("object");
260
+ if (pos !== -1) {
261
+ types.slice(pos, 1);
262
+ instances.push("Object");
263
+ }
264
+ }
265
+ if (types.length > 0) {
266
+ message += `${types.length > 1 ? "one of type" : "of type"} ${formatList(types, "or")}`;
267
+ if (instances.length > 0 || other.length > 0) message += " or ";
268
+ }
269
+ if (instances.length > 0) {
270
+ message += `an instance of ${formatList(instances, "or")}`;
271
+ if (other.length > 0) message += " or ";
272
+ }
273
+ if (other.length > 0) if (other.length > 1) message += `one of ${formatList(other, "or")}`;
274
+ else {
275
+ if (other[0]?.toLowerCase() !== other[0]) message += "an ";
276
+ message += `${other[0]}`;
277
+ }
278
+ message += `. Received ${determineSpecificType(actual)}`;
279
+ return message;
280
+ }, TypeError);
281
+ const ERR_INVALID_MODULE_SPECIFIER = createError(
282
+ "ERR_INVALID_MODULE_SPECIFIER",
283
+ /**
284
+ * @param {string} request
285
+ * @param {string} reason
286
+ * @param {string} [base]
287
+ */
288
+ (request, reason, base) => {
289
+ return `Invalid module "${request}" ${reason}${base ? ` imported from ${base}` : ""}`;
290
+ },
291
+ TypeError
292
+ );
293
+ const ERR_INVALID_PACKAGE_CONFIG = createError("ERR_INVALID_PACKAGE_CONFIG", (path$1, base, message) => {
294
+ return `Invalid package config ${path$1}${base ? ` while importing ${base}` : ""}${message ? `. ${message}` : ""}`;
295
+ }, Error);
296
+ const ERR_INVALID_PACKAGE_TARGET = createError("ERR_INVALID_PACKAGE_TARGET", (packagePath, key, target, isImport = false, base) => {
297
+ const relatedError = typeof target === "string" && !isImport && target.length > 0 && !target.startsWith("./");
298
+ if (key === ".") {
299
+ assert.ok(isImport === false);
300
+ return `Invalid "exports" main target ${JSON.stringify(target)} defined in the package config ${packagePath}package.json${base ? ` imported from ${base}` : ""}${relatedError ? "; targets must start with \"./\"" : ""}`;
301
+ }
302
+ return `Invalid "${isImport ? "imports" : "exports"}" target ${JSON.stringify(target)} defined for '${key}' in the package config ${packagePath}package.json${base ? ` imported from ${base}` : ""}${relatedError ? "; targets must start with \"./\"" : ""}`;
303
+ }, Error);
304
+ const ERR_MODULE_NOT_FOUND = createError("ERR_MODULE_NOT_FOUND", (path$1, base, exactUrl = false) => {
305
+ return `Cannot find ${exactUrl ? "module" : "package"} '${path$1}' imported from ${base}`;
306
+ }, Error);
307
+ createError("ERR_NETWORK_IMPORT_DISALLOWED", "import of '%s' by %s is not supported: %s", Error);
308
+ const ERR_PACKAGE_IMPORT_NOT_DEFINED = createError("ERR_PACKAGE_IMPORT_NOT_DEFINED", (specifier, packagePath, base) => {
309
+ return `Package import specifier "${specifier}" is not defined${packagePath ? ` in package ${packagePath || ""}package.json` : ""} imported from ${base}`;
310
+ }, TypeError);
311
+ const ERR_PACKAGE_PATH_NOT_EXPORTED = createError(
312
+ "ERR_PACKAGE_PATH_NOT_EXPORTED",
313
+ /**
314
+ * @param {string} packagePath
315
+ * @param {string} subpath
316
+ * @param {string} [base]
317
+ */
318
+ (packagePath, subpath, base) => {
319
+ if (subpath === ".") return `No "exports" main defined in ${packagePath}package.json${base ? ` imported from ${base}` : ""}`;
320
+ return `Package subpath '${subpath}' is not defined by "exports" in ${packagePath}package.json${base ? ` imported from ${base}` : ""}`;
321
+ },
322
+ Error
323
+ );
324
+ const ERR_UNSUPPORTED_DIR_IMPORT = createError("ERR_UNSUPPORTED_DIR_IMPORT", "Directory import '%s' is not supported resolving ES modules imported from %s", Error);
325
+ const ERR_UNSUPPORTED_RESOLVE_REQUEST = createError("ERR_UNSUPPORTED_RESOLVE_REQUEST", "Failed to resolve module specifier \"%s\" from \"%s\": Invalid relative URL or base scheme is not hierarchical.", TypeError);
326
+ const ERR_UNKNOWN_FILE_EXTENSION = createError("ERR_UNKNOWN_FILE_EXTENSION", (extension, path$1) => {
327
+ return `Unknown file extension "${extension}" for ${path$1}`;
328
+ }, TypeError);
329
+ createError("ERR_INVALID_ARG_VALUE", (name, value, reason = "is invalid") => {
330
+ let inspected = inspect(value);
331
+ if (inspected.length > 128) inspected = `${inspected.slice(0, 128)}...`;
332
+ return `The ${name.includes(".") ? "property" : "argument"} '${name}' ${reason}. Received ${inspected}`;
333
+ }, TypeError);
334
+ const hasOwnProperty$1 = {}.hasOwnProperty;
335
+ const cache = /* @__PURE__ */ new Map();
336
+ function read$1(jsonPath, { base, specifier }) {
337
+ const existing = cache.get(jsonPath);
338
+ if (existing) return existing;
339
+ let string;
340
+ try {
341
+ string = fs.readFileSync(path.toNamespacedPath(jsonPath), "utf8");
342
+ } catch (error) {
343
+ const exception = error;
344
+ if (exception.code !== "ENOENT") throw exception;
345
+ }
346
+ const result = {
347
+ exists: false,
348
+ pjsonPath: jsonPath,
349
+ main: void 0,
350
+ name: void 0,
351
+ type: "none",
352
+ exports: void 0,
353
+ imports: void 0
354
+ };
355
+ if (string !== void 0) {
356
+ let parsed;
357
+ try {
358
+ parsed = JSON.parse(string);
359
+ } catch (error_) {
360
+ const error = new ERR_INVALID_PACKAGE_CONFIG(jsonPath, (base ? `"${specifier}" from ` : "") + fileURLToPath(base || specifier), error_.message);
361
+ error.cause = error_;
362
+ throw error;
363
+ }
364
+ result.exists = true;
365
+ if (hasOwnProperty$1.call(parsed, "name") && typeof parsed.name === "string") result.name = parsed.name;
366
+ if (hasOwnProperty$1.call(parsed, "main") && typeof parsed.main === "string") result.main = parsed.main;
367
+ if (hasOwnProperty$1.call(parsed, "exports")) result.exports = parsed.exports;
368
+ if (hasOwnProperty$1.call(parsed, "imports")) result.imports = parsed.imports;
369
+ if (hasOwnProperty$1.call(parsed, "type") && (parsed.type === "commonjs" || parsed.type === "module")) result.type = parsed.type;
370
+ }
371
+ cache.set(jsonPath, result);
372
+ return result;
373
+ }
374
+ function getPackageScopeConfig(resolved) {
375
+ let packageJSONUrl = new URL("package.json", resolved);
376
+ while (true) {
377
+ if (packageJSONUrl.pathname.endsWith("node_modules/package.json")) break;
378
+ const packageConfig = read$1(fileURLToPath(packageJSONUrl), { specifier: resolved });
379
+ if (packageConfig.exists) return packageConfig;
380
+ const lastPackageJSONUrl = packageJSONUrl;
381
+ packageJSONUrl = new URL("../package.json", packageJSONUrl);
382
+ if (packageJSONUrl.pathname === lastPackageJSONUrl.pathname) break;
383
+ }
384
+ return {
385
+ pjsonPath: fileURLToPath(packageJSONUrl),
386
+ exists: false,
387
+ type: "none"
388
+ };
389
+ }
390
+ const hasOwnProperty = {}.hasOwnProperty;
391
+ const extensionFormatMap = {
392
+ __proto__: null,
393
+ ".json": "json",
394
+ ".cjs": "commonjs",
395
+ ".cts": "commonjs",
396
+ ".js": "module",
397
+ ".ts": "module",
398
+ ".mts": "module",
399
+ ".mjs": "module"
400
+ };
401
+ const protocolHandlers = {
402
+ __proto__: null,
403
+ "data:": getDataProtocolModuleFormat,
404
+ "file:": getFileProtocolModuleFormat,
405
+ "node:": () => "builtin"
406
+ };
407
+ function mimeToFormat(mime) {
408
+ if (mime && /\s*(text|application)\/javascript\s*(;\s*charset=utf-?8\s*)?/i.test(mime)) return "module";
409
+ if (mime === "application/json") return "json";
410
+ return null;
411
+ }
412
+ function getDataProtocolModuleFormat(parsed) {
413
+ const { 1: mime } = /^([^/]+\/[^;,]+)[^,]*?(;base64)?,/.exec(parsed.pathname) || [
414
+ null,
415
+ null,
416
+ null
417
+ ];
418
+ return mimeToFormat(mime);
419
+ }
420
+ /**
421
+ * Returns the file extension from a URL.
422
+ *
423
+ * Should give similar result to
424
+ * `require('node:path').extname(require('node:url').fileURLToPath(url))`
425
+ * when used with a `file:` URL.
426
+ *
427
+ */
428
+ function extname$1(url) {
429
+ const pathname = url.pathname;
430
+ let index = pathname.length;
431
+ while (index--) {
432
+ const code = pathname.codePointAt(index);
433
+ if (code === 47) return "";
434
+ if (code === 46) return pathname.codePointAt(index - 1) === 47 ? "" : pathname.slice(index);
435
+ }
436
+ return "";
437
+ }
438
+ function getFileProtocolModuleFormat(url, _context, ignoreErrors) {
439
+ const ext = extname$1(url);
440
+ if (ext === ".js") {
441
+ const { type: packageType } = getPackageScopeConfig(url);
442
+ if (packageType !== "none") return packageType;
443
+ return "commonjs";
444
+ }
445
+ if (ext === "") {
446
+ const { type: packageType } = getPackageScopeConfig(url);
447
+ if (packageType === "none" || packageType === "commonjs") return "commonjs";
448
+ return "module";
449
+ }
450
+ const format$1 = extensionFormatMap[ext];
451
+ if (format$1) return format$1;
452
+ if (ignoreErrors) return;
453
+ throw new ERR_UNKNOWN_FILE_EXTENSION(ext, fileURLToPath(url));
454
+ }
455
+ function defaultGetFormatWithoutErrors(url, context) {
456
+ const protocol = url.protocol;
457
+ if (!hasOwnProperty.call(protocolHandlers, protocol)) return null;
458
+ return protocolHandlers[protocol](url, context, true) || null;
459
+ }
460
+ const RegExpPrototypeSymbolReplace = RegExp.prototype[Symbol.replace];
461
+ const own = {}.hasOwnProperty;
462
+ const invalidSegmentRegEx = /(^|\\|\/)((\.|%2e)(\.|%2e)?|(n|%6e|%4e)(o|%6f|%4f)(d|%64|%44)(e|%65|%45)(_|%5f)(m|%6d|%4d)(o|%6f|%4f)(d|%64|%44)(u|%75|%55)(l|%6c|%4c)(e|%65|%45)(s|%73|%53))?(\\|\/|$)/i;
463
+ const deprecatedInvalidSegmentRegEx = /(^|\\|\/)((\.|%2e)(\.|%2e)?|(n|%6e|%4e)(o|%6f|%4f)(d|%64|%44)(e|%65|%45)(_|%5f)(m|%6d|%4d)(o|%6f|%4f)(d|%64|%44)(u|%75|%55)(l|%6c|%4c)(e|%65|%45)(s|%73|%53))(\\|\/|$)/i;
464
+ const invalidPackageNameRegEx = /^\.|%|\\/;
465
+ const patternRegEx = /\*/g;
466
+ const encodedSeparatorRegEx = /%2f|%5c/i;
467
+ const emittedPackageWarnings = /* @__PURE__ */ new Set();
468
+ const doubleSlashRegEx = /[/\\]{2}/;
469
+ function emitInvalidSegmentDeprecation(target, request, match, packageJsonUrl, internal, base, isTarget) {
470
+ if (process$1.noDeprecation) return;
471
+ const pjsonPath = fileURLToPath(packageJsonUrl);
472
+ const double = doubleSlashRegEx.exec(isTarget ? target : request) !== null;
473
+ process$1.emitWarning(`Use of deprecated ${double ? "double slash" : "leading or trailing slash matching"} resolving "${target}" for module request "${request}" ${request === match ? "" : `matched to "${match}" `}in the "${internal ? "imports" : "exports"}" field module resolution of the package at ${pjsonPath}${base ? ` imported from ${fileURLToPath(base)}` : ""}.`, "DeprecationWarning", "DEP0166");
474
+ }
475
+ function emitLegacyIndexDeprecation(url, packageJsonUrl, base, main) {
476
+ if (process$1.noDeprecation) return;
477
+ if (defaultGetFormatWithoutErrors(url, { parentURL: base.href }) !== "module") return;
478
+ const urlPath = fileURLToPath(url.href);
479
+ const packagePath = fileURLToPath(new URL$1(".", packageJsonUrl));
480
+ const basePath = fileURLToPath(base);
481
+ if (!main) process$1.emitWarning(`No "main" or "exports" field defined in the package.json for ${packagePath} resolving the main entry point "${urlPath.slice(packagePath.length)}", imported from ${basePath}.\nDefault "index" lookups for the main are deprecated for ES modules.`, "DeprecationWarning", "DEP0151");
482
+ else if (path.resolve(packagePath, main) !== urlPath) process$1.emitWarning(`Package ${packagePath} has a "main" field set to "${main}", excluding the full filename and extension to the resolved file at "${urlPath.slice(packagePath.length)}", imported from ${basePath}.\n Automatic extension resolution of the "main" field is deprecated for ES modules.`, "DeprecationWarning", "DEP0151");
483
+ }
484
+ function tryStatSync(path$1) {
485
+ try {
486
+ return statSync(path$1);
487
+ } catch {}
488
+ }
489
+ /**
490
+ * Legacy CommonJS main resolution:
491
+ * 1. let M = pkg_url + (json main field)
492
+ * 2. TRY(M, M.js, M.json, M.node)
493
+ * 3. TRY(M/index.js, M/index.json, M/index.node)
494
+ * 4. TRY(pkg_url/index.js, pkg_url/index.json, pkg_url/index.node)
495
+ * 5. NOT_FOUND
496
+ */
497
+ function fileExists(url) {
498
+ const stats = statSync(url, { throwIfNoEntry: false });
499
+ const isFile = stats ? stats.isFile() : void 0;
500
+ return isFile === null || isFile === void 0 ? false : isFile;
501
+ }
502
+ function legacyMainResolve(packageJsonUrl, packageConfig, base) {
503
+ let guess;
504
+ if (packageConfig.main !== void 0) {
505
+ guess = new URL$1(packageConfig.main, packageJsonUrl);
506
+ if (fileExists(guess)) return guess;
507
+ const tries$1 = [
508
+ `./${packageConfig.main}.js`,
509
+ `./${packageConfig.main}.json`,
510
+ `./${packageConfig.main}.node`,
511
+ `./${packageConfig.main}/index.js`,
512
+ `./${packageConfig.main}/index.json`,
513
+ `./${packageConfig.main}/index.node`
514
+ ];
515
+ let i$1 = -1;
516
+ while (++i$1 < tries$1.length) {
517
+ guess = new URL$1(tries$1[i$1], packageJsonUrl);
518
+ if (fileExists(guess)) break;
519
+ guess = void 0;
520
+ }
521
+ if (guess) {
522
+ emitLegacyIndexDeprecation(guess, packageJsonUrl, base, packageConfig.main);
523
+ return guess;
524
+ }
525
+ }
526
+ const tries = [
527
+ "./index.js",
528
+ "./index.json",
529
+ "./index.node"
530
+ ];
531
+ let i = -1;
532
+ while (++i < tries.length) {
533
+ guess = new URL$1(tries[i], packageJsonUrl);
534
+ if (fileExists(guess)) break;
535
+ guess = void 0;
536
+ }
537
+ if (guess) {
538
+ emitLegacyIndexDeprecation(guess, packageJsonUrl, base, packageConfig.main);
539
+ return guess;
540
+ }
541
+ throw new ERR_MODULE_NOT_FOUND(fileURLToPath(new URL$1(".", packageJsonUrl)), fileURLToPath(base));
542
+ }
543
+ function finalizeResolution(resolved, base, preserveSymlinks) {
544
+ if (encodedSeparatorRegEx.exec(resolved.pathname) !== null) throw new ERR_INVALID_MODULE_SPECIFIER(resolved.pathname, String.raw`must not include encoded "/" or "\" characters`, fileURLToPath(base));
545
+ let filePath;
546
+ try {
547
+ filePath = fileURLToPath(resolved);
548
+ } catch (error) {
549
+ Object.defineProperty(error, "input", { value: String(resolved) });
550
+ Object.defineProperty(error, "module", { value: String(base) });
551
+ throw error;
552
+ }
553
+ const stats = tryStatSync(filePath.endsWith("/") ? filePath.slice(-1) : filePath);
554
+ if (stats && stats.isDirectory()) {
555
+ const error = new ERR_UNSUPPORTED_DIR_IMPORT(filePath, fileURLToPath(base));
556
+ error.url = String(resolved);
557
+ throw error;
558
+ }
559
+ if (!stats || !stats.isFile()) {
560
+ const error = new ERR_MODULE_NOT_FOUND(filePath || resolved.pathname, base && fileURLToPath(base), true);
561
+ error.url = String(resolved);
562
+ throw error;
563
+ }
564
+ if (!preserveSymlinks) {
565
+ const real = realpathSync(filePath);
566
+ const { search, hash } = resolved;
567
+ resolved = pathToFileURL(real + (filePath.endsWith(path.sep) ? "/" : ""));
568
+ resolved.search = search;
569
+ resolved.hash = hash;
570
+ }
571
+ return resolved;
572
+ }
573
+ function importNotDefined(specifier, packageJsonUrl, base) {
574
+ return new ERR_PACKAGE_IMPORT_NOT_DEFINED(specifier, packageJsonUrl && fileURLToPath(new URL$1(".", packageJsonUrl)), fileURLToPath(base));
575
+ }
576
+ function exportsNotFound(subpath, packageJsonUrl, base) {
577
+ return new ERR_PACKAGE_PATH_NOT_EXPORTED(fileURLToPath(new URL$1(".", packageJsonUrl)), subpath, base && fileURLToPath(base));
578
+ }
579
+ function throwInvalidSubpath(request, match, packageJsonUrl, internal, base) {
580
+ throw new ERR_INVALID_MODULE_SPECIFIER(request, `request is not a valid match in pattern "${match}" for the "${internal ? "imports" : "exports"}" resolution of ${fileURLToPath(packageJsonUrl)}`, base && fileURLToPath(base));
581
+ }
582
+ function invalidPackageTarget(subpath, target, packageJsonUrl, internal, base) {
583
+ target = typeof target === "object" && target !== null ? JSON.stringify(target, null, "") : `${target}`;
584
+ return new ERR_INVALID_PACKAGE_TARGET(fileURLToPath(new URL$1(".", packageJsonUrl)), subpath, target, internal, base && fileURLToPath(base));
585
+ }
586
+ function resolvePackageTargetString(target, subpath, match, packageJsonUrl, base, pattern, internal, isPathMap, conditions) {
587
+ if (subpath !== "" && !pattern && target.at(-1) !== "/") throw invalidPackageTarget(match, target, packageJsonUrl, internal, base);
588
+ if (!target.startsWith("./")) {
589
+ if (internal && !target.startsWith("../") && !target.startsWith("/")) {
590
+ let isURL = false;
591
+ try {
592
+ new URL$1(target);
593
+ isURL = true;
594
+ } catch {}
595
+ if (!isURL) return packageResolve(pattern ? RegExpPrototypeSymbolReplace.call(patternRegEx, target, () => subpath) : target + subpath, packageJsonUrl, conditions);
596
+ }
597
+ throw invalidPackageTarget(match, target, packageJsonUrl, internal, base);
598
+ }
599
+ if (invalidSegmentRegEx.exec(target.slice(2)) !== null) if (deprecatedInvalidSegmentRegEx.exec(target.slice(2)) === null) {
600
+ if (!isPathMap) {
601
+ const request = pattern ? match.replace("*", () => subpath) : match + subpath;
602
+ emitInvalidSegmentDeprecation(pattern ? RegExpPrototypeSymbolReplace.call(patternRegEx, target, () => subpath) : target, request, match, packageJsonUrl, internal, base, true);
603
+ }
604
+ } else throw invalidPackageTarget(match, target, packageJsonUrl, internal, base);
605
+ const resolved = new URL$1(target, packageJsonUrl);
606
+ const resolvedPath = resolved.pathname;
607
+ const packagePath = new URL$1(".", packageJsonUrl).pathname;
608
+ if (!resolvedPath.startsWith(packagePath)) throw invalidPackageTarget(match, target, packageJsonUrl, internal, base);
609
+ if (subpath === "") return resolved;
610
+ if (invalidSegmentRegEx.exec(subpath) !== null) {
611
+ const request = pattern ? match.replace("*", () => subpath) : match + subpath;
612
+ if (deprecatedInvalidSegmentRegEx.exec(subpath) === null) {
613
+ if (!isPathMap) emitInvalidSegmentDeprecation(pattern ? RegExpPrototypeSymbolReplace.call(patternRegEx, target, () => subpath) : target, request, match, packageJsonUrl, internal, base, false);
614
+ } else throwInvalidSubpath(request, match, packageJsonUrl, internal, base);
615
+ }
616
+ if (pattern) return new URL$1(RegExpPrototypeSymbolReplace.call(patternRegEx, resolved.href, () => subpath));
617
+ return new URL$1(subpath, resolved);
618
+ }
619
+ function isArrayIndex(key) {
620
+ const keyNumber = Number(key);
621
+ if (`${keyNumber}` !== key) return false;
622
+ return keyNumber >= 0 && keyNumber < 4294967295;
623
+ }
624
+ function resolvePackageTarget(packageJsonUrl, target, subpath, packageSubpath, base, pattern, internal, isPathMap, conditions) {
625
+ if (typeof target === "string") return resolvePackageTargetString(target, subpath, packageSubpath, packageJsonUrl, base, pattern, internal, isPathMap, conditions);
626
+ if (Array.isArray(target)) {
627
+ const targetList = target;
628
+ if (targetList.length === 0) return null;
629
+ let lastException;
630
+ let i = -1;
631
+ while (++i < targetList.length) {
632
+ const targetItem = targetList[i];
633
+ let resolveResult;
634
+ try {
635
+ resolveResult = resolvePackageTarget(packageJsonUrl, targetItem, subpath, packageSubpath, base, pattern, internal, isPathMap, conditions);
636
+ } catch (error) {
637
+ const exception = error;
638
+ lastException = exception;
639
+ if (exception.code === "ERR_INVALID_PACKAGE_TARGET") continue;
640
+ throw error;
641
+ }
642
+ if (resolveResult === void 0) continue;
643
+ if (resolveResult === null) {
644
+ lastException = null;
645
+ continue;
646
+ }
647
+ return resolveResult;
648
+ }
649
+ if (lastException === void 0 || lastException === null) return null;
650
+ throw lastException;
651
+ }
652
+ if (typeof target === "object" && target !== null) {
653
+ const keys = Object.getOwnPropertyNames(target);
654
+ let i = -1;
655
+ while (++i < keys.length) {
656
+ const key = keys[i];
657
+ if (isArrayIndex(key)) throw new ERR_INVALID_PACKAGE_CONFIG(fileURLToPath(packageJsonUrl), fileURLToPath(base), "\"exports\" cannot contain numeric property keys.");
658
+ }
659
+ i = -1;
660
+ while (++i < keys.length) {
661
+ const key = keys[i];
662
+ if (key === "default" || conditions && conditions.has(key)) {
663
+ const conditionalTarget = target[key];
664
+ const resolveResult = resolvePackageTarget(packageJsonUrl, conditionalTarget, subpath, packageSubpath, base, pattern, internal, isPathMap, conditions);
665
+ if (resolveResult === void 0) continue;
666
+ return resolveResult;
667
+ }
668
+ }
669
+ return null;
670
+ }
671
+ if (target === null) return null;
672
+ throw invalidPackageTarget(packageSubpath, target, packageJsonUrl, internal, base);
673
+ }
674
+ function isConditionalExportsMainSugar(exports, packageJsonUrl, base) {
675
+ if (typeof exports === "string" || Array.isArray(exports)) return true;
676
+ if (typeof exports !== "object" || exports === null) return false;
677
+ const keys = Object.getOwnPropertyNames(exports);
678
+ let isConditionalSugar = false;
679
+ let i = 0;
680
+ let keyIndex = -1;
681
+ while (++keyIndex < keys.length) {
682
+ const key = keys[keyIndex];
683
+ const currentIsConditionalSugar = key === "" || key[0] !== ".";
684
+ if (i++ === 0) isConditionalSugar = currentIsConditionalSugar;
685
+ else if (isConditionalSugar !== currentIsConditionalSugar) throw new ERR_INVALID_PACKAGE_CONFIG(fileURLToPath(packageJsonUrl), fileURLToPath(base), "\"exports\" cannot contain some keys starting with '.' and some not. The exports object must either be an object of package subpath keys or an object of main entry condition name keys only.");
686
+ }
687
+ return isConditionalSugar;
688
+ }
689
+ function emitTrailingSlashPatternDeprecation(match, pjsonUrl, base) {
690
+ if (process$1.noDeprecation) return;
691
+ const pjsonPath = fileURLToPath(pjsonUrl);
692
+ if (emittedPackageWarnings.has(pjsonPath + "|" + match)) return;
693
+ emittedPackageWarnings.add(pjsonPath + "|" + match);
694
+ process$1.emitWarning(`Use of deprecated trailing slash pattern mapping "${match}" in the "exports" field module resolution of the package at ${pjsonPath}${base ? ` imported from ${fileURLToPath(base)}` : ""}. Mapping specifiers ending in "/" is no longer supported.`, "DeprecationWarning", "DEP0155");
695
+ }
696
+ function packageExportsResolve(packageJsonUrl, packageSubpath, packageConfig, base, conditions) {
697
+ let exports = packageConfig.exports;
698
+ if (isConditionalExportsMainSugar(exports, packageJsonUrl, base)) exports = { ".": exports };
699
+ if (own.call(exports, packageSubpath) && !packageSubpath.includes("*") && !packageSubpath.endsWith("/")) {
700
+ const target = exports[packageSubpath];
701
+ const resolveResult = resolvePackageTarget(packageJsonUrl, target, "", packageSubpath, base, false, false, false, conditions);
702
+ if (resolveResult === null || resolveResult === void 0) throw exportsNotFound(packageSubpath, packageJsonUrl, base);
703
+ return resolveResult;
704
+ }
705
+ let bestMatch = "";
706
+ let bestMatchSubpath = "";
707
+ const keys = Object.getOwnPropertyNames(exports);
708
+ let i = -1;
709
+ while (++i < keys.length) {
710
+ const key = keys[i];
711
+ const patternIndex = key.indexOf("*");
712
+ if (patternIndex !== -1 && packageSubpath.startsWith(key.slice(0, patternIndex))) {
713
+ if (packageSubpath.endsWith("/")) emitTrailingSlashPatternDeprecation(packageSubpath, packageJsonUrl, base);
714
+ const patternTrailer = key.slice(patternIndex + 1);
715
+ if (packageSubpath.length >= key.length && packageSubpath.endsWith(patternTrailer) && patternKeyCompare(bestMatch, key) === 1 && key.lastIndexOf("*") === patternIndex) {
716
+ bestMatch = key;
717
+ bestMatchSubpath = packageSubpath.slice(patternIndex, packageSubpath.length - patternTrailer.length);
718
+ }
719
+ }
720
+ }
721
+ if (bestMatch) {
722
+ const target = exports[bestMatch];
723
+ const resolveResult = resolvePackageTarget(packageJsonUrl, target, bestMatchSubpath, bestMatch, base, true, false, packageSubpath.endsWith("/"), conditions);
724
+ if (resolveResult === null || resolveResult === void 0) throw exportsNotFound(packageSubpath, packageJsonUrl, base);
725
+ return resolveResult;
726
+ }
727
+ throw exportsNotFound(packageSubpath, packageJsonUrl, base);
728
+ }
729
+ function patternKeyCompare(a, b) {
730
+ const aPatternIndex = a.indexOf("*");
731
+ const bPatternIndex = b.indexOf("*");
732
+ const baseLengthA = aPatternIndex === -1 ? a.length : aPatternIndex + 1;
733
+ const baseLengthB = bPatternIndex === -1 ? b.length : bPatternIndex + 1;
734
+ if (baseLengthA > baseLengthB) return -1;
735
+ if (baseLengthB > baseLengthA) return 1;
736
+ if (aPatternIndex === -1) return 1;
737
+ if (bPatternIndex === -1) return -1;
738
+ if (a.length > b.length) return -1;
739
+ if (b.length > a.length) return 1;
740
+ return 0;
741
+ }
742
+ function packageImportsResolve(name, base, conditions) {
743
+ if (name === "#" || name.startsWith("#/") || name.endsWith("/")) throw new ERR_INVALID_MODULE_SPECIFIER(name, "is not a valid internal imports specifier name", fileURLToPath(base));
744
+ let packageJsonUrl;
745
+ const packageConfig = getPackageScopeConfig(base);
746
+ if (packageConfig.exists) {
747
+ packageJsonUrl = pathToFileURL(packageConfig.pjsonPath);
748
+ const imports = packageConfig.imports;
749
+ if (imports) if (own.call(imports, name) && !name.includes("*")) {
750
+ const resolveResult = resolvePackageTarget(packageJsonUrl, imports[name], "", name, base, false, true, false, conditions);
751
+ if (resolveResult !== null && resolveResult !== void 0) return resolveResult;
752
+ } else {
753
+ let bestMatch = "";
754
+ let bestMatchSubpath = "";
755
+ const keys = Object.getOwnPropertyNames(imports);
756
+ let i = -1;
757
+ while (++i < keys.length) {
758
+ const key = keys[i];
759
+ const patternIndex = key.indexOf("*");
760
+ if (patternIndex !== -1 && name.startsWith(key.slice(0, -1))) {
761
+ const patternTrailer = key.slice(patternIndex + 1);
762
+ if (name.length >= key.length && name.endsWith(patternTrailer) && patternKeyCompare(bestMatch, key) === 1 && key.lastIndexOf("*") === patternIndex) {
763
+ bestMatch = key;
764
+ bestMatchSubpath = name.slice(patternIndex, name.length - patternTrailer.length);
765
+ }
766
+ }
767
+ }
768
+ if (bestMatch) {
769
+ const target = imports[bestMatch];
770
+ const resolveResult = resolvePackageTarget(packageJsonUrl, target, bestMatchSubpath, bestMatch, base, true, true, false, conditions);
771
+ if (resolveResult !== null && resolveResult !== void 0) return resolveResult;
772
+ }
773
+ }
774
+ }
775
+ throw importNotDefined(name, packageJsonUrl, base);
776
+ }
777
+ /**
778
+ * @param {string} specifier
779
+ * @param {URL} base
780
+ */
781
+ function parsePackageName(specifier, base) {
782
+ let separatorIndex = specifier.indexOf("/");
783
+ let validPackageName = true;
784
+ let isScoped = false;
785
+ if (specifier[0] === "@") {
786
+ isScoped = true;
787
+ if (separatorIndex === -1 || specifier.length === 0) validPackageName = false;
788
+ else separatorIndex = specifier.indexOf("/", separatorIndex + 1);
789
+ }
790
+ const packageName = separatorIndex === -1 ? specifier : specifier.slice(0, separatorIndex);
791
+ if (invalidPackageNameRegEx.exec(packageName) !== null) validPackageName = false;
792
+ if (!validPackageName) throw new ERR_INVALID_MODULE_SPECIFIER(specifier, "is not a valid package name", fileURLToPath(base));
793
+ return {
794
+ packageName,
795
+ packageSubpath: "." + (separatorIndex === -1 ? "" : specifier.slice(separatorIndex)),
796
+ isScoped
797
+ };
798
+ }
799
+ function packageResolve(specifier, base, conditions) {
800
+ if (nodeBuiltins.includes(specifier)) return new URL$1("node:" + specifier);
801
+ const { packageName, packageSubpath, isScoped } = parsePackageName(specifier, base);
802
+ const packageConfig = getPackageScopeConfig(base);
803
+ if (packageConfig.exists && packageConfig.name === packageName && packageConfig.exports !== void 0 && packageConfig.exports !== null) return packageExportsResolve(pathToFileURL(packageConfig.pjsonPath), packageSubpath, packageConfig, base, conditions);
804
+ let packageJsonUrl = new URL$1("./node_modules/" + packageName + "/package.json", base);
805
+ let packageJsonPath = fileURLToPath(packageJsonUrl);
806
+ let lastPath;
807
+ do {
808
+ const stat = tryStatSync(packageJsonPath.slice(0, -13));
809
+ if (!stat || !stat.isDirectory()) {
810
+ lastPath = packageJsonPath;
811
+ packageJsonUrl = new URL$1((isScoped ? "../../../../node_modules/" : "../../../node_modules/") + packageName + "/package.json", packageJsonUrl);
812
+ packageJsonPath = fileURLToPath(packageJsonUrl);
813
+ continue;
814
+ }
815
+ const packageConfig$1 = read$1(packageJsonPath, {
816
+ base,
817
+ specifier
818
+ });
819
+ if (packageConfig$1.exports !== void 0 && packageConfig$1.exports !== null) return packageExportsResolve(packageJsonUrl, packageSubpath, packageConfig$1, base, conditions);
820
+ if (packageSubpath === ".") return legacyMainResolve(packageJsonUrl, packageConfig$1, base);
821
+ return new URL$1(packageSubpath, packageJsonUrl);
822
+ } while (packageJsonPath.length !== lastPath.length);
823
+ throw new ERR_MODULE_NOT_FOUND(packageName, fileURLToPath(base), false);
824
+ }
825
+ function isRelativeSpecifier(specifier) {
826
+ if (specifier[0] === ".") {
827
+ if (specifier.length === 1 || specifier[1] === "/") return true;
828
+ if (specifier[1] === "." && (specifier.length === 2 || specifier[2] === "/")) return true;
829
+ }
830
+ return false;
831
+ }
832
+ function shouldBeTreatedAsRelativeOrAbsolutePath(specifier) {
833
+ if (specifier === "") return false;
834
+ if (specifier[0] === "/") return true;
835
+ return isRelativeSpecifier(specifier);
836
+ }
837
+ /**
838
+ * The “Resolver Algorithm Specification” as detailed in the Node docs (which is
839
+ * sync and slightly lower-level than `resolve`).
840
+ *
841
+ * @param {string} specifier
842
+ * `/example.js`, `./example.js`, `../example.js`, `some-package`, `fs`, etc.
843
+ * @param {URL} base
844
+ * Full URL (to a file) that `specifier` is resolved relative from.
845
+ * @param {Set<string>} [conditions]
846
+ * Conditions.
847
+ * @param {boolean} [preserveSymlinks]
848
+ * Keep symlinks instead of resolving them.
849
+ * @returns {URL}
850
+ * A URL object to the found thing.
851
+ */
852
+ function moduleResolve(specifier, base, conditions, preserveSymlinks) {
853
+ const protocol = base.protocol;
854
+ const isData = protocol === "data:";
855
+ let resolved;
856
+ if (shouldBeTreatedAsRelativeOrAbsolutePath(specifier)) try {
857
+ resolved = new URL$1(specifier, base);
858
+ } catch (error_) {
859
+ const error = new ERR_UNSUPPORTED_RESOLVE_REQUEST(specifier, base);
860
+ error.cause = error_;
861
+ throw error;
862
+ }
863
+ else if (protocol === "file:" && specifier[0] === "#") resolved = packageImportsResolve(specifier, base, conditions);
864
+ else try {
865
+ resolved = new URL$1(specifier);
866
+ } catch (error_) {
867
+ if (isData && !nodeBuiltins.includes(specifier)) {
868
+ const error = new ERR_UNSUPPORTED_RESOLVE_REQUEST(specifier, base);
869
+ error.cause = error_;
870
+ throw error;
871
+ }
872
+ resolved = packageResolve(specifier, base, conditions);
873
+ }
874
+ assert.ok(resolved !== void 0, "expected to be defined");
875
+ if (resolved.protocol !== "file:") return resolved;
876
+ return finalizeResolution(resolved, base, preserveSymlinks);
877
+ }
878
+ const DEFAULT_CONDITIONS_SET = /* @__PURE__ */ new Set(["node", "import"]);
879
+ const isWindows = process.platform === "win32";
880
+ const globalCache = globalThis["__EXSOLVE_CACHE__"] ||= /* @__PURE__ */ new Map();
881
+ /**
882
+ * Synchronously resolves a module url based on the options provided.
883
+ *
884
+ * @param {string} input - The identifier or path of the module to resolve.
885
+ * @param {ResolveOptions} [options] - Options to resolve the module. See {@link ResolveOptions}.
886
+ * @returns {string} The resolved URL as a string.
887
+ */
888
+ function resolveModuleURL(input, options) {
889
+ const parsedInput = _parseInput(input);
890
+ if ("external" in parsedInput) return parsedInput.external;
891
+ const specifier = parsedInput.specifier;
892
+ let url = parsedInput.url;
893
+ let absolutePath = parsedInput.absolutePath;
894
+ let cacheKey;
895
+ let cacheObj;
896
+ if (options?.cache !== false) {
897
+ cacheKey = _cacheKey(absolutePath || specifier, options);
898
+ cacheObj = options?.cache && typeof options?.cache === "object" ? options.cache : globalCache;
899
+ }
900
+ if (cacheObj) {
901
+ const cached = cacheObj.get(cacheKey);
902
+ if (typeof cached === "string") return cached;
903
+ if (cached instanceof Error) {
904
+ if (options?.try) return;
905
+ throw cached;
906
+ }
907
+ }
908
+ if (absolutePath) try {
909
+ const stat = lstatSync(absolutePath);
910
+ if (stat.isSymbolicLink()) {
911
+ absolutePath = realpathSync(absolutePath);
912
+ url = pathToFileURL(absolutePath);
913
+ }
914
+ if (stat.isFile()) {
915
+ if (cacheObj) cacheObj.set(cacheKey, url.href);
916
+ return url.href;
917
+ }
918
+ } catch (error) {
919
+ if (error?.code !== "ENOENT") {
920
+ if (cacheObj) cacheObj.set(cacheKey, error);
921
+ throw error;
922
+ }
923
+ }
924
+ const conditionsSet = options?.conditions ? new Set(options.conditions) : DEFAULT_CONDITIONS_SET;
925
+ const target = specifier || url.href;
926
+ const bases = _normalizeBases(options?.from);
927
+ const suffixes = options?.suffixes || [""];
928
+ const extensions = options?.extensions ? ["", ...options.extensions] : [""];
929
+ let resolved;
930
+ for (const base of bases) {
931
+ for (const suffix of suffixes) {
932
+ let name = _join(target, suffix);
933
+ if (name === ".") name += "/.";
934
+ for (const extension of extensions) {
935
+ resolved = _tryModuleResolve(name + extension, base, conditionsSet);
936
+ if (resolved) break;
937
+ }
938
+ if (resolved) break;
939
+ }
940
+ if (resolved) break;
941
+ }
942
+ if (!resolved) {
943
+ const error = /* @__PURE__ */ new Error(`Cannot resolve module "${input}" (from: ${bases.map((u) => _fmtPath(u)).join(", ")})`);
944
+ error.code = "ERR_MODULE_NOT_FOUND";
945
+ if (cacheObj) cacheObj.set(cacheKey, error);
946
+ if (options?.try) return;
947
+ throw error;
948
+ }
949
+ if (cacheObj) cacheObj.set(cacheKey, resolved.href);
950
+ return resolved.href;
951
+ }
952
+ /**
953
+ * Synchronously resolves a module then converts it to a file path
954
+ *
955
+ * (throws error if reolved path is not file:// scheme)
956
+ *
957
+ * @param {string} id - The identifier or path of the module to resolve.
958
+ * @param {ResolveOptions} [options] - Options to resolve the module. See {@link ResolveOptions}.
959
+ * @returns {string} The resolved URL as a string.
960
+ */
961
+ function resolveModulePath(id, options) {
962
+ const resolved = resolveModuleURL(id, options);
963
+ if (!resolved) return;
964
+ if (!resolved.startsWith("file://") && options?.try) return;
965
+ const absolutePath = fileURLToPath(resolved);
966
+ return isWindows ? _normalizeWinPath(absolutePath) : absolutePath;
967
+ }
968
+ function _tryModuleResolve(specifier, base, conditions) {
969
+ try {
970
+ return moduleResolve(specifier, base, conditions);
971
+ } catch {}
972
+ }
973
+ function _normalizeBases(inputs) {
974
+ const urls = (Array.isArray(inputs) ? inputs : [inputs]).flatMap((input) => _normalizeBase(input));
975
+ if (urls.length === 0) return [pathToFileURL("./")];
976
+ return urls;
977
+ }
978
+ function _normalizeBase(input) {
979
+ if (!input) return [];
980
+ if (_isURL(input)) return [input];
981
+ if (typeof input !== "string") return [];
982
+ if (/^(?:node|data|http|https|file):/.test(input)) return new URL(input);
983
+ try {
984
+ if (input.endsWith("/") || statSync(input).isDirectory()) return pathToFileURL(input + "/");
985
+ return pathToFileURL(input);
986
+ } catch {
987
+ return [pathToFileURL(input + "/"), pathToFileURL(input)];
988
+ }
989
+ }
990
+ function _fmtPath(input) {
991
+ try {
992
+ return fileURLToPath(input);
993
+ } catch {
994
+ return input;
995
+ }
996
+ }
997
+ function _cacheKey(id, opts) {
998
+ return JSON.stringify([
999
+ id,
1000
+ (opts?.conditions || ["node", "import"]).sort(),
1001
+ opts?.extensions,
1002
+ opts?.from,
1003
+ opts?.suffixes
1004
+ ]);
1005
+ }
1006
+ function _join(a, b) {
1007
+ if (!a || !b || b === "/") return a;
1008
+ return (a.endsWith("/") ? a : a + "/") + (b.startsWith("/") ? b.slice(1) : b);
1009
+ }
1010
+ function _normalizeWinPath(path$1) {
1011
+ return path$1.replace(/\\/g, "/").replace(/^[a-z]:\//, (r) => r.toUpperCase());
1012
+ }
1013
+ function _isURL(input) {
1014
+ return input instanceof URL || input?.constructor?.name === "URL";
1015
+ }
1016
+ function _parseInput(input) {
1017
+ if (typeof input === "string") {
1018
+ if (input.startsWith("file:")) {
1019
+ const url = new URL(input);
1020
+ return {
1021
+ url,
1022
+ absolutePath: fileURLToPath(url)
1023
+ };
1024
+ }
1025
+ if (isAbsolute(input)) return {
1026
+ url: pathToFileURL(input),
1027
+ absolutePath: input
1028
+ };
1029
+ if (/^(?:node|data|http|https):/.test(input)) return { external: input };
1030
+ if (nodeBuiltins.includes(input) && !input.includes(":")) return { external: `node:${input}` };
1031
+ return { specifier: input };
1032
+ }
1033
+ if (_isURL(input)) {
1034
+ if (input.protocol === "file:") return {
1035
+ url: input,
1036
+ absolutePath: fileURLToPath(input)
1037
+ };
1038
+ return { external: input.href };
1039
+ }
1040
+ throw new TypeError("id must be a `string` or `URL`");
1041
+ }
1042
+ //#endregion
1043
+ //#region ../../node_modules/.pnpm/rc9@3.0.1/node_modules/rc9/dist/_chunks/libs/flat.mjs
1044
+ function isBuffer(obj) {
1045
+ return obj && obj.constructor && typeof obj.constructor.isBuffer === "function" && obj.constructor.isBuffer(obj);
1046
+ }
1047
+ function keyIdentity(key) {
1048
+ return key;
1049
+ }
1050
+ function flatten(target, opts) {
1051
+ opts = opts || {};
1052
+ const delimiter = opts.delimiter || ".";
1053
+ const maxDepth = opts.maxDepth;
1054
+ const transformKey = opts.transformKey || keyIdentity;
1055
+ const output = {};
1056
+ function step(object, prev, currentDepth) {
1057
+ currentDepth = currentDepth || 1;
1058
+ Object.keys(object).forEach(function(key) {
1059
+ const value = object[key];
1060
+ const isarray = opts.safe && Array.isArray(value);
1061
+ const type = Object.prototype.toString.call(value);
1062
+ const isbuffer = isBuffer(value);
1063
+ const isobject = type === "[object Object]" || type === "[object Array]";
1064
+ const newKey = prev ? prev + delimiter + transformKey(key) : transformKey(key);
1065
+ if (!isarray && !isbuffer && isobject && Object.keys(value).length && (!opts.maxDepth || currentDepth < maxDepth)) return step(value, newKey, currentDepth + 1);
1066
+ output[newKey] = value;
1067
+ });
1068
+ }
1069
+ step(target);
1070
+ return output;
1071
+ }
1072
+ function unflatten(target, opts) {
1073
+ opts = opts || {};
1074
+ const delimiter = opts.delimiter || ".";
1075
+ const overwrite = opts.overwrite || false;
1076
+ const transformKey = opts.transformKey || keyIdentity;
1077
+ const result = {};
1078
+ if (isBuffer(target) || Object.prototype.toString.call(target) !== "[object Object]") return target;
1079
+ function getkey(key) {
1080
+ const parsedKey = Number(key);
1081
+ return isNaN(parsedKey) || key.indexOf(".") !== -1 || opts.object ? key : parsedKey;
1082
+ }
1083
+ function addKeys(keyPrefix, recipient, target) {
1084
+ return Object.keys(target).reduce(function(result, key) {
1085
+ result[keyPrefix + delimiter + key] = target[key];
1086
+ return result;
1087
+ }, recipient);
1088
+ }
1089
+ function isEmpty(val) {
1090
+ const type = Object.prototype.toString.call(val);
1091
+ const isArray = type === "[object Array]";
1092
+ const isObject = type === "[object Object]";
1093
+ if (!val) return true;
1094
+ else if (isArray) return !val.length;
1095
+ else if (isObject) return !Object.keys(val).length;
1096
+ }
1097
+ target = Object.keys(target).reduce(function(result, key) {
1098
+ const type = Object.prototype.toString.call(target[key]);
1099
+ if (!(type === "[object Object]" || type === "[object Array]") || isEmpty(target[key])) {
1100
+ result[key] = target[key];
1101
+ return result;
1102
+ } else return addKeys(key, result, flatten(target[key], opts));
1103
+ }, {});
1104
+ Object.keys(target).forEach(function(key) {
1105
+ const split = key.split(delimiter).map(transformKey);
1106
+ let key1 = getkey(split.shift());
1107
+ let key2 = getkey(split[0]);
1108
+ let recipient = result;
1109
+ while (key2 !== void 0) {
1110
+ if (key1 === "__proto__") return;
1111
+ const type = Object.prototype.toString.call(recipient[key1]);
1112
+ const isobject = type === "[object Object]" || type === "[object Array]";
1113
+ if (!overwrite && !isobject && typeof recipient[key1] !== "undefined") return;
1114
+ if (overwrite && !isobject || !overwrite && recipient[key1] == null) recipient[key1] = typeof key2 === "number" && !opts.object ? [] : {};
1115
+ recipient = recipient[key1];
1116
+ if (split.length > 0) {
1117
+ key1 = getkey(split.shift());
1118
+ key2 = getkey(split[0]);
1119
+ }
1120
+ }
1121
+ recipient[key1] = unflatten(target[key], opts);
1122
+ });
1123
+ return result;
1124
+ }
1125
+ //#endregion
1126
+ //#region ../../node_modules/.pnpm/destr@2.0.5/node_modules/destr/dist/index.mjs
1127
+ const suspectProtoRx = /"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/;
1128
+ const suspectConstructorRx = /"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/;
1129
+ const JsonSigRx = /^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/;
1130
+ function jsonParseTransform(key, value) {
1131
+ if (key === "__proto__" || key === "constructor" && value && typeof value === "object" && "prototype" in value) {
1132
+ warnKeyDropped(key);
1133
+ return;
1134
+ }
1135
+ return value;
1136
+ }
1137
+ function warnKeyDropped(key) {
1138
+ console.warn(`[destr] Dropping "${key}" key to prevent prototype pollution.`);
1139
+ }
1140
+ function destr(value, options = {}) {
1141
+ if (typeof value !== "string") return value;
1142
+ if (value[0] === "\"" && value[value.length - 1] === "\"" && value.indexOf("\\") === -1) return value.slice(1, -1);
1143
+ const _value = value.trim();
1144
+ if (_value.length <= 9) switch (_value.toLowerCase()) {
1145
+ case "true": return true;
1146
+ case "false": return false;
1147
+ case "undefined": return;
1148
+ case "null": return null;
1149
+ case "nan": return NaN;
1150
+ case "infinity": return Number.POSITIVE_INFINITY;
1151
+ case "-infinity": return Number.NEGATIVE_INFINITY;
1152
+ }
1153
+ if (!JsonSigRx.test(value)) {
1154
+ if (options.strict) throw new SyntaxError("[destr] Invalid JSON");
1155
+ return value;
1156
+ }
1157
+ try {
1158
+ if (suspectProtoRx.test(value) || suspectConstructorRx.test(value)) {
1159
+ if (options.strict) throw new Error("[destr] Possible prototype pollution");
1160
+ return JSON.parse(value, jsonParseTransform);
1161
+ }
1162
+ return JSON.parse(value);
1163
+ } catch (error) {
1164
+ if (options.strict) throw error;
1165
+ return value;
1166
+ }
1167
+ }
1168
+ //#endregion
1169
+ //#region ../../node_modules/.pnpm/rc9@3.0.1/node_modules/rc9/dist/index.mjs
1170
+ const RE_KEY_VAL = /^\s*([^\s=]+)\s*=\s*(.*)?\s*$/;
1171
+ const RE_LINES = /\n|\r|\r\n/;
1172
+ /**
1173
+ * The default options for the configuration file.
1174
+ */
1175
+ const defaults = {
1176
+ name: ".conf",
1177
+ dir: process.cwd(),
1178
+ flat: false
1179
+ };
1180
+ function withDefaults(options) {
1181
+ if (typeof options === "string") options = { name: options };
1182
+ return {
1183
+ ...defaults,
1184
+ ...options
1185
+ };
1186
+ }
1187
+ function parse(contents, options = {}) {
1188
+ const config = {};
1189
+ const lines = contents.split(RE_LINES);
1190
+ for (const line of lines) {
1191
+ const match = line.match(RE_KEY_VAL);
1192
+ if (!match) continue;
1193
+ const key = match[1];
1194
+ if (!key || key === "__proto__" || key === "constructor") continue;
1195
+ const value = destr((match[2] || "").trim());
1196
+ if (key.endsWith("[]")) {
1197
+ const nkey = key.slice(0, Math.max(0, key.length - 2));
1198
+ config[nkey] = (config[nkey] || []).concat(value);
1199
+ continue;
1200
+ }
1201
+ config[key] = value;
1202
+ }
1203
+ return options.flat ? config : unflatten(config, { overwrite: true });
1204
+ }
1205
+ /**
1206
+ * Parses a configuration string into an object.
1207
+ * @param {string} contents - The configuration data as a raw string.
1208
+ * @param {RCOptions} [options={}] - Options to control the parsing behaviour. See {@link RCOptions}.
1209
+ * @returns {RC} - The parsed configuration object. See {@link RC}.
1210
+ */
1211
+ function parseFile(path, options) {
1212
+ if (!existsSync(path)) return {};
1213
+ return parse(readFileSync(path, "utf8"), options);
1214
+ }
1215
+ /**
1216
+ * Reads a configuration file from a default or specified location and parses its contents.
1217
+ * @param {RCOptions|string} [options] - Options for reading the configuration file, or the name of the configuration file. See {@link RCOptions}.
1218
+ * @returns {RC} - The parsed configuration object. See {@link RC}.
1219
+ */
1220
+ function read(options) {
1221
+ options = withDefaults(options);
1222
+ return parseFile(resolve(options.dir, options.name), options);
1223
+ }
1224
+ /**
1225
+ * Reads a custom configuration file from a default or specified location and parses its contents.
1226
+ * @param {RCOptions|string} [options] - Options for reading the configuration file, or the name of the configuration file. See {@link RCOptions}.
1227
+ * @returns {RC} - The parsed configuration object.
1228
+ * @deprecated Use {@link readUserConfig} instead, which uses `~/.config` following XDG conventions.
1229
+ */
1230
+ function readUser(options) {
1231
+ options = withDefaults(options);
1232
+ options.dir = process.env.XDG_CONFIG_HOME || homedir();
1233
+ return read(options);
1234
+ }
1235
+ //#endregion
1236
+ //#region ../../node_modules/.pnpm/pkg-types@2.3.0/node_modules/pkg-types/dist/index.mjs
1237
+ const defaultFindOptions = {
1238
+ startingFrom: ".",
1239
+ rootPattern: /^node_modules$/,
1240
+ reverse: false,
1241
+ test: (filePath) => {
1242
+ try {
1243
+ if (statSync(filePath).isFile()) return true;
1244
+ } catch {}
1245
+ }
1246
+ };
1247
+ async function findFile(filename, _options = {}) {
1248
+ const filenames = Array.isArray(filename) ? filename : [filename];
1249
+ const options = {
1250
+ ...defaultFindOptions,
1251
+ ..._options
1252
+ };
1253
+ const basePath = resolve$1(options.startingFrom);
1254
+ const leadingSlash = basePath[0] === "/";
1255
+ const segments = basePath.split("/").filter(Boolean);
1256
+ if (filenames.includes(segments.at(-1)) && await options.test(basePath)) return basePath;
1257
+ if (leadingSlash) segments[0] = "/" + segments[0];
1258
+ let root = segments.findIndex((r) => r.match(options.rootPattern));
1259
+ if (root === -1) root = 0;
1260
+ if (options.reverse) for (let index = root + 1; index <= segments.length; index++) for (const filename2 of filenames) {
1261
+ const filePath = join$1(...segments.slice(0, index), filename2);
1262
+ if (await options.test(filePath)) return filePath;
1263
+ }
1264
+ else for (let index = segments.length; index > root; index--) for (const filename2 of filenames) {
1265
+ const filePath = join$1(...segments.slice(0, index), filename2);
1266
+ if (await options.test(filePath)) return filePath;
1267
+ }
1268
+ throw new Error(`Cannot find matching ${filename} in ${options.startingFrom} or parent directories`);
1269
+ }
1270
+ function findNearestFile(filename, options = {}) {
1271
+ return findFile(filename, options);
1272
+ }
1273
+ function _resolvePath(id, opts = {}) {
1274
+ if (id instanceof URL || id.startsWith("file://")) return normalize(fileURLToPath(id));
1275
+ if (isAbsolute$1(id)) return normalize(id);
1276
+ return resolveModulePath(id, {
1277
+ ...opts,
1278
+ from: opts.from || opts.parent || opts.url
1279
+ });
1280
+ }
1281
+ const lockFiles = [
1282
+ "yarn.lock",
1283
+ "package-lock.json",
1284
+ "pnpm-lock.yaml",
1285
+ "npm-shrinkwrap.json",
1286
+ "bun.lockb",
1287
+ "bun.lock",
1288
+ "deno.lock"
1289
+ ];
1290
+ const packageFiles = [
1291
+ "package.json",
1292
+ "package.json5",
1293
+ "package.yaml"
1294
+ ];
1295
+ const workspaceFiles = [
1296
+ "pnpm-workspace.yaml",
1297
+ "lerna.json",
1298
+ "turbo.json",
1299
+ "rush.json",
1300
+ "deno.json",
1301
+ "deno.jsonc"
1302
+ ];
1303
+ const FileCache = /* @__PURE__ */ new Map();
1304
+ async function readPackageJSON(id, options = {}) {
1305
+ const resolvedPath = await resolvePackageJSON(id, options);
1306
+ const cache = options.cache && typeof options.cache !== "boolean" ? options.cache : FileCache;
1307
+ if (options.cache && cache.has(resolvedPath)) return cache.get(resolvedPath);
1308
+ const blob = await promises.readFile(resolvedPath, "utf8");
1309
+ let parsed;
1310
+ try {
1311
+ parsed = n(blob);
1312
+ } catch {
1313
+ parsed = r(blob);
1314
+ }
1315
+ cache.set(resolvedPath, parsed);
1316
+ return parsed;
1317
+ }
1318
+ async function resolvePackageJSON(id = process.cwd(), options = {}) {
1319
+ return findNearestFile("package.json", {
1320
+ ...options,
1321
+ startingFrom: _resolvePath(id, options)
1322
+ });
1323
+ }
1324
+ const workspaceTests = {
1325
+ workspaceFile: (opts) => findFile(workspaceFiles, opts).then((r) => dirname$1(r)),
1326
+ gitConfig: (opts) => findFile(".git/config", opts).then((r) => resolve$1(r, "../..")),
1327
+ lockFile: (opts) => findFile(lockFiles, opts).then((r) => dirname$1(r)),
1328
+ packageJson: (opts) => findFile(packageFiles, opts).then((r) => dirname$1(r))
1329
+ };
1330
+ async function findWorkspaceDir(id = process.cwd(), options = {}) {
1331
+ const startingFrom = _resolvePath(id, options);
1332
+ const tests = options.tests || [
1333
+ "workspaceFile",
1334
+ "gitConfig",
1335
+ "lockFile",
1336
+ "packageJson"
1337
+ ];
1338
+ for (const testName of tests) {
1339
+ const test = workspaceTests[testName];
1340
+ if (options[testName] === false || !test) continue;
1341
+ const direction = options[testName] || (testName === "gitConfig" ? "closest" : "furthest");
1342
+ const detected = await test({
1343
+ ...options,
1344
+ startingFrom,
1345
+ reverse: direction === "furthest"
1346
+ }).catch(() => {});
1347
+ if (detected) return detected;
1348
+ }
1349
+ throw new Error(`Cannot detect workspace root from ${id}`);
1350
+ }
1351
+ //#endregion
1352
+ //#region ../../node_modules/.pnpm/c12@4.0.0-beta.4_chokidar@5.0.0_dotenv@17.4.2_giget@1.2.5_jiti@2.7.0_magicast@0.5.2/node_modules/c12/dist/index.mjs
1353
+ /**
1354
+ * Load and interpolate environment variables into `process.env`.
1355
+ * If you need more control (or access to the values), consider using `loadDotenv` instead
1356
+ *
1357
+ */
1358
+ async function setupDotenv(options) {
1359
+ const targetEnvironment = options.env ?? process.env;
1360
+ const environment = await loadDotenv({
1361
+ cwd: options.cwd,
1362
+ fileName: options.fileName ?? ".env",
1363
+ env: targetEnvironment,
1364
+ interpolate: options.interpolate ?? true,
1365
+ expandFileReferences: options.expandFileReferences ?? false
1366
+ });
1367
+ const dotenvVars = getDotEnvVars(targetEnvironment);
1368
+ for (const key in environment) {
1369
+ if (key.startsWith("_")) continue;
1370
+ if (targetEnvironment[key] === void 0 || dotenvVars.has(key)) targetEnvironment[key] = environment[key];
1371
+ }
1372
+ return environment;
1373
+ }
1374
+ /** Load environment variables into an object. */
1375
+ async function loadDotenv(options) {
1376
+ const environment = Object.create(null);
1377
+ const cwd = resolve$1(options.cwd || ".");
1378
+ const _fileName = options.fileName || ".env";
1379
+ const dotenvFiles = typeof _fileName === "string" ? [_fileName] : _fileName;
1380
+ const dotenvVars = getDotEnvVars(options.env || {});
1381
+ Object.assign(environment, options.env);
1382
+ for (const file of dotenvFiles) {
1383
+ const dotenvFile = resolve$1(cwd, file);
1384
+ if (!statSync(dotenvFile, { throwIfNoEntry: false })?.isFile()) continue;
1385
+ const parsed = await readEnvFile(dotenvFile);
1386
+ for (const key in parsed) {
1387
+ if (key in environment && !dotenvVars.has(key)) continue;
1388
+ environment[key] = parsed[key];
1389
+ dotenvVars.add(key);
1390
+ }
1391
+ }
1392
+ if (options.expandFileReferences) {
1393
+ for (const key in environment) if (key.endsWith("_FILE")) {
1394
+ const targetKey = key.slice(0, -5);
1395
+ if (environment[targetKey] === void 0) {
1396
+ const filePath = environment[key];
1397
+ if (filePath && statSync(filePath, { throwIfNoEntry: false })?.isFile()) {
1398
+ environment[targetKey] = readFileSync(filePath, "utf8").trim();
1399
+ dotenvVars.add(targetKey);
1400
+ }
1401
+ }
1402
+ }
1403
+ }
1404
+ if (options.interpolate) interpolate(environment);
1405
+ return environment;
1406
+ }
1407
+ let _parseEnv = nodeUtil.parseEnv;
1408
+ async function readEnvFile(path) {
1409
+ const src = readFileSync(path, "utf8");
1410
+ if (!_parseEnv) try {
1411
+ const dotenv = await import("./main-C_8x2aB3.js").then((m) => /* @__PURE__ */ __toESM(m.default, 1));
1412
+ _parseEnv = (src) => dotenv.parse(src);
1413
+ } catch {
1414
+ throw new Error("Failed to parse .env file: `node:util.parseEnv` is not available and `dotenv` package is not installed. Please upgrade your runtime or install `dotenv` as a dependency.");
1415
+ }
1416
+ return _parseEnv(src);
1417
+ }
1418
+ function interpolate(target, source = {}, parse = (v) => v) {
1419
+ function getValue(key) {
1420
+ return source[key] === void 0 ? target[key] : source[key];
1421
+ }
1422
+ function interpolate(value, parents = []) {
1423
+ if (typeof value !== "string") return value;
1424
+ return parse((value.match(/(.?\${?(?:[\w:]+)?}?)/g) || []).reduce((newValue, match) => {
1425
+ const parts = /(.?)\${?([\w:]+)?}?/g.exec(match) || [];
1426
+ const prefix = parts[1];
1427
+ let value, replacePart;
1428
+ if (prefix === "\\") {
1429
+ replacePart = parts[0] || "";
1430
+ value = replacePart.replace(String.raw`\$`, "$");
1431
+ } else {
1432
+ const key = parts[2];
1433
+ replacePart = (parts[0] || "").slice(prefix.length);
1434
+ if (parents.includes(key)) {
1435
+ console.warn(`Please avoid recursive environment variables ( loop: ${parents.join(" > ")} > ${key} )`);
1436
+ return "";
1437
+ }
1438
+ value = getValue(key);
1439
+ value = interpolate(value, [...parents, key]);
1440
+ }
1441
+ return value === void 0 ? newValue : newValue.replace(replacePart, value);
1442
+ }, value));
1443
+ }
1444
+ for (const key in target) target[key] = interpolate(getValue(key));
1445
+ }
1446
+ function getDotEnvVars(targetEnvironment) {
1447
+ const globalRegistry = globalThis.__c12_dotenv_vars__ ||= /* @__PURE__ */ new Map();
1448
+ if (!globalRegistry.has(targetEnvironment)) globalRegistry.set(targetEnvironment, /* @__PURE__ */ new Set());
1449
+ return globalRegistry.get(targetEnvironment);
1450
+ }
1451
+ const _normalize = (p) => p?.replace(/\\/g, "/");
1452
+ let importCounter = 0;
1453
+ const ASYNC_LOADERS = {
1454
+ ".yaml": () => import("./yaml-BS9RDuUr.js").then((r) => r.parseYAML),
1455
+ ".yml": () => import("./yaml-BS9RDuUr.js").then((r) => r.parseYAML),
1456
+ ".jsonc": () => import("./jsonc-KADMdSjU.js").then((r) => r.parseJSONC),
1457
+ ".json5": () => import("./json5-z-PGDMyy.js").then((r) => r.parseJSON5),
1458
+ ".toml": () => import("./toml-LuHsHQtV.js").then((r) => r.parseTOML)
1459
+ };
1460
+ const SUPPORTED_EXTENSIONS = Object.freeze([
1461
+ ".js",
1462
+ ".ts",
1463
+ ".mjs",
1464
+ ".cjs",
1465
+ ".mts",
1466
+ ".cts",
1467
+ ".json",
1468
+ ".jsonc",
1469
+ ".json5",
1470
+ ".yaml",
1471
+ ".yml",
1472
+ ".toml"
1473
+ ]);
1474
+ async function loadConfig$1(options) {
1475
+ options.cwd = resolve$1(process.cwd(), options.cwd || ".");
1476
+ options.name = options.name || "config";
1477
+ options.envName = options.envName ?? process.env.NODE_ENV;
1478
+ options.configFile = options.configFile ?? (options.name === "config" ? "config" : `${options.name}.config`);
1479
+ options.rcFile = options.rcFile ?? `.${options.name}rc`;
1480
+ if (options.extend !== false) options.extend = {
1481
+ extendKey: "extends",
1482
+ ...options.extend
1483
+ };
1484
+ const _merger = options.merger || defu;
1485
+ const r = {
1486
+ config: {},
1487
+ cwd: options.cwd,
1488
+ configFile: resolve$1(options.cwd, options.configFile),
1489
+ layers: [],
1490
+ _configFile: void 0
1491
+ };
1492
+ const rawConfigs = {
1493
+ overrides: options.overrides,
1494
+ main: void 0,
1495
+ rc: void 0,
1496
+ packageJson: void 0,
1497
+ defaultConfig: options.defaultConfig
1498
+ };
1499
+ if (options.dotenv) await setupDotenv({
1500
+ cwd: options.cwd,
1501
+ ...options.dotenv === true ? {} : options.dotenv
1502
+ });
1503
+ const _mainConfig = await resolveConfig(".", options);
1504
+ if (_mainConfig.configFile) {
1505
+ rawConfigs.main = _mainConfig.config;
1506
+ r.configFile = _mainConfig.configFile;
1507
+ r._configFile = _mainConfig._configFile;
1508
+ }
1509
+ if (_mainConfig.meta) r.meta = _mainConfig.meta;
1510
+ if (options.rcFile) {
1511
+ const rcSources = [];
1512
+ rcSources.push(read({
1513
+ name: options.rcFile,
1514
+ dir: options.cwd
1515
+ }));
1516
+ if (options.globalRc) {
1517
+ const workspaceDir = await findWorkspaceDir(options.cwd).catch(() => {});
1518
+ if (workspaceDir) rcSources.push(read({
1519
+ name: options.rcFile,
1520
+ dir: workspaceDir
1521
+ }));
1522
+ rcSources.push(readUser({
1523
+ name: options.rcFile,
1524
+ dir: options.cwd
1525
+ }));
1526
+ }
1527
+ rawConfigs.rc = _merger({}, ...rcSources);
1528
+ }
1529
+ if (options.packageJson) {
1530
+ const keys = (Array.isArray(options.packageJson) ? options.packageJson : [typeof options.packageJson === "string" ? options.packageJson : options.name]).filter((t) => t && typeof t === "string");
1531
+ const pkgJsonFile = await readPackageJSON(options.cwd).catch(() => {});
1532
+ rawConfigs.packageJson = _merger({}, ...keys.map((key) => pkgJsonFile?.[key]));
1533
+ }
1534
+ const configs = {};
1535
+ for (const key in rawConfigs) {
1536
+ const value = rawConfigs[key];
1537
+ configs[key] = await (typeof value === "function" ? value({
1538
+ configs,
1539
+ rawConfigs
1540
+ }) : value);
1541
+ }
1542
+ if (Array.isArray(configs.main)) r.config = configs.main;
1543
+ else {
1544
+ r.config = _merger(configs.overrides, configs.main, configs.rc, configs.packageJson, configs.defaultConfig);
1545
+ if (options.extend) {
1546
+ await extendConfig(r.config, options);
1547
+ r.layers = r.config._layers;
1548
+ delete r.config._layers;
1549
+ r.config = _merger(r.config, ...r.layers.map((e) => e.config));
1550
+ }
1551
+ }
1552
+ r.layers = [...[
1553
+ configs.overrides && {
1554
+ config: configs.overrides,
1555
+ configFile: void 0,
1556
+ cwd: void 0
1557
+ },
1558
+ {
1559
+ config: configs.main,
1560
+ configFile: options.configFile,
1561
+ cwd: options.cwd
1562
+ },
1563
+ configs.rc && {
1564
+ config: configs.rc,
1565
+ configFile: options.rcFile
1566
+ },
1567
+ configs.packageJson && {
1568
+ config: configs.packageJson,
1569
+ configFile: "package.json"
1570
+ }
1571
+ ].filter((l) => l && l.config), ...r.layers];
1572
+ if (options.defaults) r.config = _merger(r.config, options.defaults);
1573
+ if (options.omit$Keys) {
1574
+ for (const key in r.config) if (key.startsWith("$")) delete r.config[key];
1575
+ }
1576
+ if (options.configFileRequired && !r._configFile) throw new Error(`Required config (${r.configFile}) cannot be resolved.`);
1577
+ return r;
1578
+ }
1579
+ async function extendConfig(config, options) {
1580
+ config._layers = config._layers || [];
1581
+ if (!options.extend) return;
1582
+ let keys = options.extend.extendKey;
1583
+ if (typeof keys === "string") keys = [keys];
1584
+ const extendSources = [];
1585
+ for (const key of keys) {
1586
+ extendSources.push(...(Array.isArray(config[key]) ? config[key] : [config[key]]).filter(Boolean));
1587
+ delete config[key];
1588
+ }
1589
+ for (let extendSource of extendSources) {
1590
+ const originalExtendSource = extendSource;
1591
+ let sourceOptions = {};
1592
+ if (extendSource.source) {
1593
+ sourceOptions = extendSource.options || {};
1594
+ extendSource = extendSource.source;
1595
+ }
1596
+ if (Array.isArray(extendSource)) {
1597
+ sourceOptions = extendSource[1] || {};
1598
+ extendSource = extendSource[0];
1599
+ }
1600
+ if (typeof extendSource !== "string") {
1601
+ console.warn(`Cannot extend config from \`${JSON.stringify(originalExtendSource)}\` in ${options.cwd}`);
1602
+ continue;
1603
+ }
1604
+ const _config = await resolveConfig(extendSource, options, sourceOptions);
1605
+ if (!_config.config) {
1606
+ console.warn(`Cannot extend config from \`${extendSource}\` in ${options.cwd}`);
1607
+ continue;
1608
+ }
1609
+ await extendConfig(_config.config, {
1610
+ ...options,
1611
+ cwd: _config.cwd
1612
+ });
1613
+ config._layers.push(_config);
1614
+ if (_config.config._layers) {
1615
+ config._layers.push(..._config.config._layers);
1616
+ delete _config.config._layers;
1617
+ }
1618
+ }
1619
+ }
1620
+ const GIGET_PREFIXES = [
1621
+ "gh:",
1622
+ "github:",
1623
+ "gitlab:",
1624
+ "bitbucket:",
1625
+ "https://",
1626
+ "http://"
1627
+ ];
1628
+ const NPM_PACKAGE_RE = /^(@[\da-z~-][\d._a-z~-]*\/)?[\da-z~-][\d._a-z~-]*($|\/.*)/;
1629
+ async function resolveConfig(source, options, sourceOptions = {}) {
1630
+ if (options.resolve) {
1631
+ const res = await options.resolve(source, options);
1632
+ if (res) return res;
1633
+ }
1634
+ const _merger = options.merger || defu;
1635
+ const customProviderKeys = Object.keys(sourceOptions.giget?.providers || {}).map((key) => `${key}:`);
1636
+ const gigetPrefixes = customProviderKeys.length > 0 ? [...new Set([...customProviderKeys, ...GIGET_PREFIXES])] : GIGET_PREFIXES;
1637
+ if (options.giget !== false && gigetPrefixes.some((prefix) => source.startsWith(prefix))) {
1638
+ const { downloadTemplate } = await import("./dist-Xa07jNxS.js").catch((error) => {
1639
+ throw new Error(`Extending config from \`${source}\` requires \`giget\` peer dependency to be installed.\n\nInstall it with: \`npx nypm i giget\``, { cause: error });
1640
+ });
1641
+ const { digest } = await import("./ohash-BPoV4zBH.js").then((n) => n.n);
1642
+ const cloneName = source.replace(/\W+/g, "_").split("_").splice(0, 3).join("_") + "_" + digest(source).slice(0, 10).replace(/[-_]/g, "");
1643
+ let cloneDir;
1644
+ const localNodeModules = resolve$1(options.cwd, "node_modules");
1645
+ const parentDir = dirname$1(options.cwd);
1646
+ if (basename$1(parentDir) === ".c12") cloneDir = join$1(parentDir, cloneName);
1647
+ else if (existsSync(localNodeModules)) cloneDir = join$1(localNodeModules, ".c12", cloneName);
1648
+ else cloneDir = process.env.XDG_CACHE_HOME ? resolve$1(process.env.XDG_CACHE_HOME, "c12", cloneName) : resolve$1(homedir(), ".cache/c12", cloneName);
1649
+ if (existsSync(cloneDir) && !sourceOptions.install) await rm(cloneDir, { recursive: true });
1650
+ source = (await downloadTemplate(source, {
1651
+ dir: cloneDir,
1652
+ install: sourceOptions.install,
1653
+ force: sourceOptions.install,
1654
+ auth: sourceOptions.auth,
1655
+ ...options.giget,
1656
+ ...sourceOptions.giget
1657
+ })).dir;
1658
+ }
1659
+ if (NPM_PACKAGE_RE.test(source)) source = tryResolve(source, options) || source;
1660
+ const ext = extname$2(source);
1661
+ const isDir = _isDirectory(resolve$1(options.cwd, source)) ?? (!ext || ext === basename$1(source));
1662
+ const cwd = resolve$1(options.cwd, isDir ? source : dirname$1(source));
1663
+ if (isDir) source = options.configFile;
1664
+ const res = {
1665
+ config: void 0,
1666
+ configFile: void 0,
1667
+ cwd,
1668
+ source,
1669
+ sourceOptions
1670
+ };
1671
+ res.configFile = tryResolve(resolve$1(cwd, source), options) || tryResolve(resolve$1(cwd, ".config", source.replace(/\.config$/, "")), options) || tryResolve(resolve$1(cwd, ".config", source), options) || source;
1672
+ if (!existsSync(res.configFile)) return res;
1673
+ res._configFile = res.configFile;
1674
+ const configFileExt = extname$2(res.configFile) || "";
1675
+ if (configFileExt in ASYNC_LOADERS) res.config = (await ASYNC_LOADERS[configFileExt]())(await readFile(res.configFile, "utf8"));
1676
+ else {
1677
+ const _resolveModule = options.resolveModule || ((mod) => mod.default || mod);
1678
+ if (options.import) res.config = _resolveModule(await options.import(res.configFile));
1679
+ else {
1680
+ const _configURL = pathToFileURL(res.configFile);
1681
+ _configURL.search = `_${++importCounter}`;
1682
+ res.config = await import(_configURL.href).then(_resolveModule, async (error) => {
1683
+ const { createJiti } = await import("./jiti-CxWlVmZ_.js").catch(() => {
1684
+ throw new Error(`Failed to load config file \`${res.configFile}\`: ${error?.message}. Hint install \`jiti\` for compatibility.`, { cause: error });
1685
+ });
1686
+ const jiti = createJiti(join$1(options.cwd || ".", options.configFile || "/"), {
1687
+ interopDefault: true,
1688
+ moduleCache: false,
1689
+ extensions: [...SUPPORTED_EXTENSIONS]
1690
+ });
1691
+ options.import = (id) => jiti.import(id);
1692
+ return _resolveModule(await options.import(res.configFile));
1693
+ });
1694
+ }
1695
+ }
1696
+ if (typeof res.config === "function") res.config = await res.config(options.context);
1697
+ if (options.envName) {
1698
+ const envConfig = {
1699
+ ...res.config["$" + options.envName],
1700
+ ...res.config.$env?.[options.envName]
1701
+ };
1702
+ if (Object.keys(envConfig).length > 0) res.config = _merger(envConfig, res.config);
1703
+ }
1704
+ res.meta = defu(res.sourceOptions.meta, res.config.$meta);
1705
+ delete res.config.$meta;
1706
+ if (res.sourceOptions.overrides) res.config = _merger(res.sourceOptions.overrides, res.config);
1707
+ res.configFile = _normalize(res.configFile);
1708
+ res.source = _normalize(res.source);
1709
+ return res;
1710
+ }
1711
+ function tryResolve(id, options) {
1712
+ const res = resolveModulePath(id, {
1713
+ try: true,
1714
+ from: pathToFileURL(join$1(options.cwd || ".", options.configFile || "/")),
1715
+ suffixes: ["", "/index"],
1716
+ extensions: SUPPORTED_EXTENSIONS,
1717
+ cache: false
1718
+ });
1719
+ return res ? normalize(res) : void 0;
1720
+ }
1721
+ /** Returns `true`/`false` if the path exists, `null` if it doesn't. */
1722
+ function _isDirectory(path) {
1723
+ try {
1724
+ return statSync(path).isDirectory();
1725
+ } catch {
1726
+ return null;
1727
+ }
1728
+ }
1729
+ //#endregion
1730
+ //#region ../utils/dist/validate.js
1731
+ /**
1732
+ * Validate unknown input against a Zod schema.
1733
+ *
1734
+ * When validation fails, issues are automatically formatted into a human-readable
1735
+ * message. If a `createError` factory is provided, it receives the formatted
1736
+ * issues and message. Otherwise, a plain `Error` with the formatted message is
1737
+ * returned.
1738
+ *
1739
+ * @param options - The validation options.
1740
+ * @param options.schema - The Zod schema to validate against.
1741
+ * @param options.params - The unknown value to validate.
1742
+ * @param options.createError - Optional factory invoked when validation fails.
1743
+ * @returns A Result tuple - either [Error, null] on failure or [null, T] on success.
1744
+ */
1745
+ function validate({ schema, params, createError }) {
1746
+ const result = schema.safeParse(params);
1747
+ if (!result.success) {
1748
+ const formatted = formatZodIssues(result.error.issues);
1749
+ if (createError) return err(createError(formatted));
1750
+ return err(formatted.message);
1751
+ }
1752
+ return ok(result.data);
1753
+ }
1754
+ /**
1755
+ * Format raw Zod validation issues into structured objects and a human-readable string.
1756
+ *
1757
+ * @private
1758
+ * @param issues - Raw Zod validation issues.
1759
+ * @param separator - Separator between formatted issue strings.
1760
+ * @returns An object containing the formatted issues array and a joined message string.
1761
+ */
1762
+ function formatZodIssues(issues, separator = "\n ") {
1763
+ const formatted = issues.map((issue) => ({
1764
+ message: issue.message,
1765
+ path: issue.path.map(String).join(".")
1766
+ }));
1767
+ return {
1768
+ issues: formatted,
1769
+ message: formatted.map((item) => {
1770
+ if (item.path.length > 0) return `${item.path}: ${item.message}`;
1771
+ return item.message;
1772
+ }).join(separator)
1773
+ };
1774
+ }
1775
+ //#endregion
1776
+ //#region ../config/dist/utils.js
1777
+ /**
1778
+ * All supported cross-compilation targets with human-readable labels.
1779
+ *
1780
+ * This is the single source of truth — the {@link CompileTarget} union type
1781
+ * and the Zod validation schema are both derived from this array.
1782
+ *
1783
+ * Targets marked `default: true` are compiled when no explicit targets are configured,
1784
+ * covering ~95% of developer environments.
1785
+ */
1786
+ const compileTargets = [
1787
+ {
1788
+ target: "darwin-arm64",
1789
+ label: "macOS Apple Silicon",
1790
+ default: true
1791
+ },
1792
+ {
1793
+ target: "darwin-x64",
1794
+ label: "macOS Intel",
1795
+ default: true
1796
+ },
1797
+ {
1798
+ target: "linux-arm64",
1799
+ label: "Linux ARM64",
1800
+ default: false
1801
+ },
1802
+ {
1803
+ target: "linux-x64",
1804
+ label: "Linux x64",
1805
+ default: true
1806
+ },
1807
+ {
1808
+ target: "linux-x64-musl",
1809
+ label: "Linux x64 (musl)",
1810
+ default: false
1811
+ },
1812
+ {
1813
+ target: "windows-arm64",
1814
+ label: "Windows ARM64",
1815
+ default: false
1816
+ },
1817
+ {
1818
+ target: "windows-x64",
1819
+ label: "Windows x64",
1820
+ default: true
1821
+ }
1822
+ ];
1823
+ /**
1824
+ * @private
1825
+ */
1826
+ const compileTargetValues = compileTargets.map((entry) => entry.target);
1827
+ /**
1828
+ * @private
1829
+ */
1830
+ const CompileTargetSchema = z.enum(compileTargetValues);
1831
+ /**
1832
+ * @private
1833
+ */
1834
+ const BuildOptionsSchema = z.object({
1835
+ clean: z.boolean().optional(),
1836
+ define: z.record(z.string(), z.string()).optional(),
1837
+ external: z.array(z.string()).optional(),
1838
+ minify: z.boolean().optional(),
1839
+ out: z.string().optional(),
1840
+ sourcemap: z.boolean().optional(),
1841
+ target: z.string().optional()
1842
+ }).strict();
1843
+ /**
1844
+ * @private
1845
+ */
1846
+ const CompileOptionsSchema = z.object({
1847
+ autoloadDotenv: z.boolean().optional(),
1848
+ name: z.string().optional(),
1849
+ out: z.string().optional(),
1850
+ targets: z.array(CompileTargetSchema).optional()
1851
+ }).strict();
1852
+ /**
1853
+ * Zod schema validating the {@link MalttyConfig} shape.
1854
+ */
1855
+ const MalttyConfigSchema = z.object({
1856
+ build: BuildOptionsSchema.optional(),
1857
+ commands: z.string().optional(),
1858
+ compile: z.union([z.boolean(), CompileOptionsSchema]).optional(),
1859
+ entry: z.string().optional(),
1860
+ include: z.array(z.string()).optional()
1861
+ }).strict();
1862
+ /**
1863
+ * Validate arbitrary data against the {@link MalttyConfigSchema}.
1864
+ *
1865
+ * @param data - The unknown value to validate.
1866
+ * @returns A Result tuple - `[null, MalttyConfig]` on success or `[Error, null]` on failure.
1867
+ */
1868
+ function validateConfig(data) {
1869
+ return validate({
1870
+ schema: MalttyConfigSchema,
1871
+ params: data,
1872
+ createError: ({ message }) => /* @__PURE__ */ new Error(`Invalid maltty config:\n ${message}`)
1873
+ });
1874
+ }
1875
+ /**
1876
+ * Load and validate a `maltty.config.ts` file using c12.
1877
+ *
1878
+ * Searches for a config file named `maltty` (e.g. `maltty.config.ts`, `maltty.config.mts`)
1879
+ * in the given working directory, validates it against the build config schema,
1880
+ * and returns a tagged config object.
1881
+ *
1882
+ * @param options - Optional loader configuration.
1883
+ * @returns A Result tuple - `[null, LoadConfigResult]` on success or `[Error, null]` on failure.
1884
+ */
1885
+ async function loadConfig(options) {
1886
+ const { cwd, defaults, overrides } = options ?? {};
1887
+ const [loadError, loaded] = await attemptAsync(() => loadConfig$1({
1888
+ cwd,
1889
+ defaults,
1890
+ name: "maltty",
1891
+ overrides
1892
+ }));
1893
+ if (loadError) return err(`Failed to load maltty config: ${toError(loadError).message}`);
1894
+ if (!loaded) return err("Failed to load maltty config: no configuration was returned");
1895
+ const [validateError, config] = validateConfig(loaded.config);
1896
+ if (validateError) return err(validateError);
1897
+ return ok({
1898
+ config: withTag(config, "MalttyConfig"),
1899
+ configFile: loaded.configFile
1900
+ });
1901
+ }
1902
+ //#endregion
1903
+ export { loadConfig as n, compileTargets as t };
1904
+
1905
+ //# sourceMappingURL=utils-DlIJNGLQ.js.map