@aglyn/plugins-ai 1.9.0 → 1.10.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 (82) hide show
  1. package/package.json +17 -17
  2. package/src/lib/components/ai-job-requests.d.ts +5 -0
  3. package/src/lib/components/ai-job-requests.js +4 -0
  4. package/src/lib/components/ai-job-requests.js.map +1 -1
  5. package/src/lib/components/ai-site-build-page.component.js +10 -3
  6. package/src/lib/components/ai-site-build-page.component.js.map +1 -1
  7. package/src/lib/components/ai-site-import-finish.component.d.ts +40 -0
  8. package/src/lib/components/ai-site-import-finish.component.js +174 -0
  9. package/src/lib/components/ai-site-import-finish.component.js.map +1 -0
  10. package/src/lib/components/ai-site-import-job.component.d.ts +11 -3
  11. package/src/lib/components/ai-site-import-job.component.js +220 -135
  12. package/src/lib/components/ai-site-import-job.component.js.map +1 -1
  13. package/src/lib/components/ai-site-import-start.component.d.ts +11 -2
  14. package/src/lib/components/ai-site-import-start.component.js +27 -5
  15. package/src/lib/components/ai-site-import-start.component.js.map +1 -1
  16. package/src/lib/components/ai-site-start-card.component.js +1 -1
  17. package/src/lib/components/ai-site-start-card.component.js.map +1 -1
  18. package/src/lib/jobs/ai-build-capabilities.js +2 -2
  19. package/src/lib/jobs/ai-build-capabilities.js.map +1 -1
  20. package/src/lib/jobs/ai-job-import-step.d.ts +2 -0
  21. package/src/lib/jobs/ai-job-import-step.js +31 -8
  22. package/src/lib/jobs/ai-job-import-step.js.map +1 -1
  23. package/src/lib/jobs/ai-job-page-language.d.ts +40 -2
  24. package/src/lib/jobs/ai-job-page-language.js +188 -9
  25. package/src/lib/jobs/ai-job-page-language.js.map +1 -1
  26. package/src/lib/jobs/ai-job-page-step.js +2 -0
  27. package/src/lib/jobs/ai-job-page-step.js.map +1 -1
  28. package/src/lib/jobs/ai-job-privacy-step.d.ts +5 -0
  29. package/src/lib/jobs/ai-job-privacy-step.js +9 -4
  30. package/src/lib/jobs/ai-job-privacy-step.js.map +1 -1
  31. package/src/lib/jobs/ai-job-text-step.d.ts +7 -1
  32. package/src/lib/jobs/ai-job-text-step.js.map +1 -1
  33. package/src/lib/jobs/ai-site-import-compile.d.ts +13 -2
  34. package/src/lib/jobs/ai-site-import-compile.js +115 -21
  35. package/src/lib/jobs/ai-site-import-compile.js.map +1 -1
  36. package/src/lib/jobs/ai-site-import-document.d.ts +5 -1
  37. package/src/lib/jobs/ai-site-import-document.js +5 -1
  38. package/src/lib/jobs/ai-site-import-document.js.map +1 -1
  39. package/src/lib/jobs/ai-site-import-look.d.ts +16 -4
  40. package/src/lib/jobs/ai-site-import-look.js +54 -13
  41. package/src/lib/jobs/ai-site-import-look.js.map +1 -1
  42. package/src/lib/jobs/ai-site-import-wording.d.ts +187 -0
  43. package/src/lib/jobs/ai-site-import-wording.js +747 -0
  44. package/src/lib/jobs/ai-site-import-wording.js.map +1 -0
  45. package/src/lib/layout-language/ai-layout-compiler.d.ts +12 -1
  46. package/src/lib/layout-language/ai-layout-compiler.js +29 -30
  47. package/src/lib/layout-language/ai-layout-compiler.js.map +1 -1
  48. package/src/lib/layout-language/ai-layout-language.d.ts +12 -0
  49. package/src/lib/layout-language/ai-layout-language.js.map +1 -1
  50. package/src/lib/model/ai-site-import-fidelity.d.ts +211 -2
  51. package/src/lib/model/ai-site-import-fidelity.js +1011 -14
  52. package/src/lib/model/ai-site-import-fidelity.js.map +1 -1
  53. package/src/lib/model/ai-site-import-report.d.ts +52 -1
  54. package/src/lib/model/ai-site-import-report.js +102 -5
  55. package/src/lib/model/ai-site-import-report.js.map +1 -1
  56. package/src/lib/model/ai-site-import-view.d.ts +62 -2
  57. package/src/lib/model/ai-site-import-view.js +83 -4
  58. package/src/lib/model/ai-site-import-view.js.map +1 -1
  59. package/src/lib/model/ai-site-import.d.ts +122 -6
  60. package/src/lib/model/ai-site-import.js +202 -9
  61. package/src/lib/model/ai-site-import.js.map +1 -1
  62. package/src/lib/model/ai-site-look.d.ts +51 -0
  63. package/src/lib/model/ai-site-look.js +205 -29
  64. package/src/lib/model/ai-site-look.js.map +1 -1
  65. package/src/lib/runtime/ai-doctrine-validators.d.ts +19 -0
  66. package/src/lib/runtime/ai-doctrine-validators.js +25 -0
  67. package/src/lib/runtime/ai-doctrine-validators.js.map +1 -1
  68. package/src/lib/runtime/ai-doctrine.js +4 -1
  69. package/src/lib/runtime/ai-doctrine.js.map +1 -1
  70. package/src/lib/server/ai-allotments.js +4 -2
  71. package/src/lib/server/ai-allotments.js.map +1 -1
  72. package/src/lib/server/ai-jobs-resume.js +32 -5
  73. package/src/lib/server/ai-jobs-resume.js.map +1 -1
  74. package/src/lib/site-import/fixtures/site-import-fidelity-replay.d.ts +36 -10
  75. package/src/lib/site-import/fixtures/site-import-fidelity-replay.js +48 -4
  76. package/src/lib/site-import/fixtures/site-import-fidelity-replay.js.map +1 -1
  77. package/src/lib/site-import/fixtures/site-look-slate.d.ts +27 -0
  78. package/src/lib/site-import/fixtures/site-look-slate.js +29 -0
  79. package/src/lib/site-import/fixtures/site-look-slate.js.map +1 -0
  80. package/src/lib/site-import/site-import-layout.d.ts +19 -5
  81. package/src/lib/site-import/site-import-layout.js +137 -16
  82. package/src/lib/site-import/site-import-layout.js.map +1 -1
