@nsshunt/stsutils 1.19.70 → 1.19.72

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 ADDED
@@ -0,0 +1,1903 @@
1
+ "use strict";
2
+ 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;
1113
+ }
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;
1124
+ }
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;
1163
+ }
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;
1277
+ }
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;
1455
+ }
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
+ });
1480
+ };
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
+ }
1503
+ };
1504
+ var edbaction = /* @__PURE__ */ ((edbaction2) => {
1505
+ edbaction2[edbaction2["created"] = 1] = "created";
1506
+ edbaction2[edbaction2["updated"] = 2] = "updated";
1507
+ edbaction2[edbaction2["deleted"] = 3] = "deleted";
1508
+ return edbaction2;
1509
+ })(edbaction || {});
1510
+ function GetErrorPayload(errorCode, details = null) {
1511
+ return {
1512
+ error: errorCode.code,
1513
+ error_description: errorCode.description,
1514
+ timestamp: Date.now(),
1515
+ //trace_id: "255d1aef-8c98-452f-ac51-23d051240864", //@@
1516
+ //correlation_id: "fb3d2015-bc17-4bb9-bb85-30c5cf1aaaa7", //@@
1517
+ details
1518
+ };
1519
+ }
1520
+ const ajv = new Ajv();
1521
+ const _Validate = (validator, payload) => {
1522
+ const valid = validator(payload);
1523
+ if (!valid) {
1524
+ return validator.errors;
1525
+ } else {
1526
+ return null;
1527
+ }
1528
+ };
1529
+ function AddSchema(name, schema) {
1530
+ ajv.addSchema(schema, name);
1531
+ }
1532
+ function Validate(name, payload) {
1533
+ const validator = ajv.getSchema(name);
1534
+ if (validator) {
1535
+ return _Validate(validator, payload);
1536
+ }
1537
+ }
1538
+ class STSOptionsBase {
1539
+ #options;
1540
+ constructor(options = null) {
1541
+ this.#options = options;
1542
+ if (options !== null) {
1543
+ if (typeof options.validator === "undefined") ;
1544
+ else {
1545
+ Validate(options.validator, options);
1546
+ }
1547
+ }
1548
+ }
1549
+ get options() {
1550
+ return this.#options;
1551
+ }
1552
+ }
1553
+ async function Sleep(milliseconds = 1e3) {
1554
+ return new Promise((resolve) => setTimeout(resolve, milliseconds));
1555
+ }
1556
+ async function JestSleep() {
1557
+ return Sleep(100);
1558
+ }
1559
+ var OAuth2ParameterType = /* @__PURE__ */ ((OAuth2ParameterType2) => {
1560
+ OAuth2ParameterType2["AUDIENCE"] = "AUDIENCE";
1561
+ OAuth2ParameterType2["CLIENT_ID"] = "client_id";
1562
+ OAuth2ParameterType2["CLIENT_SECRET"] = "client_secret";
1563
+ OAuth2ParameterType2["RESPONSE_TYPE"] = "response_type";
1564
+ OAuth2ParameterType2["SCOPE"] = "scope";
1565
+ OAuth2ParameterType2["STATE"] = "state";
1566
+ OAuth2ParameterType2["REDIRECT_URI"] = "redirect_uri";
1567
+ OAuth2ParameterType2["ERROR"] = "error";
1568
+ OAuth2ParameterType2["ERROR_DESCRIPTION"] = "error_description";
1569
+ OAuth2ParameterType2["ERROR_CODES"] = "error_codes";
1570
+ OAuth2ParameterType2["ERROR_URI"] = "error_uri";
1571
+ OAuth2ParameterType2["GRANT_TYPE"] = "grant_type";
1572
+ OAuth2ParameterType2["CODE"] = "code";
1573
+ OAuth2ParameterType2["ACCESS_TOKEN"] = "access_token";
1574
+ OAuth2ParameterType2["TOKEN_TYPE"] = "token_type";
1575
+ OAuth2ParameterType2["EXPIRES_IN"] = "expires_in";
1576
+ OAuth2ParameterType2["USERNAME"] = "username";
1577
+ OAuth2ParameterType2["PASSWORD"] = "password";
1578
+ OAuth2ParameterType2["REFRESH_TOKEN"] = "refresh_token";
1579
+ OAuth2ParameterType2["RESPONSE_MODE"] = "response_mode";
1580
+ OAuth2ParameterType2["TIMESTAMP"] = "timestamp";
1581
+ OAuth2ParameterType2["TRACE_ID"] = "trace_id";
1582
+ OAuth2ParameterType2["CORRELATION_ID"] = "correlation_id";
1583
+ return OAuth2ParameterType2;
1584
+ })(OAuth2ParameterType || {});
1585
+ var OIDCStandardClaim = /* @__PURE__ */ ((OIDCStandardClaim2) => {
1586
+ OIDCStandardClaim2["SUB"] = "sub";
1587
+ OIDCStandardClaim2["NAME"] = "name";
1588
+ OIDCStandardClaim2["GIVEN_NAME"] = "given_name";
1589
+ OIDCStandardClaim2["FAMILY_NAME"] = "family_name";
1590
+ OIDCStandardClaim2["MIDDLE_NAME"] = "middle_name";
1591
+ OIDCStandardClaim2["NICKNAME"] = "nickname";
1592
+ OIDCStandardClaim2["PREFERRED_USERNAME"] = "preferred_username";
1593
+ OIDCStandardClaim2["PROFILE"] = "profile";
1594
+ OIDCStandardClaim2["PICTURE"] = "picture";
1595
+ OIDCStandardClaim2["WEBSITE"] = "website";
1596
+ OIDCStandardClaim2["EMAIL"] = "email";
1597
+ OIDCStandardClaim2["EMAIL_VERIFIED"] = "email_verified";
1598
+ OIDCStandardClaim2["GENDER"] = "gender";
1599
+ OIDCStandardClaim2["BIRTHDATE"] = "birthdate";
1600
+ OIDCStandardClaim2["ZONEINFO"] = "zoneinfo";
1601
+ OIDCStandardClaim2["LOCALE"] = "locale";
1602
+ OIDCStandardClaim2["PHONE_NUMBER"] = "phone_number";
1603
+ OIDCStandardClaim2["PHONE_NUMBER_VERIFIED"] = "phone_number_verified";
1604
+ OIDCStandardClaim2["ADDRESS"] = "address";
1605
+ OIDCStandardClaim2["CLIENT_SECRET"] = "client_secret";
1606
+ OIDCStandardClaim2["NONCE"] = "nonce";
1607
+ return OIDCStandardClaim2;
1608
+ })(OIDCStandardClaim || {});
1609
+ var OIDCAddressClaim = /* @__PURE__ */ ((OIDCAddressClaim2) => {
1610
+ OIDCAddressClaim2["FORMATTED"] = "formatted";
1611
+ OIDCAddressClaim2["STREET_ADDRESS"] = "street_address";
1612
+ OIDCAddressClaim2["LOCALITY"] = "locality";
1613
+ OIDCAddressClaim2["REGION"] = "region";
1614
+ OIDCAddressClaim2["COUNTRY"] = "country";
1615
+ return OIDCAddressClaim2;
1616
+ })(OIDCAddressClaim || {});
1617
+ class OAuth2ParameterErrorType {
1618
+ static NOT_EQUAL = {
1619
+ code: "STS_OAUTH2_ERR_0001",
1620
+ description: "Parameter values not equal."
1621
+ };
1622
+ static NOT_PRESENT = {
1623
+ code: "STS_OAUTH2_ERR_0002",
1624
+ description: "Parameter not provided."
1625
+ };
1626
+ static INVALID_FORMAT = {
1627
+ code: "STS_OAUTH2_ERR_0003",
1628
+ description: "Parameter value format invalid."
1629
+ };
1630
+ static EXPIRED = {
1631
+ code: "STS_OAUTH2_ERR_0004",
1632
+ description: "Parameter value expired."
1633
+ };
1634
+ }
1635
+ function compareParameterTypes(source1, source2, authParameterTypes) {
1636
+ const errors = [];
1637
+ for (let i = 0; i < authParameterTypes.length; i++) {
1638
+ const authParameterType = authParameterTypes[i];
1639
+ if (source1[i].localeCompare(source2[i]) !== 0) {
1640
+ const error = {
1641
+ error: OAuth2ParameterErrorType.NOT_EQUAL.code,
1642
+ error_description: OAuth2ParameterErrorType.NOT_EQUAL.description,
1643
+ timestamp: Date.now(),
1644
+ details: `${OAuth2ParameterErrorType.NOT_EQUAL.description}: Parameter: [${authParameterType}]`
1645
+ };
1646
+ errors.push(error);
1647
+ }
1648
+ }
1649
+ return errors;
1650
+ }
1651
+ class STSAxiosConfig {
1652
+ #url;
1653
+ #method;
1654
+ #headers;
1655
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1656
+ #data;
1657
+ #agentManager;
1658
+ #timeout;
1659
+ #withCredentials;
1660
+ constructor(url, method, headers, timeout) {
1661
+ this.#url = url;
1662
+ this.#method = method;
1663
+ if (headers !== void 0) {
1664
+ this.#headers = headers;
1665
+ }
1666
+ if (timeout !== void 0) {
1667
+ this.#timeout = timeout;
1668
+ }
1669
+ }
1670
+ withCookies(cookies) {
1671
+ if (!this.#headers) {
1672
+ this.#headers = {};
1673
+ }
1674
+ this.#headers["Cookie"] = cookies.join("; ");
1675
+ return this;
1676
+ }
1677
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1678
+ withData(data) {
1679
+ this.#data = data;
1680
+ return this;
1681
+ }
1682
+ // 'Content-Type': 'application/json'
1683
+ withAuthHeaders(accesssToken, stsUserId) {
1684
+ if (!this.#headers) {
1685
+ this.#headers = {};
1686
+ }
1687
+ this.#headers["Authorization"] = "Bearer " + accesssToken;
1688
+ if (stsUserId) {
1689
+ this.#headers["x-sts_user_id"] = stsUserId;
1690
+ }
1691
+ return this;
1692
+ }
1693
+ withHeaders(headers) {
1694
+ this.#headers = {
1695
+ ...this.#headers ?? {},
1696
+ ...headers
1697
+ };
1698
+ return this;
1699
+ }
1700
+ withApplicationFhirAndJsonContentTypeHeaders() {
1701
+ if (!this.#headers) {
1702
+ this.#headers = {};
1703
+ }
1704
+ this.#headers["Content-Type"] = "application/fhir+json";
1705
+ return this;
1706
+ }
1707
+ withApplicationMergePatchAndJsonContentTypeHeaders() {
1708
+ if (!this.#headers) {
1709
+ this.#headers = {};
1710
+ }
1711
+ this.#headers["Content-Type"] = "application/merge-patch+json";
1712
+ return this;
1713
+ }
1714
+ withApplicationJsonPatchAndJsonContentTypeHeaders() {
1715
+ if (!this.#headers) {
1716
+ this.#headers = {};
1717
+ }
1718
+ this.#headers["Content-Type"] = "application/json-patch+json";
1719
+ return this;
1720
+ }
1721
+ withApplicationJsonContentTypeHeaders() {
1722
+ if (!this.#headers) {
1723
+ this.#headers = {};
1724
+ }
1725
+ this.#headers["Content-Type"] = "application/json";
1726
+ return this;
1727
+ }
1728
+ withDefaultHeaders() {
1729
+ if (!this.#headers) {
1730
+ this.#headers = {};
1731
+ }
1732
+ this.#headers["Content-Type"] = "application/json";
1733
+ return this;
1734
+ }
1735
+ withCredentials() {
1736
+ this.#withCredentials = true;
1737
+ return this;
1738
+ }
1739
+ withTimeout(timeout) {
1740
+ this.#timeout = timeout;
1741
+ return this;
1742
+ }
1743
+ withAgentManager(agentManager) {
1744
+ this.#agentManager = agentManager;
1745
+ return this;
1746
+ }
1747
+ get config() {
1748
+ const retVal = {
1749
+ url: this.#url,
1750
+ method: this.#method
1751
+ };
1752
+ if (this.#headers) {
1753
+ retVal.headers = this.#headers;
1754
+ }
1755
+ if (this.#agentManager !== void 0) {
1756
+ if (this.#agentManager.IsHttps(this.#url)) {
1757
+ retVal.httpsAgent = this.#agentManager.GetAgent(this.#url);
1758
+ } else {
1759
+ retVal.httpAgent = this.#agentManager.GetAgent(this.#url);
1760
+ }
1761
+ }
1762
+ if (this.#data !== void 0) {
1763
+ retVal.data = this.#data;
1764
+ }
1765
+ if (this.#timeout !== void 0) {
1766
+ retVal.timeout = this.#timeout;
1767
+ }
1768
+ if (this.#withCredentials !== void 0 && this.#withCredentials === true) {
1769
+ retVal.withCredentials = true;
1770
+ }
1771
+ return retVal;
1772
+ }
1773
+ }
1774
+ class AgentManager {
1775
+ #options;
1776
+ #agentResetInterval = null;
1777
+ #requestCount = 0;
1778
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1779
+ #httpAgent = void 0;
1780
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1781
+ #httpsAgent = void 0;
1782
+ constructor(agentManagerOptions) {
1783
+ this.#options = agentManagerOptions;
1784
+ if (this.#options.agentResetInterval) {
1785
+ this.#SetupResetInterval();
1786
+ }
1787
+ }
1788
+ get agentResetInterval() {
1789
+ return this.#options.agentResetInterval;
1790
+ }
1791
+ set agentResetInterval(val) {
1792
+ if (this.#agentResetInterval) {
1793
+ clearTimeout(this.#agentResetInterval);
1794
+ }
1795
+ this.#options.agentResetInterval = val;
1796
+ this.#SetupResetInterval();
1797
+ }
1798
+ get agentResetCount() {
1799
+ return this.#options.agentResetCount;
1800
+ }
1801
+ set agentResetCount(val) {
1802
+ this.#options.agentResetCount = val;
1803
+ }
1804
+ #SetupResetInterval = () => {
1805
+ if (this.#options.agentResetInterval && this.#options.agentResetInterval > 0) {
1806
+ this.#agentResetInterval = setTimeout(() => {
1807
+ this.ResetAgent();
1808
+ this.#SetupResetInterval();
1809
+ }, this.#options.agentResetInterval).unref();
1810
+ }
1811
+ };
1812
+ IncRequestCount() {
1813
+ this.#requestCount++;
1814
+ if (this.#options.agentResetCount) {
1815
+ if (this.#requestCount % this.#options.agentResetCount === 0) {
1816
+ this.ResetAgent();
1817
+ }
1818
+ }
1819
+ }
1820
+ IsHttps(protocol) {
1821
+ if (protocol.toLowerCase().startsWith("https:")) {
1822
+ return true;
1823
+ }
1824
+ return false;
1825
+ }
1826
+ #GetAgentOptions = (https) => {
1827
+ let options;
1828
+ if (this.#options.agentOptions) {
1829
+ options = {
1830
+ keepAlive: this.#options.agentOptions.keepAlive,
1831
+ maxSockets: this.#options.agentOptions.maxSockets,
1832
+ maxTotalSockets: this.#options.agentOptions.maxTotalSockets,
1833
+ maxFreeSockets: this.#options.agentOptions.maxFreeSockets,
1834
+ timeout: this.#options.agentOptions.timeout
1835
+ };
1836
+ if (https === true) {
1837
+ options.rejectUnauthorized = this.#options.agentOptions.rejectUnauthorized;
1838
+ }
1839
+ } else {
1840
+ options = {
1841
+ keepAlive: true,
1842
+ maxSockets: 10,
1843
+ maxTotalSockets: 20,
1844
+ maxFreeSockets: 256,
1845
+ timeout: 3e4,
1846
+ rejectUnauthorized: false
1847
+ };
1848
+ }
1849
+ return options;
1850
+ };
1851
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1852
+ GetAgent(protocol) {
1853
+ if (protocol.toLowerCase().startsWith("https:")) {
1854
+ if (!this.#httpsAgent) {
1855
+ this.#httpsAgent = this.#options.httpsAgentFactory(this.#GetAgentOptions(true));
1856
+ }
1857
+ return this.#httpsAgent;
1858
+ } else if (protocol.toLowerCase().startsWith("http:")) {
1859
+ if (!this.#httpAgent) {
1860
+ this.#httpAgent = this.#options.httpAgentFactory(this.#GetAgentOptions(false));
1861
+ }
1862
+ return this.#httpAgent;
1863
+ } else {
1864
+ return null;
1865
+ }
1866
+ }
1867
+ ResetAgent() {
1868
+ this.#httpAgent = null;
1869
+ this.#httpsAgent = null;
1870
+ }
1871
+ Terminate() {
1872
+ if (this.#agentResetInterval) {
1873
+ clearTimeout(this.#agentResetInterval);
1874
+ this.#agentResetInterval = null;
1875
+ }
1876
+ if (this.#httpAgent) {
1877
+ this.#httpAgent.destroy();
1878
+ this.#httpAgent = null;
1879
+ }
1880
+ if (this.#httpsAgent) {
1881
+ this.#httpsAgent.destroy();
1882
+ this.#httpsAgent = null;
1883
+ }
1884
+ }
1885
+ }
1886
+ exports.AddSchema = AddSchema;
1887
+ exports.AgentManager = AgentManager;
1888
+ exports.CheckValidChar = CheckValidChar;
1889
+ exports.GetErrorPayload = GetErrorPayload;
1890
+ exports.JestSleep = JestSleep;
1891
+ exports.ModelDelimeter = ModelDelimeter;
1892
+ exports.OAuth2ParameterErrorType = OAuth2ParameterErrorType;
1893
+ exports.OAuth2ParameterType = OAuth2ParameterType;
1894
+ exports.OIDCAddressClaim = OIDCAddressClaim;
1895
+ exports.OIDCStandardClaim = OIDCStandardClaim;
1896
+ exports.STSAxiosConfig = STSAxiosConfig;
1897
+ exports.STSOptionsBase = STSOptionsBase;
1898
+ exports.Sleep = Sleep;
1899
+ exports.Validate = Validate;
1900
+ exports.compareParameterTypes = compareParameterTypes;
1901
+ exports.defaultLogger = defaultLogger;
1902
+ exports.edbaction = edbaction;
1903
+ //# sourceMappingURL=index.cjs.map