@keycloakify/svelte 0.0.1-rc.7 → 0.1.0

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.
@@ -3,6 +3,1812 @@ import * as __WEBPACK_EXTERNAL_MODULE_prettier__ from "prettier";
3
3
  import { createRequire as __WEBPACK_EXTERNAL_createRequire } from "module";
4
4
  /******/ var __webpack_modules__ = ({
5
5
 
6
+ /***/ 412:
7
+ /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
8
+
9
+ /* module decorator */ module = __nccwpck_require__.nmd(module);
10
+
11
+
12
+ const wrapAnsi16 = (fn, offset) => (...args) => {
13
+ const code = fn(...args);
14
+ return `\u001B[${code + offset}m`;
15
+ };
16
+
17
+ const wrapAnsi256 = (fn, offset) => (...args) => {
18
+ const code = fn(...args);
19
+ return `\u001B[${38 + offset};5;${code}m`;
20
+ };
21
+
22
+ const wrapAnsi16m = (fn, offset) => (...args) => {
23
+ const rgb = fn(...args);
24
+ return `\u001B[${38 + offset};2;${rgb[0]};${rgb[1]};${rgb[2]}m`;
25
+ };
26
+
27
+ const ansi2ansi = n => n;
28
+ const rgb2rgb = (r, g, b) => [r, g, b];
29
+
30
+ const setLazyProperty = (object, property, get) => {
31
+ Object.defineProperty(object, property, {
32
+ get: () => {
33
+ const value = get();
34
+
35
+ Object.defineProperty(object, property, {
36
+ value,
37
+ enumerable: true,
38
+ configurable: true
39
+ });
40
+
41
+ return value;
42
+ },
43
+ enumerable: true,
44
+ configurable: true
45
+ });
46
+ };
47
+
48
+ /** @type {typeof import('color-convert')} */
49
+ let colorConvert;
50
+ const makeDynamicStyles = (wrap, targetSpace, identity, isBackground) => {
51
+ if (colorConvert === undefined) {
52
+ colorConvert = __nccwpck_require__(185);
53
+ }
54
+
55
+ const offset = isBackground ? 10 : 0;
56
+ const styles = {};
57
+
58
+ for (const [sourceSpace, suite] of Object.entries(colorConvert)) {
59
+ const name = sourceSpace === 'ansi16' ? 'ansi' : sourceSpace;
60
+ if (sourceSpace === targetSpace) {
61
+ styles[name] = wrap(identity, offset);
62
+ } else if (typeof suite === 'object') {
63
+ styles[name] = wrap(suite[targetSpace], offset);
64
+ }
65
+ }
66
+
67
+ return styles;
68
+ };
69
+
70
+ function assembleStyles() {
71
+ const codes = new Map();
72
+ const styles = {
73
+ modifier: {
74
+ reset: [0, 0],
75
+ // 21 isn't widely supported and 22 does the same thing
76
+ bold: [1, 22],
77
+ dim: [2, 22],
78
+ italic: [3, 23],
79
+ underline: [4, 24],
80
+ inverse: [7, 27],
81
+ hidden: [8, 28],
82
+ strikethrough: [9, 29]
83
+ },
84
+ color: {
85
+ black: [30, 39],
86
+ red: [31, 39],
87
+ green: [32, 39],
88
+ yellow: [33, 39],
89
+ blue: [34, 39],
90
+ magenta: [35, 39],
91
+ cyan: [36, 39],
92
+ white: [37, 39],
93
+
94
+ // Bright color
95
+ blackBright: [90, 39],
96
+ redBright: [91, 39],
97
+ greenBright: [92, 39],
98
+ yellowBright: [93, 39],
99
+ blueBright: [94, 39],
100
+ magentaBright: [95, 39],
101
+ cyanBright: [96, 39],
102
+ whiteBright: [97, 39]
103
+ },
104
+ bgColor: {
105
+ bgBlack: [40, 49],
106
+ bgRed: [41, 49],
107
+ bgGreen: [42, 49],
108
+ bgYellow: [43, 49],
109
+ bgBlue: [44, 49],
110
+ bgMagenta: [45, 49],
111
+ bgCyan: [46, 49],
112
+ bgWhite: [47, 49],
113
+
114
+ // Bright color
115
+ bgBlackBright: [100, 49],
116
+ bgRedBright: [101, 49],
117
+ bgGreenBright: [102, 49],
118
+ bgYellowBright: [103, 49],
119
+ bgBlueBright: [104, 49],
120
+ bgMagentaBright: [105, 49],
121
+ bgCyanBright: [106, 49],
122
+ bgWhiteBright: [107, 49]
123
+ }
124
+ };
125
+
126
+ // Alias bright black as gray (and grey)
127
+ styles.color.gray = styles.color.blackBright;
128
+ styles.bgColor.bgGray = styles.bgColor.bgBlackBright;
129
+ styles.color.grey = styles.color.blackBright;
130
+ styles.bgColor.bgGrey = styles.bgColor.bgBlackBright;
131
+
132
+ for (const [groupName, group] of Object.entries(styles)) {
133
+ for (const [styleName, style] of Object.entries(group)) {
134
+ styles[styleName] = {
135
+ open: `\u001B[${style[0]}m`,
136
+ close: `\u001B[${style[1]}m`
137
+ };
138
+
139
+ group[styleName] = styles[styleName];
140
+
141
+ codes.set(style[0], style[1]);
142
+ }
143
+
144
+ Object.defineProperty(styles, groupName, {
145
+ value: group,
146
+ enumerable: false
147
+ });
148
+ }
149
+
150
+ Object.defineProperty(styles, 'codes', {
151
+ value: codes,
152
+ enumerable: false
153
+ });
154
+
155
+ styles.color.close = '\u001B[39m';
156
+ styles.bgColor.close = '\u001B[49m';
157
+
158
+ setLazyProperty(styles.color, 'ansi', () => makeDynamicStyles(wrapAnsi16, 'ansi16', ansi2ansi, false));
159
+ setLazyProperty(styles.color, 'ansi256', () => makeDynamicStyles(wrapAnsi256, 'ansi256', ansi2ansi, false));
160
+ setLazyProperty(styles.color, 'ansi16m', () => makeDynamicStyles(wrapAnsi16m, 'rgb', rgb2rgb, false));
161
+ setLazyProperty(styles.bgColor, 'ansi', () => makeDynamicStyles(wrapAnsi16, 'ansi16', ansi2ansi, true));
162
+ setLazyProperty(styles.bgColor, 'ansi256', () => makeDynamicStyles(wrapAnsi256, 'ansi256', ansi2ansi, true));
163
+ setLazyProperty(styles.bgColor, 'ansi16m', () => makeDynamicStyles(wrapAnsi16m, 'rgb', rgb2rgb, true));
164
+
165
+ return styles;
166
+ }
167
+
168
+ // Make the export immutable
169
+ Object.defineProperty(module, 'exports', {
170
+ enumerable: true,
171
+ get: assembleStyles
172
+ });
173
+
174
+
175
+ /***/ }),
176
+
177
+ /***/ 465:
178
+ /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
179
+
180
+
181
+ const ansiStyles = __nccwpck_require__(412);
182
+ const {stdout: stdoutColor, stderr: stderrColor} = __nccwpck_require__(450);
183
+ const {
184
+ stringReplaceAll,
185
+ stringEncaseCRLFWithFirstIndex
186
+ } = __nccwpck_require__(809);
187
+
188
+ const {isArray} = Array;
189
+
190
+ // `supportsColor.level` → `ansiStyles.color[name]` mapping
191
+ const levelMapping = [
192
+ 'ansi',
193
+ 'ansi',
194
+ 'ansi256',
195
+ 'ansi16m'
196
+ ];
197
+
198
+ const styles = Object.create(null);
199
+
200
+ const applyOptions = (object, options = {}) => {
201
+ if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {
202
+ throw new Error('The `level` option should be an integer from 0 to 3');
203
+ }
204
+
205
+ // Detect level if not set manually
206
+ const colorLevel = stdoutColor ? stdoutColor.level : 0;
207
+ object.level = options.level === undefined ? colorLevel : options.level;
208
+ };
209
+
210
+ class ChalkClass {
211
+ constructor(options) {
212
+ // eslint-disable-next-line no-constructor-return
213
+ return chalkFactory(options);
214
+ }
215
+ }
216
+
217
+ const chalkFactory = options => {
218
+ const chalk = {};
219
+ applyOptions(chalk, options);
220
+
221
+ chalk.template = (...arguments_) => chalkTag(chalk.template, ...arguments_);
222
+
223
+ Object.setPrototypeOf(chalk, Chalk.prototype);
224
+ Object.setPrototypeOf(chalk.template, chalk);
225
+
226
+ chalk.template.constructor = () => {
227
+ throw new Error('`chalk.constructor()` is deprecated. Use `new chalk.Instance()` instead.');
228
+ };
229
+
230
+ chalk.template.Instance = ChalkClass;
231
+
232
+ return chalk.template;
233
+ };
234
+
235
+ function Chalk(options) {
236
+ return chalkFactory(options);
237
+ }
238
+
239
+ for (const [styleName, style] of Object.entries(ansiStyles)) {
240
+ styles[styleName] = {
241
+ get() {
242
+ const builder = createBuilder(this, createStyler(style.open, style.close, this._styler), this._isEmpty);
243
+ Object.defineProperty(this, styleName, {value: builder});
244
+ return builder;
245
+ }
246
+ };
247
+ }
248
+
249
+ styles.visible = {
250
+ get() {
251
+ const builder = createBuilder(this, this._styler, true);
252
+ Object.defineProperty(this, 'visible', {value: builder});
253
+ return builder;
254
+ }
255
+ };
256
+
257
+ const usedModels = ['rgb', 'hex', 'keyword', 'hsl', 'hsv', 'hwb', 'ansi', 'ansi256'];
258
+
259
+ for (const model of usedModels) {
260
+ styles[model] = {
261
+ get() {
262
+ const {level} = this;
263
+ return function (...arguments_) {
264
+ const styler = createStyler(ansiStyles.color[levelMapping[level]][model](...arguments_), ansiStyles.color.close, this._styler);
265
+ return createBuilder(this, styler, this._isEmpty);
266
+ };
267
+ }
268
+ };
269
+ }
270
+
271
+ for (const model of usedModels) {
272
+ const bgModel = 'bg' + model[0].toUpperCase() + model.slice(1);
273
+ styles[bgModel] = {
274
+ get() {
275
+ const {level} = this;
276
+ return function (...arguments_) {
277
+ const styler = createStyler(ansiStyles.bgColor[levelMapping[level]][model](...arguments_), ansiStyles.bgColor.close, this._styler);
278
+ return createBuilder(this, styler, this._isEmpty);
279
+ };
280
+ }
281
+ };
282
+ }
283
+
284
+ const proto = Object.defineProperties(() => {}, {
285
+ ...styles,
286
+ level: {
287
+ enumerable: true,
288
+ get() {
289
+ return this._generator.level;
290
+ },
291
+ set(level) {
292
+ this._generator.level = level;
293
+ }
294
+ }
295
+ });
296
+
297
+ const createStyler = (open, close, parent) => {
298
+ let openAll;
299
+ let closeAll;
300
+ if (parent === undefined) {
301
+ openAll = open;
302
+ closeAll = close;
303
+ } else {
304
+ openAll = parent.openAll + open;
305
+ closeAll = close + parent.closeAll;
306
+ }
307
+
308
+ return {
309
+ open,
310
+ close,
311
+ openAll,
312
+ closeAll,
313
+ parent
314
+ };
315
+ };
316
+
317
+ const createBuilder = (self, _styler, _isEmpty) => {
318
+ const builder = (...arguments_) => {
319
+ if (isArray(arguments_[0]) && isArray(arguments_[0].raw)) {
320
+ // Called as a template literal, for example: chalk.red`2 + 3 = {bold ${2+3}}`
321
+ return applyStyle(builder, chalkTag(builder, ...arguments_));
322
+ }
323
+
324
+ // Single argument is hot path, implicit coercion is faster than anything
325
+ // eslint-disable-next-line no-implicit-coercion
326
+ return applyStyle(builder, (arguments_.length === 1) ? ('' + arguments_[0]) : arguments_.join(' '));
327
+ };
328
+
329
+ // We alter the prototype because we must return a function, but there is
330
+ // no way to create a function with a different prototype
331
+ Object.setPrototypeOf(builder, proto);
332
+
333
+ builder._generator = self;
334
+ builder._styler = _styler;
335
+ builder._isEmpty = _isEmpty;
336
+
337
+ return builder;
338
+ };
339
+
340
+ const applyStyle = (self, string) => {
341
+ if (self.level <= 0 || !string) {
342
+ return self._isEmpty ? '' : string;
343
+ }
344
+
345
+ let styler = self._styler;
346
+
347
+ if (styler === undefined) {
348
+ return string;
349
+ }
350
+
351
+ const {openAll, closeAll} = styler;
352
+ if (string.indexOf('\u001B') !== -1) {
353
+ while (styler !== undefined) {
354
+ // Replace any instances already present with a re-opening code
355
+ // otherwise only the part of the string until said closing code
356
+ // will be colored, and the rest will simply be 'plain'.
357
+ string = stringReplaceAll(string, styler.close, styler.open);
358
+
359
+ styler = styler.parent;
360
+ }
361
+ }
362
+
363
+ // We can move both next actions out of loop, because remaining actions in loop won't have
364
+ // any/visible effect on parts we add here. Close the styling before a linebreak and reopen
365
+ // after next line to fix a bleed issue on macOS: https://github.com/chalk/chalk/pull/92
366
+ const lfIndex = string.indexOf('\n');
367
+ if (lfIndex !== -1) {
368
+ string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex);
369
+ }
370
+
371
+ return openAll + string + closeAll;
372
+ };
373
+
374
+ let template;
375
+ const chalkTag = (chalk, ...strings) => {
376
+ const [firstString] = strings;
377
+
378
+ if (!isArray(firstString) || !isArray(firstString.raw)) {
379
+ // If chalk() was called by itself or with a string,
380
+ // return the string itself as a string.
381
+ return strings.join(' ');
382
+ }
383
+
384
+ const arguments_ = strings.slice(1);
385
+ const parts = [firstString.raw[0]];
386
+
387
+ for (let i = 1; i < firstString.length; i++) {
388
+ parts.push(
389
+ String(arguments_[i - 1]).replace(/[{}\\]/g, '\\$&'),
390
+ String(firstString.raw[i])
391
+ );
392
+ }
393
+
394
+ if (template === undefined) {
395
+ template = __nccwpck_require__(670);
396
+ }
397
+
398
+ return template(chalk, parts.join(''));
399
+ };
400
+
401
+ Object.defineProperties(Chalk.prototype, styles);
402
+
403
+ const chalk = Chalk(); // eslint-disable-line new-cap
404
+ chalk.supportsColor = stdoutColor;
405
+ chalk.stderr = Chalk({level: stderrColor ? stderrColor.level : 0}); // eslint-disable-line new-cap
406
+ chalk.stderr.supportsColor = stderrColor;
407
+
408
+ module.exports = chalk;
409
+
410
+
411
+ /***/ }),
412
+
413
+ /***/ 670:
414
+ /***/ ((module) => {
415
+
416
+
417
+ 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;
418
+ const STYLE_REGEX = /(?:^|\.)(\w+)(?:\(([^)]*)\))?/g;
419
+ const STRING_REGEX = /^(['"])((?:\\.|(?!\1)[^\\])*)\1$/;
420
+ const ESCAPE_REGEX = /\\(u(?:[a-f\d]{4}|{[a-f\d]{1,6}})|x[a-f\d]{2}|.)|([^\\])/gi;
421
+
422
+ const ESCAPES = new Map([
423
+ ['n', '\n'],
424
+ ['r', '\r'],
425
+ ['t', '\t'],
426
+ ['b', '\b'],
427
+ ['f', '\f'],
428
+ ['v', '\v'],
429
+ ['0', '\0'],
430
+ ['\\', '\\'],
431
+ ['e', '\u001B'],
432
+ ['a', '\u0007']
433
+ ]);
434
+
435
+ function unescape(c) {
436
+ const u = c[0] === 'u';
437
+ const bracket = c[1] === '{';
438
+
439
+ if ((u && !bracket && c.length === 5) || (c[0] === 'x' && c.length === 3)) {
440
+ return String.fromCharCode(parseInt(c.slice(1), 16));
441
+ }
442
+
443
+ if (u && bracket) {
444
+ return String.fromCodePoint(parseInt(c.slice(2, -1), 16));
445
+ }
446
+
447
+ return ESCAPES.get(c) || c;
448
+ }
449
+
450
+ function parseArguments(name, arguments_) {
451
+ const results = [];
452
+ const chunks = arguments_.trim().split(/\s*,\s*/g);
453
+ let matches;
454
+
455
+ for (const chunk of chunks) {
456
+ const number = Number(chunk);
457
+ if (!Number.isNaN(number)) {
458
+ results.push(number);
459
+ } else if ((matches = chunk.match(STRING_REGEX))) {
460
+ results.push(matches[2].replace(ESCAPE_REGEX, (m, escape, character) => escape ? unescape(escape) : character));
461
+ } else {
462
+ throw new Error(`Invalid Chalk template style argument: ${chunk} (in style '${name}')`);
463
+ }
464
+ }
465
+
466
+ return results;
467
+ }
468
+
469
+ function parseStyle(style) {
470
+ STYLE_REGEX.lastIndex = 0;
471
+
472
+ const results = [];
473
+ let matches;
474
+
475
+ while ((matches = STYLE_REGEX.exec(style)) !== null) {
476
+ const name = matches[1];
477
+
478
+ if (matches[2]) {
479
+ const args = parseArguments(name, matches[2]);
480
+ results.push([name].concat(args));
481
+ } else {
482
+ results.push([name]);
483
+ }
484
+ }
485
+
486
+ return results;
487
+ }
488
+
489
+ function buildStyle(chalk, styles) {
490
+ const enabled = {};
491
+
492
+ for (const layer of styles) {
493
+ for (const style of layer.styles) {
494
+ enabled[style[0]] = layer.inverse ? null : style.slice(1);
495
+ }
496
+ }
497
+
498
+ let current = chalk;
499
+ for (const [styleName, styles] of Object.entries(enabled)) {
500
+ if (!Array.isArray(styles)) {
501
+ continue;
502
+ }
503
+
504
+ if (!(styleName in current)) {
505
+ throw new Error(`Unknown Chalk style: ${styleName}`);
506
+ }
507
+
508
+ current = styles.length > 0 ? current[styleName](...styles) : current[styleName];
509
+ }
510
+
511
+ return current;
512
+ }
513
+
514
+ module.exports = (chalk, temporary) => {
515
+ const styles = [];
516
+ const chunks = [];
517
+ let chunk = [];
518
+
519
+ // eslint-disable-next-line max-params
520
+ temporary.replace(TEMPLATE_REGEX, (m, escapeCharacter, inverse, style, close, character) => {
521
+ if (escapeCharacter) {
522
+ chunk.push(unescape(escapeCharacter));
523
+ } else if (style) {
524
+ const string = chunk.join('');
525
+ chunk = [];
526
+ chunks.push(styles.length === 0 ? string : buildStyle(chalk, styles)(string));
527
+ styles.push({inverse, styles: parseStyle(style)});
528
+ } else if (close) {
529
+ if (styles.length === 0) {
530
+ throw new Error('Found extraneous } in Chalk template literal');
531
+ }
532
+
533
+ chunks.push(buildStyle(chalk, styles)(chunk.join('')));
534
+ chunk = [];
535
+ styles.pop();
536
+ } else {
537
+ chunk.push(character);
538
+ }
539
+ });
540
+
541
+ chunks.push(chunk.join(''));
542
+
543
+ if (styles.length > 0) {
544
+ const errMessage = `Chalk template literal is missing ${styles.length} closing bracket${styles.length === 1 ? '' : 's'} (\`}\`)`;
545
+ throw new Error(errMessage);
546
+ }
547
+
548
+ return chunks.join('');
549
+ };
550
+
551
+
552
+ /***/ }),
553
+
554
+ /***/ 809:
555
+ /***/ ((module) => {
556
+
557
+
558
+
559
+ const stringReplaceAll = (string, substring, replacer) => {
560
+ let index = string.indexOf(substring);
561
+ if (index === -1) {
562
+ return string;
563
+ }
564
+
565
+ const substringLength = substring.length;
566
+ let endIndex = 0;
567
+ let returnValue = '';
568
+ do {
569
+ returnValue += string.substr(endIndex, index - endIndex) + substring + replacer;
570
+ endIndex = index + substringLength;
571
+ index = string.indexOf(substring, endIndex);
572
+ } while (index !== -1);
573
+
574
+ returnValue += string.substr(endIndex);
575
+ return returnValue;
576
+ };
577
+
578
+ const stringEncaseCRLFWithFirstIndex = (string, prefix, postfix, index) => {
579
+ let endIndex = 0;
580
+ let returnValue = '';
581
+ do {
582
+ const gotCR = string[index - 1] === '\r';
583
+ returnValue += string.substr(endIndex, (gotCR ? index - 1 : index) - endIndex) + prefix + (gotCR ? '\r\n' : '\n') + postfix;
584
+ endIndex = index + 1;
585
+ index = string.indexOf('\n', endIndex);
586
+ } while (index !== -1);
587
+
588
+ returnValue += string.substr(endIndex);
589
+ return returnValue;
590
+ };
591
+
592
+ module.exports = {
593
+ stringReplaceAll,
594
+ stringEncaseCRLFWithFirstIndex
595
+ };
596
+
597
+
598
+ /***/ }),
599
+
600
+ /***/ 872:
601
+ /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
602
+
603
+ /* MIT license */
604
+ /* eslint-disable no-mixed-operators */
605
+ const cssKeywords = __nccwpck_require__(953);
606
+
607
+ // NOTE: conversions should only return primitive values (i.e. arrays, or
608
+ // values that give correct `typeof` results).
609
+ // do not use box values types (i.e. Number(), String(), etc.)
610
+
611
+ const reverseKeywords = {};
612
+ for (const key of Object.keys(cssKeywords)) {
613
+ reverseKeywords[cssKeywords[key]] = key;
614
+ }
615
+
616
+ const convert = {
617
+ rgb: {channels: 3, labels: 'rgb'},
618
+ hsl: {channels: 3, labels: 'hsl'},
619
+ hsv: {channels: 3, labels: 'hsv'},
620
+ hwb: {channels: 3, labels: 'hwb'},
621
+ cmyk: {channels: 4, labels: 'cmyk'},
622
+ xyz: {channels: 3, labels: 'xyz'},
623
+ lab: {channels: 3, labels: 'lab'},
624
+ lch: {channels: 3, labels: 'lch'},
625
+ hex: {channels: 1, labels: ['hex']},
626
+ keyword: {channels: 1, labels: ['keyword']},
627
+ ansi16: {channels: 1, labels: ['ansi16']},
628
+ ansi256: {channels: 1, labels: ['ansi256']},
629
+ hcg: {channels: 3, labels: ['h', 'c', 'g']},
630
+ apple: {channels: 3, labels: ['r16', 'g16', 'b16']},
631
+ gray: {channels: 1, labels: ['gray']}
632
+ };
633
+
634
+ module.exports = convert;
635
+
636
+ // Hide .channels and .labels properties
637
+ for (const model of Object.keys(convert)) {
638
+ if (!('channels' in convert[model])) {
639
+ throw new Error('missing channels property: ' + model);
640
+ }
641
+
642
+ if (!('labels' in convert[model])) {
643
+ throw new Error('missing channel labels property: ' + model);
644
+ }
645
+
646
+ if (convert[model].labels.length !== convert[model].channels) {
647
+ throw new Error('channel and label counts mismatch: ' + model);
648
+ }
649
+
650
+ const {channels, labels} = convert[model];
651
+ delete convert[model].channels;
652
+ delete convert[model].labels;
653
+ Object.defineProperty(convert[model], 'channels', {value: channels});
654
+ Object.defineProperty(convert[model], 'labels', {value: labels});
655
+ }
656
+
657
+ convert.rgb.hsl = function (rgb) {
658
+ const r = rgb[0] / 255;
659
+ const g = rgb[1] / 255;
660
+ const b = rgb[2] / 255;
661
+ const min = Math.min(r, g, b);
662
+ const max = Math.max(r, g, b);
663
+ const delta = max - min;
664
+ let h;
665
+ let s;
666
+
667
+ if (max === min) {
668
+ h = 0;
669
+ } else if (r === max) {
670
+ h = (g - b) / delta;
671
+ } else if (g === max) {
672
+ h = 2 + (b - r) / delta;
673
+ } else if (b === max) {
674
+ h = 4 + (r - g) / delta;
675
+ }
676
+
677
+ h = Math.min(h * 60, 360);
678
+
679
+ if (h < 0) {
680
+ h += 360;
681
+ }
682
+
683
+ const l = (min + max) / 2;
684
+
685
+ if (max === min) {
686
+ s = 0;
687
+ } else if (l <= 0.5) {
688
+ s = delta / (max + min);
689
+ } else {
690
+ s = delta / (2 - max - min);
691
+ }
692
+
693
+ return [h, s * 100, l * 100];
694
+ };
695
+
696
+ convert.rgb.hsv = function (rgb) {
697
+ let rdif;
698
+ let gdif;
699
+ let bdif;
700
+ let h;
701
+ let s;
702
+
703
+ const r = rgb[0] / 255;
704
+ const g = rgb[1] / 255;
705
+ const b = rgb[2] / 255;
706
+ const v = Math.max(r, g, b);
707
+ const diff = v - Math.min(r, g, b);
708
+ const diffc = function (c) {
709
+ return (v - c) / 6 / diff + 1 / 2;
710
+ };
711
+
712
+ if (diff === 0) {
713
+ h = 0;
714
+ s = 0;
715
+ } else {
716
+ s = diff / v;
717
+ rdif = diffc(r);
718
+ gdif = diffc(g);
719
+ bdif = diffc(b);
720
+
721
+ if (r === v) {
722
+ h = bdif - gdif;
723
+ } else if (g === v) {
724
+ h = (1 / 3) + rdif - bdif;
725
+ } else if (b === v) {
726
+ h = (2 / 3) + gdif - rdif;
727
+ }
728
+
729
+ if (h < 0) {
730
+ h += 1;
731
+ } else if (h > 1) {
732
+ h -= 1;
733
+ }
734
+ }
735
+
736
+ return [
737
+ h * 360,
738
+ s * 100,
739
+ v * 100
740
+ ];
741
+ };
742
+
743
+ convert.rgb.hwb = function (rgb) {
744
+ const r = rgb[0];
745
+ const g = rgb[1];
746
+ let b = rgb[2];
747
+ const h = convert.rgb.hsl(rgb)[0];
748
+ const w = 1 / 255 * Math.min(r, Math.min(g, b));
749
+
750
+ b = 1 - 1 / 255 * Math.max(r, Math.max(g, b));
751
+
752
+ return [h, w * 100, b * 100];
753
+ };
754
+
755
+ convert.rgb.cmyk = function (rgb) {
756
+ const r = rgb[0] / 255;
757
+ const g = rgb[1] / 255;
758
+ const b = rgb[2] / 255;
759
+
760
+ const k = Math.min(1 - r, 1 - g, 1 - b);
761
+ const c = (1 - r - k) / (1 - k) || 0;
762
+ const m = (1 - g - k) / (1 - k) || 0;
763
+ const y = (1 - b - k) / (1 - k) || 0;
764
+
765
+ return [c * 100, m * 100, y * 100, k * 100];
766
+ };
767
+
768
+ function comparativeDistance(x, y) {
769
+ /*
770
+ See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance
771
+ */
772
+ return (
773
+ ((x[0] - y[0]) ** 2) +
774
+ ((x[1] - y[1]) ** 2) +
775
+ ((x[2] - y[2]) ** 2)
776
+ );
777
+ }
778
+
779
+ convert.rgb.keyword = function (rgb) {
780
+ const reversed = reverseKeywords[rgb];
781
+ if (reversed) {
782
+ return reversed;
783
+ }
784
+
785
+ let currentClosestDistance = Infinity;
786
+ let currentClosestKeyword;
787
+
788
+ for (const keyword of Object.keys(cssKeywords)) {
789
+ const value = cssKeywords[keyword];
790
+
791
+ // Compute comparative distance
792
+ const distance = comparativeDistance(rgb, value);
793
+
794
+ // Check if its less, if so set as closest
795
+ if (distance < currentClosestDistance) {
796
+ currentClosestDistance = distance;
797
+ currentClosestKeyword = keyword;
798
+ }
799
+ }
800
+
801
+ return currentClosestKeyword;
802
+ };
803
+
804
+ convert.keyword.rgb = function (keyword) {
805
+ return cssKeywords[keyword];
806
+ };
807
+
808
+ convert.rgb.xyz = function (rgb) {
809
+ let r = rgb[0] / 255;
810
+ let g = rgb[1] / 255;
811
+ let b = rgb[2] / 255;
812
+
813
+ // Assume sRGB
814
+ r = r > 0.04045 ? (((r + 0.055) / 1.055) ** 2.4) : (r / 12.92);
815
+ g = g > 0.04045 ? (((g + 0.055) / 1.055) ** 2.4) : (g / 12.92);
816
+ b = b > 0.04045 ? (((b + 0.055) / 1.055) ** 2.4) : (b / 12.92);
817
+
818
+ const x = (r * 0.4124) + (g * 0.3576) + (b * 0.1805);
819
+ const y = (r * 0.2126) + (g * 0.7152) + (b * 0.0722);
820
+ const z = (r * 0.0193) + (g * 0.1192) + (b * 0.9505);
821
+
822
+ return [x * 100, y * 100, z * 100];
823
+ };
824
+
825
+ convert.rgb.lab = function (rgb) {
826
+ const xyz = convert.rgb.xyz(rgb);
827
+ let x = xyz[0];
828
+ let y = xyz[1];
829
+ let z = xyz[2];
830
+
831
+ x /= 95.047;
832
+ y /= 100;
833
+ z /= 108.883;
834
+
835
+ x = x > 0.008856 ? (x ** (1 / 3)) : (7.787 * x) + (16 / 116);
836
+ y = y > 0.008856 ? (y ** (1 / 3)) : (7.787 * y) + (16 / 116);
837
+ z = z > 0.008856 ? (z ** (1 / 3)) : (7.787 * z) + (16 / 116);
838
+
839
+ const l = (116 * y) - 16;
840
+ const a = 500 * (x - y);
841
+ const b = 200 * (y - z);
842
+
843
+ return [l, a, b];
844
+ };
845
+
846
+ convert.hsl.rgb = function (hsl) {
847
+ const h = hsl[0] / 360;
848
+ const s = hsl[1] / 100;
849
+ const l = hsl[2] / 100;
850
+ let t2;
851
+ let t3;
852
+ let val;
853
+
854
+ if (s === 0) {
855
+ val = l * 255;
856
+ return [val, val, val];
857
+ }
858
+
859
+ if (l < 0.5) {
860
+ t2 = l * (1 + s);
861
+ } else {
862
+ t2 = l + s - l * s;
863
+ }
864
+
865
+ const t1 = 2 * l - t2;
866
+
867
+ const rgb = [0, 0, 0];
868
+ for (let i = 0; i < 3; i++) {
869
+ t3 = h + 1 / 3 * -(i - 1);
870
+ if (t3 < 0) {
871
+ t3++;
872
+ }
873
+
874
+ if (t3 > 1) {
875
+ t3--;
876
+ }
877
+
878
+ if (6 * t3 < 1) {
879
+ val = t1 + (t2 - t1) * 6 * t3;
880
+ } else if (2 * t3 < 1) {
881
+ val = t2;
882
+ } else if (3 * t3 < 2) {
883
+ val = t1 + (t2 - t1) * (2 / 3 - t3) * 6;
884
+ } else {
885
+ val = t1;
886
+ }
887
+
888
+ rgb[i] = val * 255;
889
+ }
890
+
891
+ return rgb;
892
+ };
893
+
894
+ convert.hsl.hsv = function (hsl) {
895
+ const h = hsl[0];
896
+ let s = hsl[1] / 100;
897
+ let l = hsl[2] / 100;
898
+ let smin = s;
899
+ const lmin = Math.max(l, 0.01);
900
+
901
+ l *= 2;
902
+ s *= (l <= 1) ? l : 2 - l;
903
+ smin *= lmin <= 1 ? lmin : 2 - lmin;
904
+ const v = (l + s) / 2;
905
+ const sv = l === 0 ? (2 * smin) / (lmin + smin) : (2 * s) / (l + s);
906
+
907
+ return [h, sv * 100, v * 100];
908
+ };
909
+
910
+ convert.hsv.rgb = function (hsv) {
911
+ const h = hsv[0] / 60;
912
+ const s = hsv[1] / 100;
913
+ let v = hsv[2] / 100;
914
+ const hi = Math.floor(h) % 6;
915
+
916
+ const f = h - Math.floor(h);
917
+ const p = 255 * v * (1 - s);
918
+ const q = 255 * v * (1 - (s * f));
919
+ const t = 255 * v * (1 - (s * (1 - f)));
920
+ v *= 255;
921
+
922
+ switch (hi) {
923
+ case 0:
924
+ return [v, t, p];
925
+ case 1:
926
+ return [q, v, p];
927
+ case 2:
928
+ return [p, v, t];
929
+ case 3:
930
+ return [p, q, v];
931
+ case 4:
932
+ return [t, p, v];
933
+ case 5:
934
+ return [v, p, q];
935
+ }
936
+ };
937
+
938
+ convert.hsv.hsl = function (hsv) {
939
+ const h = hsv[0];
940
+ const s = hsv[1] / 100;
941
+ const v = hsv[2] / 100;
942
+ const vmin = Math.max(v, 0.01);
943
+ let sl;
944
+ let l;
945
+
946
+ l = (2 - s) * v;
947
+ const lmin = (2 - s) * vmin;
948
+ sl = s * vmin;
949
+ sl /= (lmin <= 1) ? lmin : 2 - lmin;
950
+ sl = sl || 0;
951
+ l /= 2;
952
+
953
+ return [h, sl * 100, l * 100];
954
+ };
955
+
956
+ // http://dev.w3.org/csswg/css-color/#hwb-to-rgb
957
+ convert.hwb.rgb = function (hwb) {
958
+ const h = hwb[0] / 360;
959
+ let wh = hwb[1] / 100;
960
+ let bl = hwb[2] / 100;
961
+ const ratio = wh + bl;
962
+ let f;
963
+
964
+ // Wh + bl cant be > 1
965
+ if (ratio > 1) {
966
+ wh /= ratio;
967
+ bl /= ratio;
968
+ }
969
+
970
+ const i = Math.floor(6 * h);
971
+ const v = 1 - bl;
972
+ f = 6 * h - i;
973
+
974
+ if ((i & 0x01) !== 0) {
975
+ f = 1 - f;
976
+ }
977
+
978
+ const n = wh + f * (v - wh); // Linear interpolation
979
+
980
+ let r;
981
+ let g;
982
+ let b;
983
+ /* eslint-disable max-statements-per-line,no-multi-spaces */
984
+ switch (i) {
985
+ default:
986
+ case 6:
987
+ case 0: r = v; g = n; b = wh; break;
988
+ case 1: r = n; g = v; b = wh; break;
989
+ case 2: r = wh; g = v; b = n; break;
990
+ case 3: r = wh; g = n; b = v; break;
991
+ case 4: r = n; g = wh; b = v; break;
992
+ case 5: r = v; g = wh; b = n; break;
993
+ }
994
+ /* eslint-enable max-statements-per-line,no-multi-spaces */
995
+
996
+ return [r * 255, g * 255, b * 255];
997
+ };
998
+
999
+ convert.cmyk.rgb = function (cmyk) {
1000
+ const c = cmyk[0] / 100;
1001
+ const m = cmyk[1] / 100;
1002
+ const y = cmyk[2] / 100;
1003
+ const k = cmyk[3] / 100;
1004
+
1005
+ const r = 1 - Math.min(1, c * (1 - k) + k);
1006
+ const g = 1 - Math.min(1, m * (1 - k) + k);
1007
+ const b = 1 - Math.min(1, y * (1 - k) + k);
1008
+
1009
+ return [r * 255, g * 255, b * 255];
1010
+ };
1011
+
1012
+ convert.xyz.rgb = function (xyz) {
1013
+ const x = xyz[0] / 100;
1014
+ const y = xyz[1] / 100;
1015
+ const z = xyz[2] / 100;
1016
+ let r;
1017
+ let g;
1018
+ let b;
1019
+
1020
+ r = (x * 3.2406) + (y * -1.5372) + (z * -0.4986);
1021
+ g = (x * -0.9689) + (y * 1.8758) + (z * 0.0415);
1022
+ b = (x * 0.0557) + (y * -0.2040) + (z * 1.0570);
1023
+
1024
+ // Assume sRGB
1025
+ r = r > 0.0031308
1026
+ ? ((1.055 * (r ** (1.0 / 2.4))) - 0.055)
1027
+ : r * 12.92;
1028
+
1029
+ g = g > 0.0031308
1030
+ ? ((1.055 * (g ** (1.0 / 2.4))) - 0.055)
1031
+ : g * 12.92;
1032
+
1033
+ b = b > 0.0031308
1034
+ ? ((1.055 * (b ** (1.0 / 2.4))) - 0.055)
1035
+ : b * 12.92;
1036
+
1037
+ r = Math.min(Math.max(0, r), 1);
1038
+ g = Math.min(Math.max(0, g), 1);
1039
+ b = Math.min(Math.max(0, b), 1);
1040
+
1041
+ return [r * 255, g * 255, b * 255];
1042
+ };
1043
+
1044
+ convert.xyz.lab = function (xyz) {
1045
+ let x = xyz[0];
1046
+ let y = xyz[1];
1047
+ let z = xyz[2];
1048
+
1049
+ x /= 95.047;
1050
+ y /= 100;
1051
+ z /= 108.883;
1052
+
1053
+ x = x > 0.008856 ? (x ** (1 / 3)) : (7.787 * x) + (16 / 116);
1054
+ y = y > 0.008856 ? (y ** (1 / 3)) : (7.787 * y) + (16 / 116);
1055
+ z = z > 0.008856 ? (z ** (1 / 3)) : (7.787 * z) + (16 / 116);
1056
+
1057
+ const l = (116 * y) - 16;
1058
+ const a = 500 * (x - y);
1059
+ const b = 200 * (y - z);
1060
+
1061
+ return [l, a, b];
1062
+ };
1063
+
1064
+ convert.lab.xyz = function (lab) {
1065
+ const l = lab[0];
1066
+ const a = lab[1];
1067
+ const b = lab[2];
1068
+ let x;
1069
+ let y;
1070
+ let z;
1071
+
1072
+ y = (l + 16) / 116;
1073
+ x = a / 500 + y;
1074
+ z = y - b / 200;
1075
+
1076
+ const y2 = y ** 3;
1077
+ const x2 = x ** 3;
1078
+ const z2 = z ** 3;
1079
+ y = y2 > 0.008856 ? y2 : (y - 16 / 116) / 7.787;
1080
+ x = x2 > 0.008856 ? x2 : (x - 16 / 116) / 7.787;
1081
+ z = z2 > 0.008856 ? z2 : (z - 16 / 116) / 7.787;
1082
+
1083
+ x *= 95.047;
1084
+ y *= 100;
1085
+ z *= 108.883;
1086
+
1087
+ return [x, y, z];
1088
+ };
1089
+
1090
+ convert.lab.lch = function (lab) {
1091
+ const l = lab[0];
1092
+ const a = lab[1];
1093
+ const b = lab[2];
1094
+ let h;
1095
+
1096
+ const hr = Math.atan2(b, a);
1097
+ h = hr * 360 / 2 / Math.PI;
1098
+
1099
+ if (h < 0) {
1100
+ h += 360;
1101
+ }
1102
+
1103
+ const c = Math.sqrt(a * a + b * b);
1104
+
1105
+ return [l, c, h];
1106
+ };
1107
+
1108
+ convert.lch.lab = function (lch) {
1109
+ const l = lch[0];
1110
+ const c = lch[1];
1111
+ const h = lch[2];
1112
+
1113
+ const hr = h / 360 * 2 * Math.PI;
1114
+ const a = c * Math.cos(hr);
1115
+ const b = c * Math.sin(hr);
1116
+
1117
+ return [l, a, b];
1118
+ };
1119
+
1120
+ convert.rgb.ansi16 = function (args, saturation = null) {
1121
+ const [r, g, b] = args;
1122
+ let value = saturation === null ? convert.rgb.hsv(args)[2] : saturation; // Hsv -> ansi16 optimization
1123
+
1124
+ value = Math.round(value / 50);
1125
+
1126
+ if (value === 0) {
1127
+ return 30;
1128
+ }
1129
+
1130
+ let ansi = 30
1131
+ + ((Math.round(b / 255) << 2)
1132
+ | (Math.round(g / 255) << 1)
1133
+ | Math.round(r / 255));
1134
+
1135
+ if (value === 2) {
1136
+ ansi += 60;
1137
+ }
1138
+
1139
+ return ansi;
1140
+ };
1141
+
1142
+ convert.hsv.ansi16 = function (args) {
1143
+ // Optimization here; we already know the value and don't need to get
1144
+ // it converted for us.
1145
+ return convert.rgb.ansi16(convert.hsv.rgb(args), args[2]);
1146
+ };
1147
+
1148
+ convert.rgb.ansi256 = function (args) {
1149
+ const r = args[0];
1150
+ const g = args[1];
1151
+ const b = args[2];
1152
+
1153
+ // We use the extended greyscale palette here, with the exception of
1154
+ // black and white. normal palette only has 4 greyscale shades.
1155
+ if (r === g && g === b) {
1156
+ if (r < 8) {
1157
+ return 16;
1158
+ }
1159
+
1160
+ if (r > 248) {
1161
+ return 231;
1162
+ }
1163
+
1164
+ return Math.round(((r - 8) / 247) * 24) + 232;
1165
+ }
1166
+
1167
+ const ansi = 16
1168
+ + (36 * Math.round(r / 255 * 5))
1169
+ + (6 * Math.round(g / 255 * 5))
1170
+ + Math.round(b / 255 * 5);
1171
+
1172
+ return ansi;
1173
+ };
1174
+
1175
+ convert.ansi16.rgb = function (args) {
1176
+ let color = args % 10;
1177
+
1178
+ // Handle greyscale
1179
+ if (color === 0 || color === 7) {
1180
+ if (args > 50) {
1181
+ color += 3.5;
1182
+ }
1183
+
1184
+ color = color / 10.5 * 255;
1185
+
1186
+ return [color, color, color];
1187
+ }
1188
+
1189
+ const mult = (~~(args > 50) + 1) * 0.5;
1190
+ const r = ((color & 1) * mult) * 255;
1191
+ const g = (((color >> 1) & 1) * mult) * 255;
1192
+ const b = (((color >> 2) & 1) * mult) * 255;
1193
+
1194
+ return [r, g, b];
1195
+ };
1196
+
1197
+ convert.ansi256.rgb = function (args) {
1198
+ // Handle greyscale
1199
+ if (args >= 232) {
1200
+ const c = (args - 232) * 10 + 8;
1201
+ return [c, c, c];
1202
+ }
1203
+
1204
+ args -= 16;
1205
+
1206
+ let rem;
1207
+ const r = Math.floor(args / 36) / 5 * 255;
1208
+ const g = Math.floor((rem = args % 36) / 6) / 5 * 255;
1209
+ const b = (rem % 6) / 5 * 255;
1210
+
1211
+ return [r, g, b];
1212
+ };
1213
+
1214
+ convert.rgb.hex = function (args) {
1215
+ const integer = ((Math.round(args[0]) & 0xFF) << 16)
1216
+ + ((Math.round(args[1]) & 0xFF) << 8)
1217
+ + (Math.round(args[2]) & 0xFF);
1218
+
1219
+ const string = integer.toString(16).toUpperCase();
1220
+ return '000000'.substring(string.length) + string;
1221
+ };
1222
+
1223
+ convert.hex.rgb = function (args) {
1224
+ const match = args.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);
1225
+ if (!match) {
1226
+ return [0, 0, 0];
1227
+ }
1228
+
1229
+ let colorString = match[0];
1230
+
1231
+ if (match[0].length === 3) {
1232
+ colorString = colorString.split('').map(char => {
1233
+ return char + char;
1234
+ }).join('');
1235
+ }
1236
+
1237
+ const integer = parseInt(colorString, 16);
1238
+ const r = (integer >> 16) & 0xFF;
1239
+ const g = (integer >> 8) & 0xFF;
1240
+ const b = integer & 0xFF;
1241
+
1242
+ return [r, g, b];
1243
+ };
1244
+
1245
+ convert.rgb.hcg = function (rgb) {
1246
+ const r = rgb[0] / 255;
1247
+ const g = rgb[1] / 255;
1248
+ const b = rgb[2] / 255;
1249
+ const max = Math.max(Math.max(r, g), b);
1250
+ const min = Math.min(Math.min(r, g), b);
1251
+ const chroma = (max - min);
1252
+ let grayscale;
1253
+ let hue;
1254
+
1255
+ if (chroma < 1) {
1256
+ grayscale = min / (1 - chroma);
1257
+ } else {
1258
+ grayscale = 0;
1259
+ }
1260
+
1261
+ if (chroma <= 0) {
1262
+ hue = 0;
1263
+ } else
1264
+ if (max === r) {
1265
+ hue = ((g - b) / chroma) % 6;
1266
+ } else
1267
+ if (max === g) {
1268
+ hue = 2 + (b - r) / chroma;
1269
+ } else {
1270
+ hue = 4 + (r - g) / chroma;
1271
+ }
1272
+
1273
+ hue /= 6;
1274
+ hue %= 1;
1275
+
1276
+ return [hue * 360, chroma * 100, grayscale * 100];
1277
+ };
1278
+
1279
+ convert.hsl.hcg = function (hsl) {
1280
+ const s = hsl[1] / 100;
1281
+ const l = hsl[2] / 100;
1282
+
1283
+ const c = l < 0.5 ? (2.0 * s * l) : (2.0 * s * (1.0 - l));
1284
+
1285
+ let f = 0;
1286
+ if (c < 1.0) {
1287
+ f = (l - 0.5 * c) / (1.0 - c);
1288
+ }
1289
+
1290
+ return [hsl[0], c * 100, f * 100];
1291
+ };
1292
+
1293
+ convert.hsv.hcg = function (hsv) {
1294
+ const s = hsv[1] / 100;
1295
+ const v = hsv[2] / 100;
1296
+
1297
+ const c = s * v;
1298
+ let f = 0;
1299
+
1300
+ if (c < 1.0) {
1301
+ f = (v - c) / (1 - c);
1302
+ }
1303
+
1304
+ return [hsv[0], c * 100, f * 100];
1305
+ };
1306
+
1307
+ convert.hcg.rgb = function (hcg) {
1308
+ const h = hcg[0] / 360;
1309
+ const c = hcg[1] / 100;
1310
+ const g = hcg[2] / 100;
1311
+
1312
+ if (c === 0.0) {
1313
+ return [g * 255, g * 255, g * 255];
1314
+ }
1315
+
1316
+ const pure = [0, 0, 0];
1317
+ const hi = (h % 1) * 6;
1318
+ const v = hi % 1;
1319
+ const w = 1 - v;
1320
+ let mg = 0;
1321
+
1322
+ /* eslint-disable max-statements-per-line */
1323
+ switch (Math.floor(hi)) {
1324
+ case 0:
1325
+ pure[0] = 1; pure[1] = v; pure[2] = 0; break;
1326
+ case 1:
1327
+ pure[0] = w; pure[1] = 1; pure[2] = 0; break;
1328
+ case 2:
1329
+ pure[0] = 0; pure[1] = 1; pure[2] = v; break;
1330
+ case 3:
1331
+ pure[0] = 0; pure[1] = w; pure[2] = 1; break;
1332
+ case 4:
1333
+ pure[0] = v; pure[1] = 0; pure[2] = 1; break;
1334
+ default:
1335
+ pure[0] = 1; pure[1] = 0; pure[2] = w;
1336
+ }
1337
+ /* eslint-enable max-statements-per-line */
1338
+
1339
+ mg = (1.0 - c) * g;
1340
+
1341
+ return [
1342
+ (c * pure[0] + mg) * 255,
1343
+ (c * pure[1] + mg) * 255,
1344
+ (c * pure[2] + mg) * 255
1345
+ ];
1346
+ };
1347
+
1348
+ convert.hcg.hsv = function (hcg) {
1349
+ const c = hcg[1] / 100;
1350
+ const g = hcg[2] / 100;
1351
+
1352
+ const v = c + g * (1.0 - c);
1353
+ let f = 0;
1354
+
1355
+ if (v > 0.0) {
1356
+ f = c / v;
1357
+ }
1358
+
1359
+ return [hcg[0], f * 100, v * 100];
1360
+ };
1361
+
1362
+ convert.hcg.hsl = function (hcg) {
1363
+ const c = hcg[1] / 100;
1364
+ const g = hcg[2] / 100;
1365
+
1366
+ const l = g * (1.0 - c) + 0.5 * c;
1367
+ let s = 0;
1368
+
1369
+ if (l > 0.0 && l < 0.5) {
1370
+ s = c / (2 * l);
1371
+ } else
1372
+ if (l >= 0.5 && l < 1.0) {
1373
+ s = c / (2 * (1 - l));
1374
+ }
1375
+
1376
+ return [hcg[0], s * 100, l * 100];
1377
+ };
1378
+
1379
+ convert.hcg.hwb = function (hcg) {
1380
+ const c = hcg[1] / 100;
1381
+ const g = hcg[2] / 100;
1382
+ const v = c + g * (1.0 - c);
1383
+ return [hcg[0], (v - c) * 100, (1 - v) * 100];
1384
+ };
1385
+
1386
+ convert.hwb.hcg = function (hwb) {
1387
+ const w = hwb[1] / 100;
1388
+ const b = hwb[2] / 100;
1389
+ const v = 1 - b;
1390
+ const c = v - w;
1391
+ let g = 0;
1392
+
1393
+ if (c < 1) {
1394
+ g = (v - c) / (1 - c);
1395
+ }
1396
+
1397
+ return [hwb[0], c * 100, g * 100];
1398
+ };
1399
+
1400
+ convert.apple.rgb = function (apple) {
1401
+ return [(apple[0] / 65535) * 255, (apple[1] / 65535) * 255, (apple[2] / 65535) * 255];
1402
+ };
1403
+
1404
+ convert.rgb.apple = function (rgb) {
1405
+ return [(rgb[0] / 255) * 65535, (rgb[1] / 255) * 65535, (rgb[2] / 255) * 65535];
1406
+ };
1407
+
1408
+ convert.gray.rgb = function (args) {
1409
+ return [args[0] / 100 * 255, args[0] / 100 * 255, args[0] / 100 * 255];
1410
+ };
1411
+
1412
+ convert.gray.hsl = function (args) {
1413
+ return [0, 0, args[0]];
1414
+ };
1415
+
1416
+ convert.gray.hsv = convert.gray.hsl;
1417
+
1418
+ convert.gray.hwb = function (gray) {
1419
+ return [0, 100, gray[0]];
1420
+ };
1421
+
1422
+ convert.gray.cmyk = function (gray) {
1423
+ return [0, 0, 0, gray[0]];
1424
+ };
1425
+
1426
+ convert.gray.lab = function (gray) {
1427
+ return [gray[0], 0, 0];
1428
+ };
1429
+
1430
+ convert.gray.hex = function (gray) {
1431
+ const val = Math.round(gray[0] / 100 * 255) & 0xFF;
1432
+ const integer = (val << 16) + (val << 8) + val;
1433
+
1434
+ const string = integer.toString(16).toUpperCase();
1435
+ return '000000'.substring(string.length) + string;
1436
+ };
1437
+
1438
+ convert.rgb.gray = function (rgb) {
1439
+ const val = (rgb[0] + rgb[1] + rgb[2]) / 3;
1440
+ return [val / 255 * 100];
1441
+ };
1442
+
1443
+
1444
+ /***/ }),
1445
+
1446
+ /***/ 185:
1447
+ /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
1448
+
1449
+ const conversions = __nccwpck_require__(872);
1450
+ const route = __nccwpck_require__(200);
1451
+
1452
+ const convert = {};
1453
+
1454
+ const models = Object.keys(conversions);
1455
+
1456
+ function wrapRaw(fn) {
1457
+ const wrappedFn = function (...args) {
1458
+ const arg0 = args[0];
1459
+ if (arg0 === undefined || arg0 === null) {
1460
+ return arg0;
1461
+ }
1462
+
1463
+ if (arg0.length > 1) {
1464
+ args = arg0;
1465
+ }
1466
+
1467
+ return fn(args);
1468
+ };
1469
+
1470
+ // Preserve .conversion property if there is one
1471
+ if ('conversion' in fn) {
1472
+ wrappedFn.conversion = fn.conversion;
1473
+ }
1474
+
1475
+ return wrappedFn;
1476
+ }
1477
+
1478
+ function wrapRounded(fn) {
1479
+ const wrappedFn = function (...args) {
1480
+ const arg0 = args[0];
1481
+
1482
+ if (arg0 === undefined || arg0 === null) {
1483
+ return arg0;
1484
+ }
1485
+
1486
+ if (arg0.length > 1) {
1487
+ args = arg0;
1488
+ }
1489
+
1490
+ const result = fn(args);
1491
+
1492
+ // We're assuming the result is an array here.
1493
+ // see notice in conversions.js; don't use box types
1494
+ // in conversion functions.
1495
+ if (typeof result === 'object') {
1496
+ for (let len = result.length, i = 0; i < len; i++) {
1497
+ result[i] = Math.round(result[i]);
1498
+ }
1499
+ }
1500
+
1501
+ return result;
1502
+ };
1503
+
1504
+ // Preserve .conversion property if there is one
1505
+ if ('conversion' in fn) {
1506
+ wrappedFn.conversion = fn.conversion;
1507
+ }
1508
+
1509
+ return wrappedFn;
1510
+ }
1511
+
1512
+ models.forEach(fromModel => {
1513
+ convert[fromModel] = {};
1514
+
1515
+ Object.defineProperty(convert[fromModel], 'channels', {value: conversions[fromModel].channels});
1516
+ Object.defineProperty(convert[fromModel], 'labels', {value: conversions[fromModel].labels});
1517
+
1518
+ const routes = route(fromModel);
1519
+ const routeModels = Object.keys(routes);
1520
+
1521
+ routeModels.forEach(toModel => {
1522
+ const fn = routes[toModel];
1523
+
1524
+ convert[fromModel][toModel] = wrapRounded(fn);
1525
+ convert[fromModel][toModel].raw = wrapRaw(fn);
1526
+ });
1527
+ });
1528
+
1529
+ module.exports = convert;
1530
+
1531
+
1532
+ /***/ }),
1533
+
1534
+ /***/ 200:
1535
+ /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
1536
+
1537
+ const conversions = __nccwpck_require__(872);
1538
+
1539
+ /*
1540
+ This function routes a model to all other models.
1541
+
1542
+ all functions that are routed have a property `.conversion` attached
1543
+ to the returned synthetic function. This property is an array
1544
+ of strings, each with the steps in between the 'from' and 'to'
1545
+ color models (inclusive).
1546
+
1547
+ conversions that are not possible simply are not included.
1548
+ */
1549
+
1550
+ function buildGraph() {
1551
+ const graph = {};
1552
+ // https://jsperf.com/object-keys-vs-for-in-with-closure/3
1553
+ const models = Object.keys(conversions);
1554
+
1555
+ for (let len = models.length, i = 0; i < len; i++) {
1556
+ graph[models[i]] = {
1557
+ // http://jsperf.com/1-vs-infinity
1558
+ // micro-opt, but this is simple.
1559
+ distance: -1,
1560
+ parent: null
1561
+ };
1562
+ }
1563
+
1564
+ return graph;
1565
+ }
1566
+
1567
+ // https://en.wikipedia.org/wiki/Breadth-first_search
1568
+ function deriveBFS(fromModel) {
1569
+ const graph = buildGraph();
1570
+ const queue = [fromModel]; // Unshift -> queue -> pop
1571
+
1572
+ graph[fromModel].distance = 0;
1573
+
1574
+ while (queue.length) {
1575
+ const current = queue.pop();
1576
+ const adjacents = Object.keys(conversions[current]);
1577
+
1578
+ for (let len = adjacents.length, i = 0; i < len; i++) {
1579
+ const adjacent = adjacents[i];
1580
+ const node = graph[adjacent];
1581
+
1582
+ if (node.distance === -1) {
1583
+ node.distance = graph[current].distance + 1;
1584
+ node.parent = current;
1585
+ queue.unshift(adjacent);
1586
+ }
1587
+ }
1588
+ }
1589
+
1590
+ return graph;
1591
+ }
1592
+
1593
+ function link(from, to) {
1594
+ return function (args) {
1595
+ return to(from(args));
1596
+ };
1597
+ }
1598
+
1599
+ function wrapConversion(toModel, graph) {
1600
+ const path = [graph[toModel].parent, toModel];
1601
+ let fn = conversions[graph[toModel].parent][toModel];
1602
+
1603
+ let cur = graph[toModel].parent;
1604
+ while (graph[cur].parent) {
1605
+ path.unshift(graph[cur].parent);
1606
+ fn = link(conversions[graph[cur].parent][cur], fn);
1607
+ cur = graph[cur].parent;
1608
+ }
1609
+
1610
+ fn.conversion = path;
1611
+ return fn;
1612
+ }
1613
+
1614
+ module.exports = function (fromModel) {
1615
+ const graph = deriveBFS(fromModel);
1616
+ const conversion = {};
1617
+
1618
+ const models = Object.keys(graph);
1619
+ for (let len = models.length, i = 0; i < len; i++) {
1620
+ const toModel = models[i];
1621
+ const node = graph[toModel];
1622
+
1623
+ if (node.parent === null) {
1624
+ // No possible conversion, or this node is the source model.
1625
+ continue;
1626
+ }
1627
+
1628
+ conversion[toModel] = wrapConversion(toModel, graph);
1629
+ }
1630
+
1631
+ return conversion;
1632
+ };
1633
+
1634
+
1635
+
1636
+ /***/ }),
1637
+
1638
+ /***/ 953:
1639
+ /***/ ((module) => {
1640
+
1641
+
1642
+
1643
+ module.exports = {
1644
+ "aliceblue": [240, 248, 255],
1645
+ "antiquewhite": [250, 235, 215],
1646
+ "aqua": [0, 255, 255],
1647
+ "aquamarine": [127, 255, 212],
1648
+ "azure": [240, 255, 255],
1649
+ "beige": [245, 245, 220],
1650
+ "bisque": [255, 228, 196],
1651
+ "black": [0, 0, 0],
1652
+ "blanchedalmond": [255, 235, 205],
1653
+ "blue": [0, 0, 255],
1654
+ "blueviolet": [138, 43, 226],
1655
+ "brown": [165, 42, 42],
1656
+ "burlywood": [222, 184, 135],
1657
+ "cadetblue": [95, 158, 160],
1658
+ "chartreuse": [127, 255, 0],
1659
+ "chocolate": [210, 105, 30],
1660
+ "coral": [255, 127, 80],
1661
+ "cornflowerblue": [100, 149, 237],
1662
+ "cornsilk": [255, 248, 220],
1663
+ "crimson": [220, 20, 60],
1664
+ "cyan": [0, 255, 255],
1665
+ "darkblue": [0, 0, 139],
1666
+ "darkcyan": [0, 139, 139],
1667
+ "darkgoldenrod": [184, 134, 11],
1668
+ "darkgray": [169, 169, 169],
1669
+ "darkgreen": [0, 100, 0],
1670
+ "darkgrey": [169, 169, 169],
1671
+ "darkkhaki": [189, 183, 107],
1672
+ "darkmagenta": [139, 0, 139],
1673
+ "darkolivegreen": [85, 107, 47],
1674
+ "darkorange": [255, 140, 0],
1675
+ "darkorchid": [153, 50, 204],
1676
+ "darkred": [139, 0, 0],
1677
+ "darksalmon": [233, 150, 122],
1678
+ "darkseagreen": [143, 188, 143],
1679
+ "darkslateblue": [72, 61, 139],
1680
+ "darkslategray": [47, 79, 79],
1681
+ "darkslategrey": [47, 79, 79],
1682
+ "darkturquoise": [0, 206, 209],
1683
+ "darkviolet": [148, 0, 211],
1684
+ "deeppink": [255, 20, 147],
1685
+ "deepskyblue": [0, 191, 255],
1686
+ "dimgray": [105, 105, 105],
1687
+ "dimgrey": [105, 105, 105],
1688
+ "dodgerblue": [30, 144, 255],
1689
+ "firebrick": [178, 34, 34],
1690
+ "floralwhite": [255, 250, 240],
1691
+ "forestgreen": [34, 139, 34],
1692
+ "fuchsia": [255, 0, 255],
1693
+ "gainsboro": [220, 220, 220],
1694
+ "ghostwhite": [248, 248, 255],
1695
+ "gold": [255, 215, 0],
1696
+ "goldenrod": [218, 165, 32],
1697
+ "gray": [128, 128, 128],
1698
+ "green": [0, 128, 0],
1699
+ "greenyellow": [173, 255, 47],
1700
+ "grey": [128, 128, 128],
1701
+ "honeydew": [240, 255, 240],
1702
+ "hotpink": [255, 105, 180],
1703
+ "indianred": [205, 92, 92],
1704
+ "indigo": [75, 0, 130],
1705
+ "ivory": [255, 255, 240],
1706
+ "khaki": [240, 230, 140],
1707
+ "lavender": [230, 230, 250],
1708
+ "lavenderblush": [255, 240, 245],
1709
+ "lawngreen": [124, 252, 0],
1710
+ "lemonchiffon": [255, 250, 205],
1711
+ "lightblue": [173, 216, 230],
1712
+ "lightcoral": [240, 128, 128],
1713
+ "lightcyan": [224, 255, 255],
1714
+ "lightgoldenrodyellow": [250, 250, 210],
1715
+ "lightgray": [211, 211, 211],
1716
+ "lightgreen": [144, 238, 144],
1717
+ "lightgrey": [211, 211, 211],
1718
+ "lightpink": [255, 182, 193],
1719
+ "lightsalmon": [255, 160, 122],
1720
+ "lightseagreen": [32, 178, 170],
1721
+ "lightskyblue": [135, 206, 250],
1722
+ "lightslategray": [119, 136, 153],
1723
+ "lightslategrey": [119, 136, 153],
1724
+ "lightsteelblue": [176, 196, 222],
1725
+ "lightyellow": [255, 255, 224],
1726
+ "lime": [0, 255, 0],
1727
+ "limegreen": [50, 205, 50],
1728
+ "linen": [250, 240, 230],
1729
+ "magenta": [255, 0, 255],
1730
+ "maroon": [128, 0, 0],
1731
+ "mediumaquamarine": [102, 205, 170],
1732
+ "mediumblue": [0, 0, 205],
1733
+ "mediumorchid": [186, 85, 211],
1734
+ "mediumpurple": [147, 112, 219],
1735
+ "mediumseagreen": [60, 179, 113],
1736
+ "mediumslateblue": [123, 104, 238],
1737
+ "mediumspringgreen": [0, 250, 154],
1738
+ "mediumturquoise": [72, 209, 204],
1739
+ "mediumvioletred": [199, 21, 133],
1740
+ "midnightblue": [25, 25, 112],
1741
+ "mintcream": [245, 255, 250],
1742
+ "mistyrose": [255, 228, 225],
1743
+ "moccasin": [255, 228, 181],
1744
+ "navajowhite": [255, 222, 173],
1745
+ "navy": [0, 0, 128],
1746
+ "oldlace": [253, 245, 230],
1747
+ "olive": [128, 128, 0],
1748
+ "olivedrab": [107, 142, 35],
1749
+ "orange": [255, 165, 0],
1750
+ "orangered": [255, 69, 0],
1751
+ "orchid": [218, 112, 214],
1752
+ "palegoldenrod": [238, 232, 170],
1753
+ "palegreen": [152, 251, 152],
1754
+ "paleturquoise": [175, 238, 238],
1755
+ "palevioletred": [219, 112, 147],
1756
+ "papayawhip": [255, 239, 213],
1757
+ "peachpuff": [255, 218, 185],
1758
+ "peru": [205, 133, 63],
1759
+ "pink": [255, 192, 203],
1760
+ "plum": [221, 160, 221],
1761
+ "powderblue": [176, 224, 230],
1762
+ "purple": [128, 0, 128],
1763
+ "rebeccapurple": [102, 51, 153],
1764
+ "red": [255, 0, 0],
1765
+ "rosybrown": [188, 143, 143],
1766
+ "royalblue": [65, 105, 225],
1767
+ "saddlebrown": [139, 69, 19],
1768
+ "salmon": [250, 128, 114],
1769
+ "sandybrown": [244, 164, 96],
1770
+ "seagreen": [46, 139, 87],
1771
+ "seashell": [255, 245, 238],
1772
+ "sienna": [160, 82, 45],
1773
+ "silver": [192, 192, 192],
1774
+ "skyblue": [135, 206, 235],
1775
+ "slateblue": [106, 90, 205],
1776
+ "slategray": [112, 128, 144],
1777
+ "slategrey": [112, 128, 144],
1778
+ "snow": [255, 250, 250],
1779
+ "springgreen": [0, 255, 127],
1780
+ "steelblue": [70, 130, 180],
1781
+ "tan": [210, 180, 140],
1782
+ "teal": [0, 128, 128],
1783
+ "thistle": [216, 191, 216],
1784
+ "tomato": [255, 99, 71],
1785
+ "turquoise": [64, 224, 208],
1786
+ "violet": [238, 130, 238],
1787
+ "wheat": [245, 222, 179],
1788
+ "white": [255, 255, 255],
1789
+ "whitesmoke": [245, 245, 245],
1790
+ "yellow": [255, 255, 0],
1791
+ "yellowgreen": [154, 205, 50]
1792
+ };
1793
+
1794
+
1795
+ /***/ }),
1796
+
1797
+ /***/ 813:
1798
+ /***/ ((module) => {
1799
+
1800
+
1801
+
1802
+ module.exports = (flag, argv = process.argv) => {
1803
+ const prefix = flag.startsWith('-') ? '' : (flag.length === 1 ? '-' : '--');
1804
+ const position = argv.indexOf(prefix + flag);
1805
+ const terminatorPosition = argv.indexOf('--');
1806
+ return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
1807
+ };
1808
+
1809
+
1810
+ /***/ }),
1811
+
6
1812
  /***/ 316:
