dsh-ppt 0.21.1 → 0.23.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.
Files changed (49) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/README.en.md +37 -23
  3. package/README.md +37 -22
  4. package/docs/COACHING.md +14 -13
  5. package/docs/DATA.md +8 -8
  6. package/docs/REFERENCE.en.md +17 -19
  7. package/docs/REFERENCE.zh.md +16 -18
  8. package/docs/USAGE.en.md +107 -60
  9. package/docs/USAGE.md +115 -84
  10. package/docs/VALIDATION.md +2 -0
  11. package/docs/VISUAL.md +27 -20
  12. package/docs/WORKBENCH.md +17 -6
  13. package/docs/assets/intro/screen-en.webp +0 -0
  14. package/docs/assets/intro/screen-zh.webp +0 -0
  15. package/lib/client.js +1286 -52
  16. package/lib/coaching.d.ts +1 -1
  17. package/lib/coaching.js +25 -12
  18. package/lib/config.d.ts +2 -0
  19. package/lib/config.js +36 -2
  20. package/lib/execution.d.ts +2 -1
  21. package/lib/execution.js +21 -1
  22. package/lib/tools.d.ts +1 -1
  23. package/lib/tools.js +160 -25
  24. package/lib/types.d.ts +115 -8
  25. package/lib/visual.d.ts +3 -1
  26. package/lib/visual.js +40 -13
  27. package/lib/workbench-language.js +49 -9
  28. package/lib/workbench.d.ts +5 -0
  29. package/lib/workbench.js +603 -12
  30. package/package.json +8 -3
  31. package/skills/dsh-ppt/SKILL.md +56 -54
  32. package/skills/dsh-ppt/package.json +17 -5
  33. package/skills/dsh-ppt/references/advanced.md +123 -41
  34. package/skills/dsh-ppt/references/copywriting.md +63 -41
  35. package/skills/dsh-ppt/references/data.md +83 -36
  36. package/skills/dsh-ppt/references/syntax.md +157 -28
  37. package/skills/dsh-ppt/references/themes.md +113 -58
  38. package/skills/dsh-ppt/references/troubleshooting.md +21 -16
  39. package/skills/dsh-ppt/scripts/build-deck.mjs +67 -28
  40. package/skills/dsh-ppt/scripts/deck-absorb.mjs +1338 -0
  41. package/skills/dsh-ppt/scripts/deck-advanced.mjs +422 -105
  42. package/skills/dsh-ppt/scripts/deck-core.mjs +572 -717
  43. package/skills/dsh-ppt/scripts/deck-data-view.mjs +30 -11
  44. package/skills/dsh-ppt/scripts/deck-data.mjs +35 -5
  45. package/skills/dsh-ppt/scripts/deck-director.mjs +2057 -0
  46. package/skills/dsh-ppt/scripts/deck-layouts.mjs +4673 -0
  47. package/skills/dsh-ppt/scripts/deck-media.mjs +1408 -86
  48. package/skills/dsh-ppt/scripts/deck-themes.mjs +1854 -0
  49. package/skills/dsh-ppt/scripts/deck-visual.mjs +133 -31
