modern-monaco 0.3.8 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,59 +1,2530 @@
1
- // node_modules/@esm.sh/import-map/dist/import-map.mjs
2
- function createBlankImportMap(baseURL) {
3
- return {
4
- $baseURL: new URL(baseURL ?? ".", "file:///").href,
5
- imports: {},
6
- scopes: {}
7
- };
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __commonJS = (cb, mod) => function __require() {
8
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
19
+ // If the importer is in node compatibility mode or this is not an ESM
20
+ // file that has been converted to a CommonJS file using a Babel-
21
+ // compatible transform (i.e. "__esModule" has not been set), then set
22
+ // "default" to the CommonJS "module.exports" for node compatibility.
23
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
24
+ mod
25
+ ));
26
+
27
+ // node_modules/semver/internal/constants.js
28
+ var require_constants = __commonJS({
29
+ "node_modules/semver/internal/constants.js"(exports, module) {
30
+ "use strict";
31
+ var SEMVER_SPEC_VERSION = "2.0.0";
32
+ var MAX_LENGTH = 256;
33
+ var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || /* istanbul ignore next */
34
+ 9007199254740991;
35
+ var MAX_SAFE_COMPONENT_LENGTH = 16;
36
+ var MAX_SAFE_BUILD_LENGTH = MAX_LENGTH - 6;
37
+ var RELEASE_TYPES = [
38
+ "major",
39
+ "premajor",
40
+ "minor",
41
+ "preminor",
42
+ "patch",
43
+ "prepatch",
44
+ "prerelease"
45
+ ];
46
+ module.exports = {
47
+ MAX_LENGTH,
48
+ MAX_SAFE_COMPONENT_LENGTH,
49
+ MAX_SAFE_BUILD_LENGTH,
50
+ MAX_SAFE_INTEGER,
51
+ RELEASE_TYPES,
52
+ SEMVER_SPEC_VERSION,
53
+ FLAG_INCLUDE_PRERELEASE: 1,
54
+ FLAG_LOOSE: 2
55
+ };
56
+ }
57
+ });
58
+
59
+ // node_modules/semver/internal/debug.js
60
+ var require_debug = __commonJS({
61
+ "node_modules/semver/internal/debug.js"(exports, module) {
62
+ "use strict";
63
+ var debug = typeof process === "object" && process.env && process.env.NODE_DEBUG && /\bsemver\b/i.test(process.env.NODE_DEBUG) ? (...args) => console.error("SEMVER", ...args) : () => {
64
+ };
65
+ module.exports = debug;
66
+ }
67
+ });
68
+
69
+ // node_modules/semver/internal/re.js
70
+ var require_re = __commonJS({
71
+ "node_modules/semver/internal/re.js"(exports, module) {
72
+ "use strict";
73
+ var {
74
+ MAX_SAFE_COMPONENT_LENGTH,
75
+ MAX_SAFE_BUILD_LENGTH,
76
+ MAX_LENGTH
77
+ } = require_constants();
78
+ var debug = require_debug();
79
+ exports = module.exports = {};
80
+ var re = exports.re = [];
81
+ var safeRe = exports.safeRe = [];
82
+ var src = exports.src = [];
83
+ var safeSrc = exports.safeSrc = [];
84
+ var t = exports.t = {};
85
+ var R = 0;
86
+ var LETTERDASHNUMBER = "[a-zA-Z0-9-]";
87
+ var safeRegexReplacements = [
88
+ ["\\s", 1],
89
+ ["\\d", MAX_LENGTH],
90
+ [LETTERDASHNUMBER, MAX_SAFE_BUILD_LENGTH]
91
+ ];
92
+ var makeSafeRegex = (value) => {
93
+ for (const [token, max] of safeRegexReplacements) {
94
+ value = value.split(`${token}*`).join(`${token}{0,${max}}`).split(`${token}+`).join(`${token}{1,${max}}`);
95
+ }
96
+ return value;
97
+ };
98
+ var createToken = (name, value, isGlobal) => {
99
+ const safe = makeSafeRegex(value);
100
+ const index = R++;
101
+ debug(name, index, value);
102
+ t[name] = index;
103
+ src[index] = value;
104
+ safeSrc[index] = safe;
105
+ re[index] = new RegExp(value, isGlobal ? "g" : void 0);
106
+ safeRe[index] = new RegExp(safe, isGlobal ? "g" : void 0);
107
+ };
108
+ createToken("NUMERICIDENTIFIER", "0|[1-9]\\d*");
109
+ createToken("NUMERICIDENTIFIERLOOSE", "\\d+");
110
+ createToken("NONNUMERICIDENTIFIER", `\\d*[a-zA-Z-]${LETTERDASHNUMBER}*`);
111
+ createToken("MAINVERSION", `(${src[t.NUMERICIDENTIFIER]})\\.(${src[t.NUMERICIDENTIFIER]})\\.(${src[t.NUMERICIDENTIFIER]})`);
112
+ createToken("MAINVERSIONLOOSE", `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.(${src[t.NUMERICIDENTIFIERLOOSE]})\\.(${src[t.NUMERICIDENTIFIERLOOSE]})`);
113
+ createToken("PRERELEASEIDENTIFIER", `(?:${src[t.NONNUMERICIDENTIFIER]}|${src[t.NUMERICIDENTIFIER]})`);
114
+ createToken("PRERELEASEIDENTIFIERLOOSE", `(?:${src[t.NONNUMERICIDENTIFIER]}|${src[t.NUMERICIDENTIFIERLOOSE]})`);
115
+ createToken("PRERELEASE", `(?:-(${src[t.PRERELEASEIDENTIFIER]}(?:\\.${src[t.PRERELEASEIDENTIFIER]})*))`);
116
+ createToken("PRERELEASELOOSE", `(?:-?(${src[t.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${src[t.PRERELEASEIDENTIFIERLOOSE]})*))`);
117
+ createToken("BUILDIDENTIFIER", `${LETTERDASHNUMBER}+`);
118
+ createToken("BUILD", `(?:\\+(${src[t.BUILDIDENTIFIER]}(?:\\.${src[t.BUILDIDENTIFIER]})*))`);
119
+ createToken("FULLPLAIN", `v?${src[t.MAINVERSION]}${src[t.PRERELEASE]}?${src[t.BUILD]}?`);
120
+ createToken("FULL", `^${src[t.FULLPLAIN]}$`);
121
+ createToken("LOOSEPLAIN", `[v=\\s]*${src[t.MAINVERSIONLOOSE]}${src[t.PRERELEASELOOSE]}?${src[t.BUILD]}?`);
122
+ createToken("LOOSE", `^${src[t.LOOSEPLAIN]}$`);
123
+ createToken("GTLT", "((?:<|>)?=?)");
124
+ createToken("XRANGEIDENTIFIERLOOSE", `${src[t.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`);
125
+ createToken("XRANGEIDENTIFIER", `${src[t.NUMERICIDENTIFIER]}|x|X|\\*`);
126
+ createToken("XRANGEPLAIN", `[v=\\s]*(${src[t.XRANGEIDENTIFIER]})(?:\\.(${src[t.XRANGEIDENTIFIER]})(?:\\.(${src[t.XRANGEIDENTIFIER]})(?:${src[t.PRERELEASE]})?${src[t.BUILD]}?)?)?`);
127
+ createToken("XRANGEPLAINLOOSE", `[v=\\s]*(${src[t.XRANGEIDENTIFIERLOOSE]})(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})(?:${src[t.PRERELEASELOOSE]})?${src[t.BUILD]}?)?)?`);
128
+ createToken("XRANGE", `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAIN]}$`);
129
+ createToken("XRANGELOOSE", `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAINLOOSE]}$`);
130
+ createToken("COERCEPLAIN", `${"(^|[^\\d])(\\d{1,"}${MAX_SAFE_COMPONENT_LENGTH}})(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?`);
131
+ createToken("COERCE", `${src[t.COERCEPLAIN]}(?:$|[^\\d])`);
132
+ createToken("COERCEFULL", src[t.COERCEPLAIN] + `(?:${src[t.PRERELEASE]})?(?:${src[t.BUILD]})?(?:$|[^\\d])`);
133
+ createToken("COERCERTL", src[t.COERCE], true);
134
+ createToken("COERCERTLFULL", src[t.COERCEFULL], true);
135
+ createToken("LONETILDE", "(?:~>?)");
136
+ createToken("TILDETRIM", `(\\s*)${src[t.LONETILDE]}\\s+`, true);
137
+ exports.tildeTrimReplace = "$1~";
138
+ createToken("TILDE", `^${src[t.LONETILDE]}${src[t.XRANGEPLAIN]}$`);
139
+ createToken("TILDELOOSE", `^${src[t.LONETILDE]}${src[t.XRANGEPLAINLOOSE]}$`);
140
+ createToken("LONECARET", "(?:\\^)");
141
+ createToken("CARETTRIM", `(\\s*)${src[t.LONECARET]}\\s+`, true);
142
+ exports.caretTrimReplace = "$1^";
143
+ createToken("CARET", `^${src[t.LONECARET]}${src[t.XRANGEPLAIN]}$`);
144
+ createToken("CARETLOOSE", `^${src[t.LONECARET]}${src[t.XRANGEPLAINLOOSE]}$`);
145
+ createToken("COMPARATORLOOSE", `^${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]})$|^$`);
146
+ createToken("COMPARATOR", `^${src[t.GTLT]}\\s*(${src[t.FULLPLAIN]})$|^$`);
147
+ createToken("COMPARATORTRIM", `(\\s*)${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]}|${src[t.XRANGEPLAIN]})`, true);
148
+ exports.comparatorTrimReplace = "$1$2$3";
149
+ createToken("HYPHENRANGE", `^\\s*(${src[t.XRANGEPLAIN]})\\s+-\\s+(${src[t.XRANGEPLAIN]})\\s*$`);
150
+ createToken("HYPHENRANGELOOSE", `^\\s*(${src[t.XRANGEPLAINLOOSE]})\\s+-\\s+(${src[t.XRANGEPLAINLOOSE]})\\s*$`);
151
+ createToken("STAR", "(<|>)?=?\\s*\\*");
152
+ createToken("GTE0", "^\\s*>=\\s*0\\.0\\.0\\s*$");
153
+ createToken("GTE0PRE", "^\\s*>=\\s*0\\.0\\.0-0\\s*$");
154
+ }
155
+ });
156
+
157
+ // node_modules/semver/internal/parse-options.js
158
+ var require_parse_options = __commonJS({
159
+ "node_modules/semver/internal/parse-options.js"(exports, module) {
160
+ "use strict";
161
+ var looseOption = Object.freeze({ loose: true });
162
+ var emptyOpts = Object.freeze({});
163
+ var parseOptions = (options) => {
164
+ if (!options) {
165
+ return emptyOpts;
166
+ }
167
+ if (typeof options !== "object") {
168
+ return looseOption;
169
+ }
170
+ return options;
171
+ };
172
+ module.exports = parseOptions;
173
+ }
174
+ });
175
+
176
+ // node_modules/semver/internal/identifiers.js
177
+ var require_identifiers = __commonJS({
178
+ "node_modules/semver/internal/identifiers.js"(exports, module) {
179
+ "use strict";
180
+ var numeric = /^[0-9]+$/;
181
+ var compareIdentifiers = (a, b) => {
182
+ if (typeof a === "number" && typeof b === "number") {
183
+ return a === b ? 0 : a < b ? -1 : 1;
184
+ }
185
+ const anum = numeric.test(a);
186
+ const bnum = numeric.test(b);
187
+ if (anum && bnum) {
188
+ a = +a;
189
+ b = +b;
190
+ }
191
+ return a === b ? 0 : anum && !bnum ? -1 : bnum && !anum ? 1 : a < b ? -1 : 1;
192
+ };
193
+ var rcompareIdentifiers = (a, b) => compareIdentifiers(b, a);
194
+ module.exports = {
195
+ compareIdentifiers,
196
+ rcompareIdentifiers
197
+ };
198
+ }
199
+ });
200
+
201
+ // node_modules/semver/classes/semver.js
202
+ var require_semver = __commonJS({
203
+ "node_modules/semver/classes/semver.js"(exports, module) {
204
+ "use strict";
205
+ var debug = require_debug();
206
+ var { MAX_LENGTH, MAX_SAFE_INTEGER } = require_constants();
207
+ var { safeRe: re, t } = require_re();
208
+ var parseOptions = require_parse_options();
209
+ var { compareIdentifiers } = require_identifiers();
210
+ var SemVer = class _SemVer {
211
+ constructor(version, options) {
212
+ options = parseOptions(options);
213
+ if (version instanceof _SemVer) {
214
+ if (version.loose === !!options.loose && version.includePrerelease === !!options.includePrerelease) {
215
+ return version;
216
+ } else {
217
+ version = version.version;
218
+ }
219
+ } else if (typeof version !== "string") {
220
+ throw new TypeError(`Invalid version. Must be a string. Got type "${typeof version}".`);
221
+ }
222
+ if (version.length > MAX_LENGTH) {
223
+ throw new TypeError(
224
+ `version is longer than ${MAX_LENGTH} characters`
225
+ );
226
+ }
227
+ debug("SemVer", version, options);
228
+ this.options = options;
229
+ this.loose = !!options.loose;
230
+ this.includePrerelease = !!options.includePrerelease;
231
+ const m = version.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL]);
232
+ if (!m) {
233
+ throw new TypeError(`Invalid Version: ${version}`);
234
+ }
235
+ this.raw = version;
236
+ this.major = +m[1];
237
+ this.minor = +m[2];
238
+ this.patch = +m[3];
239
+ if (this.major > MAX_SAFE_INTEGER || this.major < 0) {
240
+ throw new TypeError("Invalid major version");
241
+ }
242
+ if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) {
243
+ throw new TypeError("Invalid minor version");
244
+ }
245
+ if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) {
246
+ throw new TypeError("Invalid patch version");
247
+ }
248
+ if (!m[4]) {
249
+ this.prerelease = [];
250
+ } else {
251
+ this.prerelease = m[4].split(".").map((id) => {
252
+ if (/^[0-9]+$/.test(id)) {
253
+ const num = +id;
254
+ if (num >= 0 && num < MAX_SAFE_INTEGER) {
255
+ return num;
256
+ }
257
+ }
258
+ return id;
259
+ });
260
+ }
261
+ this.build = m[5] ? m[5].split(".") : [];
262
+ this.format();
263
+ }
264
+ format() {
265
+ this.version = `${this.major}.${this.minor}.${this.patch}`;
266
+ if (this.prerelease.length) {
267
+ this.version += `-${this.prerelease.join(".")}`;
268
+ }
269
+ return this.version;
270
+ }
271
+ toString() {
272
+ return this.version;
273
+ }
274
+ compare(other) {
275
+ debug("SemVer.compare", this.version, this.options, other);
276
+ if (!(other instanceof _SemVer)) {
277
+ if (typeof other === "string" && other === this.version) {
278
+ return 0;
279
+ }
280
+ other = new _SemVer(other, this.options);
281
+ }
282
+ if (other.version === this.version) {
283
+ return 0;
284
+ }
285
+ return this.compareMain(other) || this.comparePre(other);
286
+ }
287
+ compareMain(other) {
288
+ if (!(other instanceof _SemVer)) {
289
+ other = new _SemVer(other, this.options);
290
+ }
291
+ if (this.major < other.major) {
292
+ return -1;
293
+ }
294
+ if (this.major > other.major) {
295
+ return 1;
296
+ }
297
+ if (this.minor < other.minor) {
298
+ return -1;
299
+ }
300
+ if (this.minor > other.minor) {
301
+ return 1;
302
+ }
303
+ if (this.patch < other.patch) {
304
+ return -1;
305
+ }
306
+ if (this.patch > other.patch) {
307
+ return 1;
308
+ }
309
+ return 0;
310
+ }
311
+ comparePre(other) {
312
+ if (!(other instanceof _SemVer)) {
313
+ other = new _SemVer(other, this.options);
314
+ }
315
+ if (this.prerelease.length && !other.prerelease.length) {
316
+ return -1;
317
+ } else if (!this.prerelease.length && other.prerelease.length) {
318
+ return 1;
319
+ } else if (!this.prerelease.length && !other.prerelease.length) {
320
+ return 0;
321
+ }
322
+ let i = 0;
323
+ do {
324
+ const a = this.prerelease[i];
325
+ const b = other.prerelease[i];
326
+ debug("prerelease compare", i, a, b);
327
+ if (a === void 0 && b === void 0) {
328
+ return 0;
329
+ } else if (b === void 0) {
330
+ return 1;
331
+ } else if (a === void 0) {
332
+ return -1;
333
+ } else if (a === b) {
334
+ continue;
335
+ } else {
336
+ return compareIdentifiers(a, b);
337
+ }
338
+ } while (++i);
339
+ }
340
+ compareBuild(other) {
341
+ if (!(other instanceof _SemVer)) {
342
+ other = new _SemVer(other, this.options);
343
+ }
344
+ let i = 0;
345
+ do {
346
+ const a = this.build[i];
347
+ const b = other.build[i];
348
+ debug("build compare", i, a, b);
349
+ if (a === void 0 && b === void 0) {
350
+ return 0;
351
+ } else if (b === void 0) {
352
+ return 1;
353
+ } else if (a === void 0) {
354
+ return -1;
355
+ } else if (a === b) {
356
+ continue;
357
+ } else {
358
+ return compareIdentifiers(a, b);
359
+ }
360
+ } while (++i);
361
+ }
362
+ // preminor will bump the version up to the next minor release, and immediately
363
+ // down to pre-release. premajor and prepatch work the same way.
364
+ inc(release, identifier, identifierBase) {
365
+ if (release.startsWith("pre")) {
366
+ if (!identifier && identifierBase === false) {
367
+ throw new Error("invalid increment argument: identifier is empty");
368
+ }
369
+ if (identifier) {
370
+ const match = `-${identifier}`.match(this.options.loose ? re[t.PRERELEASELOOSE] : re[t.PRERELEASE]);
371
+ if (!match || match[1] !== identifier) {
372
+ throw new Error(`invalid identifier: ${identifier}`);
373
+ }
374
+ }
375
+ }
376
+ switch (release) {
377
+ case "premajor":
378
+ this.prerelease.length = 0;
379
+ this.patch = 0;
380
+ this.minor = 0;
381
+ this.major++;
382
+ this.inc("pre", identifier, identifierBase);
383
+ break;
384
+ case "preminor":
385
+ this.prerelease.length = 0;
386
+ this.patch = 0;
387
+ this.minor++;
388
+ this.inc("pre", identifier, identifierBase);
389
+ break;
390
+ case "prepatch":
391
+ this.prerelease.length = 0;
392
+ this.inc("patch", identifier, identifierBase);
393
+ this.inc("pre", identifier, identifierBase);
394
+ break;
395
+ // If the input is a non-prerelease version, this acts the same as
396
+ // prepatch.
397
+ case "prerelease":
398
+ if (this.prerelease.length === 0) {
399
+ this.inc("patch", identifier, identifierBase);
400
+ }
401
+ this.inc("pre", identifier, identifierBase);
402
+ break;
403
+ case "release":
404
+ if (this.prerelease.length === 0) {
405
+ throw new Error(`version ${this.raw} is not a prerelease`);
406
+ }
407
+ this.prerelease.length = 0;
408
+ break;
409
+ case "major":
410
+ if (this.minor !== 0 || this.patch !== 0 || this.prerelease.length === 0) {
411
+ this.major++;
412
+ }
413
+ this.minor = 0;
414
+ this.patch = 0;
415
+ this.prerelease = [];
416
+ break;
417
+ case "minor":
418
+ if (this.patch !== 0 || this.prerelease.length === 0) {
419
+ this.minor++;
420
+ }
421
+ this.patch = 0;
422
+ this.prerelease = [];
423
+ break;
424
+ case "patch":
425
+ if (this.prerelease.length === 0) {
426
+ this.patch++;
427
+ }
428
+ this.prerelease = [];
429
+ break;
430
+ // This probably shouldn't be used publicly.
431
+ // 1.0.0 'pre' would become 1.0.0-0 which is the wrong direction.
432
+ case "pre": {
433
+ const base = Number(identifierBase) ? 1 : 0;
434
+ if (this.prerelease.length === 0) {
435
+ this.prerelease = [base];
436
+ } else {
437
+ let i = this.prerelease.length;
438
+ while (--i >= 0) {
439
+ if (typeof this.prerelease[i] === "number") {
440
+ this.prerelease[i]++;
441
+ i = -2;
442
+ }
443
+ }
444
+ if (i === -1) {
445
+ if (identifier === this.prerelease.join(".") && identifierBase === false) {
446
+ throw new Error("invalid increment argument: identifier already exists");
447
+ }
448
+ this.prerelease.push(base);
449
+ }
450
+ }
451
+ if (identifier) {
452
+ let prerelease = [identifier, base];
453
+ if (identifierBase === false) {
454
+ prerelease = [identifier];
455
+ }
456
+ if (compareIdentifiers(this.prerelease[0], identifier) === 0) {
457
+ if (isNaN(this.prerelease[1])) {
458
+ this.prerelease = prerelease;
459
+ }
460
+ } else {
461
+ this.prerelease = prerelease;
462
+ }
463
+ }
464
+ break;
465
+ }
466
+ default:
467
+ throw new Error(`invalid increment argument: ${release}`);
468
+ }
469
+ this.raw = this.format();
470
+ if (this.build.length) {
471
+ this.raw += `+${this.build.join(".")}`;
472
+ }
473
+ return this;
474
+ }
475
+ };
476
+ module.exports = SemVer;
477
+ }
478
+ });
479
+
480
+ // node_modules/semver/functions/parse.js
481
+ var require_parse = __commonJS({
482
+ "node_modules/semver/functions/parse.js"(exports, module) {
483
+ "use strict";
484
+ var SemVer = require_semver();
485
+ var parse = (version, options, throwErrors = false) => {
486
+ if (version instanceof SemVer) {
487
+ return version;
488
+ }
489
+ try {
490
+ return new SemVer(version, options);
491
+ } catch (er) {
492
+ if (!throwErrors) {
493
+ return null;
494
+ }
495
+ throw er;
496
+ }
497
+ };
498
+ module.exports = parse;
499
+ }
500
+ });
501
+
502
+ // node_modules/semver/functions/valid.js
503
+ var require_valid = __commonJS({
504
+ "node_modules/semver/functions/valid.js"(exports, module) {
505
+ "use strict";
506
+ var parse = require_parse();
507
+ var valid2 = (version, options) => {
508
+ const v = parse(version, options);
509
+ return v ? v.version : null;
510
+ };
511
+ module.exports = valid2;
512
+ }
513
+ });
514
+
515
+ // node_modules/semver/functions/clean.js
516
+ var require_clean = __commonJS({
517
+ "node_modules/semver/functions/clean.js"(exports, module) {
518
+ "use strict";
519
+ var parse = require_parse();
520
+ var clean = (version, options) => {
521
+ const s = parse(version.trim().replace(/^[=v]+/, ""), options);
522
+ return s ? s.version : null;
523
+ };
524
+ module.exports = clean;
525
+ }
526
+ });
527
+
528
+ // node_modules/semver/functions/inc.js
529
+ var require_inc = __commonJS({
530
+ "node_modules/semver/functions/inc.js"(exports, module) {
531
+ "use strict";
532
+ var SemVer = require_semver();
533
+ var inc = (version, release, options, identifier, identifierBase) => {
534
+ if (typeof options === "string") {
535
+ identifierBase = identifier;
536
+ identifier = options;
537
+ options = void 0;
538
+ }
539
+ try {
540
+ return new SemVer(
541
+ version instanceof SemVer ? version.version : version,
542
+ options
543
+ ).inc(release, identifier, identifierBase).version;
544
+ } catch (er) {
545
+ return null;
546
+ }
547
+ };
548
+ module.exports = inc;
549
+ }
550
+ });
551
+
552
+ // node_modules/semver/functions/diff.js
553
+ var require_diff = __commonJS({
554
+ "node_modules/semver/functions/diff.js"(exports, module) {
555
+ "use strict";
556
+ var parse = require_parse();
557
+ var diff = (version1, version2) => {
558
+ const v1 = parse(version1, null, true);
559
+ const v2 = parse(version2, null, true);
560
+ const comparison = v1.compare(v2);
561
+ if (comparison === 0) {
562
+ return null;
563
+ }
564
+ const v1Higher = comparison > 0;
565
+ const highVersion = v1Higher ? v1 : v2;
566
+ const lowVersion = v1Higher ? v2 : v1;
567
+ const highHasPre = !!highVersion.prerelease.length;
568
+ const lowHasPre = !!lowVersion.prerelease.length;
569
+ if (lowHasPre && !highHasPre) {
570
+ if (!lowVersion.patch && !lowVersion.minor) {
571
+ return "major";
572
+ }
573
+ if (lowVersion.compareMain(highVersion) === 0) {
574
+ if (lowVersion.minor && !lowVersion.patch) {
575
+ return "minor";
576
+ }
577
+ return "patch";
578
+ }
579
+ }
580
+ const prefix = highHasPre ? "pre" : "";
581
+ if (v1.major !== v2.major) {
582
+ return prefix + "major";
583
+ }
584
+ if (v1.minor !== v2.minor) {
585
+ return prefix + "minor";
586
+ }
587
+ if (v1.patch !== v2.patch) {
588
+ return prefix + "patch";
589
+ }
590
+ return "prerelease";
591
+ };
592
+ module.exports = diff;
593
+ }
594
+ });
595
+
596
+ // node_modules/semver/functions/major.js
597
+ var require_major = __commonJS({
598
+ "node_modules/semver/functions/major.js"(exports, module) {
599
+ "use strict";
600
+ var SemVer = require_semver();
601
+ var major = (a, loose) => new SemVer(a, loose).major;
602
+ module.exports = major;
603
+ }
604
+ });
605
+
606
+ // node_modules/semver/functions/minor.js
607
+ var require_minor = __commonJS({
608
+ "node_modules/semver/functions/minor.js"(exports, module) {
609
+ "use strict";
610
+ var SemVer = require_semver();
611
+ var minor = (a, loose) => new SemVer(a, loose).minor;
612
+ module.exports = minor;
613
+ }
614
+ });
615
+
616
+ // node_modules/semver/functions/patch.js
617
+ var require_patch = __commonJS({
618
+ "node_modules/semver/functions/patch.js"(exports, module) {
619
+ "use strict";
620
+ var SemVer = require_semver();
621
+ var patch = (a, loose) => new SemVer(a, loose).patch;
622
+ module.exports = patch;
623
+ }
624
+ });
625
+
626
+ // node_modules/semver/functions/prerelease.js
627
+ var require_prerelease = __commonJS({
628
+ "node_modules/semver/functions/prerelease.js"(exports, module) {
629
+ "use strict";
630
+ var parse = require_parse();
631
+ var prerelease = (version, options) => {
632
+ const parsed = parse(version, options);
633
+ return parsed && parsed.prerelease.length ? parsed.prerelease : null;
634
+ };
635
+ module.exports = prerelease;
636
+ }
637
+ });
638
+
639
+ // node_modules/semver/functions/compare.js
640
+ var require_compare = __commonJS({
641
+ "node_modules/semver/functions/compare.js"(exports, module) {
642
+ "use strict";
643
+ var SemVer = require_semver();
644
+ var compare = (a, b, loose) => new SemVer(a, loose).compare(new SemVer(b, loose));
645
+ module.exports = compare;
646
+ }
647
+ });
648
+
649
+ // node_modules/semver/functions/rcompare.js
650
+ var require_rcompare = __commonJS({
651
+ "node_modules/semver/functions/rcompare.js"(exports, module) {
652
+ "use strict";
653
+ var compare = require_compare();
654
+ var rcompare = (a, b, loose) => compare(b, a, loose);
655
+ module.exports = rcompare;
656
+ }
657
+ });
658
+
659
+ // node_modules/semver/functions/compare-loose.js
660
+ var require_compare_loose = __commonJS({
661
+ "node_modules/semver/functions/compare-loose.js"(exports, module) {
662
+ "use strict";
663
+ var compare = require_compare();
664
+ var compareLoose = (a, b) => compare(a, b, true);
665
+ module.exports = compareLoose;
666
+ }
667
+ });
668
+
669
+ // node_modules/semver/functions/compare-build.js
670
+ var require_compare_build = __commonJS({
671
+ "node_modules/semver/functions/compare-build.js"(exports, module) {
672
+ "use strict";
673
+ var SemVer = require_semver();
674
+ var compareBuild = (a, b, loose) => {
675
+ const versionA = new SemVer(a, loose);
676
+ const versionB = new SemVer(b, loose);
677
+ return versionA.compare(versionB) || versionA.compareBuild(versionB);
678
+ };
679
+ module.exports = compareBuild;
680
+ }
681
+ });
682
+
683
+ // node_modules/semver/functions/sort.js
684
+ var require_sort = __commonJS({
685
+ "node_modules/semver/functions/sort.js"(exports, module) {
686
+ "use strict";
687
+ var compareBuild = require_compare_build();
688
+ var sort = (list, loose) => list.sort((a, b) => compareBuild(a, b, loose));
689
+ module.exports = sort;
690
+ }
691
+ });
692
+
693
+ // node_modules/semver/functions/rsort.js
694
+ var require_rsort = __commonJS({
695
+ "node_modules/semver/functions/rsort.js"(exports, module) {
696
+ "use strict";
697
+ var compareBuild = require_compare_build();
698
+ var rsort = (list, loose) => list.sort((a, b) => compareBuild(b, a, loose));
699
+ module.exports = rsort;
700
+ }
701
+ });
702
+
703
+ // node_modules/semver/functions/gt.js
704
+ var require_gt = __commonJS({
705
+ "node_modules/semver/functions/gt.js"(exports, module) {
706
+ "use strict";
707
+ var compare = require_compare();
708
+ var gt = (a, b, loose) => compare(a, b, loose) > 0;
709
+ module.exports = gt;
710
+ }
711
+ });
712
+
713
+ // node_modules/semver/functions/lt.js
714
+ var require_lt = __commonJS({
715
+ "node_modules/semver/functions/lt.js"(exports, module) {
716
+ "use strict";
717
+ var compare = require_compare();
718
+ var lt = (a, b, loose) => compare(a, b, loose) < 0;
719
+ module.exports = lt;
720
+ }
721
+ });
722
+
723
+ // node_modules/semver/functions/eq.js
724
+ var require_eq = __commonJS({
725
+ "node_modules/semver/functions/eq.js"(exports, module) {
726
+ "use strict";
727
+ var compare = require_compare();
728
+ var eq = (a, b, loose) => compare(a, b, loose) === 0;
729
+ module.exports = eq;
730
+ }
731
+ });
732
+
733
+ // node_modules/semver/functions/neq.js
734
+ var require_neq = __commonJS({
735
+ "node_modules/semver/functions/neq.js"(exports, module) {
736
+ "use strict";
737
+ var compare = require_compare();
738
+ var neq = (a, b, loose) => compare(a, b, loose) !== 0;
739
+ module.exports = neq;
740
+ }
741
+ });
742
+
743
+ // node_modules/semver/functions/gte.js
744
+ var require_gte = __commonJS({
745
+ "node_modules/semver/functions/gte.js"(exports, module) {
746
+ "use strict";
747
+ var compare = require_compare();
748
+ var gte = (a, b, loose) => compare(a, b, loose) >= 0;
749
+ module.exports = gte;
750
+ }
751
+ });
752
+
753
+ // node_modules/semver/functions/lte.js
754
+ var require_lte = __commonJS({
755
+ "node_modules/semver/functions/lte.js"(exports, module) {
756
+ "use strict";
757
+ var compare = require_compare();
758
+ var lte = (a, b, loose) => compare(a, b, loose) <= 0;
759
+ module.exports = lte;
760
+ }
761
+ });
762
+
763
+ // node_modules/semver/functions/cmp.js
764
+ var require_cmp = __commonJS({
765
+ "node_modules/semver/functions/cmp.js"(exports, module) {
766
+ "use strict";
767
+ var eq = require_eq();
768
+ var neq = require_neq();
769
+ var gt = require_gt();
770
+ var gte = require_gte();
771
+ var lt = require_lt();
772
+ var lte = require_lte();
773
+ var cmp = (a, op, b, loose) => {
774
+ switch (op) {
775
+ case "===":
776
+ if (typeof a === "object") {
777
+ a = a.version;
778
+ }
779
+ if (typeof b === "object") {
780
+ b = b.version;
781
+ }
782
+ return a === b;
783
+ case "!==":
784
+ if (typeof a === "object") {
785
+ a = a.version;
786
+ }
787
+ if (typeof b === "object") {
788
+ b = b.version;
789
+ }
790
+ return a !== b;
791
+ case "":
792
+ case "=":
793
+ case "==":
794
+ return eq(a, b, loose);
795
+ case "!=":
796
+ return neq(a, b, loose);
797
+ case ">":
798
+ return gt(a, b, loose);
799
+ case ">=":
800
+ return gte(a, b, loose);
801
+ case "<":
802
+ return lt(a, b, loose);
803
+ case "<=":
804
+ return lte(a, b, loose);
805
+ default:
806
+ throw new TypeError(`Invalid operator: ${op}`);
807
+ }
808
+ };
809
+ module.exports = cmp;
810
+ }
811
+ });
812
+
813
+ // node_modules/semver/functions/coerce.js
814
+ var require_coerce = __commonJS({
815
+ "node_modules/semver/functions/coerce.js"(exports, module) {
816
+ "use strict";
817
+ var SemVer = require_semver();
818
+ var parse = require_parse();
819
+ var { safeRe: re, t } = require_re();
820
+ var coerce = (version, options) => {
821
+ if (version instanceof SemVer) {
822
+ return version;
823
+ }
824
+ if (typeof version === "number") {
825
+ version = String(version);
826
+ }
827
+ if (typeof version !== "string") {
828
+ return null;
829
+ }
830
+ options = options || {};
831
+ let match = null;
832
+ if (!options.rtl) {
833
+ match = version.match(options.includePrerelease ? re[t.COERCEFULL] : re[t.COERCE]);
834
+ } else {
835
+ const coerceRtlRegex = options.includePrerelease ? re[t.COERCERTLFULL] : re[t.COERCERTL];
836
+ let next;
837
+ while ((next = coerceRtlRegex.exec(version)) && (!match || match.index + match[0].length !== version.length)) {
838
+ if (!match || next.index + next[0].length !== match.index + match[0].length) {
839
+ match = next;
840
+ }
841
+ coerceRtlRegex.lastIndex = next.index + next[1].length + next[2].length;
842
+ }
843
+ coerceRtlRegex.lastIndex = -1;
844
+ }
845
+ if (match === null) {
846
+ return null;
847
+ }
848
+ const major = match[2];
849
+ const minor = match[3] || "0";
850
+ const patch = match[4] || "0";
851
+ const prerelease = options.includePrerelease && match[5] ? `-${match[5]}` : "";
852
+ const build = options.includePrerelease && match[6] ? `+${match[6]}` : "";
853
+ return parse(`${major}.${minor}.${patch}${prerelease}${build}`, options);
854
+ };
855
+ module.exports = coerce;
856
+ }
857
+ });
858
+
859
+ // node_modules/semver/internal/lrucache.js
860
+ var require_lrucache = __commonJS({
861
+ "node_modules/semver/internal/lrucache.js"(exports, module) {
862
+ "use strict";
863
+ var LRUCache = class {
864
+ constructor() {
865
+ this.max = 1e3;
866
+ this.map = /* @__PURE__ */ new Map();
867
+ }
868
+ get(key) {
869
+ const value = this.map.get(key);
870
+ if (value === void 0) {
871
+ return void 0;
872
+ } else {
873
+ this.map.delete(key);
874
+ this.map.set(key, value);
875
+ return value;
876
+ }
877
+ }
878
+ delete(key) {
879
+ return this.map.delete(key);
880
+ }
881
+ set(key, value) {
882
+ const deleted = this.delete(key);
883
+ if (!deleted && value !== void 0) {
884
+ if (this.map.size >= this.max) {
885
+ const firstKey = this.map.keys().next().value;
886
+ this.delete(firstKey);
887
+ }
888
+ this.map.set(key, value);
889
+ }
890
+ return this;
891
+ }
892
+ };
893
+ module.exports = LRUCache;
894
+ }
895
+ });
896
+
897
+ // node_modules/semver/classes/range.js
898
+ var require_range = __commonJS({
899
+ "node_modules/semver/classes/range.js"(exports, module) {
900
+ "use strict";
901
+ var SPACE_CHARACTERS = /\s+/g;
902
+ var Range = class _Range {
903
+ constructor(range, options) {
904
+ options = parseOptions(options);
905
+ if (range instanceof _Range) {
906
+ if (range.loose === !!options.loose && range.includePrerelease === !!options.includePrerelease) {
907
+ return range;
908
+ } else {
909
+ return new _Range(range.raw, options);
910
+ }
911
+ }
912
+ if (range instanceof Comparator) {
913
+ this.raw = range.value;
914
+ this.set = [[range]];
915
+ this.formatted = void 0;
916
+ return this;
917
+ }
918
+ this.options = options;
919
+ this.loose = !!options.loose;
920
+ this.includePrerelease = !!options.includePrerelease;
921
+ this.raw = range.trim().replace(SPACE_CHARACTERS, " ");
922
+ this.set = this.raw.split("||").map((r) => this.parseRange(r.trim())).filter((c) => c.length);
923
+ if (!this.set.length) {
924
+ throw new TypeError(`Invalid SemVer Range: ${this.raw}`);
925
+ }
926
+ if (this.set.length > 1) {
927
+ const first = this.set[0];
928
+ this.set = this.set.filter((c) => !isNullSet(c[0]));
929
+ if (this.set.length === 0) {
930
+ this.set = [first];
931
+ } else if (this.set.length > 1) {
932
+ for (const c of this.set) {
933
+ if (c.length === 1 && isAny(c[0])) {
934
+ this.set = [c];
935
+ break;
936
+ }
937
+ }
938
+ }
939
+ }
940
+ this.formatted = void 0;
941
+ }
942
+ get range() {
943
+ if (this.formatted === void 0) {
944
+ this.formatted = "";
945
+ for (let i = 0; i < this.set.length; i++) {
946
+ if (i > 0) {
947
+ this.formatted += "||";
948
+ }
949
+ const comps = this.set[i];
950
+ for (let k = 0; k < comps.length; k++) {
951
+ if (k > 0) {
952
+ this.formatted += " ";
953
+ }
954
+ this.formatted += comps[k].toString().trim();
955
+ }
956
+ }
957
+ }
958
+ return this.formatted;
959
+ }
960
+ format() {
961
+ return this.range;
962
+ }
963
+ toString() {
964
+ return this.range;
965
+ }
966
+ parseRange(range) {
967
+ const memoOpts = (this.options.includePrerelease && FLAG_INCLUDE_PRERELEASE) | (this.options.loose && FLAG_LOOSE);
968
+ const memoKey = memoOpts + ":" + range;
969
+ const cached = cache2.get(memoKey);
970
+ if (cached) {
971
+ return cached;
972
+ }
973
+ const loose = this.options.loose;
974
+ const hr = loose ? re[t.HYPHENRANGELOOSE] : re[t.HYPHENRANGE];
975
+ range = range.replace(hr, hyphenReplace(this.options.includePrerelease));
976
+ debug("hyphen replace", range);
977
+ range = range.replace(re[t.COMPARATORTRIM], comparatorTrimReplace);
978
+ debug("comparator trim", range);
979
+ range = range.replace(re[t.TILDETRIM], tildeTrimReplace);
980
+ debug("tilde trim", range);
981
+ range = range.replace(re[t.CARETTRIM], caretTrimReplace);
982
+ debug("caret trim", range);
983
+ let rangeList = range.split(" ").map((comp) => parseComparator(comp, this.options)).join(" ").split(/\s+/).map((comp) => replaceGTE0(comp, this.options));
984
+ if (loose) {
985
+ rangeList = rangeList.filter((comp) => {
986
+ debug("loose invalid filter", comp, this.options);
987
+ return !!comp.match(re[t.COMPARATORLOOSE]);
988
+ });
989
+ }
990
+ debug("range list", rangeList);
991
+ const rangeMap = /* @__PURE__ */ new Map();
992
+ const comparators = rangeList.map((comp) => new Comparator(comp, this.options));
993
+ for (const comp of comparators) {
994
+ if (isNullSet(comp)) {
995
+ return [comp];
996
+ }
997
+ rangeMap.set(comp.value, comp);
998
+ }
999
+ if (rangeMap.size > 1 && rangeMap.has("")) {
1000
+ rangeMap.delete("");
1001
+ }
1002
+ const result = [...rangeMap.values()];
1003
+ cache2.set(memoKey, result);
1004
+ return result;
1005
+ }
1006
+ intersects(range, options) {
1007
+ if (!(range instanceof _Range)) {
1008
+ throw new TypeError("a Range is required");
1009
+ }
1010
+ return this.set.some((thisComparators) => {
1011
+ return isSatisfiable(thisComparators, options) && range.set.some((rangeComparators) => {
1012
+ return isSatisfiable(rangeComparators, options) && thisComparators.every((thisComparator) => {
1013
+ return rangeComparators.every((rangeComparator) => {
1014
+ return thisComparator.intersects(rangeComparator, options);
1015
+ });
1016
+ });
1017
+ });
1018
+ });
1019
+ }
1020
+ // if ANY of the sets match ALL of its comparators, then pass
1021
+ test(version) {
1022
+ if (!version) {
1023
+ return false;
1024
+ }
1025
+ if (typeof version === "string") {
1026
+ try {
1027
+ version = new SemVer(version, this.options);
1028
+ } catch (er) {
1029
+ return false;
1030
+ }
1031
+ }
1032
+ for (let i = 0; i < this.set.length; i++) {
1033
+ if (testSet(this.set[i], version, this.options)) {
1034
+ return true;
1035
+ }
1036
+ }
1037
+ return false;
1038
+ }
1039
+ };
1040
+ module.exports = Range;
1041
+ var LRU = require_lrucache();
1042
+ var cache2 = new LRU();
1043
+ var parseOptions = require_parse_options();
1044
+ var Comparator = require_comparator();
1045
+ var debug = require_debug();
1046
+ var SemVer = require_semver();
1047
+ var {
1048
+ safeRe: re,
1049
+ t,
1050
+ comparatorTrimReplace,
1051
+ tildeTrimReplace,
1052
+ caretTrimReplace
1053
+ } = require_re();
1054
+ var { FLAG_INCLUDE_PRERELEASE, FLAG_LOOSE } = require_constants();
1055
+ var isNullSet = (c) => c.value === "<0.0.0-0";
1056
+ var isAny = (c) => c.value === "";
1057
+ var isSatisfiable = (comparators, options) => {
1058
+ let result = true;
1059
+ const remainingComparators = comparators.slice();
1060
+ let testComparator = remainingComparators.pop();
1061
+ while (result && remainingComparators.length) {
1062
+ result = remainingComparators.every((otherComparator) => {
1063
+ return testComparator.intersects(otherComparator, options);
1064
+ });
1065
+ testComparator = remainingComparators.pop();
1066
+ }
1067
+ return result;
1068
+ };
1069
+ var parseComparator = (comp, options) => {
1070
+ comp = comp.replace(re[t.BUILD], "");
1071
+ debug("comp", comp, options);
1072
+ comp = replaceCarets(comp, options);
1073
+ debug("caret", comp);
1074
+ comp = replaceTildes(comp, options);
1075
+ debug("tildes", comp);
1076
+ comp = replaceXRanges(comp, options);
1077
+ debug("xrange", comp);
1078
+ comp = replaceStars(comp, options);
1079
+ debug("stars", comp);
1080
+ return comp;
1081
+ };
1082
+ var isX = (id) => !id || id.toLowerCase() === "x" || id === "*";
1083
+ var replaceTildes = (comp, options) => {
1084
+ return comp.trim().split(/\s+/).map((c) => replaceTilde(c, options)).join(" ");
1085
+ };
1086
+ var replaceTilde = (comp, options) => {
1087
+ const r = options.loose ? re[t.TILDELOOSE] : re[t.TILDE];
1088
+ return comp.replace(r, (_, M, m, p, pr) => {
1089
+ debug("tilde", comp, _, M, m, p, pr);
1090
+ let ret;
1091
+ if (isX(M)) {
1092
+ ret = "";
1093
+ } else if (isX(m)) {
1094
+ ret = `>=${M}.0.0 <${+M + 1}.0.0-0`;
1095
+ } else if (isX(p)) {
1096
+ ret = `>=${M}.${m}.0 <${M}.${+m + 1}.0-0`;
1097
+ } else if (pr) {
1098
+ debug("replaceTilde pr", pr);
1099
+ ret = `>=${M}.${m}.${p}-${pr} <${M}.${+m + 1}.0-0`;
1100
+ } else {
1101
+ ret = `>=${M}.${m}.${p} <${M}.${+m + 1}.0-0`;
1102
+ }
1103
+ debug("tilde return", ret);
1104
+ return ret;
1105
+ });
1106
+ };
1107
+ var replaceCarets = (comp, options) => {
1108
+ return comp.trim().split(/\s+/).map((c) => replaceCaret(c, options)).join(" ");
1109
+ };
1110
+ var replaceCaret = (comp, options) => {
1111
+ debug("caret", comp, options);
1112
+ const r = options.loose ? re[t.CARETLOOSE] : re[t.CARET];
1113
+ const z = options.includePrerelease ? "-0" : "";
1114
+ return comp.replace(r, (_, M, m, p, pr) => {
1115
+ debug("caret", comp, _, M, m, p, pr);
1116
+ let ret;
1117
+ if (isX(M)) {
1118
+ ret = "";
1119
+ } else if (isX(m)) {
1120
+ ret = `>=${M}.0.0${z} <${+M + 1}.0.0-0`;
1121
+ } else if (isX(p)) {
1122
+ if (M === "0") {
1123
+ ret = `>=${M}.${m}.0${z} <${M}.${+m + 1}.0-0`;
1124
+ } else {
1125
+ ret = `>=${M}.${m}.0${z} <${+M + 1}.0.0-0`;
1126
+ }
1127
+ } else if (pr) {
1128
+ debug("replaceCaret pr", pr);
1129
+ if (M === "0") {
1130
+ if (m === "0") {
1131
+ ret = `>=${M}.${m}.${p}-${pr} <${M}.${m}.${+p + 1}-0`;
1132
+ } else {
1133
+ ret = `>=${M}.${m}.${p}-${pr} <${M}.${+m + 1}.0-0`;
1134
+ }
1135
+ } else {
1136
+ ret = `>=${M}.${m}.${p}-${pr} <${+M + 1}.0.0-0`;
1137
+ }
1138
+ } else {
1139
+ debug("no pr");
1140
+ if (M === "0") {
1141
+ if (m === "0") {
1142
+ ret = `>=${M}.${m}.${p}${z} <${M}.${m}.${+p + 1}-0`;
1143
+ } else {
1144
+ ret = `>=${M}.${m}.${p}${z} <${M}.${+m + 1}.0-0`;
1145
+ }
1146
+ } else {
1147
+ ret = `>=${M}.${m}.${p} <${+M + 1}.0.0-0`;
1148
+ }
1149
+ }
1150
+ debug("caret return", ret);
1151
+ return ret;
1152
+ });
1153
+ };
1154
+ var replaceXRanges = (comp, options) => {
1155
+ debug("replaceXRanges", comp, options);
1156
+ return comp.split(/\s+/).map((c) => replaceXRange(c, options)).join(" ");
1157
+ };
1158
+ var replaceXRange = (comp, options) => {
1159
+ comp = comp.trim();
1160
+ const r = options.loose ? re[t.XRANGELOOSE] : re[t.XRANGE];
1161
+ return comp.replace(r, (ret, gtlt, M, m, p, pr) => {
1162
+ debug("xRange", comp, ret, gtlt, M, m, p, pr);
1163
+ const xM = isX(M);
1164
+ const xm = xM || isX(m);
1165
+ const xp = xm || isX(p);
1166
+ const anyX = xp;
1167
+ if (gtlt === "=" && anyX) {
1168
+ gtlt = "";
1169
+ }
1170
+ pr = options.includePrerelease ? "-0" : "";
1171
+ if (xM) {
1172
+ if (gtlt === ">" || gtlt === "<") {
1173
+ ret = "<0.0.0-0";
1174
+ } else {
1175
+ ret = "*";
1176
+ }
1177
+ } else if (gtlt && anyX) {
1178
+ if (xm) {
1179
+ m = 0;
1180
+ }
1181
+ p = 0;
1182
+ if (gtlt === ">") {
1183
+ gtlt = ">=";
1184
+ if (xm) {
1185
+ M = +M + 1;
1186
+ m = 0;
1187
+ p = 0;
1188
+ } else {
1189
+ m = +m + 1;
1190
+ p = 0;
1191
+ }
1192
+ } else if (gtlt === "<=") {
1193
+ gtlt = "<";
1194
+ if (xm) {
1195
+ M = +M + 1;
1196
+ } else {
1197
+ m = +m + 1;
1198
+ }
1199
+ }
1200
+ if (gtlt === "<") {
1201
+ pr = "-0";
1202
+ }
1203
+ ret = `${gtlt + M}.${m}.${p}${pr}`;
1204
+ } else if (xm) {
1205
+ ret = `>=${M}.0.0${pr} <${+M + 1}.0.0-0`;
1206
+ } else if (xp) {
1207
+ ret = `>=${M}.${m}.0${pr} <${M}.${+m + 1}.0-0`;
1208
+ }
1209
+ debug("xRange return", ret);
1210
+ return ret;
1211
+ });
1212
+ };
1213
+ var replaceStars = (comp, options) => {
1214
+ debug("replaceStars", comp, options);
1215
+ return comp.trim().replace(re[t.STAR], "");
1216
+ };
1217
+ var replaceGTE0 = (comp, options) => {
1218
+ debug("replaceGTE0", comp, options);
1219
+ return comp.trim().replace(re[options.includePrerelease ? t.GTE0PRE : t.GTE0], "");
1220
+ };
1221
+ var hyphenReplace = (incPr) => ($0, from, fM, fm, fp, fpr, fb, to, tM, tm, tp, tpr) => {
1222
+ if (isX(fM)) {
1223
+ from = "";
1224
+ } else if (isX(fm)) {
1225
+ from = `>=${fM}.0.0${incPr ? "-0" : ""}`;
1226
+ } else if (isX(fp)) {
1227
+ from = `>=${fM}.${fm}.0${incPr ? "-0" : ""}`;
1228
+ } else if (fpr) {
1229
+ from = `>=${from}`;
1230
+ } else {
1231
+ from = `>=${from}${incPr ? "-0" : ""}`;
1232
+ }
1233
+ if (isX(tM)) {
1234
+ to = "";
1235
+ } else if (isX(tm)) {
1236
+ to = `<${+tM + 1}.0.0-0`;
1237
+ } else if (isX(tp)) {
1238
+ to = `<${tM}.${+tm + 1}.0-0`;
1239
+ } else if (tpr) {
1240
+ to = `<=${tM}.${tm}.${tp}-${tpr}`;
1241
+ } else if (incPr) {
1242
+ to = `<${tM}.${tm}.${+tp + 1}-0`;
1243
+ } else {
1244
+ to = `<=${to}`;
1245
+ }
1246
+ return `${from} ${to}`.trim();
1247
+ };
1248
+ var testSet = (set, version, options) => {
1249
+ for (let i = 0; i < set.length; i++) {
1250
+ if (!set[i].test(version)) {
1251
+ return false;
1252
+ }
1253
+ }
1254
+ if (version.prerelease.length && !options.includePrerelease) {
1255
+ for (let i = 0; i < set.length; i++) {
1256
+ debug(set[i].semver);
1257
+ if (set[i].semver === Comparator.ANY) {
1258
+ continue;
1259
+ }
1260
+ if (set[i].semver.prerelease.length > 0) {
1261
+ const allowed = set[i].semver;
1262
+ if (allowed.major === version.major && allowed.minor === version.minor && allowed.patch === version.patch) {
1263
+ return true;
1264
+ }
1265
+ }
1266
+ }
1267
+ return false;
1268
+ }
1269
+ return true;
1270
+ };
1271
+ }
1272
+ });
1273
+
1274
+ // node_modules/semver/classes/comparator.js
1275
+ var require_comparator = __commonJS({
1276
+ "node_modules/semver/classes/comparator.js"(exports, module) {
1277
+ "use strict";
1278
+ var ANY = /* @__PURE__ */ Symbol("SemVer ANY");
1279
+ var Comparator = class _Comparator {
1280
+ static get ANY() {
1281
+ return ANY;
1282
+ }
1283
+ constructor(comp, options) {
1284
+ options = parseOptions(options);
1285
+ if (comp instanceof _Comparator) {
1286
+ if (comp.loose === !!options.loose) {
1287
+ return comp;
1288
+ } else {
1289
+ comp = comp.value;
1290
+ }
1291
+ }
1292
+ comp = comp.trim().split(/\s+/).join(" ");
1293
+ debug("comparator", comp, options);
1294
+ this.options = options;
1295
+ this.loose = !!options.loose;
1296
+ this.parse(comp);
1297
+ if (this.semver === ANY) {
1298
+ this.value = "";
1299
+ } else {
1300
+ this.value = this.operator + this.semver.version;
1301
+ }
1302
+ debug("comp", this);
1303
+ }
1304
+ parse(comp) {
1305
+ const r = this.options.loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR];
1306
+ const m = comp.match(r);
1307
+ if (!m) {
1308
+ throw new TypeError(`Invalid comparator: ${comp}`);
1309
+ }
1310
+ this.operator = m[1] !== void 0 ? m[1] : "";
1311
+ if (this.operator === "=") {
1312
+ this.operator = "";
1313
+ }
1314
+ if (!m[2]) {
1315
+ this.semver = ANY;
1316
+ } else {
1317
+ this.semver = new SemVer(m[2], this.options.loose);
1318
+ }
1319
+ }
1320
+ toString() {
1321
+ return this.value;
1322
+ }
1323
+ test(version) {
1324
+ debug("Comparator.test", version, this.options.loose);
1325
+ if (this.semver === ANY || version === ANY) {
1326
+ return true;
1327
+ }
1328
+ if (typeof version === "string") {
1329
+ try {
1330
+ version = new SemVer(version, this.options);
1331
+ } catch (er) {
1332
+ return false;
1333
+ }
1334
+ }
1335
+ return cmp(version, this.operator, this.semver, this.options);
1336
+ }
1337
+ intersects(comp, options) {
1338
+ if (!(comp instanceof _Comparator)) {
1339
+ throw new TypeError("a Comparator is required");
1340
+ }
1341
+ if (this.operator === "") {
1342
+ if (this.value === "") {
1343
+ return true;
1344
+ }
1345
+ return new Range(comp.value, options).test(this.value);
1346
+ } else if (comp.operator === "") {
1347
+ if (comp.value === "") {
1348
+ return true;
1349
+ }
1350
+ return new Range(this.value, options).test(comp.semver);
1351
+ }
1352
+ options = parseOptions(options);
1353
+ if (options.includePrerelease && (this.value === "<0.0.0-0" || comp.value === "<0.0.0-0")) {
1354
+ return false;
1355
+ }
1356
+ if (!options.includePrerelease && (this.value.startsWith("<0.0.0") || comp.value.startsWith("<0.0.0"))) {
1357
+ return false;
1358
+ }
1359
+ if (this.operator.startsWith(">") && comp.operator.startsWith(">")) {
1360
+ return true;
1361
+ }
1362
+ if (this.operator.startsWith("<") && comp.operator.startsWith("<")) {
1363
+ return true;
1364
+ }
1365
+ if (this.semver.version === comp.semver.version && this.operator.includes("=") && comp.operator.includes("=")) {
1366
+ return true;
1367
+ }
1368
+ if (cmp(this.semver, "<", comp.semver, options) && this.operator.startsWith(">") && comp.operator.startsWith("<")) {
1369
+ return true;
1370
+ }
1371
+ if (cmp(this.semver, ">", comp.semver, options) && this.operator.startsWith("<") && comp.operator.startsWith(">")) {
1372
+ return true;
1373
+ }
1374
+ return false;
1375
+ }
1376
+ };
1377
+ module.exports = Comparator;
1378
+ var parseOptions = require_parse_options();
1379
+ var { safeRe: re, t } = require_re();
1380
+ var cmp = require_cmp();
1381
+ var debug = require_debug();
1382
+ var SemVer = require_semver();
1383
+ var Range = require_range();
1384
+ }
1385
+ });
1386
+
1387
+ // node_modules/semver/functions/satisfies.js
1388
+ var require_satisfies = __commonJS({
1389
+ "node_modules/semver/functions/satisfies.js"(exports, module) {
1390
+ "use strict";
1391
+ var Range = require_range();
1392
+ var satisfies2 = (version, range, options) => {
1393
+ try {
1394
+ range = new Range(range, options);
1395
+ } catch (er) {
1396
+ return false;
1397
+ }
1398
+ return range.test(version);
1399
+ };
1400
+ module.exports = satisfies2;
1401
+ }
1402
+ });
1403
+
1404
+ // node_modules/semver/ranges/to-comparators.js
1405
+ var require_to_comparators = __commonJS({
1406
+ "node_modules/semver/ranges/to-comparators.js"(exports, module) {
1407
+ "use strict";
1408
+ var Range = require_range();
1409
+ var toComparators = (range, options) => new Range(range, options).set.map((comp) => comp.map((c) => c.value).join(" ").trim().split(" "));
1410
+ module.exports = toComparators;
1411
+ }
1412
+ });
1413
+
1414
+ // node_modules/semver/ranges/max-satisfying.js
1415
+ var require_max_satisfying = __commonJS({
1416
+ "node_modules/semver/ranges/max-satisfying.js"(exports, module) {
1417
+ "use strict";
1418
+ var SemVer = require_semver();
1419
+ var Range = require_range();
1420
+ var maxSatisfying = (versions, range, options) => {
1421
+ let max = null;
1422
+ let maxSV = null;
1423
+ let rangeObj = null;
1424
+ try {
1425
+ rangeObj = new Range(range, options);
1426
+ } catch (er) {
1427
+ return null;
1428
+ }
1429
+ versions.forEach((v) => {
1430
+ if (rangeObj.test(v)) {
1431
+ if (!max || maxSV.compare(v) === -1) {
1432
+ max = v;
1433
+ maxSV = new SemVer(max, options);
1434
+ }
1435
+ }
1436
+ });
1437
+ return max;
1438
+ };
1439
+ module.exports = maxSatisfying;
1440
+ }
1441
+ });
1442
+
1443
+ // node_modules/semver/ranges/min-satisfying.js
1444
+ var require_min_satisfying = __commonJS({
1445
+ "node_modules/semver/ranges/min-satisfying.js"(exports, module) {
1446
+ "use strict";
1447
+ var SemVer = require_semver();
1448
+ var Range = require_range();
1449
+ var minSatisfying = (versions, range, options) => {
1450
+ let min = null;
1451
+ let minSV = null;
1452
+ let rangeObj = null;
1453
+ try {
1454
+ rangeObj = new Range(range, options);
1455
+ } catch (er) {
1456
+ return null;
1457
+ }
1458
+ versions.forEach((v) => {
1459
+ if (rangeObj.test(v)) {
1460
+ if (!min || minSV.compare(v) === 1) {
1461
+ min = v;
1462
+ minSV = new SemVer(min, options);
1463
+ }
1464
+ }
1465
+ });
1466
+ return min;
1467
+ };
1468
+ module.exports = minSatisfying;
1469
+ }
1470
+ });
1471
+
1472
+ // node_modules/semver/ranges/min-version.js
1473
+ var require_min_version = __commonJS({
1474
+ "node_modules/semver/ranges/min-version.js"(exports, module) {
1475
+ "use strict";
1476
+ var SemVer = require_semver();
1477
+ var Range = require_range();
1478
+ var gt = require_gt();
1479
+ var minVersion = (range, loose) => {
1480
+ range = new Range(range, loose);
1481
+ let minver = new SemVer("0.0.0");
1482
+ if (range.test(minver)) {
1483
+ return minver;
1484
+ }
1485
+ minver = new SemVer("0.0.0-0");
1486
+ if (range.test(minver)) {
1487
+ return minver;
1488
+ }
1489
+ minver = null;
1490
+ for (let i = 0; i < range.set.length; ++i) {
1491
+ const comparators = range.set[i];
1492
+ let setMin = null;
1493
+ comparators.forEach((comparator) => {
1494
+ const compver = new SemVer(comparator.semver.version);
1495
+ switch (comparator.operator) {
1496
+ case ">":
1497
+ if (compver.prerelease.length === 0) {
1498
+ compver.patch++;
1499
+ } else {
1500
+ compver.prerelease.push(0);
1501
+ }
1502
+ compver.raw = compver.format();
1503
+ /* fallthrough */
1504
+ case "":
1505
+ case ">=":
1506
+ if (!setMin || gt(compver, setMin)) {
1507
+ setMin = compver;
1508
+ }
1509
+ break;
1510
+ case "<":
1511
+ case "<=":
1512
+ break;
1513
+ /* istanbul ignore next */
1514
+ default:
1515
+ throw new Error(`Unexpected operation: ${comparator.operator}`);
1516
+ }
1517
+ });
1518
+ if (setMin && (!minver || gt(minver, setMin))) {
1519
+ minver = setMin;
1520
+ }
1521
+ }
1522
+ if (minver && range.test(minver)) {
1523
+ return minver;
1524
+ }
1525
+ return null;
1526
+ };
1527
+ module.exports = minVersion;
1528
+ }
1529
+ });
1530
+
1531
+ // node_modules/semver/ranges/valid.js
1532
+ var require_valid2 = __commonJS({
1533
+ "node_modules/semver/ranges/valid.js"(exports, module) {
1534
+ "use strict";
1535
+ var Range = require_range();
1536
+ var validRange = (range, options) => {
1537
+ try {
1538
+ return new Range(range, options).range || "*";
1539
+ } catch (er) {
1540
+ return null;
1541
+ }
1542
+ };
1543
+ module.exports = validRange;
1544
+ }
1545
+ });
1546
+
1547
+ // node_modules/semver/ranges/outside.js
1548
+ var require_outside = __commonJS({
1549
+ "node_modules/semver/ranges/outside.js"(exports, module) {
1550
+ "use strict";
1551
+ var SemVer = require_semver();
1552
+ var Comparator = require_comparator();
1553
+ var { ANY } = Comparator;
1554
+ var Range = require_range();
1555
+ var satisfies2 = require_satisfies();
1556
+ var gt = require_gt();
1557
+ var lt = require_lt();
1558
+ var lte = require_lte();
1559
+ var gte = require_gte();
1560
+ var outside = (version, range, hilo, options) => {
1561
+ version = new SemVer(version, options);
1562
+ range = new Range(range, options);
1563
+ let gtfn, ltefn, ltfn, comp, ecomp;
1564
+ switch (hilo) {
1565
+ case ">":
1566
+ gtfn = gt;
1567
+ ltefn = lte;
1568
+ ltfn = lt;
1569
+ comp = ">";
1570
+ ecomp = ">=";
1571
+ break;
1572
+ case "<":
1573
+ gtfn = lt;
1574
+ ltefn = gte;
1575
+ ltfn = gt;
1576
+ comp = "<";
1577
+ ecomp = "<=";
1578
+ break;
1579
+ default:
1580
+ throw new TypeError('Must provide a hilo val of "<" or ">"');
1581
+ }
1582
+ if (satisfies2(version, range, options)) {
1583
+ return false;
1584
+ }
1585
+ for (let i = 0; i < range.set.length; ++i) {
1586
+ const comparators = range.set[i];
1587
+ let high = null;
1588
+ let low = null;
1589
+ comparators.forEach((comparator) => {
1590
+ if (comparator.semver === ANY) {
1591
+ comparator = new Comparator(">=0.0.0");
1592
+ }
1593
+ high = high || comparator;
1594
+ low = low || comparator;
1595
+ if (gtfn(comparator.semver, high.semver, options)) {
1596
+ high = comparator;
1597
+ } else if (ltfn(comparator.semver, low.semver, options)) {
1598
+ low = comparator;
1599
+ }
1600
+ });
1601
+ if (high.operator === comp || high.operator === ecomp) {
1602
+ return false;
1603
+ }
1604
+ if ((!low.operator || low.operator === comp) && ltefn(version, low.semver)) {
1605
+ return false;
1606
+ } else if (low.operator === ecomp && ltfn(version, low.semver)) {
1607
+ return false;
1608
+ }
1609
+ }
1610
+ return true;
1611
+ };
1612
+ module.exports = outside;
1613
+ }
1614
+ });
1615
+
1616
+ // node_modules/semver/ranges/gtr.js
1617
+ var require_gtr = __commonJS({
1618
+ "node_modules/semver/ranges/gtr.js"(exports, module) {
1619
+ "use strict";
1620
+ var outside = require_outside();
1621
+ var gtr = (version, range, options) => outside(version, range, ">", options);
1622
+ module.exports = gtr;
1623
+ }
1624
+ });
1625
+
1626
+ // node_modules/semver/ranges/ltr.js
1627
+ var require_ltr = __commonJS({
1628
+ "node_modules/semver/ranges/ltr.js"(exports, module) {
1629
+ "use strict";
1630
+ var outside = require_outside();
1631
+ var ltr = (version, range, options) => outside(version, range, "<", options);
1632
+ module.exports = ltr;
1633
+ }
1634
+ });
1635
+
1636
+ // node_modules/semver/ranges/intersects.js
1637
+ var require_intersects = __commonJS({
1638
+ "node_modules/semver/ranges/intersects.js"(exports, module) {
1639
+ "use strict";
1640
+ var Range = require_range();
1641
+ var intersects = (r1, r2, options) => {
1642
+ r1 = new Range(r1, options);
1643
+ r2 = new Range(r2, options);
1644
+ return r1.intersects(r2, options);
1645
+ };
1646
+ module.exports = intersects;
1647
+ }
1648
+ });
1649
+
1650
+ // node_modules/semver/ranges/simplify.js
1651
+ var require_simplify = __commonJS({
1652
+ "node_modules/semver/ranges/simplify.js"(exports, module) {
1653
+ "use strict";
1654
+ var satisfies2 = require_satisfies();
1655
+ var compare = require_compare();
1656
+ module.exports = (versions, range, options) => {
1657
+ const set = [];
1658
+ let first = null;
1659
+ let prev = null;
1660
+ const v = versions.sort((a, b) => compare(a, b, options));
1661
+ for (const version of v) {
1662
+ const included = satisfies2(version, range, options);
1663
+ if (included) {
1664
+ prev = version;
1665
+ if (!first) {
1666
+ first = version;
1667
+ }
1668
+ } else {
1669
+ if (prev) {
1670
+ set.push([first, prev]);
1671
+ }
1672
+ prev = null;
1673
+ first = null;
1674
+ }
1675
+ }
1676
+ if (first) {
1677
+ set.push([first, null]);
1678
+ }
1679
+ const ranges = [];
1680
+ for (const [min, max] of set) {
1681
+ if (min === max) {
1682
+ ranges.push(min);
1683
+ } else if (!max && min === v[0]) {
1684
+ ranges.push("*");
1685
+ } else if (!max) {
1686
+ ranges.push(`>=${min}`);
1687
+ } else if (min === v[0]) {
1688
+ ranges.push(`<=${max}`);
1689
+ } else {
1690
+ ranges.push(`${min} - ${max}`);
1691
+ }
1692
+ }
1693
+ const simplified = ranges.join(" || ");
1694
+ const original = typeof range.raw === "string" ? range.raw : String(range);
1695
+ return simplified.length < original.length ? simplified : range;
1696
+ };
1697
+ }
1698
+ });
1699
+
1700
+ // node_modules/semver/ranges/subset.js
1701
+ var require_subset = __commonJS({
1702
+ "node_modules/semver/ranges/subset.js"(exports, module) {
1703
+ "use strict";
1704
+ var Range = require_range();
1705
+ var Comparator = require_comparator();
1706
+ var { ANY } = Comparator;
1707
+ var satisfies2 = require_satisfies();
1708
+ var compare = require_compare();
1709
+ var subset = (sub, dom, options = {}) => {
1710
+ if (sub === dom) {
1711
+ return true;
1712
+ }
1713
+ sub = new Range(sub, options);
1714
+ dom = new Range(dom, options);
1715
+ let sawNonNull = false;
1716
+ OUTER: for (const simpleSub of sub.set) {
1717
+ for (const simpleDom of dom.set) {
1718
+ const isSub = simpleSubset(simpleSub, simpleDom, options);
1719
+ sawNonNull = sawNonNull || isSub !== null;
1720
+ if (isSub) {
1721
+ continue OUTER;
1722
+ }
1723
+ }
1724
+ if (sawNonNull) {
1725
+ return false;
1726
+ }
1727
+ }
1728
+ return true;
1729
+ };
1730
+ var minimumVersionWithPreRelease = [new Comparator(">=0.0.0-0")];
1731
+ var minimumVersion = [new Comparator(">=0.0.0")];
1732
+ var simpleSubset = (sub, dom, options) => {
1733
+ if (sub === dom) {
1734
+ return true;
1735
+ }
1736
+ if (sub.length === 1 && sub[0].semver === ANY) {
1737
+ if (dom.length === 1 && dom[0].semver === ANY) {
1738
+ return true;
1739
+ } else if (options.includePrerelease) {
1740
+ sub = minimumVersionWithPreRelease;
1741
+ } else {
1742
+ sub = minimumVersion;
1743
+ }
1744
+ }
1745
+ if (dom.length === 1 && dom[0].semver === ANY) {
1746
+ if (options.includePrerelease) {
1747
+ return true;
1748
+ } else {
1749
+ dom = minimumVersion;
1750
+ }
1751
+ }
1752
+ const eqSet = /* @__PURE__ */ new Set();
1753
+ let gt, lt;
1754
+ for (const c of sub) {
1755
+ if (c.operator === ">" || c.operator === ">=") {
1756
+ gt = higherGT(gt, c, options);
1757
+ } else if (c.operator === "<" || c.operator === "<=") {
1758
+ lt = lowerLT(lt, c, options);
1759
+ } else {
1760
+ eqSet.add(c.semver);
1761
+ }
1762
+ }
1763
+ if (eqSet.size > 1) {
1764
+ return null;
1765
+ }
1766
+ let gtltComp;
1767
+ if (gt && lt) {
1768
+ gtltComp = compare(gt.semver, lt.semver, options);
1769
+ if (gtltComp > 0) {
1770
+ return null;
1771
+ } else if (gtltComp === 0 && (gt.operator !== ">=" || lt.operator !== "<=")) {
1772
+ return null;
1773
+ }
1774
+ }
1775
+ for (const eq of eqSet) {
1776
+ if (gt && !satisfies2(eq, String(gt), options)) {
1777
+ return null;
1778
+ }
1779
+ if (lt && !satisfies2(eq, String(lt), options)) {
1780
+ return null;
1781
+ }
1782
+ for (const c of dom) {
1783
+ if (!satisfies2(eq, String(c), options)) {
1784
+ return false;
1785
+ }
1786
+ }
1787
+ return true;
1788
+ }
1789
+ let higher, lower;
1790
+ let hasDomLT, hasDomGT;
1791
+ let needDomLTPre = lt && !options.includePrerelease && lt.semver.prerelease.length ? lt.semver : false;
1792
+ let needDomGTPre = gt && !options.includePrerelease && gt.semver.prerelease.length ? gt.semver : false;
1793
+ if (needDomLTPre && needDomLTPre.prerelease.length === 1 && lt.operator === "<" && needDomLTPre.prerelease[0] === 0) {
1794
+ needDomLTPre = false;
1795
+ }
1796
+ for (const c of dom) {
1797
+ hasDomGT = hasDomGT || c.operator === ">" || c.operator === ">=";
1798
+ hasDomLT = hasDomLT || c.operator === "<" || c.operator === "<=";
1799
+ if (gt) {
1800
+ if (needDomGTPre) {
1801
+ if (c.semver.prerelease && c.semver.prerelease.length && c.semver.major === needDomGTPre.major && c.semver.minor === needDomGTPre.minor && c.semver.patch === needDomGTPre.patch) {
1802
+ needDomGTPre = false;
1803
+ }
1804
+ }
1805
+ if (c.operator === ">" || c.operator === ">=") {
1806
+ higher = higherGT(gt, c, options);
1807
+ if (higher === c && higher !== gt) {
1808
+ return false;
1809
+ }
1810
+ } else if (gt.operator === ">=" && !satisfies2(gt.semver, String(c), options)) {
1811
+ return false;
1812
+ }
1813
+ }
1814
+ if (lt) {
1815
+ if (needDomLTPre) {
1816
+ if (c.semver.prerelease && c.semver.prerelease.length && c.semver.major === needDomLTPre.major && c.semver.minor === needDomLTPre.minor && c.semver.patch === needDomLTPre.patch) {
1817
+ needDomLTPre = false;
1818
+ }
1819
+ }
1820
+ if (c.operator === "<" || c.operator === "<=") {
1821
+ lower = lowerLT(lt, c, options);
1822
+ if (lower === c && lower !== lt) {
1823
+ return false;
1824
+ }
1825
+ } else if (lt.operator === "<=" && !satisfies2(lt.semver, String(c), options)) {
1826
+ return false;
1827
+ }
1828
+ }
1829
+ if (!c.operator && (lt || gt) && gtltComp !== 0) {
1830
+ return false;
1831
+ }
1832
+ }
1833
+ if (gt && hasDomLT && !lt && gtltComp !== 0) {
1834
+ return false;
1835
+ }
1836
+ if (lt && hasDomGT && !gt && gtltComp !== 0) {
1837
+ return false;
1838
+ }
1839
+ if (needDomGTPre || needDomLTPre) {
1840
+ return false;
1841
+ }
1842
+ return true;
1843
+ };
1844
+ var higherGT = (a, b, options) => {
1845
+ if (!a) {
1846
+ return b;
1847
+ }
1848
+ const comp = compare(a.semver, b.semver, options);
1849
+ return comp > 0 ? a : comp < 0 ? b : b.operator === ">" && a.operator === ">=" ? b : a;
1850
+ };
1851
+ var lowerLT = (a, b, options) => {
1852
+ if (!a) {
1853
+ return b;
1854
+ }
1855
+ const comp = compare(a.semver, b.semver, options);
1856
+ return comp < 0 ? a : comp > 0 ? b : b.operator === "<" && a.operator === "<=" ? b : a;
1857
+ };
1858
+ module.exports = subset;
1859
+ }
1860
+ });
1861
+
1862
+ // node_modules/semver/index.js
1863
+ var require_semver2 = __commonJS({
1864
+ "node_modules/semver/index.js"(exports, module) {
1865
+ "use strict";
1866
+ var internalRe = require_re();
1867
+ var constants = require_constants();
1868
+ var SemVer = require_semver();
1869
+ var identifiers = require_identifiers();
1870
+ var parse = require_parse();
1871
+ var valid2 = require_valid();
1872
+ var clean = require_clean();
1873
+ var inc = require_inc();
1874
+ var diff = require_diff();
1875
+ var major = require_major();
1876
+ var minor = require_minor();
1877
+ var patch = require_patch();
1878
+ var prerelease = require_prerelease();
1879
+ var compare = require_compare();
1880
+ var rcompare = require_rcompare();
1881
+ var compareLoose = require_compare_loose();
1882
+ var compareBuild = require_compare_build();
1883
+ var sort = require_sort();
1884
+ var rsort = require_rsort();
1885
+ var gt = require_gt();
1886
+ var lt = require_lt();
1887
+ var eq = require_eq();
1888
+ var neq = require_neq();
1889
+ var gte = require_gte();
1890
+ var lte = require_lte();
1891
+ var cmp = require_cmp();
1892
+ var coerce = require_coerce();
1893
+ var Comparator = require_comparator();
1894
+ var Range = require_range();
1895
+ var satisfies2 = require_satisfies();
1896
+ var toComparators = require_to_comparators();
1897
+ var maxSatisfying = require_max_satisfying();
1898
+ var minSatisfying = require_min_satisfying();
1899
+ var minVersion = require_min_version();
1900
+ var validRange = require_valid2();
1901
+ var outside = require_outside();
1902
+ var gtr = require_gtr();
1903
+ var ltr = require_ltr();
1904
+ var intersects = require_intersects();
1905
+ var simplifyRange = require_simplify();
1906
+ var subset = require_subset();
1907
+ module.exports = {
1908
+ parse,
1909
+ valid: valid2,
1910
+ clean,
1911
+ inc,
1912
+ diff,
1913
+ major,
1914
+ minor,
1915
+ patch,
1916
+ prerelease,
1917
+ compare,
1918
+ rcompare,
1919
+ compareLoose,
1920
+ compareBuild,
1921
+ sort,
1922
+ rsort,
1923
+ gt,
1924
+ lt,
1925
+ eq,
1926
+ neq,
1927
+ gte,
1928
+ lte,
1929
+ cmp,
1930
+ coerce,
1931
+ Comparator,
1932
+ Range,
1933
+ satisfies: satisfies2,
1934
+ toComparators,
1935
+ maxSatisfying,
1936
+ minSatisfying,
1937
+ minVersion,
1938
+ validRange,
1939
+ outside,
1940
+ gtr,
1941
+ ltr,
1942
+ intersects,
1943
+ simplifyRange,
1944
+ subset,
1945
+ SemVer,
1946
+ re: internalRe.re,
1947
+ src: internalRe.src,
1948
+ tokens: internalRe.t,
1949
+ SEMVER_SPEC_VERSION: constants.SEMVER_SPEC_VERSION,
1950
+ RELEASE_TYPES: constants.RELEASE_TYPES,
1951
+ compareIdentifiers: identifiers.compareIdentifiers,
1952
+ rcompareIdentifiers: identifiers.rcompareIdentifiers
1953
+ };
1954
+ }
1955
+ });
1956
+
1957
+ // node_modules/@esm.sh/import-map/dist/index.mjs
1958
+ var import_semver = __toESM(require_semver2(), 1);
1959
+ var KNOWN_TARGETS = /* @__PURE__ */ new Set([
1960
+ "es2015",
1961
+ "es2016",
1962
+ "es2017",
1963
+ "es2018",
1964
+ "es2019",
1965
+ "es2020",
1966
+ "es2021",
1967
+ "es2022",
1968
+ "es2023",
1969
+ "es2024",
1970
+ "esnext"
1971
+ ]);
1972
+ var ESM_SEGMENTS = /* @__PURE__ */ new Set([
1973
+ "es2015",
1974
+ "es2016",
1975
+ "es2017",
1976
+ "es2018",
1977
+ "es2019",
1978
+ "es2020",
1979
+ "es2021",
1980
+ "es2022",
1981
+ "es2023",
1982
+ "es2024",
1983
+ "esnext",
1984
+ "denonext",
1985
+ "deno",
1986
+ "node"
1987
+ ]);
1988
+ var SPECIFIER_MARK_SEPARATOR = "\0";
1989
+ var META_CACHE = /* @__PURE__ */ new Map();
1990
+ async function addImport(importMap, specifier, noSRI) {
1991
+ const imp = parseImportSpecifier(specifier);
1992
+ const config = importMap.config ?? {};
1993
+ const target = normalizeTarget(config.target);
1994
+ const cdnOrigin = normalizeCdnOrigin(config.cdn);
1995
+ const meta = await fetchImportMeta(cdnOrigin, imp, target);
1996
+ const mark = /* @__PURE__ */ new Set();
1997
+ await addImportImpl(importMap, mark, meta, false, void 0, cdnOrigin, target, noSRI ?? false);
1998
+ pruneScopeSpecifiersShadowedByImports(importMap);
1999
+ pruneEmptyScopes(importMap);
8
2000
  }
