@tradejs/cli 1.0.8 → 1.0.10

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 (76) hide show
  1. package/dist/cli.js +29748 -13641
  2. package/dist/lib/aiPocketSearch.js +1316 -0
  3. package/dist/lib/aiTrainCharts.js +711 -0
  4. package/dist/lib/aiTrainDataset.js +40 -0
  5. package/dist/lib/aiTrainEvaluationDump.js +76 -0
  6. package/dist/lib/aiTrainMetrics.js +148 -8
  7. package/dist/lib/aiTrainOptions.js +130 -0
  8. package/dist/lib/aiTrainQuarantine.js +199 -0
  9. package/dist/lib/aiTrainResearch.js +467 -0
  10. package/dist/lib/binanceMarketContextBackfill.js +841 -0
  11. package/dist/lib/binanceMarketData.js +392 -0
  12. package/dist/lib/coinMarketCapContextBackfill.js +1088 -0
  13. package/dist/lib/continuity.js +60 -0
  14. package/dist/lib/derivativesContextBackfill.js +490 -77
  15. package/dist/lib/executionCalibration.js +705 -0
  16. package/dist/lib/marketContextPrepare.js +4403 -0
  17. package/dist/lib/paritySummary.js +101 -0
  18. package/dist/lib/runBot.js +1 -0
  19. package/dist/lib/runEnvironment.js +2254 -0
  20. package/dist/lib/runFormatting.js +1657 -0
  21. package/dist/lib/runtimeDebugEvidence.js +526 -0
  22. package/dist/lib/runtimeModeConfig.js +53 -0
  23. package/dist/lib/runtimeParity.js +88 -11
  24. package/dist/lib/runtimeParityDetails.js +751 -0
  25. package/dist/lib/runtimeRedis.js +157 -0
  26. package/dist/lib/runtimeSignalsLoader.js +187 -0
  27. package/dist/lib/runtimeSignalsStorage.js +185 -0
  28. package/dist/lib/runtimeStrategyBacktest.js +134 -0
  29. package/dist/lib/runtimeTradeSync.js +263 -0
  30. package/dist/lib/telegramReports.js +9 -0
  31. package/dist/lib/tickerUniverseCache.js +116 -0
  32. package/dist/lib/timeWindow.js +3 -3
  33. package/dist/scripts/agentRun.js +28 -8
  34. package/dist/scripts/aiExport.js +1721 -7
  35. package/dist/scripts/aiExportSelect.js +16 -4
  36. package/dist/scripts/aiPocketSearch.js +4190 -0
  37. package/dist/scripts/aiTrain.js +1866 -87
  38. package/dist/scripts/backtest.js +4509 -818
  39. package/dist/scripts/binanceMarketIngest.js +565 -0
  40. package/dist/scripts/bot.js +16 -2
  41. package/dist/scripts/candlesMigrateProvider.js +32 -22
  42. package/dist/scripts/cleanDir.js +15 -2
  43. package/dist/scripts/cleanRedis.js +15 -2
  44. package/dist/scripts/cleanTests.js +38 -2
  45. package/dist/scripts/cleanupMarketContext.js +69 -0
  46. package/dist/scripts/continuity.js +148 -67
  47. package/dist/scripts/derivativesIngest.js +14 -4
  48. package/dist/scripts/derivativesIngestCoinalyzeAll.js +14 -4
  49. package/dist/scripts/doctor.js +14 -4
  50. package/dist/scripts/executionCalibration.js +792 -0
  51. package/dist/scripts/infraCommon.js +10 -0
  52. package/dist/scripts/infraDown.js +14 -4
  53. package/dist/scripts/infraInit.js +24 -4
  54. package/dist/scripts/infraUp.js +14 -4
  55. package/dist/scripts/marketWs.js +222 -0
  56. package/dist/scripts/migration.js +15 -2
  57. package/dist/scripts/mlExport.js +1698 -10
  58. package/dist/scripts/mlExportSelect.js +16 -4
  59. package/dist/scripts/mlInspect.js +13 -3
  60. package/dist/scripts/mlTrainLatestSelect.js +14 -4
  61. package/dist/scripts/replay.js +8824 -0
  62. package/dist/scripts/replayRunner.js +8827 -0
  63. package/dist/scripts/replayRuntimeEvidence.js +868 -0
  64. package/dist/scripts/researchAuto.js +289 -60
  65. package/dist/scripts/results.js +3 -3
  66. package/dist/scripts/runtimeEvidence.js +605 -0
  67. package/dist/scripts/runtimeParity.js +6360 -1004
  68. package/dist/scripts/serverHealth.js +588 -0
  69. package/dist/scripts/signals.js +5623 -486
  70. package/dist/scripts/signalsDaemon.js +6167 -0
  71. package/dist/scripts/signalsSummary.js +954 -312
  72. package/dist/scripts/test-ml.js +25 -3
  73. package/dist/scripts/test.js +26 -1
  74. package/dist/scripts/user-add.js +15 -2
  75. package/dist/workers/testerWorker.js +130 -21
  76. package/package.json +18 -12
