@fern-api/typescript-dynamic-snippets 0.0.5 → 0.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3444 +1,20 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7
- var __esm = (fn, res) => function __init() {
8
- return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
9
- };
10
- var __export = (target, all) => {
11
- for (var name in all)
12
- __defProp(target, name, { get: all[name], enumerable: true });
13
- };
14
- var __copyProps = (to, from2, except, desc) => {
15
- if (from2 && typeof from2 === "object" || typeof from2 === "function") {
16
- for (let key of __getOwnPropNames(from2))
17
- if (!__hasOwnProp.call(to, key) && key !== except)
18
- __defProp(to, key, { get: () => from2[key], enumerable: !(desc = __getOwnPropDesc(from2, key)) || desc.enumerable });
19
- }
20
- return to;
21
- };
22
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
23
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
24
-
25
- // ../../../node_modules/.pnpm/@esbuild-plugins+node-globals-polyfill@0.2.3_esbuild@0.24.0/node_modules/@esbuild-plugins/node-globals-polyfill/process.js
26
- function defaultSetTimout() {
27
- throw new Error("setTimeout has not been defined");
28
- }
29
- function defaultClearTimeout() {
30
- throw new Error("clearTimeout has not been defined");
31
- }
32
- function runTimeout(fun) {
33
- if (cachedSetTimeout === setTimeout) {
34
- return setTimeout(fun, 0);
35
- }
36
- if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
37
- cachedSetTimeout = setTimeout;
38
- return setTimeout(fun, 0);
39
- }
40
- try {
41
- return cachedSetTimeout(fun, 0);
42
- } catch (e) {
43
- try {
44
- return cachedSetTimeout.call(null, fun, 0);
45
- } catch (e2) {
46
- return cachedSetTimeout.call(this, fun, 0);
47
- }
48
- }
49
- }
50
- function runClearTimeout(marker) {
51
- if (cachedClearTimeout === clearTimeout) {
52
- return clearTimeout(marker);
53
- }
54
- if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
55
- cachedClearTimeout = clearTimeout;
56
- return clearTimeout(marker);
57
- }
58
- try {
59
- return cachedClearTimeout(marker);
60
- } catch (e) {
61
- try {
62
- return cachedClearTimeout.call(null, marker);
63
- } catch (e2) {
64
- return cachedClearTimeout.call(this, marker);
65
- }
66
- }
67
- }
68
- function cleanUpNextTick() {
69
- if (!draining || !currentQueue) {
70
- return;
71
- }
72
- draining = false;
73
- if (currentQueue.length) {
74
- queue = currentQueue.concat(queue);
75
- } else {
76
- queueIndex = -1;
77
- }
78
- if (queue.length) {
79
- drainQueue();
80
- }
81
- }
82
- function drainQueue() {
83
- if (draining) {
84
- return;
85
- }
86
- var timeout = runTimeout(cleanUpNextTick);
87
- draining = true;
88
- var len = queue.length;
89
- while (len) {
90
- currentQueue = queue;
91
- queue = [];
92
- while (++queueIndex < len) {
93
- if (currentQueue) {
94
- currentQueue[queueIndex].run();
95
- }
96
- }
97
- queueIndex = -1;
98
- len = queue.length;
99
- }
100
- currentQueue = null;
101
- draining = false;
102
- runClearTimeout(timeout);
103
- }
104
- function nextTick(fun) {
105
- var args = new Array(arguments.length - 1);
106
- if (arguments.length > 1) {
107
- for (var i = 1; i < arguments.length; i++) {
108
- args[i - 1] = arguments[i];
109
- }
110
- }
111
- queue.push(new Item(fun, args));
112
- if (queue.length === 1 && !draining) {
113
- runTimeout(drainQueue);
114
- }
115
- }
116
- function Item(fun, array) {
117
- this.fun = fun;
118
- this.array = array;
119
- }
120
- function noop() {
121
- }
122
- function binding(name) {
123
- throw new Error("process.binding is not supported");
124
- }
125
- function cwd() {
126
- return "/";
127
- }
128
- function chdir(dir) {
129
- throw new Error("process.chdir is not supported");
130
- }
131
- function umask() {
132
- return 0;
133
- }
134
- function hrtime(previousTimestamp) {
135
- var clocktime = performanceNow.call(performance) * 1e-3;
136
- var seconds = Math.floor(clocktime);
137
- var nanoseconds = Math.floor(clocktime % 1 * 1e9);
138
- if (previousTimestamp) {
139
- seconds = seconds - previousTimestamp[0];
140
- nanoseconds = nanoseconds - previousTimestamp[1];
141
- if (nanoseconds < 0) {
142
- seconds--;
143
- nanoseconds += 1e9;
144
- }
145
- }
146
- return [seconds, nanoseconds];
147
- }
148
- function uptime() {
149
- var currentTime = /* @__PURE__ */ new Date();
150
- var dif = currentTime - startTime;
151
- return dif / 1e3;
152
- }
153
- var cachedSetTimeout, cachedClearTimeout, queue, draining, currentQueue, queueIndex, title, platform, browser, env, argv, version, versions, release, config, on, addListener, once, off, removeListener, removeAllListeners, emit, performance, performanceNow, startTime, process, defines;
154
- var init_process = __esm({
155
- "../../../node_modules/.pnpm/@esbuild-plugins+node-globals-polyfill@0.2.3_esbuild@0.24.0/node_modules/@esbuild-plugins/node-globals-polyfill/process.js"() {
156
- "use strict";
157
- cachedSetTimeout = defaultSetTimout;
158
- cachedClearTimeout = defaultClearTimeout;
159
- if (typeof globalThis.setTimeout === "function") {
160
- cachedSetTimeout = setTimeout;
161
- }
162
- if (typeof globalThis.clearTimeout === "function") {
163
- cachedClearTimeout = clearTimeout;
164
- }
165
- queue = [];
166
- draining = false;
167
- queueIndex = -1;
168
- Item.prototype.run = function() {
169
- this.fun.apply(null, this.array);
170
- };
171
- title = "browser";
172
- platform = "browser";
173
- browser = true;
174
- env = {};
175
- argv = [];
176
- version = "";
177
- versions = {};
178
- release = {};
179
- config = {};
180
- on = noop;
181
- addListener = noop;
182
- once = noop;
183
- off = noop;
184
- removeListener = noop;
185
- removeAllListeners = noop;
186
- emit = noop;
187
- performance = globalThis.performance || {};
188
- performanceNow = performance.now || performance.mozNow || performance.msNow || performance.oNow || performance.webkitNow || function() {
189
- return (/* @__PURE__ */ new Date()).getTime();
190
- };
191
- startTime = /* @__PURE__ */ new Date();
192
- process = {
193
- nextTick,
194
- title,
195
- browser,
196
- env,
197
- argv,
198
- version,
199
- versions,
200
- on,
201
- addListener,
202
- once,
203
- off,
204
- removeListener,
205
- removeAllListeners,
206
- emit,
207
- binding,
208
- cwd,
209
- chdir,
210
- umask,
211
- hrtime,
212
- platform,
213
- release,
214
- config,
215
- uptime
216
- };
217
- defines = {};
218
- Object.keys(defines).forEach((key) => {
219
- const segs = key.split(".");
220
- let target = process;
221
- for (let i = 0; i < segs.length; i++) {
222
- const seg = segs[i];
223
- if (i === segs.length - 1) {
224
- target[seg] = defines[key];
225
- } else {
226
- target = target[seg] || (target[seg] = {});
227
- }
228
- }
229
- });
230
- }
231
- });
232
-
233
- // ../../../node_modules/.pnpm/@esbuild-plugins+node-globals-polyfill@0.2.3_esbuild@0.24.0/node_modules/@esbuild-plugins/node-globals-polyfill/Buffer.js
234
- function init() {
235
- inited = true;
236
- var code = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
237
- for (var i = 0, len = code.length; i < len; ++i) {
238
- lookup[i] = code[i];
239
- revLookup[code.charCodeAt(i)] = i;
240
- }
241
- revLookup["-".charCodeAt(0)] = 62;
242
- revLookup["_".charCodeAt(0)] = 63;
243
- }
244
- function base64toByteArray(b64) {
245
- if (!inited) {
246
- init();
247
- }
248
- var i, j, l, tmp, placeHolders, arr;
249
- var len = b64.length;
250
- if (len % 4 > 0) {
251
- throw new Error("Invalid string. Length must be a multiple of 4");
252
- }
253
- placeHolders = b64[len - 2] === "=" ? 2 : b64[len - 1] === "=" ? 1 : 0;
254
- arr = new Arr(len * 3 / 4 - placeHolders);
255
- l = placeHolders > 0 ? len - 4 : len;
256
- var L = 0;
257
- for (i = 0, j = 0; i < l; i += 4, j += 3) {
258
- tmp = revLookup[b64.charCodeAt(i)] << 18 | revLookup[b64.charCodeAt(i + 1)] << 12 | revLookup[b64.charCodeAt(i + 2)] << 6 | revLookup[b64.charCodeAt(i + 3)];
259
- arr[L++] = tmp >> 16 & 255;
260
- arr[L++] = tmp >> 8 & 255;
261
- arr[L++] = tmp & 255;
262
- }
263
- if (placeHolders === 2) {
264
- tmp = revLookup[b64.charCodeAt(i)] << 2 | revLookup[b64.charCodeAt(i + 1)] >> 4;
265
- arr[L++] = tmp & 255;
266
- } else if (placeHolders === 1) {
267
- tmp = revLookup[b64.charCodeAt(i)] << 10 | revLookup[b64.charCodeAt(i + 1)] << 4 | revLookup[b64.charCodeAt(i + 2)] >> 2;
268
- arr[L++] = tmp >> 8 & 255;
269
- arr[L++] = tmp & 255;
270
- }
271
- return arr;
272
- }
273
- function tripletToBase64(num) {
274
- return lookup[num >> 18 & 63] + lookup[num >> 12 & 63] + lookup[num >> 6 & 63] + lookup[num & 63];
275
- }
276
- function encodeChunk(uint8, start, end) {
277
- var tmp;
278
- var output = [];
279
- for (var i = start; i < end; i += 3) {
280
- tmp = (uint8[i] << 16) + (uint8[i + 1] << 8) + uint8[i + 2];
281
- output.push(tripletToBase64(tmp));
282
- }
283
- return output.join("");
284
- }
285
- function base64fromByteArray(uint8) {
286
- if (!inited) {
287
- init();
288
- }
289
- var tmp;
290
- var len = uint8.length;
291
- var extraBytes = len % 3;
292
- var output = "";
293
- var parts = [];
294
- var maxChunkLength = 16383;
295
- for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
296
- parts.push(
297
- encodeChunk(
298
- uint8,
299
- i,
300
- i + maxChunkLength > len2 ? len2 : i + maxChunkLength
301
- )
302
- );
303
- }
304
- if (extraBytes === 1) {
305
- tmp = uint8[len - 1];
306
- output += lookup[tmp >> 2];
307
- output += lookup[tmp << 4 & 63];
308
- output += "==";
309
- } else if (extraBytes === 2) {
310
- tmp = (uint8[len - 2] << 8) + uint8[len - 1];
311
- output += lookup[tmp >> 10];
312
- output += lookup[tmp >> 4 & 63];
313
- output += lookup[tmp << 2 & 63];
314
- output += "=";
315
- }
316
- parts.push(output);
317
- return parts.join("");
318
- }
319
- function kMaxLength() {
320
- return Buffer2.TYPED_ARRAY_SUPPORT ? 2147483647 : 1073741823;
321
- }
322
- function createBuffer(that, length) {
323
- if (kMaxLength() < length) {
324
- throw new RangeError("Invalid typed array length");
325
- }
326
- if (Buffer2.TYPED_ARRAY_SUPPORT) {
327
- that = new Uint8Array(length);
328
- that.__proto__ = Buffer2.prototype;
329
- } else {
330
- if (that === null) {
331
- that = new Buffer2(length);
332
- }
333
- that.length = length;
334
- }
335
- return that;
336
- }
337
- function Buffer2(arg, encodingOrOffset, length) {
338
- if (!Buffer2.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer2)) {
339
- return new Buffer2(arg, encodingOrOffset, length);
340
- }
341
- if (typeof arg === "number") {
342
- if (typeof encodingOrOffset === "string") {
343
- throw new Error(
344
- "If encoding is specified then the first argument must be a string"
345
- );
346
- }
347
- return allocUnsafe(this, arg);
348
- }
349
- return from(this, arg, encodingOrOffset, length);
350
- }
351
- function from(that, value, encodingOrOffset, length) {
352
- if (typeof value === "number") {
353
- throw new TypeError('"value" argument must not be a number');
354
- }
355
- if (typeof ArrayBuffer !== "undefined" && value instanceof ArrayBuffer) {
356
- return fromArrayBuffer(that, value, encodingOrOffset, length);
357
- }
358
- if (typeof value === "string") {
359
- return fromString(that, value, encodingOrOffset);
360
- }
361
- return fromObject(that, value);
362
- }
363
- function assertSize(size) {
364
- if (typeof size !== "number") {
365
- throw new TypeError('"size" argument must be a number');
366
- } else if (size < 0) {
367
- throw new RangeError('"size" argument must not be negative');
368
- }
369
- }
370
- function alloc(that, size, fill2, encoding) {
371
- assertSize(size);
372
- if (size <= 0) {
373
- return createBuffer(that, size);
374
- }
375
- if (fill2 !== void 0) {
376
- return typeof encoding === "string" ? createBuffer(that, size).fill(fill2, encoding) : createBuffer(that, size).fill(fill2);
377
- }
378
- return createBuffer(that, size);
379
- }
380
- function allocUnsafe(that, size) {
381
- assertSize(size);
382
- that = createBuffer(that, size < 0 ? 0 : checked(size) | 0);
383
- if (!Buffer2.TYPED_ARRAY_SUPPORT) {
384
- for (var i = 0; i < size; ++i) {
385
- that[i] = 0;
386
- }
387
- }
388
- return that;
389
- }
390
- function fromString(that, string, encoding) {
391
- if (typeof encoding !== "string" || encoding === "") {
392
- encoding = "utf8";
393
- }
394
- if (!Buffer2.isEncoding(encoding)) {
395
- throw new TypeError('"encoding" must be a valid string encoding');
396
- }
397
- var length = byteLength(string, encoding) | 0;
398
- that = createBuffer(that, length);
399
- var actual = that.write(string, encoding);
400
- if (actual !== length) {
401
- that = that.slice(0, actual);
402
- }
403
- return that;
404
- }
405
- function fromArrayLike(that, array) {
406
- var length = array.length < 0 ? 0 : checked(array.length) | 0;
407
- that = createBuffer(that, length);
408
- for (var i = 0; i < length; i += 1) {
409
- that[i] = array[i] & 255;
410
- }
411
- return that;
412
- }
413
- function fromArrayBuffer(that, array, byteOffset, length) {
414
- array.byteLength;
415
- if (byteOffset < 0 || array.byteLength < byteOffset) {
416
- throw new RangeError("'offset' is out of bounds");
417
- }
418
- if (array.byteLength < byteOffset + (length || 0)) {
419
- throw new RangeError("'length' is out of bounds");
420
- }
421
- if (byteOffset === void 0 && length === void 0) {
422
- array = new Uint8Array(array);
423
- } else if (length === void 0) {
424
- array = new Uint8Array(array, byteOffset);
425
- } else {
426
- array = new Uint8Array(array, byteOffset, length);
427
- }
428
- if (Buffer2.TYPED_ARRAY_SUPPORT) {
429
- that = array;
430
- that.__proto__ = Buffer2.prototype;
431
- } else {
432
- that = fromArrayLike(that, array);
433
- }
434
- return that;
435
- }
436
- function fromObject(that, obj) {
437
- if (internalIsBuffer(obj)) {
438
- var len = checked(obj.length) | 0;
439
- that = createBuffer(that, len);
440
- if (that.length === 0) {
441
- return that;
442
- }
443
- obj.copy(that, 0, 0, len);
444
- return that;
445
- }
446
- if (obj) {
447
- if (typeof ArrayBuffer !== "undefined" && obj.buffer instanceof ArrayBuffer || "length" in obj) {
448
- if (typeof obj.length !== "number" || isnan(obj.length)) {
449
- return createBuffer(that, 0);
450
- }
451
- return fromArrayLike(that, obj);
452
- }
453
- if (obj.type === "Buffer" && Array.isArray(obj.data)) {
454
- return fromArrayLike(that, obj.data);
455
- }
456
- }
457
- throw new TypeError(
458
- "First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object."
459
- );
460
- }
461
- function checked(length) {
462
- if (length >= kMaxLength()) {
463
- throw new RangeError(
464
- "Attempt to allocate Buffer larger than maximum size: 0x" + kMaxLength().toString(16) + " bytes"
465
- );
466
- }
467
- return length | 0;
468
- }
469
- function internalIsBuffer(b) {
470
- return !!(b != null && b._isBuffer);
471
- }
472
- function byteLength(string, encoding) {
473
- if (internalIsBuffer(string)) {
474
- return string.length;
475
- }
476
- if (typeof ArrayBuffer !== "undefined" && typeof ArrayBuffer.isView === "function" && (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) {
477
- return string.byteLength;
478
- }
479
- if (typeof string !== "string") {
480
- string = "" + string;
481
- }
482
- var len = string.length;
483
- if (len === 0) return 0;
484
- var loweredCase = false;
485
- for (; ; ) {
486
- switch (encoding) {
487
- case "ascii":
488
- case "latin1":
489
- case "binary":
490
- return len;
491
- case "utf8":
492
- case "utf-8":
493
- case void 0:
494
- return utf8ToBytes(string).length;
495
- case "ucs2":
496
- case "ucs-2":
497
- case "utf16le":
498
- case "utf-16le":
499
- return len * 2;
500
- case "hex":
501
- return len >>> 1;
502
- case "base64":
503
- return base64ToBytes(string).length;
504
- default:
505
- if (loweredCase) return utf8ToBytes(string).length;
506
- encoding = ("" + encoding).toLowerCase();
507
- loweredCase = true;
508
- }
509
- }
510
- }
511
- function slowToString(encoding, start, end) {
512
- var loweredCase = false;
513
- if (start === void 0 || start < 0) {
514
- start = 0;
515
- }
516
- if (start > this.length) {
517
- return "";
518
- }
519
- if (end === void 0 || end > this.length) {
520
- end = this.length;
521
- }
522
- if (end <= 0) {
523
- return "";
524
- }
525
- end >>>= 0;
526
- start >>>= 0;
527
- if (end <= start) {
528
- return "";
529
- }
530
- if (!encoding) encoding = "utf8";
531
- while (true) {
532
- switch (encoding) {
533
- case "hex":
534
- return hexSlice(this, start, end);
535
- case "utf8":
536
- case "utf-8":
537
- return utf8Slice(this, start, end);
538
- case "ascii":
539
- return asciiSlice(this, start, end);
540
- case "latin1":
541
- case "binary":
542
- return latin1Slice(this, start, end);
543
- case "base64":
544
- return base64Slice(this, start, end);
545
- case "ucs2":
546
- case "ucs-2":
547
- case "utf16le":
548
- case "utf-16le":
549
- return utf16leSlice(this, start, end);
550
- default:
551
- if (loweredCase)
552
- throw new TypeError("Unknown encoding: " + encoding);
553
- encoding = (encoding + "").toLowerCase();
554
- loweredCase = true;
555
- }
556
- }
557
- }
558
- function swap(b, n, m) {
559
- var i = b[n];
560
- b[n] = b[m];
561
- b[m] = i;
562
- }
563
- function bidirectionalIndexOf(buffer, val, byteOffset, encoding, dir) {
564
- if (buffer.length === 0) return -1;
565
- if (typeof byteOffset === "string") {
566
- encoding = byteOffset;
567
- byteOffset = 0;
568
- } else if (byteOffset > 2147483647) {
569
- byteOffset = 2147483647;
570
- } else if (byteOffset < -2147483648) {
571
- byteOffset = -2147483648;
572
- }
573
- byteOffset = +byteOffset;
574
- if (isNaN(byteOffset)) {
575
- byteOffset = dir ? 0 : buffer.length - 1;
576
- }
577
- if (byteOffset < 0) byteOffset = buffer.length + byteOffset;
578
- if (byteOffset >= buffer.length) {
579
- if (dir) return -1;
580
- else byteOffset = buffer.length - 1;
581
- } else if (byteOffset < 0) {
582
- if (dir) byteOffset = 0;
583
- else return -1;
584
- }
585
- if (typeof val === "string") {
586
- val = Buffer2.from(val, encoding);
587
- }
588
- if (internalIsBuffer(val)) {
589
- if (val.length === 0) {
590
- return -1;
591
- }
592
- return arrayIndexOf(buffer, val, byteOffset, encoding, dir);
593
- } else if (typeof val === "number") {
594
- val = val & 255;
595
- if (Buffer2.TYPED_ARRAY_SUPPORT && typeof Uint8Array.prototype.indexOf === "function") {
596
- if (dir) {
597
- return Uint8Array.prototype.indexOf.call(
598
- buffer,
599
- val,
600
- byteOffset
601
- );
602
- } else {
603
- return Uint8Array.prototype.lastIndexOf.call(
604
- buffer,
605
- val,
606
- byteOffset
607
- );
608
- }
609
- }
610
- return arrayIndexOf(buffer, [val], byteOffset, encoding, dir);
611
- }
612
- throw new TypeError("val must be string, number or Buffer");
613
- }
614
- function arrayIndexOf(arr, val, byteOffset, encoding, dir) {
615
- var indexSize = 1;
616
- var arrLength = arr.length;
617
- var valLength = val.length;
618
- if (encoding !== void 0) {
619
- encoding = String(encoding).toLowerCase();
620
- if (encoding === "ucs2" || encoding === "ucs-2" || encoding === "utf16le" || encoding === "utf-16le") {
621
- if (arr.length < 2 || val.length < 2) {
622
- return -1;
623
- }
624
- indexSize = 2;
625
- arrLength /= 2;
626
- valLength /= 2;
627
- byteOffset /= 2;
628
- }
629
- }
630
- function read(buf, i2) {
631
- if (indexSize === 1) {
632
- return buf[i2];
633
- } else {
634
- return buf.readUInt16BE(i2 * indexSize);
635
- }
636
- }
637
- var i;
638
- if (dir) {
639
- var foundIndex = -1;
640
- for (i = byteOffset; i < arrLength; i++) {
641
- if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
642
- if (foundIndex === -1) foundIndex = i;
643
- if (i - foundIndex + 1 === valLength)
644
- return foundIndex * indexSize;
645
- } else {
646
- if (foundIndex !== -1) i -= i - foundIndex;
647
- foundIndex = -1;
648
- }
649
- }
650
- } else {
651
- if (byteOffset + valLength > arrLength)
652
- byteOffset = arrLength - valLength;
653
- for (i = byteOffset; i >= 0; i--) {
654
- var found = true;
655
- for (var j = 0; j < valLength; j++) {
656
- if (read(arr, i + j) !== read(val, j)) {
657
- found = false;
658
- break;
659
- }
660
- }
661
- if (found) return i;
662
- }
663
- }
664
- return -1;
665
- }
666
- function hexWrite(buf, string, offset, length) {
667
- offset = Number(offset) || 0;
668
- var remaining = buf.length - offset;
669
- if (!length) {
670
- length = remaining;
671
- } else {
672
- length = Number(length);
673
- if (length > remaining) {
674
- length = remaining;
675
- }
676
- }
677
- var strLen = string.length;
678
- if (strLen % 2 !== 0) throw new TypeError("Invalid hex string");
679
- if (length > strLen / 2) {
680
- length = strLen / 2;
681
- }
682
- for (var i = 0; i < length; ++i) {
683
- var parsed = parseInt(string.substr(i * 2, 2), 16);
684
- if (isNaN(parsed)) return i;
685
- buf[offset + i] = parsed;
686
- }
687
- return i;
688
- }
689
- function utf8Write(buf, string, offset, length) {
690
- return blitBuffer(
691
- utf8ToBytes(string, buf.length - offset),
692
- buf,
693
- offset,
694
- length
695
- );
696
- }
697
- function asciiWrite(buf, string, offset, length) {
698
- return blitBuffer(asciiToBytes(string), buf, offset, length);
699
- }
700
- function latin1Write(buf, string, offset, length) {
701
- return asciiWrite(buf, string, offset, length);
702
- }
703
- function base64Write(buf, string, offset, length) {
704
- return blitBuffer(base64ToBytes(string), buf, offset, length);
705
- }
706
- function ucs2Write(buf, string, offset, length) {
707
- return blitBuffer(
708
- utf16leToBytes(string, buf.length - offset),
709
- buf,
710
- offset,
711
- length
712
- );
713
- }
714
- function base64Slice(buf, start, end) {
715
- if (start === 0 && end === buf.length) {
716
- return base64fromByteArray(buf);
717
- } else {
718
- return base64fromByteArray(buf.slice(start, end));
719
- }
720
- }
721
- function utf8Slice(buf, start, end) {
722
- end = Math.min(buf.length, end);
723
- var res = [];
724
- var i = start;
725
- while (i < end) {
726
- var firstByte = buf[i];
727
- var codePoint = null;
728
- var bytesPerSequence = firstByte > 239 ? 4 : firstByte > 223 ? 3 : firstByte > 191 ? 2 : 1;
729
- if (i + bytesPerSequence <= end) {
730
- var secondByte, thirdByte, fourthByte, tempCodePoint;
731
- switch (bytesPerSequence) {
732
- case 1:
733
- if (firstByte < 128) {
734
- codePoint = firstByte;
735
- }
736
- break;
737
- case 2:
738
- secondByte = buf[i + 1];
739
- if ((secondByte & 192) === 128) {
740
- tempCodePoint = (firstByte & 31) << 6 | secondByte & 63;
741
- if (tempCodePoint > 127) {
742
- codePoint = tempCodePoint;
743
- }
744
- }
745
- break;
746
- case 3:
747
- secondByte = buf[i + 1];
748
- thirdByte = buf[i + 2];
749
- if ((secondByte & 192) === 128 && (thirdByte & 192) === 128) {
750
- tempCodePoint = (firstByte & 15) << 12 | (secondByte & 63) << 6 | thirdByte & 63;
751
- if (tempCodePoint > 2047 && (tempCodePoint < 55296 || tempCodePoint > 57343)) {
752
- codePoint = tempCodePoint;
753
- }
754
- }
755
- break;
756
- case 4:
757
- secondByte = buf[i + 1];
758
- thirdByte = buf[i + 2];
759
- fourthByte = buf[i + 3];
760
- if ((secondByte & 192) === 128 && (thirdByte & 192) === 128 && (fourthByte & 192) === 128) {
761
- tempCodePoint = (firstByte & 15) << 18 | (secondByte & 63) << 12 | (thirdByte & 63) << 6 | fourthByte & 63;
762
- if (tempCodePoint > 65535 && tempCodePoint < 1114112) {
763
- codePoint = tempCodePoint;
764
- }
765
- }
766
- }
767
- }
768
- if (codePoint === null) {
769
- codePoint = 65533;
770
- bytesPerSequence = 1;
771
- } else if (codePoint > 65535) {
772
- codePoint -= 65536;
773
- res.push(codePoint >>> 10 & 1023 | 55296);
774
- codePoint = 56320 | codePoint & 1023;
775
- }
776
- res.push(codePoint);
777
- i += bytesPerSequence;
778
- }
779
- return decodeCodePointsArray(res);
780
- }
781
- function decodeCodePointsArray(codePoints) {
782
- var len = codePoints.length;
783
- if (len <= MAX_ARGUMENTS_LENGTH) {
784
- return String.fromCharCode.apply(String, codePoints);
785
- }
786
- var res = "";
787
- var i = 0;
788
- while (i < len) {
789
- res += String.fromCharCode.apply(
790
- String,
791
- codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
792
- );
793
- }
794
- return res;
795
- }
796
- function asciiSlice(buf, start, end) {
797
- var ret = "";
798
- end = Math.min(buf.length, end);
799
- for (var i = start; i < end; ++i) {
800
- ret += String.fromCharCode(buf[i] & 127);
801
- }
802
- return ret;
803
- }
804
- function latin1Slice(buf, start, end) {
805
- var ret = "";
806
- end = Math.min(buf.length, end);
807
- for (var i = start; i < end; ++i) {
808
- ret += String.fromCharCode(buf[i]);
809
- }
810
- return ret;
811
- }
812
- function hexSlice(buf, start, end) {
813
- var len = buf.length;
814
- if (!start || start < 0) start = 0;
815
- if (!end || end < 0 || end > len) end = len;
816
- var out = "";
817
- for (var i = start; i < end; ++i) {
818
- out += toHex(buf[i]);
819
- }
820
- return out;
821
- }
822
- function utf16leSlice(buf, start, end) {
823
- var bytes = buf.slice(start, end);
824
- var res = "";
825
- for (var i = 0; i < bytes.length; i += 2) {
826
- res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256);
827
- }
828
- return res;
829
- }
830
- function checkOffset(offset, ext, length) {
831
- if (offset % 1 !== 0 || offset < 0)
832
- throw new RangeError("offset is not uint");
833
- if (offset + ext > length)
834
- throw new RangeError("Trying to access beyond buffer length");
835
- }
836
- function checkInt(buf, value, offset, ext, max, min) {
837
- if (!internalIsBuffer(buf))
838
- throw new TypeError('"buffer" argument must be a Buffer instance');
839
- if (value > max || value < min)
840
- throw new RangeError('"value" argument is out of bounds');
841
- if (offset + ext > buf.length) throw new RangeError("Index out of range");
842
- }
843
- function objectWriteUInt16(buf, value, offset, littleEndian) {
844
- if (value < 0) value = 65535 + value + 1;
845
- for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) {
846
- buf[offset + i] = (value & 255 << 8 * (littleEndian ? i : 1 - i)) >>> (littleEndian ? i : 1 - i) * 8;
847
- }
848
- }
849
- function objectWriteUInt32(buf, value, offset, littleEndian) {
850
- if (value < 0) value = 4294967295 + value + 1;
851
- for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) {
852
- buf[offset + i] = value >>> (littleEndian ? i : 3 - i) * 8 & 255;
853
- }
854
- }
855
- function checkIEEE754(buf, value, offset, ext, max, min) {
856
- if (offset + ext > buf.length) throw new RangeError("Index out of range");
857
- if (offset < 0) throw new RangeError("Index out of range");
858
- }
859
- function writeFloat(buf, value, offset, littleEndian, noAssert) {
860
- if (!noAssert) {
861
- checkIEEE754(
862
- buf,
863
- value,
864
- offset,
865
- 4,
866
- 34028234663852886e22,
867
- -34028234663852886e22
868
- );
869
- }
870
- ieee754write(buf, value, offset, littleEndian, 23, 4);
871
- return offset + 4;
872
- }
873
- function writeDouble(buf, value, offset, littleEndian, noAssert) {
874
- if (!noAssert) {
875
- checkIEEE754(
876
- buf,
877
- value,
878
- offset,
879
- 8,
880
- 17976931348623157e292,
881
- -17976931348623157e292
882
- );
883
- }
884
- ieee754write(buf, value, offset, littleEndian, 52, 8);
885
- return offset + 8;
886
- }
887
- function base64clean(str) {
888
- str = stringtrim(str).replace(INVALID_BASE64_RE, "");
889
- if (str.length < 2) return "";
890
- while (str.length % 4 !== 0) {
891
- str = str + "=";
892
- }
893
- return str;
894
- }
895
- function stringtrim(str) {
896
- if (str.trim) return str.trim();
897
- return str.replace(/^\s+|\s+$/g, "");
898
- }
899
- function toHex(n) {
900
- if (n < 16) return "0" + n.toString(16);
901
- return n.toString(16);
902
- }
903
- function utf8ToBytes(string, units) {
904
- units = units || Infinity;
905
- var codePoint;
906
- var length = string.length;
907
- var leadSurrogate = null;
908
- var bytes = [];
909
- for (var i = 0; i < length; ++i) {
910
- codePoint = string.charCodeAt(i);
911
- if (codePoint > 55295 && codePoint < 57344) {
912
- if (!leadSurrogate) {
913
- if (codePoint > 56319) {
914
- if ((units -= 3) > -1) bytes.push(239, 191, 189);
915
- continue;
916
- } else if (i + 1 === length) {
917
- if ((units -= 3) > -1) bytes.push(239, 191, 189);
918
- continue;
919
- }
920
- leadSurrogate = codePoint;
921
- continue;
922
- }
923
- if (codePoint < 56320) {
924
- if ((units -= 3) > -1) bytes.push(239, 191, 189);
925
- leadSurrogate = codePoint;
926
- continue;
927
- }
928
- codePoint = (leadSurrogate - 55296 << 10 | codePoint - 56320) + 65536;
929
- } else if (leadSurrogate) {
930
- if ((units -= 3) > -1) bytes.push(239, 191, 189);
931
- }
932
- leadSurrogate = null;
933
- if (codePoint < 128) {
934
- if ((units -= 1) < 0) break;
935
- bytes.push(codePoint);
936
- } else if (codePoint < 2048) {
937
- if ((units -= 2) < 0) break;
938
- bytes.push(codePoint >> 6 | 192, codePoint & 63 | 128);
939
- } else if (codePoint < 65536) {
940
- if ((units -= 3) < 0) break;
941
- bytes.push(
942
- codePoint >> 12 | 224,
943
- codePoint >> 6 & 63 | 128,
944
- codePoint & 63 | 128
945
- );
946
- } else if (codePoint < 1114112) {
947
- if ((units -= 4) < 0) break;
948
- bytes.push(
949
- codePoint >> 18 | 240,
950
- codePoint >> 12 & 63 | 128,
951
- codePoint >> 6 & 63 | 128,
952
- codePoint & 63 | 128
953
- );
954
- } else {
955
- throw new Error("Invalid code point");
956
- }
957
- }
958
- return bytes;
959
- }
960
- function asciiToBytes(str) {
961
- var byteArray = [];
962
- for (var i = 0; i < str.length; ++i) {
963
- byteArray.push(str.charCodeAt(i) & 255);
964
- }
965
- return byteArray;
966
- }
967
- function utf16leToBytes(str, units) {
968
- var c, hi, lo;
969
- var byteArray = [];
970
- for (var i = 0; i < str.length; ++i) {
971
- if ((units -= 2) < 0) break;
972
- c = str.charCodeAt(i);
973
- hi = c >> 8;
974
- lo = c % 256;
975
- byteArray.push(lo);
976
- byteArray.push(hi);
977
- }
978
- return byteArray;
979
- }
980
- function base64ToBytes(str) {
981
- return base64toByteArray(base64clean(str));
982
- }
983
- function blitBuffer(src, dst, offset, length) {
984
- for (var i = 0; i < length; ++i) {
985
- if (i + offset >= dst.length || i >= src.length) break;
986
- dst[i + offset] = src[i];
987
- }
988
- return i;
989
- }
990
- function isnan(val) {
991
- return val !== val;
992
- }
993
- function isBuffer(obj) {
994
- return obj != null && (!!obj._isBuffer || isFastBuffer(obj) || isSlowBuffer(obj));
995
- }
996
- function isFastBuffer(obj) {
997
- return !!obj.constructor && typeof obj.constructor.isBuffer === "function" && obj.constructor.isBuffer(obj);
998
- }
999
- function isSlowBuffer(obj) {
1000
- return typeof obj.readFloatLE === "function" && typeof obj.slice === "function" && isFastBuffer(obj.slice(0, 0));
1001
- }
1002
- function ieee754read(buffer, offset, isLE, mLen, nBytes) {
1003
- var e, m;
1004
- var eLen = nBytes * 8 - mLen - 1;
1005
- var eMax = (1 << eLen) - 1;
1006
- var eBias = eMax >> 1;
1007
- var nBits = -7;
1008
- var i = isLE ? nBytes - 1 : 0;
1009
- var d = isLE ? -1 : 1;
1010
- var s = buffer[offset + i];
1011
- i += d;
1012
- e = s & (1 << -nBits) - 1;
1013
- s >>= -nBits;
1014
- nBits += eLen;
1015
- for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8) {
1016
- }
1017
- m = e & (1 << -nBits) - 1;
1018
- e >>= -nBits;
1019
- nBits += mLen;
1020
- for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8) {
1021
- }
1022
- if (e === 0) {
1023
- e = 1 - eBias;
1024
- } else if (e === eMax) {
1025
- return m ? NaN : (s ? -1 : 1) * Infinity;
1026
- } else {
1027
- m = m + Math.pow(2, mLen);
1028
- e = e - eBias;
1029
- }
1030
- return (s ? -1 : 1) * m * Math.pow(2, e - mLen);
1031
- }
1032
- function ieee754write(buffer, value, offset, isLE, mLen, nBytes) {
1033
- var e, m, c;
1034
- var eLen = nBytes * 8 - mLen - 1;
1035
- var eMax = (1 << eLen) - 1;
1036
- var eBias = eMax >> 1;
1037
- var rt = mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0;
1038
- var i = isLE ? 0 : nBytes - 1;
1039
- var d = isLE ? 1 : -1;
1040
- var s = value < 0 || value === 0 && 1 / value < 0 ? 1 : 0;
1041
- value = Math.abs(value);
1042
- if (isNaN(value) || value === Infinity) {
1043
- m = isNaN(value) ? 1 : 0;
1044
- e = eMax;
1045
- } else {
1046
- e = Math.floor(Math.log(value) / Math.LN2);
1047
- if (value * (c = Math.pow(2, -e)) < 1) {
1048
- e--;
1049
- c *= 2;
1050
- }
1051
- if (e + eBias >= 1) {
1052
- value += rt / c;
1053
- } else {
1054
- value += rt * Math.pow(2, 1 - eBias);
1055
- }
1056
- if (value * c >= 2) {
1057
- e++;
1058
- c /= 2;
1059
- }
1060
- if (e + eBias >= eMax) {
1061
- m = 0;
1062
- e = eMax;
1063
- } else if (e + eBias >= 1) {
1064
- m = (value * c - 1) * Math.pow(2, mLen);
1065
- e = e + eBias;
1066
- } else {
1067
- m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen);
1068
- e = 0;
1069
- }
1070
- }
1071
- for (; mLen >= 8; buffer[offset + i] = m & 255, i += d, m /= 256, mLen -= 8) {
1072
- }
1073
- e = e << mLen | m;
1074
- eLen += mLen;
1075
- for (; eLen > 0; buffer[offset + i] = e & 255, i += d, e /= 256, eLen -= 8) {
1076
- }
1077
- buffer[offset + i - d] |= s * 128;
1078
- }
1079
- var lookup, revLookup, Arr, inited, MAX_ARGUMENTS_LENGTH, INVALID_BASE64_RE;
1080
- var init_Buffer = __esm({
1081
- "../../../node_modules/.pnpm/@esbuild-plugins+node-globals-polyfill@0.2.3_esbuild@0.24.0/node_modules/@esbuild-plugins/node-globals-polyfill/Buffer.js"() {
1082
- "use strict";
1083
- init_process();
1084
- init_buffer();
1085
- lookup = [];
1086
- revLookup = [];
1087
- Arr = typeof Uint8Array !== "undefined" ? Uint8Array : Array;
1088
- inited = false;
1089
- Buffer2.TYPED_ARRAY_SUPPORT = globalThis.TYPED_ARRAY_SUPPORT !== void 0 ? globalThis.TYPED_ARRAY_SUPPORT : true;
1090
- Buffer2.poolSize = 8192;
1091
- Buffer2._augment = function(arr) {
1092
- arr.__proto__ = Buffer2.prototype;
1093
- return arr;
1094
- };
1095
- Buffer2.from = function(value, encodingOrOffset, length) {
1096
- return from(null, value, encodingOrOffset, length);
1097
- };
1098
- Buffer2.kMaxLength = kMaxLength();
1099
- if (Buffer2.TYPED_ARRAY_SUPPORT) {
1100
- Buffer2.prototype.__proto__ = Uint8Array.prototype;
1101
- Buffer2.__proto__ = Uint8Array;
1102
- if (typeof Symbol !== "undefined" && Symbol.species && Buffer2[Symbol.species] === Buffer2) {
1103
- }
1104
- }
1105
- Buffer2.alloc = function(size, fill2, encoding) {
1106
- return alloc(null, size, fill2, encoding);
1107
- };
1108
- Buffer2.allocUnsafe = function(size) {
1109
- return allocUnsafe(null, size);
1110
- };
1111
- Buffer2.allocUnsafeSlow = function(size) {
1112
- return allocUnsafe(null, size);
1113
- };
1114
- Buffer2.isBuffer = isBuffer;
1115
- Buffer2.compare = function compare(a, b) {
1116
- if (!internalIsBuffer(a) || !internalIsBuffer(b)) {
1117
- throw new TypeError("Arguments must be Buffers");
1118
- }
1119
- if (a === b) return 0;
1120
- var x = a.length;
1121
- var y = b.length;
1122
- for (var i = 0, len = Math.min(x, y); i < len; ++i) {
1123
- if (a[i] !== b[i]) {
1124
- x = a[i];
1125
- y = b[i];
1126
- break;
1127
- }
1128
- }
1129
- if (x < y) return -1;
1130
- if (y < x) return 1;
1131
- return 0;
1132
- };
1133
- Buffer2.isEncoding = function isEncoding(encoding) {
1134
- switch (String(encoding).toLowerCase()) {
1135
- case "hex":
1136
- case "utf8":
1137
- case "utf-8":
1138
- case "ascii":
1139
- case "latin1":
1140
- case "binary":
1141
- case "base64":
1142
- case "ucs2":
1143
- case "ucs-2":
1144
- case "utf16le":
1145
- case "utf-16le":
1146
- return true;
1147
- default:
1148
- return false;
1149
- }
1150
- };
1151
- Buffer2.concat = function concat(list, length) {
1152
- if (!Array.isArray(list)) {
1153
- throw new TypeError('"list" argument must be an Array of Buffers');
1154
- }
1155
- if (list.length === 0) {
1156
- return Buffer2.alloc(0);
1157
- }
1158
- var i;
1159
- if (length === void 0) {
1160
- length = 0;
1161
- for (i = 0; i < list.length; ++i) {
1162
- length += list[i].length;
1163
- }
1164
- }
1165
- var buffer = Buffer2.allocUnsafe(length);
1166
- var pos = 0;
1167
- for (i = 0; i < list.length; ++i) {
1168
- var buf = list[i];
1169
- if (!internalIsBuffer(buf)) {
1170
- throw new TypeError('"list" argument must be an Array of Buffers');
1171
- }
1172
- buf.copy(buffer, pos);
1173
- pos += buf.length;
1174
- }
1175
- return buffer;
1176
- };
1177
- Buffer2.byteLength = byteLength;
1178
- Buffer2.prototype._isBuffer = true;
1179
- Buffer2.prototype.swap16 = function swap16() {
1180
- var len = this.length;
1181
- if (len % 2 !== 0) {
1182
- throw new RangeError("Buffer size must be a multiple of 16-bits");
1183
- }
1184
- for (var i = 0; i < len; i += 2) {
1185
- swap(this, i, i + 1);
1186
- }
1187
- return this;
1188
- };
1189
- Buffer2.prototype.swap32 = function swap32() {
1190
- var len = this.length;
1191
- if (len % 4 !== 0) {
1192
- throw new RangeError("Buffer size must be a multiple of 32-bits");
1193
- }
1194
- for (var i = 0; i < len; i += 4) {
1195
- swap(this, i, i + 3);
1196
- swap(this, i + 1, i + 2);
1197
- }
1198
- return this;
1199
- };
1200
- Buffer2.prototype.swap64 = function swap64() {
1201
- var len = this.length;
1202
- if (len % 8 !== 0) {
1203
- throw new RangeError("Buffer size must be a multiple of 64-bits");
1204
- }
1205
- for (var i = 0; i < len; i += 8) {
1206
- swap(this, i, i + 7);
1207
- swap(this, i + 1, i + 6);
1208
- swap(this, i + 2, i + 5);
1209
- swap(this, i + 3, i + 4);
1210
- }
1211
- return this;
1212
- };
1213
- Buffer2.prototype.toString = function toString() {
1214
- var length = this.length | 0;
1215
- if (length === 0) return "";
1216
- if (arguments.length === 0) return utf8Slice(this, 0, length);
1217
- return slowToString.apply(this, arguments);
1218
- };
1219
- Buffer2.prototype.equals = function equals(b) {
1220
- if (!internalIsBuffer(b)) throw new TypeError("Argument must be a Buffer");
1221
- if (this === b) return true;
1222
- return Buffer2.compare(this, b) === 0;
1223
- };
1224
- Buffer2.prototype.compare = function compare2(target, start, end, thisStart, thisEnd) {
1225
- if (!internalIsBuffer(target)) {
1226
- throw new TypeError("Argument must be a Buffer");
1227
- }
1228
- if (start === void 0) {
1229
- start = 0;
1230
- }
1231
- if (end === void 0) {
1232
- end = target ? target.length : 0;
1233
- }
1234
- if (thisStart === void 0) {
1235
- thisStart = 0;
1236
- }
1237
- if (thisEnd === void 0) {
1238
- thisEnd = this.length;
1239
- }
1240
- if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
1241
- throw new RangeError("out of range index");
1242
- }
1243
- if (thisStart >= thisEnd && start >= end) {
1244
- return 0;
1245
- }
1246
- if (thisStart >= thisEnd) {
1247
- return -1;
1248
- }
1249
- if (start >= end) {
1250
- return 1;
1251
- }
1252
- start >>>= 0;
1253
- end >>>= 0;
1254
- thisStart >>>= 0;
1255
- thisEnd >>>= 0;
1256
- if (this === target) return 0;
1257
- var x = thisEnd - thisStart;
1258
- var y = end - start;
1259
- var len = Math.min(x, y);
1260
- var thisCopy = this.slice(thisStart, thisEnd);
1261
- var targetCopy = target.slice(start, end);
1262
- for (var i = 0; i < len; ++i) {
1263
- if (thisCopy[i] !== targetCopy[i]) {
1264
- x = thisCopy[i];
1265
- y = targetCopy[i];
1266
- break;
1267
- }
1268
- }
1269
- if (x < y) return -1;
1270
- if (y < x) return 1;
1271
- return 0;
1272
- };
1273
- Buffer2.prototype.includes = function includes(val, byteOffset, encoding) {
1274
- return this.indexOf(val, byteOffset, encoding) !== -1;
1275
- };
1276
- Buffer2.prototype.indexOf = function indexOf(val, byteOffset, encoding) {
1277
- return bidirectionalIndexOf(this, val, byteOffset, encoding, true);
1278
- };
1279
- Buffer2.prototype.lastIndexOf = function lastIndexOf(val, byteOffset, encoding) {
1280
- return bidirectionalIndexOf(this, val, byteOffset, encoding, false);
1281
- };
1282
- Buffer2.prototype.write = function write(string, offset, length, encoding) {
1283
- if (offset === void 0) {
1284
- encoding = "utf8";
1285
- length = this.length;
1286
- offset = 0;
1287
- } else if (length === void 0 && typeof offset === "string") {
1288
- encoding = offset;
1289
- length = this.length;
1290
- offset = 0;
1291
- } else if (isFinite(offset)) {
1292
- offset = offset | 0;
1293
- if (isFinite(length)) {
1294
- length = length | 0;
1295
- if (encoding === void 0) encoding = "utf8";
1296
- } else {
1297
- encoding = length;
1298
- length = void 0;
1299
- }
1300
- } else {
1301
- throw new Error(
1302
- "Buffer.write(string, encoding, offset[, length]) is no longer supported"
1303
- );
1304
- }
1305
- var remaining = this.length - offset;
1306
- if (length === void 0 || length > remaining) length = remaining;
1307
- if (string.length > 0 && (length < 0 || offset < 0) || offset > this.length) {
1308
- throw new RangeError("Attempt to write outside buffer bounds");
1309
- }
1310
- if (!encoding) encoding = "utf8";
1311
- var loweredCase = false;
1312
- for (; ; ) {
1313
- switch (encoding) {
1314
- case "hex":
1315
- return hexWrite(this, string, offset, length);
1316
- case "utf8":
1317
- case "utf-8":
1318
- return utf8Write(this, string, offset, length);
1319
- case "ascii":
1320
- return asciiWrite(this, string, offset, length);
1321
- case "latin1":
1322
- case "binary":
1323
- return latin1Write(this, string, offset, length);
1324
- case "base64":
1325
- return base64Write(this, string, offset, length);
1326
- case "ucs2":
1327
- case "ucs-2":
1328
- case "utf16le":
1329
- case "utf-16le":
1330
- return ucs2Write(this, string, offset, length);
1331
- default:
1332
- if (loweredCase)
1333
- throw new TypeError("Unknown encoding: " + encoding);
1334
- encoding = ("" + encoding).toLowerCase();
1335
- loweredCase = true;
1336
- }
1337
- }
1338
- };
1339
- Buffer2.prototype.toJSON = function toJSON() {
1340
- return {
1341
- type: "Buffer",
1342
- data: Array.prototype.slice.call(this._arr || this, 0)
1343
- };
1344
- };
1345
- MAX_ARGUMENTS_LENGTH = 4096;
1346
- Buffer2.prototype.slice = function slice(start, end) {
1347
- var len = this.length;
1348
- start = ~~start;
1349
- end = end === void 0 ? len : ~~end;
1350
- if (start < 0) {
1351
- start += len;
1352
- if (start < 0) start = 0;
1353
- } else if (start > len) {
1354
- start = len;
1355
- }
1356
- if (end < 0) {
1357
- end += len;
1358
- if (end < 0) end = 0;
1359
- } else if (end > len) {
1360
- end = len;
1361
- }
1362
- if (end < start) end = start;
1363
- var newBuf;
1364
- if (Buffer2.TYPED_ARRAY_SUPPORT) {
1365
- newBuf = this.subarray(start, end);
1366
- newBuf.__proto__ = Buffer2.prototype;
1367
- } else {
1368
- var sliceLen = end - start;
1369
- newBuf = new Buffer2(sliceLen, void 0);
1370
- for (var i = 0; i < sliceLen; ++i) {
1371
- newBuf[i] = this[i + start];
1372
- }
1373
- }
1374
- return newBuf;
1375
- };
1376
- Buffer2.prototype.readUIntLE = function readUIntLE(offset, byteLength2, noAssert) {
1377
- offset = offset | 0;
1378
- byteLength2 = byteLength2 | 0;
1379
- if (!noAssert) checkOffset(offset, byteLength2, this.length);
1380
- var val = this[offset];
1381
- var mul = 1;
1382
- var i = 0;
1383
- while (++i < byteLength2 && (mul *= 256)) {
1384
- val += this[offset + i] * mul;
1385
- }
1386
- return val;
1387
- };
1388
- Buffer2.prototype.readUIntBE = function readUIntBE(offset, byteLength2, noAssert) {
1389
- offset = offset | 0;
1390
- byteLength2 = byteLength2 | 0;
1391
- if (!noAssert) {
1392
- checkOffset(offset, byteLength2, this.length);
1393
- }
1394
- var val = this[offset + --byteLength2];
1395
- var mul = 1;
1396
- while (byteLength2 > 0 && (mul *= 256)) {
1397
- val += this[offset + --byteLength2] * mul;
1398
- }
1399
- return val;
1400
- };
1401
- Buffer2.prototype.readUInt8 = function readUInt8(offset, noAssert) {
1402
- if (!noAssert) checkOffset(offset, 1, this.length);
1403
- return this[offset];
1404
- };
1405
- Buffer2.prototype.readUInt16LE = function readUInt16LE(offset, noAssert) {
1406
- if (!noAssert) checkOffset(offset, 2, this.length);
1407
- return this[offset] | this[offset + 1] << 8;
1408
- };
1409
- Buffer2.prototype.readUInt16BE = function readUInt16BE(offset, noAssert) {
1410
- if (!noAssert) checkOffset(offset, 2, this.length);
1411
- return this[offset] << 8 | this[offset + 1];
1412
- };
1413
- Buffer2.prototype.readUInt32LE = function readUInt32LE(offset, noAssert) {
1414
- if (!noAssert) checkOffset(offset, 4, this.length);
1415
- return (this[offset] | this[offset + 1] << 8 | this[offset + 2] << 16) + this[offset + 3] * 16777216;
1416
- };
1417
- Buffer2.prototype.readUInt32BE = function readUInt32BE(offset, noAssert) {
1418
- if (!noAssert) checkOffset(offset, 4, this.length);
1419
- return this[offset] * 16777216 + (this[offset + 1] << 16 | this[offset + 2] << 8 | this[offset + 3]);
1420
- };
1421
- Buffer2.prototype.readIntLE = function readIntLE(offset, byteLength2, noAssert) {
1422
- offset = offset | 0;
1423
- byteLength2 = byteLength2 | 0;
1424
- if (!noAssert) checkOffset(offset, byteLength2, this.length);
1425
- var val = this[offset];
1426
- var mul = 1;
1427
- var i = 0;
1428
- while (++i < byteLength2 && (mul *= 256)) {
1429
- val += this[offset + i] * mul;
1430
- }
1431
- mul *= 128;
1432
- if (val >= mul) val -= Math.pow(2, 8 * byteLength2);
1433
- return val;
1434
- };
1435
- Buffer2.prototype.readIntBE = function readIntBE(offset, byteLength2, noAssert) {
1436
- offset = offset | 0;
1437
- byteLength2 = byteLength2 | 0;
1438
- if (!noAssert) checkOffset(offset, byteLength2, this.length);
1439
- var i = byteLength2;
1440
- var mul = 1;
1441
- var val = this[offset + --i];
1442
- while (i > 0 && (mul *= 256)) {
1443
- val += this[offset + --i] * mul;
1444
- }
1445
- mul *= 128;
1446
- if (val >= mul) val -= Math.pow(2, 8 * byteLength2);
1447
- return val;
1448
- };
1449
- Buffer2.prototype.readInt8 = function readInt8(offset, noAssert) {
1450
- if (!noAssert) checkOffset(offset, 1, this.length);
1451
- if (!(this[offset] & 128)) return this[offset];
1452
- return (255 - this[offset] + 1) * -1;
1453
- };
1454
- Buffer2.prototype.readInt16LE = function readInt16LE(offset, noAssert) {
1455
- if (!noAssert) checkOffset(offset, 2, this.length);
1456
- var val = this[offset] | this[offset + 1] << 8;
1457
- return val & 32768 ? val | 4294901760 : val;
1458
- };
1459
- Buffer2.prototype.readInt16BE = function readInt16BE(offset, noAssert) {
1460
- if (!noAssert) checkOffset(offset, 2, this.length);
1461
- var val = this[offset + 1] | this[offset] << 8;
1462
- return val & 32768 ? val | 4294901760 : val;
1463
- };
1464
- Buffer2.prototype.readInt32LE = function readInt32LE(offset, noAssert) {
1465
- if (!noAssert) checkOffset(offset, 4, this.length);
1466
- return this[offset] | this[offset + 1] << 8 | this[offset + 2] << 16 | this[offset + 3] << 24;
1467
- };
1468
- Buffer2.prototype.readInt32BE = function readInt32BE(offset, noAssert) {
1469
- if (!noAssert) checkOffset(offset, 4, this.length);
1470
- return this[offset] << 24 | this[offset + 1] << 16 | this[offset + 2] << 8 | this[offset + 3];
1471
- };
1472
- Buffer2.prototype.readFloatLE = function readFloatLE(offset, noAssert) {
1473
- if (!noAssert) checkOffset(offset, 4, this.length);
1474
- return ieee754read(this, offset, true, 23, 4);
1475
- };
1476
- Buffer2.prototype.readFloatBE = function readFloatBE(offset, noAssert) {
1477
- if (!noAssert) checkOffset(offset, 4, this.length);
1478
- return ieee754read(this, offset, false, 23, 4);
1479
- };
1480
- Buffer2.prototype.readDoubleLE = function readDoubleLE(offset, noAssert) {
1481
- if (!noAssert) checkOffset(offset, 8, this.length);
1482
- return ieee754read(this, offset, true, 52, 8);
1483
- };
1484
- Buffer2.prototype.readDoubleBE = function readDoubleBE(offset, noAssert) {
1485
- if (!noAssert) checkOffset(offset, 8, this.length);
1486
- return ieee754read(this, offset, false, 52, 8);
1487
- };
1488
- Buffer2.prototype.writeUIntLE = function writeUIntLE(value, offset, byteLength2, noAssert) {
1489
- value = +value;
1490
- offset = offset | 0;
1491
- byteLength2 = byteLength2 | 0;
1492
- if (!noAssert) {
1493
- var maxBytes = Math.pow(2, 8 * byteLength2) - 1;
1494
- checkInt(this, value, offset, byteLength2, maxBytes, 0);
1495
- }
1496
- var mul = 1;
1497
- var i = 0;
1498
- this[offset] = value & 255;
1499
- while (++i < byteLength2 && (mul *= 256)) {
1500
- this[offset + i] = value / mul & 255;
1501
- }
1502
- return offset + byteLength2;
1503
- };
1504
- Buffer2.prototype.writeUIntBE = function writeUIntBE(value, offset, byteLength2, noAssert) {
1505
- value = +value;
1506
- offset = offset | 0;
1507
- byteLength2 = byteLength2 | 0;
1508
- if (!noAssert) {
1509
- var maxBytes = Math.pow(2, 8 * byteLength2) - 1;
1510
- checkInt(this, value, offset, byteLength2, maxBytes, 0);
1511
- }
1512
- var i = byteLength2 - 1;
1513
- var mul = 1;
1514
- this[offset + i] = value & 255;
1515
- while (--i >= 0 && (mul *= 256)) {
1516
- this[offset + i] = value / mul & 255;
1517
- }
1518
- return offset + byteLength2;
1519
- };
1520
- Buffer2.prototype.writeUInt8 = function writeUInt8(value, offset, noAssert) {
1521
- value = +value;
1522
- offset = offset | 0;
1523
- if (!noAssert) checkInt(this, value, offset, 1, 255, 0);
1524
- if (!Buffer2.TYPED_ARRAY_SUPPORT) value = Math.floor(value);
1525
- this[offset] = value & 255;
1526
- return offset + 1;
1527
- };
1528
- Buffer2.prototype.writeUInt16LE = function writeUInt16LE(value, offset, noAssert) {
1529
- value = +value;
1530
- offset = offset | 0;
1531
- if (!noAssert) checkInt(this, value, offset, 2, 65535, 0);
1532
- if (Buffer2.TYPED_ARRAY_SUPPORT) {
1533
- this[offset] = value & 255;
1534
- this[offset + 1] = value >>> 8;
1535
- } else {
1536
- objectWriteUInt16(this, value, offset, true);
1537
- }
1538
- return offset + 2;
1539
- };
1540
- Buffer2.prototype.writeUInt16BE = function writeUInt16BE(value, offset, noAssert) {
1541
- value = +value;
1542
- offset = offset | 0;
1543
- if (!noAssert) checkInt(this, value, offset, 2, 65535, 0);
1544
- if (Buffer2.TYPED_ARRAY_SUPPORT) {
1545
- this[offset] = value >>> 8;
1546
- this[offset + 1] = value & 255;
1547
- } else {
1548
- objectWriteUInt16(this, value, offset, false);
1549
- }
1550
- return offset + 2;
1551
- };
1552
- Buffer2.prototype.writeUInt32LE = function writeUInt32LE(value, offset, noAssert) {
1553
- value = +value;
1554
- offset = offset | 0;
1555
- if (!noAssert) checkInt(this, value, offset, 4, 4294967295, 0);
1556
- if (Buffer2.TYPED_ARRAY_SUPPORT) {
1557
- this[offset + 3] = value >>> 24;
1558
- this[offset + 2] = value >>> 16;
1559
- this[offset + 1] = value >>> 8;
1560
- this[offset] = value & 255;
1561
- } else {
1562
- objectWriteUInt32(this, value, offset, true);
1563
- }
1564
- return offset + 4;
1565
- };
1566
- Buffer2.prototype.writeUInt32BE = function writeUInt32BE(value, offset, noAssert) {
1567
- value = +value;
1568
- offset = offset | 0;
1569
- if (!noAssert) checkInt(this, value, offset, 4, 4294967295, 0);
1570
- if (Buffer2.TYPED_ARRAY_SUPPORT) {
1571
- this[offset] = value >>> 24;
1572
- this[offset + 1] = value >>> 16;
1573
- this[offset + 2] = value >>> 8;
1574
- this[offset + 3] = value & 255;
1575
- } else {
1576
- objectWriteUInt32(this, value, offset, false);
1577
- }
1578
- return offset + 4;
1579
- };
1580
- Buffer2.prototype.writeIntLE = function writeIntLE(value, offset, byteLength2, noAssert) {
1581
- value = +value;
1582
- offset = offset | 0;
1583
- if (!noAssert) {
1584
- var limit = Math.pow(2, 8 * byteLength2 - 1);
1585
- checkInt(this, value, offset, byteLength2, limit - 1, -limit);
1586
- }
1587
- var i = 0;
1588
- var mul = 1;
1589
- var sub = 0;
1590
- this[offset] = value & 255;
1591
- while (++i < byteLength2 && (mul *= 256)) {
1592
- if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
1593
- sub = 1;
1594
- }
1595
- this[offset + i] = (value / mul >> 0) - sub & 255;
1596
- }
1597
- return offset + byteLength2;
1598
- };
1599
- Buffer2.prototype.writeIntBE = function writeIntBE(value, offset, byteLength2, noAssert) {
1600
- value = +value;
1601
- offset = offset | 0;
1602
- if (!noAssert) {
1603
- var limit = Math.pow(2, 8 * byteLength2 - 1);
1604
- checkInt(this, value, offset, byteLength2, limit - 1, -limit);
1605
- }
1606
- var i = byteLength2 - 1;
1607
- var mul = 1;
1608
- var sub = 0;
1609
- this[offset + i] = value & 255;
1610
- while (--i >= 0 && (mul *= 256)) {
1611
- if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
1612
- sub = 1;
1613
- }
1614
- this[offset + i] = (value / mul >> 0) - sub & 255;
1615
- }
1616
- return offset + byteLength2;
1617
- };
1618
- Buffer2.prototype.writeInt8 = function writeInt8(value, offset, noAssert) {
1619
- value = +value;
1620
- offset = offset | 0;
1621
- if (!noAssert) checkInt(this, value, offset, 1, 127, -128);
1622
- if (!Buffer2.TYPED_ARRAY_SUPPORT) value = Math.floor(value);
1623
- if (value < 0) value = 255 + value + 1;
1624
- this[offset] = value & 255;
1625
- return offset + 1;
1626
- };
1627
- Buffer2.prototype.writeInt16LE = function writeInt16LE(value, offset, noAssert) {
1628
- value = +value;
1629
- offset = offset | 0;
1630
- if (!noAssert) checkInt(this, value, offset, 2, 32767, -32768);
1631
- if (Buffer2.TYPED_ARRAY_SUPPORT) {
1632
- this[offset] = value & 255;
1633
- this[offset + 1] = value >>> 8;
1634
- } else {
1635
- objectWriteUInt16(this, value, offset, true);
1636
- }
1637
- return offset + 2;
1638
- };
1639
- Buffer2.prototype.writeInt16BE = function writeInt16BE(value, offset, noAssert) {
1640
- value = +value;
1641
- offset = offset | 0;
1642
- if (!noAssert) checkInt(this, value, offset, 2, 32767, -32768);
1643
- if (Buffer2.TYPED_ARRAY_SUPPORT) {
1644
- this[offset] = value >>> 8;
1645
- this[offset + 1] = value & 255;
1646
- } else {
1647
- objectWriteUInt16(this, value, offset, false);
1648
- }
1649
- return offset + 2;
1650
- };
1651
- Buffer2.prototype.writeInt32LE = function writeInt32LE(value, offset, noAssert) {
1652
- value = +value;
1653
- offset = offset | 0;
1654
- if (!noAssert) checkInt(this, value, offset, 4, 2147483647, -2147483648);
1655
- if (Buffer2.TYPED_ARRAY_SUPPORT) {
1656
- this[offset] = value & 255;
1657
- this[offset + 1] = value >>> 8;
1658
- this[offset + 2] = value >>> 16;
1659
- this[offset + 3] = value >>> 24;
1660
- } else {
1661
- objectWriteUInt32(this, value, offset, true);
1662
- }
1663
- return offset + 4;
1664
- };
1665
- Buffer2.prototype.writeInt32BE = function writeInt32BE(value, offset, noAssert) {
1666
- value = +value;
1667
- offset = offset | 0;
1668
- if (!noAssert) checkInt(this, value, offset, 4, 2147483647, -2147483648);
1669
- if (value < 0) value = 4294967295 + value + 1;
1670
- if (Buffer2.TYPED_ARRAY_SUPPORT) {
1671
- this[offset] = value >>> 24;
1672
- this[offset + 1] = value >>> 16;
1673
- this[offset + 2] = value >>> 8;
1674
- this[offset + 3] = value & 255;
1675
- } else {
1676
- objectWriteUInt32(this, value, offset, false);
1677
- }
1678
- return offset + 4;
1679
- };
1680
- Buffer2.prototype.writeFloatLE = function writeFloatLE(value, offset, noAssert) {
1681
- return writeFloat(this, value, offset, true, noAssert);
1682
- };
1683
- Buffer2.prototype.writeFloatBE = function writeFloatBE(value, offset, noAssert) {
1684
- return writeFloat(this, value, offset, false, noAssert);
1685
- };
1686
- Buffer2.prototype.writeDoubleLE = function writeDoubleLE(value, offset, noAssert) {
1687
- return writeDouble(this, value, offset, true, noAssert);
1688
- };
1689
- Buffer2.prototype.writeDoubleBE = function writeDoubleBE(value, offset, noAssert) {
1690
- return writeDouble(this, value, offset, false, noAssert);
1691
- };
1692
- Buffer2.prototype.copy = function copy(target, targetStart, start, end) {
1693
- if (!start) start = 0;
1694
- if (!end && end !== 0) end = this.length;
1695
- if (targetStart >= target.length) targetStart = target.length;
1696
- if (!targetStart) targetStart = 0;
1697
- if (end > 0 && end < start) end = start;
1698
- if (end === start) return 0;
1699
- if (target.length === 0 || this.length === 0) return 0;
1700
- if (targetStart < 0) {
1701
- throw new RangeError("targetStart out of bounds");
1702
- }
1703
- if (start < 0 || start >= this.length)
1704
- throw new RangeError("sourceStart out of bounds");
1705
- if (end < 0) throw new RangeError("sourceEnd out of bounds");
1706
- if (end > this.length) end = this.length;
1707
- if (target.length - targetStart < end - start) {
1708
- end = target.length - targetStart + start;
1709
- }
1710
- var len = end - start;
1711
- var i;
1712
- if (this === target && start < targetStart && targetStart < end) {
1713
- for (i = len - 1; i >= 0; --i) {
1714
- target[i + targetStart] = this[i + start];
1715
- }
1716
- } else if (len < 1e3 || !Buffer2.TYPED_ARRAY_SUPPORT) {
1717
- for (i = 0; i < len; ++i) {
1718
- target[i + targetStart] = this[i + start];
1719
- }
1720
- } else {
1721
- Uint8Array.prototype.set.call(
1722
- target,
1723
- this.subarray(start, start + len),
1724
- targetStart
1725
- );
1726
- }
1727
- return len;
1728
- };
1729
- Buffer2.prototype.fill = function fill(val, start, end, encoding) {
1730
- if (typeof val === "string") {
1731
- if (typeof start === "string") {
1732
- encoding = start;
1733
- start = 0;
1734
- end = this.length;
1735
- } else if (typeof end === "string") {
1736
- encoding = end;
1737
- end = this.length;
1738
- }
1739
- if (val.length === 1) {
1740
- var code = val.charCodeAt(0);
1741
- if (code < 256) {
1742
- val = code;
1743
- }
1744
- }
1745
- if (encoding !== void 0 && typeof encoding !== "string") {
1746
- throw new TypeError("encoding must be a string");
1747
- }
1748
- if (typeof encoding === "string" && !Buffer2.isEncoding(encoding)) {
1749
- throw new TypeError("Unknown encoding: " + encoding);
1750
- }
1751
- } else if (typeof val === "number") {
1752
- val = val & 255;
1753
- }
1754
- if (start < 0 || this.length < start || this.length < end) {
1755
- throw new RangeError("Out of range index");
1756
- }
1757
- if (end <= start) {
1758
- return this;
1759
- }
1760
- start = start >>> 0;
1761
- end = end === void 0 ? this.length : end >>> 0;
1762
- if (!val) val = 0;
1763
- var i;
1764
- if (typeof val === "number") {
1765
- for (i = start; i < end; ++i) {
1766
- this[i] = val;
1767
- }
1768
- } else {
1769
- var bytes = internalIsBuffer(val) ? val : utf8ToBytes(new Buffer2(val, encoding).toString());
1770
- var len = bytes.length;
1771
- for (i = 0; i < end - start; ++i) {
1772
- this[i + start] = bytes[i % len];
1773
- }
1774
- }
1775
- return this;
1776
- };
1777
- INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g;
1778
- }
1779
- });
1780
-
1781
- // ../../../node_modules/.pnpm/@esbuild-plugins+node-globals-polyfill@0.2.3_esbuild@0.24.0/node_modules/@esbuild-plugins/node-globals-polyfill/_buffer.js
1782
- var init_buffer = __esm({
1783
- "../../../node_modules/.pnpm/@esbuild-plugins+node-globals-polyfill@0.2.3_esbuild@0.24.0/node_modules/@esbuild-plugins/node-globals-polyfill/_buffer.js"() {
1784
- "use strict";
1785
- init_Buffer();
1786
- }
1787
- });
1788
-
1789
- // src/context/DynamicTypeLiteralMapper.ts
1790
- var DynamicTypeLiteralMapper_exports = {};
1791
- __export(DynamicTypeLiteralMapper_exports, {
1792
- DynamicTypeLiteralMapper: () => DynamicTypeLiteralMapper
1793
- });
1794
- module.exports = __toCommonJS(DynamicTypeLiteralMapper_exports);
1795
- init_process();
1796
- init_buffer();
1797
-
1798
- // ../../../packages/commons/core-utils/lib/index.js
1799
- init_process();
1800
- init_buffer();
1801
-
1802
- // ../../../packages/commons/core-utils/lib/assertNever.js
1803
- init_process();
1804
- init_buffer();
1805
- function assertNever(x) {
1806
- throw new Error("Unexpected value: " + JSON.stringify(x));
1807
- }
1808
-
1809
- // ../../browser-compatible-base/lib/ast/index.js
1810
- init_process();
1811
- init_buffer();
1812
-
1813
- // ../../browser-compatible-base/lib/ast/AbstractAstNode.js
1814
- init_process();
1815
- init_buffer();
1816
- var AbstractAstNode = class {
1817
- };
1818
-
1819
- // ../../browser-compatible-base/lib/ast/AbstractWriter.js
1820
- init_process();
1821
- init_buffer();
1822
-
1823
- // ../../browser-compatible-base/lib/ast/CodeBlock.js
1824
- init_process();
1825
- init_buffer();
1826
- var CodeBlock = class extends AbstractAstNode {
1827
- constructor(value) {
1828
- super();
1829
- __publicField(this, "value");
1830
- this.value = value;
1831
- }
1832
- write(writer) {
1833
- if (typeof this.value === "string") {
1834
- writer.write(this.value);
1835
- } else {
1836
- this.value(writer);
1837
- }
1838
- }
1839
- };
1840
-
1841
- // ../../browser-compatible-base/lib/ast/AbstractWriter.js
1842
- var TAB_SIZE = 4;
1843
- var AbstractWriter = class {
1844
- constructor() {
1845
- /* The contents being written */
1846
- __publicField(this, "buffer", "");
1847
- /* Indentation level (multiple of 4) */
1848
- __publicField(this, "indentLevel", 0);
1849
- /* Whether anything has been written to the buffer */
1850
- __publicField(this, "hasWrittenAnything", false);
1851
- /* Whether the last character written was a newline */
1852
- __publicField(this, "lastCharacterIsNewline", false);
1853
- }
1854
- /**
1855
- * Writes arbitrary text
1856
- * @param text
1857
- */
1858
- write(text) {
1859
- const textEndsInNewline = text.length > 0 && text.endsWith("\n");
1860
- const textWithoutNewline = textEndsInNewline ? text.substring(0, text.length - 1) : text;
1861
- const indent = this.getIndentString();
1862
- let indentedText = textWithoutNewline.replaceAll("\n", `
1863
- ${indent}`);
1864
- if (this.isAtStartOfLine()) {
1865
- indentedText = indent + indentedText;
1866
- }
1867
- if (textEndsInNewline) {
1868
- indentedText += "\n";
1869
- }
1870
- this.writeInternal(indentedText);
1871
- }
1872
- /**
1873
- * Writes arbitrary text without indentation
1874
- * @param text
1875
- */
1876
- writeNoIndent(text) {
1877
- const currIndentLevel = this.indentLevel;
1878
- this.indentLevel = 0;
1879
- this.write(text);
1880
- this.indentLevel = currIndentLevel;
1881
- }
1882
- /**
1883
- * Writes a node
1884
- * @param node
1885
- */
1886
- writeNode(node) {
1887
- node.write(this);
1888
- }
1889
- /**
1890
- * Writes a node but then suffixes with a `;` and new line
1891
- * @param node
1892
- */
1893
- writeNodeStatement(node) {
1894
- node.write(this);
1895
- this.write(";");
1896
- this.writeNewLineIfLastLineNot();
1897
- }
1898
- /**
1899
- * Writes text but then suffixes with a `;`
1900
- * @param node
1901
- */
1902
- writeTextStatement(text) {
1903
- const codeBlock = new CodeBlock(text);
1904
- codeBlock.write(this);
1905
- this.write(";");
1906
- this.writeNewLineIfLastLineNot();
1907
- }
1908
- /**
1909
- * Writes text but then suffixes with a `;`
1910
- * @param node
1911
- */
1912
- controlFlow(prefix, statement) {
1913
- const codeBlock = new CodeBlock(prefix);
1914
- codeBlock.write(this);
1915
- this.write(" (");
1916
- this.writeNode(statement);
1917
- this.write(") {");
1918
- this.writeNewLineIfLastLineNot();
1919
- this.indent();
1920
- }
1921
- /**
1922
- * Writes text but then suffixes with a `;`
1923
- * @param node
1924
- */
1925
- endControlFlow() {
1926
- this.dedent();
1927
- this.writeLine("}");
1928
- }
1929
- /**
1930
- * Please try to not use this. It is here for swift.
1931
- * @param titles
1932
- * @param openingCharacter
1933
- * @param callback
1934
- * @param closingCharacter
1935
- */
1936
- openBlock(titles, openingCharacter = "{", callback, closingCharacter = "}") {
1937
- const filteredTitles = titles.filter((title2) => title2 !== void 0).join(" ");
1938
- if (filteredTitles) {
1939
- this.write(`${filteredTitles} ${openingCharacter != null ? openingCharacter : ""}`);
1940
- } else {
1941
- this.write(openingCharacter != null ? openingCharacter : "");
1942
- }
1943
- try {
1944
- this.indent();
1945
- callback();
1946
- this.dedent();
1947
- } finally {
1948
- this.write(closingCharacter != null ? closingCharacter : "");
1949
- }
1950
- }
1951
- /* Only writes a newline if last line in the buffer is not a newline */
1952
- writeLine(text = "") {
1953
- this.write(text);
1954
- this.writeNewLineIfLastLineNot();
1955
- }
1956
- /* Always writes newline */
1957
- newLine() {
1958
- this.writeInternal("\n");
1959
- }
1960
- writeNewLineIfLastLineNot() {
1961
- if (!this.lastCharacterIsNewline) {
1962
- this.writeInternal("\n");
1963
- }
1964
- }
1965
- indent() {
1966
- this.indentLevel++;
1967
- }
1968
- dedent() {
1969
- this.indentLevel--;
1970
- }
1971
- delimit({ nodes, delimiter, writeFunction }) {
1972
- if (nodes.length > 0) {
1973
- const firstNode = nodes[0];
1974
- if (firstNode != null) {
1975
- writeFunction(firstNode);
1976
- }
1977
- for (let i = 1; i < nodes.length; i++) {
1978
- this.write(delimiter);
1979
- const node = nodes[i];
1980
- if (node != null) {
1981
- writeFunction(node);
1982
- }
1983
- }
1984
- }
1985
- }
1986
- /*******************************
1987
- * Helper Methods
1988
- *******************************/
1989
- writeInternal(text) {
1990
- if (text.length > 0) {
1991
- this.hasWrittenAnything = true;
1992
- this.lastCharacterIsNewline = text.endsWith("\n");
1993
- }
1994
- return this.buffer += text;
1995
- }
1996
- isAtStartOfLine() {
1997
- return this.lastCharacterIsNewline || !this.hasWrittenAnything;
1998
- }
1999
- getIndentString() {
2000
- return " ".repeat(this.indentLevel * TAB_SIZE);
2001
- }
2002
- };
2003
-
2004
- // ../../browser-compatible-base/lib/dynamic-snippets/index.js
2005
- init_process();
2006
- init_buffer();
2007
-
2008
- // ../../browser-compatible-base/lib/dynamic-snippets/ErrorReporter.js
2009
- init_process();
2010
- init_buffer();
2011
- var Severity = {
2012
- Critical: "CRITICAL",
2013
- Warning: "WARNING"
2014
- };
2015
-
2016
- // ../ast/lib/index.js
2017
- init_process();
2018
- init_buffer();
2019
-
2020
- // ../ast/lib/typescript.js
2021
- var typescript_exports = {};
2022
- __export(typescript_exports, {
2023
- AstNode: () => AstNode,
2024
- ClassInstantiation: () => ClassInstantiation,
2025
- CodeBlock: () => CodeBlock2,
2026
- Comment: () => Comment,
2027
- Function: () => Function,
2028
- FunctionInvocation: () => FunctionInvocation,
2029
- MethodInvocation: () => MethodInvocation,
2030
- Parameter: () => Parameter,
2031
- Reference: () => Reference,
2032
- Type: () => Type,
2033
- TypeLiteral: () => TypeLiteral,
2034
- Types: () => Type,
2035
- Variable: () => Variable,
2036
- Writer: () => Writer,
2037
- codeblock: () => codeblock,
2038
- function_: () => function_,
2039
- instantiateClass: () => instantiateClass,
2040
- invokeFunction: () => invokeFunction,
2041
- invokeMethod: () => invokeMethod,
2042
- parameter: () => parameter,
2043
- reference: () => reference,
2044
- variable: () => variable
2045
- });
2046
- init_process();
2047
- init_buffer();
2048
-
2049
- // ../ast/lib/ast/index.js
2050
- init_process();
2051
- init_buffer();
2052
-
2053
- // ../ast/lib/ast/core/index.js
2054
- init_process();
2055
- init_buffer();
2056
-
2057
- // ../ast/lib/ast/core/AstNode.js
2058
- init_process();
2059
- init_buffer();
2060
-
2061
- // ../ast/lib/ast/core/Writer.js
2062
- init_process();
2063
- init_buffer();
2064
- var Writer = class extends AbstractWriter {
2065
- constructor({ customConfig }) {
2066
- super();
2067
- __publicField(this, "customConfig");
2068
- __publicField(this, "imports", {});
2069
- __publicField(this, "defaultImports", {});
2070
- __publicField(this, "starImportAliases", {});
2071
- __publicField(this, "starImportAliasesInverse", {});
2072
- this.customConfig = customConfig;
2073
- }
2074
- /**
2075
- * Adds the given import under its module name.
2076
- */
2077
- addImport(reference2) {
2078
- var _a, _b, _c;
2079
- if (reference2.importFrom != null) {
2080
- switch (reference2.importFrom.type) {
2081
- case "default": {
2082
- this.validateDefault(reference2);
2083
- break;
2084
- }
2085
- case "named": {
2086
- this.validateNamed(reference2);
2087
- break;
2088
- }
2089
- case "star": {
2090
- this.validateStar(reference2);
2091
- break;
2092
- }
2093
- }
2094
- const moduleImports = (_c = (_a = this.imports)[_b = reference2.importFrom.moduleName]) != null ? _c : _a[_b] = [];
2095
- const names = moduleImports.map((import_) => import_.name);
2096
- if (!names.includes(reference2.name)) {
2097
- moduleImports.push(reference2);
2098
- }
2099
- }
2100
- }
2101
- validateDefault(reference2) {
2102
- var _a, _b, _c, _d;
2103
- if (((_a = reference2.importFrom) == null ? void 0 : _a.type) !== "default") {
2104
- return;
2105
- }
2106
- const moduleDefault = (_d = (_b = this.defaultImports)[_c = reference2.importFrom.moduleName]) != null ? _d : _b[_c] = reference2;
2107
- if (moduleDefault.name !== reference2.name) {
2108
- throw new Error(`Cannot have multiple default imports for module ${reference2.importFrom.moduleName}: got ${reference2.name} but already had ${moduleDefault.name}`);
2109
- }
2110
- }
2111
- validateNamed(reference2) {
2112
- var _a, _b, _c, _d, _e;
2113
- if (((_a = reference2.importFrom) == null ? void 0 : _a.type) !== "named") {
2114
- return;
2115
- }
2116
- const existing = (_b = this.imports[reference2.importFrom.moduleName]) != null ? _b : [];
2117
- const existingStar = existing.filter((e) => {
2118
- var _a2;
2119
- return ((_a2 = e.importFrom) == null ? void 0 : _a2.type) === "star";
2120
- });
2121
- if (existingStar.length > 0) {
2122
- throw new Error(`Cannot add named import ${reference2.name} because non-named imports ${existingStar.map((e) => e.name)} already exist`);
2123
- }
2124
- const duplicates = [];
2125
- for (const references of Object.values(this.imports)) {
2126
- for (const ref of references) {
2127
- if (((_c = ref.importFrom) == null ? void 0 : _c.type) === "named" && ref.importFrom.moduleName !== reference2.importFrom.moduleName && ref.name === reference2.name) {
2128
- duplicates.push(ref);
2129
- }
2130
- }
2131
- }
2132
- if (duplicates.length > 0) {
2133
- throw new Error(`Cannot add named import from module ${reference2.importFrom.moduleName} because it is already imported from ${(_e = (_d = duplicates[0]) == null ? void 0 : _d.importFrom) == null ? void 0 : _e.moduleName}`);
2134
- }
2135
- }
2136
- validateStar(reference2) {
2137
- var _a, _b, _c, _d, _e, _f, _g;
2138
- if (((_a = reference2.importFrom) == null ? void 0 : _a.type) !== "star") {
2139
- return;
2140
- }
2141
- const moduleAlias = (_d = (_b = this.starImportAliases)[_c = reference2.importFrom.moduleName]) != null ? _d : _b[_c] = reference2.importFrom.starImportAlias;
2142
- if (moduleAlias !== reference2.importFrom.starImportAlias) {
2143
- throw new Error(`Cannot have more than one alias for non-named imports from a module: got ${reference2.importFrom.starImportAlias} but already have ${moduleAlias}.`);
2144
- }
2145
- const aliasModule = (_g = (_e = this.starImportAliasesInverse)[_f = reference2.importFrom.starImportAlias]) != null ? _g : _e[_f] = reference2.importFrom.moduleName;
2146
- if (aliasModule !== reference2.importFrom.moduleName) {
2147
- throw new Error(`Attempted to use alias ${reference2.importFrom.starImportAlias} for more than one module in the same file`);
2148
- }
2149
- }
2150
- toString() {
2151
- const imports = this.stringifyImports();
2152
- if (imports.length > 0) {
2153
- return imports + "\n" + this.buffer;
2154
- }
2155
- return this.buffer;
2156
- }
2157
- stringifyImports() {
2158
- let result = "";
2159
- for (const [module2, references] of Object.entries(this.imports)) {
2160
- const defaultImport = this.defaultImports[module2];
2161
- let stringifiedNonDefault = "";
2162
- const named = references.filter((r) => {
2163
- var _a;
2164
- return ((_a = r.importFrom) == null ? void 0 : _a.type) === "named";
2165
- });
2166
- const starImportAlias = this.starImportAliases[module2];
2167
- if (named.length > 0 || defaultImport != null || starImportAlias != null) {
2168
- result += "import";
2169
- if (defaultImport != null) {
2170
- result += ` ${defaultImport.name}`;
2171
- }
2172
- if (named.length > 0) {
2173
- for (const ref of named.slice(0, -1)) {
2174
- stringifiedNonDefault += `${ref.name}, `;
2175
- }
2176
- const lastRef = named[named.length - 1];
2177
- if (lastRef != null) {
2178
- stringifiedNonDefault += `${lastRef.name}`;
2179
- }
2180
- if (defaultImport != null) {
2181
- result += ",";
2182
- }
2183
- result += ` { ${stringifiedNonDefault} }`;
2184
- }
2185
- if (starImportAlias != null) {
2186
- if (defaultImport != null || named.length > 0) {
2187
- result += ", ";
2188
- }
2189
- result += ` * as ${starImportAlias}`;
2190
- }
2191
- result += ` from "${module2}";
2192
- `;
2193
- }
2194
- }
2195
- return result;
2196
- }
2197
- };
2198
-
2199
- // ../ast/lib/ast/core/AstNode.js
2200
- var AstNode = class extends AbstractAstNode {
2201
- /**
2202
- * Writes the node to a string.
2203
- */
2204
- async toString({ customConfig }) {
2205
- const writer = new Writer({ customConfig });
2206
- this.write(writer);
2207
- return writer.toString();
2208
- }
2209
- toStringSync({ customConfig }) {
2210
- const writer = new Writer({ customConfig });
2211
- this.write(writer);
2212
- return writer.toString();
2213
- }
2214
- };
2215
-
2216
- // ../ast/lib/ast/CodeBlock.js
2217
- init_process();
2218
- init_buffer();
2219
- var CodeBlock2 = class extends AstNode {
2220
- constructor(args) {
2221
- super();
2222
- __publicField(this, "args");
2223
- this.args = args;
2224
- }
2225
- write(writer) {
2226
- const commonCodeBlock = new CodeBlock(this.args);
2227
- return commonCodeBlock.write(writer);
2228
- }
2229
- };
2230
-
2231
- // ../ast/lib/ast/Type.js
2232
- init_process();
2233
- init_buffer();
2234
- var Type = class extends AstNode {
2235
- constructor(internalType) {
2236
- super();
2237
- __publicField(this, "internalType");
2238
- this.internalType = internalType;
2239
- }
2240
- write(writer) {
2241
- switch (this.internalType.type) {
2242
- case "string":
2243
- writer.write("string");
2244
- break;
2245
- case "number":
2246
- writer.write("number");
2247
- break;
2248
- case "bigint":
2249
- writer.write("bigint");
2250
- break;
2251
- case "boolean":
2252
- writer.write("boolean");
2253
- break;
2254
- case "array":
2255
- this.internalType.valueType.write(writer);
2256
- writer.write("[]");
2257
- break;
2258
- case "map":
2259
- writer.write("Record<");
2260
- this.internalType.keyType.write(writer);
2261
- writer.write(", ");
2262
- this.internalType.valueType.write(writer);
2263
- writer.write(">");
2264
- break;
2265
- case "object":
2266
- writer.write("{");
2267
- writer.indent();
2268
- for (const [key, value] of Object.entries(this.internalType.fields)) {
2269
- writer.write(`${key}: `);
2270
- value.write(writer);
2271
- writer.writeLine(",");
2272
- }
2273
- writer.dedent();
2274
- writer.write("}");
2275
- break;
2276
- case "enum":
2277
- writer.write("enum");
2278
- break;
2279
- case "any":
2280
- writer.write("any");
2281
- break;
2282
- case "promise":
2283
- writer.write("Promise<");
2284
- this.internalType.value.write(writer);
2285
- writer.write(">");
2286
- break;
2287
- case "unknown":
2288
- writer.write("unknown");
2289
- break;
2290
- case "void":
2291
- writer.write("void");
2292
- break;
2293
- case "undefined":
2294
- writer.write("undefined");
2295
- break;
2296
- case "null":
2297
- writer.write("null");
2298
- break;
2299
- case "never":
2300
- writer.write("never");
2301
- break;
2302
- case "nop":
2303
- break;
2304
- default:
2305
- assertNever(this.internalType);
2306
- }
2307
- }
2308
- /* Static factory methods for creating a Type */
2309
- static string() {
2310
- return new this({
2311
- type: "string"
2312
- });
2313
- }
2314
- static number() {
2315
- return new this({
2316
- type: "number"
2317
- });
2318
- }
2319
- static bigint() {
2320
- return new this({
2321
- type: "bigint"
2322
- });
2323
- }
2324
- static boolean() {
2325
- return new this({
2326
- type: "boolean"
2327
- });
2328
- }
2329
- static array(valueType) {
2330
- return new this({
2331
- type: "array",
2332
- valueType
2333
- });
2334
- }
2335
- static object(fields) {
2336
- return new this({
2337
- type: "object",
2338
- fields
2339
- });
2340
- }
2341
- static enum(values) {
2342
- return new this({
2343
- type: "enum",
2344
- values
2345
- });
2346
- }
2347
- static any() {
2348
- return new this({
2349
- type: "any"
2350
- });
2351
- }
2352
- static promise(value) {
2353
- if (value.internalType.type === "promise") {
2354
- return value;
2355
- }
2356
- return new this({
2357
- type: "promise",
2358
- value
2359
- });
2360
- }
2361
- static unknown() {
2362
- return new this({
2363
- type: "unknown"
2364
- });
2365
- }
2366
- static void() {
2367
- return new this({
2368
- type: "void"
2369
- });
2370
- }
2371
- static undefined() {
2372
- return new this({
2373
- type: "undefined"
2374
- });
2375
- }
2376
- static null() {
2377
- return new this({
2378
- type: "null"
2379
- });
2380
- }
2381
- static never() {
2382
- return new this({
2383
- type: "never"
2384
- });
2385
- }
2386
- static nop() {
2387
- return new this({
2388
- type: "nop"
2389
- });
2390
- }
2391
- };
2392
-
2393
- // ../ast/lib/ast/TypeLiteral.js
2394
- init_process();
2395
- init_buffer();
2396
- var TypeLiteral = class _TypeLiteral extends AstNode {
2397
- constructor(internalType) {
2398
- super();
2399
- __publicField(this, "internalType");
2400
- this.internalType = internalType;
2401
- }
2402
- write(writer) {
2403
- var _a, _b, _c, _d;
2404
- switch (this.internalType.type) {
2405
- case "array": {
2406
- this.writeIterable({ writer, iterable: this.internalType });
2407
- break;
2408
- }
2409
- case "blob": {
2410
- if ((_a = writer.customConfig) == null ? void 0 : _a.noSerdeLayer) {
2411
- writer.writeNode(_TypeLiteral.string(this.internalType.value));
2412
- return;
2413
- }
2414
- writer.write("new Blob([");
2415
- writer.writeNode(_TypeLiteral.string(this.internalType.value));
2416
- writer.write("])");
2417
- break;
2418
- }
2419
- case "boolean": {
2420
- writer.write(this.internalType.value.toString());
2421
- break;
2422
- }
2423
- case "bigint": {
2424
- if ((_b = writer.customConfig) == null ? void 0 : _b.noSerdeLayer) {
2425
- writer.writeNode(_TypeLiteral.string(this.internalType.value.toString()));
2426
- return;
2427
- }
2428
- writer.write(`BigInt(${this.internalType.value.toString()})`);
2429
- break;
2430
- }
2431
- case "datetime": {
2432
- if ((_c = writer.customConfig) == null ? void 0 : _c.noSerdeLayer) {
2433
- writer.writeNode(_TypeLiteral.string(this.internalType.value));
2434
- return;
2435
- }
2436
- writer.write("new Date(");
2437
- writer.writeNode(_TypeLiteral.string(this.internalType.value));
2438
- writer.write(")");
2439
- break;
2440
- }
2441
- case "number": {
2442
- writer.write(this.internalType.value.toString());
2443
- break;
2444
- }
2445
- case "object": {
2446
- this.writeObject({ writer, object: this.internalType });
2447
- break;
2448
- }
2449
- case "record": {
2450
- this.writeRecord({ writer, record: this.internalType });
2451
- break;
2452
- }
2453
- case "reference": {
2454
- writer.writeNode(this.internalType.value);
2455
- break;
2456
- }
2457
- case "set": {
2458
- if (((_d = writer.customConfig) == null ? void 0 : _d.noSerdeLayer) || this.isSetOfObjects()) {
2459
- writer.writeNode(_TypeLiteral.array({ values: this.internalType.values }));
2460
- return;
2461
- }
2462
- writer.write("new Set(");
2463
- this.writeIterable({ writer, iterable: this.internalType });
2464
- writer.write(")");
2465
- break;
2466
- }
2467
- case "string": {
2468
- if (this.internalType.value.includes("\n")) {
2469
- this.writeStringWithBackticks({ writer, value: this.internalType.value });
2470
- } else {
2471
- writer.write(`"${this.internalType.value.replaceAll('"', '\\"')}"`);
2472
- }
2473
- break;
2474
- }
2475
- case "tuple": {
2476
- this.writeIterable({ writer, iterable: this.internalType });
2477
- break;
2478
- }
2479
- case "unknown": {
2480
- this.writeUnknown({ writer, value: this.internalType.value });
2481
- break;
2482
- }
2483
- case "nop":
2484
- break;
2485
- default:
2486
- assertNever(this.internalType);
2487
- }
2488
- }
2489
- isObject() {
2490
- return this.internalType.type === "object";
2491
- }
2492
- asObjectOrThrow() {
2493
- if (this.isObject()) {
2494
- return this.internalType;
2495
- }
2496
- throw new Error("Internal error; ts.TypeLiteral is not an object");
2497
- }
2498
- isSet() {
2499
- return this.internalType.type === "set";
2500
- }
2501
- asSetOrThrow() {
2502
- if (this.isSet()) {
2503
- return this.internalType;
2504
- }
2505
- throw new Error("Internal error; ts.TypeLiteral is not a set");
2506
- }
2507
- isSetOfObjects() {
2508
- return this.isSet() && this.asSetOrThrow().values.every((value) => value.isObject());
2509
- }
2510
- writeStringWithBackticks({ writer, value }) {
2511
- writer.write("`");
2512
- const parts = value.split("\n");
2513
- const head = parts[0] + "\n";
2514
- const tail = parts.slice(1).join("\n");
2515
- writer.write(head.replaceAll("`", "\\`"));
2516
- writer.writeNoIndent(tail.replaceAll("`", "\\`"));
2517
- writer.write("`");
2518
- }
2519
- writeIterable({ writer, iterable }) {
2520
- const values = filterNopValues({ values: iterable.values });
2521
- if (values.length === 0) {
2522
- writer.write("[]");
2523
- return;
2524
- }
2525
- writer.writeLine("[");
2526
- writer.indent();
2527
- for (const value of values) {
2528
- value.write(writer);
2529
- writer.writeLine(",");
2530
- }
2531
- writer.dedent();
2532
- writer.write("]");
2533
- }
2534
- writeRecord({ writer, record }) {
2535
- const entries = filterNopRecordEntries({ entries: record.entries });
2536
- if (entries.length === 0) {
2537
- writer.write("{}");
2538
- return;
2539
- }
2540
- writer.writeLine("{");
2541
- writer.indent();
2542
- for (const entry of entries) {
2543
- entry.key.write(writer);
2544
- writer.write(": ");
2545
- entry.value.write(writer);
2546
- writer.writeLine(",");
2547
- }
2548
- writer.dedent();
2549
- writer.write("}");
2550
- }
2551
- writeObject({ writer, object }) {
2552
- const fields = filterNopObjectFields({ fields: object.fields });
2553
- if (fields.length === 0) {
2554
- writer.write("{}");
2555
- return;
2556
- }
2557
- writer.writeLine("{");
2558
- writer.indent();
2559
- for (const field of fields) {
2560
- writer.write(`${field.name}: `);
2561
- field.value.write(writer);
2562
- writer.writeLine(",");
2563
- }
2564
- writer.dedent();
2565
- writer.write("}");
2566
- }
2567
- /* Static factory methods for creating a TypeLiteral */
2568
- static array({ values }) {
2569
- return new this({
2570
- type: "array",
2571
- values
2572
- });
2573
- }
2574
- static bigint(value) {
2575
- return new this({ type: "bigint", value });
2576
- }
2577
- static blob(value) {
2578
- return new this({ type: "blob", value });
2579
- }
2580
- static boolean(value) {
2581
- return new this({ type: "boolean", value });
2582
- }
2583
- static datetime(value) {
2584
- return new this({ type: "datetime", value });
2585
- }
2586
- static number(value) {
2587
- return new this({ type: "number", value });
2588
- }
2589
- static object({ fields }) {
2590
- return new this({
2591
- type: "object",
2592
- fields
2593
- });
2594
- }
2595
- static record({ entries }) {
2596
- return new this({
2597
- type: "record",
2598
- entries
2599
- });
2600
- }
2601
- static reference(value) {
2602
- return new this({
2603
- type: "reference",
2604
- value
2605
- });
2606
- }
2607
- static set({ values }) {
2608
- return new this({
2609
- type: "set",
2610
- values
2611
- });
2612
- }
2613
- static string(value) {
2614
- return new this({
2615
- type: "string",
2616
- value
2617
- });
2618
- }
2619
- static tuple({ values }) {
2620
- return new this({
2621
- type: "tuple",
2622
- values
2623
- });
2624
- }
2625
- static unknown(value) {
2626
- return new this({ type: "unknown", value });
2627
- }
2628
- static nop() {
2629
- return new this({ type: "nop" });
2630
- }
2631
- static isNop(typeLiteral) {
2632
- return typeLiteral.internalType.type === "nop";
2633
- }
2634
- writeUnknown({ writer, value }) {
2635
- switch (typeof value) {
2636
- case "boolean":
2637
- writer.write(value.toString());
2638
- return;
2639
- case "string":
2640
- writer.write(value.includes('"') ? `\`${value}\`` : `"${value}"`);
2641
- return;
2642
- case "number":
2643
- writer.write(value.toString());
2644
- return;
2645
- case "object":
2646
- if (value == null) {
2647
- writer.write("null");
2648
- return;
2649
- }
2650
- if (Array.isArray(value)) {
2651
- this.writeUnknownArray({ writer, value });
2652
- return;
2653
- }
2654
- this.writeUnknownObject({ writer, value });
2655
- return;
2656
- default:
2657
- throw new Error(`Internal error; unsupported unknown type: ${typeof value}`);
2658
- }
2659
- }
2660
- writeUnknownArray({ writer, value }) {
2661
- if (value.length === 0) {
2662
- writer.write("[]");
2663
- return;
2664
- }
2665
- writer.writeLine("[");
2666
- writer.indent();
2667
- for (const element of value) {
2668
- writer.writeNode(_TypeLiteral.unknown(element));
2669
- writer.writeLine(",");
2670
- }
2671
- writer.dedent();
2672
- writer.write("]");
2673
- }
2674
- writeUnknownObject({ writer, value }) {
2675
- const entries = Object.entries(value);
2676
- if (entries.length === 0) {
2677
- writer.write("{}");
2678
- return;
2679
- }
2680
- writer.writeLine("{");
2681
- writer.indent();
2682
- for (const [key, val] of entries) {
2683
- writer.write(`${key}: `);
2684
- writer.writeNode(_TypeLiteral.unknown(val));
2685
- writer.writeLine(",");
2686
- }
2687
- writer.dedent();
2688
- writer.write("}");
2689
- }
2690
- };
2691
- function filterNopObjectFields({ fields }) {
2692
- return fields.filter((field) => !TypeLiteral.isNop(field.value));
2693
- }
2694
- function filterNopRecordEntries({ entries }) {
2695
- return entries.filter((entry) => !TypeLiteral.isNop(entry.key) && !TypeLiteral.isNop(entry.value));
2696
- }
2697
- function filterNopValues({ values }) {
2698
- return values.filter((value) => !TypeLiteral.isNop(value));
2699
- }
2700
-
2701
- // ../ast/lib/ast/Reference.js
2702
- init_process();
2703
- init_buffer();
2704
- var Reference = class extends AstNode {
2705
- constructor({ name, importFrom, memberName }) {
2706
- super();
2707
- __publicField(this, "name");
2708
- __publicField(this, "importFrom");
2709
- __publicField(this, "memberName");
2710
- this.name = name;
2711
- this.importFrom = importFrom;
2712
- this.memberName = memberName;
2713
- }
2714
- write(writer) {
2715
- var _a;
2716
- if (this.importFrom != null) {
2717
- writer.addImport(this);
2718
- }
2719
- const prefix = ((_a = this.importFrom) == null ? void 0 : _a.type) === "star" ? `${this.importFrom.starImportAlias}.` : "";
2720
- const suffix = this.memberName != null ? `.${this.memberName}` : "";
2721
- writer.write(`${prefix}${this.name}${suffix}`);
2722
- }
2723
- };
2724
-
2725
- // ../ast/lib/ast/Variable.js
2726
- init_process();
2727
- init_buffer();
2728
- var Variable = class extends AstNode {
2729
- constructor(args) {
2730
- super();
2731
- __publicField(this, "args");
2732
- this.args = args;
2733
- }
2734
- write(writer) {
2735
- if (this.args.export) {
2736
- writer.write("export ");
2737
- }
2738
- if (this.args.const) {
2739
- writer.write("const ");
2740
- } else {
2741
- writer.write("let ");
2742
- }
2743
- writer.write(`${this.args.name} = `);
2744
- writer.writeNode(this.args.initializer);
2745
- }
2746
- };
2747
-
2748
- // ../ast/lib/ast/Parameter.js
2749
- init_process();
2750
- init_buffer();
2751
-
2752
- // ../ast/lib/ast/Comment.js
2753
- init_process();
2754
- init_buffer();
2755
- var Comment = class extends AstNode {
2756
- constructor({ docs } = { docs: void 0 }) {
2757
- super();
2758
- __publicField(this, "docs");
2759
- this.docs = docs;
2760
- }
2761
- write(writer) {
2762
- if (this.docs != null) {
2763
- writer.writeLine("/**");
2764
- this.docs.split("\n").forEach((line) => {
2765
- writer.writeLine(` * ${line}`);
2766
- });
2767
- writer.writeLine("*/");
2768
- }
2769
- }
2770
- };
2771
-
2772
- // ../ast/lib/ast/Parameter.js
2773
- var Parameter = class extends AstNode {
2774
- constructor({ name, type, docs }) {
2775
- super();
2776
- __publicField(this, "name");
2777
- __publicField(this, "type");
2778
- __publicField(this, "docs");
2779
- this.name = name;
2780
- this.type = type;
2781
- this.docs = docs;
2782
- }
2783
- write(writer) {
2784
- writer.write(`${this.name}`);
2785
- }
2786
- writeWithType(writer) {
2787
- if (this.docs != null) {
2788
- writer.writeNode(new Comment({ docs: this.docs }));
2789
- }
2790
- writer.write(`${this.name}: `);
2791
- this.type.write(writer);
2792
- }
2793
- };
2794
-
2795
- // ../ast/lib/ast/Function.js
2796
- init_process();
2797
- init_buffer();
2798
- var Function = class extends AstNode {
2799
- constructor({ name, parameters, async, body, return_, docs }) {
2800
- super();
2801
- __publicField(this, "name");
2802
- __publicField(this, "parameters");
2803
- __publicField(this, "async");
2804
- __publicField(this, "body");
2805
- __publicField(this, "return_");
2806
- __publicField(this, "docs");
2807
- this.name = name;
2808
- this.parameters = parameters;
2809
- this.async = async != null ? async : false;
2810
- this.body = body;
2811
- this.return_ = return_;
2812
- this.docs = docs;
2813
- }
2814
- write(writer) {
2815
- var _a;
2816
- writer.writeNode(new Comment({ docs: this.docs }));
2817
- if (this.async) {
2818
- writer.write("async ");
2819
- }
2820
- writer.write("function ");
2821
- writer.write(`${this.name}`);
2822
- this.writeParameters(writer);
2823
- if (this.return_ != null) {
2824
- writer.write(": ");
2825
- writer.writeNode(this.async ? Type.promise(this.return_) : this.return_);
2826
- }
2827
- writer.writeLine(" {");
2828
- writer.indent();
2829
- (_a = this.body) == null ? void 0 : _a.write(writer);
2830
- writer.dedent();
2831
- writer.writeNewLineIfLastLineNot();
2832
- writer.writeLine("}");
2833
- }
2834
- writeParameters(writer) {
2835
- if (this.parameters.length === 0) {
2836
- writer.write("()");
2837
- return;
2838
- }
2839
- writer.writeLine("(");
2840
- writer.delimit({
2841
- nodes: this.parameters,
2842
- delimiter: ",\n",
2843
- writeFunction: (parameter2) => parameter2.writeWithType(writer)
2844
- });
2845
- writer.write(")");
2846
- }
2847
- };
2848
-
2849
- // ../ast/lib/ast/FunctionInvocation.js
2850
- init_process();
2851
- init_buffer();
2852
- var FunctionInvocation = class extends AstNode {
2853
- constructor({ function_: function_2, arguments_ }) {
2854
- super();
2855
- __publicField(this, "function_");
2856
- __publicField(this, "arguments_");
2857
- this.function_ = function_2;
2858
- this.arguments_ = arguments_;
2859
- }
2860
- write(writer) {
2861
- writer.writeNode(this.function_);
2862
- writer.write("(");
2863
- writer.delimit({
2864
- nodes: this.arguments_,
2865
- delimiter: ", ",
2866
- writeFunction: (argument) => argument.write(writer)
2867
- });
2868
- writer.write(")");
2869
- }
2870
- };
2871
-
2872
- // ../ast/lib/ast/MethodInvocation.js
2873
- init_process();
2874
- init_buffer();
2875
- var MethodInvocation = class extends AstNode {
2876
- constructor({ on: on2, method, arguments_, async }) {
2877
- super();
2878
- __publicField(this, "on");
2879
- __publicField(this, "method");
2880
- __publicField(this, "arguments_");
2881
- __publicField(this, "async");
2882
- this.on = on2;
2883
- this.method = method;
2884
- this.arguments_ = arguments_;
2885
- this.async = async;
2886
- }
2887
- write(writer) {
2888
- if (this.async) {
2889
- writer.write("await ");
2890
- }
2891
- this.on.write(writer);
2892
- writer.write(".");
2893
- writer.write(this.method);
2894
- writer.write("(");
2895
- writer.delimit({
2896
- nodes: this.arguments_,
2897
- delimiter: ", ",
2898
- writeFunction: (argument) => argument.write(writer)
2899
- });
2900
- writer.write(")");
2901
- }
2902
- };
2903
-
2904
- // ../ast/lib/ast/ClassInstantiation.js
2905
- init_process();
2906
- init_buffer();
2907
- var ClassInstantiation = class extends AstNode {
2908
- constructor({ class_, arguments_ }) {
2909
- super();
2910
- __publicField(this, "class_");
2911
- __publicField(this, "arguments_");
2912
- this.class_ = class_;
2913
- this.arguments_ = arguments_;
2914
- }
2915
- write(writer) {
2916
- writer.write("new ");
2917
- writer.writeNode(this.class_);
2918
- writer.write("(");
2919
- writer.delimit({
2920
- nodes: this.arguments_,
2921
- delimiter: ", ",
2922
- writeFunction: (argument) => argument.write(writer)
2923
- });
2924
- writer.write(")");
2925
- }
2926
- };
2927
-
2928
- // ../ast/lib/typescript.js
2929
- function codeblock(arg) {
2930
- return new CodeBlock2(arg);
2931
- }
2932
- function function_(args) {
2933
- return new Function(args);
2934
- }
2935
- function instantiateClass(args) {
2936
- return new ClassInstantiation(args);
2937
- }
2938
- function invokeFunction(args) {
2939
- return new FunctionInvocation(args);
2940
- }
2941
- function invokeMethod(args) {
2942
- return new MethodInvocation(args);
2943
- }
2944
- function parameter(args) {
2945
- return new Parameter(args);
2946
- }
2947
- function reference(arg) {
2948
- return new Reference(arg);
2949
- }
2950
- function variable(arg) {
2951
- return new Variable(arg);
2952
- }
2953
-
2954
- // src/context/DynamicTypeLiteralMapper.ts
2955
- var UNION_VALUE_KEY = "value";
2956
- var DynamicTypeLiteralMapper = class {
2957
- constructor({ context }) {
2958
- __publicField(this, "context");
2959
- this.context = context;
2960
- }
2961
- convert(args) {
2962
- if (args.value == null) {
2963
- return typescript_exports.TypeLiteral.nop();
2964
- }
2965
- switch (args.typeReference.type) {
2966
- case "list":
2967
- return this.convertList({ list: args.typeReference.value, value: args.value });
2968
- case "literal":
2969
- return this.convertLiteral({ literalType: args.typeReference.value, value: args.value });
2970
- case "map":
2971
- return this.convertMap({ map: args.typeReference, value: args.value });
2972
- case "named": {
2973
- const named = this.context.resolveNamedType({ typeId: args.typeReference.value });
2974
- if (named == null) {
2975
- return typescript_exports.TypeLiteral.nop();
2976
- }
2977
- return this.convertNamed({ named, value: args.value, as: args.as });
2978
- }
2979
- case "optional":
2980
- return this.convert({ typeReference: args.typeReference.value, value: args.value, as: args.as });
2981
- case "primitive":
2982
- return this.convertPrimitive({ primitive: args.typeReference.value, value: args.value, as: args.as });
2983
- case "set":
2984
- return this.convertSet({ set: args.typeReference.value, value: args.value });
2985
- case "unknown":
2986
- return this.convertUnknown({ value: args.value });
2987
- default:
2988
- assertNever(args.typeReference);
2989
- }
2990
- }
2991
- convertLiteral({
2992
- literalType,
2993
- value
2994
- }) {
2995
- switch (literalType.type) {
2996
- case "boolean": {
2997
- const bool = this.context.getValueAsBoolean({ value });
2998
- if (bool == null) {
2999
- return typescript_exports.TypeLiteral.nop();
3000
- }
3001
- return typescript_exports.TypeLiteral.boolean(bool);
3002
- }
3003
- case "string": {
3004
- const str = this.context.getValueAsString({ value });
3005
- if (str == null) {
3006
- return typescript_exports.TypeLiteral.nop();
3007
- }
3008
- return typescript_exports.TypeLiteral.string(str);
3009
- }
3010
- default:
3011
- assertNever(literalType);
3012
- }
3013
- }
3014
- convertList({ list, value }) {
3015
- if (!Array.isArray(value)) {
3016
- this.context.errors.add({
3017
- severity: Severity.Critical,
3018
- message: `Expected array but got: ${typeof value}`
3019
- });
3020
- return typescript_exports.TypeLiteral.nop();
3021
- }
3022
- return typescript_exports.TypeLiteral.array({
3023
- values: value.map((v, index) => {
3024
- this.context.errors.scope({ index });
3025
- try {
3026
- return this.convert({ typeReference: list, value: v });
3027
- } finally {
3028
- this.context.errors.unscope();
3029
- }
3030
- })
3031
- });
3032
- }
3033
- convertSet({ set, value }) {
3034
- if (!Array.isArray(value)) {
3035
- this.context.errors.add({
3036
- severity: Severity.Critical,
3037
- message: `Expected array but got: ${typeof value}`
3038
- });
3039
- return typescript_exports.TypeLiteral.nop();
3040
- }
3041
- return typescript_exports.TypeLiteral.set({
3042
- values: value.map((v, index) => {
3043
- this.context.errors.scope({ index });
3044
- try {
3045
- return this.convert({ typeReference: set, value: v });
3046
- } finally {
3047
- this.context.errors.unscope();
3048
- }
3049
- })
3050
- });
3051
- }
3052
- convertMap({ map, value }) {
3053
- if (typeof value !== "object" || value == null) {
3054
- this.context.errors.add({
3055
- severity: Severity.Critical,
3056
- message: `Expected object but got: ${value == null ? "null" : typeof value}`
3057
- });
3058
- return typescript_exports.TypeLiteral.nop();
3059
- }
3060
- return typescript_exports.TypeLiteral.record({
3061
- entries: Object.entries(value).map(([key, value2]) => {
3062
- this.context.errors.scope(key);
3063
- try {
3064
- return {
3065
- key: this.convert({ typeReference: map.key, value: key, as: "key" }),
3066
- value: this.convert({ typeReference: map.value, value: value2 })
3067
- };
3068
- } finally {
3069
- this.context.errors.unscope();
3070
- }
3071
- })
3072
- });
3073
- }
3074
- convertNamed({
3075
- named,
3076
- value,
3077
- as
3078
- }) {
3079
- var _a;
3080
- switch (named.type) {
3081
- case "alias": {
3082
- if ((_a = this.context.customConfig) == null ? void 0 : _a.useBrandedStringAliases) {
3083
- return typescript_exports.TypeLiteral.reference(
3084
- typescript_exports.codeblock((writer) => {
3085
- writer.writeNode(
3086
- typescript_exports.reference({
3087
- name: this.context.namespaceExport,
3088
- importFrom: this.context.getModuleImport(),
3089
- memberName: this.context.getFullyQualifiedReference({
3090
- declaration: named.declaration
3091
- })
3092
- })
3093
- );
3094
- writer.write("(");
3095
- writer.writeNode(this.convert({ typeReference: named.typeReference, value, as }));
3096
- writer.write(")");
3097
- })
3098
- );
3099
- }
3100
- return this.convert({ typeReference: named.typeReference, value, as });
3101
- }
3102
- case "discriminatedUnion":
3103
- return this.convertDiscriminatedUnion({
3104
- discriminatedUnion: named,
3105
- value
3106
- });
3107
- case "enum":
3108
- return this.convertEnum({ enum_: named, value });
3109
- case "object":
3110
- return this.convertObject({ object_: named, value });
3111
- case "undiscriminatedUnion":
3112
- return this.convertUndicriminatedUnion({ undicriminatedUnion: named, value });
3113
- default:
3114
- assertNever(named);
3115
- }
3116
- }
3117
- convertDiscriminatedUnion({
3118
- discriminatedUnion,
3119
- value
3120
- }) {
3121
- var _a;
3122
- const discriminatedUnionTypeInstance = this.context.resolveDiscriminatedUnionTypeInstance({
3123
- discriminatedUnion,
3124
- value
3125
- });
3126
- if (discriminatedUnionTypeInstance == null) {
3127
- return typescript_exports.TypeLiteral.nop();
3128
- }
3129
- const unionVariant = discriminatedUnionTypeInstance.singleDiscriminatedUnionType;
3130
- const unionProperties = this.convertDiscriminatedUnionProperties({
3131
- discriminatedUnionTypeInstance,
3132
- unionVariant
3133
- });
3134
- if (unionProperties == null) {
3135
- return typescript_exports.TypeLiteral.nop();
3136
- }
3137
- if ((_a = this.context.customConfig) == null ? void 0 : _a.includeUtilsOnUnionMembers) {
3138
- return typescript_exports.TypeLiteral.reference(
3139
- typescript_exports.codeblock((writer) => {
3140
- writer.writeNode(
3141
- typescript_exports.invokeMethod({
3142
- on: typescript_exports.reference({
3143
- name: this.context.namespaceExport,
3144
- importFrom: this.context.getModuleImport(),
3145
- memberName: this.context.getFullyQualifiedReference({
3146
- declaration: discriminatedUnion.declaration
3147
- })
3148
- }),
3149
- method: this.context.getMethodName(unionVariant.discriminantValue.name),
3150
- arguments_: this.convertDiscriminatedUnionUtilsArgs({
3151
- discriminatedUnionTypeInstance,
3152
- unionVariant,
3153
- unionProperties
3154
- })
3155
- })
3156
- );
3157
- })
3158
- );
3159
- }
3160
- const discriminantProperty = {
3161
- name: this.context.getPropertyName(discriminatedUnion.discriminant.name),
3162
- value: typescript_exports.TypeLiteral.string(unionVariant.discriminantValue.wireValue)
3163
- };
3164
- return typescript_exports.TypeLiteral.object({
3165
- fields: [discriminantProperty, ...unionProperties]
3166
- });
3167
- }
3168
- convertDiscriminatedUnionProperties({
3169
- discriminatedUnionTypeInstance,
3170
- unionVariant
3171
- }) {
3172
- const baseFields = this.getBaseFields({
3173
- discriminatedUnionTypeInstance,
3174
- singleDiscriminatedUnionType: unionVariant
3175
- });
3176
- switch (unionVariant.type) {
3177
- case "samePropertiesAsObject": {
3178
- const named = this.context.resolveNamedType({
3179
- typeId: unionVariant.typeId
3180
- });
3181
- if (named == null) {
3182
- return void 0;
3183
- }
3184
- const converted = this.convertNamed({ named, value: discriminatedUnionTypeInstance.value });
3185
- if (!converted.isObject()) {
3186
- this.context.errors.add({
3187
- severity: Severity.Critical,
3188
- message: "Internal error; expected union value to be an object"
3189
- });
3190
- return void 0;
3191
- }
3192
- const object_ = converted.asObjectOrThrow();
3193
- return [...baseFields, ...object_.fields];
3194
- }
3195
- case "singleProperty": {
3196
- try {
3197
- this.context.errors.scope(unionVariant.discriminantValue.wireValue);
3198
- const record = this.context.getRecord(discriminatedUnionTypeInstance.value);
3199
- if (record == null) {
3200
- return [
3201
- ...baseFields,
3202
- {
3203
- name: UNION_VALUE_KEY,
3204
- value: this.convert({
3205
- typeReference: unionVariant.typeReference,
3206
- value: discriminatedUnionTypeInstance.value
3207
- })
3208
- }
3209
- ];
3210
- }
3211
- return [
3212
- ...baseFields,
3213
- {
3214
- name: this.context.getPropertyName(unionVariant.discriminantValue.name),
3215
- value: this.convert({
3216
- typeReference: unionVariant.typeReference,
3217
- value: record[unionVariant.discriminantValue.wireValue]
3218
- })
3219
- }
3220
- ];
3221
- } finally {
3222
- this.context.errors.unscope();
3223
- }
3224
- }
3225
- case "noProperties":
3226
- return baseFields;
3227
- default:
3228
- assertNever(unionVariant);
3229
- }
3230
- }
3231
- convertDiscriminatedUnionUtilsArgs({
3232
- discriminatedUnionTypeInstance,
3233
- unionVariant,
3234
- unionProperties
3235
- }) {
3236
- if (unionVariant.type === "singleProperty") {
3237
- const record = this.context.getRecord(discriminatedUnionTypeInstance.value);
3238
- if (record == null && unionProperties.length === 1) {
3239
- return [
3240
- this.convert({
3241
- typeReference: unionVariant.typeReference,
3242
- value: discriminatedUnionTypeInstance.value
3243
- })
3244
- ];
3245
- }
3246
- }
3247
- return unionProperties.length > 0 ? [typescript_exports.TypeLiteral.object({ fields: unionProperties })] : [];
3248
- }
3249
- getBaseFields({
3250
- discriminatedUnionTypeInstance,
3251
- singleDiscriminatedUnionType
3252
- }) {
3253
- var _a, _b;
3254
- const properties = this.context.associateByWireValue({
3255
- parameters: (_a = singleDiscriminatedUnionType.properties) != null ? _a : [],
3256
- values: (_b = this.context.getRecord(discriminatedUnionTypeInstance.value)) != null ? _b : {},
3257
- // We're only selecting the base properties here. The rest of the properties
3258
- // are handled by the union variant.
3259
- ignoreMissingParameters: true
3260
- });
3261
- return properties.map((property) => {
3262
- this.context.errors.scope(property.name.wireValue);
3263
- try {
3264
- return {
3265
- name: this.context.getPropertyName(property.name.name),
3266
- value: this.convert(property)
3267
- };
3268
- } finally {
3269
- this.context.errors.unscope();
3270
- }
3271
- });
3272
- }
3273
- convertObject({ object_, value }) {
3274
- var _a;
3275
- const properties = this.context.associateByWireValue({
3276
- parameters: object_.properties,
3277
- values: (_a = this.context.getRecord(value)) != null ? _a : {}
3278
- });
3279
- return typescript_exports.TypeLiteral.object({
3280
- fields: properties.map((property) => {
3281
- this.context.errors.scope(property.name.wireValue);
3282
- try {
3283
- return {
3284
- name: this.context.getPropertyName(property.name.name),
3285
- value: this.convert(property)
3286
- };
3287
- } finally {
3288
- this.context.errors.unscope();
3289
- }
3290
- })
3291
- });
3292
- }
3293
- convertEnum({ enum_, value }) {
3294
- const enumValue = this.getEnumValue({ enum_, value });
3295
- if (enumValue == null) {
3296
- return typescript_exports.TypeLiteral.nop();
3297
- }
3298
- return typescript_exports.TypeLiteral.string(enumValue);
3299
- }
3300
- getEnumValue({ enum_, value }) {
3301
- if (typeof value !== "string") {
3302
- this.context.errors.add({
3303
- severity: Severity.Critical,
3304
- message: `Expected enum value string, got: ${typeof value}`
3305
- });
3306
- return void 0;
3307
- }
3308
- const enumValue = enum_.values.find((v) => v.wireValue === value);
3309
- if (enumValue == null) {
3310
- this.context.errors.add({
3311
- severity: Severity.Critical,
3312
- message: `An enum value named "${value}" does not exist in this context`
3313
- });
3314
- return void 0;
3315
- }
3316
- return value;
3317
- }
3318
- convertUndicriminatedUnion({
3319
- undicriminatedUnion,
3320
- value
3321
- }) {
3322
- const result = this.findMatchingUndiscriminatedUnionType({
3323
- undicriminatedUnion,
3324
- value
3325
- });
3326
- if (result == null) {
3327
- return typescript_exports.TypeLiteral.nop();
3328
- }
3329
- return result;
3330
- }
3331
- findMatchingUndiscriminatedUnionType({
3332
- undicriminatedUnion,
3333
- value
3334
- }) {
3335
- for (const typeReference of undicriminatedUnion.types) {
3336
- try {
3337
- return this.convert({ typeReference, value });
3338
- } catch (e) {
3339
- continue;
3340
- }
3341
- }
3342
- this.context.errors.add({
3343
- severity: Severity.Critical,
3344
- message: `None of the types in the undicriminated union matched the given "${typeof value}" value`
3345
- });
3346
- return void 0;
3347
- }
3348
- convertUnknown({ value }) {
3349
- return typescript_exports.TypeLiteral.unknown(value);
3350
- }
3351
- convertPrimitive({
3352
- primitive,
3353
- value,
3354
- as
3355
- }) {
3356
- var _a, _b;
3357
- switch (primitive) {
3358
- case "INTEGER":
3359
- case "UINT": {
3360
- const num = this.getValueAsNumber({ value, as });
3361
- if (num == null) {
3362
- return typescript_exports.TypeLiteral.nop();
3363
- }
3364
- return typescript_exports.TypeLiteral.number(num);
3365
- }
3366
- case "LONG":
3367
- case "UINT_64": {
3368
- const num = this.getValueAsNumber({ value, as });
3369
- if (num == null) {
3370
- return typescript_exports.TypeLiteral.nop();
3371
- }
3372
- if ((_a = this.context.customConfig) == null ? void 0 : _a.useBigInt) {
3373
- return typescript_exports.TypeLiteral.bigint(BigInt(num));
3374
- }
3375
- return typescript_exports.TypeLiteral.number(num);
3376
- }
3377
- case "FLOAT":
3378
- case "DOUBLE": {
3379
- const num = this.getValueAsNumber({ value });
3380
- if (num == null) {
3381
- return typescript_exports.TypeLiteral.nop();
3382
- }
3383
- return typescript_exports.TypeLiteral.number(num);
3384
- }
3385
- case "BOOLEAN": {
3386
- const bool = this.getValueAsBoolean({ value, as });
3387
- if (bool == null) {
3388
- return typescript_exports.TypeLiteral.nop();
3389
- }
3390
- return typescript_exports.TypeLiteral.boolean(bool);
3391
- }
3392
- case "BASE_64":
3393
- case "DATE":
3394
- case "UUID":
3395
- case "STRING": {
3396
- const str = this.context.getValueAsString({ value });
3397
- if (str == null) {
3398
- return typescript_exports.TypeLiteral.nop();
3399
- }
3400
- return typescript_exports.TypeLiteral.string(str);
3401
- }
3402
- case "DATE_TIME": {
3403
- const str = this.context.getValueAsString({ value });
3404
- if (str == null) {
3405
- return typescript_exports.TypeLiteral.nop();
3406
- }
3407
- return typescript_exports.TypeLiteral.datetime(str);
3408
- }
3409
- case "BIG_INTEGER": {
3410
- const bigInt = this.context.getValueAsString({ value });
3411
- if (bigInt == null) {
3412
- return typescript_exports.TypeLiteral.nop();
3413
- }
3414
- if ((_b = this.context.customConfig) == null ? void 0 : _b.useBigInt) {
3415
- return typescript_exports.TypeLiteral.bigint(BigInt(bigInt));
3416
- }
3417
- return typescript_exports.TypeLiteral.string(bigInt);
3418
- }
3419
- default:
3420
- assertNever(primitive);
3421
- }
3422
- }
3423
- getValueAsNumber({
3424
- value,
3425
- as
3426
- }) {
3427
- const num = as === "key" ? typeof value === "string" ? Number(value) : value : value;
3428
- return this.context.getValueAsNumber({ value: num });
3429
- }
3430
- getValueAsBoolean({
3431
- value,
3432
- as
3433
- }) {
3434
- const bool = as === "key" ? typeof value === "string" ? value === "true" : value === "false" ? false : value : value;
3435
- return this.context.getValueAsBoolean({ value: bool });
3436
- }
3437
- };
3438
- // Annotate the CommonJS export names for ESM import in node:
3439
- 0 && (module.exports = {
3440
- DynamicTypeLiteralMapper
3441
- });
1
+ "use strict";var te=Object.defineProperty;var $e=Object.getOwnPropertyDescriptor;var je=Object.getOwnPropertyNames;var Ve=Object.prototype.hasOwnProperty;var We=(n,t,e)=>t in n?te(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e;var le=(n,t)=>()=>(n&&(t=n(n=0)),t);var ye=(n,t)=>{for(var e in t)te(n,e,{get:t[e],enumerable:!0})},Ge=(n,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of je(t))!Ve.call(n,i)&&i!==e&&te(n,i,{get:()=>t[i],enumerable:!(r=$e(t,i))||r.enumerable});return n};var Je=n=>Ge(te({},"__esModule",{value:!0}),n);var f=(n,t,e)=>We(n,typeof t!="symbol"?t+"":t,e);function xe(){throw new Error("setTimeout has not been defined")}function ve(){throw new Error("clearTimeout has not been defined")}function Te(n){if(S===setTimeout)return setTimeout(n,0);if((S===xe||!S)&&setTimeout)return S=setTimeout,setTimeout(n,0);try{return S(n,0)}catch(t){try{return S.call(null,n,0)}catch(e){return S.call(this,n,0)}}}function ze(n){if(_===clearTimeout)return clearTimeout(n);if((_===ve||!_)&&clearTimeout)return _=clearTimeout,clearTimeout(n);try{return _(n)}catch(t){try{return _.call(null,n)}catch(e){return _.call(this,n)}}}function Qe(){!W||!D||(W=!1,D.length?R=D.concat(R):re=-1,R.length&&ge())}function ge(){if(!W){var n=Te(Qe);W=!0;for(var t=R.length;t;){for(D=R,R=[];++re<t;)D&&D[re].run();re=-1,t=R.length}D=null,W=!1,ze(n)}}function He(n){var t=new Array(arguments.length-1);if(arguments.length>1)for(var e=1;e<arguments.length;e++)t[e-1]=arguments[e];R.push(new Ae(n,t)),R.length===1&&!W&&Te(ge)}function Ae(n,t){this.fun=n,this.array=t}function C(){}function ft(n){throw new Error("process.binding is not supported")}function ht(){return"/"}function mt(n){throw new Error("process.chdir is not supported")}function dt(){return 0}function wt(n){var t=yt.call(V)*.001,e=Math.floor(t),r=Math.floor(t%1*1e9);return n&&(e=e-n[0],r=r-n[1],r<0&&(e--,r+=1e9)),[e,r]}function vt(){var n=new Date,t=n-xt;return t/1e3}var S,_,R,W,D,re,Xe,Ze,qe,Ke,et,tt,rt,nt,it,ot,st,at,ut,ct,lt,pt,V,yt,xt,w,we,l=le(()=>{"use strict";S=xe,_=ve;typeof globalThis.setTimeout=="function"&&(S=setTimeout);typeof globalThis.clearTimeout=="function"&&(_=clearTimeout);R=[],W=!1,re=-1;Ae.prototype.run=function(){this.fun.apply(null,this.array)};Xe="browser",Ze="browser",qe=!0,Ke={},et=[],tt="",rt={},nt={},it={};ot=C,st=C,at=C,ut=C,ct=C,lt=C,pt=C;V=globalThis.performance||{},yt=V.now||V.mozNow||V.msNow||V.oNow||V.webkitNow||function(){return new Date().getTime()};xt=new Date;w={nextTick:He,title:Xe,browser:qe,env:Ke,argv:et,version:tt,versions:rt,on:ot,addListener:st,once:at,off:ut,removeListener:ct,removeAllListeners:lt,emit:pt,binding:ft,cwd:ht,chdir:mt,umask:dt,hrtime:wt,platform:Ze,release:nt,config:it,uptime:vt},we={};Object.keys(we).forEach(n=>{let t=n.split("."),e=w;for(let r=0;r<t.length;r++){let i=t[r];r===t.length-1?e[i]=we[n]:e=e[i]||(e[i]={})}})});function Ne(){fe=!0;for(var n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0,e=n.length;t<e;++t)b[t]=n[t],E[n.charCodeAt(t)]=t;E[45]=62,E[95]=63}function gt(n){fe||Ne();var t,e,r,i,o,s,u=n.length;if(u%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o=n[u-2]==="="?2:n[u-1]==="="?1:0,s=new Tt(u*3/4-o),r=o>0?u-4:u;var c=0;for(t=0,e=0;t<r;t+=4,e+=3)i=E[n.charCodeAt(t)]<<18|E[n.charCodeAt(t+1)]<<12|E[n.charCodeAt(t+2)]<<6|E[n.charCodeAt(t+3)],s[c++]=i>>16&255,s[c++]=i>>8&255,s[c++]=i&255;return o===2?(i=E[n.charCodeAt(t)]<<2|E[n.charCodeAt(t+1)]>>4,s[c++]=i&255):o===1&&(i=E[n.charCodeAt(t)]<<10|E[n.charCodeAt(t+1)]<<4|E[n.charCodeAt(t+2)]>>2,s[c++]=i>>8&255,s[c++]=i&255),s}function At(n){return b[n>>18&63]+b[n>>12&63]+b[n>>6&63]+b[n&63]}function Et(n,t,e){for(var r,i=[],o=t;o<e;o+=3)r=(n[o]<<16)+(n[o+1]<<8)+n[o+2],i.push(At(r));return i.join("")}function Ee(n){fe||Ne();for(var t,e=n.length,r=e%3,i="",o=[],s=16383,u=0,c=e-r;u<c;u+=s)o.push(Et(n,u,u+s>c?c:u+s));return r===1?(t=n[e-1],i+=b[t>>2],i+=b[t<<4&63],i+="=="):r===2&&(t=(n[e-2]<<8)+n[e-1],i+=b[t>>10],i+=b[t>>4&63],i+=b[t<<2&63],i+="="),o.push(i),o.join("")}function ne(){return a.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function k(n,t){if(ne()<t)throw new RangeError("Invalid typed array length");return a.TYPED_ARRAY_SUPPORT?(n=new Uint8Array(t),n.__proto__=a.prototype):(n===null&&(n=new a(t)),n.length=t),n}function a(n,t,e){if(!a.TYPED_ARRAY_SUPPORT&&!(this instanceof a))return new a(n,t,e);if(typeof n=="number"){if(typeof t=="string")throw new Error("If encoding is specified then the first argument must be a string");return he(this,n)}return Le(this,n,t,e)}function Le(n,t,e,r){if(typeof t=="number")throw new TypeError('"value" argument must not be a number');return typeof ArrayBuffer!="undefined"&&t instanceof ArrayBuffer?Nt(n,t,e,r):typeof t=="string"?bt(n,t,e):Lt(n,t)}function Re(n){if(typeof n!="number")throw new TypeError('"size" argument must be a number');if(n<0)throw new RangeError('"size" argument must not be negative')}function It(n,t,e,r){return Re(t),t<=0?k(n,t):e!==void 0?typeof r=="string"?k(n,t).fill(e,r):k(n,t).fill(e):k(n,t)}function he(n,t){if(Re(t),n=k(n,t<0?0:me(t)|0),!a.TYPED_ARRAY_SUPPORT)for(var e=0;e<t;++e)n[e]=0;return n}function bt(n,t,e){if((typeof e!="string"||e==="")&&(e="utf8"),!a.isEncoding(e))throw new TypeError('"encoding" must be a valid string encoding');var r=ke(t,e)|0;n=k(n,r);var i=n.write(t,e);return i!==r&&(n=n.slice(0,i)),n}function pe(n,t){var e=t.length<0?0:me(t.length)|0;n=k(n,e);for(var r=0;r<e;r+=1)n[r]=t[r]&255;return n}function Nt(n,t,e,r){if(t.byteLength,e<0||t.byteLength<e)throw new RangeError("'offset' is out of bounds");if(t.byteLength<e+(r||0))throw new RangeError("'length' is out of bounds");return e===void 0&&r===void 0?t=new Uint8Array(t):r===void 0?t=new Uint8Array(t,e):t=new Uint8Array(t,e,r),a.TYPED_ARRAY_SUPPORT?(n=t,n.__proto__=a.prototype):n=pe(n,t),n}function Lt(n,t){if(N(t)){var e=me(t.length)|0;return n=k(n,e),n.length===0||t.copy(n,0,0,e),n}if(t){if(typeof ArrayBuffer!="undefined"&&t.buffer instanceof ArrayBuffer||"length"in t)return typeof t.length!="number"||Jt(t.length)?k(n,0):pe(n,t);if(t.type==="Buffer"&&Array.isArray(t.data))return pe(n,t.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}function me(n){if(n>=ne())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+ne().toString(16)+" bytes");return n|0}function N(n){return!!(n!=null&&n._isBuffer)}function ke(n,t){if(N(n))return n.length;if(typeof ArrayBuffer!="undefined"&&typeof ArrayBuffer.isView=="function"&&(ArrayBuffer.isView(n)||n instanceof ArrayBuffer))return n.byteLength;typeof n!="string"&&(n=""+n);var e=n.length;if(e===0)return 0;for(var r=!1;;)switch(t){case"ascii":case"latin1":case"binary":return e;case"utf8":case"utf-8":case void 0:return ie(n).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return e*2;case"hex":return e>>>1;case"base64":return Ce(n).length;default:if(r)return ie(n).length;t=(""+t).toLowerCase(),r=!0}}function Rt(n,t,e){var r=!1;if((t===void 0||t<0)&&(t=0),t>this.length||((e===void 0||e>this.length)&&(e=this.length),e<=0)||(e>>>=0,t>>>=0,e<=t))return"";for(n||(n="utf8");;)switch(n){case"hex":return Mt(this,t,e);case"utf8":case"utf-8":return _e(this,t,e);case"ascii":return Ct(this,t,e);case"latin1":case"binary":return Pt(this,t,e);case"base64":return Ft(this,t,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Ot(this,t,e);default:if(r)throw new TypeError("Unknown encoding: "+n);n=(n+"").toLowerCase(),r=!0}}function P(n,t,e){var r=n[t];n[t]=n[e],n[e]=r}function Ue(n,t,e,r,i){if(n.length===0)return-1;if(typeof e=="string"?(r=e,e=0):e>2147483647?e=2147483647:e<-2147483648&&(e=-2147483648),e=+e,isNaN(e)&&(e=i?0:n.length-1),e<0&&(e=n.length+e),e>=n.length){if(i)return-1;e=n.length-1}else if(e<0)if(i)e=0;else return-1;if(typeof t=="string"&&(t=a.from(t,r)),N(t))return t.length===0?-1:Ie(n,t,e,r,i);if(typeof t=="number")return t=t&255,a.TYPED_ARRAY_SUPPORT&&typeof Uint8Array.prototype.indexOf=="function"?i?Uint8Array.prototype.indexOf.call(n,t,e):Uint8Array.prototype.lastIndexOf.call(n,t,e):Ie(n,[t],e,r,i);throw new TypeError("val must be string, number or Buffer")}function Ie(n,t,e,r,i){var o=1,s=n.length,u=t.length;if(r!==void 0&&(r=String(r).toLowerCase(),r==="ucs2"||r==="ucs-2"||r==="utf16le"||r==="utf-16le")){if(n.length<2||t.length<2)return-1;o=2,s/=2,u/=2,e/=2}function c(A,j){return o===1?A[j]:A.readUInt16BE(j*o)}var d;if(i){var y=-1;for(d=e;d<s;d++)if(c(n,d)===c(t,y===-1?0:d-y)){if(y===-1&&(y=d),d-y+1===u)return y*o}else y!==-1&&(d-=d-y),y=-1}else for(e+u>s&&(e=s-u),d=e;d>=0;d--){for(var m=!0,v=0;v<u;v++)if(c(n,d+v)!==c(t,v)){m=!1;break}if(m)return d}return-1}function kt(n,t,e,r){e=Number(e)||0;var i=n.length-e;r?(r=Number(r),r>i&&(r=i)):r=i;var o=t.length;if(o%2!==0)throw new TypeError("Invalid hex string");r>o/2&&(r=o/2);for(var s=0;s<r;++s){var u=parseInt(t.substr(s*2,2),16);if(isNaN(u))return s;n[e+s]=u}return s}function Ut(n,t,e,r){return ae(ie(t,n.length-e),n,e,r)}function Se(n,t,e,r){return ae(Wt(t),n,e,r)}function St(n,t,e,r){return Se(n,t,e,r)}function _t(n,t,e,r){return ae(Ce(t),n,e,r)}function Bt(n,t,e,r){return ae(Gt(t,n.length-e),n,e,r)}function Ft(n,t,e){return t===0&&e===n.length?Ee(n):Ee(n.slice(t,e))}function _e(n,t,e){e=Math.min(n.length,e);for(var r=[],i=t;i<e;){var o=n[i],s=null,u=o>239?4:o>223?3:o>191?2:1;if(i+u<=e){var c,d,y,m;switch(u){case 1:o<128&&(s=o);break;case 2:c=n[i+1],(c&192)===128&&(m=(o&31)<<6|c&63,m>127&&(s=m));break;case 3:c=n[i+1],d=n[i+2],(c&192)===128&&(d&192)===128&&(m=(o&15)<<12|(c&63)<<6|d&63,m>2047&&(m<55296||m>57343)&&(s=m));break;case 4:c=n[i+1],d=n[i+2],y=n[i+3],(c&192)===128&&(d&192)===128&&(y&192)===128&&(m=(o&15)<<18|(c&63)<<12|(d&63)<<6|y&63,m>65535&&m<1114112&&(s=m))}}s===null?(s=65533,u=1):s>65535&&(s-=65536,r.push(s>>>10&1023|55296),s=56320|s&1023),r.push(s),i+=u}return Dt(r)}function Dt(n){var t=n.length;if(t<=be)return String.fromCharCode.apply(String,n);for(var e="",r=0;r<t;)e+=String.fromCharCode.apply(String,n.slice(r,r+=be));return e}function Ct(n,t,e){var r="";e=Math.min(n.length,e);for(var i=t;i<e;++i)r+=String.fromCharCode(n[i]&127);return r}function Pt(n,t,e){var r="";e=Math.min(n.length,e);for(var i=t;i<e;++i)r+=String.fromCharCode(n[i]);return r}function Mt(n,t,e){var r=n.length;(!t||t<0)&&(t=0),(!e||e<0||e>r)&&(e=r);for(var i="",o=t;o<e;++o)i+=Vt(n[o]);return i}function Ot(n,t,e){for(var r=n.slice(t,e),i="",o=0;o<r.length;o+=2)i+=String.fromCharCode(r[o]+r[o+1]*256);return i}function T(n,t,e){if(n%1!==0||n<0)throw new RangeError("offset is not uint");if(n+t>e)throw new RangeError("Trying to access beyond buffer length")}function g(n,t,e,r,i,o){if(!N(n))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<o)throw new RangeError('"value" argument is out of bounds');if(e+r>n.length)throw new RangeError("Index out of range")}function oe(n,t,e,r){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(n.length-e,2);i<o;++i)n[e+i]=(t&255<<8*(r?i:1-i))>>>(r?i:1-i)*8}function se(n,t,e,r){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(n.length-e,4);i<o;++i)n[e+i]=t>>>(r?i:3-i)*8&255}function Be(n,t,e,r,i,o){if(e+r>n.length)throw new RangeError("Index out of range");if(e<0)throw new RangeError("Index out of range")}function Fe(n,t,e,r,i){return i||Be(n,t,e,4,34028234663852886e22,-34028234663852886e22),Me(n,t,e,r,23,4),e+4}function De(n,t,e,r,i){return i||Be(n,t,e,8,17976931348623157e292,-17976931348623157e292),Me(n,t,e,r,52,8),e+8}function $t(n){if(n=jt(n).replace(Yt,""),n.length<2)return"";for(;n.length%4!==0;)n=n+"=";return n}function jt(n){return n.trim?n.trim():n.replace(/^\s+|\s+$/g,"")}function Vt(n){return n<16?"0"+n.toString(16):n.toString(16)}function ie(n,t){t=t||1/0;for(var e,r=n.length,i=null,o=[],s=0;s<r;++s){if(e=n.charCodeAt(s),e>55295&&e<57344){if(!i){if(e>56319){(t-=3)>-1&&o.push(239,191,189);continue}else if(s+1===r){(t-=3)>-1&&o.push(239,191,189);continue}i=e;continue}if(e<56320){(t-=3)>-1&&o.push(239,191,189),i=e;continue}e=(i-55296<<10|e-56320)+65536}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,e<128){if((t-=1)<0)break;o.push(e)}else if(e<2048){if((t-=2)<0)break;o.push(e>>6|192,e&63|128)}else if(e<65536){if((t-=3)<0)break;o.push(e>>12|224,e>>6&63|128,e&63|128)}else if(e<1114112){if((t-=4)<0)break;o.push(e>>18|240,e>>12&63|128,e>>6&63|128,e&63|128)}else throw new Error("Invalid code point")}return o}function Wt(n){for(var t=[],e=0;e<n.length;++e)t.push(n.charCodeAt(e)&255);return t}function Gt(n,t){for(var e,r,i,o=[],s=0;s<n.length&&!((t-=2)<0);++s)e=n.charCodeAt(s),r=e>>8,i=e%256,o.push(i),o.push(r);return o}function Ce(n){return gt($t(n))}function ae(n,t,e,r){for(var i=0;i<r&&!(i+e>=t.length||i>=n.length);++i)t[i+e]=n[i];return i}function Jt(n){return n!==n}function zt(n){return n!=null&&(!!n._isBuffer||Pe(n)||Qt(n))}function Pe(n){return!!n.constructor&&typeof n.constructor.isBuffer=="function"&&n.constructor.isBuffer(n)}function Qt(n){return typeof n.readFloatLE=="function"&&typeof n.slice=="function"&&Pe(n.slice(0,0))}function ue(n,t,e,r,i){var o,s,u=i*8-r-1,c=(1<<u)-1,d=c>>1,y=-7,m=e?i-1:0,v=e?-1:1,A=n[t+m];for(m+=v,o=A&(1<<-y)-1,A>>=-y,y+=u;y>0;o=o*256+n[t+m],m+=v,y-=8);for(s=o&(1<<-y)-1,o>>=-y,y+=r;y>0;s=s*256+n[t+m],m+=v,y-=8);if(o===0)o=1-d;else{if(o===c)return s?NaN:(A?-1:1)*(1/0);s=s+Math.pow(2,r),o=o-d}return(A?-1:1)*s*Math.pow(2,o-r)}function Me(n,t,e,r,i,o){var s,u,c,d=o*8-i-1,y=(1<<d)-1,m=y>>1,v=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,A=r?0:o-1,j=r?1:-1,Ye=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(u=isNaN(t)?1:0,s=y):(s=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-s))<1&&(s--,c*=2),s+m>=1?t+=v/c:t+=v*Math.pow(2,1-m),t*c>=2&&(s++,c/=2),s+m>=y?(u=0,s=y):s+m>=1?(u=(t*c-1)*Math.pow(2,i),s=s+m):(u=t*Math.pow(2,m-1)*Math.pow(2,i),s=0));i>=8;n[e+A]=u&255,A+=j,u/=256,i-=8);for(s=s<<i|u,d+=i;d>0;n[e+A]=s&255,A+=j,s/=256,d-=8);n[e+A-j]|=Ye*128}var b,E,Tt,fe,be,Yt,Oe=le(()=>{"use strict";l();p();b=[],E=[],Tt=typeof Uint8Array!="undefined"?Uint8Array:Array,fe=!1;a.TYPED_ARRAY_SUPPORT=globalThis.TYPED_ARRAY_SUPPORT!==void 0?globalThis.TYPED_ARRAY_SUPPORT:!0;a.poolSize=8192;a._augment=function(n){return n.__proto__=a.prototype,n};a.from=function(n,t,e){return Le(null,n,t,e)};a.kMaxLength=ne();a.TYPED_ARRAY_SUPPORT&&(a.prototype.__proto__=Uint8Array.prototype,a.__proto__=Uint8Array,typeof Symbol!="undefined"&&Symbol.species&&a[Symbol.species]);a.alloc=function(n,t,e){return It(null,n,t,e)};a.allocUnsafe=function(n){return he(null,n)};a.allocUnsafeSlow=function(n){return he(null,n)};a.isBuffer=zt;a.compare=function(t,e){if(!N(t)||!N(e))throw new TypeError("Arguments must be Buffers");if(t===e)return 0;for(var r=t.length,i=e.length,o=0,s=Math.min(r,i);o<s;++o)if(t[o]!==e[o]){r=t[o],i=e[o];break}return r<i?-1:i<r?1:0};a.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}};a.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(t.length===0)return a.alloc(0);var r;if(e===void 0)for(e=0,r=0;r<t.length;++r)e+=t[r].length;var i=a.allocUnsafe(e),o=0;for(r=0;r<t.length;++r){var s=t[r];if(!N(s))throw new TypeError('"list" argument must be an Array of Buffers');s.copy(i,o),o+=s.length}return i};a.byteLength=ke;a.prototype._isBuffer=!0;a.prototype.swap16=function(){var t=this.length;if(t%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var e=0;e<t;e+=2)P(this,e,e+1);return this};a.prototype.swap32=function(){var t=this.length;if(t%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var e=0;e<t;e+=4)P(this,e,e+3),P(this,e+1,e+2);return this};a.prototype.swap64=function(){var t=this.length;if(t%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var e=0;e<t;e+=8)P(this,e,e+7),P(this,e+1,e+6),P(this,e+2,e+5),P(this,e+3,e+4);return this};a.prototype.toString=function(){var t=this.length|0;return t===0?"":arguments.length===0?_e(this,0,t):Rt.apply(this,arguments)};a.prototype.equals=function(t){if(!N(t))throw new TypeError("Argument must be a Buffer");return this===t?!0:a.compare(this,t)===0};a.prototype.compare=function(t,e,r,i,o){if(!N(t))throw new TypeError("Argument must be a Buffer");if(e===void 0&&(e=0),r===void 0&&(r=t?t.length:0),i===void 0&&(i=0),o===void 0&&(o=this.length),e<0||r>t.length||i<0||o>this.length)throw new RangeError("out of range index");if(i>=o&&e>=r)return 0;if(i>=o)return-1;if(e>=r)return 1;if(e>>>=0,r>>>=0,i>>>=0,o>>>=0,this===t)return 0;for(var s=o-i,u=r-e,c=Math.min(s,u),d=this.slice(i,o),y=t.slice(e,r),m=0;m<c;++m)if(d[m]!==y[m]){s=d[m],u=y[m];break}return s<u?-1:u<s?1:0};a.prototype.includes=function(t,e,r){return this.indexOf(t,e,r)!==-1};a.prototype.indexOf=function(t,e,r){return Ue(this,t,e,r,!0)};a.prototype.lastIndexOf=function(t,e,r){return Ue(this,t,e,r,!1)};a.prototype.write=function(t,e,r,i){if(e===void 0)i="utf8",r=this.length,e=0;else if(r===void 0&&typeof e=="string")i=e,r=this.length,e=0;else if(isFinite(e))e=e|0,isFinite(r)?(r=r|0,i===void 0&&(i="utf8")):(i=r,r=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var o=this.length-e;if((r===void 0||r>o)&&(r=o),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");for(var s=!1;;)switch(i){case"hex":return kt(this,t,e,r);case"utf8":case"utf-8":return Ut(this,t,e,r);case"ascii":return Se(this,t,e,r);case"latin1":case"binary":return St(this,t,e,r);case"base64":return _t(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Bt(this,t,e,r);default:if(s)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),s=!0}};a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};be=4096;a.prototype.slice=function(t,e){var r=this.length;t=~~t,e=e===void 0?r:~~e,t<0?(t+=r,t<0&&(t=0)):t>r&&(t=r),e<0?(e+=r,e<0&&(e=0)):e>r&&(e=r),e<t&&(e=t);var i;if(a.TYPED_ARRAY_SUPPORT)i=this.subarray(t,e),i.__proto__=a.prototype;else{var o=e-t;i=new a(o,void 0);for(var s=0;s<o;++s)i[s]=this[s+t]}return i};a.prototype.readUIntLE=function(t,e,r){t=t|0,e=e|0,r||T(t,e,this.length);for(var i=this[t],o=1,s=0;++s<e&&(o*=256);)i+=this[t+s]*o;return i};a.prototype.readUIntBE=function(t,e,r){t=t|0,e=e|0,r||T(t,e,this.length);for(var i=this[t+--e],o=1;e>0&&(o*=256);)i+=this[t+--e]*o;return i};a.prototype.readUInt8=function(t,e){return e||T(t,1,this.length),this[t]};a.prototype.readUInt16LE=function(t,e){return e||T(t,2,this.length),this[t]|this[t+1]<<8};a.prototype.readUInt16BE=function(t,e){return e||T(t,2,this.length),this[t]<<8|this[t+1]};a.prototype.readUInt32LE=function(t,e){return e||T(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+this[t+3]*16777216};a.prototype.readUInt32BE=function(t,e){return e||T(t,4,this.length),this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])};a.prototype.readIntLE=function(t,e,r){t=t|0,e=e|0,r||T(t,e,this.length);for(var i=this[t],o=1,s=0;++s<e&&(o*=256);)i+=this[t+s]*o;return o*=128,i>=o&&(i-=Math.pow(2,8*e)),i};a.prototype.readIntBE=function(t,e,r){t=t|0,e=e|0,r||T(t,e,this.length);for(var i=e,o=1,s=this[t+--i];i>0&&(o*=256);)s+=this[t+--i]*o;return o*=128,s>=o&&(s-=Math.pow(2,8*e)),s};a.prototype.readInt8=function(t,e){return e||T(t,1,this.length),this[t]&128?(255-this[t]+1)*-1:this[t]};a.prototype.readInt16LE=function(t,e){e||T(t,2,this.length);var r=this[t]|this[t+1]<<8;return r&32768?r|4294901760:r};a.prototype.readInt16BE=function(t,e){e||T(t,2,this.length);var r=this[t+1]|this[t]<<8;return r&32768?r|4294901760:r};a.prototype.readInt32LE=function(t,e){return e||T(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24};a.prototype.readInt32BE=function(t,e){return e||T(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]};a.prototype.readFloatLE=function(t,e){return e||T(t,4,this.length),ue(this,t,!0,23,4)};a.prototype.readFloatBE=function(t,e){return e||T(t,4,this.length),ue(this,t,!1,23,4)};a.prototype.readDoubleLE=function(t,e){return e||T(t,8,this.length),ue(this,t,!0,52,8)};a.prototype.readDoubleBE=function(t,e){return e||T(t,8,this.length),ue(this,t,!1,52,8)};a.prototype.writeUIntLE=function(t,e,r,i){if(t=+t,e=e|0,r=r|0,!i){var o=Math.pow(2,8*r)-1;g(this,t,e,r,o,0)}var s=1,u=0;for(this[e]=t&255;++u<r&&(s*=256);)this[e+u]=t/s&255;return e+r};a.prototype.writeUIntBE=function(t,e,r,i){if(t=+t,e=e|0,r=r|0,!i){var o=Math.pow(2,8*r)-1;g(this,t,e,r,o,0)}var s=r-1,u=1;for(this[e+s]=t&255;--s>=0&&(u*=256);)this[e+s]=t/u&255;return e+r};a.prototype.writeUInt8=function(t,e,r){return t=+t,e=e|0,r||g(this,t,e,1,255,0),a.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=t&255,e+1};a.prototype.writeUInt16LE=function(t,e,r){return t=+t,e=e|0,r||g(this,t,e,2,65535,0),a.TYPED_ARRAY_SUPPORT?(this[e]=t&255,this[e+1]=t>>>8):oe(this,t,e,!0),e+2};a.prototype.writeUInt16BE=function(t,e,r){return t=+t,e=e|0,r||g(this,t,e,2,65535,0),a.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=t&255):oe(this,t,e,!1),e+2};a.prototype.writeUInt32LE=function(t,e,r){return t=+t,e=e|0,r||g(this,t,e,4,4294967295,0),a.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=t&255):se(this,t,e,!0),e+4};a.prototype.writeUInt32BE=function(t,e,r){return t=+t,e=e|0,r||g(this,t,e,4,4294967295,0),a.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=t&255):se(this,t,e,!1),e+4};a.prototype.writeIntLE=function(t,e,r,i){if(t=+t,e=e|0,!i){var o=Math.pow(2,8*r-1);g(this,t,e,r,o-1,-o)}var s=0,u=1,c=0;for(this[e]=t&255;++s<r&&(u*=256);)t<0&&c===0&&this[e+s-1]!==0&&(c=1),this[e+s]=(t/u>>0)-c&255;return e+r};a.prototype.writeIntBE=function(t,e,r,i){if(t=+t,e=e|0,!i){var o=Math.pow(2,8*r-1);g(this,t,e,r,o-1,-o)}var s=r-1,u=1,c=0;for(this[e+s]=t&255;--s>=0&&(u*=256);)t<0&&c===0&&this[e+s+1]!==0&&(c=1),this[e+s]=(t/u>>0)-c&255;return e+r};a.prototype.writeInt8=function(t,e,r){return t=+t,e=e|0,r||g(this,t,e,1,127,-128),a.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[e]=t&255,e+1};a.prototype.writeInt16LE=function(t,e,r){return t=+t,e=e|0,r||g(this,t,e,2,32767,-32768),a.TYPED_ARRAY_SUPPORT?(this[e]=t&255,this[e+1]=t>>>8):oe(this,t,e,!0),e+2};a.prototype.writeInt16BE=function(t,e,r){return t=+t,e=e|0,r||g(this,t,e,2,32767,-32768),a.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=t&255):oe(this,t,e,!1),e+2};a.prototype.writeInt32LE=function(t,e,r){return t=+t,e=e|0,r||g(this,t,e,4,2147483647,-2147483648),a.TYPED_ARRAY_SUPPORT?(this[e]=t&255,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):se(this,t,e,!0),e+4};a.prototype.writeInt32BE=function(t,e,r){return t=+t,e=e|0,r||g(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),a.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=t&255):se(this,t,e,!1),e+4};a.prototype.writeFloatLE=function(t,e,r){return Fe(this,t,e,!0,r)};a.prototype.writeFloatBE=function(t,e,r){return Fe(this,t,e,!1,r)};a.prototype.writeDoubleLE=function(t,e,r){return De(this,t,e,!0,r)};a.prototype.writeDoubleBE=function(t,e,r){return De(this,t,e,!1,r)};a.prototype.copy=function(t,e,r,i){if(r||(r=0),!i&&i!==0&&(i=this.length),e>=t.length&&(e=t.length),e||(e=0),i>0&&i<r&&(i=r),i===r||t.length===0||this.length===0)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("sourceStart out of bounds");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),t.length-e<i-r&&(i=t.length-e+r);var o=i-r,s;if(this===t&&r<e&&e<i)for(s=o-1;s>=0;--s)t[s+e]=this[s+r];else if(o<1e3||!a.TYPED_ARRAY_SUPPORT)for(s=0;s<o;++s)t[s+e]=this[s+r];else Uint8Array.prototype.set.call(t,this.subarray(r,r+o),e);return o};a.prototype.fill=function(t,e,r,i){if(typeof t=="string"){if(typeof e=="string"?(i=e,e=0,r=this.length):typeof r=="string"&&(i=r,r=this.length),t.length===1){var o=t.charCodeAt(0);o<256&&(t=o)}if(i!==void 0&&typeof i!="string")throw new TypeError("encoding must be a string");if(typeof i=="string"&&!a.isEncoding(i))throw new TypeError("Unknown encoding: "+i)}else typeof t=="number"&&(t=t&255);if(e<0||this.length<e||this.length<r)throw new RangeError("Out of range index");if(r<=e)return this;e=e>>>0,r=r===void 0?this.length:r>>>0,t||(t=0);var s;if(typeof t=="number")for(s=e;s<r;++s)this[s]=t;else{var u=N(t)?t:ie(new a(t,i).toString()),c=u.length;for(s=0;s<r-e;++s)this[s+e]=u[s%c]}return this};Yt=/[^+\/0-9A-Za-z-_]/g});var p=le(()=>{"use strict";Oe()});var cr={};ye(cr,{DynamicTypeLiteralMapper:()=>de});module.exports=Je(cr);l();p();l();p();l();p();function I(n){throw new Error("Unexpected value: "+JSON.stringify(n))}l();p();l();p();var M=class{};l();p();l();p();var B=class extends M{constructor(e){super();f(this,"value");this.value=e}write(e){typeof this.value=="string"?e.write(this.value):this.value(e)}};var Ht=4,q=class{constructor(){f(this,"buffer","");f(this,"indentLevel",0);f(this,"hasWrittenAnything",!1);f(this,"lastCharacterIsNewline",!1)}write(t){let e=t.length>0&&t.endsWith(`
2
+ `),r=e?t.substring(0,t.length-1):t,i=this.getIndentString(),o=r.replaceAll(`
3
+ `,`
4
+ ${i}`);this.isAtStartOfLine()&&(o=i+o),e&&(o+=`
5
+ `),this.writeInternal(o)}writeNoIndent(t){let e=this.indentLevel;this.indentLevel=0,this.write(t),this.indentLevel=e}writeNode(t){t.write(this)}writeNodeStatement(t){t.write(this),this.write(";"),this.writeNewLineIfLastLineNot()}writeTextStatement(t){new B(t).write(this),this.write(";"),this.writeNewLineIfLastLineNot()}controlFlow(t,e){new B(t).write(this),this.write(" ("),this.writeNode(e),this.write(") {"),this.writeNewLineIfLastLineNot(),this.indent()}endControlFlow(){this.dedent(),this.writeLine("}")}openBlock(t,e="{",r,i="}"){let o=t.filter(s=>s!==void 0).join(" ");o?this.write(`${o} ${e!=null?e:""}`):this.write(e!=null?e:"");try{this.indent(),r(),this.dedent()}finally{this.write(i!=null?i:"")}}writeLine(t=""){this.write(t),this.writeNewLineIfLastLineNot()}newLine(){this.writeInternal(`
6
+ `)}writeNewLineIfLastLineNot(){this.lastCharacterIsNewline||this.writeInternal(`
7
+ `)}indent(){this.indentLevel++}dedent(){this.indentLevel--}delimit({nodes:t,delimiter:e,writeFunction:r}){if(t.length>0){let i=t[0];i!=null&&r(i);for(let o=1;o<t.length;o++){this.write(e);let s=t[o];s!=null&&r(s)}}}toString(){return this.buffer}writeInternal(t){return t.length>0&&(this.hasWrittenAnything=!0,this.lastCharacterIsNewline=t.endsWith(`
8
+ `)),this.buffer+=t}isAtStartOfLine(){return this.lastCharacterIsNewline||!this.hasWrittenAnything}getIndentString(){return" ".repeat(this.indentLevel*Ht)}};l();p();var ce=class{},K=class extends ce{async format(t){return t}formatSync(t){return t}};l();p();l();p();var L={Critical:"CRITICAL",Warning:"WARNING"};l();p();var h={};ye(h,{AstNode:()=>x,ClassInstantiation:()=>Z,CodeBlock:()=>G,Comment:()=>F,Function:()=>Q,FunctionInvocation:()=>H,MethodInvocation:()=>X,Parameter:()=>z,Reference:()=>$,Type:()=>Y,TypeLiteral:()=>U,Types:()=>Y,Variable:()=>J,Writer:()=>O,codeblock:()=>er,function_:()=>tr,instantiateClass:()=>rr,invokeFunction:()=>nr,invokeMethod:()=>ir,parameter:()=>or,reference:()=>sr,variable:()=>ar});l();p();l();p();l();p();l();p();l();p();l();p();var O=class extends q{constructor({customConfig:e,formatter:r}){super();f(this,"customConfig");f(this,"formatter");f(this,"imports",{});f(this,"defaultImports",{});f(this,"starImportAliases",{});f(this,"starImportAliasesInverse",{});this.customConfig=e,this.formatter=r!=null?r:new K}addImport(e){var r,i,o;if(e.importFrom!=null){switch(e.importFrom.type){case"default":{this.validateDefault(e);break}case"named":{this.validateNamed(e);break}case"star":{this.validateStar(e);break}}let s=(o=(r=this.imports)[i=e.importFrom.moduleName])!=null?o:r[i]=[];s.map(c=>c.name).includes(e.name)||s.push(e)}}validateDefault(e){var i,o,s,u;if(((i=e.importFrom)==null?void 0:i.type)!=="default")return;let r=(u=(o=this.defaultImports)[s=e.importFrom.moduleName])!=null?u:o[s]=e;if(r.name!==e.name)throw new Error(`Cannot have multiple default imports for module ${e.importFrom.moduleName}: got ${e.name} but already had ${r.name}`)}validateNamed(e){var s,u,c,d,y;if(((s=e.importFrom)==null?void 0:s.type)!=="named")return;let i=((u=this.imports[e.importFrom.moduleName])!=null?u:[]).filter(m=>{var v;return((v=m.importFrom)==null?void 0:v.type)==="star"});if(i.length>0)throw new Error(`Cannot add named import ${e.name} because non-named imports ${i.map(m=>m.name)} already exist`);let o=[];for(let m of Object.values(this.imports))for(let v of m)((c=v.importFrom)==null?void 0:c.type)==="named"&&v.importFrom.moduleName!==e.importFrom.moduleName&&v.name===e.name&&o.push(v);if(o.length>0)throw new Error(`Cannot add named import from module ${e.importFrom.moduleName} because it is already imported from ${(y=(d=o[0])==null?void 0:d.importFrom)==null?void 0:y.moduleName}`)}validateStar(e){var o,s,u,c,d,y,m;if(((o=e.importFrom)==null?void 0:o.type)!=="star")return;let r=(c=(s=this.starImportAliases)[u=e.importFrom.moduleName])!=null?c:s[u]=e.importFrom.starImportAlias;if(r!==e.importFrom.starImportAlias)throw new Error(`Cannot have more than one alias for non-named imports from a module: got ${e.importFrom.starImportAlias} but already have ${r}.`);if(((m=(d=this.starImportAliasesInverse)[y=e.importFrom.starImportAlias])!=null?m:d[y]=e.importFrom.moduleName)!==e.importFrom.moduleName)throw new Error(`Attempted to use alias ${e.importFrom.starImportAlias} for more than one module in the same file`)}};var ee=class extends O{constructor({customConfig:t,formatter:e}){super({customConfig:t,formatter:e})}async toStringAsync(){let t=this.getContent();if(this.formatter!=null)try{return this.formatter.format(t)}catch(e){throw new Error(`Failed to format TypeScript file: ${e}
9
+ ${t}`)}return t}toString(){let t=this.getContent();if(this.formatter!=null)try{return this.formatter.formatSync(t)}catch(e){throw new Error(`Failed to format TypeScript file: ${e}
10
+ ${t}`)}return t}getContent(){let t=this.stringifyImports();return t.length>0?t+`
11
+ `+this.buffer:this.buffer}stringifyImports(){let t="";for(let[e,r]of Object.entries(this.imports)){let i=this.defaultImports[e],o="",s=r.filter(c=>{var d;return((d=c.importFrom)==null?void 0:d.type)==="named"}),u=this.starImportAliases[e];if(s.length>0||i!=null||u!=null){if(t+="import",i!=null&&(t+=` ${i.name}`),s.length>0){for(let d of s.slice(0,-1))o+=`${d.name}, `;let c=s[s.length-1];c!=null&&(o+=`${c.name}`),i!=null&&(t+=","),t+=` { ${o} }`}u!=null&&((i!=null||s.length>0)&&(t+=", "),t+=` * as ${u}`),t+=` from "${e}";
12
+ `}}return t}};var x=class extends M{async toStringAsync({customConfig:t,formatter:e}){let r=new ee({customConfig:t,formatter:e});return this.write(r),await r.toStringAsync()}toString({customConfig:t,formatter:e}){let r=new ee({customConfig:t,formatter:e});return this.write(r),r.toString()}};l();p();var G=class extends x{constructor(e){super();f(this,"args");this.args=e}write(e){return new B(this.args).write(e)}};l();p();var Y=class extends x{constructor(e){super();f(this,"internalType");this.internalType=e}write(e){switch(this.internalType.type){case"string":e.write("string");break;case"number":e.write("number");break;case"bigint":e.write("bigint");break;case"boolean":e.write("boolean");break;case"array":this.internalType.valueType.write(e),e.write("[]");break;case"map":e.write("Record<"),this.internalType.keyType.write(e),e.write(", "),this.internalType.valueType.write(e),e.write(">");break;case"object":e.write("{"),e.indent();for(let[r,i]of Object.entries(this.internalType.fields))e.write(`${r}: `),i.write(e),e.writeLine(",");e.dedent(),e.write("}");break;case"enum":e.write("enum");break;case"any":e.write("any");break;case"promise":e.write("Promise<"),this.internalType.value.write(e),e.write(">");break;case"unknown":e.write("unknown");break;case"void":e.write("void");break;case"undefined":e.write("undefined");break;case"null":e.write("null");break;case"never":e.write("never");break;case"nop":break;default:I(this.internalType)}}static string(){return new this({type:"string"})}static number(){return new this({type:"number"})}static bigint(){return new this({type:"bigint"})}static boolean(){return new this({type:"boolean"})}static array(e){return new this({type:"array",valueType:e})}static object(e){return new this({type:"object",fields:e})}static enum(e){return new this({type:"enum",values:e})}static any(){return new this({type:"any"})}static promise(e){return e.internalType.type==="promise"?e:new this({type:"promise",value:e})}static unknown(){return new this({type:"unknown"})}static void(){return new this({type:"void"})}static undefined(){return new this({type:"undefined"})}static null(){return new this({type:"null"})}static never(){return new this({type:"never"})}static nop(){return new this({type:"nop"})}};l();p();var U=class n extends x{constructor(e){super();f(this,"internalType");this.internalType=e}write(e){var o,s;let r=!!((o=e.customConfig)!=null&&o.noSerdeLayer),i=!!((s=e.customConfig)!=null&&s.useBigInt);switch(this.internalType.type){case"array":{this.writeIterable({writer:e,iterable:this.internalType});break}case"blob":{if(r){e.writeNode(n.string(this.internalType.value));return}e.write("new Blob(["),e.writeNode(n.string(this.internalType.value)),e.write("])");break}case"boolean":{e.write(this.internalType.value.toString());break}case"bigint":{if(i){e.write(`BigInt(${this.internalType.value.toString()})`);return}e.write(`"${this.internalType.value.toString()}"`);return}case"datetime":{if(r){e.writeNode(n.string(this.internalType.value));return}e.write("new Date("),e.writeNode(n.string(this.internalType.value)),e.write(")");break}case"number":{e.write(this.internalType.value.toString());break}case"object":{this.writeObject({writer:e,object:this.internalType});break}case"record":{this.writeRecord({writer:e,record:this.internalType});break}case"reference":{e.writeNode(this.internalType.value);break}case"set":{if(r||this.isSetOfObjects()){e.writeNode(n.array({values:this.internalType.values}));return}e.write("new Set("),this.writeIterable({writer:e,iterable:this.internalType}),e.write(")");break}case"string":{this.internalType.value.includes(`
13
+ `)?this.writeStringWithBackticks({writer:e,value:this.internalType.value}):e.write(`"${this.internalType.value.replaceAll('"','\\"')}"`);break}case"tuple":{this.writeIterable({writer:e,iterable:this.internalType});break}case"unknown":{this.writeUnknown({writer:e,value:this.internalType.value});break}case"null":{e.write("null");break}case"nop":break;default:I(this.internalType)}}isObject(){return this.internalType.type==="object"}asObjectOrThrow(){if(this.isObject())return this.internalType;throw new Error("Internal error; ts.TypeLiteral is not an object")}isSet(){return this.internalType.type==="set"}asSetOrThrow(){if(this.isSet())return this.internalType;throw new Error("Internal error; ts.TypeLiteral is not a set")}isSetOfObjects(){return this.isSet()&&this.asSetOrThrow().values.every(e=>e.isObject())}writeStringWithBackticks({writer:e,value:r}){e.write("`");let i=r.split(`
14
+ `),o=i[0]+`
15
+ `,s=i.slice(1).join(`
16
+ `);e.write(o.replaceAll("`","\\`")),e.writeNoIndent(s.replaceAll("`","\\`")),e.write("`")}writeIterable({writer:e,iterable:r}){let i=qt({values:r.values});if(i.length===0){e.write("[]");return}e.writeLine("["),e.indent();for(let o of i)o.write(e),e.writeLine(",");e.dedent(),e.write("]")}writeRecord({writer:e,record:r}){let i=Zt({entries:r.entries});if(i.length===0){e.write("{}");return}e.writeLine("{"),e.indent();for(let o of i)o.key.write(e),e.write(": "),o.value.write(e),e.writeLine(",");e.dedent(),e.write("}")}writeObject({writer:e,object:r}){let i=Xt({fields:r.fields});if(i.length===0){e.write("{}");return}e.writeLine("{"),e.indent();for(let o of i)e.write(`${o.name}: `),o.value.write(e),e.writeLine(",");e.dedent(),e.write("}")}static array({values:e}){return new this({type:"array",values:e})}static bigint(e){return new this({type:"bigint",value:e})}static blob(e){return new this({type:"blob",value:e})}static boolean(e){return new this({type:"boolean",value:e})}static datetime(e){return new this({type:"datetime",value:e})}static number(e){return new this({type:"number",value:e})}static object({fields:e}){return new this({type:"object",fields:e})}static record({entries:e}){return new this({type:"record",entries:e})}static reference(e){return new this({type:"reference",value:e})}static set({values:e}){return new this({type:"set",values:e})}static string(e){return new this({type:"string",value:e})}static tuple({values:e}){return new this({type:"tuple",values:e})}static unknown(e){return new this({type:"unknown",value:e})}static null(){return new this({type:"null"})}static nop(){return new this({type:"nop"})}static isNop(e){return e.internalType.type==="nop"}writeUnknown({writer:e,value:r}){switch(typeof r){case"boolean":e.write(r.toString());return;case"string":e.write(r.includes('"')?`\`${r}\``:`"${r}"`);return;case"number":e.write(r.toString());return;case"object":if(r==null){e.write("null");return}if(Array.isArray(r)){this.writeUnknownArray({writer:e,value:r});return}this.writeUnknownObject({writer:e,value:r});return;default:throw new Error(`Internal error; unsupported unknown type: ${typeof r}`)}}writeUnknownArray({writer:e,value:r}){if(r.length===0){e.write("[]");return}e.writeLine("["),e.indent();for(let i of r)e.writeNode(n.unknown(i)),e.writeLine(",");e.dedent(),e.write("]")}writeUnknownObject({writer:e,value:r}){let i=Object.entries(r);if(i.length===0){e.write("{}");return}e.writeLine("{"),e.indent();for(let[o,s]of i)e.write(`${o}: `),e.writeNode(n.unknown(s)),e.writeLine(",");e.dedent(),e.write("}")}};function Xt({fields:n}){return n.filter(t=>!U.isNop(t.value))}function Zt({entries:n}){return n.filter(t=>!U.isNop(t.key)&&!U.isNop(t.value))}function qt({values:n}){return n.filter(t=>!U.isNop(t))}l();p();var $=class extends x{constructor({name:e,importFrom:r,memberName:i}){super();f(this,"name");f(this,"importFrom");f(this,"memberName");this.name=e,this.importFrom=r,this.memberName=i}write(e){var o;this.importFrom!=null&&e.addImport(this);let r=((o=this.importFrom)==null?void 0:o.type)==="star"?`${this.importFrom.starImportAlias}.`:"",i=this.memberName!=null?`.${this.memberName}`:"";e.write(`${r}${this.name}${i}`)}};l();p();var J=class extends x{constructor(e){super();f(this,"args");this.args=e}write(e){this.args.export&&e.write("export "),this.args.const?e.write("const "):e.write("let "),e.write(`${this.args.name} = `),e.writeNode(this.args.initializer)}};l();p();l();p();var F=class extends x{constructor({docs:e}={docs:void 0}){super();f(this,"docs");this.docs=e}write(e){this.docs!=null&&(e.writeLine("/**"),this.docs.split(`
17
+ `).forEach(r=>{e.writeLine(` * ${r}`)}),e.writeLine("*/"))}};var z=class extends x{constructor({name:e,type:r,docs:i}){super();f(this,"name");f(this,"type");f(this,"docs");this.name=e,this.type=r,this.docs=i}write(e){this.docs!=null&&e.writeNode(new F({docs:this.docs})),e.write(`${this.name}: `),this.type.write(e)}};l();p();var Q=class extends x{constructor({name:e,parameters:r,async:i,body:o,return_:s,docs:u}){super();f(this,"name");f(this,"parameters");f(this,"async");f(this,"body");f(this,"return_");f(this,"docs");this.name=e,this.parameters=r,this.async=i!=null?i:!1,this.body=o,this.return_=s,this.docs=u}write(e){var r;e.writeNode(new F({docs:this.docs})),this.async&&e.write("async "),e.write("function "),e.write(`${this.name}`),this.writeParameters(e),this.return_!=null&&(e.write(": "),e.writeNode(this.async?Y.promise(this.return_):this.return_)),e.writeLine(" {"),e.indent(),(r=this.body)==null||r.write(e),e.dedent(),e.writeNewLineIfLastLineNot(),e.writeLine("}")}writeParameters(e){if(this.parameters.length===0){e.write("()");return}e.indent(),e.writeLine("(");for(let r of this.parameters)e.writeNode(r),e.writeLine(",");e.dedent(),e.write(")")}};l();p();var H=class extends x{constructor({function_:e,arguments_:r}){super();f(this,"function_");f(this,"arguments_");this.function_=e,this.arguments_=r}write(e){e.writeNode(this.function_),e.write("("),e.delimit({nodes:this.arguments_,delimiter:", ",writeFunction:r=>r.write(e)}),e.write(")")}};l();p();var X=class extends x{constructor({on:e,method:r,arguments_:i,async:o}){super();f(this,"on");f(this,"method");f(this,"arguments_");f(this,"async");this.on=e,this.method=r,this.arguments_=i,this.async=o}write(e){this.async&&e.write("await "),this.on.write(e),e.write("."),e.write(this.method),e.write("("),e.delimit({nodes:this.arguments_,delimiter:", ",writeFunction:r=>r.write(e)}),e.write(")")}};l();p();var Z=class extends x{constructor({class_:e,arguments_:r}){super();f(this,"class_");f(this,"arguments_");this.class_=e,this.arguments_=r}write(e){e.write("new "),e.writeNode(this.class_),e.write("("),e.delimit({nodes:this.arguments_,delimiter:", ",writeFunction:r=>r.write(e)}),e.write(")")}};function er(n){return new G(n)}function tr(n){return new Q(n)}function rr(n){return new Z(n)}function nr(n){return new H(n)}function ir(n){return new X(n)}function or(n){return new z(n)}function sr(n){return new $(n)}function ar(n){return new J(n)}var ur="value",de=class{constructor({context:t}){f(this,"context");this.context=t}convert(t){if(t.value===null)return this.context.isNullable(t.typeReference)?h.TypeLiteral.null():(this.context.errors.add({severity:L.Critical,message:"Expected non-null value, but got null"}),h.TypeLiteral.nop());if(t.value===void 0)return h.TypeLiteral.nop();switch(t.typeReference.type){case"list":return this.convertList({list:t.typeReference.value,value:t.value});case"literal":return this.convertLiteral({literalType:t.typeReference.value,value:t.value});case"map":return this.convertMap({map:t.typeReference,value:t.value});case"named":{let e=this.context.resolveNamedType({typeId:t.typeReference.value});return e==null?h.TypeLiteral.nop():this.convertNamed({named:e,value:t.value,as:t.as})}case"optional":return this.convert({typeReference:t.typeReference.value,value:t.value,as:t.as});case"nullable":return this.convert({typeReference:t.typeReference.value,value:t.value,as:t.as});case"primitive":return this.convertPrimitive({primitive:t.typeReference.value,value:t.value,as:t.as});case"set":return this.convertSet({set:t.typeReference.value,value:t.value});case"unknown":return this.convertUnknown({value:t.value});default:I(t.typeReference)}}convertLiteral({literalType:t,value:e}){switch(t.type){case"boolean":{let r=this.context.getValueAsBoolean({value:e});return r==null?h.TypeLiteral.nop():h.TypeLiteral.boolean(r)}case"string":{let r=this.context.getValueAsString({value:e});return r==null?h.TypeLiteral.nop():h.TypeLiteral.string(r)}default:I(t)}}convertList({list:t,value:e}){return Array.isArray(e)?h.TypeLiteral.array({values:e.map((r,i)=>{this.context.errors.scope({index:i});try{return this.convert({typeReference:t,value:r})}finally{this.context.errors.unscope()}})}):(this.context.errors.add({severity:L.Critical,message:`Expected array but got: ${typeof e}`}),h.TypeLiteral.nop())}convertSet({set:t,value:e}){return Array.isArray(e)?h.TypeLiteral.set({values:e.map((r,i)=>{this.context.errors.scope({index:i});try{return this.convert({typeReference:t,value:r})}finally{this.context.errors.unscope()}})}):(this.context.errors.add({severity:L.Critical,message:`Expected array but got: ${typeof e}`}),h.TypeLiteral.nop())}convertMap({map:t,value:e}){return typeof e!="object"||e==null?(this.context.errors.add({severity:L.Critical,message:`Expected object but got: ${e==null?"null":typeof e}`}),h.TypeLiteral.nop()):h.TypeLiteral.record({entries:Object.entries(e).map(([r,i])=>{this.context.errors.scope(r);try{return{key:this.convert({typeReference:t.key,value:r,as:"key"}),value:this.convert({typeReference:t.value,value:i})}}finally{this.context.errors.unscope()}})})}convertNamed({named:t,value:e,as:r}){var i;switch(t.type){case"alias":return(i=this.context.customConfig)!=null&&i.useBrandedStringAliases?h.TypeLiteral.reference(h.codeblock(o=>{o.writeNode(h.reference({name:this.context.namespaceExport,importFrom:this.context.getModuleImport(),memberName:this.context.getFullyQualifiedReference({declaration:t.declaration})})),o.write("("),o.writeNode(this.convert({typeReference:t.typeReference,value:e,as:r})),o.write(")")})):this.convert({typeReference:t.typeReference,value:e,as:r});case"discriminatedUnion":return this.convertDiscriminatedUnion({discriminatedUnion:t,value:e});case"enum":return this.convertEnum({enum_:t,value:e});case"object":return this.convertObject({object_:t,value:e});case"undiscriminatedUnion":return this.convertUndicriminatedUnion({undicriminatedUnion:t,value:e});default:I(t)}}convertDiscriminatedUnion({discriminatedUnion:t,value:e}){var u;let r=this.context.resolveDiscriminatedUnionTypeInstance({discriminatedUnion:t,value:e});if(r==null)return h.TypeLiteral.nop();let i=r.singleDiscriminatedUnionType,o=this.convertDiscriminatedUnionProperties({discriminatedUnionTypeInstance:r,unionVariant:i});if(o==null)return h.TypeLiteral.nop();if((u=this.context.customConfig)!=null&&u.includeUtilsOnUnionMembers)return h.TypeLiteral.reference(h.codeblock(c=>{c.writeNode(h.invokeMethod({on:h.reference({name:this.context.namespaceExport,importFrom:this.context.getModuleImport(),memberName:this.context.getFullyQualifiedReference({declaration:t.declaration})}),method:this.context.getMethodName(i.discriminantValue.name),arguments_:this.convertDiscriminatedUnionUtilsArgs({discriminatedUnionTypeInstance:r,unionVariant:i,unionProperties:o})}))}));let s={name:this.context.getPropertyName(t.discriminant.name),value:h.TypeLiteral.string(i.discriminantValue.wireValue)};return h.TypeLiteral.object({fields:[s,...o]})}convertDiscriminatedUnionProperties({discriminatedUnionTypeInstance:t,unionVariant:e}){let r=this.getBaseFields({discriminatedUnionTypeInstance:t,singleDiscriminatedUnionType:e});switch(e.type){case"samePropertiesAsObject":{let i=this.context.resolveNamedType({typeId:e.typeId});if(i==null)return;let o=this.convertNamed({named:i,value:t.value});if(!o.isObject()){this.context.errors.add({severity:L.Critical,message:"Internal error; expected union value to be an object"});return}let s=o.asObjectOrThrow();return[...r,...s.fields]}case"singleProperty":try{this.context.errors.scope(e.discriminantValue.wireValue);let i=this.context.getRecord(t.value);return i==null?[...r,{name:ur,value:this.convert({typeReference:e.typeReference,value:t.value})}]:[...r,{name:this.context.getPropertyName(e.discriminantValue.name),value:this.convert({typeReference:e.typeReference,value:i[e.discriminantValue.wireValue]})}]}finally{this.context.errors.unscope()}case"noProperties":return r;default:I(e)}}convertDiscriminatedUnionUtilsArgs({discriminatedUnionTypeInstance:t,unionVariant:e,unionProperties:r}){return e.type==="singleProperty"&&this.context.getRecord(t.value)==null&&r.length===1?[this.convert({typeReference:e.typeReference,value:t.value})]:r.length>0?[h.TypeLiteral.object({fields:r})]:[]}getBaseFields({discriminatedUnionTypeInstance:t,singleDiscriminatedUnionType:e}){var i,o;return this.context.associateByWireValue({parameters:(i=e.properties)!=null?i:[],values:(o=this.context.getRecord(t.value))!=null?o:{},ignoreMissingParameters:!0}).map(s=>{this.context.errors.scope(s.name.wireValue);try{return{name:this.context.getPropertyName(s.name.name),value:this.convert(s)}}finally{this.context.errors.unscope()}})}convertObject({object_:t,value:e}){var i;let r=this.context.associateByWireValue({parameters:t.properties,values:(i=this.context.getRecord(e))!=null?i:{}});return h.TypeLiteral.object({fields:r.map(o=>{this.context.errors.scope(o.name.wireValue);try{return{name:this.context.getPropertyName(o.name.name),value:this.convert(o)}}finally{this.context.errors.unscope()}})})}convertEnum({enum_:t,value:e}){let r=this.getEnumValue({enum_:t,value:e});return r==null?h.TypeLiteral.nop():h.TypeLiteral.string(r)}getEnumValue({enum_:t,value:e}){if(typeof e!="string"){this.context.errors.add({severity:L.Critical,message:`Expected enum value string, got: ${typeof e}`});return}if(t.values.find(i=>i.wireValue===e)==null){this.context.errors.add({severity:L.Critical,message:`An enum value named "${e}" does not exist in this context`});return}return e}convertUndicriminatedUnion({undicriminatedUnion:t,value:e}){let r=this.findMatchingUndiscriminatedUnionType({undicriminatedUnion:t,value:e});return r==null?h.TypeLiteral.nop():r}findMatchingUndiscriminatedUnionType({undicriminatedUnion:t,value:e}){for(let r of t.types)try{return this.convert({typeReference:r,value:e})}catch(i){continue}this.context.errors.add({severity:L.Critical,message:`None of the types in the undicriminated union matched the given "${typeof e}" value`})}convertUnknown({value:t}){return h.TypeLiteral.unknown(t)}convertPrimitive({primitive:t,value:e,as:r}){var i,o;switch(t){case"INTEGER":case"UINT":{let s=this.getValueAsNumber({value:e,as:r});return s==null?h.TypeLiteral.nop():h.TypeLiteral.number(s)}case"LONG":case"UINT_64":{let s=this.getValueAsNumber({value:e,as:r});return s==null?h.TypeLiteral.nop():(i=this.context.customConfig)!=null&&i.useBigInt?h.TypeLiteral.bigint(BigInt(s)):h.TypeLiteral.number(s)}case"FLOAT":case"DOUBLE":{let s=this.getValueAsNumber({value:e});return s==null?h.TypeLiteral.nop():h.TypeLiteral.number(s)}case"BOOLEAN":{let s=this.getValueAsBoolean({value:e,as:r});return s==null?h.TypeLiteral.nop():h.TypeLiteral.boolean(s)}case"BASE_64":case"DATE":case"UUID":case"STRING":{let s=this.context.getValueAsString({value:e});return s==null?h.TypeLiteral.nop():h.TypeLiteral.string(s)}case"DATE_TIME":{let s=this.context.getValueAsString({value:e});return s==null?h.TypeLiteral.nop():h.TypeLiteral.datetime(s)}case"BIG_INTEGER":{let s=this.context.getValueAsString({value:e});return s==null?h.TypeLiteral.nop():(o=this.context.customConfig)!=null&&o.useBigInt?h.TypeLiteral.bigint(BigInt(s)):h.TypeLiteral.string(s)}default:I(t)}}getValueAsNumber({value:t,as:e}){let r=e==="key"&&typeof t=="string"?Number(t):t;return this.context.getValueAsNumber({value:r})}getValueAsBoolean({value:t,as:e}){let r=e==="key"?typeof t=="string"?t==="true":t==="false"?!1:t:t;return this.context.getValueAsBoolean({value:r})}};0&&(module.exports={DynamicTypeLiteralMapper});
3442
18
  /*! Bundled license information:
3443
19
 
3444
20
  @esbuild-plugins/node-globals-polyfill/Buffer.js: