@salty-css/react 0.0.1-alpha.260 → 0.0.1-alpha.262

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/helpers.js CHANGED
@@ -1,1154 +1 @@
1
- var A = Object.defineProperty;
2
- var P = (e, t, n) => t in e ? A(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
- var _ = (e, t, n) => P(e, typeof t != "symbol" ? t + "" : t, n);
4
- import { d as Q } from "./viewport-clamp-BOc-8Oph.js";
5
- const w = {
6
- aliceblue: [240, 248, 255],
7
- antiquewhite: [250, 235, 215],
8
- aqua: [0, 255, 255],
9
- aquamarine: [127, 255, 212],
10
- azure: [240, 255, 255],
11
- beige: [245, 245, 220],
12
- bisque: [255, 228, 196],
13
- black: [0, 0, 0],
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
- }, O = /* @__PURE__ */ Object.create(null);
155
- for (const e in w)
156
- Object.hasOwn(w, e) && (O[w[e]] = e);
157
- const d = {
158
- to: {},
159
- get: {}
160
- };
161
- d.get = function(e) {
162
- const t = e.slice(0, 3).toLowerCase();
163
- let n, r;
164
- switch (t) {
165
- case "hsl": {
166
- n = d.get.hsl(e), r = "hsl";
167
- break;
168
- }
169
- case "hwb": {
170
- n = d.get.hwb(e), r = "hwb";
171
- break;
172
- }
173
- default: {
174
- n = d.get.rgb(e), r = "rgb";
175
- break;
176
- }
177
- }
178
- return n ? { model: r, value: n } : null;
179
- };
180
- d.get.rgb = function(e) {
181
- if (!e)
182
- return null;
183
- const t = /^#([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, i, u;
185
- if (a = e.match(n)) {
186
- for (u = a[2], a = a[1], i = 0; i < 3; i++) {
187
- const m = i * 2;
188
- s[i] = Number.parseInt(a.slice(m, m + 2), 16);
189
- }
190
- u && (s[3] = Number.parseInt(u, 16) / 255);
191
- } else if (a = e.match(t)) {
192
- for (a = a[1], u = a[3], i = 0; i < 3; i++)
193
- s[i] = Number.parseInt(a[i] + a[i], 16);
194
- u && (s[3] = Number.parseInt(u + u, 16) / 255);
195
- } else if (a = e.match(r)) {
196
- for (i = 0; i < 3; i++)
197
- s[i] = Number.parseInt(a[i + 1], 10);
198
- a[4] && (s[3] = a[5] ? Number.parseFloat(a[4]) * 0.01 : Number.parseFloat(a[4]));
199
- } else if (a = e.match(o)) {
200
- for (i = 0; i < 3; i++)
201
- s[i] = Math.round(Number.parseFloat(a[i + 1]) * 2.55);
202
- a[4] && (s[3] = a[5] ? Number.parseFloat(a[4]) * 0.01 : Number.parseFloat(a[4]));
203
- } else return (a = e.match(l)) ? a[1] === "transparent" ? [0, 0, 0, 0] : Object.hasOwn(w, a[1]) ? (s = w[a[1]], s[3] = 1, s) : null : null;
204
- for (i = 0; i < 3; i++)
205
- s[i] = k(s[i], 0, 255);
206
- return s[3] = k(s[3], 0, 1), s;
207
- };
208
- d.get.hsl = function(e) {
209
- if (!e)
210
- return null;
211
- const t = /^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 = e.match(t);
212
- if (n) {
213
- const r = Number.parseFloat(n[4]), o = (Number.parseFloat(n[1]) % 360 + 360) % 360, l = k(Number.parseFloat(n[2]), 0, 100), s = k(Number.parseFloat(n[3]), 0, 100), a = k(Number.isNaN(r) ? 1 : r, 0, 1);
214
- return [o, l, s, a];
215
- }
216
- return null;
217
- };
218
- d.get.hwb = function(e) {
219
- if (!e)
220
- return null;
221
- const t = /^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 = e.match(t);
222
- if (n) {
223
- const r = Number.parseFloat(n[4]), o = (Number.parseFloat(n[1]) % 360 + 360) % 360, l = k(Number.parseFloat(n[2]), 0, 100), s = k(Number.parseFloat(n[3]), 0, 100), a = k(Number.isNaN(r) ? 1 : r, 0, 1);
224
- return [o, l, s, a];
225
- }
226
- return null;
227
- };
228
- d.to.hex = function(...e) {
229
- return "#" + x(e[0]) + x(e[1]) + x(e[2]) + (e[3] < 1 ? x(Math.round(e[3] * 255)) : "");
230
- };
231
- d.to.rgb = function(...e) {
232
- return e.length < 4 || e[3] === 1 ? "rgb(" + Math.round(e[0]) + ", " + Math.round(e[1]) + ", " + Math.round(e[2]) + ")" : "rgba(" + Math.round(e[0]) + ", " + Math.round(e[1]) + ", " + Math.round(e[2]) + ", " + e[3] + ")";
233
- };
234
- d.to.rgb.percent = function(...e) {
235
- const t = Math.round(e[0] / 255 * 100), n = Math.round(e[1] / 255 * 100), r = Math.round(e[2] / 255 * 100);
236
- return e.length < 4 || e[3] === 1 ? "rgb(" + t + "%, " + n + "%, " + r + "%)" : "rgba(" + t + "%, " + n + "%, " + r + "%, " + e[3] + ")";
237
- };
238
- d.to.hsl = function(...e) {
239
- return e.length < 4 || e[3] === 1 ? "hsl(" + e[0] + ", " + e[1] + "%, " + e[2] + "%)" : "hsla(" + e[0] + ", " + e[1] + "%, " + e[2] + "%, " + e[3] + ")";
240
- };
241
- d.to.hwb = function(...e) {
242
- let t = "";
243
- return e.length >= 4 && e[3] !== 1 && (t = ", " + e[3]), "hwb(" + e[0] + ", " + e[1] + "%, " + e[2] + "%" + t + ")";
244
- };
245
- d.to.keyword = function(...e) {
246
- return O[e.slice(0, 3)];
247
- };
248
- function k(e, t, n) {
249
- return Math.min(Math.max(t, e), n);
250
- }
251
- function x(e) {
252
- const t = Math.round(e).toString(16).toUpperCase();
253
- return t.length < 2 ? "0" + t : t;
254
- }
255
- const M = {
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
- }, q = {};
405
- for (const e of Object.keys(M))
406
- q[M[e]] = e;
407
- const c = {
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
- lch: { channels: 3, labels: "lch" },
416
- hex: { channels: 1, labels: ["hex"] },
417
- keyword: { channels: 1, labels: ["keyword"] },
418
- ansi16: { channels: 1, labels: ["ansi16"] },
419
- ansi256: { channels: 1, labels: ["ansi256"] },
420
- hcg: { channels: 3, labels: ["h", "c", "g"] },
421
- apple: { channels: 3, labels: ["r16", "g16", "b16"] },
422
- gray: { channels: 1, labels: ["gray"] }
423
- }, y = (6 / 29) ** 3;
424
- for (const e of Object.keys(c)) {
425
- if (!("channels" in c[e]))
426
- throw new Error("missing channels property: " + e);
427
- if (!("labels" in c[e]))
428
- throw new Error("missing channel labels property: " + e);
429
- if (c[e].labels.length !== c[e].channels)
430
- throw new Error("channel and label counts mismatch: " + e);
431
- const { channels: t, labels: n } = c[e];
432
- delete c[e].channels, delete c[e].labels, Object.defineProperty(c[e], "channels", { value: t }), Object.defineProperty(c[e], "labels", { value: n });
433
- }
434
- c.rgb.hsl = function(e) {
435
- const t = e[0] / 255, n = e[1] / 255, r = e[2] / 255, o = Math.min(t, n, r), l = Math.max(t, n, r), s = l - o;
436
- let a, i;
437
- switch (l) {
438
- case o: {
439
- a = 0;
440
- break;
441
- }
442
- case t: {
443
- a = (n - r) / s;
444
- break;
445
- }
446
- case n: {
447
- a = 2 + (r - t) / s;
448
- break;
449
- }
450
- case r: {
451
- a = 4 + (t - n) / s;
452
- break;
453
- }
454
- }
455
- a = Math.min(a * 60, 360), a < 0 && (a += 360);
456
- const u = (o + l) / 2;
457
- return l === o ? i = 0 : u <= 0.5 ? i = s / (l + o) : i = s / (2 - l - o), [a, i * 100, u * 100];
458
- };
459
- c.rgb.hsv = function(e) {
460
- let t, n, r, o, l;
461
- const s = e[0] / 255, a = e[1] / 255, i = e[2] / 255, u = Math.max(s, a, i), m = u - Math.min(s, a, i), p = function(z) {
462
- return (u - z) / 6 / m + 1 / 2;
463
- };
464
- if (m === 0)
465
- o = 0, l = 0;
466
- else {
467
- switch (l = m / u, t = p(s), n = p(a), r = p(i), u) {
468
- case s: {
469
- o = r - n;
470
- break;
471
- }
472
- case a: {
473
- o = 1 / 3 + t - r;
474
- break;
475
- }
476
- case i: {
477
- o = 2 / 3 + n - t;
478
- break;
479
- }
480
- }
481
- o < 0 ? o += 1 : o > 1 && (o -= 1);
482
- }
483
- return [
484
- o * 360,
485
- l * 100,
486
- u * 100
487
- ];
488
- };
489
- c.rgb.hwb = function(e) {
490
- const t = e[0], n = e[1];
491
- let r = e[2];
492
- const o = c.rgb.hsl(e)[0], l = 1 / 255 * Math.min(t, Math.min(n, r));
493
- return r = 1 - 1 / 255 * Math.max(t, Math.max(n, r)), [o, l * 100, r * 100];
494
- };
495
- c.rgb.cmyk = function(e) {
496
- const t = e[0] / 255, n = e[1] / 255, r = e[2] / 255, o = Math.min(1 - t, 1 - n, 1 - r), l = (1 - t - o) / (1 - o) || 0, s = (1 - n - o) / (1 - o) || 0, a = (1 - r - o) / (1 - o) || 0;
497
- return [l * 100, s * 100, a * 100, o * 100];
498
- };
499
- function S(e, t) {
500
- return (e[0] - t[0]) ** 2 + (e[1] - t[1]) ** 2 + (e[2] - t[2]) ** 2;
501
- }
502
- c.rgb.keyword = function(e) {
503
- const t = q[e];
504
- if (t)
505
- return t;
506
- let n = Number.POSITIVE_INFINITY, r;
507
- for (const o of Object.keys(M)) {
508
- const l = M[o], s = S(e, l);
509
- s < n && (n = s, r = o);
510
- }
511
- return r;
512
- };
513
- c.keyword.rgb = function(e) {
514
- return M[e];
515
- };
516
- c.rgb.xyz = function(e) {
517
- let t = e[0] / 255, n = e[1] / 255, r = e[2] / 255;
518
- t = t > 0.04045 ? ((t + 0.055) / 1.055) ** 2.4 : t / 12.92, n = n > 0.04045 ? ((n + 0.055) / 1.055) ** 2.4 : n / 12.92, r = r > 0.04045 ? ((r + 0.055) / 1.055) ** 2.4 : r / 12.92;
519
- const o = t * 0.4124564 + n * 0.3575761 + r * 0.1804375, l = t * 0.2126729 + n * 0.7151522 + r * 0.072175, s = t * 0.0193339 + n * 0.119192 + r * 0.9503041;
520
- return [o * 100, l * 100, s * 100];
521
- };
522
- c.rgb.lab = function(e) {
523
- const t = c.rgb.xyz(e);
524
- let n = t[0], r = t[1], o = t[2];
525
- n /= 95.047, r /= 100, o /= 108.883, n = n > y ? n ** (1 / 3) : 7.787 * n + 16 / 116, r = r > y ? r ** (1 / 3) : 7.787 * r + 16 / 116, o = o > y ? o ** (1 / 3) : 7.787 * o + 16 / 116;
526
- const l = 116 * r - 16, s = 500 * (n - r), a = 200 * (r - o);
527
- return [l, s, a];
528
- };
529
- c.hsl.rgb = function(e) {
530
- const t = e[0] / 360, n = e[1] / 100, r = e[2] / 100;
531
- let o, l;
532
- if (n === 0)
533
- return l = r * 255, [l, l, l];
534
- const s = r < 0.5 ? r * (1 + n) : r + n - r * n, a = 2 * r - s, i = [0, 0, 0];
535
- for (let u = 0; u < 3; u++)
536
- o = t + 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, i[u] = l * 255;
537
- return i;
538
- };
539
- c.hsl.hsv = function(e) {
540
- const t = e[0];
541
- let n = e[1] / 100, r = e[2] / 100, o = n;
542
- const l = Math.max(r, 0.01);
543
- r *= 2, n *= r <= 1 ? r : 2 - r, o *= l <= 1 ? l : 2 - l;
544
- const s = (r + n) / 2, a = r === 0 ? 2 * o / (l + o) : 2 * n / (r + n);
545
- return [t, a * 100, s * 100];
546
- };
547
- c.hsv.rgb = function(e) {
548
- const t = e[0] / 60, n = e[1] / 100;
549
- let r = e[2] / 100;
550
- const o = Math.floor(t) % 6, l = t - Math.floor(t), s = 255 * r * (1 - n), a = 255 * r * (1 - n * l), i = 255 * r * (1 - n * (1 - l));
551
- switch (r *= 255, o) {
552
- case 0:
553
- return [r, i, s];
554
- case 1:
555
- return [a, r, s];
556
- case 2:
557
- return [s, r, i];
558
- case 3:
559
- return [s, a, r];
560
- case 4:
561
- return [i, s, r];
562
- case 5:
563
- return [r, s, a];
564
- }
565
- };
566
- c.hsv.hsl = function(e) {
567
- const t = e[0], n = e[1] / 100, r = e[2] / 100, o = Math.max(r, 0.01);
568
- let l, s;
569
- s = (2 - n) * r;
570
- const a = (2 - n) * o;
571
- return l = n * o, l /= a <= 1 ? a : 2 - a, l = l || 0, s /= 2, [t, l * 100, s * 100];
572
- };
573
- c.hwb.rgb = function(e) {
574
- const t = e[0] / 360;
575
- let n = e[1] / 100, r = e[2] / 100;
576
- const o = n + r;
577
- let l;
578
- o > 1 && (n /= o, r /= o);
579
- const s = Math.floor(6 * t), a = 1 - r;
580
- l = 6 * t - s, (s & 1) !== 0 && (l = 1 - l);
581
- const i = n + l * (a - n);
582
- let u, m, p;
583
- switch (s) {
584
- default:
585
- case 6:
586
- case 0: {
587
- u = a, m = i, p = n;
588
- break;
589
- }
590
- case 1: {
591
- u = i, m = a, p = n;
592
- break;
593
- }
594
- case 2: {
595
- u = n, m = a, p = i;
596
- break;
597
- }
598
- case 3: {
599
- u = n, m = i, p = a;
600
- break;
601
- }
602
- case 4: {
603
- u = i, m = n, p = a;
604
- break;
605
- }
606
- case 5: {
607
- u = a, m = n, p = i;
608
- break;
609
- }
610
- }
611
- return [u * 255, m * 255, p * 255];
612
- };
613
- c.cmyk.rgb = function(e) {
614
- const t = e[0] / 100, n = e[1] / 100, r = e[2] / 100, o = e[3] / 100, l = 1 - Math.min(1, t * (1 - o) + o), s = 1 - Math.min(1, n * (1 - o) + o), a = 1 - Math.min(1, r * (1 - o) + o);
615
- return [l * 255, s * 255, a * 255];
616
- };
617
- c.xyz.rgb = function(e) {
618
- const t = e[0] / 100, n = e[1] / 100, r = e[2] / 100;
619
- let o, l, s;
620
- return o = t * 3.2404542 + n * -1.5371385 + r * -0.4985314, l = t * -0.969266 + n * 1.8760108 + r * 0.041556, s = t * 0.0556434 + n * -0.2040259 + r * 1.0572252, o = o > 31308e-7 ? 1.055 * o ** (1 / 2.4) - 0.055 : o * 12.92, l = l > 31308e-7 ? 1.055 * l ** (1 / 2.4) - 0.055 : l * 12.92, s = s > 31308e-7 ? 1.055 * s ** (1 / 2.4) - 0.055 : s * 12.92, o = Math.min(Math.max(0, o), 1), l = Math.min(Math.max(0, l), 1), s = Math.min(Math.max(0, s), 1), [o * 255, l * 255, s * 255];
621
- };
622
- c.xyz.lab = function(e) {
623
- let t = e[0], n = e[1], r = e[2];
624
- t /= 95.047, n /= 100, r /= 108.883, t = t > y ? t ** (1 / 3) : 7.787 * t + 16 / 116, n = n > y ? n ** (1 / 3) : 7.787 * n + 16 / 116, r = r > y ? r ** (1 / 3) : 7.787 * r + 16 / 116;
625
- const o = 116 * n - 16, l = 500 * (t - n), s = 200 * (n - r);
626
- return [o, l, s];
627
- };
628
- c.lab.xyz = function(e) {
629
- const t = e[0], n = e[1], r = e[2];
630
- let o, l, s;
631
- l = (t + 16) / 116, o = n / 500 + l, s = l - r / 200;
632
- const a = l ** 3, i = o ** 3, u = s ** 3;
633
- return l = a > y ? a : (l - 16 / 116) / 7.787, o = i > y ? i : (o - 16 / 116) / 7.787, s = u > y ? u : (s - 16 / 116) / 7.787, o *= 95.047, l *= 100, s *= 108.883, [o, l, s];
634
- };
635
- c.lab.lch = function(e) {
636
- const t = e[0], n = e[1], r = e[2];
637
- let o;
638
- o = Math.atan2(r, n) * 360 / 2 / Math.PI, o < 0 && (o += 360);
639
- const s = Math.sqrt(n * n + r * r);
640
- return [t, s, o];
641
- };
642
- c.lch.lab = function(e) {
643
- const t = e[0], n = e[1], o = e[2] / 360 * 2 * Math.PI, l = n * Math.cos(o), s = n * Math.sin(o);
644
- return [t, l, s];
645
- };
646
- c.rgb.ansi16 = function(e, t = null) {
647
- const [n, r, o] = e;
648
- let l = t === null ? c.rgb.hsv(e)[2] : t;
649
- if (l = Math.round(l / 50), l === 0)
650
- return 30;
651
- let s = 30 + (Math.round(o / 255) << 2 | Math.round(r / 255) << 1 | Math.round(n / 255));
652
- return l === 2 && (s += 60), s;
653
- };
654
- c.hsv.ansi16 = function(e) {
655
- return c.rgb.ansi16(c.hsv.rgb(e), e[2]);
656
- };
657
- c.rgb.ansi256 = function(e) {
658
- const t = e[0], n = e[1], r = e[2];
659
- return t >> 4 === n >> 4 && n >> 4 === r >> 4 ? t < 8 ? 16 : t > 248 ? 231 : Math.round((t - 8) / 247 * 24) + 232 : 16 + 36 * Math.round(t / 255 * 5) + 6 * Math.round(n / 255 * 5) + Math.round(r / 255 * 5);
660
- };
661
- c.ansi16.rgb = function(e) {
662
- e = e[0];
663
- let t = e % 10;
664
- if (t === 0 || t === 7)
665
- return e > 50 && (t += 3.5), t = t / 10.5 * 255, [t, t, t];
666
- const n = (Math.trunc(e > 50) + 1) * 0.5, r = (t & 1) * n * 255, o = (t >> 1 & 1) * n * 255, l = (t >> 2 & 1) * n * 255;
667
- return [r, o, l];
668
- };
669
- c.ansi256.rgb = function(e) {
670
- if (e = e[0], e >= 232) {
671
- const l = (e - 232) * 10 + 8;
672
- return [l, l, l];
673
- }
674
- e -= 16;
675
- let t;
676
- const n = Math.floor(e / 36) / 5 * 255, r = Math.floor((t = e % 36) / 6) / 5 * 255, o = t % 6 / 5 * 255;
677
- return [n, r, o];
678
- };
679
- c.rgb.hex = function(e) {
680
- const n = (((Math.round(e[0]) & 255) << 16) + ((Math.round(e[1]) & 255) << 8) + (Math.round(e[2]) & 255)).toString(16).toUpperCase();
681
- return "000000".slice(n.length) + n;
682
- };
683
- c.hex.rgb = function(e) {
684
- const t = e.toString(16).match(/[a-f\d]{6}|[a-f\d]{3}/i);
685
- if (!t)
686
- return [0, 0, 0];
687
- let n = t[0];
688
- t[0].length === 3 && (n = [...n].map((a) => a + a).join(""));
689
- const r = Number.parseInt(n, 16), o = r >> 16 & 255, l = r >> 8 & 255, s = r & 255;
690
- return [o, l, s];
691
- };
692
- c.rgb.hcg = function(e) {
693
- const t = e[0] / 255, n = e[1] / 255, r = e[2] / 255, o = Math.max(Math.max(t, n), r), l = Math.min(Math.min(t, n), r), s = o - l;
694
- let a;
695
- const i = s < 1 ? l / (1 - s) : 0;
696
- return s <= 0 ? a = 0 : o === t ? a = (n - r) / s % 6 : o === n ? a = 2 + (r - t) / s : a = 4 + (t - n) / s, a /= 6, a %= 1, [a * 360, s * 100, i * 100];
697
- };
698
- c.hsl.hcg = function(e) {
699
- const t = e[1] / 100, n = e[2] / 100, r = n < 0.5 ? 2 * t * n : 2 * t * (1 - n);
700
- let o = 0;
701
- return r < 1 && (o = (n - 0.5 * r) / (1 - r)), [e[0], r * 100, o * 100];
702
- };
703
- c.hsv.hcg = function(e) {
704
- const t = e[1] / 100, n = e[2] / 100, r = t * n;
705
- let o = 0;
706
- return r < 1 && (o = (n - r) / (1 - r)), [e[0], r * 100, o * 100];
707
- };
708
- c.hcg.rgb = function(e) {
709
- const t = e[0] / 360, n = e[1] / 100, r = e[2] / 100;
710
- if (n === 0)
711
- return [r * 255, r * 255, r * 255];
712
- const o = [0, 0, 0], l = t % 1 * 6, s = l % 1, a = 1 - s;
713
- let i = 0;
714
- switch (Math.floor(l)) {
715
- case 0: {
716
- o[0] = 1, o[1] = s, o[2] = 0;
717
- break;
718
- }
719
- case 1: {
720
- o[0] = a, o[1] = 1, o[2] = 0;
721
- break;
722
- }
723
- case 2: {
724
- o[0] = 0, o[1] = 1, o[2] = s;
725
- break;
726
- }
727
- case 3: {
728
- o[0] = 0, o[1] = a, o[2] = 1;
729
- break;
730
- }
731
- case 4: {
732
- o[0] = s, o[1] = 0, o[2] = 1;
733
- break;
734
- }
735
- default:
736
- o[0] = 1, o[1] = 0, o[2] = a;
737
- }
738
- return i = (1 - n) * r, [
739
- (n * o[0] + i) * 255,
740
- (n * o[1] + i) * 255,
741
- (n * o[2] + i) * 255
742
- ];
743
- };
744
- c.hcg.hsv = function(e) {
745
- const t = e[1] / 100, n = e[2] / 100, r = t + n * (1 - t);
746
- let o = 0;
747
- return r > 0 && (o = t / r), [e[0], o * 100, r * 100];
748
- };
749
- c.hcg.hsl = function(e) {
750
- const t = e[1] / 100, r = e[2] / 100 * (1 - t) + 0.5 * t;
751
- let o = 0;
752
- return r > 0 && r < 0.5 ? o = t / (2 * r) : r >= 0.5 && r < 1 && (o = t / (2 * (1 - r))), [e[0], o * 100, r * 100];
753
- };
754
- c.hcg.hwb = function(e) {
755
- const t = e[1] / 100, n = e[2] / 100, r = t + n * (1 - t);
756
- return [e[0], (r - t) * 100, (1 - r) * 100];
757
- };
758
- c.hwb.hcg = function(e) {
759
- const t = e[1] / 100, r = 1 - e[2] / 100, o = r - t;
760
- let l = 0;
761
- return o < 1 && (l = (r - o) / (1 - o)), [e[0], o * 100, l * 100];
762
- };
763
- c.apple.rgb = function(e) {
764
- return [e[0] / 65535 * 255, e[1] / 65535 * 255, e[2] / 65535 * 255];
765
- };
766
- c.rgb.apple = function(e) {
767
- return [e[0] / 255 * 65535, e[1] / 255 * 65535, e[2] / 255 * 65535];
768
- };
769
- c.gray.rgb = function(e) {
770
- return [e[0] / 100 * 255, e[0] / 100 * 255, e[0] / 100 * 255];
771
- };
772
- c.gray.hsl = function(e) {
773
- return [0, 0, e[0]];
774
- };
775
- c.gray.hsv = c.gray.hsl;
776
- c.gray.hwb = function(e) {
777
- return [0, 100, e[0]];
778
- };
779
- c.gray.cmyk = function(e) {
780
- return [0, 0, 0, e[0]];
781
- };
782
- c.gray.lab = function(e) {
783
- return [e[0], 0, 0];
784
- };
785
- c.gray.hex = function(e) {
786
- const t = Math.round(e[0] / 100 * 255) & 255, r = ((t << 16) + (t << 8) + t).toString(16).toUpperCase();
787
- return "000000".slice(r.length) + r;
788
- };
789
- c.rgb.gray = function(e) {
790
- return [(e[0] + e[1] + e[2]) / 3 / 255 * 100];
791
- };
792
- function I() {
793
- const e = {}, t = Object.keys(c);
794
- for (let { length: n } = t, r = 0; r < n; r++)
795
- e[t[r]] = {
796
- // http://jsperf.com/1-vs-infinity
797
- // micro-opt, but this is simple.
798
- distance: -1,
799
- parent: null
800
- };
801
- return e;
802
- }
803
- function j(e) {
804
- const t = I(), n = [e];
805
- for (t[e].distance = 0; n.length > 0; ) {
806
- const r = n.pop(), o = Object.keys(c[r]);
807
- for (let { length: l } = o, s = 0; s < l; s++) {
808
- const a = o[s], i = t[a];
809
- i.distance === -1 && (i.distance = t[r].distance + 1, i.parent = r, n.unshift(a));
810
- }
811
- }
812
- return t;
813
- }
814
- function E(e, t) {
815
- return function(n) {
816
- return t(e(n));
817
- };
818
- }
819
- function $(e, t) {
820
- const n = [t[e].parent, e];
821
- let r = c[t[e].parent][e], o = t[e].parent;
822
- for (; t[o].parent; )
823
- n.unshift(t[o].parent), r = E(c[t[o].parent][o], r), o = t[o].parent;
824
- return r.conversion = n, r;
825
- }
826
- function T(e) {
827
- const t = j(e), n = {}, r = Object.keys(t);
828
- for (let { length: o } = r, l = 0; l < o; l++) {
829
- const s = r[l];
830
- t[s].parent !== null && (n[s] = $(s, t));
831
- }
832
- return n;
833
- }
834
- const g = {}, U = Object.keys(c);
835
- function D(e) {
836
- const t = function(...n) {
837
- const r = n[0];
838
- return r == null ? r : (r.length > 1 && (n = r), e(n));
839
- };
840
- return "conversion" in e && (t.conversion = e.conversion), t;
841
- }
842
- function K(e) {
843
- const t = function(...n) {
844
- const r = n[0];
845
- if (r == null)
846
- return r;
847
- r.length > 1 && (n = r);
848
- const o = e(n);
849
- if (typeof o == "object")
850
- for (let { length: l } = o, s = 0; s < l; s++)
851
- o[s] = Math.round(o[s]);
852
- return o;
853
- };
854
- return "conversion" in e && (t.conversion = e.conversion), t;
855
- }
856
- for (const e of U) {
857
- g[e] = {}, Object.defineProperty(g[e], "channels", { value: c[e].channels }), Object.defineProperty(g[e], "labels", { value: c[e].labels });
858
- const t = T(e), n = Object.keys(t);
859
- for (const r of n) {
860
- const o = t[r];
861
- g[e][r] = K(o), g[e][r].raw = D(o);
862
- }
863
- }
864
- const C = [
865
- // To be honest, I don't really feel like keyword belongs in color convert, but eh.
866
- "keyword",
867
- // Gray conflicts with some method names, and has its own method defined.
868
- "gray",
869
- // Shouldn't really be in color-convert either...
870
- "hex"
871
- ], F = {};
872
- for (const e of Object.keys(g))
873
- F[[...g[e].labels].sort().join("")] = e;
874
- const v = {};
875
- function b(e, t) {
876
- if (!(this instanceof b))
877
- return new b(e, t);
878
- if (t && t in C && (t = null), t && !(t in g))
879
- throw new Error("Unknown model: " + t);
880
- let n, r;
881
- if (e == null)
882
- this.model = "rgb", this.color = [0, 0, 0], this.valpha = 1;
883
- else if (e instanceof b)
884
- this.model = e.model, this.color = [...e.color], this.valpha = e.valpha;
885
- else if (typeof e == "string") {
886
- const o = d.get(e);
887
- if (o === null)
888
- throw new Error("Unable to parse color from string: " + e);
889
- 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;
890
- } else if (e.length > 0) {
891
- this.model = t || "rgb", r = g[this.model].channels;
892
- const o = Array.prototype.slice.call(e, 0, r);
893
- this.color = N(o, r), this.valpha = typeof e[r] == "number" ? e[r] : 1;
894
- } else if (typeof e == "number")
895
- this.model = "rgb", this.color = [
896
- e >> 16 & 255,
897
- e >> 8 & 255,
898
- e & 255
899
- ], this.valpha = 1;
900
- else {
901
- this.valpha = 1;
902
- const o = Object.keys(e);
903
- "alpha" in e && (o.splice(o.indexOf("alpha"), 1), this.valpha = typeof e.alpha == "number" ? e.alpha : 0);
904
- const l = o.sort().join("");
905
- if (!(l in F))
906
- throw new Error("Unable to parse color from object: " + JSON.stringify(e));
907
- this.model = F[l];
908
- const { labels: s } = g[this.model], a = [];
909
- for (n = 0; n < s.length; n++)
910
- a.push(e[s[n]]);
911
- this.color = N(a);
912
- }
913
- if (v[this.model])
914
- for (r = g[this.model].channels, n = 0; n < r; n++) {
915
- const o = v[this.model][n];
916
- o && (this.color[n] = o(this.color[n]));
917
- }
918
- this.valpha = Math.max(0, Math.min(1, this.valpha)), Object.freeze && Object.freeze(this);
919
- }
920
- b.prototype = {
921
- toString() {
922
- return this.string();
923
- },
924
- toJSON() {
925
- return this[this.model]();
926
- },
927
- string(e) {
928
- let t = this.model in d.to ? this : this.rgb();
929
- t = t.round(typeof e == "number" ? e : 1);
930
- const n = t.valpha === 1 ? t.color : [...t.color, this.valpha];
931
- return d.to[t.model](...n);
932
- },
933
- percentString(e) {
934
- const t = this.rgb().round(typeof e == "number" ? e : 1), n = t.valpha === 1 ? t.color : [...t.color, this.valpha];
935
- return d.to.rgb.percent(...n);
936
- },
937
- array() {
938
- return this.valpha === 1 ? [...this.color] : [...this.color, this.valpha];
939
- },
940
- object() {
941
- const e = {}, { channels: t } = g[this.model], { labels: n } = g[this.model];
942
- for (let r = 0; r < t; r++)
943
- e[n[r]] = this.color[r];
944
- return this.valpha !== 1 && (e.alpha = this.valpha), e;
945
- },
946
- unitArray() {
947
- const e = this.rgb().color;
948
- return e[0] /= 255, e[1] /= 255, e[2] /= 255, this.valpha !== 1 && e.push(this.valpha), e;
949
- },
950
- unitObject() {
951
- const e = this.rgb().object();
952
- return e.r /= 255, e.g /= 255, e.b /= 255, this.valpha !== 1 && (e.alpha = this.valpha), e;
953
- },
954
- round(e) {
955
- return e = Math.max(e || 0, 0), new b([...this.color.map(V(e)), this.valpha], this.model);
956
- },
957
- alpha(e) {
958
- return e !== void 0 ? new b([...this.color, Math.max(0, Math.min(1, e))], this.model) : this.valpha;
959
- },
960
- // Rgb
961
- red: h("rgb", 0, f(255)),
962
- green: h("rgb", 1, f(255)),
963
- blue: h("rgb", 2, f(255)),
964
- hue: h(["hsl", "hsv", "hsl", "hwb", "hcg"], 0, (e) => (e % 360 + 360) % 360),
965
- saturationl: h("hsl", 1, f(100)),
966
- lightness: h("hsl", 2, f(100)),
967
- saturationv: h("hsv", 1, f(100)),
968
- value: h("hsv", 2, f(100)),
969
- chroma: h("hcg", 1, f(100)),
970
- gray: h("hcg", 2, f(100)),
971
- white: h("hwb", 1, f(100)),
972
- wblack: h("hwb", 2, f(100)),
973
- cyan: h("cmyk", 0, f(100)),
974
- magenta: h("cmyk", 1, f(100)),
975
- yellow: h("cmyk", 2, f(100)),
976
- black: h("cmyk", 3, f(100)),
977
- x: h("xyz", 0, f(95.047)),
978
- y: h("xyz", 1, f(100)),
979
- z: h("xyz", 2, f(108.833)),
980
- l: h("lab", 0, f(100)),
981
- a: h("lab", 1),
982
- b: h("lab", 2),
983
- keyword(e) {
984
- return e !== void 0 ? new b(e) : g[this.model].keyword(this.color);
985
- },
986
- hex(e) {
987
- return e !== void 0 ? new b(e) : d.to.hex(...this.rgb().round().color);
988
- },
989
- hexa(e) {
990
- if (e !== void 0)
991
- return new b(e);
992
- const t = this.rgb().round().color;
993
- let n = Math.round(this.valpha * 255).toString(16).toUpperCase();
994
- return n.length === 1 && (n = "0" + n), d.to.hex(...t) + n;
995
- },
996
- rgbNumber() {
997
- const e = this.rgb().color;
998
- return (e[0] & 255) << 16 | (e[1] & 255) << 8 | e[2] & 255;
999
- },
1000
- luminosity() {
1001
- const e = this.rgb().color, t = [];
1002
- for (const [n, r] of e.entries()) {
1003
- const o = r / 255;
1004
- t[n] = o <= 0.04045 ? o / 12.92 : ((o + 0.055) / 1.055) ** 2.4;
1005
- }
1006
- return 0.2126 * t[0] + 0.7152 * t[1] + 0.0722 * t[2];
1007
- },
1008
- contrast(e) {
1009
- const t = this.luminosity(), n = e.luminosity();
1010
- return t > n ? (t + 0.05) / (n + 0.05) : (n + 0.05) / (t + 0.05);
1011
- },
1012
- level(e) {
1013
- const t = this.contrast(e);
1014
- return t >= 7 ? "AAA" : t >= 4.5 ? "AA" : "";
1015
- },
1016
- isDark() {
1017
- const e = this.rgb().color;
1018
- return (e[0] * 2126 + e[1] * 7152 + e[2] * 722) / 1e4 < 128;
1019
- },
1020
- isLight() {
1021
- return !this.isDark();
1022
- },
1023
- negate() {
1024
- const e = this.rgb();
1025
- for (let t = 0; t < 3; t++)
1026
- e.color[t] = 255 - e.color[t];
1027
- return e;
1028
- },
1029
- lighten(e) {
1030
- const t = this.hsl();
1031
- return t.color[2] += t.color[2] * e, t;
1032
- },
1033
- darken(e) {
1034
- const t = this.hsl();
1035
- return t.color[2] -= t.color[2] * e, t;
1036
- },
1037
- saturate(e) {
1038
- const t = this.hsl();
1039
- return t.color[1] += t.color[1] * e, t;
1040
- },
1041
- desaturate(e) {
1042
- const t = this.hsl();
1043
- return t.color[1] -= t.color[1] * e, t;
1044
- },
1045
- whiten(e) {
1046
- const t = this.hwb();
1047
- return t.color[1] += t.color[1] * e, t;
1048
- },
1049
- blacken(e) {
1050
- const t = this.hwb();
1051
- return t.color[2] += t.color[2] * e, t;
1052
- },
1053
- grayscale() {
1054
- const e = this.rgb().color, t = e[0] * 0.3 + e[1] * 0.59 + e[2] * 0.11;
1055
- return b.rgb(t, t, t);
1056
- },
1057
- fade(e) {
1058
- return this.alpha(this.valpha - this.valpha * e);
1059
- },
1060
- opaquer(e) {
1061
- return this.alpha(this.valpha + this.valpha * e);
1062
- },
1063
- rotate(e) {
1064
- const t = this.hsl();
1065
- let n = t.color[0];
1066
- return n = (n + e) % 360, n = n < 0 ? 360 + n : n, t.color[0] = n, t;
1067
- },
1068
- mix(e, t) {
1069
- if (!e || !e.rgb)
1070
- throw new Error('Argument to "mix" was not a Color instance, but rather an instance of ' + typeof e);
1071
- const n = e.rgb(), r = this.rgb(), o = t === void 0 ? 0.5 : t, l = 2 * o - 1, s = n.alpha() - r.alpha(), a = ((l * s === -1 ? l : (l + s) / (1 + l * s)) + 1) / 2, i = 1 - a;
1072
- return b.rgb(
1073
- a * n.red() + i * r.red(),
1074
- a * n.green() + i * r.green(),
1075
- a * n.blue() + i * r.blue(),
1076
- n.alpha() * o + r.alpha() * (1 - o)
1077
- );
1078
- }
1079
- };
1080
- for (const e of Object.keys(g)) {
1081
- if (C.includes(e))
1082
- continue;
1083
- const { channels: t } = g[e];
1084
- b.prototype[e] = function(...n) {
1085
- return this.model === e ? new b(this) : n.length > 0 ? new b(n, e) : new b([...L(g[this.model][e].raw(this.color)), this.valpha], e);
1086
- }, b[e] = function(...n) {
1087
- let r = n[0];
1088
- return typeof r == "number" && (r = N(n, t)), new b(r, e);
1089
- };
1090
- }
1091
- function B(e, t) {
1092
- return Number(e.toFixed(t));
1093
- }
1094
- function V(e) {
1095
- return function(t) {
1096
- return B(t, e);
1097
- };
1098
- }
1099
- function h(e, t, n) {
1100
- e = Array.isArray(e) ? e : [e];
1101
- for (const r of e)
1102
- (v[r] || (v[r] = []))[t] = n;
1103
- return e = e[0], function(r) {
1104
- let o;
1105
- return r !== void 0 ? (n && (r = n(r)), o = this[e](), o.color[t] = r, o) : (o = this[e]().color[t], n && (o = n(o)), o);
1106
- };
1107
- }
1108
- function f(e) {
1109
- return function(t) {
1110
- return Math.max(0, Math.min(e, t));
1111
- };
1112
- }
1113
- function L(e) {
1114
- return Array.isArray(e) ? e : [e];
1115
- }
1116
- function N(e, t) {
1117
- for (let n = 0; n < t; n++)
1118
- typeof e[n] != "number" && (e[n] = 0);
1119
- return e;
1120
- }
1121
- class R {
1122
- constructor(t) {
1123
- _(this, "isColor", !0);
1124
- _(this, "currentColor");
1125
- this.base = t;
1126
- const n = this._resolveBaseColor(t);
1127
- return this.currentColor = b(n), this._createProxy();
1128
- }
1129
- _createProxy() {
1130
- return new Proxy(this, {
1131
- get(t, n) {
1132
- return n in t ? t[n] : n in t.currentColor ? t._handleColorMethod(n) : t[n];
1133
- }
1134
- });
1135
- }
1136
- _resolveBaseColor(t) {
1137
- if (typeof t != "string" || !/\{[^{}]+\}/g.test(t)) return t;
1138
- if (typeof saltyConfig > "u") return "transparent";
1139
- const { staticVariables: r } = saltyConfig;
1140
- return r ? t.replace(/^\{|\}$/g, "").split(".").reduce((s, a) => s[a], r) : "transparent";
1141
- }
1142
- _handleColorMethod(t) {
1143
- const n = this.currentColor;
1144
- return typeof n[t] != "function" ? n[t] : (...r) => (this.currentColor = n[t](...r), this._createProxy());
1145
- }
1146
- toString() {
1147
- return this.currentColor.toString();
1148
- }
1149
- }
1150
- const G = (e) => new R(e);
1151
- export {
1152
- G as color,
1153
- Q as defineViewportClamp
1154
- };
1
+ export * from "@salty-css/core/helpers";