@fern-api/typescript-dynamic-snippets 0.0.6 → 0.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/cjs/DynamicSnippetsGenerator.cjs +17 -5508
  2. package/cjs/DynamicSnippetsGenerator.d.cts +4 -2
  3. package/cjs/{DynamicSnippetsGeneratorContext-DFkk3dho.d.cts → DynamicSnippetsGeneratorContext-CmDa2k9n.d.cts} +1 -1
  4. package/cjs/EndpointSnippetGenerator.cjs +17 -3539
  5. package/cjs/EndpointSnippetGenerator.d.cts +1 -1
  6. package/cjs/context/DynamicSnippetsGeneratorContext.cjs +17 -4863
  7. package/cjs/context/DynamicSnippetsGeneratorContext.d.cts +1 -1
  8. package/cjs/context/DynamicTypeLiteralMapper.cjs +17 -3493
  9. package/cjs/context/DynamicTypeLiteralMapper.d.cts +1 -1
  10. package/cjs/context/FilePropertyMapper.cjs +17 -3073
  11. package/cjs/context/FilePropertyMapper.d.cts +1 -1
  12. package/cjs/index.cjs +29 -8811
  13. package/cjs/index.d.cts +2 -1
  14. package/esm/DynamicSnippetsGenerator.d.ts +4 -2
  15. package/esm/DynamicSnippetsGenerator.js +1 -12
  16. package/esm/{DynamicSnippetsGeneratorContext-DFkk3dho.d.ts → DynamicSnippetsGeneratorContext-CmDa2k9n.d.ts} +1 -1
  17. package/esm/EndpointSnippetGenerator.d.ts +1 -1
  18. package/esm/EndpointSnippetGenerator.js +1 -8
  19. package/esm/chunk-3SA25SVX.js +1 -0
  20. package/esm/chunk-D7ZDXIQ6.js +1 -0
  21. package/esm/chunk-DJQMPRPJ.js +1 -0
  22. package/esm/chunk-JGNWFXNM.js +1 -0
  23. package/esm/chunk-RL2XA35J.js +27 -0
  24. package/esm/chunk-T2HPPEKP.js +14 -0
  25. package/esm/chunk-XC2QAVJY.js +1 -0
  26. package/esm/context/DynamicSnippetsGeneratorContext.d.ts +1 -1
  27. package/esm/context/DynamicSnippetsGeneratorContext.js +1 -10
  28. package/esm/context/DynamicTypeLiteralMapper.d.ts +1 -1
  29. package/esm/context/DynamicTypeLiteralMapper.js +1 -8
  30. package/esm/context/FilePropertyMapper.d.ts +1 -1
  31. package/esm/context/FilePropertyMapper.js +1 -7
  32. package/esm/index.d.ts +2 -1
  33. package/esm/index.js +13 -3311
  34. package/package.json +2 -2
  35. package/esm/chunk-37WY6L3Q.js +0 -551
  36. package/esm/chunk-6Y2IOBCK.js +0 -501
  37. package/esm/chunk-KUITDN45.js +0 -538
  38. package/esm/chunk-MR7ZAFRL.js +0 -819
  39. package/esm/chunk-PLZLTFT4.js +0 -90
  40. package/esm/chunk-TKT54OF7.js +0 -86
  41. package/esm/chunk-WPDO6IRW.js +0 -3060
