@salty-css/core 0.0.1-alpha.193 → 0.0.1-alpha.195

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/index.js CHANGED
@@ -1,6 +1,6 @@
1
- var C = Object.defineProperty;
2
- var S = (e, t, n) => t in e ? C(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
- var F = (e, t, n) => S(e, typeof t != "symbol" ? t + "" : t, n);
1
+ var A = Object.defineProperty;
2
+ var S = (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) => S(e, typeof t != "symbol" ? t + "" : t, n);
4
4
  const k = {
5
5
  aliceblue: [240, 248, 255],
6
6
  antiquewhite: [250, 235, 215],
@@ -180,28 +180,28 @@ d.get.rgb = function(e) {
180
180
  if (!e)
181
181
  return null;
182
182
  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+)$/;
183
- let s = [0, 0, 0, 1], a, c, u;
183
+ let s = [0, 0, 0, 1], a, i, u;
184
184
  if (a = e.match(n)) {
185
- for (u = a[2], a = a[1], c = 0; c < 3; c++) {
186
- const m = c * 2;
187
- s[c] = Number.parseInt(a.slice(m, m + 2), 16);
185
+ for (u = a[2], a = a[1], i = 0; i < 3; i++) {
186
+ const m = i * 2;
187
+ s[i] = Number.parseInt(a.slice(m, m + 2), 16);
188
188
  }
189
189
  u && (s[3] = Number.parseInt(u, 16) / 255);
190
190
  } else if (a = e.match(t)) {
191
- for (a = a[1], u = a[3], c = 0; c < 3; c++)
192
- s[c] = Number.parseInt(a[c] + a[c], 16);
191
+ for (a = a[1], u = a[3], i = 0; i < 3; i++)
192
+ s[i] = Number.parseInt(a[i] + a[i], 16);
193
193
  u && (s[3] = Number.parseInt(u + u, 16) / 255);
194
194
  } else if (a = e.match(r)) {
195
- for (c = 0; c < 3; c++)
196
- s[c] = Number.parseInt(a[c + 1], 10);
195
+ for (i = 0; i < 3; i++)
196
+ s[i] = Number.parseInt(a[i + 1], 10);
197
197
  a[4] && (s[3] = a[5] ? Number.parseFloat(a[4]) * 0.01 : Number.parseFloat(a[4]));
198
198
  } else if (a = e.match(o)) {
199
- for (c = 0; c < 3; c++)
200
- s[c] = Math.round(Number.parseFloat(a[c + 1]) * 2.55);
199
+ for (i = 0; i < 3; i++)
200
+ s[i] = Math.round(Number.parseFloat(a[i + 1]) * 2.55);
201
201
  a[4] && (s[3] = a[5] ? Number.parseFloat(a[4]) * 0.01 : Number.parseFloat(a[4]));
202
202
  } else return (a = e.match(l)) ? a[1] === "transparent" ? [0, 0, 0, 0] : Object.hasOwn(k, a[1]) ? (s = k[a[1]], s[3] = 1, s) : null : null;
203
- for (c = 0; c < 3; c++)
204
- s[c] = w(s[c], 0, 255);
203
+ for (i = 0; i < 3; i++)
204
+ s[i] = w(s[i], 0, 255);
205
205
  return s[3] = w(s[3], 0, 1), s;
206
206
  };
207
207
  d.get.hsl = function(e) {
@@ -403,7 +403,7 @@ const M = {
403
403
  }, q = {};
404
404
  for (const e of Object.keys(M))
405
405
  q[M[e]] = e;
406
- const i = {
406
+ const c = {
407
407
  rgb: { channels: 3, labels: "rgb" },
408
408
  hsl: { channels: 3, labels: "hsl" },
409
409
  hsv: { channels: 3, labels: "hsv" },
@@ -420,19 +420,19 @@ const i = {
420
420
  apple: { channels: 3, labels: ["r16", "g16", "b16"] },
421
421
  gray: { channels: 1, labels: ["gray"] }
422
422
  }, y = (6 / 29) ** 3;
423
- for (const e of Object.keys(i)) {
424
- if (!("channels" in i[e]))
423
+ for (const e of Object.keys(c)) {
424
+ if (!("channels" in c[e]))
425
425
  throw new Error("missing channels property: " + e);
426
- if (!("labels" in i[e]))
426
+ if (!("labels" in c[e]))
427
427
  throw new Error("missing channel labels property: " + e);
428
- if (i[e].labels.length !== i[e].channels)
428
+ if (c[e].labels.length !== c[e].channels)
429
429
  throw new Error("channel and label counts mismatch: " + e);
430
- const { channels: t, labels: n } = i[e];
431
- delete i[e].channels, delete i[e].labels, Object.defineProperty(i[e], "channels", { value: t }), Object.defineProperty(i[e], "labels", { value: n });
430
+ const { channels: t, labels: n } = c[e];
431
+ delete c[e].channels, delete c[e].labels, Object.defineProperty(c[e], "channels", { value: t }), Object.defineProperty(c[e], "labels", { value: n });
432
432
  }
433
- i.rgb.hsl = function(e) {
433
+ c.rgb.hsl = function(e) {
434
434
  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;
435
- let a, c;
435
+ let a, i;
436
436
  switch (l) {
437
437
  case o: {
438
438
  a = 0;
@@ -453,17 +453,17 @@ i.rgb.hsl = function(e) {
453
453
  }
454
454
  a = Math.min(a * 60, 360), a < 0 && (a += 360);
455
455
  const u = (o + l) / 2;
456
- return l === o ? c = 0 : u <= 0.5 ? c = s / (l + o) : c = s / (2 - l - o), [a, c * 100, u * 100];
456
+ return l === o ? i = 0 : u <= 0.5 ? i = s / (l + o) : i = s / (2 - l - o), [a, i * 100, u * 100];
457
457
  };
458
- i.rgb.hsv = function(e) {
458
+ c.rgb.hsv = function(e) {
459
459
  let t, n, r, o, l;
460
- const s = e[0] / 255, a = e[1] / 255, c = e[2] / 255, u = Math.max(s, a, c), m = u - Math.min(s, a, c), p = function(A) {
461
- return (u - A) / 6 / m + 1 / 2;
460
+ 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(C) {
461
+ return (u - C) / 6 / m + 1 / 2;
462
462
  };
463
463
  if (m === 0)
464
464
  o = 0, l = 0;
465
465
  else {
466
- switch (l = m / u, t = p(s), n = p(a), r = p(c), u) {
466
+ switch (l = m / u, t = p(s), n = p(a), r = p(i), u) {
467
467
  case s: {
468
468
  o = r - n;
469
469
  break;
@@ -472,7 +472,7 @@ i.rgb.hsv = function(e) {
472
472
  o = 1 / 3 + t - r;
473
473
  break;
474
474
  }
475
- case c: {
475
+ case i: {
476
476
  o = 2 / 3 + n - t;
477
477
  break;
478
478
  }
@@ -485,20 +485,20 @@ i.rgb.hsv = function(e) {
485
485
  u * 100
486
486
  ];
487
487
  };
488
- i.rgb.hwb = function(e) {
488
+ c.rgb.hwb = function(e) {
489
489
  const t = e[0], n = e[1];
490
490
  let r = e[2];
491
- const o = i.rgb.hsl(e)[0], l = 1 / 255 * Math.min(t, Math.min(n, r));
491
+ const o = c.rgb.hsl(e)[0], l = 1 / 255 * Math.min(t, Math.min(n, r));
492
492
  return r = 1 - 1 / 255 * Math.max(t, Math.max(n, r)), [o, l * 100, r * 100];
493
493
  };
494
- i.rgb.cmyk = function(e) {
494
+ c.rgb.cmyk = function(e) {
495
495
  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;
496
496
  return [l * 100, s * 100, a * 100, o * 100];
497
497
  };
498
498
  function I(e, t) {
499
499
  return (e[0] - t[0]) ** 2 + (e[1] - t[1]) ** 2 + (e[2] - t[2]) ** 2;
500
500
  }
501
- i.rgb.keyword = function(e) {
501
+ c.rgb.keyword = function(e) {
502
502
  const t = q[e];
503
503
  if (t)
504
504
  return t;
@@ -509,33 +509,33 @@ i.rgb.keyword = function(e) {
509
509
  }
510
510
  return r;
511
511
  };
512
- i.keyword.rgb = function(e) {
512
+ c.keyword.rgb = function(e) {
513
513
  return M[e];
514
514
  };
515
- i.rgb.xyz = function(e) {
515
+ c.rgb.xyz = function(e) {
516
516
  let t = e[0] / 255, n = e[1] / 255, r = e[2] / 255;
517
517
  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;
518
518
  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;
519
519
  return [o * 100, l * 100, s * 100];
520
520
  };
521
- i.rgb.lab = function(e) {
522
- const t = i.rgb.xyz(e);
521
+ c.rgb.lab = function(e) {
522
+ const t = c.rgb.xyz(e);
523
523
  let n = t[0], r = t[1], o = t[2];
524
524
  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;
525
525
  const l = 116 * r - 16, s = 500 * (n - r), a = 200 * (r - o);
526
526
  return [l, s, a];
527
527
  };
528
- i.hsl.rgb = function(e) {
528
+ c.hsl.rgb = function(e) {
529
529
  const t = e[0] / 360, n = e[1] / 100, r = e[2] / 100;
530
530
  let o, l;
531
531
  if (n === 0)
532
532
  return l = r * 255, [l, l, l];
533
- const s = r < 0.5 ? r * (1 + n) : r + n - r * n, a = 2 * r - s, c = [0, 0, 0];
533
+ const s = r < 0.5 ? r * (1 + n) : r + n - r * n, a = 2 * r - s, i = [0, 0, 0];
534
534
  for (let u = 0; u < 3; u++)
535
- 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, c[u] = l * 255;
536
- return c;
535
+ 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;
536
+ return i;
537
537
  };
538
- i.hsl.hsv = function(e) {
538
+ c.hsl.hsv = function(e) {
539
539
  const t = e[0];
540
540
  let n = e[1] / 100, r = e[2] / 100, o = n;
541
541
  const l = Math.max(r, 0.01);
@@ -543,33 +543,33 @@ i.hsl.hsv = function(e) {
543
543
  const s = (r + n) / 2, a = r === 0 ? 2 * o / (l + o) : 2 * n / (r + n);
544
544
  return [t, a * 100, s * 100];
545
545
  };
546
- i.hsv.rgb = function(e) {
546
+ c.hsv.rgb = function(e) {
547
547
  const t = e[0] / 60, n = e[1] / 100;
548
548
  let r = e[2] / 100;
549
- const o = Math.floor(t) % 6, l = t - Math.floor(t), s = 255 * r * (1 - n), a = 255 * r * (1 - n * l), c = 255 * r * (1 - n * (1 - l));
549
+ 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));
550
550
  switch (r *= 255, o) {
551
551
  case 0:
552
- return [r, c, s];
552
+ return [r, i, s];
553
553
  case 1:
554
554
  return [a, r, s];
555
555
  case 2:
556
- return [s, r, c];
556
+ return [s, r, i];
557
557
  case 3:
558
558
  return [s, a, r];
559
559
  case 4:
560
- return [c, s, r];
560
+ return [i, s, r];
561
561
  case 5:
562
562
  return [r, s, a];
563
563
  }
564
564
  };
565
- i.hsv.hsl = function(e) {
565
+ c.hsv.hsl = function(e) {
566
566
  const t = e[0], n = e[1] / 100, r = e[2] / 100, o = Math.max(r, 0.01);
567
567
  let l, s;
568
568
  s = (2 - n) * r;
569
569
  const a = (2 - n) * o;
570
570
  return l = n * o, l /= a <= 1 ? a : 2 - a, l = l || 0, s /= 2, [t, l * 100, s * 100];
571
571
  };
572
- i.hwb.rgb = function(e) {
572
+ c.hwb.rgb = function(e) {
573
573
  const t = e[0] / 360;
574
574
  let n = e[1] / 100, r = e[2] / 100;
575
575
  const o = n + r;
@@ -577,87 +577,87 @@ i.hwb.rgb = function(e) {
577
577
  o > 1 && (n /= o, r /= o);
578
578
  const s = Math.floor(6 * t), a = 1 - r;
579
579
  l = 6 * t - s, s & 1 && (l = 1 - l);
580
- const c = n + l * (a - n);
580
+ const i = n + l * (a - n);
581
581
  let u, m, p;
582
582
  switch (s) {
583
583
  default:
584
584
  case 6:
585
585
  case 0: {
586
- u = a, m = c, p = n;
586
+ u = a, m = i, p = n;
587
587
  break;
588
588
  }
589
589
  case 1: {
590
- u = c, m = a, p = n;
590
+ u = i, m = a, p = n;
591
591
  break;
592
592
  }
593
593
  case 2: {
594
- u = n, m = a, p = c;
594
+ u = n, m = a, p = i;
595
595
  break;
596
596
  }
597
597
  case 3: {
598
- u = n, m = c, p = a;
598
+ u = n, m = i, p = a;
599
599
  break;
600
600
  }
601
601
  case 4: {
602
- u = c, m = n, p = a;
602
+ u = i, m = n, p = a;
603
603
  break;
604
604
  }
605
605
  case 5: {
606
- u = a, m = n, p = c;
606
+ u = a, m = n, p = i;
607
607
  break;
608
608
  }
609
609
  }
610
610
  return [u * 255, m * 255, p * 255];
611
611
  };
612
- i.cmyk.rgb = function(e) {
612
+ c.cmyk.rgb = function(e) {
613
613
  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);
614
614
  return [l * 255, s * 255, a * 255];
615
615
  };
616
- i.xyz.rgb = function(e) {
616
+ c.xyz.rgb = function(e) {
617
617
  const t = e[0] / 100, n = e[1] / 100, r = e[2] / 100;
618
618
  let o, l, s;
619
619
  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];
620
620
  };
621
- i.xyz.lab = function(e) {
621
+ c.xyz.lab = function(e) {
622
622
  let t = e[0], n = e[1], r = e[2];
623
623
  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;
624
624
  const o = 116 * n - 16, l = 500 * (t - n), s = 200 * (n - r);
625
625
  return [o, l, s];
626
626
  };
627
- i.lab.xyz = function(e) {
627
+ c.lab.xyz = function(e) {
628
628
  const t = e[0], n = e[1], r = e[2];
629
629
  let o, l, s;
630
630
  l = (t + 16) / 116, o = n / 500 + l, s = l - r / 200;
631
- const a = l ** 3, c = o ** 3, u = s ** 3;
632
- return l = a > y ? a : (l - 16 / 116) / 7.787, o = c > y ? c : (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];
631
+ const a = l ** 3, i = o ** 3, u = s ** 3;
632
+ 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];
633
633
  };
634
- i.lab.lch = function(e) {
634
+ c.lab.lch = function(e) {
635
635
  const t = e[0], n = e[1], r = e[2];
636
636
  let o;
637
637
  o = Math.atan2(r, n) * 360 / 2 / Math.PI, o < 0 && (o += 360);
638
638
  const s = Math.sqrt(n * n + r * r);
639
639
  return [t, s, o];
640
640
  };
641
- i.lch.lab = function(e) {
641
+ c.lch.lab = function(e) {
642
642
  const t = e[0], n = e[1], o = e[2] / 360 * 2 * Math.PI, l = n * Math.cos(o), s = n * Math.sin(o);
643
643
  return [t, l, s];
644
644
  };
645
- i.rgb.ansi16 = function(e, t = null) {
645
+ c.rgb.ansi16 = function(e, t = null) {
646
646
  const [n, r, o] = e;
647
- let l = t === null ? i.rgb.hsv(e)[2] : t;
647
+ let l = t === null ? c.rgb.hsv(e)[2] : t;
648
648
  if (l = Math.round(l / 50), l === 0)
649
649
  return 30;
650
650
  let s = 30 + (Math.round(o / 255) << 2 | Math.round(r / 255) << 1 | Math.round(n / 255));
651
651
  return l === 2 && (s += 60), s;
652
652
  };
653
- i.hsv.ansi16 = function(e) {
654
- return i.rgb.ansi16(i.hsv.rgb(e), e[2]);
653
+ c.hsv.ansi16 = function(e) {
654
+ return c.rgb.ansi16(c.hsv.rgb(e), e[2]);
655
655
  };
656
- i.rgb.ansi256 = function(e) {
656
+ c.rgb.ansi256 = function(e) {
657
657
  const t = e[0], n = e[1], r = e[2];
658
658
  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);
659
659
  };
660
- i.ansi16.rgb = function(e) {
660
+ c.ansi16.rgb = function(e) {
661
661
  e = e[0];
662
662
  let t = e % 10;
663
663
  if (t === 0 || t === 7)
@@ -665,7 +665,7 @@ i.ansi16.rgb = function(e) {
665
665
  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;
666
666
  return [r, o, l];
667
667
  };
668
- i.ansi256.rgb = function(e) {
668
+ c.ansi256.rgb = function(e) {
669
669
  if (e = e[0], e >= 232) {
670
670
  const l = (e - 232) * 10 + 8;
671
671
  return [l, l, l];
@@ -675,11 +675,11 @@ i.ansi256.rgb = function(e) {
675
675
  const n = Math.floor(e / 36) / 5 * 255, r = Math.floor((t = e % 36) / 6) / 5 * 255, o = t % 6 / 5 * 255;
676
676
  return [n, r, o];
677
677
  };
678
- i.rgb.hex = function(e) {
678
+ c.rgb.hex = function(e) {
679
679
  const n = (((Math.round(e[0]) & 255) << 16) + ((Math.round(e[1]) & 255) << 8) + (Math.round(e[2]) & 255)).toString(16).toUpperCase();
680
680
  return "000000".slice(n.length) + n;
681
681
  };
682
- i.hex.rgb = function(e) {
682
+ c.hex.rgb = function(e) {
683
683
  const t = e.toString(16).match(/[a-f\d]{6}|[a-f\d]{3}/i);
684
684
  if (!t)
685
685
  return [0, 0, 0];
@@ -688,28 +688,28 @@ i.hex.rgb = function(e) {
688
688
  const r = Number.parseInt(n, 16), o = r >> 16 & 255, l = r >> 8 & 255, s = r & 255;
689
689
  return [o, l, s];
690
690
  };
691
- i.rgb.hcg = function(e) {
691
+ c.rgb.hcg = function(e) {
692
692
  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;
693
693
  let a;
694
- const c = s < 1 ? l / (1 - s) : 0;
695
- 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, c * 100];
694
+ const i = s < 1 ? l / (1 - s) : 0;
695
+ 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];
696
696
  };
697
- i.hsl.hcg = function(e) {
697
+ c.hsl.hcg = function(e) {
698
698
  const t = e[1] / 100, n = e[2] / 100, r = n < 0.5 ? 2 * t * n : 2 * t * (1 - n);
699
699
  let o = 0;
700
700
  return r < 1 && (o = (n - 0.5 * r) / (1 - r)), [e[0], r * 100, o * 100];
701
701
  };
702
- i.hsv.hcg = function(e) {
702
+ c.hsv.hcg = function(e) {
703
703
  const t = e[1] / 100, n = e[2] / 100, r = t * n;
704
704
  let o = 0;
705
705
  return r < 1 && (o = (n - r) / (1 - r)), [e[0], r * 100, o * 100];
706
706
  };
707
- i.hcg.rgb = function(e) {
707
+ c.hcg.rgb = function(e) {
708
708
  const t = e[0] / 360, n = e[1] / 100, r = e[2] / 100;
709
709
  if (n === 0)
710
710
  return [r * 255, r * 255, r * 255];
711
711
  const o = [0, 0, 0], l = t % 1 * 6, s = l % 1, a = 1 - s;
712
- let c = 0;
712
+ let i = 0;
713
713
  switch (Math.floor(l)) {
714
714
  case 0: {
715
715
  o[0] = 1, o[1] = s, o[2] = 0;
@@ -734,62 +734,62 @@ i.hcg.rgb = function(e) {
734
734
  default:
735
735
  o[0] = 1, o[1] = 0, o[2] = a;
736
736
  }
737
- return c = (1 - n) * r, [
738
- (n * o[0] + c) * 255,
739
- (n * o[1] + c) * 255,
740
- (n * o[2] + c) * 255
737
+ return i = (1 - n) * r, [
738
+ (n * o[0] + i) * 255,
739
+ (n * o[1] + i) * 255,
740
+ (n * o[2] + i) * 255
741
741
  ];
742
742
  };
743
- i.hcg.hsv = function(e) {
743
+ c.hcg.hsv = function(e) {
744
744
  const t = e[1] / 100, n = e[2] / 100, r = t + n * (1 - t);
745
745
  let o = 0;
746
746
  return r > 0 && (o = t / r), [e[0], o * 100, r * 100];
747
747
  };
748
- i.hcg.hsl = function(e) {
748
+ c.hcg.hsl = function(e) {
749
749
  const t = e[1] / 100, r = e[2] / 100 * (1 - t) + 0.5 * t;
750
750
  let o = 0;
751
751
  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];
752
752
  };
753
- i.hcg.hwb = function(e) {
753
+ c.hcg.hwb = function(e) {
754
754
  const t = e[1] / 100, n = e[2] / 100, r = t + n * (1 - t);
755
755
  return [e[0], (r - t) * 100, (1 - r) * 100];
756
756
  };
757
- i.hwb.hcg = function(e) {
757
+ c.hwb.hcg = function(e) {
758
758
  const t = e[1] / 100, r = 1 - e[2] / 100, o = r - t;
759
759
  let l = 0;
760
760
  return o < 1 && (l = (r - o) / (1 - o)), [e[0], o * 100, l * 100];
761
761
  };
762
- i.apple.rgb = function(e) {
762
+ c.apple.rgb = function(e) {
763
763
  return [e[0] / 65535 * 255, e[1] / 65535 * 255, e[2] / 65535 * 255];
764
764
  };
765
- i.rgb.apple = function(e) {
765
+ c.rgb.apple = function(e) {
766
766
  return [e[0] / 255 * 65535, e[1] / 255 * 65535, e[2] / 255 * 65535];
767
767
  };
768
- i.gray.rgb = function(e) {
768
+ c.gray.rgb = function(e) {
769
769
  return [e[0] / 100 * 255, e[0] / 100 * 255, e[0] / 100 * 255];
770
770
  };
771
- i.gray.hsl = function(e) {
771
+ c.gray.hsl = function(e) {
772
772
  return [0, 0, e[0]];
773
773
  };
774
- i.gray.hsv = i.gray.hsl;
775
- i.gray.hwb = function(e) {
774
+ c.gray.hsv = c.gray.hsl;
775
+ c.gray.hwb = function(e) {
776
776
  return [0, 100, e[0]];
777
777
  };
778
- i.gray.cmyk = function(e) {
778
+ c.gray.cmyk = function(e) {
779
779
  return [0, 0, 0, e[0]];
780
780
  };
781
- i.gray.lab = function(e) {
781
+ c.gray.lab = function(e) {
782
782
  return [e[0], 0, 0];
783
783
  };
784
- i.gray.hex = function(e) {
784
+ c.gray.hex = function(e) {
785
785
  const t = Math.round(e[0] / 100 * 255) & 255, r = ((t << 16) + (t << 8) + t).toString(16).toUpperCase();
786
786
  return "000000".slice(r.length) + r;
787
787
  };
788
- i.rgb.gray = function(e) {
788
+ c.rgb.gray = function(e) {
789
789
  return [(e[0] + e[1] + e[2]) / 3 / 255 * 100];
790
790
  };
791
- function j() {
792
- const e = {}, t = Object.keys(i);
791
+ function P() {
792
+ const e = {}, t = Object.keys(c);
793
793
  for (let { length: n } = t, r = 0; r < n; r++)
794
794
  e[t[r]] = {
795
795
  // http://jsperf.com/1-vs-infinity
@@ -800,29 +800,29 @@ function j() {
800
800
  return e;
801
801
  }
802
802
  function E(e) {
803
- const t = j(), n = [e];
803
+ const t = P(), n = [e];
804
804
  for (t[e].distance = 0; n.length > 0; ) {
805
- const r = n.pop(), o = Object.keys(i[r]);
805
+ const r = n.pop(), o = Object.keys(c[r]);
806
806
  for (let { length: l } = o, s = 0; s < l; s++) {
807
- const a = o[s], c = t[a];
808
- c.distance === -1 && (c.distance = t[r].distance + 1, c.parent = r, n.unshift(a));
807
+ const a = o[s], i = t[a];
808
+ i.distance === -1 && (i.distance = t[r].distance + 1, i.parent = r, n.unshift(a));
809
809
  }
810
810
  }
811
811
  return t;
812
812
  }
813
- function P(e, t) {
813
+ function j(e, t) {
814
814
  return function(n) {
815
815
  return t(e(n));
816
816
  };
817
817
  }
818
818
  function $(e, t) {
819
819
  const n = [t[e].parent, e];
820
- let r = i[t[e].parent][e], o = t[e].parent;
820
+ let r = c[t[e].parent][e], o = t[e].parent;
821
821
  for (; t[o].parent; )
822
- n.unshift(t[o].parent), r = P(i[t[o].parent][o], r), o = t[o].parent;
822
+ n.unshift(t[o].parent), r = j(c[t[o].parent][o], r), o = t[o].parent;
823
823
  return r.conversion = n, r;
824
824
  }
825
- function U(e) {
825
+ function T(e) {
826
826
  const t = E(e), n = {}, r = Object.keys(t);
827
827
  for (let { length: o } = r, l = 0; l < o; l++) {
828
828
  const s = r[l];
@@ -830,15 +830,15 @@ function U(e) {
830
830
  }
831
831
  return n;
832
832
  }
833
- const g = {}, D = Object.keys(i);
834
- function K(e) {
833
+ const g = {}, U = Object.keys(c);
834
+ function D(e) {
835
835
  const t = function(...n) {
836
836
  const r = n[0];
837
837
  return r == null ? r : (r.length > 1 && (n = r), e(n));
838
838
  };
839
839
  return "conversion" in e && (t.conversion = e.conversion), t;
840
840
  }
841
- function T(e) {
841
+ function K(e) {
842
842
  const t = function(...n) {
843
843
  const r = n[0];
844
844
  if (r == null)
@@ -852,12 +852,12 @@ function T(e) {
852
852
  };
853
853
  return "conversion" in e && (t.conversion = e.conversion), t;
854
854
  }
855
- for (const e of D) {
856
- g[e] = {}, Object.defineProperty(g[e], "channels", { value: i[e].channels }), Object.defineProperty(g[e], "labels", { value: i[e].labels });
857
- const t = U(e), n = Object.keys(t);
855
+ for (const e of U) {
856
+ g[e] = {}, Object.defineProperty(g[e], "channels", { value: c[e].channels }), Object.defineProperty(g[e], "labels", { value: c[e].labels });
857
+ const t = T(e), n = Object.keys(t);
858
858
  for (const r of n) {
859
859
  const o = t[r];
860
- g[e][r] = T(o), g[e][r].raw = K(o);
860
+ g[e][r] = K(o), g[e][r].raw = D(o);
861
861
  }
862
862
  }
863
863
  const z = [
@@ -867,9 +867,9 @@ const z = [
867
867
  "gray",
868
868
  // Shouldn't really be in color-convert either...
869
869
  "hex"
870
- ], _ = {};
870
+ ], F = {};
871
871
  for (const e of Object.keys(g))
872
- _[[...g[e].labels].sort().join("")] = e;
872
+ F[[...g[e].labels].sort().join("")] = e;
873
873
  const v = {};
874
874
  function b(e, t) {
875
875
  if (!(this instanceof b))
@@ -901,9 +901,9 @@ function b(e, t) {
901
901
  const o = Object.keys(e);
902
902
  "alpha" in e && (o.splice(o.indexOf("alpha"), 1), this.valpha = typeof e.alpha == "number" ? e.alpha : 0);
903
903
  const l = o.sort().join("");
904
- if (!(l in _))
904
+ if (!(l in F))
905
905
  throw new Error("Unable to parse color from object: " + JSON.stringify(e));
906
- this.model = _[l];
906
+ this.model = F[l];
907
907
  const { labels: s } = g[this.model], a = [];
908
908
  for (n = 0; n < s.length; n++)
909
909
  a.push(e[s[n]]);
@@ -951,7 +951,7 @@ b.prototype = {
951
951
  return e.r /= 255, e.g /= 255, e.b /= 255, this.valpha !== 1 && (e.alpha = this.valpha), e;
952
952
  },
953
953
  round(e) {
954
- return e = Math.max(e || 0, 0), new b([...this.color.map(R(e)), this.valpha], this.model);
954
+ return e = Math.max(e || 0, 0), new b([...this.color.map(L(e)), this.valpha], this.model);
955
955
  },
956
956
  alpha(e) {
957
957
  return e !== void 0 ? new b([...this.color, Math.max(0, Math.min(1, e))], this.model) : this.valpha;
@@ -1067,11 +1067,11 @@ b.prototype = {
1067
1067
  mix(e, t) {
1068
1068
  if (!e || !e.rgb)
1069
1069
  throw new Error('Argument to "mix" was not a Color instance, but rather an instance of ' + typeof e);
1070
- 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, c = 1 - a;
1070
+ 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;
1071
1071
  return b.rgb(
1072
- a * n.red() + c * r.red(),
1073
- a * n.green() + c * r.green(),
1074
- a * n.blue() + c * r.blue(),
1072
+ a * n.red() + i * r.red(),
1073
+ a * n.green() + i * r.green(),
1074
+ a * n.blue() + i * r.blue(),
1075
1075
  n.alpha() * o + r.alpha() * (1 - o)
1076
1076
  );
1077
1077
  }
@@ -1081,18 +1081,18 @@ for (const e of Object.keys(g)) {
1081
1081
  continue;
1082
1082
  const { channels: t } = g[e];
1083
1083
  b.prototype[e] = function(...n) {
1084
- return this.model === e ? new b(this) : n.length > 0 ? new b(n, e) : new b([...B(g[this.model][e].raw(this.color)), this.valpha], e);
1084
+ return this.model === e ? new b(this) : n.length > 0 ? new b(n, e) : new b([...R(g[this.model][e].raw(this.color)), this.valpha], e);
1085
1085
  }, b[e] = function(...n) {
1086
1086
  let r = n[0];
1087
1087
  return typeof r == "number" && (r = N(n, t)), new b(r, e);
1088
1088
  };
1089
1089
  }
1090
- function L(e, t) {
1090
+ function B(e, t) {
1091
1091
  return Number(e.toFixed(t));
1092
1092
  }
1093
- function R(e) {
1093
+ function L(e) {
1094
1094
  return function(t) {
1095
- return L(t, e);
1095
+ return B(t, e);
1096
1096
  };
1097
1097
  }
1098
1098
  function h(e, t, n) {
@@ -1109,7 +1109,7 @@ function f(e) {
1109
1109
  return Math.max(0, Math.min(e, t));
1110
1110
  };
1111
1111
  }
1112
- function B(e) {
1112
+ function R(e) {
1113
1113
  return Array.isArray(e) ? e : [e];
1114
1114
  }
1115
1115
  function N(e, t) {
@@ -1119,23 +1119,32 @@ function N(e, t) {
1119
1119
  }
1120
1120
  class J {
1121
1121
  constructor(t) {
1122
- F(this, "isColor", !0);
1123
- F(this, "currentColor");
1124
- return this.currentColor = b(t), new Proxy(this, {
1125
- get(n, r) {
1126
- return r in n.currentColor ? n._handleColorMethod(r) : n[r];
1122
+ _(this, "isColor", !0);
1123
+ _(this, "currentColor");
1124
+ this.base = t;
1125
+ const n = this._resolveBaseColor(t);
1126
+ return this.currentColor = b(n), this._createProxy();
1127
+ }
1128
+ _createProxy() {
1129
+ return new Proxy(this, {
1130
+ get(t, n) {
1131
+ return n in t ? t[n] : n in t.currentColor ? t._handleColorMethod(n) : t[n];
1127
1132
  }
1128
1133
  });
1129
1134
  }
1135
+ _resolveBaseColor(t) {
1136
+ if (typeof t != "string" || !/\{[^{}]+\}/g.test(t)) return t;
1137
+ throw new Error("Token values are not yet supported, use a color string instead");
1138
+ }
1130
1139
  _handleColorMethod(t) {
1131
1140
  const n = this.currentColor;
1132
- return typeof n[t] != "function" ? n[t] : (...r) => (this.currentColor = n[t](...r), this);
1141
+ return typeof n[t] != "function" ? n[t] : (...r) => (this.currentColor = n[t](...r), this._createProxy());
1133
1142
  }
1134
1143
  toString() {
1135
1144
  return this.currentColor.toString();
1136
1145
  }
1137
1146
  }
1138
- const H = (e) => new J(e);
1147
+ const G = (e) => new J(e);
1139
1148
  export {
1140
- H as color
1149
+ G as color
1141
1150
  };