@multiplatform.one/theme 9.0.1 → 9.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (119) hide show
  1. package/dist/cjs/theme/createThemes.cjs +153 -107
  2. package/dist/cjs/theme/createThemes.native.js +258 -198
  3. package/dist/cjs/theme/createThemes.native.js.map +1 -1
  4. package/dist/esm/audit/constraintAudit.native.js.map +1 -1
  5. package/dist/esm/audit/designTokens.native.js.map +1 -1
  6. package/dist/esm/audit/diffReport.native.js.map +1 -1
  7. package/dist/esm/audit/index.native.js.map +1 -1
  8. package/dist/esm/audit/themeMatrix.native.js.map +1 -1
  9. package/dist/esm/dates.native.js.map +1 -1
  10. package/dist/esm/devWarn.native.js.map +1 -1
  11. package/dist/esm/expo.native.js.map +1 -1
  12. package/dist/esm/figma/figmaTokens.native.js.map +1 -1
  13. package/dist/esm/font.native.js.map +1 -1
  14. package/dist/esm/fonts/createFontLoader.native.js.map +1 -1
  15. package/dist/esm/fonts/index.native.js.map +1 -1
  16. package/dist/esm/fonts/interFaces.native.js.map +1 -1
  17. package/dist/esm/fonts/types.native.js.map +1 -1
  18. package/dist/esm/index.gnome.native.js.map +1 -1
  19. package/dist/esm/index.native.js.map +1 -1
  20. package/dist/esm/keyboardFocusRing.native.js.map +1 -1
  21. package/dist/esm/menuRow.native.js.map +1 -1
  22. package/dist/esm/nativeTwins.native.js.map +1 -1
  23. package/dist/esm/numbers.native.js.map +1 -1
  24. package/dist/esm/theme/Heading.native.js.map +1 -1
  25. package/dist/esm/theme/IconSlot.native.js.map +1 -1
  26. package/dist/esm/theme/Intent.native.js.map +1 -1
  27. package/dist/esm/theme/Preset.native.js.map +1 -1
  28. package/dist/esm/theme/PresetContext.native.js.map +1 -1
  29. package/dist/esm/theme/Surface.native.js.map +1 -1
  30. package/dist/esm/theme/Text.native.js.map +1 -1
  31. package/dist/esm/theme/Tint.native.js.map +1 -1
  32. package/dist/esm/theme/accentInk.native.js.map +1 -1
  33. package/dist/esm/theme/activateThemeConfig.native.js.map +1 -1
  34. package/dist/esm/theme/animations/css.native.js.map +1 -1
  35. package/dist/esm/theme/animations/index.native.js.map +1 -1
  36. package/dist/esm/theme/animations/reactNative.native.js.map +1 -1
  37. package/dist/esm/theme/chartPalette.native.js.map +1 -1
  38. package/dist/esm/theme/colorRules.native.js.map +1 -1
  39. package/dist/esm/theme/controlTiers.native.js.map +1 -1
  40. package/dist/esm/theme/cookies.native.js.map +1 -1
  41. package/dist/esm/theme/createDefaultThemeConfig.native.js.map +1 -1
  42. package/dist/esm/theme/createThemes.mjs +153 -107
  43. package/dist/esm/theme/createThemes.mjs.map +1 -1
  44. package/dist/esm/theme/createThemes.native.js +258 -198
  45. package/dist/esm/theme/createThemes.native.js.map +1 -1
  46. package/dist/esm/theme/dedupeInherited.native.js.map +1 -1
  47. package/dist/esm/theme/defaults/accent.native.js.map +1 -1
  48. package/dist/esm/theme/defaults/base.native.js.map +1 -1
  49. package/dist/esm/theme/defaults/builderOptions.native.js.map +1 -1
  50. package/dist/esm/theme/defaults/categoryFonts.native.js.map +1 -1
  51. package/dist/esm/theme/defaults/fonts.native.js.map +1 -1
  52. package/dist/esm/theme/defaults/house.native.js.map +1 -1
  53. package/dist/esm/theme/defaults/index.native.js.map +1 -1
  54. package/dist/esm/theme/devtools/animationOptions.native.js.map +1 -1
  55. package/dist/esm/theme/devtools/buildSnapshot.native.js.map +1 -1
  56. package/dist/esm/theme/devtools/index.native.js.map +1 -1
  57. package/dist/esm/theme/devtools/knobIcons.native.js.map +1 -1
  58. package/dist/esm/theme/devtools/vizConstants.native.js.map +1 -1
  59. package/dist/esm/theme/dynamicType.native.js.map +1 -1
  60. package/dist/esm/theme/fieldFocus.native.js.map +1 -1
  61. package/dist/esm/theme/fillContrast.native.js.map +1 -1
  62. package/dist/esm/theme/focusState.native.js.map +1 -1
  63. package/dist/esm/theme/fontCategoryMetrics.native.js.map +1 -1
  64. package/dist/esm/theme/fontCategoryStacks.native.js.map +1 -1
  65. package/dist/esm/theme/glyphPaint.native.js.map +1 -1
  66. package/dist/esm/theme/glyphTint.native.js.map +1 -1
  67. package/dist/esm/theme/groupGeometry.native.js.map +1 -1
  68. package/dist/esm/theme/index.native.js.map +1 -1
  69. package/dist/esm/theme/intents.native.js.map +1 -1
  70. package/dist/esm/theme/knobs.native.js.map +1 -1
  71. package/dist/esm/theme/layoutTokens.native.js.map +1 -1
  72. package/dist/esm/theme/listRows.native.js.map +1 -1
  73. package/dist/esm/theme/mergedTokens.native.js.map +1 -1
  74. package/dist/esm/theme/motion.native.js.map +1 -1
  75. package/dist/esm/theme/motionStops.native.js.map +1 -1
  76. package/dist/esm/theme/motionTiming.native.js.map +1 -1
  77. package/dist/esm/theme/nativeMonoFamily.native.js.map +1 -1
  78. package/dist/esm/theme/nativePresetSwitch.native.js.map +1 -1
  79. package/dist/esm/theme/nativeSchemePreference.native.js.map +1 -1
  80. package/dist/esm/theme/nativeTheme.native.js.map +1 -1
  81. package/dist/esm/theme/nativeTransitionProps.native.js.map +1 -1
  82. package/dist/esm/theme/overlaySurfaces.native.js.map +1 -1
  83. package/dist/esm/theme/pageGutter.native.js.map +1 -1
  84. package/dist/esm/theme/preset.types.native.js.map +1 -1
  85. package/dist/esm/theme/presetPreview.native.js.map +1 -1
  86. package/dist/esm/theme/presetStore.native.js.map +1 -1
  87. package/dist/esm/theme/presetUserSync.native.js.map +1 -1
  88. package/dist/esm/theme/presets.native.js.map +1 -1
  89. package/dist/esm/theme/radiusClass.native.js.map +1 -1
  90. package/dist/esm/theme/radiusClassTable.generated.native.js.map +1 -1
  91. package/dist/esm/theme/ramps.native.js.map +1 -1
  92. package/dist/esm/theme/readableColor.native.js.map +1 -1
  93. package/dist/esm/theme/recipeInputs.native.js.map +1 -1
  94. package/dist/esm/theme/recipes.native.js.map +1 -1
  95. package/dist/esm/theme/resolveKnobs.native.js.map +1 -1
  96. package/dist/esm/theme/scale/activeScale.native.js.map +1 -1
  97. package/dist/esm/theme/scale/deriveRecipeInputs.native.js.map +1 -1
  98. package/dist/esm/theme/scale/index.native.js.map +1 -1
  99. package/dist/esm/theme/scale/scaleAttribute.native.js.map +1 -1
  100. package/dist/esm/theme/scale/scaleCss.native.js.map +1 -1
  101. package/dist/esm/theme/scale/scaleFonts.native.js.map +1 -1
  102. package/dist/esm/theme/scale/scaleInputs.native.js.map +1 -1
  103. package/dist/esm/theme/scale/themeScales.native.js.map +1 -1
  104. package/dist/esm/theme/scale/useActiveScale.native.js.map +1 -1
  105. package/dist/esm/theme/schemeStore.native.js.map +1 -1
  106. package/dist/esm/theme/shared.native.js.map +1 -1
  107. package/dist/esm/theme/sizeRecipes.native.js.map +1 -1
  108. package/dist/esm/theme/subsetThemes.native.js.map +1 -1
  109. package/dist/esm/theme/themeValue.native.js.map +1 -1
  110. package/dist/esm/theme/tileSizes.native.js.map +1 -1
  111. package/dist/esm/theme/tintHues.native.js.map +1 -1
  112. package/dist/esm/theme/tokenNumber.native.js.map +1 -1
  113. package/dist/esm/theme/touchManipulation.native.js.map +1 -1
  114. package/dist/esm/theme/useResolvedKnobs.native.js.map +1 -1
  115. package/dist/esm/theme/useTouchSurface.native.js.map +1 -1
  116. package/dist/esm/theme/v3TokenRoles.native.js.map +1 -1
  117. package/package.json +5 -5
  118. package/src/theme/createThemes.ts +233 -141
  119. package/types/theme/createThemes.d.ts.map +1 -1