@@ -92,12 +92,43 @@ export interface AiSiteStyle {
92
92
  * pages move in its kind's mood.
93
93
  */
94
94
  motion?: AiSiteMotionStyle;
95
+ /**
96
+ * How a site brought in was finished when its look was drawn (AGL-4152).
97
+ * `keep` (Keep my site) holds the source's look closer: its page ground is
98
+ * kept down to a lightness of 0.85 where the theme's text reads on it, and
99
+ * its dark ground, button case and filled buttons' own fill are pinned
100
+ * below. `improve` pins only the brand's colors and fonts, so the base
101
+ * shows. Absent on every other style, which draws as it always did.
102
+ */
103
+ finish?: 'keep' | 'improve';
95
104
  /**
96
105
  * A site brought in's own page ground (AGL-4108), `#rrggbb`: the color its
97
106
  * source's pages sit on, where it is light enough for the theme's text.
98
107
  * Absent, the ground is drawn as `ground` says.
99
108
  */
100
109
  page?: string;
110
+ /**
111
+ * A site brought in's own dark ground (AGL-4152), `#rrggbb`, kept by Keep
112
+ * my site: the dark scheme's page, with its paper a step lighter, where
113
+ * white reads on it. Absent, the dark scheme's own.
114
+ */
115
+ darkPage?: string;
116
+ /**
117
+ * A site brought in's button case (AGL-4152), kept by Keep my site: the
118
+ * button Text Style in capitals, or not. Absent, the buttons' own style
119
+ * (`caps`) says.
120
+ */
121
+ buttonCase?: 'upper' | 'none';
122
+ /**
123
+ * A site brought in's filled buttons as its source draws them (AGL-4152),
124
+ * `#rrggbb`, kept by Keep my site: their fill, and the words' color on it.
125
+ * Where those words read on the fill, the fill is the brand where it reads
126
+ * on the page, else the theme's filled buttons alone are drawn in it.
127
+ * Absent, every button is drawn in the brand.
128
+ */
129
+ buttonFill?: string;
130
+ /** The words' color on {@link AiSiteStyle.buttonFill}, `#rrggbb`, as the source draws them (AGL-4152). */
131
+ buttonText?: string;
101
132
  /**
102
133
  * A site brought in's own type (AGL-4108): the families its source sets
103
134
  * its body and its headings in, where the theme font catalog has them,
@@ -188,6 +219,20 @@ export declare function aiHexOklch(hex: string): {
188
219
  C: number;
189
220
  h: number;
190
221
  };
222
+ /** How far apart two colors look (AGL-4152): their distance in OKLab, 0 for one color. */
223
+ export declare function aiOklabDistance(a: string, b: string): number;
224
+ /**
225
+ * The theme's filled buttons drawn in a site brought in's own fill (AGL-4152),
226
+ * where the brand cannot be that fill. The fill is the primary's lighter
227
+ * shade in both schemes (on the dark ground, its nearest shade that stands
228
+ * apart from it); the label a palette role, white or black on the source's
229
+ * words' own side of the fill; and outlined buttons take the fill too where
230
+ * it reads on both schemes' pages.
231
+ */
232
+ export interface AiSiteOwnButton {
233
+ label: 'common.white' | 'common.black';
234
+ outlined: boolean;
235
+ }
191
236
  /** How far apart two hues sit on the wheel, in degrees: 0 to 180. */
192
237
  export declare function aiHueGap(a: number, b: number): number;
193
238
  /**
@@ -202,6 +247,12 @@ export declare function aiSiteColors(style: AiSiteStyle): {
202
247
  light: HostThemeSchemeColors;
203
248
  dark: HostThemeSchemeColors;
204
249
  };
250
+ /**
251
+ * The filled buttons a style draws in its source's own fill (AGL-4152), as
252
+ * its theme's button styles take them, or `null` where they are drawn in the
253
+ * brand: every style but a site brought in kept by Keep my site.
254
+ */
255
+ export declare function aiSiteOwnButton(style: AiSiteStyle): AiSiteOwnButton | null;
205
256
  /**
206
257
  * The kinds whose titles are their design (AGL-3660): a portfolio's or a
207
258
  * studio's statement, a photographer's name over a cover, a publication's
@@ -713,6 +713,56 @@ const ratio = (a, b)=>{
713
713
  }
714
714
  return lightness;
715
715
  }
716
+ const SOLID = /^#[0-9a-f]{6}$/i;
717
+ /** A `#rrggbb` color in lower case, or `null`. */ const solid = (value)=>typeof value === 'string' && SOLID.test(value) ? value.toLowerCase() : null;
718
+ /** How far apart two colors look (AGL-4152): their distance in OKLab, 0 for one color. */ export function aiOklabDistance(a, b) {
719
+ const one = aiHexOklch(a);
720
+ const two = aiHexOklch(b);
721
+ const at = (color)=>[
722
+ color.C * Math.cos(color.h * Math.PI / 180),
723
+ color.C * Math.sin(color.h * Math.PI / 180)
724
+ ];
725
+ const [a1, b1] = at(one);
726
+ const [a2, b2] = at(two);
727
+ return Math.hypot(one.L - two.L, a1 - a2, b1 - b2);
728
+ }
729
+ /**
730
+ * A label's nearest shade that reads on its fill at `min` (AGL-4152): the
731
+ * label itself, else stepped further from the fill's lightness, its hue
732
+ * kept. `null` where only a shade past the fill's own lightness would read:
733
+ * white words on a light fill have no lighter shade to go to.
734
+ */ function shadeOn(label, fill, min) {
735
+ if (ratio(label, fill) >= min) return label;
736
+ const own = aiHexOklch(label);
737
+ const lighter = own.L >= aiHexOklch(fill).L;
738
+ for(let L = own.L; lighter ? L < 1 : L > 0; L += lighter ? 0.01 : -0.01){
739
+ const shade = aiOklchHex(L, own.C, own.h);
740
+ if (ratio(shade, fill) >= min) return shade;
741
+ }
742
+ const end = lighter ? '#ffffff' : '#000000';
743
+ return ratio(end, fill) >= min ? end : null;
744
+ }
745
+ /** How far a fill must sit from a ground to be drawn on it as a fill of its own (AGL-4152), in OKLab. */ const OWN_FILL_APART = 0.1;
746
+ /** The colors the palette roles an own-fill button's label names stand for. */ const COMMON = {
747
+ 'common.white': '#ffffff',
748
+ 'common.black': '#000000'
749
+ };
750
+ /**
751
+ * A fill as a ground carries it (AGL-4152): itself where it stands apart
752
+ * from the ground, else its nearest shade that does, stepped away from the
753
+ * ground's lightness, its hue kept. `null` where that shade no longer
754
+ * carries its label at 4.5:1.
755
+ */ function apartFrom(fill, ground, label) {
756
+ if (aiOklabDistance(fill, ground) >= OWN_FILL_APART) return fill;
757
+ const own = aiHexOklch(fill);
758
+ const up = own.L >= aiHexOklch(ground).L;
759
+ for(let L = own.L; up ? L <= 1 : L >= 0; L += up ? 0.01 : -0.01){
760
+ const shade = aiOklchHex(L, own.C, own.h);
761
+ if (aiOklabDistance(shade, ground) >= OWN_FILL_APART) return ratio(label, shade) >= 4.5 ? shade : null;
762
+ }
763
+ return null;
764
+ }
765
+ /** The step the dark scheme's paper sits above its page. */ const DARK_PAPER_STEP = 0.045;
716
766
  /** The label color of a fill: white or a deep ink of its hue, whichever reads at 4.5:1, or better. */ function labelOn(fill, h) {
717
767
  const white = '#ffffff';
718
768
  const ink = aiOklchHex(0.2, 0.04, h);
@@ -741,7 +791,21 @@ const START_L = {
741
791
  vivid: 0.56
742
792
  };
743
793
  /** Both schemes' colors for a style. */ export function aiSiteColors(style) {
744
- var _ref, _ref1;
794
+ const { light, dark } = colorsOf(style);
795
+ return {
796
+ light,
797
+ dark
798
+ };
799
+ }
800
+ /**
801
+ * The filled buttons a style draws in its source's own fill (AGL-4152), as
802
+ * its theme's button styles take them, or `null` where they are drawn in the
803
+ * brand: every style but a site brought in kept by Keep my site.
804
+ */ export function aiSiteOwnButton(style) {
805
+ return colorsOf(style).button;
806
+ }
807
+ function colorsOf(style) {
808
+ var _ref, _ref1, _ref2, _ref3;
745
809
  const next = random(style.seed ^ 0x9e3779b9);
746
810
  const neutral = style.chroma === 'neutral';
747
811
  const brand = style.brand ? aiHexOklch(style.brand) : null;
@@ -749,6 +813,10 @@ const START_L = {
749
813
  const chroma = (_ref1 = brand == null ? void 0 : brand.C) != null ? _ref1 : CHROMA[style.chroma] * (0.9 + next() * 0.2);
750
814
  const groundChroma = neutral ? 0.3 : 1;
751
815
  const white = '#ffffff';
816
+ const textChroma = neutral ? 0.006 : 0.02;
817
+ const ink = aiOklchHex(0.22, textChroma, h);
818
+ const darkInk = aiOklchHex(0.95, 0.008, h);
819
+ const keep = style.finish === 'keep';
752
820
  // The page grounds.
753
821
  const grounds = {
754
822
  white: {
@@ -789,14 +857,52 @@ const START_L = {
789
857
  }
790
858
  };
791
859
  const ground = grounds[style.ground];
792
- // A site brought in keeps the ground its source's pages sit on (AGL-4108), where its text reads on it.
793
- const own = style.page && /^#[0-9a-f]{6}$/i.test(style.page) && aiHexOklch(style.page).L >= 0.9 ? style.page.toLowerCase() : null;
860
+ // A site brought in keeps the ground its source's pages sit on (AGL-4108), where its text reads on it:
861
+ // kept as it is, down to a lightness of 0.85 where the words read on it at 4.5 (AGL-4152).
862
+ const page = solid(style.page);
863
+ const own = page && (keep ? aiHexOklch(page).L >= 0.85 && ratio(ink, page) >= 4.5 : aiHexOklch(page).L >= 0.9) ? page : null;
794
864
  const background = own != null ? own : aiOklchHex(ground.L, ground.C * groundChroma, ground.h);
795
865
  const paper = aiOklchHex(ground.paper[0], ground.paper[1] * groundChroma, ground.h);
866
+ // The dark scheme's ground: its own, or a site brought in's (AGL-4152) where white and the
867
+ // scheme's words read on it and on its paper a step lighter.
868
+ const darkGround = style.ground === 'tinted' ? 0.024 : style.ground === 'warm' ? 0.014 : 0.012;
869
+ const darkOwn = (()=>{
870
+ const hex = solid(style.darkPage);
871
+ if (!hex) return null;
872
+ const at = aiHexOklch(hex);
873
+ const darkPaper = aiOklchHex(at.L + DARK_PAPER_STEP, at.C, at.h);
874
+ return ratio(white, hex) >= 4.5 && ratio(darkInk, hex) >= 4.5 && ratio(darkInk, darkPaper) >= 4.5 ? {
875
+ page: hex,
876
+ paper: darkPaper,
877
+ L: at.L
878
+ } : null;
879
+ })();
880
+ const darkBackground = (_ref2 = darkOwn == null ? void 0 : darkOwn.page) != null ? _ref2 : aiOklchHex(0.17, darkGround * groundChroma, style.ground === 'warm' ? 60 : h);
881
+ const darkPaper = (_ref3 = darkOwn == null ? void 0 : darkOwn.paper) != null ? _ref3 : aiOklchHex(0.215, darkGround * groundChroma, style.ground === 'warm' ? 60 : h);
882
+ // Its cards and rules keep their place against its ground.
883
+ const darkShift = darkOwn ? darkOwn.L - 0.17 : 0;
884
+ // A site brought in's filled buttons (AGL-4152): their fill, and their words' nearest shade that reads on it.
885
+ const buttonFill = solid(style.buttonFill);
886
+ const buttonText = solid(style.buttonText);
887
+ const label = buttonFill && buttonText ? shadeOn(buttonText, buttonFill, 4.5) : null;
888
+ // The fill is the brand: drawn as the brand where its words read on it and it reads on the page.
889
+ const fillIsBrand = !!buttonFill && !!brand && buttonFill === solid(style.brand);
890
+ const ownPrimary = !!label && fillIsBrand && ratio(buttonFill, background) >= 3;
891
+ // Else the filled buttons alone are drawn in it, where it is a fill of its own on the page: under
892
+ // white or black, on its words' own side, and on the dark ground at its nearest shade apart from it.
893
+ const ownLabel = buttonFill && label ? aiHexOklch(label).L >= aiHexOklch(buttonFill).L ? 'common.white' : 'common.black' : null;
894
+ const darkButtonFill = buttonFill && ownLabel && !ownPrimary && aiOklabDistance(buttonFill, background) >= OWN_FILL_APART ? apartFrom(buttonFill, darkBackground, COMMON[ownLabel]) : null;
895
+ const button = ownLabel && darkButtonFill ? {
896
+ label: ownLabel,
897
+ outlined: ratio(buttonFill, background) >= 3 && ratio(darkButtonFill, darkBackground) >= 3
898
+ } : null;
796
899
  // The brand color: a button label reads on it, so it reads on the page too.
797
900
  let primaryMain;
798
901
  let primaryL;
799
- if (brand && ratio(white, style.brand) >= 4.5) {
902
+ if (ownPrimary && brand) {
903
+ primaryMain = buttonFill;
904
+ primaryL = brand.L;
905
+ } else if (brand && ratio(white, style.brand) >= 4.5) {
800
906
  primaryMain = style.brand;
801
907
  primaryL = brand.L;
802
908
  } else {
@@ -837,13 +943,13 @@ const START_L = {
837
943
  const tertiaryChroma = third ? Math.min(0.2, Math.max(0.07, third.C)) : 0.12;
838
944
  const tertiaryL = untilContrast(third ? Math.min(third.L, 0.6) : 0.52, tertiaryChroma, tertiaryHue, white, 4.6, 0);
839
945
  const tertiary = aiOklchHex(tertiaryL, tertiaryChroma, tertiaryHue);
840
- const textChroma = neutral ? 0.006 : 0.02;
841
946
  const light = {
842
947
  primary: {
843
948
  main: primaryMain,
844
- light: aiOklchHex(Math.min(0.92, primaryL + 0.12), chroma, h),
949
+ // The filled buttons' own fill, where they are drawn in it (AGL-4152): the brand's lighter shade.
950
+ light: button ? buttonFill : aiOklchHex(Math.min(0.92, primaryL + 0.12), chroma, h),
845
951
  dark: aiOklchHex(Math.max(0.15, primaryL - 0.1), chroma, h),
846
- contrastText: labelOn(primaryMain, h)
952
+ contrastText: ownPrimary ? label : labelOn(primaryMain, h)
847
953
  },
848
954
  secondary: {
849
955
  main: secondary.main,
@@ -859,14 +965,14 @@ const START_L = {
859
965
  },
860
966
  surface: {
861
967
  main: aiOklchHex(0.955, 0.012 * groundChroma, h),
862
- contrastText: aiOklchHex(0.22, textChroma, h)
968
+ contrastText: ink
863
969
  },
864
970
  background: {
865
971
  default: background,
866
972
  paper
867
973
  },
868
974
  text: {
869
- primary: aiOklchHex(0.22, textChroma, h),
975
+ primary: ink,
870
976
  secondary: aiOklchHex(0.45, textChroma + 0.005, h),
871
977
  disabled: aiOklchHex(0.68, 0.01, h)
872
978
  },
@@ -879,20 +985,21 @@ const START_L = {
879
985
  },
880
986
  divider: aiOklchHex(0.9, 0.012 * groundChroma, h)
881
987
  };
882
- const darkGround = style.ground === 'tinted' ? 0.024 : style.ground === 'warm' ? 0.014 : 0.012;
883
- const darkBackground = aiOklchHex(0.17, darkGround * groundChroma, style.ground === 'warm' ? 60 : h);
884
- const darkPaper = aiOklchHex(0.215, darkGround * groundChroma, style.ground === 'warm' ? 60 : h);
885
988
  const darkChroma = Math.min(chroma, 0.14);
886
- const darkPrimaryL = untilContrast(0.78, darkChroma, h, darkBackground, 4.5, 1);
887
- const darkPrimary = aiOklchHex(darkPrimaryL, darkChroma, h);
989
+ // A site brought in's own button fill is the dark scheme's brand where it reads on its ground (AGL-4152).
990
+ const darkFill = fillIsBrand && ratio(buttonFill, darkBackground) >= 4.5 ? buttonFill : null;
991
+ const darkPrimaryL = darkFill ? aiHexOklch(darkFill).L : untilContrast(0.78, darkChroma, h, darkBackground, 4.5, 1);
992
+ const darkPrimary = darkFill != null ? darkFill : aiOklchHex(darkPrimaryL, darkChroma, h);
888
993
  const darkSecondary = neutral ? aiOklchHex(0.93, 0.01, h) : aiOklchHex(0.45, accentChroma * 0.85, buttonHue);
889
994
  const darkTertiary = aiOklchHex(0.8, 0.1, tertiaryHue);
995
+ // The cards' surface a step above a ground of its own, held where the scheme's words still read on it.
996
+ const darkSurfaceL = darkShift ? untilContrast(0.25 + darkShift, 0.014 * groundChroma, h, darkInk, 4.5, 0) : 0.25;
890
997
  const dark = {
891
998
  primary: {
892
999
  main: darkPrimary,
893
- light: aiOklchHex(Math.min(0.94, darkPrimaryL + 0.08), darkChroma, h),
1000
+ light: button ? darkButtonFill : aiOklchHex(Math.min(0.94, darkPrimaryL + 0.08), darkChroma, h),
894
1001
  dark: aiOklchHex(darkPrimaryL - 0.1, darkChroma, h),
895
- contrastText: labelOn(darkPrimary, h)
1002
+ contrastText: darkFill && label && ratio(label, darkFill) >= 4.5 ? label : labelOn(darkPrimary, h)
896
1003
  },
897
1004
  secondary: {
898
1005
  main: darkSecondary,
@@ -907,7 +1014,7 @@ const START_L = {
907
1014
  contrastText: labelOn(darkTertiary, tertiaryHue)
908
1015
  },
909
1016
  surface: {
910
- main: aiOklchHex(0.25, 0.014 * groundChroma, h),
1017
+ main: aiOklchHex(darkSurfaceL, 0.014 * groundChroma, h),
911
1018
  contrastText: aiOklchHex(0.95, 0.01, h)
912
1019
  },
913
1020
  background: {
@@ -915,20 +1022,22 @@ const START_L = {
915
1022
  paper: darkPaper
916
1023
  },
917
1024
  text: {
918
- primary: aiOklchHex(0.95, 0.008, h),
1025
+ primary: darkInk,
919
1026
  secondary: aiOklchHex(0.77, 0.014, h),
920
1027
  disabled: aiOklchHex(0.52, 0.01, h)
921
1028
  },
1029
+ // The tints stay where they are: a base draws the primary's dark words on them.
922
1030
  tint: {
923
1031
  primary: aiOklchHex(0.27, 0.05, h),
924
1032
  secondary: aiOklchHex(0.27, 0.05, buttonHue),
925
1033
  tertiary: aiOklchHex(0.27, 0.04, tertiaryHue)
926
1034
  },
927
- divider: aiOklchHex(0.32, 0.015 * groundChroma, h)
1035
+ divider: aiOklchHex(0.32 + darkShift, 0.015 * groundChroma, h)
928
1036
  };
929
1037
  return {
930
1038
  light,
931
- dark
1039
+ dark,
1040
+ button
932
1041
  };
933
1042
  }
934
1043
  // ── The theme ────────────────────────────────────────────────────────────
@@ -1031,10 +1140,12 @@ const rem = (value)=>`${Math.round(value * 1000) / 1000}rem`;
1031
1140
  letterSpacing: style.eyebrow === 'rule' ? '0.16em' : '0.12em',
1032
1141
  textTransform: 'uppercase'
1033
1142
  };
1143
+ // A site brought in's own button case (AGL-4152), where it keeps one; else the buttons' style says.
1144
+ const capitals = style.buttonCase ? style.buttonCase === 'upper' : style.buttons === 'caps';
1034
1145
  variants.button = _extends({
1035
1146
  fontWeight: style.buttons === 'caps' ? 700 : bodyBold,
1036
- textTransform: style.buttons === 'caps' ? 'uppercase' : 'none'
1037
- }, style.buttons === 'caps' ? {
1147
+ textTransform: capitals ? 'uppercase' : 'none'
1148
+ }, capitals ? {
1038
1149
  letterSpacing: '0.06em'
1039
1150
  } : {});
1040
1151
  return {
@@ -1079,6 +1190,41 @@ const rem = (value)=>`${Math.round(value * 1000) / 1000}rem`;
1079
1190
  };
1080
1191
  }
1081
1192
  }
1193
+ /**
1194
+ * The button styles that draw a site brought in's filled buttons in its own
1195
+ * fill (AGL-4152), in palette roles: the fill is the primary's lighter shade
1196
+ * and the label white or black, and an outlined button takes the fill as its
1197
+ * border and words where it reads on both pages.
1198
+ */ function ownButtonVariants(button) {
1199
+ return [
1200
+ {
1201
+ props: {
1202
+ variant: 'contained',
1203
+ color: 'primary'
1204
+ },
1205
+ sx: {
1206
+ bgcolor: 'primary.light',
1207
+ color: button.label,
1208
+ '&:hover': {
1209
+ bgcolor: 'primary.light',
1210
+ boxShadow: 1
1211
+ }
1212
+ }
1213
+ },
1214
+ ...button.outlined ? [
1215
+ {
1216
+ props: {
1217
+ variant: 'outlined',
1218
+ color: 'primary'
1219
+ },
1220
+ sx: {
1221
+ color: 'primary.light',
1222
+ borderColor: 'primary.light'
1223
+ }
1224
+ }
1225
+ ] : []
1226
+ ];
1227
+ }
1082
1228
  /** The component defaults and styles a style sets: buttons, cards, fields, eyebrows, the header bar and the FAQ. */ function componentsFor(style) {
1083
1229
  var _card_borderTop;
1084
1230
  const radius = RADIUS[style.corners];
@@ -1227,7 +1373,12 @@ function isRecord(value) {
1227
1373
  for (const [key, value] of Object.entries(over))out[key] = key in out ? merged(out[key], value) : value;
1228
1374
  return out;
1229
1375
  }
1230
- /** Whether a theme passes the publish check and the brand-on-page contrast the doctrine asks. */ function themeReads(theme) {
1376
+ /**
1377
+ * Whether a theme passes the publish check and the brand-on-page contrast the
1378
+ * doctrine asks; and, where its filled buttons are drawn in a site brought
1379
+ * in's own fill (AGL-4152), whether their label reads on that fill and an
1380
+ * outlined button's on each page.
1381
+ */ function themeReads(theme, button = null) {
1231
1382
  if (!validateThemeForPublish(theme).ok) return false;
1232
1383
  for (const scheme of [
1233
1384
  'light',
@@ -1246,6 +1397,12 @@ function isRecord(value) {
1246
1397
  const fill = colors == null ? void 0 : colors[key];
1247
1398
  if ((fill == null ? void 0 : fill.main) && fill.contrastText && ratio(fill.contrastText, fill.main) < 4.5) return false;
1248
1399
  }
1400
+ if (button) {
1401
+ var _colors_primary1;
1402
+ const own = colors == null ? void 0 : (_colors_primary1 = colors.primary) == null ? void 0 : _colors_primary1.light;
1403
+ if (!own || ratio(COMMON[button.label], own) < 4.5) return false;
1404
+ if (button.outlined && ratio(own, page) < 3) return false;
1405
+ }
1249
1406
  }
1250
1407
  return true;
1251
1408
  }
@@ -1255,10 +1412,10 @@ function isRecord(value) {
1255
1412
  * site's own; whatever the base sets beyond them — its focus rings, its menu
1256
1413
  * and dialog styles, its control heights — stays the base's.
1257
1414
  */ export function aiSiteTheme(style, base) {
1258
- var _aiSiteFontPairing, _base_typography, _base_shape, _base_components, _style_sourceFonts;
1415
+ var _aiSiteFontPairing, _base_components, _base_typography, _base_shape, _style_sourceFonts;
1259
1416
  var _theme_fonts;
1260
1417
  const pairing = (_aiSiteFontPairing = aiSiteFontPairing(style.fonts)) != null ? _aiSiteFontPairing : AI_SITE_FONT_PAIRINGS[0];
1261
- const colors = aiSiteColors(style);
1418
+ const colors = colorsOf(style);
1262
1419
  const keep = (scheme)=>{
1263
1420
  var _ref;
1264
1421
  var _base_colorSchemes;
@@ -1274,6 +1431,7 @@ function isRecord(value) {
1274
1431
  success: own.success
1275
1432
  } : {}, colors[scheme]);
1276
1433
  };
1434
+ const components = merged((_base_components = base.components) != null ? _base_components : {}, componentsFor(style));
1277
1435
  let theme = _extends({}, base, {
1278
1436
  colorSchemes: {
1279
1437
  light: keep('light'),
@@ -1284,7 +1442,7 @@ function isRecord(value) {
1284
1442
  borderRadius: RADIUS[style.corners]
1285
1443
  }),
1286
1444
  spacing: SPACING[style.density],
1287
- components: merged((_base_components = base.components) != null ? _base_components : {}, componentsFor(style))
1445
+ components: colors.button ? withOwnButton(components, colors.button) : components
1288
1446
  });
1289
1447
  delete theme.darkScheme;
1290
1448
  // A site brought in is set in its source's own families (AGL-4108), at the
@@ -1339,14 +1497,32 @@ function isRecord(value) {
1339
1497
  ].sort((a, b)=>a - b)
1340
1498
  });
1341
1499
  }
1342
- if (!themeReads(theme)) {
1343
- // Never a theme that fails the reading checks: the starter's colors, with everything else kept.
1500
+ if (!themeReads(theme, colors.button)) {
1501
+ // Never a theme that fails the reading checks: the starter's colors, with everything else kept,
1502
+ // and the buttons drawn in them rather than in a fill the starter's colors know nothing of.
1344
1503
  theme = _extends({}, theme, {
1345
- colorSchemes: DEFAULT_SITE_THEME.colorSchemes
1504
+ colorSchemes: DEFAULT_SITE_THEME.colorSchemes,
1505
+ components
1346
1506
  });
1347
1507
  }
1348
1508
  return theme;
1349
1509
  }
1510
+ /**
1511
+ * The components with the filled buttons drawn in a site brought in's own
1512
+ * fill (AGL-4152): after the button styles the theme already holds, the
1513
+ * base's or the look's, so the fill's win where both style one.
1514
+ */ function withOwnButton(components, button) {
1515
+ var _components_MuiButton, _own_variants;
1516
+ const own = (_components_MuiButton = components['MuiButton']) != null ? _components_MuiButton : {};
1517
+ return _extends({}, components, {
1518
+ MuiButton: _extends({}, own, {
1519
+ variants: [
1520
+ ...(_own_variants = own.variants) != null ? _own_variants : [],
1521
+ ...ownButtonVariants(button)
1522
+ ]
1523
+ })
1524
+ });
1525
+ }
1350
1526
  // ── A kind's first look (AGL-4049) ──────────────────────────────────────────
1351
1527
  /** The midpoint of a kind's first hue range, or `null` when it spans the whole wheel (any hue suits it). */ function firstHueOf(hues) {
1352
1528
  var _ref;