@@ -1,3542 +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/EndpointSnippetGenerator.ts
1790
- var EndpointSnippetGenerator_exports = {};
1791
- __export(EndpointSnippetGenerator_exports, {
1792
- EndpointSnippetGenerator: () => EndpointSnippetGenerator
1793
- });
1794
- module.exports = __toCommonJS(EndpointSnippetGenerator_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/ast/AbstractFormatter.js
2005
- init_process();
2006
- init_buffer();
2007
- var AbstractFormatter = class {
2008
- };
2009
- var NopFormatter = class extends AbstractFormatter {
2010
- async format(content) {
2011
- return content;
2012
- }
2013
- formatSync(content) {
2014
- return content;
2015
- }
2016
- };
2017
-
2018
- // ../../browser-compatible-base/lib/dynamic-snippets/index.js
2019
- init_process();
2020
- init_buffer();
2021
-
2022
- // ../../browser-compatible-base/lib/dynamic-snippets/ErrorReporter.js
2023
- init_process();
2024
- init_buffer();
2025
- var Severity = {
2026
- Critical: "CRITICAL",
2027
- Warning: "WARNING"
2028
- };
2029
-
2030
- // ../../browser-compatible-base/lib/dynamic-snippets/Scope.js
2031
- init_process();
2032
- init_buffer();
2033
- var Scope = {
2034
- PathParameters: "pathParameters",
2035
- QueryParameters: "queryParameters",
2036
- Headers: "headers",
2037
- RequestBody: "requestBody"
2038
- };
2039
-
2040
- // ../ast/lib/index.js
2041
- init_process();
2042
- init_buffer();
2043
-
2044
- // ../ast/lib/typescript.js
2045
- var typescript_exports = {};
2046
- __export(typescript_exports, {
2047
- AstNode: () => AstNode,
2048
- ClassInstantiation: () => ClassInstantiation,
2049
- CodeBlock: () => CodeBlock2,
2050
- Comment: () => Comment,
2051
- Function: () => Function,
2052
- FunctionInvocation: () => FunctionInvocation,
2053
- MethodInvocation: () => MethodInvocation,
2054
- Parameter: () => Parameter,
2055
- Reference: () => Reference,
2056
- Type: () => Type,
2057
- TypeLiteral: () => TypeLiteral,
2058
- Types: () => Type,
2059
- Variable: () => Variable,
2060
- Writer: () => Writer,
2061
- codeblock: () => codeblock,
2062
- function_: () => function_,
2063
- instantiateClass: () => instantiateClass,
2064
- invokeFunction: () => invokeFunction,
2065
- invokeMethod: () => invokeMethod,
2066
- parameter: () => parameter,
2067
- reference: () => reference,
2068
- variable: () => variable
2069
- });
2070
- init_process();
2071
- init_buffer();
2072
-
2073
- // ../ast/lib/ast/index.js
2074
- init_process();
2075
- init_buffer();
2076
-
2077
- // ../ast/lib/ast/core/index.js
2078
- init_process();
2079
- init_buffer();
2080
-
2081
- // ../ast/lib/ast/core/AstNode.js
2082
- init_process();
2083
- init_buffer();
2084
-
2085
- // ../ast/lib/ast/core/TypeScriptFile.js
2086
- init_process();
2087
- init_buffer();
2088
-
2089
- // ../ast/lib/ast/core/Writer.js
2090
- init_process();
2091
- init_buffer();
2092
- var Writer = class extends AbstractWriter {
2093
- constructor({ customConfig, formatter }) {
2094
- super();
2095
- /* Custom generator config */
2096
- __publicField(this, "customConfig");
2097
- /* Formatter used to format Go source files */
2098
- __publicField(this, "formatter");
2099
- /* Import statements */
2100
- __publicField(this, "imports", {});
2101
- __publicField(this, "defaultImports", {});
2102
- __publicField(this, "starImportAliases", {});
2103
- __publicField(this, "starImportAliasesInverse", {});
2104
- this.customConfig = customConfig;
2105
- this.formatter = formatter != null ? formatter : new NopFormatter();
2106
- }
2107
- /**
2108
- * Adds the given import under its module name.
2109
- */
2110
- addImport(reference2) {
2111
- var _a, _b, _c;
2112
- if (reference2.importFrom != null) {
2113
- switch (reference2.importFrom.type) {
2114
- case "default": {
2115
- this.validateDefault(reference2);
2116
- break;
2117
- }
2118
- case "named": {
2119
- this.validateNamed(reference2);
2120
- break;
2121
- }
2122
- case "star": {
2123
- this.validateStar(reference2);
2124
- break;
2125
- }
2126
- }
2127
- const moduleImports = (_c = (_a = this.imports)[_b = reference2.importFrom.moduleName]) != null ? _c : _a[_b] = [];
2128
- const names = moduleImports.map((import_) => import_.name);
2129
- if (!names.includes(reference2.name)) {
2130
- moduleImports.push(reference2);
2131
- }
2132
- }
2133
- }
2134
- validateDefault(reference2) {
2135
- var _a, _b, _c, _d;
2136
- if (((_a = reference2.importFrom) == null ? void 0 : _a.type) !== "default") {
2137
- return;
2138
- }
2139
- const moduleDefault = (_d = (_b = this.defaultImports)[_c = reference2.importFrom.moduleName]) != null ? _d : _b[_c] = reference2;
2140
- if (moduleDefault.name !== reference2.name) {
2141
- throw new Error(`Cannot have multiple default imports for module ${reference2.importFrom.moduleName}: got ${reference2.name} but already had ${moduleDefault.name}`);
2142
- }
2143
- }
2144
- validateNamed(reference2) {
2145
- var _a, _b, _c, _d, _e;
2146
- if (((_a = reference2.importFrom) == null ? void 0 : _a.type) !== "named") {
2147
- return;
2148
- }
2149
- const existing = (_b = this.imports[reference2.importFrom.moduleName]) != null ? _b : [];
2150
- const existingStar = existing.filter((e) => {
2151
- var _a2;
2152
- return ((_a2 = e.importFrom) == null ? void 0 : _a2.type) === "star";
2153
- });
2154
- if (existingStar.length > 0) {
2155
- throw new Error(`Cannot add named import ${reference2.name} because non-named imports ${existingStar.map((e) => e.name)} already exist`);
2156
- }
2157
- const duplicates = [];
2158
- for (const references of Object.values(this.imports)) {
2159
- for (const ref of references) {
2160
- if (((_c = ref.importFrom) == null ? void 0 : _c.type) === "named" && ref.importFrom.moduleName !== reference2.importFrom.moduleName && ref.name === reference2.name) {
2161
- duplicates.push(ref);
2162
- }
2163
- }
2164
- }
2165
- if (duplicates.length > 0) {
2166
- 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}`);
2167
- }
2168
- }
2169
- validateStar(reference2) {
2170
- var _a, _b, _c, _d, _e, _f, _g;
2171
- if (((_a = reference2.importFrom) == null ? void 0 : _a.type) !== "star") {
2172
- return;
2173
- }
2174
- const moduleAlias = (_d = (_b = this.starImportAliases)[_c = reference2.importFrom.moduleName]) != null ? _d : _b[_c] = reference2.importFrom.starImportAlias;
2175
- if (moduleAlias !== reference2.importFrom.starImportAlias) {
2176
- throw new Error(`Cannot have more than one alias for non-named imports from a module: got ${reference2.importFrom.starImportAlias} but already have ${moduleAlias}.`);
2177
- }
2178
- const aliasModule = (_g = (_e = this.starImportAliasesInverse)[_f = reference2.importFrom.starImportAlias]) != null ? _g : _e[_f] = reference2.importFrom.moduleName;
2179
- if (aliasModule !== reference2.importFrom.moduleName) {
2180
- throw new Error(`Attempted to use alias ${reference2.importFrom.starImportAlias} for more than one module in the same file`);
2181
- }
2182
- }
2183
- };
2184
-
2185
- // ../ast/lib/ast/core/TypeScriptFile.js
2186
- var TypeScriptFile = class extends Writer {
2187
- constructor({ customConfig, formatter }) {
2188
- super({ customConfig, formatter });
2189
- }
2190
- async toString() {
2191
- const content = this.getContent();
2192
- if (this.formatter != null) {
2193
- try {
2194
- return this.formatter.format(content);
2195
- } catch (error) {
2196
- throw new Error(`Failed to format TypeScript file: ${error}
2197
- ${content}`);
2198
- }
2199
- }
2200
- return content;
2201
- }
2202
- toStringSync() {
2203
- const content = this.getContent();
2204
- if (this.formatter != null) {
2205
- try {
2206
- return this.formatter.formatSync(content);
2207
- } catch (error) {
2208
- throw new Error(`Failed to format TypeScript file: ${error}
2209
- ${content}`);
2210
- }
2211
- }
2212
- return content;
2213
- }
2214
- getContent() {
2215
- const imports = this.stringifyImports();
2216
- if (imports.length > 0) {
2217
- return imports + "\n" + this.buffer;
2218
- }
2219
- return this.buffer;
2220
- }
2221
- stringifyImports() {
2222
- let result = "";
2223
- for (const [module2, references] of Object.entries(this.imports)) {
2224
- const defaultImport = this.defaultImports[module2];
2225
- let stringifiedNonDefault = "";
2226
- const named = references.filter((r) => {
2227
- var _a;
2228
- return ((_a = r.importFrom) == null ? void 0 : _a.type) === "named";
2229
- });
2230
- const starImportAlias = this.starImportAliases[module2];
2231
- if (named.length > 0 || defaultImport != null || starImportAlias != null) {
2232
- result += "import";
2233
- if (defaultImport != null) {
2234
- result += ` ${defaultImport.name}`;
2235
- }
2236
- if (named.length > 0) {
2237
- for (const ref of named.slice(0, -1)) {
2238
- stringifiedNonDefault += `${ref.name}, `;
2239
- }
2240
- const lastRef = named[named.length - 1];
2241
- if (lastRef != null) {
2242
- stringifiedNonDefault += `${lastRef.name}`;
2243
- }
2244
- if (defaultImport != null) {
2245
- result += ",";
2246
- }
2247
- result += ` { ${stringifiedNonDefault} }`;
2248
- }
2249
- if (starImportAlias != null) {
2250
- if (defaultImport != null || named.length > 0) {
2251
- result += ", ";
2252
- }
2253
- result += ` * as ${starImportAlias}`;
2254
- }
2255
- result += ` from "${module2}";
2256
- `;
2257
- }
2258
- }
2259
- return result;
2260
- }
2261
- };
2262
-
2263
- // ../ast/lib/ast/core/AstNode.js
2264
- var AstNode = class extends AbstractAstNode {
2265
- /**
2266
- * Writes the node to a string.
2267
- */
2268
- async toString({ customConfig, formatter }) {
2269
- const file = new TypeScriptFile({ customConfig, formatter });
2270
- this.write(file);
2271
- return await file.toString();
2272
- }
2273
- toStringSync({ customConfig, formatter }) {
2274
- const file = new TypeScriptFile({ customConfig, formatter });
2275
- this.write(file);
2276
- return file.toStringSync();
2277
- }
2278
- };
2279
-
2280
- // ../ast/lib/ast/CodeBlock.js
2281
- init_process();
2282
- init_buffer();
2283
- var CodeBlock2 = class extends AstNode {
2284
- constructor(args) {
2285
- super();
2286
- __publicField(this, "args");
2287
- this.args = args;
2288
- }
2289
- write(writer) {
2290
- const commonCodeBlock = new CodeBlock(this.args);
2291
- return commonCodeBlock.write(writer);
2292
- }
2293
- };
2294
-
2295
- // ../ast/lib/ast/Type.js
2296
- init_process();
2297
- init_buffer();
2298
- var Type = class extends AstNode {
2299
- constructor(internalType) {
2300
- super();
2301
- __publicField(this, "internalType");
2302
- this.internalType = internalType;
2303
- }
2304
- write(writer) {
2305
- switch (this.internalType.type) {
2306
- case "string":
2307
- writer.write("string");
2308
- break;
2309
- case "number":
2310
- writer.write("number");
2311
- break;
2312
- case "bigint":
2313
- writer.write("bigint");
2314
- break;
2315
- case "boolean":
2316
- writer.write("boolean");
2317
- break;
2318
- case "array":
2319
- this.internalType.valueType.write(writer);
2320
- writer.write("[]");
2321
- break;
2322
- case "map":
2323
- writer.write("Record<");
2324
- this.internalType.keyType.write(writer);
2325
- writer.write(", ");
2326
- this.internalType.valueType.write(writer);
2327
- writer.write(">");
2328
- break;
2329
- case "object":
2330
- writer.write("{");
2331
- writer.indent();
2332
- for (const [key, value] of Object.entries(this.internalType.fields)) {
2333
- writer.write(`${key}: `);
2334
- value.write(writer);
2335
- writer.writeLine(",");
2336
- }
2337
- writer.dedent();
2338
- writer.write("}");
2339
- break;
2340
- case "enum":
2341
- writer.write("enum");
2342
- break;
2343
- case "any":
2344
- writer.write("any");
2345
- break;
2346
- case "promise":
2347
- writer.write("Promise<");
2348
- this.internalType.value.write(writer);
2349
- writer.write(">");
2350
- break;
2351
- case "unknown":
2352
- writer.write("unknown");
2353
- break;
2354
- case "void":
2355
- writer.write("void");
2356
- break;
2357
- case "undefined":
2358
- writer.write("undefined");
2359
- break;
2360
- case "null":
2361
- writer.write("null");
2362
- break;
2363
- case "never":
2364
- writer.write("never");
2365
- break;
2366
- case "nop":
2367
- break;
2368
- default:
2369
- assertNever(this.internalType);
2370
- }
2371
- }
2372
- /* Static factory methods for creating a Type */
2373
- static string() {
2374
- return new this({
2375
- type: "string"
2376
- });
2377
- }
2378
- static number() {
2379
- return new this({
2380
- type: "number"
2381
- });
2382
- }
2383
- static bigint() {
2384
- return new this({
2385
- type: "bigint"
2386
- });
2387
- }
2388
- static boolean() {
2389
- return new this({
2390
- type: "boolean"
2391
- });
2392
- }
2393
- static array(valueType) {
2394
- return new this({
2395
- type: "array",
2396
- valueType
2397
- });
2398
- }
2399
- static object(fields) {
2400
- return new this({
2401
- type: "object",
2402
- fields
2403
- });
2404
- }
2405
- static enum(values) {
2406
- return new this({
2407
- type: "enum",
2408
- values
2409
- });
2410
- }
2411
- static any() {
2412
- return new this({
2413
- type: "any"
2414
- });
2415
- }
2416
- static promise(value) {
2417
- if (value.internalType.type === "promise") {
2418
- return value;
2419
- }
2420
- return new this({
2421
- type: "promise",
2422
- value
2423
- });
2424
- }
2425
- static unknown() {
2426
- return new this({
2427
- type: "unknown"
2428
- });
2429
- }
2430
- static void() {
2431
- return new this({
2432
- type: "void"
2433
- });
2434
- }
2435
- static undefined() {
2436
- return new this({
2437
- type: "undefined"
2438
- });
2439
- }
2440
- static null() {
2441
- return new this({
2442
- type: "null"
2443
- });
2444
- }
2445
- static never() {
2446
- return new this({
2447
- type: "never"
2448
- });
2449
- }
2450
- static nop() {
2451
- return new this({
2452
- type: "nop"
2453
- });
2454
- }
2455
- };
2456
-
2457
- // ../ast/lib/ast/TypeLiteral.js
2458
- init_process();
2459
- init_buffer();
2460
- var TypeLiteral = class _TypeLiteral extends AstNode {
2461
- constructor(internalType) {
2462
- super();
2463
- __publicField(this, "internalType");
2464
- this.internalType = internalType;
2465
- }
2466
- write(writer) {
2467
- var _a, _b, _c, _d;
2468
- switch (this.internalType.type) {
2469
- case "array": {
2470
- this.writeIterable({ writer, iterable: this.internalType });
2471
- break;
2472
- }
2473
- case "blob": {
2474
- if ((_a = writer.customConfig) == null ? void 0 : _a.noSerdeLayer) {
2475
- writer.writeNode(_TypeLiteral.string(this.internalType.value));
2476
- return;
2477
- }
2478
- writer.write("new Blob([");
2479
- writer.writeNode(_TypeLiteral.string(this.internalType.value));
2480
- writer.write("])");
2481
- break;
2482
- }
2483
- case "boolean": {
2484
- writer.write(this.internalType.value.toString());
2485
- break;
2486
- }
2487
- case "bigint": {
2488
- if ((_b = writer.customConfig) == null ? void 0 : _b.noSerdeLayer) {
2489
- writer.writeNode(_TypeLiteral.string(this.internalType.value.toString()));
2490
- return;
2491
- }
2492
- writer.write(`BigInt(${this.internalType.value.toString()})`);
2493
- break;
2494
- }
2495
- case "datetime": {
2496
- if ((_c = writer.customConfig) == null ? void 0 : _c.noSerdeLayer) {
2497
- writer.writeNode(_TypeLiteral.string(this.internalType.value));
2498
- return;
2499
- }
2500
- writer.write("new Date(");
2501
- writer.writeNode(_TypeLiteral.string(this.internalType.value));
2502
- writer.write(")");
2503
- break;
2504
- }
2505
- case "number": {
2506
- writer.write(this.internalType.value.toString());
2507
- break;
2508
- }
2509
- case "object": {
2510
- this.writeObject({ writer, object: this.internalType });
2511
- break;
2512
- }
2513
- case "record": {
2514
- this.writeRecord({ writer, record: this.internalType });
2515
- break;
2516
- }
2517
- case "reference": {
2518
- writer.writeNode(this.internalType.value);
2519
- break;
2520
- }
2521
- case "set": {
2522
- if (((_d = writer.customConfig) == null ? void 0 : _d.noSerdeLayer) || this.isSetOfObjects()) {
2523
- writer.writeNode(_TypeLiteral.array({ values: this.internalType.values }));
2524
- return;
2525
- }
2526
- writer.write("new Set(");
2527
- this.writeIterable({ writer, iterable: this.internalType });
2528
- writer.write(")");
2529
- break;
2530
- }
2531
- case "string": {
2532
- if (this.internalType.value.includes("\n")) {
2533
- this.writeStringWithBackticks({ writer, value: this.internalType.value });
2534
- } else {
2535
- writer.write(`"${this.internalType.value.replaceAll('"', '\\"')}"`);
2536
- }
2537
- break;
2538
- }
2539
- case "tuple": {
2540
- this.writeIterable({ writer, iterable: this.internalType });
2541
- break;
2542
- }
2543
- case "unknown": {
2544
- this.writeUnknown({ writer, value: this.internalType.value });
2545
- break;
2546
- }
2547
- case "nop":
2548
- break;
2549
- default:
2550
- assertNever(this.internalType);
2551
- }
2552
- }
2553
- isObject() {
2554
- return this.internalType.type === "object";
2555
- }
2556
- asObjectOrThrow() {
2557
- if (this.isObject()) {
2558
- return this.internalType;
2559
- }
2560
- throw new Error("Internal error; ts.TypeLiteral is not an object");
2561
- }
2562
- isSet() {
2563
- return this.internalType.type === "set";
2564
- }
2565
- asSetOrThrow() {
2566
- if (this.isSet()) {
2567
- return this.internalType;
2568
- }
2569
- throw new Error("Internal error; ts.TypeLiteral is not a set");
2570
- }
2571
- isSetOfObjects() {
2572
- return this.isSet() && this.asSetOrThrow().values.every((value) => value.isObject());
2573
- }
2574
- writeStringWithBackticks({ writer, value }) {
2575
- writer.write("`");
2576
- const parts = value.split("\n");
2577
- const head = parts[0] + "\n";
2578
- const tail = parts.slice(1).join("\n");
2579
- writer.write(head.replaceAll("`", "\\`"));
2580
- writer.writeNoIndent(tail.replaceAll("`", "\\`"));
2581
- writer.write("`");
2582
- }
2583
- writeIterable({ writer, iterable }) {
2584
- const values = filterNopValues({ values: iterable.values });
2585
- if (values.length === 0) {
2586
- writer.write("[]");
2587
- return;
2588
- }
2589
- writer.writeLine("[");
2590
- writer.indent();
2591
- for (const value of values) {
2592
- value.write(writer);
2593
- writer.writeLine(",");
2594
- }
2595
- writer.dedent();
2596
- writer.write("]");
2597
- }
2598
- writeRecord({ writer, record }) {
2599
- const entries = filterNopRecordEntries({ entries: record.entries });
2600
- if (entries.length === 0) {
2601
- writer.write("{}");
2602
- return;
2603
- }
2604
- writer.writeLine("{");
2605
- writer.indent();
2606
- for (const entry of entries) {
2607
- entry.key.write(writer);
2608
- writer.write(": ");
2609
- entry.value.write(writer);
2610
- writer.writeLine(",");
2611
- }
2612
- writer.dedent();
2613
- writer.write("}");
2614
- }
2615
- writeObject({ writer, object }) {
2616
- const fields = filterNopObjectFields({ fields: object.fields });
2617
- if (fields.length === 0) {
2618
- writer.write("{}");
2619
- return;
2620
- }
2621
- writer.writeLine("{");
2622
- writer.indent();
2623
- for (const field of fields) {
2624
- writer.write(`${field.name}: `);
2625
- field.value.write(writer);
2626
- writer.writeLine(",");
2627
- }
2628
- writer.dedent();
2629
- writer.write("}");
2630
- }
2631
- /* Static factory methods for creating a TypeLiteral */
2632
- static array({ values }) {
2633
- return new this({
2634
- type: "array",
2635
- values
2636
- });
2637
- }
2638
- static bigint(value) {
2639
- return new this({ type: "bigint", value });
2640
- }
2641
- static blob(value) {
2642
- return new this({ type: "blob", value });
2643
- }
2644
- static boolean(value) {
2645
- return new this({ type: "boolean", value });
2646
- }
2647
- static datetime(value) {
2648
- return new this({ type: "datetime", value });
2649
- }
2650
- static number(value) {
2651
- return new this({ type: "number", value });
2652
- }
2653
- static object({ fields }) {
2654
- return new this({
2655
- type: "object",
2656
- fields
2657
- });
2658
- }
2659
- static record({ entries }) {
2660
- return new this({
2661
- type: "record",
2662
- entries
2663
- });
2664
- }
2665
- static reference(value) {
2666
- return new this({
2667
- type: "reference",
2668
- value
2669
- });
2670
- }
2671
- static set({ values }) {
2672
- return new this({
2673
- type: "set",
2674
- values
2675
- });
2676
- }
2677
- static string(value) {
2678
- return new this({
2679
- type: "string",
2680
- value
2681
- });
2682
- }
2683
- static tuple({ values }) {
2684
- return new this({
2685
- type: "tuple",
2686
- values
2687
- });
2688
- }
2689
- static unknown(value) {
2690
- return new this({ type: "unknown", value });
2691
- }
2692
- static nop() {
2693
- return new this({ type: "nop" });
2694
- }
2695
- static isNop(typeLiteral) {
2696
- return typeLiteral.internalType.type === "nop";
2697
- }
2698
- writeUnknown({ writer, value }) {
2699
- switch (typeof value) {
2700
- case "boolean":
2701
- writer.write(value.toString());
2702
- return;
2703
- case "string":
2704
- writer.write(value.includes('"') ? `\`${value}\`` : `"${value}"`);
2705
- return;
2706
- case "number":
2707
- writer.write(value.toString());
2708
- return;
2709
- case "object":
2710
- if (value == null) {
2711
- writer.write("null");
2712
- return;
2713
- }
2714
- if (Array.isArray(value)) {
2715
- this.writeUnknownArray({ writer, value });
2716
- return;
2717
- }
2718
- this.writeUnknownObject({ writer, value });
2719
- return;
2720
- default:
2721
- throw new Error(`Internal error; unsupported unknown type: ${typeof value}`);
2722
- }
2723
- }
2724
- writeUnknownArray({ writer, value }) {
2725
- if (value.length === 0) {
2726
- writer.write("[]");
2727
- return;
2728
- }
2729
- writer.writeLine("[");
2730
- writer.indent();
2731
- for (const element of value) {
2732
- writer.writeNode(_TypeLiteral.unknown(element));
2733
- writer.writeLine(",");
2734
- }
2735
- writer.dedent();
2736
- writer.write("]");
2737
- }
2738
- writeUnknownObject({ writer, value }) {
2739
- const entries = Object.entries(value);
2740
- if (entries.length === 0) {
2741
- writer.write("{}");
2742
- return;
2743
- }
2744
- writer.writeLine("{");
2745
- writer.indent();
2746
- for (const [key, val] of entries) {
2747
- writer.write(`${key}: `);
2748
- writer.writeNode(_TypeLiteral.unknown(val));
2749
- writer.writeLine(",");
2750
- }
2751
- writer.dedent();
2752
- writer.write("}");
2753
- }
2754
- };
2755
- function filterNopObjectFields({ fields }) {
2756
- return fields.filter((field) => !TypeLiteral.isNop(field.value));
2757
- }
2758
- function filterNopRecordEntries({ entries }) {
2759
- return entries.filter((entry) => !TypeLiteral.isNop(entry.key) && !TypeLiteral.isNop(entry.value));
2760
- }
2761
- function filterNopValues({ values }) {
2762
- return values.filter((value) => !TypeLiteral.isNop(value));
2763
- }
2764
-
2765
- // ../ast/lib/ast/Reference.js
2766
- init_process();
2767
- init_buffer();
2768
- var Reference = class extends AstNode {
2769
- constructor({ name, importFrom, memberName }) {
2770
- super();
2771
- __publicField(this, "name");
2772
- __publicField(this, "importFrom");
2773
- __publicField(this, "memberName");
2774
- this.name = name;
2775
- this.importFrom = importFrom;
2776
- this.memberName = memberName;
2777
- }
2778
- write(writer) {
2779
- var _a;
2780
- if (this.importFrom != null) {
2781
- writer.addImport(this);
2782
- }
2783
- const prefix = ((_a = this.importFrom) == null ? void 0 : _a.type) === "star" ? `${this.importFrom.starImportAlias}.` : "";
2784
- const suffix = this.memberName != null ? `.${this.memberName}` : "";
2785
- writer.write(`${prefix}${this.name}${suffix}`);
2786
- }
2787
- };
2788
-
2789
- // ../ast/lib/ast/Variable.js
2790
- init_process();
2791
- init_buffer();
2792
- var Variable = class extends AstNode {
2793
- constructor(args) {
2794
- super();
2795
- __publicField(this, "args");
2796
- this.args = args;
2797
- }
2798
- write(writer) {
2799
- if (this.args.export) {
2800
- writer.write("export ");
2801
- }
2802
- if (this.args.const) {
2803
- writer.write("const ");
2804
- } else {
2805
- writer.write("let ");
2806
- }
2807
- writer.write(`${this.args.name} = `);
2808
- writer.writeNode(this.args.initializer);
2809
- }
2810
- };
2811
-
2812
- // ../ast/lib/ast/Parameter.js
2813
- init_process();
2814
- init_buffer();
2815
-
2816
- // ../ast/lib/ast/Comment.js
2817
- init_process();
2818
- init_buffer();
2819
- var Comment = class extends AstNode {
2820
- constructor({ docs } = { docs: void 0 }) {
2821
- super();
2822
- __publicField(this, "docs");
2823
- this.docs = docs;
2824
- }
2825
- write(writer) {
2826
- if (this.docs != null) {
2827
- writer.writeLine("/**");
2828
- this.docs.split("\n").forEach((line) => {
2829
- writer.writeLine(` * ${line}`);
2830
- });
2831
- writer.writeLine("*/");
2832
- }
2833
- }
2834
- };
2835
-
2836
- // ../ast/lib/ast/Parameter.js
2837
- var Parameter = class extends AstNode {
2838
- constructor({ name, type, docs }) {
2839
- super();
2840
- __publicField(this, "name");
2841
- __publicField(this, "type");
2842
- __publicField(this, "docs");
2843
- this.name = name;
2844
- this.type = type;
2845
- this.docs = docs;
2846
- }
2847
- write(writer) {
2848
- if (this.docs != null) {
2849
- writer.writeNode(new Comment({ docs: this.docs }));
2850
- }
2851
- writer.write(`${this.name}: `);
2852
- this.type.write(writer);
2853
- }
2854
- };
2855
-
2856
- // ../ast/lib/ast/Function.js
2857
- init_process();
2858
- init_buffer();
2859
- var Function = class extends AstNode {
2860
- constructor({ name, parameters, async, body, return_, docs }) {
2861
- super();
2862
- __publicField(this, "name");
2863
- __publicField(this, "parameters");
2864
- __publicField(this, "async");
2865
- __publicField(this, "body");
2866
- __publicField(this, "return_");
2867
- __publicField(this, "docs");
2868
- this.name = name;
2869
- this.parameters = parameters;
2870
- this.async = async != null ? async : false;
2871
- this.body = body;
2872
- this.return_ = return_;
2873
- this.docs = docs;
2874
- }
2875
- write(writer) {
2876
- var _a;
2877
- writer.writeNode(new Comment({ docs: this.docs }));
2878
- if (this.async) {
2879
- writer.write("async ");
2880
- }
2881
- writer.write("function ");
2882
- writer.write(`${this.name}`);
2883
- this.writeParameters(writer);
2884
- if (this.return_ != null) {
2885
- writer.write(": ");
2886
- writer.writeNode(this.async ? Type.promise(this.return_) : this.return_);
2887
- }
2888
- writer.writeLine(" {");
2889
- writer.indent();
2890
- (_a = this.body) == null ? void 0 : _a.write(writer);
2891
- writer.dedent();
2892
- writer.writeNewLineIfLastLineNot();
2893
- writer.writeLine("}");
2894
- }
2895
- writeParameters(writer) {
2896
- if (this.parameters.length === 0) {
2897
- writer.write("()");
2898
- return;
2899
- }
2900
- writer.indent();
2901
- writer.writeLine("(");
2902
- for (const parameter2 of this.parameters) {
2903
- writer.writeNode(parameter2);
2904
- writer.writeLine(",");
2905
- }
2906
- writer.dedent();
2907
- writer.write(")");
2908
- }
2909
- };
2910
-
2911
- // ../ast/lib/ast/FunctionInvocation.js
2912
- init_process();
2913
- init_buffer();
2914
- var FunctionInvocation = class extends AstNode {
2915
- constructor({ function_: function_2, arguments_ }) {
2916
- super();
2917
- __publicField(this, "function_");
2918
- __publicField(this, "arguments_");
2919
- this.function_ = function_2;
2920
- this.arguments_ = arguments_;
2921
- }
2922
- write(writer) {
2923
- writer.writeNode(this.function_);
2924
- writer.write("(");
2925
- writer.delimit({
2926
- nodes: this.arguments_,
2927
- delimiter: ", ",
2928
- writeFunction: (argument) => argument.write(writer)
2929
- });
2930
- writer.write(")");
2931
- }
2932
- };
2933
-
2934
- // ../ast/lib/ast/MethodInvocation.js
2935
- init_process();
2936
- init_buffer();
2937
- var MethodInvocation = class extends AstNode {
2938
- constructor({ on: on2, method, arguments_, async }) {
2939
- super();
2940
- __publicField(this, "on");
2941
- __publicField(this, "method");
2942
- __publicField(this, "arguments_");
2943
- __publicField(this, "async");
2944
- this.on = on2;
2945
- this.method = method;
2946
- this.arguments_ = arguments_;
2947
- this.async = async;
2948
- }
2949
- write(writer) {
2950
- if (this.async) {
2951
- writer.write("await ");
2952
- }
2953
- this.on.write(writer);
2954
- writer.write(".");
2955
- writer.write(this.method);
2956
- writer.write("(");
2957
- writer.delimit({
2958
- nodes: this.arguments_,
2959
- delimiter: ", ",
2960
- writeFunction: (argument) => argument.write(writer)
2961
- });
2962
- writer.write(")");
2963
- }
2964
- };
2965
-
2966
- // ../ast/lib/ast/ClassInstantiation.js
2967
- init_process();
2968
- init_buffer();
2969
- var ClassInstantiation = class extends AstNode {
2970
- constructor({ class_, arguments_ }) {
2971
- super();
2972
- __publicField(this, "class_");
2973
- __publicField(this, "arguments_");
2974
- this.class_ = class_;
2975
- this.arguments_ = arguments_;
2976
- }
2977
- write(writer) {
2978
- writer.write("new ");
2979
- writer.writeNode(this.class_);
2980
- writer.write("(");
2981
- writer.delimit({
2982
- nodes: this.arguments_,
2983
- delimiter: ", ",
2984
- writeFunction: (argument) => argument.write(writer)
2985
- });
2986
- writer.write(")");
2987
- }
2988
- };
2989
-
2990
- // ../ast/lib/typescript.js
2991
- function codeblock(arg) {
2992
- return new CodeBlock2(arg);
2993
- }
2994
- function function_(args) {
2995
- return new Function(args);
2996
- }
2997
- function instantiateClass(args) {
2998
- return new ClassInstantiation(args);
2999
- }
3000
- function invokeFunction(args) {
3001
- return new FunctionInvocation(args);
3002
- }
3003
- function invokeMethod(args) {
3004
- return new MethodInvocation(args);
3005
- }
3006
- function parameter(args) {
3007
- return new Parameter(args);
3008
- }
3009
- function reference(arg) {
3010
- return new Reference(arg);
3011
- }
3012
- function variable(arg) {
3013
- return new Variable(arg);
3014
- }
3015
-
3016
- // src/EndpointSnippetGenerator.ts
3017
- var CLIENT_VAR_NAME = "client";
3018
- var MAIN_FUNCTION_NAME = "main";
3019
- var STRING_TYPE_REFERENCE = {
3020
- type: "primitive",
3021
- value: "STRING"
3022
- };
3023
- var EndpointSnippetGenerator = class {
3024
- constructor({ context }) {
3025
- __publicField(this, "context");
3026
- this.context = context;
3027
- }
3028
- async generateSnippet({
3029
- endpoint,
3030
- request
3031
- }) {
3032
- const code = this.buildCodeBlock({ endpoint, snippet: request });
3033
- return await code.toString({ customConfig: this.context.customConfig });
3034
- }
3035
- generateSnippetSync({
3036
- endpoint,
3037
- request
3038
- }) {
3039
- const code = this.buildCodeBlock({ endpoint, snippet: request });
3040
- return code.toStringSync({ customConfig: this.context.customConfig });
3041
- }
3042
- buildCodeBlock({
3043
- endpoint,
3044
- snippet
3045
- }) {
3046
- return typescript_exports.codeblock((writer) => {
3047
- writer.writeNode(
3048
- typescript_exports.function_({
3049
- name: MAIN_FUNCTION_NAME,
3050
- async: true,
3051
- parameters: [],
3052
- body: typescript_exports.codeblock((writer2) => {
3053
- writer2.writeNodeStatement(this.constructClient({ endpoint, snippet }));
3054
- writer2.writeNodeStatement(this.callMethod({ endpoint, snippet }));
3055
- })
3056
- })
3057
- );
3058
- writer.writeNodeStatement(
3059
- typescript_exports.invokeFunction({
3060
- function_: typescript_exports.reference({
3061
- name: MAIN_FUNCTION_NAME
3062
- }),
3063
- arguments_: []
3064
- })
3065
- );
3066
- });
3067
- }
3068
- constructClient({
3069
- endpoint,
3070
- snippet
3071
- }) {
3072
- return typescript_exports.variable({
3073
- name: CLIENT_VAR_NAME,
3074
- const: true,
3075
- initializer: typescript_exports.instantiateClass({
3076
- class_: typescript_exports.reference({
3077
- name: this.context.getRootClientName(),
3078
- importFrom: this.context.getModuleImport()
3079
- }),
3080
- arguments_: [this.getConstructorArgs({ endpoint, snippet })]
3081
- })
3082
- });
3083
- }
3084
- getConstructorArgs({
3085
- endpoint,
3086
- snippet
3087
- }) {
3088
- const fields = [];
3089
- const environmentArgs = this.getConstructorEnvironmentArgs({
3090
- baseUrl: snippet.baseURL,
3091
- environment: snippet.environment
3092
- });
3093
- if (environmentArgs.length > 0) {
3094
- fields.push(...environmentArgs);
3095
- }
3096
- if (endpoint.auth != null) {
3097
- if (snippet.auth != null) {
3098
- fields.push(...this.getConstructorAuthArgs({ auth: endpoint.auth, values: snippet.auth }));
3099
- } else {
3100
- this.context.errors.add({
3101
- severity: Severity.Warning,
3102
- message: `Auth with ${endpoint.auth.type} configuration is required for this endpoint`
3103
- });
3104
- }
3105
- }
3106
- this.context.errors.scope(Scope.Headers);
3107
- if (this.context.ir.headers != null && snippet.headers != null) {
3108
- fields.push(
3109
- ...this.getConstructorHeaderArgs({ headers: this.context.ir.headers, values: snippet.headers })
3110
- );
3111
- }
3112
- this.context.errors.unscope();
3113
- if (fields.length === 0) {
3114
- return typescript_exports.TypeLiteral.nop();
3115
- }
3116
- return typescript_exports.TypeLiteral.object({ fields });
3117
- }
3118
- getConstructorEnvironmentArgs({
3119
- baseUrl,
3120
- environment
3121
- }) {
3122
- const environmentValue = this.getEnvironmentValue({ baseUrl, environment });
3123
- if (environmentValue == null) {
3124
- return [];
3125
- }
3126
- return [
3127
- {
3128
- name: "environment",
3129
- value: environmentValue
3130
- }
3131
- ];
3132
- }
3133
- getEnvironmentValue({
3134
- baseUrl,
3135
- environment
3136
- }) {
3137
- if (baseUrl != null && environment != null) {
3138
- this.context.errors.add({
3139
- severity: Severity.Critical,
3140
- message: "Cannot specify both baseUrl and environment options"
3141
- });
3142
- return void 0;
3143
- }
3144
- if (baseUrl != null) {
3145
- return typescript_exports.TypeLiteral.string(baseUrl);
3146
- }
3147
- if (environment != null) {
3148
- if (this.context.isSingleEnvironmentID(environment)) {
3149
- const environmentTypeReference = this.context.getEnvironmentTypeReferenceFromID(environment);
3150
- if (environmentTypeReference == null) {
3151
- this.context.errors.add({
3152
- severity: Severity.Warning,
3153
- message: `Environment ${JSON.stringify(environment)} was not found`
3154
- });
3155
- return void 0;
3156
- }
3157
- return typescript_exports.TypeLiteral.reference(environmentTypeReference);
3158
- }
3159
- if (this.context.isMultiEnvironmentValues(environment)) {
3160
- if (!this.context.validateMultiEnvironmentUrlValues(environment)) {
3161
- return void 0;
3162
- }
3163
- return typescript_exports.TypeLiteral.object({
3164
- fields: Object.entries(environment).map(([key, value]) => ({
3165
- name: key,
3166
- value: this.context.dynamicTypeLiteralMapper.convert({
3167
- typeReference: STRING_TYPE_REFERENCE,
3168
- value
3169
- })
3170
- }))
3171
- });
3172
- }
3173
- }
3174
- return void 0;
3175
- }
3176
- getConstructorAuthArgs({
3177
- auth,
3178
- values
3179
- }) {
3180
- switch (auth.type) {
3181
- case "basic":
3182
- if (values.type !== "basic") {
3183
- this.context.errors.add({
3184
- severity: Severity.Critical,
3185
- message: this.context.newAuthMismatchError({ auth, values }).message
3186
- });
3187
- return [];
3188
- }
3189
- return this.getConstructorBasicAuthArg({ auth, values });
3190
- case "bearer":
3191
- if (values.type !== "bearer") {
3192
- this.context.errors.add({
3193
- severity: Severity.Critical,
3194
- message: this.context.newAuthMismatchError({ auth, values }).message
3195
- });
3196
- return [];
3197
- }
3198
- return this.getConstructorBearerAuthArgs({ auth, values });
3199
- case "header":
3200
- if (values.type !== "header") {
3201
- this.context.errors.add({
3202
- severity: Severity.Critical,
3203
- message: this.context.newAuthMismatchError({ auth, values }).message
3204
- });
3205
- return [];
3206
- }
3207
- return this.getConstructorHeaderAuthArgs({ auth, values });
3208
- default:
3209
- assertNever(auth);
3210
- }
3211
- }
3212
- getConstructorBasicAuthArg({
3213
- auth,
3214
- values
3215
- }) {
3216
- return [
3217
- {
3218
- name: this.context.getPropertyName(auth.username),
3219
- value: typescript_exports.TypeLiteral.string(values.username)
3220
- },
3221
- {
3222
- name: this.context.getPropertyName(auth.password),
3223
- value: typescript_exports.TypeLiteral.string(values.password)
3224
- }
3225
- ];
3226
- }
3227
- getConstructorBearerAuthArgs({
3228
- auth,
3229
- values
3230
- }) {
3231
- return [
3232
- {
3233
- name: this.context.getPropertyName(auth.token),
3234
- value: typescript_exports.TypeLiteral.string(values.token)
3235
- }
3236
- ];
3237
- }
3238
- getConstructorHeaderAuthArgs({
3239
- auth,
3240
- values
3241
- }) {
3242
- return [
3243
- {
3244
- name: this.context.getPropertyName(auth.header.name.name),
3245
- value: this.context.dynamicTypeLiteralMapper.convert({
3246
- typeReference: auth.header.typeReference,
3247
- value: values.value
3248
- })
3249
- }
3250
- ];
3251
- }
3252
- getConstructorHeaderArgs({
3253
- headers,
3254
- values
3255
- }) {
3256
- const fields = [];
3257
- for (const header of headers) {
3258
- const field = this.getConstructorHeaderArg({ header, value: values.value });
3259
- if (field != null) {
3260
- fields.push(field);
3261
- }
3262
- }
3263
- return fields;
3264
- }
3265
- getConstructorHeaderArg({
3266
- header,
3267
- value
3268
- }) {
3269
- const typeLiteral = this.context.dynamicTypeLiteralMapper.convert({
3270
- typeReference: header.typeReference,
3271
- value
3272
- });
3273
- if (typescript_exports.TypeLiteral.isNop(typeLiteral)) {
3274
- return void 0;
3275
- }
3276
- return {
3277
- name: this.context.getPropertyName(header.name.name),
3278
- value: typeLiteral
3279
- };
3280
- }
3281
- callMethod({
3282
- endpoint,
3283
- snippet
3284
- }) {
3285
- return typescript_exports.invokeMethod({
3286
- on: typescript_exports.reference({ name: CLIENT_VAR_NAME }),
3287
- method: this.getMethod({ endpoint }),
3288
- async: true,
3289
- arguments_: this.getMethodArgs({ endpoint, snippet })
3290
- });
3291
- }
3292
- getMethodArgs({
3293
- endpoint,
3294
- snippet
3295
- }) {
3296
- switch (endpoint.request.type) {
3297
- case "inlined":
3298
- return this.getMethodArgsForInlinedRequest({ request: endpoint.request, snippet });
3299
- case "body":
3300
- return this.getMethodArgsForBodyRequest({ request: endpoint.request, snippet });
3301
- default:
3302
- assertNever(endpoint.request);
3303
- }
3304
- }
3305
- getMethodArgsForBodyRequest({
3306
- request,
3307
- snippet
3308
- }) {
3309
- const args = [];
3310
- this.context.errors.scope(Scope.PathParameters);
3311
- if (request.pathParameters != null) {
3312
- const pathParameterFields = this.getPathParameters({ namedParameters: request.pathParameters, snippet });
3313
- args.push(...pathParameterFields.map((field) => field.value));
3314
- }
3315
- this.context.errors.unscope();
3316
- this.context.errors.scope(Scope.RequestBody);
3317
- if (request.body != null) {
3318
- args.push(this.getBodyRequestArg({ body: request.body, value: snippet.requestBody }));
3319
- }
3320
- this.context.errors.unscope();
3321
- return args;
3322
- }
3323
- getBodyRequestArg({
3324
- body,
3325
- value
3326
- }) {
3327
- switch (body.type) {
3328
- case "bytes":
3329
- return this.getBytesBodyRequestArg({ value });
3330
- case "typeReference":
3331
- return this.context.dynamicTypeLiteralMapper.convert({ typeReference: body.value, value });
3332
- default:
3333
- assertNever(body);
3334
- }
3335
- }
3336
- getBytesBodyRequestArg({ value }) {
3337
- if (typeof value !== "string") {
3338
- this.context.errors.add({
3339
- severity: Severity.Critical,
3340
- message: `Expected bytes value to be a string, got ${typeof value}`
3341
- });
3342
- return typescript_exports.TypeLiteral.nop();
3343
- }
3344
- return typescript_exports.TypeLiteral.blob(value);
3345
- }
3346
- getMethodArgsForInlinedRequest({
3347
- request,
3348
- snippet
3349
- }) {
3350
- var _a, _b, _c, _d;
3351
- const args = [];
3352
- const { inlinePathParameters, inlineFileProperties } = {
3353
- inlinePathParameters: (_b = (_a = this.context.customConfig) == null ? void 0 : _a.inlinePathParameters) != null ? _b : false,
3354
- inlineFileProperties: (_d = (_c = this.context.customConfig) == null ? void 0 : _c.inlineFileProperties) != null ? _d : false
3355
- };
3356
- this.context.errors.scope(Scope.PathParameters);
3357
- const pathParameterFields = [];
3358
- if (request.pathParameters != null) {
3359
- pathParameterFields.push(...this.getPathParameters({ namedParameters: request.pathParameters, snippet }));
3360
- }
3361
- this.context.errors.unscope();
3362
- this.context.errors.scope(Scope.RequestBody);
3363
- const filePropertyInfo = this.getFilePropertyInfo({ request, snippet });
3364
- this.context.errors.unscope();
3365
- if (!this.context.includePathParametersInWrappedRequest({
3366
- request,
3367
- inlinePathParameters
3368
- })) {
3369
- args.push(...pathParameterFields.map((field) => field.value));
3370
- }
3371
- if (!inlineFileProperties) {
3372
- args.push(...filePropertyInfo.fileFields.map((field) => field.value));
3373
- }
3374
- if (this.context.needsRequestParameter({
3375
- request,
3376
- inlinePathParameters,
3377
- inlineFileProperties
3378
- })) {
3379
- args.push(
3380
- this.getInlinedRequestArg({
3381
- request,
3382
- snippet,
3383
- pathParameterFields: this.context.includePathParametersInWrappedRequest({
3384
- request,
3385
- inlinePathParameters
3386
- }) ? pathParameterFields : [],
3387
- filePropertyInfo
3388
- })
3389
- );
3390
- }
3391
- return args;
3392
- }
3393
- getFilePropertyInfo({
3394
- request,
3395
- snippet
3396
- }) {
3397
- if (request.body == null || !this.context.isFileUploadRequestBody(request.body)) {
3398
- return {
3399
- fileFields: [],
3400
- bodyPropertyFields: []
3401
- };
3402
- }
3403
- return this.context.filePropertyMapper.getFilePropertyInfo({
3404
- body: request.body,
3405
- value: snippet.requestBody
3406
- });
3407
- }
3408
- getInlinedRequestArg({
3409
- request,
3410
- snippet,
3411
- pathParameterFields,
3412
- filePropertyInfo
3413
- }) {
3414
- var _a, _b, _c, _d;
3415
- this.context.errors.scope(Scope.QueryParameters);
3416
- const queryParameters = this.context.associateQueryParametersByWireValue({
3417
- parameters: (_a = request.queryParameters) != null ? _a : [],
3418
- values: (_b = snippet.queryParameters) != null ? _b : {}
3419
- });
3420
- const queryParameterFields = queryParameters.map((queryParameter) => ({
3421
- name: this.context.getPropertyName(queryParameter.name.name),
3422
- value: this.context.dynamicTypeLiteralMapper.convert(queryParameter)
3423
- }));
3424
- this.context.errors.unscope();
3425
- this.context.errors.scope(Scope.Headers);
3426
- const headers = this.context.associateByWireValue({
3427
- parameters: (_c = request.headers) != null ? _c : [],
3428
- values: (_d = snippet.headers) != null ? _d : {}
3429
- });
3430
- const headerFields = headers.map((header) => ({
3431
- name: this.context.getPropertyName(header.name.name),
3432
- value: this.context.dynamicTypeLiteralMapper.convert(header)
3433
- }));
3434
- this.context.errors.unscope();
3435
- this.context.errors.scope(Scope.RequestBody);
3436
- const requestBodyFields = request.body != null ? this.getInlinedRequestBodyObjectFields({
3437
- body: request.body,
3438
- value: snippet.requestBody,
3439
- filePropertyInfo
3440
- }) : [];
3441
- this.context.errors.unscope();
3442
- return typescript_exports.TypeLiteral.object({
3443
- fields: [...pathParameterFields, ...queryParameterFields, ...headerFields, ...requestBodyFields]
3444
- });
3445
- }
3446
- getInlinedRequestBodyObjectFields({
3447
- body,
3448
- value,
3449
- filePropertyInfo
3450
- }) {
3451
- switch (body.type) {
3452
- case "properties":
3453
- return this.getInlinedRequestBodyPropertyObjectFields({ parameters: body.value, value });
3454
- case "referenced":
3455
- return [this.getReferencedRequestBodyPropertyObjectField({ body, value })];
3456
- case "fileUpload":
3457
- return this.getFileUploadRequestBodyObjectFields({ filePropertyInfo });
3458
- default:
3459
- assertNever(body);
3460
- }
3461
- }
3462
- getFileUploadRequestBodyObjectFields({
3463
- filePropertyInfo
3464
- }) {
3465
- var _a;
3466
- if ((_a = this.context.customConfig) == null ? void 0 : _a.inlineFileProperties) {
3467
- return [...filePropertyInfo.fileFields, ...filePropertyInfo.bodyPropertyFields];
3468
- }
3469
- return filePropertyInfo.bodyPropertyFields;
3470
- }
3471
- getReferencedRequestBodyPropertyObjectField({
3472
- body,
3473
- value
3474
- }) {
3475
- return {
3476
- name: this.context.getPropertyName(body.bodyKey),
3477
- value: this.getReferencedRequestBodyPropertyTypeLiteral({ body: body.bodyType, value })
3478
- };
3479
- }
3480
- getReferencedRequestBodyPropertyTypeLiteral({
3481
- body,
3482
- value
3483
- }) {
3484
- switch (body.type) {
3485
- case "bytes":
3486
- return this.getBytesBodyRequestArg({ value });
3487
- case "typeReference":
3488
- return this.context.dynamicTypeLiteralMapper.convert({ typeReference: body.value, value });
3489
- default:
3490
- assertNever(body);
3491
- }
3492
- }
3493
- getInlinedRequestBodyPropertyObjectFields({
3494
- parameters,
3495
- value
3496
- }) {
3497
- var _a;
3498
- const fields = [];
3499
- const bodyProperties = this.context.associateByWireValue({
3500
- parameters,
3501
- values: (_a = this.context.getRecord(value)) != null ? _a : {}
3502
- });
3503
- for (const parameter2 of bodyProperties) {
3504
- fields.push({
3505
- name: this.context.getPropertyName(parameter2.name.name),
3506
- value: this.context.dynamicTypeLiteralMapper.convert(parameter2)
3507
- });
3508
- }
3509
- return fields;
3510
- }
3511
- getPathParameters({
3512
- namedParameters,
3513
- snippet
3514
- }) {
3515
- var _a;
3516
- const args = [];
3517
- const pathParameters = this.context.associateByWireValue({
3518
- parameters: namedParameters,
3519
- values: (_a = snippet.pathParameters) != null ? _a : {}
3520
- });
3521
- for (const parameter2 of pathParameters) {
3522
- args.push({
3523
- name: this.context.getPropertyName(parameter2.name.name),
3524
- value: this.context.dynamicTypeLiteralMapper.convert(parameter2)
3525
- });
3526
- }
3527
- return args;
3528
- }
3529
- getMethod({ endpoint }) {
3530
- if (endpoint.declaration.fernFilepath.allParts.length > 0) {
3531
- return `${endpoint.declaration.fernFilepath.allParts.map((val) => this.context.getMethodName(val)).join(".")}.${this.context.getMethodName(endpoint.declaration.name)}`;
3532
- }
3533
- return this.context.getMethodName(endpoint.declaration.name);
3534
- }
3535
- };
3536
- // Annotate the CommonJS export names for ESM import in node:
3537
- 0 && (module.exports = {
3538
- EndpointSnippetGenerator
3539
- });
1
+ "use strict";var re=Object.defineProperty;var We=Object.getOwnPropertyDescriptor;var Ve=Object.getOwnPropertyNames;var He=Object.prototype.hasOwnProperty;var Ge=(n,t,e)=>t in n?re(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e;var pe=(n,t)=>()=>(n&&(t=n(n=0)),t);var we=(n,t)=>{for(var e in t)re(n,e,{get:t[e],enumerable:!0})},Je=(n,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Ve(t))!He.call(n,i)&&i!==e&&re(n,i,{get:()=>t[i],enumerable:!(r=We(t,i))||r.enumerable});return n};var ze=n=>Je(re({},"__esModule",{value:!0}),n);var h=(n,t,e)=>Ge(n,typeof t!="symbol"?t+"":t,e);function ge(){throw new Error("setTimeout has not been defined")}function ve(){throw new Error("clearTimeout has not been defined")}function Ae(n){if(_===setTimeout)return setTimeout(n,0);if((_===ge||!_)&&setTimeout)return _=setTimeout,setTimeout(n,0);try{return _(n,0)}catch(t){try{return _.call(null,n,0)}catch(e){return _.call(this,n,0)}}}function Qe(n){if(C===clearTimeout)return clearTimeout(n);if((C===ve||!C)&&clearTimeout)return C=clearTimeout,clearTimeout(n);try{return C(n)}catch(t){try{return C.call(null,n)}catch(e){return C.call(this,n)}}}function Xe(){!V||!M||(V=!1,M.length?S=M.concat(S):ne=-1,S.length&&Te())}function Te(){if(!V){var n=Ae(Xe);V=!0;for(var t=S.length;t;){for(M=S,S=[];++ne<t;)M&&M[ne].run();ne=-1,t=S.length}M=null,V=!1,Qe(n)}}function Ze(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];S.push(new Ie(n,t)),S.length===1&&!V&&Ae(Te)}function Ie(n,t){this.fun=n,this.array=t}function O(){}function dt(n){throw new Error("process.binding is not supported")}function yt(){return"/"}function wt(n){throw new Error("process.chdir is not supported")}function xt(){return 0}function vt(n){var t=gt.call(W)*.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 Tt(){var n=new Date,t=n-At;return t/1e3}var _,C,S,V,M,ne,Ke,et,tt,rt,nt,it,ot,st,at,ut,ct,lt,pt,ht,ft,mt,W,gt,At,y,xe,l=pe(()=>{"use strict";_=ge,C=ve;typeof globalThis.setTimeout=="function"&&(_=setTimeout);typeof globalThis.clearTimeout=="function"&&(C=clearTimeout);S=[],V=!1,ne=-1;Ie.prototype.run=function(){this.fun.apply(null,this.array)};Ke="browser",et="browser",tt=!0,rt={},nt=[],it="",ot={},st={},at={};ut=O,ct=O,lt=O,pt=O,ht=O,ft=O,mt=O;W=globalThis.performance||{},gt=W.now||W.mozNow||W.msNow||W.oNow||W.webkitNow||function(){return new Date().getTime()};At=new Date;y={nextTick:Ze,title:Ke,browser:tt,env:rt,argv:nt,version:it,versions:ot,on:ut,addListener:ct,once:lt,off:pt,removeListener:ht,removeAllListeners:ft,emit:mt,binding:dt,cwd:yt,chdir:wt,umask:xt,hrtime:vt,platform:et,release:st,config:at,uptime:Tt},xe={};Object.keys(xe).forEach(n=>{let t=n.split("."),e=y;for(let r=0;r<t.length;r++){let i=t[r];r===t.length-1?e[i]=xe[n]:e=e[i]||(e[i]={})}})});function Fe(){fe=!0;for(var n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0,e=n.length;t<e;++t)R[t]=n[t],E[n.charCodeAt(t)]=t;E[45]=62,E[95]=63}function Et(n){fe||Fe();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 It(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 bt(n){return R[n>>18&63]+R[n>>12&63]+R[n>>6&63]+R[n&63]}function Rt(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(bt(r));return i.join("")}function Ee(n){fe||Fe();for(var t,e=n.length,r=e%3,i="",o=[],s=16383,u=0,c=e-r;u<c;u+=s)o.push(Rt(n,u,u+s>c?c:u+s));return r===1?(t=n[e-1],i+=R[t>>2],i+=R[t<<4&63],i+="=="):r===2&&(t=(n[e-2]<<8)+n[e-1],i+=R[t>>10],i+=R[t>>4&63],i+=R[t<<2&63],i+="="),o.push(i),o.join("")}function ie(){return a.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function B(n,t){if(ie()<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 me(this,n)}return Ne(this,n,t,e)}function Ne(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?Pt(n,t,e,r):typeof t=="string"?Nt(n,t,e):St(n,t)}function Pe(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 Ft(n,t,e,r){return Pe(t),t<=0?B(n,t):e!==void 0?typeof r=="string"?B(n,t).fill(e,r):B(n,t).fill(e):B(n,t)}function me(n,t){if(Pe(t),n=B(n,t<0?0:de(t)|0),!a.TYPED_ARRAY_SUPPORT)for(var e=0;e<t;++e)n[e]=0;return n}function Nt(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=Se(t,e)|0;n=B(n,r);var i=n.write(t,e);return i!==r&&(n=n.slice(0,i)),n}function he(n,t){var e=t.length<0?0:de(t.length)|0;n=B(n,e);for(var r=0;r<e;r+=1)n[r]=t[r]&255;return n}function Pt(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=he(n,t),n}function St(n,t){if(F(t)){var e=de(t.length)|0;return n=B(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"||zt(t.length)?B(n,0):he(n,t);if(t.type==="Buffer"&&Array.isArray(t.data))return he(n,t.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}function de(n){if(n>=ie())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+ie().toString(16)+" bytes");return n|0}function F(n){return!!(n!=null&&n._isBuffer)}function Se(n,t){if(F(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 oe(n).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return e*2;case"hex":return e>>>1;case"base64":return Me(n).length;default:if(r)return oe(n).length;t=(""+t).toLowerCase(),r=!0}}function Bt(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 Yt(this,t,e);case"utf8":case"utf-8":return Le(this,t,e);case"ascii":return qt(this,t,e);case"latin1":case"binary":return Dt(this,t,e);case"base64":return Mt(this,t,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return jt(this,t,e);default:if(r)throw new TypeError("Unknown encoding: "+n);n=(n+"").toLowerCase(),r=!0}}function q(n,t,e){var r=n[t];n[t]=n[e],n[e]=r}function Be(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)),F(t))return t.length===0?-1:be(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):be(n,[t],e,r,i);throw new TypeError("val must be string, number or Buffer")}function be(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,I){return o===1?A[I]:A.readUInt16BE(I*o)}var m;if(i){var d=-1;for(m=e;m<s;m++)if(c(n,m)===c(t,d===-1?0:m-d)){if(d===-1&&(d=m),m-d+1===u)return d*o}else d!==-1&&(m-=m-d),d=-1}else for(e+u>s&&(e=s-u),m=e;m>=0;m--){for(var f=!0,x=0;x<u;x++)if(c(n,m+x)!==c(t,x)){f=!1;break}if(f)return m}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 Lt(n,t,e,r){return ue(oe(t,n.length-e),n,e,r)}function ke(n,t,e,r){return ue(Gt(t),n,e,r)}function _t(n,t,e,r){return ke(n,t,e,r)}function Ct(n,t,e,r){return ue(Me(t),n,e,r)}function Ut(n,t,e,r){return ue(Jt(t,n.length-e),n,e,r)}function Mt(n,t,e){return t===0&&e===n.length?Ee(n):Ee(n.slice(t,e))}function Le(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,m,d,f;switch(u){case 1:o<128&&(s=o);break;case 2:c=n[i+1],(c&192)===128&&(f=(o&31)<<6|c&63,f>127&&(s=f));break;case 3:c=n[i+1],m=n[i+2],(c&192)===128&&(m&192)===128&&(f=(o&15)<<12|(c&63)<<6|m&63,f>2047&&(f<55296||f>57343)&&(s=f));break;case 4:c=n[i+1],m=n[i+2],d=n[i+3],(c&192)===128&&(m&192)===128&&(d&192)===128&&(f=(o&15)<<18|(c&63)<<12|(m&63)<<6|d&63,f>65535&&f<1114112&&(s=f))}}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 Ot(r)}function Ot(n){var t=n.length;if(t<=Re)return String.fromCharCode.apply(String,n);for(var e="",r=0;r<t;)e+=String.fromCharCode.apply(String,n.slice(r,r+=Re));return e}function qt(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 Dt(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 Yt(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+=Ht(n[o]);return i}function jt(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 v(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 T(n,t,e,r,i,o){if(!F(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 se(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 ae(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 _e(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 Ce(n,t,e,r,i){return i||_e(n,t,e,4,34028234663852886e22,-34028234663852886e22),qe(n,t,e,r,23,4),e+4}function Ue(n,t,e,r,i){return i||_e(n,t,e,8,17976931348623157e292,-17976931348623157e292),qe(n,t,e,r,52,8),e+8}function Wt(n){if(n=Vt(n).replace($t,""),n.length<2)return"";for(;n.length%4!==0;)n=n+"=";return n}function Vt(n){return n.trim?n.trim():n.replace(/^\s+|\s+$/g,"")}function Ht(n){return n<16?"0"+n.toString(16):n.toString(16)}function oe(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 Gt(n){for(var t=[],e=0;e<n.length;++e)t.push(n.charCodeAt(e)&255);return t}function Jt(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 Me(n){return Et(Wt(n))}function ue(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 zt(n){return n!==n}function Qt(n){return n!=null&&(!!n._isBuffer||Oe(n)||Xt(n))}function Oe(n){return!!n.constructor&&typeof n.constructor.isBuffer=="function"&&n.constructor.isBuffer(n)}function Xt(n){return typeof n.readFloatLE=="function"&&typeof n.slice=="function"&&Oe(n.slice(0,0))}function ce(n,t,e,r,i){var o,s,u=i*8-r-1,c=(1<<u)-1,m=c>>1,d=-7,f=e?i-1:0,x=e?-1:1,A=n[t+f];for(f+=x,o=A&(1<<-d)-1,A>>=-d,d+=u;d>0;o=o*256+n[t+f],f+=x,d-=8);for(s=o&(1<<-d)-1,o>>=-d,d+=r;d>0;s=s*256+n[t+f],f+=x,d-=8);if(o===0)o=1-m;else{if(o===c)return s?NaN:(A?-1:1)*(1/0);s=s+Math.pow(2,r),o=o-m}return(A?-1:1)*s*Math.pow(2,o-r)}function qe(n,t,e,r,i,o){var s,u,c,m=o*8-i-1,d=(1<<m)-1,f=d>>1,x=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,A=r?0:o-1,I=r?1:-1,$e=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=d):(s=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-s))<1&&(s--,c*=2),s+f>=1?t+=x/c:t+=x*Math.pow(2,1-f),t*c>=2&&(s++,c/=2),s+f>=d?(u=0,s=d):s+f>=1?(u=(t*c-1)*Math.pow(2,i),s=s+f):(u=t*Math.pow(2,f-1)*Math.pow(2,i),s=0));i>=8;n[e+A]=u&255,A+=I,u/=256,i-=8);for(s=s<<i|u,m+=i;m>0;n[e+A]=s&255,A+=I,s/=256,m-=8);n[e+A-I]|=$e*128}var R,E,It,fe,Re,$t,De=pe(()=>{"use strict";l();p();R=[],E=[],It=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 Ne(null,n,t,e)};a.kMaxLength=ie();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 Ft(null,n,t,e)};a.allocUnsafe=function(n){return me(null,n)};a.allocUnsafeSlow=function(n){return me(null,n)};a.isBuffer=Qt;a.compare=function(t,e){if(!F(t)||!F(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(!F(s))throw new TypeError('"list" argument must be an Array of Buffers');s.copy(i,o),o+=s.length}return i};a.byteLength=Se;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)q(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)q(this,e,e+3),q(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)q(this,e,e+7),q(this,e+1,e+6),q(this,e+2,e+5),q(this,e+3,e+4);return this};a.prototype.toString=function(){var t=this.length|0;return t===0?"":arguments.length===0?Le(this,0,t):Bt.apply(this,arguments)};a.prototype.equals=function(t){if(!F(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(!F(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),m=this.slice(i,o),d=t.slice(e,r),f=0;f<c;++f)if(m[f]!==d[f]){s=m[f],u=d[f];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 Be(this,t,e,r,!0)};a.prototype.lastIndexOf=function(t,e,r){return Be(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 Lt(this,t,e,r);case"ascii":return ke(this,t,e,r);case"latin1":case"binary":return _t(this,t,e,r);case"base64":return Ct(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Ut(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)}};Re=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||v(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||v(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||v(t,1,this.length),this[t]};a.prototype.readUInt16LE=function(t,e){return e||v(t,2,this.length),this[t]|this[t+1]<<8};a.prototype.readUInt16BE=function(t,e){return e||v(t,2,this.length),this[t]<<8|this[t+1]};a.prototype.readUInt32LE=function(t,e){return e||v(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||v(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||v(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||v(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||v(t,1,this.length),this[t]&128?(255-this[t]+1)*-1:this[t]};a.prototype.readInt16LE=function(t,e){e||v(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||v(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||v(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||v(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||v(t,4,this.length),ce(this,t,!0,23,4)};a.prototype.readFloatBE=function(t,e){return e||v(t,4,this.length),ce(this,t,!1,23,4)};a.prototype.readDoubleLE=function(t,e){return e||v(t,8,this.length),ce(this,t,!0,52,8)};a.prototype.readDoubleBE=function(t,e){return e||v(t,8,this.length),ce(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;T(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;T(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||T(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||T(this,t,e,2,65535,0),a.TYPED_ARRAY_SUPPORT?(this[e]=t&255,this[e+1]=t>>>8):se(this,t,e,!0),e+2};a.prototype.writeUInt16BE=function(t,e,r){return t=+t,e=e|0,r||T(this,t,e,2,65535,0),a.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=t&255):se(this,t,e,!1),e+2};a.prototype.writeUInt32LE=function(t,e,r){return t=+t,e=e|0,r||T(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):ae(this,t,e,!0),e+4};a.prototype.writeUInt32BE=function(t,e,r){return t=+t,e=e|0,r||T(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):ae(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);T(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);T(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||T(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||T(this,t,e,2,32767,-32768),a.TYPED_ARRAY_SUPPORT?(this[e]=t&255,this[e+1]=t>>>8):se(this,t,e,!0),e+2};a.prototype.writeInt16BE=function(t,e,r){return t=+t,e=e|0,r||T(this,t,e,2,32767,-32768),a.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=t&255):se(this,t,e,!1),e+2};a.prototype.writeInt32LE=function(t,e,r){return t=+t,e=e|0,r||T(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):ae(this,t,e,!0),e+4};a.prototype.writeInt32BE=function(t,e,r){return t=+t,e=e|0,r||T(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):ae(this,t,e,!1),e+4};a.prototype.writeFloatLE=function(t,e,r){return Ce(this,t,e,!0,r)};a.prototype.writeFloatBE=function(t,e,r){return Ce(this,t,e,!1,r)};a.prototype.writeDoubleLE=function(t,e,r){return Ue(this,t,e,!0,r)};a.prototype.writeDoubleBE=function(t,e,r){return Ue(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=F(t)?t:oe(new a(t,i).toString()),c=u.length;for(s=0;s<r-e;++s)this[s+e]=u[s%c]}return this};$t=/[^+\/0-9A-Za-z-_]/g});var p=pe(()=>{"use strict";De()});var hr={};we(hr,{EndpointSnippetGenerator:()=>ye});module.exports=ze(hr);l();p();l();p();l();p();function b(n){throw new Error("Unexpected value: "+JSON.stringify(n))}l();p();l();p();var D=class{};l();p();l();p();var N=class extends D{constructor(e){super();h(this,"value");this.value=e}write(e){typeof this.value=="string"?e.write(this.value):this.value(e)}};var Zt=4,K=class{constructor(){h(this,"buffer","");h(this,"indentLevel",0);h(this,"hasWrittenAnything",!1);h(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)}writeNodeOrString(t){if(typeof t=="string"){this.write(t);return}this.writeNode(t)}writeNodeStatement(t){t.write(this),this.write(";"),this.writeNewLineIfLastLineNot()}writeTextStatement(t){new N(t).write(this),this.write(";"),this.writeNewLineIfLastLineNot()}controlFlow(t,e){new N(t).write(this),this.write(" ("),this.writeNode(e),this.write(") {"),this.writeNewLineIfLastLineNot(),this.indent()}endControlFlow(){this.dedent(),this.writeLine("}")}contiguousControlFlow(t,e){this.dedent(),this.write("} "),new N(t).write(this),this.write(" ("),this.writeNode(e),this.write(") {"),this.writeNewLineIfLastLineNot(),this.indent()}alternativeControlFlow(t){this.dedent(),this.write("} "),new N(t).write(this),this.write(" {"),this.writeNewLineIfLastLineNot(),this.indent()}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*Zt)}};l();p();var le=class{},ee=class extends le{async format(t){return t}formatSync(t){return t}};l();p();l();p();var k={Critical:"CRITICAL",Warning:"WARNING"};l();p();var P={PathParameters:"pathParameters",QueryParameters:"queryParameters",Headers:"headers",RequestBody:"requestBody"};l();p();var g={};we(g,{AstNode:()=>w,ClassInstantiation:()=>Z,CodeBlock:()=>H,Comment:()=>U,Function:()=>z,FunctionInvocation:()=>Q,MethodInvocation:()=>X,Parameter:()=>J,Reference:()=>$,Type:()=>j,TypeLiteral:()=>L,Types:()=>j,Variable:()=>G,Writer:()=>Y,codeblock:()=>nr,function_:()=>ir,instantiateClass:()=>or,invokeFunction:()=>sr,invokeMethod:()=>ar,parameter:()=>ur,reference:()=>cr,variable:()=>lr});l();p();l();p();l();p();l();p();l();p();l();p();var Y=class extends K{constructor({customConfig:e,formatter:r}){super();h(this,"customConfig");h(this,"formatter");h(this,"imports",{});h(this,"defaultImports",{});h(this,"starImportAliases",{});h(this,"starImportAliasesInverse",{});this.customConfig=e,this.formatter=r!=null?r:new ee}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,m,d;if(((s=e.importFrom)==null?void 0:s.type)!=="named")return;let i=((u=this.imports[e.importFrom.moduleName])!=null?u:[]).filter(f=>{var x;return((x=f.importFrom)==null?void 0:x.type)==="star"});if(i.length>0)throw new Error(`Cannot add named import ${e.name} because non-named imports ${i.map(f=>f.name)} already exist`);let o=[];for(let f of Object.values(this.imports))for(let x of f)((c=x.importFrom)==null?void 0:c.type)==="named"&&x.importFrom.moduleName!==e.importFrom.moduleName&&x.name===e.name&&o.push(x);if(o.length>0)throw new Error(`Cannot add named import from module ${e.importFrom.moduleName} because it is already imported from ${(d=(m=o[0])==null?void 0:m.importFrom)==null?void 0:d.moduleName}`)}validateStar(e){var o,s,u,c,m,d,f;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(((f=(m=this.starImportAliasesInverse)[d=e.importFrom.starImportAlias])!=null?f:m[d]=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 te=class extends Y{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 m;return((m=c.importFrom)==null?void 0:m.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 m of s.slice(0,-1))o+=`${m.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 w=class extends D{async toStringAsync({customConfig:t,formatter:e}){let r=new te({customConfig:t,formatter:e});return this.write(r),await r.toStringAsync()}toString({customConfig:t,formatter:e}){let r=new te({customConfig:t,formatter:e});return this.write(r),r.toString()}};l();p();var H=class extends w{constructor(e){super();h(this,"args");this.args=e}write(e){return new N(this.args).write(e)}};l();p();var j=class extends w{constructor(e){super();h(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:b(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 L=class n extends w{constructor(e){super();h(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:b(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=tr({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=er({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=Kt({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 Kt({fields:n}){return n.filter(t=>!L.isNop(t.value))}function er({entries:n}){return n.filter(t=>!L.isNop(t.key)&&!L.isNop(t.value))}function tr({values:n}){return n.filter(t=>!L.isNop(t))}l();p();var $=class extends w{constructor({name:e,importFrom:r,memberName:i}){super();h(this,"name");h(this,"importFrom");h(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 G=class extends w{constructor(e){super();h(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 U=class extends w{constructor({docs:e}={docs:void 0}){super();h(this,"docs");this.docs=e}write(e){this.docs!=null&&(e.writeLine("/**"),this.docs.split(`
17
+ `).forEach(r=>{e.writeLine(` * ${r}`)}),e.writeLine("*/"))}};var J=class extends w{constructor({name:e,type:r,docs:i}){super();h(this,"name");h(this,"type");h(this,"docs");this.name=e,this.type=r,this.docs=i}write(e){this.docs!=null&&e.writeNode(new U({docs:this.docs})),e.write(`${this.name}: `),this.type.write(e)}};l();p();var z=class extends w{constructor({name:e,parameters:r,async:i,body:o,return_:s,docs:u}){super();h(this,"name");h(this,"parameters");h(this,"async");h(this,"body");h(this,"return_");h(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 U({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?j.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 Q=class extends w{constructor({function_:e,arguments_:r}){super();h(this,"function_");h(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 w{constructor({on:e,method:r,arguments_:i,async:o}){super();h(this,"on");h(this,"method");h(this,"arguments_");h(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 w{constructor({class_:e,arguments_:r}){super();h(this,"class_");h(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 nr(n){return new H(n)}function ir(n){return new z(n)}function or(n){return new Z(n)}function sr(n){return new Q(n)}function ar(n){return new X(n)}function ur(n){return new J(n)}function cr(n){return new $(n)}function lr(n){return new G(n)}var Ye="client",je="main",pr={type:"primitive",value:"STRING"},ye=class{constructor({context:t}){h(this,"context");this.context=t}async generateSnippet({endpoint:t,request:e}){return await this.buildCodeBlock({endpoint:t,snippet:e}).toStringAsync({customConfig:this.context.customConfig})}generateSnippetSync({endpoint:t,request:e}){return this.buildCodeBlock({endpoint:t,snippet:e}).toString({customConfig:this.context.customConfig})}buildCodeBlock({endpoint:t,snippet:e}){return g.codeblock(r=>{r.writeNode(g.function_({name:je,async:!0,parameters:[],body:g.codeblock(i=>{i.writeNodeStatement(this.constructClient({endpoint:t,snippet:e})),i.writeNodeStatement(this.callMethod({endpoint:t,snippet:e}))})})),r.writeNodeStatement(g.invokeFunction({function_:g.reference({name:je}),arguments_:[]}))})}constructClient({endpoint:t,snippet:e}){return g.variable({name:Ye,const:!0,initializer:g.instantiateClass({class_:g.reference({name:this.context.getRootClientName(),importFrom:this.context.getModuleImport()}),arguments_:[this.getConstructorArgs({endpoint:t,snippet:e})]})})}getConstructorArgs({endpoint:t,snippet:e}){let r=[],i=this.getConstructorEnvironmentArgs({baseUrl:e.baseURL,environment:e.environment});return i.length>0&&r.push(...i),t.auth!=null&&(e.auth!=null?r.push(...this.getConstructorAuthArgs({auth:t.auth,values:e.auth})):this.context.errors.add({severity:k.Warning,message:`Auth with ${t.auth.type} configuration is required for this endpoint`})),this.context.errors.scope(P.Headers),this.context.ir.headers!=null&&e.headers!=null&&r.push(...this.getConstructorHeaderArgs({headers:this.context.ir.headers,values:e.headers})),this.context.errors.unscope(),r.length===0?g.TypeLiteral.nop():g.TypeLiteral.object({fields:r})}getConstructorEnvironmentArgs({baseUrl:t,environment:e}){let r=this.getEnvironmentValue({baseUrl:t,environment:e});return r==null?[]:[{name:"environment",value:r}]}getEnvironmentValue({baseUrl:t,environment:e}){if(t!=null&&e!=null){this.context.errors.add({severity:k.Critical,message:"Cannot specify both baseUrl and environment options"});return}if(t!=null)return g.TypeLiteral.string(t);if(e!=null){if(this.context.isSingleEnvironmentID(e)){let r=this.context.getEnvironmentTypeReferenceFromID(e);if(r==null){this.context.errors.add({severity:k.Warning,message:`Environment ${JSON.stringify(e)} was not found`});return}return g.TypeLiteral.reference(r)}if(this.context.isMultiEnvironmentValues(e))return this.context.validateMultiEnvironmentUrlValues(e)?g.TypeLiteral.object({fields:Object.entries(e).map(([r,i])=>({name:r,value:this.context.dynamicTypeLiteralMapper.convert({typeReference:pr,value:i})}))}):void 0}}getConstructorAuthArgs({auth:t,values:e}){switch(t.type){case"basic":return e.type!=="basic"?(this.context.errors.add({severity:k.Critical,message:this.context.newAuthMismatchError({auth:t,values:e}).message}),[]):this.getConstructorBasicAuthArg({auth:t,values:e});case"bearer":return e.type!=="bearer"?(this.context.errors.add({severity:k.Critical,message:this.context.newAuthMismatchError({auth:t,values:e}).message}),[]):this.getConstructorBearerAuthArgs({auth:t,values:e});case"header":return e.type!=="header"?(this.context.errors.add({severity:k.Critical,message:this.context.newAuthMismatchError({auth:t,values:e}).message}),[]):this.getConstructorHeaderAuthArgs({auth:t,values:e});default:b(t)}}getConstructorBasicAuthArg({auth:t,values:e}){return[{name:this.context.getPropertyName(t.username),value:g.TypeLiteral.string(e.username)},{name:this.context.getPropertyName(t.password),value:g.TypeLiteral.string(e.password)}]}getConstructorBearerAuthArgs({auth:t,values:e}){return[{name:this.context.getPropertyName(t.token),value:g.TypeLiteral.string(e.token)}]}getConstructorHeaderAuthArgs({auth:t,values:e}){return[{name:this.context.getPropertyName(t.header.name.name),value:this.context.dynamicTypeLiteralMapper.convert({typeReference:t.header.typeReference,value:e.value})}]}getConstructorHeaderArgs({headers:t,values:e}){let r=[];for(let i of t){let o=this.getConstructorHeaderArg({header:i,value:e.value});o!=null&&r.push(o)}return r}getConstructorHeaderArg({header:t,value:e}){let r=this.context.dynamicTypeLiteralMapper.convert({typeReference:t.typeReference,value:e});if(!g.TypeLiteral.isNop(r))return{name:this.context.getPropertyName(t.name.name),value:r}}callMethod({endpoint:t,snippet:e}){return g.invokeMethod({on:g.reference({name:Ye}),method:this.getMethod({endpoint:t}),async:!0,arguments_:this.getMethodArgs({endpoint:t,snippet:e})})}getMethodArgs({endpoint:t,snippet:e}){switch(t.request.type){case"inlined":return this.getMethodArgsForInlinedRequest({request:t.request,snippet:e});case"body":return this.getMethodArgsForBodyRequest({request:t.request,snippet:e});default:b(t.request)}}getMethodArgsForBodyRequest({request:t,snippet:e}){let r=[];if(this.context.errors.scope(P.PathParameters),t.pathParameters!=null){let i=this.getPathParameters({namedParameters:t.pathParameters,snippet:e});r.push(...i.map(o=>o.value))}return this.context.errors.unscope(),this.context.errors.scope(P.RequestBody),t.body!=null&&r.push(this.getBodyRequestArg({body:t.body,value:e.requestBody})),this.context.errors.unscope(),r}getBodyRequestArg({body:t,value:e}){switch(t.type){case"bytes":return this.getBytesBodyRequestArg({value:e});case"typeReference":return this.context.dynamicTypeLiteralMapper.convert({typeReference:t.value,value:e});default:b(t)}}getBytesBodyRequestArg({value:t}){return typeof t!="string"?(this.context.errors.add({severity:k.Critical,message:`Expected bytes value to be a string, got ${typeof t}`}),g.TypeLiteral.nop()):g.TypeLiteral.blob(t)}getMethodArgsForInlinedRequest({request:t,snippet:e}){var c,m,d,f;let r=[],{inlinePathParameters:i,inlineFileProperties:o}={inlinePathParameters:(m=(c=this.context.customConfig)==null?void 0:c.inlinePathParameters)!=null?m:!1,inlineFileProperties:(f=(d=this.context.customConfig)==null?void 0:d.inlineFileProperties)!=null?f:!1};this.context.errors.scope(P.PathParameters);let s=[];t.pathParameters!=null&&s.push(...this.getPathParameters({namedParameters:t.pathParameters,snippet:e})),this.context.errors.unscope(),this.context.errors.scope(P.RequestBody);let u=this.getFilePropertyInfo({request:t,snippet:e});return this.context.errors.unscope(),this.context.includePathParametersInWrappedRequest({request:t,inlinePathParameters:i})||r.push(...s.map(x=>x.value)),o||r.push(...u.fileFields.map(x=>x.value)),this.context.needsRequestParameter({request:t,inlinePathParameters:i,inlineFileProperties:o})&&r.push(this.getInlinedRequestArg({request:t,snippet:e,pathParameterFields:this.context.includePathParametersInWrappedRequest({request:t,inlinePathParameters:i})?s:[],filePropertyInfo:u})),r}getFilePropertyInfo({request:t,snippet:e}){return t.body==null||!this.context.isFileUploadRequestBody(t.body)?{fileFields:[],bodyPropertyFields:[]}:this.context.filePropertyMapper.getFilePropertyInfo({body:t.body,value:e.requestBody})}getInlinedRequestArg({request:t,snippet:e,pathParameterFields:r,filePropertyInfo:i}){var d,f,x,A;this.context.errors.scope(P.QueryParameters);let s=this.context.associateQueryParametersByWireValue({parameters:(d=t.queryParameters)!=null?d:[],values:(f=e.queryParameters)!=null?f:{}}).map(I=>({name:this.context.getPropertyName(I.name.name),value:this.context.dynamicTypeLiteralMapper.convert(I)}));this.context.errors.unscope(),this.context.errors.scope(P.Headers);let c=this.context.associateByWireValue({parameters:(x=t.headers)!=null?x:[],values:(A=e.headers)!=null?A:{}}).map(I=>({name:this.context.getPropertyName(I.name.name),value:this.context.dynamicTypeLiteralMapper.convert(I)}));this.context.errors.unscope(),this.context.errors.scope(P.RequestBody);let m=t.body!=null?this.getInlinedRequestBodyObjectFields({body:t.body,value:e.requestBody,filePropertyInfo:i}):[];return this.context.errors.unscope(),g.TypeLiteral.object({fields:[...r,...s,...c,...m]})}getInlinedRequestBodyObjectFields({body:t,value:e,filePropertyInfo:r}){switch(t.type){case"properties":return this.getInlinedRequestBodyPropertyObjectFields({parameters:t.value,value:e});case"referenced":return[this.getReferencedRequestBodyPropertyObjectField({body:t,value:e})];case"fileUpload":return this.getFileUploadRequestBodyObjectFields({filePropertyInfo:r});default:b(t)}}getFileUploadRequestBodyObjectFields({filePropertyInfo:t}){var e;return(e=this.context.customConfig)!=null&&e.inlineFileProperties?[...t.fileFields,...t.bodyPropertyFields]:t.bodyPropertyFields}getReferencedRequestBodyPropertyObjectField({body:t,value:e}){return{name:this.context.getPropertyName(t.bodyKey),value:this.getReferencedRequestBodyPropertyTypeLiteral({body:t.bodyType,value:e})}}getReferencedRequestBodyPropertyTypeLiteral({body:t,value:e}){switch(t.type){case"bytes":return this.getBytesBodyRequestArg({value:e});case"typeReference":return this.context.dynamicTypeLiteralMapper.convert({typeReference:t.value,value:e});default:b(t)}}getInlinedRequestBodyPropertyObjectFields({parameters:t,value:e}){var o;let r=[],i=this.context.associateByWireValue({parameters:t,values:(o=this.context.getRecord(e))!=null?o:{}});for(let s of i)r.push({name:this.context.getPropertyName(s.name.name),value:this.context.dynamicTypeLiteralMapper.convert(s)});return r}getPathParameters({namedParameters:t,snippet:e}){var o;let r=[],i=this.context.associateByWireValue({parameters:t,values:(o=e.pathParameters)!=null?o:{}});for(let s of i)r.push({name:this.context.getPropertyName(s.name.name),value:this.context.dynamicTypeLiteralMapper.convert(s)});return r}getMethod({endpoint:t}){return t.declaration.fernFilepath.allParts.length>0?`${t.declaration.fernFilepath.allParts.map(e=>this.context.getMethodName(e)).join(".")}.${this.context.getMethodName(t.declaration.name)}`:this.context.getMethodName(t.declaration.name)}};0&&(module.exports={EndpointSnippetGenerator});
3540
18
  /*! Bundled license information:
3541
19
 
3542
20
  @esbuild-plugins/node-globals-polyfill/Buffer.js: