@aglyn/shared-ui-theme 1.0.0-beta.230 → 1.0.0-beta.232

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/package.json +4 -4
  2. package/src/lib/console-app.theme.d.ts +25 -0
  3. package/src/lib/console-app.theme.js +142 -0
  4. package/src/lib/console-app.theme.js.map +1 -0
  5. package/src/lib/console.theme.js +8 -2
  6. package/src/lib/console.theme.js.map +1 -1
  7. package/src/lib/constants.d.ts +2 -0
  8. package/src/lib/constants.js +1 -0
  9. package/src/lib/constants.js.map +1 -1
  10. package/src/lib/platform-brand.d.ts +25 -0
  11. package/src/lib/platform-brand.js +40 -0
  12. package/src/lib/platform-brand.js.map +1 -0
  13. package/src/lib/site-base-fonts.d.ts +54 -0
  14. package/src/lib/site-base-fonts.js +125 -0
  15. package/src/lib/site-base-fonts.js.map +1 -0
  16. package/src/lib/tenant.theme.d.ts +1 -2
  17. package/src/lib/tenant.theme.js +8 -30
  18. package/src/lib/tenant.theme.js.map +1 -1
  19. package/src/lib/util/font-stack.d.ts +44 -0
  20. package/src/lib/util/font-stack.js +79 -0
  21. package/src/lib/util/font-stack.js.map +1 -0
  22. package/src/lib/util/roboto-flex.d.ts +65 -0
  23. package/src/lib/util/roboto-flex.js +115 -0
  24. package/src/lib/util/roboto-flex.js.map +1 -0
  25. package/src/lib/util/self-hosted-fonts.d.ts +111 -1
  26. package/src/lib/util/self-hosted-fonts.js +349 -2
  27. package/src/lib/util/self-hosted-fonts.js.map +1 -1
  28. package/src/lib/util/theme-editor-edits.d.ts +105 -0
  29. package/src/lib/util/theme-editor-edits.js +168 -0
  30. package/src/lib/util/theme-editor-edits.js.map +1 -0
  31. package/src/lib/util/theme-editor-fields.d.ts +53 -2
  32. package/src/lib/util/theme-editor-fields.js +171 -20
  33. package/src/lib/util/theme-editor-fields.js.map +1 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../../libs/shared/ui/theme/src/lib/util/theme-editor-fields.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 type {\n HostTheme,\n HostThemeComponentOverride,\n HostThemeScheme,\n HostThemeSchemeColors,\n} from '@aglyn/shared-data-types'\nimport {\n HOST_THEME_COMPONENT_WHITELIST,\n type HostThemeComponentKey,\n} from './host-theme'\n\n/**\n * The host theme editor's field catalog (AGL-2938): every control the editor\n * renders, the range each one accepts, the token it writes, and the write\n * itself.\n *\n * It lives here rather than beside the editor because the editor is not the\n * only thing that changes a site's theme. Anything that proposes a theme\n * change has to offer exactly the controls the editor offers, with the same\n * bounds, and has to write each one the way the editor writes it. A copy of\n * this list anywhere else is a second answer to \"what can a theme hold\" that\n * drifts from the first the day a control is added, so the editor renders\n * from this module and every other writer reads it.\n *\n * Pure data and pure functions over `HostTheme`: no MUI, no React and no\n * brand theme. What a control resolves to when the site sets nothing is the\n * brand theme's business, in `theme-editor-defaults.ts`.\n *\n * Deliberately NOT re-exported from this library's index: the index reaches\n * every published page, and nothing a visitor renders needs the catalog.\n * Reach it as `@aglyn/shared-ui-theme/util/theme-editor-fields`.\n */\n\n/**\n * MUI's own toolbar breakpoint. `mixins.toolbar` has to carry this exact\n * query, because the rule it competes with is MUI's `@media (min-width:600px)\n * { min-height: 64px }` (AGL-1242).\n */\nexport const TOOLBAR_SM_MIN_WIDTH = 600\nexport const TOOLBAR_SM_QUERY = `@media (min-width:${TOOLBAR_SM_MIN_WIDTH}px)`\n/** MUI's stock Toolbar heights, shown when the host has set none. */\nexport const DEFAULT_TOOLBAR_XS = 56\nexport const DEFAULT_TOOLBAR_SM = 64\n/**\n * `createMixins` spreads `...mixins` AFTER its default, so anything we write\n * REPLACES the stock toolbar wholesale — including its short-landscape rule.\n * Carrying it forward keeps that behavior instead of dropping it silently.\n */\nexport const TOOLBAR_LANDSCAPE_QUERY = '@media (min-width:0px)'\nexport const TOOLBAR_LANDSCAPE_RULE = {\n '@media (orientation: landscape)': { minHeight: 48 },\n}\n\n/** Reads a px `minHeight` out of `mixins.toolbar` for one breakpoint. */\nexport function readToolbarHeight(theme: HostTheme, breakpoint: 'xs' | 'sm') {\n const toolbar = theme.mixins?.toolbar\n if (!toolbar) return undefined\n const raw =\n breakpoint === 'xs'\n ? toolbar.minHeight\n : (toolbar[TOOLBAR_SM_QUERY] as { minHeight?: unknown } | undefined)\n ?.minHeight\n const value = parseFloat(String(raw ?? ''))\n return Number.isFinite(value) ? value : undefined\n}\n\n/**\n * Builds a COMPLETE `mixins.toolbar`, in the order MUI emits it.\n *\n * Two things this exists to get right, both because `mixins.toolbar` replaces\n * MUI's default wholesale rather than merging into it (AGL-1242):\n *\n * - **Completeness.** Anything omitted is simply gone. Writing only a desktop\n * height left portrait phones with no `min-height` at all, so unset\n * breakpoints fall back to MUI's own 56 / 64.\n * - **Key order.** These land in one CSS rule, so the last matching\n * declaration wins. MUI emits the landscape clause BEFORE the sm height;\n * emitting it after makes a wide landscape window — i.e. every desktop —\n * 48px tall.\n */\nexport function buildToolbarMixin(xs: number | undefined, sm: number | undefined) {\n return {\n minHeight: `${xs ?? DEFAULT_TOOLBAR_XS}px`,\n [TOOLBAR_LANDSCAPE_QUERY]: TOOLBAR_LANDSCAPE_RULE,\n [TOOLBAR_SM_QUERY]: { minHeight: `${sm ?? DEFAULT_TOOLBAR_SM}px` },\n }\n}\n\n/**\n * Serializes the branches whose KEY ORDER changes what renders.\n *\n * `deepEqual` is order-INsensitive on purpose (AGL-56: Firestore hands the\n * palette back in a different key order than the editor builds it, and a\n * string compare left Save enabled forever), so on its own it cannot see a\n * reorder of `mixins.toolbar` — a change that really does alter the CSS.\n *\n * Deliberately narrow: only `mixins`. `components.*.styleOverrides` are CSS\n * objects too, but widening this would re-expose the AGL-56 failure for every\n * host with component overrides, and order-sensitivity has only actually been\n * demonstrated here.\n *\n * Firestore does NOT hand a map back in the order it was written, and it\n * hands different readers different orders (AGL-3146) — which is why what\n * renders is canonicalized in `hostThemeToThemeOptions` rather than trusted\n * from storage. A freshly-loaded document is still not dirty here, because\n * the draft is seeded from the loaded document itself: both sides of this\n * comparison carry whatever order THIS reader was given.\n */\nexport function orderSensitiveKey(theme: HostTheme): string {\n return JSON.stringify(theme.mixins ?? {})\n}\n\nexport type PaletteColorKey =\n | 'primary'\n | 'secondary'\n | 'tertiary'\n | 'surface'\n | 'error'\n | 'warning'\n | 'info'\n | 'success'\n\nexport const PALETTE_COLOR_FIELDS: Array<{\n key: PaletteColorKey\n label: string\n}> = [\n { key: 'primary', label: 'Primary' },\n { key: 'secondary', label: 'Secondary' },\n { key: 'tertiary', label: 'Tertiary' },\n { key: 'surface', label: 'Surface' },\n { key: 'error', label: 'Error' },\n { key: 'warning', label: 'Warning' },\n { key: 'info', label: 'Info' },\n { key: 'success', label: 'Success' },\n]\n\nexport type SurfaceColorPath =\n | ['background', 'default']\n | ['background', 'paper']\n | ['text', 'primary']\n | ['text', 'secondary']\n | ['text', 'disabled']\n | ['tint', 'primary']\n | ['tint', 'secondary']\n | ['tint', 'tertiary']\n\nexport const SURFACE_COLOR_FIELDS: Array<{\n path: SurfaceColorPath\n label: string\n}> = [\n { path: ['background', 'default'], label: 'Background' },\n { path: ['background', 'paper'], label: 'Paper' },\n { path: ['text', 'primary'], label: 'Text' },\n { path: ['text', 'secondary'], label: 'Secondary text' },\n { path: ['text', 'disabled'], label: 'Disabled text' },\n]\n\n/**\n * Pale accent washes (AGL-1244).\n *\n * Separate from {@link PALETTE_COLOR_FIELDS} because a tint is a STRING LEAF,\n * not a `{ main }` record — the palette fields all write `main`, and a tint has\n * none. It rides the same `SurfaceColorPath` machinery as `background`/`text`\n * for exactly that reason, and is listed apart only so the editor can head it\n * \"Tints\" instead of filing it under \"Background & text\".\n */\nexport const TINT_COLOR_FIELDS: Array<{\n path: SurfaceColorPath\n label: string\n}> = [\n { path: ['tint', 'primary'], label: 'Primary tint' },\n { path: ['tint', 'secondary'], label: 'Secondary tint' },\n { path: ['tint', 'tertiary'], label: 'Tertiary tint' },\n]\n\n/** The one color leaf that is neither a palette color nor a member of a group. */\nexport const DIVIDER_COLOR_FIELD = { key: 'divider', label: 'Divider' } as const\n\n/** Curated Google Fonts choices for the font family selector. */\nexport const GOOGLE_FONT_OPTIONS: Array<{\n family: string\n category: 'sans-serif' | 'serif' | 'monospace' | 'display'\n weights: Array<number>\n}> = [\n { family: 'Inter', category: 'sans-serif', weights: [400, 500, 700] },\n { family: 'Roboto', category: 'sans-serif', weights: [400, 500, 700] },\n { family: 'Open Sans', category: 'sans-serif', weights: [400, 600, 700] },\n { family: 'Lato', category: 'sans-serif', weights: [400, 700] },\n { family: 'Montserrat', category: 'sans-serif', weights: [400, 500, 700] },\n { family: 'Poppins', category: 'sans-serif', weights: [400, 500, 700] },\n { family: 'Nunito', category: 'sans-serif', weights: [400, 600, 700] },\n { family: 'Work Sans', category: 'sans-serif', weights: [400, 500, 700] },\n { family: 'Raleway', category: 'sans-serif', weights: [400, 500, 700] },\n { family: 'Merriweather', category: 'serif', weights: [400, 700] },\n { family: 'Playfair Display', category: 'serif', weights: [400, 700] },\n { family: 'Lora', category: 'serif', weights: [400, 700] },\n { family: 'Source Serif 4', category: 'serif', weights: [400, 700] },\n { family: 'JetBrains Mono', category: 'monospace', weights: [400, 700] },\n { family: 'Bebas Neue', category: 'display', weights: [400] },\n]\n\nexport function fontFamilyStack(\n family: string,\n category: (typeof GOOGLE_FONT_OPTIONS)[number]['category'],\n) {\n const fallback = category === 'monospace' ? 'monospace' : category === 'serif' ? 'serif' : 'sans-serif'\n return `\"${family}\", ${fallback}`\n}\n\nexport function getSchemeColor(\n colors: HostThemeSchemeColors | undefined,\n path: SurfaceColorPath,\n): string | undefined {\n const [group, key] = path\n return (colors?.[group] as Record<string, string> | undefined)?.[key]\n}\n\n/* ------------------------------------------------------------------------ *\n * The controls, as one catalog\n * ------------------------------------------------------------------------ */\n\n/** The two color schemes the editor edits, in tab order. */\nexport const THEME_EDITOR_SCHEMES: readonly HostThemeScheme[] = ['light', 'dark']\n\n/**\n * Every color the editor edits per scheme, named the way a diff names it: a\n * palette key (`primary`), a group path joined with a dot\n * (`background.default`, `tint.primary`), or `divider`.\n */\nexport type ThemeColorToken =\n | PaletteColorKey\n | 'background.default'\n | 'background.paper'\n | 'text.primary'\n | 'text.secondary'\n | 'text.disabled'\n | 'tint.primary'\n | 'tint.secondary'\n | 'tint.tertiary'\n | 'divider'\n\n/** Where a color control sits in the editor's Color scheme card. */\nexport type ThemeColorGroup = 'palette' | 'surface' | 'tint' | 'divider'\n\n/** Every color field the editor renders, in the order it renders them. */\nexport const THEME_COLOR_FIELDS: ReadonlyArray<{\n token: ThemeColorToken\n label: string\n group: ThemeColorGroup\n}> = [\n ...PALETTE_COLOR_FIELDS.map(({ key, label }) => ({\n token: key,\n label,\n group: 'palette' as const,\n })),\n ...SURFACE_COLOR_FIELDS.map(({ path, label }) => ({\n token: path.join('.') as ThemeColorToken,\n label,\n group: 'surface' as const,\n })),\n ...TINT_COLOR_FIELDS.map(({ path, label }) => ({\n token: path.join('.') as ThemeColorToken,\n label,\n group: 'tint' as const,\n })),\n {\n token: DIVIDER_COLOR_FIELD.key,\n label: DIVIDER_COLOR_FIELD.label,\n group: 'divider' as const,\n },\n]\n\n/** Whether visitors get a dark scheme; absent from the document means `auto`. */\nexport type ThemeDarkSchemeValue = 'auto' | 'off'\n\nexport const DARK_SCHEME_FIELD = {\n label: 'Dark scheme',\n options: [\n { value: 'auto', label: 'Follows the visitor' },\n { value: 'off', label: 'Off — always light' },\n ],\n} as const\n\n/**\n * The font select's value for \"no font of the site's own\": the theme's\n * default stack, with nothing to load.\n */\nexport const SYSTEM_FONT_VALUE = '__system__'\n\nexport const FONT_FAMILY_FIELD = { label: 'Font family' } as const\n\n/** The corner radius slider, in px. */\nexport const BORDER_RADIUS_FIELD = {\n label: 'Border radius',\n min: 0,\n max: 24,\n step: 1,\n} as const\n\n/** The spacing unit MUI multiplies every `spacing(n)` by, in px. */\nexport const SPACING_FIELD = {\n label: 'Spacing unit (px)',\n min: 2,\n max: 16,\n step: 1,\n} as const\n\n/** The two nav heights, either side of MUI's toolbar breakpoint, in px. */\nexport const TOOLBAR_HEIGHT_FIELDS = {\n xs: { label: 'Nav height, mobile (px)', min: 40, max: 160, step: 1 },\n sm: { label: 'Nav height, desktop (px)', min: 40, max: 160, step: 1 },\n} as const\n\n/** The raw-JSON component overrides, limited to the sanitizer's whitelist. */\nexport const COMPONENT_OVERRIDES_FIELD = {\n label: 'Component overrides',\n components: HOST_THEME_COMPONENT_WHITELIST,\n} as const\n\n/**\n * The media queries a component override may scope a style to: either side\n * of MUI's own toolbar breakpoint, the one breakpoint the editor already\n * names. MUI's `down('sm')` stops a twentieth of a pixel short of it.\n */\nexport const THEME_EDITOR_MEDIA_QUERIES = {\n mobile: `@media (max-width:${TOOLBAR_SM_MIN_WIDTH - 0.05}px)`,\n desktop: TOOLBAR_SM_QUERY,\n} as const\n\nexport type ThemeEditorMedia = keyof typeof THEME_EDITOR_MEDIA_QUERIES\n\nexport type ThemeEditorControlId =\n | `color.${ThemeColorToken}`\n | 'darkScheme'\n | 'fontFamily'\n | 'borderRadius'\n | 'spacing'\n | 'navHeight.xs'\n | 'navHeight.sm'\n | 'components'\n\n/** One control the editor renders, described well enough to be offered elsewhere. */\nexport interface ThemeEditorControl {\n /** Stable id: what a diff row, a proposal and a spec name the control by. */\n id: ThemeEditorControlId\n /** The label the editor shows. */\n label: string\n kind: 'color' | 'select' | 'number' | 'json'\n /** Edited once per scheme, under the Light and Dark tabs. */\n perScheme: boolean\n /** A color control's token. */\n token?: ThemeColorToken\n /** A select's values, or the components a JSON control accepts. */\n options?: readonly string[]\n /** A number control's inclusive bounds and its step. */\n min?: number\n max?: number\n step?: number\n}\n\n/**\n * Every value-bearing control the editor renders, in the order it renders\n * them. The buttons that act on these values rather than hold one — Copy\n * from light, Reset to default, Discard, Save — are not controls: a reset is\n * a control set back to nothing, and a copy is every color control of one\n * scheme written from the other.\n */\nexport const THEME_EDITOR_CONTROLS: readonly ThemeEditorControl[] = [\n {\n id: 'darkScheme',\n label: DARK_SCHEME_FIELD.label,\n kind: 'select',\n perScheme: false,\n options: DARK_SCHEME_FIELD.options.map((option) => option.value),\n },\n ...THEME_COLOR_FIELDS.map(({ token, label }) => ({\n id: `color.${token}` as const,\n label,\n kind: 'color' as const,\n perScheme: true,\n token,\n })),\n {\n id: 'fontFamily',\n label: FONT_FAMILY_FIELD.label,\n kind: 'select',\n perScheme: false,\n options: [SYSTEM_FONT_VALUE, ...GOOGLE_FONT_OPTIONS.map((option) => option.family)],\n },\n {\n id: 'borderRadius',\n label: BORDER_RADIUS_FIELD.label,\n kind: 'number',\n perScheme: false,\n min: BORDER_RADIUS_FIELD.min,\n max: BORDER_RADIUS_FIELD.max,\n step: BORDER_RADIUS_FIELD.step,\n },\n {\n id: 'spacing',\n label: SPACING_FIELD.label,\n kind: 'number',\n perScheme: false,\n min: SPACING_FIELD.min,\n max: SPACING_FIELD.max,\n step: SPACING_FIELD.step,\n },\n {\n id: 'navHeight.xs',\n label: TOOLBAR_HEIGHT_FIELDS.xs.label,\n kind: 'number',\n perScheme: false,\n min: TOOLBAR_HEIGHT_FIELDS.xs.min,\n max: TOOLBAR_HEIGHT_FIELDS.xs.max,\n step: TOOLBAR_HEIGHT_FIELDS.xs.step,\n },\n {\n id: 'navHeight.sm',\n label: TOOLBAR_HEIGHT_FIELDS.sm.label,\n kind: 'number',\n perScheme: false,\n min: TOOLBAR_HEIGHT_FIELDS.sm.min,\n max: TOOLBAR_HEIGHT_FIELDS.sm.max,\n step: TOOLBAR_HEIGHT_FIELDS.sm.step,\n },\n {\n id: 'components',\n label: COMPONENT_OVERRIDES_FIELD.label,\n kind: 'json',\n perScheme: false,\n options: COMPONENT_OVERRIDES_FIELD.components,\n },\n]\n\n/** The catalog entry for a control id. */\nexport function themeEditorControl(id: ThemeEditorControlId): ThemeEditorControl {\n const control = THEME_EDITOR_CONTROLS.find((entry) => entry.id === id)\n if (!control) throw new Error(`unknown theme editor control ${id}`)\n return control\n}\n\n/* ------------------------------------------------------------------------ *\n * Reads and writes, exactly as the editor performs them\n * ------------------------------------------------------------------------ */\n\nfunction setSchemeValue(\n theme: HostTheme,\n scheme: HostThemeScheme,\n update: (colors: HostThemeSchemeColors) => HostThemeSchemeColors,\n): HostTheme {\n const colors = theme.colorSchemes?.[scheme] ?? {}\n return {\n ...theme,\n colorSchemes: { ...theme.colorSchemes, [scheme]: update(colors) },\n }\n}\n\n/** A color the site set for one scheme; `undefined` when the slot inherits. */\nexport function readThemeColor(\n theme: HostTheme | undefined,\n scheme: HostThemeScheme,\n token: ThemeColorToken,\n): string | undefined {\n const colors = theme?.colorSchemes?.[scheme]\n if (token === 'divider') return colors?.divider\n const [group, key] = token.split('.')\n if (!key) return colors?.[group as PaletteColorKey]?.main\n return getSchemeColor(colors, [group, key] as SurfaceColorPath)\n}\n\n/**\n * Sets one color for one scheme, or clears it with `undefined` so the slot\n * inherits again. A palette color writes `main` and keeps whatever else its\n * record carries, and clearing it drops the record; a group member that\n * leaves its group empty drops the group.\n */\nexport function writeThemeColor(\n theme: HostTheme,\n scheme: HostThemeScheme,\n token: ThemeColorToken,\n hex: string | undefined,\n): HostTheme {\n return setSchemeValue(theme, scheme, (colors) => {\n const next: HostThemeSchemeColors = { ...colors }\n if (token === 'divider') {\n if (hex) next.divider = hex\n else delete next.divider\n return next\n }\n const [group, key] = token.split('.')\n if (!key) {\n const paletteKey = group as PaletteColorKey\n if (hex) next[paletteKey] = { ...next[paletteKey], main: hex }\n else delete next[paletteKey]\n return next\n }\n const groupKey = group as 'background' | 'text' | 'tint'\n const groupValue = {\n ...(colors[groupKey] as Record<string, string> | undefined),\n }\n if (hex) groupValue[key] = hex\n else delete groupValue[key]\n const grouped = { ...next, [groupKey]: groupValue } as HostThemeSchemeColors\n if (!Object.keys(groupValue).length) delete grouped[groupKey]\n return grouped\n })\n}\n\n/** Replaces one scheme's colors with a copy of the other's. */\nexport function copyThemeSchemeColors(\n theme: HostTheme,\n from: HostThemeScheme,\n to: HostThemeScheme,\n): HostTheme {\n const source = theme.colorSchemes?.[from]\n if (!source) return theme\n return {\n ...theme,\n colorSchemes: {\n ...theme.colorSchemes,\n [to]: JSON.parse(JSON.stringify(source)),\n },\n }\n}\n\n/** The dark scheme switch as the select shows it. */\nexport function readDarkScheme(theme: HostTheme | undefined): ThemeDarkSchemeValue {\n return theme?.darkScheme === 'off' ? 'off' : 'auto'\n}\n\n/**\n * Absent means \"follows the visitor\"; only the opt-out is written, so the\n * saved document stays empty for the common case.\n */\nexport function writeDarkScheme(\n theme: HostTheme,\n value: ThemeDarkSchemeValue,\n): HostTheme {\n const next: HostTheme = { ...theme }\n if (value === 'off') next.darkScheme = 'off'\n else delete next.darkScheme\n return next\n}\n\n/** The font select's value: the site's font, or {@link SYSTEM_FONT_VALUE}. */\nexport function readFontFamily(theme: HostTheme | undefined): string {\n return theme?.fonts?.[0]?.family ?? SYSTEM_FONT_VALUE\n}\n\n/**\n * Picks a font from {@link GOOGLE_FONT_OPTIONS}, loading it and naming it as\n * the typography's stack, or {@link SYSTEM_FONT_VALUE} to go back to the\n * theme default. A family outside the curated list changes nothing.\n */\nexport function writeFontFamily(theme: HostTheme, value: string): HostTheme {\n if (value === SYSTEM_FONT_VALUE) {\n const next = { ...theme }\n delete next.fonts\n const typography = { ...next.typography }\n delete typography.fontFamily\n if (Object.keys(typography).length) next.typography = typography\n else delete next.typography\n return next\n }\n const option = GOOGLE_FONT_OPTIONS.find((entry) => entry.family === value)\n if (!option) return theme\n return {\n ...theme,\n fonts: [\n {\n family: option.family,\n weights: option.weights,\n source: 'google',\n },\n ],\n typography: {\n ...theme.typography,\n fontFamily: fontFamilyStack(option.family, option.category),\n },\n }\n}\n\n/** Sets the corner radius, or clears it with `undefined` so it inherits. */\nexport function writeBorderRadius(\n theme: HostTheme,\n value: number | undefined,\n): HostTheme {\n if (value !== undefined && Number.isFinite(value)) {\n return { ...theme, shape: { ...theme.shape, borderRadius: value } }\n }\n const next = { ...theme }\n const shape = { ...next.shape }\n delete shape.borderRadius\n if (Object.keys(shape).length) next.shape = shape\n else delete next.shape\n return next\n}\n\n/** Sets the spacing unit; anything but a positive number clears it. */\nexport function writeSpacing(theme: HostTheme, value: number | undefined): HostTheme {\n const next = { ...theme }\n if (value !== undefined && Number.isFinite(value) && value > 0) next.spacing = value\n else delete next.spacing\n return next\n}\n\n/**\n * Sets one nav height — anything but a positive number clears it — and\n * rebuilds the whole toolbar mixin around both, because `mixins.toolbar`\n * replaces MUI's default rather than merging into it (AGL-1242).\n */\nexport function writeToolbarHeight(\n theme: HostTheme,\n breakpoint: 'xs' | 'sm',\n value: number | undefined,\n): HostTheme {\n const valid = value !== undefined && Number.isFinite(value) && value > 0\n const edited = valid ? value : undefined\n const xs = breakpoint === 'xs' ? edited : readToolbarHeight(theme, 'xs')\n const sm = breakpoint === 'sm' ? edited : readToolbarHeight(theme, 'sm')\n const next = { ...theme }\n if (xs === undefined && sm === undefined) {\n delete next.mixins\n return next\n }\n next.mixins = { toolbar: buildToolbarMixin(xs, sm) }\n return next\n}\n\n/**\n * Drops the site's component overrides. With nothing stored the site renders\n * the brand's own component styles, which is what the editor's \"Reset to\n * theme defaults\" means.\n */\nexport function resetComponentOverrides(theme: HostTheme): HostTheme {\n const next = { ...theme }\n delete next.components\n return next\n}\n\n/** One leaf of a component override, as a writer names it. */\nexport interface ThemeComponentOverrideLeaf {\n component: HostThemeComponentKey\n /**\n * `styleOverrides` styles a slot in literal CSS; `sx` styles it in theme\n * terms, so a value may name a palette path (`primary.main`) or a spacing\n * unit (AGL-3403); `defaultProps` sets a prop's default.\n */\n target: 'styleOverrides' | 'sx' | 'defaultProps'\n /** The style slot (`root`, `contained`, `h1`); `null` for a default prop. */\n slot: string | null\n /** A camelCase CSS property, or the prop's name. */\n property: string\n /** Scopes a style to one side of the toolbar breakpoint; `null` for every width. */\n media: ThemeEditorMedia | null\n value: string | number | boolean\n}\n\n/**\n * Sets one leaf inside the site's component overrides and keeps every other\n * override the site has. The stored overrides are deep-merged over the\n * brand's own at render time, so naming one property changes that property\n * and inherits the rest of the component.\n */\nexport function writeComponentOverride(\n theme: HostTheme,\n leaf: ThemeComponentOverrideLeaf,\n): HostTheme {\n const components = { ...theme.components }\n const entry: HostThemeComponentOverride = { ...components[leaf.component] }\n if (leaf.target === 'defaultProps') {\n entry.defaultProps = { ...entry.defaultProps, [leaf.property]: leaf.value }\n } else {\n const slot = leaf.slot ?? 'root'\n const styles: Record<string, unknown> = {\n ...(leaf.target === 'sx' ? entry.sx : entry.styleOverrides),\n }\n const slotStyles = { ...(styles[slot] as Record<string, unknown> | undefined) }\n if (leaf.media) {\n const query = THEME_EDITOR_MEDIA_QUERIES[leaf.media]\n slotStyles[query] = {\n ...(slotStyles[query] as Record<string, unknown> | undefined),\n [leaf.property]: leaf.value,\n }\n } else {\n slotStyles[leaf.property] = leaf.value\n }\n styles[slot] = slotStyles\n if (leaf.target === 'sx') {\n entry.sx = styles as HostThemeComponentOverride['sx']\n } else {\n entry.styleOverrides = styles\n }\n }\n components[leaf.component] = entry\n return { ...theme, components }\n}\n"],"names":["HOST_THEME_COMPONENT_WHITELIST","TOOLBAR_SM_MIN_WIDTH","TOOLBAR_SM_QUERY","DEFAULT_TOOLBAR_XS","DEFAULT_TOOLBAR_SM","TOOLBAR_LANDSCAPE_QUERY","TOOLBAR_LANDSCAPE_RULE","minHeight","readToolbarHeight","theme","breakpoint","toolbar","mixins","undefined","raw","value","parseFloat","String","Number","isFinite","buildToolbarMixin","xs","sm","orderSensitiveKey","JSON","stringify","PALETTE_COLOR_FIELDS","key","label","SURFACE_COLOR_FIELDS","path","TINT_COLOR_FIELDS","DIVIDER_COLOR_FIELD","GOOGLE_FONT_OPTIONS","family","category","weights","fontFamilyStack","fallback","getSchemeColor","colors","group","THEME_EDITOR_SCHEMES","THEME_COLOR_FIELDS","map","token","join","DARK_SCHEME_FIELD","options","SYSTEM_FONT_VALUE","FONT_FAMILY_FIELD","BORDER_RADIUS_FIELD","min","max","step","SPACING_FIELD","TOOLBAR_HEIGHT_FIELDS","COMPONENT_OVERRIDES_FIELD","components","THEME_EDITOR_MEDIA_QUERIES","mobile","desktop","THEME_EDITOR_CONTROLS","id","kind","perScheme","option","themeEditorControl","control","find","entry","Error","setSchemeValue","scheme","update","colorSchemes","readThemeColor","divider","split","main","writeThemeColor","hex","next","paletteKey","groupKey","groupValue","grouped","Object","keys","length","copyThemeSchemeColors","from","to","source","parse","readDarkScheme","darkScheme","writeDarkScheme","readFontFamily","fonts","writeFontFamily","typography","fontFamily","writeBorderRadius","shape","borderRadius","writeSpacing","spacing","writeToolbarHeight","valid","edited","resetComponentOverrides","writeComponentOverride","leaf","component","target","defaultProps","property","slot","styles","sx","styleOverrides","slotStyles","media","query"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC;AAQD,SACEA,8BAA8B,QAEzB,kBAAc;AAErB;;;;;;;;;;;;;;;;;;;;CAoBC,GAED;;;;CAIC,GACD,OAAO,MAAMC,uBAAuB,IAAG;AACvC,OAAO,MAAMC,mBAAmB,CAAC,kBAAkB,EAAED,qBAAqB,GAAG,CAAC,CAAA;AAC9E,mEAAmE,GACnE,OAAO,MAAME,qBAAqB,GAAE;AACpC,OAAO,MAAMC,qBAAqB,GAAE;AACpC;;;;CAIC,GACD,OAAO,MAAMC,0BAA0B,yBAAwB;AAC/D,OAAO,MAAMC,yBAAyB;IACpC,mCAAmC;QAAEC,WAAW;IAAG;AACrD,EAAC;AAED,uEAAuE,GACvE,OAAO,SAASC,kBAAkBC,KAAgB,EAAEC,UAAuB;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AM8C,YAAY,GAAG,aAAK9C,MAAM8C,YAAY;YAAE,CAACH,KAAKI,QAAQ,CAAC,EAAEJ,KAAKlG,KAAK;;IAC3E,OAAO;YACQkG;QAAb,MAAMK,QAAOL,aAAAA,KAAKK,IAAI,YAATL,aAAa;QAC1B,MAAMM,SAAkC,aAClCN,KAAKE,MAAM,KAAK,OAAO7C,MAAMkD,EAAE,GAAGlD,MAAMmD,cAAc;QAE5D,MAAMC,aAAa,aAAMH,MAAM,CAACD,KAAK;QACrC,IAAIL,KAAKU,KAAK,EAAE;YACd,MAAMC,QAAQjE,0BAA0B,CAACsD,KAAKU,KAAK,CAAC;YACpDD,UAAU,CAACE,MAAM,GAAG,aACdF,UAAU,CAACE,MAAM;gBACrB,CAACX,KAAKI,QAAQ,CAAC,EAAEJ,KAAKlG,KAAK;;QAE/B,OAAO;YACL2G,UAAU,CAACT,KAAKI,QAAQ,CAAC,GAAGJ,KAAKlG,KAAK;QACxC;QACAwG,MAAM,CAACD,KAAK,GAAGI;QACf,IAAIT,KAAKE,MAAM,KAAK,MAAM;YACxB7C,MAAMkD,EAAE,GAAGD;QACb,OAAO;YACLjD,MAAMmD,cAAc,GAAGF;QACzB;IACF;IACA7D,UAAU,CAACuD,KAAKC,SAAS,CAAC,GAAG5C;IAC7B,OAAO,aAAK7D;QAAOiD;;AACrB"}
