@gbozee/ultimate 0.0.2-37 → 0.0.2-40

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 (3) hide show
  1. package/dist/index.d.ts +122 -127
  2. package/dist/index.js +1769 -1766
  3. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -18,426 +18,1633 @@ var __toESM = (mod, isNodeMode, target) => {
18
18
  var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
19
19
  var __require = /* @__PURE__ */ createRequire(import.meta.url);
20
20
 
21
- // node_modules/smart-buffer/build/utils.js
22
- var require_utils = __commonJS((exports) => {
23
- Object.defineProperty(exports, "__esModule", { value: true });
24
- var buffer_1 = __require("buffer");
25
- var ERRORS = {
26
- INVALID_ENCODING: "Invalid encoding provided. Please specify a valid encoding the internal Node.js Buffer supports.",
27
- INVALID_SMARTBUFFER_SIZE: "Invalid size provided. Size must be a valid integer greater than zero.",
28
- INVALID_SMARTBUFFER_BUFFER: "Invalid Buffer provided in SmartBufferOptions.",
29
- INVALID_SMARTBUFFER_OBJECT: "Invalid SmartBufferOptions object supplied to SmartBuffer constructor or factory methods.",
30
- INVALID_OFFSET: "An invalid offset value was provided.",
31
- INVALID_OFFSET_NON_NUMBER: "An invalid offset value was provided. A numeric value is required.",
32
- INVALID_LENGTH: "An invalid length value was provided.",
33
- INVALID_LENGTH_NON_NUMBER: "An invalid length value was provived. A numeric value is required.",
34
- INVALID_TARGET_OFFSET: "Target offset is beyond the bounds of the internal SmartBuffer data.",
35
- INVALID_TARGET_LENGTH: "Specified length value moves cursor beyong the bounds of the internal SmartBuffer data.",
36
- INVALID_READ_BEYOND_BOUNDS: "Attempted to read beyond the bounds of the managed data.",
37
- INVALID_WRITE_BEYOND_BOUNDS: "Attempted to write beyond the bounds of the managed data."
21
+ // node_modules/ms/index.js
22
+ var require_ms = __commonJS((exports, module) => {
23
+ var s = 1000;
24
+ var m = s * 60;
25
+ var h = m * 60;
26
+ var d = h * 24;
27
+ var w = d * 7;
28
+ var y = d * 365.25;
29
+ module.exports = function(val, options) {
30
+ options = options || {};
31
+ var type = typeof val;
32
+ if (type === "string" && val.length > 0) {
33
+ return parse(val);
34
+ } else if (type === "number" && isFinite(val)) {
35
+ return options.long ? fmtLong(val) : fmtShort(val);
36
+ }
37
+ throw new Error("val is not a non-empty string or a valid number. val=" + JSON.stringify(val));
38
38
  };
39
- exports.ERRORS = ERRORS;
40
- function checkEncoding(encoding) {
41
- if (!buffer_1.Buffer.isEncoding(encoding)) {
42
- throw new Error(ERRORS.INVALID_ENCODING);
39
+ function parse(str) {
40
+ str = String(str);
41
+ if (str.length > 100) {
42
+ return;
43
43
  }
44
- }
45
- exports.checkEncoding = checkEncoding;
46
- function isFiniteInteger(value) {
47
- return typeof value === "number" && isFinite(value) && isInteger(value);
48
- }
49
- exports.isFiniteInteger = isFiniteInteger;
50
- function checkOffsetOrLengthValue(value, offset) {
51
- if (typeof value === "number") {
52
- if (!isFiniteInteger(value) || value < 0) {
53
- throw new Error(offset ? ERRORS.INVALID_OFFSET : ERRORS.INVALID_LENGTH);
54
- }
55
- } else {
56
- throw new Error(offset ? ERRORS.INVALID_OFFSET_NON_NUMBER : ERRORS.INVALID_LENGTH_NON_NUMBER);
44
+ var match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(str);
45
+ if (!match) {
46
+ return;
57
47
  }
58
- }
59
- function checkLengthValue(length) {
60
- checkOffsetOrLengthValue(length, false);
61
- }
62
- exports.checkLengthValue = checkLengthValue;
63
- function checkOffsetValue(offset) {
64
- checkOffsetOrLengthValue(offset, true);
65
- }
66
- exports.checkOffsetValue = checkOffsetValue;
67
- function checkTargetOffset(offset, buff) {
68
- if (offset < 0 || offset > buff.length) {
69
- throw new Error(ERRORS.INVALID_TARGET_OFFSET);
48
+ var n = parseFloat(match[1]);
49
+ var type = (match[2] || "ms").toLowerCase();
50
+ switch (type) {
51
+ case "years":
52
+ case "year":
53
+ case "yrs":
54
+ case "yr":
55
+ case "y":
56
+ return n * y;
57
+ case "weeks":
58
+ case "week":
59
+ case "w":
60
+ return n * w;
61
+ case "days":
62
+ case "day":
63
+ case "d":
64
+ return n * d;
65
+ case "hours":
66
+ case "hour":
67
+ case "hrs":
68
+ case "hr":
69
+ case "h":
70
+ return n * h;
71
+ case "minutes":
72
+ case "minute":
73
+ case "mins":
74
+ case "min":
75
+ case "m":
76
+ return n * m;
77
+ case "seconds":
78
+ case "second":
79
+ case "secs":
80
+ case "sec":
81
+ case "s":
82
+ return n * s;
83
+ case "milliseconds":
84
+ case "millisecond":
85
+ case "msecs":
86
+ case "msec":
87
+ case "ms":
88
+ return n;
89
+ default:
90
+ return;
70
91
  }
71
92
  }
72
- exports.checkTargetOffset = checkTargetOffset;
73
- function isInteger(value) {
74
- return typeof value === "number" && isFinite(value) && Math.floor(value) === value;
93
+ function fmtShort(ms) {
94
+ var msAbs = Math.abs(ms);
95
+ if (msAbs >= d) {
96
+ return Math.round(ms / d) + "d";
97
+ }
98
+ if (msAbs >= h) {
99
+ return Math.round(ms / h) + "h";
100
+ }
101
+ if (msAbs >= m) {
102
+ return Math.round(ms / m) + "m";
103
+ }
104
+ if (msAbs >= s) {
105
+ return Math.round(ms / s) + "s";
106
+ }
107
+ return ms + "ms";
75
108
  }
76
- function bigIntAndBufferInt64Check(bufferMethod) {
77
- if (typeof BigInt === "undefined") {
78
- throw new Error("Platform does not support JS BigInt type.");
109
+ function fmtLong(ms) {
110
+ var msAbs = Math.abs(ms);
111
+ if (msAbs >= d) {
112
+ return plural(ms, msAbs, d, "day");
79
113
  }
80
- if (typeof buffer_1.Buffer.prototype[bufferMethod] === "undefined") {
81
- throw new Error(`Platform does not support Buffer.prototype.${bufferMethod}.`);
114
+ if (msAbs >= h) {
115
+ return plural(ms, msAbs, h, "hour");
116
+ }
117
+ if (msAbs >= m) {
118
+ return plural(ms, msAbs, m, "minute");
119
+ }
120
+ if (msAbs >= s) {
121
+ return plural(ms, msAbs, s, "second");
82
122
  }
123
+ return ms + " ms";
124
+ }
125
+ function plural(ms, msAbs, n, name) {
126
+ var isPlural = msAbs >= n * 1.5;
127
+ return Math.round(ms / n) + " " + name + (isPlural ? "s" : "");
83
128
  }
84
- exports.bigIntAndBufferInt64Check = bigIntAndBufferInt64Check;
85
129
  });
86
130
 
87
- // node_modules/smart-buffer/build/smartbuffer.js
88
- var require_smartbuffer = __commonJS((exports) => {
89
- Object.defineProperty(exports, "__esModule", { value: true });
90
- var utils_1 = require_utils();
91
- var DEFAULT_SMARTBUFFER_SIZE = 4096;
92
- var DEFAULT_SMARTBUFFER_ENCODING = "utf8";
93
-
94
- class SmartBuffer {
95
- constructor(options) {
96
- this.length = 0;
97
- this._encoding = DEFAULT_SMARTBUFFER_ENCODING;
98
- this._writeOffset = 0;
99
- this._readOffset = 0;
100
- if (SmartBuffer.isSmartBufferOptions(options)) {
101
- if (options.encoding) {
102
- utils_1.checkEncoding(options.encoding);
103
- this._encoding = options.encoding;
131
+ // node_modules/debug/src/common.js
132
+ var require_common = __commonJS((exports, module) => {
133
+ function setup(env) {
134
+ createDebug.debug = createDebug;
135
+ createDebug.default = createDebug;
136
+ createDebug.coerce = coerce;
137
+ createDebug.disable = disable;
138
+ createDebug.enable = enable;
139
+ createDebug.enabled = enabled;
140
+ createDebug.humanize = require_ms();
141
+ createDebug.destroy = destroy;
142
+ Object.keys(env).forEach((key) => {
143
+ createDebug[key] = env[key];
144
+ });
145
+ createDebug.names = [];
146
+ createDebug.skips = [];
147
+ createDebug.formatters = {};
148
+ function selectColor(namespace) {
149
+ let hash = 0;
150
+ for (let i = 0;i < namespace.length; i++) {
151
+ hash = (hash << 5) - hash + namespace.charCodeAt(i);
152
+ hash |= 0;
153
+ }
154
+ return createDebug.colors[Math.abs(hash) % createDebug.colors.length];
155
+ }
156
+ createDebug.selectColor = selectColor;
157
+ function createDebug(namespace) {
158
+ let prevTime;
159
+ let enableOverride = null;
160
+ let namespacesCache;
161
+ let enabledCache;
162
+ function debug(...args) {
163
+ if (!debug.enabled) {
164
+ return;
104
165
  }
105
- if (options.size) {
106
- if (utils_1.isFiniteInteger(options.size) && options.size > 0) {
107
- this._buff = Buffer.allocUnsafe(options.size);
108
- } else {
109
- throw new Error(utils_1.ERRORS.INVALID_SMARTBUFFER_SIZE);
166
+ const self2 = debug;
167
+ const curr = Number(new Date);
168
+ const ms = curr - (prevTime || curr);
169
+ self2.diff = ms;
170
+ self2.prev = prevTime;
171
+ self2.curr = curr;
172
+ prevTime = curr;
173
+ args[0] = createDebug.coerce(args[0]);
174
+ if (typeof args[0] !== "string") {
175
+ args.unshift("%O");
176
+ }
177
+ let index = 0;
178
+ args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => {
179
+ if (match === "%%") {
180
+ return "%";
110
181
  }
111
- } else if (options.buff) {
112
- if (Buffer.isBuffer(options.buff)) {
113
- this._buff = options.buff;
114
- this.length = options.buff.length;
115
- } else {
116
- throw new Error(utils_1.ERRORS.INVALID_SMARTBUFFER_BUFFER);
182
+ index++;
183
+ const formatter = createDebug.formatters[format];
184
+ if (typeof formatter === "function") {
185
+ const val = args[index];
186
+ match = formatter.call(self2, val);
187
+ args.splice(index, 1);
188
+ index--;
117
189
  }
118
- } else {
119
- this._buff = Buffer.allocUnsafe(DEFAULT_SMARTBUFFER_SIZE);
120
- }
121
- } else {
122
- if (typeof options !== "undefined") {
123
- throw new Error(utils_1.ERRORS.INVALID_SMARTBUFFER_OBJECT);
124
- }
125
- this._buff = Buffer.allocUnsafe(DEFAULT_SMARTBUFFER_SIZE);
190
+ return match;
191
+ });
192
+ createDebug.formatArgs.call(self2, args);
193
+ const logFn = self2.log || createDebug.log;
194
+ logFn.apply(self2, args);
126
195
  }
127
- }
128
- static fromSize(size, encoding) {
129
- return new this({
130
- size,
131
- encoding
196
+ debug.namespace = namespace;
197
+ debug.useColors = createDebug.useColors();
198
+ debug.color = createDebug.selectColor(namespace);
199
+ debug.extend = extend;
200
+ debug.destroy = createDebug.destroy;
201
+ Object.defineProperty(debug, "enabled", {
202
+ enumerable: true,
203
+ configurable: false,
204
+ get: () => {
205
+ if (enableOverride !== null) {
206
+ return enableOverride;
207
+ }
208
+ if (namespacesCache !== createDebug.namespaces) {
209
+ namespacesCache = createDebug.namespaces;
210
+ enabledCache = createDebug.enabled(namespace);
211
+ }
212
+ return enabledCache;
213
+ },
214
+ set: (v) => {
215
+ enableOverride = v;
216
+ }
132
217
  });
218
+ if (typeof createDebug.init === "function") {
219
+ createDebug.init(debug);
220
+ }
221
+ return debug;
133
222
  }
134
- static fromBuffer(buff, encoding) {
135
- return new this({
136
- buff,
137
- encoding
138
- });
223
+ function extend(namespace, delimiter) {
224
+ const newDebug = createDebug(this.namespace + (typeof delimiter === "undefined" ? ":" : delimiter) + namespace);
225
+ newDebug.log = this.log;
226
+ return newDebug;
139
227
  }
140
- static fromOptions(options) {
141
- return new this(options);
228
+ function enable(namespaces) {
229
+ createDebug.save(namespaces);
230
+ createDebug.namespaces = namespaces;
231
+ createDebug.names = [];
232
+ createDebug.skips = [];
233
+ const split = (typeof namespaces === "string" ? namespaces : "").trim().replace(" ", ",").split(",").filter(Boolean);
234
+ for (const ns of split) {
235
+ if (ns[0] === "-") {
236
+ createDebug.skips.push(ns.slice(1));
237
+ } else {
238
+ createDebug.names.push(ns);
239
+ }
240
+ }
142
241
  }
143
- static isSmartBufferOptions(options) {
144
- const castOptions = options;
145
- return castOptions && (castOptions.encoding !== undefined || castOptions.size !== undefined || castOptions.buff !== undefined);
242
+ function matchesTemplate(search, template) {
243
+ let searchIndex = 0;
244
+ let templateIndex = 0;
245
+ let starIndex = -1;
246
+ let matchIndex = 0;
247
+ while (searchIndex < search.length) {
248
+ if (templateIndex < template.length && (template[templateIndex] === search[searchIndex] || template[templateIndex] === "*")) {
249
+ if (template[templateIndex] === "*") {
250
+ starIndex = templateIndex;
251
+ matchIndex = searchIndex;
252
+ templateIndex++;
253
+ } else {
254
+ searchIndex++;
255
+ templateIndex++;
256
+ }
257
+ } else if (starIndex !== -1) {
258
+ templateIndex = starIndex + 1;
259
+ matchIndex++;
260
+ searchIndex = matchIndex;
261
+ } else {
262
+ return false;
263
+ }
264
+ }
265
+ while (templateIndex < template.length && template[templateIndex] === "*") {
266
+ templateIndex++;
267
+ }
268
+ return templateIndex === template.length;
146
269
  }
147
- readInt8(offset) {
148
- return this._readNumberValue(Buffer.prototype.readInt8, 1, offset);
270
+ function disable() {
271
+ const namespaces = [
272
+ ...createDebug.names,
273
+ ...createDebug.skips.map((namespace) => "-" + namespace)
274
+ ].join(",");
275
+ createDebug.enable("");
276
+ return namespaces;
149
277
  }
150
- readInt16BE(offset) {
151
- return this._readNumberValue(Buffer.prototype.readInt16BE, 2, offset);
278
+ function enabled(name) {
279
+ for (const skip of createDebug.skips) {
280
+ if (matchesTemplate(name, skip)) {
281
+ return false;
282
+ }
283
+ }
284
+ for (const ns of createDebug.names) {
285
+ if (matchesTemplate(name, ns)) {
286
+ return true;
287
+ }
288
+ }
289
+ return false;
152
290
  }
153
- readInt16LE(offset) {
154
- return this._readNumberValue(Buffer.prototype.readInt16LE, 2, offset);
291
+ function coerce(val) {
292
+ if (val instanceof Error) {
293
+ return val.stack || val.message;
294
+ }
295
+ return val;
155
296
  }
156
- readInt32BE(offset) {
157
- return this._readNumberValue(Buffer.prototype.readInt32BE, 4, offset);
297
+ function destroy() {
298
+ console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
158
299
  }
159
- readInt32LE(offset) {
160
- return this._readNumberValue(Buffer.prototype.readInt32LE, 4, offset);
300
+ createDebug.enable(createDebug.load());
301
+ return createDebug;
302
+ }
303
+ module.exports = setup;
304
+ });
305
+
306
+ // node_modules/debug/src/browser.js
307
+ var require_browser = __commonJS((exports, module) => {
308
+ exports.formatArgs = formatArgs;
309
+ exports.save = save;
310
+ exports.load = load;
311
+ exports.useColors = useColors;
312
+ exports.storage = localstorage();
313
+ exports.destroy = (() => {
314
+ let warned = false;
315
+ return () => {
316
+ if (!warned) {
317
+ warned = true;
318
+ console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
319
+ }
320
+ };
321
+ })();
322
+ exports.colors = [
323
+ "#0000CC",
324
+ "#0000FF",
325
+ "#0033CC",
326
+ "#0033FF",
327
+ "#0066CC",
328
+ "#0066FF",
329
+ "#0099CC",
330
+ "#0099FF",
331
+ "#00CC00",
332
+ "#00CC33",
333
+ "#00CC66",
334
+ "#00CC99",
335
+ "#00CCCC",
336
+ "#00CCFF",
337
+ "#3300CC",
338
+ "#3300FF",
339
+ "#3333CC",
340
+ "#3333FF",
341
+ "#3366CC",
342
+ "#3366FF",
343
+ "#3399CC",
344
+ "#3399FF",
345
+ "#33CC00",
346
+ "#33CC33",
347
+ "#33CC66",
348
+ "#33CC99",
349
+ "#33CCCC",
350
+ "#33CCFF",
351
+ "#6600CC",
352
+ "#6600FF",
353
+ "#6633CC",
354
+ "#6633FF",
355
+ "#66CC00",
356
+ "#66CC33",
357
+ "#9900CC",
358
+ "#9900FF",
359
+ "#9933CC",
360
+ "#9933FF",
361
+ "#99CC00",
362
+ "#99CC33",
363
+ "#CC0000",
364
+ "#CC0033",
365
+ "#CC0066",
366
+ "#CC0099",
367
+ "#CC00CC",
368
+ "#CC00FF",
369
+ "#CC3300",
370
+ "#CC3333",
371
+ "#CC3366",
372
+ "#CC3399",
373
+ "#CC33CC",
374
+ "#CC33FF",
375
+ "#CC6600",
376
+ "#CC6633",
377
+ "#CC9900",
378
+ "#CC9933",
379
+ "#CCCC00",
380
+ "#CCCC33",
381
+ "#FF0000",
382
+ "#FF0033",
383
+ "#FF0066",
384
+ "#FF0099",
385
+ "#FF00CC",
386
+ "#FF00FF",
387
+ "#FF3300",
388
+ "#FF3333",
389
+ "#FF3366",
390
+ "#FF3399",
391
+ "#FF33CC",
392
+ "#FF33FF",
393
+ "#FF6600",
394
+ "#FF6633",
395
+ "#FF9900",
396
+ "#FF9933",
397
+ "#FFCC00",
398
+ "#FFCC33"
399
+ ];
400
+ function useColors() {
401
+ if (typeof window !== "undefined" && window.process && (window.process.type === "renderer" || window.process.__nwjs)) {
402
+ return true;
161
403
  }
162
- readBigInt64BE(offset) {
163
- utils_1.bigIntAndBufferInt64Check("readBigInt64BE");
164
- return this._readNumberValue(Buffer.prototype.readBigInt64BE, 8, offset);
404
+ if (typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
405
+ return false;
165
406
  }
166
- readBigInt64LE(offset) {
167
- utils_1.bigIntAndBufferInt64Check("readBigInt64LE");
168
- return this._readNumberValue(Buffer.prototype.readBigInt64LE, 8, offset);
407
+ let m;
408
+ return typeof document !== "undefined" && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance || typeof window !== "undefined" && window.console && (window.console.firebug || window.console.exception && window.console.table) || typeof navigator !== "undefined" && navigator.userAgent && (m = navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)) && parseInt(m[1], 10) >= 31 || typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/);
409
+ }
410
+ function formatArgs(args) {
411
+ args[0] = (this.useColors ? "%c" : "") + this.namespace + (this.useColors ? " %c" : " ") + args[0] + (this.useColors ? "%c " : " ") + "+" + module.exports.humanize(this.diff);
412
+ if (!this.useColors) {
413
+ return;
169
414
  }
170
- writeInt8(value, offset) {
171
- this._writeNumberValue(Buffer.prototype.writeInt8, 1, value, offset);
172
- return this;
415
+ const c = "color: " + this.color;
416
+ args.splice(1, 0, c, "color: inherit");
417
+ let index = 0;
418
+ let lastC = 0;
419
+ args[0].replace(/%[a-zA-Z%]/g, (match) => {
420
+ if (match === "%%") {
421
+ return;
422
+ }
423
+ index++;
424
+ if (match === "%c") {
425
+ lastC = index;
426
+ }
427
+ });
428
+ args.splice(lastC, 0, c);
429
+ }
430
+ exports.log = console.debug || console.log || (() => {
431
+ });
432
+ function save(namespaces) {
433
+ try {
434
+ if (namespaces) {
435
+ exports.storage.setItem("debug", namespaces);
436
+ } else {
437
+ exports.storage.removeItem("debug");
438
+ }
439
+ } catch (error) {
173
440
  }
174
- insertInt8(value, offset) {
175
- return this._insertNumberValue(Buffer.prototype.writeInt8, 1, value, offset);
441
+ }
442
+ function load() {
443
+ let r;
444
+ try {
445
+ r = exports.storage.getItem("debug");
446
+ } catch (error) {
176
447
  }
177
- writeInt16BE(value, offset) {
178
- return this._writeNumberValue(Buffer.prototype.writeInt16BE, 2, value, offset);
448
+ if (!r && typeof process !== "undefined" && "env" in process) {
449
+ r = process.env.DEBUG;
179
450
  }
180
- insertInt16BE(value, offset) {
181
- return this._insertNumberValue(Buffer.prototype.writeInt16BE, 2, value, offset);
451
+ return r;
452
+ }
453
+ function localstorage() {
454
+ try {
455
+ return localStorage;
456
+ } catch (error) {
182
457
  }
183
- writeInt16LE(value, offset) {
184
- return this._writeNumberValue(Buffer.prototype.writeInt16LE, 2, value, offset);
185
- }
186
- insertInt16LE(value, offset) {
187
- return this._insertNumberValue(Buffer.prototype.writeInt16LE, 2, value, offset);
188
- }
189
- writeInt32BE(value, offset) {
190
- return this._writeNumberValue(Buffer.prototype.writeInt32BE, 4, value, offset);
458
+ }
459
+ module.exports = require_common()(exports);
460
+ var { formatters } = module.exports;
461
+ formatters.j = function(v) {
462
+ try {
463
+ return JSON.stringify(v);
464
+ } catch (error) {
465
+ return "[UnexpectedJSONParseError]: " + error.message;
191
466
  }
192
- insertInt32BE(value, offset) {
193
- return this._insertNumberValue(Buffer.prototype.writeInt32BE, 4, value, offset);
467
+ };
468
+ });
469
+
470
+ // node_modules/has-flag/index.js
471
+ var require_has_flag = __commonJS((exports, module) => {
472
+ module.exports = (flag, argv = process.argv) => {
473
+ const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
474
+ const position = argv.indexOf(prefix + flag);
475
+ const terminatorPosition = argv.indexOf("--");
476
+ return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
477
+ };
478
+ });
479
+
480
+ // node_modules/supports-color/index.js
481
+ var require_supports_color = __commonJS((exports, module) => {
482
+ var os = __require("os");
483
+ var tty = __require("tty");
484
+ var hasFlag = require_has_flag();
485
+ var { env } = process;
486
+ var forceColor;
487
+ if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) {
488
+ forceColor = 0;
489
+ } else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) {
490
+ forceColor = 1;
491
+ }
492
+ if ("FORCE_COLOR" in env) {
493
+ if (env.FORCE_COLOR === "true") {
494
+ forceColor = 1;
495
+ } else if (env.FORCE_COLOR === "false") {
496
+ forceColor = 0;
497
+ } else {
498
+ forceColor = env.FORCE_COLOR.length === 0 ? 1 : Math.min(parseInt(env.FORCE_COLOR, 10), 3);
194
499
  }
195
- writeInt32LE(value, offset) {
196
- return this._writeNumberValue(Buffer.prototype.writeInt32LE, 4, value, offset);
500
+ }
501
+ function translateLevel(level) {
502
+ if (level === 0) {
503
+ return false;
197
504
  }
198
- insertInt32LE(value, offset) {
199
- return this._insertNumberValue(Buffer.prototype.writeInt32LE, 4, value, offset);
505
+ return {
506
+ level,
507
+ hasBasic: true,
508
+ has256: level >= 2,
509
+ has16m: level >= 3
510
+ };
511
+ }
512
+ function supportsColor(haveStream, streamIsTTY) {
513
+ if (forceColor === 0) {
514
+ return 0;
200
515
  }
201
- writeBigInt64BE(value, offset) {
202
- utils_1.bigIntAndBufferInt64Check("writeBigInt64BE");
203
- return this._writeNumberValue(Buffer.prototype.writeBigInt64BE, 8, value, offset);
516
+ if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor")) {
517
+ return 3;
204
518
  }
205
- insertBigInt64BE(value, offset) {
206
- utils_1.bigIntAndBufferInt64Check("writeBigInt64BE");
207
- return this._insertNumberValue(Buffer.prototype.writeBigInt64BE, 8, value, offset);
519
+ if (hasFlag("color=256")) {
520
+ return 2;
208
521
  }
209
- writeBigInt64LE(value, offset) {
210
- utils_1.bigIntAndBufferInt64Check("writeBigInt64LE");
211
- return this._writeNumberValue(Buffer.prototype.writeBigInt64LE, 8, value, offset);
522
+ if (haveStream && !streamIsTTY && forceColor === undefined) {
523
+ return 0;
212
524
  }
213
- insertBigInt64LE(value, offset) {
214
- utils_1.bigIntAndBufferInt64Check("writeBigInt64LE");
215
- return this._insertNumberValue(Buffer.prototype.writeBigInt64LE, 8, value, offset);
525
+ const min = forceColor || 0;
526
+ if (env.TERM === "dumb") {
527
+ return min;
216
528
  }
217
- readUInt8(offset) {
218
- return this._readNumberValue(Buffer.prototype.readUInt8, 1, offset);
529
+ if (process.platform === "win32") {
530
+ const osRelease = os.release().split(".");
531
+ if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
532
+ return Number(osRelease[2]) >= 14931 ? 3 : 2;
533
+ }
534
+ return 1;
219
535
  }
220
- readUInt16BE(offset) {
221
- return this._readNumberValue(Buffer.prototype.readUInt16BE, 2, offset);
536
+ if ("CI" in env) {
537
+ if (["TRAVIS", "CIRCLECI", "APPVEYOR", "GITLAB_CI", "GITHUB_ACTIONS", "BUILDKITE"].some((sign) => (sign in env)) || env.CI_NAME === "codeship") {
538
+ return 1;
539
+ }
540
+ return min;
222
541
  }
223
- readUInt16LE(offset) {
224
- return this._readNumberValue(Buffer.prototype.readUInt16LE, 2, offset);
542
+ if ("TEAMCITY_VERSION" in env) {
543
+ return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
225
544
  }
226
- readUInt32BE(offset) {
227
- return this._readNumberValue(Buffer.prototype.readUInt32BE, 4, offset);
545
+ if (env.COLORTERM === "truecolor") {
546
+ return 3;
228
547
  }
229
- readUInt32LE(offset) {
230
- return this._readNumberValue(Buffer.prototype.readUInt32LE, 4, offset);
548
+ if ("TERM_PROGRAM" in env) {
549
+ const version = parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
550
+ switch (env.TERM_PROGRAM) {
551
+ case "iTerm.app":
552
+ return version >= 3 ? 3 : 2;
553
+ case "Apple_Terminal":
554
+ return 2;
555
+ }
231
556
  }
232
- readBigUInt64BE(offset) {
233
- utils_1.bigIntAndBufferInt64Check("readBigUInt64BE");
234
- return this._readNumberValue(Buffer.prototype.readBigUInt64BE, 8, offset);
557
+ if (/-256(color)?$/i.test(env.TERM)) {
558
+ return 2;
235
559
  }
236
- readBigUInt64LE(offset) {
237
- utils_1.bigIntAndBufferInt64Check("readBigUInt64LE");
238
- return this._readNumberValue(Buffer.prototype.readBigUInt64LE, 8, offset);
560
+ if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
561
+ return 1;
239
562
  }
240
- writeUInt8(value, offset) {
241
- return this._writeNumberValue(Buffer.prototype.writeUInt8, 1, value, offset);
563
+ if ("COLORTERM" in env) {
564
+ return 1;
242
565
  }
243
- insertUInt8(value, offset) {
244
- return this._insertNumberValue(Buffer.prototype.writeUInt8, 1, value, offset);
566
+ return min;
567
+ }
568
+ function getSupportLevel(stream) {
569
+ const level = supportsColor(stream, stream && stream.isTTY);
570
+ return translateLevel(level);
571
+ }
572
+ module.exports = {
573
+ supportsColor: getSupportLevel,
574
+ stdout: translateLevel(supportsColor(true, tty.isatty(1))),
575
+ stderr: translateLevel(supportsColor(true, tty.isatty(2)))
576
+ };
577
+ });
578
+
579
+ // node_modules/debug/src/node.js
580
+ var require_node = __commonJS((exports, module) => {
581
+ var tty = __require("tty");
582
+ var util = __require("util");
583
+ exports.init = init;
584
+ exports.log = log;
585
+ exports.formatArgs = formatArgs;
586
+ exports.save = save;
587
+ exports.load = load;
588
+ exports.useColors = useColors;
589
+ exports.destroy = util.deprecate(() => {
590
+ }, "Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
591
+ exports.colors = [6, 2, 3, 4, 5, 1];
592
+ try {
593
+ const supportsColor = require_supports_color();
594
+ if (supportsColor && (supportsColor.stderr || supportsColor).level >= 2) {
595
+ exports.colors = [
596
+ 20,
597
+ 21,
598
+ 26,
599
+ 27,
600
+ 32,
601
+ 33,
602
+ 38,
603
+ 39,
604
+ 40,
605
+ 41,
606
+ 42,
607
+ 43,
608
+ 44,
609
+ 45,
610
+ 56,
611
+ 57,
612
+ 62,
613
+ 63,
614
+ 68,
615
+ 69,
616
+ 74,
617
+ 75,
618
+ 76,
619
+ 77,
620
+ 78,
621
+ 79,
622
+ 80,
623
+ 81,
624
+ 92,
625
+ 93,
626
+ 98,
627
+ 99,
628
+ 112,
629
+ 113,
630
+ 128,
631
+ 129,
632
+ 134,
633
+ 135,
634
+ 148,
635
+ 149,
636
+ 160,
637
+ 161,
638
+ 162,
639
+ 163,
640
+ 164,
641
+ 165,
642
+ 166,
643
+ 167,
644
+ 168,
645
+ 169,
646
+ 170,
647
+ 171,
648
+ 172,
649
+ 173,
650
+ 178,
651
+ 179,
652
+ 184,
653
+ 185,
654
+ 196,
655
+ 197,
656
+ 198,
657
+ 199,
658
+ 200,
659
+ 201,
660
+ 202,
661
+ 203,
662
+ 204,
663
+ 205,
664
+ 206,
665
+ 207,
666
+ 208,
667
+ 209,
668
+ 214,
669
+ 215,
670
+ 220,
671
+ 221
672
+ ];
245
673
  }
246
- writeUInt16BE(value, offset) {
247
- return this._writeNumberValue(Buffer.prototype.writeUInt16BE, 2, value, offset);
674
+ } catch (error) {
675
+ }
676
+ exports.inspectOpts = Object.keys(process.env).filter((key) => {
677
+ return /^debug_/i.test(key);
678
+ }).reduce((obj, key) => {
679
+ const prop = key.substring(6).toLowerCase().replace(/_([a-z])/g, (_, k) => {
680
+ return k.toUpperCase();
681
+ });
682
+ let val = process.env[key];
683
+ if (/^(yes|on|true|enabled)$/i.test(val)) {
684
+ val = true;
685
+ } else if (/^(no|off|false|disabled)$/i.test(val)) {
686
+ val = false;
687
+ } else if (val === "null") {
688
+ val = null;
689
+ } else {
690
+ val = Number(val);
248
691
  }
249
- insertUInt16BE(value, offset) {
250
- return this._insertNumberValue(Buffer.prototype.writeUInt16BE, 2, value, offset);
692
+ obj[prop] = val;
693
+ return obj;
694
+ }, {});
695
+ function useColors() {
696
+ return "colors" in exports.inspectOpts ? Boolean(exports.inspectOpts.colors) : tty.isatty(process.stderr.fd);
697
+ }
698
+ function formatArgs(args) {
699
+ const { namespace: name, useColors: useColors2 } = this;
700
+ if (useColors2) {
701
+ const c = this.color;
702
+ const colorCode = "\x1B[3" + (c < 8 ? c : "8;5;" + c);
703
+ const prefix = ` ${colorCode};1m${name} \x1B[0m`;
704
+ args[0] = prefix + args[0].split(`
705
+ `).join(`
706
+ ` + prefix);
707
+ args.push(colorCode + "m+" + module.exports.humanize(this.diff) + "\x1B[0m");
708
+ } else {
709
+ args[0] = getDate() + name + " " + args[0];
251
710
  }
252
- writeUInt16LE(value, offset) {
253
- return this._writeNumberValue(Buffer.prototype.writeUInt16LE, 2, value, offset);
711
+ }
712
+ function getDate() {
713
+ if (exports.inspectOpts.hideDate) {
714
+ return "";
254
715
  }
255
- insertUInt16LE(value, offset) {
256
- return this._insertNumberValue(Buffer.prototype.writeUInt16LE, 2, value, offset);
716
+ return new Date().toISOString() + " ";
717
+ }
718
+ function log(...args) {
719
+ return process.stderr.write(util.formatWithOptions(exports.inspectOpts, ...args) + `
720
+ `);
721
+ }
722
+ function save(namespaces) {
723
+ if (namespaces) {
724
+ process.env.DEBUG = namespaces;
725
+ } else {
726
+ delete process.env.DEBUG;
257
727
  }
258
- writeUInt32BE(value, offset) {
259
- return this._writeNumberValue(Buffer.prototype.writeUInt32BE, 4, value, offset);
728
+ }
729
+ function load() {
730
+ return process.env.DEBUG;
731
+ }
732
+ function init(debug) {
733
+ debug.inspectOpts = {};
734
+ const keys = Object.keys(exports.inspectOpts);
735
+ for (let i = 0;i < keys.length; i++) {
736
+ debug.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]];
260
737
  }
261
- insertUInt32BE(value, offset) {
262
- return this._insertNumberValue(Buffer.prototype.writeUInt32BE, 4, value, offset);
738
+ }
739
+ module.exports = require_common()(exports);
740
+ var { formatters } = module.exports;
741
+ formatters.o = function(v) {
742
+ this.inspectOpts.colors = this.useColors;
743
+ return util.inspect(v, this.inspectOpts).split(`
744
+ `).map((str) => str.trim()).join(" ");
745
+ };
746
+ formatters.O = function(v) {
747
+ this.inspectOpts.colors = this.useColors;
748
+ return util.inspect(v, this.inspectOpts);
749
+ };
750
+ });
751
+
752
+ // node_modules/debug/src/index.js
753
+ var require_src = __commonJS((exports, module) => {
754
+ if (typeof process === "undefined" || process.type === "renderer" || false || process.__nwjs) {
755
+ module.exports = require_browser();
756
+ } else {
757
+ module.exports = require_node();
758
+ }
759
+ });
760
+
761
+ // node_modules/agent-base/dist/helpers.js
762
+ var require_helpers = __commonJS((exports) => {
763
+ var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
764
+ if (k2 === undefined)
765
+ k2 = k;
766
+ var desc = Object.getOwnPropertyDescriptor(m, k);
767
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
768
+ desc = { enumerable: true, get: function() {
769
+ return m[k];
770
+ } };
263
771
  }
264
- writeUInt32LE(value, offset) {
265
- return this._writeNumberValue(Buffer.prototype.writeUInt32LE, 4, value, offset);
772
+ Object.defineProperty(o, k2, desc);
773
+ } : function(o, m, k, k2) {
774
+ if (k2 === undefined)
775
+ k2 = k;
776
+ o[k2] = m[k];
777
+ });
778
+ var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? function(o, v) {
779
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
780
+ } : function(o, v) {
781
+ o["default"] = v;
782
+ });
783
+ var __importStar = exports && exports.__importStar || function(mod) {
784
+ if (mod && mod.__esModule)
785
+ return mod;
786
+ var result = {};
787
+ if (mod != null) {
788
+ for (var k in mod)
789
+ if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
790
+ __createBinding(result, mod, k);
266
791
  }
267
- insertUInt32LE(value, offset) {
268
- return this._insertNumberValue(Buffer.prototype.writeUInt32LE, 4, value, offset);
792
+ __setModuleDefault(result, mod);
793
+ return result;
794
+ };
795
+ Object.defineProperty(exports, "__esModule", { value: true });
796
+ exports.req = exports.json = exports.toBuffer = undefined;
797
+ var http = __importStar(__require("http"));
798
+ var https = __importStar(__require("https"));
799
+ async function toBuffer(stream) {
800
+ let length = 0;
801
+ const chunks = [];
802
+ for await (const chunk of stream) {
803
+ length += chunk.length;
804
+ chunks.push(chunk);
269
805
  }
270
- writeBigUInt64BE(value, offset) {
271
- utils_1.bigIntAndBufferInt64Check("writeBigUInt64BE");
272
- return this._writeNumberValue(Buffer.prototype.writeBigUInt64BE, 8, value, offset);
806
+ return Buffer.concat(chunks, length);
807
+ }
808
+ exports.toBuffer = toBuffer;
809
+ async function json(stream) {
810
+ const buf = await toBuffer(stream);
811
+ const str = buf.toString("utf8");
812
+ try {
813
+ return JSON.parse(str);
814
+ } catch (_err) {
815
+ const err = _err;
816
+ err.message += ` (input: ${str})`;
817
+ throw err;
273
818
  }
274
- insertBigUInt64BE(value, offset) {
275
- utils_1.bigIntAndBufferInt64Check("writeBigUInt64BE");
276
- return this._insertNumberValue(Buffer.prototype.writeBigUInt64BE, 8, value, offset);
819
+ }
820
+ exports.json = json;
821
+ function req(url, opts = {}) {
822
+ const href = typeof url === "string" ? url : url.href;
823
+ const req2 = (href.startsWith("https:") ? https : http).request(url, opts);
824
+ const promise = new Promise((resolve, reject) => {
825
+ req2.once("response", resolve).once("error", reject).end();
826
+ });
827
+ req2.then = promise.then.bind(promise);
828
+ return req2;
829
+ }
830
+ exports.req = req;
831
+ });
832
+
833
+ // node_modules/agent-base/dist/index.js
834
+ var require_dist = __commonJS((exports) => {
835
+ var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
836
+ if (k2 === undefined)
837
+ k2 = k;
838
+ var desc = Object.getOwnPropertyDescriptor(m, k);
839
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
840
+ desc = { enumerable: true, get: function() {
841
+ return m[k];
842
+ } };
277
843
  }
278
- writeBigUInt64LE(value, offset) {
279
- utils_1.bigIntAndBufferInt64Check("writeBigUInt64LE");
280
- return this._writeNumberValue(Buffer.prototype.writeBigUInt64LE, 8, value, offset);
844
+ Object.defineProperty(o, k2, desc);
845
+ } : function(o, m, k, k2) {
846
+ if (k2 === undefined)
847
+ k2 = k;
848
+ o[k2] = m[k];
849
+ });
850
+ var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? function(o, v) {
851
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
852
+ } : function(o, v) {
853
+ o["default"] = v;
854
+ });
855
+ var __importStar = exports && exports.__importStar || function(mod) {
856
+ if (mod && mod.__esModule)
857
+ return mod;
858
+ var result = {};
859
+ if (mod != null) {
860
+ for (var k in mod)
861
+ if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
862
+ __createBinding(result, mod, k);
281
863
  }
282
- insertBigUInt64LE(value, offset) {
283
- utils_1.bigIntAndBufferInt64Check("writeBigUInt64LE");
284
- return this._insertNumberValue(Buffer.prototype.writeBigUInt64LE, 8, value, offset);
864
+ __setModuleDefault(result, mod);
865
+ return result;
866
+ };
867
+ var __exportStar = exports && exports.__exportStar || function(m, exports2) {
868
+ for (var p in m)
869
+ if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports2, p))
870
+ __createBinding(exports2, m, p);
871
+ };
872
+ Object.defineProperty(exports, "__esModule", { value: true });
873
+ exports.Agent = undefined;
874
+ var net = __importStar(__require("net"));
875
+ var http = __importStar(__require("http"));
876
+ var https_1 = __require("https");
877
+ __exportStar(require_helpers(), exports);
878
+ var INTERNAL = Symbol("AgentBaseInternalState");
879
+
880
+ class Agent extends http.Agent {
881
+ constructor(opts) {
882
+ super(opts);
883
+ this[INTERNAL] = {};
285
884
  }
286
- readFloatBE(offset) {
287
- return this._readNumberValue(Buffer.prototype.readFloatBE, 4, offset);
885
+ isSecureEndpoint(options) {
886
+ if (options) {
887
+ if (typeof options.secureEndpoint === "boolean") {
888
+ return options.secureEndpoint;
889
+ }
890
+ if (typeof options.protocol === "string") {
891
+ return options.protocol === "https:";
892
+ }
893
+ }
894
+ const { stack } = new Error;
895
+ if (typeof stack !== "string")
896
+ return false;
897
+ return stack.split(`
898
+ `).some((l) => l.indexOf("(https.js:") !== -1 || l.indexOf("node:https:") !== -1);
288
899
  }
289
- readFloatLE(offset) {
290
- return this._readNumberValue(Buffer.prototype.readFloatLE, 4, offset);
900
+ incrementSockets(name) {
901
+ if (this.maxSockets === Infinity && this.maxTotalSockets === Infinity) {
902
+ return null;
903
+ }
904
+ if (!this.sockets[name]) {
905
+ this.sockets[name] = [];
906
+ }
907
+ const fakeSocket = new net.Socket({ writable: false });
908
+ this.sockets[name].push(fakeSocket);
909
+ this.totalSocketCount++;
910
+ return fakeSocket;
291
911
  }
292
- writeFloatBE(value, offset) {
293
- return this._writeNumberValue(Buffer.prototype.writeFloatBE, 4, value, offset);
912
+ decrementSockets(name, socket) {
913
+ if (!this.sockets[name] || socket === null) {
914
+ return;
915
+ }
916
+ const sockets = this.sockets[name];
917
+ const index = sockets.indexOf(socket);
918
+ if (index !== -1) {
919
+ sockets.splice(index, 1);
920
+ this.totalSocketCount--;
921
+ if (sockets.length === 0) {
922
+ delete this.sockets[name];
923
+ }
924
+ }
294
925
  }
295
- insertFloatBE(value, offset) {
296
- return this._insertNumberValue(Buffer.prototype.writeFloatBE, 4, value, offset);
297
- }
298
- writeFloatLE(value, offset) {
299
- return this._writeNumberValue(Buffer.prototype.writeFloatLE, 4, value, offset);
300
- }
301
- insertFloatLE(value, offset) {
302
- return this._insertNumberValue(Buffer.prototype.writeFloatLE, 4, value, offset);
926
+ getName(options) {
927
+ const secureEndpoint = typeof options.secureEndpoint === "boolean" ? options.secureEndpoint : this.isSecureEndpoint(options);
928
+ if (secureEndpoint) {
929
+ return https_1.Agent.prototype.getName.call(this, options);
930
+ }
931
+ return super.getName(options);
303
932
  }
304
- readDoubleBE(offset) {
305
- return this._readNumberValue(Buffer.prototype.readDoubleBE, 8, offset);
933
+ createSocket(req, options, cb) {
934
+ const connectOpts = {
935
+ ...options,
936
+ secureEndpoint: this.isSecureEndpoint(options)
937
+ };
938
+ const name = this.getName(connectOpts);
939
+ const fakeSocket = this.incrementSockets(name);
940
+ Promise.resolve().then(() => this.connect(req, connectOpts)).then((socket) => {
941
+ this.decrementSockets(name, fakeSocket);
942
+ if (socket instanceof http.Agent) {
943
+ try {
944
+ return socket.addRequest(req, connectOpts);
945
+ } catch (err) {
946
+ return cb(err);
947
+ }
948
+ }
949
+ this[INTERNAL].currentSocket = socket;
950
+ super.createSocket(req, options, cb);
951
+ }, (err) => {
952
+ this.decrementSockets(name, fakeSocket);
953
+ cb(err);
954
+ });
306
955
  }
307
- readDoubleLE(offset) {
308
- return this._readNumberValue(Buffer.prototype.readDoubleLE, 8, offset);
956
+ createConnection() {
957
+ const socket = this[INTERNAL].currentSocket;
958
+ this[INTERNAL].currentSocket = undefined;
959
+ if (!socket) {
960
+ throw new Error("No socket was returned in the `connect()` function");
961
+ }
962
+ return socket;
309
963
  }
310
- writeDoubleBE(value, offset) {
311
- return this._writeNumberValue(Buffer.prototype.writeDoubleBE, 8, value, offset);
964
+ get defaultPort() {
965
+ return this[INTERNAL].defaultPort ?? (this.protocol === "https:" ? 443 : 80);
312
966
  }
313
- insertDoubleBE(value, offset) {
314
- return this._insertNumberValue(Buffer.prototype.writeDoubleBE, 8, value, offset);
967
+ set defaultPort(v) {
968
+ if (this[INTERNAL]) {
969
+ this[INTERNAL].defaultPort = v;
970
+ }
315
971
  }
316
- writeDoubleLE(value, offset) {
317
- return this._writeNumberValue(Buffer.prototype.writeDoubleLE, 8, value, offset);
972
+ get protocol() {
973
+ return this[INTERNAL].protocol ?? (this.isSecureEndpoint() ? "https:" : "http:");
318
974
  }
319
- insertDoubleLE(value, offset) {
320
- return this._insertNumberValue(Buffer.prototype.writeDoubleLE, 8, value, offset);
975
+ set protocol(v) {
976
+ if (this[INTERNAL]) {
977
+ this[INTERNAL].protocol = v;
978
+ }
321
979
  }
322
- readString(arg1, encoding) {
323
- let lengthVal;
324
- if (typeof arg1 === "number") {
325
- utils_1.checkLengthValue(arg1);
326
- lengthVal = Math.min(arg1, this.length - this._readOffset);
327
- } else {
328
- encoding = arg1;
329
- lengthVal = this.length - this._readOffset;
980
+ }
981
+ exports.Agent = Agent;
982
+ });
983
+
984
+ // node_modules/https-proxy-agent/dist/parse-proxy-response.js
985
+ var require_parse_proxy_response = __commonJS((exports) => {
986
+ var __importDefault = exports && exports.__importDefault || function(mod) {
987
+ return mod && mod.__esModule ? mod : { default: mod };
988
+ };
989
+ Object.defineProperty(exports, "__esModule", { value: true });
990
+ exports.parseProxyResponse = undefined;
991
+ var debug_1 = __importDefault(require_src());
992
+ var debug = (0, debug_1.default)("https-proxy-agent:parse-proxy-response");
993
+ function parseProxyResponse(socket) {
994
+ return new Promise((resolve, reject) => {
995
+ let buffersLength = 0;
996
+ const buffers = [];
997
+ function read() {
998
+ const b = socket.read();
999
+ if (b)
1000
+ ondata(b);
1001
+ else
1002
+ socket.once("readable", read);
330
1003
  }
331
- if (typeof encoding !== "undefined") {
332
- utils_1.checkEncoding(encoding);
1004
+ function cleanup() {
1005
+ socket.removeListener("end", onend);
1006
+ socket.removeListener("error", onerror);
1007
+ socket.removeListener("readable", read);
333
1008
  }
334
- const value = this._buff.slice(this._readOffset, this._readOffset + lengthVal).toString(encoding || this._encoding);
335
- this._readOffset += lengthVal;
336
- return value;
337
- }
338
- insertString(value, offset, encoding) {
339
- utils_1.checkOffsetValue(offset);
340
- return this._handleString(value, true, offset, encoding);
341
- }
342
- writeString(value, arg2, encoding) {
343
- return this._handleString(value, false, arg2, encoding);
344
- }
345
- readStringNT(encoding) {
346
- if (typeof encoding !== "undefined") {
347
- utils_1.checkEncoding(encoding);
1009
+ function onend() {
1010
+ cleanup();
1011
+ debug("onend");
1012
+ reject(new Error("Proxy connection ended before receiving CONNECT response"));
348
1013
  }
349
- let nullPos = this.length;
350
- for (let i2 = this._readOffset;i2 < this.length; i2++) {
351
- if (this._buff[i2] === 0) {
352
- nullPos = i2;
353
- break;
1014
+ function onerror(err) {
1015
+ cleanup();
1016
+ debug("onerror %o", err);
1017
+ reject(err);
1018
+ }
1019
+ function ondata(b) {
1020
+ buffers.push(b);
1021
+ buffersLength += b.length;
1022
+ const buffered = Buffer.concat(buffers, buffersLength);
1023
+ const endOfHeaders = buffered.indexOf(`\r
1024
+ \r
1025
+ `);
1026
+ if (endOfHeaders === -1) {
1027
+ debug("have not received end of HTTP headers yet...");
1028
+ read();
1029
+ return;
1030
+ }
1031
+ const headerParts = buffered.slice(0, endOfHeaders).toString("ascii").split(`\r
1032
+ `);
1033
+ const firstLine = headerParts.shift();
1034
+ if (!firstLine) {
1035
+ socket.destroy();
1036
+ return reject(new Error("No header received from proxy CONNECT response"));
1037
+ }
1038
+ const firstLineParts = firstLine.split(" ");
1039
+ const statusCode = +firstLineParts[1];
1040
+ const statusText = firstLineParts.slice(2).join(" ");
1041
+ const headers = {};
1042
+ for (const header of headerParts) {
1043
+ if (!header)
1044
+ continue;
1045
+ const firstColon = header.indexOf(":");
1046
+ if (firstColon === -1) {
1047
+ socket.destroy();
1048
+ return reject(new Error(`Invalid header from proxy CONNECT response: "${header}"`));
1049
+ }
1050
+ const key = header.slice(0, firstColon).toLowerCase();
1051
+ const value = header.slice(firstColon + 1).trimStart();
1052
+ const current = headers[key];
1053
+ if (typeof current === "string") {
1054
+ headers[key] = [current, value];
1055
+ } else if (Array.isArray(current)) {
1056
+ current.push(value);
1057
+ } else {
1058
+ headers[key] = value;
1059
+ }
354
1060
  }
1061
+ debug("got proxy server response: %o %o", firstLine, headers);
1062
+ cleanup();
1063
+ resolve({
1064
+ connect: {
1065
+ statusCode,
1066
+ statusText,
1067
+ headers
1068
+ },
1069
+ buffered
1070
+ });
355
1071
  }
356
- const value = this._buff.slice(this._readOffset, nullPos);
357
- this._readOffset = nullPos + 1;
358
- return value.toString(encoding || this._encoding);
1072
+ socket.on("error", onerror);
1073
+ socket.on("end", onend);
1074
+ read();
1075
+ });
1076
+ }
1077
+ exports.parseProxyResponse = parseProxyResponse;
1078
+ });
1079
+
1080
+ // node_modules/https-proxy-agent/dist/index.js
1081
+ var require_dist2 = __commonJS((exports) => {
1082
+ var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
1083
+ if (k2 === undefined)
1084
+ k2 = k;
1085
+ var desc = Object.getOwnPropertyDescriptor(m, k);
1086
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
1087
+ desc = { enumerable: true, get: function() {
1088
+ return m[k];
1089
+ } };
359
1090
  }
360
- insertStringNT(value, offset, encoding) {
361
- utils_1.checkOffsetValue(offset);
362
- this.insertString(value, offset, encoding);
363
- this.insertUInt8(0, offset + value.length);
364
- return this;
1091
+ Object.defineProperty(o, k2, desc);
1092
+ } : function(o, m, k, k2) {
1093
+ if (k2 === undefined)
1094
+ k2 = k;
1095
+ o[k2] = m[k];
1096
+ });
1097
+ var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? function(o, v) {
1098
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
1099
+ } : function(o, v) {
1100
+ o["default"] = v;
1101
+ });
1102
+ var __importStar = exports && exports.__importStar || function(mod) {
1103
+ if (mod && mod.__esModule)
1104
+ return mod;
1105
+ var result = {};
1106
+ if (mod != null) {
1107
+ for (var k in mod)
1108
+ if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
1109
+ __createBinding(result, mod, k);
365
1110
  }
366
- writeStringNT(value, arg2, encoding) {
367
- this.writeString(value, arg2, encoding);
368
- this.writeUInt8(0, typeof arg2 === "number" ? arg2 + value.length : this.writeOffset);
369
- return this;
1111
+ __setModuleDefault(result, mod);
1112
+ return result;
1113
+ };
1114
+ var __importDefault = exports && exports.__importDefault || function(mod) {
1115
+ return mod && mod.__esModule ? mod : { default: mod };
1116
+ };
1117
+ Object.defineProperty(exports, "__esModule", { value: true });
1118
+ exports.HttpsProxyAgent = undefined;
1119
+ var net = __importStar(__require("net"));
1120
+ var tls = __importStar(__require("tls"));
1121
+ var assert_1 = __importDefault(__require("assert"));
1122
+ var debug_1 = __importDefault(require_src());
1123
+ var agent_base_1 = require_dist();
1124
+ var url_1 = __require("url");
1125
+ var parse_proxy_response_1 = require_parse_proxy_response();
1126
+ var debug = (0, debug_1.default)("https-proxy-agent");
1127
+ var setServernameFromNonIpHost = (options) => {
1128
+ if (options.servername === undefined && options.host && !net.isIP(options.host)) {
1129
+ return {
1130
+ ...options,
1131
+ servername: options.host
1132
+ };
370
1133
  }
371
- readBuffer(length) {
372
- if (typeof length !== "undefined") {
373
- utils_1.checkLengthValue(length);
1134
+ return options;
1135
+ };
1136
+
1137
+ class HttpsProxyAgent extends agent_base_1.Agent {
1138
+ constructor(proxy, opts) {
1139
+ super(opts);
1140
+ this.options = { path: undefined };
1141
+ this.proxy = typeof proxy === "string" ? new url_1.URL(proxy) : proxy;
1142
+ this.proxyHeaders = opts?.headers ?? {};
1143
+ debug("Creating new HttpsProxyAgent instance: %o", this.proxy.href);
1144
+ const host = (this.proxy.hostname || this.proxy.host).replace(/^\[|\]$/g, "");
1145
+ const port = this.proxy.port ? parseInt(this.proxy.port, 10) : this.proxy.protocol === "https:" ? 443 : 80;
1146
+ this.connectOpts = {
1147
+ ALPNProtocols: ["http/1.1"],
1148
+ ...opts ? omit(opts, "headers") : null,
1149
+ host,
1150
+ port
1151
+ };
1152
+ }
1153
+ async connect(req, opts) {
1154
+ const { proxy } = this;
1155
+ if (!opts.host) {
1156
+ throw new TypeError('No "host" provided');
374
1157
  }
375
- const lengthVal = typeof length === "number" ? length : this.length;
376
- const endPoint = Math.min(this.length, this._readOffset + lengthVal);
377
- const value = this._buff.slice(this._readOffset, endPoint);
378
- this._readOffset = endPoint;
379
- return value;
1158
+ let socket;
1159
+ if (proxy.protocol === "https:") {
1160
+ debug("Creating `tls.Socket`: %o", this.connectOpts);
1161
+ socket = tls.connect(setServernameFromNonIpHost(this.connectOpts));
1162
+ } else {
1163
+ debug("Creating `net.Socket`: %o", this.connectOpts);
1164
+ socket = net.connect(this.connectOpts);
1165
+ }
1166
+ const headers = typeof this.proxyHeaders === "function" ? this.proxyHeaders() : { ...this.proxyHeaders };
1167
+ const host = net.isIPv6(opts.host) ? `[${opts.host}]` : opts.host;
1168
+ let payload = `CONNECT ${host}:${opts.port} HTTP/1.1\r
1169
+ `;
1170
+ if (proxy.username || proxy.password) {
1171
+ const auth = `${decodeURIComponent(proxy.username)}:${decodeURIComponent(proxy.password)}`;
1172
+ headers["Proxy-Authorization"] = `Basic ${Buffer.from(auth).toString("base64")}`;
1173
+ }
1174
+ headers.Host = `${host}:${opts.port}`;
1175
+ if (!headers["Proxy-Connection"]) {
1176
+ headers["Proxy-Connection"] = this.keepAlive ? "Keep-Alive" : "close";
1177
+ }
1178
+ for (const name of Object.keys(headers)) {
1179
+ payload += `${name}: ${headers[name]}\r
1180
+ `;
1181
+ }
1182
+ const proxyResponsePromise = (0, parse_proxy_response_1.parseProxyResponse)(socket);
1183
+ socket.write(`${payload}\r
1184
+ `);
1185
+ const { connect, buffered } = await proxyResponsePromise;
1186
+ req.emit("proxyConnect", connect);
1187
+ this.emit("proxyConnect", connect, req);
1188
+ if (connect.statusCode === 200) {
1189
+ req.once("socket", resume);
1190
+ if (opts.secureEndpoint) {
1191
+ debug("Upgrading socket connection to TLS");
1192
+ return tls.connect({
1193
+ ...omit(setServernameFromNonIpHost(opts), "host", "path", "port"),
1194
+ socket
1195
+ });
1196
+ }
1197
+ return socket;
1198
+ }
1199
+ socket.destroy();
1200
+ const fakeSocket = new net.Socket({ writable: false });
1201
+ fakeSocket.readable = true;
1202
+ req.once("socket", (s) => {
1203
+ debug("Replaying proxy buffer for failed request");
1204
+ (0, assert_1.default)(s.listenerCount("data") > 0);
1205
+ s.push(buffered);
1206
+ s.push(null);
1207
+ });
1208
+ return fakeSocket;
380
1209
  }
381
- insertBuffer(value, offset) {
382
- utils_1.checkOffsetValue(offset);
383
- return this._handleBuffer(value, true, offset);
1210
+ }
1211
+ HttpsProxyAgent.protocols = ["http", "https"];
1212
+ exports.HttpsProxyAgent = HttpsProxyAgent;
1213
+ function resume(socket) {
1214
+ socket.resume();
1215
+ }
1216
+ function omit(obj, ...keys) {
1217
+ const ret = {};
1218
+ let key;
1219
+ for (key in obj) {
1220
+ if (!keys.includes(key)) {
1221
+ ret[key] = obj[key];
1222
+ }
384
1223
  }
385
- writeBuffer(value, offset) {
386
- return this._handleBuffer(value, false, offset);
1224
+ return ret;
1225
+ }
1226
+ });
1227
+
1228
+ // node_modules/smart-buffer/build/utils.js
1229
+ var require_utils = __commonJS((exports) => {
1230
+ Object.defineProperty(exports, "__esModule", { value: true });
1231
+ var buffer_1 = __require("buffer");
1232
+ var ERRORS = {
1233
+ INVALID_ENCODING: "Invalid encoding provided. Please specify a valid encoding the internal Node.js Buffer supports.",
1234
+ INVALID_SMARTBUFFER_SIZE: "Invalid size provided. Size must be a valid integer greater than zero.",
1235
+ INVALID_SMARTBUFFER_BUFFER: "Invalid Buffer provided in SmartBufferOptions.",
1236
+ INVALID_SMARTBUFFER_OBJECT: "Invalid SmartBufferOptions object supplied to SmartBuffer constructor or factory methods.",
1237
+ INVALID_OFFSET: "An invalid offset value was provided.",
1238
+ INVALID_OFFSET_NON_NUMBER: "An invalid offset value was provided. A numeric value is required.",
1239
+ INVALID_LENGTH: "An invalid length value was provided.",
1240
+ INVALID_LENGTH_NON_NUMBER: "An invalid length value was provived. A numeric value is required.",
1241
+ INVALID_TARGET_OFFSET: "Target offset is beyond the bounds of the internal SmartBuffer data.",
1242
+ INVALID_TARGET_LENGTH: "Specified length value moves cursor beyong the bounds of the internal SmartBuffer data.",
1243
+ INVALID_READ_BEYOND_BOUNDS: "Attempted to read beyond the bounds of the managed data.",
1244
+ INVALID_WRITE_BEYOND_BOUNDS: "Attempted to write beyond the bounds of the managed data."
1245
+ };
1246
+ exports.ERRORS = ERRORS;
1247
+ function checkEncoding(encoding) {
1248
+ if (!buffer_1.Buffer.isEncoding(encoding)) {
1249
+ throw new Error(ERRORS.INVALID_ENCODING);
387
1250
  }
388
- readBufferNT() {
389
- let nullPos = this.length;
390
- for (let i2 = this._readOffset;i2 < this.length; i2++) {
391
- if (this._buff[i2] === 0) {
392
- nullPos = i2;
393
- break;
394
- }
1251
+ }
1252
+ exports.checkEncoding = checkEncoding;
1253
+ function isFiniteInteger(value) {
1254
+ return typeof value === "number" && isFinite(value) && isInteger(value);
1255
+ }
1256
+ exports.isFiniteInteger = isFiniteInteger;
1257
+ function checkOffsetOrLengthValue(value, offset) {
1258
+ if (typeof value === "number") {
1259
+ if (!isFiniteInteger(value) || value < 0) {
1260
+ throw new Error(offset ? ERRORS.INVALID_OFFSET : ERRORS.INVALID_LENGTH);
395
1261
  }
396
- const value = this._buff.slice(this._readOffset, nullPos);
397
- this._readOffset = nullPos + 1;
398
- return value;
1262
+ } else {
1263
+ throw new Error(offset ? ERRORS.INVALID_OFFSET_NON_NUMBER : ERRORS.INVALID_LENGTH_NON_NUMBER);
399
1264
  }
400
- insertBufferNT(value, offset) {
401
- utils_1.checkOffsetValue(offset);
402
- this.insertBuffer(value, offset);
403
- this.insertUInt8(0, offset + value.length);
404
- return this;
1265
+ }
1266
+ function checkLengthValue(length) {
1267
+ checkOffsetOrLengthValue(length, false);
1268
+ }
1269
+ exports.checkLengthValue = checkLengthValue;
1270
+ function checkOffsetValue(offset) {
1271
+ checkOffsetOrLengthValue(offset, true);
1272
+ }
1273
+ exports.checkOffsetValue = checkOffsetValue;
1274
+ function checkTargetOffset(offset, buff) {
1275
+ if (offset < 0 || offset > buff.length) {
1276
+ throw new Error(ERRORS.INVALID_TARGET_OFFSET);
405
1277
  }
406
- writeBufferNT(value, offset) {
407
- if (typeof offset !== "undefined") {
408
- utils_1.checkOffsetValue(offset);
409
- }
410
- this.writeBuffer(value, offset);
411
- this.writeUInt8(0, typeof offset === "number" ? offset + value.length : this._writeOffset);
412
- return this;
1278
+ }
1279
+ exports.checkTargetOffset = checkTargetOffset;
1280
+ function isInteger(value) {
1281
+ return typeof value === "number" && isFinite(value) && Math.floor(value) === value;
1282
+ }
1283
+ function bigIntAndBufferInt64Check(bufferMethod) {
1284
+ if (typeof BigInt === "undefined") {
1285
+ throw new Error("Platform does not support JS BigInt type.");
413
1286
  }
414
- clear() {
1287
+ if (typeof buffer_1.Buffer.prototype[bufferMethod] === "undefined") {
1288
+ throw new Error(`Platform does not support Buffer.prototype.${bufferMethod}.`);
1289
+ }
1290
+ }
1291
+ exports.bigIntAndBufferInt64Check = bigIntAndBufferInt64Check;
1292
+ });
1293
+
1294
+ // node_modules/smart-buffer/build/smartbuffer.js
1295
+ var require_smartbuffer = __commonJS((exports) => {
1296
+ Object.defineProperty(exports, "__esModule", { value: true });
1297
+ var utils_1 = require_utils();
1298
+ var DEFAULT_SMARTBUFFER_SIZE = 4096;
1299
+ var DEFAULT_SMARTBUFFER_ENCODING = "utf8";
1300
+
1301
+ class SmartBuffer {
1302
+ constructor(options) {
1303
+ this.length = 0;
1304
+ this._encoding = DEFAULT_SMARTBUFFER_ENCODING;
415
1305
  this._writeOffset = 0;
416
1306
  this._readOffset = 0;
417
- this.length = 0;
418
- return this;
1307
+ if (SmartBuffer.isSmartBufferOptions(options)) {
1308
+ if (options.encoding) {
1309
+ utils_1.checkEncoding(options.encoding);
1310
+ this._encoding = options.encoding;
1311
+ }
1312
+ if (options.size) {
1313
+ if (utils_1.isFiniteInteger(options.size) && options.size > 0) {
1314
+ this._buff = Buffer.allocUnsafe(options.size);
1315
+ } else {
1316
+ throw new Error(utils_1.ERRORS.INVALID_SMARTBUFFER_SIZE);
1317
+ }
1318
+ } else if (options.buff) {
1319
+ if (Buffer.isBuffer(options.buff)) {
1320
+ this._buff = options.buff;
1321
+ this.length = options.buff.length;
1322
+ } else {
1323
+ throw new Error(utils_1.ERRORS.INVALID_SMARTBUFFER_BUFFER);
1324
+ }
1325
+ } else {
1326
+ this._buff = Buffer.allocUnsafe(DEFAULT_SMARTBUFFER_SIZE);
1327
+ }
1328
+ } else {
1329
+ if (typeof options !== "undefined") {
1330
+ throw new Error(utils_1.ERRORS.INVALID_SMARTBUFFER_OBJECT);
1331
+ }
1332
+ this._buff = Buffer.allocUnsafe(DEFAULT_SMARTBUFFER_SIZE);
1333
+ }
419
1334
  }
420
- remaining() {
421
- return this.length - this._readOffset;
1335
+ static fromSize(size, encoding) {
1336
+ return new this({
1337
+ size,
1338
+ encoding
1339
+ });
422
1340
  }
423
- get readOffset() {
424
- return this._readOffset;
1341
+ static fromBuffer(buff, encoding) {
1342
+ return new this({
1343
+ buff,
1344
+ encoding
1345
+ });
425
1346
  }
426
- set readOffset(offset) {
427
- utils_1.checkOffsetValue(offset);
428
- utils_1.checkTargetOffset(offset, this);
429
- this._readOffset = offset;
1347
+ static fromOptions(options) {
1348
+ return new this(options);
430
1349
  }
431
- get writeOffset() {
432
- return this._writeOffset;
1350
+ static isSmartBufferOptions(options) {
1351
+ const castOptions = options;
1352
+ return castOptions && (castOptions.encoding !== undefined || castOptions.size !== undefined || castOptions.buff !== undefined);
433
1353
  }
434
- set writeOffset(offset) {
435
- utils_1.checkOffsetValue(offset);
436
- utils_1.checkTargetOffset(offset, this);
437
- this._writeOffset = offset;
1354
+ readInt8(offset) {
1355
+ return this._readNumberValue(Buffer.prototype.readInt8, 1, offset);
438
1356
  }
439
- get encoding() {
440
- return this._encoding;
1357
+ readInt16BE(offset) {
1358
+ return this._readNumberValue(Buffer.prototype.readInt16BE, 2, offset);
1359
+ }
1360
+ readInt16LE(offset) {
1361
+ return this._readNumberValue(Buffer.prototype.readInt16LE, 2, offset);
1362
+ }
1363
+ readInt32BE(offset) {
1364
+ return this._readNumberValue(Buffer.prototype.readInt32BE, 4, offset);
1365
+ }
1366
+ readInt32LE(offset) {
1367
+ return this._readNumberValue(Buffer.prototype.readInt32LE, 4, offset);
1368
+ }
1369
+ readBigInt64BE(offset) {
1370
+ utils_1.bigIntAndBufferInt64Check("readBigInt64BE");
1371
+ return this._readNumberValue(Buffer.prototype.readBigInt64BE, 8, offset);
1372
+ }
1373
+ readBigInt64LE(offset) {
1374
+ utils_1.bigIntAndBufferInt64Check("readBigInt64LE");
1375
+ return this._readNumberValue(Buffer.prototype.readBigInt64LE, 8, offset);
1376
+ }
1377
+ writeInt8(value, offset) {
1378
+ this._writeNumberValue(Buffer.prototype.writeInt8, 1, value, offset);
1379
+ return this;
1380
+ }
1381
+ insertInt8(value, offset) {
1382
+ return this._insertNumberValue(Buffer.prototype.writeInt8, 1, value, offset);
1383
+ }
1384
+ writeInt16BE(value, offset) {
1385
+ return this._writeNumberValue(Buffer.prototype.writeInt16BE, 2, value, offset);
1386
+ }
1387
+ insertInt16BE(value, offset) {
1388
+ return this._insertNumberValue(Buffer.prototype.writeInt16BE, 2, value, offset);
1389
+ }
1390
+ writeInt16LE(value, offset) {
1391
+ return this._writeNumberValue(Buffer.prototype.writeInt16LE, 2, value, offset);
1392
+ }
1393
+ insertInt16LE(value, offset) {
1394
+ return this._insertNumberValue(Buffer.prototype.writeInt16LE, 2, value, offset);
1395
+ }
1396
+ writeInt32BE(value, offset) {
1397
+ return this._writeNumberValue(Buffer.prototype.writeInt32BE, 4, value, offset);
1398
+ }
1399
+ insertInt32BE(value, offset) {
1400
+ return this._insertNumberValue(Buffer.prototype.writeInt32BE, 4, value, offset);
1401
+ }
1402
+ writeInt32LE(value, offset) {
1403
+ return this._writeNumberValue(Buffer.prototype.writeInt32LE, 4, value, offset);
1404
+ }
1405
+ insertInt32LE(value, offset) {
1406
+ return this._insertNumberValue(Buffer.prototype.writeInt32LE, 4, value, offset);
1407
+ }
1408
+ writeBigInt64BE(value, offset) {
1409
+ utils_1.bigIntAndBufferInt64Check("writeBigInt64BE");
1410
+ return this._writeNumberValue(Buffer.prototype.writeBigInt64BE, 8, value, offset);
1411
+ }
1412
+ insertBigInt64BE(value, offset) {
1413
+ utils_1.bigIntAndBufferInt64Check("writeBigInt64BE");
1414
+ return this._insertNumberValue(Buffer.prototype.writeBigInt64BE, 8, value, offset);
1415
+ }
1416
+ writeBigInt64LE(value, offset) {
1417
+ utils_1.bigIntAndBufferInt64Check("writeBigInt64LE");
1418
+ return this._writeNumberValue(Buffer.prototype.writeBigInt64LE, 8, value, offset);
1419
+ }
1420
+ insertBigInt64LE(value, offset) {
1421
+ utils_1.bigIntAndBufferInt64Check("writeBigInt64LE");
1422
+ return this._insertNumberValue(Buffer.prototype.writeBigInt64LE, 8, value, offset);
1423
+ }
1424
+ readUInt8(offset) {
1425
+ return this._readNumberValue(Buffer.prototype.readUInt8, 1, offset);
1426
+ }
1427
+ readUInt16BE(offset) {
1428
+ return this._readNumberValue(Buffer.prototype.readUInt16BE, 2, offset);
1429
+ }
1430
+ readUInt16LE(offset) {
1431
+ return this._readNumberValue(Buffer.prototype.readUInt16LE, 2, offset);
1432
+ }
1433
+ readUInt32BE(offset) {
1434
+ return this._readNumberValue(Buffer.prototype.readUInt32BE, 4, offset);
1435
+ }
1436
+ readUInt32LE(offset) {
1437
+ return this._readNumberValue(Buffer.prototype.readUInt32LE, 4, offset);
1438
+ }
1439
+ readBigUInt64BE(offset) {
1440
+ utils_1.bigIntAndBufferInt64Check("readBigUInt64BE");
1441
+ return this._readNumberValue(Buffer.prototype.readBigUInt64BE, 8, offset);
1442
+ }
1443
+ readBigUInt64LE(offset) {
1444
+ utils_1.bigIntAndBufferInt64Check("readBigUInt64LE");
1445
+ return this._readNumberValue(Buffer.prototype.readBigUInt64LE, 8, offset);
1446
+ }
1447
+ writeUInt8(value, offset) {
1448
+ return this._writeNumberValue(Buffer.prototype.writeUInt8, 1, value, offset);
1449
+ }
1450
+ insertUInt8(value, offset) {
1451
+ return this._insertNumberValue(Buffer.prototype.writeUInt8, 1, value, offset);
1452
+ }
1453
+ writeUInt16BE(value, offset) {
1454
+ return this._writeNumberValue(Buffer.prototype.writeUInt16BE, 2, value, offset);
1455
+ }
1456
+ insertUInt16BE(value, offset) {
1457
+ return this._insertNumberValue(Buffer.prototype.writeUInt16BE, 2, value, offset);
1458
+ }
1459
+ writeUInt16LE(value, offset) {
1460
+ return this._writeNumberValue(Buffer.prototype.writeUInt16LE, 2, value, offset);
1461
+ }
1462
+ insertUInt16LE(value, offset) {
1463
+ return this._insertNumberValue(Buffer.prototype.writeUInt16LE, 2, value, offset);
1464
+ }
1465
+ writeUInt32BE(value, offset) {
1466
+ return this._writeNumberValue(Buffer.prototype.writeUInt32BE, 4, value, offset);
1467
+ }
1468
+ insertUInt32BE(value, offset) {
1469
+ return this._insertNumberValue(Buffer.prototype.writeUInt32BE, 4, value, offset);
1470
+ }
1471
+ writeUInt32LE(value, offset) {
1472
+ return this._writeNumberValue(Buffer.prototype.writeUInt32LE, 4, value, offset);
1473
+ }
1474
+ insertUInt32LE(value, offset) {
1475
+ return this._insertNumberValue(Buffer.prototype.writeUInt32LE, 4, value, offset);
1476
+ }
1477
+ writeBigUInt64BE(value, offset) {
1478
+ utils_1.bigIntAndBufferInt64Check("writeBigUInt64BE");
1479
+ return this._writeNumberValue(Buffer.prototype.writeBigUInt64BE, 8, value, offset);
1480
+ }
1481
+ insertBigUInt64BE(value, offset) {
1482
+ utils_1.bigIntAndBufferInt64Check("writeBigUInt64BE");
1483
+ return this._insertNumberValue(Buffer.prototype.writeBigUInt64BE, 8, value, offset);
1484
+ }
1485
+ writeBigUInt64LE(value, offset) {
1486
+ utils_1.bigIntAndBufferInt64Check("writeBigUInt64LE");
1487
+ return this._writeNumberValue(Buffer.prototype.writeBigUInt64LE, 8, value, offset);
1488
+ }
1489
+ insertBigUInt64LE(value, offset) {
1490
+ utils_1.bigIntAndBufferInt64Check("writeBigUInt64LE");
1491
+ return this._insertNumberValue(Buffer.prototype.writeBigUInt64LE, 8, value, offset);
1492
+ }
1493
+ readFloatBE(offset) {
1494
+ return this._readNumberValue(Buffer.prototype.readFloatBE, 4, offset);
1495
+ }
1496
+ readFloatLE(offset) {
1497
+ return this._readNumberValue(Buffer.prototype.readFloatLE, 4, offset);
1498
+ }
1499
+ writeFloatBE(value, offset) {
1500
+ return this._writeNumberValue(Buffer.prototype.writeFloatBE, 4, value, offset);
1501
+ }
1502
+ insertFloatBE(value, offset) {
1503
+ return this._insertNumberValue(Buffer.prototype.writeFloatBE, 4, value, offset);
1504
+ }
1505
+ writeFloatLE(value, offset) {
1506
+ return this._writeNumberValue(Buffer.prototype.writeFloatLE, 4, value, offset);
1507
+ }
1508
+ insertFloatLE(value, offset) {
1509
+ return this._insertNumberValue(Buffer.prototype.writeFloatLE, 4, value, offset);
1510
+ }
1511
+ readDoubleBE(offset) {
1512
+ return this._readNumberValue(Buffer.prototype.readDoubleBE, 8, offset);
1513
+ }
1514
+ readDoubleLE(offset) {
1515
+ return this._readNumberValue(Buffer.prototype.readDoubleLE, 8, offset);
1516
+ }
1517
+ writeDoubleBE(value, offset) {
1518
+ return this._writeNumberValue(Buffer.prototype.writeDoubleBE, 8, value, offset);
1519
+ }
1520
+ insertDoubleBE(value, offset) {
1521
+ return this._insertNumberValue(Buffer.prototype.writeDoubleBE, 8, value, offset);
1522
+ }
1523
+ writeDoubleLE(value, offset) {
1524
+ return this._writeNumberValue(Buffer.prototype.writeDoubleLE, 8, value, offset);
1525
+ }
1526
+ insertDoubleLE(value, offset) {
1527
+ return this._insertNumberValue(Buffer.prototype.writeDoubleLE, 8, value, offset);
1528
+ }
1529
+ readString(arg1, encoding) {
1530
+ let lengthVal;
1531
+ if (typeof arg1 === "number") {
1532
+ utils_1.checkLengthValue(arg1);
1533
+ lengthVal = Math.min(arg1, this.length - this._readOffset);
1534
+ } else {
1535
+ encoding = arg1;
1536
+ lengthVal = this.length - this._readOffset;
1537
+ }
1538
+ if (typeof encoding !== "undefined") {
1539
+ utils_1.checkEncoding(encoding);
1540
+ }
1541
+ const value = this._buff.slice(this._readOffset, this._readOffset + lengthVal).toString(encoding || this._encoding);
1542
+ this._readOffset += lengthVal;
1543
+ return value;
1544
+ }
1545
+ insertString(value, offset, encoding) {
1546
+ utils_1.checkOffsetValue(offset);
1547
+ return this._handleString(value, true, offset, encoding);
1548
+ }
1549
+ writeString(value, arg2, encoding) {
1550
+ return this._handleString(value, false, arg2, encoding);
1551
+ }
1552
+ readStringNT(encoding) {
1553
+ if (typeof encoding !== "undefined") {
1554
+ utils_1.checkEncoding(encoding);
1555
+ }
1556
+ let nullPos = this.length;
1557
+ for (let i2 = this._readOffset;i2 < this.length; i2++) {
1558
+ if (this._buff[i2] === 0) {
1559
+ nullPos = i2;
1560
+ break;
1561
+ }
1562
+ }
1563
+ const value = this._buff.slice(this._readOffset, nullPos);
1564
+ this._readOffset = nullPos + 1;
1565
+ return value.toString(encoding || this._encoding);
1566
+ }
1567
+ insertStringNT(value, offset, encoding) {
1568
+ utils_1.checkOffsetValue(offset);
1569
+ this.insertString(value, offset, encoding);
1570
+ this.insertUInt8(0, offset + value.length);
1571
+ return this;
1572
+ }
1573
+ writeStringNT(value, arg2, encoding) {
1574
+ this.writeString(value, arg2, encoding);
1575
+ this.writeUInt8(0, typeof arg2 === "number" ? arg2 + value.length : this.writeOffset);
1576
+ return this;
1577
+ }
1578
+ readBuffer(length) {
1579
+ if (typeof length !== "undefined") {
1580
+ utils_1.checkLengthValue(length);
1581
+ }
1582
+ const lengthVal = typeof length === "number" ? length : this.length;
1583
+ const endPoint = Math.min(this.length, this._readOffset + lengthVal);
1584
+ const value = this._buff.slice(this._readOffset, endPoint);
1585
+ this._readOffset = endPoint;
1586
+ return value;
1587
+ }
1588
+ insertBuffer(value, offset) {
1589
+ utils_1.checkOffsetValue(offset);
1590
+ return this._handleBuffer(value, true, offset);
1591
+ }
1592
+ writeBuffer(value, offset) {
1593
+ return this._handleBuffer(value, false, offset);
1594
+ }
1595
+ readBufferNT() {
1596
+ let nullPos = this.length;
1597
+ for (let i2 = this._readOffset;i2 < this.length; i2++) {
1598
+ if (this._buff[i2] === 0) {
1599
+ nullPos = i2;
1600
+ break;
1601
+ }
1602
+ }
1603
+ const value = this._buff.slice(this._readOffset, nullPos);
1604
+ this._readOffset = nullPos + 1;
1605
+ return value;
1606
+ }
1607
+ insertBufferNT(value, offset) {
1608
+ utils_1.checkOffsetValue(offset);
1609
+ this.insertBuffer(value, offset);
1610
+ this.insertUInt8(0, offset + value.length);
1611
+ return this;
1612
+ }
1613
+ writeBufferNT(value, offset) {
1614
+ if (typeof offset !== "undefined") {
1615
+ utils_1.checkOffsetValue(offset);
1616
+ }
1617
+ this.writeBuffer(value, offset);
1618
+ this.writeUInt8(0, typeof offset === "number" ? offset + value.length : this._writeOffset);
1619
+ return this;
1620
+ }
1621
+ clear() {
1622
+ this._writeOffset = 0;
1623
+ this._readOffset = 0;
1624
+ this.length = 0;
1625
+ return this;
1626
+ }
1627
+ remaining() {
1628
+ return this.length - this._readOffset;
1629
+ }
1630
+ get readOffset() {
1631
+ return this._readOffset;
1632
+ }
1633
+ set readOffset(offset) {
1634
+ utils_1.checkOffsetValue(offset);
1635
+ utils_1.checkTargetOffset(offset, this);
1636
+ this._readOffset = offset;
1637
+ }
1638
+ get writeOffset() {
1639
+ return this._writeOffset;
1640
+ }
1641
+ set writeOffset(offset) {
1642
+ utils_1.checkOffsetValue(offset);
1643
+ utils_1.checkTargetOffset(offset, this);
1644
+ this._writeOffset = offset;
1645
+ }
1646
+ get encoding() {
1647
+ return this._encoding;
441
1648
  }
442
1649
  set encoding(encoding) {
443
1650
  utils_1.checkEncoding(encoding);
@@ -714,7 +1921,7 @@ var require_util = __commonJS((exports) => {
714
1921
  });
715
1922
 
716
1923
  // node_modules/ip-address/dist/common.js
717
- var require_common = __commonJS((exports) => {
1924
+ var require_common2 = __commonJS((exports) => {
718
1925
  Object.defineProperty(exports, "__esModule", { value: true });
719
1926
  exports.isCorrect = exports.isInSubnet = undefined;
720
1927
  function isInSubnet(address) {
@@ -2426,7 +3633,7 @@ var require_ipv4 = __commonJS((exports) => {
2426
3633
  };
2427
3634
  Object.defineProperty(exports, "__esModule", { value: true });
2428
3635
  exports.Address4 = undefined;
2429
- var common = __importStar(require_common());
3636
+ var common = __importStar(require_common2());
2430
3637
  var constants = __importStar(require_constants2());
2431
3638
  var address_error_1 = require_address_error();
2432
3639
  var jsbn_1 = require_jsbn();
@@ -2615,7 +3822,7 @@ var require_constants3 = __commonJS((exports) => {
2615
3822
  });
2616
3823
 
2617
3824
  // node_modules/ip-address/dist/v6/helpers.js
2618
- var require_helpers = __commonJS((exports) => {
3825
+ var require_helpers2 = __commonJS((exports) => {
2619
3826
  Object.defineProperty(exports, "__esModule", { value: true });
2620
3827
  exports.simpleGroup = exports.spanLeadingZeroes = exports.spanAll = exports.spanAllZeroes = undefined;
2621
3828
  var sprintf_js_1 = require_sprintf();
@@ -2779,10 +3986,10 @@ var require_ipv6 = __commonJS((exports) => {
2779
3986
  };
2780
3987
  Object.defineProperty(exports, "__esModule", { value: true });
2781
3988
  exports.Address6 = undefined;
2782
- var common = __importStar(require_common());
3989
+ var common = __importStar(require_common2());
2783
3990
  var constants4 = __importStar(require_constants2());
2784
3991
  var constants6 = __importStar(require_constants3());
2785
- var helpers = __importStar(require_helpers());
3992
+ var helpers = __importStar(require_helpers2());
2786
3993
  var ipv4_1 = require_ipv4();
2787
3994
  var regular_expressions_1 = require_regular_expressions();
2788
3995
  var address_error_1 = require_address_error();
@@ -3391,12 +4598,12 @@ var require_ip_address = __commonJS((exports) => {
3391
4598
  Object.defineProperty(exports, "AddressError", { enumerable: true, get: function() {
3392
4599
  return address_error_1.AddressError;
3393
4600
  } });
3394
- var helpers = __importStar(require_helpers());
4601
+ var helpers = __importStar(require_helpers2());
3395
4602
  exports.v6 = { helpers };
3396
4603
  });
3397
4604
 
3398
4605
  // node_modules/socks/build/common/helpers.js
3399
- var require_helpers2 = __commonJS((exports) => {
4606
+ var require_helpers3 = __commonJS((exports) => {
3400
4607
  Object.defineProperty(exports, "__esModule", { value: true });
3401
4608
  exports.ipToBuffer = exports.int32ToIpv4 = exports.ipv4ToInt32 = exports.validateSocksClientChainOptions = exports.validateSocksClientOptions = undefined;
3402
4609
  var util_1 = require_util();
@@ -3580,7 +4787,7 @@ var require_socksclient = __commonJS((exports) => {
3580
4787
  var net = __require("net");
3581
4788
  var smart_buffer_1 = require_smartbuffer();
3582
4789
  var constants_1 = require_constants();
3583
- var helpers_1 = require_helpers2();
4790
+ var helpers_1 = require_helpers3();
3584
4791
  var receivebuffer_1 = require_receivebuffer();
3585
4792
  var util_1 = require_util();
3586
4793
  Object.defineProperty(exports, "SocksClientError", { enumerable: true, get: function() {
@@ -4149,1254 +5356,7 @@ var require_build = __commonJS((exports) => {
4149
5356
  __exportStar(require_socksclient(), exports);
4150
5357
  });
4151
5358
 
4152
- // node_modules/agent-base/dist/helpers.js
4153
- var require_helpers3 = __commonJS((exports) => {
4154
- var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
4155
- if (k2 === undefined)
4156
- k2 = k;
4157
- var desc = Object.getOwnPropertyDescriptor(m, k);
4158
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
4159
- desc = { enumerable: true, get: function() {
4160
- return m[k];
4161
- } };
4162
- }
4163
- Object.defineProperty(o, k2, desc);
4164
- } : function(o, m, k, k2) {
4165
- if (k2 === undefined)
4166
- k2 = k;
4167
- o[k2] = m[k];
4168
- });
4169
- var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? function(o, v) {
4170
- Object.defineProperty(o, "default", { enumerable: true, value: v });
4171
- } : function(o, v) {
4172
- o["default"] = v;
4173
- });
4174
- var __importStar = exports && exports.__importStar || function(mod) {
4175
- if (mod && mod.__esModule)
4176
- return mod;
4177
- var result = {};
4178
- if (mod != null) {
4179
- for (var k in mod)
4180
- if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
4181
- __createBinding(result, mod, k);
4182
- }
4183
- __setModuleDefault(result, mod);
4184
- return result;
4185
- };
4186
- Object.defineProperty(exports, "__esModule", { value: true });
4187
- exports.req = exports.json = exports.toBuffer = undefined;
4188
- var http = __importStar(__require("http"));
4189
- var https = __importStar(__require("https"));
4190
- async function toBuffer(stream) {
4191
- let length = 0;
4192
- const chunks = [];
4193
- for await (const chunk of stream) {
4194
- length += chunk.length;
4195
- chunks.push(chunk);
4196
- }
4197
- return Buffer.concat(chunks, length);
4198
- }
4199
- exports.toBuffer = toBuffer;
4200
- async function json(stream) {
4201
- const buf = await toBuffer(stream);
4202
- const str = buf.toString("utf8");
4203
- try {
4204
- return JSON.parse(str);
4205
- } catch (_err) {
4206
- const err = _err;
4207
- err.message += ` (input: ${str})`;
4208
- throw err;
4209
- }
4210
- }
4211
- exports.json = json;
4212
- function req(url, opts = {}) {
4213
- const href = typeof url === "string" ? url : url.href;
4214
- const req2 = (href.startsWith("https:") ? https : http).request(url, opts);
4215
- const promise = new Promise((resolve, reject) => {
4216
- req2.once("response", resolve).once("error", reject).end();
4217
- });
4218
- req2.then = promise.then.bind(promise);
4219
- return req2;
4220
- }
4221
- exports.req = req;
4222
- });
4223
-
4224
- // node_modules/agent-base/dist/index.js
4225
- var require_dist = __commonJS((exports) => {
4226
- var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
4227
- if (k2 === undefined)
4228
- k2 = k;
4229
- var desc = Object.getOwnPropertyDescriptor(m, k);
4230
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
4231
- desc = { enumerable: true, get: function() {
4232
- return m[k];
4233
- } };
4234
- }
4235
- Object.defineProperty(o, k2, desc);
4236
- } : function(o, m, k, k2) {
4237
- if (k2 === undefined)
4238
- k2 = k;
4239
- o[k2] = m[k];
4240
- });
4241
- var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? function(o, v) {
4242
- Object.defineProperty(o, "default", { enumerable: true, value: v });
4243
- } : function(o, v) {
4244
- o["default"] = v;
4245
- });
4246
- var __importStar = exports && exports.__importStar || function(mod) {
4247
- if (mod && mod.__esModule)
4248
- return mod;
4249
- var result = {};
4250
- if (mod != null) {
4251
- for (var k in mod)
4252
- if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
4253
- __createBinding(result, mod, k);
4254
- }
4255
- __setModuleDefault(result, mod);
4256
- return result;
4257
- };
4258
- var __exportStar = exports && exports.__exportStar || function(m, exports2) {
4259
- for (var p in m)
4260
- if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports2, p))
4261
- __createBinding(exports2, m, p);
4262
- };
4263
- Object.defineProperty(exports, "__esModule", { value: true });
4264
- exports.Agent = undefined;
4265
- var net = __importStar(__require("net"));
4266
- var http = __importStar(__require("http"));
4267
- var https_1 = __require("https");
4268
- __exportStar(require_helpers3(), exports);
4269
- var INTERNAL = Symbol("AgentBaseInternalState");
4270
-
4271
- class Agent extends http.Agent {
4272
- constructor(opts) {
4273
- super(opts);
4274
- this[INTERNAL] = {};
4275
- }
4276
- isSecureEndpoint(options) {
4277
- if (options) {
4278
- if (typeof options.secureEndpoint === "boolean") {
4279
- return options.secureEndpoint;
4280
- }
4281
- if (typeof options.protocol === "string") {
4282
- return options.protocol === "https:";
4283
- }
4284
- }
4285
- const { stack } = new Error;
4286
- if (typeof stack !== "string")
4287
- return false;
4288
- return stack.split(`
4289
- `).some((l) => l.indexOf("(https.js:") !== -1 || l.indexOf("node:https:") !== -1);
4290
- }
4291
- incrementSockets(name) {
4292
- if (this.maxSockets === Infinity && this.maxTotalSockets === Infinity) {
4293
- return null;
4294
- }
4295
- if (!this.sockets[name]) {
4296
- this.sockets[name] = [];
4297
- }
4298
- const fakeSocket = new net.Socket({ writable: false });
4299
- this.sockets[name].push(fakeSocket);
4300
- this.totalSocketCount++;
4301
- return fakeSocket;
4302
- }
4303
- decrementSockets(name, socket) {
4304
- if (!this.sockets[name] || socket === null) {
4305
- return;
4306
- }
4307
- const sockets = this.sockets[name];
4308
- const index = sockets.indexOf(socket);
4309
- if (index !== -1) {
4310
- sockets.splice(index, 1);
4311
- this.totalSocketCount--;
4312
- if (sockets.length === 0) {
4313
- delete this.sockets[name];
4314
- }
4315
- }
4316
- }
4317
- getName(options) {
4318
- const secureEndpoint = typeof options.secureEndpoint === "boolean" ? options.secureEndpoint : this.isSecureEndpoint(options);
4319
- if (secureEndpoint) {
4320
- return https_1.Agent.prototype.getName.call(this, options);
4321
- }
4322
- return super.getName(options);
4323
- }
4324
- createSocket(req, options, cb) {
4325
- const connectOpts = {
4326
- ...options,
4327
- secureEndpoint: this.isSecureEndpoint(options)
4328
- };
4329
- const name = this.getName(connectOpts);
4330
- const fakeSocket = this.incrementSockets(name);
4331
- Promise.resolve().then(() => this.connect(req, connectOpts)).then((socket) => {
4332
- this.decrementSockets(name, fakeSocket);
4333
- if (socket instanceof http.Agent) {
4334
- try {
4335
- return socket.addRequest(req, connectOpts);
4336
- } catch (err) {
4337
- return cb(err);
4338
- }
4339
- }
4340
- this[INTERNAL].currentSocket = socket;
4341
- super.createSocket(req, options, cb);
4342
- }, (err) => {
4343
- this.decrementSockets(name, fakeSocket);
4344
- cb(err);
4345
- });
4346
- }
4347
- createConnection() {
4348
- const socket = this[INTERNAL].currentSocket;
4349
- this[INTERNAL].currentSocket = undefined;
4350
- if (!socket) {
4351
- throw new Error("No socket was returned in the `connect()` function");
4352
- }
4353
- return socket;
4354
- }
4355
- get defaultPort() {
4356
- return this[INTERNAL].defaultPort ?? (this.protocol === "https:" ? 443 : 80);
4357
- }
4358
- set defaultPort(v) {
4359
- if (this[INTERNAL]) {
4360
- this[INTERNAL].defaultPort = v;
4361
- }
4362
- }
4363
- get protocol() {
4364
- return this[INTERNAL].protocol ?? (this.isSecureEndpoint() ? "https:" : "http:");
4365
- }
4366
- set protocol(v) {
4367
- if (this[INTERNAL]) {
4368
- this[INTERNAL].protocol = v;
4369
- }
4370
- }
4371
- }
4372
- exports.Agent = Agent;
4373
- });
4374
-
4375
- // node_modules/ms/index.js
4376
- var require_ms = __commonJS((exports, module) => {
4377
- var s2 = 1000;
4378
- var m = s2 * 60;
4379
- var h = m * 60;
4380
- var d = h * 24;
4381
- var w = d * 7;
4382
- var y = d * 365.25;
4383
- module.exports = function(val, options) {
4384
- options = options || {};
4385
- var type = typeof val;
4386
- if (type === "string" && val.length > 0) {
4387
- return parse(val);
4388
- } else if (type === "number" && isFinite(val)) {
4389
- return options.long ? fmtLong(val) : fmtShort(val);
4390
- }
4391
- throw new Error("val is not a non-empty string or a valid number. val=" + JSON.stringify(val));
4392
- };
4393
- function parse(str) {
4394
- str = String(str);
4395
- if (str.length > 100) {
4396
- return;
4397
- }
4398
- var match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(str);
4399
- if (!match) {
4400
- return;
4401
- }
4402
- var n2 = parseFloat(match[1]);
4403
- var type = (match[2] || "ms").toLowerCase();
4404
- switch (type) {
4405
- case "years":
4406
- case "year":
4407
- case "yrs":
4408
- case "yr":
4409
- case "y":
4410
- return n2 * y;
4411
- case "weeks":
4412
- case "week":
4413
- case "w":
4414
- return n2 * w;
4415
- case "days":
4416
- case "day":
4417
- case "d":
4418
- return n2 * d;
4419
- case "hours":
4420
- case "hour":
4421
- case "hrs":
4422
- case "hr":
4423
- case "h":
4424
- return n2 * h;
4425
- case "minutes":
4426
- case "minute":
4427
- case "mins":
4428
- case "min":
4429
- case "m":
4430
- return n2 * m;
4431
- case "seconds":
4432
- case "second":
4433
- case "secs":
4434
- case "sec":
4435
- case "s":
4436
- return n2 * s2;
4437
- case "milliseconds":
4438
- case "millisecond":
4439
- case "msecs":
4440
- case "msec":
4441
- case "ms":
4442
- return n2;
4443
- default:
4444
- return;
4445
- }
4446
- }
4447
- function fmtShort(ms) {
4448
- var msAbs = Math.abs(ms);
4449
- if (msAbs >= d) {
4450
- return Math.round(ms / d) + "d";
4451
- }
4452
- if (msAbs >= h) {
4453
- return Math.round(ms / h) + "h";
4454
- }
4455
- if (msAbs >= m) {
4456
- return Math.round(ms / m) + "m";
4457
- }
4458
- if (msAbs >= s2) {
4459
- return Math.round(ms / s2) + "s";
4460
- }
4461
- return ms + "ms";
4462
- }
4463
- function fmtLong(ms) {
4464
- var msAbs = Math.abs(ms);
4465
- if (msAbs >= d) {
4466
- return plural(ms, msAbs, d, "day");
4467
- }
4468
- if (msAbs >= h) {
4469
- return plural(ms, msAbs, h, "hour");
4470
- }
4471
- if (msAbs >= m) {
4472
- return plural(ms, msAbs, m, "minute");
4473
- }
4474
- if (msAbs >= s2) {
4475
- return plural(ms, msAbs, s2, "second");
4476
- }
4477
- return ms + " ms";
4478
- }
4479
- function plural(ms, msAbs, n2, name) {
4480
- var isPlural = msAbs >= n2 * 1.5;
4481
- return Math.round(ms / n2) + " " + name + (isPlural ? "s" : "");
4482
- }
4483
- });
4484
-
4485
- // node_modules/debug/src/common.js
4486
- var require_common2 = __commonJS((exports, module) => {
4487
- function setup(env) {
4488
- createDebug.debug = createDebug;
4489
- createDebug.default = createDebug;
4490
- createDebug.coerce = coerce;
4491
- createDebug.disable = disable;
4492
- createDebug.enable = enable;
4493
- createDebug.enabled = enabled;
4494
- createDebug.humanize = require_ms();
4495
- createDebug.destroy = destroy;
4496
- Object.keys(env).forEach((key) => {
4497
- createDebug[key] = env[key];
4498
- });
4499
- createDebug.names = [];
4500
- createDebug.skips = [];
4501
- createDebug.formatters = {};
4502
- function selectColor(namespace) {
4503
- let hash = 0;
4504
- for (let i2 = 0;i2 < namespace.length; i2++) {
4505
- hash = (hash << 5) - hash + namespace.charCodeAt(i2);
4506
- hash |= 0;
4507
- }
4508
- return createDebug.colors[Math.abs(hash) % createDebug.colors.length];
4509
- }
4510
- createDebug.selectColor = selectColor;
4511
- function createDebug(namespace) {
4512
- let prevTime;
4513
- let enableOverride = null;
4514
- let namespacesCache;
4515
- let enabledCache;
4516
- function debug(...args) {
4517
- if (!debug.enabled) {
4518
- return;
4519
- }
4520
- const self2 = debug;
4521
- const curr = Number(new Date);
4522
- const ms = curr - (prevTime || curr);
4523
- self2.diff = ms;
4524
- self2.prev = prevTime;
4525
- self2.curr = curr;
4526
- prevTime = curr;
4527
- args[0] = createDebug.coerce(args[0]);
4528
- if (typeof args[0] !== "string") {
4529
- args.unshift("%O");
4530
- }
4531
- let index = 0;
4532
- args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => {
4533
- if (match === "%%") {
4534
- return "%";
4535
- }
4536
- index++;
4537
- const formatter = createDebug.formatters[format];
4538
- if (typeof formatter === "function") {
4539
- const val = args[index];
4540
- match = formatter.call(self2, val);
4541
- args.splice(index, 1);
4542
- index--;
4543
- }
4544
- return match;
4545
- });
4546
- createDebug.formatArgs.call(self2, args);
4547
- const logFn = self2.log || createDebug.log;
4548
- logFn.apply(self2, args);
4549
- }
4550
- debug.namespace = namespace;
4551
- debug.useColors = createDebug.useColors();
4552
- debug.color = createDebug.selectColor(namespace);
4553
- debug.extend = extend;
4554
- debug.destroy = createDebug.destroy;
4555
- Object.defineProperty(debug, "enabled", {
4556
- enumerable: true,
4557
- configurable: false,
4558
- get: () => {
4559
- if (enableOverride !== null) {
4560
- return enableOverride;
4561
- }
4562
- if (namespacesCache !== createDebug.namespaces) {
4563
- namespacesCache = createDebug.namespaces;
4564
- enabledCache = createDebug.enabled(namespace);
4565
- }
4566
- return enabledCache;
4567
- },
4568
- set: (v) => {
4569
- enableOverride = v;
4570
- }
4571
- });
4572
- if (typeof createDebug.init === "function") {
4573
- createDebug.init(debug);
4574
- }
4575
- return debug;
4576
- }
4577
- function extend(namespace, delimiter) {
4578
- const newDebug = createDebug(this.namespace + (typeof delimiter === "undefined" ? ":" : delimiter) + namespace);
4579
- newDebug.log = this.log;
4580
- return newDebug;
4581
- }
4582
- function enable(namespaces) {
4583
- createDebug.save(namespaces);
4584
- createDebug.namespaces = namespaces;
4585
- createDebug.names = [];
4586
- createDebug.skips = [];
4587
- const split = (typeof namespaces === "string" ? namespaces : "").trim().replace(" ", ",").split(",").filter(Boolean);
4588
- for (const ns of split) {
4589
- if (ns[0] === "-") {
4590
- createDebug.skips.push(ns.slice(1));
4591
- } else {
4592
- createDebug.names.push(ns);
4593
- }
4594
- }
4595
- }
4596
- function matchesTemplate(search, template) {
4597
- let searchIndex = 0;
4598
- let templateIndex = 0;
4599
- let starIndex = -1;
4600
- let matchIndex = 0;
4601
- while (searchIndex < search.length) {
4602
- if (templateIndex < template.length && (template[templateIndex] === search[searchIndex] || template[templateIndex] === "*")) {
4603
- if (template[templateIndex] === "*") {
4604
- starIndex = templateIndex;
4605
- matchIndex = searchIndex;
4606
- templateIndex++;
4607
- } else {
4608
- searchIndex++;
4609
- templateIndex++;
4610
- }
4611
- } else if (starIndex !== -1) {
4612
- templateIndex = starIndex + 1;
4613
- matchIndex++;
4614
- searchIndex = matchIndex;
4615
- } else {
4616
- return false;
4617
- }
4618
- }
4619
- while (templateIndex < template.length && template[templateIndex] === "*") {
4620
- templateIndex++;
4621
- }
4622
- return templateIndex === template.length;
4623
- }
4624
- function disable() {
4625
- const namespaces = [
4626
- ...createDebug.names,
4627
- ...createDebug.skips.map((namespace) => "-" + namespace)
4628
- ].join(",");
4629
- createDebug.enable("");
4630
- return namespaces;
4631
- }
4632
- function enabled(name) {
4633
- for (const skip of createDebug.skips) {
4634
- if (matchesTemplate(name, skip)) {
4635
- return false;
4636
- }
4637
- }
4638
- for (const ns of createDebug.names) {
4639
- if (matchesTemplate(name, ns)) {
4640
- return true;
4641
- }
4642
- }
4643
- return false;
4644
- }
4645
- function coerce(val) {
4646
- if (val instanceof Error) {
4647
- return val.stack || val.message;
4648
- }
4649
- return val;
4650
- }
4651
- function destroy() {
4652
- console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
4653
- }
4654
- createDebug.enable(createDebug.load());
4655
- return createDebug;
4656
- }
4657
- module.exports = setup;
4658
- });
4659
-
4660
- // node_modules/debug/src/browser.js
4661
- var require_browser = __commonJS((exports, module) => {
4662
- exports.formatArgs = formatArgs;
4663
- exports.save = save;
4664
- exports.load = load;
4665
- exports.useColors = useColors;
4666
- exports.storage = localstorage();
4667
- exports.destroy = (() => {
4668
- let warned = false;
4669
- return () => {
4670
- if (!warned) {
4671
- warned = true;
4672
- console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
4673
- }
4674
- };
4675
- })();
4676
- exports.colors = [
4677
- "#0000CC",
4678
- "#0000FF",
4679
- "#0033CC",
4680
- "#0033FF",
4681
- "#0066CC",
4682
- "#0066FF",
4683
- "#0099CC",
4684
- "#0099FF",
4685
- "#00CC00",
4686
- "#00CC33",
4687
- "#00CC66",
4688
- "#00CC99",
4689
- "#00CCCC",
4690
- "#00CCFF",
4691
- "#3300CC",
4692
- "#3300FF",
4693
- "#3333CC",
4694
- "#3333FF",
4695
- "#3366CC",
4696
- "#3366FF",
4697
- "#3399CC",
4698
- "#3399FF",
4699
- "#33CC00",
4700
- "#33CC33",
4701
- "#33CC66",
4702
- "#33CC99",
4703
- "#33CCCC",
4704
- "#33CCFF",
4705
- "#6600CC",
4706
- "#6600FF",
4707
- "#6633CC",
4708
- "#6633FF",
4709
- "#66CC00",
4710
- "#66CC33",
4711
- "#9900CC",
4712
- "#9900FF",
4713
- "#9933CC",
4714
- "#9933FF",
4715
- "#99CC00",
4716
- "#99CC33",
4717
- "#CC0000",
4718
- "#CC0033",
4719
- "#CC0066",
4720
- "#CC0099",
4721
- "#CC00CC",
4722
- "#CC00FF",
4723
- "#CC3300",
4724
- "#CC3333",
4725
- "#CC3366",
4726
- "#CC3399",
4727
- "#CC33CC",
4728
- "#CC33FF",
4729
- "#CC6600",
4730
- "#CC6633",
4731
- "#CC9900",
4732
- "#CC9933",
4733
- "#CCCC00",
4734
- "#CCCC33",
4735
- "#FF0000",
4736
- "#FF0033",
4737
- "#FF0066",
4738
- "#FF0099",
4739
- "#FF00CC",
4740
- "#FF00FF",
4741
- "#FF3300",
4742
- "#FF3333",
4743
- "#FF3366",
4744
- "#FF3399",
4745
- "#FF33CC",
4746
- "#FF33FF",
4747
- "#FF6600",
4748
- "#FF6633",
4749
- "#FF9900",
4750
- "#FF9933",
4751
- "#FFCC00",
4752
- "#FFCC33"
4753
- ];
4754
- function useColors() {
4755
- if (typeof window !== "undefined" && window.process && (window.process.type === "renderer" || window.process.__nwjs)) {
4756
- return true;
4757
- }
4758
- if (typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
4759
- return false;
4760
- }
4761
- let m;
4762
- return typeof document !== "undefined" && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance || typeof window !== "undefined" && window.console && (window.console.firebug || window.console.exception && window.console.table) || typeof navigator !== "undefined" && navigator.userAgent && (m = navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)) && parseInt(m[1], 10) >= 31 || typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/);
4763
- }
4764
- function formatArgs(args) {
4765
- args[0] = (this.useColors ? "%c" : "") + this.namespace + (this.useColors ? " %c" : " ") + args[0] + (this.useColors ? "%c " : " ") + "+" + module.exports.humanize(this.diff);
4766
- if (!this.useColors) {
4767
- return;
4768
- }
4769
- const c = "color: " + this.color;
4770
- args.splice(1, 0, c, "color: inherit");
4771
- let index = 0;
4772
- let lastC = 0;
4773
- args[0].replace(/%[a-zA-Z%]/g, (match) => {
4774
- if (match === "%%") {
4775
- return;
4776
- }
4777
- index++;
4778
- if (match === "%c") {
4779
- lastC = index;
4780
- }
4781
- });
4782
- args.splice(lastC, 0, c);
4783
- }
4784
- exports.log = console.debug || console.log || (() => {
4785
- });
4786
- function save(namespaces) {
4787
- try {
4788
- if (namespaces) {
4789
- exports.storage.setItem("debug", namespaces);
4790
- } else {
4791
- exports.storage.removeItem("debug");
4792
- }
4793
- } catch (error) {
4794
- }
4795
- }
4796
- function load() {
4797
- let r2;
4798
- try {
4799
- r2 = exports.storage.getItem("debug");
4800
- } catch (error) {
4801
- }
4802
- if (!r2 && typeof process !== "undefined" && "env" in process) {
4803
- r2 = process.env.DEBUG;
4804
- }
4805
- return r2;
4806
- }
4807
- function localstorage() {
4808
- try {
4809
- return localStorage;
4810
- } catch (error) {
4811
- }
4812
- }
4813
- module.exports = require_common2()(exports);
4814
- var { formatters } = module.exports;
4815
- formatters.j = function(v) {
4816
- try {
4817
- return JSON.stringify(v);
4818
- } catch (error) {
4819
- return "[UnexpectedJSONParseError]: " + error.message;
4820
- }
4821
- };
4822
- });
4823
-
4824
- // node_modules/has-flag/index.js
4825
- var require_has_flag = __commonJS((exports, module) => {
4826
- module.exports = (flag, argv = process.argv) => {
4827
- const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
4828
- const position = argv.indexOf(prefix + flag);
4829
- const terminatorPosition = argv.indexOf("--");
4830
- return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
4831
- };
4832
- });
4833
-
4834
- // node_modules/supports-color/index.js
4835
- var require_supports_color = __commonJS((exports, module) => {
4836
- var os = __require("os");
4837
- var tty = __require("tty");
4838
- var hasFlag = require_has_flag();
4839
- var { env } = process;
4840
- var forceColor;
4841
- if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) {
4842
- forceColor = 0;
4843
- } else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) {
4844
- forceColor = 1;
4845
- }
4846
- if ("FORCE_COLOR" in env) {
4847
- if (env.FORCE_COLOR === "true") {
4848
- forceColor = 1;
4849
- } else if (env.FORCE_COLOR === "false") {
4850
- forceColor = 0;
4851
- } else {
4852
- forceColor = env.FORCE_COLOR.length === 0 ? 1 : Math.min(parseInt(env.FORCE_COLOR, 10), 3);
4853
- }
4854
- }
4855
- function translateLevel(level) {
4856
- if (level === 0) {
4857
- return false;
4858
- }
4859
- return {
4860
- level,
4861
- hasBasic: true,
4862
- has256: level >= 2,
4863
- has16m: level >= 3
4864
- };
4865
- }
4866
- function supportsColor(haveStream, streamIsTTY) {
4867
- if (forceColor === 0) {
4868
- return 0;
4869
- }
4870
- if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor")) {
4871
- return 3;
4872
- }
4873
- if (hasFlag("color=256")) {
4874
- return 2;
4875
- }
4876
- if (haveStream && !streamIsTTY && forceColor === undefined) {
4877
- return 0;
4878
- }
4879
- const min = forceColor || 0;
4880
- if (env.TERM === "dumb") {
4881
- return min;
4882
- }
4883
- if (process.platform === "win32") {
4884
- const osRelease = os.release().split(".");
4885
- if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
4886
- return Number(osRelease[2]) >= 14931 ? 3 : 2;
4887
- }
4888
- return 1;
4889
- }
4890
- if ("CI" in env) {
4891
- if (["TRAVIS", "CIRCLECI", "APPVEYOR", "GITLAB_CI", "GITHUB_ACTIONS", "BUILDKITE"].some((sign) => (sign in env)) || env.CI_NAME === "codeship") {
4892
- return 1;
4893
- }
4894
- return min;
4895
- }
4896
- if ("TEAMCITY_VERSION" in env) {
4897
- return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
4898
- }
4899
- if (env.COLORTERM === "truecolor") {
4900
- return 3;
4901
- }
4902
- if ("TERM_PROGRAM" in env) {
4903
- const version = parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
4904
- switch (env.TERM_PROGRAM) {
4905
- case "iTerm.app":
4906
- return version >= 3 ? 3 : 2;
4907
- case "Apple_Terminal":
4908
- return 2;
4909
- }
4910
- }
4911
- if (/-256(color)?$/i.test(env.TERM)) {
4912
- return 2;
4913
- }
4914
- if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
4915
- return 1;
4916
- }
4917
- if ("COLORTERM" in env) {
4918
- return 1;
4919
- }
4920
- return min;
4921
- }
4922
- function getSupportLevel(stream) {
4923
- const level = supportsColor(stream, stream && stream.isTTY);
4924
- return translateLevel(level);
4925
- }
4926
- module.exports = {
4927
- supportsColor: getSupportLevel,
4928
- stdout: translateLevel(supportsColor(true, tty.isatty(1))),
4929
- stderr: translateLevel(supportsColor(true, tty.isatty(2)))
4930
- };
4931
- });
4932
-
4933
- // node_modules/debug/src/node.js
4934
- var require_node = __commonJS((exports, module) => {
4935
- var tty = __require("tty");
4936
- var util = __require("util");
4937
- exports.init = init;
4938
- exports.log = log;
4939
- exports.formatArgs = formatArgs;
4940
- exports.save = save;
4941
- exports.load = load;
4942
- exports.useColors = useColors;
4943
- exports.destroy = util.deprecate(() => {
4944
- }, "Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
4945
- exports.colors = [6, 2, 3, 4, 5, 1];
4946
- try {
4947
- const supportsColor = require_supports_color();
4948
- if (supportsColor && (supportsColor.stderr || supportsColor).level >= 2) {
4949
- exports.colors = [
4950
- 20,
4951
- 21,
4952
- 26,
4953
- 27,
4954
- 32,
4955
- 33,
4956
- 38,
4957
- 39,
4958
- 40,
4959
- 41,
4960
- 42,
4961
- 43,
4962
- 44,
4963
- 45,
4964
- 56,
4965
- 57,
4966
- 62,
4967
- 63,
4968
- 68,
4969
- 69,
4970
- 74,
4971
- 75,
4972
- 76,
4973
- 77,
4974
- 78,
4975
- 79,
4976
- 80,
4977
- 81,
4978
- 92,
4979
- 93,
4980
- 98,
4981
- 99,
4982
- 112,
4983
- 113,
4984
- 128,
4985
- 129,
4986
- 134,
4987
- 135,
4988
- 148,
4989
- 149,
4990
- 160,
4991
- 161,
4992
- 162,
4993
- 163,
4994
- 164,
4995
- 165,
4996
- 166,
4997
- 167,
4998
- 168,
4999
- 169,
5000
- 170,
5001
- 171,
5002
- 172,
5003
- 173,
5004
- 178,
5005
- 179,
5006
- 184,
5007
- 185,
5008
- 196,
5009
- 197,
5010
- 198,
5011
- 199,
5012
- 200,
5013
- 201,
5014
- 202,
5015
- 203,
5016
- 204,
5017
- 205,
5018
- 206,
5019
- 207,
5020
- 208,
5021
- 209,
5022
- 214,
5023
- 215,
5024
- 220,
5025
- 221
5026
- ];
5027
- }
5028
- } catch (error) {
5029
- }
5030
- exports.inspectOpts = Object.keys(process.env).filter((key) => {
5031
- return /^debug_/i.test(key);
5032
- }).reduce((obj, key) => {
5033
- const prop = key.substring(6).toLowerCase().replace(/_([a-z])/g, (_, k) => {
5034
- return k.toUpperCase();
5035
- });
5036
- let val = process.env[key];
5037
- if (/^(yes|on|true|enabled)$/i.test(val)) {
5038
- val = true;
5039
- } else if (/^(no|off|false|disabled)$/i.test(val)) {
5040
- val = false;
5041
- } else if (val === "null") {
5042
- val = null;
5043
- } else {
5044
- val = Number(val);
5045
- }
5046
- obj[prop] = val;
5047
- return obj;
5048
- }, {});
5049
- function useColors() {
5050
- return "colors" in exports.inspectOpts ? Boolean(exports.inspectOpts.colors) : tty.isatty(process.stderr.fd);
5051
- }
5052
- function formatArgs(args) {
5053
- const { namespace: name, useColors: useColors2 } = this;
5054
- if (useColors2) {
5055
- const c = this.color;
5056
- const colorCode = "\x1B[3" + (c < 8 ? c : "8;5;" + c);
5057
- const prefix = ` ${colorCode};1m${name} \x1B[0m`;
5058
- args[0] = prefix + args[0].split(`
5059
- `).join(`
5060
- ` + prefix);
5061
- args.push(colorCode + "m+" + module.exports.humanize(this.diff) + "\x1B[0m");
5062
- } else {
5063
- args[0] = getDate() + name + " " + args[0];
5064
- }
5065
- }
5066
- function getDate() {
5067
- if (exports.inspectOpts.hideDate) {
5068
- return "";
5069
- }
5070
- return new Date().toISOString() + " ";
5071
- }
5072
- function log(...args) {
5073
- return process.stderr.write(util.formatWithOptions(exports.inspectOpts, ...args) + `
5074
- `);
5075
- }
5076
- function save(namespaces) {
5077
- if (namespaces) {
5078
- process.env.DEBUG = namespaces;
5079
- } else {
5080
- delete process.env.DEBUG;
5081
- }
5082
- }
5083
- function load() {
5084
- return process.env.DEBUG;
5085
- }
5086
- function init(debug) {
5087
- debug.inspectOpts = {};
5088
- const keys = Object.keys(exports.inspectOpts);
5089
- for (let i2 = 0;i2 < keys.length; i2++) {
5090
- debug.inspectOpts[keys[i2]] = exports.inspectOpts[keys[i2]];
5091
- }
5092
- }
5093
- module.exports = require_common2()(exports);
5094
- var { formatters } = module.exports;
5095
- formatters.o = function(v) {
5096
- this.inspectOpts.colors = this.useColors;
5097
- return util.inspect(v, this.inspectOpts).split(`
5098
- `).map((str) => str.trim()).join(" ");
5099
- };
5100
- formatters.O = function(v) {
5101
- this.inspectOpts.colors = this.useColors;
5102
- return util.inspect(v, this.inspectOpts);
5103
- };
5104
- });
5105
-
5106
- // node_modules/debug/src/index.js
5107
- var require_src = __commonJS((exports, module) => {
5108
- if (typeof process === "undefined" || process.type === "renderer" || false || process.__nwjs) {
5109
- module.exports = require_browser();
5110
- } else {
5111
- module.exports = require_node();
5112
- }
5113
- });
5114
-
5115
5359
  // node_modules/socks-proxy-agent/dist/index.js
5116
- var require_dist2 = __commonJS((exports) => {
5117
- var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
5118
- if (k2 === undefined)
5119
- k2 = k;
5120
- var desc = Object.getOwnPropertyDescriptor(m, k);
5121
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
5122
- desc = { enumerable: true, get: function() {
5123
- return m[k];
5124
- } };
5125
- }
5126
- Object.defineProperty(o, k2, desc);
5127
- } : function(o, m, k, k2) {
5128
- if (k2 === undefined)
5129
- k2 = k;
5130
- o[k2] = m[k];
5131
- });
5132
- var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? function(o, v) {
5133
- Object.defineProperty(o, "default", { enumerable: true, value: v });
5134
- } : function(o, v) {
5135
- o["default"] = v;
5136
- });
5137
- var __importStar = exports && exports.__importStar || function(mod) {
5138
- if (mod && mod.__esModule)
5139
- return mod;
5140
- var result = {};
5141
- if (mod != null) {
5142
- for (var k in mod)
5143
- if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
5144
- __createBinding(result, mod, k);
5145
- }
5146
- __setModuleDefault(result, mod);
5147
- return result;
5148
- };
5149
- var __importDefault = exports && exports.__importDefault || function(mod) {
5150
- return mod && mod.__esModule ? mod : { default: mod };
5151
- };
5152
- Object.defineProperty(exports, "__esModule", { value: true });
5153
- exports.SocksProxyAgent = undefined;
5154
- var socks_1 = require_build();
5155
- var agent_base_1 = require_dist();
5156
- var debug_1 = __importDefault(require_src());
5157
- var dns = __importStar(__require("dns"));
5158
- var net = __importStar(__require("net"));
5159
- var tls = __importStar(__require("tls"));
5160
- var url_1 = __require("url");
5161
- var debug = (0, debug_1.default)("socks-proxy-agent");
5162
- var setServernameFromNonIpHost = (options) => {
5163
- if (options.servername === undefined && options.host && !net.isIP(options.host)) {
5164
- return {
5165
- ...options,
5166
- servername: options.host
5167
- };
5168
- }
5169
- return options;
5170
- };
5171
- function parseSocksURL(url) {
5172
- let lookup = false;
5173
- let type = 5;
5174
- const host = url.hostname;
5175
- const port = parseInt(url.port, 10) || 1080;
5176
- switch (url.protocol.replace(":", "")) {
5177
- case "socks4":
5178
- lookup = true;
5179
- type = 4;
5180
- break;
5181
- case "socks4a":
5182
- type = 4;
5183
- break;
5184
- case "socks5":
5185
- lookup = true;
5186
- type = 5;
5187
- break;
5188
- case "socks":
5189
- type = 5;
5190
- break;
5191
- case "socks5h":
5192
- type = 5;
5193
- break;
5194
- default:
5195
- throw new TypeError(`A "socks" protocol must be specified! Got: ${String(url.protocol)}`);
5196
- }
5197
- const proxy = {
5198
- host,
5199
- port,
5200
- type
5201
- };
5202
- if (url.username) {
5203
- Object.defineProperty(proxy, "userId", {
5204
- value: decodeURIComponent(url.username),
5205
- enumerable: false
5206
- });
5207
- }
5208
- if (url.password != null) {
5209
- Object.defineProperty(proxy, "password", {
5210
- value: decodeURIComponent(url.password),
5211
- enumerable: false
5212
- });
5213
- }
5214
- return { lookup, proxy };
5215
- }
5216
-
5217
- class SocksProxyAgent extends agent_base_1.Agent {
5218
- constructor(uri, opts) {
5219
- super(opts);
5220
- const url = typeof uri === "string" ? new url_1.URL(uri) : uri;
5221
- const { proxy, lookup } = parseSocksURL(url);
5222
- this.shouldLookup = lookup;
5223
- this.proxy = proxy;
5224
- this.timeout = opts?.timeout ?? null;
5225
- this.socketOptions = opts?.socketOptions ?? null;
5226
- }
5227
- async connect(req, opts) {
5228
- const { shouldLookup, proxy, timeout } = this;
5229
- if (!opts.host) {
5230
- throw new Error("No `host` defined!");
5231
- }
5232
- let { host } = opts;
5233
- const { port, lookup: lookupFn = dns.lookup } = opts;
5234
- if (shouldLookup) {
5235
- host = await new Promise((resolve, reject) => {
5236
- lookupFn(host, {}, (err, res) => {
5237
- if (err) {
5238
- reject(err);
5239
- } else {
5240
- resolve(res);
5241
- }
5242
- });
5243
- });
5244
- }
5245
- const socksOpts = {
5246
- proxy,
5247
- destination: {
5248
- host,
5249
- port: typeof port === "number" ? port : parseInt(port, 10)
5250
- },
5251
- command: "connect",
5252
- timeout: timeout ?? undefined,
5253
- socket_options: this.socketOptions ?? undefined
5254
- };
5255
- const cleanup = (tlsSocket) => {
5256
- req.destroy();
5257
- socket.destroy();
5258
- if (tlsSocket)
5259
- tlsSocket.destroy();
5260
- };
5261
- debug("Creating socks proxy connection: %o", socksOpts);
5262
- const { socket } = await socks_1.SocksClient.createConnection(socksOpts);
5263
- debug("Successfully created socks proxy connection");
5264
- if (timeout !== null) {
5265
- socket.setTimeout(timeout);
5266
- socket.on("timeout", () => cleanup());
5267
- }
5268
- if (opts.secureEndpoint) {
5269
- debug("Upgrading socket connection to TLS");
5270
- const tlsSocket = tls.connect({
5271
- ...omit(setServernameFromNonIpHost(opts), "host", "path", "port"),
5272
- socket
5273
- });
5274
- tlsSocket.once("error", (error) => {
5275
- debug("Socket TLS error", error.message);
5276
- cleanup(tlsSocket);
5277
- });
5278
- return tlsSocket;
5279
- }
5280
- return socket;
5281
- }
5282
- }
5283
- SocksProxyAgent.protocols = [
5284
- "socks",
5285
- "socks4",
5286
- "socks4a",
5287
- "socks5",
5288
- "socks5h"
5289
- ];
5290
- exports.SocksProxyAgent = SocksProxyAgent;
5291
- function omit(obj, ...keys) {
5292
- const ret = {};
5293
- let key;
5294
- for (key in obj) {
5295
- if (!keys.includes(key)) {
5296
- ret[key] = obj[key];
5297
- }
5298
- }
5299
- return ret;
5300
- }
5301
- });
5302
-
5303
- // node_modules/https-proxy-agent/dist/parse-proxy-response.js
5304
- var require_parse_proxy_response = __commonJS((exports) => {
5305
- var __importDefault = exports && exports.__importDefault || function(mod) {
5306
- return mod && mod.__esModule ? mod : { default: mod };
5307
- };
5308
- Object.defineProperty(exports, "__esModule", { value: true });
5309
- exports.parseProxyResponse = undefined;
5310
- var debug_1 = __importDefault(require_src());
5311
- var debug = (0, debug_1.default)("https-proxy-agent:parse-proxy-response");
5312
- function parseProxyResponse(socket) {
5313
- return new Promise((resolve, reject) => {
5314
- let buffersLength = 0;
5315
- const buffers = [];
5316
- function read() {
5317
- const b = socket.read();
5318
- if (b)
5319
- ondata(b);
5320
- else
5321
- socket.once("readable", read);
5322
- }
5323
- function cleanup() {
5324
- socket.removeListener("end", onend);
5325
- socket.removeListener("error", onerror);
5326
- socket.removeListener("readable", read);
5327
- }
5328
- function onend() {
5329
- cleanup();
5330
- debug("onend");
5331
- reject(new Error("Proxy connection ended before receiving CONNECT response"));
5332
- }
5333
- function onerror(err) {
5334
- cleanup();
5335
- debug("onerror %o", err);
5336
- reject(err);
5337
- }
5338
- function ondata(b) {
5339
- buffers.push(b);
5340
- buffersLength += b.length;
5341
- const buffered = Buffer.concat(buffers, buffersLength);
5342
- const endOfHeaders = buffered.indexOf(`\r
5343
- \r
5344
- `);
5345
- if (endOfHeaders === -1) {
5346
- debug("have not received end of HTTP headers yet...");
5347
- read();
5348
- return;
5349
- }
5350
- const headerParts = buffered.slice(0, endOfHeaders).toString("ascii").split(`\r
5351
- `);
5352
- const firstLine = headerParts.shift();
5353
- if (!firstLine) {
5354
- socket.destroy();
5355
- return reject(new Error("No header received from proxy CONNECT response"));
5356
- }
5357
- const firstLineParts = firstLine.split(" ");
5358
- const statusCode = +firstLineParts[1];
5359
- const statusText = firstLineParts.slice(2).join(" ");
5360
- const headers = {};
5361
- for (const header of headerParts) {
5362
- if (!header)
5363
- continue;
5364
- const firstColon = header.indexOf(":");
5365
- if (firstColon === -1) {
5366
- socket.destroy();
5367
- return reject(new Error(`Invalid header from proxy CONNECT response: "${header}"`));
5368
- }
5369
- const key = header.slice(0, firstColon).toLowerCase();
5370
- const value = header.slice(firstColon + 1).trimStart();
5371
- const current = headers[key];
5372
- if (typeof current === "string") {
5373
- headers[key] = [current, value];
5374
- } else if (Array.isArray(current)) {
5375
- current.push(value);
5376
- } else {
5377
- headers[key] = value;
5378
- }
5379
- }
5380
- debug("got proxy server response: %o %o", firstLine, headers);
5381
- cleanup();
5382
- resolve({
5383
- connect: {
5384
- statusCode,
5385
- statusText,
5386
- headers
5387
- },
5388
- buffered
5389
- });
5390
- }
5391
- socket.on("error", onerror);
5392
- socket.on("end", onend);
5393
- read();
5394
- });
5395
- }
5396
- exports.parseProxyResponse = parseProxyResponse;
5397
- });
5398
-
5399
- // node_modules/https-proxy-agent/dist/index.js
5400
5360
  var require_dist3 = __commonJS((exports) => {
5401
5361
  var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
5402
5362
  if (k2 === undefined)
@@ -5434,15 +5394,15 @@ var require_dist3 = __commonJS((exports) => {
5434
5394
  return mod && mod.__esModule ? mod : { default: mod };
5435
5395
  };
5436
5396
  Object.defineProperty(exports, "__esModule", { value: true });
5437
- exports.HttpsProxyAgent = undefined;
5397
+ exports.SocksProxyAgent = undefined;
5398
+ var socks_1 = require_build();
5399
+ var agent_base_1 = require_dist();
5400
+ var debug_1 = __importDefault(require_src());
5401
+ var dns = __importStar(__require("dns"));
5438
5402
  var net = __importStar(__require("net"));
5439
5403
  var tls = __importStar(__require("tls"));
5440
- var assert_1 = __importDefault(__require("assert"));
5441
- var debug_1 = __importDefault(require_src());
5442
- var agent_base_1 = require_dist();
5443
5404
  var url_1 = __require("url");
5444
- var parse_proxy_response_1 = require_parse_proxy_response();
5445
- var debug = (0, debug_1.default)("https-proxy-agent");
5405
+ var debug = (0, debug_1.default)("socks-proxy-agent");
5446
5406
  var setServernameFromNonIpHost = (options) => {
5447
5407
  if (options.servername === undefined && options.host && !net.isIP(options.host)) {
5448
5408
  return {
@@ -5452,86 +5412,126 @@ var require_dist3 = __commonJS((exports) => {
5452
5412
  }
5453
5413
  return options;
5454
5414
  };
5415
+ function parseSocksURL(url) {
5416
+ let lookup = false;
5417
+ let type = 5;
5418
+ const host = url.hostname;
5419
+ const port = parseInt(url.port, 10) || 1080;
5420
+ switch (url.protocol.replace(":", "")) {
5421
+ case "socks4":
5422
+ lookup = true;
5423
+ type = 4;
5424
+ break;
5425
+ case "socks4a":
5426
+ type = 4;
5427
+ break;
5428
+ case "socks5":
5429
+ lookup = true;
5430
+ type = 5;
5431
+ break;
5432
+ case "socks":
5433
+ type = 5;
5434
+ break;
5435
+ case "socks5h":
5436
+ type = 5;
5437
+ break;
5438
+ default:
5439
+ throw new TypeError(`A "socks" protocol must be specified! Got: ${String(url.protocol)}`);
5440
+ }
5441
+ const proxy = {
5442
+ host,
5443
+ port,
5444
+ type
5445
+ };
5446
+ if (url.username) {
5447
+ Object.defineProperty(proxy, "userId", {
5448
+ value: decodeURIComponent(url.username),
5449
+ enumerable: false
5450
+ });
5451
+ }
5452
+ if (url.password != null) {
5453
+ Object.defineProperty(proxy, "password", {
5454
+ value: decodeURIComponent(url.password),
5455
+ enumerable: false
5456
+ });
5457
+ }
5458
+ return { lookup, proxy };
5459
+ }
5455
5460
 
5456
- class HttpsProxyAgent extends agent_base_1.Agent {
5457
- constructor(proxy, opts) {
5461
+ class SocksProxyAgent extends agent_base_1.Agent {
5462
+ constructor(uri, opts) {
5458
5463
  super(opts);
5459
- this.options = { path: undefined };
5460
- this.proxy = typeof proxy === "string" ? new url_1.URL(proxy) : proxy;
5461
- this.proxyHeaders = opts?.headers ?? {};
5462
- debug("Creating new HttpsProxyAgent instance: %o", this.proxy.href);
5463
- const host = (this.proxy.hostname || this.proxy.host).replace(/^\[|\]$/g, "");
5464
- const port = this.proxy.port ? parseInt(this.proxy.port, 10) : this.proxy.protocol === "https:" ? 443 : 80;
5465
- this.connectOpts = {
5466
- ALPNProtocols: ["http/1.1"],
5467
- ...opts ? omit(opts, "headers") : null,
5468
- host,
5469
- port
5470
- };
5464
+ const url = typeof uri === "string" ? new url_1.URL(uri) : uri;
5465
+ const { proxy, lookup } = parseSocksURL(url);
5466
+ this.shouldLookup = lookup;
5467
+ this.proxy = proxy;
5468
+ this.timeout = opts?.timeout ?? null;
5469
+ this.socketOptions = opts?.socketOptions ?? null;
5471
5470
  }
5472
5471
  async connect(req, opts) {
5473
- const { proxy } = this;
5472
+ const { shouldLookup, proxy, timeout } = this;
5474
5473
  if (!opts.host) {
5475
- throw new TypeError('No "host" provided');
5476
- }
5477
- let socket;
5478
- if (proxy.protocol === "https:") {
5479
- debug("Creating `tls.Socket`: %o", this.connectOpts);
5480
- socket = tls.connect(setServernameFromNonIpHost(this.connectOpts));
5481
- } else {
5482
- debug("Creating `net.Socket`: %o", this.connectOpts);
5483
- socket = net.connect(this.connectOpts);
5484
- }
5485
- const headers = typeof this.proxyHeaders === "function" ? this.proxyHeaders() : { ...this.proxyHeaders };
5486
- const host = net.isIPv6(opts.host) ? `[${opts.host}]` : opts.host;
5487
- let payload = `CONNECT ${host}:${opts.port} HTTP/1.1\r
5488
- `;
5489
- if (proxy.username || proxy.password) {
5490
- const auth = `${decodeURIComponent(proxy.username)}:${decodeURIComponent(proxy.password)}`;
5491
- headers["Proxy-Authorization"] = `Basic ${Buffer.from(auth).toString("base64")}`;
5474
+ throw new Error("No `host` defined!");
5492
5475
  }
5493
- headers.Host = `${host}:${opts.port}`;
5494
- if (!headers["Proxy-Connection"]) {
5495
- headers["Proxy-Connection"] = this.keepAlive ? "Keep-Alive" : "close";
5476
+ let { host } = opts;
5477
+ const { port, lookup: lookupFn = dns.lookup } = opts;
5478
+ if (shouldLookup) {
5479
+ host = await new Promise((resolve, reject) => {
5480
+ lookupFn(host, {}, (err, res) => {
5481
+ if (err) {
5482
+ reject(err);
5483
+ } else {
5484
+ resolve(res);
5485
+ }
5486
+ });
5487
+ });
5496
5488
  }
5497
- for (const name of Object.keys(headers)) {
5498
- payload += `${name}: ${headers[name]}\r
5499
- `;
5489
+ const socksOpts = {
5490
+ proxy,
5491
+ destination: {
5492
+ host,
5493
+ port: typeof port === "number" ? port : parseInt(port, 10)
5494
+ },
5495
+ command: "connect",
5496
+ timeout: timeout ?? undefined,
5497
+ socket_options: this.socketOptions ?? undefined
5498
+ };
5499
+ const cleanup = (tlsSocket) => {
5500
+ req.destroy();
5501
+ socket.destroy();
5502
+ if (tlsSocket)
5503
+ tlsSocket.destroy();
5504
+ };
5505
+ debug("Creating socks proxy connection: %o", socksOpts);
5506
+ const { socket } = await socks_1.SocksClient.createConnection(socksOpts);
5507
+ debug("Successfully created socks proxy connection");
5508
+ if (timeout !== null) {
5509
+ socket.setTimeout(timeout);
5510
+ socket.on("timeout", () => cleanup());
5500
5511
  }
5501
- const proxyResponsePromise = (0, parse_proxy_response_1.parseProxyResponse)(socket);
5502
- socket.write(`${payload}\r
5503
- `);
5504
- const { connect, buffered } = await proxyResponsePromise;
5505
- req.emit("proxyConnect", connect);
5506
- this.emit("proxyConnect", connect, req);
5507
- if (connect.statusCode === 200) {
5508
- req.once("socket", resume);
5509
- if (opts.secureEndpoint) {
5510
- debug("Upgrading socket connection to TLS");
5511
- return tls.connect({
5512
- ...omit(setServernameFromNonIpHost(opts), "host", "path", "port"),
5513
- socket
5514
- });
5515
- }
5516
- return socket;
5512
+ if (opts.secureEndpoint) {
5513
+ debug("Upgrading socket connection to TLS");
5514
+ const tlsSocket = tls.connect({
5515
+ ...omit(setServernameFromNonIpHost(opts), "host", "path", "port"),
5516
+ socket
5517
+ });
5518
+ tlsSocket.once("error", (error) => {
5519
+ debug("Socket TLS error", error.message);
5520
+ cleanup(tlsSocket);
5521
+ });
5522
+ return tlsSocket;
5517
5523
  }
5518
- socket.destroy();
5519
- const fakeSocket = new net.Socket({ writable: false });
5520
- fakeSocket.readable = true;
5521
- req.once("socket", (s2) => {
5522
- debug("Replaying proxy buffer for failed request");
5523
- (0, assert_1.default)(s2.listenerCount("data") > 0);
5524
- s2.push(buffered);
5525
- s2.push(null);
5526
- });
5527
- return fakeSocket;
5524
+ return socket;
5528
5525
  }
5529
5526
  }
5530
- HttpsProxyAgent.protocols = ["http", "https"];
5531
- exports.HttpsProxyAgent = HttpsProxyAgent;
5532
- function resume(socket) {
5533
- socket.resume();
5534
- }
5527
+ SocksProxyAgent.protocols = [
5528
+ "socks",
5529
+ "socks4",
5530
+ "socks4a",
5531
+ "socks5",
5532
+ "socks5h"
5533
+ ];
5534
+ exports.SocksProxyAgent = SocksProxyAgent;
5535
5535
  function omit(obj, ...keys) {
5536
5536
  const ret = {};
5537
5537
  let key;
@@ -31016,6 +31016,15 @@ var require_lib2 = __commonJS((exports) => {
31016
31016
  __exportStar(require_enum(), exports);
31017
31017
  });
31018
31018
 
31019
+ // src/database.ts
31020
+ var import_https_proxy_agent = __toESM(require_dist2(), 1);
31021
+ import {
31022
+ createCipheriv,
31023
+ createDecipheriv,
31024
+ randomBytes,
31025
+ scryptSync
31026
+ } from "crypto";
31027
+
31019
31028
  // node_modules/pocketbase/dist/pocketbase.es.mjs
31020
31029
  class ClientResponseError extends Error {
31021
31030
  constructor(e) {
@@ -32102,14 +32111,7 @@ class Client {
32102
32111
  }
32103
32112
 
32104
32113
  // src/database.ts
32105
- var import_socks_proxy_agent = __toESM(require_dist2(), 1);
32106
- var import_https_proxy_agent = __toESM(require_dist3(), 1);
32107
- import {
32108
- createCipheriv,
32109
- createDecipheriv,
32110
- randomBytes,
32111
- scryptSync
32112
- } from "crypto";
32114
+ var import_socks_proxy_agent = __toESM(require_dist3(), 1);
32113
32115
  function encryptObject(obj, password) {
32114
32116
  const jsonString = JSON.stringify(obj);
32115
32117
  const salt = randomBytes(16);
@@ -32434,6 +32436,28 @@ class AppDatabase {
32434
32436
  kind
32435
32437
  });
32436
32438
  }
32439
+ async cancelLimitOrders(payload) {
32440
+ const { symbol, kind, account, cancelExchangeOrders } = payload;
32441
+ const side = kind === "long" ? "buy" : "sell";
32442
+ const orders = await this.pb.collection("orders").getFullList({
32443
+ filter: `symbol:lower="${symbol.toLowerCase()}" && account.owner:lower="${account.owner.toLowerCase()}" && account.exchange:lower="${account.exchange.toLowerCase()}" && kind="${kind}" && side:lower="${side}" && stop = 0`
32444
+ });
32445
+ const exchange_order_ids = orders.map((o) => parseInt(o.order_id, 10));
32446
+ try {
32447
+ console.log(`Attempting to cancel ${exchange_order_ids.length} orders on ${account.exchange} for ${account.owner}...`);
32448
+ const cancel_result = await cancelExchangeOrders({
32449
+ symbol,
32450
+ orders: exchange_order_ids
32451
+ });
32452
+ console.log("Exchange cancellation result:", cancel_result);
32453
+ for (const order of orders) {
32454
+ await this.pb.collection("orders").delete(order.id);
32455
+ }
32456
+ console.log("Successfully canceled orders from PocketBase.");
32457
+ } catch (error) {
32458
+ console.error("Error canceling exchange orders:", error);
32459
+ }
32460
+ }
32437
32461
  async cancelOrders(payload) {
32438
32462
  const { stop, cancelExchangeOrders, all, kind, account, symbol, price } = payload;
32439
32463
  let orders_to_cancel = [];
@@ -32572,12 +32596,12 @@ class AppDatabase {
32572
32596
  return null;
32573
32597
  }
32574
32598
  async getPositionStrategy(account) {
32575
- const _strategy_instance = await this.pb.collection("account_strategies").getFirstListItem(`account.owner:lower="${account.owner.toLowerCase()}" && account.exchange:lower="${account.exchange.toLowerCase()}"`, { expand: "strategy,focus_account" });
32576
- if (_strategy_instance) {
32577
- return {
32578
- strategy_instance: _strategy_instance?.expand?.strategy,
32579
- focus_account: _strategy_instance?.expand?.focus_account
32580
- };
32599
+ const _strategy_instance = await this.pb.collection("account_strategies").getFullList({
32600
+ filter: `account.owner:lower="${account.owner.toLowerCase()}" && account.exchange:lower="${account.exchange.toLowerCase()}"`,
32601
+ expand: "account"
32602
+ });
32603
+ if (_strategy_instance.length > 0) {
32604
+ return _strategy_instance[0];
32581
32605
  }
32582
32606
  return null;
32583
32607
  }
@@ -36372,7 +36396,7 @@ class ExchangeAccount {
36372
36396
  }
36373
36397
  }
36374
36398
  async cancelOrders(payload) {
36375
- const { symbol, kind, price: _price, all, stop } = payload;
36399
+ const { symbol, kind, price: _price, all, stop, limit } = payload;
36376
36400
  let price = _price || 0;
36377
36401
  await this.getLiveExchangeInstance({
36378
36402
  symbol,
@@ -36383,6 +36407,14 @@ class ExchangeAccount {
36383
36407
  kind,
36384
36408
  update: true
36385
36409
  });
36410
+ if (limit) {
36411
+ return await this.app_db.cancelLimitOrders({
36412
+ symbol,
36413
+ kind,
36414
+ account: this.instance,
36415
+ cancelExchangeOrders: this.cancelExchangeOrders.bind(this)
36416
+ });
36417
+ }
36386
36418
  if (all) {
36387
36419
  } else {
36388
36420
  if (!price) {
@@ -36764,6 +36796,23 @@ class ExchangeAccount {
36764
36796
  async getPositionStrategy() {
36765
36797
  return await this.app_db.getPositionStrategy(this.instance);
36766
36798
  }
36799
+ async toUpdate(payload) {
36800
+ const { refresh } = payload;
36801
+ const strategy = await this.getPositionStrategy();
36802
+ if (!strategy) {
36803
+ return;
36804
+ }
36805
+ const { symbol: _symbol, watch_symbol } = strategy;
36806
+ const watch_positions = await this.syncAccount({
36807
+ symbol: watch_symbol,
36808
+ live_refresh: refresh,
36809
+ update: true
36810
+ });
36811
+ const long_watch_position = watch_positions.find((x) => x.kind === "long");
36812
+ const short_watch_position = watch_positions.find((x) => x.kind === "short");
36813
+ if (long_watch_position.quantity === short_watch_position.quantity && long_watch_position.quantity > 0) {
36814
+ }
36815
+ }
36767
36816
  async buildReduceConfig(payload) {
36768
36817
  const positions = await this.syncAccount({
36769
36818
  symbol: payload.symbol
@@ -37094,13 +37143,24 @@ class ExchangeAccount {
37094
37143
  }
37095
37144
  }
37096
37145
  async triggerTradeFromConfig(payload) {
37097
- const { symbol, kind, place = true, stop, use_current } = payload;
37146
+ const {
37147
+ symbol,
37148
+ kind,
37149
+ place = true,
37150
+ stop,
37151
+ use_current,
37152
+ ignore_config
37153
+ } = payload;
37098
37154
  const position2 = await this.syncAccount({
37099
37155
  symbol,
37100
37156
  kind
37101
37157
  });
37102
- if (position2?.config) {
37103
- const config = position2.expand.config;
37158
+ const config = await this.getPositionConfig({
37159
+ symbol,
37160
+ kind
37161
+ });
37162
+ let condition = ignore_config ? true : position2?.config;
37163
+ if (condition) {
37104
37164
  let entry = payload.tp ? position2.entry || config.entry : config.entry;
37105
37165
  const v = stop ? "place_stop_orders" : "place_limit_orders";
37106
37166
  return await this.placeSharedOrder(v, {
@@ -37857,7 +37917,16 @@ class ExchangeAccount {
37857
37917
  return 0;
37858
37918
  }
37859
37919
  async placeTrade(payload) {
37860
- const { symbol, kind, place, tp, raw: _raw, cancel, stop } = payload;
37920
+ const {
37921
+ symbol,
37922
+ kind,
37923
+ place,
37924
+ tp,
37925
+ raw: _raw,
37926
+ cancel,
37927
+ stop,
37928
+ ignore_config
37929
+ } = payload;
37861
37930
  if (cancel) {
37862
37931
  await this.cancelOrders({
37863
37932
  symbol,
@@ -37869,7 +37938,8 @@ class ExchangeAccount {
37869
37938
  symbol,
37870
37939
  kind,
37871
37940
  raw: payload.raw,
37872
- stop
37941
+ stop,
37942
+ ignore_config
37873
37943
  });
37874
37944
  }
37875
37945
  await this.syncAccount({
@@ -37894,6 +37964,29 @@ class ExchangeAccount {
37894
37964
  }
37895
37965
  return result;
37896
37966
  }
37967
+ async updateConfigPnl(payload) {
37968
+ const { symbol, kind } = payload;
37969
+ const position2 = await this.syncAccount({
37970
+ symbol,
37971
+ kind
37972
+ });
37973
+ if (!position2?.config) {
37974
+ const config = await this.getPositionConfig({ symbol, kind });
37975
+ if (config) {
37976
+ await this.app_db.update_db_position(position2, { config: config.id });
37977
+ await this.updateTargetPnl({
37978
+ symbol,
37979
+ kind
37980
+ });
37981
+ await this.app_db.update_db_position(position2, { config: null });
37982
+ }
37983
+ } else {
37984
+ await this.updateTargetPnl({
37985
+ symbol,
37986
+ kind
37987
+ });
37988
+ }
37989
+ }
37897
37990
  }
37898
37991
  function getExchangeKlass(exchange) {
37899
37992
  const func = exchange === "binance" ? BinanceExchange : BybitExchange;
@@ -38005,96 +38098,6 @@ class App {
38005
38098
  stop: payload.stop
38006
38099
  });
38007
38100
  }
38008
- async generateConfig(payload) {
38009
- const { symbol, kind } = payload;
38010
- const exchange_account = await this.getExchangeAccount(payload.account);
38011
- let focus_position = await exchange_account.syncAccount({
38012
- symbol,
38013
- kind: kind === "long" ? "short" : "long",
38014
- as_view: true
38015
- });
38016
- if (payload.update_orders) {
38017
- await exchange_account.syncOrders({
38018
- symbol,
38019
- kind,
38020
- update: true
38021
- });
38022
- }
38023
- const current_price = await exchange_account.getCurrentPrice(symbol);
38024
- const config_instance = await exchange_account.getPositionConfig({
38025
- symbol,
38026
- kind
38027
- });
38028
- const strategy = await exchange_account.getPositionStrategy();
38029
- if (strategy?.focus_account) {
38030
- const focus_exchange_account = await this.getExchangeAccount(strategy.focus_account);
38031
- const __payload = await focus_exchange_account.syncAccount({
38032
- symbol,
38033
- kind: kind === "long" ? "short" : "long",
38034
- as_view: true
38035
- });
38036
- focus_position = __payload;
38037
- }
38038
- if (focus_position && config_instance && strategy?.strategy_instance && focus_position?.liquidation && focus_position?.take_profit && focus_position?.target_pnl) {
38039
- const { strategy_instance } = strategy;
38040
- const risk_factor = payload.kind === "long" ? strategy_instance.long_risk_factor : strategy_instance.short_risk_factor;
38041
- let entry = strategy_instance.liquidation_as_entry ? focus_position.liquidation : strategy_instance.stop_as_entry && focus_position.stop_loss?.price ? focus_position.stop_loss.price : config_instance.entry;
38042
- let stop = strategy_instance.tp_as_stop ? focus_position.take_profit : strategy_instance.entry_as_stop ? focus_position.entry : config_instance.stop;
38043
- if (entry < 0) {
38044
- entry = current_price;
38045
- }
38046
- if (!risk_factor) {
38047
- return null;
38048
- }
38049
- let config = await exchange_account.generate_config_params({
38050
- entry,
38051
- stop,
38052
- risk_reward: config_instance.risk_reward,
38053
- risk: focus_position.target_pnl * risk_factor,
38054
- symbol
38055
- });
38056
- config = {
38057
- ...config_instance,
38058
- ...config,
38059
- place_stop: strategy_instance?.place_stop || false,
38060
- profit_percent: strategy_instance?.profit_percent || config_instance.profit_percent
38061
- };
38062
- let rr = {};
38063
- if (strategy_instance.save_config) {
38064
- rr = await this.app_db.createOrUpdatePositionConfig(config_instance, {
38065
- entry: config.entry,
38066
- stop: config.stop,
38067
- risk_reward: config.risk_reward,
38068
- risk: config.risk
38069
- });
38070
- }
38071
- if (payload.place_orders) {
38072
- const promises = [
38073
- exchange_account.placeSharedOrder("place_limit_orders", {
38074
- symbol,
38075
- entry: config.entry,
38076
- stop: config.stop,
38077
- risk_reward: config.risk_reward,
38078
- risk: config.risk,
38079
- place: true
38080
- })
38081
- ];
38082
- if (config.place_stop) {
38083
- promises.push(exchange_account.placeSharedOrder("place_stop_orders", {
38084
- symbol,
38085
- entry: config.entry,
38086
- stop: config.stop,
38087
- risk_reward: config.risk_reward,
38088
- risk: config.risk,
38089
- place: true
38090
- }));
38091
- }
38092
- return await Promise.all(promises);
38093
- }
38094
- return { ...rr, ...config };
38095
- }
38096
- return null;
38097
- }
38098
38101
  async updateReduceRatio(payload) {
38099
38102
  const { symbol } = payload;
38100
38103
  const exchange_account = await this.getExchangeAccount(payload.account);