9
- function parseImportMapFromJson(json, baseURL) {
10
- const importMap = {
11
- $baseURL: new URL(baseURL ?? ".", "file:///").href,
12
- imports: {},
13
- scopes: {}
2001
+ async function addImportImpl(importMap, mark, imp, indirect, targetImports, cdnOrigin, target, noSRI) {
2002
+ const markedSpecifier = specifierOf(imp) + SPECIFIER_MARK_SEPARATOR + imp.version;
2003
+ if (mark.has(markedSpecifier)) {
2004
+ return;
2005
+ }
2006
+ mark.add(markedSpecifier);
2007
+ const cdnScopeKey = cdnOrigin + "/";
2008
+ const cdnScopeImports = importMap.scopes?.[cdnScopeKey];
2009
+ const imports = indirect ? targetImports ?? ensureScope(importMap, cdnScopeKey) : importMap.imports;
2010
+ const moduleUrl = moduleUrlOf(cdnOrigin, target, imp);
2011
+ const currentSpecifier = specifierOf(imp);
2012
+ imports[currentSpecifier] = moduleUrl;
2013
+ await updateIntegrity(importMap, imp, moduleUrl, cdnOrigin, target, noSRI);
2014
+ if (!indirect) {
2015
+ if (cdnScopeImports) {
2016
+ delete cdnScopeImports[currentSpecifier];
2017
+ }
2018
+ pruneEmptyScopes(importMap);
2019
+ }
2020
+ const allDeps = [
2021
+ ...imp.peerImports.map((pathname) => ({ pathname, isPeer: true })),
2022
+ ...imp.imports.map((pathname) => ({ pathname, isPeer: false }))
2023
+ ];
2024
+ await Promise.all(
2025
+ allDeps.map(async ({ pathname, isPeer }) => {
2026
+ if (pathname.startsWith("/node/")) {
2027
+ return;
2028
+ }
2029
+ const depImport = parseEsmPath(pathname);
2030
+ if (depImport.name === imp.name) {
2031
+ depImport.version = imp.version;
2032
+ }
2033
+ const depSpecifier = specifierOf(depImport);
2034
+ const existingUrl = importMap.imports[depSpecifier] ?? importMap.scopes?.[cdnScopeKey]?.[depSpecifier];
2035
+ let scopedTargetImports = targetImports;
2036
+ if (existingUrl?.startsWith(cdnOrigin + "/")) {
2037
+ const existingImport = parseEsmPath(existingUrl);
2038
+ const existingVersion = (0, import_semver.valid)(existingImport.version);
2039
+ if (existingVersion && depImport.version === existingImport.version) {
2040
+ return;
2041
+ }
2042
+ if (existingVersion && depImport.version && !(0, import_semver.valid)(depImport.version)) {
2043
+ if ((0, import_semver.satisfies)(existingVersion, depImport.version, { includePrerelease: true })) {
2044
+ return;
2045
+ }
2046
+ if (isPeer) {
2047
+ console.warn(
2048
+ "incorrect peer dependency(unmeet " + depImport.version + "): " + depImport.name + "@" + existingVersion
2049
+ );
2050
+ return;
2051
+ }
2052
+ const scope = cdnOrigin + "/" + esmSpecifierOf(imp) + "/";
2053
+ scopedTargetImports = ensureScope(importMap, scope);
2054
+ }
2055
+ }
2056
+ const depMeta = await fetchImportMeta(cdnOrigin, depImport, target);
2057
+ await addImportImpl(importMap, mark, depMeta, !isPeer, scopedTargetImports, cdnOrigin, target, noSRI);
2058
+ })
2059
+ );
2060
+ pruneEmptyScopes(importMap);
2061
+ }
2062
+ async function updateIntegrity(importMap, imp, moduleUrl, cdnOrigin, target, noSRI) {
2063
+ if (noSRI) {
2064
+ if (importMap.integrity) {
2065
+ delete importMap.integrity[moduleUrl];
2066
+ }
2067
+ return;
2068
+ }
2069
+ if (!hasExternalImports(imp)) {
2070
+ if (imp.integrity) {
2071
+ importMap.integrity ??= {};
2072
+ importMap.integrity[moduleUrl] = imp.integrity;
2073
+ }
2074
+ return;
2075
+ }
2076
+ const integrityMeta = await fetchImportMeta(
2077
+ cdnOrigin,
2078
+ {
2079
+ name: imp.name,
2080
+ version: imp.version,
2081
+ subPath: imp.subPath,
2082
+ github: imp.github,
2083
+ jsr: imp.jsr,
2084
+ external: true,
2085
+ dev: imp.dev
2086
+ },
2087
+ target
2088
+ );
2089
+ if (integrityMeta.integrity) {
2090
+ importMap.integrity ??= {};
2091
+ importMap.integrity[moduleUrl] = integrityMeta.integrity;
2092
+ }
2093
+ }
2094
+ function parseImportSpecifier(specifier) {
2095
+ let source = specifier.trim();
2096
+ const imp = {
2097
+ name: "",
2098
+ version: "",
2099
+ subPath: "",
2100
+ github: false,
2101
+ jsr: false,
2102
+ external: false,
2103
+ dev: false
14
2104
  };
15
- const v = JSON.parse(json);
16
- if (isObject(v)) {
17
- const { imports, scopes } = v;
18
- if (isObject(imports)) {
19
- validateImports(imports);
20
- importMap.imports = imports;
2105
+ if (source.startsWith("gh:")) {
2106
+ imp.github = true;
2107
+ source = source.slice(3);
2108
+ } else if (source.startsWith("jsr:")) {
2109
+ imp.jsr = true;
2110
+ source = source.slice(4);
2111
+ }
2112
+ let scopeName = "";
2113
+ if ((source.startsWith("@") || imp.github) && source.includes("/")) {
2114
+ [scopeName, source] = splitByFirst(source, "/");
2115
+ }
2116
+ let packageAndVersion = "";
2117
+ [packageAndVersion, imp.subPath] = splitByFirst(source, "/");
2118
+ [imp.name, imp.version] = splitByFirst(packageAndVersion, "@");
2119
+ if (scopeName) {
2120
+ imp.name = scopeName + "/" + imp.name;
2121
+ }
2122
+ if (!imp.name) {
2123
+ throw new Error("invalid package name or version: " + specifier);
2124
+ }
2125
+ return imp;
2126
+ }
2127
+ function normalizeTarget(target) {
2128
+ if (target && KNOWN_TARGETS.has(target)) {
2129
+ return target;
2130
+ }
2131
+ return "es2022";
2132
+ }
2133
+ function normalizeCdnOrigin(cdn) {
2134
+ if (cdn && (cdn.startsWith("https://") || cdn.startsWith("http://"))) {
2135
+ try {
2136
+ return new URL(cdn).origin;
2137
+ } catch (error) {
2138
+ console.warn("invalid cdn: " + cdn);
21
2139
  }
22
- if (isObject(scopes)) {
23
- validateScopes(scopes);
24
- importMap.scopes = scopes;
2140
+ }
2141
+ return "https://esm.sh";
2142
+ }
2143
+ function specifierOf(imp) {
2144
+ const prefix = imp.github ? "gh:" : imp.jsr ? "jsr:" : "";
2145
+ return prefix + imp.name + (imp.subPath ? "/" + imp.subPath : "");
2146
+ }
2147
+ function esmSpecifierOf(imp) {
2148
+ const prefix = imp.github ? "gh/" : imp.jsr ? "jsr/" : "";
2149
+ const external = hasExternalImports(imp) ? "*" : "";
2150
+ return prefix + external + imp.name + "@" + imp.version;
2151
+ }
2152
+ function registryPrefix(imp) {
2153
+ if (imp.github) {
2154
+ return "gh/";
2155
+ }
2156
+ if (imp.jsr) {
2157
+ return "jsr/";
2158
+ }
2159
+ return "";
2160
+ }
2161
+ function hasExternalImports(meta) {
2162
+ if (meta.peerImports.length > 0) {
2163
+ return true;
2164
+ }
2165
+ for (const dep of meta.imports) {
2166
+ if (!dep.startsWith("/node/") && !dep.startsWith("/" + meta.name + "@")) {
2167
+ return true;
25
2168
  }
26
2169
  }
27
- return importMap;
2170
+ return false;
28
2171
  }
29
- function parseImportMapFromHtml(html, baseURL) {
30
- const tplEl = document.createElement("template");
31
- tplEl.innerHTML = html;
32
- const scriptEl = tplEl.content.querySelector("script[type='importmap']");
33
- if (scriptEl) {
34
- return parseImportMapFromJson(scriptEl.textContent, baseURL);
2172
+ function moduleUrlOf(cdnOrigin, target, imp) {
2173
+ let url = cdnOrigin + "/" + esmSpecifierOf(imp) + "/" + target + "/";
2174
+ if (imp.subPath) {
2175
+ if (imp.dev || imp.subPath === "jsx-dev-runtime") {
2176
+ url += imp.subPath + ".development.mjs";
2177
+ } else {
2178
+ url += imp.subPath + ".mjs";
2179
+ }
2180
+ return url;
35
2181
  }
36
- return createBlankImportMap(baseURL);
2182
+ const fileName = imp.name.includes("/") ? imp.name.split("/").at(-1) : imp.name;
2183
+ return url + fileName + ".mjs";
2184
+ }
2185
+ var fetcher = globalThis.fetch;
2186
+ function setFetcher(f) {
2187
+ fetcher = f;
37
2188
  }
38
- function validateImports(imports) {
39
- for (const [k, v] of Object.entries(imports)) {
40
- if (!v || typeof v !== "string") {
41
- delete imports[k];
2189
+ async function fetchImportMeta(cdnOrigin, imp, target) {
2190
+ const star = imp.external ? "*" : "";
2191
+ const version = imp.version ? "@" + imp.version : "";
2192
+ const subPath = imp.subPath ? "/" + imp.subPath : "";
2193
+ const targetQuery = target !== "es2022" ? "&target=" + encodeURIComponent(target) : "";
2194
+ const url = cdnOrigin + "/" + star + registryPrefix(imp) + imp.name + version + subPath + "?meta" + targetQuery;
2195
+ const cached = META_CACHE.get(url);
2196
+ if (cached) {
2197
+ return cached;
2198
+ }
2199
+ const pending = (async () => {
2200
+ const res = await fetcher(url);
2201
+ if (res.status === 404) {
2202
+ throw new Error("package not found: " + imp.name + version + subPath);
2203
+ }
2204
+ if (!res.ok) {
2205
+ throw new Error("unexpected http status " + res.status + ": " + await res.text());
42
2206
  }
2207
+ const bodyText = await res.text();
2208
+ let data;
2209
+ try {
2210
+ data = JSON.parse(bodyText);
2211
+ } catch (error) {
2212
+ throw new Error("invalid meta response from " + url + ": " + String(error));
2213
+ }
2214
+ return {
2215
+ name: data.name ?? imp.name,
2216
+ version: data.version ?? imp.version,
2217
+ subPath: imp.subPath,
2218
+ github: imp.github,
2219
+ jsr: imp.jsr,
2220
+ external: imp.external,
2221
+ dev: imp.dev,
2222
+ module: data.module ?? "",
2223
+ integrity: data.integrity ?? "",
2224
+ exports: data.exports ?? [],
2225
+ imports: data.imports ?? [],
2226
+ peerImports: data.peerImports ?? []
2227
+ };
2228
+ })();
2229
+ META_CACHE.set(url, pending);
2230
+ try {
2231
+ return await pending;
2232
+ } catch (error) {
2233
+ META_CACHE.delete(url);
2234
+ throw error;
43
2235
  }
44
2236
  }
45
- function validateScopes(imports) {
46
- for (const [k, v] of Object.entries(imports)) {
47
- if (isObject(v)) {
48
- validateImports(v);
2237
+ function ensureScope(importMap, scopeKey) {
2238
+ importMap.scopes ??= {};
2239
+ importMap.scopes[scopeKey] ??= {};
2240
+ return importMap.scopes[scopeKey];
2241
+ }
2242
+ function pruneEmptyScopes(importMap) {
2243
+ if (!importMap.scopes) {
2244
+ return;
2245
+ }
2246
+ for (const [scope, imports] of Object.entries(importMap.scopes)) {
2247
+ if (Object.keys(imports).length === 0) {
2248
+ delete importMap.scopes[scope];
2249
+ }
2250
+ }
2251
+ }
2252
+ function pruneScopeSpecifiersShadowedByImports(importMap) {
2253
+ for (const [scopeKey, scopedImports] of Object.entries(importMap.scopes)) {
2254
+ if (scopeKey.startsWith("https://") || scopeKey.startsWith("http://")) {
2255
+ const url = new URL(scopeKey);
2256
+ if (url.pathname === "/") {
2257
+ for (const specifier of Object.keys(scopedImports)) {
2258
+ if (specifier in importMap.imports) {
2259
+ delete scopedImports[specifier];
2260
+ }
2261
+ }
2262
+ }
2263
+ }
2264
+ }
2265
+ }
2266
+ function parseEsmPath(pathnameOrUrl) {
2267
+ let pathname;
2268
+ if (pathnameOrUrl.startsWith("https://") || pathnameOrUrl.startsWith("http://")) {
2269
+ pathname = new URL(pathnameOrUrl).pathname;
2270
+ } else if (pathnameOrUrl.startsWith("/")) {
2271
+ pathname = splitByFirst(splitByFirst(pathnameOrUrl, "#")[0], "?")[0];
2272
+ } else {
2273
+ throw new Error("invalid pathname or url: " + pathnameOrUrl);
2274
+ }
2275
+ const imp = {
2276
+ name: "",
2277
+ version: "",
2278
+ subPath: "",
2279
+ github: false,
2280
+ jsr: false,
2281
+ external: false,
2282
+ dev: false
2283
+ };
2284
+ if (pathname.startsWith("/gh/")) {
2285
+ imp.github = true;
2286
+ pathname = pathname.slice(3);
2287
+ } else if (pathname.startsWith("/jsr/")) {
2288
+ imp.jsr = true;
2289
+ pathname = pathname.slice(4);
2290
+ }
2291
+ const segs = pathname.split("/").filter(Boolean);
2292
+ if (segs.length === 0) {
2293
+ throw new Error("invalid pathname: " + pathnameOrUrl);
2294
+ }
2295
+ if (segs[0].startsWith("@")) {
2296
+ if (!segs[1]) {
2297
+ throw new Error("invalid pathname: " + pathnameOrUrl);
2298
+ }
2299
+ const [name, version] = splitByLast(segs[1], "@");
2300
+ imp.name = trimLeadingStar(segs[0] + "/" + name);
2301
+ imp.version = version;
2302
+ segs.splice(0, 2);
2303
+ } else {
2304
+ const [name, version] = splitByLast(segs[0], "@");
2305
+ imp.name = trimLeadingStar(name);
2306
+ imp.version = version;
2307
+ segs.splice(0, 1);
2308
+ }
2309
+ let hasTargetSegment = false;
2310
+ if (segs[0] && ESM_SEGMENTS.has(segs[0])) {
2311
+ hasTargetSegment = true;
2312
+ segs.shift();
2313
+ }
2314
+ if (segs.length > 0) {
2315
+ if (hasTargetSegment && pathname.endsWith(".mjs")) {
2316
+ let subPath = segs.join("/");
2317
+ if (subPath.endsWith(".mjs")) {
2318
+ subPath = subPath.slice(0, -4);
2319
+ }
2320
+ if (subPath.endsWith(".development")) {
2321
+ subPath = subPath.slice(0, -12);
2322
+ imp.dev = true;
2323
+ }
2324
+ if (subPath.includes("/") || subPath !== imp.name && !imp.name.endsWith("/" + subPath)) {
2325
+ imp.subPath = subPath;
2326
+ }
49
2327
  } else {
50
- delete imports[k];
2328
+ imp.subPath = segs.join("/");
2329
+ }
2330
+ }
2331
+ return imp;
2332
+ }
2333
+ function trimLeadingStar(value) {
2334
+ if (value.startsWith("*")) {
2335
+ return value.slice(1);
2336
+ }
2337
+ return value;
2338
+ }
2339
+ function splitByFirst(value, separator) {
2340
+ const idx = value.indexOf(separator);
2341
+ if (idx < 0) {
2342
+ return [value, ""];
2343
+ }
2344
+ return [value.slice(0, idx), value.slice(idx + separator.length)];
2345
+ }
2346
+ function splitByLast(value, separator) {
2347
+ const idx = value.lastIndexOf(separator);
2348
+ if (idx < 0) {
2349
+ return [value, ""];
2350
+ }
2351
+ return [value.slice(0, idx), value.slice(idx + separator.length)];
2352
+ }
2353
+ function resolve(importMap, specifier, containingFile) {
2354
+ const baseURL = importMap.baseURL;
2355
+ const referrer = new URL(containingFile, baseURL);
2356
+ const [specifierWithoutHash, hashPart = ""] = specifier.split("#", 2);
2357
+ const [specifierWithoutQuery, queryPart = ""] = specifierWithoutHash.split("?", 2);
2358
+ const hash = hashPart ? `#${hashPart}` : "";
2359
+ const query = queryPart ? `?${queryPart}` : "";
2360
+ const cleanSpecifier = specifierWithoutQuery;
2361
+ const scopes = importMap.scopes ?? {};
2362
+ const scopeEntries = Object.entries(scopes).map(([scopeKey, scopeImports]) => {
2363
+ try {
2364
+ return [new URL(scopeKey, baseURL).toString(), scopeImports];
2365
+ } catch {
2366
+ return [scopeKey, scopeImports];
2367
+ }
2368
+ }).sort((a, b) => compareScopeKeys(a[0], b[0]));
2369
+ for (const [scopeKey, scopeImports] of scopeEntries) {
2370
+ if (!referrer.toString().startsWith(scopeKey)) {
2371
+ continue;
2372
+ }
2373
+ const mapped2 = resolveWith(cleanSpecifier, scopeImports ?? {});
2374
+ if (mapped2) {
2375
+ return [normalizeUrl(baseURL, mapped2) + query + hash, true];
2376
+ }
2377
+ }
2378
+ const mapped = resolveWith(cleanSpecifier, importMap.imports);
2379
+ if (mapped) {
2380
+ return [normalizeUrl(baseURL, mapped) + query + hash, true];
2381
+ }
2382
+ return [cleanSpecifier + query + hash, false];
2383
+ }
2384
+ function resolveWith(specifier, imports) {
2385
+ if (imports[specifier]) {
2386
+ return imports[specifier];
2387
+ }
2388
+ if (!specifier.includes("/")) {
2389
+ return null;
2390
+ }
2391
+ const prefixKeys = Object.keys(imports).filter((k) => k.endsWith("/") && specifier.startsWith(k)).sort((a, b) => b.length - a.length || (a < b ? 1 : -1));
2392
+ for (const key of prefixKeys) {
2393
+ const value = imports[key];
2394
+ if (value && value.endsWith("/")) {
2395
+ return value + specifier.slice(key.length);
2396
+ }
2397
+ }
2398
+ return null;
2399
+ }
2400
+ function compareScopeKeys(a, b) {
2401
+ const aSlashCount = a.split("/").length;
2402
+ const bSlashCount = b.split("/").length;
2403
+ if (aSlashCount !== bSlashCount) {
2404
+ return bSlashCount - aSlashCount;
2405
+ }
2406
+ return a < b ? 1 : -1;
2407
+ }
2408
+ function normalizeUrl(baseURL, path) {
2409
+ if (path.startsWith("/") || path.startsWith("./") || path.startsWith("../")) {
2410
+ return new URL(path, baseURL).toString();
2411
+ }
2412
+ return path;
2413
+ }
2414
+ function sanitizeStringMap(map) {
2415
+ if (!isObject(map)) {
2416
+ return {};
2417
+ }
2418
+ const next = {};
2419
+ for (const [key, value] of Object.entries(map)) {
2420
+ if (typeof value === "string") {
2421
+ next[key] = value;
2422
+ }
2423
+ }
2424
+ return next;
2425
+ }
2426
+ function sanitizeScopes(scopes) {
2427
+ if (!isObject(scopes)) {
2428
+ return {};
2429
+ }
2430
+ const next = {};
2431
+ for (const [scopeKey, scopeImports] of Object.entries(scopes)) {
2432
+ if (isObject(scopeImports)) {
2433
+ next[scopeKey] = sanitizeStringMap(scopeImports);
51
2434
  }
52
2435
  }
2436
+ return next;
53
2437
  }
54
2438
  function isObject(v) {
55
2439
  return typeof v === "object" && v !== null && !Array.isArray(v);
56
2440
  }
2441
+ var ImportMap = class {
2442
+ #baseURL;
2443
+ config = {};
2444
+ imports = {};
2445
+ scopes = {};
2446
+ integrity = {};
2447
+ constructor(init2, baseURL) {
2448
+ this.#baseURL = new URL(baseURL ?? globalThis.location?.href ?? "file:///");
2449
+ if (init2) {
2450
+ this.config = sanitizeStringMap(init2.config);
2451
+ this.imports = sanitizeStringMap(init2.imports);
2452
+ this.scopes = sanitizeScopes(init2.scopes);
2453
+ this.integrity = sanitizeStringMap(init2.integrity);
2454
+ }
2455
+ }
2456
+ get baseURL() {
2457
+ return this.#baseURL;
2458
+ }
2459
+ get raw() {
2460
+ const json = {};
2461
+ const config = sortStringMap(this.config);
2462
+ if (Object.keys(config).length > 0) {
2463
+ json.config = config;
2464
+ }
2465
+ const imports = sortStringMap(this.imports);
2466
+ if (Object.keys(imports).length > 0) {
2467
+ json.imports = imports;
2468
+ }
2469
+ const scopes = sortScopes(this.scopes);
2470
+ if (Object.keys(scopes).length > 0) {
2471
+ json.scopes = scopes;
2472
+ }
2473
+ const integrity = sortStringMap(this.integrity);
2474
+ if (Object.keys(integrity).length > 0) {
2475
+ json.integrity = integrity;
2476
+ }
2477
+ return json;
2478
+ }
2479
+ addImport(specifier, noSRI) {
2480
+ return addImport(this, specifier, noSRI);
2481
+ }
2482
+ resolve(specifier, containingFile) {
2483
+ return resolve(this, specifier, containingFile);
2484
+ }
2485
+ };
2486
+ function sortStringMap(map) {
2487
+ const source = map;
2488
+ const next = {};
2489
+ for (const key of Object.keys(source).sort()) {
2490
+ const value = source[key];
2491
+ if (typeof value === "string") {
2492
+ next[key] = value;
2493
+ }
2494
+ }
2495
+ return next;
2496
+ }
2497
+ function sortScopes(scopes) {
2498
+ const next = {};
2499
+ for (const scopeKey of Object.keys(scopes).sort()) {
2500
+ const scopeImports = sortStringMap(scopes[scopeKey]);
2501
+ if (Object.keys(scopeImports).length > 0) {
2502
+ next[scopeKey] = scopeImports;
2503
+ }
2504
+ }
2505
+ return next;
2506
+ }
2507
+ function parseFromJson(json, baseURL) {
2508
+ const im = new ImportMap({}, baseURL);
2509
+ const v = JSON.parse(json);
2510
+ if (isObject(v)) {
2511
+ const { config, imports, scopes, integrity } = v;
2512
+ im.config = sanitizeStringMap(config);
2513
+ im.imports = sanitizeStringMap(imports);
2514
+ im.scopes = sanitizeScopes(scopes);
2515
+ im.integrity = sanitizeStringMap(integrity);
2516
+ }
2517
+ return im;
2518
+ }
2519
+ function parseFromHtml(html, baseURL) {
2520
+ const tplEl = document.createElement("template");
2521
+ tplEl.innerHTML = html;
2522
+ const scriptEl = tplEl.content.querySelector("script[type='importmap']");
2523
+ if (scriptEl) {
2524
+ return parseFromJson(scriptEl.textContent, baseURL);
2525
+ }
2526
+ return new ImportMap({}, baseURL);
2527
+ }
57
2528
 
58
2529
  // src/lsp/json/schemas.ts
59
2530
  var schemas = [
@@ -111,13 +2582,14 @@ var schemas = [
111
2582
  ];
112
2583
 
113
2584
  // src/lsp/json/setup.ts
2585
+ import { cache } from "../../cache.mjs";
114
2586
  import * as client from "../client.mjs";
115
2587
  async function setup(monaco, languageId, languageSettings, formattingOptions, workspace) {
116
2588
  const { editor, languages } = monaco;
117
2589
  const schemas2 = Array.isArray(languageSettings?.schemas) ? schemas.concat(languageSettings.schemas) : schemas;
118
2590
  const createData = {
119
2591
  settings: {
120
- validate: true,
2592
+ validate: languageSettings?.diagnosticsOptions?.validate ?? true,
121
2593
  allowComments: false,
122
2594
  comments: "error",
123
2595
  trailingCommas: "error",
@@ -154,98 +2626,99 @@ async function setup(monaco, languageId, languageSettings, formattingOptions, wo
154
2626
  }
155
2627
  });
156
2628
  client.init(monaco);
157
- client.registerBasicFeatures(languageId, worker, [" ", ":", '"'], workspace);
2629
+ client.registerBasicFeatures(languageId, worker, [" ", ":", '"'], workspace, languageSettings?.diagnosticsOptions);
158
2630
  client.registerColorPresentation(languageId, worker);
159
2631
  client.registerDocumentLinks(languageId, worker);
160
- languages.registerCodeLensProvider(languageId, {
161
- provideCodeLenses: function(model, _token) {
162
- const isImportMap = model.uri.scheme == "file" && ["importmap.json", "import_map.json", "import-map.json", "importMap.json"].some((name) => model.uri.path === "/" + name);
163
- if (isImportMap) {
164
- const m2 = model.findNextMatch(`"imports":\\s*\\{`, { column: 1, lineNumber: 1 }, true, false, null, false);
165
- return {
166
- lenses: [
167
- {
168
- range: m2?.range ?? new monaco.Range(1, 1, 1, 1),
169
- command: {
170
- id: "search-npm-package",
171
- title: "$(sparkle-filled) Search packages on NPM",
172
- tooltip: "Search packages on NPM",
173
- arguments: [model]
2632
+ if (languageSettings?.importMapCodeLens ?? true) {
2633
+ languages.registerCodeLensProvider(languageId, {
2634
+ provideCodeLenses: function(model, _token) {
2635
+ const isImportMap = model.uri.scheme == "file" && ["importmap.json", "import_map.json", "import-map.json", "importMap.json"].some((name) => model.uri.path === "/" + name);
2636
+ if (isImportMap) {
2637
+ const m2 = model.findNextMatch(`"imports":\\s*\\{`, { column: 1, lineNumber: 1 }, true, false, null, false);
2638
+ return {
2639
+ lenses: [
2640
+ {
2641
+ range: m2?.range ?? new monaco.Range(1, 1, 1, 1),
2642
+ command: {
2643
+ id: "importmap:add-import",
2644
+ title: "$(sparkle-filled) Add import from esm.sh",
2645
+ tooltip: "Add Import",
2646
+ arguments: [model]
2647
+ }
174
2648
  }
2649
+ ],
2650
+ dispose: () => {
175
2651
  }
176
- ],
177
- dispose: () => {
178
- }
179
- };
180
- }
181
- }
182
- });
183
- editor.registerCommand("search-npm-package", async (_accessor, model) => {
184
- const keyword = await monaco.showInputBox({
185
- placeHolder: "Enter package name, e.g. lodash",
186
- validateInput: (value) => {
187
- return /^[\w\-\.@]+$/.test(value) ? null : "Invalid package name, only word characters are allowed";
2652
+ };
2653
+ }
188
2654
  }
189
2655
  });
190
- if (!keyword) {
191
- return;
192
- }
193
- const pkg = await monaco.showQuickPick(searchPackagesFromNpm(keyword, 32), {
194
- placeHolder: "Select a package",
195
- matchOnDetail: true
2656
+ }
2657
+ setFetcher(cache.fetch.bind(cache));
2658
+ editor.registerCommand("importmap:add-import", async (_accessor, model) => {
2659
+ const specifier = await monaco.showInputBox({
2660
+ placeHolder: "Enter package name, e.g. react, react@18, react-dom@beta, etc.",
2661
+ validateInput: (value) => /^[\w\-\.\/@]+$/.test(value) ? null : "Invalid package name"
196
2662
  });
197
- if (!pkg) {
2663
+ if (!specifier) {
198
2664
  return;
199
2665
  }
200
- const editor2 = monaco.editor.getEditors().filter((e) => e.hasWidgetFocus())[0];
201
2666
  const modelPath = model.uri.path;
202
- const { imports, scopes } = modelPath.endsWith(".json") ? parseImportMapFromJson(model.getValue()) : parseImportMapFromHtml(model.getValue());
203
- const specifier = "https://esm.sh/" + pkg.name + "@" + pkg.version;
204
- if (imports[pkg.name] === specifier) {
2667
+ const im = modelPath.endsWith(".json") ? parseFromJson(model.getValue()) : parseFromHtml(model.getValue());
2668
+ const items = await createModulePickItems(specifier, im.config?.cdn);
2669
+ const imports = items.length > 1 ? await monaco.showQuickPick(items, {
2670
+ placeHolder: "Select modules to add",
2671
+ canPickMany: true
2672
+ }) : items;
2673
+ if (!imports || imports.length === 0) {
205
2674
  return;
206
2675
  }
207
- imports[pkg.name] = specifier;
208
- const json = JSON.stringify({ imports, scopes: Object.keys(scopes).length > 0 ? scopes : void 0 }, null, 2);
209
- if (modelPath.endsWith(".json")) {
210
- const viewState = editor2?.saveViewState();
211
- model.setValue(model.normalizeIndentation(json));
212
- editor2?.restoreViewState(viewState);
213
- } else if (modelPath.endsWith(".html")) {
2676
+ await Promise.all(imports.map(async (module) => im.addImport(module.specifier, true)));
2677
+ const json = JSON.stringify(im.raw, null, 2);
2678
+ const editor2 = monaco.editor.getEditors().filter((e) => e.hasWidgetFocus())[0];
2679
+ const viewState = editor2?.saveViewState();
2680
+ if (modelPath.endsWith(".html")) {
214
2681
  const html = model.getValue();
215
2682
  const newHtml = html.replace(
216
2683
  /<script[^>]*? type="importmap"[^>]*?>[^]*?<\/script>/,
217
2684
  ['<script type="importmap">', ...json.split("\n").map((l) => " " + l), "<\/script>"].join("\n ")
218
2685
  );
219
- const viewState = editor2?.saveViewState();
220
2686
  model.setValue(model.normalizeIndentation(newHtml));
221
- editor2?.restoreViewState(viewState);
2687
+ } else if (modelPath.endsWith(".json")) {
2688
+ model.setValue(model.normalizeIndentation(json));
222
2689
  }
2690
+ editor2?.restoreViewState(viewState);
223
2691
  });
224
2692
  }
225
- async function searchPackagesFromNpm(keyword, size = 20) {
226
- const res = await fetch(`https://registry.npmjs.com/-/v1/search?text=${keyword}&size=${size}`);
2693
+ async function createModulePickItems(specifier, cdn) {
2694
+ if (!cdn || !(cdn.startsWith("https://") || cdn.startsWith("http://"))) {
2695
+ cdn = "https://esm.sh";
2696
+ }
2697
+ const res = await cache.fetch(new URL(`/${specifier}?meta`, cdn));
227
2698
  if (!res.ok) {
228
- throw new Error(`Failed to search npm packages: ${res.statusText}`);
229
- }
230
- const { objects } = await res.json();
231
- if (!Array.isArray(objects)) {
232
- return [];
233
- }
234
- const items = new Array(objects.length);
235
- let len = 0;
236
- for (const { package: pkg } of objects) {
237
- if (!pkg.name.startsWith("@types/")) {
238
- items[len] = {
239
- label: (keyword === pkg.name ? "$(star-empty) " : "") + pkg.name,
240
- description: pkg.version,
241
- detail: pkg.description,
242
- name: pkg.name,
243
- version: pkg.version
244
- };
245
- len++;
246
- }
247
- }
248
- return items.slice(0, len);
2699
+ throw new Error(`Failed to fetch module metadata of ${specifier}: ${res.statusText}`);
2700
+ }
2701
+ const { name, version, exports } = await res.json();
2702
+ const items = [{
2703
+ label: name,
2704
+ description: "@" + version + " main-module",
2705
+ picked: true,
2706
+ specifier: name + "@" + version
2707
+ }];
2708
+ if (exports) {
2709
+ const subModules = exports.filter(
2710
+ (subModule) => subModule.startsWith("./") && !subModule.endsWith(".json") && !subModule.endsWith(".wasm") && !subModule.endsWith(".css")
2711
+ );
2712
+ subModules.forEach((subModule, index) => {
2713
+ const treeChar = index === subModules.length - 1 ? "\u2514" : "\u251C";
2714
+ items.push({
2715
+ label: " " + treeChar + " " + subModule.slice(2),
2716
+ description: "sub-module",
2717
+ specifier: name + "@" + version + subModule.slice(1)
2718
+ });
2719
+ });
2720
+ }
2721
+ return items;
249
2722
  }
250
2723
  function createWebWorker() {
251
2724
  const workerUrl = new URL("./worker.mjs", import.meta.url);