@powerlines/plugin-automd 0.1.253 → 0.1.255

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 (139) hide show
  1. package/dist/{chunk-BrXtsOCC.cjs → _virtual/rolldown_runtime.cjs} +2 -12
  2. package/dist/{chunk-CS8OKu3y.mjs → _virtual/rolldown_runtime.mjs} +1 -1
  3. package/dist/index.cjs +7 -9656
  4. package/dist/index.d.cts +3 -3
  5. package/dist/index.d.mts +3 -3
  6. package/dist/index.mjs +2 -9646
  7. package/dist/index.mjs.map +1 -1
  8. package/dist/node_modules/.pnpm/@jridgewell_sourcemap-codec@1.5.5/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.cjs +78 -0
  9. package/dist/node_modules/.pnpm/@jridgewell_sourcemap-codec@1.5.5/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs +78 -0
  10. package/dist/node_modules/.pnpm/@jridgewell_sourcemap-codec@1.5.5/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs.map +1 -0
  11. package/dist/node_modules/.pnpm/acorn@8.15.0/node_modules/acorn/dist/acorn.cjs +5032 -0
  12. package/dist/node_modules/.pnpm/acorn@8.15.0/node_modules/acorn/dist/acorn.mjs +5032 -0
  13. package/dist/node_modules/.pnpm/acorn@8.15.0/node_modules/acorn/dist/acorn.mjs.map +1 -0
  14. package/dist/node_modules/.pnpm/automd@0.4.3_patch_hash_0fe864a2d6fa1461e144747e5f0fbc0a5fb51435ec6b3217ffb18ff2d7058778_magicast@0.5.1/node_modules/automd/dist/index.cjs +650 -0
  15. package/dist/node_modules/.pnpm/automd@0.4.3_patch_hash_0fe864a2d6fa1461e144747e5f0fbc0a5fb51435ec6b3217ffb18ff2d7058778_magicast@0.5.1/node_modules/automd/dist/index.mjs +648 -0
  16. package/dist/node_modules/.pnpm/automd@0.4.3_patch_hash_0fe864a2d6fa1461e144747e5f0fbc0a5fb51435ec6b3217ffb18ff2d7058778_magicast@0.5.1/node_modules/automd/dist/index.mjs.map +1 -0
  17. package/dist/node_modules/.pnpm/confbox@0.2.2/node_modules/confbox/dist/shared/confbox.DA7CpUDY.cjs +23 -0
  18. package/dist/node_modules/.pnpm/confbox@0.2.2/node_modules/confbox/dist/shared/confbox.DA7CpUDY.mjs +23 -0
  19. package/dist/node_modules/.pnpm/confbox@0.2.2/node_modules/confbox/dist/shared/confbox.DA7CpUDY.mjs.map +1 -0
  20. package/dist/node_modules/.pnpm/confbox@0.2.2/node_modules/confbox/dist/shared/confbox.DnMsyigM.cjs +405 -0
  21. package/dist/node_modules/.pnpm/confbox@0.2.2/node_modules/confbox/dist/shared/confbox.DnMsyigM.mjs +405 -0
  22. package/dist/node_modules/.pnpm/confbox@0.2.2/node_modules/confbox/dist/shared/confbox.DnMsyigM.mjs.map +1 -0
  23. package/dist/node_modules/.pnpm/destr@2.0.5/node_modules/destr/dist/index.cjs +46 -0
  24. package/dist/node_modules/.pnpm/destr@2.0.5/node_modules/destr/dist/index.mjs +46 -0
  25. package/dist/node_modules/.pnpm/destr@2.0.5/node_modules/destr/dist/index.mjs.map +1 -0
  26. package/dist/node_modules/.pnpm/didyoumean2@7.0.4/node_modules/didyoumean2/dist/index.cjs +204 -0
  27. package/dist/node_modules/.pnpm/didyoumean2@7.0.4/node_modules/didyoumean2/dist/index.mjs +203 -0
  28. package/dist/node_modules/.pnpm/didyoumean2@7.0.4/node_modules/didyoumean2/dist/index.mjs.map +1 -0
  29. package/dist/node_modules/.pnpm/exsolve@1.0.8/node_modules/exsolve/dist/index.cjs +1013 -0
  30. package/dist/node_modules/.pnpm/exsolve@1.0.8/node_modules/exsolve/dist/index.mjs +1008 -0
  31. package/dist/node_modules/.pnpm/exsolve@1.0.8/node_modules/exsolve/dist/index.mjs.map +1 -0
  32. package/dist/node_modules/.pnpm/fastest-levenshtein@1.0.16/node_modules/fastest-levenshtein/mod.cjs +128 -0
  33. package/dist/node_modules/.pnpm/fastest-levenshtein@1.0.16/node_modules/fastest-levenshtein/mod.mjs +124 -0
  34. package/dist/node_modules/.pnpm/fastest-levenshtein@1.0.16/node_modules/fastest-levenshtein/mod.mjs.map +1 -0
  35. package/dist/{loader-DNEbMIIe.cjs → node_modules/.pnpm/jiti@2.4.2/node_modules/jiti/dist/babel.cjs} +41337 -58245
  36. package/dist/{loader-BRhKFmUn.mjs → node_modules/.pnpm/jiti@2.4.2/node_modules/jiti/dist/babel.mjs} +41334 -58245
  37. package/dist/node_modules/.pnpm/jiti@2.4.2/node_modules/jiti/dist/babel.mjs.map +1 -0
  38. package/dist/node_modules/.pnpm/jiti@2.4.2/node_modules/jiti/dist/jiti.cjs +4387 -0
  39. package/dist/node_modules/.pnpm/jiti@2.4.2/node_modules/jiti/dist/jiti.mjs +4385 -0
  40. package/dist/node_modules/.pnpm/jiti@2.4.2/node_modules/jiti/dist/jiti.mjs.map +1 -0
  41. package/dist/node_modules/.pnpm/jiti@2.4.2/node_modules/jiti/lib/jiti.cjs +26 -0
  42. package/dist/node_modules/.pnpm/jiti@2.4.2/node_modules/jiti/lib/jiti.mjs +27 -0
  43. package/dist/node_modules/.pnpm/jiti@2.4.2/node_modules/jiti/lib/jiti.mjs.map +1 -0
  44. package/dist/node_modules/.pnpm/lodash.deburr@4.1.0/node_modules/lodash.deburr/index.cjs +370 -0
  45. package/dist/node_modules/.pnpm/lodash.deburr@4.1.0/node_modules/lodash.deburr/index.mjs +368 -0
  46. package/dist/node_modules/.pnpm/lodash.deburr@4.1.0/node_modules/lodash.deburr/index.mjs.map +1 -0
  47. package/dist/node_modules/.pnpm/magic-string@0.30.21/node_modules/magic-string/dist/magic-string.es.cjs +939 -0
  48. package/dist/node_modules/.pnpm/magic-string@0.30.21/node_modules/magic-string/dist/magic-string.es.mjs +940 -0
  49. package/dist/node_modules/.pnpm/magic-string@0.30.21/node_modules/magic-string/dist/magic-string.es.mjs.map +1 -0
  50. package/dist/node_modules/.pnpm/mdbox@0.1.1/node_modules/mdbox/dist/index.cjs +67 -0
  51. package/dist/node_modules/.pnpm/mdbox@0.1.1/node_modules/mdbox/dist/index.mjs +65 -0
  52. package/dist/node_modules/.pnpm/mdbox@0.1.1/node_modules/mdbox/dist/index.mjs.map +1 -0
  53. package/dist/node_modules/.pnpm/mlly@1.8.0/node_modules/mlly/dist/index.cjs +1292 -0
  54. package/dist/node_modules/.pnpm/mlly@1.8.0/node_modules/mlly/dist/index.mjs +1285 -0
  55. package/dist/node_modules/.pnpm/mlly@1.8.0/node_modules/mlly/dist/index.mjs.map +1 -0
  56. package/dist/{multipart-parser-C_EjwsED.cjs → node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/chunks/multipart-parser.cjs} +2 -1
  57. package/dist/{multipart-parser-Dtmz_axo.mjs → node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/chunks/multipart-parser.mjs} +3 -2
  58. package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/chunks/multipart-parser.mjs.map +1 -0
  59. package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/index.cjs +20 -0
  60. package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/index.mjs +17 -0
  61. package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/index.mjs.map +1 -0
  62. package/dist/{node-DapIDpAC.cjs → node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/node.cjs} +808 -857
  63. package/dist/{node-FGT1CWpL.mjs → node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/node.mjs} +794 -806
  64. package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/node.mjs.map +1 -0
  65. package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/shared/node-fetch-native.DfbY2q-x.cjs +16 -0
  66. package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/shared/node-fetch-native.DfbY2q-x.mjs +15 -0
  67. package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/shared/node-fetch-native.DfbY2q-x.mjs.map +1 -0
  68. package/dist/node_modules/.pnpm/ofetch@1.5.1/node_modules/ofetch/dist/node.cjs +36 -0
  69. package/dist/node_modules/.pnpm/ofetch@1.5.1/node_modules/ofetch/dist/node.mjs +34 -0
  70. package/dist/node_modules/.pnpm/ofetch@1.5.1/node_modules/ofetch/dist/node.mjs.map +1 -0
  71. package/dist/{node-CsMhpAoX.cjs → node_modules/.pnpm/ofetch@1.5.1/node_modules/ofetch/dist/shared/ofetch.CWycOUEr.cjs} +24 -66
  72. package/dist/{node-D8lz5B3d.mjs → node_modules/.pnpm/ofetch@1.5.1/node_modules/ofetch/dist/shared/ofetch.CWycOUEr.mjs} +20 -59
  73. package/dist/node_modules/.pnpm/ofetch@1.5.1/node_modules/ofetch/dist/shared/ofetch.CWycOUEr.mjs.map +1 -0
  74. package/dist/node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/shared/pathe.M-eThtNZ.cjs +139 -0
  75. package/dist/node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/shared/pathe.M-eThtNZ.mjs +134 -0
  76. package/dist/node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/shared/pathe.M-eThtNZ.mjs.map +1 -0
  77. package/dist/node_modules/.pnpm/pkg-types@2.3.0/node_modules/pkg-types/dist/index.cjs +77 -0
  78. package/dist/node_modules/.pnpm/pkg-types@2.3.0/node_modules/pkg-types/dist/index.mjs +77 -0
  79. package/dist/node_modules/.pnpm/pkg-types@2.3.0/node_modules/pkg-types/dist/index.mjs.map +1 -0
  80. package/dist/{dist-PRh64A_O.mjs → node_modules/.pnpm/scule@1.3.0/node_modules/scule/dist/index.cjs} +4 -2
  81. package/dist/{dist-DVv98dZY.cjs → node_modules/.pnpm/scule@1.3.0/node_modules/scule/dist/index.mjs} +2 -19
  82. package/dist/node_modules/.pnpm/scule@1.3.0/node_modules/scule/dist/index.mjs.map +1 -0
  83. package/dist/{dist-Jfd0GR_C.mjs → node_modules/.pnpm/ufo@1.6.3/node_modules/ufo/dist/index.cjs} +4 -46
  84. package/dist/{dist-8g8frrZv.cjs → node_modules/.pnpm/ufo@1.6.3/node_modules/ufo/dist/index.mjs} +2 -69
  85. package/dist/node_modules/.pnpm/ufo@1.6.3/node_modules/ufo/dist/index.mjs.map +1 -0
  86. package/dist/node_modules/.pnpm/untyped@2.0.0/node_modules/untyped/dist/loader/babel.cjs +12337 -0
  87. package/dist/node_modules/.pnpm/untyped@2.0.0/node_modules/untyped/dist/loader/babel.mjs +12338 -0
  88. package/dist/node_modules/.pnpm/untyped@2.0.0/node_modules/untyped/dist/loader/babel.mjs.map +1 -0
  89. package/dist/node_modules/.pnpm/untyped@2.0.0/node_modules/untyped/dist/loader/loader.cjs +19 -0
  90. package/dist/node_modules/.pnpm/untyped@2.0.0/node_modules/untyped/dist/loader/loader.mjs +19 -0
  91. package/dist/node_modules/.pnpm/untyped@2.0.0/node_modules/untyped/dist/loader/loader.mjs.map +1 -0
  92. package/dist/node_modules/.pnpm/untyped@2.0.0/node_modules/untyped/dist/shared/untyped.BTwOq8Jl.cjs +71 -0
  93. package/dist/node_modules/.pnpm/untyped@2.0.0/node_modules/untyped/dist/shared/untyped.BTwOq8Jl.mjs +72 -0
  94. package/dist/node_modules/.pnpm/untyped@2.0.0/node_modules/untyped/dist/shared/untyped.BTwOq8Jl.mjs.map +1 -0
  95. package/dist/node_modules/.pnpm/untyped@2.0.0/node_modules/untyped/dist/shared/untyped.Br_uXjZG.cjs +110 -0
  96. package/dist/node_modules/.pnpm/untyped@2.0.0/node_modules/untyped/dist/shared/untyped.Br_uXjZG.mjs +101 -0
  97. package/dist/node_modules/.pnpm/untyped@2.0.0/node_modules/untyped/dist/shared/untyped.Br_uXjZG.mjs.map +1 -0
  98. package/dist/types/index.cjs +0 -3
  99. package/dist/types/index.d.cts +2 -3
  100. package/dist/types/index.d.mts +2 -3
  101. package/dist/types/index.mjs +0 -4
  102. package/dist/types/plugin.cjs +0 -1
  103. package/dist/types/plugin.d.cts +52 -3
  104. package/dist/types/plugin.d.cts.map +1 -0
  105. package/dist/types/plugin.d.mts +52 -3
  106. package/dist/types/plugin.d.mts.map +1 -0
  107. package/dist/types/plugin.mjs +0 -2
  108. package/dist/types/toc.cjs +0 -1
  109. package/dist/types/toc.d.cts +35 -2
  110. package/dist/types/toc.d.cts.map +1 -0
  111. package/dist/types/toc.d.mts +35 -2
  112. package/dist/types/toc.d.mts.map +1 -0
  113. package/dist/types/toc.mjs +0 -2
  114. package/package.json +4 -4
  115. package/dist/dist-BavrV299.cjs +0 -682
  116. package/dist/dist-Jfd0GR_C.mjs.map +0 -1
  117. package/dist/dist-PRh64A_O.mjs.map +0 -1
  118. package/dist/dist-PXnBmevt.mjs +0 -681
  119. package/dist/dist-PXnBmevt.mjs.map +0 -1
  120. package/dist/index-B8OHl-c_.d.mts +0 -1
  121. package/dist/index-CmCelmEL.d.cts +0 -1
  122. package/dist/loader-BRhKFmUn.mjs.map +0 -1
  123. package/dist/multipart-parser-Dtmz_axo.mjs.map +0 -1
  124. package/dist/node-D8lz5B3d.mjs.map +0 -1
  125. package/dist/node-FGT1CWpL.mjs.map +0 -1
  126. package/dist/plugin-BVD0UMjp.d.cts +0 -52
  127. package/dist/plugin-BVD0UMjp.d.cts.map +0 -1
  128. package/dist/plugin-C6jB5e_j.d.mts +0 -52
  129. package/dist/plugin-C6jB5e_j.d.mts.map +0 -1
  130. package/dist/plugin-Ckx8qAq8.cjs +0 -0
  131. package/dist/plugin-jZ9N9Mz-.mjs +0 -1
  132. package/dist/toc-BN2Ji9Yo.d.mts +0 -35
  133. package/dist/toc-BN2Ji9Yo.d.mts.map +0 -1
  134. package/dist/toc-BQgoCyR1.cjs +0 -0
  135. package/dist/toc-BrayIFG6.d.cts +0 -35
  136. package/dist/toc-BrayIFG6.d.cts.map +0 -1
  137. package/dist/toc-CBjybXug.mjs +0 -1
  138. package/dist/types--fVOUYBq.mjs +0 -1
  139. package/dist/types-D208vOSb.cjs +0 -0
