@machinemetrics/mm-erp-sdk 0.1.8-beta.1 → 0.1.8-beta.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.
Files changed (46) hide show
  1. package/dist/{config-CV-KosWV.js → config-cB7h4yvc.js} +2 -2
  2. package/dist/{config-CV-KosWV.js.map → config-cB7h4yvc.js.map} +1 -1
  3. package/dist/{connector-factory-D8v6aQIt.js → connector-factory-CKm74_WZ.js} +2 -2
  4. package/dist/{connector-factory-D8v6aQIt.js.map → connector-factory-CKm74_WZ.js.map} +1 -1
  5. package/dist/{hashed-cache-manager-B6hTDLxU.js → hashed-cache-manager-B1hPBNnF.js} +4 -4
  6. package/dist/{hashed-cache-manager-B6hTDLxU.js.map → hashed-cache-manager-B1hPBNnF.js.map} +1 -1
  7. package/dist/{index-Bg76oouR.js → index-DCgheVjV.js} +2 -2
  8. package/dist/{index-Bg76oouR.js.map → index-DCgheVjV.js.map} +1 -1
  9. package/dist/index.d.ts +1 -1
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/{logger-SqdNut1H.js → logger-CBDNtsMq.js} +969 -1024
  12. package/dist/logger-CBDNtsMq.js.map +1 -0
  13. package/dist/mm-erp-sdk.js +60 -53
  14. package/dist/mm-erp-sdk.js.map +1 -1
  15. package/dist/services/data-sync-service/jobs/clean-up-expired-cache.js +4 -4
  16. package/dist/services/data-sync-service/jobs/from-erp.js +4 -4
  17. package/dist/services/data-sync-service/jobs/retry-failed-labor-tickets.js +3 -3
  18. package/dist/services/data-sync-service/jobs/run-migrations.js +1 -1
  19. package/dist/services/data-sync-service/jobs/to-erp.js +3 -3
  20. package/dist/services/psql-erp-service/index.d.ts +0 -5
  21. package/dist/services/psql-erp-service/index.d.ts.map +1 -1
  22. package/dist/services/psql-erp-service/internal/types/psql-types.d.ts +0 -3
  23. package/dist/services/psql-erp-service/internal/types/psql-types.d.ts.map +1 -1
  24. package/dist/services/psql-erp-service/psql-service.d.ts +7 -0
  25. package/dist/services/psql-erp-service/psql-service.d.ts.map +1 -1
  26. package/dist/services/reporting-service/logger.d.ts.map +1 -1
  27. package/dist/utils/index.d.ts +1 -1
  28. package/dist/utils/index.d.ts.map +1 -1
  29. package/dist/utils/timezone.d.ts +7 -0
  30. package/dist/utils/timezone.d.ts.map +1 -1
  31. package/package.json +4 -3
  32. package/src/index.ts +0 -1
  33. package/src/services/psql-erp-service/index.ts +0 -6
  34. package/src/services/psql-erp-service/internal/types/psql-types.ts +0 -4
  35. package/src/services/psql-erp-service/psql-service.ts +65 -3
  36. package/src/services/reporting-service/logger.ts +57 -70
  37. package/src/utils/index.ts +1 -1
  38. package/src/utils/mm-labor-ticket-helpers.ts +2 -2
  39. package/src/utils/timezone.ts +28 -0
  40. package/dist/logger-SqdNut1H.js.map +0 -1
  41. package/dist/services/psql-erp-service/internal/psql-config.d.ts +0 -28
  42. package/dist/services/psql-erp-service/internal/psql-config.d.ts.map +0 -1
  43. package/dist/services/psql-erp-service/internal/psql-labor-ticket-operations.d.ts +0 -40
  44. package/dist/services/psql-erp-service/internal/psql-labor-ticket-operations.d.ts.map +0 -1
  45. package/src/services/psql-erp-service/internal/psql-config.ts +0 -13
  46. package/src/services/psql-erp-service/internal/psql-labor-ticket-operations.ts +0 -58
@@ -2946,7 +2946,7 @@ var common$1 = {};
2946
2946
  const common = /* @__PURE__ */ getDefaultExportFromCjs(common$1);
2947
2947
  const name$1 = "winston";
2948
2948
  const description = "A logger for just about everything.";
2949
- const version = "3.17.0";
2949
+ const version = "3.18.3";
2950
2950
  const author = "Charlie Robbins <charlie.robbins@gmail.com>";
