/* ═══════════════════════════════════════════════════════════════ THEME The admin's palette (Panel → Site settings → Colors, table site_setting_colors) over the site's own color tokens. The defaults are THEME_DEFAULTS (themeDefaults.js), which the build checks against src/index.css. A blank override keeps the default. themeCss() is written into every page's (pageMeta.js). It goes into the same cascade layers as index.css (theme for light, base for dark), after it, so an override replaces exactly the value it names: a light-only change leaves dark mode alone. checkTheme() runs when Site settings is saved (the descriptor's `check`, inside the save's transaction), and refuses a palette in which any text would fall under WCAG AA (4.5:1) in either mode, so an admin can't make the site unreadable. ═══════════════════════════════════════════════════════════════ */ import { HttpError } from "./admin-crud.js"; import { THEME_DEFAULTS } from "./themeDefaults.js"; export { THEME_DEFAULTS }; export const THEME_TOKENS = Object.keys(THEME_DEFAULTS); const HEX = /^#[0-9a-f]{6}$/i; const MODES = ["light", "dark"]; function overrides(db) { const rows = db .prepare(`SELECT token, light, dark FROM site_setting_colors WHERE settings_id = 'site'`) .all(); // Checked again here, not only by the table's CHECK: this goes // straight into a