@@ -0,0 +1,1292 @@
1
+ const require_rolldown_runtime = require('../../../../../../_virtual/rolldown_runtime.cjs');
2
+ const require_pathe_M_eThtNZ = require('../../../../pathe@2.0.3/node_modules/pathe/dist/shared/pathe.M-eThtNZ.cjs');
3
+ const require_acorn = require('../../../../acorn@8.15.0/node_modules/acorn/dist/acorn.cjs');
4
+ const require_index = require('../../../../ufo@1.6.3/node_modules/ufo/dist/index.cjs');
5
+ let node_fs = require("node:fs");
6
+ node_fs = require_rolldown_runtime.__toESM(node_fs);
7
+ let node_module = require("node:module");
8
+ let node_url = require("node:url");
9
+ let node_assert = require("node:assert");
10
+ node_assert = require_rolldown_runtime.__toESM(node_assert);
11
+ let node_process = require("node:process");
12
+ node_process = require_rolldown_runtime.__toESM(node_process);
13
+ let node_path = require("node:path");
14
+ node_path = require_rolldown_runtime.__toESM(node_path);
15
+ let node_v8 = require("node:v8");
16
+ node_v8 = require_rolldown_runtime.__toESM(node_v8);
17
+ let node_util = require("node:util");
18
+
19
+ //#region ../../node_modules/.pnpm/mlly@1.8.0/node_modules/mlly/dist/index.mjs
20
+ const BUILTIN_MODULES = new Set(node_module.builtinModules);
21
+ function normalizeSlash(path$1) {
22
+ return path$1.replace(/\\/g, "/");
23
+ }
24
+ function matchAll(regex, string, addition) {
25
+ const matches = [];
26
+ for (const match of string.matchAll(regex)) matches.push({
27
+ ...addition,
28
+ ...match.groups,
29
+ code: match[0],
30
+ start: match.index,
31
+ end: (match.index || 0) + match[0].length
32
+ });
33
+ return matches;
34
+ }
35
+ /**
36
+ * @typedef ErrnoExceptionFields
37
+ * @property {number | undefined} [errnode]
38
+ * @property {string | undefined} [code]
39
+ * @property {string | undefined} [path]
40
+ * @property {string | undefined} [syscall]
41
+ * @property {string | undefined} [url]
42
+ *
43
+ * @typedef {Error & ErrnoExceptionFields} ErrnoException
44
+ */
45
+ const own$1 = {}.hasOwnProperty;
46
+ const classRegExp = /^([A-Z][a-z\d]*)+$/;
47
+ const kTypes = new Set([
48
+ "string",
49
+ "function",
50
+ "number",
51
+ "object",
52
+ "Function",
53
+ "Object",
54
+ "boolean",
55
+ "bigint",
56
+ "symbol"
57
+ ]);
58
+ const codes = {};
59
+ /**
60
+ * Create a list string in the form like 'A and B' or 'A, B, ..., and Z'.
61
+ * We cannot use Intl.ListFormat because it's not available in
62
+ * --without-intl builds.
63
+ *
64
+ * @param {Array<string>} array
65
+ * An array of strings.
66
+ * @param {string} [type]
67
+ * The list type to be inserted before the last element.
68
+ * @returns {string}
69
+ */
70
+ function formatList(array, type = "and") {
71
+ return array.length < 3 ? array.join(` ${type} `) : `${array.slice(0, -1).join(", ")}, ${type} ${array[array.length - 1]}`;
72
+ }
73
+ /** @type {Map<string, MessageFunction | string>} */
74
+ const messages = /* @__PURE__ */ new Map();
75
+ const nodeInternalPrefix = "__node_internal_";
76
+ /** @type {number} */
77
+ let userStackTraceLimit;
78
+ codes.ERR_INVALID_ARG_TYPE = createError(
79
+ "ERR_INVALID_ARG_TYPE",
80
+ /**
81
+ * @param {string} name
82
+ * @param {Array<string> | string} expected
83
+ * @param {unknown} actual
84
+ */
85
+ (name, expected, actual) => {
86
+ (0, node_assert.default)(typeof name === "string", "'name' must be a string");
87
+ if (!Array.isArray(expected)) expected = [expected];
88
+ let message = "The ";
89
+ if (name.endsWith(" argument")) message += `${name} `;
90
+ else {
91
+ const type = name.includes(".") ? "property" : "argument";
92
+ message += `"${name}" ${type} `;
93
+ }
94
+ message += "must be ";
95
+ /** @type {Array<string>} */
96
+ const types = [];
97
+ /** @type {Array<string>} */
98
+ const instances = [];
99
+ /** @type {Array<string>} */
100
+ const other = [];
101
+ for (const value of expected) {
102
+ (0, node_assert.default)(typeof value === "string", "All expected entries have to be of type string");
103
+ if (kTypes.has(value)) types.push(value.toLowerCase());
104
+ else if (classRegExp.exec(value) === null) {
105
+ (0, node_assert.default)(value !== "object", "The value \"object\" should be written as \"Object\"");
106
+ other.push(value);
107
+ } else instances.push(value);
108
+ }
109
+ if (instances.length > 0) {
110
+ const pos = types.indexOf("object");
111
+ if (pos !== -1) {
112
+ types.slice(pos, 1);
113
+ instances.push("Object");
114
+ }
115
+ }
116
+ if (types.length > 0) {
117
+ message += `${types.length > 1 ? "one of type" : "of type"} ${formatList(types, "or")}`;
118
+ if (instances.length > 0 || other.length > 0) message += " or ";
119
+ }
120
+ if (instances.length > 0) {
121
+ message += `an instance of ${formatList(instances, "or")}`;
122
+ if (other.length > 0) message += " or ";
123
+ }
124
+ if (other.length > 0) if (other.length > 1) message += `one of ${formatList(other, "or")}`;
125
+ else {
126
+ if (other[0].toLowerCase() !== other[0]) message += "an ";
127
+ message += `${other[0]}`;
128
+ }
129
+ message += `. Received ${determineSpecificType(actual)}`;
130
+ return message;
131
+ },
132
+ TypeError
133
+ );
134
+ codes.ERR_INVALID_MODULE_SPECIFIER = createError(
135
+ "ERR_INVALID_MODULE_SPECIFIER",
136
+ /**
137
+ * @param {string} request
138
+ * @param {string} reason
139
+ * @param {string} [base]
140
+ */
141
+ (request, reason, base = void 0) => {
142
+ return `Invalid module "${request}" ${reason}${base ? ` imported from ${base}` : ""}`;
143
+ },
144
+ TypeError
145
+ );
146
+ codes.ERR_INVALID_PACKAGE_CONFIG = createError(
147
+ "ERR_INVALID_PACKAGE_CONFIG",
148
+ /**
149
+ * @param {string} path
150
+ * @param {string} [base]
151
+ * @param {string} [message]
152
+ */
153
+ (path$1, base, message) => {
154
+ return `Invalid package config ${path$1}${base ? ` while importing ${base}` : ""}${message ? `. ${message}` : ""}`;
155
+ },
156
+ Error
157
+ );
158
+ codes.ERR_INVALID_PACKAGE_TARGET = createError(
159
+ "ERR_INVALID_PACKAGE_TARGET",
160
+ /**
161
+ * @param {string} packagePath
162
+ * @param {string} key
163
+ * @param {unknown} target
164
+ * @param {boolean} [isImport=false]
165
+ * @param {string} [base]
166
+ */
167
+ (packagePath, key, target, isImport = false, base = void 0) => {
168
+ const relatedError = typeof target === "string" && !isImport && target.length > 0 && !target.startsWith("./");
169
+ if (key === ".") {
170
+ (0, node_assert.default)(isImport === false);
171
+ 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 \"./\"" : ""}`;
172
+ }
173
+ 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 \"./\"" : ""}`;
174
+ },
175
+ Error
176
+ );
177
+ codes.ERR_MODULE_NOT_FOUND = createError(
178
+ "ERR_MODULE_NOT_FOUND",
179
+ /**
180
+ * @param {string} path
181
+ * @param {string} base
182
+ * @param {boolean} [exactUrl]
183
+ */
184
+ (path$1, base, exactUrl = false) => {
185
+ return `Cannot find ${exactUrl ? "module" : "package"} '${path$1}' imported from ${base}`;
186
+ },
187
+ Error
188
+ );
189
+ codes.ERR_NETWORK_IMPORT_DISALLOWED = createError("ERR_NETWORK_IMPORT_DISALLOWED", "import of '%s' by %s is not supported: %s", Error);
190
+ codes.ERR_PACKAGE_IMPORT_NOT_DEFINED = createError(
191
+ "ERR_PACKAGE_IMPORT_NOT_DEFINED",
192
+ /**
193
+ * @param {string} specifier
194
+ * @param {string} packagePath
195
+ * @param {string} base
196
+ */
197
+ (specifier, packagePath, base) => {
198
+ return `Package import specifier "${specifier}" is not defined${packagePath ? ` in package ${packagePath}package.json` : ""} imported from ${base}`;
199
+ },
200
+ TypeError
201
+ );
202
+ codes.ERR_PACKAGE_PATH_NOT_EXPORTED = createError(
203
+ "ERR_PACKAGE_PATH_NOT_EXPORTED",
204
+ /**
205
+ * @param {string} packagePath
206
+ * @param {string} subpath
207
+ * @param {string} [base]
208
+ */
209
+ (packagePath, subpath, base = void 0) => {
210
+ if (subpath === ".") return `No "exports" main defined in ${packagePath}package.json${base ? ` imported from ${base}` : ""}`;
211
+ return `Package subpath '${subpath}' is not defined by "exports" in ${packagePath}package.json${base ? ` imported from ${base}` : ""}`;
212
+ },
213
+ Error
214
+ );
215
+ codes.ERR_UNSUPPORTED_DIR_IMPORT = createError("ERR_UNSUPPORTED_DIR_IMPORT", "Directory import '%s' is not supported resolving ES modules imported from %s", Error);
216
+ codes.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);
217
+ codes.ERR_UNKNOWN_FILE_EXTENSION = createError(
218
+ "ERR_UNKNOWN_FILE_EXTENSION",
219
+ /**
220
+ * @param {string} extension
221
+ * @param {string} path
222
+ */
223
+ (extension, path$1) => {
224
+ return `Unknown file extension "${extension}" for ${path$1}`;
225
+ },
226
+ TypeError
227
+ );
228
+ codes.ERR_INVALID_ARG_VALUE = createError(
229
+ "ERR_INVALID_ARG_VALUE",
230
+ /**
231
+ * @param {string} name
232
+ * @param {unknown} value
233
+ * @param {string} [reason='is invalid']
234
+ */
235
+ (name, value, reason = "is invalid") => {
236
+ let inspected = (0, node_util.inspect)(value);
237
+ if (inspected.length > 128) inspected = `${inspected.slice(0, 128)}...`;
238
+ return `The ${name.includes(".") ? "property" : "argument"} '${name}' ${reason}. Received ${inspected}`;
239
+ },
240
+ TypeError
241
+ );
242
+ /**
243
+ * Utility function for registering the error codes. Only used here. Exported
244
+ * *only* to allow for testing.
245
+ * @param {string} sym
246
+ * @param {MessageFunction | string} value
247
+ * @param {ErrorConstructor} constructor
248
+ * @returns {new (...parameters: Array<any>) => Error}
249
+ */
250
+ function createError(sym, value, constructor) {
251
+ messages.set(sym, value);
252
+ return makeNodeErrorWithCode(constructor, sym);
253
+ }
254
+ /**
255
+ * @param {ErrorConstructor} Base
256
+ * @param {string} key
257
+ * @returns {ErrorConstructor}
258
+ */
259
+ function makeNodeErrorWithCode(Base, key) {
260
+ return NodeError;
261
+ /**
262
+ * @param {Array<unknown>} parameters
263
+ */
264
+ function NodeError(...parameters) {
265
+ const limit = Error.stackTraceLimit;
266
+ if (isErrorStackTraceLimitWritable()) Error.stackTraceLimit = 0;
267
+ const error = new Base();
268
+ if (isErrorStackTraceLimitWritable()) Error.stackTraceLimit = limit;
269
+ const message = getMessage(key, parameters, error);
270
+ Object.defineProperties(error, {
271
+ message: {
272
+ value: message,
273
+ enumerable: false,
274
+ writable: true,
275
+ configurable: true
276
+ },
277
+ toString: {
278
+ value() {
279
+ return `${this.name} [${key}]: ${this.message}`;
280
+ },
281
+ enumerable: false,
282
+ writable: true,
283
+ configurable: true
284
+ }
285
+ });
286
+ captureLargerStackTrace(error);
287
+ error.code = key;
288
+ return error;
289
+ }
290
+ }
291
+ /**
292
+ * @returns {boolean}
293
+ */
294
+ function isErrorStackTraceLimitWritable() {
295
+ try {
296
+ if (node_v8.default.startupSnapshot.isBuildingSnapshot()) return false;
297
+ } catch {}
298
+ const desc = Object.getOwnPropertyDescriptor(Error, "stackTraceLimit");
299
+ if (desc === void 0) return Object.isExtensible(Error);
300
+ return own$1.call(desc, "writable") && desc.writable !== void 0 ? desc.writable : desc.set !== void 0;
301
+ }
302
+ /**
303
+ * This function removes unnecessary frames from Node.js core errors.
304
+ * @template {(...parameters: unknown[]) => unknown} T
305
+ * @param {T} wrappedFunction
306
+ * @returns {T}
307
+ */
308
+ function hideStackFrames(wrappedFunction) {
309
+ const hidden = nodeInternalPrefix + wrappedFunction.name;
310
+ Object.defineProperty(wrappedFunction, "name", { value: hidden });
311
+ return wrappedFunction;
312
+ }
313
+ const captureLargerStackTrace = hideStackFrames(
314
+ /**
315
+ * @param {Error} error
316
+ * @returns {Error}
317
+ */
318
+ function(error) {
319
+ const stackTraceLimitIsWritable = isErrorStackTraceLimitWritable();
320
+ if (stackTraceLimitIsWritable) {
321
+ userStackTraceLimit = Error.stackTraceLimit;
322
+ Error.stackTraceLimit = Number.POSITIVE_INFINITY;
323
+ }
324
+ Error.captureStackTrace(error);
325
+ if (stackTraceLimitIsWritable) Error.stackTraceLimit = userStackTraceLimit;
326
+ return error;
327
+ }
328
+ );
329
+ /**
330
+ * @param {string} key
331
+ * @param {Array<unknown>} parameters
332
+ * @param {Error} self
333
+ * @returns {string}
334
+ */
335
+ function getMessage(key, parameters, self) {
336
+ const message = messages.get(key);
337
+ (0, node_assert.default)(message !== void 0, "expected `message` to be found");
338
+ if (typeof message === "function") {
339
+ (0, node_assert.default)(message.length <= parameters.length, `Code: ${key}; The provided arguments length (${parameters.length}) does not match the required ones (${message.length}).`);
340
+ return Reflect.apply(message, self, parameters);
341
+ }
342
+ const regex = /%[dfijoOs]/g;
343
+ let expectedLength = 0;
344
+ while (regex.exec(message) !== null) expectedLength++;
345
+ (0, node_assert.default)(expectedLength === parameters.length, `Code: ${key}; The provided arguments length (${parameters.length}) does not match the required ones (${expectedLength}).`);
346
+ if (parameters.length === 0) return message;
347
+ parameters.unshift(message);
348
+ return Reflect.apply(node_util.format, null, parameters);
349
+ }
350
+ /**
351
+ * Determine the specific type of a value for type-mismatch errors.
352
+ * @param {unknown} value
353
+ * @returns {string}
354
+ */
355
+ function determineSpecificType(value) {
356
+ if (value === null || value === void 0) return String(value);
357
+ if (typeof value === "function" && value.name) return `function ${value.name}`;
358
+ if (typeof value === "object") {
359
+ if (value.constructor && value.constructor.name) return `an instance of ${value.constructor.name}`;
360
+ return `${(0, node_util.inspect)(value, { depth: -1 })}`;
361
+ }
362
+ let inspected = (0, node_util.inspect)(value, { colors: false });
363
+ if (inspected.length > 28) inspected = `${inspected.slice(0, 25)}...`;
364
+ return `type ${typeof value} (${inspected})`;
365
+ }
366
+ const hasOwnProperty$1 = {}.hasOwnProperty;
367
+ const { ERR_INVALID_PACKAGE_CONFIG: ERR_INVALID_PACKAGE_CONFIG$1 } = codes;
368
+ /** @type {Map<string, PackageConfig>} */
369
+ const cache = /* @__PURE__ */ new Map();
370
+ /**
371
+ * @param {string} jsonPath
372
+ * @param {{specifier: URL | string, base?: URL}} options
373
+ * @returns {PackageConfig}
374
+ */
375
+ function read(jsonPath, { base, specifier }) {
376
+ const existing = cache.get(jsonPath);
377
+ if (existing) return existing;
378
+ /** @type {string | undefined} */
379
+ let string;
380
+ try {
381
+ string = node_fs.default.readFileSync(node_path.default.toNamespacedPath(jsonPath), "utf8");
382
+ } catch (error) {
383
+ const exception = error;
384
+ if (exception.code !== "ENOENT") throw exception;
385
+ }
386
+ /** @type {PackageConfig} */
387
+ const result = {
388
+ exists: false,
389
+ pjsonPath: jsonPath,
390
+ main: void 0,
391
+ name: void 0,
392
+ type: "none",
393
+ exports: void 0,
394
+ imports: void 0
395
+ };
396
+ if (string !== void 0) {
397
+ /** @type {Record<string, unknown>} */
398
+ let parsed;
399
+ try {
400
+ parsed = JSON.parse(string);
401
+ } catch (error_) {
402
+ const cause = error_;
403
+ const error = new ERR_INVALID_PACKAGE_CONFIG$1(jsonPath, (base ? `"${specifier}" from ` : "") + (0, node_url.fileURLToPath)(base || specifier), cause.message);
404
+ error.cause = cause;
405
+ throw error;
406
+ }
407
+ result.exists = true;
408
+ if (hasOwnProperty$1.call(parsed, "name") && typeof parsed.name === "string") result.name = parsed.name;
409
+ if (hasOwnProperty$1.call(parsed, "main") && typeof parsed.main === "string") result.main = parsed.main;
410
+ if (hasOwnProperty$1.call(parsed, "exports")) result.exports = parsed.exports;
411
+ if (hasOwnProperty$1.call(parsed, "imports")) result.imports = parsed.imports;
412
+ if (hasOwnProperty$1.call(parsed, "type") && (parsed.type === "commonjs" || parsed.type === "module")) result.type = parsed.type;
413
+ }
414
+ cache.set(jsonPath, result);
415
+ return result;
416
+ }
417
+ /**
418
+ * @param {URL | string} resolved
419
+ * @returns {PackageConfig}
420
+ */
421
+ function getPackageScopeConfig(resolved) {
422
+ let packageJSONUrl = new URL("package.json", resolved);
423
+ while (true) {
424
+ if (packageJSONUrl.pathname.endsWith("node_modules/package.json")) break;
425
+ const packageConfig = read((0, node_url.fileURLToPath)(packageJSONUrl), { specifier: resolved });
426
+ if (packageConfig.exists) return packageConfig;
427
+ const lastPackageJSONUrl = packageJSONUrl;
428
+ packageJSONUrl = new URL("../package.json", packageJSONUrl);
429
+ if (packageJSONUrl.pathname === lastPackageJSONUrl.pathname) break;
430
+ }
431
+ return {
432
+ pjsonPath: (0, node_url.fileURLToPath)(packageJSONUrl),
433
+ exists: false,
434
+ type: "none"
435
+ };
436
+ }
437
+ /**
438
+ * Returns the package type for a given URL.
439
+ * @param {URL} url - The URL to get the package type for.
440
+ * @returns {PackageType}
441
+ */
442
+ function getPackageType(url) {
443
+ return getPackageScopeConfig(url).type;
444
+ }
445
+ const { ERR_UNKNOWN_FILE_EXTENSION } = codes;
446
+ const hasOwnProperty = {}.hasOwnProperty;
447
+ /** @type {Record<string, string>} */
448
+ const extensionFormatMap = {
449
+ __proto__: null,
450
+ ".cjs": "commonjs",
451
+ ".js": "module",
452
+ ".json": "json",
453
+ ".mjs": "module"
454
+ };
455
+ /**
456
+ * @param {string | null} mime
457
+ * @returns {string | null}
458
+ */
459
+ function mimeToFormat(mime) {
460
+ if (mime && /\s*(text|application)\/javascript\s*(;\s*charset=utf-?8\s*)?/i.test(mime)) return "module";
461
+ if (mime === "application/json") return "json";
462
+ return null;
463
+ }
464
+ /**
465
+ * @callback ProtocolHandler
466
+ * @param {URL} parsed
467
+ * @param {{parentURL: string, source?: Buffer}} context
468
+ * @param {boolean} ignoreErrors
469
+ * @returns {string | null | void}
470
+ */
471
+ /**
472
+ * @type {Record<string, ProtocolHandler>}
473
+ */
474
+ const protocolHandlers = {
475
+ __proto__: null,
476
+ "data:": getDataProtocolModuleFormat,
477
+ "file:": getFileProtocolModuleFormat,
478
+ "http:": getHttpProtocolModuleFormat,
479
+ "https:": getHttpProtocolModuleFormat,
480
+ "node:"() {
481
+ return "builtin";
482
+ }
483
+ };
484
+ /**
485
+ * @param {URL} parsed
486
+ */
487
+ function getDataProtocolModuleFormat(parsed) {
488
+ const { 1: mime } = /^([^/]+\/[^;,]+)[^,]*?(;base64)?,/.exec(parsed.pathname) || [
489
+ null,
490
+ null,
491
+ null
492
+ ];
493
+ return mimeToFormat(mime);
494
+ }
495
+ /**
496
+ * Returns the file extension from a URL.
497
+ *
498
+ * Should give similar result to
499
+ * `require('node:path').extname(require('node:url').fileURLToPath(url))`
500
+ * when used with a `file:` URL.
501
+ *
502
+ * @param {URL} url
503
+ * @returns {string}
504
+ */
505
+ function extname$1(url) {
506
+ const pathname = url.pathname;
507
+ let index = pathname.length;
508
+ while (index--) {
509
+ const code = pathname.codePointAt(index);
510
+ if (code === 47) return "";
511
+ if (code === 46) return pathname.codePointAt(index - 1) === 47 ? "" : pathname.slice(index);
512
+ }
513
+ return "";
514
+ }
515
+ /**
516
+ * @type {ProtocolHandler}
517
+ */
518
+ function getFileProtocolModuleFormat(url, _context, ignoreErrors) {
519
+ const value = extname$1(url);
520
+ if (value === ".js") {
521
+ const packageType = getPackageType(url);
522
+ if (packageType !== "none") return packageType;
523
+ return "commonjs";
524
+ }
525
+ if (value === "") {
526
+ const packageType = getPackageType(url);
527
+ if (packageType === "none" || packageType === "commonjs") return "commonjs";
528
+ return "module";
529
+ }
530
+ const format$1 = extensionFormatMap[value];
531
+ if (format$1) return format$1;
532
+ if (ignoreErrors) return;
533
+ throw new ERR_UNKNOWN_FILE_EXTENSION(value, (0, node_url.fileURLToPath)(url));
534
+ }
535
+ function getHttpProtocolModuleFormat() {}
536
+ /**
537
+ * @param {URL} url
538
+ * @param {{parentURL: string}} context
539
+ * @returns {string | null}
540
+ */
541
+ function defaultGetFormatWithoutErrors(url, context) {
542
+ const protocol = url.protocol;
543
+ if (!hasOwnProperty.call(protocolHandlers, protocol)) return null;
544
+ return protocolHandlers[protocol](url, context, true) || null;
545
+ }
546
+ const RegExpPrototypeSymbolReplace = RegExp.prototype[Symbol.replace];
547
+ const { ERR_INVALID_MODULE_SPECIFIER, ERR_INVALID_PACKAGE_CONFIG, ERR_INVALID_PACKAGE_TARGET, ERR_MODULE_NOT_FOUND, ERR_PACKAGE_IMPORT_NOT_DEFINED, ERR_PACKAGE_PATH_NOT_EXPORTED, ERR_UNSUPPORTED_DIR_IMPORT, ERR_UNSUPPORTED_RESOLVE_REQUEST } = codes;
548
+ const own = {}.hasOwnProperty;
549
+ 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;
550
+ 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;
551
+ const invalidPackageNameRegEx = /^\.|%|\\/;
552
+ const patternRegEx = /\*/g;
553
+ const encodedSeparatorRegEx = /%2f|%5c/i;
554
+ /** @type {Set<string>} */
555
+ const emittedPackageWarnings = /* @__PURE__ */ new Set();
556
+ const doubleSlashRegEx = /[/\\]{2}/;
557
+ /**
558
+ *
559
+ * @param {string} target
560
+ * @param {string} request
561
+ * @param {string} match
562
+ * @param {URL} packageJsonUrl
563
+ * @param {boolean} internal
564
+ * @param {URL} base
565
+ * @param {boolean} isTarget
566
+ */
567
+ function emitInvalidSegmentDeprecation(target, request, match, packageJsonUrl, internal, base, isTarget) {
568
+ if (node_process.default.noDeprecation) return;
569
+ const pjsonPath = (0, node_url.fileURLToPath)(packageJsonUrl);
570
+ const double = doubleSlashRegEx.exec(isTarget ? target : request) !== null;
571
+ node_process.default.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 ${(0, node_url.fileURLToPath)(base)}` : ""}.`, "DeprecationWarning", "DEP0166");
572
+ }
573
+ /**
574
+ * @param {URL} url
575
+ * @param {URL} packageJsonUrl
576
+ * @param {URL} base
577
+ * @param {string} [main]
578
+ * @returns {void}
579
+ */
580
+ function emitLegacyIndexDeprecation(url, packageJsonUrl, base, main) {
581
+ if (node_process.default.noDeprecation) return;
582
+ if (defaultGetFormatWithoutErrors(url, { parentURL: base.href }) !== "module") return;
583
+ const urlPath = (0, node_url.fileURLToPath)(url.href);
584
+ const packagePath = (0, node_url.fileURLToPath)(new node_url.URL(".", packageJsonUrl));
585
+ const basePath = (0, node_url.fileURLToPath)(base);
586
+ if (!main) node_process.default.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");
587
+ else if (node_path.default.resolve(packagePath, main) !== urlPath) node_process.default.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");
588
+ }
589
+ /**
590
+ * @param {string} path
591
+ * @returns {Stats | undefined}
592
+ */
593
+ function tryStatSync(path$1) {
594
+ try {
595
+ return (0, node_fs.statSync)(path$1);
596
+ } catch {}
597
+ }
598
+ /**
599
+ * Legacy CommonJS main resolution:
600
+ * 1. let M = pkg_url + (json main field)
601
+ * 2. TRY(M, M.js, M.json, M.node)
602
+ * 3. TRY(M/index.js, M/index.json, M/index.node)
603
+ * 4. TRY(pkg_url/index.js, pkg_url/index.json, pkg_url/index.node)
604
+ * 5. NOT_FOUND
605
+ *
606
+ * @param {URL} url
607
+ * @returns {boolean}
608
+ */
609
+ function fileExists(url) {
610
+ const stats = (0, node_fs.statSync)(url, { throwIfNoEntry: false });
611
+ const isFile = stats ? stats.isFile() : void 0;
612
+ return isFile === null || isFile === void 0 ? false : isFile;
613
+ }
614
+ /**
615
+ * @param {URL} packageJsonUrl
616
+ * @param {PackageConfig} packageConfig
617
+ * @param {URL} base
618
+ * @returns {URL}
619
+ */
620
+ function legacyMainResolve(packageJsonUrl, packageConfig, base) {
621
+ /** @type {URL | undefined} */
622
+ let guess;
623
+ if (packageConfig.main !== void 0) {
624
+ guess = new node_url.URL(packageConfig.main, packageJsonUrl);
625
+ if (fileExists(guess)) return guess;
626
+ const tries$1 = [
627
+ `./${packageConfig.main}.js`,
628
+ `./${packageConfig.main}.json`,
629
+ `./${packageConfig.main}.node`,
630
+ `./${packageConfig.main}/index.js`,
631
+ `./${packageConfig.main}/index.json`,
632
+ `./${packageConfig.main}/index.node`
633
+ ];
634
+ let i$1 = -1;
635
+ while (++i$1 < tries$1.length) {
636
+ guess = new node_url.URL(tries$1[i$1], packageJsonUrl);
637
+ if (fileExists(guess)) break;
638
+ guess = void 0;
639
+ }
640
+ if (guess) {
641
+ emitLegacyIndexDeprecation(guess, packageJsonUrl, base, packageConfig.main);
642
+ return guess;
643
+ }
644
+ }
645
+ const tries = [
646
+ "./index.js",
647
+ "./index.json",
648
+ "./index.node"
649
+ ];
650
+ let i = -1;
651
+ while (++i < tries.length) {
652
+ guess = new node_url.URL(tries[i], packageJsonUrl);
653
+ if (fileExists(guess)) break;
654
+ guess = void 0;
655
+ }
656
+ if (guess) {
657
+ emitLegacyIndexDeprecation(guess, packageJsonUrl, base, packageConfig.main);
658
+ return guess;
659
+ }
660
+ throw new ERR_MODULE_NOT_FOUND((0, node_url.fileURLToPath)(new node_url.URL(".", packageJsonUrl)), (0, node_url.fileURLToPath)(base));
661
+ }
662
+ /**
663
+ * @param {URL} resolved
664
+ * @param {URL} base
665
+ * @param {boolean} [preserveSymlinks]
666
+ * @returns {URL}
667
+ */
668
+ function finalizeResolution(resolved, base, preserveSymlinks) {
669
+ if (encodedSeparatorRegEx.exec(resolved.pathname) !== null) throw new ERR_INVALID_MODULE_SPECIFIER(resolved.pathname, "must not include encoded \"/\" or \"\\\" characters", (0, node_url.fileURLToPath)(base));
670
+ /** @type {string} */
671
+ let filePath;
672
+ try {
673
+ filePath = (0, node_url.fileURLToPath)(resolved);
674
+ } catch (error) {
675
+ const cause = error;
676
+ Object.defineProperty(cause, "input", { value: String(resolved) });
677
+ Object.defineProperty(cause, "module", { value: String(base) });
678
+ throw cause;
679
+ }
680
+ const stats = tryStatSync(filePath.endsWith("/") ? filePath.slice(-1) : filePath);
681
+ if (stats && stats.isDirectory()) {
682
+ const error = new ERR_UNSUPPORTED_DIR_IMPORT(filePath, (0, node_url.fileURLToPath)(base));
683
+ error.url = String(resolved);
684
+ throw error;
685
+ }
686
+ if (!stats || !stats.isFile()) {
687
+ const error = new ERR_MODULE_NOT_FOUND(filePath || resolved.pathname, base && (0, node_url.fileURLToPath)(base), true);
688
+ error.url = String(resolved);
689
+ throw error;
690
+ }
691
+ {
692
+ const real = (0, node_fs.realpathSync)(filePath);
693
+ const { search, hash } = resolved;
694
+ resolved = (0, node_url.pathToFileURL)(real + (filePath.endsWith(node_path.default.sep) ? "/" : ""));
695
+ resolved.search = search;
696
+ resolved.hash = hash;
697
+ }
698
+ return resolved;
699
+ }
700
+ /**
701
+ * @param {string} specifier
702
+ * @param {URL | undefined} packageJsonUrl
703
+ * @param {URL} base
704
+ * @returns {Error}
705
+ */
706
+ function importNotDefined(specifier, packageJsonUrl, base) {
707
+ return new ERR_PACKAGE_IMPORT_NOT_DEFINED(specifier, packageJsonUrl && (0, node_url.fileURLToPath)(new node_url.URL(".", packageJsonUrl)), (0, node_url.fileURLToPath)(base));
708
+ }
709
+ /**
710
+ * @param {string} subpath
711
+ * @param {URL} packageJsonUrl
712
+ * @param {URL} base
713
+ * @returns {Error}
714
+ */
715
+ function exportsNotFound(subpath, packageJsonUrl, base) {
716
+ return new ERR_PACKAGE_PATH_NOT_EXPORTED((0, node_url.fileURLToPath)(new node_url.URL(".", packageJsonUrl)), subpath, base && (0, node_url.fileURLToPath)(base));
717
+ }
718
+ /**
719
+ * @param {string} request
720
+ * @param {string} match
721
+ * @param {URL} packageJsonUrl
722
+ * @param {boolean} internal
723
+ * @param {URL} [base]
724
+ * @returns {never}
725
+ */
726
+ function throwInvalidSubpath(request, match, packageJsonUrl, internal, base) {
727
+ throw new ERR_INVALID_MODULE_SPECIFIER(request, `request is not a valid match in pattern "${match}" for the "${internal ? "imports" : "exports"}" resolution of ${(0, node_url.fileURLToPath)(packageJsonUrl)}`, base && (0, node_url.fileURLToPath)(base));
728
+ }
729
+ /**
730
+ * @param {string} subpath
731
+ * @param {unknown} target
732
+ * @param {URL} packageJsonUrl
733
+ * @param {boolean} internal
734
+ * @param {URL} [base]
735
+ * @returns {Error}
736
+ */
737
+ function invalidPackageTarget(subpath, target, packageJsonUrl, internal, base) {
738
+ target = typeof target === "object" && target !== null ? JSON.stringify(target, null, "") : `${target}`;
739
+ return new ERR_INVALID_PACKAGE_TARGET((0, node_url.fileURLToPath)(new node_url.URL(".", packageJsonUrl)), subpath, target, internal, base && (0, node_url.fileURLToPath)(base));
740
+ }
741
+ /**
742
+ * @param {string} target
743
+ * @param {string} subpath
744
+ * @param {string} match
745
+ * @param {URL} packageJsonUrl
746
+ * @param {URL} base
747
+ * @param {boolean} pattern
748
+ * @param {boolean} internal
749
+ * @param {boolean} isPathMap
750
+ * @param {Set<string> | undefined} conditions
751
+ * @returns {URL}
752
+ */
753
+ function resolvePackageTargetString(target, subpath, match, packageJsonUrl, base, pattern, internal, isPathMap, conditions) {
754
+ if (subpath !== "" && !pattern && target[target.length - 1] !== "/") throw invalidPackageTarget(match, target, packageJsonUrl, internal, base);
755
+ if (!target.startsWith("./")) {
756
+ if (internal && !target.startsWith("../") && !target.startsWith("/")) {
757
+ let isURL = false;
758
+ try {
759
+ new node_url.URL(target);
760
+ isURL = true;
761
+ } catch {}
762
+ if (!isURL) return packageResolve(pattern ? RegExpPrototypeSymbolReplace.call(patternRegEx, target, () => subpath) : target + subpath, packageJsonUrl, conditions);
763
+ }
764
+ throw invalidPackageTarget(match, target, packageJsonUrl, internal, base);
765
+ }
766
+ if (invalidSegmentRegEx.exec(target.slice(2)) !== null) if (deprecatedInvalidSegmentRegEx.exec(target.slice(2)) === null) {
767
+ if (!isPathMap) {
768
+ const request = pattern ? match.replace("*", () => subpath) : match + subpath;
769
+ emitInvalidSegmentDeprecation(pattern ? RegExpPrototypeSymbolReplace.call(patternRegEx, target, () => subpath) : target, request, match, packageJsonUrl, internal, base, true);
770
+ }
771
+ } else throw invalidPackageTarget(match, target, packageJsonUrl, internal, base);
772
+ const resolved = new node_url.URL(target, packageJsonUrl);
773
+ const resolvedPath = resolved.pathname;
774
+ const packagePath = new node_url.URL(".", packageJsonUrl).pathname;
775
+ if (!resolvedPath.startsWith(packagePath)) throw invalidPackageTarget(match, target, packageJsonUrl, internal, base);
776
+ if (subpath === "") return resolved;
777
+ if (invalidSegmentRegEx.exec(subpath) !== null) {
778
+ const request = pattern ? match.replace("*", () => subpath) : match + subpath;
779
+ if (deprecatedInvalidSegmentRegEx.exec(subpath) === null) {
780
+ if (!isPathMap) emitInvalidSegmentDeprecation(pattern ? RegExpPrototypeSymbolReplace.call(patternRegEx, target, () => subpath) : target, request, match, packageJsonUrl, internal, base, false);
781
+ } else throwInvalidSubpath(request, match, packageJsonUrl, internal, base);
782
+ }
783
+ if (pattern) return new node_url.URL(RegExpPrototypeSymbolReplace.call(patternRegEx, resolved.href, () => subpath));
784
+ return new node_url.URL(subpath, resolved);
785
+ }
786
+ /**
787
+ * @param {string} key
788
+ * @returns {boolean}
789
+ */
790
+ function isArrayIndex(key) {
791
+ const keyNumber = Number(key);
792
+ if (`${keyNumber}` !== key) return false;
793
+ return keyNumber >= 0 && keyNumber < 4294967295;
794
+ }
795
+ /**
796
+ * @param {URL} packageJsonUrl
797
+ * @param {unknown} target
798
+ * @param {string} subpath
799
+ * @param {string} packageSubpath
800
+ * @param {URL} base
801
+ * @param {boolean} pattern
802
+ * @param {boolean} internal
803
+ * @param {boolean} isPathMap
804
+ * @param {Set<string> | undefined} conditions
805
+ * @returns {URL | null}
806
+ */
807
+ function resolvePackageTarget(packageJsonUrl, target, subpath, packageSubpath, base, pattern, internal, isPathMap, conditions) {
808
+ if (typeof target === "string") return resolvePackageTargetString(target, subpath, packageSubpath, packageJsonUrl, base, pattern, internal, isPathMap, conditions);
809
+ if (Array.isArray(target)) {
810
+ /** @type {Array<unknown>} */
811
+ const targetList = target;
812
+ if (targetList.length === 0) return null;
813
+ /** @type {ErrnoException | null | undefined} */
814
+ let lastException;
815
+ let i = -1;
816
+ while (++i < targetList.length) {
817
+ const targetItem = targetList[i];
818
+ /** @type {URL | null} */
819
+ let resolveResult;
820
+ try {
821
+ resolveResult = resolvePackageTarget(packageJsonUrl, targetItem, subpath, packageSubpath, base, pattern, internal, isPathMap, conditions);
822
+ } catch (error) {
823
+ const exception = error;
824
+ lastException = exception;
825
+ if (exception.code === "ERR_INVALID_PACKAGE_TARGET") continue;
826
+ throw error;
827
+ }
828
+ if (resolveResult === void 0) continue;
829
+ if (resolveResult === null) {
830
+ lastException = null;
831
+ continue;
832
+ }
833
+ return resolveResult;
834
+ }
835
+ if (lastException === void 0 || lastException === null) return null;
836
+ throw lastException;
837
+ }
838
+ if (typeof target === "object" && target !== null) {
839
+ const keys = Object.getOwnPropertyNames(target);
840
+ let i = -1;
841
+ while (++i < keys.length) {
842
+ const key = keys[i];
843
+ if (isArrayIndex(key)) throw new ERR_INVALID_PACKAGE_CONFIG((0, node_url.fileURLToPath)(packageJsonUrl), base, "\"exports\" cannot contain numeric property keys.");
844
+ }
845
+ i = -1;
846
+ while (++i < keys.length) {
847
+ const key = keys[i];
848
+ if (key === "default" || conditions && conditions.has(key)) {
849
+ const conditionalTarget = target[key];
850
+ const resolveResult = resolvePackageTarget(packageJsonUrl, conditionalTarget, subpath, packageSubpath, base, pattern, internal, isPathMap, conditions);
851
+ if (resolveResult === void 0) continue;
852
+ return resolveResult;
853
+ }
854
+ }
855
+ return null;
856
+ }
857
+ if (target === null) return null;
858
+ throw invalidPackageTarget(packageSubpath, target, packageJsonUrl, internal, base);
859
+ }
860
+ /**
861
+ * @param {unknown} exports
862
+ * @param {URL} packageJsonUrl
863
+ * @param {URL} base
864
+ * @returns {boolean}
865
+ */
866
+ function isConditionalExportsMainSugar(exports$1, packageJsonUrl, base) {
867
+ if (typeof exports$1 === "string" || Array.isArray(exports$1)) return true;
868
+ if (typeof exports$1 !== "object" || exports$1 === null) return false;
869
+ const keys = Object.getOwnPropertyNames(exports$1);
870
+ let isConditionalSugar = false;
871
+ let i = 0;
872
+ let keyIndex = -1;
873
+ while (++keyIndex < keys.length) {
874
+ const key = keys[keyIndex];
875
+ const currentIsConditionalSugar = key === "" || key[0] !== ".";
876
+ if (i++ === 0) isConditionalSugar = currentIsConditionalSugar;
877
+ else if (isConditionalSugar !== currentIsConditionalSugar) throw new ERR_INVALID_PACKAGE_CONFIG((0, node_url.fileURLToPath)(packageJsonUrl), 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.");
878
+ }
879
+ return isConditionalSugar;
880
+ }
881
+ /**
882
+ * @param {string} match
883
+ * @param {URL} pjsonUrl
884
+ * @param {URL} base
885
+ */
886
+ function emitTrailingSlashPatternDeprecation(match, pjsonUrl, base) {
887
+ if (node_process.default.noDeprecation) return;
888
+ const pjsonPath = (0, node_url.fileURLToPath)(pjsonUrl);
889
+ if (emittedPackageWarnings.has(pjsonPath + "|" + match)) return;
890
+ emittedPackageWarnings.add(pjsonPath + "|" + match);
891
+ node_process.default.emitWarning(`Use of deprecated trailing slash pattern mapping "${match}" in the "exports" field module resolution of the package at ${pjsonPath}${base ? ` imported from ${(0, node_url.fileURLToPath)(base)}` : ""}. Mapping specifiers ending in "/" is no longer supported.`, "DeprecationWarning", "DEP0155");
892
+ }
893
+ /**
894
+ * @param {URL} packageJsonUrl
895
+ * @param {string} packageSubpath
896
+ * @param {Record<string, unknown>} packageConfig
897
+ * @param {URL} base
898
+ * @param {Set<string> | undefined} conditions
899
+ * @returns {URL}
900
+ */
901
+ function packageExportsResolve(packageJsonUrl, packageSubpath, packageConfig, base, conditions) {
902
+ let exports$1 = packageConfig.exports;
903
+ if (isConditionalExportsMainSugar(exports$1, packageJsonUrl, base)) exports$1 = { ".": exports$1 };
904
+ if (own.call(exports$1, packageSubpath) && !packageSubpath.includes("*") && !packageSubpath.endsWith("/")) {
905
+ const target = exports$1[packageSubpath];
906
+ const resolveResult = resolvePackageTarget(packageJsonUrl, target, "", packageSubpath, base, false, false, false, conditions);
907
+ if (resolveResult === null || resolveResult === void 0) throw exportsNotFound(packageSubpath, packageJsonUrl, base);
908
+ return resolveResult;
909
+ }
910
+ let bestMatch = "";
911
+ let bestMatchSubpath = "";
912
+ const keys = Object.getOwnPropertyNames(exports$1);
913
+ let i = -1;
914
+ while (++i < keys.length) {
915
+ const key = keys[i];
916
+ const patternIndex = key.indexOf("*");
917
+ if (patternIndex !== -1 && packageSubpath.startsWith(key.slice(0, patternIndex))) {
918
+ if (packageSubpath.endsWith("/")) emitTrailingSlashPatternDeprecation(packageSubpath, packageJsonUrl, base);
919
+ const patternTrailer = key.slice(patternIndex + 1);
920
+ if (packageSubpath.length >= key.length && packageSubpath.endsWith(patternTrailer) && patternKeyCompare(bestMatch, key) === 1 && key.lastIndexOf("*") === patternIndex) {
921
+ bestMatch = key;
922
+ bestMatchSubpath = packageSubpath.slice(patternIndex, packageSubpath.length - patternTrailer.length);
923
+ }
924
+ }
925
+ }
926
+ if (bestMatch) {
927
+ const target = exports$1[bestMatch];
928
+ const resolveResult = resolvePackageTarget(packageJsonUrl, target, bestMatchSubpath, bestMatch, base, true, false, packageSubpath.endsWith("/"), conditions);
929
+ if (resolveResult === null || resolveResult === void 0) throw exportsNotFound(packageSubpath, packageJsonUrl, base);
930
+ return resolveResult;
931
+ }
932
+ throw exportsNotFound(packageSubpath, packageJsonUrl, base);
933
+ }
934
+ /**
935
+ * @param {string} a
936
+ * @param {string} b
937
+ */
938
+ function patternKeyCompare(a, b) {
939
+ const aPatternIndex = a.indexOf("*");
940
+ const bPatternIndex = b.indexOf("*");
941
+ const baseLengthA = aPatternIndex === -1 ? a.length : aPatternIndex + 1;
942
+ const baseLengthB = bPatternIndex === -1 ? b.length : bPatternIndex + 1;
943
+ if (baseLengthA > baseLengthB) return -1;
944
+ if (baseLengthB > baseLengthA) return 1;
945
+ if (aPatternIndex === -1) return 1;
946
+ if (bPatternIndex === -1) return -1;
947
+ if (a.length > b.length) return -1;
948
+ if (b.length > a.length) return 1;
949
+ return 0;
950
+ }
951
+ /**
952
+ * @param {string} name
953
+ * @param {URL} base
954
+ * @param {Set<string>} [conditions]
955
+ * @returns {URL}
956
+ */
957
+ function packageImportsResolve(name, base, conditions) {
958
+ if (name === "#" || name.startsWith("#/") || name.endsWith("/")) throw new ERR_INVALID_MODULE_SPECIFIER(name, "is not a valid internal imports specifier name", (0, node_url.fileURLToPath)(base));
959
+ /** @type {URL | undefined} */
960
+ let packageJsonUrl;
961
+ const packageConfig = getPackageScopeConfig(base);
962
+ if (packageConfig.exists) {
963
+ packageJsonUrl = (0, node_url.pathToFileURL)(packageConfig.pjsonPath);
964
+ const imports = packageConfig.imports;
965
+ if (imports) if (own.call(imports, name) && !name.includes("*")) {
966
+ const resolveResult = resolvePackageTarget(packageJsonUrl, imports[name], "", name, base, false, true, false, conditions);
967
+ if (resolveResult !== null && resolveResult !== void 0) return resolveResult;
968
+ } else {
969
+ let bestMatch = "";
970
+ let bestMatchSubpath = "";
971
+ const keys = Object.getOwnPropertyNames(imports);
972
+ let i = -1;
973
+ while (++i < keys.length) {
974
+ const key = keys[i];
975
+ const patternIndex = key.indexOf("*");
976
+ if (patternIndex !== -1 && name.startsWith(key.slice(0, -1))) {
977
+ const patternTrailer = key.slice(patternIndex + 1);
978
+ if (name.length >= key.length && name.endsWith(patternTrailer) && patternKeyCompare(bestMatch, key) === 1 && key.lastIndexOf("*") === patternIndex) {
979
+ bestMatch = key;
980
+ bestMatchSubpath = name.slice(patternIndex, name.length - patternTrailer.length);
981
+ }
982
+ }
983
+ }
984
+ if (bestMatch) {
985
+ const target = imports[bestMatch];
986
+ const resolveResult = resolvePackageTarget(packageJsonUrl, target, bestMatchSubpath, bestMatch, base, true, true, false, conditions);
987
+ if (resolveResult !== null && resolveResult !== void 0) return resolveResult;
988
+ }
989
+ }
990
+ }
991
+ throw importNotDefined(name, packageJsonUrl, base);
992
+ }
993
+ /**
994
+ * @param {string} specifier
995
+ * @param {URL} base
996
+ */
997
+ function parsePackageName(specifier, base) {
998
+ let separatorIndex = specifier.indexOf("/");
999
+ let validPackageName = true;
1000
+ let isScoped = false;
1001
+ if (specifier[0] === "@") {
1002
+ isScoped = true;
1003
+ if (separatorIndex === -1 || specifier.length === 0) validPackageName = false;
1004
+ else separatorIndex = specifier.indexOf("/", separatorIndex + 1);
1005
+ }
1006
+ const packageName = separatorIndex === -1 ? specifier : specifier.slice(0, separatorIndex);
1007
+ if (invalidPackageNameRegEx.exec(packageName) !== null) validPackageName = false;
1008
+ if (!validPackageName) throw new ERR_INVALID_MODULE_SPECIFIER(specifier, "is not a valid package name", (0, node_url.fileURLToPath)(base));
1009
+ return {
1010
+ packageName,
1011
+ packageSubpath: "." + (separatorIndex === -1 ? "" : specifier.slice(separatorIndex)),
1012
+ isScoped
1013
+ };
1014
+ }
1015
+ /**
1016
+ * @param {string} specifier
1017
+ * @param {URL} base
1018
+ * @param {Set<string> | undefined} conditions
1019
+ * @returns {URL}
1020
+ */
1021
+ function packageResolve(specifier, base, conditions) {
1022
+ if (node_module.builtinModules.includes(specifier)) return new node_url.URL("node:" + specifier);
1023
+ const { packageName, packageSubpath, isScoped } = parsePackageName(specifier, base);
1024
+ const packageConfig = getPackageScopeConfig(base);
1025
+ /* c8 ignore next 16 */
1026
+ if (packageConfig.exists) {
1027
+ const packageJsonUrl$1 = (0, node_url.pathToFileURL)(packageConfig.pjsonPath);
1028
+ if (packageConfig.name === packageName && packageConfig.exports !== void 0 && packageConfig.exports !== null) return packageExportsResolve(packageJsonUrl$1, packageSubpath, packageConfig, base, conditions);
1029
+ }
1030
+ let packageJsonUrl = new node_url.URL("./node_modules/" + packageName + "/package.json", base);
1031
+ let packageJsonPath = (0, node_url.fileURLToPath)(packageJsonUrl);
1032
+ /** @type {string} */
1033
+ let lastPath;
1034
+ do {
1035
+ const stat = tryStatSync(packageJsonPath.slice(0, -13));
1036
+ if (!stat || !stat.isDirectory()) {
1037
+ lastPath = packageJsonPath;
1038
+ packageJsonUrl = new node_url.URL((isScoped ? "../../../../node_modules/" : "../../../node_modules/") + packageName + "/package.json", packageJsonUrl);
1039
+ packageJsonPath = (0, node_url.fileURLToPath)(packageJsonUrl);
1040
+ continue;
1041
+ }
1042
+ const packageConfig$1 = read(packageJsonPath, {
1043
+ base,
1044
+ specifier
1045
+ });
1046
+ if (packageConfig$1.exports !== void 0 && packageConfig$1.exports !== null) return packageExportsResolve(packageJsonUrl, packageSubpath, packageConfig$1, base, conditions);
1047
+ if (packageSubpath === ".") return legacyMainResolve(packageJsonUrl, packageConfig$1, base);
1048
+ return new node_url.URL(packageSubpath, packageJsonUrl);
1049
+ } while (packageJsonPath.length !== lastPath.length);
1050
+ throw new ERR_MODULE_NOT_FOUND(packageName, (0, node_url.fileURLToPath)(base), false);
1051
+ }
1052
+ /**
1053
+ * @param {string} specifier
1054
+ * @returns {boolean}
1055
+ */
1056
+ function isRelativeSpecifier(specifier) {
1057
+ if (specifier[0] === ".") {
1058
+ if (specifier.length === 1 || specifier[1] === "/") return true;
1059
+ if (specifier[1] === "." && (specifier.length === 2 || specifier[2] === "/")) return true;
1060
+ }
1061
+ return false;
1062
+ }
1063
+ /**
1064
+ * @param {string} specifier
1065
+ * @returns {boolean}
1066
+ */
1067
+ function shouldBeTreatedAsRelativeOrAbsolutePath(specifier) {
1068
+ if (specifier === "") return false;
1069
+ if (specifier[0] === "/") return true;
1070
+ return isRelativeSpecifier(specifier);
1071
+ }
1072
+ /**
1073
+ * The “Resolver Algorithm Specification” as detailed in the Node docs (which is
1074
+ * sync and slightly lower-level than `resolve`).
1075
+ *
1076
+ * @param {string} specifier
1077
+ * `/example.js`, `./example.js`, `../example.js`, `some-package`, `fs`, etc.
1078
+ * @param {URL} base
1079
+ * Full URL (to a file) that `specifier` is resolved relative from.
1080
+ * @param {Set<string>} [conditions]
1081
+ * Conditions.
1082
+ * @param {boolean} [preserveSymlinks]
1083
+ * Keep symlinks instead of resolving them.
1084
+ * @returns {URL}
1085
+ * A URL object to the found thing.
1086
+ */
1087
+ function moduleResolve(specifier, base, conditions, preserveSymlinks) {
1088
+ const protocol = base.protocol;
1089
+ const isRemote = protocol === "data:" || protocol === "http:" || protocol === "https:";
1090
+ /** @type {URL | undefined} */
1091
+ let resolved;
1092
+ if (shouldBeTreatedAsRelativeOrAbsolutePath(specifier)) try {
1093
+ resolved = new node_url.URL(specifier, base);
1094
+ } catch (error_) {
1095
+ const error = new ERR_UNSUPPORTED_RESOLVE_REQUEST(specifier, base);
1096
+ error.cause = error_;
1097
+ throw error;
1098
+ }
1099
+ else if (protocol === "file:" && specifier[0] === "#") resolved = packageImportsResolve(specifier, base, conditions);
1100
+ else try {
1101
+ resolved = new node_url.URL(specifier);
1102
+ } catch (error_) {
1103
+ if (isRemote && !node_module.builtinModules.includes(specifier)) {
1104
+ const error = new ERR_UNSUPPORTED_RESOLVE_REQUEST(specifier, base);
1105
+ error.cause = error_;
1106
+ throw error;
1107
+ }
1108
+ resolved = packageResolve(specifier, base, conditions);
1109
+ }
1110
+ (0, node_assert.default)(resolved !== void 0, "expected to be defined");
1111
+ if (resolved.protocol !== "file:") return resolved;
1112
+ return finalizeResolution(resolved, base);
1113
+ }
1114
+ function fileURLToPath(id) {
1115
+ if (typeof id === "string" && !id.startsWith("file://")) return normalizeSlash(id);
1116
+ return normalizeSlash((0, node_url.fileURLToPath)(id));
1117
+ }
1118
+ function pathToFileURL(id) {
1119
+ return (0, node_url.pathToFileURL)(fileURLToPath(id)).toString();
1120
+ }
1121
+ function normalizeid(id) {
1122
+ if (typeof id !== "string") id = id.toString();
1123
+ if (/(?:node|data|http|https|file):/.test(id)) return id;
1124
+ if (BUILTIN_MODULES.has(id)) return "node:" + id;
1125
+ return "file://" + encodeURI(normalizeSlash(id));
1126
+ }
1127
+ const DEFAULT_CONDITIONS_SET = /* @__PURE__ */ new Set(["node", "import"]);
1128
+ const DEFAULT_EXTENSIONS = [
1129
+ ".mjs",
1130
+ ".cjs",
1131
+ ".js",
1132
+ ".json"
1133
+ ];
1134
+ const NOT_FOUND_ERRORS = /* @__PURE__ */ new Set([
1135
+ "ERR_MODULE_NOT_FOUND",
1136
+ "ERR_UNSUPPORTED_DIR_IMPORT",
1137
+ "MODULE_NOT_FOUND",
1138
+ "ERR_PACKAGE_PATH_NOT_EXPORTED"
1139
+ ]);
1140
+ function _tryModuleResolve(id, url, conditions) {
1141
+ try {
1142
+ return moduleResolve(id, url, conditions);
1143
+ } catch (error) {
1144
+ if (!NOT_FOUND_ERRORS.has(error?.code)) throw error;
1145
+ }
1146
+ }
1147
+ function _resolve(id, options = {}) {
1148
+ if (typeof id !== "string") if (id instanceof URL) id = fileURLToPath(id);
1149
+ else throw new TypeError("input must be a `string` or `URL`");
1150
+ if (/(?:node|data|http|https):/.test(id)) return id;
1151
+ if (BUILTIN_MODULES.has(id)) return "node:" + id;
1152
+ if (id.startsWith("file://")) id = fileURLToPath(id);
1153
+ if (require_pathe_M_eThtNZ.isAbsolute(id)) try {
1154
+ if ((0, node_fs.statSync)(id).isFile()) return pathToFileURL(id);
1155
+ } catch (error) {
1156
+ if (error?.code !== "ENOENT") throw error;
1157
+ }
1158
+ const conditionsSet = options.conditions ? new Set(options.conditions) : DEFAULT_CONDITIONS_SET;
1159
+ const _urls = (Array.isArray(options.url) ? options.url : [options.url]).filter(Boolean).map((url) => new URL(normalizeid(url.toString())));
1160
+ if (_urls.length === 0) _urls.push(new URL(pathToFileURL(process.cwd())));
1161
+ const urls = [..._urls];
1162
+ for (const url of _urls) if (url.protocol === "file:") urls.push(new URL("./", url), new URL(require_index.joinURL(url.pathname, "_index.js"), url), new URL("node_modules", url));
1163
+ let resolved;
1164
+ for (const url of urls) {
1165
+ resolved = _tryModuleResolve(id, url, conditionsSet);
1166
+ if (resolved) break;
1167
+ for (const prefix of ["", "/index"]) {
1168
+ for (const extension of options.extensions || DEFAULT_EXTENSIONS) {
1169
+ resolved = _tryModuleResolve(require_index.joinURL(id, prefix) + extension, url, conditionsSet);
1170
+ if (resolved) break;
1171
+ }
1172
+ if (resolved) break;
1173
+ }
1174
+ if (resolved) break;
1175
+ }
1176
+ if (!resolved) {
1177
+ const error = /* @__PURE__ */ new Error(`Cannot find module ${id} imported from ${urls.join(", ")}`);
1178
+ error.code = "ERR_MODULE_NOT_FOUND";
1179
+ throw error;
1180
+ }
1181
+ return pathToFileURL(resolved);
1182
+ }
1183
+ function resolveSync(id, options) {
1184
+ return _resolve(id, options);
1185
+ }
1186
+ function resolvePathSync(id, options) {
1187
+ return fileURLToPath(resolveSync(id, options));
1188
+ }
1189
+ function resolvePath(id, options) {
1190
+ try {
1191
+ return Promise.resolve(resolvePathSync(id, options));
1192
+ } catch (error) {
1193
+ return Promise.reject(error);
1194
+ }
1195
+ }
1196
+ const EXPORT_DECAL_RE = /\bexport\s+(?<declaration>(?:async function\s*\*?|function\s*\*?|let|const enum|const|enum|var|class))\s+\*?(?<name>[\w$]+)(?<extraNames>.*,\s*[\s\w:[\]{}]*[\w$\]}]+)*/g;
1197
+ const EXPORT_NAMED_RE = /\bexport\s*{(?<exports>[^}]+?)[\s,]*}(?:\s*from\s*["']\s*(?<specifier>(?<="\s*)[^"]*[^\s"](?=\s*")|(?<='\s*)[^']*[^\s'](?=\s*'))\s*["'][^\n;]*)?/g;
1198
+ const EXPORT_NAMED_DESTRUCT = /\bexport\s+(?:let|var|const)\s+(?:{(?<exports1>[^}]+?)[\s,]*}|\[(?<exports2>[^\]]+?)[\s,]*])\s+=/gm;
1199
+ const EXPORT_STAR_RE = /\bexport\s*\*(?:\s*as\s+(?<name>[\w$]+)\s+)?\s*(?:\s*from\s*["']\s*(?<specifier>(?<="\s*)[^"]*[^\s"](?=\s*")|(?<='\s*)[^']*[^\s'](?=\s*'))\s*["'][^\n;]*)?/g;
1200
+ const EXPORT_DEFAULT_RE = /\bexport\s+default\s+(async function|function|class|true|false|\W|\d)|\bexport\s+default\s+(?<defaultName>.*)/g;
1201
+ const EXPORT_DEFAULT_CLASS_RE = /\bexport\s+default\s+(?<declaration>class)\s+(?<name>[\w$]+)/g;
1202
+ const TYPE_RE = /^\s*?type\s/;
1203
+ function findExports(code) {
1204
+ const declaredExports = matchAll(EXPORT_DECAL_RE, code, { type: "declaration" });
1205
+ for (const declaredExport of declaredExports) {
1206
+ if (/^export\s+(?:async\s+)?function/.test(declaredExport.code)) continue;
1207
+ const extraNamesStr = declaredExport.extraNames;
1208
+ if (extraNamesStr) {
1209
+ const extraNames = matchAll(/({.*?})|(\[.*?])|(,\s*(?<name>\w+))/g, extraNamesStr, {}).map((m) => m.name).filter(Boolean);
1210
+ declaredExport.names = [declaredExport.name, ...extraNames];
1211
+ }
1212
+ delete declaredExport.extraNames;
1213
+ }
1214
+ const namedExports = normalizeNamedExports(matchAll(EXPORT_NAMED_RE, code, { type: "named" }));
1215
+ const destructuredExports = matchAll(EXPORT_NAMED_DESTRUCT, code, { type: "named" });
1216
+ for (const namedExport of destructuredExports) {
1217
+ namedExport.exports = namedExport.exports1 || namedExport.exports2;
1218
+ namedExport.names = namedExport.exports.replace(/^\r?\n?/, "").split(/\s*,\s*/g).filter((name) => !TYPE_RE.test(name)).map((name) => name.replace(/^.*?\s*:\s*/, "").replace(/\s*=\s*.*$/, "").trim());
1219
+ }
1220
+ const defaultExport = matchAll(EXPORT_DEFAULT_RE, code, {
1221
+ type: "default",
1222
+ name: "default"
1223
+ });
1224
+ const defaultClassExports = matchAll(EXPORT_DEFAULT_CLASS_RE, code, { type: "declaration" });
1225
+ const starExports = matchAll(EXPORT_STAR_RE, code, { type: "star" });
1226
+ const exports$1 = normalizeExports([
1227
+ ...declaredExports,
1228
+ ...namedExports,
1229
+ ...destructuredExports,
1230
+ ...defaultExport,
1231
+ ...defaultClassExports,
1232
+ ...starExports
1233
+ ]);
1234
+ if (exports$1.length === 0) return [];
1235
+ const exportLocations = _tryGetLocations(code, "export");
1236
+ if (exportLocations && exportLocations.length === 0) return [];
1237
+ return _filterStatement(exportLocations, exports$1).filter((exp, index, exports2) => {
1238
+ const nextExport = exports2[index + 1];
1239
+ return !nextExport || exp.type !== nextExport.type || !exp.name || exp.name !== nextExport.name;
1240
+ });
1241
+ }
1242
+ function normalizeExports(exports$1) {
1243
+ for (const exp of exports$1) {
1244
+ if (!exp.name && exp.names && exp.names.length === 1) exp.name = exp.names[0];
1245
+ if (exp.name === "default" && exp.type !== "default") {
1246
+ exp._type = exp.type;
1247
+ exp.type = "default";
1248
+ }
1249
+ if (!exp.names && exp.name) exp.names = [exp.name];
1250
+ if (exp.type === "declaration" && exp.declaration) exp.declarationType = exp.declaration.replace(/^declare\s*/, "");
1251
+ }
1252
+ return exports$1;
1253
+ }
1254
+ function normalizeNamedExports(namedExports) {
1255
+ for (const namedExport of namedExports) namedExport.names = namedExport.exports.replace(/^\r?\n?/, "").split(/\s*,\s*/g).filter((name) => !TYPE_RE.test(name)).map((name) => name.replace(/^.*?\sas\s/, "").trim());
1256
+ return namedExports;
1257
+ }
1258
+ function findExportNames(code) {
1259
+ return findExports(code).flatMap((exp) => exp.names).filter(Boolean);
1260
+ }
1261
+ function _filterStatement(locations, statements) {
1262
+ return statements.filter((exp) => {
1263
+ return !locations || locations.some((location) => {
1264
+ return exp.start <= location.start && exp.end >= location.end;
1265
+ });
1266
+ });
1267
+ }
1268
+ function _tryGetLocations(code, label) {
1269
+ try {
1270
+ return _getLocations(code, label);
1271
+ } catch {}
1272
+ }
1273
+ function _getLocations(code, label) {
1274
+ const tokens = require_acorn.tokenizer(code, {
1275
+ ecmaVersion: "latest",
1276
+ sourceType: "module",
1277
+ allowHashBang: true,
1278
+ allowAwaitOutsideFunction: true,
1279
+ allowImportExportEverywhere: true
1280
+ });
1281
+ const locations = [];
1282
+ for (const token of tokens) if (token.type.label === label) locations.push({
1283
+ start: token.start,
1284
+ end: token.end
1285
+ });
1286
+ return locations;
1287
+ }
1288
+
1289
+ //#endregion
1290
+ exports.fileURLToPath = fileURLToPath;
1291
+ exports.findExportNames = findExportNames;
1292
+ exports.resolvePath = resolvePath;