@becket-ui/mcp 0.0.0-stage → 0.5.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.
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../tokens/theme/color.mjs","../../tokens/theme/contrast.mjs","../../tokens/theme/derive.mjs","../../tokens/theme/index.mjs","../src/theme/extractColors.ts"],"sourcesContent":["/**\n * Color parsing, OKLCH conversion and WCAG 2 contrast. Shared by the contrast test, the theme\n * checker and palette derivation so every one of them measures with the same math.\n */\n\n/** @param {number} value */\nconst clamp01 = (value) => Math.min(1, Math.max(0, value));\n\n/** sRGB channel (0–1) → linear light. */\nfunction toLinear(channel) {\n return channel <= 0.04045 ? channel / 12.92 : ((channel + 0.055) / 1.055) ** 2.4;\n}\n\n/** Linear sRGB → OKLCH (CSS Color 4). */\nfunction linearToOklch([r, g, b]) {\n const l = Math.cbrt(0.4122214708 * r + 0.5363325363 * g + 0.0514459929 * b);\n const m = Math.cbrt(0.2119034982 * r + 0.6806995451 * g + 0.1073969566 * b);\n const s = Math.cbrt(0.0883024619 * r + 0.2817188376 * g + 0.6299787005 * b);\n const a = 1.9779984951 * l - 2.428592205 * m + 0.4505937099 * s;\n const bb = 0.0259040371 * l + 0.7827717662 * m - 0.808675766 * s;\n const C = Math.hypot(a, bb);\n return {\n L: 0.2104542553 * l + 0.793617785 * m - 0.0040720468 * s,\n C: C < 1e-4 ? 0 : C,\n // Grays have no meaningful hue; 0 keeps the output stable.\n h: C < 1e-4 ? 0 : ((Math.atan2(bb, a) * 180) / Math.PI + 360) % 360,\n };\n}\n\n/** OKLCH → linear sRGB, unclamped (channels outside 0–1 mean out of gamut). */\nfunction oklchToLinear({ L, C, h }) {\n const radians = (h * Math.PI) / 180;\n const a = C * Math.cos(radians);\n const b = C * Math.sin(radians);\n const l = (L + 0.3963377774 * a + 0.2158037573 * b) ** 3;\n const m = (L - 0.1055613458 * a - 0.0638541728 * b) ** 3;\n const s = (L - 0.0894841775 * a - 1.291485548 * b) ** 3;\n return [\n 4.0767416621 * l - 3.3077115913 * m + 0.2309699292 * s,\n -1.2684380046 * l + 2.6097574011 * m - 0.3413193965 * s,\n -0.0041960863 * l - 0.7034186147 * m + 1.707614701 * s,\n ];\n}\n\n/** \"50%\" → 0.5 of `scale`, \"0.5\" → 0.5. */\nfunction number(part, scale = 1) {\n const value = part.trim();\n if (value === 'none') return 0;\n if (value.endsWith('%')) return (Number.parseFloat(value) / 100) * scale;\n return Number.parseFloat(value);\n}\n\n/**\n * Parse a CSS color (hex, rgb(), hsl(), oklch() or a basic color name) into OKLCH.\n * Alpha is ignored: Becket brand tokens are opaque.\n *\n * @param {string} input\n * @returns {{ L: number, C: number, h: number } | null} null when the format isn't supported\n */\nexport function parseColor(input) {\n if (typeof input !== 'string') return null;\n // CSS's basic color names, the ones logos and SVGs use. Rarer names aren't guessed.\n const value = (\n {\n black: '#000000',\n white: '#ffffff',\n red: '#ff0000',\n green: '#008000',\n blue: '#0000ff',\n yellow: '#ffff00',\n orange: '#ffa500',\n purple: '#800080',\n gray: '#808080',\n grey: '#808080',\n navy: '#000080',\n teal: '#008080',\n maroon: '#800000',\n olive: '#808000',\n lime: '#00ff00',\n aqua: '#00ffff',\n fuchsia: '#ff00ff',\n silver: '#c0c0c0',\n }[input.trim().toLowerCase()] ?? input\n ).trim();\n\n const hex = value.match(/^#([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i);\n if (hex) {\n return linearToOklch(\n // #abc → #aabbcc; the first three pairs are r, g, b (alpha is dropped).\n (hex[1].length <= 4 ? [...hex[1]].map((digit) => digit + digit).join('') : hex[1])\n .match(/../g)\n .slice(0, 3)\n .map((pair) => toLinear(Number.parseInt(pair, 16) / 255)),\n );\n }\n\n const fn = value.match(/^(rgba?|hsla?|oklch)\\(\\s*([^)]*)\\)$/i);\n if (!fn) return null;\n const kind = fn[1].toLowerCase();\n // `1 2 3 / 0.5` or `1, 2, 3, 0.5`: three channels, alpha dropped.\n const withoutAlpha = fn[2].split('/')[0];\n const parts = (\n withoutAlpha.includes(',') ? withoutAlpha.split(',') : withoutAlpha.trim().split(/\\s+/)\n ).slice(0, 3);\n if (parts.length !== 3) return null;\n\n if (kind.startsWith('rgb')) {\n const rgb = parts.map((part) => clamp01(number(part, 255) / 255));\n if (rgb.some(Number.isNaN)) return null;\n return linearToOklch(rgb.map(toLinear));\n }\n if (kind.startsWith('hsl')) {\n const hue = Number.parseFloat(parts[0]);\n const saturation = clamp01(number(parts[1]));\n const lightness = clamp01(number(parts[2]));\n if ([hue, saturation, lightness].some(Number.isNaN)) return null;\n // CSS Color 4 hsl() → sRGB.\n const chroma = (1 - Math.abs(2 * lightness - 1)) * saturation;\n const sector = (((hue % 360) + 360) % 360) / 60;\n const x = chroma * (1 - Math.abs((sector % 2) - 1));\n const [r, g, b] = [\n [chroma, x, 0],\n [x, chroma, 0],\n [0, chroma, x],\n [0, x, chroma],\n [x, 0, chroma],\n [chroma, 0, x],\n ][Math.min(5, Math.floor(sector))];\n const offset = lightness - chroma / 2;\n return linearToOklch([r + offset, g + offset, b + offset].map(toLinear));\n }\n const [L, C, h] = [number(parts[0]), number(parts[1], 0.4), number(parts[2])];\n if ([L, C, h].some(Number.isNaN)) return null;\n return { L: clamp01(L), C: Math.max(0, C), h: ((h % 360) + 360) % 360 };\n}\n\n/**\n * Bring a color into sRGB by lowering chroma only, keeping lightness and hue. That keeps\n * contrast predictable, which matters more here than keeping saturation.\n *\n * @param {{ L: number, C: number, h: number }} color\n */\nexport function toGamut(color) {\n // In gamut: every linear channel within 0–1, give or take float noise.\n if (oklchToLinear(color).every((channel) => channel >= -1e-4 && channel <= 1 + 1e-4))\n return color;\n let [low, high] = [0, color.C];\n for (let step = 0; step < 24; step += 1) {\n const middle = (low + high) / 2;\n if (\n oklchToLinear({ ...color, C: middle }).every(\n (channel) => channel >= -1e-4 && channel <= 1 + 1e-4,\n )\n )\n low = middle;\n else high = middle;\n }\n return { ...color, C: low };\n}\n\n/** @param {{ L: number, C: number, h: number }} color */\nexport function formatOklch({ L, C, h }) {\n const round = (value, digits) => Number(value.toFixed(digits));\n return `oklch(${round(L, 4)} ${round(C, 4)} ${round(C === 0 ? 0 : h, 2)})`;\n}\n\n/** @param {{ L: number, C: number, h: number }} color */\nexport function formatHex(color) {\n return `#${oklchToLinear(toGamut(color))\n .map((linear) => {\n const channel = clamp01(linear);\n // Linear light → sRGB channel (the inverse of toLinear).\n return Math.round(\n clamp01(channel <= 0.0031308 ? channel * 12.92 : 1.055 * channel ** (1 / 2.4) - 0.055) *\n 255,\n )\n .toString(16)\n .padStart(2, '0');\n })\n .join('')}`;\n}\n\n/**\n * WCAG 2 contrast ratio between two colors (CSS strings or parsed OKLCH), 1–21. Channels are\n * clamped to sRGB first, as a browser would display them.\n *\n * @param {string | { L: number, C: number, h: number }} foreground\n * @param {string | { L: number, C: number, h: number }} background\n */\nexport function contrastRatio(foreground, background) {\n const [first, second] = [foreground, background].map((color) => {\n const parsed = typeof color === 'string' ? parseColor(color) : color;\n if (!parsed)\n throw new Error(`Can't read the color \"${color}\". Use hex, rgb(), hsl() or oklch().`);\n const [r, g, b] = oklchToLinear(parsed).map(clamp01);\n return 0.2126 * r + 0.7152 * g + 0.0722 * b;\n });\n const [high, low] = first > second ? [first, second] : [second, first];\n return (high + 0.05) / (low + 0.05);\n}\n\n/**\n * Perceptual distance (ΔE OK, Euclidean in OKLab). Around 0.02 is a just-noticeable difference.\n *\n * @param {{ L: number, C: number, h: number }} first\n * @param {{ L: number, C: number, h: number }} second\n */\nexport function colorDistance(first, second) {\n const [a, b] = [first, second].map(({ L, C, h }) => [\n L,\n C * Math.cos((h * Math.PI) / 180),\n C * Math.sin((h * Math.PI) / 180),\n ]);\n return Math.hypot(a[0] - b[0], a[1] - b[1], a[2] - b[2]);\n}\n\n/**\n * The OKLCH color for an sRGB triplet (0–255). Used by image decoders.\n *\n * @param {[number, number, number]} rgb\n */\nexport function rgbToOklch(rgb) {\n return linearToOklch(rgb.map((channel) => toLinear(channel / 255)));\n}\n","/**\n * Resolve a BecketTheme to final colors in both themes, the way the browser would, and check\n * every pair Becket draws text or controls with.\n */\n\nimport { contrastRatio, formatOklch, parseColor } from './color.mjs';\n\n/**\n * Default color tokens as index.css declares them. `{key}` is a reference to another token, so\n * a theme that changes `primary` also moves `link`. contrast.test.mjs asserts these match\n * index.css, so they can't drift.\n */\nexport const defaultColors = {\n dark: {\n primary: 'oklch(0.75 0.15 78)',\n secondary: 'oklch(0.70 0.13 125)',\n tertiary: 'oklch(0.60 0.16 48)',\n // index.css: color-mix(in oklch, primary 88%, white)\n primaryHover: { mixWithWhite: 'primary', amount: 0.88 },\n 'neutral.50': 'oklch(0.96 0.012 78)',\n 'neutral.100': 'oklch(0.94 0.012 78)',\n 'neutral.200': 'oklch(0.89 0.012 75)',\n 'neutral.300': 'oklch(0.84 0.012 72)',\n 'neutral.400': 'oklch(0.75 0.012 70)',\n 'neutral.500': 'oklch(0.65 0.012 65)',\n 'neutral.600': 'oklch(0.55 0.014 62)',\n 'neutral.700': 'oklch(0.45 0.014 60)',\n 'neutral.800': 'oklch(0.35 0.015 60)',\n 'neutral.900': 'oklch(0.22 0.015 60)',\n white: 'oklch(99% 0 0)',\n background: '{neutral.900}',\n text: '{neutral.50}',\n muted: '{neutral.300}',\n surface: '{neutral.800}',\n border: '{neutral.200}',\n danger: 'oklch(0.76 0.16 25)',\n accent: 'oklch(0.86 0.12 125)',\n link: '{primary}',\n linkHover: 'oklch(0.78 0.13 78)',\n linkVisited: 'oklch(0.72 0.12 125)',\n warning: 'oklch(0.72 0.16 42)',\n success: 'oklch(0.68 0.14 165)',\n },\n /** Only what `[data-theme='light']` changes; the rest is inherited from dark. */\n light: {\n background: '{neutral.50}',\n text: '{neutral.900}',\n muted: 'oklch(0.53 0.014 62)',\n surface: '{white}',\n danger: 'oklch(0.48 0.20 25)',\n accent: 'oklch(0.38 0.14 125)',\n link: 'oklch(0.54 0.12 70)',\n linkHover: 'oklch(0.46 0.11 70)',\n linkVisited: 'oklch(0.52 0.09 125)',\n },\n};\n\nconst text = 4.5;\nconst canvases = ['background', 'surface'];\n\n/**\n * Every pair Becket draws. `required` pairs pass in the default theme and must pass in any\n * theme. `advisory` pairs fail in the default theme too (see their `note`), so they're\n * reported, not enforced, until Becket's recipes change.\n */\nexport const contrastPairs = [\n ...['text', 'muted', 'link', 'linkHover', 'linkVisited', 'danger', 'accent'].flatMap(\n (foreground) =>\n canvases.map((background) => ({\n foreground,\n background,\n minimum: text,\n level: 'required',\n use: `${foreground} text on ${background}`,\n })),\n ),\n ...['primary', 'primaryHover', 'secondary'].map((background) => ({\n foreground: 'neutral.900',\n background,\n minimum: text,\n level: 'required',\n use: `label on a filled ${background} control`,\n })),\n {\n foreground: 'neutral.900',\n background: 'tertiary',\n minimum: text,\n level: 'advisory',\n use: 'label over the tertiary end of a gradient fill',\n note: 'The default tertiary is 4.13:1; the label mostly sits over the primary half.',\n },\n ...canvases.map((background) => ({\n foreground: 'primary',\n background,\n // Non-text UI and state indicators (WCAG 1.4.11).\n minimum: 3,\n level: 'advisory',\n use: `focus ring and checked controls on ${background}`,\n note: 'A primary light enough for dark labels is usually too light for 3:1 on a near-white canvas; the default is 2.02:1 in light.',\n })),\n];\n\n/**\n * Final colors in both themes for a theme config, as OKLCH.\n *\n * Mirrors the CSS that `defineBecketTheme` emits: its `:root` block is unlayered, so it beats\n * index.css's layered light block too. A plain string (or a `{ dark }` value) therefore applies\n * in light as well, unless the config also gives `light`.\n *\n * @param {import('./index.d.ts').BecketTheme} [theme]\n */\nexport function resolveBecketColors(theme = {}) {\n const root = {};\n const lightOnly = {};\n for (const [key, value] of Object.entries(theme.colors ?? {})) {\n if (value == null) continue;\n if (key === 'neutral') {\n for (const [step, color] of Object.entries(value)) root[`neutral.${step}`] = color;\n } else if (typeof value === 'object') {\n if (value.dark) root[key] = value.dark;\n if (value.light) lightOnly[key] = value.light;\n } else {\n root[key] = value;\n }\n }\n const [dark, light] = [\n { ...defaultColors.dark, ...root },\n { ...defaultColors.dark, ...defaultColors.light, ...root, ...lightOnly },\n ].map((table) => {\n const resolved = {};\n const resolve = (key, depth = 0) => {\n if (resolved[key]) return resolved[key];\n if (depth > 8) throw new Error(`Color token \"${key}\" refers to itself`);\n const value = table[key];\n if (value == null) throw new Error(`Unknown color token \"${key}\"`);\n let color;\n if (typeof value === 'object') {\n const base = resolve(value.mixWithWhite, depth + 1);\n // color-mix(in oklch, base n%, white): white has no hue, so the hue stays the base's.\n color = {\n L: base.L * value.amount + (1 - value.amount),\n C: base.C * value.amount,\n h: base.h,\n };\n } else {\n const reference = value.match(/^\\{([\\w.]+)\\}$/);\n color = reference ? resolve(reference[1], depth + 1) : parseColor(value);\n if (!color)\n throw new Error(`Can't read colors.${key} \"${value}\". Use hex, rgb(), hsl() or oklch().`);\n }\n resolved[key] = color;\n return color;\n };\n for (const key of Object.keys(table)) resolve(key);\n return resolved;\n });\n return { dark, light };\n}\n\n/**\n * WCAG 2.2 AA contrast for every pair in contrastPairs, in dark and light.\n *\n * @param {import('./index.d.ts').BecketTheme} [theme]\n * @returns {import('./index.d.ts').BecketContrastReport}\n */\nexport function checkBecketThemeContrast(theme = {}) {\n const colors = resolveBecketColors(theme);\n const results = ['dark', 'light'].flatMap((mode) =>\n contrastPairs.map((pair) => {\n const ratio = contrastRatio(colors[mode][pair.foreground], colors[mode][pair.background]);\n return {\n ...pair,\n theme: mode,\n ratio: Math.floor(ratio * 100) / 100,\n passes: ratio >= pair.minimum,\n foregroundColor: formatOklch(colors[mode][pair.foreground]),\n backgroundColor: formatOklch(colors[mode][pair.background]),\n };\n }),\n );\n return {\n passes: results.every((result) => result.passes || result.level === 'advisory'),\n failures: results.filter((result) => !result.passes && result.level === 'required'),\n advisories: results.filter((result) => !result.passes && result.level === 'advisory'),\n results,\n };\n}\n","/**\n * Turn one to three brand colors into a full Becket color theme that passes WCAG 2.2 AA in\n * dark and light. Works in OKLCH and only moves lightness (and chroma when a lighter or darker\n * shade leaves sRGB), so the brand hue never changes.\n */\n\nimport { contrastRatio, formatOklch, parseColor, toGamut } from './color.mjs';\nimport { checkBecketThemeContrast, resolveBecketColors } from './contrast.mjs';\n\n// Aim slightly above 4.5:1 so values rounded for CSS still pass.\nconst textTarget = 4.6;\n\n/**\n * Move a color's lightness in one direction, one small step at a time, until it reaches\n * `minimum` against every color in `against`. The first step is the color itself, so one that\n * already passes comes back unchanged. Null when no lightness in that direction works.\n */\nfunction fitLightness({ color, against, minimum, direction }) {\n for (let L = color.L; L >= 0 && L <= 1; L += direction === 'lighter' ? 0.005 : -0.005) {\n const candidate = toGamut({ ...color, L });\n if (against.every((other) => contrastRatio(candidate, other) >= minimum)) return candidate;\n }\n return null;\n}\n\nfunction describe(color) {\n return `L ${color.L.toFixed(2)}`;\n}\n\n/**\n * @param {import('./index.d.ts').DeriveBecketThemeInput} input\n * @returns {import('./index.d.ts').DerivedBecketTheme}\n */\nexport function deriveBecketTheme({ brand, pinned = {} }) {\n if (!Array.isArray(brand) || brand.length === 0 || brand.length > 3) {\n throw new Error('Pass one to three brand colors, most important first.');\n }\n const seeds = brand.map((value) => {\n const color = parseColor(value);\n if (!color)\n throw new Error(`Can't read the brand color \"${value}\". Use hex, rgb(), hsl() or oklch().`);\n return color;\n });\n const [primarySeed] = seeds;\n // With fewer than three colors, follow the default theme's shape: secondary is the brand hue\n // turned ~45° and tertiary ~30° the other way, at the same lightness and chroma.\n const secondarySeed = seeds[1] ?? { ...primarySeed, h: (primarySeed.h + 45) % 360 };\n\n const notes = [];\n const colors = {};\n const note = (token, reason) => notes.push({ token, reason });\n\n // A whisper of the brand hue in the grays, like the default theme's warm neutrals. Below 0.012\n // the tint is invisible; above it grays start to read as a color.\n const tint = primarySeed.C < 0.02 ? 0 : 0.012;\n colors.neutral = Object.fromEntries(\n // The default theme's lightness ladder, so text and canvases keep their contrast.\n Object.entries({\n 50: 0.96,\n 100: 0.94,\n 200: 0.89,\n 300: 0.84,\n 400: 0.75,\n 500: 0.65,\n 600: 0.55,\n 700: 0.45,\n 800: 0.35,\n 900: 0.22,\n }).map(([step, L]) => [step, formatOklch({ L, C: tint, h: tint ? primarySeed.h : 0 })]),\n );\n colors.muted = { light: formatOklch({ L: 0.53, C: tint, h: tint ? primarySeed.h : 0 }) };\n note(\n 'neutral',\n tint\n ? `Grays tinted toward the brand hue (${primarySeed.h.toFixed(0)}°), lightness unchanged.`\n : 'The brand is near-gray, so neutrals stay untinted.',\n );\n\n // Fit everything against the canvases the user will actually see, pinned ones included.\n const canvases = resolveBecketColors({ colors: { ...colors, ...pinned } });\n const dark = [canvases.dark.background, canvases.dark.surface];\n const light = [canvases.light.background, canvases.light.surface];\n\n const fill = ({ token, seed, label }) => {\n const fitted = fitLightness({\n color: seed,\n // Filled controls put neutral.900 labels on the brand color.\n against: [canvases.dark['neutral.900']],\n minimum: textTarget,\n direction: 'lighter',\n });\n colors[token] = formatOklch(fitted);\n if (fitted.L !== seed.L)\n note(\n token,\n `${label} lightened from ${describe(seed)} to ${describe(fitted)} so dark button labels reach 4.5:1.`,\n );\n else note(token, `${label} used as is.`);\n };\n fill({ token: 'primary', seed: primarySeed, label: 'Brand color 1' });\n fill({\n token: 'secondary',\n seed: secondarySeed,\n label: seeds[1] ? 'Brand color 2' : 'Derived from brand color 1 (hue +45°)',\n });\n fill({\n token: 'tertiary',\n seed: seeds[2] ?? { ...primarySeed, h: (primarySeed.h + 330) % 360 },\n label: seeds[2] ? 'Brand color 3' : 'Derived from brand color 1 (hue −30°)',\n });\n\n const onCanvas = ({ token, seed, label }) => {\n const darkFit = fitLightness({\n color: seed,\n against: dark,\n minimum: textTarget,\n direction: 'lighter',\n });\n const lightFit = fitLightness({\n color: seed,\n against: light,\n minimum: textTarget,\n direction: 'darker',\n });\n if (!darkFit || !lightFit) {\n note(\n token,\n `${label} can't reach 4.5:1 on your pinned canvas in ${darkFit ? 'light' : 'dark'}; left at the Becket default.`,\n );\n return null;\n }\n colors[token] = { dark: formatOklch(darkFit), light: formatOklch(lightFit) };\n const exact = [darkFit.L === seed.L && 'dark', lightFit.L === seed.L && 'light'].filter(\n Boolean,\n );\n note(\n token,\n exact.length === 2\n ? `${label} used as is in both themes.`\n : exact.length === 1\n ? `${label} used as is in ${exact[0]}; a ${exact[0] === 'dark' ? 'darker' : 'lighter'} shade (${describe(exact[0] === 'dark' ? lightFit : darkFit)}) in ${exact[0] === 'dark' ? 'light' : 'dark'} for 4.5:1 on the canvas.`\n : `${label} shaded per theme (dark ${describe(darkFit)}, light ${describe(lightFit)}) for 4.5:1 on the canvas.`,\n );\n return { dark: darkFit, light: lightFit };\n };\n const link = onCanvas({ token: 'link', seed: primarySeed, label: 'Brand color 1' });\n onCanvas({\n token: 'linkVisited',\n seed: secondarySeed,\n label: seeds[1] ? 'Brand color 2' : 'The derived secondary',\n });\n onCanvas({\n token: 'accent',\n seed: secondarySeed,\n label: seeds[1] ? 'Brand color 2' : 'The derived secondary',\n });\n if (link) {\n // Hover moves away from the canvas, so it keeps (and gains) contrast.\n colors.linkHover = {\n dark: formatOklch(toGamut({ ...link.dark, L: Math.min(1, link.dark.L + 0.06) })),\n light: formatOklch(\n fitLightness({\n color: { ...link.light, L: Math.max(0, link.light.L - 0.08) },\n against: light,\n minimum: textTarget,\n direction: 'darker',\n }),\n ),\n };\n note('linkHover', 'The link color a step lighter on dark and a step darker on light.');\n }\n\n // Body text only moves when a pinned canvas breaks it; otherwise the neutral ladder already passes.\n for (const token of ['text', 'muted']) {\n if (pinned[token]) continue;\n const current = resolveBecketColors({ colors: { ...colors, ...pinned } });\n const darkFit = fitLightness({\n color: current.dark[token],\n against: dark,\n minimum: textTarget,\n direction: 'lighter',\n });\n const lightFit = fitLightness({\n color: current.light[token],\n against: light,\n minimum: textTarget,\n direction: 'darker',\n });\n if (darkFit.L === current.dark[token].L && lightFit.L === current.light[token].L) continue;\n colors[token] = { dark: formatOklch(darkFit), light: formatOklch(lightFit) };\n note(token, 'Adjusted so it stays at 4.5:1 on your pinned canvas.');\n }\n\n // Within 20° of Becket's danger hue (25°).\n const fromDanger = Math.abs(primarySeed.h - 25);\n if (primarySeed.C >= 0.08 && Math.min(fromDanger, 360 - fromDanger) < 20) {\n note(\n 'danger',\n 'Your brand is red, like error text. Danger stays Becket red; make sure errors also carry an icon or text, not color alone.',\n );\n }\n\n for (const [token, value] of Object.entries(pinned)) {\n if (token === 'neutral') colors.neutral = { ...colors.neutral, ...value };\n else colors[token] = value;\n note(token, 'Pinned by you, kept exactly.');\n }\n\n const theme = { colors };\n return { theme, notes, contrast: checkBecketThemeContrast(theme) };\n}\n","/** Public CSS-variable theming. No Panda, no theme provider. */\n\nexport { colorDistance, contrastRatio, formatHex, formatOklch, parseColor, rgbToOklch, toGamut } from './color.mjs';\nexport { contrastPairs, checkBecketThemeContrast, resolveBecketColors } from './contrast.mjs';\nexport { deriveBecketTheme } from './derive.mjs';\n\nconst PREFIX = '--beckui--';\n\nconst COLOR_FLAT = [\n 'primary',\n 'secondary',\n 'tertiary',\n 'primaryHover',\n 'lightBackground',\n 'lightText',\n 'warning',\n 'success',\n];\n\nconst COLOR_THEMED = [\n 'background',\n 'text',\n 'muted',\n 'border',\n 'danger',\n 'accent',\n 'surface',\n 'link',\n 'linkHover',\n 'linkVisited',\n];\nconst NEUTRAL_STEPS = ['50', '100', '200', '300', '400', '500', '600', '700', '800', '900'];\nconst RADII = ['none', 'sm', 'md', 'lg', 'xl', 'full'];\n// `base` rescales the whole type scale; the steps are ratios of it.\nconst FONT_SIZES = ['base', 'xs', 'sm', 'md', 'lg', 'xl', '2xl', '3xl', '4xl', '5xl', '6xl'];\n// `unit` rescales every Fibonacci spacing and size step; `textUnit` the em-based text spacing.\nconst SPACING = ['unit', 'textUnit', 'xs', 'sm', 'md', 'lg', 'xl'];\nconst FONTS = ['sans', 'mono'];\nconst DENSITY_SIZES = {\n button: ['sm', 'md'],\n field: ['sm', 'md', 'lg'],\n tag: ['sm', 'md', 'lg'],\n};\n\nfunction kebab(value) {\n return value.replace(/[A-Z]/g, (char) => `-${char.toLowerCase()}`);\n}\n\nfunction cssVar(parts) {\n return `${PREFIX}${parts.map(kebab).join('-')}`;\n}\n\nfunction assertAllowedKeys(object, allowed, label) {\n for (const key of Object.keys(object)) {\n if (!allowed.includes(key)) {\n throw new Error(`Unknown Becket theme key \"${label}.${key}\"`);\n }\n }\n}\n\nfunction pushDecl(decls, name, value) {\n if (value == null || value === '') return;\n decls.push(` ${name}: ${value};`);\n}\n\nfunction pushThemed(rootDecls, lightDecls, name, value) {\n if (value == null || value === '') return;\n if (typeof value === 'object') {\n if (value.dark) pushDecl(rootDecls, name, value.dark);\n if (value.light) pushDecl(lightDecls, name, value.light);\n return;\n }\n pushDecl(rootDecls, name, value);\n}\n\nfunction colorDecls(colors, rootDecls, lightDecls) {\n assertAllowedKeys(colors, [...COLOR_FLAT, ...COLOR_THEMED, 'neutral'], 'colors');\n\n for (const key of COLOR_FLAT) {\n const value = colors[key];\n if (value == null) continue;\n if (typeof value === 'object') {\n throw new Error(`colors.${key} must be a CSS color string`);\n }\n pushDecl(rootDecls, cssVar(['colors', key]), value);\n }\n\n for (const key of COLOR_THEMED) {\n pushThemed(rootDecls, lightDecls, cssVar(['colors', key]), colors[key]);\n }\n\n if (colors.neutral) {\n assertAllowedKeys(colors.neutral, NEUTRAL_STEPS, 'colors.neutral');\n for (const step of NEUTRAL_STEPS) {\n pushDecl(rootDecls, cssVar(['colors', 'neutral', step]), colors.neutral[step]);\n }\n }\n}\n\nfunction densityDecls(density, decls) {\n assertAllowedKeys(density, ['button', 'field', 'tag'], 'density');\n for (const component of Object.keys(DENSITY_SIZES)) {\n const sizes = density[component];\n if (!sizes) continue;\n const allowed = DENSITY_SIZES[component];\n assertAllowedKeys(sizes, allowed, `density.${component}`);\n for (const size of allowed) {\n const box = sizes[size];\n if (!box) continue;\n assertAllowedKeys(box, ['px', 'py'], `density.${component}.${size}`);\n if (box.px) decls.push(` --beckui-${component}-px-${size}: ${box.px};`);\n if (box.py) decls.push(` --beckui-${component}-py-${size}: ${box.py};`);\n }\n }\n}\n\nfunction sheet(selector, decls) {\n if (!decls.length) return '';\n return `${selector} {\\n${decls.join('\\n')}\\n}\\n`;\n}\n\n/**\n * Emit unlayered `:root` / `html[data-theme='light']` overrides. Import or\n * inject **after** `@becket-ui/tokens/index.css` so these win over `@layer tokens`.\n *\n * @param {import('./index.d.ts').BecketTheme} config\n * @returns {string}\n */\nexport function defineBecketTheme(config = {}) {\n assertAllowedKeys(\n config,\n ['colors', 'radii', 'fontSizes', 'spacing', 'sizes', 'fonts', 'density'],\n 'theme',\n );\n\n const rootDecls = [];\n const lightDecls = [];\n\n if (config.colors) colorDecls(config.colors, rootDecls, lightDecls);\n\n if (config.radii) {\n assertAllowedKeys(config.radii, RADII, 'radii');\n for (const key of RADII) {\n pushDecl(rootDecls, cssVar(['radii', key]), config.radii[key]);\n }\n }\n\n if (config.fontSizes) {\n assertAllowedKeys(config.fontSizes, FONT_SIZES, 'fontSizes');\n for (const key of FONT_SIZES) {\n pushDecl(rootDecls, cssVar(['font-sizes', key]), config.fontSizes[key]);\n }\n }\n\n if (config.spacing) {\n assertAllowedKeys(config.spacing, SPACING, 'spacing');\n for (const key of SPACING) {\n pushDecl(rootDecls, cssVar(['spacing', key]), config.spacing[key]);\n }\n }\n\n if (config.sizes) {\n assertAllowedKeys(config.sizes, ['field'], 'sizes');\n pushDecl(rootDecls, cssVar(['sizes', 'field']), config.sizes.field);\n }\n\n if (config.fonts) {\n assertAllowedKeys(config.fonts, FONTS, 'fonts');\n for (const key of FONTS) {\n pushDecl(rootDecls, cssVar(['fonts', key]), config.fonts[key]);\n }\n }\n\n if (config.density) densityDecls(config.density, rootDecls);\n\n const css = `${sheet(':root', rootDecls)}${sheet(\"html[data-theme='light']\", lightDecls)}`;\n if (!css) {\n return '/* defineBecketTheme: empty config, Becket defaults unchanged */\\n';\n }\n return css;\n}\n\nexport const BECKET_PUBLIC_COLOR_KEYS = [...COLOR_FLAT, ...COLOR_THEMED];\nexport const BECKET_PUBLIC_NEUTRAL_STEPS = NEUTRAL_STEPS;\n","import {\n colorDistance,\n formatHex,\n parseColor,\n rgbToOklch,\n type Oklch,\n} from '@becket-ui/tokens/theme';\nimport jpeg from 'jpeg-js';\nimport { PNG } from 'pngjs';\n\nimport type { Source } from './loadSource';\n\nexport type ColorRole = 'background' | 'neutral' | 'brand';\nexport type ExtractedColor = { hex: string; color: Oklch; share: number; role: ColorRole };\n\n// Decompression bombs: a tiny PNG can claim gigapixels. Real logos and manual pages are far below.\nconst maxPixels = 50_000_000;\n// Colors closer than this (ΔE OK) are one color: anti-aliasing, JPEG noise, gradients' near steps.\nconst sameColor = 0.05;\n/** Below this chroma a color reads as white, gray or black. Shared with suggest_theme and PDFs. */\nexport const neutralChroma = 0.04;\n\n/**\n * Dominant colors of a bitmap. Transparent pixels are ignored. A color that keeps touching the\n * image's edges is the background (logos have padding; photos behind them touch every edge).\n * Each color is its most common exact shade, not an average, so edges and noise don't tint it.\n */\nexport function colorsFromPixels({\n width,\n height,\n data,\n}: {\n width: number;\n height: number;\n data: Uint8Array;\n}): ExtractedColor[] {\n // Sample at most ~160k pixels: plenty for a palette, and fast on a 2000×2000 logo.\n const step = Math.max(1, Math.floor(Math.sqrt((width * height) / 160_000)));\n const border = Math.max(1, Math.round(Math.min(width, height) * 0.02));\n const bins = new Map<number, { count: number; edge: number; r: number; g: number; b: number }>();\n let opaque = 0;\n let edgeSamples = 0;\n\n for (let y = 0; y < height; y += step) {\n for (let x = 0; x < width; x += step) {\n const offset = (y * width + x) * 4;\n if (data[offset + 3] < 128) continue;\n const [r, g, b] = [data[offset], data[offset + 1], data[offset + 2]];\n const key = ((r >> 3) << 10) | ((g >> 3) << 5) | (b >> 3);\n const isEdge = x < border || y < border || x >= width - border || y >= height - border;\n const bin = bins.get(key) ?? { count: 0, edge: 0, r: 0, g: 0, b: 0 };\n bin.count += 1;\n bin.r += r;\n bin.g += g;\n bin.b += b;\n if (isEdge) bin.edge += 1;\n bins.set(key, bin);\n opaque += 1;\n if (isEdge) edgeSamples += 1;\n }\n }\n if (opaque === 0) return [];\n\n const clusters: { count: number; edge: number; color: Oklch }[] = [];\n for (const bin of [...bins.values()].toSorted((a, b) => b.count - a.count)) {\n const color = rgbToOklch([bin.r / bin.count, bin.g / bin.count, bin.b / bin.count]);\n const home = clusters.find((cluster) => colorDistance(cluster.color, color) < sameColor);\n if (home) {\n home.count += bin.count;\n home.edge += bin.edge;\n continue;\n }\n if (clusters.length < 64) clusters.push({ count: bin.count, edge: bin.edge, color });\n }\n\n return (\n clusters\n // Under 0.5% is anti-aliasing or a stray pixel.\n .filter((cluster) => cluster.count / opaque >= 0.005)\n .map((cluster): ExtractedColor => ({\n hex: formatHex(cluster.color),\n color: cluster.color,\n share: cluster.count / opaque,\n // The background touches the edges at least half as often as the average opaque pixel,\n // and covers 5% or more of the edge.\n role:\n edgeSamples > 0 &&\n cluster.edge / cluster.count >= (edgeSamples / opaque) * 0.5 &&\n cluster.edge / edgeSamples >= 0.05\n ? 'background'\n : cluster.color.C < neutralChroma\n ? 'neutral'\n : 'brand',\n }))\n .toSorted((a, b) => b.share - a.share)\n );\n}\n\n/** Merge near-identical colors (keeping the more common one's exact value), most common first. */\nexport function mergeClose(colors: ExtractedColor[]): ExtractedColor[] {\n const merged: ExtractedColor[] = [];\n for (const color of colors.toSorted((a, b) => b.share - a.share)) {\n const home = merged.find(\n (each) => each.role === color.role && colorDistance(each.color, color.color) < sameColor,\n );\n if (home) home.share += color.share;\n else merged.push({ ...color });\n }\n return merged;\n}\n\n/** Dominant colors of a PNG, JPEG or SVG source. */\nexport function extractImageColors(source: Source): {\n colors: ExtractedColor[];\n method: string;\n skipped: string[];\n} {\n if (source.kind === 'png') {\n // The header's size, read before decoding: decompression bombs claim gigapixels in a tiny file.\n const [width, height] = [source.bytes.readUInt32BE(16), source.bytes.readUInt32BE(20)];\n if (width * height > maxPixels)\n throw new Error(`The PNG is ${width}×${height}; the limit is ${maxPixels / 1e6} megapixels.`);\n return {\n colors: colorsFromPixels(PNG.sync.read(source.bytes)),\n method: 'PNG pixels',\n skipped: [],\n };\n }\n if (source.kind === 'jpeg') {\n return {\n colors: colorsFromPixels(\n jpeg.decode(source.bytes, {\n useTArray: true,\n formatAsRGBA: true,\n maxResolutionInMP: maxPixels / 1e6,\n maxMemoryUsageInMB: 1024,\n }),\n ),\n method: 'JPEG pixels',\n skipped: [],\n };\n }\n if (source.kind === 'svg') {\n // Colors the SVG declares (fill, stroke, stop-color, color, in attributes and CSS), weighted by\n // how often each appears. The SVG is read as text: nothing renders, runs or loads.\n const svg = source.bytes.toString('utf8');\n const counts = new Map<string, { color: Oklch; count: number }>();\n const skippedValues = new Set<string>();\n for (const [, , raw] of svg.matchAll(\n /(?:^|[\\s;\"'{])(fill|stroke|stop-color|color|flood-color)\\s*(?:=\\s*[\"']|:\\s*)([^\"';}>]+)/gi,\n )) {\n const value = raw.trim().replace(/\\s*!important$/, '');\n const lower = value.toLowerCase();\n if (\n ['none', 'currentcolor', 'transparent', 'inherit', 'initial', 'unset'].includes(lower) ||\n lower.startsWith('url(') ||\n lower.startsWith('var(')\n )\n continue;\n // parseColor knows the basic color names; rarer ones are reported as skipped, not guessed.\n const color = parseColor(value);\n if (!color) {\n skippedValues.add(value);\n continue;\n }\n const hex = formatHex(color);\n const entry = counts.get(hex) ?? { color, count: 0 };\n entry.count += 1;\n counts.set(hex, entry);\n }\n const embedded = [...svg.matchAll(/data:image\\/(?:png|jpeg);base64,([A-Za-z0-9+/=\\s]+)/g)].map(\n ([, data]) => Buffer.from(data.replace(/\\s+/g, ''), 'base64'),\n );\n // Summed once here, not per color inside the map below.\n const total = [...counts.values()].reduce((sum, entry) => sum + entry.count, 0);\n return {\n colors: mergeClose([\n ...[...counts.entries()].map(([hex, entry]): ExtractedColor => ({\n hex,\n color: entry.color,\n share: entry.count / total,\n role: entry.color.C < neutralChroma ? 'neutral' : 'brand',\n })),\n ...embedded.flatMap((bytes) => {\n try {\n return extractImageColors({\n bytes,\n kind: bytes[0] === 0x89 ? 'png' : 'jpeg',\n label: source.label,\n }).colors.map((color) => ({ ...color, share: color.share / embedded.length }));\n } catch {\n // A broken embedded image doesn't hide the colors the SVG declares.\n return [];\n }\n }),\n ]),\n method: embedded.length\n ? 'SVG colors and embedded images (by how often each color is used, not by area)'\n : 'SVG colors (by how often each is used, not by area)',\n skipped: [...skippedValues],\n };\n }\n if (source.kind === 'webp' || source.kind === 'gif') {\n throw new Error(\n `${source.kind.toUpperCase()} isn't supported yet. Export the logo as SVG or PNG, or tell me its colors.`,\n );\n }\n throw new Error(\"That isn't a PNG, JPEG, SVG or PDF file.\");\n}\n"],"mappings":";AAMA,IAAM,UAAU,CAAC,UAAU,KAAK,IAAI,GAAG,KAAK,IAAI,GAAG,KAAK,CAAC;AAGzD,SAAS,SAAS,SAAS;AACzB,SAAO,WAAW,UAAU,UAAU,UAAU,UAAU,SAAS,UAAU;AAC/E;AAGA,SAAS,cAAc,CAAC,GAAG,GAAG,CAAC,GAAG;AAChC,QAAM,IAAI,KAAK,KAAK,eAAe,IAAI,eAAe,IAAI,eAAe,CAAC;AAC1E,QAAM,IAAI,KAAK,KAAK,eAAe,IAAI,eAAe,IAAI,eAAe,CAAC;AAC1E,QAAM,IAAI,KAAK,KAAK,eAAe,IAAI,eAAe,IAAI,eAAe,CAAC;AAC1E,QAAM,IAAI,eAAe,IAAI,cAAc,IAAI,eAAe;AAC9D,QAAM,KAAK,eAAe,IAAI,eAAe,IAAI,cAAc;AAC/D,QAAM,IAAI,KAAK,MAAM,GAAG,EAAE;AAC1B,SAAO;AAAA,IACL,GAAG,eAAe,IAAI,cAAc,IAAI,eAAe;AAAA,IACvD,GAAG,IAAI,OAAO,IAAI;AAAA;AAAA,IAElB,GAAG,IAAI,OAAO,KAAM,KAAK,MAAM,IAAI,CAAC,IAAI,MAAO,KAAK,KAAK,OAAO;AAAA,EAClE;AACF;AAGA,SAAS,cAAc,EAAE,GAAG,GAAG,EAAE,GAAG;AACl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