@@ -0,0 +1,2254 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __commonJS = (cb, mod) => function __require() {
9
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
10
+ };
11
+ var __export = (target, all) => {
12
+ for (var name in all)
13
+ __defProp(target, name, { get: all[name], enumerable: true });
14
+ };
15
+ var __copyProps = (to, from, except, desc) => {
16
+ if (from && typeof from === "object" || typeof from === "function") {
17
+ for (let key of __getOwnPropNames(from))
18
+ if (!__hasOwnProp.call(to, key) && key !== except)
19
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
20
+ }
21
+ return to;
22
+ };
23
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
24
+ // If the importer is in node compatibility mode or this is not an ESM
25
+ // file that has been converted to a CommonJS file using a Babel-
26
+ // compatible transform (i.e. "__esModule" has not been set), then set
27
+ // "default" to the CommonJS "module.exports" for node compatibility.
28
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
29
+ mod
30
+ ));
31
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
32
+
33
+ // ../../node_modules/debug/node_modules/ms/index.js
34
+ var require_ms = __commonJS({
35
+ "../../node_modules/debug/node_modules/ms/index.js"(exports2, module2) {
36
+ "use strict";
37
+ var s = 1e3;
38
+ var m = s * 60;
39
+ var h = m * 60;
40
+ var d = h * 24;
41
+ var w = d * 7;
42
+ var y = d * 365.25;
43
+ module2.exports = function(val, options) {
44
+ options = options || {};
45
+ var type = typeof val;
46
+ if (type === "string" && val.length > 0) {
47
+ return parse(val);
48
+ } else if (type === "number" && isFinite(val)) {
49
+ return options.long ? fmtLong(val) : fmtShort(val);
50
+ }
51
+ throw new Error(
52
+ "val is not a non-empty string or a valid number. val=" + JSON.stringify(val)
53
+ );
54
+ };
55
+ function parse(str) {
56
+ str = String(str);
57
+ if (str.length > 100) {
58
+ return;
59
+ }
60
+ 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(
61
+ str
62
+ );
63
+ if (!match) {
64
+ return;
65
+ }
66
+ var n = parseFloat(match[1]);
67
+ var type = (match[2] || "ms").toLowerCase();
68
+ switch (type) {
69
+ case "years":
70
+ case "year":
71
+ case "yrs":
72
+ case "yr":
73
+ case "y":
74
+ return n * y;
75
+ case "weeks":
76
+ case "week":
77
+ case "w":
78
+ return n * w;
79
+ case "days":
80
+ case "day":
81
+ case "d":
82
+ return n * d;
83
+ case "hours":
84
+ case "hour":
85
+ case "hrs":
86
+ case "hr":
87
+ case "h":
88
+ return n * h;
89
+ case "minutes":
90
+ case "minute":
91
+ case "mins":
92
+ case "min":
93
+ case "m":
94
+ return n * m;
95
+ case "seconds":
96
+ case "second":
97
+ case "secs":
98
+ case "sec":
99
+ case "s":
100
+ return n * s;
101
+ case "milliseconds":
102
+ case "millisecond":
103
+ case "msecs":
104
+ case "msec":
105
+ case "ms":
106
+ return n;
107
+ default:
108
+ return void 0;
109
+ }
110
+ }
111
+ function fmtShort(ms) {
112
+ var msAbs = Math.abs(ms);
113
+ if (msAbs >= d) {
114
+ return Math.round(ms / d) + "d";
115
+ }
116
+ if (msAbs >= h) {
117
+ return Math.round(ms / h) + "h";
118
+ }
119
+ if (msAbs >= m) {
120
+ return Math.round(ms / m) + "m";
121
+ }
122
+ if (msAbs >= s) {
123
+ return Math.round(ms / s) + "s";
124
+ }
125
+ return ms + "ms";
126
+ }
127
+ function fmtLong(ms) {
128
+ var msAbs = Math.abs(ms);
129
+ if (msAbs >= d) {
130
+ return plural(ms, msAbs, d, "day");
131
+ }
132
+ if (msAbs >= h) {
133
+ return plural(ms, msAbs, h, "hour");
134
+ }
135
+ if (msAbs >= m) {
136
+ return plural(ms, msAbs, m, "minute");
137
+ }
138
+ if (msAbs >= s) {
139
+ return plural(ms, msAbs, s, "second");
140
+ }
141
+ return ms + " ms";
142
+ }
143
+ function plural(ms, msAbs, n, name) {
144
+ var isPlural = msAbs >= n * 1.5;
145
+ return Math.round(ms / n) + " " + name + (isPlural ? "s" : "");
146
+ }
147
+ }
148
+ });
149
+
150
+ // ../../node_modules/debug/src/common.js
151
+ var require_common = __commonJS({
152
+ "../../node_modules/debug/src/common.js"(exports2, module2) {
153
+ "use strict";
154
+ function setup(env) {
155
+ createDebug.debug = createDebug;
156
+ createDebug.default = createDebug;
157
+ createDebug.coerce = coerce;
158
+ createDebug.disable = disable;
159
+ createDebug.enable = enable;
160
+ createDebug.enabled = enabled;
161
+ createDebug.humanize = require_ms();
162
+ createDebug.destroy = destroy;
163
+ Object.keys(env).forEach((key) => {
164
+ createDebug[key] = env[key];
165
+ });
166
+ createDebug.names = [];
167
+ createDebug.skips = [];
168
+ createDebug.formatters = {};
169
+ function selectColor(namespace) {
170
+ let hash = 0;
171
+ for (let i = 0; i < namespace.length; i++) {
172
+ hash = (hash << 5) - hash + namespace.charCodeAt(i);
173
+ hash |= 0;
174
+ }
175
+ return createDebug.colors[Math.abs(hash) % createDebug.colors.length];
176
+ }
177
+ createDebug.selectColor = selectColor;
178
+ function createDebug(namespace) {
179
+ let prevTime;
180
+ let enableOverride = null;
181
+ let namespacesCache;
182
+ let enabledCache;
183
+ function debug(...args) {
184
+ if (!debug.enabled) {
185
+ return;
186
+ }
187
+ const self = debug;
188
+ const curr = Number(/* @__PURE__ */ new Date());
189
+ const ms = curr - (prevTime || curr);
190
+ self.diff = ms;
191
+ self.prev = prevTime;
192
+ self.curr = curr;
193
+ prevTime = curr;
194
+ args[0] = createDebug.coerce(args[0]);
195
+ if (typeof args[0] !== "string") {
196
+ args.unshift("%O");
197
+ }
198
+ let index = 0;
199
+ args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format2) => {
200
+ if (match === "%%") {
201
+ return "%";
202
+ }
203
+ index++;
204
+ const formatter = createDebug.formatters[format2];
205
+ if (typeof formatter === "function") {
206
+ const val = args[index];
207
+ match = formatter.call(self, val);
208
+ args.splice(index, 1);
209
+ index--;
210
+ }
211
+ return match;
212
+ });
213
+ createDebug.formatArgs.call(self, args);
214
+ const logFn = self.log || createDebug.log;
215
+ logFn.apply(self, args);
216
+ }
217
+ debug.namespace = namespace;
218
+ debug.useColors = createDebug.useColors();
219
+ debug.color = createDebug.selectColor(namespace);
220
+ debug.extend = extend;
221
+ debug.destroy = createDebug.destroy;
222
+ Object.defineProperty(debug, "enabled", {
223
+ enumerable: true,
224
+ configurable: false,
225
+ get: () => {
226
+ if (enableOverride !== null) {
227
+ return enableOverride;
228
+ }
229
+ if (namespacesCache !== createDebug.namespaces) {
230
+ namespacesCache = createDebug.namespaces;
231
+ enabledCache = createDebug.enabled(namespace);
232
+ }
233
+ return enabledCache;
234
+ },
235
+ set: (v) => {
236
+ enableOverride = v;
237
+ }
238
+ });
239
+ if (typeof createDebug.init === "function") {
240
+ createDebug.init(debug);
241
+ }
242
+ return debug;
243
+ }
244
+ function extend(namespace, delimiter) {
245
+ const newDebug = createDebug(this.namespace + (typeof delimiter === "undefined" ? ":" : delimiter) + namespace);
246
+ newDebug.log = this.log;
247
+ return newDebug;
248
+ }
249
+ function enable(namespaces) {
250
+ createDebug.save(namespaces);
251
+ createDebug.namespaces = namespaces;
252
+ createDebug.names = [];
253
+ createDebug.skips = [];
254
+ let i;
255
+ const split = (typeof namespaces === "string" ? namespaces : "").split(/[\s,]+/);
256
+ const len = split.length;
257
+ for (i = 0; i < len; i++) {
258
+ if (!split[i]) {
259
+ continue;
260
+ }
261
+ namespaces = split[i].replace(/\*/g, ".*?");
262
+ if (namespaces[0] === "-") {
263
+ createDebug.skips.push(new RegExp("^" + namespaces.slice(1) + "$"));
264
+ } else {
265
+ createDebug.names.push(new RegExp("^" + namespaces + "$"));
266
+ }
267
+ }
268
+ }
269
+ function disable() {
270
+ const namespaces = [
271
+ ...createDebug.names.map(toNamespace),
272
+ ...createDebug.skips.map(toNamespace).map((namespace) => "-" + namespace)
273
+ ].join(",");
274
+ createDebug.enable("");
275
+ return namespaces;
276
+ }
277
+ function enabled(name) {
278
+ if (name[name.length - 1] === "*") {
279
+ return true;
280
+ }
281
+ let i;
282
+ let len;
283
+ for (i = 0, len = createDebug.skips.length; i < len; i++) {
284
+ if (createDebug.skips[i].test(name)) {
285
+ return false;
286
+ }
287
+ }
288
+ for (i = 0, len = createDebug.names.length; i < len; i++) {
289
+ if (createDebug.names[i].test(name)) {
290
+ return true;
291
+ }
292
+ }
293
+ return false;
294
+ }
295
+ function toNamespace(regexp) {
296
+ return regexp.toString().substring(2, regexp.toString().length - 2).replace(/\.\*\?$/, "*");
297
+ }
298
+ function coerce(val) {
299
+ if (val instanceof Error) {
300
+ return val.stack || val.message;
301
+ }
302
+ return val;
303
+ }
304
+ function destroy() {
305
+ console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
306
+ }
307
+ createDebug.enable(createDebug.load());
308
+ return createDebug;
309
+ }
310
+ module2.exports = setup;
311
+ }
312
+ });
313
+
314
+ // ../../node_modules/debug/src/browser.js
315
+ var require_browser = __commonJS({
316
+ "../../node_modules/debug/src/browser.js"(exports2, module2) {
317
+ "use strict";
318
+ exports2.formatArgs = formatArgs;
319
+ exports2.save = save;
320
+ exports2.load = load;
321
+ exports2.useColors = useColors;
322
+ exports2.storage = localstorage();
323
+ exports2.destroy = /* @__PURE__ */ (() => {
324
+ let warned = false;
325
+ return () => {
326
+ if (!warned) {
327
+ warned = true;
328
+ console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
329
+ }
330
+ };
331
+ })();
332
+ exports2.colors = [
333
+ "#0000CC",
334
+ "#0000FF",
335
+ "#0033CC",
336
+ "#0033FF",
337
+ "#0066CC",
338
+ "#0066FF",
339
+ "#0099CC",
340
+ "#0099FF",
341
+ "#00CC00",
342
+ "#00CC33",
343
+ "#00CC66",
344
+ "#00CC99",
345
+ "#00CCCC",
346
+ "#00CCFF",
347
+ "#3300CC",
348
+ "#3300FF",
349
+ "#3333CC",
350
+ "#3333FF",
351
+ "#3366CC",
352
+ "#3366FF",
353
+ "#3399CC",
354
+ "#3399FF",
355
+ "#33CC00",
356
+ "#33CC33",
357
+ "#33CC66",
358
+ "#33CC99",
359
+ "#33CCCC",
360
+ "#33CCFF",
361
+ "#6600CC",
362
+ "#6600FF",
363
+ "#6633CC",
364
+ "#6633FF",
365
+ "#66CC00",
366
+ "#66CC33",
367
+ "#9900CC",
368
+ "#9900FF",
369
+ "#9933CC",
370
+ "#9933FF",
371
+ "#99CC00",
372
+ "#99CC33",
373
+ "#CC0000",
374
+ "#CC0033",
375
+ "#CC0066",
376
+ "#CC0099",
377
+ "#CC00CC",
378
+ "#CC00FF",
379
+ "#CC3300",
380
+ "#CC3333",
381
+ "#CC3366",
382
+ "#CC3399",
383
+ "#CC33CC",
384
+ "#CC33FF",
385
+ "#CC6600",
386
+ "#CC6633",
387
+ "#CC9900",
388
+ "#CC9933",
389
+ "#CCCC00",
390
+ "#CCCC33",
391
+ "#FF0000",
392
+ "#FF0033",
393
+ "#FF0066",
394
+ "#FF0099",
395
+ "#FF00CC",
396
+ "#FF00FF",
397
+ "#FF3300",
398
+ "#FF3333",
399
+ "#FF3366",
400
+ "#FF3399",
401
+ "#FF33CC",
402
+ "#FF33FF",
403
+ "#FF6600",
404
+ "#FF6633",
405
+ "#FF9900",
406
+ "#FF9933",
407
+ "#FFCC00",
408
+ "#FFCC33"
409
+ ];
410
+ function useColors() {
411
+ if (typeof window !== "undefined" && window.process && (window.process.type === "renderer" || window.process.__nwjs)) {
412
+ return true;
413
+ }
414
+ if (typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
415
+ return false;
416
+ }
417
+ return typeof document !== "undefined" && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance || // Is firebug? http://stackoverflow.com/a/398120/376773
418
+ typeof window !== "undefined" && window.console && (window.console.firebug || window.console.exception && window.console.table) || // Is firefox >= v31?
419
+ // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
420
+ typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31 || // Double check webkit in userAgent just in case we are in a worker
421
+ typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/);
422
+ }
423
+ function formatArgs(args) {
424
+ args[0] = (this.useColors ? "%c" : "") + this.namespace + (this.useColors ? " %c" : " ") + args[0] + (this.useColors ? "%c " : " ") + "+" + module2.exports.humanize(this.diff);
425
+ if (!this.useColors) {
426
+ return;
427
+ }
428
+ const c = "color: " + this.color;
429
+ args.splice(1, 0, c, "color: inherit");
430
+ let index = 0;
431
+ let lastC = 0;
432
+ args[0].replace(/%[a-zA-Z%]/g, (match) => {
433
+ if (match === "%%") {
434
+ return;
435
+ }
436
+ index++;
437
+ if (match === "%c") {
438
+ lastC = index;
439
+ }
440
+ });
441
+ args.splice(lastC, 0, c);
442
+ }
443
+ exports2.log = console.debug || console.log || (() => {
444
+ });
445
+ function save(namespaces) {
446
+ try {
447
+ if (namespaces) {
448
+ exports2.storage.setItem("debug", namespaces);
449
+ } else {
450
+ exports2.storage.removeItem("debug");
451
+ }
452
+ } catch (error) {
453
+ }
454
+ }
455
+ function load() {
456
+ let r;
457
+ try {
458
+ r = exports2.storage.getItem("debug");
459
+ } catch (error) {
460
+ }
461
+ if (!r && typeof process !== "undefined" && "env" in process) {
462
+ r = process.env.DEBUG;
463
+ }
464
+ return r;
465
+ }
466
+ function localstorage() {
467
+ try {
468
+ return localStorage;
469
+ } catch (error) {
470
+ }
471
+ }
472
+ module2.exports = require_common()(exports2);
473
+ var { formatters } = module2.exports;
474
+ formatters.j = function(v) {
475
+ try {
476
+ return JSON.stringify(v);
477
+ } catch (error) {
478
+ return "[UnexpectedJSONParseError]: " + error.message;
479
+ }
480
+ };
481
+ }
482
+ });
483
+
484
+ // ../../node_modules/has-flag/index.js
485
+ var require_has_flag = __commonJS({
486
+ "../../node_modules/has-flag/index.js"(exports2, module2) {
487
+ "use strict";
488
+ module2.exports = (flag, argv = process.argv) => {
489
+ const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
490
+ const position = argv.indexOf(prefix + flag);
491
+ const terminatorPosition = argv.indexOf("--");
492
+ return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
493
+ };
494
+ }
495
+ });
496
+
497
+ // ../../node_modules/supports-color/index.js
498
+ var require_supports_color = __commonJS({
499
+ "../../node_modules/supports-color/index.js"(exports2, module2) {
500
+ "use strict";
501
+ var os = require("os");
502
+ var tty = require("tty");
503
+ var hasFlag = require_has_flag();
504
+ var { env } = process;
505
+ var flagForceColor;
506
+ if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) {
507
+ flagForceColor = 0;
508
+ } else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) {
509
+ flagForceColor = 1;
510
+ }
511
+ function envForceColor() {
512
+ if ("FORCE_COLOR" in env) {
513
+ if (env.FORCE_COLOR === "true") {
514
+ return 1;
515
+ }
516
+ if (env.FORCE_COLOR === "false") {
517
+ return 0;
518
+ }
519
+ return env.FORCE_COLOR.length === 0 ? 1 : Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3);
520
+ }
521
+ }
522
+ function translateLevel(level) {
523
+ if (level === 0) {
524
+ return false;
525
+ }
526
+ return {
527
+ level,
528
+ hasBasic: true,
529
+ has256: level >= 2,
530
+ has16m: level >= 3
531
+ };
532
+ }
533
+ function supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
534
+ const noFlagForceColor = envForceColor();
535
+ if (noFlagForceColor !== void 0) {
536
+ flagForceColor = noFlagForceColor;
537
+ }
538
+ const forceColor = sniffFlags ? flagForceColor : noFlagForceColor;
539
+ if (forceColor === 0) {
540
+ return 0;
541
+ }
542
+ if (sniffFlags) {
543
+ if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor")) {
544
+ return 3;
545
+ }
546
+ if (hasFlag("color=256")) {
547
+ return 2;
548
+ }
549
+ }
550
+ if (haveStream && !streamIsTTY && forceColor === void 0) {
551
+ return 0;
552
+ }
553
+ const min = forceColor || 0;
554
+ if (env.TERM === "dumb") {
555
+ return min;
556
+ }
557
+ if (process.platform === "win32") {
558
+ const osRelease = os.release().split(".");
559
+ if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
560
+ return Number(osRelease[2]) >= 14931 ? 3 : 2;
561
+ }
562
+ return 1;
563
+ }
564
+ if ("CI" in env) {
565
+ if (["TRAVIS", "CIRCLECI", "APPVEYOR", "GITLAB_CI", "GITHUB_ACTIONS", "BUILDKITE", "DRONE"].some((sign) => sign in env) || env.CI_NAME === "codeship") {
566
+ return 1;
567
+ }
568
+ return min;
569
+ }
570
+ if ("TEAMCITY_VERSION" in env) {
571
+ return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
572
+ }
573
+ if (env.COLORTERM === "truecolor") {
574
+ return 3;
575
+ }
576
+ if ("TERM_PROGRAM" in env) {
577
+ const version = Number.parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
578
+ switch (env.TERM_PROGRAM) {
579
+ case "iTerm.app":
580
+ return version >= 3 ? 3 : 2;
581
+ case "Apple_Terminal":
582
+ return 2;
583
+ }
584
+ }
585
+ if (/-256(color)?$/i.test(env.TERM)) {
586
+ return 2;
587
+ }
588
+ if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
589
+ return 1;
590
+ }
591
+ if ("COLORTERM" in env) {
592
+ return 1;
593
+ }
594
+ return min;
595
+ }
596
+ function getSupportLevel(stream, options = {}) {
597
+ const level = supportsColor(stream, {
598
+ streamIsTTY: stream && stream.isTTY,
599
+ ...options
600
+ });
601
+ return translateLevel(level);
602
+ }
603
+ module2.exports = {
604
+ supportsColor: getSupportLevel,
605
+ stdout: getSupportLevel({ isTTY: tty.isatty(1) }),
606
+ stderr: getSupportLevel({ isTTY: tty.isatty(2) })
607
+ };
608
+ }
609
+ });
610
+
611
+ // ../../node_modules/debug/src/node.js
612
+ var require_node = __commonJS({
613
+ "../../node_modules/debug/src/node.js"(exports2, module2) {
614
+ "use strict";
615
+ var tty = require("tty");
616
+ var util = require("util");
617
+ exports2.init = init;
618
+ exports2.log = log;
619
+ exports2.formatArgs = formatArgs;
620
+ exports2.save = save;
621
+ exports2.load = load;
622
+ exports2.useColors = useColors;
623
+ exports2.destroy = util.deprecate(
624
+ () => {
625
+ },
626
+ "Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."
627
+ );
628
+ exports2.colors = [6, 2, 3, 4, 5, 1];
629
+ try {
630
+ const supportsColor = require_supports_color();
631
+ if (supportsColor && (supportsColor.stderr || supportsColor).level >= 2) {
632
+ exports2.colors = [
633
+ 20,
634
+ 21,
635
+ 26,
636
+ 27,
637
+ 32,
638
+ 33,
639
+ 38,
640
+ 39,
641
+ 40,
642
+ 41,
643
+ 42,
644
+ 43,
645
+ 44,
646
+ 45,
647
+ 56,
648
+ 57,
649
+ 62,
650
+ 63,
651
+ 68,
652
+ 69,
653
+ 74,
654
+ 75,
655
+ 76,
656
+ 77,
657
+ 78,
658
+ 79,
659
+ 80,
660
+ 81,
661
+ 92,
662
+ 93,
663
+ 98,
664
+ 99,
665
+ 112,
666
+ 113,
667
+ 128,
668
+ 129,
669
+ 134,
670
+ 135,
671
+ 148,
672
+ 149,
673
+ 160,
674
+ 161,
675
+ 162,
676
+ 163,
677
+ 164,
678
+ 165,
679
+ 166,
680
+ 167,
681
+ 168,
682
+ 169,
683
+ 170,
684
+ 171,
685
+ 172,
686
+ 173,
687
+ 178,
688
+ 179,
689
+ 184,
690
+ 185,
691
+ 196,
692
+ 197,
693
+ 198,
694
+ 199,
695
+ 200,
696
+ 201,
697
+ 202,
698
+ 203,
699
+ 204,
700
+ 205,
701
+ 206,
702
+ 207,
703
+ 208,
704
+ 209,
705
+ 214,
706
+ 215,
707
+ 220,
708
+ 221
709
+ ];
710
+ }
711
+ } catch (error) {
712
+ }
713
+ exports2.inspectOpts = Object.keys(process.env).filter((key) => {
714
+ return /^debug_/i.test(key);
715
+ }).reduce((obj, key) => {
716
+ const prop = key.substring(6).toLowerCase().replace(/_([a-z])/g, (_, k) => {
717
+ return k.toUpperCase();
718
+ });
719
+ let val = process.env[key];
720
+ if (/^(yes|on|true|enabled)$/i.test(val)) {
721
+ val = true;
722
+ } else if (/^(no|off|false|disabled)$/i.test(val)) {
723
+ val = false;
724
+ } else if (val === "null") {
725
+ val = null;
726
+ } else {
727
+ val = Number(val);
728
+ }
729
+ obj[prop] = val;
730
+ return obj;
731
+ }, {});
732
+ function useColors() {
733
+ return "colors" in exports2.inspectOpts ? Boolean(exports2.inspectOpts.colors) : tty.isatty(process.stderr.fd);
734
+ }
735
+ function formatArgs(args) {
736
+ const { namespace: name, useColors: useColors2 } = this;
737
+ if (useColors2) {
738
+ const c = this.color;
739
+ const colorCode = "\x1B[3" + (c < 8 ? c : "8;5;" + c);
740
+ const prefix = ` ${colorCode};1m${name} \x1B[0m`;
741
+ args[0] = prefix + args[0].split("\n").join("\n" + prefix);
742
+ args.push(colorCode + "m+" + module2.exports.humanize(this.diff) + "\x1B[0m");
743
+ } else {
744
+ args[0] = getDate() + name + " " + args[0];
745
+ }
746
+ }
747
+ function getDate() {
748
+ if (exports2.inspectOpts.hideDate) {
749
+ return "";
750
+ }
751
+ return (/* @__PURE__ */ new Date()).toISOString() + " ";
752
+ }
753
+ function log(...args) {
754
+ return process.stderr.write(util.format(...args) + "\n");
755
+ }
756
+ function save(namespaces) {
757
+ if (namespaces) {
758
+ process.env.DEBUG = namespaces;
759
+ } else {
760
+ delete process.env.DEBUG;
761
+ }
762
+ }
763
+ function load() {
764
+ return process.env.DEBUG;
765
+ }
766
+ function init(debug) {
767
+ debug.inspectOpts = {};
768
+ const keys = Object.keys(exports2.inspectOpts);
769
+ for (let i = 0; i < keys.length; i++) {
770
+ debug.inspectOpts[keys[i]] = exports2.inspectOpts[keys[i]];
771
+ }
772
+ }
773
+ module2.exports = require_common()(exports2);
774
+ var { formatters } = module2.exports;
775
+ formatters.o = function(v) {
776
+ this.inspectOpts.colors = this.useColors;
777
+ return util.inspect(v, this.inspectOpts).split("\n").map((str) => str.trim()).join(" ");
778
+ };
779
+ formatters.O = function(v) {
780
+ this.inspectOpts.colors = this.useColors;
781
+ return util.inspect(v, this.inspectOpts);
782
+ };
783
+ }
784
+ });
785
+
786
+ // ../../node_modules/debug/src/index.js
787
+ var require_src = __commonJS({
788
+ "../../node_modules/debug/src/index.js"(exports2, module2) {
789
+ "use strict";
790
+ if (typeof process === "undefined" || process.type === "renderer" || process.browser === true || process.__nwjs) {
791
+ module2.exports = require_browser();
792
+ } else {
793
+ module2.exports = require_node();
794
+ }
795
+ }
796
+ });
797
+
798
+ // ../../node_modules/eastasianwidth/eastasianwidth.js
799
+ var require_eastasianwidth = __commonJS({
800
+ "../../node_modules/eastasianwidth/eastasianwidth.js"(exports2, module2) {
801
+ "use strict";
802
+ var eaw = {};
803
+ if ("undefined" == typeof module2) {
804
+ window.eastasianwidth = eaw;
805
+ } else {
806
+ module2.exports = eaw;
807
+ }
808
+ eaw.eastAsianWidth = function(character) {
809
+ var x = character.charCodeAt(0);
810
+ var y = character.length == 2 ? character.charCodeAt(1) : 0;
811
+ var codePoint = x;
812
+ if (55296 <= x && x <= 56319 && (56320 <= y && y <= 57343)) {
813
+ x &= 1023;
814
+ y &= 1023;
815
+ codePoint = x << 10 | y;
816
+ codePoint += 65536;
817
+ }
818
+ if (12288 == codePoint || 65281 <= codePoint && codePoint <= 65376 || 65504 <= codePoint && codePoint <= 65510) {
819
+ return "F";
820
+ }
821
+ if (8361 == codePoint || 65377 <= codePoint && codePoint <= 65470 || 65474 <= codePoint && codePoint <= 65479 || 65482 <= codePoint && codePoint <= 65487 || 65490 <= codePoint && codePoint <= 65495 || 65498 <= codePoint && codePoint <= 65500 || 65512 <= codePoint && codePoint <= 65518) {
822
+ return "H";
823
+ }
824
+ if (4352 <= codePoint && codePoint <= 4447 || 4515 <= codePoint && codePoint <= 4519 || 4602 <= codePoint && codePoint <= 4607 || 9001 <= codePoint && codePoint <= 9002 || 11904 <= codePoint && codePoint <= 11929 || 11931 <= codePoint && codePoint <= 12019 || 12032 <= codePoint && codePoint <= 12245 || 12272 <= codePoint && codePoint <= 12283 || 12289 <= codePoint && codePoint <= 12350 || 12353 <= codePoint && codePoint <= 12438 || 12441 <= codePoint && codePoint <= 12543 || 12549 <= codePoint && codePoint <= 12589 || 12593 <= codePoint && codePoint <= 12686 || 12688 <= codePoint && codePoint <= 12730 || 12736 <= codePoint && codePoint <= 12771 || 12784 <= codePoint && codePoint <= 12830 || 12832 <= codePoint && codePoint <= 12871 || 12880 <= codePoint && codePoint <= 13054 || 13056 <= codePoint && codePoint <= 19903 || 19968 <= codePoint && codePoint <= 42124 || 42128 <= codePoint && codePoint <= 42182 || 43360 <= codePoint && codePoint <= 43388 || 44032 <= codePoint && codePoint <= 55203 || 55216 <= codePoint && codePoint <= 55238 || 55243 <= codePoint && codePoint <= 55291 || 63744 <= codePoint && codePoint <= 64255 || 65040 <= codePoint && codePoint <= 65049 || 65072 <= codePoint && codePoint <= 65106 || 65108 <= codePoint && codePoint <= 65126 || 65128 <= codePoint && codePoint <= 65131 || 110592 <= codePoint && codePoint <= 110593 || 127488 <= codePoint && codePoint <= 127490 || 127504 <= codePoint && codePoint <= 127546 || 127552 <= codePoint && codePoint <= 127560 || 127568 <= codePoint && codePoint <= 127569 || 131072 <= codePoint && codePoint <= 194367 || 177984 <= codePoint && codePoint <= 196605 || 196608 <= codePoint && codePoint <= 262141) {
825
+ return "W";
826
+ }
827
+ if (32 <= codePoint && codePoint <= 126 || 162 <= codePoint && codePoint <= 163 || 165 <= codePoint && codePoint <= 166 || 172 == codePoint || 175 == codePoint || 10214 <= codePoint && codePoint <= 10221 || 10629 <= codePoint && codePoint <= 10630) {
828
+ return "Na";
829
+ }
830
+ if (161 == codePoint || 164 == codePoint || 167 <= codePoint && codePoint <= 168 || 170 == codePoint || 173 <= codePoint && codePoint <= 174 || 176 <= codePoint && codePoint <= 180 || 182 <= codePoint && codePoint <= 186 || 188 <= codePoint && codePoint <= 191 || 198 == codePoint || 208 == codePoint || 215 <= codePoint && codePoint <= 216 || 222 <= codePoint && codePoint <= 225 || 230 == codePoint || 232 <= codePoint && codePoint <= 234 || 236 <= codePoint && codePoint <= 237 || 240 == codePoint || 242 <= codePoint && codePoint <= 243 || 247 <= codePoint && codePoint <= 250 || 252 == codePoint || 254 == codePoint || 257 == codePoint || 273 == codePoint || 275 == codePoint || 283 == codePoint || 294 <= codePoint && codePoint <= 295 || 299 == codePoint || 305 <= codePoint && codePoint <= 307 || 312 == codePoint || 319 <= codePoint && codePoint <= 322 || 324 == codePoint || 328 <= codePoint && codePoint <= 331 || 333 == codePoint || 338 <= codePoint && codePoint <= 339 || 358 <= codePoint && codePoint <= 359 || 363 == codePoint || 462 == codePoint || 464 == codePoint || 466 == codePoint || 468 == codePoint || 470 == codePoint || 472 == codePoint || 474 == codePoint || 476 == codePoint || 593 == codePoint || 609 == codePoint || 708 == codePoint || 711 == codePoint || 713 <= codePoint && codePoint <= 715 || 717 == codePoint || 720 == codePoint || 728 <= codePoint && codePoint <= 731 || 733 == codePoint || 735 == codePoint || 768 <= codePoint && codePoint <= 879 || 913 <= codePoint && codePoint <= 929 || 931 <= codePoint && codePoint <= 937 || 945 <= codePoint && codePoint <= 961 || 963 <= codePoint && codePoint <= 969 || 1025 == codePoint || 1040 <= codePoint && codePoint <= 1103 || 1105 == codePoint || 8208 == codePoint || 8211 <= codePoint && codePoint <= 8214 || 8216 <= codePoint && codePoint <= 8217 || 8220 <= codePoint && codePoint <= 8221 || 8224 <= codePoint && codePoint <= 8226 || 8228 <= codePoint && codePoint <= 8231 || 8240 == codePoint || 8242 <= codePoint && codePoint <= 8243 || 8245 == codePoint || 8251 == codePoint || 8254 == codePoint || 8308 == codePoint || 8319 == codePoint || 8321 <= codePoint && codePoint <= 8324 || 8364 == codePoint || 8451 == codePoint || 8453 == codePoint || 8457 == codePoint || 8467 == codePoint || 8470 == codePoint || 8481 <= codePoint && codePoint <= 8482 || 8486 == codePoint || 8491 == codePoint || 8531 <= codePoint && codePoint <= 8532 || 8539 <= codePoint && codePoint <= 8542 || 8544 <= codePoint && codePoint <= 8555 || 8560 <= codePoint && codePoint <= 8569 || 8585 == codePoint || 8592 <= codePoint && codePoint <= 8601 || 8632 <= codePoint && codePoint <= 8633 || 8658 == codePoint || 8660 == codePoint || 8679 == codePoint || 8704 == codePoint || 8706 <= codePoint && codePoint <= 8707 || 8711 <= codePoint && codePoint <= 8712 || 8715 == codePoint || 8719 == codePoint || 8721 == codePoint || 8725 == codePoint || 8730 == codePoint || 8733 <= codePoint && codePoint <= 8736 || 8739 == codePoint || 8741 == codePoint || 8743 <= codePoint && codePoint <= 8748 || 8750 == codePoint || 8756 <= codePoint && codePoint <= 8759 || 8764 <= codePoint && codePoint <= 8765 || 8776 == codePoint || 8780 == codePoint || 8786 == codePoint || 8800 <= codePoint && codePoint <= 8801 || 8804 <= codePoint && codePoint <= 8807 || 8810 <= codePoint && codePoint <= 8811 || 8814 <= codePoint && codePoint <= 8815 || 8834 <= codePoint && codePoint <= 8835 || 8838 <= codePoint && codePoint <= 8839 || 8853 == codePoint || 8857 == codePoint || 8869 == codePoint || 8895 == codePoint || 8978 == codePoint || 9312 <= codePoint && codePoint <= 9449 || 9451 <= codePoint && codePoint <= 9547 || 9552 <= codePoint && codePoint <= 9587 || 9600 <= codePoint && codePoint <= 9615 || 9618 <= codePoint && codePoint <= 9621 || 9632 <= codePoint && codePoint <= 9633 || 9635 <= codePoint && codePoint <= 9641 || 9650 <= codePoint && codePoint <= 9651 || 9654 <= codePoint && codePoint <= 9655 || 9660 <= codePoint && codePoint <= 9661 || 9664 <= codePoint && codePoint <= 9665 || 9670 <= codePoint && codePoint <= 9672 || 9675 == codePoint || 9678 <= codePoint && codePoint <= 9681 || 9698 <= codePoint && codePoint <= 9701 || 9711 == codePoint || 9733 <= codePoint && codePoint <= 9734 || 9737 == codePoint || 9742 <= codePoint && codePoint <= 9743 || 9748 <= codePoint && codePoint <= 9749 || 9756 == codePoint || 9758 == codePoint || 9792 == codePoint || 9794 == codePoint || 9824 <= codePoint && codePoint <= 9825 || 9827 <= codePoint && codePoint <= 9829 || 9831 <= codePoint && codePoint <= 9834 || 9836 <= codePoint && codePoint <= 9837 || 9839 == codePoint || 9886 <= codePoint && codePoint <= 9887 || 9918 <= codePoint && codePoint <= 9919 || 9924 <= codePoint && codePoint <= 9933 || 9935 <= codePoint && codePoint <= 9953 || 9955 == codePoint || 9960 <= codePoint && codePoint <= 9983 || 10045 == codePoint || 10071 == codePoint || 10102 <= codePoint && codePoint <= 10111 || 11093 <= codePoint && codePoint <= 11097 || 12872 <= codePoint && codePoint <= 12879 || 57344 <= codePoint && codePoint <= 63743 || 65024 <= codePoint && codePoint <= 65039 || 65533 == codePoint || 127232 <= codePoint && codePoint <= 127242 || 127248 <= codePoint && codePoint <= 127277 || 127280 <= codePoint && codePoint <= 127337 || 127344 <= codePoint && codePoint <= 127386 || 917760 <= codePoint && codePoint <= 917999 || 983040 <= codePoint && codePoint <= 1048573 || 1048576 <= codePoint && codePoint <= 1114109) {
831
+ return "A";
832
+ }
833
+ return "N";
834
+ };
835
+ eaw.characterLength = function(character) {
836
+ var code = this.eastAsianWidth(character);
837
+ if (code == "F" || code == "W" || code == "A") {
838
+ return 2;
839
+ } else {
840
+ return 1;
841
+ }
842
+ };
843
+ function stringToArray(string) {
844
+ return string.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[^\uD800-\uDFFF]/g) || [];
845
+ }
846
+ eaw.length = function(string) {
847
+ var characters = stringToArray(string);
848
+ var len = 0;
849
+ for (var i = 0; i < characters.length; i++) {
850
+ len = len + this.characterLength(characters[i]);
851
+ }
852
+ return len;
853
+ };
854
+ eaw.slice = function(text, start, end) {
855
+ textLen = eaw.length(text);
856
+ start = start ? start : 0;
857
+ end = end ? end : 1;
858
+ if (start < 0) {
859
+ start = textLen + start;
860
+ }
861
+ if (end < 0) {
862
+ end = textLen + end;
863
+ }
864
+ var result = "";
865
+ var eawLen = 0;
866
+ var chars = stringToArray(text);
867
+ for (var i = 0; i < chars.length; i++) {
868
+ var char = chars[i];
869
+ var charLen = eaw.length(char);
870
+ if (eawLen >= start - (charLen == 2 ? 1 : 0)) {
871
+ if (eawLen + charLen <= end) {
872
+ result += char;
873
+ } else {
874
+ break;
875
+ }
876
+ }
877
+ eawLen += charLen;
878
+ }
879
+ return result;
880
+ };
881
+ }
882
+ });
883
+
884
+ // ../../node_modules/list-it/lib/data-cell.js
885
+ var require_data_cell = __commonJS({
886
+ "../../node_modules/list-it/lib/data-cell.js"(exports2, module2) {
887
+ "use strict";
888
+ var eaw = require_eastasianwidth();
889
+ function DataCell() {
890
+ this.data = "";
891
+ }
892
+ module2.exports = DataCell;
893
+ DataCell.prototype.getData = function() {
894
+ return this.data;
895
+ };
896
+ DataCell.prototype.setData = function(data) {
897
+ this.data = data;
898
+ };
899
+ DataCell.prototype.visibleLength = function() {
900
+ if (typeof this.data != "string") {
901
+ return ("" + this.data).length;
902
+ }
903
+ return DataCell.visibleLength(this.data);
904
+ };
905
+ DataCell.visibleLength = function(data) {
906
+ const s = data.replace(/\x1b[^m]*m/g, "");
907
+ return eaw.length(s);
908
+ };
909
+ }
910
+ });
911
+
912
+ // ../../node_modules/list-it/lib/row.js
913
+ var require_row = __commonJS({
914
+ "../../node_modules/list-it/lib/row.js"(exports2, module2) {
915
+ "use strict";
916
+ function Row() {
917
+ this.cells = [];
918
+ this.empty = true;
919
+ this.fixed = false;
920
+ }
921
+ module2.exports = Row;
922
+ Row.prototype.getCellLength = function() {
923
+ return this.cells.length;
924
+ };
925
+ Row.prototype.getCell = function(idx) {
926
+ return this.cells[idx];
927
+ };
928
+ Row.prototype.pushCell = function(cell) {
929
+ if (this.isFixed()) {
930
+ throw "pushCell Fail, The row was already fixed.";
931
+ }
932
+ this.empty = false;
933
+ return this.cells.push(cell);
934
+ };
935
+ Row.prototype.fix = function() {
936
+ this.fixed = true;
937
+ };
938
+ Row.prototype.isEmpty = function() {
939
+ return this.empty;
940
+ };
941
+ Row.prototype.isFixed = function() {
942
+ return this.fixed;
943
+ };
944
+ }
945
+ });
946
+
947
+ // ../../node_modules/list-it/lib/column.js
948
+ var require_column = __commonJS({
949
+ "../../node_modules/list-it/lib/column.js"(exports2, module2) {
950
+ "use strict";
951
+ var DataCell = require_data_cell();
952
+ function Column() {
953
+ this.opt = {
954
+ "autoAlign": false
955
+ };
956
+ this.width = 0;
957
+ this.textWidth = null;
958
+ this.intLen = 0;
959
+ this.fracLen = 0;
960
+ this.expLen = 0;
961
+ this.cellAtRow = {};
962
+ this.header = null;
963
+ }
964
+ module2.exports = Column;
965
+ Column.prototype.getWidth = function() {
966
+ return this.width;
967
+ };
968
+ Column.prototype.setTextWidth = function(textWidth) {
969
+ this.textWidth = textWidth;
970
+ };
971
+ Column.prototype.setCellAt = function(row, cell) {
972
+ this.cellAtRow[row] = cell;
973
+ };
974
+ Column.prototype.setHeader = function(header) {
975
+ this.header = header;
976
+ };
977
+ Column.prototype.hasHeader = function() {
978
+ return this.header != null;
979
+ };
980
+ Column.prototype.updateWidth = function() {
981
+ const headerWidth = !this.hasHeader() ? 0 : DataCell.visibleLength("" + this.header);
982
+ this.width = headerWidth;
983
+ Object.keys(this.cellAtRow).forEach((key) => {
984
+ const cell = this.cellAtRow[key];
985
+ const data = cell.getData();
986
+ let width = cell.visibleLength();
987
+ if (typeof data == "number") {
988
+ if (this.opt.autoAlign) {
989
+ this.updateNumWidth(data);
990
+ width = this.getNumMaxWidth();
991
+ }
992
+ }
993
+ if (width > this.width) {
994
+ this.width = width;
995
+ }
996
+ if (typeof data == "string") {
997
+ if (this.textWidth && this.textWidth > headerWidth) {
998
+ if (this.width > this.textWidth) {
999
+ this.width = this.textWidth;
1000
+ }
1001
+ }
1002
+ }
1003
+ });
1004
+ };
1005
+ Column.prototype.formatColumnHeader = function() {
1006
+ if (!this.hasHeader()) {
1007
+ return null;
1008
+ }
1009
+ const width = this.getWidth();
1010
+ const header = this.header;
1011
+ const headerWidth = DataCell.visibleLength("" + header);
1012
+ if (header.length == headerWidth && width - headerWidth <= 0) {
1013
+ return ("" + header).substring(0, width);
1014
+ }
1015
+ return "" + header + " ".repeat(width - headerWidth);
1016
+ };
1017
+ Column.prototype.formatCell = function(data) {
1018
+ const width = this.getWidth();
1019
+ if (this.opt.autoAlign) {
1020
+ if (typeof data == "number") {
1021
+ return this.makeAutoAlignNum(data).padStart(width, " ");
1022
+ }
1023
+ }
1024
+ const dataWidth = DataCell.visibleLength("" + data);
1025
+ if (data.length == dataWidth && width - dataWidth <= 0) {
1026
+ return ("" + data).substring(0, width);
1027
+ }
1028
+ return "" + data + " ".repeat(width - dataWidth);
1029
+ };
1030
+ Column.prototype.setAutoAlign = function(autoAlign) {
1031
+ this.opt.autoAlign = autoAlign;
1032
+ };
1033
+ Column.prototype.updateNumWidth = function(num) {
1034
+ const numInfo = this.analyzeNumber(num);
1035
+ const intLen = numInfo.intStr.length;
1036
+ const fracLen = numInfo.fracStr.length;
1037
+ const expLen = numInfo.expStr.length;
1038
+ if (intLen > this.intLen) {
1039
+ this.intLen = intLen;
1040
+ }
1041
+ if (fracLen > this.fracLen) {
1042
+ this.fracLen = fracLen;
1043
+ }
1044
+ if (expLen > this.expLen) {
1045
+ this.expLen = expLen;
1046
+ }
1047
+ };
1048
+ Column.prototype.getNumMaxWidth = function() {
1049
+ return this.intLen + this.fracLen + (this.fracLen > 0 ? 1 : 0) + this.expLen + (this.expLen > 0 ? 1 : 0);
1050
+ };
1051
+ Column.prototype.makeAutoAlignNum = function(num) {
1052
+ const numInfo = this.analyzeNumber(num);
1053
+ const intStr = numInfo.intStr.padStart(this.intLen, " ");
1054
+ const fracStr = numInfo.expStr != "" ? numInfo.fracStr.padEnd(this.fracLen, "0") : numInfo.fracStr.padEnd(this.fracLen, " ");
1055
+ const expStr = numInfo.expStr.padEnd(this.expLen, " ");
1056
+ if (numInfo.expStr != "") {
1057
+ return [intStr, ".", fracStr, "e", expStr].join("");
1058
+ }
1059
+ if (numInfo.pointPos >= 0) {
1060
+ if (this.expLen > 0) {
1061
+ return [intStr, ".", fracStr, " ", expStr].join("");
1062
+ }
1063
+ return [intStr, ".", fracStr].join("");
1064
+ } else if (this.fracLen == 0) {
1065
+ return intStr;
1066
+ }
1067
+ if (this.expLen > 0) {
1068
+ return [intStr, ".0", fracStr.substr(1), " ", expStr].join("");
1069
+ }
1070
+ return [intStr, ".0", fracStr.substr(1)].join("");
1071
+ };
1072
+ Column.prototype.analyzeNumber = function(num) {
1073
+ const s = "" + num;
1074
+ let intStr = "";
1075
+ let fracStr = "";
1076
+ const pointPos = s.indexOf(".");
1077
+ const expIndex = s.indexOf("e");
1078
+ if (expIndex >= 0) {
1079
+ if (pointPos < 0) {
1080
+ return {
1081
+ pointPos: expIndex,
1082
+ intStr: s.substr(0, expIndex),
1083
+ fracStr: "0",
1084
+ expStr: s.substr(expIndex + 1)
1085
+ };
1086
+ }
1087
+ return {
1088
+ pointPos,
1089
+ intStr: s.substr(0, pointPos),
1090
+ fracStr: s.substring(pointPos + 1, expIndex),
1091
+ expStr: s.substr(expIndex + 1)
1092
+ };
1093
+ }
1094
+ if (pointPos < 0) {
1095
+ intStr = s;
1096
+ } else {
1097
+ intStr = s.substr(0, pointPos);
1098
+ fracStr = s.substr(pointPos + 1);
1099
+ }
1100
+ return {
1101
+ "pointPos": pointPos,
1102
+ "intStr": intStr,
1103
+ "fracStr": fracStr,
1104
+ "expStr": ""
1105
+ };
1106
+ };
1107
+ }
1108
+ });
1109
+
1110
+ // ../../node_modules/ansi-escape-sequences/dist/index.cjs
1111
+ var require_dist = __commonJS({
1112
+ "../../node_modules/ansi-escape-sequences/dist/index.cjs"(exports2, module2) {
1113
+ "use strict";
1114
+ function isObject(input) {
1115
+ return typeof input === "object" && input !== null;
1116
+ }
1117
+ function isArrayLike(input) {
1118
+ return isObject(input) && typeof input.length === "number";
1119
+ }
1120
+ function arrayify(input) {
1121
+ if (Array.isArray(input)) {
1122
+ return input;
1123
+ } else if (input === void 0) {
1124
+ return [];
1125
+ } else if (isArrayLike(input) || input instanceof Set) {
1126
+ return Array.from(input);
1127
+ } else {
1128
+ return [input];
1129
+ }
1130
+ }
1131
+ var csi = "\x1B[";
1132
+ var ansi = {};
1133
+ ansi.style = {
1134
+ reset: "\x1B[0m",
1135
+ bold: "\x1B[1m",
1136
+ italic: "\x1B[3m",
1137
+ underline: "\x1B[4m",
1138
+ fontDefault: "\x1B[10m",
1139
+ font2: "\x1B[11m",
1140
+ font3: "\x1B[12m",
1141
+ font4: "\x1B[13m",
1142
+ font5: "\x1B[14m",
1143
+ font6: "\x1B[15m",
1144
+ imageNegative: "\x1B[7m",
1145
+ imagePositive: "\x1B[27m",
1146
+ black: "\x1B[30m",
1147
+ red: "\x1B[31m",
1148
+ green: "\x1B[32m",
1149
+ yellow: "\x1B[33m",
1150
+ blue: "\x1B[34m",
1151
+ magenta: "\x1B[35m",
1152
+ cyan: "\x1B[36m",
1153
+ white: "\x1B[37m",
1154
+ grey: "\x1B[90m",
1155
+ gray: "\x1B[90m",
1156
+ brightRed: "\x1B[91m",
1157
+ brightGreen: "\x1B[92m",
1158
+ brightYellow: "\x1B[93m",
1159
+ brightBlue: "\x1B[94m",
1160
+ brightMagenta: "\x1B[95m",
1161
+ brightCyan: "\x1B[96m",
1162
+ brightWhite: "\x1B[97m",
1163
+ "bg-black": "\x1B[40m",
1164
+ "bg-red": "\x1B[41m",
1165
+ "bg-green": "\x1B[42m",
1166
+ "bg-yellow": "\x1B[43m",
1167
+ "bg-blue": "\x1B[44m",
1168
+ "bg-magenta": "\x1B[45m",
1169
+ "bg-cyan": "\x1B[46m",
1170
+ "bg-white": "\x1B[47m",
1171
+ "bg-grey": "\x1B[100m",
1172
+ "bg-gray": "\x1B[100m",
1173
+ "bg-brightRed": "\x1B[101m",
1174
+ "bg-brightGreen": "\x1B[102m",
1175
+ "bg-brightYellow": "\x1B[103m",
1176
+ "bg-brightBlue": "\x1B[104m",
1177
+ "bg-brightMagenta": "\x1B[105m",
1178
+ "bg-brightCyan": "\x1B[106m",
1179
+ "bg-brightWhite": "\x1B[107m"
1180
+ };
1181
+ ansi.rgb = function(r, g, b) {
1182
+ return `\x1B[38;2;${r};${g};${b}m`;
1183
+ };
1184
+ ansi.bgRgb = function(r, g, b) {
1185
+ return `\x1B[48;2;${r};${g};${b}m`;
1186
+ };
1187
+ ansi.styles = function(styles) {
1188
+ styles = arrayify(styles);
1189
+ return styles.map(function(effect) {
1190
+ const rgbMatches = effect.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);
1191
+ const bgRgbMatches = effect.match(/bg-rgb\((\d+),\s*(\d+),\s*(\d+)\)/);
1192
+ if (bgRgbMatches) {
1193
+ const [full, r, g, b] = bgRgbMatches;
1194
+ return ansi.bgRgb(r, g, b);
1195
+ } else if (rgbMatches) {
1196
+ const [full, r, g, b] = rgbMatches;
1197
+ return ansi.rgb(r, g, b);
1198
+ } else {
1199
+ return ansi.style[effect];
1200
+ }
1201
+ }).join("");
1202
+ };
1203
+ ansi.format = function(str, styleArray) {
1204
+ const re = /\[([\w\s-\(\),]+)\]{([^]*?)}/;
1205
+ let matches;
1206
+ str = String(str);
1207
+ if (!str) return "";
1208
+ while (matches = str.match(re)) {
1209
+ const inlineStyles = matches[1].split(/\s+/);
1210
+ const inlineString = matches[2];
1211
+ str = str.replace(matches[0], ansi.format(inlineString, inlineStyles));
1212
+ }
1213
+ return styleArray && styleArray.length ? ansi.styles(styleArray) + str + ansi.style.reset : str;
1214
+ };
1215
+ ansi.cursor = {
1216
+ /**
1217
+ * Moves the cursor `lines` cells up. If the cursor is already at the edge of the screen, this has no effect
1218
+ * @param [lines=1] {number}
1219
+ * @return {string}
1220
+ */
1221
+ up: function(lines) {
1222
+ return csi + (lines || 1) + "A";
1223
+ },
1224
+ /**
1225
+ * Moves the cursor `lines` cells down. If the cursor is already at the edge of the screen, this has no effect
1226
+ * @param [lines=1] {number}
1227
+ * @return {string}
1228
+ */
1229
+ down: function(lines) {
1230
+ return csi + (lines || 1) + "B";
1231
+ },
1232
+ /**
1233
+ * Moves the cursor `lines` cells forward. If the cursor is already at the edge of the screen, this has no effect
1234
+ * @param [lines=1] {number}
1235
+ * @return {string}
1236
+ */
1237
+ forward: function(lines) {
1238
+ return csi + (lines || 1) + "C";
1239
+ },
1240
+ /**
1241
+ * Moves the cursor `lines` cells back. If the cursor is already at the edge of the screen, this has no effect
1242
+ * @param [lines=1] {number}
1243
+ * @return {string}
1244
+ */
1245
+ back: function(lines) {
1246
+ return csi + (lines || 1) + "D";
1247
+ },
1248
+ /**
1249
+ * Moves cursor to beginning of the line n lines down.
1250
+ * @param [lines=1] {number}
1251
+ * @return {string}
1252
+ */
1253
+ nextLine: function(lines) {
1254
+ return csi + (lines || 1) + "E";
1255
+ },
1256
+ /**
1257
+ * Moves cursor to beginning of the line n lines up.
1258
+ * @param [lines=1] {number}
1259
+ * @return {string}
1260
+ */
1261
+ previousLine: function(lines) {
1262
+ return csi + (lines || 1) + "F";
1263
+ },
1264
+ /**
1265
+ * Moves the cursor to column n.
1266
+ * @param n {number} - column number
1267
+ * @return {string}
1268
+ */
1269
+ horizontalAbsolute: function(n) {
1270
+ return csi + n + "G";
1271
+ },
1272
+ /**
1273
+ * Moves the cursor to row n, column m. The values are 1-based, and default to 1 (top left corner) if omitted.
1274
+ * @param n {number} - row number
1275
+ * @param m {number} - column number
1276
+ * @return {string}
1277
+ */
1278
+ position: function(n, m) {
1279
+ return csi + (n || 1) + ";" + (m || 1) + "H";
1280
+ },
1281
+ /**
1282
+ * Hides the cursor
1283
+ */
1284
+ hide: csi + "?25l",
1285
+ /**
1286
+ * Shows the cursor
1287
+ */
1288
+ show: csi + "?25h"
1289
+ };
1290
+ ansi.erase = {
1291
+ /**
1292
+ * Clears part of the screen. If n is 0 (or missing), clear from cursor to end of screen. If n is 1, clear from cursor to beginning of the screen. If n is 2, clear entire screen.
1293
+ * @param n {number}
1294
+ * @return {string}
1295
+ */
1296
+ display: function(n) {
1297
+ return csi + (n || 0) + "J";
1298
+ },
1299
+ /**
1300
+ * Erases part of the line. If n is zero (or missing), clear from cursor to the end of the line. If n is one, clear from cursor to beginning of the line. If n is two, clear entire line. Cursor position does not change.
1301
+ * @param n {number}
1302
+ * @return {string}
1303
+ */
1304
+ inLine: function(n) {
1305
+ return csi + (n || 0) + "K";
1306
+ }
1307
+ };
1308
+ module2.exports = ansi;
1309
+ }
1310
+ });
1311
+
1312
+ // ../../node_modules/list-it/lib/list-it-buffer.js
1313
+ var require_list_it_buffer = __commonJS({
1314
+ "../../node_modules/list-it/lib/list-it-buffer.js"(exports2, module2) {
1315
+ "use strict";
1316
+ var debug = require_src()("list-it-buffer");
1317
+ var DataCell = require_data_cell();
1318
+ var Row = require_row();
1319
+ var Column = require_column();
1320
+ var ansi = require_dist();
1321
+ function ListItBuffer(opt) {
1322
+ opt = opt || {};
1323
+ this.opt = {
1324
+ "autoAlign": true,
1325
+ "columnWidth": null,
1326
+ "header": null,
1327
+ "headerBold": false,
1328
+ "headerColor": "",
1329
+ "headerUnderline": false
1330
+ };
1331
+ if (opt.header != null && !Array.isArray(opt.header)) {
1332
+ throw new Error([
1333
+ `Invalid header was specified. It must be an array, but (${JSON.stringify(opt.header)}):${typeof opt.header} was specified.`
1334
+ ].join(" "));
1335
+ }
1336
+ if (opt.headerColor && !(opt.headerColor in COLORS)) {
1337
+ throw new Error([
1338
+ `Invalid color ${JSON.stringify(opt.headerColor)} was specified.`,
1339
+ "Available color names:",
1340
+ ...AVAILABLE_COLORS.map((color) => `* ${JSON.stringify(color)}`)
1341
+ ].join("\n"));
1342
+ }
1343
+ Object.keys(this.opt).forEach((key) => {
1344
+ if (key in opt) {
1345
+ this.opt[key] = opt[key];
1346
+ }
1347
+ });
1348
+ this.lines = [];
1349
+ this.columns = [];
1350
+ this.columnWidth = this.opt.columnWidth;
1351
+ if (this.opt.header) {
1352
+ this.setHeaderRow(this.opt.header);
1353
+ }
1354
+ }
1355
+ module2.exports = ListItBuffer;
1356
+ ListItBuffer.prototype.nl = function() {
1357
+ const lastRowIndex = this.lines.length - 1;
1358
+ if (lastRowIndex >= 0 && !this.lines[lastRowIndex].isFixed()) {
1359
+ this.lines[lastRowIndex].fix();
1360
+ }
1361
+ this.pushNewRow();
1362
+ return this;
1363
+ };
1364
+ ListItBuffer.prototype.d = function(data) {
1365
+ if (arguments.length > 1) {
1366
+ const array = Array.apply(null, arguments);
1367
+ if (ListItBuffer.isMultiDimensionalArray(array)) {
1368
+ array.forEach((row) => this.addRow(row));
1369
+ } else {
1370
+ array.forEach((data2) => this.d(data2));
1371
+ }
1372
+ return this;
1373
+ }
1374
+ if (Array.isArray(data)) {
1375
+ if (ListItBuffer.isMultiDimensionalArray(data)) {
1376
+ data.forEach((row) => this.addRow(row));
1377
+ } else if (ListItBuffer.isObjectArray(data)) {
1378
+ data = objectArrayToTable(data);
1379
+ if (!this.header && (this.opt.headerBold || this.opt.headerColor || this.opt.headerUnderline)) {
1380
+ this.setHeaderRow(data.shift());
1381
+ }
1382
+ data.forEach((row) => this.addRow(row));
1383
+ } else {
1384
+ this.addRow(data);
1385
+ }
1386
+ return this;
1387
+ }
1388
+ const rowidx = this.lines.length - 1;
1389
+ if (rowidx < 0 || this.lines[rowidx].isFixed()) {
1390
+ this.pushNewRow();
1391
+ }
1392
+ const cell = new DataCell();
1393
+ cell.setData(data);
1394
+ const iRow = this.lines.length - 1;
1395
+ let iCol = this.lines[iRow].getCellLength();
1396
+ if (iCol >= this.columns.length) {
1397
+ this.addColumn();
1398
+ }
1399
+ this.columns[iCol].setCellAt(iRow, cell);
1400
+ this.lines[iRow].pushCell(cell);
1401
+ return this;
1402
+ };
1403
+ ListItBuffer.isMultiDimensionalArray = function(arr) {
1404
+ if (!Array.isArray(arr)) {
1405
+ throw Error("The parameter arr must be array");
1406
+ }
1407
+ for (let element of arr) {
1408
+ if (!Array.isArray(element)) {
1409
+ return false;
1410
+ }
1411
+ }
1412
+ return true;
1413
+ };
1414
+ ListItBuffer.isObjectArray = function(arr) {
1415
+ if (!Array.isArray(arr)) {
1416
+ throw Error("The parameter arr must be array");
1417
+ }
1418
+ const ctor = arr[0].constructor;
1419
+ for (let element of arr) {
1420
+ if (typeof element != "object") {
1421
+ return false;
1422
+ } else {
1423
+ if (element.constructor.name != ctor.name) {
1424
+ return false;
1425
+ }
1426
+ }
1427
+ }
1428
+ return true;
1429
+ };
1430
+ ListItBuffer.prototype.addRow = function(row) {
1431
+ row.forEach((col) => {
1432
+ switch (typeof col) {
1433
+ case "string":
1434
+ case "number":
1435
+ this.d(col);
1436
+ break;
1437
+ default:
1438
+ this.d(col != null ? col.toString() : "(null)");
1439
+ break;
1440
+ }
1441
+ });
1442
+ this.nl();
1443
+ };
1444
+ ListItBuffer.prototype.pushNewRow = function() {
1445
+ this.lines.push(new Row());
1446
+ };
1447
+ ListItBuffer.prototype.toString = function() {
1448
+ const rows = [];
1449
+ this.columns.forEach((column, iCol) => {
1450
+ if (this.header != null) {
1451
+ column.setHeader(this.header[iCol] || "");
1452
+ }
1453
+ column.setTextWidth(this.getColumnWidth(iCol));
1454
+ column.updateWidth();
1455
+ });
1456
+ if (this.header != null) {
1457
+ const headerLine = this.applyHeaderStyleOption(
1458
+ this.columns.map((column) => column.formatColumnHeader()).join(" ")
1459
+ );
1460
+ rows.push(headerLine);
1461
+ const headerUnderline = this.generateHeaderUnderline();
1462
+ if (headerUnderline) {
1463
+ rows.push(headerUnderline);
1464
+ }
1465
+ }
1466
+ this.lines.forEach((line) => {
1467
+ if (line.isFixed() || !line.isEmpty()) {
1468
+ if (line.isEmpty()) {
1469
+ rows.push("\n");
1470
+ } else {
1471
+ rows.push(this.columns.map((column, iCol) => {
1472
+ const cell = line.getCell(iCol);
1473
+ const data = cell.getData();
1474
+ return column.formatCell(data);
1475
+ }).join(" "));
1476
+ }
1477
+ }
1478
+ });
1479
+ return rows.join("\n");
1480
+ };
1481
+ var COLORS = {};
1482
+ var BGCOLORS = {};
1483
+ Object.keys(ansi.style).forEach((key) => {
1484
+ const value = ansi.style[key];
1485
+ if (/^bg-/.test(key)) {
1486
+ BGCOLORS[key.substr(3)] = value;
1487
+ } else {
1488
+ COLORS[key] = value;
1489
+ debug(`COLOR-KEY: ${key}`);
1490
+ }
1491
+ });
1492
+ Object.keys(COLORS).forEach((key) => {
1493
+ if (!(key in BGCOLORS)) {
1494
+ delete COLORS[key];
1495
+ debug(`remove COLOR-KEY: ${key}`);
1496
+ }
1497
+ });
1498
+ var AVAILABLE_COLORS = Object.keys(COLORS);
1499
+ debug(`AVAILABLE_COLORS:${JSON.stringify(AVAILABLE_COLORS)}`);
1500
+ ListItBuffer.prototype.applyHeaderStyleOption = function(line) {
1501
+ if (!this.opt.headerBold && !this.opt.headerColor) {
1502
+ return line;
1503
+ }
1504
+ const textBuffer = [];
1505
+ if (this.opt.headerBold) {
1506
+ textBuffer.push(ansi.style.bold);
1507
+ }
1508
+ if (this.opt.headerColor) {
1509
+ textBuffer.push(COLORS[this.opt.headerColor]);
1510
+ }
1511
+ textBuffer.push(line);
1512
+ textBuffer.push(ansi.style.reset);
1513
+ return textBuffer.join("");
1514
+ };
1515
+ ListItBuffer.prototype.generateHeaderUnderline = function() {
1516
+ if (!this.opt.headerUnderline) {
1517
+ return null;
1518
+ }
1519
+ if (this.header == null) {
1520
+ return null;
1521
+ }
1522
+ return this.columns.map(
1523
+ (column) => "-".repeat(column.getWidth())
1524
+ ).join(" ");
1525
+ };
1526
+ function objectArrayToTable(objects) {
1527
+ const keys = Object.keys(objects[0]);
1528
+ const body = objects.map((item) => keys.map((key) => {
1529
+ if (item[key] != null && typeof item[key] == "object" && item[key].constructor.name == "Date") {
1530
+ return item[key].toISOString();
1531
+ }
1532
+ return item[key];
1533
+ }));
1534
+ return [keys, ...body];
1535
+ }
1536
+ ListItBuffer.prototype.setColumnWidth = function(indexOfColumns, width) {
1537
+ this.columnWidth = this.columnWidth || [];
1538
+ if (typeof indexOfColumns !== "number") {
1539
+ throw new Error("indexOfColumns must be a number");
1540
+ }
1541
+ if (!width) {
1542
+ delete this.columnWidth[indexOfColumns];
1543
+ } else {
1544
+ if (typeof width !== "number") {
1545
+ throw new Error("width must be a number");
1546
+ }
1547
+ this.columnWidth[indexOfColumns] = width;
1548
+ }
1549
+ return this;
1550
+ };
1551
+ ListItBuffer.prototype.setColumnWidthAll = function(widthForAll) {
1552
+ if (widthForAll != null && !Array.isArray(widthForAll) && typeof widthForAll !== "number") {
1553
+ throw new Error(
1554
+ "widthForAll must be one of a null, an Array or a number"
1555
+ );
1556
+ }
1557
+ if (Array.isArray(widthForAll)) {
1558
+ for (let i = 0; i < widthForAll.length; i++) {
1559
+ const width = widthForAll[i];
1560
+ if (width != void 0 && typeof width !== "number") {
1561
+ throw new Error(
1562
+ `widthForAll[${i}] must be an undefined or a number`
1563
+ );
1564
+ }
1565
+ }
1566
+ }
1567
+ this.columnWidth = widthForAll;
1568
+ return this;
1569
+ };
1570
+ ListItBuffer.prototype.getColumnWidth = function(indexOfColumns) {
1571
+ if (Array.isArray(this.columnWidth)) {
1572
+ return this.columnWidth[indexOfColumns];
1573
+ }
1574
+ return this.columnWidth;
1575
+ };
1576
+ ListItBuffer.prototype.setHeaderRow = function(header) {
1577
+ if (header && !Array.isArray(header)) {
1578
+ throw new Error([
1579
+ "The header must be an array,",
1580
+ `but ${typeof header} was specified.`,
1581
+ `header: ${JSON.stringify(header)}`
1582
+ ].join(" "));
1583
+ }
1584
+ this.header = header;
1585
+ if (this.header == null) {
1586
+ this.columns.forEach((column) => column.setHeader(null));
1587
+ } else {
1588
+ this.header.forEach((headerText, iCol) => {
1589
+ if (iCol >= this.columns.length) {
1590
+ this.addColumn(headerText);
1591
+ }
1592
+ });
1593
+ }
1594
+ return this;
1595
+ };
1596
+ ListItBuffer.prototype.addColumn = function(headerText) {
1597
+ const column = new Column();
1598
+ if (headerText) {
1599
+ column.setHeader(headerText);
1600
+ }
1601
+ if (this.opt.autoAlign) {
1602
+ column.setAutoAlign(true);
1603
+ }
1604
+ this.columns.push(column);
1605
+ };
1606
+ }
1607
+ });
1608
+
1609
+ // ../../node_modules/list-it/index.js
1610
+ var require_list_it = __commonJS({
1611
+ "../../node_modules/list-it/index.js"(exports2, module2) {
1612
+ "use strict";
1613
+ var ListItBuffer = require_list_it_buffer();
1614
+ function ListIt2(opt) {
1615
+ ListItBuffer.call(this, opt);
1616
+ }
1617
+ ListIt2.prototype = new ListItBuffer();
1618
+ ListIt2.buffer = function(opt) {
1619
+ opt = opt || {};
1620
+ if (!("autoAlign" in opt)) {
1621
+ opt.autoAlign = false;
1622
+ }
1623
+ return new ListIt2(opt);
1624
+ };
1625
+ module2.exports = ListIt2;
1626
+ }
1627
+ });
1628
+
1629
+ // src/lib/runEnvironment.ts
1630
+ var runEnvironment_exports = {};
1631
+ __export(runEnvironment_exports, {
1632
+ loadReplayStrategies: () => loadReplayStrategies,
1633
+ prepareRunEnvironment: () => prepareRunEnvironment,
1634
+ resolveBacktestExecutionPreloadInterval: () => resolveBacktestExecutionPreloadInterval
1635
+ });
1636
+ module.exports = __toCommonJS(runEnvironment_exports);
1637
+ var import_chalk3 = __toESM(require("chalk"));
1638
+ var import_connectors3 = require("@tradejs/node/connectors");
1639
+ var import_cli3 = require("@tradejs/node/cli");
1640
+ var import_constants = require("@tradejs/core/constants");
1641
+ var import_time2 = require("@tradejs/core/time");
1642
+
1643
+ // src/lib/timeWindow.ts
1644
+ var ONE_DAY_MS = 24 * 60 * 60 * 1e3;
1645
+ var toEpochMs = (value) => {
1646
+ if (value == null || value === "") {
1647
+ return null;
1648
+ }
1649
+ const parsed = Number(value);
1650
+ if (!Number.isFinite(parsed) || parsed <= 0) {
1651
+ return null;
1652
+ }
1653
+ return parsed < 1e12 ? Math.trunc(parsed * 1e3) : Math.trunc(parsed);
1654
+ };
1655
+ var toPositiveNumber = (value) => {
1656
+ if (value == null || value === "") {
1657
+ return null;
1658
+ }
1659
+ const parsed = Number(value);
1660
+ if (!Number.isFinite(parsed) || parsed <= 0) {
1661
+ return null;
1662
+ }
1663
+ return parsed;
1664
+ };
1665
+ var resolveTimeWindow = ({
1666
+ days,
1667
+ startTime,
1668
+ endTime,
1669
+ nowMs = Date.now(),
1670
+ defaultStartMs,
1671
+ defaultEndMs
1672
+ }) => {
1673
+ const explicitStart = toEpochMs(startTime);
1674
+ const explicitEnd = toEpochMs(endTime);
1675
+ const resolvedDays = toPositiveNumber(days);
1676
+ if (explicitStart != null || explicitEnd != null) {
1677
+ const resolvedStart = explicitStart ?? (resolvedDays != null && explicitEnd != null ? explicitEnd - resolvedDays * ONE_DAY_MS : defaultStartMs);
1678
+ const resolvedEnd2 = explicitEnd ?? (resolvedDays != null && explicitStart != null ? explicitStart + resolvedDays * ONE_DAY_MS : defaultEndMs ?? nowMs);
1679
+ if (resolvedStart >= resolvedEnd2) {
1680
+ throw new Error(
1681
+ `Invalid time window: startTime (${resolvedStart}) must be less than endTime (${resolvedEnd2})`
1682
+ );
1683
+ }
1684
+ return {
1685
+ start: resolvedStart,
1686
+ end: resolvedEnd2,
1687
+ source: "explicit"
1688
+ };
1689
+ }
1690
+ if (resolvedDays != null) {
1691
+ const resolvedEnd2 = defaultEndMs ?? nowMs;
1692
+ const resolvedStart = resolvedEnd2 - resolvedDays * ONE_DAY_MS;
1693
+ if (resolvedStart >= resolvedEnd2) {
1694
+ throw new Error(
1695
+ `Invalid time window: computed start (${resolvedStart}) must be less than end (${resolvedEnd2})`
1696
+ );
1697
+ }
1698
+ return {
1699
+ start: Math.trunc(resolvedStart),
1700
+ end: Math.trunc(resolvedEnd2),
1701
+ source: "days"
1702
+ };
1703
+ }
1704
+ const resolvedEnd = defaultEndMs ?? nowMs;
1705
+ if (defaultStartMs >= resolvedEnd) {
1706
+ throw new Error(
1707
+ `Invalid default time window: start (${defaultStartMs}) must be less than end (${resolvedEnd})`
1708
+ );
1709
+ }
1710
+ return {
1711
+ start: Math.trunc(defaultStartMs),
1712
+ end: Math.trunc(resolvedEnd),
1713
+ source: "default"
1714
+ };
1715
+ };
1716
+
1717
+ // src/lib/runtimeStrategyBacktest.ts
1718
+ var import_chalk = __toESM(require("chalk"));
1719
+
1720
+ // src/lib/runtimeRedis.ts
1721
+ var import_redis = require("@tradejs/infra/redis");
1722
+ var import_time = require("@tradejs/core/time");
1723
+ var RESERVED_STRATEGY_NAMES = /* @__PURE__ */ new Set(["charts"]);
1724
+ var RESERVED_CONFIG_IDS = /* @__PURE__ */ new Set(["results"]);
1725
+ var resolveStrategyConfigIdentityByKey = (userName, key) => {
1726
+ const parts = key.split(":");
1727
+ if (parts.length !== 5) return null;
1728
+ const [users, keyUserName, strategiesKey, strategyName, configId] = parts;
1729
+ if (users !== "users" || keyUserName !== userName || strategiesKey !== "strategies" || !strategyName || !configId || RESERVED_STRATEGY_NAMES.has(strategyName) || RESERVED_CONFIG_IDS.has(configId) || !/^[a-zA-Z0-9_-]+$/.test(configId)) {
1730
+ return null;
1731
+ }
1732
+ return { strategyName, configId };
1733
+ };
1734
+ var isRuntimeStrategyEnabled = (strategyConfig) => {
1735
+ const enabled = strategyConfig.ENABLE;
1736
+ return enabled !== false;
1737
+ };
1738
+ var resolveStrategyNameByConfigKey = (userName, key) => {
1739
+ return resolveStrategyConfigIdentityByKey(userName, key)?.strategyName ?? null;
1740
+ };
1741
+ var getRuntimeStrategyConfigKeys = async (userName) => {
1742
+ const keys = await (0, import_redis.getKeys)(`${import_redis.redisKeys.strategies(userName)}:`);
1743
+ return keys.filter((key) => resolveStrategyConfigIdentityByKey(userName, key)).sort((left, right) => left.localeCompare(right));
1744
+ };
1745
+ var loadRuntimeStrategyConfigs = async (userName, {
1746
+ onInvalidConfig
1747
+ } = {}) => {
1748
+ const configKeys = await getRuntimeStrategyConfigKeys(userName);
1749
+ const strategyConfigs = await Promise.all(
1750
+ configKeys.map(async (key) => {
1751
+ const strategyName = resolveStrategyNameByConfigKey(userName, key);
1752
+ const identity = resolveStrategyConfigIdentityByKey(userName, key);
1753
+ if (!strategyName || !identity) {
1754
+ return null;
1755
+ }
1756
+ const strategyConfig = await (0, import_redis.getData)(
1757
+ key,
1758
+ null
1759
+ );
1760
+ if (!strategyConfig || typeof strategyConfig !== "object" || Array.isArray(strategyConfig)) {
1761
+ onInvalidConfig?.(key);
1762
+ return null;
1763
+ }
1764
+ return {
1765
+ key,
1766
+ strategyName,
1767
+ configId: identity.configId,
1768
+ strategyConfig
1769
+ };
1770
+ })
1771
+ );
1772
+ return strategyConfigs.filter(Boolean);
1773
+ };
1774
+
1775
+ // src/lib/runtimeStrategyBacktest.ts
1776
+ var BACKTEST_CLI_RUNTIME_CONFIG_KEYS = /* @__PURE__ */ new Set([
1777
+ "ENV",
1778
+ "INTERVAL",
1779
+ "MAKE_ORDERS",
1780
+ "CLOSE_OPPOSITE_POSITIONS",
1781
+ "BACKTEST_PRICE_MODE",
1782
+ "BACKTEST_ENTRY_DELAY_BARS"
1783
+ ]);
1784
+ var toStrategyConfigGrid = (strategyConfig) => Object.fromEntries(
1785
+ Object.entries(strategyConfig).filter(([key]) => !BACKTEST_CLI_RUNTIME_CONFIG_KEYS.has(key)).map(([key, value]) => [key, [value]])
1786
+ );
1787
+ var loadRuntimeStrategyBacktestConfigs = async (userName) => {
1788
+ const configs = await loadRuntimeStrategyConfigs(userName, {
1789
+ onInvalidConfig: (key) => {
1790
+ console.log(import_chalk.default.yellow(`Skip invalid runtime strategy config: ${key}`));
1791
+ }
1792
+ });
1793
+ return configs.filter(({ configId }) => configId === "config").filter(({ strategyName, strategyConfig }) => {
1794
+ const enabled = isRuntimeStrategyEnabled(strategyConfig);
1795
+ if (!enabled) {
1796
+ console.log(
1797
+ import_chalk.default.yellow(
1798
+ `Skip inactive runtime strategy config by ENABLE=false: ${strategyName}`
1799
+ )
1800
+ );
1801
+ }
1802
+ return enabled;
1803
+ }).map(({ strategyName, strategyConfig }) => ({
1804
+ strategyName,
1805
+ strategyConfig,
1806
+ backtestConfig: toStrategyConfigGrid(strategyConfig)
1807
+ }));
1808
+ };
1809
+
1810
+ // src/lib/runFormatting.ts
1811
+ var import_date_fns = require("date-fns");
1812
+ var ListIt = require_list_it();
1813
+ var formatDuration = (startedAt) => {
1814
+ const seconds = Math.max(0, (Date.now() - startedAt) / 1e3);
1815
+ if (seconds < 60) return `${seconds.toFixed(1)}s`;
1816
+ const minutes = Math.floor(seconds / 60);
1817
+ const restSeconds = Math.round(seconds % 60);
1818
+ return `${minutes}m ${restSeconds}s`;
1819
+ };
1820
+ var timeOperation = async (label, operation, log = console.log) => {
1821
+ const startedAt = Date.now();
1822
+ try {
1823
+ return await operation();
1824
+ } finally {
1825
+ log(`${label}: done in ${formatDuration(startedAt)}`);
1826
+ }
1827
+ };
1828
+
1829
+ // src/lib/marketData/historyPrepare.ts
1830
+ var import_chalk2 = __toESM(require("chalk"));
1831
+ var import_connectors = require("@tradejs/connectors");
1832
+ var import_cli = require("@tradejs/node/cli");
1833
+ var import_connectors2 = require("@tradejs/node/connectors");
1834
+ var withPrimaryMarketReferenceSymbols = (symbols) => [
1835
+ .../* @__PURE__ */ new Set([...symbols, "ETHUSDT"])
1836
+ ];
1837
+ var loadBtcReferenceConnectors = async ({
1838
+ connectorName,
1839
+ marketConnector,
1840
+ userName,
1841
+ projectRoot,
1842
+ shouldUseDedicatedReferences,
1843
+ requireDedicatedReferences = false,
1844
+ warn
1845
+ }) => {
1846
+ if (!shouldUseDedicatedReferences) {
1847
+ return {
1848
+ binance: marketConnector,
1849
+ coinbase: marketConnector
1850
+ };
1851
+ }
1852
+ const [binanceFactory, coinbaseFactory] = await Promise.all([
1853
+ (0, import_connectors2.getConnectorCreatorByName)(import_connectors.ConnectorNames.Binance, projectRoot),
1854
+ (0, import_connectors2.getConnectorCreatorByName)(import_connectors.ConnectorNames.Coinbase, projectRoot)
1855
+ ]);
1856
+ const binance = binanceFactory ? await binanceFactory({ userName }) : marketConnector;
1857
+ if (!binanceFactory) {
1858
+ if (requireDedicatedReferences) {
1859
+ throw new Error("Binance connector is required for BTC reference data");
1860
+ }
1861
+ warn(`Binance connector is unavailable. Reusing ${connectorName}.`);
1862
+ }
1863
+ const coinbase = coinbaseFactory ? await coinbaseFactory({ userName }) : marketConnector;
1864
+ if (!coinbaseFactory) {
1865
+ if (requireDedicatedReferences) {
1866
+ throw new Error("Coinbase connector is required for BTC reference data");
1867
+ }
1868
+ warn(`Coinbase connector is unavailable. Reusing ${connectorName}.`);
1869
+ }
1870
+ return { binance, coinbase };
1871
+ };
1872
+ var updateMarketHistoryWithBtcReferences = async ({
1873
+ marketConnector,
1874
+ connectorName,
1875
+ btcReferences,
1876
+ interval,
1877
+ symbols,
1878
+ preloadDays,
1879
+ preloadStart,
1880
+ preloadEnd,
1881
+ log,
1882
+ universe = marketConnector.universe ?? "crypto"
1883
+ }) => {
1884
+ await updatePrimaryMarketHistory({
1885
+ marketConnector,
1886
+ connectorName,
1887
+ interval,
1888
+ symbols,
1889
+ preloadDays,
1890
+ preloadStart,
1891
+ preloadEnd,
1892
+ universe,
1893
+ log
1894
+ });
1895
+ await updateBtcReferenceHistory({
1896
+ marketConnector,
1897
+ btcReferences,
1898
+ interval,
1899
+ preloadDays,
1900
+ preloadStart,
1901
+ preloadEnd,
1902
+ universe,
1903
+ log
1904
+ });
1905
+ };
1906
+ var updatePrimaryMarketHistory = async ({
1907
+ marketConnector,
1908
+ connectorName,
1909
+ interval,
1910
+ symbols,
1911
+ preloadDays,
1912
+ preloadStart,
1913
+ preloadEnd,
1914
+ log,
1915
+ universe = marketConnector.universe ?? "crypto"
1916
+ }) => {
1917
+ if (!symbols.length) return;
1918
+ const timeOperation3 = (label, operation) => timeOperation(
1919
+ label,
1920
+ operation,
1921
+ log ?? ((message) => console.log(import_chalk2.default.gray(message)))
1922
+ );
1923
+ const updateOptions = preloadStart != null || preloadEnd != null ? {
1924
+ connectorLabel: connectorName,
1925
+ ...preloadStart != null ? { preloadStart } : {},
1926
+ ...preloadEnd != null ? { preloadEnd } : {}
1927
+ } : { connectorLabel: connectorName };
1928
+ await timeOperation3(
1929
+ `update ${connectorName}`,
1930
+ () => (0, import_cli.update)(
1931
+ marketConnector,
1932
+ interval,
1933
+ universe === "crypto" ? withPrimaryMarketReferenceSymbols(symbols) : symbols,
1934
+ preloadDays,
1935
+ updateOptions
1936
+ )
1937
+ );
1938
+ };
1939
+ var updateBtcReferenceHistory = async ({
1940
+ marketConnector,
1941
+ btcReferences,
1942
+ interval,
1943
+ preloadDays,
1944
+ preloadStart,
1945
+ preloadEnd,
1946
+ log,
1947
+ universe = marketConnector.universe ?? "crypto"
1948
+ }) => {
1949
+ if (universe !== "crypto") return;
1950
+ const timeOperation3 = (label, operation) => timeOperation(
1951
+ label,
1952
+ operation,
1953
+ log ?? ((message) => console.log(import_chalk2.default.gray(message)))
1954
+ );
1955
+ const updateReference = async ({
1956
+ connector,
1957
+ connectorLabel
1958
+ }) => {
1959
+ if (connector === marketConnector) {
1960
+ return;
1961
+ }
1962
+ const referenceOptions = preloadStart != null || preloadEnd != null ? {
1963
+ connectorLabel,
1964
+ ...preloadStart != null ? { preloadStart } : {},
1965
+ ...preloadEnd != null ? { preloadEnd } : {}
1966
+ } : { connectorLabel };
1967
+ await timeOperation3(
1968
+ `update ${connectorLabel}`,
1969
+ () => (0, import_cli.update)(connector, interval, ["BTCUSDT"], preloadDays, referenceOptions)
1970
+ );
1971
+ };
1972
+ await updateReference({
1973
+ connector: btcReferences.binance,
1974
+ connectorLabel: import_connectors.ConnectorNames.Binance
1975
+ });
1976
+ await updateReference({
1977
+ connector: btcReferences.coinbase,
1978
+ connectorLabel: import_connectors.ConnectorNames.Coinbase
1979
+ });
1980
+ };
1981
+
1982
+ // src/lib/tickerUniverseCache.ts
1983
+ var import_tickers = require("@tradejs/core/tickers");
1984
+ var import_redis2 = require("@tradejs/infra/redis");
1985
+ var import_cli2 = require("@tradejs/node/cli");
1986
+ var TICKER_CACHE_VERSION = 1;
1987
+ var parseSymbolsFromCLI = (symbols = "") => symbols.split(",").map((symbol) => symbol.trim().toUpperCase()).filter(Boolean);
1988
+ var isTickerLike = (value) => {
1989
+ if (!value || typeof value !== "object") {
1990
+ return false;
1991
+ }
1992
+ const ticker = value;
1993
+ return typeof ticker.symbol === "string" && ticker.symbol.trim().length > 0 && typeof ticker.volume24h === "number" && Number.isFinite(ticker.volume24h);
1994
+ };
1995
+ var readCachedTickerUniverse = async (cacheKey) => {
1996
+ const cached = await (0, import_redis2.getData)(cacheKey, null);
1997
+ if (!cached || !Array.isArray(cached.tickers)) {
1998
+ return null;
1999
+ }
2000
+ const tickers = cached.tickers.filter(isTickerLike);
2001
+ return tickers.length ? tickers : null;
2002
+ };
2003
+ var selectTickerSymbols = ({
2004
+ tickers,
2005
+ exclude,
2006
+ limit
2007
+ }) => {
2008
+ const excludedTickers = parseSymbolsFromCLI(exclude);
2009
+ return (0, import_tickers.getTopTickers)(tickers, limit).map(({ value }) => value).filter((ticker) => !excludedTickers.includes(ticker));
2010
+ };
2011
+ var loadRunTickers = async ({
2012
+ connector,
2013
+ connectorName,
2014
+ userName,
2015
+ include,
2016
+ exclude,
2017
+ limit,
2018
+ cacheOnly,
2019
+ universe,
2020
+ accountId,
2021
+ assetClasses
2022
+ }) => {
2023
+ if (include?.trim()) {
2024
+ return (0, import_cli2.getTickers)(connector, include, exclude, limit, void 0, {
2025
+ universe,
2026
+ assetClasses
2027
+ });
2028
+ }
2029
+ const cacheKey = import_redis2.redisKeys.tickerUniverse(
2030
+ userName,
2031
+ connectorName,
2032
+ universe,
2033
+ accountId
2034
+ );
2035
+ if (cacheOnly) {
2036
+ const cachedTickers = await readCachedTickerUniverse(cacheKey);
2037
+ if (!cachedTickers) {
2038
+ throw new Error(
2039
+ `No cached ticker universe for ${connectorName}. Run once without --cacheOnly or pass --tickers explicitly.`
2040
+ );
2041
+ }
2042
+ return selectTickerSymbols({
2043
+ tickers: cachedTickers,
2044
+ exclude,
2045
+ limit
2046
+ });
2047
+ }
2048
+ const exchangeTickers = await connector.getTickers({
2049
+ universe,
2050
+ assetClasses
2051
+ });
2052
+ if (exchangeTickers.length) {
2053
+ await (0, import_redis2.setData)(
2054
+ cacheKey,
2055
+ {
2056
+ version: TICKER_CACHE_VERSION,
2057
+ connectorName,
2058
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
2059
+ tickers: exchangeTickers
2060
+ },
2061
+ { expire: 0 }
2062
+ );
2063
+ }
2064
+ return selectTickerSymbols({
2065
+ tickers: exchangeTickers,
2066
+ exclude,
2067
+ limit
2068
+ });
2069
+ };
2070
+
2071
+ // src/lib/runEnvironment.ts
2072
+ var timeOperation2 = async (label, operation) => timeOperation(
2073
+ label,
2074
+ operation,
2075
+ (message) => console.log(import_chalk3.default.gray(message))
2076
+ );
2077
+ var resolveBacktestExecutionPreloadInterval = (interval) => {
2078
+ const normalized = String(interval);
2079
+ if (normalized === "15") {
2080
+ return import_constants.BACKTEST_EXECUTION_INTERVAL;
2081
+ }
2082
+ if (normalized === "60") {
2083
+ return "15";
2084
+ }
2085
+ return null;
2086
+ };
2087
+ var resolveRunConnectorName = async ({
2088
+ value,
2089
+ projectRoot
2090
+ }) => {
2091
+ const connectorName = await (0, import_connectors3.resolveConnectorName)(value, projectRoot);
2092
+ if (connectorName) {
2093
+ return connectorName;
2094
+ }
2095
+ console.log(
2096
+ import_chalk3.default.yellow(
2097
+ `Unknown connector "${String(value || "").trim() || String(value)}". Fallback to ${import_connectors3.DEFAULT_CONNECTOR_NAME}.`
2098
+ )
2099
+ );
2100
+ return import_connectors3.DEFAULT_CONNECTOR_NAME;
2101
+ };
2102
+ var loadReplayStrategies = async (userName) => {
2103
+ const runtimeStrategies = await loadRuntimeStrategyBacktestConfigs(userName);
2104
+ if (!runtimeStrategies.length) {
2105
+ console.log(
2106
+ import_chalk3.default.yellow(
2107
+ `No active runtime strategy configs found by users:${userName}:strategies:*:config`
2108
+ )
2109
+ );
2110
+ return [];
2111
+ }
2112
+ return runtimeStrategies;
2113
+ };
2114
+ var prepareRunEnvironment = async ({
2115
+ connector,
2116
+ userName,
2117
+ tickers,
2118
+ exclude,
2119
+ tickersLimit,
2120
+ showTickersList,
2121
+ days,
2122
+ startTime,
2123
+ endTime,
2124
+ cacheOnly,
2125
+ interval,
2126
+ projectRoot,
2127
+ universe = "crypto",
2128
+ accountId,
2129
+ deploymentId,
2130
+ assetClasses,
2131
+ deployment
2132
+ }) => {
2133
+ const connectorName = await resolveRunConnectorName({
2134
+ value: connector,
2135
+ projectRoot
2136
+ });
2137
+ const connectorFactory = await (0, import_connectors3.getConnectorCreatorByName)(
2138
+ connectorName,
2139
+ projectRoot
2140
+ );
2141
+ if (!connectorFactory) {
2142
+ throw new Error(`Connector "${connectorName}" is not registered`);
2143
+ }
2144
+ const marketConnector = await connectorFactory({
2145
+ userName,
2146
+ universe,
2147
+ accountId,
2148
+ deploymentId
2149
+ });
2150
+ const resolvedTickersLimit = typeof tickersLimit === "number" ? tickersLimit : typeof tickersLimit === "string" && tickersLimit.trim() ? Number(tickersLimit) : void 0;
2151
+ const loadedTickers = await timeOperation2(
2152
+ "tickers load",
2153
+ () => loadRunTickers({
2154
+ connector: marketConnector,
2155
+ connectorName,
2156
+ userName,
2157
+ include: typeof tickers === "string" ? tickers : void 0,
2158
+ exclude: typeof exclude === "string" ? exclude : void 0,
2159
+ limit: Number.isFinite(resolvedTickersLimit) ? resolvedTickersLimit : void 0,
2160
+ cacheOnly: Boolean(cacheOnly),
2161
+ universe,
2162
+ accountId,
2163
+ assetClasses
2164
+ })
2165
+ );
2166
+ if (showTickersList) {
2167
+ console.log(import_chalk3.default.gray(JSON.stringify(loadedTickers.sort(), null, 2)));
2168
+ return null;
2169
+ }
2170
+ const instruments = !cacheOnly && typeof marketConnector.listInstruments === "function" ? await timeOperation2(
2171
+ "instruments load",
2172
+ () => marketConnector.listInstruments({
2173
+ universe,
2174
+ assetClasses,
2175
+ symbols: loadedTickers
2176
+ })
2177
+ ) : [];
2178
+ const instrumentsBySymbol = new Map(
2179
+ instruments.map((instrument) => [
2180
+ instrument.symbol.toUpperCase(),
2181
+ instrument
2182
+ ])
2183
+ );
2184
+ const window2 = resolveTimeWindow({
2185
+ days,
2186
+ startTime,
2187
+ endTime,
2188
+ defaultStartMs: (0, import_time2.getTimestamp)(import_constants.BACKTEST_DEFAULT_DAYS),
2189
+ defaultEndMs: (0, import_time2.getTimestamp)()
2190
+ });
2191
+ const preloadStart = (0, import_time2.getBacktestPreloadStart)(
2192
+ window2.start,
2193
+ import_constants.BACKTEST_PRELOAD_DAYS
2194
+ );
2195
+ if (!cacheOnly) {
2196
+ const btcReferences = await loadBtcReferenceConnectors({
2197
+ connectorName,
2198
+ marketConnector,
2199
+ userName,
2200
+ projectRoot,
2201
+ shouldUseDedicatedReferences: universe === "crypto",
2202
+ requireDedicatedReferences: universe === "crypto",
2203
+ warn: (message) => console.log(import_chalk3.default.yellow(message))
2204
+ });
2205
+ await updateMarketHistoryWithBtcReferences({
2206
+ marketConnector,
2207
+ connectorName,
2208
+ btcReferences,
2209
+ interval,
2210
+ symbols: loadedTickers,
2211
+ preloadStart,
2212
+ preloadEnd: window2.end,
2213
+ universe,
2214
+ log: (message) => console.log(import_chalk3.default.gray(message))
2215
+ });
2216
+ const backtestExecutionInterval = resolveBacktestExecutionPreloadInterval(interval);
2217
+ if (backtestExecutionInterval && String(backtestExecutionInterval) !== String(interval)) {
2218
+ await timeOperation2(
2219
+ `update ${connectorName} execution`,
2220
+ () => (0, import_cli3.update)(
2221
+ marketConnector,
2222
+ backtestExecutionInterval,
2223
+ loadedTickers,
2224
+ void 0,
2225
+ {
2226
+ connectorLabel: connectorName,
2227
+ preloadStart,
2228
+ preloadEnd: window2.end,
2229
+ skipCovered: true
2230
+ }
2231
+ )
2232
+ );
2233
+ }
2234
+ }
2235
+ return {
2236
+ connectorName,
2237
+ marketConnector,
2238
+ tickers: loadedTickers,
2239
+ instrumentsBySymbol,
2240
+ window: window2,
2241
+ preloadStart,
2242
+ universe,
2243
+ accountId,
2244
+ deploymentId,
2245
+ assetClasses,
2246
+ deployment
2247
+ };
2248
+ };
2249
+ // Annotate the CommonJS export names for ESM import in node:
2250
+ 0 && (module.exports = {
2251
+ loadReplayStrategies,
2252
+ prepareRunEnvironment,
2253
+ resolveBacktestExecutionPreloadInterval
2254
+ });