1
+ {"version":3,"sources":["../../../../../../../../libs/shared/ui/theme/src/lib/util/theme-editor-fields.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 type {\n HostTheme,\n HostThemeComponentOverride,\n HostThemeFont,\n HostThemeFontCategory,\n HostThemeTypographyVariantKey,\n HostThemeScheme,\n HostThemeSchemeColors,\n} from '@aglyn/shared-data-types'\nimport {\n HOST_THEME_COMPONENT_WHITELIST,\n type HostThemeComponentKey,\n} from './host-theme'\n\n/**\n * The host theme editor's field catalog (AGL-2938): every control the editor\n * renders, the range each one accepts, the token it writes, and the write\n * itself.\n *\n * It lives here rather than beside the editor because the editor is not the\n * only thing that changes a site's theme. Anything that proposes a theme\n * change has to offer exactly the controls the editor offers, with the same\n * bounds, and has to write each one the way the editor writes it. A copy of\n * this list anywhere else is a second answer to \"what can a theme hold\" that\n * drifts from the first the day a control is added, so the editor renders\n * from this module and every other writer reads it.\n *\n * Pure data and pure functions over `HostTheme`: no MUI, no React and no\n * brand theme. What a control resolves to when the site sets nothing is the\n * brand theme's business, in `theme-editor-defaults.ts`.\n *\n * Deliberately NOT re-exported from this library's index: the index reaches\n * every published page, and nothing a visitor renders needs the catalog.\n * Reach it as `@aglyn/shared-ui-theme/util/theme-editor-fields`.\n */\n\n/**\n * MUI's own toolbar breakpoint. `mixins.toolbar` has to carry this exact\n * query, because the rule it competes with is MUI's `@media (min-width:600px)\n * { min-height: 64px }` (AGL-1242).\n */\nexport const TOOLBAR_SM_MIN_WIDTH = 600\nexport const TOOLBAR_SM_QUERY = `@media (min-width:${TOOLBAR_SM_MIN_WIDTH}px)`\n/** MUI's stock Toolbar heights, shown when the host has set none. */\nexport const DEFAULT_TOOLBAR_XS = 56\nexport const DEFAULT_TOOLBAR_SM = 64\n/**\n * `createMixins` spreads `...mixins` AFTER its default, so anything we write\n * REPLACES the stock toolbar wholesale — including its short-landscape rule.\n * Carrying it forward keeps that behavior instead of dropping it silently.\n */\nexport const TOOLBAR_LANDSCAPE_QUERY = '@media (min-width:0px)'\nexport const TOOLBAR_LANDSCAPE_RULE = {\n '@media (orientation: landscape)': { minHeight: 48 },\n}\n\n/** Reads a px `minHeight` out of `mixins.toolbar` for one breakpoint. */\nexport function readToolbarHeight(theme: HostTheme, breakpoint: 'xs' | 'sm') {\n const toolbar = theme.mixins?.toolbar\n if (!toolbar) return undefined\n const raw =\n breakpoint === 'xs'\n ? toolbar.minHeight\n : (toolbar[TOOLBAR_SM_QUERY] as { minHeight?: unknown } | undefined)\n ?.minHeight\n const value = parseFloat(String(raw ?? ''))\n return Number.isFinite(value) ? value : undefined\n}\n\n/**\n * Builds a COMPLETE `mixins.toolbar`, in the order MUI emits it.\n *\n * Two things this exists to get right, both because `mixins.toolbar` replaces\n * MUI's default wholesale rather than merging into it (AGL-1242):\n *\n * - **Completeness.** Anything omitted is simply gone. Writing only a desktop\n * height left portrait phones with no `min-height` at all, so unset\n * breakpoints fall back to MUI's own 56 / 64.\n * - **Key order.** These land in one CSS rule, so the last matching\n * declaration wins. MUI emits the landscape clause BEFORE the sm height;\n * emitting it after makes a wide landscape window — i.e. every desktop —\n * 48px tall.\n */\nexport function buildToolbarMixin(xs: number | undefined, sm: number | undefined) {\n return {\n minHeight: `${xs ?? DEFAULT_TOOLBAR_XS}px`,\n [TOOLBAR_LANDSCAPE_QUERY]: TOOLBAR_LANDSCAPE_RULE,\n [TOOLBAR_SM_QUERY]: { minHeight: `${sm ?? DEFAULT_TOOLBAR_SM}px` },\n }\n}\n\n/**\n * Serializes the branches whose KEY ORDER changes what renders.\n *\n * `deepEqual` is order-INsensitive on purpose (AGL-56: Firestore hands the\n * palette back in a different key order than the editor builds it, and a\n * string compare left Save enabled forever), so on its own it cannot see a\n * reorder of `mixins.toolbar` — a change that really does alter the CSS.\n *\n * Deliberately narrow: only `mixins`. `components.*.styleOverrides` are CSS\n * objects too, but widening this would re-expose the AGL-56 failure for every\n * host with component overrides, and order-sensitivity has only actually been\n * demonstrated here.\n *\n * Firestore does NOT hand a map back in the order it was written, and it\n * hands different readers different orders (AGL-3146) — which is why what\n * renders is canonicalized in `hostThemeToThemeOptions` rather than trusted\n * from storage. A freshly-loaded document is still not dirty here, because\n * the draft is seeded from the loaded document itself: both sides of this\n * comparison carry whatever order THIS reader was given.\n */\nexport function orderSensitiveKey(theme: HostTheme): string {\n return JSON.stringify(theme.mixins ?? {})\n}\n\nexport type PaletteColorKey =\n | 'primary'\n | 'secondary'\n | 'tertiary'\n | 'surface'\n | 'error'\n | 'warning'\n | 'info'\n | 'success'\n\nexport const PALETTE_COLOR_FIELDS: Array<{\n key: PaletteColorKey\n label: string\n}> = [\n { key: 'primary', label: 'Primary' },\n { key: 'secondary', label: 'Secondary' },\n { key: 'tertiary', label: 'Tertiary' },\n { key: 'surface', label: 'Surface' },\n { key: 'error', label: 'Error' },\n { key: 'warning', label: 'Warning' },\n { key: 'info', label: 'Info' },\n { key: 'success', label: 'Success' },\n]\n\nexport type SurfaceColorPath =\n | ['background', 'default']\n | ['background', 'paper']\n | ['text', 'primary']\n | ['text', 'secondary']\n | ['text', 'disabled']\n | ['tint', 'primary']\n | ['tint', 'secondary']\n | ['tint', 'tertiary']\n\nexport const SURFACE_COLOR_FIELDS: Array<{\n path: SurfaceColorPath\n label: string\n}> = [\n { path: ['background', 'default'], label: 'Background' },\n { path: ['background', 'paper'], label: 'Paper' },\n { path: ['text', 'primary'], label: 'Text' },\n { path: ['text', 'secondary'], label: 'Secondary text' },\n { path: ['text', 'disabled'], label: 'Disabled text' },\n]\n\n/**\n * Pale accent washes (AGL-1244).\n *\n * Separate from {@link PALETTE_COLOR_FIELDS} because a tint is a STRING LEAF,\n * not a `{ main }` record — the palette fields all write `main`, and a tint has\n * none. It rides the same `SurfaceColorPath` machinery as `background`/`text`\n * for exactly that reason, and is listed apart only so the editor can head it\n * \"Tints\" instead of filing it under \"Background & text\".\n */\nexport const TINT_COLOR_FIELDS: Array<{\n path: SurfaceColorPath\n label: string\n}> = [\n { path: ['tint', 'primary'], label: 'Primary tint' },\n { path: ['tint', 'secondary'], label: 'Secondary tint' },\n { path: ['tint', 'tertiary'], label: 'Tertiary tint' },\n]\n\n/** The one color leaf that is neither a palette color nor a member of a group. */\nexport const DIVIDER_COLOR_FIELD = { key: 'divider', label: 'Divider' } as const\n\n/** Curated Google Fonts choices for the font family selector. */\nexport const GOOGLE_FONT_OPTIONS: Array<{\n family: string\n category: 'sans-serif' | 'serif' | 'monospace' | 'display'\n weights: Array<number>\n}> = [\n { family: 'Inter', category: 'sans-serif', weights: [400, 500, 700] },\n { family: 'Roboto', category: 'sans-serif', weights: [400, 500, 700] },\n { family: 'Open Sans', category: 'sans-serif', weights: [400, 600, 700] },\n { family: 'Lato', category: 'sans-serif', weights: [400, 700] },\n { family: 'Montserrat', category: 'sans-serif', weights: [400, 500, 700] },\n { family: 'Poppins', category: 'sans-serif', weights: [400, 500, 700] },\n { family: 'Nunito', category: 'sans-serif', weights: [400, 600, 700] },\n { family: 'Work Sans', category: 'sans-serif', weights: [400, 500, 700] },\n { family: 'Raleway', category: 'sans-serif', weights: [400, 500, 700] },\n { family: 'Merriweather', category: 'serif', weights: [400, 700] },\n { family: 'Playfair Display', category: 'serif', weights: [400, 700] },\n { family: 'Lora', category: 'serif', weights: [400, 700] },\n { family: 'Source Serif 4', category: 'serif', weights: [400, 700] },\n { family: 'JetBrains Mono', category: 'monospace', weights: [400, 700] },\n { family: 'Bebas Neue', category: 'display', weights: [400] },\n]\n\nexport function fontFamilyStack(\n family: string,\n category: HostThemeFontCategory,\n) {\n const fallback = category === 'monospace' ? 'monospace' : category === 'serif' ? 'serif' : 'sans-serif'\n return `\"${family}\", ${fallback}`\n}\n\nexport function getSchemeColor(\n colors: HostThemeSchemeColors | undefined,\n path: SurfaceColorPath,\n): string | undefined {\n const [group, key] = path\n return (colors?.[group] as Record<string, string> | undefined)?.[key]\n}\n\n/* ------------------------------------------------------------------------ *\n * The controls, as one catalog\n * ------------------------------------------------------------------------ */\n\n/** The two color schemes the editor edits, in tab order. */\nexport const THEME_EDITOR_SCHEMES: readonly HostThemeScheme[] = ['light', 'dark']\n\n/**\n * Every color the editor edits per scheme, named the way a diff names it: a\n * palette key (`primary`), a group path joined with a dot\n * (`background.default`, `tint.primary`), or `divider`.\n */\nexport type ThemeColorToken =\n | PaletteColorKey\n | 'background.default'\n | 'background.paper'\n | 'text.primary'\n | 'text.secondary'\n | 'text.disabled'\n | 'tint.primary'\n | 'tint.secondary'\n | 'tint.tertiary'\n | 'divider'\n\n/** Where a color control sits in the editor's Color scheme card. */\nexport type ThemeColorGroup = 'palette' | 'surface' | 'tint' | 'divider'\n\n/** Every color field the editor renders, in the order it renders them. */\nexport const THEME_COLOR_FIELDS: ReadonlyArray<{\n token: ThemeColorToken\n label: string\n group: ThemeColorGroup\n}> = [\n ...PALETTE_COLOR_FIELDS.map(({ key, label }) => ({\n token: key,\n label,\n group: 'palette' as const,\n })),\n ...SURFACE_COLOR_FIELDS.map(({ path, label }) => ({\n token: path.join('.') as ThemeColorToken,\n label,\n group: 'surface' as const,\n })),\n ...TINT_COLOR_FIELDS.map(({ path, label }) => ({\n token: path.join('.') as ThemeColorToken,\n label,\n group: 'tint' as const,\n })),\n {\n token: DIVIDER_COLOR_FIELD.key,\n label: DIVIDER_COLOR_FIELD.label,\n group: 'divider' as const,\n },\n]\n\n/** Whether visitors get a dark scheme; absent from the document means `auto`. */\nexport type ThemeDarkSchemeValue = 'auto' | 'off'\n\nexport const DARK_SCHEME_FIELD = {\n label: 'Dark scheme',\n options: [\n { value: 'auto', label: 'Follows the visitor' },\n { value: 'off', label: 'Off — always light' },\n ],\n} as const\n\n/**\n * The font select's value for \"no font of the site's own\": the theme's\n * default stack, with nothing to load.\n */\nexport const SYSTEM_FONT_VALUE = '__system__'\n\nexport const FONT_FAMILY_FIELD = { label: 'Font family' } as const\n\n/** The corner radius slider, in px. */\nexport const BORDER_RADIUS_FIELD = {\n label: 'Border radius',\n min: 0,\n max: 24,\n step: 1,\n} as const\n\n/** The spacing unit MUI multiplies every `spacing(n)` by, in px. */\nexport const SPACING_FIELD = {\n label: 'Spacing unit (px)',\n min: 2,\n max: 16,\n step: 1,\n} as const\n\n/** The two nav heights, either side of MUI's toolbar breakpoint, in px. */\nexport const TOOLBAR_HEIGHT_FIELDS = {\n xs: { label: 'Nav height, mobile (px)', min: 40, max: 160, step: 1 },\n sm: { label: 'Nav height, desktop (px)', min: 40, max: 160, step: 1 },\n} as const\n\n/** The raw-JSON component overrides, limited to the sanitizer's whitelist. */\nexport const COMPONENT_OVERRIDES_FIELD = {\n label: 'Component overrides',\n components: HOST_THEME_COMPONENT_WHITELIST,\n} as const\n\n/**\n * The media queries a component override may scope a style to: either side\n * of MUI's own toolbar breakpoint, the one breakpoint the editor already\n * names. MUI's `down('sm')` stops a twentieth of a pixel short of it.\n */\nexport const THEME_EDITOR_MEDIA_QUERIES = {\n mobile: `@media (max-width:${TOOLBAR_SM_MIN_WIDTH - 0.05}px)`,\n desktop: TOOLBAR_SM_QUERY,\n} as const\n\nexport type ThemeEditorMedia = keyof typeof THEME_EDITOR_MEDIA_QUERIES\n\nexport type ThemeEditorControlId =\n | `color.${ThemeColorToken}`\n | 'darkScheme'\n | 'fontFamily'\n | 'borderRadius'\n | 'spacing'\n | 'navHeight.xs'\n | 'navHeight.sm'\n | 'components'\n\n/** One control the editor renders, described well enough to be offered elsewhere. */\nexport interface ThemeEditorControl {\n /** Stable id: what a diff row, a proposal and a spec name the control by. */\n id: ThemeEditorControlId\n /** The label the editor shows. */\n label: string\n kind: 'color' | 'select' | 'number' | 'json'\n /** Edited once per scheme, under the Light and Dark tabs. */\n perScheme: boolean\n /** A color control's token. */\n token?: ThemeColorToken\n /** A select's values, or the components a JSON control accepts. */\n options?: readonly string[]\n /** A number control's inclusive bounds and its step. */\n min?: number\n max?: number\n step?: number\n}\n\n/**\n * Every value-bearing control the editor renders, in the order it renders\n * them. The buttons that act on these values rather than hold one — Copy\n * from light, Reset to default, Discard, Save — are not controls: a reset is\n * a control set back to nothing, and a copy is every color control of one\n * scheme written from the other.\n */\nexport const THEME_EDITOR_CONTROLS: readonly ThemeEditorControl[] = [\n {\n id: 'darkScheme',\n label: DARK_SCHEME_FIELD.label,\n kind: 'select',\n perScheme: false,\n options: DARK_SCHEME_FIELD.options.map((option) => option.value),\n },\n ...THEME_COLOR_FIELDS.map(({ token, label }) => ({\n id: `color.${token}` as const,\n label,\n kind: 'color' as const,\n perScheme: true,\n token,\n })),\n {\n id: 'fontFamily',\n label: FONT_FAMILY_FIELD.label,\n kind: 'select',\n perScheme: false,\n options: [SYSTEM_FONT_VALUE, ...GOOGLE_FONT_OPTIONS.map((option) => option.family)],\n },\n {\n id: 'borderRadius',\n label: BORDER_RADIUS_FIELD.label,\n kind: 'number',\n perScheme: false,\n min: BORDER_RADIUS_FIELD.min,\n max: BORDER_RADIUS_FIELD.max,\n step: BORDER_RADIUS_FIELD.step,\n },\n {\n id: 'spacing',\n label: SPACING_FIELD.label,\n kind: 'number',\n perScheme: false,\n min: SPACING_FIELD.min,\n max: SPACING_FIELD.max,\n step: SPACING_FIELD.step,\n },\n {\n id: 'navHeight.xs',\n label: TOOLBAR_HEIGHT_FIELDS.xs.label,\n kind: 'number',\n perScheme: false,\n min: TOOLBAR_HEIGHT_FIELDS.xs.min,\n max: TOOLBAR_HEIGHT_FIELDS.xs.max,\n step: TOOLBAR_HEIGHT_FIELDS.xs.step,\n },\n {\n id: 'navHeight.sm',\n label: TOOLBAR_HEIGHT_FIELDS.sm.label,\n kind: 'number',\n perScheme: false,\n min: TOOLBAR_HEIGHT_FIELDS.sm.min,\n max: TOOLBAR_HEIGHT_FIELDS.sm.max,\n step: TOOLBAR_HEIGHT_FIELDS.sm.step,\n },\n {\n id: 'components',\n label: COMPONENT_OVERRIDES_FIELD.label,\n kind: 'json',\n perScheme: false,\n options: COMPONENT_OVERRIDES_FIELD.components,\n },\n]\n\n/** The catalog entry for a control id. */\nexport function themeEditorControl(id: ThemeEditorControlId): ThemeEditorControl {\n const control = THEME_EDITOR_CONTROLS.find((entry) => entry.id === id)\n if (!control) throw new Error(`unknown theme editor control ${id}`)\n return control\n}\n\n/* ------------------------------------------------------------------------ *\n * Reads and writes, exactly as the editor performs them\n * ------------------------------------------------------------------------ */\n\nfunction setSchemeValue(\n theme: HostTheme,\n scheme: HostThemeScheme,\n update: (colors: HostThemeSchemeColors) => HostThemeSchemeColors,\n): HostTheme {\n const colors = theme.colorSchemes?.[scheme] ?? {}\n return {\n ...theme,\n colorSchemes: { ...theme.colorSchemes, [scheme]: update(colors) },\n }\n}\n\n/** A color the site set for one scheme; `undefined` when the slot inherits. */\nexport function readThemeColor(\n theme: HostTheme | undefined,\n scheme: HostThemeScheme,\n token: ThemeColorToken,\n): string | undefined {\n const colors = theme?.colorSchemes?.[scheme]\n if (token === 'divider') return colors?.divider\n const [group, key] = token.split('.')\n if (!key) return colors?.[group as PaletteColorKey]?.main\n return getSchemeColor(colors, [group, key] as SurfaceColorPath)\n}\n\n/**\n * Sets one color for one scheme, or clears it with `undefined` so the slot\n * inherits again. A palette color writes `main` and keeps whatever else its\n * record carries, and clearing it drops the record; a group member that\n * leaves its group empty drops the group.\n */\nexport function writeThemeColor(\n theme: HostTheme,\n scheme: HostThemeScheme,\n token: ThemeColorToken,\n hex: string | undefined,\n): HostTheme {\n return setSchemeValue(theme, scheme, (colors) => {\n const next: HostThemeSchemeColors = { ...colors }\n if (token === 'divider') {\n if (hex) next.divider = hex\n else delete next.divider\n return next\n }\n const [group, key] = token.split('.')\n if (!key) {\n const paletteKey = group as PaletteColorKey\n if (hex) next[paletteKey] = { ...next[paletteKey], main: hex }\n else delete next[paletteKey]\n return next\n }\n const groupKey = group as 'background' | 'text' | 'tint'\n const groupValue = {\n ...(colors[groupKey] as Record<string, string> | undefined),\n }\n if (hex) groupValue[key] = hex\n else delete groupValue[key]\n const grouped = { ...next, [groupKey]: groupValue } as HostThemeSchemeColors\n if (!Object.keys(groupValue).length) delete grouped[groupKey]\n return grouped\n })\n}\n\n/** Replaces one scheme's colors with a copy of the other's. */\nexport function copyThemeSchemeColors(\n theme: HostTheme,\n from: HostThemeScheme,\n to: HostThemeScheme,\n): HostTheme {\n const source = theme.colorSchemes?.[from]\n if (!source) return theme\n return {\n ...theme,\n colorSchemes: {\n ...theme.colorSchemes,\n [to]: JSON.parse(JSON.stringify(source)),\n },\n }\n}\n\n/** The dark scheme switch as the select shows it. */\nexport function readDarkScheme(theme: HostTheme | undefined): ThemeDarkSchemeValue {\n return theme?.darkScheme === 'off' ? 'off' : 'auto'\n}\n\n/**\n * Absent means \"follows the visitor\"; only the opt-out is written, so the\n * saved document stays empty for the common case.\n */\nexport function writeDarkScheme(\n theme: HostTheme,\n value: ThemeDarkSchemeValue,\n): HostTheme {\n const next: HostTheme = { ...theme }\n if (value === 'off') next.darkScheme = 'off'\n else delete next.darkScheme\n return next\n}\n\n/** The font select's value: the site's font, or {@link SYSTEM_FONT_VALUE}. */\nexport function readFontFamily(theme: HostTheme | undefined): string {\n return readThemeFonts(theme).body?.family ?? SYSTEM_FONT_VALUE\n}\n\n/**\n * Picks a font from {@link GOOGLE_FONT_OPTIONS}, loading it and naming it as\n * the typography's stack, or {@link SYSTEM_FONT_VALUE} to go back to the\n * theme default. A family outside the curated list changes nothing.\n */\nexport function writeFontFamily(theme: HostTheme, value: string): HostTheme {\n // Through writeThemeFonts (AGL-3656), so a heading font and the site's own\n // uploaded fonts survive a body font picked from the short list or by the\n // AI theme step; replacing `fonts` wholesale dropped both.\n const current = readThemeFonts(theme)\n if (value === SYSTEM_FONT_VALUE) {\n return writeThemeFonts(theme, { body: null, heading: current.heading })\n }\n const option = GOOGLE_FONT_OPTIONS.find((entry) => entry.family === value)\n if (!option) return theme\n return writeThemeFonts(theme, {\n body: {\n family: option.family,\n category: option.category,\n weights: option.weights,\n source: 'google',\n },\n heading: current.heading,\n })\n}\n\n/**\n * The text styles a separate heading font is set on: `h1`…`h6`, and\n * `displayXl`, the platform's rung above `h1`, which a heading font left off\n * would draw in the body font — and load the body font's heaviest weight for.\n */\nexport const THEME_HEADING_VARIANTS: readonly HostThemeTypographyVariantKey[] = [\n 'displayXl',\n 'h1',\n 'h2',\n 'h3',\n 'h4',\n 'h5',\n 'h6',\n]\n\n/**\n * One family a theme sets text in, as the font picker shows and writes it\n * (AGL-3656): a `fonts` entry and the role it plays.\n */\nexport interface ThemeFontChoice {\n family: string\n category: HostThemeFontCategory\n /** Upright weights to load, ascending. */\n weights: number[]\n /** Italic weights to load, ascending; absent or empty for none. */\n italics?: number[]\n source: 'google' | 'custom'\n}\n\n/**\n * The theme's body font and, when it differs, its heading font. `null` is the\n * theme default: the base stack, nothing loaded.\n */\nexport interface ThemeFontSelection {\n body: ThemeFontChoice | null\n heading: ThemeFontChoice | null\n}\n\n/** The first family a CSS font-family stack names, unquoted. */\nexport function firstStackFamily(stack: unknown): string | undefined {\n if (typeof stack !== 'string') return undefined\n const first = stack.split(',')[0]?.trim().replace(/^[\"']|[\"']$/g, '').trim()\n return first || undefined\n}\n\n/** The category a stack's generic keyword names, for a font that records none. */\nfunction stackCategory(stack: unknown): HostThemeFontCategory {\n if (typeof stack !== 'string') return 'sans-serif'\n if (/\\bmonospace\\b/i.test(stack)) return 'monospace'\n if (/(^|,)\\s*serif\\b/i.test(stack)) return 'serif'\n return 'sans-serif'\n}\n\nfunction sortedWeights(values: readonly unknown[] | undefined): number[] {\n return [\n ...new Set(\n (values ?? [])\n .map((value) => Math.round(Number(value)))\n .filter((value) => Number.isFinite(value) && value >= 1 && value <= 1000),\n ),\n ].sort((a, b) => a - b)\n}\n\nfunction choiceOf(font: HostThemeFont, stack: unknown): ThemeFontChoice {\n const italics = sortedWeights(font.italics)\n return {\n family: font.family.trim(),\n category: font.category ?? stackCategory(stack),\n weights: sortedWeights(font.weights).length ? sortedWeights(font.weights) : [400],\n ...(italics.length ? { italics } : {}),\n source: font.source === 'custom' ? 'custom' : 'google',\n }\n}\n\nfunction findFont(theme: HostTheme | undefined, family: string | undefined) {\n if (!family) return undefined\n const wanted = family.toLowerCase()\n return theme?.fonts?.find(\n (font) =>\n font.family?.trim().toLowerCase() === wanted && (font.source ?? 'google') !== 'system',\n )\n}\n\n/**\n * The body and heading fonts a theme sets text in (AGL-3656).\n *\n * The body font is the family the theme-wide stack names first, when the\n * theme loads it: a font the theme lists that no stack names draws nothing,\n * which is what the theme default is. The heading font is the family `h1`\n * names, when that is a loaded font other than the body's.\n */\nexport function readThemeFonts(theme: HostTheme | undefined): ThemeFontSelection {\n const stack = theme?.typography?.fontFamily\n const bodyFont = findFont(theme, firstStackFamily(stack))\n const headingStack = theme?.typography?.variants?.h1?.fontFamily\n const headingFont = findFont(theme, firstStackFamily(headingStack))\n return {\n body: bodyFont ? choiceOf(bodyFont, stack) : null,\n heading:\n headingFont && headingFont !== bodyFont ? choiceOf(headingFont, headingStack) : null,\n }\n}\n\nfunction fontEntry(choice: ThemeFontChoice): HostThemeFont {\n const italics = sortedWeights(choice.italics)\n return {\n family: choice.family.trim(),\n weights: sortedWeights(choice.weights).length ? sortedWeights(choice.weights) : [400],\n ...(italics.length ? { italics } : {}),\n source: choice.source,\n category: choice.category,\n }\n}\n\n/**\n * Sets the theme's body and heading fonts (AGL-3656): the `fonts` entries the\n * page loads, the theme-wide stack, and the stack of each style in\n * {@link THEME_HEADING_VARIANTS} for a heading font of its own. `null` goes\n * back to the theme default for that role.\n *\n * An uploaded (`custom`) font the theme lists but no longer sets text in is\n * kept, because it is the site's own and is picked again from the list; a\n * Google font nothing sets text in any more is dropped, so the page stops\n * loading it. Everything else in the typography — sizes, weights, a variant's own\n * family that is not a heading — is left as it was.\n */\nexport function writeThemeFonts(theme: HostTheme, selection: ThemeFontSelection): HostTheme {\n const body = selection.body\n const heading =\n selection.heading &&\n (!body || selection.heading.family.toLowerCase() !== body.family.toLowerCase())\n ? selection.heading\n : null\n const previous = readThemeFonts(theme)\n const previousHeadingStack = previous.heading\n ? theme.typography?.variants?.h1?.fontFamily\n : undefined\n\n const chosen = [body, heading].filter((entry): entry is ThemeFontChoice => !!entry)\n const chosenKeys = new Set(chosen.map((entry) => entry.family.trim().toLowerCase()))\n // Families a text style other than a heading still names, by hand or by\n // an earlier editor: they keep loading, as their style keeps drawing them.\n const otherStyles = new Set(\n Object.entries(theme.typography?.variants ?? {})\n .filter(([key]) => !(THEME_HEADING_VARIANTS as readonly string[]).includes(key))\n .map(([, variant]) => firstStackFamily(variant?.fontFamily)?.toLowerCase())\n .filter((family): family is string => !!family),\n )\n const kept = (theme.fonts ?? []).filter((font) => {\n const key = font.family?.trim().toLowerCase() ?? ''\n if (!key || chosenKeys.has(key)) return false\n return font.source === 'custom' || otherStyles.has(key)\n })\n const fonts = [...chosen.map(fontEntry), ...kept]\n\n const typography = { ...theme.typography }\n if (body) typography.fontFamily = fontFamilyStack(body.family.trim(), body.category)\n else delete typography.fontFamily\n\n const variants = { ...typography.variants }\n for (const key of THEME_HEADING_VARIANTS) {\n const variant = { ...variants[key] }\n if (heading) {\n variant.fontFamily = fontFamilyStack(heading.family.trim(), heading.category)\n } else if (\n variant.fontFamily !== undefined &&\n (variant.fontFamily === previousHeadingStack ||\n !findFont({ fonts }, firstStackFamily(variant.fontFamily)))\n ) {\n // The heading font this theme had, or a family it no longer loads.\n delete variant.fontFamily\n }\n if (Object.keys(variant).length) variants[key] = variant\n else delete variants[key]\n }\n if (Object.keys(variants).length) typography.variants = variants\n else delete typography.variants\n\n const next: HostTheme = { ...theme }\n if (fonts.length) next.fonts = fonts\n else delete next.fonts\n if (Object.keys(typography).length) next.typography = typography\n else delete next.typography\n return next\n}\n\n/** Sets the corner radius, or clears it with `undefined` so it inherits. */\nexport function writeBorderRadius(\n theme: HostTheme,\n value: number | undefined,\n): HostTheme {\n if (value !== undefined && Number.isFinite(value)) {\n return { ...theme, shape: { ...theme.shape, borderRadius: value } }\n }\n const next = { ...theme }\n const shape = { ...next.shape }\n delete shape.borderRadius\n if (Object.keys(shape).length) next.shape = shape\n else delete next.shape\n return next\n}\n\n/** Sets the spacing unit; anything but a positive number clears it. */\nexport function writeSpacing(theme: HostTheme, value: number | undefined): HostTheme {\n const next = { ...theme }\n if (value !== undefined && Number.isFinite(value) && value > 0) next.spacing = value\n else delete next.spacing\n return next\n}\n\n/**\n * Sets one nav height — anything but a positive number clears it — and\n * rebuilds the whole toolbar mixin around both, because `mixins.toolbar`\n * replaces MUI's default rather than merging into it (AGL-1242).\n */\nexport function writeToolbarHeight(\n theme: HostTheme,\n breakpoint: 'xs' | 'sm',\n value: number | undefined,\n): HostTheme {\n const valid = value !== undefined && Number.isFinite(value) && value > 0\n const edited = valid ? value : undefined\n const xs = breakpoint === 'xs' ? edited : readToolbarHeight(theme, 'xs')\n const sm = breakpoint === 'sm' ? edited : readToolbarHeight(theme, 'sm')\n const next = { ...theme }\n if (xs === undefined && sm === undefined) {\n delete next.mixins\n return next\n }\n next.mixins = { toolbar: buildToolbarMixin(xs, sm) }\n return next\n}\n\n/**\n * Drops the site's component overrides. With nothing stored the site renders\n * the brand's own component styles, which is what the editor's \"Reset to\n * theme defaults\" means.\n */\nexport function resetComponentOverrides(theme: HostTheme): HostTheme {\n const next = { ...theme }\n delete next.components\n return next\n}\n\n/** One leaf of a component override, as a writer names it. */\nexport interface ThemeComponentOverrideLeaf {\n component: HostThemeComponentKey\n /**\n * `styleOverrides` styles a slot in literal CSS; `sx` styles it in theme\n * terms, so a value may name a palette path (`primary.main`) or a spacing\n * unit (AGL-3403); `defaultProps` sets a prop's default.\n */\n target: 'styleOverrides' | 'sx' | 'defaultProps'\n /** The style slot (`root`, `contained`, `h1`); `null` for a default prop. */\n slot: string | null\n /** A camelCase CSS property, or the prop's name. */\n property: string\n /** Scopes a style to one side of the toolbar breakpoint; `null` for every width. */\n media: ThemeEditorMedia | null\n value: string | number | boolean\n}\n\n/**\n * Sets one leaf inside the site's component overrides and keeps every other\n * override the site has. The stored overrides are deep-merged over the\n * brand's own at render time, so naming one property changes that property\n * and inherits the rest of the component.\n */\nexport function writeComponentOverride(\n theme: HostTheme,\n leaf: ThemeComponentOverrideLeaf,\n): HostTheme {\n const components = { ...theme.components }\n const entry: HostThemeComponentOverride = { ...components[leaf.component] }\n if (leaf.target === 'defaultProps') {\n entry.defaultProps = { ...entry.defaultProps, [leaf.property]: leaf.value }\n } else {\n const slot = leaf.slot ?? 'root'\n const styles: Record<string, unknown> = {\n ...(leaf.target === 'sx' ? entry.sx : entry.styleOverrides),\n }\n const slotStyles = { ...(styles[slot] as Record<string, unknown> | undefined) }\n if (leaf.media) {\n const query = THEME_EDITOR_MEDIA_QUERIES[leaf.media]\n slotStyles[query] = {\n ...(slotStyles[query] as Record<string, unknown> | undefined),\n [leaf.property]: leaf.value,\n }\n } else {\n slotStyles[leaf.property] = leaf.value\n }\n styles[slot] = slotStyles\n if (leaf.target === 'sx') {\n entry.sx = styles as HostThemeComponentOverride['sx']\n } else {\n entry.styleOverrides = styles\n }\n }\n components[leaf.component] = entry\n return { ...theme, components }\n}\n"],"names":["HOST_THEME_COMPONENT_WHITELIST","TOOLBAR_SM_MIN_WIDTH","TOOLBAR_SM_QUERY","DEFAULT_TOOLBAR_XS","DEFAULT_TOOLBAR_SM","TOOLBAR_LANDSCAPE_QUERY","TOOLBAR_LANDSCAPE_RULE","minHeight","readToolbarHeight","theme","breakpoint","toolbar","mixins","undefined","raw","value","parseFloat","String","Number","isFinite","buildToolbarMixin","xs","sm","orderSensitiveKey","JSON","stringify","PALETTE_COLOR_FIELDS","key","label","SURFACE_COLOR_FIELDS","path","TINT_COLOR_FIELDS","DIVIDER_COLOR_FIELD","GOOGLE_FONT_OPTIONS","family","category","weights","fontFamilyStack","fallback","getSchemeColor","colors","group","THEME_EDITOR_SCHEMES","THEME_COLOR_FIELDS","map","token","join","DARK_SCHEME_FIELD","options","SYSTEM_FONT_VALUE","FONT_FAMILY_FIELD","BORDER_RADIUS_FIELD","min","max","step","SPACING_FIELD","TOOLBAR_HEIGHT_FIELDS","COMPONENT_OVERRIDES_FIELD","components","THEME_EDITOR_MEDIA_QUERIES","mobile","desktop","THEME_EDITOR_CONTROLS","id","kind","perScheme","option","themeEditorControl","control","find","entry","Error","setSchemeValue","scheme","update","colorSchemes","readThemeColor","divider","split","main","writeThemeColor","hex","next","paletteKey","groupKey","groupValue","grouped","Object","keys","length","copyThemeSchemeColors","from","to","source","parse","readDarkScheme","darkScheme","writeDarkScheme","readFontFamily","readThemeFonts","body","writeFontFamily","current","writeThemeFonts","heading","THEME_HEADING_VARIANTS","firstStackFamily","stack","first","trim","replace","stackCategory","test","sortedWeights","values","Set","Math","round","filter","sort","a","b","choiceOf","font","italics","findFont","wanted","toLowerCase","fonts","typography","fontFamily","bodyFont","headingStack","variants","h1","headingFont","fontEntry","choice","selection","previous","previousHeadingStack","chosen","chosenKeys","otherStyles","entries","includes","variant","kept","has","writeBorderRadius","shape","borderRadius","writeSpacing","spacing","writeToolbarHeight","valid","edited","resetComponentOverrides","writeComponentOverride","leaf","component","target","defaultProps","property","slot","styles","sx","styleOverrides","slotStyles","media","query"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC;AAWD,SACEA,8BAA8B,QAEzB,kBAAc;AAErB;;;;;;;;;;;;;;;;;;;;CAoBC,GAED;;;;CAIC,GACD,OAAO,MAAMC,uBAAuB,IAAG;AACvC,OAAO,MAAMC,mBAAmB,CAAC,kBAAkB,EAAED,qBAAqB,GAAG,CAAC,CAAA;AAC9E,mEAAmE,GACnE,OAAO,MAAME,qBAAqB,GAAE;AACpC,OAAO,MAAMC,qBAAqB,GAAE;AACpC;;;;CAIC,GACD,OAAO,MAAMC,0BAA0B,yBAAwB;AAC/D,OAAO,MAAMC,yBAAyB;IACpC,mCAAmC;QAAEC,WAAW;IAAG;AACrD,EAAC;AAED,uEAAuE,GACvE,OAAO,SAASC,kBAAkBC,KAAgB,EAAEC,UAAuB;QACzDD,eAKTE;IALP,MAAMA,WAAUF,gBAAAA,MAAMG,MAAM,qBAAZH,cAAcE,OAAO;IACrC,IAAI,CAACA,SAAS,OAAOE;IACrB,MAAMC,MACJJ,eAAe,OACXC,QAAQJ,SAAS,IAChBI,4BAAAA,OAAO,CAACT,iBAAiB,qBAA1B,AAACS,0BACGJ,SAAS;IACnB,MAAMQ,QAAQC,WAAWC,OAAOH,cAAAA,M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