@machinemetrics/mm-erp-sdk 0.1.8-beta.1 → 0.1.8-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{config-CV-KosWV.js → config-152LkbTv.js} +2 -2
- package/dist/{config-CV-KosWV.js.map → config-152LkbTv.js.map} +1 -1
- package/dist/{connector-factory-D8v6aQIt.js → connector-factory-wivcyMhC.js} +2 -2
- package/dist/{connector-factory-D8v6aQIt.js.map → connector-factory-wivcyMhC.js.map} +1 -1
- package/dist/{hashed-cache-manager-B6hTDLxU.js → hashed-cache-manager-BnviJzB7.js} +4 -4
- package/dist/{hashed-cache-manager-B6hTDLxU.js.map → hashed-cache-manager-BnviJzB7.js.map} +1 -1
- package/dist/{index-Bg76oouR.js → index-DNqHWa8F.js} +2 -2
- package/dist/{index-Bg76oouR.js.map → index-DNqHWa8F.js.map} +1 -1
- package/dist/{logger-SqdNut1H.js → logger-HAWySEbs.js} +989 -1023
- package/dist/logger-HAWySEbs.js.map +1 -0
- package/dist/mm-erp-sdk.js +6 -6
- package/dist/services/data-sync-service/jobs/clean-up-expired-cache.js +4 -4
- package/dist/services/data-sync-service/jobs/from-erp.js +4 -4
- package/dist/services/data-sync-service/jobs/retry-failed-labor-tickets.js +3 -3
- package/dist/services/data-sync-service/jobs/run-migrations.js +1 -1
- package/dist/services/data-sync-service/jobs/to-erp.js +3 -3
- package/dist/services/reporting-service/logger.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/services/reporting-service/logger.ts +78 -70
- package/dist/logger-SqdNut1H.js.map +0 -1
|
@@ -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.
|
|
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.
|
|
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
|
|
6639
|
-
var
|
|
6640
|
-
|
|
6641
|
-
|
|
6642
|
-
|
|
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
|
-
|
|
6646
|
-
|
|
6647
|
-
|
|
6648
|
-
|
|
6649
|
-
|
|
6650
|
-
|
|
6651
|
-
|
|
6652
|
-
|
|
6653
|
-
|
|
6654
|
-
|
|
6655
|
-
|
|
6656
|
-
|
|
6657
|
-
|
|
6658
|
-
|
|
6659
|
-
|
|
6660
|
-
|
|
6661
|
-
|
|
6662
|
-
|
|
6663
|
-
|
|
6664
|
-
|
|
6665
|
-
|
|
6666
|
-
|
|
6667
|
-
|
|
6668
|
-
|
|
6669
|
-
|
|
6670
|
-
|
|
6671
|
-
|
|
6672
|
-
|
|
6673
|
-
|
|
6674
|
-
|
|
6675
|
-
|
|
6676
|
-
|
|
6677
|
-
|
|
6678
|
-
|
|
6679
|
-
|
|
6680
|
-
|
|
6681
|
-
|
|
6682
|
-
|
|
6683
|
-
|
|
6684
|
-
|
|
6685
|
-
|
|
6686
|
-
|
|
6687
|
-
|
|
6688
|
-
|
|
6689
|
-
|
|
6690
|
-
|
|
6691
|
-
|
|
6692
|
-
|
|
6693
|
-
|
|
6694
|
-
|
|
6695
|
-
|
|
6696
|
-
|
|
6697
|
-
|
|
6698
|
-
|
|
6699
|
-
|
|
6700
|
-
|
|
6701
|
-
|
|
6702
|
-
|
|
6703
|
-
|
|
6704
|
-
|
|
6705
|
-
|
|
6706
|
-
|
|
6707
|
-
|
|
6708
|
-
|
|
6709
|
-
|
|
6710
|
-
|
|
6711
|
-
|
|
6712
|
-
|
|
6713
|
-
|
|
6714
|
-
|
|
6715
|
-
|
|
6716
|
-
|
|
6717
|
-
|
|
6718
|
-
|
|
6719
|
-
|
|
6720
|
-
|
|
6721
|
-
|
|
6722
|
-
|
|
6723
|
-
|
|
6724
|
-
|
|
6725
|
-
|
|
6726
|
-
|
|
6727
|
-
|
|
6728
|
-
|
|
6729
|
-
|
|
6730
|
-
|
|
6731
|
-
|
|
6732
|
-
|
|
6733
|
-
|
|
6734
|
-
|
|
6735
|
-
|
|
6736
|
-
|
|
6737
|
-
|
|
6738
|
-
|
|
6739
|
-
|
|
6740
|
-
|
|
6741
|
-
|
|
6742
|
-
|
|
6743
|
-
|
|
6744
|
-
|
|
6745
|
-
|
|
6746
|
-
|
|
6747
|
-
|
|
6748
|
-
|
|
6749
|
-
|
|
6750
|
-
|
|
6751
|
-
|
|
6752
|
-
|
|
6753
|
-
|
|
6754
|
-
|
|
6755
|
-
|
|
6756
|
-
|
|
6757
|
-
|
|
6758
|
-
|
|
6759
|
-
|
|
6760
|
-
|
|
6761
|
-
|
|
6762
|
-
|
|
6763
|
-
|
|
6764
|
-
|
|
6765
|
-
|
|
6766
|
-
|
|
6767
|
-
|
|
6768
|
-
|
|
6769
|
-
|
|
6770
|
-
|
|
6771
|
-
|
|
6772
|
-
|
|
6773
|
-
|
|
6774
|
-
|
|
6775
|
-
|
|
6776
|
-
|
|
6777
|
-
|
|
6778
|
-
|
|
6779
|
-
|
|
6780
|
-
|
|
6781
|
-
|
|
6782
|
-
|
|
6783
|
-
|
|
6784
|
-
|
|
6785
|
-
|
|
6786
|
-
|
|
6787
|
-
|
|
6788
|
-
|
|
6789
|
-
|
|
6790
|
-
|
|
6791
|
-
|
|
6792
|
-
|
|
6793
|
-
|
|
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
|
-
|
|
6796
|
-
|
|
6797
|
-
|
|
6798
|
-
|
|
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;
|
|
6806
|
-
}
|
|
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
|
-
}
|
|
6794
|
+
const reverseNames = /* @__PURE__ */ Object.create(null);
|
|
6795
|
+
for (const name3 in cssKeywords) {
|
|
6796
|
+
if (Object.hasOwn(cssKeywords, name3)) {
|
|
6797
|
+
reverseNames[cssKeywords[name3]] = name3;
|
|
6829
6798
|
}
|
|
6830
|
-
|
|
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
|
-
|
|
6859
|
-
|
|
6860
|
-
|
|
6805
|
+
const prefix = string.slice(0, 3).toLowerCase();
|
|
6806
|
+
let value;
|
|
6807
|
+
let model;
|
|
6861
6808
|
switch (prefix) {
|
|
6862
|
-
case "hsl":
|
|
6863
|
-
|
|
6809
|
+
case "hsl": {
|
|
6810
|
+
value = cs.get.hsl(string);
|
|
6864
6811
|
model = "hsl";
|
|
6865
6812
|
break;
|
|
6866
|
-
|
|
6867
|
-
|
|
6813
|
+
}
|
|
6814
|
+
case "hwb": {
|
|
6815
|
+
value = cs.get.hwb(string);
|
|
6868
6816
|
model = "hwb";
|
|
6869
6817
|
break;
|
|
6870
|
-
|
|
6871
|
-
|
|
6818
|
+
}
|
|
6819
|
+
default: {
|
|
6820
|
+
value = cs.get.rgb(string);
|
|
6872
6821
|
model = "rgb";
|
|
6873
6822
|
break;
|
|
6823
|
+
}
|
|
6874
6824
|
}
|
|
6875
|
-
if (!
|
|
6825
|
+
if (!value) {
|
|
6876
6826
|
return null;
|
|
6877
6827
|
}
|
|
6878
|
-
return { model, value
|
|
6828
|
+
return { model, value };
|
|
6879
6829
|
};
|
|
6880
6830
|
cs.get.rgb = function(string) {
|
|
6881
6831
|
if (!string) {
|
|
6882
6832
|
return null;
|
|
6883
6833
|
}
|
|
6884
|
-
|
|
6885
|
-
|
|
6886
|
-
|
|
6887
|
-
|
|
6888
|
-
|
|
6889
|
-
|
|
6890
|
-
|
|
6891
|
-
|
|
6892
|
-
|
|
6893
|
-
if (match = string.match(
|
|
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
|
-
|
|
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],
|
|
6864
|
+
rgb[i] = Number.parseInt(match[i + 1], 10);
|
|
6915
6865
|
}
|
|
6916
6866
|
if (match[4]) {
|
|
6917
|
-
|
|
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
|
-
|
|
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 (!
|
|
6880
|
+
if (!Object.hasOwn(cssKeywords, match[1])) {
|
|
6939
6881
|
return null;
|
|
6940
6882
|
}
|
|
6941
|
-
rgb =
|
|
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
|
-
|
|
6958
|
-
|
|
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
|
-
|
|
6961
|
-
|
|
6962
|
-
|
|
6963
|
-
|
|
6964
|
-
|
|
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
|
-
|
|
6974
|
-
|
|
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
|
-
|
|
6977
|
-
|
|
6978
|
-
|
|
6979
|
-
|
|
6980
|
-
|
|
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
|
-
|
|
6995
|
-
|
|
6996
|
-
|
|
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
|
-
|
|
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(
|
|
7016
|
-
return Math.min(Math.max(min2,
|
|
6952
|
+
function clamp(number_, min2, max2) {
|
|
6953
|
+
return Math.min(Math.max(min2, number_), max2);
|
|
7017
6954
|
}
|
|
7018
|
-
function hexDouble(
|
|
7019
|
-
|
|
7020
|
-
return
|
|
6955
|
+
function hexDouble(number_) {
|
|
6956
|
+
const string_ = Math.round(number_).toString(16).toUpperCase();
|
|
6957
|
+
return string_.length < 2 ? "0" + string_ : string_;
|
|
7021
6958
|
}
|
|
7022
|
-
|
|
7023
|
-
|
|
7024
|
-
|
|
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
|
-
|
|
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
|
-
|
|
7055
|
-
|
|
7056
|
-
|
|
7057
|
-
|
|
7058
|
-
|
|
7059
|
-
|
|
7060
|
-
|
|
7061
|
-
|
|
7062
|
-
|
|
7063
|
-
|
|
7064
|
-
|
|
7065
|
-
|
|
7066
|
-
|
|
7067
|
-
|
|
7068
|
-
|
|
7069
|
-
|
|
7070
|
-
|
|
7071
|
-
}
|
|
7072
|
-
|
|
7073
|
-
|
|
7074
|
-
|
|
7075
|
-
|
|
7076
|
-
|
|
7077
|
-
|
|
7078
|
-
|
|
7079
|
-
|
|
7080
|
-
|
|
7081
|
-
|
|
7082
|
-
|
|
7083
|
-
|
|
7084
|
-
|
|
7085
|
-
|
|
7086
|
-
|
|
7087
|
-
|
|
7088
|
-
|
|
7089
|
-
|
|
7090
|
-
|
|
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
|
-
|
|
7108
|
-
|
|
7109
|
-
|
|
7110
|
-
|
|
7111
|
-
|
|
7112
|
-
|
|
7113
|
-
|
|
7114
|
-
|
|
7115
|
-
|
|
7116
|
-
|
|
7117
|
-
|
|
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 =
|
|
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
|
-
|
|
7128
|
-
|
|
7129
|
-
|
|
7130
|
-
|
|
7131
|
-
|
|
7132
|
-
|
|
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
|
-
|
|
7148
|
-
|
|
7149
|
-
|
|
7150
|
-
|
|
7151
|
-
|
|
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.
|
|
7156
|
-
|
|
7157
|
-
|
|
7158
|
-
|
|
7159
|
-
|
|
7160
|
-
|
|
7161
|
-
|
|
7162
|
-
|
|
7163
|
-
|
|
7164
|
-
|
|
7165
|
-
|
|
7166
|
-
|
|
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
|
|
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
|
-
|
|
7129
|
+
convert$1.rgb.keyword = function(rgb) {
|
|
7130
|
+
const reversed = reverseKeywords[rgb];
|
|
7174
7131
|
if (reversed) {
|
|
7175
7132
|
return reversed;
|
|
7176
7133
|
}
|
|
7177
|
-
|
|
7178
|
-
|
|
7179
|
-
for (
|
|
7180
|
-
|
|
7181
|
-
|
|
7182
|
-
|
|
7183
|
-
|
|
7184
|
-
|
|
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
|
-
|
|
7196
|
-
|
|
7197
|
-
|
|
7198
|
-
|
|
7199
|
-
|
|
7200
|
-
|
|
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
|
-
|
|
7208
|
-
|
|
7209
|
-
|
|
7210
|
-
|
|
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 >
|
|
7218
|
-
y2 = y2 >
|
|
7219
|
-
z = z >
|
|
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
|
-
|
|
7227
|
-
|
|
7228
|
-
|
|
7229
|
-
|
|
7230
|
-
|
|
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
|
-
|
|
7236
|
-
return [
|
|
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
|
-
|
|
7244
|
-
|
|
7245
|
-
|
|
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
|
-
|
|
7196
|
+
value = t1 + (t2 - t1) * 6 * t3;
|
|
7255
7197
|
} else if (2 * t3 < 1) {
|
|
7256
|
-
|
|
7198
|
+
value = t2;
|
|
7257
7199
|
} else if (3 * t3 < 2) {
|
|
7258
|
-
|
|
7200
|
+
value = t1 + (t2 - t1) * (2 / 3 - t3) * 6;
|
|
7259
7201
|
} else {
|
|
7260
|
-
|
|
7202
|
+
value = t1;
|
|
7261
7203
|
}
|
|
7262
|
-
rgb[i] =
|
|
7204
|
+
rgb[i] = value * 255;
|
|
7263
7205
|
}
|
|
7264
7206
|
return rgb;
|
|
7265
7207
|
};
|
|
7266
|
-
convert.hsl.hsv = function(hsl) {
|
|
7267
|
-
|
|
7268
|
-
|
|
7269
|
-
|
|
7270
|
-
|
|
7271
|
-
|
|
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
|
-
|
|
7283
|
-
|
|
7284
|
-
|
|
7285
|
-
|
|
7286
|
-
|
|
7287
|
-
|
|
7288
|
-
|
|
7289
|
-
|
|
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
|
-
|
|
7234
|
+
}
|
|
7235
|
+
case 1: {
|
|
7295
7236
|
return [q, v, p];
|
|
7296
|
-
|
|
7237
|
+
}
|
|
7238
|
+
case 2: {
|
|
7297
7239
|
return [p, v, t];
|
|
7298
|
-
|
|
7240
|
+
}
|
|
7241
|
+
case 3: {
|
|
7299
7242
|
return [p, q, v];
|
|
7300
|
-
|
|
7243
|
+
}
|
|
7244
|
+
case 4: {
|
|
7301
7245
|
return [t, p, v];
|
|
7302
|
-
|
|
7246
|
+
}
|
|
7247
|
+
case 5: {
|
|
7303
7248
|
return [v, p, q];
|
|
7249
|
+
}
|
|
7304
7250
|
}
|
|
7305
7251
|
};
|
|
7306
|
-
convert.hsv.hsl = function(hsv) {
|
|
7307
|
-
|
|
7308
|
-
|
|
7309
|
-
|
|
7310
|
-
|
|
7311
|
-
|
|
7312
|
-
|
|
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
|
-
|
|
7324
|
-
|
|
7325
|
-
|
|
7326
|
-
|
|
7327
|
-
|
|
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
|
-
|
|
7343
|
-
|
|
7344
|
-
|
|
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
|
-
|
|
7295
|
+
}
|
|
7296
|
+
case 1: {
|
|
7354
7297
|
r = n;
|
|
7355
7298
|
g = v;
|
|
7356
7299
|
b = wh;
|
|
7357
7300
|
break;
|
|
7358
|
-
|
|
7301
|
+
}
|
|
7302
|
+
case 2: {
|
|
7359
7303
|
r = wh;
|
|
7360
7304
|
g = v;
|
|
7361
7305
|
b = n;
|
|
7362
7306
|
break;
|
|
7363
|
-
|
|
7307
|
+
}
|
|
7308
|
+
case 3: {
|
|
7364
7309
|
r = wh;
|
|
7365
7310
|
g = n;
|
|
7366
7311
|
b = v;
|
|
7367
7312
|
break;
|
|
7368
|
-
|
|
7313
|
+
}
|
|
7314
|
+
case 4: {
|
|
7369
7315
|
r = n;
|
|
7370
7316
|
g = wh;
|
|
7371
7317
|
b = v;
|
|
7372
7318
|
break;
|
|
7373
|
-
|
|
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
|
-
|
|
7383
|
-
|
|
7384
|
-
|
|
7385
|
-
|
|
7386
|
-
|
|
7387
|
-
|
|
7388
|
-
|
|
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
|
-
|
|
7396
|
-
|
|
7397
|
-
|
|
7398
|
-
|
|
7399
|
-
|
|
7400
|
-
|
|
7401
|
-
r = x * 3.
|
|
7402
|
-
g = x * -0.
|
|
7403
|
-
b = x * 0.
|
|
7404
|
-
r =
|
|
7405
|
-
g =
|
|
7406
|
-
b =
|
|
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
|
-
|
|
7414
|
-
|
|
7415
|
-
|
|
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 >
|
|
7423
|
-
y2 = y2 >
|
|
7424
|
-
z = z >
|
|
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.
|
|
7431
|
-
|
|
7432
|
-
|
|
7433
|
-
|
|
7434
|
-
|
|
7435
|
-
|
|
7436
|
-
|
|
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
|
-
|
|
7441
|
-
|
|
7442
|
-
|
|
7443
|
-
y2 = y22 >
|
|
7444
|
-
x = x2 >
|
|
7445
|
-
z = z2 >
|
|
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
|
-
|
|
7453
|
-
|
|
7454
|
-
|
|
7455
|
-
|
|
7456
|
-
|
|
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
|
-
|
|
7468
|
-
|
|
7469
|
-
|
|
7470
|
-
|
|
7471
|
-
|
|
7472
|
-
|
|
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
|
-
|
|
7480
|
-
|
|
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
|
-
|
|
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
|
-
|
|
7498
|
-
|
|
7499
|
-
|
|
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
|
-
|
|
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
|
-
|
|
7514
|
-
|
|
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
|
-
|
|
7491
|
+
color += 3.5;
|
|
7517
7492
|
}
|
|
7518
|
-
|
|
7519
|
-
return [
|
|
7493
|
+
color = color / 10.5 * 255;
|
|
7494
|
+
return [color, color, color];
|
|
7520
7495
|
}
|
|
7521
|
-
|
|
7522
|
-
|
|
7523
|
-
|
|
7524
|
-
|
|
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
|
-
|
|
7505
|
+
const c = (args - 232) * 10 + 8;
|
|
7530
7506
|
return [c, c, c];
|
|
7531
7507
|
}
|
|
7532
7508
|
args -= 16;
|
|
7533
|
-
|
|
7534
|
-
|
|
7535
|
-
|
|
7536
|
-
|
|
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
|
-
|
|
7541
|
-
|
|
7542
|
-
return "000000".
|
|
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
|
-
|
|
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
|
-
|
|
7525
|
+
let colorString = match[0];
|
|
7550
7526
|
if (match[0].length === 3) {
|
|
7551
|
-
|
|
7552
|
-
|
|
7553
|
-
|
|
7554
|
-
|
|
7555
|
-
|
|
7556
|
-
|
|
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
|
-
|
|
7563
|
-
|
|
7564
|
-
|
|
7565
|
-
|
|
7566
|
-
|
|
7567
|
-
|
|
7568
|
-
|
|
7569
|
-
|
|
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
|
|
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
|
-
|
|
7590
|
-
|
|
7591
|
-
|
|
7592
|
-
|
|
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
|
-
|
|
7605
|
-
|
|
7606
|
-
|
|
7607
|
-
|
|
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
|
-
|
|
7615
|
-
|
|
7616
|
-
|
|
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
|
-
|
|
7621
|
-
|
|
7622
|
-
|
|
7623
|
-
|
|
7624
|
-
|
|
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
|
-
|
|
7595
|
+
}
|
|
7596
|
+
case 1: {
|
|
7632
7597
|
pure[0] = w2;
|
|
7633
7598
|
pure[1] = 1;
|
|
7634
7599
|
pure[2] = 0;
|
|
7635
7600
|
break;
|
|
7636
|
-
|
|
7601
|
+
}
|
|
7602
|
+
case 2: {
|
|
7637
7603
|
pure[0] = 0;
|
|
7638
7604
|
pure[1] = 1;
|
|
7639
7605
|
pure[2] = v;
|
|
7640
7606
|
break;
|
|
7641
|
-
|
|
7607
|
+
}
|
|
7608
|
+
case 3: {
|
|
7642
7609
|
pure[0] = 0;
|
|
7643
7610
|
pure[1] = w2;
|
|
7644
7611
|
pure[2] = 1;
|
|
7645
7612
|
break;
|
|
7646
|
-
|
|
7613
|
+
}
|
|
7614
|
+
case 4: {
|
|
7647
7615
|
pure[0] = v;
|
|
7648
7616
|
pure[1] = 0;
|
|
7649
7617
|
pure[2] = 1;
|
|
7650
7618
|
break;
|
|
7651
|
-
|
|
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
|
-
|
|
7665
|
-
|
|
7666
|
-
|
|
7667
|
-
|
|
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
|
-
|
|
7675
|
-
|
|
7676
|
-
|
|
7677
|
-
|
|
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
|
-
|
|
7687
|
-
|
|
7688
|
-
|
|
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
|
-
|
|
7693
|
-
|
|
7694
|
-
|
|
7695
|
-
|
|
7696
|
-
|
|
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 =
|
|
7681
|
+
convert$1.gray.hsl = function(args) {
|
|
7712
7682
|
return [0, 0, args[0]];
|
|
7713
7683
|
};
|
|
7714
|
-
convert.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
|
-
|
|
7725
|
-
|
|
7726
|
-
|
|
7727
|
-
return "000000".
|
|
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
|
-
|
|
7731
|
-
return [
|
|
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
|
-
|
|
7743
|
-
|
|
7744
|
-
for (
|
|
7745
|
-
graph[
|
|
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
|
-
|
|
7756
|
-
|
|
7718
|
+
const graph = buildGraph();
|
|
7719
|
+
const queue = [fromModel];
|
|
7757
7720
|
graph[fromModel].distance = 0;
|
|
7758
|
-
while (queue.length) {
|
|
7759
|
-
|
|
7760
|
-
|
|
7761
|
-
for (
|
|
7762
|
-
|
|
7763
|
-
|
|
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
|
-
|
|
7780
|
-
|
|
7781
|
-
|
|
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(
|
|
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
|
|
7791
|
-
|
|
7792
|
-
|
|
7793
|
-
|
|
7794
|
-
for (
|
|
7795
|
-
|
|
7796
|
-
|
|
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
|
-
|
|
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
|
-
|
|
7817
|
-
|
|
7818
|
-
|
|
7770
|
+
const wrappedFn = function(...args) {
|
|
7771
|
+
const arg0 = args[0];
|
|
7772
|
+
if (arg0 === void 0 || arg0 === null) {
|
|
7773
|
+
return arg0;
|
|
7819
7774
|
}
|
|
7820
|
-
if (
|
|
7821
|
-
args =
|
|
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
|
-
|
|
7832
|
-
|
|
7833
|
-
|
|
7786
|
+
const wrappedFn = function(...args) {
|
|
7787
|
+
const arg0 = args[0];
|
|
7788
|
+
if (arg0 === void 0 || arg0 === null) {
|
|
7789
|
+
return arg0;
|
|
7834
7790
|
}
|
|
7835
|
-
if (
|
|
7836
|
-
args =
|
|
7791
|
+
if (arg0.length > 1) {
|
|
7792
|
+
args = arg0;
|
|
7837
7793
|
}
|
|
7838
|
-
|
|
7794
|
+
const result = fn(args);
|
|
7839
7795
|
if (typeof result === "object") {
|
|
7840
|
-
for (
|
|
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
|
-
|
|
7807
|
+
for (const fromModel of models) {
|
|
7852
7808
|
convert[fromModel] = {};
|
|
7853
|
-
Object.defineProperty(convert[fromModel], "channels", { value:
|
|
7854
|
-
Object.defineProperty(convert[fromModel], "labels", { value:
|
|
7855
|
-
|
|
7856
|
-
|
|
7857
|
-
|
|
7858
|
-
|
|
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
|
-
|
|
7864
|
-
|
|
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
|
-
//
|
|
7822
|
+
// Gray conflicts with some method names, and has its own method defined.
|
|
7879
7823
|
"gray",
|
|
7880
|
-
//
|
|
7824
|
+
// Shouldn't really be in color-convert either...
|
|
7881
7825
|
"hex"
|
|
7882
7826
|
];
|
|
7883
|
-
|
|
7884
|
-
Object.keys(convert)
|
|
7885
|
-
hashedModelKeys[
|
|
7886
|
-
}
|
|
7887
|
-
|
|
7888
|
-
function Color(
|
|
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(
|
|
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
|
-
|
|
7899
|
-
|
|
7900
|
-
if (
|
|
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 (
|
|
7905
|
-
this.model =
|
|
7906
|
-
this.color =
|
|
7907
|
-
this.valpha =
|
|
7908
|
-
} else if (typeof
|
|
7909
|
-
|
|
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: " +
|
|
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 (
|
|
7861
|
+
} else if (object.length > 0) {
|
|
7918
7862
|
this.model = model || "rgb";
|
|
7919
7863
|
channels = convert[this.model].channels;
|
|
7920
|
-
|
|
7921
|
-
this.color = zeroArray(
|
|
7922
|
-
this.valpha = typeof
|
|
7923
|
-
} else if (typeof
|
|
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
|
-
|
|
7928
|
-
|
|
7929
|
-
|
|
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
|
-
|
|
7935
|
-
if ("alpha" in
|
|
7877
|
+
const keys2 = Object.keys(object);
|
|
7878
|
+
if ("alpha" in object) {
|
|
7936
7879
|
keys2.splice(keys2.indexOf("alpha"), 1);
|
|
7937
|
-
this.valpha = typeof
|
|
7880
|
+
this.valpha = typeof object.alpha === "number" ? object.alpha : 0;
|
|
7938
7881
|
}
|
|
7939
|
-
|
|
7882
|
+
const hashedKeys = keys2.sort().join("");
|
|
7940
7883
|
if (!(hashedKeys in hashedModelKeys)) {
|
|
7941
|
-
throw new Error("Unable to parse color from object: " + JSON.stringify(
|
|
7884
|
+
throw new Error("Unable to parse color from object: " + JSON.stringify(object));
|
|
7942
7885
|
}
|
|
7943
7886
|
this.model = hashedModelKeys[hashedKeys];
|
|
7944
|
-
|
|
7945
|
-
|
|
7887
|
+
const { labels } = convert[this.model];
|
|
7888
|
+
const color = [];
|
|
7946
7889
|
for (i = 0; i < labels.length; i++) {
|
|
7947
|
-
|
|
7890
|
+
color.push(object[labels[i]]);
|
|
7948
7891
|
}
|
|
7949
|
-
this.color = zeroArray(
|
|
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
|
-
|
|
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
|
|
7909
|
+
toString() {
|
|
7967
7910
|
return this.string();
|
|
7968
7911
|
},
|
|
7969
|
-
toJSON
|
|
7912
|
+
toJSON() {
|
|
7970
7913
|
return this[this.model]();
|
|
7971
7914
|
},
|
|
7972
|
-
string
|
|
7973
|
-
|
|
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
|
-
|
|
7976
|
-
return
|
|
7918
|
+
const arguments_ = self2.valpha === 1 ? self2.color : [...self2.color, this.valpha];
|
|
7919
|
+
return cs.to[self2.model](...arguments_);
|
|
7977
7920
|
},
|
|
7978
|
-
percentString
|
|
7979
|
-
|
|
7980
|
-
|
|
7981
|
-
return
|
|
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
|
|
7984
|
-
return this.valpha === 1 ? this.color
|
|
7926
|
+
array() {
|
|
7927
|
+
return this.valpha === 1 ? [...this.color] : [...this.color, this.valpha];
|
|
7985
7928
|
},
|
|
7986
|
-
object
|
|
7987
|
-
|
|
7988
|
-
|
|
7989
|
-
|
|
7990
|
-
for (
|
|
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
|
|
7999
|
-
|
|
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
|
|
8009
|
-
|
|
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
|
|
7961
|
+
round(places) {
|
|
8019
7962
|
places = Math.max(places || 0, 0);
|
|
8020
|
-
return new Color(this.color.map(roundToPlace(places))
|
|
7963
|
+
return new Color([...this.color.map(roundToPlace(places)), this.valpha], this.model);
|
|
8021
7964
|
},
|
|
8022
|
-
alpha
|
|
8023
|
-
if (
|
|
8024
|
-
return new Color(this.color
|
|
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
|
-
//
|
|
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,
|
|
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(
|
|
7988
|
+
x: getset("xyz", 0, maxfn(95.047)),
|
|
8049
7989
|
y: getset("xyz", 1, maxfn(100)),
|
|
8050
|
-
z: getset("xyz", 2, maxfn(
|
|
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
|
|
8055
|
-
if (
|
|
8056
|
-
return new Color(
|
|
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
|
|
8061
|
-
if (
|
|
8062
|
-
return new Color(
|
|
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);
|
|
8063
8009
|
}
|
|
8064
|
-
|
|
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;
|
|
8014
|
+
}
|
|
8015
|
+
return cs.to.hex(...rgbArray) + alphaHex;
|
|
8065
8016
|
},
|
|
8066
|
-
rgbNumber
|
|
8067
|
-
|
|
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
|
|
8071
|
-
|
|
8072
|
-
|
|
8073
|
-
for (
|
|
8074
|
-
|
|
8075
|
-
lum[i] = chan <= 0.
|
|
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
|
|
8080
|
-
|
|
8081
|
-
|
|
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
|
|
8088
|
-
|
|
8089
|
-
if (contrastRatio >= 7
|
|
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
|
|
8095
|
-
|
|
8096
|
-
|
|
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
|
|
8050
|
+
isLight() {
|
|
8100
8051
|
return !this.isDark();
|
|
8101
8052
|
},
|
|
8102
|
-
negate
|
|
8103
|
-
|
|
8104
|
-
for (
|
|
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
|
|
8110
|
-
|
|
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
|
|
8115
|
-
|
|
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
|
|
8120
|
-
|
|
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
|
|
8125
|
-
|
|
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
|
|
8130
|
-
|
|
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
|
|
8135
|
-
|
|
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
|
|
8140
|
-
|
|
8141
|
-
|
|
8142
|
-
return Color.rgb(
|
|
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
|
|
8095
|
+
fade(ratio) {
|
|
8145
8096
|
return this.alpha(this.valpha - this.valpha * ratio);
|
|
8146
8097
|
},
|
|
8147
|
-
opaquer
|
|
8098
|
+
opaquer(ratio) {
|
|
8148
8099
|
return this.alpha(this.valpha + this.valpha * ratio);
|
|
8149
8100
|
},
|
|
8150
|
-
rotate
|
|
8151
|
-
|
|
8152
|
-
|
|
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
|
|
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
|
-
|
|
8163
|
-
|
|
8164
|
-
|
|
8165
|
-
|
|
8166
|
-
|
|
8167
|
-
|
|
8168
|
-
|
|
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)
|
|
8178
|
-
if (skippedModels.
|
|
8179
|
-
|
|
8128
|
+
for (const model of Object.keys(convert)) {
|
|
8129
|
+
if (skippedModels.includes(model)) {
|
|
8130
|
+
continue;
|
|
8180
8131
|
}
|
|
8181
|
-
|
|
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 (
|
|
8187
|
-
return new Color(
|
|
8137
|
+
if (arguments_.length > 0) {
|
|
8138
|
+
return new Color(arguments_, model);
|
|
8188
8139
|
}
|
|
8189
|
-
|
|
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(
|
|
8193
|
-
|
|
8194
|
-
|
|
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(
|
|
8147
|
+
return new Color(color, model);
|
|
8197
8148
|
};
|
|
8198
|
-
}
|
|
8199
|
-
function roundTo(
|
|
8200
|
-
return Number(
|
|
8149
|
+
}
|
|
8150
|
+
function roundTo(number, places) {
|
|
8151
|
+
return Number(number.toFixed(places));
|
|
8201
8152
|
}
|
|
8202
8153
|
function roundToPlace(places) {
|
|
8203
|
-
return function(
|
|
8204
|
-
return roundTo(
|
|
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
|
-
|
|
8210
|
-
(limiters[m2]
|
|
8211
|
-
}
|
|
8160
|
+
for (const m2 of model) {
|
|
8161
|
+
(limiters[m2] ||= [])[channel] = modifier;
|
|
8162
|
+
}
|
|
8212
8163
|
model = model[0];
|
|
8213
|
-
return function(
|
|
8214
|
-
|
|
8215
|
-
if (
|
|
8164
|
+
return function(value) {
|
|
8165
|
+
let result;
|
|
8166
|
+
if (value !== void 0) {
|
|
8216
8167
|
if (modifier) {
|
|
8217
|
-
|
|
8168
|
+
value = modifier(value);
|
|
8218
8169
|
}
|
|
8219
8170
|
result = this[model]();
|
|
8220
|
-
result.color[channel] =
|
|
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(
|
|
8236
|
-
return Array.isArray(
|
|
8186
|
+
function assertArray(value) {
|
|
8187
|
+
return Array.isArray(value) ? value : [value];
|
|
8237
8188
|
}
|
|
8238
|
-
function zeroArray(
|
|
8239
|
-
for (
|
|
8240
|
-
if (typeof
|
|
8241
|
-
|
|
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
|
|
8195
|
+
return array;
|
|
8245
8196
|
}
|
|
8246
|
-
|
|
8247
|
-
|
|
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
|
|
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 -
|
|
8207
|
+
return "#" + Array(6 - color.length + 1).join("0") + color;
|
|
8263
8208
|
};
|
|
8264
|
-
|
|
8265
|
-
|
|
8266
|
-
|
|
8267
|
-
|
|
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 (
|
|
8278
|
-
base =
|
|
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
|
-
|
|
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
|
|
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
|
|
8234
|
+
var color = colorspace(namespace2);
|
|
8297
8235
|
args[0] = "%c" + namespace2 + ":%c " + args[0];
|
|
8298
|
-
args.splice(1, 0, "color:" +
|
|
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
|
|
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(
|
|
11122
|
+
var transportLevelValue = getLevelValue(_this4.levels, transport.level);
|
|
11165
11123
|
if (transportLevelValue === null) {
|
|
11166
11124
|
transportLevelValue = configuredLevelValue;
|
|
11167
11125
|
}
|
|
@@ -17488,24 +17446,8 @@ const logger = winston$2.createLogger({
|
|
|
17488
17446
|
})
|
|
17489
17447
|
]
|
|
17490
17448
|
});
|
|
17491
|
-
const
|
|
17492
|
-
|
|
17493
|
-
const existingFileTransports = (logger.transports || []).filter(
|
|
17494
|
-
(t) => t instanceof DailyRotateFile$1
|
|
17495
|
-
);
|
|
17496
|
-
for (const t of existingFileTransports) {
|
|
17497
|
-
const s2 = t.logStream;
|
|
17498
|
-
if (s2 && typeof s2.end === "function") {
|
|
17499
|
-
try {
|
|
17500
|
-
s2.end();
|
|
17501
|
-
} catch {
|
|
17502
|
-
}
|
|
17503
|
-
}
|
|
17504
|
-
}
|
|
17505
|
-
} catch {
|
|
17506
|
-
}
|
|
17507
|
-
logger.clear();
|
|
17508
|
-
const fileTransport = new DailyRotateFile$1({
|
|
17449
|
+
const createFileTransport = () => {
|
|
17450
|
+
return new DailyRotateFile$1({
|
|
17509
17451
|
filename: path$1.join(logDirectory, "%DATE%.log"),
|
|
17510
17452
|
datePattern: "YYYY-MM-DD",
|
|
17511
17453
|
zippedArchive: true,
|
|
@@ -17513,57 +17455,81 @@ const configureLogger = (logLevel, nodeEnv) => {
|
|
|
17513
17455
|
maxFiles: "14d",
|
|
17514
17456
|
format: logFormat
|
|
17515
17457
|
});
|
|
17516
|
-
|
|
17458
|
+
};
|
|
17459
|
+
function attachRotateMitigation(transport, opts) {
|
|
17460
|
+
const { logLevel, nodeEnv } = opts;
|
|
17517
17461
|
let isRefreshing = false;
|
|
17518
|
-
|
|
17462
|
+
transport.on("rotate", (_old, _new) => {
|
|
17519
17463
|
if (isRefreshing) return;
|
|
17520
17464
|
isRefreshing = true;
|
|
17521
17465
|
logger.silent = true;
|
|
17522
|
-
|
|
17523
|
-
|
|
17524
|
-
|
|
17466
|
+
const REFRESH_TIMEOUT_MS = 1e4;
|
|
17467
|
+
let timeout = setTimeout(() => {
|
|
17468
|
+
logger.silent = false;
|
|
17469
|
+
isRefreshing = false;
|
|
17470
|
+
console.warn(
|
|
17471
|
+
'[logger] Refresh timeout: resuming logging after 10s without "new" event.'
|
|
17525
17472
|
);
|
|
17526
|
-
|
|
17527
|
-
|
|
17528
|
-
|
|
17529
|
-
|
|
17530
|
-
|
|
17531
|
-
|
|
17532
|
-
|
|
17473
|
+
}, REFRESH_TIMEOUT_MS);
|
|
17474
|
+
const existing = (logger.transports || []).filter(
|
|
17475
|
+
(t) => t instanceof DailyRotateFile$1
|
|
17476
|
+
);
|
|
17477
|
+
for (const t of existing) {
|
|
17478
|
+
const s2 = t.logStream;
|
|
17479
|
+
if (s2 && typeof s2.end === "function") {
|
|
17480
|
+
try {
|
|
17481
|
+
s2.end();
|
|
17482
|
+
} catch {
|
|
17533
17483
|
}
|
|
17534
17484
|
}
|
|
17535
|
-
|
|
17536
|
-
|
|
17537
|
-
|
|
17538
|
-
|
|
17539
|
-
|
|
17540
|
-
|
|
17541
|
-
|
|
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
|
-
);
|
|
17485
|
+
}
|
|
17486
|
+
logger.clear();
|
|
17487
|
+
const next = createFileTransport();
|
|
17488
|
+
next.on("new", () => {
|
|
17489
|
+
if (timeout) {
|
|
17490
|
+
clearTimeout(timeout);
|
|
17491
|
+
timeout = null;
|
|
17560
17492
|
}
|
|
17561
|
-
logger.level = logLevel;
|
|
17562
|
-
} catch {
|
|
17563
17493
|
logger.silent = false;
|
|
17564
17494
|
isRefreshing = false;
|
|
17495
|
+
});
|
|
17496
|
+
attachRotateMitigation(next, opts);
|
|
17497
|
+
logger.add(next);
|
|
17498
|
+
if (nodeEnv !== "production") {
|
|
17499
|
+
logger.add(
|
|
17500
|
+
new winston$2.transports.Console({
|
|
17501
|
+
format: winston$2.format.combine(
|
|
17502
|
+
winston$2.format.timestamp(),
|
|
17503
|
+
winston$2.format.splat(),
|
|
17504
|
+
baseFormat,
|
|
17505
|
+
winston$2.format.colorize({ all: true })
|
|
17506
|
+
)
|
|
17507
|
+
})
|
|
17508
|
+
);
|
|
17565
17509
|
}
|
|
17510
|
+
logger.level = logLevel;
|
|
17566
17511
|
});
|
|
17512
|
+
}
|
|
17513
|
+
const configureLogger = (logLevel, nodeEnv) => {
|
|
17514
|
+
try {
|
|
17515
|
+
const existingFileTransports = (logger.transports || []).filter(
|
|
17516
|
+
(t) => t instanceof DailyRotateFile$1
|
|
17517
|
+
);
|
|
17518
|
+
for (const t of existingFileTransports) {
|
|
17519
|
+
const s2 = t.logStream;
|
|
17520
|
+
if (s2 && typeof s2.end === "function") {
|
|
17521
|
+
try {
|
|
17522
|
+
s2.end();
|
|
17523
|
+
} catch {
|
|
17524
|
+
}
|
|
17525
|
+
}
|
|
17526
|
+
}
|
|
17527
|
+
} catch {
|
|
17528
|
+
}
|
|
17529
|
+
logger.clear();
|
|
17530
|
+
const fileTransport = createFileTransport();
|
|
17531
|
+
attachRotateMitigation(fileTransport, { logLevel, nodeEnv });
|
|
17532
|
+
logger.add(fileTransport);
|
|
17567
17533
|
if (nodeEnv !== "production") {
|
|
17568
17534
|
logger.add(
|
|
17569
17535
|
new winston$2.transports.Console({
|
|
@@ -17584,4 +17550,4 @@ export {
|
|
|
17584
17550
|
getDefaultExportFromCjs as g,
|
|
17585
17551
|
logger as l
|
|
17586
17552
|
};
|
|
17587
|
-
//# sourceMappingURL=logger-
|
|
17553
|
+
//# sourceMappingURL=logger-HAWySEbs.js.map
|