7
1813
  /***/ ((__unused_webpack_module, __webpack_exports__, __nccwpck_require__) => {
8
1814
 
@@ -12,7 +1818,7 @@ import { createRequire as __WEBPACK_EXTERNAL_createRequire } from "module";
12
1818
  /* harmony export */ qA: () => (/* binding */ THEME_TYPES),
13
1819
  /* harmony export */ yp: () => (/* binding */ CUSTOM_HANDLER_ENV_NAMES)
14
1820
  /* harmony export */ });
15
- /* unused harmony exports WELL_KNOWN_DIRECTORY_BASE_NAME, VITE_PLUGIN_SUB_SCRIPTS_ENV_NAMES, BUILD_FOR_KEYCLOAK_MAJOR_VERSION_ENV_NAME, CONTAINER_NAME, FALLBACK_LANGUAGE_TAG, KEYCLOAK_THEME */
1821
+ /* unused harmony exports WELL_KNOWN_DIRECTORY_BASE_NAME, VITE_PLUGIN_SUB_SCRIPTS_ENV_NAMES, BUILD_FOR_KEYCLOAK_MAJOR_VERSION_ENV_NAME, CONTAINER_NAME, FALLBACK_LANGUAGE_TAG, KEYCLOAK_THEME, KEYCLOAKIFY_SPA_DEV_SERVER_PORT, KEYCLOAKIFY_LOGGING_VERSION, KEYCLOAKIFY_LOGIN_JAR_BASENAME, TEST_APP_URL */
16
1822
  const WELL_KNOWN_DIRECTORY_BASE_NAME = {
17
1823
  KEYCLOAKIFY_DEV_RESOURCES: "keycloakify-dev-resources",
18
1824
  RESOURCES_COMMON: "resources-common",
@@ -21,7 +1827,8 @@ const WELL_KNOWN_DIRECTORY_BASE_NAME = {
21
1827
  const THEME_TYPES = ["login", "account", "admin"];
22
1828
  const VITE_PLUGIN_SUB_SCRIPTS_ENV_NAMES = {
23
1829
  RUN_POST_BUILD_SCRIPT: "KEYCLOAKIFY_RUN_POST_BUILD_SCRIPT",
24
- RESOLVE_VITE_CONFIG: "KEYCLOAKIFY_RESOLVE_VITE_CONFIG"
1830
+ RESOLVE_VITE_CONFIG: "KEYCLOAKIFY_RESOLVE_VITE_CONFIG",
1831
+ READ_KC_CONTEXT_FROM_URL: "KEYCLOAKIFY_READ_KC_CONTEXT_FROM_URL"
25
1832
  };
26
1833
  const BUILD_FOR_KEYCLOAK_MAJOR_VERSION_ENV_NAME = "KEYCLOAKIFY_BUILD_FOR_KEYCLOAK_MAJOR_VERSION";
27
1834
  const LOGIN_THEME_PAGE_IDS = [
@@ -78,8 +1885,154 @@ const CUSTOM_HANDLER_ENV_NAMES = {
78
1885
  BUILD_CONTEXT: "KEYCLOAKIFY_BUILD_CONTEXT"
79
1886
  };
80
1887
  const KEYCLOAK_THEME = "keycloak-theme";
1888
+ const KEYCLOAKIFY_SPA_DEV_SERVER_PORT = "KEYCLOAKIFY_SPA_DEV_SERVER_PORT";
1889
+ const KEYCLOAKIFY_LOGGING_VERSION = "1.0.3";
1890
+ const KEYCLOAKIFY_LOGIN_JAR_BASENAME = (/* unused pure expression or super */ null && (`keycloakify-logging-${KEYCLOAKIFY_LOGGING_VERSION}.jar`));
1891
+ const TEST_APP_URL = "https://my-theme.keycloakify.dev";
81
1892
  //# sourceMappingURL=constants.js.map
82
1893
 
1894
+ /***/ }),
1895
+
1896
+ /***/ 450:
1897
+ /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
1898
+
1899
+
1900
+ const os = __nccwpck_require__(857);
1901
+ const tty = __nccwpck_require__(18);
1902
+ const hasFlag = __nccwpck_require__(813);
1903
+
1904
+ const {env} = process;
1905
+
1906
+ let forceColor;
1907
+ if (hasFlag('no-color') ||
1908
+ hasFlag('no-colors') ||
1909
+ hasFlag('color=false') ||
1910
+ hasFlag('color=never')) {
1911
+ forceColor = 0;
1912
+ } else if (hasFlag('color') ||
1913
+ hasFlag('colors') ||
1914
+ hasFlag('color=true') ||
1915
+ hasFlag('color=always')) {
1916
+ forceColor = 1;
1917
+ }
1918
+
1919
+ if ('FORCE_COLOR' in env) {
1920
+ if (env.FORCE_COLOR === 'true') {
1921
+ forceColor = 1;
1922
+ } else if (env.FORCE_COLOR === 'false') {
1923
+ forceColor = 0;
1924
+ } else {
1925
+ forceColor = env.FORCE_COLOR.length === 0 ? 1 : Math.min(parseInt(env.FORCE_COLOR, 10), 3);
1926
+ }
1927
+ }
1928
+
1929
+ function translateLevel(level) {
1930
+ if (level === 0) {
1931
+ return false;
1932
+ }
1933
+
1934
+ return {
1935
+ level,
1936
+ hasBasic: true,
1937
+ has256: level >= 2,
1938
+ has16m: level >= 3
1939
+ };
1940
+ }
1941
+
1942
+ function supportsColor(haveStream, streamIsTTY) {
1943
+ if (forceColor === 0) {
1944
+ return 0;
1945
+ }
1946
+
1947
+ if (hasFlag('color=16m') ||
1948
+ hasFlag('color=full') ||
1949
+ hasFlag('color=truecolor')) {
1950
+ return 3;
1951
+ }
1952
+
1953
+ if (hasFlag('color=256')) {
1954
+ return 2;
1955
+ }
1956
+
1957
+ if (haveStream && !streamIsTTY && forceColor === undefined) {
1958
+ return 0;
1959
+ }
1960
+
1961
+ const min = forceColor || 0;
1962
+
1963
+ if (env.TERM === 'dumb') {
1964
+ return min;
1965
+ }
1966
+
1967
+ if (process.platform === 'win32') {
1968
+ // Windows 10 build 10586 is the first Windows release that supports 256 colors.
1969
+ // Windows 10 build 14931 is the first release that supports 16m/TrueColor.
1970
+ const osRelease = os.release().split('.');
1971
+ if (
1972
+ Number(osRelease[0]) >= 10 &&
1973
+ Number(osRelease[2]) >= 10586
1974
+ ) {
1975
+ return Number(osRelease[2]) >= 14931 ? 3 : 2;
1976
+ }
1977
+
1978
+ return 1;
1979
+ }
1980
+
1981
+ if ('CI' in env) {
1982
+ if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI', 'GITHUB_ACTIONS', 'BUILDKITE'].some(sign => sign in env) || env.CI_NAME === 'codeship') {
1983
+ return 1;
1984
+ }
1985
+
1986
+ return min;
1987
+ }
1988
+
1989
+ if ('TEAMCITY_VERSION' in env) {
1990
+ return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
1991
+ }
1992
+
1993
+ if (env.COLORTERM === 'truecolor') {
1994
+ return 3;
1995
+ }
1996
+
1997
+ if ('TERM_PROGRAM' in env) {
1998
+ const version = parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10);
1999
+
2000
+ switch (env.TERM_PROGRAM) {
2001
+ case 'iTerm.app':
2002
+ return version >= 3 ? 3 : 2;
2003
+ case 'Apple_Terminal':
2004
+ return 2;
2005
+ // No default
2006
+ }
2007
+ }
2008
+
2009
+ if (/-256(color)?$/i.test(env.TERM)) {
2010
+ return 2;
2011
+ }
2012
+
2013
+ if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
2014
+ return 1;
2015
+ }
2016
+
2017
+ if ('COLORTERM' in env) {
2018
+ return 1;
2019
+ }
2020
+
2021
+ return min;
2022
+ }
2023
+
2024
+ function getSupportLevel(stream) {
2025
+ const level = supportsColor(stream, stream && stream.isTTY);
2026
+ return translateLevel(level);
2027
+ }
2028
+
2029
+ module.exports = {
2030
+ supportsColor: getSupportLevel,
2031
+ stdout: translateLevel(supportsColor(true, tty.isatty(1))),
2032
+ stderr: translateLevel(supportsColor(true, tty.isatty(2)))
2033
+ };
2034
+
2035
+
83
2036
  /***/ }),
