@aglyn/plugins-ai 1.7.0 → 1.9.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.
- package/package.json +17 -17
- package/src/lib/activity/ai-activity.js +4 -2
- package/src/lib/activity/ai-activity.js.map +1 -1
- package/src/lib/components/ai-credits-card.component.d.ts +4 -3
- package/src/lib/components/ai-credits-card.component.js +13 -12
- package/src/lib/components/ai-credits-card.component.js.map +1 -1
- package/src/lib/components/ai-site-import-job.component.js +14 -5
- package/src/lib/components/ai-site-import-job.component.js.map +1 -1
- package/src/lib/components/ai-upsell-dialog.component.d.ts +2 -2
- package/src/lib/components/ai-upsell-dialog.component.js +3 -3
- package/src/lib/components/ai-upsell-dialog.component.js.map +1 -1
- package/src/lib/components/staff-org-ai-card.component.js +2 -2
- package/src/lib/components/staff-org-ai-card.component.js.map +1 -1
- package/src/lib/declarations.d.ts +2 -2
- package/src/lib/declarations.js +10 -9
- package/src/lib/declarations.js.map +1 -1
- package/src/lib/jobs/ai-job-import-step.d.ts +28 -2
- package/src/lib/jobs/ai-job-import-step.js +170 -14
- package/src/lib/jobs/ai-job-import-step.js.map +1 -1
- package/src/lib/jobs/ai-job-layout-language.js +2 -0
- package/src/lib/jobs/ai-job-layout-language.js.map +1 -1
- package/src/lib/jobs/ai-job-page-language.js +6 -2
- package/src/lib/jobs/ai-job-page-language.js.map +1 -1
- package/src/lib/jobs/ai-site-import-compile.d.ts +13 -3
- package/src/lib/jobs/ai-site-import-compile.js +339 -27
- package/src/lib/jobs/ai-site-import-compile.js.map +1 -1
- package/src/lib/jobs/ai-site-import-document.d.ts +3 -1
- package/src/lib/jobs/ai-site-import-document.js +42 -1
- package/src/lib/jobs/ai-site-import-document.js.map +1 -1
- package/src/lib/jobs/ai-site-import-look.d.ts +9 -0
- package/src/lib/jobs/ai-site-import-look.js +89 -6
- package/src/lib/jobs/ai-site-import-look.js.map +1 -1
- package/src/lib/layout-language/ai-layout-compiler.d.ts +16 -0
- package/src/lib/layout-language/ai-layout-compiler.js +378 -56
- package/src/lib/layout-language/ai-layout-compiler.js.map +1 -1
- package/src/lib/layout-language/ai-layout-frame-source.d.ts +88 -2
- package/src/lib/layout-language/ai-layout-frame-source.js +591 -30
- package/src/lib/layout-language/ai-layout-frame-source.js.map +1 -1
- package/src/lib/layout-language/ai-layout-frame.js +30 -18
- package/src/lib/layout-language/ai-layout-frame.js.map +1 -1
- package/src/lib/layout-language/ai-layout-language.d.ts +74 -3
- package/src/lib/layout-language/ai-layout-language.js +5 -3
- package/src/lib/layout-language/ai-layout-language.js.map +1 -1
- package/src/lib/layout-language/ai-layout-store.d.ts +8 -0
- package/src/lib/layout-language/ai-layout-store.js +32 -6
- package/src/lib/layout-language/ai-layout-store.js.map +1 -1
- package/src/lib/model/ai-site-import-fidelity.d.ts +31 -1
- package/src/lib/model/ai-site-import-fidelity.js +347 -25
- package/src/lib/model/ai-site-import-fidelity.js.map +1 -1
- package/src/lib/model/ai-site-import-view.js +4 -3
- package/src/lib/model/ai-site-import-view.js.map +1 -1
- package/src/lib/model/ai-site-import.d.ts +205 -6
- package/src/lib/model/ai-site-import.js +161 -5
- package/src/lib/model/ai-site-import.js.map +1 -1
- package/src/lib/model/ai-site-look.d.ts +8 -1
- package/src/lib/model/ai-site-look.js +8 -5
- package/src/lib/model/ai-site-look.js.map +1 -1
- package/src/lib/model/ai-upsell-copy.js +4 -3
- package/src/lib/model/ai-upsell-copy.js.map +1 -1
- package/src/lib/plan-entitlements.d.ts +3 -3
- package/src/lib/plan-entitlements.js +1 -1
- package/src/lib/plan-entitlements.js.map +1 -1
- package/src/lib/providers/model-choice.d.ts +6 -3
- package/src/lib/providers/model-choice.js +8 -4
- package/src/lib/providers/model-choice.js.map +1 -1
- package/src/lib/runtime/ai-doctrine-validators.d.ts +7 -1
- package/src/lib/runtime/ai-doctrine-validators.js +25 -2
- package/src/lib/runtime/ai-doctrine-validators.js.map +1 -1
- package/src/lib/runtime/ai-node-tree.js +19 -2
- package/src/lib/runtime/ai-node-tree.js.map +1 -1
- package/src/lib/runtime/ai-page-links.d.ts +15 -0
- package/src/lib/runtime/ai-page-links.js +48 -0
- package/src/lib/runtime/ai-page-links.js.map +1 -1
- package/src/lib/site-import/fixtures/site-import-fidelity-replay.d.ts +1 -1
- package/src/lib/site-import/fixtures/site-import-fidelity-replay.js +35 -6
- package/src/lib/site-import/fixtures/site-import-fidelity-replay.js.map +1 -1
- package/src/lib/site-import/fixtures/site-layout-recordings.d.ts +9 -0
- package/src/lib/site-import/fixtures/site-layout-recordings.js +24 -5
- package/src/lib/site-import/fixtures/site-layout-recordings.js.map +1 -1
- package/src/lib/site-import/site-import-crawl.d.ts +3 -1
- package/src/lib/site-import/site-import-crawl.js +8 -3
- package/src/lib/site-import/site-import-crawl.js.map +1 -1
- package/src/lib/site-import/site-import-css.d.ts +20 -0
- package/src/lib/site-import/site-import-css.js +106 -0
- package/src/lib/site-import/site-import-css.js.map +1 -1
- package/src/lib/site-import/site-import-html.d.ts +39 -0
- package/src/lib/site-import/site-import-html.js +515 -5
- package/src/lib/site-import/site-import-html.js.map +1 -1
- package/src/lib/site-import/site-import-layout.d.ts +16 -6
- package/src/lib/site-import/site-import-layout.js +528 -52
- package/src/lib/site-import/site-import-layout.js.map +1 -1
- package/src/lib/site-import/site-import-nav.js +286 -24
- package/src/lib/site-import/site-import-nav.js.map +1 -1
- package/src/lib/site-import/site-import-page.js +3 -0
- package/src/lib/site-import/site-import-page.js.map +1 -1
- package/src/lib/usage/assist-credits.d.ts +5 -4
- package/src/lib/usage/assist-credits.js +5 -4
- package/src/lib/usage/assist-credits.js.map +1 -1
- package/src/lib/usage/staff-org-ai-view.js +6 -6
- package/src/lib/usage/staff-org-ai-view.js.map +1 -1
- package/src/lib/usage/staff-org-ai.d.ts +4 -4
- package/src/lib/usage/staff-org-ai.js +8 -7
- package/src/lib/usage/staff-org-ai.js.map +1 -1
- package/src/lib/usage/staff-org-usage-ai.js +2 -2
- package/src/lib/usage/staff-org-usage-ai.js.map +1 -1
|
@@ -109,6 +109,13 @@ export interface AiSiteStyle {
|
|
|
109
109
|
body: AiSiteSourceFont;
|
|
110
110
|
heading: AiSiteSourceFont | null;
|
|
111
111
|
} | null;
|
|
112
|
+
/**
|
|
113
|
+
* A site brought in's third color (AGL-4138), `#rrggbb`: the color its
|
|
114
|
+
* source draws its eyebrows in, where that is a color of its own. The theme's
|
|
115
|
+
* tertiary is drawn at the nearest shade of it that reads on the page.
|
|
116
|
+
* Absent, the tertiary sits sixty degrees round from the accent.
|
|
117
|
+
*/
|
|
118
|
+
tertiary?: string;
|
|
112
119
|
}
|
|
113
120
|
/** A family a site brought in is set in (AGL-4108), with the weights the catalog says it has. */
|
|
114
121
|
export interface AiSiteSourceFont {
|
|
@@ -128,7 +135,7 @@ export type AiSiteLookAnswer = Partial<Pick<AiSiteStyle, 'base' | 'hue' | 'accen
|
|
|
128
135
|
* always is. A brand the person gave in the brief still wins over a pinned
|
|
129
136
|
* brand color, and the hue pinned with it.
|
|
130
137
|
*/
|
|
131
|
-
export type AiSiteLookPins = Partial<Pick<AiSiteStyle, 'brand' | 'hue' | 'accent' | 'ground' | 'fonts' | 'corners' | 'buttons' | 'cards' | 'header' | 'headerAlign' | 'density' | 'motion'>>;
|
|
138
|
+
export type AiSiteLookPins = Partial<Pick<AiSiteStyle, 'brand' | 'hue' | 'accent' | 'ground' | 'fonts' | 'corners' | 'buttons' | 'cards' | 'header' | 'headerAlign' | 'density' | 'motion' | 'eyebrow' | 'tertiary'>>;
|
|
132
139
|
/** A job's seed: FNV-1a over its id. */
|
|
133
140
|
export declare function aiSiteSeed(jobId: string): number;
|
|
134
141
|
export declare const AI_SITE_LOOK_TOOL_NAME = "submit_site_look";
|
|
@@ -831,9 +831,12 @@ const START_L = {
|
|
|
831
831
|
h: buttonHue
|
|
832
832
|
};
|
|
833
833
|
})();
|
|
834
|
-
|
|
835
|
-
const
|
|
836
|
-
const
|
|
834
|
+
// A site brought in's own third color (AGL-4138), at the nearest shade of it that reads on white; else the accent's neighbor.
|
|
835
|
+
const third = style.tertiary && /^#[0-9a-f]{6}$/i.test(style.tertiary) ? aiHexOklch(style.tertiary) : null;
|
|
836
|
+
const tertiaryHue = third ? Math.round(third.h) % 360 : (style.accent + 60) % 360;
|
|
837
|
+
const tertiaryChroma = third ? Math.min(0.2, Math.max(0.07, third.C)) : 0.12;
|
|
838
|
+
const tertiaryL = untilContrast(third ? Math.min(third.L, 0.6) : 0.52, tertiaryChroma, tertiaryHue, white, 4.6, 0);
|
|
839
|
+
const tertiary = aiOklchHex(tertiaryL, tertiaryChroma, tertiaryHue);
|
|
837
840
|
const textChroma = neutral ? 0.006 : 0.02;
|
|
838
841
|
const light = {
|
|
839
842
|
primary: {
|
|
@@ -850,8 +853,8 @@ const START_L = {
|
|
|
850
853
|
},
|
|
851
854
|
tertiary: {
|
|
852
855
|
main: tertiary,
|
|
853
|
-
light: aiOklchHex(Math.min(0.9, tertiaryL + 0.14),
|
|
854
|
-
dark: aiOklchHex(Math.max(0.15, tertiaryL - 0.1),
|
|
856
|
+
light: aiOklchHex(Math.min(0.9, tertiaryL + 0.14), tertiaryChroma, tertiaryHue),
|
|
857
|
+
dark: aiOklchHex(Math.max(0.15, tertiaryL - 0.1), tertiaryChroma, tertiaryHue),
|
|
855
858
|
contrastText: labelOn(tertiary, tertiaryHue)
|
|
856
859
|
},
|
|
857
860
|
surface: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/model/ai-site-look.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n contrastRatio,\n validateThemeForPublish,\n} from '@aglyn/aglyn/app-utils/site-theme'\nimport { DEFAULT_SITE_THEME } from '@aglyn/aglyn/app-utils/default-site'\nimport type {\n HostTheme,\n HostThemeComponentOverride,\n HostThemeFontCategory,\n HostThemeSchemeColors,\n HostThemeTypographyVariant,\n HostThemeTypographyVariantKey,\n} from '@aglyn/shared-data-types'\nimport { writeThemeFonts } from '@aglyn/shared-ui-theme/util/theme-editor-fields'\nimport {\n AI_SITE_MOTION_STYLES,\n aiSiteMotionStyle,\n aiSiteMotionStylesFor,\n type AiSiteMotionStyle,\n} from '../layout-language/ai-layout-motion'\nimport type { AiTool } from '../runtime/ai-runtime'\nimport {\n AI_SITE_BASES,\n AI_SITE_CORNERS,\n AI_SITE_FONT_PAIRINGS,\n AI_SITE_GROUNDS,\n AI_SITE_RHYTHMS,\n aiSiteFontPairing,\n type AiSiteBase,\n type AiSiteButtons,\n type AiSiteChroma,\n type AiSiteCorners,\n type AiSiteDensity,\n type AiSiteGround,\n type AiSiteKind,\n type AiSiteRhythm,\n} from './ai-site-kinds'\n\n/**\n * A site's look (AGL-3660): one of the platform's base themes, and this\n * site's own customizations layered over it as the site theme's override —\n * the same base-and-edits shape a person's pick on Setup → Theme is stored\n * as, so the Theme page names the base it came from and every edit there\n * starts from what the AI chose.\n *\n * Everything the look decides lives in the THEME, never on a node: palette,\n * fonts, type scale, corners, spacing, and the component defaults and styles\n * of buttons, cards, fields, eyebrows, the header bar and the FAQ. So a Card\n * or a Button a person drags in later looks like the rest of the site, and\n * the layout compiler emits plain components.\n *\n * Three inputs decide it:\n * - the KIND (`ai-site-kinds.ts`): the family of looks that suit the site;\n * - the MODEL's choices for this business (`submit_site_look`), any of\n * which may be missing;\n * - the per-job SEED, which fills what the model left out from the kind's\n * options and nudges every hue, chroma and size, so two jobs with the same\n * brief and the same answers still produce two different themes.\n *\n * Colors are built in OKLCH and held to WCAG: body text 4.5:1 on its ground\n * and on paper, every button label 4.5:1 on its fill, the brand color 3:1 on\n * the page — then the whole theme passes `validateThemeForPublish`, or its\n * colors fall back to the starter theme's.\n */\n\n// ── The tokens ───────────────────────────────────────────────────────────\n\n/** How cards are drawn. */\nexport const AI_SITE_CARDS = ['flat', 'outlined', 'elevated', 'tinted', 'rule'] as const\nexport type AiSiteCards = (typeof AI_SITE_CARDS)[number]\n/** The form field style. */\nexport const AI_SITE_FIELDS = ['outlined', 'filled', 'standard'] as const\nexport type AiSiteFields = (typeof AI_SITE_FIELDS)[number]\n/** How an eyebrow above a heading is set. */\nexport const AI_SITE_EYEBROWS = ['caps', 'small', 'rule'] as const\nexport type AiSiteEyebrow = (typeof AI_SITE_EYEBROWS)[number]\n/** What sets a plain header bar off the page. */\nexport const AI_SITE_HEADERS = ['line', 'shadow', 'flat'] as const\nexport type AiSiteHeader = (typeof AI_SITE_HEADERS)[number]\n/** Button shapes and casing; `link` draws quiet buttons as underlined links. */\nexport const AI_SITE_BUTTONS: readonly AiSiteButtons[] = ['rounded', 'pill', 'square', 'caps', 'link']\nconst DENSITIES: readonly AiSiteDensity[] = ['compact', 'regular', 'airy']\n\n/**\n * A site's style tokens: everything its theme was built from. Stored with the\n * site (`hosts/{id}.siteStyle`) so a later AI edit keeps the look.\n */\nexport interface AiSiteStyle {\n v: 1\n kind: string\n base: AiSiteBase\n seed: number\n hue: number\n accent: number\n chroma: AiSiteChroma\n ground: AiSiteGround\n fonts: string\n corners: AiSiteCorners\n buttons: AiSiteButtons\n cards: AiSiteCards\n fields: AiSiteFields\n eyebrow: AiSiteEyebrow\n header: AiSiteHeader\n /** The header's arrangement: brand at the start and links after it, or both centered. */\n headerAlign: 'start' | 'center'\n /** How the pages alternate their bands. */\n rhythm: AiSiteRhythm\n headingScale: number\n density: AiSiteDensity\n /** A brand color the brief gave, used as the primary color. */\n brand: string | null\n /**\n * How the site's pages arrive (AGL-3941), from `ai-layout-motion.ts`'s\n * vocabulary. Absent on a style stored before the look chose motion, whose\n * pages move in its kind's mood.\n */\n motion?: AiSiteMotionStyle\n /**\n * A site brought in's own page ground (AGL-4108), `#rrggbb`: the color its\n * source's pages sit on, where it is light enough for the theme's text.\n * Absent, the ground is drawn as `ground` says.\n */\n page?: string\n /**\n * A site brought in's own type (AGL-4108): the families its source sets\n * its body and its headings in, where the theme font catalog has them,\n * loaded in place of the pairing's. The pairing still sets the weights and\n * the scale they are drawn at. Absent on every other site, whose type is\n * the pairing's alone.\n */\n sourceFonts?: { body: AiSiteSourceFont; heading: AiSiteSourceFont | null } | null\n}\n\n/** A family a site brought in is set in (AGL-4108), with the weights the catalog says it has. */\nexport interface AiSiteSourceFont {\n family: string\n category: HostThemeFontCategory\n /** The upright weights the family offers. */\n weights: number[]\n}\n\n/** The weights of `wanted` a family offers, each the nearest it has where it lacks one. */\nexport function aiSiteFontWeightsIn(wanted: readonly number[], offered: readonly number[]): number[] {\n if (!offered.length) return [...new Set(wanted)].sort((a, b) => a - b)\n const nearest = (weight: number) => offered.reduce((best, each) => (Math.abs(each - weight) < Math.abs(best - weight) ? each : best), offered[0] as number)\n return [...new Set(wanted.map(nearest))].sort((a, b) => a - b)\n}\n\n/** What the model may choose, every field optional. */\nexport type AiSiteLookAnswer = Partial<\n Pick<\n AiSiteStyle,\n | 'base'\n | 'hue'\n | 'accent'\n | 'ground'\n | 'fonts'\n | 'corners'\n | 'buttons'\n | 'cards'\n | 'fields'\n | 'eyebrow'\n | 'header'\n | 'brand'\n | 'motion'\n >\n>\n\n/**\n * The dimensions the sites a person likes pin (AGL-3975,\n * `jobs/ai-site-inspiration.ts`): each one present is KEPT, whatever the\n * model or the seed would choose, and every other dimension is chosen as it\n * always is. A brand the person gave in the brief still wins over a pinned\n * brand color, and the hue pinned with it.\n */\nexport type AiSiteLookPins = Partial<\n Pick<\n AiSiteStyle,\n | 'brand'\n | 'hue'\n | 'accent'\n | 'ground'\n | 'fonts'\n | 'corners'\n | 'buttons'\n | 'cards'\n | 'header'\n | 'headerAlign'\n | 'density'\n | 'motion'\n >\n>\n\n// ── The seed ─────────────────────────────────────────────────────────────\n\n/** A job's seed: FNV-1a over its id. */\nexport function aiSiteSeed(jobId: string): number {\n let hash = 0x811c9dc5\n for (let index = 0; index < jobId.length; index += 1) {\n hash ^= jobId.charCodeAt(index)\n hash = Math.imul(hash, 0x01000193)\n }\n return hash >>> 0\n}\n\n/** A small deterministic generator over a seed (mulberry32). */\nfunction random(seed: number): () => number {\n let state = seed >>> 0\n return () => {\n state = (state + 0x6d2b79f5) >>> 0\n let t = state\n t = Math.imul(t ^ (t >>> 15), t | 1)\n t ^= t + Math.imul(t ^ (t >>> 7), t | 61)\n return ((t ^ (t >>> 14)) >>> 0) / 4294967296\n }\n}\n\nconst pick = <T,>(next: () => number, list: readonly T[]): T => list[Math.floor(next() * list.length) % list.length] as T\n\n// ── The model's answer ───────────────────────────────────────────────────\n\nexport const AI_SITE_LOOK_TOOL_NAME = 'submit_site_look'\n\nconst enumOf = (values: readonly string[], description: string) => ({ type: 'string', enum: [...values], description })\n\n/** The strict tool the look is answered with; every field is required and the reader is lenient. */\nexport const AI_SITE_LOOK_TOOL: AiTool = {\n name: AI_SITE_LOOK_TOOL_NAME,\n description: \"Submit this website's look: the base theme it starts from and the choices that make it this business's own.\",\n strict: true,\n inputSchema: {\n type: 'object',\n additionalProperties: false,\n required: ['base', 'hue', 'accent', 'ground', 'fonts', 'corners', 'buttons', 'cards', 'fields', 'eyebrow', 'header', 'brand', 'motion'],\n properties: {\n base: enumOf(AI_SITE_BASES, 'The base theme to start from, from the list in the request.'),\n hue: { type: 'integer', description: 'The brand color as a hue from 0 to 359 (0 red, 30 orange, 55 gold, 140 green, 190 teal, 220 blue, 270 violet, 330 pink).' },\n accent: { type: 'integer', description: 'The accent color as a hue from 0 to 359, chosen to sit well beside the brand hue.' },\n ground: enumOf(AI_SITE_GROUNDS, 'The page background: white, warm (cream), cool (gray-blue) or tinted (a whisper of the brand color).'),\n fonts: enumOf(AI_SITE_FONT_PAIRINGS.map((pairing) => pairing.id), 'A font pairing from the list in the request.'),\n corners: enumOf(AI_SITE_CORNERS, 'Corner rounding for cards and fields.'),\n buttons: enumOf(AI_SITE_BUTTONS, 'Buttons: rounded, pill, square, caps (capitals) or link (quiet buttons drawn as underlined links).'),\n cards: enumOf(AI_SITE_CARDS, 'Cards: flat, outlined, elevated (a soft shadow), tinted (a wash of the brand color) or rule (a colored line on top).'),\n fields: enumOf(AI_SITE_FIELDS, 'Form fields: outlined, filled or standard (underlined).'),\n eyebrow: enumOf(AI_SITE_EYEBROWS, 'The small label above headings: caps (spaced capitals), small (quiet small text) or rule (capitals after a short line).'),\n header: enumOf(AI_SITE_HEADERS, 'What sets the header bar off the page: a line, a shadow, or flat.'),\n brand: { anyOf: [{ type: 'string' }, { type: 'null' }], description: 'A hex brand color the brief gives, exactly as written, or null.' },\n motion: enumOf(AI_SITE_MOTION_STYLES, 'How the pages arrive as a visitor scrolls, from the motion list in the request.'),\n },\n },\n}\n\nconst oneOf = <T extends string>(value: unknown, values: readonly T[]): T | undefined =>\n typeof value === 'string' && (values as readonly string[]).includes(value) ? (value as T) : undefined\n\nconst hueOf = (value: unknown): number | undefined =>\n typeof value === 'number' && Number.isFinite(value) ? ((Math.round(value) % 360) + 360) % 360 : undefined\n\n/** A brand color as a six-digit hex, or `null`. */\nexport function aiSiteBrandHex(value: unknown): string | null {\n if (typeof value !== 'string') return null\n const match = /#?([0-9a-f]{6}|[0-9a-f]{3})\\b/i.exec(value.trim())\n if (!match) return null\n const hex = match[1] as string\n const full = hex.length === 3 ? [...hex].map((digit) => digit + digit).join('') : hex\n return `#${full.toLowerCase()}`\n}\n\n/** The model's answer, read leniently: a value outside its vocabulary is left for the seed. */\nexport function aiReadSiteLook(answer: unknown): AiSiteLookAnswer {\n const raw = (answer && typeof answer === 'object' ? answer : {}) as Record<string, unknown>\n const look: AiSiteLookAnswer = {}\n const base = oneOf(raw['base'], AI_SITE_BASES)\n if (base) look.base = base\n const hue = hueOf(raw['hue'])\n if (hue !== undefined) look.hue = hue\n const accent = hueOf(raw['accent'])\n if (accent !== undefined) look.accent = accent\n const ground = oneOf(raw['ground'], AI_SITE_GROUNDS)\n if (ground) look.ground = ground\n if (aiSiteFontPairing(raw['fonts'])) look.fonts = raw['fonts'] as string\n const corners = oneOf(raw['corners'], AI_SITE_CORNERS)\n if (corners) look.corners = corners\n const buttons = oneOf(raw['buttons'], AI_SITE_BUTTONS)\n if (buttons) look.buttons = buttons\n const cards = oneOf(raw['cards'], AI_SITE_CARDS)\n if (cards) look.cards = cards\n const fields = oneOf(raw['fields'], AI_SITE_FIELDS)\n if (fields) look.fields = fields\n const eyebrow = oneOf(raw['eyebrow'], AI_SITE_EYEBROWS)\n if (eyebrow) look.eyebrow = eyebrow\n const header = oneOf(raw['header'], AI_SITE_HEADERS)\n if (header) look.header = header\n const brand = aiSiteBrandHex(raw['brand'])\n if (brand) look.brand = brand\n const motion = aiSiteMotionStyle(raw['motion'])\n if (motion) look.motion = motion\n return look\n}\n\n// ── Kind, model and seed into tokens ─────────────────────────────────────\n\n/** The building-block styles a kind leans to, before the model or the seed choose. */\nconst BLOCK_BIAS: Partial<\n Record<string, { cards: readonly AiSiteCards[]; eyebrow: readonly AiSiteEyebrow[]; header: readonly AiSiteHeader[]; fields: readonly AiSiteFields[] }>\n> = {\n portfolio: { cards: ['rule', 'flat', 'outlined'], eyebrow: ['small', 'rule', 'caps'], header: ['flat', 'line', 'shadow'], fields: ['standard', 'outlined', 'filled'] },\n studio: { cards: ['flat', 'rule', 'outlined'], eyebrow: ['rule', 'small', 'caps'], header: ['flat', 'line', 'shadow'], fields: ['standard', 'outlined', 'filled'] },\n photography: { cards: ['flat', 'rule', 'outlined'], eyebrow: ['small', 'rule', 'caps'], header: ['flat', 'line', 'shadow'], fields: ['standard', 'outlined', 'filled'] },\n blog: { cards: ['rule', 'outlined', 'flat', 'tinted'], eyebrow: ['small', 'caps', 'rule'], header: ['line', 'flat', 'shadow'], fields: ['outlined', 'standard', 'filled'] },\n trades: { cards: ['elevated', 'outlined', 'rule', 'flat', 'tinted'], eyebrow: ['caps', 'rule', 'small'], header: ['shadow', 'line', 'flat'], fields: ['outlined', 'filled', 'standard'] },\n fitness: { cards: ['elevated', 'flat', 'rule', 'outlined'], eyebrow: ['caps', 'rule', 'small'], header: ['shadow', 'flat', 'line'], fields: ['filled', 'outlined', 'standard'] },\n professional: { cards: ['outlined', 'rule', 'flat', 'elevated'], eyebrow: ['caps', 'rule', 'small'], header: ['line', 'flat', 'shadow'], fields: ['outlined', 'standard', 'filled'] },\n wellness: { cards: ['tinted', 'flat', 'elevated', 'outlined'], eyebrow: ['small', 'caps', 'rule'], header: ['flat', 'line', 'shadow'], fields: ['filled', 'outlined', 'standard'] },\n yoga: { cards: ['tinted', 'flat', 'outlined'], eyebrow: ['small', 'rule', 'caps'], header: ['flat', 'line', 'shadow'], fields: ['filled', 'standard', 'outlined'] },\n restaurant: { cards: ['flat', 'elevated', 'tinted', 'rule'], eyebrow: ['caps', 'rule', 'small'], header: ['flat', 'shadow', 'line'], fields: ['outlined', 'filled', 'standard'] },\n beauty: { cards: ['tinted', 'flat', 'outlined', 'rule'], eyebrow: ['rule', 'small', 'caps'], header: ['flat', 'line', 'shadow'], fields: ['standard', 'filled', 'outlined'] },\n music: { cards: ['flat', 'rule', 'elevated'], eyebrow: ['caps', 'rule', 'small'], header: ['flat', 'shadow', 'line'], fields: ['filled', 'standard', 'outlined'] },\n}\nconst ANY_BLOCKS = { cards: AI_SITE_CARDS, eyebrow: AI_SITE_EYEBROWS, header: AI_SITE_HEADERS, fields: AI_SITE_FIELDS }\n\n/** The hue family a hue is in: twelve families of thirty degrees, 0 the reds. */\nexport function aiSiteHueFamily(hue: number): number {\n return Math.floor((((hue + 15) % 360) + 360) % 360 / 30)\n}\n\n/** Which of a kind's hue ranges a hue falls in, or -1. */\nfunction rangeOf(hue: number, kind: AiSiteKind): number {\n return kind.look.hues.findIndex(([from, to]) => (from <= to ? hue >= from && hue <= to : hue >= from || hue <= to))\n}\n\n/** The look dimensions two sites are compared by (`ai-site-look.spec.ts`). */\nexport const AI_SITE_LOOK_DIMENSIONS = [\n 'base',\n 'hueFamily',\n 'fonts',\n 'buttons',\n 'cards',\n 'corners',\n 'ground',\n 'eyebrow',\n 'header',\n 'fields',\n 'headerAlign',\n 'rhythm',\n] as const\n\n/** A style's value on each tracked dimension. */\nexport function aiSiteLookSignature(style: AiSiteStyle): Record<(typeof AI_SITE_LOOK_DIMENSIONS)[number], string> {\n return {\n base: style.base,\n hueFamily: String(aiSiteHueFamily(style.hue)),\n fonts: style.fonts,\n buttons: style.buttons,\n cards: style.cards,\n corners: style.corners,\n ground: style.ground,\n eyebrow: style.eyebrow,\n header: style.header,\n fields: style.fields,\n headerAlign: style.headerAlign,\n rhythm: style.rhythm,\n }\n}\n\n/**\n * The style tokens for a site of this kind (AGL-3660). Every dimension is\n * the SEED's choice among what suits the kind, with the model's choice for\n * this business as a favored candidate — kept at a given chance, not always\n * — so the brief steers the look and two jobs with the same brief and the\n * same answer still come out as two sites: another base, another hue family,\n * another pairing, other buttons. A brand color the brief gives is always\n * kept.\n */\nexport function aiSiteStyleFor(input: {\n kind: AiSiteKind\n answer: AiSiteLookAnswer\n seed: number\n brand?: string | null\n /**\n * The looks of the workspace's other sites (AGL-3660): a look that shares\n * one's base, hue family, heading font and buttons, or differs from one in\n * fewer than three tracked dimensions, is drawn again from the next seed.\n */\n avoid?: readonly AiSiteStyle[]\n /** What the sites the person likes pin (AGL-3975): kept on every draw. */\n pins?: AiSiteLookPins\n}): AiSiteStyle {\n const avoid = input.avoid ?? []\n if (!avoid.length) return styleOnce(input, input.seed)\n const signatures = avoid.map(aiSiteLookSignature)\n let best: { style: AiSiteStyle; least: number } | null = null\n for (let attempt = 0; attempt < AI_SITE_LOOK_DRAWS; attempt += 1) {\n const style = styleOnce(input, attempt === 0 ? input.seed : (Math.imul(input.seed ^ 0x5bd1e995, attempt + 1) >>> 0))\n const own = aiSiteLookSignature(style)\n const least = Math.min(\n ...signatures.map((other) =>\n TUPLE.every((dimension) => own[dimension] === other[dimension])\n ? -1\n : AI_SITE_LOOK_DIMENSIONS.filter((dimension) => own[dimension] !== other[dimension]).length,\n ),\n )\n if (least >= AI_SITE_LOOK_LEAST_DIFFERENCES) return style\n if (!best || least > best.least) best = { style, least }\n }\n return (best as { style: AiSiteStyle }).style\n}\n\n/** How many seeds a look draws before it settles for the most different. */\nexport const AI_SITE_LOOK_DRAWS = 32\n/** The fewest tracked dimensions in which two of a workspace's sites differ. */\nexport const AI_SITE_LOOK_LEAST_DIFFERENCES = 3\n/** The dimensions no two of a workspace's sites share all of. */\nconst TUPLE = ['base', 'hueFamily', 'fonts', 'buttons'] as const\n\nfunction styleOnce(\n input: { kind: AiSiteKind; answer: AiSiteLookAnswer; brand?: string | null; pins?: AiSiteLookPins },\n seed: number,\n): AiSiteStyle {\n return withPins(drawOnce(input, seed), input)\n}\n\n/**\n * A drawn style with its pins laid over it (AGL-3975). Applied after the\n * draw, so every dimension is drawn the same with or without pins and an\n * unpinned job's look is exactly what it was.\n */\nfunction withPins(style: AiSiteStyle, input: { brand?: string | null; pins?: AiSiteLookPins }): AiSiteStyle {\n const pins = input.pins\n if (!pins || !Object.keys(pins).length) return style\n // The person's own brand color outranks the one their sites suggest.\n const own = aiSiteBrandHex(input.brand)\n const { brand, hue, ...rest } = pins\n const pinned = Object.fromEntries(Object.entries(rest).filter(([, value]) => value !== undefined && value !== null))\n return {\n ...style,\n ...pinned,\n ...(!own && aiSiteBrandHex(brand) ? { brand: aiSiteBrandHex(brand) } : {}),\n ...(!own && typeof hue === 'number' && Number.isFinite(hue) ? { hue: ((Math.round(hue) % 360) + 360) % 360 } : {}),\n }\n}\n\nfunction drawOnce(\n input: { kind: AiSiteKind; answer: AiSiteLookAnswer; brand?: string | null },\n seed: number,\n): AiSiteStyle {\n const { kind, answer } = input\n const next = random(seed)\n const family = kind.look\n const blocks = BLOCK_BIAS[kind.id] ?? ANY_BLOCKS\n /** The model's choice at a chance of `keep`, else the seed's among `options`. */\n const choose = <T,>(model: T | undefined, options: readonly T[], keep: number): T =>\n model !== undefined && next() < keep ? model : pick(next, options)\n\n // The hue: a family among the kind's (the brief's industry), the model's\n // own family favored, and a hue within it.\n const modelRange = answer.hue === undefined ? -1 : rangeOf(answer.hue, kind)\n const keepHue = modelRange !== -1 && next() < 0.3\n const range = keepHue ? modelRange : Math.floor(next() * family.hues.length) % family.hues.length\n const [from, to] = family.hues[range] as readonly [number, number]\n const span = from <= to ? to - from : 360 - from + to\n const hue = keepHue\n ? ((answer.hue as number) + (next() < 0.5 ? -1 : 1) * Math.round(4 + next() * 8) + 360) % 360\n : Math.round(from + next() * span) % 360\n const accentFrom = answer.accent !== undefined && next() < 0.4 ? answer.accent : (hue + pick(next, [30, 150, 180, 210, 330])) % 360\n const accent = (accentFrom + (next() < 0.5 ? -1 : 1) * Math.round(8 + next() * 16) + 360) % 360\n\n const bases = [...new Set([...(answer.base ? [answer.base] : []), ...family.bases])]\n return {\n v: 1,\n kind: kind.id,\n base: choose(answer.base, bases, 0.3),\n seed,\n hue,\n accent,\n chroma: family.chroma,\n ground: choose(answer.ground, family.grounds, 0.35),\n fonts: choose(answer.fonts, family.fonts, 0.3),\n corners: choose(answer.corners, family.corners, 0.35),\n buttons: choose(answer.buttons, [family.buttons, ...AI_SITE_BUTTONS], 0.3),\n cards: choose(answer.cards, blocks.cards, 0.35),\n fields: choose(answer.fields, blocks.fields, 0.35),\n eyebrow: choose(answer.eyebrow, blocks.eyebrow, 0.35),\n header: choose(answer.header, blocks.header, 0.35),\n headerAlign: pick(next, family.headerAligns ?? ['start', 'start', 'center']),\n rhythm: pick(next, family.rhythms ?? AI_SITE_RHYTHMS),\n headingScale: Math.round(family.headingScale * (0.94 + next() * 0.12) * 100) / 100,\n density: family.density === 'regular' && next() < 0.25 ? pick(next, DENSITIES) : family.density,\n brand: aiSiteBrandHex(input.brand) ?? answer.brand ?? null,\n // Drawn last, so every dimension above is drawn the same whether or not\n // the answer chose a motion. The model's choice is kept more often than\n // the other dimensions', because nothing else of the site says how it\n // moves; the seed's draw is among the styles that suit the kind.\n motion: choose(answer.motion, aiSiteMotionStylesFor(kind.id), AI_SITE_MOTION_KEEP),\n }\n}\n\n/** The chance a look keeps the motion style the model chose (AGL-3941). */\nexport const AI_SITE_MOTION_KEEP = 0.6\n\n// ── Color ────────────────────────────────────────────────────────────────\n\ntype Rgb = [number, number, number]\n\nfunction oklabToLinear(L: number, a: number, b: number): Rgb {\n const l = (L + 0.3963377774 * a + 0.2158037573 * b) ** 3\n const m = (L - 0.1055613458 * a - 0.0638541728 * b) ** 3\n const s = (L - 0.0894841775 * a - 1.291485548 * b) ** 3\n return [\n 4.0767416621 * l - 3.3077115913 * m + 0.2309699292 * s,\n -1.2684380046 * l + 2.6097574011 * m - 0.3413193965 * s,\n -0.0041960863 * l - 0.7034186147 * m + 1.707614701 * s,\n ]\n}\n\nconst toSrgb = (channel: number) =>\n channel <= 0.0031308 ? 12.92 * channel : 1.055 * channel ** (1 / 2.4) - 0.055\nconst fromSrgb = (channel: number) =>\n channel <= 0.04045 ? channel / 12.92 : ((channel + 0.055) / 1.055) ** 2.4\n\n/** An OKLCH color as hex, its chroma reduced until it fits sRGB. */\nexport function aiOklchHex(L: number, C: number, h: number): string {\n const lightness = Math.min(1, Math.max(0, L))\n let chroma = Math.max(0, C)\n for (;;) {\n const radians = (h * Math.PI) / 180\n const linear = oklabToLinear(lightness, chroma * Math.cos(radians), chroma * Math.sin(radians))\n const fits = linear.every((channel) => channel >= -0.0005 && channel <= 1.0005)\n if (fits || chroma <= 0) {\n return `#${linear\n .map((channel) => Math.round(Math.min(1, Math.max(0, toSrgb(Math.min(1, Math.max(0, channel))))) * 255))\n .map((value) => value.toString(16).padStart(2, '0'))\n .join('')}`\n }\n chroma = Math.max(0, chroma - 0.004)\n }\n}\n\n/** A hex color in OKLCH. */\nexport function aiHexOklch(hex: string): { L: number; C: number; h: number } {\n const value = hex.replace('#', '')\n const [r, g, b] = [0, 2, 4].map((at) => fromSrgb(parseInt(value.slice(at, at + 2), 16) / 255)) as Rgb\n const l = Math.cbrt(0.4122214708 * r + 0.5363325363 * g + 0.0514459929 * b)\n const m = Math.cbrt(0.2119034982 * r + 0.6806995451 * g + 0.1073969566 * b)\n const s = Math.cbrt(0.0883024619 * r + 0.2817188376 * g + 0.6299787005 * b)\n const L = 0.2104542553 * l + 0.793617785 * m - 0.0040720468 * s\n const A = 1.9779984951 * l - 2.428592205 * m + 0.4505937099 * s\n const B = 0.0259040371 * l + 0.7827717662 * m - 0.808675766 * s\n return { L, C: Math.hypot(A, B), h: ((Math.atan2(B, A) * 180) / Math.PI + 360) % 360 }\n}\n\nconst ratio = (a: string, b: string) => contrastRatio(a, b) ?? 1\n\n/** The lightness, stepped from `L` toward `toward`, at which `hex(L)` first reaches `min` against `against`. */\nfunction untilContrast(L: number, C: number, h: number, against: string, min: number, toward: 0 | 1): number {\n let lightness = L\n for (let step = 0; step < 60; step += 1) {\n if (ratio(aiOklchHex(lightness, C, h), against) >= min) return lightness\n lightness += toward ? 0.012 : -0.012\n if (lightness <= 0.05 || lightness >= 0.98) break\n }\n return lightness\n}\n\n/** The label color of a fill: white or a deep ink of its hue, whichever reads at 4.5:1, or better. */\nfunction labelOn(fill: string, h: number): string {\n const white = '#ffffff'\n const ink = aiOklchHex(0.2, 0.04, h)\n return ratio(white, fill) >= 4.5 ? white : ratio(ink, fill) >= 4.5 ? ink : ratio(white, fill) > ratio(ink, fill) ? white : '#000000'\n}\n\n/** How far apart two hues sit on the wheel, in degrees: 0 to 180. */\nexport function aiHueGap(a: number, b: number): number {\n const d = Math.abs(a - b) % 360\n return Math.min(d, 360 - d)\n}\n\n/**\n * The widest gap an accent may keep from the brand hue and still color a\n * button beside it (AGL-3660). Past it the accent clashes: a live portfolio of\n * green (hue 131) and magenta (323) showed its outlined buttons as a pink wash\n * and its footer button as purple under green words, on a Cupertino base.\n */\nexport const AI_SITE_ACCENT_CLASH_DEGREES = 60\n\nconst CHROMA: Record<AiSiteChroma, number> = { neutral: 0.15, muted: 0.085, balanced: 0.135, vivid: 0.185 }\nconst START_L: Record<AiSiteChroma, number> = { neutral: 0.52, muted: 0.48, balanced: 0.52, vivid: 0.56 }\n\n/** Both schemes' colors for a style. */\nexport function aiSiteColors(style: AiSiteStyle): { light: HostThemeSchemeColors; dark: HostThemeSchemeColors } {\n const next = random(style.seed ^ 0x9e3779b9)\n const neutral = style.chroma === 'neutral'\n const brand = style.brand ? aiHexOklch(style.brand) : null\n const h = brand?.h ?? style.hue\n const chroma = brand?.C ?? CHROMA[style.chroma] * (0.9 + next() * 0.2)\n const groundChroma = neutral ? 0.3 : 1\n const white = '#ffffff'\n\n // The page grounds.\n const grounds: Record<AiSiteGround, { L: number; C: number; h: number; paper: [number, number] }> = {\n white: { L: 0.985, C: 0.004, h, paper: [1, 0] },\n warm: { L: 0.972, C: 0.016, h: 78, paper: [0.993, 0.007] },\n cool: { L: 0.974, C: 0.009, h: 250, paper: [1, 0] },\n tinted: { L: 0.968, C: 0.02, h, paper: [0.994, 0.006] },\n }\n const ground = grounds[style.ground]\n // A site brought in keeps the ground its source's pages sit on (AGL-4108), where its text reads on it.\n const own = style.page && /^#[0-9a-f]{6}$/i.test(style.page) && aiHexOklch(style.page).L >= 0.9 ? style.page.toLowerCase() : null\n const background = own ?? aiOklchHex(ground.L, ground.C * groundChroma, ground.h)\n const paper = aiOklchHex(ground.paper[0], ground.paper[1] * groundChroma, ground.h)\n\n // The brand color: a button label reads on it, so it reads on the page too.\n let primaryMain: string\n let primaryL: number\n if (brand && ratio(white, style.brand as string) >= 4.5) {\n primaryMain = style.brand as string\n primaryL = brand.L\n } else {\n primaryL = untilContrast(brand ? Math.min(brand.L, START_L[style.chroma]) : START_L[style.chroma] + (next() - 0.5) * 0.06, chroma, h, white, 4.6, 0)\n primaryMain = aiOklchHex(primaryL, chroma, h)\n }\n const accentChroma = neutral ? 0.17 : Math.max(0.07, chroma * 0.95)\n // A button's colors come from the brand hue where the accent clashes with\n // it (AGL-3660); the accent keeps its tint and the tertiary.\n const buttonHue = aiHueGap(style.accent, h) > AI_SITE_ACCENT_CLASH_DEGREES ? h : style.accent\n\n // The secondary color fills a button ON a brand band, so it stands apart from the brand color.\n const secondary = neutral\n ? (() => {\n // Ink or paper, whichever stands further from the brand color (AGL-3660).\n const ink = aiOklchHex(0.24, 0.012, h)\n const paper = aiOklchHex(0.97, 0.008, h)\n return { main: ratio(ink, primaryMain) >= ratio(paper, primaryMain) ? ink : paper, h }\n })()\n : (() => {\n // A light wash of the accent rather than the accent at full strength:\n // it reads on the brand color without fighting it.\n const washChroma = Math.min(accentChroma, 0.08)\n let L = 0.9\n let main = aiOklchHex(L, washChroma, buttonHue)\n while (ratio(main, primaryMain) < 3 && L < 0.96) {\n L += 0.02\n main = aiOklchHex(L, washChroma, buttonHue)\n }\n return { main, h: buttonHue }\n })()\n const tertiaryHue = (style.accent + 60) % 360\n const tertiaryL = untilContrast(0.52, 0.12, tertiaryHue, white, 4.6, 0)\n const tertiary = aiOklchHex(tertiaryL, 0.12, tertiaryHue)\n const textChroma = neutral ? 0.006 : 0.02\n\n const light: HostThemeSchemeColors = {\n primary: {\n main: primaryMain,\n light: aiOklchHex(Math.min(0.92, primaryL + 0.12), chroma, h),\n dark: aiOklchHex(Math.max(0.15, primaryL - 0.1), chroma, h),\n contrastText: labelOn(primaryMain, h),\n },\n secondary: {\n main: secondary.main,\n light: aiOklchHex(0.93, accentChroma * 0.6, secondary.h),\n dark: aiOklchHex(0.42, accentChroma, secondary.h),\n contrastText: labelOn(secondary.main, secondary.h),\n },\n tertiary: {\n main: tertiary,\n light: aiOklchHex(Math.min(0.9, tertiaryL + 0.14), 0.12, tertiaryHue),\n dark: aiOklchHex(Math.max(0.15, tertiaryL - 0.1), 0.12, tertiaryHue),\n contrastText: labelOn(tertiary, tertiaryHue),\n },\n surface: { main: aiOklchHex(0.955, 0.012 * groundChroma, h), contrastText: aiOklchHex(0.22, textChroma, h) },\n background: { default: background, paper },\n text: {\n primary: aiOklchHex(0.22, textChroma, h),\n secondary: aiOklchHex(0.45, textChroma + 0.005, h),\n disabled: aiOklchHex(0.68, 0.01, h),\n },\n // The primary's tint is the brand's own wash (AGL-3660): a base fills an\n // outlined or tinted button with it, under the primary's dark words.\n tint: {\n primary: aiOklchHex(0.955, neutral ? 0.03 : 0.035, h),\n secondary: aiOklchHex(0.955, 0.035, buttonHue),\n tertiary: aiOklchHex(0.955, 0.03, tertiaryHue),\n },\n divider: aiOklchHex(0.9, 0.012 * groundChroma, h),\n }\n\n const darkGround = style.ground === 'tinted' ? 0.024 : style.ground === 'warm' ? 0.014 : 0.012\n const darkBackground = aiOklchHex(0.17, darkGround * groundChroma, style.ground === 'warm' ? 60 : h)\n const darkPaper = aiOklchHex(0.215, darkGround * groundChroma, style.ground === 'warm' ? 60 : h)\n const darkChroma = Math.min(chroma, 0.14)\n const darkPrimaryL = untilContrast(0.78, darkChroma, h, darkBackground, 4.5, 1)\n const darkPrimary = aiOklchHex(darkPrimaryL, darkChroma, h)\n const darkSecondary = neutral ? aiOklchHex(0.93, 0.01, h) : aiOklchHex(0.45, accentChroma * 0.85, buttonHue)\n const darkTertiary = aiOklchHex(0.8, 0.1, tertiaryHue)\n const dark: HostThemeSchemeColors = {\n primary: {\n main: darkPrimary,\n light: aiOklchHex(Math.min(0.94, darkPrimaryL + 0.08), darkChroma, h),\n dark: aiOklchHex(darkPrimaryL - 0.1, darkChroma, h),\n contrastText: labelOn(darkPrimary, h),\n },\n secondary: {\n main: darkSecondary,\n light: aiOklchHex(0.6, accentChroma * 0.7, secondary.h),\n dark: aiOklchHex(0.35, accentChroma * 0.7, secondary.h),\n contrastText: labelOn(darkSecondary, secondary.h),\n },\n tertiary: {\n main: darkTertiary,\n light: aiOklchHex(0.88, 0.08, tertiaryHue),\n dark: aiOklchHex(0.7, 0.1, tertiaryHue),\n contrastText: labelOn(darkTertiary, tertiaryHue),\n },\n surface: { main: aiOklchHex(0.25, 0.014 * groundChroma, h), contrastText: aiOklchHex(0.95, 0.01, h) },\n background: { default: darkBackground, paper: darkPaper },\n text: {\n primary: aiOklchHex(0.95, 0.008, h),\n secondary: aiOklchHex(0.77, 0.014, h),\n disabled: aiOklchHex(0.52, 0.01, h),\n },\n tint: {\n primary: aiOklchHex(0.27, 0.05, h),\n secondary: aiOklchHex(0.27, 0.05, buttonHue),\n tertiary: aiOklchHex(0.27, 0.04, tertiaryHue),\n },\n divider: aiOklchHex(0.32, 0.015 * groundChroma, h),\n }\n return { light, dark }\n}\n\n// ── The theme ────────────────────────────────────────────────────────────\n\nconst RADIUS: Record<AiSiteCorners, number> = { sharp: 2, soft: 6, round: 12, pill: 18 }\nconst SPACING: Record<AiSiteDensity, number> = { compact: 7, regular: 8, airy: 9 }\n\n/** How much of the heading scale each style takes: a display line grows most, small headings not at all. */\nconst SCALE_SHARE: Partial<Record<HostThemeTypographyVariantKey, { size: number; share: number }>> = {\n displayXl: { size: 4, share: 1.2 },\n h1: { size: 3.25, share: 1 },\n h2: { size: 2.25, share: 0.8 },\n h3: { size: 1.75, share: 0.5 },\n h4: { size: 1.5, share: 0.3 },\n h5: { size: 1.25, share: 0 },\n h6: { size: 1.125, share: 0 },\n}\n\nconst rem = (value: number) => `${Math.round(value * 1000) / 1000}rem`\n\n/**\n * The kinds whose titles are their design (AGL-3660): a portfolio's or a\n * studio's statement, a photographer's name over a cover, a publication's\n * masthead are set larger than a business site's, the way the designer\n * templates set them. The display line grows most, the page title a little,\n * and nothing under it; a phone still steps every size down\n * (`responsiveFontSizes`).\n */\nexport const AI_SITE_DISPLAY_BOOST: Readonly<Record<string, { display: number; title: number }>> = {\n portfolio: { display: 1.25, title: 1.1 },\n studio: { display: 1.3, title: 1.1 },\n photography: { display: 1.2, title: 1.08 },\n blog: { display: 1.25, title: 1.1 },\n}\n\n/** The type a style sets: headings at its scale, weight and tracking, and the eyebrow and button styles. */\nfunction typographyFor(style: AiSiteStyle): HostTheme['typography'] {\n const pairing = aiSiteFontPairing(style.fonts) ?? (AI_SITE_FONT_PAIRINGS[0] as NonNullable<ReturnType<typeof aiSiteFontPairing>>)\n const variants: Partial<Record<HostThemeTypographyVariantKey, HostThemeTypographyVariant>> = {\n ...(DEFAULT_SITE_THEME.typography?.variants ?? {}),\n }\n const boost = AI_SITE_DISPLAY_BOOST[style.kind]\n for (const [key, { size, share }] of Object.entries(SCALE_SHARE) as Array<[HostThemeTypographyVariantKey, { size: number; share: number }]>) {\n const big = key === 'displayXl' || key === 'h1' || key === 'h2'\n const boosted = key === 'displayXl' ? (boost?.display ?? 1) : key === 'h1' ? (boost?.title ?? 1) : 1\n const variant: HostThemeTypographyVariant = {\n fontSize: rem(size * (1 + (style.headingScale - 1) * share) * (pairing.caps && big ? 0.92 : 1) * boosted),\n fontWeight: big ? pairing.heading.weight : pairing.heading.sub,\n // A display line set larger sets tighter.\n lineHeight: big ? (pairing.caps ? 1.05 : key === 'displayXl' && boost ? 1.02 : 1.1) : 1.25,\n }\n if (pairing.tracking !== undefined && (big || key === 'h3')) variant.letterSpacing = `${pairing.tracking}em`\n if (pairing.caps && (big || key === 'h3')) variant.textTransform = 'uppercase'\n variants[key] = variant\n }\n const bodyBold = pairing.body.weights.includes(600) ? 600 : 700\n variants.overline =\n style.eyebrow === 'small'\n ? { fontSize: '0.875rem', fontWeight: bodyBold, letterSpacing: '0.01em', textTransform: 'none' }\n : { fontSize: '0.78rem', fontWeight: 700, letterSpacing: style.eyebrow === 'rule' ? '0.16em' : '0.12em', textTransform: 'uppercase' }\n variants.button = {\n fontWeight: style.buttons === 'caps' ? 700 : bodyBold,\n textTransform: style.buttons === 'caps' ? 'uppercase' : 'none',\n ...(style.buttons === 'caps' ? { letterSpacing: '0.06em' } : {}),\n }\n return { variants }\n}\n\n/** The card's look, in theme terms only: palette paths, shadow indexes and border widths. */\nfunction cardSx(cards: AiSiteCards): Record<string, unknown> {\n switch (cards) {\n case 'flat':\n return { boxShadow: 0, border: 0, bgcolor: 'surface.main' }\n case 'outlined':\n return { boxShadow: 0, border: 1, borderColor: 'divider', bgcolor: 'background.paper' }\n case 'elevated':\n return { boxShadow: 3, border: 0, bgcolor: 'background.paper' }\n case 'tinted':\n return { boxShadow: 0, border: 0, bgcolor: 'tint.primary' }\n case 'rule':\n return { boxShadow: 0, border: 0, borderTop: 3, borderColor: 'primary.main', borderRadius: 0, bgcolor: 'background.paper' }\n }\n}\n\n/** The component defaults and styles a style sets: buttons, cards, fields, eyebrows, the header bar and the FAQ. */\nfunction componentsFor(style: AiSiteStyle): Record<string, HostThemeComponentOverride> {\n const radius = RADIUS[style.corners]\n const buttonRadius = style.buttons === 'pill' ? 999 : style.buttons === 'square' ? 2 : radius\n const card = cardSx(style.cards)\n return {\n MuiButton: {\n defaultProps: { disableElevation: true },\n // 44px: the touch target a visitor's thumb needs.\n styleOverrides: { root: { borderRadius: buttonRadius, minHeight: 44, boxShadow: 'none' } },\n ...(style.buttons === 'link'\n ? {\n variants: [\n {\n props: { variant: 'text' },\n style: { textDecoration: 'underline', textUnderlineOffset: '0.3em', textDecorationThickness: '2px' },\n },\n ],\n }\n : {}),\n },\n MuiCard: {\n defaultProps:\n style.cards === 'outlined'\n ? { variant: 'outlined' }\n : { variant: 'elevation', elevation: style.cards === 'elevated' ? 3 : 0 },\n styleOverrides: { root: { borderRadius: style.cards === 'rule' ? 0 : Math.max(radius, 4) } },\n sx: { root: card },\n },\n MuiAccordion: {\n defaultProps: { disableGutters: true, elevation: 0 },\n sx: {\n root: {\n ...card,\n borderTop: style.cards === 'rule' ? 1 : card['borderTop'] ?? card['border'],\n '&::before': { display: 'none' },\n '&:not(:last-of-type)': { mb: 1 },\n },\n },\n },\n MuiTextField: { defaultProps: { variant: style.fields } },\n MuiOutlinedInput: { styleOverrides: { root: { borderRadius: radius } } },\n MuiFilledInput: { styleOverrides: { root: { borderTopLeftRadius: radius, borderTopRightRadius: radius } } },\n MuiChip: { styleOverrides: { root: { borderRadius: style.corners === 'sharp' ? 2 : 999 } } },\n MuiAppBar: {\n defaultProps: { elevation: 0 },\n variants: [\n {\n props: { color: 'inherit' },\n sx:\n style.header === 'line'\n ? { boxShadow: 0, borderBottom: 1, borderColor: 'divider' }\n : style.header === 'shadow'\n ? { boxShadow: 2, borderBottom: 0 }\n : { boxShadow: 0, borderBottom: 0 },\n },\n ],\n },\n ...(style.eyebrow === 'rule'\n ? {\n MuiTypography: {\n variants: [\n {\n props: { variant: 'overline' },\n // A short line in the eyebrow's own color, so it reads on any band.\n style: {\n '&::before': {\n content: '\"\"',\n display: 'inline-block',\n width: '1.75em',\n height: '2px',\n marginRight: '0.75em',\n verticalAlign: 'middle',\n backgroundColor: 'currentColor',\n },\n },\n },\n ],\n },\n }\n : {}),\n }\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value)\n}\n\n/** `over` merged into `under`, objects key by key, anything else replaced. */\nfunction merged<T>(under: T, over: unknown): T {\n if (!isRecord(under) || !isRecord(over)) return (over === undefined ? under : over) as T\n const out: Record<string, unknown> = { ...under }\n for (const [key, value] of Object.entries(over)) out[key] = key in out ? merged(out[key], value) : value\n return out as T\n}\n\n/** Whether a theme passes the publish check and the brand-on-page contrast the doctrine asks. */\nfunction themeReads(theme: HostTheme): boolean {\n if (!validateThemeForPublish(theme).ok) return false\n for (const scheme of ['light', 'dark'] as const) {\n const colors = theme.colorSchemes?.[scheme]\n const main = colors?.primary?.main\n const page = colors?.background?.default\n if (!main || !page || ratio(main, page) < 3) return false\n for (const key of ['primary', 'secondary', 'tertiary'] as const) {\n const fill = colors?.[key]\n if (fill?.main && fill.contrastText && ratio(fill.contrastText, fill.main) < 4.5) return false\n }\n }\n return true\n}\n\n/**\n * The site's theme: the base theme with this style layered over it. Colors,\n * type, corners, spacing and the building blocks' component styles are the\n * site's own; whatever the base sets beyond them — its focus rings, its menu\n * and dialog styles, its control heights — stays the base's.\n */\nexport function aiSiteTheme(style: AiSiteStyle, base: HostTheme): HostTheme {\n const pairing = aiSiteFontPairing(style.fonts) ?? (AI_SITE_FONT_PAIRINGS[0] as NonNullable<ReturnType<typeof aiSiteFontPairing>>)\n const colors = aiSiteColors(style)\n const keep = (scheme: 'light' | 'dark') => {\n const own = base.colorSchemes?.[scheme] ?? {}\n // The status colors stay the base's: they mean the same thing on every site.\n return {\n ...(own.error ? { error: own.error } : {}),\n ...(own.warning ? { warning: own.warning } : {}),\n ...(own.info ? { info: own.info } : {}),\n ...(own.success ? { success: own.success } : {}),\n ...colors[scheme],\n }\n }\n let theme: HostTheme = {\n ...base,\n colorSchemes: { light: keep('light'), dark: keep('dark') },\n typography: merged(base.typography ?? {}, typographyFor(style)),\n shape: { ...(base.shape ?? {}), borderRadius: RADIUS[style.corners] },\n spacing: SPACING[style.density],\n components: merged(base.components ?? {}, componentsFor(style)),\n }\n delete theme.darkScheme\n // A site brought in is set in its source's own families (AGL-4108), at the\n // weights the pairing draws with, as near as each family has them.\n const headingWeights = [pairing.heading.weight, pairing.heading.sub]\n const source = style.sourceFonts ?? null\n const body = source?.body\n ? { family: source.body.family, category: source.body.category, weights: aiSiteFontWeightsIn(pairing.body.weights, source.body.weights) }\n : { family: pairing.body.family, category: pairing.body.category, weights: [...pairing.body.weights] }\n const heading = source\n ? source.heading\n ? { family: source.heading.family, category: source.heading.category, weights: aiSiteFontWeightsIn(headingWeights, source.heading.weights) }\n : { ...body, weights: aiSiteFontWeightsIn(headingWeights, source.body.weights) }\n : { family: pairing.heading.family, category: pairing.heading.category, weights: [...new Set(headingWeights)].sort((a, b) => a - b) }\n const sameFamily = heading.family.toLowerCase() === body.family.toLowerCase()\n theme = writeThemeFonts(theme, {\n body: { ...body, source: 'google' },\n heading: sameFamily ? null : { ...heading, source: 'google' },\n })\n // A heading in the body's family loads the heading weights too.\n if (sameFamily && theme.fonts?.[0]) {\n theme.fonts[0] = {\n ...theme.fonts[0],\n weights: [...new Set([...(theme.fonts[0].weights ?? []), ...heading.weights])].sort((a, b) => a - b),\n }\n }\n if (!themeReads(theme)) {\n // Never a theme that fails the reading checks: the starter's colors, with everything else kept.\n theme = { ...theme, colorSchemes: DEFAULT_SITE_THEME.colorSchemes }\n }\n return theme\n}\n\n// ── A kind's first look (AGL-4049) ──────────────────────────────────────────\n\n/** The midpoint of a kind's first hue range, or `null` when it spans the whole wheel (any hue suits it). */\nfunction firstHueOf(hues: AiSiteKind['look']['hues']): number | null {\n const [from, to] = hues?.[0] ?? [0, 360]\n const span = from <= to ? to - from : 360 - from + to\n if (span >= 360) return null\n return Math.round(from + span / 2) % 360\n}\n\n/** A kind's first look as a built-in theme with a brand over it, and the style answers that say the same. */\nexport interface AiSiteKindDefaultLook {\n /** The `builtin` starter theme a site created in this style starts with. */\n theme: {\n kind: 'builtin'\n base: string\n brand: { light: Record<string, string>; dark?: Record<string, string> }\n fonts: string | null\n }\n /** The same look as the AI start's style answers name it (`fp-starter-{kind}-ai`). */\n answerStyle: {\n base: string\n hue?: number\n ground: AiSiteGround\n fonts: string | null\n corners: AiSiteCorners\n buttons: AiSiteButtons\n }\n}\n\n/**\n * A kind of site's FIRST look (AGL-4049), the one a site created in that\n * style starts with and the one the platform's own starter listings carry:\n * the kind's first base theme the deployment has (`starter`, or a built-in\n * whose preset `known.presetIds` holds), its first font pairing the platform\n * has, and a brand primary from the midpoint of its first hue range, colored\n * as {@link aiSiteColors} colors one. A kind that suits any hue keeps the\n * base's own colors. One derivation, so the style a person picks in Create\n * site and the seeded `fp-starter-{kind}-base` listing look the same.\n *\n * Deterministic: no draw, the seed is the kind's id.\n */\nexport function aiSiteKindDefaultLook(\n kind: AiSiteKind,\n known: { presetIds: ReadonlySet<string>; pairingIds?: ReadonlySet<string> },\n): AiSiteKindDefaultLook {\n const family = kind.look\n const pairingIds = known.pairingIds ?? new Set(AI_SITE_FONT_PAIRINGS.map((pairing) => pairing.id))\n const base =\n family.bases.find((name) => name === 'starter' || known.presetIds.has(`theme-presets.${name}`)) ?? 'starter'\n const fonts = family.fonts.find((id) => pairingIds.has(id)) ?? null\n const hue = firstHueOf(family.hues)\n const ground = family.grounds[0] as AiSiteGround\n const corners = family.corners[0] as AiSiteCorners\n const colors =\n hue === null\n ? null\n : aiSiteColors({\n v: 1,\n kind: kind.id,\n base,\n seed: aiSiteSeed(kind.id),\n hue,\n accent: hue,\n chroma: family.chroma,\n ground,\n fonts: fonts ?? '',\n corners,\n buttons: family.buttons,\n // Not read by the colors; named so the style is whole.\n cards: 'flat',\n fields: 'outlined',\n eyebrow: 'caps',\n header: 'line',\n headerAlign: 'start',\n rhythm: 'calm',\n headingScale: family.headingScale,\n density: family.density,\n brand: null,\n })\n const primary = (scheme: 'light' | 'dark') => {\n const value = colors?.[scheme]?.primary\n return value && typeof value === 'object' && typeof (value as { main?: unknown }).main === 'string'\n ? (value as { main: string }).main\n : null\n }\n const light = primary('light')\n const dark = primary('dark')\n const brand = light && dark ? { light: { primary: light }, dark: { primary: dark } } : { light: {} }\n return {\n theme: { kind: 'builtin', base, brand, fonts },\n answerStyle: {\n base,\n ...(hue === null ? {} : { hue }),\n ground,\n fonts,\n corners,\n buttons: family.buttons,\n },\n }\n}\n"],"names":["contrastRatio","validateThemeForPublish","DEFAULT_SITE_THEME","writeThemeFonts","AI_SITE_MOTION_STYLES","aiSiteMotionStyle","aiSiteMotionStylesFor","AI_SITE_BASES","AI_SITE_CORNERS","AI_SITE_FONT_PAIRINGS","AI_SITE_GROUNDS","AI_SITE_RHYTHMS","aiSiteFontPairing","AI_SITE_CARDS","AI_SITE_FIELDS","AI_SITE_EYEBROWS","AI_SITE_HEADERS","AI_SITE_BUTTONS","DENSITIES","aiSiteFontWeightsIn","wanted","offered","length","Set","sort","a","b","nearest","weight","reduce","best","each","Math","abs","map","aiSiteSeed","jobId","hash","index","charCodeAt","imul","random","seed","state","t","pick","next","list","floor","AI_SITE_LOOK_TOOL_NAME","enumOf","values","description","type","enum","AI_SITE_LOOK_TOOL","name","strict","inputSchema","additionalProperties","required","properties","base","hue","accent","ground","fonts","pairing","id","corners","buttons","cards","fields","eyebrow","header","brand","anyOf","motion","oneOf","value","includes","undefined","hueOf","Number","isFinite","round","aiSiteBrandHex","match","exec","trim","hex","full","digit","join","toLowerCase","aiReadSiteLook","answer","raw","look","BLOCK_BIAS","portfolio","studio","photography","blog","trades","fitness","professional","wellness","yoga","restaurant","beauty","music","ANY_BLOCKS","aiSiteHueFamily","rangeOf","kind","hues","findIndex","from","to","AI_SITE_LOOK_DIMENSIONS","aiSiteLookSignature","style","hueFamily","String","headerAlign","rhythm","aiSiteStyleFor","input","avoid","styleOnce","signatures","attempt","AI_SITE_LOOK_DRAWS","own","least","min","other","TUPLE","every","dimension","filter","AI_SITE_LOOK_LEAST_DIFFERENCES","withPins","drawOnce","pins","Object","keys","rest","pinned","fromEntries","entries","family","blocks","choose","model","options","keep","modelRange","keepHue","range","span","accentFrom","bases","v","chroma","grounds","headerAligns","rhythms","headingScale","density","AI_SITE_MOTION_KEEP","oklabToLinear","L","l","m","s","toSrgb","channel","fromSrgb","aiOklchHex","C","h","lightness","max","radians","PI","linear","cos","sin","fits","toString","padStart","aiHexOklch","replace","r","g","at","parseInt","slice","cbrt","A","B","hypot","atan2","ratio","untilContrast","against","toward","step","labelOn","fill","white","ink","aiHueGap","d","AI_SITE_ACCENT_CLASH_DEGREES","CHROMA","neutral","muted","balanced","vivid","START_L","aiSiteColors","groundChroma","paper","warm","cool","tinted","page","test","background","primaryMain","primaryL","accentChroma","buttonHue","secondary","main","washChroma","tertiaryHue","tertiaryL","tertiary","textChroma","light","primary","dark","contrastText","surface","default","text","disabled","tint","divider","darkGround","darkBackground","darkPaper","darkChroma","darkPrimaryL","darkPrimary","darkSecondary","darkTertiary","RADIUS","sharp","soft","pill","SPACING","compact","regular","airy","SCALE_SHARE","displayXl","size","share","h1","h2","h3","h4","h5","h6","rem","AI_SITE_DISPLAY_BOOST","display","title","typographyFor","variants","typography","boost","key","big","boosted","variant","fontSize","caps","fontWeight","heading","sub","lineHeight","tracking","letterSpacing","textTransform","bodyBold","body","weights","overline","button","cardSx","boxShadow","border","bgcolor","borderColor","borderTop","borderRadius","componentsFor","card","radius","buttonRadius","MuiButton","defaultProps","disableElevation","styleOverrides","root","minHeight","props","textDecoration","textUnderlineOffset","textDecorationThickness","MuiCard","elevation","sx","MuiAccordion","disableGutters","mb","MuiTextField","MuiOutlinedInput","MuiFilledInput","borderTopLeftRadius","borderTopRightRadius","MuiChip","MuiAppBar","color","borderBottom","MuiTypography","content","width","height","marginRight","verticalAlign","backgroundColor","isRecord","Array","isArray","merged","under","over","out","themeReads","theme","ok","scheme","colors","colorSchemes","aiSiteTheme","error","warning","info","success","shape","spacing","components","darkScheme","headingWeights","source","sourceFonts","category","sameFamily","firstHueOf","aiSiteKindDefaultLook","known","pairingIds","find","presetIds","has","answerStyle"],"mappings":";;AAAA;;;;;;;;;;;;;;;CAeC,GAED,SACEA,aAAa,EACbC,uBAAuB,QAClB,oCAAmC;AAC1C,SAASC,kBAAkB,QAAQ,sCAAqC;AASxE,SAASC,eAAe,QAAQ,kDAAiD;AACjF,SACEC,qBAAqB,EACrBC,iBAAiB,EACjBC,qBAAqB,QAEhB,yCAAqC;AAE5C,SACEC,aAAa,EACbC,eAAe,EACfC,qBAAqB,EACrBC,eAAe,EACfC,eAAe,EACfC,iBAAiB,QASZ,qBAAiB;AAExB;;;;;;;;;;;;;;;;;;;;;;;;;CAyBC,GAED,4EAA4E;AAE5E,yBAAyB,GACzB,OAAO,MAAMC,gBAAgB;IAAC;IAAQ;IAAY;IAAY;IAAU;CAAO,CAAS;AAExF,0BAA0B,GAC1B,OAAO,MAAMC,iBAAiB;IAAC;IAAY;IAAU;CAAW,CAAS;AAEzE,2CAA2C,GAC3C,OAAO,MAAMC,mBAAmB;IAAC;IAAQ;IAAS;CAAO,CAAS;AAElE,+CAA+C,GAC/C,OAAO,MAAMC,kBAAkB;IAAC;IAAQ;IAAU;CAAO,CAAS;AAElE,8EAA8E,GAC9E,OAAO,MAAMC,k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,OAAO,CAAC,IAAI;YAAEA;QAAI;YAC9BE;YACAC;YACAG;YACAC,SAASkF,OAAOlF,OAAO;;IAE3B;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/model/ai-site-look.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n contrastRatio,\n validateThemeForPublish,\n} from '@aglyn/aglyn/app-utils/site-theme'\nimport { DEFAULT_SITE_THEME } from '@aglyn/aglyn/app-utils/default-site'\nimport type {\n HostTheme,\n HostThemeComponentOverride,\n HostThemeFontCategory,\n HostThemeSchemeColors,\n HostThemeTypographyVariant,\n HostThemeTypographyVariantKey,\n} from '@aglyn/shared-data-types'\nimport { writeThemeFonts } from '@aglyn/shared-ui-theme/util/theme-editor-fields'\nimport {\n AI_SITE_MOTION_STYLES,\n aiSiteMotionStyle,\n aiSiteMotionStylesFor,\n type AiSiteMotionStyle,\n} from '../layout-language/ai-layout-motion'\nimport type { AiTool } from '../runtime/ai-runtime'\nimport {\n AI_SITE_BASES,\n AI_SITE_CORNERS,\n AI_SITE_FONT_PAIRINGS,\n AI_SITE_GROUNDS,\n AI_SITE_RHYTHMS,\n aiSiteFontPairing,\n type AiSiteBase,\n type AiSiteButtons,\n type AiSiteChroma,\n type AiSiteCorners,\n type AiSiteDensity,\n type AiSiteGround,\n type AiSiteKind,\n type AiSiteRhythm,\n} from './ai-site-kinds'\n\n/**\n * A site's look (AGL-3660): one of the platform's base themes, and this\n * site's own customizations layered over it as the site theme's override —\n * the same base-and-edits shape a person's pick on Setup → Theme is stored\n * as, so the Theme page names the base it came from and every edit there\n * starts from what the AI chose.\n *\n * Everything the look decides lives in the THEME, never on a node: palette,\n * fonts, type scale, corners, spacing, and the component defaults and styles\n * of buttons, cards, fields, eyebrows, the header bar and the FAQ. So a Card\n * or a Button a person drags in later looks like the rest of the site, and\n * the layout compiler emits plain components.\n *\n * Three inputs decide it:\n * - the KIND (`ai-site-kinds.ts`): the family of looks that suit the site;\n * - the MODEL's choices for this business (`submit_site_look`), any of\n * which may be missing;\n * - the per-job SEED, which fills what the model left out from the kind's\n * options and nudges every hue, chroma and size, so two jobs with the same\n * brief and the same answers still produce two different themes.\n *\n * Colors are built in OKLCH and held to WCAG: body text 4.5:1 on its ground\n * and on paper, every button label 4.5:1 on its fill, the brand color 3:1 on\n * the page — then the whole theme passes `validateThemeForPublish`, or its\n * colors fall back to the starter theme's.\n */\n\n// ── The tokens ───────────────────────────────────────────────────────────\n\n/** How cards are drawn. */\nexport const AI_SITE_CARDS = ['flat', 'outlined', 'elevated', 'tinted', 'rule'] as const\nexport type AiSiteCards = (typeof AI_SITE_CARDS)[number]\n/** The form field style. */\nexport const AI_SITE_FIELDS = ['outlined', 'filled', 'standard'] as const\nexport type AiSiteFields = (typeof AI_SITE_FIELDS)[number]\n/** How an eyebrow above a heading is set. */\nexport const AI_SITE_EYEBROWS = ['caps', 'small', 'rule'] as const\nexport type AiSiteEyebrow = (typeof AI_SITE_EYEBROWS)[number]\n/** What sets a plain header bar off the page. */\nexport const AI_SITE_HEADERS = ['line', 'shadow', 'flat'] as const\nexport type AiSiteHeader = (typeof AI_SITE_HEADERS)[number]\n/** Button shapes and casing; `link` draws quiet buttons as underlined links. */\nexport const AI_SITE_BUTTONS: readonly AiSiteButtons[] = ['rounded', 'pill', 'square', 'caps', 'link']\nconst DENSITIES: readonly AiSiteDensity[] = ['compact', 'regular', 'airy']\n\n/**\n * A site's style tokens: everything its theme was built from. Stored with the\n * site (`hosts/{id}.siteStyle`) so a later AI edit keeps the look.\n */\nexport interface AiSiteStyle {\n v: 1\n kind: string\n base: AiSiteBase\n seed: number\n hue: number\n accent: number\n chroma: AiSiteChroma\n ground: AiSiteGround\n fonts: string\n corners: AiSiteCorners\n buttons: AiSiteButtons\n cards: AiSiteCards\n fields: AiSiteFields\n eyebrow: AiSiteEyebrow\n header: AiSiteHeader\n /** The header's arrangement: brand at the start and links after it, or both centered. */\n headerAlign: 'start' | 'center'\n /** How the pages alternate their bands. */\n rhythm: AiSiteRhythm\n headingScale: number\n density: AiSiteDensity\n /** A brand color the brief gave, used as the primary color. */\n brand: string | null\n /**\n * How the site's pages arrive (AGL-3941), from `ai-layout-motion.ts`'s\n * vocabulary. Absent on a style stored before the look chose motion, whose\n * pages move in its kind's mood.\n */\n motion?: AiSiteMotionStyle\n /**\n * A site brought in's own page ground (AGL-4108), `#rrggbb`: the color its\n * source's pages sit on, where it is light enough for the theme's text.\n * Absent, the ground is drawn as `ground` says.\n */\n page?: string\n /**\n * A site brought in's own type (AGL-4108): the families its source sets\n * its body and its headings in, where the theme font catalog has them,\n * loaded in place of the pairing's. The pairing still sets the weights and\n * the scale they are drawn at. Absent on every other site, whose type is\n * the pairing's alone.\n */\n sourceFonts?: { body: AiSiteSourceFont; heading: AiSiteSourceFont | null } | null\n /**\n * A site brought in's third color (AGL-4138), `#rrggbb`: the color its\n * source draws its eyebrows in, where that is a color of its own. The theme's\n * tertiary is drawn at the nearest shade of it that reads on the page.\n * Absent, the tertiary sits sixty degrees round from the accent.\n */\n tertiary?: string\n}\n\n/** A family a site brought in is set in (AGL-4108), with the weights the catalog says it has. */\nexport interface AiSiteSourceFont {\n family: string\n category: HostThemeFontCategory\n /** The upright weights the family offers. */\n weights: number[]\n}\n\n/** The weights of `wanted` a family offers, each the nearest it has where it lacks one. */\nexport function aiSiteFontWeightsIn(wanted: readonly number[], offered: readonly number[]): number[] {\n if (!offered.length) return [...new Set(wanted)].sort((a, b) => a - b)\n const nearest = (weight: number) => offered.reduce((best, each) => (Math.abs(each - weight) < Math.abs(best - weight) ? each : best), offered[0] as number)\n return [...new Set(wanted.map(nearest))].sort((a, b) => a - b)\n}\n\n/** What the model may choose, every field optional. */\nexport type AiSiteLookAnswer = Partial<\n Pick<\n AiSiteStyle,\n | 'base'\n | 'hue'\n | 'accent'\n | 'ground'\n | 'fonts'\n | 'corners'\n | 'buttons'\n | 'cards'\n | 'fields'\n | 'eyebrow'\n | 'header'\n | 'brand'\n | 'motion'\n >\n>\n\n/**\n * The dimensions the sites a person likes pin (AGL-3975,\n * `jobs/ai-site-inspiration.ts`): each one present is KEPT, whatever the\n * model or the seed would choose, and every other dimension is chosen as it\n * always is. A brand the person gave in the brief still wins over a pinned\n * brand color, and the hue pinned with it.\n */\nexport type AiSiteLookPins = Partial<\n Pick<\n AiSiteStyle,\n | 'brand'\n | 'hue'\n | 'accent'\n | 'ground'\n | 'fonts'\n | 'corners'\n | 'buttons'\n | 'cards'\n | 'header'\n | 'headerAlign'\n | 'density'\n | 'motion'\n // A site brought in's eyebrows and its third color, as its source draws them (AGL-4138).\n | 'eyebrow'\n | 'tertiary'\n >\n>\n\n// ── The seed ─────────────────────────────────────────────────────────────\n\n/** A job's seed: FNV-1a over its id. */\nexport function aiSiteSeed(jobId: string): number {\n let hash = 0x811c9dc5\n for (let index = 0; index < jobId.length; index += 1) {\n hash ^= jobId.charCodeAt(index)\n hash = Math.imul(hash, 0x01000193)\n }\n return hash >>> 0\n}\n\n/** A small deterministic generator over a seed (mulberry32). */\nfunction random(seed: number): () => number {\n let state = seed >>> 0\n return () => {\n state = (state + 0x6d2b79f5) >>> 0\n let t = state\n t = Math.imul(t ^ (t >>> 15), t | 1)\n t ^= t + Math.imul(t ^ (t >>> 7), t | 61)\n return ((t ^ (t >>> 14)) >>> 0) / 4294967296\n }\n}\n\nconst pick = <T,>(next: () => number, list: readonly T[]): T => list[Math.floor(next() * list.length) % list.length] as T\n\n// ── The model's answer ───────────────────────────────────────────────────\n\nexport const AI_SITE_LOOK_TOOL_NAME = 'submit_site_look'\n\nconst enumOf = (values: readonly string[], description: string) => ({ type: 'string', enum: [...values], description })\n\n/** The strict tool the look is answered with; every field is required and the reader is lenient. */\nexport const AI_SITE_LOOK_TOOL: AiTool = {\n name: AI_SITE_LOOK_TOOL_NAME,\n description: \"Submit this website's look: the base theme it starts from and the choices that make it this business's own.\",\n strict: true,\n inputSchema: {\n type: 'object',\n additionalProperties: false,\n required: ['base', 'hue', 'accent', 'ground', 'fonts', 'corners', 'buttons', 'cards', 'fields', 'eyebrow', 'header', 'brand', 'motion'],\n properties: {\n base: enumOf(AI_SITE_BASES, 'The base theme to start from, from the list in the request.'),\n hue: { type: 'integer', description: 'The brand color as a hue from 0 to 359 (0 red, 30 orange, 55 gold, 140 green, 190 teal, 220 blue, 270 violet, 330 pink).' },\n accent: { type: 'integer', description: 'The accent color as a hue from 0 to 359, chosen to sit well beside the brand hue.' },\n ground: enumOf(AI_SITE_GROUNDS, 'The page background: white, warm (cream), cool (gray-blue) or tinted (a whisper of the brand color).'),\n fonts: enumOf(AI_SITE_FONT_PAIRINGS.map((pairing) => pairing.id), 'A font pairing from the list in the request.'),\n corners: enumOf(AI_SITE_CORNERS, 'Corner rounding for cards and fields.'),\n buttons: enumOf(AI_SITE_BUTTONS, 'Buttons: rounded, pill, square, caps (capitals) or link (quiet buttons drawn as underlined links).'),\n cards: enumOf(AI_SITE_CARDS, 'Cards: flat, outlined, elevated (a soft shadow), tinted (a wash of the brand color) or rule (a colored line on top).'),\n fields: enumOf(AI_SITE_FIELDS, 'Form fields: outlined, filled or standard (underlined).'),\n eyebrow: enumOf(AI_SITE_EYEBROWS, 'The small label above headings: caps (spaced capitals), small (quiet small text) or rule (capitals after a short line).'),\n header: enumOf(AI_SITE_HEADERS, 'What sets the header bar off the page: a line, a shadow, or flat.'),\n brand: { anyOf: [{ type: 'string' }, { type: 'null' }], description: 'A hex brand color the brief gives, exactly as written, or null.' },\n motion: enumOf(AI_SITE_MOTION_STYLES, 'How the pages arrive as a visitor scrolls, from the motion list in the request.'),\n },\n },\n}\n\nconst oneOf = <T extends string>(value: unknown, values: readonly T[]): T | undefined =>\n typeof value === 'string' && (values as readonly string[]).includes(value) ? (value as T) : undefined\n\nconst hueOf = (value: unknown): number | undefined =>\n typeof value === 'number' && Number.isFinite(value) ? ((Math.round(value) % 360) + 360) % 360 : undefined\n\n/** A brand color as a six-digit hex, or `null`. */\nexport function aiSiteBrandHex(value: unknown): string | null {\n if (typeof value !== 'string') return null\n const match = /#?([0-9a-f]{6}|[0-9a-f]{3})\\b/i.exec(value.trim())\n if (!match) return null\n const hex = match[1] as string\n const full = hex.length === 3 ? [...hex].map((digit) => digit + digit).join('') : hex\n return `#${full.toLowerCase()}`\n}\n\n/** The model's answer, read leniently: a value outside its vocabulary is left for the seed. */\nexport function aiReadSiteLook(answer: unknown): AiSiteLookAnswer {\n const raw = (answer && typeof answer === 'object' ? answer : {}) as Record<string, unknown>\n const look: AiSiteLookAnswer = {}\n const base = oneOf(raw['base'], AI_SITE_BASES)\n if (base) look.base = base\n const hue = hueOf(raw['hue'])\n if (hue !== undefined) look.hue = hue\n const accent = hueOf(raw['accent'])\n if (accent !== undefined) look.accent = accent\n const ground = oneOf(raw['ground'], AI_SITE_GROUNDS)\n if (ground) look.ground = ground\n if (aiSiteFontPairing(raw['fonts'])) look.fonts = raw['fonts'] as string\n const corners = oneOf(raw['corners'], AI_SITE_CORNERS)\n if (corners) look.corners = corners\n const buttons = oneOf(raw['buttons'], AI_SITE_BUTTONS)\n if (buttons) look.buttons = buttons\n const cards = oneOf(raw['cards'], AI_SITE_CARDS)\n if (cards) look.cards = cards\n const fields = oneOf(raw['fields'], AI_SITE_FIELDS)\n if (fields) look.fields = fields\n const eyebrow = oneOf(raw['eyebrow'], AI_SITE_EYEBROWS)\n if (eyebrow) look.eyebrow = eyebrow\n const header = oneOf(raw['header'], AI_SITE_HEADERS)\n if (header) look.header = header\n const brand = aiSiteBrandHex(raw['brand'])\n if (brand) look.brand = brand\n const motion = aiSiteMotionStyle(raw['motion'])\n if (motion) look.motion = motion\n return look\n}\n\n// ── Kind, model and seed into tokens ─────────────────────────────────────\n\n/** The building-block styles a kind leans to, before the model or the seed choose. */\nconst BLOCK_BIAS: Partial<\n Record<string, { cards: readonly AiSiteCards[]; eyebrow: readonly AiSiteEyebrow[]; header: readonly AiSiteHeader[]; fields: readonly AiSiteFields[] }>\n> = {\n portfolio: { cards: ['rule', 'flat', 'outlined'], eyebrow: ['small', 'rule', 'caps'], header: ['flat', 'line', 'shadow'], fields: ['standard', 'outlined', 'filled'] },\n studio: { cards: ['flat', 'rule', 'outlined'], eyebrow: ['rule', 'small', 'caps'], header: ['flat', 'line', 'shadow'], fields: ['standard', 'outlined', 'filled'] },\n photography: { cards: ['flat', 'rule', 'outlined'], eyebrow: ['small', 'rule', 'caps'], header: ['flat', 'line', 'shadow'], fields: ['standard', 'outlined', 'filled'] },\n blog: { cards: ['rule', 'outlined', 'flat', 'tinted'], eyebrow: ['small', 'caps', 'rule'], header: ['line', 'flat', 'shadow'], fields: ['outlined', 'standard', 'filled'] },\n trades: { cards: ['elevated', 'outlined', 'rule', 'flat', 'tinted'], eyebrow: ['caps', 'rule', 'small'], header: ['shadow', 'line', 'flat'], fields: ['outlined', 'filled', 'standard'] },\n fitness: { cards: ['elevated', 'flat', 'rule', 'outlined'], eyebrow: ['caps', 'rule', 'small'], header: ['shadow', 'flat', 'line'], fields: ['filled', 'outlined', 'standard'] },\n professional: { cards: ['outlined', 'rule', 'flat', 'elevated'], eyebrow: ['caps', 'rule', 'small'], header: ['line', 'flat', 'shadow'], fields: ['outlined', 'standard', 'filled'] },\n wellness: { cards: ['tinted', 'flat', 'elevated', 'outlined'], eyebrow: ['small', 'caps', 'rule'], header: ['flat', 'line', 'shadow'], fields: ['filled', 'outlined', 'standard'] },\n yoga: { cards: ['tinted', 'flat', 'outlined'], eyebrow: ['small', 'rule', 'caps'], header: ['flat', 'line', 'shadow'], fields: ['filled', 'standard', 'outlined'] },\n restaurant: { cards: ['flat', 'elevated', 'tinted', 'rule'], eyebrow: ['caps', 'rule', 'small'], header: ['flat', 'shadow', 'line'], fields: ['outlined', 'filled', 'standard'] },\n beauty: { cards: ['tinted', 'flat', 'outlined', 'rule'], eyebrow: ['rule', 'small', 'caps'], header: ['flat', 'line', 'shadow'], fields: ['standard', 'filled', 'outlined'] },\n music: { cards: ['flat', 'rule', 'elevated'], eyebrow: ['caps', 'rule', 'small'], header: ['flat', 'shadow', 'line'], fields: ['filled', 'standard', 'outlined'] },\n}\nconst ANY_BLOCKS = { cards: AI_SITE_CARDS, eyebrow: AI_SITE_EYEBROWS, header: AI_SITE_HEADERS, fields: AI_SITE_FIELDS }\n\n/** The hue family a hue is in: twelve families of thirty degrees, 0 the reds. */\nexport function aiSiteHueFamily(hue: number): number {\n return Math.floor((((hue + 15) % 360) + 360) % 360 / 30)\n}\n\n/** Which of a kind's hue ranges a hue falls in, or -1. */\nfunction rangeOf(hue: number, kind: AiSiteKind): number {\n return kind.look.hues.findIndex(([from, to]) => (from <= to ? hue >= from && hue <= to : hue >= from || hue <= to))\n}\n\n/** The look dimensions two sites are compared by (`ai-site-look.spec.ts`). */\nexport const AI_SITE_LOOK_DIMENSIONS = [\n 'base',\n 'hueFamily',\n 'fonts',\n 'buttons',\n 'cards',\n 'corners',\n 'ground',\n 'eyebrow',\n 'header',\n 'fields',\n 'headerAlign',\n 'rhythm',\n] as const\n\n/** A style's value on each tracked dimension. */\nexport function aiSiteLookSignature(style: AiSiteStyle): Record<(typeof AI_SITE_LOOK_DIMENSIONS)[number], string> {\n return {\n base: style.base,\n hueFamily: String(aiSiteHueFamily(style.hue)),\n fonts: style.fonts,\n buttons: style.buttons,\n cards: style.cards,\n corners: style.corners,\n ground: style.ground,\n eyebrow: style.eyebrow,\n header: style.header,\n fields: style.fields,\n headerAlign: style.headerAlign,\n rhythm: style.rhythm,\n }\n}\n\n/**\n * The style tokens for a site of this kind (AGL-3660). Every dimension is\n * the SEED's choice among what suits the kind, with the model's choice for\n * this business as a favored candidate — kept at a given chance, not always\n * — so the brief steers the look and two jobs with the same brief and the\n * same answer still come out as two sites: another base, another hue family,\n * another pairing, other buttons. A brand color the brief gives is always\n * kept.\n */\nexport function aiSiteStyleFor(input: {\n kind: AiSiteKind\n answer: AiSiteLookAnswer\n seed: number\n brand?: string | null\n /**\n * The looks of the workspace's other sites (AGL-3660): a look that shares\n * one's base, hue family, heading font and buttons, or differs from one in\n * fewer than three tracked dimensions, is drawn again from the next seed.\n */\n avoid?: readonly AiSiteStyle[]\n /** What the sites the person likes pin (AGL-3975): kept on every draw. */\n pins?: AiSiteLookPins\n}): AiSiteStyle {\n const avoid = input.avoid ?? []\n if (!avoid.length) return styleOnce(input, input.seed)\n const signatures = avoid.map(aiSiteLookSignature)\n let best: { style: AiSiteStyle; least: number } | null = null\n for (let attempt = 0; attempt < AI_SITE_LOOK_DRAWS; attempt += 1) {\n const style = styleOnce(input, attempt === 0 ? input.seed : (Math.imul(input.seed ^ 0x5bd1e995, attempt + 1) >>> 0))\n const own = aiSiteLookSignature(style)\n const least = Math.min(\n ...signatures.map((other) =>\n TUPLE.every((dimension) => own[dimension] === other[dimension])\n ? -1\n : AI_SITE_LOOK_DIMENSIONS.filter((dimension) => own[dimension] !== other[dimension]).length,\n ),\n )\n if (least >= AI_SITE_LOOK_LEAST_DIFFERENCES) return style\n if (!best || least > best.least) best = { style, least }\n }\n return (best as { style: AiSiteStyle }).style\n}\n\n/** How many seeds a look draws before it settles for the most different. */\nexport const AI_SITE_LOOK_DRAWS = 32\n/** The fewest tracked dimensions in which two of a workspace's sites differ. */\nexport const AI_SITE_LOOK_LEAST_DIFFERENCES = 3\n/** The dimensions no two of a workspace's sites share all of. */\nconst TUPLE = ['base', 'hueFamily', 'fonts', 'buttons'] as const\n\nfunction styleOnce(\n input: { kind: AiSiteKind; answer: AiSiteLookAnswer; brand?: string | null; pins?: AiSiteLookPins },\n seed: number,\n): AiSiteStyle {\n return withPins(drawOnce(input, seed), input)\n}\n\n/**\n * A drawn style with its pins laid over it (AGL-3975). Applied after the\n * draw, so every dimension is drawn the same with or without pins and an\n * unpinned job's look is exactly what it was.\n */\nfunction withPins(style: AiSiteStyle, input: { brand?: string | null; pins?: AiSiteLookPins }): AiSiteStyle {\n const pins = input.pins\n if (!pins || !Object.keys(pins).length) return style\n // The person's own brand color outranks the one their sites suggest.\n const own = aiSiteBrandHex(input.brand)\n const { brand, hue, ...rest } = pins\n const pinned = Object.fromEntries(Object.entries(rest).filter(([, value]) => value !== undefined && value !== null))\n return {\n ...style,\n ...pinned,\n ...(!own && aiSiteBrandHex(brand) ? { brand: aiSiteBrandHex(brand) } : {}),\n ...(!own && typeof hue === 'number' && Number.isFinite(hue) ? { hue: ((Math.round(hue) % 360) + 360) % 360 } : {}),\n }\n}\n\nfunction drawOnce(\n input: { kind: AiSiteKind; answer: AiSiteLookAnswer; brand?: string | null },\n seed: number,\n): AiSiteStyle {\n const { kind, answer } = input\n const next = random(seed)\n const family = kind.look\n const blocks = BLOCK_BIAS[kind.id] ?? ANY_BLOCKS\n /** The model's choice at a chance of `keep`, else the seed's among `options`. */\n const choose = <T,>(model: T | undefined, options: readonly T[], keep: number): T =>\n model !== undefined && next() < keep ? model : pick(next, options)\n\n // The hue: a family among the kind's (the brief's industry), the model's\n // own family favored, and a hue within it.\n const modelRange = answer.hue === undefined ? -1 : rangeOf(answer.hue, kind)\n const keepHue = modelRange !== -1 && next() < 0.3\n const range = keepHue ? modelRange : Math.floor(next() * family.hues.length) % family.hues.length\n const [from, to] = family.hues[range] as readonly [number, number]\n const span = from <= to ? to - from : 360 - from + to\n const hue = keepHue\n ? ((answer.hue as number) + (next() < 0.5 ? -1 : 1) * Math.round(4 + next() * 8) + 360) % 360\n : Math.round(from + next() * span) % 360\n const accentFrom = answer.accent !== undefined && next() < 0.4 ? answer.accent : (hue + pick(next, [30, 150, 180, 210, 330])) % 360\n const accent = (accentFrom + (next() < 0.5 ? -1 : 1) * Math.round(8 + next() * 16) + 360) % 360\n\n const bases = [...new Set([...(answer.base ? [answer.base] : []), ...family.bases])]\n return {\n v: 1,\n kind: kind.id,\n base: choose(answer.base, bases, 0.3),\n seed,\n hue,\n accent,\n chroma: family.chroma,\n ground: choose(answer.ground, family.grounds, 0.35),\n fonts: choose(answer.fonts, family.fonts, 0.3),\n corners: choose(answer.corners, family.corners, 0.35),\n buttons: choose(answer.buttons, [family.buttons, ...AI_SITE_BUTTONS], 0.3),\n cards: choose(answer.cards, blocks.cards, 0.35),\n fields: choose(answer.fields, blocks.fields, 0.35),\n eyebrow: choose(answer.eyebrow, blocks.eyebrow, 0.35),\n header: choose(answer.header, blocks.header, 0.35),\n headerAlign: pick(next, family.headerAligns ?? ['start', 'start', 'center']),\n rhythm: pick(next, family.rhythms ?? AI_SITE_RHYTHMS),\n headingScale: Math.round(family.headingScale * (0.94 + next() * 0.12) * 100) / 100,\n density: family.density === 'regular' && next() < 0.25 ? pick(next, DENSITIES) : family.density,\n brand: aiSiteBrandHex(input.brand) ?? answer.brand ?? null,\n // Drawn last, so every dimension above is drawn the same whether or not\n // the answer chose a motion. The model's choice is kept more often than\n // the other dimensions', because nothing else of the site says how it\n // moves; the seed's draw is among the styles that suit the kind.\n motion: choose(answer.motion, aiSiteMotionStylesFor(kind.id), AI_SITE_MOTION_KEEP),\n }\n}\n\n/** The chance a look keeps the motion style the model chose (AGL-3941). */\nexport const AI_SITE_MOTION_KEEP = 0.6\n\n// ── Color ────────────────────────────────────────────────────────────────\n\ntype Rgb = [number, number, number]\n\nfunction oklabToLinear(L: number, a: number, b: number): Rgb {\n const l = (L + 0.3963377774 * a + 0.2158037573 * b) ** 3\n const m = (L - 0.1055613458 * a - 0.0638541728 * b) ** 3\n const s = (L - 0.0894841775 * a - 1.291485548 * b) ** 3\n return [\n 4.0767416621 * l - 3.3077115913 * m + 0.2309699292 * s,\n -1.2684380046 * l + 2.6097574011 * m - 0.3413193965 * s,\n -0.0041960863 * l - 0.7034186147 * m + 1.707614701 * s,\n ]\n}\n\nconst toSrgb = (channel: number) =>\n channel <= 0.0031308 ? 12.92 * channel : 1.055 * channel ** (1 / 2.4) - 0.055\nconst fromSrgb = (channel: number) =>\n channel <= 0.04045 ? channel / 12.92 : ((channel + 0.055) / 1.055) ** 2.4\n\n/** An OKLCH color as hex, its chroma reduced until it fits sRGB. */\nexport function aiOklchHex(L: number, C: number, h: number): string {\n const lightness = Math.min(1, Math.max(0, L))\n let chroma = Math.max(0, C)\n for (;;) {\n const radians = (h * Math.PI) / 180\n const linear = oklabToLinear(lightness, chroma * Math.cos(radians), chroma * Math.sin(radians))\n const fits = linear.every((channel) => channel >= -0.0005 && channel <= 1.0005)\n if (fits || chroma <= 0) {\n return `#${linear\n .map((channel) => Math.round(Math.min(1, Math.max(0, toSrgb(Math.min(1, Math.max(0, channel))))) * 255))\n .map((value) => value.toString(16).padStart(2, '0'))\n .join('')}`\n }\n chroma = Math.max(0, chroma - 0.004)\n }\n}\n\n/** A hex color in OKLCH. */\nexport function aiHexOklch(hex: string): { L: number; C: number; h: number } {\n const value = hex.replace('#', '')\n const [r, g, b] = [0, 2, 4].map((at) => fromSrgb(parseInt(value.slice(at, at + 2), 16) / 255)) as Rgb\n const l = Math.cbrt(0.4122214708 * r + 0.5363325363 * g + 0.0514459929 * b)\n const m = Math.cbrt(0.2119034982 * r + 0.6806995451 * g + 0.1073969566 * b)\n const s = Math.cbrt(0.0883024619 * r + 0.2817188376 * g + 0.6299787005 * b)\n const L = 0.2104542553 * l + 0.793617785 * m - 0.0040720468 * s\n const A = 1.9779984951 * l - 2.428592205 * m + 0.4505937099 * s\n const B = 0.0259040371 * l + 0.7827717662 * m - 0.808675766 * s\n return { L, C: Math.hypot(A, B), h: ((Math.atan2(B, A) * 180) / Math.PI + 360) % 360 }\n}\n\nconst ratio = (a: string, b: string) => contrastRatio(a, b) ?? 1\n\n/** The lightness, stepped from `L` toward `toward`, at which `hex(L)` first reaches `min` against `against`. */\nfunction untilContrast(L: number, C: number, h: number, against: string, min: number, toward: 0 | 1): number {\n let lightness = L\n for (let step = 0; step < 60; step += 1) {\n if (ratio(aiOklchHex(lightness, C, h), against) >= min) return lightness\n lightness += toward ? 0.012 : -0.012\n if (lightness <= 0.05 || lightness >= 0.98) break\n }\n return lightness\n}\n\n/** The label color of a fill: white or a deep ink of its hue, whichever reads at 4.5:1, or better. */\nfunction labelOn(fill: string, h: number): string {\n const white = '#ffffff'\n const ink = aiOklchHex(0.2, 0.04, h)\n return ratio(white, fill) >= 4.5 ? white : ratio(ink, fill) >= 4.5 ? ink : ratio(white, fill) > ratio(ink, fill) ? white : '#000000'\n}\n\n/** How far apart two hues sit on the wheel, in degrees: 0 to 180. */\nexport function aiHueGap(a: number, b: number): number {\n const d = Math.abs(a - b) % 360\n return Math.min(d, 360 - d)\n}\n\n/**\n * The widest gap an accent may keep from the brand hue and still color a\n * button beside it (AGL-3660). Past it the accent clashes: a live portfolio of\n * green (hue 131) and magenta (323) showed its outlined buttons as a pink wash\n * and its footer button as purple under green words, on a Cupertino base.\n */\nexport const AI_SITE_ACCENT_CLASH_DEGREES = 60\n\nconst CHROMA: Record<AiSiteChroma, number> = { neutral: 0.15, muted: 0.085, balanced: 0.135, vivid: 0.185 }\nconst START_L: Record<AiSiteChroma, number> = { neutral: 0.52, muted: 0.48, balanced: 0.52, vivid: 0.56 }\n\n/** Both schemes' colors for a style. */\nexport function aiSiteColors(style: AiSiteStyle): { light: HostThemeSchemeColors; dark: HostThemeSchemeColors } {\n const next = random(style.seed ^ 0x9e3779b9)\n const neutral = style.chroma === 'neutral'\n const brand = style.brand ? aiHexOklch(style.brand) : null\n const h = brand?.h ?? style.hue\n const chroma = brand?.C ?? CHROMA[style.chroma] * (0.9 + next() * 0.2)\n const groundChroma = neutral ? 0.3 : 1\n const white = '#ffffff'\n\n // The page grounds.\n const grounds: Record<AiSiteGround, { L: number; C: number; h: number; paper: [number, number] }> = {\n white: { L: 0.985, C: 0.004, h, paper: [1, 0] },\n warm: { L: 0.972, C: 0.016, h: 78, paper: [0.993, 0.007] },\n cool: { L: 0.974, C: 0.009, h: 250, paper: [1, 0] },\n tinted: { L: 0.968, C: 0.02, h, paper: [0.994, 0.006] },\n }\n const ground = grounds[style.ground]\n // A site brought in keeps the ground its source's pages sit on (AGL-4108), where its text reads on it.\n const own = style.page && /^#[0-9a-f]{6}$/i.test(style.page) && aiHexOklch(style.page).L >= 0.9 ? style.page.toLowerCase() : null\n const background = own ?? aiOklchHex(ground.L, ground.C * groundChroma, ground.h)\n const paper = aiOklchHex(ground.paper[0], ground.paper[1] * groundChroma, ground.h)\n\n // The brand color: a button label reads on it, so it reads on the page too.\n let primaryMain: string\n let primaryL: number\n if (brand && ratio(white, style.brand as string) >= 4.5) {\n primaryMain = style.brand as string\n primaryL = brand.L\n } else {\n primaryL = untilContrast(brand ? Math.min(brand.L, START_L[style.chroma]) : START_L[style.chroma] + (next() - 0.5) * 0.06, chroma, h, white, 4.6, 0)\n primaryMain = aiOklchHex(primaryL, chroma, h)\n }\n const accentChroma = neutral ? 0.17 : Math.max(0.07, chroma * 0.95)\n // A button's colors come from the brand hue where the accent clashes with\n // it (AGL-3660); the accent keeps its tint and the tertiary.\n const buttonHue = aiHueGap(style.accent, h) > AI_SITE_ACCENT_CLASH_DEGREES ? h : style.accent\n\n // The secondary color fills a button ON a brand band, so it stands apart from the brand color.\n const secondary = neutral\n ? (() => {\n // Ink or paper, whichever stands further from the brand color (AGL-3660).\n const ink = aiOklchHex(0.24, 0.012, h)\n const paper = aiOklchHex(0.97, 0.008, h)\n return { main: ratio(ink, primaryMain) >= ratio(paper, primaryMain) ? ink : paper, h }\n })()\n : (() => {\n // A light wash of the accent rather than the accent at full strength:\n // it reads on the brand color without fighting it.\n const washChroma = Math.min(accentChroma, 0.08)\n let L = 0.9\n let main = aiOklchHex(L, washChroma, buttonHue)\n while (ratio(main, primaryMain) < 3 && L < 0.96) {\n L += 0.02\n main = aiOklchHex(L, washChroma, buttonHue)\n }\n return { main, h: buttonHue }\n })()\n // A site brought in's own third color (AGL-4138), at the nearest shade of it that reads on white; else the accent's neighbor.\n const third = style.tertiary && /^#[0-9a-f]{6}$/i.test(style.tertiary) ? aiHexOklch(style.tertiary) : null\n const tertiaryHue = third ? Math.round(third.h) % 360 : (style.accent + 60) % 360\n const tertiaryChroma = third ? Math.min(0.2, Math.max(0.07, third.C)) : 0.12\n const tertiaryL = untilContrast(third ? Math.min(third.L, 0.6) : 0.52, tertiaryChroma, tertiaryHue, white, 4.6, 0)\n const tertiary = aiOklchHex(tertiaryL, tertiaryChroma, tertiaryHue)\n const textChroma = neutral ? 0.006 : 0.02\n\n const light: HostThemeSchemeColors = {\n primary: {\n main: primaryMain,\n light: aiOklchHex(Math.min(0.92, primaryL + 0.12), chroma, h),\n dark: aiOklchHex(Math.max(0.15, primaryL - 0.1), chroma, h),\n contrastText: labelOn(primaryMain, h),\n },\n secondary: {\n main: secondary.main,\n light: aiOklchHex(0.93, accentChroma * 0.6, secondary.h),\n dark: aiOklchHex(0.42, accentChroma, secondary.h),\n contrastText: labelOn(secondary.main, secondary.h),\n },\n tertiary: {\n main: tertiary,\n light: aiOklchHex(Math.min(0.9, tertiaryL + 0.14), tertiaryChroma, tertiaryHue),\n dark: aiOklchHex(Math.max(0.15, tertiaryL - 0.1), tertiaryChroma, tertiaryHue),\n contrastText: labelOn(tertiary, tertiaryHue),\n },\n surface: { main: aiOklchHex(0.955, 0.012 * groundChroma, h), contrastText: aiOklchHex(0.22, textChroma, h) },\n background: { default: background, paper },\n text: {\n primary: aiOklchHex(0.22, textChroma, h),\n secondary: aiOklchHex(0.45, textChroma + 0.005, h),\n disabled: aiOklchHex(0.68, 0.01, h),\n },\n // The primary's tint is the brand's own wash (AGL-3660): a base fills an\n // outlined or tinted button with it, under the primary's dark words.\n tint: {\n primary: aiOklchHex(0.955, neutral ? 0.03 : 0.035, h),\n secondary: aiOklchHex(0.955, 0.035, buttonHue),\n tertiary: aiOklchHex(0.955, 0.03, tertiaryHue),\n },\n divider: aiOklchHex(0.9, 0.012 * groundChroma, h),\n }\n\n const darkGround = style.ground === 'tinted' ? 0.024 : style.ground === 'warm' ? 0.014 : 0.012\n const darkBackground = aiOklchHex(0.17, darkGround * groundChroma, style.ground === 'warm' ? 60 : h)\n const darkPaper = aiOklchHex(0.215, darkGround * groundChroma, style.ground === 'warm' ? 60 : h)\n const darkChroma = Math.min(chroma, 0.14)\n const darkPrimaryL = untilContrast(0.78, darkChroma, h, darkBackground, 4.5, 1)\n const darkPrimary = aiOklchHex(darkPrimaryL, darkChroma, h)\n const darkSecondary = neutral ? aiOklchHex(0.93, 0.01, h) : aiOklchHex(0.45, accentChroma * 0.85, buttonHue)\n const darkTertiary = aiOklchHex(0.8, 0.1, tertiaryHue)\n const dark: HostThemeSchemeColors = {\n primary: {\n main: darkPrimary,\n light: aiOklchHex(Math.min(0.94, darkPrimaryL + 0.08), darkChroma, h),\n dark: aiOklchHex(darkPrimaryL - 0.1, darkChroma, h),\n contrastText: labelOn(darkPrimary, h),\n },\n secondary: {\n main: darkSecondary,\n light: aiOklchHex(0.6, accentChroma * 0.7, secondary.h),\n dark: aiOklchHex(0.35, accentChroma * 0.7, secondary.h),\n contrastText: labelOn(darkSecondary, secondary.h),\n },\n tertiary: {\n main: darkTertiary,\n light: aiOklchHex(0.88, 0.08, tertiaryHue),\n dark: aiOklchHex(0.7, 0.1, tertiaryHue),\n contrastText: labelOn(darkTertiary, tertiaryHue),\n },\n surface: { main: aiOklchHex(0.25, 0.014 * groundChroma, h), contrastText: aiOklchHex(0.95, 0.01, h) },\n background: { default: darkBackground, paper: darkPaper },\n text: {\n primary: aiOklchHex(0.95, 0.008, h),\n secondary: aiOklchHex(0.77, 0.014, h),\n disabled: aiOklchHex(0.52, 0.01, h),\n },\n tint: {\n primary: aiOklchHex(0.27, 0.05, h),\n secondary: aiOklchHex(0.27, 0.05, buttonHue),\n tertiary: aiOklchHex(0.27, 0.04, tertiaryHue),\n },\n divider: aiOklchHex(0.32, 0.015 * groundChroma, h),\n }\n return { light, dark }\n}\n\n// ── The theme ────────────────────────────────────────────────────────────\n\nconst RADIUS: Record<AiSiteCorners, number> = { sharp: 2, soft: 6, round: 12, pill: 18 }\nconst SPACING: Record<AiSiteDensity, number> = { compact: 7, regular: 8, airy: 9 }\n\n/** How much of the heading scale each style takes: a display line grows most, small headings not at all. */\nconst SCALE_SHARE: Partial<Record<HostThemeTypographyVariantKey, { size: number; share: number }>> = {\n displayXl: { size: 4, share: 1.2 },\n h1: { size: 3.25, share: 1 },\n h2: { size: 2.25, share: 0.8 },\n h3: { size: 1.75, share: 0.5 },\n h4: { size: 1.5, share: 0.3 },\n h5: { size: 1.25, share: 0 },\n h6: { size: 1.125, share: 0 },\n}\n\nconst rem = (value: number) => `${Math.round(value * 1000) / 1000}rem`\n\n/**\n * The kinds whose titles are their design (AGL-3660): a portfolio's or a\n * studio's statement, a photographer's name over a cover, a publication's\n * masthead are set larger than a business site's, the way the designer\n * templates set them. The display line grows most, the page title a little,\n * and nothing under it; a phone still steps every size down\n * (`responsiveFontSizes`).\n */\nexport const AI_SITE_DISPLAY_BOOST: Readonly<Record<string, { display: number; title: number }>> = {\n portfolio: { display: 1.25, title: 1.1 },\n studio: { display: 1.3, title: 1.1 },\n photography: { display: 1.2, title: 1.08 },\n blog: { display: 1.25, title: 1.1 },\n}\n\n/** The type a style sets: headings at its scale, weight and tracking, and the eyebrow and button styles. */\nfunction typographyFor(style: AiSiteStyle): HostTheme['typography'] {\n const pairing = aiSiteFontPairing(style.fonts) ?? (AI_SITE_FONT_PAIRINGS[0] as NonNullable<ReturnType<typeof aiSiteFontPairing>>)\n const variants: Partial<Record<HostThemeTypographyVariantKey, HostThemeTypographyVariant>> = {\n ...(DEFAULT_SITE_THEME.typography?.variants ?? {}),\n }\n const boost = AI_SITE_DISPLAY_BOOST[style.kind]\n for (const [key, { size, share }] of Object.entries(SCALE_SHARE) as Array<[HostThemeTypographyVariantKey, { size: number; share: number }]>) {\n const big = key === 'displayXl' || key === 'h1' || key === 'h2'\n const boosted = key === 'displayXl' ? (boost?.display ?? 1) : key === 'h1' ? (boost?.title ?? 1) : 1\n const variant: HostThemeTypographyVariant = {\n fontSize: rem(size * (1 + (style.headingScale - 1) * share) * (pairing.caps && big ? 0.92 : 1) * boosted),\n fontWeight: big ? pairing.heading.weight : pairing.heading.sub,\n // A display line set larger sets tighter.\n lineHeight: big ? (pairing.caps ? 1.05 : key === 'displayXl' && boost ? 1.02 : 1.1) : 1.25,\n }\n if (pairing.tracking !== undefined && (big || key === 'h3')) variant.letterSpacing = `${pairing.tracking}em`\n if (pairing.caps && (big || key === 'h3')) variant.textTransform = 'uppercase'\n variants[key] = variant\n }\n const bodyBold = pairing.body.weights.includes(600) ? 600 : 700\n variants.overline =\n style.eyebrow === 'small'\n ? { fontSize: '0.875rem', fontWeight: bodyBold, letterSpacing: '0.01em', textTransform: 'none' }\n : { fontSize: '0.78rem', fontWeight: 700, letterSpacing: style.eyebrow === 'rule' ? '0.16em' : '0.12em', textTransform: 'uppercase' }\n variants.button = {\n fontWeight: style.buttons === 'caps' ? 700 : bodyBold,\n textTransform: style.buttons === 'caps' ? 'uppercase' : 'none',\n ...(style.buttons === 'caps' ? { letterSpacing: '0.06em' } : {}),\n }\n return { variants }\n}\n\n/** The card's look, in theme terms only: palette paths, shadow indexes and border widths. */\nfunction cardSx(cards: AiSiteCards): Record<string, unknown> {\n switch (cards) {\n case 'flat':\n return { boxShadow: 0, border: 0, bgcolor: 'surface.main' }\n case 'outlined':\n return { boxShadow: 0, border: 1, borderColor: 'divider', bgcolor: 'background.paper' }\n case 'elevated':\n return { boxShadow: 3, border: 0, bgcolor: 'background.paper' }\n case 'tinted':\n return { boxShadow: 0, border: 0, bgcolor: 'tint.primary' }\n case 'rule':\n return { boxShadow: 0, border: 0, borderTop: 3, borderColor: 'primary.main', borderRadius: 0, bgcolor: 'background.paper' }\n }\n}\n\n/** The component defaults and styles a style sets: buttons, cards, fields, eyebrows, the header bar and the FAQ. */\nfunction componentsFor(style: AiSiteStyle): Record<string, HostThemeComponentOverride> {\n const radius = RADIUS[style.corners]\n const buttonRadius = style.buttons === 'pill' ? 999 : style.buttons === 'square' ? 2 : radius\n const card = cardSx(style.cards)\n return {\n MuiButton: {\n defaultProps: { disableElevation: true },\n // 44px: the touch target a visitor's thumb needs.\n styleOverrides: { root: { borderRadius: buttonRadius, minHeight: 44, boxShadow: 'none' } },\n ...(style.buttons === 'link'\n ? {\n variants: [\n {\n props: { variant: 'text' },\n style: { textDecoration: 'underline', textUnderlineOffset: '0.3em', textDecorationThickness: '2px' },\n },\n ],\n }\n : {}),\n },\n MuiCard: {\n defaultProps:\n style.cards === 'outlined'\n ? { variant: 'outlined' }\n : { variant: 'elevation', elevation: style.cards === 'elevated' ? 3 : 0 },\n styleOverrides: { root: { borderRadius: style.cards === 'rule' ? 0 : Math.max(radius, 4) } },\n sx: { root: card },\n },\n MuiAccordion: {\n defaultProps: { disableGutters: true, elevation: 0 },\n sx: {\n root: {\n ...card,\n borderTop: style.cards === 'rule' ? 1 : card['borderTop'] ?? card['border'],\n '&::before': { display: 'none' },\n '&:not(:last-of-type)': { mb: 1 },\n },\n },\n },\n MuiTextField: { defaultProps: { variant: style.fields } },\n MuiOutlinedInput: { styleOverrides: { root: { borderRadius: radius } } },\n MuiFilledInput: { styleOverrides: { root: { borderTopLeftRadius: radius, borderTopRightRadius: radius } } },\n MuiChip: { styleOverrides: { root: { borderRadius: style.corners === 'sharp' ? 2 : 999 } } },\n MuiAppBar: {\n defaultProps: { elevation: 0 },\n variants: [\n {\n props: { color: 'inherit' },\n sx:\n style.header === 'line'\n ? { boxShadow: 0, borderBottom: 1, borderColor: 'divider' }\n : style.header === 'shadow'\n ? { boxShadow: 2, borderBottom: 0 }\n : { boxShadow: 0, borderBottom: 0 },\n },\n ],\n },\n ...(style.eyebrow === 'rule'\n ? {\n MuiTypography: {\n variants: [\n {\n props: { variant: 'overline' },\n // A short line in the eyebrow's own color, so it reads on any band.\n style: {\n '&::before': {\n content: '\"\"',\n display: 'inline-block',\n width: '1.75em',\n height: '2px',\n marginRight: '0.75em',\n verticalAlign: 'middle',\n backgroundColor: 'currentColor',\n },\n },\n },\n ],\n },\n }\n : {}),\n }\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value)\n}\n\n/** `over` merged into `under`, objects key by key, anything else replaced. */\nfunction merged<T>(under: T, over: unknown): T {\n if (!isRecord(under) || !isRecord(over)) return (over === undefined ? under : over) as T\n const out: Record<string, unknown> = { ...under }\n for (const [key, value] of Object.entries(over)) out[key] = key in out ? merged(out[key], value) : value\n return out as T\n}\n\n/** Whether a theme passes the publish check and the brand-on-page contrast the doctrine asks. */\nfunction themeReads(theme: HostTheme): boolean {\n if (!validateThemeForPublish(theme).ok) return false\n for (const scheme of ['light', 'dark'] as const) {\n const colors = theme.colorSchemes?.[scheme]\n const main = colors?.primary?.main\n const page = colors?.background?.default\n if (!main || !page || ratio(main, page) < 3) return false\n for (const key of ['primary', 'secondary', 'tertiary'] as const) {\n const fill = colors?.[key]\n if (fill?.main && fill.contrastText && ratio(fill.contrastText, fill.main) < 4.5) return false\n }\n }\n return true\n}\n\n/**\n * The site's theme: the base theme with this style layered over it. Colors,\n * type, corners, spacing and the building blocks' component styles are the\n * site's own; whatever the base sets beyond them — its focus rings, its menu\n * and dialog styles, its control heights — stays the base's.\n */\nexport function aiSiteTheme(style: AiSiteStyle, base: HostTheme): HostTheme {\n const pairing = aiSiteFontPairing(style.fonts) ?? (AI_SITE_FONT_PAIRINGS[0] as NonNullable<ReturnType<typeof aiSiteFontPairing>>)\n const colors = aiSiteColors(style)\n const keep = (scheme: 'light' | 'dark') => {\n const own = base.colorSchemes?.[scheme] ?? {}\n // The status colors stay the base's: they mean the same thing on every site.\n return {\n ...(own.error ? { error: own.error } : {}),\n ...(own.warning ? { warning: own.warning } : {}),\n ...(own.info ? { info: own.info } : {}),\n ...(own.success ? { success: own.success } : {}),\n ...colors[scheme],\n }\n }\n let theme: HostTheme = {\n ...base,\n colorSchemes: { light: keep('light'), dark: keep('dark') },\n typography: merged(base.typography ?? {}, typographyFor(style)),\n shape: { ...(base.shape ?? {}), borderRadius: RADIUS[style.corners] },\n spacing: SPACING[style.density],\n components: merged(base.components ?? {}, componentsFor(style)),\n }\n delete theme.darkScheme\n // A site brought in is set in its source's own families (AGL-4108), at the\n // weights the pairing draws with, as near as each family has them.\n const headingWeights = [pairing.heading.weight, pairing.heading.sub]\n const source = style.sourceFonts ?? null\n const body = source?.body\n ? { family: source.body.family, category: source.body.category, weights: aiSiteFontWeightsIn(pairing.body.weights, source.body.weights) }\n : { family: pairing.body.family, category: pairing.body.category, weights: [...pairing.body.weights] }\n const heading = source\n ? source.heading\n ? { family: source.heading.family, category: source.heading.category, weights: aiSiteFontWeightsIn(headingWeights, source.heading.weights) }\n : { ...body, weights: aiSiteFontWeightsIn(headingWeights, source.body.weights) }\n : { family: pairing.heading.family, category: pairing.heading.category, weights: [...new Set(headingWeights)].sort((a, b) => a - b) }\n const sameFamily = heading.family.toLowerCase() === body.family.toLowerCase()\n theme = writeThemeFonts(theme, {\n body: { ...body, source: 'google' },\n heading: sameFamily ? null : { ...heading, source: 'google' },\n })\n // A heading in the body's family loads the heading weights too.\n if (sameFamily && theme.fonts?.[0]) {\n theme.fonts[0] = {\n ...theme.fonts[0],\n weights: [...new Set([...(theme.fonts[0].weights ?? []), ...heading.weights])].sort((a, b) => a - b),\n }\n }\n if (!themeReads(theme)) {\n // Never a theme that fails the reading checks: the starter's colors, with everything else kept.\n theme = { ...theme, colorSchemes: DEFAULT_SITE_THEME.colorSchemes }\n }\n return theme\n}\n\n// ── A kind's first look (AGL-4049) ──────────────────────────────────────────\n\n/** The midpoint of a kind's first hue range, or `null` when it spans the whole wheel (any hue suits it). */\nfunction firstHueOf(hues: AiSiteKind['look']['hues']): number | null {\n const [from, to] = hues?.[0] ?? [0, 360]\n const span = from <= to ? to - from : 360 - from + to\n if (span >= 360) return null\n return Math.round(from + span / 2) % 360\n}\n\n/** A kind's first look as a built-in theme with a brand over it, and the style answers that say the same. */\nexport interface AiSiteKindDefaultLook {\n /** The `builtin` starter theme a site created in this style starts with. */\n theme: {\n kind: 'builtin'\n base: string\n brand: { light: Record<string, string>; dark?: Record<string, string> }\n fonts: string | null\n }\n /** The same look as the AI start's style answers name it (`fp-starter-{kind}-ai`). */\n answerStyle: {\n base: string\n hue?: number\n ground: AiSiteGround\n fonts: string | null\n corners: AiSiteCorners\n buttons: AiSiteButtons\n }\n}\n\n/**\n * A kind of site's FIRST look (AGL-4049), the one a site created in that\n * style starts with and the one the platform's own starter listings carry:\n * the kind's first base theme the deployment has (`starter`, or a built-in\n * whose preset `known.presetIds` holds), its first font pairing the platform\n * has, and a brand primary from the midpoint of its first hue range, colored\n * as {@link aiSiteColors} colors one. A kind that suits any hue keeps the\n * base's own colors. One derivation, so the style a person picks in Create\n * site and the seeded `fp-starter-{kind}-base` listing look the same.\n *\n * Deterministic: no draw, the seed is the kind's id.\n */\nexport function aiSiteKindDefaultLook(\n kind: AiSiteKind,\n known: { presetIds: ReadonlySet<string>; pairingIds?: ReadonlySet<string> },\n): AiSiteKindDefaultLook {\n const family = kind.look\n const pairingIds = known.pairingIds ?? new Set(AI_SITE_FONT_PAIRINGS.map((pairing) => pairing.id))\n const base =\n family.bases.find((name) => name === 'starter' || known.presetIds.has(`theme-presets.${name}`)) ?? 'starter'\n const fonts = family.fonts.find((id) => pairingIds.has(id)) ?? null\n const hue = firstHueOf(family.hues)\n const ground = family.grounds[0] as AiSiteGround\n const corners = family.corners[0] as AiSiteCorners\n const colors =\n hue === null\n ? null\n : aiSiteColors({\n v: 1,\n kind: kind.id,\n base,\n seed: aiSiteSeed(kind.id),\n hue,\n accent: hue,\n chroma: family.chroma,\n ground,\n fonts: fonts ?? '',\n corners,\n buttons: family.buttons,\n // Not read by the colors; named so the style is whole.\n cards: 'flat',\n fields: 'outlined',\n eyebrow: 'caps',\n header: 'line',\n headerAlign: 'start',\n rhythm: 'calm',\n headingScale: family.headingScale,\n density: family.density,\n brand: null,\n })\n const primary = (scheme: 'light' | 'dark') => {\n const value = colors?.[scheme]?.primary\n return value && typeof value === 'object' && typeof (value as { main?: unknown }).main === 'string'\n ? (value as { main: string }).main\n : null\n }\n const light = primary('light')\n const dark = primary('dark')\n const brand = light && dark ? { light: { primary: light }, dark: { primary: dark } } : { light: {} }\n return {\n theme: { kind: 'builtin', base, brand, fonts },\n answerStyle: {\n base,\n ...(hue === null ? {} : { hue }),\n ground,\n fonts,\n corners,\n buttons: family.buttons,\n },\n }\n}\n"],"names":["contrastRatio","validateThemeForPublish","DEFAULT_SITE_THEME","writeThemeFonts","AI_SITE_MOTION_STYLES","aiSiteMotionStyle","aiSiteMotionStylesFor","AI_SITE_BASES","AI_SITE_CORNERS","AI_SITE_FONT_PAIRINGS","AI_SITE_GROUNDS","AI_SITE_RHYTHMS","aiSiteFontPairing","AI_SITE_CARDS","AI_SITE_FIELDS","AI_SITE_EYEBROWS","AI_SITE_HEADERS","AI_SITE_BUTTONS","DENSITIES","aiSiteFontWeightsIn","wanted","offered","length","Set","sort","a","b","nearest","weight","reduce","best","each","Math","abs","map","aiSiteSeed","jobId","hash","index","charCodeAt","imul","random","seed","state","t","pick","next","list","floor","AI_SITE_LOOK_TOOL_NAME","enumOf","values","description","type","enum","AI_SITE_LOOK_TOOL","name","strict","inputSchema","additionalProperties","required","properties","base","hue","accent","ground","fonts","pairing","id","corners","buttons","cards","fields","eyebrow","header","brand","anyOf","motion","oneOf","value","includes","undefined","hueOf","Number","isFinite","round","aiSiteBrandHex","match","exec","trim","hex","full","digit","join","toLowerCase","aiReadSiteLook","answer","raw","look","BLOCK_BIAS","portfolio","studio","photography","blog","trades","fitness","professional","wellness","yoga","restaurant","beauty","music","ANY_BLOCKS","aiSiteHueFamily","rangeOf","kind","hues","findIndex","from","to","AI_SITE_LOOK_DIMENSIONS","aiSiteLookSignature","style","hueFamily","String","headerAlign","rhythm","aiSiteStyleFor","input","avoid","styleOnce","signatures","attempt","AI_SITE_LOOK_DRAWS","own","least","min","other","TUPLE","every","dimension","filter","AI_SITE_LOOK_LEAST_DIFFERENCES","withPins","drawOnce","pins","Object","keys","rest","pinned","fromEntries","entries","family","blocks","choose","model","options","keep","modelRange","keepHue","range","span","accentFrom","bases","v","chroma","grounds","headerAligns","rhythms","headingScale","density","AI_SITE_MOTION_KEEP","oklabToLinear","L","l","m","s","toSrgb","channel","fromSrgb","aiOklchHex","C","h","lightness","max","radians","PI","linear","cos","sin","fits","toString","padStart","aiHexOklch","replace","r","g","at","parseInt","slice","cbrt","A","B","hypot","atan2","ratio","untilContrast","against","toward","step","labelOn","fill","white","ink","aiHueGap","d","AI_SITE_ACCENT_CLASH_DEGREES","CHROMA","neutral","muted","balanced","vivid","START_L","aiSiteColors","groundChroma","paper","warm","cool","tinted","page","test","background","primaryMain","primaryL","accentChroma","buttonHue","secondary","main","washChroma","third","tertiary","tertiaryHue","tertiaryChroma","tertiaryL","textChroma","light","primary","dark","contrastText","surface","default","text","disabled","tint","divider","darkGround","darkBackground","darkPaper","darkChroma","darkPrimaryL","darkPrimary","darkSecondary","darkTertiary","RADIUS","sharp","soft","pill","SPACING","compact","regular","airy","SCALE_SHARE","displayXl","size","share","h1","h2","h3","h4","h5","h6","rem","AI_SITE_DISPLAY_BOOST","display","title","typographyFor","variants","typography","boost","key","big","boosted","variant","fontSize","caps","fontWeight","heading","sub","lineHeight","tracking","letterSpacing","textTransform","bodyBold","body","weights","overline","button","cardSx","boxShadow","border","bgcolor","borderColor","borderTop","borderRadius","componentsFor","card","radius","buttonRadius","MuiButton","defaultProps","disableElevation","styleOverrides","root","minHeight","props","textDecoration","textUnderlineOffset","textDecorationThickness","MuiCard","elevation","sx","MuiAccordion","disableGutters","mb","MuiTextField","MuiOutlinedInput","MuiFilledInput","borderTopLeftRadius","borderTopRightRadius","MuiChip","MuiAppBar","color","borderBottom","MuiTypography","content","width","height","marginRight","verticalAlign","backgroundColor","isRecord","Array","isArray","merged","under","over","out","themeReads","theme","ok","scheme","colors","colorSchemes","aiSiteTheme","error","warning","info","success","shape","spacing","components","darkScheme","headingWeights","source","sourceFonts","category","sameFamily","firstHueOf","aiSiteKindDefaultLook","known","pairingIds","find","presetIds","has","answerStyle"],"mappings":";;AAAA;;;;;;;;;;;;;;;CAeC,GAED,SACEA,aAAa,EACbC,uBAAuB,QAClB,oCAAmC;AAC1C,SAASC,kBAAkB,QAAQ,sCAAqC;AASxE,SAASC,eAAe,QAAQ,kDAAiD;AACjF,SACEC,qBAAqB,EACrBC,iBAAiB,EACjBC,qBAAqB,QAEhB,yCAAqC;AAE5C,SACEC,aAAa,EACbC,eAAe,EACfC,qBAAqB,EACrBC,eAAe,EACfC,eAAe,EACfC,iBAAiB,QASZ,qBAAiB;AAExB;;;;;;;;;;;;;;;;;;;;;;;;;CAyBC,GAED,4EAA4E;AAE5E,yBAAyB,GACzB,OAAO,MAAMC,gBAAgB;IAAC;IAAQ;IAAY;IAAY;IAAU;CAAO,CAAS;AAExF,0BAA0B,GAC1B,OAAO,MAAMC,iBAAiB;IAAC;IAAY;IAAU;CAAW,CAAS;AAEzE,2CAA2C,GAC3C,OAAO,MAAMC,mBAAmB;IAAC;IAAQ;IAAS;CAAO,CAAS;AAElE,+CAA+C,GAC/C,OAAO,MAAMC,kBAAkB;IAAC;IAAQ;IAAU;CAAO,CAAS;AAElE,8EAA8E,GAC9E,OAAO,MAAMC,kBAA4C;IAAC;IAAW;IAAQ;IAAU;IAAQ;CAAO,CAAA;AACtG,MAAMC,YAAsC;IAAC;IAAW;IAAW;CAAO;AAmE1E,yFAAyF,GACzF,OAAO,SAASC,oBAAoBC,MAAyB,EAAEC,OAA0B;IACvF,IAAI,CAACA,QAAQC,MAAM,EAAE,OAAO;WAAI,IAAIC,IAAIH;KAAQ,CAACI,IAAI,CAAC,CAACC,GAAGC,IAAMD,IAAIC;IACpE,MAAMC,UAAU,CAACC,SAAmBP,QAAQQ,MAAM,CAAC,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YAAOT;QAAM;QAC7C8T,aAAa;YACXlU;WACIC,QAAQ,OAAO,CAAC,IAAI;YAAEA;QAAI;YAC9BE;YACAC;YACAG;YACAC,SAASkF,OAAOlF,OAAO;;IAE3B;AACF"}
|
|
@@ -79,10 +79,11 @@
|
|
|
79
79
|
* `feature` is what the entry is called: "Create with AI" unless it is an ask.
|
|
80
80
|
*/ export function aiUpsellOffer(canManageBilling, feature = AI_UPSELL_CREATE_LABEL) {
|
|
81
81
|
// Since AGL-3965 every paid plan's own credits pay for generation, so this
|
|
82
|
-
// door is reached only where it is switched off for the workspace and
|
|
83
|
-
// Aglyn AI
|
|
82
|
+
// door is reached only where it is switched off for the workspace and
|
|
83
|
+
// Aglyn AI credit blocks (which switch it on with their credits, AGL-4144)
|
|
84
|
+
// are for sale.
|
|
84
85
|
const addon = aiAddonName();
|
|
85
|
-
return canManageBilling ? `${feature} is switched off for this workspace. It comes with
|
|
86
|
+
return canManageBilling ? `${feature} is switched off for this workspace. It comes with ${addon} ` + 'credits, which you can add in Billing.' : `${feature} is switched off for this workspace. It comes with ${addon} ` + 'credits. Ask a workspace owner or admin to add them in Billing.';
|
|
86
87
|
}
|
|
87
88
|
|
|
88
89
|
//# sourceMappingURL=ai-upsell-copy.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/model/ai-upsell-copy.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { aiAddonName } from '@aglyn/aglyn/app-utils/plan-entitlements'\nimport type { AiBriefKind } from './ai-brief-copy'\n\n/**\n * What a \"Create with AI\" or \"Ask AI\" entry makes: the brief kinds, an\n * automation, products, a function or variable, an overlay, and an answer\n * about the figures on a page.\n */\nexport type AiUpsellKind =\n | AiBriefKind\n | 'workflow'\n | 'product'\n | 'logic'\n | 'overlay'\n | 'funnel'\n | 'insight'\n\n/** What one entry's dialog says. */\nexport interface AiUpsellCopy {\n title: string\n does: string\n /** The entry's own label, which the button reads and the offer names; \"Create with AI\" when absent. */\n label?: string\n}\n\n/** The label every \"Create with AI\" entry reads. */\nexport const AI_UPSELL_CREATE_LABEL = 'Create with AI'\n\n/** What the dialog says one entry would do here. */\nexport const AI_UPSELL_COPY: Readonly<Record<AiUpsellKind, AiUpsellCopy>> = {\n page: {\n title: 'Create a page with AI',\n does:\n 'Describe the page you need and AI plans it from your brief, using your theme and ' +\n 'what the site already has. You confirm the plan, and the page is built as an ' +\n 'unpublished draft.',\n },\n template: {\n title: 'Create a page template with AI',\n does:\n 'Describe what each page should show and AI plans the template, filling what ' +\n 'changes from page to page from each record. You confirm the plan, and the template ' +\n 'is built as a draft in your library.',\n },\n layout: {\n title: 'Create a layout with AI',\n does:\n 'Describe what the layout should hold and AI plans it, linking your pages and placing ' +\n 'your navigation or menu component when the site has one. You confirm the plan, and ' +\n 'the layout is built as a draft no page uses until you assign it.',\n },\n form: {\n title: 'Create a form with AI',\n does:\n 'Describe what the form is for and AI plans its fields, its marketing consent and ' +\n 'where each submission goes. You confirm the plan, and the form is built as a draft.',\n },\n component: {\n title: 'Create a reusable component with AI',\n does:\n 'Describe what the component should show and AI plans it, making what each page can ' +\n 'change into its properties. You confirm the plan, and the component is built as a ' +\n 'draft.',\n },\n workflow: {\n title: 'Create an automation with AI',\n does:\n 'Describe what should happen, and when, and AI drafts the automation from the ' +\n 'triggers and steps your plan includes. It is saved switched off for you to review.',\n },\n email: {\n title: 'Create an email with AI',\n does:\n 'Describe the email you need and AI plans a design from the email blocks, with three ' +\n 'subject lines and three preheaders to choose between. You confirm the plan, and the ' +\n 'design is built as a draft that is sent to nobody.',\n },\n campaign: {\n title: 'Create a campaign with AI',\n does:\n 'Describe what the campaign is for and AI writes its email design and a draft campaign ' +\n 'that would send it. Nothing is sent or scheduled, and the campaign is aimed at nobody ' +\n 'until you pick its lists.',\n },\n product: {\n title: 'Create products with AI',\n does:\n 'Describe what the store sells and AI proposes up to twelve products. You review them ' +\n 'before any is created, and each is created as a draft at a suggested price that is not on ' +\n 'your storefront until you review it and activate it.',\n },\n logic: {\n title: 'Create a function or variable with AI',\n does:\n 'Describe what it should work out or hold and AI drafts the function or variable. It ' +\n 'opens unsaved in the editor for you to check and save.',\n },\n overlay: {\n title: 'Create an overlay with AI',\n does:\n 'Describe the announcement bar or popup you want and AI writes its copy within the ' +\n 'overlay’s limits. It is saved switched off, for you to check and turn on.',\n },\n funnel: {\n title: 'Create a funnel with AI',\n does:\n 'Describe the journey you want to measure and AI proposes its steps from the site’s ' +\n 'real pages, forms and products. It opens in the funnel editor for you to check and save.',\n },\n insight: {\n title: 'Ask AI about these numbers',\n label: 'Ask a question',\n does:\n 'Ask a question about the figures on this page and AI answers from them, every answer ' +\n 'traced to the figures it is built from. It reads; it changes nothing.',\n },\n}\n\n/** The label an entry's button reads. */\nexport function aiUpsellLabel(kind: AiUpsellKind): string {\n return AI_UPSELL_COPY[kind].label ?? AI_UPSELL_CREATE_LABEL\n}\n\n/**\n * The sentence that says where the feature comes from, and who can add it.\n * `feature` is what the entry is called: \"Create with AI\" unless it is an ask.\n */\nexport function aiUpsellOffer(canManageBilling: boolean, feature = AI_UPSELL_CREATE_LABEL): string {\n // Since AGL-3965 every paid plan's own credits pay for generation, so this\n // door is reached only where it is switched off for the workspace and
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/model/ai-upsell-copy.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { aiAddonName } from '@aglyn/aglyn/app-utils/plan-entitlements'\nimport type { AiBriefKind } from './ai-brief-copy'\n\n/**\n * What a \"Create with AI\" or \"Ask AI\" entry makes: the brief kinds, an\n * automation, products, a function or variable, an overlay, and an answer\n * about the figures on a page.\n */\nexport type AiUpsellKind =\n | AiBriefKind\n | 'workflow'\n | 'product'\n | 'logic'\n | 'overlay'\n | 'funnel'\n | 'insight'\n\n/** What one entry's dialog says. */\nexport interface AiUpsellCopy {\n title: string\n does: string\n /** The entry's own label, which the button reads and the offer names; \"Create with AI\" when absent. */\n label?: string\n}\n\n/** The label every \"Create with AI\" entry reads. */\nexport const AI_UPSELL_CREATE_LABEL = 'Create with AI'\n\n/** What the dialog says one entry would do here. */\nexport const AI_UPSELL_COPY: Readonly<Record<AiUpsellKind, AiUpsellCopy>> = {\n page: {\n title: 'Create a page with AI',\n does:\n 'Describe the page you need and AI plans it from your brief, using your theme and ' +\n 'what the site already has. You confirm the plan, and the page is built as an ' +\n 'unpublished draft.',\n },\n template: {\n title: 'Create a page template with AI',\n does:\n 'Describe what each page should show and AI plans the template, filling what ' +\n 'changes from page to page from each record. You confirm the plan, and the template ' +\n 'is built as a draft in your library.',\n },\n layout: {\n title: 'Create a layout with AI',\n does:\n 'Describe what the layout should hold and AI plans it, linking your pages and placing ' +\n 'your navigation or menu component when the site has one. You confirm the plan, and ' +\n 'the layout is built as a draft no page uses until you assign it.',\n },\n form: {\n title: 'Create a form with AI',\n does:\n 'Describe what the form is for and AI plans its fields, its marketing consent and ' +\n 'where each submission goes. You confirm the plan, and the form is built as a draft.',\n },\n component: {\n title: 'Create a reusable component with AI',\n does:\n 'Describe what the component should show and AI plans it, making what each page can ' +\n 'change into its properties. You confirm the plan, and the component is built as a ' +\n 'draft.',\n },\n workflow: {\n title: 'Create an automation with AI',\n does:\n 'Describe what should happen, and when, and AI drafts the automation from the ' +\n 'triggers and steps your plan includes. It is saved switched off for you to review.',\n },\n email: {\n title: 'Create an email with AI',\n does:\n 'Describe the email you need and AI plans a design from the email blocks, with three ' +\n 'subject lines and three preheaders to choose between. You confirm the plan, and the ' +\n 'design is built as a draft that is sent to nobody.',\n },\n campaign: {\n title: 'Create a campaign with AI',\n does:\n 'Describe what the campaign is for and AI writes its email design and a draft campaign ' +\n 'that would send it. Nothing is sent or scheduled, and the campaign is aimed at nobody ' +\n 'until you pick its lists.',\n },\n product: {\n title: 'Create products with AI',\n does:\n 'Describe what the store sells and AI proposes up to twelve products. You review them ' +\n 'before any is created, and each is created as a draft at a suggested price that is not on ' +\n 'your storefront until you review it and activate it.',\n },\n logic: {\n title: 'Create a function or variable with AI',\n does:\n 'Describe what it should work out or hold and AI drafts the function or variable. It ' +\n 'opens unsaved in the editor for you to check and save.',\n },\n overlay: {\n title: 'Create an overlay with AI',\n does:\n 'Describe the announcement bar or popup you want and AI writes its copy within the ' +\n 'overlay’s limits. It is saved switched off, for you to check and turn on.',\n },\n funnel: {\n title: 'Create a funnel with AI',\n does:\n 'Describe the journey you want to measure and AI proposes its steps from the site’s ' +\n 'real pages, forms and products. It opens in the funnel editor for you to check and save.',\n },\n insight: {\n title: 'Ask AI about these numbers',\n label: 'Ask a question',\n does:\n 'Ask a question about the figures on this page and AI answers from them, every answer ' +\n 'traced to the figures it is built from. It reads; it changes nothing.',\n },\n}\n\n/** The label an entry's button reads. */\nexport function aiUpsellLabel(kind: AiUpsellKind): string {\n return AI_UPSELL_COPY[kind].label ?? AI_UPSELL_CREATE_LABEL\n}\n\n/**\n * The sentence that says where the feature comes from, and who can add it.\n * `feature` is what the entry is called: \"Create with AI\" unless it is an ask.\n */\nexport function aiUpsellOffer(canManageBilling: boolean, feature = AI_UPSELL_CREATE_LABEL): string {\n // Since AGL-3965 every paid plan's own credits pay for generation, so this\n // door is reached only where it is switched off for the workspace and\n // Aglyn AI credit blocks (which switch it on with their credits, AGL-4144)\n // are for sale.\n const addon = aiAddonName()\n return canManageBilling\n ? `${feature} is switched off for this workspace. It comes with ${addon} ` +\n 'credits, which you can add in Billing.'\n : `${feature} is switched off for this workspace. It comes with ${addon} ` +\n 'credits. Ask a workspace owner or admin to add them in Billing.'\n}\n"],"names":["aiAddonName","AI_UPSELL_CREATE_LABEL","AI_UPSELL_COPY","page","title","does","template","layout","form","component","workflow","email","campaign","product","logic","overlay","funnel","insight","label","aiUpsellLabel","kind","aiUpsellOffer","canManageBilling","feature","addon"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED,SAASA,WAAW,QAAQ,2CAA0C;AAyBtE,kDAAkD,GAClD,OAAO,MAAMC,yBAAyB,iBAAgB;AAEtD,kDAAkD,GAClD,OAAO,MAAMC,iBAA+D;IAC1EC,MAAM;QACJC,OAAO;QACPC,MACE,sFACA,kFACA;IACJ;IACAC,UAAU;QACRF,OAAO;QACPC,MACE,iFACA,wFACA;IACJ;IACAE,QAAQ;QACNH,OAAO;QACPC,MACE,0FACA,wFACA;IACJ;IACAG,MAAM;QACJJ,OAAO;QACPC,MACE,sFACA;IACJ;IACAI,WAAW;QACTL,OAAO;QACPC,MACE,wFACA,uFACA;IACJ;IACAK,UAAU;QACRN,OAAO;QACPC,MACE,kFACA;IACJ;IACAM,OAAO;QACLP,OAAO;QACPC,MACE,yFACA,yFACA;IACJ;IACAO,UAAU;QACRR,OAAO;QACPC,MACE,2FACA,2FACA;IACJ;IACAQ,SAAS;QACPT,OAAO;QACPC,MACE,0FACA,+FACA;IACJ;IACAS,OAAO;QACLV,OAAO;QACPC,MACE,yFACA;IACJ;IACAU,SAAS;QACPX,OAAO;QACPC,MACE,uFACA;IACJ;IACAW,QAAQ;QACNZ,OAAO;QACPC,MACE,wFACA;IACJ;IACAY,SAAS;QACPb,OAAO;QACPc,OAAO;QACPb,MACE,0FACA;IACJ;AACF,EAAC;AAED,uCAAuC,GACvC,OAAO,SAASc,cAAcC,IAAkB;QACvClB;IAAP,QAAOA,6BAAAA,cAAc,CAACkB,KAAK,CAACF,KAAK,YAA1BhB,6BAA8BD;AACvC;AAEA;;;CAGC,GACD,OAAO,SAASoB,cAAcC,gBAAyB,EAAEC,UAAUtB,sBAAsB;IACvF,2EAA2E;IAC3E,sEAAsE;IACtE,2EAA2E;IAC3E,gBAAgB;IAChB,MAAMuB,QAAQxB;IACd,OAAOsB,mBACH,GAAGC,QAAQ,mDAAmD,EAAEC,MAAM,CAAC,CAAC,GACtE,2CACF,GAAGD,QAAQ,mDAAmD,EAAEC,MAAM,CAAC,CAAC,GACtE;AACR"}
|
|
@@ -62,9 +62,9 @@ declare module '@aglyn/aglyn/plugin-manager/plugin-entitlement-keys' {
|
|
|
62
62
|
* the resulting figures.
|
|
63
63
|
*
|
|
64
64
|
* ONE POOL FOR EVERYTHING (AGL-3965): this band pays for every Aglyn AI
|
|
65
|
-
* action, generation included, on every plan.
|
|
66
|
-
* credits (`
|
|
67
|
-
* — one pool, widened, rather than a second meter.
|
|
65
|
+
* action, generation included, on every plan. Aglyn AI credit blocks add
|
|
66
|
+
* 5,000 credits each (AGL-4144, `ai-credit-blocks.ts`) to it in
|
|
67
|
+
* `resolveOrgEntitlements` — one pool, widened, rather than a second meter.
|
|
68
68
|
*/
|
|
69
69
|
assistCreditsPerMonth?: number;
|
|
70
70
|
}
|
|
@@ -126,7 +126,7 @@
|
|
|
126
126
|
//
|
|
127
127
|
// Since AGL-3965 it opens `aiGenerative` too, as every paid rung does: the
|
|
128
128
|
// included band pays for generation and assist alike (one pool), and an
|
|
129
|
-
// Aglyn AI
|
|
129
|
+
// Aglyn AI credit block adds credits on top rather than opening a door.
|
|
130
130
|
//
|
|
131
131
|
// No cost moves: `tier-margin-floor.spec.ts` already prices this tier's
|
|
132
132
|
// assist term at 100% burn of the 750 credits, 75¢/mo. A door does not
|