css-color-parser-h 3.0.9 → 3.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -95,7 +95,7 @@ export default class CssColorParser {
95
95
  * @description: 返回ColorJson
96
96
  * @return {ColorJson}
97
97
  */
98
- toJson(): ColorJson;
98
+ toJson(isLimit:boolean, colorPrecision?:number, alphaPrecision?:number): ColorJson;
99
99
  /**
100
100
  * @description: 返回取反色后的新的实例
101
101
  * @return {CssColorParser}
@@ -164,8 +164,8 @@ export default class CssColorParserPlus extends CssColorParser {
164
164
  * @example: CssColorParserPlus.fromRandom('black', new CssColorParserPlus(255,255,255,1))
165
165
  */
166
166
  static fromRandom(
167
- color1: CssColorParserPlus | string,
168
- color2: CssColorParserPlus | string
167
+ color1?: CssColorParserPlus | string,
168
+ color2?: CssColorParserPlus | string
169
169
  ): CssColorParserPlus;
170
170
  /**
171
171
  * @description: 颜色序列化数组转换为CssColorParserPlus对象实例
package/example.html CHANGED
@@ -2,7 +2,7 @@
2
2
  * @Author: roman_123
3
3
  * @Description:
4
4
  * @Date: 2022-12-06 11:15:17
5
- * @LastEditTime: 2023-06-27 19:24:53
5
+ * @LastEditTime: 2026-02-25 14:56:54
6
6
  -->
7
7
  <!DOCTYPE html>
8
8
  <html lang="en">
@@ -23,11 +23,11 @@
23
23
  <body>
24
24
  <h2>f12 to view console log</h2>
25
25
  <script>
26
- const cssColorParser = new Parser.CssColorParserPlus()
26
+ const cssColorParser = new Parser.CssColorParserPlus(100.2,200.3,200.4,0.88123)
27
27
  console.log(cssColorParser.toHEX())
28
28
  console.log(cssColorParser.toRGBA())
29
29
  cssColorParser.add('#333').add('red')
30
- console.log(cssColorParser.toRGBA())
30
+ console.log(cssColorParser)
31
31
  cssColorParser.subtract('blue', false)
32
32
  console.log(cssColorParser.toRGBA())
33
33
  const lerpedColor = Parser.CssColorParserPlus.lerp({
@@ -211,8 +211,8 @@ var CssColorStringParser = /** @class */ (function () {
211
211
  * @version: 1.0.0
212
212
  * @Author: roman_123
213
213
  * @Date: 2021-01-19 09:22:11
214
- * @LastEditors: Please set LastEditors
215
- * @LastEditTime: 2023-06-27 19:01:50
214
+ * @LastEditors: zhangyu 306863030@qq.com
215
+ * @LastEditTime: 2026-02-25 14:59:49
216
216
  */
217
217
  var CssColorParser = /** @class */ (function () {
218
218
  function CssColorParser(red, green, blue, alpha) {
@@ -331,39 +331,36 @@ var CssColorParser = /** @class */ (function () {
331
331
  * @return {array}
332
332
  */
333
333
  CssColorParser.prototype.toNormalize = function () {
334
- var r = setNumberPrecision(this.r / 255, this._outColorPrecision);
335
- var g = setNumberPrecision(this.g / 255, this._outColorPrecision);
336
- var b = setNumberPrecision(this.b / 255, this._outColorPrecision);
337
- var a = setNumberPrecision(this.a, this._outAlphaPrecision);
338
- return [r, g, b, a];
334
+ var _a = this.toJson(), r = _a.r, g = _a.g, b = _a.b, a = _a.a;
335
+ return [r / 255, g / 255, b / 255, a];
339
336
  };
340
337
  /**
341
338
  * @description: 返回16进制格式的css字符串
342
339
  * @return {string}
343
340
  */
344
341
  CssColorParser.prototype.toHEX = function () {
345
- var color = this.toJson();
346
- var r = color.r.toString(16);
347
- if (r.length < 2) {
348
- r = "0".concat(r);
342
+ var _a = this.toJson(true, 0, 0), r = _a.r, g = _a.g, b = _a.b;
343
+ var red = r.toString(16);
344
+ if (red.length < 2) {
345
+ red = "0".concat(red);
349
346
  }
350
- var g = color.g.toString(16);
351
- if (g.length < 2) {
352
- g = "0".concat(g);
347
+ var green = g.toString(16);
348
+ if (green.length < 2) {
349
+ green = "0".concat(green);
353
350
  }
354
- var b = color.b.toString(16);
355
- if (b.length < 2) {
356
- b = "0".concat(b);
351
+ var blue = b.toString(16);
352
+ if (blue.length < 2) {
353
+ blue = "0".concat(blue);
357
354
  }
358
355
  // 由于tojson后a会丢失精度,此处使用this.a
359
356
  if (this.a < 1) {
360
- var hexAlpha = parseInt((this.a * 255).toFixed()).toString(16);
357
+ var hexAlpha = setNumberPrecision(this.a * 255, 0).toString(16);
361
358
  if (hexAlpha.length < 2) {
362
359
  hexAlpha = "0".concat(hexAlpha);
363
360
  }
364
- return "#".concat(r).concat(g).concat(b).concat(hexAlpha);
361
+ return "#".concat(red).concat(green).concat(blue).concat(hexAlpha);
365
362
  }
366
- return "#".concat(r).concat(g).concat(b);
363
+ return "#".concat(red).concat(green).concat(blue);
367
364
  };
368
365
  /**
369
366
  * @description: 返回rgba数组
@@ -377,12 +374,25 @@ var CssColorParser = /** @class */ (function () {
377
374
  * @description: 返回ColorJson
378
375
  * @return {ColorJson}
379
376
  */
380
- CssColorParser.prototype.toJson = function () {
377
+ CssColorParser.prototype.toJson = function (isLimit, colorPrecision, alphaPrecision) {
378
+ if (isLimit === void 0) { isLimit = true; }
379
+ if (colorPrecision === void 0) { colorPrecision = this._outColorPrecision; }
380
+ if (alphaPrecision === void 0) { alphaPrecision = this._outAlphaPrecision; }
381
+ var r = this.r;
382
+ var g = this.g;
383
+ var b = this.b;
384
+ var a = this.a;
385
+ if (isLimit) {
386
+ r = limitNumber(0, 255, this.r);
387
+ g = limitNumber(0, 255, this.g);
388
+ b = limitNumber(0, 255, this.b);
389
+ a = limitNumber(0, 1, this.a);
390
+ }
381
391
  return {
382
- r: setNumberPrecision(this.r, this._outColorPrecision),
383
- g: setNumberPrecision(this.g, this._outColorPrecision),
384
- b: setNumberPrecision(this.b, this._outColorPrecision),
385
- a: setNumberPrecision(this.a, this._outAlphaPrecision),
392
+ r: setNumberPrecision(r, colorPrecision),
393
+ g: setNumberPrecision(g, colorPrecision),
394
+ b: setNumberPrecision(b, colorPrecision),
395
+ a: setNumberPrecision(a, alphaPrecision),
386
396
  };
387
397
  };
388
398
  /**
@@ -390,10 +400,11 @@ var CssColorParser = /** @class */ (function () {
390
400
  * @return {CssColorParser}
391
401
  */
392
402
  CssColorParser.prototype.toInvert = function () {
393
- var r = 255 - this.r;
394
- var g = 255 - this.g;
395
- var b = 255 - this.b;
396
- var a = 1 - this.a;
403
+ var _a = this.toJson(), r = _a.r, g = _a.g, b = _a.b, a = _a.a;
404
+ r = 255 - this.r;
405
+ g = 255 - this.g;
406
+ b = 255 - this.b;
407
+ a = 1 - this.a;
397
408
  return new CssColorParser(r, g, b, a);
398
409
  };
399
410
  /**
@@ -401,7 +412,10 @@ var CssColorParser = /** @class */ (function () {
401
412
  * @return {CssColorParser}
402
413
  */
403
414
  CssColorParser.prototype.clone = function () {
404
- return new CssColorParser(this.r, this.g, this.b, this.a);
415
+ var newParser = new CssColorParser(this.r, this.g, this.b, this.a);
416
+ newParser._outColorPrecision = this._outColorPrecision;
417
+ newParser._outAlphaPrecision = this._outAlphaPrecision;
418
+ return newParser;
405
419
  };
406
420
  /**
407
421
  * @description: 比较两个解析对象的数据是否相等
@@ -426,10 +440,11 @@ var CssColorParser = /** @class */ (function () {
426
440
  * @return {CssColorParser}
427
441
  */
428
442
  CssColorParser.prototype.setInvert = function () {
429
- this.r = 255 - this.r;
430
- this.g = 255 - this.g;
431
- this.b = 255 - this.b;
432
- this.a = 1 - this.a;
443
+ var _a = this.toJson(), r = _a.r, g = _a.g, b = _a.b, a = _a.a;
444
+ this.r = 255 - r;
445
+ this.g = 255 - g;
446
+ this.b = 255 - b;
447
+ this.a = 1 - a;
433
448
  return this;
434
449
  };
435
450
  /**
@@ -660,10 +675,11 @@ var CssColorParserPlus = /** @class */ (function (_super) {
660
675
  * @return {CssColorParserPlus}
661
676
  */
662
677
  CssColorParserPlus.prototype.toInvert = function () {
663
- var r = 255 - this.r;
664
- var g = 255 - this.g;
665
- var b = 255 - this.b;
666
- var a = 1 - this.a;
678
+ var _a = this.toJson(), r = _a.r, g = _a.g, b = _a.b, a = _a.a;
679
+ r = 255 - this.r;
680
+ g = 255 - this.g;
681
+ b = 255 - this.b;
682
+ a = 1 - this.a;
667
683
  return new CssColorParserPlus(r, g, b, a);
668
684
  };
669
685
  /**
@@ -671,7 +687,10 @@ var CssColorParserPlus = /** @class */ (function (_super) {
671
687
  * @return {CssColorParserPlus}
672
688
  */
673
689
  CssColorParserPlus.prototype.clone = function () {
674
- return new CssColorParserPlus(this.r, this.g, this.b, this.a);
690
+ var newParser = new CssColorParserPlus(this.r, this.g, this.b, this.a);
691
+ newParser._outColorPrecision = this._outColorPrecision;
692
+ newParser._outAlphaPrecision = this._outAlphaPrecision;
693
+ return newParser;
675
694
  };
676
695
  /**
677
696
  * @description: 比较两个解析对象的数据是否相等
@@ -878,6 +897,8 @@ var CssColorParserPlus = /** @class */ (function (_super) {
878
897
  * @example: CssColorParserPlus.fromRandom('black', new CssColorParserPlus(255,255,255,1))
879
898
  */
880
899
  CssColorParserPlus.fromRandom = function (color1, color2) {
900
+ if (color1 === void 0) { color1 = new CssColorParserPlus(0, 0, 0, 1); }
901
+ if (color2 === void 0) { color2 = new CssColorParserPlus(255, 255, 255, 1); }
881
902
  color1 = CssColorParserPlus.parseColor(color1);
882
903
  color2 = CssColorParserPlus.parseColor(color2);
883
904
  var r = Math.random() * Math.abs(color2.r - color1.r) +
@@ -209,8 +209,8 @@ var CssColorStringParser = /** @class */ (function () {
209
209
  * @version: 1.0.0
210
210
  * @Author: roman_123
211
211
  * @Date: 2021-01-19 09:22:11
212
- * @LastEditors: Please set LastEditors
213
- * @LastEditTime: 2023-06-27 19:01:50
212
+ * @LastEditors: zhangyu 306863030@qq.com
213
+ * @LastEditTime: 2026-02-25 14:59:49
214
214
  */
215
215
  var CssColorParser = /** @class */ (function () {
216
216
  function CssColorParser(red, green, blue, alpha) {
@@ -329,39 +329,36 @@ var CssColorParser = /** @class */ (function () {
329
329
  * @return {array}
330
330
  */
331
331
  CssColorParser.prototype.toNormalize = function () {
332
- var r = setNumberPrecision(this.r / 255, this._outColorPrecision);
333
- var g = setNumberPrecision(this.g / 255, this._outColorPrecision);
334
- var b = setNumberPrecision(this.b / 255, this._outColorPrecision);
335
- var a = setNumberPrecision(this.a, this._outAlphaPrecision);
336
- return [r, g, b, a];
332
+ var _a = this.toJson(), r = _a.r, g = _a.g, b = _a.b, a = _a.a;
333
+ return [r / 255, g / 255, b / 255, a];
337
334
  };
338
335
  /**
339
336
  * @description: 返回16进制格式的css字符串
340
337
  * @return {string}
341
338
  */
342
339
  CssColorParser.prototype.toHEX = function () {
343
- var color = this.toJson();
344
- var r = color.r.toString(16);
345
- if (r.length < 2) {
346
- r = "0".concat(r);
340
+ var _a = this.toJson(true, 0, 0), r = _a.r, g = _a.g, b = _a.b;
341
+ var red = r.toString(16);
342
+ if (red.length < 2) {
343
+ red = "0".concat(red);
347
344
  }
348
- var g = color.g.toString(16);
349
- if (g.length < 2) {
350
- g = "0".concat(g);
345
+ var green = g.toString(16);
346
+ if (green.length < 2) {
347
+ green = "0".concat(green);
351
348
  }
352
- var b = color.b.toString(16);
353
- if (b.length < 2) {
354
- b = "0".concat(b);
349
+ var blue = b.toString(16);
350
+ if (blue.length < 2) {
351
+ blue = "0".concat(blue);
355
352
  }
356
353
  // 由于tojson后a会丢失精度,此处使用this.a
357
354
  if (this.a < 1) {
358
- var hexAlpha = parseInt((this.a * 255).toFixed()).toString(16);
355
+ var hexAlpha = setNumberPrecision(this.a * 255, 0).toString(16);
359
356
  if (hexAlpha.length < 2) {
360
357
  hexAlpha = "0".concat(hexAlpha);
361
358
  }
362
- return "#".concat(r).concat(g).concat(b).concat(hexAlpha);
359
+ return "#".concat(red).concat(green).concat(blue).concat(hexAlpha);
363
360
  }
364
- return "#".concat(r).concat(g).concat(b);
361
+ return "#".concat(red).concat(green).concat(blue);
365
362
  };
366
363
  /**
367
364
  * @description: 返回rgba数组
@@ -375,12 +372,25 @@ var CssColorParser = /** @class */ (function () {
375
372
  * @description: 返回ColorJson
376
373
  * @return {ColorJson}
377
374
  */
378
- CssColorParser.prototype.toJson = function () {
375
+ CssColorParser.prototype.toJson = function (isLimit, colorPrecision, alphaPrecision) {
376
+ if (isLimit === void 0) { isLimit = true; }
377
+ if (colorPrecision === void 0) { colorPrecision = this._outColorPrecision; }
378
+ if (alphaPrecision === void 0) { alphaPrecision = this._outAlphaPrecision; }
379
+ var r = this.r;
380
+ var g = this.g;
381
+ var b = this.b;
382
+ var a = this.a;
383
+ if (isLimit) {
384
+ r = limitNumber(0, 255, this.r);
385
+ g = limitNumber(0, 255, this.g);
386
+ b = limitNumber(0, 255, this.b);
387
+ a = limitNumber(0, 1, this.a);
388
+ }
379
389
  return {
380
- r: setNumberPrecision(this.r, this._outColorPrecision),
381
- g: setNumberPrecision(this.g, this._outColorPrecision),
382
- b: setNumberPrecision(this.b, this._outColorPrecision),
383
- a: setNumberPrecision(this.a, this._outAlphaPrecision),
390
+ r: setNumberPrecision(r, colorPrecision),
391
+ g: setNumberPrecision(g, colorPrecision),
392
+ b: setNumberPrecision(b, colorPrecision),
393
+ a: setNumberPrecision(a, alphaPrecision),
384
394
  };
385
395
  };
386
396
  /**
@@ -388,10 +398,11 @@ var CssColorParser = /** @class */ (function () {
388
398
  * @return {CssColorParser}
389
399
  */
390
400
  CssColorParser.prototype.toInvert = function () {
391
- var r = 255 - this.r;
392
- var g = 255 - this.g;
393
- var b = 255 - this.b;
394
- var a = 1 - this.a;
401
+ var _a = this.toJson(), r = _a.r, g = _a.g, b = _a.b, a = _a.a;
402
+ r = 255 - this.r;
403
+ g = 255 - this.g;
404
+ b = 255 - this.b;
405
+ a = 1 - this.a;
395
406
  return new CssColorParser(r, g, b, a);
396
407
  };
397
408
  /**
@@ -399,7 +410,10 @@ var CssColorParser = /** @class */ (function () {
399
410
  * @return {CssColorParser}
400
411
  */
401
412
  CssColorParser.prototype.clone = function () {
402
- return new CssColorParser(this.r, this.g, this.b, this.a);
413
+ var newParser = new CssColorParser(this.r, this.g, this.b, this.a);
414
+ newParser._outColorPrecision = this._outColorPrecision;
415
+ newParser._outAlphaPrecision = this._outAlphaPrecision;
416
+ return newParser;
403
417
  };
404
418
  /**
405
419
  * @description: 比较两个解析对象的数据是否相等
@@ -424,10 +438,11 @@ var CssColorParser = /** @class */ (function () {
424
438
  * @return {CssColorParser}
425
439
  */
426
440
  CssColorParser.prototype.setInvert = function () {
427
- this.r = 255 - this.r;
428
- this.g = 255 - this.g;
429
- this.b = 255 - this.b;
430
- this.a = 1 - this.a;
441
+ var _a = this.toJson(), r = _a.r, g = _a.g, b = _a.b, a = _a.a;
442
+ this.r = 255 - r;
443
+ this.g = 255 - g;
444
+ this.b = 255 - b;
445
+ this.a = 1 - a;
431
446
  return this;
432
447
  };
433
448
  /**
@@ -658,10 +673,11 @@ var CssColorParserPlus = /** @class */ (function (_super) {
658
673
  * @return {CssColorParserPlus}
659
674
  */
660
675
  CssColorParserPlus.prototype.toInvert = function () {
661
- var r = 255 - this.r;
662
- var g = 255 - this.g;
663
- var b = 255 - this.b;
664
- var a = 1 - this.a;
676
+ var _a = this.toJson(), r = _a.r, g = _a.g, b = _a.b, a = _a.a;
677
+ r = 255 - this.r;
678
+ g = 255 - this.g;
679
+ b = 255 - this.b;
680
+ a = 1 - this.a;
665
681
  return new CssColorParserPlus(r, g, b, a);
666
682
  };
667
683
  /**
@@ -669,7 +685,10 @@ var CssColorParserPlus = /** @class */ (function (_super) {
669
685
  * @return {CssColorParserPlus}
670
686
  */
671
687
  CssColorParserPlus.prototype.clone = function () {
672
- return new CssColorParserPlus(this.r, this.g, this.b, this.a);
688
+ var newParser = new CssColorParserPlus(this.r, this.g, this.b, this.a);
689
+ newParser._outColorPrecision = this._outColorPrecision;
690
+ newParser._outAlphaPrecision = this._outAlphaPrecision;
691
+ return newParser;
673
692
  };
674
693
  /**
675
694
  * @description: 比较两个解析对象的数据是否相等
@@ -876,6 +895,8 @@ var CssColorParserPlus = /** @class */ (function (_super) {
876
895
  * @example: CssColorParserPlus.fromRandom('black', new CssColorParserPlus(255,255,255,1))
877
896
  */
878
897
  CssColorParserPlus.fromRandom = function (color1, color2) {
898
+ if (color1 === void 0) { color1 = new CssColorParserPlus(0, 0, 0, 1); }
899
+ if (color2 === void 0) { color2 = new CssColorParserPlus(255, 255, 255, 1); }
879
900
  color1 = CssColorParserPlus.parseColor(color1);
880
901
  color2 = CssColorParserPlus.parseColor(color2);
881
902
  var r = Math.random() * Math.abs(color2.r - color1.r) +
@@ -1 +1 @@
1
- !function(t,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r((t="undefined"!=typeof globalThis?globalThis:t||self).Parser={})}(this,(function(t){"use strict";var r=function(){function t(){}return t.type=function(t,r,e){var n=typeof r;if(n!==e)throw new Error("Expected ".concat(t," to be typeof ").concat(e,", actual typeof was ").concat(n))},t.types=function(t,r,e){var n=typeof r;if(!e.includes(n))throw new Error("Expected ".concat(t," to be typeof ").concat(e.join("|"),", actual typeof was ").concat(n))},t.numValue=function(r,e,n,o){t.numMinValue(r,e,n),t.numMaxValue(r,e,o)},t.numMinValue=function(t,r,e){if(r<e)throw new Error("Expected ".concat(t," to > ").concat(e,", actual value was ").concat(r))},t.numMaxValue=function(t,r,e){if(r>e)throw new Error("Expected ".concat(t," to < ").concat(e,", actual value was ").concat(r))},t.numIsInt=function(t,r,e){var n=Math.floor(r)===r;if(n!==e)throw new Error("Expected ".concat(t," to ").concat(e?"Integer":"Float",", actual value was ").concat(n?"Integer":"Float"))},t}();function e(t,r){return null==t||isNaN(t)&&"number"==typeof r?r:t}function n(t,r,e){return e>r?e=r:e<t&&(e=t),e}function o(t,r){void 0===t&&(t=0);var e=Math.pow(10,r);return Math.round(t*e)/e}var a,s,i,c,u,l,h,p,f=function(){function t(){}return t.clearStrSpace=function(t){return t.replace(/\s/g,"")},t.trimStr=function(t){return(t=t.replace(/\s+/g," ")).trim()},t.parse3BitsHEX=function(r){var n=/^#([0-9a-f])([0-9a-f])([0-9a-f])([0-9a-f])?$/i.exec(r);if(n){var o=e(n[4],"f");return[t._parseResStrForRgb(parseInt(n[1]+n[1],16)),t._parseResStrForRgb(parseInt(n[2]+n[2],16)),t._parseResStrForRgb(parseInt(n[3]+n[3],16)),t._parsePercent(parseInt(o+o,16)/255)]}return null},t.parse6BitsHEX=function(r){var n=/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})?$/i.exec(r);if(n){var o=e(n[4],"ff");return[t._parseResStrForRgb(parseInt(n[1],16)),t._parseResStrForRgb(parseInt(n[2],16)),t._parseResStrForRgb(parseInt(n[3],16)),t._parsePercent(parseInt(o,16)/255)]}return null},t.parseRGBA=function(r){var e=/^rgba?\(([0-9.]+%?),([0-9.]+%?),([0-9.]+%?)(?:,([0-9.]+%?))?\)$/i.exec(r);return e?[t._parseResStrForRgb(e[1]),t._parseResStrForRgb(e[2]),t._parseResStrForRgb(e[3]),t._parsePercent(e[4])]:null},t.parseHSLA=function(r){var e=/^hsla?\(([0-9.]+)(?:deg)?,([0-9.]+%?),([0-9.]+%?)(?:,([0-9.]+%?))?\)$/i.exec(r);return e?[t._parseResStrForHue(e[1]),t._parsePercent(e[2]),t._parsePercent(e[3]),t._parsePercent(e[4])]:null},t.parseHWB=function(r){var e=/^hwb\s?\(\s?([0-9.]+)(?:deg)?\s([0-9.]+%?)\s([0-9.]+%?)\s?(?:\/\s?([0-9.]+%?))?\s?\)$/i.exec(r);return e?[t._parseResStrForHue(e[1]),t._parsePercent(e[2]),t._parsePercent(e[3]),t._parsePercent(e[4])]:null},t.parseRGBA2=function(r){var e=/^rgba?\s?\(\s?([0-9.]+%?)\s?([0-9.]+%?)\s?([0-9.]+%?)(?:\s?\/\s?([0-9.]+%?))?\s?\)$/i.exec(r);return e?[t._parseResStrForRgb(e[1]),t._parseResStrForRgb(e[2]),t._parseResStrForRgb(e[3]),t._parsePercent(e[4])]:null},t.parseHSLA2=function(r){var e=/^hsla?\s?\(\s?([0-9.]+)(?:deg)?\s([0-9.]+%?)\s([0-9.]+%?)\s?(?:\/\s?([0-9.]+%?))?\s?\)$/i.exec(r);return e?[t._parseResStrForHue(e[1]),t._parsePercent(e[2]),t._parsePercent(e[3]),t._parsePercent(e[4])]:null},t._parseResStrForRgb=function(t){return"string"==typeof t&&(t=parseFloat(t)/("%"===t.substr(-1)?100/255:1)),isNaN(t)&&(t=1),n(0,255,t)},t._parseResStrForHue=function(t){return"string"==typeof t&&(t=parseFloat(t)),isNaN(t)&&(t=0),n(0,360,t)},t._parsePercent=function(t){return"string"==typeof t&&(t=parseFloat(t)/("%"===t.substr(-1)?100:1)),isNaN(t)&&(t=1),n(0,1,t)},t}(),b=function(){function t(t,r,e,n){this.r=255,this.g=255,this.b=255,this.a=1,this._outColorPrecision=2,this._outAlphaPrecision=2,this.setColor(t,r,e,n)}return t.prototype.setOutPrecision=function(t,e){return r.type("colorPrecision",t,"number"),r.type("outAlphaPrecision",e,"number"),r.numMinValue("colorPrecision",t,0),r.numMinValue("outAlphaPrecision",e,0),r.numIsInt("colorPrecision",t,!0),r.numIsInt("outAlphaPrecision",e,!0),this._outColorPrecision=t,this._outAlphaPrecision=e,this},t.prototype.setColor=function(t,r,o,a,s){return void 0===s&&(s=!0),s?(this.r=n(0,255,e(Number(t),0)),this.g=n(0,255,e(Number(r),0)),this.b=n(0,255,e(Number(o),0)),this.a=n(0,1,e(Number(a),1))):(this.r=e(Number(t),0),this.g=e(Number(r),0),this.b=e(Number(o),0),this.a=e(Number(a),1)),this},t.prototype.limitColor=function(){return this.setColor(this.r,this.g,this.b,this.a,!0)},t.prototype.setAlpha=function(t){return this.a=n(0,1,e(Number(t),1)),this},t.prototype.setRed=function(t){return this.r=n(0,255,e(Number(t),0)),this},t.prototype.setGreen=function(t){return this.g=n(0,255,e(Number(t),0)),this},t.prototype.setBlue=function(t){return this.b=n(0,255,e(Number(t),0)),this},t.prototype.toRGBA=function(){var t=this.toJson();return 1===t.a?"rgb(".concat(t.r,",").concat(t.g,",").concat(t.b,")"):"rgba(".concat(t.r,",").concat(t.g,",").concat(t.b,",").concat(t.a,")")},t.prototype.toString=function(){return this.toRGBA()},t.prototype.toNormalize=function(){return[o(this.r/255,this._outColorPrecision),o(this.g/255,this._outColorPrecision),o(this.b/255,this._outColorPrecision),o(this.a,this._outAlphaPrecision)]},t.prototype.toHEX=function(){var t=this.toJson(),r=t.r.toString(16);r.length<2&&(r="0".concat(r));var e=t.g.toString(16);e.length<2&&(e="0".concat(e));var n=t.b.toString(16);if(n.length<2&&(n="0".concat(n)),this.a<1){var o=parseInt((255*this.a).toFixed()).toString(16);return o.length<2&&(o="0".concat(o)),"#".concat(r).concat(e).concat(n).concat(o)}return"#".concat(r).concat(e).concat(n)},t.prototype.toArray=function(){var t=this.toJson();return[t.r,t.g,t.b,t.a]},t.prototype.toJson=function(){return{r:o(this.r,this._outColorPrecision),g:o(this.g,this._outColorPrecision),b:o(this.b,this._outColorPrecision),a:o(this.a,this._outAlphaPrecision)}},t.prototype.toInvert=function(){return new t(255-this.r,255-this.g,255-this.b,1-this.a)},t.prototype.clone=function(){return new t(this.r,this.g,this.b,this.a)},t.prototype.equals=function(t){if(this===t)return!0;var r=this.toJson(),e=t.toJson();return r.r===e.r&&r.g===e.g&&r.b===e.g&&r.a===e.a},t.prototype.setInvert=function(){return this.r=255-this.r,this.g=255-this.g,this.b=255-this.b,this.a=1-this.a,this},t.prototype.multiplyByScalar=function(t,r){void 0===r&&(r=!0);var e=this.r*t,n=this.g*t,o=this.b*t,a=r?this.a*t:this.a;return this.setColor(e,n,o,a,!1)},t.prototype.divideByScalar=function(t,r){void 0===r&&(r=!0);var e=this.r/t,n=this.g/t,o=this.b/t,a=r?this.a/t:this.a;return this.setColor(e,n,o,a,!1)},t.prototype.add=function(t,r){void 0===r&&(r=!0);var e=this.r+t.r,n=this.g+t.g,o=this.b+t.b,a=r?this.a+t.a:this.a;return this.setColor(e,n,o,a,!1)},t.prototype.subtract=function(t,r){void 0===r&&(r=!0);var e=this.r-t.r,n=this.g-t.g,o=this.b-t.b,a=r?this.a-t.a:this.a;return this.setColor(e,n,o,a,!1)},t.prototype.multiply=function(t,r){void 0===r&&(r=!0);var e=this.r*t.r,n=this.g*t.g,o=this.b*t.b,a=r?this.a*t.a:this.a;return this.setColor(e,n,o,a,!1)},t.prototype.divide=function(t,r){void 0===r&&(r=!0);var e=this.r/t.r,n=this.g/t.g,o=this.b/t.b,a=r?this.a/t.a:this.a;return this.setColor(e,n,o,a,!1)},t.prototype.addNumberForRGB=function(t){return this.r=this.r+t,this.g=this.g+t,this.b=this.b+t,this},t.prototype.addNumberForAlpha=function(t){return this.a=this.a+t,this},t.parseHEX=function(r){var e=f.clearStrSpace(r),n=f.parse3BitsHEX(e);return n||(n=f.parse6BitsHEX(e)),n&&t.fromArray(n)},t.parseRGBA=function(r){var e=f.clearStrSpace(r),n=f.parseRGBA(e);if(!n){var o=f.trimStr(r);n=f.parseRGBA2(o)}return n&&t.fromArray(n)},t.fromJson=function(r){return new t(r.r,r.g,r.b,r.a)},t.fromArray=function(r){return new t(r[0],r[1],r[2],r[3])},t.fromRandom=function(r,e){return new t(Math.random()*Math.abs(e.r-r.r)+Math.min(r.r,e.r),Math.random()*Math.abs(e.g-r.g)+Math.min(r.g,e.g),Math.random()*Math.abs(e.b-r.b)+Math.min(r.b,e.b),Math.random()*Math.abs(e.a-r.a)+Math.min(r.a,e.a))},t.fromNormalize=function(r){var e=255*r[0],n=255*r[1],o=255*r[2],a=r[3];return t.fromArray([e,n,o,a])},t}(),g=function(t,r){return g=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,r){t.__proto__=r}||function(t,r){for(var e in r)Object.prototype.hasOwnProperty.call(r,e)&&(t[e]=r[e])},g(t,r)};function d(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function y(){if(c)return i;c=1;const t=s?a:(s=1,a={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}),r={};for(const e of Object.keys(t))r[t[e]]=e;const e={rgb:{channels:3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"},hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channels:3,labels:"xyz"},lab:{channels:3,labels:"lab"},lch:{channels:3,labels:"lch"},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]},ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256"]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","g16","b16"]},gray:{channels:1,labels:["gray"]}};i=e;for(const t of Object.keys(e)){if(!("channels"in e[t]))throw new Error("missing channels property: "+t);if(!("labels"in e[t]))throw new Error("missing channel labels property: "+t);if(e[t].labels.length!==e[t].channels)throw new Error("channel and label counts mismatch: "+t);const{channels:r,labels:n}=e[t];delete e[t].channels,delete e[t].labels,Object.defineProperty(e[t],"channels",{value:r}),Object.defineProperty(e[t],"labels",{value:n})}return e.rgb.hsl=function(t){const r=t[0]/255,e=t[1]/255,n=t[2]/255,o=Math.min(r,e,n),a=Math.max(r,e,n),s=a-o;let i,c;a===o?i=0:r===a?i=(e-n)/s:e===a?i=2+(n-r)/s:n===a&&(i=4+(r-e)/s),i=Math.min(60*i,360),i<0&&(i+=360);const u=(o+a)/2;return c=a===o?0:u<=.5?s/(a+o):s/(2-a-o),[i,100*c,100*u]},e.rgb.hsv=function(t){let r,e,n,o,a;const s=t[0]/255,i=t[1]/255,c=t[2]/255,u=Math.max(s,i,c),l=u-Math.min(s,i,c),h=function(t){return(u-t)/6/l+.5};return 0===l?(o=0,a=0):(a=l/u,r=h(s),e=h(i),n=h(c),s===u?o=n-e:i===u?o=1/3+r-n:c===u&&(o=2/3+e-r),o<0?o+=1:o>1&&(o-=1)),[360*o,100*a,100*u]},e.rgb.hwb=function(t){const r=t[0],n=t[1];let o=t[2];const a=e.rgb.hsl(t)[0],s=1/255*Math.min(r,Math.min(n,o));return o=1-1/255*Math.max(r,Math.max(n,o)),[a,100*s,100*o]},e.rgb.cmyk=function(t){const r=t[0]/255,e=t[1]/255,n=t[2]/255,o=Math.min(1-r,1-e,1-n);return[100*((1-r-o)/(1-o)||0),100*((1-e-o)/(1-o)||0),100*((1-n-o)/(1-o)||0),100*o]},e.rgb.keyword=function(e){const n=r[e];if(n)return n;let o,a=1/0;for(const r of Object.keys(t)){const n=t[r],c=(i=n,((s=e)[0]-i[0])**2+(s[1]-i[1])**2+(s[2]-i[2])**2);c<a&&(a=c,o=r)}var s,i;return o},e.keyword.rgb=function(r){return t[r]},e.rgb.xyz=function(t){let r=t[0]/255,e=t[1]/255,n=t[2]/255;r=r>.04045?((r+.055)/1.055)**2.4:r/12.92,e=e>.04045?((e+.055)/1.055)**2.4:e/12.92,n=n>.04045?((n+.055)/1.055)**2.4:n/12.92;return[100*(.4124*r+.3576*e+.1805*n),100*(.2126*r+.7152*e+.0722*n),100*(.0193*r+.1192*e+.9505*n)]},e.rgb.lab=function(t){const r=e.rgb.xyz(t);let n=r[0],o=r[1],a=r[2];n/=95.047,o/=100,a/=108.883,n=n>.008856?n**(1/3):7.787*n+16/116,o=o>.008856?o**(1/3):7.787*o+16/116,a=a>.008856?a**(1/3):7.787*a+16/116;return[116*o-16,500*(n-o),200*(o-a)]},e.hsl.rgb=function(t){const r=t[0]/360,e=t[1]/100,n=t[2]/100;let o,a,s;if(0===e)return s=255*n,[s,s,s];o=n<.5?n*(1+e):n+e-n*e;const i=2*n-o,c=[0,0,0];for(let t=0;t<3;t++)a=r+1/3*-(t-1),a<0&&a++,a>1&&a--,s=6*a<1?i+6*(o-i)*a:2*a<1?o:3*a<2?i+(o-i)*(2/3-a)*6:i,c[t]=255*s;return c},e.hsl.hsv=function(t){const r=t[0];let e=t[1]/100,n=t[2]/100,o=e;const a=Math.max(n,.01);n*=2,e*=n<=1?n:2-n,o*=a<=1?a:2-a;return[r,100*(0===n?2*o/(a+o):2*e/(n+e)),100*((n+e)/2)]},e.hsv.rgb=function(t){const r=t[0]/60,e=t[1]/100;let n=t[2]/100;const o=Math.floor(r)%6,a=r-Math.floor(r),s=255*n*(1-e),i=255*n*(1-e*a),c=255*n*(1-e*(1-a));switch(n*=255,o){case 0:return[n,c,s];case 1:return[i,n,s];case 2:return[s,n,c];case 3:return[s,i,n];case 4:return[c,s,n];case 5:return[n,s,i]}},e.hsv.hsl=function(t){const r=t[0],e=t[1]/100,n=t[2]/100,o=Math.max(n,.01);let a,s;s=(2-e)*n;const i=(2-e)*o;return a=e*o,a/=i<=1?i:2-i,a=a||0,s/=2,[r,100*a,100*s]},e.hwb.rgb=function(t){const r=t[0]/360;let e=t[1]/100,n=t[2]/100;const o=e+n;let a;o>1&&(e/=o,n/=o);const s=Math.floor(6*r),i=1-n;a=6*r-s,1&s&&(a=1-a);const c=e+a*(i-e);let u,l,h;switch(s){default:case 6:case 0:u=i,l=c,h=e;break;case 1:u=c,l=i,h=e;break;case 2:u=e,l=i,h=c;break;case 3:u=e,l=c,h=i;break;case 4:u=c,l=e,h=i;break;case 5:u=i,l=e,h=c}return[255*u,255*l,255*h]},e.cmyk.rgb=function(t){const r=t[0]/100,e=t[1]/100,n=t[2]/100,o=t[3]/100;return[255*(1-Math.min(1,r*(1-o)+o)),255*(1-Math.min(1,e*(1-o)+o)),255*(1-Math.min(1,n*(1-o)+o))]},e.xyz.rgb=function(t){const r=t[0]/100,e=t[1]/100,n=t[2]/100;let o,a,s;return o=3.2406*r+-1.5372*e+-.4986*n,a=-.9689*r+1.8758*e+.0415*n,s=.0557*r+-.204*e+1.057*n,o=o>.0031308?1.055*o**(1/2.4)-.055:12.92*o,a=a>.0031308?1.055*a**(1/2.4)-.055:12.92*a,s=s>.0031308?1.055*s**(1/2.4)-.055:12.92*s,o=Math.min(Math.max(0,o),1),a=Math.min(Math.max(0,a),1),s=Math.min(Math.max(0,s),1),[255*o,255*a,255*s]},e.xyz.lab=function(t){let r=t[0],e=t[1],n=t[2];r/=95.047,e/=100,n/=108.883,r=r>.008856?r**(1/3):7.787*r+16/116,e=e>.008856?e**(1/3):7.787*e+16/116,n=n>.008856?n**(1/3):7.787*n+16/116;return[116*e-16,500*(r-e),200*(e-n)]},e.lab.xyz=function(t){let r,e,n;e=(t[0]+16)/116,r=t[1]/500+e,n=e-t[2]/200;const o=e**3,a=r**3,s=n**3;return e=o>.008856?o:(e-16/116)/7.787,r=a>.008856?a:(r-16/116)/7.787,n=s>.008856?s:(n-16/116)/7.787,r*=95.047,e*=100,n*=108.883,[r,e,n]},e.lab.lch=function(t){const r=t[0],e=t[1],n=t[2];let o;o=360*Math.atan2(n,e)/2/Math.PI,o<0&&(o+=360);return[r,Math.sqrt(e*e+n*n),o]},e.lch.lab=function(t){const r=t[0],e=t[1],n=t[2]/360*2*Math.PI;return[r,e*Math.cos(n),e*Math.sin(n)]},e.rgb.ansi16=function(t,r=null){const[n,o,a]=t;let s=null===r?e.rgb.hsv(t)[2]:r;if(s=Math.round(s/50),0===s)return 30;let i=30+(Math.round(a/255)<<2|Math.round(o/255)<<1|Math.round(n/255));return 2===s&&(i+=60),i},e.hsv.ansi16=function(t){return e.rgb.ansi16(e.hsv.rgb(t),t[2])},e.rgb.ansi256=function(t){const r=t[0],e=t[1],n=t[2];if(r===e&&e===n)return r<8?16:r>248?231:Math.round((r-8)/247*24)+232;return 16+36*Math.round(r/255*5)+6*Math.round(e/255*5)+Math.round(n/255*5)},e.ansi16.rgb=function(t){let r=t%10;if(0===r||7===r)return t>50&&(r+=3.5),r=r/10.5*255,[r,r,r];const e=.5*(1+~~(t>50));return[(1&r)*e*255,(r>>1&1)*e*255,(r>>2&1)*e*255]},e.ansi256.rgb=function(t){if(t>=232){const r=10*(t-232)+8;return[r,r,r]}let r;t-=16;return[Math.floor(t/36)/5*255,Math.floor((r=t%36)/6)/5*255,r%6/5*255]},e.rgb.hex=function(t){const r=(((255&Math.round(t[0]))<<16)+((255&Math.round(t[1]))<<8)+(255&Math.round(t[2]))).toString(16).toUpperCase();return"000000".substring(r.length)+r},e.hex.rgb=function(t){const r=t.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);if(!r)return[0,0,0];let e=r[0];3===r[0].length&&(e=e.split("").map((t=>t+t)).join(""));const n=parseInt(e,16);return[n>>16&255,n>>8&255,255&n]},e.rgb.hcg=function(t){const r=t[0]/255,e=t[1]/255,n=t[2]/255,o=Math.max(Math.max(r,e),n),a=Math.min(Math.min(r,e),n),s=o-a;let i,c;return i=s<1?a/(1-s):0,c=s<=0?0:o===r?(e-n)/s%6:o===e?2+(n-r)/s:4+(r-e)/s,c/=6,c%=1,[360*c,100*s,100*i]},e.hsl.hcg=function(t){const r=t[1]/100,e=t[2]/100,n=e<.5?2*r*e:2*r*(1-e);let o=0;return n<1&&(o=(e-.5*n)/(1-n)),[t[0],100*n,100*o]},e.hsv.hcg=function(t){const r=t[1]/100,e=t[2]/100,n=r*e;let o=0;return n<1&&(o=(e-n)/(1-n)),[t[0],100*n,100*o]},e.hcg.rgb=function(t){const r=t[0]/360,e=t[1]/100,n=t[2]/100;if(0===e)return[255*n,255*n,255*n];const o=[0,0,0],a=r%1*6,s=a%1,i=1-s;let c=0;switch(Math.floor(a)){case 0:o[0]=1,o[1]=s,o[2]=0;break;case 1:o[0]=i,o[1]=1,o[2]=0;break;case 2:o[0]=0,o[1]=1,o[2]=s;break;case 3:o[0]=0,o[1]=i,o[2]=1;break;case 4:o[0]=s,o[1]=0,o[2]=1;break;default:o[0]=1,o[1]=0,o[2]=i}return c=(1-e)*n,[255*(e*o[0]+c),255*(e*o[1]+c),255*(e*o[2]+c)]},e.hcg.hsv=function(t){const r=t[1]/100,e=r+t[2]/100*(1-r);let n=0;return e>0&&(n=r/e),[t[0],100*n,100*e]},e.hcg.hsl=function(t){const r=t[1]/100,e=t[2]/100*(1-r)+.5*r;let n=0;return e>0&&e<.5?n=r/(2*e):e>=.5&&e<1&&(n=r/(2*(1-e))),[t[0],100*n,100*e]},e.hcg.hwb=function(t){const r=t[1]/100,e=r+t[2]/100*(1-r);return[t[0],100*(e-r),100*(1-e)]},e.hwb.hcg=function(t){const r=t[1]/100,e=1-t[2]/100,n=e-r;let o=0;return n<1&&(o=(e-n)/(1-n)),[t[0],100*n,100*o]},e.apple.rgb=function(t){return[t[0]/65535*255,t[1]/65535*255,t[2]/65535*255]},e.rgb.apple=function(t){return[t[0]/255*65535,t[1]/255*65535,t[2]/255*65535]},e.gray.rgb=function(t){return[t[0]/100*255,t[0]/100*255,t[0]/100*255]},e.gray.hsl=function(t){return[0,0,t[0]]},e.gray.hsv=e.gray.hsl,e.gray.hwb=function(t){return[0,100,t[0]]},e.gray.cmyk=function(t){return[0,0,0,t[0]]},e.gray.lab=function(t){return[t[0],0,0]},e.gray.hex=function(t){const r=255&Math.round(t[0]/100*255),e=((r<<16)+(r<<8)+r).toString(16).toUpperCase();return"000000".substring(e.length)+e},e.rgb.gray=function(t){return[(t[0]+t[1]+t[2])/3/255*100]},i}function m(){if(l)return u;l=1;const t=y();function r(r){const e=function(){const r={},e=Object.keys(t);for(let t=e.length,n=0;n<t;n++)r[e[n]]={distance:-1,parent:null};return r}(),n=[r];for(e[r].distance=0;n.length;){const r=n.pop(),o=Object.keys(t[r]);for(let t=o.length,a=0;a<t;a++){const t=o[a],s=e[t];-1===s.distance&&(s.distance=e[r].distance+1,s.parent=r,n.unshift(t))}}return e}function e(t,r){return function(e){return r(t(e))}}function n(r,n){const o=[n[r].parent,r];let a=t[n[r].parent][r],s=n[r].parent;for(;n[s].parent;)o.unshift(n[s].parent),a=e(t[n[s].parent][s],a),s=n[s].parent;return a.conversion=o,a}return u=function(t){const e=r(t),o={},a=Object.keys(e);for(let t=a.length,r=0;r<t;r++){const t=a[r];null!==e[t].parent&&(o[t]=n(t,e))}return o}}"function"==typeof SuppressedError&&SuppressedError;var v=function(){if(p)return h;p=1;const t=y(),r=m(),e={};return Object.keys(t).forEach((n=>{e[n]={},Object.defineProperty(e[n],"channels",{value:t[n].channels}),Object.defineProperty(e[n],"labels",{value:t[n].labels});const o=r(n);Object.keys(o).forEach((t=>{const r=o[t];e[n][t]=function(t){const r=function(...r){const e=r[0];if(null==e)return e;e.length>1&&(r=e);const n=t(r);if("object"==typeof n)for(let t=n.length,r=0;r<t;r++)n[r]=Math.round(n[r]);return n};return"conversion"in t&&(r.conversion=t.conversion),r}(r),e[n][t].raw=function(t){const r=function(...r){const e=r[0];return null==e?e:(e.length>1&&(r=e),t(r))};return"conversion"in t&&(r.conversion=t.conversion),r}(r)}))})),h=e}(),M=d(v),w=function(t){function o(){return null!==t&&t.apply(this,arguments)||this}return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function e(){this.constructor=t}g(t,r),t.prototype=null===r?Object.create(r):(e.prototype=r.prototype,new e)}(o,t),o.prototype.toInvert=function(){return new o(255-this.r,255-this.g,255-this.b,1-this.a)},o.prototype.clone=function(){return new o(this.r,this.g,this.b,this.a)},o.prototype.equals=function(t){if(this===(t=o.parseColor(t)))return!0;var r=this.toJson(),e=t.toJson();return r.r===e.r&&r.g===e.g&&r.b===e.g&&r.a===e.a},o.prototype.add=function(r,e){void 0===e&&(e=!0);var n=o.parseColor(r);return t.prototype.add.call(this,n,e)},o.prototype.subtract=function(r,e){void 0===e&&(e=!0);var n=o.parseColor(r);return t.prototype.subtract.call(this,n,e)},o.prototype.multiply=function(r,e){void 0===e&&(e=!0);var n=o.parseColor(r);return t.prototype.multiply.call(this,n,e)},o.prototype.divide=function(r,e){void 0===e&&(e=!0);var n=o.parseColor(r);return t.prototype.divide.call(this,n,e)},o.parseColor=function(t){return t instanceof b?t.clone():o.parseCssColorStr(t)},o.parseCssColorStr=function(t){return r.type("color",t,"string"),o.parseHEX(t)||o.parseRGBA(t)||o.parseKeyWord(t)||o.parseHSLA(t)||o.parseHWB(t)},o.parseKeyWord=function(t){var r=f.clearStrSpace(t),e=M.keyword.rgb(r);return e&&o.fromArray(e)},o.parseHSLA=function(t){var r=f.clearStrSpace(t),e=f.parseHSLA(r);if(!e){var n=f.trimStr(t);e=f.parseHSLA2(n)}return e&&o.fromHSL(e[0],e[1],e[2],e[3])},o.parseHWB=function(t){var r=f.trimStr(t),e=f.parseHWB(r);return e&&o.fromHWB(e[0],e[1],e[2],e[3])},o.fromHSL=function(t,r,a,s){var i=M.hsl.rgb(n(0,360,t),n(0,100,100*r),n(0,100,100*a));return new o(i[0],i[1],i[2],e(Number(s),1))},o.fromHWB=function(t,r,a,s){var i=M.hwb.rgb(n(0,360,t),n(0,100,100*r),n(0,100,100*a));return new o(i[0],i[1],i[2],e(Number(s),1))},o.parseHEX=function(t){var r=f.clearStrSpace(t),e=f.parse3BitsHEX(r);return e||(e=f.parse6BitsHEX(r)),e&&o.fromArray(e)},o.parseRGBA=function(t){var r=f.clearStrSpace(t),e=f.parseRGBA(r);if(!e){var n=f.trimStr(t);e=f.parseRGBA2(n)}return e&&o.fromArray(e)},o.fromJson=function(t){return new o(t.r,t.g,t.b,t.a)},o.fromArray=function(t){return new o(t[0],t[1],t[2],t[3])},o.fromRandom=function(t,r){return t=o.parseColor(t),r=o.parseColor(r),new o(Math.random()*Math.abs(r.r-t.r)+Math.min(t.r,r.r),Math.random()*Math.abs(r.g-t.g)+Math.min(t.g,r.g),Math.random()*Math.abs(r.b-t.b)+Math.min(t.b,r.b),Math.random()*Math.abs(r.a-t.a)+Math.min(t.a,r.a))},o.fromNormalize=function(t){var r=255*t[0],e=255*t[1],n=255*t[2],a=t[3];return o.fromArray([r,e,n,a])},o.lerp=function(t,r){var e=Object.keys(t).map((function(t){return Number(t)}));e.sort((function(t,r){return t-r}));for(var n=0;n<e.length;n++)if(r<=e[n]){var a=e[n-1],s=e[n];if(void 0===a)return o.parseColor(t[s]);var i=(r-a)/(s-a),c=o.parseColor(t[a]);return o.parseColor(t[s]).subtract(c).multiplyByScalar(i).add(c)}return o.parseColor(t[e[e.length-1]]).limitColor()},o}(b);t.CssColorParser=b,t.CssColorParserPlus=w}));
1
+ !function(t,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r((t="undefined"!=typeof globalThis?globalThis:t||self).Parser={})}(this,(function(t){"use strict";var r=function(){function t(){}return t.type=function(t,r,n){var e=typeof r;if(e!==n)throw new Error("Expected ".concat(t," to be typeof ").concat(n,", actual typeof was ").concat(e))},t.types=function(t,r,n){var e=typeof r;if(!n.includes(e))throw new Error("Expected ".concat(t," to be typeof ").concat(n.join("|"),", actual typeof was ").concat(e))},t.numValue=function(r,n,e,o){t.numMinValue(r,n,e),t.numMaxValue(r,n,o)},t.numMinValue=function(t,r,n){if(r<n)throw new Error("Expected ".concat(t," to > ").concat(n,", actual value was ").concat(r))},t.numMaxValue=function(t,r,n){if(r>n)throw new Error("Expected ".concat(t," to < ").concat(n,", actual value was ").concat(r))},t.numIsInt=function(t,r,n){var e=Math.floor(r)===r;if(e!==n)throw new Error("Expected ".concat(t," to ").concat(n?"Integer":"Float",", actual value was ").concat(e?"Integer":"Float"))},t}();function n(t,r){return null==t||isNaN(t)&&"number"==typeof r?r:t}function e(t,r,n){return n>r?n=r:n<t&&(n=t),n}function o(t,r){void 0===t&&(t=0);var n=Math.pow(10,r);return Math.round(t*n)/n}var a,s,i,c,u,l,h,p,f=function(){function t(){}return t.clearStrSpace=function(t){return t.replace(/\s/g,"")},t.trimStr=function(t){return(t=t.replace(/\s+/g," ")).trim()},t.parse3BitsHEX=function(r){var e=/^#([0-9a-f])([0-9a-f])([0-9a-f])([0-9a-f])?$/i.exec(r);if(e){var o=n(e[4],"f");return[t._parseResStrForRgb(parseInt(e[1]+e[1],16)),t._parseResStrForRgb(parseInt(e[2]+e[2],16)),t._parseResStrForRgb(parseInt(e[3]+e[3],16)),t._parsePercent(parseInt(o+o,16)/255)]}return null},t.parse6BitsHEX=function(r){var e=/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})?$/i.exec(r);if(e){var o=n(e[4],"ff");return[t._parseResStrForRgb(parseInt(e[1],16)),t._parseResStrForRgb(parseInt(e[2],16)),t._parseResStrForRgb(parseInt(e[3],16)),t._parsePercent(parseInt(o,16)/255)]}return null},t.parseRGBA=function(r){var n=/^rgba?\(([0-9.]+%?),([0-9.]+%?),([0-9.]+%?)(?:,([0-9.]+%?))?\)$/i.exec(r);return n?[t._parseResStrForRgb(n[1]),t._parseResStrForRgb(n[2]),t._parseResStrForRgb(n[3]),t._parsePercent(n[4])]:null},t.parseHSLA=function(r){var n=/^hsla?\(([0-9.]+)(?:deg)?,([0-9.]+%?),([0-9.]+%?)(?:,([0-9.]+%?))?\)$/i.exec(r);return n?[t._parseResStrForHue(n[1]),t._parsePercent(n[2]),t._parsePercent(n[3]),t._parsePercent(n[4])]:null},t.parseHWB=function(r){var n=/^hwb\s?\(\s?([0-9.]+)(?:deg)?\s([0-9.]+%?)\s([0-9.]+%?)\s?(?:\/\s?([0-9.]+%?))?\s?\)$/i.exec(r);return n?[t._parseResStrForHue(n[1]),t._parsePercent(n[2]),t._parsePercent(n[3]),t._parsePercent(n[4])]:null},t.parseRGBA2=function(r){var n=/^rgba?\s?\(\s?([0-9.]+%?)\s?([0-9.]+%?)\s?([0-9.]+%?)(?:\s?\/\s?([0-9.]+%?))?\s?\)$/i.exec(r);return n?[t._parseResStrForRgb(n[1]),t._parseResStrForRgb(n[2]),t._parseResStrForRgb(n[3]),t._parsePercent(n[4])]:null},t.parseHSLA2=function(r){var n=/^hsla?\s?\(\s?([0-9.]+)(?:deg)?\s([0-9.]+%?)\s([0-9.]+%?)\s?(?:\/\s?([0-9.]+%?))?\s?\)$/i.exec(r);return n?[t._parseResStrForHue(n[1]),t._parsePercent(n[2]),t._parsePercent(n[3]),t._parsePercent(n[4])]:null},t._parseResStrForRgb=function(t){return"string"==typeof t&&(t=parseFloat(t)/("%"===t.substr(-1)?100/255:1)),isNaN(t)&&(t=1),e(0,255,t)},t._parseResStrForHue=function(t){return"string"==typeof t&&(t=parseFloat(t)),isNaN(t)&&(t=0),e(0,360,t)},t._parsePercent=function(t){return"string"==typeof t&&(t=parseFloat(t)/("%"===t.substr(-1)?100:1)),isNaN(t)&&(t=1),e(0,1,t)},t}(),b=function(){function t(t,r,n,e){this.r=255,this.g=255,this.b=255,this.a=1,this._outColorPrecision=2,this._outAlphaPrecision=2,this.setColor(t,r,n,e)}return t.prototype.setOutPrecision=function(t,n){return r.type("colorPrecision",t,"number"),r.type("outAlphaPrecision",n,"number"),r.numMinValue("colorPrecision",t,0),r.numMinValue("outAlphaPrecision",n,0),r.numIsInt("colorPrecision",t,!0),r.numIsInt("outAlphaPrecision",n,!0),this._outColorPrecision=t,this._outAlphaPrecision=n,this},t.prototype.setColor=function(t,r,o,a,s){return void 0===s&&(s=!0),s?(this.r=e(0,255,n(Number(t),0)),this.g=e(0,255,n(Number(r),0)),this.b=e(0,255,n(Number(o),0)),this.a=e(0,1,n(Number(a),1))):(this.r=n(Number(t),0),this.g=n(Number(r),0),this.b=n(Number(o),0),this.a=n(Number(a),1)),this},t.prototype.limitColor=function(){return this.setColor(this.r,this.g,this.b,this.a,!0)},t.prototype.setAlpha=function(t){return this.a=e(0,1,n(Number(t),1)),this},t.prototype.setRed=function(t){return this.r=e(0,255,n(Number(t),0)),this},t.prototype.setGreen=function(t){return this.g=e(0,255,n(Number(t),0)),this},t.prototype.setBlue=function(t){return this.b=e(0,255,n(Number(t),0)),this},t.prototype.toRGBA=function(){var t=this.toJson();return 1===t.a?"rgb(".concat(t.r,",").concat(t.g,",").concat(t.b,")"):"rgba(".concat(t.r,",").concat(t.g,",").concat(t.b,",").concat(t.a,")")},t.prototype.toString=function(){return this.toRGBA()},t.prototype.toNormalize=function(){var t=this.toJson();return[t.r/255,t.g/255,t.b/255,t.a]},t.prototype.toHEX=function(){var t=this.toJson(!0,0,0),r=t.r,n=t.g,e=t.b,a=r.toString(16);a.length<2&&(a="0".concat(a));var s=n.toString(16);s.length<2&&(s="0".concat(s));var i=e.toString(16);if(i.length<2&&(i="0".concat(i)),this.a<1){var c=o(255*this.a,0).toString(16);return c.length<2&&(c="0".concat(c)),"#".concat(a).concat(s).concat(i).concat(c)}return"#".concat(a).concat(s).concat(i)},t.prototype.toArray=function(){var t=this.toJson();return[t.r,t.g,t.b,t.a]},t.prototype.toJson=function(t,r,n){void 0===t&&(t=!0),void 0===r&&(r=this._outColorPrecision),void 0===n&&(n=this._outAlphaPrecision);var a=this.r,s=this.g,i=this.b,c=this.a;return t&&(a=e(0,255,this.r),s=e(0,255,this.g),i=e(0,255,this.b),c=e(0,1,this.a)),{r:o(a,r),g:o(s,r),b:o(i,r),a:o(c,n)}},t.prototype.toInvert=function(){var r=this.toJson();r.r,r.g,r.b,r.a;return new t(255-this.r,255-this.g,255-this.b,1-this.a)},t.prototype.clone=function(){var r=new t(this.r,this.g,this.b,this.a);return r._outColorPrecision=this._outColorPrecision,r._outAlphaPrecision=this._outAlphaPrecision,r},t.prototype.equals=function(t){if(this===t)return!0;var r=this.toJson(),n=t.toJson();return r.r===n.r&&r.g===n.g&&r.b===n.g&&r.a===n.a},t.prototype.setInvert=function(){var t=this.toJson(),r=t.r,n=t.g,e=t.b,o=t.a;return this.r=255-r,this.g=255-n,this.b=255-e,this.a=1-o,this},t.prototype.multiplyByScalar=function(t,r){void 0===r&&(r=!0);var n=this.r*t,e=this.g*t,o=this.b*t,a=r?this.a*t:this.a;return this.setColor(n,e,o,a,!1)},t.prototype.divideByScalar=function(t,r){void 0===r&&(r=!0);var n=this.r/t,e=this.g/t,o=this.b/t,a=r?this.a/t:this.a;return this.setColor(n,e,o,a,!1)},t.prototype.add=function(t,r){void 0===r&&(r=!0);var n=this.r+t.r,e=this.g+t.g,o=this.b+t.b,a=r?this.a+t.a:this.a;return this.setColor(n,e,o,a,!1)},t.prototype.subtract=function(t,r){void 0===r&&(r=!0);var n=this.r-t.r,e=this.g-t.g,o=this.b-t.b,a=r?this.a-t.a:this.a;return this.setColor(n,e,o,a,!1)},t.prototype.multiply=function(t,r){void 0===r&&(r=!0);var n=this.r*t.r,e=this.g*t.g,o=this.b*t.b,a=r?this.a*t.a:this.a;return this.setColor(n,e,o,a,!1)},t.prototype.divide=function(t,r){void 0===r&&(r=!0);var n=this.r/t.r,e=this.g/t.g,o=this.b/t.b,a=r?this.a/t.a:this.a;return this.setColor(n,e,o,a,!1)},t.prototype.addNumberForRGB=function(t){return this.r=this.r+t,this.g=this.g+t,this.b=this.b+t,this},t.prototype.addNumberForAlpha=function(t){return this.a=this.a+t,this},t.parseHEX=function(r){var n=f.clearStrSpace(r),e=f.parse3BitsHEX(n);return e||(e=f.parse6BitsHEX(n)),e&&t.fromArray(e)},t.parseRGBA=function(r){var n=f.clearStrSpace(r),e=f.parseRGBA(n);if(!e){var o=f.trimStr(r);e=f.parseRGBA2(o)}return e&&t.fromArray(e)},t.fromJson=function(r){return new t(r.r,r.g,r.b,r.a)},t.fromArray=function(r){return new t(r[0],r[1],r[2],r[3])},t.fromRandom=function(r,n){return new t(Math.random()*Math.abs(n.r-r.r)+Math.min(r.r,n.r),Math.random()*Math.abs(n.g-r.g)+Math.min(r.g,n.g),Math.random()*Math.abs(n.b-r.b)+Math.min(r.b,n.b),Math.random()*Math.abs(n.a-r.a)+Math.min(r.a,n.a))},t.fromNormalize=function(r){var n=255*r[0],e=255*r[1],o=255*r[2],a=r[3];return t.fromArray([n,e,o,a])},t}(),g=function(t,r){return g=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,r){t.__proto__=r}||function(t,r){for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])},g(t,r)};function d(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function y(){if(c)return i;c=1;const t=s?a:(s=1,a={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}),r={};for(const n of Object.keys(t))r[t[n]]=n;const n={rgb:{channels:3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"},hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channels:3,labels:"xyz"},lab:{channels:3,labels:"lab"},lch:{channels:3,labels:"lch"},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]},ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256"]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","g16","b16"]},gray:{channels:1,labels:["gray"]}};i=n;for(const t of Object.keys(n)){if(!("channels"in n[t]))throw new Error("missing channels property: "+t);if(!("labels"in n[t]))throw new Error("missing channel labels property: "+t);if(n[t].labels.length!==n[t].channels)throw new Error("channel and label counts mismatch: "+t);const{channels:r,labels:e}=n[t];delete n[t].channels,delete n[t].labels,Object.defineProperty(n[t],"channels",{value:r}),Object.defineProperty(n[t],"labels",{value:e})}return n.rgb.hsl=function(t){const r=t[0]/255,n=t[1]/255,e=t[2]/255,o=Math.min(r,n,e),a=Math.max(r,n,e),s=a-o;let i,c;a===o?i=0:r===a?i=(n-e)/s:n===a?i=2+(e-r)/s:e===a&&(i=4+(r-n)/s),i=Math.min(60*i,360),i<0&&(i+=360);const u=(o+a)/2;return c=a===o?0:u<=.5?s/(a+o):s/(2-a-o),[i,100*c,100*u]},n.rgb.hsv=function(t){let r,n,e,o,a;const s=t[0]/255,i=t[1]/255,c=t[2]/255,u=Math.max(s,i,c),l=u-Math.min(s,i,c),h=function(t){return(u-t)/6/l+.5};return 0===l?(o=0,a=0):(a=l/u,r=h(s),n=h(i),e=h(c),s===u?o=e-n:i===u?o=1/3+r-e:c===u&&(o=2/3+n-r),o<0?o+=1:o>1&&(o-=1)),[360*o,100*a,100*u]},n.rgb.hwb=function(t){const r=t[0],e=t[1];let o=t[2];const a=n.rgb.hsl(t)[0],s=1/255*Math.min(r,Math.min(e,o));return o=1-1/255*Math.max(r,Math.max(e,o)),[a,100*s,100*o]},n.rgb.cmyk=function(t){const r=t[0]/255,n=t[1]/255,e=t[2]/255,o=Math.min(1-r,1-n,1-e);return[100*((1-r-o)/(1-o)||0),100*((1-n-o)/(1-o)||0),100*((1-e-o)/(1-o)||0),100*o]},n.rgb.keyword=function(n){const e=r[n];if(e)return e;let o,a=1/0;for(const r of Object.keys(t)){const e=t[r],c=(i=e,((s=n)[0]-i[0])**2+(s[1]-i[1])**2+(s[2]-i[2])**2);c<a&&(a=c,o=r)}var s,i;return o},n.keyword.rgb=function(r){return t[r]},n.rgb.xyz=function(t){let r=t[0]/255,n=t[1]/255,e=t[2]/255;r=r>.04045?((r+.055)/1.055)**2.4:r/12.92,n=n>.04045?((n+.055)/1.055)**2.4:n/12.92,e=e>.04045?((e+.055)/1.055)**2.4:e/12.92;return[100*(.4124*r+.3576*n+.1805*e),100*(.2126*r+.7152*n+.0722*e),100*(.0193*r+.1192*n+.9505*e)]},n.rgb.lab=function(t){const r=n.rgb.xyz(t);let e=r[0],o=r[1],a=r[2];e/=95.047,o/=100,a/=108.883,e=e>.008856?e**(1/3):7.787*e+16/116,o=o>.008856?o**(1/3):7.787*o+16/116,a=a>.008856?a**(1/3):7.787*a+16/116;return[116*o-16,500*(e-o),200*(o-a)]},n.hsl.rgb=function(t){const r=t[0]/360,n=t[1]/100,e=t[2]/100;let o,a,s;if(0===n)return s=255*e,[s,s,s];o=e<.5?e*(1+n):e+n-e*n;const i=2*e-o,c=[0,0,0];for(let t=0;t<3;t++)a=r+1/3*-(t-1),a<0&&a++,a>1&&a--,s=6*a<1?i+6*(o-i)*a:2*a<1?o:3*a<2?i+(o-i)*(2/3-a)*6:i,c[t]=255*s;return c},n.hsl.hsv=function(t){const r=t[0];let n=t[1]/100,e=t[2]/100,o=n;const a=Math.max(e,.01);e*=2,n*=e<=1?e:2-e,o*=a<=1?a:2-a;return[r,100*(0===e?2*o/(a+o):2*n/(e+n)),100*((e+n)/2)]},n.hsv.rgb=function(t){const r=t[0]/60,n=t[1]/100;let e=t[2]/100;const o=Math.floor(r)%6,a=r-Math.floor(r),s=255*e*(1-n),i=255*e*(1-n*a),c=255*e*(1-n*(1-a));switch(e*=255,o){case 0:return[e,c,s];case 1:return[i,e,s];case 2:return[s,e,c];case 3:return[s,i,e];case 4:return[c,s,e];case 5:return[e,s,i]}},n.hsv.hsl=function(t){const r=t[0],n=t[1]/100,e=t[2]/100,o=Math.max(e,.01);let a,s;s=(2-n)*e;const i=(2-n)*o;return a=n*o,a/=i<=1?i:2-i,a=a||0,s/=2,[r,100*a,100*s]},n.hwb.rgb=function(t){const r=t[0]/360;let n=t[1]/100,e=t[2]/100;const o=n+e;let a;o>1&&(n/=o,e/=o);const s=Math.floor(6*r),i=1-e;a=6*r-s,1&s&&(a=1-a);const c=n+a*(i-n);let u,l,h;switch(s){default:case 6:case 0:u=i,l=c,h=n;break;case 1:u=c,l=i,h=n;break;case 2:u=n,l=i,h=c;break;case 3:u=n,l=c,h=i;break;case 4:u=c,l=n,h=i;break;case 5:u=i,l=n,h=c}return[255*u,255*l,255*h]},n.cmyk.rgb=function(t){const r=t[0]/100,n=t[1]/100,e=t[2]/100,o=t[3]/100;return[255*(1-Math.min(1,r*(1-o)+o)),255*(1-Math.min(1,n*(1-o)+o)),255*(1-Math.min(1,e*(1-o)+o))]},n.xyz.rgb=function(t){const r=t[0]/100,n=t[1]/100,e=t[2]/100;let o,a,s;return o=3.2406*r+-1.5372*n+-.4986*e,a=-.9689*r+1.8758*n+.0415*e,s=.0557*r+-.204*n+1.057*e,o=o>.0031308?1.055*o**(1/2.4)-.055:12.92*o,a=a>.0031308?1.055*a**(1/2.4)-.055:12.92*a,s=s>.0031308?1.055*s**(1/2.4)-.055:12.92*s,o=Math.min(Math.max(0,o),1),a=Math.min(Math.max(0,a),1),s=Math.min(Math.max(0,s),1),[255*o,255*a,255*s]},n.xyz.lab=function(t){let r=t[0],n=t[1],e=t[2];r/=95.047,n/=100,e/=108.883,r=r>.008856?r**(1/3):7.787*r+16/116,n=n>.008856?n**(1/3):7.787*n+16/116,e=e>.008856?e**(1/3):7.787*e+16/116;return[116*n-16,500*(r-n),200*(n-e)]},n.lab.xyz=function(t){let r,n,e;n=(t[0]+16)/116,r=t[1]/500+n,e=n-t[2]/200;const o=n**3,a=r**3,s=e**3;return n=o>.008856?o:(n-16/116)/7.787,r=a>.008856?a:(r-16/116)/7.787,e=s>.008856?s:(e-16/116)/7.787,r*=95.047,n*=100,e*=108.883,[r,n,e]},n.lab.lch=function(t){const r=t[0],n=t[1],e=t[2];let o;o=360*Math.atan2(e,n)/2/Math.PI,o<0&&(o+=360);return[r,Math.sqrt(n*n+e*e),o]},n.lch.lab=function(t){const r=t[0],n=t[1],e=t[2]/360*2*Math.PI;return[r,n*Math.cos(e),n*Math.sin(e)]},n.rgb.ansi16=function(t,r=null){const[e,o,a]=t;let s=null===r?n.rgb.hsv(t)[2]:r;if(s=Math.round(s/50),0===s)return 30;let i=30+(Math.round(a/255)<<2|Math.round(o/255)<<1|Math.round(e/255));return 2===s&&(i+=60),i},n.hsv.ansi16=function(t){return n.rgb.ansi16(n.hsv.rgb(t),t[2])},n.rgb.ansi256=function(t){const r=t[0],n=t[1],e=t[2];if(r===n&&n===e)return r<8?16:r>248?231:Math.round((r-8)/247*24)+232;return 16+36*Math.round(r/255*5)+6*Math.round(n/255*5)+Math.round(e/255*5)},n.ansi16.rgb=function(t){let r=t%10;if(0===r||7===r)return t>50&&(r+=3.5),r=r/10.5*255,[r,r,r];const n=.5*(1+~~(t>50));return[(1&r)*n*255,(r>>1&1)*n*255,(r>>2&1)*n*255]},n.ansi256.rgb=function(t){if(t>=232){const r=10*(t-232)+8;return[r,r,r]}let r;t-=16;return[Math.floor(t/36)/5*255,Math.floor((r=t%36)/6)/5*255,r%6/5*255]},n.rgb.hex=function(t){const r=(((255&Math.round(t[0]))<<16)+((255&Math.round(t[1]))<<8)+(255&Math.round(t[2]))).toString(16).toUpperCase();return"000000".substring(r.length)+r},n.hex.rgb=function(t){const r=t.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);if(!r)return[0,0,0];let n=r[0];3===r[0].length&&(n=n.split("").map((t=>t+t)).join(""));const e=parseInt(n,16);return[e>>16&255,e>>8&255,255&e]},n.rgb.hcg=function(t){const r=t[0]/255,n=t[1]/255,e=t[2]/255,o=Math.max(Math.max(r,n),e),a=Math.min(Math.min(r,n),e),s=o-a;let i,c;return i=s<1?a/(1-s):0,c=s<=0?0:o===r?(n-e)/s%6:o===n?2+(e-r)/s:4+(r-n)/s,c/=6,c%=1,[360*c,100*s,100*i]},n.hsl.hcg=function(t){const r=t[1]/100,n=t[2]/100,e=n<.5?2*r*n:2*r*(1-n);let o=0;return e<1&&(o=(n-.5*e)/(1-e)),[t[0],100*e,100*o]},n.hsv.hcg=function(t){const r=t[1]/100,n=t[2]/100,e=r*n;let o=0;return e<1&&(o=(n-e)/(1-e)),[t[0],100*e,100*o]},n.hcg.rgb=function(t){const r=t[0]/360,n=t[1]/100,e=t[2]/100;if(0===n)return[255*e,255*e,255*e];const o=[0,0,0],a=r%1*6,s=a%1,i=1-s;let c=0;switch(Math.floor(a)){case 0:o[0]=1,o[1]=s,o[2]=0;break;case 1:o[0]=i,o[1]=1,o[2]=0;break;case 2:o[0]=0,o[1]=1,o[2]=s;break;case 3:o[0]=0,o[1]=i,o[2]=1;break;case 4:o[0]=s,o[1]=0,o[2]=1;break;default:o[0]=1,o[1]=0,o[2]=i}return c=(1-n)*e,[255*(n*o[0]+c),255*(n*o[1]+c),255*(n*o[2]+c)]},n.hcg.hsv=function(t){const r=t[1]/100,n=r+t[2]/100*(1-r);let e=0;return n>0&&(e=r/n),[t[0],100*e,100*n]},n.hcg.hsl=function(t){const r=t[1]/100,n=t[2]/100*(1-r)+.5*r;let e=0;return n>0&&n<.5?e=r/(2*n):n>=.5&&n<1&&(e=r/(2*(1-n))),[t[0],100*e,100*n]},n.hcg.hwb=function(t){const r=t[1]/100,n=r+t[2]/100*(1-r);return[t[0],100*(n-r),100*(1-n)]},n.hwb.hcg=function(t){const r=t[1]/100,n=1-t[2]/100,e=n-r;let o=0;return e<1&&(o=(n-e)/(1-e)),[t[0],100*e,100*o]},n.apple.rgb=function(t){return[t[0]/65535*255,t[1]/65535*255,t[2]/65535*255]},n.rgb.apple=function(t){return[t[0]/255*65535,t[1]/255*65535,t[2]/255*65535]},n.gray.rgb=function(t){return[t[0]/100*255,t[0]/100*255,t[0]/100*255]},n.gray.hsl=function(t){return[0,0,t[0]]},n.gray.hsv=n.gray.hsl,n.gray.hwb=function(t){return[0,100,t[0]]},n.gray.cmyk=function(t){return[0,0,0,t[0]]},n.gray.lab=function(t){return[t[0],0,0]},n.gray.hex=function(t){const r=255&Math.round(t[0]/100*255),n=((r<<16)+(r<<8)+r).toString(16).toUpperCase();return"000000".substring(n.length)+n},n.rgb.gray=function(t){return[(t[0]+t[1]+t[2])/3/255*100]},i}function m(){if(l)return u;l=1;const t=y();function r(r){const n=function(){const r={},n=Object.keys(t);for(let t=n.length,e=0;e<t;e++)r[n[e]]={distance:-1,parent:null};return r}(),e=[r];for(n[r].distance=0;e.length;){const r=e.pop(),o=Object.keys(t[r]);for(let t=o.length,a=0;a<t;a++){const t=o[a],s=n[t];-1===s.distance&&(s.distance=n[r].distance+1,s.parent=r,e.unshift(t))}}return n}function n(t,r){return function(n){return r(t(n))}}function e(r,e){const o=[e[r].parent,r];let a=t[e[r].parent][r],s=e[r].parent;for(;e[s].parent;)o.unshift(e[s].parent),a=n(t[e[s].parent][s],a),s=e[s].parent;return a.conversion=o,a}return u=function(t){const n=r(t),o={},a=Object.keys(n);for(let t=a.length,r=0;r<t;r++){const t=a[r];null!==n[t].parent&&(o[t]=e(t,n))}return o}}"function"==typeof SuppressedError&&SuppressedError;var v=function(){if(p)return h;p=1;const t=y(),r=m(),n={};return Object.keys(t).forEach((e=>{n[e]={},Object.defineProperty(n[e],"channels",{value:t[e].channels}),Object.defineProperty(n[e],"labels",{value:t[e].labels});const o=r(e);Object.keys(o).forEach((t=>{const r=o[t];n[e][t]=function(t){const r=function(...r){const n=r[0];if(null==n)return n;n.length>1&&(r=n);const e=t(r);if("object"==typeof e)for(let t=e.length,r=0;r<t;r++)e[r]=Math.round(e[r]);return e};return"conversion"in t&&(r.conversion=t.conversion),r}(r),n[e][t].raw=function(t){const r=function(...r){const n=r[0];return null==n?n:(n.length>1&&(r=n),t(r))};return"conversion"in t&&(r.conversion=t.conversion),r}(r)}))})),h=n}(),M=d(v),w=function(t){function o(){return null!==t&&t.apply(this,arguments)||this}return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=t}g(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}(o,t),o.prototype.toInvert=function(){var t=this.toJson();t.r,t.g,t.b,t.a;return new o(255-this.r,255-this.g,255-this.b,1-this.a)},o.prototype.clone=function(){var t=new o(this.r,this.g,this.b,this.a);return t._outColorPrecision=this._outColorPrecision,t._outAlphaPrecision=this._outAlphaPrecision,t},o.prototype.equals=function(t){if(this===(t=o.parseColor(t)))return!0;var r=this.toJson(),n=t.toJson();return r.r===n.r&&r.g===n.g&&r.b===n.g&&r.a===n.a},o.prototype.add=function(r,n){void 0===n&&(n=!0);var e=o.parseColor(r);return t.prototype.add.call(this,e,n)},o.prototype.subtract=function(r,n){void 0===n&&(n=!0);var e=o.parseColor(r);return t.prototype.subtract.call(this,e,n)},o.prototype.multiply=function(r,n){void 0===n&&(n=!0);var e=o.parseColor(r);return t.prototype.multiply.call(this,e,n)},o.prototype.divide=function(r,n){void 0===n&&(n=!0);var e=o.parseColor(r);return t.prototype.divide.call(this,e,n)},o.parseColor=function(t){return t instanceof b?t.clone():o.parseCssColorStr(t)},o.parseCssColorStr=function(t){return r.type("color",t,"string"),o.parseHEX(t)||o.parseRGBA(t)||o.parseKeyWord(t)||o.parseHSLA(t)||o.parseHWB(t)},o.parseKeyWord=function(t){var r=f.clearStrSpace(t),n=M.keyword.rgb(r);return n&&o.fromArray(n)},o.parseHSLA=function(t){var r=f.clearStrSpace(t),n=f.parseHSLA(r);if(!n){var e=f.trimStr(t);n=f.parseHSLA2(e)}return n&&o.fromHSL(n[0],n[1],n[2],n[3])},o.parseHWB=function(t){var r=f.trimStr(t),n=f.parseHWB(r);return n&&o.fromHWB(n[0],n[1],n[2],n[3])},o.fromHSL=function(t,r,a,s){var i=M.hsl.rgb(e(0,360,t),e(0,100,100*r),e(0,100,100*a));return new o(i[0],i[1],i[2],n(Number(s),1))},o.fromHWB=function(t,r,a,s){var i=M.hwb.rgb(e(0,360,t),e(0,100,100*r),e(0,100,100*a));return new o(i[0],i[1],i[2],n(Number(s),1))},o.parseHEX=function(t){var r=f.clearStrSpace(t),n=f.parse3BitsHEX(r);return n||(n=f.parse6BitsHEX(r)),n&&o.fromArray(n)},o.parseRGBA=function(t){var r=f.clearStrSpace(t),n=f.parseRGBA(r);if(!n){var e=f.trimStr(t);n=f.parseRGBA2(e)}return n&&o.fromArray(n)},o.fromJson=function(t){return new o(t.r,t.g,t.b,t.a)},o.fromArray=function(t){return new o(t[0],t[1],t[2],t[3])},o.fromRandom=function(t,r){return void 0===t&&(t=new o(0,0,0,1)),void 0===r&&(r=new o(255,255,255,1)),t=o.parseColor(t),r=o.parseColor(r),new o(Math.random()*Math.abs(r.r-t.r)+Math.min(t.r,r.r),Math.random()*Math.abs(r.g-t.g)+Math.min(t.g,r.g),Math.random()*Math.abs(r.b-t.b)+Math.min(t.b,r.b),Math.random()*Math.abs(r.a-t.a)+Math.min(t.a,r.a))},o.fromNormalize=function(t){var r=255*t[0],n=255*t[1],e=255*t[2],a=t[3];return o.fromArray([r,n,e,a])},o.lerp=function(t,r){var n=Object.keys(t).map((function(t){return Number(t)}));n.sort((function(t,r){return t-r}));for(var e=0;e<n.length;e++)if(r<=n[e]){var a=n[e-1],s=n[e];if(void 0===a)return o.parseColor(t[s]);var i=(r-a)/(s-a),c=o.parseColor(t[a]);return o.parseColor(t[s]).subtract(c).multiplyByScalar(i).add(c)}return o.parseColor(t[n[n.length-1]]).limitColor()},o}(b);t.CssColorParser=b,t.CssColorParserPlus=w}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "css-color-parser-h",
3
- "version": "3.0.9",
3
+ "version": "3.0.10",
4
4
  "description": "A tool for parsing css color",
5
5
  "main": "lib/css-color-parser-h.cjs.js",
6
6
  "module": "lib/css-color-parser-h.esm.js",