@assistant-ui/metro 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,2189 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ //#region \0rolldown/runtime.js
3
+ var __create = Object.create;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
12
+ key = keys[i];
13
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
14
+ get: ((k) => from[k]).bind(null, key),
15
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
16
+ });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
21
+ value: mod,
22
+ enumerable: true
23
+ }) : target, mod));
24
+ //#endregion
25
+ const require_index = require("./index.cjs");
26
+ let node_module = require("node:module");
27
+ let node_fs = require("node:fs");
28
+ let node_url = require("node:url");
29
+ let node_path = require("node:path");
30
+ node_path = __toESM(node_path, 1);
31
+ let _babel_parser = require("@babel/parser");
32
+ let _babel_traverse = require("@babel/traverse");
33
+ _babel_traverse = __toESM(_babel_traverse, 1);
34
+ let _babel_generator = require("@babel/generator");
35
+ _babel_generator = __toESM(_babel_generator, 1);
36
+ let _babel_types = require("@babel/types");
37
+ _babel_types = __toESM(_babel_types, 1);
38
+ //#region ../x-generative-compiler/dist/constants.js
39
+ /** The directive a module uses to opt into generative compilation. */
40
+ const DIRECTIVE = "use generative";
41
+ //#endregion
42
+ //#region ../x-generative-compiler/dist/package.js
43
+ var version = "0.0.3";
44
+ //#endregion
45
+ //#region ../../node_modules/.pnpm/semver@7.8.1/node_modules/semver/internal/constants.js
46
+ var require_constants = /* @__PURE__ */ __commonJSMin(((exports, module) => {
47
+ const SEMVER_SPEC_VERSION = "2.0.0";
48
+ const MAX_LENGTH = 256;
49
+ const MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || 9007199254740991;
50
+ module.exports = {
51
+ MAX_LENGTH,
52
+ MAX_SAFE_COMPONENT_LENGTH: 16,
53
+ MAX_SAFE_BUILD_LENGTH: MAX_LENGTH - 6,
54
+ MAX_SAFE_INTEGER,
55
+ RELEASE_TYPES: [
56
+ "major",
57
+ "premajor",
58
+ "minor",
59
+ "preminor",
60
+ "patch",
61
+ "prepatch",
62
+ "prerelease"
63
+ ],
64
+ SEMVER_SPEC_VERSION,
65
+ FLAG_INCLUDE_PRERELEASE: 1,
66
+ FLAG_LOOSE: 2
67
+ };
68
+ }));
69
+ //#endregion
70
+ //#region ../../node_modules/.pnpm/semver@7.8.1/node_modules/semver/internal/debug.js
71
+ var require_debug = /* @__PURE__ */ __commonJSMin(((exports, module) => {
72
+ module.exports = typeof process === "object" && process.env && process.env.NODE_DEBUG && /\bsemver\b/i.test(process.env.NODE_DEBUG) ? (...args) => console.error("SEMVER", ...args) : () => {};
73
+ }));
74
+ //#endregion
75
+ //#region ../../node_modules/.pnpm/semver@7.8.1/node_modules/semver/internal/re.js
76
+ var require_re = /* @__PURE__ */ __commonJSMin(((exports, module) => {
77
+ const { MAX_SAFE_COMPONENT_LENGTH, MAX_SAFE_BUILD_LENGTH, MAX_LENGTH } = require_constants();
78
+ const debug = require_debug();
79
+ exports = module.exports = {};
80
+ const re = exports.re = [];
81
+ const safeRe = exports.safeRe = [];
82
+ const src = exports.src = [];
83
+ const safeSrc = exports.safeSrc = [];
84
+ const t = exports.t = {};
85
+ let R = 0;
86
+ const LETTERDASHNUMBER = "[a-zA-Z0-9-]";
87
+ const safeRegexReplacements = [
88
+ ["\\s", 1],
89
+ ["\\d", MAX_LENGTH],
90
+ [LETTERDASHNUMBER, MAX_SAFE_BUILD_LENGTH]
91
+ ];
92
+ const makeSafeRegex = (value) => {
93
+ for (const [token, max] of safeRegexReplacements) value = value.split(`${token}*`).join(`${token}{0,${max}}`).split(`${token}+`).join(`${token}{1,${max}}`);
94
+ return value;
95
+ };
96
+ const createToken = (name, value, isGlobal) => {
97
+ const safe = makeSafeRegex(value);
98
+ const index = R++;
99
+ debug(name, index, value);
100
+ t[name] = index;
101
+ src[index] = value;
102
+ safeSrc[index] = safe;
103
+ re[index] = new RegExp(value, isGlobal ? "g" : void 0);
104
+ safeRe[index] = new RegExp(safe, isGlobal ? "g" : void 0);
105
+ };
106
+ createToken("NUMERICIDENTIFIER", "0|[1-9]\\d*");
107
+ createToken("NUMERICIDENTIFIERLOOSE", "\\d+");
108
+ createToken("NONNUMERICIDENTIFIER", `\\d*[a-zA-Z-]${LETTERDASHNUMBER}*`);
109
+ createToken("MAINVERSION", `(${src[t.NUMERICIDENTIFIER]})\\.(${src[t.NUMERICIDENTIFIER]})\\.(${src[t.NUMERICIDENTIFIER]})`);
110
+ createToken("MAINVERSIONLOOSE", `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.(${src[t.NUMERICIDENTIFIERLOOSE]})\\.(${src[t.NUMERICIDENTIFIERLOOSE]})`);
111
+ createToken("PRERELEASEIDENTIFIER", `(?:${src[t.NONNUMERICIDENTIFIER]}|${src[t.NUMERICIDENTIFIER]})`);
112
+ createToken("PRERELEASEIDENTIFIERLOOSE", `(?:${src[t.NONNUMERICIDENTIFIER]}|${src[t.NUMERICIDENTIFIERLOOSE]})`);
113
+ createToken("PRERELEASE", `(?:-(${src[t.PRERELEASEIDENTIFIER]}(?:\\.${src[t.PRERELEASEIDENTIFIER]})*))`);
114
+ createToken("PRERELEASELOOSE", `(?:-?(${src[t.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${src[t.PRERELEASEIDENTIFIERLOOSE]})*))`);
115
+ createToken("BUILDIDENTIFIER", `${LETTERDASHNUMBER}+`);
116
+ createToken("BUILD", `(?:\\+(${src[t.BUILDIDENTIFIER]}(?:\\.${src[t.BUILDIDENTIFIER]})*))`);
117
+ createToken("FULLPLAIN", `v?${src[t.MAINVERSION]}${src[t.PRERELEASE]}?${src[t.BUILD]}?`);
118
+ createToken("FULL", `^${src[t.FULLPLAIN]}$`);
119
+ createToken("LOOSEPLAIN", `[v=\\s]*${src[t.MAINVERSIONLOOSE]}${src[t.PRERELEASELOOSE]}?${src[t.BUILD]}?`);
120
+ createToken("LOOSE", `^${src[t.LOOSEPLAIN]}$`);
121
+ createToken("GTLT", "((?:<|>)?=?)");
122
+ createToken("XRANGEIDENTIFIERLOOSE", `${src[t.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`);
123
+ createToken("XRANGEIDENTIFIER", `${src[t.NUMERICIDENTIFIER]}|x|X|\\*`);
124
+ createToken("XRANGEPLAIN", `[v=\\s]*(${src[t.XRANGEIDENTIFIER]})(?:\\.(${src[t.XRANGEIDENTIFIER]})(?:\\.(${src[t.XRANGEIDENTIFIER]})(?:${src[t.PRERELEASE]})?${src[t.BUILD]}?)?)?`);
125
+ createToken("XRANGEPLAINLOOSE", `[v=\\s]*(${src[t.XRANGEIDENTIFIERLOOSE]})(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})(?:${src[t.PRERELEASELOOSE]})?${src[t.BUILD]}?)?)?`);
126
+ createToken("XRANGE", `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAIN]}$`);
127
+ createToken("XRANGELOOSE", `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAINLOOSE]}$`);
128
+ createToken("COERCEPLAIN", `(^|[^\\d])(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}})(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?`);
129
+ createToken("COERCE", `${src[t.COERCEPLAIN]}(?:$|[^\\d])`);
130
+ createToken("COERCEFULL", src[t.COERCEPLAIN] + `(?:${src[t.PRERELEASE]})?(?:${src[t.BUILD]})?(?:$|[^\\d])`);
131
+ createToken("COERCERTL", src[t.COERCE], true);
132
+ createToken("COERCERTLFULL", src[t.COERCEFULL], true);
133
+ createToken("LONETILDE", "(?:~>?)");
134
+ createToken("TILDETRIM", `(\\s*)${src[t.LONETILDE]}\\s+`, true);
135
+ exports.tildeTrimReplace = "$1~";
136
+ createToken("TILDE", `^${src[t.LONETILDE]}${src[t.XRANGEPLAIN]}$`);
137
+ createToken("TILDELOOSE", `^${src[t.LONETILDE]}${src[t.XRANGEPLAINLOOSE]}$`);
138
+ createToken("LONECARET", "(?:\\^)");
139
+ createToken("CARETTRIM", `(\\s*)${src[t.LONECARET]}\\s+`, true);
140
+ exports.caretTrimReplace = "$1^";
141
+ createToken("CARET", `^${src[t.LONECARET]}${src[t.XRANGEPLAIN]}$`);
142
+ createToken("CARETLOOSE", `^${src[t.LONECARET]}${src[t.XRANGEPLAINLOOSE]}$`);
143
+ createToken("COMPARATORLOOSE", `^${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]})$|^$`);
144
+ createToken("COMPARATOR", `^${src[t.GTLT]}\\s*(${src[t.FULLPLAIN]})$|^$`);
145
+ createToken("COMPARATORTRIM", `(\\s*)${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]}|${src[t.XRANGEPLAIN]})`, true);
146
+ exports.comparatorTrimReplace = "$1$2$3";
147
+ createToken("HYPHENRANGE", `^\\s*(${src[t.XRANGEPLAIN]})\\s+-\\s+(${src[t.XRANGEPLAIN]})\\s*$`);
148
+ createToken("HYPHENRANGELOOSE", `^\\s*(${src[t.XRANGEPLAINLOOSE]})\\s+-\\s+(${src[t.XRANGEPLAINLOOSE]})\\s*$`);
149
+ createToken("STAR", "(<|>)?=?\\s*\\*");
150
+ createToken("GTE0", "^\\s*>=\\s*0\\.0\\.0\\s*$");
151
+ createToken("GTE0PRE", "^\\s*>=\\s*0\\.0\\.0-0\\s*$");
152
+ }));
153
+ //#endregion
154
+ //#region ../../node_modules/.pnpm/semver@7.8.1/node_modules/semver/internal/parse-options.js
155
+ var require_parse_options = /* @__PURE__ */ __commonJSMin(((exports, module) => {
156
+ const looseOption = Object.freeze({ loose: true });
157
+ const emptyOpts = Object.freeze({});
158
+ const parseOptions = (options) => {
159
+ if (!options) return emptyOpts;
160
+ if (typeof options !== "object") return looseOption;
161
+ return options;
162
+ };
163
+ module.exports = parseOptions;
164
+ }));
165
+ //#endregion
166
+ //#region ../../node_modules/.pnpm/semver@7.8.1/node_modules/semver/internal/identifiers.js
167
+ var require_identifiers = /* @__PURE__ */ __commonJSMin(((exports, module) => {
168
+ const numeric = /^[0-9]+$/;
169
+ const compareIdentifiers = (a, b) => {
170
+ if (typeof a === "number" && typeof b === "number") return a === b ? 0 : a < b ? -1 : 1;
171
+ const anum = numeric.test(a);
172
+ const bnum = numeric.test(b);
173
+ if (anum && bnum) {
174
+ a = +a;
175
+ b = +b;
176
+ }
177
+ return a === b ? 0 : anum && !bnum ? -1 : bnum && !anum ? 1 : a < b ? -1 : 1;
178
+ };
179
+ const rcompareIdentifiers = (a, b) => compareIdentifiers(b, a);
180
+ module.exports = {
181
+ compareIdentifiers,
182
+ rcompareIdentifiers
183
+ };
184
+ }));
185
+ //#endregion
186
+ //#region ../../node_modules/.pnpm/semver@7.8.1/node_modules/semver/classes/semver.js
187
+ var require_semver$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
188
+ const debug = require_debug();
189
+ const { MAX_LENGTH, MAX_SAFE_INTEGER } = require_constants();
190
+ const { safeRe: re, t } = require_re();
191
+ const parseOptions = require_parse_options();
192
+ const { compareIdentifiers } = require_identifiers();
193
+ module.exports = class SemVer {
194
+ constructor(version, options) {
195
+ options = parseOptions(options);
196
+ if (version instanceof SemVer) if (version.loose === !!options.loose && version.includePrerelease === !!options.includePrerelease) return version;
197
+ else version = version.version;
198
+ else if (typeof version !== "string") throw new TypeError(`Invalid version. Must be a string. Got type "${typeof version}".`);
199
+ if (version.length > MAX_LENGTH) throw new TypeError(`version is longer than ${MAX_LENGTH} characters`);
200
+ debug("SemVer", version, options);
201
+ this.options = options;
202
+ this.loose = !!options.loose;
203
+ this.includePrerelease = !!options.includePrerelease;
204
+ const m = version.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL]);
205
+ if (!m) throw new TypeError(`Invalid Version: ${version}`);
206
+ this.raw = version;
207
+ this.major = +m[1];
208
+ this.minor = +m[2];
209
+ this.patch = +m[3];
210
+ if (this.major > MAX_SAFE_INTEGER || this.major < 0) throw new TypeError("Invalid major version");
211
+ if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) throw new TypeError("Invalid minor version");
212
+ if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) throw new TypeError("Invalid patch version");
213
+ if (!m[4]) this.prerelease = [];
214
+ else this.prerelease = m[4].split(".").map((id) => {
215
+ if (/^[0-9]+$/.test(id)) {
216
+ const num = +id;
217
+ if (num >= 0 && num < MAX_SAFE_INTEGER) return num;
218
+ }
219
+ return id;
220
+ });
221
+ this.build = m[5] ? m[5].split(".") : [];
222
+ this.format();
223
+ }
224
+ format() {
225
+ this.version = `${this.major}.${this.minor}.${this.patch}`;
226
+ if (this.prerelease.length) this.version += `-${this.prerelease.join(".")}`;
227
+ return this.version;
228
+ }
229
+ toString() {
230
+ return this.version;
231
+ }
232
+ compare(other) {
233
+ debug("SemVer.compare", this.version, this.options, other);
234
+ if (!(other instanceof SemVer)) {
235
+ if (typeof other === "string" && other === this.version) return 0;
236
+ other = new SemVer(other, this.options);
237
+ }
238
+ if (other.version === this.version) return 0;
239
+ return this.compareMain(other) || this.comparePre(other);
240
+ }
241
+ compareMain(other) {
242
+ if (!(other instanceof SemVer)) other = new SemVer(other, this.options);
243
+ if (this.major < other.major) return -1;
244
+ if (this.major > other.major) return 1;
245
+ if (this.minor < other.minor) return -1;
246
+ if (this.minor > other.minor) return 1;
247
+ if (this.patch < other.patch) return -1;
248
+ if (this.patch > other.patch) return 1;
249
+ return 0;
250
+ }
251
+ comparePre(other) {
252
+ if (!(other instanceof SemVer)) other = new SemVer(other, this.options);
253
+ if (this.prerelease.length && !other.prerelease.length) return -1;
254
+ else if (!this.prerelease.length && other.prerelease.length) return 1;
255
+ else if (!this.prerelease.length && !other.prerelease.length) return 0;
256
+ let i = 0;
257
+ do {
258
+ const a = this.prerelease[i];
259
+ const b = other.prerelease[i];
260
+ debug("prerelease compare", i, a, b);
261
+ if (a === void 0 && b === void 0) return 0;
262
+ else if (b === void 0) return 1;
263
+ else if (a === void 0) return -1;
264
+ else if (a === b) continue;
265
+ else return compareIdentifiers(a, b);
266
+ } while (++i);
267
+ }
268
+ compareBuild(other) {
269
+ if (!(other instanceof SemVer)) other = new SemVer(other, this.options);
270
+ let i = 0;
271
+ do {
272
+ const a = this.build[i];
273
+ const b = other.build[i];
274
+ debug("build compare", i, a, b);
275
+ if (a === void 0 && b === void 0) return 0;
276
+ else if (b === void 0) return 1;
277
+ else if (a === void 0) return -1;
278
+ else if (a === b) continue;
279
+ else return compareIdentifiers(a, b);
280
+ } while (++i);
281
+ }
282
+ inc(release, identifier, identifierBase) {
283
+ if (release.startsWith("pre")) {
284
+ if (!identifier && identifierBase === false) throw new Error("invalid increment argument: identifier is empty");
285
+ if (identifier) {
286
+ const match = `-${identifier}`.match(this.options.loose ? re[t.PRERELEASELOOSE] : re[t.PRERELEASE]);
287
+ if (!match || match[1] !== identifier) throw new Error(`invalid identifier: ${identifier}`);
288
+ }
289
+ }
290
+ switch (release) {
291
+ case "premajor":
292
+ this.prerelease.length = 0;
293
+ this.patch = 0;
294
+ this.minor = 0;
295
+ this.major++;
296
+ this.inc("pre", identifier, identifierBase);
297
+ break;
298
+ case "preminor":
299
+ this.prerelease.length = 0;
300
+ this.patch = 0;
301
+ this.minor++;
302
+ this.inc("pre", identifier, identifierBase);
303
+ break;
304
+ case "prepatch":
305
+ this.prerelease.length = 0;
306
+ this.inc("patch", identifier, identifierBase);
307
+ this.inc("pre", identifier, identifierBase);
308
+ break;
309
+ case "prerelease":
310
+ if (this.prerelease.length === 0) this.inc("patch", identifier, identifierBase);
311
+ this.inc("pre", identifier, identifierBase);
312
+ break;
313
+ case "release":
314
+ if (this.prerelease.length === 0) throw new Error(`version ${this.raw} is not a prerelease`);
315
+ this.prerelease.length = 0;
316
+ break;
317
+ case "major":
318
+ if (this.minor !== 0 || this.patch !== 0 || this.prerelease.length === 0) this.major++;
319
+ this.minor = 0;
320
+ this.patch = 0;
321
+ this.prerelease = [];
322
+ break;
323
+ case "minor":
324
+ if (this.patch !== 0 || this.prerelease.length === 0) this.minor++;
325
+ this.patch = 0;
326
+ this.prerelease = [];
327
+ break;
328
+ case "patch":
329
+ if (this.prerelease.length === 0) this.patch++;
330
+ this.prerelease = [];
331
+ break;
332
+ case "pre": {
333
+ const base = Number(identifierBase) ? 1 : 0;
334
+ if (this.prerelease.length === 0) this.prerelease = [base];
335
+ else {
336
+ let i = this.prerelease.length;
337
+ while (--i >= 0) if (typeof this.prerelease[i] === "number") {
338
+ this.prerelease[i]++;
339
+ i = -2;
340
+ }
341
+ if (i === -1) {
342
+ if (identifier === this.prerelease.join(".") && identifierBase === false) throw new Error("invalid increment argument: identifier already exists");
343
+ this.prerelease.push(base);
344
+ }
345
+ }
346
+ if (identifier) {
347
+ let prerelease = [identifier, base];
348
+ if (identifierBase === false) prerelease = [identifier];
349
+ if (compareIdentifiers(this.prerelease[0], identifier) === 0) {
350
+ if (isNaN(this.prerelease[1])) this.prerelease = prerelease;
351
+ } else this.prerelease = prerelease;
352
+ }
353
+ break;
354
+ }
355
+ default: throw new Error(`invalid increment argument: ${release}`);
356
+ }
357
+ this.raw = this.format();
358
+ if (this.build.length) this.raw += `+${this.build.join(".")}`;
359
+ return this;
360
+ }
361
+ };
362
+ }));
363
+ //#endregion
364
+ //#region ../../node_modules/.pnpm/semver@7.8.1/node_modules/semver/functions/parse.js
365
+ var require_parse = /* @__PURE__ */ __commonJSMin(((exports, module) => {
366
+ const SemVer = require_semver$1();
367
+ const parse = (version, options, throwErrors = false) => {
368
+ if (version instanceof SemVer) return version;
369
+ try {
370
+ return new SemVer(version, options);
371
+ } catch (er) {
372
+ if (!throwErrors) return null;
373
+ throw er;
374
+ }
375
+ };
376
+ module.exports = parse;
377
+ }));
378
+ //#endregion
379
+ //#region ../../node_modules/.pnpm/semver@7.8.1/node_modules/semver/functions/valid.js
380
+ var require_valid$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
381
+ const parse = require_parse();
382
+ const valid = (version, options) => {
383
+ const v = parse(version, options);
384
+ return v ? v.version : null;
385
+ };
386
+ module.exports = valid;
387
+ }));
388
+ //#endregion
389
+ //#region ../../node_modules/.pnpm/semver@7.8.1/node_modules/semver/functions/clean.js
390
+ var require_clean = /* @__PURE__ */ __commonJSMin(((exports, module) => {
391
+ const parse = require_parse();
392
+ const clean = (version, options) => {
393
+ const s = parse(version.trim().replace(/^[=v]+/, ""), options);
394
+ return s ? s.version : null;
395
+ };
396
+ module.exports = clean;
397
+ }));
398
+ //#endregion
399
+ //#region ../../node_modules/.pnpm/semver@7.8.1/node_modules/semver/functions/inc.js
400
+ var require_inc = /* @__PURE__ */ __commonJSMin(((exports, module) => {
401
+ const SemVer = require_semver$1();
402
+ const inc = (version, release, options, identifier, identifierBase) => {
403
+ if (typeof options === "string") {
404
+ identifierBase = identifier;
405
+ identifier = options;
406
+ options = void 0;
407
+ }
408
+ try {
409
+ return new SemVer(version instanceof SemVer ? version.version : version, options).inc(release, identifier, identifierBase).version;
410
+ } catch (er) {
411
+ return null;
412
+ }
413
+ };
414
+ module.exports = inc;
415
+ }));
416
+ //#endregion
417
+ //#region ../../node_modules/.pnpm/semver@7.8.1/node_modules/semver/functions/diff.js
418
+ var require_diff = /* @__PURE__ */ __commonJSMin(((exports, module) => {
419
+ const parse = require_parse();
420
+ const diff = (version1, version2) => {
421
+ const v1 = parse(version1, null, true);
422
+ const v2 = parse(version2, null, true);
423
+ const comparison = v1.compare(v2);
424
+ if (comparison === 0) return null;
425
+ const v1Higher = comparison > 0;
426
+ const highVersion = v1Higher ? v1 : v2;
427
+ const lowVersion = v1Higher ? v2 : v1;
428
+ const highHasPre = !!highVersion.prerelease.length;
429
+ if (!!lowVersion.prerelease.length && !highHasPre) {
430
+ if (!lowVersion.patch && !lowVersion.minor) return "major";
431
+ if (lowVersion.compareMain(highVersion) === 0) {
432
+ if (lowVersion.minor && !lowVersion.patch) return "minor";
433
+ return "patch";
434
+ }
435
+ }
436
+ const prefix = highHasPre ? "pre" : "";
437
+ if (v1.major !== v2.major) return prefix + "major";
438
+ if (v1.minor !== v2.minor) return prefix + "minor";
439
+ if (v1.patch !== v2.patch) return prefix + "patch";
440
+ return "prerelease";
441
+ };
442
+ module.exports = diff;
443
+ }));
444
+ //#endregion
445
+ //#region ../../node_modules/.pnpm/semver@7.8.1/node_modules/semver/functions/major.js
446
+ var require_major = /* @__PURE__ */ __commonJSMin(((exports, module) => {
447
+ const SemVer = require_semver$1();
448
+ const major = (a, loose) => new SemVer(a, loose).major;
449
+ module.exports = major;
450
+ }));
451
+ //#endregion
452
+ //#region ../../node_modules/.pnpm/semver@7.8.1/node_modules/semver/functions/minor.js
453
+ var require_minor = /* @__PURE__ */ __commonJSMin(((exports, module) => {
454
+ const SemVer = require_semver$1();
455
+ const minor = (a, loose) => new SemVer(a, loose).minor;
456
+ module.exports = minor;
457
+ }));
458
+ //#endregion
459
+ //#region ../../node_modules/.pnpm/semver@7.8.1/node_modules/semver/functions/patch.js
460
+ var require_patch = /* @__PURE__ */ __commonJSMin(((exports, module) => {
461
+ const SemVer = require_semver$1();
462
+ const patch = (a, loose) => new SemVer(a, loose).patch;
463
+ module.exports = patch;
464
+ }));
465
+ //#endregion
466
+ //#region ../../node_modules/.pnpm/semver@7.8.1/node_modules/semver/functions/prerelease.js
467
+ var require_prerelease = /* @__PURE__ */ __commonJSMin(((exports, module) => {
468
+ const parse = require_parse();
469
+ const prerelease = (version, options) => {
470
+ const parsed = parse(version, options);
471
+ return parsed && parsed.prerelease.length ? parsed.prerelease : null;
472
+ };
473
+ module.exports = prerelease;
474
+ }));
475
+ //#endregion
476
+ //#region ../../node_modules/.pnpm/semver@7.8.1/node_modules/semver/functions/compare.js
477
+ var require_compare = /* @__PURE__ */ __commonJSMin(((exports, module) => {
478
+ const SemVer = require_semver$1();
479
+ const compare = (a, b, loose) => new SemVer(a, loose).compare(new SemVer(b, loose));
480
+ module.exports = compare;
481
+ }));
482
+ //#endregion
483
+ //#region ../../node_modules/.pnpm/semver@7.8.1/node_modules/semver/functions/rcompare.js
484
+ var require_rcompare = /* @__PURE__ */ __commonJSMin(((exports, module) => {
485
+ const compare = require_compare();
486
+ const rcompare = (a, b, loose) => compare(b, a, loose);
487
+ module.exports = rcompare;
488
+ }));
489
+ //#endregion
490
+ //#region ../../node_modules/.pnpm/semver@7.8.1/node_modules/semver/functions/compare-loose.js
491
+ var require_compare_loose = /* @__PURE__ */ __commonJSMin(((exports, module) => {
492
+ const compare = require_compare();
493
+ const compareLoose = (a, b) => compare(a, b, true);
494
+ module.exports = compareLoose;
495
+ }));
496
+ //#endregion
497
+ //#region ../../node_modules/.pnpm/semver@7.8.1/node_modules/semver/functions/compare-build.js
498
+ var require_compare_build = /* @__PURE__ */ __commonJSMin(((exports, module) => {
499
+ const SemVer = require_semver$1();
500
+ const compareBuild = (a, b, loose) => {
501
+ const versionA = new SemVer(a, loose);
502
+ const versionB = new SemVer(b, loose);
503
+ return versionA.compare(versionB) || versionA.compareBuild(versionB);
504
+ };
505
+ module.exports = compareBuild;
506
+ }));
507
+ //#endregion
508
+ //#region ../../node_modules/.pnpm/semver@7.8.1/node_modules/semver/functions/sort.js
509
+ var require_sort = /* @__PURE__ */ __commonJSMin(((exports, module) => {
510
+ const compareBuild = require_compare_build();
511
+ const sort = (list, loose) => list.sort((a, b) => compareBuild(a, b, loose));
512
+ module.exports = sort;
513
+ }));
514
+ //#endregion
515
+ //#region ../../node_modules/.pnpm/semver@7.8.1/node_modules/semver/functions/rsort.js
516
+ var require_rsort = /* @__PURE__ */ __commonJSMin(((exports, module) => {
517
+ const compareBuild = require_compare_build();
518
+ const rsort = (list, loose) => list.sort((a, b) => compareBuild(b, a, loose));
519
+ module.exports = rsort;
520
+ }));
521
+ //#endregion
522
+ //#region ../../node_modules/.pnpm/semver@7.8.1/node_modules/semver/functions/gt.js
523
+ var require_gt = /* @__PURE__ */ __commonJSMin(((exports, module) => {
524
+ const compare = require_compare();
525
+ const gt = (a, b, loose) => compare(a, b, loose) > 0;
526
+ module.exports = gt;
527
+ }));
528
+ //#endregion
529
+ //#region ../../node_modules/.pnpm/semver@7.8.1/node_modules/semver/functions/lt.js
530
+ var require_lt = /* @__PURE__ */ __commonJSMin(((exports, module) => {
531
+ const compare = require_compare();
532
+ const lt = (a, b, loose) => compare(a, b, loose) < 0;
533
+ module.exports = lt;
534
+ }));
535
+ //#endregion
536
+ //#region ../../node_modules/.pnpm/semver@7.8.1/node_modules/semver/functions/eq.js
537
+ var require_eq = /* @__PURE__ */ __commonJSMin(((exports, module) => {
538
+ const compare = require_compare();
539
+ const eq = (a, b, loose) => compare(a, b, loose) === 0;
540
+ module.exports = eq;
541
+ }));
542
+ //#endregion
543
+ //#region ../../node_modules/.pnpm/semver@7.8.1/node_modules/semver/functions/neq.js
544
+ var require_neq = /* @__PURE__ */ __commonJSMin(((exports, module) => {
545
+ const compare = require_compare();
546
+ const neq = (a, b, loose) => compare(a, b, loose) !== 0;
547
+ module.exports = neq;
548
+ }));
549
+ //#endregion
550
+ //#region ../../node_modules/.pnpm/semver@7.8.1/node_modules/semver/functions/gte.js
551
+ var require_gte = /* @__PURE__ */ __commonJSMin(((exports, module) => {
552
+ const compare = require_compare();
553
+ const gte = (a, b, loose) => compare(a, b, loose) >= 0;
554
+ module.exports = gte;
555
+ }));
556
+ //#endregion
557
+ //#region ../../node_modules/.pnpm/semver@7.8.1/node_modules/semver/functions/lte.js
558
+ var require_lte = /* @__PURE__ */ __commonJSMin(((exports, module) => {
559
+ const compare = require_compare();
560
+ const lte = (a, b, loose) => compare(a, b, loose) <= 0;
561
+ module.exports = lte;
562
+ }));
563
+ //#endregion
564
+ //#region ../../node_modules/.pnpm/semver@7.8.1/node_modules/semver/functions/cmp.js
565
+ var require_cmp = /* @__PURE__ */ __commonJSMin(((exports, module) => {
566
+ const eq = require_eq();
567
+ const neq = require_neq();
568
+ const gt = require_gt();
569
+ const gte = require_gte();
570
+ const lt = require_lt();
571
+ const lte = require_lte();
572
+ const cmp = (a, op, b, loose) => {
573
+ switch (op) {
574
+ case "===":
575
+ if (typeof a === "object") a = a.version;
576
+ if (typeof b === "object") b = b.version;
577
+ return a === b;
578
+ case "!==":
579
+ if (typeof a === "object") a = a.version;
580
+ if (typeof b === "object") b = b.version;
581
+ return a !== b;
582
+ case "":
583
+ case "=":
584
+ case "==": return eq(a, b, loose);
585
+ case "!=": return neq(a, b, loose);
586
+ case ">": return gt(a, b, loose);
587
+ case ">=": return gte(a, b, loose);
588
+ case "<": return lt(a, b, loose);
589
+ case "<=": return lte(a, b, loose);
590
+ default: throw new TypeError(`Invalid operator: ${op}`);
591
+ }
592
+ };
593
+ module.exports = cmp;
594
+ }));
595
+ //#endregion
596
+ //#region ../../node_modules/.pnpm/semver@7.8.1/node_modules/semver/functions/coerce.js
597
+ var require_coerce = /* @__PURE__ */ __commonJSMin(((exports, module) => {
598
+ const SemVer = require_semver$1();
599
+ const parse = require_parse();
600
+ const { safeRe: re, t } = require_re();
601
+ const coerce = (version, options) => {
602
+ if (version instanceof SemVer) return version;
603
+ if (typeof version === "number") version = String(version);
604
+ if (typeof version !== "string") return null;
605
+ options = options || {};
606
+ let match = null;
607
+ if (!options.rtl) match = version.match(options.includePrerelease ? re[t.COERCEFULL] : re[t.COERCE]);
608
+ else {
609
+ const coerceRtlRegex = options.includePrerelease ? re[t.COERCERTLFULL] : re[t.COERCERTL];
610
+ let next;
611
+ while ((next = coerceRtlRegex.exec(version)) && (!match || match.index + match[0].length !== version.length)) {
612
+ if (!match || next.index + next[0].length !== match.index + match[0].length) match = next;
613
+ coerceRtlRegex.lastIndex = next.index + next[1].length + next[2].length;
614
+ }
615
+ coerceRtlRegex.lastIndex = -1;
616
+ }
617
+ if (match === null) return null;
618
+ const major = match[2];
619
+ return parse(`${major}.${match[3] || "0"}.${match[4] || "0"}${options.includePrerelease && match[5] ? `-${match[5]}` : ""}${options.includePrerelease && match[6] ? `+${match[6]}` : ""}`, options);
620
+ };
621
+ module.exports = coerce;
622
+ }));
623
+ //#endregion
624
+ //#region ../../node_modules/.pnpm/semver@7.8.1/node_modules/semver/functions/truncate.js
625
+ var require_truncate = /* @__PURE__ */ __commonJSMin(((exports, module) => {
626
+ const parse = require_parse();
627
+ const constants = require_constants();
628
+ const SemVer = require_semver$1();
629
+ const truncate = (version, truncation, options) => {
630
+ if (!constants.RELEASE_TYPES.includes(truncation)) return null;
631
+ const clonedVersion = cloneInputVersion(version, options);
632
+ return clonedVersion && doTruncation(clonedVersion, truncation);
633
+ };
634
+ const cloneInputVersion = (version, options) => {
635
+ return parse(version instanceof SemVer ? version.version : version, options);
636
+ };
637
+ const doTruncation = (version, truncation) => {
638
+ if (isPrerelease(truncation)) return version.version;
639
+ version.prerelease = [];
640
+ switch (truncation) {
641
+ case "major":
642
+ version.minor = 0;
643
+ version.patch = 0;
644
+ break;
645
+ case "minor":
646
+ version.patch = 0;
647
+ break;
648
+ }
649
+ return version.format();
650
+ };
651
+ const isPrerelease = (type) => {
652
+ return type.startsWith("pre");
653
+ };
654
+ module.exports = truncate;
655
+ }));
656
+ //#endregion
657
+ //#region ../../node_modules/.pnpm/semver@7.8.1/node_modules/semver/internal/lrucache.js
658
+ var require_lrucache = /* @__PURE__ */ __commonJSMin(((exports, module) => {
659
+ var LRUCache = class {
660
+ constructor() {
661
+ this.max = 1e3;
662
+ this.map = /* @__PURE__ */ new Map();
663
+ }
664
+ get(key) {
665
+ const value = this.map.get(key);
666
+ if (value === void 0) return;
667
+ else {
668
+ this.map.delete(key);
669
+ this.map.set(key, value);
670
+ return value;
671
+ }
672
+ }
673
+ delete(key) {
674
+ return this.map.delete(key);
675
+ }
676
+ set(key, value) {
677
+ if (!this.delete(key) && value !== void 0) {
678
+ if (this.map.size >= this.max) {
679
+ const firstKey = this.map.keys().next().value;
680
+ this.delete(firstKey);
681
+ }
682
+ this.map.set(key, value);
683
+ }
684
+ return this;
685
+ }
686
+ };
687
+ module.exports = LRUCache;
688
+ }));
689
+ //#endregion
690
+ //#region ../../node_modules/.pnpm/semver@7.8.1/node_modules/semver/classes/range.js
691
+ var require_range = /* @__PURE__ */ __commonJSMin(((exports, module) => {
692
+ const SPACE_CHARACTERS = /\s+/g;
693
+ module.exports = class Range {
694
+ constructor(range, options) {
695
+ options = parseOptions(options);
696
+ if (range instanceof Range) if (range.loose === !!options.loose && range.includePrerelease === !!options.includePrerelease) return range;
697
+ else return new Range(range.raw, options);
698
+ if (range instanceof Comparator) {
699
+ this.raw = range.value;
700
+ this.set = [[range]];
701
+ this.formatted = void 0;
702
+ return this;
703
+ }
704
+ this.options = options;
705
+ this.loose = !!options.loose;
706
+ this.includePrerelease = !!options.includePrerelease;
707
+ this.raw = range.trim().replace(SPACE_CHARACTERS, " ");
708
+ this.set = this.raw.split("||").map((r) => this.parseRange(r.trim())).filter((c) => c.length);
709
+ if (!this.set.length) throw new TypeError(`Invalid SemVer Range: ${this.raw}`);
710
+ if (this.set.length > 1) {
711
+ const first = this.set[0];
712
+ this.set = this.set.filter((c) => !isNullSet(c[0]));
713
+ if (this.set.length === 0) this.set = [first];
714
+ else if (this.set.length > 1) {
715
+ for (const c of this.set) if (c.length === 1 && isAny(c[0])) {
716
+ this.set = [c];
717
+ break;
718
+ }
719
+ }
720
+ }
721
+ this.formatted = void 0;
722
+ }
723
+ get range() {
724
+ if (this.formatted === void 0) {
725
+ this.formatted = "";
726
+ for (let i = 0; i < this.set.length; i++) {
727
+ if (i > 0) this.formatted += "||";
728
+ const comps = this.set[i];
729
+ for (let k = 0; k < comps.length; k++) {
730
+ if (k > 0) this.formatted += " ";
731
+ this.formatted += comps[k].toString().trim();
732
+ }
733
+ }
734
+ }
735
+ return this.formatted;
736
+ }
737
+ format() {
738
+ return this.range;
739
+ }
740
+ toString() {
741
+ return this.range;
742
+ }
743
+ parseRange(range) {
744
+ range = range.replace(BUILDSTRIPRE, "");
745
+ const memoKey = ((this.options.includePrerelease && FLAG_INCLUDE_PRERELEASE) | (this.options.loose && FLAG_LOOSE)) + ":" + range;
746
+ const cached = cache.get(memoKey);
747
+ if (cached) return cached;
748
+ const loose = this.options.loose;
749
+ const hr = loose ? re[t.HYPHENRANGELOOSE] : re[t.HYPHENRANGE];
750
+ range = range.replace(hr, hyphenReplace(this.options.includePrerelease));
751
+ debug("hyphen replace", range);
752
+ range = range.replace(re[t.COMPARATORTRIM], comparatorTrimReplace);
753
+ debug("comparator trim", range);
754
+ range = range.replace(re[t.TILDETRIM], tildeTrimReplace);
755
+ debug("tilde trim", range);
756
+ range = range.replace(re[t.CARETTRIM], caretTrimReplace);
757
+ debug("caret trim", range);
758
+ let rangeList = range.split(" ").map((comp) => parseComparator(comp, this.options)).join(" ").split(/\s+/).map((comp) => replaceGTE0(comp, this.options));
759
+ if (loose) rangeList = rangeList.filter((comp) => {
760
+ debug("loose invalid filter", comp, this.options);
761
+ return !!comp.match(re[t.COMPARATORLOOSE]);
762
+ });
763
+ debug("range list", rangeList);
764
+ const rangeMap = /* @__PURE__ */ new Map();
765
+ const comparators = rangeList.map((comp) => new Comparator(comp, this.options));
766
+ for (const comp of comparators) {
767
+ if (isNullSet(comp)) return [comp];
768
+ rangeMap.set(comp.value, comp);
769
+ }
770
+ if (rangeMap.size > 1 && rangeMap.has("")) rangeMap.delete("");
771
+ const result = [...rangeMap.values()];
772
+ cache.set(memoKey, result);
773
+ return result;
774
+ }
775
+ intersects(range, options) {
776
+ if (!(range instanceof Range)) throw new TypeError("a Range is required");
777
+ return this.set.some((thisComparators) => {
778
+ return isSatisfiable(thisComparators, options) && range.set.some((rangeComparators) => {
779
+ return isSatisfiable(rangeComparators, options) && thisComparators.every((thisComparator) => {
780
+ return rangeComparators.every((rangeComparator) => {
781
+ return thisComparator.intersects(rangeComparator, options);
782
+ });
783
+ });
784
+ });
785
+ });
786
+ }
787
+ test(version) {
788
+ if (!version) return false;
789
+ if (typeof version === "string") try {
790
+ version = new SemVer(version, this.options);
791
+ } catch (er) {
792
+ return false;
793
+ }
794
+ for (let i = 0; i < this.set.length; i++) if (testSet(this.set[i], version, this.options)) return true;
795
+ return false;
796
+ }
797
+ };
798
+ const cache = new (require_lrucache())();
799
+ const parseOptions = require_parse_options();
800
+ const Comparator = require_comparator();
801
+ const debug = require_debug();
802
+ const SemVer = require_semver$1();
803
+ const { safeRe: re, src, t, comparatorTrimReplace, tildeTrimReplace, caretTrimReplace } = require_re();
804
+ const { FLAG_INCLUDE_PRERELEASE, FLAG_LOOSE } = require_constants();
805
+ const BUILDSTRIPRE = new RegExp(src[t.BUILD], "g");
806
+ const isNullSet = (c) => c.value === "<0.0.0-0";
807
+ const isAny = (c) => c.value === "";
808
+ const isSatisfiable = (comparators, options) => {
809
+ let result = true;
810
+ const remainingComparators = comparators.slice();
811
+ let testComparator = remainingComparators.pop();
812
+ while (result && remainingComparators.length) {
813
+ result = remainingComparators.every((otherComparator) => {
814
+ return testComparator.intersects(otherComparator, options);
815
+ });
816
+ testComparator = remainingComparators.pop();
817
+ }
818
+ return result;
819
+ };
820
+ const parseComparator = (comp, options) => {
821
+ comp = comp.replace(re[t.BUILD], "");
822
+ debug("comp", comp, options);
823
+ comp = replaceCarets(comp, options);
824
+ debug("caret", comp);
825
+ comp = replaceTildes(comp, options);
826
+ debug("tildes", comp);
827
+ comp = replaceXRanges(comp, options);
828
+ debug("xrange", comp);
829
+ comp = replaceStars(comp, options);
830
+ debug("stars", comp);
831
+ return comp;
832
+ };
833
+ const isX = (id) => !id || id.toLowerCase() === "x" || id === "*";
834
+ const replaceTildes = (comp, options) => {
835
+ return comp.trim().split(/\s+/).map((c) => replaceTilde(c, options)).join(" ");
836
+ };
837
+ const replaceTilde = (comp, options) => {
838
+ const r = options.loose ? re[t.TILDELOOSE] : re[t.TILDE];
839
+ return comp.replace(r, (_, M, m, p, pr) => {
840
+ debug("tilde", comp, _, M, m, p, pr);
841
+ let ret;
842
+ if (isX(M)) ret = "";
843
+ else if (isX(m)) ret = `>=${M}.0.0 <${+M + 1}.0.0-0`;
844
+ else if (isX(p)) ret = `>=${M}.${m}.0 <${M}.${+m + 1}.0-0`;
845
+ else if (pr) {
846
+ debug("replaceTilde pr", pr);
847
+ ret = `>=${M}.${m}.${p}-${pr} <${M}.${+m + 1}.0-0`;
848
+ } else ret = `>=${M}.${m}.${p} <${M}.${+m + 1}.0-0`;
849
+ debug("tilde return", ret);
850
+ return ret;
851
+ });
852
+ };
853
+ const replaceCarets = (comp, options) => {
854
+ return comp.trim().split(/\s+/).map((c) => replaceCaret(c, options)).join(" ");
855
+ };
856
+ const replaceCaret = (comp, options) => {
857
+ debug("caret", comp, options);
858
+ const r = options.loose ? re[t.CARETLOOSE] : re[t.CARET];
859
+ const z = options.includePrerelease ? "-0" : "";
860
+ return comp.replace(r, (_, M, m, p, pr) => {
861
+ debug("caret", comp, _, M, m, p, pr);
862
+ let ret;
863
+ if (isX(M)) ret = "";
864
+ else if (isX(m)) ret = `>=${M}.0.0${z} <${+M + 1}.0.0-0`;
865
+ else if (isX(p)) if (M === "0") ret = `>=${M}.${m}.0${z} <${M}.${+m + 1}.0-0`;
866
+ else ret = `>=${M}.${m}.0${z} <${+M + 1}.0.0-0`;
867
+ else if (pr) {
868
+ debug("replaceCaret pr", pr);
869
+ if (M === "0") if (m === "0") ret = `>=${M}.${m}.${p}-${pr} <${M}.${m}.${+p + 1}-0`;
870
+ else ret = `>=${M}.${m}.${p}-${pr} <${M}.${+m + 1}.0-0`;
871
+ else ret = `>=${M}.${m}.${p}-${pr} <${+M + 1}.0.0-0`;
872
+ } else {
873
+ debug("no pr");
874
+ if (M === "0") if (m === "0") ret = `>=${M}.${m}.${p}${z} <${M}.${m}.${+p + 1}-0`;
875
+ else ret = `>=${M}.${m}.${p}${z} <${M}.${+m + 1}.0-0`;
876
+ else ret = `>=${M}.${m}.${p} <${+M + 1}.0.0-0`;
877
+ }
878
+ debug("caret return", ret);
879
+ return ret;
880
+ });
881
+ };
882
+ const replaceXRanges = (comp, options) => {
883
+ debug("replaceXRanges", comp, options);
884
+ return comp.split(/\s+/).map((c) => replaceXRange(c, options)).join(" ");
885
+ };
886
+ const replaceXRange = (comp, options) => {
887
+ comp = comp.trim();
888
+ const r = options.loose ? re[t.XRANGELOOSE] : re[t.XRANGE];
889
+ return comp.replace(r, (ret, gtlt, M, m, p, pr) => {
890
+ debug("xRange", comp, ret, gtlt, M, m, p, pr);
891
+ const xM = isX(M);
892
+ const xm = xM || isX(m);
893
+ const xp = xm || isX(p);
894
+ const anyX = xp;
895
+ if (gtlt === "=" && anyX) gtlt = "";
896
+ pr = options.includePrerelease ? "-0" : "";
897
+ if (xM) if (gtlt === ">" || gtlt === "<") ret = "<0.0.0-0";
898
+ else ret = "*";
899
+ else if (gtlt && anyX) {
900
+ if (xm) m = 0;
901
+ p = 0;
902
+ if (gtlt === ">") {
903
+ gtlt = ">=";
904
+ if (xm) {
905
+ M = +M + 1;
906
+ m = 0;
907
+ p = 0;
908
+ } else {
909
+ m = +m + 1;
910
+ p = 0;
911
+ }
912
+ } else if (gtlt === "<=") {
913
+ gtlt = "<";
914
+ if (xm) M = +M + 1;
915
+ else m = +m + 1;
916
+ }
917
+ if (gtlt === "<") pr = "-0";
918
+ ret = `${gtlt + M}.${m}.${p}${pr}`;
919
+ } else if (xm) ret = `>=${M}.0.0${pr} <${+M + 1}.0.0-0`;
920
+ else if (xp) ret = `>=${M}.${m}.0${pr} <${M}.${+m + 1}.0-0`;
921
+ debug("xRange return", ret);
922
+ return ret;
923
+ });
924
+ };
925
+ const replaceStars = (comp, options) => {
926
+ debug("replaceStars", comp, options);
927
+ return comp.trim().replace(re[t.STAR], "");
928
+ };
929
+ const replaceGTE0 = (comp, options) => {
930
+ debug("replaceGTE0", comp, options);
931
+ return comp.trim().replace(re[options.includePrerelease ? t.GTE0PRE : t.GTE0], "");
932
+ };
933
+ const hyphenReplace = (incPr) => ($0, from, fM, fm, fp, fpr, fb, to, tM, tm, tp, tpr) => {
934
+ if (isX(fM)) from = "";
935
+ else if (isX(fm)) from = `>=${fM}.0.0${incPr ? "-0" : ""}`;
936
+ else if (isX(fp)) from = `>=${fM}.${fm}.0${incPr ? "-0" : ""}`;
937
+ else if (fpr) from = `>=${from}`;
938
+ else from = `>=${from}${incPr ? "-0" : ""}`;
939
+ if (isX(tM)) to = "";
940
+ else if (isX(tm)) to = `<${+tM + 1}.0.0-0`;
941
+ else if (isX(tp)) to = `<${tM}.${+tm + 1}.0-0`;
942
+ else if (tpr) to = `<=${tM}.${tm}.${tp}-${tpr}`;
943
+ else if (incPr) to = `<${tM}.${tm}.${+tp + 1}-0`;
944
+ else to = `<=${to}`;
945
+ return `${from} ${to}`.trim();
946
+ };
947
+ const testSet = (set, version, options) => {
948
+ for (let i = 0; i < set.length; i++) if (!set[i].test(version)) return false;
949
+ if (version.prerelease.length && !options.includePrerelease) {
950
+ for (let i = 0; i < set.length; i++) {
951
+ debug(set[i].semver);
952
+ if (set[i].semver === Comparator.ANY) continue;
953
+ if (set[i].semver.prerelease.length > 0) {
954
+ const allowed = set[i].semver;
955
+ if (allowed.major === version.major && allowed.minor === version.minor && allowed.patch === version.patch) return true;
956
+ }
957
+ }
958
+ return false;
959
+ }
960
+ return true;
961
+ };
962
+ }));
963
+ //#endregion
964
+ //#region ../../node_modules/.pnpm/semver@7.8.1/node_modules/semver/classes/comparator.js
965
+ var require_comparator = /* @__PURE__ */ __commonJSMin(((exports, module) => {
966
+ const ANY = Symbol("SemVer ANY");
967
+ module.exports = class Comparator {
968
+ static get ANY() {
969
+ return ANY;
970
+ }
971
+ constructor(comp, options) {
972
+ options = parseOptions(options);
973
+ if (comp instanceof Comparator) if (comp.loose === !!options.loose) return comp;
974
+ else comp = comp.value;
975
+ comp = comp.trim().split(/\s+/).join(" ");
976
+ debug("comparator", comp, options);
977
+ this.options = options;
978
+ this.loose = !!options.loose;
979
+ this.parse(comp);
980
+ if (this.semver === ANY) this.value = "";
981
+ else this.value = this.operator + this.semver.version;
982
+ debug("comp", this);
983
+ }
984
+ parse(comp) {
985
+ const r = this.options.loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR];
986
+ const m = comp.match(r);
987
+ if (!m) throw new TypeError(`Invalid comparator: ${comp}`);
988
+ this.operator = m[1] !== void 0 ? m[1] : "";
989
+ if (this.operator === "=") this.operator = "";
990
+ if (!m[2]) this.semver = ANY;
991
+ else this.semver = new SemVer(m[2], this.options.loose);
992
+ }
993
+ toString() {
994
+ return this.value;
995
+ }
996
+ test(version) {
997
+ debug("Comparator.test", version, this.options.loose);
998
+ if (this.semver === ANY || version === ANY) return true;
999
+ if (typeof version === "string") try {
1000
+ version = new SemVer(version, this.options);
1001
+ } catch (er) {
1002
+ return false;
1003
+ }
1004
+ return cmp(version, this.operator, this.semver, this.options);
1005
+ }
1006
+ intersects(comp, options) {
1007
+ if (!(comp instanceof Comparator)) throw new TypeError("a Comparator is required");
1008
+ if (this.operator === "") {
1009
+ if (this.value === "") return true;
1010
+ return new Range(comp.value, options).test(this.value);
1011
+ } else if (comp.operator === "") {
1012
+ if (comp.value === "") return true;
1013
+ return new Range(this.value, options).test(comp.semver);
1014
+ }
1015
+ options = parseOptions(options);
1016
+ if (options.includePrerelease && (this.value === "<0.0.0-0" || comp.value === "<0.0.0-0")) return false;
1017
+ if (!options.includePrerelease && (this.value.startsWith("<0.0.0") || comp.value.startsWith("<0.0.0"))) return false;
1018
+ if (this.operator.startsWith(">") && comp.operator.startsWith(">")) return true;
1019
+ if (this.operator.startsWith("<") && comp.operator.startsWith("<")) return true;
1020
+ if (this.semver.version === comp.semver.version && this.operator.includes("=") && comp.operator.includes("=")) return true;
1021
+ if (cmp(this.semver, "<", comp.semver, options) && this.operator.startsWith(">") && comp.operator.startsWith("<")) return true;
1022
+ if (cmp(this.semver, ">", comp.semver, options) && this.operator.startsWith("<") && comp.operator.startsWith(">")) return true;
1023
+ return false;
1024
+ }
1025
+ };
1026
+ const parseOptions = require_parse_options();
1027
+ const { safeRe: re, t } = require_re();
1028
+ const cmp = require_cmp();
1029
+ const debug = require_debug();
1030
+ const SemVer = require_semver$1();
1031
+ const Range = require_range();
1032
+ }));
1033
+ //#endregion
1034
+ //#region ../../node_modules/.pnpm/semver@7.8.1/node_modules/semver/functions/satisfies.js
1035
+ var require_satisfies = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1036
+ const Range = require_range();
1037
+ const satisfies = (version, range, options) => {
1038
+ try {
1039
+ range = new Range(range, options);
1040
+ } catch (er) {
1041
+ return false;
1042
+ }
1043
+ return range.test(version);
1044
+ };
1045
+ module.exports = satisfies;
1046
+ }));
1047
+ //#endregion
1048
+ //#region ../../node_modules/.pnpm/semver@7.8.1/node_modules/semver/ranges/to-comparators.js
1049
+ var require_to_comparators = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1050
+ const Range = require_range();
1051
+ const toComparators = (range, options) => new Range(range, options).set.map((comp) => comp.map((c) => c.value).join(" ").trim().split(" "));
1052
+ module.exports = toComparators;
1053
+ }));
1054
+ //#endregion
1055
+ //#region ../../node_modules/.pnpm/semver@7.8.1/node_modules/semver/ranges/max-satisfying.js
1056
+ var require_max_satisfying = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1057
+ const SemVer = require_semver$1();
1058
+ const Range = require_range();
1059
+ const maxSatisfying = (versions, range, options) => {
1060
+ let max = null;
1061
+ let maxSV = null;
1062
+ let rangeObj = null;
1063
+ try {
1064
+ rangeObj = new Range(range, options);
1065
+ } catch (er) {
1066
+ return null;
1067
+ }
1068
+ versions.forEach((v) => {
1069
+ if (rangeObj.test(v)) {
1070
+ if (!max || maxSV.compare(v) === -1) {
1071
+ max = v;
1072
+ maxSV = new SemVer(max, options);
1073
+ }
1074
+ }
1075
+ });
1076
+ return max;
1077
+ };
1078
+ module.exports = maxSatisfying;
1079
+ }));
1080
+ //#endregion
1081
+ //#region ../../node_modules/.pnpm/semver@7.8.1/node_modules/semver/ranges/min-satisfying.js
1082
+ var require_min_satisfying = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1083
+ const SemVer = require_semver$1();
1084
+ const Range = require_range();
1085
+ const minSatisfying = (versions, range, options) => {
1086
+ let min = null;
1087
+ let minSV = null;
1088
+ let rangeObj = null;
1089
+ try {
1090
+ rangeObj = new Range(range, options);
1091
+ } catch (er) {
1092
+ return null;
1093
+ }
1094
+ versions.forEach((v) => {
1095
+ if (rangeObj.test(v)) {
1096
+ if (!min || minSV.compare(v) === 1) {
1097
+ min = v;
1098
+ minSV = new SemVer(min, options);
1099
+ }
1100
+ }
1101
+ });
1102
+ return min;
1103
+ };
1104
+ module.exports = minSatisfying;
1105
+ }));
1106
+ //#endregion
1107
+ //#region ../../node_modules/.pnpm/semver@7.8.1/node_modules/semver/ranges/min-version.js
1108
+ var require_min_version = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1109
+ const SemVer = require_semver$1();
1110
+ const Range = require_range();
1111
+ const gt = require_gt();
1112
+ const minVersion = (range, loose) => {
1113
+ range = new Range(range, loose);
1114
+ let minver = new SemVer("0.0.0");
1115
+ if (range.test(minver)) return minver;
1116
+ minver = new SemVer("0.0.0-0");
1117
+ if (range.test(minver)) return minver;
1118
+ minver = null;
1119
+ for (let i = 0; i < range.set.length; ++i) {
1120
+ const comparators = range.set[i];
1121
+ let setMin = null;
1122
+ comparators.forEach((comparator) => {
1123
+ const compver = new SemVer(comparator.semver.version);
1124
+ switch (comparator.operator) {
1125
+ case ">":
1126
+ if (compver.prerelease.length === 0) compver.patch++;
1127
+ else compver.prerelease.push(0);
1128
+ compver.raw = compver.format();
1129
+ case "":
1130
+ case ">=":
1131
+ if (!setMin || gt(compver, setMin)) setMin = compver;
1132
+ break;
1133
+ case "<":
1134
+ case "<=": break;
1135
+ /* istanbul ignore next */
1136
+ default: throw new Error(`Unexpected operation: ${comparator.operator}`);
1137
+ }
1138
+ });
1139
+ if (setMin && (!minver || gt(minver, setMin))) minver = setMin;
1140
+ }
1141
+ if (minver && range.test(minver)) return minver;
1142
+ return null;
1143
+ };
1144
+ module.exports = minVersion;
1145
+ }));
1146
+ //#endregion
1147
+ //#region ../../node_modules/.pnpm/semver@7.8.1/node_modules/semver/ranges/valid.js
1148
+ var require_valid = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1149
+ const Range = require_range();
1150
+ const validRange = (range, options) => {
1151
+ try {
1152
+ return new Range(range, options).range || "*";
1153
+ } catch (er) {
1154
+ return null;
1155
+ }
1156
+ };
1157
+ module.exports = validRange;
1158
+ }));
1159
+ //#endregion
1160
+ //#region ../../node_modules/.pnpm/semver@7.8.1/node_modules/semver/ranges/outside.js
1161
+ var require_outside = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1162
+ const SemVer = require_semver$1();
1163
+ const Comparator = require_comparator();
1164
+ const { ANY } = Comparator;
1165
+ const Range = require_range();
1166
+ const satisfies = require_satisfies();
1167
+ const gt = require_gt();
1168
+ const lt = require_lt();
1169
+ const lte = require_lte();
1170
+ const gte = require_gte();
1171
+ const outside = (version, range, hilo, options) => {
1172
+ version = new SemVer(version, options);
1173
+ range = new Range(range, options);
1174
+ let gtfn, ltefn, ltfn, comp, ecomp;
1175
+ switch (hilo) {
1176
+ case ">":
1177
+ gtfn = gt;
1178
+ ltefn = lte;
1179
+ ltfn = lt;
1180
+ comp = ">";
1181
+ ecomp = ">=";
1182
+ break;
1183
+ case "<":
1184
+ gtfn = lt;
1185
+ ltefn = gte;
1186
+ ltfn = gt;
1187
+ comp = "<";
1188
+ ecomp = "<=";
1189
+ break;
1190
+ default: throw new TypeError("Must provide a hilo val of \"<\" or \">\"");
1191
+ }
1192
+ if (satisfies(version, range, options)) return false;
1193
+ for (let i = 0; i < range.set.length; ++i) {
1194
+ const comparators = range.set[i];
1195
+ let high = null;
1196
+ let low = null;
1197
+ comparators.forEach((comparator) => {
1198
+ if (comparator.semver === ANY) comparator = new Comparator(">=0.0.0");
1199
+ high = high || comparator;
1200
+ low = low || comparator;
1201
+ if (gtfn(comparator.semver, high.semver, options)) high = comparator;
1202
+ else if (ltfn(comparator.semver, low.semver, options)) low = comparator;
1203
+ });
1204
+ if (high.operator === comp || high.operator === ecomp) return false;
1205
+ if ((!low.operator || low.operator === comp) && ltefn(version, low.semver)) return false;
1206
+ else if (low.operator === ecomp && ltfn(version, low.semver)) return false;
1207
+ }
1208
+ return true;
1209
+ };
1210
+ module.exports = outside;
1211
+ }));
1212
+ //#endregion
1213
+ //#region ../../node_modules/.pnpm/semver@7.8.1/node_modules/semver/ranges/gtr.js
1214
+ var require_gtr = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1215
+ const outside = require_outside();
1216
+ const gtr = (version, range, options) => outside(version, range, ">", options);
1217
+ module.exports = gtr;
1218
+ }));
1219
+ //#endregion
1220
+ //#region ../../node_modules/.pnpm/semver@7.8.1/node_modules/semver/ranges/ltr.js
1221
+ var require_ltr = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1222
+ const outside = require_outside();
1223
+ const ltr = (version, range, options) => outside(version, range, "<", options);
1224
+ module.exports = ltr;
1225
+ }));
1226
+ //#endregion
1227
+ //#region ../../node_modules/.pnpm/semver@7.8.1/node_modules/semver/ranges/intersects.js
1228
+ var require_intersects = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1229
+ const Range = require_range();
1230
+ const intersects = (r1, r2, options) => {
1231
+ r1 = new Range(r1, options);
1232
+ r2 = new Range(r2, options);
1233
+ return r1.intersects(r2, options);
1234
+ };
1235
+ module.exports = intersects;
1236
+ }));
1237
+ //#endregion
1238
+ //#region ../../node_modules/.pnpm/semver@7.8.1/node_modules/semver/ranges/simplify.js
1239
+ var require_simplify = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1240
+ const satisfies = require_satisfies();
1241
+ const compare = require_compare();
1242
+ module.exports = (versions, range, options) => {
1243
+ const set = [];
1244
+ let first = null;
1245
+ let prev = null;
1246
+ const v = versions.sort((a, b) => compare(a, b, options));
1247
+ for (const version of v) if (satisfies(version, range, options)) {
1248
+ prev = version;
1249
+ if (!first) first = version;
1250
+ } else {
1251
+ if (prev) set.push([first, prev]);
1252
+ prev = null;
1253
+ first = null;
1254
+ }
1255
+ if (first) set.push([first, null]);
1256
+ const ranges = [];
1257
+ for (const [min, max] of set) if (min === max) ranges.push(min);
1258
+ else if (!max && min === v[0]) ranges.push("*");
1259
+ else if (!max) ranges.push(`>=${min}`);
1260
+ else if (min === v[0]) ranges.push(`<=${max}`);
1261
+ else ranges.push(`${min} - ${max}`);
1262
+ const simplified = ranges.join(" || ");
1263
+ const original = typeof range.raw === "string" ? range.raw : String(range);
1264
+ return simplified.length < original.length ? simplified : range;
1265
+ };
1266
+ }));
1267
+ //#endregion
1268
+ //#region ../../node_modules/.pnpm/semver@7.8.1/node_modules/semver/ranges/subset.js
1269
+ var require_subset = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1270
+ const Range = require_range();
1271
+ const Comparator = require_comparator();
1272
+ const { ANY } = Comparator;
1273
+ const satisfies = require_satisfies();
1274
+ const compare = require_compare();
1275
+ const subset = (sub, dom, options = {}) => {
1276
+ if (sub === dom) return true;
1277
+ sub = new Range(sub, options);
1278
+ dom = new Range(dom, options);
1279
+ let sawNonNull = false;
1280
+ OUTER: for (const simpleSub of sub.set) {
1281
+ for (const simpleDom of dom.set) {
1282
+ const isSub = simpleSubset(simpleSub, simpleDom, options);
1283
+ sawNonNull = sawNonNull || isSub !== null;
1284
+ if (isSub) continue OUTER;
1285
+ }
1286
+ if (sawNonNull) return false;
1287
+ }
1288
+ return true;
1289
+ };
1290
+ const minimumVersionWithPreRelease = [new Comparator(">=0.0.0-0")];
1291
+ const minimumVersion = [new Comparator(">=0.0.0")];
1292
+ const simpleSubset = (sub, dom, options) => {
1293
+ if (sub === dom) return true;
1294
+ if (sub.length === 1 && sub[0].semver === ANY) if (dom.length === 1 && dom[0].semver === ANY) return true;
1295
+ else if (options.includePrerelease) sub = minimumVersionWithPreRelease;
1296
+ else sub = minimumVersion;
1297
+ if (dom.length === 1 && dom[0].semver === ANY) if (options.includePrerelease) return true;
1298
+ else dom = minimumVersion;
1299
+ const eqSet = /* @__PURE__ */ new Set();
1300
+ let gt, lt;
1301
+ for (const c of sub) if (c.operator === ">" || c.operator === ">=") gt = higherGT(gt, c, options);
1302
+ else if (c.operator === "<" || c.operator === "<=") lt = lowerLT(lt, c, options);
1303
+ else eqSet.add(c.semver);
1304
+ if (eqSet.size > 1) return null;
1305
+ let gtltComp;
1306
+ if (gt && lt) {
1307
+ gtltComp = compare(gt.semver, lt.semver, options);
1308
+ if (gtltComp > 0) return null;
1309
+ else if (gtltComp === 0 && (gt.operator !== ">=" || lt.operator !== "<=")) return null;
1310
+ }
1311
+ for (const eq of eqSet) {
1312
+ if (gt && !satisfies(eq, String(gt), options)) return null;
1313
+ if (lt && !satisfies(eq, String(lt), options)) return null;
1314
+ for (const c of dom) if (!satisfies(eq, String(c), options)) return false;
1315
+ return true;
1316
+ }
1317
+ let higher, lower;
1318
+ let hasDomLT, hasDomGT;
1319
+ let needDomLTPre = lt && !options.includePrerelease && lt.semver.prerelease.length ? lt.semver : false;
1320
+ let needDomGTPre = gt && !options.includePrerelease && gt.semver.prerelease.length ? gt.semver : false;
1321
+ if (needDomLTPre && needDomLTPre.prerelease.length === 1 && lt.operator === "<" && needDomLTPre.prerelease[0] === 0) needDomLTPre = false;
1322
+ for (const c of dom) {
1323
+ hasDomGT = hasDomGT || c.operator === ">" || c.operator === ">=";
1324
+ hasDomLT = hasDomLT || c.operator === "<" || c.operator === "<=";
1325
+ if (gt) {
1326
+ if (needDomGTPre) {
1327
+ if (c.semver.prerelease && c.semver.prerelease.length && c.semver.major === needDomGTPre.major && c.semver.minor === needDomGTPre.minor && c.semver.patch === needDomGTPre.patch) needDomGTPre = false;
1328
+ }
1329
+ if (c.operator === ">" || c.operator === ">=") {
1330
+ higher = higherGT(gt, c, options);
1331
+ if (higher === c && higher !== gt) return false;
1332
+ } else if (gt.operator === ">=" && !c.test(gt.semver)) return false;
1333
+ }
1334
+ if (lt) {
1335
+ if (needDomLTPre) {
1336
+ if (c.semver.prerelease && c.semver.prerelease.length && c.semver.major === needDomLTPre.major && c.semver.minor === needDomLTPre.minor && c.semver.patch === needDomLTPre.patch) needDomLTPre = false;
1337
+ }
1338
+ if (c.operator === "<" || c.operator === "<=") {
1339
+ lower = lowerLT(lt, c, options);
1340
+ if (lower === c && lower !== lt) return false;
1341
+ } else if (lt.operator === "<=" && !c.test(lt.semver)) return false;
1342
+ }
1343
+ if (!c.operator && (lt || gt) && gtltComp !== 0) return false;
1344
+ }
1345
+ if (gt && hasDomLT && !lt && gtltComp !== 0) return false;
1346
+ if (lt && hasDomGT && !gt && gtltComp !== 0) return false;
1347
+ if (needDomGTPre || needDomLTPre) return false;
1348
+ return true;
1349
+ };
1350
+ const higherGT = (a, b, options) => {
1351
+ if (!a) return b;
1352
+ const comp = compare(a.semver, b.semver, options);
1353
+ return comp > 0 ? a : comp < 0 ? b : b.operator === ">" && a.operator === ">=" ? b : a;
1354
+ };
1355
+ const lowerLT = (a, b, options) => {
1356
+ if (!a) return b;
1357
+ const comp = compare(a.semver, b.semver, options);
1358
+ return comp < 0 ? a : comp > 0 ? b : b.operator === "<" && a.operator === "<=" ? b : a;
1359
+ };
1360
+ module.exports = subset;
1361
+ }));
1362
+ //#endregion
1363
+ //#region ../x-generative-compiler/dist/compile.js
1364
+ var import_semver = (/* @__PURE__ */ __commonJSMin(((exports, module) => {
1365
+ const internalRe = require_re();
1366
+ const constants = require_constants();
1367
+ const SemVer = require_semver$1();
1368
+ const identifiers = require_identifiers();
1369
+ module.exports = {
1370
+ parse: require_parse(),
1371
+ valid: require_valid$1(),
1372
+ clean: require_clean(),
1373
+ inc: require_inc(),
1374
+ diff: require_diff(),
1375
+ major: require_major(),
1376
+ minor: require_minor(),
1377
+ patch: require_patch(),
1378
+ prerelease: require_prerelease(),
1379
+ compare: require_compare(),
1380
+ rcompare: require_rcompare(),
1381
+ compareLoose: require_compare_loose(),
1382
+ compareBuild: require_compare_build(),
1383
+ sort: require_sort(),
1384
+ rsort: require_rsort(),
1385
+ gt: require_gt(),
1386
+ lt: require_lt(),
1387
+ eq: require_eq(),
1388
+ neq: require_neq(),
1389
+ gte: require_gte(),
1390
+ lte: require_lte(),
1391
+ cmp: require_cmp(),
1392
+ coerce: require_coerce(),
1393
+ truncate: require_truncate(),
1394
+ Comparator: require_comparator(),
1395
+ Range: require_range(),
1396
+ satisfies: require_satisfies(),
1397
+ toComparators: require_to_comparators(),
1398
+ maxSatisfying: require_max_satisfying(),
1399
+ minSatisfying: require_min_satisfying(),
1400
+ minVersion: require_min_version(),
1401
+ validRange: require_valid(),
1402
+ outside: require_outside(),
1403
+ gtr: require_gtr(),
1404
+ ltr: require_ltr(),
1405
+ intersects: require_intersects(),
1406
+ simplifyRange: require_simplify(),
1407
+ subset: require_subset(),
1408
+ SemVer,
1409
+ re: internalRe.re,
1410
+ src: internalRe.src,
1411
+ tokens: internalRe.t,
1412
+ SEMVER_SPEC_VERSION: constants.SEMVER_SPEC_VERSION,
1413
+ RELEASE_TYPES: constants.RELEASE_TYPES,
1414
+ compareIdentifiers: identifiers.compareIdentifiers,
1415
+ rcompareIdentifiers: identifiers.rcompareIdentifiers
1416
+ };
1417
+ })))();
1418
+ const traverse = typeof _babel_traverse.default === "function" ? _babel_traverse.default : _babel_traverse.default.default;
1419
+ const generate = typeof _babel_generator.default === "function" ? _babel_generator.default : _babel_generator.default.default;
1420
+ /** The required wrapper around a toolkit's tools (stripped at build time). */
1421
+ const TOOLKIT_WRAPPER = "defineToolkit";
1422
+ /** The helper that produces MCP-only toolkit fragments. */
1423
+ const MCP_TOOLKIT_WRAPPER = "defineMcpToolkit";
1424
+ /** The required wrapper around a generative-UI library (stripped at build time). */
1425
+ const COMPONENTS_WRAPPER = "defineGenerativeComponents";
1426
+ /** The core package whose metadata declares supported compiler versions. */
1427
+ const CORE_PACKAGE = "@assistant-ui/core";
1428
+ /** This package, checked against core's compatibility range. */
1429
+ const COMPILER_PACKAGE = "@assistant-ui/x-generative-compiler";
1430
+ /** Packages that re-export core's generative markers. */
1431
+ const DISTRIBUTION_PACKAGES = [
1432
+ CORE_PACKAGE,
1433
+ "@assistant-ui/react",
1434
+ "@assistant-ui/react-native",
1435
+ "@assistant-ui/react-ink"
1436
+ ];
1437
+ /**
1438
+ * The class whose instances expose split-by-condition tools (`present()`,
1439
+ * `promptUser()`). A toolkit entry that calls a method on one of these passes
1440
+ * through untouched — the library, not this compiler, routes its halves.
1441
+ */
1442
+ const GENERATIVE_FACTORY = "JSONGenerativeUI";
1443
+ /** Thrown when a `"use generative"` file violates an authoring constraint. */
1444
+ var GenerativeCompileError = class extends Error {
1445
+ constructor(message, filename) {
1446
+ super(`[assistant-ui/next]${filename ? ` ${filename}:` : ""} ${message}`);
1447
+ this.name = "GenerativeCompileError";
1448
+ }
1449
+ };
1450
+ /** Whether a source string opts into generative compilation via the directive. */
1451
+ function isGenerativeModule(code) {
1452
+ let i = code.charCodeAt(0) === 65279 ? 1 : 0;
1453
+ for (;;) {
1454
+ while (i < code.length && /\s/.test(code[i])) i++;
1455
+ if (code.startsWith("//", i)) {
1456
+ const nl = code.indexOf("\n", i);
1457
+ if (nl === -1) return false;
1458
+ i = nl + 1;
1459
+ } else if (code.startsWith("/*", i)) {
1460
+ const end = code.indexOf("*/", i + 2);
1461
+ if (end === -1) return false;
1462
+ i = end + 2;
1463
+ } else break;
1464
+ }
1465
+ return code.startsWith(`"use generative"`, i) || code.startsWith(`'use generative'`, i);
1466
+ }
1467
+ /**
1468
+ * Rewrites a `"use generative"` module for a single build target, keeping only the
1469
+ * regions that target needs and pruning the imports the dropped regions used.
1470
+ */
1471
+ function compileGenerative(code, options) {
1472
+ const { target, filename } = options;
1473
+ const ast = (0, _babel_parser.parse)(code, {
1474
+ sourceType: "module",
1475
+ plugins: [
1476
+ "typescript",
1477
+ "jsx",
1478
+ "explicitResourceManagement"
1479
+ ]
1480
+ });
1481
+ if (!ast.program.directives.some((d) => d.value.value === "use generative")) throw new GenerativeCompileError(`missing "${DIRECTIVE}" directive`, filename);
1482
+ ensureCompilerCompatibleWithCore(ast, filename);
1483
+ ensureDefaultExport(ast, filename);
1484
+ const generativeInstances = collectGenerativeInstances(ast);
1485
+ const safeToolkitSpreads = collectSafeToolkitSpreads(ast, filename);
1486
+ const flags = {
1487
+ keptRender: false,
1488
+ keptBackendExecute: false
1489
+ };
1490
+ traverse(ast, { CallExpression(path) {
1491
+ const callee = path.node.callee;
1492
+ const object = _babel_types.isObjectExpression(path.node.arguments[0]) ? path.node.arguments[0] : null;
1493
+ if (_babel_types.isIdentifier(callee, { name: COMPONENTS_WRAPPER })) {
1494
+ if (!object) throw new GenerativeCompileError(`${COMPONENTS_WRAPPER}() takes an inline object literal of components`, filename);
1495
+ compileComponents(object, target, flags, filename);
1496
+ path.replaceWith(object);
1497
+ path.skip();
1498
+ return;
1499
+ }
1500
+ if (_babel_types.isIdentifier(callee, { name: TOOLKIT_WRAPPER })) {
1501
+ if (!object) throw new GenerativeCompileError(`${TOOLKIT_WRAPPER}() takes an inline object literal of tools`, filename);
1502
+ compileToolkit(object, target, generativeInstances, safeToolkitSpreads, flags, filename);
1503
+ path.replaceWith(object);
1504
+ path.skip();
1505
+ }
1506
+ } });
1507
+ const { keptRender, keptBackendExecute } = flags;
1508
+ pruneUnused(ast);
1509
+ ast.program.directives = ast.program.directives.filter((d) => d.value.value !== "use generative" && d.value.value !== "use client");
1510
+ if (target === "client" && keptRender) ast.program.directives.unshift(_babel_types.directive(_babel_types.directiveLiteral("use client")));
1511
+ if (target === "server" && keptBackendExecute && (options.injectServerOnly ?? true)) ast.program.body.unshift(_babel_types.importDeclaration([], _babel_types.stringLiteral("server-only")));
1512
+ const result = generate(ast, {
1513
+ sourceMaps: options.sourceMaps ?? false,
1514
+ filename,
1515
+ jsescOption: { minimal: true }
1516
+ }, code);
1517
+ return {
1518
+ code: result.code,
1519
+ map: result.map
1520
+ };
1521
+ }
1522
+ const checkedCorePackageJsonPaths = /* @__PURE__ */ new Set();
1523
+ const COMPILER_VERSION = version;
1524
+ function ensureCompilerCompatibleWithCore(ast, filename) {
1525
+ const corePackageJsonPath = resolveCorePackageJson(ast, filename);
1526
+ if (!corePackageJsonPath || checkedCorePackageJsonPaths.has(corePackageJsonPath)) return;
1527
+ const corePackageJson = readPackageJson(corePackageJsonPath);
1528
+ const range = corePackageJson?.optionalDevDependencies?.[COMPILER_PACKAGE];
1529
+ if (!range) {
1530
+ checkedCorePackageJsonPaths.add(corePackageJsonPath);
1531
+ return;
1532
+ }
1533
+ let compatible = false;
1534
+ try {
1535
+ compatible = (0, import_semver.satisfies)(COMPILER_VERSION, range, { includePrerelease: true });
1536
+ } catch {
1537
+ throw new GenerativeCompileError(`${CORE_PACKAGE}@${corePackageJson.version ?? "unknown"} declares an invalid optionalDevDependencies range for ${COMPILER_PACKAGE}: ` + JSON.stringify(range), filename);
1538
+ }
1539
+ if (!compatible) throw new GenerativeCompileError(`${CORE_PACKAGE}@${corePackageJson.version ?? "unknown"} requires ${COMPILER_PACKAGE} ${range}, but the current compiler is ${COMPILER_VERSION}. Update @assistant-ui/next, @assistant-ui/vite, or @assistant-ui/metro so their compiler satisfies the core package's optionalDevDependencies range.`, filename);
1540
+ checkedCorePackageJsonPaths.add(corePackageJsonPath);
1541
+ }
1542
+ function resolveCorePackageJson(ast, filename) {
1543
+ for (const packageName of collectImportedDistributionPackages(ast)) {
1544
+ const packageJsonPath = resolvePackageJson(packageName, filename);
1545
+ if (!packageJsonPath) continue;
1546
+ if (packageName === CORE_PACKAGE) return packageJsonPath;
1547
+ const corePackageJsonPath = resolvePackageJson(CORE_PACKAGE, packageJsonPath);
1548
+ if (corePackageJsonPath) return corePackageJsonPath;
1549
+ }
1550
+ return null;
1551
+ }
1552
+ function collectImportedDistributionPackages(ast) {
1553
+ const packages = /* @__PURE__ */ new Set();
1554
+ for (const statement of ast.program.body) {
1555
+ const source = (_babel_types.isImportDeclaration(statement) || _babel_types.isExportNamedDeclaration(statement) || _babel_types.isExportAllDeclaration(statement)) && statement.source ? statement.source.value : null;
1556
+ if (!source) continue;
1557
+ const packageName = packageNameFromSpecifier(source);
1558
+ if (packageName) packages.add(packageName);
1559
+ }
1560
+ return packages;
1561
+ }
1562
+ function packageNameFromSpecifier(specifier) {
1563
+ for (const packageName of DISTRIBUTION_PACKAGES) if (specifier === packageName || specifier.startsWith(`${packageName}/`)) return packageName;
1564
+ return null;
1565
+ }
1566
+ function resolvePackageJson(packageName, filename) {
1567
+ const requirePath = normalizeRequirePath(filename);
1568
+ const require = (0, node_module.createRequire)(requirePath);
1569
+ try {
1570
+ return findPackageJson(require.resolve(packageName), packageName);
1571
+ } catch {
1572
+ return findPackageJsonFromNodeModules(packageName, requirePath);
1573
+ }
1574
+ }
1575
+ function normalizeRequirePath(filename) {
1576
+ return cleanAbsoluteFilename(filename) ?? require("url").pathToFileURL(__filename).href;
1577
+ }
1578
+ /** Strips a `?query`/`#hash` suffix and returns the path only if it is absolute. */
1579
+ function cleanAbsoluteFilename(filename) {
1580
+ if (!filename) return null;
1581
+ const clean = filename.split(/[?#]/, 1)[0];
1582
+ return node_path.isAbsolute(clean) ? clean : null;
1583
+ }
1584
+ function findPackageJson(fromPathOrUrl, packageName) {
1585
+ let current = node_path.dirname(fromPathOrUrl.startsWith("file:") ? new URL(fromPathOrUrl).pathname : node_path.resolve(fromPathOrUrl));
1586
+ for (;;) {
1587
+ const packageJsonPath = node_path.join(current, "package.json");
1588
+ if (readPackageJson(packageJsonPath)?.name === packageName) return packageJsonPath;
1589
+ const parent = node_path.dirname(current);
1590
+ if (parent === current) return null;
1591
+ current = parent;
1592
+ }
1593
+ }
1594
+ function findPackageJsonFromNodeModules(packageName, fromPathOrUrl) {
1595
+ const parts = packageName.split("/");
1596
+ let current = node_path.dirname(fromPathOrUrl.startsWith("file:") ? new URL(fromPathOrUrl).pathname : node_path.resolve(fromPathOrUrl));
1597
+ for (;;) {
1598
+ const packageJsonPath = node_path.join(current, "node_modules", ...parts, "package.json");
1599
+ if (readPackageJson(packageJsonPath)?.name === packageName) return packageJsonPath;
1600
+ const parent = node_path.dirname(current);
1601
+ if (parent === current) return null;
1602
+ current = parent;
1603
+ }
1604
+ }
1605
+ function readPackageJson(packageJsonPath) {
1606
+ if (!(0, node_fs.existsSync)(packageJsonPath)) return null;
1607
+ try {
1608
+ return JSON.parse((0, node_fs.readFileSync)(packageJsonPath, "utf8"));
1609
+ } catch (error) {
1610
+ throw new GenerativeCompileError(`could not parse package metadata at ${packageJsonPath}: ${error instanceof Error ? error.message : String(error)}`);
1611
+ }
1612
+ }
1613
+ /**
1614
+ * Errors unless the module's default export is the toolkit — a `defineToolkit(...)`
1615
+ * call (through `satisfies`/`as`/parens). This is the security boundary: the
1616
+ * default export is what the runtime registers, so it must be wrapped (and thus
1617
+ * split). A bare `export default { ... }` would ship a backend `execute` to the
1618
+ * client even if some *other* `defineToolkit(...)` exists elsewhere in the file.
1619
+ */
1620
+ function ensureDefaultExport(ast, filename) {
1621
+ const def = ast.program.body.find((stmt) => _babel_types.isExportDefaultDeclaration(stmt));
1622
+ if (!def) throw new GenerativeCompileError("missing a default export", filename);
1623
+ if (!unwrapToToolkitCall(def.declaration)) throw new GenerativeCompileError(`the default export must be ${TOOLKIT_WRAPPER}({ ... }) or ${MCP_TOOLKIT_WRAPPER}({ ... }) (imported from "@assistant-ui/react"); wrapping is required so a backend \`execute\` can't be authored in a way that reaches the client`, filename);
1624
+ }
1625
+ /**
1626
+ * Unwraps a node through `satisfies`/`as`/parens to a call of the named function,
1627
+ * or returns `null`.
1628
+ */
1629
+ function unwrapToCall(node, name) {
1630
+ if (_babel_types.isTSSatisfiesExpression(node) || _babel_types.isTSAsExpression(node)) return unwrapToCall(node.expression, name);
1631
+ if (_babel_types.isParenthesizedExpression(node)) return unwrapToCall(node.expression, name);
1632
+ if (_babel_types.isCallExpression(node) && _babel_types.isIdentifier(node.callee, { name })) return node;
1633
+ return null;
1634
+ }
1635
+ /**
1636
+ * Collects the names bound to `new JSONGenerativeUI(...)` (e.g.
1637
+ * `const generative = new JSONGenerativeUI({ library })`). A toolkit entry that
1638
+ * calls a method on one of these is a generative tool whose halves the library
1639
+ * routes by export condition, so it passes through the toolkit pass untouched.
1640
+ */
1641
+ function collectGenerativeInstances(ast) {
1642
+ const names = /* @__PURE__ */ new Set();
1643
+ for (const statement of ast.program.body) {
1644
+ if (!_babel_types.isVariableDeclaration(statement)) continue;
1645
+ for (const declaration of statement.declarations) {
1646
+ const { id, init } = declaration;
1647
+ if (_babel_types.isIdentifier(id) && _babel_types.isNewExpression(init) && _babel_types.isIdentifier(init.callee, { name: GENERATIVE_FACTORY })) names.add(id.name);
1648
+ }
1649
+ }
1650
+ return names;
1651
+ }
1652
+ /**
1653
+ * Toolkit identifiers that are safe to spread into a `defineToolkit({ ... })`.
1654
+ *
1655
+ * Two kinds qualify:
1656
+ *
1657
+ * - A local variable whose initializer is visible to this compiler pass: a
1658
+ * `defineToolkit(...)` binding is compiled in-place before a later spread
1659
+ * reads it, and `defineMcpToolkit(...)` entries can't contain executable code.
1660
+ * - The default import of another `"use generative"` module: that module is
1661
+ * split per-target by its own compiler pass, so spreading its default-exported
1662
+ * toolkit can't leak a backend `execute` to the client. Only the default
1663
+ * export crosses the generative-module boundary, so named imports don't
1664
+ * qualify — they would be `undefined` once that module is build-split.
1665
+ */
1666
+ function collectSafeToolkitSpreads(ast, filename) {
1667
+ const names = /* @__PURE__ */ new Set();
1668
+ const generativeBySource = /* @__PURE__ */ new Map();
1669
+ for (const statement of ast.program.body) {
1670
+ if (_babel_types.isVariableDeclaration(statement)) {
1671
+ for (const declaration of statement.declarations) {
1672
+ const { id, init } = declaration;
1673
+ if (_babel_types.isIdentifier(id) && init && unwrapToToolkitCall(init)) names.add(id.name);
1674
+ }
1675
+ continue;
1676
+ }
1677
+ if (_babel_types.isImportDeclaration(statement)) {
1678
+ const defaultSpecifier = statement.specifiers.find((specifier) => _babel_types.isImportDefaultSpecifier(specifier));
1679
+ if (!defaultSpecifier) continue;
1680
+ const source = statement.source.value;
1681
+ let isGenerative = generativeBySource.get(source);
1682
+ if (isGenerative === void 0) {
1683
+ isGenerative = isGenerativeImport(source, filename);
1684
+ generativeBySource.set(source, isGenerative);
1685
+ }
1686
+ if (isGenerative) names.add(defaultSpecifier.local.name);
1687
+ }
1688
+ }
1689
+ return names;
1690
+ }
1691
+ const MODULE_EXTENSIONS = [
1692
+ ".ts",
1693
+ ".tsx",
1694
+ ".mts",
1695
+ ".cts",
1696
+ ".js",
1697
+ ".jsx",
1698
+ ".mjs",
1699
+ ".cjs"
1700
+ ];
1701
+ /** Extensions a specifier may carry that actually map to a TS source file. */
1702
+ const REWRITABLE_JS_EXTENSIONS = new Set([
1703
+ ".js",
1704
+ ".jsx",
1705
+ ".mjs",
1706
+ ".cjs"
1707
+ ]);
1708
+ /**
1709
+ * Whether an import specifier resolves on disk to a `"use generative"` module.
1710
+ * Relative specifiers and `tsconfig` path aliases (e.g. `@/tools`) are resolved;
1711
+ * anything else (a bare package, an unresolvable alias) is treated as
1712
+ * non-generative, and thus an unsafe spread.
1713
+ */
1714
+ function isGenerativeImport(source, filename) {
1715
+ const cleanFilename = cleanAbsoluteFilename(filename);
1716
+ if (!cleanFilename) return false;
1717
+ const resolved = resolveImportedModuleFile(source, cleanFilename);
1718
+ if (!resolved) return false;
1719
+ try {
1720
+ return isGenerativeModule((0, node_fs.readFileSync)(resolved, "utf8"));
1721
+ } catch {
1722
+ return false;
1723
+ }
1724
+ }
1725
+ /** Resolves an import specifier (relative or `tsconfig`-aliased) to a file on disk. */
1726
+ function resolveImportedModuleFile(source, fromFilename) {
1727
+ if (source.startsWith(".")) return resolveModuleFileAtPath(node_path.resolve(node_path.dirname(fromFilename), source));
1728
+ return resolveAliasImport(source, fromFilename);
1729
+ }
1730
+ /**
1731
+ * Resolves a candidate module path, trying TS/JS extensions then index files. A
1732
+ * specifier may carry a `.js`-family extension that maps to a `.ts`/`.tsx`
1733
+ * source (TypeScript's `bundler`/`nodenext` resolution), so the extension is
1734
+ * dropped before probing.
1735
+ */
1736
+ function resolveModuleFileAtPath(base) {
1737
+ const ext = node_path.extname(base);
1738
+ if (ext && (0, node_fs.existsSync)(base)) return base;
1739
+ const stem = REWRITABLE_JS_EXTENSIONS.has(ext) ? base.slice(0, -ext.length) : base;
1740
+ for (const candidateExt of MODULE_EXTENSIONS) {
1741
+ const candidate = `${stem}${candidateExt}`;
1742
+ if ((0, node_fs.existsSync)(candidate)) return candidate;
1743
+ }
1744
+ for (const candidateExt of MODULE_EXTENSIONS) {
1745
+ const candidate = node_path.join(base, `index${candidateExt}`);
1746
+ if ((0, node_fs.existsSync)(candidate)) return candidate;
1747
+ }
1748
+ return null;
1749
+ }
1750
+ /** Resolves a `tsconfig` path alias (e.g. `@/tools/x`) to a file on disk. */
1751
+ function resolveAliasImport(source, fromFilename) {
1752
+ const tsconfig = loadTsconfigAliases(node_path.dirname(fromFilename));
1753
+ if (!tsconfig) return null;
1754
+ const patterns = Object.entries(tsconfig.paths).sort(([a], [b]) => aliasSpecificity(b) - aliasSpecificity(a));
1755
+ for (const [pattern, targets] of patterns) {
1756
+ const matched = matchAliasPattern(pattern, source);
1757
+ if (matched === null) continue;
1758
+ for (const target of targets) {
1759
+ const specifier = substituteAliasWildcard(target, matched);
1760
+ const file = resolveModuleFileAtPath(node_path.resolve(tsconfig.baseDir, specifier));
1761
+ if (file) return file;
1762
+ }
1763
+ }
1764
+ return null;
1765
+ }
1766
+ /** Ranks a `paths` key: an exact key outranks any wildcard; longer prefixes win. */
1767
+ function aliasSpecificity(pattern) {
1768
+ const star = pattern.indexOf("*");
1769
+ return star === -1 ? pattern.length + 1 : star;
1770
+ }
1771
+ /** Substitutes the single `*` in a `paths` target with the matched text. */
1772
+ function substituteAliasWildcard(target, matched) {
1773
+ const star = target.indexOf("*");
1774
+ if (star === -1) return target;
1775
+ return target.slice(0, star) + matched + target.slice(star + 1);
1776
+ }
1777
+ /**
1778
+ * Matches an import specifier against a `tsconfig` `paths` key. Returns the text
1779
+ * captured by the key's `*` (or `""` for an exact, wildcard-free key), or `null`
1780
+ * when the specifier doesn't match.
1781
+ */
1782
+ function matchAliasPattern(pattern, source) {
1783
+ const star = pattern.indexOf("*");
1784
+ if (star === -1) return pattern === source ? "" : null;
1785
+ const prefix = pattern.slice(0, star);
1786
+ const suffix = pattern.slice(star + 1);
1787
+ if (source.length >= prefix.length + suffix.length && source.startsWith(prefix) && source.endsWith(suffix)) return source.slice(prefix.length, source.length - suffix.length);
1788
+ return null;
1789
+ }
1790
+ /**
1791
+ * Memoizes resolved aliases per start directory. The compiler runs once per
1792
+ * file across a build, so without this every aliased spread re-walks and
1793
+ * re-parses the same `tsconfig.json`. Process-lifetime, like
1794
+ * `checkedCorePackageJsonPaths`.
1795
+ */
1796
+ const tsconfigAliasesByDir = /* @__PURE__ */ new Map();
1797
+ /** Walks up from a directory to the nearest `tsconfig.json` that declares `paths`. */
1798
+ function loadTsconfigAliases(fromDir) {
1799
+ const cached = tsconfigAliasesByDir.get(fromDir);
1800
+ if (cached !== void 0) return cached;
1801
+ let aliases = null;
1802
+ let dir = fromDir;
1803
+ for (;;) {
1804
+ const tsconfigPath = node_path.join(dir, "tsconfig.json");
1805
+ if ((0, node_fs.existsSync)(tsconfigPath)) {
1806
+ aliases = readTsconfigAliases(tsconfigPath, /* @__PURE__ */ new Set());
1807
+ if (aliases) break;
1808
+ }
1809
+ const parent = node_path.dirname(dir);
1810
+ if (parent === dir) break;
1811
+ dir = parent;
1812
+ }
1813
+ tsconfigAliasesByDir.set(fromDir, aliases);
1814
+ return aliases;
1815
+ }
1816
+ /** Reads `baseUrl`/`paths` from a tsconfig, following a single `extends` chain. */
1817
+ function readTsconfigAliases(tsconfigPath, seen) {
1818
+ if (seen.has(tsconfigPath)) return null;
1819
+ seen.add(tsconfigPath);
1820
+ let config;
1821
+ try {
1822
+ config = parseJsonc((0, node_fs.readFileSync)(tsconfigPath, "utf8"));
1823
+ } catch {
1824
+ return null;
1825
+ }
1826
+ if (!config) return null;
1827
+ const configDir = node_path.dirname(tsconfigPath);
1828
+ const { baseUrl, paths } = config.compilerOptions ?? {};
1829
+ if (paths) return {
1830
+ baseDir: baseUrl ? node_path.resolve(configDir, baseUrl) : configDir,
1831
+ paths
1832
+ };
1833
+ const extendsList = Array.isArray(config.extends) ? config.extends : config.extends ? [config.extends] : [];
1834
+ for (let i = extendsList.length - 1; i >= 0; i--) {
1835
+ const entry = extendsList[i];
1836
+ if (typeof entry !== "string") continue;
1837
+ const extended = resolveExtendedTsconfig(entry, configDir);
1838
+ if (extended) {
1839
+ const aliases = readTsconfigAliases(extended, seen);
1840
+ if (aliases) return aliases;
1841
+ }
1842
+ }
1843
+ return null;
1844
+ }
1845
+ /** Resolves a tsconfig `extends` value (relative path or installed package). */
1846
+ function resolveExtendedTsconfig(extendsValue, configDir) {
1847
+ if (extendsValue.startsWith(".")) {
1848
+ const base = node_path.resolve(configDir, extendsValue);
1849
+ return (node_path.extname(base) === ".json" ? [base] : [`${base}.json`, base]).find((candidate) => (0, node_fs.existsSync)(candidate)) ?? null;
1850
+ }
1851
+ try {
1852
+ return (0, node_module.createRequire)(node_path.join(configDir, "package.json")).resolve(extendsValue.endsWith(".json") ? extendsValue : `${extendsValue}.json`);
1853
+ } catch {
1854
+ return null;
1855
+ }
1856
+ }
1857
+ /** Parses JSON with `//` and block comments and trailing commas stripped (tsconfig is JSONC). */
1858
+ function parseJsonc(text) {
1859
+ const withoutTrailingCommas = text.replace(/"(?:[^"\\]|\\.)*"|\/\/[^\n\r]*|\/\*[\s\S]*?\*\//g, (match) => match.startsWith("\"") ? match : "").replace(/,(\s*[}\]])/g, "$1");
1860
+ return JSON.parse(withoutTrailingCommas);
1861
+ }
1862
+ function unwrapToToolkitCall(node) {
1863
+ return unwrapToCall(node, TOOLKIT_WRAPPER) ?? unwrapToCall(node, MCP_TOOLKIT_WRAPPER);
1864
+ }
1865
+ function isSafeToolkitSpread(entry, safeToolkitSpreads) {
1866
+ if (_babel_types.isIdentifier(entry.argument)) return safeToolkitSpreads.has(entry.argument.name);
1867
+ const directMcpToolkit = unwrapToCall(entry.argument, MCP_TOOLKIT_WRAPPER);
1868
+ return !!directMcpToolkit && _babel_types.isObjectExpression(directMcpToolkit.arguments[0]);
1869
+ }
1870
+ /** The `JSONGenerativeUI` methods that produce a split-by-condition tool. */
1871
+ const GENERATIVE_TOOL_METHODS = new Set(["present", "promptUser"]);
1872
+ /**
1873
+ * Whether a toolkit entry's value is a call to a tool-producing method on a
1874
+ * collected `JSONGenerativeUI` instance (`generative.present()`), which passes
1875
+ * through. The method name is checked too, so a typo like `generative.presnt()`
1876
+ * is a compile error here rather than a pass-through that fails at runtime.
1877
+ */
1878
+ function isGenerativeToolEntry(value, instances) {
1879
+ return _babel_types.isCallExpression(value) && _babel_types.isMemberExpression(value.callee) && !value.callee.computed && _babel_types.isIdentifier(value.callee.object) && instances.has(value.callee.object.name) && _babel_types.isIdentifier(value.callee.property) && GENERATIVE_TOOL_METHODS.has(value.callee.property.name);
1880
+ }
1881
+ /**
1882
+ * Splits a `defineGenerativeComponents({ ... })` library for a build target:
1883
+ * a component's `render` (and the client imports it alone uses) is dropped on
1884
+ * the server; `properties`/`description` stay on both, since they drive the tool
1885
+ * schema either way. Mutates the object in place.
1886
+ */
1887
+ function compileComponents(object, target, flags, filename) {
1888
+ for (const entry of object.properties) {
1889
+ const value = entryValue(entry);
1890
+ if (!value) throw new GenerativeCompileError(`each component in ${COMPONENTS_WRAPPER}() must be an inline object literal (\`name: { ... }\`) so its \`render\` can be routed`, filename);
1891
+ if (!findMember(value, "render")) continue;
1892
+ if (target === "client") flags.keptRender = true;
1893
+ else removeMember(value, "render");
1894
+ }
1895
+ }
1896
+ /**
1897
+ * Splits a `defineToolkit({ ... })` for a build target. Each inline tool is
1898
+ * routed by inferred type (see the per-entry logic); a generative entry like
1899
+ * `generative.present()` passes through, the library having already split it.
1900
+ * Mutates the object in place and records outcomes in {@link TargetFlags}.
1901
+ */
1902
+ function compileToolkit(object, target, instances, safeToolkitSpreads, flags, filename) {
1903
+ const nextProperties = [];
1904
+ for (const entry of object.properties) {
1905
+ const value = entryValue(entry);
1906
+ if (!value) {
1907
+ if (_babel_types.isSpreadElement(entry) && isSafeToolkitSpread(entry, safeToolkitSpreads)) {
1908
+ nextProperties.push(entry);
1909
+ continue;
1910
+ }
1911
+ const raw = entryRawValue(entry);
1912
+ if (raw && isGenerativeToolEntry(raw, instances)) {
1913
+ nextProperties.push(entry);
1914
+ continue;
1915
+ }
1916
+ throw new GenerativeCompileError("each tool must be an inline object literal (`name: { ... }`) or a compiler-visible toolkit spread / generative tool (e.g. `...defineMcpToolkit(...)`, `...baseToolkit`, or `generative.present()`) so its `execute` can be routed", filename);
1917
+ }
1918
+ const execute = findMember(value, "execute");
1919
+ const isStub = execute ? executeIsStubTool(execute) : false;
1920
+ const isExternal = execute ? executeIsExternalTool(execute) : false;
1921
+ const type = inferToolType(value, filename);
1922
+ const hasRender = !!findMember(value, "render");
1923
+ const hasRenderText = !!findMember(value, "renderText");
1924
+ if (type === "frontend" && !hasRender && !hasRenderText) throw new GenerativeCompileError("a frontend tool must declare a `render` or `renderText` (it has no server execute to show otherwise)", filename);
1925
+ if (type === "human" && !hasRender) throw new GenerativeCompileError("a human tool must declare a `render` so it can collect input", filename);
1926
+ if (type === "provider" && execute) applyProviderToolConfig(value, execute, filename);
1927
+ if (isExternal) {
1928
+ if (!hasRender && !hasRenderText) throw new GenerativeCompileError("an external tool must declare a `render` or `renderText` (assistant-ui only renders calls for tools defined elsewhere)", filename);
1929
+ if (target === "server") continue;
1930
+ stripExternalToolMetadata(value);
1931
+ }
1932
+ if (target === "client") {
1933
+ if (execute && type === "frontend" && !isStub) stripUseClient(execute);
1934
+ else if (execute) removeMember(value, "execute");
1935
+ if (hasRender || hasRenderText) flags.keptRender = true;
1936
+ } else {
1937
+ if (hasRender) removeMember(value, "render");
1938
+ if (hasRenderText) removeMember(value, "renderText");
1939
+ if (execute) if (type === "backend" && !isExternal) flags.keptBackendExecute = true;
1940
+ else removeMember(value, "execute");
1941
+ }
1942
+ setToolType(value, type);
1943
+ setBackendDefault(value, target, type);
1944
+ nextProperties.push(entry);
1945
+ }
1946
+ object.properties = nextProperties;
1947
+ }
1948
+ function applyProviderToolConfig(object, execute, filename) {
1949
+ if (!_babel_types.isObjectProperty(execute) || !_babel_types.isCallExpression(execute.value) || execute.value.arguments.length !== 1 || !_babel_types.isObjectExpression(execute.value.arguments[0])) throw new GenerativeCompileError("`providerTool(...)` must receive an inline object literal", filename);
1950
+ const existingNames = new Set(object.properties.flatMap((prop) => {
1951
+ if (!_babel_types.isObjectProperty(prop) && !_babel_types.isObjectMethod(prop)) return [];
1952
+ const name = memberName(prop.key, prop.computed);
1953
+ return name ? [name] : [];
1954
+ }));
1955
+ const configNames = /* @__PURE__ */ new Set();
1956
+ for (const prop of execute.value.arguments[0].properties) {
1957
+ if (!_babel_types.isObjectProperty(prop)) throw new GenerativeCompileError("`providerTool(...)` config can only contain object properties", filename);
1958
+ const name = memberName(prop.key, prop.computed);
1959
+ if (!name) throw new GenerativeCompileError("`providerTool(...)` config can only contain static property names", filename);
1960
+ if (_babel_types.isFunctionExpression(prop.value) || _babel_types.isArrowFunctionExpression(prop.value)) throw new GenerativeCompileError("`providerTool(...)` config cannot contain function-valued properties", filename);
1961
+ if (existingNames.has(name) || configNames.has(name)) throw new GenerativeCompileError("`providerTool(...)` config cannot duplicate tool properties", filename);
1962
+ configNames.add(name);
1963
+ object.properties.push(prop);
1964
+ }
1965
+ }
1966
+ /** The raw AST value of an entry (any expression), or null for spreads/methods. */
1967
+ function entryRawValue(entry) {
1968
+ if (_babel_types.isObjectProperty(entry) && _babel_types.isExpression(entry.value)) return entry.value;
1969
+ return null;
1970
+ }
1971
+ function entryValue(entry) {
1972
+ if (_babel_types.isObjectProperty(entry) && _babel_types.isObjectExpression(entry.value)) return entry.value;
1973
+ return null;
1974
+ }
1975
+ /** A member of an entry object: `render`/`execute`/`type`, as property or method. */
1976
+ function findMember(object, name) {
1977
+ return object.properties.find((p) => (_babel_types.isObjectProperty(p) || _babel_types.isObjectMethod(p)) && memberName(p.key, p.computed) === name);
1978
+ }
1979
+ function removeMember(object, name) {
1980
+ object.properties = object.properties.filter((p) => !((_babel_types.isObjectProperty(p) || _babel_types.isObjectMethod(p)) && memberName(p.key, p.computed) === name));
1981
+ }
1982
+ /** The `BlockStatement` body of an `execute` member, if it has one. */
1983
+ function executeBody(member) {
1984
+ if (_babel_types.isObjectMethod(member)) return member.body;
1985
+ const value = member.value;
1986
+ if ((_babel_types.isArrowFunctionExpression(value) || _babel_types.isFunctionExpression(value)) && _babel_types.isBlockStatement(value.body)) return value.body;
1987
+ }
1988
+ /** Whether an `execute` opts into the client via a leading `"use client"`. */
1989
+ function executeIsClient(member) {
1990
+ return !!executeBody(member)?.directives.some((d) => d.value.value === "use client");
1991
+ }
1992
+ function executeIsSentinel(member, name) {
1993
+ return _babel_types.isObjectProperty(member) && _babel_types.isCallExpression(member.value) && _babel_types.isIdentifier(member.value.callee, { name });
1994
+ }
1995
+ /** Whether an `execute` is the human-in-the-loop sentinel. */
1996
+ function executeIsHumanTool(member) {
1997
+ return executeIsSentinel(member, "humanTool") || executeIsSentinel(member, "hitlTool") || executeIsSentinel(member, "hitl");
1998
+ }
1999
+ /** Whether an `execute` is the provider-tool sentinel. */
2000
+ function executeIsProviderTool(member) {
2001
+ return executeIsSentinel(member, "providerTool");
2002
+ }
2003
+ /** Whether an `execute` is the local override sentinel. */
2004
+ function executeIsStubTool(member) {
2005
+ return executeIsSentinel(member, "stubTool");
2006
+ }
2007
+ /** Whether an `execute` is the externally-defined backend tool sentinel. */
2008
+ function executeIsExternalTool(member) {
2009
+ return executeIsSentinel(member, "externalTool");
2010
+ }
2011
+ /** Drops the `"use client"` directive from an `execute` body (kept frontend). */
2012
+ function stripUseClient(member) {
2013
+ const body = executeBody(member);
2014
+ if (body) body.directives = body.directives.filter((d) => d.value.value !== "use client");
2015
+ }
2016
+ /**
2017
+ * The tool's nature, inferred from its (mandatory) `execute` rather than an
2018
+ * authored `type`: `humanTool()` → `human`; `providerTool(...)` → `provider`;
2019
+ * `stubTool()` → `frontend`; `externalTool()` → `backend`; `"use client"` →
2020
+ * `frontend`; otherwise `backend`.
2021
+ * The loader writes the result back as a `type` field (see {@link setToolType})
2022
+ * so the runtime keeps it.
2023
+ */
2024
+ function inferToolType(object, filename) {
2025
+ const execute = findMember(object, "execute");
2026
+ if (!execute) throw new GenerativeCompileError("every tool must declare an `execute`; use `humanTool()` for a human-in-the-loop tool", filename);
2027
+ if (executeIsHumanTool(execute)) return "human";
2028
+ if (executeIsProviderTool(execute)) return "provider";
2029
+ if (executeIsStubTool(execute)) return "frontend";
2030
+ if (executeIsExternalTool(execute)) return "backend";
2031
+ return executeIsClient(execute) ? "frontend" : "backend";
2032
+ }
2033
+ function stripExternalToolMetadata(object) {
2034
+ removeMember(object, "description");
2035
+ removeMember(object, "parameters");
2036
+ removeMember(object, "disabled");
2037
+ removeMember(object, "toModelOutput");
2038
+ removeMember(object, "experimental_onSchemaValidationError");
2039
+ removeMember(object, "providerOptions");
2040
+ removeMember(object, "streamCall");
2041
+ }
2042
+ /** Writes the resolved `type` back onto the tool object (replacing any author's). */
2043
+ function setToolType(object, type) {
2044
+ removeMember(object, "type");
2045
+ object.properties.push(_babel_types.objectProperty(_babel_types.identifier("type"), _babel_types.stringLiteral(type)));
2046
+ }
2047
+ function setBackendDefault(object, target, type) {
2048
+ removeMember(object, "unstable_backendDefault");
2049
+ if (target !== "client" || type !== "frontend" && type !== "human") return;
2050
+ object.properties.push(_babel_types.objectProperty(_babel_types.identifier("unstable_backendDefault"), _babel_types.objectExpression([_babel_types.objectProperty(_babel_types.identifier("parameters"), _babel_types.booleanLiteral(true))])));
2051
+ }
2052
+ function memberName(key, computed) {
2053
+ if (computed) return void 0;
2054
+ if (_babel_types.isIdentifier(key)) return key.name;
2055
+ if (_babel_types.isStringLiteral(key)) return key.value;
2056
+ }
2057
+ /**
2058
+ * Removes declarations and import specifiers left unreferenced after region
2059
+ * removal, to a fixpoint (a dropped helper frees what it used). Keeps exports,
2060
+ * side-effect imports, and possibly-side-effectful initializers.
2061
+ */
2062
+ function pruneUnused(ast) {
2063
+ const hadSpecifiers = /* @__PURE__ */ new WeakSet();
2064
+ for (const stmt of ast.program.body) if (_babel_types.isImportDeclaration(stmt) && stmt.specifiers.length > 0) hadSpecifiers.add(stmt);
2065
+ let removedSomething = true;
2066
+ while (removedSomething) {
2067
+ removedSomething = false;
2068
+ traverse(ast, { Program(path) {
2069
+ path.scope.crawl();
2070
+ const isUnused = (name) => {
2071
+ const binding = path.scope.getBinding(name);
2072
+ return !!binding && !binding.referenced;
2073
+ };
2074
+ path.node.body = path.node.body.filter((stmt) => {
2075
+ if ((_babel_types.isFunctionDeclaration(stmt) || _babel_types.isClassDeclaration(stmt)) && stmt.id && isUnused(stmt.id.name)) {
2076
+ removedSomething = true;
2077
+ return false;
2078
+ }
2079
+ if (_babel_types.isVariableDeclaration(stmt)) {
2080
+ stmt.declarations = stmt.declarations.filter((decl) => {
2081
+ const names = Object.keys(_babel_types.getBindingIdentifiers(decl.id));
2082
+ if (names.length > 0 && isPlainPattern(decl.id) && isRemovableInit(decl.init) && names.every(isUnused)) {
2083
+ removedSomething = true;
2084
+ return false;
2085
+ }
2086
+ return true;
2087
+ });
2088
+ if (stmt.declarations.length === 0) return false;
2089
+ }
2090
+ return true;
2091
+ });
2092
+ path.stop();
2093
+ } });
2094
+ }
2095
+ traverse(ast, { Program(path) {
2096
+ path.scope.crawl();
2097
+ for (const stmt of path.node.body) {
2098
+ if (!_babel_types.isImportDeclaration(stmt)) continue;
2099
+ stmt.specifiers = stmt.specifiers.filter((spec) => {
2100
+ const binding = path.scope.getBinding(spec.local.name);
2101
+ return binding ? binding.referenced : true;
2102
+ });
2103
+ }
2104
+ path.node.body = path.node.body.filter((stmt) => !(_babel_types.isImportDeclaration(stmt) && stmt.specifiers.length === 0 && hadSpecifiers.has(stmt)));
2105
+ path.stop();
2106
+ } });
2107
+ }
2108
+ /**
2109
+ * Whether a binding pattern is side-effect-free to drop: a plain identifier, or
2110
+ * an object/array pattern of plain bindings — no default values
2111
+ * (`{ a = expr }`) or computed keys (`{ [expr]: a }`), which would evaluate (and
2112
+ * thus could have side effects) at destructuring time.
2113
+ */
2114
+ function isPlainPattern(node) {
2115
+ if (_babel_types.isIdentifier(node)) return true;
2116
+ if (_babel_types.isObjectPattern(node)) return node.properties.every((p) => _babel_types.isRestElement(p) ? isPlainPattern(p.argument) : !p.computed && isPlainPattern(p.value));
2117
+ if (_babel_types.isArrayPattern(node)) return node.elements.every((el) => el == null || isPlainPattern(el));
2118
+ return false;
2119
+ }
2120
+ /** Whether a variable initializer is safe to drop (no observable side effects). */
2121
+ function isRemovableInit(node) {
2122
+ if (node == null) return true;
2123
+ if (_babel_types.isTSAsExpression(node) || _babel_types.isTSSatisfiesExpression(node)) return isRemovableInit(node.expression);
2124
+ if (_babel_types.isArrayExpression(node)) return node.elements.every((el) => el == null || _babel_types.isExpression(el) && isRemovableInit(el));
2125
+ if (_babel_types.isObjectExpression(node)) return node.properties.every((p) => _babel_types.isObjectProperty(p) && !p.computed && _babel_types.isExpression(p.value) && isRemovableInit(p.value));
2126
+ if (_babel_types.isTemplateLiteral(node)) return node.expressions.every((e) => _babel_types.isExpression(e) && isRemovableInit(e));
2127
+ return _babel_types.isArrowFunctionExpression(node) || _babel_types.isFunctionExpression(node) || _babel_types.isClassExpression(node) || _babel_types.isIdentifier(node) || _babel_types.isMemberExpression(node) && !node.computed || _babel_types.isJSXElement(node) || _babel_types.isJSXFragment(node) || _babel_types.isLiteral(node);
2128
+ }
2129
+ //#endregion
2130
+ //#region src/transformer.ts
2131
+ const require$1 = (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href);
2132
+ /** Source modules a `"use generative"` directive can appear in. */
2133
+ const SOURCE_RE = /\.[cm]?[jt]sx?$/;
2134
+ /**
2135
+ * The project's upstream babel transformer: what Metro would have used without
2136
+ * this wrapper. Taken from {@link UPSTREAM_TRANSFORMER_ENV} (set by `withAui`),
2137
+ * else auto-detected: Expo's transformer, then React Native's.
2138
+ */
2139
+ function resolveUpstream() {
2140
+ const fromEnv = process.env[require_index.UPSTREAM_TRANSFORMER_ENV];
2141
+ if (fromEnv) return require$1(fromEnv);
2142
+ for (const id of ["@expo/metro-config/babel-transformer", "@react-native/metro-babel-transformer"]) try {
2143
+ return require$1(id);
2144
+ } catch {}
2145
+ throw new Error("[@assistant-ui/metro] Could not resolve an upstream Metro babel transformer. Make sure `transformer.babelTransformerPath` is set before `withAui(...)` (Expo's `getDefaultConfig` sets it), or install `@expo/metro-config` or `@react-native/metro-babel-transformer`.");
2146
+ }
2147
+ let cachedUpstream;
2148
+ function upstreamTransformer() {
2149
+ return cachedUpstream ??= resolveUpstream();
2150
+ }
2151
+ /** Expo bundles `+api` routes / RSC for a server environment; the app is client. */
2152
+ function isServerEnvironment(environment) {
2153
+ return environment === "node" || environment === "react-server";
2154
+ }
2155
+ function transform(props) {
2156
+ const upstream = upstreamTransformer();
2157
+ const { filename, src, options } = props;
2158
+ if (SOURCE_RE.test(filename) && isGenerativeModule(src)) {
2159
+ const { code } = compileGenerative(src, {
2160
+ target: isServerEnvironment(options?.customTransformOptions?.environment) ? "server" : "client",
2161
+ filename,
2162
+ injectServerOnly: false
2163
+ });
2164
+ return upstream.transform({
2165
+ ...props,
2166
+ src: code
2167
+ });
2168
+ }
2169
+ return upstream.transform(props);
2170
+ }
2171
+ let cachedSelfToken;
2172
+ function selfCacheToken() {
2173
+ if (cachedSelfToken !== void 0) return cachedSelfToken;
2174
+ try {
2175
+ cachedSelfToken = String((0, node_fs.statSync)((0, node_url.fileURLToPath)(require("url").pathToFileURL(__filename).href)).mtimeMs);
2176
+ } catch {
2177
+ cachedSelfToken = "0";
2178
+ }
2179
+ return cachedSelfToken;
2180
+ }
2181
+ function getCacheKey() {
2182
+ const upstream = upstreamTransformer();
2183
+ return `${upstream.getCacheKey ? upstream.getCacheKey() : ""}$aui-metro:${selfCacheToken()}`;
2184
+ }
2185
+ //#endregion
2186
+ exports.getCacheKey = getCacheKey;
2187
+ exports.transform = transform;
2188
+
2189
+ //# sourceMappingURL=transformer.cjs.map