@atomic-ui/design-tokens 0.1.7 → 0.2.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/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/inputs.ts","../src/fonts.ts","../src/contrast.ts","../src/derive.ts","../src/variables.ts","../src/validate.ts","../src/dtcg.ts"],"sourcesContent":["/**\n * Brand inputs — everything a partner may set, and nothing else.\n *\n * The list is closed, and it is short on purpose. Stripe's Appearance API gets\n * almost all of its brand expression from eight variables and derives the rest;\n * Cloudscape allows typography, colour and border radius and refuses the\n * question beyond that; the legacy Sanity CMS this replaces allowed everything\n * and accumulated forty per-viewport override fields nobody could prune. The\n * reasoning, with sources, is\n * [ADR 0010](../../../docs/decisions/0010-what-a-brand-may-set.md).\n *\n * Two absences are the point of the whole file. There is no foreground colour\n * anywhere — text on a surface is computed, so a partner cannot pin white text\n * onto a mid-tone brand colour. And there is no focus colour — the ring keeps\n * system values, because a focus indicator drawn in a partner's own brand\n * colour on that partner's own background is where focus visibility dies.\n */\nimport { z } from 'zod';\n\n/** A hex colour. The only colour form the inputs accept. */\nexport const HexColorSchema = z\n .string()\n .regex(/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/, 'Must be a hex colour, e.g. #5e10b1');\n\n/**\n * The page background, which may be a gradient.\n *\n * It is the one exception and it is safe by construction rather than by\n * exception: the page background never carries text directly — text sits on a\n * card — so it is the only surface with nothing to contrast against. Northwind\n * Plus's shell is a three-stop gradient, which is a real requirement and\n * would otherwise need an escape hatch.\n */\nexport const SurfaceValueSchema = z.union([\n HexColorSchema,\n z.string().regex(/^(linear|radial|conic)-gradient\\(.+\\)$/, 'Must be a hex colour or a CSS gradient'),\n]);\n\nexport const WebFontSchema = z.object({\n family: z.string(),\n url: z.string(),\n weight: z.string().optional(),\n style: z.string().optional(),\n display: z.string().optional(),\n});\nexport type WebFont = z.infer<typeof WebFontSchema>;\n\n/**\n * The type ramp ratio.\n *\n * Bounded rather than free. Below 1.067 the ramp stops distinguishing levels\n * and heading structure becomes invisible to a sighted reader even though the\n * markup is correct; above 1.333 the top of the scale overflows a 360px\n * viewport at 200% zoom, which fails 1.4.4. A partner who wants bigger headings\n * raises the base size.\n */\nexport const TypeScaleSchema = z.number().min(1.067).max(1.333);\n\n/**\n * A step on the spacing scale, as the `space.*` tokens name them: `4` is four\n * spacing units, `6` is eight, `8` is sixteen. Layout names a step rather\n * than a size, so it follows the brand's spacing unit.\n */\nexport const SPACE_STEP_NAMES = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10'] as const;\nexport const SpaceStepSchema = z.enum(SPACE_STEP_NAMES);\nexport type SpaceStep = z.infer<typeof SpaceStepSchema>;\n\n/**\n * Each group is `.strict()`.\n *\n * Zod strips unknown keys by default, so `color.onBrand` would validate, be\n * dropped, and leave an editor looking at a brand that ignores a value they\n * set. Rejecting it says what is actually true: there is nowhere to put a\n * foreground colour, because foregrounds are measured.\n */\nexport const BrandInputsSchema = z.object({\n color: z.strictObject({\n /** The partner's primary colour: actions, emphasis, selected states. */\n brand: HexColorSchema,\n /** The secondary colour. Defaults to the brand colour when unset. */\n accent: HexColorSchema.optional(),\n\n /** The page behind everything. May be a gradient; carries no text. */\n surfacePage: SurfaceValueSchema,\n /** Where content actually sits, and what text is read against. */\n surfaceCard: HexColorSchema,\n /** The header band. */\n surfaceHeader: HexColorSchema,\n /** The footer band. */\n surfaceFooter: HexColorSchema,\n\n /** Default body text, on `surfaceCard`. */\n text: HexColorSchema,\n\n danger: HexColorSchema,\n warning: HexColorSchema,\n success: HexColorSchema,\n info: HexColorSchema,\n }),\n\n font: z.strictObject({\n body: z.string(),\n /** Defaults to `body` when unset — most brands have one typeface. */\n heading: z.string().optional(),\n /** Root size in px. Everything else is `rem`, scaled from this. */\n sizeBase: z.number().min(14).max(20).default(16),\n scale: TypeScaleSchema.default(1.2),\n /** Faces the shell must load. A partner brings its own typeface. */\n webFonts: z.array(WebFontSchema).default([]),\n }),\n\n shape: z.strictObject({\n /** Corner rounding in px. Every radius derives from it. */\n radiusBase: z.number().min(0).max(24).default(4),\n /** The spacing unit in px. All spacing is a multiple. */\n spaceBase: z.number().min(2).max(8).default(4),\n /** Default border weight in px. */\n borderWidth: z.number().min(1).max(3).default(1),\n }),\n\n /**\n * The page's frame and the spacing between columns.\n *\n * Margins and gutters name steps on the spacing scale rather than pixels,\n * so they move with `shape.spaceBase` and stay on the same rhythm as\n * everything else. The page width is bounded: below 640px a desktop page\n * reads as a phone page, and above 1600px a line of text outgrows what can\n * be read comfortably. Every value defaults to what pages had before this\n * group existed, so a brand that sets none of it looks the same.\n */\n layout: z.strictObject({\n /** The widest the content gets on a large screen, in px, inside the margins. */\n pageWidth: z.number().min(640).max(1600).default(1200),\n /** Space between the screen's edge and the content, at each size. */\n margin: z.strictObject({\n phone: SpaceStepSchema.default('4'),\n tablet: SpaceStepSchema.default('6'),\n desktop: SpaceStepSchema.default('8'),\n }).default({}),\n /** The three gutters a grid may choose between columns. */\n gutter: z.strictObject({\n sm: SpaceStepSchema.default('2'),\n md: SpaceStepSchema.default('4'),\n lg: SpaceStepSchema.default('6'),\n }).default({}),\n }).default({}),\n\n assets: z.strictObject({\n logo: z.string(),\n logoAlt: z.string(),\n /** For use on dark surfaces, where the main logo would disappear. */\n logoDark: z.string().optional(),\n favicon: z.string().optional(),\n }),\n});\n\nexport type BrandInputs = z.infer<typeof BrandInputsSchema>;\n\n/**\n * The house defaults — a complete, neutral, AA-passing brand.\n *\n * Every input is optional at the edges of the system because this exists: a\n * site with no brand document still renders something legible rather than\n * unstyled, which is what makes a missing brand a visible problem instead of a\n * broken page.\n */\nexport const DEFAULT_BRAND_INPUTS: BrandInputs = BrandInputsSchema.parse({\n color: {\n brand: '#1f4ed8',\n surfacePage: '#f4f5f7',\n surfaceCard: '#ffffff',\n surfaceHeader: '#ffffff',\n surfaceFooter: '#1f2430',\n text: '#1a1a1a',\n danger: '#c8102e',\n warning: '#b45309',\n success: '#047857',\n info: '#1f4ed8',\n },\n font: { body: 'system-ui, -apple-system, \"Segoe UI\", Roboto, sans-serif' },\n shape: {},\n assets: { logo: '', logoAlt: '' },\n});\n","/**\n * Fonts a brand names, and whether anything will actually draw them.\n *\n * A brand names its typefaces by family (\"GT Walsheim Pro\"). A browser draws a\n * family only if the device has it or the page loads it with `@font-face`, and\n * when it can do neither it falls back to its default, which is Times. So every\n * family a brand names is followed by a fallback stack, and a family is only\n * called loaded when the brand carries a file for it.\n */\nimport type { WebFont } from './inputs';\n\n/** What a browser draws when a sans-serif family is missing: the device's own interface font. */\nexport const SYSTEM_SANS = 'system-ui, -apple-system, \"Segoe UI\", Roboto, \"Helvetica Neue\", Arial, sans-serif';\n/** The serif equivalent, for a brand whose type is a serif. */\nexport const SYSTEM_SERIF = 'Georgia, Cambria, \"Times New Roman\", serif';\n\nconst GENERIC = new Set(['serif', 'sans-serif', 'monospace', 'cursive', 'fantasy', 'system-ui', 'ui-sans-serif', 'ui-serif', 'ui-monospace', 'ui-rounded', 'math', 'emoji']);\n/** Families every device has, or that name the device's own font, so nothing needs loading. */\nconst ON_EVERY_DEVICE = new Set([...GENERIC, '-apple-system', 'blinkmacsystemfont', 'segoe ui', 'helvetica', 'helvetica neue', 'arial', 'georgia', 'times new roman', 'cambria', 'courier new', 'verdana', 'tahoma', 'trebuchet ms']);\n\n/** The weights Strata's components use: body, medium labels, semibold and bold headings. */\nexport const FONT_WEIGHTS = ['400', '500', '600', '700'] as const;\n\nconst unquote = (s: string) => s.trim().replace(/^['\"]|['\"]$/g, '').trim();\nconst quote = (s: string) => (GENERIC.has(s.toLowerCase()) || s.startsWith('-') || /^[a-z0-9-]+$/i.test(s) ? s : JSON.stringify(s));\n\n/** The families in a `font-family` value, unquoted, in order. */\nexport function fontFamilies(value: string | undefined): string[] {\n return (value ?? '').split(',').map(unquote).filter(Boolean);\n}\n\n/** The family a brand means: the first one named. */\nexport function primaryFamily(value: string | undefined): string {\n return fontFamilies(value)[0] ?? '';\n}\n\n/**\n * A `font-family` value that never ends in the browser's default. The families\n * the brand names come first, exactly as named; a generic fallback is added\n * when none is there.\n */\nexport function fontStack(value: string | undefined, fallback: 'sans' | 'serif' = 'sans'): string {\n const named = fontFamilies(value);\n if (named.some((f) => GENERIC.has(f.toLowerCase()))) return named.map(quote).join(', ');\n const stack = fontFamilies(fallback === 'serif' ? SYSTEM_SERIF : SYSTEM_SANS);\n const seen = new Set(named.map((f) => f.toLowerCase()));\n return [...named, ...stack.filter((f) => !seen.has(f.toLowerCase()))].map(quote).join(', ');\n}\n\nexport type FontStatus =\n | { kind: 'system'; family: string }\n | { kind: 'loaded'; family: string; weights: string[]; missingWeights: string[] }\n | { kind: 'missing'; family: string };\n\n/** Whether pages will draw the family a brand names, and which weights it has files for. */\nexport function fontStatus(value: string | undefined, webFonts: readonly WebFont[] = []): FontStatus {\n const family = primaryFamily(value);\n if (!family || ON_EVERY_DEVICE.has(family.toLowerCase())) return { kind: 'system', family: family || 'system-ui' };\n // A face found on a partner's site is recorded without a file until someone with the right to upload it does.\n const faces = webFonts.filter((f) => f.url && f.family.toLowerCase() === family.toLowerCase() && (f.style ?? 'normal') === 'normal');\n if (!faces.length) return { kind: 'missing', family };\n // A face with no weight, or a range such as \"100 900\", is a variable font and covers them all.\n const covers = (w: string) => faces.some((f) => !f.weight || f.weight === w || (/^\\d+ \\d+$/.test(f.weight) && Number(f.weight.split(' ')[0]) <= Number(w) && Number(w) <= Number(f.weight.split(' ')[1])));\n const weights = FONT_WEIGHTS.filter(covers);\n return { kind: 'loaded', family, weights, missingWeights: FONT_WEIGHTS.filter((w) => !covers(w)) };\n}\n\nexport interface OpenFont { family: string; category: 'sans' | 'serif' }\n\n/**\n * Open-licence families Strata fetches and stores itself, so a customer's\n * browser loads them from Strata and never calls a third party.\n */\nexport const OPEN_FONTS: readonly OpenFont[] = [\n { family: 'Inter', category: 'sans' },\n { family: 'Roboto', category: 'sans' },\n { family: 'Open Sans', category: 'sans' },\n { family: 'Lato', category: 'sans' },\n { family: 'Montserrat', category: 'sans' },\n { family: 'Poppins', category: 'sans' },\n { family: 'Nunito Sans', category: 'sans' },\n { family: 'Source Sans 3', category: 'sans' },\n { family: 'Work Sans', category: 'sans' },\n { family: 'DM Sans', category: 'sans' },\n { family: 'IBM Plex Sans', category: 'sans' },\n { family: 'Manrope', category: 'sans' },\n { family: 'Plus Jakarta Sans', category: 'sans' },\n { family: 'Figtree', category: 'sans' },\n { family: 'Raleway', category: 'sans' },\n { family: 'Merriweather', category: 'serif' },\n { family: 'Lora', category: 'serif' },\n { family: 'Playfair Display', category: 'serif' },\n { family: 'Source Serif 4', category: 'serif' },\n { family: 'IBM Plex Serif', category: 'serif' },\n];\n\n/** The open font of that name, if Strata can fetch it. */\nexport const openFont = (family: string): OpenFont | undefined => OPEN_FONTS.find((f) => f.family.toLowerCase() === family.trim().toLowerCase());\n","/**\n * Contrast maths, to WCAG 2.x.\n *\n * This file exists because of one decision: a partner never authors a text\n * colour to sit on a background ([ADR 0010](../../../docs/decisions/0010-what-a-brand-may-set.md)).\n * They pick a brand colour and the system picks what reads on top of it. That\n * makes the most common white-label accessibility failure — a mid-tone brand\n * colour under a white label — unrepresentable rather than merely discouraged.\n *\n * The formulae are from WCAG 2.2 (relative luminance, and the (L1+0.05)/(L2+0.05)\n * contrast ratio). They are stable, cheap and exactly what an auditor will use.\n * APCA is better maths and is not normative yet; when it is, this is the one\n * file that changes.\n */\n\n/** A colour this module can reason about: #rgb, #rrggbb, or #rrggbbaa. */\nexport type Hex = string;\n\nexport interface Rgb {\n r: number;\n g: number;\n b: number;\n}\n\nconst HEX = /^#?([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i;\n\n/**\n * Parse a hex colour. Returns null rather than throwing: callers are usually\n * validating authored content, where \"this is not a colour\" is a message to an\n * editor and not an exception.\n */\nexport function parseHex(value: string): Rgb | null {\n const m = HEX.exec(value.trim());\n if (!m) return null;\n let h = m[1];\n if (h.length === 3) h = h.split('').map((c) => c + c).join('');\n return {\n r: parseInt(h.slice(0, 2), 16),\n g: parseInt(h.slice(2, 4), 16),\n b: parseInt(h.slice(4, 6), 16),\n };\n}\n\nexport function toHex({ r, g, b }: Rgb): Hex {\n const c = (n: number) => Math.round(Math.min(255, Math.max(0, n))).toString(16).padStart(2, '0');\n return `#${c(r)}${c(g)}${c(b)}`;\n}\n\n/** WCAG relative luminance. */\nexport function luminance(rgb: Rgb): number {\n const channel = (v: number) => {\n const s = v / 255;\n return s <= 0.03928 ? s / 12.92 : ((s + 0.055) / 1.055) ** 2.4;\n };\n return 0.2126 * channel(rgb.r) + 0.7152 * channel(rgb.g) + 0.0722 * channel(rgb.b);\n}\n\n/** WCAG contrast ratio, 1–21. Returns 0 for anything unparseable. */\nexport function contrastRatio(a: string, b: string): number {\n const ra = parseHex(a);\n const rb = parseHex(b);\n if (!ra || !rb) return 0;\n const la = luminance(ra);\n const lb = luminance(rb);\n const [hi, lo] = la > lb ? [la, lb] : [lb, la];\n return (hi + 0.05) / (lo + 0.05);\n}\n\n/** The thresholds, named, so call sites read as the criterion they enforce. */\nexport const AA_TEXT = 4.5;\nexport const AA_LARGE_TEXT = 3;\n/** 1.4.11 Non-text Contrast: UI components and meaningful graphics. */\nexport const AA_NON_TEXT = 3;\n\n/**\n * The two foregrounds anything may be drawn in.\n *\n * Not pure black and white. Pure black on a light surface is harsher than it\n * needs to be and pure white on a saturated brand colour haloes; these are the\n * near-neutrals most systems settle on, and they still clear 4.5:1 against\n * every surface the inputs can produce — which the tests assert rather than\n * assume.\n */\nexport const FOREGROUND_DARK = '#1a1a1a';\nexport const FOREGROUND_LIGHT = '#ffffff';\n\n/**\n * Pick the foreground that reads best on `background`.\n *\n * Deliberately returns the BETTER of the two rather than the first that passes.\n * On a mid-tone brand colour both may clear 4.5:1 and the winner is still\n * visibly easier to read; on a colour where neither passes, the better one is\n * what gets rendered while the publish check reports the failure. A caller that\n * needs to know whether it passed asks `contrastRatio` — this function always\n * answers.\n */\nexport function pickForeground(background: string): Hex {\n const dark = contrastRatio(background, FOREGROUND_DARK);\n const light = contrastRatio(background, FOREGROUND_LIGHT);\n return dark >= light ? FOREGROUND_DARK : FOREGROUND_LIGHT;\n}\n\n/**\n * Shift a colour toward black or white by `amount` (0–1).\n *\n * This is how every hover, active and subtle state is derived. Mixing in sRGB\n * is not perceptually uniform and a perceptual space would give more even\n * steps; sRGB is used because it is what CSS `color-mix` does, so a value\n * derived here and a value a stylesheet computes agree. Matching the platform\n * matters more here than being slightly more correct than it.\n */\nexport function shade(color: string, amount: number): Hex {\n const rgb = parseHex(color);\n if (!rgb) return color;\n const t = amount < 0 ? 255 : 0;\n const k = Math.abs(amount);\n return toHex({\n r: rgb.r + (t - rgb.r) * k,\n g: rgb.g + (t - rgb.g) * k,\n b: rgb.b + (t - rgb.b) * k,\n });\n}\n\n/** Darken toward black. */\nexport const darken = (color: string, amount: number): Hex => shade(color, amount);\n/** Lighten toward white. */\nexport const lighten = (color: string, amount: number): Hex => shade(color, -amount);\n\n/**\n * A very light tint of a colour, for subtle backgrounds — an info panel, a\n * selected row. Always light enough to take the dark foreground, which is what\n * makes \"subtle\" a safe surface rather than a guess.\n */\nexport const tint = (color: string): Hex => lighten(color, 0.88);\n\n/** Blend two colours. `amount` is how far from `a` toward `b`. */\nexport function mix(a: string, b: string, amount: number): Hex {\n const ra = parseHex(a);\n const rb = parseHex(b);\n if (!ra || !rb) return a;\n const k = Math.min(1, Math.max(0, amount));\n return toHex({\n r: ra.r + (rb.r - ra.r) * k,\n g: ra.g + (rb.g - ra.g) * k,\n b: ra.b + (rb.b - ra.b) * k,\n });\n}\n\n/**\n * Walk a foreground away from its background until it clears `target`.\n *\n * This is the mechanism that makes a derived token safe rather than merely\n * plausible. Muted text, placeholder text and borders are all produced by\n * blending toward a surface, and a blend that looks right on one brand falls\n * under 4.5:1 on the next. Rather than pick a blend that happens to work for\n * the brands we have, each derived value is pushed back until it passes.\n *\n * It moves toward whichever end of the scale is already further from the\n * background, in small steps, and gives up after it runs out of room — at\n * which point the colour is returned as-is and the publish check reports it.\n * Silently returning black would hide a brand that cannot work.\n */\nexport function ensureContrast(foreground: string, background: string, target: number): Hex {\n const fg = parseHex(foreground);\n const bg = parseHex(background);\n if (!fg || !bg) return foreground;\n if (contrastRatio(foreground, background) >= target) return toHex(fg);\n\n const toward = luminance(bg) > 0.5 ? FOREGROUND_DARK : FOREGROUND_LIGHT;\n let current = toHex(fg);\n for (let step = 1; step <= 20; step += 1) {\n current = mix(toHex(fg), toward, step / 20);\n if (contrastRatio(current, background) >= target) return current;\n }\n return current;\n}\n","/**\n * Brand inputs → the semantic tokens components actually read.\n *\n * This is the whole argument of\n * [ADR 0010](../../../docs/decisions/0010-what-a-brand-may-set.md) in executable\n * form: around twenty authored values go in, roughly a hundred come out, and\n * the hundred are not authorable. A partner who wants a different hover colour\n * is describing a change to this function, which is a product decision with a\n * version number, rather than a field in a CMS nobody can later prune.\n *\n * Three rules run through it. Foregrounds are always picked by measured\n * contrast, never authored. Anything that carries text is ratcheted until it\n * passes AA rather than trusted to. And the focus ring and the minimum target\n * size are constants, because they are the two things a brand would break first\n * and notice last.\n */\nimport { fontStack, openFont, primaryFamily } from './fonts';\nimport {\n AA_NON_TEXT,\n AA_TEXT,\n darken,\n ensureContrast,\n luminance,\n mix,\n parseHex,\n pickForeground,\n tint,\n} from './contrast';\nimport { BrandInputsSchema, type BrandInputs } from './inputs';\n\n/** A flat token set: dotted path → CSS value. */\nexport type TokenSet = Record<string, string>;\n\n/**\n * The locked tokens. A brand cannot reach these and nothing derives them.\n *\n * The focus ring is two-tone — a light inner ring inside a dark outer one — so\n * that it stays visible on any surface a partner can produce, including their\n * own brand colour. A single-colour ring has to assume a background, and the\n * one it assumes is the one a white-label product does not have. This is the\n * rule Scotland's design system states directly: adopters may change the\n * colours, and must still keep the system's colours for focus.\n *\n * `target.min` is WCAG 2.2's 2.5.8 minimum. It is here rather than in the\n * spacing scale so that shrinking the spacing unit cannot shrink a tap target.\n */\nexport const LOCKED_TOKENS: TokenSet = {\n 'focus.ring.inner': '#ffffff',\n 'focus.ring.outer': '#1a1a1a',\n 'focus.ring.width': '2px',\n 'focus.ring.offset': '2px',\n 'focus.ring.shadow': '0 0 0 2px #ffffff, 0 0 0 4px #1a1a1a',\n 'target.min': '24px',\n 'target.spacing': '8px',\n};\n\n/** Spacing steps, as multiples of the base unit. */\n/**\n * The spacing scale: each step is that many quarters of the brand's base unit,\n * so with a 4px base `space.4` is 16px and `space.12` is 48px. Every step is a\n * whole multiple, which is what keeps a page on its grid: two things that are\n * `space.6` apart line up with anything else that is.\n */\nexport const SPACE_SCALE = [0, 0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 16, 20, 24, 28, 32, 36, 40, 48, 56, 64, 72, 80, 96] as const;\n\n/** A step's token name: `0.5` is `space.0-5`, since a dot separates the path. */\nexport const spaceName = (step: number) => `space.${String(step).replace('.', '-')}`;\n\n/**\n * The steps a brand's layout names its margins and gutters by, as they were\n * before the scale above. Kept so a stored brand's page frame does not move.\n */\nconst LAYOUT_STEPS: Record<string, number> = {\n '0': 0, '1': 1, '2': 2, '3': 3, '4': 4,\n '5': 6, '6': 8, '7': 12, '8': 16, '9': 24, '10': 32,\n};\n\n/** Type ramp, as powers of the scale ratio either side of the base. */\n/**\n * The type scale against a 16px base, with the line height each size reads\n * best at: tight for display sizes, open for small print. `2xs` is kept for\n * stored work and is the same as `xs`.\n */\nconst TYPE_SCALE: Record<string, { size: number; leading: number }> = {\n '2xs': { size: 12, leading: 16 },\n xs: { size: 12, leading: 16 },\n sm: { size: 14, leading: 20 },\n md: { size: 16, leading: 24 },\n lg: { size: 18, leading: 28 },\n xl: { size: 20, leading: 28 },\n '2xl': { size: 24, leading: 32 },\n '3xl': { size: 30, leading: 36 },\n '4xl': { size: 36, leading: 40 },\n '5xl': { size: 48, leading: 52 },\n '6xl': { size: 60, leading: 64 },\n};\n\n/** Sizes from here up are display type: drawn a little tighter, and stretched by the brand's ratio. */\nconst DISPLAY_FROM = 24;\n\n/**\n * The smallest text the ramp may produce, in px.\n *\n * A 1.333 ratio three steps below a 14px base lands at 5.9px. Clamping here\n * rather than narrowing the ratio keeps the top of the ramp expressive while\n * stopping the bottom from becoming unreadable.\n */\nconst MIN_FONT_PX = 12;\n\n/**\n * The text colour for a branded band — the header, the footer.\n *\n * Not simply the picked foreground, because that throws away real brand\n * expression: Northwind's header is white with dark-purple text, and deriving\n * near-black there would be legible and wrong. On a LIGHT band the accent\n * colour is used, ratcheted until it passes, which is what partners actually\n * do and what every migrated theme authored. On a DARK band the picked\n * foreground wins, because coloured text on a saturated brand background is\n * exactly where legibility goes, and a washed-out tint of the band's own\n * colour is worse than white.\n *\n * An unparseable surface — a gradient — is treated as dark, since a gradient\n * is only allowed on the page and the page is the one band nothing sits on.\n */\nfunction onSurface(surface: string, accent: string): string {\n const rgb = parseHex(surface);\n if (!rgb) return pickForeground('#000000');\n return luminance(rgb) > 0.5 ? ensureContrast(accent, surface, AA_TEXT) : pickForeground(surface);\n}\n\nfunction typeRamp(sizeBase: number, scale: number): TokenSet {\n const out: TokenSet = {};\n // The brand's ratio stretches display type away from the base: 1.25 is the\n // scale as written, a larger ratio makes headings bigger, a smaller one quieter.\n const stretch = Math.max(0.8, Math.min(1.4, scale / 1.25));\n for (const [name, { size, leading }] of Object.entries(TYPE_SCALE)) {\n // Display sizes move with the ratio, more the larger they are; body sizes never do.\n const display = size >= DISPLAY_FROM ? 1 + (stretch - 1) * Math.min(1, (size - 16) / 44) : 1;\n const px = Math.max(MIN_FONT_PX, (size / 16) * sizeBase * display);\n // Round UP at four places. Rounding to nearest loses the 12px floor by a\n // ten-thousandth, which is invisible until a test asserts the floor and\n // fails — and the floor is the accessibility claim, so it rounds its way.\n const rem = Math.ceil((px / sizeBase) * 10000) / 10000;\n out[`font.size.${name}`] = `${rem}rem`;\n out[`font.leading.${name}`] = String(Math.round((leading / size) * 1000) / 1000);\n }\n out['font.tracking.tight'] = '-0.02em';\n out['font.tracking.normal'] = '0em';\n out['font.tracking.wide'] = '0.06em';\n return out;\n}\n\nexport function deriveTokens(input: BrandInputs): TokenSet {\n const { color, font, shape } = input;\n // A brand stored before layout existed has none, and gets the frame pages had then.\n const layout = input.layout ?? BrandInputsSchema.shape.layout.parse(undefined);\n const card = color.surfaceCard;\n const accent = color.accent ?? color.brand;\n\n const tokens: TokenSet = { ...LOCKED_TOKENS };\n\n // --- surfaces ------------------------------------------------------------\n // `page` is the only one that may be a gradient, and the only one nothing is\n // read against. `inset` is for wells and disabled fields: a step away from\n // the card in whichever direction the card is not.\n tokens['color.surface.page'] = color.surfacePage;\n tokens['color.surface.card'] = card;\n tokens['color.surface.header'] = color.surfaceHeader;\n tokens['color.surface.footer'] = color.surfaceFooter;\n tokens['color.surface.subtle'] = tint(color.brand);\n tokens['color.surface.inset'] = mix(card, pickForeground(card), 0.05);\n\n // --- brand ---------------------------------------------------------------\n // Hover and active are tone shifts rather than authored colours. The\n // direction is fixed: darker on interaction, because a lighter hover on a\n // light surface reads as disabled.\n tokens['color.brand.default'] = color.brand;\n tokens['color.brand.hover'] = darken(color.brand, 0.12);\n tokens['color.brand.active'] = darken(color.brand, 0.24);\n tokens['color.brand.subtle'] = tint(color.brand);\n tokens['color.brand.on'] = pickForeground(color.brand);\n\n tokens['color.accent.default'] = accent;\n tokens['color.accent.hover'] = darken(accent, 0.12);\n tokens['color.accent.on'] = pickForeground(accent);\n\n // --- text ----------------------------------------------------------------\n // Muted and placeholder are blends toward the surface, then ratcheted back\n // until they clear AA. Placeholder is included deliberately: it is routinely\n // treated as exempt and 1.4.3 does not exempt it.\n tokens['color.text.default'] = ensureContrast(color.text, card, AA_TEXT);\n tokens['color.text.muted'] = ensureContrast(mix(color.text, card, 0.38), card, AA_TEXT);\n tokens['color.text.placeholder'] = ensureContrast(mix(color.text, card, 0.5), card, AA_TEXT);\n tokens['color.text.on-brand'] = pickForeground(color.brand);\n tokens['color.text.on-header'] = onSurface(color.surfaceHeader, accent);\n tokens['color.text.on-footer'] = onSurface(color.surfaceFooter, accent);\n // A link is the brand colour where that is readable, and a darkened brand\n // colour where it is not — so a partner with a pale brand still gets links\n // that look like theirs.\n // Headings take the accent colour. The legacy schema had an authored\n // `typography.headingColor`, and on every migrated theme it was the secondary\n // colour — so deriving it reproduces them exactly and removes a field whose\n // only job was to restate another one.\n tokens['color.text.heading'] = ensureContrast(accent, card, AA_TEXT);\n tokens['color.text.link'] = ensureContrast(color.brand, card, AA_TEXT);\n tokens['color.text.link-hover'] = darken(tokens['color.text.link'], 0.2);\n\n // --- borders -------------------------------------------------------------\n // 1.4.11 governs these: a field border is a UI component boundary, so 3:1,\n // not 4.5:1.\n tokens['color.border.default'] = ensureContrast(mix(color.text, card, 0.7), card, AA_NON_TEXT);\n tokens['color.border.strong'] = ensureContrast(mix(color.text, card, 0.45), card, AA_NON_TEXT);\n\n // --- status --------------------------------------------------------------\n // Each gets three: the colour itself at UI contrast, a tint to sit behind it,\n // and the foreground that reads on it. `*.text` is separate from `*.default`\n // because the same red that is fine as a 3:1 border is not fine as 4.5:1 body\n // text, and conflating them is how error messages end up unreadable.\n for (const name of ['danger', 'warning', 'success', 'info'] as const) {\n const base = color[name];\n tokens[`color.status.${name}.default`] = ensureContrast(base, card, AA_NON_TEXT);\n tokens[`color.status.${name}.text`] = ensureContrast(base, card, AA_TEXT);\n tokens[`color.status.${name}.subtle`] = tint(base);\n tokens[`color.status.${name}.on`] = pickForeground(base);\n }\n\n // --- typography ----------------------------------------------------------\n // A family the device lacks and the brand does not load would fall back to Times, so each is followed by a stack.\n const fallbackFor = (value: string) => (openFont(primaryFamily(value))?.category === 'serif' ? 'serif' : 'sans');\n tokens['font.family.body'] = fontStack(font.body, fallbackFor(font.body));\n tokens['font.family.heading'] = fontStack(font.heading ?? font.body, fallbackFor(font.heading ?? font.body));\n tokens['font.size.root'] = `${font.sizeBase}px`;\n Object.assign(tokens, typeRamp(font.sizeBase, font.scale));\n tokens['font.weight.regular'] = '400';\n tokens['font.weight.medium'] = '500';\n tokens['font.weight.semibold'] = '600';\n tokens['font.weight.bold'] = '700';\n // 1.4.8 asks for 1.5 within a paragraph; `tight` is for headings, where it\n // does not apply.\n tokens['font.line-height.tight'] = '1.25';\n tokens['font.line-height.normal'] = '1.5';\n tokens['font.line-height.relaxed'] = '1.75';\n\n // --- space, radius, border width -----------------------------------------\n for (const step of SPACE_SCALE) tokens[spaceName(step)] = `${shape.spaceBase * step}px`;\n // Radii in steps from the brand's base, which is the medium one: a sharp\n // brand keeps everything square, a soft one rounds everything together.\n const r = (multiple: number) => `${Math.round(shape.radiusBase * multiple * 10) / 10}px`;\n tokens['radius.none'] = '0';\n tokens['radius.xs'] = r(1 / 3);\n tokens['radius.sm'] = r(2 / 3);\n tokens['radius.md'] = r(1);\n tokens['radius.lg'] = r(4 / 3);\n tokens['radius.xl'] = r(2);\n tokens['radius.2xl'] = r(8 / 3);\n tokens['radius.3xl'] = r(4);\n tokens['radius.full'] = '9999px';\n // Shadows, from a hairline to a lifted dialog. Tinted with the text colour so\n // they sit on a warm or cool page rather than looking pasted on.\n const ink = parseHex(color.text) ? color.text : '#000000';\n const a = (alpha: number) => `color-mix(in srgb, ${ink} ${Math.round(alpha * 100)}%, transparent)`;\n tokens['shadow.xs'] = `0 1px 2px 0 ${a(0.05)}`;\n tokens['shadow.sm'] = `0 1px 3px 0 ${a(0.1)}, 0 1px 2px -1px ${a(0.1)}`;\n tokens['shadow.md'] = `0 4px 6px -1px ${a(0.1)}, 0 2px 4px -2px ${a(0.1)}`;\n tokens['shadow.lg'] = `0 10px 15px -3px ${a(0.1)}, 0 4px 6px -4px ${a(0.1)}`;\n tokens['shadow.xl'] = `0 20px 25px -5px ${a(0.1)}, 0 8px 10px -6px ${a(0.1)}`;\n tokens['border.width.thin'] = `${shape.borderWidth}px`;\n tokens['border.width.thick'] = `${shape.borderWidth * 2}px`;\n\n // --- layout: the page frame and the gutters between columns ----------------\n const step = (name: string) => `${shape.spaceBase * (LAYOUT_STEPS[name] ?? 0)}px`;\n tokens['layout.page.width'] = `${layout.pageWidth}px`;\n tokens['layout.margin.phone'] = step(layout.margin.phone);\n tokens['layout.margin.tablet'] = step(layout.margin.tablet);\n tokens['layout.margin.desktop'] = step(layout.margin.desktop);\n tokens['layout.gutter.sm'] = step(layout.gutter.sm);\n tokens['layout.gutter.md'] = step(layout.gutter.md);\n tokens['layout.gutter.lg'] = step(layout.gutter.lg);\n\n return tokens;\n}\n","/**\n * A brand as design-tool variables, and back.\n *\n * Figma, and tools like it, keep a design system's values as variables in\n * collections. This turns a partner's brand into two collections: the inputs a\n * designer may change, and the tokens Strata derives from them, which are\n * there to design with and are never read back. Changes come back as a patch\n * to the brand inputs, checked by the same schema as any other edit, so\n * nothing Strata would refuse in the CMS gets in through a design file.\n *\n * Plain JSON with no Figma types, so the plugin, the delivery API and the CMS\n * share it, and it is tested without Figma.\n */\nimport { BrandInputsSchema, SPACE_STEP_NAMES, type BrandInputs } from './inputs';\nimport { deriveTokens } from './derive';\n\nexport const VARIABLES_FORMAT = 'strata.brand-variables';\nexport const VARIABLES_VERSION = 1;\n\nexport type VariableType = 'COLOR' | 'FLOAT' | 'STRING';\n\n/** One variable. `name` uses `/` for groups, as Figma does; `path` is where it lives in Strata. */\nexport interface BrandVariable {\n name: string;\n path: string;\n type: VariableType;\n value: string | number;\n description?: string;\n}\n\nexport interface BrandVariables {\n format: typeof VARIABLES_FORMAT;\n version: typeof VARIABLES_VERSION;\n /** The site the brand belongs to, so a file says which partner it is. */\n site: string;\n /** What a designer may change, and what Strata reads back. */\n inputs: BrandVariable[];\n /** Worked out from the inputs. To design with; ignored when read back. */\n derived: BrandVariable[];\n}\n\n/** The spacing multiples the scale's step names stand for. */\nconst STEP_MULTIPLES: Record<string, number> = { '0': 0, '1': 1, '2': 2, '3': 3, '4': 4, '5': 6, '6': 8, '7': 12, '8': 16, '9': 24, '10': 32 };\n\nconst HEX = /^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/;\n\ninterface InputSpec {\n path: string;\n name: string;\n /** A spacing step, shown to a designer in pixels at the brand's spacing unit. */\n step?: boolean;\n description?: string;\n}\n\n/** The inputs a design tool may hold, in the order a designer meets them. Assets and web fonts stay in the CMS. */\nconst INPUTS: InputSpec[] = [\n { path: 'color.brand', name: 'color/brand' },\n { path: 'color.accent', name: 'color/accent' },\n { path: 'color.surfacePage', name: 'color/surface/page', description: 'May be a gradient; carries no text.' },\n { path: 'color.surfaceCard', name: 'color/surface/card' },\n { path: 'color.surfaceHeader', name: 'color/surface/header' },\n { path: 'color.surfaceFooter', name: 'color/surface/footer' },\n { path: 'color.text', name: 'color/text' },\n { path: 'color.danger', name: 'color/status/danger' },\n { path: 'color.warning', name: 'color/status/warning' },\n { path: 'color.success', name: 'color/status/success' },\n { path: 'color.info', name: 'color/status/info' },\n { path: 'font.body', name: 'font/body' },\n { path: 'font.heading', name: 'font/heading' },\n { path: 'font.sizeBase', name: 'font/size-base', description: 'Root size in px, 14 to 20.' },\n { path: 'font.scale', name: 'font/scale', description: 'Type ramp ratio, 1.067 to 1.333.' },\n { path: 'shape.radiusBase', name: 'shape/radius', description: 'Corner radius in px, 0 to 24.' },\n { path: 'shape.spaceBase', name: 'shape/space-unit', description: 'The spacing unit in px, 2 to 8.' },\n { path: 'shape.borderWidth', name: 'shape/border-width', description: 'Border weight in px, 1 to 3.' },\n { path: 'layout.pageWidth', name: 'layout/page-width', description: 'Widest content in px, 640 to 1600.' },\n { path: 'layout.margin.phone', name: 'layout/margin/phone', step: true },\n { path: 'layout.margin.tablet', name: 'layout/margin/tablet', step: true },\n { path: 'layout.margin.desktop', name: 'layout/margin/desktop', step: true },\n { path: 'layout.gutter.sm', name: 'layout/gutter/sm', step: true },\n { path: 'layout.gutter.md', name: 'layout/gutter/md', step: true },\n { path: 'layout.gutter.lg', name: 'layout/gutter/lg', step: true },\n];\n\nconst STEP_HINT = 'A step on the spacing scale, in px: a multiple of the space unit (1, 2, 3, 4, 6, 8, 12, 16, 24 or 32 times).';\n\nconst read = (source: unknown, path: string): unknown =>\n path.split('.').reduce<unknown>((at, key) => (at && typeof at === 'object' ? (at as Record<string, unknown>)[key] : undefined), source);\n\nfunction write(target: Record<string, unknown>, path: string, value: unknown) {\n const keys = path.split('.');\n let at = target;\n for (const key of keys.slice(0, -1)) at = (at[key] ??= {}) as Record<string, unknown>;\n at[keys[keys.length - 1]!] = value;\n}\n\n/** A partner's brand as variables: its inputs, and the tokens derived from them. */\nexport function brandToVariables(brand: BrandInputs, site: string): BrandVariables {\n const inputs = BrandInputsSchema.parse(brand);\n const unit = inputs.shape.spaceBase;\n const fromInputs: BrandVariable[] = [];\n for (const spec of INPUTS) {\n let value = read(inputs, spec.path);\n // An unset accent or heading font means \"the same as the brand colour or body font\".\n if (value === undefined && spec.path === 'color.accent') value = inputs.color.brand;\n if (value === undefined && spec.path === 'font.heading') value = inputs.font.body;\n if (value === undefined) continue;\n if (spec.step) {\n fromInputs.push({ name: spec.name, path: spec.path, type: 'FLOAT', value: unit * (STEP_MULTIPLES[String(value)] ?? 0), description: STEP_HINT });\n continue;\n }\n const type: VariableType = typeof value === 'number' ? 'FLOAT' : spec.path.startsWith('color.') && HEX.test(String(value)) ? 'COLOR' : 'STRING';\n fromInputs.push({ name: spec.name, path: spec.path, type, value: value as string | number, ...(spec.description ? { description: spec.description } : {}) });\n }\n\n const derived: BrandVariable[] = [];\n for (const [path, value] of Object.entries(deriveTokens(inputs))) {\n const name = path.replace(/\\./g, '/');\n if (HEX.test(value)) derived.push({ name, path, type: 'COLOR', value });\n else if (/^-?[\\d.]+px$/.test(value)) derived.push({ name, path, type: 'FLOAT', value: Number.parseFloat(value) });\n else if (/^-?[\\d.]+$/.test(value)) derived.push({ name, path, type: 'FLOAT', value: Number(value) });\n else derived.push({ name, path, type: 'STRING', value });\n }\n return { format: VARIABLES_FORMAT, version: VARIABLES_VERSION, site, inputs: fromInputs, derived };\n}\n\nexport interface VariableChange {\n path: string;\n name: string;\n from: unknown;\n to: unknown;\n /** The change as a designer reads it: a spacing step in pixels rather than by its name. */\n shown: { from: string; to: string };\n}\n\nexport type VariablesImport =\n | { ok: true; inputs: BrandInputs; changes: VariableChange[] }\n | { ok: false; problems: string[] };\n\n/**\n * Read variables back onto a brand.\n *\n * Only the inputs are read; derived tokens are worked out again, never\n * copied. A spacing step comes back from pixels to the step it names, and a\n * value that is not one of the steps is refused rather than rounded, because\n * rounding would quietly change the designer's layout.\n */\nexport function variablesToBrand(document: unknown, base: BrandInputs): VariablesImport {\n const doc = document as Partial<BrandVariables> | null;\n if (!doc || doc.format !== VARIABLES_FORMAT || !Array.isArray(doc.inputs)) {\n return { ok: false, problems: ['This is not a Strata brand variables export.'] };\n }\n const current = BrandInputsSchema.parse(base);\n const next = structuredClone(current) as unknown as Record<string, unknown>;\n const problems: string[] = [];\n const changes: VariableChange[] = [];\n const unitVariable = doc.inputs.find((v) => v.path === 'shape.spaceBase');\n const unit = typeof unitVariable?.value === 'number' ? unitVariable.value : current.shape.spaceBase;\n\n for (const variable of doc.inputs) {\n const spec = INPUTS.find((s) => s.path === variable?.path);\n if (!spec) continue;\n let value: unknown = variable.value;\n // Figma keeps numbers as 32-bit floats, so 1.2 comes back as 1.2000000476837158.\n if (typeof value === 'number') value = Math.round(value * 10_000) / 10_000;\n if (spec.step) {\n const step = typeof value === 'number' ? SPACE_STEP_NAMES.find((name) => unit * (STEP_MULTIPLES[name] ?? -1) === value) : undefined;\n if (!step) { problems.push(`${spec.name} is ${String(value)}px, which is not a step on the spacing scale at a ${unit}px unit.`); continue; }\n value = step;\n }\n if (typeof value === 'string' && spec.path.startsWith('color.') && HEX.test(value)) value = value.toLowerCase();\n const was = read(current, spec.path);\n write(next, spec.path, value);\n const comparable = (v: unknown) => (typeof v === 'string' ? v.toLowerCase() : v);\n if (comparable(was) !== comparable(value) && !(was === undefined && (spec.path === 'color.accent' || spec.path === 'font.heading') && value === (spec.path === 'color.accent' ? current.color.brand : current.font.body))) {\n const show = (v: unknown, at: number) => (v === undefined ? 'not set' : spec.step ? `${at * (STEP_MULTIPLES[String(v)] ?? 0)}px` : String(v));\n changes.push({ path: spec.path, name: spec.name, from: was, to: value, shown: { from: show(was, current.shape.spaceBase), to: show(value, unit) } });\n }\n }\n // Check everything else too, so a designer sees every problem in one go rather than one round at a time.\n // A value refused above was never written, so it cannot be reported twice.\n const parsed = BrandInputsSchema.safeParse(next);\n if (!parsed.success) {\n for (const issue of parsed.error.issues) {\n const path = issue.path.join('.');\n const spec = INPUTS.find((s) => s.path === path);\n if (!spec) { problems.push(`${path}: ${issue.message}`); continue; }\n const sent = doc.inputs.find((v) => v?.path === path)?.value;\n problems.push(`${spec.name} is ${JSON.stringify(sent)}. ${issue.message.replace(/\\.?$/, '.')}`);\n }\n }\n if (problems.length || !parsed.success) return { ok: false, problems };\n return { ok: true, inputs: parsed.data, changes };\n}\n\n/** Each input variable's name, as a design tool shows it, and where it lives in Strata. A plugin reads variables back by name. */\nexport const INPUT_VARIABLE_PATHS: Readonly<Record<string, string>> = Object.fromEntries(INPUTS.map((spec) => [spec.name, spec.path]));\n","/**\n * The contrast gate.\n *\n * Derivation means most pairs cannot fail — a foreground is picked by measured\n * contrast and a blend is ratcheted until it passes. What is left are the pairs\n * a partner controls both sides of: their brand colour against their own\n * surfaces, their text against their own card, and their status colours\n * against it. Those are checked here, and a failure blocks a publish the way a\n * dangling reference already does\n * ([ADR 0009](../../../docs/decisions/0009-wcag-is-an-authoring-gate.md)).\n *\n * This is a floor, not a certificate. It is arithmetic over colour pairs: it\n * cannot see a value rendered on an image, text baked into a logo, or a\n * disabled control whose contrast is exempt but whose meaning is not. Treating\n * a green build as \"the brand is accessible\" is the failure mode to guard\n * against, which is why the result says what it checked.\n */\nimport { AA_NON_TEXT, AA_TEXT, contrastRatio, parseHex } from './contrast';\nimport { deriveTokens, type TokenSet } from './derive';\nimport type { BrandInputs } from './inputs';\n\nexport interface ContrastIssue {\n /** The token that fails, as an editor would be shown it. */\n token: string;\n foreground: string;\n background: string;\n ratio: number;\n required: number;\n /** The WCAG criterion, so the message can cite it. */\n criterion: '1.4.3 Contrast (Minimum)' | '1.4.11 Non-text Contrast';\n message: string;\n}\n\nexport interface ContrastReport {\n ok: boolean;\n issues: ContrastIssue[];\n /** How many pairs were examined — the honest denominator. */\n checked: number;\n}\n\ninterface Pair {\n token: string;\n fg: string;\n bg: string;\n required: number;\n criterion: ContrastIssue['criterion'];\n what: string;\n}\n\n/**\n * A gradient has no single luminance, so it is skipped rather than guessed at.\n * Safe because nothing is read directly against the page surface — the one\n * place a gradient is allowed.\n */\nconst isMeasurable = (value: string): boolean => parseHex(value) !== null;\n\nfunction pairsFor(tokens: TokenSet): Pair[] {\n const card = tokens['color.surface.card'];\n const text = (t: string) => ({ required: AA_TEXT, criterion: '1.4.3 Contrast (Minimum)' as const, what: t });\n const ui = (t: string) => ({ required: AA_NON_TEXT, criterion: '1.4.11 Non-text Contrast' as const, what: t });\n\n const pairs: Pair[] = [\n { token: 'color.text.default', fg: tokens['color.text.default'], bg: card, ...text('Body text on a card') },\n { token: 'color.text.muted', fg: tokens['color.text.muted'], bg: card, ...text('Muted text on a card') },\n { token: 'color.text.placeholder', fg: tokens['color.text.placeholder'], bg: card, ...text('Placeholder text in a field') },\n { token: 'color.text.link', fg: tokens['color.text.link'], bg: card, ...text('A link on a card') },\n { token: 'color.text.on-brand', fg: tokens['color.text.on-brand'], bg: tokens['color.brand.default'], ...text('Text on a brand-coloured button') },\n { token: 'color.text.on-header', fg: tokens['color.text.on-header'], bg: tokens['color.surface.header'], ...text('Text in the header') },\n { token: 'color.text.on-footer', fg: tokens['color.text.on-footer'], bg: tokens['color.surface.footer'], ...text('Text in the footer') },\n { token: 'color.brand.default', fg: tokens['color.brand.default'], bg: card, ...ui('A brand-coloured control against a card') },\n { token: 'color.border.default', fg: tokens['color.border.default'], bg: card, ...ui('A field border against a card') },\n ];\n\n for (const name of ['danger', 'warning', 'success', 'info']) {\n pairs.push({\n token: `color.status.${name}.text`,\n fg: tokens[`color.status.${name}.text`],\n bg: card,\n ...text(`${name[0].toUpperCase()}${name.slice(1)} message text`),\n });\n pairs.push({\n token: `color.status.${name}.default`,\n fg: tokens[`color.status.${name}.default`],\n bg: card,\n ...ui(`The ${name} indicator against a card`),\n });\n }\n\n return pairs;\n}\n\n/** Check a derived token set. */\nexport function checkContrast(tokens: TokenSet): ContrastReport {\n const issues: ContrastIssue[] = [];\n let checked = 0;\n\n for (const pair of pairsFor(tokens)) {\n if (!isMeasurable(pair.fg) || !isMeasurable(pair.bg)) continue;\n checked += 1;\n const ratio = contrastRatio(pair.fg, pair.bg);\n if (ratio >= pair.required) continue;\n issues.push({\n token: pair.token,\n foreground: pair.fg,\n background: pair.bg,\n ratio: Math.round(ratio * 100) / 100,\n required: pair.required,\n criterion: pair.criterion,\n message:\n `${pair.what} is ${(Math.round(ratio * 100) / 100).toFixed(2)}:1, ` +\n `below the ${pair.required}:1 that ${pair.criterion} requires.`,\n });\n }\n\n return { ok: issues.length === 0, issues, checked };\n}\n\n/** Check a brand before its tokens exist. What the CMS editor calls. */\nexport const checkBrandContrast = (input: BrandInputs): ContrastReport =>\n checkContrast(deriveTokens(input));\n","/**\n * Tokens → the W3C Design Tokens Community Group format.\n *\n * An OUTPUT, not the source. ADR 0005 originally had tokens authored as DTCG\n * files and built by Style Dictionary; writing the derivation showed why that\n * cannot be the whole story. A partner's tokens are computed at runtime from a\n * published brand document, so the authoring format has to be code — a\n * build-time pipeline can only ever produce the house theme, and a second\n * emitter for the runtime path would drift from it.\n *\n * So the format is kept as an export. It is what Figma, Style Dictionary and\n * the token tooling read, which is what makes a design-tool round trip a thing\n * we can add later rather than a rewrite, and it costs one function.\n */\nimport type { TokenSet } from './derive';\n\nexport type DtcgType = 'color' | 'dimension' | 'fontFamily' | 'fontWeight' | 'number' | 'shadow';\n\ninterface DtcgToken {\n $type: DtcgType;\n $value: string;\n $description?: string;\n}\n\nexport type DtcgGroup = { [key: string]: DtcgGroup | DtcgToken };\n\n/**\n * Infer the type from the token's path and value.\n *\n * By path first, because a value alone is ambiguous — `\"400\"` is a font weight\n * and `\"2px\"` is a dimension and both are strings. The paths are ours, so this\n * is reading our own naming convention rather than guessing.\n */\nfunction typeOf(path: string, value: string): DtcgType {\n if (path.startsWith('color.') || path.startsWith('focus.ring.') && !/width|offset|shadow/.test(path)) return 'color';\n if (path.includes('font.family')) return 'fontFamily';\n if (path.includes('font.weight')) return 'fontWeight';\n if (path.includes('line-height')) return 'number';\n if (path.includes('shadow')) return 'shadow';\n if (/^-?[\\d.]+(px|rem|em|%)$/.test(value) || value === '0') return 'dimension';\n return 'color';\n}\n\n/** A flat token set as a nested DTCG document. */\nexport function toDtcg(tokens: TokenSet): DtcgGroup {\n const root: DtcgGroup = {};\n for (const [path, value] of Object.entries(tokens)) {\n const parts = path.split('.');\n const leaf = parts.pop() as string;\n let node = root;\n for (const part of parts) {\n if (!(part in node) || '$value' in (node[part] as DtcgToken)) node[part] = {} as DtcgGroup;\n node = node[part] as DtcgGroup;\n }\n node[leaf] = { $type: typeOf(path, value), $value: value };\n }\n return root;\n}\n"],"mappings":";;;;;;;;;;;;AAiBA,SAAS,SAAS;AAGX,IAAM,iBAAiB,EAC3B,OAAO,EACP,MAAM,sCAAsC,oCAAoC;AAW5E,IAAM,qBAAqB,EAAE,MAAM;AAAA,EACxC;AAAA,EACA,EAAE,OAAO,EAAE,MAAM,0CAA0C,wCAAwC;AACrG,CAAC;AAEM,IAAM,gBAAgB,EAAE,OAAO;AAAA,EACpC,QAAQ,EAAE,OAAO;AAAA,EACjB,KAAK,EAAE,OAAO;AAAA,EACd,QAAQ,EAAE,OAAO,EAAE,SAAS;AAAA,EAC5B,OAAO,EAAE,OAAO,EAAE,SAAS;AAAA,EAC3B,SAAS,EAAE,OAAO,EAAE,SAAS;AAC/B,CAAC;AAYM,IAAM,kBAAkB,EAAE,OAAO,EAAE,IAAI,KAAK,EAAE,IAAI,KAAK;AAO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IAAI,IAAI,CAAC;AAC5E,aAAO,KAAK,IAAI;AAAA,IAClB;AACA,SAAK,IAAI,IAAI,EAAE,OAAO,OAAO,MAAM,KAAK,GAAG,QAAQ,MAAM;AAAA,EAC3D;AACA,SAAO;AACT;","names":["step","HEX"]}
1
+ {"version":3,"sources":["../src/inputs.ts","../src/motion.ts","../src/fonts.ts","../src/contrast.ts","../src/derive.ts","../src/variables.ts","../src/validate.ts","../src/dtcg.ts"],"sourcesContent":["/**\n * Brand inputs — everything a partner may set, and nothing else.\n *\n * The list is closed, and it is short on purpose. Stripe's Appearance API gets\n * almost all of its brand expression from eight variables and derives the rest;\n * Cloudscape allows typography, colour and border radius and refuses the\n * question beyond that; the legacy Sanity CMS this replaces allowed everything\n * and accumulated forty per-viewport override fields nobody could prune. The\n * reasoning, with sources, is\n * [ADR 0010](https://github.com/matthill8286/strata/blob/main/docs/decisions/0010-what-a-brand-may-set.md).\n *\n * Two absences are the point of the whole file. There is no foreground colour\n * anywhere — text on a surface is computed, so a partner cannot pin white text\n * onto a mid-tone brand colour. And there is no focus colour — the ring keeps\n * system values, because a focus indicator drawn in a partner's own brand\n * colour on that partner's own background is where focus visibility dies.\n */\nimport { z } from 'zod';\nimport { MotionInputsSchema } from './motion';\n\n/** A hex colour. The only colour form the inputs accept. */\nexport const HexColorSchema = z\n .string()\n .regex(/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/, 'Must be a hex colour, e.g. #5e10b1');\n\n/**\n * The page background, which may be a gradient.\n *\n * It is the one exception and it is safe by construction rather than by\n * exception: the page background never carries text directly — text sits on a\n * card — so it is the only surface with nothing to contrast against. Northwind\n * Plus's shell is a three-stop gradient, which is a real requirement and\n * would otherwise need an escape hatch.\n */\nexport const SurfaceValueSchema = z.union([\n HexColorSchema,\n z.string().regex(/^(linear|radial|conic)-gradient\\(.+\\)$/, 'Must be a hex colour or a CSS gradient'),\n]);\n\nexport const WebFontSchema = z.object({\n family: z.string(),\n url: z.string(),\n weight: z.string().optional(),\n style: z.string().optional(),\n display: z.string().optional(),\n});\nexport type WebFont = z.infer<typeof WebFontSchema>;\n\n/**\n * The type ramp ratio.\n *\n * Bounded rather than free. Below 1.067 the ramp stops distinguishing levels\n * and heading structure becomes invisible to a sighted reader even though the\n * markup is correct; above 1.333 the top of the scale overflows a 360px\n * viewport at 200% zoom, which fails 1.4.4. A partner who wants bigger headings\n * raises the base size.\n */\nexport const TypeScaleSchema = z.number().min(1.067).max(1.333);\n\n/**\n * A step on the spacing scale, as the `space.*` tokens name them: `4` is four\n * spacing units, `6` is eight, `8` is sixteen. Layout names a step rather\n * than a size, so it follows the brand's spacing unit.\n */\nexport const SPACE_STEP_NAMES = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10'] as const;\nexport const SpaceStepSchema = z.enum(SPACE_STEP_NAMES);\nexport type SpaceStep = z.infer<typeof SpaceStepSchema>;\n\n/**\n * Each group is `.strict()`.\n *\n * Zod strips unknown keys by default, so `color.onBrand` would validate, be\n * dropped, and leave an editor looking at a brand that ignores a value they\n * set. Rejecting it says what is actually true: there is nowhere to put a\n * foreground colour, because foregrounds are measured.\n */\nexport const BrandInputsSchema = z.object({\n color: z.strictObject({\n /** The partner's primary colour: actions, emphasis, selected states. */\n brand: HexColorSchema,\n /** The secondary colour. Defaults to the brand colour when unset. */\n accent: HexColorSchema.optional(),\n\n /** The page behind everything. May be a gradient; carries no text. */\n surfacePage: SurfaceValueSchema,\n /** Where content actually sits, and what text is read against. */\n surfaceCard: HexColorSchema,\n /** The header band. */\n surfaceHeader: HexColorSchema,\n /** The footer band. */\n surfaceFooter: HexColorSchema,\n /** Text in the header band. Unset, it is the accent on a light band and white or black on a dark one. */\n textHeader: HexColorSchema.optional(),\n /** Text in the footer band. Unset, it follows the same rule as the header's. */\n textFooter: HexColorSchema.optional(),\n /** Headings. Unset, they take the accent; a brand whose headings are set in ink names it here. */\n textHeading: HexColorSchema.optional(),\n /**\n * Colours for things told apart by colour alone: the lanes of a timeline,\n * the branches of a list, the stripe along a footer. In order; unset, the\n * accent and the status colours stand in.\n */\n chart: z.array(HexColorSchema).max(8).optional(),\n\n /** Default body text, on `surfaceCard`. */\n text: HexColorSchema,\n\n danger: HexColorSchema,\n warning: HexColorSchema,\n success: HexColorSchema,\n info: HexColorSchema,\n }),\n\n font: z.strictObject({\n body: z.string(),\n /** Defaults to `body` when unset — most brands have one typeface. */\n heading: z.string().optional(),\n /** Code-like labels: hashes, branches, version lines. Unset, the device's own monospace face. */\n mono: z.string().optional(),\n /** The face of the small line above a heading. `mono` sets it as a code label, as a changelog would. */\n eyebrow: z.enum(['body', 'mono']).default('body'),\n /** Root size in px. Everything else is `rem`, scaled from this. */\n sizeBase: z.number().min(14).max(20).default(16),\n scale: TypeScaleSchema.default(1.2),\n /** Faces the shell must load. A partner brings its own typeface. */\n webFonts: z.array(WebFontSchema).default([]),\n }),\n\n shape: z.strictObject({\n /** Corner rounding in px. Every radius derives from it. */\n radiusBase: z.number().min(0).max(24).default(4),\n /** The spacing unit in px. All spacing is a multiple. */\n spaceBase: z.number().min(2).max(8).default(4),\n /** Default border weight in px. */\n borderWidth: z.number().min(1).max(3).default(1),\n /** A form field: a card-coloured box with a border, or a box filled a shade off the page with a fainter one. */\n fields: z.enum(['outlined', 'filled']).default('outlined'),\n /**\n * What a solid button does when pointed at: a shade darker, or turn the\n * accent colour, its arrow lifting a quarter-turn up, as some brands do.\n */\n buttonHover: z.enum(['shade', 'accent']).default('shade'),\n }),\n\n /**\n * The page's frame and the spacing between columns.\n *\n * Margins and gutters name steps on the spacing scale rather than pixels,\n * so they move with `shape.spaceBase` and stay on the same rhythm as\n * everything else. The page width is bounded: below 640px a desktop page\n * reads as a phone page, and above 1600px a line of text outgrows what can\n * be read comfortably. Every value defaults to what pages had before this\n * group existed, so a brand that sets none of it looks the same.\n */\n layout: z.strictObject({\n /** The widest the content gets on a large screen, in px, inside the margins. */\n pageWidth: z.number().min(640).max(1600).default(1200),\n /** Space between the screen's edge and the content, at each size. */\n margin: z.strictObject({\n phone: SpaceStepSchema.default('4'),\n tablet: SpaceStepSchema.default('6'),\n desktop: SpaceStepSchema.default('8'),\n }).default({}),\n /** The three gutters a grid may choose between columns. */\n gutter: z.strictObject({\n sm: SpaceStepSchema.default('2'),\n md: SpaceStepSchema.default('4'),\n lg: SpaceStepSchema.default('6'),\n }).default({}),\n }).default({}),\n\n /**\n * How the brand moves: a personality and a playback speed, and nothing else.\n * Every duration, curve and spring is derived from these two\n * ([ADR 0027](https://github.com/matthill8286/strata/blob/main/docs/decisions/0027-motion-is-states-transitions-and-timelines.md)).\n * Defaults to calm at normal speed, so a brand that sets none of it is quiet.\n */\n motion: MotionInputsSchema.default({}),\n\n /**\n * The logo and favicon. A site made in the CMS before anyone uploads a logo\n * has none, which is the house default's empty logo rather than a missing\n * brand: without the default, delivery refused the whole brand and the site\n * rendered in the generic look.\n */\n assets: z.strictObject({\n logo: z.string(),\n logoAlt: z.string(),\n /** For use on dark surfaces, where the main logo would disappear. */\n logoDark: z.string().optional(),\n favicon: z.string().optional(),\n }).default({ logo: '', logoAlt: '' }),\n});\n\nexport type BrandInputs = z.infer<typeof BrandInputsSchema>;\n\n/**\n * The house defaults — a complete, neutral, AA-passing brand.\n *\n * Every input is optional at the edges of the system because this exists: a\n * site with no brand document still renders something legible rather than\n * unstyled, which is what makes a missing brand a visible problem instead of a\n * broken page.\n */\nexport const DEFAULT_BRAND_INPUTS: BrandInputs = BrandInputsSchema.parse({\n color: {\n brand: '#1f4ed8',\n surfacePage: '#f4f5f7',\n surfaceCard: '#ffffff',\n surfaceHeader: '#ffffff',\n surfaceFooter: '#1f2430',\n text: '#1a1a1a',\n danger: '#c8102e',\n warning: '#b45309',\n success: '#047857',\n info: '#1f4ed8',\n },\n font: { body: 'system-ui, -apple-system, \"Segoe UI\", Roboto, sans-serif' },\n shape: {},\n assets: { logo: '', logoAlt: '' },\n});\n","/**\n * Motion tokens — the timing every transition names, derived from two inputs.\n *\n * [ADR 0027](https://github.com/matthill8286/strata/blob/main/docs/decisions/0027-motion-is-states-transitions-and-timelines.md)\n * keeps motion inside the rule of ADR 0010: a brand chooses a personality and a\n * speed, and nothing else. Durations, curves, springs, stagger gaps and travel\n * distances are derived here. A partner who wants a different curve is asking\n * for a change to this table, which is a product decision with a version number.\n *\n * Springs are described physically (stiffness, damping ratio, mass) and also\n * baked into a CSS `linear()` easing with its own duration, so a compiled page\n * can run a spring with no script. Interruptible transitions read the physical\n * values instead and run on the motion runtime.\n */\nimport { z } from 'zod';\nimport type { TokenSet } from './derive';\n\nexport const MOTION_PERSONALITIES = ['calm', 'lively', 'expressive'] as const;\nexport type MotionPersonality = (typeof MOTION_PERSONALITIES)[number];\n\n/**\n * What a brand may set about motion.\n *\n * `speed` is a playback rate: 1.25 is a quarter faster, 0.75 a quarter slower.\n * The bounds are where the derived durations stay inside the range the motion\n * gate accepts for every personality.\n */\nexport const MotionInputsSchema = z.strictObject({\n personality: z.enum(MOTION_PERSONALITIES).default('calm'),\n speed: z.number().min(0.75).max(1.25).default(1),\n});\nexport type MotionInputs = z.infer<typeof MotionInputsSchema>;\n\nexport const DURATION_NAMES = ['instant', 'fast', 'base', 'slow', 'scene'] as const;\nexport const EASING_NAMES = ['standard', 'enter', 'exit', 'emphasis'] as const;\nexport const SPRING_NAMES = ['snappy', 'gentle', 'bouncy'] as const;\nexport const STAGGER_NAMES = ['tight', 'base', 'loose'] as const;\nexport const DISTANCE_NAMES = ['near', 'far'] as const;\nexport type DurationName = (typeof DURATION_NAMES)[number];\nexport type EasingName = (typeof EASING_NAMES)[number];\nexport type SpringName = (typeof SPRING_NAMES)[number];\nexport type StaggerName = (typeof STAGGER_NAMES)[number];\nexport type DistanceName = (typeof DISTANCE_NAMES)[number];\n\nexport type Bezier = readonly [number, number, number, number];\n\n/** A spring by its physics. `dampingRatio` 1 settles with no overshoot; below 1 it bounces. */\nexport interface Spring {\n stiffness: number;\n dampingRatio: number;\n mass: number;\n}\n\ninterface Personality {\n /** Milliseconds at speed 1. `instant` is always 0 and is not listed. */\n duration: Record<Exclude<DurationName, 'instant'>, number>;\n easing: Record<EasingName, Bezier>;\n spring: Record<SpringName, Spring>;\n /** Milliseconds between choreographed siblings, at speed 1. */\n stagger: Record<StaggerName, number>;\n /** How far an entering element travels, in steps of the spacing unit. */\n distance: Record<DistanceName, number>;\n}\n\n/**\n * The three personalities.\n *\n * `calm` is the house default and suits regulated products: short, no\n * overshoot except in `bouncy`, small travel. `lively` is the marketing\n * register. `expressive` is for studios and launches, with real bounce and\n * longer scenes, and is still inside the gate's limits.\n */\nexport const PERSONALITIES: Record<MotionPersonality, Personality> = {\n calm: {\n duration: { fast: 140, base: 220, slow: 360, scene: 700 },\n easing: { standard: [0.2, 0, 0, 1], enter: [0, 0, 0.2, 1], exit: [0.4, 0, 1, 1], emphasis: [0.65, 0, 0.35, 1] },\n spring: {\n snappy: { stiffness: 400, dampingRatio: 1, mass: 1 },\n gentle: { stiffness: 170, dampingRatio: 1, mass: 1 },\n bouncy: { stiffness: 260, dampingRatio: 0.82, mass: 1 },\n },\n stagger: { tight: 30, base: 60, loose: 100 },\n distance: { near: 4, far: 12 },\n },\n lively: {\n duration: { fast: 160, base: 260, slow: 440, scene: 900 },\n easing: { standard: [0.2, 0, 0, 1], enter: [0.22, 1, 0.36, 1], exit: [0.55, 0, 1, 0.45], emphasis: [0.83, 0, 0.17, 1] },\n spring: {\n snappy: { stiffness: 500, dampingRatio: 0.86, mass: 1 },\n gentle: { stiffness: 200, dampingRatio: 0.9, mass: 1 },\n bouncy: { stiffness: 300, dampingRatio: 0.65, mass: 1 },\n },\n stagger: { tight: 40, base: 80, loose: 140 },\n distance: { near: 6, far: 16 },\n },\n expressive: {\n duration: { fast: 180, base: 320, slow: 560, scene: 1200 },\n easing: { standard: [0.2, 0, 0, 1], enter: [0.16, 1, 0.3, 1], exit: [0.7, 0, 0.84, 0], emphasis: [0.7, 0, 0.2, 1] },\n spring: {\n snappy: { stiffness: 520, dampingRatio: 0.75, mass: 1 },\n gentle: { stiffness: 180, dampingRatio: 0.8, mass: 1 },\n bouncy: { stiffness: 320, dampingRatio: 0.5, mass: 1 },\n },\n stagger: { tight: 50, base: 100, loose: 180 },\n distance: { near: 8, far: 24 },\n },\n};\n\n/** The bounds the motion gate holds every derived duration to, in ms. */\nexport const DURATION_LIMITS = { min: 0, max: 2000 } as const;\n\n/**\n * A spring's position over time, from 0 at rest to 1 at the target.\n *\n * The closed-form solution of a damped harmonic oscillator released from 0\n * with no initial velocity. Under-damped springs overshoot; critically damped\n * ones approach 1 without passing it. Time is in seconds.\n */\nexport function springAt(spring: Spring, t: number): number {\n const { stiffness: k, dampingRatio: z, mass: m } = spring;\n const w0 = Math.sqrt(k / m);\n if (z < 1) {\n const wd = w0 * Math.sqrt(1 - z * z);\n return 1 - Math.exp(-z * w0 * t) * (Math.cos(wd * t) + ((z * w0) / wd) * Math.sin(wd * t));\n }\n return 1 - Math.exp(-w0 * t) * (1 + w0 * t);\n}\n\n/**\n * How long a spring takes to settle, in ms: the last moment it is more than\n * `tolerance` away from its target.\n */\nexport function springDuration(spring: Spring, tolerance = 0.001): number {\n const step = 1 / 240;\n let last = 0;\n for (let t = 0; t < 10; t += step) if (Math.abs(1 - springAt(spring, t)) > tolerance) last = t;\n return Math.ceil((last + step) * 1000);\n}\n\n/**\n * A spring baked into a CSS `linear()` easing and the duration it runs over.\n *\n * `linear()` interpolates straight lines between the listed points, so a spring\n * sampled densely enough is visually indistinguishable from the physics. Forty\n * points is where the overshoot of the bounciest spring stops showing facets.\n */\nexport function springToLinear(spring: Spring, points = 40): { easing: string; durationMs: number } {\n const durationMs = springDuration(spring);\n const values: string[] = [];\n for (let i = 0; i <= points; i += 1) {\n const v = i === points ? 1 : springAt(spring, (durationMs / 1000) * (i / points));\n values.push(String(Math.round(v * 10000) / 10000));\n }\n return { easing: `linear(${values.join(', ')})`, durationMs };\n}\n\n/** A spring sped up or slowed down: time scales by 1/speed, so stiffness scales by speed². */\nexport function scaleSpring(spring: Spring, speed: number): Spring {\n return { ...spring, stiffness: spring.stiffness * speed * speed };\n}\n\nconst ms = (n: number) => `${Math.round(n)}ms`;\nconst bezier = (b: Bezier) => `cubic-bezier(${b.join(', ')})`;\nconst round = (n: number) => String(Math.round(n * 1000) / 1000);\n\n/** The fully resolved motion values, for code that needs numbers rather than CSS strings. */\nexport interface ResolvedMotion {\n personality: MotionPersonality;\n speed: number;\n duration: Record<DurationName, number>;\n easing: Record<EasingName, Bezier>;\n spring: Record<SpringName, Spring>;\n stagger: Record<StaggerName, number>;\n /** In px, after the spacing unit is applied. */\n distance: Record<DistanceName, number>;\n}\n\nexport function resolveMotion(input: Partial<MotionInputs> | undefined, spaceBase = 4): ResolvedMotion {\n const { personality, speed } = MotionInputsSchema.parse(input ?? {});\n const p = PERSONALITIES[personality];\n const scaled = <K extends string>(r: Record<K, number>) =>\n Object.fromEntries(Object.entries(r).map(([k, v]) => [k, (v as number) / speed])) as Record<K, number>;\n return {\n personality,\n speed,\n duration: { instant: 0, ...scaled(p.duration) },\n easing: p.easing,\n spring: Object.fromEntries(Object.entries(p.spring).map(([k, s]) => [k, scaleSpring(s as Spring, speed)])) as Record<SpringName, Spring>,\n stagger: scaled(p.stagger),\n distance: Object.fromEntries(Object.entries(p.distance).map(([k, steps]) => [k, (steps as number) * spaceBase])) as Record<DistanceName, number>,\n };\n}\n\n/** Motion as flat tokens, merged into the set `deriveTokens` returns. */\nexport function deriveMotionTokens(input: Partial<MotionInputs> | undefined, spaceBase = 4): TokenSet {\n const m = resolveMotion(input, spaceBase);\n const tokens: TokenSet = {};\n for (const name of DURATION_NAMES) tokens[`motion.duration.${name}`] = ms(m.duration[name]);\n for (const name of EASING_NAMES) tokens[`motion.easing.${name}`] = bezier(m.easing[name]);\n for (const name of SPRING_NAMES) {\n const s = m.spring[name];\n const baked = springToLinear(s);\n tokens[`motion.spring.${name}.stiffness`] = round(s.stiffness);\n tokens[`motion.spring.${name}.damping-ratio`] = round(s.dampingRatio);\n tokens[`motion.spring.${name}.mass`] = round(s.mass);\n tokens[`motion.spring.${name}.easing`] = baked.easing;\n tokens[`motion.spring.${name}.duration`] = ms(baked.durationMs);\n }\n for (const name of STAGGER_NAMES) tokens[`motion.stagger.${name}`] = ms(m.stagger[name]);\n for (const name of DISTANCE_NAMES) tokens[`motion.distance.${name}`] = `${m.distance[name]}px`;\n return tokens;\n}\n","/**\n * Fonts a brand names, and whether anything will actually draw them.\n *\n * A brand names its typefaces by family (\"GT Walsheim Pro\"). A browser draws a\n * family only if the device has it or the page loads it with `@font-face`, and\n * when it can do neither it falls back to its default, which is Times. So every\n * family a brand names is followed by a fallback stack, and a family is only\n * called loaded when the brand carries a file for it.\n */\nimport type { WebFont } from './inputs';\n\n/**\n * What a browser draws when a sans-serif family is missing: the device's own\n * interface font. A brand font often has only Latin letters, so the stack also\n * names fonts that have Greek, Cyrillic and Simplified Chinese (ADR 0026):\n * Arial and Roboto carry Greek and Cyrillic, and PingFang SC (Apple), Microsoft\n * YaHei (Windows) and Noto Sans SC (Android and Linux) carry Chinese. A browser\n * picks per letter, so a Greek page in a Latin-only brand font keeps the brand\n * font for digits and Latin names and takes the Greek letters from these.\n */\nexport const SYSTEM_SANS = 'system-ui, -apple-system, \"Segoe UI\", Roboto, \"Helvetica Neue\", Arial, \"Noto Sans\", \"PingFang SC\", \"Microsoft YaHei\", \"Noto Sans SC\", sans-serif';\n/** The serif equivalent, for a brand whose type is a serif, with the same cover. */\nexport const SYSTEM_SERIF = 'Georgia, Cambria, \"Times New Roman\", \"Noto Serif\", \"Songti SC\", SimSun, \"Noto Serif SC\", serif';\n\n\nconst GENERIC = new Set(['serif', 'sans-serif', 'monospace', 'cursive', 'fantasy', 'system-ui', 'ui-sans-serif', 'ui-serif', 'ui-monospace', 'ui-rounded', 'math', 'emoji']);\n/** Families every device has, or that name the device's own font, so nothing needs loading. */\nconst ON_EVERY_DEVICE = new Set([...GENERIC, '-apple-system', 'blinkmacsystemfont', 'segoe ui', 'helvetica', 'helvetica neue', 'arial', 'georgia', 'times new roman', 'cambria', 'courier new', 'verdana', 'tahoma', 'trebuchet ms']);\n\n/** The weights Strata's components use: body, medium labels, semibold and bold headings. */\nexport const FONT_WEIGHTS = ['400', '500', '600', '700'] as const;\n\nconst unquote = (s: string) => s.trim().replace(/^['\"]|['\"]$/g, '').trim();\nconst quote = (s: string) => (GENERIC.has(s.toLowerCase()) || s.startsWith('-') || /^[a-z0-9-]+$/i.test(s) ? s : JSON.stringify(s));\n\n/** The families in a `font-family` value, unquoted, in order. */\nexport function fontFamilies(value: string | undefined): string[] {\n return (value ?? '').split(',').map(unquote).filter(Boolean);\n}\n\n/** The family a brand means: the first one named. */\nexport function primaryFamily(value: string | undefined): string {\n return fontFamilies(value)[0] ?? '';\n}\n\n/**\n * A `font-family` value that never ends in the browser's default. The families\n * the brand names come first, exactly as named; a generic fallback is added\n * when none is there.\n */\nexport function fontStack(value: string | undefined, fallback: 'sans' | 'serif' = 'sans'): string {\n const named = fontFamilies(value);\n if (named.some((f) => GENERIC.has(f.toLowerCase()))) return named.map(quote).join(', ');\n const stack = fontFamilies(fallback === 'serif' ? SYSTEM_SERIF : SYSTEM_SANS);\n const seen = new Set(named.map((f) => f.toLowerCase()));\n return [...named, ...stack.filter((f) => !seen.has(f.toLowerCase()))].map(quote).join(', ');\n}\n\nexport type FontStatus =\n | { kind: 'system'; family: string }\n | { kind: 'loaded'; family: string; weights: string[]; missingWeights: string[] }\n | { kind: 'missing'; family: string };\n\n/** Whether pages will draw the family a brand names, and which weights it has files for. */\nexport function fontStatus(value: string | undefined, webFonts: readonly WebFont[] = []): FontStatus {\n const family = primaryFamily(value);\n if (!family || ON_EVERY_DEVICE.has(family.toLowerCase())) return { kind: 'system', family: family || 'system-ui' };\n // A face found on a partner's site is recorded without a file until someone with the right to upload it does.\n const faces = webFonts.filter((f) => f.url && f.family.toLowerCase() === family.toLowerCase() && (f.style ?? 'normal') === 'normal');\n if (!faces.length) return { kind: 'missing', family };\n // A face with no weight, or a range such as \"100 900\", is a variable font and covers them all.\n const covers = (w: string) => faces.some((f) => !f.weight || f.weight === w || (/^\\d+ \\d+$/.test(f.weight) && Number(f.weight.split(' ')[0]) <= Number(w) && Number(w) <= Number(f.weight.split(' ')[1])));\n const weights = FONT_WEIGHTS.filter(covers);\n return { kind: 'loaded', family, weights, missingWeights: FONT_WEIGHTS.filter((w) => !covers(w)) };\n}\n\nexport interface OpenFont { family: string; category: 'sans' | 'serif' }\n\n/**\n * Open-licence families Strata fetches and stores itself, so a customer's\n * browser loads them from Strata and never calls a third party.\n */\nexport const OPEN_FONTS: readonly OpenFont[] = [\n { family: 'Inter', category: 'sans' },\n { family: 'Roboto', category: 'sans' },\n { family: 'Open Sans', category: 'sans' },\n { family: 'Lato', category: 'sans' },\n { family: 'Montserrat', category: 'sans' },\n { family: 'Poppins', category: 'sans' },\n { family: 'Nunito Sans', category: 'sans' },\n { family: 'Source Sans 3', category: 'sans' },\n { family: 'Work Sans', category: 'sans' },\n { family: 'DM Sans', category: 'sans' },\n { family: 'IBM Plex Sans', category: 'sans' },\n { family: 'Manrope', category: 'sans' },\n { family: 'Plus Jakarta Sans', category: 'sans' },\n { family: 'Figtree', category: 'sans' },\n { family: 'Raleway', category: 'sans' },\n { family: 'Merriweather', category: 'serif' },\n { family: 'Lora', category: 'serif' },\n { family: 'Playfair Display', category: 'serif' },\n { family: 'Source Serif 4', category: 'serif' },\n { family: 'IBM Plex Serif', category: 'serif' },\n];\n\n/** The open font of that name, if Strata can fetch it. */\nexport const openFont = (family: string): OpenFont | undefined => OPEN_FONTS.find((f) => f.family.toLowerCase() === family.trim().toLowerCase());\n","/**\n * Contrast maths, to WCAG 2.x.\n *\n * This file exists because of one decision: a partner never authors a text\n * colour to sit on a background ([ADR 0010](https://github.com/matthill8286/strata/blob/main/docs/decisions/0010-what-a-brand-may-set.md)).\n * They pick a brand colour and the system picks what reads on top of it. That\n * makes the most common white-label accessibility failure — a mid-tone brand\n * colour under a white label — unrepresentable rather than merely discouraged.\n *\n * The formulae are from WCAG 2.2 (relative luminance, and the (L1+0.05)/(L2+0.05)\n * contrast ratio). They are stable, cheap and exactly what an auditor will use.\n * APCA is better maths and is not normative yet; when it is, this is the one\n * file that changes.\n */\n\n/** A colour this module can reason about: #rgb, #rrggbb, or #rrggbbaa. */\nexport type Hex = string;\n\nexport interface Rgb {\n r: number;\n g: number;\n b: number;\n}\n\nconst HEX = /^#?([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i;\n\n/**\n * Parse a hex colour. Returns null rather than throwing: callers are usually\n * validating authored content, where \"this is not a colour\" is a message to an\n * editor and not an exception.\n */\nexport function parseHex(value: string): Rgb | null {\n const m = HEX.exec(value.trim());\n if (!m) return null;\n let h = m[1];\n if (h.length === 3) h = h.split('').map((c) => c + c).join('');\n return {\n r: parseInt(h.slice(0, 2), 16),\n g: parseInt(h.slice(2, 4), 16),\n b: parseInt(h.slice(4, 6), 16),\n };\n}\n\nexport function toHex({ r, g, b }: Rgb): Hex {\n const c = (n: number) => Math.round(Math.min(255, Math.max(0, n))).toString(16).padStart(2, '0');\n return `#${c(r)}${c(g)}${c(b)}`;\n}\n\n/** WCAG relative luminance. */\nexport function luminance(rgb: Rgb): number {\n const channel = (v: number) => {\n const s = v / 255;\n return s <= 0.03928 ? s / 12.92 : ((s + 0.055) / 1.055) ** 2.4;\n };\n return 0.2126 * channel(rgb.r) + 0.7152 * channel(rgb.g) + 0.0722 * channel(rgb.b);\n}\n\n/** WCAG contrast ratio, 1–21. Returns 0 for anything unparseable. */\nexport function contrastRatio(a: string, b: string): number {\n const ra = parseHex(a);\n const rb = parseHex(b);\n if (!ra || !rb) return 0;\n const la = luminance(ra);\n const lb = luminance(rb);\n const [hi, lo] = la > lb ? [la, lb] : [lb, la];\n return (hi + 0.05) / (lo + 0.05);\n}\n\n/** The thresholds, named, so call sites read as the criterion they enforce. */\nexport const AA_TEXT = 4.5;\nexport const AA_LARGE_TEXT = 3;\n/** 1.4.11 Non-text Contrast: UI components and meaningful graphics. */\nexport const AA_NON_TEXT = 3;\n\n/**\n * The two foregrounds anything may be drawn in.\n *\n * Not pure black and white. Pure black on a light surface is harsher than it\n * needs to be and pure white on a saturated brand colour haloes; these are the\n * near-neutrals most systems settle on, and they still clear 4.5:1 against\n * every surface the inputs can produce — which the tests assert rather than\n * assume.\n */\nexport const FOREGROUND_DARK = '#1a1a1a';\nexport const FOREGROUND_LIGHT = '#ffffff';\n\n/**\n * Pick the foreground that reads best on `background`.\n *\n * Deliberately returns the BETTER of the two rather than the first that passes.\n * On a mid-tone brand colour both may clear 4.5:1 and the winner is still\n * visibly easier to read; on a colour where neither passes, the better one is\n * what gets rendered while the publish check reports the failure. A caller that\n * needs to know whether it passed asks `contrastRatio` — this function always\n * answers.\n */\nexport function pickForeground(background: string): Hex {\n const dark = contrastRatio(background, FOREGROUND_DARK);\n const light = contrastRatio(background, FOREGROUND_LIGHT);\n return dark >= light ? FOREGROUND_DARK : FOREGROUND_LIGHT;\n}\n\n/**\n * Shift a colour toward black or white by `amount` (0–1).\n *\n * This is how every hover, active and subtle state is derived. Mixing in sRGB\n * is not perceptually uniform and a perceptual space would give more even\n * steps; sRGB is used because it is what CSS `color-mix` does, so a value\n * derived here and a value a stylesheet computes agree. Matching the platform\n * matters more here than being slightly more correct than it.\n */\nexport function shade(color: string, amount: number): Hex {\n const rgb = parseHex(color);\n if (!rgb) return color;\n const t = amount < 0 ? 255 : 0;\n const k = Math.abs(amount);\n return toHex({\n r: rgb.r + (t - rgb.r) * k,\n g: rgb.g + (t - rgb.g) * k,\n b: rgb.b + (t - rgb.b) * k,\n });\n}\n\n/** Darken toward black. */\nexport const darken = (color: string, amount: number): Hex => shade(color, amount);\n/** Lighten toward white. */\nexport const lighten = (color: string, amount: number): Hex => shade(color, -amount);\n\n/**\n * A very light tint of a colour, for subtle backgrounds — an info panel, a\n * selected row. Always light enough to take the dark foreground, which is what\n * makes \"subtle\" a safe surface rather than a guess.\n */\nexport const tint = (color: string): Hex => lighten(color, 0.88);\n\n/** Blend two colours. `amount` is how far from `a` toward `b`. */\nexport function mix(a: string, b: string, amount: number): Hex {\n const ra = parseHex(a);\n const rb = parseHex(b);\n if (!ra || !rb) return a;\n const k = Math.min(1, Math.max(0, amount));\n return toHex({\n r: ra.r + (rb.r - ra.r) * k,\n g: ra.g + (rb.g - ra.g) * k,\n b: ra.b + (rb.b - ra.b) * k,\n });\n}\n\n/**\n * Walk a foreground away from its background until it clears `target`.\n *\n * This is the mechanism that makes a derived token safe rather than merely\n * plausible. Muted text, placeholder text and borders are all produced by\n * blending toward a surface, and a blend that looks right on one brand falls\n * under 4.5:1 on the next. Rather than pick a blend that happens to work for\n * the brands we have, each derived value is pushed back until it passes.\n *\n * It moves toward whichever end of the scale is already further from the\n * background, in small steps, and gives up after it runs out of room — at\n * which point the colour is returned as-is and the publish check reports it.\n * Silently returning black would hide a brand that cannot work.\n */\nexport function ensureContrast(foreground: string, background: string, target: number): Hex {\n const fg = parseHex(foreground);\n const bg = parseHex(background);\n if (!fg || !bg) return foreground;\n if (contrastRatio(foreground, background) >= target) return toHex(fg);\n\n const toward = luminance(bg) > 0.5 ? FOREGROUND_DARK : FOREGROUND_LIGHT;\n let current = toHex(fg);\n for (let step = 1; step <= 20; step += 1) {\n current = mix(toHex(fg), toward, step / 20);\n if (contrastRatio(current, background) >= target) return current;\n }\n return current;\n}\n","/**\n * Brand inputs → the semantic tokens components actually read.\n *\n * This is the whole argument of\n * [ADR 0010](https://github.com/matthill8286/strata/blob/main/docs/decisions/0010-what-a-brand-may-set.md) in executable\n * form: around twenty authored values go in, roughly a hundred come out, and\n * the hundred are not authorable. A partner who wants a different hover colour\n * is describing a change to this function, which is a product decision with a\n * version number, rather than a field in a CMS nobody can later prune.\n *\n * Three rules run through it. Foregrounds are always picked by measured\n * contrast, never authored. Anything that carries text is ratcheted until it\n * passes AA rather than trusted to. And the focus ring and the minimum target\n * size are constants, because they are the two things a brand would break first\n * and notice last.\n */\nimport { fontFamilies, fontStack, openFont, primaryFamily } from './fonts';\n\n/** The device's own code faces, after any the brand names. */\nconst MONO_STACK = 'ui-monospace, SFMono-Regular, Menlo, Consolas, \"Liberation Mono\", monospace';\nimport {\n AA_NON_TEXT,\n AA_TEXT,\n darken,\n ensureContrast,\n luminance,\n mix,\n parseHex,\n pickForeground,\n tint,\n} from './contrast';\nimport { BrandInputsSchema, type BrandInputs } from './inputs';\nimport { deriveMotionTokens } from './motion';\n\n/** A flat token set: dotted path → CSS value. */\nexport type TokenSet = Record<string, string>;\n\n/**\n * The locked tokens. A brand cannot reach these and nothing derives them.\n *\n * The focus ring is two-tone — a light inner ring inside a dark outer one — so\n * that it stays visible on any surface a partner can produce, including their\n * own brand colour. A single-colour ring has to assume a background, and the\n * one it assumes is the one a white-label product does not have. This is the\n * rule Scotland's design system states directly: adopters may change the\n * colours, and must still keep the system's colours for focus.\n *\n * `target.min` is WCAG 2.2's 2.5.8 minimum. It is here rather than in the\n * spacing scale so that shrinking the spacing unit cannot shrink a tap target.\n */\nexport const LOCKED_TOKENS: TokenSet = {\n 'focus.ring.inner': '#ffffff',\n 'focus.ring.outer': '#1a1a1a',\n 'focus.ring.width': '2px',\n 'focus.ring.offset': '2px',\n 'focus.ring.shadow': '0 0 0 2px #ffffff, 0 0 0 4px #1a1a1a',\n 'target.min': '24px',\n 'target.spacing': '8px',\n};\n\n/** Spacing steps, as multiples of the base unit. */\n/**\n * The spacing scale: each step is that many quarters of the brand's base unit,\n * so with a 4px base `space.4` is 16px and `space.12` is 48px. Every step is a\n * whole multiple, which is what keeps a page on its grid: two things that are\n * `space.6` apart line up with anything else that is.\n */\nexport const SPACE_SCALE = [0, 0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 16, 20, 24, 28, 32, 36, 40, 48, 56, 64, 72, 80, 96] as const;\n\n/** A step's token name: `0.5` is `space.0-5`, since a dot separates the path. */\nexport const spaceName = (step: number) => `space.${String(step).replace('.', '-')}`;\n\n/**\n * The steps a brand's layout names its margins and gutters by, as they were\n * before the scale above. Kept so a stored brand's page frame does not move.\n */\nconst LAYOUT_STEPS: Record<string, number> = {\n '0': 0, '1': 1, '2': 2, '3': 3, '4': 4,\n '5': 6, '6': 8, '7': 12, '8': 16, '9': 24, '10': 32,\n};\n\n/** Type ramp, as powers of the scale ratio either side of the base. */\n/**\n * The type scale against a 16px base, with the line height each size reads\n * best at: tight for display sizes, open for small print. `2xs` is kept for\n * stored work and is the same as `xs`.\n */\nconst TYPE_SCALE: Record<string, { size: number; leading: number }> = {\n '2xs': { size: 12, leading: 16 },\n xs: { size: 12, leading: 16 },\n sm: { size: 14, leading: 20 },\n md: { size: 16, leading: 24 },\n lg: { size: 18, leading: 28 },\n xl: { size: 20, leading: 28 },\n '2xl': { size: 24, leading: 32 },\n '3xl': { size: 30, leading: 36 },\n '4xl': { size: 36, leading: 40 },\n '5xl': { size: 48, leading: 52 },\n '6xl': { size: 60, leading: 64 },\n};\n\n/** Sizes from here up are display type: drawn a little tighter, and stretched by the brand's ratio. */\nconst DISPLAY_FROM = 24;\n\n/**\n * The smallest text the ramp may produce, in px.\n *\n * A 1.333 ratio three steps below a 14px base lands at 5.9px. Clamping here\n * rather than narrowing the ratio keeps the top of the ramp expressive while\n * stopping the bottom from becoming unreadable.\n */\nconst MIN_FONT_PX = 12;\n\n/**\n * The text colour for a branded band — the header, the footer.\n *\n * Not simply the picked foreground, because that throws away real brand\n * expression: Northwind's header is white with dark-purple text, and deriving\n * near-black there would be legible and wrong. On a LIGHT band the accent\n * colour is used, ratcheted until it passes, which is what partners actually\n * do and what every migrated theme authored. On a DARK band the picked\n * foreground wins, because coloured text on a saturated brand background is\n * exactly where legibility goes, and a washed-out tint of the band's own\n * colour is worse than white.\n *\n * An unparseable surface — a gradient — is treated as dark, since a gradient\n * is only allowed on the page and the page is the one band nothing sits on.\n */\nfunction onSurface(surface: string, accent: string): string {\n const rgb = parseHex(surface);\n if (!rgb) return pickForeground('#000000');\n return luminance(rgb) > 0.5 ? ensureContrast(accent, surface, AA_TEXT) : pickForeground(surface);\n}\n\nfunction typeRamp(sizeBase: number, scale: number): TokenSet {\n const out: TokenSet = {};\n // The brand's ratio stretches display type away from the base: 1.25 is the\n // scale as written, a larger ratio makes headings bigger, a smaller one quieter.\n const stretch = Math.max(0.8, Math.min(1.4, scale / 1.25));\n for (const [name, { size, leading }] of Object.entries(TYPE_SCALE)) {\n // Display sizes move with the ratio, more the larger they are; body sizes never do.\n const display = size >= DISPLAY_FROM ? 1 + (stretch - 1) * Math.min(1, (size - 16) / 44) : 1;\n const px = Math.max(MIN_FONT_PX, (size / 16) * sizeBase * display);\n // Round UP at four places. Rounding to nearest loses the 12px floor by a\n // ten-thousandth, which is invisible until a test asserts the floor and\n // fails — and the floor is the accessibility claim, so it rounds its way.\n const rem = Math.ceil((px / sizeBase) * 10000) / 10000;\n out[`font.size.${name}`] = `${rem}rem`;\n out[`font.leading.${name}`] = String(Math.round((leading / size) * 1000) / 1000);\n }\n out['font.tracking.tight'] = '-0.02em';\n out['font.tracking.normal'] = '0em';\n out['font.tracking.wide'] = '0.06em';\n return out;\n}\n\nexport function deriveTokens(input: BrandInputs): TokenSet {\n const { color, font, shape } = input;\n // A brand stored before layout existed has none, and gets the frame pages had then.\n const layout = input.layout ?? BrandInputsSchema.shape.layout.parse(undefined);\n const card = color.surfaceCard;\n const accent = color.accent ?? color.brand;\n\n const tokens: TokenSet = { ...LOCKED_TOKENS };\n\n // --- surfaces ------------------------------------------------------------\n // `page` is the only one that may be a gradient, and the only one nothing is\n // read against. `inset` is for wells and disabled fields: a step away from\n // the card in whichever direction the card is not.\n tokens['color.surface.page'] = color.surfacePage;\n tokens['color.surface.card'] = card;\n tokens['color.surface.header'] = color.surfaceHeader;\n tokens['color.surface.footer'] = color.surfaceFooter;\n tokens['color.surface.subtle'] = tint(color.brand);\n tokens['color.surface.inset'] = mix(card, pickForeground(card), 0.05);\n\n // --- brand ---------------------------------------------------------------\n // Hover and active are tone shifts rather than authored colours. The\n // direction is fixed: darker on interaction, because a lighter hover on a\n // light surface reads as disabled.\n tokens['color.brand.default'] = color.brand;\n tokens['color.brand.hover'] = darken(color.brand, 0.12);\n tokens['color.brand.active'] = darken(color.brand, 0.24);\n tokens['color.brand.subtle'] = tint(color.brand);\n tokens['color.brand.on'] = pickForeground(color.brand);\n\n tokens['color.accent.default'] = accent;\n tokens['color.accent.hover'] = darken(accent, 0.12);\n tokens['color.accent.on'] = pickForeground(accent);\n\n // --- text ----------------------------------------------------------------\n // Muted and placeholder are blends toward the surface, then ratcheted back\n // until they clear AA. Placeholder is included deliberately: it is routinely\n // treated as exempt and 1.4.3 does not exempt it.\n tokens['color.text.default'] = ensureContrast(color.text, card, AA_TEXT);\n tokens['color.text.muted'] = ensureContrast(mix(color.text, card, 0.38), card, AA_TEXT);\n tokens['color.text.placeholder'] = ensureContrast(mix(color.text, card, 0.5), card, AA_TEXT);\n tokens['color.text.on-brand'] = pickForeground(color.brand);\n // A brand that names its header or footer text gets it, raised until it is readable on the band.\n tokens['color.text.on-header'] = color.textHeader ? ensureContrast(color.textHeader, color.surfaceHeader, AA_TEXT) : onSurface(color.surfaceHeader, accent);\n tokens['color.text.on-footer'] = color.textFooter ? ensureContrast(color.textFooter, color.surfaceFooter, AA_TEXT) : onSurface(color.surfaceFooter, accent);\n // A link is the brand colour where that is readable, and a darkened brand\n // colour where it is not — so a partner with a pale brand still gets links\n // that look like theirs.\n // Headings take the accent colour. The legacy schema had an authored\n // `typography.headingColor`, and on every migrated theme it was the secondary\n // colour — so deriving it reproduces them exactly and removes a field whose\n // only job was to restate another one.\n tokens['color.text.heading'] = ensureContrast(color.textHeading ?? accent, card, AA_TEXT);\n // A categorical palette, each kept clear of the card as a line or a dot must be.\n const chart = color.chart?.length ? color.chart : [accent, color.info, color.success, color.warning, color.danger];\n chart.forEach((c, i) => { tokens[`color.chart.${i + 1}`] = ensureContrast(c, card, AA_NON_TEXT); });\n tokens['color.text.link'] = ensureContrast(color.brand, card, AA_TEXT);\n tokens['color.text.link-hover'] = darken(tokens['color.text.link'], 0.2);\n\n // --- borders -------------------------------------------------------------\n // 1.4.11 governs these: a field border is a UI component boundary, so 3:1,\n // not 4.5:1.\n tokens['color.border.default'] = ensureContrast(mix(color.text, card, 0.7), card, AA_NON_TEXT);\n tokens['color.border.strong'] = ensureContrast(mix(color.text, card, 0.45), card, AA_NON_TEXT);\n // A filled field still has an edge that clears 3:1, so it reads as a place to type (1.4.11).\n if (shape.fields === 'filled') {\n tokens['color.field.surface'] = mix(card, pickForeground(card), 0.05);\n tokens['color.field.border'] = tokens['color.border.default']!;\n tokens['shadow.field'] = 'none';\n }\n if (shape.buttonHover === 'accent') {\n tokens['color.action.hover'] = accent;\n tokens['color.action.on-hover'] = pickForeground(accent);\n tokens['motion.button.turn'] = '-45deg';\n }\n\n // --- status --------------------------------------------------------------\n // Each gets three: the colour itself at UI contrast, a tint to sit behind it,\n // and the foreground that reads on it. `*.text` is separate from `*.default`\n // because the same red that is fine as a 3:1 border is not fine as 4.5:1 body\n // text, and conflating them is how error messages end up unreadable.\n for (const name of ['danger', 'warning', 'success', 'info'] as const) {\n const base = color[name];\n tokens[`color.status.${name}.default`] = ensureContrast(base, card, AA_NON_TEXT);\n tokens[`color.status.${name}.text`] = ensureContrast(base, card, AA_TEXT);\n tokens[`color.status.${name}.subtle`] = tint(base);\n tokens[`color.status.${name}.on`] = pickForeground(base);\n }\n\n // --- typography ----------------------------------------------------------\n // A family the device lacks and the brand does not load would fall back to Times, so each is followed by a stack.\n const fallbackFor = (value: string) => (openFont(primaryFamily(value))?.category === 'serif' ? 'serif' : 'sans');\n tokens['font.family.body'] = fontStack(font.body, fallbackFor(font.body));\n tokens['font.family.heading'] = fontStack(font.heading ?? font.body, fallbackFor(font.heading ?? font.body));\n tokens['font.family.mono'] = font.mono ? `${fontFamilies(font.mono).map((f) => JSON.stringify(f)).join(', ')}, ${MONO_STACK}` : MONO_STACK;\n tokens['font.family.eyebrow'] = font.eyebrow === 'mono' ? tokens['font.family.mono'] : tokens['font.family.body'];\n // A code-style eyebrow is a quiet label, as a changelog's is: small, muted and medium weight.\n if (font.eyebrow === 'mono') {\n tokens['color.text.eyebrow'] = tokens['color.text.muted']!;\n tokens['font.weight.eyebrow'] = '500';\n tokens['font.size.eyebrow'] = '0.6875rem';\n }\n tokens['font.size.root'] = `${font.sizeBase}px`;\n Object.assign(tokens, typeRamp(font.sizeBase, font.scale));\n tokens['font.weight.regular'] = '400';\n tokens['font.weight.medium'] = '500';\n tokens['font.weight.semibold'] = '600';\n tokens['font.weight.bold'] = '700';\n // 1.4.8 asks for 1.5 within a paragraph; `tight` is for headings, where it\n // does not apply.\n tokens['font.line-height.tight'] = '1.25';\n tokens['font.line-height.normal'] = '1.5';\n tokens['font.line-height.relaxed'] = '1.75';\n\n // --- space, radius, border width -----------------------------------------\n for (const step of SPACE_SCALE) tokens[spaceName(step)] = `${shape.spaceBase * step}px`;\n // Radii in steps from the brand's base, which is the medium one: a sharp\n // brand keeps everything square, a soft one rounds everything together.\n const r = (multiple: number) => `${Math.round(shape.radiusBase * multiple * 10) / 10}px`;\n tokens['radius.none'] = '0';\n tokens['radius.xs'] = r(1 / 3);\n tokens['radius.sm'] = r(2 / 3);\n tokens['radius.md'] = r(1);\n tokens['radius.lg'] = r(4 / 3);\n tokens['radius.xl'] = r(2);\n tokens['radius.2xl'] = r(8 / 3);\n tokens['radius.3xl'] = r(4);\n tokens['radius.full'] = '9999px';\n // Shadows, from a hairline to a lifted dialog. Tinted with the text colour so\n // they sit on a warm or cool page rather than looking pasted on.\n const ink = parseHex(color.text) ? color.text : '#000000';\n const a = (alpha: number) => `color-mix(in srgb, ${ink} ${Math.round(alpha * 100)}%, transparent)`;\n tokens['shadow.xs'] = `0 1px 2px 0 ${a(0.05)}`;\n tokens['shadow.sm'] = `0 1px 3px 0 ${a(0.1)}, 0 1px 2px -1px ${a(0.1)}`;\n tokens['shadow.md'] = `0 4px 6px -1px ${a(0.1)}, 0 2px 4px -2px ${a(0.1)}`;\n tokens['shadow.lg'] = `0 10px 15px -3px ${a(0.1)}, 0 4px 6px -4px ${a(0.1)}`;\n tokens['shadow.xl'] = `0 20px 25px -5px ${a(0.1)}, 0 8px 10px -6px ${a(0.1)}`;\n tokens['border.width.thin'] = `${shape.borderWidth}px`;\n tokens['border.width.thick'] = `${shape.borderWidth * 2}px`;\n\n // --- layout: the page frame and the gutters between columns ----------------\n const step = (name: string) => `${shape.spaceBase * (LAYOUT_STEPS[name] ?? 0)}px`;\n tokens['layout.page.width'] = `${layout.pageWidth}px`;\n tokens['layout.margin.phone'] = step(layout.margin.phone);\n tokens['layout.margin.tablet'] = step(layout.margin.tablet);\n tokens['layout.margin.desktop'] = step(layout.margin.desktop);\n tokens['layout.gutter.sm'] = step(layout.gutter.sm);\n tokens['layout.gutter.md'] = step(layout.gutter.md);\n tokens['layout.gutter.lg'] = step(layout.gutter.lg);\n\n Object.assign(tokens, deriveMotionTokens(input.motion, input.shape?.spaceBase ?? 4));\n\n return tokens;\n}\n","/**\n * A brand as design-tool variables, and back.\n *\n * Figma, and tools like it, keep a design system's values as variables in\n * collections. This turns a partner's brand into two collections: the inputs a\n * designer may change, and the tokens Strata derives from them, which are\n * there to design with and are never read back. Changes come back as a patch\n * to the brand inputs, checked by the same schema as any other edit, so\n * nothing Strata would refuse in the CMS gets in through a design file.\n *\n * Plain JSON with no Figma types, so the plugin, the delivery API and the CMS\n * share it, and it is tested without Figma.\n */\nimport { BrandInputsSchema, SPACE_STEP_NAMES, type BrandInputs } from './inputs';\nimport { deriveTokens } from './derive';\n\nexport const VARIABLES_FORMAT = 'strata.brand-variables';\nexport const VARIABLES_VERSION = 1;\n\nexport type VariableType = 'COLOR' | 'FLOAT' | 'STRING';\n\n/** One variable. `name` uses `/` for groups, as Figma does; `path` is where it lives in Strata. */\nexport interface BrandVariable {\n name: string;\n path: string;\n type: VariableType;\n value: string | number;\n description?: string;\n}\n\nexport interface BrandVariables {\n format: typeof VARIABLES_FORMAT;\n version: typeof VARIABLES_VERSION;\n /** The site the brand belongs to, so a file says which partner it is. */\n site: string;\n /** What a designer may change, and what Strata reads back. */\n inputs: BrandVariable[];\n /** Worked out from the inputs. To design with; ignored when read back. */\n derived: BrandVariable[];\n}\n\n/** The spacing multiples the scale's step names stand for. */\nconst STEP_MULTIPLES: Record<string, number> = { '0': 0, '1': 1, '2': 2, '3': 3, '4': 4, '5': 6, '6': 8, '7': 12, '8': 16, '9': 24, '10': 32 };\n\nconst HEX = /^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/;\n\ninterface InputSpec {\n path: string;\n name: string;\n /** A spacing step, shown to a designer in pixels at the brand's spacing unit. */\n step?: boolean;\n description?: string;\n}\n\n/** The inputs a design tool may hold, in the order a designer meets them. Assets and web fonts stay in the CMS. */\nconst INPUTS: InputSpec[] = [\n { path: 'color.brand', name: 'color/brand' },\n { path: 'color.accent', name: 'color/accent' },\n { path: 'color.surfacePage', name: 'color/surface/page', description: 'May be a gradient; carries no text.' },\n { path: 'color.surfaceCard', name: 'color/surface/card' },\n { path: 'color.surfaceHeader', name: 'color/surface/header' },\n { path: 'color.surfaceFooter', name: 'color/surface/footer' },\n { path: 'color.text', name: 'color/text' },\n { path: 'color.danger', name: 'color/status/danger' },\n { path: 'color.warning', name: 'color/status/warning' },\n { path: 'color.success', name: 'color/status/success' },\n { path: 'color.info', name: 'color/status/info' },\n { path: 'font.body', name: 'font/body' },\n { path: 'font.heading', name: 'font/heading' },\n { path: 'font.sizeBase', name: 'font/size-base', description: 'Root size in px, 14 to 20.' },\n { path: 'font.scale', name: 'font/scale', description: 'Type ramp ratio, 1.067 to 1.333.' },\n { path: 'shape.radiusBase', name: 'shape/radius', description: 'Corner radius in px, 0 to 24.' },\n { path: 'shape.spaceBase', name: 'shape/space-unit', description: 'The spacing unit in px, 2 to 8.' },\n { path: 'shape.borderWidth', name: 'shape/border-width', description: 'Border weight in px, 1 to 3.' },\n { path: 'layout.pageWidth', name: 'layout/page-width', description: 'Widest content in px, 640 to 1600.' },\n { path: 'layout.margin.phone', name: 'layout/margin/phone', step: true },\n { path: 'layout.margin.tablet', name: 'layout/margin/tablet', step: true },\n { path: 'layout.margin.desktop', name: 'layout/margin/desktop', step: true },\n { path: 'layout.gutter.sm', name: 'layout/gutter/sm', step: true },\n { path: 'layout.gutter.md', name: 'layout/gutter/md', step: true },\n { path: 'layout.gutter.lg', name: 'layout/gutter/lg', step: true },\n];\n\nconst STEP_HINT = 'A step on the spacing scale, in px: a multiple of the space unit (1, 2, 3, 4, 6, 8, 12, 16, 24 or 32 times).';\n\nconst read = (source: unknown, path: string): unknown =>\n path.split('.').reduce<unknown>((at, key) => (at && typeof at === 'object' ? (at as Record<string, unknown>)[key] : undefined), source);\n\nfunction write(target: Record<string, unknown>, path: string, value: unknown) {\n const keys = path.split('.');\n let at = target;\n for (const key of keys.slice(0, -1)) at = (at[key] ??= {}) as Record<string, unknown>;\n at[keys[keys.length - 1]!] = value;\n}\n\n/** A partner's brand as variables: its inputs, and the tokens derived from them. */\nexport function brandToVariables(brand: BrandInputs, site: string): BrandVariables {\n const inputs = BrandInputsSchema.parse(brand);\n const unit = inputs.shape.spaceBase;\n const fromInputs: BrandVariable[] = [];\n for (const spec of INPUTS) {\n let value = read(inputs, spec.path);\n // An unset accent or heading font means \"the same as the brand colour or body font\".\n if (value === undefined && spec.path === 'color.accent') value = inputs.color.brand;\n if (value === undefined && spec.path === 'font.heading') value = inputs.font.body;\n if (value === undefined) continue;\n if (spec.step) {\n fromInputs.push({ name: spec.name, path: spec.path, type: 'FLOAT', value: unit * (STEP_MULTIPLES[String(value)] ?? 0), description: STEP_HINT });\n continue;\n }\n const type: VariableType = typeof value === 'number' ? 'FLOAT' : spec.path.startsWith('color.') && HEX.test(String(value)) ? 'COLOR' : 'STRING';\n fromInputs.push({ name: spec.name, path: spec.path, type, value: value as string | number, ...(spec.description ? { description: spec.description } : {}) });\n }\n\n const derived: BrandVariable[] = [];\n for (const [path, value] of Object.entries(deriveTokens(inputs))) {\n const name = path.replace(/\\./g, '/');\n if (HEX.test(value)) derived.push({ name, path, type: 'COLOR', value });\n else if (/^-?[\\d.]+px$/.test(value)) derived.push({ name, path, type: 'FLOAT', value: Number.parseFloat(value) });\n else if (/^-?[\\d.]+$/.test(value)) derived.push({ name, path, type: 'FLOAT', value: Number(value) });\n else derived.push({ name, path, type: 'STRING', value });\n }\n return { format: VARIABLES_FORMAT, version: VARIABLES_VERSION, site, inputs: fromInputs, derived };\n}\n\nexport interface VariableChange {\n path: string;\n name: string;\n from: unknown;\n to: unknown;\n /** The change as a designer reads it: a spacing step in pixels rather than by its name. */\n shown: { from: string; to: string };\n}\n\nexport type VariablesImport =\n | { ok: true; inputs: BrandInputs; changes: VariableChange[] }\n | { ok: false; problems: string[] };\n\n/**\n * Read variables back onto a brand.\n *\n * Only the inputs are read; derived tokens are worked out again, never\n * copied. A spacing step comes back from pixels to the step it names, and a\n * value that is not one of the steps is refused rather than rounded, because\n * rounding would quietly change the designer's layout.\n */\nexport function variablesToBrand(document: unknown, base: BrandInputs): VariablesImport {\n const doc = document as Partial<BrandVariables> | null;\n if (!doc || doc.format !== VARIABLES_FORMAT || !Array.isArray(doc.inputs)) {\n return { ok: false, problems: ['This is not a Strata brand variables export.'] };\n }\n const current = BrandInputsSchema.parse(base);\n const next = structuredClone(current) as unknown as Record<string, unknown>;\n const problems: string[] = [];\n const changes: VariableChange[] = [];\n const unitVariable = doc.inputs.find((v) => v.path === 'shape.spaceBase');\n const unit = typeof unitVariable?.value === 'number' ? unitVariable.value : current.shape.spaceBase;\n\n for (const variable of doc.inputs) {\n const spec = INPUTS.find((s) => s.path === variable?.path);\n if (!spec) continue;\n let value: unknown = variable.value;\n // Figma keeps numbers as 32-bit floats, so 1.2 comes back as 1.2000000476837158.\n if (typeof value === 'number') value = Math.round(value * 10_000) / 10_000;\n if (spec.step) {\n const step = typeof value === 'number' ? SPACE_STEP_NAMES.find((name) => unit * (STEP_MULTIPLES[name] ?? -1) === value) : undefined;\n if (!step) { problems.push(`${spec.name} is ${String(value)}px, which is not a step on the spacing scale at a ${unit}px unit.`); continue; }\n value = step;\n }\n if (typeof value === 'string' && spec.path.startsWith('color.') && HEX.test(value)) value = value.toLowerCase();\n const was = read(current, spec.path);\n write(next, spec.path, value);\n const comparable = (v: unknown) => (typeof v === 'string' ? v.toLowerCase() : v);\n if (comparable(was) !== comparable(value) && !(was === undefined && (spec.path === 'color.accent' || spec.path === 'font.heading') && value === (spec.path === 'color.accent' ? current.color.brand : current.font.body))) {\n const show = (v: unknown, at: number) => (v === undefined ? 'not set' : spec.step ? `${at * (STEP_MULTIPLES[String(v)] ?? 0)}px` : String(v));\n changes.push({ path: spec.path, name: spec.name, from: was, to: value, shown: { from: show(was, current.shape.spaceBase), to: show(value, unit) } });\n }\n }\n // Check everything else too, so a designer sees every problem in one go rather than one round at a time.\n // A value refused above was never written, so it cannot be reported twice.\n const parsed = BrandInputsSchema.safeParse(next);\n if (!parsed.success) {\n for (const issue of parsed.error.issues) {\n const path = issue.path.join('.');\n const spec = INPUTS.find((s) => s.path === path);\n if (!spec) { problems.push(`${path}: ${issue.message}`); continue; }\n const sent = doc.inputs.find((v) => v?.path === path)?.value;\n problems.push(`${spec.name} is ${JSON.stringify(sent)}. ${issue.message.replace(/\\.?$/, '.')}`);\n }\n }\n if (problems.length || !parsed.success) return { ok: false, problems };\n return { ok: true, inputs: parsed.data, changes };\n}\n\n/** Each input variable's name, as a design tool shows it, and where it lives in Strata. A plugin reads variables back by name. */\nexport const INPUT_VARIABLE_PATHS: Readonly<Record<string, string>> = Object.fromEntries(INPUTS.map((spec) => [spec.name, spec.path]));\n","/**\n * The contrast gate.\n *\n * Derivation means most pairs cannot fail — a foreground is picked by measured\n * contrast and a blend is ratcheted until it passes. What is left are the pairs\n * a partner controls both sides of: their brand colour against their own\n * surfaces, their text against their own card, and their status colours\n * against it. Those are checked here, and a failure blocks a publish the way a\n * dangling reference already does\n * ([ADR 0009](https://github.com/matthill8286/strata/blob/main/docs/decisions/0009-wcag-is-an-authoring-gate.md)).\n *\n * This is a floor, not a certificate. It is arithmetic over colour pairs: it\n * cannot see a value rendered on an image, text baked into a logo, or a\n * disabled control whose contrast is exempt but whose meaning is not. Treating\n * a green build as \"the brand is accessible\" is the failure mode to guard\n * against, which is why the result says what it checked.\n */\nimport { AA_NON_TEXT, AA_TEXT, contrastRatio, parseHex } from './contrast';\nimport { deriveTokens, type TokenSet } from './derive';\nimport type { BrandInputs } from './inputs';\n\nexport interface ContrastIssue {\n /** The token that fails, as an editor would be shown it. */\n token: string;\n foreground: string;\n background: string;\n ratio: number;\n required: number;\n /** The WCAG criterion, so the message can cite it. */\n criterion: '1.4.3 Contrast (Minimum)' | '1.4.11 Non-text Contrast';\n message: string;\n}\n\nexport interface ContrastReport {\n ok: boolean;\n issues: ContrastIssue[];\n /** How many pairs were examined — the honest denominator. */\n checked: number;\n}\n\ninterface Pair {\n token: string;\n fg: string;\n bg: string;\n required: number;\n criterion: ContrastIssue['criterion'];\n what: string;\n}\n\n/**\n * A gradient has no single luminance, so it is skipped rather than guessed at.\n * Safe because nothing is read directly against the page surface — the one\n * place a gradient is allowed.\n */\nconst isMeasurable = (value: string): boolean => parseHex(value) !== null;\n\nfunction pairsFor(tokens: TokenSet): Pair[] {\n const card = tokens['color.surface.card'];\n const text = (t: string) => ({ required: AA_TEXT, criterion: '1.4.3 Contrast (Minimum)' as const, what: t });\n const ui = (t: string) => ({ required: AA_NON_TEXT, criterion: '1.4.11 Non-text Contrast' as const, what: t });\n\n const pairs: Pair[] = [\n { token: 'color.text.default', fg: tokens['color.text.default'], bg: card, ...text('Body text on a card') },\n { token: 'color.text.muted', fg: tokens['color.text.muted'], bg: card, ...text('Muted text on a card') },\n { token: 'color.text.placeholder', fg: tokens['color.text.placeholder'], bg: card, ...text('Placeholder text in a field') },\n { token: 'color.text.link', fg: tokens['color.text.link'], bg: card, ...text('A link on a card') },\n { token: 'color.text.on-brand', fg: tokens['color.text.on-brand'], bg: tokens['color.brand.default'], ...text('Text on a brand-coloured button') },\n { token: 'color.text.on-header', fg: tokens['color.text.on-header'], bg: tokens['color.surface.header'], ...text('Text in the header') },\n { token: 'color.text.on-footer', fg: tokens['color.text.on-footer'], bg: tokens['color.surface.footer'], ...text('Text in the footer') },\n { token: 'color.brand.default', fg: tokens['color.brand.default'], bg: card, ...ui('A brand-coloured control against a card') },\n { token: 'color.border.default', fg: tokens['color.border.default'], bg: card, ...ui('A field border against a card') },\n ];\n\n for (const name of ['danger', 'warning', 'success', 'info']) {\n pairs.push({\n token: `color.status.${name}.text`,\n fg: tokens[`color.status.${name}.text`],\n bg: card,\n ...text(`${name[0].toUpperCase()}${name.slice(1)} message text`),\n });\n pairs.push({\n token: `color.status.${name}.default`,\n fg: tokens[`color.status.${name}.default`],\n bg: card,\n ...ui(`The ${name} indicator against a card`),\n });\n }\n\n return pairs;\n}\n\n/** Check a derived token set. */\nexport function checkContrast(tokens: TokenSet): ContrastReport {\n const issues: ContrastIssue[] = [];\n let checked = 0;\n\n for (const pair of pairsFor(tokens)) {\n if (!isMeasurable(pair.fg) || !isMeasurable(pair.bg)) continue;\n checked += 1;\n const ratio = contrastRatio(pair.fg, pair.bg);\n if (ratio >= pair.required) continue;\n issues.push({\n token: pair.token,\n foreground: pair.fg,\n background: pair.bg,\n ratio: Math.round(ratio * 100) / 100,\n required: pair.required,\n criterion: pair.criterion,\n message:\n `${pair.what} is ${(Math.round(ratio * 100) / 100).toFixed(2)}:1, ` +\n `below the ${pair.required}:1 that ${pair.criterion} requires.`,\n });\n }\n\n return { ok: issues.length === 0, issues, checked };\n}\n\n/** Check a brand before its tokens exist. What the CMS editor calls. */\nexport const checkBrandContrast = (input: BrandInputs): ContrastReport =>\n checkContrast(deriveTokens(input));\n","/**\n * Tokens → the W3C Design Tokens Community Group format.\n *\n * An OUTPUT, not the source. ADR 0005 originally had tokens authored as DTCG\n * files and built by Style Dictionary; writing the derivation showed why that\n * cannot be the whole story. A partner's tokens are computed at runtime from a\n * published brand document, so the authoring format has to be code — a\n * build-time pipeline can only ever produce the house theme, and a second\n * emitter for the runtime path would drift from it.\n *\n * So the format is kept as an export. It is what Figma, Style Dictionary and\n * the token tooling read, which is what makes a design-tool round trip a thing\n * we can add later rather than a rewrite, and it costs one function.\n */\nimport type { TokenSet } from './derive';\n\nexport type DtcgType = 'color' | 'dimension' | 'fontFamily' | 'fontWeight' | 'number' | 'shadow' | 'duration' | 'cubicBezier' | 'string';\n\ninterface DtcgToken {\n $type: DtcgType;\n $value: string;\n $description?: string;\n}\n\nexport type DtcgGroup = { [key: string]: DtcgGroup | DtcgToken };\n\n/**\n * Infer the type from the token's path and value.\n *\n * By path first, because a value alone is ambiguous — `\"400\"` is a font weight\n * and `\"2px\"` is a dimension and both are strings. The paths are ours, so this\n * is reading our own naming convention rather than guessing.\n */\nfunction typeOf(path: string, value: string): DtcgType {\n if (path.startsWith('motion.')) {\n if (/ms$/.test(value)) return 'duration';\n if (value.startsWith('cubic-bezier(')) return 'cubicBezier';\n if (value.startsWith('linear(')) return 'string';\n if (/px$/.test(value)) return 'dimension';\n return 'number';\n }\n if (path.startsWith('color.') || path.startsWith('focus.ring.') && !/width|offset|shadow/.test(path)) return 'color';\n if (path.includes('font.family')) return 'fontFamily';\n if (path.includes('font.weight')) return 'fontWeight';\n if (path.includes('line-height')) return 'number';\n if (path.includes('shadow')) return 'shadow';\n if (/^-?[\\d.]+(px|rem|em|%)$/.test(value) || value === '0') return 'dimension';\n return 'color';\n}\n\n/** A flat token set as a nested DTCG document. */\nexport function toDtcg(tokens: TokenSet): DtcgGroup {\n const root: DtcgGroup = {};\n for (const [path, value] of Object.entries(tokens)) {\n const parts = path.split('.');\n const leaf = parts.pop() as string;\n let node = root;\n for (const part of parts) {\n if (!(part in node) || '$value' in (node[part] as DtcgToken)) node[part] = {} as DtcgGroup;\n node = node[part] as DtcgGroup;\n }\n node[leaf] = { $type: typeOf(path, value), $value: value };\n }\n return root;\n}\n"],"mappings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