@g9tm/lynxcontrols-foundation 2.5.8 → 2.5.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/catalog/catalog.json +216 -8
  2. package/catalog/index.md +1 -1
  3. package/dist/.tsbuildinfo +1 -1
  4. package/dist/theme/appearance-kit.d.ts +32 -9
  5. package/dist/theme/appearance-kit.d.ts.map +1 -1
  6. package/dist/theme/appearance-kit.js +62 -24
  7. package/dist/theme/appearance-kit.js.map +1 -1
  8. package/dist/theme/appearance.d.ts +6 -1
  9. package/dist/theme/appearance.d.ts.map +1 -1
  10. package/dist/theme/appearance.js +21 -3
  11. package/dist/theme/appearance.js.map +1 -1
  12. package/dist/theme/index.d.ts +3 -2
  13. package/dist/theme/index.d.ts.map +1 -1
  14. package/dist/theme/index.js +2 -1
  15. package/dist/theme/recipe.d.ts.map +1 -1
  16. package/dist/theme/recipe.js +11 -3
  17. package/dist/theme/recipe.js.map +1 -1
  18. package/dist/theme/sanitize.d.ts +7 -0
  19. package/dist/theme/sanitize.d.ts.map +1 -0
  20. package/dist/theme/sanitize.js +22 -0
  21. package/dist/theme/sanitize.js.map +1 -0
  22. package/dist/theme/theme.d.ts +12 -0
  23. package/dist/theme/theme.d.ts.map +1 -1
  24. package/dist/theme/theme.js +13 -2
  25. package/dist/theme/theme.js.map +1 -1
  26. package/dist/theme/token-themes.d.ts +114 -0
  27. package/dist/theme/token-themes.d.ts.map +1 -0
  28. package/dist/theme/token-themes.js +568 -0
  29. package/dist/theme/token-themes.js.map +1 -0
  30. package/dist/tokens/index.d.ts +1 -1
  31. package/dist/tokens/index.d.ts.map +1 -1
  32. package/dist/tokens/index.js +1 -1
  33. package/dist/tokens/root.d.ts +8 -0
  34. package/dist/tokens/root.d.ts.map +1 -1
  35. package/dist/tokens/root.js +9 -2
  36. package/dist/tokens/root.js.map +1 -1
  37. package/docs/api.md +28 -2
  38. package/package.json +1 -1
@@ -2,10 +2,13 @@ import type { G9PaletteValues } from '../tokens/generated/palettes.js';
2
2
  import { type G9Density, type G9TypeRole, type G9TypeRoleName } from '../tokens/shape.js';
3
3
  import { type G9ThemeDefinition } from './appearance.js';
4
4
  import type { G9ColorScheme } from './theme.js';
5
+ import { type G9EffectsReason, type G9TokenTheme, type G9TokenThemeOptions } from './token-themes.js';
5
6
  /** The tokens an app (a messenger) adds to the library palette. */
6
7
  export declare const g9AppTokenNames: readonly ["hover", "press", "field", "skeleton", "accent-soft", "accent-glow", "accent-gradient", "text-on-accent", "glass", "glass-border", "bubble-mine", "bubble-mine-text", "bubble-mine-meta", "bubble-other", "bubble-other-text", "bubble-other-border", "highlight", "link", "selection", "focus-ring", "online", "away", "busy"];
7
8
  /** The name of an app token (`hover`, `bubble-mine`…). */
8
9
  export type G9AppTokenName = (typeof g9AppTokenNames)[number];
10
+ /** Every app token name the library knows: its own and a token theme's (2.5.10), for a sanitizer or an editor. */
11
+ export declare const g9AllAppTokenNames: readonly string[];
9
12
  /** Options of {@link g9AppTokens}. */
