@udixio/theme 2.0.0 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/bin.cjs +1 -1
  3. package/dist/bin.js +1 -1
  4. package/dist/browser.cjs +3 -2
  5. package/dist/browser.js +24 -23
  6. package/dist/color/color.api.d.ts +5 -1
  7. package/dist/color/color.api.d.ts.map +1 -1
  8. package/dist/color/color.d.ts +1 -0
  9. package/dist/color/color.d.ts.map +1 -1
  10. package/dist/color/color.manager.d.ts +1 -2
  11. package/dist/color/color.manager.d.ts.map +1 -1
  12. package/dist/color/default-color.d.ts +5 -1
  13. package/dist/color/default-color.d.ts.map +1 -1
  14. package/dist/{font.plugin-DZtMajJV.js → font.plugin-5Xpo-ntw.js} +1 -1
  15. package/dist/{font.plugin-BZ-TTeTo.cjs → font.plugin-FPU_gL1Y.cjs} +1 -1
  16. package/dist/{load-from-path-Dobe0beV.js → load-from-path-CBnO8ESw.js} +1 -1
  17. package/dist/{load-from-path-DZ35yiXK.cjs → load-from-path-kuofMGN3.cjs} +2 -2
  18. package/dist/loader/loader.d.ts.map +1 -1
  19. package/dist/{loader-C8LnOoqg.cjs → loader-BzsrGBu-.cjs} +1166 -458
  20. package/dist/{loader-BS_Esfwg.js → loader-CoayTlSl.js} +1186 -478
  21. package/dist/node.cjs +4 -3
  22. package/dist/node.js +26 -25
  23. package/dist/palette/palette.d.ts.map +1 -1
  24. package/dist/variant/variant.d.ts +2 -0
  25. package/dist/variant/variant.d.ts.map +1 -1
  26. package/dist/variant/variants/expressive.variant.d.ts.map +1 -1
  27. package/dist/variant/variants/index.d.ts +1 -1
  28. package/dist/variant/variants/neutral.variant.d.ts.map +1 -1
  29. package/dist/variant/variants/tonal-spot.variant.d.ts.map +1 -1
  30. package/dist/variant/variants/udixio.variant.d.ts +3 -0
  31. package/dist/variant/variants/udixio.variant.d.ts.map +1 -0
  32. package/dist/variant/variants/vibrant.variant.d.ts.map +1 -1
  33. package/package.json +1 -1
  34. package/src/color/color.api.ts +24 -3
  35. package/src/color/color.manager.ts +4 -16
  36. package/src/color/color.ts +4 -0
  37. package/src/color/default-color.ts +34 -68
  38. package/src/loader/loader.ts +0 -4
  39. package/src/palette/palette.ts +1 -2
  40. package/src/variant/variant.ts +3 -0
  41. package/src/variant/variants/expressive.variant.ts +2 -0
  42. package/src/variant/variants/index.ts +2 -2
  43. package/src/variant/variants/neutral.variant.ts +2 -0
  44. package/src/variant/variants/tonal-spot.variant.ts +2 -0
  45. package/src/variant/variants/udixio.variant.ts +846 -0
  46. package/src/variant/variants/vibrant.variant.ts +2 -0
  47. package/dist/variant/variants/fidelity.variant.d.ts +0 -3
  48. package/dist/variant/variants/fidelity.variant.d.ts.map +0 -1
  49. package/src/variant/variants/fidelity.variant.ts +0 -46
@@ -2,8 +2,8 @@
2
2
  var __defProp = Object.defineProperty;
3
3
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4
4
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
- const materialColorUtilities = require("@material/material-color-utilities");
6
5
  const awilix = require("awilix");
