@nsshunt/stsutils 1.19.90 → 1.19.92

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.
package/dist/index.cjs CHANGED
@@ -1,1964 +1,754 @@
1
- "use strict";
2
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const Ajv = require("ajv/dist/jtd.js");
4
- function getDefaultExportFromCjs(x) {
5
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
6
- }
7
- var ansiStyles = { exports: {} };
8
- var colorName;
9
- var hasRequiredColorName;
10
- function requireColorName() {
11
- if (hasRequiredColorName) return colorName;
12
- hasRequiredColorName = 1;
13
- colorName = {
14
- "aliceblue": [240, 248, 255],
15
- "antiquewhite": [250, 235, 215],
16
- "aqua": [0, 255, 255],
17
- "aquamarine": [127, 255, 212],
18
- "azure": [240, 255, 255],
19
- "beige": [245, 245, 220],
20
- "bisque": [255, 228, 196],
21
- "black": [0, 0, 0],
22
- "blanchedalmond": [255, 235, 205],
23
- "blue": [0, 0, 255],
24
- "blueviolet": [138, 43, 226],
25
- "brown": [165, 42, 42],
26
- "burlywood": [222, 184, 135],
27
- "cadetblue": [95, 158, 160],
28
- "chartreuse": [127, 255, 0],
29
- "chocolate": [210, 105, 30],
30
- "coral": [255, 127, 80],
31
- "cornflowerblue": [100, 149, 237],
32
- "cornsilk": [255, 248, 220],
33
- "crimson": [220, 20, 60],
34
- "cyan": [0, 255, 255],
35
- "darkblue": [0, 0, 139],
36
- "darkcyan": [0, 139, 139],
37
- "darkgoldenrod": [184, 134, 11],
38
- "darkgray": [169, 169, 169],
39
- "darkgreen": [0, 100, 0],
40
- "darkgrey": [169, 169, 169],
41
- "darkkhaki": [189, 183, 107],
42
- "darkmagenta": [139, 0, 139],
43
- "darkolivegreen": [85, 107, 47],
44
- "darkorange": [255, 140, 0],
45
- "darkorchid": [153, 50, 204],
46
- "darkred": [139, 0, 0],
47
- "darksalmon": [233, 150, 122],
48
- "darkseagreen": [143, 188, 143],
49
- "darkslateblue": [72, 61, 139],
50
- "darkslategray": [47, 79, 79],
51
- "darkslategrey": [47, 79, 79],
52
- "darkturquoise": [0, 206, 209],
53
- "darkviolet": [148, 0, 211],
54
- "deeppink": [255, 20, 147],
55
- "deepskyblue": [0, 191, 255],
56
- "dimgray": [105, 105, 105],
57
- "dimgrey": [105, 105, 105],
58
- "dodgerblue": [30, 144, 255],
59
- "firebrick": [178, 34, 34],
60
- "floralwhite": [255, 250, 240],
61
- "forestgreen": [34, 139, 34],
62
- "fuchsia": [255, 0, 255],
63
- "gainsboro": [220, 220, 220],
64
- "ghostwhite": [248, 248, 255],
65
- "gold": [255, 215, 0],
66
- "goldenrod": [218, 165, 32],
67
- "gray": [128, 128, 128],
68
- "green": [0, 128, 0],
69
- "greenyellow": [173, 255, 47],
70
- "grey": [128, 128, 128],
71
- "honeydew": [240, 255, 240],
72
- "hotpink": [255, 105, 180],
73
- "indianred": [205, 92, 92],
74
- "indigo": [75, 0, 130],
75
- "ivory": [255, 255, 240],
76
- "khaki": [240, 230, 140],
77
- "lavender": [230, 230, 250],
78
- "lavenderblush": [255, 240, 245],
79
- "lawngreen": [124, 252, 0],
80
- "lemonchiffon": [255, 250, 205],
81
- "lightblue": [173, 216, 230],
82
- "lightcoral": [240, 128, 128],
83
- "lightcyan": [224, 255, 255],
84
- "lightgoldenrodyellow": [250, 250, 210],
85
- "lightgray": [211, 211, 211],
86
- "lightgreen": [144, 238, 144],
87
- "lightgrey": [211, 211, 211],
88
- "lightpink": [255, 182, 193],
89
- "lightsalmon": [255, 160, 122],
90
- "lightseagreen": [32, 178, 170],
91
- "lightskyblue": [135, 206, 250],
92
- "lightslategray": [119, 136, 153],
93
- "lightslategrey": [119, 136, 153],
94
- "lightsteelblue": [176, 196, 222],
95
- "lightyellow": [255, 255, 224],
96
- "lime": [0, 255, 0],
97
- "limegreen": [50, 205, 50],
98
- "linen": [250, 240, 230],
99
- "magenta": [255, 0, 255],
100
- "maroon": [128, 0, 0],
101
- "mediumaquamarine": [102, 205, 170],
102
- "mediumblue": [0, 0, 205],
103
- "mediumorchid": [186, 85, 211],
104
- "mediumpurple": [147, 112, 219],
105
- "mediumseagreen": [60, 179, 113],
106
- "mediumslateblue": [123, 104, 238],
107
- "mediumspringgreen": [0, 250, 154],
108
- "mediumturquoise": [72, 209, 204],
109
- "mediumvioletred": [199, 21, 133],
110
- "midnightblue": [25, 25, 112],
111
- "mintcream": [245, 255, 250],
112
- "mistyrose": [255, 228, 225],
113
- "moccasin": [255, 228, 181],
114
- "navajowhite": [255, 222, 173],
115
- "navy": [0, 0, 128],
116
- "oldlace": [253, 245, 230],
117
- "olive": [128, 128, 0],
118
- "olivedrab": [107, 142, 35],
119
- "orange": [255, 165, 0],
120
- "orangered": [255, 69, 0],
121
- "orchid": [218, 112, 214],
122
- "palegoldenrod": [238, 232, 170],
123
- "palegreen": [152, 251, 152],
124
- "paleturquoise": [175, 238, 238],
125
- "palevioletred": [219, 112, 147],
126
- "papayawhip": [255, 239, 213],
127
- "peachpuff": [255, 218, 185],
128
- "peru": [205, 133, 63],
129
- "pink": [255, 192, 203],
130
- "plum": [221, 160, 221],
131
- "powderblue": [176, 224, 230],
132
- "purple": [128, 0, 128],
133
- "rebeccapurple": [102, 51, 153],
134
- "red": [255, 0, 0],
135
- "rosybrown": [188, 143, 143],
136
- "royalblue": [65, 105, 225],
137
- "saddlebrown": [139, 69, 19],
138
- "salmon": [250, 128, 114],
139
- "sandybrown": [244, 164, 96],
140
- "seagreen": [46, 139, 87],
141
- "seashell": [255, 245, 238],
142
- "sienna": [160, 82, 45],
143
- "silver": [192, 192, 192],
144
- "skyblue": [135, 206, 235],
145
- "slateblue": [106, 90, 205],
146
- "slategray": [112, 128, 144],
147
- "slategrey": [112, 128, 144],
148
- "snow": [255, 250, 250],
149
- "springgreen": [0, 255, 127],
150
- "steelblue": [70, 130, 180],
151
- "tan": [210, 180, 140],
152
- "teal": [0, 128, 128],
153
- "thistle": [216, 191, 216],
154
- "tomato": [255, 99, 71],
155
- "turquoise": [64, 224, 208],
156
- "violet": [238, 130, 238],
157
- "wheat": [245, 222, 179],
158
- "white": [255, 255, 255],
159
- "whitesmoke": [245, 245, 245],
160
- "yellow": [255, 255, 0],
161
- "yellowgreen": [154, 205, 50]
162
- };
163
- return colorName;
164
- }
165
- var conversions;
166
- var hasRequiredConversions;
167
- function requireConversions() {
168
- if (hasRequiredConversions) return conversions;
169
- hasRequiredConversions = 1;
170
- const cssKeywords = requireColorName();
171
- const reverseKeywords = {};
172
- for (const key of Object.keys(cssKeywords)) {
173
- reverseKeywords[cssKeywords[key]] = key;
174
- }
175
- const convert = {
176
- rgb: { channels: 3, labels: "rgb" },
177
- hsl: { channels: 3, labels: "hsl" },
178
- hsv: { channels: 3, labels: "hsv" },
179
- hwb: { channels: 3, labels: "hwb" },
180
- cmyk: { channels: 4, labels: "cmyk" },
181
- xyz: { channels: 3, labels: "xyz" },
182
- lab: { channels: 3, labels: "lab" },
183
- lch: { channels: 3, labels: "lch" },
184
- hex: { channels: 1, labels: ["hex"] },
185
- keyword: { channels: 1, labels: ["keyword"] },
186
- ansi16: { channels: 1, labels: ["ansi16"] },
187
- ansi256: { channels: 1, labels: ["ansi256"] },
188
- hcg: { channels: 3, labels: ["h", "c", "g"] },
189
- apple: { channels: 3, labels: ["r16", "g16", "b16"] },
190
- gray: { channels: 1, labels: ["gray"] }
191
- };
192
- conversions = convert;
193
- for (const model of Object.keys(convert)) {
194
- if (!("channels" in convert[model])) {
195
- throw new Error("missing channels property: " + model);
196
- }
197
- if (!("labels" in convert[model])) {
198
- throw new Error("missing channel labels property: " + model);
199
- }
200
- if (convert[model].labels.length !== convert[model].channels) {
201
- throw new Error("channel and label counts mismatch: " + model);
202
- }
203
- const { channels, labels } = convert[model];
204
- delete convert[model].channels;
205
- delete convert[model].labels;
206
- Object.defineProperty(convert[model], "channels", { value: channels });
207
- Object.defineProperty(convert[model], "labels", { value: labels });
208
- }
209
- convert.rgb.hsl = function(rgb) {
210
- const r = rgb[0] / 255;
211
- const g = rgb[1] / 255;
212
- const b = rgb[2] / 255;
213
- const min = Math.min(r, g, b);
214
- const max = Math.max(r, g, b);
215
- const delta = max - min;
216
- let h;
217
- let s;
218
- if (max === min) {
219
- h = 0;
220
- } else if (r === max) {
221
- h = (g - b) / delta;
222
- } else if (g === max) {
223
- h = 2 + (b - r) / delta;
224
- } else if (b === max) {
225
- h = 4 + (r - g) / delta;
226
- }
227
- h = Math.min(h * 60, 360);
228
- if (h < 0) {
229
- h += 360;
230
- }
231
- const l = (min + max) / 2;
232
- if (max === min) {
233
- s = 0;
234
- } else if (l <= 0.5) {
235
- s = delta / (max + min);
236
- } else {
237
- s = delta / (2 - max - min);
238
- }
239
- return [h, s * 100, l * 100];
240
- };
241
- convert.rgb.hsv = function(rgb) {
242
- let rdif;
243
- let gdif;
244
- let bdif;
245
- let h;
246
- let s;
247
- const r = rgb[0] / 255;
248
- const g = rgb[1] / 255;
249
- const b = rgb[2] / 255;
250
- const v = Math.max(r, g, b);
251
- const diff = v - Math.min(r, g, b);
252
- const diffc = function(c) {
253
- return (v - c) / 6 / diff + 1 / 2;
254
- };
255
- if (diff === 0) {
256
- h = 0;
257
- s = 0;
258
- } else {
259
- s = diff / v;
260
- rdif = diffc(r);
261
- gdif = diffc(g);
262
- bdif = diffc(b);
263
- if (r === v) {
264
- h = bdif - gdif;
265
- } else if (g === v) {
266
- h = 1 / 3 + rdif - bdif;
267
- } else if (b === v) {
268
- h = 2 / 3 + gdif - rdif;
269
- }
270
- if (h < 0) {
271
- h += 1;
272
- } else if (h > 1) {
273
- h -= 1;
274
- }
275
- }
276
- return [
277
- h * 360,
278
- s * 100,
279
- v * 100
280
- ];
281
- };
282
- convert.rgb.hwb = function(rgb) {
283
- const r = rgb[0];
284
- const g = rgb[1];
285
- let b = rgb[2];
286
- const h = convert.rgb.hsl(rgb)[0];
287
- const w = 1 / 255 * Math.min(r, Math.min(g, b));
288
- b = 1 - 1 / 255 * Math.max(r, Math.max(g, b));
289
- return [h, w * 100, b * 100];
290
- };
291
- convert.rgb.cmyk = function(rgb) {
292
- const r = rgb[0] / 255;
293
- const g = rgb[1] / 255;
294
- const b = rgb[2] / 255;
295
- const k = Math.min(1 - r, 1 - g, 1 - b);
296
- const c = (1 - r - k) / (1 - k) || 0;
297
- const m = (1 - g - k) / (1 - k) || 0;
298
- const y = (1 - b - k) / (1 - k) || 0;
299
- return [c * 100, m * 100, y * 100, k * 100];
300
- };
301
- function comparativeDistance(x, y) {
302
- return (x[0] - y[0]) ** 2 + (x[1] - y[1]) ** 2 + (x[2] - y[2]) ** 2;
303
- }
304
- convert.rgb.keyword = function(rgb) {
305
- const reversed = reverseKeywords[rgb];
306
- if (reversed) {
307
- return reversed;
308
- }
309
- let currentClosestDistance = Infinity;
310
- let currentClosestKeyword;
311
- for (const keyword of Object.keys(cssKeywords)) {
312
- const value = cssKeywords[keyword];
313
- const distance = comparativeDistance(rgb, value);
314
- if (distance < currentClosestDistance) {
315
- currentClosestDistance = distance;
316
- currentClosestKeyword = keyword;
317
- }
318
- }
319
- return currentClosestKeyword;
320
- };
321
- convert.keyword.rgb = function(keyword) {
322
- return cssKeywords[keyword];
323
- };
324
- convert.rgb.xyz = function(rgb) {
325
- let r = rgb[0] / 255;
326
- let g = rgb[1] / 255;
327
- let b = rgb[2] / 255;
328
- r = r > 0.04045 ? ((r + 0.055) / 1.055) ** 2.4 : r / 12.92;
329
- g = g > 0.04045 ? ((g + 0.055) / 1.055) ** 2.4 : g / 12.92;
330
- b = b > 0.04045 ? ((b + 0.055) / 1.055) ** 2.4 : b / 12.92;
331
- const x = r * 0.4124 + g * 0.3576 + b * 0.1805;
332
- const y = r * 0.2126 + g * 0.7152 + b * 0.0722;
333
- const z = r * 0.0193 + g * 0.1192 + b * 0.9505;
334
- return [x * 100, y * 100, z * 100];
335
- };
336
- convert.rgb.lab = function(rgb) {
337
- const xyz = convert.rgb.xyz(rgb);
338
- let x = xyz[0];
339
- let y = xyz[1];
340
- let z = xyz[2];
341
- x /= 95.047;
342
- y /= 100;
343
- z /= 108.883;
344
- x = x > 8856e-6 ? x ** (1 / 3) : 7.787 * x + 16 / 116;
345
- y = y > 8856e-6 ? y ** (1 / 3) : 7.787 * y + 16 / 116;
346
- z = z > 8856e-6 ? z ** (1 / 3) : 7.787 * z + 16 / 116;
347
- const l = 116 * y - 16;
348
- const a = 500 * (x - y);
349
- const b = 200 * (y - z);
350
- return [l, a, b];
351
- };
352
- convert.hsl.rgb = function(hsl) {
353
- const h = hsl[0] / 360;
354
- const s = hsl[1] / 100;
355
- const l = hsl[2] / 100;
356
- let t2;
357
- let t3;
358
- let val;
359
- if (s === 0) {
360
- val = l * 255;
361
- return [val, val, val];
362
- }
363
- if (l < 0.5) {
364
- t2 = l * (1 + s);
365
- } else {
366
- t2 = l + s - l * s;
367
- }
368
- const t1 = 2 * l - t2;
369
- const rgb = [0, 0, 0];
370
- for (let i = 0; i < 3; i++) {
371
- t3 = h + 1 / 3 * -(i - 1);
372
- if (t3 < 0) {
373
- t3++;
374
- }
375
- if (t3 > 1) {
376
- t3--;
377
- }
378
- if (6 * t3 < 1) {
379
- val = t1 + (t2 - t1) * 6 * t3;
380
- } else if (2 * t3 < 1) {
381
- val = t2;
382
- } else if (3 * t3 < 2) {
383
- val = t1 + (t2 - t1) * (2 / 3 - t3) * 6;
384
- } else {
385
- val = t1;
386
- }
387
- rgb[i] = val * 255;
388
- }
389
- return rgb;
390
- };
391
- convert.hsl.hsv = function(hsl) {
392
- const h = hsl[0];
393
- let s = hsl[1] / 100;
394
- let l = hsl[2] / 100;
395
- let smin = s;
396
- const lmin = Math.max(l, 0.01);
397
- l *= 2;
398
- s *= l <= 1 ? l : 2 - l;
399
- smin *= lmin <= 1 ? lmin : 2 - lmin;
400
- const v = (l + s) / 2;
401
- const sv = l === 0 ? 2 * smin / (lmin + smin) : 2 * s / (l + s);
402
- return [h, sv * 100, v * 100];
403
- };
404
- convert.hsv.rgb = function(hsv) {
405
- const h = hsv[0] / 60;
406
- const s = hsv[1] / 100;
407
- let v = hsv[2] / 100;
408
- const hi = Math.floor(h) % 6;
409
- const f = h - Math.floor(h);
410
- const p = 255 * v * (1 - s);
411
- const q = 255 * v * (1 - s * f);
412
- const t = 255 * v * (1 - s * (1 - f));
413
- v *= 255;
414
- switch (hi) {
415
- case 0:
416
- return [v, t, p];
417
- case 1:
418
- return [q, v, p];
419
- case 2:
420
- return [p, v, t];
421
- case 3:
422
- return [p, q, v];
423
- case 4:
424
- return [t, p, v];
425
- case 5:
426
- return [v, p, q];
427
- }
428
- };
429
- convert.hsv.hsl = function(hsv) {
430
- const h = hsv[0];
431
- const s = hsv[1] / 100;
432
- const v = hsv[2] / 100;
433
- const vmin = Math.max(v, 0.01);
434
- let sl;
435
- let l;
436
- l = (2 - s) * v;
437
- const lmin = (2 - s) * vmin;
438
- sl = s * vmin;
439
- sl /= lmin <= 1 ? lmin : 2 - lmin;
440
- sl = sl || 0;
441
- l /= 2;
442
- return [h, sl * 100, l * 100];
443
- };
444
- convert.hwb.rgb = function(hwb) {
445
- const h = hwb[0] / 360;
446
- let wh = hwb[1] / 100;
447
- let bl = hwb[2] / 100;
448
- const ratio = wh + bl;
449
- let f;
450
- if (ratio > 1) {
451
- wh /= ratio;
452
- bl /= ratio;
453
- }
454
- const i = Math.floor(6 * h);
455
- const v = 1 - bl;
456
- f = 6 * h - i;
457
- if ((i & 1) !== 0) {
458
- f = 1 - f;
459
- }
460
- const n = wh + f * (v - wh);
461
- let r;
462
- let g;
463
- let b;
464
- switch (i) {
465
- default:
466
- case 6:
467
- case 0:
468
- r = v;
469
- g = n;
470
- b = wh;
471
- break;
472
- case 1:
473
- r = n;
474
- g = v;
475
- b = wh;
476
- break;
477
- case 2:
478
- r = wh;
479
- g = v;
480
- b = n;
481
- break;
482
- case 3:
483
- r = wh;
484
- g = n;
485
- b = v;
486
- break;
487
- case 4:
488
- r = n;
489
- g = wh;
490
- b = v;
491
- break;
492
- case 5:
493
- r = v;
494
- g = wh;
495
- b = n;
496
- break;
497
- }
498
- return [r * 255, g * 255, b * 255];
499
- };
500
- convert.cmyk.rgb = function(cmyk) {
501
- const c = cmyk[0] / 100;
502
- const m = cmyk[1] / 100;
503
- const y = cmyk[2] / 100;
504
- const k = cmyk[3] / 100;
505
- const r = 1 - Math.min(1, c * (1 - k) + k);
506
- const g = 1 - Math.min(1, m * (1 - k) + k);
507
- const b = 1 - Math.min(1, y * (1 - k) + k);
508
- return [r * 255, g * 255, b * 255];
509
- };
510
- convert.xyz.rgb = function(xyz) {
511
- const x = xyz[0] / 100;
512
- const y = xyz[1] / 100;
513
- const z = xyz[2] / 100;
514
- let r;
515
- let g;
516
- let b;
517
- r = x * 3.2406 + y * -1.5372 + z * -0.4986;
518
- g = x * -0.9689 + y * 1.8758 + z * 0.0415;
519
- b = x * 0.0557 + y * -0.204 + z * 1.057;
520
- r = r > 31308e-7 ? 1.055 * r ** (1 / 2.4) - 0.055 : r * 12.92;
521
- g = g > 31308e-7 ? 1.055 * g ** (1 / 2.4) - 0.055 : g * 12.92;
522
- b = b > 31308e-7 ? 1.055 * b ** (1 / 2.4) - 0.055 : b * 12.92;
523
- r = Math.min(Math.max(0, r), 1);
524
- g = Math.min(Math.max(0, g), 1);
525
- b = Math.min(Math.max(0, b), 1);
526
- return [r * 255, g * 255, b * 255];
527
- };
528
- convert.xyz.lab = function(xyz) {
529
- let x = xyz[0];
530
- let y = xyz[1];
531
- let z = xyz[2];
532
- x /= 95.047;
533
- y /= 100;
534
- z /= 108.883;
535
- x = x > 8856e-6 ? x ** (1 / 3) : 7.787 * x + 16 / 116;
536
- y = y > 8856e-6 ? y ** (1 / 3) : 7.787 * y + 16 / 116;
537
- z = z > 8856e-6 ? z ** (1 / 3) : 7.787 * z + 16 / 116;
538
- const l = 116 * y - 16;
539
- const a = 500 * (x - y);
540
- const b = 200 * (y - z);
541
- return [l, a, b];
542
- };
543
- convert.lab.xyz = function(lab) {
544
- const l = lab[0];
545
- const a = lab[1];
546
- const b = lab[2];
547
- let x;
548
- let y;
549
- let z;
550
- y = (l + 16) / 116;
551
- x = a / 500 + y;
552
- z = y - b / 200;
553
- const y2 = y ** 3;
554
- const x2 = x ** 3;
555
- const z2 = z ** 3;
556
- y = y2 > 8856e-6 ? y2 : (y - 16 / 116) / 7.787;
557
- x = x2 > 8856e-6 ? x2 : (x - 16 / 116) / 7.787;
558
- z = z2 > 8856e-6 ? z2 : (z - 16 / 116) / 7.787;
559
- x *= 95.047;
560
- y *= 100;
561
- z *= 108.883;
562
- return [x, y, z];
563
- };
564
- convert.lab.lch = function(lab) {
565
- const l = lab[0];
566
- const a = lab[1];
567
- const b = lab[2];
568
- let h;
569
- const hr = Math.atan2(b, a);
570
- h = hr * 360 / 2 / Math.PI;
571
- if (h < 0) {
572
- h += 360;
573
- }
574
- const c = Math.sqrt(a * a + b * b);
575
- return [l, c, h];
576
- };
577
- convert.lch.lab = function(lch) {
578
- const l = lch[0];
579
- const c = lch[1];
580
- const h = lch[2];
581
- const hr = h / 360 * 2 * Math.PI;
582
- const a = c * Math.cos(hr);
583
- const b = c * Math.sin(hr);
584
- return [l, a, b];
585
- };
586
- convert.rgb.ansi16 = function(args, saturation = null) {
587
- const [r, g, b] = args;
588
- let value = saturation === null ? convert.rgb.hsv(args)[2] : saturation;
589
- value = Math.round(value / 50);
590
- if (value === 0) {
591
- return 30;
592
- }
593
- let ansi = 30 + (Math.round(b / 255) << 2 | Math.round(g / 255) << 1 | Math.round(r / 255));
594
- if (value === 2) {
595
- ansi += 60;
596
- }
597
- return ansi;
598
- };
599
- convert.hsv.ansi16 = function(args) {
600
- return convert.rgb.ansi16(convert.hsv.rgb(args), args[2]);
601
- };
602
- convert.rgb.ansi256 = function(args) {
603
- const r = args[0];
604
- const g = args[1];
605
- const b = args[2];
606
- if (r === g && g === b) {
607
- if (r < 8) {
608
- return 16;
609
- }
610
- if (r > 248) {
611
- return 231;
612
- }
613
- return Math.round((r - 8) / 247 * 24) + 232;
614
- }
615
- const ansi = 16 + 36 * Math.round(r / 255 * 5) + 6 * Math.round(g / 255 * 5) + Math.round(b / 255 * 5);
616
- return ansi;
617
- };
618
- convert.ansi16.rgb = function(args) {
619
- let color = args % 10;
620
- if (color === 0 || color === 7) {
621
- if (args > 50) {
622
- color += 3.5;
623
- }
624
- color = color / 10.5 * 255;
625
- return [color, color, color];
626
- }
627
- const mult = (~~(args > 50) + 1) * 0.5;
628
- const r = (color & 1) * mult * 255;
629
- const g = (color >> 1 & 1) * mult * 255;
630
- const b = (color >> 2 & 1) * mult * 255;
631
- return [r, g, b];
632
- };
633
- convert.ansi256.rgb = function(args) {
634
- if (args >= 232) {
635
- const c = (args - 232) * 10 + 8;
636
- return [c, c, c];
637
- }
638
- args -= 16;
639
- let rem;
640
- const r = Math.floor(args / 36) / 5 * 255;
641
- const g = Math.floor((rem = args % 36) / 6) / 5 * 255;
642
- const b = rem % 6 / 5 * 255;
643
- return [r, g, b];
644
- };
645
- convert.rgb.hex = function(args) {
646
- const integer = ((Math.round(args[0]) & 255) << 16) + ((Math.round(args[1]) & 255) << 8) + (Math.round(args[2]) & 255);
647
- const string = integer.toString(16).toUpperCase();
648
- return "000000".substring(string.length) + string;
649
- };
650
- convert.hex.rgb = function(args) {
651
- const match = args.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);
652
- if (!match) {
653
- return [0, 0, 0];
654
- }
655
- let colorString = match[0];
656
- if (match[0].length === 3) {
657
- colorString = colorString.split("").map((char) => {
658
- return char + char;
659
- }).join("");
660
- }
661
- const integer = parseInt(colorString, 16);
662
- const r = integer >> 16 & 255;
663
- const g = integer >> 8 & 255;
664
- const b = integer & 255;
665
- return [r, g, b];
666
- };
667
- convert.rgb.hcg = function(rgb) {
668
- const r = rgb[0] / 255;
669
- const g = rgb[1] / 255;
670
- const b = rgb[2] / 255;
671
- const max = Math.max(Math.max(r, g), b);
672
- const min = Math.min(Math.min(r, g), b);
673
- const chroma = max - min;
674
- let grayscale;
675
- let hue;
676
- if (chroma < 1) {
677
- grayscale = min / (1 - chroma);
678
- } else {
679
- grayscale = 0;
680
- }
681
- if (chroma <= 0) {
682
- hue = 0;
683
- } else if (max === r) {
684
- hue = (g - b) / chroma % 6;
685
- } else if (max === g) {
686
- hue = 2 + (b - r) / chroma;
687
- } else {
688
- hue = 4 + (r - g) / chroma;
689
- }
690
- hue /= 6;
691
- hue %= 1;
692
- return [hue * 360, chroma * 100, grayscale * 100];
693
- };
694
- convert.hsl.hcg = function(hsl) {
695
- const s = hsl[1] / 100;
696
- const l = hsl[2] / 100;
697
- const c = l < 0.5 ? 2 * s * l : 2 * s * (1 - l);
698
- let f = 0;
699
- if (c < 1) {
700
- f = (l - 0.5 * c) / (1 - c);
701
- }
702
- return [hsl[0], c * 100, f * 100];
703
- };
704
- convert.hsv.hcg = function(hsv) {
705
- const s = hsv[1] / 100;
706
- const v = hsv[2] / 100;
707
- const c = s * v;
708
- let f = 0;
709
- if (c < 1) {
710
- f = (v - c) / (1 - c);
711
- }
712
- return [hsv[0], c * 100, f * 100];
713
- };
714
- convert.hcg.rgb = function(hcg) {
715
- const h = hcg[0] / 360;
716
- const c = hcg[1] / 100;
717
- const g = hcg[2] / 100;
718
- if (c === 0) {
719
- return [g * 255, g * 255, g * 255];
720
- }
721
- const pure = [0, 0, 0];
722
- const hi = h % 1 * 6;
723
- const v = hi % 1;
724
- const w = 1 - v;
725
- let mg = 0;
726
- switch (Math.floor(hi)) {
727
- case 0:
728
- pure[0] = 1;
729
- pure[1] = v;
730
- pure[2] = 0;
731
- break;
732
- case 1:
733
- pure[0] = w;
734
- pure[1] = 1;
735
- pure[2] = 0;
736
- break;
737
- case 2:
738
- pure[0] = 0;
739
- pure[1] = 1;
740
- pure[2] = v;
741
- break;
742
- case 3:
743
- pure[0] = 0;
744
- pure[1] = w;
745
- pure[2] = 1;
746
- break;
747
- case 4:
748
- pure[0] = v;
749
- pure[1] = 0;
750
- pure[2] = 1;
751
- break;
752
- default:
753
- pure[0] = 1;
754
- pure[1] = 0;
755
- pure[2] = w;
756
- }
757
- mg = (1 - c) * g;
758
- return [
759
- (c * pure[0] + mg) * 255,
760
- (c * pure[1] + mg) * 255,
761
- (c * pure[2] + mg) * 255
762
- ];
763
- };
764
- convert.hcg.hsv = function(hcg) {
765
- const c = hcg[1] / 100;
766
- const g = hcg[2] / 100;
767
- const v = c + g * (1 - c);
768
- let f = 0;
769
- if (v > 0) {
770
- f = c / v;
771
- }
772
- return [hcg[0], f * 100, v * 100];
773
- };
774
- convert.hcg.hsl = function(hcg) {
775
- const c = hcg[1] / 100;
776
- const g = hcg[2] / 100;
777
- const l = g * (1 - c) + 0.5 * c;
778
- let s = 0;
779
- if (l > 0 && l < 0.5) {
780
- s = c / (2 * l);
781
- } else if (l >= 0.5 && l < 1) {
782
- s = c / (2 * (1 - l));
783
- }
784
- return [hcg[0], s * 100, l * 100];
785
- };
786
- convert.hcg.hwb = function(hcg) {
787
- const c = hcg[1] / 100;
788
- const g = hcg[2] / 100;
789
- const v = c + g * (1 - c);
790
- return [hcg[0], (v - c) * 100, (1 - v) * 100];
791
- };
792
- convert.hwb.hcg = function(hwb) {
793
- const w = hwb[1] / 100;
794
- const b = hwb[2] / 100;
795
- const v = 1 - b;
796
- const c = v - w;
797
- let g = 0;
798
- if (c < 1) {
799
- g = (v - c) / (1 - c);
800
- }
801
- return [hwb[0], c * 100, g * 100];
802
- };
803
- convert.apple.rgb = function(apple) {
804
- return [apple[0] / 65535 * 255, apple[1] / 65535 * 255, apple[2] / 65535 * 255];
805
- };
806
- convert.rgb.apple = function(rgb) {
807
- return [rgb[0] / 255 * 65535, rgb[1] / 255 * 65535, rgb[2] / 255 * 65535];
808
- };
809
- convert.gray.rgb = function(args) {
810
- return [args[0] / 100 * 255, args[0] / 100 * 255, args[0] / 100 * 255];
811
- };
812
- convert.gray.hsl = function(args) {
813
- return [0, 0, args[0]];
814
- };
815
- convert.gray.hsv = convert.gray.hsl;
816
- convert.gray.hwb = function(gray) {
817
- return [0, 100, gray[0]];
818
- };
819
- convert.gray.cmyk = function(gray) {
820
- return [0, 0, 0, gray[0]];
821
- };
822
- convert.gray.lab = function(gray) {
823
- return [gray[0], 0, 0];
824
- };
825
- convert.gray.hex = function(gray) {
826
- const val = Math.round(gray[0] / 100 * 255) & 255;
827
- const integer = (val << 16) + (val << 8) + val;
828
- const string = integer.toString(16).toUpperCase();
829
- return "000000".substring(string.length) + string;
830
- };
831
- convert.rgb.gray = function(rgb) {
832
- const val = (rgb[0] + rgb[1] + rgb[2]) / 3;
833
- return [val / 255 * 100];
834
- };
835
- return conversions;
836
- }
837
- var route;
838
- var hasRequiredRoute;
839
- function requireRoute() {
840
- if (hasRequiredRoute) return route;
841
- hasRequiredRoute = 1;
842
- const conversions2 = requireConversions();
843
- function buildGraph() {
844
- const graph = {};
845
- const models = Object.keys(conversions2);
846
- for (let len = models.length, i = 0; i < len; i++) {
847
- graph[models[i]] = {
848
- // http://jsperf.com/1-vs-infinity
849
- // micro-opt, but this is simple.
850
- distance: -1,
851
- parent: null
852
- };
853
- }
854
- return graph;
855
- }
856
- function deriveBFS(fromModel) {
857
- const graph = buildGraph();
858
- const queue = [fromModel];
859
- graph[fromModel].distance = 0;
860
- while (queue.length) {
861
- const current = queue.pop();
862
- const adjacents = Object.keys(conversions2[current]);
863
- for (let len = adjacents.length, i = 0; i < len; i++) {
864
- const adjacent = adjacents[i];
865
- const node = graph[adjacent];
866
- if (node.distance === -1) {
867
- node.distance = graph[current].distance + 1;
868
- node.parent = current;
869
- queue.unshift(adjacent);
870
- }
871
- }
872
- }
873
- return graph;
874
- }
875
- function link(from, to) {
876
- return function(args) {
877
- return to(from(args));
878
- };
879
- }
880
- function wrapConversion(toModel, graph) {
881
- const path = [graph[toModel].parent, toModel];
882
- let fn = conversions2[graph[toModel].parent][toModel];
883
- let cur = graph[toModel].parent;
884
- while (graph[cur].parent) {
885
- path.unshift(graph[cur].parent);
886
- fn = link(conversions2[graph[cur].parent][cur], fn);
887
- cur = graph[cur].parent;
888
- }
889
- fn.conversion = path;
890
- return fn;
891
- }
892
- route = function(fromModel) {
893
- const graph = deriveBFS(fromModel);
894
- const conversion = {};
895
- const models = Object.keys(graph);
896
- for (let len = models.length, i = 0; i < len; i++) {
897
- const toModel = models[i];
898
- const node = graph[toModel];
899
- if (node.parent === null) {
900
- continue;
901
- }
902
- conversion[toModel] = wrapConversion(toModel, graph);
903
- }
904
- return conversion;
905
- };
906
- return route;
907
- }
908
- var colorConvert;
909
- var hasRequiredColorConvert;
910
- function requireColorConvert() {
911
- if (hasRequiredColorConvert) return colorConvert;
912
- hasRequiredColorConvert = 1;
913
- const conversions2 = requireConversions();
914
- const route2 = requireRoute();
915
- const convert = {};
916
- const models = Object.keys(conversions2);
917
- function wrapRaw(fn) {
918
- const wrappedFn = function(...args) {
919
- const arg0 = args[0];
920
- if (arg0 === void 0 || arg0 === null) {
921
- return arg0;
922
- }
923
- if (arg0.length > 1) {
924
- args = arg0;
925
- }
926
- return fn(args);
927
- };
928
- if ("conversion" in fn) {
929
- wrappedFn.conversion = fn.conversion;
930
- }
931
- return wrappedFn;
932
- }
933
- function wrapRounded(fn) {
934
- const wrappedFn = function(...args) {
935
- const arg0 = args[0];
936
- if (arg0 === void 0 || arg0 === null) {
937
- return arg0;
938
- }
939
- if (arg0.length > 1) {
940
- args = arg0;
941
- }
942
- const result = fn(args);
943
- if (typeof result === "object") {
944
- for (let len = result.length, i = 0; i < len; i++) {
945
- result[i] = Math.round(result[i]);
946
- }
947
- }
948
- return result;
949
- };
950
- if ("conversion" in fn) {
951
- wrappedFn.conversion = fn.conversion;
952
- }
953
- return wrappedFn;
954
- }
955
- models.forEach((fromModel) => {
956
- convert[fromModel] = {};
957
- Object.defineProperty(convert[fromModel], "channels", { value: conversions2[fromModel].channels });
958
- Object.defineProperty(convert[fromModel], "labels", { value: conversions2[fromModel].labels });
959
- const routes = route2(fromModel);
960
- const routeModels = Object.keys(routes);
961
- routeModels.forEach((toModel) => {
962
- const fn = routes[toModel];
963
- convert[fromModel][toModel] = wrapRounded(fn);
964
- convert[fromModel][toModel].raw = wrapRaw(fn);
965
- });
966
- });
967
- colorConvert = convert;
968
- return colorConvert;
969
- }
970
- ansiStyles.exports;
971
- var hasRequiredAnsiStyles;
972
- function requireAnsiStyles() {
973
- if (hasRequiredAnsiStyles) return ansiStyles.exports;
974
- hasRequiredAnsiStyles = 1;
975
- (function(module2) {
976
- const wrapAnsi16 = (fn, offset) => (...args) => {
977
- const code = fn(...args);
978
- return `\x1B[${code + offset}m`;
979
- };
980
- const wrapAnsi256 = (fn, offset) => (...args) => {
981
- const code = fn(...args);
982
- return `\x1B[${38 + offset};5;${code}m`;
983
- };
984
- const wrapAnsi16m = (fn, offset) => (...args) => {
985
- const rgb = fn(...args);
986
- return `\x1B[${38 + offset};2;${rgb[0]};${rgb[1]};${rgb[2]}m`;
987
- };
988
- const ansi2ansi = (n) => n;
989
- const rgb2rgb = (r, g, b) => [r, g, b];
990
- const setLazyProperty = (object, property, get) => {
991
- Object.defineProperty(object, property, {
992
- get: () => {
993
- const value = get();
994
- Object.defineProperty(object, property, {
995
- value,
996
- enumerable: true,
997
- configurable: true
998
- });
999
- return value;
1000
- },
1001
- enumerable: true,
1002
- configurable: true
1003
- });
1004
- };
1005
- let colorConvert2;
1006
- const makeDynamicStyles = (wrap, targetSpace, identity, isBackground) => {
1007
- if (colorConvert2 === void 0) {
1008
- colorConvert2 = requireColorConvert();
1009
- }
1010
- const offset = isBackground ? 10 : 0;
1011
- const styles = {};
1012
- for (const [sourceSpace, suite] of Object.entries(colorConvert2)) {
1013
- const name = sourceSpace === "ansi16" ? "ansi" : sourceSpace;
1014
- if (sourceSpace === targetSpace) {
1015
- styles[name] = wrap(identity, offset);
1016
- } else if (typeof suite === "object") {
1017
- styles[name] = wrap(suite[targetSpace], offset);
1018
- }
1019
- }
1020
- return styles;
1021
- };
1022
- function assembleStyles() {
1023
- const codes = /* @__PURE__ */ new Map();
1024
- const styles = {
1025
- modifier: {
1026
- reset: [0, 0],
1027
- // 21 isn't widely supported and 22 does the same thing
1028
- bold: [1, 22],
1029
- dim: [2, 22],
1030
- italic: [3, 23],
1031
- underline: [4, 24],
1032
- inverse: [7, 27],
1033
- hidden: [8, 28],
1034
- strikethrough: [9, 29]
1035
- },
1036
- color: {
1037
- black: [30, 39],
1038
- red: [31, 39],
1039
- green: [32, 39],
1040
- yellow: [33, 39],
1041
- blue: [34, 39],
1042
- magenta: [35, 39],
1043
- cyan: [36, 39],
1044
- white: [37, 39],
1045
- // Bright color
1046
- blackBright: [90, 39],
1047
- redBright: [91, 39],
1048
- greenBright: [92, 39],
1049
- yellowBright: [93, 39],
1050
- blueBright: [94, 39],
1051
- magentaBright: [95, 39],
1052
- cyanBright: [96, 39],
1053
- whiteBright: [97, 39]
1054
- },
1055
- bgColor: {
1056
- bgBlack: [40, 49],
1057
- bgRed: [41, 49],
1058
- bgGreen: [42, 49],
1059
- bgYellow: [43, 49],
1060
- bgBlue: [44, 49],
1061
- bgMagenta: [45, 49],
1062
- bgCyan: [46, 49],
1063
- bgWhite: [47, 49],
1064
- // Bright color
1065
- bgBlackBright: [100, 49],
1066
- bgRedBright: [101, 49],
1067
- bgGreenBright: [102, 49],
1068
- bgYellowBright: [103, 49],
1069
- bgBlueBright: [104, 49],
1070
- bgMagentaBright: [105, 49],
1071
- bgCyanBright: [106, 49],
1072
- bgWhiteBright: [107, 49]
1073
- }
1074
- };
1075
- styles.color.gray = styles.color.blackBright;
1076
- styles.bgColor.bgGray = styles.bgColor.bgBlackBright;
1077
- styles.color.grey = styles.color.blackBright;
1078
- styles.bgColor.bgGrey = styles.bgColor.bgBlackBright;
1079
- for (const [groupName, group] of Object.entries(styles)) {
1080
- for (const [styleName, style] of Object.entries(group)) {
1081
- styles[styleName] = {
1082
- open: `\x1B[${style[0]}m`,
1083
- close: `\x1B[${style[1]}m`
1084
- };
1085
- group[styleName] = styles[styleName];
1086
- codes.set(style[0], style[1]);
1087
- }
1088
- Object.defineProperty(styles, groupName, {
1089
- value: group,
1090
- enumerable: false
1091
- });
1092
- }
1093
- Object.defineProperty(styles, "codes", {
1094
- value: codes,
1095
- enumerable: false
1096
- });
1097
- styles.color.close = "\x1B[39m";
1098
- styles.bgColor.close = "\x1B[49m";
1099
- setLazyProperty(styles.color, "ansi", () => makeDynamicStyles(wrapAnsi16, "ansi16", ansi2ansi, false));
1100
- setLazyProperty(styles.color, "ansi256", () => makeDynamicStyles(wrapAnsi256, "ansi256", ansi2ansi, false));
1101
- setLazyProperty(styles.color, "ansi16m", () => makeDynamicStyles(wrapAnsi16m, "rgb", rgb2rgb, false));
1102
- setLazyProperty(styles.bgColor, "ansi", () => makeDynamicStyles(wrapAnsi16, "ansi16", ansi2ansi, true));
1103
- setLazyProperty(styles.bgColor, "ansi256", () => makeDynamicStyles(wrapAnsi256, "ansi256", ansi2ansi, true));
1104
- setLazyProperty(styles.bgColor, "ansi16m", () => makeDynamicStyles(wrapAnsi16m, "rgb", rgb2rgb, true));
1105
- return styles;
1106
- }
1107
- Object.defineProperty(module2, "exports", {
1108
- enumerable: true,
1109
- get: assembleStyles
1110
- });
1111
- })(ansiStyles);
1112
- return ansiStyles.exports;
2
+ //#region node_modules/chalk/source/vendor/ansi-styles/index.js
3
+ var ANSI_BACKGROUND_OFFSET = 10;
4
+ var wrapAnsi16 = (offset = 0) => (code) => `\u001B[${code + offset}m`;
5
+ var wrapAnsi256 = (offset = 0) => (code) => `\u001B[${38 + offset};5;${code}m`;
6
+ var wrapAnsi16m = (offset = 0) => (red, green, blue) => `\u001B[${38 + offset};2;${red};${green};${blue}m`;
7
+ var styles$1 = {
8
+ modifier: {
9
+ reset: [0, 0],
10
+ bold: [1, 22],
11
+ dim: [2, 22],
12
+ italic: [3, 23],
13
+ underline: [4, 24],
14
+ overline: [53, 55],
15
+ inverse: [7, 27],
16
+ hidden: [8, 28],
17
+ strikethrough: [9, 29]
18
+ },
19
+ color: {
20
+ black: [30, 39],
21
+ red: [31, 39],
22
+ green: [32, 39],
23
+ yellow: [33, 39],
24
+ blue: [34, 39],
25
+ magenta: [35, 39],
26
+ cyan: [36, 39],
27
+ white: [37, 39],
28
+ blackBright: [90, 39],
29
+ gray: [90, 39],
30
+ grey: [90, 39],
31
+ redBright: [91, 39],
32
+ greenBright: [92, 39],
33
+ yellowBright: [93, 39],
34
+ blueBright: [94, 39],
35
+ magentaBright: [95, 39],
36
+ cyanBright: [96, 39],
37
+ whiteBright: [97, 39]
38
+ },
39
+ bgColor: {
40
+ bgBlack: [40, 49],
41
+ bgRed: [41, 49],
42
+ bgGreen: [42, 49],
43
+ bgYellow: [43, 49],
44
+ bgBlue: [44, 49],
45
+ bgMagenta: [45, 49],
46
+ bgCyan: [46, 49],
47
+ bgWhite: [47, 49],
48
+ bgBlackBright: [100, 49],
49
+ bgGray: [100, 49],
50
+ bgGrey: [100, 49],
51
+ bgRedBright: [101, 49],
52
+ bgGreenBright: [102, 49],
53
+ bgYellowBright: [103, 49],
54
+ bgBlueBright: [104, 49],
55
+ bgMagentaBright: [105, 49],
56
+ bgCyanBright: [106, 49],
57
+ bgWhiteBright: [107, 49]
58
+ }
59
+ };
60
+ Object.keys(styles$1.modifier);
61
+ var foregroundColorNames = Object.keys(styles$1.color);
62
+ var backgroundColorNames = Object.keys(styles$1.bgColor);
63
+ [...foregroundColorNames, ...backgroundColorNames];
64
+ function assembleStyles() {
65
+ const codes = /* @__PURE__ */ new Map();
66
+ for (const [groupName, group] of Object.entries(styles$1)) {
67
+ for (const [styleName, style] of Object.entries(group)) {
68
+ styles$1[styleName] = {
69
+ open: `\u001B[${style[0]}m`,
70
+ close: `\u001B[${style[1]}m`
71
+ };
72
+ group[styleName] = styles$1[styleName];
73
+ codes.set(style[0], style[1]);
74
+ }
75
+ Object.defineProperty(styles$1, groupName, {
76
+ value: group,
77
+ enumerable: false
78
+ });
79
+ }
80
+ Object.defineProperty(styles$1, "codes", {
81
+ value: codes,
82
+ enumerable: false
83
+ });
84
+ styles$1.color.close = "\x1B[39m";
85
+ styles$1.bgColor.close = "\x1B[49m";
86
+ styles$1.color.ansi = wrapAnsi16();
87
+ styles$1.color.ansi256 = wrapAnsi256();
88
+ styles$1.color.ansi16m = wrapAnsi16m();
89
+ styles$1.bgColor.ansi = wrapAnsi16(ANSI_BACKGROUND_OFFSET);
90
+ styles$1.bgColor.ansi256 = wrapAnsi256(ANSI_BACKGROUND_OFFSET);
91
+ styles$1.bgColor.ansi16m = wrapAnsi16m(ANSI_BACKGROUND_OFFSET);
92
+ Object.defineProperties(styles$1, {
93
+ rgbToAnsi256: {
94
+ value(red, green, blue) {
95
+ if (red === green && green === blue) {
96
+ if (red < 8) return 16;
97
+ if (red > 248) return 231;
98
+ return Math.round((red - 8) / 247 * 24) + 232;
99
+ }
100
+ return 16 + 36 * Math.round(red / 255 * 5) + 6 * Math.round(green / 255 * 5) + Math.round(blue / 255 * 5);
101
+ },
102
+ enumerable: false
103
+ },
104
+ hexToRgb: {
105
+ value(hex) {
106
+ const matches = /[a-f\d]{6}|[a-f\d]{3}/i.exec(hex.toString(16));
107
+ if (!matches) return [
108
+ 0,
109
+ 0,
110
+ 0
111
+ ];
112
+ let [colorString] = matches;
113
+ if (colorString.length === 3) colorString = [...colorString].map((character) => character + character).join("");
114
+ const integer = Number.parseInt(colorString, 16);
115
+ return [
116
+ integer >> 16 & 255,
117
+ integer >> 8 & 255,
118
+ integer & 255
119
+ ];
120
+ },
121
+ enumerable: false
122
+ },
123
+ hexToAnsi256: {
124
+ value: (hex) => styles$1.rgbToAnsi256(...styles$1.hexToRgb(hex)),
125
+ enumerable: false
126
+ },
127
+ ansi256ToAnsi: {
128
+ value(code) {
129
+ if (code < 8) return 30 + code;
130
+ if (code < 16) return 90 + (code - 8);
131
+ let red;
132
+ let green;
133
+ let blue;
134
+ if (code >= 232) {
135
+ red = ((code - 232) * 10 + 8) / 255;
136
+ green = red;
137
+ blue = red;
138
+ } else {
139
+ code -= 16;
140
+ const remainder = code % 36;
141
+ red = Math.floor(code / 36) / 5;
142
+ green = Math.floor(remainder / 6) / 5;
143
+ blue = remainder % 6 / 5;
144
+ }
145
+ const value = Math.max(red, green, blue) * 2;
146
+ if (value === 0) return 30;
147
+ let result = 30 + (Math.round(blue) << 2 | Math.round(green) << 1 | Math.round(red));
148
+ if (value === 2) result += 60;
149
+ return result;
150
+ },
151
+ enumerable: false
152
+ },
153
+ rgbToAnsi: {
154
+ value: (red, green, blue) => styles$1.ansi256ToAnsi(styles$1.rgbToAnsi256(red, green, blue)),
155
+ enumerable: false
156
+ },
157
+ hexToAnsi: {
158
+ value: (hex) => styles$1.ansi256ToAnsi(styles$1.hexToAnsi256(hex)),
159
+ enumerable: false
160
+ }
161
+ });
162
+ return styles$1;
1113
163
  }
1114
- var browser;
1115
- var hasRequiredBrowser;
1116
- function requireBrowser() {
1117
- if (hasRequiredBrowser) return browser;
1118
- hasRequiredBrowser = 1;
1119
- browser = {
1120
- stdout: false,
1121
- stderr: false
1122
- };
1123
- return browser;
164
+ var ansiStyles = assembleStyles();
165
+ //#endregion
166
+ //#region node_modules/chalk/source/vendor/supports-color/browser.js
167
+ var level = (() => {
168
+ if (!("navigator" in globalThis)) return 0;
169
+ if (globalThis.navigator.userAgentData) {
170
+ const brand = navigator.userAgentData.brands.find(({ brand }) => brand === "Chromium");
171
+ if (brand && brand.version > 93) return 3;
172
+ }
173
+ if (/\b(Chrome|Chromium)\//.test(globalThis.navigator.userAgent)) return 1;
174
+ return 0;
175
+ })();
176
+ var colorSupport = level !== 0 && {
177
+ level,
178
+ hasBasic: true,
179
+ has256: level >= 2,
180
+ has16m: level >= 3
181
+ };
182
+ var supportsColor = {
183
+ stdout: colorSupport,
184
+ stderr: colorSupport
185
+ };
186
+ //#endregion
187
+ //#region node_modules/chalk/source/utilities.js
188
+ function stringReplaceAll(string, substring, replacer) {
189
+ let index = string.indexOf(substring);
190
+ if (index === -1) return string;
191
+ const substringLength = substring.length;
192
+ let endIndex = 0;
193
+ let returnValue = "";
194
+ do {
195
+ returnValue += string.slice(endIndex, index) + substring + replacer;
196
+ endIndex = index + substringLength;
197
+ index = string.indexOf(substring, endIndex);
198
+ } while (index !== -1);
199
+ returnValue += string.slice(endIndex);
200
+ return returnValue;
1124
201
  }
1125
- var util;
1126
- var hasRequiredUtil;
1127
- function requireUtil() {
1128
- if (hasRequiredUtil) return util;
1129
- hasRequiredUtil = 1;
1130
- const stringReplaceAll = (string, substring, replacer) => {
1131
- let index = string.indexOf(substring);
1132
- if (index === -1) {
1133
- return string;
1134
- }
1135
- const substringLength = substring.length;
1136
- let endIndex = 0;
1137
- let returnValue = "";
1138
- do {
1139
- returnValue += string.substr(endIndex, index - endIndex) + substring + replacer;
1140
- endIndex = index + substringLength;
1141
- index = string.indexOf(substring, endIndex);
1142
- } while (index !== -1);
1143
- returnValue += string.substr(endIndex);
1144
- return returnValue;
1145
- };
1146
- const stringEncaseCRLFWithFirstIndex = (string, prefix, postfix, index) => {
1147
- let endIndex = 0;
1148
- let returnValue = "";
1149
- do {
1150
- const gotCR = string[index - 1] === "\r";
1151
- returnValue += string.substr(endIndex, (gotCR ? index - 1 : index) - endIndex) + prefix + (gotCR ? "\r\n" : "\n") + postfix;
1152
- endIndex = index + 1;
1153
- index = string.indexOf("\n", endIndex);
1154
- } while (index !== -1);
1155
- returnValue += string.substr(endIndex);
1156
- return returnValue;
1157
- };
1158
- util = {
1159
- stringReplaceAll,
1160
- stringEncaseCRLFWithFirstIndex
1161
- };
1162
- return util;
202
+ function stringEncaseCRLFWithFirstIndex(string, prefix, postfix, index) {
203
+ let endIndex = 0;
204
+ let returnValue = "";
205
+ do {
206
+ const gotCR = string[index - 1] === "\r";
207
+ returnValue += string.slice(endIndex, gotCR ? index - 1 : index) + prefix + (gotCR ? "\r\n" : "\n") + postfix;
208
+ endIndex = index + 1;
209
+ index = string.indexOf("\n", endIndex);
210
+ } while (index !== -1);
211
+ returnValue += string.slice(endIndex);
212
+ return returnValue;
1163
213
  }
1164
- var templates;
1165
- var hasRequiredTemplates;
1166
- function requireTemplates() {
1167
- if (hasRequiredTemplates) return templates;
1168
- hasRequiredTemplates = 1;
1169
- const TEMPLATE_REGEX = /(?:\\(u(?:[a-f\d]{4}|\{[a-f\d]{1,6}\})|x[a-f\d]{2}|.))|(?:\{(~)?(\w+(?:\([^)]*\))?(?:\.\w+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n)))|(\})|((?:.|[\r\n\f])+?)/gi;
1170
- const STYLE_REGEX = /(?:^|\.)(\w+)(?:\(([^)]*)\))?/g;
1171
- const STRING_REGEX = /^(['"])((?:\\.|(?!\1)[^\\])*)\1$/;
1172
- const ESCAPE_REGEX = /\\(u(?:[a-f\d]{4}|{[a-f\d]{1,6}})|x[a-f\d]{2}|.)|([^\\])/gi;
1173
- const ESCAPES = /* @__PURE__ */ new Map([
1174
- ["n", "\n"],
1175
- ["r", "\r"],
1176
- ["t", " "],
1177
- ["b", "\b"],
1178
- ["f", "\f"],
1179
- ["v", "\v"],
1180
- ["0", "\0"],
1181
- ["\\", "\\"],
1182
- ["e", "\x1B"],
1183
- ["a", "\x07"]
1184
- ]);
1185
- function unescape(c) {
1186
- const u = c[0] === "u";
1187
- const bracket = c[1] === "{";
1188
- if (u && !bracket && c.length === 5 || c[0] === "x" && c.length === 3) {
1189
- return String.fromCharCode(parseInt(c.slice(1), 16));
1190
- }
1191
- if (u && bracket) {
1192
- return String.fromCodePoint(parseInt(c.slice(2, -1), 16));
1193
- }
1194
- return ESCAPES.get(c) || c;
1195
- }
1196
- function parseArguments(name, arguments_) {
1197
- const results = [];
1198
- const chunks = arguments_.trim().split(/\s*,\s*/g);
1199
- let matches;
1200
- for (const chunk of chunks) {
1201
- const number = Number(chunk);
1202
- if (!Number.isNaN(number)) {
1203
- results.push(number);
1204
- } else if (matches = chunk.match(STRING_REGEX)) {
1205
- results.push(matches[2].replace(ESCAPE_REGEX, (m, escape, character) => escape ? unescape(escape) : character));
1206
- } else {
1207
- throw new Error(`Invalid Chalk template style argument: ${chunk} (in style '${name}')`);
1208
- }
1209
- }
1210
- return results;
1211
- }
1212
- function parseStyle(style) {
1213
- STYLE_REGEX.lastIndex = 0;
1214
- const results = [];
1215
- let matches;
1216
- while ((matches = STYLE_REGEX.exec(style)) !== null) {
1217
- const name = matches[1];
1218
- if (matches[2]) {
1219
- const args = parseArguments(name, matches[2]);
1220
- results.push([name].concat(args));
1221
- } else {
1222
- results.push([name]);
1223
- }
1224
- }
1225
- return results;
1226
- }
1227
- function buildStyle(chalk2, styles) {
1228
- const enabled = {};
1229
- for (const layer of styles) {
1230
- for (const style of layer.styles) {
1231
- enabled[style[0]] = layer.inverse ? null : style.slice(1);
1232
- }
1233
- }
1234
- let current = chalk2;
1235
- for (const [styleName, styles2] of Object.entries(enabled)) {
1236
- if (!Array.isArray(styles2)) {
1237
- continue;
1238
- }
1239
- if (!(styleName in current)) {
1240
- throw new Error(`Unknown Chalk style: ${styleName}`);
1241
- }
1242
- current = styles2.length > 0 ? current[styleName](...styles2) : current[styleName];
1243
- }
1244
- return current;
1245
- }
1246
- templates = (chalk2, temporary) => {
1247
- const styles = [];
1248
- const chunks = [];
1249
- let chunk = [];
1250
- temporary.replace(TEMPLATE_REGEX, (m, escapeCharacter, inverse, style, close, character) => {
1251
- if (escapeCharacter) {
1252
- chunk.push(unescape(escapeCharacter));
1253
- } else if (style) {
1254
- const string = chunk.join("");
1255
- chunk = [];
1256
- chunks.push(styles.length === 0 ? string : buildStyle(chalk2, styles)(string));
1257
- styles.push({ inverse, styles: parseStyle(style) });
1258
- } else if (close) {
1259
- if (styles.length === 0) {
1260
- throw new Error("Found extraneous } in Chalk template literal");
1261
- }
1262
- chunks.push(buildStyle(chalk2, styles)(chunk.join("")));
1263
- chunk = [];
1264
- styles.pop();
1265
- } else {
1266
- chunk.push(character);
1267
- }
1268
- });
1269
- chunks.push(chunk.join(""));
1270
- if (styles.length > 0) {
1271
- const errMessage = `Chalk template literal is missing ${styles.length} closing bracket${styles.length === 1 ? "" : "s"} (\`}\`)`;
1272
- throw new Error(errMessage);
1273
- }
1274
- return chunks.join("");
1275
- };
1276
- return templates;
214
+ //#endregion
215
+ //#region node_modules/chalk/source/index.js
216
+ var { stdout: stdoutColor, stderr: stderrColor } = supportsColor;
217
+ var GENERATOR = Symbol("GENERATOR");
218
+ var STYLER = Symbol("STYLER");
219
+ var IS_EMPTY = Symbol("IS_EMPTY");
220
+ var levelMapping = [
221
+ "ansi",
222
+ "ansi",
223
+ "ansi256",
224
+ "ansi16m"
225
+ ];
226
+ var styles = Object.create(null);
227
+ var applyOptions = (object, options = {}) => {
228
+ if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) throw new Error("The `level` option should be an integer from 0 to 3");
229
+ const colorLevel = stdoutColor ? stdoutColor.level : 0;
230
+ object.level = options.level === void 0 ? colorLevel : options.level;
231
+ };
232
+ var chalkFactory = (options) => {
233
+ const chalk = (...strings) => strings.join(" ");
234
+ applyOptions(chalk, options);
235
+ Object.setPrototypeOf(chalk, createChalk.prototype);
236
+ return chalk;
237
+ };
238
+ function createChalk(options) {
239
+ return chalkFactory(options);
1277
240
  }
1278
- var source;
1279
- var hasRequiredSource;
1280
- function requireSource() {
1281
- if (hasRequiredSource) return source;
1282
- hasRequiredSource = 1;
1283
- const ansiStyles2 = requireAnsiStyles();
1284
- const { stdout: stdoutColor, stderr: stderrColor } = requireBrowser();
1285
- const {
1286
- stringReplaceAll,
1287
- stringEncaseCRLFWithFirstIndex
1288
- } = requireUtil();
1289
- const { isArray } = Array;
1290
- const levelMapping = [
1291
- "ansi",
1292
- "ansi",
1293
- "ansi256",
1294
- "ansi16m"
1295
- ];
1296
- const styles = /* @__PURE__ */ Object.create(null);
1297
- const applyOptions = (object, options = {}) => {
1298
- if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {
1299
- throw new Error("The `level` option should be an integer from 0 to 3");
1300
- }
1301
- const colorLevel = stdoutColor ? stdoutColor.level : 0;
1302
- object.level = options.level === void 0 ? colorLevel : options.level;
1303
- };
1304
- class ChalkClass {
1305
- constructor(options) {
1306
- return chalkFactory(options);
1307
- }
1308
- }
1309
- const chalkFactory = (options) => {
1310
- const chalk3 = {};
1311
- applyOptions(chalk3, options);
1312
- chalk3.template = (...arguments_) => chalkTag(chalk3.template, ...arguments_);
1313
- Object.setPrototypeOf(chalk3, Chalk.prototype);
1314
- Object.setPrototypeOf(chalk3.template, chalk3);
1315
- chalk3.template.constructor = () => {
1316
- throw new Error("`chalk.constructor()` is deprecated. Use `new chalk.Instance()` instead.");
1317
- };
1318
- chalk3.template.Instance = ChalkClass;
1319
- return chalk3.template;
1320
- };
1321
- function Chalk(options) {
1322
- return chalkFactory(options);
1323
- }
1324
- for (const [styleName, style] of Object.entries(ansiStyles2)) {
1325
- styles[styleName] = {
1326
- get() {
1327
- const builder = createBuilder(this, createStyler(style.open, style.close, this._styler), this._isEmpty);
1328
- Object.defineProperty(this, styleName, { value: builder });
1329
- return builder;
1330
- }
1331
- };
1332
- }
1333
- styles.visible = {
1334
- get() {
1335
- const builder = createBuilder(this, this._styler, true);
1336
- Object.defineProperty(this, "visible", { value: builder });
1337
- return builder;
1338
- }
1339
- };
1340
- const usedModels = ["rgb", "hex", "keyword", "hsl", "hsv", "hwb", "ansi", "ansi256"];
1341
- for (const model of usedModels) {
1342
- styles[model] = {
1343
- get() {
1344
- const { level } = this;
1345
- return function(...arguments_) {
1346
- const styler = createStyler(ansiStyles2.color[levelMapping[level]][model](...arguments_), ansiStyles2.color.close, this._styler);
1347
- return createBuilder(this, styler, this._isEmpty);
1348
- };
1349
- }
1350
- };
1351
- }
1352
- for (const model of usedModels) {
1353
- const bgModel = "bg" + model[0].toUpperCase() + model.slice(1);
1354
- styles[bgModel] = {
1355
- get() {
1356
- const { level } = this;
1357
- return function(...arguments_) {
1358
- const styler = createStyler(ansiStyles2.bgColor[levelMapping[level]][model](...arguments_), ansiStyles2.bgColor.close, this._styler);
1359
- return createBuilder(this, styler, this._isEmpty);
1360
- };
1361
- }
1362
- };
1363
- }
1364
- const proto = Object.defineProperties(() => {
1365
- }, {
1366
- ...styles,
1367
- level: {
1368
- enumerable: true,
1369
- get() {
1370
- return this._generator.level;
1371
- },
1372
- set(level) {
1373
- this._generator.level = level;
1374
- }
1375
- }
1376
- });
1377
- const createStyler = (open, close, parent) => {
1378
- let openAll;
1379
- let closeAll;
1380
- if (parent === void 0) {
1381
- openAll = open;
1382
- closeAll = close;
1383
- } else {
1384
- openAll = parent.openAll + open;
1385
- closeAll = close + parent.closeAll;
1386
- }
1387
- return {
1388
- open,
1389
- close,
1390
- openAll,
1391
- closeAll,
1392
- parent
1393
- };
1394
- };
1395
- const createBuilder = (self, _styler, _isEmpty) => {
1396
- const builder = (...arguments_) => {
1397
- if (isArray(arguments_[0]) && isArray(arguments_[0].raw)) {
1398
- return applyStyle(builder, chalkTag(builder, ...arguments_));
1399
- }
1400
- return applyStyle(builder, arguments_.length === 1 ? "" + arguments_[0] : arguments_.join(" "));
1401
- };
1402
- Object.setPrototypeOf(builder, proto);
1403
- builder._generator = self;
1404
- builder._styler = _styler;
1405
- builder._isEmpty = _isEmpty;
1406
- return builder;
1407
- };
1408
- const applyStyle = (self, string) => {
1409
- if (self.level <= 0 || !string) {
1410
- return self._isEmpty ? "" : string;
1411
- }
1412
- let styler = self._styler;
1413
- if (styler === void 0) {
1414
- return string;
1415
- }
1416
- const { openAll, closeAll } = styler;
1417
- if (string.indexOf("\x1B") !== -1) {
1418
- while (styler !== void 0) {
1419
- string = stringReplaceAll(string, styler.close, styler.open);
1420
- styler = styler.parent;
1421
- }
1422
- }
1423
- const lfIndex = string.indexOf("\n");
1424
- if (lfIndex !== -1) {
1425
- string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex);
1426
- }
1427
- return openAll + string + closeAll;
1428
- };
1429
- let template;
1430
- const chalkTag = (chalk3, ...strings) => {
1431
- const [firstString] = strings;
1432
- if (!isArray(firstString) || !isArray(firstString.raw)) {
1433
- return strings.join(" ");
1434
- }
1435
- const arguments_ = strings.slice(1);
1436
- const parts = [firstString.raw[0]];
1437
- for (let i = 1; i < firstString.length; i++) {
1438
- parts.push(
1439
- String(arguments_[i - 1]).replace(/[{}\\]/g, "\\$&"),
1440
- String(firstString.raw[i])
1441
- );
1442
- }
1443
- if (template === void 0) {
1444
- template = requireTemplates();
1445
- }
1446
- return template(chalk3, parts.join(""));
1447
- };
1448
- Object.defineProperties(Chalk.prototype, styles);
1449
- const chalk2 = Chalk();
1450
- chalk2.supportsColor = stdoutColor;
1451
- chalk2.stderr = Chalk({ level: stderrColor ? stderrColor.level : 0 });
1452
- chalk2.stderr.supportsColor = stderrColor;
1453
- source = chalk2;
1454
- return source;
241
+ Object.setPrototypeOf(createChalk.prototype, Function.prototype);
242
+ for (const [styleName, style] of Object.entries(ansiStyles)) styles[styleName] = { get() {
243
+ const builder = createBuilder(this, createStyler(style.open, style.close, this[STYLER]), this[IS_EMPTY]);
244
+ Object.defineProperty(this, styleName, { value: builder });
245
+ return builder;
246
+ } };
247
+ styles.visible = { get() {
248
+ const builder = createBuilder(this, this[STYLER], true);
249
+ Object.defineProperty(this, "visible", { value: builder });
250
+ return builder;
251
+ } };
252
+ var getModelAnsi = (model, level, type, ...arguments_) => {
253
+ if (model === "rgb") {
254
+ if (level === "ansi16m") return ansiStyles[type].ansi16m(...arguments_);
255
+ if (level === "ansi256") return ansiStyles[type].ansi256(ansiStyles.rgbToAnsi256(...arguments_));
256
+ return ansiStyles[type].ansi(ansiStyles.rgbToAnsi(...arguments_));
257
+ }
258
+ if (model === "hex") return getModelAnsi("rgb", level, type, ...ansiStyles.hexToRgb(...arguments_));
259
+ return ansiStyles[type][model](...arguments_);
260
+ };
261
+ for (const model of [
262
+ "rgb",
263
+ "hex",
264
+ "ansi256"
265
+ ]) {
266
+ styles[model] = { get() {
267
+ const { level } = this;
268
+ return function(...arguments_) {
269
+ const styler = createStyler(getModelAnsi(model, levelMapping[level], "color", ...arguments_), ansiStyles.color.close, this[STYLER]);
270
+ return createBuilder(this, styler, this[IS_EMPTY]);
271
+ };
272
+ } };
273
+ const bgModel = "bg" + model[0].toUpperCase() + model.slice(1);
274
+ styles[bgModel] = { get() {
275
+ const { level } = this;
276
+ return function(...arguments_) {
277
+ const styler = createStyler(getModelAnsi(model, levelMapping[level], "bgColor", ...arguments_), ansiStyles.bgColor.close, this[STYLER]);
278
+ return createBuilder(this, styler, this[IS_EMPTY]);
279
+ };
280
+ } };
1455
281
  }
1456
- var sourceExports = requireSource();
1457
- const chalk = /* @__PURE__ */ getDefaultExportFromCjs(sourceExports);
1458
- var ModelDelimeter = /* @__PURE__ */ ((ModelDelimeter2) => {
1459
- ModelDelimeter2["ROOT"] = "_";
1460
- ModelDelimeter2["SEPERATOR"] = "|";
1461
- ModelDelimeter2["COMPONENT_SEPERATOR"] = "@";
1462
- ModelDelimeter2["NID_SEPERATOR"] = "^";
1463
- return ModelDelimeter2;
1464
- })(ModelDelimeter || {});
1465
- const CheckValidChar = (checkParams) => {
1466
- const invalidChars = [
1467
- "_",
1468
- "|",
1469
- "@",
1470
- "^"
1471
- /* NID_SEPERATOR */
1472
- ];
1473
- checkParams.forEach((param) => {
1474
- invalidChars.forEach((char) => {
1475
- if (param[1].includes(char)) {
1476
- throw new Error(`Invalid character inside [${param[0]}:${param[1]}], no [${char}] allowed`);
1477
- }
1478
- });
1479
- });
282
+ var proto = Object.defineProperties(() => {}, {
283
+ ...styles,
284
+ level: {
285
+ enumerable: true,
286
+ get() {
287
+ return this[GENERATOR].level;
288
+ },
289
+ set(level) {
290
+ this[GENERATOR].level = level;
291
+ }
292
+ }
293
+ });
294
+ var createStyler = (open, close, parent) => {
295
+ let openAll;
296
+ let closeAll;
297
+ if (parent === void 0) {
298
+ openAll = open;
299
+ closeAll = close;
300
+ } else {
301
+ openAll = parent.openAll + open;
302
+ closeAll = close + parent.closeAll;
303
+ }
304
+ return {
305
+ open,
306
+ close,
307
+ openAll,
308
+ closeAll,
309
+ parent
310
+ };
1480
311
  };
1481
- const defaultLogger = {
1482
- debug(message) {
1483
- console.log(chalk.grey(`debug: ${message}`));
1484
- },
1485
- error(message) {
1486
- console.log(chalk.red(`error: ${message}`));
1487
- },
1488
- http(message) {
1489
- console.log(chalk.cyan(`http: ${message}`));
1490
- },
1491
- info(message) {
1492
- console.log(chalk.white(`info: ${message}`));
1493
- },
1494
- silly(message) {
1495
- console.log(chalk.yellow(`silly: ${message}`));
1496
- },
1497
- verbose(message) {
1498
- console.log(chalk.green(`verbose: ${message}`));
1499
- },
1500
- warn(message) {
1501
- console.log(chalk.magenta(`warn: ${message}`));
1502
- }
312
+ var createBuilder = (self, _styler, _isEmpty) => {
313
+ const builder = (...arguments_) => applyStyle(builder, arguments_.length === 1 ? "" + arguments_[0] : arguments_.join(" "));
314
+ Object.setPrototypeOf(builder, proto);
315
+ builder[GENERATOR] = self;
316
+ builder[STYLER] = _styler;
317
+ builder[IS_EMPTY] = _isEmpty;
318
+ return builder;
1503
319
  };
1504
- const emptyLogger = {
1505
- debug(message) {
1506
- },
1507
- error(message) {
1508
- },
1509
- http(message) {
1510
- },
1511
- info(message) {
1512
- },
1513
- silly(message) {
1514
- },
1515
- verbose(message) {
1516
- },
1517
- warn(message) {
1518
- }
320
+ var applyStyle = (self, string) => {
321
+ if (self.level <= 0 || !string) return self[IS_EMPTY] ? "" : string;
322
+ let styler = self[STYLER];
323
+ if (styler === void 0) return string;
324
+ const { openAll, closeAll } = styler;
325
+ if (string.includes("\x1B")) while (styler !== void 0) {
326
+ string = stringReplaceAll(string, styler.close, styler.open);
327
+ styler = styler.parent;
328
+ }
329
+ const lfIndex = string.indexOf("\n");
330
+ if (lfIndex !== -1) string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex);
331
+ return openAll + string + closeAll;
1519
332
  };
1520
- var edbaction = /* @__PURE__ */ ((edbaction2) => {
1521
- edbaction2[edbaction2["created"] = 1] = "created";
1522
- edbaction2[edbaction2["updated"] = 2] = "updated";
1523
- edbaction2[edbaction2["deleted"] = 3] = "deleted";
1524
- return edbaction2;
1525
- })(edbaction || {});
1526
- function GetErrorPayload(errorCode, details = null) {
1527
- return {
1528
- error: errorCode.code,
1529
- error_description: errorCode.description,
1530
- timestamp: Date.now(),
1531
- //trace_id: "255d1aef-8c98-452f-ac51-23d051240864", //@@
1532
- //correlation_id: "fb3d2015-bc17-4bb9-bb85-30c5cf1aaaa7", //@@
1533
- details
1534
- };
1535
- }
1536
- const ajv = new Ajv();
1537
- const _Validate = (validator, payload) => {
1538
- const valid = validator(payload);
1539
- if (!valid) {
1540
- return validator.errors;
1541
- } else {
1542
- return null;
1543
- }
333
+ Object.defineProperties(createChalk.prototype, styles);
334
+ var chalk = createChalk();
335
+ createChalk({ level: stderrColor ? stderrColor.level : 0 });
336
+ //#endregion
337
+ //#region src/commonTypes.ts
338
+ var ModelDelimeter = /* @__PURE__ */ function(ModelDelimeter) {
339
+ ModelDelimeter["ROOT"] = "_";
340
+ ModelDelimeter["SEPERATOR"] = "|";
341
+ ModelDelimeter["COMPONENT_SEPERATOR"] = "@";
342
+ ModelDelimeter["NID_SEPERATOR"] = "^";
343
+ return ModelDelimeter;
344
+ }({});
345
+ var CheckValidChar = (checkParams) => {
346
+ const invalidChars = [
347
+ ModelDelimeter.ROOT,
348
+ ModelDelimeter.SEPERATOR,
349
+ ModelDelimeter.COMPONENT_SEPERATOR,
350
+ ModelDelimeter.NID_SEPERATOR
351
+ ];
352
+ checkParams.forEach((param) => {
353
+ invalidChars.forEach((char) => {
354
+ if (param[1].includes(char)) throw new Error(`Invalid character inside [${param[0]}:${param[1]}], no [${char}] allowed`);
355
+ });
356
+ });
1544
357
  };
1545
- function AddSchema(name, schema) {
1546
- ajv.addSchema(schema, name);
1547
- }
1548
- function Validate(name, payload) {
1549
- const validator = ajv.getSchema(name);
1550
- if (validator) {
1551
- return _Validate(validator, payload);
1552
- }
1553
- }
1554
- class STSOptionsBase {
1555
- #options;
1556
- constructor(options = null) {
1557
- this.#options = options;
1558
- if (options !== null) {
1559
- if (typeof options.validator === "undefined") ;
1560
- else {
1561
- Validate(options.validator, options);
1562
- }
1563
- }
1564
- }
1565
- get options() {
1566
- return this.#options;
1567
- }
358
+ var defaultLogger = {
359
+ debug(message) {
360
+ console.log(chalk.grey(`debug: ${message}`));
361
+ },
362
+ error(message) {
363
+ console.log(chalk.red(`error: ${message}`));
364
+ },
365
+ http(message) {
366
+ console.log(chalk.cyan(`http: ${message}`));
367
+ },
368
+ info(message) {
369
+ console.log(chalk.white(`info: ${message}`));
370
+ },
371
+ silly(message) {
372
+ console.log(chalk.yellow(`silly: ${message}`));
373
+ },
374
+ verbose(message) {
375
+ console.log(chalk.green(`verbose: ${message}`));
376
+ },
377
+ warn(message) {
378
+ console.log(chalk.magenta(`warn: ${message}`));
379
+ }
380
+ };
381
+ var emptyLogger = {
382
+ debug(message) {},
383
+ error(message) {},
384
+ http(message) {},
385
+ info(message) {},
386
+ silly(message) {},
387
+ verbose(message) {},
388
+ warn(message) {}
389
+ };
390
+ //#endregion
391
+ //#region src/dataAccessTypes.ts
392
+ var edbaction = /* @__PURE__ */ function(edbaction) {
393
+ edbaction[edbaction["created"] = 1] = "created";
394
+ edbaction[edbaction["updated"] = 2] = "updated";
395
+ edbaction[edbaction["deleted"] = 3] = "deleted";
396
+ return edbaction;
397
+ }({});
398
+ //#endregion
399
+ //#region src/errorhandling.ts
400
+ function GetErrorPayload(errorCode, details = null) {
401
+ return {
402
+ error: errorCode.code,
403
+ error_description: errorCode.description,
404
+ timestamp: Date.now(),
405
+ details
406
+ };
1568
407
  }
408
+ //#endregion
409
+ //#region src/sleep.ts
1569
410
  async function Sleep(milliseconds = 1e3) {
1570
- return new Promise((resolve) => setTimeout(resolve, milliseconds));
411
+ return new Promise((resolve) => setTimeout(resolve, milliseconds));
1571
412
  }
1572
413
  async function JestSleep() {
1573
- return Sleep(100);
1574
- }
1575
- var OAuth2ParameterType = /* @__PURE__ */ ((OAuth2ParameterType2) => {
1576
- OAuth2ParameterType2["AUDIENCE"] = "AUDIENCE";
1577
- OAuth2ParameterType2["CLIENT_ID"] = "client_id";
1578
- OAuth2ParameterType2["CLIENT_SECRET"] = "client_secret";
1579
- OAuth2ParameterType2["RESPONSE_TYPE"] = "response_type";
1580
- OAuth2ParameterType2["SCOPE"] = "scope";
1581
- OAuth2ParameterType2["STATE"] = "state";
1582
- OAuth2ParameterType2["REDIRECT_URI"] = "redirect_uri";
1583
- OAuth2ParameterType2["ERROR"] = "error";
1584
- OAuth2ParameterType2["ERROR_DESCRIPTION"] = "error_description";
1585
- OAuth2ParameterType2["ERROR_CODES"] = "error_codes";
1586
- OAuth2ParameterType2["ERROR_URI"] = "error_uri";
1587
- OAuth2ParameterType2["GRANT_TYPE"] = "grant_type";
1588
- OAuth2ParameterType2["CODE"] = "code";
1589
- OAuth2ParameterType2["ACCESS_TOKEN"] = "access_token";
1590
- OAuth2ParameterType2["TOKEN_TYPE"] = "token_type";
1591
- OAuth2ParameterType2["EXPIRES_IN"] = "expires_in";
1592
- OAuth2ParameterType2["USERNAME"] = "username";
1593
- OAuth2ParameterType2["PASSWORD"] = "password";
1594
- OAuth2ParameterType2["REFRESH_TOKEN"] = "refresh_token";
1595
- OAuth2ParameterType2["RESPONSE_MODE"] = "response_mode";
1596
- OAuth2ParameterType2["TIMESTAMP"] = "timestamp";
1597
- OAuth2ParameterType2["TRACE_ID"] = "trace_id";
1598
- OAuth2ParameterType2["CORRELATION_ID"] = "correlation_id";
1599
- return OAuth2ParameterType2;
1600
- })(OAuth2ParameterType || {});
1601
- var OIDCStandardClaim = /* @__PURE__ */ ((OIDCStandardClaim2) => {
1602
- OIDCStandardClaim2["SUB"] = "sub";
1603
- OIDCStandardClaim2["NAME"] = "name";
1604
- OIDCStandardClaim2["GIVEN_NAME"] = "given_name";
1605
- OIDCStandardClaim2["FAMILY_NAME"] = "family_name";
1606
- OIDCStandardClaim2["MIDDLE_NAME"] = "middle_name";
1607
- OIDCStandardClaim2["NICKNAME"] = "nickname";
1608
- OIDCStandardClaim2["PREFERRED_USERNAME"] = "preferred_username";
1609
- OIDCStandardClaim2["PROFILE"] = "profile";
1610
- OIDCStandardClaim2["PICTURE"] = "picture";
1611
- OIDCStandardClaim2["WEBSITE"] = "website";
1612
- OIDCStandardClaim2["EMAIL"] = "email";
1613
- OIDCStandardClaim2["EMAIL_VERIFIED"] = "email_verified";
1614
- OIDCStandardClaim2["GENDER"] = "gender";
1615
- OIDCStandardClaim2["BIRTHDATE"] = "birthdate";
1616
- OIDCStandardClaim2["ZONEINFO"] = "zoneinfo";
1617
- OIDCStandardClaim2["LOCALE"] = "locale";
1618
- OIDCStandardClaim2["PHONE_NUMBER"] = "phone_number";
1619
- OIDCStandardClaim2["PHONE_NUMBER_VERIFIED"] = "phone_number_verified";
1620
- OIDCStandardClaim2["ADDRESS"] = "address";
1621
- OIDCStandardClaim2["CLIENT_SECRET"] = "client_secret";
1622
- OIDCStandardClaim2["NONCE"] = "nonce";
1623
- return OIDCStandardClaim2;
1624
- })(OIDCStandardClaim || {});
1625
- var OIDCAddressClaim = /* @__PURE__ */ ((OIDCAddressClaim2) => {
1626
- OIDCAddressClaim2["FORMATTED"] = "formatted";
1627
- OIDCAddressClaim2["STREET_ADDRESS"] = "street_address";
1628
- OIDCAddressClaim2["LOCALITY"] = "locality";
1629
- OIDCAddressClaim2["REGION"] = "region";
1630
- OIDCAddressClaim2["COUNTRY"] = "country";
1631
- return OIDCAddressClaim2;
1632
- })(OIDCAddressClaim || {});
1633
- class OAuth2ParameterErrorType {
1634
- static NOT_EQUAL = {
1635
- code: "STS_OAUTH2_ERR_0001",
1636
- description: "Parameter values not equal."
1637
- };
1638
- static NOT_PRESENT = {
1639
- code: "STS_OAUTH2_ERR_0002",
1640
- description: "Parameter not provided."
1641
- };
1642
- static INVALID_FORMAT = {
1643
- code: "STS_OAUTH2_ERR_0003",
1644
- description: "Parameter value format invalid."
1645
- };
1646
- static EXPIRED = {
1647
- code: "STS_OAUTH2_ERR_0004",
1648
- description: "Parameter value expired."
1649
- };
414
+ return Sleep(100);
1650
415
  }
416
+ //#endregion
417
+ //#region src/oauth2terms.ts
418
+ var OAuth2ParameterType = /* @__PURE__ */ function(OAuth2ParameterType) {
419
+ OAuth2ParameterType["AUDIENCE"] = "AUDIENCE";
420
+ OAuth2ParameterType["CLIENT_ID"] = "client_id";
421
+ OAuth2ParameterType["CLIENT_SECRET"] = "client_secret";
422
+ OAuth2ParameterType["RESPONSE_TYPE"] = "response_type";
423
+ OAuth2ParameterType["SCOPE"] = "scope";
424
+ OAuth2ParameterType["STATE"] = "state";
425
+ OAuth2ParameterType["REDIRECT_URI"] = "redirect_uri";
426
+ OAuth2ParameterType["ERROR"] = "error";
427
+ OAuth2ParameterType["ERROR_DESCRIPTION"] = "error_description";
428
+ OAuth2ParameterType["ERROR_CODES"] = "error_codes";
429
+ OAuth2ParameterType["ERROR_URI"] = "error_uri";
430
+ OAuth2ParameterType["GRANT_TYPE"] = "grant_type";
431
+ OAuth2ParameterType["CODE"] = "code";
432
+ OAuth2ParameterType["ACCESS_TOKEN"] = "access_token";
433
+ OAuth2ParameterType["TOKEN_TYPE"] = "token_type";
434
+ OAuth2ParameterType["EXPIRES_IN"] = "expires_in";
435
+ OAuth2ParameterType["USERNAME"] = "username";
436
+ OAuth2ParameterType["PASSWORD"] = "password";
437
+ OAuth2ParameterType["REFRESH_TOKEN"] = "refresh_token";
438
+ OAuth2ParameterType["RESPONSE_MODE"] = "response_mode";
439
+ OAuth2ParameterType["TIMESTAMP"] = "timestamp";
440
+ OAuth2ParameterType["TRACE_ID"] = "trace_id";
441
+ OAuth2ParameterType["CORRELATION_ID"] = "correlation_id";
442
+ return OAuth2ParameterType;
443
+ }({});
444
+ var OIDCStandardClaim = /* @__PURE__ */ function(OIDCStandardClaim) {
445
+ OIDCStandardClaim["SUB"] = "sub";
446
+ OIDCStandardClaim["NAME"] = "name";
447
+ OIDCStandardClaim["GIVEN_NAME"] = "given_name";
448
+ OIDCStandardClaim["FAMILY_NAME"] = "family_name";
449
+ OIDCStandardClaim["MIDDLE_NAME"] = "middle_name";
450
+ OIDCStandardClaim["NICKNAME"] = "nickname";
451
+ OIDCStandardClaim["PREFERRED_USERNAME"] = "preferred_username";
452
+ OIDCStandardClaim["PROFILE"] = "profile";
453
+ OIDCStandardClaim["PICTURE"] = "picture";
454
+ OIDCStandardClaim["WEBSITE"] = "website";
455
+ OIDCStandardClaim["EMAIL"] = "email";
456
+ OIDCStandardClaim["EMAIL_VERIFIED"] = "email_verified";
457
+ OIDCStandardClaim["GENDER"] = "gender";
458
+ OIDCStandardClaim["BIRTHDATE"] = "birthdate";
459
+ OIDCStandardClaim["ZONEINFO"] = "zoneinfo";
460
+ OIDCStandardClaim["LOCALE"] = "locale";
461
+ OIDCStandardClaim["PHONE_NUMBER"] = "phone_number";
462
+ OIDCStandardClaim["PHONE_NUMBER_VERIFIED"] = "phone_number_verified";
463
+ OIDCStandardClaim["ADDRESS"] = "address";
464
+ OIDCStandardClaim["CLIENT_SECRET"] = "client_secret";
465
+ OIDCStandardClaim["NONCE"] = "nonce";
466
+ return OIDCStandardClaim;
467
+ }({});
468
+ var OIDCAddressClaim = /* @__PURE__ */ function(OIDCAddressClaim) {
469
+ OIDCAddressClaim["FORMATTED"] = "formatted";
470
+ OIDCAddressClaim["STREET_ADDRESS"] = "street_address";
471
+ OIDCAddressClaim["LOCALITY"] = "locality";
472
+ OIDCAddressClaim["REGION"] = "region";
473
+ OIDCAddressClaim["COUNTRY"] = "country";
474
+ return OIDCAddressClaim;
475
+ }({});
476
+ var OAuth2ParameterErrorType = class {
477
+ static NOT_EQUAL = {
478
+ code: "STS_OAUTH2_ERR_0001",
479
+ description: "Parameter values not equal."
480
+ };
481
+ static NOT_PRESENT = {
482
+ code: "STS_OAUTH2_ERR_0002",
483
+ description: "Parameter not provided."
484
+ };
485
+ static INVALID_FORMAT = {
486
+ code: "STS_OAUTH2_ERR_0003",
487
+ description: "Parameter value format invalid."
488
+ };
489
+ static EXPIRED = {
490
+ code: "STS_OAUTH2_ERR_0004",
491
+ description: "Parameter value expired."
492
+ };
493
+ };
1651
494
  function compareParameterTypes(source1, source2, authParameterTypes) {
1652
- const errors = [];
1653
- for (let i = 0; i < authParameterTypes.length; i++) {
1654
- const authParameterType = authParameterTypes[i];
1655
- if (source1[i].localeCompare(source2[i]) !== 0) {
1656
- const error = {
1657
- error: OAuth2ParameterErrorType.NOT_EQUAL.code,
1658
- error_description: OAuth2ParameterErrorType.NOT_EQUAL.description,
1659
- timestamp: Date.now(),
1660
- details: `${OAuth2ParameterErrorType.NOT_EQUAL.description}: Parameter: [${authParameterType}]`
1661
- };
1662
- errors.push(error);
1663
- }
1664
- }
1665
- return errors;
1666
- }
1667
- class STSAxiosConfig {
1668
- #url;
1669
- #method;
1670
- #headers;
1671
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
1672
- #data;
1673
- #agentManager;
1674
- #timeout;
1675
- #withCredentials;
1676
- constructor(url, method, headers, timeout) {
1677
- this.#url = url;
1678
- this.#method = method;
1679
- if (headers !== void 0) {
1680
- this.#headers = headers;
1681
- }
1682
- if (timeout !== void 0) {
1683
- this.#timeout = timeout;
1684
- }
1685
- }
1686
- /**
1687
- *
1688
- * @param cookies this.#headers['Cookie'] = cookies.join('; ')
1689
- * @returns
1690
- */
1691
- withCookies(cookies) {
1692
- if (!this.#headers) {
1693
- this.#headers = {};
1694
- }
1695
- this.#headers["Cookie"] = cookies.join("; ");
1696
- return this;
1697
- }
1698
- /**
1699
- *
1700
- * @param data Add data to the body
1701
- * @returns
1702
- */
1703
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
1704
- withData(data) {
1705
- this.#data = data;
1706
- return this;
1707
- }
1708
- // 'Content-Type': 'application/json'
1709
- /**
1710
- *
1711
- * @param accesssToken
1712
- * @param stsUserId
1713
- * @returns this.#headers['Authorization'] = 'Bearer ' + accesssToken; and this.#headers['x-sts_user_id'] = stsUserId;
1714
- */
1715
- withAuthHeaders(accesssToken, stsUserId) {
1716
- if (!this.#headers) {
1717
- this.#headers = {};
1718
- }
1719
- this.#headers["Authorization"] = "Bearer " + accesssToken;
1720
- if (stsUserId) {
1721
- this.#headers["x-sts_user_id"] = stsUserId;
1722
- }
1723
- return this;
1724
- }
1725
- /**
1726
- *
1727
- * @param headers Add headers to the existing header
1728
- * @returns
1729
- */
1730
- withHeaders(headers) {
1731
- this.#headers = {
1732
- ...this.#headers ?? {},
1733
- ...headers
1734
- };
1735
- return this;
1736
- }
1737
- /**
1738
- *
1739
- * @returns this.#headers['Content-Type'] = 'application/fhir+json';
1740
- */
1741
- withApplicationFhirAndJsonContentTypeHeaders() {
1742
- if (!this.#headers) {
1743
- this.#headers = {};
1744
- }
1745
- this.#headers["Content-Type"] = "application/fhir+json";
1746
- return this;
1747
- }
1748
- /**
1749
- *
1750
- * @returns this.#headers['Content-Type'] = 'application/merge-patch+json';
1751
- */
1752
- withApplicationMergePatchAndJsonContentTypeHeaders() {
1753
- if (!this.#headers) {
1754
- this.#headers = {};
1755
- }
1756
- this.#headers["Content-Type"] = "application/merge-patch+json";
1757
- return this;
1758
- }
1759
- /**
1760
- *
1761
- * @returns this.#headers['Content-Type'] = 'application/json-patch+json';
1762
- */
1763
- withApplicationJsonPatchAndJsonContentTypeHeaders() {
1764
- if (!this.#headers) {
1765
- this.#headers = {};
1766
- }
1767
- this.#headers["Content-Type"] = "application/json-patch+json";
1768
- return this;
1769
- }
1770
- /**
1771
- *
1772
- * @returns this.#headers['Content-Type'] = 'application/json';
1773
- */
1774
- withApplicationJsonContentTypeHeaders() {
1775
- if (!this.#headers) {
1776
- this.#headers = {};
1777
- }
1778
- this.#headers["Content-Type"] = "application/json";
1779
- return this;
1780
- }
1781
- /**
1782
- *
1783
- * @returns this.#headers['Content-Type'] = 'application/json';
1784
- */
1785
- withDefaultHeaders() {
1786
- if (!this.#headers) {
1787
- this.#headers = {};
1788
- }
1789
- this.#headers["Content-Type"] = "application/json";
1790
- return this;
1791
- }
1792
- /**
1793
- *
1794
- * @returns
1795
- */
1796
- withCredentials() {
1797
- this.#withCredentials = true;
1798
- return this;
1799
- }
1800
- /**
1801
- *
1802
- * @param timeout Add a connection timeout
1803
- * @returns
1804
- */
1805
- withTimeout(timeout) {
1806
- this.#timeout = timeout;
1807
- return this;
1808
- }
1809
- /**
1810
- *
1811
- * @param agentManager Add the agent manager for each rest call. Only for nodejs not browser.
1812
- * @returns
1813
- */
1814
- withAgentManager(agentManager) {
1815
- this.#agentManager = agentManager;
1816
- return this;
1817
- }
1818
- /**
1819
- * @returns Returns axios config object
1820
- */
1821
- get config() {
1822
- const retVal = {
1823
- url: this.#url,
1824
- method: this.#method
1825
- };
1826
- if (this.#headers) {
1827
- retVal.headers = this.#headers;
1828
- }
1829
- if (this.#agentManager !== void 0) {
1830
- if (this.#agentManager.IsHttps(this.#url)) {
1831
- retVal.httpsAgent = this.#agentManager.GetAgent(this.#url);
1832
- } else {
1833
- retVal.httpAgent = this.#agentManager.GetAgent(this.#url);
1834
- }
1835
- }
1836
- if (this.#data !== void 0) {
1837
- retVal.data = this.#data;
1838
- }
1839
- if (this.#timeout !== void 0) {
1840
- retVal.timeout = this.#timeout;
1841
- }
1842
- if (this.#withCredentials !== void 0 && this.#withCredentials === true) {
1843
- retVal.withCredentials = true;
1844
- }
1845
- return retVal;
1846
- }
495
+ const errors = [];
496
+ for (let i = 0; i < authParameterTypes.length; i++) {
497
+ const authParameterType = authParameterTypes[i];
498
+ if (source1[i].localeCompare(source2[i]) !== 0) {
499
+ const error = {
500
+ error: OAuth2ParameterErrorType.NOT_EQUAL.code,
501
+ error_description: OAuth2ParameterErrorType.NOT_EQUAL.description,
502
+ timestamp: Date.now(),
503
+ details: `${OAuth2ParameterErrorType.NOT_EQUAL.description}: Parameter: [${authParameterType}]`
504
+ };
505
+ errors.push(error);
506
+ }
507
+ }
508
+ return errors;
1847
509
  }
510
+ //#endregion
511
+ //#region src/stsAxiosConfig.ts
512
+ var STSAxiosConfig = class {
513
+ #url;
514
+ #method;
515
+ #headers;
516
+ #data;
517
+ #agentManager;
518
+ #timeout;
519
+ #withCredentials;
520
+ constructor(url, method, headers, timeout) {
521
+ this.#url = url;
522
+ this.#method = method;
523
+ if (headers !== void 0) this.#headers = headers;
524
+ if (timeout !== void 0) this.#timeout = timeout;
525
+ }
526
+ /**
527
+ *
528
+ * @param cookies this.#headers['Cookie'] = cookies.join('; ')
529
+ * @returns
530
+ */
531
+ withCookies(cookies) {
532
+ if (!this.#headers) this.#headers = {};
533
+ this.#headers["Cookie"] = cookies.join("; ");
534
+ return this;
535
+ }
536
+ /**
537
+ *
538
+ * @param data Add data to the body
539
+ * @returns
540
+ */
541
+ withData(data) {
542
+ this.#data = data;
543
+ return this;
544
+ }
545
+ /**
546
+ *
547
+ * @param accesssToken
548
+ * @param stsUserId
549
+ * @returns this.#headers['Authorization'] = 'Bearer ' + accesssToken; and this.#headers['x-sts_user_id'] = stsUserId;
550
+ */
551
+ withAuthHeaders(accesssToken, stsUserId) {
552
+ if (!this.#headers) this.#headers = {};
553
+ this.#headers["Authorization"] = "Bearer " + accesssToken;
554
+ if (stsUserId) this.#headers["x-sts_user_id"] = stsUserId;
555
+ return this;
556
+ }
557
+ /**
558
+ *
559
+ * @param headers Add headers to the existing header
560
+ * @returns
561
+ */
562
+ withHeaders(headers) {
563
+ this.#headers = {
564
+ ...this.#headers ?? {},
565
+ ...headers
566
+ };
567
+ return this;
568
+ }
569
+ /**
570
+ *
571
+ * @returns this.#headers['Content-Type'] = 'application/fhir+json';
572
+ */
573
+ withApplicationFhirAndJsonContentTypeHeaders() {
574
+ if (!this.#headers) this.#headers = {};
575
+ this.#headers["Content-Type"] = "application/fhir+json";
576
+ return this;
577
+ }
578
+ /**
579
+ *
580
+ * @returns this.#headers['Content-Type'] = 'application/merge-patch+json';
581
+ */
582
+ withApplicationMergePatchAndJsonContentTypeHeaders() {
583
+ if (!this.#headers) this.#headers = {};
584
+ this.#headers["Content-Type"] = "application/merge-patch+json";
585
+ return this;
586
+ }
587
+ /**
588
+ *
589
+ * @returns this.#headers['Content-Type'] = 'application/json-patch+json';
590
+ */
591
+ withApplicationJsonPatchAndJsonContentTypeHeaders() {
592
+ if (!this.#headers) this.#headers = {};
593
+ this.#headers["Content-Type"] = "application/json-patch+json";
594
+ return this;
595
+ }
596
+ /**
597
+ *
598
+ * @returns this.#headers['Content-Type'] = 'application/json';
599
+ */
600
+ withApplicationJsonContentTypeHeaders() {
601
+ if (!this.#headers) this.#headers = {};
602
+ this.#headers["Content-Type"] = "application/json";
603
+ return this;
604
+ }
605
+ /**
606
+ *
607
+ * @returns this.#headers['Content-Type'] = 'application/json';
608
+ */
609
+ withDefaultHeaders() {
610
+ if (!this.#headers) this.#headers = {};
611
+ this.#headers["Content-Type"] = "application/json";
612
+ return this;
613
+ }
614
+ /**
615
+ *
616
+ * @returns
617
+ */
618
+ withCredentials() {
619
+ this.#withCredentials = true;
620
+ return this;
621
+ }
622
+ /**
623
+ *
624
+ * @param timeout Add a connection timeout
625
+ * @returns
626
+ */
627
+ withTimeout(timeout) {
628
+ this.#timeout = timeout;
629
+ return this;
630
+ }
631
+ /**
632
+ *
633
+ * @param agentManager Add the agent manager for each rest call. Only for nodejs not browser.
634
+ * @returns
635
+ */
636
+ withAgentManager(agentManager) {
637
+ this.#agentManager = agentManager;
638
+ return this;
639
+ }
640
+ /**
641
+ * @returns Returns axios config object
642
+ */
643
+ get config() {
644
+ const retVal = {
645
+ url: this.#url,
646
+ method: this.#method
647
+ };
648
+ if (this.#headers) retVal.headers = this.#headers;
649
+ if (this.#agentManager !== void 0) if (this.#agentManager.IsHttps(this.#url)) retVal.httpsAgent = this.#agentManager.GetAgent(this.#url);
650
+ else retVal.httpAgent = this.#agentManager.GetAgent(this.#url);
651
+ if (this.#data !== void 0) retVal.data = this.#data;
652
+ if (this.#timeout !== void 0) retVal.timeout = this.#timeout;
653
+ if (this.#withCredentials !== void 0 && this.#withCredentials === true) retVal.withCredentials = true;
654
+ return retVal;
655
+ }
656
+ };
657
+ //#endregion
658
+ //#region src/agentManager.ts
1848
659
  function createAgentManager(agentManagerOptions) {
1849
- return new AgentManager(agentManagerOptions);
1850
- }
1851
- class AgentManager {
1852
- #options;
1853
- #agentResetInterval = null;
1854
- #requestCount = 0;
1855
- #httpAgent = void 0;
1856
- #httpsAgent = void 0;
1857
- constructor(agentManagerOptions) {
1858
- this.#options = agentManagerOptions;
1859
- if (this.#options.agentResetInterval) {
1860
- this.#SetupResetInterval();
1861
- }
1862
- }
1863
- get agentResetInterval() {
1864
- return this.#options.agentResetInterval;
1865
- }
1866
- UpdateAgentResetInterval(val) {
1867
- if (this.#agentResetInterval) {
1868
- clearTimeout(this.#agentResetInterval);
1869
- }
1870
- this.#options.agentResetInterval = val;
1871
- this.#SetupResetInterval();
1872
- }
1873
- get agentResetCount() {
1874
- return this.#options.agentResetCount;
1875
- }
1876
- UpdateAgentResetCount(val) {
1877
- this.#options.agentResetCount = val;
1878
- }
1879
- #SetupResetInterval = () => {
1880
- if (this.#options.agentResetInterval && this.#options.agentResetInterval > 0) {
1881
- this.#agentResetInterval = setTimeout(() => {
1882
- this.ResetAgent();
1883
- this.#SetupResetInterval();
1884
- }, this.#options.agentResetInterval).unref();
1885
- }
1886
- };
1887
- IncRequestCount() {
1888
- this.#requestCount++;
1889
- if (this.#options.agentResetCount) {
1890
- if (this.#requestCount % this.#options.agentResetCount === 0) {
1891
- this.ResetAgent();
1892
- }
1893
- }
1894
- }
1895
- IsHttps(protocol) {
1896
- if (protocol.toLowerCase().startsWith("https:")) {
1897
- return true;
1898
- }
1899
- return false;
1900
- }
1901
- #GetAgentOptions = (https) => {
1902
- let options;
1903
- if (this.#options.agentOptions) {
1904
- options = {
1905
- keepAlive: this.#options.agentOptions.keepAlive,
1906
- maxSockets: this.#options.agentOptions.maxSockets,
1907
- maxTotalSockets: this.#options.agentOptions.maxTotalSockets,
1908
- maxFreeSockets: this.#options.agentOptions.maxFreeSockets,
1909
- timeout: this.#options.agentOptions.timeout
1910
- };
1911
- if (https === true) {
1912
- options.rejectUnauthorized = this.#options.agentOptions.rejectUnauthorized;
1913
- }
1914
- } else {
1915
- options = {
1916
- keepAlive: true,
1917
- maxSockets: 10,
1918
- maxTotalSockets: 20,
1919
- maxFreeSockets: 256,
1920
- timeout: 3e4,
1921
- rejectUnauthorized: false
1922
- };
1923
- }
1924
- return options;
1925
- };
1926
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
1927
- GetAgent(protocol) {
1928
- if (protocol.toLowerCase().startsWith("https:")) {
1929
- if (!this.#httpsAgent) {
1930
- this.#httpsAgent = this.#options.httpsAgentFactory(this.#GetAgentOptions(true));
1931
- }
1932
- return this.#httpsAgent;
1933
- } else if (protocol.toLowerCase().startsWith("http:")) {
1934
- if (!this.#httpAgent) {
1935
- this.#httpAgent = this.#options.httpAgentFactory(this.#GetAgentOptions(false));
1936
- }
1937
- return this.#httpAgent;
1938
- } else {
1939
- return null;
1940
- }
1941
- }
1942
- ResetAgent() {
1943
- this.#httpAgent = null;
1944
- this.#httpsAgent = null;
1945
- }
1946
- Terminate() {
1947
- if (this.#agentResetInterval) {
1948
- clearTimeout(this.#agentResetInterval);
1949
- this.#agentResetInterval = null;
1950
- }
1951
- if (this.#httpAgent) {
1952
- this.#httpAgent.destroy();
1953
- this.#httpAgent = null;
1954
- }
1955
- if (this.#httpsAgent) {
1956
- this.#httpsAgent.destroy();
1957
- this.#httpsAgent = null;
1958
- }
1959
- }
660
+ return new AgentManager(agentManagerOptions);
1960
661
  }
1961
- exports.AddSchema = AddSchema;
662
+ var AgentManager = class {
663
+ #options;
664
+ #agentResetInterval = null;
665
+ #requestCount = 0;
666
+ #httpAgent = void 0;
667
+ #httpsAgent = void 0;
668
+ constructor(agentManagerOptions) {
669
+ this.#options = agentManagerOptions;
670
+ if (this.#options.agentResetInterval) this.#SetupResetInterval();
671
+ }
672
+ get agentResetInterval() {
673
+ return this.#options.agentResetInterval;
674
+ }
675
+ UpdateAgentResetInterval(val) {
676
+ if (this.#agentResetInterval) clearTimeout(this.#agentResetInterval);
677
+ this.#options.agentResetInterval = val;
678
+ this.#SetupResetInterval();
679
+ }
680
+ get agentResetCount() {
681
+ return this.#options.agentResetCount;
682
+ }
683
+ UpdateAgentResetCount(val) {
684
+ this.#options.agentResetCount = val;
685
+ }
686
+ #SetupResetInterval = () => {
687
+ if (this.#options.agentResetInterval && this.#options.agentResetInterval > 0) this.#agentResetInterval = setTimeout(() => {
688
+ this.ResetAgent();
689
+ this.#SetupResetInterval();
690
+ }, this.#options.agentResetInterval).unref();
691
+ };
692
+ IncRequestCount() {
693
+ this.#requestCount++;
694
+ if (this.#options.agentResetCount) {
695
+ if (this.#requestCount % this.#options.agentResetCount === 0) this.ResetAgent();
696
+ }
697
+ }
698
+ IsHttps(protocol) {
699
+ if (protocol.toLowerCase().startsWith("https:")) return true;
700
+ return false;
701
+ }
702
+ #GetAgentOptions = (https) => {
703
+ let options;
704
+ if (this.#options.agentOptions) {
705
+ options = {
706
+ keepAlive: this.#options.agentOptions.keepAlive,
707
+ maxSockets: this.#options.agentOptions.maxSockets,
708
+ maxTotalSockets: this.#options.agentOptions.maxTotalSockets,
709
+ maxFreeSockets: this.#options.agentOptions.maxFreeSockets,
710
+ timeout: this.#options.agentOptions.timeout
711
+ };
712
+ if (https === true) options.rejectUnauthorized = this.#options.agentOptions.rejectUnauthorized;
713
+ } else options = {
714
+ keepAlive: true,
715
+ maxSockets: 10,
716
+ maxTotalSockets: 20,
717
+ maxFreeSockets: 256,
718
+ timeout: 3e4,
719
+ rejectUnauthorized: false
720
+ };
721
+ return options;
722
+ };
723
+ GetAgent(protocol) {
724
+ if (protocol.toLowerCase().startsWith("https:")) {
725
+ if (!this.#httpsAgent) this.#httpsAgent = this.#options.httpsAgentFactory(this.#GetAgentOptions(true));
726
+ return this.#httpsAgent;
727
+ } else if (protocol.toLowerCase().startsWith("http:")) {
728
+ if (!this.#httpAgent) this.#httpAgent = this.#options.httpAgentFactory(this.#GetAgentOptions(false));
729
+ return this.#httpAgent;
730
+ } else return null;
731
+ }
732
+ ResetAgent() {
733
+ this.#httpAgent = null;
734
+ this.#httpsAgent = null;
735
+ }
736
+ Terminate() {
737
+ if (this.#agentResetInterval) {
738
+ clearTimeout(this.#agentResetInterval);
739
+ this.#agentResetInterval = null;
740
+ }
741
+ if (this.#httpAgent) {
742
+ this.#httpAgent.destroy();
743
+ this.#httpAgent = null;
744
+ }
745
+ if (this.#httpsAgent) {
746
+ this.#httpsAgent.destroy();
747
+ this.#httpsAgent = null;
748
+ }
749
+ }
750
+ };
751
+ //#endregion
1962
752
  exports.CheckValidChar = CheckValidChar;
1963
753
  exports.GetErrorPayload = GetErrorPayload;
1964
754
  exports.JestSleep = JestSleep;
@@ -1968,12 +758,11 @@ exports.OAuth2ParameterType = OAuth2ParameterType;
1968
758
  exports.OIDCAddressClaim = OIDCAddressClaim;
1969
759
  exports.OIDCStandardClaim = OIDCStandardClaim;
1970
760
  exports.STSAxiosConfig = STSAxiosConfig;
1971
- exports.STSOptionsBase = STSOptionsBase;
1972
761
  exports.Sleep = Sleep;
1973
- exports.Validate = Validate;
1974
762
  exports.compareParameterTypes = compareParameterTypes;
1975
763
  exports.createAgentManager = createAgentManager;
1976
764
  exports.defaultLogger = defaultLogger;
1977
765
  exports.edbaction = edbaction;
1978
766
  exports.emptyLogger = emptyLogger;
1979
- //# sourceMappingURL=index.cjs.map
767
+
768
+ //# sourceMappingURL=index.cjs.map