@@ -464,91 +464,122 @@ function holdSelectionSurface(themes) {
464
464
  }
465
465
  return out;
466
466
  }
467
+ function ownerScope(scopes, name) {
468
+ return scopes.filter(function (scope) {
469
+ return name === scope || name.startsWith(`${scope}_`);
470
+ }).reduce(function (longest, scope) {
471
+ return scope.length > longest.length ? scope : longest;
472
+ }, "");
473
+ }
474
+ function clearsDarkGrounds(color, grounds) {
475
+ var brightest = Math.max(...grounds);
476
+ var luminance = luminanceOf(color);
477
+ return luminance !== null && luminance > brightest && grounds.every(function (ground) {
478
+ return contrastRatio(luminance, ground) >= darkHairlineContrast;
479
+ });
480
+ }
481
+ function darkHairlineOf(scope) {
482
+ var ramp = Array.from({
483
+ length: 12
484
+ }, function (_, index) {
485
+ return scope[`color${index + 1}`];
486
+ });
487
+ var grounds = [scope.background, scope.color4].map(function (color) {
488
+ return luminanceOf(color);
489
+ });
490
+ if (grounds.some(function (ground) {
491
+ return ground === null;
492
+ })) return void 0;
493
+ var hairline = ramp.findIndex(function (color, index) {
494
+ return index < 11 && clearsDarkGrounds(color, grounds);
495
+ });
496
+ return hairline < 0 ? void 0 : {
497
+ ramp,
498
+ hairline
499
+ };
500
+ }
501
+ var darkEdgeStateKeys = ["borderColor", "borderColorHover", "borderColorFocus", "borderColorPress"];
502
+ function darkEdgesOf(name, theme, scopeName, scope, param) {
503
+ var {
504
+ ramp,
505
+ hairline
506
+ } = param;
507
+ var medium = hairline + 1;
508
+ var surface = name === scopeName || theme.background === scope.color4;
509
+ var step = ramp.indexOf(theme.borderColor);
510
+ var shift = surface && step >= 0 ? medium - step : 0;
511
+ var moved = {};
512
+ if ("borderColorHairline" in theme || name === scopeName) moved.borderColorHairline = ramp[hairline];
513
+ if (shift <= 0) return moved;
514
+ var _iteratorNormalCompletion = true,
515
+ _didIteratorError = false,
516
+ _iteratorError = void 0;
517
+ try {
518
+ for (var _iterator = darkEdgeStateKeys[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
519
+ var key = _step.value;
520
+ var at = ramp.indexOf(theme[key]);
521
+ if (at >= 0) moved[key] = ramp[Math.min(11, at + shift)];
522
+ }
523
+ } catch (err) {
524
+ _didIteratorError = true;
525
+ _iteratorError = err;
526
+ } finally {
527
+ try {
528
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
529
+ _iterator.return();
530
+ }
531
+ } finally {
532
+ if (_didIteratorError) {
533
+ throw _iteratorError;
534
+ }
535
+ }
536
+ }
537
+ return moved;
538
+ }
467
539
  function holdDarkEdges(themes) {
468
540
  var out = {
469
541
  ...themes
470
542
  };
471
- var scopes = Object.keys(themes).filter(function (name) {
472
- return /^dark(_[a-z]+)?$/.test(name);
543
+ var scopes = Object.keys(themes).filter(function (name2) {
544
+ return /^dark(_[a-z]+)?$/.test(name2);
473
545
  });
474
- var ownerOf = function ownerOf2(name) {
475
- return scopes.filter(function (scope) {
476
- return name === scope || name.startsWith(`${scope}_`);
477
- }).reduce(function (longest, scope) {
478
- return scope.length > longest.length ? scope : longest;
479
- }, "");
480
- };
481
546
  var _iteratorNormalCompletion = true,
482
547
  _didIteratorError = false,
483
548
  _iteratorError = void 0;
484
549
  try {
485
- var _loop = function () {
550
+ for (var _iterator = scopes[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
486
551
  var scopeName = _step.value;
487
- if (/_(accent|active)$/.test(scopeName)) return "continue";
552
+ if (/_(accent|active)$/.test(scopeName)) continue;
488
553
  var scope = themes[scopeName];
489
- var ramp = Array.from({
490
- length: 12
491
- }, function (_, index) {
492
- return scope[`color${index + 1}`];
493
- });
494
- var grounds = [scope.background, scope.color4].map(function (color) {
495
- return luminanceOf(color);
496
- });
497
- if (grounds.some(function (ground) {
498
- return ground === null;
499
- })) return "continue";
500
- var brightest = Math.max(...grounds);
501
- var clears = function clears2(color) {
502
- var luminance = luminanceOf(color);
503
- return luminance !== null && luminance > brightest && grounds.every(function (ground) {
504
- return contrastRatio(luminance, ground) >= darkHairlineContrast;
505
- });
506
- };
507
- var hairline = ramp.findIndex(function (color, index) {
508
- return index < 11 && clears(color);
509
- });
510
- if (hairline < 0) return "continue";
511
- var medium = hairline + 1;
512
- var _iteratorNormalCompletion2 = true,
513
- _didIteratorError2 = false,
514
- _iteratorError2 = void 0;
554
+ var pick = darkHairlineOf(scope);
555
+ if (!pick) continue;
556
+ var _iteratorNormalCompletion1 = true,
557
+ _didIteratorError1 = false,
558
+ _iteratorError1 = void 0;
515
559
  try {
516
- for (var _iterator2 = Object.entries(themes)[Symbol.iterator](), _step1; !(_iteratorNormalCompletion2 = (_step1 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
560
+ for (var _iterator1 = Object.entries(themes)[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true) {
517
561
  var [name, theme] = _step1.value;
518
- if (ownerOf(name) !== scopeName) continue;
519
- var surface = name === scopeName || theme.background === scope.color4;
520
- var step = ramp.indexOf(theme.borderColor);
521
- var shift = surface && step >= 0 ? medium - step : 0;
522
- var moved = {};
523
- if ("borderColorHairline" in theme || name === scopeName) moved.borderColorHairline = ramp[hairline];
524
- if (shift > 0) {
525
- for (var _i = 0, _iter = ["borderColor", "borderColorHover", "borderColorFocus", "borderColorPress"]; _i < _iter.length; _i++) {
526
- var key = _iter[_i];
527
- var at = ramp.indexOf(theme[key]);
528
- if (at >= 0) moved[key] = ramp[Math.min(11, at + shift)];
529
- }
530
- }
562
+ if (ownerScope(scopes, name) !== scopeName) continue;
531
563
  out[name] = {
532
564
  ...out[name],
533
- ...moved
565
+ ...darkEdgesOf(name, theme, scopeName, scope, pick)
534
566
  };
535
567
  }
536
568
  } catch (err) {
537
- _didIteratorError2 = true;
538
- _iteratorError2 = err;
569
+ _didIteratorError1 = true;
570
+ _iteratorError1 = err;
539
571
  } finally {
540
572
  try {
541
- if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
542
- _iterator2.return();
573
+ if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
574
+ _iterator1.return();
543
575
  }
544
576
  } finally {
545
- if (_didIteratorError2) {
546
- throw _iteratorError2;
577
+ if (_didIteratorError1) {
578
+ throw _iteratorError1;
547
579
  }
548
580
  }
549
581
  }
550
- };
551
- for (var _iterator = scopes[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) _loop();
582
+ }
552
583
  } catch (err) {
553
584
  _didIteratorError = true;
554
585
  _iteratorError = err;
@@ -565,6 +596,117 @@ function holdDarkEdges(themes) {
565
596
  }
566
597
  return out;
567
598
  }
599
+ function firstClearing(neutral, grounds) {
600
+ var lums = grounds.map(function (ground) {
601
+ return luminanceOf(ground);
602
+ });
603
+ if (lums.some(function (lum) {
604
+ return lum === null;
605
+ })) return -1;
606
+ var darkest = Math.min(...lums);
607
+ var brightest = Math.max(...lums);
608
+ var light = isLightGround(grounds[0]);
609
+ return neutral.findIndex(function (color) {
610
+ var lum = luminanceOf(color);
611
+ return lum !== null && (light ? lum < darkest : lum > brightest) && lums.every(function (ground) {
612
+ return contrastRatio(lum, ground) >= minContrastRatio;
613
+ });
614
+ });
615
+ }
616
+ function inheritedValue(out, themes, name, key) {
617
+ for (var at = name; at; at = at.slice(0, Math.max(0, at.lastIndexOf("_")))) {
618
+ var _out_at;
619
+ var _this;
620
+ var value = (_this = (_out_at = out[at]) !== null && _out_at !== void 0 ? _out_at : themes[at]) === null || _this === void 0 ? void 0 : _this[key];
621
+ if (value !== void 0) return value;
622
+ if (!at.includes("_")) break;
623
+ }
624
+ return void 0;
625
+ }
626
+ function nearestStep(ramp, color) {
627
+ var lum = luminanceOf(color);
628
+ if (lum === null) return -1;
629
+ return ramp.reduce(function (best, step, index) {
630
+ var _luminanceOf, _luminanceOf1;
631
+ return Math.abs(((_luminanceOf = luminanceOf(step)) !== null && _luminanceOf !== void 0 ? _luminanceOf : 2) - lum) < Math.abs(((_luminanceOf1 = luminanceOf(ramp[best])) !== null && _luminanceOf1 !== void 0 ? _luminanceOf1 : 2) - lum) ? index : best;
632
+ }, 0);
633
+ }
634
+ function fieldEdgesOf(themes, out, neutral, scopeName) {
635
+ var scope = themes[scopeName];
636
+ var field = `${scopeName}_Input`;
637
+ var edge = firstClearing(neutral, [scope.background, inheritedValue(out, themes, field, "background")]);
638
+ if (edge < 0) return void 0;
639
+ var ramp = Array.from({
640
+ length: 12
641
+ }, function (_, index) {
642
+ return scope[`color${index + 1}`];
643
+ });
644
+ var rest = nearestStep(ramp, inheritedValue(out, themes, field, "borderColor"));
645
+ var hover = nearestStep(ramp, inheritedValue(out, themes, field, "borderColorHover"));
646
+ return {
647
+ borderColorField: neutral[edge],
648
+ borderColorFieldHover: neutral[Math.min(11, Math.max(edge, edge + hover - rest))]
649
+ };
650
+ }
651
+ function intentFieldEdges(themes, out, scopeName, pages) {
652
+ var scope = themes[scopeName];
653
+ var field = `${scopeName}_Input`;
654
+ var ramp = Array.from({
655
+ length: 12
656
+ }, function (_, index) {
657
+ return scope[`color${index + 1}`];
658
+ });
659
+ var edge = firstClearing(ramp, [...pages, inheritedValue(out, themes, field, "background")]);
660
+ if (edge < 0) return {
661
+ borderColorField: inheritedValue(out, themes, field, "borderColor"),
662
+ borderColorFieldHover: inheritedValue(out, themes, field, "borderColorHover")
663
+ };
664
+ return {
665
+ borderColorField: ramp[edge],
666
+ borderColorFieldHover: ramp[Math.min(11, edge + 1)]
667
+ };
668
+ }
669
+ function controlEdgePatch(themes, out, scopeName, param) {
670
+ var {
671
+ scheme,
672
+ neutral,
673
+ pages,
674
+ rootFields,
675
+ rootControl
676
+ } = param;
677
+ var scope = themes[scopeName];
678
+ var patch = {};
679
+ if (scheme === "dark" && "switchTrackOff" in scope) patch.switchTrackOffBorder = scope.switchTrackOff;
680
+ if (semanticIntentNames.has(scopeName.slice(scheme.length + 1))) return Object.assign(patch, intentFieldEdges(themes, out, scopeName, pages));
681
+ var fields = fieldEdgesOf(themes, out, neutral, scopeName);
682
+ if (fields) {
683
+ var _iteratorNormalCompletion = true,
684
+ _didIteratorError = false,
685
+ _iteratorError = void 0;
686
+ try {
687
+ for (var _iterator = Object.entries(fields)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
688
+ var [key, value] = _step.value;
689
+ if (value !== rootFields[key]) patch[key] = value;
690
+ }
691
+ } catch (err) {
692
+ _didIteratorError = true;
693
+ _iteratorError = err;
694
+ } finally {
695
+ try {
696
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
697
+ _iterator.return();
698
+ }
699
+ } finally {
700
+ if (_didIteratorError) {
701
+ throw _iteratorError;
702
+ }
703
+ }
704
+ }
705
+ }
706
+ var control = firstClearing(neutral, [scope.background]);
707
+ if (control >= 0 && control !== rootControl) patch.borderColorControl = neutral[control];
708
+ return patch;
709
+ }
568
710
  function holdControlEdges(themes) {
569
711
  var _loop = function (_i2, _iter2) {
570
712
  var scheme = _iter2[_i2];
@@ -575,32 +717,7 @@ function holdControlEdges(themes) {
575
717
  }, function (_, index) {
576
718
  return root[`color${index + 1}`];
577
719
  });
578
- var fieldEdges = function fieldEdges2(scopeName) {
579
- var scope = themes[scopeName];
580
- var field = `${scopeName}_Input`;
581
- var edge = firstClearing(neutral, [scope.background, resolved(field, "background")]);
582
- if (edge < 0) return void 0;
583
- var ramp = Array.from({
584
- length: 12
585
- }, function (_, index) {
586
- return scope[`color${index + 1}`];
587
- });
588
- var stepOf = function stepOf2(color) {
589
- var lum = luminanceOf(color);
590
- if (lum === null) return -1;
591
- return ramp.reduce(function (best, step, index) {
592
- var _luminanceOf, _luminanceOf1;
593
- return Math.abs(((_luminanceOf = luminanceOf(step)) !== null && _luminanceOf !== void 0 ? _luminanceOf : 2) - lum) < Math.abs(((_luminanceOf1 = luminanceOf(ramp[best])) !== null && _luminanceOf1 !== void 0 ? _luminanceOf1 : 2) - lum) ? index : best;
594
- }, 0);
595
- };
596
- var rest = stepOf(resolved(field, "borderColor"));
597
- var hover = stepOf(resolved(field, "borderColorHover"));
598
- return {
599
- borderColorField: neutral[edge],
600
- borderColorFieldHover: neutral[Math.min(11, Math.max(edge, edge + hover - rest))]
601
- };
602
- };
603
- var rootFields = fieldEdges(scheme);
720
+ var rootFields = fieldEdgesOf(themes, out, neutral, scheme);
604
721
  var rootControl = firstClearing(neutral, [root.background]);
605
722
  if (!rootFields || rootControl < 0) return "continue";
606
723
  out[scheme] = {
@@ -617,60 +734,25 @@ function holdControlEdges(themes) {
617
734
  }).map(function (name) {
618
735
  return themes[name].background;
619
736
  })];
737
+ var context = {
738
+ scheme,
739
+ neutral,
740
+ pages,
741
+ rootFields,
742
+ rootControl
743
+ };
620
744
  var _iteratorNormalCompletion = true,
621
745
  _didIteratorError = false,
622
746
  _iteratorError = void 0;
623
747
  try {
624
- var _loop2 = function () {
748
+ for (var _iterator = scopes[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
625
749
  var scopeName = _step.value;
626
- var scope = themes[scopeName];
627
- var patch = {};
628
- if (scheme === "dark" && "switchTrackOff" in scope) patch.switchTrackOffBorder = scope.switchTrackOff;
629
- if (semanticIntentNames.has(scopeName.slice(scheme.length + 1))) {
630
- var field = `${scopeName}_Input`;
631
- var ramp = Array.from({
632
- length: 12
633
- }, function (_, index) {
634
- return scope[`color${index + 1}`];
635
- });
636
- var edge = firstClearing(ramp, [...pages, resolved(field, "background")]);
637
- patch.borderColorField = edge < 0 ? resolved(field, "borderColor") : ramp[edge];
638
- patch.borderColorFieldHover = edge < 0 ? resolved(field, "borderColorHover") : ramp[Math.min(11, edge + 1)];
639
- } else {
640
- var fields = fieldEdges(scopeName);
641
- if (fields) {
642
- var _iteratorNormalCompletion2 = true,
643
- _didIteratorError2 = false,
644
- _iteratorError2 = void 0;
645
- try {
646
- for (var _iterator2 = Object.entries(fields)[Symbol.iterator](), _step1; !(_iteratorNormalCompletion2 = (_step1 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
647
- var [key, value] = _step1.value;
648
- if (value !== rootFields[key]) patch[key] = value;
649
- }
650
- } catch (err) {
651
- _didIteratorError2 = true;
652
- _iteratorError2 = err;
653
- } finally {
654
- try {
655
- if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
656
- _iterator2.return();
657
- }
658
- } finally {
659
- if (_didIteratorError2) {
660
- throw _iteratorError2;
661
- }
662
- }
663
- }
664
- }
665
- var control = firstClearing(neutral, [scope.background]);
666
- if (control >= 0 && control !== rootControl) patch.borderColorControl = neutral[control];
667
- }
750
+ var patch = controlEdgePatch(themes, out, scopeName, context);
668
751
  if (Object.keys(patch).length > 0) out[scopeName] = {
669
752
  ...out[scopeName],
670
753
  ...patch
671
754
  };
672
- };
673
- for (var _iterator = scopes[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) _loop2();
755
+ }
674
756
  } catch (err) {
675
757
  _didIteratorError = true;
676
758
  _iteratorError = err;
@@ -689,33 +771,6 @@ function holdControlEdges(themes) {
689
771
  var out = {
690
772
  ...themes
691
773
  };
692
- var firstClearing = function firstClearing2(neutral, grounds) {
693
- var lums = grounds.map(function (ground) {
694
- return luminanceOf(ground);
695
- });
696
- if (lums.some(function (lum) {
697
- return lum === null;
698
- })) return -1;
699
- var darkest = Math.min(...lums);
700
- var brightest = Math.max(...lums);
701
- var light = isLightGround(grounds[0]);
702
- return neutral.findIndex(function (color) {
703
- var lum = luminanceOf(color);
704
- return lum !== null && (light ? lum < darkest : lum > brightest) && lums.every(function (ground) {
705
- return contrastRatio(lum, ground) >= minContrastRatio;
706
- });
707
- });
708
- };
709
- var resolved = function resolved2(name, key) {
710
- for (var at = name; at; at = at.slice(0, Math.max(0, at.lastIndexOf("_")))) {
711
- var _out_at;
712
- var _this;
713
- var value = (_this = (_out_at = out[at]) !== null && _out_at !== void 0 ? _out_at : themes[at]) === null || _this === void 0 ? void 0 : _this[key];
714
- if (value !== void 0) return value;
715
- if (!at.includes("_")) break;
716
- }
717
- return void 0;
718
- };
719
774
  for (var _i = 0, _iter = ["light", "dark"]; _i < _iter.length; _i++) _loop(_i, _iter);
720
775
  return out;
721
776
  }
@@ -848,24 +903,15 @@ function holdSwitchTrack(themes) {
848
903
  _didIteratorError = false,
849
904
  _iteratorError = void 0;
850
905
  try {
851
- var _loop = function () {
906
+ for (var _iterator = semanticIntentNames[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
852
907
  var intent = _step.value;
853
- var _scope_accentBackground;
854
908
  var scope = themes[`${scheme}_${intent}`];
855
- var off = luminanceOf(paint.switchTrackOff);
856
- if (!(scope === null || scope === void 0 ? void 0 : scope.color4) || !scope.color5 || off === null) return "continue";
857
- var holds = inSwitchOffBand(paint.switchTrackOff, scope.color4) && [scope.color4, scope.color5].every(function (ground) {
858
- var _luminanceOf;
859
- return contrastRatio(off, (_luminanceOf = luminanceOf(ground)) !== null && _luminanceOf !== void 0 ? _luminanceOf : off) >= plateContrastRatio;
860
- });
861
- if (holds) return "continue";
862
- var track = switchTrackPaint(base, (_scope_accentBackground = scope.accentBackground) !== null && _scope_accentBackground !== void 0 ? _scope_accentBackground : base.accentBackground, scope.color4, [base.color4, scope.color4, scope.color5]);
909
+ var track = intentSwitchTrack(base, scope, paint);
863
910
  if (track) out[`${scheme}_${intent}`] = {
864
911
  ...scope,
865
912
  ...track
866
913
  };
867
- };
868
- for (var _iterator = semanticIntentNames[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) _loop();
914
+ }
869
915
  } catch (err) {
870
916
  _didIteratorError = true;
871
917
  _iteratorError = err;
@@ -883,6 +929,17 @@ function holdSwitchTrack(themes) {
883
929
  }
884
930
  return out;
885
931
  }
932
+ function intentSwitchTrack(base, scope, paint) {
933
+ var _scope_accentBackground;
934
+ var off = luminanceOf(paint.switchTrackOff);
935
+ if (!(scope === null || scope === void 0 ? void 0 : scope.color4) || !scope.color5 || off === null) return void 0;
936
+ var holds = inSwitchOffBand(paint.switchTrackOff, scope.color4) && [scope.color4, scope.color5].every(function (ground) {
937
+ var _luminanceOf;
938
+ return contrastRatio(off, (_luminanceOf = luminanceOf(ground)) !== null && _luminanceOf !== void 0 ? _luminanceOf : off) >= plateContrastRatio;
939
+ });
940
+ if (holds) return void 0;
941
+ return switchTrackPaint(base, (_scope_accentBackground = scope.accentBackground) !== null && _scope_accentBackground !== void 0 ? _scope_accentBackground : base.accentBackground, scope.color4, [base.color4, scope.color4, scope.color5]);
942
+ }
886
943
  function switchTrackPaint(base, onFill, ground) {
887
944
  var raised = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : [];
888
945
  var _ref, _inBand_find;
@@ -1202,7 +1259,8 @@ function holdColorThemeAccent(themes) {
1202
1259
  var _luminanceOf;
1203
1260
  return contrastRatio(rootOn, (_luminanceOf = luminanceOf(ground)) !== null && _luminanceOf !== void 0 ? _luminanceOf : rootOn) >= plateContrastRatio;
1204
1261
  });
1205
- var track = rootHolds ? void 0 : switchTrackPaint(base, fill, switchGround, isLightGround(scope.background) ? [] : [base.color4, scope.color4, scope.color5]);
1262
+ var trackGrounds = isLightGround(scope.background) ? [] : [base.color4, scope.color4, scope.color5];
1263
+ var track = rootHolds ? void 0 : switchTrackPaint(base, fill, switchGround, trackGrounds);
1206
1264
  var _iteratorNormalCompletion2 = true,
1207
1265
  _didIteratorError2 = false,
1208
1266
  _iteratorError2 = void 0;
@@ -1392,37 +1450,26 @@ function holdHouseAccent(themes) {
1392
1450
  return out;
1393
1451
  }
1394
1452
  function holdHouseIdentityInk(themes) {
1395
- var _loop = function (_i2, _iter2) {
1396
- var scheme = _iter2[_i2];
1453
+ var out = {
1454
+ ...themes
1455
+ };
1456
+ for (var _i = 0, _iter = ["light", "dark"]; _i < _iter.length; _i++) {
1457
+ var scheme = _iter[_i];
1397
1458
  var _themes_;
1398
1459
  var base = themes[scheme];
1399
1460
  var blueInk = (_themes_ = themes[`${scheme}_blue`]) === null || _themes_ === void 0 ? void 0 : _themes_.identityInk;
1400
- if (!(base === null || base === void 0 ? void 0 : base.identityInk) || !blueInk || base.identityInk === blueInk) return "continue";
1401
- var held = Array.from({
1402
- length: 12
1403
- }, function (_, index) {
1404
- return index + 1;
1405
- }).every(function (step) {
1406
- return base[`accent${step}`] !== void 0 && base[`accent${step}`] === base[`blue${step}`];
1407
- });
1408
- if (!held) return "continue";
1461
+ if (!(base === null || base === void 0 ? void 0 : base.identityInk) || !blueInk || base.identityInk === blueInk) continue;
1462
+ if (!accentIsBlue(base)) continue;
1409
1463
  var _iteratorNormalCompletion = true,
1410
1464
  _didIteratorError = false,
1411
1465
  _iteratorError = void 0;
1412
1466
  try {
1413
1467
  for (var _iterator = Object.entries(themes)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
1414
1468
  var [name, theme] = _step.value;
1415
- if (name !== scheme && !name.startsWith(`${scheme}_`)) continue;
1416
- var scope = name.split("_")[1];
1417
- if (scope === "accent" || childrenHues.includes(scope)) continue;
1418
- if (theme.identityInk !== base.identityInk) continue;
1419
- var values = resolveThemeThroughParents(themes, name);
1420
- if (pickIdentityInk([blueInk], pageSurfaces(name, values)) === blueInk) {
1421
- out[name] = {
1422
- ...theme,
1423
- identityInk: blueInk
1424
- };
1425
- }
1469
+ if (takesBlueInk(themes, scheme, name, theme, base, blueInk)) out[name] = {
1470
+ ...theme,
1471
+ identityInk: blueInk
1472
+ };
1426
1473
  }
1427
1474
  } catch (err) {
1428
1475
  _didIteratorError = true;
@@ -1438,13 +1485,26 @@ function holdHouseIdentityInk(themes) {
1438
1485
  }
1439
1486
  }
1440
1487
  }
1441
- };
1442
- var out = {
1443
- ...themes
1444
- };
1445
- for (var _i = 0, _iter = ["light", "dark"]; _i < _iter.length; _i++) _loop(_i, _iter);
1488
+ }
1446
1489
  return out;
1447
1490
  }
1491
+ function accentIsBlue(base) {
1492
+ return Array.from({
1493
+ length: 12
1494
+ }, function (_, index) {
1495
+ return index + 1;
1496
+ }).every(function (step) {
1497
+ return base[`accent${step}`] !== void 0 && base[`accent${step}`] === base[`blue${step}`];
1498
+ });
1499
+ }
1500
+ function takesBlueInk(themes, scheme, name, theme, base, blueInk) {
1501
+ if (name !== scheme && !name.startsWith(`${scheme}_`)) return false;
1502
+ var scope = name.split("_")[1];
1503
+ if (scope === "accent" || childrenHues.includes(scope)) return false;
1504
+ if (theme.identityInk !== base.identityInk) return false;
1505
+ var values = resolveThemeThroughParents(themes, name);
1506
+ return pickIdentityInk([blueInk], pageSurfaces(name, values)) === blueInk;
1507
+ }
1448
1508
  var defaultLightShadows = {
1449
1509
  shadow1: "rgba(0,0,0,0.04)",
1450
1510
  shadow2: "rgba(0,0,0,0.08)",