@salty-css/core 0.0.1-alpha.300 → 0.0.1-alpha.301
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/.saltyrc.schema.json +1 -1
- package/bin/index.cjs +3 -1
- package/bin/index.js +2 -2
- package/bin/main.cjs +445 -11
- package/bin/main.js +405 -224
- package/cache/resolve-dynamic-config-cache.cjs +13 -1
- package/cache/resolve-dynamic-config-cache.js +10 -8
- package/compiler/index.cjs +774 -1
- package/compiler/index.d.ts +3 -0
- package/compiler/index.js +754 -20
- package/config/index.cjs +16 -1
- package/config/index.js +14 -12
- package/css/index.cjs +12 -1
- package/css/index.js +10 -10
- package/css/keyframes.cjs +49 -1
- package/css/keyframes.js +44 -34
- package/css/media.cjs +93 -1
- package/css/media.js +54 -49
- package/css/merge.cjs +15 -1
- package/css/merge.js +13 -3
- package/css/token.cjs +4 -1
- package/css/token.js +2 -2
- package/dash-case-Cz8wwE9a.cjs +32 -0
- package/dash-case-NMk0mXyT.js +33 -0
- package/define-templates-CVhhgPnd.js +60 -0
- package/define-templates-Deq1aCbN.cjs +59 -0
- package/factories/index.cjs +37 -1
- package/factories/index.js +27 -20
- package/generators/index.cjs +121 -1
- package/generators/index.js +82 -49
- package/helpers/index.cjs +53 -1
- package/helpers/index.js +40 -1170
- package/helpers-DM2fbDDz.js +18 -0
- package/helpers-wv74jTRI.cjs +18 -0
- package/index-ByR0nfaf.cjs +4 -0
- package/index-DKz1QXqs.js +4 -0
- package/package.json +1 -1
- package/parse-styles-CqBQc3eQ.js +232 -0
- package/parse-styles-D-p_guRO.cjs +231 -0
- package/parsers/index.cjs +57 -2
- package/parsers/index.js +55 -30
- package/pascal-case-By_l58S-.cjs +7 -0
- package/pascal-case-F3Usi5Wf.js +8 -0
- package/{react-styled-file-CGVf5n1B.js → react-styled-file-B99mwk0w.js} +2 -2
- package/react-styled-file-U02jek-B.cjs +11 -0
- package/react-vanilla-file-Bj6XC8GS.cjs +18 -0
- package/{react-vanilla-file-CCXbsjIb.js → react-vanilla-file-D9px70iK.js} +2 -2
- package/salty.config-DjosWdPw.js +4 -0
- package/salty.config-cqavVm2t.cjs +4 -0
- package/server/index.cjs +4 -1
- package/server/index.js +2 -2
- package/should-restart-5jI-bzz0.js +18 -0
- package/should-restart-DoaGoD5T.cjs +17 -0
- package/util/index.cjs +13 -1
- package/util/index.js +10 -8
- package/viewport-clamp-CEmzmcSj.cjs +10 -0
- package/viewport-clamp-K553uXu3.js +11 -0
- package/dash-case-BJEkFEGQ.cjs +0 -1
- package/dash-case-DBThphLm.js +0 -19
- package/define-templates-4A2yHcMF.js +0 -52
- package/define-templates-Cunsb_Tr.cjs +0 -1
- package/helpers-CC5pFyba.cjs +0 -1
- package/helpers-nHqH4L9L.js +0 -11
- package/index-84Wroia-.cjs +0 -1
- package/index-CituHO0U.js +0 -524
- package/index-D_732b92.js +0 -4
- package/index-ol1Q_xul.cjs +0 -41
- package/parse-styles-B1E0JeC7.cjs +0 -5
- package/parse-styles-y_-drahL.js +0 -161
- package/pascal-case-BQpR5PdN.js +0 -6
- package/pascal-case-iWoaJWwT.cjs +0 -1
- package/react-styled-file-Dkubsz-U.cjs +0 -8
- package/react-vanilla-file-CG_WJLam.cjs +0 -15
- package/salty.config-BhBY_oOk.js +0 -10
- package/salty.config-Dk6ZcCxI.cjs +0 -7
- package/should-restart-C6VJ-qaY.js +0 -12
- package/should-restart-DAhvRrtu.cjs +0 -1
- package/viewport-clamp-CaYwREKc.js +0 -7
- package/viewport-clamp-mq_DFtRR.cjs +0 -1
package/helpers/index.js
CHANGED
@@ -1,1183 +1,53 @@
|
|
1
|
-
var
|
2
|
-
var
|
3
|
-
var
|
4
|
-
import
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
blanchedalmond: [255, 235, 205],
|
15
|
-
blue: [0, 0, 255],
|
16
|
-
blueviolet: [138, 43, 226],
|
17
|
-
brown: [165, 42, 42],
|
18
|
-
burlywood: [222, 184, 135],
|
19
|
-
cadetblue: [95, 158, 160],
|
20
|
-
chartreuse: [127, 255, 0],
|
21
|
-
chocolate: [210, 105, 30],
|
22
|
-
coral: [255, 127, 80],
|
23
|
-
cornflowerblue: [100, 149, 237],
|
24
|
-
cornsilk: [255, 248, 220],
|
25
|
-
crimson: [220, 20, 60],
|
26
|
-
cyan: [0, 255, 255],
|
27
|
-
darkblue: [0, 0, 139],
|
28
|
-
darkcyan: [0, 139, 139],
|
29
|
-
darkgoldenrod: [184, 134, 11],
|
30
|
-
darkgray: [169, 169, 169],
|
31
|
-
darkgreen: [0, 100, 0],
|
32
|
-
darkgrey: [169, 169, 169],
|
33
|
-
darkkhaki: [189, 183, 107],
|
34
|
-
darkmagenta: [139, 0, 139],
|
35
|
-
darkolivegreen: [85, 107, 47],
|
36
|
-
darkorange: [255, 140, 0],
|
37
|
-
darkorchid: [153, 50, 204],
|
38
|
-
darkred: [139, 0, 0],
|
39
|
-
darksalmon: [233, 150, 122],
|
40
|
-
darkseagreen: [143, 188, 143],
|
41
|
-
darkslateblue: [72, 61, 139],
|
42
|
-
darkslategray: [47, 79, 79],
|
43
|
-
darkslategrey: [47, 79, 79],
|
44
|
-
darkturquoise: [0, 206, 209],
|
45
|
-
darkviolet: [148, 0, 211],
|
46
|
-
deeppink: [255, 20, 147],
|
47
|
-
deepskyblue: [0, 191, 255],
|
48
|
-
dimgray: [105, 105, 105],
|
49
|
-
dimgrey: [105, 105, 105],
|
50
|
-
dodgerblue: [30, 144, 255],
|
51
|
-
firebrick: [178, 34, 34],
|
52
|
-
floralwhite: [255, 250, 240],
|
53
|
-
forestgreen: [34, 139, 34],
|
54
|
-
fuchsia: [255, 0, 255],
|
55
|
-
gainsboro: [220, 220, 220],
|
56
|
-
ghostwhite: [248, 248, 255],
|
57
|
-
gold: [255, 215, 0],
|
58
|
-
goldenrod: [218, 165, 32],
|
59
|
-
gray: [128, 128, 128],
|
60
|
-
green: [0, 128, 0],
|
61
|
-
greenyellow: [173, 255, 47],
|
62
|
-
grey: [128, 128, 128],
|
63
|
-
honeydew: [240, 255, 240],
|
64
|
-
hotpink: [255, 105, 180],
|
65
|
-
indianred: [205, 92, 92],
|
66
|
-
indigo: [75, 0, 130],
|
67
|
-
ivory: [255, 255, 240],
|
68
|
-
khaki: [240, 230, 140],
|
69
|
-
lavender: [230, 230, 250],
|
70
|
-
lavenderblush: [255, 240, 245],
|
71
|
-
lawngreen: [124, 252, 0],
|
72
|
-
lemonchiffon: [255, 250, 205],
|
73
|
-
lightblue: [173, 216, 230],
|
74
|
-
lightcoral: [240, 128, 128],
|
75
|
-
lightcyan: [224, 255, 255],
|
76
|
-
lightgoldenrodyellow: [250, 250, 210],
|
77
|
-
lightgray: [211, 211, 211],
|
78
|
-
lightgreen: [144, 238, 144],
|
79
|
-
lightgrey: [211, 211, 211],
|
80
|
-
lightpink: [255, 182, 193],
|
81
|
-
lightsalmon: [255, 160, 122],
|
82
|
-
lightseagreen: [32, 178, 170],
|
83
|
-
lightskyblue: [135, 206, 250],
|
84
|
-
lightslategray: [119, 136, 153],
|
85
|
-
lightslategrey: [119, 136, 153],
|
86
|
-
lightsteelblue: [176, 196, 222],
|
87
|
-
lightyellow: [255, 255, 224],
|
88
|
-
lime: [0, 255, 0],
|
89
|
-
limegreen: [50, 205, 50],
|
90
|
-
linen: [250, 240, 230],
|
91
|
-
magenta: [255, 0, 255],
|
92
|
-
maroon: [128, 0, 0],
|
93
|
-
mediumaquamarine: [102, 205, 170],
|
94
|
-
mediumblue: [0, 0, 205],
|
95
|
-
mediumorchid: [186, 85, 211],
|
96
|
-
mediumpurple: [147, 112, 219],
|
97
|
-
mediumseagreen: [60, 179, 113],
|
98
|
-
mediumslateblue: [123, 104, 238],
|
99
|
-
mediumspringgreen: [0, 250, 154],
|
100
|
-
mediumturquoise: [72, 209, 204],
|
101
|
-
mediumvioletred: [199, 21, 133],
|
102
|
-
midnightblue: [25, 25, 112],
|
103
|
-
mintcream: [245, 255, 250],
|
104
|
-
mistyrose: [255, 228, 225],
|
105
|
-
moccasin: [255, 228, 181],
|
106
|
-
navajowhite: [255, 222, 173],
|
107
|
-
navy: [0, 0, 128],
|
108
|
-
oldlace: [253, 245, 230],
|
109
|
-
olive: [128, 128, 0],
|
110
|
-
olivedrab: [107, 142, 35],
|
111
|
-
orange: [255, 165, 0],
|
112
|
-
orangered: [255, 69, 0],
|
113
|
-
orchid: [218, 112, 214],
|
114
|
-
palegoldenrod: [238, 232, 170],
|
115
|
-
palegreen: [152, 251, 152],
|
116
|
-
paleturquoise: [175, 238, 238],
|
117
|
-
palevioletred: [219, 112, 147],
|
118
|
-
papayawhip: [255, 239, 213],
|
119
|
-
peachpuff: [255, 218, 185],
|
120
|
-
peru: [205, 133, 63],
|
121
|
-
pink: [255, 192, 203],
|
122
|
-
plum: [221, 160, 221],
|
123
|
-
powderblue: [176, 224, 230],
|
124
|
-
purple: [128, 0, 128],
|
125
|
-
rebeccapurple: [102, 51, 153],
|
126
|
-
red: [255, 0, 0],
|
127
|
-
rosybrown: [188, 143, 143],
|
128
|
-
royalblue: [65, 105, 225],
|
129
|
-
saddlebrown: [139, 69, 19],
|
130
|
-
salmon: [250, 128, 114],
|
131
|
-
sandybrown: [244, 164, 96],
|
132
|
-
seagreen: [46, 139, 87],
|
133
|
-
seashell: [255, 245, 238],
|
134
|
-
sienna: [160, 82, 45],
|
135
|
-
silver: [192, 192, 192],
|
136
|
-
skyblue: [135, 206, 235],
|
137
|
-
slateblue: [106, 90, 205],
|
138
|
-
slategray: [112, 128, 144],
|
139
|
-
slategrey: [112, 128, 144],
|
140
|
-
snow: [255, 250, 250],
|
141
|
-
springgreen: [0, 255, 127],
|
142
|
-
steelblue: [70, 130, 180],
|
143
|
-
tan: [210, 180, 140],
|
144
|
-
teal: [0, 128, 128],
|
145
|
-
thistle: [216, 191, 216],
|
146
|
-
tomato: [255, 99, 71],
|
147
|
-
turquoise: [64, 224, 208],
|
148
|
-
violet: [238, 130, 238],
|
149
|
-
wheat: [245, 222, 179],
|
150
|
-
white: [255, 255, 255],
|
151
|
-
whitesmoke: [245, 245, 245],
|
152
|
-
yellow: [255, 255, 0],
|
153
|
-
yellowgreen: [154, 205, 50]
|
154
|
-
}, C = /* @__PURE__ */ Object.create(null);
|
155
|
-
for (const t in v)
|
156
|
-
Object.hasOwn(v, t) && (C[v[t]] = t);
|
157
|
-
const d = {
|
158
|
-
to: {},
|
159
|
-
get: {}
|
160
|
-
};
|
161
|
-
d.get = function(t) {
|
162
|
-
const e = t.slice(0, 3).toLowerCase();
|
163
|
-
let n, r;
|
164
|
-
switch (e) {
|
165
|
-
case "hsl": {
|
166
|
-
n = d.get.hsl(t), r = "hsl";
|
167
|
-
break;
|
168
|
-
}
|
169
|
-
case "hwb": {
|
170
|
-
n = d.get.hwb(t), r = "hwb";
|
171
|
-
break;
|
172
|
-
}
|
173
|
-
default: {
|
174
|
-
n = d.get.rgb(t), r = "rgb";
|
175
|
-
break;
|
176
|
-
}
|
177
|
-
}
|
178
|
-
return n ? { model: r, value: n } : null;
|
179
|
-
};
|
180
|
-
d.get.rgb = function(t) {
|
181
|
-
if (!t)
|
182
|
-
return null;
|
183
|
-
const e = /^#([a-f\d]{3,4})$/i, n = /^#([a-f\d]{6})([a-f\d]{2})?$/i, r = /^rgba?\(\s*([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)\s*(?:[,|/]\s*([+-]?[\d.]+)(%?)\s*)?\)$/, o = /^rgba?\(\s*([+-]?[\d.]+)%\s*,?\s*([+-]?[\d.]+)%\s*,?\s*([+-]?[\d.]+)%\s*(?:[,|/]\s*([+-]?[\d.]+)(%?)\s*)?\)$/, l = /^(\w+)$/;
|
184
|
-
let s = [0, 0, 0, 1], a, c, u;
|
185
|
-
if (a = t.match(n)) {
|
186
|
-
for (u = a[2], a = a[1], c = 0; c < 3; c++) {
|
187
|
-
const m = c * 2;
|
188
|
-
s[c] = Number.parseInt(a.slice(m, m + 2), 16);
|
189
|
-
}
|
190
|
-
u && (s[3] = Number.parseInt(u, 16) / 255);
|
191
|
-
} else if (a = t.match(e)) {
|
192
|
-
for (a = a[1], u = a[3], c = 0; c < 3; c++)
|
193
|
-
s[c] = Number.parseInt(a[c] + a[c], 16);
|
194
|
-
u && (s[3] = Number.parseInt(u + u, 16) / 255);
|
195
|
-
} else if (a = t.match(r)) {
|
196
|
-
for (c = 0; c < 3; c++)
|
197
|
-
s[c] = Number.parseInt(a[c + 1], 10);
|
198
|
-
a[4] && (s[3] = a[5] ? Number.parseFloat(a[4]) * 0.01 : Number.parseFloat(a[4]));
|
199
|
-
} else if (a = t.match(o)) {
|
200
|
-
for (c = 0; c < 3; c++)
|
201
|
-
s[c] = Math.round(Number.parseFloat(a[c + 1]) * 2.55);
|
202
|
-
a[4] && (s[3] = a[5] ? Number.parseFloat(a[4]) * 0.01 : Number.parseFloat(a[4]));
|
203
|
-
} else return (a = t.match(l)) ? a[1] === "transparent" ? [0, 0, 0, 0] : Object.hasOwn(v, a[1]) ? (s = v[a[1]], s[3] = 1, s) : null : null;
|
204
|
-
for (c = 0; c < 3; c++)
|
205
|
-
s[c] = y(s[c], 0, 255);
|
206
|
-
return s[3] = y(s[3], 0, 1), s;
|
207
|
-
};
|
208
|
-
d.get.hsl = function(t) {
|
209
|
-
if (!t)
|
210
|
-
return null;
|
211
|
-
const e = /^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*)?\)$/, n = t.match(e);
|
212
|
-
if (n) {
|
213
|
-
const r = Number.parseFloat(n[4]), o = (Number.parseFloat(n[1]) % 360 + 360) % 360, l = y(Number.parseFloat(n[2]), 0, 100), s = y(Number.parseFloat(n[3]), 0, 100), a = y(Number.isNaN(r) ? 1 : r, 0, 1);
|
214
|
-
return [o, l, s, a];
|
215
|
-
}
|
216
|
-
return null;
|
217
|
-
};
|
218
|
-
d.get.hwb = function(t) {
|
219
|
-
if (!t)
|
220
|
-
return null;
|
221
|
-
const e = /^hwb\(\s*([+-]?\d{0,3}(?:\.\d+)?)(?:deg)?\s*,\s*([+-]?[\d.]+)%\s*,\s*([+-]?[\d.]+)%\s*(?:,\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/, n = t.match(e);
|
222
|
-
if (n) {
|
223
|
-
const r = Number.parseFloat(n[4]), o = (Number.parseFloat(n[1]) % 360 + 360) % 360, l = y(Number.parseFloat(n[2]), 0, 100), s = y(Number.parseFloat(n[3]), 0, 100), a = y(Number.isNaN(r) ? 1 : r, 0, 1);
|
224
|
-
return [o, l, s, a];
|
225
|
-
}
|
226
|
-
return null;
|
227
|
-
};
|
228
|
-
d.to.hex = function(...t) {
|
229
|
-
return "#" + F(t[0]) + F(t[1]) + F(t[2]) + (t[3] < 1 ? F(Math.round(t[3] * 255)) : "");
|
230
|
-
};
|
231
|
-
d.to.rgb = function(...t) {
|
232
|
-
return t.length < 4 || t[3] === 1 ? "rgb(" + Math.round(t[0]) + ", " + Math.round(t[1]) + ", " + Math.round(t[2]) + ")" : "rgba(" + Math.round(t[0]) + ", " + Math.round(t[1]) + ", " + Math.round(t[2]) + ", " + t[3] + ")";
|
233
|
-
};
|
234
|
-
d.to.rgb.percent = function(...t) {
|
235
|
-
const e = Math.round(t[0] / 255 * 100), n = Math.round(t[1] / 255 * 100), r = Math.round(t[2] / 255 * 100);
|
236
|
-
return t.length < 4 || t[3] === 1 ? "rgb(" + e + "%, " + n + "%, " + r + "%)" : "rgba(" + e + "%, " + n + "%, " + r + "%, " + t[3] + ")";
|
237
|
-
};
|
238
|
-
d.to.hsl = function(...t) {
|
239
|
-
return t.length < 4 || t[3] === 1 ? "hsl(" + t[0] + ", " + t[1] + "%, " + t[2] + "%)" : "hsla(" + t[0] + ", " + t[1] + "%, " + t[2] + "%, " + t[3] + ")";
|
240
|
-
};
|
241
|
-
d.to.hwb = function(...t) {
|
242
|
-
let e = "";
|
243
|
-
return t.length >= 4 && t[3] !== 1 && (e = ", " + t[3]), "hwb(" + t[0] + ", " + t[1] + "%, " + t[2] + "%" + e + ")";
|
244
|
-
};
|
245
|
-
d.to.keyword = function(...t) {
|
246
|
-
return C[t.slice(0, 3)];
|
247
|
-
};
|
248
|
-
function y(t, e, n) {
|
249
|
-
return Math.min(Math.max(e, t), n);
|
250
|
-
}
|
251
|
-
function F(t) {
|
252
|
-
const e = Math.round(t).toString(16).toUpperCase();
|
253
|
-
return e.length < 2 ? "0" + e : e;
|
254
|
-
}
|
255
|
-
const x = {
|
256
|
-
aliceblue: [240, 248, 255],
|
257
|
-
antiquewhite: [250, 235, 215],
|
258
|
-
aqua: [0, 255, 255],
|
259
|
-
aquamarine: [127, 255, 212],
|
260
|
-
azure: [240, 255, 255],
|
261
|
-
beige: [245, 245, 220],
|
262
|
-
bisque: [255, 228, 196],
|
263
|
-
black: [0, 0, 0],
|
264
|
-
blanchedalmond: [255, 235, 205],
|
265
|
-
blue: [0, 0, 255],
|
266
|
-
blueviolet: [138, 43, 226],
|
267
|
-
brown: [165, 42, 42],
|
268
|
-
burlywood: [222, 184, 135],
|
269
|
-
cadetblue: [95, 158, 160],
|
270
|
-
chartreuse: [127, 255, 0],
|
271
|
-
chocolate: [210, 105, 30],
|
272
|
-
coral: [255, 127, 80],
|
273
|
-
cornflowerblue: [100, 149, 237],
|
274
|
-
cornsilk: [255, 248, 220],
|
275
|
-
crimson: [220, 20, 60],
|
276
|
-
cyan: [0, 255, 255],
|
277
|
-
darkblue: [0, 0, 139],
|
278
|
-
darkcyan: [0, 139, 139],
|
279
|
-
darkgoldenrod: [184, 134, 11],
|
280
|
-
darkgray: [169, 169, 169],
|
281
|
-
darkgreen: [0, 100, 0],
|
282
|
-
darkgrey: [169, 169, 169],
|
283
|
-
darkkhaki: [189, 183, 107],
|
284
|
-
darkmagenta: [139, 0, 139],
|
285
|
-
darkolivegreen: [85, 107, 47],
|
286
|
-
darkorange: [255, 140, 0],
|
287
|
-
darkorchid: [153, 50, 204],
|
288
|
-
darkred: [139, 0, 0],
|
289
|
-
darksalmon: [233, 150, 122],
|
290
|
-
darkseagreen: [143, 188, 143],
|
291
|
-
darkslateblue: [72, 61, 139],
|
292
|
-
darkslategray: [47, 79, 79],
|
293
|
-
darkslategrey: [47, 79, 79],
|
294
|
-
darkturquoise: [0, 206, 209],
|
295
|
-
darkviolet: [148, 0, 211],
|
296
|
-
deeppink: [255, 20, 147],
|
297
|
-
deepskyblue: [0, 191, 255],
|
298
|
-
dimgray: [105, 105, 105],
|
299
|
-
dimgrey: [105, 105, 105],
|
300
|
-
dodgerblue: [30, 144, 255],
|
301
|
-
firebrick: [178, 34, 34],
|
302
|
-
floralwhite: [255, 250, 240],
|
303
|
-
forestgreen: [34, 139, 34],
|
304
|
-
fuchsia: [255, 0, 255],
|
305
|
-
gainsboro: [220, 220, 220],
|
306
|
-
ghostwhite: [248, 248, 255],
|
307
|
-
gold: [255, 215, 0],
|
308
|
-
goldenrod: [218, 165, 32],
|
309
|
-
gray: [128, 128, 128],
|
310
|
-
green: [0, 128, 0],
|
311
|
-
greenyellow: [173, 255, 47],
|
312
|
-
grey: [128, 128, 128],
|
313
|
-
honeydew: [240, 255, 240],
|
314
|
-
hotpink: [255, 105, 180],
|
315
|
-
indianred: [205, 92, 92],
|
316
|
-
indigo: [75, 0, 130],
|
317
|
-
ivory: [255, 255, 240],
|
318
|
-
khaki: [240, 230, 140],
|
319
|
-
lavender: [230, 230, 250],
|
320
|
-
lavenderblush: [255, 240, 245],
|
321
|
-
lawngreen: [124, 252, 0],
|
322
|
-
lemonchiffon: [255, 250, 205],
|
323
|
-
lightblue: [173, 216, 230],
|
324
|
-
lightcoral: [240, 128, 128],
|
325
|
-
lightcyan: [224, 255, 255],
|
326
|
-
lightgoldenrodyellow: [250, 250, 210],
|
327
|
-
lightgray: [211, 211, 211],
|
328
|
-
lightgreen: [144, 238, 144],
|
329
|
-
lightgrey: [211, 211, 211],
|
330
|
-
lightpink: [255, 182, 193],
|
331
|
-
lightsalmon: [255, 160, 122],
|
332
|
-
lightseagreen: [32, 178, 170],
|
333
|
-
lightskyblue: [135, 206, 250],
|
334
|
-
lightslategray: [119, 136, 153],
|
335
|
-
lightslategrey: [119, 136, 153],
|
336
|
-
lightsteelblue: [176, 196, 222],
|
337
|
-
lightyellow: [255, 255, 224],
|
338
|
-
lime: [0, 255, 0],
|
339
|
-
limegreen: [50, 205, 50],
|
340
|
-
linen: [250, 240, 230],
|
341
|
-
magenta: [255, 0, 255],
|
342
|
-
maroon: [128, 0, 0],
|
343
|
-
mediumaquamarine: [102, 205, 170],
|
344
|
-
mediumblue: [0, 0, 205],
|
345
|
-
mediumorchid: [186, 85, 211],
|
346
|
-
mediumpurple: [147, 112, 219],
|
347
|
-
mediumseagreen: [60, 179, 113],
|
348
|
-
mediumslateblue: [123, 104, 238],
|
349
|
-
mediumspringgreen: [0, 250, 154],
|
350
|
-
mediumturquoise: [72, 209, 204],
|
351
|
-
mediumvioletred: [199, 21, 133],
|
352
|
-
midnightblue: [25, 25, 112],
|
353
|
-
mintcream: [245, 255, 250],
|
354
|
-
mistyrose: [255, 228, 225],
|
355
|
-
moccasin: [255, 228, 181],
|
356
|
-
navajowhite: [255, 222, 173],
|
357
|
-
navy: [0, 0, 128],
|
358
|
-
oldlace: [253, 245, 230],
|
359
|
-
olive: [128, 128, 0],
|
360
|
-
olivedrab: [107, 142, 35],
|
361
|
-
orange: [255, 165, 0],
|
362
|
-
orangered: [255, 69, 0],
|
363
|
-
orchid: [218, 112, 214],
|
364
|
-
palegoldenrod: [238, 232, 170],
|
365
|
-
palegreen: [152, 251, 152],
|
366
|
-
paleturquoise: [175, 238, 238],
|
367
|
-
palevioletred: [219, 112, 147],
|
368
|
-
papayawhip: [255, 239, 213],
|
369
|
-
peachpuff: [255, 218, 185],
|
370
|
-
peru: [205, 133, 63],
|
371
|
-
pink: [255, 192, 203],
|
372
|
-
plum: [221, 160, 221],
|
373
|
-
powderblue: [176, 224, 230],
|
374
|
-
purple: [128, 0, 128],
|
375
|
-
rebeccapurple: [102, 51, 153],
|
376
|
-
red: [255, 0, 0],
|
377
|
-
rosybrown: [188, 143, 143],
|
378
|
-
royalblue: [65, 105, 225],
|
379
|
-
saddlebrown: [139, 69, 19],
|
380
|
-
salmon: [250, 128, 114],
|
381
|
-
sandybrown: [244, 164, 96],
|
382
|
-
seagreen: [46, 139, 87],
|
383
|
-
seashell: [255, 245, 238],
|
384
|
-
sienna: [160, 82, 45],
|
385
|
-
silver: [192, 192, 192],
|
386
|
-
skyblue: [135, 206, 235],
|
387
|
-
slateblue: [106, 90, 205],
|
388
|
-
slategray: [112, 128, 144],
|
389
|
-
slategrey: [112, 128, 144],
|
390
|
-
snow: [255, 250, 250],
|
391
|
-
springgreen: [0, 255, 127],
|
392
|
-
steelblue: [70, 130, 180],
|
393
|
-
tan: [210, 180, 140],
|
394
|
-
teal: [0, 128, 128],
|
395
|
-
thistle: [216, 191, 216],
|
396
|
-
tomato: [255, 99, 71],
|
397
|
-
turquoise: [64, 224, 208],
|
398
|
-
violet: [238, 130, 238],
|
399
|
-
wheat: [245, 222, 179],
|
400
|
-
white: [255, 255, 255],
|
401
|
-
whitesmoke: [245, 245, 245],
|
402
|
-
yellow: [255, 255, 0],
|
403
|
-
yellowgreen: [154, 205, 50]
|
404
|
-
}, z = {};
|
405
|
-
for (const t of Object.keys(x))
|
406
|
-
z[x[t]] = t;
|
407
|
-
const i = {
|
408
|
-
rgb: { channels: 3, labels: "rgb" },
|
409
|
-
hsl: { channels: 3, labels: "hsl" },
|
410
|
-
hsv: { channels: 3, labels: "hsv" },
|
411
|
-
hwb: { channels: 3, labels: "hwb" },
|
412
|
-
cmyk: { channels: 4, labels: "cmyk" },
|
413
|
-
xyz: { channels: 3, labels: "xyz" },
|
414
|
-
lab: { channels: 3, labels: "lab" },
|
415
|
-
oklab: { channels: 3, labels: ["okl", "oka", "okb"] },
|
416
|
-
lch: { channels: 3, labels: "lch" },
|
417
|
-
oklch: { channels: 3, labels: ["okl", "okc", "okh"] },
|
418
|
-
hex: { channels: 1, labels: ["hex"] },
|
419
|
-
keyword: { channels: 1, labels: ["keyword"] },
|
420
|
-
ansi16: { channels: 1, labels: ["ansi16"] },
|
421
|
-
ansi256: { channels: 1, labels: ["ansi256"] },
|
422
|
-
hcg: { channels: 3, labels: ["h", "c", "g"] },
|
423
|
-
apple: { channels: 3, labels: ["r16", "g16", "b16"] },
|
424
|
-
gray: { channels: 1, labels: ["gray"] }
|
425
|
-
}, p = (6 / 29) ** 3;
|
426
|
-
function k(t) {
|
427
|
-
const e = t > 31308e-7 ? 1.055 * t ** 0.4166666666666667 - 0.055 : t * 12.92;
|
428
|
-
return Math.min(Math.max(0, e), 1);
|
429
|
-
}
|
430
|
-
function w(t) {
|
431
|
-
return t > 0.04045 ? ((t + 0.055) / 1.055) ** 2.4 : t / 12.92;
|
432
|
-
}
|
433
|
-
for (const t of Object.keys(i)) {
|
434
|
-
if (!("channels" in i[t]))
|
435
|
-
throw new Error("missing channels property: " + t);
|
436
|
-
if (!("labels" in i[t]))
|
437
|
-
throw new Error("missing channel labels property: " + t);
|
438
|
-
if (i[t].labels.length !== i[t].channels)
|
439
|
-
throw new Error("channel and label counts mismatch: " + t);
|
440
|
-
const { channels: e, labels: n } = i[t];
|
441
|
-
delete i[t].channels, delete i[t].labels, Object.defineProperty(i[t], "channels", { value: e }), Object.defineProperty(i[t], "labels", { value: n });
|
442
|
-
}
|
443
|
-
i.rgb.hsl = function(t) {
|
444
|
-
const e = t[0] / 255, n = t[1] / 255, r = t[2] / 255, o = Math.min(e, n, r), l = Math.max(e, n, r), s = l - o;
|
445
|
-
let a, c;
|
446
|
-
switch (l) {
|
447
|
-
case o: {
|
448
|
-
a = 0;
|
449
|
-
break;
|
450
|
-
}
|
451
|
-
case e: {
|
452
|
-
a = (n - r) / s;
|
453
|
-
break;
|
454
|
-
}
|
455
|
-
case n: {
|
456
|
-
a = 2 + (r - e) / s;
|
457
|
-
break;
|
458
|
-
}
|
459
|
-
case r: {
|
460
|
-
a = 4 + (e - n) / s;
|
461
|
-
break;
|
462
|
-
}
|
463
|
-
}
|
464
|
-
a = Math.min(a * 60, 360), a < 0 && (a += 360);
|
465
|
-
const u = (o + l) / 2;
|
466
|
-
return l === o ? c = 0 : u <= 0.5 ? c = s / (l + o) : c = s / (2 - l - o), [a, c * 100, u * 100];
|
467
|
-
};
|
468
|
-
i.rgb.hsv = function(t) {
|
469
|
-
let e, n, r, o, l;
|
470
|
-
const s = t[0] / 255, a = t[1] / 255, c = t[2] / 255, u = Math.max(s, a, c), m = u - Math.min(s, a, c), _ = function(I) {
|
471
|
-
return (u - I) / 6 / m + 1 / 2;
|
472
|
-
};
|
473
|
-
if (m === 0)
|
474
|
-
o = 0, l = 0;
|
475
|
-
else {
|
476
|
-
switch (l = m / u, e = _(s), n = _(a), r = _(c), u) {
|
477
|
-
case s: {
|
478
|
-
o = r - n;
|
479
|
-
break;
|
480
|
-
}
|
481
|
-
case a: {
|
482
|
-
o = 1 / 3 + e - r;
|
483
|
-
break;
|
484
|
-
}
|
485
|
-
case c: {
|
486
|
-
o = 2 / 3 + n - e;
|
487
|
-
break;
|
488
|
-
}
|
489
|
-
}
|
490
|
-
o < 0 ? o += 1 : o > 1 && (o -= 1);
|
491
|
-
}
|
492
|
-
return [
|
493
|
-
o * 360,
|
494
|
-
l * 100,
|
495
|
-
u * 100
|
496
|
-
];
|
497
|
-
};
|
498
|
-
i.rgb.hwb = function(t) {
|
499
|
-
const e = t[0], n = t[1];
|
500
|
-
let r = t[2];
|
501
|
-
const o = i.rgb.hsl(t)[0], l = 1 / 255 * Math.min(e, Math.min(n, r));
|
502
|
-
return r = 1 - 1 / 255 * Math.max(e, Math.max(n, r)), [o, l * 100, r * 100];
|
503
|
-
};
|
504
|
-
i.rgb.oklab = function(t) {
|
505
|
-
const e = w(t[0] / 255), n = w(t[1] / 255), r = w(t[2] / 255), o = Math.cbrt(0.4122214708 * e + 0.5363325363 * n + 0.0514459929 * r), l = Math.cbrt(0.2119034982 * e + 0.6806995451 * n + 0.1073969566 * r), s = Math.cbrt(0.0883024619 * e + 0.2817188376 * n + 0.6299787005 * r), a = 0.2104542553 * o + 0.793617785 * l - 0.0040720468 * s, c = 1.9779984951 * o - 2.428592205 * l + 0.4505937099 * s, u = 0.0259040371 * o + 0.7827717662 * l - 0.808675766 * s;
|
506
|
-
return [a * 100, c * 100, u * 100];
|
507
|
-
};
|
508
|
-
i.rgb.cmyk = function(t) {
|
509
|
-
const e = t[0] / 255, n = t[1] / 255, r = t[2] / 255, o = Math.min(1 - e, 1 - n, 1 - r), l = (1 - e - o) / (1 - o) || 0, s = (1 - n - o) / (1 - o) || 0, a = (1 - r - o) / (1 - o) || 0;
|
510
|
-
return [l * 100, s * 100, a * 100, o * 100];
|
511
|
-
};
|
512
|
-
function j(t, e) {
|
513
|
-
return (t[0] - e[0]) ** 2 + (t[1] - e[1]) ** 2 + (t[2] - e[2]) ** 2;
|
514
|
-
}
|
515
|
-
i.rgb.keyword = function(t) {
|
516
|
-
const e = z[t];
|
517
|
-
if (e)
|
518
|
-
return e;
|
519
|
-
let n = Number.POSITIVE_INFINITY, r;
|
520
|
-
for (const o of Object.keys(x)) {
|
521
|
-
const l = x[o], s = j(t, l);
|
522
|
-
s < n && (n = s, r = o);
|
523
|
-
}
|
524
|
-
return r;
|
525
|
-
};
|
526
|
-
i.keyword.rgb = function(t) {
|
527
|
-
return x[t];
|
528
|
-
};
|
529
|
-
i.rgb.xyz = function(t) {
|
530
|
-
const e = w(t[0] / 255), n = w(t[1] / 255), r = w(t[2] / 255), o = e * 0.4124564 + n * 0.3575761 + r * 0.1804375, l = e * 0.2126729 + n * 0.7151522 + r * 0.072175, s = e * 0.0193339 + n * 0.119192 + r * 0.9503041;
|
531
|
-
return [o * 100, l * 100, s * 100];
|
532
|
-
};
|
533
|
-
i.rgb.lab = function(t) {
|
534
|
-
const e = i.rgb.xyz(t);
|
535
|
-
let n = e[0], r = e[1], o = e[2];
|
536
|
-
n /= 95.047, r /= 100, o /= 108.883, n = n > p ? n ** (1 / 3) : 7.787 * n + 16 / 116, r = r > p ? r ** (1 / 3) : 7.787 * r + 16 / 116, o = o > p ? o ** (1 / 3) : 7.787 * o + 16 / 116;
|
537
|
-
const l = 116 * r - 16, s = 500 * (n - r), a = 200 * (r - o);
|
538
|
-
return [l, s, a];
|
539
|
-
};
|
540
|
-
i.hsl.rgb = function(t) {
|
541
|
-
const e = t[0] / 360, n = t[1] / 100, r = t[2] / 100;
|
542
|
-
let o, l;
|
543
|
-
if (n === 0)
|
544
|
-
return l = r * 255, [l, l, l];
|
545
|
-
const s = r < 0.5 ? r * (1 + n) : r + n - r * n, a = 2 * r - s, c = [0, 0, 0];
|
546
|
-
for (let u = 0; u < 3; u++)
|
547
|
-
o = e + 1 / 3 * -(u - 1), o < 0 && o++, o > 1 && o--, 6 * o < 1 ? l = a + (s - a) * 6 * o : 2 * o < 1 ? l = s : 3 * o < 2 ? l = a + (s - a) * (2 / 3 - o) * 6 : l = a, c[u] = l * 255;
|
548
|
-
return c;
|
549
|
-
};
|
550
|
-
i.hsl.hsv = function(t) {
|
551
|
-
const e = t[0];
|
552
|
-
let n = t[1] / 100, r = t[2] / 100, o = n;
|
553
|
-
const l = Math.max(r, 0.01);
|
554
|
-
r *= 2, n *= r <= 1 ? r : 2 - r, o *= l <= 1 ? l : 2 - l;
|
555
|
-
const s = (r + n) / 2, a = r === 0 ? 2 * o / (l + o) : 2 * n / (r + n);
|
556
|
-
return [e, a * 100, s * 100];
|
557
|
-
};
|
558
|
-
i.hsv.rgb = function(t) {
|
559
|
-
const e = t[0] / 60, n = t[1] / 100;
|
560
|
-
let r = t[2] / 100;
|
561
|
-
const o = Math.floor(e) % 6, l = e - Math.floor(e), s = 255 * r * (1 - n), a = 255 * r * (1 - n * l), c = 255 * r * (1 - n * (1 - l));
|
562
|
-
switch (r *= 255, o) {
|
563
|
-
case 0:
|
564
|
-
return [r, c, s];
|
565
|
-
case 1:
|
566
|
-
return [a, r, s];
|
567
|
-
case 2:
|
568
|
-
return [s, r, c];
|
569
|
-
case 3:
|
570
|
-
return [s, a, r];
|
571
|
-
case 4:
|
572
|
-
return [c, s, r];
|
573
|
-
case 5:
|
574
|
-
return [r, s, a];
|
575
|
-
}
|
576
|
-
};
|
577
|
-
i.hsv.hsl = function(t) {
|
578
|
-
const e = t[0], n = t[1] / 100, r = t[2] / 100, o = Math.max(r, 0.01);
|
579
|
-
let l, s;
|
580
|
-
s = (2 - n) * r;
|
581
|
-
const a = (2 - n) * o;
|
582
|
-
return l = n * o, l /= a <= 1 ? a : 2 - a, l = l || 0, s /= 2, [e, l * 100, s * 100];
|
583
|
-
};
|
584
|
-
i.hwb.rgb = function(t) {
|
585
|
-
const e = t[0] / 360;
|
586
|
-
let n = t[1] / 100, r = t[2] / 100;
|
587
|
-
const o = n + r;
|
588
|
-
let l;
|
589
|
-
o > 1 && (n /= o, r /= o);
|
590
|
-
const s = Math.floor(6 * e), a = 1 - r;
|
591
|
-
l = 6 * e - s, (s & 1) !== 0 && (l = 1 - l);
|
592
|
-
const c = n + l * (a - n);
|
593
|
-
let u, m, _;
|
594
|
-
switch (s) {
|
595
|
-
default:
|
596
|
-
case 6:
|
597
|
-
case 0: {
|
598
|
-
u = a, m = c, _ = n;
|
599
|
-
break;
|
600
|
-
}
|
601
|
-
case 1: {
|
602
|
-
u = c, m = a, _ = n;
|
603
|
-
break;
|
604
|
-
}
|
605
|
-
case 2: {
|
606
|
-
u = n, m = a, _ = c;
|
607
|
-
break;
|
608
|
-
}
|
609
|
-
case 3: {
|
610
|
-
u = n, m = c, _ = a;
|
611
|
-
break;
|
612
|
-
}
|
613
|
-
case 4: {
|
614
|
-
u = c, m = n, _ = a;
|
615
|
-
break;
|
616
|
-
}
|
617
|
-
case 5: {
|
618
|
-
u = a, m = n, _ = c;
|
619
|
-
break;
|
620
|
-
}
|
621
|
-
}
|
622
|
-
return [u * 255, m * 255, _ * 255];
|
623
|
-
};
|
624
|
-
i.cmyk.rgb = function(t) {
|
625
|
-
const e = t[0] / 100, n = t[1] / 100, r = t[2] / 100, o = t[3] / 100, l = 1 - Math.min(1, e * (1 - o) + o), s = 1 - Math.min(1, n * (1 - o) + o), a = 1 - Math.min(1, r * (1 - o) + o);
|
626
|
-
return [l * 255, s * 255, a * 255];
|
627
|
-
};
|
628
|
-
i.xyz.rgb = function(t) {
|
629
|
-
const e = t[0] / 100, n = t[1] / 100, r = t[2] / 100;
|
630
|
-
let o, l, s;
|
631
|
-
return o = e * 3.2404542 + n * -1.5371385 + r * -0.4985314, l = e * -0.969266 + n * 1.8760108 + r * 0.041556, s = e * 0.0556434 + n * -0.2040259 + r * 1.0572252, o = k(o), l = k(l), s = k(s), [o * 255, l * 255, s * 255];
|
632
|
-
};
|
633
|
-
i.xyz.lab = function(t) {
|
634
|
-
let e = t[0], n = t[1], r = t[2];
|
635
|
-
e /= 95.047, n /= 100, r /= 108.883, e = e > p ? e ** (1 / 3) : 7.787 * e + 16 / 116, n = n > p ? n ** (1 / 3) : 7.787 * n + 16 / 116, r = r > p ? r ** (1 / 3) : 7.787 * r + 16 / 116;
|
636
|
-
const o = 116 * n - 16, l = 500 * (e - n), s = 200 * (n - r);
|
637
|
-
return [o, l, s];
|
638
|
-
};
|
639
|
-
i.xyz.oklab = function(t) {
|
640
|
-
const e = t[0] / 100, n = t[1] / 100, r = t[2] / 100, o = Math.cbrt(0.8189330101 * e + 0.3618667424 * n - 0.1288597137 * r), l = Math.cbrt(0.0329845436 * e + 0.9293118715 * n + 0.0361456387 * r), s = Math.cbrt(0.0482003018 * e + 0.2643662691 * n + 0.633851707 * r), a = 0.2104542553 * o + 0.793617785 * l - 0.0040720468 * s, c = 1.9779984951 * o - 2.428592205 * l + 0.4505937099 * s, u = 0.0259040371 * o + 0.7827717662 * l - 0.808675766 * s;
|
641
|
-
return [a * 100, c * 100, u * 100];
|
642
|
-
};
|
643
|
-
i.oklab.oklch = function(t) {
|
644
|
-
return i.lab.lch(t);
|
645
|
-
};
|
646
|
-
i.oklab.xyz = function(t) {
|
647
|
-
const e = t[0] / 100, n = t[1] / 100, r = t[2] / 100, o = (0.999999998 * e + 0.396337792 * n + 0.215803758 * r) ** 3, l = (1.000000008 * e - 0.105561342 * n - 0.063854175 * r) ** 3, s = (1.000000055 * e - 0.089484182 * n - 1.291485538 * r) ** 3, a = 1.227013851 * o - 0.55779998 * l + 0.281256149 * s, c = -0.040580178 * o + 1.11225687 * l - 0.071676679 * s, u = -0.076381285 * o - 0.421481978 * l + 1.58616322 * s;
|
648
|
-
return [a * 100, c * 100, u * 100];
|
649
|
-
};
|
650
|
-
i.oklab.rgb = function(t) {
|
651
|
-
const e = t[0] / 100, n = t[1] / 100, r = t[2] / 100, o = (e + 0.3963377774 * n + 0.2158037573 * r) ** 3, l = (e - 0.1055613458 * n - 0.0638541728 * r) ** 3, s = (e - 0.0894841775 * n - 1.291485548 * r) ** 3, a = k(4.0767416621 * o - 3.3077115913 * l + 0.2309699292 * s), c = k(-1.2684380046 * o + 2.6097574011 * l - 0.3413193965 * s), u = k(-0.0041960863 * o - 0.7034186147 * l + 1.707614701 * s);
|
652
|
-
return [a * 255, c * 255, u * 255];
|
653
|
-
};
|
654
|
-
i.oklch.oklab = function(t) {
|
655
|
-
return i.lch.lab(t);
|
656
|
-
};
|
657
|
-
i.lab.xyz = function(t) {
|
658
|
-
const e = t[0], n = t[1], r = t[2];
|
659
|
-
let o, l, s;
|
660
|
-
l = (e + 16) / 116, o = n / 500 + l, s = l - r / 200;
|
661
|
-
const a = l ** 3, c = o ** 3, u = s ** 3;
|
662
|
-
return l = a > p ? a : (l - 16 / 116) / 7.787, o = c > p ? c : (o - 16 / 116) / 7.787, s = u > p ? u : (s - 16 / 116) / 7.787, o *= 95.047, l *= 100, s *= 108.883, [o, l, s];
|
663
|
-
};
|
664
|
-
i.lab.lch = function(t) {
|
665
|
-
const e = t[0], n = t[1], r = t[2];
|
666
|
-
let o;
|
667
|
-
o = Math.atan2(r, n) * 360 / 2 / Math.PI, o < 0 && (o += 360);
|
668
|
-
const s = Math.sqrt(n * n + r * r);
|
669
|
-
return [e, s, o];
|
670
|
-
};
|
671
|
-
i.lch.lab = function(t) {
|
672
|
-
const e = t[0], n = t[1], o = t[2] / 360 * 2 * Math.PI, l = n * Math.cos(o), s = n * Math.sin(o);
|
673
|
-
return [e, l, s];
|
674
|
-
};
|
675
|
-
i.rgb.ansi16 = function(t, e = null) {
|
676
|
-
const [n, r, o] = t;
|
677
|
-
let l = e === null ? i.rgb.hsv(t)[2] : e;
|
678
|
-
if (l = Math.round(l / 50), l === 0)
|
679
|
-
return 30;
|
680
|
-
let s = 30 + (Math.round(o / 255) << 2 | Math.round(r / 255) << 1 | Math.round(n / 255));
|
681
|
-
return l === 2 && (s += 60), s;
|
682
|
-
};
|
683
|
-
i.hsv.ansi16 = function(t) {
|
684
|
-
return i.rgb.ansi16(i.hsv.rgb(t), t[2]);
|
685
|
-
};
|
686
|
-
i.rgb.ansi256 = function(t) {
|
687
|
-
const e = t[0], n = t[1], r = t[2];
|
688
|
-
return e >> 4 === n >> 4 && n >> 4 === r >> 4 ? e < 8 ? 16 : e > 248 ? 231 : Math.round((e - 8) / 247 * 24) + 232 : 16 + 36 * Math.round(e / 255 * 5) + 6 * Math.round(n / 255 * 5) + Math.round(r / 255 * 5);
|
689
|
-
};
|
690
|
-
i.ansi16.rgb = function(t) {
|
691
|
-
t = t[0];
|
692
|
-
let e = t % 10;
|
693
|
-
if (e === 0 || e === 7)
|
694
|
-
return t > 50 && (e += 3.5), e = e / 10.5 * 255, [e, e, e];
|
695
|
-
const n = (Math.trunc(t > 50) + 1) * 0.5, r = (e & 1) * n * 255, o = (e >> 1 & 1) * n * 255, l = (e >> 2 & 1) * n * 255;
|
696
|
-
return [r, o, l];
|
697
|
-
};
|
698
|
-
i.ansi256.rgb = function(t) {
|
699
|
-
if (t = t[0], t >= 232) {
|
700
|
-
const l = (t - 232) * 10 + 8;
|
701
|
-
return [l, l, l];
|
702
|
-
}
|
703
|
-
t -= 16;
|
704
|
-
let e;
|
705
|
-
const n = Math.floor(t / 36) / 5 * 255, r = Math.floor((e = t % 36) / 6) / 5 * 255, o = e % 6 / 5 * 255;
|
706
|
-
return [n, r, o];
|
707
|
-
};
|
708
|
-
i.rgb.hex = function(t) {
|
709
|
-
const n = (((Math.round(t[0]) & 255) << 16) + ((Math.round(t[1]) & 255) << 8) + (Math.round(t[2]) & 255)).toString(16).toUpperCase();
|
710
|
-
return "000000".slice(n.length) + n;
|
711
|
-
};
|
712
|
-
i.hex.rgb = function(t) {
|
713
|
-
const e = t.toString(16).match(/[a-f\d]{6}|[a-f\d]{3}/i);
|
714
|
-
if (!e)
|
715
|
-
return [0, 0, 0];
|
716
|
-
let n = e[0];
|
717
|
-
e[0].length === 3 && (n = [...n].map((a) => a + a).join(""));
|
718
|
-
const r = Number.parseInt(n, 16), o = r >> 16 & 255, l = r >> 8 & 255, s = r & 255;
|
719
|
-
return [o, l, s];
|
720
|
-
};
|
721
|
-
i.rgb.hcg = function(t) {
|
722
|
-
const e = t[0] / 255, n = t[1] / 255, r = t[2] / 255, o = Math.max(Math.max(e, n), r), l = Math.min(Math.min(e, n), r), s = o - l;
|
723
|
-
let a;
|
724
|
-
const c = s < 1 ? l / (1 - s) : 0;
|
725
|
-
return s <= 0 ? a = 0 : o === e ? a = (n - r) / s % 6 : o === n ? a = 2 + (r - e) / s : a = 4 + (e - n) / s, a /= 6, a %= 1, [a * 360, s * 100, c * 100];
|
726
|
-
};
|
727
|
-
i.hsl.hcg = function(t) {
|
728
|
-
const e = t[1] / 100, n = t[2] / 100, r = n < 0.5 ? 2 * e * n : 2 * e * (1 - n);
|
729
|
-
let o = 0;
|
730
|
-
return r < 1 && (o = (n - 0.5 * r) / (1 - r)), [t[0], r * 100, o * 100];
|
731
|
-
};
|
732
|
-
i.hsv.hcg = function(t) {
|
733
|
-
const e = t[1] / 100, n = t[2] / 100, r = e * n;
|
734
|
-
let o = 0;
|
735
|
-
return r < 1 && (o = (n - r) / (1 - r)), [t[0], r * 100, o * 100];
|
736
|
-
};
|
737
|
-
i.hcg.rgb = function(t) {
|
738
|
-
const e = t[0] / 360, n = t[1] / 100, r = t[2] / 100;
|
739
|
-
if (n === 0)
|
740
|
-
return [r * 255, r * 255, r * 255];
|
741
|
-
const o = [0, 0, 0], l = e % 1 * 6, s = l % 1, a = 1 - s;
|
742
|
-
let c = 0;
|
743
|
-
switch (Math.floor(l)) {
|
744
|
-
case 0: {
|
745
|
-
o[0] = 1, o[1] = s, o[2] = 0;
|
746
|
-
break;
|
747
|
-
}
|
748
|
-
case 1: {
|
749
|
-
o[0] = a, o[1] = 1, o[2] = 0;
|
750
|
-
break;
|
751
|
-
}
|
752
|
-
case 2: {
|
753
|
-
o[0] = 0, o[1] = 1, o[2] = s;
|
754
|
-
break;
|
755
|
-
}
|
756
|
-
case 3: {
|
757
|
-
o[0] = 0, o[1] = a, o[2] = 1;
|
758
|
-
break;
|
759
|
-
}
|
760
|
-
case 4: {
|
761
|
-
o[0] = s, o[1] = 0, o[2] = 1;
|
762
|
-
break;
|
763
|
-
}
|
764
|
-
default:
|
765
|
-
o[0] = 1, o[1] = 0, o[2] = a;
|
766
|
-
}
|
767
|
-
return c = (1 - n) * r, [
|
768
|
-
(n * o[0] + c) * 255,
|
769
|
-
(n * o[1] + c) * 255,
|
770
|
-
(n * o[2] + c) * 255
|
771
|
-
];
|
772
|
-
};
|
773
|
-
i.hcg.hsv = function(t) {
|
774
|
-
const e = t[1] / 100, n = t[2] / 100, r = e + n * (1 - e);
|
775
|
-
let o = 0;
|
776
|
-
return r > 0 && (o = e / r), [t[0], o * 100, r * 100];
|
777
|
-
};
|
778
|
-
i.hcg.hsl = function(t) {
|
779
|
-
const e = t[1] / 100, r = t[2] / 100 * (1 - e) + 0.5 * e;
|
780
|
-
let o = 0;
|
781
|
-
return r > 0 && r < 0.5 ? o = e / (2 * r) : r >= 0.5 && r < 1 && (o = e / (2 * (1 - r))), [t[0], o * 100, r * 100];
|
782
|
-
};
|
783
|
-
i.hcg.hwb = function(t) {
|
784
|
-
const e = t[1] / 100, n = t[2] / 100, r = e + n * (1 - e);
|
785
|
-
return [t[0], (r - e) * 100, (1 - r) * 100];
|
786
|
-
};
|
787
|
-
i.hwb.hcg = function(t) {
|
788
|
-
const e = t[1] / 100, r = 1 - t[2] / 100, o = r - e;
|
789
|
-
let l = 0;
|
790
|
-
return o < 1 && (l = (r - o) / (1 - o)), [t[0], o * 100, l * 100];
|
791
|
-
};
|
792
|
-
i.apple.rgb = function(t) {
|
793
|
-
return [t[0] / 65535 * 255, t[1] / 65535 * 255, t[2] / 65535 * 255];
|
794
|
-
};
|
795
|
-
i.rgb.apple = function(t) {
|
796
|
-
return [t[0] / 255 * 65535, t[1] / 255 * 65535, t[2] / 255 * 65535];
|
797
|
-
};
|
798
|
-
i.gray.rgb = function(t) {
|
799
|
-
return [t[0] / 100 * 255, t[0] / 100 * 255, t[0] / 100 * 255];
|
800
|
-
};
|
801
|
-
i.gray.hsl = function(t) {
|
802
|
-
return [0, 0, t[0]];
|
803
|
-
};
|
804
|
-
i.gray.hsv = i.gray.hsl;
|
805
|
-
i.gray.hwb = function(t) {
|
806
|
-
return [0, 100, t[0]];
|
807
|
-
};
|
808
|
-
i.gray.cmyk = function(t) {
|
809
|
-
return [0, 0, 0, t[0]];
|
810
|
-
};
|
811
|
-
i.gray.lab = function(t) {
|
812
|
-
return [t[0], 0, 0];
|
813
|
-
};
|
814
|
-
i.gray.hex = function(t) {
|
815
|
-
const e = Math.round(t[0] / 100 * 255) & 255, r = ((e << 16) + (e << 8) + e).toString(16).toUpperCase();
|
816
|
-
return "000000".slice(r.length) + r;
|
817
|
-
};
|
818
|
-
i.rgb.gray = function(t) {
|
819
|
-
return [(t[0] + t[1] + t[2]) / 3 / 255 * 100];
|
820
|
-
};
|
821
|
-
function E() {
|
822
|
-
const t = {}, e = Object.keys(i);
|
823
|
-
for (let { length: n } = e, r = 0; r < n; r++)
|
824
|
-
t[e[r]] = {
|
825
|
-
// http://jsperf.com/1-vs-infinity
|
826
|
-
// micro-opt, but this is simple.
|
827
|
-
distance: -1,
|
828
|
-
parent: null
|
829
|
-
};
|
830
|
-
return t;
|
831
|
-
}
|
832
|
-
function $(t) {
|
833
|
-
const e = E(), n = [t];
|
834
|
-
for (e[t].distance = 0; n.length > 0; ) {
|
835
|
-
const r = n.pop(), o = Object.keys(i[r]);
|
836
|
-
for (let { length: l } = o, s = 0; s < l; s++) {
|
837
|
-
const a = o[s], c = e[a];
|
838
|
-
c.distance === -1 && (c.distance = e[r].distance + 1, c.parent = r, n.unshift(a));
|
839
|
-
}
|
840
|
-
}
|
841
|
-
return e;
|
842
|
-
}
|
843
|
-
function T(t, e) {
|
844
|
-
return function(n) {
|
845
|
-
return e(t(n));
|
846
|
-
};
|
847
|
-
}
|
848
|
-
function U(t, e) {
|
849
|
-
const n = [e[t].parent, t];
|
850
|
-
let r = i[e[t].parent][t], o = e[t].parent;
|
851
|
-
for (; e[o].parent; )
|
852
|
-
n.unshift(e[o].parent), r = T(i[e[o].parent][o], r), o = e[o].parent;
|
853
|
-
return r.conversion = n, r;
|
854
|
-
}
|
855
|
-
function D(t) {
|
856
|
-
const e = $(t), n = {}, r = Object.keys(e);
|
857
|
-
for (let { length: o } = r, l = 0; l < o; l++) {
|
858
|
-
const s = r[l];
|
859
|
-
e[s].parent !== null && (n[s] = U(s, e));
|
860
|
-
}
|
861
|
-
return n;
|
862
|
-
}
|
863
|
-
const g = {}, K = Object.keys(i);
|
864
|
-
function B(t) {
|
865
|
-
const e = function(...n) {
|
866
|
-
const r = n[0];
|
867
|
-
return r == null ? r : (r.length > 1 && (n = r), t(n));
|
868
|
-
};
|
869
|
-
return "conversion" in t && (e.conversion = t.conversion), e;
|
870
|
-
}
|
871
|
-
function V(t) {
|
872
|
-
const e = function(...n) {
|
873
|
-
const r = n[0];
|
874
|
-
if (r == null)
|
875
|
-
return r;
|
876
|
-
r.length > 1 && (n = r);
|
877
|
-
const o = t(n);
|
878
|
-
if (typeof o == "object")
|
879
|
-
for (let { length: l } = o, s = 0; s < l; s++)
|
880
|
-
o[s] = Math.round(o[s]);
|
881
|
-
return o;
|
882
|
-
};
|
883
|
-
return "conversion" in t && (e.conversion = t.conversion), e;
|
884
|
-
}
|
885
|
-
for (const t of K) {
|
886
|
-
g[t] = {}, Object.defineProperty(g[t], "channels", { value: i[t].channels }), Object.defineProperty(g[t], "labels", { value: i[t].labels });
|
887
|
-
const e = D(t), n = Object.keys(e);
|
888
|
-
for (const r of n) {
|
889
|
-
const o = e[r];
|
890
|
-
g[t][r] = V(o), g[t][r].raw = B(o);
|
891
|
-
}
|
892
|
-
}
|
893
|
-
const A = [
|
894
|
-
// To be honest, I don't really feel like keyword belongs in color convert, but eh.
|
895
|
-
"keyword",
|
896
|
-
// Gray conflicts with some method names, and has its own method defined.
|
897
|
-
"gray",
|
898
|
-
// Shouldn't really be in color-convert either...
|
899
|
-
"hex"
|
900
|
-
], O = {};
|
901
|
-
for (const t of Object.keys(g))
|
902
|
-
O[[...g[t].labels].sort().join("")] = t;
|
903
|
-
const M = {};
|
904
|
-
function b(t, e) {
|
905
|
-
if (!(this instanceof b))
|
906
|
-
return new b(t, e);
|
907
|
-
if (e && e in A && (e = null), e && !(e in g))
|
908
|
-
throw new Error("Unknown model: " + e);
|
909
|
-
let n, r;
|
910
|
-
if (t == null)
|
911
|
-
this.model = "rgb", this.color = [0, 0, 0], this.valpha = 1;
|
912
|
-
else if (t instanceof b)
|
913
|
-
this.model = t.model, this.color = [...t.color], this.valpha = t.valpha;
|
914
|
-
else if (typeof t == "string") {
|
915
|
-
const o = d.get(t);
|
916
|
-
if (o === null)
|
917
|
-
throw new Error("Unable to parse color from string: " + t);
|
918
|
-
this.model = o.model, r = g[this.model].channels, this.color = o.value.slice(0, r), this.valpha = typeof o.value[r] == "number" ? o.value[r] : 1;
|
919
|
-
} else if (t.length > 0) {
|
920
|
-
this.model = e || "rgb", r = g[this.model].channels;
|
921
|
-
const o = Array.prototype.slice.call(t, 0, r);
|
922
|
-
this.color = q(o, r), this.valpha = typeof t[r] == "number" ? t[r] : 1;
|
923
|
-
} else if (typeof t == "number")
|
924
|
-
this.model = "rgb", this.color = [
|
925
|
-
t >> 16 & 255,
|
926
|
-
t >> 8 & 255,
|
927
|
-
t & 255
|
928
|
-
], this.valpha = 1;
|
929
|
-
else {
|
930
|
-
this.valpha = 1;
|
931
|
-
const o = Object.keys(t);
|
932
|
-
"alpha" in t && (o.splice(o.indexOf("alpha"), 1), this.valpha = typeof t.alpha == "number" ? t.alpha : 0);
|
933
|
-
const l = o.sort().join("");
|
934
|
-
if (!(l in O))
|
935
|
-
throw new Error("Unable to parse color from object: " + JSON.stringify(t));
|
936
|
-
this.model = O[l];
|
937
|
-
const { labels: s } = g[this.model], a = [];
|
938
|
-
for (n = 0; n < s.length; n++)
|
939
|
-
a.push(t[s[n]]);
|
940
|
-
this.color = q(a);
|
941
|
-
}
|
942
|
-
if (M[this.model])
|
943
|
-
for (r = g[this.model].channels, n = 0; n < r; n++) {
|
944
|
-
const o = M[this.model][n];
|
945
|
-
o && (this.color[n] = o(this.color[n]));
|
946
|
-
}
|
947
|
-
this.valpha = Math.max(0, Math.min(1, this.valpha)), Object.freeze && Object.freeze(this);
|
948
|
-
}
|
949
|
-
b.prototype = {
|
950
|
-
toString() {
|
951
|
-
return this.string();
|
952
|
-
},
|
953
|
-
toJSON() {
|
954
|
-
return this[this.model]();
|
955
|
-
},
|
956
|
-
string(t) {
|
957
|
-
let e = this.model in d.to ? this : this.rgb();
|
958
|
-
e = e.round(typeof t == "number" ? t : 1);
|
959
|
-
const n = e.valpha === 1 ? e.color : [...e.color, this.valpha];
|
960
|
-
return d.to[e.model](...n);
|
961
|
-
},
|
962
|
-
percentString(t) {
|
963
|
-
const e = this.rgb().round(typeof t == "number" ? t : 1), n = e.valpha === 1 ? e.color : [...e.color, this.valpha];
|
964
|
-
return d.to.rgb.percent(...n);
|
965
|
-
},
|
966
|
-
array() {
|
967
|
-
return this.valpha === 1 ? [...this.color] : [...this.color, this.valpha];
|
968
|
-
},
|
969
|
-
object() {
|
970
|
-
const t = {}, { channels: e } = g[this.model], { labels: n } = g[this.model];
|
971
|
-
for (let r = 0; r < e; r++)
|
972
|
-
t[n[r]] = this.color[r];
|
973
|
-
return this.valpha !== 1 && (t.alpha = this.valpha), t;
|
974
|
-
},
|
975
|
-
unitArray() {
|
976
|
-
const t = this.rgb().color;
|
977
|
-
return t[0] /= 255, t[1] /= 255, t[2] /= 255, this.valpha !== 1 && t.push(this.valpha), t;
|
978
|
-
},
|
979
|
-
unitObject() {
|
980
|
-
const t = this.rgb().object();
|
981
|
-
return t.r /= 255, t.g /= 255, t.b /= 255, this.valpha !== 1 && (t.alpha = this.valpha), t;
|
982
|
-
},
|
983
|
-
round(t) {
|
984
|
-
return t = Math.max(t || 0, 0), new b([...this.color.map(R(t)), this.valpha], this.model);
|
985
|
-
},
|
986
|
-
alpha(t) {
|
987
|
-
return t !== void 0 ? new b([...this.color, Math.max(0, Math.min(1, t))], this.model) : this.valpha;
|
988
|
-
},
|
989
|
-
// Rgb
|
990
|
-
red: h("rgb", 0, f(255)),
|
991
|
-
green: h("rgb", 1, f(255)),
|
992
|
-
blue: h("rgb", 2, f(255)),
|
993
|
-
hue: h(["hsl", "hsv", "hsl", "hwb", "hcg"], 0, (t) => (t % 360 + 360) % 360),
|
994
|
-
saturationl: h("hsl", 1, f(100)),
|
995
|
-
lightness: h("hsl", 2, f(100)),
|
996
|
-
saturationv: h("hsv", 1, f(100)),
|
997
|
-
value: h("hsv", 2, f(100)),
|
998
|
-
chroma: h("hcg", 1, f(100)),
|
999
|
-
gray: h("hcg", 2, f(100)),
|
1000
|
-
white: h("hwb", 1, f(100)),
|
1001
|
-
wblack: h("hwb", 2, f(100)),
|
1002
|
-
cyan: h("cmyk", 0, f(100)),
|
1003
|
-
magenta: h("cmyk", 1, f(100)),
|
1004
|
-
yellow: h("cmyk", 2, f(100)),
|
1005
|
-
black: h("cmyk", 3, f(100)),
|
1006
|
-
x: h("xyz", 0, f(95.047)),
|
1007
|
-
y: h("xyz", 1, f(100)),
|
1008
|
-
z: h("xyz", 2, f(108.833)),
|
1009
|
-
l: h("lab", 0, f(100)),
|
1010
|
-
a: h("lab", 1),
|
1011
|
-
b: h("lab", 2),
|
1012
|
-
keyword(t) {
|
1013
|
-
return t !== void 0 ? new b(t) : g[this.model].keyword(this.color);
|
1014
|
-
},
|
1015
|
-
hex(t) {
|
1016
|
-
return t !== void 0 ? new b(t) : d.to.hex(...this.rgb().round().color);
|
1017
|
-
},
|
1018
|
-
hexa(t) {
|
1019
|
-
if (t !== void 0)
|
1020
|
-
return new b(t);
|
1021
|
-
const e = this.rgb().round().color;
|
1022
|
-
let n = Math.round(this.valpha * 255).toString(16).toUpperCase();
|
1023
|
-
return n.length === 1 && (n = "0" + n), d.to.hex(...e) + n;
|
1024
|
-
},
|
1025
|
-
rgbNumber() {
|
1026
|
-
const t = this.rgb().color;
|
1027
|
-
return (t[0] & 255) << 16 | (t[1] & 255) << 8 | t[2] & 255;
|
1028
|
-
},
|
1029
|
-
luminosity() {
|
1030
|
-
const t = this.rgb().color, e = [];
|
1031
|
-
for (const [n, r] of t.entries()) {
|
1032
|
-
const o = r / 255;
|
1033
|
-
e[n] = o <= 0.04045 ? o / 12.92 : ((o + 0.055) / 1.055) ** 2.4;
|
1034
|
-
}
|
1035
|
-
return 0.2126 * e[0] + 0.7152 * e[1] + 0.0722 * e[2];
|
1036
|
-
},
|
1037
|
-
contrast(t) {
|
1038
|
-
const e = this.luminosity(), n = t.luminosity();
|
1039
|
-
return e > n ? (e + 0.05) / (n + 0.05) : (n + 0.05) / (e + 0.05);
|
1040
|
-
},
|
1041
|
-
level(t) {
|
1042
|
-
const e = this.contrast(t);
|
1043
|
-
return e >= 7 ? "AAA" : e >= 4.5 ? "AA" : "";
|
1044
|
-
},
|
1045
|
-
isDark() {
|
1046
|
-
const t = this.rgb().color;
|
1047
|
-
return (t[0] * 2126 + t[1] * 7152 + t[2] * 722) / 1e4 < 128;
|
1048
|
-
},
|
1049
|
-
isLight() {
|
1050
|
-
return !this.isDark();
|
1051
|
-
},
|
1052
|
-
negate() {
|
1053
|
-
const t = this.rgb();
|
1054
|
-
for (let e = 0; e < 3; e++)
|
1055
|
-
t.color[e] = 255 - t.color[e];
|
1056
|
-
return t;
|
1057
|
-
},
|
1058
|
-
lighten(t) {
|
1059
|
-
const e = this.hsl();
|
1060
|
-
return e.color[2] += e.color[2] * t, e;
|
1061
|
-
},
|
1062
|
-
darken(t) {
|
1063
|
-
const e = this.hsl();
|
1064
|
-
return e.color[2] -= e.color[2] * t, e;
|
1065
|
-
},
|
1066
|
-
saturate(t) {
|
1067
|
-
const e = this.hsl();
|
1068
|
-
return e.color[1] += e.color[1] * t, e;
|
1069
|
-
},
|
1070
|
-
desaturate(t) {
|
1071
|
-
const e = this.hsl();
|
1072
|
-
return e.color[1] -= e.color[1] * t, e;
|
1073
|
-
},
|
1074
|
-
whiten(t) {
|
1075
|
-
const e = this.hwb();
|
1076
|
-
return e.color[1] += e.color[1] * t, e;
|
1077
|
-
},
|
1078
|
-
blacken(t) {
|
1079
|
-
const e = this.hwb();
|
1080
|
-
return e.color[2] += e.color[2] * t, e;
|
1081
|
-
},
|
1082
|
-
grayscale() {
|
1083
|
-
const t = this.rgb().color, e = t[0] * 0.3 + t[1] * 0.59 + t[2] * 0.11;
|
1084
|
-
return b.rgb(e, e, e);
|
1085
|
-
},
|
1086
|
-
fade(t) {
|
1087
|
-
return this.alpha(this.valpha - this.valpha * t);
|
1088
|
-
},
|
1089
|
-
opaquer(t) {
|
1090
|
-
return this.alpha(this.valpha + this.valpha * t);
|
1091
|
-
},
|
1092
|
-
rotate(t) {
|
1093
|
-
const e = this.hsl();
|
1094
|
-
let n = e.color[0];
|
1095
|
-
return n = (n + t) % 360, n = n < 0 ? 360 + n : n, e.color[0] = n, e;
|
1096
|
-
},
|
1097
|
-
mix(t, e) {
|
1098
|
-
if (!t || !t.rgb)
|
1099
|
-
throw new Error('Argument to "mix" was not a Color instance, but rather an instance of ' + typeof t);
|
1100
|
-
const n = t.rgb(), r = this.rgb(), o = e === void 0 ? 0.5 : e, l = 2 * o - 1, s = n.alpha() - r.alpha(), a = ((l * s === -1 ? l : (l + s) / (1 + l * s)) + 1) / 2, c = 1 - a;
|
1101
|
-
return b.rgb(
|
1102
|
-
a * n.red() + c * r.red(),
|
1103
|
-
a * n.green() + c * r.green(),
|
1104
|
-
a * n.blue() + c * r.blue(),
|
1105
|
-
n.alpha() * o + r.alpha() * (1 - o)
|
1106
|
-
);
|
1107
|
-
}
|
1108
|
-
};
|
1109
|
-
for (const t of Object.keys(g)) {
|
1110
|
-
if (A.includes(t))
|
1111
|
-
continue;
|
1112
|
-
const { channels: e } = g[t];
|
1113
|
-
b.prototype[t] = function(...n) {
|
1114
|
-
return this.model === t ? new b(this) : n.length > 0 ? new b(n, t) : new b([...J(g[this.model][t].raw(this.color)), this.valpha], t);
|
1115
|
-
}, b[t] = function(...n) {
|
1116
|
-
let r = n[0];
|
1117
|
-
return typeof r == "number" && (r = q(n, e)), new b(r, t);
|
1118
|
-
};
|
1119
|
-
}
|
1120
|
-
function L(t, e) {
|
1121
|
-
return Number(t.toFixed(e));
|
1122
|
-
}
|
1123
|
-
function R(t) {
|
1124
|
-
return function(e) {
|
1125
|
-
return L(e, t);
|
1126
|
-
};
|
1127
|
-
}
|
1128
|
-
function h(t, e, n) {
|
1129
|
-
t = Array.isArray(t) ? t : [t];
|
1130
|
-
for (const r of t)
|
1131
|
-
(M[r] || (M[r] = []))[e] = n;
|
1132
|
-
return t = t[0], function(r) {
|
1133
|
-
let o;
|
1134
|
-
return r !== void 0 ? (n && (r = n(r)), o = this[t](), o.color[e] = r, o) : (o = this[t]().color[e], n && (o = n(o)), o);
|
1135
|
-
};
|
1136
|
-
}
|
1137
|
-
function f(t) {
|
1138
|
-
return function(e) {
|
1139
|
-
return Math.max(0, Math.min(t, e));
|
1140
|
-
};
|
1141
|
-
}
|
1142
|
-
function J(t) {
|
1143
|
-
return Array.isArray(t) ? t : [t];
|
1144
|
-
}
|
1145
|
-
function q(t, e) {
|
1146
|
-
for (let n = 0; n < e; n++)
|
1147
|
-
typeof t[n] != "number" && (t[n] = 0);
|
1148
|
-
return t;
|
1149
|
-
}
|
1150
|
-
class G {
|
1151
|
-
constructor(e) {
|
1152
|
-
N(this, "isColor", !0);
|
1153
|
-
N(this, "currentColor");
|
1154
|
-
this.base = e;
|
1155
|
-
const n = this._resolveBaseColor(e);
|
1156
|
-
return this.currentColor = b(n), this._createProxy();
|
1
|
+
var __defProp = Object.defineProperty;
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
3
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
4
|
+
import colorFunction from "color";
|
5
|
+
import { d } from "../viewport-clamp-K553uXu3.js";
|
6
|
+
class Color {
|
7
|
+
constructor(base) {
|
8
|
+
__publicField(this, "isColor", true);
|
9
|
+
__publicField(this, "currentColor");
|
10
|
+
this.base = base;
|
11
|
+
const colorValue = this._resolveBaseColor(base);
|
12
|
+
this.currentColor = colorFunction(colorValue);
|
13
|
+
return this._createProxy();
|
1157
14
|
}
|
1158
15
|
_createProxy() {
|
1159
16
|
return new Proxy(this, {
|
1160
|
-
get(
|
1161
|
-
|
17
|
+
get(target, prop) {
|
18
|
+
if (prop in target) return target[prop];
|
19
|
+
if (prop in target.currentColor) return target._handleColorMethod(prop);
|
20
|
+
return target[prop];
|
1162
21
|
}
|
1163
22
|
});
|
1164
23
|
}
|
1165
|
-
_resolveBaseColor(
|
1166
|
-
if (typeof
|
1167
|
-
|
1168
|
-
|
1169
|
-
|
1170
|
-
|
1171
|
-
|
1172
|
-
const
|
1173
|
-
|
24
|
+
_resolveBaseColor(base) {
|
25
|
+
if (typeof base !== "string") return base;
|
26
|
+
const isToken = /\{[^{}]+\}/g.test(base);
|
27
|
+
if (!isToken) return base;
|
28
|
+
if (typeof saltyConfig === "undefined") return "transparent";
|
29
|
+
const { staticVariables } = saltyConfig;
|
30
|
+
if (!staticVariables) return "transparent";
|
31
|
+
const tokenPath = base.replace(/^\{|\}$/g, "").split(".");
|
32
|
+
const value = tokenPath.reduce((acc, key) => acc[key], staticVariables);
|
33
|
+
return value;
|
34
|
+
}
|
35
|
+
_handleColorMethod(method) {
|
36
|
+
const color2 = this.currentColor;
|
37
|
+
if (typeof color2[method] !== "function") return color2[method];
|
38
|
+
return (...args) => {
|
39
|
+
this.currentColor = color2[method](...args);
|
40
|
+
return this._createProxy();
|
41
|
+
};
|
1174
42
|
}
|
1175
43
|
toString() {
|
1176
44
|
return this.currentColor.toString();
|
1177
45
|
}
|
1178
46
|
}
|
1179
|
-
const
|
47
|
+
const color = (value) => {
|
48
|
+
return new Color(value);
|
49
|
+
};
|
1180
50
|
export {
|
1181
|
-
|
1182
|
-
|
51
|
+
color,
|
52
|
+
d as defineViewportClamp
|
1183
53
|
};
|