2951
2951
  const maintainers = [
2952
2952
  "David Hyde <dabh@alumni.stanford.edu>"
@@ -2969,7 +2969,7 @@ const keywords = [
2969
2969
  "stream"
2970
2970
  ];
2971
2971
  const dependencies = {
2972
- "@dabh/diagnostics": "^2.0.2",
2972
+ "@dabh/diagnostics": "^2.0.8",
2973
2973
  "@colors/colors": "^1.6.0",
2974
2974
  async: "^3.2.3",
2975
2975
  "is-stream": "^2.0.0",
@@ -6635,310 +6635,252 @@ function requireProduction() {
6635
6635
  production = diagnostics2;
6636
6636
  return production;
6637
6637
  }
6638
- var colorString$1 = { exports: {} };
6639
- var colorName;
6640
- var hasRequiredColorName;
6641
- function requireColorName() {
6642
- if (hasRequiredColorName) return colorName;
6643
- hasRequiredColorName = 1;
6638
+ var index_cjs;
6639
+ var hasRequiredIndex_cjs;
6640
+ function requireIndex_cjs() {
6641
+ if (hasRequiredIndex_cjs) return index_cjs;
6642
+ hasRequiredIndex_cjs = 1;
6644
6643
  "use strict";
6645
- colorName = {
6646
- "aliceblue": [240, 248, 255],
6647
- "antiquewhite": [250, 235, 215],
6648
- "aqua": [0, 255, 255],
6649
- "aquamarine": [127, 255, 212],
6650
- "azure": [240, 255, 255],
6651
- "beige": [245, 245, 220],
6652
- "bisque": [255, 228, 196],
6653
- "black": [0, 0, 0],
6654
- "blanchedalmond": [255, 235, 205],
6655
- "blue": [0, 0, 255],
6656
- "blueviolet": [138, 43, 226],
6657
- "brown": [165, 42, 42],
6658
- "burlywood": [222, 184, 135],
6659
- "cadetblue": [95, 158, 160],
6660
- "chartreuse": [127, 255, 0],
6661
- "chocolate": [210, 105, 30],
6662
- "coral": [255, 127, 80],
6663
- "cornflowerblue": [100, 149, 237],
6664
- "cornsilk": [255, 248, 220],
6665
- "crimson": [220, 20, 60],
6666
- "cyan": [0, 255, 255],
6667
- "darkblue": [0, 0, 139],
6668
- "darkcyan": [0, 139, 139],
6669
- "darkgoldenrod": [184, 134, 11],
6670
- "darkgray": [169, 169, 169],
6671
- "darkgreen": [0, 100, 0],
6672
- "darkgrey": [169, 169, 169],
6673
- "darkkhaki": [189, 183, 107],
6674
- "darkmagenta": [139, 0, 139],
6675
- "darkolivegreen": [85, 107, 47],
6676
- "darkorange": [255, 140, 0],
6677
- "darkorchid": [153, 50, 204],
6678
- "darkred": [139, 0, 0],
6679
- "darksalmon": [233, 150, 122],
6680
- "darkseagreen": [143, 188, 143],
6681
- "darkslateblue": [72, 61, 139],
6682
- "darkslategray": [47, 79, 79],
6683
- "darkslategrey": [47, 79, 79],
6684
- "darkturquoise": [0, 206, 209],
6685
- "darkviolet": [148, 0, 211],
6686
- "deeppink": [255, 20, 147],
6687
- "deepskyblue": [0, 191, 255],
6688
- "dimgray": [105, 105, 105],
6689
- "dimgrey": [105, 105, 105],
6690
- "dodgerblue": [30, 144, 255],
6691
- "firebrick": [178, 34, 34],
6692
- "floralwhite": [255, 250, 240],
6693
- "forestgreen": [34, 139, 34],
6694
- "fuchsia": [255, 0, 255],
6695
- "gainsboro": [220, 220, 220],
6696
- "ghostwhite": [248, 248, 255],
6697
- "gold": [255, 215, 0],
6698
- "goldenrod": [218, 165, 32],
6699
- "gray": [128, 128, 128],
6700
- "green": [0, 128, 0],
6701
- "greenyellow": [173, 255, 47],
6702
- "grey": [128, 128, 128],
6703
- "honeydew": [240, 255, 240],
6704
- "hotpink": [255, 105, 180],
6705
- "indianred": [205, 92, 92],
6706
- "indigo": [75, 0, 130],
6707
- "ivory": [255, 255, 240],
6708
- "khaki": [240, 230, 140],
6709
- "lavender": [230, 230, 250],
6710
- "lavenderblush": [255, 240, 245],
6711
- "lawngreen": [124, 252, 0],
6712
- "lemonchiffon": [255, 250, 205],
6713
- "lightblue": [173, 216, 230],
6714
- "lightcoral": [240, 128, 128],
6715
- "lightcyan": [224, 255, 255],
6716
- "lightgoldenrodyellow": [250, 250, 210],
6717
- "lightgray": [211, 211, 211],
6718
- "lightgreen": [144, 238, 144],
6719
- "lightgrey": [211, 211, 211],
6720
- "lightpink": [255, 182, 193],
6721
- "lightsalmon": [255, 160, 122],
6722
- "lightseagreen": [32, 178, 170],
6723
- "lightskyblue": [135, 206, 250],
6724
- "lightslategray": [119, 136, 153],
6725
- "lightslategrey": [119, 136, 153],
6726
- "lightsteelblue": [176, 196, 222],
6727
- "lightyellow": [255, 255, 224],
6728
- "lime": [0, 255, 0],
6729
- "limegreen": [50, 205, 50],
6730
- "linen": [250, 240, 230],
6731
- "magenta": [255, 0, 255],
6732
- "maroon": [128, 0, 0],
6733
- "mediumaquamarine": [102, 205, 170],
6734
- "mediumblue": [0, 0, 205],
6735
- "mediumorchid": [186, 85, 211],
6736
- "mediumpurple": [147, 112, 219],
6737
- "mediumseagreen": [60, 179, 113],
6738
- "mediumslateblue": [123, 104, 238],
6739
- "mediumspringgreen": [0, 250, 154],
6740
- "mediumturquoise": [72, 209, 204],
6741
- "mediumvioletred": [199, 21, 133],
6742
- "midnightblue": [25, 25, 112],
6743
- "mintcream": [245, 255, 250],
6744
- "mistyrose": [255, 228, 225],
6745
- "moccasin": [255, 228, 181],
6746
- "navajowhite": [255, 222, 173],
6747
- "navy": [0, 0, 128],
6748
- "oldlace": [253, 245, 230],
6749
- "olive": [128, 128, 0],
6750
- "olivedrab": [107, 142, 35],
6751
- "orange": [255, 165, 0],
6752
- "orangered": [255, 69, 0],
6753
- "orchid": [218, 112, 214],
6754
- "palegoldenrod": [238, 232, 170],
6755
- "palegreen": [152, 251, 152],
6756
- "paleturquoise": [175, 238, 238],
6757
- "palevioletred": [219, 112, 147],
6758
- "papayawhip": [255, 239, 213],
6759
- "peachpuff": [255, 218, 185],
6760
- "peru": [205, 133, 63],
6761
- "pink": [255, 192, 203],
6762
- "plum": [221, 160, 221],
6763
- "powderblue": [176, 224, 230],
6764
- "purple": [128, 0, 128],
6765
- "rebeccapurple": [102, 51, 153],
6766
- "red": [255, 0, 0],
6767
- "rosybrown": [188, 143, 143],
6768
- "royalblue": [65, 105, 225],
6769
- "saddlebrown": [139, 69, 19],
6770
- "salmon": [250, 128, 114],
6771
- "sandybrown": [244, 164, 96],
6772
- "seagreen": [46, 139, 87],
6773
- "seashell": [255, 245, 238],
6774
- "sienna": [160, 82, 45],
6775
- "silver": [192, 192, 192],
6776
- "skyblue": [135, 206, 235],
6777
- "slateblue": [106, 90, 205],
6778
- "slategray": [112, 128, 144],
6779
- "slategrey": [112, 128, 144],
6780
- "snow": [255, 250, 250],
6781
- "springgreen": [0, 255, 127],
6782
- "steelblue": [70, 130, 180],
6783
- "tan": [210, 180, 140],
6784
- "teal": [0, 128, 128],
6785
- "thistle": [216, 191, 216],
6786
- "tomato": [255, 99, 71],
6787
- "turquoise": [64, 224, 208],
6788
- "violet": [238, 130, 238],
6789
- "wheat": [245, 222, 179],
6790
- "white": [255, 255, 255],
6791
- "whitesmoke": [245, 245, 245],
6792
- "yellow": [255, 255, 0],
6793
- "yellowgreen": [154, 205, 50]
6644
+ var cssKeywords = {
6645
+ aliceblue: [240, 248, 255],
6646
+ antiquewhite: [250, 235, 215],
6647
+ aqua: [0, 255, 255],
6648
+ aquamarine: [127, 255, 212],
6649
+ azure: [240, 255, 255],
6650
+ beige: [245, 245, 220],
6651
+ bisque: [255, 228, 196],
6652
+ black: [0, 0, 0],
6653
+ blanchedalmond: [255, 235, 205],
6654
+ blue: [0, 0, 255],
6655
+ blueviolet: [138, 43, 226],
6656
+ brown: [165, 42, 42],
6657
+ burlywood: [222, 184, 135],
6658
+ cadetblue: [95, 158, 160],
6659
+ chartreuse: [127, 255, 0],
6660
+ chocolate: [210, 105, 30],
6661
+ coral: [255, 127, 80],
6662
+ cornflowerblue: [100, 149, 237],
6663
+ cornsilk: [255, 248, 220],
6664
+ crimson: [220, 20, 60],
6665
+ cyan: [0, 255, 255],
6666
+ darkblue: [0, 0, 139],
6667
+ darkcyan: [0, 139, 139],
6668
+ darkgoldenrod: [184, 134, 11],
6669
+ darkgray: [169, 169, 169],
6670
+ darkgreen: [0, 100, 0],
6671
+ darkgrey: [169, 169, 169],
6672
+ darkkhaki: [189, 183, 107],
6673
+ darkmagenta: [139, 0, 139],
6674
+ darkolivegreen: [85, 107, 47],
6675
+ darkorange: [255, 140, 0],
6676
+ darkorchid: [153, 50, 204],
6677
+ darkred: [139, 0, 0],
6678
+ darksalmon: [233, 150, 122],
6679
+ darkseagreen: [143, 188, 143],
6680
+ darkslateblue: [72, 61, 139],
6681
+ darkslategray: [47, 79, 79],
6682
+ darkslategrey: [47, 79, 79],
6683
+ darkturquoise: [0, 206, 209],
6684
+ darkviolet: [148, 0, 211],
6685
+ deeppink: [255, 20, 147],
6686
+ deepskyblue: [0, 191, 255],
6687
+ dimgray: [105, 105, 105],
6688
+ dimgrey: [105, 105, 105],
6689
+ dodgerblue: [30, 144, 255],
6690
+ firebrick: [178, 34, 34],
6691
+ floralwhite: [255, 250, 240],
6692
+ forestgreen: [34, 139, 34],
6693
+ fuchsia: [255, 0, 255],
6694
+ gainsboro: [220, 220, 220],
6695
+ ghostwhite: [248, 248, 255],
6696
+ gold: [255, 215, 0],
6697
+ goldenrod: [218, 165, 32],
6698
+ gray: [128, 128, 128],
6699
+ green: [0, 128, 0],
6700
+ greenyellow: [173, 255, 47],
6701
+ grey: [128, 128, 128],
6702
+ honeydew: [240, 255, 240],
6703
+ hotpink: [255, 105, 180],
6704
+ indianred: [205, 92, 92],
6705
+ indigo: [75, 0, 130],
6706
+ ivory: [255, 255, 240],
6707
+ khaki: [240, 230, 140],
6708
+ lavender: [230, 230, 250],
6709
+ lavenderblush: [255, 240, 245],
6710
+ lawngreen: [124, 252, 0],
6711
+ lemonchiffon: [255, 250, 205],
6712
+ lightblue: [173, 216, 230],
6713
+ lightcoral: [240, 128, 128],
6714
+ lightcyan: [224, 255, 255],
6715
+ lightgoldenrodyellow: [250, 250, 210],
6716
+ lightgray: [211, 211, 211],
6717
+ lightgreen: [144, 238, 144],
6718
+ lightgrey: [211, 211, 211],
6719
+ lightpink: [255, 182, 193],
6720
+ lightsalmon: [255, 160, 122],
6721
+ lightseagreen: [32, 178, 170],
6722
+ lightskyblue: [135, 206, 250],
6723
+ lightslategray: [119, 136, 153],
6724
+ lightslategrey: [119, 136, 153],
6725
+ lightsteelblue: [176, 196, 222],
6726
+ lightyellow: [255, 255, 224],
6727
+ lime: [0, 255, 0],
6728
+ limegreen: [50, 205, 50],
6729
+ linen: [250, 240, 230],
6730
+ magenta: [255, 0, 255],
6731
+ maroon: [128, 0, 0],
6732
+ mediumaquamarine: [102, 205, 170],
6733
+ mediumblue: [0, 0, 205],
6734
+ mediumorchid: [186, 85, 211],
6735
+ mediumpurple: [147, 112, 219],
6736
+ mediumseagreen: [60, 179, 113],
6737
+ mediumslateblue: [123, 104, 238],
6738
+ mediumspringgreen: [0, 250, 154],
6739
+ mediumturquoise: [72, 209, 204],
6740
+ mediumvioletred: [199, 21, 133],
6741
+ midnightblue: [25, 25, 112],
6742
+ mintcream: [245, 255, 250],
6743
+ mistyrose: [255, 228, 225],
6744
+ moccasin: [255, 228, 181],
6745
+ navajowhite: [255, 222, 173],
6746
+ navy: [0, 0, 128],
6747
+ oldlace: [253, 245, 230],
6748
+ olive: [128, 128, 0],
6749
+ olivedrab: [107, 142, 35],
6750
+ orange: [255, 165, 0],
6751
+ orangered: [255, 69, 0],
6752
+ orchid: [218, 112, 214],
6753
+ palegoldenrod: [238, 232, 170],
6754
+ palegreen: [152, 251, 152],
6755
+ paleturquoise: [175, 238, 238],
6756
+ palevioletred: [219, 112, 147],
6757
+ papayawhip: [255, 239, 213],
6758
+ peachpuff: [255, 218, 185],
6759
+ peru: [205, 133, 63],
6760
+ pink: [255, 192, 203],
6761
+ plum: [221, 160, 221],
6762
+ powderblue: [176, 224, 230],
6763
+ purple: [128, 0, 128],
6764
+ rebeccapurple: [102, 51, 153],
6765
+ red: [255, 0, 0],
6766
+ rosybrown: [188, 143, 143],
6767
+ royalblue: [65, 105, 225],
6768
+ saddlebrown: [139, 69, 19],
6769
+ salmon: [250, 128, 114],
6770
+ sandybrown: [244, 164, 96],
6771
+ seagreen: [46, 139, 87],
6772
+ seashell: [255, 245, 238],
6773
+ sienna: [160, 82, 45],
6774
+ silver: [192, 192, 192],
6775
+ skyblue: [135, 206, 235],
6776
+ slateblue: [106, 90, 205],
6777
+ slategray: [112, 128, 144],
6778
+ slategrey: [112, 128, 144],
6779
+ snow: [255, 250, 250],
6780
+ springgreen: [0, 255, 127],
6781
+ steelblue: [70, 130, 180],
6782
+ tan: [210, 180, 140],
6783
+ teal: [0, 128, 128],
6784
+ thistle: [216, 191, 216],
6785
+ tomato: [255, 99, 71],
6786
+ turquoise: [64, 224, 208],
6787
+ violet: [238, 130, 238],
6788
+ wheat: [245, 222, 179],
6789
+ white: [255, 255, 255],
6790
+ whitesmoke: [245, 245, 245],
6791
+ yellow: [255, 255, 0],
6792
+ yellowgreen: [154, 205, 50]
6794
6793
  };
6795
- return colorName;
6796
- }
6797
- var simpleSwizzle$1 = { exports: {} };
6798
- var isArrayish;
6799
- var hasRequiredIsArrayish;
6800
- function requireIsArrayish() {
6801
- if (hasRequiredIsArrayish) return isArrayish;
6802
- hasRequiredIsArrayish = 1;
6803
- isArrayish = function isArrayish2(obj) {
6804
- if (!obj || typeof obj === "string") {
6805
- return false;
6794
+ const reverseNames = /* @__PURE__ */ Object.create(null);
6795
+ for (const name3 in cssKeywords) {
6796
+ if (Object.hasOwn(cssKeywords, name3)) {
6797
+ reverseNames[cssKeywords[name3]] = name3;
6806
6798
  }
6807
- return obj instanceof Array || Array.isArray(obj) || obj.length >= 0 && (obj.splice instanceof Function || Object.getOwnPropertyDescriptor(obj, obj.length - 1) && obj.constructor.name !== "String");
6808
- };
6809
- return isArrayish;
6810
- }
6811
- var simpleSwizzle = simpleSwizzle$1.exports;
6812
- var hasRequiredSimpleSwizzle;
6813
- function requireSimpleSwizzle() {
6814
- if (hasRequiredSimpleSwizzle) return simpleSwizzle$1.exports;
6815
- hasRequiredSimpleSwizzle = 1;
6816
- "use strict";
6817
- var isArrayish2 = requireIsArrayish();
6818
- var concat = Array.prototype.concat;
6819
- var slice = Array.prototype.slice;
6820
- var swizzle = simpleSwizzle$1.exports = function swizzle2(args) {
6821
- var results = [];
6822
- for (var i = 0, len = args.length; i < len; i++) {
6823
- var arg = args[i];
6824
- if (isArrayish2(arg)) {
6825
- results = concat.call(results, slice.call(arg));
6826
- } else {
6827
- results.push(arg);
6828
- }
6829
- }
6830
- return results;
6831
- };
6832
- swizzle.wrap = function(fn) {
6833
- return function() {
6834
- return fn(swizzle(arguments));
6835
- };
6836
- };
6837
- return simpleSwizzle$1.exports;
6838
- }
6839
- var colorString = colorString$1.exports;
6840
- var hasRequiredColorString;
6841
- function requireColorString() {
6842
- if (hasRequiredColorString) return colorString$1.exports;
6843
- hasRequiredColorString = 1;
6844
- var colorNames = requireColorName();
6845
- var swizzle = requireSimpleSwizzle();
6846
- var hasOwnProperty = Object.hasOwnProperty;
6847
- var reverseNames = /* @__PURE__ */ Object.create(null);
6848
- for (var name3 in colorNames) {
6849
- if (hasOwnProperty.call(colorNames, name3)) {
6850
- reverseNames[colorNames[name3]] = name3;
6851
- }
6852
- }
6853
- var cs = colorString$1.exports = {
6799
+ }
6800
+ const cs = {
6854
6801
  to: {},
6855
6802
  get: {}
6856
6803
  };
6857
6804
  cs.get = function(string) {
6858
- var prefix = string.substring(0, 3).toLowerCase();
6859
- var val;
6860
- var model;
6805
+ const prefix = string.slice(0, 3).toLowerCase();
6806
+ let value;
6807
+ let model;
6861
6808
  switch (prefix) {
6862
- case "hsl":
6863
- val = cs.get.hsl(string);
6809
+ case "hsl": {
6810
+ value = cs.get.hsl(string);
6864
6811
  model = "hsl";
6865
6812
  break;
6866
- case "hwb":
6867
- val = cs.get.hwb(string);
6813
+ }
6814
+ case "hwb": {
6815
+ value = cs.get.hwb(string);
6868
6816
  model = "hwb";
6869
6817
  break;
6870
- default:
6871
- val = cs.get.rgb(string);
6818
+ }
6819
+ default: {
6820
+ value = cs.get.rgb(string);
6872
6821
  model = "rgb";
6873
6822
  break;
6823
+ }
6874
6824
  }
6875
- if (!val) {
6825
+ if (!value) {
6876
6826
  return null;
6877
6827
  }
6878
- return { model, value: val };
6828
+ return { model, value };
6879
6829
  };
6880
6830
  cs.get.rgb = function(string) {
6881
6831
  if (!string) {
6882
6832
  return null;
6883
6833
  }
6884
- var abbr = /^#([a-f0-9]{3,4})$/i;
6885
- var hex = /^#([a-f0-9]{6})([a-f0-9]{2})?$/i;
6886
- var rgba = /^rgba?\(\s*([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/;
6887
- var per = /^rgba?\(\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/;
6888
- var keyword = /^(\w+)$/;
6889
- var rgb = [0, 0, 0, 1];
6890
- var match;
6891
- var i;
6892
- var hexAlpha;
6893
- if (match = string.match(hex)) {
6834
+ const abbr = /^#([a-f\d]{3,4})$/i;
6835
+ const hex2 = /^#([a-f\d]{6})([a-f\d]{2})?$/i;
6836
+ const rgba = /^rgba?\(\s*([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)\s*(?:[\s,|/]\s*([+-]?[\d.]+)(%?)\s*)?\)$/;
6837
+ const per = /^rgba?\(\s*([+-]?[\d.]+)%\s*,?\s*([+-]?[\d.]+)%\s*,?\s*([+-]?[\d.]+)%\s*(?:[\s,|/]\s*([+-]?[\d.]+)(%?)\s*)?\)$/;
6838
+ const keyword = /^(\w+)$/;
6839
+ let rgb = [0, 0, 0, 1];
6840
+ let match;
6841
+ let i;
6842
+ let hexAlpha;
6843
+ if (match = string.match(hex2)) {
6894
6844
  hexAlpha = match[2];
6895
6845
  match = match[1];
6896
6846
  for (i = 0; i < 3; i++) {
6897
- var i2 = i * 2;
6898
- rgb[i] = parseInt(match.slice(i2, i2 + 2), 16);
6847
+ const i2 = i * 2;
6848
+ rgb[i] = Number.parseInt(match.slice(i2, i2 + 2), 16);
6899
6849
  }
6900
6850
  if (hexAlpha) {
6901
- rgb[3] = parseInt(hexAlpha, 16) / 255;
6851
+ rgb[3] = Number.parseInt(hexAlpha, 16) / 255;
6902
6852
  }
6903
6853
  } else if (match = string.match(abbr)) {
6904
6854
  match = match[1];
6905
6855
  hexAlpha = match[3];
6906
6856
  for (i = 0; i < 3; i++) {
6907
- rgb[i] = parseInt(match[i] + match[i], 16);
6857
+ rgb[i] = Number.parseInt(match[i] + match[i], 16);
6908
6858
  }
6909
6859
  if (hexAlpha) {
6910
- rgb[3] = parseInt(hexAlpha + hexAlpha, 16) / 255;
6860
+ rgb[3] = Number.parseInt(hexAlpha + hexAlpha, 16) / 255;
6911
6861
  }
6912
6862
  } else if (match = string.match(rgba)) {
6913
6863
  for (i = 0; i < 3; i++) {
6914
- rgb[i] = parseInt(match[i + 1], 0);
6864
+ rgb[i] = Number.parseInt(match[i + 1], 10);
6915
6865
  }
6916
6866
  if (match[4]) {
6917
- if (match[5]) {
6918
- rgb[3] = parseFloat(match[4]) * 0.01;
6919
- } else {
6920
- rgb[3] = parseFloat(match[4]);
6921
- }
6867
+ rgb[3] = match[5] ? Number.parseFloat(match[4]) * 0.01 : Number.parseFloat(match[4]);
6922
6868
  }
6923
6869
  } else if (match = string.match(per)) {
6924
6870
  for (i = 0; i < 3; i++) {
6925
- rgb[i] = Math.round(parseFloat(match[i + 1]) * 2.55);
6871
+ rgb[i] = Math.round(Number.parseFloat(match[i + 1]) * 2.55);
6926
6872
  }
6927
6873
  if (match[4]) {
6928
- if (match[5]) {
6929
- rgb[3] = parseFloat(match[4]) * 0.01;
6930
- } else {
6931
- rgb[3] = parseFloat(match[4]);
6932
- }
6874
+ rgb[3] = match[5] ? Number.parseFloat(match[4]) * 0.01 : Number.parseFloat(match[4]);
6933
6875
  }
6934
6876
  } else if (match = string.match(keyword)) {
6935
6877
  if (match[1] === "transparent") {
6936
6878
  return [0, 0, 0, 0];
6937
6879
  }
6938
- if (!hasOwnProperty.call(colorNames, match[1])) {
6880
+ if (!Object.hasOwn(cssKeywords, match[1])) {
6939
6881
  return null;
6940
6882
  }
6941
- rgb = colorNames[match[1]];
6883
+ rgb = cssKeywords[match[1]];
6942
6884
  rgb[3] = 1;
6943
6885
  return rgb;
6944
6886
  } else {
@@ -6954,14 +6896,14 @@ function requireColorString() {
6954
6896
  if (!string) {
6955
6897
  return null;
6956
6898
  }
6957
- var hsl = /^hsla?\(\s*([+-]?(?:\d{0,3}\.)?\d+)(?:deg)?\s*,?\s*([+-]?[\d\.]+)%\s*,?\s*([+-]?[\d\.]+)%\s*(?:[,|\/]\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/;
6958
- var match = string.match(hsl);
6899
+ const hsl = /^hsla?\(\s*([+-]?(?:\d{0,3}\.)?\d+)(?:deg)?\s*,?\s*([+-]?[\d.]+)%\s*,?\s*([+-]?[\d.]+)%\s*(?:[,|/]\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/;
6900
+ const match = string.match(hsl);
6959
6901
  if (match) {
6960
- var alpha = parseFloat(match[4]);
6961
- var h2 = (parseFloat(match[1]) % 360 + 360) % 360;
6962
- var s2 = clamp(parseFloat(match[2]), 0, 100);
6963
- var l = clamp(parseFloat(match[3]), 0, 100);
6964
- var a = clamp(isNaN(alpha) ? 1 : alpha, 0, 1);
6902
+ const alpha = Number.parseFloat(match[4]);
6903
+ const h2 = (Number.parseFloat(match[1]) % 360 + 360) % 360;
6904
+ const s2 = clamp(Number.parseFloat(match[2]), 0, 100);
6905
+ const l = clamp(Number.parseFloat(match[3]), 0, 100);
6906
+ const a = clamp(Number.isNaN(alpha) ? 1 : alpha, 0, 1);
6965
6907
  return [h2, s2, l, a];
6966
6908
  }
6967
6909
  return null;
@@ -6970,71 +6912,55 @@ function requireColorString() {
6970
6912
  if (!string) {
6971
6913
  return null;
6972
6914
  }
6973
- var hwb = /^hwb\(\s*([+-]?\d{0,3}(?:\.\d+)?)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/;
6974
- var match = string.match(hwb);
6915
+ const hwb = /^hwb\(\s*([+-]?\d{0,3}(?:\.\d+)?)(?:deg)?\s*[\s,]\s*([+-]?[\d.]+)%\s*[\s,]\s*([+-]?[\d.]+)%\s*(?:[\s,]\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/;
6916
+ const match = string.match(hwb);
6975
6917
  if (match) {
6976
- var alpha = parseFloat(match[4]);
6977
- var h2 = (parseFloat(match[1]) % 360 + 360) % 360;
6978
- var w2 = clamp(parseFloat(match[2]), 0, 100);
6979
- var b = clamp(parseFloat(match[3]), 0, 100);
6980
- var a = clamp(isNaN(alpha) ? 1 : alpha, 0, 1);
6918
+ const alpha = Number.parseFloat(match[4]);
6919
+ const h2 = (Number.parseFloat(match[1]) % 360 + 360) % 360;
6920
+ const w2 = clamp(Number.parseFloat(match[2]), 0, 100);
6921
+ const b = clamp(Number.parseFloat(match[3]), 0, 100);
6922
+ const a = clamp(Number.isNaN(alpha) ? 1 : alpha, 0, 1);
6981
6923
  return [h2, w2, b, a];
6982
6924
  }
6983
6925
  return null;
6984
6926
  };
6985
- cs.to.hex = function() {
6986
- var rgba = swizzle(arguments);
6927
+ cs.to.hex = function(...rgba) {
6987
6928
  return "#" + hexDouble(rgba[0]) + hexDouble(rgba[1]) + hexDouble(rgba[2]) + (rgba[3] < 1 ? hexDouble(Math.round(rgba[3] * 255)) : "");
6988
6929
  };
6989
- cs.to.rgb = function() {
6990
- var rgba = swizzle(arguments);
6930
+ cs.to.rgb = function(...rgba) {
6991
6931
  return rgba.length < 4 || rgba[3] === 1 ? "rgb(" + Math.round(rgba[0]) + ", " + Math.round(rgba[1]) + ", " + Math.round(rgba[2]) + ")" : "rgba(" + Math.round(rgba[0]) + ", " + Math.round(rgba[1]) + ", " + Math.round(rgba[2]) + ", " + rgba[3] + ")";
6992
6932
  };
6993
- cs.to.rgb.percent = function() {
6994
- var rgba = swizzle(arguments);
6995
- var r = Math.round(rgba[0] / 255 * 100);
6996
- var g = Math.round(rgba[1] / 255 * 100);
6997
- var b = Math.round(rgba[2] / 255 * 100);
6933
+ cs.to.rgb.percent = function(...rgba) {
6934
+ const r = Math.round(rgba[0] / 255 * 100);
6935
+ const g = Math.round(rgba[1] / 255 * 100);
6936
+ const b = Math.round(rgba[2] / 255 * 100);
6998
6937
  return rgba.length < 4 || rgba[3] === 1 ? "rgb(" + r + "%, " + g + "%, " + b + "%)" : "rgba(" + r + "%, " + g + "%, " + b + "%, " + rgba[3] + ")";
6999
6938
  };
7000
- cs.to.hsl = function() {
7001
- var hsla = swizzle(arguments);
6939
+ cs.to.hsl = function(...hsla) {
7002
6940
  return hsla.length < 4 || hsla[3] === 1 ? "hsl(" + hsla[0] + ", " + hsla[1] + "%, " + hsla[2] + "%)" : "hsla(" + hsla[0] + ", " + hsla[1] + "%, " + hsla[2] + "%, " + hsla[3] + ")";
7003
6941
  };
7004
- cs.to.hwb = function() {
7005
- var hwba = swizzle(arguments);
7006
- var a = "";
6942
+ cs.to.hwb = function(...hwba) {
6943
+ let a = "";
7007
6944
  if (hwba.length >= 4 && hwba[3] !== 1) {
7008
6945
  a = ", " + hwba[3];
7009
6946
  }
7010
6947
  return "hwb(" + hwba[0] + ", " + hwba[1] + "%, " + hwba[2] + "%" + a + ")";
7011
6948
  };
7012
- cs.to.keyword = function(rgb) {
6949
+ cs.to.keyword = function(...rgb) {
7013
6950
  return reverseNames[rgb.slice(0, 3)];
7014
6951
  };
7015
- function clamp(num, min2, max2) {
7016
- return Math.min(Math.max(min2, num), max2);
6952
+ function clamp(number_, min2, max2) {
6953
+ return Math.min(Math.max(min2, number_), max2);
7017
6954
  }
7018
- function hexDouble(num) {
7019
- var str = Math.round(num).toString(16).toUpperCase();
7020
- return str.length < 2 ? "0" + str : str;
6955
+ function hexDouble(number_) {
6956
+ const string_ = Math.round(number_).toString(16).toUpperCase();
6957
+ return string_.length < 2 ? "0" + string_ : string_;
7021
6958
  }
7022
- return colorString$1.exports;
7023
- }
7024
- var conversions$1 = { exports: {} };
7025
- var conversions = conversions$1.exports;
7026
- var hasRequiredConversions;
7027
- function requireConversions() {
7028
- if (hasRequiredConversions) return conversions$1.exports;
7029
- hasRequiredConversions = 1;
7030
- var cssKeywords = requireColorName();
7031
- var reverseKeywords = {};
7032
- for (var key in cssKeywords) {
7033
- if (cssKeywords.hasOwnProperty(key)) {
7034
- reverseKeywords[cssKeywords[key]] = key;
7035
- }
6959
+ const reverseKeywords = {};
6960
+ for (const key of Object.keys(cssKeywords)) {
6961
+ reverseKeywords[cssKeywords[key]] = key;
7036
6962
  }
7037
- var convert = conversions$1.exports = {
6963
+ const convert$1 = {
7038
6964
  rgb: { channels: 3, labels: "rgb" },
7039
6965
  hsl: { channels: 3, labels: "hsl" },
7040
6966
  hsv: { channels: 3, labels: "hsv" },
@@ -7042,7 +6968,9 @@ function requireConversions() {
7042
6968
  cmyk: { channels: 4, labels: "cmyk" },
7043
6969
  xyz: { channels: 3, labels: "xyz" },
7044
6970
  lab: { channels: 3, labels: "lab" },
6971
+ oklab: { channels: 3, labels: ["okl", "oka", "okb"] },
7045
6972
  lch: { channels: 3, labels: "lch" },
6973
+ oklch: { channels: 3, labels: ["okl", "okc", "okh"] },
7046
6974
  hex: { channels: 1, labels: ["hex"] },
7047
6975
  keyword: { channels: 1, labels: ["keyword"] },
7048
6976
  ansi16: { channels: 1, labels: ["ansi16"] },
@@ -7051,49 +6979,62 @@ function requireConversions() {
7051
6979
  apple: { channels: 3, labels: ["r16", "g16", "b16"] },
7052
6980
  gray: { channels: 1, labels: ["gray"] }
7053
6981
  };
7054
- for (var model in convert) {
7055
- if (convert.hasOwnProperty(model)) {
7056
- if (!("channels" in convert[model])) {
7057
- throw new Error("missing channels property: " + model);
7058
- }
7059
- if (!("labels" in convert[model])) {
7060
- throw new Error("missing channel labels property: " + model);
7061
- }
7062
- if (convert[model].labels.length !== convert[model].channels) {
7063
- throw new Error("channel and label counts mismatch: " + model);
7064
- }
7065
- var channels = convert[model].channels;
7066
- var labels = convert[model].labels;
7067
- delete convert[model].channels;
7068
- delete convert[model].labels;
7069
- Object.defineProperty(convert[model], "channels", { value: channels });
7070
- Object.defineProperty(convert[model], "labels", { value: labels });
7071
- }
7072
- }
7073
- convert.rgb.hsl = function(rgb) {
7074
- var r = rgb[0] / 255;
7075
- var g = rgb[1] / 255;
7076
- var b = rgb[2] / 255;
7077
- var min2 = Math.min(r, g, b);
7078
- var max2 = Math.max(r, g, b);
7079
- var delta = max2 - min2;
7080
- var h2;
7081
- var s2;
7082
- var l;
7083
- if (max2 === min2) {
7084
- h2 = 0;
7085
- } else if (r === max2) {
7086
- h2 = (g - b) / delta;
7087
- } else if (g === max2) {
7088
- h2 = 2 + (b - r) / delta;
7089
- } else if (b === max2) {
7090
- h2 = 4 + (r - g) / delta;
6982
+ const LAB_FT = (6 / 29) ** 3;
6983
+ function srgbNonlinearTransform(c) {
6984
+ const cc = c > 31308e-7 ? 1.055 * c ** (1 / 2.4) - 0.055 : c * 12.92;
6985
+ return Math.min(Math.max(0, cc), 1);
6986
+ }
6987
+ function srgbNonlinearTransformInv(c) {
6988
+ return c > 0.04045 ? ((c + 0.055) / 1.055) ** 2.4 : c / 12.92;
6989
+ }
6990
+ for (const model of Object.keys(convert$1)) {
6991
+ if (!("channels" in convert$1[model])) {
6992
+ throw new Error("missing channels property: " + model);
6993
+ }
6994
+ if (!("labels" in convert$1[model])) {
6995
+ throw new Error("missing channel labels property: " + model);
6996
+ }
6997
+ if (convert$1[model].labels.length !== convert$1[model].channels) {
6998
+ throw new Error("channel and label counts mismatch: " + model);
6999
+ }
7000
+ const { channels, labels } = convert$1[model];
7001
+ delete convert$1[model].channels;
7002
+ delete convert$1[model].labels;
7003
+ Object.defineProperty(convert$1[model], "channels", { value: channels });
7004
+ Object.defineProperty(convert$1[model], "labels", { value: labels });
7005
+ }
7006
+ convert$1.rgb.hsl = function(rgb) {
7007
+ const r = rgb[0] / 255;
7008
+ const g = rgb[1] / 255;
7009
+ const b = rgb[2] / 255;
7010
+ const min2 = Math.min(r, g, b);
7011
+ const max2 = Math.max(r, g, b);
7012
+ const delta = max2 - min2;
7013
+ let h2;
7014
+ let s2;
7015
+ switch (max2) {
7016
+ case min2: {
7017
+ h2 = 0;
7018
+ break;
7019
+ }
7020
+ case r: {
7021
+ h2 = (g - b) / delta;
7022
+ break;
7023
+ }
7024
+ case g: {
7025
+ h2 = 2 + (b - r) / delta;
7026
+ break;
7027
+ }
7028
+ case b: {
7029
+ h2 = 4 + (r - g) / delta;
7030
+ break;
7031
+ }
7091
7032
  }
7092
7033
  h2 = Math.min(h2 * 60, 360);
7093
7034
  if (h2 < 0) {
7094
7035
  h2 += 360;
7095
7036
  }
7096
- l = (min2 + max2) / 2;
7037
+ const l = (min2 + max2) / 2;
7097
7038
  if (max2 === min2) {
7098
7039
  s2 = 0;
7099
7040
  } else if (l <= 0.5) {
@@ -7103,33 +7044,41 @@ function requireConversions() {
7103
7044
  }
7104
7045
  return [h2, s2 * 100, l * 100];
7105
7046
  };
7106
- convert.rgb.hsv = function(rgb) {
7107
- var rdif;
7108
- var gdif;
7109
- var bdif;
7110
- var h2;
7111
- var s2;
7112
- var r = rgb[0] / 255;
7113
- var g = rgb[1] / 255;
7114
- var b = rgb[2] / 255;
7115
- var v = Math.max(r, g, b);
7116
- var diff2 = v - Math.min(r, g, b);
7117
- var diffc = function(c) {
7047
+ convert$1.rgb.hsv = function(rgb) {
7048
+ let rdif;
7049
+ let gdif;
7050
+ let bdif;
7051
+ let h2;
7052
+ let s2;
7053
+ const r = rgb[0] / 255;
7054
+ const g = rgb[1] / 255;
7055
+ const b = rgb[2] / 255;
7056
+ const v = Math.max(r, g, b);
7057
+ const diff2 = v - Math.min(r, g, b);
7058
+ const diffc = function(c) {
7118
7059
  return (v - c) / 6 / diff2 + 1 / 2;
7119
7060
  };
7120
7061
  if (diff2 === 0) {
7121
- h2 = s2 = 0;
7062
+ h2 = 0;
7063
+ s2 = 0;
7122
7064
  } else {
7123
7065
  s2 = diff2 / v;
7124
7066
  rdif = diffc(r);
7125
7067
  gdif = diffc(g);
7126
7068
  bdif = diffc(b);
7127
- if (r === v) {
7128
- h2 = bdif - gdif;
7129
- } else if (g === v) {
7130
- h2 = 1 / 3 + rdif - bdif;
7131
- } else if (b === v) {
7132
- h2 = 2 / 3 + gdif - rdif;
7069
+ switch (v) {
7070
+ case r: {
7071
+ h2 = bdif - gdif;
7072
+ break;
7073
+ }
7074
+ case g: {
7075
+ h2 = 1 / 3 + rdif - bdif;
7076
+ break;
7077
+ }
7078
+ case b: {
7079
+ h2 = 2 / 3 + gdif - rdif;
7080
+ break;
7081
+ }
7133
7082
  }
7134
7083
  if (h2 < 0) {
7135
7084
  h2 += 1;
@@ -7143,106 +7092,99 @@ function requireConversions() {
7143
7092
  v * 100
7144
7093
  ];
7145
7094
  };
7146
- convert.rgb.hwb = function(rgb) {
7147
- var r = rgb[0];
7148
- var g = rgb[1];
7149
- var b = rgb[2];
7150
- var h2 = convert.rgb.hsl(rgb)[0];
7151
- var w2 = 1 / 255 * Math.min(r, Math.min(g, b));
7095
+ convert$1.rgb.hwb = function(rgb) {
7096
+ const r = rgb[0];
7097
+ const g = rgb[1];
7098
+ let b = rgb[2];
7099
+ const h2 = convert$1.rgb.hsl(rgb)[0];
7100
+ const w2 = 1 / 255 * Math.min(r, Math.min(g, b));
7152
7101
  b = 1 - 1 / 255 * Math.max(r, Math.max(g, b));
7153
7102
  return [h2, w2 * 100, b * 100];
7154
7103
  };
7155
- convert.rgb.cmyk = function(rgb) {
7156
- var r = rgb[0] / 255;
7157
- var g = rgb[1] / 255;
7158
- var b = rgb[2] / 255;
7159
- var c;
7160
- var m2;
7161
- var y2;
7162
- var k;
7163
- k = Math.min(1 - r, 1 - g, 1 - b);
7164
- c = (1 - r - k) / (1 - k) || 0;
7165
- m2 = (1 - g - k) / (1 - k) || 0;
7166
- y2 = (1 - b - k) / (1 - k) || 0;
7104
+ convert$1.rgb.oklab = function(rgb) {
7105
+ const r = srgbNonlinearTransformInv(rgb[0] / 255);
7106
+ const g = srgbNonlinearTransformInv(rgb[1] / 255);
7107
+ const b = srgbNonlinearTransformInv(rgb[2] / 255);
7108
+ const lp = Math.cbrt(0.4122214708 * r + 0.5363325363 * g + 0.0514459929 * b);
7109
+ const mp = Math.cbrt(0.2119034982 * r + 0.6806995451 * g + 0.1073969566 * b);
7110
+ const sp = Math.cbrt(0.0883024619 * r + 0.2817188376 * g + 0.6299787005 * b);
7111
+ const l = 0.2104542553 * lp + 0.793617785 * mp - 0.0040720468 * sp;
7112
+ const aa = 1.9779984951 * lp - 2.428592205 * mp + 0.4505937099 * sp;
7113
+ const bb = 0.0259040371 * lp + 0.7827717662 * mp - 0.808675766 * sp;
7114
+ return [l * 100, aa * 100, bb * 100];
7115
+ };
7116
+ convert$1.rgb.cmyk = function(rgb) {
7117
+ const r = rgb[0] / 255;
7118
+ const g = rgb[1] / 255;
7119
+ const b = rgb[2] / 255;
7120
+ const k = Math.min(1 - r, 1 - g, 1 - b);
7121
+ const c = (1 - r - k) / (1 - k) || 0;
7122
+ const m2 = (1 - g - k) / (1 - k) || 0;
7123
+ const y2 = (1 - b - k) / (1 - k) || 0;
7167
7124
  return [c * 100, m2 * 100, y2 * 100, k * 100];
7168
7125
  };
7169
7126
  function comparativeDistance(x, y2) {
7170
- return Math.pow(x[0] - y2[0], 2) + Math.pow(x[1] - y2[1], 2) + Math.pow(x[2] - y2[2], 2);
7127
+ return (x[0] - y2[0]) ** 2 + (x[1] - y2[1]) ** 2 + (x[2] - y2[2]) ** 2;
7171
7128
  }
7172
- convert.rgb.keyword = function(rgb) {
7173
- var reversed = reverseKeywords[rgb];
7129
+ convert$1.rgb.keyword = function(rgb) {
7130
+ const reversed = reverseKeywords[rgb];
7174
7131
  if (reversed) {
7175
7132
  return reversed;
7176
7133
  }
7177
- var currentClosestDistance = Infinity;
7178
- var currentClosestKeyword;
7179
- for (var keyword in cssKeywords) {
7180
- if (cssKeywords.hasOwnProperty(keyword)) {
7181
- var value = cssKeywords[keyword];
7182
- var distance = comparativeDistance(rgb, value);
7183
- if (distance < currentClosestDistance) {
7184
- currentClosestDistance = distance;
7185
- currentClosestKeyword = keyword;
7186
- }
7134
+ let currentClosestDistance = Number.POSITIVE_INFINITY;
7135
+ let currentClosestKeyword;
7136
+ for (const keyword of Object.keys(cssKeywords)) {
7137
+ const value = cssKeywords[keyword];
7138
+ const distance = comparativeDistance(rgb, value);
7139
+ if (distance < currentClosestDistance) {
7140
+ currentClosestDistance = distance;
7141
+ currentClosestKeyword = keyword;
7187
7142
  }
7188
7143
  }
7189
7144
  return currentClosestKeyword;
7190
7145
  };
7191
- convert.keyword.rgb = function(keyword) {
7146
+ convert$1.keyword.rgb = function(keyword) {
7192
7147
  return cssKeywords[keyword];
7193
7148
  };
7194
- convert.rgb.xyz = function(rgb) {
7195
- var r = rgb[0] / 255;
7196
- var g = rgb[1] / 255;
7197
- var b = rgb[2] / 255;
7198
- r = r > 0.04045 ? Math.pow((r + 0.055) / 1.055, 2.4) : r / 12.92;
7199
- g = g > 0.04045 ? Math.pow((g + 0.055) / 1.055, 2.4) : g / 12.92;
7200
- b = b > 0.04045 ? Math.pow((b + 0.055) / 1.055, 2.4) : b / 12.92;
7201
- var x = r * 0.4124 + g * 0.3576 + b * 0.1805;
7202
- var y2 = r * 0.2126 + g * 0.7152 + b * 0.0722;
7203
- var z = r * 0.0193 + g * 0.1192 + b * 0.9505;
7149
+ convert$1.rgb.xyz = function(rgb) {
7150
+ const r = srgbNonlinearTransformInv(rgb[0] / 255);
7151
+ const g = srgbNonlinearTransformInv(rgb[1] / 255);
7152
+ const b = srgbNonlinearTransformInv(rgb[2] / 255);
7153
+ const x = r * 0.4124564 + g * 0.3575761 + b * 0.1804375;
7154
+ const y2 = r * 0.2126729 + g * 0.7151522 + b * 0.072175;
7155
+ const z = r * 0.0193339 + g * 0.119192 + b * 0.9503041;
7204
7156
  return [x * 100, y2 * 100, z * 100];
7205
7157
  };
7206
- convert.rgb.lab = function(rgb) {
7207
- var xyz = convert.rgb.xyz(rgb);
7208
- var x = xyz[0];
7209
- var y2 = xyz[1];
7210
- var z = xyz[2];
7211
- var l;
7212
- var a;
7213
- var b;
7158
+ convert$1.rgb.lab = function(rgb) {
7159
+ const xyz = convert$1.rgb.xyz(rgb);
7160
+ let x = xyz[0];
7161
+ let y2 = xyz[1];
7162
+ let z = xyz[2];
7214
7163
  x /= 95.047;
7215
7164
  y2 /= 100;
7216
7165
  z /= 108.883;
7217
- x = x > 8856e-6 ? Math.pow(x, 1 / 3) : 7.787 * x + 16 / 116;
7218
- y2 = y2 > 8856e-6 ? Math.pow(y2, 1 / 3) : 7.787 * y2 + 16 / 116;
7219
- z = z > 8856e-6 ? Math.pow(z, 1 / 3) : 7.787 * z + 16 / 116;
7220
- l = 116 * y2 - 16;
7221
- a = 500 * (x - y2);
7222
- b = 200 * (y2 - z);
7166
+ x = x > LAB_FT ? x ** (1 / 3) : 7.787 * x + 16 / 116;
7167
+ y2 = y2 > LAB_FT ? y2 ** (1 / 3) : 7.787 * y2 + 16 / 116;
7168
+ z = z > LAB_FT ? z ** (1 / 3) : 7.787 * z + 16 / 116;
7169
+ const l = 116 * y2 - 16;
7170
+ const a = 500 * (x - y2);
7171
+ const b = 200 * (y2 - z);
7223
7172
  return [l, a, b];
7224
7173
  };
7225
- convert.hsl.rgb = function(hsl) {
7226
- var h2 = hsl[0] / 360;
7227
- var s2 = hsl[1] / 100;
7228
- var l = hsl[2] / 100;
7229
- var t1;
7230
- var t2;
7231
- var t3;
7232
- var rgb;
7233
- var val;
7174
+ convert$1.hsl.rgb = function(hsl) {
7175
+ const h2 = hsl[0] / 360;
7176
+ const s2 = hsl[1] / 100;
7177
+ const l = hsl[2] / 100;
7178
+ let t3;
7179
+ let value;
7234
7180
  if (s2 === 0) {
7235
- val = l * 255;
7236
- return [val, val, val];
7237
- }
7238
- if (l < 0.5) {
7239
- t2 = l * (1 + s2);
7240
- } else {
7241
- t2 = l + s2 - l * s2;
7181
+ value = l * 255;
7182
+ return [value, value, value];
7242
7183
  }
7243
- t1 = 2 * l - t2;
7244
- rgb = [0, 0, 0];
7245
- for (var i = 0; i < 3; i++) {
7184
+ const t2 = l < 0.5 ? l * (1 + s2) : l + s2 - l * s2;
7185
+ const t1 = 2 * l - t2;
7186
+ const rgb = [0, 0, 0];
7187
+ for (let i = 0; i < 3; i++) {
7246
7188
  t3 = h2 + 1 / 3 * -(i - 1);
7247
7189
  if (t3 < 0) {
7248
7190
  t3++;
@@ -7251,253 +7193,285 @@ function requireConversions() {
7251
7193
  t3--;
7252
7194
  }
7253
7195
  if (6 * t3 < 1) {
7254
- val = t1 + (t2 - t1) * 6 * t3;
7196
+ value = t1 + (t2 - t1) * 6 * t3;
7255
7197
  } else if (2 * t3 < 1) {
7256
- val = t2;
7198
+ value = t2;
7257
7199
  } else if (3 * t3 < 2) {
7258
- val = t1 + (t2 - t1) * (2 / 3 - t3) * 6;
7200
+ value = t1 + (t2 - t1) * (2 / 3 - t3) * 6;
7259
7201
  } else {
7260
- val = t1;
7202
+ value = t1;
7261
7203
  }
7262
- rgb[i] = val * 255;
7204
+ rgb[i] = value * 255;
7263
7205
  }
7264
7206
  return rgb;
7265
7207
  };
7266
- convert.hsl.hsv = function(hsl) {
7267
- var h2 = hsl[0];
7268
- var s2 = hsl[1] / 100;
7269
- var l = hsl[2] / 100;
7270
- var smin = s2;
7271
- var lmin = Math.max(l, 0.01);
7272
- var sv;
7273
- var v;
7208
+ convert$1.hsl.hsv = function(hsl) {
7209
+ const h2 = hsl[0];
7210
+ let s2 = hsl[1] / 100;
7211
+ let l = hsl[2] / 100;
7212
+ let smin = s2;
7213
+ const lmin = Math.max(l, 0.01);
7274
7214
  l *= 2;
7275
7215
  s2 *= l <= 1 ? l : 2 - l;
7276
7216
  smin *= lmin <= 1 ? lmin : 2 - lmin;
7277
- v = (l + s2) / 2;
7278
- sv = l === 0 ? 2 * smin / (lmin + smin) : 2 * s2 / (l + s2);
7217
+ const v = (l + s2) / 2;
7218
+ const sv = l === 0 ? 2 * smin / (lmin + smin) : 2 * s2 / (l + s2);
7279
7219
  return [h2, sv * 100, v * 100];
7280
7220
  };
7281
- convert.hsv.rgb = function(hsv) {
7282
- var h2 = hsv[0] / 60;
7283
- var s2 = hsv[1] / 100;
7284
- var v = hsv[2] / 100;
7285
- var hi = Math.floor(h2) % 6;
7286
- var f = h2 - Math.floor(h2);
7287
- var p = 255 * v * (1 - s2);
7288
- var q = 255 * v * (1 - s2 * f);
7289
- var t = 255 * v * (1 - s2 * (1 - f));
7221
+ convert$1.hsv.rgb = function(hsv) {
7222
+ const h2 = hsv[0] / 60;
7223
+ const s2 = hsv[1] / 100;
7224
+ let v = hsv[2] / 100;
7225
+ const hi = Math.floor(h2) % 6;
7226
+ const f = h2 - Math.floor(h2);
7227
+ const p = 255 * v * (1 - s2);
7228
+ const q = 255 * v * (1 - s2 * f);
7229
+ const t = 255 * v * (1 - s2 * (1 - f));
7290
7230
  v *= 255;
7291
7231
  switch (hi) {
7292
- case 0:
7232
+ case 0: {
7293
7233
  return [v, t, p];
7294
- case 1:
7234
+ }
7235
+ case 1: {
7295
7236
  return [q, v, p];
7296
- case 2:
7237
+ }
7238
+ case 2: {
7297
7239
  return [p, v, t];
7298
- case 3:
7240
+ }
7241
+ case 3: {
7299
7242
  return [p, q, v];
7300
- case 4:
7243
+ }
7244
+ case 4: {
7301
7245
  return [t, p, v];
7302
- case 5:
7246
+ }
7247
+ case 5: {
7303
7248
  return [v, p, q];
7249
+ }
7304
7250
  }
7305
7251
  };
7306
- convert.hsv.hsl = function(hsv) {
7307
- var h2 = hsv[0];
7308
- var s2 = hsv[1] / 100;
7309
- var v = hsv[2] / 100;
7310
- var vmin = Math.max(v, 0.01);
7311
- var lmin;
7312
- var sl;
7313
- var l;
7252
+ convert$1.hsv.hsl = function(hsv) {
7253
+ const h2 = hsv[0];
7254
+ const s2 = hsv[1] / 100;
7255
+ const v = hsv[2] / 100;
7256
+ const vmin = Math.max(v, 0.01);
7257
+ let sl;
7258
+ let l;
7314
7259
  l = (2 - s2) * v;
7315
- lmin = (2 - s2) * vmin;
7260
+ const lmin = (2 - s2) * vmin;
7316
7261
  sl = s2 * vmin;
7317
7262
  sl /= lmin <= 1 ? lmin : 2 - lmin;
7318
7263
  sl = sl || 0;
7319
7264
  l /= 2;
7320
7265
  return [h2, sl * 100, l * 100];
7321
7266
  };
7322
- convert.hwb.rgb = function(hwb) {
7323
- var h2 = hwb[0] / 360;
7324
- var wh = hwb[1] / 100;
7325
- var bl = hwb[2] / 100;
7326
- var ratio = wh + bl;
7327
- var i;
7328
- var v;
7329
- var f;
7330
- var n;
7267
+ convert$1.hwb.rgb = function(hwb) {
7268
+ const h2 = hwb[0] / 360;
7269
+ let wh = hwb[1] / 100;
7270
+ let bl = hwb[2] / 100;
7271
+ const ratio = wh + bl;
7272
+ let f;
7331
7273
  if (ratio > 1) {
7332
7274
  wh /= ratio;
7333
7275
  bl /= ratio;
7334
7276
  }
7335
- i = Math.floor(6 * h2);
7336
- v = 1 - bl;
7277
+ const i = Math.floor(6 * h2);
7278
+ const v = 1 - bl;
7337
7279
  f = 6 * h2 - i;
7338
7280
  if ((i & 1) !== 0) {
7339
7281
  f = 1 - f;
7340
7282
  }
7341
- n = wh + f * (v - wh);
7342
- var r;
7343
- var g;
7344
- var b;
7283
+ const n = wh + f * (v - wh);
7284
+ let r;
7285
+ let g;
7286
+ let b;
7345
7287
  switch (i) {
7346
7288
  default:
7347
7289
  case 6:
7348
- case 0:
7290
+ case 0: {
7349
7291
  r = v;
7350
7292
  g = n;
7351
7293
  b = wh;
7352
7294
  break;
7353
- case 1:
7295
+ }
7296
+ case 1: {
7354
7297
  r = n;
7355
7298
  g = v;
7356
7299
  b = wh;
7357
7300
  break;
7358
- case 2:
7301
+ }
7302
+ case 2: {
7359
7303
  r = wh;
7360
7304
  g = v;
7361
7305
  b = n;
7362
7306
  break;
7363
- case 3:
7307
+ }
7308
+ case 3: {
7364
7309
  r = wh;
7365
7310
  g = n;
7366
7311
  b = v;
7367
7312
  break;
7368
- case 4:
7313
+ }
7314
+ case 4: {
7369
7315
  r = n;
7370
7316
  g = wh;
7371
7317
  b = v;
7372
7318
  break;
7373
- case 5:
7319
+ }
7320
+ case 5: {
7374
7321
  r = v;
7375
7322
  g = wh;
7376
7323
  b = n;
7377
7324
  break;
7325
+ }
7378
7326
  }
7379
7327
  return [r * 255, g * 255, b * 255];
7380
7328
  };
7381
- convert.cmyk.rgb = function(cmyk) {
7382
- var c = cmyk[0] / 100;
7383
- var m2 = cmyk[1] / 100;
7384
- var y2 = cmyk[2] / 100;
7385
- var k = cmyk[3] / 100;
7386
- var r;
7387
- var g;
7388
- var b;
7389
- r = 1 - Math.min(1, c * (1 - k) + k);
7390
- g = 1 - Math.min(1, m2 * (1 - k) + k);
7391
- b = 1 - Math.min(1, y2 * (1 - k) + k);
7329
+ convert$1.cmyk.rgb = function(cmyk) {
7330
+ const c = cmyk[0] / 100;
7331
+ const m2 = cmyk[1] / 100;
7332
+ const y2 = cmyk[2] / 100;
7333
+ const k = cmyk[3] / 100;
7334
+ const r = 1 - Math.min(1, c * (1 - k) + k);
7335
+ const g = 1 - Math.min(1, m2 * (1 - k) + k);
7336
+ const b = 1 - Math.min(1, y2 * (1 - k) + k);
7392
7337
  return [r * 255, g * 255, b * 255];
7393
7338
  };
7394
- convert.xyz.rgb = function(xyz) {
7395
- var x = xyz[0] / 100;
7396
- var y2 = xyz[1] / 100;
7397
- var z = xyz[2] / 100;
7398
- var r;
7399
- var g;
7400
- var b;
7401
- r = x * 3.2406 + y2 * -1.5372 + z * -0.4986;
7402
- g = x * -0.9689 + y2 * 1.8758 + z * 0.0415;
7403
- b = x * 0.0557 + y2 * -0.204 + z * 1.057;
7404
- r = r > 31308e-7 ? 1.055 * Math.pow(r, 1 / 2.4) - 0.055 : r * 12.92;
7405
- g = g > 31308e-7 ? 1.055 * Math.pow(g, 1 / 2.4) - 0.055 : g * 12.92;
7406
- b = b > 31308e-7 ? 1.055 * Math.pow(b, 1 / 2.4) - 0.055 : b * 12.92;
7407
- r = Math.min(Math.max(0, r), 1);
7408
- g = Math.min(Math.max(0, g), 1);
7409
- b = Math.min(Math.max(0, b), 1);
7339
+ convert$1.xyz.rgb = function(xyz) {
7340
+ const x = xyz[0] / 100;
7341
+ const y2 = xyz[1] / 100;
7342
+ const z = xyz[2] / 100;
7343
+ let r;
7344
+ let g;
7345
+ let b;
7346
+ r = x * 3.2404542 + y2 * -1.5371385 + z * -0.4985314;
7347
+ g = x * -0.969266 + y2 * 1.8760108 + z * 0.041556;
7348
+ b = x * 0.0556434 + y2 * -0.2040259 + z * 1.0572252;
7349
+ r = srgbNonlinearTransform(r);
7350
+ g = srgbNonlinearTransform(g);
7351
+ b = srgbNonlinearTransform(b);
7410
7352
  return [r * 255, g * 255, b * 255];
7411
7353
  };
7412
- convert.xyz.lab = function(xyz) {
7413
- var x = xyz[0];
7414
- var y2 = xyz[1];
7415
- var z = xyz[2];
7416
- var l;
7417
- var a;
7418
- var b;
7354
+ convert$1.xyz.lab = function(xyz) {
7355
+ let x = xyz[0];
7356
+ let y2 = xyz[1];
7357
+ let z = xyz[2];
7419
7358
  x /= 95.047;
7420
7359
  y2 /= 100;
7421
7360
  z /= 108.883;
7422
- x = x > 8856e-6 ? Math.pow(x, 1 / 3) : 7.787 * x + 16 / 116;
7423
- y2 = y2 > 8856e-6 ? Math.pow(y2, 1 / 3) : 7.787 * y2 + 16 / 116;
7424
- z = z > 8856e-6 ? Math.pow(z, 1 / 3) : 7.787 * z + 16 / 116;
7425
- l = 116 * y2 - 16;
7426
- a = 500 * (x - y2);
7427
- b = 200 * (y2 - z);
7361
+ x = x > LAB_FT ? x ** (1 / 3) : 7.787 * x + 16 / 116;
7362
+ y2 = y2 > LAB_FT ? y2 ** (1 / 3) : 7.787 * y2 + 16 / 116;
7363
+ z = z > LAB_FT ? z ** (1 / 3) : 7.787 * z + 16 / 116;
7364
+ const l = 116 * y2 - 16;
7365
+ const a = 500 * (x - y2);
7366
+ const b = 200 * (y2 - z);
7428
7367
  return [l, a, b];
7429
7368
  };
7430
- convert.lab.xyz = function(lab) {
7431
- var l = lab[0];
7432
- var a = lab[1];
7433
- var b = lab[2];
7434
- var x;
7435
- var y2;
7436
- var z;
7369
+ convert$1.xyz.oklab = function(xyz) {
7370
+ const x = xyz[0] / 100;
7371
+ const y2 = xyz[1] / 100;
7372
+ const z = xyz[2] / 100;
7373
+ const lp = Math.cbrt(0.8189330101 * x + 0.3618667424 * y2 - 0.1288597137 * z);
7374
+ const mp = Math.cbrt(0.0329845436 * x + 0.9293118715 * y2 + 0.0361456387 * z);
7375
+ const sp = Math.cbrt(0.0482003018 * x + 0.2643662691 * y2 + 0.633851707 * z);
7376
+ const l = 0.2104542553 * lp + 0.793617785 * mp - 0.0040720468 * sp;
7377
+ const a = 1.9779984951 * lp - 2.428592205 * mp + 0.4505937099 * sp;
7378
+ const b = 0.0259040371 * lp + 0.7827717662 * mp - 0.808675766 * sp;
7379
+ return [l * 100, a * 100, b * 100];
7380
+ };
7381
+ convert$1.oklab.oklch = function(oklab) {
7382
+ return convert$1.lab.lch(oklab);
7383
+ };
7384
+ convert$1.oklab.xyz = function(oklab) {
7385
+ const ll = oklab[0] / 100;
7386
+ const a = oklab[1] / 100;
7387
+ const b = oklab[2] / 100;
7388
+ const l = (0.999999998 * ll + 0.396337792 * a + 0.215803758 * b) ** 3;
7389
+ const m2 = (1.000000008 * ll - 0.105561342 * a - 0.063854175 * b) ** 3;
7390
+ const s2 = (1.000000055 * ll - 0.089484182 * a - 1.291485538 * b) ** 3;
7391
+ const x = 1.227013851 * l - 0.55779998 * m2 + 0.281256149 * s2;
7392
+ const y2 = -0.040580178 * l + 1.11225687 * m2 - 0.071676679 * s2;
7393
+ const z = -0.076381285 * l - 0.421481978 * m2 + 1.58616322 * s2;
7394
+ return [x * 100, y2 * 100, z * 100];
7395
+ };
7396
+ convert$1.oklab.rgb = function(oklab) {
7397
+ const ll = oklab[0] / 100;
7398
+ const aa = oklab[1] / 100;
7399
+ const bb = oklab[2] / 100;
7400
+ const l = (ll + 0.3963377774 * aa + 0.2158037573 * bb) ** 3;
7401
+ const m2 = (ll - 0.1055613458 * aa - 0.0638541728 * bb) ** 3;
7402
+ const s2 = (ll - 0.0894841775 * aa - 1.291485548 * bb) ** 3;
7403
+ const r = srgbNonlinearTransform(4.0767416621 * l - 3.3077115913 * m2 + 0.2309699292 * s2);
7404
+ const g = srgbNonlinearTransform(-1.2684380046 * l + 2.6097574011 * m2 - 0.3413193965 * s2);
7405
+ const b = srgbNonlinearTransform(-0.0041960863 * l - 0.7034186147 * m2 + 1.707614701 * s2);
7406
+ return [r * 255, g * 255, b * 255];
7407
+ };
7408
+ convert$1.oklch.oklab = function(oklch) {
7409
+ return convert$1.lch.lab(oklch);
7410
+ };
7411
+ convert$1.lab.xyz = function(lab) {
7412
+ const l = lab[0];
7413
+ const a = lab[1];
7414
+ const b = lab[2];
7415
+ let x;
7416
+ let y2;
7417
+ let z;
7437
7418
  y2 = (l + 16) / 116;
7438
7419
  x = a / 500 + y2;
7439
7420
  z = y2 - b / 200;
7440
- var y22 = Math.pow(y2, 3);
7441
- var x2 = Math.pow(x, 3);
7442
- var z2 = Math.pow(z, 3);
7443
- y2 = y22 > 8856e-6 ? y22 : (y2 - 16 / 116) / 7.787;
7444
- x = x2 > 8856e-6 ? x2 : (x - 16 / 116) / 7.787;
7445
- z = z2 > 8856e-6 ? z2 : (z - 16 / 116) / 7.787;
7421
+ const y22 = y2 ** 3;
7422
+ const x2 = x ** 3;
7423
+ const z2 = z ** 3;
7424
+ y2 = y22 > LAB_FT ? y22 : (y2 - 16 / 116) / 7.787;
7425
+ x = x2 > LAB_FT ? x2 : (x - 16 / 116) / 7.787;
7426
+ z = z2 > LAB_FT ? z2 : (z - 16 / 116) / 7.787;
7446
7427
  x *= 95.047;
7447
7428
  y2 *= 100;
7448
7429
  z *= 108.883;
7449
7430
  return [x, y2, z];
7450
7431
  };
7451
- convert.lab.lch = function(lab) {
7452
- var l = lab[0];
7453
- var a = lab[1];
7454
- var b = lab[2];
7455
- var hr;
7456
- var h2;
7457
- var c;
7458
- hr = Math.atan2(b, a);
7432
+ convert$1.lab.lch = function(lab) {
7433
+ const l = lab[0];
7434
+ const a = lab[1];
7435
+ const b = lab[2];
7436
+ let h2;
7437
+ const hr = Math.atan2(b, a);
7459
7438
  h2 = hr * 360 / 2 / Math.PI;
7460
7439
  if (h2 < 0) {
7461
7440
  h2 += 360;
7462
7441
  }
7463
- c = Math.sqrt(a * a + b * b);
7442
+ const c = Math.sqrt(a * a + b * b);
7464
7443
  return [l, c, h2];
7465
7444
  };
7466
- convert.lch.lab = function(lch) {
7467
- var l = lch[0];
7468
- var c = lch[1];
7469
- var h2 = lch[2];
7470
- var a;
7471
- var b;
7472
- var hr;
7473
- hr = h2 / 360 * 2 * Math.PI;
7474
- a = c * Math.cos(hr);
7475
- b = c * Math.sin(hr);
7445
+ convert$1.lch.lab = function(lch) {
7446
+ const l = lch[0];
7447
+ const c = lch[1];
7448
+ const h2 = lch[2];
7449
+ const hr = h2 / 360 * 2 * Math.PI;
7450
+ const a = c * Math.cos(hr);
7451
+ const b = c * Math.sin(hr);
7476
7452
  return [l, a, b];
7477
7453
  };
7478
- convert.rgb.ansi16 = function(args) {
7479
- var r = args[0];
7480
- var g = args[1];
7481
- var b = args[2];
7482
- var value = 1 in arguments ? arguments[1] : convert.rgb.hsv(args)[2];
7454
+ convert$1.rgb.ansi16 = function(args, saturation = null) {
7455
+ const [r, g, b] = args;
7456
+ let value = saturation === null ? convert$1.rgb.hsv(args)[2] : saturation;
7483
7457
  value = Math.round(value / 50);
7484
7458
  if (value === 0) {
7485
7459
  return 30;
7486
7460
  }
7487
- var ansi = 30 + (Math.round(b / 255) << 2 | Math.round(g / 255) << 1 | Math.round(r / 255));
7461
+ let ansi = 30 + (Math.round(b / 255) << 2 | Math.round(g / 255) << 1 | Math.round(r / 255));
7488
7462
  if (value === 2) {
7489
7463
  ansi += 60;
7490
7464
  }
7491
7465
  return ansi;
7492
7466
  };
7493
- convert.hsv.ansi16 = function(args) {
7494
- return convert.rgb.ansi16(convert.hsv.rgb(args), args[2]);
7467
+ convert$1.hsv.ansi16 = function(args) {
7468
+ return convert$1.rgb.ansi16(convert$1.hsv.rgb(args), args[2]);
7495
7469
  };
7496
- convert.rgb.ansi256 = function(args) {
7497
- var r = args[0];
7498
- var g = args[1];
7499
- var b = args[2];
7500
- if (r === g && g === b) {
7470
+ convert$1.rgb.ansi256 = function(args) {
7471
+ const r = args[0];
7472
+ const g = args[1];
7473
+ const b = args[2];
7474
+ if (r >> 4 === g >> 4 && g >> 4 === b >> 4) {
7501
7475
  if (r < 8) {
7502
7476
  return 16;
7503
7477
  }
@@ -7506,72 +7480,67 @@ function requireConversions() {
7506
7480
  }
7507
7481
  return Math.round((r - 8) / 247 * 24) + 232;
7508
7482
  }
7509
- var ansi = 16 + 36 * Math.round(r / 255 * 5) + 6 * Math.round(g / 255 * 5) + Math.round(b / 255 * 5);
7483
+ const ansi = 16 + 36 * Math.round(r / 255 * 5) + 6 * Math.round(g / 255 * 5) + Math.round(b / 255 * 5);
7510
7484
  return ansi;
7511
7485
  };
7512
- convert.ansi16.rgb = function(args) {
7513
- var color2 = args % 10;
7514
- if (color2 === 0 || color2 === 7) {
7486
+ convert$1.ansi16.rgb = function(args) {
7487
+ args = args[0];
7488
+ let color = args % 10;
7489
+ if (color === 0 || color === 7) {
7515
7490
  if (args > 50) {
7516
- color2 += 3.5;
7491
+ color += 3.5;
7517
7492
  }
7518
- color2 = color2 / 10.5 * 255;
7519
- return [color2, color2, color2];
7493
+ color = color / 10.5 * 255;
7494
+ return [color, color, color];
7520
7495
  }
7521
- var mult = (~~(args > 50) + 1) * 0.5;
7522
- var r = (color2 & 1) * mult * 255;
7523
- var g = (color2 >> 1 & 1) * mult * 255;
7524
- var b = (color2 >> 2 & 1) * mult * 255;
7496
+ const mult = (Math.trunc(args > 50) + 1) * 0.5;
7497
+ const r = (color & 1) * mult * 255;
7498
+ const g = (color >> 1 & 1) * mult * 255;
7499
+ const b = (color >> 2 & 1) * mult * 255;
7525
7500
  return [r, g, b];
7526
7501
  };
7527
- convert.ansi256.rgb = function(args) {
7502
+ convert$1.ansi256.rgb = function(args) {
7503
+ args = args[0];
7528
7504
  if (args >= 232) {
7529
- var c = (args - 232) * 10 + 8;
7505
+ const c = (args - 232) * 10 + 8;
7530
7506
  return [c, c, c];
7531
7507
  }
7532
7508
  args -= 16;
7533
- var rem;
7534
- var r = Math.floor(args / 36) / 5 * 255;
7535
- var g = Math.floor((rem = args % 36) / 6) / 5 * 255;
7536
- var b = rem % 6 / 5 * 255;
7509
+ let rem;
7510
+ const r = Math.floor(args / 36) / 5 * 255;
7511
+ const g = Math.floor((rem = args % 36) / 6) / 5 * 255;
7512
+ const b = rem % 6 / 5 * 255;
7537
7513
  return [r, g, b];
7538
7514
  };
7539
- convert.rgb.hex = function(args) {
7540
- var integer = ((Math.round(args[0]) & 255) << 16) + ((Math.round(args[1]) & 255) << 8) + (Math.round(args[2]) & 255);
7541
- var string = integer.toString(16).toUpperCase();
7542
- return "000000".substring(string.length) + string;
7515
+ convert$1.rgb.hex = function(args) {
7516
+ const integer = ((Math.round(args[0]) & 255) << 16) + ((Math.round(args[1]) & 255) << 8) + (Math.round(args[2]) & 255);
7517
+ const string = integer.toString(16).toUpperCase();
7518
+ return "000000".slice(string.length) + string;
7543
7519
  };
7544
- convert.hex.rgb = function(args) {
7545
- var match = args.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);
7520
+ convert$1.hex.rgb = function(args) {
7521
+ const match = args.toString(16).match(/[a-f\d]{6}|[a-f\d]{3}/i);
7546
7522
  if (!match) {
7547
7523
  return [0, 0, 0];
7548
7524
  }
7549
- var colorString2 = match[0];
7525
+ let colorString = match[0];
7550
7526
  if (match[0].length === 3) {
7551
- colorString2 = colorString2.split("").map(function(char) {
7552
- return char + char;
7553
- }).join("");
7554
- }
7555
- var integer = parseInt(colorString2, 16);
7556
- var r = integer >> 16 & 255;
7557
- var g = integer >> 8 & 255;
7558
- var b = integer & 255;
7527
+ colorString = [...colorString].map((char) => char + char).join("");
7528
+ }
7529
+ const integer = Number.parseInt(colorString, 16);
7530
+ const r = integer >> 16 & 255;
7531
+ const g = integer >> 8 & 255;
7532
+ const b = integer & 255;
7559
7533
  return [r, g, b];
7560
7534
  };
7561
- convert.rgb.hcg = function(rgb) {
7562
- var r = rgb[0] / 255;
7563
- var g = rgb[1] / 255;
7564
- var b = rgb[2] / 255;
7565
- var max2 = Math.max(Math.max(r, g), b);
7566
- var min2 = Math.min(Math.min(r, g), b);
7567
- var chroma = max2 - min2;
7568
- var grayscale;
7569
- var hue;
7570
- if (chroma < 1) {
7571
- grayscale = min2 / (1 - chroma);
7572
- } else {
7573
- grayscale = 0;
7574
- }
7535
+ convert$1.rgb.hcg = function(rgb) {
7536
+ const r = rgb[0] / 255;
7537
+ const g = rgb[1] / 255;
7538
+ const b = rgb[2] / 255;
7539
+ const max2 = Math.max(Math.max(r, g), b);
7540
+ const min2 = Math.min(Math.min(r, g), b);
7541
+ const chroma = max2 - min2;
7542
+ let hue;
7543
+ const grayscale = chroma < 1 ? min2 / (1 - chroma) : 0;
7575
7544
  if (chroma <= 0) {
7576
7545
  hue = 0;
7577
7546
  } else if (max2 === r) {
@@ -7579,79 +7548,80 @@ function requireConversions() {
7579
7548
  } else if (max2 === g) {
7580
7549
  hue = 2 + (b - r) / chroma;
7581
7550
  } else {
7582
- hue = 4 + (r - g) / chroma + 4;
7551
+ hue = 4 + (r - g) / chroma;
7583
7552
  }
7584
7553
  hue /= 6;
7585
7554
  hue %= 1;
7586
7555
  return [hue * 360, chroma * 100, grayscale * 100];
7587
7556
  };
7588
- convert.hsl.hcg = function(hsl) {
7589
- var s2 = hsl[1] / 100;
7590
- var l = hsl[2] / 100;
7591
- var c = 1;
7592
- var f = 0;
7593
- if (l < 0.5) {
7594
- c = 2 * s2 * l;
7595
- } else {
7596
- c = 2 * s2 * (1 - l);
7597
- }
7557
+ convert$1.hsl.hcg = function(hsl) {
7558
+ const s2 = hsl[1] / 100;
7559
+ const l = hsl[2] / 100;
7560
+ const c = l < 0.5 ? 2 * s2 * l : 2 * s2 * (1 - l);
7561
+ let f = 0;
7598
7562
  if (c < 1) {
7599
7563
  f = (l - 0.5 * c) / (1 - c);
7600
7564
  }
7601
7565
  return [hsl[0], c * 100, f * 100];
7602
7566
  };
7603
- convert.hsv.hcg = function(hsv) {
7604
- var s2 = hsv[1] / 100;
7605
- var v = hsv[2] / 100;
7606
- var c = s2 * v;
7607
- var f = 0;
7567
+ convert$1.hsv.hcg = function(hsv) {
7568
+ const s2 = hsv[1] / 100;
7569
+ const v = hsv[2] / 100;
7570
+ const c = s2 * v;
7571
+ let f = 0;
7608
7572
  if (c < 1) {
7609
7573
  f = (v - c) / (1 - c);
7610
7574
  }
7611
7575
  return [hsv[0], c * 100, f * 100];
7612
7576
  };
7613
- convert.hcg.rgb = function(hcg) {
7614
- var h2 = hcg[0] / 360;
7615
- var c = hcg[1] / 100;
7616
- var g = hcg[2] / 100;
7577
+ convert$1.hcg.rgb = function(hcg) {
7578
+ const h2 = hcg[0] / 360;
7579
+ const c = hcg[1] / 100;
7580
+ const g = hcg[2] / 100;
7617
7581
  if (c === 0) {
7618
7582
  return [g * 255, g * 255, g * 255];
7619
7583
  }
7620
- var pure = [0, 0, 0];
7621
- var hi = h2 % 1 * 6;
7622
- var v = hi % 1;
7623
- var w2 = 1 - v;
7624
- var mg = 0;
7584
+ const pure = [0, 0, 0];
7585
+ const hi = h2 % 1 * 6;
7586
+ const v = hi % 1;
7587
+ const w2 = 1 - v;
7588
+ let mg = 0;
7625
7589
  switch (Math.floor(hi)) {
7626
- case 0:
7590
+ case 0: {
7627
7591
  pure[0] = 1;
7628
7592
  pure[1] = v;
7629
7593
  pure[2] = 0;
7630
7594
  break;
7631
- case 1:
7595
+ }
7596
+ case 1: {
7632
7597
  pure[0] = w2;
7633
7598
  pure[1] = 1;
7634
7599
  pure[2] = 0;
7635
7600
  break;
7636
- case 2:
7601
+ }
7602
+ case 2: {
7637
7603
  pure[0] = 0;
7638
7604
  pure[1] = 1;
7639
7605
  pure[2] = v;
7640
7606
  break;
7641
- case 3:
7607
+ }
7608
+ case 3: {
7642
7609
  pure[0] = 0;
7643
7610
  pure[1] = w2;
7644
7611
  pure[2] = 1;
7645
7612
  break;
7646
- case 4:
7613
+ }
7614
+ case 4: {
7647
7615
  pure[0] = v;
7648
7616
  pure[1] = 0;
7649
7617
  pure[2] = 1;
7650
7618
  break;
7651
- default:
7619
+ }
7620
+ default: {
7652
7621
  pure[0] = 1;
7653
7622
  pure[1] = 0;
7654
7623
  pure[2] = w2;
7624
+ }
7655
7625
  }
7656
7626
  mg = (1 - c) * g;
7657
7627
  return [
@@ -7660,21 +7630,21 @@ function requireConversions() {
7660
7630
  (c * pure[2] + mg) * 255
7661
7631
  ];
7662
7632
  };
7663
- convert.hcg.hsv = function(hcg) {
7664
- var c = hcg[1] / 100;
7665
- var g = hcg[2] / 100;
7666
- var v = c + g * (1 - c);
7667
- var f = 0;
7633
+ convert$1.hcg.hsv = function(hcg) {
7634
+ const c = hcg[1] / 100;
7635
+ const g = hcg[2] / 100;
7636
+ const v = c + g * (1 - c);
7637
+ let f = 0;
7668
7638
  if (v > 0) {
7669
7639
  f = c / v;
7670
7640
  }
7671
7641
  return [hcg[0], f * 100, v * 100];
7672
7642
  };
7673
- convert.hcg.hsl = function(hcg) {
7674
- var c = hcg[1] / 100;
7675
- var g = hcg[2] / 100;
7676
- var l = g * (1 - c) + 0.5 * c;
7677
- var s2 = 0;
7643
+ convert$1.hcg.hsl = function(hcg) {
7644
+ const c = hcg[1] / 100;
7645
+ const g = hcg[2] / 100;
7646
+ const l = g * (1 - c) + 0.5 * c;
7647
+ let s2 = 0;
7678
7648
  if (l > 0 && l < 0.5) {
7679
7649
  s2 = c / (2 * l);
7680
7650
  } else if (l >= 0.5 && l < 1) {
@@ -7682,67 +7652,60 @@ function requireConversions() {
7682
7652
  }
7683
7653
  return [hcg[0], s2 * 100, l * 100];
7684
7654
  };
7685
- convert.hcg.hwb = function(hcg) {
7686
- var c = hcg[1] / 100;
7687
- var g = hcg[2] / 100;
7688
- var v = c + g * (1 - c);
7655
+ convert$1.hcg.hwb = function(hcg) {
7656
+ const c = hcg[1] / 100;
7657
+ const g = hcg[2] / 100;
7658
+ const v = c + g * (1 - c);
7689
7659
  return [hcg[0], (v - c) * 100, (1 - v) * 100];
7690
7660
  };
7691
- convert.hwb.hcg = function(hwb) {
7692
- var w2 = hwb[1] / 100;
7693
- var b = hwb[2] / 100;
7694
- var v = 1 - b;
7695
- var c = v - w2;
7696
- var g = 0;
7661
+ convert$1.hwb.hcg = function(hwb) {
7662
+ const w2 = hwb[1] / 100;
7663
+ const b = hwb[2] / 100;
7664
+ const v = 1 - b;
7665
+ const c = v - w2;
7666
+ let g = 0;
7697
7667
  if (c < 1) {
7698
7668
  g = (v - c) / (1 - c);
7699
7669
  }
7700
7670
  return [hwb[0], c * 100, g * 100];
7701
7671
  };
7702
- convert.apple.rgb = function(apple) {
7672
+ convert$1.apple.rgb = function(apple) {
7703
7673
  return [apple[0] / 65535 * 255, apple[1] / 65535 * 255, apple[2] / 65535 * 255];
7704
7674
  };
7705
- convert.rgb.apple = function(rgb) {
7675
+ convert$1.rgb.apple = function(rgb) {
7706
7676
  return [rgb[0] / 255 * 65535, rgb[1] / 255 * 65535, rgb[2] / 255 * 65535];
7707
7677
  };
7708
- convert.gray.rgb = function(args) {
7678
+ convert$1.gray.rgb = function(args) {
7709
7679
  return [args[0] / 100 * 255, args[0] / 100 * 255, args[0] / 100 * 255];
7710
7680
  };
7711
- convert.gray.hsl = convert.gray.hsv = function(args) {
7681
+ convert$1.gray.hsl = function(args) {
7712
7682
  return [0, 0, args[0]];
7713
7683
  };
7714
- convert.gray.hwb = function(gray) {
7684
+ convert$1.gray.hsv = convert$1.gray.hsl;
7685
+ convert$1.gray.hwb = function(gray) {
7715
7686
  return [0, 100, gray[0]];
7716
7687
  };
7717
- convert.gray.cmyk = function(gray) {
7688
+ convert$1.gray.cmyk = function(gray) {
7718
7689
  return [0, 0, 0, gray[0]];
7719
7690
  };
7720
- convert.gray.lab = function(gray) {
7691
+ convert$1.gray.lab = function(gray) {
7721
7692
  return [gray[0], 0, 0];
7722
7693
  };
7723
- convert.gray.hex = function(gray) {
7724
- var val = Math.round(gray[0] / 100 * 255) & 255;
7725
- var integer = (val << 16) + (val << 8) + val;
7726
- var string = integer.toString(16).toUpperCase();
7727
- return "000000".substring(string.length) + string;
7694
+ convert$1.gray.hex = function(gray) {
7695
+ const value = Math.round(gray[0] / 100 * 255) & 255;
7696
+ const integer = (value << 16) + (value << 8) + value;
7697
+ const string = integer.toString(16).toUpperCase();
7698
+ return "000000".slice(string.length) + string;
7728
7699
  };
7729
- convert.rgb.gray = function(rgb) {
7730
- var val = (rgb[0] + rgb[1] + rgb[2]) / 3;
7731
- return [val / 255 * 100];
7700
+ convert$1.rgb.gray = function(rgb) {
7701
+ const value = (rgb[0] + rgb[1] + rgb[2]) / 3;
7702
+ return [value / 255 * 100];
7732
7703
  };
7733
- return conversions$1.exports;
7734
- }
7735
- var route;
7736
- var hasRequiredRoute;
7737
- function requireRoute() {
7738
- if (hasRequiredRoute) return route;
7739
- hasRequiredRoute = 1;
7740
- var conversions2 = requireConversions();
7741
7704
  function buildGraph() {
7742
- var graph = {};
7743
- var models = Object.keys(conversions2);
7744
- for (var len = models.length, i = 0; i < len; i++) {
7745
- graph[models[i]] = {
7705
+ const graph = {};
7706
+ const models2 = Object.keys(convert$1);
7707
+ for (let { length } = models2, i = 0; i < length; i++) {
7708
+ graph[models2[i]] = {
7746
7709
  // http://jsperf.com/1-vs-infinity
7747
7710
  // micro-opt, but this is simple.
7748
7711
  distance: -1,
@@ -7752,15 +7715,15 @@ function requireRoute() {
7752
7715
  return graph;
7753
7716
  }
7754
7717
  function deriveBFS(fromModel) {
7755
- var graph = buildGraph();
7756
- var queue = [fromModel];
7718
+ const graph = buildGraph();
7719
+ const queue = [fromModel];
7757
7720
  graph[fromModel].distance = 0;
7758
- while (queue.length) {
7759
- var current = queue.pop();
7760
- var adjacents = Object.keys(conversions2[current]);
7761
- for (var len = adjacents.length, i = 0; i < len; i++) {
7762
- var adjacent = adjacents[i];
7763
- var node = graph[adjacent];
7721
+ while (queue.length > 0) {
7722
+ const current = queue.pop();
7723
+ const adjacents = Object.keys(convert$1[current]);
7724
+ for (let { length } = adjacents, i = 0; i < length; i++) {
7725
+ const adjacent = adjacents[i];
7726
+ const node = graph[adjacent];
7764
7727
  if (node.distance === -1) {
7765
7728
  node.distance = graph[current].distance + 1;
7766
7729
  node.parent = current;
@@ -7776,49 +7739,41 @@ function requireRoute() {
7776
7739
  };
7777
7740
  }
7778
7741
  function wrapConversion(toModel, graph) {
7779
- var path2 = [graph[toModel].parent, toModel];
7780
- var fn = conversions2[graph[toModel].parent][toModel];
7781
- var cur = graph[toModel].parent;
7742
+ const path2 = [graph[toModel].parent, toModel];
7743
+ let fn = convert$1[graph[toModel].parent][toModel];
7744
+ let cur = graph[toModel].parent;
7782
7745
  while (graph[cur].parent) {
7783
7746
  path2.unshift(graph[cur].parent);
7784
- fn = link(conversions2[graph[cur].parent][cur], fn);
7747
+ fn = link(convert$1[graph[cur].parent][cur], fn);
7785
7748
  cur = graph[cur].parent;
7786
7749
  }
7787
7750
  fn.conversion = path2;
7788
7751
  return fn;
7789
7752
  }
7790
- route = function(fromModel) {
7791
- var graph = deriveBFS(fromModel);
7792
- var conversion = {};
7793
- var models = Object.keys(graph);
7794
- for (var len = models.length, i = 0; i < len; i++) {
7795
- var toModel = models[i];
7796
- var node = graph[toModel];
7753
+ function route(fromModel) {
7754
+ const graph = deriveBFS(fromModel);
7755
+ const conversion = {};
7756
+ const models2 = Object.keys(graph);
7757
+ for (let { length } = models2, i = 0; i < length; i++) {
7758
+ const toModel = models2[i];
7759
+ const node = graph[toModel];
7797
7760
  if (node.parent === null) {
7798
7761
  continue;
7799
7762
  }
7800
7763
  conversion[toModel] = wrapConversion(toModel, graph);
7801
7764
  }
7802
7765
  return conversion;
7803
- };
7804
- return route;
7805
- }
7806
- var colorConvert;
7807
- var hasRequiredColorConvert;
7808
- function requireColorConvert() {
7809
- if (hasRequiredColorConvert) return colorConvert;
7810
- hasRequiredColorConvert = 1;
7811
- var conversions2 = requireConversions();
7812
- var route2 = requireRoute();
7813
- var convert = {};
7814
- var models = Object.keys(conversions2);
7766
+ }
7767
+ const convert = {};
7768
+ const models = Object.keys(convert$1);
7815
7769
  function wrapRaw(fn) {
7816
- var wrappedFn = function(args) {
7817
- if (args === void 0 || args === null) {
7818
- return args;
7770
+ const wrappedFn = function(...args) {
7771
+ const arg0 = args[0];
7772
+ if (arg0 === void 0 || arg0 === null) {
7773
+ return arg0;
7819
7774
  }
7820
- if (arguments.length > 1) {
7821
- args = Array.prototype.slice.call(arguments);
7775
+ if (arg0.length > 1) {
7776
+ args = arg0;
7822
7777
  }
7823
7778
  return fn(args);
7824
7779
  };
@@ -7828,16 +7783,17 @@ function requireColorConvert() {
7828
7783
  return wrappedFn;
7829
7784
  }
7830
7785
  function wrapRounded(fn) {
7831
- var wrappedFn = function(args) {
7832
- if (args === void 0 || args === null) {
7833
- return args;
7786
+ const wrappedFn = function(...args) {
7787
+ const arg0 = args[0];
7788
+ if (arg0 === void 0 || arg0 === null) {
7789
+ return arg0;
7834
7790
  }
7835
- if (arguments.length > 1) {
7836
- args = Array.prototype.slice.call(arguments);
7791
+ if (arg0.length > 1) {
7792
+ args = arg0;
7837
7793
  }
7838
- var result = fn(args);
7794
+ const result = fn(args);
7839
7795
  if (typeof result === "object") {
7840
- for (var len = result.length, i = 0; i < len; i++) {
7796
+ for (let { length } = result, i = 0; i < length; i++) {
7841
7797
  result[i] = Math.round(result[i]);
7842
7798
  }
7843
7799
  }
@@ -7848,46 +7804,34 @@ function requireColorConvert() {
7848
7804
  }
7849
7805
  return wrappedFn;
7850
7806
  }
7851
- models.forEach(function(fromModel) {
7807
+ for (const fromModel of models) {
7852
7808
  convert[fromModel] = {};
7853
- Object.defineProperty(convert[fromModel], "channels", { value: conversions2[fromModel].channels });
7854
- Object.defineProperty(convert[fromModel], "labels", { value: conversions2[fromModel].labels });
7855
- var routes = route2(fromModel);
7856
- var routeModels = Object.keys(routes);
7857
- routeModels.forEach(function(toModel) {
7858
- var fn = routes[toModel];
7809
+ Object.defineProperty(convert[fromModel], "channels", { value: convert$1[fromModel].channels });
7810
+ Object.defineProperty(convert[fromModel], "labels", { value: convert$1[fromModel].labels });
7811
+ const routes = route(fromModel);
7812
+ const routeModels = Object.keys(routes);
7813
+ for (const toModel of routeModels) {
7814
+ const fn = routes[toModel];
7859
7815
  convert[fromModel][toModel] = wrapRounded(fn);
7860
7816
  convert[fromModel][toModel].raw = wrapRaw(fn);
7861
- });
7862
- });
7863
- colorConvert = convert;
7864
- return colorConvert;
7865
- }
7866
- var color;
7867
- var hasRequiredColor;
7868
- function requireColor() {
7869
- if (hasRequiredColor) return color;
7870
- hasRequiredColor = 1;
7871
- "use strict";
7872
- var colorString2 = requireColorString();
7873
- var convert = requireColorConvert();
7874
- var _slice = [].slice;
7875
- var skippedModels = [
7876
- // to be honest, I don't really feel like keyword belongs in color convert, but eh.
7817
+ }
7818
+ }
7819
+ const skippedModels = [
7820
+ // To be honest, I don't really feel like keyword belongs in color convert, but eh.
7877
7821
  "keyword",
7878
- // gray conflicts with some method names, and has its own method defined.
7822
+ // Gray conflicts with some method names, and has its own method defined.
7879
7823
  "gray",
7880
- // shouldn't really be in color-convert either...
7824
+ // Shouldn't really be in color-convert either...
7881
7825
  "hex"
7882
7826
  ];
7883
- var hashedModelKeys = {};
7884
- Object.keys(convert).forEach(function(model) {
7885
- hashedModelKeys[_slice.call(convert[model].labels).sort().join("")] = model;
7886
- });
7887
- var limiters = {};
7888
- function Color(obj, model) {
7827
+ const hashedModelKeys = {};
7828
+ for (const model of Object.keys(convert)) {
7829
+ hashedModelKeys[[...convert[model].labels].sort().join("")] = model;
7830
+ }
7831
+ const limiters = {};
7832
+ function Color(object, model) {
7889
7833
  if (!(this instanceof Color)) {
7890
- return new Color(obj, model);
7834
+ return new Color(object, model);
7891
7835
  }
7892
7836
  if (model && model in skippedModels) {
7893
7837
  model = null;
@@ -7895,63 +7839,62 @@ function requireColor() {
7895
7839
  if (model && !(model in convert)) {
7896
7840
  throw new Error("Unknown model: " + model);
7897
7841
  }
7898
- var i;
7899
- var channels;
7900
- if (obj == null) {
7842
+ let i;
7843
+ let channels;
7844
+ if (object == null) {
7901
7845
  this.model = "rgb";
7902
7846
  this.color = [0, 0, 0];
7903
7847
  this.valpha = 1;
7904
- } else if (obj instanceof Color) {
7905
- this.model = obj.model;
7906
- this.color = obj.color.slice();
7907
- this.valpha = obj.valpha;
7908
- } else if (typeof obj === "string") {
7909
- var result = colorString2.get(obj);
7848
+ } else if (object instanceof Color) {
7849
+ this.model = object.model;
7850
+ this.color = [...object.color];
7851
+ this.valpha = object.valpha;
7852
+ } else if (typeof object === "string") {
7853
+ const result = cs.get(object);
7910
7854
  if (result === null) {
7911
- throw new Error("Unable to parse color from string: " + obj);
7855
+ throw new Error("Unable to parse color from string: " + object);
7912
7856
  }
7913
7857
  this.model = result.model;
7914
7858
  channels = convert[this.model].channels;
7915
7859
  this.color = result.value.slice(0, channels);
7916
7860
  this.valpha = typeof result.value[channels] === "number" ? result.value[channels] : 1;
7917
- } else if (obj.length) {
7861
+ } else if (object.length > 0) {
7918
7862
  this.model = model || "rgb";
7919
7863
  channels = convert[this.model].channels;
7920
- var newArr = _slice.call(obj, 0, channels);
7921
- this.color = zeroArray(newArr, channels);
7922
- this.valpha = typeof obj[channels] === "number" ? obj[channels] : 1;
7923
- } else if (typeof obj === "number") {
7924
- obj &= 16777215;
7864
+ const newArray = Array.prototype.slice.call(object, 0, channels);
7865
+ this.color = zeroArray(newArray, channels);
7866
+ this.valpha = typeof object[channels] === "number" ? object[channels] : 1;
7867
+ } else if (typeof object === "number") {
7925
7868
  this.model = "rgb";
7926
7869
  this.color = [
7927
- obj >> 16 & 255,
7928
- obj >> 8 & 255,
7929
- obj & 255
7870
+ object >> 16 & 255,
7871
+ object >> 8 & 255,
7872
+ object & 255
7930
7873
  ];
7931
7874
  this.valpha = 1;
7932
7875
  } else {
7933
7876
  this.valpha = 1;
7934
- var keys2 = Object.keys(obj);
7935
- if ("alpha" in obj) {
7877
+ const keys2 = Object.keys(object);
7878
+ if ("alpha" in object) {
7936
7879
  keys2.splice(keys2.indexOf("alpha"), 1);
7937
- this.valpha = typeof obj.alpha === "number" ? obj.alpha : 0;
7880
+ this.valpha = typeof object.alpha === "number" ? object.alpha : 0;
7938
7881
  }
7939
- var hashedKeys = keys2.sort().join("");
7882
+ const hashedKeys = keys2.sort().join("");
7940
7883
  if (!(hashedKeys in hashedModelKeys)) {
7941
- throw new Error("Unable to parse color from object: " + JSON.stringify(obj));
7884
+ throw new Error("Unable to parse color from object: " + JSON.stringify(object));
7942
7885
  }
7943
7886
  this.model = hashedModelKeys[hashedKeys];
7944
- var labels = convert[this.model].labels;
7945
- var color2 = [];
7887
+ const { labels } = convert[this.model];
7888
+ const color = [];
7946
7889
  for (i = 0; i < labels.length; i++) {
7947
- color2.push(obj[labels[i]]);
7890
+ color.push(object[labels[i]]);
7948
7891
  }
7949
- this.color = zeroArray(color2);
7892
+ this.color = zeroArray(color);
7950
7893
  }
7951
7894
  if (limiters[this.model]) {
7952
7895
  channels = convert[this.model].channels;
7953
7896
  for (i = 0; i < channels; i++) {
7954
- var limit = limiters[this.model][i];
7897
+ const limit = limiters[this.model][i];
7955
7898
  if (limit) {
7956
7899
  this.color[i] = limit(this.color[i]);
7957
7900
  }
@@ -7963,31 +7906,31 @@ function requireColor() {
7963
7906
  }
7964
7907
  }
7965
7908
  Color.prototype = {
7966
- toString: function() {
7909
+ toString() {
7967
7910
  return this.string();
7968
7911
  },
7969
- toJSON: function() {
7912
+ toJSON() {
7970
7913
  return this[this.model]();
7971
7914
  },
7972
- string: function(places) {
7973
- var self2 = this.model in colorString2.to ? this : this.rgb();
7915
+ string(places) {
7916
+ let self2 = this.model in cs.to ? this : this.rgb();
7974
7917
  self2 = self2.round(typeof places === "number" ? places : 1);
7975
- var args = self2.valpha === 1 ? self2.color : self2.color.concat(this.valpha);
7976
- return colorString2.to[self2.model](args);
7918
+ const arguments_ = self2.valpha === 1 ? self2.color : [...self2.color, this.valpha];
7919
+ return cs.to[self2.model](...arguments_);
7977
7920
  },
7978
- percentString: function(places) {
7979
- var self2 = this.rgb().round(typeof places === "number" ? places : 1);
7980
- var args = self2.valpha === 1 ? self2.color : self2.color.concat(this.valpha);
7981
- return colorString2.to.rgb.percent(args);
7921
+ percentString(places) {
7922
+ const self2 = this.rgb().round(typeof places === "number" ? places : 1);
7923
+ const arguments_ = self2.valpha === 1 ? self2.color : [...self2.color, this.valpha];
7924
+ return cs.to.rgb.percent(...arguments_);
7982
7925
  },
7983
- array: function() {
7984
- return this.valpha === 1 ? this.color.slice() : this.color.concat(this.valpha);
7926
+ array() {
7927
+ return this.valpha === 1 ? [...this.color] : [...this.color, this.valpha];
7985
7928
  },
7986
- object: function() {
7987
- var result = {};
7988
- var channels = convert[this.model].channels;
7989
- var labels = convert[this.model].labels;
7990
- for (var i = 0; i < channels; i++) {
7929
+ object() {
7930
+ const result = {};
7931
+ const { channels } = convert[this.model];
7932
+ const { labels } = convert[this.model];
7933
+ for (let i = 0; i < channels; i++) {
7991
7934
  result[labels[i]] = this.color[i];
7992
7935
  }
7993
7936
  if (this.valpha !== 1) {
@@ -7995,8 +7938,8 @@ function requireColor() {
7995
7938
  }
7996
7939
  return result;
7997
7940
  },
7998
- unitArray: function() {
7999
- var rgb = this.rgb().color;
7941
+ unitArray() {
7942
+ const rgb = this.rgb().color;
8000
7943
  rgb[0] /= 255;
8001
7944
  rgb[1] /= 255;
8002
7945
  rgb[2] /= 255;
@@ -8005,8 +7948,8 @@ function requireColor() {
8005
7948
  }
8006
7949
  return rgb;
8007
7950
  },
8008
- unitObject: function() {
8009
- var rgb = this.rgb().object();
7951
+ unitObject() {
7952
+ const rgb = this.rgb().object();
8010
7953
  rgb.r /= 255;
8011
7954
  rgb.g /= 255;
8012
7955
  rgb.b /= 255;
@@ -8015,24 +7958,21 @@ function requireColor() {
8015
7958
  }
8016
7959
  return rgb;
8017
7960
  },
8018
- round: function(places) {
7961
+ round(places) {
8019
7962
  places = Math.max(places || 0, 0);
8020
- return new Color(this.color.map(roundToPlace(places)).concat(this.valpha), this.model);
7963
+ return new Color([...this.color.map(roundToPlace(places)), this.valpha], this.model);
8021
7964
  },
8022
- alpha: function(val) {
8023
- if (arguments.length) {
8024
- return new Color(this.color.concat(Math.max(0, Math.min(1, val))), this.model);
7965
+ alpha(value) {
7966
+ if (value !== void 0) {
7967
+ return new Color([...this.color, Math.max(0, Math.min(1, value))], this.model);
8025
7968
  }
8026
7969
  return this.valpha;
8027
7970
  },
8028
- // rgb
7971
+ // Rgb
8029
7972
  red: getset("rgb", 0, maxfn(255)),
8030
7973
  green: getset("rgb", 1, maxfn(255)),
8031
7974
  blue: getset("rgb", 2, maxfn(255)),
8032
- hue: getset(["hsl", "hsv", "hsl", "hwb", "hcg"], 0, function(val) {
8033
- return (val % 360 + 360) % 360;
8034
- }),
8035
- // eslint-disable-line brace-style
7975
+ hue: getset(["hsl", "hsv", "hsl", "hwb", "hcg"], 0, (value) => (value % 360 + 360) % 360),
8036
7976
  saturationl: getset("hsl", 1, maxfn(100)),
8037
7977
  lightness: getset("hsl", 2, maxfn(100)),
8038
7978
  saturationv: getset("hsv", 1, maxfn(100)),
@@ -8045,127 +7985,138 @@ function requireColor() {
8045
7985
  magenta: getset("cmyk", 1, maxfn(100)),
8046
7986
  yellow: getset("cmyk", 2, maxfn(100)),
8047
7987
  black: getset("cmyk", 3, maxfn(100)),
8048
- x: getset("xyz", 0, maxfn(100)),
7988
+ x: getset("xyz", 0, maxfn(95.047)),
8049
7989
  y: getset("xyz", 1, maxfn(100)),
8050
- z: getset("xyz", 2, maxfn(100)),
7990
+ z: getset("xyz", 2, maxfn(108.833)),
8051
7991
  l: getset("lab", 0, maxfn(100)),
8052
7992
  a: getset("lab", 1),
8053
7993
  b: getset("lab", 2),
8054
- keyword: function(val) {
8055
- if (arguments.length) {
8056
- return new Color(val);
7994
+ keyword(value) {
7995
+ if (value !== void 0) {
7996
+ return new Color(value);
8057
7997
  }
8058
7998
  return convert[this.model].keyword(this.color);
8059
7999
  },
8060
- hex: function(val) {
8061
- if (arguments.length) {
8062
- return new Color(val);
8000
+ hex(value) {
8001
+ if (value !== void 0) {
8002
+ return new Color(value);
8003
+ }
8004
+ return cs.to.hex(...this.rgb().round().color);
8005
+ },
8006
+ hexa(value) {
8007
+ if (value !== void 0) {
8008
+ return new Color(value);
8009
+ }
8010
+ const rgbArray = this.rgb().round().color;
8011
+ let alphaHex = Math.round(this.valpha * 255).toString(16).toUpperCase();
8012
+ if (alphaHex.length === 1) {
8013
+ alphaHex = "0" + alphaHex;
8063
8014
  }
8064
- return colorString2.to.hex(this.rgb().round().color);
8015
+ return cs.to.hex(...rgbArray) + alphaHex;
8065
8016
  },
8066
- rgbNumber: function() {
8067
- var rgb = this.rgb().color;
8017
+ rgbNumber() {
8018
+ const rgb = this.rgb().color;
8068
8019
  return (rgb[0] & 255) << 16 | (rgb[1] & 255) << 8 | rgb[2] & 255;
8069
8020
  },
8070
- luminosity: function() {
8071
- var rgb = this.rgb().color;
8072
- var lum = [];
8073
- for (var i = 0; i < rgb.length; i++) {
8074
- var chan = rgb[i] / 255;
8075
- lum[i] = chan <= 0.03928 ? chan / 12.92 : Math.pow((chan + 0.055) / 1.055, 2.4);
8021
+ luminosity() {
8022
+ const rgb = this.rgb().color;
8023
+ const lum = [];
8024
+ for (const [i, element] of rgb.entries()) {
8025
+ const chan = element / 255;
8026
+ lum[i] = chan <= 0.04045 ? chan / 12.92 : ((chan + 0.055) / 1.055) ** 2.4;
8076
8027
  }
8077
8028
  return 0.2126 * lum[0] + 0.7152 * lum[1] + 0.0722 * lum[2];
8078
8029
  },
8079
- contrast: function(color2) {
8080
- var lum1 = this.luminosity();
8081
- var lum2 = color2.luminosity();
8030
+ contrast(color2) {
8031
+ const lum1 = this.luminosity();
8032
+ const lum2 = color2.luminosity();
8082
8033
  if (lum1 > lum2) {
8083
8034
  return (lum1 + 0.05) / (lum2 + 0.05);
8084
8035
  }
8085
8036
  return (lum2 + 0.05) / (lum1 + 0.05);
8086
8037
  },
8087
- level: function(color2) {
8088
- var contrastRatio = this.contrast(color2);
8089
- if (contrastRatio >= 7.1) {
8038
+ level(color2) {
8039
+ const contrastRatio = this.contrast(color2);
8040
+ if (contrastRatio >= 7) {
8090
8041
  return "AAA";
8091
8042
  }
8092
8043
  return contrastRatio >= 4.5 ? "AA" : "";
8093
8044
  },
8094
- isDark: function() {
8095
- var rgb = this.rgb().color;
8096
- var yiq = (rgb[0] * 299 + rgb[1] * 587 + rgb[2] * 114) / 1e3;
8045
+ isDark() {
8046
+ const rgb = this.rgb().color;
8047
+ const yiq = (rgb[0] * 2126 + rgb[1] * 7152 + rgb[2] * 722) / 1e4;
8097
8048
  return yiq < 128;
8098
8049
  },
8099
- isLight: function() {
8050
+ isLight() {
8100
8051
  return !this.isDark();
8101
8052
  },
8102
- negate: function() {
8103
- var rgb = this.rgb();
8104
- for (var i = 0; i < 3; i++) {
8053
+ negate() {
8054
+ const rgb = this.rgb();
8055
+ for (let i = 0; i < 3; i++) {
8105
8056
  rgb.color[i] = 255 - rgb.color[i];
8106
8057
  }
8107
8058
  return rgb;
8108
8059
  },
8109
- lighten: function(ratio) {
8110
- var hsl = this.hsl();
8060
+ lighten(ratio) {
8061
+ const hsl = this.hsl();
8111
8062
  hsl.color[2] += hsl.color[2] * ratio;
8112
8063
  return hsl;
8113
8064
  },
8114
- darken: function(ratio) {
8115
- var hsl = this.hsl();
8065
+ darken(ratio) {
8066
+ const hsl = this.hsl();
8116
8067
  hsl.color[2] -= hsl.color[2] * ratio;
8117
8068
  return hsl;
8118
8069
  },
8119
- saturate: function(ratio) {
8120
- var hsl = this.hsl();
8070
+ saturate(ratio) {
8071
+ const hsl = this.hsl();
8121
8072
  hsl.color[1] += hsl.color[1] * ratio;
8122
8073
  return hsl;
8123
8074
  },
8124
- desaturate: function(ratio) {
8125
- var hsl = this.hsl();
8075
+ desaturate(ratio) {
8076
+ const hsl = this.hsl();
8126
8077
  hsl.color[1] -= hsl.color[1] * ratio;
8127
8078
  return hsl;
8128
8079
  },
8129
- whiten: function(ratio) {
8130
- var hwb = this.hwb();
8080
+ whiten(ratio) {
8081
+ const hwb = this.hwb();
8131
8082
  hwb.color[1] += hwb.color[1] * ratio;
8132
8083
  return hwb;
8133
8084
  },
8134
- blacken: function(ratio) {
8135
- var hwb = this.hwb();
8085
+ blacken(ratio) {
8086
+ const hwb = this.hwb();
8136
8087
  hwb.color[2] += hwb.color[2] * ratio;
8137
8088
  return hwb;
8138
8089
  },
8139
- grayscale: function() {
8140
- var rgb = this.rgb().color;
8141
- var val = rgb[0] * 0.3 + rgb[1] * 0.59 + rgb[2] * 0.11;
8142
- return Color.rgb(val, val, val);
8090
+ grayscale() {
8091
+ const rgb = this.rgb().color;
8092
+ const value = rgb[0] * 0.3 + rgb[1] * 0.59 + rgb[2] * 0.11;
8093
+ return Color.rgb(value, value, value);
8143
8094
  },
8144
- fade: function(ratio) {
8095
+ fade(ratio) {
8145
8096
  return this.alpha(this.valpha - this.valpha * ratio);
8146
8097
  },
8147
- opaquer: function(ratio) {
8098
+ opaquer(ratio) {
8148
8099
  return this.alpha(this.valpha + this.valpha * ratio);
8149
8100
  },
8150
- rotate: function(degrees) {
8151
- var hsl = this.hsl();
8152
- var hue = hsl.color[0];
8101
+ rotate(degrees) {
8102
+ const hsl = this.hsl();
8103
+ let hue = hsl.color[0];
8153
8104
  hue = (hue + degrees) % 360;
8154
8105
  hue = hue < 0 ? 360 + hue : hue;
8155
8106
  hsl.color[0] = hue;
8156
8107
  return hsl;
8157
8108
  },
8158
- mix: function(mixinColor, weight) {
8109
+ mix(mixinColor, weight) {
8159
8110
  if (!mixinColor || !mixinColor.rgb) {
8160
8111
  throw new Error('Argument to "mix" was not a Color instance, but rather an instance of ' + typeof mixinColor);
8161
8112
  }
8162
- var color1 = mixinColor.rgb();
8163
- var color2 = this.rgb();
8164
- var p = weight === void 0 ? 0.5 : weight;
8165
- var w2 = 2 * p - 1;
8166
- var a = color1.alpha() - color2.alpha();
8167
- var w1 = ((w2 * a === -1 ? w2 : (w2 + a) / (1 + w2 * a)) + 1) / 2;
8168
- var w22 = 1 - w1;
8113
+ const color1 = mixinColor.rgb();
8114
+ const color2 = this.rgb();
8115
+ const p = weight === void 0 ? 0.5 : weight;
8116
+ const w2 = 2 * p - 1;
8117
+ const a = color1.alpha() - color2.alpha();
8118
+ const w1 = ((w2 * a === -1 ? w2 : (w2 + a) / (1 + w2 * a)) + 1) / 2;
8119
+ const w22 = 1 - w1;
8169
8120
  return Color.rgb(
8170
8121
  w1 * color1.red() + w22 * color2.red(),
8171
8122
  w1 * color1.green() + w22 * color2.green(),
@@ -8174,50 +8125,50 @@ function requireColor() {
8174
8125
  );
8175
8126
  }
8176
8127
  };
8177
- Object.keys(convert).forEach(function(model) {
8178
- if (skippedModels.indexOf(model) !== -1) {
8179
- return;
8128
+ for (const model of Object.keys(convert)) {
8129
+ if (skippedModels.includes(model)) {
8130
+ continue;
8180
8131
  }
8181
- var channels = convert[model].channels;
8182
- Color.prototype[model] = function() {
8132
+ const { channels } = convert[model];
8133
+ Color.prototype[model] = function(...arguments_) {
8183
8134
  if (this.model === model) {
8184
8135
  return new Color(this);
8185
8136
  }
8186
- if (arguments.length) {
8187
- return new Color(arguments, model);
8137
+ if (arguments_.length > 0) {
8138
+ return new Color(arguments_, model);
8188
8139
  }
8189
- var newAlpha = typeof arguments[channels] === "number" ? channels : this.valpha;
8190
- return new Color(assertArray(convert[this.model][model].raw(this.color)).concat(newAlpha), model);
8140
+ return new Color([...assertArray(convert[this.model][model].raw(this.color)), this.valpha], model);
8191
8141
  };
8192
- Color[model] = function(color2) {
8193
- if (typeof color2 === "number") {
8194
- color2 = zeroArray(_slice.call(arguments), channels);
8142
+ Color[model] = function(...arguments_) {
8143
+ let color = arguments_[0];
8144
+ if (typeof color === "number") {
8145
+ color = zeroArray(arguments_, channels);
8195
8146
  }
8196
- return new Color(color2, model);
8147
+ return new Color(color, model);
8197
8148
  };
8198
- });
8199
- function roundTo(num, places) {
8200
- return Number(num.toFixed(places));
8149
+ }
8150
+ function roundTo(number, places) {
8151
+ return Number(number.toFixed(places));
8201
8152
  }
8202
8153
  function roundToPlace(places) {
8203
- return function(num) {
8204
- return roundTo(num, places);
8154
+ return function(number) {
8155
+ return roundTo(number, places);
8205
8156
  };
8206
8157
  }
8207
8158
  function getset(model, channel, modifier) {
8208
8159
  model = Array.isArray(model) ? model : [model];
8209
- model.forEach(function(m2) {
8210
- (limiters[m2] || (limiters[m2] = []))[channel] = modifier;
8211
- });
8160
+ for (const m2 of model) {
8161
+ (limiters[m2] ||= [])[channel] = modifier;
8162
+ }
8212
8163
  model = model[0];
8213
- return function(val) {
8214
- var result;
8215
- if (arguments.length) {
8164
+ return function(value) {
8165
+ let result;
8166
+ if (value !== void 0) {
8216
8167
  if (modifier) {
8217
- val = modifier(val);
8168
+ value = modifier(value);
8218
8169
  }
8219
8170
  result = this[model]();
8220
- result.color[channel] = val;
8171
+ result.color[channel] = value;
8221
8172
  return result;
8222
8173
  }
8223
8174
  result = this[model]().color[channel];
@@ -8232,70 +8183,57 @@ function requireColor() {
8232
8183
  return Math.max(0, Math.min(max2, v));
8233
8184
  };
8234
8185
  }
8235
- function assertArray(val) {
8236
- return Array.isArray(val) ? val : [val];
8186
+ function assertArray(value) {
8187
+ return Array.isArray(value) ? value : [value];
8237
8188
  }
8238
- function zeroArray(arr, length) {
8239
- for (var i = 0; i < length; i++) {
8240
- if (typeof arr[i] !== "number") {
8241
- arr[i] = 0;
8189
+ function zeroArray(array, length) {
8190
+ for (let i = 0; i < length; i++) {
8191
+ if (typeof array[i] !== "number") {
8192
+ array[i] = 0;
8242
8193
  }
8243
8194
  }
8244
- return arr;
8195
+ return array;
8245
8196
  }
8246
- color = Color;
8247
- return color;
8248
- }
8249
- var textHex;
8250
- var hasRequiredTextHex;
8251
- function requireTextHex() {
8252
- if (hasRequiredTextHex) return textHex;
8253
- hasRequiredTextHex = 1;
8254
- "use strict";
8255
- textHex = function hex(str) {
8197
+ function getDefaultExportFromCjs2(x) {
8198
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
8199
+ }
8200
+ var textHex = function hex2(str) {
8256
8201
  for (var i = 0, hash2 = 0; i < str.length; hash2 = str.charCodeAt(i++) + ((hash2 << 5) - hash2)) ;
8257
- var color2 = Math.floor(
8202
+ var color = Math.floor(
8258
8203
  Math.abs(
8259
8204
  Math.sin(hash2) * 1e4 % 1 * 16777216
8260
8205
  )
8261
8206
  ).toString(16);
8262
- return "#" + Array(6 - color2.length + 1).join("0") + color2;
8207
+ return "#" + Array(6 - color.length + 1).join("0") + color;
8263
8208
  };
8264
- return textHex;
8265
- }
8266
- var colorspace;
8267
- var hasRequiredColorspace;
8268
- function requireColorspace() {
8269
- if (hasRequiredColorspace) return colorspace;
8270
- hasRequiredColorspace = 1;
8271
- "use strict";
8272
- var color2 = requireColor(), hex = requireTextHex();
8273
- colorspace = function colorspace2(namespace2, delimiter) {
8274
- var split = namespace2.split(delimiter || ":");
8275
- var base = hex(split[0]);
8209
+ var hex = /* @__PURE__ */ getDefaultExportFromCjs2(textHex);
8210
+ function colorspace(namespace2, delimiter) {
8211
+ const split = namespace2.split(delimiter || ":");
8212
+ let base = hex(split[0]);
8276
8213
  if (!split.length) return base;
8277
- for (var i = 0, l = split.length - 1; i < l; i++) {
8278
- base = color2(base).mix(color2(hex(split[i + 1]))).saturate(1).hex();
8214
+ for (let i = 0, l = split.length - 1; i < l; i++) {
8215
+ base = Color(base).mix(Color(hex(split[i + 1]))).saturate(1).hex();
8279
8216
  }
8280
8217
  return base;
8281
- };
8282
- return colorspace;
8218
+ }
8219
+ index_cjs = colorspace;
8220
+ return index_cjs;
8283
8221
  }
8284
8222
  var namespace;
8285
8223
  var hasRequiredNamespace;
8286
8224
  function requireNamespace() {
8287
8225
  if (hasRequiredNamespace) return namespace;
8288
8226
  hasRequiredNamespace = 1;
8289
- var colorspace2 = requireColorspace();
8227
+ var colorspace = requireIndex_cjs();
8290
8228
  namespace = function colorNamespace(args, options) {
8291
8229
  var namespace2 = options.namespace;
8292
8230
  if (options.colors === false) {
8293
8231
  args[0] = namespace2 + ": " + args[0];
8294
8232
  return args;
8295
8233
  }
8296
- var color2 = colorspace2(namespace2);
8234
+ var color = colorspace(namespace2);
8297
8235
  args[0] = "%c" + namespace2 + ":%c " + args[0];
8298
- args.splice(1, 0, "color:" + color2, "color:inherit");
8236
+ args.splice(1, 0, "color:" + color, "color:inherit");
8299
8237
  return args;
8300
8238
  };
8301
8239
  return namespace;
@@ -11145,10 +11083,30 @@ function requireLogger() {
11145
11083
  this.rejections.handle(rejectionHandlers);
11146
11084
  }
11147
11085
  }
11086
+ /* eslint-disable valid-jsdoc */
11087
+ /**
11088
+ * Helper method to get the highest logging level associated with a logger
11089
+ *
11090
+ * @returns { number | null } - The highest configured logging level, null
11091
+ * for invalid configuration
11092
+ */
11093
+ }, {
11094
+ key: "getHighestLogLevel",
11095
+ value: function getHighestLogLevel() {
11096
+ var _this3 = this;
11097
+ var configuredLevelValue = getLevelValue(this.levels, this.level);
11098
+ if (!this.transports || this.transports.length === 0) {
11099
+ return configuredLevelValue;
11100
+ }
11101
+ return this.transports.reduce(function(max2, transport) {
11102
+ var levelValue = getLevelValue(_this3.levels, transport.level);
11103
+ return levelValue !== null && levelValue > max2 ? levelValue : max2;
11104
+ }, configuredLevelValue);
11105
+ }
11148
11106
  }, {
11149
11107
  key: "isLevelEnabled",
11150
11108
  value: function isLevelEnabled(level) {
11151
- var _this3 = this;
11109
+ var _this4 = this;
11152
11110
  var givenLevelValue = getLevelValue(this.levels, level);
11153
11111
  if (givenLevelValue === null) {
11154
11112
  return false;
@@ -11161,7 +11119,7 @@ function requireLogger() {
11161
11119
  return configuredLevelValue >= givenLevelValue;
11162
11120
  }
11163
11121
  var index2 = this.transports.findIndex(function(transport) {
11164
- var transportLevelValue = getLevelValue(_this3.levels, transport.level);
11122
+ var transportLevelValue = getLevelValue(_this4.levels, transport.level);
11165
11123
  if (transportLevelValue === null) {
11166
11124
  transportLevelValue = configuredLevelValue;
11167
11125
  }
@@ -17488,6 +17446,49 @@ const logger = winston$2.createLogger({
17488
17446
  })
17489
17447
  ]
17490
17448
  });
17449
+ const createFileTransport = () => {
17450
+ return new DailyRotateFile$1({
17451
+ filename: path$1.join(logDirectory, "%DATE%.log"),
17452
+ datePattern: "YYYY-MM-DD",
17453
+ zippedArchive: true,
17454
+ maxSize: "20m",
17455
+ maxFiles: "14d",
17456
+ format: logFormat
17457
+ });
17458
+ };
17459
+ function attachRotateMitigation(transport, opts) {
17460
+ const { logLevel, nodeEnv } = opts;
17461
+ let isRefreshing = false;
17462
+ transport.on("rotate", (_old, _new) => {
17463
+ if (isRefreshing) return;
17464
+ isRefreshing = true;
17465
+ let removalTimer = null;
17466
+ const next = createFileTransport();
17467
+ next.on("new", () => {
17468
+ if (removalTimer) {
17469
+ clearTimeout(removalTimer);
17470
+ removalTimer = null;
17471
+ }
17472
+ try {
17473
+ logger.remove(transport);
17474
+ } catch {
17475
+ }
17476
+ isRefreshing = false;
17477
+ });
17478
+ attachRotateMitigation(next, opts);
17479
+ logger.add(next);
17480
+ const REMOVAL_GRACE_MS = 3e4;
17481
+ removalTimer = setTimeout(() => {
17482
+ try {
17483
+ logger.remove(transport);
17484
+ } catch {
17485
+ }
17486
+ isRefreshing = false;
17487
+ removalTimer = null;
17488
+ }, REMOVAL_GRACE_MS);
17489
+ logger.level = logLevel;
17490
+ });
17491
+ }
17491
17492
  const configureLogger = (logLevel, nodeEnv) => {
17492
17493
  try {
17493
17494
  const existingFileTransports = (logger.transports || []).filter(
@@ -17505,65 +17506,9 @@ const configureLogger = (logLevel, nodeEnv) => {
17505
17506
  } catch {
17506
17507
  }
17507
17508
  logger.clear();
17508
- const fileTransport = new DailyRotateFile$1({
17509
- filename: path$1.join(logDirectory, "%DATE%.log"),
17510
- datePattern: "YYYY-MM-DD",
17511
- zippedArchive: true,
17512
- maxSize: "20m",
17513
- maxFiles: "14d",
17514
- format: logFormat
17515
- });
17509
+ const fileTransport = createFileTransport();
17510
+ attachRotateMitigation(fileTransport, { logLevel, nodeEnv });
17516
17511
  logger.add(fileTransport);
17517
- let isRefreshing = false;
17518
- fileTransport.on("rotate", (_oldFilename, _newFilename) => {
17519
- if (isRefreshing) return;
17520
- isRefreshing = true;
17521
- logger.silent = true;
17522
- try {
17523
- const existing = (logger.transports || []).filter(
17524
- (t) => t instanceof DailyRotateFile$1
17525
- );
17526
- for (const t of existing) {
17527
- const s2 = t.logStream;
17528
- if (s2 && typeof s2.end === "function") {
17529
- try {
17530
- s2.end();
17531
- } catch {
17532
- }
17533
- }
17534
- }
17535
- logger.clear();
17536
- const refreshed = new DailyRotateFile$1({
17537
- filename: path$1.join(logDirectory, "%DATE%.log"),
17538
- datePattern: "YYYY-MM-DD",
17539
- zippedArchive: true,
17540
- maxSize: "20m",
17541
- maxFiles: "14d",
17542
- format: logFormat
17543
- });
17544
- refreshed.on("new", () => {
17545
- logger.silent = false;
17546
- isRefreshing = false;
17547
- });
17548
- logger.add(refreshed);
17549
- if (nodeEnv !== "production") {
17550
- logger.add(
17551
- new winston$2.transports.Console({
17552
- format: winston$2.format.combine(
17553
- winston$2.format.timestamp(),
17554
- winston$2.format.splat(),
17555
- baseFormat,
17556
- winston$2.format.colorize({ all: true })
17557
- )
17558
- })
17559
- );
17560
- }
17561
- logger.level = logLevel;
17562
- } catch {
17563
- logger.silent = false;
17564
- isRefreshing = false;
17565
- }
17566
- });
17567
17512
  if (nodeEnv !== "production") {
17568
17513
  logger.add(
17569
17514
  new winston$2.transports.Console({
@@ -17584,4 +17529,4 @@ export {
17584
17529
  getDefaultExportFromCjs as g,
17585
17530
  logger as l
17586
17531
  };
17587
- //# sourceMappingURL=logger-SqdNut1H.js.map
17532
+ //# sourceMappingURL=logger-CBDNtsMq.js.map