@nsshunt/stsoauth2plugin 1.0.43 → 1.0.44
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.
|
@@ -53,6 +53,7 @@ var __privateWrapper = (obj, member, setter, getter) => ({
|
|
|
53
53
|
}
|
|
54
54
|
const wt__namespace = /* @__PURE__ */ _interopNamespaceDefault(wt);
|
|
55
55
|
const STSOAuth2ManagerPluginKey = Symbol();
|
|
56
|
+
const isNode = Object.prototype.toString.call(typeof process !== "undefined" ? process : 0) === "[object process]";
|
|
56
57
|
var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
|
|
57
58
|
function getDefaultExportFromCjs(x) {
|
|
58
59
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
|
@@ -83,1436 +84,6 @@ var __privateWrapper = (obj, member, setter, getter) => ({
|
|
|
83
84
|
});
|
|
84
85
|
return a;
|
|
85
86
|
}
|
|
86
|
-
var ansiStyles$1 = { exports: {} };
|
|
87
|
-
var colorName;
|
|
88
|
-
var hasRequiredColorName;
|
|
89
|
-
function requireColorName() {
|
|
90
|
-
if (hasRequiredColorName)
|
|
91
|
-
return colorName;
|
|
92
|
-
hasRequiredColorName = 1;
|
|
93
|
-
colorName = {
|
|
94
|
-
"aliceblue": [240, 248, 255],
|
|
95
|
-
"antiquewhite": [250, 235, 215],
|
|
96
|
-
"aqua": [0, 255, 255],
|
|
97
|
-
"aquamarine": [127, 255, 212],
|
|
98
|
-
"azure": [240, 255, 255],
|
|
99
|
-
"beige": [245, 245, 220],
|
|
100
|
-
"bisque": [255, 228, 196],
|
|
101
|
-
"black": [0, 0, 0],
|
|
102
|
-
"blanchedalmond": [255, 235, 205],
|
|
103
|
-
"blue": [0, 0, 255],
|
|
104
|
-
"blueviolet": [138, 43, 226],
|
|
105
|
-
"brown": [165, 42, 42],
|
|
106
|
-
"burlywood": [222, 184, 135],
|
|
107
|
-
"cadetblue": [95, 158, 160],
|
|
108
|
-
"chartreuse": [127, 255, 0],
|
|
109
|
-
"chocolate": [210, 105, 30],
|
|
110
|
-
"coral": [255, 127, 80],
|
|
111
|
-
"cornflowerblue": [100, 149, 237],
|
|
112
|
-
"cornsilk": [255, 248, 220],
|
|
113
|
-
"crimson": [220, 20, 60],
|
|
114
|
-
"cyan": [0, 255, 255],
|
|
115
|
-
"darkblue": [0, 0, 139],
|
|
116
|
-
"darkcyan": [0, 139, 139],
|
|
117
|
-
"darkgoldenrod": [184, 134, 11],
|
|
118
|
-
"darkgray": [169, 169, 169],
|
|
119
|
-
"darkgreen": [0, 100, 0],
|
|
120
|
-
"darkgrey": [169, 169, 169],
|
|
121
|
-
"darkkhaki": [189, 183, 107],
|
|
122
|
-
"darkmagenta": [139, 0, 139],
|
|
123
|
-
"darkolivegreen": [85, 107, 47],
|
|
124
|
-
"darkorange": [255, 140, 0],
|
|
125
|
-
"darkorchid": [153, 50, 204],
|
|
126
|
-
"darkred": [139, 0, 0],
|
|
127
|
-
"darksalmon": [233, 150, 122],
|
|
128
|
-
"darkseagreen": [143, 188, 143],
|
|
129
|
-
"darkslateblue": [72, 61, 139],
|
|
130
|
-
"darkslategray": [47, 79, 79],
|
|
131
|
-
"darkslategrey": [47, 79, 79],
|
|
132
|
-
"darkturquoise": [0, 206, 209],
|
|
133
|
-
"darkviolet": [148, 0, 211],
|
|
134
|
-
"deeppink": [255, 20, 147],
|
|
135
|
-
"deepskyblue": [0, 191, 255],
|
|
136
|
-
"dimgray": [105, 105, 105],
|
|
137
|
-
"dimgrey": [105, 105, 105],
|
|
138
|
-
"dodgerblue": [30, 144, 255],
|
|
139
|
-
"firebrick": [178, 34, 34],
|
|
140
|
-
"floralwhite": [255, 250, 240],
|
|
141
|
-
"forestgreen": [34, 139, 34],
|
|
142
|
-
"fuchsia": [255, 0, 255],
|
|
143
|
-
"gainsboro": [220, 220, 220],
|
|
144
|
-
"ghostwhite": [248, 248, 255],
|
|
145
|
-
"gold": [255, 215, 0],
|
|
146
|
-
"goldenrod": [218, 165, 32],
|
|
147
|
-
"gray": [128, 128, 128],
|
|
148
|
-
"green": [0, 128, 0],
|
|
149
|
-
"greenyellow": [173, 255, 47],
|
|
150
|
-
"grey": [128, 128, 128],
|
|
151
|
-
"honeydew": [240, 255, 240],
|
|
152
|
-
"hotpink": [255, 105, 180],
|
|
153
|
-
"indianred": [205, 92, 92],
|
|
154
|
-
"indigo": [75, 0, 130],
|
|
155
|
-
"ivory": [255, 255, 240],
|
|
156
|
-
"khaki": [240, 230, 140],
|
|
157
|
-
"lavender": [230, 230, 250],
|
|
158
|
-
"lavenderblush": [255, 240, 245],
|
|
159
|
-
"lawngreen": [124, 252, 0],
|
|
160
|
-
"lemonchiffon": [255, 250, 205],
|
|
161
|
-
"lightblue": [173, 216, 230],
|
|
162
|
-
"lightcoral": [240, 128, 128],
|
|
163
|
-
"lightcyan": [224, 255, 255],
|
|
164
|
-
"lightgoldenrodyellow": [250, 250, 210],
|
|
165
|
-
"lightgray": [211, 211, 211],
|
|
166
|
-
"lightgreen": [144, 238, 144],
|
|
167
|
-
"lightgrey": [211, 211, 211],
|
|
168
|
-
"lightpink": [255, 182, 193],
|
|
169
|
-
"lightsalmon": [255, 160, 122],
|
|
170
|
-
"lightseagreen": [32, 178, 170],
|
|
171
|
-
"lightskyblue": [135, 206, 250],
|
|
172
|
-
"lightslategray": [119, 136, 153],
|
|
173
|
-
"lightslategrey": [119, 136, 153],
|
|
174
|
-
"lightsteelblue": [176, 196, 222],
|
|
175
|
-
"lightyellow": [255, 255, 224],
|
|
176
|
-
"lime": [0, 255, 0],
|
|
177
|
-
"limegreen": [50, 205, 50],
|
|
178
|
-
"linen": [250, 240, 230],
|
|
179
|
-
"magenta": [255, 0, 255],
|
|
180
|
-
"maroon": [128, 0, 0],
|
|
181
|
-
"mediumaquamarine": [102, 205, 170],
|
|
182
|
-
"mediumblue": [0, 0, 205],
|
|
183
|
-
"mediumorchid": [186, 85, 211],
|
|
184
|
-
"mediumpurple": [147, 112, 219],
|
|
185
|
-
"mediumseagreen": [60, 179, 113],
|
|
186
|
-
"mediumslateblue": [123, 104, 238],
|
|
187
|
-
"mediumspringgreen": [0, 250, 154],
|
|
188
|
-
"mediumturquoise": [72, 209, 204],
|
|
189
|
-
"mediumvioletred": [199, 21, 133],
|
|
190
|
-
"midnightblue": [25, 25, 112],
|
|
191
|
-
"mintcream": [245, 255, 250],
|
|
192
|
-
"mistyrose": [255, 228, 225],
|
|
193
|
-
"moccasin": [255, 228, 181],
|
|
194
|
-
"navajowhite": [255, 222, 173],
|
|
195
|
-
"navy": [0, 0, 128],
|
|
196
|
-
"oldlace": [253, 245, 230],
|
|
197
|
-
"olive": [128, 128, 0],
|
|
198
|
-
"olivedrab": [107, 142, 35],
|
|
199
|
-
"orange": [255, 165, 0],
|
|
200
|
-
"orangered": [255, 69, 0],
|
|
201
|
-
"orchid": [218, 112, 214],
|
|
202
|
-
"palegoldenrod": [238, 232, 170],
|
|
203
|
-
"palegreen": [152, 251, 152],
|
|
204
|
-
"paleturquoise": [175, 238, 238],
|
|
205
|
-
"palevioletred": [219, 112, 147],
|
|
206
|
-
"papayawhip": [255, 239, 213],
|
|
207
|
-
"peachpuff": [255, 218, 185],
|
|
208
|
-
"peru": [205, 133, 63],
|
|
209
|
-
"pink": [255, 192, 203],
|
|
210
|
-
"plum": [221, 160, 221],
|
|
211
|
-
"powderblue": [176, 224, 230],
|
|
212
|
-
"purple": [128, 0, 128],
|
|
213
|
-
"rebeccapurple": [102, 51, 153],
|
|
214
|
-
"red": [255, 0, 0],
|
|
215
|
-
"rosybrown": [188, 143, 143],
|
|
216
|
-
"royalblue": [65, 105, 225],
|
|
217
|
-
"saddlebrown": [139, 69, 19],
|
|
218
|
-
"salmon": [250, 128, 114],
|
|
219
|
-
"sandybrown": [244, 164, 96],
|
|
220
|
-
"seagreen": [46, 139, 87],
|
|
221
|
-
"seashell": [255, 245, 238],
|
|
222
|
-
"sienna": [160, 82, 45],
|
|
223
|
-
"silver": [192, 192, 192],
|
|
224
|
-
"skyblue": [135, 206, 235],
|
|
225
|
-
"slateblue": [106, 90, 205],
|
|
226
|
-
"slategray": [112, 128, 144],
|
|
227
|
-
"slategrey": [112, 128, 144],
|
|
228
|
-
"snow": [255, 250, 250],
|
|
229
|
-
"springgreen": [0, 255, 127],
|
|
230
|
-
"steelblue": [70, 130, 180],
|
|
231
|
-
"tan": [210, 180, 140],
|
|
232
|
-
"teal": [0, 128, 128],
|
|
233
|
-
"thistle": [216, 191, 216],
|
|
234
|
-
"tomato": [255, 99, 71],
|
|
235
|
-
"turquoise": [64, 224, 208],
|
|
236
|
-
"violet": [238, 130, 238],
|
|
237
|
-
"wheat": [245, 222, 179],
|
|
238
|
-
"white": [255, 255, 255],
|
|
239
|
-
"whitesmoke": [245, 245, 245],
|
|
240
|
-
"yellow": [255, 255, 0],
|
|
241
|
-
"yellowgreen": [154, 205, 50]
|
|
242
|
-
};
|
|
243
|
-
return colorName;
|
|
244
|
-
}
|
|
245
|
-
var conversions;
|
|
246
|
-
var hasRequiredConversions;
|
|
247
|
-
function requireConversions() {
|
|
248
|
-
if (hasRequiredConversions)
|
|
249
|
-
return conversions;
|
|
250
|
-
hasRequiredConversions = 1;
|
|
251
|
-
const cssKeywords = requireColorName();
|
|
252
|
-
const reverseKeywords = {};
|
|
253
|
-
for (const key of Object.keys(cssKeywords)) {
|
|
254
|
-
reverseKeywords[cssKeywords[key]] = key;
|
|
255
|
-
}
|
|
256
|
-
const convert = {
|
|
257
|
-
rgb: { channels: 3, labels: "rgb" },
|
|
258
|
-
hsl: { channels: 3, labels: "hsl" },
|
|
259
|
-
hsv: { channels: 3, labels: "hsv" },
|
|
260
|
-
hwb: { channels: 3, labels: "hwb" },
|
|
261
|
-
cmyk: { channels: 4, labels: "cmyk" },
|
|
262
|
-
xyz: { channels: 3, labels: "xyz" },
|
|
263
|
-
lab: { channels: 3, labels: "lab" },
|
|
264
|
-
lch: { channels: 3, labels: "lch" },
|
|
265
|
-
hex: { channels: 1, labels: ["hex"] },
|
|
266
|
-
keyword: { channels: 1, labels: ["keyword"] },
|
|
267
|
-
ansi16: { channels: 1, labels: ["ansi16"] },
|
|
268
|
-
ansi256: { channels: 1, labels: ["ansi256"] },
|
|
269
|
-
hcg: { channels: 3, labels: ["h", "c", "g"] },
|
|
270
|
-
apple: { channels: 3, labels: ["r16", "g16", "b16"] },
|
|
271
|
-
gray: { channels: 1, labels: ["gray"] }
|
|
272
|
-
};
|
|
273
|
-
conversions = convert;
|
|
274
|
-
for (const model of Object.keys(convert)) {
|
|
275
|
-
if (!("channels" in convert[model])) {
|
|
276
|
-
throw new Error("missing channels property: " + model);
|
|
277
|
-
}
|
|
278
|
-
if (!("labels" in convert[model])) {
|
|
279
|
-
throw new Error("missing channel labels property: " + model);
|
|
280
|
-
}
|
|
281
|
-
if (convert[model].labels.length !== convert[model].channels) {
|
|
282
|
-
throw new Error("channel and label counts mismatch: " + model);
|
|
283
|
-
}
|
|
284
|
-
const { channels, labels } = convert[model];
|
|
285
|
-
delete convert[model].channels;
|
|
286
|
-
delete convert[model].labels;
|
|
287
|
-
Object.defineProperty(convert[model], "channels", { value: channels });
|
|
288
|
-
Object.defineProperty(convert[model], "labels", { value: labels });
|
|
289
|
-
}
|
|
290
|
-
convert.rgb.hsl = function(rgb) {
|
|
291
|
-
const r = rgb[0] / 255;
|
|
292
|
-
const g = rgb[1] / 255;
|
|
293
|
-
const b = rgb[2] / 255;
|
|
294
|
-
const min = Math.min(r, g, b);
|
|
295
|
-
const max = Math.max(r, g, b);
|
|
296
|
-
const delta = max - min;
|
|
297
|
-
let h;
|
|
298
|
-
let s;
|
|
299
|
-
if (max === min) {
|
|
300
|
-
h = 0;
|
|
301
|
-
} else if (r === max) {
|
|
302
|
-
h = (g - b) / delta;
|
|
303
|
-
} else if (g === max) {
|
|
304
|
-
h = 2 + (b - r) / delta;
|
|
305
|
-
} else if (b === max) {
|
|
306
|
-
h = 4 + (r - g) / delta;
|
|
307
|
-
}
|
|
308
|
-
h = Math.min(h * 60, 360);
|
|
309
|
-
if (h < 0) {
|
|
310
|
-
h += 360;
|
|
311
|
-
}
|
|
312
|
-
const l = (min + max) / 2;
|
|
313
|
-
if (max === min) {
|
|
314
|
-
s = 0;
|
|
315
|
-
} else if (l <= 0.5) {
|
|
316
|
-
s = delta / (max + min);
|
|
317
|
-
} else {
|
|
318
|
-
s = delta / (2 - max - min);
|
|
319
|
-
}
|
|
320
|
-
return [h, s * 100, l * 100];
|
|
321
|
-
};
|
|
322
|
-
convert.rgb.hsv = function(rgb) {
|
|
323
|
-
let rdif;
|
|
324
|
-
let gdif;
|
|
325
|
-
let bdif;
|
|
326
|
-
let h;
|
|
327
|
-
let s;
|
|
328
|
-
const r = rgb[0] / 255;
|
|
329
|
-
const g = rgb[1] / 255;
|
|
330
|
-
const b = rgb[2] / 255;
|
|
331
|
-
const v = Math.max(r, g, b);
|
|
332
|
-
const diff = v - Math.min(r, g, b);
|
|
333
|
-
const diffc = function(c) {
|
|
334
|
-
return (v - c) / 6 / diff + 1 / 2;
|
|
335
|
-
};
|
|
336
|
-
if (diff === 0) {
|
|
337
|
-
h = 0;
|
|
338
|
-
s = 0;
|
|
339
|
-
} else {
|
|
340
|
-
s = diff / v;
|
|
341
|
-
rdif = diffc(r);
|
|
342
|
-
gdif = diffc(g);
|
|
343
|
-
bdif = diffc(b);
|
|
344
|
-
if (r === v) {
|
|
345
|
-
h = bdif - gdif;
|
|
346
|
-
} else if (g === v) {
|
|
347
|
-
h = 1 / 3 + rdif - bdif;
|
|
348
|
-
} else if (b === v) {
|
|
349
|
-
h = 2 / 3 + gdif - rdif;
|
|
350
|
-
}
|
|
351
|
-
if (h < 0) {
|
|
352
|
-
h += 1;
|
|
353
|
-
} else if (h > 1) {
|
|
354
|
-
h -= 1;
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
return [
|
|
358
|
-
h * 360,
|
|
359
|
-
s * 100,
|
|
360
|
-
v * 100
|
|
361
|
-
];
|
|
362
|
-
};
|
|
363
|
-
convert.rgb.hwb = function(rgb) {
|
|
364
|
-
const r = rgb[0];
|
|
365
|
-
const g = rgb[1];
|
|
366
|
-
let b = rgb[2];
|
|
367
|
-
const h = convert.rgb.hsl(rgb)[0];
|
|
368
|
-
const w = 1 / 255 * Math.min(r, Math.min(g, b));
|
|
369
|
-
b = 1 - 1 / 255 * Math.max(r, Math.max(g, b));
|
|
370
|
-
return [h, w * 100, b * 100];
|
|
371
|
-
};
|
|
372
|
-
convert.rgb.cmyk = function(rgb) {
|
|
373
|
-
const r = rgb[0] / 255;
|
|
374
|
-
const g = rgb[1] / 255;
|
|
375
|
-
const b = rgb[2] / 255;
|
|
376
|
-
const k = Math.min(1 - r, 1 - g, 1 - b);
|
|
377
|
-
const c = (1 - r - k) / (1 - k) || 0;
|
|
378
|
-
const m = (1 - g - k) / (1 - k) || 0;
|
|
379
|
-
const y = (1 - b - k) / (1 - k) || 0;
|
|
380
|
-
return [c * 100, m * 100, y * 100, k * 100];
|
|
381
|
-
};
|
|
382
|
-
function comparativeDistance(x, y) {
|
|
383
|
-
return (x[0] - y[0]) ** 2 + (x[1] - y[1]) ** 2 + (x[2] - y[2]) ** 2;
|
|
384
|
-
}
|
|
385
|
-
convert.rgb.keyword = function(rgb) {
|
|
386
|
-
const reversed = reverseKeywords[rgb];
|
|
387
|
-
if (reversed) {
|
|
388
|
-
return reversed;
|
|
389
|
-
}
|
|
390
|
-
let currentClosestDistance = Infinity;
|
|
391
|
-
let currentClosestKeyword;
|
|
392
|
-
for (const keyword of Object.keys(cssKeywords)) {
|
|
393
|
-
const value = cssKeywords[keyword];
|
|
394
|
-
const distance = comparativeDistance(rgb, value);
|
|
395
|
-
if (distance < currentClosestDistance) {
|
|
396
|
-
currentClosestDistance = distance;
|
|
397
|
-
currentClosestKeyword = keyword;
|
|
398
|
-
}
|
|
399
|
-
}
|
|
400
|
-
return currentClosestKeyword;
|
|
401
|
-
};
|
|
402
|
-
convert.keyword.rgb = function(keyword) {
|
|
403
|
-
return cssKeywords[keyword];
|
|
404
|
-
};
|
|
405
|
-
convert.rgb.xyz = function(rgb) {
|
|
406
|
-
let r = rgb[0] / 255;
|
|
407
|
-
let g = rgb[1] / 255;
|
|
408
|
-
let b = rgb[2] / 255;
|
|
409
|
-
r = r > 0.04045 ? ((r + 0.055) / 1.055) ** 2.4 : r / 12.92;
|
|
410
|
-
g = g > 0.04045 ? ((g + 0.055) / 1.055) ** 2.4 : g / 12.92;
|
|
411
|
-
b = b > 0.04045 ? ((b + 0.055) / 1.055) ** 2.4 : b / 12.92;
|
|
412
|
-
const x = r * 0.4124 + g * 0.3576 + b * 0.1805;
|
|
413
|
-
const y = r * 0.2126 + g * 0.7152 + b * 0.0722;
|
|
414
|
-
const z = r * 0.0193 + g * 0.1192 + b * 0.9505;
|
|
415
|
-
return [x * 100, y * 100, z * 100];
|
|
416
|
-
};
|
|
417
|
-
convert.rgb.lab = function(rgb) {
|
|
418
|
-
const xyz = convert.rgb.xyz(rgb);
|
|
419
|
-
let x = xyz[0];
|
|
420
|
-
let y = xyz[1];
|
|
421
|
-
let z = xyz[2];
|
|
422
|
-
x /= 95.047;
|
|
423
|
-
y /= 100;
|
|
424
|
-
z /= 108.883;
|
|
425
|
-
x = x > 8856e-6 ? x ** (1 / 3) : 7.787 * x + 16 / 116;
|
|
426
|
-
y = y > 8856e-6 ? y ** (1 / 3) : 7.787 * y + 16 / 116;
|
|
427
|
-
z = z > 8856e-6 ? z ** (1 / 3) : 7.787 * z + 16 / 116;
|
|
428
|
-
const l = 116 * y - 16;
|
|
429
|
-
const a = 500 * (x - y);
|
|
430
|
-
const b = 200 * (y - z);
|
|
431
|
-
return [l, a, b];
|
|
432
|
-
};
|
|
433
|
-
convert.hsl.rgb = function(hsl) {
|
|
434
|
-
const h = hsl[0] / 360;
|
|
435
|
-
const s = hsl[1] / 100;
|
|
436
|
-
const l = hsl[2] / 100;
|
|
437
|
-
let t2;
|
|
438
|
-
let t3;
|
|
439
|
-
let val;
|
|
440
|
-
if (s === 0) {
|
|
441
|
-
val = l * 255;
|
|
442
|
-
return [val, val, val];
|
|
443
|
-
}
|
|
444
|
-
if (l < 0.5) {
|
|
445
|
-
t2 = l * (1 + s);
|
|
446
|
-
} else {
|
|
447
|
-
t2 = l + s - l * s;
|
|
448
|
-
}
|
|
449
|
-
const t1 = 2 * l - t2;
|
|
450
|
-
const rgb = [0, 0, 0];
|
|
451
|
-
for (let i = 0; i < 3; i++) {
|
|
452
|
-
t3 = h + 1 / 3 * -(i - 1);
|
|
453
|
-
if (t3 < 0) {
|
|
454
|
-
t3++;
|
|
455
|
-
}
|
|
456
|
-
if (t3 > 1) {
|
|
457
|
-
t3--;
|
|
458
|
-
}
|
|
459
|
-
if (6 * t3 < 1) {
|
|
460
|
-
val = t1 + (t2 - t1) * 6 * t3;
|
|
461
|
-
} else if (2 * t3 < 1) {
|
|
462
|
-
val = t2;
|
|
463
|
-
} else if (3 * t3 < 2) {
|
|
464
|
-
val = t1 + (t2 - t1) * (2 / 3 - t3) * 6;
|
|
465
|
-
} else {
|
|
466
|
-
val = t1;
|
|
467
|
-
}
|
|
468
|
-
rgb[i] = val * 255;
|
|
469
|
-
}
|
|
470
|
-
return rgb;
|
|
471
|
-
};
|
|
472
|
-
convert.hsl.hsv = function(hsl) {
|
|
473
|
-
const h = hsl[0];
|
|
474
|
-
let s = hsl[1] / 100;
|
|
475
|
-
let l = hsl[2] / 100;
|
|
476
|
-
let smin = s;
|
|
477
|
-
const lmin = Math.max(l, 0.01);
|
|
478
|
-
l *= 2;
|
|
479
|
-
s *= l <= 1 ? l : 2 - l;
|
|
480
|
-
smin *= lmin <= 1 ? lmin : 2 - lmin;
|
|
481
|
-
const v = (l + s) / 2;
|
|
482
|
-
const sv = l === 0 ? 2 * smin / (lmin + smin) : 2 * s / (l + s);
|
|
483
|
-
return [h, sv * 100, v * 100];
|
|
484
|
-
};
|
|
485
|
-
convert.hsv.rgb = function(hsv) {
|
|
486
|
-
const h = hsv[0] / 60;
|
|
487
|
-
const s = hsv[1] / 100;
|
|
488
|
-
let v = hsv[2] / 100;
|
|
489
|
-
const hi = Math.floor(h) % 6;
|
|
490
|
-
const f = h - Math.floor(h);
|
|
491
|
-
const p = 255 * v * (1 - s);
|
|
492
|
-
const q = 255 * v * (1 - s * f);
|
|
493
|
-
const t = 255 * v * (1 - s * (1 - f));
|
|
494
|
-
v *= 255;
|
|
495
|
-
switch (hi) {
|
|
496
|
-
case 0:
|
|
497
|
-
return [v, t, p];
|
|
498
|
-
case 1:
|
|
499
|
-
return [q, v, p];
|
|
500
|
-
case 2:
|
|
501
|
-
return [p, v, t];
|
|
502
|
-
case 3:
|
|
503
|
-
return [p, q, v];
|
|
504
|
-
case 4:
|
|
505
|
-
return [t, p, v];
|
|
506
|
-
case 5:
|
|
507
|
-
return [v, p, q];
|
|
508
|
-
}
|
|
509
|
-
};
|
|
510
|
-
convert.hsv.hsl = function(hsv) {
|
|
511
|
-
const h = hsv[0];
|
|
512
|
-
const s = hsv[1] / 100;
|
|
513
|
-
const v = hsv[2] / 100;
|
|
514
|
-
const vmin = Math.max(v, 0.01);
|
|
515
|
-
let sl;
|
|
516
|
-
let l;
|
|
517
|
-
l = (2 - s) * v;
|
|
518
|
-
const lmin = (2 - s) * vmin;
|
|
519
|
-
sl = s * vmin;
|
|
520
|
-
sl /= lmin <= 1 ? lmin : 2 - lmin;
|
|
521
|
-
sl = sl || 0;
|
|
522
|
-
l /= 2;
|
|
523
|
-
return [h, sl * 100, l * 100];
|
|
524
|
-
};
|
|
525
|
-
convert.hwb.rgb = function(hwb) {
|
|
526
|
-
const h = hwb[0] / 360;
|
|
527
|
-
let wh = hwb[1] / 100;
|
|
528
|
-
let bl = hwb[2] / 100;
|
|
529
|
-
const ratio = wh + bl;
|
|
530
|
-
let f;
|
|
531
|
-
if (ratio > 1) {
|
|
532
|
-
wh /= ratio;
|
|
533
|
-
bl /= ratio;
|
|
534
|
-
}
|
|
535
|
-
const i = Math.floor(6 * h);
|
|
536
|
-
const v = 1 - bl;
|
|
537
|
-
f = 6 * h - i;
|
|
538
|
-
if ((i & 1) !== 0) {
|
|
539
|
-
f = 1 - f;
|
|
540
|
-
}
|
|
541
|
-
const n = wh + f * (v - wh);
|
|
542
|
-
let r;
|
|
543
|
-
let g;
|
|
544
|
-
let b;
|
|
545
|
-
switch (i) {
|
|
546
|
-
default:
|
|
547
|
-
case 6:
|
|
548
|
-
case 0:
|
|
549
|
-
r = v;
|
|
550
|
-
g = n;
|
|
551
|
-
b = wh;
|
|
552
|
-
break;
|
|
553
|
-
case 1:
|
|
554
|
-
r = n;
|
|
555
|
-
g = v;
|
|
556
|
-
b = wh;
|
|
557
|
-
break;
|
|
558
|
-
case 2:
|
|
559
|
-
r = wh;
|
|
560
|
-
g = v;
|
|
561
|
-
b = n;
|
|
562
|
-
break;
|
|
563
|
-
case 3:
|
|
564
|
-
r = wh;
|
|
565
|
-
g = n;
|
|
566
|
-
b = v;
|
|
567
|
-
break;
|
|
568
|
-
case 4:
|
|
569
|
-
r = n;
|
|
570
|
-
g = wh;
|
|
571
|
-
b = v;
|
|
572
|
-
break;
|
|
573
|
-
case 5:
|
|
574
|
-
r = v;
|
|
575
|
-
g = wh;
|
|
576
|
-
b = n;
|
|
577
|
-
break;
|
|
578
|
-
}
|
|
579
|
-
return [r * 255, g * 255, b * 255];
|
|
580
|
-
};
|
|
581
|
-
convert.cmyk.rgb = function(cmyk) {
|
|
582
|
-
const c = cmyk[0] / 100;
|
|
583
|
-
const m = cmyk[1] / 100;
|
|
584
|
-
const y = cmyk[2] / 100;
|
|
585
|
-
const k = cmyk[3] / 100;
|
|
586
|
-
const r = 1 - Math.min(1, c * (1 - k) + k);
|
|
587
|
-
const g = 1 - Math.min(1, m * (1 - k) + k);
|
|
588
|
-
const b = 1 - Math.min(1, y * (1 - k) + k);
|
|
589
|
-
return [r * 255, g * 255, b * 255];
|
|
590
|
-
};
|
|
591
|
-
convert.xyz.rgb = function(xyz) {
|
|
592
|
-
const x = xyz[0] / 100;
|
|
593
|
-
const y = xyz[1] / 100;
|
|
594
|
-
const z = xyz[2] / 100;
|
|
595
|
-
let r;
|
|
596
|
-
let g;
|
|
597
|
-
let b;
|
|
598
|
-
r = x * 3.2406 + y * -1.5372 + z * -0.4986;
|
|
599
|
-
g = x * -0.9689 + y * 1.8758 + z * 0.0415;
|
|
600
|
-
b = x * 0.0557 + y * -0.204 + z * 1.057;
|
|
601
|
-
r = r > 31308e-7 ? 1.055 * r ** (1 / 2.4) - 0.055 : r * 12.92;
|
|
602
|
-
g = g > 31308e-7 ? 1.055 * g ** (1 / 2.4) - 0.055 : g * 12.92;
|
|
603
|
-
b = b > 31308e-7 ? 1.055 * b ** (1 / 2.4) - 0.055 : b * 12.92;
|
|
604
|
-
r = Math.min(Math.max(0, r), 1);
|
|
605
|
-
g = Math.min(Math.max(0, g), 1);
|
|
606
|
-
b = Math.min(Math.max(0, b), 1);
|
|
607
|
-
return [r * 255, g * 255, b * 255];
|
|
608
|
-
};
|
|
609
|
-
convert.xyz.lab = function(xyz) {
|
|
610
|
-
let x = xyz[0];
|
|
611
|
-
let y = xyz[1];
|
|
612
|
-
let z = xyz[2];
|
|
613
|
-
x /= 95.047;
|
|
614
|
-
y /= 100;
|
|
615
|
-
z /= 108.883;
|
|
616
|
-
x = x > 8856e-6 ? x ** (1 / 3) : 7.787 * x + 16 / 116;
|
|
617
|
-
y = y > 8856e-6 ? y ** (1 / 3) : 7.787 * y + 16 / 116;
|
|
618
|
-
z = z > 8856e-6 ? z ** (1 / 3) : 7.787 * z + 16 / 116;
|
|
619
|
-
const l = 116 * y - 16;
|
|
620
|
-
const a = 500 * (x - y);
|
|
621
|
-
const b = 200 * (y - z);
|
|
622
|
-
return [l, a, b];
|
|
623
|
-
};
|
|
624
|
-
convert.lab.xyz = function(lab) {
|
|
625
|
-
const l = lab[0];
|
|
626
|
-
const a = lab[1];
|
|
627
|
-
const b = lab[2];
|
|
628
|
-
let x;
|
|
629
|
-
let y;
|
|
630
|
-
let z;
|
|
631
|
-
y = (l + 16) / 116;
|
|
632
|
-
x = a / 500 + y;
|
|
633
|
-
z = y - b / 200;
|
|
634
|
-
const y2 = y ** 3;
|
|
635
|
-
const x2 = x ** 3;
|
|
636
|
-
const z2 = z ** 3;
|
|
637
|
-
y = y2 > 8856e-6 ? y2 : (y - 16 / 116) / 7.787;
|
|
638
|
-
x = x2 > 8856e-6 ? x2 : (x - 16 / 116) / 7.787;
|
|
639
|
-
z = z2 > 8856e-6 ? z2 : (z - 16 / 116) / 7.787;
|
|
640
|
-
x *= 95.047;
|
|
641
|
-
y *= 100;
|
|
642
|
-
z *= 108.883;
|
|
643
|
-
return [x, y, z];
|
|
644
|
-
};
|
|
645
|
-
convert.lab.lch = function(lab) {
|
|
646
|
-
const l = lab[0];
|
|
647
|
-
const a = lab[1];
|
|
648
|
-
const b = lab[2];
|
|
649
|
-
let h;
|
|
650
|
-
const hr = Math.atan2(b, a);
|
|
651
|
-
h = hr * 360 / 2 / Math.PI;
|
|
652
|
-
if (h < 0) {
|
|
653
|
-
h += 360;
|
|
654
|
-
}
|
|
655
|
-
const c = Math.sqrt(a * a + b * b);
|
|
656
|
-
return [l, c, h];
|
|
657
|
-
};
|
|
658
|
-
convert.lch.lab = function(lch) {
|
|
659
|
-
const l = lch[0];
|
|
660
|
-
const c = lch[1];
|
|
661
|
-
const h = lch[2];
|
|
662
|
-
const hr = h / 360 * 2 * Math.PI;
|
|
663
|
-
const a = c * Math.cos(hr);
|
|
664
|
-
const b = c * Math.sin(hr);
|
|
665
|
-
return [l, a, b];
|
|
666
|
-
};
|
|
667
|
-
convert.rgb.ansi16 = function(args, saturation = null) {
|
|
668
|
-
const [r, g, b] = args;
|
|
669
|
-
let value = saturation === null ? convert.rgb.hsv(args)[2] : saturation;
|
|
670
|
-
value = Math.round(value / 50);
|
|
671
|
-
if (value === 0) {
|
|
672
|
-
return 30;
|
|
673
|
-
}
|
|
674
|
-
let ansi = 30 + (Math.round(b / 255) << 2 | Math.round(g / 255) << 1 | Math.round(r / 255));
|
|
675
|
-
if (value === 2) {
|
|
676
|
-
ansi += 60;
|
|
677
|
-
}
|
|
678
|
-
return ansi;
|
|
679
|
-
};
|
|
680
|
-
convert.hsv.ansi16 = function(args) {
|
|
681
|
-
return convert.rgb.ansi16(convert.hsv.rgb(args), args[2]);
|
|
682
|
-
};
|
|
683
|
-
convert.rgb.ansi256 = function(args) {
|
|
684
|
-
const r = args[0];
|
|
685
|
-
const g = args[1];
|
|
686
|
-
const b = args[2];
|
|
687
|
-
if (r === g && g === b) {
|
|
688
|
-
if (r < 8) {
|
|
689
|
-
return 16;
|
|
690
|
-
}
|
|
691
|
-
if (r > 248) {
|
|
692
|
-
return 231;
|
|
693
|
-
}
|
|
694
|
-
return Math.round((r - 8) / 247 * 24) + 232;
|
|
695
|
-
}
|
|
696
|
-
const ansi = 16 + 36 * Math.round(r / 255 * 5) + 6 * Math.round(g / 255 * 5) + Math.round(b / 255 * 5);
|
|
697
|
-
return ansi;
|
|
698
|
-
};
|
|
699
|
-
convert.ansi16.rgb = function(args) {
|
|
700
|
-
let color = args % 10;
|
|
701
|
-
if (color === 0 || color === 7) {
|
|
702
|
-
if (args > 50) {
|
|
703
|
-
color += 3.5;
|
|
704
|
-
}
|
|
705
|
-
color = color / 10.5 * 255;
|
|
706
|
-
return [color, color, color];
|
|
707
|
-
}
|
|
708
|
-
const mult = (~~(args > 50) + 1) * 0.5;
|
|
709
|
-
const r = (color & 1) * mult * 255;
|
|
710
|
-
const g = (color >> 1 & 1) * mult * 255;
|
|
711
|
-
const b = (color >> 2 & 1) * mult * 255;
|
|
712
|
-
return [r, g, b];
|
|
713
|
-
};
|
|
714
|
-
convert.ansi256.rgb = function(args) {
|
|
715
|
-
if (args >= 232) {
|
|
716
|
-
const c = (args - 232) * 10 + 8;
|
|
717
|
-
return [c, c, c];
|
|
718
|
-
}
|
|
719
|
-
args -= 16;
|
|
720
|
-
let rem;
|
|
721
|
-
const r = Math.floor(args / 36) / 5 * 255;
|
|
722
|
-
const g = Math.floor((rem = args % 36) / 6) / 5 * 255;
|
|
723
|
-
const b = rem % 6 / 5 * 255;
|
|
724
|
-
return [r, g, b];
|
|
725
|
-
};
|
|
726
|
-
convert.rgb.hex = function(args) {
|
|
727
|
-
const integer = ((Math.round(args[0]) & 255) << 16) + ((Math.round(args[1]) & 255) << 8) + (Math.round(args[2]) & 255);
|
|
728
|
-
const string = integer.toString(16).toUpperCase();
|
|
729
|
-
return "000000".substring(string.length) + string;
|
|
730
|
-
};
|
|
731
|
-
convert.hex.rgb = function(args) {
|
|
732
|
-
const match = args.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);
|
|
733
|
-
if (!match) {
|
|
734
|
-
return [0, 0, 0];
|
|
735
|
-
}
|
|
736
|
-
let colorString = match[0];
|
|
737
|
-
if (match[0].length === 3) {
|
|
738
|
-
colorString = colorString.split("").map((char) => {
|
|
739
|
-
return char + char;
|
|
740
|
-
}).join("");
|
|
741
|
-
}
|
|
742
|
-
const integer = parseInt(colorString, 16);
|
|
743
|
-
const r = integer >> 16 & 255;
|
|
744
|
-
const g = integer >> 8 & 255;
|
|
745
|
-
const b = integer & 255;
|
|
746
|
-
return [r, g, b];
|
|
747
|
-
};
|
|
748
|
-
convert.rgb.hcg = function(rgb) {
|
|
749
|
-
const r = rgb[0] / 255;
|
|
750
|
-
const g = rgb[1] / 255;
|
|
751
|
-
const b = rgb[2] / 255;
|
|
752
|
-
const max = Math.max(Math.max(r, g), b);
|
|
753
|
-
const min = Math.min(Math.min(r, g), b);
|
|
754
|
-
const chroma = max - min;
|
|
755
|
-
let grayscale;
|
|
756
|
-
let hue;
|
|
757
|
-
if (chroma < 1) {
|
|
758
|
-
grayscale = min / (1 - chroma);
|
|
759
|
-
} else {
|
|
760
|
-
grayscale = 0;
|
|
761
|
-
}
|
|
762
|
-
if (chroma <= 0) {
|
|
763
|
-
hue = 0;
|
|
764
|
-
} else if (max === r) {
|
|
765
|
-
hue = (g - b) / chroma % 6;
|
|
766
|
-
} else if (max === g) {
|
|
767
|
-
hue = 2 + (b - r) / chroma;
|
|
768
|
-
} else {
|
|
769
|
-
hue = 4 + (r - g) / chroma;
|
|
770
|
-
}
|
|
771
|
-
hue /= 6;
|
|
772
|
-
hue %= 1;
|
|
773
|
-
return [hue * 360, chroma * 100, grayscale * 100];
|
|
774
|
-
};
|
|
775
|
-
convert.hsl.hcg = function(hsl) {
|
|
776
|
-
const s = hsl[1] / 100;
|
|
777
|
-
const l = hsl[2] / 100;
|
|
778
|
-
const c = l < 0.5 ? 2 * s * l : 2 * s * (1 - l);
|
|
779
|
-
let f = 0;
|
|
780
|
-
if (c < 1) {
|
|
781
|
-
f = (l - 0.5 * c) / (1 - c);
|
|
782
|
-
}
|
|
783
|
-
return [hsl[0], c * 100, f * 100];
|
|
784
|
-
};
|
|
785
|
-
convert.hsv.hcg = function(hsv) {
|
|
786
|
-
const s = hsv[1] / 100;
|
|
787
|
-
const v = hsv[2] / 100;
|
|
788
|
-
const c = s * v;
|
|
789
|
-
let f = 0;
|
|
790
|
-
if (c < 1) {
|
|
791
|
-
f = (v - c) / (1 - c);
|
|
792
|
-
}
|
|
793
|
-
return [hsv[0], c * 100, f * 100];
|
|
794
|
-
};
|
|
795
|
-
convert.hcg.rgb = function(hcg) {
|
|
796
|
-
const h = hcg[0] / 360;
|
|
797
|
-
const c = hcg[1] / 100;
|
|
798
|
-
const g = hcg[2] / 100;
|
|
799
|
-
if (c === 0) {
|
|
800
|
-
return [g * 255, g * 255, g * 255];
|
|
801
|
-
}
|
|
802
|
-
const pure = [0, 0, 0];
|
|
803
|
-
const hi = h % 1 * 6;
|
|
804
|
-
const v = hi % 1;
|
|
805
|
-
const w = 1 - v;
|
|
806
|
-
let mg = 0;
|
|
807
|
-
switch (Math.floor(hi)) {
|
|
808
|
-
case 0:
|
|
809
|
-
pure[0] = 1;
|
|
810
|
-
pure[1] = v;
|
|
811
|
-
pure[2] = 0;
|
|
812
|
-
break;
|
|
813
|
-
case 1:
|
|
814
|
-
pure[0] = w;
|
|
815
|
-
pure[1] = 1;
|
|
816
|
-
pure[2] = 0;
|
|
817
|
-
break;
|
|
818
|
-
case 2:
|
|
819
|
-
pure[0] = 0;
|
|
820
|
-
pure[1] = 1;
|
|
821
|
-
pure[2] = v;
|
|
822
|
-
break;
|
|
823
|
-
case 3:
|
|
824
|
-
pure[0] = 0;
|
|
825
|
-
pure[1] = w;
|
|
826
|
-
pure[2] = 1;
|
|
827
|
-
break;
|
|
828
|
-
case 4:
|
|
829
|
-
pure[0] = v;
|
|
830
|
-
pure[1] = 0;
|
|
831
|
-
pure[2] = 1;
|
|
832
|
-
break;
|
|
833
|
-
default:
|
|
834
|
-
pure[0] = 1;
|
|
835
|
-
pure[1] = 0;
|
|
836
|
-
pure[2] = w;
|
|
837
|
-
}
|
|
838
|
-
mg = (1 - c) * g;
|
|
839
|
-
return [
|
|
840
|
-
(c * pure[0] + mg) * 255,
|
|
841
|
-
(c * pure[1] + mg) * 255,
|
|
842
|
-
(c * pure[2] + mg) * 255
|
|
843
|
-
];
|
|
844
|
-
};
|
|
845
|
-
convert.hcg.hsv = function(hcg) {
|
|
846
|
-
const c = hcg[1] / 100;
|
|
847
|
-
const g = hcg[2] / 100;
|
|
848
|
-
const v = c + g * (1 - c);
|
|
849
|
-
let f = 0;
|
|
850
|
-
if (v > 0) {
|
|
851
|
-
f = c / v;
|
|
852
|
-
}
|
|
853
|
-
return [hcg[0], f * 100, v * 100];
|
|
854
|
-
};
|
|
855
|
-
convert.hcg.hsl = function(hcg) {
|
|
856
|
-
const c = hcg[1] / 100;
|
|
857
|
-
const g = hcg[2] / 100;
|
|
858
|
-
const l = g * (1 - c) + 0.5 * c;
|
|
859
|
-
let s = 0;
|
|
860
|
-
if (l > 0 && l < 0.5) {
|
|
861
|
-
s = c / (2 * l);
|
|
862
|
-
} else if (l >= 0.5 && l < 1) {
|
|
863
|
-
s = c / (2 * (1 - l));
|
|
864
|
-
}
|
|
865
|
-
return [hcg[0], s * 100, l * 100];
|
|
866
|
-
};
|
|
867
|
-
convert.hcg.hwb = function(hcg) {
|
|
868
|
-
const c = hcg[1] / 100;
|
|
869
|
-
const g = hcg[2] / 100;
|
|
870
|
-
const v = c + g * (1 - c);
|
|
871
|
-
return [hcg[0], (v - c) * 100, (1 - v) * 100];
|
|
872
|
-
};
|
|
873
|
-
convert.hwb.hcg = function(hwb) {
|
|
874
|
-
const w = hwb[1] / 100;
|
|
875
|
-
const b = hwb[2] / 100;
|
|
876
|
-
const v = 1 - b;
|
|
877
|
-
const c = v - w;
|
|
878
|
-
let g = 0;
|
|
879
|
-
if (c < 1) {
|
|
880
|
-
g = (v - c) / (1 - c);
|
|
881
|
-
}
|
|
882
|
-
return [hwb[0], c * 100, g * 100];
|
|
883
|
-
};
|
|
884
|
-
convert.apple.rgb = function(apple) {
|
|
885
|
-
return [apple[0] / 65535 * 255, apple[1] / 65535 * 255, apple[2] / 65535 * 255];
|
|
886
|
-
};
|
|
887
|
-
convert.rgb.apple = function(rgb) {
|
|
888
|
-
return [rgb[0] / 255 * 65535, rgb[1] / 255 * 65535, rgb[2] / 255 * 65535];
|
|
889
|
-
};
|
|
890
|
-
convert.gray.rgb = function(args) {
|
|
891
|
-
return [args[0] / 100 * 255, args[0] / 100 * 255, args[0] / 100 * 255];
|
|
892
|
-
};
|
|
893
|
-
convert.gray.hsl = function(args) {
|
|
894
|
-
return [0, 0, args[0]];
|
|
895
|
-
};
|
|
896
|
-
convert.gray.hsv = convert.gray.hsl;
|
|
897
|
-
convert.gray.hwb = function(gray) {
|
|
898
|
-
return [0, 100, gray[0]];
|
|
899
|
-
};
|
|
900
|
-
convert.gray.cmyk = function(gray) {
|
|
901
|
-
return [0, 0, 0, gray[0]];
|
|
902
|
-
};
|
|
903
|
-
convert.gray.lab = function(gray) {
|
|
904
|
-
return [gray[0], 0, 0];
|
|
905
|
-
};
|
|
906
|
-
convert.gray.hex = function(gray) {
|
|
907
|
-
const val = Math.round(gray[0] / 100 * 255) & 255;
|
|
908
|
-
const integer = (val << 16) + (val << 8) + val;
|
|
909
|
-
const string = integer.toString(16).toUpperCase();
|
|
910
|
-
return "000000".substring(string.length) + string;
|
|
911
|
-
};
|
|
912
|
-
convert.rgb.gray = function(rgb) {
|
|
913
|
-
const val = (rgb[0] + rgb[1] + rgb[2]) / 3;
|
|
914
|
-
return [val / 255 * 100];
|
|
915
|
-
};
|
|
916
|
-
return conversions;
|
|
917
|
-
}
|
|
918
|
-
var route;
|
|
919
|
-
var hasRequiredRoute;
|
|
920
|
-
function requireRoute() {
|
|
921
|
-
if (hasRequiredRoute)
|
|
922
|
-
return route;
|
|
923
|
-
hasRequiredRoute = 1;
|
|
924
|
-
const conversions2 = requireConversions();
|
|
925
|
-
function buildGraph() {
|
|
926
|
-
const graph = {};
|
|
927
|
-
const models = Object.keys(conversions2);
|
|
928
|
-
for (let len = models.length, i = 0; i < len; i++) {
|
|
929
|
-
graph[models[i]] = {
|
|
930
|
-
// http://jsperf.com/1-vs-infinity
|
|
931
|
-
// micro-opt, but this is simple.
|
|
932
|
-
distance: -1,
|
|
933
|
-
parent: null
|
|
934
|
-
};
|
|
935
|
-
}
|
|
936
|
-
return graph;
|
|
937
|
-
}
|
|
938
|
-
function deriveBFS(fromModel) {
|
|
939
|
-
const graph = buildGraph();
|
|
940
|
-
const queue = [fromModel];
|
|
941
|
-
graph[fromModel].distance = 0;
|
|
942
|
-
while (queue.length) {
|
|
943
|
-
const current = queue.pop();
|
|
944
|
-
const adjacents = Object.keys(conversions2[current]);
|
|
945
|
-
for (let len = adjacents.length, i = 0; i < len; i++) {
|
|
946
|
-
const adjacent = adjacents[i];
|
|
947
|
-
const node = graph[adjacent];
|
|
948
|
-
if (node.distance === -1) {
|
|
949
|
-
node.distance = graph[current].distance + 1;
|
|
950
|
-
node.parent = current;
|
|
951
|
-
queue.unshift(adjacent);
|
|
952
|
-
}
|
|
953
|
-
}
|
|
954
|
-
}
|
|
955
|
-
return graph;
|
|
956
|
-
}
|
|
957
|
-
function link(from, to) {
|
|
958
|
-
return function(args) {
|
|
959
|
-
return to(from(args));
|
|
960
|
-
};
|
|
961
|
-
}
|
|
962
|
-
function wrapConversion(toModel, graph) {
|
|
963
|
-
const path = [graph[toModel].parent, toModel];
|
|
964
|
-
let fn = conversions2[graph[toModel].parent][toModel];
|
|
965
|
-
let cur = graph[toModel].parent;
|
|
966
|
-
while (graph[cur].parent) {
|
|
967
|
-
path.unshift(graph[cur].parent);
|
|
968
|
-
fn = link(conversions2[graph[cur].parent][cur], fn);
|
|
969
|
-
cur = graph[cur].parent;
|
|
970
|
-
}
|
|
971
|
-
fn.conversion = path;
|
|
972
|
-
return fn;
|
|
973
|
-
}
|
|
974
|
-
route = function(fromModel) {
|
|
975
|
-
const graph = deriveBFS(fromModel);
|
|
976
|
-
const conversion = {};
|
|
977
|
-
const models = Object.keys(graph);
|
|
978
|
-
for (let len = models.length, i = 0; i < len; i++) {
|
|
979
|
-
const toModel = models[i];
|
|
980
|
-
const node = graph[toModel];
|
|
981
|
-
if (node.parent === null) {
|
|
982
|
-
continue;
|
|
983
|
-
}
|
|
984
|
-
conversion[toModel] = wrapConversion(toModel, graph);
|
|
985
|
-
}
|
|
986
|
-
return conversion;
|
|
987
|
-
};
|
|
988
|
-
return route;
|
|
989
|
-
}
|
|
990
|
-
var colorConvert;
|
|
991
|
-
var hasRequiredColorConvert;
|
|
992
|
-
function requireColorConvert() {
|
|
993
|
-
if (hasRequiredColorConvert)
|
|
994
|
-
return colorConvert;
|
|
995
|
-
hasRequiredColorConvert = 1;
|
|
996
|
-
const conversions2 = requireConversions();
|
|
997
|
-
const route2 = requireRoute();
|
|
998
|
-
const convert = {};
|
|
999
|
-
const models = Object.keys(conversions2);
|
|
1000
|
-
function wrapRaw(fn) {
|
|
1001
|
-
const wrappedFn = function(...args) {
|
|
1002
|
-
const arg0 = args[0];
|
|
1003
|
-
if (arg0 === void 0 || arg0 === null) {
|
|
1004
|
-
return arg0;
|
|
1005
|
-
}
|
|
1006
|
-
if (arg0.length > 1) {
|
|
1007
|
-
args = arg0;
|
|
1008
|
-
}
|
|
1009
|
-
return fn(args);
|
|
1010
|
-
};
|
|
1011
|
-
if ("conversion" in fn) {
|
|
1012
|
-
wrappedFn.conversion = fn.conversion;
|
|
1013
|
-
}
|
|
1014
|
-
return wrappedFn;
|
|
1015
|
-
}
|
|
1016
|
-
function wrapRounded(fn) {
|
|
1017
|
-
const wrappedFn = function(...args) {
|
|
1018
|
-
const arg0 = args[0];
|
|
1019
|
-
if (arg0 === void 0 || arg0 === null) {
|
|
1020
|
-
return arg0;
|
|
1021
|
-
}
|
|
1022
|
-
if (arg0.length > 1) {
|
|
1023
|
-
args = arg0;
|
|
1024
|
-
}
|
|
1025
|
-
const result = fn(args);
|
|
1026
|
-
if (typeof result === "object") {
|
|
1027
|
-
for (let len = result.length, i = 0; i < len; i++) {
|
|
1028
|
-
result[i] = Math.round(result[i]);
|
|
1029
|
-
}
|
|
1030
|
-
}
|
|
1031
|
-
return result;
|
|
1032
|
-
};
|
|
1033
|
-
if ("conversion" in fn) {
|
|
1034
|
-
wrappedFn.conversion = fn.conversion;
|
|
1035
|
-
}
|
|
1036
|
-
return wrappedFn;
|
|
1037
|
-
}
|
|
1038
|
-
models.forEach((fromModel) => {
|
|
1039
|
-
convert[fromModel] = {};
|
|
1040
|
-
Object.defineProperty(convert[fromModel], "channels", { value: conversions2[fromModel].channels });
|
|
1041
|
-
Object.defineProperty(convert[fromModel], "labels", { value: conversions2[fromModel].labels });
|
|
1042
|
-
const routes = route2(fromModel);
|
|
1043
|
-
const routeModels = Object.keys(routes);
|
|
1044
|
-
routeModels.forEach((toModel) => {
|
|
1045
|
-
const fn = routes[toModel];
|
|
1046
|
-
convert[fromModel][toModel] = wrapRounded(fn);
|
|
1047
|
-
convert[fromModel][toModel].raw = wrapRaw(fn);
|
|
1048
|
-
});
|
|
1049
|
-
});
|
|
1050
|
-
colorConvert = convert;
|
|
1051
|
-
return colorConvert;
|
|
1052
|
-
}
|
|
1053
|
-
ansiStyles$1.exports;
|
|
1054
|
-
(function(module2) {
|
|
1055
|
-
const wrapAnsi16 = (fn, offset) => (...args) => {
|
|
1056
|
-
const code = fn(...args);
|
|
1057
|
-
return `\x1B[${code + offset}m`;
|
|
1058
|
-
};
|
|
1059
|
-
const wrapAnsi256 = (fn, offset) => (...args) => {
|
|
1060
|
-
const code = fn(...args);
|
|
1061
|
-
return `\x1B[${38 + offset};5;${code}m`;
|
|
1062
|
-
};
|
|
1063
|
-
const wrapAnsi16m = (fn, offset) => (...args) => {
|
|
1064
|
-
const rgb = fn(...args);
|
|
1065
|
-
return `\x1B[${38 + offset};2;${rgb[0]};${rgb[1]};${rgb[2]}m`;
|
|
1066
|
-
};
|
|
1067
|
-
const ansi2ansi = (n) => n;
|
|
1068
|
-
const rgb2rgb = (r, g, b) => [r, g, b];
|
|
1069
|
-
const setLazyProperty = (object, property, get) => {
|
|
1070
|
-
Object.defineProperty(object, property, {
|
|
1071
|
-
get: () => {
|
|
1072
|
-
const value = get();
|
|
1073
|
-
Object.defineProperty(object, property, {
|
|
1074
|
-
value,
|
|
1075
|
-
enumerable: true,
|
|
1076
|
-
configurable: true
|
|
1077
|
-
});
|
|
1078
|
-
return value;
|
|
1079
|
-
},
|
|
1080
|
-
enumerable: true,
|
|
1081
|
-
configurable: true
|
|
1082
|
-
});
|
|
1083
|
-
};
|
|
1084
|
-
let colorConvert2;
|
|
1085
|
-
const makeDynamicStyles = (wrap, targetSpace, identity, isBackground) => {
|
|
1086
|
-
if (colorConvert2 === void 0) {
|
|
1087
|
-
colorConvert2 = requireColorConvert();
|
|
1088
|
-
}
|
|
1089
|
-
const offset = isBackground ? 10 : 0;
|
|
1090
|
-
const styles2 = {};
|
|
1091
|
-
for (const [sourceSpace, suite] of Object.entries(colorConvert2)) {
|
|
1092
|
-
const name = sourceSpace === "ansi16" ? "ansi" : sourceSpace;
|
|
1093
|
-
if (sourceSpace === targetSpace) {
|
|
1094
|
-
styles2[name] = wrap(identity, offset);
|
|
1095
|
-
} else if (typeof suite === "object") {
|
|
1096
|
-
styles2[name] = wrap(suite[targetSpace], offset);
|
|
1097
|
-
}
|
|
1098
|
-
}
|
|
1099
|
-
return styles2;
|
|
1100
|
-
};
|
|
1101
|
-
function assembleStyles() {
|
|
1102
|
-
const codes = /* @__PURE__ */ new Map();
|
|
1103
|
-
const styles2 = {
|
|
1104
|
-
modifier: {
|
|
1105
|
-
reset: [0, 0],
|
|
1106
|
-
// 21 isn't widely supported and 22 does the same thing
|
|
1107
|
-
bold: [1, 22],
|
|
1108
|
-
dim: [2, 22],
|
|
1109
|
-
italic: [3, 23],
|
|
1110
|
-
underline: [4, 24],
|
|
1111
|
-
inverse: [7, 27],
|
|
1112
|
-
hidden: [8, 28],
|
|
1113
|
-
strikethrough: [9, 29]
|
|
1114
|
-
},
|
|
1115
|
-
color: {
|
|
1116
|
-
black: [30, 39],
|
|
1117
|
-
red: [31, 39],
|
|
1118
|
-
green: [32, 39],
|
|
1119
|
-
yellow: [33, 39],
|
|
1120
|
-
blue: [34, 39],
|
|
1121
|
-
magenta: [35, 39],
|
|
1122
|
-
cyan: [36, 39],
|
|
1123
|
-
white: [37, 39],
|
|
1124
|
-
// Bright color
|
|
1125
|
-
blackBright: [90, 39],
|
|
1126
|
-
redBright: [91, 39],
|
|
1127
|
-
greenBright: [92, 39],
|
|
1128
|
-
yellowBright: [93, 39],
|
|
1129
|
-
blueBright: [94, 39],
|
|
1130
|
-
magentaBright: [95, 39],
|
|
1131
|
-
cyanBright: [96, 39],
|
|
1132
|
-
whiteBright: [97, 39]
|
|
1133
|
-
},
|
|
1134
|
-
bgColor: {
|
|
1135
|
-
bgBlack: [40, 49],
|
|
1136
|
-
bgRed: [41, 49],
|
|
1137
|
-
bgGreen: [42, 49],
|
|
1138
|
-
bgYellow: [43, 49],
|
|
1139
|
-
bgBlue: [44, 49],
|
|
1140
|
-
bgMagenta: [45, 49],
|
|
1141
|
-
bgCyan: [46, 49],
|
|
1142
|
-
bgWhite: [47, 49],
|
|
1143
|
-
// Bright color
|
|
1144
|
-
bgBlackBright: [100, 49],
|
|
1145
|
-
bgRedBright: [101, 49],
|
|
1146
|
-
bgGreenBright: [102, 49],
|
|
1147
|
-
bgYellowBright: [103, 49],
|
|
1148
|
-
bgBlueBright: [104, 49],
|
|
1149
|
-
bgMagentaBright: [105, 49],
|
|
1150
|
-
bgCyanBright: [106, 49],
|
|
1151
|
-
bgWhiteBright: [107, 49]
|
|
1152
|
-
}
|
|
1153
|
-
};
|
|
1154
|
-
styles2.color.gray = styles2.color.blackBright;
|
|
1155
|
-
styles2.bgColor.bgGray = styles2.bgColor.bgBlackBright;
|
|
1156
|
-
styles2.color.grey = styles2.color.blackBright;
|
|
1157
|
-
styles2.bgColor.bgGrey = styles2.bgColor.bgBlackBright;
|
|
1158
|
-
for (const [groupName, group] of Object.entries(styles2)) {
|
|
1159
|
-
for (const [styleName, style] of Object.entries(group)) {
|
|
1160
|
-
styles2[styleName] = {
|
|
1161
|
-
open: `\x1B[${style[0]}m`,
|
|
1162
|
-
close: `\x1B[${style[1]}m`
|
|
1163
|
-
};
|
|
1164
|
-
group[styleName] = styles2[styleName];
|
|
1165
|
-
codes.set(style[0], style[1]);
|
|
1166
|
-
}
|
|
1167
|
-
Object.defineProperty(styles2, groupName, {
|
|
1168
|
-
value: group,
|
|
1169
|
-
enumerable: false
|
|
1170
|
-
});
|
|
1171
|
-
}
|
|
1172
|
-
Object.defineProperty(styles2, "codes", {
|
|
1173
|
-
value: codes,
|
|
1174
|
-
enumerable: false
|
|
1175
|
-
});
|
|
1176
|
-
styles2.color.close = "\x1B[39m";
|
|
1177
|
-
styles2.bgColor.close = "\x1B[49m";
|
|
1178
|
-
setLazyProperty(styles2.color, "ansi", () => makeDynamicStyles(wrapAnsi16, "ansi16", ansi2ansi, false));
|
|
1179
|
-
setLazyProperty(styles2.color, "ansi256", () => makeDynamicStyles(wrapAnsi256, "ansi256", ansi2ansi, false));
|
|
1180
|
-
setLazyProperty(styles2.color, "ansi16m", () => makeDynamicStyles(wrapAnsi16m, "rgb", rgb2rgb, false));
|
|
1181
|
-
setLazyProperty(styles2.bgColor, "ansi", () => makeDynamicStyles(wrapAnsi16, "ansi16", ansi2ansi, true));
|
|
1182
|
-
setLazyProperty(styles2.bgColor, "ansi256", () => makeDynamicStyles(wrapAnsi256, "ansi256", ansi2ansi, true));
|
|
1183
|
-
setLazyProperty(styles2.bgColor, "ansi16m", () => makeDynamicStyles(wrapAnsi16m, "rgb", rgb2rgb, true));
|
|
1184
|
-
return styles2;
|
|
1185
|
-
}
|
|
1186
|
-
Object.defineProperty(module2, "exports", {
|
|
1187
|
-
enumerable: true,
|
|
1188
|
-
get: assembleStyles
|
|
1189
|
-
});
|
|
1190
|
-
})(ansiStyles$1);
|
|
1191
|
-
var ansiStylesExports = ansiStyles$1.exports;
|
|
1192
|
-
var browser = {
|
|
1193
|
-
stdout: false,
|
|
1194
|
-
stderr: false
|
|
1195
|
-
};
|
|
1196
|
-
const stringReplaceAll$1 = (string, substring, replacer) => {
|
|
1197
|
-
let index = string.indexOf(substring);
|
|
1198
|
-
if (index === -1) {
|
|
1199
|
-
return string;
|
|
1200
|
-
}
|
|
1201
|
-
const substringLength = substring.length;
|
|
1202
|
-
let endIndex = 0;
|
|
1203
|
-
let returnValue = "";
|
|
1204
|
-
do {
|
|
1205
|
-
returnValue += string.substr(endIndex, index - endIndex) + substring + replacer;
|
|
1206
|
-
endIndex = index + substringLength;
|
|
1207
|
-
index = string.indexOf(substring, endIndex);
|
|
1208
|
-
} while (index !== -1);
|
|
1209
|
-
returnValue += string.substr(endIndex);
|
|
1210
|
-
return returnValue;
|
|
1211
|
-
};
|
|
1212
|
-
const stringEncaseCRLFWithFirstIndex$1 = (string, prefix, postfix, index) => {
|
|
1213
|
-
let endIndex = 0;
|
|
1214
|
-
let returnValue = "";
|
|
1215
|
-
do {
|
|
1216
|
-
const gotCR = string[index - 1] === "\r";
|
|
1217
|
-
returnValue += string.substr(endIndex, (gotCR ? index - 1 : index) - endIndex) + prefix + (gotCR ? "\r\n" : "\n") + postfix;
|
|
1218
|
-
endIndex = index + 1;
|
|
1219
|
-
index = string.indexOf("\n", endIndex);
|
|
1220
|
-
} while (index !== -1);
|
|
1221
|
-
returnValue += string.substr(endIndex);
|
|
1222
|
-
return returnValue;
|
|
1223
|
-
};
|
|
1224
|
-
var util = {
|
|
1225
|
-
stringReplaceAll: stringReplaceAll$1,
|
|
1226
|
-
stringEncaseCRLFWithFirstIndex: stringEncaseCRLFWithFirstIndex$1
|
|
1227
|
-
};
|
|
1228
|
-
var templates;
|
|
1229
|
-
var hasRequiredTemplates;
|
|
1230
|
-
function requireTemplates() {
|
|
1231
|
-
if (hasRequiredTemplates)
|
|
1232
|
-
return templates;
|
|
1233
|
-
hasRequiredTemplates = 1;
|
|
1234
|
-
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;
|
|
1235
|
-
const STYLE_REGEX = /(?:^|\.)(\w+)(?:\(([^)]*)\))?/g;
|
|
1236
|
-
const STRING_REGEX = /^(['"])((?:\\.|(?!\1)[^\\])*)\1$/;
|
|
1237
|
-
const ESCAPE_REGEX = /\\(u(?:[a-f\d]{4}|{[a-f\d]{1,6}})|x[a-f\d]{2}|.)|([^\\])/gi;
|
|
1238
|
-
const ESCAPES = /* @__PURE__ */ new Map([
|
|
1239
|
-
["n", "\n"],
|
|
1240
|
-
["r", "\r"],
|
|
1241
|
-
["t", " "],
|
|
1242
|
-
["b", "\b"],
|
|
1243
|
-
["f", "\f"],
|
|
1244
|
-
["v", "\v"],
|
|
1245
|
-
["0", "\0"],
|
|
1246
|
-
["\\", "\\"],
|
|
1247
|
-
["e", "\x1B"],
|
|
1248
|
-
["a", "\x07"]
|
|
1249
|
-
]);
|
|
1250
|
-
function unescape2(c) {
|
|
1251
|
-
const u = c[0] === "u";
|
|
1252
|
-
const bracket = c[1] === "{";
|
|
1253
|
-
if (u && !bracket && c.length === 5 || c[0] === "x" && c.length === 3) {
|
|
1254
|
-
return String.fromCharCode(parseInt(c.slice(1), 16));
|
|
1255
|
-
}
|
|
1256
|
-
if (u && bracket) {
|
|
1257
|
-
return String.fromCodePoint(parseInt(c.slice(2, -1), 16));
|
|
1258
|
-
}
|
|
1259
|
-
return ESCAPES.get(c) || c;
|
|
1260
|
-
}
|
|
1261
|
-
function parseArguments(name, arguments_) {
|
|
1262
|
-
const results = [];
|
|
1263
|
-
const chunks = arguments_.trim().split(/\s*,\s*/g);
|
|
1264
|
-
let matches;
|
|
1265
|
-
for (const chunk of chunks) {
|
|
1266
|
-
const number = Number(chunk);
|
|
1267
|
-
if (!Number.isNaN(number)) {
|
|
1268
|
-
results.push(number);
|
|
1269
|
-
} else if (matches = chunk.match(STRING_REGEX)) {
|
|
1270
|
-
results.push(matches[2].replace(ESCAPE_REGEX, (m, escape2, character) => escape2 ? unescape2(escape2) : character));
|
|
1271
|
-
} else {
|
|
1272
|
-
throw new Error(`Invalid Chalk template style argument: ${chunk} (in style '${name}')`);
|
|
1273
|
-
}
|
|
1274
|
-
}
|
|
1275
|
-
return results;
|
|
1276
|
-
}
|
|
1277
|
-
function parseStyle(style) {
|
|
1278
|
-
STYLE_REGEX.lastIndex = 0;
|
|
1279
|
-
const results = [];
|
|
1280
|
-
let matches;
|
|
1281
|
-
while ((matches = STYLE_REGEX.exec(style)) !== null) {
|
|
1282
|
-
const name = matches[1];
|
|
1283
|
-
if (matches[2]) {
|
|
1284
|
-
const args = parseArguments(name, matches[2]);
|
|
1285
|
-
results.push([name].concat(args));
|
|
1286
|
-
} else {
|
|
1287
|
-
results.push([name]);
|
|
1288
|
-
}
|
|
1289
|
-
}
|
|
1290
|
-
return results;
|
|
1291
|
-
}
|
|
1292
|
-
function buildStyle(chalk2, styles2) {
|
|
1293
|
-
const enabled = {};
|
|
1294
|
-
for (const layer of styles2) {
|
|
1295
|
-
for (const style of layer.styles) {
|
|
1296
|
-
enabled[style[0]] = layer.inverse ? null : style.slice(1);
|
|
1297
|
-
}
|
|
1298
|
-
}
|
|
1299
|
-
let current = chalk2;
|
|
1300
|
-
for (const [styleName, styles3] of Object.entries(enabled)) {
|
|
1301
|
-
if (!Array.isArray(styles3)) {
|
|
1302
|
-
continue;
|
|
1303
|
-
}
|
|
1304
|
-
if (!(styleName in current)) {
|
|
1305
|
-
throw new Error(`Unknown Chalk style: ${styleName}`);
|
|
1306
|
-
}
|
|
1307
|
-
current = styles3.length > 0 ? current[styleName](...styles3) : current[styleName];
|
|
1308
|
-
}
|
|
1309
|
-
return current;
|
|
1310
|
-
}
|
|
1311
|
-
templates = (chalk2, temporary) => {
|
|
1312
|
-
const styles2 = [];
|
|
1313
|
-
const chunks = [];
|
|
1314
|
-
let chunk = [];
|
|
1315
|
-
temporary.replace(TEMPLATE_REGEX, (m, escapeCharacter, inverse, style, close, character) => {
|
|
1316
|
-
if (escapeCharacter) {
|
|
1317
|
-
chunk.push(unescape2(escapeCharacter));
|
|
1318
|
-
} else if (style) {
|
|
1319
|
-
const string = chunk.join("");
|
|
1320
|
-
chunk = [];
|
|
1321
|
-
chunks.push(styles2.length === 0 ? string : buildStyle(chalk2, styles2)(string));
|
|
1322
|
-
styles2.push({ inverse, styles: parseStyle(style) });
|
|
1323
|
-
} else if (close) {
|
|
1324
|
-
if (styles2.length === 0) {
|
|
1325
|
-
throw new Error("Found extraneous } in Chalk template literal");
|
|
1326
|
-
}
|
|
1327
|
-
chunks.push(buildStyle(chalk2, styles2)(chunk.join("")));
|
|
1328
|
-
chunk = [];
|
|
1329
|
-
styles2.pop();
|
|
1330
|
-
} else {
|
|
1331
|
-
chunk.push(character);
|
|
1332
|
-
}
|
|
1333
|
-
});
|
|
1334
|
-
chunks.push(chunk.join(""));
|
|
1335
|
-
if (styles2.length > 0) {
|
|
1336
|
-
const errMessage = `Chalk template literal is missing ${styles2.length} closing bracket${styles2.length === 1 ? "" : "s"} (\`}\`)`;
|
|
1337
|
-
throw new Error(errMessage);
|
|
1338
|
-
}
|
|
1339
|
-
return chunks.join("");
|
|
1340
|
-
};
|
|
1341
|
-
return templates;
|
|
1342
|
-
}
|
|
1343
|
-
const ansiStyles = ansiStylesExports;
|
|
1344
|
-
const { stdout: stdoutColor, stderr: stderrColor } = browser;
|
|
1345
|
-
const {
|
|
1346
|
-
stringReplaceAll,
|
|
1347
|
-
stringEncaseCRLFWithFirstIndex
|
|
1348
|
-
} = util;
|
|
1349
|
-
const { isArray } = Array;
|
|
1350
|
-
const levelMapping = [
|
|
1351
|
-
"ansi",
|
|
1352
|
-
"ansi",
|
|
1353
|
-
"ansi256",
|
|
1354
|
-
"ansi16m"
|
|
1355
|
-
];
|
|
1356
|
-
const styles = /* @__PURE__ */ Object.create(null);
|
|
1357
|
-
const applyOptions = (object, options = {}) => {
|
|
1358
|
-
if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {
|
|
1359
|
-
throw new Error("The `level` option should be an integer from 0 to 3");
|
|
1360
|
-
}
|
|
1361
|
-
const colorLevel = stdoutColor ? stdoutColor.level : 0;
|
|
1362
|
-
object.level = options.level === void 0 ? colorLevel : options.level;
|
|
1363
|
-
};
|
|
1364
|
-
class ChalkClass {
|
|
1365
|
-
constructor(options) {
|
|
1366
|
-
return chalkFactory(options);
|
|
1367
|
-
}
|
|
1368
|
-
}
|
|
1369
|
-
const chalkFactory = (options) => {
|
|
1370
|
-
const chalk2 = {};
|
|
1371
|
-
applyOptions(chalk2, options);
|
|
1372
|
-
chalk2.template = (...arguments_) => chalkTag(chalk2.template, ...arguments_);
|
|
1373
|
-
Object.setPrototypeOf(chalk2, Chalk.prototype);
|
|
1374
|
-
Object.setPrototypeOf(chalk2.template, chalk2);
|
|
1375
|
-
chalk2.template.constructor = () => {
|
|
1376
|
-
throw new Error("`chalk.constructor()` is deprecated. Use `new chalk.Instance()` instead.");
|
|
1377
|
-
};
|
|
1378
|
-
chalk2.template.Instance = ChalkClass;
|
|
1379
|
-
return chalk2.template;
|
|
1380
|
-
};
|
|
1381
|
-
function Chalk(options) {
|
|
1382
|
-
return chalkFactory(options);
|
|
1383
|
-
}
|
|
1384
|
-
for (const [styleName, style] of Object.entries(ansiStyles)) {
|
|
1385
|
-
styles[styleName] = {
|
|
1386
|
-
get() {
|
|
1387
|
-
const builder = createBuilder(this, createStyler(style.open, style.close, this._styler), this._isEmpty);
|
|
1388
|
-
Object.defineProperty(this, styleName, { value: builder });
|
|
1389
|
-
return builder;
|
|
1390
|
-
}
|
|
1391
|
-
};
|
|
1392
|
-
}
|
|
1393
|
-
styles.visible = {
|
|
1394
|
-
get() {
|
|
1395
|
-
const builder = createBuilder(this, this._styler, true);
|
|
1396
|
-
Object.defineProperty(this, "visible", { value: builder });
|
|
1397
|
-
return builder;
|
|
1398
|
-
}
|
|
1399
|
-
};
|
|
1400
|
-
const usedModels = ["rgb", "hex", "keyword", "hsl", "hsv", "hwb", "ansi", "ansi256"];
|
|
1401
|
-
for (const model of usedModels) {
|
|
1402
|
-
styles[model] = {
|
|
1403
|
-
get() {
|
|
1404
|
-
const { level } = this;
|
|
1405
|
-
return function(...arguments_) {
|
|
1406
|
-
const styler = createStyler(ansiStyles.color[levelMapping[level]][model](...arguments_), ansiStyles.color.close, this._styler);
|
|
1407
|
-
return createBuilder(this, styler, this._isEmpty);
|
|
1408
|
-
};
|
|
1409
|
-
}
|
|
1410
|
-
};
|
|
1411
|
-
}
|
|
1412
|
-
for (const model of usedModels) {
|
|
1413
|
-
const bgModel = "bg" + model[0].toUpperCase() + model.slice(1);
|
|
1414
|
-
styles[bgModel] = {
|
|
1415
|
-
get() {
|
|
1416
|
-
const { level } = this;
|
|
1417
|
-
return function(...arguments_) {
|
|
1418
|
-
const styler = createStyler(ansiStyles.bgColor[levelMapping[level]][model](...arguments_), ansiStyles.bgColor.close, this._styler);
|
|
1419
|
-
return createBuilder(this, styler, this._isEmpty);
|
|
1420
|
-
};
|
|
1421
|
-
}
|
|
1422
|
-
};
|
|
1423
|
-
}
|
|
1424
|
-
const proto = Object.defineProperties(() => {
|
|
1425
|
-
}, {
|
|
1426
|
-
...styles,
|
|
1427
|
-
level: {
|
|
1428
|
-
enumerable: true,
|
|
1429
|
-
get() {
|
|
1430
|
-
return this._generator.level;
|
|
1431
|
-
},
|
|
1432
|
-
set(level) {
|
|
1433
|
-
this._generator.level = level;
|
|
1434
|
-
}
|
|
1435
|
-
}
|
|
1436
|
-
});
|
|
1437
|
-
const createStyler = (open, close, parent) => {
|
|
1438
|
-
let openAll;
|
|
1439
|
-
let closeAll;
|
|
1440
|
-
if (parent === void 0) {
|
|
1441
|
-
openAll = open;
|
|
1442
|
-
closeAll = close;
|
|
1443
|
-
} else {
|
|
1444
|
-
openAll = parent.openAll + open;
|
|
1445
|
-
closeAll = close + parent.closeAll;
|
|
1446
|
-
}
|
|
1447
|
-
return {
|
|
1448
|
-
open,
|
|
1449
|
-
close,
|
|
1450
|
-
openAll,
|
|
1451
|
-
closeAll,
|
|
1452
|
-
parent
|
|
1453
|
-
};
|
|
1454
|
-
};
|
|
1455
|
-
const createBuilder = (self2, _styler, _isEmpty) => {
|
|
1456
|
-
const builder = (...arguments_) => {
|
|
1457
|
-
if (isArray(arguments_[0]) && isArray(arguments_[0].raw)) {
|
|
1458
|
-
return applyStyle(builder, chalkTag(builder, ...arguments_));
|
|
1459
|
-
}
|
|
1460
|
-
return applyStyle(builder, arguments_.length === 1 ? "" + arguments_[0] : arguments_.join(" "));
|
|
1461
|
-
};
|
|
1462
|
-
Object.setPrototypeOf(builder, proto);
|
|
1463
|
-
builder._generator = self2;
|
|
1464
|
-
builder._styler = _styler;
|
|
1465
|
-
builder._isEmpty = _isEmpty;
|
|
1466
|
-
return builder;
|
|
1467
|
-
};
|
|
1468
|
-
const applyStyle = (self2, string) => {
|
|
1469
|
-
if (self2.level <= 0 || !string) {
|
|
1470
|
-
return self2._isEmpty ? "" : string;
|
|
1471
|
-
}
|
|
1472
|
-
let styler = self2._styler;
|
|
1473
|
-
if (styler === void 0) {
|
|
1474
|
-
return string;
|
|
1475
|
-
}
|
|
1476
|
-
const { openAll, closeAll } = styler;
|
|
1477
|
-
if (string.indexOf("\x1B") !== -1) {
|
|
1478
|
-
while (styler !== void 0) {
|
|
1479
|
-
string = stringReplaceAll(string, styler.close, styler.open);
|
|
1480
|
-
styler = styler.parent;
|
|
1481
|
-
}
|
|
1482
|
-
}
|
|
1483
|
-
const lfIndex = string.indexOf("\n");
|
|
1484
|
-
if (lfIndex !== -1) {
|
|
1485
|
-
string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex);
|
|
1486
|
-
}
|
|
1487
|
-
return openAll + string + closeAll;
|
|
1488
|
-
};
|
|
1489
|
-
let template;
|
|
1490
|
-
const chalkTag = (chalk2, ...strings) => {
|
|
1491
|
-
const [firstString] = strings;
|
|
1492
|
-
if (!isArray(firstString) || !isArray(firstString.raw)) {
|
|
1493
|
-
return strings.join(" ");
|
|
1494
|
-
}
|
|
1495
|
-
const arguments_ = strings.slice(1);
|
|
1496
|
-
const parts = [firstString.raw[0]];
|
|
1497
|
-
for (let i = 1; i < firstString.length; i++) {
|
|
1498
|
-
parts.push(
|
|
1499
|
-
String(arguments_[i - 1]).replace(/[{}\\]/g, "\\$&"),
|
|
1500
|
-
String(firstString.raw[i])
|
|
1501
|
-
);
|
|
1502
|
-
}
|
|
1503
|
-
if (template === void 0) {
|
|
1504
|
-
template = requireTemplates();
|
|
1505
|
-
}
|
|
1506
|
-
return template(chalk2, parts.join(""));
|
|
1507
|
-
};
|
|
1508
|
-
Object.defineProperties(Chalk.prototype, styles);
|
|
1509
|
-
const chalk = Chalk();
|
|
1510
|
-
chalk.supportsColor = stdoutColor;
|
|
1511
|
-
chalk.stderr = Chalk({ level: stderrColor ? stderrColor.level : 0 });
|
|
1512
|
-
chalk.stderr.supportsColor = stderrColor;
|
|
1513
|
-
var source = chalk;
|
|
1514
|
-
const chalk$1 = /* @__PURE__ */ getDefaultExportFromCjs(source);
|
|
1515
|
-
const isNode = Object.prototype.toString.call(typeof process !== "undefined" ? process : 0) === "[object process]";
|
|
1516
87
|
var sha256$1 = { exports: {} };
|
|
1517
88
|
function commonjsRequire(path) {
|
|
1518
89
|
throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
|
|
@@ -2693,9 +1264,9 @@ var __privateWrapper = (obj, member, setter, getter) => ({
|
|
|
2693
1264
|
}
|
|
2694
1265
|
const str = to.query;
|
|
2695
1266
|
if (str[stsutils.OAuth2ParameterType.CODE] || str[stsutils.OAuth2ParameterType.ERROR]) {
|
|
2696
|
-
debug$1(
|
|
1267
|
+
debug$1(`STSOAuth2Manager:#SetupRoute:Processing redirect: [${JSON.stringify(str)}]`.magenta);
|
|
2697
1268
|
const retVal = await oAuth2Manager.HandleRedirect(str);
|
|
2698
|
-
debug$1(
|
|
1269
|
+
debug$1(`STSOAuth2Manager:#SetupRoute:Redirect result: [${retVal}]`.magenta);
|
|
2699
1270
|
if (retVal) {
|
|
2700
1271
|
next({
|
|
2701
1272
|
path: "/",
|
|
@@ -2772,7 +1343,7 @@ var __privateWrapper = (obj, member, setter, getter) => ({
|
|
|
2772
1343
|
debug$1(`STSOAuth2Manager:RestoreSession:response: [${JSON.stringify(response.payload)}]`);
|
|
2773
1344
|
return response.payload;
|
|
2774
1345
|
} catch (error) {
|
|
2775
|
-
console.log(
|
|
1346
|
+
console.log(`RestoreSession Error: ${error}`);
|
|
2776
1347
|
return false;
|
|
2777
1348
|
}
|
|
2778
1349
|
});
|
|
@@ -2787,18 +1358,18 @@ var __privateWrapper = (obj, member, setter, getter) => ({
|
|
|
2787
1358
|
return response.payload.authorizeOptionsClientCopy;
|
|
2788
1359
|
}
|
|
2789
1360
|
} catch (error) {
|
|
2790
|
-
console.log(
|
|
1361
|
+
console.log(`Authorize Error: ${error}`);
|
|
2791
1362
|
}
|
|
2792
1363
|
return {};
|
|
2793
1364
|
});
|
|
2794
1365
|
__publicField(this, "HandleRedirect", async (queryVars) => {
|
|
2795
1366
|
try {
|
|
2796
|
-
debug$1(
|
|
1367
|
+
debug$1(`STSOAuth2Manager:HandleRedirect`.magenta);
|
|
2797
1368
|
let response = null;
|
|
2798
1369
|
if (queryVars[stsutils.OAuth2ParameterType.CODE]) {
|
|
2799
1370
|
const authorizeOptions = __privateGet(this, _transactionStore).get(__privateGet(this, _STORAGE_AUTHORIZE_OPTIONS_KEY));
|
|
2800
1371
|
__privateGet(this, _transactionStore).remove(__privateGet(this, _STORAGE_AUTHORIZE_OPTIONS_KEY));
|
|
2801
|
-
debug$1(
|
|
1372
|
+
debug$1(`STSOAuth2Manager:HandleRedirect: sending HANDLE_REDIRECT command`.magenta);
|
|
2802
1373
|
response = await __privateGet(this, _PostMessage).call(this, { command: IOauth2ListenerCommand.HANDLE_REDIRECT, payload: {
|
|
2803
1374
|
queryVars,
|
|
2804
1375
|
authorizeOptions
|
|
@@ -2806,10 +1377,10 @@ var __privateWrapper = (obj, member, setter, getter) => ({
|
|
|
2806
1377
|
} else {
|
|
2807
1378
|
response = await __privateGet(this, _PostMessage).call(this, { command: IOauth2ListenerCommand.HANDLE_REDIRECT, payload: queryVars });
|
|
2808
1379
|
}
|
|
2809
|
-
debug$1(
|
|
1380
|
+
debug$1(`STSOAuth2Manager:HandleRedirect: HANDLE_REDIRECT response: [${JSON.stringify(response)}]`.magenta);
|
|
2810
1381
|
return response.payload;
|
|
2811
1382
|
} catch (error) {
|
|
2812
|
-
console.log(
|
|
1383
|
+
console.log(`HandleRedirect Error: ${error}`);
|
|
2813
1384
|
return false;
|
|
2814
1385
|
}
|
|
2815
1386
|
});
|
|
@@ -2818,7 +1389,7 @@ var __privateWrapper = (obj, member, setter, getter) => ({
|
|
|
2818
1389
|
const response = await __privateGet(this, _PostMessage).call(this, { command: IOauth2ListenerCommand.LOGOUT });
|
|
2819
1390
|
return response.payload;
|
|
2820
1391
|
} catch (error) {
|
|
2821
|
-
console.log(
|
|
1392
|
+
console.log(`Logout Error: ${error}`);
|
|
2822
1393
|
return false;
|
|
2823
1394
|
}
|
|
2824
1395
|
});
|
|
@@ -2828,7 +1399,7 @@ var __privateWrapper = (obj, member, setter, getter) => ({
|
|
|
2828
1399
|
const response = await __privateGet(this, _PostMessage).call(this, { command: IOauth2ListenerCommand.LOGOUT });
|
|
2829
1400
|
return response.payload;
|
|
2830
1401
|
} catch (error) {
|
|
2831
|
-
console.log(
|
|
1402
|
+
console.log(`InvokeExternalAPI Error: ${error}`);
|
|
2832
1403
|
return null;
|
|
2833
1404
|
}
|
|
2834
1405
|
});
|
|
@@ -2859,10 +1430,10 @@ var __privateWrapper = (obj, member, setter, getter) => ({
|
|
|
2859
1430
|
}
|
|
2860
1431
|
if (!isNode) {
|
|
2861
1432
|
__privateGet(this, _worker).onmessage = (data) => {
|
|
2862
|
-
console.log(
|
|
1433
|
+
console.log(`this.#worker.onmessage = [${data}]`);
|
|
2863
1434
|
};
|
|
2864
1435
|
__privateGet(this, _worker).onerror = function(error) {
|
|
2865
|
-
console.log(
|
|
1436
|
+
console.log(`this.#worker.onerror = [${JSON.stringify(error)}]`);
|
|
2866
1437
|
};
|
|
2867
1438
|
}
|
|
2868
1439
|
let workerMessage;
|
|
@@ -2907,7 +1478,7 @@ var __privateWrapper = (obj, member, setter, getter) => ({
|
|
|
2907
1478
|
const response: IOauth2ListenerMessageResponse = await this.#PostMessage({ command: IOauth2ListenerCommand.ID_TOKEN });
|
|
2908
1479
|
return response.payload;
|
|
2909
1480
|
} catch (error) {
|
|
2910
|
-
console.log(
|
|
1481
|
+
console.log(`Logout Error: ${error}`); // red
|
|
2911
1482
|
return null;
|
|
2912
1483
|
}
|
|
2913
1484
|
}
|
|
@@ -3174,7 +1745,7 @@ var __privateWrapper = (obj, member, setter, getter) => ({
|
|
|
3174
1745
|
// Ensure cookies are passed to the service
|
|
3175
1746
|
timeout: __privateGet(this, _options2).timeout
|
|
3176
1747
|
};
|
|
3177
|
-
debug(
|
|
1748
|
+
debug(`#RestoreSession:session request detail: [${JSON.stringify(rConfig)}]`.magenta);
|
|
3178
1749
|
if (isNode) {
|
|
3179
1750
|
rConfig.httpsAgent = __privateGet(this, _httpsAgent);
|
|
3180
1751
|
}
|
|
@@ -3251,20 +1822,20 @@ var __privateWrapper = (obj, member, setter, getter) => ({
|
|
|
3251
1822
|
__privateAdd(this, _HandleRedirect, async (payload) => {
|
|
3252
1823
|
const queryVars = payload.queryVars;
|
|
3253
1824
|
const authorizeOptions = payload.authorizeOptions;
|
|
3254
|
-
debug(
|
|
3255
|
-
debug(
|
|
1825
|
+
debug(`#HandleRedirect: HandleRedirect`.magenta);
|
|
1826
|
+
debug(`#HandleRedirect: HandleRedirect:Query Vars: [${JSON.stringify(queryVars)}]`.magenta);
|
|
3256
1827
|
if (queryVars[stsutils.OAuth2ParameterType.CODE]) {
|
|
3257
1828
|
const response = queryVars;
|
|
3258
1829
|
console.log(`authorizeOptions from transaction state: [${JSON.stringify(authorizeOptions)}]`);
|
|
3259
1830
|
const redirectState = response.state;
|
|
3260
1831
|
const authorizeOptionsState = authorizeOptions.state;
|
|
3261
1832
|
if (authorizeOptionsState.localeCompare(redirectState) === 0) {
|
|
3262
|
-
console.log(
|
|
1833
|
+
console.log("redirected state (from queryVars) matched previously saved transaction authorizeOptions state");
|
|
3263
1834
|
return await __privateGet(this, _GetToken).call(this, authorizeOptions, response);
|
|
3264
1835
|
} else {
|
|
3265
|
-
console.log(
|
|
3266
|
-
console.log(
|
|
3267
|
-
console.log(
|
|
1836
|
+
console.log("redirected state (from queryVars) did NOT match previously saved transaction authorizeOptions state");
|
|
1837
|
+
console.log(`authorizeOptionsState: [${authorizeOptionsState}]`);
|
|
1838
|
+
console.log(`redirectState: [${redirectState}]`);
|
|
3268
1839
|
__privateGet(this, _HandleErrorEvent2).call(this, { message: "State un-matched" });
|
|
3269
1840
|
return false;
|
|
3270
1841
|
}
|
|
@@ -3297,7 +1868,7 @@ var __privateWrapper = (obj, member, setter, getter) => ({
|
|
|
3297
1868
|
*/
|
|
3298
1869
|
// Get access_token, refresh_token and id_token using OAuth2 Authorization Code Flow
|
|
3299
1870
|
__privateAdd(this, _GetTokenFromBroker, async (authorizationCodeFlowParameters) => {
|
|
3300
|
-
debug(
|
|
1871
|
+
debug(`#GetTokenFromBroker`.magenta);
|
|
3301
1872
|
__privateGet(this, _clientSessionStore).remove(__privateGet(this, _STORAGE_SESSION_KEY2));
|
|
3302
1873
|
const url = `${__privateGet(this, _options2).brokerendpoint}:${__privateGet(this, _options2).brokerport}${__privateGet(this, _options2).brokerapiroot}/token`;
|
|
3303
1874
|
try {
|
|
@@ -3309,15 +1880,15 @@ var __privateWrapper = (obj, member, setter, getter) => ({
|
|
|
3309
1880
|
// Ensure cookies are passed to the service
|
|
3310
1881
|
timeout: __privateGet(this, _options2).timeout
|
|
3311
1882
|
};
|
|
3312
|
-
debug(
|
|
1883
|
+
debug(`#GetTokenFromBroker: request config: [${JSON.stringify(rConfig)}]`.magenta);
|
|
3313
1884
|
if (isNode) {
|
|
3314
1885
|
rConfig.httpsAgent = __privateGet(this, _httpsAgent);
|
|
3315
1886
|
}
|
|
3316
|
-
debug(
|
|
1887
|
+
debug(`#GetTokenFromBroker: axios API call`.magenta);
|
|
3317
1888
|
const retVal = await axios(rConfig);
|
|
3318
|
-
debug(
|
|
1889
|
+
debug(`#GetTokenFromBroker: axios API call result: [${retVal.status}]`.magenta);
|
|
3319
1890
|
if (retVal.status === StatusCodes.OK) {
|
|
3320
|
-
debug(
|
|
1891
|
+
debug(`#GetTokenFromBroker: storing tokens`.magenta);
|
|
3321
1892
|
const tokenResponse = retVal.data;
|
|
3322
1893
|
__privateGet(this, _HandleAuthenticateEvent2).call(this, tokenResponse.id_token);
|
|
3323
1894
|
const newSessionData = {
|
|
@@ -3329,18 +1900,18 @@ var __privateWrapper = (obj, member, setter, getter) => ({
|
|
|
3329
1900
|
__privateGet(this, _clientSessionStore).set(__privateGet(this, _STORAGE_SESSION_KEY2), newSessionData);
|
|
3330
1901
|
return true;
|
|
3331
1902
|
} else if (retVal.status === StatusCodes.UNAUTHORIZED) {
|
|
3332
|
-
debug(
|
|
1903
|
+
debug(`#GetTokenFromBroker: NOT storing tokens, status: [${retVal.status}]`.magenta);
|
|
3333
1904
|
__privateGet(this, _HandleAuthenticateEvent2).call(this, null);
|
|
3334
1905
|
return false;
|
|
3335
1906
|
} else {
|
|
3336
|
-
debug(
|
|
1907
|
+
debug(`#GetTokenFromBroker: NOT storing tokens (general error 1), status: [${retVal.status}]`.magenta);
|
|
3337
1908
|
__privateGet(this, _HandleAuthenticateEvent2).call(this, null);
|
|
3338
1909
|
console.log("Could not obtain access_token from token end-point:-");
|
|
3339
1910
|
console.log(JSON.stringify(retVal.data));
|
|
3340
1911
|
return false;
|
|
3341
1912
|
}
|
|
3342
1913
|
} catch (error) {
|
|
3343
|
-
debug(
|
|
1914
|
+
debug(`#GetTokenFromBroker: NOT storing tokens (general error 2), status: [${error}]`.red);
|
|
3344
1915
|
__privateGet(this, _HandleAuthenticateEvent2).call(this, null);
|
|
3345
1916
|
return false;
|
|
3346
1917
|
}
|
|
@@ -3399,7 +1970,7 @@ var __privateWrapper = (obj, member, setter, getter) => ({
|
|
|
3399
1970
|
};
|
|
3400
1971
|
return await __privateGet(this, _GetTokenFromBroker).call(this, refreshFlowParameters);
|
|
3401
1972
|
} else {
|
|
3402
|
-
debug(
|
|
1973
|
+
debug(`STSOAuth2Worker:#RefreshToken:sessionData not found within clientSessionStore`.red);
|
|
3403
1974
|
return false;
|
|
3404
1975
|
}
|
|
3405
1976
|
});
|
|
@@ -3434,7 +2005,7 @@ var __privateWrapper = (obj, member, setter, getter) => ({
|
|
|
3434
2005
|
// Ensure cookies are passed to the service
|
|
3435
2006
|
timeout: __privateGet(this, _options2).timeout
|
|
3436
2007
|
};
|
|
3437
|
-
debug(
|
|
2008
|
+
debug(`#Logout: request config: [${rConfig}]`.magenta);
|
|
3438
2009
|
if (isNode) {
|
|
3439
2010
|
rConfig.httpsAgent = __privateGet(this, _httpsAgent);
|
|
3440
2011
|
}
|