@camunda8/cli 4.7.0-alpha.3 → 4.7.0-alpha.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (118) hide show
  1. package/CONTEXT.md +11 -0
  2. package/PLUGIN-HELP.md +1 -1
  3. package/README.md +9 -1
  4. package/dist/commands/deploy.d.ts.map +1 -1
  5. package/dist/commands/deploy.js +48 -9
  6. package/dist/commands/deploy.js.map +1 -1
  7. package/dist/commands/helpers/deploy-helpers.d.ts +96 -2
  8. package/dist/commands/helpers/deploy-helpers.d.ts.map +1 -1
  9. package/dist/commands/helpers/deploy-helpers.js +213 -70
  10. package/dist/commands/helpers/deploy-helpers.js.map +1 -1
  11. package/dist/commands/mcp-proxy.d.ts.map +1 -1
  12. package/dist/commands/mcp-proxy.js +13 -8
  13. package/dist/commands/mcp-proxy.js.map +1 -1
  14. package/dist/commands/profiles.d.ts.map +1 -1
  15. package/dist/commands/profiles.js +13 -7
  16. package/dist/commands/profiles.js.map +1 -1
  17. package/dist/commands/run.d.ts.map +1 -1
  18. package/dist/commands/run.js +1 -8
  19. package/dist/commands/run.js.map +1 -1
  20. package/dist/commands/watch.d.ts.map +1 -1
  21. package/dist/commands/watch.js +309 -16
  22. package/dist/commands/watch.js.map +1 -1
  23. package/dist/core/client.d.ts +13 -0
  24. package/dist/core/client.d.ts.map +1 -1
  25. package/dist/core/client.js +48 -21
  26. package/dist/core/client.js.map +1 -1
  27. package/dist/core/config.d.ts +34 -3
  28. package/dist/core/config.d.ts.map +1 -1
  29. package/dist/core/config.js +91 -9
  30. package/dist/core/config.js.map +1 -1
  31. package/dist/core/env-address.d.ts +22 -0
  32. package/dist/core/env-address.d.ts.map +1 -0
  33. package/dist/core/env-address.js +30 -0
  34. package/dist/core/env-address.js.map +1 -0
  35. package/dist/core/errors.d.ts +17 -0
  36. package/dist/core/errors.d.ts.map +1 -1
  37. package/dist/core/errors.js +32 -0
  38. package/dist/core/errors.js.map +1 -1
  39. package/dist/core/index.d.ts +2 -0
  40. package/dist/core/index.d.ts.map +1 -1
  41. package/dist/core/index.js +2 -0
  42. package/dist/core/index.js.map +1 -1
  43. package/dist/core/logger.d.ts.map +1 -1
  44. package/dist/core/logger.js +2 -1
  45. package/dist/core/logger.js.map +1 -1
  46. package/dist/core/node-version.d.ts +18 -0
  47. package/dist/core/node-version.d.ts.map +1 -0
  48. package/dist/core/node-version.js +38 -0
  49. package/dist/core/node-version.js.map +1 -0
  50. package/dist/default-plugins/cluster/README.md +1 -1
  51. package/dist/default-plugins/cluster/c8ctl-plugin.js +289 -36
  52. package/dist/default-plugins/element-template/c8ctl-plugin.js +248 -7
  53. package/dist/default-plugins/mcp/README.md +37 -0
  54. package/dist/default-plugins/mcp/c8ctl-plugin.js +4973 -0
  55. package/dist/default-plugins/mcp/package.json +8 -0
  56. package/dist/default-plugins/modeler/README.md +23 -0
  57. package/dist/default-plugins/modeler/c8ctl-plugin.js +4314 -0
  58. package/dist/default-plugins/modeler/package.json +8 -0
  59. package/dist/default-plugins/setup/README.md +43 -0
  60. package/dist/default-plugins/setup/c8ctl-plugin.js +6910 -0
  61. package/dist/default-plugins/setup/package.json +8 -0
  62. package/dist/default-plugins/skills/README.md +35 -0
  63. package/dist/default-plugins/skills/c8ctl-plugin.js +3352 -0
  64. package/dist/default-plugins/skills/package.json +8 -0
  65. package/dist/framework/argv-parser.d.ts +14 -0
  66. package/dist/framework/argv-parser.d.ts.map +1 -1
  67. package/dist/framework/argv-parser.js +25 -0
  68. package/dist/framework/argv-parser.js.map +1 -1
  69. package/dist/framework/command-registry.d.ts +26 -0
  70. package/dist/framework/command-registry.d.ts.map +1 -1
  71. package/dist/framework/command-registry.js +45 -0
  72. package/dist/framework/command-registry.js.map +1 -1
  73. package/dist/framework/plugins/plugin-loader.d.ts +20 -2
  74. package/dist/framework/plugins/plugin-loader.d.ts.map +1 -1
  75. package/dist/framework/plugins/plugin-loader.js.map +1 -1
  76. package/dist/framework/ui/help.d.ts.map +1 -1
  77. package/dist/framework/ui/help.js +57 -14
  78. package/dist/framework/ui/help.js.map +1 -1
  79. package/dist/framework/ui/prompt.d.ts +88 -0
  80. package/dist/framework/ui/prompt.d.ts.map +1 -1
  81. package/dist/framework/ui/prompt.js +344 -0
  82. package/dist/framework/ui/prompt.js.map +1 -1
  83. package/dist/index.d.ts.map +1 -1
  84. package/dist/index.js +68 -12
  85. package/dist/index.js.map +1 -1
  86. package/dist/utils/command-local/mcp-install-helpers.d.ts +68 -0
  87. package/dist/utils/command-local/mcp-install-helpers.d.ts.map +1 -0
  88. package/dist/utils/command-local/mcp-install-helpers.js +485 -0
  89. package/dist/utils/command-local/mcp-install-helpers.js.map +1 -0
  90. package/dist/utils/command-local/process-instance-helpers.d.ts +6 -0
  91. package/dist/utils/command-local/process-instance-helpers.d.ts.map +1 -1
  92. package/dist/utils/command-local/process-instance-helpers.js +9 -0
  93. package/dist/utils/command-local/process-instance-helpers.js.map +1 -1
  94. package/dist/utils/command-local/skills-install-helpers.d.ts +45 -0
  95. package/dist/utils/command-local/skills-install-helpers.d.ts.map +1 -0
  96. package/dist/utils/command-local/skills-install-helpers.js +423 -0
  97. package/dist/utils/command-local/skills-install-helpers.js.map +1 -0
  98. package/dist/utils/index.d.ts +3 -1
  99. package/dist/utils/index.d.ts.map +1 -1
  100. package/dist/utils/index.js +3 -1
  101. package/dist/utils/index.js.map +1 -1
  102. package/dist/utils/shared/camunda-json.d.ts +24 -3
  103. package/dist/utils/shared/camunda-json.d.ts.map +1 -1
  104. package/dist/utils/shared/camunda-json.js +23 -5
  105. package/dist/utils/shared/camunda-json.js.map +1 -1
  106. package/dist/utils/shared/deploy-resource-selection.d.ts +165 -0
  107. package/dist/utils/shared/deploy-resource-selection.d.ts.map +1 -0
  108. package/dist/utils/shared/deploy-resource-selection.js +466 -0
  109. package/dist/utils/shared/deploy-resource-selection.js.map +1 -0
  110. package/dist/utils/shared/ignore.d.ts +26 -0
  111. package/dist/utils/shared/ignore.d.ts.map +1 -1
  112. package/dist/utils/shared/ignore.js +6 -2
  113. package/dist/utils/shared/ignore.js.map +1 -1
  114. package/package.json +3 -2
  115. package/dist/utils/command-local/setup-prerequisites.d.ts +0 -67
  116. package/dist/utils/command-local/setup-prerequisites.d.ts.map +0 -1
  117. package/dist/utils/command-local/setup-prerequisites.js +0 -238
  118. package/dist/utils/command-local/setup-prerequisites.js.map +0 -1