6
+ const materialColorUtilities = require("@material/material-color-utilities");
7
7
  class API {
8
8
  constructor({
9
9
  colorApi,
@@ -25,58 +25,6 @@ class API {
25
25
  return this.plugins.loadPlugins();
26
26
  }
27
27
  }
28
- /**
29
- * @license
30
- * Copyright 2023 Google LLC
31
- *
32
- * Licensed under the Apache License, Version 2.0 (the "License");
33
- * you may not use this file except in compliance with the License.
34
- * You may obtain a copy of the License at
35
- *
36
- * http://www.apache.org/licenses/LICENSE-2.0
37
- *
38
- * Unless required by applicable law or agreed to in writing, software
39
- * distributed under the License is distributed on an "AS IS" BASIS,
40
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
41
- * See the License for the specific language governing permissions and
42
- * limitations under the License.
43
- */
44
- class ContrastCurve {
45
- /**
46
- * Creates a `ContrastCurve` object.
47
- *
48
- * @param low Value for contrast level -1.0
49
- * @param normal Value for contrast level 0.0
50
- * @param medium Value for contrast level 0.5
51
- * @param high Value for contrast level 1.0
52
- */
53
- constructor(low, normal, medium, high) {
54
- this.low = low;
55
- this.normal = normal;
56
- this.medium = medium;
57
- this.high = high;
58
- }
59
- /**
60
- * Returns the value at a given contrast level.
61
- *
62
- * @param contrastLevel The contrast level. 0.0 is the default (normal); -1.0
63
- * is the lowest; 1.0 is the highest.
64
- * @return The value. For contrast ratios, a number between 1.0 and 21.0.
65
- */
66
- get(contrastLevel) {
67
- if (contrastLevel <= -1) {
68
- return this.low;
69
- } else if (contrastLevel < 0) {
70
- return materialColorUtilities.lerp(this.low, this.normal, (contrastLevel - -1) / 1);
71
- } else if (contrastLevel < 0.5) {
72
- return materialColorUtilities.lerp(this.normal, this.medium, (contrastLevel - 0) / 0.5);
73
- } else if (contrastLevel < 1) {
74
- return materialColorUtilities.lerp(this.medium, this.high, (contrastLevel - 0.5) / 0.5);
75
- } else {
76
- return this.high;
77
- }
78
- }
79
- }
80
28
  /**
81
29
  * @license
82
30
  * Copyright 2021 Google LLC
@@ -863,6 +811,125 @@ class Hct {
863
811
  this.argb = argb;
864
812
  }
865
813
  }
814
+ /**
815
+ * @license
816
+ * Copyright 2023 Google LLC
817
+ *
818
+ * Licensed under the Apache License, Version 2.0 (the "License");
819
+ * you may not use this file except in compliance with the License.
820
+ * You may obtain a copy of the License at
821
+ *
822
+ * http://www.apache.org/licenses/LICENSE-2.0
823
+ *
824
+ * Unless required by applicable law or agreed to in writing, software
825
+ * distributed under the License is distributed on an "AS IS" BASIS,
826
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
827
+ * See the License for the specific language governing permissions and
828
+ * limitations under the License.
829
+ */
830
+ class ContrastCurve {
831
+ /**
832
+ * Creates a `ContrastCurve` object.
833
+ *
834
+ * @param low Value for contrast level -1.0
835
+ * @param normal Value for contrast level 0.0
836
+ * @param medium Value for contrast level 0.5
837
+ * @param high Value for contrast level 1.0
838
+ */
839
+ constructor(low, normal, medium, high) {
840
+ this.low = low;
841
+ this.normal = normal;
842
+ this.medium = medium;
843
+ this.high = high;
844
+ }
845
+ /**
846
+ * Returns the value at a given contrast level.
847
+ *
848
+ * @param contrastLevel The contrast level. 0.0 is the default (normal); -1.0
849
+ * is the lowest; 1.0 is the highest.
850
+ * @return The value. For contrast ratios, a number between 1.0 and 21.0.
851
+ */
852
+ get(contrastLevel) {
853
+ if (contrastLevel <= -1) {
854
+ return this.low;
855
+ } else if (contrastLevel < 0) {
856
+ return materialColorUtilities.lerp(this.low, this.normal, (contrastLevel - -1) / 1);
857
+ } else if (contrastLevel < 0.5) {
858
+ return materialColorUtilities.lerp(this.normal, this.medium, (contrastLevel - 0) / 0.5);
859
+ } else if (contrastLevel < 1) {
860
+ return materialColorUtilities.lerp(this.medium, this.high, (contrastLevel - 0.5) / 0.5);
861
+ } else {
862
+ return this.high;
863
+ }
864
+ }
865
+ }
866
+ function getCurve(defaultContrast) {
867
+ if (defaultContrast === 1.5) {
868
+ return new ContrastCurve(1.5, 1.5, 3, 4.5);
869
+ } else if (defaultContrast === 3) {
870
+ return new ContrastCurve(3, 3, 4.5, 7);
871
+ } else if (defaultContrast === 4.5) {
872
+ return new ContrastCurve(4.5, 4.5, 7, 11);
873
+ } else if (defaultContrast === 6) {
874
+ return new ContrastCurve(6, 6, 7, 11);
875
+ } else if (defaultContrast === 7) {
876
+ return new ContrastCurve(7, 7, 11, 21);
877
+ } else if (defaultContrast === 9) {
878
+ return new ContrastCurve(9, 9, 11, 21);
879
+ } else if (defaultContrast === 11) {
880
+ return new ContrastCurve(11, 11, 21, 21);
881
+ } else if (defaultContrast === 21) {
882
+ return new ContrastCurve(21, 21, 21, 21);
883
+ } else {
884
+ return new ContrastCurve(defaultContrast, defaultContrast, 7, 21);
885
+ }
886
+ }
887
+ function tMaxC(palette, lowerBound = 0, upperBound = 100, chromaMultiplier = 1) {
888
+ const answer = findBestToneForChroma(
889
+ palette.hue,
890
+ palette.chroma * chromaMultiplier,
891
+ 100,
892
+ true
893
+ );
894
+ return materialColorUtilities.clampDouble(lowerBound, upperBound, answer);
895
+ }
896
+ function tMinC(palette, lowerBound = 0, upperBound = 100) {
897
+ const answer = findBestToneForChroma(palette.hue, palette.chroma, 0, false);
898
+ return materialColorUtilities.clampDouble(lowerBound, upperBound, answer);
899
+ }
900
+ function findBestToneForChroma(hue, chroma, tone, byDecreasingTone) {
901
+ let answer = tone;
902
+ let bestCandidate = Hct.from(hue, chroma, answer);
903
+ while (bestCandidate.chroma < chroma) {
904
+ if (tone < 0 || tone > 100) {
905
+ break;
906
+ }
907
+ tone += byDecreasingTone ? -1 : 1;
908
+ const newCandidate = Hct.from(hue, chroma, tone);
909
+ if (bestCandidate.chroma < newCandidate.chroma) {
910
+ bestCandidate = newCandidate;
911
+ answer = tone;
912
+ }
913
+ }
914
+ return answer;
915
+ }
916
+ function calculateToneAdjustmentPercentage(toneA, toneB, desiredRatio) {
917
+ const currentRatio = materialColorUtilities.Contrast.ratioOfTones(toneA, toneB);
918
+ if (currentRatio >= desiredRatio) {
919
+ return 0;
920
+ }
921
+ const lighterTone = materialColorUtilities.Contrast.lighter(toneA, desiredRatio);
922
+ const darkerTone = materialColorUtilities.Contrast.darker(toneA, desiredRatio);
923
+ if (lighterTone !== -1 && toneB < lighterTone) {
924
+ const percentageToAdjust = (toneB - lighterTone) / (toneA - lighterTone);
925
+ return materialColorUtilities.clampDouble(0, 1, percentageToAdjust);
926
+ }
927
+ if (darkerTone !== -1 && toneB > darkerTone) {
928
+ const percentageToAdjust = (toneB - darkerTone) / (toneA - darkerTone);
929
+ return materialColorUtilities.clampDouble(0, 1, percentageToAdjust);
930
+ }
931
+ return 0;
932
+ }
866
933
  /**
867
934
  * @license
868
935
  * Copyright 2022 Google LLC
@@ -1250,6 +1317,9 @@ class Color {
1250
1317
  constructor(name) {
1251
1318
  this.name = name;
1252
1319
  }
1320
+ static maxChroma(hue, tone = 50) {
1321
+ return Hct.from(hue, 200, tone).chroma;
1322
+ }
1253
1323
  getHex() {
1254
1324
  return materialColorUtilities.hexFromArgb(this.getArgb());
1255
1325
  }
@@ -1398,349 +1468,71 @@ class ColorFromPalette extends Color {
1398
1468
  }
1399
1469
  }
1400
1470
  }
1401
- const highestSurface = (context, colorService) => {
1471
+ const highestSurface$1 = (context, colorService) => {
1402
1472
  if (colorService instanceof ColorApi) {
1403
1473
  return context.isDark ? colorService.get("surfaceBright") : colorService.get("surfaceDim");
1404
1474
  } else {
1405
1475
  return context.isDark ? colorService.get("surfaceBright") : colorService.get("surfaceDim");
1406
1476
  }
1407
1477
  };
1408
- class ColorManager {
1409
- constructor(args) {
1410
- __publicField(this, "colorMap", /* @__PURE__ */ new Map());
1411
- __publicField(this, "context");
1412
- this.context = args.context;
1413
- }
1414
- createOrUpdate(key, args) {
1415
- let colorEntity = this.colorMap.get(key);
1416
- if ("alias" in args) {
1417
- colorEntity = new ColorAlias(key, args.alias, this);
1418
- } else if ("hex" in args) {
1419
- colorEntity = new ColorFromHex(key, args.hex);
1420
- } else {
1421
- try {
1422
- if (colorEntity instanceof ColorFromPalette) {
1423
- colorEntity.update(args);
1478
+ const defaultColors = ({
1479
+ colors,
1480
+ context: c,
1481
+ palettes
1482
+ }) => {
1483
+ const getColor = (key) => {
1484
+ return colors.get(key);
1485
+ };
1486
+ return {
1487
+ ////////////////////////////////////////////////////////////////
1488
+ // Surfaces [S] //
1489
+ ////////////////////////////////////////////////////////////////
1490
+ surface: {
1491
+ palette: () => palettes.get("neutral"),
1492
+ tone: () => {
1493
+ if (c.isDark) {
1494
+ return 4;
1424
1495
  } else {
1425
- colorEntity = new ColorFromPalette(key, args, this.context);
1496
+ if (Hct.isYellow(palettes.get("neutral").hue)) {
1497
+ return 99;
1498
+ } else if (c.variant.name === "vibrant") {
1499
+ return 97;
1500
+ } else {
1501
+ return 98;
1502
+ }
1426
1503
  }
1427
- } catch (e) {
1428
- console.error(e);
1429
- throw new Error(`Invalid color options provided for ${key}`);
1430
- }
1431
- }
1432
- this.colorMap.set(key, colorEntity);
1433
- return colorEntity;
1434
- }
1435
- remove(key) {
1436
- return this.colorMap.delete(key);
1437
- }
1438
- get(key) {
1439
- const colorEntity = this.colorMap.get(key);
1440
- if (colorEntity) {
1441
- return colorEntity;
1442
- } else {
1443
- throw new Error(`Color ${key} does not exist`);
1444
- }
1445
- }
1446
- getAll() {
1447
- return this.colorMap;
1448
- }
1449
- }
1450
- function getCurve(defaultContrast) {
1451
- if (defaultContrast === 1.5) {
1452
- return new ContrastCurve(1.5, 1.5, 3, 4.5);
1453
- } else if (defaultContrast === 3) {
1454
- return new ContrastCurve(3, 3, 4.5, 7);
1455
- } else if (defaultContrast === 4.5) {
1456
- return new ContrastCurve(4.5, 4.5, 7, 11);
1457
- } else if (defaultContrast === 6) {
1458
- return new ContrastCurve(6, 6, 7, 11);
1459
- } else if (defaultContrast === 7) {
1460
- return new ContrastCurve(7, 7, 11, 21);
1461
- } else if (defaultContrast === 9) {
1462
- return new ContrastCurve(9, 9, 11, 21);
1463
- } else if (defaultContrast === 11) {
1464
- return new ContrastCurve(11, 11, 21, 21);
1465
- } else if (defaultContrast === 21) {
1466
- return new ContrastCurve(21, 21, 21, 21);
1467
- } else {
1468
- return new ContrastCurve(defaultContrast, defaultContrast, 7, 21);
1469
- }
1470
- }
1471
- function tMaxC(palette, lowerBound = 0, upperBound = 100, chromaMultiplier = 1) {
1472
- const answer = findBestToneForChroma(
1473
- palette.hue,
1474
- palette.chroma * chromaMultiplier,
1475
- 100,
1476
- true
1477
- );
1478
- return materialColorUtilities.clampDouble(lowerBound, upperBound, answer);
1479
- }
1480
- function tMinC(palette, lowerBound = 0, upperBound = 100) {
1481
- const answer = findBestToneForChroma(palette.hue, palette.chroma, 0, false);
1482
- return materialColorUtilities.clampDouble(lowerBound, upperBound, answer);
1483
- }
1484
- function findBestToneForChroma(hue, chroma, tone, byDecreasingTone) {
1485
- let answer = tone;
1486
- let bestCandidate = Hct.from(hue, chroma, answer);
1487
- while (bestCandidate.chroma < chroma) {
1488
- if (tone < 0 || tone > 100) {
1489
- break;
1490
- }
1491
- tone += byDecreasingTone ? -1 : 1;
1492
- const newCandidate = Hct.from(hue, chroma, tone);
1493
- if (bestCandidate.chroma < newCandidate.chroma) {
1494
- bestCandidate = newCandidate;
1495
- answer = tone;
1496
- }
1497
- }
1498
- return answer;
1499
- }
1500
- function calculateToneAdjustmentPercentage(toneA, toneB, desiredRatio) {
1501
- const currentRatio = materialColorUtilities.Contrast.ratioOfTones(toneA, toneB);
1502
- if (currentRatio >= desiredRatio) {
1503
- return 0;
1504
- }
1505
- const lighterTone = materialColorUtilities.Contrast.lighter(toneA, desiredRatio);
1506
- const darkerTone = materialColorUtilities.Contrast.darker(toneA, desiredRatio);
1507
- if (lighterTone !== -1 && toneB < lighterTone) {
1508
- const percentageToAdjust = (toneB - lighterTone) / (toneA - lighterTone);
1509
- return materialColorUtilities.clampDouble(0, 1, percentageToAdjust);
1510
- }
1511
- if (darkerTone !== -1 && toneB > darkerTone) {
1512
- const percentageToAdjust = (toneB - darkerTone) / (toneA - darkerTone);
1513
- return materialColorUtilities.clampDouble(0, 1, percentageToAdjust);
1514
- }
1515
- return 0;
1516
- }
1517
- function capitalizeFirstLetter(string) {
1518
- return string.charAt(0).toUpperCase() + string.slice(1);
1519
- }
1520
- class ColorApi {
1521
- constructor({ colorManager }) {
1522
- __publicField(this, "colorManager");
1523
- __publicField(this, "api");
1524
- this.colorManager = colorManager;
1525
- }
1526
- getAll() {
1527
- return this.colorManager.getAll();
1528
- }
1529
- addColor(key, color) {
1530
- return this.colorManager.createOrUpdate(key, color);
1531
- }
1532
- addColors(args) {
1533
- if (!this.api)
1534
- throw new Error(
1535
- "The API is not initialized. Please call bootstrap() before calling addColors()."
1536
- );
1537
- if (typeof args === "function") {
1538
- args = args(this.api);
1539
- }
1540
- if (args) {
1541
- Object.entries(args).forEach(([name, colorOption]) => {
1542
- this.addColor(name, colorOption);
1543
- });
1544
- }
1545
- }
1546
- get(key) {
1547
- return this.colorManager.get(key);
1548
- }
1549
- remove(key) {
1550
- return this.colorManager.remove(key);
1551
- }
1552
- update(key, newColor) {
1553
- return this.colorManager.createOrUpdate(key, newColor);
1554
- }
1555
- addFromCustomPalette(key) {
1556
- const colorKey = key;
1557
- const colorDimKey = colorKey + "Dim";
1558
- const ColorKey = capitalizeFirstLetter(key);
1559
- const onColorKey = "on" + ColorKey;
1560
- const colorContainerKey = colorKey + "Container";
1561
- const onColorContainerKey = "on" + ColorKey + "Container";
1562
- const colorFixedKey = colorKey + "Fixed";
1563
- const colorFixedDimKey = colorKey + "FixedDim";
1564
- const onColorFixedKey = "on" + ColorKey + "Fixed";
1565
- const onColorFixedVariantKey = "on" + ColorKey + "FixedVariant";
1566
- const colors = ({ palettes, colors: colors2, context: ctx }) => ({
1567
- [colorKey]: {
1568
- palette: () => palettes.get(colorKey),
1569
- tone: () => {
1570
- if (ctx.variant.name === "neutral") {
1571
- return ctx.isDark ? tMinC(palettes.get(colorKey), 0, 98) : tMaxC(palettes.get(colorKey));
1572
- } else if (ctx.variant.name === "vibrant") {
1573
- return tMaxC(palettes.get(colorKey), 0, ctx.isDark ? 90 : 98);
1574
- } else {
1575
- return ctx.isDark ? 80 : tMaxC(palettes.get(colorKey));
1576
- }
1577
- },
1578
- isBackground: true,
1579
- background: () => highestSurface(ctx, this),
1580
- contrastCurve: () => getCurve(4.5),
1581
- adjustTone: () => toneDeltaPair(
1582
- colors2.get(colorContainerKey),
1583
- colors2.get(colorKey),
1584
- 5,
1585
- "relative_lighter",
1586
- true,
1587
- "farther"
1588
- )
1589
- },
1590
- [colorDimKey]: {
1591
- palette: () => palettes.get(colorKey),
1592
- tone: () => {
1593
- if (ctx.variant.name === "neutral") {
1594
- return 85;
1595
- } else {
1596
- return tMaxC(palettes.get(colorKey), 0, 90);
1597
- }
1598
- },
1599
- isBackground: true,
1600
- background: () => this.get("surfaceContainerHigh"),
1601
- contrastCurve: () => getCurve(4.5),
1602
- adjustTone: () => toneDeltaPair(
1603
- this.get(colorDimKey),
1604
- this.get(colorKey),
1605
- 5,
1606
- "darker",
1607
- true,
1608
- "farther"
1609
- )
1610
- },
1611
- [onColorKey]: {
1612
- palette: () => palettes.get(colorKey),
1613
- background: () => this.get(colorKey),
1614
- contrastCurve: () => getCurve(6)
1615
- },
1616
- [colorContainerKey]: {
1617
- palette: () => palettes.get(colorKey),
1618
- tone: () => {
1619
- if (ctx.variant.name === "vibrant") {
1620
- return ctx.isDark ? tMinC(palettes.get(colorKey), 30, 40) : tMaxC(palettes.get(colorKey), 84, 90);
1621
- } else if (ctx.variant.name === "expressive") {
1622
- return ctx.isDark ? 15 : tMaxC(palettes.get(colorKey), 90, 95);
1623
- } else {
1624
- return ctx.isDark ? 25 : 90;
1625
- }
1626
- },
1627
- isBackground: true,
1628
- background: () => highestSurface(ctx, this),
1629
- adjustTone: () => void 0,
1630
- contrastCurve: () => ctx.contrastLevel > 0 ? getCurve(1.5) : void 0
1631
- },
1632
- [onColorContainerKey]: {
1633
- palette: () => palettes.get(colorKey),
1634
- background: () => this.get(colorContainerKey),
1635
- contrastCurve: () => getCurve(6)
1636
- },
1637
- [colorFixedKey]: {
1638
- palette: () => palettes.get(colorKey),
1639
- tone: () => {
1640
- return ctx.temp({ isDark: false, contrastLevel: 0 }, () => {
1641
- const color = this.get(colorContainerKey);
1642
- return color.getTone();
1643
- });
1644
- },
1645
- isBackground: true,
1646
- background: () => highestSurface(ctx, this),
1647
- contrastCurve: () => ctx.contrastLevel > 0 ? getCurve(1.5) : void 0
1648
- },
1649
- [colorFixedDimKey]: {
1650
- palette: () => palettes.get(colorKey),
1651
- tone: () => this.get(colorFixedKey).getTone(),
1652
- isBackground: true,
1653
- adjustTone: () => toneDeltaPair(
1654
- this.get(colorFixedDimKey),
1655
- this.get(colorFixedKey),
1656
- 5,
1657
- "darker",
1658
- true,
1659
- "exact"
1660
- )
1661
- },
1662
- [onColorFixedKey]: {
1663
- palette: () => palettes.get(colorKey),
1664
- background: () => this.get(colorFixedDimKey),
1665
- contrastCurve: () => getCurve(7)
1666
- },
1667
- [onColorFixedVariantKey]: {
1668
- palette: () => palettes.get(colorKey),
1669
- background: () => this.get(colorFixedDimKey),
1670
- contrastCurve: () => getCurve(4.5)
1671
- }
1672
- });
1673
- this.addColors(colors);
1674
- }
1675
- }
1676
- const ColorModule = {
1677
- colorManager: awilix.asClass(ColorManager).singleton(),
1678
- colorApi: awilix.asClass(ColorApi).singleton()
1679
- };
1680
- const inverseTone = (tone) => {
1681
- return 100 - tone;
1682
- };
1683
- const defaultColors = ({
1684
- colors,
1685
- context: c,
1686
- palettes
1687
- }) => {
1688
- const getColor = (key) => {
1689
- return colors.get(key);
1690
- };
1691
- return {
1692
- ////////////////////////////////////////////////////////////////
1693
- // Surfaces [S] //
1694
- ////////////////////////////////////////////////////////////////
1695
- surface: {
1696
- palette: () => palettes.get("neutral"),
1697
- tone: () => {
1698
- if (c.isDark) {
1699
- return 4;
1700
- } else {
1701
- if (c.variant.name == "fidelity") {
1702
- return 100;
1703
- }
1704
- if (Hct.isYellow(palettes.get("neutral").hue)) {
1705
- return 99;
1706
- } else if (c.variant.name === "vibrant") {
1707
- return 97;
1708
- } else {
1709
- return 98;
1710
- }
1711
- }
1712
- },
1713
- isBackground: true
1714
- },
1715
- surfaceDim: {
1716
- palette: () => palettes.get("neutral"),
1717
- tone: () => {
1718
- if (c.isDark) {
1719
- return 4;
1720
- } else {
1721
- if (Hct.isYellow(palettes.get("neutral").hue)) {
1722
- return 90;
1723
- } else if (c.variant.name === "vibrant") {
1724
- return 85;
1725
- } else {
1726
- return 87;
1727
- }
1728
- }
1729
- },
1730
- isBackground: true,
1731
- chromaMultiplier: () => {
1732
- if (!c.isDark) {
1733
- if (c.variant.name === "neutral") {
1734
- return 2.5;
1735
- } else if (c.variant.name === "tonalSpot") {
1736
- return 1.7;
1737
- } else if (c.variant.name === "expressive") {
1738
- return Hct.isYellow(palettes.get("neutral").hue) ? 2.7 : 1.75;
1739
- } else if (c.variant.name === "vibrant") {
1740
- return 1.36;
1741
- }
1742
- }
1743
- return 1;
1504
+ },
1505
+ isBackground: true
1506
+ },
1507
+ surfaceDim: {
1508
+ palette: () => palettes.get("neutral"),
1509
+ tone: () => {
1510
+ if (c.isDark) {
1511
+ return 4;
1512
+ } else {
1513
+ if (Hct.isYellow(palettes.get("neutral").hue)) {
1514
+ return 90;
1515
+ } else if (c.variant.name === "vibrant") {
1516
+ return 85;
1517
+ } else {
1518
+ return 87;
1519
+ }
1520
+ }
1521
+ },
1522
+ isBackground: true,
1523
+ chromaMultiplier: () => {
1524
+ if (!c.isDark) {
1525
+ if (c.variant.name === "neutral") {
1526
+ return 2.5;
1527
+ } else if (c.variant.name === "tonalSpot") {
1528
+ return 1.7;
1529
+ } else if (c.variant.name === "expressive") {
1530
+ return Hct.isYellow(palettes.get("neutral").hue) ? 2.7 : 1.75;
1531
+ } else if (c.variant.name === "vibrant") {
1532
+ return 1.36;
1533
+ }
1534
+ }
1535
+ return 1;
1744
1536
  }
1745
1537
  },
1746
1538
  surfaceBright: {
@@ -1902,7 +1694,7 @@ const defaultColors = ({
1902
1694
  if (c.variant.name === "vibrant") {
1903
1695
  return tMaxC(palettes.get("neutral"), 0, 100, 1.1);
1904
1696
  } else {
1905
- return getInitialToneFromBackground(highestSurface(c, colors));
1697
+ return getInitialToneFromBackground(highestSurface$1(c, colors));
1906
1698
  }
1907
1699
  },
1908
1700
  chromaMultiplier: () => {
@@ -1915,7 +1707,7 @@ const defaultColors = ({
1915
1707
  }
1916
1708
  return 1;
1917
1709
  },
1918
- background: () => highestSurface(c, colors),
1710
+ background: () => highestSurface$1(c, colors),
1919
1711
  contrastCurve: () => c.isDark ? getCurve(11) : getCurve(9)
1920
1712
  },
1921
1713
  onSurfaceVariant: {
@@ -1930,7 +1722,7 @@ const defaultColors = ({
1930
1722
  }
1931
1723
  return 1;
1932
1724
  },
1933
- background: () => highestSurface(c, colors),
1725
+ background: () => highestSurface$1(c, colors),
1934
1726
  contrastCurve: () => c.isDark ? getCurve(6) : getCurve(4.5)
1935
1727
  },
1936
1728
  outline: {
@@ -1945,7 +1737,7 @@ const defaultColors = ({
1945
1737
  }
1946
1738
  return 1;
1947
1739
  },
1948
- background: () => highestSurface(c, colors),
1740
+ background: () => highestSurface$1(c, colors),
1949
1741
  contrastCurve: () => getCurve(3)
1950
1742
  },
1951
1743
  outlineVariant: {
@@ -1960,7 +1752,7 @@ const defaultColors = ({
1960
1752
  }
1961
1753
  return 1;
1962
1754
  },
1963
- background: () => highestSurface(c, colors),
1755
+ background: () => highestSurface$1(c, colors),
1964
1756
  contrastCurve: () => getCurve(1.5)
1965
1757
  },
1966
1758
  inverseSurface: {
@@ -1994,8 +1786,6 @@ const defaultColors = ({
1994
1786
  0,
1995
1787
  Hct.isYellow(palettes.get("primary").hue) ? 25 : Hct.isCyan(palettes.get("primary").hue) ? 88 : 98
1996
1788
  );
1997
- } else if (c.variant.name == "fidelity") {
1998
- return c.sourceColor.tone;
1999
1789
  } else {
2000
1790
  return tMaxC(
2001
1791
  palettes.get("primary"),
@@ -2005,23 +1795,9 @@ const defaultColors = ({
2005
1795
  }
2006
1796
  },
2007
1797
  isBackground: true,
2008
- background: () => highestSurface(c, colors),
1798
+ background: () => highestSurface$1(c, colors),
2009
1799
  contrastCurve: () => getCurve(4.5),
2010
- adjustTone: () => c.variant.name == "fidelity" ? () => {
2011
- const surfaceTone = colors.get("surface").getTone();
2012
- const primaryTone = colors.get("primary").options.tone;
2013
- let selfTone = primaryTone;
2014
- if (materialColorUtilities.Contrast.ratioOfTones(surfaceTone, selfTone) < 3) {
2015
- const ratio = calculateToneAdjustmentPercentage(
2016
- surfaceTone,
2017
- selfTone,
2018
- 3
2019
- );
2020
- const inverseT = inverseTone(primaryTone);
2021
- selfTone = selfTone + (inverseT - selfTone) * ratio;
2022
- }
2023
- return selfTone;
2024
- } : toneDeltaPair(
1800
+ adjustTone: () => toneDeltaPair(
2025
1801
  colors.get("primaryContainer"),
2026
1802
  colors.get("primary"),
2027
1803
  5,
@@ -2072,26 +1848,14 @@ const defaultColors = ({
2072
1848
  Hct.isCyan(palettes.get("primary").hue) ? 88 : 90
2073
1849
  );
2074
1850
  }
2075
- if (c.variant.name == "fidelity") {
2076
- return c.isDark ? tMinC(palettes.get("primary"), 35, 93) : tMaxC(palettes.get("primary"), 0, 90);
2077
- } else {
2078
- return c.isDark ? tMinC(palettes.get("primary"), 66, 93) : tMaxC(
2079
- palettes.get("primary"),
2080
- 66,
2081
- Hct.isCyan(palettes.get("primary").hue) ? 88 : 93
2082
- );
2083
- }
1851
+ return c.isDark ? tMinC(palettes.get("primary"), 66, 93) : tMaxC(
1852
+ palettes.get("primary"),
1853
+ 66,
1854
+ Hct.isCyan(palettes.get("primary").hue) ? 88 : 93
1855
+ );
2084
1856
  },
2085
1857
  isBackground: true,
2086
- background: () => highestSurface(c, colors),
2087
- adjustTone: () => c.variant.name == "fidelity" ? toneDeltaPair(
2088
- colors.get("primary"),
2089
- colors.get("primaryContainer"),
2090
- 15,
2091
- "relative_darker",
2092
- true,
2093
- "farther"
2094
- ) : void 0,
1858
+ background: () => highestSurface$1(c, colors),
2095
1859
  contrastCurve: () => c.contrastLevel > 0 ? getCurve(1.5) : void 0
2096
1860
  },
2097
1861
  onPrimaryContainer: {
@@ -2114,7 +1878,7 @@ const defaultColors = ({
2114
1878
  );
2115
1879
  },
2116
1880
  isBackground: true,
2117
- background: () => highestSurface(c, colors),
1881
+ background: () => highestSurface$1(c, colors),
2118
1882
  contrastCurve: () => c.contrastLevel > 0 ? getCurve(1.5) : void 0
2119
1883
  },
2120
1884
  primaryFixedDim: {
@@ -2161,7 +1925,7 @@ const defaultColors = ({
2161
1925
  }
2162
1926
  },
2163
1927
  isBackground: true,
2164
- background: () => highestSurface(c, colors),
1928
+ background: () => highestSurface$1(c, colors),
2165
1929
  contrastCurve: () => getCurve(4.5),
2166
1930
  adjustTone: () => toneDeltaPair(
2167
1931
  getColor("secondaryContainer"),
@@ -2210,7 +1974,7 @@ const defaultColors = ({
2210
1974
  }
2211
1975
  },
2212
1976
  isBackground: true,
2213
- background: () => highestSurface(c, colors),
1977
+ background: () => highestSurface$1(c, colors),
2214
1978
  adjustTone: () => void 0,
2215
1979
  contrastCurve: () => c.contrastLevel > 0 ? getCurve(1.5) : void 0
2216
1980
  },
@@ -2234,7 +1998,7 @@ const defaultColors = ({
2234
1998
  );
2235
1999
  },
2236
2000
  isBackground: true,
2237
- background: () => highestSurface(c, colors),
2001
+ background: () => highestSurface$1(c, colors),
2238
2002
  contrastCurve: () => c.contrastLevel > 0 ? getCurve(1.5) : void 0
2239
2003
  },
2240
2004
  secondaryFixedDim: {
@@ -2277,7 +2041,7 @@ const defaultColors = ({
2277
2041
  }
2278
2042
  },
2279
2043
  isBackground: true,
2280
- background: () => highestSurface(c, colors),
2044
+ background: () => highestSurface$1(c, colors),
2281
2045
  contrastCurve: () => getCurve(4.5),
2282
2046
  adjustTone: () => toneDeltaPair(
2283
2047
  getColor("tertiaryContainer"),
@@ -2332,7 +2096,7 @@ const defaultColors = ({
2332
2096
  }
2333
2097
  },
2334
2098
  isBackground: true,
2335
- background: () => highestSurface(c, colors),
2099
+ background: () => highestSurface$1(c, colors),
2336
2100
  adjustTone: () => void 0,
2337
2101
  contrastCurve: () => c.contrastLevel > 0 ? getCurve(1.5) : void 0
2338
2102
  },
@@ -2356,7 +2120,7 @@ const defaultColors = ({
2356
2120
  );
2357
2121
  },
2358
2122
  isBackground: true,
2359
- background: () => highestSurface(c, colors),
2123
+ background: () => highestSurface$1(c, colors),
2360
2124
  contrastCurve: () => c.contrastLevel > 0 ? getCurve(1.5) : void 0
2361
2125
  },
2362
2126
  tertiaryFixedDim: {
@@ -2391,7 +2155,7 @@ const defaultColors = ({
2391
2155
  return c.isDark ? tMinC(palettes.get("error"), 0, 98) : tMaxC(palettes.get("error"));
2392
2156
  },
2393
2157
  isBackground: true,
2394
- background: () => highestSurface(c, colors),
2158
+ background: () => highestSurface$1(c, colors),
2395
2159
  contrastCurve: () => getCurve(4.5),
2396
2160
  adjustTone: () => toneDeltaPair(
2397
2161
  colors.get("errorContainer"),
@@ -2428,7 +2192,7 @@ const defaultColors = ({
2428
2192
  return c.isDark ? tMinC(palettes.get("error"), 30, 93) : tMaxC(palettes.get("error"), 0, 90);
2429
2193
  },
2430
2194
  isBackground: true,
2431
- background: () => highestSurface(c, colors),
2195
+ background: () => highestSurface$1(c, colors),
2432
2196
  adjustTone: () => void 0,
2433
2197
  contrastCurve: () => c.contrastLevel > 0 ? getCurve(1.5) : void 0
2434
2198
  },
@@ -2452,7 +2216,229 @@ const defaultColors = ({
2452
2216
  onBackground: {
2453
2217
  alias: "onSurface"
2454
2218
  }
2455
- };
2219
+ };
2220
+ };
2221
+ function capitalizeFirstLetter(string) {
2222
+ return string.charAt(0).toUpperCase() + string.slice(1);
2223
+ }
2224
+ class ColorApi {
2225
+ constructor({
2226
+ colorManager,
2227
+ context
2228
+ }) {
2229
+ __publicField(this, "colorManager");
2230
+ __publicField(this, "context");
2231
+ __publicField(this, "api");
2232
+ this.context = context;
2233
+ this.colorManager = colorManager;
2234
+ this.context.onUpdate((changed) => {
2235
+ if (changed.includes("variant")) {
2236
+ this.colorManager.clear();
2237
+ this.addColors(this.context.variant.colors);
2238
+ }
2239
+ });
2240
+ }
2241
+ getAll() {
2242
+ return this.colorManager.getAll();
2243
+ }
2244
+ addColor(key, color) {
2245
+ return this.colorManager.createOrUpdate(key, color);
2246
+ }
2247
+ addColors(args) {
2248
+ if (!this.api)
2249
+ throw new Error(
2250
+ "The API is not initialized. Please call bootstrap() before calling addColors()."
2251
+ );
2252
+ if (typeof args === "function") {
2253
+ args = args(this.api);
2254
+ }
2255
+ if (args) {
2256
+ Object.entries(args).forEach(([name, colorOption]) => {
2257
+ this.addColor(name, colorOption);
2258
+ });
2259
+ }
2260
+ }
2261
+ get(key) {
2262
+ return this.colorManager.get(key);
2263
+ }
2264
+ remove(key) {
2265
+ return this.colorManager.remove(key);
2266
+ }
2267
+ update(key, newColor) {
2268
+ return this.colorManager.createOrUpdate(key, newColor);
2269
+ }
2270
+ addFromCustomPalette(key) {
2271
+ if (this.context.variant.colorsFromCustomPalette) {
2272
+ return this.addColors(this.context.variant.colorsFromCustomPalette(key));
2273
+ }
2274
+ const colorKey = key;
2275
+ const colorDimKey = colorKey + "Dim";
2276
+ const ColorKey = capitalizeFirstLetter(key);
2277
+ const onColorKey = "on" + ColorKey;
2278
+ const colorContainerKey = colorKey + "Container";
2279
+ const onColorContainerKey = "on" + ColorKey + "Container";
2280
+ const colorFixedKey = colorKey + "Fixed";
2281
+ const colorFixedDimKey = colorKey + "FixedDim";
2282
+ const onColorFixedKey = "on" + ColorKey + "Fixed";
2283
+ const onColorFixedVariantKey = "on" + ColorKey + "FixedVariant";
2284
+ const colors = ({ palettes, colors: colors2, context: ctx }) => ({
2285
+ [colorKey]: {
2286
+ palette: () => palettes.get(colorKey),
2287
+ tone: () => {
2288
+ if (ctx.variant.name === "neutral") {
2289
+ return ctx.isDark ? tMinC(palettes.get(colorKey), 0, 98) : tMaxC(palettes.get(colorKey));
2290
+ } else if (ctx.variant.name === "vibrant") {
2291
+ return tMaxC(palettes.get(colorKey), 0, ctx.isDark ? 90 : 98);
2292
+ } else {
2293
+ return ctx.isDark ? 80 : tMaxC(palettes.get(colorKey));
2294
+ }
2295
+ },
2296
+ isBackground: true,
2297
+ background: () => highestSurface$1(ctx, this),
2298
+ contrastCurve: () => getCurve(4.5),
2299
+ adjustTone: () => toneDeltaPair(
2300
+ colors2.get(colorContainerKey),
2301
+ colors2.get(colorKey),
2302
+ 5,
2303
+ "relative_lighter",
2304
+ true,
2305
+ "farther"
2306
+ )
2307
+ },
2308
+ [colorDimKey]: {
2309
+ palette: () => palettes.get(colorKey),
2310
+ tone: () => {
2311
+ if (ctx.variant.name === "neutral") {
2312
+ return 85;
2313
+ } else {
2314
+ return tMaxC(palettes.get(colorKey), 0, 90);
2315
+ }
2316
+ },
2317
+ isBackground: true,
2318
+ background: () => this.get("surfaceContainerHigh"),
2319
+ contrastCurve: () => getCurve(4.5),
2320
+ adjustTone: () => toneDeltaPair(
2321
+ this.get(colorDimKey),
2322
+ this.get(colorKey),
2323
+ 5,
2324
+ "darker",
2325
+ true,
2326
+ "farther"
2327
+ )
2328
+ },
2329
+ [onColorKey]: {
2330
+ palette: () => palettes.get(colorKey),
2331
+ background: () => this.get(colorKey),
2332
+ contrastCurve: () => getCurve(6)
2333
+ },
2334
+ [colorContainerKey]: {
2335
+ palette: () => palettes.get(colorKey),
2336
+ tone: () => {
2337
+ if (ctx.variant.name === "vibrant") {
2338
+ return ctx.isDark ? tMinC(palettes.get(colorKey), 30, 40) : tMaxC(palettes.get(colorKey), 84, 90);
2339
+ } else if (ctx.variant.name === "expressive") {
2340
+ return ctx.isDark ? 15 : tMaxC(palettes.get(colorKey), 90, 95);
2341
+ } else {
2342
+ return ctx.isDark ? 25 : 90;
2343
+ }
2344
+ },
2345
+ isBackground: true,
2346
+ background: () => highestSurface$1(ctx, this),
2347
+ adjustTone: () => void 0,
2348
+ contrastCurve: () => ctx.contrastLevel > 0 ? getCurve(1.5) : void 0
2349
+ },
2350
+ [onColorContainerKey]: {
2351
+ palette: () => palettes.get(colorKey),
2352
+ background: () => this.get(colorContainerKey),
2353
+ contrastCurve: () => getCurve(6)
2354
+ },
2355
+ [colorFixedKey]: {
2356
+ palette: () => palettes.get(colorKey),
2357
+ tone: () => {
2358
+ return ctx.temp({ isDark: false, contrastLevel: 0 }, () => {
2359
+ const color = this.get(colorContainerKey);
2360
+ return color.getTone();
2361
+ });
2362
+ },
2363
+ isBackground: true,
2364
+ background: () => highestSurface$1(ctx, this),
2365
+ contrastCurve: () => ctx.contrastLevel > 0 ? getCurve(1.5) : void 0
2366
+ },
2367
+ [colorFixedDimKey]: {
2368
+ palette: () => palettes.get(colorKey),
2369
+ tone: () => this.get(colorFixedKey).getTone(),
2370
+ isBackground: true,
2371
+ adjustTone: () => toneDeltaPair(
2372
+ this.get(colorFixedDimKey),
2373
+ this.get(colorFixedKey),
2374
+ 5,
2375
+ "darker",
2376
+ true,
2377
+ "exact"
2378
+ )
2379
+ },
2380
+ [onColorFixedKey]: {
2381
+ palette: () => palettes.get(colorKey),
2382
+ background: () => this.get(colorFixedDimKey),
2383
+ contrastCurve: () => getCurve(7)
2384
+ },
2385
+ [onColorFixedVariantKey]: {
2386
+ palette: () => palettes.get(colorKey),
2387
+ background: () => this.get(colorFixedDimKey),
2388
+ contrastCurve: () => getCurve(4.5)
2389
+ }
2390
+ });
2391
+ this.addColors(colors);
2392
+ }
2393
+ }
2394
+ class ColorManager {
2395
+ constructor(args) {
2396
+ __publicField(this, "colorMap", /* @__PURE__ */ new Map());
2397
+ __publicField(this, "context");
2398
+ this.context = args.context;
2399
+ }
2400
+ createOrUpdate(key, args) {
2401
+ let colorEntity = this.colorMap.get(key);
2402
+ if ("alias" in args) {
2403
+ colorEntity = new ColorAlias(key, args.alias, this);
2404
+ } else if ("hex" in args) {
2405
+ colorEntity = new ColorFromHex(key, args.hex);
2406
+ } else {
2407
+ try {
2408
+ if (colorEntity instanceof ColorFromPalette) {
2409
+ colorEntity.update(args);
2410
+ } else {
2411
+ colorEntity = new ColorFromPalette(key, args, this.context);
2412
+ }
2413
+ } catch (e) {
2414
+ console.error(e);
2415
+ throw new Error(`Invalid color options provided for ${key}`);
2416
+ }
2417
+ }
2418
+ this.colorMap.set(key, colorEntity);
2419
+ return colorEntity;
2420
+ }
2421
+ remove(key) {
2422
+ return this.colorMap.delete(key);
2423
+ }
2424
+ clear() {
2425
+ this.colorMap.clear();
2426
+ }
2427
+ get(key) {
2428
+ const colorEntity = this.colorMap.get(key);
2429
+ if (colorEntity) {
2430
+ return colorEntity;
2431
+ } else {
2432
+ throw new Error(`Color ${key} does not exist`);
2433
+ }
2434
+ }
2435
+ getAll() {
2436
+ return this.colorMap;
2437
+ }
2438
+ }
2439
+ const ColorModule = {
2440
+ colorManager: awilix.asClass(ColorManager).singleton(),
2441
+ colorApi: awilix.asClass(ColorApi).singleton()
2456
2442
  };
2457
2443
  const AppModule = {
2458
2444
  api: awilix.asClass(API).singleton()
@@ -2666,7 +2652,7 @@ class Palette {
2666
2652
  })) {
2667
2653
  result = this.callback(this.context);
2668
2654
  }
2669
- if (result && this.hueCache !== result.hue && this.chromaCache !== result.chroma) {
2655
+ if (result && (this.hueCache !== result.hue || this.chromaCache !== result.chroma)) {
2670
2656
  this.clearCache();
2671
2657
  this.hueCache = result.hue;
2672
2658
  this.chromaCache = result.chroma;
@@ -2856,6 +2842,7 @@ class Variant {
2856
2842
  constructor(options) {
2857
2843
  __publicField(this, "_palettes");
2858
2844
  __publicField(this, "customPalettes");
2845
+ __publicField(this, "colorsFromCustomPalette");
2859
2846
  __publicField(this, "colors");
2860
2847
  __publicField(this, "name");
2861
2848
  __publicField(this, "context");
@@ -2863,6 +2850,7 @@ class Variant {
2863
2850
  this.customPalettes = options.customPalettes;
2864
2851
  this.colors = options.colors || {};
2865
2852
  this.name = options.name;
2853
+ this.colorsFromCustomPalette = options.colorsFromCustomPalette;
2866
2854
  }
2867
2855
  get palettes() {
2868
2856
  if (!this._palettes) {
@@ -2949,7 +2937,8 @@ const expressiveVariant = variant({
2949
2937
  [-160, 155, -100, 96, -96, -156, -165, -160]
2950
2938
  ),
2951
2939
  isDark ? 16 : 24
2952
- )
2940
+ ),
2941
+ colors: defaultColors
2953
2942
  });
2954
2943
  const neutralVariant = variant({
2955
2944
  name: "neutral",
@@ -2984,7 +2973,8 @@ const neutralVariant = variant({
2984
2973
  customPalettes: (_, colorHct) => materialColorUtilities.TonalPalette.fromHueAndChroma(
2985
2974
  colorHct.hue,
2986
2975
  Hct.isBlue(colorHct.hue) ? 6 : 4
2987
- )
2976
+ ),
2977
+ colors: defaultColors
2988
2978
  });
2989
2979
  const tonalSpotVariant = variant({
2990
2980
  name: "tonalSpot",
@@ -3010,7 +3000,8 @@ const tonalSpotVariant = variant({
3010
3000
  return materialColorUtilities.TonalPalette.fromHueAndChroma(errorHue, 60);
3011
3001
  }
3012
3002
  },
3013
- customPalettes: (_, colorHct) => materialColorUtilities.TonalPalette.fromHueAndChroma(colorHct.hue, 16)
3003
+ customPalettes: (_, colorHct) => materialColorUtilities.TonalPalette.fromHueAndChroma(colorHct.hue, 16),
3004
+ colors: defaultColors
3014
3005
  });
3015
3006
  const getVibrantNeutralHue = (sourceColor) => {
3016
3007
  return getRotatedHue(
@@ -3070,10 +3061,33 @@ const vibrantVariant = variant({
3070
3061
  [-14, 10, -14, 10, -14]
3071
3062
  ),
3072
3063
  56
3073
- )
3064
+ ),
3065
+ colors: defaultColors
3074
3066
  });
3075
- const fidelityVariant = variant({
3076
- name: "fidelity",
3067
+ const surfaceContainerToneDelta = 2.5;
3068
+ const inverseTone = (tone) => {
3069
+ return 100 - tone;
3070
+ };
3071
+ const surfaceContainerTone = (layer, api) => {
3072
+ const t = surfaceContainerToneDelta * layer * (1 + api.context.contrastLevel);
3073
+ if (api.context.isDark) {
3074
+ return t * 1.5;
3075
+ } else {
3076
+ if (Hct.isYellow(api.palettes.get("neutral").hue)) {
3077
+ return 100 - t - surfaceContainerToneDelta;
3078
+ }
3079
+ return 100 - t;
3080
+ }
3081
+ };
3082
+ const highestSurface = (context, colorService) => {
3083
+ if (colorService instanceof ColorApi) {
3084
+ return colorService.get("surface");
3085
+ } else {
3086
+ return colorService.get("surface");
3087
+ }
3088
+ };
3089
+ const udixioVariant = variant({
3090
+ name: "udixio",
3077
3091
  palettes: {
3078
3092
  primary: ({ sourceColor }) => ({
3079
3093
  hue: sourceColor.hue,
@@ -3091,14 +3105,19 @@ const fidelityVariant = variant({
3091
3105
  ),
3092
3106
  chroma: sourceColor.chroma
3093
3107
  }),
3094
- neutral: ({ sourceColor }) => ({
3095
- hue: sourceColor.hue,
3096
- chroma: 5
3097
- }),
3098
- neutralVariant: ({ sourceColor }) => ({
3099
- hue: sourceColor.hue,
3100
- chroma: 5 * 1.7
3101
- }),
3108
+ neutral: ({ sourceColor }) => {
3109
+ return {
3110
+ hue: sourceColor.hue,
3111
+ chroma: 5
3112
+ };
3113
+ },
3114
+ neutralVariant: ({ sourceColor }) => {
3115
+ const neutral = 5;
3116
+ return {
3117
+ hue: sourceColor.hue,
3118
+ chroma: neutral * 1.7
3119
+ };
3120
+ },
3102
3121
  error: ({ sourceColor }) => {
3103
3122
  const errorHue = getPiecewiseHue(
3104
3123
  sourceColor,
@@ -3114,14 +3133,703 @@ const fidelityVariant = variant({
3114
3133
  customPalettes: ({ sourceColor }, colorHct) => ({
3115
3134
  hue: colorHct.hue,
3116
3135
  chroma: sourceColor.chroma
3117
- })
3136
+ }),
3137
+ colorsFromCustomPalette: (key) => {
3138
+ const colorKey = key;
3139
+ const ColorKey = capitalizeFirstLetter(key);
3140
+ const onColorKey = "on" + ColorKey;
3141
+ const colorContainerKey = colorKey + "Container";
3142
+ const onColorContainerKey = "on" + ColorKey + "Container";
3143
+ const colors = ({ palettes, colors: colors2, context: ctx }) => ({
3144
+ [colorKey]: {
3145
+ palette: () => palettes.get(colorKey),
3146
+ tone: () => {
3147
+ if (ctx.variant.name === "neutral") {
3148
+ return ctx.isDark ? tMinC(palettes.get(colorKey), 0, 98) : tMaxC(palettes.get(colorKey));
3149
+ } else if (ctx.variant.name === "vibrant") {
3150
+ return tMaxC(palettes.get(colorKey), 0, ctx.isDark ? 90 : 98);
3151
+ } else {
3152
+ return ctx.isDark ? 80 : tMaxC(palettes.get(colorKey));
3153
+ }
3154
+ },
3155
+ isBackground: true,
3156
+ background: () => highestSurface(ctx, colors2),
3157
+ contrastCurve: () => getCurve(4.5),
3158
+ adjustTone: () => toneDeltaPair(
3159
+ colors2.get(colorContainerKey),
3160
+ colors2.get(colorKey),
3161
+ 5,
3162
+ "relative_lighter",
3163
+ true,
3164
+ "farther"
3165
+ )
3166
+ },
3167
+ // [colorDimKey]: {
3168
+ // palette: () => palettes.get(colorKey),
3169
+ // tone: () => {
3170
+ // if (ctx.variant.name === 'neutral') {
3171
+ // return 85;
3172
+ // } else {
3173
+ // return tMaxC(palettes.get(colorKey), 0, 90);
3174
+ // }
3175
+ // },
3176
+ // isBackground: true,
3177
+ // background: () => colors.get('surfaceContainerHigh'),
3178
+ // contrastCurve: () => getCurve(4.5),
3179
+ // adjustTone: () =>
3180
+ // toneDeltaPair(
3181
+ // colors.get(colorDimKey),
3182
+ // colors.get(colorKey),
3183
+ // 5,
3184
+ // 'darker',
3185
+ // true,
3186
+ // 'farther',
3187
+ // ),
3188
+ // },
3189
+ [onColorKey]: {
3190
+ palette: () => palettes.get(colorKey),
3191
+ background: () => colors2.get(colorKey),
3192
+ contrastCurve: () => getCurve(6)
3193
+ },
3194
+ [colorContainerKey]: {
3195
+ palette: () => palettes.get(colorKey),
3196
+ tone: () => {
3197
+ if (ctx.variant.name === "vibrant") {
3198
+ return ctx.isDark ? tMinC(palettes.get(colorKey), 30, 40) : tMaxC(palettes.get(colorKey), 84, 90);
3199
+ } else if (ctx.variant.name === "expressive") {
3200
+ return ctx.isDark ? 15 : tMaxC(palettes.get(colorKey), 90, 95);
3201
+ } else {
3202
+ return ctx.isDark ? 25 : 90;
3203
+ }
3204
+ },
3205
+ isBackground: true,
3206
+ background: () => highestSurface(ctx, colors2),
3207
+ adjustTone: () => void 0,
3208
+ contrastCurve: () => ctx.contrastLevel > 0 ? getCurve(1.5) : void 0
3209
+ },
3210
+ [onColorContainerKey]: {
3211
+ palette: () => palettes.get(colorKey),
3212
+ background: () => colors2.get(colorContainerKey),
3213
+ contrastCurve: () => getCurve(6)
3214
+ }
3215
+ // [colorFixedKey]: {
3216
+ // palette: () => palettes.get(colorKey),
3217
+ // tone: () => {
3218
+ // return ctx.temp({ isDark: false, contrastLevel: 0 }, () => {
3219
+ // const color = colors.get(colorContainerKey);
3220
+ // return color.getTone();
3221
+ // });
3222
+ // },
3223
+ // isBackground: true,
3224
+ // background: () => highestSurface(ctx, colors),
3225
+ // contrastCurve: () =>
3226
+ // ctx.contrastLevel > 0 ? getCurve(1.5) : undefined,
3227
+ // },
3228
+ // [colorFixedDimKey]: {
3229
+ // palette: () => palettes.get(colorKey),
3230
+ // tone: () => colors.get(colorFixedKey).getTone(),
3231
+ // isBackground: true,
3232
+ // adjustTone: () =>
3233
+ // toneDeltaPair(
3234
+ // colors.get(colorFixedDimKey),
3235
+ // colors.get(colorFixedKey),
3236
+ // 5,
3237
+ // 'darker',
3238
+ // true,
3239
+ // 'exact',
3240
+ // ),
3241
+ // },
3242
+ // [onColorFixedKey]: {
3243
+ // palette: () => palettes.get(colorKey),
3244
+ // background: () => this.get(colorFixedDimKey),
3245
+ // contrastCurve: () => getCurve(7),
3246
+ // },
3247
+ // [onColorFixedVariantKey]: {
3248
+ // palette: () => palettes.get(colorKey),
3249
+ // background: () => colors.get(colorFixedDimKey),
3250
+ // contrastCurve: () => getCurve(4.5),
3251
+ // },
3252
+ });
3253
+ return colors;
3254
+ },
3255
+ colors: ({ colors, context: c, palettes }) => {
3256
+ const getColor = (key) => {
3257
+ return colors.get(key);
3258
+ };
3259
+ return {
3260
+ ////////////////////////////////////////////////////////////////
3261
+ // Surfaces [S] //
3262
+ ////////////////////////////////////////////////////////////////
3263
+ surface: {
3264
+ palette: () => palettes.get("neutral"),
3265
+ tone: () => {
3266
+ if (c.isDark) {
3267
+ return 2;
3268
+ } else {
3269
+ return 99;
3270
+ }
3271
+ },
3272
+ isBackground: true
3273
+ },
3274
+ // surfaceDim: {
3275
+ // palette: () => palettes.get('neutral'),
3276
+ // tone: () => {
3277
+ // if (c.isDark) {
3278
+ // return 4;
3279
+ // } else {
3280
+ // if (Hct.isYellow(palettes.get('neutral').hue)) {
3281
+ // return 90;
3282
+ // } else if (c.variant.name === 'vibrant') {
3283
+ // return 85;
3284
+ // } else {
3285
+ // return 87;
3286
+ // }
3287
+ // }
3288
+ // },
3289
+ // isBackground: true,
3290
+ // chromaMultiplier: () => {
3291
+ // if (!c.isDark) {
3292
+ // if (c.variant.name === 'neutral') {
3293
+ // return 2.5;
3294
+ // } else if (c.variant.name === 'tonalSpot') {
3295
+ // return 1.7;
3296
+ // } else if (c.variant.name === 'expressive') {
3297
+ // return Hct.isYellow(palettes.get('neutral').hue) ? 2.7 : 1.75;
3298
+ // } else if (c.variant.name === 'vibrant') {
3299
+ // return 1.36;
3300
+ // }
3301
+ // }
3302
+ // return 1;
3303
+ // },
3304
+ // },
3305
+ // surfaceBright: {
3306
+ // palette: () => palettes.get('neutral'),
3307
+ // tone: () => {
3308
+ // if (c.isDark) {
3309
+ // return 18;
3310
+ // } else {
3311
+ // if (Hct.isYellow(palettes.get('neutral').hue)) {
3312
+ // return 99;
3313
+ // } else if (c.variant.name === 'vibrant') {
3314
+ // return 97;
3315
+ // } else {
3316
+ // return 98;
3317
+ // }
3318
+ // }
3319
+ // },
3320
+ // isBackground: true,
3321
+ // chromaMultiplier: () => {
3322
+ // if (c.isDark) {
3323
+ // if (c.variant.name === 'neutral') {
3324
+ // return 2.5;
3325
+ // } else if (c.variant.name === 'tonalSpot') {
3326
+ // return 1.7;
3327
+ // } else if (c.variant.name === 'expressive') {
3328
+ // return Hct.isYellow(palettes.get('neutral').hue) ? 2.7 : 1.75;
3329
+ // } else if (c.variant.name === 'vibrant') {
3330
+ // return 1.36;
3331
+ // }
3332
+ // }
3333
+ // return 1;
3334
+ // },
3335
+ // },
3336
+ surfaceContainerLowest: {
3337
+ palette: () => palettes.get("neutral"),
3338
+ tone: () => surfaceContainerTone(0, { palettes, context: c }),
3339
+ isBackground: true
3340
+ },
3341
+ surfaceContainerLow: {
3342
+ palette: () => palettes.get("neutral"),
3343
+ tone: () => surfaceContainerTone(1, { palettes, context: c }),
3344
+ isBackground: true,
3345
+ chromaMultiplier: () => {
3346
+ return 1.25;
3347
+ }
3348
+ },
3349
+ surfaceContainer: {
3350
+ palette: () => palettes.get("neutral"),
3351
+ tone: () => surfaceContainerTone(2, { palettes, context: c }),
3352
+ isBackground: true,
3353
+ chromaMultiplier: () => {
3354
+ return 1.4;
3355
+ }
3356
+ },
3357
+ surfaceContainerHigh: {
3358
+ palette: () => palettes.get("neutral"),
3359
+ tone: () => surfaceContainerTone(3, { palettes, context: c }),
3360
+ isBackground: true,
3361
+ chromaMultiplier: () => {
3362
+ return 1.5;
3363
+ }
3364
+ },
3365
+ surfaceContainerHighest: {
3366
+ palette: () => palettes.get("neutral"),
3367
+ tone: () => surfaceContainerTone(4, { palettes, context: c }),
3368
+ isBackground: true,
3369
+ chromaMultiplier: () => {
3370
+ return 1.7;
3371
+ }
3372
+ },
3373
+ onSurface: {
3374
+ palette: () => palettes.get("neutral"),
3375
+ tone: () => {
3376
+ return getInitialToneFromBackground(highestSurface(c, colors));
3377
+ },
3378
+ chromaMultiplier: () => {
3379
+ return 1.7;
3380
+ },
3381
+ background: () => highestSurface(c, colors),
3382
+ contrastCurve: () => c.isDark ? getCurve(11) : getCurve(9)
3383
+ },
3384
+ onSurfaceVariant: {
3385
+ palette: () => palettes.get("neutralVariant"),
3386
+ chromaMultiplier: () => {
3387
+ return 1.7;
3388
+ },
3389
+ background: () => highestSurface(c, colors),
3390
+ contrastCurve: () => c.isDark ? getCurve(6) : getCurve(4.5)
3391
+ },
3392
+ outline: {
3393
+ palette: () => palettes.get("neutralVariant"),
3394
+ chromaMultiplier: () => {
3395
+ return 1.7;
3396
+ },
3397
+ background: () => highestSurface(c, colors),
3398
+ contrastCurve: () => getCurve(3)
3399
+ },
3400
+ outlineVariant: {
3401
+ palette: () => palettes.get("neutralVariant"),
3402
+ chromaMultiplier: () => {
3403
+ return 1.7;
3404
+ },
3405
+ background: () => highestSurface(c, colors),
3406
+ contrastCurve: () => getCurve(1.5)
3407
+ },
3408
+ inverseSurface: {
3409
+ palette: () => palettes.get("neutral"),
3410
+ tone: () => 100 - colors.get("surface").getTone(),
3411
+ isBackground: true
3412
+ },
3413
+ inverseOnSurface: {
3414
+ palette: () => palettes.get("neutral"),
3415
+ tone: () => c.isDark ? 20 : 95,
3416
+ background: () => colors.get("inverseSurface"),
3417
+ contrastCurve: () => getCurve(7)
3418
+ },
3419
+ ////////////////////////////////////////////////////////////////
3420
+ // Primaries [P] //
3421
+ ////////////////////////////////////////////////////////////////
3422
+ primary: {
3423
+ palette: () => palettes.get("primary"),
3424
+ tone: () => {
3425
+ return c.sourceColor.tone;
3426
+ },
3427
+ isBackground: true,
3428
+ background: () => highestSurface(c, colors),
3429
+ contrastCurve: () => getCurve(4.5),
3430
+ adjustTone: () => () => {
3431
+ const surfaceTone = colors.get("surface").getTone();
3432
+ const primaryTone = colors.get("primary").options.tone;
3433
+ let selfTone = primaryTone;
3434
+ if (materialColorUtilities.Contrast.ratioOfTones(surfaceTone, selfTone) < 3) {
3435
+ const ratio = calculateToneAdjustmentPercentage(
3436
+ surfaceTone,
3437
+ selfTone,
3438
+ 3
3439
+ );
3440
+ const inverseT = inverseTone(primaryTone);
3441
+ selfTone = selfTone + (inverseT - selfTone) * ratio;
3442
+ }
3443
+ return selfTone;
3444
+ }
3445
+ },
3446
+ // primaryDim: {
3447
+ // palette: () => palettes.get('primary'),
3448
+ // tone: () => {
3449
+ // if (c.variant.name === 'neutral') {
3450
+ // return 85;
3451
+ // } else if (c.variant.name === 'tonalSpot') {
3452
+ // return tMaxC(palettes.get('primary'), 0, 90);
3453
+ // } else {
3454
+ // return tMaxC(palettes.get('primary'));
3455
+ // }
3456
+ // },
3457
+ // isBackground: true,
3458
+ // background: () => getColor('surfaceContainerHigh'),
3459
+ // contrastCurve: () => getCurve(4.5),
3460
+ // adjustTone: () =>
3461
+ // toneDeltaPair(
3462
+ // colors.get('primaryDim'),
3463
+ // colors.get('primary'),
3464
+ // 5,
3465
+ // 'darker',
3466
+ // true,
3467
+ // 'farther',
3468
+ // ),
3469
+ // },
3470
+ onPrimary: {
3471
+ palette: () => palettes.get("primary"),
3472
+ background: () => colors.get("primary"),
3473
+ contrastCurve: () => getCurve(6)
3474
+ },
3475
+ primaryContainer: {
3476
+ palette: () => palettes.get("primary"),
3477
+ tone: () => {
3478
+ return c.isDark ? tMinC(palettes.get("primary"), 35, 93) : tMaxC(palettes.get("primary"), 0, 90);
3479
+ },
3480
+ isBackground: true,
3481
+ background: () => highestSurface(c, colors),
3482
+ adjustTone: () => c.variant.name == "fidelity" ? toneDeltaPair(
3483
+ colors.get("primary"),
3484
+ colors.get("primaryContainer"),
3485
+ 15,
3486
+ "relative_darker",
3487
+ true,
3488
+ "farther"
3489
+ ) : void 0,
3490
+ contrastCurve: () => c.contrastLevel > 0 ? getCurve(1.5) : void 0
3491
+ },
3492
+ onPrimaryContainer: {
3493
+ palette: () => palettes.get("primary"),
3494
+ background: () => colors.get("primaryContainer"),
3495
+ contrastCurve: () => getCurve(6)
3496
+ },
3497
+ // primaryFixed: {
3498
+ // palette: () => palettes.get('primary'),
3499
+ // tone: () => {
3500
+ // return c.temp(
3501
+ // {
3502
+ // isDark: false,
3503
+ // contrastLevel: 0,
3504
+ // },
3505
+ // () => {
3506
+ // const color = getColor('primaryContainer');
3507
+ // return color.getTone();
3508
+ // },
3509
+ // );
3510
+ // },
3511
+ // isBackground: true,
3512
+ // background: () => highestSurface(c, colors),
3513
+ // contrastCurve: () => (c.contrastLevel > 0 ? getCurve(1.5) : undefined),
3514
+ // },
3515
+ // primaryFixedDim: {
3516
+ // palette: () => palettes.get('primary'),
3517
+ // tone: () => colors.get('primaryFixed').getTone(),
3518
+ // isBackground: true,
3519
+ // adjustTone: () =>
3520
+ // toneDeltaPair(
3521
+ // getColor('primaryFixedDim'),
3522
+ // getColor('primaryFixed'),
3523
+ // 5,
3524
+ // 'darker',
3525
+ // true,
3526
+ // 'exact',
3527
+ // ),
3528
+ // },
3529
+ // onPrimaryFixed: {
3530
+ // palette: () => palettes.get('primary'),
3531
+ // background: () => colors.get('primaryFixedDim'),
3532
+ // contrastCurve: () => getCurve(7),
3533
+ // },
3534
+ // onPrimaryFixedVariant: {
3535
+ // palette: () => palettes.get('primary'),
3536
+ // background: () => colors.get('primaryFixedDim'),
3537
+ // contrastCurve: () => getCurve(4.5),
3538
+ // },
3539
+ inversePrimary: {
3540
+ palette: () => palettes.get("primary"),
3541
+ tone: () => tMaxC(palettes.get("primary")),
3542
+ background: () => colors.get("inverseSurface"),
3543
+ contrastCurve: () => getCurve(6)
3544
+ },
3545
+ ////////////////////////////////////////////////////////////////
3546
+ // Secondaries [Q] //
3547
+ ////////////////////////////////////////////////////////////////
3548
+ secondary: {
3549
+ palette: () => palettes.get("secondary"),
3550
+ tone: () => {
3551
+ return c.isDark ? 80 : tMaxC(palettes.get("secondary"));
3552
+ },
3553
+ isBackground: true,
3554
+ background: () => highestSurface(c, colors),
3555
+ contrastCurve: () => getCurve(4.5),
3556
+ adjustTone: () => toneDeltaPair(
3557
+ getColor("secondaryContainer"),
3558
+ getColor("secondary"),
3559
+ 5,
3560
+ "relative_lighter",
3561
+ true,
3562
+ "farther"
3563
+ )
3564
+ },
3565
+ // secondaryDim: {
3566
+ // palette: () => palettes.get('secondary'),
3567
+ // tone: () => {
3568
+ // if (c.variant.name === 'neutral') {
3569
+ // return 85;
3570
+ // } else {
3571
+ // return tMaxC(palettes.get('secondary'), 0, 90);
3572
+ // }
3573
+ // },
3574
+ // isBackground: true,
3575
+ // background: () => getColor('surfaceContainerHigh'),
3576
+ // contrastCurve: () => getCurve(4.5),
3577
+ // adjustTone: () =>
3578
+ // toneDeltaPair(
3579
+ // getColor('secondaryDim'),
3580
+ // getColor('secondary'),
3581
+ // 5,
3582
+ // 'darker',
3583
+ // true,
3584
+ // 'farther',
3585
+ // ),
3586
+ // },
3587
+ onSecondary: {
3588
+ palette: () => palettes.get("secondary"),
3589
+ background: () => getColor("secondary"),
3590
+ contrastCurve: () => getCurve(6)
3591
+ },
3592
+ secondaryContainer: {
3593
+ palette: () => palettes.get("secondary"),
3594
+ tone: () => {
3595
+ return c.isDark ? 25 : 90;
3596
+ },
3597
+ isBackground: true,
3598
+ background: () => highestSurface(c, colors),
3599
+ adjustTone: () => void 0,
3600
+ contrastCurve: () => c.contrastLevel > 0 ? getCurve(1.5) : void 0
3601
+ },
3602
+ onSecondaryContainer: {
3603
+ palette: () => palettes.get("secondary"),
3604
+ background: () => getColor("secondaryContainer"),
3605
+ contrastCurve: () => getCurve(6)
3606
+ },
3607
+ // secondaryFixed: {
3608
+ // palette: () => palettes.get('secondary'),
3609
+ // tone: () => {
3610
+ // return c.temp(
3611
+ // {
3612
+ // isDark: false,
3613
+ // contrastLevel: 0,
3614
+ // },
3615
+ // () => {
3616
+ // const color = getColor('secondaryContainer');
3617
+ // return color.getTone();
3618
+ // },
3619
+ // );
3620
+ // },
3621
+ // isBackground: true,
3622
+ // background: () => highestSurface(c, colors),
3623
+ // contrastCurve: () => (c.contrastLevel > 0 ? getCurve(1.5) : undefined),
3624
+ // },
3625
+ // secondaryFixedDim: {
3626
+ // palette: () => palettes.get('secondary'),
3627
+ // tone: () => getColor('secondaryFixed').getTone(),
3628
+ // isBackground: true,
3629
+ // adjustTone: () =>
3630
+ // toneDeltaPair(
3631
+ // getColor('secondaryFixedDim'),
3632
+ // getColor('secondaryFixed'),
3633
+ // 5,
3634
+ // 'darker',
3635
+ // true,
3636
+ // 'exact',
3637
+ // ),
3638
+ // },
3639
+ // onSecondaryFixed: {
3640
+ // palette: () => palettes.get('secondary'),
3641
+ // background: () => getColor('secondaryFixedDim'),
3642
+ // contrastCurve: () => getCurve(7),
3643
+ // },
3644
+ // onSecondaryFixedVariant: {
3645
+ // palette: () => palettes.get('secondary'),
3646
+ // background: () => getColor('secondaryFixedDim'),
3647
+ // contrastCurve: () => getCurve(4.5),
3648
+ // },
3649
+ ////////////////////////////////////////////////////////////////
3650
+ // Tertiaries [T] //
3651
+ ////////////////////////////////////////////////////////////////
3652
+ tertiary: {
3653
+ palette: () => palettes.get("tertiary"),
3654
+ tone: () => {
3655
+ return c.isDark ? tMaxC(palettes.get("tertiary"), 0, 98) : tMaxC(palettes.get("tertiary"));
3656
+ },
3657
+ isBackground: true,
3658
+ background: () => highestSurface(c, colors),
3659
+ contrastCurve: () => getCurve(4.5),
3660
+ adjustTone: () => toneDeltaPair(
3661
+ getColor("tertiaryContainer"),
3662
+ getColor("tertiary"),
3663
+ 5,
3664
+ "relative_lighter",
3665
+ true,
3666
+ "farther"
3667
+ )
3668
+ },
3669
+ // tertiaryDim: {
3670
+ // palette: () => palettes.get('tertiary'),
3671
+ // tone: () => {
3672
+ // if (c.variant.name === 'tonalSpot') {
3673
+ // return tMaxC(palettes.get('tertiary'), 0, 90);
3674
+ // } else {
3675
+ // return tMaxC(palettes.get('tertiary'));
3676
+ // }
3677
+ // },
3678
+ // isBackground: true,
3679
+ // background: () => getColor('surfaceContainerHigh'),
3680
+ // contrastCurve: () => getCurve(4.5),
3681
+ // adjustTone: () =>
3682
+ // toneDeltaPair(
3683
+ // getColor('tertiaryDim'),
3684
+ // getColor('tertiary'),
3685
+ // 5,
3686
+ // 'darker',
3687
+ // true,
3688
+ // 'farther',
3689
+ // ),
3690
+ // },
3691
+ onTertiary: {
3692
+ palette: () => palettes.get("tertiary"),
3693
+ background: () => getColor("tertiary"),
3694
+ contrastCurve: () => getCurve(6)
3695
+ },
3696
+ tertiaryContainer: {
3697
+ palette: () => palettes.get("tertiary"),
3698
+ tone: () => {
3699
+ return tMaxC(palettes.get("tertiary"), 0, c.isDark ? 93 : 100);
3700
+ },
3701
+ isBackground: true,
3702
+ background: () => highestSurface(c, colors),
3703
+ adjustTone: () => void 0,
3704
+ contrastCurve: () => c.contrastLevel > 0 ? getCurve(1.5) : void 0
3705
+ },
3706
+ onTertiaryContainer: {
3707
+ palette: () => palettes.get("tertiary"),
3708
+ background: () => getColor("tertiaryContainer"),
3709
+ contrastCurve: () => getCurve(6)
3710
+ },
3711
+ // tertiaryFixed: {
3712
+ // palette: () => palettes.get('tertiary'),
3713
+ // tone: () => {
3714
+ // return c.temp(
3715
+ // {
3716
+ // isDark: false,
3717
+ // contrastLevel: 0,
3718
+ // },
3719
+ // () => {
3720
+ // const color = getColor('tertiaryContainer');
3721
+ // return color.getTone();
3722
+ // },
3723
+ // );
3724
+ // },
3725
+ // isBackground: true,
3726
+ // background: () => highestSurface(c, colors),
3727
+ // contrastCurve: () => (c.contrastLevel > 0 ? getCurve(1.5) : undefined),
3728
+ // },
3729
+ // tertiaryFixedDim: {
3730
+ // palette: () => palettes.get('tertiary'),
3731
+ // tone: () => getColor('tertiaryFixed').getTone(),
3732
+ // isBackground: true,
3733
+ // adjustTone: () =>
3734
+ // toneDeltaPair(
3735
+ // getColor('tertiaryFixedDim'),
3736
+ // getColor('tertiaryFixed'),
3737
+ // 5,
3738
+ // 'darker',
3739
+ // true,
3740
+ // 'exact',
3741
+ // ),
3742
+ // },
3743
+ // onTertiaryFixed: {
3744
+ // palette: () => palettes.get('tertiary'),
3745
+ // background: () => getColor('tertiaryFixedDim'),
3746
+ // contrastCurve: () => getCurve(7),
3747
+ // },
3748
+ // onTertiaryFixedVariant: {
3749
+ // palette: () => palettes.get('tertiary'),
3750
+ // background: () => getColor('tertiaryFixedDim'),
3751
+ // contrastCurve: () => getCurve(4.5),
3752
+ // },
3753
+ ////////////////////////////////////////////////////////////////
3754
+ // Errors [E] //
3755
+ ////////////////////////////////////////////////////////////////
3756
+ error: {
3757
+ palette: () => palettes.get("error"),
3758
+ tone: () => {
3759
+ return c.isDark ? tMinC(palettes.get("error"), 0, 98) : tMaxC(palettes.get("error"));
3760
+ },
3761
+ isBackground: true,
3762
+ background: () => highestSurface(c, colors),
3763
+ contrastCurve: () => getCurve(4.5),
3764
+ adjustTone: () => toneDeltaPair(
3765
+ colors.get("errorContainer"),
3766
+ colors.get("error"),
3767
+ 5,
3768
+ "relative_lighter",
3769
+ true,
3770
+ "farther"
3771
+ )
3772
+ },
3773
+ // errorDim: {
3774
+ // palette: () => palettes.get('error'),
3775
+ // tone: () => tMinC(palettes.get('error')),
3776
+ // isBackground: true,
3777
+ // background: () => getColor('surfaceContainerHigh'),
3778
+ // contrastCurve: () => getCurve(4.5),
3779
+ // adjustTone: () =>
3780
+ // toneDeltaPair(
3781
+ // getColor('errorDim'),
3782
+ // getColor('error'),
3783
+ // 5,
3784
+ // 'darker',
3785
+ // true,
3786
+ // 'farther',
3787
+ // ),
3788
+ // },
3789
+ onError: {
3790
+ palette: () => palettes.get("error"),
3791
+ background: () => colors.get("error"),
3792
+ contrastCurve: () => getCurve(6)
3793
+ },
3794
+ errorContainer: {
3795
+ palette: () => palettes.get("error"),
3796
+ tone: () => {
3797
+ return c.isDark ? tMinC(palettes.get("error"), 30, 93) : tMaxC(palettes.get("error"), 0, 90);
3798
+ },
3799
+ isBackground: true,
3800
+ background: () => highestSurface(c, colors),
3801
+ adjustTone: () => void 0,
3802
+ contrastCurve: () => c.contrastLevel > 0 ? getCurve(1.5) : void 0
3803
+ },
3804
+ onErrorContainer: {
3805
+ palette: () => palettes.get("error"),
3806
+ background: () => colors.get("errorContainer"),
3807
+ contrastCurve: () => getCurve(4.5)
3808
+ },
3809
+ /////////////////////////////////////////////////////////////////
3810
+ // Remapped Colors //
3811
+ /////////////////////////////////////////////////////////////////
3812
+ surfaceVariant: {
3813
+ alias: "surfaceContainerHighest"
3814
+ },
3815
+ surfaceTint: {
3816
+ alias: "primary"
3817
+ },
3818
+ background: {
3819
+ alias: "surface"
3820
+ },
3821
+ onBackground: {
3822
+ alias: "onSurface"
3823
+ }
3824
+ };
3825
+ }
3118
3826
  });
3119
3827
  const Variants = {
3120
3828
  Expressive: expressiveVariant,
3121
3829
  Neutral: neutralVariant,
3122
3830
  TonalSpot: tonalSpotVariant,
3123
3831
  Vibrant: vibrantVariant,
3124
- Fidelity: fidelityVariant
3832
+ Udixio: udixioVariant
3125
3833
  };
3126
3834
  const loader = async (config, load = true) => {
3127
3835
  const api = bootstrap();
@@ -3141,7 +3849,6 @@ const loader = async (config, load = true) => {
3141
3849
  sourceColor,
3142
3850
  variant: variant2
3143
3851
  });
3144
- api.colors.addColors(defaultColors);
3145
3852
  if (palettes) {
3146
3853
  api.palettes.add(palettes);
3147
3854
  }
@@ -3183,12 +3890,13 @@ exports.PluginModule = PluginModule;
3183
3890
  exports.Variant = Variant;
3184
3891
  exports.Variants = Variants;
3185
3892
  exports.bootstrap = bootstrap;
3893
+ exports.capitalizeFirstLetter = capitalizeFirstLetter;
3186
3894
  exports.defaultColors = defaultColors;
3187
3895
  exports.expressiveVariant = expressiveVariant;
3188
3896
  exports.getInitialToneFromBackground = getInitialToneFromBackground;
3189
3897
  exports.getPiecewiseHue = getPiecewiseHue;
3190
3898
  exports.getRotatedHue = getRotatedHue;
3191
- exports.highestSurface = highestSurface;
3899
+ exports.highestSurface = highestSurface$1;
3192
3900
  exports.loader = loader;
3193
3901
  exports.neutralVariant = neutralVariant;
3194
3902
  exports.tonalSpotVariant = tonalSpotVariant;