@@ -0,0 +1,1854 @@
1
+ /**
2
+ * deck-themes.mjs —— dsh-ppt 的 18 套大师视觉主题、18 语义设计 Token、
3
+ * 6 套差异化母版骨架(Chrome Skeleton)、WCAG 对比度求解器、
4
+ * 外源 PPTX 主题净化器与跨平台零缺字字体映射系统。
5
+ *
6
+ * 零外部运行时依赖,仅使用 Node 内置模块。
7
+ */
8
+
9
+ import { existsSync, mkdirSync, writeFileSync } from 'node:fs'
10
+ import { resolve as resolvePath, join as joinPath } from 'node:path'
11
+
12
+ // ---------------------------------------------------------------------------
13
+ // 色彩空间、WCAG 对比度与确定性净化数学工具
14
+ // ---------------------------------------------------------------------------
15
+
16
+ export function normalizeHex(input, fallback = '#000000') {
17
+ const raw = String(input ?? '').trim().replace(/^#/, '')
18
+ if (/^[\da-fA-F]{3}$/.test(raw)) {
19
+ return '#' + raw.split('').map((c) => c + c).join('').toUpperCase()
20
+ }
21
+ if (/^[\da-fA-F]{6}$/.test(raw)) {
22
+ return '#' + raw.toUpperCase()
23
+ }
24
+ if (/^[\da-fA-F]{8}$/.test(raw)) {
25
+ return '#' + raw.slice(0, 6).toUpperCase()
26
+ }
27
+ return fallback.toUpperCase()
28
+ }
29
+
30
+ export function hexToRgb(hex) {
31
+ const clean = normalizeHex(hex).slice(1)
32
+ const num = Number.parseInt(clean, 16)
33
+ return {
34
+ r: (num >> 16) & 255,
35
+ g: (num >> 8) & 255,
36
+ b: num & 255,
37
+ }
38
+ }
39
+
40
+ export function rgbToHex(r, g, b) {
41
+ const clamp = (v) => Math.max(0, Math.min(255, Math.round(v)))
42
+ return '#' + [clamp(r), clamp(g), clamp(b)].map((v) => v.toString(16).padStart(2, '0')).join('').toUpperCase()
43
+ }
44
+
45
+ export function hexToRgba(hex, alpha) {
46
+ const { r, g, b } = hexToRgb(hex)
47
+ return 'rgba(' + r + ',' + g + ',' + b + ',' + alpha + ')'
48
+ }
49
+
50
+ export function rgbToHsl(r, g, b) {
51
+ const rn = r / 255
52
+ const gn = g / 255
53
+ const bn = b / 255
54
+ const max = Math.max(rn, gn, bn)
55
+ const min = Math.min(rn, gn, bn)
56
+ let h = 0
57
+ let s = 0
58
+ const l = (max + min) / 2
59
+ if (max !== min) {
60
+ const d = max - min
61
+ s = l > 0.5 ? d / (2 - max - min) : d / (max + min)
62
+ switch (max) {
63
+ case rn:
64
+ h = ((gn - bn) / d + (gn < bn ? 6 : 0)) / 6
65
+ break
66
+ case gn:
67
+ h = ((bn - rn) / d + 2) / 6
68
+ break
69
+ default:
70
+ h = ((rn - gn) / d + 4) / 6
71
+ break
72
+ }
73
+ }
74
+ return { h: h * 360, s, l }
75
+ }
76
+
77
+ export function hslToRgb(h, s, l) {
78
+ const hn = (((h % 360) + 360) % 360) / 360
79
+ const sn = Math.max(0, Math.min(1, s))
80
+ const ln = Math.max(0, Math.min(1, l))
81
+ if (sn === 0) {
82
+ const v = Math.round(ln * 255)
83
+ return { r: v, g: v, b: v }
84
+ }
85
+ const hue2rgb = (p, q, t) => {
86
+ let tn = t
87
+ if (tn < 0) tn += 1
88
+ if (tn > 1) tn -= 1
89
+ if (tn < 1 / 6) return p + (q - p) * 6 * tn
90
+ if (tn < 1 / 2) return q
91
+ if (tn < 2 / 3) return p + (q - p) * (2 / 3 - tn) * 6
92
+ return p
93
+ }
94
+ const q = ln < 0.5 ? ln * (1 + sn) : ln + sn - ln * sn
95
+ const p = 2 * ln - q
96
+ return {
97
+ r: Math.round(hue2rgb(p, q, hn + 1 / 3) * 255),
98
+ g: Math.round(hue2rgb(p, q, hn) * 255),
99
+ b: Math.round(hue2rgb(p, q, hn - 1 / 3) * 255),
100
+ }
101
+ }
102
+
103
+ export function hexToHsl(hex) {
104
+ const { r, g, b } = hexToRgb(hex)
105
+ return rgbToHsl(r, g, b)
106
+ }
107
+
108
+ export function hslToHex(h, s, l) {
109
+ const { r, g, b } = hslToRgb(h, s, l)
110
+ return rgbToHex(r, g, b)
111
+ }
112
+
113
+ export function relativeLuminance(hex) {
114
+ const { r, g, b } = hexToRgb(hex)
115
+ const lin = (c) => {
116
+ const v = c / 255
117
+ return v <= 0.04045 ? v / 12.92 : ((v + 0.055) / 1.055) ** 2.4
118
+ }
119
+ return 0.2126 * lin(r) + 0.7152 * lin(g) + 0.0722 * lin(b)
120
+ }
121
+
122
+ export function contrastRatio(hexA, hexB) {
123
+ const la = relativeLuminance(hexA)
124
+ const lb = relativeLuminance(hexB)
125
+ return (Math.max(la, lb) + 0.05) / (Math.min(la, lb) + 0.05)
126
+ }
127
+
128
+ export function mixHex(hexA, hexB, weightB = 0.5) {
129
+ const t = Math.max(0, Math.min(1, weightB))
130
+ const a = hexToRgb(hexA)
131
+ const b = hexToRgb(hexB)
132
+ return rgbToHex(
133
+ a.r * (1 - t) + b.r * t,
134
+ a.g * (1 - t) + b.g * t,
135
+ a.b * (1 - t) + b.b * t,
136
+ )
137
+ }
138
+
139
+ function adjustLightness(hex, deltaL) {
140
+ const { h, s, l } = hexToHsl(hex)
141
+ return hslToHex(h, s, Math.max(0, Math.min(1, l + deltaL)))
142
+ }
143
+
144
+ function clampHslColor(hex, { minL = 0, maxL = 1, maxS = 1 } = {}) {
145
+ const { h, s, l } = hexToHsl(hex)
146
+ return hslToHex(h, Math.min(s, maxS), Math.max(minL, Math.min(maxL, l)))
147
+ }
148
+
149
+ /**
150
+ * 16 步二分法对比度求解器:钳制过饱和荧光色并调整亮度直至满足 WCAG 目标对比度。
151
+ */
152
+ export function ensureContrast(hex, bgHex, minCR = 4.5, maxSaturation = 0.82) {
153
+ const bg = normalizeHex(bgHex, '#FFFFFF')
154
+ const start = normalizeHex(hex, '#0057B8')
155
+ const hsl = hexToHsl(start)
156
+ const cappedS = Math.min(hsl.s, maxSaturation)
157
+ const cappedHex = hslToHex(hsl.h, cappedS, hsl.l)
158
+ if (contrastRatio(cappedHex, bg) >= minCR) return cappedHex
159
+
160
+ const bgLum = relativeLuminance(bg)
161
+ const goDarker = bgLum >= 0.42
162
+ let low = goDarker ? 0 : hsl.l
163
+ let high = goDarker ? hsl.l : 1
164
+ let best = goDarker ? '#000000' : '#FFFFFF'
165
+ // Check whether target direction can reach minCR; if not, flip search direction
166
+ const extreme = hslToHex(hsl.h, cappedS, goDarker ? 0.02 : 0.98)
167
+ if (contrastRatio(extreme, bg) < minCR) {
168
+ return bgLum >= 0.42 ? '#0F172A' : '#F8FAFC'
169
+ }
170
+ best = extreme
171
+ for (let step = 0; step < 16; step += 1) {
172
+ const mid = (low + high) / 2
173
+ const candidate = hslToHex(hsl.h, cappedS, mid)
174
+ if (contrastRatio(candidate, bg) >= minCR) {
175
+ best = candidate
176
+ if (goDarker) low = mid
177
+ else high = mid
178
+ } else {
179
+ if (goDarker) high = mid
180
+ else low = mid
181
+ }
182
+ }
183
+ return best
184
+ }
185
+
186
+ function colorDistance(hexA, hexB) {
187
+ const a = hexToRgb(hexA)
188
+ const b = hexToRgb(hexB)
189
+ return Math.hypot(a.r - b.r, a.g - b.g, a.b - b.b)
190
+ }
191
+
192
+ function hueDelta(hexA, hexB) {
193
+ const ha = hexToHsl(hexA).h
194
+ const hb = hexToHsl(hexB).h
195
+ const diff = Math.abs(ha - hb) % 360
196
+ return diff > 180 ? 360 - diff : diff
197
+ }
198
+
199
+ // ---------------------------------------------------------------------------
200
+ // 跨平台安全字体栈与零缺字 PPTX 字体解析
201
+ // ---------------------------------------------------------------------------
202
+
203
+ const SANS_STACK = '"Inter", "Segoe UI", "Helvetica Neue", "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif'
204
+ const GEOMETRIC_SANS_STACK = '"Avenir Next", "Segoe UI", "Helvetica Neue", "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif'
205
+ const DISPLAY_SANS_STACK = '"Segoe UI", "Helvetica Neue", "Arial Black", "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif'
206
+ const SERIF_HEADING_STACK = 'Georgia, "Times New Roman", "Songti SC", "Noto Serif CJK SC", "Microsoft YaHei", serif'
207
+
208
+ const BITMAP_SERIF_FONT_RE = /^(?:SimSun|NSimSun|宋体|新宋体|FangSong|仿宋)$/i
209
+ const NOVELTY_FONT_RE = /^(?:Impact|Comic Sans MS|Papyrus)$/i
210
+
211
+ export function pptxFontName(value, platform = process.platform) {
212
+ const names = String(value ?? '')
213
+ .split(',')
214
+ .map((name) => name.trim().replace(/^["']|["']$/g, ''))
215
+ .filter(Boolean)
216
+ if (names.length === 1 && !['serif', 'sans-serif', 'system-ui', 'monospace'].includes(names[0].toLowerCase())) {
217
+ const single = names[0]
218
+ if (BITMAP_SERIF_FONT_RE.test(single)) {
219
+ return platform === 'win32' ? 'Microsoft YaHei' : platform === 'darwin' ? 'Songti SC' : 'Noto Serif CJK SC'
220
+ }
221
+ if (NOVELTY_FONT_RE.test(single) || /^(?:微软雅黑|黑体)$/i.test(single)) {
222
+ return platform === 'win32' ? 'Microsoft YaHei' : platform === 'darwin' ? 'PingFang SC' : 'Noto Sans CJK SC'
223
+ }
224
+ if (platform === 'win32' && /^Songti SC$/i.test(single)) return 'Microsoft YaHei'
225
+ if (platform === 'linux' && /^(Microsoft YaHei|PingFang SC|Songti SC|Segoe UI|Helvetica Neue|Avenir Next)$/i.test(single)) {
226
+ return /Songti|Serif/i.test(single) ? 'Liberation Serif' : 'Liberation Sans'
227
+ }
228
+ return single
229
+ }
230
+ const available = platform === 'win32'
231
+ ? ['Segoe UI', 'Georgia', 'Arial', 'Arial Black', 'Calibri', 'Times New Roman', 'Microsoft YaHei']
232
+ : platform === 'darwin'
233
+ ? ['Helvetica Neue', 'Avenir Next', 'Georgia', 'Arial', 'Times New Roman', 'PingFang SC', 'Songti SC']
234
+ : ['Liberation Sans', 'Liberation Serif', 'Noto Sans', 'Noto Sans CJK SC', 'Noto Serif CJK SC']
235
+ const hit = names.find((name) => available.includes(name))
236
+ if (hit) return hit
237
+ const isSerif = names.some((n) => /serif|Georgia|Times/i.test(n) && !/sans-serif/i.test(n))
238
+ if (isSerif) return platform === 'linux' ? 'Liberation Serif' : 'Georgia'
239
+ return platform === 'win32' ? 'Segoe UI' : platform === 'darwin' ? 'Helvetica Neue' : 'Liberation Sans'
240
+ }
241
+
242
+ /**
243
+ * PPTX <a:ea> 东亚字体映射:
244
+ * - win32 统一优先使用矢量平滑的 Microsoft YaHei(避免 SimSun 大字号点阵锯齿,且避免 macOS 专属 Songti SC 缺字)
245
+ * - darwin 使用 PingFang SC / Songti SC
246
+ * - linux 使用 Noto Sans CJK SC / Noto Serif CJK SC
247
+ */
248
+ export function pptxEastAsianFont(value, platform = process.platform) {
249
+ const names = String(value ?? '')
250
+ .split(',')
251
+ .map((name) => name.trim().replace(/^["']|["']$/g, ''))
252
+ .filter(Boolean)
253
+ if (names.length === 1) {
254
+ const single = names[0]
255
+ if (BITMAP_SERIF_FONT_RE.test(single)) {
256
+ return platform === 'win32' ? 'Microsoft YaHei' : platform === 'darwin' ? 'Songti SC' : 'Noto Serif CJK SC'
257
+ }
258
+ if (NOVELTY_FONT_RE.test(single) || /^(?:微软雅黑|黑体)$/i.test(single)) {
259
+ return platform === 'win32' ? 'Microsoft YaHei' : platform === 'darwin' ? 'PingFang SC' : 'Noto Sans CJK SC'
260
+ }
261
+ if (platform === 'win32' && /^(Microsoft YaHei|SimHei|KaiTi)$/i.test(single)) return single
262
+ if (platform === 'darwin' && /^(PingFang SC|Songti SC|Heiti SC|Kaiti SC)$/i.test(single)) return single
263
+ if (platform === 'linux' && /^Noto (Sans|Serif) CJK SC$/i.test(single)) return single
264
+ }
265
+ const font = pptxFontName(value, platform)
266
+ const isSerif = /Georgia|Times New Roman|Cambria|Liberation Serif|Songti|Noto Serif/i.test(font) ||
267
+ names.some((n) => /^serif$/i.test(n))
268
+ if (platform === 'win32') return 'Microsoft YaHei'
269
+ if (platform === 'darwin') return isSerif ? 'Songti SC' : 'PingFang SC'
270
+ return isSerif ? 'Noto Serif CJK SC' : 'Noto Sans CJK SC'
271
+ }
272
+
273
+ // ---------------------------------------------------------------------------
274
+ // 6 套母版骨架(Chrome Skeleton)与 18 套内置大师主题定义(前 5 项兼容原顺序与色值)
275
+ // ---------------------------------------------------------------------------
276
+
277
+ export const CHROME_STYLES = Object.freeze([
278
+ 'consulting-classic',
279
+ 'keynote-spatial',
280
+ 'editorial-folio',
281
+ 'saas-bento',
282
+ 'academic-minimal',
283
+ 'gov-ceremonial',
284
+ ])
285
+
286
+ const CHROME_STYLE_SET = new Set(CHROME_STYLES)
287
+
288
+ export function resolveChromeStyle(theme, slide = null, brand = null) {
289
+ const candidates = [slide?.chrome, brand?.chromeStyle, theme?.chromeStyle]
290
+ for (const cand of candidates) {
291
+ if (typeof cand === 'string') {
292
+ const clean = cand.trim()
293
+ if (CHROME_STYLE_SET.has(clean)) return clean
294
+ }
295
+ }
296
+ return 'consulting-classic'
297
+ }
298
+
299
+ function makeTheme(spec) {
300
+ const {
301
+ id,
302
+ name,
303
+ mood,
304
+ bestFor,
305
+ persona,
306
+ dark,
307
+ palette,
308
+ tokens,
309
+ fonts,
310
+ radiusPx = 10,
311
+ shadow = !dark,
312
+ defaultTableStyle = 'consulting',
313
+ chromeStyle = 'saas-bento',
314
+ } = spec
315
+ const canvas = normalizeHex(tokens.canvas ?? palette.bg)
316
+ const surface1 = normalizeHex(tokens.surface1 ?? palette.panel)
317
+ const surface2 = normalizeHex(tokens.surface2 ?? (dark ? mixHex(surface1, '#FFFFFF', 0.06) : mixHex(surface1, '#0F172A', 0.05)))
318
+ const hairline = normalizeHex(tokens.hairline ?? (dark ? mixHex(canvas, '#FFFFFF', 0.16) : mixHex(canvas, '#0F172A', 0.14)))
319
+ const inkPrimary = normalizeHex(tokens.inkPrimary ?? palette.fg)
320
+ const inkSecondary = ensureContrast(tokens.inkSecondary ?? mixHex(inkPrimary, surface1, 0.24), surface1, 7.0)
321
+ const inkMuted = ensureContrast(tokens.inkMuted ?? palette.muted, surface1, 4.6)
322
+ const accentPrimary = normalizeHex(tokens.accentPrimary ?? palette.accent)
323
+ const accentText = ensureContrast(tokens.accentText ?? accentPrimary, surface1, 4.6)
324
+ const accentSecondary = normalizeHex(tokens.accentSecondary ?? palette.accent2)
325
+ const accent2Text = ensureContrast(tokens.accent2Text ?? accentSecondary, surface1, 4.6)
326
+ const inkOnAccent = normalizeHex(tokens.inkOnAccent ?? (relativeLuminance(accentPrimary) > 0.36 ? '#0F172A' : '#FFFFFF'))
327
+ const accentSoft = normalizeHex(tokens.accentSoft ?? mixHex(canvas, accentPrimary, dark ? 0.18 : 0.10))
328
+ const positive = normalizeHex(tokens.positive ?? ensureContrast(dark ? '#34D399' : '#0D7A4E', surface1, 4.5))
329
+ const negative = normalizeHex(tokens.negative ?? ensureContrast(dark ? '#F87171' : '#C81E1E', surface1, 4.5))
330
+ const warning = normalizeHex(tokens.warning ?? ensureContrast(dark ? '#FBBF24' : '#B45309', surface1, 4.5))
331
+ const chartFocal = normalizeHex(tokens.chartFocal ?? accentPrimary)
332
+ const chartNeutral = normalizeHex(tokens.chartNeutral ?? (dark ? '#2B354D' : '#CBD5E1'))
333
+ const chartSeries = (tokens.chartSeries ?? [accentPrimary, accentSecondary, '#0E7490', '#4F46E5', '#0D7A4E', '#64748B']).map((c) => normalizeHex(c))
334
+ const coverMode = tokens.coverMode ?? 'standard'
335
+ const coverBg = normalizeHex(tokens.coverBg ?? (coverMode === 'inverted-accent' ? accentPrimary : canvas))
336
+
337
+ return Object.freeze({
338
+ id,
339
+ name: Object.freeze(name),
340
+ mood: Object.freeze(mood),
341
+ bestFor: Object.freeze(bestFor),
342
+ persona: persona ?? 'consulting',
343
+ dark: Boolean(dark),
344
+ radiusPx,
345
+ shadow: Boolean(shadow),
346
+ defaultTableStyle,
347
+ chromeStyle,
348
+ palette: Object.freeze({
349
+ bg: normalizeHex(palette.bg),
350
+ panel: normalizeHex(palette.panel),
351
+ fg: normalizeHex(palette.fg),
352
+ muted: normalizeHex(palette.muted),
353
+ accent: normalizeHex(palette.accent),
354
+ accent2: normalizeHex(palette.accent2),
355
+ }),
356
+ tokens: Object.freeze({
357
+ canvas,
358
+ surface1,
359
+ surface2,
360
+ hairline,
361
+ inkPrimary,
362
+ inkSecondary,
363
+ inkMuted,
364
+ inkOnAccent,
365
+ accentPrimary,
366
+ accentText,
367
+ accentSecondary,
368
+ accent2Text,
369
+ accentSoft,
370
+ positive,
371
+ negative,
372
+ warning,
373
+ chartFocal,
374
+ chartNeutral,
375
+ chartSeries: Object.freeze(chartSeries),
376
+ coverMode,
377
+ coverBg,
378
+ }),
379
+ fonts: Object.freeze(fonts),
380
+ })
381
+ }
382
+
383
+ export const THEMES = {
384
+ // 0..4: Legacy 5 themes (exact order & exact palette hexes preserved for zero regression)
385
+ swiss: makeTheme({
386
+ id: 'swiss',
387
+ name: { zh: '瑞士脉冲', en: 'Swiss Pulse' },
388
+ mood: { zh: '精准、理性、数据', en: 'Precise, rational, data-driven' },
389
+ bestFor: { zh: 'SaaS、数据、开发者工具', en: 'SaaS, data, developer tools' },
390
+ persona: 'tech-pitch',
391
+ dark: true,
392
+ radiusPx: 8,
393
+ shadow: false,
394
+ chromeStyle: 'saas-bento',
395
+ palette: {
396
+ bg: '#10151B',
397
+ panel: '#161D26',
398
+ fg: '#F5F7FA',
399
+ muted: '#8E9AAA',
400
+ accent: '#2F6BFF',
401
+ accent2: '#FFB300',
402
+ },
403
+ tokens: {
404
+ canvas: '#10151B',
405
+ surface1: '#161D26',
406
+ surface2: '#1E2835',
407
+ hairline: '#293646',
408
+ inkPrimary: '#F5F7FA',
409
+ inkSecondary: '#C2CCD8',
410
+ inkMuted: '#8E9AAA',
411
+ accentPrimary: '#2F6BFF',
412
+ accentText: '#6B9BFF',
413
+ accentSecondary: '#FFB300',
414
+ accent2Text: '#FFC233',
415
+ chartNeutral: '#2A3748',
416
+ chartSeries: ['#2F6BFF', '#FFB300', '#22D3EE', '#34D399', '#F87171', '#94A3B8'],
417
+ },
418
+ fonts: { heading: SANS_STACK, body: SANS_STACK },
419
+ }),
420
+ velvet: makeTheme({
421
+ id: 'velvet',
422
+ name: { zh: '天鹅绒标准', en: 'Velvet Standard' },
423
+ mood: { zh: '高级、克制、可信', en: 'Premium, restrained, trustworthy' },
424
+ bestFor: { zh: '高管汇报、品牌、融资路演', en: 'Executive decks, brand, investor pitches' },
425
+ persona: 'editorial',
426
+ dark: true,
427
+ radiusPx: 8,
428
+ shadow: false,
429
+ chromeStyle: 'editorial-folio',
430
+ palette: {
431
+ bg: '#111316',
432
+ panel: '#1A1D22',
433
+ fg: '#F4EFE6',
434
+ muted: '#A79F91',
435
+ accent: '#C9A84C',
436
+ accent2: '#3D4A63',
437
+ },
438
+ tokens: {
439
+ canvas: '#111316',
440
+ surface1: '#1A1D22',
441
+ surface2: '#23272F',
442
+ hairline: '#2F3540',
443
+ inkPrimary: '#F4EFE6',
444
+ inkSecondary: '#CEC6B8',
445
+ inkMuted: '#A79F91',
446
+ accentPrimary: '#C9A84C',
447
+ accentText: '#D6B862',
448
+ accentSecondary: '#3D4A63',
449
+ accent2Text: '#8FA5C7',
450
+ chartNeutral: '#323842',
451
+ chartSeries: ['#C9A84C', '#6C82A6', '#C87D65', '#6D9B87', '#9B8EC4', '#8A847C'],
452
+ },
453
+ fonts: { heading: SERIF_HEADING_STACK, body: SANS_STACK },
454
+ }),
455
+ data: makeTheme({
456
+ id: 'data',
457
+ name: { zh: '数据漂移', en: 'Data Drift' },
458
+ mood: { zh: '未来、沉浸、前沿', en: 'Futuristic, immersive, cutting-edge' },
459
+ bestFor: { zh: 'AI、数据、研究、技术发布', en: 'AI, data, research, tech launches' },
460
+ persona: 'tech-pitch',
461
+ dark: true,
462
+ radiusPx: 10,
463
+ shadow: false,
464
+ chromeStyle: 'saas-bento',
465
+ palette: {
466
+ bg: '#070B14',
467
+ panel: '#0D1424',
468
+ fg: '#E8F1FF',
469
+ muted: '#7E8BA8',
470
+ accent: '#7C3AED',
471
+ accent2: '#06B6D4',
472
+ },
473
+ tokens: {
474
+ canvas: '#070B14',
475
+ surface1: '#0D1424',
476
+ surface2: '#152038',
477
+ hairline: '#233252',
478
+ inkPrimary: '#E8F1FF',
479
+ inkSecondary: '#B5C5E0',
480
+ inkMuted: '#8896B5',
481
+ accentPrimary: '#7C3AED',
482
+ accentText: '#A78BFA',
483
+ accentSecondary: '#06B6D4',
484
+ accent2Text: '#22D3EE',
485
+ chartNeutral: '#253453',
486
+ chartSeries: ['#7C3AED', '#06B6D4', '#60A5FA', '#34D399', '#F472B6', '#818CF8'],
487
+ },
488
+ fonts: { heading: SANS_STACK, body: SANS_STACK },
489
+ }),
490
+ soft: makeTheme({
491
+ id: 'soft',
492
+ name: { zh: '柔和信号', en: 'Soft Signal' },
493
+ mood: { zh: '温暖、亲近、人本', en: 'Warm, intimate, human' },
494
+ bestFor: { zh: '品牌故事、培训、个人分享', en: 'Brand stories, training, personal talks' },
495
+ persona: 'education',
496
+ dark: false,
497
+ radiusPx: 12,
498
+ shadow: true,
499
+ chromeStyle: 'saas-bento',
500
+ palette: {
501
+ bg: '#FFF8EC',
502
+ panel: '#FFF2DE',
503
+ fg: '#3B2F2A',
504
+ muted: '#7E6F68',
505
+ accent: '#E58A2F',
506
+ accent2: '#8FAF8C',
507
+ },
508
+ tokens: {
509
+ canvas: '#FFF8EC',
510
+ surface1: '#F7EEDF',
511
+ surface2: '#EFE2CE',
512
+ hairline: '#DED0BC',
513
+ inkPrimary: '#3B2F2A',
514
+ inkSecondary: '#54453E',
515
+ inkMuted: '#6E5E57',
516
+ accentPrimary: '#E58A2F',
517
+ accentText: '#B35309',
518
+ accentSecondary: '#8FAF8C',
519
+ accent2Text: '#3E6644',
520
+ chartNeutral: '#D8CBB8',
521
+ chartSeries: ['#C86419', '#4D7358', '#2B5B84', '#9A3B26', '#7A5C3E', '#7D746D'],
522
+ },
523
+ fonts: { heading: GEOMETRIC_SANS_STACK, body: GEOMETRIC_SANS_STACK },
524
+ }),
525
+ bold: makeTheme({
526
+ id: 'bold',
527
+ name: { zh: '极繁大字', en: 'Maximalist Type' },
528
+ mood: { zh: '大声、动能、发布', en: 'Loud, kinetic, launch' },
529
+ bestFor: { zh: '产品发布、活动、品牌大事件', en: 'Product launches, events, brand moments' },
530
+ persona: 'tech-pitch',
531
+ dark: true,
532
+ radiusPx: 6,
533
+ shadow: false,
534
+ chromeStyle: 'keynote-spatial',
535
+ palette: {
536
+ bg: '#0D0D0D',
537
+ panel: '#181818',
538
+ fg: '#FFFFFF',
539
+ muted: '#B8B8B8',
540
+ accent: '#E63946',
541
+ accent2: '#FFD60A',
542
+ },
543
+ tokens: {
544
+ canvas: '#0D0D0D',
545
+ surface1: '#181818',
546
+ surface2: '#222226',
547
+ hairline: '#303036',
548
+ inkPrimary: '#FFFFFF',
549
+ inkSecondary: '#D4D4D8',
550
+ inkMuted: '#A1A1AA',
551
+ accentPrimary: '#E63946',
552
+ accentText: '#FF6B76',
553
+ accentSecondary: '#FFD60A',
554
+ accent2Text: '#FFD60A',
555
+ chartNeutral: '#32323A',
556
+ chartSeries: ['#E63946', '#FFD60A', '#38BDF8', '#34D399', '#A855F7', '#71717A'],
557
+ },
558
+ fonts: { heading: DISPLAY_SANS_STACK, body: SANS_STACK },
559
+ }),
560
+
561
+ // 5..13: 9 High-Taste Daylight & Persona Signature Themes
562
+ consulting: makeTheme({
563
+ id: 'consulting',
564
+ name: { zh: '蔚蓝战略', en: 'Strategy Navy' },
565
+ mood: { zh: '权威、清晰、高管决策', en: 'Authoritative, crisp, executive strategy' },
566
+ bestFor: { zh: '管理咨询、商业分析、经营汇报、项目复盘', en: 'Consulting, business reviews, strategy decks' },
567
+ persona: 'consulting',
568
+ dark: false,
569
+ radiusPx: 8,
570
+ shadow: false,
571
+ defaultTableStyle: 'consulting',
572
+ chromeStyle: 'consulting-classic',
573
+ palette: {
574
+ bg: '#FFFFFF',
575
+ panel: '#F4F6F9',
576
+ fg: '#0F172A',
577
+ muted: '#5B6B82',
578
+ accent: '#0057B8',
579
+ accent2: '#0E7490',
580
+ },
581
+ tokens: {
582
+ canvas: '#FFFFFF',
583
+ surface1: '#F4F6F9',
584
+ surface2: '#E9EEF5',
585
+ hairline: '#D5DFEC',
586
+ inkPrimary: '#0F172A',
587
+ inkSecondary: '#334155',
588
+ inkMuted: '#5B6B82',
589
+ accentPrimary: '#0057B8',
590
+ accentText: '#004C9E',
591
+ accentSecondary: '#0E7490',
592
+ accent2Text: '#0C637B',
593
+ chartNeutral: '#CBD5E1',
594
+ chartSeries: ['#0057B8', '#0E7490', '#1E293B', '#4F46E5', '#0D7A4E', '#64748B'],
595
+ },
596
+ fonts: { heading: SANS_STACK, body: SANS_STACK },
597
+ }),
598
+ 'cobalt-cream': makeTheme({
599
+ id: 'cobalt-cream',
600
+ name: { zh: '钴蓝简报', en: 'Blue Professional' },
601
+ mood: { zh: '理性纸感、现代简报、零阴影', en: 'Warm paper, crisp cobalt, zero-shadow precision' },
602
+ bestFor: { zh: '产品方案、B2B提案、研究简报、技术方案', en: 'B2B proposals, product briefs, research memos' },
603
+ persona: 'consulting',
604
+ dark: false,
605
+ radiusPx: 8,
606
+ shadow: false,
607
+ chromeStyle: 'consulting-classic',
608
+ palette: {
609
+ bg: '#FDFAE7',
610
+ panel: '#F3F1E8',
611
+ fg: '#111111',
612
+ muted: '#5C5B55',
613
+ accent: '#1E2BFA',
614
+ accent2: '#0F6E56',
615
+ },
616
+ tokens: {
617
+ canvas: '#FDFAE7',
618
+ surface1: '#F3F1E8',
619
+ surface2: '#E8E6DC',
620
+ hairline: '#D0D0EC',
621
+ inkPrimary: '#111111',
622
+ inkSecondary: '#363632',
623
+ inkMuted: '#5C5B55',
624
+ accentPrimary: '#1E2BFA',
625
+ accentText: '#1A25D9',
626
+ accentSecondary: '#0F6E56',
627
+ accent2Text: '#0D5E49',
628
+ chartNeutral: '#CFCBC0',
629
+ chartSeries: ['#1E2BFA', '#0F6E56', '#1E293B', '#B45309', '#9A3B26', '#64748B'],
630
+ },
631
+ fonts: { heading: SANS_STACK, body: SANS_STACK },
632
+ }),
633
+ 'exec-jilan': makeTheme({
634
+ id: 'exec-jilan',
635
+ name: { zh: '霁蓝政务', en: 'Imperial Slate' },
636
+ mood: { zh: '庄重、稳健、现代东方政务', en: 'Dignified, composed, modern institutional' },
637
+ bestFor: { zh: '政企汇报、年度总结、述职报告、专项规划', en: 'Institutional reports, annual reviews, executive briefings' },
638
+ persona: 'gov-exec',
639
+ dark: false,
640
+ radiusPx: 6,
641
+ shadow: false,
642
+ chromeStyle: 'gov-ceremonial',
643
+ palette: {
644
+ bg: '#F7F6F2',
645
+ panel: '#EFECE6',
646
+ fg: '#16243E',
647
+ muted: '#5F6C80',
648
+ accent: '#1A2B4C',
649
+ accent2: '#9E1B1E',
650
+ },
651
+ tokens: {
652
+ canvas: '#F7F6F2',
653
+ surface1: '#EFECE6',
654
+ surface2: '#E5E0D5',
655
+ hairline: '#D4CEC3',
656
+ inkPrimary: '#16243E',
657
+ inkSecondary: '#3A4963',
658
+ inkMuted: '#5F6C80',
659
+ accentPrimary: '#1A2B4C',
660
+ accentText: '#1A2B4C',
661
+ accentSecondary: '#9E1B1E',
662
+ accent2Text: '#9E1B1E',
663
+ chartNeutral: '#C8C3B8',
664
+ chartSeries: ['#1A2B4C', '#9E1B1E', '#2B5B84', '#8C6508', '#3D6B5E', '#7A869A'],
665
+ coverMode: 'inverted-accent',
666
+ coverBg: '#1A2B4C',
667
+ },
668
+ fonts: { heading: SANS_STACK, body: SANS_STACK },
669
+ }),
670
+ 'exec-palace': makeTheme({
671
+ id: 'exec-palace',
672
+ name: { zh: '故宫丹宸', en: 'Palace Vermilion' },
673
+ mood: { zh: '典雅庄严、丹红金线、宣纸浅底', en: 'Ceremonial vermilion cover with warm rice-paper body' },
674
+ bestFor: { zh: '党建述职、重大表彰、文化工程、庆典汇报', en: 'Keynote ceremonies, cultural & institutional milestones' },
675
+ persona: 'gov-exec',
676
+ dark: false,
677
+ radiusPx: 6,
678
+ shadow: false,
679
+ chromeStyle: 'gov-ceremonial',
680
+ palette: {
681
+ bg: '#F9F6F1',
682
+ panel: '#F1ECE3',
683
+ fg: '#231916',
684
+ muted: '#6E5D56',
685
+ accent: '#9E1B1E',
686
+ accent2: '#8A6826',
687
+ },
688
+ tokens: {
689
+ canvas: '#F9F6F1',
690
+ surface1: '#F1ECE3',
691
+ surface2: '#E7DFD3',
692
+ hairline: '#D8CEBE',
693
+ inkPrimary: '#231916',
694
+ inkSecondary: '#4A3B36',
695
+ inkMuted: '#6E5D56',
696
+ accentPrimary: '#9E1B1E',
697
+ accentText: '#8E171A',
698
+ accentSecondary: '#8A6826',
699
+ accent2Text: '#75571E',
700
+ chartNeutral: '#CFC6BA',
701
+ chartSeries: ['#9E1B1E', '#2C4A63', '#8A6826', '#4E6E5D', '#5C4B51', '#8C7B70'],
702
+ coverMode: 'inverted-accent',
703
+ coverBg: '#9E1B1E',
704
+ },
705
+ fonts: { heading: SERIF_HEADING_STACK, body: SANS_STACK },
706
+ }),
707
+ academic: makeTheme({
708
+ id: 'academic',
709
+ name: { zh: '清澄学术', en: 'ETH & Nature' },
710
+ mood: { zh: '严谨、清澈、出版级学术规范', en: 'Rigorous, high-clarity, publication-grade' },
711
+ bestFor: { zh: '论文答辩、开题报告、学术会议、科研组会', en: 'Thesis defense, academic talks, research seminars' },
712
+ persona: 'academic',
713
+ dark: false,
714
+ radiusPx: 6,
715
+ shadow: false,
716
+ defaultTableStyle: 'booktabs',
717
+ chromeStyle: 'academic-minimal',
718
+ palette: {
719
+ bg: '#FFFFFF',
720
+ panel: '#F5F7FA',
721
+ fg: '#111827',
722
+ muted: '#596577',
723
+ accent: '#006980',
724
+ accent2: '#C8430E',
725
+ },
726
+ tokens: {
727
+ canvas: '#FFFFFF',
728
+ surface1: '#F5F7FA',
729
+ surface2: '#EBF0F5',
730
+ hairline: '#CBD5E1',
731
+ inkPrimary: '#111827',
732
+ inkSecondary: '#374151',
733
+ inkMuted: '#596577',
734
+ accentPrimary: '#006980',
735
+ accentText: '#005A6E',
736
+ accentSecondary: '#C8430E',
737
+ accent2Text: '#B23A0B',
738
+ chartNeutral: '#CBD5E1',
739
+ chartSeries: ['#006980', '#C8430E', '#1E3A8A', '#2E7D32', '#6D28D9', '#52525B'],
740
+ },
741
+ fonts: { heading: SANS_STACK, body: SANS_STACK },
742
+ }),
743
+ 'editorial-forest': makeTheme({
744
+ id: 'editorial-forest',
745
+ name: { zh: '森系社论', en: 'Editorial Forest' },
746
+ mood: { zh: '人文杂志、衬线留白、沉静质感', en: 'Editorial serif, organic calm, generous whitespace' },
747
+ bestFor: { zh: '品牌提案、文化策展、ESG报告、深度叙事', en: 'Brand strategy, ESG reports, cultural curation' },
748
+ persona: 'editorial',
749
+ dark: false,
750
+ radiusPx: 8,
751
+ shadow: false,
752
+ chromeStyle: 'editorial-folio',
753
+ palette: {
754
+ bg: '#F4EFE4',
755
+ panel: '#EAE2D3',
756
+ fg: '#1A1A17',
757
+ muted: '#615E55',
758
+ accent: '#2E4A2A',
759
+ accent2: '#A64B67',
760
+ },
761
+ tokens: {
762
+ canvas: '#F4EFE4',
763
+ surface1: '#EAE2D3',
764
+ surface2: '#DFD5C3',
765
+ hairline: '#C5BCAA',
766
+ inkPrimary: '#1A1A17',
767
+ inkSecondary: '#3F3E38',
768
+ inkMuted: '#615E55',
769
+ accentPrimary: '#2E4A2A',
770
+ accentText: '#263E23',
771
+ accentSecondary: '#E89CB1',
772
+ accent2Text: '#9C3F5B',
773
+ chartNeutral: '#C9C0AE',
774
+ chartSeries: ['#2E4A2A', '#9C3F5B', '#2D4A5E', '#8C6239', '#556B52', '#7A756B'],
775
+ },
776
+ fonts: { heading: SERIF_HEADING_STACK, body: SANS_STACK },
777
+ }),
778
+ cartesian: makeTheme({
779
+ id: 'cartesian',
780
+ name: { zh: '暖石极简', en: 'Cartesian Stone' },
781
+ mood: { zh: '建筑网格、0圆角锋利线条、克制优雅', en: 'Architectural hairline grid, zero-radius minimalism' },
782
+ bestFor: { zh: '设计提案、建筑作品集、高端零售、战略宣言', en: 'Design portfolios, architecture, luxury & manifesto decks' },
783
+ persona: 'editorial',
784
+ dark: false,
785
+ radiusPx: 0,
786
+ shadow: false,
787
+ defaultTableStyle: 'minimal',
788
+ chromeStyle: 'editorial-folio',
789
+ palette: {
790
+ bg: '#F5F1EB',
791
+ panel: '#EAE4DB',
792
+ fg: '#1A1A1A',
793
+ muted: '#635E57',
794
+ accent: '#734B2F',
795
+ accent2: '#2F4F4F',
796
+ },
797
+ tokens: {
798
+ canvas: '#F5F1EB',
799
+ surface1: '#EAE4DB',
800
+ surface2: '#DFD7CB',
801
+ hairline: '#B8B0A4',
802
+ inkPrimary: '#1A1A1A',
803
+ inkSecondary: '#403D39',
804
+ inkMuted: '#635E57',
805
+ accentPrimary: '#734B2F',
806
+ accentText: '#664128',
807
+ accentSecondary: '#2F4F4F',
808
+ accent2Text: '#284545',
809
+ chartNeutral: '#C9C1B6',
810
+ chartSeries: ['#734B2F', '#2F4F4F', '#8C6239', '#4A5D73', '#5E5063', '#7D776D'],
811
+ },
812
+ fonts: { heading: SERIF_HEADING_STACK, body: SANS_STACK },
813
+ }),
814
+ 'course-sage': makeTheme({
815
+ id: 'course-sage',
816
+ name: { zh: '知行讲义', en: 'Workshop Sage' },
817
+ mood: { zh: '清晰易读、护眼低眩光、循序渐进', en: 'Low-glare clarity, structured learning progression' },
818
+ bestFor: { zh: '教学课件、企业内训、工作坊、科普分享', en: 'Courseware, corporate training, workshops, tutorials' },
819
+ persona: 'education',
820
+ dark: false,
821
+ radiusPx: 10,
822
+ shadow: false,
823
+ chromeStyle: 'academic-minimal',
824
+ palette: {
825
+ bg: '#FAFBF9',
826
+ panel: '#F0F4F1',
827
+ fg: '#182420',
828
+ muted: '#5A6F67',
829
+ accent: '#0F6E56',
830
+ accent2: '#B45309',
831
+ },
832
+ tokens: {
833
+ canvas: '#FAFBF9',
834
+ surface1: '#F0F4F1',
835
+ surface2: '#E3EBE6',
836
+ hairline: '#C8D6CE',
837
+ inkPrimary: '#182420',
838
+ inkSecondary: '#384B44',
839
+ inkMuted: '#5A6F67',
840
+ accentPrimary: '#0F6E56',
841
+ accentText: '#0C5C47',
842
+ accentSecondary: '#B45309',
843
+ accent2Text: '#9A4607',
844
+ chartNeutral: '#CBD8D1',
845
+ chartSeries: ['#0F6E56', '#B45309', '#1D4ED8', '#7C3AED', '#BE123C', '#576B63'],
846
+ },
847
+ fonts: { heading: GEOMETRIC_SANS_STACK, body: GEOMETRIC_SANS_STACK },
848
+ }),
849
+ 'linear-dark': makeTheme({
850
+ id: 'linear-dark',
851
+ name: { zh: '黑曜石路演', en: 'Obsidian Keynote' },
852
+ mood: { zh: '1px微描边层级、Apple/Linear式科技质感', en: 'Keynote dark elevation, crisp 1px hairlines' },
853
+ bestFor: { zh: '科技发布会、AI产品路演、融资Deck、开发者大会', en: 'Product keynotes, AI launches, VC pitch decks' },
854
+ persona: 'tech-pitch',
855
+ dark: true,
856
+ radiusPx: 12,
857
+ shadow: false,
858
+ chromeStyle: 'saas-bento',
859
+ palette: {
860
+ bg: '#090B10',
861
+ panel: '#11151F',
862
+ fg: '#F3F6FC',
863
+ muted: '#8A96AC',
864
+ accent: '#5E81F4',
865
+ accent2: '#38BDF8',
866
+ },
867
+ tokens: {
868
+ canvas: '#090B10',
869
+ surface1: '#11151F',
870
+ surface2: '#181E2C',
871
+ hairline: '#232B3E',
872
+ inkPrimary: '#F3F6FC',
873
+ inkSecondary: '#B8C2D4',
874
+ inkMuted: '#8A96AC',
875
+ accentPrimary: '#5E81F4',
876
+ accentText: '#7C9BFF',
877
+ accentSecondary: '#38BDF8',
878
+ accent2Text: '#38BDF8',
879
+ chartNeutral: '#2B354D',
880
+ chartSeries: ['#5E81F4', '#38BDF8', '#A78BFA', '#34D399', '#FBBF24', '#64748B'],
881
+ },
882
+ fonts: { heading: SANS_STACK, body: SANS_STACK },
883
+ }),
884
+
885
+ // 14..17: 4 Signature World-Class Themes (Keynote, FT Financial, Clinical Medical, Luxury Noir)
886
+ 'keynote-light': makeTheme({
887
+ id: 'keynote-light',
888
+ name: { zh: '苹果极简白', en: 'Keynote Spatial Light' },
889
+ mood: { zh: 'Apple空间留白、无框空气感、极致纯净', en: 'Apple spatial whitespace, borderless purity, airy clarity' },
890
+ bestFor: { zh: '旗舰产品发布、设计哲学演讲、高管主题演讲', en: 'Flagship launches, design keynotes, executive talks' },
891
+ persona: 'tech-pitch',
892
+ dark: false,
893
+ radiusPx: 16,
894
+ shadow: false,
895
+ chromeStyle: 'keynote-spatial',
896
+ palette: {
897
+ bg: '#FFFFFF',
898
+ panel: '#F5F5F7',
899
+ fg: '#1D1D1F',
900
+ muted: '#6E6E73',
901
+ accent: '#0066CC',
902
+ accent2: '#5E5CE6',
903
+ },
904
+ tokens: {
905
+ canvas: '#FFFFFF',
906
+ surface1: '#F5F5F7',
907
+ surface2: '#EAEAEF',
908
+ hairline: '#D2D2D7',
909
+ inkPrimary: '#1D1D1F',
910
+ inkSecondary: '#424245',
911
+ inkMuted: '#6E6E73',
912
+ accentPrimary: '#0066CC',
913
+ accentText: '#0055B3',
914
+ accentSecondary: '#5E5CE6',
915
+ accent2Text: '#4947C2',
916
+ chartNeutral: '#D2D2D7',
917
+ chartSeries: ['#0066CC', '#5E5CE6', '#0F766E', '#D97706', '#DC2626', '#6E6E73'],
918
+ },
919
+ fonts: { heading: GEOMETRIC_SANS_STACK, body: SANS_STACK },
920
+ }),
921
+ 'financial-ft': makeTheme({
922
+ id: 'financial-ft',
923
+ name: { zh: '金融时报粉', en: 'FT Salmon Financial' },
924
+ mood: { zh: '财经权威纸感、锋利直角、深海蓝与酒红双色', en: 'FT salmon paper authority, sharp corners, deep teal & claret' },
925
+ bestFor: { zh: '季度财报、投行路演、宏观研究、CFO经营复盘', en: 'Earnings decks, investment banking, macro research, CFO reviews' },
926
+ persona: 'consulting',
927
+ dark: false,
928
+ radiusPx: 0,
929
+ shadow: false,
930
+ defaultTableStyle: 'consulting',
931
+ chromeStyle: 'consulting-classic',
932
+ palette: {
933
+ bg: '#FFF1E5',
934
+ panel: '#F6E3D2',
935
+ fg: '#1A1817',
936
+ muted: '#5F544C',
937
+ accent: '#0D3D56',
938
+ accent2: '#990F3D',
939
+ },
940
+ tokens: {
941
+ canvas: '#FFF1E5',
942
+ surface1: '#F6E3D2',
943
+ surface2: '#ECD3BE',
944
+ hairline: '#D8BFA9',
945
+ inkPrimary: '#1A1817',
946
+ inkSecondary: '#3E3834',
947
+ inkMuted: '#5F544C',
948
+ accentPrimary: '#0D3D56',
949
+ accentText: '#0D3D56',
950
+ accentSecondary: '#990F3D',
951
+ accent2Text: '#990F3D',
952
+ chartNeutral: '#D2BAA5',
953
+ chartSeries: ['#0D3D56', '#990F3D', '#0F766E', '#B45309', '#4F46E5', '#6B5E54'],
954
+ },
955
+ fonts: { heading: SERIF_HEADING_STACK, body: SANS_STACK },
956
+ }),
957
+ 'medical-clean': makeTheme({
958
+ id: 'medical-clean',
959
+ name: { zh: '循证医学蓝绿', en: 'Clinical Evidence Teal' },
960
+ mood: { zh: '高洁净临床严谨感、蓝绿理性配色、三线表规范', en: 'Clinical precision, antiseptic clarity, publication-grade rigor' },
961
+ bestFor: { zh: '医学病例汇报、临床试验、生物医药路演、科研进展', en: 'Clinical cases, biomedical trials, healthcare research' },
962
+ persona: 'academic',
963
+ dark: false,
964
+ radiusPx: 8,
965
+ shadow: false,
966
+ defaultTableStyle: 'booktabs',
967
+ chromeStyle: 'academic-minimal',
968
+ palette: {
969
+ bg: '#F8FAFC',
970
+ panel: '#EEF5F7',
971
+ fg: '#0F172A',
972
+ muted: '#526478',
973
+ accent: '#0F766E',
974
+ accent2: '#0284C7',
975
+ },
976
+ tokens: {
977
+ canvas: '#F8FAFC',
978
+ surface1: '#EEF5F7',
979
+ surface2: '#E1ECEF',
980
+ hairline: '#CBD8DE',
981
+ inkPrimary: '#0F172A',
982
+ inkSecondary: '#334155',
983
+ inkMuted: '#526478',
984
+ accentPrimary: '#0F766E',
985
+ accentText: '#0D665F',
986
+ accentSecondary: '#0284C7',
987
+ accent2Text: '#0369A1',
988
+ chartNeutral: '#CBD5E1',
989
+ chartSeries: ['#0F766E', '#0284C7', '#1E3A8A', '#B45309', '#BE123C', '#64748B'],
990
+ },
991
+ fonts: { heading: SANS_STACK, body: SANS_STACK },
992
+ }),
993
+ 'luxury-noir': makeTheme({
994
+ id: 'luxury-noir',
995
+ name: { zh: '黑金典藏', en: 'Luxury Noir Gold' },
996
+ mood: { zh: '黑金杂志书脊、衬线排印、高奢品牌与白皮书', en: 'Noir gold editorial folio, serif authority, luxury lookbook' },
997
+ bestFor: { zh: '高奢品牌画册、创意作品集、年度白皮书、高端峰会', en: 'Luxury lookbooks, creative portfolios, flagship annual books' },
998
+ persona: 'editorial',
999
+ dark: true,
1000
+ radiusPx: 0,
1001
+ shadow: false,
1002
+ defaultTableStyle: 'minimal',
1003
+ chromeStyle: 'editorial-folio',
1004
+ palette: {
1005
+ bg: '#0B0B0D',
1006
+ panel: '#151519',
1007
+ fg: '#F5F2EB',
1008
+ muted: '#A09A8E',
1009
+ accent: '#D4AF37',
1010
+ accent2: '#8FA3BF',
1011
+ },
1012
+ tokens: {
1013
+ canvas: '#0B0B0D',
1014
+ surface1: '#151519',
1015
+ surface2: '#1F1F26',
1016
+ hairline: '#2D2C33',
1017
+ inkPrimary: '#F5F2EB',
1018
+ inkSecondary: '#D2CCC0',
1019
+ inkMuted: '#A09A8E',
1020
+ accentPrimary: '#D4AF37',
1021
+ accentText: '#E0BE4C',
1022
+ accentSecondary: '#8FA3BF',
1023
+ accent2Text: '#9EB3CF',
1024
+ chartNeutral: '#2C2C34',
1025
+ chartSeries: ['#D4AF37', '#8FA3BF', '#C87D65', '#6D9B87', '#B695C0', '#8A847C'],
1026
+ },
1027
+ fonts: { heading: SERIF_HEADING_STACK, body: SANS_STACK },
1028
+ }),
1029
+
1030
+ // 18..23: 6 Absorbed World-Class Benchmark Themes (BCG, Economist, Venture Daylight, Stripe Craft, Aurora, Terminal)
1031
+ 'bcg-emerald': makeTheme({
1032
+ id: 'bcg-emerald',
1033
+ name: { zh: '翡翠战略', en: 'Emerald Strategy' },
1034
+ mood: { zh: '顶级绿金咨询、增长转型、锋利高管矩阵', en: 'BCG-grade emerald authority, growth & sustainability' },
1035
+ bestFor: { zh: '增长战略、业务转型、ESG双碳、OKR季度复盘', en: 'Growth strategy, ESG transformation, quarterly OKR reviews' },
1036
+ persona: 'consulting',
1037
+ dark: false,
1038
+ radiusPx: 4,
1039
+ shadow: false,
1040
+ defaultTableStyle: 'consulting',
1041
+ chromeStyle: 'consulting-classic',
1042
+ palette: {
1043
+ bg: '#FFFFFF',
1044
+ panel: '#F1F7F4',
1045
+ fg: '#0D1F18',
1046
+ muted: '#4A6157',
1047
+ accent: '#006B54',
1048
+ accent2: '#0F4C81',
1049
+ },
1050
+ tokens: {
1051
+ canvas: '#FFFFFF',
1052
+ surface1: '#F1F7F4',
1053
+ surface2: '#E3EFE9',
1054
+ hairline: '#C8DDD3',
1055
+ inkPrimary: '#0D1F18',
1056
+ inkSecondary: '#2C4239',
1057
+ inkMuted: '#4A6157',
1058
+ accentPrimary: '#006B54',
1059
+ accentText: '#005A46',
1060
+ accentSecondary: '#0F4C81',
1061
+ accent2Text: '#0D416E',
1062
+ chartNeutral: '#C9D8D0',
1063
+ chartSeries: ['#006B54', '#0F4C81', '#1F2937', '#0D9488', '#B45309', '#64748B'],
1064
+ },
1065
+ fonts: { heading: SANS_STACK, body: SANS_STACK },
1066
+ }),
1067
+ 'economist-brief': makeTheme({
1068
+ id: 'economist-brief',
1069
+ name: { zh: '社论红标', en: 'Economist Briefing' },
1070
+ mood: { zh: '经济学人红标书脊、智库级图表、衬线洞察', en: 'Economist red-tab folio, think-tank rigor, editorial serif' },
1071
+ bestFor: { zh: '行业研究、宏观洞察、智库白皮书、并购尽调', en: 'Macro briefings, industry research, think-tank & M&A memos' },
1072
+ persona: 'consulting',
1073
+ dark: false,
1074
+ radiusPx: 0,
1075
+ shadow: false,
1076
+ defaultTableStyle: 'booktabs',
1077
+ chromeStyle: 'editorial-folio',
1078
+ palette: {
1079
+ bg: '#F9F8F5',
1080
+ panel: '#F0EDE6',
1081
+ fg: '#141413',
1082
+ muted: '#57534B',
1083
+ accent: '#C8102E',
1084
+ accent2: '#1D3557',
1085
+ },
1086
+ tokens: {
1087
+ canvas: '#F9F8F5',
1088
+ surface1: '#F0EDE6',
1089
+ surface2: '#E5E0D6',
1090
+ hairline: '#CFC8BA',
1091
+ inkPrimary: '#141413',
1092
+ inkSecondary: '#383631',
1093
+ inkMuted: '#57534B',
1094
+ accentPrimary: '#C8102E',
1095
+ accentText: '#A60D25',
1096
+ accentSecondary: '#1D3557',
1097
+ accent2Text: '#1D3557',
1098
+ chartNeutral: '#CCC5B7',
1099
+ chartSeries: ['#C8102E', '#1D3557', '#0F766E', '#6D4C3D', '#3B5998', '#6B665E'],
1100
+ },
1101
+ fonts: { heading: SERIF_HEADING_STACK, body: SANS_STACK },
1102
+ }),
1103
+ 'venture-daylight': makeTheme({
1104
+ id: 'venture-daylight',
1105
+ name: { zh: '硅谷创投白', en: 'Venture Daylight' },
1106
+ mood: { zh: '红杉/YC日间阅读风、清爽高锐度、数据抓手', en: 'Sequoia/YC partner-memo clarity, crisp daylight pitch' },
1107
+ bestFor: { zh: '创投BP(邮件/iPad阅读版)、商业计划书、新业务立项', en: 'Daylight investor decks, partner memos, venture proposals' },
1108
+ persona: 'tech-pitch',
1109
+ dark: false,
1110
+ radiusPx: 12,
1111
+ shadow: false,
1112
+ defaultTableStyle: 'consulting',
1113
+ chromeStyle: 'keynote-spatial',
1114
+ palette: {
1115
+ bg: '#FFFFFF',
1116
+ panel: '#F6F7F9',
1117
+ fg: '#111827',
1118
+ muted: '#525B66',
1119
+ accent: '#C2410C',
1120
+ accent2: '#0F766E',
1121
+ },
1122
+ tokens: {
1123
+ canvas: '#FFFFFF',
1124
+ surface1: '#F6F7F9',
1125
+ surface2: '#ECEEF2',
1126
+ hairline: '#D8DEE4',
1127
+ inkPrimary: '#111827',
1128
+ inkSecondary: '#374151',
1129
+ inkMuted: '#525B66',
1130
+ accentPrimary: '#C2410C',
1131
+ accentText: '#9A3412',
1132
+ accentSecondary: '#0F766E',
1133
+ accent2Text: '#0D655E',
1134
+ chartNeutral: '#CBD5E1',
1135
+ chartSeries: ['#C2410C', '#0F766E', '#1E3A8A', '#7C3AED', '#B45309', '#64748B'],
1136
+ },
1137
+ fonts: { heading: GEOMETRIC_SANS_STACK, body: SANS_STACK },
1138
+ }),
1139
+ 'stripe-craft': makeTheme({
1140
+ id: 'stripe-craft',
1141
+ name: { zh: '极光产研', en: 'Product Indigo' },
1142
+ mood: { zh: 'Stripe/Vercel工程美学、1px精密Bento、清透靛蓝', en: 'Stripe/Vercel product craft, crisp 1px Bento hairlines' },
1143
+ bestFor: { zh: 'PRD产品评审、SaaS方案、开发者平台、AI工程复盘', en: 'Product reviews, SaaS roadmaps, developer platforms, AI eng' },
1144
+ persona: 'tech-pitch',
1145
+ dark: false,
1146
+ radiusPx: 10,
1147
+ shadow: false,
1148
+ defaultTableStyle: 'consulting',
1149
+ chromeStyle: 'saas-bento',
1150
+ palette: {
1151
+ bg: '#F8FAFC',
1152
+ panel: '#EFF3F9',
1153
+ fg: '#0F172A',
1154
+ muted: '#4E5D73',
1155
+ accent: '#4F46E5',
1156
+ accent2: '#0284C7',
1157
+ },
1158
+ tokens: {
1159
+ canvas: '#F8FAFC',
1160
+ surface1: '#EFF3F9',
1161
+ surface2: '#E2E9F3',
1162
+ hairline: '#CBD5E1',
1163
+ inkPrimary: '#0F172A',
1164
+ inkSecondary: '#334155',
1165
+ inkMuted: '#4E5D73',
1166
+ accentPrimary: '#4F46E5',
1167
+ accentText: '#3730A3',
1168
+ accentSecondary: '#0284C7',
1169
+ accent2Text: '#0369A1',
1170
+ chartNeutral: '#CBD5E1',
1171
+ chartSeries: ['#4F46E5', '#0284C7', '#0D9488', '#7C3AED', '#D97706', '#64748B'],
1172
+ },
1173
+ fonts: { heading: SANS_STACK, body: SANS_STACK },
1174
+ }),
1175
+ 'aurora-stage': makeTheme({
1176
+ id: 'aurora-stage',
1177
+ name: { zh: '极光发布会', en: 'Aurora Keynote' },
1178
+ mood: { zh: '深海极光青紫、无框空间悬浮、算力与硬件大秀', en: 'Deep midnight aurora teal & indigo, spatial keynote stage' },
1179
+ bestFor: { zh: 'AI基础设施发布、大模型演进、芯片/硬件主题演讲', en: 'AI infra keynotes, foundation model launches, hardware talks' },
1180
+ persona: 'tech-pitch',
1181
+ dark: true,
1182
+ radiusPx: 16,
1183
+ shadow: false,
1184
+ chromeStyle: 'keynote-spatial',
1185
+ palette: {
1186
+ bg: '#070B14',
1187
+ panel: '#101726',
1188
+ fg: '#F1F5F9',
1189
+ muted: '#94A3B8',
1190
+ accent: '#2DD4BF',
1191
+ accent2: '#818CF8',
1192
+ },
1193
+ tokens: {
1194
+ canvas: '#070B14',
1195
+ surface1: '#101726',
1196
+ surface2: '#192338',
1197
+ hairline: '#26344E',
1198
+ inkPrimary: '#F1F5F9',
1199
+ inkSecondary: '#CBD5E1',
1200
+ inkMuted: '#94A3B8',
1201
+ accentPrimary: '#2DD4BF',
1202
+ accentText: '#2DD4BF',
1203
+ accentSecondary: '#818CF8',
1204
+ accent2Text: '#A5B4FC',
1205
+ chartNeutral: '#293856',
1206
+ chartSeries: ['#2DD4BF', '#818CF8', '#38BDF8', '#F472B6', '#FBBF24', '#64748B'],
1207
+ },
1208
+ fonts: { heading: GEOMETRIC_SANS_STACK, body: SANS_STACK },
1209
+ }),
1210
+ 'obsidian-amber': makeTheme({
1211
+ id: 'obsidian-amber',
1212
+ name: { zh: '黑曜终端', en: 'Terminal Amber' },
1213
+ mood: { zh: '彭博终端琥珀金、0px锋利栅格、高密风控与量化', en: 'Bloomberg-inspired carbon & amber, sharp analytical grid' },
1214
+ bestFor: { zh: '量化金融、网络安全态势、SRE作战室、实时监控复盘', en: 'Quant finance, security operations, SRE war-room, telemetry' },
1215
+ persona: 'consulting',
1216
+ dark: true,
1217
+ radiusPx: 0,
1218
+ shadow: false,
1219
+ defaultTableStyle: 'consulting',
1220
+ chromeStyle: 'consulting-classic',
1221
+ palette: {
1222
+ bg: '#0C0D10',
1223
+ panel: '#151820',
1224
+ fg: '#F3F4F6',
1225
+ muted: '#9CA3AF',
1226
+ accent: '#F59E0B',
1227
+ accent2: '#38BDF8',
1228
+ },
1229
+ tokens: {
1230
+ canvas: '#0C0D10',
1231
+ surface1: '#151820',
1232
+ surface2: '#1F2430',
1233
+ hairline: '#2E3545',
1234
+ inkPrimary: '#F3F4F6',
1235
+ inkSecondary: '#D1D5DB',
1236
+ inkMuted: '#9CA3AF',
1237
+ accentPrimary: '#F59E0B',
1238
+ accentText: '#FBBF24',
1239
+ accentSecondary: '#38BDF8',
1240
+ accent2Text: '#38BDF8',
1241
+ chartNeutral: '#2A303E',
1242
+ chartSeries: ['#F59E0B', '#38BDF8', '#34D399', '#F87171', '#A78BFA', '#6B7280'],
1243
+ },
1244
+ fonts: { heading: SANS_STACK, body: SANS_STACK },
1245
+ }),
1246
+ }
1247
+
1248
+ /**
1249
+ * 8 套内置名家参考文稿直吸预设(无需外部 .pptx 文件,一键套用大师级配色、母版骨架与叙事节奏建议)。
1250
+ */
1251
+ export const CURATED_MASTER_PRESETS = Object.freeze([
1252
+ {
1253
+ id: 'mckinsey-board',
1254
+ name: { zh: '麦肯锡董事会简报', en: 'McKinsey Board Brief' },
1255
+ sourceStyle: { zh: '0px 直角卡片 · 结论先行 · 深海蓝主调', en: '0px sharp cards · Action titles · Deep navy' },
1256
+ theme: 'consulting',
1257
+ chromeStyle: 'consulting-classic',
1258
+ brand: { primaryColor: '#0057B8', secondaryColor: '#0E7490', backgroundColor: '#FFFFFF', textColor: '#0F172A', chromeStyle: 'consulting-classic' },
1259
+ rhythm: ['cover', 'cards', 'kpi', 'waterfall', 'matrix', 'gantt', 'closing'],
1260
+ },
1261
+ {
1262
+ id: 'bcg-growth',
1263
+ name: { zh: 'BCG 增长与双碳战略', en: 'BCG Growth & Sustainability' },
1264
+ sourceStyle: { zh: '翡翠绿主色 · 价值链五边形箭头 · 哈维球矩阵', en: 'Emerald accent · Value-chain chevrons · Harvey matrix' },
1265
+ theme: 'bcg-emerald',
1266
+ chromeStyle: 'consulting-classic',
1267
+ brand: { primaryColor: '#006B54', secondaryColor: '#0F4C81', backgroundColor: '#FFFFFF', textColor: '#0D1F18', chromeStyle: 'consulting-classic' },
1268
+ rhythm: ['cover', 'kpi', 'process', 'harvey', 'gantt', 'closing'],
1269
+ },
1270
+ {
1271
+ id: 'sequoia-memo',
1272
+ name: { zh: '红杉 / YC 创投融资简报(明亮版)', en: 'Sequoia / YC Partner Deck' },
1273
+ sourceStyle: { zh: '适合邮件与平板阅读 · TAM 同心圆 · 增长指标', en: 'Screen-first daylight · TAM sizing · Traction KPIs' },
1274
+ theme: 'venture-daylight',
1275
+ chromeStyle: 'keynote-spatial',
1276
+ brand: { primaryColor: '#C2410C', secondaryColor: '#0F766E', backgroundColor: '#FFFFFF', textColor: '#111827', chromeStyle: 'keynote-spatial' },
1277
+ rhythm: ['cover', 'comparison', 'kpi', 'tam', 'harvey', 'org', 'closing'],
1278
+ },
1279
+ {
1280
+ id: 'apple-cupertino',
1281
+ name: { zh: 'Cupertino 旗舰产品发布', en: 'Cupertino Spatial Keynote' },
1282
+ sourceStyle: { zh: '无顶部分隔线 · 16pt 呼吸感浮卡 · 大数字聚焦', en: 'Divider-free canvas · 16pt airy Bento · Hero metrics' },
1283
+ theme: 'keynote-light',
1284
+ chromeStyle: 'keynote-spatial',
1285
+ brand: { primaryColor: '#0066CC', secondaryColor: '#5E5CE6', backgroundColor: '#FFFFFF', textColor: '#1D1D1F', chromeStyle: 'keynote-spatial' },
1286
+ rhythm: ['cover', 'statement', 'cards', 'kpi', 'architecture', 'closing'],
1287
+ },
1288
+ {
1289
+ id: 'stripe-product',
1290
+ name: { zh: 'Stripe / Vercel 产研方案评审', en: 'Stripe / Vercel Product Craft' },
1291
+ sourceStyle: { zh: '1px 精密 Bento 网格 · 系统分层架构 · 路线图', en: '1px Bento grid · Layered architecture · Roadmap' },
1292
+ theme: 'stripe-craft',
1293
+ chromeStyle: 'saas-bento',
1294
+ brand: { primaryColor: '#4F46E5', secondaryColor: '#0284C7', backgroundColor: '#F8FAFC', textColor: '#0F172A', chromeStyle: 'saas-bento' },
1295
+ rhythm: ['cover', 'comparison', 'architecture', 'cards', 'gantt', 'closing'],
1296
+ },
1297
+ {
1298
+ id: 'economist-macro',
1299
+ name: { zh: '经济学人 / FT 宏观与财报洞察', en: 'Economist & FT Macro Briefing' },
1300
+ sourceStyle: { zh: '暖纸底色 · 红标书脊 · 衬线标题 + 瀑布利润桥', en: 'Warm paper · Editorial folio · Serif title & waterfall' },
1301
+ theme: 'economist-brief',
1302
+ chromeStyle: 'editorial-folio',
1303
+ brand: { primaryColor: '#C8102E', secondaryColor: '#1D3557', backgroundColor: '#F9F8F5', textColor: '#141413', headingFont: 'Georgia', chromeStyle: 'editorial-folio' },
1304
+ rhythm: ['cover', 'statement', 'waterfall', 'chart-split', 'table', 'closing'],
1305
+ },
1306
+ {
1307
+ id: 'nature-defense',
1308
+ name: { zh: 'Nature / ETH 学术答辩与临床研究', en: 'Nature & Beamer Academic Defense' },
1309
+ sourceStyle: { zh: 'Beamer 通栏页眉 · 无竖线学术三线表 · 严谨对比', en: 'Beamer header band · Booktabs 3-line tables · Rigor' },
1310
+ theme: 'academic',
1311
+ chromeStyle: 'academic-minimal',
1312
+ brand: { primaryColor: '#006980', secondaryColor: '#C8430E', backgroundColor: '#FFFFFF', textColor: '#111827', chromeStyle: 'academic-minimal' },
1313
+ rhythm: ['cover', 'cards', 'process', 'table', 'kpi', 'closing'],
1314
+ },
1315
+ {
1316
+ id: 'imperial-gov',
1317
+ name: { zh: '现代东方政务述职与规划', en: 'Modern Institutional Briefing' },
1318
+ sourceStyle: { zh: '深霁蓝庄重封面 + 宣纸浅底正文 · 双线页眉', en: 'Inverted slate cover + warm paper body · Double rule' },
1319
+ theme: 'exec-jilan',
1320
+ chromeStyle: 'gov-ceremonial',
1321
+ brand: { primaryColor: '#1A2B4C', secondaryColor: '#9E1B1E', chromeStyle: 'gov-ceremonial' },
1322
+ rhythm: ['cover', 'kpi', 'cards', 'comparison', 'org', 'gantt', 'closing'],
1323
+ },
1324
+ ])
1325
+
1326
+ export function listMasterPresets(lang = 'zh') {
1327
+ const pick = (pair) => (lang === 'en' ? pair.en : pair.zh)
1328
+ return CURATED_MASTER_PRESETS.map((preset) => ({
1329
+ id: preset.id,
1330
+ name: pick(preset.name),
1331
+ sourceStyle: pick(preset.sourceStyle),
1332
+ theme: preset.theme,
1333
+ chromeStyle: preset.chromeStyle,
1334
+ brand: { ...preset.brand },
1335
+ rhythm: [...preset.rhythm],
1336
+ }))
1337
+ }
1338
+
1339
+ export const THEME_IDS = Object.keys(THEMES)
1340
+ export const DEFAULT_THEME = 'data'
1341
+ export const SMART_DEFAULT_THEME = 'consulting'
1342
+
1343
+ export function resolveTheme(input) {
1344
+ if (input && typeof input === 'object' && input.palette && input.tokens) return input
1345
+ const raw = String(input ?? DEFAULT_THEME).trim().toLowerCase()
1346
+ const id = raw === '' || raw === 'auto' ? (raw === 'auto' ? SMART_DEFAULT_THEME : DEFAULT_THEME) : raw
1347
+ const theme = THEMES[id]
1348
+ if (!theme) {
1349
+ throw new Error('dsh-ppt:未知主题 "' + id + '",可选:' + THEME_IDS.join(' / ') + '(默认 ' + DEFAULT_THEME + ')')
1350
+ }
1351
+ return theme
1352
+ }
1353
+
1354
+ export function listThemes(lang = 'zh') {
1355
+ const pick = (pair) => (lang === 'en' ? pair.en : pair.zh)
1356
+ return THEME_IDS.map((id) => {
1357
+ const theme = THEMES[id]
1358
+ return {
1359
+ id,
1360
+ name: pick(theme.name),
1361
+ mood: pick(theme.mood),
1362
+ bestFor: pick(theme.bestFor),
1363
+ persona: theme.persona,
1364
+ dark: theme.dark,
1365
+ radiusPx: theme.radiusPx,
1366
+ defaultTableStyle: theme.defaultTableStyle,
1367
+ chromeStyle: theme.chromeStyle,
1368
+ palette: { ...theme.palette },
1369
+ tokens: { ...theme.tokens, chartSeries: [...theme.tokens.chartSeries] },
1370
+ fonts: { ...theme.fonts },
1371
+ }
1372
+ })
1373
+ }
1374
+
1375
+ // ---------------------------------------------------------------------------
1376
+ // 外源 PPTX 主题净化器 sanitizeAbsorbedTheme() 与品牌色派生器 deriveBrandedTheme()
1377
+ // ---------------------------------------------------------------------------
1378
+
1379
+ const OKABE_ITO_FALLBACKS = ['#0057B8', '#C8430E', '#0F6E56', '#7C3AED', '#B45309', '#475569']
1380
+
1381
+ /**
1382
+ * 将任意提取出的外部 .pptx 色板与字体净化为满足 WCAG 对比度与审美约束的 18-Token 主题配置。
1383
+ * 自动处理高饱和企业红/蓝底母版(降级为深色庄重封面 + 明亮正文画布)。
1384
+ */
1385
+ export function sanitizeAbsorbedTheme(raw = {}) {
1386
+ const warnings = []
1387
+ const srcPalette = raw.palette ?? raw.theme ?? raw
1388
+ const srcFonts = raw.fonts ?? raw
1389
+
1390
+ const rawBgCandidate = raw.contentSlideBg ?? raw.backgroundColor ?? raw.masterBg ?? srcPalette.bg ?? srcPalette.light1 ?? '#FFFFFF'
1391
+ const rawBg = normalizeHex(rawBgCandidate, '#FFFFFF')
1392
+ const bgHsl = hexToHsl(rawBg)
1393
+ const bgLum = relativeLuminance(rawBg)
1394
+
1395
+ let dark = false
1396
+ let canvas = rawBg
1397
+ let coverMode = 'standard'
1398
+ let coverBg = rawBg
1399
+
1400
+ // 高饱和度母版背景自动降级(如 #FF0000 刺眼大红底或高饱和蓝底)
1401
+ if (bgHsl.s > 0.35 && bgLum > 0.06 && bgLum < 0.78) {
1402
+ coverMode = 'inverted-accent'
1403
+ coverBg = hslToHex(bgHsl.h, Math.min(bgHsl.s, 0.76), Math.max(0.14, Math.min(0.22, bgHsl.l * 0.42)))
1404
+ canvas = mixHex('#FFFFFF', rawBg, 0.03)
1405
+ dark = false
1406
+ warnings.push('检测到高饱和背景色 ' + rawBg + ',已自动设为庄重深色封面 + 护眼浅色正文画布。')
1407
+ } else if (bgLum >= 0.42) {
1408
+ dark = false
1409
+ canvas = clampHslColor(rawBg, { minL: 0.88, maxL: 1.0, maxS: 0.18 })
1410
+ if (raw.coverSlideBg) {
1411
+ const rawCover = normalizeHex(raw.coverSlideBg, '')
1412
+ if (rawCover && relativeLuminance(rawCover) < 0.30) {
1413
+ coverMode = 'inverted-accent'
1414
+ coverBg = clampHslColor(rawCover, { minL: 0.06, maxL: 0.25, maxS: 0.78 })
1415
+ }
1416
+ }
1417
+ } else {
1418
+ dark = true
1419
+ canvas = clampHslColor(rawBg, { minL: 0.008, maxL: 0.055, maxS: 0.35 })
1420
+ if (bgLum > 0.08) warnings.push('检测到中灰低对比背景色 ' + rawBg + ',已提纯为深邃暗色画布 ' + canvas + '。')
1421
+ }
1422
+
1423
+ const accentCandidates = [
1424
+ raw.brandPrimary,
1425
+ raw.primaryColor,
1426
+ coverMode === 'inverted-accent' ? coverBg : null,
1427
+ srcPalette.accent,
1428
+ srcPalette.accent1,
1429
+ srcPalette.accent2,
1430
+ srcPalette.accent3,
1431
+ srcPalette.dark2,
1432
+ ]
1433
+ .filter(Boolean)
1434
+ .map((c) => normalizeHex(c, ''))
1435
+ .filter((c) => c.length === 7)
1436
+
1437
+ const chromaticSeed = accentCandidates.find((c) => hexToHsl(c).s >= 0.12 && colorDistance(c, canvas) > 36)
1438
+ ?? accentCandidates[0]
1439
+ ?? (dark ? '#5E81F4' : '#0057B8')
1440
+ const accentSeed = clampHslColor(chromaticSeed, { maxS: 0.84, minL: 0.12, maxL: 0.82 })
1441
+
1442
+ const surface1 = dark
1443
+ ? mixHex(canvas, '#FFFFFF', 0.055)
1444
+ : adjustLightness(mixHex(canvas, accentSeed, 0.04), -0.03)
1445
+ const surface2 = dark
1446
+ ? mixHex(canvas, '#FFFFFF', 0.105)
1447
+ : adjustLightness(mixHex(canvas, accentSeed, 0.08), -0.065)
1448
+ const hairline = dark
1449
+ ? mixHex(canvas, '#FFFFFF', 0.16)
1450
+ : mixHex(canvas, '#0F172A', 0.14)
1451
+
1452
+ const rawFgCandidate = raw.textColor ?? srcPalette.fg ?? srcPalette.dark1 ?? (dark ? '#F5F7FA' : '#0F172A')
1453
+ const rawFg = normalizeHex(rawFgCandidate, dark ? '#F5F7FA' : '#0F172A')
1454
+ const inkPrimary = ensureContrast(rawFg, surface1, 10.0)
1455
+ if (contrastRatio(rawFg, surface1) < 4.5) {
1456
+ warnings.push('原文字颜色 ' + rawFg + ' 对比度不足,已自动增强至 ' + inkPrimary + '。')
1457
+ }
1458
+ const inkSecondary = ensureContrast(mixHex(inkPrimary, surface1, 0.25), surface1, 7.0)
1459
+ const inkMuted = ensureContrast(mixHex(inkPrimary, surface1, 0.46), surface1, 4.6)
1460
+
1461
+ const accentPrimary = ensureContrast(accentSeed, canvas, 3.2, 0.82)
1462
+ const accentText = ensureContrast(accentPrimary, surface1, 4.6, 0.82)
1463
+ const inkOnAccent = relativeLuminance(accentPrimary) > 0.36 ? '#0F172A' : '#FFFFFF'
1464
+
1465
+ const secondaryPool = [
1466
+ raw.brandSecondary,
1467
+ raw.secondaryColor,
1468
+ srcPalette.accent2,
1469
+ srcPalette.accent3,
1470
+ srcPalette.accent4,
1471
+ srcPalette.accent5,
1472
+ srcPalette.accent6,
1473
+ ]
1474
+ .filter(Boolean)
1475
+ .map((c) => normalizeHex(c, ''))
1476
+ .filter((c) => c.length === 7 && hueDelta(c, accentPrimary) >= 24 && colorDistance(c, canvas) > 32)
1477
+
1478
+ const rawSecondary = secondaryPool[0] ?? hslToHex((hexToHsl(accentPrimary).h + 36) % 360, Math.max(0.45, hexToHsl(accentPrimary).s * 0.85), dark ? 0.62 : 0.38)
1479
+ const accentSecondary = ensureContrast(rawSecondary, canvas, 3.2, 0.80)
1480
+ const accent2Text = ensureContrast(accentSecondary, surface1, 4.6, 0.80)
1481
+ const accentSoft = mixHex(canvas, accentPrimary, dark ? 0.18 : 0.10)
1482
+
1483
+ const positive = ensureContrast(dark ? '#34D399' : '#0D7A4E', surface1, 4.5)
1484
+ const negative = ensureContrast(dark ? '#F87171' : '#C81E1E', surface1, 4.5)
1485
+ const warning = ensureContrast(dark ? '#FBBF24' : '#B45309', surface1, 4.5)
1486
+
1487
+ const seriesSeeds = [
1488
+ accentPrimary,
1489
+ accentSecondary,
1490
+ ...[srcPalette.accent3, srcPalette.accent4, srcPalette.accent5, srcPalette.accent6].filter(Boolean).map((c) => normalizeHex(c)),
1491
+ ...OKABE_ITO_FALLBACKS,
1492
+ ]
1493
+ const chartSeries = []
1494
+ for (const candidate of seriesSeeds) {
1495
+ if (chartSeries.length >= 6) break
1496
+ const adjusted = ensureContrast(candidate, canvas, 3.0, 0.80)
1497
+ if (chartSeries.every((existing) => colorDistance(existing, adjusted) >= 34)) {
1498
+ chartSeries.push(adjusted)
1499
+ }
1500
+ }
1501
+ while (chartSeries.length < 6) {
1502
+ chartSeries.push(ensureContrast(OKABE_ITO_FALLBACKS[chartSeries.length % OKABE_ITO_FALLBACKS.length], canvas, 3.0))
1503
+ }
1504
+ const chartNeutral = mixHex(canvas, inkPrimary, dark ? 0.24 : 0.18)
1505
+
1506
+ const warnedFonts = new Set()
1507
+ const sanitizeExtractedFont = (rawFont) => {
1508
+ const trimmed = String(rawFont ?? '').trim()
1509
+ if (!trimmed || /^\+mn-|^\+mj-/i.test(trimmed)) return ''
1510
+ if (BITMAP_SERIF_FONT_RE.test(trimmed) || NOVELTY_FONT_RE.test(trimmed)) {
1511
+ if (!warnedFonts.has(trimmed)) {
1512
+ warnedFonts.add(trimmed)
1513
+ warnings.push('检测到低可读点阵或装饰字体 ' + trimmed + ',已自动升级为矢量抗锯齿字体。')
1514
+ }
1515
+ return pptxEastAsianFont(trimmed)
1516
+ }
1517
+ if (/^微软雅黑$/i.test(trimmed)) return pptxEastAsianFont(trimmed)
1518
+ return trimmed
1519
+ }
1520
+
1521
+ const isSafeSingleFont = (f) => Boolean(f && /^[\p{L}\p{N} _-]+$/u.test(f) && f.length <= 80 && !/^\+mn-|^\+mj-/i.test(f))
1522
+ const majorLatin = sanitizeExtractedFont(srcFonts.majorLatin)
1523
+ const majorEA = sanitizeExtractedFont(srcFonts.majorEastAsian)
1524
+ const minorLatin = sanitizeExtractedFont(srcFonts.minorLatin)
1525
+ const minorEA = sanitizeExtractedFont(srcFonts.minorEastAsian)
1526
+ const headingStack = [majorLatin, majorEA, SANS_STACK].filter(Boolean).join(', ')
1527
+ const bodyStack = [minorLatin || majorLatin, minorEA || majorEA, SANS_STACK].filter(Boolean).join(', ')
1528
+ const safeBrandFont = [minorEA, majorEA, minorLatin, majorLatin].find(isSafeSingleFont)
1529
+ const safeHeadingCandidate = [majorEA, majorLatin].find(isSafeSingleFont)
1530
+ const safeHeadingFont = safeHeadingCandidate && safeHeadingCandidate !== safeBrandFont ? safeHeadingCandidate : ''
1531
+
1532
+ // 匹配最接近的内置大师主题 ID
1533
+ let recommendedTheme = dark ? 'linear-dark' : 'consulting'
1534
+ let bestScore = Infinity
1535
+ for (const id of THEME_IDS) {
1536
+ const candidate = THEMES[id]
1537
+ if (candidate.dark !== dark) continue
1538
+ if (coverMode === 'inverted-accent' && candidate.tokens.coverMode === 'inverted-accent') {
1539
+ const d = hueDelta(coverBg, candidate.tokens.coverBg)
1540
+ if (d < bestScore) {
1541
+ bestScore = d
1542
+ recommendedTheme = id
1543
+ }
1544
+ continue
1545
+ }
1546
+ const score = hueDelta(accentPrimary, candidate.palette.accent) + colorDistance(canvas, candidate.palette.bg) * 0.25
1547
+ if (score < bestScore) {
1548
+ bestScore = score
1549
+ recommendedTheme = id
1550
+ }
1551
+ }
1552
+
1553
+ const tokens = {
1554
+ canvas,
1555
+ surface1,
1556
+ surface2,
1557
+ hairline,
1558
+ inkPrimary,
1559
+ inkSecondary,
1560
+ inkMuted,
1561
+ inkOnAccent,
1562
+ accentPrimary,
1563
+ accentText,
1564
+ accentSecondary,
1565
+ accent2Text,
1566
+ accentSoft,
1567
+ positive,
1568
+ negative,
1569
+ warning,
1570
+ chartFocal: accentPrimary,
1571
+ chartNeutral,
1572
+ chartSeries,
1573
+ coverMode,
1574
+ coverBg: coverMode === 'inverted-accent' ? coverBg : canvas,
1575
+ }
1576
+ const palette = {
1577
+ bg: canvas,
1578
+ panel: surface1,
1579
+ fg: inkPrimary,
1580
+ muted: inkMuted,
1581
+ accent: accentPrimary,
1582
+ accent2: accentSecondary,
1583
+ }
1584
+ const sanitizedBrand = {
1585
+ primaryColor: accentPrimary,
1586
+ secondaryColor: accentSecondary,
1587
+ backgroundColor: canvas,
1588
+ textColor: inkPrimary,
1589
+ ...(safeBrandFont ? { fontFamily: safeBrandFont } : {}),
1590
+ ...(safeHeadingFont ? { headingFont: safeHeadingFont } : {}),
1591
+ ...(coverMode === 'inverted-accent' ? { coverMode: 'inverted-accent', coverBg } : {}),
1592
+ }
1593
+
1594
+ return {
1595
+ dark,
1596
+ tokens,
1597
+ palette,
1598
+ fonts: { heading: headingStack, body: bodyStack },
1599
+ sanitizedBrand,
1600
+ sanitizedTokens: tokens,
1601
+ recommendedTheme,
1602
+ warnings,
1603
+ }
1604
+ }
1605
+
1606
+ /**
1607
+ * 基于用户 brand 覆盖安全重算整套主题表面色、网格线与次级色(彻底修复浅色覆盖深色主题时的黑网格线 Bug),
1608
+ * 同时保留用户显式指定的 backgroundColor / textColor 原值以供 checkManifest 进行对比度告警。
1609
+ */
1610
+ export function deriveBrandedTheme(themeOrId, brand) {
1611
+ const base = resolveTheme(themeOrId)
1612
+ const cloned = {
1613
+ ...base,
1614
+ palette: { ...base.palette },
1615
+ tokens: { ...base.tokens, chartSeries: [...base.tokens.chartSeries] },
1616
+ fonts: { ...base.fonts },
1617
+ }
1618
+ if (!brand || typeof brand !== 'object') return cloned
1619
+
1620
+ const hasColorOverride = Boolean(brand.backgroundColor || brand.textColor || brand.primaryColor || brand.secondaryColor || brand.coverMode || brand.coverBg)
1621
+ if (hasColorOverride) {
1622
+ const nextBg = brand.backgroundColor ? normalizeHex(brand.backgroundColor, base.palette.bg) : base.palette.bg
1623
+ const nextDark = relativeLuminance(nextBg) < 0.42
1624
+ const nextAccent = brand.primaryColor ? normalizeHex(brand.primaryColor, base.palette.accent) : base.palette.accent
1625
+ const defaultFgForPolarity = nextDark ? '#F5F7FA' : '#0F172A'
1626
+ const nextFg = brand.textColor
1627
+ ? normalizeHex(brand.textColor, defaultFgForPolarity)
1628
+ : (nextDark === base.dark ? base.palette.fg : defaultFgForPolarity)
1629
+
1630
+ const nextSurface1 = nextDark
1631
+ ? mixHex(nextBg, '#FFFFFF', 0.06)
1632
+ : adjustLightness(mixHex(nextBg, nextAccent, 0.035), -0.028)
1633
+ const nextSurface2 = nextDark
1634
+ ? mixHex(nextBg, '#FFFFFF', 0.11)
1635
+ : adjustLightness(mixHex(nextBg, nextAccent, 0.07), -0.06)
1636
+ const nextHairline = nextDark
1637
+ ? mixHex(nextBg, '#FFFFFF', 0.16)
1638
+ : mixHex(nextBg, '#0F172A', 0.13)
1639
+ const safeInkForDerived = contrastRatio(nextFg, nextSurface1) >= 4.5 ? nextFg : defaultFgForPolarity
1640
+ const nextInkSecondary = ensureContrast(mixHex(safeInkForDerived, nextSurface1, 0.25), nextSurface1, 7.0)
1641
+ const nextMuted = ensureContrast(mixHex(safeInkForDerived, nextSurface1, 0.46), nextSurface1, 4.6)
1642
+ const nextAccentText = ensureContrast(nextAccent, nextSurface1, 4.6)
1643
+ const rawSecondary = brand.secondaryColor ? normalizeHex(brand.secondaryColor, base.palette.accent2) : base.palette.accent2
1644
+ const nextAccent2 = ensureContrast(rawSecondary, nextBg, 3.0)
1645
+ const nextAccent2Text = ensureContrast(nextAccent2, nextSurface1, 4.6)
1646
+ const nextChartNeutral = mixHex(nextBg, safeInkForDerived, nextDark ? 0.24 : 0.18)
1647
+ const seedTail = brand.secondaryColor
1648
+ ? [nextAccent2, ...base.tokens.chartSeries.slice(1).filter((c) => colorDistance(c, nextAccent2) >= 28)]
1649
+ : base.tokens.chartSeries.slice(1)
1650
+ const nextSeries = [nextAccent, ...seedTail.slice(0, 5).map((c) => ensureContrast(c, nextBg, 2.8))]
1651
+ while (nextSeries.length < 6) {
1652
+ nextSeries.push(ensureContrast(OKABE_ITO_FALLBACKS[nextSeries.length % OKABE_ITO_FALLBACKS.length], nextBg, 2.8))
1653
+ }
1654
+
1655
+ const explicitInverted = brand.coverMode === 'inverted-accent'
1656
+ const resolvedCoverMode = explicitInverted
1657
+ ? 'inverted-accent'
1658
+ : brand.coverMode === 'standard'
1659
+ ? 'standard'
1660
+ : (brand.backgroundColor ? 'standard' : cloned.tokens.coverMode)
1661
+ const resolvedCoverBg = resolvedCoverMode === 'inverted-accent'
1662
+ ? (brand.coverBg ? normalizeHex(brand.coverBg, nextAccent) : (cloned.tokens.coverMode === 'inverted-accent' ? cloned.tokens.coverBg : nextAccent))
1663
+ : nextBg
1664
+
1665
+ cloned.dark = nextDark
1666
+ cloned.shadow = !nextDark && base.shadow
1667
+ cloned.palette = {
1668
+ bg: nextBg,
1669
+ panel: nextSurface1,
1670
+ fg: nextFg,
1671
+ muted: nextMuted,
1672
+ accent: nextAccent,
1673
+ accent2: nextAccent2,
1674
+ }
1675
+ cloned.tokens = {
1676
+ ...cloned.tokens,
1677
+ canvas: nextBg,
1678
+ surface1: nextSurface1,
1679
+ surface2: nextSurface2,
1680
+ hairline: nextHairline,
1681
+ inkPrimary: nextFg,
1682
+ inkSecondary: nextInkSecondary,
1683
+ inkMuted: nextMuted,
1684
+ inkOnAccent: relativeLuminance(nextAccent) > 0.36 ? '#0F172A' : '#FFFFFF',
1685
+ accentPrimary: nextAccent,
1686
+ accentText: nextAccentText,
1687
+ accentSecondary: nextAccent2,
1688
+ accent2Text: nextAccent2Text,
1689
+ accentSoft: mixHex(nextBg, nextAccent, nextDark ? 0.18 : 0.10),
1690
+ positive: ensureContrast(nextDark ? '#34D399' : '#0D7A4E', nextSurface1, 4.5),
1691
+ negative: ensureContrast(nextDark ? '#F87171' : '#C81E1E', nextSurface1, 4.5),
1692
+ warning: ensureContrast(nextDark ? '#FBBF24' : '#B45309', nextSurface1, 4.5),
1693
+ chartFocal: nextAccent,
1694
+ chartNeutral: nextChartNeutral,
1695
+ chartSeries: nextSeries,
1696
+ coverMode: resolvedCoverMode,
1697
+ coverBg: resolvedCoverBg,
1698
+ }
1699
+ }
1700
+
1701
+ if (brand.chromeStyle && CHROME_STYLE_SET.has(String(brand.chromeStyle).trim())) {
1702
+ cloned.chromeStyle = String(brand.chromeStyle).trim()
1703
+ }
1704
+
1705
+ const normalizeBrandFontStack = (raw, fallbackStack) => {
1706
+ const trimmed = String(raw).trim()
1707
+ if (!trimmed) return fallbackStack
1708
+ if (BITMAP_SERIF_FONT_RE.test(trimmed) || NOVELTY_FONT_RE.test(trimmed) || /^微软雅黑$/i.test(trimmed)) {
1709
+ return [pptxEastAsianFont(trimmed), SANS_STACK].join(', ')
1710
+ }
1711
+ return trimmed
1712
+ }
1713
+
1714
+ if (brand.fontFamily) {
1715
+ const cleanBody = normalizeBrandFontStack(brand.fontFamily, cloned.fonts.body)
1716
+ cloned.fonts = { heading: cleanBody, body: cleanBody }
1717
+ }
1718
+ if (brand.headingFont) {
1719
+ cloned.fonts = {
1720
+ ...cloned.fonts,
1721
+ heading: normalizeBrandFontStack(brand.headingFont, cloned.fonts.heading),
1722
+ }
1723
+ }
1724
+ return cloned
1725
+ }
1726
+
1727
+ // ---------------------------------------------------------------------------
1728
+ // 主题预览 SVG 色板卡与对比页生成
1729
+ // ---------------------------------------------------------------------------
1730
+
1731
+ function xmlEsc(value) {
1732
+ return String(value ?? '')
1733
+ .replace(/&/g, '&amp;')
1734
+ .replace(/</g, '&lt;')
1735
+ .replace(/>/g, '&gt;')
1736
+ .replace(/"/g, '&quot;')
1737
+ .replace(/'/g, '&apos;')
1738
+ }
1739
+
1740
+ function htmlEsc(value) {
1741
+ return String(value ?? '')
1742
+ .replace(/&/g, '&amp;')
1743
+ .replace(/</g, '&lt;')
1744
+ .replace(/>/g, '&gt;')
1745
+ .replace(/"/g, '&quot;')
1746
+ }
1747
+
1748
+ function themePreviewLabels(lang) {
1749
+ return lang === 'en'
1750
+ ? { title: 'dsh-ppt theme gallery', hint: 'Pick a theme id for ppt_create (or pass auto)', usage: 'theme', dark: 'dark', light: 'light', palette: 'Palette' }
1751
+ : { title: 'dsh-ppt 主题预览', hint: '把 id 填给 ppt_create 的 theme 参数(默认推荐 auto 智能匹配)', usage: 'theme', dark: '深色', light: '浅色', palette: '色板' }
1752
+ }
1753
+
1754
+ export function renderThemeSvg(input, lang = 'zh', version = '0.0.0') {
1755
+ const theme = typeof input === 'string' ? resolveTheme(input) : input
1756
+ const pick = (pair) => (lang === 'en' ? pair.en : pair.zh)
1757
+ const p = theme.palette
1758
+ const tk = theme.tokens
1759
+ const L = themePreviewLabels(lang === 'en' ? 'en' : 'zh')
1760
+ const font = theme.fonts.heading.replace(/"/g, "'")
1761
+ const bodyFont = theme.fonts.body.replace(/"/g, "'")
1762
+ const rx = Math.max(0, Math.min(16, theme.radiusPx ?? 10))
1763
+ const out = []
1764
+ out.push('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 960 540" width="960" height="540" role="img" aria-label="' + xmlEsc(theme.id + ' ' + pick(theme.name)) + '">')
1765
+ out.push('<rect width="960" height="540" fill="' + p.bg + '"/>')
1766
+ out.push('<rect x="0" y="0" width="960" height="6" fill="' + p.accent + '"/><rect x="0" y="534" width="960" height="4" fill="' + p.accent2 + '"/>')
1767
+ out.push('<rect x="36" y="40" width="560" height="360" rx="' + rx + '" fill="' + p.panel + '" stroke="' + tk.hairline + '"/>')
1768
+ out.push('<text x="64" y="92" fill="' + tk.accentText + '" font-family="' + xmlEsc(bodyFont) + '" font-size="13" font-weight="700" letter-spacing="2.5">' + xmlEsc(pick(theme.mood).toUpperCase()) + '</text>')
1769
+ out.push('<text x="64" y="156" fill="' + p.fg + '" font-family="' + xmlEsc(font) + '" font-size="40" font-weight="800">' + xmlEsc('Aa ' + pick(theme.name)) + '</text>')
1770
+ out.push('<rect x="64" y="196" width="164" height="74" rx="' + Math.max(0, rx - 2) + '" fill="' + tk.surface2 + '" stroke="' + tk.hairline + '"/>')
1771
+ out.push('<text x="80" y="232" fill="' + tk.accentText + '" font-family="' + xmlEsc(font) + '" font-size="24" font-weight="800">+38.4%</text>')
1772
+ out.push('<text x="80" y="254" fill="' + p.muted + '" font-family="' + xmlEsc(bodyFont) + '" font-size="12">Core KPI · YoY</text>')
1773
+ out.push('<rect x="244" y="196" width="320" height="74" rx="' + Math.max(0, rx - 2) + '" fill="' + tk.surface2 + '" stroke="' + tk.hairline + '"/>')
1774
+ out.push('<rect x="262" y="214" width="210" height="10" rx="4" fill="' + hexToRgba(p.fg, 0.78) + '"/>')
1775
+ out.push('<rect x="262" y="238" width="165" height="10" rx="4" fill="' + hexToRgba(p.fg, 0.45) + '"/>')
1776
+ out.push('<rect x="64" y="298" width="500" height="36" rx="' + Math.max(0, rx - 2) + '" fill="' + p.accent + '"/>')
1777
+ out.push('<text x="80" y="321" fill="' + tk.inkOnAccent + '" font-family="' + xmlEsc(bodyFont) + '" font-size="14" font-weight="700">dsh-ppt · ' + xmlEsc(theme.persona) + '</text>')
1778
+ out.push('<text x="548" y="321" fill="' + tk.inkOnAccent + '" font-family="' + xmlEsc(bodyFont) + '" font-size="14" font-weight="700" text-anchor="end">100%</text>')
1779
+ out.push('<rect x="64" y="352" width="500" height="1" fill="' + tk.hairline + '"/>')
1780
+ out.push('<text x="64" y="380" fill="' + p.muted + '" font-family="' + xmlEsc(bodyFont) + '" font-size="13">' + xmlEsc(theme.id + ' · ' + (theme.dark ? L.dark : L.light) + ' · v' + version) + '</text>')
1781
+ const swatches = ['bg', 'panel', 'fg', 'muted', 'accent', 'accent2']
1782
+ out.push('<text x="632" y="76" fill="' + p.muted + '" font-family="' + xmlEsc(bodyFont) + '" font-size="13" font-weight="700" letter-spacing="2">' + xmlEsc(L.palette.toUpperCase()) + '</text>')
1783
+ swatches.forEach((key, i) => {
1784
+ const y = 96 + i * 62
1785
+ out.push('<rect x="632" y="' + y + '" width="44" height="44" rx="10" fill="' + p[key] + '" stroke="' + tk.hairline + '"/>')
1786
+ out.push('<text x="692" y="' + (y + 20) + '" fill="' + p.fg + '" font-family="' + xmlEsc(bodyFont) + '" font-size="14" font-weight="600">' + xmlEsc(key) + '</text>')
1787
+ out.push('<text x="692" y="' + (y + 38) + '" fill="' + p.muted + '" font-family="' + xmlEsc(bodyFont) + '" font-size="13">' + xmlEsc(String(p[key]).toUpperCase()) + '</text>')
1788
+ })
1789
+ out.push('<text x="632" y="508" fill="' + p.muted + '" font-family="' + xmlEsc(bodyFont) + '" font-size="12">' + xmlEsc(pick(theme.bestFor)).slice(0, 44) + '</text>')
1790
+ out.push('</svg>')
1791
+ return out.join('')
1792
+ }
1793
+
1794
+ export function renderThemePreviewHtml(lang = 'zh', version = '0.0.0') {
1795
+ const L = themePreviewLabels(lang === 'en' ? 'en' : 'zh')
1796
+ const cards = THEME_IDS.map((id) => {
1797
+ const theme = THEMES[id]
1798
+ const pick = (pair) => (lang === 'en' ? pair.en : pair.zh)
1799
+ const chips = Object.keys(theme.palette).map((key) =>
1800
+ '<span class="chip"><i style="background:' + theme.palette[key] + '"></i>' + htmlEsc(String(theme.palette[key]).toUpperCase()) + '</span>').join('')
1801
+ return '<figure class="card" id="theme-' + htmlEsc(id) + '">' +
1802
+ renderThemeSvg(theme, lang === 'en' ? 'en' : 'zh', version) +
1803
+ '<figcaption><div class="row"><strong>' + htmlEsc(id) + '</strong><span class="badge">' + htmlEsc(pick(theme.name)) + ' · ' + (theme.dark ? L.dark : L.light) + '</span></div>' +
1804
+ '<p class="muted">' + htmlEsc(pick(theme.mood)) + ' · ' + htmlEsc(pick(theme.bestFor)) + '</p>' +
1805
+ '<p class="chips">' + chips + '</p>' +
1806
+ '<p class="usage">' + htmlEsc(L.usage) + ': <code>' + htmlEsc(id) + '</code></p></figcaption></figure>'
1807
+ }).join('')
1808
+ return '<!DOCTYPE html><html lang="' + (lang === 'en' ? 'en-US' : 'zh-CN') + '">' +
1809
+ '<head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0">' +
1810
+ '<title>' + htmlEsc(L.title) + '</title><style>' +
1811
+ 'body{margin:0;background:#F8FAFC;color:#0F172A;font-family:"Inter","Segoe UI","PingFang SC","Microsoft YaHei",sans-serif;padding:32px}' +
1812
+ 'h1{font-size:28px;margin:0 0 6px;letter-spacing:-.02em}p.sub{color:#475569;margin:0 0 26px;font-size:14px}' +
1813
+ '.grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(420px,1fr));gap:22px}' +
1814
+ '.card{margin:0;background:#FFFFFF;border:1px solid #E2E8F0;border-radius:14px;overflow:hidden;box-shadow:0 4px 16px rgba(15,23,42,.04)}' +
1815
+ '.card svg{display:block;width:100%;height:auto;border-bottom:1px solid #E2E8F0}' +
1816
+ 'figcaption{padding:14px 16px 16px}.row{display:flex;align-items:center;gap:10px;font-size:16px}' +
1817
+ '.badge{color:#475569;font-size:13px}.muted{color:#475569;font-size:13px;margin:6px 0 10px;line-height:1.5}' +
1818
+ '.chips{display:flex;flex-wrap:wrap;gap:6px;margin:0 0 10px}.chip{display:inline-flex;align-items:center;gap:6px;font-size:12px;color:#334155;background:#F8FAFC;border:1px solid #CBD5E1;border-radius:99px;padding:3px 9px}' +
1819
+ '.chip i{width:10px;height:10px;border-radius:3px;display:inline-block;border:1px solid rgba(0,0,0,.12)}' +
1820
+ '.usage{margin:0;font-size:13px;color:#334155}code{background:#F1F5F9;border:1px solid #CBD5E1;border-radius:6px;padding:1px 6px}' +
1821
+ '@media (prefers-reduced-motion: reduce){*{transition:none!important;animation:none!important}}' +
1822
+ '</style></head><body><h1>' + htmlEsc(L.title) + '</h1><p class="sub">' + htmlEsc(L.hint) + ' · dsh-ppt v' + htmlEsc(version) + '</p>' +
1823
+ '<div class="grid">' + cards + '</div></body></html>'
1824
+ }
1825
+
1826
+ export function buildThemePreviewFileSet(options = {}, resolveLanguageFn, version = '0.0.0') {
1827
+ const langInput = typeof options.lang === 'string' && options.lang.trim() !== '' ? options.lang.trim() : 'zh'
1828
+ const language = resolveLanguageFn ? resolveLanguageFn(langInput) : { id: langInput === 'en' ? 'en' : 'zh' }
1829
+ const outputDir = resolvePath(String(options.outputDir ?? '.'))
1830
+ mkdirSync(outputDir, { recursive: true })
1831
+ const overwrite = options.overwrite === true
1832
+ const pickPath = (base, ext) => {
1833
+ const first = resolvePath(joinPath(outputDir, base + ext))
1834
+ if (overwrite || !existsSync(first)) return first
1835
+ for (let i = 1; i < 1000; i += 1) {
1836
+ const candidate = resolvePath(joinPath(outputDir, base + '-' + i + ext))
1837
+ if (!existsSync(candidate)) return candidate
1838
+ }
1839
+ throw new Error('dsh-ppt:找不到可用的预览文件名(同名前缀超过 999 个),请允许 overwrite。')
1840
+ }
1841
+ const htmlPath = pickPath('themes-preview', '.html')
1842
+ writeFileSync(htmlPath, renderThemePreviewHtml(language.id, version), 'utf8')
1843
+ const svgs = THEME_IDS.map((id) => {
1844
+ const svgPath = pickPath('theme-' + id, '.svg')
1845
+ writeFileSync(svgPath, renderThemeSvg(id, language.id, version), 'utf8')
1846
+ return { id, path: svgPath }
1847
+ })
1848
+ return { ok: true, outputDir, htmlPath, svgs, themeCount: THEME_IDS.length, language: language.id }
1849
+ }
1850
+
1851
+ export function buildThemePreview(options = {}, resolveLanguageFn, version = '0.0.0') {
1852
+ return buildThemePreviewFileSet(options, resolveLanguageFn, version)
1853
+ }
1854
+