@@ -0,0 +1,4973 @@
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
+ try {
9
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
10
+ } catch (e) {
11
+ throw mod = 0, e;
12
+ }
13
+ };
14
+ var __copyProps = (to, from, except, desc) => {
15
+ if (from && typeof from === "object" || typeof from === "function") {
16
+ for (let key of __getOwnPropNames(from))
17
+ if (!__hasOwnProp.call(to, key) && key !== except)
18
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
19
+ }
20
+ return to;
21
+ };
22
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
23
+ // If the importer is in node compatibility mode or this is not an ESM
24
+ // file that has been converted to a CommonJS file using a Babel-
25
+ // compatible transform (i.e. "__esModule" has not been set), then set
26
+ // "default" to the CommonJS "module.exports" for node compatibility.
27
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
28
+ mod
29
+ ));
30
+
31
+ // node_modules/semver/internal/constants.js
32
+ var require_constants = __commonJS({
33
+ "node_modules/semver/internal/constants.js"(exports, module) {
34
+ "use strict";
35
+ var SEMVER_SPEC_VERSION = "2.0.0";
36
+ var MAX_LENGTH = 256;
37
+ var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || /* istanbul ignore next */
38
+ 9007199254740991;
39
+ var MAX_SAFE_COMPONENT_LENGTH = 16;
40
+ var MAX_SAFE_BUILD_LENGTH = MAX_LENGTH - 6;
41
+ var WHITESPACE_CHARACTERS = [
42
+ " ",
43
+ "\n",
44
+ "\v",
45
+ "\f",
46
+ "\r",
47
+ " ",
48
+ "\xA0",
49
+ "\u1680",
50
+ "\u2000",
51
+ "\u2001",
52
+ "\u2002",
53
+ "\u2003",
54
+ "\u2004",
55
+ "\u2005",
56
+ "\u2006",
57
+ "\u2007",
58
+ "\u2008",
59
+ "\u2009",
60
+ "\u200A",
61
+ "\u2028",
62
+ "\u2029",
63
+ "\u202F",
64
+ "\u205F",
65
+ "\u3000",
66
+ "\uFEFF"
67
+ ];
68
+ var RELEASE_TYPES = [
69
+ "major",
70
+ "premajor",
71
+ "minor",
72
+ "preminor",
73
+ "patch",
74
+ "prepatch",
75
+ "prerelease"
76
+ ];
77
+ module.exports = {
78
+ MAX_LENGTH,
79
+ MAX_SAFE_COMPONENT_LENGTH,
80
+ MAX_SAFE_BUILD_LENGTH,
81
+ MAX_SAFE_INTEGER,
82
+ WHITESPACE_CHARACTERS,
83
+ RELEASE_TYPES,
84
+ SEMVER_SPEC_VERSION,
85
+ FLAG_INCLUDE_PRERELEASE: 1,
86
+ FLAG_LOOSE: 2
87
+ };
88
+ }
89
+ });
90
+
91
+ // node_modules/semver/internal/debug.js
92
+ var require_debug = __commonJS({
93
+ "node_modules/semver/internal/debug.js"(exports, module) {
94
+ "use strict";
95
+ var debug = typeof process === "object" && process.env && process.env.NODE_DEBUG && /\bsemver\b/i.test(process.env.NODE_DEBUG) ? (...args) => console.error("SEMVER", ...args) : () => {
96
+ };
97
+ module.exports = debug;
98
+ }
99
+ });
100
+
101
+ // node_modules/semver/internal/re.js
102
+ var require_re = __commonJS({
103
+ "node_modules/semver/internal/re.js"(exports, module) {
104
+ "use strict";
105
+ var {
106
+ MAX_SAFE_COMPONENT_LENGTH,
107
+ MAX_SAFE_BUILD_LENGTH,
108
+ MAX_LENGTH
109
+ } = require_constants();
110
+ var debug = require_debug();
111
+ exports = module.exports = {};
112
+ var re = exports.re = [];
113
+ var safeRe = exports.safeRe = [];
114
+ var src = exports.src = [];
115
+ var safeSrc = exports.safeSrc = [];
116
+ var t = exports.t = {};
117
+ var R = 0;
118
+ var LETTERDASHNUMBER = "[a-zA-Z0-9-]";
119
+ var safeRegexReplacements = [
120
+ ["\\s", 1],
121
+ ["\\d", MAX_LENGTH],
122
+ [LETTERDASHNUMBER, MAX_SAFE_BUILD_LENGTH]
123
+ ];
124
+ var makeSafeRegex = (value) => {
125
+ for (const [token, max] of safeRegexReplacements) {
126
+ value = value.split(`${token}*`).join(`${token}{0,${max}}`).split(`${token}+`).join(`${token}{1,${max}}`);
127
+ }
128
+ return value;
129
+ };
130
+ var createToken = (name, value, isGlobal) => {
131
+ const safe = makeSafeRegex(value);
132
+ const index = R++;
133
+ debug(name, index, value);
134
+ t[name] = index;
135
+ src[index] = value;
136
+ safeSrc[index] = safe;
137
+ re[index] = new RegExp(value, isGlobal ? "g" : void 0);
138
+ safeRe[index] = new RegExp(safe, isGlobal ? "g" : void 0);
139
+ };
140
+ createToken("NUMERICIDENTIFIER", "0|[1-9]\\d*");
141
+ createToken("NUMERICIDENTIFIERLOOSE", "\\d+");
142
+ createToken("NONNUMERICIDENTIFIER", `\\d*[a-zA-Z-]${LETTERDASHNUMBER}*`);
143
+ createToken("MAINVERSION", `(${src[t.NUMERICIDENTIFIER]})\\.(${src[t.NUMERICIDENTIFIER]})\\.(${src[t.NUMERICIDENTIFIER]})`);
144
+ createToken("MAINVERSIONLOOSE", `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.(${src[t.NUMERICIDENTIFIERLOOSE]})\\.(${src[t.NUMERICIDENTIFIERLOOSE]})`);
145
+ createToken("PRERELEASEIDENTIFIER", `(?:${src[t.NONNUMERICIDENTIFIER]}|${src[t.NUMERICIDENTIFIER]})`);
146
+ createToken("PRERELEASEIDENTIFIERLOOSE", `(?:${src[t.NONNUMERICIDENTIFIER]}|${src[t.NUMERICIDENTIFIERLOOSE]})`);
147
+ createToken("PRERELEASE", `(?:-(${src[t.PRERELEASEIDENTIFIER]}(?:\\.${src[t.PRERELEASEIDENTIFIER]})*))`);
148
+ createToken("PRERELEASELOOSE", `(?:-?(${src[t.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${src[t.PRERELEASEIDENTIFIERLOOSE]})*))`);
149
+ createToken("BUILDIDENTIFIER", `${LETTERDASHNUMBER}+`);
150
+ createToken("BUILD", `(?:\\+(${src[t.BUILDIDENTIFIER]}(?:\\.${src[t.BUILDIDENTIFIER]})*))`);
151
+ createToken("FULLPLAIN", `v?${src[t.MAINVERSION]}${src[t.PRERELEASE]}?${src[t.BUILD]}?`);
152
+ createToken("FULL", `^${src[t.FULLPLAIN]}$`);
153
+ createToken("LOOSEPLAIN", `[v=\\s]*${src[t.MAINVERSIONLOOSE]}${src[t.PRERELEASELOOSE]}?${src[t.BUILD]}?`);
154
+ createToken("LOOSE", `^${src[t.LOOSEPLAIN]}$`);
155
+ createToken("GTLT", "((?:<|>)?=?)");
156
+ createToken("XRANGEIDENTIFIERLOOSE", `${src[t.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`);
157
+ createToken("XRANGEIDENTIFIER", `${src[t.NUMERICIDENTIFIER]}|x|X|\\*`);
158
+ createToken("XRANGEPLAIN", `[v=\\s]*(${src[t.XRANGEIDENTIFIER]})(?:\\.(${src[t.XRANGEIDENTIFIER]})(?:\\.(${src[t.XRANGEIDENTIFIER]})(?:${src[t.PRERELEASE]})?${src[t.BUILD]}?)?)?`);
159
+ createToken("XRANGEPLAINLOOSE", `[v=\\s]*(${src[t.XRANGEIDENTIFIERLOOSE]})(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})(?:${src[t.PRERELEASELOOSE]})?${src[t.BUILD]}?)?)?`);
160
+ createToken("XRANGE", `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAIN]}$`);
161
+ createToken("XRANGELOOSE", `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAINLOOSE]}$`);
162
+ createToken("COERCEPLAIN", `${"(^|[^\\d])(\\d{1,"}${MAX_SAFE_COMPONENT_LENGTH}})(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?`);
163
+ createToken("COERCE", `${src[t.COERCEPLAIN]}(?:$|[^\\d])`);
164
+ createToken("COERCEFULL", src[t.COERCEPLAIN] + `(?:${src[t.PRERELEASE]})?(?:${src[t.BUILD]})?(?:$|[^\\d])`);
165
+ createToken("COERCERTL", src[t.COERCE], true);
166
+ createToken("COERCERTLFULL", src[t.COERCEFULL], true);
167
+ createToken("LONETILDE", "(?:~>?)");
168
+ createToken("TILDETRIM", `(\\s*)${src[t.LONETILDE]}\\s+`, true);
169
+ exports.tildeTrimReplace = "$1~";
170
+ createToken("TILDE", `^${src[t.LONETILDE]}${src[t.XRANGEPLAIN]}$`);
171
+ createToken("TILDELOOSE", `^${src[t.LONETILDE]}${src[t.XRANGEPLAINLOOSE]}$`);
172
+ createToken("LONECARET", "(?:\\^)");
173
+ createToken("CARETTRIM", `(\\s*)${src[t.LONECARET]}\\s+`, true);
174
+ exports.caretTrimReplace = "$1^";
175
+ createToken("CARET", `^${src[t.LONECARET]}${src[t.XRANGEPLAIN]}$`);
176
+ createToken("CARETLOOSE", `^${src[t.LONECARET]}${src[t.XRANGEPLAINLOOSE]}$`);
177
+ createToken("COMPARATORLOOSE", `^${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]})$|^$`);
178
+ createToken("COMPARATOR", `^${src[t.GTLT]}\\s*(${src[t.FULLPLAIN]})$|^$`);
179
+ createToken("COMPARATORTRIM", `(\\s*)${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]}|${src[t.XRANGEPLAIN]})`, true);
180
+ exports.comparatorTrimReplace = "$1$2$3";
181
+ createToken("HYPHENRANGE", `^\\s*(${src[t.XRANGEPLAIN]})\\s+-\\s+(${src[t.XRANGEPLAIN]})\\s*$`);
182
+ createToken("HYPHENRANGELOOSE", `^\\s*(${src[t.XRANGEPLAINLOOSE]})\\s+-\\s+(${src[t.XRANGEPLAINLOOSE]})\\s*$`);
183
+ createToken("STAR", "(<|>)?=?\\s*\\*");
184
+ createToken("GTE0", "^\\s*>=\\s*0\\.0\\.0\\s*$");
185
+ createToken("GTE0PRE", "^\\s*>=\\s*0\\.0\\.0-0\\s*$");
186
+ }
187
+ });
188
+
189
+ // node_modules/semver/internal/parse-options.js
190
+ var require_parse_options = __commonJS({
191
+ "node_modules/semver/internal/parse-options.js"(exports, module) {
192
+ "use strict";
193
+ var looseOption = Object.freeze({ loose: true });
194
+ var emptyOpts = Object.freeze({});
195
+ var parseOptions = (options) => {
196
+ if (!options) {
197
+ return emptyOpts;
198
+ }
199
+ if (typeof options !== "object") {
200
+ return looseOption;
201
+ }
202
+ return options;
203
+ };
204
+ module.exports = parseOptions;
205
+ }
206
+ });
207
+
208
+ // node_modules/semver/internal/identifiers.js
209
+ var require_identifiers = __commonJS({
210
+ "node_modules/semver/internal/identifiers.js"(exports, module) {
211
+ "use strict";
212
+ var numeric = /^[0-9]+$/;
213
+ var compareIdentifiers = (a, b) => {
214
+ if (typeof a === "number" && typeof b === "number") {
215
+ return a === b ? 0 : a < b ? -1 : 1;
216
+ }
217
+ const anum = numeric.test(a);
218
+ const bnum = numeric.test(b);
219
+ if (anum && bnum) {
220
+ a = +a;
221
+ b = +b;
222
+ }
223
+ return a === b ? 0 : anum && !bnum ? -1 : bnum && !anum ? 1 : a < b ? -1 : 1;
224
+ };
225
+ var rcompareIdentifiers = (a, b) => compareIdentifiers(b, a);
226
+ module.exports = {
227
+ compareIdentifiers,
228
+ rcompareIdentifiers
229
+ };
230
+ }
231
+ });
232
+
233
+ // node_modules/semver/classes/semver.js
234
+ var require_semver = __commonJS({
235
+ "node_modules/semver/classes/semver.js"(exports, module) {
236
+ "use strict";
237
+ var debug = require_debug();
238
+ var { MAX_LENGTH, MAX_SAFE_INTEGER } = require_constants();
239
+ var { safeRe: re, t } = require_re();
240
+ var parseOptions = require_parse_options();
241
+ var { compareIdentifiers } = require_identifiers();
242
+ var isPrereleaseIdentifier = (prerelease, identifier) => {
243
+ const identifiers = identifier.split(".");
244
+ if (identifiers.length > prerelease.length) {
245
+ return false;
246
+ }
247
+ for (let i = 0; i < identifiers.length; i++) {
248
+ if (compareIdentifiers(prerelease[i], identifiers[i]) !== 0) {
249
+ return false;
250
+ }
251
+ }
252
+ return true;
253
+ };
254
+ var SemVer = class _SemVer {
255
+ constructor(version, options) {
256
+ options = parseOptions(options);
257
+ if (version instanceof _SemVer) {
258
+ if (version.loose === !!options.loose && version.includePrerelease === !!options.includePrerelease) {
259
+ return version;
260
+ } else {
261
+ version = version.version;
262
+ }
263
+ } else if (typeof version !== "string") {
264
+ throw new TypeError(`Invalid version. Must be a string. Got type "${typeof version}".`);
265
+ }
266
+ if (version.length > MAX_LENGTH) {
267
+ throw new TypeError(
268
+ `version is longer than ${MAX_LENGTH} characters`
269
+ );
270
+ }
271
+ debug("SemVer", version, options);
272
+ this.options = options;
273
+ this.loose = !!options.loose;
274
+ this.includePrerelease = !!options.includePrerelease;
275
+ const m = version.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL]);
276
+ if (!m) {
277
+ throw new TypeError(`Invalid Version: ${version}`);
278
+ }
279
+ this.raw = version;
280
+ this.major = +m[1];
281
+ this.minor = +m[2];
282
+ this.patch = +m[3];
283
+ if (this.major > MAX_SAFE_INTEGER || this.major < 0) {
284
+ throw new TypeError("Invalid major version");
285
+ }
286
+ if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) {
287
+ throw new TypeError("Invalid minor version");
288
+ }
289
+ if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) {
290
+ throw new TypeError("Invalid patch version");
291
+ }
292
+ if (!m[4]) {
293
+ this.prerelease = [];
294
+ } else {
295
+ this.prerelease = m[4].split(".").map((id) => {
296
+ if (/^[0-9]+$/.test(id)) {
297
+ const num = +id;
298
+ if (num >= 0 && num < MAX_SAFE_INTEGER) {
299
+ return num;
300
+ }
301
+ }
302
+ return id;
303
+ });
304
+ }
305
+ this.build = m[5] ? m[5].split(".") : [];
306
+ this.format();
307
+ }
308
+ format() {
309
+ this.version = `${this.major}.${this.minor}.${this.patch}`;
310
+ if (this.prerelease.length) {
311
+ this.version += `-${this.prerelease.join(".")}`;
312
+ }
313
+ return this.version;
314
+ }
315
+ toString() {
316
+ return this.version;
317
+ }
318
+ compare(other) {
319
+ debug("SemVer.compare", this.version, this.options, other);
320
+ if (!(other instanceof _SemVer)) {
321
+ if (typeof other === "string" && other === this.version) {
322
+ return 0;
323
+ }
324
+ other = new _SemVer(other, this.options);
325
+ }
326
+ if (other.version === this.version) {
327
+ return 0;
328
+ }
329
+ return this.compareMain(other) || this.comparePre(other);
330
+ }
331
+ compareMain(other) {
332
+ if (!(other instanceof _SemVer)) {
333
+ other = new _SemVer(other, this.options);
334
+ }
335
+ if (this.major < other.major) {
336
+ return -1;
337
+ }
338
+ if (this.major > other.major) {
339
+ return 1;
340
+ }
341
+ if (this.minor < other.minor) {
342
+ return -1;
343
+ }
344
+ if (this.minor > other.minor) {
345
+ return 1;
346
+ }
347
+ if (this.patch < other.patch) {
348
+ return -1;
349
+ }
350
+ if (this.patch > other.patch) {
351
+ return 1;
352
+ }
353
+ return 0;
354
+ }
355
+ comparePre(other) {
356
+ if (!(other instanceof _SemVer)) {
357
+ other = new _SemVer(other, this.options);
358
+ }
359
+ if (this.prerelease.length && !other.prerelease.length) {
360
+ return -1;
361
+ } else if (!this.prerelease.length && other.prerelease.length) {
362
+ return 1;
363
+ } else if (!this.prerelease.length && !other.prerelease.length) {
364
+ return 0;
365
+ }
366
+ let i = 0;
367
+ do {
368
+ const a = this.prerelease[i];
369
+ const b = other.prerelease[i];
370
+ debug("prerelease compare", i, a, b);
371
+ if (a === void 0 && b === void 0) {
372
+ return 0;
373
+ } else if (b === void 0) {
374
+ return 1;
375
+ } else if (a === void 0) {
376
+ return -1;
377
+ } else if (a === b) {
378
+ continue;
379
+ } else {
380
+ return compareIdentifiers(a, b);
381
+ }
382
+ } while (++i);
383
+ }
384
+ compareBuild(other) {
385
+ if (!(other instanceof _SemVer)) {
386
+ other = new _SemVer(other, this.options);
387
+ }
388
+ let i = 0;
389
+ do {
390
+ const a = this.build[i];
391
+ const b = other.build[i];
392
+ debug("build compare", i, a, b);
393
+ if (a === void 0 && b === void 0) {
394
+ return 0;
395
+ } else if (b === void 0) {
396
+ return 1;
397
+ } else if (a === void 0) {
398
+ return -1;
399
+ } else if (a === b) {
400
+ continue;
401
+ } else {
402
+ return compareIdentifiers(a, b);
403
+ }
404
+ } while (++i);
405
+ }
406
+ // preminor will bump the version up to the next minor release, and immediately
407
+ // down to pre-release. premajor and prepatch work the same way.
408
+ inc(release, identifier, identifierBase) {
409
+ if (release.startsWith("pre")) {
410
+ if (!identifier && identifierBase === false) {
411
+ throw new Error("invalid increment argument: identifier is empty");
412
+ }
413
+ if (identifier) {
414
+ const match = `-${identifier}`.match(this.options.loose ? re[t.PRERELEASELOOSE] : re[t.PRERELEASE]);
415
+ if (!match || match[1] !== identifier) {
416
+ throw new Error(`invalid identifier: ${identifier}`);
417
+ }
418
+ }
419
+ }
420
+ switch (release) {
421
+ case "premajor":
422
+ this.prerelease.length = 0;
423
+ this.patch = 0;
424
+ this.minor = 0;
425
+ this.major++;
426
+ this.inc("pre", identifier, identifierBase);
427
+ break;
428
+ case "preminor":
429
+ this.prerelease.length = 0;
430
+ this.patch = 0;
431
+ this.minor++;
432
+ this.inc("pre", identifier, identifierBase);
433
+ break;
434
+ case "prepatch":
435
+ this.prerelease.length = 0;
436
+ this.inc("patch", identifier, identifierBase);
437
+ this.inc("pre", identifier, identifierBase);
438
+ break;
439
+ // If the input is a non-prerelease version, this acts the same as
440
+ // prepatch.
441
+ case "prerelease":
442
+ if (this.prerelease.length === 0) {
443
+ this.inc("patch", identifier, identifierBase);
444
+ }
445
+ this.inc("pre", identifier, identifierBase);
446
+ break;
447
+ case "release":
448
+ if (this.prerelease.length === 0) {
449
+ throw new Error(`version ${this.raw} is not a prerelease`);
450
+ }
451
+ this.prerelease.length = 0;
452
+ break;
453
+ case "major":
454
+ if (this.minor !== 0 || this.patch !== 0 || this.prerelease.length === 0) {
455
+ this.major++;
456
+ }
457
+ this.minor = 0;
458
+ this.patch = 0;
459
+ this.prerelease = [];
460
+ break;
461
+ case "minor":
462
+ if (this.patch !== 0 || this.prerelease.length === 0) {
463
+ this.minor++;
464
+ }
465
+ this.patch = 0;
466
+ this.prerelease = [];
467
+ break;
468
+ case "patch":
469
+ if (this.prerelease.length === 0) {
470
+ this.patch++;
471
+ }
472
+ this.prerelease = [];
473
+ break;
474
+ // This probably shouldn't be used publicly.
475
+ // 1.0.0 'pre' would become 1.0.0-0 which is the wrong direction.
476
+ case "pre": {
477
+ const base = Number(identifierBase) ? 1 : 0;
478
+ if (this.prerelease.length === 0) {
479
+ this.prerelease = [base];
480
+ } else {
481
+ let i = this.prerelease.length;
482
+ while (--i >= 0) {
483
+ if (typeof this.prerelease[i] === "number") {
484
+ this.prerelease[i]++;
485
+ i = -2;
486
+ }
487
+ }
488
+ if (i === -1) {
489
+ if (identifier === this.prerelease.join(".") && identifierBase === false) {
490
+ throw new Error("invalid increment argument: identifier already exists");
491
+ }
492
+ this.prerelease.push(base);
493
+ }
494
+ }
495
+ if (identifier) {
496
+ let prerelease = [identifier, base];
497
+ if (identifierBase === false) {
498
+ prerelease = [identifier];
499
+ }
500
+ if (isPrereleaseIdentifier(this.prerelease, identifier)) {
501
+ const prereleaseBase = this.prerelease[identifier.split(".").length];
502
+ if (isNaN(prereleaseBase)) {
503
+ this.prerelease = prerelease;
504
+ }
505
+ } else {
506
+ this.prerelease = prerelease;
507
+ }
508
+ }
509
+ break;
510
+ }
511
+ default:
512
+ throw new Error(`invalid increment argument: ${release}`);
513
+ }
514
+ this.raw = this.format();
515
+ if (this.build.length) {
516
+ this.raw += `+${this.build.join(".")}`;
517
+ }
518
+ return this;
519
+ }
520
+ };
521
+ module.exports = SemVer;
522
+ }
523
+ });
524
+
525
+ // node_modules/semver/functions/parse.js
526
+ var require_parse = __commonJS({
527
+ "node_modules/semver/functions/parse.js"(exports, module) {
528
+ "use strict";
529
+ var SemVer = require_semver();
530
+ var parse3 = (version, options, throwErrors = false) => {
531
+ if (version instanceof SemVer) {
532
+ return version;
533
+ }
534
+ try {
535
+ return new SemVer(version, options);
536
+ } catch (er) {
537
+ if (!throwErrors) {
538
+ return null;
539
+ }
540
+ throw er;
541
+ }
542
+ };
543
+ module.exports = parse3;
544
+ }
545
+ });
546
+
547
+ // node_modules/semver/functions/valid.js
548
+ var require_valid = __commonJS({
549
+ "node_modules/semver/functions/valid.js"(exports, module) {
550
+ "use strict";
551
+ var parse3 = require_parse();
552
+ var valid = (version, options) => {
553
+ const v = parse3(version, options);
554
+ return v ? v.version : null;
555
+ };
556
+ module.exports = valid;
557
+ }
558
+ });
559
+
560
+ // node_modules/semver/functions/clean.js
561
+ var require_clean = __commonJS({
562
+ "node_modules/semver/functions/clean.js"(exports, module) {
563
+ "use strict";
564
+ var parse3 = require_parse();
565
+ var clean = (version, options) => {
566
+ const s = parse3(version.trim().replace(/^[=v]+/, ""), options);
567
+ return s ? s.version : null;
568
+ };
569
+ module.exports = clean;
570
+ }
571
+ });
572
+
573
+ // node_modules/semver/functions/inc.js
574
+ var require_inc = __commonJS({
575
+ "node_modules/semver/functions/inc.js"(exports, module) {
576
+ "use strict";
577
+ var SemVer = require_semver();
578
+ var inc = (version, release, options, identifier, identifierBase) => {
579
+ if (typeof options === "string") {
580
+ identifierBase = identifier;
581
+ identifier = options;
582
+ options = void 0;
583
+ }
584
+ try {
585
+ return new SemVer(
586
+ version instanceof SemVer ? version.version : version,
587
+ options
588
+ ).inc(release, identifier, identifierBase).version;
589
+ } catch (er) {
590
+ return null;
591
+ }
592
+ };
593
+ module.exports = inc;
594
+ }
595
+ });
596
+
597
+ // node_modules/semver/functions/diff.js
598
+ var require_diff = __commonJS({
599
+ "node_modules/semver/functions/diff.js"(exports, module) {
600
+ "use strict";
601
+ var parse3 = require_parse();
602
+ var diff = (version1, version2) => {
603
+ const v1 = parse3(version1, null, true);
604
+ const v2 = parse3(version2, null, true);
605
+ const comparison = v1.compare(v2);
606
+ if (comparison === 0) {
607
+ return null;
608
+ }
609
+ const v1Higher = comparison > 0;
610
+ const highVersion = v1Higher ? v1 : v2;
611
+ const lowVersion = v1Higher ? v2 : v1;
612
+ const highHasPre = !!highVersion.prerelease.length;
613
+ const lowHasPre = !!lowVersion.prerelease.length;
614
+ if (lowHasPre && !highHasPre) {
615
+ if (!lowVersion.patch && !lowVersion.minor) {
616
+ return "major";
617
+ }
618
+ if (lowVersion.compareMain(highVersion) === 0) {
619
+ if (lowVersion.minor && !lowVersion.patch) {
620
+ return "minor";
621
+ }
622
+ return "patch";
623
+ }
624
+ }
625
+ const prefix = highHasPre ? "pre" : "";
626
+ if (v1.major !== v2.major) {
627
+ return prefix + "major";
628
+ }
629
+ if (v1.minor !== v2.minor) {
630
+ return prefix + "minor";
631
+ }
632
+ if (v1.patch !== v2.patch) {
633
+ return prefix + "patch";
634
+ }
635
+ return "prerelease";
636
+ };
637
+ module.exports = diff;
638
+ }
639
+ });
640
+
641
+ // node_modules/semver/functions/major.js
642
+ var require_major = __commonJS({
643
+ "node_modules/semver/functions/major.js"(exports, module) {
644
+ "use strict";
645
+ var SemVer = require_semver();
646
+ var major = (a, loose) => new SemVer(a, loose).major;
647
+ module.exports = major;
648
+ }
649
+ });
650
+
651
+ // node_modules/semver/functions/minor.js
652
+ var require_minor = __commonJS({
653
+ "node_modules/semver/functions/minor.js"(exports, module) {
654
+ "use strict";
655
+ var SemVer = require_semver();
656
+ var minor = (a, loose) => new SemVer(a, loose).minor;
657
+ module.exports = minor;
658
+ }
659
+ });
660
+
661
+ // node_modules/semver/functions/patch.js
662
+ var require_patch = __commonJS({
663
+ "node_modules/semver/functions/patch.js"(exports, module) {
664
+ "use strict";
665
+ var SemVer = require_semver();
666
+ var patch = (a, loose) => new SemVer(a, loose).patch;
667
+ module.exports = patch;
668
+ }
669
+ });
670
+
671
+ // node_modules/semver/functions/prerelease.js
672
+ var require_prerelease = __commonJS({
673
+ "node_modules/semver/functions/prerelease.js"(exports, module) {
674
+ "use strict";
675
+ var parse3 = require_parse();
676
+ var prerelease = (version, options) => {
677
+ const parsed = parse3(version, options);
678
+ return parsed && parsed.prerelease.length ? parsed.prerelease : null;
679
+ };
680
+ module.exports = prerelease;
681
+ }
682
+ });
683
+
684
+ // node_modules/semver/functions/compare.js
685
+ var require_compare = __commonJS({
686
+ "node_modules/semver/functions/compare.js"(exports, module) {
687
+ "use strict";
688
+ var SemVer = require_semver();
689
+ var compare = (a, b, loose) => new SemVer(a, loose).compare(new SemVer(b, loose));
690
+ module.exports = compare;
691
+ }
692
+ });
693
+
694
+ // node_modules/semver/functions/rcompare.js
695
+ var require_rcompare = __commonJS({
696
+ "node_modules/semver/functions/rcompare.js"(exports, module) {
697
+ "use strict";
698
+ var compare = require_compare();
699
+ var rcompare = (a, b, loose) => compare(b, a, loose);
700
+ module.exports = rcompare;
701
+ }
702
+ });
703
+
704
+ // node_modules/semver/functions/compare-loose.js
705
+ var require_compare_loose = __commonJS({
706
+ "node_modules/semver/functions/compare-loose.js"(exports, module) {
707
+ "use strict";
708
+ var compare = require_compare();
709
+ var compareLoose = (a, b) => compare(a, b, true);
710
+ module.exports = compareLoose;
711
+ }
712
+ });
713
+
714
+ // node_modules/semver/functions/compare-build.js
715
+ var require_compare_build = __commonJS({
716
+ "node_modules/semver/functions/compare-build.js"(exports, module) {
717
+ "use strict";
718
+ var SemVer = require_semver();
719
+ var compareBuild = (a, b, loose) => {
720
+ const versionA = new SemVer(a, loose);
721
+ const versionB = new SemVer(b, loose);
722
+ return versionA.compare(versionB) || versionA.compareBuild(versionB);
723
+ };
724
+ module.exports = compareBuild;
725
+ }
726
+ });
727
+
728
+ // node_modules/semver/functions/sort.js
729
+ var require_sort = __commonJS({
730
+ "node_modules/semver/functions/sort.js"(exports, module) {
731
+ "use strict";
732
+ var compareBuild = require_compare_build();
733
+ var sort = (list, loose) => list.sort((a, b) => compareBuild(a, b, loose));
734
+ module.exports = sort;
735
+ }
736
+ });
737
+
738
+ // node_modules/semver/functions/rsort.js
739
+ var require_rsort = __commonJS({
740
+ "node_modules/semver/functions/rsort.js"(exports, module) {
741
+ "use strict";
742
+ var compareBuild = require_compare_build();
743
+ var rsort = (list, loose) => list.sort((a, b) => compareBuild(b, a, loose));
744
+ module.exports = rsort;
745
+ }
746
+ });
747
+
748
+ // node_modules/semver/functions/gt.js
749
+ var require_gt = __commonJS({
750
+ "node_modules/semver/functions/gt.js"(exports, module) {
751
+ "use strict";
752
+ var compare = require_compare();
753
+ var gt = (a, b, loose) => compare(a, b, loose) > 0;
754
+ module.exports = gt;
755
+ }
756
+ });
757
+
758
+ // node_modules/semver/functions/lt.js
759
+ var require_lt = __commonJS({
760
+ "node_modules/semver/functions/lt.js"(exports, module) {
761
+ "use strict";
762
+ var compare = require_compare();
763
+ var lt = (a, b, loose) => compare(a, b, loose) < 0;
764
+ module.exports = lt;
765
+ }
766
+ });
767
+
768
+ // node_modules/semver/functions/eq.js
769
+ var require_eq = __commonJS({
770
+ "node_modules/semver/functions/eq.js"(exports, module) {
771
+ "use strict";
772
+ var compare = require_compare();
773
+ var eq = (a, b, loose) => compare(a, b, loose) === 0;
774
+ module.exports = eq;
775
+ }
776
+ });
777
+
778
+ // node_modules/semver/functions/neq.js
779
+ var require_neq = __commonJS({
780
+ "node_modules/semver/functions/neq.js"(exports, module) {
781
+ "use strict";
782
+ var compare = require_compare();
783
+ var neq = (a, b, loose) => compare(a, b, loose) !== 0;
784
+ module.exports = neq;
785
+ }
786
+ });
787
+
788
+ // node_modules/semver/functions/gte.js
789
+ var require_gte = __commonJS({
790
+ "node_modules/semver/functions/gte.js"(exports, module) {
791
+ "use strict";
792
+ var compare = require_compare();
793
+ var gte = (a, b, loose) => compare(a, b, loose) >= 0;
794
+ module.exports = gte;
795
+ }
796
+ });
797
+
798
+ // node_modules/semver/functions/lte.js
799
+ var require_lte = __commonJS({
800
+ "node_modules/semver/functions/lte.js"(exports, module) {
801
+ "use strict";
802
+ var compare = require_compare();
803
+ var lte = (a, b, loose) => compare(a, b, loose) <= 0;
804
+ module.exports = lte;
805
+ }
806
+ });
807
+
808
+ // node_modules/semver/functions/cmp.js
809
+ var require_cmp = __commonJS({
810
+ "node_modules/semver/functions/cmp.js"(exports, module) {
811
+ "use strict";
812
+ var eq = require_eq();
813
+ var neq = require_neq();
814
+ var gt = require_gt();
815
+ var gte = require_gte();
816
+ var lt = require_lt();
817
+ var lte = require_lte();
818
+ var cmp = (a, op, b, loose) => {
819
+ switch (op) {
820
+ case "===":
821
+ if (typeof a === "object") {
822
+ a = a.version;
823
+ }
824
+ if (typeof b === "object") {
825
+ b = b.version;
826
+ }
827
+ return a === b;
828
+ case "!==":
829
+ if (typeof a === "object") {
830
+ a = a.version;
831
+ }
832
+ if (typeof b === "object") {
833
+ b = b.version;
834
+ }
835
+ return a !== b;
836
+ case "":
837
+ case "=":
838
+ case "==":
839
+ return eq(a, b, loose);
840
+ case "!=":
841
+ return neq(a, b, loose);
842
+ case ">":
843
+ return gt(a, b, loose);
844
+ case ">=":
845
+ return gte(a, b, loose);
846
+ case "<":
847
+ return lt(a, b, loose);
848
+ case "<=":
849
+ return lte(a, b, loose);
850
+ default:
851
+ throw new TypeError(`Invalid operator: ${op}`);
852
+ }
853
+ };
854
+ module.exports = cmp;
855
+ }
856
+ });
857
+
858
+ // node_modules/semver/functions/coerce.js
859
+ var require_coerce = __commonJS({
860
+ "node_modules/semver/functions/coerce.js"(exports, module) {
861
+ "use strict";
862
+ var SemVer = require_semver();
863
+ var parse3 = require_parse();
864
+ var { safeRe: re, t } = require_re();
865
+ var coerce = (version, options) => {
866
+ if (version instanceof SemVer) {
867
+ return version;
868
+ }
869
+ if (typeof version === "number") {
870
+ version = String(version);
871
+ }
872
+ if (typeof version !== "string") {
873
+ return null;
874
+ }
875
+ options = options || {};
876
+ let match = null;
877
+ if (!options.rtl) {
878
+ match = version.match(options.includePrerelease ? re[t.COERCEFULL] : re[t.COERCE]);
879
+ } else {
880
+ const coerceRtlRegex = options.includePrerelease ? re[t.COERCERTLFULL] : re[t.COERCERTL];
881
+ let next;
882
+ while ((next = coerceRtlRegex.exec(version)) && (!match || match.index + match[0].length !== version.length)) {
883
+ if (!match || next.index + next[0].length !== match.index + match[0].length) {
884
+ match = next;
885
+ }
886
+ coerceRtlRegex.lastIndex = next.index + next[1].length + next[2].length;
887
+ }
888
+ coerceRtlRegex.lastIndex = -1;
889
+ }
890
+ if (match === null) {
891
+ return null;
892
+ }
893
+ const major = match[2];
894
+ const minor = match[3] || "0";
895
+ const patch = match[4] || "0";
896
+ const prerelease = options.includePrerelease && match[5] ? `-${match[5]}` : "";
897
+ const build = options.includePrerelease && match[6] ? `+${match[6]}` : "";
898
+ return parse3(`${major}.${minor}.${patch}${prerelease}${build}`, options);
899
+ };
900
+ module.exports = coerce;
901
+ }
902
+ });
903
+
904
+ // node_modules/semver/functions/truncate.js
905
+ var require_truncate = __commonJS({
906
+ "node_modules/semver/functions/truncate.js"(exports, module) {
907
+ "use strict";
908
+ var parse3 = require_parse();
909
+ var constants2 = require_constants();
910
+ var SemVer = require_semver();
911
+ var truncate = (version, truncation, options) => {
912
+ if (!constants2.RELEASE_TYPES.includes(truncation)) {
913
+ return null;
914
+ }
915
+ const clonedVersion = cloneInputVersion(version, options);
916
+ return clonedVersion && doTruncation(clonedVersion, truncation);
917
+ };
918
+ var cloneInputVersion = (version, options) => {
919
+ const versionStringToParse = version instanceof SemVer ? version.version : version;
920
+ return parse3(versionStringToParse, options);
921
+ };
922
+ var doTruncation = (version, truncation) => {
923
+ if (isPrerelease(truncation)) {
924
+ return version.version;
925
+ }
926
+ version.prerelease = [];
927
+ switch (truncation) {
928
+ case "major":
929
+ version.minor = 0;
930
+ version.patch = 0;
931
+ break;
932
+ case "minor":
933
+ version.patch = 0;
934
+ break;
935
+ }
936
+ return version.format();
937
+ };
938
+ var isPrerelease = (type) => {
939
+ return type.startsWith("pre");
940
+ };
941
+ module.exports = truncate;
942
+ }
943
+ });
944
+
945
+ // node_modules/semver/internal/lrucache.js
946
+ var require_lrucache = __commonJS({
947
+ "node_modules/semver/internal/lrucache.js"(exports, module) {
948
+ "use strict";
949
+ var LRUCache = class {
950
+ constructor() {
951
+ this.max = 1e3;
952
+ this.map = /* @__PURE__ */ new Map();
953
+ }
954
+ get(key) {
955
+ const value = this.map.get(key);
956
+ if (value === void 0) {
957
+ return void 0;
958
+ } else {
959
+ this.map.delete(key);
960
+ this.map.set(key, value);
961
+ return value;
962
+ }
963
+ }
964
+ delete(key) {
965
+ return this.map.delete(key);
966
+ }
967
+ set(key, value) {
968
+ const deleted = this.delete(key);
969
+ if (!deleted && value !== void 0) {
970
+ if (this.map.size >= this.max) {
971
+ const firstKey = this.map.keys().next().value;
972
+ this.delete(firstKey);
973
+ }
974
+ this.map.set(key, value);
975
+ }
976
+ return this;
977
+ }
978
+ };
979
+ module.exports = LRUCache;
980
+ }
981
+ });
982
+
983
+ // node_modules/semver/internal/trim-comparator-whitespace.js
984
+ var require_trim_comparator_whitespace = __commonJS({
985
+ "node_modules/semver/internal/trim-comparator-whitespace.js"(exports, module) {
986
+ "use strict";
987
+ var {
988
+ MAX_LENGTH,
989
+ MAX_SAFE_BUILD_LENGTH,
990
+ WHITESPACE_CHARACTERS
991
+ } = require_constants();
992
+ var whitespace = new Uint8Array(65536);
993
+ for (const char of WHITESPACE_CHARACTERS) {
994
+ whitespace[char.charCodeAt(0)] = 1;
995
+ }
996
+ var isWhitespace = (char) => char !== void 0 && whitespace[char.charCodeAt(0)] === 1;
997
+ var isVersionPrefix = (char) => char === "v" || char === "=" || isWhitespace(char);
998
+ var isDigit2 = (char) => char !== void 0 && char >= "0" && char <= "9";
999
+ var isLetter = (char) => char !== void 0 && (char >= "a" && char <= "z" || char >= "A" && char <= "Z");
1000
+ var isIdentifierCharacter = (char) => isDigit2(char) || isLetter(char) || char === "-";
1001
+ var isVersionStart = (char) => isDigit2(char) || char === "x" || char === "X" || char === "*";
1002
+ var findDigitsEndIndex = (range, start, limit, digitRuns) => {
1003
+ if (!isDigit2(range[start])) {
1004
+ return start;
1005
+ }
1006
+ if (start >= digitRuns.start && start < digitRuns.end) {
1007
+ return Math.min(start + limit, digitRuns.end);
1008
+ }
1009
+ if (start >= digitRuns.previousStart && start < digitRuns.previousEnd) {
1010
+ return Math.min(start + limit, digitRuns.previousEnd);
1011
+ }
1012
+ let end = start + 1;
1013
+ while (isDigit2(range[end])) {
1014
+ end++;
1015
+ }
1016
+ digitRuns.previousStart = digitRuns.start;
1017
+ digitRuns.previousEnd = digitRuns.end;
1018
+ digitRuns.start = start;
1019
+ digitRuns.end = end;
1020
+ return Math.min(start + limit, end);
1021
+ };
1022
+ var findVersionNumberEndIndex = (range, start, loose, digitRuns) => {
1023
+ if (!loose && range[start] === "0") {
1024
+ return start + 1;
1025
+ }
1026
+ return findDigitsEndIndex(range, start, loose ? MAX_LENGTH : MAX_LENGTH + 1, digitRuns);
1027
+ };
1028
+ var findPrereleaseIdentifierEndIndex = (range, start, loose, digitRuns) => {
1029
+ const digitsEnd = findDigitsEndIndex(range, start, MAX_LENGTH, digitRuns);
1030
+ if (isLetter(range[digitsEnd]) || range[digitsEnd] === "-") {
1031
+ let end = digitsEnd + 1;
1032
+ const limit = end + MAX_SAFE_BUILD_LENGTH;
1033
+ while (end < limit && isIdentifierCharacter(range[end])) {
1034
+ end++;
1035
+ }
1036
+ return end;
1037
+ }
1038
+ return findVersionNumberEndIndex(range, start, loose, digitRuns);
1039
+ };
1040
+ var findPrereleaseEndIndex = (range, start, loose, digitRuns) => {
1041
+ const hyphen = range[start] === "-";
1042
+ if (!loose && !hyphen) {
1043
+ return start;
1044
+ }
1045
+ const identifierStart = start + (hyphen ? 1 : 0);
1046
+ let end = findPrereleaseIdentifierEndIndex(range, identifierStart, loose, digitRuns);
1047
+ if (end === identifierStart) {
1048
+ if (!loose || !hyphen) {
1049
+ return start;
1050
+ }
1051
+ end = findPrereleaseIdentifierEndIndex(range, start, loose, digitRuns);
1052
+ }
1053
+ while (range[end] === ".") {
1054
+ const next = findPrereleaseIdentifierEndIndex(range, end + 1, loose, digitRuns);
1055
+ if (next === end + 1) {
1056
+ break;
1057
+ }
1058
+ end = next;
1059
+ }
1060
+ return end;
1061
+ };
1062
+ var findBuildIdentifierEndIndex = (range, start) => {
1063
+ let end = start;
1064
+ while (end - start < MAX_SAFE_BUILD_LENGTH && isIdentifierCharacter(range[end])) {
1065
+ end++;
1066
+ }
1067
+ return end;
1068
+ };
1069
+ var findBuildEndIndex = (range, start) => {
1070
+ if (range[start] !== "+") {
1071
+ return start;
1072
+ }
1073
+ let end = findBuildIdentifierEndIndex(range, start + 1);
1074
+ if (end === start + 1) {
1075
+ return start;
1076
+ }
1077
+ while (range[end] === ".") {
1078
+ const next = findBuildIdentifierEndIndex(range, end + 1);
1079
+ if (next === end + 1) {
1080
+ break;
1081
+ }
1082
+ end = next;
1083
+ }
1084
+ return end;
1085
+ };
1086
+ var findLooseFullVersionEndIndex = (range, start, digitRuns) => {
1087
+ let end = start;
1088
+ for (let component = 0; component < 3; component++) {
1089
+ const next = findVersionNumberEndIndex(range, end, true, digitRuns);
1090
+ if (next === end) {
1091
+ return start;
1092
+ }
1093
+ end = next;
1094
+ if (component < 2) {
1095
+ if (range[end] !== ".") {
1096
+ return start;
1097
+ }
1098
+ end++;
1099
+ }
1100
+ }
1101
+ const prereleaseEnd = findPrereleaseEndIndex(range, end, true, digitRuns);
1102
+ return findBuildEndIndex(range, prereleaseEnd);
1103
+ };
1104
+ var findPartialVersionComponentEndIndex = (range, start, digitRuns) => {
1105
+ if (isDigit2(range[start])) {
1106
+ return findVersionNumberEndIndex(range, start, false, digitRuns);
1107
+ }
1108
+ return isVersionStart(range[start]) ? start + 1 : start;
1109
+ };
1110
+ var findPartialVersionEndIndex = (range, start, digitRuns) => {
1111
+ let end = findPartialVersionComponentEndIndex(range, start, digitRuns);
1112
+ for (let component = 0; component < 2; component++) {
1113
+ if (range[end] !== ".") {
1114
+ return end;
1115
+ }
1116
+ const next = findPartialVersionComponentEndIndex(range, end + 1, digitRuns);
1117
+ if (next === end + 1) {
1118
+ return end;
1119
+ }
1120
+ end = next;
1121
+ }
1122
+ const prereleaseEnd = findPrereleaseEndIndex(range, end, false, digitRuns);
1123
+ return findBuildEndIndex(range, prereleaseEnd);
1124
+ };
1125
+ var findVersionEndIndex = (range, start, digitRuns) => {
1126
+ const fullVersionEnd = findLooseFullVersionEndIndex(range, start, digitRuns);
1127
+ return fullVersionEnd !== start ? fullVersionEnd : findPartialVersionEndIndex(range, start, digitRuns);
1128
+ };
1129
+ var findRemovableWhitespaceIndex = (range, matchStart) => {
1130
+ let position = matchStart;
1131
+ if (isWhitespace(range[position])) {
1132
+ position++;
1133
+ }
1134
+ if (range[position] === "<" || range[position] === ">") {
1135
+ position++;
1136
+ }
1137
+ if (range[position] === "=") {
1138
+ position++;
1139
+ }
1140
+ return isWhitespace(range[position]) ? position : -1;
1141
+ };
1142
+ var trimComparatorWhitespace = (range) => {
1143
+ let result = "";
1144
+ let copyFrom = 0;
1145
+ let cursor = 0;
1146
+ const digitRuns = { start: -1, end: -1, previousStart: -1, previousEnd: -1 };
1147
+ while (cursor < range.length) {
1148
+ const matchStart = cursor;
1149
+ if (range[cursor] === "<" || range[cursor] === ">") {
1150
+ cursor++;
1151
+ } else if (!isVersionPrefix(range[cursor]) && !isVersionStart(range[cursor])) {
1152
+ cursor++;
1153
+ continue;
1154
+ }
1155
+ while (cursor < range.length && isVersionPrefix(range[cursor])) {
1156
+ cursor++;
1157
+ }
1158
+ if (!isVersionStart(range[cursor])) {
1159
+ continue;
1160
+ }
1161
+ const whitespacePosition = findRemovableWhitespaceIndex(range, matchStart);
1162
+ if (whitespacePosition !== -1) {
1163
+ result += range.slice(copyFrom, whitespacePosition);
1164
+ copyFrom = whitespacePosition + 1;
1165
+ }
1166
+ cursor = findVersionEndIndex(range, cursor, digitRuns);
1167
+ }
1168
+ return result + range.slice(copyFrom);
1169
+ };
1170
+ module.exports = trimComparatorWhitespace;
1171
+ }
1172
+ });
1173
+
1174
+ // node_modules/semver/classes/range.js
1175
+ var require_range = __commonJS({
1176
+ "node_modules/semver/classes/range.js"(exports, module) {
1177
+ "use strict";
1178
+ var SPACE_CHARACTERS = /\s+/g;
1179
+ var Range = class _Range {
1180
+ constructor(range, options) {
1181
+ options = parseOptions(options);
1182
+ if (range instanceof _Range) {
1183
+ if (range.loose === !!options.loose && range.includePrerelease === !!options.includePrerelease) {
1184
+ return range;
1185
+ } else {
1186
+ return new _Range(range.raw, options);
1187
+ }
1188
+ }
1189
+ if (range instanceof Comparator) {
1190
+ this.raw = range.value;
1191
+ this.set = [[range]];
1192
+ this.formatted = void 0;
1193
+ return this;
1194
+ }
1195
+ this.options = options;
1196
+ this.loose = !!options.loose;
1197
+ this.includePrerelease = !!options.includePrerelease;
1198
+ this.raw = range.trim().replace(SPACE_CHARACTERS, " ");
1199
+ this.set = this.raw.split("||").map((r) => this.parseRange(r.trim())).filter((c) => c.length);
1200
+ if (!this.set.length) {
1201
+ throw new TypeError(`Invalid SemVer Range: ${this.raw}`);
1202
+ }
1203
+ if (this.set.length > 1) {
1204
+ const first = this.set[0];
1205
+ this.set = this.set.filter((c) => !isNullSet(c[0]));
1206
+ if (this.set.length === 0) {
1207
+ this.set = [first];
1208
+ } else if (this.set.length > 1) {
1209
+ for (const c of this.set) {
1210
+ if (c.length === 1 && isAny(c[0])) {
1211
+ this.set = [c];
1212
+ break;
1213
+ }
1214
+ }
1215
+ }
1216
+ }
1217
+ this.formatted = void 0;
1218
+ }
1219
+ get range() {
1220
+ if (this.formatted === void 0) {
1221
+ this.formatted = "";
1222
+ for (let i = 0; i < this.set.length; i++) {
1223
+ if (i > 0) {
1224
+ this.formatted += "||";
1225
+ }
1226
+ const comps = this.set[i];
1227
+ for (let k = 0; k < comps.length; k++) {
1228
+ if (k > 0) {
1229
+ this.formatted += " ";
1230
+ }
1231
+ this.formatted += comps[k].toString().trim();
1232
+ }
1233
+ }
1234
+ }
1235
+ return this.formatted;
1236
+ }
1237
+ format() {
1238
+ return this.range;
1239
+ }
1240
+ toString() {
1241
+ return this.range;
1242
+ }
1243
+ parseRange(range) {
1244
+ range = range.replace(BUILDSTRIPRE, "");
1245
+ const memoOpts = (this.options.includePrerelease && FLAG_INCLUDE_PRERELEASE) | (this.options.loose && FLAG_LOOSE);
1246
+ const memoKey = memoOpts + ":" + range;
1247
+ const cached = cache.get(memoKey);
1248
+ if (cached) {
1249
+ return cached;
1250
+ }
1251
+ const loose = this.options.loose;
1252
+ const hr = loose ? re[t.HYPHENRANGELOOSE] : re[t.HYPHENRANGE];
1253
+ range = range.replace(hr, hyphenReplace(this.options.includePrerelease));
1254
+ debug("hyphen replace", range);
1255
+ range = trimComparatorWhitespace(range);
1256
+ debug("comparator trim", range);
1257
+ range = range.replace(re[t.TILDETRIM], tildeTrimReplace);
1258
+ debug("tilde trim", range);
1259
+ range = range.replace(re[t.CARETTRIM], caretTrimReplace);
1260
+ debug("caret trim", range);
1261
+ let rangeList = range.split(" ").map((comp) => parseComparator(comp, this.options)).join(" ").split(/\s+/).map((comp) => replaceGTE0(comp, this.options));
1262
+ if (loose) {
1263
+ rangeList = rangeList.filter((comp) => {
1264
+ debug("loose invalid filter", comp, this.options);
1265
+ return !!comp.match(re[t.COMPARATORLOOSE]);
1266
+ });
1267
+ }
1268
+ debug("range list", rangeList);
1269
+ const rangeMap = /* @__PURE__ */ new Map();
1270
+ const comparators = rangeList.map((comp) => new Comparator(comp, this.options));
1271
+ for (const comp of comparators) {
1272
+ if (isNullSet(comp)) {
1273
+ return [comp];
1274
+ }
1275
+ rangeMap.set(comp.value, comp);
1276
+ }
1277
+ if (rangeMap.size > 1 && rangeMap.has("")) {
1278
+ rangeMap.delete("");
1279
+ }
1280
+ const result = [...rangeMap.values()];
1281
+ cache.set(memoKey, result);
1282
+ return result;
1283
+ }
1284
+ intersects(range, options) {
1285
+ if (!(range instanceof _Range)) {
1286
+ throw new TypeError("a Range is required");
1287
+ }
1288
+ return this.set.some((thisComparators) => {
1289
+ return isSatisfiable(thisComparators, options) && range.set.some((rangeComparators) => {
1290
+ return isSatisfiable(rangeComparators, options) && thisComparators.every((thisComparator) => {
1291
+ return rangeComparators.every((rangeComparator) => {
1292
+ return thisComparator.intersects(rangeComparator, options);
1293
+ });
1294
+ });
1295
+ });
1296
+ });
1297
+ }
1298
+ // if ANY of the sets match ALL of its comparators, then pass
1299
+ test(version) {
1300
+ if (!version) {
1301
+ return false;
1302
+ }
1303
+ if (typeof version === "string") {
1304
+ try {
1305
+ version = new SemVer(version, this.options);
1306
+ } catch (er) {
1307
+ return false;
1308
+ }
1309
+ }
1310
+ for (let i = 0; i < this.set.length; i++) {
1311
+ if (testSet(this.set[i], version, this.options)) {
1312
+ return true;
1313
+ }
1314
+ }
1315
+ return false;
1316
+ }
1317
+ };
1318
+ module.exports = Range;
1319
+ var LRU = require_lrucache();
1320
+ var cache = new LRU();
1321
+ var parseOptions = require_parse_options();
1322
+ var Comparator = require_comparator();
1323
+ var debug = require_debug();
1324
+ var SemVer = require_semver();
1325
+ var trimComparatorWhitespace = require_trim_comparator_whitespace();
1326
+ var {
1327
+ safeRe: re,
1328
+ src,
1329
+ t,
1330
+ tildeTrimReplace,
1331
+ caretTrimReplace
1332
+ } = require_re();
1333
+ var { FLAG_INCLUDE_PRERELEASE, FLAG_LOOSE } = require_constants();
1334
+ var BUILDSTRIPRE = new RegExp(src[t.BUILD], "g");
1335
+ var isNullSet = (c) => c.value === "<0.0.0-0";
1336
+ var isAny = (c) => c.value === "";
1337
+ var isSatisfiable = (comparators, options) => {
1338
+ let result = true;
1339
+ const remainingComparators = comparators.slice();
1340
+ let testComparator = remainingComparators.pop();
1341
+ while (result && remainingComparators.length) {
1342
+ result = remainingComparators.every((otherComparator) => {
1343
+ return testComparator.intersects(otherComparator, options);
1344
+ });
1345
+ testComparator = remainingComparators.pop();
1346
+ }
1347
+ return result;
1348
+ };
1349
+ var parseComparator = (comp, options) => {
1350
+ comp = comp.replace(re[t.BUILD], "");
1351
+ debug("comp", comp, options);
1352
+ comp = replaceCarets(comp, options);
1353
+ debug("caret", comp);
1354
+ comp = replaceTildes(comp, options);
1355
+ debug("tildes", comp);
1356
+ comp = replaceXRanges(comp, options);
1357
+ debug("xrange", comp);
1358
+ comp = replaceStars(comp, options);
1359
+ debug("stars", comp);
1360
+ return comp;
1361
+ };
1362
+ var isX = (id) => !id || id.toLowerCase() === "x" || id === "*";
1363
+ var invalidXRangeOrder = (M, m, p) => isX(M) && !isX(m) || isX(m) && p && !isX(p);
1364
+ var replaceTildes = (comp, options) => {
1365
+ return comp.trim().split(/\s+/).map((c) => replaceTilde(c, options)).join(" ");
1366
+ };
1367
+ var replaceTilde = (comp, options) => {
1368
+ const r = options.loose ? re[t.TILDELOOSE] : re[t.TILDE];
1369
+ const z = options.includePrerelease ? "-0" : "";
1370
+ return comp.replace(r, (_, M, m, p, pr) => {
1371
+ debug("tilde", comp, _, M, m, p, pr);
1372
+ let ret;
1373
+ if (isX(M)) {
1374
+ ret = "";
1375
+ } else if (isX(m)) {
1376
+ ret = `>=${M}.0.0${z} <${+M + 1}.0.0-0`;
1377
+ } else if (isX(p)) {
1378
+ ret = `>=${M}.${m}.0${z} <${M}.${+m + 1}.0-0`;
1379
+ } else if (pr) {
1380
+ debug("replaceTilde pr", pr);
1381
+ ret = `>=${M}.${m}.${p}-${pr} <${M}.${+m + 1}.0-0`;
1382
+ } else {
1383
+ ret = `>=${M}.${m}.${p} <${M}.${+m + 1}.0-0`;
1384
+ }
1385
+ debug("tilde return", ret);
1386
+ return ret;
1387
+ });
1388
+ };
1389
+ var replaceCarets = (comp, options) => {
1390
+ return comp.trim().split(/\s+/).map((c) => replaceCaret(c, options)).join(" ");
1391
+ };
1392
+ var replaceCaret = (comp, options) => {
1393
+ debug("caret", comp, options);
1394
+ const r = options.loose ? re[t.CARETLOOSE] : re[t.CARET];
1395
+ const z = options.includePrerelease ? "-0" : "";
1396
+ return comp.replace(r, (_, M, m, p, pr) => {
1397
+ debug("caret", comp, _, M, m, p, pr);
1398
+ let ret;
1399
+ if (isX(M)) {
1400
+ ret = "";
1401
+ } else if (isX(m)) {
1402
+ ret = `>=${M}.0.0${z} <${+M + 1}.0.0-0`;
1403
+ } else if (isX(p)) {
1404
+ if (M === "0") {
1405
+ ret = `>=${M}.${m}.0${z} <${M}.${+m + 1}.0-0`;
1406
+ } else {
1407
+ ret = `>=${M}.${m}.0${z} <${+M + 1}.0.0-0`;
1408
+ }
1409
+ } else if (pr) {
1410
+ debug("replaceCaret pr", pr);
1411
+ if (M === "0") {
1412
+ if (m === "0") {
1413
+ ret = `>=${M}.${m}.${p}-${pr} <${M}.${m}.${+p + 1}-0`;
1414
+ } else {
1415
+ ret = `>=${M}.${m}.${p}-${pr} <${M}.${+m + 1}.0-0`;
1416
+ }
1417
+ } else {
1418
+ ret = `>=${M}.${m}.${p}-${pr} <${+M + 1}.0.0-0`;
1419
+ }
1420
+ } else {
1421
+ debug("no pr");
1422
+ if (M === "0") {
1423
+ if (m === "0") {
1424
+ ret = `>=${M}.${m}.${p} <${M}.${m}.${+p + 1}-0`;
1425
+ } else {
1426
+ ret = `>=${M}.${m}.${p} <${M}.${+m + 1}.0-0`;
1427
+ }
1428
+ } else {
1429
+ ret = `>=${M}.${m}.${p} <${+M + 1}.0.0-0`;
1430
+ }
1431
+ }
1432
+ debug("caret return", ret);
1433
+ return ret;
1434
+ });
1435
+ };
1436
+ var replaceXRanges = (comp, options) => {
1437
+ debug("replaceXRanges", comp, options);
1438
+ return comp.split(/\s+/).map((c) => replaceXRange(c, options)).join(" ");
1439
+ };
1440
+ var replaceXRange = (comp, options) => {
1441
+ comp = comp.trim();
1442
+ const r = options.loose ? re[t.XRANGELOOSE] : re[t.XRANGE];
1443
+ return comp.replace(r, (ret, gtlt, M, m, p, pr) => {
1444
+ debug("xRange", comp, ret, gtlt, M, m, p, pr);
1445
+ if (invalidXRangeOrder(M, m, p)) {
1446
+ return comp;
1447
+ }
1448
+ const xM = isX(M);
1449
+ const xm = xM || isX(m);
1450
+ const xp = xm || isX(p);
1451
+ const anyX = xp;
1452
+ if (gtlt === "=" && anyX) {
1453
+ gtlt = "";
1454
+ }
1455
+ pr = options.includePrerelease ? "-0" : "";
1456
+ if (xM) {
1457
+ if (gtlt === ">" || gtlt === "<") {
1458
+ ret = "<0.0.0-0";
1459
+ } else {
1460
+ ret = "*";
1461
+ }
1462
+ } else if (gtlt && anyX) {
1463
+ if (xm) {
1464
+ m = 0;
1465
+ }
1466
+ p = 0;
1467
+ if (gtlt === ">") {
1468
+ gtlt = ">=";
1469
+ if (xm) {
1470
+ M = +M + 1;
1471
+ m = 0;
1472
+ p = 0;
1473
+ } else {
1474
+ m = +m + 1;
1475
+ p = 0;
1476
+ }
1477
+ } else if (gtlt === "<=") {
1478
+ gtlt = "<";
1479
+ if (xm) {
1480
+ M = +M + 1;
1481
+ } else {
1482
+ m = +m + 1;
1483
+ }
1484
+ }
1485
+ if (gtlt === "<") {
1486
+ pr = "-0";
1487
+ }
1488
+ ret = `${gtlt + M}.${m}.${p}${pr}`;
1489
+ } else if (xm) {
1490
+ ret = `>=${M}.0.0${pr} <${+M + 1}.0.0-0`;
1491
+ } else if (xp) {
1492
+ ret = `>=${M}.${m}.0${pr} <${M}.${+m + 1}.0-0`;
1493
+ }
1494
+ debug("xRange return", ret);
1495
+ return ret;
1496
+ });
1497
+ };
1498
+ var replaceStars = (comp, options) => {
1499
+ debug("replaceStars", comp, options);
1500
+ return comp.trim().replace(re[t.STAR], "");
1501
+ };
1502
+ var replaceGTE0 = (comp, options) => {
1503
+ debug("replaceGTE0", comp, options);
1504
+ return comp.trim().replace(re[options.includePrerelease ? t.GTE0PRE : t.GTE0], "");
1505
+ };
1506
+ var hyphenReplace = (incPr) => ($0, from, fM, fm, fp, fpr, fb, to, tM, tm, tp, tpr) => {
1507
+ if (isX(fM)) {
1508
+ from = "";
1509
+ } else if (isX(fm)) {
1510
+ from = `>=${fM}.0.0${incPr ? "-0" : ""}`;
1511
+ } else if (isX(fp)) {
1512
+ from = `>=${fM}.${fm}.0${incPr ? "-0" : ""}`;
1513
+ } else if (fpr) {
1514
+ from = `>=${from}`;
1515
+ } else {
1516
+ from = `>=${from}${incPr ? "-0" : ""}`;
1517
+ }
1518
+ if (isX(tM)) {
1519
+ to = "";
1520
+ } else if (isX(tm)) {
1521
+ to = `<${+tM + 1}.0.0-0`;
1522
+ } else if (isX(tp)) {
1523
+ to = `<${tM}.${+tm + 1}.0-0`;
1524
+ } else if (tpr) {
1525
+ to = `<=${tM}.${tm}.${tp}-${tpr}`;
1526
+ } else if (incPr) {
1527
+ to = `<${tM}.${tm}.${+tp + 1}-0`;
1528
+ } else {
1529
+ to = `<=${to}`;
1530
+ }
1531
+ return `${from} ${to}`.trim();
1532
+ };
1533
+ var testSet = (set, version, options) => {
1534
+ for (let i = 0; i < set.length; i++) {
1535
+ if (!set[i].test(version)) {
1536
+ return false;
1537
+ }
1538
+ }
1539
+ if (version.prerelease.length && !options.includePrerelease) {
1540
+ for (let i = 0; i < set.length; i++) {
1541
+ debug(set[i].semver);
1542
+ if (set[i].semver === Comparator.ANY) {
1543
+ continue;
1544
+ }
1545
+ if (set[i].semver.prerelease.length > 0) {
1546
+ const allowed = set[i].semver;
1547
+ if (allowed.major === version.major && allowed.minor === version.minor && allowed.patch === version.patch) {
1548
+ return true;
1549
+ }
1550
+ }
1551
+ }
1552
+ return false;
1553
+ }
1554
+ return true;
1555
+ };
1556
+ }
1557
+ });
1558
+
1559
+ // node_modules/semver/classes/comparator.js
1560
+ var require_comparator = __commonJS({
1561
+ "node_modules/semver/classes/comparator.js"(exports, module) {
1562
+ "use strict";
1563
+ var ANY = /* @__PURE__ */ Symbol("SemVer ANY");
1564
+ var Comparator = class _Comparator {
1565
+ static get ANY() {
1566
+ return ANY;
1567
+ }
1568
+ constructor(comp, options) {
1569
+ options = parseOptions(options);
1570
+ if (comp instanceof _Comparator) {
1571
+ if (comp.loose === !!options.loose) {
1572
+ return comp;
1573
+ } else {
1574
+ comp = comp.value;
1575
+ }
1576
+ }
1577
+ comp = comp.trim().split(/\s+/).join(" ");
1578
+ debug("comparator", comp, options);
1579
+ this.options = options;
1580
+ this.loose = !!options.loose;
1581
+ this.parse(comp);
1582
+ if (this.semver === ANY) {
1583
+ this.value = "";
1584
+ } else {
1585
+ this.value = this.operator + this.semver.version;
1586
+ }
1587
+ debug("comp", this);
1588
+ }
1589
+ parse(comp) {
1590
+ const r = this.options.loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR];
1591
+ const m = comp.match(r);
1592
+ if (!m) {
1593
+ throw new TypeError(`Invalid comparator: ${comp}`);
1594
+ }
1595
+ this.operator = m[1] !== void 0 ? m[1] : "";
1596
+ if (this.operator === "=") {
1597
+ this.operator = "";
1598
+ }
1599
+ if (!m[2]) {
1600
+ this.semver = ANY;
1601
+ } else {
1602
+ this.semver = new SemVer(m[2], this.options.loose);
1603
+ }
1604
+ }
1605
+ toString() {
1606
+ return this.value;
1607
+ }
1608
+ test(version) {
1609
+ debug("Comparator.test", version, this.options.loose);
1610
+ if (this.semver === ANY || version === ANY) {
1611
+ return true;
1612
+ }
1613
+ if (typeof version === "string") {
1614
+ try {
1615
+ version = new SemVer(version, this.options);
1616
+ } catch (er) {
1617
+ return false;
1618
+ }
1619
+ }
1620
+ return cmp(version, this.operator, this.semver, this.options);
1621
+ }
1622
+ intersects(comp, options) {
1623
+ if (!(comp instanceof _Comparator)) {
1624
+ throw new TypeError("a Comparator is required");
1625
+ }
1626
+ if (this.operator === "") {
1627
+ if (this.value === "") {
1628
+ return true;
1629
+ }
1630
+ return new Range(comp.value, options).test(this.value);
1631
+ } else if (comp.operator === "") {
1632
+ if (comp.value === "") {
1633
+ return true;
1634
+ }
1635
+ return new Range(this.value, options).test(comp.semver);
1636
+ }
1637
+ options = parseOptions(options);
1638
+ if (options.includePrerelease && (this.value === "<0.0.0-0" || comp.value === "<0.0.0-0")) {
1639
+ return false;
1640
+ }
1641
+ if (!options.includePrerelease && (this.value.startsWith("<0.0.0") || comp.value.startsWith("<0.0.0"))) {
1642
+ return false;
1643
+ }
1644
+ if (this.operator.startsWith(">") && comp.operator.startsWith(">")) {
1645
+ return true;
1646
+ }
1647
+ if (this.operator.startsWith("<") && comp.operator.startsWith("<")) {
1648
+ return true;
1649
+ }
1650
+ if (this.semver.version === comp.semver.version && this.operator.includes("=") && comp.operator.includes("=")) {
1651
+ return true;
1652
+ }
1653
+ if (cmp(this.semver, "<", comp.semver, options) && this.operator.startsWith(">") && comp.operator.startsWith("<")) {
1654
+ return true;
1655
+ }
1656
+ if (cmp(this.semver, ">", comp.semver, options) && this.operator.startsWith("<") && comp.operator.startsWith(">")) {
1657
+ return true;
1658
+ }
1659
+ return false;
1660
+ }
1661
+ };
1662
+ module.exports = Comparator;
1663
+ var parseOptions = require_parse_options();
1664
+ var { safeRe: re, t } = require_re();
1665
+ var cmp = require_cmp();
1666
+ var debug = require_debug();
1667
+ var SemVer = require_semver();
1668
+ var Range = require_range();
1669
+ }
1670
+ });
1671
+
1672
+ // node_modules/semver/functions/satisfies.js
1673
+ var require_satisfies = __commonJS({
1674
+ "node_modules/semver/functions/satisfies.js"(exports, module) {
1675
+ "use strict";
1676
+ var Range = require_range();
1677
+ var satisfies = (version, range, options) => {
1678
+ try {
1679
+ range = new Range(range, options);
1680
+ } catch (er) {
1681
+ return false;
1682
+ }
1683
+ return range.test(version);
1684
+ };
1685
+ module.exports = satisfies;
1686
+ }
1687
+ });
1688
+
1689
+ // node_modules/semver/ranges/to-comparators.js
1690
+ var require_to_comparators = __commonJS({
1691
+ "node_modules/semver/ranges/to-comparators.js"(exports, module) {
1692
+ "use strict";
1693
+ var Range = require_range();
1694
+ var toComparators = (range, options) => new Range(range, options).set.map((comp) => comp.map((c) => c.value).join(" ").trim().split(" "));
1695
+ module.exports = toComparators;
1696
+ }
1697
+ });
1698
+
1699
+ // node_modules/semver/ranges/max-satisfying.js
1700
+ var require_max_satisfying = __commonJS({
1701
+ "node_modules/semver/ranges/max-satisfying.js"(exports, module) {
1702
+ "use strict";
1703
+ var SemVer = require_semver();
1704
+ var Range = require_range();
1705
+ var maxSatisfying = (versions, range, options) => {
1706
+ let max = null;
1707
+ let maxSV = null;
1708
+ let rangeObj = null;
1709
+ try {
1710
+ rangeObj = new Range(range, options);
1711
+ } catch (er) {
1712
+ return null;
1713
+ }
1714
+ versions.forEach((v) => {
1715
+ if (rangeObj.test(v)) {
1716
+ if (!max || maxSV.compare(v) === -1) {
1717
+ max = v;
1718
+ maxSV = new SemVer(max, options);
1719
+ }
1720
+ }
1721
+ });
1722
+ return max;
1723
+ };
1724
+ module.exports = maxSatisfying;
1725
+ }
1726
+ });
1727
+
1728
+ // node_modules/semver/ranges/min-satisfying.js
1729
+ var require_min_satisfying = __commonJS({
1730
+ "node_modules/semver/ranges/min-satisfying.js"(exports, module) {
1731
+ "use strict";
1732
+ var SemVer = require_semver();
1733
+ var Range = require_range();
1734
+ var minSatisfying = (versions, range, options) => {
1735
+ let min = null;
1736
+ let minSV = null;
1737
+ let rangeObj = null;
1738
+ try {
1739
+ rangeObj = new Range(range, options);
1740
+ } catch (er) {
1741
+ return null;
1742
+ }
1743
+ versions.forEach((v) => {
1744
+ if (rangeObj.test(v)) {
1745
+ if (!min || minSV.compare(v) === 1) {
1746
+ min = v;
1747
+ minSV = new SemVer(min, options);
1748
+ }
1749
+ }
1750
+ });
1751
+ return min;
1752
+ };
1753
+ module.exports = minSatisfying;
1754
+ }
1755
+ });
1756
+
1757
+ // node_modules/semver/ranges/min-version.js
1758
+ var require_min_version = __commonJS({
1759
+ "node_modules/semver/ranges/min-version.js"(exports, module) {
1760
+ "use strict";
1761
+ var SemVer = require_semver();
1762
+ var Range = require_range();
1763
+ var gt = require_gt();
1764
+ var minVersion = (range, loose) => {
1765
+ range = new Range(range, loose);
1766
+ let minver = new SemVer("0.0.0");
1767
+ if (range.test(minver)) {
1768
+ return minver;
1769
+ }
1770
+ minver = new SemVer("0.0.0-0");
1771
+ if (range.test(minver)) {
1772
+ return minver;
1773
+ }
1774
+ minver = null;
1775
+ for (let i = 0; i < range.set.length; ++i) {
1776
+ const comparators = range.set[i];
1777
+ let setMin = null;
1778
+ comparators.forEach((comparator) => {
1779
+ const compver = new SemVer(comparator.semver.version);
1780
+ switch (comparator.operator) {
1781
+ case ">":
1782
+ if (compver.prerelease.length === 0) {
1783
+ compver.patch++;
1784
+ } else {
1785
+ compver.prerelease.push(0);
1786
+ }
1787
+ compver.raw = compver.format();
1788
+ /* fallthrough */
1789
+ case "":
1790
+ case ">=":
1791
+ if (!setMin || gt(compver, setMin)) {
1792
+ setMin = compver;
1793
+ }
1794
+ break;
1795
+ case "<":
1796
+ case "<=":
1797
+ break;
1798
+ /* istanbul ignore next */
1799
+ default:
1800
+ throw new Error(`Unexpected operation: ${comparator.operator}`);
1801
+ }
1802
+ });
1803
+ if (setMin && (!minver || gt(minver, setMin))) {
1804
+ minver = setMin;
1805
+ }
1806
+ }
1807
+ if (minver && range.test(minver)) {
1808
+ return minver;
1809
+ }
1810
+ return null;
1811
+ };
1812
+ module.exports = minVersion;
1813
+ }
1814
+ });
1815
+
1816
+ // node_modules/semver/ranges/valid.js
1817
+ var require_valid2 = __commonJS({
1818
+ "node_modules/semver/ranges/valid.js"(exports, module) {
1819
+ "use strict";
1820
+ var Range = require_range();
1821
+ var validRange = (range, options) => {
1822
+ try {
1823
+ return new Range(range, options).range || "*";
1824
+ } catch (er) {
1825
+ return null;
1826
+ }
1827
+ };
1828
+ module.exports = validRange;
1829
+ }
1830
+ });
1831
+
1832
+ // node_modules/semver/ranges/outside.js
1833
+ var require_outside = __commonJS({
1834
+ "node_modules/semver/ranges/outside.js"(exports, module) {
1835
+ "use strict";
1836
+ var SemVer = require_semver();
1837
+ var Comparator = require_comparator();
1838
+ var { ANY } = Comparator;
1839
+ var Range = require_range();
1840
+ var satisfies = require_satisfies();
1841
+ var gt = require_gt();
1842
+ var lt = require_lt();
1843
+ var lte = require_lte();
1844
+ var gte = require_gte();
1845
+ var outside = (version, range, hilo, options) => {
1846
+ version = new SemVer(version, options);
1847
+ range = new Range(range, options);
1848
+ let gtfn, ltefn, ltfn, comp, ecomp;
1849
+ switch (hilo) {
1850
+ case ">":
1851
+ gtfn = gt;
1852
+ ltefn = lte;
1853
+ ltfn = lt;
1854
+ comp = ">";
1855
+ ecomp = ">=";
1856
+ break;
1857
+ case "<":
1858
+ gtfn = lt;
1859
+ ltefn = gte;
1860
+ ltfn = gt;
1861
+ comp = "<";
1862
+ ecomp = "<=";
1863
+ break;
1864
+ default:
1865
+ throw new TypeError('Must provide a hilo val of "<" or ">"');
1866
+ }
1867
+ if (satisfies(version, range, options)) {
1868
+ return false;
1869
+ }
1870
+ for (let i = 0; i < range.set.length; ++i) {
1871
+ const comparators = range.set[i];
1872
+ let high = null;
1873
+ let low = null;
1874
+ comparators.forEach((comparator) => {
1875
+ if (comparator.semver === ANY) {
1876
+ comparator = new Comparator(">=0.0.0");
1877
+ }
1878
+ high = high || comparator;
1879
+ low = low || comparator;
1880
+ if (gtfn(comparator.semver, high.semver, options)) {
1881
+ high = comparator;
1882
+ } else if (ltfn(comparator.semver, low.semver, options)) {
1883
+ low = comparator;
1884
+ }
1885
+ });
1886
+ if (high.operator === comp || high.operator === ecomp) {
1887
+ return false;
1888
+ }
1889
+ if ((!low.operator || low.operator === comp) && ltefn(version, low.semver)) {
1890
+ return false;
1891
+ } else if (low.operator === ecomp && ltfn(version, low.semver)) {
1892
+ return false;
1893
+ }
1894
+ }
1895
+ return true;
1896
+ };
1897
+ module.exports = outside;
1898
+ }
1899
+ });
1900
+
1901
+ // node_modules/semver/ranges/gtr.js
1902
+ var require_gtr = __commonJS({
1903
+ "node_modules/semver/ranges/gtr.js"(exports, module) {
1904
+ "use strict";
1905
+ var outside = require_outside();
1906
+ var gtr = (version, range, options) => outside(version, range, ">", options);
1907
+ module.exports = gtr;
1908
+ }
1909
+ });
1910
+
1911
+ // node_modules/semver/ranges/ltr.js
1912
+ var require_ltr = __commonJS({
1913
+ "node_modules/semver/ranges/ltr.js"(exports, module) {
1914
+ "use strict";
1915
+ var outside = require_outside();
1916
+ var ltr = (version, range, options) => outside(version, range, "<", options);
1917
+ module.exports = ltr;
1918
+ }
1919
+ });
1920
+
1921
+ // node_modules/semver/ranges/intersects.js
1922
+ var require_intersects = __commonJS({
1923
+ "node_modules/semver/ranges/intersects.js"(exports, module) {
1924
+ "use strict";
1925
+ var Range = require_range();
1926
+ var intersects = (r1, r2, options) => {
1927
+ r1 = new Range(r1, options);
1928
+ r2 = new Range(r2, options);
1929
+ return r1.intersects(r2, options);
1930
+ };
1931
+ module.exports = intersects;
1932
+ }
1933
+ });
1934
+
1935
+ // node_modules/semver/ranges/simplify.js
1936
+ var require_simplify = __commonJS({
1937
+ "node_modules/semver/ranges/simplify.js"(exports, module) {
1938
+ "use strict";
1939
+ var satisfies = require_satisfies();
1940
+ var compare = require_compare();
1941
+ module.exports = (versions, range, options) => {
1942
+ const set = [];
1943
+ let first = null;
1944
+ let prev = null;
1945
+ const v = versions.sort((a, b) => compare(a, b, options));
1946
+ for (const version of v) {
1947
+ const included = satisfies(version, range, options);
1948
+ if (included) {
1949
+ prev = version;
1950
+ if (!first) {
1951
+ first = version;
1952
+ }
1953
+ } else {
1954
+ if (prev) {
1955
+ set.push([first, prev]);
1956
+ }
1957
+ prev = null;
1958
+ first = null;
1959
+ }
1960
+ }
1961
+ if (first) {
1962
+ set.push([first, null]);
1963
+ }
1964
+ const ranges = [];
1965
+ for (const [min, max] of set) {
1966
+ if (min === max) {
1967
+ ranges.push(min);
1968
+ } else if (!max && min === v[0]) {
1969
+ ranges.push("*");
1970
+ } else if (!max) {
1971
+ ranges.push(`>=${min}`);
1972
+ } else if (min === v[0]) {
1973
+ ranges.push(`<=${max}`);
1974
+ } else {
1975
+ ranges.push(`${min} - ${max}`);
1976
+ }
1977
+ }
1978
+ const simplified = ranges.join(" || ");
1979
+ const original = typeof range.raw === "string" ? range.raw : String(range);
1980
+ return simplified.length < original.length ? simplified : range;
1981
+ };
1982
+ }
1983
+ });
1984
+
1985
+ // node_modules/semver/ranges/subset.js
1986
+ var require_subset = __commonJS({
1987
+ "node_modules/semver/ranges/subset.js"(exports, module) {
1988
+ "use strict";
1989
+ var Range = require_range();
1990
+ var Comparator = require_comparator();
1991
+ var { ANY } = Comparator;
1992
+ var satisfies = require_satisfies();
1993
+ var compare = require_compare();
1994
+ var subset = (sub, dom, options = {}) => {
1995
+ if (sub === dom) {
1996
+ return true;
1997
+ }
1998
+ sub = new Range(sub, options);
1999
+ dom = new Range(dom, options);
2000
+ let sawNonNull = false;
2001
+ OUTER: for (const simpleSub of sub.set) {
2002
+ for (const simpleDom of dom.set) {
2003
+ const isSub = simpleSubset(simpleSub, simpleDom, options);
2004
+ sawNonNull = sawNonNull || isSub !== null;
2005
+ if (isSub) {
2006
+ continue OUTER;
2007
+ }
2008
+ }
2009
+ if (sawNonNull) {
2010
+ return false;
2011
+ }
2012
+ }
2013
+ return true;
2014
+ };
2015
+ var minimumVersionWithPreRelease = [new Comparator(">=0.0.0-0")];
2016
+ var minimumVersion = [new Comparator(">=0.0.0")];
2017
+ var simpleSubset = (sub, dom, options) => {
2018
+ if (sub === dom) {
2019
+ return true;
2020
+ }
2021
+ if (sub.length === 1 && sub[0].semver === ANY) {
2022
+ if (dom.length === 1 && dom[0].semver === ANY) {
2023
+ return true;
2024
+ } else if (options.includePrerelease) {
2025
+ sub = minimumVersionWithPreRelease;
2026
+ } else {
2027
+ sub = minimumVersion;
2028
+ }
2029
+ }
2030
+ if (dom.length === 1 && dom[0].semver === ANY) {
2031
+ if (options.includePrerelease) {
2032
+ return true;
2033
+ } else {
2034
+ dom = minimumVersion;
2035
+ }
2036
+ }
2037
+ const eqSet = /* @__PURE__ */ new Set();
2038
+ let gt, lt;
2039
+ for (const c of sub) {
2040
+ if (c.operator === ">" || c.operator === ">=") {
2041
+ gt = higherGT(gt, c, options);
2042
+ } else if (c.operator === "<" || c.operator === "<=") {
2043
+ lt = lowerLT(lt, c, options);
2044
+ } else {
2045
+ eqSet.add(c.semver);
2046
+ }
2047
+ }
2048
+ if (eqSet.size > 1) {
2049
+ return null;
2050
+ }
2051
+ let gtltComp;
2052
+ if (gt && lt) {
2053
+ gtltComp = compare(gt.semver, lt.semver, options);
2054
+ if (gtltComp > 0) {
2055
+ return null;
2056
+ } else if (gtltComp === 0 && (gt.operator !== ">=" || lt.operator !== "<=")) {
2057
+ return null;
2058
+ }
2059
+ }
2060
+ for (const eq of eqSet) {
2061
+ if (gt && !satisfies(eq, String(gt), options)) {
2062
+ return null;
2063
+ }
2064
+ if (lt && !satisfies(eq, String(lt), options)) {
2065
+ return null;
2066
+ }
2067
+ for (const c of dom) {
2068
+ if (!satisfies(eq, String(c), options)) {
2069
+ return false;
2070
+ }
2071
+ }
2072
+ return true;
2073
+ }
2074
+ let higher, lower;
2075
+ let hasDomLT, hasDomGT;
2076
+ let needDomLTPre = lt && !options.includePrerelease && lt.semver.prerelease.length ? lt.semver : false;
2077
+ let needDomGTPre = gt && !options.includePrerelease && gt.semver.prerelease.length ? gt.semver : false;
2078
+ if (needDomLTPre && needDomLTPre.prerelease.length === 1 && lt.operator === "<" && needDomLTPre.prerelease[0] === 0) {
2079
+ needDomLTPre = false;
2080
+ }
2081
+ for (const c of dom) {
2082
+ hasDomGT = hasDomGT || c.operator === ">" || c.operator === ">=";
2083
+ hasDomLT = hasDomLT || c.operator === "<" || c.operator === "<=";
2084
+ if (gt) {
2085
+ if (needDomGTPre) {
2086
+ if (c.semver.prerelease && c.semver.prerelease.length && c.semver.major === needDomGTPre.major && c.semver.minor === needDomGTPre.minor && c.semver.patch === needDomGTPre.patch) {
2087
+ needDomGTPre = false;
2088
+ }
2089
+ }
2090
+ if (c.operator === ">" || c.operator === ">=") {
2091
+ higher = higherGT(gt, c, options);
2092
+ if (higher === c && higher !== gt) {
2093
+ return false;
2094
+ }
2095
+ } else if (gt.operator === ">=" && !c.test(gt.semver)) {
2096
+ return false;
2097
+ }
2098
+ }
2099
+ if (lt) {
2100
+ if (needDomLTPre) {
2101
+ if (c.semver.prerelease && c.semver.prerelease.length && c.semver.major === needDomLTPre.major && c.semver.minor === needDomLTPre.minor && c.semver.patch === needDomLTPre.patch) {
2102
+ needDomLTPre = false;
2103
+ }
2104
+ }
2105
+ if (c.operator === "<" || c.operator === "<=") {
2106
+ lower = lowerLT(lt, c, options);
2107
+ if (lower === c && lower !== lt) {
2108
+ return false;
2109
+ }
2110
+ } else if (lt.operator === "<=" && !c.test(lt.semver)) {
2111
+ return false;
2112
+ }
2113
+ }
2114
+ if (!c.operator && (lt || gt) && gtltComp !== 0) {
2115
+ return false;
2116
+ }
2117
+ }
2118
+ if (gt && hasDomLT && !lt && gtltComp !== 0) {
2119
+ return false;
2120
+ }
2121
+ if (lt && hasDomGT && !gt && gtltComp !== 0) {
2122
+ return false;
2123
+ }
2124
+ if (needDomGTPre || needDomLTPre) {
2125
+ return false;
2126
+ }
2127
+ return true;
2128
+ };
2129
+ var higherGT = (a, b, options) => {
2130
+ if (!a) {
2131
+ return b;
2132
+ }
2133
+ const comp = compare(a.semver, b.semver, options);
2134
+ return comp > 0 ? a : comp < 0 ? b : b.operator === ">" && a.operator === ">=" ? b : a;
2135
+ };
2136
+ var lowerLT = (a, b, options) => {
2137
+ if (!a) {
2138
+ return b;
2139
+ }
2140
+ const comp = compare(a.semver, b.semver, options);
2141
+ return comp < 0 ? a : comp > 0 ? b : b.operator === "<" && a.operator === "<=" ? b : a;
2142
+ };
2143
+ module.exports = subset;
2144
+ }
2145
+ });
2146
+
2147
+ // node_modules/semver/index.js
2148
+ var require_semver2 = __commonJS({
2149
+ "node_modules/semver/index.js"(exports, module) {
2150
+ "use strict";
2151
+ var internalRe = require_re();
2152
+ var constants2 = require_constants();
2153
+ var SemVer = require_semver();
2154
+ var identifiers = require_identifiers();
2155
+ var parse3 = require_parse();
2156
+ var valid = require_valid();
2157
+ var clean = require_clean();
2158
+ var inc = require_inc();
2159
+ var diff = require_diff();
2160
+ var major = require_major();
2161
+ var minor = require_minor();
2162
+ var patch = require_patch();
2163
+ var prerelease = require_prerelease();
2164
+ var compare = require_compare();
2165
+ var rcompare = require_rcompare();
2166
+ var compareLoose = require_compare_loose();
2167
+ var compareBuild = require_compare_build();
2168
+ var sort = require_sort();
2169
+ var rsort = require_rsort();
2170
+ var gt = require_gt();
2171
+ var lt = require_lt();
2172
+ var eq = require_eq();
2173
+ var neq = require_neq();
2174
+ var gte = require_gte();
2175
+ var lte = require_lte();
2176
+ var cmp = require_cmp();
2177
+ var coerce = require_coerce();
2178
+ var truncate = require_truncate();
2179
+ var Comparator = require_comparator();
2180
+ var Range = require_range();
2181
+ var satisfies = require_satisfies();
2182
+ var toComparators = require_to_comparators();
2183
+ var maxSatisfying = require_max_satisfying();
2184
+ var minSatisfying = require_min_satisfying();
2185
+ var minVersion = require_min_version();
2186
+ var validRange = require_valid2();
2187
+ var outside = require_outside();
2188
+ var gtr = require_gtr();
2189
+ var ltr = require_ltr();
2190
+ var intersects = require_intersects();
2191
+ var simplifyRange = require_simplify();
2192
+ var subset = require_subset();
2193
+ module.exports = {
2194
+ parse: parse3,
2195
+ valid,
2196
+ clean,
2197
+ inc,
2198
+ diff,
2199
+ major,
2200
+ minor,
2201
+ patch,
2202
+ prerelease,
2203
+ compare,
2204
+ rcompare,
2205
+ compareLoose,
2206
+ compareBuild,
2207
+ sort,
2208
+ rsort,
2209
+ gt,
2210
+ lt,
2211
+ eq,
2212
+ neq,
2213
+ gte,
2214
+ lte,
2215
+ cmp,
2216
+ coerce,
2217
+ truncate,
2218
+ Comparator,
2219
+ Range,
2220
+ satisfies,
2221
+ toComparators,
2222
+ maxSatisfying,
2223
+ minSatisfying,
2224
+ minVersion,
2225
+ validRange,
2226
+ outside,
2227
+ gtr,
2228
+ ltr,
2229
+ intersects,
2230
+ simplifyRange,
2231
+ subset,
2232
+ SemVer,
2233
+ re: internalRe.re,
2234
+ src: internalRe.src,
2235
+ tokens: internalRe.t,
2236
+ SEMVER_SPEC_VERSION: constants2.SEMVER_SPEC_VERSION,
2237
+ RELEASE_TYPES: constants2.RELEASE_TYPES,
2238
+ compareIdentifiers: identifiers.compareIdentifiers,
2239
+ rcompareIdentifiers: identifiers.rcompareIdentifiers
2240
+ };
2241
+ }
2242
+ });
2243
+
2244
+ // default-plugins/mcp/c8ctl-plugin.ts
2245
+ import { existsSync as existsSync4, realpathSync as realpathSync3 } from "node:fs";
2246
+ import { resolve as resolve3 } from "node:path";
2247
+ import { fileURLToPath as fileURLToPath3 } from "node:url";
2248
+
2249
+ // src/core/config.ts
2250
+ import { createHash, randomUUID } from "node:crypto";
2251
+ import {
2252
+ closeSync,
2253
+ constants,
2254
+ existsSync,
2255
+ fchmodSync,
2256
+ fstatSync,
2257
+ linkSync,
2258
+ lstatSync,
2259
+ mkdirSync,
2260
+ openSync,
2261
+ readFileSync as readFileSync2,
2262
+ renameSync,
2263
+ rmSync,
2264
+ statSync,
2265
+ writeFileSync
2266
+ } from "node:fs";
2267
+ import { homedir, platform } from "node:os";
2268
+ import { join as join2 } from "node:path";
2269
+
2270
+ // src/core/env-address.ts
2271
+ function resolveEnvBaseUrl(vars = process.env) {
2272
+ return vars.CAMUNDA_BASE_URL?.trim() || vars.CAMUNDA_REST_ADDRESS?.trim() || void 0;
2273
+ }
2274
+
2275
+ // src/core/runtime.ts
2276
+ import { readFileSync } from "node:fs";
2277
+ import { dirname, join } from "node:path";
2278
+ import { fileURLToPath } from "node:url";
2279
+ var __filename = fileURLToPath(import.meta.url);
2280
+ var __dirname = dirname(__filename);
2281
+ var UNVERSIONED_DEV_BUILD = "0.0.0-semantically-released";
2282
+ function getVersion() {
2283
+ try {
2284
+ const packageJsonPath = join(__dirname, "..", "..", "package.json");
2285
+ const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf-8"));
2286
+ return packageJson.version || UNVERSIONED_DEV_BUILD;
2287
+ } catch {
2288
+ return UNVERSIONED_DEV_BUILD;
2289
+ }
2290
+ }
2291
+ var C8ctl = class {
2292
+ _activeProfile;
2293
+ _activeTenant;
2294
+ _outputMode = "text";
2295
+ _fields;
2296
+ _dryRun;
2297
+ _verbose;
2298
+ _quiet;
2299
+ _resolvedBaseUrl;
2300
+ _deps;
2301
+ env = {
2302
+ version: getVersion(),
2303
+ nodeVersion: process.version,
2304
+ platform: process.platform,
2305
+ arch: process.arch,
2306
+ cwd: process.cwd(),
2307
+ rootDir: join(__dirname, "..", "..")
2308
+ };
2309
+ /**
2310
+ * Inject dependencies that cannot be imported at module level
2311
+ * due to circular imports. Must be called once during startup,
2312
+ * before any plugin or command accesses createClient/resolveTenantId/getLogger.
2313
+ */
2314
+ init(deps) {
2315
+ if (this._deps) {
2316
+ throw new Error("c8ctl.init() must only be called once");
2317
+ }
2318
+ this._deps = deps;
2319
+ }
2320
+ createClient(profileFlag, additionalSdkConfig) {
2321
+ if (!this._deps) {
2322
+ throw new Error("c8ctl.init() must be called before createClient()");
2323
+ }
2324
+ return this._deps.createClient(profileFlag, additionalSdkConfig);
2325
+ }
2326
+ resolveTenantId(profileFlag) {
2327
+ if (!this._deps) {
2328
+ throw new Error("c8ctl.init() must be called before resolveTenantId()");
2329
+ }
2330
+ return this._deps.resolveTenantId(profileFlag);
2331
+ }
2332
+ getLogger(mode) {
2333
+ if (!this._deps) {
2334
+ throw new Error("c8ctl.init() must be called before getLogger()");
2335
+ }
2336
+ return this._deps.getLogger(mode);
2337
+ }
2338
+ getUserDataDir() {
2339
+ if (!this._deps) {
2340
+ throw new Error("c8ctl.init() must be called before getUserDataDir()");
2341
+ }
2342
+ return this._deps.getUserDataDir();
2343
+ }
2344
+ getModelerDataDir() {
2345
+ if (!this._deps) {
2346
+ throw new Error("c8ctl.init() must be called before getModelerDataDir()");
2347
+ }
2348
+ return this._deps.getModelerDataDir();
2349
+ }
2350
+ npm(options) {
2351
+ if (!this._deps) {
2352
+ throw new Error("c8ctl.init() must be called before npm()");
2353
+ }
2354
+ return options.stdout === true ? this._deps.npm(options) : this._deps.npm(options);
2355
+ }
2356
+ // Expose env properties directly for plugin compatibility
2357
+ get version() {
2358
+ return this.env.version;
2359
+ }
2360
+ get nodeVersion() {
2361
+ return this.env.nodeVersion;
2362
+ }
2363
+ get platform() {
2364
+ return this.env.platform;
2365
+ }
2366
+ get arch() {
2367
+ return this.env.arch;
2368
+ }
2369
+ get cwd() {
2370
+ return this.env.cwd;
2371
+ }
2372
+ get activeProfile() {
2373
+ return this._activeProfile;
2374
+ }
2375
+ set activeProfile(value) {
2376
+ this._activeProfile = value;
2377
+ }
2378
+ get activeTenant() {
2379
+ return this._activeTenant;
2380
+ }
2381
+ set activeTenant(value) {
2382
+ this._activeTenant = value;
2383
+ }
2384
+ get outputMode() {
2385
+ return this._outputMode;
2386
+ }
2387
+ set outputMode(value) {
2388
+ this._outputMode = value;
2389
+ }
2390
+ get fields() {
2391
+ return this._fields;
2392
+ }
2393
+ set fields(value) {
2394
+ this._fields = value;
2395
+ }
2396
+ get dryRun() {
2397
+ return this._dryRun;
2398
+ }
2399
+ set dryRun(value) {
2400
+ this._dryRun = value;
2401
+ }
2402
+ get verbose() {
2403
+ return this._verbose;
2404
+ }
2405
+ set verbose(value) {
2406
+ this._verbose = value;
2407
+ }
2408
+ get quiet() {
2409
+ return this._quiet;
2410
+ }
2411
+ set quiet(value) {
2412
+ this._quiet = value;
2413
+ }
2414
+ get resolvedBaseUrl() {
2415
+ return this._resolvedBaseUrl;
2416
+ }
2417
+ set resolvedBaseUrl(value) {
2418
+ this._resolvedBaseUrl = value;
2419
+ }
2420
+ };
2421
+ var c8ctl = new C8ctl();
2422
+
2423
+ // src/core/logger.ts
2424
+ function isRecord(value) {
2425
+ return value != null && typeof value === "object" && !Array.isArray(value);
2426
+ }
2427
+
2428
+ // src/core/config.ts
2429
+ var TARGET_TYPES = {
2430
+ CAMUNDA_CLOUD: "camundaCloud",
2431
+ SELF_HOSTED: "selfHosted"
2432
+ };
2433
+ var AUTH_TYPES = {
2434
+ NONE: "none",
2435
+ BASIC: "basic",
2436
+ OAUTH: "oauth"
2437
+ };
2438
+ var VALIDATION_PATTERNS = {
2439
+ URL: /^https?:\/\//,
2440
+ CAMUNDA_CLOUD_REST_URL: /^https:\/\/[a-z]+-\d+\.zeebe\.camunda\.io(:443|)\/[a-z\d-]+\/?$/
2441
+ };
2442
+ var CAMUNDA_CLOUD_URL_PATTERN = VALIDATION_PATTERNS.CAMUNDA_CLOUD_REST_URL;
2443
+ function getUserDataDir() {
2444
+ if (process.env.C8CTL_DATA_DIR) {
2445
+ return process.env.C8CTL_DATA_DIR;
2446
+ }
2447
+ const plat = platform();
2448
+ const home = homedir();
2449
+ switch (plat) {
2450
+ case "win32":
2451
+ return join2(
2452
+ process.env.APPDATA || join2(home, "AppData", "Roaming"),
2453
+ "c8ctl"
2454
+ );
2455
+ case "darwin":
2456
+ return join2(home, "Library", "Application Support", "c8ctl");
2457
+ default:
2458
+ return join2(
2459
+ process.env.XDG_CONFIG_HOME || join2(home, ".config"),
2460
+ "c8ctl"
2461
+ );
2462
+ }
2463
+ }
2464
+ function getModelerDataDir() {
2465
+ if (process.env.C8CTL_MODELER_DIR) {
2466
+ return process.env.C8CTL_MODELER_DIR;
2467
+ }
2468
+ const plat = platform();
2469
+ const home = homedir();
2470
+ switch (plat) {
2471
+ case "win32":
2472
+ return join2(
2473
+ process.env.APPDATA || join2(home, "AppData", "Roaming"),
2474
+ "camunda-modeler"
2475
+ );
2476
+ case "darwin":
2477
+ return join2(home, "Library", "Application Support", "camunda-modeler");
2478
+ default:
2479
+ return join2(
2480
+ process.env.XDG_CONFIG_HOME || join2(home, ".config"),
2481
+ "camunda-modeler"
2482
+ );
2483
+ }
2484
+ }
2485
+ function ensureUserDataDir() {
2486
+ const dir = getUserDataDir();
2487
+ if (!existsSync(dir)) {
2488
+ mkdirSync(dir, { recursive: true });
2489
+ }
2490
+ return dir;
2491
+ }
2492
+ function getProfilesPath() {
2493
+ return join2(ensureUserDataDir(), "profiles.json");
2494
+ }
2495
+ function getModelerSettingsPath() {
2496
+ return join2(getModelerDataDir(), "settings.json");
2497
+ }
2498
+ function fileMode(path) {
2499
+ try {
2500
+ return statSync(path).mode & 511;
2501
+ } catch {
2502
+ return void 0;
2503
+ }
2504
+ }
2505
+ var isWindows = platform() === "win32";
2506
+ function pinFdMode(fd, mode) {
2507
+ if (!isWindows) fchmodSync(fd, mode);
2508
+ }
2509
+ var OPTIONAL_STRING_PROFILE_FIELDS = [
2510
+ "clientId",
2511
+ "clientSecret",
2512
+ "audience",
2513
+ "oAuthUrl",
2514
+ "scope",
2515
+ "username",
2516
+ "password",
2517
+ "defaultTenantId"
2518
+ ];
2519
+ function isStringRecord(value) {
2520
+ return isRecord(value) && Object.values(value).every((v) => typeof v === "string");
2521
+ }
2522
+ function isValidProfile(value) {
2523
+ if (!isRecord(value) || typeof value.name !== "string" || typeof value.baseUrl !== "string") {
2524
+ return false;
2525
+ }
2526
+ for (const field of OPTIONAL_STRING_PROFILE_FIELDS) {
2527
+ if (value[field] !== void 0 && typeof value[field] !== "string") {
2528
+ return false;
2529
+ }
2530
+ }
2531
+ if (value.exactBaseUrl !== void 0 && typeof value.exactBaseUrl !== "boolean") {
2532
+ return false;
2533
+ }
2534
+ if (value.headers !== void 0 && !isStringRecord(value.headers)) {
2535
+ return false;
2536
+ }
2537
+ if (value.authStrategy !== void 0 && !CAMUNDA_AUTH_STRATEGIES.some((s) => s === value.authStrategy)) {
2538
+ return false;
2539
+ }
2540
+ return true;
2541
+ }
2542
+ function extractValidProfiles(parsed) {
2543
+ if (!isRecord(parsed)) return null;
2544
+ const rawProfiles = parsed.profiles;
2545
+ if (!Array.isArray(rawProfiles)) return null;
2546
+ if (!rawProfiles.every(isValidProfile)) return null;
2547
+ return rawProfiles;
2548
+ }
2549
+ function backupCorruptProfiles(profilesPath, data) {
2550
+ const mode = fileMode(profilesPath) ?? 384;
2551
+ const hash = createHash("sha256").update(data).digest("hex");
2552
+ const backup = `${profilesPath}.corrupt-${hash}`;
2553
+ const tmp = `${profilesPath}.corrupt-tmp-${randomUUID()}`;
2554
+ let stagedFd;
2555
+ try {
2556
+ stagedFd = openSync(
2557
+ tmp,
2558
+ constants.O_WRONLY | constants.O_CREAT | constants.O_EXCL | constants.O_NOFOLLOW,
2559
+ mode
2560
+ );
2561
+ writeFileSync(stagedFd, data);
2562
+ pinFdMode(stagedFd, mode);
2563
+ } catch {
2564
+ if (stagedFd !== void 0) closeQuietly(stagedFd);
2565
+ removeQuietly(tmp);
2566
+ return { backup, backedUp: false };
2567
+ }
2568
+ closeQuietly(stagedFd);
2569
+ try {
2570
+ for (const name of [backup, `${backup}.dup`]) {
2571
+ if (publishBackup(tmp, name, data, mode)) {
2572
+ return { backup: name, backedUp: true };
2573
+ }
2574
+ }
2575
+ return { backup, backedUp: false };
2576
+ } finally {
2577
+ removeQuietly(tmp);
2578
+ }
2579
+ }
2580
+ function publishBackup(tmp, name, data, mode) {
2581
+ try {
2582
+ linkSync(tmp, name);
2583
+ return true;
2584
+ } catch (err) {
2585
+ if (isRecord(err) && err.code === "EEXIST") {
2586
+ return reuseCanonicalBackup(name, data, mode);
2587
+ }
2588
+ return false;
2589
+ }
2590
+ }
2591
+ function removeQuietly(path) {
2592
+ try {
2593
+ rmSync(path, { force: true });
2594
+ } catch {
2595
+ }
2596
+ }
2597
+ function pathEntryExists(path) {
2598
+ try {
2599
+ lstatSync(path);
2600
+ return true;
2601
+ } catch (err) {
2602
+ if (isRecord(err) && err.code === "ENOENT") return false;
2603
+ return true;
2604
+ }
2605
+ }
2606
+ function reuseCanonicalBackup(backup, data, mode) {
2607
+ let fd;
2608
+ try {
2609
+ fd = openSync(
2610
+ backup,
2611
+ constants.O_RDONLY | constants.O_NOFOLLOW | constants.O_NONBLOCK
2612
+ );
2613
+ const st = fstatSync(fd);
2614
+ if (!st.isFile()) return false;
2615
+ if (st.nlink !== 1) return false;
2616
+ if (!readFileSync2(fd).equals(data)) return false;
2617
+ if ((st.mode & 511) !== mode) {
2618
+ try {
2619
+ pinFdMode(fd, mode);
2620
+ } catch {
2621
+ return false;
2622
+ }
2623
+ }
2624
+ return true;
2625
+ } catch {
2626
+ return false;
2627
+ } finally {
2628
+ if (fd !== void 0) closeQuietly(fd);
2629
+ }
2630
+ }
2631
+ function closeQuietly(fd) {
2632
+ try {
2633
+ closeSync(fd);
2634
+ } catch {
2635
+ }
2636
+ }
2637
+ function throwCorruptProfiles(profilesPath, data, detail) {
2638
+ const { backup, backedUp } = backupCorruptProfiles(profilesPath, data);
2639
+ const backupNote = backedUp ? `Its contents were backed up to ${backup}. ` : `A backup could not be written, but the original file is still on disk untouched. `;
2640
+ throw new Error(
2641
+ `profiles.json at ${profilesPath} is corrupt (${detail}). ${backupNote}Refusing to overwrite it to avoid destroying your saved profiles \u2014 fix or remove the file, then re-run.`
2642
+ );
2643
+ }
2644
+ function loadProfiles() {
2645
+ const profilesPath = getProfilesPath();
2646
+ let data;
2647
+ let fd;
2648
+ try {
2649
+ fd = openSync(profilesPath, constants.O_RDONLY | constants.O_NONBLOCK);
2650
+ const st = fstatSync(fd);
2651
+ if (!st.isFile()) {
2652
+ throw new Error(
2653
+ `profiles file at ${profilesPath} is not a regular file (e.g. a FIFO, device, or directory). Refusing to treat it as empty (that would overwrite your saved profiles) \u2014 fix or remove it, then re-run.`
2654
+ );
2655
+ }
2656
+ data = readFileSync2(fd);
2657
+ } catch (err) {
2658
+ if (isRecord(err) && err.code === "ENOENT") {
2659
+ if (pathEntryExists(profilesPath)) {
2660
+ throw new Error(
2661
+ `profiles file at ${profilesPath} exists but its contents could not be read (e.g. a dangling symlink). Refusing to treat it as empty (that would overwrite your saved profiles) \u2014 fix or remove it, then re-run.`
2662
+ );
2663
+ }
2664
+ return [];
2665
+ }
2666
+ if (!(isRecord(err) && typeof err.code === "string")) {
2667
+ throw err;
2668
+ }
2669
+ throw new Error(
2670
+ `Failed to read profiles at ${profilesPath}: ${err instanceof Error ? err.message : String(err)}. Refusing to treat an unreadable profiles file as empty (that would overwrite your saved profiles).`
2671
+ );
2672
+ } finally {
2673
+ if (fd !== void 0) closeQuietly(fd);
2674
+ }
2675
+ try {
2676
+ let text;
2677
+ try {
2678
+ text = new TextDecoder("utf-8", { fatal: true }).decode(data);
2679
+ } catch {
2680
+ throwCorruptProfiles(
2681
+ profilesPath,
2682
+ data,
2683
+ "contains invalid UTF-8 byte sequences"
2684
+ );
2685
+ }
2686
+ const parsed = JSON.parse(text);
2687
+ const profiles = extractValidProfiles(parsed);
2688
+ if (profiles === null) {
2689
+ throwCorruptProfiles(
2690
+ profilesPath,
2691
+ data,
2692
+ 'does not contain a valid "profiles" array'
2693
+ );
2694
+ }
2695
+ return profiles;
2696
+ } catch (err) {
2697
+ if (err instanceof SyntaxError) {
2698
+ throwCorruptProfiles(
2699
+ profilesPath,
2700
+ data,
2701
+ `could not be parsed: ${err.message}`
2702
+ );
2703
+ }
2704
+ throw err;
2705
+ }
2706
+ }
2707
+ function getProfile(name) {
2708
+ const profiles = loadProfiles();
2709
+ return profiles.find((p) => p.name === name);
2710
+ }
2711
+ var MODELER_PREFIX = "modeler:";
2712
+ function loadModelerConnections() {
2713
+ const settingsPath = getModelerSettingsPath();
2714
+ if (!existsSync(settingsPath)) {
2715
+ return [];
2716
+ }
2717
+ try {
2718
+ const data = readFileSync2(settingsPath, "utf-8");
2719
+ const settings = JSON.parse(data);
2720
+ const connections = settings["connectionManagerPlugin.c8connections"];
2721
+ if (!connections || !Array.isArray(connections)) {
2722
+ return [];
2723
+ }
2724
+ return connections.filter((c) => c?.id);
2725
+ } catch {
2726
+ return [];
2727
+ }
2728
+ }
2729
+ function getProfileOrModeler(name) {
2730
+ const c8ctlProfile = getProfile(name);
2731
+ if (c8ctlProfile) {
2732
+ return c8ctlProfile;
2733
+ }
2734
+ const modelerName = name.startsWith(MODELER_PREFIX) ? name.slice(MODELER_PREFIX.length) : name;
2735
+ const modelerConnections = loadModelerConnections();
2736
+ const modelerConnection = modelerConnections.find(
2737
+ (c) => c.name === modelerName || c.id === modelerName
2738
+ );
2739
+ if (modelerConnection) {
2740
+ const profile = connectionToProfile(modelerConnection);
2741
+ return {
2742
+ ...profile,
2743
+ name: `${MODELER_PREFIX}${profile.name}`
2744
+ };
2745
+ }
2746
+ return void 0;
2747
+ }
2748
+ function connectionToClusterConfig(conn) {
2749
+ if (conn.targetType === TARGET_TYPES.CAMUNDA_CLOUD) {
2750
+ const audience = conn.audience?.trim();
2751
+ const oAuthUrl = conn.oauthURL?.trim();
2752
+ const scope = conn.scope?.trim();
2753
+ return {
2754
+ baseUrl: conn.camundaCloudClusterUrl || "",
2755
+ clientId: conn.camundaCloudClientId,
2756
+ clientSecret: conn.camundaCloudClientSecret,
2757
+ audience: audience || void 0,
2758
+ oAuthUrl: oAuthUrl || "https://login.cloud.camunda.io/oauth/token",
2759
+ scope: scope || void 0
2760
+ };
2761
+ }
2762
+ const config = {
2763
+ baseUrl: conn.contactPoint || "http://localhost:8080/v2"
2764
+ };
2765
+ if (conn.authType === AUTH_TYPES.BASIC) {
2766
+ config.username = conn.basicAuthUsername;
2767
+ config.password = conn.basicAuthPassword;
2768
+ } else if (conn.authType === AUTH_TYPES.OAUTH) {
2769
+ config.clientId = conn.clientId;
2770
+ config.clientSecret = conn.clientSecret;
2771
+ config.oAuthUrl = conn.oauthURL;
2772
+ config.audience = conn.audience;
2773
+ config.scope = conn.scope;
2774
+ }
2775
+ return config;
2776
+ }
2777
+ function connectionToProfile(conn) {
2778
+ const config = connectionToClusterConfig(conn);
2779
+ return {
2780
+ name: conn.name || conn.id,
2781
+ baseUrl: config.baseUrl,
2782
+ clientId: config.clientId,
2783
+ clientSecret: config.clientSecret,
2784
+ audience: config.audience,
2785
+ oAuthUrl: config.oAuthUrl,
2786
+ scope: config.scope,
2787
+ username: config.username,
2788
+ password: config.password,
2789
+ defaultTenantId: conn.tenantId
2790
+ };
2791
+ }
2792
+ var DEFAULT_PROFILE = "local";
2793
+ var CAMUNDA_AUTH_STRATEGIES = ["NONE", "BASIC", "OAUTH"];
2794
+
2795
+ // src/core/errors.ts
2796
+ var SilentError = class extends Error {
2797
+ constructor(message) {
2798
+ super(message);
2799
+ this.name = "SilentError";
2800
+ }
2801
+ };
2802
+ function normalizeToError(error, fallbackMessage = "Operation failed") {
2803
+ if (error instanceof Error) {
2804
+ return error;
2805
+ }
2806
+ const raw = isRecord(error) ? error : {};
2807
+ const title = typeof raw.title === "string" ? raw.title : void 0;
2808
+ const detail = typeof raw.detail === "string" ? raw.detail : void 0;
2809
+ const status = typeof raw.status === "number" ? raw.status : void 0;
2810
+ const head = [title ?? fallbackMessage, detail].filter((p) => Boolean(p)).join(": ");
2811
+ const message = status !== void 0 ? `${head} (status ${status})` : head;
2812
+ return new Error(message, { cause: error });
2813
+ }
2814
+ function renderCommandFailure(logger, message, error, { verbose = false } = {}) {
2815
+ const normalizedError = normalizeToError(error, message);
2816
+ if (verbose) {
2817
+ throw normalizedError;
2818
+ }
2819
+ if (error instanceof SilentError) {
2820
+ return;
2821
+ }
2822
+ if (normalizedError.message === message) {
2823
+ logger.error(message);
2824
+ } else {
2825
+ logger.error(message, normalizedError);
2826
+ }
2827
+ logger.info("For more details on the error, run with the --verbose flag", {
2828
+ essential: true
2829
+ });
2830
+ }
2831
+
2832
+ // src/core/node-version.ts
2833
+ var import_semver = __toESM(require_semver2(), 1);
2834
+ import { readFileSync as readFileSync3 } from "node:fs";
2835
+ import { dirname as dirname2, join as join3 } from "node:path";
2836
+ import { fileURLToPath as fileURLToPath2 } from "node:url";
2837
+ function readRequiredNodeRange() {
2838
+ try {
2839
+ const packageJson = join3(
2840
+ dirname2(fileURLToPath2(import.meta.url)),
2841
+ "..",
2842
+ "..",
2843
+ "package.json"
2844
+ );
2845
+ const pkg = JSON.parse(readFileSync3(packageJson, "utf-8"));
2846
+ const node = isRecord(pkg) && isRecord(pkg.engines) && pkg.engines.node;
2847
+ return typeof node === "string" ? node : void 0;
2848
+ } catch {
2849
+ return void 0;
2850
+ }
2851
+ }
2852
+ var REQUIRED_NODE_RANGE = readRequiredNodeRange();
2853
+
2854
+ // src/core/update-check.ts
2855
+ var CHECK_INTERVAL_MS = 60 * 60 * 1e3;
2856
+
2857
+ // src/utils/command-local/mcp-install-helpers.ts
2858
+ import { randomUUID as randomUUID2 } from "node:crypto";
2859
+ import {
2860
+ closeSync as closeSync2,
2861
+ existsSync as existsSync3,
2862
+ fchmodSync as fchmodSync2,
2863
+ fsyncSync,
2864
+ lstatSync as lstatSync3,
2865
+ mkdirSync as mkdirSync2,
2866
+ openSync as openSync2,
2867
+ readFileSync as readFileSync4,
2868
+ realpathSync as realpathSync2,
2869
+ renameSync as renameSync2,
2870
+ rmSync as rmSync3,
2871
+ statSync as statSync3,
2872
+ writeFileSync as writeFileSync2
2873
+ } from "node:fs";
2874
+ import { homedir as homedir2 } from "node:os";
2875
+ import { basename as basename2, dirname as dirname4, join as join4, resolve as resolve2 } from "node:path";
2876
+ import { isDeepStrictEqual } from "node:util";
2877
+
2878
+ // node_modules/jsonc-parser/lib/esm/impl/scanner.js
2879
+ function createScanner(text, ignoreTrivia = false) {
2880
+ const len = text.length;
2881
+ let pos = 0, value = "", tokenOffset = 0, token = 16, lineNumber = 0, lineStartOffset = 0, tokenLineStartOffset = 0, prevTokenLineStartOffset = 0, scanError = 0;
2882
+ function scanHexDigits(count, exact) {
2883
+ let digits = 0;
2884
+ let value2 = 0;
2885
+ while (digits < count || !exact) {
2886
+ let ch = text.charCodeAt(pos);
2887
+ if (ch >= 48 && ch <= 57) {
2888
+ value2 = value2 * 16 + ch - 48;
2889
+ } else if (ch >= 65 && ch <= 70) {
2890
+ value2 = value2 * 16 + ch - 65 + 10;
2891
+ } else if (ch >= 97 && ch <= 102) {
2892
+ value2 = value2 * 16 + ch - 97 + 10;
2893
+ } else {
2894
+ break;
2895
+ }
2896
+ pos++;
2897
+ digits++;
2898
+ }
2899
+ if (digits < count) {
2900
+ value2 = -1;
2901
+ }
2902
+ return value2;
2903
+ }
2904
+ function setPosition(newPosition) {
2905
+ pos = newPosition;
2906
+ value = "";
2907
+ tokenOffset = 0;
2908
+ token = 16;
2909
+ scanError = 0;
2910
+ }
2911
+ function scanNumber() {
2912
+ let start = pos;
2913
+ if (text.charCodeAt(pos) === 48) {
2914
+ pos++;
2915
+ } else {
2916
+ pos++;
2917
+ while (pos < text.length && isDigit(text.charCodeAt(pos))) {
2918
+ pos++;
2919
+ }
2920
+ }
2921
+ if (pos < text.length && text.charCodeAt(pos) === 46) {
2922
+ pos++;
2923
+ if (pos < text.length && isDigit(text.charCodeAt(pos))) {
2924
+ pos++;
2925
+ while (pos < text.length && isDigit(text.charCodeAt(pos))) {
2926
+ pos++;
2927
+ }
2928
+ } else {
2929
+ scanError = 3;
2930
+ return text.substring(start, pos);
2931
+ }
2932
+ }
2933
+ let end = pos;
2934
+ if (pos < text.length && (text.charCodeAt(pos) === 69 || text.charCodeAt(pos) === 101)) {
2935
+ pos++;
2936
+ if (pos < text.length && text.charCodeAt(pos) === 43 || text.charCodeAt(pos) === 45) {
2937
+ pos++;
2938
+ }
2939
+ if (pos < text.length && isDigit(text.charCodeAt(pos))) {
2940
+ pos++;
2941
+ while (pos < text.length && isDigit(text.charCodeAt(pos))) {
2942
+ pos++;
2943
+ }
2944
+ end = pos;
2945
+ } else {
2946
+ scanError = 3;
2947
+ }
2948
+ }
2949
+ return text.substring(start, end);
2950
+ }
2951
+ function scanString() {
2952
+ let result = "", start = pos;
2953
+ while (true) {
2954
+ if (pos >= len) {
2955
+ result += text.substring(start, pos);
2956
+ scanError = 2;
2957
+ break;
2958
+ }
2959
+ const ch = text.charCodeAt(pos);
2960
+ if (ch === 34) {
2961
+ result += text.substring(start, pos);
2962
+ pos++;
2963
+ break;
2964
+ }
2965
+ if (ch === 92) {
2966
+ result += text.substring(start, pos);
2967
+ pos++;
2968
+ if (pos >= len) {
2969
+ scanError = 2;
2970
+ break;
2971
+ }
2972
+ const ch2 = text.charCodeAt(pos++);
2973
+ switch (ch2) {
2974
+ case 34:
2975
+ result += '"';
2976
+ break;
2977
+ case 92:
2978
+ result += "\\";
2979
+ break;
2980
+ case 47:
2981
+ result += "/";
2982
+ break;
2983
+ case 98:
2984
+ result += "\b";
2985
+ break;
2986
+ case 102:
2987
+ result += "\f";
2988
+ break;
2989
+ case 110:
2990
+ result += "\n";
2991
+ break;
2992
+ case 114:
2993
+ result += "\r";
2994
+ break;
2995
+ case 116:
2996
+ result += " ";
2997
+ break;
2998
+ case 117:
2999
+ const ch3 = scanHexDigits(4, true);
3000
+ if (ch3 >= 0) {
3001
+ result += String.fromCharCode(ch3);
3002
+ } else {
3003
+ scanError = 4;
3004
+ }
3005
+ break;
3006
+ default:
3007
+ scanError = 5;
3008
+ }
3009
+ start = pos;
3010
+ continue;
3011
+ }
3012
+ if (ch >= 0 && ch <= 31) {
3013
+ if (isLineBreak(ch)) {
3014
+ result += text.substring(start, pos);
3015
+ scanError = 2;
3016
+ break;
3017
+ } else {
3018
+ scanError = 6;
3019
+ }
3020
+ }
3021
+ pos++;
3022
+ }
3023
+ return result;
3024
+ }
3025
+ function scanNext() {
3026
+ value = "";
3027
+ scanError = 0;
3028
+ tokenOffset = pos;
3029
+ lineStartOffset = lineNumber;
3030
+ prevTokenLineStartOffset = tokenLineStartOffset;
3031
+ if (pos >= len) {
3032
+ tokenOffset = len;
3033
+ return token = 17;
3034
+ }
3035
+ let code = text.charCodeAt(pos);
3036
+ if (isWhiteSpace(code)) {
3037
+ do {
3038
+ pos++;
3039
+ value += String.fromCharCode(code);
3040
+ code = text.charCodeAt(pos);
3041
+ } while (isWhiteSpace(code));
3042
+ return token = 15;
3043
+ }
3044
+ if (isLineBreak(code)) {
3045
+ pos++;
3046
+ value += String.fromCharCode(code);
3047
+ if (code === 13 && text.charCodeAt(pos) === 10) {
3048
+ pos++;
3049
+ value += "\n";
3050
+ }
3051
+ lineNumber++;
3052
+ tokenLineStartOffset = pos;
3053
+ return token = 14;
3054
+ }
3055
+ switch (code) {
3056
+ // tokens: []{}:,
3057
+ case 123:
3058
+ pos++;
3059
+ return token = 1;
3060
+ case 125:
3061
+ pos++;
3062
+ return token = 2;
3063
+ case 91:
3064
+ pos++;
3065
+ return token = 3;
3066
+ case 93:
3067
+ pos++;
3068
+ return token = 4;
3069
+ case 58:
3070
+ pos++;
3071
+ return token = 6;
3072
+ case 44:
3073
+ pos++;
3074
+ return token = 5;
3075
+ // strings
3076
+ case 34:
3077
+ pos++;
3078
+ value = scanString();
3079
+ return token = 10;
3080
+ // comments
3081
+ case 47:
3082
+ const start = pos - 1;
3083
+ if (text.charCodeAt(pos + 1) === 47) {
3084
+ pos += 2;
3085
+ while (pos < len) {
3086
+ if (isLineBreak(text.charCodeAt(pos))) {
3087
+ break;
3088
+ }
3089
+ pos++;
3090
+ }
3091
+ value = text.substring(start, pos);
3092
+ return token = 12;
3093
+ }
3094
+ if (text.charCodeAt(pos + 1) === 42) {
3095
+ pos += 2;
3096
+ const safeLength = len - 1;
3097
+ let commentClosed = false;
3098
+ while (pos < safeLength) {
3099
+ const ch = text.charCodeAt(pos);
3100
+ if (ch === 42 && text.charCodeAt(pos + 1) === 47) {
3101
+ pos += 2;
3102
+ commentClosed = true;
3103
+ break;
3104
+ }
3105
+ pos++;
3106
+ if (isLineBreak(ch)) {
3107
+ if (ch === 13 && text.charCodeAt(pos) === 10) {
3108
+ pos++;
3109
+ }
3110
+ lineNumber++;
3111
+ tokenLineStartOffset = pos;
3112
+ }
3113
+ }
3114
+ if (!commentClosed) {
3115
+ pos++;
3116
+ scanError = 1;
3117
+ }
3118
+ value = text.substring(start, pos);
3119
+ return token = 13;
3120
+ }
3121
+ value += String.fromCharCode(code);
3122
+ pos++;
3123
+ return token = 16;
3124
+ // numbers
3125
+ case 45:
3126
+ value += String.fromCharCode(code);
3127
+ pos++;
3128
+ if (pos === len || !isDigit(text.charCodeAt(pos))) {
3129
+ return token = 16;
3130
+ }
3131
+ // found a minus, followed by a number so
3132
+ // we fall through to proceed with scanning
3133
+ // numbers
3134
+ case 48:
3135
+ case 49:
3136
+ case 50:
3137
+ case 51:
3138
+ case 52:
3139
+ case 53:
3140
+ case 54:
3141
+ case 55:
3142
+ case 56:
3143
+ case 57:
3144
+ value += scanNumber();
3145
+ return token = 11;
3146
+ // literals and unknown symbols
3147
+ default:
3148
+ while (pos < len && isUnknownContentCharacter(code)) {
3149
+ pos++;
3150
+ code = text.charCodeAt(pos);
3151
+ }
3152
+ if (tokenOffset !== pos) {
3153
+ value = text.substring(tokenOffset, pos);
3154
+ switch (value) {
3155
+ case "true":
3156
+ return token = 8;
3157
+ case "false":
3158
+ return token = 9;
3159
+ case "null":
3160
+ return token = 7;
3161
+ }
3162
+ return token = 16;
3163
+ }
3164
+ value += String.fromCharCode(code);
3165
+ pos++;
3166
+ return token = 16;
3167
+ }
3168
+ }
3169
+ function isUnknownContentCharacter(code) {
3170
+ if (isWhiteSpace(code) || isLineBreak(code)) {
3171
+ return false;
3172
+ }
3173
+ switch (code) {
3174
+ case 125:
3175
+ case 93:
3176
+ case 123:
3177
+ case 91:
3178
+ case 34:
3179
+ case 58:
3180
+ case 44:
3181
+ case 47:
3182
+ return false;
3183
+ }
3184
+ return true;
3185
+ }
3186
+ function scanNextNonTrivia() {
3187
+ let result;
3188
+ do {
3189
+ result = scanNext();
3190
+ } while (result >= 12 && result <= 15);
3191
+ return result;
3192
+ }
3193
+ return {
3194
+ setPosition,
3195
+ getPosition: () => pos,
3196
+ scan: ignoreTrivia ? scanNextNonTrivia : scanNext,
3197
+ getToken: () => token,
3198
+ getTokenValue: () => value,
3199
+ getTokenOffset: () => tokenOffset,
3200
+ getTokenLength: () => pos - tokenOffset,
3201
+ getTokenStartLine: () => lineStartOffset,
3202
+ getTokenStartCharacter: () => tokenOffset - prevTokenLineStartOffset,
3203
+ getTokenError: () => scanError
3204
+ };
3205
+ }
3206
+ function isWhiteSpace(ch) {
3207
+ return ch === 32 || ch === 9;
3208
+ }
3209
+ function isLineBreak(ch) {
3210
+ return ch === 10 || ch === 13;
3211
+ }
3212
+ function isDigit(ch) {
3213
+ return ch >= 48 && ch <= 57;
3214
+ }
3215
+ var CharacterCodes;
3216
+ (function(CharacterCodes2) {
3217
+ CharacterCodes2[CharacterCodes2["lineFeed"] = 10] = "lineFeed";
3218
+ CharacterCodes2[CharacterCodes2["carriageReturn"] = 13] = "carriageReturn";
3219
+ CharacterCodes2[CharacterCodes2["space"] = 32] = "space";
3220
+ CharacterCodes2[CharacterCodes2["_0"] = 48] = "_0";
3221
+ CharacterCodes2[CharacterCodes2["_1"] = 49] = "_1";
3222
+ CharacterCodes2[CharacterCodes2["_2"] = 50] = "_2";
3223
+ CharacterCodes2[CharacterCodes2["_3"] = 51] = "_3";
3224
+ CharacterCodes2[CharacterCodes2["_4"] = 52] = "_4";
3225
+ CharacterCodes2[CharacterCodes2["_5"] = 53] = "_5";
3226
+ CharacterCodes2[CharacterCodes2["_6"] = 54] = "_6";
3227
+ CharacterCodes2[CharacterCodes2["_7"] = 55] = "_7";
3228
+ CharacterCodes2[CharacterCodes2["_8"] = 56] = "_8";
3229
+ CharacterCodes2[CharacterCodes2["_9"] = 57] = "_9";
3230
+ CharacterCodes2[CharacterCodes2["a"] = 97] = "a";
3231
+ CharacterCodes2[CharacterCodes2["b"] = 98] = "b";
3232
+ CharacterCodes2[CharacterCodes2["c"] = 99] = "c";
3233
+ CharacterCodes2[CharacterCodes2["d"] = 100] = "d";
3234
+ CharacterCodes2[CharacterCodes2["e"] = 101] = "e";
3235
+ CharacterCodes2[CharacterCodes2["f"] = 102] = "f";
3236
+ CharacterCodes2[CharacterCodes2["g"] = 103] = "g";
3237
+ CharacterCodes2[CharacterCodes2["h"] = 104] = "h";
3238
+ CharacterCodes2[CharacterCodes2["i"] = 105] = "i";
3239
+ CharacterCodes2[CharacterCodes2["j"] = 106] = "j";
3240
+ CharacterCodes2[CharacterCodes2["k"] = 107] = "k";
3241
+ CharacterCodes2[CharacterCodes2["l"] = 108] = "l";
3242
+ CharacterCodes2[CharacterCodes2["m"] = 109] = "m";
3243
+ CharacterCodes2[CharacterCodes2["n"] = 110] = "n";
3244
+ CharacterCodes2[CharacterCodes2["o"] = 111] = "o";
3245
+ CharacterCodes2[CharacterCodes2["p"] = 112] = "p";
3246
+ CharacterCodes2[CharacterCodes2["q"] = 113] = "q";
3247
+ CharacterCodes2[CharacterCodes2["r"] = 114] = "r";
3248
+ CharacterCodes2[CharacterCodes2["s"] = 115] = "s";
3249
+ CharacterCodes2[CharacterCodes2["t"] = 116] = "t";
3250
+ CharacterCodes2[CharacterCodes2["u"] = 117] = "u";
3251
+ CharacterCodes2[CharacterCodes2["v"] = 118] = "v";
3252
+ CharacterCodes2[CharacterCodes2["w"] = 119] = "w";
3253
+ CharacterCodes2[CharacterCodes2["x"] = 120] = "x";
3254
+ CharacterCodes2[CharacterCodes2["y"] = 121] = "y";
3255
+ CharacterCodes2[CharacterCodes2["z"] = 122] = "z";
3256
+ CharacterCodes2[CharacterCodes2["A"] = 65] = "A";
3257
+ CharacterCodes2[CharacterCodes2["B"] = 66] = "B";
3258
+ CharacterCodes2[CharacterCodes2["C"] = 67] = "C";
3259
+ CharacterCodes2[CharacterCodes2["D"] = 68] = "D";
3260
+ CharacterCodes2[CharacterCodes2["E"] = 69] = "E";
3261
+ CharacterCodes2[CharacterCodes2["F"] = 70] = "F";
3262
+ CharacterCodes2[CharacterCodes2["G"] = 71] = "G";
3263
+ CharacterCodes2[CharacterCodes2["H"] = 72] = "H";
3264
+ CharacterCodes2[CharacterCodes2["I"] = 73] = "I";
3265
+ CharacterCodes2[CharacterCodes2["J"] = 74] = "J";
3266
+ CharacterCodes2[CharacterCodes2["K"] = 75] = "K";
3267
+ CharacterCodes2[CharacterCodes2["L"] = 76] = "L";
3268
+ CharacterCodes2[CharacterCodes2["M"] = 77] = "M";
3269
+ CharacterCodes2[CharacterCodes2["N"] = 78] = "N";
3270
+ CharacterCodes2[CharacterCodes2["O"] = 79] = "O";
3271
+ CharacterCodes2[CharacterCodes2["P"] = 80] = "P";
3272
+ CharacterCodes2[CharacterCodes2["Q"] = 81] = "Q";
3273
+ CharacterCodes2[CharacterCodes2["R"] = 82] = "R";
3274
+ CharacterCodes2[CharacterCodes2["S"] = 83] = "S";
3275
+ CharacterCodes2[CharacterCodes2["T"] = 84] = "T";
3276
+ CharacterCodes2[CharacterCodes2["U"] = 85] = "U";
3277
+ CharacterCodes2[CharacterCodes2["V"] = 86] = "V";
3278
+ CharacterCodes2[CharacterCodes2["W"] = 87] = "W";
3279
+ CharacterCodes2[CharacterCodes2["X"] = 88] = "X";
3280
+ CharacterCodes2[CharacterCodes2["Y"] = 89] = "Y";
3281
+ CharacterCodes2[CharacterCodes2["Z"] = 90] = "Z";
3282
+ CharacterCodes2[CharacterCodes2["asterisk"] = 42] = "asterisk";
3283
+ CharacterCodes2[CharacterCodes2["backslash"] = 92] = "backslash";
3284
+ CharacterCodes2[CharacterCodes2["closeBrace"] = 125] = "closeBrace";
3285
+ CharacterCodes2[CharacterCodes2["closeBracket"] = 93] = "closeBracket";
3286
+ CharacterCodes2[CharacterCodes2["colon"] = 58] = "colon";
3287
+ CharacterCodes2[CharacterCodes2["comma"] = 44] = "comma";
3288
+ CharacterCodes2[CharacterCodes2["dot"] = 46] = "dot";
3289
+ CharacterCodes2[CharacterCodes2["doubleQuote"] = 34] = "doubleQuote";
3290
+ CharacterCodes2[CharacterCodes2["minus"] = 45] = "minus";
3291
+ CharacterCodes2[CharacterCodes2["openBrace"] = 123] = "openBrace";
3292
+ CharacterCodes2[CharacterCodes2["openBracket"] = 91] = "openBracket";
3293
+ CharacterCodes2[CharacterCodes2["plus"] = 43] = "plus";
3294
+ CharacterCodes2[CharacterCodes2["slash"] = 47] = "slash";
3295
+ CharacterCodes2[CharacterCodes2["formFeed"] = 12] = "formFeed";
3296
+ CharacterCodes2[CharacterCodes2["tab"] = 9] = "tab";
3297
+ })(CharacterCodes || (CharacterCodes = {}));
3298
+
3299
+ // node_modules/jsonc-parser/lib/esm/impl/string-intern.js
3300
+ var cachedSpaces = new Array(20).fill(0).map((_, index) => {
3301
+ return " ".repeat(index);
3302
+ });
3303
+ var maxCachedValues = 200;
3304
+ var cachedBreakLinesWithSpaces = {
3305
+ " ": {
3306
+ "\n": new Array(maxCachedValues).fill(0).map((_, index) => {
3307
+ return "\n" + " ".repeat(index);
3308
+ }),
3309
+ "\r": new Array(maxCachedValues).fill(0).map((_, index) => {
3310
+ return "\r" + " ".repeat(index);
3311
+ }),
3312
+ "\r\n": new Array(maxCachedValues).fill(0).map((_, index) => {
3313
+ return "\r\n" + " ".repeat(index);
3314
+ })
3315
+ },
3316
+ " ": {
3317
+ "\n": new Array(maxCachedValues).fill(0).map((_, index) => {
3318
+ return "\n" + " ".repeat(index);
3319
+ }),
3320
+ "\r": new Array(maxCachedValues).fill(0).map((_, index) => {
3321
+ return "\r" + " ".repeat(index);
3322
+ }),
3323
+ "\r\n": new Array(maxCachedValues).fill(0).map((_, index) => {
3324
+ return "\r\n" + " ".repeat(index);
3325
+ })
3326
+ }
3327
+ };
3328
+ var supportedEols = ["\n", "\r", "\r\n"];
3329
+
3330
+ // node_modules/jsonc-parser/lib/esm/impl/format.js
3331
+ function format(documentText, range, options) {
3332
+ let initialIndentLevel;
3333
+ let formatText;
3334
+ let formatTextStart;
3335
+ let rangeStart;
3336
+ let rangeEnd;
3337
+ if (range) {
3338
+ rangeStart = range.offset;
3339
+ rangeEnd = rangeStart + range.length;
3340
+ formatTextStart = rangeStart;
3341
+ while (formatTextStart > 0 && !isEOL(documentText, formatTextStart - 1)) {
3342
+ formatTextStart--;
3343
+ }
3344
+ let endOffset = rangeEnd;
3345
+ while (endOffset < documentText.length && !isEOL(documentText, endOffset)) {
3346
+ endOffset++;
3347
+ }
3348
+ formatText = documentText.substring(formatTextStart, endOffset);
3349
+ initialIndentLevel = computeIndentLevel(formatText, options);
3350
+ } else {
3351
+ formatText = documentText;
3352
+ initialIndentLevel = 0;
3353
+ formatTextStart = 0;
3354
+ rangeStart = 0;
3355
+ rangeEnd = documentText.length;
3356
+ }
3357
+ const eol = getEOL(options, documentText);
3358
+ const eolFastPathSupported = supportedEols.includes(eol);
3359
+ let numberLineBreaks = 0;
3360
+ let indentLevel = 0;
3361
+ let indentValue;
3362
+ if (options.insertSpaces) {
3363
+ indentValue = cachedSpaces[options.tabSize || 4] ?? repeat(cachedSpaces[1], options.tabSize || 4);
3364
+ } else {
3365
+ indentValue = " ";
3366
+ }
3367
+ const indentType = indentValue === " " ? " " : " ";
3368
+ let scanner = createScanner(formatText, false);
3369
+ let hasError = false;
3370
+ function newLinesAndIndent() {
3371
+ if (numberLineBreaks > 1) {
3372
+ return repeat(eol, numberLineBreaks) + repeat(indentValue, initialIndentLevel + indentLevel);
3373
+ }
3374
+ const amountOfSpaces = indentValue.length * (initialIndentLevel + indentLevel);
3375
+ if (!eolFastPathSupported || amountOfSpaces > cachedBreakLinesWithSpaces[indentType][eol].length) {
3376
+ return eol + repeat(indentValue, initialIndentLevel + indentLevel);
3377
+ }
3378
+ if (amountOfSpaces <= 0) {
3379
+ return eol;
3380
+ }
3381
+ return cachedBreakLinesWithSpaces[indentType][eol][amountOfSpaces];
3382
+ }
3383
+ function scanNext() {
3384
+ let token = scanner.scan();
3385
+ numberLineBreaks = 0;
3386
+ while (token === 15 || token === 14) {
3387
+ if (token === 14 && options.keepLines) {
3388
+ numberLineBreaks += 1;
3389
+ } else if (token === 14) {
3390
+ numberLineBreaks = 1;
3391
+ }
3392
+ token = scanner.scan();
3393
+ }
3394
+ hasError = token === 16 || scanner.getTokenError() !== 0;
3395
+ return token;
3396
+ }
3397
+ const editOperations = [];
3398
+ function addEdit(text, startOffset, endOffset) {
3399
+ if (!hasError && (!range || startOffset < rangeEnd && endOffset > rangeStart) && documentText.substring(startOffset, endOffset) !== text) {
3400
+ editOperations.push({ offset: startOffset, length: endOffset - startOffset, content: text });
3401
+ }
3402
+ }
3403
+ let firstToken = scanNext();
3404
+ if (options.keepLines && numberLineBreaks > 0) {
3405
+ addEdit(repeat(eol, numberLineBreaks), 0, 0);
3406
+ }
3407
+ if (firstToken !== 17) {
3408
+ let firstTokenStart = scanner.getTokenOffset() + formatTextStart;
3409
+ let initialIndent = indentValue.length * initialIndentLevel < 20 && options.insertSpaces ? cachedSpaces[indentValue.length * initialIndentLevel] : repeat(indentValue, initialIndentLevel);
3410
+ addEdit(initialIndent, formatTextStart, firstTokenStart);
3411
+ }
3412
+ while (firstToken !== 17) {
3413
+ let firstTokenEnd = scanner.getTokenOffset() + scanner.getTokenLength() + formatTextStart;
3414
+ let secondToken = scanNext();
3415
+ let replaceContent = "";
3416
+ let needsLineBreak = false;
3417
+ while (numberLineBreaks === 0 && (secondToken === 12 || secondToken === 13)) {
3418
+ let commentTokenStart = scanner.getTokenOffset() + formatTextStart;
3419
+ addEdit(cachedSpaces[1], firstTokenEnd, commentTokenStart);
3420
+ firstTokenEnd = scanner.getTokenOffset() + scanner.getTokenLength() + formatTextStart;
3421
+ needsLineBreak = secondToken === 12;
3422
+ replaceContent = needsLineBreak ? newLinesAndIndent() : "";
3423
+ secondToken = scanNext();
3424
+ }
3425
+ if (secondToken === 2) {
3426
+ if (firstToken !== 1) {
3427
+ indentLevel--;
3428
+ }
3429
+ ;
3430
+ if (options.keepLines && numberLineBreaks > 0 || !options.keepLines && firstToken !== 1) {
3431
+ replaceContent = newLinesAndIndent();
3432
+ } else if (options.keepLines) {
3433
+ replaceContent = cachedSpaces[1];
3434
+ }
3435
+ } else if (secondToken === 4) {
3436
+ if (firstToken !== 3) {
3437
+ indentLevel--;
3438
+ }
3439
+ ;
3440
+ if (options.keepLines && numberLineBreaks > 0 || !options.keepLines && firstToken !== 3) {
3441
+ replaceContent = newLinesAndIndent();
3442
+ } else if (options.keepLines) {
3443
+ replaceContent = cachedSpaces[1];
3444
+ }
3445
+ } else {
3446
+ switch (firstToken) {
3447
+ case 3:
3448
+ case 1:
3449
+ indentLevel++;
3450
+ if (options.keepLines && numberLineBreaks > 0 || !options.keepLines) {
3451
+ replaceContent = newLinesAndIndent();
3452
+ } else {
3453
+ replaceContent = cachedSpaces[1];
3454
+ }
3455
+ break;
3456
+ case 5:
3457
+ if (options.keepLines && numberLineBreaks > 0 || !options.keepLines) {
3458
+ replaceContent = newLinesAndIndent();
3459
+ } else {
3460
+ replaceContent = cachedSpaces[1];
3461
+ }
3462
+ break;
3463
+ case 12:
3464
+ replaceContent = newLinesAndIndent();
3465
+ break;
3466
+ case 13:
3467
+ if (numberLineBreaks > 0) {
3468
+ replaceContent = newLinesAndIndent();
3469
+ } else if (!needsLineBreak) {
3470
+ replaceContent = cachedSpaces[1];
3471
+ }
3472
+ break;
3473
+ case 6:
3474
+ if (options.keepLines && numberLineBreaks > 0) {
3475
+ replaceContent = newLinesAndIndent();
3476
+ } else if (!needsLineBreak) {
3477
+ replaceContent = cachedSpaces[1];
3478
+ }
3479
+ break;
3480
+ case 10:
3481
+ if (options.keepLines && numberLineBreaks > 0) {
3482
+ replaceContent = newLinesAndIndent();
3483
+ } else if (secondToken === 6 && !needsLineBreak) {
3484
+ replaceContent = "";
3485
+ }
3486
+ break;
3487
+ case 7:
3488
+ case 8:
3489
+ case 9:
3490
+ case 11:
3491
+ case 2:
3492
+ case 4:
3493
+ if (options.keepLines && numberLineBreaks > 0) {
3494
+ replaceContent = newLinesAndIndent();
3495
+ } else {
3496
+ if ((secondToken === 12 || secondToken === 13) && !needsLineBreak) {
3497
+ replaceContent = cachedSpaces[1];
3498
+ } else if (secondToken !== 5 && secondToken !== 17) {
3499
+ hasError = true;
3500
+ }
3501
+ }
3502
+ break;
3503
+ case 16:
3504
+ hasError = true;
3505
+ break;
3506
+ }
3507
+ if (numberLineBreaks > 0 && (secondToken === 12 || secondToken === 13)) {
3508
+ replaceContent = newLinesAndIndent();
3509
+ }
3510
+ }
3511
+ if (secondToken === 17) {
3512
+ if (options.keepLines && numberLineBreaks > 0) {
3513
+ replaceContent = newLinesAndIndent();
3514
+ } else {
3515
+ replaceContent = options.insertFinalNewline ? eol : "";
3516
+ }
3517
+ }
3518
+ const secondTokenStart = scanner.getTokenOffset() + formatTextStart;
3519
+ addEdit(replaceContent, firstTokenEnd, secondTokenStart);
3520
+ firstToken = secondToken;
3521
+ }
3522
+ return editOperations;
3523
+ }
3524
+ function repeat(s, count) {
3525
+ let result = "";
3526
+ for (let i = 0; i < count; i++) {
3527
+ result += s;
3528
+ }
3529
+ return result;
3530
+ }
3531
+ function computeIndentLevel(content, options) {
3532
+ let i = 0;
3533
+ let nChars = 0;
3534
+ const tabSize = options.tabSize || 4;
3535
+ while (i < content.length) {
3536
+ let ch = content.charAt(i);
3537
+ if (ch === cachedSpaces[1]) {
3538
+ nChars++;
3539
+ } else if (ch === " ") {
3540
+ nChars += tabSize;
3541
+ } else {
3542
+ break;
3543
+ }
3544
+ i++;
3545
+ }
3546
+ return Math.floor(nChars / tabSize);
3547
+ }
3548
+ function getEOL(options, text) {
3549
+ for (let i = 0; i < text.length; i++) {
3550
+ const ch = text.charAt(i);
3551
+ if (ch === "\r") {
3552
+ if (i + 1 < text.length && text.charAt(i + 1) === "\n") {
3553
+ return "\r\n";
3554
+ }
3555
+ return "\r";
3556
+ } else if (ch === "\n") {
3557
+ return "\n";
3558
+ }
3559
+ }
3560
+ return options && options.eol || "\n";
3561
+ }
3562
+ function isEOL(text, offset) {
3563
+ return "\r\n".indexOf(text.charAt(offset)) !== -1;
3564
+ }
3565
+
3566
+ // node_modules/jsonc-parser/lib/esm/impl/parser.js
3567
+ var ParseOptions;
3568
+ (function(ParseOptions2) {
3569
+ ParseOptions2.DEFAULT = {
3570
+ allowTrailingComma: false
3571
+ };
3572
+ })(ParseOptions || (ParseOptions = {}));
3573
+ function parse(text, errors = [], options = ParseOptions.DEFAULT) {
3574
+ let currentProperty = null;
3575
+ let currentParent = [];
3576
+ const previousParents = [];
3577
+ function onValue(value) {
3578
+ if (Array.isArray(currentParent)) {
3579
+ currentParent.push(value);
3580
+ } else if (currentProperty !== null) {
3581
+ currentParent[currentProperty] = value;
3582
+ }
3583
+ }
3584
+ const visitor = {
3585
+ onObjectBegin: () => {
3586
+ const object = {};
3587
+ onValue(object);
3588
+ previousParents.push(currentParent);
3589
+ currentParent = object;
3590
+ currentProperty = null;
3591
+ },
3592
+ onObjectProperty: (name) => {
3593
+ currentProperty = name;
3594
+ },
3595
+ onObjectEnd: () => {
3596
+ currentParent = previousParents.pop();
3597
+ },
3598
+ onArrayBegin: () => {
3599
+ const array = [];
3600
+ onValue(array);
3601
+ previousParents.push(currentParent);
3602
+ currentParent = array;
3603
+ currentProperty = null;
3604
+ },
3605
+ onArrayEnd: () => {
3606
+ currentParent = previousParents.pop();
3607
+ },
3608
+ onLiteralValue: onValue,
3609
+ onError: (error, offset, length) => {
3610
+ errors.push({ error, offset, length });
3611
+ }
3612
+ };
3613
+ visit(text, visitor, options);
3614
+ return currentParent[0];
3615
+ }
3616
+ function parseTree(text, errors = [], options = ParseOptions.DEFAULT) {
3617
+ let currentParent = { type: "array", offset: -1, length: -1, children: [], parent: void 0 };
3618
+ function ensurePropertyComplete(endOffset) {
3619
+ if (currentParent.type === "property") {
3620
+ currentParent.length = endOffset - currentParent.offset;
3621
+ currentParent = currentParent.parent;
3622
+ }
3623
+ }
3624
+ function onValue(valueNode) {
3625
+ currentParent.children.push(valueNode);
3626
+ return valueNode;
3627
+ }
3628
+ const visitor = {
3629
+ onObjectBegin: (offset) => {
3630
+ currentParent = onValue({ type: "object", offset, length: -1, parent: currentParent, children: [] });
3631
+ },
3632
+ onObjectProperty: (name, offset, length) => {
3633
+ currentParent = onValue({ type: "property", offset, length: -1, parent: currentParent, children: [] });
3634
+ currentParent.children.push({ type: "string", value: name, offset, length, parent: currentParent });
3635
+ },
3636
+ onObjectEnd: (offset, length) => {
3637
+ ensurePropertyComplete(offset + length);
3638
+ currentParent.length = offset + length - currentParent.offset;
3639
+ currentParent = currentParent.parent;
3640
+ ensurePropertyComplete(offset + length);
3641
+ },
3642
+ onArrayBegin: (offset, length) => {
3643
+ currentParent = onValue({ type: "array", offset, length: -1, parent: currentParent, children: [] });
3644
+ },
3645
+ onArrayEnd: (offset, length) => {
3646
+ currentParent.length = offset + length - currentParent.offset;
3647
+ currentParent = currentParent.parent;
3648
+ ensurePropertyComplete(offset + length);
3649
+ },
3650
+ onLiteralValue: (value, offset, length) => {
3651
+ onValue({ type: getNodeType(value), offset, length, parent: currentParent, value });
3652
+ ensurePropertyComplete(offset + length);
3653
+ },
3654
+ onSeparator: (sep2, offset, length) => {
3655
+ if (currentParent.type === "property") {
3656
+ if (sep2 === ":") {
3657
+ currentParent.colonOffset = offset;
3658
+ } else if (sep2 === ",") {
3659
+ ensurePropertyComplete(offset);
3660
+ }
3661
+ }
3662
+ },
3663
+ onError: (error, offset, length) => {
3664
+ errors.push({ error, offset, length });
3665
+ }
3666
+ };
3667
+ visit(text, visitor, options);
3668
+ const result = currentParent.children[0];
3669
+ if (result) {
3670
+ delete result.parent;
3671
+ }
3672
+ return result;
3673
+ }
3674
+ function findNodeAtLocation(root, path) {
3675
+ if (!root) {
3676
+ return void 0;
3677
+ }
3678
+ let node = root;
3679
+ for (let segment of path) {
3680
+ if (typeof segment === "string") {
3681
+ if (node.type !== "object" || !Array.isArray(node.children)) {
3682
+ return void 0;
3683
+ }
3684
+ let found = false;
3685
+ for (const propertyNode of node.children) {
3686
+ if (Array.isArray(propertyNode.children) && propertyNode.children[0].value === segment && propertyNode.children.length === 2) {
3687
+ node = propertyNode.children[1];
3688
+ found = true;
3689
+ break;
3690
+ }
3691
+ }
3692
+ if (!found) {
3693
+ return void 0;
3694
+ }
3695
+ } else {
3696
+ const index = segment;
3697
+ if (node.type !== "array" || index < 0 || !Array.isArray(node.children) || index >= node.children.length) {
3698
+ return void 0;
3699
+ }
3700
+ node = node.children[index];
3701
+ }
3702
+ }
3703
+ return node;
3704
+ }
3705
+ function visit(text, visitor, options = ParseOptions.DEFAULT) {
3706
+ const _scanner = createScanner(text, false);
3707
+ const _jsonPath = [];
3708
+ let suppressedCallbacks = 0;
3709
+ function toNoArgVisit(visitFunction) {
3710
+ return visitFunction ? () => suppressedCallbacks === 0 && visitFunction(_scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter()) : () => true;
3711
+ }
3712
+ function toOneArgVisit(visitFunction) {
3713
+ return visitFunction ? (arg) => suppressedCallbacks === 0 && visitFunction(arg, _scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter()) : () => true;
3714
+ }
3715
+ function toOneArgVisitWithPath(visitFunction) {
3716
+ return visitFunction ? (arg) => suppressedCallbacks === 0 && visitFunction(arg, _scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter(), () => _jsonPath.slice()) : () => true;
3717
+ }
3718
+ function toBeginVisit(visitFunction) {
3719
+ return visitFunction ? () => {
3720
+ if (suppressedCallbacks > 0) {
3721
+ suppressedCallbacks++;
3722
+ } else {
3723
+ let cbReturn = visitFunction(_scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter(), () => _jsonPath.slice());
3724
+ if (cbReturn === false) {
3725
+ suppressedCallbacks = 1;
3726
+ }
3727
+ }
3728
+ } : () => true;
3729
+ }
3730
+ function toEndVisit(visitFunction) {
3731
+ return visitFunction ? () => {
3732
+ if (suppressedCallbacks > 0) {
3733
+ suppressedCallbacks--;
3734
+ }
3735
+ if (suppressedCallbacks === 0) {
3736
+ visitFunction(_scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter());
3737
+ }
3738
+ } : () => true;
3739
+ }
3740
+ const onObjectBegin = toBeginVisit(visitor.onObjectBegin), onObjectProperty = toOneArgVisitWithPath(visitor.onObjectProperty), onObjectEnd = toEndVisit(visitor.onObjectEnd), onArrayBegin = toBeginVisit(visitor.onArrayBegin), onArrayEnd = toEndVisit(visitor.onArrayEnd), onLiteralValue = toOneArgVisitWithPath(visitor.onLiteralValue), onSeparator = toOneArgVisit(visitor.onSeparator), onComment = toNoArgVisit(visitor.onComment), onError = toOneArgVisit(visitor.onError);
3741
+ const disallowComments = options && options.disallowComments;
3742
+ const allowTrailingComma = options && options.allowTrailingComma;
3743
+ function scanNext() {
3744
+ while (true) {
3745
+ const token = _scanner.scan();
3746
+ switch (_scanner.getTokenError()) {
3747
+ case 4:
3748
+ handleError(
3749
+ 14
3750
+ /* ParseErrorCode.InvalidUnicode */
3751
+ );
3752
+ break;
3753
+ case 5:
3754
+ handleError(
3755
+ 15
3756
+ /* ParseErrorCode.InvalidEscapeCharacter */
3757
+ );
3758
+ break;
3759
+ case 3:
3760
+ handleError(
3761
+ 13
3762
+ /* ParseErrorCode.UnexpectedEndOfNumber */
3763
+ );
3764
+ break;
3765
+ case 1:
3766
+ if (!disallowComments) {
3767
+ handleError(
3768
+ 11
3769
+ /* ParseErrorCode.UnexpectedEndOfComment */
3770
+ );
3771
+ }
3772
+ break;
3773
+ case 2:
3774
+ handleError(
3775
+ 12
3776
+ /* ParseErrorCode.UnexpectedEndOfString */
3777
+ );
3778
+ break;
3779
+ case 6:
3780
+ handleError(
3781
+ 16
3782
+ /* ParseErrorCode.InvalidCharacter */
3783
+ );
3784
+ break;
3785
+ }
3786
+ switch (token) {
3787
+ case 12:
3788
+ case 13:
3789
+ if (disallowComments) {
3790
+ handleError(
3791
+ 10
3792
+ /* ParseErrorCode.InvalidCommentToken */
3793
+ );
3794
+ } else {
3795
+ onComment();
3796
+ }
3797
+ break;
3798
+ case 16:
3799
+ handleError(
3800
+ 1
3801
+ /* ParseErrorCode.InvalidSymbol */
3802
+ );
3803
+ break;
3804
+ case 15:
3805
+ case 14:
3806
+ break;
3807
+ default:
3808
+ return token;
3809
+ }
3810
+ }
3811
+ }
3812
+ function handleError(error, skipUntilAfter = [], skipUntil = []) {
3813
+ onError(error);
3814
+ if (skipUntilAfter.length + skipUntil.length > 0) {
3815
+ let token = _scanner.getToken();
3816
+ while (token !== 17) {
3817
+ if (skipUntilAfter.indexOf(token) !== -1) {
3818
+ scanNext();
3819
+ break;
3820
+ } else if (skipUntil.indexOf(token) !== -1) {
3821
+ break;
3822
+ }
3823
+ token = scanNext();
3824
+ }
3825
+ }
3826
+ }
3827
+ function parseString(isValue) {
3828
+ const value = _scanner.getTokenValue();
3829
+ if (isValue) {
3830
+ onLiteralValue(value);
3831
+ } else {
3832
+ onObjectProperty(value);
3833
+ _jsonPath.push(value);
3834
+ }
3835
+ scanNext();
3836
+ return true;
3837
+ }
3838
+ function parseLiteral() {
3839
+ switch (_scanner.getToken()) {
3840
+ case 11:
3841
+ const tokenValue = _scanner.getTokenValue();
3842
+ let value = Number(tokenValue);
3843
+ if (isNaN(value)) {
3844
+ handleError(
3845
+ 2
3846
+ /* ParseErrorCode.InvalidNumberFormat */
3847
+ );
3848
+ value = 0;
3849
+ }
3850
+ onLiteralValue(value);
3851
+ break;
3852
+ case 7:
3853
+ onLiteralValue(null);
3854
+ break;
3855
+ case 8:
3856
+ onLiteralValue(true);
3857
+ break;
3858
+ case 9:
3859
+ onLiteralValue(false);
3860
+ break;
3861
+ default:
3862
+ return false;
3863
+ }
3864
+ scanNext();
3865
+ return true;
3866
+ }
3867
+ function parseProperty() {
3868
+ if (_scanner.getToken() !== 10) {
3869
+ handleError(3, [], [
3870
+ 2,
3871
+ 5
3872
+ /* SyntaxKind.CommaToken */
3873
+ ]);
3874
+ return false;
3875
+ }
3876
+ parseString(false);
3877
+ if (_scanner.getToken() === 6) {
3878
+ onSeparator(":");
3879
+ scanNext();
3880
+ if (!parseValue()) {
3881
+ handleError(4, [], [
3882
+ 2,
3883
+ 5
3884
+ /* SyntaxKind.CommaToken */
3885
+ ]);
3886
+ }
3887
+ } else {
3888
+ handleError(5, [], [
3889
+ 2,
3890
+ 5
3891
+ /* SyntaxKind.CommaToken */
3892
+ ]);
3893
+ }
3894
+ _jsonPath.pop();
3895
+ return true;
3896
+ }
3897
+ function parseObject() {
3898
+ onObjectBegin();
3899
+ scanNext();
3900
+ let needsComma = false;
3901
+ while (_scanner.getToken() !== 2 && _scanner.getToken() !== 17) {
3902
+ if (_scanner.getToken() === 5) {
3903
+ if (!needsComma) {
3904
+ handleError(4, [], []);
3905
+ }
3906
+ onSeparator(",");
3907
+ scanNext();
3908
+ if (_scanner.getToken() === 2 && allowTrailingComma) {
3909
+ break;
3910
+ }
3911
+ } else if (needsComma) {
3912
+ handleError(6, [], []);
3913
+ }
3914
+ if (!parseProperty()) {
3915
+ handleError(4, [], [
3916
+ 2,
3917
+ 5
3918
+ /* SyntaxKind.CommaToken */
3919
+ ]);
3920
+ }
3921
+ needsComma = true;
3922
+ }
3923
+ onObjectEnd();
3924
+ if (_scanner.getToken() !== 2) {
3925
+ handleError(7, [
3926
+ 2
3927
+ /* SyntaxKind.CloseBraceToken */
3928
+ ], []);
3929
+ } else {
3930
+ scanNext();
3931
+ }
3932
+ return true;
3933
+ }
3934
+ function parseArray() {
3935
+ onArrayBegin();
3936
+ scanNext();
3937
+ let isFirstElement = true;
3938
+ let needsComma = false;
3939
+ while (_scanner.getToken() !== 4 && _scanner.getToken() !== 17) {
3940
+ if (_scanner.getToken() === 5) {
3941
+ if (!needsComma) {
3942
+ handleError(4, [], []);
3943
+ }
3944
+ onSeparator(",");
3945
+ scanNext();
3946
+ if (_scanner.getToken() === 4 && allowTrailingComma) {
3947
+ break;
3948
+ }
3949
+ } else if (needsComma) {
3950
+ handleError(6, [], []);
3951
+ }
3952
+ if (isFirstElement) {
3953
+ _jsonPath.push(0);
3954
+ isFirstElement = false;
3955
+ } else {
3956
+ _jsonPath[_jsonPath.length - 1]++;
3957
+ }
3958
+ if (!parseValue()) {
3959
+ handleError(4, [], [
3960
+ 4,
3961
+ 5
3962
+ /* SyntaxKind.CommaToken */
3963
+ ]);
3964
+ }
3965
+ needsComma = true;
3966
+ }
3967
+ onArrayEnd();
3968
+ if (!isFirstElement) {
3969
+ _jsonPath.pop();
3970
+ }
3971
+ if (_scanner.getToken() !== 4) {
3972
+ handleError(8, [
3973
+ 4
3974
+ /* SyntaxKind.CloseBracketToken */
3975
+ ], []);
3976
+ } else {
3977
+ scanNext();
3978
+ }
3979
+ return true;
3980
+ }
3981
+ function parseValue() {
3982
+ switch (_scanner.getToken()) {
3983
+ case 3:
3984
+ return parseArray();
3985
+ case 1:
3986
+ return parseObject();
3987
+ case 10:
3988
+ return parseString(true);
3989
+ default:
3990
+ return parseLiteral();
3991
+ }
3992
+ }
3993
+ scanNext();
3994
+ if (_scanner.getToken() === 17) {
3995
+ if (options.allowEmptyContent) {
3996
+ return true;
3997
+ }
3998
+ handleError(4, [], []);
3999
+ return false;
4000
+ }
4001
+ if (!parseValue()) {
4002
+ handleError(4, [], []);
4003
+ return false;
4004
+ }
4005
+ if (_scanner.getToken() !== 17) {
4006
+ handleError(9, [], []);
4007
+ }
4008
+ return true;
4009
+ }
4010
+ function getNodeType(value) {
4011
+ switch (typeof value) {
4012
+ case "boolean":
4013
+ return "boolean";
4014
+ case "number":
4015
+ return "number";
4016
+ case "string":
4017
+ return "string";
4018
+ case "object": {
4019
+ if (!value) {
4020
+ return "null";
4021
+ } else if (Array.isArray(value)) {
4022
+ return "array";
4023
+ }
4024
+ return "object";
4025
+ }
4026
+ default:
4027
+ return "null";
4028
+ }
4029
+ }
4030
+
4031
+ // node_modules/jsonc-parser/lib/esm/impl/edit.js
4032
+ function setProperty(text, originalPath, value, options) {
4033
+ const path = originalPath.slice();
4034
+ const errors = [];
4035
+ const root = parseTree(text, errors);
4036
+ let parent = void 0;
4037
+ let lastSegment = void 0;
4038
+ while (path.length > 0) {
4039
+ lastSegment = path.pop();
4040
+ parent = findNodeAtLocation(root, path);
4041
+ if (parent === void 0 && value !== void 0) {
4042
+ if (typeof lastSegment === "string") {
4043
+ value = { [lastSegment]: value };
4044
+ } else {
4045
+ value = [value];
4046
+ }
4047
+ } else {
4048
+ break;
4049
+ }
4050
+ }
4051
+ if (!parent) {
4052
+ if (value === void 0) {
4053
+ throw new Error("Can not delete in empty document");
4054
+ }
4055
+ return withFormatting(text, { offset: root ? root.offset : 0, length: root ? root.length : 0, content: JSON.stringify(value) }, options);
4056
+ } else if (parent.type === "object" && typeof lastSegment === "string" && Array.isArray(parent.children)) {
4057
+ const existing = findNodeAtLocation(parent, [lastSegment]);
4058
+ if (existing !== void 0) {
4059
+ if (value === void 0) {
4060
+ if (!existing.parent) {
4061
+ throw new Error("Malformed AST");
4062
+ }
4063
+ const propertyIndex = parent.children.indexOf(existing.parent);
4064
+ let removeBegin;
4065
+ let removeEnd = existing.parent.offset + existing.parent.length;
4066
+ if (propertyIndex > 0) {
4067
+ let previous = parent.children[propertyIndex - 1];
4068
+ removeBegin = previous.offset + previous.length;
4069
+ } else {
4070
+ removeBegin = parent.offset + 1;
4071
+ if (parent.children.length > 1) {
4072
+ let next = parent.children[1];
4073
+ removeEnd = next.offset;
4074
+ }
4075
+ }
4076
+ return withFormatting(text, { offset: removeBegin, length: removeEnd - removeBegin, content: "" }, options);
4077
+ } else {
4078
+ return withFormatting(text, { offset: existing.offset, length: existing.length, content: JSON.stringify(value) }, options);
4079
+ }
4080
+ } else {
4081
+ if (value === void 0) {
4082
+ return [];
4083
+ }
4084
+ const newProperty = `${JSON.stringify(lastSegment)}: ${JSON.stringify(value)}`;
4085
+ const index = options.getInsertionIndex ? options.getInsertionIndex(parent.children.map((p) => p.children[0].value)) : parent.children.length;
4086
+ let edit;
4087
+ if (index > 0) {
4088
+ let previous = parent.children[index - 1];
4089
+ edit = { offset: previous.offset + previous.length, length: 0, content: "," + newProperty };
4090
+ } else if (parent.children.length === 0) {
4091
+ edit = { offset: parent.offset + 1, length: 0, content: newProperty };
4092
+ } else {
4093
+ edit = { offset: parent.offset + 1, length: 0, content: newProperty + "," };
4094
+ }
4095
+ return withFormatting(text, edit, options);
4096
+ }
4097
+ } else if (parent.type === "array" && typeof lastSegment === "number" && Array.isArray(parent.children)) {
4098
+ const insertIndex = lastSegment;
4099
+ if (insertIndex === -1) {
4100
+ const newProperty = `${JSON.stringify(value)}`;
4101
+ let edit;
4102
+ if (parent.children.length === 0) {
4103
+ edit = { offset: parent.offset + 1, length: 0, content: newProperty };
4104
+ } else {
4105
+ const previous = parent.children[parent.children.length - 1];
4106
+ edit = { offset: previous.offset + previous.length, length: 0, content: "," + newProperty };
4107
+ }
4108
+ return withFormatting(text, edit, options);
4109
+ } else if (value === void 0 && parent.children.length >= 0) {
4110
+ const removalIndex = lastSegment;
4111
+ const toRemove = parent.children[removalIndex];
4112
+ let edit;
4113
+ if (parent.children.length === 1) {
4114
+ edit = { offset: parent.offset + 1, length: parent.length - 2, content: "" };
4115
+ } else if (parent.children.length - 1 === removalIndex) {
4116
+ let previous = parent.children[removalIndex - 1];
4117
+ let offset = previous.offset + previous.length;
4118
+ let parentEndOffset = parent.offset + parent.length;
4119
+ edit = { offset, length: parentEndOffset - 2 - offset, content: "" };
4120
+ } else {
4121
+ edit = { offset: toRemove.offset, length: parent.children[removalIndex + 1].offset - toRemove.offset, content: "" };
4122
+ }
4123
+ return withFormatting(text, edit, options);
4124
+ } else if (value !== void 0) {
4125
+ let edit;
4126
+ const newProperty = `${JSON.stringify(value)}`;
4127
+ if (!options.isArrayInsertion && parent.children.length > lastSegment) {
4128
+ const toModify = parent.children[lastSegment];
4129
+ edit = { offset: toModify.offset, length: toModify.length, content: newProperty };
4130
+ } else if (parent.children.length === 0 || lastSegment === 0) {
4131
+ edit = { offset: parent.offset + 1, length: 0, content: parent.children.length === 0 ? newProperty : newProperty + "," };
4132
+ } else {
4133
+ const index = lastSegment > parent.children.length ? parent.children.length : lastSegment;
4134
+ const previous = parent.children[index - 1];
4135
+ edit = { offset: previous.offset + previous.length, length: 0, content: "," + newProperty };
4136
+ }
4137
+ return withFormatting(text, edit, options);
4138
+ } else {
4139
+ throw new Error(`Can not ${value === void 0 ? "remove" : options.isArrayInsertion ? "insert" : "modify"} Array index ${insertIndex} as length is not sufficient`);
4140
+ }
4141
+ } else {
4142
+ throw new Error(`Can not add ${typeof lastSegment !== "number" ? "index" : "property"} to parent of type ${parent.type}`);
4143
+ }
4144
+ }
4145
+ function withFormatting(text, edit, options) {
4146
+ if (!options.formattingOptions) {
4147
+ return [edit];
4148
+ }
4149
+ let newText = applyEdit(text, edit);
4150
+ let begin = edit.offset;
4151
+ let end = edit.offset + edit.content.length;
4152
+ if (edit.length === 0 || edit.content.length === 0) {
4153
+ while (begin > 0 && !isEOL(newText, begin - 1)) {
4154
+ begin--;
4155
+ }
4156
+ while (end < newText.length && !isEOL(newText, end)) {
4157
+ end++;
4158
+ }
4159
+ }
4160
+ const edits = format(newText, { offset: begin, length: end - begin }, { ...options.formattingOptions, keepLines: false });
4161
+ for (let i = edits.length - 1; i >= 0; i--) {
4162
+ const edit2 = edits[i];
4163
+ newText = applyEdit(newText, edit2);
4164
+ begin = Math.min(begin, edit2.offset);
4165
+ end = Math.max(end, edit2.offset + edit2.length);
4166
+ end += edit2.content.length - edit2.length;
4167
+ }
4168
+ const editLength = text.length - (newText.length - end) - begin;
4169
+ return [{ offset: begin, length: editLength, content: newText.substring(begin, end) }];
4170
+ }
4171
+ function applyEdit(text, edit) {
4172
+ return text.substring(0, edit.offset) + edit.content + text.substring(edit.offset + edit.length);
4173
+ }
4174
+
4175
+ // node_modules/jsonc-parser/lib/esm/main.js
4176
+ var ScanError;
4177
+ (function(ScanError2) {
4178
+ ScanError2[ScanError2["None"] = 0] = "None";
4179
+ ScanError2[ScanError2["UnexpectedEndOfComment"] = 1] = "UnexpectedEndOfComment";
4180
+ ScanError2[ScanError2["UnexpectedEndOfString"] = 2] = "UnexpectedEndOfString";
4181
+ ScanError2[ScanError2["UnexpectedEndOfNumber"] = 3] = "UnexpectedEndOfNumber";
4182
+ ScanError2[ScanError2["InvalidUnicode"] = 4] = "InvalidUnicode";
4183
+ ScanError2[ScanError2["InvalidEscapeCharacter"] = 5] = "InvalidEscapeCharacter";
4184
+ ScanError2[ScanError2["InvalidCharacter"] = 6] = "InvalidCharacter";
4185
+ })(ScanError || (ScanError = {}));
4186
+ var SyntaxKind;
4187
+ (function(SyntaxKind2) {
4188
+ SyntaxKind2[SyntaxKind2["OpenBraceToken"] = 1] = "OpenBraceToken";
4189
+ SyntaxKind2[SyntaxKind2["CloseBraceToken"] = 2] = "CloseBraceToken";
4190
+ SyntaxKind2[SyntaxKind2["OpenBracketToken"] = 3] = "OpenBracketToken";
4191
+ SyntaxKind2[SyntaxKind2["CloseBracketToken"] = 4] = "CloseBracketToken";
4192
+ SyntaxKind2[SyntaxKind2["CommaToken"] = 5] = "CommaToken";
4193
+ SyntaxKind2[SyntaxKind2["ColonToken"] = 6] = "ColonToken";
4194
+ SyntaxKind2[SyntaxKind2["NullKeyword"] = 7] = "NullKeyword";
4195
+ SyntaxKind2[SyntaxKind2["TrueKeyword"] = 8] = "TrueKeyword";
4196
+ SyntaxKind2[SyntaxKind2["FalseKeyword"] = 9] = "FalseKeyword";
4197
+ SyntaxKind2[SyntaxKind2["StringLiteral"] = 10] = "StringLiteral";
4198
+ SyntaxKind2[SyntaxKind2["NumericLiteral"] = 11] = "NumericLiteral";
4199
+ SyntaxKind2[SyntaxKind2["LineCommentTrivia"] = 12] = "LineCommentTrivia";
4200
+ SyntaxKind2[SyntaxKind2["BlockCommentTrivia"] = 13] = "BlockCommentTrivia";
4201
+ SyntaxKind2[SyntaxKind2["LineBreakTrivia"] = 14] = "LineBreakTrivia";
4202
+ SyntaxKind2[SyntaxKind2["Trivia"] = 15] = "Trivia";
4203
+ SyntaxKind2[SyntaxKind2["Unknown"] = 16] = "Unknown";
4204
+ SyntaxKind2[SyntaxKind2["EOF"] = 17] = "EOF";
4205
+ })(SyntaxKind || (SyntaxKind = {}));
4206
+ var parse2 = parse;
4207
+ var parseTree2 = parseTree;
4208
+ var findNodeAtLocation2 = findNodeAtLocation;
4209
+ var ParseErrorCode;
4210
+ (function(ParseErrorCode2) {
4211
+ ParseErrorCode2[ParseErrorCode2["InvalidSymbol"] = 1] = "InvalidSymbol";
4212
+ ParseErrorCode2[ParseErrorCode2["InvalidNumberFormat"] = 2] = "InvalidNumberFormat";
4213
+ ParseErrorCode2[ParseErrorCode2["PropertyNameExpected"] = 3] = "PropertyNameExpected";
4214
+ ParseErrorCode2[ParseErrorCode2["ValueExpected"] = 4] = "ValueExpected";
4215
+ ParseErrorCode2[ParseErrorCode2["ColonExpected"] = 5] = "ColonExpected";
4216
+ ParseErrorCode2[ParseErrorCode2["CommaExpected"] = 6] = "CommaExpected";
4217
+ ParseErrorCode2[ParseErrorCode2["CloseBraceExpected"] = 7] = "CloseBraceExpected";
4218
+ ParseErrorCode2[ParseErrorCode2["CloseBracketExpected"] = 8] = "CloseBracketExpected";
4219
+ ParseErrorCode2[ParseErrorCode2["EndOfFileExpected"] = 9] = "EndOfFileExpected";
4220
+ ParseErrorCode2[ParseErrorCode2["InvalidCommentToken"] = 10] = "InvalidCommentToken";
4221
+ ParseErrorCode2[ParseErrorCode2["UnexpectedEndOfComment"] = 11] = "UnexpectedEndOfComment";
4222
+ ParseErrorCode2[ParseErrorCode2["UnexpectedEndOfString"] = 12] = "UnexpectedEndOfString";
4223
+ ParseErrorCode2[ParseErrorCode2["UnexpectedEndOfNumber"] = 13] = "UnexpectedEndOfNumber";
4224
+ ParseErrorCode2[ParseErrorCode2["InvalidUnicode"] = 14] = "InvalidUnicode";
4225
+ ParseErrorCode2[ParseErrorCode2["InvalidEscapeCharacter"] = 15] = "InvalidEscapeCharacter";
4226
+ ParseErrorCode2[ParseErrorCode2["InvalidCharacter"] = 16] = "InvalidCharacter";
4227
+ })(ParseErrorCode || (ParseErrorCode = {}));
4228
+ function modify(text, path, value, options) {
4229
+ return setProperty(text, path, value, options);
4230
+ }
4231
+ function applyEdits(text, edits) {
4232
+ let sortedEdits = edits.slice(0).sort((a, b) => {
4233
+ const diff = a.offset - b.offset;
4234
+ if (diff === 0) {
4235
+ return a.length - b.length;
4236
+ }
4237
+ return diff;
4238
+ });
4239
+ let lastModifiedOffset = text.length;
4240
+ for (let i = sortedEdits.length - 1; i >= 0; i--) {
4241
+ let e = sortedEdits[i];
4242
+ if (e.offset + e.length <= lastModifiedOffset) {
4243
+ text = applyEdit(text, e);
4244
+ } else {
4245
+ throw new Error("Overlapping edit");
4246
+ }
4247
+ lastModifiedOffset = e.offset;
4248
+ }
4249
+ return text;
4250
+ }
4251
+
4252
+ // src/utils/command-local/skills-install-helpers.ts
4253
+ import {
4254
+ existsSync as existsSync2,
4255
+ lstatSync as lstatSync2,
4256
+ realpathSync,
4257
+ rmSync as rmSync2,
4258
+ statSync as statSync2,
4259
+ unlinkSync
4260
+ } from "node:fs";
4261
+ import {
4262
+ basename,
4263
+ dirname as dirname3,
4264
+ isAbsolute,
4265
+ posix,
4266
+ relative,
4267
+ resolve,
4268
+ sep,
4269
+ win32
4270
+ } from "node:path";
4271
+ var CAMUNDA_SKILLS_REPOSITORY = "camunda/skills";
4272
+ var CAMUNDA_SKILLS_URL = `https://github.com/${CAMUNDA_SKILLS_REPOSITORY}`;
4273
+ function joinForPlatform(platform2, ...paths) {
4274
+ return platform2 === "win32" ? win32.join(...paths) : posix.join(...paths);
4275
+ }
4276
+ function executableIsOnPath({
4277
+ name,
4278
+ env,
4279
+ platform: platform2
4280
+ }) {
4281
+ const pathSeparator = platform2 === "win32" ? ";" : ":";
4282
+ const directories = (env.PATH ?? "").split(pathSeparator).filter((directory) => directory.length > 0);
4283
+ const extensions = platform2 === "win32" ? (env.PATHEXT ?? ".COM;.EXE;.BAT;.CMD").split(";").filter((extension) => extension.length > 0) : [""];
4284
+ return directories.some(
4285
+ (directory) => extensions.some(
4286
+ (extension) => existsSync2(joinForPlatform(platform2, directory, `${name}${extension}`))
4287
+ )
4288
+ );
4289
+ }
4290
+
4291
+ // src/utils/command-local/mcp-install-helpers.ts
4292
+ var DOCS_URL = "https://camunda-docs.mcp.kapa.ai";
4293
+ function buildHarnesses() {
4294
+ const home = (process.platform === "win32" ? process.env.USERPROFILE : process.env.HOME) || homedir2();
4295
+ const appData = process.platform === "darwin" ? join4(home, "Library", "Application Support") : process.platform === "win32" ? process.env.APPDATA || join4(home, "AppData", "Roaming") : process.env.XDG_CONFIG_HOME || join4(home, ".config");
4296
+ const claude = process.env.CLAUDE_CONFIG_DIR || join4(home, ".claude");
4297
+ const copilot = process.env.COPILOT_HOME || join4(home, ".copilot");
4298
+ const harnesses = [
4299
+ {
4300
+ id: "claude-code",
4301
+ path: join4(process.env.CLAUDE_CONFIG_DIR || home, ".claude.json"),
4302
+ key: "mcpServers",
4303
+ directories: [claude],
4304
+ executable: "claude",
4305
+ stdioType: "stdio"
4306
+ },
4307
+ {
4308
+ id: "github-copilot",
4309
+ path: join4(copilot, "mcp-config.json"),
4310
+ key: "mcpServers",
4311
+ directories: [copilot],
4312
+ executable: "copilot",
4313
+ stdioType: "local"
4314
+ },
4315
+ {
4316
+ id: "cursor",
4317
+ path: join4(home, ".cursor", "mcp.json"),
4318
+ key: "mcpServers",
4319
+ directories: [join4(home, ".cursor"), join4(appData, "Cursor")],
4320
+ executable: "cursor",
4321
+ stdioType: "stdio"
4322
+ },
4323
+ {
4324
+ id: "vscode",
4325
+ path: join4(appData, "Code", "User", "mcp.json"),
4326
+ key: "servers",
4327
+ directories: [join4(appData, "Code")],
4328
+ executable: "code",
4329
+ stdioType: "stdio"
4330
+ }
4331
+ ];
4332
+ if (process.platform === "darwin" || process.platform === "win32") {
4333
+ harnesses.push({
4334
+ id: "claude-desktop",
4335
+ path: join4(appData, "Claude", "claude_desktop_config.json"),
4336
+ key: "mcpServers",
4337
+ directories: [join4(appData, "Claude")]
4338
+ });
4339
+ }
4340
+ return harnesses;
4341
+ }
4342
+ function detectMcpHarnesses() {
4343
+ return buildHarnesses().filter(
4344
+ (harness) => existsSync3(harness.path) || harness.directories.some((directory) => existsSync3(directory)) || harness.executable !== void 0 && executableIsOnPath({
4345
+ name: harness.executable,
4346
+ env: process.env,
4347
+ platform: process.platform
4348
+ })
4349
+ );
4350
+ }
4351
+ var HARNESS_ALIASES = {
4352
+ claude: "claude-code",
4353
+ copilot: "github-copilot",
4354
+ code: "vscode"
4355
+ };
4356
+ function resolveHarnessIds(requested) {
4357
+ return [
4358
+ ...new Set(
4359
+ requested.map((name) => {
4360
+ const id = name.trim().toLowerCase();
4361
+ return Object.hasOwn(HARNESS_ALIASES, id) ? HARNESS_ALIASES[id] : id;
4362
+ })
4363
+ )
4364
+ ];
4365
+ }
4366
+ function requireHarness(harnesses, id) {
4367
+ const harness = harnesses.find((candidate) => candidate.id === id);
4368
+ if (!harness) {
4369
+ throw new Error(
4370
+ `Unsupported MCP harness '${id}' on ${process.platform}. Choose: ${harnesses.map((candidate) => candidate.id).join(", ")}.`
4371
+ );
4372
+ }
4373
+ return harness;
4374
+ }
4375
+ function selectHarnesses(requested) {
4376
+ const harnesses = buildHarnesses();
4377
+ if (requested.length > 0) {
4378
+ return resolveHarnessIds(requested).map(
4379
+ (id) => requireHarness(harnesses, id)
4380
+ );
4381
+ }
4382
+ const detected = detectMcpHarnesses();
4383
+ if (detected.length === 0) {
4384
+ throw new Error(
4385
+ `No supported MCP harness was detected. Specify a harness: ${harnesses.map((harness) => harness.id).join(", ")}.`
4386
+ );
4387
+ }
4388
+ return detected;
4389
+ }
4390
+ function docsEntry(harness) {
4391
+ if (harness.id === "claude-desktop") {
4392
+ return process.platform === "win32" ? {
4393
+ command: "cmd.exe",
4394
+ args: ["/d", "/c", "npx", "-y", "mcp-remote", DOCS_URL]
4395
+ } : { command: "npx", args: ["-y", "mcp-remote", DOCS_URL] };
4396
+ }
4397
+ return {
4398
+ ...harness.id === "cursor" ? {} : { type: "http" },
4399
+ url: DOCS_URL
4400
+ };
4401
+ }
4402
+ function isOrchestrationEntry(entry) {
4403
+ if (!isRecord(entry) || !Array.isArray(entry.args)) return false;
4404
+ const [script, command, flag, profile] = entry.args;
4405
+ return typeof entry.command === "string" && ["node", "node.exe"].includes(basename2(entry.command)) && entry.args.length === 4 && typeof script === "string" && ["index.js", "index.ts"].includes(basename2(script)) && command === "mcp-proxy" && flag === "--profile" && typeof profile === "string" && isRecord(entry.env) && typeof entry.env.C8CTL_DATA_DIR === "string";
4406
+ }
4407
+ function updateManagedEntry({
4408
+ content,
4409
+ path,
4410
+ current,
4411
+ expected
4412
+ }) {
4413
+ const formattingOptions = {
4414
+ insertSpaces: true,
4415
+ tabSize: 2,
4416
+ eol: content.includes("\r\n") ? "\r\n" : "\n"
4417
+ };
4418
+ const edit = (keyPath, value) => {
4419
+ content = applyEdits(
4420
+ content,
4421
+ modify(content, keyPath, value, { formattingOptions })
4422
+ );
4423
+ };
4424
+ for (const [key, value] of Object.entries(expected)) {
4425
+ const currentEnv = isRecord(current.env) ? current.env : void 0;
4426
+ if (key === "env" && isRecord(value) && currentEnv) {
4427
+ for (const [envKey, envValue] of Object.entries(value)) {
4428
+ if (!isDeepStrictEqual(currentEnv[envKey], envValue)) {
4429
+ edit([...path, "env", envKey], envValue);
4430
+ }
4431
+ }
4432
+ continue;
4433
+ }
4434
+ if (!isDeepStrictEqual(current[key], value)) edit([...path, key], value);
4435
+ }
4436
+ if (Object.hasOwn(current, "type") && !Object.hasOwn(expected, "type")) {
4437
+ edit([...path, "type"], void 0);
4438
+ }
4439
+ return content;
4440
+ }
4441
+ function readOptionalFile(path) {
4442
+ try {
4443
+ return readFileSync4(path, "utf8");
4444
+ } catch (error) {
4445
+ if (isRecord(error) && error.code === "ENOENT") return void 0;
4446
+ throw error;
4447
+ }
4448
+ }
4449
+ function matchesServerConfig(current, expected) {
4450
+ return isRecord(current) && Object.entries(expected).every(
4451
+ ([key, value]) => Object.hasOwn(current, key) && (isRecord(value) ? matchesServerConfig(current[key], value) : isDeepStrictEqual(current[key], value))
4452
+ );
4453
+ }
4454
+ function planMcpConfigs({
4455
+ requested,
4456
+ operation,
4457
+ docs,
4458
+ orchestration,
4459
+ alias,
4460
+ connection,
4461
+ preserveConflicts = false,
4462
+ onError
4463
+ }) {
4464
+ const plans = [];
4465
+ const plansByTarget = /* @__PURE__ */ new Map();
4466
+ for (const harness of selectHarnesses(requested)) {
4467
+ try {
4468
+ const path = resolve2(harness.path);
4469
+ const existing = lstatSync3(path, { throwIfNoEntry: false });
4470
+ const targetPath = existing ? realpathSync2(path) : path;
4471
+ const previous = plansByTarget.get(targetPath);
4472
+ const original = previous ? previous.original : readOptionalFile(targetPath);
4473
+ let content = previous ? previous.content : original ?? "{}\n";
4474
+ const errors = [];
4475
+ const parseOptions = {
4476
+ disallowComments: harness.id !== "vscode",
4477
+ allowTrailingComma: harness.id === "vscode"
4478
+ };
4479
+ const root = parseTree2(content, errors, parseOptions);
4480
+ if (errors.length > 0 || !root || root.type !== "object") {
4481
+ throw new Error(
4482
+ `Invalid MCP config in ${path}. Repair it before continuing.`
4483
+ );
4484
+ }
4485
+ const config = parse2(content, void 0, parseOptions);
4486
+ if (!isRecord(config)) throw new Error(`Expected an object in ${path}.`);
4487
+ const servers = Object.hasOwn(config, harness.key) ? config[harness.key] : {};
4488
+ if (!isRecord(servers)) {
4489
+ throw new Error(
4490
+ `Expected '${harness.key}' to be an object in ${path}.`
4491
+ );
4492
+ }
4493
+ for (const node of [root, findNodeAtLocation2(root, [harness.key])]) {
4494
+ const keys = node?.children?.map((property) => property.children?.[0]?.value) ?? [];
4495
+ if (new Set(keys).size !== keys.length) {
4496
+ throw new Error(
4497
+ `Duplicate configuration keys in ${path}. Repair them before continuing.`
4498
+ );
4499
+ }
4500
+ }
4501
+ const entries = [];
4502
+ if (orchestration) {
4503
+ entries.push({
4504
+ name: alias,
4505
+ config: {
4506
+ ...harness.stdioType ? { type: harness.stdioType } : {},
4507
+ ...connection
4508
+ },
4509
+ docs: false
4510
+ });
4511
+ }
4512
+ if (docs)
4513
+ entries.push({
4514
+ name: "camunda-docs",
4515
+ config: docsEntry(harness),
4516
+ docs: true
4517
+ });
4518
+ const changes = entries.map((entry) => {
4519
+ const present = Object.hasOwn(servers, entry.name);
4520
+ const current = servers[entry.name];
4521
+ const matches = operation === "uninstall" && !entry.docs ? isOrchestrationEntry(current) : matchesServerConfig(current, entry.config);
4522
+ const owned = !entry.docs && isOrchestrationEntry(current);
4523
+ if (present && !matches && !(operation === "install" && owned)) {
4524
+ if (operation === "uninstall" && preserveConflicts) {
4525
+ return { server: entry.name, status: "preserved" };
4526
+ }
4527
+ throw new Error(
4528
+ `MCP entry '${entry.name}' conflicts in ${path}. Inspect it before changing it${entry.docs ? "." : ", or choose another --alias."}`
4529
+ );
4530
+ }
4531
+ const status = operation === "install" ? !present ? "installed" : matches ? "unchanged" : "updated" : present ? "removed" : "absent";
4532
+ if (status === "updated") {
4533
+ content = updateManagedEntry({
4534
+ content,
4535
+ path: [harness.key, entry.name],
4536
+ current: isRecord(current) ? current : {},
4537
+ expected: entry.config
4538
+ });
4539
+ } else if (status === "installed" || status === "removed") {
4540
+ content = applyEdits(
4541
+ content,
4542
+ modify(
4543
+ content,
4544
+ [harness.key, entry.name],
4545
+ operation === "install" ? entry.config : void 0,
4546
+ {
4547
+ formattingOptions: {
4548
+ insertSpaces: true,
4549
+ tabSize: 2,
4550
+ eol: content.includes("\r\n") ? "\r\n" : "\n"
4551
+ }
4552
+ }
4553
+ )
4554
+ );
4555
+ }
4556
+ return {
4557
+ server: entry.name,
4558
+ status,
4559
+ ...operation === "install" ? { config: entry.config } : {}
4560
+ };
4561
+ });
4562
+ const mode = previous?.mode ?? (existing ? statSync3(targetPath).mode & 384 : 384);
4563
+ const plan = {
4564
+ harness: harness.id,
4565
+ path,
4566
+ targetPath,
4567
+ original,
4568
+ content,
4569
+ mode,
4570
+ changes
4571
+ };
4572
+ const target = previous ?? {
4573
+ original,
4574
+ content,
4575
+ mode,
4576
+ plans: []
4577
+ };
4578
+ target.content = content;
4579
+ target.plans.push(plan);
4580
+ plansByTarget.set(targetPath, target);
4581
+ plans.push(plan);
4582
+ } catch (error) {
4583
+ if (!onError) throw error;
4584
+ onError(harness.id, error);
4585
+ }
4586
+ }
4587
+ for (const target of plansByTarget.values()) {
4588
+ for (const plan of target.plans) plan.content = target.content;
4589
+ }
4590
+ return plans;
4591
+ }
4592
+ function orchestrationProfile(entry) {
4593
+ if (!isOrchestrationEntry(entry) || !isRecord(entry)) return void 0;
4594
+ const args = entry.args;
4595
+ if (!Array.isArray(args)) return void 0;
4596
+ const profile = args[3];
4597
+ return typeof profile === "string" ? profile : void 0;
4598
+ }
4599
+ function listMcpEntries({
4600
+ requested
4601
+ }) {
4602
+ const harnesses = buildHarnesses();
4603
+ const selected = requested.length > 0 ? resolveHarnessIds(requested).map((id) => requireHarness(harnesses, id)) : harnesses;
4604
+ const entries = [];
4605
+ for (const harness of selected) {
4606
+ const path = resolve2(harness.path);
4607
+ let content;
4608
+ try {
4609
+ content = readOptionalFile(path);
4610
+ } catch {
4611
+ entries.push({ harness: harness.id, path, error: "read error" });
4612
+ continue;
4613
+ }
4614
+ if (content === void 0) continue;
4615
+ const errors = [];
4616
+ const config = parse2(content, errors, {
4617
+ disallowComments: harness.id !== "vscode",
4618
+ allowTrailingComma: harness.id === "vscode"
4619
+ });
4620
+ const rawServers = isRecord(config) ? config[harness.key] : void 0;
4621
+ if (errors.length > 0 || !isRecord(config)) {
4622
+ entries.push({ harness: harness.id, path, error: "parse error" });
4623
+ continue;
4624
+ }
4625
+ if (rawServers === void 0) continue;
4626
+ if (!isRecord(rawServers)) {
4627
+ entries.push({
4628
+ harness: harness.id,
4629
+ path,
4630
+ error: `'${harness.key}' is not an object`
4631
+ });
4632
+ continue;
4633
+ }
4634
+ const servers = rawServers;
4635
+ for (const [name, entry] of Object.entries(servers)) {
4636
+ const profile = orchestrationProfile(entry);
4637
+ if (profile !== void 0) {
4638
+ entries.push({
4639
+ harness: harness.id,
4640
+ path,
4641
+ server: name,
4642
+ target: "orchestration",
4643
+ profile
4644
+ });
4645
+ } else if (name === "camunda-docs" && matchesServerConfig(entry, docsEntry(harness))) {
4646
+ entries.push({
4647
+ harness: harness.id,
4648
+ path,
4649
+ server: name,
4650
+ target: "docs"
4651
+ });
4652
+ }
4653
+ }
4654
+ }
4655
+ return entries;
4656
+ }
4657
+ function acquireConfigLock(targetPath, timeoutMs, retryMs) {
4658
+ const lockPath = `${targetPath}.lock`;
4659
+ const deadline = Date.now() + timeoutMs;
4660
+ const waitSlot = new Int32Array(new SharedArrayBuffer(4));
4661
+ for (; ; ) {
4662
+ try {
4663
+ closeSync2(openSync2(lockPath, "wx", 384));
4664
+ return lockPath;
4665
+ } catch (error) {
4666
+ if (!(isRecord(error) && error.code === "EEXIST")) throw error;
4667
+ if (Date.now() >= deadline) {
4668
+ throw new Error(
4669
+ `Another c8ctl process is updating ${targetPath}. Retry shortly, or remove the stale lock ${lockPath} if that process crashed.`
4670
+ );
4671
+ }
4672
+ Atomics.wait(waitSlot, 0, 0, retryMs);
4673
+ }
4674
+ }
4675
+ }
4676
+ function writeMcpConfig(plan, options) {
4677
+ if (!plan.changes.some(
4678
+ (change) => change.status === "installed" || change.status === "updated" || change.status === "removed"
4679
+ ))
4680
+ return;
4681
+ mkdirSync2(dirname4(plan.targetPath), { recursive: true });
4682
+ const lockPath = acquireConfigLock(
4683
+ plan.targetPath,
4684
+ options?.lockTimeoutMs ?? 5e3,
4685
+ options?.lockRetryMs ?? 50
4686
+ );
4687
+ try {
4688
+ const temp = `${plan.targetPath}.${randomUUID2()}.tmp`;
4689
+ let fd;
4690
+ let created = false;
4691
+ try {
4692
+ fd = openSync2(temp, "wx", 384);
4693
+ created = true;
4694
+ writeFileSync2(fd, plan.content, "utf8");
4695
+ if (process.platform !== "win32") fchmodSync2(fd, plan.mode);
4696
+ fsyncSync(fd);
4697
+ closeSync2(fd);
4698
+ fd = void 0;
4699
+ const current = readOptionalFile(plan.targetPath);
4700
+ if (current === plan.content) return;
4701
+ if (current !== plan.original) {
4702
+ throw new Error(
4703
+ `MCP config changed during installation: ${plan.path}. Run the command again.`
4704
+ );
4705
+ }
4706
+ renameSync2(temp, plan.targetPath);
4707
+ } finally {
4708
+ if (fd !== void 0) closeSync2(fd);
4709
+ if (created) rmSync3(temp, { force: true });
4710
+ }
4711
+ } finally {
4712
+ rmSync3(lockPath, { force: true });
4713
+ }
4714
+ }
4715
+
4716
+ // default-plugins/mcp/c8ctl-plugin.ts
4717
+ var metadata = {
4718
+ name: "mcp",
4719
+ description: "Install, uninstall, or list Camunda MCP connections in AI harnesses",
4720
+ commands: {
4721
+ mcp: {
4722
+ description: "Install, uninstall, or list Camunda MCP connections in AI harnesses",
4723
+ helpDescription: `Configure user-scoped Camunda orchestration and docs MCP servers.
4724
+
4725
+ Harnesses: claude-code, github-copilot, cursor, vscode, claude-desktop (macOS/Windows).
4726
+ Omit harness names to configure all detected supported harnesses.
4727
+ Aliases: claude = claude-code, copilot = github-copilot, code = vscode.
4728
+ Targets: orchestration by default; --docs selects only docs; --docs --orchestration selects both.
4729
+ Orchestration references --profile, the active saved profile, or the default local profile; credentials are not copied.
4730
+ Docs uses camunda-docs, needs no cluster profile, and requires sign-in on first use.
4731
+ Claude Desktop docs uses npx mcp-remote; other harnesses connect over HTTP.
4732
+ VS Code's editor-managed config uses servers. For the newer Copilot harness, select github-copilot.
4733
+ On uninstall, --preserve-conflicts leaves entries that no longer match the c8ctl-managed shape untouched instead of failing.
4734
+ --dry-run previews selected entries without writing or exposing unrelated config values.
4735
+ mcp list shows c8ctl-managed entries across all supported (or named) harnesses without touching disk.`,
4736
+ subcommands: [
4737
+ {
4738
+ name: "install",
4739
+ description: "Install MCP connections for detected or named harnesses"
4740
+ },
4741
+ {
4742
+ name: "uninstall",
4743
+ description: "Remove MCP connections from detected or named harnesses"
4744
+ },
4745
+ {
4746
+ name: "list",
4747
+ description: "List c8ctl-managed MCP entries across supported harnesses"
4748
+ }
4749
+ ],
4750
+ examples: [
4751
+ {
4752
+ command: "c8ctl mcp install",
4753
+ description: "Install orchestration MCP for detected harnesses"
4754
+ },
4755
+ {
4756
+ command: "c8ctl mcp install --docs",
4757
+ description: "Install only docs MCP for detected harnesses"
4758
+ },
4759
+ {
4760
+ command: "c8ctl mcp install claude-code cursor --docs --orchestration",
4761
+ description: "Install both MCP servers for selected harnesses"
4762
+ },
4763
+ {
4764
+ command: "c8ctl mcp uninstall claude-code --docs",
4765
+ description: "Remove only the docs MCP entry"
4766
+ },
4767
+ {
4768
+ command: "c8ctl mcp list",
4769
+ description: "List c8ctl-managed MCP entries in all harnesses"
4770
+ }
4771
+ ]
4772
+ }
4773
+ }
4774
+ };
4775
+ var CLI_ENTRY = (() => {
4776
+ const dir = realpathSync3(fileURLToPath3(new URL(".", import.meta.url)));
4777
+ const candidates = [
4778
+ resolve3(dir, "..", "..", "index.js"),
4779
+ resolve3(dir, "..", "..", "src", "index.ts")
4780
+ ];
4781
+ return candidates.find((candidate) => existsSync4(candidate)) ?? candidates[0];
4782
+ })();
4783
+ function buildMcpConnection(profile) {
4784
+ if (profile === void 0 && resolveEnvBaseUrl()) {
4785
+ throw new Error(
4786
+ "MCP installation requires a saved profile. Save your environment with 'c8ctl add profile <name> --from-env', then pass --profile <name>."
4787
+ );
4788
+ }
4789
+ const name = profile ?? DEFAULT_PROFILE;
4790
+ const resolved = getProfileOrModeler(name);
4791
+ if (!resolved) {
4792
+ throw new Error(
4793
+ `Profile '${name}' not found. Run 'c8ctl list profiles' and select one with --profile.`
4794
+ );
4795
+ }
4796
+ const entry = {
4797
+ command: process.execPath,
4798
+ args: [CLI_ENTRY, "mcp-proxy", "--profile", resolved.name],
4799
+ env: {
4800
+ C8CTL_DATA_DIR: resolve3(getUserDataDir()),
4801
+ ...resolved.name.startsWith("modeler:") ? { C8CTL_MODELER_DIR: resolve3(getModelerDataDir()) } : {}
4802
+ }
4803
+ };
4804
+ if ([entry.command, ...entry.args, ...Object.values(entry.env)].some(
4805
+ (value) => value.includes("${")
4806
+ )) {
4807
+ throw new Error(
4808
+ `MCP harnesses expand \${...} placeholders. Use a profile name and Node.js, c8ctl, and data-directory paths without that syntax.`
4809
+ );
4810
+ }
4811
+ return entry;
4812
+ }
4813
+ function targets({
4814
+ docs,
4815
+ orchestration,
4816
+ alias,
4817
+ aliasProvided
4818
+ }) {
4819
+ const selectedDocs = docs;
4820
+ const selectedOrchestration = orchestration || !docs;
4821
+ if (aliasProvided && !selectedOrchestration) {
4822
+ throw new Error(
4823
+ "--alias applies to orchestration. Add --orchestration or omit --alias."
4824
+ );
4825
+ }
4826
+ if (!/^[a-zA-Z0-9][a-zA-Z0-9_-]*$/.test(alias) || alias === "camunda-docs") {
4827
+ throw new Error(
4828
+ "Use an orchestration alias containing letters, digits, underscores or hyphens, starting with a letter or digit. 'camunda-docs' is reserved."
4829
+ );
4830
+ }
4831
+ return { docs: selectedDocs, orchestration: selectedOrchestration, alias };
4832
+ }
4833
+ function applyPlans({
4834
+ ctx,
4835
+ plans,
4836
+ operation
4837
+ }) {
4838
+ const { logger } = ctx;
4839
+ if (ctx.dryRun) {
4840
+ logger.json({
4841
+ dryRun: true,
4842
+ command: `mcp ${operation}`,
4843
+ changes: plans.flatMap(
4844
+ (plan) => plan.changes.map((change) => ({
4845
+ harness: plan.harness,
4846
+ path: plan.path,
4847
+ ...change
4848
+ }))
4849
+ )
4850
+ });
4851
+ return;
4852
+ }
4853
+ for (const plan of plans) {
4854
+ writeMcpConfig(plan);
4855
+ logger.info(`MCP configuration: ${plan.harness} (${plan.path})`);
4856
+ }
4857
+ if (operation === "install") {
4858
+ logger.info("Restart or reload the selected harnesses to activate MCP.");
4859
+ if (plans.some(
4860
+ (plan) => plan.changes.some((change) => change.server === "camunda-docs")
4861
+ )) {
4862
+ logger.info("The docs server requires sign-in on first use.");
4863
+ }
4864
+ }
4865
+ const items = plans.flatMap(
4866
+ (plan) => plan.changes.map(({ server, status }) => ({
4867
+ harness: plan.harness,
4868
+ server,
4869
+ status,
4870
+ path: plan.path
4871
+ }))
4872
+ );
4873
+ if (items.length > 0) {
4874
+ logger.table(items);
4875
+ } else {
4876
+ logger.info("No MCP entries selected.", { essential: true });
4877
+ }
4878
+ }
4879
+ async function mcpHandler(args, flags, ctx) {
4880
+ if (!ctx) throw new Error("mcp requires the plugin host context");
4881
+ const { logger } = ctx;
4882
+ const operation = args[0];
4883
+ if (operation !== "install" && operation !== "uninstall" && operation !== "list") {
4884
+ if (operation === void 0) {
4885
+ logger.info(
4886
+ "\nUsage: c8ctl mcp install|uninstall|list [harness...]\n\nAvailable resources:\n install\n uninstall\n list",
4887
+ { essential: true }
4888
+ );
4889
+ } else {
4890
+ logger.error(`Unknown command: mcp ${args.join(" ")}`);
4891
+ logger.info('Run "c8 help" for usage information', { essential: true });
4892
+ }
4893
+ process.exitCode = 1;
4894
+ return;
4895
+ }
4896
+ try {
4897
+ if (operation === "list") {
4898
+ const installOnly = [
4899
+ "docs",
4900
+ "orchestration",
4901
+ "alias",
4902
+ "preserve-conflicts"
4903
+ ].filter((name) => flags?.[name] !== void 0);
4904
+ if (installOnly.length > 0) {
4905
+ throw new Error(
4906
+ `mcp list takes no ${installOnly.map((name) => `--${name}`).join(", ")} flag. It always lists every c8ctl-managed entry.`
4907
+ );
4908
+ }
4909
+ const items = listMcpEntries({ requested: args.slice(1) });
4910
+ if (items.length === 0) {
4911
+ logger.info(
4912
+ "No c8ctl-managed MCP entries found. Run 'c8ctl mcp install' to add one.",
4913
+ { essential: true }
4914
+ );
4915
+ }
4916
+ logger.table(items);
4917
+ return;
4918
+ }
4919
+ const rawAlias = flags?.alias;
4920
+ if (rawAlias !== void 0 && (typeof rawAlias !== "string" || rawAlias === "")) {
4921
+ logger.error("Invalid --alias: value must not be empty");
4922
+ process.exitCode = 1;
4923
+ return;
4924
+ }
4925
+ const selected = targets({
4926
+ docs: flags?.docs === true,
4927
+ orchestration: flags?.orchestration === true,
4928
+ alias: rawAlias ?? "camunda",
4929
+ aliasProvided: rawAlias !== void 0
4930
+ });
4931
+ const plans = planMcpConfigs({
4932
+ requested: args.slice(1),
4933
+ operation,
4934
+ ...selected,
4935
+ preserveConflicts: flags?.["preserve-conflicts"] === true,
4936
+ connection: operation === "install" && selected.orchestration ? buildMcpConnection(ctx.profile) : void 0
4937
+ });
4938
+ applyPlans({ ctx, plans, operation });
4939
+ } catch (error) {
4940
+ renderCommandFailure(logger, `Failed to mcp ${operation}`, error, {
4941
+ verbose: ctx.verbose
4942
+ });
4943
+ process.exitCode = 1;
4944
+ }
4945
+ }
4946
+ var commands = {
4947
+ mcp: {
4948
+ flags: {
4949
+ orchestration: {
4950
+ type: "boolean",
4951
+ description: "Select the orchestration MCP server (default when --docs is absent)"
4952
+ },
4953
+ docs: {
4954
+ type: "boolean",
4955
+ description: "Select the Camunda docs MCP server; combine with --orchestration for both"
4956
+ },
4957
+ alias: {
4958
+ type: "string",
4959
+ rejectEmpty: true,
4960
+ description: "Orchestration server entry name (default: camunda)"
4961
+ },
4962
+ "preserve-conflicts": {
4963
+ type: "boolean",
4964
+ description: "On uninstall, leave conflicting foreign entries untouched instead of failing"
4965
+ }
4966
+ },
4967
+ handler: mcpHandler
4968
+ }
4969
+ };
4970
+ export {
4971
+ commands,
4972
+ metadata
4973
+ };