84
2037
 
85
2038
  /***/ 261:
@@ -430,6 +2383,9 @@ function is(value) {
430
2383
  /************************************************************************/
431
2384
  var __webpack_exports__ = {};
432
2385
 
2386
+ // EXTERNAL MODULE: ./node_modules/chalk/source/index.js
2387
+ var source = __nccwpck_require__(465);
2388
+ var source_default = /*#__PURE__*/__nccwpck_require__.n(source);
433
2389
  // EXTERNAL MODULE: ./node_modules/tsafe/esm/assert.mjs + 1 modules
434
2390
  var assert = __nccwpck_require__(966);
435
2391
  // EXTERNAL MODULE: ./node_modules/keycloakify/bin/shared/constants.js
@@ -457,33 +2413,40 @@ function readParams(params) {
457
2413
  //# sourceMappingURL=customHandler.js.map
458
2414
  ;// CONCATENATED MODULE: ./dist/keycloakify-svelte/bin/main.ts
459
2415
 
2416
+
460
2417
  const { buildContext, commandName } = readParams({ apiVersion: 'v1' });
461
2418
  (async () => {
462
2419
  switch (commandName) {
463
2420
  case 'add-story':
464
2421
  {
465
- const { command } = await Promise.all(/* import() */[__nccwpck_require__.e(17), __nccwpck_require__.e(266)]).then(__nccwpck_require__.bind(__nccwpck_require__, 266));
2422
+ const { command } = await __nccwpck_require__.e(/* import() */ 266).then(__nccwpck_require__.bind(__nccwpck_require__, 266));
466
2423
  command({ buildContext });
467
2424
  }
468
2425
  return;
469
2426
  case 'eject-page':
470
2427
  {
471
- const { command } = await Promise.all(/* import() */[__nccwpck_require__.e(17), __nccwpck_require__.e(818)]).then(__nccwpck_require__.bind(__nccwpck_require__, 818));
2428
+ const { command } = await __nccwpck_require__.e(/* import() */ 818).then(__nccwpck_require__.bind(__nccwpck_require__, 818));
472
2429
  command({ buildContext });
473
2430
  }
474
2431
  return;
475
2432
  case 'update-kc-gen':
476
2433
  {
477
- const { command } = await Promise.all(/* import() */[__nccwpck_require__.e(17), __nccwpck_require__.e(200)]).then(__nccwpck_require__.bind(__nccwpck_require__, 819));
2434
+ const { command } = await __nccwpck_require__.e(/* import() */ 200).then(__nccwpck_require__.bind(__nccwpck_require__, 819));
478
2435
  command({ buildContext });
479
2436
  }
480
2437
  return;
481
2438
  case 'initialize-account-theme':
482
2439
  {
483
- const { command } = await Promise.all(/* import() */[__nccwpck_require__.e(17), __nccwpck_require__.e(383), __nccwpck_require__.e(709)]).then(__nccwpck_require__.bind(__nccwpck_require__, 709));
2440
+ const { command } = await Promise.all(/* import() */[__nccwpck_require__.e(279), __nccwpck_require__.e(709)]).then(__nccwpck_require__.bind(__nccwpck_require__, 709));
484
2441
  command({ buildContext });
485
2442
  }
486
2443
  return;
2444
+ case 'initialize-admin-theme':
2445
+ {
2446
+ console.log(source_default().red('Cannot create an admin theme when using Svelte.'));
2447
+ process.exit(1);
2448
+ }
2449
+ return;
487
2450
  default:
488
2451
  process.exit(NOT_IMPLEMENTED_EXIT_CODE);
489
2452
  }