10
13
  export interface G9AppTokenOptions {
11
14
  /** The person's accent (`#rrggbb`) over the theme's primary; null / invalid: the theme's own. */
@@ -23,11 +26,7 @@ export declare function g9AppTokenVariables(theme: {
23
26
  readonly palette: G9PaletteValues;
24
27
  readonly scheme: G9ColorScheme;
25
28
  }, options?: G9AppTokenOptions, prefix?: string): Readonly<Record<string, string>>;
26
- /**
27
- * Only well-formed tokens of `allowed` names (a leading `--g9-` is dropped first), from a theme that came from outside
28
- * (the server, a file): values that cannot break out of a declaration, and pictures only as inline `data:` images.
29
- */
30
- export declare function g9SanitizeTokens(input: Readonly<Record<string, unknown>> | null | undefined, allowed: readonly string[]): Record<string, string>;
29
+ export { g9SanitizeTokens } from './sanitize.js';
31
30
  /** A text size step. */
32
31
  export type G9FontScale = 'small' | 'normal' | 'large' | 'larger';
33
32
  /** Whether effects are on, off, or decided by the device. */
@@ -64,6 +63,25 @@ export declare function g9EffectsEnabled(mode: G9EffectsMode, device?: {
64
63
  readonly reducedMotion?: boolean;
65
64
  readonly lowEnd?: boolean;
66
65
  }): boolean;
66
+ /**
67
+ * Whether effects are on and, when they are off, why (2.5.10): the person turned them off (`setting`), or `auto` on a
68
+ * low-end device (`lowEnd`) or a system that asks for less motion (`reducedMotion`).
69
+ */
70
+ export declare function g9EffectsState(mode: G9EffectsMode, device?: {
71
+ readonly reducedMotion?: boolean;
72
+ readonly lowEnd?: boolean;
73
+ }): {
74
+ readonly enabled: boolean;
75
+ readonly reason: G9EffectsReason;
76
+ };
77
+ /**
78
+ * The classes an app's root takes for the appearance in force (2.5.10, G9Hub's root classes): `g9-scheme-dark`,
79
+ * `g9-density-compact`, `g9-effects-off`, `g9-effects-off--low-end` / `--reduced-motion`, `g9-text-large`.
80
+ */
81
+ export declare function g9AppearanceClasses(settings: G9AppearanceSettings, scheme: G9ColorScheme, device?: {
82
+ readonly reducedMotion?: boolean;
83
+ readonly lowEnd?: boolean;
84
+ }): string[];
67
85
  /** The theme id in force: the chosen one, or the light / dark one for the device's scheme when following it. */
68
86
  export declare function g9ActiveThemeId(settings: G9AppearanceSettings, systemScheme: G9ColorScheme): string;
69
87
  /** The themes a person can pick, by source. */
@@ -73,8 +91,10 @@ export interface G9ThemeRegistrySnapshot {
73
91
  }
74
92
  /** Options of {@link createG9ThemeRegistry}. */
75
93
  export interface G9ThemeRegistryOptions {
76
- /** Default {@link g9BuiltInThemes}. */
77
- readonly builtins?: readonly G9ThemeDefinition[];
94
+ /** Default {@link g9BuiltInThemes}. Token themes (`{ id, name, scheme, tokens }`, 2.5.10) are read as they come. */
95
+ readonly builtins?: readonly (G9ThemeDefinition | G9TokenTheme)[];
96
+ /** How token themes are read (2.5.10: the scheme defaults an organisation theme falls back to). */
97
+ readonly tokenThemes?: G9TokenThemeOptions;
78
98
  /** The person's own themes as the app stored them (read before the first paint). */
79
99
  readonly personal?: readonly G9ThemeDefinition[];
80
100
  /** Saves the personal list (the device's preferences). */
@@ -97,8 +117,11 @@ export interface G9ThemeRegistry {
97
117
  removePersonal(id: string): void;
98
118
  readonly personal: () => readonly G9ThemeDefinition[];
99
119
  }
100
- /** A theme from the server or a file, read loosely (a newer server never breaks the client); null when broken. */
101
- export declare function g9ThemeFromInput(input: unknown, source: G9ThemeDefinition['source']): G9ThemeDefinition | null;
120
+ /**
121
+ * A theme from the server or a file, read loosely (a newer server never breaks the client); null when broken. A token
122
+ * theme (`{ id, name, scheme, tokens }`, G9Hub's format; 2.5.10) is read with {@link g9ThemeFromTokens}.
123
+ */
124
+ export declare function g9ThemeFromInput(input: unknown, source: G9ThemeDefinition['source'], tokenThemes?: G9TokenThemeOptions): G9ThemeDefinition | null;
102
125
  /** Creates a theme registry. */
103
126
  export declare function createG9ThemeRegistry(options?: G9ThemeRegistryOptions): G9ThemeRegistry;
104
127
  /** How a personal theme's surfaces are tinted. */
@@ -1 +1 @@
1
- {"version":3,"file":"appearance-kit.d.ts","sourceRoot":"","sources":["../../src/theme/appearance-kit.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAgB,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAClF,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,UAAU,EAAE,KAAK,cAAc,EAAkB,MAAM,iBAAiB,CAAC;AACvG,OAAO,EAAE,KAAK,iBAAiB,EAAgC,MAAM,cAAc,CAAC;AAGpF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAI7C,mEAAmE;AACnE,eAAO,MAAM,eAAe,2UAwBlB,CAAC;AAEX,0DAA0D;AAC1D,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,CAAC,CAAC;AAE9D,sCAAsC;AACtC,MAAM,WAAW,iBAAiB;IAChC,iGAAiG;IACjG,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,+CAA+C;IAC/C,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC,MAAM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AAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAChD,gHAAgH;IAChH,KAAK,CAAC,OAAO,EAAE,eAAe,EAAE,MAAM,EAAE,aAAa,GAAG;QAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CAC7G;AAID,sEAAsE;AACtE,eAAO,MAAM,YAAY,EAAE,SAAS,WAAW,EAsCrB,CAAC;AAE3B,8EAA8E;AAC9E,wBAAgB,WAAW,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,GAAE,SAAS,WAAW,EAAiB,GAAG,WAAW,GAAG,IAAI,CAEvG"}
@@ -2,6 +2,7 @@ import { g9DefaultShape } from "../tokens/shape.js";
2
2
  import { g9BuiltInThemes, importTheme } from "./appearance.js";
3
3
  import { formatColor, toHex, tryParseColor, withAlpha } from "./color.js";
4
4
  import { ensureContrast, mixOklch, readableOn } from "./oklch.js";
5
+ import { g9IsTokenTheme, g9ThemeFromTokens, g9ThemeTokenNames } from "./token-themes.js";
5
6
  const g9AppTokenNames = [
6
7
  'hover',
7
8
  'press',
@@ -27,6 +28,12 @@ const g9AppTokenNames = [
27
28
  'away',
28
29
  'busy'
29
30
  ];
31
+ const g9AllAppTokenNames = Object.freeze([
32
+ ...new Set([
33
+ ...g9AppTokenNames,
34
+ ...g9ThemeTokenNames
35
+ ])
36
+ ]);
30
37
  const css = (c)=>formatColor(c);
31
38
  function g9AppTokens(theme, options = {}) {
32
39
  var _p_InputBackground, _options_overrides;
@@ -70,25 +77,6 @@ function g9AppTokenVariables(theme, options = {}, prefix = 'g9-') {
70
77
  for (const [name, value] of Object.entries(g9AppTokens(theme, options)))out[`--${prefix}${name}`] = value;
71
78
  return Object.freeze(out);
72
79
  }
73
- const MAX_VALUE = 2000;
74
- function g9SanitizeTokens(input, allowed) {
75
- const known = new Set(allowed);
76
- const result = {};
77
- if (!input) return result;
78
- for (const [rawName, rawValue] of Object.entries(input)){
79
- var _value_match;
80
- const name = rawName.replace(/^--g9-/, '');
81
- if (!known.has(name) || 'string' != typeof rawValue) continue;
82
- const value = rawValue.trim();
83
- if (!value || value.length > MAX_VALUE) continue;
84
- if (/[;{}<>]|\/\*|\\/.test(value.replace(/url\("data:image\/svg\+xml,[^"]*"\)/g, ''))) continue;
85
- const urls = null != (_value_match = value.match(/url\(([^)]*)\)/g)) ? _value_match : [];
86
- if (!urls.some((url)=>!/^url\(["']?data:image\//.test(url))) {
87
- if (!/expression\s*\(|javascript:/i.test(value)) result[name] = value;
88
- }
89
- }
90
- return result;
91
- }
92
80
  const g9DefaultAppearance = Object.freeze({
93
81
  theme: 'system',
94
82
  light: 'classic',
@@ -151,12 +139,58 @@ function g9EffectsEnabled(mode, device = {}) {
151
139
  if ('auto' !== mode) return 'on' === mode;
152
140
  return !device.reducedMotion && !device.lowEnd;
153
141
  }
142
+ function g9EffectsState(mode, device = {}) {
143
+ if ('on' === mode) return {
144
+ enabled: true,
145
+ reason: null
146
+ };
147
+ if ('off' === mode) return {
148
+ enabled: false,
149
+ reason: 'setting'
150
+ };
151
+ if (device.lowEnd) return {
152
+ enabled: false,
153
+ reason: 'lowEnd'
154
+ };
155
+ if (device.reducedMotion) return {
156
+ enabled: false,
157
+ reason: 'reducedMotion'
158
+ };
159
+ return {
160
+ enabled: true,
161
+ reason: null
162
+ };
163
+ }
164
+ function g9AppearanceClasses(settings, scheme, device = {}) {
165
+ const effects = g9EffectsState(settings.effects, device);
166
+ const out = [
167
+ `g9-scheme-${scheme}`,
168
+ `g9-density-${settings.density}`,
169
+ `g9-text-${settings.fontScale}`
170
+ ];
171
+ out.push(effects.enabled ? 'g9-effects-on' : 'g9-effects-off');
172
+ if ('lowEnd' === effects.reason) out.push('g9-effects-off--low-end');
173
+ if ('reducedMotion' === effects.reason) out.push('g9-effects-off--reduced-motion');
174
+ return out;
175
+ }
154
176
  function g9ActiveThemeId(settings, systemScheme) {
155
177
  if ('system' !== settings.theme) return settings.theme;
156
178
  return 'dark' === systemScheme ? settings.dark : settings.light;
157
179
  }
158
- function g9ThemeFromInput(input, source) {
180
+ function g9ThemeFromInput(input, source, tokenThemes = {}) {
159
181
  if (!input || 'object' != typeof input) return null;
182
+ if (g9IsTokenTheme(input)) {
183
+ if ('string' != typeof input.name && ('object' != typeof input.name || null === input.name)) return null;
184
+ if ('string' == typeof input.name && !input.name.trim()) return null;
185
+ const def = g9ThemeFromTokens(input, {
186
+ ...tokenThemes,
187
+ source
188
+ });
189
+ return Object.freeze({
190
+ ...def,
191
+ id: 'org' !== source || def.id.startsWith('org:') ? def.id : `org:${def.id}`
192
+ });
193
+ }
160
194
  const t = input;
161
195
  try {
162
196
  const def = importTheme(JSON.stringify({
@@ -176,10 +210,13 @@ function g9ThemeFromInput(input, source) {
176
210
  }
177
211
  function createG9ThemeRegistry(options = {}) {
178
212
  var _options_builtins, _options_maxPersonal, _options_personal;
179
- const builtins = null != (_options_builtins = options.builtins) ? _options_builtins : g9BuiltInThemes;
213
+ const builtins = (null != (_options_builtins = options.builtins) ? _options_builtins : g9BuiltInThemes).map((t)=>g9IsTokenTheme(t) ? g9ThemeFromTokens(t, {
214
+ ...options.tokenThemes,
215
+ source: 'builtin'
216
+ }) : t);
180
217
  const max = Math.max(1, null != (_options_maxPersonal = options.maxPersonal) ? _options_maxPersonal : 12);
181
218
  let org = [];
182
- let personal = (null != (_options_personal = options.personal) ? _options_personal : []).map((t)=>g9ThemeFromInput(t, 'personal')).filter((t)=>null !== t).slice(0, max);
219
+ let personal = (null != (_options_personal = options.personal) ? _options_personal : []).map((t)=>g9ThemeFromInput(t, 'personal', options.tokenThemes)).filter((t)=>null !== t).slice(0, max);
183
220
  const listeners = new Set();
184
221
  let snapshot = {
185
222
  themes: [
@@ -217,7 +254,7 @@ function createG9ThemeRegistry(options = {}) {
217
254
  return null != (_find = find(id)) ? _find : builtins[0];
218
255
  },
219
256
  setOrgThemes (inputs) {
220
- org = inputs.map((i)=>g9ThemeFromInput(i, 'org')).filter((t)=>null !== t);
257
+ org = inputs.map((i)=>g9ThemeFromInput(i, 'org', options.tokenThemes)).filter((t)=>null !== t);
221
258
  rebuild();
222
259
  },
223
260
  savePersonal (theme) {
@@ -405,6 +442,7 @@ function g9Wallpaper(id, list = g9Wallpapers) {
405
442
  var _list_find;
406
443
  return null != (_list_find = list.find((w)=>w.id === id)) ? _list_find : null;
407
444
  }
408
- export { createG9ThemeRegistry, g9ActiveThemeId, g9AppTokenNames, g9AppTokenVariables, g9AppTokens, g9BuildPersonalTheme, g9DefaultAppearance, g9EffectsEnabled, g9FontScaleFactors, g9NewPersonalThemeId, g9NormalizeAppearance, g9PersonalDraft, g9SanitizeTokens, g9ScaledType, g9ThemeFileName, g9ThemeFromInput, g9Wallpaper, g9Wallpapers };
445
+ export { g9SanitizeTokens } from "./sanitize.js";
446
+ export { createG9ThemeRegistry, g9ActiveThemeId, g9AllAppTokenNames, g9AppTokenNames, g9AppTokenVariables, g9AppTokens, g9AppearanceClasses, g9BuildPersonalTheme, g9DefaultAppearance, g9EffectsEnabled, g9EffectsState, g9FontScaleFactors, g9NewPersonalThemeId, g9NormalizeAppearance, g9PersonalDraft, g9ScaledType, g9ThemeFileName, g9ThemeFromInput, g9Wallpaper, g9Wallpapers };
409
447
 
410
448
  //# sourceMappingURL=appearance-kit.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"theme/appearance-kit.js","sources":["../../src/theme/appearance-kit.ts"],"sourcesContent":["// The appearance kit (2.5.8, from G9Hub item 42): what an app's Settings → Appearance needs over the theme engine —\n// the tokens a messenger adds to a palette (hover / press, fields and skeletons, the accent's soft wash and glow,\n// glass, chat bubbles, presence colours), each derived from the palette so every theme and accent drives them; the\n// person's settings (theme, light and dark themes when following the device, accent, wallpaper, text size, effects,\n// density); a theme registry (built in, the organisation's from the server, the person's own on the device); a\n// personal theme built from a base theme, an accent and a surface tone; wallpapers; and a token sanitizer for themes\n// that come from outside. Pure: the app persists the settings and the personal themes.\nimport type { G9ColorToken, G9PaletteValues } from '../tokens/generated/palettes';\nimport { type G9Density, type G9TypeRole, type G9TypeRoleName, g9DefaultShape } from '../tokens/shape';\nimport { type G9ThemeDefinition, g9BuiltInThemes, importTheme } from './appearance';\nimport { formatColor, toHex, tryParseColor, withAlpha } from './color';\nimport { ensureContrast, mixOklch, readableOn } from './oklch';\nimport type { G9ColorScheme } from './theme';\n\n// ------------------------------------------------------------------------------------------------ the app tokens\n\n/** The tokens an app (a messenger) adds to the library palette. */\nexport const g9AppTokenNames = [\n 'hover',\n 'press',\n 'field',\n 'skeleton',\n 'accent-soft',\n 'accent-glow',\n 'accent-gradient',\n 'text-on-accent',\n 'glass',\n 'glass-border',\n 'bubble-mine',\n 'bubble-mine-text',\n 'bubble-mine-meta',\n 'bubble-other',\n 'bubble-other-text',\n 'bubble-other-border',\n 'highlight',\n 'link',\n 'selection',\n 'focus-ring',\n 'online',\n 'away',\n 'busy',\n] as const;\n\n/** The name of an app token (`hover`, `bubble-mine`…). */\nexport type G9AppTokenName = (typeof g9AppTokenNames)[number];\n\n/** Options of {@link g9AppTokens}. */\nexport interface G9AppTokenOptions {\n /** The person's accent (`#rrggbb`) over the theme's primary; null / invalid: the theme's own. */\n readonly accent?: string | null;\n /** Values the app (or a theme) sets itself. */\n readonly overrides?: Partial<Record<G9AppTokenName, string>>;\n}\n\nconst css = (c: Parameters<typeof formatColor>[0]) => formatColor(c);\n\n/** The app tokens for a palette and scheme: plain colours (and one gradient), never variables. */\nexport function g9AppTokens(\n theme: { readonly palette: G9PaletteValues; readonly scheme: G9ColorScheme },\n options: G9AppTokenOptions = {},\n): Readonly<Record<G9AppTokenName, string>> {\n const p = theme.palette;\n const dark = theme.scheme === 'dark';\n const accent = options.accent && tryParseColor(options.accent) ? options.accent : p.Primary;\n const own = accent === p.Primary;\n const onAccent = own ? p.OnPrimary : readableOn(accent);\n const surface = p.Surface;\n const field = (p as Partial<Record<string, string>>).InputBackground ?? p.SurfaceContainerLow;\n const out: Record<G9AppTokenName, string> = {\n hover: css(withAlpha(p.TextPrimary, dark ? 0.08 : 0.06)),\n press: css(withAlpha(p.TextPrimary, dark ? 0.14 : 0.1)),\n field,\n skeleton: p.SurfaceContainerHigh,\n 'accent-soft': css(withAlpha(accent, dark ? 0.16 : 0.11)),\n 'accent-glow': css(withAlpha(accent, dark ? 0.48 : 0.34)),\n 'accent-gradient': `linear-gradient(135deg, ${mixOklch(accent, '#ffffff', 0.2)} 0%, ${accent} 50%, ${mixOklch(accent, '#000000', 0.2)} 100%)`,\n 'text-on-accent': onAccent,\n glass: css(withAlpha(surface, dark ? 0.6 : 0.72)),\n 'glass-border': css(withAlpha(p.OutlineVariant, 0.6)),\n 'bubble-mine': accent,\n 'bubble-mine-text': onAccent,\n 'bubble-mine-meta': css(withAlpha(onAccent, 0.76)),\n 'bubble-other': p.SurfaceContainer,\n 'bubble-other-text': p.TextPrimary,\n 'bubble-other-border': p.OutlineVariant,\n highlight: css(withAlpha(accent, dark ? 0.22 : 0.14)),\n link: ensureContrast(accent, surface, 4.5),\n selection: css(withAlpha(accent, dark ? 0.34 : 0.22)),\n 'focus-ring': css(withAlpha(accent, dark ? 0.72 : 0.55)),\n online: p.Success,\n away: p.Warning,\n busy: p.Error,\n };\n for (const [name, value] of Object.entries(options.overrides ?? {})) if (value) out[name as G9AppTokenName] = value;\n return Object.freeze(out);\n}\n\n/** The app tokens as CSS variables (`--g9-hover`…; `prefix` default `g9-`), for G9Provider's `themeExtras`. */\nexport function g9AppTokenVariables(\n theme: { readonly palette: G9PaletteValues; readonly scheme: G9ColorScheme },\n options: G9AppTokenOptions = {},\n prefix = 'g9-',\n): Readonly<Record<string, string>> {\n const out: Record<string, string> = {};\n for (const [name, value] of Object.entries(g9AppTokens(theme, options))) out[`--${prefix}${name}`] = value;\n return Object.freeze(out);\n}\n\n// ------------------------------------------------------------------------------------------------ the sanitizer\n\nconst MAX_VALUE = 2000;\n\n/**\n * Only well-formed tokens of `allowed` names (a leading `--g9-` is dropped first), from a theme that came from outside\n * (the server, a file): values that cannot break out of a declaration, and pictures only as inline `data:` images.\n */\nexport function g9SanitizeTokens(\n input: Readonly<Record<string, unknown>> | null | undefined,\n allowed: readonly string[],\n): Record<string, string> {\n const known = new Set(allowed);\n const result: Record<string, string> = {};\n if (!input) return result;\n for (const [rawName, rawValue] of Object.entries(input)) {\n const name = rawName.replace(/^--g9-/, '');\n if (!known.has(name) || typeof rawValue !== 'string') continue;\n const value = rawValue.trim();\n if (!value || value.length > MAX_VALUE) continue;\n if (/[;{}<>]|\\/\\*|\\\\/.test(value.replace(/url\\(\"data:image\\/svg\\+xml,[^\"]*\"\\)/g, ''))) continue;\n const urls = value.match(/url\\(([^)]*)\\)/g) ?? [];\n if (urls.some((url) => !/^url\\([\"']?data:image\\//.test(url))) continue;\n if (/expression\\s*\\(|javascript:/i.test(value)) continue;\n result[name] = value;\n }\n return result;\n}\n\n// ------------------------------------------------------------------------------------------------ the settings\n\n/** A text size step. */\nexport type G9FontScale = 'small' | 'normal' | 'large' | 'larger';\n/** Whether effects are on, off, or decided by the device. */\nexport type G9EffectsMode = 'auto' | 'on' | 'off';\n\n/** What a person chose on Settings → Appearance (kept per device by the app). */\nexport interface G9AppearanceSettings {\n /** A theme id, or `system`: follow the device between `light` and `dark`. */\n readonly theme: string;\n readonly light: string;\n readonly dark: string;\n /** `#rrggbb`, or null for the theme's own. */\n readonly accent: string | null;\n /** A wallpaper id; `theme` keeps the theme's own. */\n readonly wallpaper: string;\n readonly fontScale: G9FontScale;\n /** `auto`: off on low-end devices and when the system asks for reduced motion. */\n readonly effects: G9EffectsMode;\n readonly density: G9Density;\n}\n\n/** The settings of a new install. */\nexport const g9DefaultAppearance: G9AppearanceSettings = Object.freeze({\n theme: 'system',\n light: 'classic',\n dark: 'midnight',\n accent: null,\n wallpaper: 'theme',\n fontScale: 'normal',\n effects: 'auto',\n density: 'regular',\n});\n\nconst SCALES: readonly G9FontScale[] = ['small', 'normal', 'large', 'larger'];\nconst EFFECTS: readonly G9EffectsMode[] = ['auto', 'on', 'off'];\nconst DENSITIES: readonly G9Density[] = ['compact', 'regular', 'comfortable'];\n\n/** Stored settings read back loosely: every unknown or broken field takes its default. */\nexport function g9NormalizeAppearance(\n raw: unknown,\n defaults: G9AppearanceSettings = g9DefaultAppearance,\n): G9AppearanceSettings {\n const r = (raw && typeof raw === 'object' ? raw : {}) as Partial<Record<keyof G9AppearanceSettings, unknown>>;\n const text = (v: unknown, d: string) => (typeof v === 'string' && v.trim() ? v : d);\n const pick = <T extends string>(v: unknown, list: readonly T[], d: T) => (list.includes(v as T) ? (v as T) : d);\n const accent = typeof r.accent === 'string' && /^#[0-9a-f]{6}$/i.test(r.accent) ? r.accent.toLowerCase() : null;\n return Object.freeze({\n theme: text(r.theme, defaults.theme),\n light: text(r.light, defaults.light),\n dark: text(r.dark, defaults.dark),\n accent: r.accent === undefined ? defaults.accent : accent,\n wallpaper: text(r.wallpaper, defaults.wallpaper),\n fontScale: pick(r.fontScale, SCALES, defaults.fontScale),\n effects: pick(r.effects, EFFECTS, defaults.effects),\n density: pick(r.density, DENSITIES, defaults.density),\n });\n}\n\n/** Text size factors. */\nexport const g9FontScaleFactors: Readonly<Record<G9FontScale, number>> = Object.freeze({\n small: 0.9,\n normal: 1,\n large: 1.12,\n larger: 1.25,\n});\n\n/** The type scale at a text size (sizes and line heights rounded), for G9Provider's `shape.type`. */\nexport function g9ScaledType(\n scale: G9FontScale | number,\n base: { readonly [K in G9TypeRoleName]: G9TypeRole } = g9DefaultShape.type,\n): { readonly [K in G9TypeRoleName]: G9TypeRole } {\n const k = typeof scale === 'number' ? scale : g9FontScaleFactors[scale];\n const out = {} as Record<G9TypeRoleName, G9TypeRole>;\n for (const [role, t] of Object.entries(base) as [G9TypeRoleName, G9TypeRole][])\n out[role] = { ...t, size: Math.round(t.size * k), lineHeight: Math.round(t.lineHeight * k) };\n return Object.freeze(out);\n}\n\n/** Whether effects (blur, glow, motion flourishes) are on. */\nexport function g9EffectsEnabled(\n mode: G9EffectsMode,\n device: { readonly reducedMotion?: boolean; readonly lowEnd?: boolean } = {},\n): boolean {\n if (mode !== 'auto') return mode === 'on';\n return !device.reducedMotion && !device.lowEnd;\n}\n\n/** The theme id in force: the chosen one, or the light / dark one for the device's scheme when following it. */\nexport function g9ActiveThemeId(settings: G9AppearanceSettings, systemScheme: G9ColorScheme): string {\n if (settings.theme !== 'system') return settings.theme;\n return systemScheme === 'dark' ? settings.dark : settings.light;\n}\n\n// ------------------------------------------------------------------------------------------------ the registry\n\n/** The themes a person can pick, by source. */\nexport interface G9ThemeRegistrySnapshot {\n readonly themes: readonly G9ThemeDefinition[];\n readonly revision: number;\n}\n\n/** Options of {@link createG9ThemeRegistry}. */\nexport interface G9ThemeRegistryOptions {\n /** Default {@link g9BuiltInThemes}. */\n readonly builtins?: readonly G9ThemeDefinition[];\n /** The person's own themes as the app stored them (read before the first paint). */\n readonly personal?: readonly G9ThemeDefinition[];\n /** Saves the personal list (the device's preferences). */\n readonly savePersonal?: (themes: readonly G9ThemeDefinition[]) => void;\n /** The most personal themes kept. Default 12. */\n readonly maxPersonal?: number;\n}\n\n/** Every theme: built in, the organisation's, the person's own (a store an appearance page reads). */\nexport interface G9ThemeRegistry {\n get(): G9ThemeRegistrySnapshot;\n subscribe(listener: () => void): () => void;\n /** A theme by id, or null. */\n find(id: string): G9ThemeDefinition | null;\n /** A theme by id; one that disappeared (an admin deleted it) falls back to the first built-in theme. */\n themeOrDefault(id: string): G9ThemeDefinition;\n /** Replaces the organisation's themes (from the server; each read loosely, broken ones dropped). */\n setOrgThemes(inputs: readonly unknown[]): void;\n /** Adds or replaces a personal theme (the newest first; past the limit the oldest go). */\n savePersonal(theme: G9ThemeDefinition): void;\n removePersonal(id: string): void;\n readonly personal: () => readonly G9ThemeDefinition[];\n}\n\n/** A theme from the server or a file, read loosely (a newer server never breaks the client); null when broken. */\nexport function g9ThemeFromInput(input: unknown, source: G9ThemeDefinition['source']): G9ThemeDefinition | null {\n if (!input || typeof input !== 'object') return null;\n const t = input as Partial<G9ThemeDefinition>;\n try {\n const def = importTheme(JSON.stringify({ format: 'g9-theme', version: 1, theme: t }));\n if (!def.name || (typeof def.name === 'string' && !def.name.trim())) return null;\n return Object.freeze({\n ...def,\n id: source === 'org' && !def.id.startsWith('org:') ? `org:${def.id}` : def.id,\n source,\n });\n } catch {\n return null;\n }\n}\n\n/** Creates a theme registry. */\nexport function createG9ThemeRegistry(options: G9ThemeRegistryOptions = {}): G9ThemeRegistry {\n const builtins = options.builtins ?? g9BuiltInThemes;\n const max = Math.max(1, options.maxPersonal ?? 12);\n let org: G9ThemeDefinition[] = [];\n let personal: G9ThemeDefinition[] = (options.personal ?? [])\n .map((t) => g9ThemeFromInput(t, 'personal'))\n .filter((t): t is G9ThemeDefinition => t !== null)\n .slice(0, max);\n const listeners = new Set<() => void>();\n let snapshot: G9ThemeRegistrySnapshot = { themes: [...builtins, ...personal], revision: 0 };\n const rebuild = () => {\n snapshot = { themes: [...builtins, ...org, ...personal], revision: snapshot.revision + 1 };\n for (const l of [...listeners]) l();\n };\n const find = (id: string) => snapshot.themes.find((t) => t.id === id) ?? null;\n return {\n get: () => snapshot,\n subscribe(listener) {\n listeners.add(listener);\n return () => listeners.delete(listener);\n },\n find,\n themeOrDefault: (id) => find(id) ?? (builtins[0] as G9ThemeDefinition),\n setOrgThemes(inputs) {\n org = inputs.map((i) => g9ThemeFromInput(i, 'org')).filter((t): t is G9ThemeDefinition => t !== null);\n rebuild();\n },\n savePersonal(theme) {\n const own = Object.freeze({ ...theme, source: 'personal' as const });\n personal = [own, ...personal.filter((t) => t.id !== theme.id)].slice(0, max);\n options.savePersonal?.(personal);\n rebuild();\n },\n removePersonal(id) {\n if (!personal.some((t) => t.id === id)) return;\n personal = personal.filter((t) => t.id !== id);\n options.savePersonal?.(personal);\n rebuild();\n },\n personal: () => personal,\n };\n}\n\n// ------------------------------------------------------------------------------------------------ personal themes\n\n/** How a personal theme's surfaces are tinted. */\nexport type G9SurfaceTone = 'neutral' | 'cool' | 'warm' | 'tinted';\n\n/** What the personal theme editor edits. */\nexport interface G9PersonalThemeDraft {\n readonly id: string;\n readonly name: string;\n /** The theme it starts from. */\n readonly base: G9ThemeDefinition;\n /** `#rrggbb`. */\n readonly accent: string;\n readonly surfaces: G9SurfaceTone;\n /** A wallpaper id, or `theme`. */\n readonly wallpaper: string;\n /** Light or dark (default the base's own mode, else light). */\n readonly scheme?: G9ColorScheme;\n}\n\n/** A fresh personal id (`me:…`). */\nexport function g9NewPersonalThemeId(random: () => number = Math.random): string {\n let id = '';\n for (let i = 0; i < 12; i++) id += Math.floor(random() * 36).toString(36);\n return `me:${id}`;\n}\n\n/** A draft starting from `base`. */\nexport function g9PersonalDraft(\n base: G9ThemeDefinition,\n name: string,\n id: string = g9NewPersonalThemeId(),\n): G9PersonalThemeDraft {\n return {\n id,\n name,\n base,\n accent: toHex(base.brand.primary),\n surfaces: 'neutral',\n wallpaper: base.wallpaper ?? 'theme',\n };\n}\n\nconst TINTS: Readonly<Record<'cool' | 'warm', string>> = { cool: '#3b82f6', warm: '#f59e0b' };\nconst SURFACES: readonly [G9ColorToken, number, number][] = [\n // token, tint in dark, tint in light (fractions)\n ['Background', 0.07, 0.04],\n ['BackgroundSecondary', 0.08, 0.05],\n ['Surface', 0.09, 0.05],\n ['SurfaceContainerLow', 0.09, 0.05],\n ['SurfaceContainer', 0.1, 0.06],\n ['SurfaceContainerHigh', 0.12, 0.08],\n];\n\n/**\n * The theme a draft describes: the base's recipe with the draft's accent, its surfaces tinted (cool, warm, or by the\n * accent) through overrides measured on `palettes` (the base's palettes for the accent: `recipePalettes(...)`).\n */\nexport function g9BuildPersonalTheme(\n draft: G9PersonalThemeDraft,\n palettes: { readonly light: G9PaletteValues; readonly dark: G9PaletteValues },\n): G9ThemeDefinition {\n const accent = tryParseColor(draft.accent) ? draft.accent : draft.base.brand.primary;\n const scheme: G9ColorScheme = draft.scheme ?? (draft.base.mode === 'dark' ? 'dark' : 'light');\n let overrides: G9ThemeDefinition['overrides'];\n if (draft.surfaces !== 'neutral') {\n const tint = draft.surfaces === 'tinted' ? accent : TINTS[draft.surfaces];\n const of = (s: G9ColorScheme) => {\n const o: Partial<Record<G9ColorToken, string>> = {};\n for (const [token, d, l] of SURFACES) o[token] = mixOklch(palettes[s][token], tint, s === 'dark' ? d : l);\n return o;\n };\n overrides = { light: of('light'), dark: of('dark') };\n }\n const name = draft.name.trim().slice(0, 60);\n return Object.freeze({\n id: draft.id,\n name: name || draft.base.name,\n source: 'personal' as const,\n recipe: draft.base.recipe,\n brand: { ...draft.base.brand, primary: accent },\n ...(overrides ? { overrides } : {}),\n ...(draft.base.shape ? { shape: draft.base.shape } : {}),\n mode: scheme,\n ...(draft.wallpaper !== 'theme' ? { wallpaper: draft.wallpaper } : {}),\n });\n}\n\n/** A file name for a theme export (letters, digits, dashes; any script). */\nexport function g9ThemeFileName(name: string): string {\n const slug = name\n .trim()\n .toLowerCase()\n .replace(/[\\s!-/:-@[-`{-~،؛؟«»]+/g, '-')\n .replace(/^-+|-+$/g, '')\n .slice(0, 40);\n return `${slug || 'theme'}.g9theme.json`;\n}\n\n// ------------------------------------------------------------------------------------------------ wallpapers\n\n/** A chat wallpaper: layers drawn behind a thread, from the palette so it follows the theme and accent. */\nexport interface G9Wallpaper {\n readonly id: string;\n readonly name: Readonly<Record<string, string>>;\n /** The background for a palette and scheme: a colour and optional gradient layers (Lynx `background-image`). */\n paint(palette: G9PaletteValues, scheme: G9ColorScheme): { readonly color: string; readonly image?: string };\n}\n\nconst glow = (c: string, a: number) => css(withAlpha(c, a));\n\n/** Wallpapers drawn with gradients only (no pictures, no network). */\nexport const g9Wallpapers: readonly G9Wallpaper[] = Object.freeze([\n { id: 'none', name: { en: 'None', fa: 'هیچ' }, paint: (p) => ({ color: p.Background }) },\n {\n id: 'aurora',\n name: { en: 'Aurora', fa: 'شفق' },\n paint: (p, s) => ({\n color: p.Background,\n image: `radial-gradient(circle at 0% 0%, ${glow(p.Primary, s === 'dark' ? 0.18 : 0.12)} 0%, transparent 60%), radial-gradient(circle at 100% 100%, ${glow(p.Tertiary, s === 'dark' ? 0.16 : 0.1)} 0%, transparent 60%)`,\n }),\n },\n {\n id: 'dusk',\n name: { en: 'Dusk', fa: 'غروب' },\n paint: (p, s) => ({\n color: p.Background,\n image: `linear-gradient(180deg, ${glow(p.Primary, s === 'dark' ? 0.12 : 0.08)} 0%, transparent 45%, ${glow(p.Secondary, s === 'dark' ? 0.1 : 0.06)} 100%)`,\n }),\n },\n {\n id: 'mesh',\n name: { en: 'Mesh', fa: 'توری' },\n paint: (p, s) => {\n const k = s === 'dark' ? 1 : 0.75;\n return {\n color: p.Background,\n image: [\n `radial-gradient(circle at 15% 20%, ${glow(p.Primary, 0.14 * k)} 0%, transparent 55%)`,\n `radial-gradient(circle at 85% 30%, ${glow(p.Tertiary, 0.14 * k)} 0%, transparent 55%)`,\n `radial-gradient(circle at 50% 95%, ${glow(p.Secondary, 0.14 * k)} 0%, transparent 55%)`,\n ].join(', '),\n };\n },\n },\n {\n id: 'paper',\n name: { en: 'Paper', fa: 'کاغذی' },\n paint: (p, s) => ({ color: mixOklch(p.Background, s === 'dark' ? '#000000' : '#f5ecd7', 0.25) }),\n },\n] satisfies G9Wallpaper[]);\n\n/** A wallpaper by id (from `list`, default {@link g9Wallpapers}), or null. */\nexport function g9Wallpaper(id: string, list: readonly G9Wallpaper[] = g9Wallpapers): G9Wallpaper | null {\n return list.find((w) => w.id === id) ?? null;\n}\n"],"names":["g9AppTokenNames","css","c","formatColor","g9AppTokens","theme","options","_p_InputBackground","_options_overrides","p","dark","accent","tryParseColor","own","onAccent","readableOn","surface","field","out","withAlpha","mixOklch","ensureContrast","name","value","Object","g9AppTokenVariables","prefix","MAX_VALUE","g9SanitizeTokens","input","allowed","known","Set","result","rawName","rawValue","_value_match","urls","url","g9DefaultAppearance","SCALES","EFFECTS","DENSITIES","g9NormalizeAppearance","raw","defaults","r","text","v","d","pick","list","undefined","g9FontScaleFactors","g9ScaledType","scale","base","g9DefaultShape","k","role","t","Math","g9EffectsEnabled","mode","device","g9ActiveThemeId","settings","systemScheme","g9ThemeFromInput","source","def","importTheme","JSON","createG9ThemeRegistry","_options_builtins","_options_maxPersonal","_options_personal","builtins","g9BuiltInThemes","max","org","personal","listeners","snapshot","rebuild","l","find","id","_snapshot_themes_find","listener","_find","inputs","i","g9NewPersonalThemeId","random","g9PersonalDraft","_base_wallpaper","toHex","TINTS","SURFACES","g9BuildPersonalTheme","draft","palettes","_draft_scheme","scheme","overrides","tint","of","s","o","token","g9ThemeFileName","slug","glow","a","g9Wallpapers","g9Wallpaper","_list_find","w"],"mappings":";;;;AAiBO,MAAMA,kBAAkB;IAC7B;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACD;AAaD,MAAMC,MAAM,CAACC,IAAyCC,YAAYD;AAG3D,SAASE,YACdC,KAA4E,EAC5EC,UAA6B,CAAC,CAAC;QAQjBC,oBA0B6BC;IAhC3C,MAAMC,IAAIJ,MAAM,OAAO;IACvB,MAAMK,OAAOL,AAAiB,WAAjBA,MAAM,MAAM;IACzB,MAAMM,SAASL,QAAQ,MAAM,IAAIM,cAAcN,QAAQ,MAAM,IAAIA,QAAQ,MAAM,GAAGG,EAAE,OAAO;IAC3F,MAAMI,MAAMF,WAAWF,EAAE,OAAO;IAChC,MAAMK,WAAWD,MAAMJ,EAAE,SAAS,GAAGM,WAAWJ;IAChD,MAAMK,UAAUP,EAAE,OAAO;IACzB,MAAMQ,QAAQ,QAAAV,CAAAA,qBAACE,EAAsC,eAAe,AAAD,IAArDF,qBAA0DE,EAAE,mBAAmB;IAC7F,MAAMS,MAAsC;QAC1C,OAAOjB,IAAIkB,UAAUV,EAAE,WAAW,EAAEC,OA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I;QAAO;QAC/B,OAAO,CAACnG,GAAGmG;YACT,MAAMlD,IAAIkD,AAAM,WAANA,IAAe,IAAI;YAC7B,OAAO;gBACL,OAAOnG,EAAE,UAAU;gBACnB,OAAO;oBACL,CAAC,mCAAmC,EAAEwG,KAAKxG,EAAE,OAAO,EAAE,OAAOiD,GAAG,qBAAqB,CAAC;oBACtF,CAAC,mCAAmC,EAAEuD,KAAKxG,EAAE,QAAQ,EAAE,OAAOiD,GAAG,qBAAqB,CAAC;oBACvF,CAAC,mCAAmC,EAAEuD,KAAKxG,EAAE,SAAS,EAAE,OAAOiD,GAAG,qBAAqB,CAAC;iBACzF,CAAC,IAAI,CAAC;YACT;QACF;IACF;IACA;QACE,IAAI;QACJ,MAAM;YAAE,IAAI;YAAS,IAAI;QAAQ;QACjC,OAAO,CAACjD,GAAGmG,IAAO;gBAAE,OAAOxF,SAASX,EAAE,UAAU,EAAEmG,AAAM,WAANA,IAAe,YAAY,WAAW;YAAM;IAChG;CACD;AAGM,SAASQ,YAAY7B,EAAU,EAAEpC,OAA+BgE,YAAY;QAC1EE;IAAP,OAAO,QAAAA,CAAAA,aAAAA,KAAK,IAAI,CAAC,CAACC,IAAMA,EAAE,EAAE,KAAK/B,GAAE,IAA5B8B,aAAiC;AAC1C"}
1
+ {"version":3,"file":"theme/appearance-kit.js","sources":["../../src/theme/appearance-kit.ts"],"sourcesContent":["// The appearance kit (2.5.8, from G9Hub item 42): what an app's Settings → Appearance needs over the theme engine —\n// the tokens a messenger adds to a palette (hover / press, fields and skeletons, the accent's soft wash and glow,\n// glass, chat bubbles, presence colours), each derived from the palette so every theme and accent drives them; the\n// person's settings (theme, light and dark themes when following the device, accent, wallpaper, text size, effects,\n// density); a theme registry (built in, the organisation's from the server, the person's own on the device); a\n// personal theme built from a base theme, an accent and a surface tone; wallpapers; and a token sanitizer for themes\n// that come from outside. Pure: the app persists the settings and the personal themes.\nimport type { G9ColorToken, G9PaletteValues } from '../tokens/generated/palettes';\nimport { type G9Density, type G9TypeRole, type G9TypeRoleName, g9DefaultShape } from '../tokens/shape';\nimport { type G9ThemeDefinition, g9BuiltInThemes, importTheme } from './appearance';\nimport { formatColor, toHex, tryParseColor, withAlpha } from './color';\nimport { ensureContrast, mixOklch, readableOn } from './oklch';\nimport type { G9ColorScheme } from './theme';\nimport {\n type G9EffectsReason,\n type G9TokenTheme,\n type G9TokenThemeOptions,\n g9IsTokenTheme,\n g9ThemeFromTokens,\n g9ThemeTokenNames,\n} from './token-themes';\n\n// ------------------------------------------------------------------------------------------------ the app tokens\n\n/** The tokens an app (a messenger) adds to the library palette. */\nexport const g9AppTokenNames = [\n 'hover',\n 'press',\n 'field',\n 'skeleton',\n 'accent-soft',\n 'accent-glow',\n 'accent-gradient',\n 'text-on-accent',\n 'glass',\n 'glass-border',\n 'bubble-mine',\n 'bubble-mine-text',\n 'bubble-mine-meta',\n 'bubble-other',\n 'bubble-other-text',\n 'bubble-other-border',\n 'highlight',\n 'link',\n 'selection',\n 'focus-ring',\n 'online',\n 'away',\n 'busy',\n] as const;\n\n/** The name of an app token (`hover`, `bubble-mine`…). */\nexport type G9AppTokenName = (typeof g9AppTokenNames)[number];\n\n/** Every app token name the library knows: its own and a token theme's (2.5.10), for a sanitizer or an editor. */\nexport const g9AllAppTokenNames: readonly string[] = Object.freeze([\n ...new Set<string>([...g9AppTokenNames, ...g9ThemeTokenNames]),\n]);\n\n/** Options of {@link g9AppTokens}. */\nexport interface G9AppTokenOptions {\n /** The person's accent (`#rrggbb`) over the theme's primary; null / invalid: the theme's own. */\n readonly accent?: string | null;\n /** Values the app (or a theme) sets itself. */\n readonly overrides?: Partial<Record<G9AppTokenName, string>>;\n}\n\nconst css = (c: Parameters<typeof formatColor>[0]) => formatColor(c);\n\n/** The app tokens for a palette and scheme: plain colours (and one gradient), never variables. */\nexport function g9AppTokens(\n theme: { readonly palette: G9PaletteValues; readonly scheme: G9ColorScheme },\n options: G9AppTokenOptions = {},\n): Readonly<Record<G9AppTokenName, string>> {\n const p = theme.palette;\n const dark = theme.scheme === 'dark';\n const accent = options.accent && tryParseColor(options.accent) ? options.accent : p.Primary;\n const own = accent === p.Primary;\n const onAccent = own ? p.OnPrimary : readableOn(accent);\n const surface = p.Surface;\n const field = (p as Partial<Record<string, string>>).InputBackground ?? p.SurfaceContainerLow;\n const out: Record<G9AppTokenName, string> = {\n hover: css(withAlpha(p.TextPrimary, dark ? 0.08 : 0.06)),\n press: css(withAlpha(p.TextPrimary, dark ? 0.14 : 0.1)),\n field,\n skeleton: p.SurfaceContainerHigh,\n 'accent-soft': css(withAlpha(accent, dark ? 0.16 : 0.11)),\n 'accent-glow': css(withAlpha(accent, dark ? 0.48 : 0.34)),\n 'accent-gradient': `linear-gradient(135deg, ${mixOklch(accent, '#ffffff', 0.2)} 0%, ${accent} 50%, ${mixOklch(accent, '#000000', 0.2)} 100%)`,\n 'text-on-accent': onAccent,\n glass: css(withAlpha(surface, dark ? 0.6 : 0.72)),\n 'glass-border': css(withAlpha(p.OutlineVariant, 0.6)),\n 'bubble-mine': accent,\n 'bubble-mine-text': onAccent,\n 'bubble-mine-meta': css(withAlpha(onAccent, 0.76)),\n 'bubble-other': p.SurfaceContainer,\n 'bubble-other-text': p.TextPrimary,\n 'bubble-other-border': p.OutlineVariant,\n highlight: css(withAlpha(accent, dark ? 0.22 : 0.14)),\n link: ensureContrast(accent, surface, 4.5),\n selection: css(withAlpha(accent, dark ? 0.34 : 0.22)),\n 'focus-ring': css(withAlpha(accent, dark ? 0.72 : 0.55)),\n online: p.Success,\n away: p.Warning,\n busy: p.Error,\n };\n for (const [name, value] of Object.entries(options.overrides ?? {})) if (value) out[name as G9AppTokenName] = value;\n return Object.freeze(out);\n}\n\n/** The app tokens as CSS variables (`--g9-hover`…; `prefix` default `g9-`), for G9Provider's `themeExtras`. */\nexport function g9AppTokenVariables(\n theme: { readonly palette: G9PaletteValues; readonly scheme: G9ColorScheme },\n options: G9AppTokenOptions = {},\n prefix = 'g9-',\n): Readonly<Record<string, string>> {\n const out: Record<string, string> = {};\n for (const [name, value] of Object.entries(g9AppTokens(theme, options))) out[`--${prefix}${name}`] = value;\n return Object.freeze(out);\n}\n\n// ------------------------------------------------------------------------------------------------ the sanitizer\n\nexport { g9SanitizeTokens } from './sanitize';\n\n// ------------------------------------------------------------------------------------------------ the settings\n\n/** A text size step. */\nexport type G9FontScale = 'small' | 'normal' | 'large' | 'larger';\n/** Whether effects are on, off, or decided by the device. */\nexport type G9EffectsMode = 'auto' | 'on' | 'off';\n\n/** What a person chose on Settings → Appearance (kept per device by the app). */\nexport interface G9AppearanceSettings {\n /** A theme id, or `system`: follow the device between `light` and `dark`. */\n readonly theme: string;\n readonly light: string;\n readonly dark: string;\n /** `#rrggbb`, or null for the theme's own. */\n readonly accent: string | null;\n /** A wallpaper id; `theme` keeps the theme's own. */\n readonly wallpaper: string;\n readonly fontScale: G9FontScale;\n /** `auto`: off on low-end devices and when the system asks for reduced motion. */\n readonly effects: G9EffectsMode;\n readonly density: G9Density;\n}\n\n/** The settings of a new install. */\nexport const g9DefaultAppearance: G9AppearanceSettings = Object.freeze({\n theme: 'system',\n light: 'classic',\n dark: 'midnight',\n accent: null,\n wallpaper: 'theme',\n fontScale: 'normal',\n effects: 'auto',\n density: 'regular',\n});\n\nconst SCALES: readonly G9FontScale[] = ['small', 'normal', 'large', 'larger'];\nconst EFFECTS: readonly G9EffectsMode[] = ['auto', 'on', 'off'];\nconst DENSITIES: readonly G9Density[] = ['compact', 'regular', 'comfortable'];\n\n/** Stored settings read back loosely: every unknown or broken field takes its default. */\nexport function g9NormalizeAppearance(\n raw: unknown,\n defaults: G9AppearanceSettings = g9DefaultAppearance,\n): G9AppearanceSettings {\n const r = (raw && typeof raw === 'object' ? raw : {}) as Partial<Record<keyof G9AppearanceSettings, unknown>>;\n const text = (v: unknown, d: string) => (typeof v === 'string' && v.trim() ? v : d);\n const pick = <T extends string>(v: unknown, list: readonly T[], d: T) => (list.includes(v as T) ? (v as T) : d);\n const accent = typeof r.accent === 'string' && /^#[0-9a-f]{6}$/i.test(r.accent) ? r.accent.toLowerCase() : null;\n return Object.freeze({\n theme: text(r.theme, defaults.theme),\n light: text(r.light, defaults.light),\n dark: text(r.dark, defaults.dark),\n accent: r.accent === undefined ? defaults.accent : accent,\n wallpaper: text(r.wallpaper, defaults.wallpaper),\n fontScale: pick(r.fontScale, SCALES, defaults.fontScale),\n effects: pick(r.effects, EFFECTS, defaults.effects),\n density: pick(r.density, DENSITIES, defaults.density),\n });\n}\n\n/** Text size factors. */\nexport const g9FontScaleFactors: Readonly<Record<G9FontScale, number>> = Object.freeze({\n small: 0.9,\n normal: 1,\n large: 1.12,\n larger: 1.25,\n});\n\n/** The type scale at a text size (sizes and line heights rounded), for G9Provider's `shape.type`. */\nexport function g9ScaledType(\n scale: G9FontScale | number,\n base: { readonly [K in G9TypeRoleName]: G9TypeRole } = g9DefaultShape.type,\n): { readonly [K in G9TypeRoleName]: G9TypeRole } {\n const k = typeof scale === 'number' ? scale : g9FontScaleFactors[scale];\n const out = {} as Record<G9TypeRoleName, G9TypeRole>;\n for (const [role, t] of Object.entries(base) as [G9TypeRoleName, G9TypeRole][])\n out[role] = { ...t, size: Math.round(t.size * k), lineHeight: Math.round(t.lineHeight * k) };\n return Object.freeze(out);\n}\n\n/** Whether effects (blur, glow, motion flourishes) are on. */\nexport function g9EffectsEnabled(\n mode: G9EffectsMode,\n device: { readonly reducedMotion?: boolean; readonly lowEnd?: boolean } = {},\n): boolean {\n if (mode !== 'auto') return mode === 'on';\n return !device.reducedMotion && !device.lowEnd;\n}\n\n/**\n * Whether effects are on and, when they are off, why (2.5.10): the person turned them off (`setting`), or `auto` on a\n * low-end device (`lowEnd`) or a system that asks for less motion (`reducedMotion`).\n */\nexport function g9EffectsState(\n mode: G9EffectsMode,\n device: { readonly reducedMotion?: boolean; readonly lowEnd?: boolean } = {},\n): { readonly enabled: boolean; readonly reason: G9EffectsReason } {\n if (mode === 'on') return { enabled: true, reason: null };\n if (mode === 'off') return { enabled: false, reason: 'setting' };\n if (device.lowEnd) return { enabled: false, reason: 'lowEnd' };\n if (device.reducedMotion) return { enabled: false, reason: 'reducedMotion' };\n return { enabled: true, reason: null };\n}\n\n/**\n * The classes an app's root takes for the appearance in force (2.5.10, G9Hub's root classes): `g9-scheme-dark`,\n * `g9-density-compact`, `g9-effects-off`, `g9-effects-off--low-end` / `--reduced-motion`, `g9-text-large`.\n */\nexport function g9AppearanceClasses(\n settings: G9AppearanceSettings,\n scheme: G9ColorScheme,\n device: { readonly reducedMotion?: boolean; readonly lowEnd?: boolean } = {},\n): string[] {\n const effects = g9EffectsState(settings.effects, device);\n const out = [`g9-scheme-${scheme}`, `g9-density-${settings.density}`, `g9-text-${settings.fontScale}`];\n out.push(effects.enabled ? 'g9-effects-on' : 'g9-effects-off');\n if (effects.reason === 'lowEnd') out.push('g9-effects-off--low-end');\n if (effects.reason === 'reducedMotion') out.push('g9-effects-off--reduced-motion');\n return out;\n}\n\n/** The theme id in force: the chosen one, or the light / dark one for the device's scheme when following it. */\nexport function g9ActiveThemeId(settings: G9AppearanceSettings, systemScheme: G9ColorScheme): string {\n if (settings.theme !== 'system') return settings.theme;\n return systemScheme === 'dark' ? settings.dark : settings.light;\n}\n\n// ------------------------------------------------------------------------------------------------ the registry\n\n/** The themes a person can pick, by source. */\nexport interface G9ThemeRegistrySnapshot {\n readonly themes: readonly G9ThemeDefinition[];\n readonly revision: number;\n}\n\n/** Options of {@link createG9ThemeRegistry}. */\nexport interface G9ThemeRegistryOptions {\n /** Default {@link g9BuiltInThemes}. Token themes (`{ id, name, scheme, tokens }`, 2.5.10) are read as they come. */\n readonly builtins?: readonly (G9ThemeDefinition | G9TokenTheme)[];\n /** How token themes are read (2.5.10: the scheme defaults an organisation theme falls back to). */\n readonly tokenThemes?: G9TokenThemeOptions;\n /** The person's own themes as the app stored them (read before the first paint). */\n readonly personal?: readonly G9ThemeDefinition[];\n /** Saves the personal list (the device's preferences). */\n readonly savePersonal?: (themes: readonly G9ThemeDefinition[]) => void;\n /** The most personal themes kept. Default 12. */\n readonly maxPersonal?: number;\n}\n\n/** Every theme: built in, the organisation's, the person's own (a store an appearance page reads). */\nexport interface G9ThemeRegistry {\n get(): G9ThemeRegistrySnapshot;\n subscribe(listener: () => void): () => void;\n /** A theme by id, or null. */\n find(id: string): G9ThemeDefinition | null;\n /** A theme by id; one that disappeared (an admin deleted it) falls back to the first built-in theme. */\n themeOrDefault(id: string): G9ThemeDefinition;\n /** Replaces the organisation's themes (from the server; each read loosely, broken ones dropped). */\n setOrgThemes(inputs: readonly unknown[]): void;\n /** Adds or replaces a personal theme (the newest first; past the limit the oldest go). */\n savePersonal(theme: G9ThemeDefinition): void;\n removePersonal(id: string): void;\n readonly personal: () => readonly G9ThemeDefinition[];\n}\n\n/**\n * A theme from the server or a file, read loosely (a newer server never breaks the client); null when broken. A token\n * theme (`{ id, name, scheme, tokens }`, G9Hub's format; 2.5.10) is read with {@link g9ThemeFromTokens}.\n */\nexport function g9ThemeFromInput(\n input: unknown,\n source: G9ThemeDefinition['source'],\n tokenThemes: G9TokenThemeOptions = {},\n): G9ThemeDefinition | null {\n if (!input || typeof input !== 'object') return null;\n if (g9IsTokenTheme(input)) {\n if (typeof input.name !== 'string' && (typeof input.name !== 'object' || input.name === null)) return null;\n if (typeof input.name === 'string' && !input.name.trim()) return null;\n const def = g9ThemeFromTokens(input, { ...tokenThemes, source });\n return Object.freeze({ ...def, id: source === 'org' && !def.id.startsWith('org:') ? `org:${def.id}` : def.id });\n }\n const t = input as Partial<G9ThemeDefinition>;\n try {\n const def = importTheme(JSON.stringify({ format: 'g9-theme', version: 1, theme: t }));\n if (!def.name || (typeof def.name === 'string' && !def.name.trim())) return null;\n return Object.freeze({\n ...def,\n id: source === 'org' && !def.id.startsWith('org:') ? `org:${def.id}` : def.id,\n source,\n });\n } catch {\n return null;\n }\n}\n\n/** Creates a theme registry. */\nexport function createG9ThemeRegistry(options: G9ThemeRegistryOptions = {}): G9ThemeRegistry {\n const builtins: readonly G9ThemeDefinition[] = (options.builtins ?? g9BuiltInThemes).map((t) =>\n g9IsTokenTheme(t) ? g9ThemeFromTokens(t, { ...options.tokenThemes, source: 'builtin' }) : t,\n );\n const max = Math.max(1, options.maxPersonal ?? 12);\n let org: G9ThemeDefinition[] = [];\n let personal: G9ThemeDefinition[] = (options.personal ?? [])\n .map((t) => g9ThemeFromInput(t, 'personal', options.tokenThemes))\n .filter((t): t is G9ThemeDefinition => t !== null)\n .slice(0, max);\n const listeners = new Set<() => void>();\n let snapshot: G9ThemeRegistrySnapshot = { themes: [...builtins, ...personal], revision: 0 };\n const rebuild = () => {\n snapshot = { themes: [...builtins, ...org, ...personal], revision: snapshot.revision + 1 };\n for (const l of [...listeners]) l();\n };\n const find = (id: string) => snapshot.themes.find((t) => t.id === id) ?? null;\n return {\n get: () => snapshot,\n subscribe(listener) {\n listeners.add(listener);\n return () => listeners.delete(listener);\n },\n find,\n themeOrDefault: (id) => find(id) ?? (builtins[0] as G9ThemeDefinition),\n setOrgThemes(inputs) {\n org = inputs\n .map((i) => g9ThemeFromInput(i, 'org', options.tokenThemes))\n .filter((t): t is G9ThemeDefinition => t !== null);\n rebuild();\n },\n savePersonal(theme) {\n const own = Object.freeze({ ...theme, source: 'personal' as const });\n personal = [own, ...personal.filter((t) => t.id !== theme.id)].slice(0, max);\n options.savePersonal?.(personal);\n rebuild();\n },\n removePersonal(id) {\n if (!personal.some((t) => t.id === id)) return;\n personal = personal.filter((t) => t.id !== id);\n options.savePersonal?.(personal);\n rebuild();\n },\n personal: () => personal,\n };\n}\n\n// ------------------------------------------------------------------------------------------------ personal themes\n\n/** How a personal theme's surfaces are tinted. */\nexport type G9SurfaceTone = 'neutral' | 'cool' | 'warm' | 'tinted';\n\n/** What the personal theme editor edits. */\nexport interface G9PersonalThemeDraft {\n readonly id: string;\n readonly name: string;\n /** The theme it starts from. */\n readonly base: G9ThemeDefinition;\n /** `#rrggbb`. */\n readonly accent: string;\n readonly surfaces: G9SurfaceTone;\n /** A wallpaper id, or `theme`. */\n readonly wallpaper: string;\n /** Light or dark (default the base's own mode, else light). */\n readonly scheme?: G9ColorScheme;\n}\n\n/** A fresh personal id (`me:…`). */\nexport function g9NewPersonalThemeId(random: () => number = Math.random): string {\n let id = '';\n for (let i = 0; i < 12; i++) id += Math.floor(random() * 36).toString(36);\n return `me:${id}`;\n}\n\n/** A draft starting from `base`. */\nexport function g9PersonalDraft(\n base: G9ThemeDefinition,\n name: string,\n id: string = g9NewPersonalThemeId(),\n): G9PersonalThemeDraft {\n return {\n id,\n name,\n base,\n accent: toHex(base.brand.primary),\n surfaces: 'neutral',\n wallpaper: base.wallpaper ?? 'theme',\n };\n}\n\nconst TINTS: Readonly<Record<'cool' | 'warm', string>> = { cool: '#3b82f6', warm: '#f59e0b' };\nconst SURFACES: readonly [G9ColorToken, number, number][] = [\n // token, tint in dark, tint in light (fractions)\n ['Background', 0.07, 0.04],\n ['BackgroundSecondary', 0.08, 0.05],\n ['Surface', 0.09, 0.05],\n ['SurfaceContainerLow', 0.09, 0.05],\n ['SurfaceContainer', 0.1, 0.06],\n ['SurfaceContainerHigh', 0.12, 0.08],\n];\n\n/**\n * The theme a draft describes: the base's recipe with the draft's accent, its surfaces tinted (cool, warm, or by the\n * accent) through overrides measured on `palettes` (the base's palettes for the accent: `recipePalettes(...)`).\n */\nexport function g9BuildPersonalTheme(\n draft: G9PersonalThemeDraft,\n palettes: { readonly light: G9PaletteValues; readonly dark: G9PaletteValues },\n): G9ThemeDefinition {\n const accent = tryParseColor(draft.accent) ? draft.accent : draft.base.brand.primary;\n const scheme: G9ColorScheme = draft.scheme ?? (draft.base.mode === 'dark' ? 'dark' : 'light');\n let overrides: G9ThemeDefinition['overrides'];\n if (draft.surfaces !== 'neutral') {\n const tint = draft.surfaces === 'tinted' ? accent : TINTS[draft.surfaces];\n const of = (s: G9ColorScheme) => {\n const o: Partial<Record<G9ColorToken, string>> = {};\n for (const [token, d, l] of SURFACES) o[token] = mixOklch(palettes[s][token], tint, s === 'dark' ? d : l);\n return o;\n };\n overrides = { light: of('light'), dark: of('dark') };\n }\n const name = draft.name.trim().slice(0, 60);\n return Object.freeze({\n id: draft.id,\n name: name || draft.base.name,\n source: 'personal' as const,\n recipe: draft.base.recipe,\n brand: { ...draft.base.brand, primary: accent },\n ...(overrides ? { overrides } : {}),\n ...(draft.base.shape ? { shape: draft.base.shape } : {}),\n mode: scheme,\n ...(draft.wallpaper !== 'theme' ? { wallpaper: draft.wallpaper } : {}),\n });\n}\n\n/** A file name for a theme export (letters, digits, dashes; any script). */\nexport function g9ThemeFileName(name: string): string {\n const slug = name\n .trim()\n .toLowerCase()\n .replace(/[\\s!-/:-@[-`{-~،؛؟«»]+/g, '-')\n .replace(/^-+|-+$/g, '')\n .slice(0, 40);\n return `${slug || 'theme'}.g9theme.json`;\n}\n\n// ------------------------------------------------------------------------------------------------ wallpapers\n\n/** A chat wallpaper: layers drawn behind a thread, from the palette so it follows the theme and accent. */\nexport interface G9Wallpaper {\n readonly id: string;\n readonly name: Readonly<Record<string, string>>;\n /** The background for a palette and scheme: a colour and optional gradient layers (Lynx `background-image`). */\n paint(palette: G9PaletteValues, scheme: G9ColorScheme): { readonly color: string; readonly image?: string };\n}\n\nconst glow = (c: string, a: number) => css(withAlpha(c, a));\n\n/** Wallpapers drawn with gradients only (no pictures, no network). */\nexport const g9Wallpapers: readonly G9Wallpaper[] = Object.freeze([\n { id: 'none', name: { en: 'None', fa: 'هیچ' }, paint: (p) => ({ color: p.Background }) },\n {\n id: 'aurora',\n name: { en: 'Aurora', fa: 'شفق' },\n paint: (p, s) => ({\n color: p.Background,\n image: `radial-gradient(circle at 0% 0%, ${glow(p.Primary, s === 'dark' ? 0.18 : 0.12)} 0%, transparent 60%), radial-gradient(circle at 100% 100%, ${glow(p.Tertiary, s === 'dark' ? 0.16 : 0.1)} 0%, transparent 60%)`,\n }),\n },\n {\n id: 'dusk',\n name: { en: 'Dusk', fa: 'غروب' },\n paint: (p, s) => ({\n color: p.Background,\n image: `linear-gradient(180deg, ${glow(p.Primary, s === 'dark' ? 0.12 : 0.08)} 0%, transparent 45%, ${glow(p.Secondary, s === 'dark' ? 0.1 : 0.06)} 100%)`,\n }),\n },\n {\n id: 'mesh',\n name: { en: 'Mesh', fa: 'توری' },\n paint: (p, s) => {\n const k = s === 'dark' ? 1 : 0.75;\n return {\n color: p.Background,\n image: [\n `radial-gradient(circle at 15% 20%, ${glow(p.Primary, 0.14 * k)} 0%, transparent 55%)`,\n `radial-gradient(circle at 85% 30%, ${glow(p.Tertiary, 0.14 * k)} 0%, transparent 55%)`,\n `radial-gradient(circle at 50% 95%, ${glow(p.Secondary, 0.14 * k)} 0%, transparent 55%)`,\n ].join(', '),\n };\n },\n },\n {\n id: 'paper',\n name: { en: 'Paper', fa: 'کاغذی' },\n paint: (p, s) => ({ color: mixOklch(p.Background, s === 'dark' ? '#000000' : '#f5ecd7', 0.25) }),\n },\n] satisfies G9Wallpaper[]);\n\n/** A wallpaper by id (from `list`, default {@link g9Wallpapers}), or null. */\nexport function g9Wallpaper(id: string, list: readonly G9Wallpaper[] = g9Wallpapers): G9Wallpaper | null {\n return list.find((w) => w.id === id) ?? null;\n}\n"],"names":["g9AppTokenNames","g9AllAppTokenNames","Object","Set","g9ThemeTokenNames","css","c","formatColor","g9AppTokens","theme","options","_p_InputBackground","_options_overrides","p","dark","accent","tryParseColor","own","onAccent","readableOn","surface","field","out","withAlpha","mixOklch","ensureContrast","name","value","g9AppTokenVariables","prefix","g9DefaultAppearance","SCALES","EFFECTS","DENSITIES","g9NormalizeAppearance","raw","defaults","r","text","v","d","pick","list","undefined","g9FontScaleFactors","g9ScaledType","scale","base","g9DefaultShape","k","role","t","Math","g9EffectsEnabled","mode","device","g9EffectsState","g9AppearanceClasses","settings","scheme","effects","g9ActiveThemeId","systemScheme","g9ThemeFromInput","input","source","tokenThemes","g9IsTokenTheme","def","g9ThemeFromTokens","importTheme","JSON","createG9ThemeRegistry","_options_builtins","_options_maxPersonal","_options_personal","builtins","g9BuiltInThemes","max","org","personal","listeners","snapshot","rebuild","l","find","id","_snapshot_themes_find","listener","_find","inputs","i","g9NewPersonalThemeId","random","g9PersonalDraft","_base_wallpaper","toHex","TINTS","SURFACES","g9BuildPersonalTheme","draft","palettes","_draft_scheme","overrides","tint","of","s","o","token","g9ThemeFileName","slug","glow","a","g9Wallpapers","g9Wallpaper","_list_find","w"],"mappings":";;;;;AAyBO,MAAMA,kBAAkB;IAC7B;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACD;AAMM,MAAMC,qBAAwCC,OAAO,MAAM,CAAC;OAC9D,IAAIC,IAAY;WAAIH;WAAoBI;KAAkB;CAC9D;AAUD,MAAMC,MAAM,CAACC,IAAyCC,YAAYD;AAG3D,SAASE,YACdC,KAA4E,EAC5EC,UAA6B,CAAC,CAAC;QAQjBC,oBA0B6BC;IAhC3C,MAAMC,IAAIJ,MAAM,OAAO;IACvB,MAAMK,OAAOL,AAAiB,WAAjBA,MAAM,MAAM;IACzB,MAAMM,SAASL,QAAQ,MAAM,IAAIM,cAAcN,QAAQ,MAAM,IAAIA,QAAQ,MAAM,GAAGG,EAAE,OAAO;IAC3F,MAAMI,MAAMF,WAAWF,EAAE,OAAO;IAChC,MAAMK,WAAWD,MAAMJ,EAAE,SAAS,GAAGM,WAAWJ;IAChD,MAAMK,UAAUP,EAAE,OAAO;IACzB,MAAMQ,QAAQ,QAAAV,CAAAA,qBAACE,EAAsC,eAAe,AAAD,IAArDF,qBAA0DE,EAAE,mBAAmB;IAC7F,MAAMS,MAAsC;QAC1C,OAAOjB,IAAIkB,UAAUV,EAAE,WAAW,EAAEC,OAAO,OAAO;QAClD,OAAOT,IAAIkB,UAAUV,EAAE,WAAW,EAAEC,OAAO,OAAO;QAClDO;QACA,UAAUR,EAAE,oBAAoB;QAChC,eAAeR,IAAIkB,UAAUR,QAAQD,O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AO;gBAAE,OAAOlF,SAASX,EAAE,UAAU,EAAE6F,AAAM,WAANA,IAAe,YAAY,WAAW;YAAM;IAChG;CACD;AAGM,SAASQ,YAAY5B,EAAU,EAAE5C,OAA+BuE,YAAY;QAC1EE;IAAP,OAAO,QAAAA,CAAAA,aAAAA,KAAK,IAAI,CAAC,CAACC,IAAMA,EAAE,EAAE,KAAK9B,GAAE,IAA5B6B,aAAiC;AAC1C"}
@@ -1,7 +1,7 @@
1
1
  import type { G9ColorToken } from '../tokens/generated/palettes.js';
2
2
  import { type G9ShapeSet } from '../tokens/shape.js';
3
3
  import type { G9BrandColors } from './brand.js';
4
- import { type G9ColorScheme, type G9PaletteOverrides, type G9ResolvedTheme, type G9ThemeMode, type G9ThemeStore } from './theme.js';
4
+ import { type G9ColorScheme, type G9PaletteOverrides, type G9ResolvedTheme, type G9SchemeAppTokens, type G9ThemeMode, type G9ThemeStore } from './theme.js';
5
5
  /** Where a theme definition comes from: built in, the organisation's, or the person's own. */
6
6
  export type G9ThemeSource = 'builtin' | 'org' | 'personal';
7
7
  /** One selectable theme. */
@@ -22,6 +22,11 @@ export interface G9ThemeDefinition {
22
22
  readonly mode?: G9ThemeMode;
23
23
  /** An app-defined wallpaper key. */
24
24
  readonly wallpaper?: string;
25
+ /**
26
+ * The theme's app tokens per scheme (2.5.10): `--g9-<name>` values beside the palette — a token theme's every token
27
+ * (`bubble-mine` gradient, glass, wallpaper, shadows, radii, motion), kept through the registry, export and import.
28
+ */
29
+ readonly appTokens?: G9SchemeAppTokens;
25
30
  }
26
31
  /** Accent colours offered by "pick a colour" UIs (G9Hub ACCENT_PRESETS, SAC brand picker). Tested for contrast. */
27
32
  export declare const g9AccentPresets: ReadonlyArray<{
@@ -1 +1 @@
1
- {"version":3,"file":"appearance.d.ts","sourceRoot":"","sources":["../../src/theme/appearance.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,KAA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W,CAAC,KAAK,EAAE,iBAAiB,GAAG,MAAM,CAE5D;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,iBAAiB,CA+C3E;AAED,mFAAmF;AACnF,eAAO,MAAM,eAAe,EAAE,SAAS,iBAAiB,EAgCxB,CAAC;AAEjC,8EAA8E;AAC9E,wBAAgB,SAAS,CAAC,KAAK,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAG5E;AAED,iFAAiF;AACjF,eAAO,MAAM,gBAAgB,GAAI,OAAO,iBAAiB,KAAG,SAAS,YAAY,EAG5D,CAAC"}
@@ -2,6 +2,7 @@ import { G9Error } from "../errors.js";
2
2
  import { resolveShape } from "../tokens/shape.js";
3
3
  import { tryParseColor } from "./color.js";
4
4
  import { recipePalettes } from "./recipe.js";
5
+ import { g9SanitizeTokens } from "./sanitize.js";
5
6
  import { lazyPalettes } from "./theme.js";
6
7
  const g9AccentPresets = Object.freeze([
7
8
  {
@@ -109,10 +110,12 @@ function applyThemeDefinition(store, theme) {
109
110
  }) : palette;
110
111
  store.beginBatch();
111
112
  try {
113
+ var _store_setAppTokens;
112
114
  store.setPalettes(lazyPalettes((scheme)=>{
113
115
  var _theme_overrides;
114
116
  return layer(base[scheme], null == (_theme_overrides = theme.overrides) ? void 0 : _theme_overrides[scheme]);
115
117
  }));
118
+ null == (_store_setAppTokens = store.setAppTokens) || _store_setAppTokens.call(store, theme.appTokens);
116
119
  if (theme.mode) store.setMode(theme.mode);
117
120
  } finally{
118
121
  store.endBatch();
@@ -120,18 +123,22 @@ function applyThemeDefinition(store, theme) {
120
123
  return resolveShape(theme.shape);
121
124
  }
122
125
  function previewThemeDefinition(theme, scheme = 'light') {
123
- var _theme_overrides;
126
+ var _theme_overrides, _theme_appTokens;
124
127
  const base = recipePalettes(theme.recipe, theme.brand)[scheme];
125
128
  const over = null == (_theme_overrides = theme.overrides) ? void 0 : _theme_overrides[scheme];
126
129
  const palette = over ? Object.freeze({
127
130
  ...base,
128
131
  ...stripUndefined(over)
129
132
  }) : base;
133
+ const appTokens = null == (_theme_appTokens = theme.appTokens) ? void 0 : _theme_appTokens[scheme];
130
134
  return Object.freeze({
131
135
  mode: scheme,
132
136
  systemScheme: scheme,
133
137
  scheme,
134
- palette
138
+ palette,
139
+ ...appTokens ? {
140
+ appTokens
141
+ } : {}
135
142
  });
136
143
  }
137
144
  function stripUndefined(o) {
@@ -174,10 +181,21 @@ function importTheme(json, newId) {
174
181
  if (null == (_t_shape = t.shape) ? void 0 : _t_shape.radii) {
175
182
  for (const [key, value] of Object.entries(t.shape.radii))if ('number' != typeof value || value < 0 || value > 999) throw new G9Error('theme-import', `Radius "${key}" is not a number 0–999.`);
176
183
  }
184
+ const appTokens = t.appTokens ? {
185
+ ...t.appTokens.light ? {
186
+ light: Object.freeze(g9SanitizeTokens(t.appTokens.light))
187
+ } : {},
188
+ ...t.appTokens.dark ? {
189
+ dark: Object.freeze(g9SanitizeTokens(t.appTokens.dark))
190
+ } : {}
191
+ } : void 0;
177
192
  return Object.freeze({
178
193
  ...t,
179
194
  id: null != newId ? newId : t.id,
180
- source: 'personal'
195
+ source: 'personal',
196
+ ...appTokens ? {
197
+ appTokens
198
+ } : {}
181
199
  });
182
200
  }
183
201
  const g9BuiltInThemes = Object.freeze([
@@ -1 +1 @@
1
- {"version":3,"file":"theme/appearance.js","sources":["../../src/theme/appearance.ts"],"sourcesContent":["// Appearance: the themes a person can pick (built-in, the organisation's, their own), each a recipe + brand + optional\n// designer overrides and shape, applied to the theme store in one batch. Personal themes travel as versioned JSON\n// (export / import, G9Hub's PersonalThemeSheet). Pure: the app persists the choice and the personal list.\nimport { G9Error } from '../errors';\nimport type { G9ColorToken } from '../tokens/generated/palettes';\nimport { type G9ShapeSet, resolveShape } from '../tokens/shape';\nimport type { G9BrandColors } from './brand';\nimport { tryParseColor } from './color';\nimport { recipePalettes } from './recipe';\nimport {\n type G9ColorScheme,\n type G9PaletteOverrides,\n type G9ResolvedTheme,\n type G9ThemeMode,\n type G9ThemeStore,\n lazyPalettes,\n} from './theme';\n\n/** Where a theme definition comes from: built in, the organisation's, or the person's own. */\nexport type G9ThemeSource = 'builtin' | 'org' | 'personal';\n\n/** One selectable theme. */\nexport interface G9ThemeDefinition {\n readonly id: string;\n /** Display name, one string or per language. */\n readonly name: string | Readonly<Record<string, string>>;\n readonly source: G9ThemeSource;\n readonly recipe: string;\n readonly brand: G9BrandColors;\n /** Designer overrides on top of the recipe, per scheme. */\n readonly overrides?: { readonly light?: G9PaletteOverrides; readonly dark?: G9PaletteOverrides };\n readonly shape?: Partial<G9ShapeSet>;\n /** A mode this theme forces (`'dark'` for a night theme); otherwise the user's mode stays. */\n readonly mode?: G9ThemeMode;\n /** An app-defined wallpaper key. */\n readonly wallpaper?: string;\n}\n\n/** Accent colours offered by \"pick a colour\" UIs (G9Hub ACCENT_PRESETS, SAC brand picker). Tested for contrast. */\nexport const g9AccentPresets: ReadonlyArray<{\n readonly id: string;\n readonly color: string;\n readonly name: Readonly<Record<string, string>>;\n}> = Object.freeze([\n { id: 'emerald', color: '#349D57', name: { en: 'Emerald', fa: 'زمردی' } },\n { id: 'teal', color: '#01A890', name: { en: 'Teal', fa: 'فیروزه‌ای' } },\n { id: 'ocean', color: '#2B6FB3', name: { en: 'Ocean', fa: 'اقیانوسی' } },\n { id: 'indigo', color: '#4F55D8', name: { en: 'Indigo', fa: 'نیلی' } },\n { id: 'violet', color: '#7B5EA7', name: { en: 'Violet', fa: 'بنفش' } },\n { id: 'rose', color: '#D0457A', name: { en: 'Rose', fa: 'گلی' } },\n { id: 'terracotta', color: '#C2552D', name: { en: 'Terracotta', fa: 'آجری' } },\n { id: 'amber', color: '#B7791F', name: { en: 'Amber', fa: 'کهربایی' } },\n { id: 'olive', color: '#6B7A2A', name: { en: 'Olive', fa: 'زیتونی' } },\n { id: 'slate', color: '#4A5A6A', name: { en: 'Slate', fa: 'سنگی' } },\n { id: 'graphite', color: '#2F3437', name: { en: 'Graphite', fa: 'گرافیتی' } },\n { id: 'saffron', color: '#E0A100', name: { en: 'Saffron', fa: 'زعفرانی' } },\n]);\n\n/**\n * Paints `theme` into `store` (one notification): the recipe's palettes for its brand, the designer overrides layered\n * per scheme, the forced mode if any. Returns the theme's resolved shape for the provider's CSS variables.\n */\nexport function applyThemeDefinition(store: G9ThemeStore, theme: G9ThemeDefinition): G9ShapeSet {\n const base = recipePalettes(theme.recipe, theme.brand);\n const layer = (palette: typeof base.light, over?: G9PaletteOverrides) =>\n over ? (Object.freeze({ ...palette, ...stripUndefined(over) }) as typeof palette) : palette;\n store.beginBatch();\n try {\n // each scheme built when the store first paints it (the dark one waits for dark mode)\n store.setPalettes(lazyPalettes((scheme) => layer(base[scheme], theme.overrides?.[scheme])));\n if (theme.mode) store.setMode(theme.mode);\n } finally {\n store.endBatch();\n }\n return resolveShape(theme.shape);\n}\n\n/**\n * A theme definition resolved for one scheme without touching any store: what `G9ThemePreviewCard` shows (a theme\n * picker's cards, an editor's draft). Only the asked scheme's palette is built (palettes are cached by recipe and\n * brand, so showing the same card again costs nothing).\n */\nexport function previewThemeDefinition(theme: G9ThemeDefinition, scheme: G9ColorScheme = 'light'): G9ResolvedTheme {\n const base = recipePalettes(theme.recipe, theme.brand)[scheme];\n const over = theme.overrides?.[scheme];\n const palette = over ? (Object.freeze({ ...base, ...stripUndefined(over) }) as typeof base) : base;\n return Object.freeze({ mode: scheme, systemScheme: scheme, scheme, palette });\n}\n\nfunction stripUndefined(o: G9PaletteOverrides): Record<string, string> {\n const out: Record<string, string> = {};\n for (const [k, v] of Object.entries(o)) if (v !== undefined) out[k] = v;\n return out;\n}\n\nconst FORMAT = 'g9-theme';\nconst VERSION = 1;\n\n/** A theme as portable JSON (personal themes, sharing, backup). */\nexport function exportTheme(theme: G9ThemeDefinition): string {\n return JSON.stringify({ format: FORMAT, version: VERSION, theme: { ...theme, source: 'personal' } });\n}\n\n/**\n * Reads exported JSON back, checking every colour and the shape's numbers; the result is always a personal theme with\n * a fresh id when `newId` is given (an import never overwrites a built-in).\n * @throws {G9Error} `theme-import` with the reason.\n */\nexport function importTheme(json: string, newId?: string): G9ThemeDefinition {\n let data: unknown;\n try {\n data = JSON.parse(json);\n } catch {\n throw new G9Error('theme-import', 'Not a theme file (not JSON).');\n }\n const d = data as { format?: unknown; version?: unknown; theme?: Partial<G9ThemeDefinition> };\n if (d?.format !== FORMAT) throw new G9Error('theme-import', 'Not a G9 theme file.');\n if (typeof d.version !== 'number' || d.version > VERSION)\n throw new G9Error(\n 'theme-import',\n `Theme file version ${String(d.version)} is newer than this app reads (${VERSION}).`,\n );\n const t = d.theme;\n if (!t || typeof t.id !== 'string' || typeof t.recipe !== 'string' || !t.brand || typeof t.brand !== 'object') {\n throw new G9Error('theme-import', 'The theme lacks an id, a recipe or a brand.');\n }\n const colours: [string, unknown][] = [\n ...Object.entries(t.brand),\n ...Object.entries(t.overrides?.light ?? {}),\n ...Object.entries(t.overrides?.dark ?? {}),\n ];\n for (const [key, value] of colours) {\n if (value !== undefined && (typeof value !== 'string' || !tryParseColor(value))) {\n throw new G9Error('theme-import', `\"${key}\" is not a colour: ${JSON.stringify(value)}.`);\n }\n }\n if (t.shape?.radii) {\n for (const [key, value] of Object.entries(t.shape.radii)) {\n if (typeof value !== 'number' || value < 0 || value > 999)\n throw new G9Error('theme-import', `Radius \"${key}\" is not a number 0–999.`);\n }\n }\n return Object.freeze({ ...(t as G9ThemeDefinition), id: newId ?? t.id, source: 'personal' as const });\n}\n\n/** The built-in themes over the built-in recipes, one per accent preset family. */\nexport const g9BuiltInThemes: readonly G9ThemeDefinition[] = Object.freeze([\n {\n id: 'classic',\n name: { en: 'Classic', fa: 'کلاسیک' },\n source: 'builtin',\n recipe: 'stock',\n brand: { primary: '#349D57' },\n },\n {\n id: 'tonal',\n name: { en: 'Tonal', fa: 'هم‌رنگ' },\n source: 'builtin',\n recipe: 'tonal',\n brand: { primary: '#2B6FB3' },\n },\n { id: 'calm', name: { en: 'Calm', fa: 'آرام' }, source: 'builtin', recipe: 'neutral', brand: { primary: '#4A5A6A' } },\n { id: 'vivid', name: { en: 'Vivid', fa: 'شاد' }, source: 'builtin', recipe: 'tinted', brand: { primary: '#D0457A' } },\n {\n id: 'midnight',\n name: { en: 'Midnight', fa: 'نیمه‌شب' },\n source: 'builtin',\n recipe: 'midnight',\n brand: { primary: '#01C6AC' },\n mode: 'dark',\n },\n {\n id: 'accessible',\n name: { en: 'High contrast', fa: 'کنتراست بالا' },\n source: 'builtin',\n recipe: 'contrast',\n brand: { primary: '#1F5FA8' },\n },\n] satisfies G9ThemeDefinition[]);\n\n/** A theme's display name in `language` (falls back to English, then any). */\nexport function themeName(theme: G9ThemeDefinition, language: string): string {\n if (typeof theme.name === 'string') return theme.name;\n return theme.name[language] ?? theme.name.en ?? Object.values(theme.name)[0] ?? theme.id;\n}\n\n/** Tokens a theme overrides (for a \"what is changed\" list in a theme editor). */\nexport const overriddenTokens = (theme: G9ThemeDefinition): readonly G9ColorToken[] =>\n [\n ...new Set([...Object.keys(theme.overrides?.light ?? {}), ...Object.keys(theme.overrides?.dark ?? {})]),\n ] as G9ColorToken[];\n"],"names":["g9AccentPresets","Object","applyThemeDefinition","store","theme","base","recipePalettes","layer","palette","over","stripUndefined","lazyPalettes","scheme","_theme_overrides","resolveShape","previewThemeDefinition","o","out","k","v","undefined","FORMAT","VERSION","exportTheme","JSON","importTheme","json","newId","_t_overrides","_t_overrides1","_t_shape","data","G9Error","d","String","t","colours","key","value","tryParseColor","g9BuiltInThemes","themeName","language","_ref","overriddenTokens","_theme_overrides1","Set"],"mappings":";;;;;AAuCO,MAAMA,kBAIRC,OAAO,MAAM,CAAC;IACjB;QAAE,IAAI;QAAW,OAAO;QAAW,MAAM;YAAE,IAAI;YAAW,IAAI;QAAQ;IAAE;IACxE;QAAE,IAAI;QAAQ,OAAO;QAAW,MAAM;YAAE,IAAI;YAAQ,IAAI;QAAY;IAA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,QAAAA,QAAAA,CAAAA,uBAAAA,MAAM,IAAI,CAACD,SAAS,AAAD,IAAnBC,uBAAwBvC,MAAM,IAAI,CAAC,EAAE,AAAD,IAApCuC,QAAyC1C,OAAO,MAAM,CAACG,MAAM,IAAI,CAAC,CAAC,EAAE,AAAD,IAApEuC,OAAyEvC,MAAM,EAAE;AAC1F;AAGO,MAAMwC,mBAAmB,CAACxC;;QAEFS,kBAA8CgC;WAD3E;WACK,IAAIC,IAAI;eAAI7C,OAAO,IAAI,CAAC,QAAD,gBAACY,CAAAA,mBAAAA,MAAM,SAAS,AAAD,IAAdA,KAAAA,IAAAA,iBAAiB,KAAK,AAAD,IAAC,OAAI,CAAC;eAAOZ,OAAO,IAAI,CAAC,QAAD,iBAAC4C,CAAAA,oBAAAA,MAAM,SAAS,AAAD,IAAdA,KAAAA,IAAAA,kBAAiB,IAAI,AAAD,IAAC,QAAI,CAAC;SAAG;KACvG"}
1
+ {"version":3,"file":"theme/appearance.js","sources":["../../src/theme/appearance.ts"],"sourcesContent":["// Appearance: the themes a person can pick (built-in, the organisation's, their own), each a recipe + brand + optional\n// designer overrides and shape, applied to the theme store in one batch. Personal themes travel as versioned JSON\n// (export / import, G9Hub's PersonalThemeSheet). Pure: the app persists the choice and the personal list.\nimport { G9Error } from '../errors';\nimport type { G9ColorToken } from '../tokens/generated/palettes';\nimport { type G9ShapeSet, resolveShape } from '../tokens/shape';\nimport type { G9BrandColors } from './brand';\nimport { tryParseColor } from './color';\nimport { recipePalettes } from './recipe';\nimport { g9SanitizeTokens } from './sanitize';\nimport {\n type G9ColorScheme,\n type G9PaletteOverrides,\n type G9ResolvedTheme,\n type G9SchemeAppTokens,\n type G9ThemeMode,\n type G9ThemeStore,\n lazyPalettes,\n} from './theme';\n\n/** Where a theme definition comes from: built in, the organisation's, or the person's own. */\nexport type G9ThemeSource = 'builtin' | 'org' | 'personal';\n\n/** One selectable theme. */\nexport interface G9ThemeDefinition {\n readonly id: string;\n /** Display name, one string or per language. */\n readonly name: string | Readonly<Record<string, string>>;\n readonly source: G9ThemeSource;\n readonly recipe: string;\n readonly brand: G9BrandColors;\n /** Designer overrides on top of the recipe, per scheme. */\n readonly overrides?: { readonly light?: G9PaletteOverrides; readonly dark?: G9PaletteOverrides };\n readonly shape?: Partial<G9ShapeSet>;\n /** A mode this theme forces (`'dark'` for a night theme); otherwise the user's mode stays. */\n readonly mode?: G9ThemeMode;\n /** An app-defined wallpaper key. */\n readonly wallpaper?: string;\n /**\n * The theme's app tokens per scheme (2.5.10): `--g9-<name>` values beside the palette — a token theme's every token\n * (`bubble-mine` gradient, glass, wallpaper, shadows, radii, motion), kept through the registry, export and import.\n */\n readonly appTokens?: G9SchemeAppTokens;\n}\n\n/** Accent colours offered by \"pick a colour\" UIs (G9Hub ACCENT_PRESETS, SAC brand picker). Tested for contrast. */\nexport const g9AccentPresets: ReadonlyArray<{\n readonly id: string;\n readonly color: string;\n readonly name: Readonly<Record<string, string>>;\n}> = Object.freeze([\n { id: 'emerald', color: '#349D57', name: { en: 'Emerald', fa: 'زمردی' } },\n { id: 'teal', color: '#01A890', name: { en: 'Teal', fa: 'فیروزه‌ای' } },\n { id: 'ocean', color: '#2B6FB3', name: { en: 'Ocean', fa: 'اقیانوسی' } },\n { id: 'indigo', color: '#4F55D8', name: { en: 'Indigo', fa: 'نیلی' } },\n { id: 'violet', color: '#7B5EA7', name: { en: 'Violet', fa: 'بنفش' } },\n { id: 'rose', color: '#D0457A', name: { en: 'Rose', fa: 'گلی' } },\n { id: 'terracotta', color: '#C2552D', name: { en: 'Terracotta', fa: 'آجری' } },\n { id: 'amber', color: '#B7791F', name: { en: 'Amber', fa: 'کهربایی' } },\n { id: 'olive', color: '#6B7A2A', name: { en: 'Olive', fa: 'زیتونی' } },\n { id: 'slate', color: '#4A5A6A', name: { en: 'Slate', fa: 'سنگی' } },\n { id: 'graphite', color: '#2F3437', name: { en: 'Graphite', fa: 'گرافیتی' } },\n { id: 'saffron', color: '#E0A100', name: { en: 'Saffron', fa: 'زعفرانی' } },\n]);\n\n/**\n * Paints `theme` into `store` (one notification): the recipe's palettes for its brand, the designer overrides layered\n * per scheme, the forced mode if any. Returns the theme's resolved shape for the provider's CSS variables.\n */\nexport function applyThemeDefinition(store: G9ThemeStore, theme: G9ThemeDefinition): G9ShapeSet {\n const base = recipePalettes(theme.recipe, theme.brand);\n const layer = (palette: typeof base.light, over?: G9PaletteOverrides) =>\n over ? (Object.freeze({ ...palette, ...stripUndefined(over) }) as typeof palette) : palette;\n store.beginBatch();\n try {\n // each scheme built when the store first paints it (the dark one waits for dark mode)\n store.setPalettes(lazyPalettes((scheme) => layer(base[scheme], theme.overrides?.[scheme])));\n store.setAppTokens?.(theme.appTokens);\n if (theme.mode) store.setMode(theme.mode);\n } finally {\n store.endBatch();\n }\n return resolveShape(theme.shape);\n}\n\n/**\n * A theme definition resolved for one scheme without touching any store: what `G9ThemePreviewCard` shows (a theme\n * picker's cards, an editor's draft). Only the asked scheme's palette is built (palettes are cached by recipe and\n * brand, so showing the same card again costs nothing).\n */\nexport function previewThemeDefinition(theme: G9ThemeDefinition, scheme: G9ColorScheme = 'light'): G9ResolvedTheme {\n const base = recipePalettes(theme.recipe, theme.brand)[scheme];\n const over = theme.overrides?.[scheme];\n const palette = over ? (Object.freeze({ ...base, ...stripUndefined(over) }) as typeof base) : base;\n const appTokens = theme.appTokens?.[scheme];\n return Object.freeze({ mode: scheme, systemScheme: scheme, scheme, palette, ...(appTokens ? { appTokens } : {}) });\n}\n\nfunction stripUndefined(o: G9PaletteOverrides): Record<string, string> {\n const out: Record<string, string> = {};\n for (const [k, v] of Object.entries(o)) if (v !== undefined) out[k] = v;\n return out;\n}\n\nconst FORMAT = 'g9-theme';\nconst VERSION = 1;\n\n/** A theme as portable JSON (personal themes, sharing, backup). */\nexport function exportTheme(theme: G9ThemeDefinition): string {\n return JSON.stringify({ format: FORMAT, version: VERSION, theme: { ...theme, source: 'personal' } });\n}\n\n/**\n * Reads exported JSON back, checking every colour and the shape's numbers; the result is always a personal theme with\n * a fresh id when `newId` is given (an import never overwrites a built-in).\n * @throws {G9Error} `theme-import` with the reason.\n */\nexport function importTheme(json: string, newId?: string): G9ThemeDefinition {\n let data: unknown;\n try {\n data = JSON.parse(json);\n } catch {\n throw new G9Error('theme-import', 'Not a theme file (not JSON).');\n }\n const d = data as { format?: unknown; version?: unknown; theme?: Partial<G9ThemeDefinition> };\n if (d?.format !== FORMAT) throw new G9Error('theme-import', 'Not a G9 theme file.');\n if (typeof d.version !== 'number' || d.version > VERSION)\n throw new G9Error(\n 'theme-import',\n `Theme file version ${String(d.version)} is newer than this app reads (${VERSION}).`,\n );\n const t = d.theme;\n if (!t || typeof t.id !== 'string' || typeof t.recipe !== 'string' || !t.brand || typeof t.brand !== 'object') {\n throw new G9Error('theme-import', 'The theme lacks an id, a recipe or a brand.');\n }\n const colours: [string, unknown][] = [\n ...Object.entries(t.brand),\n ...Object.entries(t.overrides?.light ?? {}),\n ...Object.entries(t.overrides?.dark ?? {}),\n ];\n for (const [key, value] of colours) {\n if (value !== undefined && (typeof value !== 'string' || !tryParseColor(value))) {\n throw new G9Error('theme-import', `\"${key}\" is not a colour: ${JSON.stringify(value)}.`);\n }\n }\n if (t.shape?.radii) {\n for (const [key, value] of Object.entries(t.shape.radii)) {\n if (typeof value !== 'number' || value < 0 || value > 999)\n throw new G9Error('theme-import', `Radius \"${key}\" is not a number 0–999.`);\n }\n }\n // app tokens are CSS values, not colours: each kept only when it is a safe declaration value\n const appTokens = t.appTokens\n ? {\n ...(t.appTokens.light ? { light: Object.freeze(g9SanitizeTokens(t.appTokens.light)) } : {}),\n ...(t.appTokens.dark ? { dark: Object.freeze(g9SanitizeTokens(t.appTokens.dark)) } : {}),\n }\n : undefined;\n return Object.freeze({\n ...(t as G9ThemeDefinition),\n id: newId ?? t.id,\n source: 'personal' as const,\n ...(appTokens ? { appTokens } : {}),\n });\n}\n\n/** The built-in themes over the built-in recipes, one per accent preset family. */\nexport const g9BuiltInThemes: readonly G9ThemeDefinition[] = Object.freeze([\n {\n id: 'classic',\n name: { en: 'Classic', fa: 'کلاسیک' },\n source: 'builtin',\n recipe: 'stock',\n brand: { primary: '#349D57' },\n },\n {\n id: 'tonal',\n name: { en: 'Tonal', fa: 'هم‌رنگ' },\n source: 'builtin',\n recipe: 'tonal',\n brand: { primary: '#2B6FB3' },\n },\n { id: 'calm', name: { en: 'Calm', fa: 'آرام' }, source: 'builtin', recipe: 'neutral', brand: { primary: '#4A5A6A' } },\n { id: 'vivid', name: { en: 'Vivid', fa: 'شاد' }, source: 'builtin', recipe: 'tinted', brand: { primary: '#D0457A' } },\n {\n id: 'midnight',\n name: { en: 'Midnight', fa: 'نیمه‌شب' },\n source: 'builtin',\n recipe: 'midnight',\n brand: { primary: '#01C6AC' },\n mode: 'dark',\n },\n {\n id: 'accessible',\n name: { en: 'High contrast', fa: 'کنتراست بالا' },\n source: 'builtin',\n recipe: 'contrast',\n brand: { primary: '#1F5FA8' },\n },\n] satisfies G9ThemeDefinition[]);\n\n/** A theme's display name in `language` (falls back to English, then any). */\nexport function themeName(theme: G9ThemeDefinition, language: string): string {\n if (typeof theme.name === 'string') return theme.name;\n return theme.name[language] ?? theme.name.en ?? Object.values(theme.name)[0] ?? theme.id;\n}\n\n/** Tokens a theme overrides (for a \"what is changed\" list in a theme editor). */\nexport const overriddenTokens = (theme: G9ThemeDefinition): readonly G9ColorToken[] =>\n [\n ...new Set([...Object.keys(theme.overrides?.light ?? {}), ...Object.keys(theme.overrides?.dark ?? {})]),\n ] as G9ColorToken[];\n"],"names":["g9AccentPresets","Object","applyThemeDefinition","store","theme","base","recipePalettes","layer","palette","over","stripUndefined","lazyPalettes","scheme","_theme_overrides","resolveShape","previewThemeDefinition","_theme_appTokens","appTokens","o","out","k","v","undefined","FORMAT","VERSION","exportTheme","JSON","importTheme","json","newId","_t_overrides","_t_overrides1","_t_shape","data","G9Error","d","String","t","colours","key","value","tryParseColor","g9SanitizeTokens","g9BuiltInThemes","themeName","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