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,4673 @@
1
+ /**
2
+ * deck-layouts.mjs —— dsh-ppt 的 16:9 12 列栅格几何求解器、CJK 确定性字号拟合引擎、
3
+ * 无损内联富文本分词器,以及 19 套零依赖核心原生版式(含 5 套专业图示)与 6 套母版骨架同构渲染器。
4
+ *
5
+ * 零外部运行时依赖,仅使用 Node 内置模块。
6
+ */
7
+
8
+ import { pptxFontName, pptxEastAsianFont, hexToRgba, relativeLuminance, resolveChromeStyle, mixHex } from './deck-themes.mjs'
9
+
10
+ // ---------------------------------------------------------------------------
11
+ // 常量与坐标换算(16:9 画布:13.3333" × 7.5" = 12192000 × 6858000 EMU)
12
+ // ---------------------------------------------------------------------------
13
+
14
+ export const CANVAS_IN = Object.freeze({ w: 13.3333333333, h: 7.5 })
15
+ export const EMU_PER_IN = 914400
16
+ export const EMU_PER_PT = 12700
17
+ export const EMU_W = 12192000
18
+ export const EMU_H = 6858000
19
+
20
+ export const CORE_LAYOUTS = new Set([
21
+ 'cover',
22
+ 'agenda',
23
+ 'section',
24
+ 'bullets',
25
+ 'statement',
26
+ 'quote',
27
+ 'kpi',
28
+ 'cards',
29
+ 'comparison',
30
+ 'matrix',
31
+ 'process',
32
+ 'callout',
33
+ 'gantt',
34
+ 'architecture',
35
+ 'harvey',
36
+ 'tam',
37
+ 'org',
38
+ 'table',
39
+ 'closing',
40
+ ])
41
+
42
+ export const LAYOUT_ALIASES = Object.freeze({
43
+ 'kpi-grid': { layout: 'kpi', variant: 'grid' },
44
+ scorecard: { layout: 'kpi', variant: 'grid' },
45
+ bento: { layout: 'cards', variant: 'bento' },
46
+ pillars: { layout: 'cards', variant: 'pillars' },
47
+ 'exec-summary': { layout: 'cards', variant: 'exec-summary' },
48
+ timeline: { layout: 'process', variant: 'timeline' },
49
+ steps: { layout: 'process', variant: 'steps' },
50
+ layers: { layout: 'process', variant: 'layers' },
51
+ funnel: { layout: 'process', variant: 'funnel' },
52
+ flywheel: { layout: 'process', variant: 'flywheel' },
53
+ chevron: { layout: 'process', variant: 'chevron' },
54
+ 'value-chain': { layout: 'process', variant: 'chevron' },
55
+ 'issue-action': { layout: 'comparison', variant: 'issue-action' },
56
+ 'before-after': { layout: 'comparison', variant: 'before-after' },
57
+ 'matrix-2x2': { layout: 'matrix', variant: '2x2' },
58
+ 'formula-callout': { layout: 'callout', variant: 'formula' },
59
+ takeaways: { layout: 'callout', variant: 'takeaways' },
60
+ roadmap: { layout: 'gantt', variant: 'quarters' },
61
+ swimlane: { layout: 'gantt', variant: 'swimlane' },
62
+ team: { layout: 'org', variant: 'team' },
63
+ gallery: { layout: 'image', variant: 'gallery' },
64
+ 'gallery-grid': { layout: 'image', variant: 'gallery' },
65
+ 'ablation-compare': { layout: 'chart-split', variant: 'chart-right' },
66
+ waterfall: { layout: 'chart', chartKind: 'waterfall' },
67
+ })
68
+
69
+ export function inToEmu(inches) {
70
+ return Math.round(inches * EMU_PER_IN)
71
+ }
72
+
73
+ export function ptToEmu(pts) {
74
+ return Math.round(pts * EMU_PER_PT)
75
+ }
76
+
77
+ export function boxToEmu(box) {
78
+ return {
79
+ x: inToEmu(box.x),
80
+ y: inToEmu(box.y),
81
+ w: inToEmu(box.w),
82
+ h: inToEmu(box.h),
83
+ }
84
+ }
85
+
86
+ export function boxToCssPct(box) {
87
+ return (
88
+ 'left:' + (box.x / CANVAS_IN.w * 100).toFixed(4) + '%;' +
89
+ 'top:' + (box.y / CANVAS_IN.h * 100).toFixed(4) + '%;' +
90
+ 'width:' + (box.w / CANVAS_IN.w * 100).toFixed(4) + '%;' +
91
+ 'height:' + (box.h / CANVAS_IN.h * 100).toFixed(4) + '%'
92
+ )
93
+ }
94
+
95
+ /**
96
+ * 计算 OOXML roundRect 的 adj 参数(0..50000),使物理圆角半径与 HTML border-radius 严格一致。
97
+ */
98
+ export function roundRectAdj(wIn, hIn, radiusPx = 8) {
99
+ if (!radiusPx || radiusPx <= 0) return 0
100
+ const rIn = radiusPx / 96
101
+ const minSide = Math.max(0.05, Math.min(wIn, hIn))
102
+ return Math.max(0, Math.min(50000, Math.round((rIn / minSide) * 100000)))
103
+ }
104
+
105
+ // ---------------------------------------------------------------------------
106
+ // XML / HTML 转义与无损内联富文本解析
107
+ // ---------------------------------------------------------------------------
108
+
109
+ export function escapeXml(value) {
110
+ return String(value ?? '')
111
+ .replace(/[\u000B\u000C]/g, '\n')
112
+ .replace(/[^\u0009\u000A\u000D\u0020-\uD7FF\uE000-\uFFFD\u{10000}-\u{10FFFF}]/gu, '')
113
+ .replace(/&/g, '&amp;')
114
+ .replace(/</g, '&lt;')
115
+ .replace(/>/g, '&gt;')
116
+ .replace(/"/g, '&quot;')
117
+ .replace(/'/g, '&apos;')
118
+ }
119
+
120
+ export function escapeHtml(value) {
121
+ return String(value ?? '')
122
+ .replace(/&/g, '&amp;')
123
+ .replace(/</g, '&lt;')
124
+ .replace(/>/g, '&gt;')
125
+ .replace(/"/g, '&quot;')
126
+ }
127
+
128
+ export function stripInlineMarkdown(value) {
129
+ return String(value ?? '')
130
+ .replace(/!\[[^\]]*\]\([^)]*\)/g, '')
131
+ .replace(/\[([^\]]+)\]\([^)]*\)/g, '$1')
132
+ .replace(/`([^`]*)`/g, '$1')
133
+ .replace(/\*\*([^*]+)\*\*/g, '$1')
134
+ .replace(/__([^_]+)__/g, '$1')
135
+ .replace(/\*([^*\n]+)\*/g, '$1')
136
+ .replace(/_([^_\n]+)_/g, '$1')
137
+ .replace(/<[^>]+>/g, '')
138
+ .replace(/\s+/g, ' ')
139
+ .trim()
140
+ }
141
+
142
+ /**
143
+ * 清理不安全标签与链接语法,但保留成对的 **粗体**、*斜体* 与 `代码` 标记。
144
+ * 纯文本输入(无标记)输出与 stripInlineMarkdown 完全一致。
145
+ */
146
+ export function cleanRichText(value) {
147
+ return String(value ?? '')
148
+ .replace(/!\[[^\]]*\]\([^)]*\)/g, '')
149
+ .replace(/\[([^\]]+)\]\([^)]*\)/g, '$1')
150
+ .replace(/<[^>]+>/g, '')
151
+ .replace(/__([^_]+)__/g, '**$1**')
152
+ .replace(/\s+/g, ' ')
153
+ .trim()
154
+ }
155
+
156
+ const INLINE_TOKEN_RE = /(\*\*[^*]+\*\*|`[^`]+`|\*[^*\s][^*]*?\*)/g
157
+
158
+ /**
159
+ * 将单行富文本拆分为结构化 Run 数组,用于 HTML 与 PPTX 多 <a:r> 同构输出。
160
+ * 支持可选 autoLeadBold:对「短前缀:正文说明」自动加粗前缀(不篡改源字符串)。
161
+ */
162
+ export function parseInlineRuns(input, options = {}) {
163
+ const text = String(input ?? '')
164
+ if (text === '') return []
165
+ const hasExplicitMarkup = /\*\*[^*]+\*\*|`[^`]+`|\*[^*\s][^*]*?\*/.test(text)
166
+
167
+ if (!hasExplicitMarkup && options.autoLeadBold) {
168
+ const colonMatch = /^([^::]{2,12}[::])\s*(.+)$/.exec(text)
169
+ if (colonMatch && !/^https?:/i.test(text)) {
170
+ return [
171
+ { text: colonMatch[1], bold: true, lead: true },
172
+ { text: (colonMatch[1].endsWith(':') ? ' ' : '') + colonMatch[2], secondary: true },
173
+ ]
174
+ }
175
+ }
176
+
177
+ if (!hasExplicitMarkup) {
178
+ return [{ text }]
179
+ }
180
+
181
+ const runs = []
182
+ let lastIndex = 0
183
+ for (const match of text.matchAll(INLINE_TOKEN_RE)) {
184
+ const idx = match.index ?? 0
185
+ if (idx > lastIndex) {
186
+ runs.push({ text: text.slice(lastIndex, idx) })
187
+ }
188
+ const token = match[0]
189
+ if (token.startsWith('**') && token.endsWith('**')) {
190
+ runs.push({ text: token.slice(2, -2), bold: true })
191
+ } else if (token.startsWith('`') && token.endsWith('`')) {
192
+ runs.push({ text: token.slice(1, -1), code: true })
193
+ } else if (token.startsWith('*') && token.endsWith('*')) {
194
+ runs.push({ text: token.slice(1, -1), italic: true })
195
+ } else {
196
+ runs.push({ text: token })
197
+ }
198
+ lastIndex = idx + token.length
199
+ }
200
+ if (lastIndex < text.length) {
201
+ runs.push({ text: text.slice(lastIndex) })
202
+ }
203
+ return runs.filter((r) => r.text !== '')
204
+ }
205
+
206
+ export function renderInlineHtml(input, options = {}) {
207
+ const text = String(input ?? '')
208
+ const runs = parseInlineRuns(text, options)
209
+ if (runs.length === 1 && !runs[0].bold && !runs[0].italic && !runs[0].code) {
210
+ return escapeHtml(runs[0].text)
211
+ }
212
+ return runs.map((run) => {
213
+ const escaped = escapeHtml(run.text)
214
+ if (run.code) return '<code class="inline-code">' + escaped + '</code>'
215
+ if (run.bold && run.lead) return '<strong class="lead-in">' + escaped + '</strong>'
216
+ if (run.bold) return '<strong>' + escaped + '</strong>'
217
+ if (run.italic) return '<em>' + escaped + '</em>'
218
+ if (run.secondary) return '<span class="ink-sec">' + escaped + '</span>'
219
+ return escaped
220
+ }).join('')
221
+ }
222
+
223
+ // ---------------------------------------------------------------------------
224
+ // CJK + Latin 视觉宽度与确定性字号拟合算法 computeTextFit()
225
+ // ---------------------------------------------------------------------------
226
+
227
+ export function measureEmWidth(input, bold = false) {
228
+ const plain = stripInlineMarkdown(input)
229
+ let total = 0
230
+ for (const ch of plain) {
231
+ const code = ch.codePointAt(0) ?? 0
232
+ if (
233
+ (code >= 0x2E80 && code <= 0x9FFF) ||
234
+ (code >= 0xF900 && code <= 0xFAFF) ||
235
+ (code >= 0xFF00 && code <= 0xFFEF) ||
236
+ (code >= 0x3000 && code <= 0x303F) ||
237
+ code > 0x1F000
238
+ ) {
239
+ total += 1.02
240
+ } else if (ch >= 'A' && ch <= 'Z') {
241
+ total += 0.66
242
+ } else if (ch >= '0' && ch <= '9') {
243
+ total += 0.58
244
+ } else if (ch === ' ' || ch === '.' || ch === ',' || ch === ':' || ch === ';' || ch === '|' || ch === '!' || ch === 'i' || ch === 'l') {
245
+ total += 0.32
246
+ } else {
247
+ total += 0.54
248
+ }
249
+ }
250
+ return bold ? total * 1.06 : total
251
+ }
252
+
253
+ const ROLE_DEFAULTS = {
254
+ coverTitle: { maxPt: 44, minPt: 28, lineHeight: 1.16, spaceAfterPt: 8, bold: true },
255
+ sectionTitle: { maxPt: 38, minPt: 24, lineHeight: 1.18, spaceAfterPt: 6, bold: true },
256
+ slideTitle: { maxPt: 27, minPt: 20, lineHeight: 1.22, spaceAfterPt: 0, bold: true },
257
+ statement: { maxPt: 34, minPt: 22, lineHeight: 1.26, spaceAfterPt: 8, bold: true },
258
+ quote: { maxPt: 28, minPt: 18, lineHeight: 1.32, spaceAfterPt: 8, bold: true },
259
+ body: { maxPt: 18, minPt: 13.5, lineHeight: 1.48, spaceAfterPt: 8, bold: false },
260
+ cardTitle: { maxPt: 17.5, minPt: 14, lineHeight: 1.28, spaceAfterPt: 4, bold: true },
261
+ cardBody: { maxPt: 15, minPt: 13.5, lineHeight: 1.44, spaceAfterPt: 5, bold: false },
262
+ kpiValue: { maxPt: 46, minPt: 26, lineHeight: 1.06, spaceAfterPt: 2, bold: true },
263
+ tableCell: { maxPt: 15, minPt: 11.5, lineHeight: 1.32, spaceAfterPt: 0, bold: false },
264
+ }
265
+
266
+ /**
267
+ * 根据目标框英寸尺寸与文本行数组,确定性求解不溢出的最大字号(硬底线 13.5pt 正文 / 20pt 标题)。
268
+ */
269
+ export function computeTextFit(linesInput, boxIn, role = 'body', overrides = {}) {
270
+ const cfg = { ...(ROLE_DEFAULTS[role] ?? ROLE_DEFAULTS.body), ...overrides }
271
+ const paragraphs = (Array.isArray(linesInput) ? linesInput : [linesInput])
272
+ .map((line) => String(line ?? ''))
273
+ .filter((line) => line.trim() !== '')
274
+ if (paragraphs.length === 0) {
275
+ return { fontPt: cfg.maxPt, lineHeight: cfg.lineHeight, lines: 0, fontScale: 100000, overflow: false }
276
+ }
277
+
278
+ const padXPt = overrides.padXPt ?? 14
279
+ const padYPt = overrides.padYPt ?? 10
280
+ const innerWPt = Math.max(36, boxIn.w * 72 - padXPt * 2)
281
+ const innerHPt = Math.max(20, boxIn.h * 72 - padYPt * 2)
282
+ const emWidths = paragraphs.map((p) => measureEmWidth(p, cfg.bold))
283
+
284
+ const evalAt = (pt) => {
285
+ const lines = emWidths.reduce((sum, em) => sum + Math.max(1, Math.ceil((em * pt) / innerWPt)), 0)
286
+ const totalHPt = lines * pt * cfg.lineHeight + Math.max(0, paragraphs.length - 1) * cfg.spaceAfterPt
287
+ return { lines, totalHPt }
288
+ }
289
+
290
+ for (let pt = cfg.maxPt; pt >= cfg.minPt - 1e-6; pt -= 0.5) {
291
+ const roundedPt = Math.round(pt * 2) / 2
292
+ const { lines, totalHPt } = evalAt(roundedPt)
293
+ if (totalHPt <= innerHPt * 0.94) {
294
+ const ratio = totalHPt / innerHPt
295
+ const fontScale = ratio > 0.88 ? 94000 : 100000
296
+ return { fontPt: roundedPt, lineHeight: cfg.lineHeight, lines, fontScale, overflow: false }
297
+ }
298
+ }
299
+
300
+ const floorEval = evalAt(cfg.minPt)
301
+ return {
302
+ fontPt: cfg.minPt,
303
+ lineHeight: cfg.lineHeight,
304
+ lines: floorEval.lines,
305
+ fontScale: floorEval.totalHPt > innerHPt ? 90000 : 96000,
306
+ overflow: floorEval.totalHPt > innerHPt * 1.05,
307
+ }
308
+ }
309
+
310
+ // ---------------------------------------------------------------------------
311
+ // 结构化子项 items 规范化与从 bullets 自动投影
312
+ // ---------------------------------------------------------------------------
313
+
314
+ const VALID_STATUS = new Set(['positive', 'negative', 'warning', 'neutral', 'accent'])
315
+
316
+ function parseBulletToItem(rawBullet, index, layout) {
317
+ const clean = cleanRichText(rawBullet)
318
+ const plain = stripInlineMarkdown(clean)
319
+
320
+ if (layout === 'kpi') {
321
+ // 识别形如 "+38.4% | 转化率:季度环比提升" 或 "1,280万元 营收(+32% YoY):华东大区驱动"
322
+ const pipeParts = clean.split(/\s*[||]\s*/)
323
+ if (pipeParts.length >= 2) {
324
+ const first = stripInlineMarkdown(pipeParts[0])
325
+ const second = pipeParts.slice(1).join(' · ')
326
+ const colonIdx = second.search(/[::]/)
327
+ const title = colonIdx > 0 ? stripInlineMarkdown(second.slice(0, colonIdx)) : stripInlineMarkdown(second)
328
+ const text = colonIdx > 0 ? cleanRichText(second.slice(colonIdx + 1)) : ''
329
+ const deltaMatch = /([+-]\d+(?:\.\d+)?\s*[%%]|YoY[^\s))]*)/i.exec(text + ' ' + pipeParts.join(' '))
330
+ return {
331
+ value: first,
332
+ title: title || ('指标 ' + (index + 1)),
333
+ ...(text ? { text } : {}),
334
+ ...(deltaMatch ? { delta: deltaMatch[1], status: deltaMatch[1].startsWith('-') ? 'negative' : 'positive' } : {}),
335
+ }
336
+ }
337
+ const metricMatch = /^((?:[¥$€]\s*)?[+-]?\d[\d,.]*\s*(?:[%%倍xX]|万|亿|元|万元|亿元|美元|万美元|亿美元|家|个|人|次|台|套|条|项|席|秒|ms|s|h|天|小时|分钟|k|M|B|\+)?)\s*[::\-—]?\s*(.*)$/i.exec(plain)
338
+ if (metricMatch) {
339
+ const rest = metricMatch[2] || ''
340
+ const colon = rest.search(/[::]/)
341
+ return {
342
+ value: metricMatch[1].trim(),
343
+ title: colon > 0 ? rest.slice(0, colon).trim() : (rest.trim() || ('指标 ' + (index + 1))),
344
+ ...(colon > 0 ? { text: rest.slice(colon + 1).trim() } : {}),
345
+ }
346
+ }
347
+ // 识别行中显著数值(含货币前缀与中文量词)
348
+ const inlineMetric = /((?:[¥$€]\s*[+-]?\d[\d,.]*(?:\s*(?:[%%倍xX]|万|亿|万元|亿元|美元|万美元|亿美元|家|个|人|次|台|套|条|项|席|秒|ms|天|小时|分钟|k|M|B|\+))?|[+-]?\d[\d,.]*\s*(?:[%%倍xX]|万|亿|万元|亿元|美元|万美元|亿美元|家|个|人|次|台|套|条|项|席|秒|ms|天|小时|分钟|\+)))/.exec(plain)
349
+ if (inlineMetric) {
350
+ const colon = plain.search(/[::]/)
351
+ return {
352
+ value: inlineMetric[1].trim(),
353
+ title: colon > 0 ? plain.slice(0, colon).trim() : plain.replace(inlineMetric[0], '').trim().slice(0, 18) || ('指标 ' + (index + 1)),
354
+ text: colon > 0 ? plain.slice(colon + 1).trim() : plain,
355
+ }
356
+ }
357
+ }
358
+
359
+ if (layout === 'comparison') {
360
+ const arrowMatch = /^(.+?)\s*(?:->|→|=>|──>|——>|vs\.?|VS)\s*(.+)$/.exec(clean)
361
+ if (arrowMatch) {
362
+ return {
363
+ tag: String(index + 1).padStart(2, '0'),
364
+ title: stripInlineMarkdown(arrowMatch[1]),
365
+ text: cleanRichText(arrowMatch[2]),
366
+ }
367
+ }
368
+ }
369
+
370
+ const boldLead = /^\*\*([^*]+)\*\*\s*[::—\-]?\s*(.*)$/.exec(clean)
371
+ if (boldLead) {
372
+ return {
373
+ tag: String(index + 1).padStart(2, '0'),
374
+ title: boldLead[1].trim(),
375
+ ...(boldLead[2].trim() ? { text: boldLead[2].trim() } : {}),
376
+ }
377
+ }
378
+
379
+ const colonSplit = /^([^::]{1,18})[::]\s*(.+)$/.exec(clean)
380
+ if (colonSplit && !/^https?$/i.test(colonSplit[1])) {
381
+ return {
382
+ tag: String(index + 1).padStart(2, '0'),
383
+ title: stripInlineMarkdown(colonSplit[1]),
384
+ text: colonSplit[2].trim(),
385
+ }
386
+ }
387
+
388
+ return {
389
+ tag: String(index + 1).padStart(2, '0'),
390
+ title: plain.length <= 20 ? plain : plain.slice(0, 16) + '…',
391
+ ...(plain.length > 20 ? { text: clean } : {}),
392
+ }
393
+ }
394
+
395
+ export function normalizeSlideItems(rawItems, layout) {
396
+ if (!Array.isArray(rawItems) || rawItems.length === 0) return undefined
397
+ const out = rawItems
398
+ .slice(0, 8)
399
+ .map((entry, idx) => {
400
+ if (typeof entry === 'string') return parseBulletToItem(entry, idx, layout)
401
+ if (!entry || typeof entry !== 'object' || Array.isArray(entry)) return null
402
+ const tag = stripInlineMarkdown(entry.tag ?? entry.badge ?? entry.step ?? entry.phase ?? '')
403
+ const title = stripInlineMarkdown(entry.title ?? entry.label ?? entry.heading ?? entry.name ?? '')
404
+ const text = cleanRichText(entry.text ?? entry.body ?? entry.description ?? entry.detail ?? '')
405
+ const value = entry.value !== undefined && entry.value !== null ? stripInlineMarkdown(String(entry.value)) : ''
406
+ const unit = stripInlineMarkdown(entry.unit ?? '')
407
+ const delta = stripInlineMarkdown(entry.delta ?? entry.change ?? '')
408
+ const rawStatus = String(entry.status ?? entry.tone ?? '').trim().toLowerCase()
409
+ const status = VALID_STATUS.has(rawStatus) ? rawStatus : undefined
410
+ const startNum = entry.start !== undefined && entry.start !== null && entry.start !== '' ? Number(entry.start) : NaN
411
+ const start = Number.isFinite(startNum) ? Math.max(0, startNum) : undefined
412
+ const spanNum = entry.span !== undefined && entry.span !== null && entry.span !== '' ? Number(entry.span) : NaN
413
+ const span = Number.isFinite(spanNum) ? Math.max(0, spanNum) : undefined
414
+ const milestone = entry.milestone === true ? true : undefined
415
+ const role = stripInlineMarkdown(entry.role ?? '')
416
+ const conversion = stripInlineMarkdown(entry.conversion ?? '')
417
+ const bullets = Array.isArray(entry.bullets ?? entry.items)
418
+ ? (entry.bullets ?? entry.items).map((b) => cleanRichText(String(b))).filter(Boolean).slice(0, 6)
419
+ : undefined
420
+ if (!title && !text && !value && (!bullets || bullets.length === 0)) return null
421
+ return {
422
+ ...(tag ? { tag } : {}),
423
+ ...(title ? { title } : {}),
424
+ ...(text ? { text } : {}),
425
+ ...(value ? { value } : {}),
426
+ ...(unit ? { unit } : {}),
427
+ ...(delta ? { delta } : {}),
428
+ ...(start !== undefined ? { start } : {}),
429
+ ...(span !== undefined ? { span } : {}),
430
+ ...(milestone ? { milestone } : {}),
431
+ ...(role ? { role } : {}),
432
+ ...(conversion ? { conversion } : {}),
433
+ ...(status ? { status } : {}),
434
+ ...(bullets?.length ? { bullets } : {}),
435
+ }
436
+ })
437
+ .filter(Boolean)
438
+ return out.length > 0 ? out : undefined
439
+ }
440
+
441
+ export function resolveEffectiveItems(slide) {
442
+ if (Array.isArray(slide.items) && slide.items.length > 0) return slide.items
443
+ const bullets = Array.isArray(slide.bullets) ? slide.bullets : []
444
+ if (bullets.length > 0) {
445
+ return bullets.slice(0, 8).map((b, i) => parseBulletToItem(b, i, slide.layout))
446
+ }
447
+ if (slide.subtitle || slide.text) {
448
+ return [parseBulletToItem(slide.text || slide.subtitle, 0, slide.layout)]
449
+ }
450
+ return []
451
+ }
452
+
453
+ // ---------------------------------------------------------------------------
454
+ // OOXML 基础图元构建器(严格遵循 ECMA-376 元素顺序与单页唯一 ID)
455
+ // ---------------------------------------------------------------------------
456
+
457
+ function hex6(color) {
458
+ return String(color ?? '#000000').replace(/^#/, '').slice(0, 6).toUpperCase()
459
+ }
460
+
461
+ export function ooxmlSolidFill(color, alphaFraction = 1) {
462
+ const alphaXml = alphaFraction < 0.999
463
+ ? '<a:alpha val="' + Math.round(Math.max(0, Math.min(1, alphaFraction)) * 100000) + '"/>'
464
+ : ''
465
+ return '<a:solidFill><a:srgbClr val="' + hex6(color) + '">' + alphaXml + '</a:srgbClr></a:solidFill>'
466
+ }
467
+
468
+ export function ooxmlLinearGradientFill(stops, angleDeg = 135) {
469
+ const gsLst = stops.map((s) => {
470
+ const pos = Math.round(Math.max(0, Math.min(1, s.offset)) * 100000)
471
+ const alpha = s.alpha !== undefined && s.alpha < 0.999
472
+ ? '<a:alpha val="' + Math.round(Math.max(0, Math.min(1, s.alpha)) * 100000) + '"/>'
473
+ : ''
474
+ return '<a:gs pos="' + pos + '"><a:srgbClr val="' + hex6(s.color) + '">' + alpha + '</a:srgbClr></a:gs>'
475
+ }).join('')
476
+ const ang = Math.round((((angleDeg % 360) + 360) % 360) * 60000)
477
+ return '<a:gradFill rotWithShape="1"><a:gsLst>' + gsLst + '</a:gsLst><a:lin ang="' + ang + '" scaled="1"/></a:gradFill>'
478
+ }
479
+
480
+ export function ooxmlRichParagraph(textOrRuns, options = {}) {
481
+ const {
482
+ sizePt = 16,
483
+ color = '#0F172A',
484
+ secondaryColor = color,
485
+ accentColor = color,
486
+ codeHighlight = '',
487
+ bold = false,
488
+ italic = false,
489
+ lang = 'zh-CN',
490
+ align = 'l',
491
+ bullet = false,
492
+ bulletChar = '▪',
493
+ bulletColor = '',
494
+ font = 'Segoe UI',
495
+ lineHeight = 1.35,
496
+ spaceBeforePt = 0,
497
+ spaceAfterPt = 0,
498
+ spc = 0,
499
+ autoLeadBold = false,
500
+ } = options
501
+
502
+ const latinFont = pptxFontName(font)
503
+ const eaFont = pptxEastAsianFont(font)
504
+ const sz = Math.round(sizePt * 100)
505
+ const runs = Array.isArray(textOrRuns)
506
+ ? textOrRuns
507
+ : parseInlineRuns(String(textOrRuns ?? ''), { autoLeadBold })
508
+
509
+ const lnSpcXml = lineHeight > 0
510
+ ? '<a:lnSpc><a:spcPct val="' + Math.round(lineHeight * 100000) + '"/></a:lnSpc>'
511
+ : ''
512
+ const spcBefXml = spaceBeforePt > 0
513
+ ? '<a:spcBef><a:spcPts val="' + Math.round(spaceBeforePt * 100) + '"/></a:spcBef>'
514
+ : ''
515
+ const spcAftXml = spaceAfterPt > 0
516
+ ? '<a:spcAft><a:spcPts val="' + Math.round(spaceAfterPt * 100) + '"/></a:spcAft>'
517
+ : ''
518
+ const bulletXml = bullet
519
+ ? (bulletColor ? '<a:buClr><a:srgbClr val="' + hex6(bulletColor) + '"/></a:buClr>' : '') +
520
+ '<a:buSzPct val="85000"/>' +
521
+ '<a:buFont typeface="' + escapeXml(latinFont) + '"/>' +
522
+ '<a:buChar char="' + escapeXml(bulletChar) + '"/>'
523
+ : '<a:buNone/>'
524
+
525
+ const pPrAttrs = (bullet ? ' marL="247650" indent="-247650"' : '') + (align !== 'l' ? ' algn="' + align + '"' : '')
526
+ const pPr = '<a:pPr' + pPrAttrs + '>' + lnSpcXml + spcBefXml + spcAftXml + bulletXml + '</a:pPr>'
527
+
528
+ if (runs.length === 0) {
529
+ return '<a:p>' + pPr + '<a:endParaRPr lang="' + lang + '" sz="' + sz + '" dirty="0"/></a:p>'
530
+ }
531
+
532
+ const runsXml = runs.map((run) => {
533
+ const runBold = Boolean(bold || run.bold)
534
+ const runItalic = Boolean(italic || run.italic)
535
+ const runColor = run.accent ? accentColor : run.secondary ? secondaryColor : color
536
+ const runSize = run.sizePt ? Math.round(run.sizePt * 100) : sz
537
+ const spcAttr = spc !== 0 ? ' spc="' + Math.round(spc) + '"' : ''
538
+ const hlXml = run.code && codeHighlight
539
+ ? '<a:highlight><a:srgbClr val="' + hex6(codeHighlight) + '"/></a:highlight>'
540
+ : ''
541
+ return (
542
+ '<a:r><a:rPr lang="' + lang + '" sz="' + runSize + '" b="' + (runBold ? 1 : 0) + '"' +
543
+ (runItalic ? ' i="1"' : '') + spcAttr + ' dirty="0">' +
544
+ ooxmlSolidFill(runColor) +
545
+ hlXml +
546
+ '<a:latin typeface="' + escapeXml(latinFont) + '"/>' +
547
+ '<a:ea typeface="' + escapeXml(eaFont) + '"/>' +
548
+ '</a:rPr><a:t>' + escapeXml(run.text) + '</a:t></a:r>'
549
+ )
550
+ }).join('')
551
+
552
+ return '<a:p>' + pPr + runsXml + '</a:p>'
553
+ }
554
+
555
+ export function ooxmlShape(id, name, boxIn, options = {}) {
556
+ const {
557
+ preset = 'rect',
558
+ adj,
559
+ adjs,
560
+ fill = '',
561
+ fillAlpha = 1,
562
+ gradientStops = null,
563
+ gradientAngle = 135,
564
+ stroke = '',
565
+ strokePt = 0.75,
566
+ dash = '',
567
+ shadow = false,
568
+ txBox = false,
569
+ anchor = 't',
570
+ marginsIn = { l: 0.08, r: 0.08, t: 0.05, b: 0.05 },
571
+ fontScale = 100000,
572
+ autofit = true,
573
+ paragraphs = [],
574
+ } = options
575
+
576
+ const b = boxToEmu(boxIn)
577
+ const avLst = adjs && typeof adjs === 'object'
578
+ ? '<a:avLst>' + Object.entries(adjs).map(([k, v]) => '<a:gd name="' + escapeXml(k) + '" fmla="val ' + Math.round(v) + '"/>').join('') + '</a:avLst>'
579
+ : adj !== undefined && preset === 'roundRect'
580
+ ? '<a:avLst><a:gd name="adj" fmla="val ' + Math.round(adj) + '"/></a:avLst>'
581
+ : '<a:avLst/>'
582
+ const fillXml = gradientStops
583
+ ? ooxmlLinearGradientFill(gradientStops, gradientAngle)
584
+ : fill
585
+ ? ooxmlSolidFill(fill, fillAlpha)
586
+ : '<a:noFill/>'
587
+ const lnXml = stroke
588
+ ? '<a:ln w="' + ptToEmu(strokePt) + '" cap="flat">' + ooxmlSolidFill(stroke) + (dash ? '<a:prstDash val="' + dash + '"/>' : '') + '</a:ln>'
589
+ : '<a:ln><a:noFill/></a:ln>'
590
+ const effectXml = shadow
591
+ ? '<a:effectLst><a:outerShdw blurRad="152400" dist="38100" dir="5400000" algn="tl" rotWithShape="0"><a:srgbClr val="0F172A"><a:alpha val="9000"/></a:srgbClr></a:outerShdw></a:effectLst>'
592
+ : ''
593
+
594
+ const lIns = inToEmu(marginsIn.l ?? 0.08)
595
+ const rIns = inToEmu(marginsIn.r ?? 0.08)
596
+ const tIns = inToEmu(marginsIn.t ?? 0.05)
597
+ const bIns = inToEmu(marginsIn.b ?? 0.05)
598
+ const fitXml = autofit
599
+ ? '<a:normAutofit' + (fontScale < 100000 ? ' fontScale="' + fontScale + '"' : '') + '/>'
600
+ : '<a:noAutofit/>'
601
+ const bodyContent = paragraphs.length > 0 ? paragraphs.join('') : '<a:p/>'
602
+
603
+ return (
604
+ '<p:sp>' +
605
+ '<p:nvSpPr><p:cNvPr id="' + id + '" name="' + escapeXml(name) + '"/>' +
606
+ '<p:cNvSpPr' + (txBox ? ' txBox="1"' : '') + '/><p:nvPr/></p:nvSpPr>' +
607
+ '<p:spPr><a:xfrm><a:off x="' + b.x + '" y="' + b.y + '"/><a:ext cx="' + b.w + '" cy="' + b.h + '"/></a:xfrm>' +
608
+ '<a:prstGeom prst="' + preset + '">' + avLst + '</a:prstGeom>' +
609
+ fillXml + lnXml + effectXml + '</p:spPr>' +
610
+ '<p:txBody><a:bodyPr wrap="square" rtlCol="0" lIns="' + lIns + '" tIns="' + tIns + '" rIns="' + rIns + '" bIns="' + bIns + '" anchor="' + anchor + '">' +
611
+ fitXml + '</a:bodyPr><a:lstStyle/>' + bodyContent + '</p:txBody>' +
612
+ '</p:sp>'
613
+ )
614
+ }
615
+
616
+ export function ooxmlLine(id, name, fromIn, toIn, options = {}) {
617
+ const {
618
+ color = '#CBD5E1',
619
+ widthPt = 1,
620
+ dash = '',
621
+ headArrow = false,
622
+ tailArrow = false,
623
+ } = options
624
+ const x = Math.min(fromIn.x, toIn.x)
625
+ const y = Math.min(fromIn.y, toIn.y)
626
+ const w = Math.max(0.001, Math.abs(toIn.x - fromIn.x))
627
+ const h = Math.max(0.001, Math.abs(toIn.y - fromIn.y))
628
+ const flipH = toIn.x < fromIn.x ? ' flipH="1"' : ''
629
+ const flipV = toIn.y < fromIn.y ? ' flipV="1"' : ''
630
+ const headXml = headArrow ? '<a:headEnd type="triangle" w="med" len="med"/>' : ''
631
+ const tailXml = tailArrow ? '<a:tailEnd type="triangle" w="med" len="med"/>' : ''
632
+
633
+ return (
634
+ '<p:cxnSp>' +
635
+ '<p:nvCxnSpPr><p:cNvPr id="' + id + '" name="' + escapeXml(name) + '"/><p:cNvCxnSpPr/><p:nvPr/></p:nvCxnSpPr>' +
636
+ '<p:spPr><a:xfrm' + flipH + flipV + '><a:off x="' + inToEmu(x) + '" y="' + inToEmu(y) + '"/>' +
637
+ '<a:ext cx="' + (Math.abs(toIn.x - fromIn.x) < 0.0005 ? 0 : Math.max(12700, inToEmu(w))) + '" cy="' + (Math.abs(toIn.y - fromIn.y) < 0.0005 ? 0 : inToEmu(h)) + '"/></a:xfrm>' +
638
+ '<a:prstGeom prst="line"><a:avLst/></a:prstGeom>' +
639
+ '<a:ln w="' + ptToEmu(widthPt) + '" cap="rnd">' + ooxmlSolidFill(color) +
640
+ (dash ? '<a:prstDash val="' + dash + '"/>' : '') + headXml + tailXml + '</a:ln>' +
641
+ '</p:spPr></p:cxnSp>'
642
+ )
643
+ }
644
+
645
+ function isNumericCell(cell) {
646
+ const plain = stripInlineMarkdown(cell)
647
+ return /^\s*[+-]?[$¥€£]?\s*(?:\d{1,3}(?:,\d{3})+|\d+)(?:\.\d+)?\s*(?:[%%xX倍]|万|亿|元|万元|亿元|次|页|个|人|天|小时|分钟|ms|s)?\s*$/.test(plain)
648
+ }
649
+
650
+ /**
651
+ * 原生可编辑 OOXML 表格(支持 consulting / booktabs 学术三线表 / minimal / banded,
652
+ * 智能按内容宽度分配列宽,数值列自动右对齐,支持单元格 **粗体** 高亮)。
653
+ */
654
+ export function ooxmlTable(id, name, boxIn, rows, theme, langAttr, tableStyleInput) {
655
+ const tk = theme.tokens
656
+ const style = tableStyleInput || theme.defaultTableStyle || 'consulting'
657
+ const safeRows = Array.isArray(rows) && rows.length > 0 ? rows : [['']]
658
+ const cols = Math.max(1, ...safeRows.map((r) => r.length))
659
+ const fontSizePt = cols <= 5 ? 15 : cols === 6 ? 14 : 12.5
660
+
661
+ // 智能按列最大视觉宽度分配列宽(钳制最小占比 9%,最大占比 44%)
662
+ const weights = Array.from({ length: cols }, (_, c) => {
663
+ const maxEm = Math.max(3, ...safeRows.map((r) => measureEmWidth(r[c] ?? '', true)))
664
+ return Math.min(24, Math.max(4, maxEm + 2))
665
+ })
666
+ const weightSum = weights.reduce((a, b) => a + b, 0) || cols
667
+ const totalWEmu = inToEmu(boxIn.w)
668
+ const colWidths = weights.map((w) => Math.floor((w / weightSum) * totalWEmu))
669
+ const remainder = totalWEmu - colWidths.reduce((a, b) => a + b, 0)
670
+ colWidths[0] += remainder
671
+ const gridXml = colWidths.map((w) => '<a:gridCol w="' + w + '"/>').join('')
672
+
673
+ // 判断数值列(除表头外 >=60% 非空单元格为数值)
674
+ const numericCols = Array.from({ length: cols }, (_, c) => {
675
+ const bodyCells = safeRows.slice(1).map((r) => String(r[c] ?? '').trim()).filter(Boolean)
676
+ return bodyCells.length > 0 && bodyCells.filter(isNumericCell).length / bodyCells.length >= 0.6
677
+ })
678
+
679
+ const rowCount = safeRows.length
680
+ const maxRowHIn = Math.min(0.56, Math.max(0.38, boxIn.h / Math.max(rowCount, 1)))
681
+ const rowHEmu = inToEmu(maxRowHIn)
682
+
683
+ const borderXml = (side, ptWidth, colorHex) =>
684
+ colorHex && ptWidth > 0
685
+ ? '<a:' + side + ' w="' + ptToEmu(ptWidth) + '" cap="flat" cmpd="sng" algn="ctr">' + ooxmlSolidFill(colorHex) + '<a:prstDash val="solid"/></a:' + side + '>'
686
+ : '<a:' + side + '><a:noFill/></a:' + side + '>'
687
+
688
+ const trsXml = safeRows.map((row, rIdx) => {
689
+ const isHeader = rIdx === 0
690
+ const isLast = rIdx === rowCount - 1
691
+ const padded = Array.from({ length: cols }, (_, c) => String(row[c] ?? ''))
692
+
693
+ const cellsXml = padded.map((cellText, cIdx) => {
694
+ const align = (numericCols[cIdx] || (!isHeader && isNumericCell(cellText))) ? 'r' : 'l'
695
+ let fillHex = ''
696
+ let textColor = tk.inkPrimary
697
+ let lnT = ''
698
+ let lnB = ''
699
+
700
+ if (style === 'booktabs') {
701
+ // 学术三线表:顶线 1.5pt,表头下线 0.75pt,底线 1.5pt,零底色,零竖线
702
+ fillHex = ''
703
+ textColor = tk.inkPrimary
704
+ lnT = isHeader ? borderXml('lnT', 1.5, tk.inkPrimary) : borderXml('lnT', 0, '')
705
+ lnB = isHeader
706
+ ? borderXml('lnB', 0.75, tk.inkPrimary)
707
+ : isLast
708
+ ? borderXml('lnB', 1.5, tk.inkPrimary)
709
+ : borderXml('lnB', 0, '')
710
+ } else if (style === 'minimal') {
711
+ fillHex = ''
712
+ textColor = isHeader ? tk.accentText : tk.inkPrimary
713
+ lnT = borderXml('lnT', 0, '')
714
+ lnB = isHeader
715
+ ? borderXml('lnB', 1.25, tk.accentPrimary)
716
+ : borderXml('lnB', 0.5, tk.hairline)
717
+ } else if (style === 'banded') {
718
+ fillHex = isHeader ? tk.accentPrimary : (rIdx % 2 === 1 ? tk.surface1 : '')
719
+ textColor = isHeader ? tk.inkOnAccent : tk.inkPrimary
720
+ lnT = borderXml('lnT', 0, '')
721
+ lnB = borderXml('lnB', 0.5, tk.hairline)
722
+ } else {
723
+ // consulting(默认):表头微表面底色 + 主强调底线,行间细发丝线,隔行微弱衬底
724
+ fillHex = isHeader ? tk.surface2 : (rIdx % 2 === 0 && rIdx > 0 ? tk.surface1 : '')
725
+ textColor = isHeader ? tk.inkPrimary : tk.inkPrimary
726
+ lnT = isHeader ? borderXml('lnT', 1.25, tk.accentPrimary) : borderXml('lnT', 0, '')
727
+ lnB = isHeader
728
+ ? borderXml('lnB', 1.25, tk.accentPrimary)
729
+ : isLast
730
+ ? borderXml('lnB', 1.0, tk.inkMuted)
731
+ : borderXml('lnB', 0.5, tk.hairline)
732
+ }
733
+
734
+ const para = ooxmlRichParagraph(cellText, {
735
+ sizePt: fontSizePt,
736
+ color: textColor,
737
+ secondaryColor: tk.inkSecondary,
738
+ accentColor: tk.accentText,
739
+ codeHighlight: tk.surface2,
740
+ bold: isHeader,
741
+ lang: langAttr,
742
+ align,
743
+ font: theme.fonts.body,
744
+ lineHeight: 1.25,
745
+ })
746
+
747
+ return (
748
+ '<a:tc>' +
749
+ '<a:txBody><a:bodyPr anchor="ctr"/><a:lstStyle/>' + para + '</a:txBody>' +
750
+ '<a:tcPr marL="109728" marR="109728" marT="54864" marB="54864" anchor="ctr">' +
751
+ borderXml('lnL', 0, '') +
752
+ borderXml('lnR', 0, '') +
753
+ lnT +
754
+ lnB +
755
+ (fillHex ? ooxmlSolidFill(fillHex) : '<a:noFill/>') +
756
+ '</a:tcPr></a:tc>'
757
+ )
758
+ }).join('')
759
+
760
+ return '<a:tr h="' + rowHEmu + '">' + cellsXml + '</a:tr>'
761
+ }).join('')
762
+
763
+ const totalHEmu = Math.max(1, rowCount) * rowHEmu
764
+ return (
765
+ '<p:graphicFrame>' +
766
+ '<p:nvGraphicFramePr><p:cNvPr id="' + id + '" name="' + escapeXml(name) + '"/>' +
767
+ '<p:cNvGraphicFramePr><a:graphicFrameLocks noGrp="1"/></p:cNvGraphicFramePr><p:nvPr/></p:nvGraphicFramePr>' +
768
+ '<p:xfrm><a:off x="' + inToEmu(boxIn.x) + '" y="' + inToEmu(boxIn.y) + '"/>' +
769
+ '<a:ext cx="' + totalWEmu + '" cy="' + totalHEmu + '"/></p:xfrm>' +
770
+ '<a:graphic><a:graphicData uri="http://schemas.openxmlformats.org/drawingml/2006/table">' +
771
+ '<a:tbl><a:tblPr firstRow="1" bandRow="' + (style === 'booktabs' || style === 'minimal' ? '0' : '1') + '"/>' +
772
+ '<a:tblGrid>' + gridXml + '</a:tblGrid>' + trsXml + '</a:tbl>' +
773
+ '</a:graphicData></a:graphic></p:graphicFrame>'
774
+ )
775
+ }
776
+
777
+ // ---------------------------------------------------------------------------
778
+ // 页眉、底栏结论条(Takeaway)与页脚页码(Folio)共享装饰组件
779
+ // ---------------------------------------------------------------------------
780
+
781
+ function statusPalette(status, tk) {
782
+ if (status === 'positive') return { fg: tk.positive, bg: tk.surface2, bar: tk.positive }
783
+ if (status === 'negative') return { fg: tk.negative, bg: tk.surface2, bar: tk.negative }
784
+ if (status === 'warning') return { fg: tk.warning, bg: tk.surface2, bar: tk.warning }
785
+ if (status === 'accent') return { fg: tk.accentText, bg: tk.accentSoft, bar: tk.accentPrimary }
786
+ return { fg: tk.accentText, bg: tk.surface1, bar: tk.accentPrimary }
787
+ }
788
+
789
+ const SOURCE_PREFIX_RE = /^(?:数据来源|来源|出处|测算口径|实验环境|统计口径|资料来源|Source|Sources|Note|Notes)\s*[::]/i
790
+
791
+ export function formatSourceLine(rawSource, langOrAttr = 'zh') {
792
+ const clean = String(rawSource ?? '').trim()
793
+ if (clean === '') return ''
794
+ if (SOURCE_PREFIX_RE.test(clean)) return clean
795
+ const isEn = langOrAttr === 'en' || langOrAttr === 'en-US'
796
+ return (isEn ? 'Source: ' : '数据来源:') + clean
797
+ }
798
+
799
+ export function computeBadgePillWidth(text, sizePt = 11, maxW = 2.8, minW = 0.54) {
800
+ const rawW = measureEmWidth(String(text ?? ''), true) * (sizePt / 72) * 1.24 + 0.38
801
+ return Math.min(Math.max(minW, maxW), Math.max(minW, +rawW.toFixed(4)))
802
+ }
803
+
804
+ export function getChromeConfig(chromeStyle, theme) {
805
+ const chrome = chromeStyle || resolveChromeStyle(theme)
806
+ if (chrome === 'consulting-classic') {
807
+ return {
808
+ chrome,
809
+ cardRadiusPx: 0,
810
+ cardBorderless: false,
811
+ cardStrokePt: 0.75,
812
+ cardTopBar: false,
813
+ cardLeftBar: true,
814
+ headerStyle: 'consulting-tracker',
815
+ bodyTopY: 1.80,
816
+ takeawayStyle: 'top-rule',
817
+ folioPos: 'bottom-right',
818
+ useDisplayNumeral: false,
819
+ }
820
+ }
821
+ if (chrome === 'keynote-spatial') {
822
+ return {
823
+ chrome,
824
+ cardRadiusPx: 21,
825
+ cardBorderless: true,
826
+ cardStrokePt: 0,
827
+ cardTopBar: false,
828
+ cardLeftBar: false,
829
+ headerStyle: 'keynote-clean',
830
+ bodyTopY: 1.76,
831
+ takeawayStyle: 'caption',
832
+ folioPos: 'bottom-right',
833
+ useDisplayNumeral: false,
834
+ }
835
+ }
836
+ if (chrome === 'editorial-folio') {
837
+ return {
838
+ chrome,
839
+ cardRadiusPx: 0,
840
+ cardBorderless: false,
841
+ cardStrokePt: 0.5,
842
+ cardTopBar: false,
843
+ cardLeftBar: false,
844
+ headerStyle: 'editorial-folio',
845
+ bodyTopY: 1.80,
846
+ takeawayStyle: 'editorial-rule',
847
+ folioPos: 'top-right',
848
+ useDisplayNumeral: true,
849
+ }
850
+ }
851
+ if (chrome === 'academic-minimal') {
852
+ return {
853
+ chrome,
854
+ cardRadiusPx: 8,
855
+ cardBorderless: false,
856
+ cardStrokePt: 0.75,
857
+ cardTopBar: false,
858
+ cardLeftBar: false,
859
+ headerStyle: 'beamer-band',
860
+ bodyTopY: 1.54,
861
+ takeawayStyle: 'top-rule',
862
+ folioPos: 'beamer-bar',
863
+ useDisplayNumeral: false,
864
+ }
865
+ }
866
+ if (chrome === 'gov-ceremonial') {
867
+ return {
868
+ chrome,
869
+ cardRadiusPx: 8,
870
+ cardBorderless: false,
871
+ cardStrokePt: 0.75,
872
+ cardTopBar: true,
873
+ cardLeftBar: false,
874
+ headerStyle: 'double-rule',
875
+ bodyTopY: 1.82,
876
+ takeawayStyle: 'pill',
877
+ folioPos: 'bottom-right',
878
+ useDisplayNumeral: false,
879
+ }
880
+ }
881
+ return {
882
+ chrome: 'saas-bento',
883
+ cardRadiusPx: Math.max(10, theme?.radiusPx ?? 13),
884
+ cardBorderless: false,
885
+ cardStrokePt: 0.75,
886
+ cardTopBar: true,
887
+ cardLeftBar: false,
888
+ headerStyle: 'standard',
889
+ bodyTopY: 1.82,
890
+ takeawayStyle: 'pill',
891
+ folioPos: 'bottom-right',
892
+ useDisplayNumeral: false,
893
+ }
894
+ }
895
+
896
+ function renderSurfaceCardPptx(name, box, opts, nextIdFn, chromeCfg, theme) {
897
+ const tk = theme.tokens
898
+ const {
899
+ fill = tk.surface1,
900
+ focal = false,
901
+ stroke,
902
+ accentBarColor = tk.accentPrimary,
903
+ paragraphs = [],
904
+ anchor = 't',
905
+ marginsIn = { l: 0.08, r: 0.08, t: 0.05, b: 0.05 },
906
+ fontScale = 100000,
907
+ txBox = false,
908
+ } = opts
909
+ const radius = chromeCfg.cardRadiusPx
910
+ const preset = radius > 0 ? 'roundRect' : 'rect'
911
+ const resolvedFill = chromeCfg.cardBorderless && focal && fill === tk.surface1 ? tk.surface2 : fill
912
+ const resolvedStroke = stroke !== undefined
913
+ ? stroke
914
+ : chromeCfg.cardBorderless
915
+ ? ''
916
+ : (focal ? tk.accentPrimary : tk.hairline)
917
+ const strokePt = focal ? 1.0 : chromeCfg.cardStrokePt
918
+ const out = [
919
+ ooxmlShape(nextIdFn(), name, box, {
920
+ preset,
921
+ adj: roundRectAdj(box.w, box.h, radius),
922
+ fill: resolvedFill,
923
+ stroke: resolvedStroke,
924
+ strokePt,
925
+ shadow: theme.shadow && !chromeCfg.cardBorderless,
926
+ txBox,
927
+ anchor,
928
+ marginsIn,
929
+ fontScale,
930
+ paragraphs,
931
+ }),
932
+ ]
933
+ if (chromeCfg.cardTopBar) {
934
+ out.push(ooxmlShape(nextIdFn(), name + ' top bar', { x: box.x, y: box.y, w: box.w, h: 0.05 }, {
935
+ preset: 'rect',
936
+ fill: focal ? accentBarColor : tk.hairline,
937
+ }))
938
+ }
939
+ if (chromeCfg.cardLeftBar) {
940
+ out.push(ooxmlShape(nextIdFn(), name + ' left stripe', { x: box.x, y: box.y, w: 0.04, h: box.h }, {
941
+ preset: 'rect',
942
+ fill: focal ? accentBarColor : tk.accentPrimary,
943
+ }))
944
+ }
945
+ return out.join('')
946
+ }
947
+
948
+ function formatGovKicker(kicker) {
949
+ const clean = String(kicker ?? '').trim()
950
+ if (!clean) return ''
951
+ return /^【/.test(clean) ? clean : '【' + clean + '】'
952
+ }
953
+
954
+ export function renderSlideChromePptx(slide, index, total, theme, langAttr, manifest = {}, nextIdFn) {
955
+ const tk = theme.tokens
956
+ const chromeStyle = resolveChromeStyle(theme, slide, manifest.brand)
957
+ const chromeCfg = getChromeConfig(chromeStyle, theme)
958
+ const idBase = (index + 1) * 10
959
+ const shapes = []
960
+ const isFraming = slide.layout === 'cover' || slide.layout === 'closing'
961
+ const hasTakeaway = !isFraming && typeof slide.takeaway === 'string' && slide.takeaway.trim() !== ''
962
+ const isEn = langAttr === 'en-US'
963
+
964
+ // Bottom Takeaway Bar (6 Chrome Skeleton differentiated treatment)
965
+ if (hasTakeaway) {
966
+ const barBox = { x: 0.62, y: 6.26, w: 12.09, h: 0.54 }
967
+ const text = slide.takeaway.trim()
968
+ if (chromeCfg.takeawayStyle === 'caption') {
969
+ shapes.push(ooxmlShape(nextIdFn(), 'Takeaway box', barBox, {
970
+ txBox: true,
971
+ anchor: 'ctr',
972
+ marginsIn: { l: 0.4, r: 0.4, t: 0.02, b: 0.02 },
973
+ paragraphs: [
974
+ ooxmlRichParagraph(text, {
975
+ sizePt: 13.5,
976
+ color: tk.inkSecondary,
977
+ secondaryColor: tk.inkMuted,
978
+ accentColor: tk.accentText,
979
+ bold: false,
980
+ lang: langAttr,
981
+ align: 'ctr',
982
+ font: theme.fonts.body,
983
+ lineHeight: 1.2,
984
+ }),
985
+ ],
986
+ }))
987
+ } else if (chromeCfg.takeawayStyle === 'top-rule' || chromeCfg.takeawayStyle === 'editorial-rule') {
988
+ const prefix = chromeCfg.takeawayStyle === 'editorial-rule'
989
+ ? '**—** '
990
+ : (isEn ? '**Key Takeaway:** ' : '**核心结论:**')
991
+ shapes.push(ooxmlLine(nextIdFn(), 'Takeaway rule', { x: 0.62, y: 6.22 }, { x: 12.71, y: 6.22 }, {
992
+ color: chromeCfg.takeawayStyle === 'editorial-rule' ? tk.hairline : tk.accentPrimary,
993
+ widthPt: chromeCfg.takeawayStyle === 'editorial-rule' ? 0.75 : 1.0,
994
+ }))
995
+ shapes.push(ooxmlShape(nextIdFn(), 'Takeaway box', { x: 0.62, y: 6.28, w: 12.09, h: 0.50 }, {
996
+ txBox: true,
997
+ anchor: 'ctr',
998
+ marginsIn: { l: 0, r: 0, t: 0.02, b: 0.02 },
999
+ paragraphs: [
1000
+ ooxmlRichParagraph(prefix + text, {
1001
+ sizePt: 13.5,
1002
+ color: tk.inkPrimary,
1003
+ secondaryColor: tk.inkSecondary,
1004
+ accentColor: tk.accentText,
1005
+ bold: false,
1006
+ lang: langAttr,
1007
+ font: theme.fonts.body,
1008
+ lineHeight: 1.22,
1009
+ }),
1010
+ ],
1011
+ }))
1012
+ } else {
1013
+ const preset = chromeCfg.cardRadiusPx > 0 ? 'roundRect' : 'rect'
1014
+ shapes.push(ooxmlShape(nextIdFn(), 'Takeaway box', barBox, {
1015
+ preset,
1016
+ adj: roundRectAdj(barBox.w, barBox.h, Math.min(8, chromeCfg.cardRadiusPx)),
1017
+ fill: tk.accentSoft,
1018
+ stroke: tk.hairline,
1019
+ strokePt: 0.75,
1020
+ anchor: 'ctr',
1021
+ marginsIn: { l: 0.22, r: 0.16, t: 0.04, b: 0.04 },
1022
+ paragraphs: [
1023
+ ooxmlRichParagraph('▸ ' + text, {
1024
+ sizePt: 13.5,
1025
+ color: tk.inkPrimary,
1026
+ secondaryColor: tk.inkSecondary,
1027
+ accentColor: tk.accentText,
1028
+ bold: true,
1029
+ lang: langAttr,
1030
+ font: theme.fonts.body,
1031
+ lineHeight: 1.2,
1032
+ }),
1033
+ ],
1034
+ }))
1035
+ shapes.push(ooxmlShape(nextIdFn(), 'Takeaway accent', { x: 0.62, y: 6.26, w: 0.06, h: 0.54 }, {
1036
+ preset: 'rect',
1037
+ fill: tk.accentPrimary,
1038
+ }))
1039
+ }
1040
+ }
1041
+
1042
+ // Footer source + page folio (suppressed on cover & closing)
1043
+ if (!isFraming) {
1044
+ const folio = String(index + 1).padStart(2, '0') + ' / ' + String(total).padStart(2, '0')
1045
+ if (chromeCfg.folioPos === 'beamer-bar') {
1046
+ // 3-zone Beamer academic status bar at bottom edge
1047
+ shapes.push(ooxmlShape(nextIdFn(), 'Beamer footer band', { x: 0, y: 7.04, w: CANVAS_IN.w, h: 0.46 }, {
1048
+ preset: 'rect',
1049
+ fill: tk.surface1,
1050
+ }))
1051
+ shapes.push(ooxmlLine(nextIdFn(), 'Beamer footer rule', { x: 0, y: 7.04 }, { x: CANVAS_IN.w, y: 7.04 }, {
1052
+ color: tk.hairline,
1053
+ widthPt: 0.5,
1054
+ }))
1055
+ const leftText = slide.source
1056
+ ? formatSourceLine(slide.source, langAttr)
1057
+ : (manifest.brand?.footer || manifest.title || '')
1058
+ if (leftText) {
1059
+ shapes.push(ooxmlShape(nextIdFn(), slide.source ? 'Footer source' : 'Beamer zone left', { x: 0.62, y: 7.10, w: 4.4, h: 0.32 }, {
1060
+ txBox: true,
1061
+ anchor: 'ctr',
1062
+ marginsIn: { l: 0, r: 0, t: 0, b: 0 },
1063
+ paragraphs: [
1064
+ ooxmlRichParagraph(leftText, {
1065
+ sizePt: 9.5,
1066
+ color: tk.inkMuted,
1067
+ lang: langAttr,
1068
+ align: 'l',
1069
+ font: theme.fonts.body,
1070
+ lineHeight: 1.15,
1071
+ }),
1072
+ ],
1073
+ }))
1074
+ }
1075
+ const centerText = (slide.kicker || slide.title || '').trim()
1076
+ if (centerText) {
1077
+ shapes.push(ooxmlShape(nextIdFn(), 'Beamer zone chapter', { x: 5.1, y: 7.10, w: 3.13, h: 0.32 }, {
1078
+ txBox: true,
1079
+ anchor: 'ctr',
1080
+ marginsIn: { l: 0, r: 0, t: 0, b: 0 },
1081
+ paragraphs: [
1082
+ ooxmlRichParagraph(centerText, {
1083
+ sizePt: 9.5,
1084
+ color: tk.inkSecondary,
1085
+ bold: true,
1086
+ lang: langAttr,
1087
+ align: 'ctr',
1088
+ font: theme.fonts.body,
1089
+ lineHeight: 1.15,
1090
+ }),
1091
+ ],
1092
+ }))
1093
+ }
1094
+ shapes.push(ooxmlShape(idBase + 9, 'Page number', { x: 10.65, y: 7.10, w: 2.06, h: 0.32 }, {
1095
+ txBox: true,
1096
+ anchor: 'ctr',
1097
+ marginsIn: { l: 0, r: 0, t: 0, b: 0 },
1098
+ paragraphs: [
1099
+ ooxmlRichParagraph(folio, {
1100
+ sizePt: 9.5,
1101
+ color: tk.accentText,
1102
+ bold: true,
1103
+ lang: langAttr,
1104
+ align: 'r',
1105
+ font: theme.fonts.body,
1106
+ lineHeight: 1.15,
1107
+ }),
1108
+ ],
1109
+ }))
1110
+ } else {
1111
+ if (slide.source) {
1112
+ const hasBrandFooter = Boolean(manifest.brand?.footer)
1113
+ const sourceBox = hasBrandFooter
1114
+ ? { x: 5.4, y: 6.95, w: 5.0, h: 0.32 }
1115
+ : { x: 0.62, y: 6.95, w: 9.2, h: 0.32 }
1116
+ shapes.push(ooxmlShape(nextIdFn(), 'Footer source', sourceBox, {
1117
+ txBox: true,
1118
+ anchor: 'ctr',
1119
+ marginsIn: { l: 0, r: 0, t: 0, b: 0 },
1120
+ paragraphs: [
1121
+ ooxmlRichParagraph(formatSourceLine(slide.source, langAttr), {
1122
+ sizePt: 9.5,
1123
+ color: tk.inkMuted,
1124
+ lang: langAttr,
1125
+ align: hasBrandFooter ? 'r' : 'l',
1126
+ font: theme.fonts.body,
1127
+ lineHeight: 1.15,
1128
+ }),
1129
+ ],
1130
+ }))
1131
+ }
1132
+
1133
+ const folioBox = chromeCfg.folioPos === 'top-right'
1134
+ ? { x: 10.65, y: 0.24, w: 2.06, h: 0.28 }
1135
+ : { x: 10.65, y: 6.95, w: 2.06, h: 0.32 }
1136
+ shapes.push(ooxmlShape(idBase + 9, 'Page number', folioBox, {
1137
+ txBox: true,
1138
+ anchor: 'ctr',
1139
+ marginsIn: { l: 0, r: 0, t: 0, b: 0 },
1140
+ paragraphs: [
1141
+ ooxmlRichParagraph(folio, {
1142
+ sizePt: chromeCfg.folioPos === 'top-right' ? 10 : 9.5,
1143
+ color: tk.inkMuted,
1144
+ lang: langAttr,
1145
+ align: 'r',
1146
+ font: theme.fonts.body,
1147
+ lineHeight: 1.15,
1148
+ }),
1149
+ ],
1150
+ }))
1151
+ }
1152
+ }
1153
+
1154
+ return shapes.join('')
1155
+ }
1156
+
1157
+ function renderStandardHeaderPptx(slide, idBase, nextIdFn, theme, langAttr, chromeCfg) {
1158
+ const tk = theme.tokens
1159
+ const kicker = (slide.kicker ?? '').trim()
1160
+ const title = (slide.title ?? '').trim()
1161
+ const showKicker = kicker !== '' && kicker !== title
1162
+ const shapes = []
1163
+ const style = chromeCfg?.headerStyle || 'standard'
1164
+
1165
+ if (style === 'beamer-band') {
1166
+ // Beamer Metropolis full-width tinted header band + 1.5pt accent bottom rule
1167
+ shapes.push(ooxmlShape(nextIdFn(), 'Beamer header band', { x: 0, y: 0, w: CANVAS_IN.w, h: 1.28 }, {
1168
+ preset: 'rect',
1169
+ fill: tk.surface1,
1170
+ }))
1171
+ shapes.push(ooxmlLine(nextIdFn(), 'Beamer header rule', { x: 0, y: 1.28 }, { x: CANVAS_IN.w, y: 1.28 }, {
1172
+ color: tk.accentPrimary,
1173
+ widthPt: 1.5,
1174
+ }))
1175
+ if (showKicker) {
1176
+ shapes.push(ooxmlShape(idBase + 1, 'Kicker', { x: 0.62, y: 0.14, w: 12.09, h: 0.24 }, {
1177
+ txBox: true,
1178
+ anchor: 'ctr',
1179
+ marginsIn: { l: 0, r: 0, t: 0, b: 0 },
1180
+ paragraphs: [
1181
+ ooxmlRichParagraph(kicker.toUpperCase(), {
1182
+ sizePt: 10,
1183
+ color: tk.accentText,
1184
+ bold: true,
1185
+ lang: langAttr,
1186
+ font: theme.fonts.body,
1187
+ lineHeight: 1.1,
1188
+ spc: 140,
1189
+ }),
1190
+ ],
1191
+ }))
1192
+ }
1193
+ if (title !== '') {
1194
+ const titleBox = { x: 0.62, y: showKicker ? 0.40 : 0.24, w: 12.09, h: 0.78 }
1195
+ const fit = computeTextFit(title, titleBox, 'slideTitle', { maxPt: 25, minPt: 20, padXPt: 2, padYPt: 2 })
1196
+ shapes.push(ooxmlShape(idBase + 2, 'Title', titleBox, {
1197
+ txBox: true,
1198
+ anchor: 'ctr',
1199
+ marginsIn: { l: 0, r: 0, t: 0, b: 0 },
1200
+ fontScale: fit.fontScale,
1201
+ paragraphs: [
1202
+ ooxmlRichParagraph(title, {
1203
+ sizePt: fit.fontPt,
1204
+ color: tk.inkPrimary,
1205
+ bold: true,
1206
+ lang: langAttr,
1207
+ font: theme.fonts.heading,
1208
+ lineHeight: fit.lineHeight,
1209
+ }),
1210
+ ],
1211
+ }))
1212
+ }
1213
+ return shapes.join('')
1214
+ }
1215
+
1216
+ if (style === 'editorial-folio') {
1217
+ // Full-width top 0.5pt magazine running folio bar (Kicker left, Page number top-right handled in chrome)
1218
+ if (showKicker) {
1219
+ shapes.push(ooxmlShape(idBase + 1, 'Kicker', { x: 0.62, y: 0.24, w: 8.8, h: 0.28 }, {
1220
+ txBox: true,
1221
+ anchor: 'ctr',
1222
+ marginsIn: { l: 0, r: 0, t: 0, b: 0 },
1223
+ paragraphs: [
1224
+ ooxmlRichParagraph(kicker.toUpperCase(), {
1225
+ sizePt: 10,
1226
+ color: tk.accentText,
1227
+ bold: true,
1228
+ lang: langAttr,
1229
+ font: theme.fonts.body,
1230
+ lineHeight: 1.1,
1231
+ spc: 180,
1232
+ }),
1233
+ ],
1234
+ }))
1235
+ }
1236
+ shapes.push(ooxmlLine(nextIdFn(), 'Editorial folio rule', { x: 0.62, y: 0.56 }, { x: 12.71, y: 0.56 }, {
1237
+ color: tk.hairline,
1238
+ widthPt: 0.5,
1239
+ }))
1240
+ if (title !== '') {
1241
+ const titleBox = { x: 0.62, y: 0.70, w: 12.09, h: 0.86 }
1242
+ const fit = computeTextFit(title, titleBox, 'slideTitle', { padXPt: 2, padYPt: 2 })
1243
+ shapes.push(ooxmlShape(idBase + 2, 'Title', titleBox, {
1244
+ txBox: true,
1245
+ anchor: 'ctr',
1246
+ marginsIn: { l: 0, r: 0, t: 0, b: 0 },
1247
+ fontScale: fit.fontScale,
1248
+ paragraphs: [
1249
+ ooxmlRichParagraph(title, {
1250
+ sizePt: fit.fontPt,
1251
+ color: tk.inkPrimary,
1252
+ bold: true,
1253
+ lang: langAttr,
1254
+ font: theme.fonts.heading,
1255
+ lineHeight: fit.lineHeight,
1256
+ }),
1257
+ ],
1258
+ }))
1259
+ }
1260
+ shapes.push(ooxmlLine(nextIdFn(), 'Header rule', { x: 0.62, y: 1.64 }, { x: 12.71, y: 1.64 }, {
1261
+ color: tk.hairline,
1262
+ widthPt: 0.5,
1263
+ }))
1264
+ return shapes.join('')
1265
+ }
1266
+
1267
+ if (style === 'keynote-clean') {
1268
+ // Floating eyebrow pill + NO top horizontal divider rule
1269
+ if (showKicker) {
1270
+ const pillW = computeBadgePillWidth(kicker.toUpperCase(), 10, 4.2, 1.05)
1271
+ shapes.push(ooxmlShape(idBase + 1, 'Kicker', { x: 0.62, y: 0.38, w: pillW, h: 0.30 }, {
1272
+ preset: 'roundRect',
1273
+ adj: 50000,
1274
+ fill: tk.accentSoft,
1275
+ anchor: 'ctr',
1276
+ marginsIn: { l: 0.08, r: 0.08, t: 0.02, b: 0.02 },
1277
+ paragraphs: [
1278
+ ooxmlRichParagraph(kicker.toUpperCase(), {
1279
+ sizePt: 10,
1280
+ color: tk.accentText,
1281
+ bold: true,
1282
+ lang: langAttr,
1283
+ align: 'ctr',
1284
+ font: theme.fonts.body,
1285
+ lineHeight: 1.1,
1286
+ spc: 100,
1287
+ }),
1288
+ ],
1289
+ }))
1290
+ }
1291
+ if (title !== '') {
1292
+ const titleBox = { x: 0.62, y: showKicker ? 0.76 : 0.48, w: 12.09, h: 0.88 }
1293
+ const fit = computeTextFit(title, titleBox, 'slideTitle', { padXPt: 2, padYPt: 2 })
1294
+ shapes.push(ooxmlShape(idBase + 2, 'Title', titleBox, {
1295
+ txBox: true,
1296
+ anchor: 'ctr',
1297
+ marginsIn: { l: 0, r: 0, t: 0, b: 0 },
1298
+ fontScale: fit.fontScale,
1299
+ paragraphs: [
1300
+ ooxmlRichParagraph(title, {
1301
+ sizePt: fit.fontPt,
1302
+ color: tk.inkPrimary,
1303
+ bold: true,
1304
+ lang: langAttr,
1305
+ font: theme.fonts.heading,
1306
+ lineHeight: fit.lineHeight,
1307
+ }),
1308
+ ],
1309
+ }))
1310
+ }
1311
+ return shapes.join('')
1312
+ }
1313
+
1314
+ if (style === 'consulting-tracker') {
1315
+ // Top-right section tracker pill + left-aligned title + crisp 0.75pt header rule
1316
+ let trackerW = 0
1317
+ if (showKicker) {
1318
+ trackerW = computeBadgePillWidth(kicker.toUpperCase(), 10, 3.6, 1.15)
1319
+ shapes.push(ooxmlShape(idBase + 1, 'Kicker', { x: 12.71 - trackerW, y: 0.44, w: trackerW, h: 0.32 }, {
1320
+ preset: 'rect',
1321
+ fill: tk.accentSoft,
1322
+ stroke: tk.accentPrimary,
1323
+ strokePt: 0.75,
1324
+ anchor: 'ctr',
1325
+ marginsIn: { l: 0.08, r: 0.08, t: 0.02, b: 0.02 },
1326
+ paragraphs: [
1327
+ ooxmlRichParagraph(kicker.toUpperCase(), {
1328
+ sizePt: 10,
1329
+ color: tk.accentText,
1330
+ bold: true,
1331
+ lang: langAttr,
1332
+ align: 'ctr',
1333
+ font: theme.fonts.body,
1334
+ lineHeight: 1.1,
1335
+ spc: 80,
1336
+ }),
1337
+ ],
1338
+ }))
1339
+ }
1340
+ if (title !== '') {
1341
+ const titleW = trackerW > 0 ? 12.09 - trackerW - 0.30 : 12.09
1342
+ const titleBox = { x: 0.62, y: 0.44, w: titleW, h: 1.06 }
1343
+ const fit = computeTextFit(title, titleBox, 'slideTitle', { padXPt: 2, padYPt: 2 })
1344
+ shapes.push(ooxmlShape(idBase + 2, 'Title', titleBox, {
1345
+ txBox: true,
1346
+ anchor: 'ctr',
1347
+ marginsIn: { l: 0, r: 0, t: 0, b: 0 },
1348
+ fontScale: fit.fontScale,
1349
+ paragraphs: [
1350
+ ooxmlRichParagraph(title, {
1351
+ sizePt: fit.fontPt,
1352
+ color: tk.inkPrimary,
1353
+ bold: true,
1354
+ lang: langAttr,
1355
+ font: theme.fonts.heading,
1356
+ lineHeight: fit.lineHeight,
1357
+ }),
1358
+ ],
1359
+ }))
1360
+ }
1361
+ shapes.push(ooxmlLine(nextIdFn(), 'Header rule', { x: 0.62, y: 1.64 }, { x: 12.71, y: 1.64 }, {
1362
+ color: tk.hairline,
1363
+ widthPt: 0.75,
1364
+ }))
1365
+ return shapes.join('')
1366
+ }
1367
+
1368
+ if (style === 'double-rule') {
1369
+ // Dignified gov-ceremonial header: 【kicker】 ribbon tag + 1.5pt primary rule + 0.5pt gold/secondary rule
1370
+ if (showKicker) {
1371
+ shapes.push(ooxmlShape(idBase + 1, 'Kicker', { x: 0.62, y: 0.36, w: 11.4, h: 0.30 }, {
1372
+ txBox: true,
1373
+ anchor: 'ctr',
1374
+ marginsIn: { l: 0, r: 0, t: 0, b: 0 },
1375
+ paragraphs: [
1376
+ ooxmlRichParagraph(formatGovKicker(kicker), {
1377
+ sizePt: 11.5,
1378
+ color: tk.accentText,
1379
+ bold: true,
1380
+ lang: langAttr,
1381
+ font: theme.fonts.body,
1382
+ lineHeight: 1.1,
1383
+ spc: 80,
1384
+ }),
1385
+ ],
1386
+ }))
1387
+ }
1388
+ if (title !== '') {
1389
+ const titleBox = { x: 0.62, y: showKicker ? 0.68 : 0.48, w: 12.09, h: 0.84 }
1390
+ const fit = computeTextFit(title, titleBox, 'slideTitle', { padXPt: 2, padYPt: 2 })
1391
+ shapes.push(ooxmlShape(idBase + 2, 'Title', titleBox, {
1392
+ txBox: true,
1393
+ anchor: 'ctr',
1394
+ marginsIn: { l: 0, r: 0, t: 0, b: 0 },
1395
+ fontScale: fit.fontScale,
1396
+ paragraphs: [
1397
+ ooxmlRichParagraph(title, {
1398
+ sizePt: fit.fontPt,
1399
+ color: tk.inkPrimary,
1400
+ bold: true,
1401
+ lang: langAttr,
1402
+ font: theme.fonts.heading,
1403
+ lineHeight: fit.lineHeight,
1404
+ }),
1405
+ ],
1406
+ }))
1407
+ }
1408
+ shapes.push(ooxmlLine(nextIdFn(), 'Header rule', { x: 0.62, y: 1.60 }, { x: 12.71, y: 1.60 }, {
1409
+ color: tk.accentPrimary,
1410
+ widthPt: 1.5,
1411
+ }))
1412
+ shapes.push(ooxmlLine(nextIdFn(), 'Header secondary rule', { x: 0.62, y: 1.67 }, { x: 12.71, y: 1.67 }, {
1413
+ color: tk.accentSecondary,
1414
+ widthPt: 0.5,
1415
+ }))
1416
+ return shapes.join('')
1417
+ }
1418
+
1419
+ // standard ('saas-bento')
1420
+ if (showKicker) {
1421
+ shapes.push(ooxmlShape(idBase + 1, 'Kicker', { x: 0.62, y: 0.42, w: 11.4, h: 0.28 }, {
1422
+ txBox: true,
1423
+ anchor: 'ctr',
1424
+ marginsIn: { l: 0, r: 0, t: 0, b: 0 },
1425
+ paragraphs: [
1426
+ ooxmlRichParagraph(kicker.toUpperCase(), {
1427
+ sizePt: 11,
1428
+ color: tk.accentText,
1429
+ bold: true,
1430
+ lang: langAttr,
1431
+ font: theme.fonts.body,
1432
+ lineHeight: 1.1,
1433
+ spc: 140,
1434
+ }),
1435
+ ],
1436
+ }))
1437
+ }
1438
+
1439
+ if (title !== '') {
1440
+ const titleBox = { x: 0.62, y: showKicker ? 0.72 : 0.52, w: 12.09, h: 0.86 }
1441
+ const fit = computeTextFit(title, titleBox, 'slideTitle', { padXPt: 2, padYPt: 2 })
1442
+ shapes.push(ooxmlShape(idBase + 2, 'Title', titleBox, {
1443
+ txBox: true,
1444
+ anchor: 'ctr',
1445
+ marginsIn: { l: 0, r: 0, t: 0, b: 0 },
1446
+ fontScale: fit.fontScale,
1447
+ paragraphs: [
1448
+ ooxmlRichParagraph(title, {
1449
+ sizePt: fit.fontPt,
1450
+ color: tk.inkPrimary,
1451
+ bold: true,
1452
+ lang: langAttr,
1453
+ font: theme.fonts.heading,
1454
+ lineHeight: fit.lineHeight,
1455
+ }),
1456
+ ],
1457
+ }))
1458
+ }
1459
+
1460
+ shapes.push(ooxmlLine(nextIdFn(), 'Header rule', { x: 0.62, y: 1.66 }, { x: 12.71, y: 1.66 }, {
1461
+ color: tk.hairline,
1462
+ widthPt: 0.75,
1463
+ }))
1464
+
1465
+ return shapes.join('')
1466
+ }
1467
+
1468
+ // ---------------------------------------------------------------------------
1469
+ // 19 套零依赖核心原生版式(含 5 套专业图示)OOXML 编译器
1470
+ // ---------------------------------------------------------------------------
1471
+
1472
+ export function parseHarveyValue(rawCell) {
1473
+ const clean = stripInlineMarkdown(String(rawCell ?? '')).trim()
1474
+ const lower = clean.toLowerCase()
1475
+ if (lower === 'full' || lower === '100%' || clean === '●') return { kind: 'harvey', pct: 100, label: '100%' }
1476
+ if (lower === '75%' || clean === '◕') return { kind: 'harvey', pct: 75, label: '75%' }
1477
+ if (lower === '50%' || lower === 'half' || clean === '◑') return { kind: 'harvey', pct: 50, label: '50%' }
1478
+ if (lower === '25%' || clean === '◔') return { kind: 'harvey', pct: 25, label: '25%' }
1479
+ if (lower === '0%' || lower === 'none' || clean === '○') return { kind: 'harvey', pct: 0, label: '0%' }
1480
+ if (lower === 'yes' || clean === '✓') return { kind: 'check', ok: true, label: '✓' }
1481
+ if (lower === 'no' || clean === '✗') return { kind: 'check', ok: false, label: '✗' }
1482
+ return null
1483
+ }
1484
+
1485
+ function findHarveyOursCol(headerRow, cols) {
1486
+ const hit = headerRow.findIndex((h) => /ours|本方案|我们|dsh|推荐|self|\bour\b/i.test(stripInlineMarkdown(h)))
1487
+ if (hit >= 0) return hit
1488
+ return cols >= 3 ? cols - 1 : -1
1489
+ }
1490
+
1491
+ function renderHarveyBallPptx(parsed, cx, cy, sizeIn, isOurs, nextIdFn, theme, langAttr) {
1492
+ const tk = theme.tokens
1493
+ const x = cx - sizeIn / 2
1494
+ const y = cy - sizeIn / 2
1495
+ const fillCol = isOurs ? tk.accentPrimary : tk.inkPrimary
1496
+ const ringCol = isOurs ? tk.accentPrimary : tk.inkMuted
1497
+ const bgCol = isOurs ? tk.accentSoft : tk.canvas
1498
+ const shapes = []
1499
+
1500
+ if (parsed.kind === 'check') {
1501
+ const badgeFill = parsed.ok ? (isOurs ? tk.accentPrimary : tk.positive) : tk.surface2
1502
+ const badgeFg = parsed.ok ? '#FFFFFF' : tk.inkMuted
1503
+ shapes.push(ooxmlShape(nextIdFn(), 'Harvey Check', { x, y, w: sizeIn, h: sizeIn }, {
1504
+ preset: 'ellipse',
1505
+ fill: badgeFill,
1506
+ stroke: parsed.ok ? '' : tk.hairline,
1507
+ strokePt: 0.75,
1508
+ anchor: 'ctr',
1509
+ marginsIn: { l: 0, r: 0, t: 0, b: 0 },
1510
+ paragraphs: [
1511
+ ooxmlRichParagraph(parsed.ok ? '✓' : '✗', {
1512
+ sizePt: 11.5,
1513
+ color: badgeFg,
1514
+ bold: true,
1515
+ lang: langAttr,
1516
+ align: 'ctr',
1517
+ font: theme.fonts.body,
1518
+ lineHeight: 1.0,
1519
+ }),
1520
+ ],
1521
+ }))
1522
+ return shapes.join('')
1523
+ }
1524
+
1525
+ if (parsed.pct === 100) {
1526
+ shapes.push(ooxmlShape(nextIdFn(), 'Harvey 100', { x, y, w: sizeIn, h: sizeIn }, {
1527
+ preset: 'ellipse',
1528
+ fill: fillCol,
1529
+ stroke: fillCol,
1530
+ strokePt: 1.0,
1531
+ }))
1532
+ return shapes.join('')
1533
+ }
1534
+
1535
+ // Base empty ring
1536
+ shapes.push(ooxmlShape(nextIdFn(), 'Harvey Ring', { x, y, w: sizeIn, h: sizeIn }, {
1537
+ preset: 'ellipse',
1538
+ fill: bgCol,
1539
+ stroke: parsed.pct === 0 ? ringCol : fillCol,
1540
+ strokePt: 1.25,
1541
+ }))
1542
+
1543
+ if (parsed.pct > 0) {
1544
+ // 25%: 12 o'clock (270deg) to 3 o'clock (360deg); 50%: 12 to 6 (90deg); 75%: 12 to 9 (180deg)
1545
+ const startAng = 16200000
1546
+ const endAng = parsed.pct === 25 ? 21600000 : parsed.pct === 50 ? 5400000 : 10800000
1547
+ shapes.push(ooxmlShape(nextIdFn(), 'Harvey Slice', { x, y, w: sizeIn, h: sizeIn }, {
1548
+ preset: 'pie',
1549
+ adjs: { adj1: startAng, adj2: endAng },
1550
+ fill: fillCol,
1551
+ stroke: '',
1552
+ }))
1553
+ }
1554
+
1555
+ return shapes.join('')
1556
+ }
1557
+
1558
+ function renderHarveyMatrixPptx(slide, area, nextIdFn, chromeCfg, theme, langAttr) {
1559
+ const tk = theme.tokens
1560
+ const items = resolveEffectiveItems(slide)
1561
+ const rawRows = Array.isArray(slide.rows) && slide.rows.length > 0
1562
+ ? slide.rows
1563
+ : items.length > 0
1564
+ ? [['评估维度', '行业基线', '本方案 / Ours'], ...items.map((it) => [it.title || '', it.delta || '50%', it.value || (it.status === 'positive' ? 'full' : 'full')])]
1565
+ : [['维度', '本方案 / Ours'], ['能力项', 'full']]
1566
+ const safeRows = rawRows.slice(0, 9)
1567
+ const cols = Math.max(2, ...safeRows.map((r) => r.length))
1568
+ const headerRow = Array.from({ length: cols }, (_, c) => String(safeRows[0]?.[c] ?? ''))
1569
+ const oursCol = findHarveyOursCol(headerRow, cols)
1570
+
1571
+ // Compute proportional column widths (first col wider for criteria label)
1572
+ const firstColW = Math.min(4.6, Math.max(2.8, area.w * (cols <= 3 ? 0.44 : 0.34)))
1573
+ const otherW = (area.w - firstColW) / Math.max(1, cols - 1)
1574
+ const colXs = []
1575
+ const colWs = []
1576
+ let cursorX = area.x
1577
+ for (let c = 0; c < cols; c += 1) {
1578
+ const w = c === 0 ? firstColW : otherW
1579
+ colXs.push(cursorX)
1580
+ colWs.push(w)
1581
+ cursorX += w
1582
+ }
1583
+
1584
+ const rowCount = safeRows.length
1585
+ const rowH = Math.min(0.62, Math.max(0.40, area.h / Math.max(1, rowCount)))
1586
+ const startY = area.y + Math.max(0, (area.h - rowH * rowCount) / 2)
1587
+ const shapes = []
1588
+ const cellPreset = chromeCfg.cardRadiusPx > 0 ? 'roundRect' : 'rect'
1589
+
1590
+ safeRows.forEach((row, rIdx) => {
1591
+ const isHeader = rIdx === 0
1592
+ const y = startY + rIdx * rowH
1593
+ for (let c = 0; c < cols; c += 1) {
1594
+ const cellText = String(row[c] ?? '')
1595
+ const isOurs = c === oursCol
1596
+ const x = colXs[c]
1597
+ const w = colWs[c]
1598
+ const cellFill = isHeader
1599
+ ? (isOurs ? tk.accentPrimary : tk.surface2)
1600
+ : (isOurs ? tk.accentSoft : (rIdx % 2 === 0 ? tk.surface1 : tk.canvas))
1601
+
1602
+ shapes.push(ooxmlShape(nextIdFn(), 'Harvey Cell ' + rIdx + '-' + c, { x, y, w, h: rowH }, {
1603
+ preset: isHeader && c === 0 ? cellPreset : 'rect',
1604
+ adj: 0,
1605
+ fill: cellFill,
1606
+ stroke: isOurs ? tk.accentPrimary : tk.hairline,
1607
+ strokePt: isOurs ? 0.75 : 0.5,
1608
+ }))
1609
+
1610
+ const parsed = !isHeader && c > 0 ? parseHarveyValue(cellText) : null
1611
+ if (parsed) {
1612
+ const ballSize = Math.min(0.28, rowH * 0.56)
1613
+ shapes.push(renderHarveyBallPptx(parsed, x + w / 2, y + rowH / 2, ballSize, isOurs, nextIdFn, theme, langAttr))
1614
+ } else {
1615
+ shapes.push(ooxmlShape(nextIdFn(), 'Harvey Text ' + rIdx + '-' + c, { x: x + 0.08, y: y + 0.03, w: w - 0.16, h: rowH - 0.06 }, {
1616
+ txBox: true,
1617
+ anchor: 'ctr',
1618
+ marginsIn: { l: 0.04, r: 0.04, t: 0.01, b: 0.01 },
1619
+ paragraphs: [
1620
+ ooxmlRichParagraph(cellText, {
1621
+ sizePt: isHeader ? 13.5 : (cols >= 6 ? 12 : 13.5),
1622
+ color: isHeader && isOurs ? tk.inkOnAccent : (isOurs ? tk.accentText : tk.inkPrimary),
1623
+ bold: isHeader || isOurs,
1624
+ lang: langAttr,
1625
+ align: c === 0 ? 'l' : 'ctr',
1626
+ font: isHeader ? theme.fonts.heading : theme.fonts.body,
1627
+ lineHeight: 1.18,
1628
+ }),
1629
+ ],
1630
+ }))
1631
+ }
1632
+ }
1633
+ })
1634
+
1635
+ return shapes.join('')
1636
+ }
1637
+
1638
+ function monogramLetters(name) {
1639
+ const clean = stripInlineMarkdown(String(name ?? ''))
1640
+ .replace(/\s*(?:博士|教授|先生|女士|院士|院长|主任|总|Ph\.?D\.?|M\.?D\.?|MBA).*$/i, '')
1641
+ .trim()
1642
+ if (!clean) return 'T'
1643
+ if (/[\u4E00-\u9FFF]/.test(clean)) {
1644
+ return clean.replace(/\s+/g, '').slice(0, 1)
1645
+ }
1646
+ const parts = clean.split(/\s+/).filter(Boolean)
1647
+ return parts.length >= 2
1648
+ ? (parts[0][0] + parts[1][0]).toUpperCase()
1649
+ : clean.slice(0, 2).toUpperCase()
1650
+ }
1651
+
1652
+ export function renderCoreSlidePptx(slide, index, total, theme, langAttr, manifest = {}) {
1653
+ const tk = theme.tokens
1654
+ const chromeStyle = resolveChromeStyle(theme, slide, manifest.brand)
1655
+ const chromeCfg = getChromeConfig(chromeStyle, theme)
1656
+ const idBase = (index + 1) * 10
1657
+ let dynCounter = (index + 1) * 100 + 10
1658
+ const nextId = () => { dynCounter += 1; return dynCounter }
1659
+
1660
+ const layout = slide.layout || 'bullets'
1661
+ const variant = slide.variant || ''
1662
+ const title = slide.title || ''
1663
+ const subtitle = slide.subtitle || ''
1664
+ const kicker = slide.kicker || ''
1665
+ const bullets = Array.isArray(slide.bullets) ? slide.bullets : []
1666
+ const hasTakeaway = typeof slide.takeaway === 'string' && slide.takeaway.trim() !== ''
1667
+ const bodyBottomY = hasTakeaway ? 6.08 : 6.72
1668
+ const bodyTopY = chromeCfg.bodyTopY
1669
+ const bodyH = bodyBottomY - bodyTopY
1670
+ const cardPreset = chromeCfg.cardRadiusPx > 0 ? 'roundRect' : 'rect'
1671
+
1672
+ const shapes = []
1673
+
1674
+ if (layout === 'cover') {
1675
+ const inverted = variant === 'inverted' || (!variant && tk.coverMode === 'inverted-accent')
1676
+ const coverFill = inverted ? tk.coverBg : tk.canvas
1677
+ const coverDark = relativeLuminance(coverFill) < 0.36
1678
+ const fg = inverted ? (coverDark ? '#F8FAFC' : '#0F172A') : tk.inkPrimary
1679
+ const subColor = inverted ? (coverDark ? '#E2E8F0' : '#334155') : tk.inkSecondary
1680
+ const accentRule = inverted ? (theme.id === 'exec-jilan' || theme.id === 'exec-palace' ? '#D4AF37' : tk.accentSecondary) : tk.accentPrimary
1681
+ const kickerColor = inverted ? accentRule : tk.accentText
1682
+
1683
+ if (inverted) {
1684
+ shapes.push(ooxmlShape(nextId(), 'Cover backdrop', { x: 0, y: 0, w: CANVAS_IN.w, h: CANVAS_IN.h }, {
1685
+ preset: 'rect',
1686
+ fill: coverFill,
1687
+ }))
1688
+ } else if (variant === 'monolith') {
1689
+ shapes.push(ooxmlShape(nextId(), 'Cover monolith band', { x: 0, y: 0, w: 0.42, h: CANVAS_IN.h }, {
1690
+ preset: 'rect',
1691
+ fill: tk.accentPrimary,
1692
+ }))
1693
+ } else {
1694
+ // 精致顶栏结构线与右侧微弱几何装饰块
1695
+ shapes.push(ooxmlShape(nextId(), 'Cover top accent', { x: 0, y: 0, w: CANVAS_IN.w, h: 0.08 }, {
1696
+ preset: 'rect',
1697
+ fill: tk.accentPrimary,
1698
+ }))
1699
+ shapes.push(ooxmlShape(nextId(), 'Cover architectural panel', { x: 9.65, y: 0.08, w: 3.6833, h: 7.42 }, {
1700
+ preset: 'rect',
1701
+ fill: tk.surface1,
1702
+ }))
1703
+ shapes.push(ooxmlLine(nextId(), 'Cover vertical hairline', { x: 9.65, y: 0.08 }, { x: 9.65, y: 7.5 }, {
1704
+ color: tk.hairline,
1705
+ widthPt: 0.75,
1706
+ }))
1707
+ }
1708
+
1709
+ // 精确对齐标题 + 副标题总高度的左侧结构竖线(彻底修复旧版红条悬空问题)
1710
+ const lockupTop = 1.95
1711
+ const lockupHeight = subtitle !== '' ? 3.15 : 2.05
1712
+ shapes.push(ooxmlShape(idBase + 1, 'Accent bar', { x: 0.88, y: lockupTop, w: 0.09, h: lockupHeight }, {
1713
+ preset: 'rect',
1714
+ fill: accentRule,
1715
+ }))
1716
+
1717
+ if (kicker !== '') {
1718
+ shapes.push(ooxmlShape(idBase + 4, 'Kicker', { x: 1.22, y: 1.42, w: 8.1, h: 0.36 }, {
1719
+ txBox: true,
1720
+ anchor: 'ctr',
1721
+ marginsIn: { l: 0, r: 0, t: 0, b: 0 },
1722
+ paragraphs: [
1723
+ ooxmlRichParagraph(kicker.toUpperCase(), {
1724
+ sizePt: 12,
1725
+ color: kickerColor,
1726
+ bold: true,
1727
+ lang: langAttr,
1728
+ font: theme.fonts.body,
1729
+ spc: 180,
1730
+ }),
1731
+ ],
1732
+ }))
1733
+ }
1734
+
1735
+ const titleBox = { x: 1.22, y: lockupTop, w: inverted ? 10.6 : 8.1, h: 1.95 }
1736
+ const titleFit = computeTextFit(title, titleBox, 'coverTitle', { padXPt: 2, padYPt: 4 })
1737
+ shapes.push(ooxmlShape(idBase + 2, 'Title', titleBox, {
1738
+ txBox: true,
1739
+ anchor: 'ctr',
1740
+ marginsIn: { l: 0, r: 0, t: 0, b: 0 },
1741
+ fontScale: titleFit.fontScale,
1742
+ paragraphs: [
1743
+ ooxmlRichParagraph(title, {
1744
+ sizePt: titleFit.fontPt,
1745
+ color: fg,
1746
+ bold: true,
1747
+ lang: langAttr,
1748
+ font: theme.fonts.heading,
1749
+ lineHeight: titleFit.lineHeight,
1750
+ }),
1751
+ ],
1752
+ }))
1753
+
1754
+ if (subtitle !== '') {
1755
+ const subBox = { x: 1.22, y: 4.05, w: inverted ? 9.8 : 7.9, h: 1.05 }
1756
+ const subFit = computeTextFit(subtitle, subBox, 'body', { maxPt: 20, minPt: 14, padXPt: 2, padYPt: 2 })
1757
+ shapes.push(ooxmlShape(idBase + 3, 'Subtitle', subBox, {
1758
+ txBox: true,
1759
+ anchor: 't',
1760
+ marginsIn: { l: 0, r: 0, t: 0, b: 0 },
1761
+ fontScale: subFit.fontScale,
1762
+ paragraphs: [
1763
+ ooxmlRichParagraph(subtitle, {
1764
+ sizePt: subFit.fontPt,
1765
+ color: subColor,
1766
+ lang: langAttr,
1767
+ font: theme.fonts.body,
1768
+ lineHeight: 1.42,
1769
+ }),
1770
+ ],
1771
+ }))
1772
+ }
1773
+
1774
+ // 底部元数据线与页脚说明(绝不印 01 / 01 页码)
1775
+ shapes.push(ooxmlLine(nextId(), 'Cover footer rule', { x: 0.88, y: 6.48 }, { x: inverted ? 12.45 : 9.2, y: 6.48 }, {
1776
+ color: inverted ? hexToRgbaSafeHex(accentRule, coverFill, 0.45) : tk.hairline,
1777
+ widthPt: 0.75,
1778
+ }))
1779
+ const metaText = [slide.text, slide.source, manifest.brand?.footer].filter(Boolean).join(' · ')
1780
+ if (metaText) {
1781
+ shapes.push(ooxmlShape(nextId(), 'Cover meta', { x: 0.88, y: 6.62, w: 8.3, h: 0.36 }, {
1782
+ txBox: true,
1783
+ anchor: 'ctr',
1784
+ marginsIn: { l: 0, r: 0, t: 0, b: 0 },
1785
+ paragraphs: [
1786
+ ooxmlRichParagraph(metaText, {
1787
+ sizePt: 11,
1788
+ color: subColor,
1789
+ lang: langAttr,
1790
+ font: theme.fonts.body,
1791
+ }),
1792
+ ],
1793
+ }))
1794
+ }
1795
+ return shapes.join('')
1796
+ }
1797
+
1798
+ if (layout === 'closing') {
1799
+ const inverted = variant === 'inverted' || (!variant && tk.coverMode === 'inverted-accent')
1800
+ const closeFill = inverted ? tk.coverBg : tk.canvas
1801
+ const closeDark = relativeLuminance(closeFill) < 0.36
1802
+ const fg = inverted ? (closeDark ? '#F8FAFC' : '#0F172A') : tk.inkPrimary
1803
+ const accent = inverted ? (theme.id === 'exec-jilan' || theme.id === 'exec-palace' ? '#D4AF37' : '#F8FAFC') : tk.accentText
1804
+ if (inverted) {
1805
+ shapes.push(ooxmlShape(nextId(), 'Closing backdrop', { x: 0, y: 0, w: CANVAS_IN.w, h: CANVAS_IN.h }, {
1806
+ preset: 'rect',
1807
+ fill: closeFill,
1808
+ }))
1809
+ } else {
1810
+ shapes.push(ooxmlShape(nextId(), 'Closing top bar', { x: 0, y: 0, w: CANVAS_IN.w, h: 0.08 }, {
1811
+ preset: 'rect',
1812
+ fill: tk.accentPrimary,
1813
+ }))
1814
+ }
1815
+
1816
+ const items = resolveEffectiveItems(slide)
1817
+ const hasCards = (variant === 'cta-cards' || items.length >= 2) && (slide.items?.length || bullets.length >= 2)
1818
+ const titleY = hasCards ? 1.35 : 2.25
1819
+ shapes.push(ooxmlShape(idBase + 2, 'Title', { x: 1.0, y: titleY, w: 11.33, h: 1.45 }, {
1820
+ txBox: true,
1821
+ anchor: 'ctr',
1822
+ marginsIn: { l: 0, r: 0, t: 0, b: 0 },
1823
+ paragraphs: [
1824
+ ooxmlRichParagraph(title || (langAttr === 'en-US' ? 'Thank You' : '谢谢'), {
1825
+ sizePt: hasCards ? 40 : 48,
1826
+ color: fg,
1827
+ bold: true,
1828
+ lang: langAttr,
1829
+ align: 'ctr',
1830
+ font: theme.fonts.heading,
1831
+ lineHeight: 1.15,
1832
+ }),
1833
+ ],
1834
+ }))
1835
+
1836
+ shapes.push(ooxmlShape(nextId(), 'Closing divider', { x: 5.92, y: titleY + 1.56, w: 1.5, h: 0.05 }, {
1837
+ preset: 'rect',
1838
+ fill: inverted ? accent : tk.accentPrimary,
1839
+ }))
1840
+
1841
+ if (subtitle !== '') {
1842
+ shapes.push(ooxmlShape(idBase + 3, 'Subtitle', { x: 1.5, y: titleY + 1.78, w: 10.33, h: 0.78 }, {
1843
+ txBox: true,
1844
+ anchor: 'ctr',
1845
+ marginsIn: { l: 0, r: 0, t: 0, b: 0 },
1846
+ paragraphs: [
1847
+ ooxmlRichParagraph(subtitle, {
1848
+ sizePt: 19,
1849
+ color: accent,
1850
+ bold: true,
1851
+ lang: langAttr,
1852
+ align: 'ctr',
1853
+ font: theme.fonts.body,
1854
+ }),
1855
+ ],
1856
+ }))
1857
+ }
1858
+
1859
+ if (hasCards) {
1860
+ const cols = Math.min(3, items.length)
1861
+ const gap = 0.26
1862
+ const cardW = (10.8 - gap * (cols - 1)) / cols
1863
+ const startX = (CANVAS_IN.w - (cardW * cols + gap * (cols - 1))) / 2
1864
+ items.slice(0, cols).forEach((it, idx) => {
1865
+ const box = { x: startX + idx * (cardW + gap), y: 4.35, w: cardW, h: 1.75 }
1866
+ shapes.push(ooxmlShape(nextId(), 'CTA Card ' + (idx + 1), box, {
1867
+ preset: cardPreset,
1868
+ adj: roundRectAdj(box.w, box.h, theme.radiusPx),
1869
+ fill: inverted ? hexToRgbaSafeHex('#FFFFFF', closeFill, 0.1) : tk.surface1,
1870
+ stroke: inverted ? hexToRgbaSafeHex('#FFFFFF', closeFill, 0.22) : tk.hairline,
1871
+ strokePt: 0.75,
1872
+ anchor: 'ctr',
1873
+ marginsIn: { l: 0.18, r: 0.18, t: 0.12, b: 0.12 },
1874
+ paragraphs: [
1875
+ ...(it.title ? [ooxmlRichParagraph(it.title, { sizePt: 15, color: fg, bold: true, lang: langAttr, align: 'ctr', font: theme.fonts.heading, spaceAfterPt: 4 })] : []),
1876
+ ...(it.text ? [ooxmlRichParagraph(it.text, { sizePt: 13.5, color: inverted ? '#CBD5E1' : tk.inkSecondary, lang: langAttr, align: 'ctr', font: theme.fonts.body })] : []),
1877
+ ],
1878
+ }))
1879
+ })
1880
+ }
1881
+ return shapes.join('')
1882
+ }
1883
+
1884
+ if (layout === 'section') {
1885
+ shapes.push(ooxmlShape(nextId(), 'Section side band', { x: 0, y: 0, w: 0.16, h: CANVAS_IN.h }, {
1886
+ preset: 'rect',
1887
+ fill: tk.accentPrimary,
1888
+ }))
1889
+ const sectionNum = /^\d+$/.test(kicker.trim()) ? kicker.trim().padStart(2, '0') : kicker
1890
+ if (sectionNum !== '' && sectionNum !== title) {
1891
+ shapes.push(ooxmlShape(idBase + 1, 'Kicker', { x: 1.05, y: 1.85, w: 10.5, h: 0.75 }, {
1892
+ txBox: true,
1893
+ anchor: 'b',
1894
+ marginsIn: { l: 0, r: 0, t: 0, b: 0 },
1895
+ paragraphs: [
1896
+ ooxmlRichParagraph(sectionNum.toUpperCase(), {
1897
+ sizePt: /^\d+$/.test(sectionNum) ? 36 : 14,
1898
+ color: tk.accentText,
1899
+ bold: true,
1900
+ lang: langAttr,
1901
+ font: theme.fonts.heading,
1902
+ spc: 140,
1903
+ }),
1904
+ ],
1905
+ }))
1906
+ }
1907
+ shapes.push(ooxmlShape(nextId(), 'Accent bar', { x: 1.05, y: 2.74, w: 1.45, h: 0.07 }, {
1908
+ preset: 'rect',
1909
+ fill: tk.accentPrimary,
1910
+ }))
1911
+ const tBox = { x: 1.05, y: 3.0, w: 10.8, h: 1.55 }
1912
+ const tFit = computeTextFit(title, tBox, 'sectionTitle')
1913
+ shapes.push(ooxmlShape(idBase + 2, 'Title', tBox, {
1914
+ txBox: true,
1915
+ anchor: 't',
1916
+ marginsIn: { l: 0, r: 0, t: 0, b: 0 },
1917
+ fontScale: tFit.fontScale,
1918
+ paragraphs: [
1919
+ ooxmlRichParagraph(title, {
1920
+ sizePt: tFit.fontPt,
1921
+ color: tk.inkPrimary,
1922
+ bold: true,
1923
+ lang: langAttr,
1924
+ font: theme.fonts.heading,
1925
+ lineHeight: tFit.lineHeight,
1926
+ }),
1927
+ ],
1928
+ }))
1929
+ if (subtitle !== '') {
1930
+ shapes.push(ooxmlShape(idBase + 3, 'Subtitle', { x: 1.05, y: 4.68, w: 9.8, h: 0.9 }, {
1931
+ txBox: true,
1932
+ anchor: 't',
1933
+ marginsIn: { l: 0, r: 0, t: 0, b: 0 },
1934
+ paragraphs: [
1935
+ ooxmlRichParagraph(subtitle, {
1936
+ sizePt: 18,
1937
+ color: tk.inkSecondary,
1938
+ lang: langAttr,
1939
+ font: theme.fonts.body,
1940
+ }),
1941
+ ],
1942
+ }))
1943
+ }
1944
+ shapes.push(renderSlideChromePptx(slide, index, total, theme, langAttr, manifest, nextId))
1945
+ return shapes.join('')
1946
+ }
1947
+
1948
+ if (layout === 'statement') {
1949
+ if (kicker !== '') {
1950
+ shapes.push(ooxmlShape(idBase + 1, 'Kicker', { x: 1.05, y: 1.35, w: 10.5, h: 0.34 }, {
1951
+ txBox: true,
1952
+ anchor: 'ctr',
1953
+ marginsIn: { l: 0, r: 0, t: 0, b: 0 },
1954
+ paragraphs: [
1955
+ ooxmlRichParagraph(kicker.toUpperCase(), {
1956
+ sizePt: 12,
1957
+ color: tk.accentText,
1958
+ bold: true,
1959
+ lang: langAttr,
1960
+ font: theme.fonts.body,
1961
+ spc: 160,
1962
+ }),
1963
+ ],
1964
+ }))
1965
+ }
1966
+ const stmtText = title || slide.text || ''
1967
+ const cardBox = { x: 0.88, y: 1.92, w: 11.57, h: subtitle ? 2.95 : 3.45 }
1968
+ shapes.push(ooxmlShape(nextId(), 'Statement surface', cardBox, {
1969
+ preset: cardPreset,
1970
+ adj: roundRectAdj(cardBox.w, cardBox.h, theme.radiusPx),
1971
+ fill: tk.surface1,
1972
+ stroke: tk.hairline,
1973
+ strokePt: 0.75,
1974
+ }))
1975
+ shapes.push(ooxmlShape(nextId(), 'Accent bar', { x: 0.88, y: 1.92, w: 0.10, h: cardBox.h }, {
1976
+ preset: 'rect',
1977
+ fill: tk.accentPrimary,
1978
+ }))
1979
+ const sBox = { x: 1.32, y: 2.12, w: 10.8, h: cardBox.h - 0.4 }
1980
+ const sFit = computeTextFit(stmtText, sBox, 'statement')
1981
+ shapes.push(ooxmlShape(idBase + 2, 'Statement', sBox, {
1982
+ txBox: true,
1983
+ anchor: 'ctr',
1984
+ marginsIn: { l: 0, r: 0, t: 0, b: 0 },
1985
+ fontScale: sFit.fontScale,
1986
+ paragraphs: [
1987
+ ooxmlRichParagraph(stmtText, {
1988
+ sizePt: sFit.fontPt,
1989
+ color: tk.inkPrimary,
1990
+ secondaryColor: tk.inkSecondary,
1991
+ accentColor: tk.accentText,
1992
+ bold: true,
1993
+ lang: langAttr,
1994
+ font: theme.fonts.heading,
1995
+ lineHeight: sFit.lineHeight,
1996
+ }),
1997
+ ],
1998
+ }))
1999
+ if (subtitle !== '') {
2000
+ shapes.push(ooxmlShape(idBase + 3, 'Subtitle', { x: 1.32, y: 5.12, w: 10.5, h: 0.85 }, {
2001
+ txBox: true,
2002
+ anchor: 't',
2003
+ marginsIn: { l: 0, r: 0, t: 0, b: 0 },
2004
+ paragraphs: [
2005
+ ooxmlRichParagraph(subtitle, {
2006
+ sizePt: 17,
2007
+ color: tk.inkSecondary,
2008
+ lang: langAttr,
2009
+ font: theme.fonts.body,
2010
+ }),
2011
+ ],
2012
+ }))
2013
+ }
2014
+ shapes.push(renderSlideChromePptx(slide, index, total, theme, langAttr, manifest, nextId))
2015
+ return shapes.join('')
2016
+ }
2017
+
2018
+ if (layout === 'quote') {
2019
+ const quoteText = title || slide.text || ''
2020
+ shapes.push(ooxmlShape(nextId(), 'Quote card', { x: 0.88, y: 1.25, w: 11.57, h: 4.85 }, {
2021
+ preset: cardPreset,
2022
+ adj: roundRectAdj(11.57, 4.85, theme.radiusPx),
2023
+ fill: tk.surface1,
2024
+ stroke: tk.hairline,
2025
+ strokePt: 0.75,
2026
+ }))
2027
+ shapes.push(ooxmlShape(idBase + 1, 'Quote mark', { x: 1.25, y: 1.38, w: 1.5, h: 1.15 }, {
2028
+ txBox: true,
2029
+ anchor: 't',
2030
+ marginsIn: { l: 0, r: 0, t: 0, b: 0 },
2031
+ paragraphs: [
2032
+ ooxmlRichParagraph('\u201C', {
2033
+ sizePt: 72,
2034
+ color: tk.accentPrimary,
2035
+ bold: true,
2036
+ lang: langAttr,
2037
+ font: theme.fonts.heading,
2038
+ lineHeight: 0.9,
2039
+ }),
2040
+ ],
2041
+ }))
2042
+ const qBox = { x: 1.38, y: 2.38, w: 10.5, h: 2.45 }
2043
+ const qFit = computeTextFit(quoteText, qBox, 'quote')
2044
+ shapes.push(ooxmlShape(idBase + 2, 'Quote', qBox, {
2045
+ txBox: true,
2046
+ anchor: 'ctr',
2047
+ marginsIn: { l: 0, r: 0, t: 0, b: 0 },
2048
+ fontScale: qFit.fontScale,
2049
+ paragraphs: [
2050
+ ooxmlRichParagraph(quoteText, {
2051
+ sizePt: qFit.fontPt,
2052
+ color: tk.inkPrimary,
2053
+ bold: true,
2054
+ lang: langAttr,
2055
+ font: theme.fonts.heading,
2056
+ lineHeight: qFit.lineHeight,
2057
+ }),
2058
+ ],
2059
+ }))
2060
+ if (subtitle !== '') {
2061
+ shapes.push(ooxmlLine(nextId(), 'Quote rule', { x: 1.38, y: 5.08 }, { x: 3.2, y: 5.08 }, {
2062
+ color: tk.accentPrimary,
2063
+ widthPt: 1.25,
2064
+ }))
2065
+ shapes.push(ooxmlShape(idBase + 3, 'Attribution', { x: 1.38, y: 5.22, w: 9.8, h: 0.55 }, {
2066
+ txBox: true,
2067
+ anchor: 'ctr',
2068
+ marginsIn: { l: 0, r: 0, t: 0, b: 0 },
2069
+ paragraphs: [
2070
+ ooxmlRichParagraph('\u2014\u2014 ' + subtitle, {
2071
+ sizePt: 15,
2072
+ color: tk.inkMuted,
2073
+ bold: true,
2074
+ lang: langAttr,
2075
+ font: theme.fonts.body,
2076
+ }),
2077
+ ],
2078
+ }))
2079
+ }
2080
+ shapes.push(renderSlideChromePptx(slide, index, total, theme, langAttr, manifest, nextId))
2081
+ return shapes.join('')
2082
+ }
2083
+
2084
+ // 所有常规内容版式共享 6 套母版骨架页眉
2085
+ shapes.push(renderStandardHeaderPptx(slide, idBase, nextId, theme, langAttr, chromeCfg))
2086
+
2087
+ if (layout === 'harvey') {
2088
+ shapes.push(renderHarveyMatrixPptx(slide, { x: 0.62, y: bodyTopY + 0.06, w: 12.09, h: bodyH - 0.14 }, nextId, chromeCfg, theme, langAttr))
2089
+ shapes.push(renderSlideChromePptx(slide, index, total, theme, langAttr, manifest, nextId))
2090
+ return shapes.join('')
2091
+ }
2092
+
2093
+ if (layout === 'table') {
2094
+ const rows = Array.isArray(slide.rows) ? slide.rows : [['']]
2095
+ const tStyle = slide.tableStyle || slide.visual?.tableStyle
2096
+ if (tStyle === 'harvey') {
2097
+ shapes.push(renderHarveyMatrixPptx(slide, { x: 0.62, y: bodyTopY + 0.06, w: 12.09, h: bodyH - 0.14 }, nextId, chromeCfg, theme, langAttr))
2098
+ } else {
2099
+ shapes.push(ooxmlTable(idBase + 3, 'Table', { x: 0.62, y: bodyTopY + 0.08, w: 12.09, h: bodyH - 0.16 }, rows, theme, langAttr, tStyle))
2100
+ }
2101
+ shapes.push(renderSlideChromePptx(slide, index, total, theme, langAttr, manifest, nextId))
2102
+ return shapes.join('')
2103
+ }
2104
+
2105
+ if (layout === 'gantt') {
2106
+ const defaultCols = variant === 'months'
2107
+ ? ['M1', 'M2', 'M3', 'M4', 'M5', 'M6']
2108
+ : variant === 'weeks'
2109
+ ? ['W1', 'W2', 'W3', 'W4', 'W5', 'W6']
2110
+ : ['Q1', 'Q2', 'Q3', 'Q4']
2111
+ const cols = Array.isArray(slide.columns) && slide.columns.length > 0 && slide.columns.every((c) => typeof c === 'string')
2112
+ ? slide.columns.slice(0, 8)
2113
+ : defaultCols
2114
+ const colCount = Math.max(2, cols.length)
2115
+ const items = resolveEffectiveItems(slide).slice(0, 7)
2116
+ const rowCount = Math.max(1, items.length)
2117
+
2118
+ const labelW = 3.72
2119
+ const gridX = 0.62 + labelW + 0.14
2120
+ const gridW = 12.71 - gridX
2121
+ const headH = 0.44
2122
+ const rowGap = 0.08
2123
+ const availRowH = bodyH - headH - 0.14
2124
+ const rowH = Math.min(0.66, Math.max(0.42, (availRowH - rowGap * (rowCount - 1)) / rowCount))
2125
+ const colW = gridW / colCount
2126
+ const totalH = headH + rowCount * rowH + Math.max(0, rowCount - 1) * rowGap
2127
+ const topY = bodyTopY + Math.max(0, (bodyH - totalH) / 2)
2128
+
2129
+ // Left corner header + time column headers
2130
+ shapes.push(ooxmlShape(nextId(), 'Gantt Corner', { x: 0.62, y: topY, w: labelW, h: headH }, {
2131
+ preset: cardPreset,
2132
+ adj: roundRectAdj(labelW, headH, Math.min(6, chromeCfg.cardRadiusPx)),
2133
+ fill: tk.surface2,
2134
+ stroke: tk.hairline,
2135
+ strokePt: 0.5,
2136
+ anchor: 'ctr',
2137
+ marginsIn: { l: 0.14, r: 0.08, t: 0.02, b: 0.02 },
2138
+ paragraphs: [
2139
+ ooxmlRichParagraph(variant === 'swimlane' ? (langAttr === 'en-US' ? 'WORKSTREAM / TASK' : '泳道 / 任务项') : (langAttr === 'en-US' ? 'INITIATIVE / MILESTONE' : '任务里程碑'), {
2140
+ sizePt: 11,
2141
+ color: tk.inkMuted,
2142
+ bold: true,
2143
+ lang: langAttr,
2144
+ font: theme.fonts.body,
2145
+ }),
2146
+ ],
2147
+ }))
2148
+
2149
+ cols.forEach((colLabel, cIdx) => {
2150
+ const cx = gridX + cIdx * colW
2151
+ shapes.push(ooxmlShape(nextId(), 'Gantt Col ' + (cIdx + 1), { x: cx, y: topY, w: colW, h: headH }, {
2152
+ preset: 'rect',
2153
+ fill: cIdx % 2 === 0 ? tk.surface2 : tk.surface1,
2154
+ stroke: tk.hairline,
2155
+ strokePt: 0.5,
2156
+ anchor: 'ctr',
2157
+ marginsIn: { l: 0.04, r: 0.04, t: 0.02, b: 0.02 },
2158
+ paragraphs: [
2159
+ ooxmlRichParagraph(colLabel, {
2160
+ sizePt: 12,
2161
+ color: tk.inkPrimary,
2162
+ bold: true,
2163
+ lang: langAttr,
2164
+ align: 'ctr',
2165
+ font: theme.fonts.heading,
2166
+ }),
2167
+ ],
2168
+ }))
2169
+ })
2170
+
2171
+ // Vertical grid lines
2172
+ const gridBottomY = topY + totalH
2173
+ for (let c = 0; c <= colCount; c += 1) {
2174
+ const lx = gridX + c * colW
2175
+ shapes.push(ooxmlLine(nextId(), 'Gantt Grid ' + c, { x: lx, y: topY + headH }, { x: lx, y: gridBottomY }, {
2176
+ color: tk.hairline,
2177
+ widthPt: 0.5,
2178
+ dash: c === 0 || c === colCount ? '' : 'dot',
2179
+ }))
2180
+ }
2181
+
2182
+ const barPalette = [tk.accentPrimary, tk.accentSecondary, tk.positive, tk.accentPrimary]
2183
+ items.forEach((it, idx) => {
2184
+ const ry = topY + headH + 0.06 + idx * (rowH + rowGap)
2185
+ const st = statusPalette(it.status, tk)
2186
+ const barFill = it.status ? st.bar : barPalette[idx % barPalette.length]
2187
+
2188
+ // Row backdrop
2189
+ shapes.push(ooxmlShape(nextId(), 'Gantt Track ' + (idx + 1), { x: gridX, y: ry, w: gridW, h: rowH }, {
2190
+ preset: 'rect',
2191
+ fill: idx % 2 === 0 ? tk.surface1 : tk.canvas,
2192
+ stroke: tk.hairline,
2193
+ strokePt: 0.25,
2194
+ }))
2195
+
2196
+ // Left task label card (optional swimlane tag + title)
2197
+ shapes.push(ooxmlShape(nextId(), 'Gantt Task BG ' + (idx + 1), { x: 0.62, y: ry, w: labelW, h: rowH }, {
2198
+ preset: cardPreset,
2199
+ adj: roundRectAdj(labelW, rowH, Math.min(6, chromeCfg.cardRadiusPx)),
2200
+ fill: tk.surface1,
2201
+ stroke: chromeCfg.cardBorderless ? '' : tk.hairline,
2202
+ strokePt: 0.5,
2203
+ }))
2204
+ if (it.tag) {
2205
+ const tagW = computeBadgePillWidth(it.tag, 9.5, 1.18, 0.52)
2206
+ shapes.push(ooxmlShape(nextId(), 'Gantt Tag ' + (idx + 1), { x: 0.72, y: ry + (rowH - 0.28) / 2, w: tagW, h: 0.28 }, {
2207
+ preset: cardPreset,
2208
+ adj: roundRectAdj(tagW, 0.28, Math.min(6, chromeCfg.cardRadiusPx)),
2209
+ fill: tk.accentSoft,
2210
+ anchor: 'ctr',
2211
+ marginsIn: { l: 0.03, r: 0.03, t: 0.01, b: 0.01 },
2212
+ paragraphs: [
2213
+ ooxmlRichParagraph(it.tag, {
2214
+ sizePt: 9.5,
2215
+ color: tk.accentText,
2216
+ bold: true,
2217
+ lang: langAttr,
2218
+ align: 'ctr',
2219
+ font: theme.fonts.body,
2220
+ }),
2221
+ ],
2222
+ }))
2223
+ shapes.push(ooxmlShape(nextId(), 'Gantt ' + (idx + 1), { x: 0.72 + tagW + 0.10, y: ry + 0.02, w: labelW - tagW - 0.28, h: rowH - 0.04 }, {
2224
+ txBox: true,
2225
+ anchor: 'ctr',
2226
+ marginsIn: { l: 0, r: 0, t: 0, b: 0 },
2227
+ paragraphs: [
2228
+ ooxmlRichParagraph(it.title || it.text || '', {
2229
+ sizePt: 12.5,
2230
+ color: tk.inkPrimary,
2231
+ bold: true,
2232
+ lang: langAttr,
2233
+ font: theme.fonts.body,
2234
+ lineHeight: 1.15,
2235
+ }),
2236
+ ],
2237
+ }))
2238
+ } else {
2239
+ shapes.push(ooxmlShape(nextId(), 'Gantt ' + (idx + 1), { x: 0.76, y: ry + 0.02, w: labelW - 0.24, h: rowH - 0.04 }, {
2240
+ txBox: true,
2241
+ anchor: 'ctr',
2242
+ marginsIn: { l: 0, r: 0, t: 0, b: 0 },
2243
+ paragraphs: [
2244
+ ooxmlRichParagraph(it.title || it.text || '', {
2245
+ sizePt: 13,
2246
+ color: tk.inkPrimary,
2247
+ bold: true,
2248
+ lang: langAttr,
2249
+ font: theme.fonts.body,
2250
+ lineHeight: 1.15,
2251
+ }),
2252
+ ],
2253
+ }))
2254
+ }
2255
+
2256
+ const startSlot = it.start !== undefined
2257
+ ? Math.max(0, Math.min(colCount - 0.25, it.start))
2258
+ : Math.min(colCount - 1, idx % colCount)
2259
+ const isPureMilestone = it.span === 0 || (Boolean(it.milestone) && it.span === undefined)
2260
+ const hasEndMilestone = !isPureMilestone && Boolean(it.milestone)
2261
+ if (isPureMilestone) {
2262
+ const mCenter = gridX + ((startSlot + 0.5) / colCount) * gridW
2263
+ const mSize = Math.min(0.32, rowH * 0.62)
2264
+ shapes.push(ooxmlShape(nextId(), 'Gantt Milestone ' + (idx + 1), {
2265
+ x: mCenter - mSize / 2,
2266
+ y: ry + (rowH - mSize) / 2,
2267
+ w: mSize,
2268
+ h: mSize,
2269
+ }, {
2270
+ preset: 'diamond',
2271
+ fill: barFill,
2272
+ stroke: tk.canvas,
2273
+ strokePt: 1.0,
2274
+ }))
2275
+ const mLabel = it.value || it.delta || it.text || ''
2276
+ if (mLabel) {
2277
+ const onRight = startSlot < colCount - 1.2
2278
+ const lblBox = onRight
2279
+ ? { x: mCenter + mSize / 2 + 0.10, y: ry + 0.04, w: Math.max(1.2, gridX + gridW - (mCenter + mSize / 2 + 0.14)), h: rowH - 0.08 }
2280
+ : { x: Math.max(gridX + 0.08, mCenter - mSize / 2 - 2.1), y: ry + 0.04, w: 2.0, h: rowH - 0.08 }
2281
+ shapes.push(ooxmlShape(nextId(), 'Gantt Milestone Label ' + (idx + 1), lblBox, {
2282
+ txBox: true,
2283
+ anchor: 'ctr',
2284
+ marginsIn: { l: 0, r: 0, t: 0, b: 0 },
2285
+ paragraphs: [
2286
+ ooxmlRichParagraph(mLabel, {
2287
+ sizePt: 11,
2288
+ color: tk.accentText,
2289
+ bold: true,
2290
+ lang: langAttr,
2291
+ align: onRight ? 'l' : 'r',
2292
+ font: theme.fonts.body,
2293
+ }),
2294
+ ],
2295
+ }))
2296
+ }
2297
+ } else {
2298
+ const spanSlot = Math.max(0.35, Math.min(colCount - startSlot, it.span !== undefined ? it.span : 1))
2299
+ const barX = gridX + (startSlot / colCount) * gridW + 0.04
2300
+ const barW = Math.max(0.30, (spanSlot / colCount) * gridW - 0.08)
2301
+ const barH = Math.min(0.36, rowH * 0.64)
2302
+ const barY = ry + (rowH - barH) / 2
2303
+ const barText = it.value || it.delta || ''
2304
+ shapes.push(ooxmlShape(nextId(), 'Gantt Bar ' + (idx + 1), { x: barX, y: barY, w: barW, h: barH }, {
2305
+ preset: chromeCfg.cardRadiusPx > 0 ? 'roundRect' : 'rect',
2306
+ adj: roundRectAdj(barW, barH, Math.min(8, chromeCfg.cardRadiusPx)),
2307
+ fill: barFill,
2308
+ anchor: 'ctr',
2309
+ marginsIn: { l: 0.08, r: 0.08, t: 0.01, b: 0.01 },
2310
+ paragraphs: barText
2311
+ ? [ooxmlRichParagraph(barText, { sizePt: 11, color: '#FFFFFF', bold: true, lang: langAttr, align: 'ctr', font: theme.fonts.body })]
2312
+ : [],
2313
+ }))
2314
+ if (hasEndMilestone) {
2315
+ const endMSize = Math.min(0.28, rowH * 0.56)
2316
+ shapes.push(ooxmlShape(nextId(), 'Gantt Milestone ' + (idx + 1), {
2317
+ x: barX + barW - endMSize / 2,
2318
+ y: ry + (rowH - endMSize) / 2,
2319
+ w: endMSize,
2320
+ h: endMSize,
2321
+ }, {
2322
+ preset: 'diamond',
2323
+ fill: barFill,
2324
+ stroke: tk.canvas,
2325
+ strokePt: 1.5,
2326
+ }))
2327
+ }
2328
+ }
2329
+ })
2330
+
2331
+ shapes.push(renderSlideChromePptx(slide, index, total, theme, langAttr, manifest, nextId))
2332
+ return shapes.join('')
2333
+ }
2334
+
2335
+ if (layout === 'architecture') {
2336
+ const allItems = resolveEffectiveItems(slide).slice(0, 6)
2337
+ const isSidecarItem = (it) =>
2338
+ it.status === 'accent' || /^(?:sidecar|governance|security|observability|安全|治理|可观测|监控|合规|运维)$/i.test(String(it.tag || '').trim())
2339
+ const candidateSidecars = allItems.filter(isSidecarItem)
2340
+ const candidateTiers = allItems.filter((it) => !isSidecarItem(it))
2341
+ const hasSidecar = candidateSidecars.length >= 1 && candidateTiers.length >= 2
2342
+ const sidecarItems = hasSidecar ? candidateSidecars : []
2343
+ const tierItems = hasSidecar ? candidateTiers : allItems
2344
+ const nTiers = Math.max(1, tierItems.length)
2345
+
2346
+ const sidecarW = hasSidecar ? 2.38 : 0
2347
+ const sidecarGap = hasSidecar ? 0.24 : 0
2348
+ const tierAreaW = 12.09 - sidecarW - sidecarGap
2349
+ const arrowH = nTiers > 1 ? 0.34 : 0
2350
+ const tierH = Math.min(1.32, (bodyH - arrowH * Math.max(0, nTiers - 1)) / nTiers)
2351
+ const totalArchH = tierH * nTiers + arrowH * Math.max(0, nTiers - 1)
2352
+ const startY = bodyTopY + Math.max(0, (bodyH - totalArchH) / 2)
2353
+
2354
+ tierItems.forEach((it, idx) => {
2355
+ const ty = startY + idx * (tierH + arrowH)
2356
+ const isTopTier = idx === 0
2357
+ shapes.push(renderSurfaceCardPptx('Architecture Tier ' + (idx + 1), { x: 0.62, y: ty, w: tierAreaW, h: tierH }, {
2358
+ fill: isTopTier ? tk.surface2 : tk.surface1,
2359
+ focal: isTopTier,
2360
+ }, nextId, chromeCfg, theme))
2361
+
2362
+ // Left tier label block
2363
+ const labelW = Math.min(2.65, tierAreaW * 0.27)
2364
+ shapes.push(ooxmlShape(nextId(), 'Architecture ' + (idx + 1), { x: 0.78, y: ty + 0.08, w: labelW, h: tierH - 0.16 }, {
2365
+ txBox: true,
2366
+ anchor: 'ctr',
2367
+ marginsIn: { l: 0.04, r: 0.06, t: 0.02, b: 0.02 },
2368
+ paragraphs: [
2369
+ ...(it.tag ? [ooxmlRichParagraph(it.tag.toUpperCase(), { sizePt: 9.5, color: tk.accentText, bold: true, lang: langAttr, font: theme.fonts.body, spc: 100, spaceAfterPt: 2 })] : []),
2370
+ ooxmlRichParagraph(it.title || '', { sizePt: 14.5, color: tk.inkPrimary, bold: true, lang: langAttr, font: theme.fonts.heading, lineHeight: 1.18 }),
2371
+ ],
2372
+ }))
2373
+
2374
+ // Sub-module boxes from bullets[] or text fallback
2375
+ const modsX = 0.62 + labelW + 0.22
2376
+ const modsW = tierAreaW - labelW - 0.38
2377
+ const mods = it.bullets?.length ? it.bullets : (it.text ? [it.text] : [])
2378
+ if (mods.length > 0) {
2379
+ const modGap = 0.14
2380
+ const modW = (modsW - modGap * (mods.length - 1)) / mods.length
2381
+ const modH = Math.max(0.46, tierH - 0.28)
2382
+ mods.forEach((modText, mIdx) => {
2383
+ const mx = modsX + mIdx * (modW + modGap)
2384
+ shapes.push(ooxmlShape(nextId(), 'Arch Module ' + (idx + 1) + '-' + (mIdx + 1), { x: mx, y: ty + 0.14, w: modW, h: modH }, {
2385
+ preset: cardPreset,
2386
+ adj: roundRectAdj(modW, modH, Math.min(8, chromeCfg.cardRadiusPx)),
2387
+ fill: tk.canvas,
2388
+ stroke: tk.hairline,
2389
+ strokePt: 0.75,
2390
+ anchor: 'ctr',
2391
+ marginsIn: { l: 0.08, r: 0.08, t: 0.04, b: 0.04 },
2392
+ paragraphs: [
2393
+ ooxmlRichParagraph(modText, {
2394
+ sizePt: mods.length >= 4 ? 12 : 13,
2395
+ color: tk.inkPrimary,
2396
+ secondaryColor: tk.inkSecondary,
2397
+ bold: false,
2398
+ lang: langAttr,
2399
+ align: 'ctr',
2400
+ font: theme.fonts.body,
2401
+ lineHeight: 1.2,
2402
+ autoLeadBold: true,
2403
+ }),
2404
+ ],
2405
+ }))
2406
+ })
2407
+ }
2408
+
2409
+ // Dataflow arrows between tiers
2410
+ if (idx < nTiers - 1) {
2411
+ const ay = ty + tierH + 0.02
2412
+ const ah = arrowH - 0.04
2413
+ const arrowPreset = variant === 'platform' ? 'upDownArrow' : 'downArrow'
2414
+ const positions = [0.62 + tierAreaW * 0.36, 0.62 + tierAreaW * 0.68]
2415
+ positions.forEach((ax, aIdx) => {
2416
+ shapes.push(ooxmlShape(nextId(), 'Arch Arrow ' + (idx + 1) + '-' + (aIdx + 1), { x: ax - 0.09, y: ay, w: 0.18, h: ah }, {
2417
+ preset: arrowPreset,
2418
+ fill: tk.accentPrimary,
2419
+ }))
2420
+ })
2421
+ }
2422
+ })
2423
+
2424
+ if (hasSidecar) {
2425
+ const sx = 0.62 + tierAreaW + sidecarGap
2426
+ const sideCount = sidecarItems.length
2427
+ const scGap = 0.16
2428
+ const scH = (totalArchH - scGap * (sideCount - 1)) / sideCount
2429
+ sidecarItems.forEach((sc, sIdx) => {
2430
+ const sy = startY + sIdx * (scH + scGap)
2431
+ shapes.push(renderSurfaceCardPptx('Arch Sidecar ' + (sIdx + 1), { x: sx, y: sy, w: sidecarW, h: scH }, {
2432
+ fill: tk.accentSoft,
2433
+ focal: true,
2434
+ }, nextId, chromeCfg, theme))
2435
+ const scLines = [sc.title || '', sc.text || '', ...(sc.bullets ?? [])].filter(Boolean)
2436
+ const scBox = { x: sx + 0.16, y: sy + 0.16, w: sidecarW - 0.32, h: scH - 0.32 }
2437
+ const scFit = computeTextFit(scLines, scBox, 'cardBody', { maxPt: 13.5, minPt: 11.5 })
2438
+ const scParas = []
2439
+ if (sc.tag) {
2440
+ scParas.push(ooxmlRichParagraph(sc.tag.toUpperCase(), { sizePt: 9.5, color: tk.accentText, bold: true, lang: langAttr, font: theme.fonts.body, spc: 100, spaceAfterPt: 4 }))
2441
+ }
2442
+ if (sc.title) {
2443
+ scParas.push(ooxmlRichParagraph(sc.title, { sizePt: 14.5, color: tk.inkPrimary, bold: true, lang: langAttr, font: theme.fonts.heading, spaceAfterPt: 6 }))
2444
+ }
2445
+ if (sc.text) {
2446
+ scParas.push(ooxmlRichParagraph(sc.text, { sizePt: scFit.fontPt, color: tk.inkSecondary, lang: langAttr, font: theme.fonts.body, lineHeight: 1.32, spaceAfterPt: 5 }))
2447
+ }
2448
+ for (const b of sc.bullets ?? []) {
2449
+ scParas.push(ooxmlRichParagraph(b, { sizePt: scFit.fontPt, color: tk.inkPrimary, secondaryColor: tk.inkSecondary, bullet: true, bulletColor: tk.accentPrimary, lang: langAttr, font: theme.fonts.body, lineHeight: 1.3, spaceAfterPt: 4, autoLeadBold: true }))
2450
+ }
2451
+ shapes.push(ooxmlShape(nextId(), 'Architecture Sidecar Text ' + (sIdx + 1), scBox, {
2452
+ txBox: true,
2453
+ anchor: 'ctr',
2454
+ marginsIn: { l: 0, r: 0, t: 0, b: 0 },
2455
+ fontScale: scFit.fontScale,
2456
+ paragraphs: scParas,
2457
+ }))
2458
+ })
2459
+ }
2460
+
2461
+ shapes.push(renderSlideChromePptx(slide, index, total, theme, langAttr, manifest, nextId))
2462
+ return shapes.join('')
2463
+ }
2464
+
2465
+ if (layout === 'tam') {
2466
+ const rawItems = resolveEffectiveItems(slide).slice(0, 3)
2467
+ const defaults = ['TAM', 'SAM', 'SOM']
2468
+ const items = Array.from({ length: Math.max(1, rawItems.length) }, (_, idx) => ({
2469
+ ...rawItems[idx],
2470
+ tag: rawItems[idx]?.tag || defaults[idx] || ('T' + (idx + 1)),
2471
+ }))
2472
+ const maxDiam = Math.min(4.78, bodyH - 0.12)
2473
+ const cx = 3.12
2474
+ const bottomY = bodyTopY + (bodyH + maxDiam) / 2
2475
+ const ratios = [1.0, 0.68, 0.39]
2476
+ const ringFills = [tk.surface1, tk.accentSoft, tk.accentPrimary]
2477
+ const ringStrokes = [tk.hairline, tk.accentPrimary, tk.accentPrimary]
2478
+
2479
+ // 3 bottom-tangent nested ellipses (drawn outer-to-inner)
2480
+ const ringLabelYs = []
2481
+ items.forEach((it, idx) => {
2482
+ const d = maxDiam * (ratios[idx] ?? Math.max(0.28, 1 - idx * 0.28))
2483
+ const rx = cx - d / 2
2484
+ const ry = bottomY - d
2485
+ const isInner = idx === items.length - 1
2486
+ shapes.push(ooxmlShape(nextId(), 'TAM Circle ' + (idx + 1), { x: rx, y: ry, w: d, h: d }, {
2487
+ preset: 'ellipse',
2488
+ fill: ringFills[idx] ?? tk.surface2,
2489
+ stroke: ringStrokes[idx] ?? tk.accentPrimary,
2490
+ strokePt: idx === 0 ? 1.25 : 1.5,
2491
+ }))
2492
+ const lblY = isInner ? ry + d / 2 - 0.30 : ry + 0.14
2493
+ const lblH = isInner ? 0.60 : 0.44
2494
+ const lblCenterY = lblY + lblH / 2
2495
+ ringLabelYs.push(lblCenterY)
2496
+ const halfChord = Math.sqrt(Math.max(0.04, (d / 2) ** 2 - (lblCenterY - (ry + d / 2)) ** 2))
2497
+ const lblW = Math.max(0.85, Math.min(d * 0.72, 2 * halfChord - 0.24))
2498
+ const ringShortTag = String(it.tag || defaults[idx] || ('T' + (idx + 1))).split(/\s*[·::\-—|]\s*/)[0].trim() || (defaults[idx] || ('T' + (idx + 1)))
2499
+ const ringText = ringShortTag + (it.value ? (isInner ? '\n' : ' ') + it.value + (it.unit ? ' ' + it.unit : '') : '')
2500
+ shapes.push(ooxmlShape(nextId(), 'TAM Label ' + (idx + 1), { x: cx - lblW / 2, y: lblY, w: lblW, h: lblH }, {
2501
+ txBox: true,
2502
+ anchor: 'ctr',
2503
+ marginsIn: { l: 0, r: 0, t: 0, b: 0 },
2504
+ paragraphs: [
2505
+ ooxmlRichParagraph(ringText, {
2506
+ sizePt: isInner ? 12.5 : 12,
2507
+ color: isInner ? tk.inkOnAccent : tk.accentText,
2508
+ bold: true,
2509
+ lang: langAttr,
2510
+ align: 'ctr',
2511
+ font: theme.fonts.heading,
2512
+ }),
2513
+ ],
2514
+ }))
2515
+ })
2516
+
2517
+ // Right 3 breakdown cards + horizontal leader connectors
2518
+ const cardX = 6.26
2519
+ const cardW = 6.45
2520
+ const cardGap = 0.20
2521
+ const nCards = items.length
2522
+ const cardH = Math.min(1.52, (bodyH - cardGap * (nCards - 1)) / nCards)
2523
+ const cardsStartY = bodyTopY + Math.max(0, (bodyH - (cardH * nCards + cardGap * (nCards - 1))) / 2)
2524
+
2525
+ items.forEach((it, idx) => {
2526
+ const cy = cardsStartY + idx * (cardH + cardGap)
2527
+ const isInner = idx === nCards - 1
2528
+ const d = maxDiam * (ratios[idx] ?? 0.4)
2529
+ const circleTopY = bottomY - d
2530
+ const dy = (ringLabelYs[idx] ?? (circleTopY + 0.3)) - (circleTopY + d / 2)
2531
+ const r = d / 2
2532
+ const dx = Math.sqrt(Math.max(0, r * r - dy * dy))
2533
+ const lineStartX = Math.min(cardX - 0.14, cx + dx * 0.72)
2534
+ const lineY = cy + cardH / 2
2535
+ shapes.push(ooxmlLine(nextId(), 'TAM Connector ' + (idx + 1), { x: lineStartX, y: lineY }, { x: cardX, y: lineY }, {
2536
+ color: isInner ? tk.accentPrimary : tk.hairline,
2537
+ widthPt: 1.0,
2538
+ dash: 'dot',
2539
+ }))
2540
+
2541
+ shapes.push(renderSurfaceCardPptx('TAM Card ' + (idx + 1), { x: cardX, y: cy, w: cardW, h: cardH }, {
2542
+ fill: isInner ? tk.accentSoft : tk.surface1,
2543
+ focal: isInner,
2544
+ }, nextId, chromeCfg, theme))
2545
+
2546
+ const tagW = computeBadgePillWidth(it.tag, 10.5, 1.85, 0.72)
2547
+ shapes.push(ooxmlShape(nextId(), 'TAM Tag ' + (idx + 1), { x: cardX + 0.22, y: cy + 0.22, w: tagW, h: 0.32 }, {
2548
+ preset: cardPreset,
2549
+ adj: roundRectAdj(tagW, 0.32, Math.min(6, chromeCfg.cardRadiusPx)),
2550
+ fill: isInner ? tk.accentPrimary : tk.surface2,
2551
+ anchor: 'ctr',
2552
+ marginsIn: { l: 0.04, r: 0.04, t: 0.01, b: 0.01 },
2553
+ paragraphs: [
2554
+ ooxmlRichParagraph(it.tag, {
2555
+ sizePt: 10.5,
2556
+ color: isInner ? tk.inkOnAccent : tk.accentText,
2557
+ bold: true,
2558
+ lang: langAttr,
2559
+ align: 'ctr',
2560
+ font: theme.fonts.heading,
2561
+ }),
2562
+ ],
2563
+ }))
2564
+
2565
+ const metaColW = Math.max(1.85, tagW)
2566
+ if (it.value) {
2567
+ shapes.push(ooxmlShape(nextId(), 'TAM Value ' + (idx + 1), { x: cardX + 0.22, y: cy + 0.62, w: metaColW, h: cardH - 0.76 }, {
2568
+ txBox: true,
2569
+ anchor: 'ctr',
2570
+ marginsIn: { l: 0, r: 0, t: 0, b: 0 },
2571
+ paragraphs: [
2572
+ ooxmlRichParagraph(it.value + (it.unit ? ' ' + it.unit : ''), {
2573
+ sizePt: 20,
2574
+ color: tk.accentText,
2575
+ bold: true,
2576
+ lang: langAttr,
2577
+ font: theme.fonts.heading,
2578
+ }),
2579
+ ],
2580
+ }))
2581
+ }
2582
+
2583
+ const cardBodyText = [it.text, ...(it.bullets ?? [])].filter(Boolean).join(';')
2584
+ const textLeft = it.value ? cardX + 0.22 + metaColW + 0.16 : cardX + 0.22 + tagW + 0.18
2585
+ const textBox = { x: textLeft, y: cy + 0.16, w: cardX + cardW - textLeft - 0.18, h: cardH - 0.32 }
2586
+ const fit = computeTextFit([it.title || '', cardBodyText], textBox, 'cardBody', { maxPt: 14.5, minPt: 12.5 })
2587
+ shapes.push(ooxmlShape(nextId(), 'TAM ' + (idx + 1), textBox, {
2588
+ txBox: true,
2589
+ anchor: 'ctr',
2590
+ marginsIn: { l: 0, r: 0, t: 0, b: 0 },
2591
+ fontScale: fit.fontScale,
2592
+ paragraphs: [
2593
+ ...(it.title ? [ooxmlRichParagraph(it.title, { sizePt: Math.min(16, fit.fontPt + 1.5), color: tk.inkPrimary, bold: true, lang: langAttr, font: theme.fonts.heading, spaceAfterPt: cardBodyText ? 4 : 0 })] : []),
2594
+ ...(cardBodyText ? [ooxmlRichParagraph(cardBodyText, { sizePt: fit.fontPt, color: tk.inkSecondary, lang: langAttr, font: theme.fonts.body, lineHeight: 1.32 })] : []),
2595
+ ],
2596
+ }))
2597
+ })
2598
+
2599
+ shapes.push(renderSlideChromePptx(slide, index, total, theme, langAttr, manifest, nextId))
2600
+ return shapes.join('')
2601
+ }
2602
+
2603
+ if (layout === 'org') {
2604
+ const items = resolveEffectiveItems(slide)
2605
+ if (variant === 'team') {
2606
+ const members = items.slice(0, 4)
2607
+ const n = Math.max(1, members.length)
2608
+ const gap = 0.28
2609
+ const cardW = (12.09 - gap * (n - 1)) / n
2610
+ const cardH = Math.min(4.35, bodyH - 0.16)
2611
+ const cardY = bodyTopY + (bodyH - cardH) / 2
2612
+
2613
+ members.forEach((it, idx) => {
2614
+ const cx = 0.62 + idx * (cardW + gap)
2615
+ shapes.push(renderSurfaceCardPptx('Team Card ' + (idx + 1), { x: cx, y: cardY, w: cardW, h: cardH }, {
2616
+ fill: tk.surface1,
2617
+ focal: idx === 0,
2618
+ }, nextId, chromeCfg, theme))
2619
+
2620
+ const avatarD = 0.78
2621
+ const avatarX = cx + (cardW - avatarD) / 2
2622
+ const avatarY = cardY + 0.26
2623
+ shapes.push(ooxmlShape(nextId(), 'Team Avatar ' + (idx + 1), { x: avatarX, y: avatarY, w: avatarD, h: avatarD }, {
2624
+ preset: 'ellipse',
2625
+ fill: idx === 0 ? tk.accentPrimary : tk.surface2,
2626
+ stroke: tk.accentPrimary,
2627
+ strokePt: 1.25,
2628
+ anchor: 'ctr',
2629
+ marginsIn: { l: 0, r: 0, t: 0, b: 0 },
2630
+ paragraphs: [
2631
+ ooxmlRichParagraph(monogramLetters(it.title || it.tag || 'T'), {
2632
+ sizePt: 18,
2633
+ color: idx === 0 ? tk.inkOnAccent : tk.accentText,
2634
+ bold: true,
2635
+ lang: langAttr,
2636
+ align: 'ctr',
2637
+ font: theme.fonts.heading,
2638
+ }),
2639
+ ],
2640
+ }))
2641
+
2642
+ const roleText = it.role || it.tag || ''
2643
+ if (roleText) {
2644
+ const roleW = computeBadgePillWidth(roleText, 10.5, cardW - 0.36, 0.85)
2645
+ shapes.push(ooxmlShape(nextId(), 'Team Role ' + (idx + 1), { x: cx + (cardW - roleW) / 2, y: avatarY + avatarD + 0.14, w: roleW, h: 0.28 }, {
2646
+ preset: 'roundRect',
2647
+ adj: 50000,
2648
+ fill: tk.accentSoft,
2649
+ anchor: 'ctr',
2650
+ marginsIn: { l: 0.04, r: 0.04, t: 0.01, b: 0.01 },
2651
+ paragraphs: [
2652
+ ooxmlRichParagraph(roleText, { sizePt: 10.5, color: tk.accentText, bold: true, lang: langAttr, align: 'ctr', font: theme.fonts.body }),
2653
+ ],
2654
+ }))
2655
+ }
2656
+
2657
+ const innerY = avatarY + avatarD + (roleText ? 0.52 : 0.20)
2658
+ const innerBox = { x: cx + 0.20, y: innerY, w: cardW - 0.40, h: Math.max(0.8, cardY + cardH - innerY - 0.16) }
2659
+ const bodyLines = [it.text || '', ...(it.bullets ?? [])].filter(Boolean)
2660
+ const fit = computeTextFit([it.title || '', ...bodyLines], innerBox, 'cardBody', { maxPt: 14.5, minPt: 12.5 })
2661
+ const paras = []
2662
+ if (it.title) {
2663
+ paras.push(ooxmlRichParagraph(it.title, { sizePt: 16.5, color: tk.inkPrimary, bold: true, lang: langAttr, align: 'ctr', font: theme.fonts.heading, spaceAfterPt: 6 }))
2664
+ }
2665
+ if (it.text) {
2666
+ paras.push(ooxmlRichParagraph(it.text, { sizePt: fit.fontPt, color: tk.inkSecondary, lang: langAttr, align: 'ctr', font: theme.fonts.body, lineHeight: 1.36, spaceAfterPt: 4 }))
2667
+ }
2668
+ for (const b of it.bullets ?? []) {
2669
+ paras.push(ooxmlRichParagraph(b, { sizePt: fit.fontPt, color: tk.inkSecondary, bullet: true, bulletColor: tk.accentPrimary, lang: langAttr, font: theme.fonts.body, lineHeight: 1.32, spaceAfterPt: 3 }))
2670
+ }
2671
+ shapes.push(ooxmlShape(nextId(), 'Team ' + (idx + 1), innerBox, {
2672
+ txBox: true,
2673
+ anchor: 't',
2674
+ marginsIn: { l: 0, r: 0, t: 0, b: 0 },
2675
+ fontScale: fit.fontScale,
2676
+ paragraphs: paras,
2677
+ }))
2678
+ })
2679
+ } else {
2680
+ // 'tree' hierarchy org chart
2681
+ const rootItem = items[0] ?? { tag: 'CEO', title: title || '组织架构' }
2682
+ const rawChildren = items.length > 1
2683
+ ? items.slice(1, 6)
2684
+ : (rootItem.bullets ?? []).slice(0, 5).map((b, i) => ({ tag: 'DEPT ' + (i + 1), title: b }))
2685
+ const children = rawChildren.length > 0 ? rawChildren : [{ title: '核心业务单元' }]
2686
+ const nChild = children.length
2687
+
2688
+ const rootW = 4.4
2689
+ const rootH = 1.18
2690
+ const rootX = (CANVAS_IN.w - rootW) / 2
2691
+ const rootY = bodyTopY + 0.08
2692
+ shapes.push(renderSurfaceCardPptx('Org Root', { x: rootX, y: rootY, w: rootW, h: rootH }, {
2693
+ fill: tk.accentSoft,
2694
+ focal: true,
2695
+ }, nextId, chromeCfg, theme))
2696
+ shapes.push(ooxmlShape(nextId(), 'Org 0', { x: rootX + 0.18, y: rootY + 0.10, w: rootW - 0.36, h: rootH - 0.20 }, {
2697
+ txBox: true,
2698
+ anchor: 'ctr',
2699
+ marginsIn: { l: 0, r: 0, t: 0, b: 0 },
2700
+ paragraphs: [
2701
+ ...((rootItem.role || rootItem.tag) ? [ooxmlRichParagraph((rootItem.role || rootItem.tag).toUpperCase(), { sizePt: 10, color: tk.accentText, bold: true, lang: langAttr, align: 'ctr', font: theme.fonts.body, spc: 120, spaceAfterPt: 2 })] : []),
2702
+ ooxmlRichParagraph(rootItem.title || '', { sizePt: 16.5, color: tk.inkPrimary, bold: true, lang: langAttr, align: 'ctr', font: theme.fonts.heading, spaceAfterPt: rootItem.text ? 2 : 0 }),
2703
+ ...(rootItem.text ? [ooxmlRichParagraph(rootItem.text, { sizePt: 12.5, color: tk.inkSecondary, lang: langAttr, align: 'ctr', font: theme.fonts.body })] : []),
2704
+ ],
2705
+ }))
2706
+
2707
+ const busY = rootY + rootH + 0.38
2708
+ const childTopY = busY + 0.36
2709
+ const childH = Math.max(1.85, bodyBottomY - childTopY - 0.10)
2710
+ const gap = nChild >= 5 ? 0.18 : 0.26
2711
+ const childW = (12.09 - gap * (nChild - 1)) / nChild
2712
+ const rootCx = CANVAS_IN.w / 2
2713
+
2714
+ // Trunk from root bottom to busY
2715
+ shapes.push(ooxmlLine(nextId(), 'Org Trunk', { x: rootCx, y: rootY + rootH }, { x: rootCx, y: busY }, {
2716
+ color: tk.accentPrimary,
2717
+ widthPt: 1.5,
2718
+ }))
2719
+
2720
+ const childCxs = children.map((_, idx) => 0.62 + idx * (childW + gap) + childW / 2)
2721
+ if (childCxs.length >= 2) {
2722
+ shapes.push(ooxmlLine(nextId(), 'Org Bus', { x: childCxs[0], y: busY }, { x: childCxs[childCxs.length - 1], y: busY }, {
2723
+ color: tk.accentPrimary,
2724
+ widthPt: 1.5,
2725
+ }))
2726
+ }
2727
+
2728
+ children.forEach((ch, idx) => {
2729
+ const cx = 0.62 + idx * (childW + gap)
2730
+ const midX = childCxs[idx]
2731
+ shapes.push(ooxmlLine(nextId(), 'Org Branch ' + (idx + 1), { x: midX, y: busY }, { x: midX, y: childTopY }, {
2732
+ color: tk.accentPrimary,
2733
+ widthPt: 1.25,
2734
+ }))
2735
+ shapes.push(renderSurfaceCardPptx('Org Child ' + (idx + 1), { x: cx, y: childTopY, w: childW, h: childH }, {
2736
+ fill: tk.surface1,
2737
+ focal: false,
2738
+ }, nextId, chromeCfg, theme))
2739
+
2740
+ const roleLabel = ch.role || ch.tag || ''
2741
+ if (roleLabel) {
2742
+ const rW = computeBadgePillWidth(roleLabel, 10, childW - 0.28, 0.54)
2743
+ shapes.push(ooxmlShape(nextId(), 'Org Tag ' + (idx + 1), { x: cx + 0.16, y: childTopY + 0.16, w: rW, h: 0.28 }, {
2744
+ preset: cardPreset,
2745
+ adj: roundRectAdj(rW, 0.28, Math.min(6, chromeCfg.cardRadiusPx)),
2746
+ fill: tk.accentSoft,
2747
+ anchor: 'ctr',
2748
+ marginsIn: { l: 0.03, r: 0.03, t: 0.01, b: 0.01 },
2749
+ paragraphs: [
2750
+ ooxmlRichParagraph(roleLabel, { sizePt: 10, color: tk.accentText, bold: true, lang: langAttr, align: 'ctr', font: theme.fonts.body }),
2751
+ ],
2752
+ }))
2753
+ }
2754
+
2755
+ const innerTop = childTopY + (roleLabel ? 0.54 : 0.20)
2756
+ const innerBox = { x: cx + 0.16, y: innerTop, w: childW - 0.32, h: Math.max(0.8, childTopY + childH - innerTop - 0.14) }
2757
+ const bodyLines = [ch.text || '', ...(ch.bullets ?? [])].filter(Boolean)
2758
+ const fit = computeTextFit([ch.title || '', ...bodyLines], innerBox, 'cardBody', { maxPt: 14, minPt: 12 })
2759
+ const paras = []
2760
+ if (ch.title) {
2761
+ paras.push(ooxmlRichParagraph(ch.title, { sizePt: Math.min(16, fit.fontPt + 1.5), color: tk.inkPrimary, bold: true, lang: langAttr, font: theme.fonts.heading, spaceAfterPt: bodyLines.length ? 5 : 0 }))
2762
+ }
2763
+ if (ch.text) {
2764
+ paras.push(ooxmlRichParagraph(ch.text, { sizePt: fit.fontPt, color: tk.inkSecondary, lang: langAttr, font: theme.fonts.body, lineHeight: 1.32, spaceAfterPt: 4 }))
2765
+ }
2766
+ for (const b of ch.bullets ?? []) {
2767
+ paras.push(ooxmlRichParagraph(b, { sizePt: fit.fontPt, color: tk.inkSecondary, bullet: true, bulletColor: tk.accentPrimary, lang: langAttr, font: theme.fonts.body, lineHeight: 1.3, spaceAfterPt: 3 }))
2768
+ }
2769
+ shapes.push(ooxmlShape(nextId(), 'Org ' + (idx + 1), innerBox, {
2770
+ txBox: true,
2771
+ anchor: 't',
2772
+ marginsIn: { l: 0, r: 0, t: 0, b: 0 },
2773
+ fontScale: fit.fontScale,
2774
+ paragraphs: paras,
2775
+ }))
2776
+ })
2777
+ }
2778
+ shapes.push(renderSlideChromePptx(slide, index, total, theme, langAttr, manifest, nextId))
2779
+ return shapes.join('')
2780
+ }
2781
+
2782
+ if (layout === 'agenda') {
2783
+ const items = resolveEffectiveItems(slide)
2784
+ const n = Math.max(1, items.length)
2785
+ const twoCol = n > 4
2786
+ const cols = twoCol ? 2 : 1
2787
+ const rowsPerCol = Math.ceil(n / cols)
2788
+ const gapX = 0.34
2789
+ const gapY = 0.18
2790
+ const colW = (12.09 - gapX * (cols - 1)) / cols
2791
+ const rowH = Math.min(0.95, (bodyH - gapY * (rowsPerCol - 1)) / rowsPerCol)
2792
+ const startY = bodyTopY + Math.max(0, (bodyH - (rowH * rowsPerCol + gapY * (rowsPerCol - 1))) / 2)
2793
+
2794
+ items.forEach((it, idx) => {
2795
+ const col = twoCol ? Math.floor(idx / rowsPerCol) : 0
2796
+ const row = twoCol ? idx % rowsPerCol : idx
2797
+ const x = 0.62 + col * (colW + gapX)
2798
+ const y = startY + row * (rowH + gapY)
2799
+ const isActive = slide.activeIndex === idx + 1 || it.status === 'accent'
2800
+ const badgeText = it.tag || String(idx + 1).padStart(2, '0')
2801
+ const badgeW = chromeCfg.useDisplayNumeral
2802
+ ? 0.74
2803
+ : computeBadgePillWidth(badgeText, 13.5, Math.min(2.4, colW * 0.38), 0.58)
2804
+
2805
+ shapes.push(renderSurfaceCardPptx('Agenda Card ' + (idx + 1), { x, y, w: colW, h: rowH }, {
2806
+ fill: isActive ? tk.accentSoft : tk.surface1,
2807
+ focal: isActive,
2808
+ }, nextId, chromeCfg, theme))
2809
+ if (chromeCfg.useDisplayNumeral) {
2810
+ shapes.push(ooxmlShape(nextId(), 'Agenda Badge ' + (idx + 1), { x: x + 0.18, y: y + (rowH - 0.54) / 2, w: badgeW, h: 0.54 }, {
2811
+ txBox: true,
2812
+ anchor: 'ctr',
2813
+ marginsIn: { l: 0, r: 0, t: 0, b: 0 },
2814
+ paragraphs: [
2815
+ ooxmlRichParagraph(badgeText, {
2816
+ sizePt: 22,
2817
+ color: tk.accentText,
2818
+ bold: true,
2819
+ lang: langAttr,
2820
+ font: theme.fonts.heading,
2821
+ }),
2822
+ ],
2823
+ }))
2824
+ } else {
2825
+ shapes.push(ooxmlShape(nextId(), 'Agenda Badge ' + (idx + 1), { x: x + 0.18, y: y + (rowH - 0.44) / 2, w: badgeW, h: 0.44 }, {
2826
+ preset: cardPreset,
2827
+ adj: roundRectAdj(badgeW, 0.44, Math.min(8, chromeCfg.cardRadiusPx)),
2828
+ fill: isActive ? tk.accentPrimary : tk.surface2,
2829
+ anchor: 'ctr',
2830
+ marginsIn: { l: 0.04, r: 0.04, t: 0.02, b: 0.02 },
2831
+ paragraphs: [
2832
+ ooxmlRichParagraph(badgeText, {
2833
+ sizePt: 13.5,
2834
+ color: isActive ? tk.inkOnAccent : tk.accentText,
2835
+ bold: true,
2836
+ lang: langAttr,
2837
+ align: 'ctr',
2838
+ font: theme.fonts.heading,
2839
+ }),
2840
+ ],
2841
+ }))
2842
+ }
2843
+ const textLeftOffset = 0.18 + badgeW + 0.18
2844
+ const textBox = { x: x + textLeftOffset, y: y + 0.08, w: Math.max(1.2, colW - textLeftOffset - 0.18), h: rowH - 0.16 }
2845
+ shapes.push(ooxmlShape(nextId(), 'Card ' + (idx + 1), textBox, {
2846
+ txBox: true,
2847
+ anchor: 'ctr',
2848
+ marginsIn: { l: 0, r: 0, t: 0, b: 0 },
2849
+ paragraphs: [
2850
+ ooxmlRichParagraph(it.title || it.text || '', {
2851
+ sizePt: 16,
2852
+ color: tk.inkPrimary,
2853
+ bold: true,
2854
+ lang: langAttr,
2855
+ font: theme.fonts.heading,
2856
+ spaceAfterPt: it.text && it.title ? 2 : 0,
2857
+ }),
2858
+ ...(it.text && it.title ? [ooxmlRichParagraph(it.text, { sizePt: 13.5, color: tk.inkSecondary, lang: langAttr, font: theme.fonts.body })] : []),
2859
+ ],
2860
+ }))
2861
+ })
2862
+ shapes.push(renderSlideChromePptx(slide, index, total, theme, langAttr, manifest, nextId))
2863
+ return shapes.join('')
2864
+ }
2865
+
2866
+ if (layout === 'kpi') {
2867
+ const items = resolveEffectiveItems(slide).slice(0, 4)
2868
+ const n = Math.max(1, items.length)
2869
+ const gap = 0.28
2870
+ const cardW = (12.09 - gap * (n - 1)) / n
2871
+ const cardH = Math.min(3.55, bodyH - 0.3)
2872
+ const cardY = bodyTopY + (bodyH - cardH) / 2
2873
+
2874
+ items.forEach((it, idx) => {
2875
+ const x = 0.62 + idx * (cardW + gap)
2876
+ const st = statusPalette(it.status, tk)
2877
+ const valText = (it.value || it.title || '—') + (it.unit ? ' ' + it.unit : '')
2878
+ const labelText = it.value ? (it.title || '') : ''
2879
+
2880
+ shapes.push(renderSurfaceCardPptx('KPI Surface ' + (idx + 1), { x, y: cardY, w: cardW, h: cardH }, {
2881
+ fill: tk.surface1,
2882
+ focal: idx === 0,
2883
+ }, nextId, chromeCfg, theme))
2884
+
2885
+ if (labelText) {
2886
+ shapes.push(ooxmlShape(nextId(), 'KPI Label ' + (idx + 1), { x: x + 0.24, y: cardY + 0.24, w: cardW - 0.48, h: 0.38 }, {
2887
+ txBox: true,
2888
+ anchor: 'ctr',
2889
+ marginsIn: { l: 0, r: 0, t: 0, b: 0 },
2890
+ paragraphs: [
2891
+ ooxmlRichParagraph(labelText, {
2892
+ sizePt: 13.5,
2893
+ color: tk.inkMuted,
2894
+ bold: true,
2895
+ lang: langAttr,
2896
+ font: theme.fonts.body,
2897
+ }),
2898
+ ],
2899
+ }))
2900
+ }
2901
+
2902
+ const vBox = { x: x + 0.24, y: cardY + 0.72, w: cardW - 0.48, h: 1.15 }
2903
+ const vFit = computeTextFit(valText, vBox, 'kpiValue', { maxPt: n >= 4 ? 38 : 46, minPt: 24, padXPt: 2, padYPt: 2 })
2904
+ shapes.push(ooxmlShape(nextId(), 'KPI Value ' + (idx + 1), vBox, {
2905
+ txBox: true,
2906
+ anchor: 'ctr',
2907
+ marginsIn: { l: 0, r: 0, t: 0, b: 0 },
2908
+ fontScale: vFit.fontScale,
2909
+ paragraphs: [
2910
+ ooxmlRichParagraph(valText, {
2911
+ sizePt: vFit.fontPt,
2912
+ color: idx === 0 ? tk.accentText : tk.inkPrimary,
2913
+ bold: true,
2914
+ lang: langAttr,
2915
+ font: theme.fonts.heading,
2916
+ lineHeight: 1.05,
2917
+ }),
2918
+ ],
2919
+ }))
2920
+
2921
+ if (it.delta) {
2922
+ const pillW = computeBadgePillWidth(it.delta, 12, cardW - 0.48, 1.15)
2923
+ shapes.push(ooxmlShape(nextId(), 'KPI Delta ' + (idx + 1), { x: x + 0.24, y: cardY + 1.98, w: pillW, h: 0.36 }, {
2924
+ preset: 'roundRect',
2925
+ adj: 50000,
2926
+ fill: st.bg,
2927
+ stroke: chromeCfg.cardBorderless ? '' : tk.hairline,
2928
+ strokePt: 0.5,
2929
+ anchor: 'ctr',
2930
+ marginsIn: { l: 0.05, r: 0.05, t: 0.02, b: 0.02 },
2931
+ paragraphs: [
2932
+ ooxmlRichParagraph(it.delta, {
2933
+ sizePt: 12,
2934
+ color: st.fg,
2935
+ bold: true,
2936
+ lang: langAttr,
2937
+ align: 'ctr',
2938
+ font: theme.fonts.body,
2939
+ }),
2940
+ ],
2941
+ }))
2942
+ }
2943
+
2944
+ if (it.text) {
2945
+ const descY = it.delta ? cardY + 2.46 : cardY + 2.02
2946
+ const descBox = { x: x + 0.24, y: descY, w: cardW - 0.48, h: Math.max(0.5, cardY + cardH - descY - 0.18) }
2947
+ const dFit = computeTextFit(it.text, descBox, 'cardBody', { maxPt: 14.5, minPt: 13.5, padXPt: 2, padYPt: 2 })
2948
+ shapes.push(ooxmlShape(nextId(), 'Card ' + (idx + 1), descBox, {
2949
+ txBox: true,
2950
+ anchor: 't',
2951
+ marginsIn: { l: 0, r: 0, t: 0, b: 0 },
2952
+ fontScale: dFit.fontScale,
2953
+ paragraphs: [
2954
+ ooxmlRichParagraph(it.text, {
2955
+ sizePt: dFit.fontPt,
2956
+ color: tk.inkSecondary,
2957
+ lang: langAttr,
2958
+ font: theme.fonts.body,
2959
+ lineHeight: 1.38,
2960
+ }),
2961
+ ],
2962
+ }))
2963
+ }
2964
+ })
2965
+ shapes.push(renderSlideChromePptx(slide, index, total, theme, langAttr, manifest, nextId))
2966
+ return shapes.join('')
2967
+ }
2968
+
2969
+ if (layout === 'cards') {
2970
+ const items = resolveEffectiveItems(slide)
2971
+ const n = Math.max(1, items.length)
2972
+ const gap = 0.24
2973
+ let topOffset = bodyTopY
2974
+ let availH = bodyH
2975
+
2976
+ // exec-summary 变体:顶部通栏核心论断横幅 + 下方支柱卡
2977
+ if (variant === 'exec-summary' && (subtitle || slide.text)) {
2978
+ const thesisText = slide.text || subtitle
2979
+ const bannerBox = { x: 0.62, y: bodyTopY, w: 12.09, h: 0.96 }
2980
+ shapes.push(ooxmlShape(nextId(), 'Exec thesis banner', bannerBox, {
2981
+ preset: cardPreset,
2982
+ adj: roundRectAdj(bannerBox.w, bannerBox.h, chromeCfg.cardRadiusPx),
2983
+ fill: tk.accentSoft,
2984
+ stroke: chromeCfg.cardBorderless ? '' : tk.accentPrimary,
2985
+ strokePt: 0.75,
2986
+ anchor: 'ctr',
2987
+ marginsIn: { l: 0.22, r: 0.22, t: 0.08, b: 0.08 },
2988
+ paragraphs: [
2989
+ ooxmlRichParagraph(thesisText, {
2990
+ sizePt: 15.5,
2991
+ color: tk.inkPrimary,
2992
+ bold: true,
2993
+ lang: langAttr,
2994
+ font: theme.fonts.body,
2995
+ lineHeight: 1.35,
2996
+ }),
2997
+ ],
2998
+ }))
2999
+ topOffset = bodyTopY + 1.18
3000
+ availH = bodyBottomY - topOffset
3001
+ }
3002
+
3003
+ // 计算每张卡片的几何坐标(支持 bento 非对称网格与 pillars 等分网格)
3004
+ const cardBoxes = computeCardGridBoxes(n, variant, { x: 0.62, y: topOffset, w: 12.09, h: availH }, gap)
3005
+ items.slice(0, cardBoxes.length).forEach((it, idx) => {
3006
+ const box = cardBoxes[idx]
3007
+ const isHero = variant === 'bento' && idx === 0
3008
+ shapes.push(renderSurfaceCardPptx('Card Surface ' + (idx + 1), box, {
3009
+ fill: isHero ? tk.surface2 : tk.surface1,
3010
+ focal: isHero || idx === 0,
3011
+ }, nextId, chromeCfg, theme))
3012
+
3013
+ const badge = it.tag || String(idx + 1).padStart(2, '0')
3014
+ if (chromeCfg.useDisplayNumeral) {
3015
+ shapes.push(ooxmlShape(nextId(), 'Card Badge ' + (idx + 1), { x: box.x + 0.22, y: box.y + 0.16, w: Math.min(2.8, box.w - 0.44), h: 0.44 }, {
3016
+ txBox: true,
3017
+ anchor: 'ctr',
3018
+ marginsIn: { l: 0, r: 0, t: 0, b: 0 },
3019
+ paragraphs: [
3020
+ ooxmlRichParagraph(badge, {
3021
+ sizePt: /^\d+$/.test(badge) ? 24 : 12.5,
3022
+ color: tk.accentText,
3023
+ bold: true,
3024
+ lang: langAttr,
3025
+ font: theme.fonts.heading,
3026
+ spc: /^\d+$/.test(badge) ? 0 : 120,
3027
+ }),
3028
+ ],
3029
+ }))
3030
+ } else {
3031
+ const badgeW = computeBadgePillWidth(badge, 11, box.w - 0.44, 0.54)
3032
+ shapes.push(ooxmlShape(nextId(), 'Card Badge ' + (idx + 1), { x: box.x + 0.22, y: box.y + 0.20, w: badgeW, h: 0.30 }, {
3033
+ preset: cardPreset,
3034
+ adj: roundRectAdj(badgeW, 0.30, Math.min(6, chromeCfg.cardRadiusPx)),
3035
+ fill: isHero ? tk.accentPrimary : tk.accentSoft,
3036
+ anchor: 'ctr',
3037
+ marginsIn: { l: 0.04, r: 0.04, t: 0.01, b: 0.01 },
3038
+ paragraphs: [
3039
+ ooxmlRichParagraph(badge, {
3040
+ sizePt: 11,
3041
+ color: isHero ? tk.inkOnAccent : tk.accentText,
3042
+ bold: true,
3043
+ lang: langAttr,
3044
+ align: 'ctr',
3045
+ font: theme.fonts.body,
3046
+ }),
3047
+ ],
3048
+ }))
3049
+ }
3050
+
3051
+ const innerTop = box.y + (chromeCfg.useDisplayNumeral ? 0.66 : 0.58)
3052
+ const innerBox = { x: box.x + 0.22, y: innerTop, w: box.w - 0.44, h: Math.max(0.5, box.y + box.h - innerTop - 0.16) }
3053
+ const bodyLines = [
3054
+ ...(it.text ? [it.text] : []),
3055
+ ...(it.bullets ?? []),
3056
+ ]
3057
+ const fit = computeTextFit([it.title || '', ...bodyLines], innerBox, 'cardBody', { maxPt: 15.5, minPt: 13.5, padXPt: 2, padYPt: 2 })
3058
+ const paras = []
3059
+ if (it.title) {
3060
+ paras.push(ooxmlRichParagraph(it.title, {
3061
+ sizePt: Math.min(18, fit.fontPt + 2),
3062
+ color: tk.inkPrimary,
3063
+ bold: true,
3064
+ lang: langAttr,
3065
+ font: theme.fonts.heading,
3066
+ lineHeight: 1.25,
3067
+ spaceAfterPt: bodyLines.length ? 6 : 0,
3068
+ }))
3069
+ }
3070
+ if (it.value) {
3071
+ paras.push(ooxmlRichParagraph(it.value + (it.unit ? ' ' + it.unit : ''), {
3072
+ sizePt: 24,
3073
+ color: tk.accentText,
3074
+ bold: true,
3075
+ lang: langAttr,
3076
+ font: theme.fonts.heading,
3077
+ spaceAfterPt: 4,
3078
+ }))
3079
+ }
3080
+ if (it.text) {
3081
+ paras.push(ooxmlRichParagraph(it.text, {
3082
+ sizePt: fit.fontPt,
3083
+ color: tk.inkSecondary,
3084
+ accentColor: tk.accentText,
3085
+ lang: langAttr,
3086
+ font: theme.fonts.body,
3087
+ lineHeight: 1.42,
3088
+ spaceAfterPt: it.bullets?.length ? 5 : 0,
3089
+ }))
3090
+ }
3091
+ for (const b of it.bullets ?? []) {
3092
+ paras.push(ooxmlRichParagraph(b, {
3093
+ sizePt: fit.fontPt,
3094
+ color: tk.inkSecondary,
3095
+ accentColor: tk.accentText,
3096
+ bullet: true,
3097
+ bulletColor: tk.accentPrimary,
3098
+ lang: langAttr,
3099
+ font: theme.fonts.body,
3100
+ lineHeight: 1.38,
3101
+ spaceAfterPt: 4,
3102
+ autoLeadBold: true,
3103
+ }))
3104
+ }
3105
+ shapes.push(ooxmlShape(nextId(), 'Card ' + (idx + 1), innerBox, {
3106
+ txBox: true,
3107
+ anchor: 't',
3108
+ marginsIn: { l: 0, r: 0, t: 0, b: 0 },
3109
+ fontScale: fit.fontScale,
3110
+ paragraphs: paras,
3111
+ }))
3112
+ })
3113
+ shapes.push(renderSlideChromePptx(slide, index, total, theme, langAttr, manifest, nextId))
3114
+ return shapes.join('')
3115
+ }
3116
+
3117
+ if (layout === 'comparison') {
3118
+ const items = resolveEffectiveItems(slide)
3119
+ if (variant === 'issue-action') {
3120
+ const pairs = items.slice(0, 4)
3121
+ const rowCount = Math.max(1, pairs.length)
3122
+ const gapY = 0.18
3123
+ const rowH = Math.min(1.12, (bodyH - gapY * (rowCount - 1)) / rowCount)
3124
+ const startY = bodyTopY + (bodyH - (rowH * rowCount + gapY * (rowCount - 1))) / 2
3125
+ const colW = 5.56
3126
+
3127
+ pairs.forEach((it, idx) => {
3128
+ const y = startY + idx * (rowH + gapY)
3129
+ const leftText = it.title || ''
3130
+ const rightText = it.text || (it.bullets ?? []).join(';') || ''
3131
+
3132
+ shapes.push(ooxmlShape(nextId(), 'Issue Card ' + (idx + 1), { x: 0.62, y, w: colW, h: rowH }, {
3133
+ preset: cardPreset,
3134
+ adj: roundRectAdj(colW, rowH, chromeCfg.cardRadiusPx),
3135
+ fill: tk.surface1,
3136
+ stroke: chromeCfg.cardBorderless ? '' : tk.hairline,
3137
+ strokePt: 0.75,
3138
+ anchor: 'ctr',
3139
+ marginsIn: { l: 0.22, r: 0.16, t: 0.08, b: 0.08 },
3140
+ paragraphs: [
3141
+ ooxmlRichParagraph(leftText, {
3142
+ sizePt: 15,
3143
+ color: tk.inkPrimary,
3144
+ bold: true,
3145
+ lang: langAttr,
3146
+ font: theme.fonts.body,
3147
+ }),
3148
+ ],
3149
+ }))
3150
+ shapes.push(ooxmlShape(nextId(), 'Issue Bar ' + (idx + 1), { x: 0.62, y, w: 0.07, h: rowH }, {
3151
+ preset: 'rect',
3152
+ fill: tk.negative,
3153
+ }))
3154
+
3155
+ shapes.push(ooxmlShape(nextId(), 'Bridge Arrow ' + (idx + 1), { x: 6.40, y: y + (rowH - 0.28) / 2, w: 0.52, h: 0.28 }, {
3156
+ preset: 'rightArrow',
3157
+ fill: tk.accentPrimary,
3158
+ }))
3159
+
3160
+ shapes.push(ooxmlShape(nextId(), 'Action Card ' + (idx + 1), { x: 7.15, y, w: colW, h: rowH }, {
3161
+ preset: cardPreset,
3162
+ adj: roundRectAdj(colW, rowH, chromeCfg.cardRadiusPx),
3163
+ fill: tk.accentSoft,
3164
+ stroke: chromeCfg.cardBorderless ? '' : tk.accentPrimary,
3165
+ strokePt: 0.75,
3166
+ anchor: 'ctr',
3167
+ marginsIn: { l: 0.22, r: 0.16, t: 0.08, b: 0.08 },
3168
+ paragraphs: [
3169
+ ooxmlRichParagraph(rightText, {
3170
+ sizePt: 15,
3171
+ color: tk.inkPrimary,
3172
+ secondaryColor: tk.inkSecondary,
3173
+ bold: false,
3174
+ lang: langAttr,
3175
+ font: theme.fonts.body,
3176
+ autoLeadBold: true,
3177
+ }),
3178
+ ],
3179
+ }))
3180
+ })
3181
+ } else {
3182
+ // 双栏对比(versus / before-after / do-dont)
3183
+ const twoSides = items.length <= 2
3184
+ ? items
3185
+ : [
3186
+ { title: items[0]?.title || '方案 A', bullets: items.slice(0, Math.ceil(items.length / 2)).map((x) => [x.title, x.text].filter(Boolean).join(':')) },
3187
+ { title: items[Math.ceil(items.length / 2)]?.title || '方案 B', bullets: items.slice(Math.ceil(items.length / 2)).map((x) => [x.title, x.text].filter(Boolean).join(':')) },
3188
+ ]
3189
+ const colW = 5.86
3190
+ const gap = 0.37
3191
+ ;[0, 1].forEach((side) => {
3192
+ const it = twoSides[side] ?? { title: side === 0 ? '对照项' : '推荐项', text: '' }
3193
+ const x = 0.62 + side * (colW + gap)
3194
+ const isDoDont = variant === 'do-dont'
3195
+ const headerFill = isDoDont
3196
+ ? (side === 0 ? tk.negative : tk.positive)
3197
+ : (side === 0 ? tk.surface2 : tk.accentPrimary)
3198
+ const headerFg = isDoDont || side === 1 ? '#FFFFFF' : tk.inkPrimary
3199
+ const box = { x, y: bodyTopY, w: colW, h: bodyH }
3200
+
3201
+ shapes.push(ooxmlShape(nextId(), 'Comparison Card ' + (side + 1), box, {
3202
+ preset: cardPreset,
3203
+ adj: roundRectAdj(box.w, box.h, chromeCfg.cardRadiusPx),
3204
+ fill: side === 1 && !isDoDont ? tk.accentSoft : tk.surface1,
3205
+ stroke: chromeCfg.cardBorderless ? '' : (side === 1 ? tk.accentPrimary : tk.hairline),
3206
+ strokePt: side === 1 ? 1.0 : 0.75,
3207
+ }))
3208
+ shapes.push(ooxmlShape(nextId(), 'Comparison Header ' + (side + 1), { x, y: bodyTopY, w: colW, h: 0.62 }, {
3209
+ preset: 'rect',
3210
+ fill: headerFill,
3211
+ anchor: 'ctr',
3212
+ marginsIn: { l: 0.24, r: 0.24, t: 0.04, b: 0.04 },
3213
+ paragraphs: [
3214
+ ooxmlRichParagraph((isDoDont ? (side === 0 ? '✗ ' : '✓ ') : '') + (it.title || (side === 0 ? '现状 / 对照' : '方案 / 目标')), {
3215
+ sizePt: 16.5,
3216
+ color: headerFg,
3217
+ bold: true,
3218
+ lang: langAttr,
3219
+ font: theme.fonts.heading,
3220
+ }),
3221
+ ],
3222
+ }))
3223
+
3224
+ const contentBox = { x: x + 0.24, y: bodyTopY + 0.80, w: colW - 0.48, h: bodyH - 1.0 }
3225
+ const lines = [...(it.text ? [it.text] : []), ...(it.bullets ?? [])]
3226
+ const fit = computeTextFit(lines, contentBox, 'cardBody', { maxPt: 16, minPt: 13.5 })
3227
+ const paras = []
3228
+ if (it.text) {
3229
+ paras.push(ooxmlRichParagraph(it.text, {
3230
+ sizePt: fit.fontPt,
3231
+ color: tk.inkPrimary,
3232
+ secondaryColor: tk.inkSecondary,
3233
+ lang: langAttr,
3234
+ font: theme.fonts.body,
3235
+ lineHeight: 1.44,
3236
+ spaceAfterPt: 6,
3237
+ autoLeadBold: true,
3238
+ }))
3239
+ }
3240
+ for (const b of it.bullets ?? []) {
3241
+ paras.push(ooxmlRichParagraph(b, {
3242
+ sizePt: fit.fontPt,
3243
+ color: tk.inkPrimary,
3244
+ secondaryColor: tk.inkSecondary,
3245
+ bullet: true,
3246
+ bulletColor: side === 1 ? tk.accentPrimary : tk.inkMuted,
3247
+ lang: langAttr,
3248
+ font: theme.fonts.body,
3249
+ lineHeight: 1.42,
3250
+ spaceAfterPt: 6,
3251
+ autoLeadBold: true,
3252
+ }))
3253
+ }
3254
+ shapes.push(ooxmlShape(nextId(), 'Comparison ' + (side + 1), contentBox, {
3255
+ txBox: true,
3256
+ anchor: 't',
3257
+ marginsIn: { l: 0, r: 0, t: 0, b: 0 },
3258
+ fontScale: fit.fontScale,
3259
+ paragraphs: paras,
3260
+ }))
3261
+ })
3262
+ }
3263
+ shapes.push(renderSlideChromePptx(slide, index, total, theme, langAttr, manifest, nextId))
3264
+ return shapes.join('')
3265
+ }
3266
+
3267
+ if (layout === 'matrix') {
3268
+ const items = resolveEffectiveItems(slide).slice(0, 4)
3269
+ const plotX = 1.18
3270
+ const plotY = bodyTopY + 0.08
3271
+ const plotW = 11.45
3272
+ const plotH = bodyH - 0.36
3273
+ const gap = 0.28
3274
+ const qW = (plotW - gap) / 2
3275
+ const qH = (plotH - gap) / 2
3276
+
3277
+ // X / Y 坐标轴带箭头
3278
+ const midX = plotX + plotW / 2
3279
+ const midY = plotY + plotH / 2
3280
+ shapes.push(ooxmlLine(nextId(), 'Matrix X axis', { x: plotX - 0.16, y: midY }, { x: plotX + plotW + 0.16, y: midY }, {
3281
+ color: tk.inkMuted,
3282
+ widthPt: 1.25,
3283
+ tailArrow: true,
3284
+ }))
3285
+ shapes.push(ooxmlLine(nextId(), 'Matrix Y axis', { x: midX, y: plotY + plotH + 0.14 }, { x: midX, y: plotY - 0.14 }, {
3286
+ color: tk.inkMuted,
3287
+ widthPt: 1.25,
3288
+ tailArrow: true,
3289
+ }))
3290
+
3291
+ for (let idx = 0; idx < 4; idx += 1) {
3292
+ const it = items[idx] ?? { title: '象限 ' + (idx + 1), text: '' }
3293
+ const col = idx % 2
3294
+ const row = Math.floor(idx / 2)
3295
+ const isTarget = idx === 1 // 右上战略核心象限高亮
3296
+ const box = {
3297
+ x: plotX + col * (qW + gap),
3298
+ y: plotY + row * (qH + gap),
3299
+ w: qW,
3300
+ h: qH,
3301
+ }
3302
+ shapes.push(ooxmlShape(nextId(), 'Matrix Quadrant ' + (idx + 1), box, {
3303
+ preset: cardPreset,
3304
+ adj: roundRectAdj(box.w, box.h, chromeCfg.cardRadiusPx),
3305
+ fill: isTarget ? tk.accentSoft : tk.surface1,
3306
+ stroke: chromeCfg.cardBorderless ? '' : (isTarget ? tk.accentPrimary : tk.hairline),
3307
+ strokePt: isTarget ? 1.25 : 0.75,
3308
+ anchor: 'ctr',
3309
+ marginsIn: { l: 0.22, r: 0.22, t: 0.14, b: 0.14 },
3310
+ paragraphs: [
3311
+ ...(it.tag ? [ooxmlRichParagraph(it.tag.toUpperCase(), { sizePt: 10.5, color: isTarget ? tk.accentText : tk.inkMuted, bold: true, lang: langAttr, font: theme.fonts.body, spc: 120, spaceAfterPt: 3 })] : []),
3312
+ ooxmlRichParagraph(it.title || '', { sizePt: 16, color: tk.inkPrimary, bold: true, lang: langAttr, font: theme.fonts.heading, spaceAfterPt: 4 }),
3313
+ ...(it.text ? [ooxmlRichParagraph(it.text, { sizePt: 13.5, color: tk.inkSecondary, lang: langAttr, font: theme.fonts.body, lineHeight: 1.38 })] : []),
3314
+ ...(it.bullets ?? []).map((b) => ooxmlRichParagraph(b, { sizePt: 13.5, color: tk.inkSecondary, bullet: true, bulletColor: tk.accentPrimary, lang: langAttr, font: theme.fonts.body, spaceAfterPt: 2 })),
3315
+ ],
3316
+ }))
3317
+ }
3318
+ shapes.push(renderSlideChromePptx(slide, index, total, theme, langAttr, manifest, nextId))
3319
+ return shapes.join('')
3320
+ }
3321
+
3322
+ if (layout === 'process') {
3323
+ const items = resolveEffectiveItems(slide).slice(0, 6)
3324
+ const n = Math.max(1, items.length)
3325
+
3326
+ if (variant === 'flywheel') {
3327
+ const centerX = CANVAS_IN.w / 2
3328
+ const centerY = bodyTopY + bodyH / 2
3329
+ const hubD = Math.min(2.28, bodyH * 0.46)
3330
+ const ringD = Math.min(4.25, bodyH * 0.86)
3331
+ // Subtle circular orbital ring behind flywheel
3332
+ shapes.push(ooxmlShape(nextId(), 'Flywheel Orbit', { x: centerX - ringD / 2, y: centerY - ringD / 2, w: ringD, h: ringD }, {
3333
+ preset: 'ellipse',
3334
+ fill: '',
3335
+ stroke: tk.hairline,
3336
+ strokePt: 1.5,
3337
+ dash: 'dash',
3338
+ }))
3339
+ // Central hub
3340
+ shapes.push(ooxmlShape(nextId(), 'Flywheel Hub', { x: centerX - hubD / 2, y: centerY - hubD / 2, w: hubD, h: hubD }, {
3341
+ preset: 'ellipse',
3342
+ fill: tk.accentPrimary,
3343
+ stroke: tk.canvas,
3344
+ strokePt: 2.0,
3345
+ anchor: 'ctr',
3346
+ marginsIn: { l: 0.16, r: 0.16, t: 0.12, b: 0.12 },
3347
+ paragraphs: [
3348
+ ooxmlRichParagraph(
3349
+ (slide.text && slide.text.trim().length <= 18 ? slide.text.trim() : '')
3350
+ || (slide.subtitle && slide.subtitle.trim().length <= 18 ? slide.subtitle.trim() : '')
3351
+ || (langAttr === 'en-US' ? 'Growth\nFlywheel' : '增长飞轮'),
3352
+ {
3353
+ sizePt: 15,
3354
+ color: tk.inkOnAccent,
3355
+ bold: true,
3356
+ lang: langAttr,
3357
+ align: 'ctr',
3358
+ font: theme.fonts.heading,
3359
+ lineHeight: 1.22,
3360
+ },
3361
+ ),
3362
+ ],
3363
+ }))
3364
+
3365
+ // 4-node corner flywheel (or radial ring for 3/5/6 nodes)
3366
+ const nodes = items.slice(0, 4)
3367
+ const cardW = 4.32
3368
+ const cardH = Math.min(1.88, (bodyH - 0.56) / 2)
3369
+ const corners = [
3370
+ { x: 0.62, y: bodyTopY + 0.08, w: cardW, h: cardH },
3371
+ { x: 12.71 - cardW, y: bodyTopY + 0.08, w: cardW, h: cardH },
3372
+ { x: 12.71 - cardW, y: bodyBottomY - cardH - 0.08, w: cardW, h: cardH },
3373
+ { x: 0.62, y: bodyBottomY - cardH - 0.08, w: cardW, h: cardH },
3374
+ ]
3375
+ nodes.forEach((it, idx) => {
3376
+ const box = corners[idx]
3377
+ shapes.push(renderSurfaceCardPptx('Flywheel Surface ' + (idx + 1), box, {
3378
+ fill: idx === 0 ? tk.accentSoft : tk.surface1,
3379
+ focal: idx === 0,
3380
+ }, nextId, chromeCfg, theme))
3381
+ const tag = it.tag || String(idx + 1).padStart(2, '0')
3382
+ const tagW = computeBadgePillWidth(tag, 10.5, 1.5, 0.48)
3383
+ shapes.push(ooxmlShape(nextId(), 'Flywheel Tag ' + (idx + 1), { x: box.x + 0.18, y: box.y + 0.16, w: tagW, h: 0.28 }, {
3384
+ preset: cardPreset,
3385
+ adj: roundRectAdj(tagW, 0.28, Math.min(6, chromeCfg.cardRadiusPx)),
3386
+ fill: tk.accentPrimary,
3387
+ anchor: 'ctr',
3388
+ marginsIn: { l: 0.03, r: 0.03, t: 0.01, b: 0.01 },
3389
+ paragraphs: [
3390
+ ooxmlRichParagraph(tag, { sizePt: 10.5, color: tk.inkOnAccent, bold: true, lang: langAttr, align: 'ctr', font: theme.fonts.heading }),
3391
+ ],
3392
+ }))
3393
+ if (it.conversion || it.delta) {
3394
+ const badge = it.conversion || it.delta
3395
+ const bw = computeBadgePillWidth(badge, 10, 1.4, 0.62)
3396
+ shapes.push(ooxmlShape(nextId(), 'Flywheel Delta ' + (idx + 1), { x: box.x + box.w - bw - 0.16, y: box.y + 0.16, w: bw, h: 0.28 }, {
3397
+ preset: 'roundRect',
3398
+ adj: 50000,
3399
+ fill: tk.surface2,
3400
+ stroke: tk.hairline,
3401
+ strokePt: 0.5,
3402
+ anchor: 'ctr',
3403
+ marginsIn: { l: 0.03, r: 0.03, t: 0.01, b: 0.01 },
3404
+ paragraphs: [
3405
+ ooxmlRichParagraph(badge, { sizePt: 10, color: tk.accentText, bold: true, lang: langAttr, align: 'ctr', font: theme.fonts.body }),
3406
+ ],
3407
+ }))
3408
+ }
3409
+ const innerBox = { x: box.x + 0.18, y: box.y + 0.52, w: box.w - 0.36, h: box.h - 0.64 }
3410
+ const cardBodyText = [it.text, ...(it.bullets ?? [])].filter(Boolean).join(';')
3411
+ const fit = computeTextFit([it.title || '', cardBodyText], innerBox, 'cardBody', { maxPt: 14.5, minPt: 12.5 })
3412
+ shapes.push(ooxmlShape(nextId(), 'Flywheel ' + (idx + 1), innerBox, {
3413
+ txBox: true,
3414
+ anchor: 't',
3415
+ marginsIn: { l: 0, r: 0, t: 0, b: 0 },
3416
+ fontScale: fit.fontScale,
3417
+ paragraphs: [
3418
+ ...(it.title ? [ooxmlRichParagraph(it.title, { sizePt: Math.min(16, fit.fontPt + 1.5), color: tk.inkPrimary, bold: true, lang: langAttr, font: theme.fonts.heading, spaceAfterPt: 4 })] : []),
3419
+ ...(cardBodyText ? [ooxmlRichParagraph(cardBodyText, { sizePt: fit.fontPt, color: tk.inkSecondary, lang: langAttr, font: theme.fonts.body, lineHeight: 1.35 })] : []),
3420
+ ],
3421
+ }))
3422
+ })
3423
+
3424
+ // Clockwise directional arrows between the 4 nodes
3425
+ shapes.push(ooxmlShape(nextId(), 'Flywheel Arrow Top', { x: centerX - 0.26, y: corners[0].y + cardH / 2 - 0.14, w: 0.52, h: 0.28 }, { preset: 'rightArrow', fill: tk.accentPrimary }))
3426
+ shapes.push(ooxmlShape(nextId(), 'Flywheel Arrow Right', { x: corners[1].x + cardW / 2 - 0.14, y: centerY - 0.22, w: 0.28, h: 0.44 }, { preset: 'downArrow', fill: tk.accentPrimary }))
3427
+ shapes.push(ooxmlShape(nextId(), 'Flywheel Arrow Bottom', { x: centerX - 0.26, y: corners[2].y + cardH / 2 - 0.14, w: 0.52, h: 0.28 }, { preset: 'leftArrow', fill: tk.accentPrimary }))
3428
+ shapes.push(ooxmlShape(nextId(), 'Flywheel Arrow Left', { x: corners[0].x + cardW / 2 - 0.14, y: centerY - 0.22, w: 0.28, h: 0.44 }, { preset: 'upArrow', fill: tk.accentPrimary }))
3429
+ } else if (variant === 'chevron') {
3430
+ // McKinsey / BCG Interlocking Value-Chain Chevrons + Supporting Detail Cards
3431
+ const overlap = n > 1 ? 0.08 : 0
3432
+ const chevW = (12.09 + (n - 1) * overlap) / n
3433
+ const chevY = bodyTopY + 0.08
3434
+ const chevH = 0.88
3435
+ const detailGap = 0.16
3436
+ const colW = (12.09 - detailGap * (n - 1)) / n
3437
+ const detailY = chevY + chevH + 0.20
3438
+ const detailH = Math.max(1.55, bodyBottomY - detailY - 0.06)
3439
+
3440
+ items.forEach((it, idx) => {
3441
+ const isFirst = idx === 0
3442
+ const isLast = idx === n - 1 && n >= 3
3443
+ const cx = 0.62 + idx * (chevW - overlap)
3444
+ const fillHex = isFirst ? tk.accentPrimary : isLast ? tk.accentSecondary : tk.surface2
3445
+ const inkHex = isFirst
3446
+ ? tk.inkOnAccent
3447
+ : isLast
3448
+ ? (relativeLuminance(tk.accentSecondary) > 0.36 ? '#0F172A' : '#FFFFFF')
3449
+ : tk.inkPrimary
3450
+ const stageTag = it.tag || String(idx + 1).padStart(2, '0')
3451
+ const chevLabel = (stageTag ? stageTag + ' · ' : '') + (it.title || '')
3452
+
3453
+ shapes.push(ooxmlShape(nextId(), 'Chevron Stage ' + (idx + 1), { x: cx, y: chevY, w: chevW, h: chevH }, {
3454
+ preset: isFirst ? 'homePlate' : 'chevron',
3455
+ adjs: { adj: 20000 },
3456
+ fill: fillHex,
3457
+ stroke: tk.canvas,
3458
+ strokePt: 2.0,
3459
+ anchor: 'ctr',
3460
+ marginsIn: { l: isFirst ? 0.14 : 0.28, r: 0.24, t: 0.06, b: 0.06 },
3461
+ paragraphs: [
3462
+ ooxmlRichParagraph(chevLabel, {
3463
+ sizePt: n >= 5 ? 13 : 14.5,
3464
+ color: inkHex,
3465
+ bold: true,
3466
+ lang: langAttr,
3467
+ align: 'ctr',
3468
+ font: theme.fonts.heading,
3469
+ lineHeight: 1.18,
3470
+ }),
3471
+ ],
3472
+ }))
3473
+
3474
+ const dx = 0.62 + idx * (colW + detailGap)
3475
+ const cardBox = { x: dx, y: detailY, w: colW, h: detailH }
3476
+ shapes.push(renderSurfaceCardPptx('Chevron Detail Surface ' + (idx + 1), cardBox, {
3477
+ fill: isFirst ? tk.accentSoft : tk.surface1,
3478
+ focal: isFirst,
3479
+ }, nextId, chromeCfg, theme))
3480
+
3481
+ const convNote = it.conversion || it.delta || (it.value ? it.value + (it.unit ? ' ' + it.unit : '') : '')
3482
+ const detailLines = [
3483
+ ...(convNote ? ['**' + convNote + '**'] : []),
3484
+ ...(it.text ? [it.text] : []),
3485
+ ...(Array.isArray(it.bullets) ? it.bullets : []),
3486
+ ]
3487
+ const innerBox = { x: cardBox.x + 0.16, y: cardBox.y + 0.16, w: cardBox.w - 0.32, h: cardBox.h - 0.30 }
3488
+ const fit = computeTextFit(detailLines, innerBox, 'cardBody', { maxPt: 14, minPt: 12.5 })
3489
+ if (detailLines.length > 0) {
3490
+ shapes.push(ooxmlShape(nextId(), 'Chevron Detail ' + (idx + 1), innerBox, {
3491
+ txBox: true,
3492
+ anchor: 't',
3493
+ marginsIn: { l: 0, r: 0, t: 0, b: 0 },
3494
+ fontScale: fit.fontScale,
3495
+ paragraphs: detailLines.map((line, lIdx) =>
3496
+ ooxmlRichParagraph(line, {
3497
+ sizePt: fit.fontPt,
3498
+ color: lIdx === 0 && convNote ? tk.accentText : tk.inkSecondary,
3499
+ accentColor: tk.accentText,
3500
+ lang: langAttr,
3501
+ font: theme.fonts.body,
3502
+ lineHeight: 1.36,
3503
+ spaceAfterPt: 4,
3504
+ }),
3505
+ ),
3506
+ }))
3507
+ }
3508
+ })
3509
+ } else if (variant === 'layers' || variant === 'funnel') {
3510
+ const gapY = 0.14
3511
+ const rowH = Math.min(0.92, (bodyH - gapY * (n - 1)) / n)
3512
+ const startY = bodyTopY + (bodyH - (rowH * n + gapY * (n - 1))) / 2
3513
+ const hasConversions = variant === 'funnel' && items.some((it) => it.conversion || it.delta)
3514
+ const maxBarW = hasConversions ? 10.2 : 12.09
3515
+
3516
+ items.forEach((it, idx) => {
3517
+ const shrink = variant === 'funnel' ? idx * ((maxBarW * 0.34) / Math.max(1, n - 1)) : 0
3518
+ const w = maxBarW - shrink
3519
+ const x = 0.62 + shrink / 2
3520
+ const y = startY + idx * (rowH + gapY)
3521
+ const isFirst = idx === 0
3522
+ const funnelValue = variant === 'funnel' && it.value ? ' · ' + it.value + (it.unit ? ' ' + it.unit : '') : ''
3523
+
3524
+ shapes.push(ooxmlShape(nextId(), 'Layer ' + (idx + 1), { x, y, w, h: rowH }, {
3525
+ preset: cardPreset,
3526
+ adj: roundRectAdj(w, rowH, chromeCfg.cardRadiusPx),
3527
+ fill: isFirst ? tk.accentPrimary : (idx % 2 === 1 ? tk.surface2 : tk.surface1),
3528
+ stroke: chromeCfg.cardBorderless ? '' : (isFirst ? tk.accentPrimary : tk.hairline),
3529
+ strokePt: 0.75,
3530
+ anchor: 'ctr',
3531
+ marginsIn: { l: 0.24, r: 0.24, t: 0.06, b: 0.06 },
3532
+ paragraphs: [
3533
+ ooxmlRichParagraph(
3534
+ (it.tag ? it.tag + ' · ' : '') + (it.title || '') + funnelValue + (it.text ? ' — ' + it.text : ''),
3535
+ {
3536
+ sizePt: 15,
3537
+ color: isFirst ? tk.inkOnAccent : tk.inkPrimary,
3538
+ secondaryColor: isFirst ? tk.inkOnAccent : tk.inkSecondary,
3539
+ bold: isFirst,
3540
+ lang: langAttr,
3541
+ align: variant === 'funnel' ? 'ctr' : 'l',
3542
+ font: theme.fonts.body,
3543
+ autoLeadBold: !isFirst,
3544
+ },
3545
+ ),
3546
+ ],
3547
+ }))
3548
+
3549
+ const convBadge = variant === 'funnel' ? (it.conversion || it.delta || '') : ''
3550
+ if (convBadge) {
3551
+ const badgeX = 0.62 + maxBarW + 0.24
3552
+ const badgeW = 12.71 - badgeX
3553
+ shapes.push(ooxmlShape(nextId(), 'Funnel Conversion ' + (idx + 1), { x: badgeX, y: y + (rowH - 0.38) / 2, w: badgeW, h: 0.38 }, {
3554
+ preset: 'roundRect',
3555
+ adj: 50000,
3556
+ fill: tk.accentSoft,
3557
+ stroke: tk.accentPrimary,
3558
+ strokePt: 0.75,
3559
+ anchor: 'ctr',
3560
+ marginsIn: { l: 0.06, r: 0.06, t: 0.02, b: 0.02 },
3561
+ paragraphs: [
3562
+ ooxmlRichParagraph('↓ ' + convBadge, {
3563
+ sizePt: 11.5,
3564
+ color: tk.accentText,
3565
+ bold: true,
3566
+ lang: langAttr,
3567
+ align: 'ctr',
3568
+ font: theme.fonts.body,
3569
+ }),
3570
+ ],
3571
+ }))
3572
+ }
3573
+ })
3574
+ } else if (variant === 'timeline') {
3575
+ const spineY = bodyTopY + 0.72
3576
+ shapes.push(ooxmlLine(nextId(), 'Timeline axis', { x: 0.85, y: spineY }, { x: 12.48, y: spineY }, {
3577
+ color: tk.accentPrimary,
3578
+ widthPt: 2.0,
3579
+ }))
3580
+ const gap = 0.20
3581
+ const stepW = (12.09 - gap * (n - 1)) / n
3582
+ items.forEach((it, idx) => {
3583
+ const x = 0.62 + idx * (stepW + gap)
3584
+ const cx = x + stepW / 2
3585
+ shapes.push(ooxmlShape(nextId(), 'Timeline Node ' + (idx + 1), { x: cx - 0.15, y: spineY - 0.15, w: 0.30, h: 0.30 }, {
3586
+ preset: 'ellipse',
3587
+ fill: idx === n - 1 ? tk.accentPrimary : tk.surface1,
3588
+ stroke: tk.accentPrimary,
3589
+ strokePt: 2.0,
3590
+ }))
3591
+ shapes.push(ooxmlShape(nextId(), 'Timeline Tag ' + (idx + 1), { x, y: bodyTopY + 0.10, w: stepW, h: 0.38 }, {
3592
+ txBox: true,
3593
+ anchor: 'ctr',
3594
+ marginsIn: { l: 0.02, r: 0.02, t: 0, b: 0 },
3595
+ paragraphs: [
3596
+ ooxmlRichParagraph(it.tag || ('0' + (idx + 1)), {
3597
+ sizePt: 13,
3598
+ color: tk.accentText,
3599
+ bold: true,
3600
+ lang: langAttr,
3601
+ align: 'ctr',
3602
+ font: theme.fonts.heading,
3603
+ }),
3604
+ ],
3605
+ }))
3606
+ const cardBox = { x, y: spineY + 0.36, w: stepW, h: Math.max(1.8, bodyBottomY - (spineY + 0.42)) }
3607
+ const fit = computeTextFit([it.title || '', it.text || ''], cardBox, 'cardBody', { maxPt: 14.5, minPt: 13.5 })
3608
+ shapes.push(ooxmlShape(nextId(), 'Step ' + (idx + 1), cardBox, {
3609
+ preset: cardPreset,
3610
+ adj: roundRectAdj(cardBox.w, cardBox.h, chromeCfg.cardRadiusPx),
3611
+ fill: tk.surface1,
3612
+ stroke: chromeCfg.cardBorderless ? '' : tk.hairline,
3613
+ strokePt: 0.75,
3614
+ anchor: 't',
3615
+ marginsIn: { l: 0.16, r: 0.16, t: 0.16, b: 0.14 },
3616
+ fontScale: fit.fontScale,
3617
+ paragraphs: [
3618
+ ...(it.title ? [ooxmlRichParagraph(it.title, { sizePt: Math.min(16.5, fit.fontPt + 1.5), color: tk.inkPrimary, bold: true, lang: langAttr, font: theme.fonts.heading, spaceAfterPt: 6 })] : []),
3619
+ ...(it.text ? [ooxmlRichParagraph(it.text, { sizePt: fit.fontPt, color: tk.inkSecondary, lang: langAttr, font: theme.fonts.body, lineHeight: 1.4 })] : []),
3620
+ ],
3621
+ }))
3622
+ })
3623
+ } else {
3624
+ // steps(带箭头连接的横向步骤卡片)
3625
+ const arrowGap = n <= 4 ? 0.36 : 0.24
3626
+ const cardW = (12.09 - arrowGap * (n - 1)) / n
3627
+ const cardH = Math.min(3.55, bodyH - 0.24)
3628
+ const cardY = bodyTopY + (bodyH - cardH) / 2
3629
+
3630
+ items.forEach((it, idx) => {
3631
+ const x = 0.62 + idx * (cardW + arrowGap)
3632
+ const box = { x, y: cardY, w: cardW, h: cardH }
3633
+ shapes.push(renderSurfaceCardPptx('Step Surface ' + (idx + 1), box, {
3634
+ fill: tk.surface1,
3635
+ focal: idx === n - 1,
3636
+ }, nextId, chromeCfg, theme))
3637
+ const stepTag = it.tag || String(idx + 1).padStart(2, '0')
3638
+ if (chromeCfg.useDisplayNumeral) {
3639
+ shapes.push(ooxmlShape(nextId(), 'Step Number ' + (idx + 1), { x: x + 0.18, y: cardY + 0.14, w: cardW - 0.36, h: 0.42 }, {
3640
+ txBox: true,
3641
+ anchor: 'ctr',
3642
+ marginsIn: { l: 0, r: 0, t: 0, b: 0 },
3643
+ paragraphs: [
3644
+ ooxmlRichParagraph(stepTag, {
3645
+ sizePt: /^\d+$/.test(stepTag) ? 22 : 12,
3646
+ color: tk.accentText,
3647
+ bold: true,
3648
+ lang: langAttr,
3649
+ font: theme.fonts.heading,
3650
+ }),
3651
+ ],
3652
+ }))
3653
+ } else {
3654
+ const stepBadgeW = computeBadgePillWidth(stepTag, 12, cardW - 0.36, 0.50)
3655
+ shapes.push(ooxmlShape(nextId(), 'Step Number ' + (idx + 1), { x: x + 0.18, y: cardY + 0.18, w: stepBadgeW, h: 0.36 }, {
3656
+ preset: cardPreset,
3657
+ adj: roundRectAdj(stepBadgeW, 0.36, Math.min(6, chromeCfg.cardRadiusPx)),
3658
+ fill: tk.accentPrimary,
3659
+ anchor: 'ctr',
3660
+ marginsIn: { l: 0.04, r: 0.04, t: 0.02, b: 0.02 },
3661
+ paragraphs: [
3662
+ ooxmlRichParagraph(stepTag, {
3663
+ sizePt: 12,
3664
+ color: tk.inkOnAccent,
3665
+ bold: true,
3666
+ lang: langAttr,
3667
+ align: 'ctr',
3668
+ font: theme.fonts.heading,
3669
+ }),
3670
+ ],
3671
+ }))
3672
+ }
3673
+ const inner = { x: x + 0.18, y: cardY + 0.66, w: cardW - 0.36, h: cardH - 0.84 }
3674
+ const fit = computeTextFit([it.title || '', it.text || ''], inner, 'cardBody', { maxPt: 15, minPt: 13.5 })
3675
+ shapes.push(ooxmlShape(nextId(), 'Step ' + (idx + 1), inner, {
3676
+ txBox: true,
3677
+ anchor: 't',
3678
+ marginsIn: { l: 0, r: 0, t: 0, b: 0 },
3679
+ fontScale: fit.fontScale,
3680
+ paragraphs: [
3681
+ ...(it.title ? [ooxmlRichParagraph(it.title, { sizePt: Math.min(17, fit.fontPt + 1.5), color: tk.inkPrimary, bold: true, lang: langAttr, font: theme.fonts.heading, spaceAfterPt: 6 })] : []),
3682
+ ...(it.text ? [ooxmlRichParagraph(it.text, { sizePt: fit.fontPt, color: tk.inkSecondary, lang: langAttr, font: theme.fonts.body, lineHeight: 1.42 })] : []),
3683
+ ],
3684
+ }))
3685
+
3686
+ if (idx < n - 1) {
3687
+ shapes.push(ooxmlShape(nextId(), 'Step Connector ' + (idx + 1), {
3688
+ x: x + cardW + arrowGap * 0.18,
3689
+ y: cardY + cardH / 2 - 0.12,
3690
+ w: arrowGap * 0.64,
3691
+ h: 0.24,
3692
+ }, {
3693
+ preset: 'rightArrow',
3694
+ fill: tk.accentPrimary,
3695
+ }))
3696
+ }
3697
+ })
3698
+ }
3699
+ shapes.push(renderSlideChromePptx(slide, index, total, theme, langAttr, manifest, nextId))
3700
+ return shapes.join('')
3701
+ }
3702
+
3703
+ if (layout === 'callout') {
3704
+ const heroText = slide.text || subtitle || ''
3705
+ const items = resolveEffectiveItems(slide)
3706
+ const hasHero = heroText !== ''
3707
+ if (hasHero) {
3708
+ const calloutH = items.length > 0 ? 1.55 : 2.85
3709
+ const box = { x: 0.62, y: bodyTopY + 0.06, w: 12.09, h: calloutH }
3710
+ shapes.push(ooxmlShape(nextId(), 'Callout surface', box, {
3711
+ preset: cardPreset,
3712
+ adj: roundRectAdj(box.w, box.h, chromeCfg.cardRadiusPx),
3713
+ fill: tk.surface2,
3714
+ stroke: chromeCfg.cardBorderless ? '' : tk.accentPrimary,
3715
+ strokePt: 1.0,
3716
+ anchor: 'ctr',
3717
+ marginsIn: { l: 0.32, r: 0.28, t: 0.16, b: 0.16 },
3718
+ paragraphs: [
3719
+ ooxmlRichParagraph(heroText, {
3720
+ sizePt: variant === 'formula' ? 20 : 18,
3721
+ color: tk.inkPrimary,
3722
+ accentColor: tk.accentText,
3723
+ bold: true,
3724
+ lang: langAttr,
3725
+ align: variant === 'formula' ? 'ctr' : 'l',
3726
+ font: variant === 'formula' ? 'Georgia' : theme.fonts.heading,
3727
+ lineHeight: 1.38,
3728
+ }),
3729
+ ],
3730
+ }))
3731
+ }
3732
+ if (items.length > 0) {
3733
+ const listTop = hasHero ? bodyTopY + 1.82 : bodyTopY + 0.08
3734
+ const listBox = { x: 0.62, y: listTop, w: 12.09, h: Math.max(1.2, bodyBottomY - listTop) }
3735
+ const lines = items.map((it, idx) => (it.tag || (idx + 1) + '.') + ' ' + [it.title, it.text].filter(Boolean).join(':'))
3736
+ const fit = computeTextFit(lines, listBox, 'body', { maxPt: 16.5, minPt: 13.5 })
3737
+ shapes.push(ooxmlShape(nextId(), 'Callout 1', listBox, {
3738
+ txBox: true,
3739
+ anchor: 't',
3740
+ marginsIn: { l: 0.08, r: 0.08, t: 0.04, b: 0.04 },
3741
+ fontScale: fit.fontScale,
3742
+ paragraphs: items.map((it, idx) =>
3743
+ ooxmlRichParagraph(
3744
+ '**' + (it.tag || String(idx + 1).padStart(2, '0')) + (it.title ? ' ' + it.title : '') + '**' + (it.text ? ':' + it.text : ''),
3745
+ {
3746
+ sizePt: fit.fontPt,
3747
+ color: tk.inkPrimary,
3748
+ secondaryColor: tk.inkSecondary,
3749
+ lang: langAttr,
3750
+ font: theme.fonts.body,
3751
+ lineHeight: 1.44,
3752
+ spaceAfterPt: 8,
3753
+ },
3754
+ ),
3755
+ ),
3756
+ }))
3757
+ }
3758
+ shapes.push(renderSlideChromePptx(slide, index, total, theme, langAttr, manifest, nextId))
3759
+ return shapes.join('')
3760
+ }
3761
+
3762
+ // 默认版式:bullets(保留 idBase + 3 Body 以严格兼容逐条点击动画 spid)
3763
+ const surfaceBox = { x: 0.62, y: bodyTopY + 0.06, w: 12.09, h: bodyH - 0.12 }
3764
+ shapes.push(ooxmlShape(nextId(), 'Bullets container', surfaceBox, {
3765
+ preset: cardPreset,
3766
+ adj: roundRectAdj(surfaceBox.w, surfaceBox.h, chromeCfg.cardRadiusPx),
3767
+ fill: tk.surface1,
3768
+ stroke: chromeCfg.cardBorderless ? '' : tk.hairline,
3769
+ strokePt: 0.75,
3770
+ }))
3771
+ if (chromeCfg.cardLeftBar || chromeCfg.chrome === 'saas-bento' || chromeCfg.chrome === 'gov-ceremonial') {
3772
+ shapes.push(ooxmlShape(nextId(), 'Bullets accent rail', { x: 0.62, y: bodyTopY + 0.06, w: 0.07, h: surfaceBox.h }, {
3773
+ preset: 'rect',
3774
+ fill: tk.accentPrimary,
3775
+ }))
3776
+ }
3777
+
3778
+ const bodyBox = { x: 0.98, y: bodyTopY + 0.24, w: 11.42, h: surfaceBox.h - 0.36 }
3779
+ const sourceLines = bullets.length > 0 ? bullets : [subtitle || slide.text || '']
3780
+ const bodyFit = computeTextFit(sourceLines, bodyBox, 'body', { maxPt: bullets.length <= 4 ? 19 : 17.5, minPt: 13.5 })
3781
+ const bodyParagraphs = bullets.length > 0
3782
+ ? bullets.map((b) =>
3783
+ ooxmlRichParagraph(b, {
3784
+ sizePt: bodyFit.fontPt,
3785
+ color: tk.inkPrimary,
3786
+ secondaryColor: tk.inkSecondary,
3787
+ accentColor: tk.accentText,
3788
+ codeHighlight: tk.surface2,
3789
+ bullet: true,
3790
+ bulletChar: '▪',
3791
+ bulletColor: tk.accentPrimary,
3792
+ lang: langAttr,
3793
+ font: theme.fonts.body,
3794
+ lineHeight: bodyFit.lineHeight,
3795
+ spaceAfterPt: bullets.length <= 4 ? 12 : 7,
3796
+ autoLeadBold: true,
3797
+ }),
3798
+ )
3799
+ : [
3800
+ ooxmlRichParagraph(subtitle || slide.text || '', {
3801
+ sizePt: bodyFit.fontPt,
3802
+ color: tk.inkPrimary,
3803
+ secondaryColor: tk.inkSecondary,
3804
+ lang: langAttr,
3805
+ font: theme.fonts.body,
3806
+ lineHeight: bodyFit.lineHeight,
3807
+ }),
3808
+ ]
3809
+
3810
+ shapes.push(ooxmlShape(idBase + 3, 'Body', bodyBox, {
3811
+ txBox: true,
3812
+ anchor: bullets.length > 0 && bullets.length <= 4 ? 'ctr' : 't',
3813
+ marginsIn: { l: 0, r: 0, t: 0, b: 0 },
3814
+ fontScale: bodyFit.fontScale,
3815
+ paragraphs: bodyParagraphs,
3816
+ }))
3817
+ shapes.push(renderSlideChromePptx(slide, index, total, theme, langAttr, manifest, nextId))
3818
+ return shapes.join('')
3819
+ }
3820
+
3821
+ function hexToRgbaSafeHex(fgHex, bgHex, alpha) {
3822
+ const f = parseInt(hex6(fgHex), 16)
3823
+ const b = parseInt(hex6(bgHex), 16)
3824
+ const mix = (fc, bc) => Math.round(fc * alpha + bc * (1 - alpha)).toString(16).padStart(2, '0')
3825
+ return '#' + mix((f >> 16) & 255, (b >> 16) & 255) + mix((f >> 8) & 255, (b >> 8) & 255) + mix(f & 255, b & 255)
3826
+ }
3827
+
3828
+ function computeCardGridBoxes(count, variant, area, gap) {
3829
+ const n = Math.max(1, Math.min(6, count))
3830
+ const { x, y, w, h } = area
3831
+
3832
+ if (variant === 'bento' && n === 3) {
3833
+ const leftW = w * 0.43 - gap / 2
3834
+ const rightW = w - leftW - gap
3835
+ const halfH = (h - gap) / 2
3836
+ return [
3837
+ { x, y, w: leftW, h },
3838
+ { x: x + leftW + gap, y, w: rightW, h: halfH },
3839
+ { x: x + leftW + gap, y: y + halfH + gap, w: rightW, h: halfH },
3840
+ ]
3841
+ }
3842
+ if (variant === 'bento' && n === 4) {
3843
+ const topLeftW = w * 0.58 - gap / 2
3844
+ const topRightW = w - topLeftW - gap
3845
+ const halfH = (h - gap) / 2
3846
+ return [
3847
+ { x, y, w: topLeftW, h: halfH },
3848
+ { x: x + topLeftW + gap, y, w: topRightW, h: halfH },
3849
+ { x, y: y + halfH + gap, w: topRightW, h: halfH },
3850
+ { x: x + topRightW + gap, y: y + halfH + gap, w: topLeftW, h: halfH },
3851
+ ]
3852
+ }
3853
+ if (n <= 4 && variant !== 'bento') {
3854
+ const cardW = (w - gap * (n - 1)) / n
3855
+ return Array.from({ length: n }, (_, i) => ({ x: x + i * (cardW + gap), y, w: cardW, h }))
3856
+ }
3857
+ // 5 或 6 张卡片:2 行等高排布
3858
+ const topCols = Math.ceil(n / 2)
3859
+ const botCols = n - topCols
3860
+ const rowH = (h - gap) / 2
3861
+ const topW = (w - gap * (topCols - 1)) / topCols
3862
+ const botW = (w - gap * (Math.max(1, botCols) - 1)) / Math.max(1, botCols)
3863
+ return [
3864
+ ...Array.from({ length: topCols }, (_, i) => ({ x: x + i * (topW + gap), y, w: topW, h: rowH })),
3865
+ ...Array.from({ length: botCols }, (_, i) => ({ x: x + i * (botW + gap), y: y + rowH + gap, w: botW, h: rowH })),
3866
+ ]
3867
+ }
3868
+
3869
+ // ---------------------------------------------------------------------------
3870
+ // HTML 同构渲染器与设计系统级样式表 LAYOUT_CSS
3871
+ // ---------------------------------------------------------------------------
3872
+
3873
+ function renderHarveyCellHtml(cellText, isHeader, cIdx, oursCol) {
3874
+ const isOurs = cIdx === oursCol
3875
+ if (!isHeader && cIdx > 0) {
3876
+ const parsed = parseHarveyValue(cellText)
3877
+ if (parsed) {
3878
+ if (parsed.kind === 'check') {
3879
+ return '<td class="harvey-cell' + (isOurs ? ' is-ours' : '') + '"><span class="harvey-check ' + (parsed.ok ? 'is-yes' : 'is-no') + '" aria-label="' + escapeHtml(parsed.label) + '">' + escapeHtml(parsed.label) + '</span></td>'
3880
+ }
3881
+ return '<td class="harvey-cell' + (isOurs ? ' is-ours' : '') + '"><span class="harvey-ball harvey-' + parsed.pct + '" title="' + escapeHtml(parsed.label) + '" aria-label="' + escapeHtml(parsed.label) + '"></span></td>'
3882
+ }
3883
+ }
3884
+ const tag = isHeader ? 'th' : 'td'
3885
+ return '<' + tag + (isOurs ? ' class="is-ours"' : (isNumericCell(cellText) ? ' class="num"' : '')) + '>' + renderInlineHtml(cellText) + '</' + tag + '>'
3886
+ }
3887
+
3888
+ export function renderCoreSlideHtml(slide, index, total, ui, langId, manifest = {}, theme) {
3889
+ const layout = slide.layout || 'bullets'
3890
+ const variant = slide.variant || ''
3891
+ const kicker = slide.kicker || (layout === 'cover' ? ui.coverKicker : '')
3892
+ const title = slide.title || ''
3893
+ const subtitle = slide.subtitle || ''
3894
+ const bullets = Array.isArray(slide.bullets) ? slide.bullets : []
3895
+ const isFraming = layout === 'cover' || layout === 'closing'
3896
+ const inverted = isFraming && (variant === 'inverted' || (!variant && theme.tokens.coverMode === 'inverted-accent'))
3897
+ const chromeStyle = resolveChromeStyle(theme, slide, manifest.brand)
3898
+ const folioText = String(index + 1).padStart(2, '0') + ' / ' + String(total).padStart(2, '0')
3899
+
3900
+ const renderHeader = (fallbackKicker = '') => {
3901
+ const k = kicker || fallbackKicker
3902
+ const showK = k !== '' && k !== title
3903
+ if (chromeStyle === 'editorial-folio') {
3904
+ return (
3905
+ '<div class="editorial-folio-bar">' +
3906
+ (showK ? '<span class="kicker">' + escapeHtml(k) + '</span>' : '<span class="kicker"></span>') +
3907
+ (!isFraming ? '<span class="slide-folio">' + folioText + '</span>' : '') +
3908
+ '</div>' +
3909
+ '<header class="slide-header">' +
3910
+ (title !== '' ? '<h2>' + renderInlineHtml(title) + '</h2>' : '') +
3911
+ '</header>'
3912
+ )
3913
+ }
3914
+ if (chromeStyle === 'academic-minimal') {
3915
+ return (
3916
+ '<header class="slide-header beamer-header-band">' +
3917
+ (showK ? '<div class="kicker">' + escapeHtml(k) + '</div>' : '') +
3918
+ (title !== '' ? '<h2>' + renderInlineHtml(title) + '</h2>' : '') +
3919
+ '</header>'
3920
+ )
3921
+ }
3922
+ if (chromeStyle === 'consulting-classic') {
3923
+ return (
3924
+ '<header class="slide-header consulting-header">' +
3925
+ (title !== '' ? '<h2>' + renderInlineHtml(title) + '</h2>' : '') +
3926
+ (showK ? '<span class="consulting-tracker kicker">' + escapeHtml(k) + '</span>' : '') +
3927
+ '</header>'
3928
+ )
3929
+ }
3930
+ if (chromeStyle === 'gov-ceremonial') {
3931
+ return (
3932
+ '<header class="slide-header gov-header">' +
3933
+ (showK ? '<div class="kicker gov-ribbon">' + escapeHtml(formatGovKicker(k)) + '</div>' : '') +
3934
+ (title !== '' ? '<h2>' + renderInlineHtml(title) + '</h2>' : '') +
3935
+ '</header>'
3936
+ )
3937
+ }
3938
+ return (
3939
+ '<header class="slide-header">' +
3940
+ (showK ? '<div class="kicker">' + escapeHtml(k) + '</div>' : '') +
3941
+ (title !== '' ? '<h2>' + renderInlineHtml(title) + '</h2>' : '') +
3942
+ '</header>'
3943
+ )
3944
+ }
3945
+
3946
+ let inner = ''
3947
+
3948
+ if (layout === 'cover') {
3949
+ const meta = [slide.text, slide.source, !manifest.brand?.footer ? ui.generatedBy : ''].filter(Boolean)[0] || ''
3950
+ inner =
3951
+ '<div class="cover-shell' + (inverted ? ' is-inverted' : '') + '">' +
3952
+ '<div class="cover-lockup">' +
3953
+ (kicker !== '' ? '<div class="kicker">' + escapeHtml(kicker) + '</div>' : '') +
3954
+ '<h1>' + renderInlineHtml(title) + '</h1>' +
3955
+ (subtitle !== '' ? '<div class="subtitle">' + renderInlineHtml(subtitle) + '</div>' : '') +
3956
+ '</div>' +
3957
+ (meta !== '' ? '<div class="meta">' + escapeHtml(meta) + '</div>' : '') +
3958
+ '</div>'
3959
+ } else if (layout === 'closing') {
3960
+ const items = resolveEffectiveItems(slide)
3961
+ const showCtaCards = (variant === 'cta-cards' || items.length >= 2) && (slide.items?.length || bullets.length >= 2)
3962
+ inner =
3963
+ '<div class="closing-shell' + (inverted ? ' is-inverted' : '') + '">' +
3964
+ '<h1>' + renderInlineHtml(title || ui.closingTitle) + '</h1>' +
3965
+ '<div class="closing-rule"></div>' +
3966
+ (subtitle !== '' ? '<div class="subtitle">' + renderInlineHtml(subtitle) + '</div>' : '') +
3967
+ (showCtaCards
3968
+ ? '<div class="layout-grid cols-' + Math.min(3, items.length) + ' closing-cards">' +
3969
+ items.slice(0, 3).map((it) =>
3970
+ '<div class="surface-card"><div class="card-title">' + renderInlineHtml(it.title || '') + '</div>' +
3971
+ (it.text ? '<div class="card-body">' + renderInlineHtml(it.text) + '</div>' : '') + '</div>',
3972
+ ).join('') +
3973
+ '</div>'
3974
+ : '') +
3975
+ (!manifest.brand?.footer ? '<div class="meta">' + escapeHtml(ui.generatedBy) + '</div>' : '') +
3976
+ '</div>'
3977
+ } else if (layout === 'section') {
3978
+ inner =
3979
+ (chromeStyle === 'editorial-folio'
3980
+ ? '<div class="editorial-folio-bar"><span class="kicker">' + escapeHtml(kicker || '') + '</span><span class="slide-folio">' + folioText + '</span></div>'
3981
+ : '') +
3982
+ (kicker !== '' && kicker !== title ? '<div class="kicker section-index">' + escapeHtml(kicker) + '</div>' : '') +
3983
+ '<div class="accent-line"></div>' +
3984
+ '<h2>' + renderInlineHtml(title) + '</h2>' +
3985
+ (subtitle !== '' ? '<div class="subtitle">' + renderInlineHtml(subtitle) + '</div>' : '')
3986
+ } else if (layout === 'statement') {
3987
+ inner =
3988
+ (chromeStyle === 'editorial-folio'
3989
+ ? '<div class="editorial-folio-bar"><span class="kicker">' + escapeHtml(kicker || '') + '</span><span class="slide-folio">' + folioText + '</span></div>'
3990
+ : (kicker !== '' ? '<div class="kicker">' + escapeHtml(kicker) + '</div>' : '')) +
3991
+ '<div class="statement-card"><div class="statement-title">' + renderInlineHtml(title || slide.text || '') + '</div></div>' +
3992
+ (subtitle !== '' ? '<div class="subtitle">' + renderInlineHtml(subtitle) + '</div>' : '')
3993
+ } else if (layout === 'quote') {
3994
+ inner =
3995
+ (chromeStyle === 'editorial-folio'
3996
+ ? '<div class="editorial-folio-bar"><span class="kicker">' + escapeHtml(kicker || ui.quoteKicker) + '</span><span class="slide-folio">' + folioText + '</span></div>'
3997
+ : (kicker !== '' ? '<div class="kicker">' + escapeHtml(kicker || ui.quoteKicker) + '</div>' : '')) +
3998
+ '<div class="quote-card">' +
3999
+ '<div class="quote-mark" aria-hidden="true">\u201C</div>' +
4000
+ '<blockquote class="quote-text">' + escapeHtml(title || slide.text || '') + '</blockquote>' +
4001
+ (subtitle !== '' ? '<div class="quote-attr">\u2014\u2014 ' + escapeHtml(subtitle) + '</div>' : '') +
4002
+ '</div>'
4003
+ } else if (layout === 'harvey' || (layout === 'table' && (slide.tableStyle || slide.visual?.tableStyle) === 'harvey')) {
4004
+ const items = resolveEffectiveItems(slide)
4005
+ const rows = Array.isArray(slide.rows) && slide.rows.length > 0
4006
+ ? slide.rows
4007
+ : items.length > 0
4008
+ ? [['评估维度', '行业基线', '本方案 / Ours'], ...items.map((it) => [it.title || '', it.delta || '50%', it.value || 'full'])]
4009
+ : [['维度', '本方案 / Ours'], ['能力项', 'full']]
4010
+ const cols = Math.max(2, ...rows.map((r) => r.length))
4011
+ const head = Array.from({ length: cols }, (_, c) => String(rows[0]?.[c] ?? ''))
4012
+ const oursCol = findHarveyOursCol(head, cols)
4013
+ const body = rows.slice(1)
4014
+ inner =
4015
+ renderHeader(ui.tableKicker) +
4016
+ '<table class="deck-table harvey-table"><thead><tr>' +
4017
+ head.map((cell, cIdx) => renderHarveyCellHtml(cell, true, cIdx, oursCol)).join('') +
4018
+ '</tr></thead><tbody>' +
4019
+ body.map((row) => '<tr>' + Array.from({ length: cols }, (_, cIdx) => renderHarveyCellHtml(String(row[cIdx] ?? ''), false, cIdx, oursCol)).join('') + '</tr>').join('') +
4020
+ '</tbody></table>'
4021
+ } else if (layout === 'table') {
4022
+ const rows = Array.isArray(slide.rows) ? slide.rows : []
4023
+ const head = rows[0] ?? []
4024
+ const body = rows.slice(1)
4025
+ inner =
4026
+ renderHeader(ui.tableKicker) +
4027
+ '<table class="deck-table"><thead><tr>' +
4028
+ head.map((cell) => '<th' + (isNumericCell(cell) ? ' class="num"' : '') + '>' + renderInlineHtml(cell) + '</th>').join('') +
4029
+ '</tr></thead><tbody>' +
4030
+ body.map((row) => '<tr>' + row.map((cell) => '<td' + (isNumericCell(cell) ? ' class="num"' : '') + '>' + renderInlineHtml(cell) + '</td>').join('') + '</tr>').join('') +
4031
+ '</tbody></table>'
4032
+ } else if (layout === 'gantt') {
4033
+ const defaultCols = variant === 'months'
4034
+ ? ['M1', 'M2', 'M3', 'M4', 'M5', 'M6']
4035
+ : variant === 'weeks'
4036
+ ? ['W1', 'W2', 'W3', 'W4', 'W5', 'W6']
4037
+ : ['Q1', 'Q2', 'Q3', 'Q4']
4038
+ const cols = Array.isArray(slide.columns) && slide.columns.length > 0 && slide.columns.every((c) => typeof c === 'string')
4039
+ ? slide.columns.slice(0, 8)
4040
+ : defaultCols
4041
+ const colCount = Math.max(2, cols.length)
4042
+ const items = resolveEffectiveItems(slide).slice(0, 7)
4043
+ const cornerLabel = variant === 'swimlane'
4044
+ ? (langId === 'en' ? 'WORKSTREAM / TASK' : '泳道 / 任务项')
4045
+ : (langId === 'en' ? 'INITIATIVE / MILESTONE' : '任务里程碑')
4046
+ inner =
4047
+ renderHeader() +
4048
+ '<div class="gantt-board" style="--gantt-cols:' + colCount + '">' +
4049
+ '<div class="gantt-head"><div class="gantt-corner">' + escapeHtml(cornerLabel) + '</div>' +
4050
+ '<div class="gantt-col-heads">' + cols.map((c) => '<div class="gantt-col-head">' + escapeHtml(c) + '</div>').join('') + '</div></div>' +
4051
+ '<div class="gantt-rows">' +
4052
+ items.map((it, idx) => {
4053
+ const startSlot = it.start !== undefined ? Math.max(0, Math.min(colCount - 0.25, it.start)) : Math.min(colCount - 1, idx % colCount)
4054
+ const isPureMilestone = it.span === 0 || (Boolean(it.milestone) && it.span === undefined)
4055
+ const hasEndMilestone = !isPureMilestone && Boolean(it.milestone)
4056
+ const spanSlot = isPureMilestone ? 0 : Math.max(0.35, Math.min(colCount - startSlot, it.span !== undefined ? it.span : 1))
4057
+ const leftPct = ((startSlot / colCount) * 100).toFixed(2)
4058
+ const widthPct = ((spanSlot / colCount) * 100).toFixed(2)
4059
+ const mPct = (((startSlot + 0.5) / colCount) * 100).toFixed(2)
4060
+ const label = it.value || it.delta || ''
4061
+ return (
4062
+ '<div class="gantt-row" data-item-index="' + idx + '">' +
4063
+ '<div class="gantt-label surface-card">' +
4064
+ (it.tag ? '<span class="gantt-tag">' + escapeHtml(it.tag) + '</span>' : '') +
4065
+ '<span class="gantt-task" data-item-field="title">' + renderInlineHtml(it.title || it.text || '') + '</span>' +
4066
+ '</div>' +
4067
+ '<div class="gantt-track">' +
4068
+ (isPureMilestone
4069
+ ? '<span class="gantt-milestone" style="left:' + mPct + '%"></span>' +
4070
+ (label || it.text ? '<span class="gantt-m-label" style="left:' + mPct + '%">' + escapeHtml(label || it.text) + '</span>' : '')
4071
+ : '<div class="gantt-bar tone-' + escapeHtml(it.status || 'accent') + '" style="left:' + leftPct + '%;width:' + widthPct + '%">' +
4072
+ (label ? '<span>' + escapeHtml(label) + '</span>' : '') +
4073
+ (hasEndMilestone ? '<span class="gantt-bar-milestone" aria-hidden="true"></span>' : '') +
4074
+ '</div>') +
4075
+ '</div></div>'
4076
+ )
4077
+ }).join('') +
4078
+ '</div></div>'
4079
+ } else if (layout === 'architecture') {
4080
+ const allItems = resolveEffectiveItems(slide).slice(0, 6)
4081
+ const isSidecarItem = (it) =>
4082
+ it.status === 'accent' || /^(?:sidecar|governance|security|observability|安全|治理|可观测|监控|合规|运维)$/i.test(String(it.tag || '').trim())
4083
+ const candidateSidecars = allItems.filter(isSidecarItem)
4084
+ const candidateTiers = allItems.filter((it) => !isSidecarItem(it))
4085
+ const hasSidecar = candidateSidecars.length >= 1 && candidateTiers.length >= 2
4086
+ const sidecarItems = hasSidecar ? candidateSidecars : []
4087
+ const tierItems = hasSidecar ? candidateTiers : allItems
4088
+ const arrowGlyph = variant === 'platform' ? '↕' : '↓'
4089
+
4090
+ inner =
4091
+ renderHeader() +
4092
+ '<div class="arch-board' + (hasSidecar ? ' has-sidecar' : '') + '">' +
4093
+ '<div class="arch-tiers">' +
4094
+ tierItems.map((it, idx) => {
4095
+ const mods = it.bullets?.length ? it.bullets : (it.text ? [it.text] : [])
4096
+ return (
4097
+ '<div class="surface-card arch-tier' + (idx === 0 ? ' is-focal' : '') + '" data-item-index="' + allItems.indexOf(it) + '">' +
4098
+ '<div class="arch-tier-head">' +
4099
+ (it.tag ? '<span class="kicker arch-tag">' + escapeHtml(it.tag) + '</span>' : '') +
4100
+ '<div class="card-title" data-item-field="title">' + renderInlineHtml(it.title || '') + '</div>' +
4101
+ '</div>' +
4102
+ '<div class="arch-modules cols-' + Math.max(1, mods.length) + '">' +
4103
+ mods.map((m) => '<div class="arch-module">' + renderInlineHtml(m, { autoLeadBold: true }) + '</div>').join('') +
4104
+ '</div></div>' +
4105
+ (idx < tierItems.length - 1 ? '<div class="arch-flow-arrows" aria-hidden="true"><span>' + arrowGlyph + '</span><span>' + arrowGlyph + '</span></div>' : '')
4106
+ )
4107
+ }).join('') +
4108
+ '</div>' +
4109
+ (hasSidecar
4110
+ ? '<aside class="arch-sidecar-col">' +
4111
+ sidecarItems.map((sc) =>
4112
+ '<div class="surface-card arch-sidecar is-focal" data-item-index="' + allItems.indexOf(sc) + '">' +
4113
+ (sc.tag ? '<span class="kicker">' + escapeHtml(sc.tag) + '</span>' : '') +
4114
+ '<div class="card-title" data-item-field="title">' + renderInlineHtml(sc.title || '') + '</div>' +
4115
+ (sc.text ? '<div class="card-body" data-item-field="text">' + renderInlineHtml(sc.text) + '</div>' : '') +
4116
+ (sc.bullets?.length ? '<ul class="card-bullets">' + sc.bullets.map((b) => '<li>' + renderInlineHtml(b, { autoLeadBold: true }) + '</li>').join('') + '</ul>' : '') +
4117
+ '</div>',
4118
+ ).join('') +
4119
+ '</aside>'
4120
+ : '') +
4121
+ '</div>'
4122
+ } else if (layout === 'tam') {
4123
+ const rawItems = resolveEffectiveItems(slide).slice(0, 3)
4124
+ const defaults = ['TAM', 'SAM', 'SOM']
4125
+ const items = Array.from({ length: Math.max(1, rawItems.length) }, (_, idx) => ({
4126
+ ...rawItems[idx],
4127
+ tag: rawItems[idx]?.tag || defaults[idx] || ('T' + (idx + 1)),
4128
+ }))
4129
+ inner =
4130
+ renderHeader() +
4131
+ '<div class="tam-board">' +
4132
+ '<div class="tam-circles">' +
4133
+ items.map((it, idx) => {
4134
+ const shortTag = String(it.tag || defaults[idx] || ('T' + (idx + 1))).split(/\s*[·::\-—|]\s*/)[0].trim() || (defaults[idx] || ('T' + (idx + 1)))
4135
+ return (
4136
+ '<div class="tam-circle tam-ring-' + idx + (idx === items.length - 1 ? ' is-inner' : '') + '">' +
4137
+ '<span class="tam-ring-label">' + escapeHtml(shortTag + (it.value ? ' · ' + it.value + (it.unit ? ' ' + it.unit : '') : '')) + '</span>' +
4138
+ '</div>'
4139
+ )
4140
+ }).join('') +
4141
+ '</div>' +
4142
+ '<div class="tam-cards">' +
4143
+ items.map((it, idx) => {
4144
+ const cardBodyText = [it.text, ...(it.bullets ?? [])].filter(Boolean).join(';')
4145
+ return (
4146
+ '<div class="surface-card tam-card' + (idx === items.length - 1 ? ' is-focal' : '') + '" data-item-index="' + idx + '">' +
4147
+ '<div class="tam-card-meta">' +
4148
+ '<span class="item-badge">' + escapeHtml(it.tag) + '</span>' +
4149
+ (it.value ? '<strong class="tam-card-val" data-item-field="value">' + escapeHtml(it.value + (it.unit ? ' ' + it.unit : '')) + '</strong>' : '') +
4150
+ '</div>' +
4151
+ '<div class="tam-card-copy">' +
4152
+ (it.title ? '<div class="card-title" data-item-field="title">' + renderInlineHtml(it.title) + '</div>' : '') +
4153
+ (cardBodyText ? '<div class="card-body" data-item-field="text">' + renderInlineHtml(cardBodyText) + '</div>' : '') +
4154
+ '</div></div>'
4155
+ )
4156
+ }).join('') +
4157
+ '</div></div>'
4158
+ } else if (layout === 'org') {
4159
+ const items = resolveEffectiveItems(slide)
4160
+ if (variant === 'team') {
4161
+ const members = items.slice(0, 4)
4162
+ inner =
4163
+ renderHeader() +
4164
+ '<div class="layout-grid team-grid cols-' + Math.max(1, members.length) + '">' +
4165
+ members.map((it, idx) =>
4166
+ '<article class="surface-card team-card' + (idx === 0 ? ' is-focal' : '') + '" data-item-index="' + idx + '">' +
4167
+ '<div class="team-avatar">' + escapeHtml(monogramLetters(it.title || it.tag || 'T')) + '</div>' +
4168
+ ((it.role || it.tag) ? '<span class="team-role">' + escapeHtml(it.role || it.tag) + '</span>' : '') +
4169
+ (it.title ? '<h3 class="card-title" data-item-field="title">' + renderInlineHtml(it.title) + '</h3>' : '') +
4170
+ (it.text ? '<div class="card-body" data-item-field="text">' + renderInlineHtml(it.text) + '</div>' : '') +
4171
+ (it.bullets?.length ? '<ul class="card-bullets">' + it.bullets.map((b) => '<li>' + renderInlineHtml(b, { autoLeadBold: true }) + '</li>').join('') + '</ul>' : '') +
4172
+ '</article>',
4173
+ ).join('') +
4174
+ '</div>'
4175
+ } else {
4176
+ const rootItem = items[0] ?? { tag: 'CEO', title: title || '组织架构' }
4177
+ const rawChildren = items.length > 1
4178
+ ? items.slice(1, 6)
4179
+ : (rootItem.bullets ?? []).slice(0, 5).map((b, i) => ({ tag: 'DEPT ' + (i + 1), title: b }))
4180
+ const children = rawChildren.length > 0 ? rawChildren : [{ title: '核心业务单元' }]
4181
+ inner =
4182
+ renderHeader() +
4183
+ '<div class="org-tree">' +
4184
+ '<div class="org-root-wrap">' +
4185
+ '<div class="surface-card org-root is-focal" data-item-index="0">' +
4186
+ ((rootItem.role || rootItem.tag) ? '<span class="kicker">' + escapeHtml(rootItem.role || rootItem.tag) + '</span>' : '') +
4187
+ '<div class="card-title" data-item-field="title">' + renderInlineHtml(rootItem.title || '') + '</div>' +
4188
+ (rootItem.text ? '<div class="card-body" data-item-field="text">' + renderInlineHtml(rootItem.text) + '</div>' : '') +
4189
+ '</div></div>' +
4190
+ '<div class="org-trunk" aria-hidden="true"></div>' +
4191
+ '<div class="org-children cols-' + Math.max(1, children.length) + '">' +
4192
+ children.map((ch, idx) =>
4193
+ '<div class="org-branch">' +
4194
+ '<div class="surface-card org-child" data-item-index="' + (items.length > 1 ? idx + 1 : idx) + '">' +
4195
+ ((ch.role || ch.tag) ? '<span class="item-badge">' + escapeHtml(ch.role || ch.tag) + '</span>' : '') +
4196
+ '<div class="card-title" data-item-field="title">' + renderInlineHtml(ch.title || '') + '</div>' +
4197
+ (ch.text ? '<div class="card-body" data-item-field="text">' + renderInlineHtml(ch.text) + '</div>' : '') +
4198
+ (ch.bullets?.length ? '<ul class="card-bullets">' + ch.bullets.map((b) => '<li>' + renderInlineHtml(b, { autoLeadBold: true }) + '</li>').join('') + '</ul>' : '') +
4199
+ '</div></div>',
4200
+ ).join('') +
4201
+ '</div></div>'
4202
+ }
4203
+ } else if (layout === 'agenda') {
4204
+ const items = resolveEffectiveItems(slide)
4205
+ const badgeClass = chromeStyle === 'editorial-folio' ? 'item-badge is-editorial-num' : 'item-badge'
4206
+ inner =
4207
+ renderHeader() +
4208
+ '<ol class="layout-grid agenda-grid ' + (items.length > 4 ? 'cols-2' : 'cols-1') + '">' +
4209
+ items.map((it, idx) => {
4210
+ const active = slide.activeIndex === idx + 1 || it.status === 'accent'
4211
+ return (
4212
+ '<li class="surface-card agenda-item' + (active ? ' is-active' : '') + '" data-item-index="' + idx + '">' +
4213
+ '<span class="' + badgeClass + '">' + escapeHtml(it.tag || String(idx + 1).padStart(2, '0')) + '</span>' +
4214
+ '<div class="agenda-copy"><div class="card-title" data-item-field="title">' + renderInlineHtml(it.title || it.text || '') + '</div>' +
4215
+ (it.text && it.title ? '<div class="card-body" data-item-field="text">' + renderInlineHtml(it.text) + '</div>' : '') +
4216
+ '</div></li>'
4217
+ )
4218
+ }).join('') +
4219
+ '</ol>'
4220
+ } else if (layout === 'kpi') {
4221
+ const items = resolveEffectiveItems(slide).slice(0, 4)
4222
+ inner =
4223
+ renderHeader() +
4224
+ '<div class="layout-grid kpi-grid cols-' + Math.max(1, items.length) + '">' +
4225
+ items.map((it, idx) =>
4226
+ '<div class="surface-card kpi-card' + (idx === 0 ? ' is-focal' : '') + '" data-item-index="' + idx + '">' +
4227
+ (it.value && it.title ? '<div class="kpi-label" data-item-field="title">' + renderInlineHtml(it.title) + '</div>' : '') +
4228
+ '<div class="kpi-value"><span data-item-field="value">' + escapeHtml(it.value || it.title || '—') + '</span>' +
4229
+ (it.unit ? '<small class="kpi-unit" data-item-field="unit">' + escapeHtml(it.unit) + '</small>' : '') + '</div>' +
4230
+ (it.delta ? '<span class="kpi-delta tone-' + escapeHtml(it.status || 'positive') + '" data-item-field="delta">' + escapeHtml(it.delta) + '</span>' : '') +
4231
+ (it.text ? '<div class="card-body" data-item-field="text">' + renderInlineHtml(it.text) + '</div>' : '') +
4232
+ '</div>',
4233
+ ).join('') +
4234
+ '</div>'
4235
+ } else if (layout === 'cards') {
4236
+ const items = resolveEffectiveItems(slide)
4237
+ const thesis = variant === 'exec-summary' && (slide.text || subtitle)
4238
+ ? '<div class="exec-thesis">' + renderInlineHtml(slide.text || subtitle) + '</div>'
4239
+ : ''
4240
+ const gridClass = variant === 'bento'
4241
+ ? 'bento-grid bento-' + Math.min(6, Math.max(2, items.length))
4242
+ : 'cols-' + Math.min(4, Math.max(2, items.length <= 4 ? items.length : 3))
4243
+ const badgeClass = chromeStyle === 'editorial-folio' ? 'item-badge is-editorial-num' : 'item-badge'
4244
+ inner =
4245
+ renderHeader() +
4246
+ thesis +
4247
+ '<div class="layout-grid cards-grid ' + gridClass + '">' +
4248
+ items.slice(0, 6).map((it, idx) =>
4249
+ '<article class="surface-card' + (variant === 'bento' && idx === 0 ? ' is-hero' : '') + '" data-item-index="' + idx + '">' +
4250
+ '<span class="' + badgeClass + '">' + escapeHtml(it.tag || String(idx + 1).padStart(2, '0')) + '</span>' +
4251
+ (it.title ? '<h3 class="card-title" data-item-field="title">' + renderInlineHtml(it.title) + '</h3>' : '') +
4252
+ (it.value ? '<div class="card-stat" data-item-field="value">' + escapeHtml(it.value + (it.unit ? ' ' + it.unit : '')) + '</div>' : '') +
4253
+ (it.text ? '<div class="card-body" data-item-field="text">' + renderInlineHtml(it.text) + '</div>' : '') +
4254
+ (it.bullets?.length
4255
+ ? '<ul class="card-bullets">' + it.bullets.map((b) => '<li>' + renderInlineHtml(b, { autoLeadBold: true }) + '</li>').join('') + '</ul>'
4256
+ : '') +
4257
+ '</article>',
4258
+ ).join('') +
4259
+ '</div>'
4260
+ } else if (layout === 'comparison') {
4261
+ const items = resolveEffectiveItems(slide)
4262
+ if (variant === 'issue-action') {
4263
+ inner =
4264
+ renderHeader() +
4265
+ '<div class="layout-grid issue-action-list">' +
4266
+ items.slice(0, 4).map((it, idx) =>
4267
+ '<div class="issue-action-row" data-item-index="' + idx + '">' +
4268
+ '<div class="surface-card issue-box"><span class="card-title" data-item-field="title">' + renderInlineHtml(it.title || '') + '</span></div>' +
4269
+ '<span class="bridge-arrow" aria-hidden="true">→</span>' +
4270
+ '<div class="surface-card action-box"><span class="card-body" data-item-field="text">' + renderInlineHtml(it.text || (it.bullets ?? []).join(';'), { autoLeadBold: true }) + '</span></div>' +
4271
+ '</div>',
4272
+ ).join('') +
4273
+ '</div>'
4274
+ } else {
4275
+ const twoSides = items.length <= 2
4276
+ ? items
4277
+ : [
4278
+ { title: items[0]?.title || '方案 A', bullets: items.slice(0, Math.ceil(items.length / 2)).map((x) => [x.title, x.text].filter(Boolean).join(':')) },
4279
+ { title: items[Math.ceil(items.length / 2)]?.title || '方案 B', bullets: items.slice(Math.ceil(items.length / 2)).map((x) => [x.title, x.text].filter(Boolean).join(':')) },
4280
+ ]
4281
+ const isDoDont = variant === 'do-dont'
4282
+ inner =
4283
+ renderHeader() +
4284
+ '<div class="layout-grid cols-2 comparison-grid">' +
4285
+ [0, 1].map((side) => {
4286
+ const it = twoSides[side] ?? { title: side === 0 ? '对照项' : '推荐项' }
4287
+ const headPrefix = isDoDont ? (side === 0 ? '✗ ' : '✓ ') : ''
4288
+ return (
4289
+ '<div class="surface-card comp-card side-' + side + (isDoDont ? ' is-dodont' : '') + '" data-item-index="' + side + '">' +
4290
+ '<div class="comp-head" data-item-field="title">' + escapeHtml(headPrefix) + renderInlineHtml(it.title || '') + '</div>' +
4291
+ '<div class="comp-body">' +
4292
+ (it.text ? '<p class="card-body" data-item-field="text">' + renderInlineHtml(it.text, { autoLeadBold: true }) + '</p>' : '') +
4293
+ (it.bullets?.length ? '<ul class="card-bullets">' + it.bullets.map((b) => '<li>' + renderInlineHtml(b, { autoLeadBold: true }) + '</li>').join('') + '</ul>' : '') +
4294
+ '</div></div>'
4295
+ )
4296
+ }).join('') +
4297
+ '</div>'
4298
+ }
4299
+ } else if (layout === 'matrix') {
4300
+ const items = resolveEffectiveItems(slide).slice(0, 4)
4301
+ inner =
4302
+ renderHeader() +
4303
+ '<div class="layout-grid cols-2 matrix-grid">' +
4304
+ Array.from({ length: 4 }, (_, idx) => {
4305
+ const it = items[idx] ?? { title: '象限 ' + (idx + 1) }
4306
+ return (
4307
+ '<div class="surface-card matrix-cell' + (idx === 1 ? ' is-target' : '') + '" data-item-index="' + idx + '">' +
4308
+ (it.tag ? '<div class="kicker matrix-tag">' + escapeHtml(it.tag) + '</div>' : '') +
4309
+ '<div class="card-title" data-item-field="title">' + renderInlineHtml(it.title || '') + '</div>' +
4310
+ (it.text ? '<div class="card-body" data-item-field="text">' + renderInlineHtml(it.text) + '</div>' : '') +
4311
+ '</div>'
4312
+ )
4313
+ }).join('') +
4314
+ '</div>'
4315
+ } else if (layout === 'process') {
4316
+ const items = resolveEffectiveItems(slide).slice(0, 6)
4317
+ const badgeClass = chromeStyle === 'editorial-folio' ? 'item-badge is-editorial-num' : 'item-badge'
4318
+ if (variant === 'flywheel') {
4319
+ const nodes = items.slice(0, 4)
4320
+ const rawHub = (slide.text && slide.text.trim().length <= 18 ? slide.text.trim() : '')
4321
+ || (slide.subtitle && slide.subtitle.trim().length <= 18 ? slide.subtitle.trim() : '')
4322
+ const hubText = rawHub || (langId === 'en' ? 'Growth Flywheel' : '增长飞轮')
4323
+ inner =
4324
+ renderHeader() +
4325
+ '<div class="flywheel-stage">' +
4326
+ '<div class="flywheel-hub">' + escapeHtml(hubText) + '</div>' +
4327
+ nodes.map((it, idx) => {
4328
+ const cardBodyText = [it.text, ...(it.bullets ?? [])].filter(Boolean).join(';')
4329
+ return (
4330
+ '<div class="surface-card flywheel-node node-' + idx + (idx === 0 ? ' is-focal' : '') + '" data-item-index="' + idx + '">' +
4331
+ '<div class="flywheel-node-top">' +
4332
+ '<span class="' + badgeClass + '">' + escapeHtml(it.tag || String(idx + 1).padStart(2, '0')) + '</span>' +
4333
+ ((it.conversion || it.delta) ? '<span class="funnel-conversion-badge">' + escapeHtml(it.conversion || it.delta) + '</span>' : '') +
4334
+ '</div>' +
4335
+ (it.title ? '<div class="card-title" data-item-field="title">' + renderInlineHtml(it.title) + '</div>' : '') +
4336
+ (cardBodyText ? '<div class="card-body" data-item-field="text">' + renderInlineHtml(cardBodyText) + '</div>' : '') +
4337
+ '</div>'
4338
+ )
4339
+ }).join('') +
4340
+ '</div>'
4341
+ } else if (variant === 'chevron') {
4342
+ inner =
4343
+ renderHeader() +
4344
+ '<ol class="layout-grid chevron-board cols-' + Math.max(1, items.length) + '">' +
4345
+ items.map((it, idx) => {
4346
+ const isFirst = idx === 0
4347
+ const isLast = idx === items.length - 1 && items.length >= 3
4348
+ const conv = it.conversion || it.delta || (it.value ? it.value + (it.unit ? ' ' + it.unit : '') : '')
4349
+ const bodyLines = [
4350
+ ...(it.text ? [it.text] : []),
4351
+ ...(Array.isArray(it.bullets) ? it.bullets : []),
4352
+ ]
4353
+ return (
4354
+ '<li class="chevron-col" data-item-index="' + idx + '">' +
4355
+ '<div class="chevron-arrow' + (isFirst ? ' is-first' : isLast ? ' is-last' : '') + '">' +
4356
+ '<span class="chevron-tag">' + escapeHtml(it.tag || String(idx + 1).padStart(2, '0')) + '</span>' +
4357
+ (it.title ? '<span class="chevron-title" data-item-field="title">' + renderInlineHtml(it.title) + '</span>' : '') +
4358
+ '</div>' +
4359
+ '<div class="surface-card chevron-detail' + (isFirst ? ' is-focal' : '') + '">' +
4360
+ (conv ? '<span class="funnel-conversion-badge chevron-metric">' + escapeHtml(conv) + '</span>' : '') +
4361
+ (bodyLines.length ? '<div class="card-body" data-item-field="text">' + bodyLines.map((ln) => renderInlineHtml(ln)).join('<br>') + '</div>' : '') +
4362
+ '</div>' +
4363
+ '</li>'
4364
+ )
4365
+ }).join('') +
4366
+ '</ol>'
4367
+ } else {
4368
+ const modeClass = variant === 'timeline' ? 'is-timeline' : variant === 'layers' ? 'is-layers' : variant === 'funnel' ? 'is-funnel' : 'is-steps'
4369
+ inner =
4370
+ renderHeader() +
4371
+ '<ol class="layout-grid process-grid ' + modeClass + ' cols-' + Math.max(1, items.length) + '">' +
4372
+ items.map((it, idx) => {
4373
+ const conv = variant === 'funnel' ? (it.conversion || it.delta || '') : ''
4374
+ const valSuffix = variant === 'funnel' && it.value ? ' · ' + it.value + (it.unit ? ' ' + it.unit : '') : ''
4375
+ return (
4376
+ '<li class="surface-card process-step" style="--step:' + idx + ';--total:' + items.length + '" data-item-index="' + idx + '">' +
4377
+ '<span class="' + badgeClass + '">' + escapeHtml(it.tag || String(idx + 1).padStart(2, '0')) + '</span>' +
4378
+ '<div class="process-copy">' +
4379
+ (it.title ? '<div class="card-title" data-item-field="title">' + renderInlineHtml(it.title) + (valSuffix ? '<span class="funnel-val">' + escapeHtml(valSuffix) + '</span>' : '') + '</div>' : '') +
4380
+ (it.text ? '<div class="card-body" data-item-field="text">' + renderInlineHtml(it.text) + '</div>' : '') +
4381
+ '</div>' +
4382
+ (conv ? '<span class="funnel-conversion-badge">↓ ' + escapeHtml(conv) + '</span>' : '') +
4383
+ '</li>'
4384
+ )
4385
+ }).join('') +
4386
+ '</ol>'
4387
+ }
4388
+ } else if (layout === 'callout') {
4389
+ const heroText = slide.text || subtitle || ''
4390
+ const items = resolveEffectiveItems(slide)
4391
+ inner =
4392
+ renderHeader() +
4393
+ (heroText ? '<div class="callout-hero' + (variant === 'formula' ? ' is-formula' : '') + '">' + renderInlineHtml(heroText) + '</div>' : '') +
4394
+ (items.length
4395
+ ? '<ul class="layout-grid callout-list">' +
4396
+ items.map((it, idx) =>
4397
+ '<li class="surface-card callout-row" data-item-index="' + idx + '">' +
4398
+ '<span class="item-badge">' + escapeHtml(it.tag || String(idx + 1).padStart(2, '0')) + '</span>' +
4399
+ '<div class="card-body"><strong data-item-field="title">' + renderInlineHtml(it.title || '') + '</strong>' +
4400
+ (it.text ? ' <span data-item-field="text">' + renderInlineHtml(it.text) + '</span>' : '') +
4401
+ '</div></li>',
4402
+ ).join('') +
4403
+ '</ul>'
4404
+ : '')
4405
+ } else {
4406
+ // bullets 默认版式(严格保持 <li style="--i:0">纯文本</li> 无多余包裹,兼容 test/features.test.mjs:202)
4407
+ inner =
4408
+ renderHeader() +
4409
+ (subtitle !== '' && bullets.length === 0 ? '<div class="subtitle">' + renderInlineHtml(subtitle) + '</div>' : '') +
4410
+ (bullets.length > 0
4411
+ ? '<ul class="bullets-list' + (variant === 'two-column' ? ' cols-2' : '') + '">' +
4412
+ bullets.map((bullet, bulletIndex) => '<li style="--i:' + bulletIndex + '">' + renderInlineHtml(bullet, { autoLeadBold: true }) + '</li>').join('') +
4413
+ '</ul>'
4414
+ : '')
4415
+ }
4416
+
4417
+ const takeawayPrefix = chromeStyle === 'consulting-classic'
4418
+ ? '<strong class="takeaway-prefix">' + (langId === 'en' ? 'Key Takeaway:' : '核心结论:') + '</strong>'
4419
+ : '<span class="takeaway-arrow" aria-hidden="true">' + (chromeStyle === 'editorial-folio' ? '—' : '▸') + '</span>'
4420
+ const takeawayHtml = !isFraming && slide.takeaway
4421
+ ? '<div class="slide-takeaway">' + takeawayPrefix + '<span class="takeaway-text">' + renderInlineHtml(slide.takeaway) + '</span></div>'
4422
+ : ''
4423
+
4424
+ let footerStrip = ''
4425
+ if (!isFraming) {
4426
+ const sourceText = slide.source ? formatSourceLine(slide.source, langId) : ''
4427
+ if (chromeStyle === 'academic-minimal') {
4428
+ const zLeft = sourceText || manifest.brand?.footer || manifest.title || ''
4429
+ const zMid = (slide.kicker || slide.title || '').trim()
4430
+ footerStrip =
4431
+ '<footer class="beamer-status-bar">' +
4432
+ '<span class="slide-source beamer-zone-left">' + escapeHtml(zLeft) + '</span>' +
4433
+ '<span class="beamer-zone-mid">' + escapeHtml(zMid) + '</span>' +
4434
+ '<span class="slide-folio beamer-zone-right">' + folioText + '</span>' +
4435
+ '</footer>'
4436
+ } else if (chromeStyle === 'editorial-folio') {
4437
+ footerStrip = sourceText
4438
+ ? '<footer class="slide-footer-strip"><span class="slide-source">' + escapeHtml(sourceText) + '</span></footer>'
4439
+ : ''
4440
+ } else {
4441
+ const folioLeft = sourceText ? '<span class="slide-source">' + escapeHtml(sourceText) + '</span>' : ''
4442
+ const folioRight = '<span class="slide-folio">' + folioText + '</span>'
4443
+ footerStrip = '<footer class="slide-footer-strip">' + folioLeft + folioRight + '</footer>'
4444
+ }
4445
+ }
4446
+
4447
+ return inner + takeawayHtml + footerStrip
4448
+ }
4449
+
4450
+ export const LAYOUT_CSS = `
4451
+ .slide-inner{display:flex;flex-direction:column;justify-content:center;width:100%;max-width:1560px;margin:0 auto;height:100%;gap:clamp(16px,2vw,28px)}
4452
+ .slide--cover .slide-inner,.slide--closing .slide-inner,.slide--section .slide-inner,.slide--statement .slide-inner,.slide--quote .slide-inner{justify-content:center}
4453
+ .slide-header{border-bottom:1px solid var(--hairline);padding-bottom:clamp(12px,1.5vw,20px)}
4454
+ .slide-header .kicker{margin-bottom:8px}
4455
+ .slide-header h2{font-size:clamp(26px,3.1vw,46px);max-width:34ch;line-height:1.18}
4456
+ .cover-shell{display:flex;flex-direction:column;justify-content:center;gap:clamp(24px,3.5vw,44px);min-height:72%}
4457
+ .cover-shell.is-inverted,.closing-shell.is-inverted{
4458
+ background:var(--cover-bg);color:#F8FAFC;padding:clamp(36px,5vw,76px);
4459
+ border-radius:calc(var(--radius) * 1.4);box-shadow:0 24px 60px rgba(0,0,0,.18);
4460
+ }
4461
+ .cover-shell.is-inverted h1,.closing-shell.is-inverted h1{color:#F8FAFC}
4462
+ .cover-shell.is-inverted .subtitle,.closing-shell.is-inverted .subtitle{color:#E2E8F0}
4463
+ .cover-shell.is-inverted .kicker{color:#FDE68A}
4464
+ .cover-shell.is-inverted .meta,.closing-shell.is-inverted .meta{color:#CBD5E1;border-top-color:rgba(255,255,255,.2)}
4465
+ .cover-lockup{border-left:5px solid var(--accent);padding-left:clamp(20px,2.6vw,38px)}
4466
+ .cover-shell.is-inverted .cover-lockup{border-left-color:#D4AF37}
4467
+ .cover-shell .meta{margin-top:auto;padding-top:16px;border-top:1px solid var(--hairline)}
4468
+ .closing-shell{display:flex;flex-direction:column;align-items:center;text-align:center;gap:18px}
4469
+ .closing-rule{width:96px;height:4px;background:var(--accent);border-radius:2px}
4470
+ .closing-cards{width:100%;margin-top:14px;text-align:center}
4471
+ .section-index{font-size:clamp(22px,3vw,44px);letter-spacing:.08em}
4472
+ .statement-card,.quote-card{
4473
+ background:var(--surface1);border:1px solid var(--hairline);border-left:6px solid var(--accent);
4474
+ border-radius:var(--radius);padding:clamp(24px,3.6vw,52px);
4475
+ }
4476
+ .statement-card .statement-title{border-left:0;padding-left:0}
4477
+ .inline-code{background:var(--surface2);border:1px solid var(--hairline);border-radius:5px;padding:.08em .38em;font-size:.9em}
4478
+ .ink-sec{color:var(--ink-secondary)}
4479
+ .bullets-list{
4480
+ margin:0;padding:clamp(18px,2.4vw,34px) clamp(22px,2.8vw,40px);list-style:none;
4481
+ display:grid;gap:clamp(12px,1.5vw,20px);background:var(--surface1);
4482
+ border:1px solid var(--hairline);border-left:4px solid var(--accent);border-radius:var(--radius);
4483
+ }
4484
+ .bullets-list.cols-2{grid-template-columns:repeat(2,minmax(0,1fr));column-gap:32px}
4485
+ .bullets-list li{position:relative;padding-left:clamp(22px,2vw,32px);font-size:clamp(17px,1.8vw,26px);line-height:1.48;max-width:52ch}
4486
+ .bullets-list li::before{
4487
+ content:"";position:absolute;left:0;top:.56em;width:.42em;height:.42em;
4488
+ background:var(--accent);border-radius:2px;
4489
+ }
4490
+ .layout-grid{display:grid;gap:clamp(14px,1.6vw,22px);margin:0;padding:0;list-style:none;width:100%}
4491
+ .cols-1{grid-template-columns:1fr}
4492
+ .cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}
4493
+ .cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}
4494
+ .cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}
4495
+ .cols-5{grid-template-columns:repeat(5,minmax(0,1fr))}
4496
+ .cols-6{grid-template-columns:repeat(6,minmax(0,1fr))}
4497
+ .surface-card{
4498
+ background:var(--surface1);border:1px solid var(--hairline);border-radius:var(--radius);
4499
+ padding:clamp(16px,2vw,28px);display:flex;flex-direction:column;gap:10px;min-width:0;
4500
+ }
4501
+ .surface-card.is-hero,.surface-card.is-focal,.surface-card.is-target,.surface-card.is-active{
4502
+ background:var(--accent-soft);border-color:var(--accent);
4503
+ }
4504
+ .item-badge{
4505
+ display:inline-flex;align-items:center;justify-content:center;align-self:flex-start;
4506
+ min-width:34px;height:26px;padding:0 9px;border-radius:calc(var(--radius) * .6);
4507
+ background:var(--accent-soft);color:var(--accent-text);font-weight:700;font-size:13px;
4508
+ font-variant-numeric:tabular-nums;
4509
+ }
4510
+ .item-badge.is-editorial-num{
4511
+ background:transparent;padding:0;min-width:auto;height:auto;border-radius:0;
4512
+ font-family:var(--font-heading);font-size:clamp(22px,2.2vw,34px);font-weight:800;line-height:1;
4513
+ }
4514
+ .card-title{margin:0;font-family:var(--font-heading);font-size:clamp(17px,1.6vw,23px);font-weight:700;line-height:1.3;color:var(--fg)}
4515
+ .card-stat{font-family:var(--font-heading);font-size:clamp(24px,2.6vw,38px);font-weight:800;color:var(--accent-text);font-variant-numeric:tabular-nums}
4516
+ .card-body{margin:0;font-size:clamp(14px,1.35vw,19px);line-height:1.5;color:var(--ink-secondary)}
4517
+ .card-bullets{margin:4px 0 0;padding-left:1.15em;display:grid;gap:6px;color:var(--ink-secondary);font-size:clamp(14px,1.3vw,18px);line-height:1.45}
4518
+ .kpi-card{justify-content:space-between}
4519
+ .kpi-label{font-size:clamp(13px,1.15vw,16px);font-weight:600;color:var(--muted)}
4520
+ .kpi-value{font-family:var(--font-heading);font-size:clamp(34px,4.4vw,68px);font-weight:800;line-height:1.04;letter-spacing:-.025em;color:var(--fg);font-variant-numeric:tabular-nums}
4521
+ .kpi-card.is-focal .kpi-value{color:var(--accent-text)}
4522
+ .kpi-unit{font-size:.42em;font-weight:600;color:var(--muted);margin-left:.22em}
4523
+ .kpi-delta{display:inline-flex;align-self:flex-start;padding:3px 10px;border-radius:99px;font-size:13px;font-weight:700;background:var(--surface2);border:1px solid var(--hairline);font-variant-numeric:tabular-nums}
4524
+ .kpi-delta.tone-positive{color:var(--positive)}
4525
+ .kpi-delta.tone-negative{color:var(--negative)}
4526
+ .kpi-delta.tone-warning{color:var(--warning)}
4527
+ .kpi-delta.tone-accent{color:var(--accent-text)}
4528
+ .bento-grid.bento-3{grid-template-columns:5fr 7fr;grid-template-rows:repeat(2,minmax(0,1fr))}
4529
+ .bento-grid.bento-3 > :first-child{grid-row:1 / span 2}
4530
+ .bento-grid.bento-4{grid-template-columns:repeat(12,minmax(0,1fr))}
4531
+ .bento-grid.bento-4 > :nth-child(1){grid-column:span 7}
4532
+ .bento-grid.bento-4 > :nth-child(2){grid-column:span 5}
4533
+ .bento-grid.bento-4 > :nth-child(3){grid-column:span 5}
4534
+ .bento-grid.bento-4 > :nth-child(4){grid-column:span 7}
4535
+ .bento-grid.bento-5,.bento-grid.bento-6{grid-template-columns:repeat(3,minmax(0,1fr))}
4536
+ .exec-thesis{background:var(--accent-soft);border:1px solid var(--accent);border-radius:var(--radius);padding:14px 20px;font-weight:600;font-size:clamp(15px,1.45vw,21px);line-height:1.4}
4537
+ .agenda-item{flex-direction:row;align-items:center;gap:16px;padding:14px 20px}
4538
+ .comp-card{padding:0;overflow:hidden}
4539
+ .comp-head{padding:14px 22px;font-family:var(--font-heading);font-weight:700;font-size:clamp(16px,1.55vw,22px);background:var(--surface2);color:var(--fg)}
4540
+ .comp-card.side-1 .comp-head{background:var(--accent);color:var(--ink-on-accent)}
4541
+ .comp-card.is-dodont.side-0 .comp-head{background:var(--negative);color:#FFF}
4542
+ .comp-card.is-dodont.side-1 .comp-head{background:var(--positive);color:#FFF}
4543
+ .comp-body{padding:18px 22px;display:flex;flex-direction:column;gap:8px}
4544
+ .issue-action-row{display:grid;grid-template-columns:1fr auto 1fr;align-items:center;gap:14px}
4545
+ .issue-box{border-left:4px solid var(--negative)}
4546
+ .action-box{background:var(--accent-soft);border-color:var(--accent)}
4547
+ .bridge-arrow{color:var(--accent-text);font-weight:800;font-size:22px}
4548
+ .matrix-grid{position:relative}
4549
+ .process-grid.is-layers,.process-grid.is-funnel{grid-template-columns:1fr;gap:10px}
4550
+ .process-grid.is-layers .process-step,.process-grid.is-funnel .process-step{flex-direction:row;align-items:center;padding:12px 20px}
4551
+ .process-grid.is-funnel .process-step{width:calc(100% - var(--step, 0) * 8%);margin:0 auto;justify-content:center}
4552
+ .funnel-conversion-badge{margin-left:auto;padding:3px 10px;border-radius:99px;background:var(--accent-soft);border:1px solid var(--accent);color:var(--accent-text);font-size:12px;font-weight:700;white-space:nowrap}
4553
+ .flywheel-stage{position:relative;display:grid;grid-template-columns:1fr 1fr;gap:clamp(22px,3vw,42px) clamp(120px,14vw,220px);align-items:center;padding:8px 0}
4554
+ .flywheel-hub{position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);width:clamp(130px,13vw,190px);height:clamp(130px,13vw,190px);border-radius:50%;background:var(--accent);color:var(--ink-on-accent);border:4px solid var(--bg);display:flex;align-items:center;justify-content:center;text-align:center;padding:14px;font-family:var(--font-heading);font-weight:800;font-size:clamp(14px,1.4vw,20px);z-index:2;box-shadow:0 12px 32px rgba(0,0,0,.14)}
4555
+ .flywheel-node-top{display:flex;align-items:center;justify-content:space-between;gap:8px}
4556
+ .chevron-board{gap:12px;align-items:stretch}
4557
+ .chevron-col{display:flex;flex-direction:column;gap:12px;min-width:0;list-style:none}
4558
+ .chevron-arrow{min-height:68px;padding:12px 24px 12px 28px;background:var(--surface2);color:var(--fg);font-family:var(--font-heading);font-weight:700;font-size:clamp(13px,1.2vw,16px);display:flex;flex-direction:column;justify-content:center;align-items:center;text-align:center;gap:3px;clip-path:polygon(0 0,calc(100% - 16px) 0,100% 50%,calc(100% - 16px) 100%,0 100%,16px 50%)}
4559
+ .chevron-arrow.is-first{padding-left:16px;background:var(--accent);color:var(--ink-on-accent);clip-path:polygon(0 0,calc(100% - 16px) 0,100% 50%,calc(100% - 16px) 100%,0 100%)}
4560
+ .chevron-arrow.is-last{background:var(--accent2);color:#FFF}
4561
+ .chevron-tag{font-size:11px;opacity:.86;letter-spacing:.06em}
4562
+ .chevron-detail{flex:1;padding:14px 16px;gap:8px}
4563
+ .chevron-metric{margin-left:0;align-self:flex-start}
4564
+ .callout-hero{background:var(--surface2);border:1px solid var(--accent);border-left:5px solid var(--accent);border-radius:var(--radius);padding:20px 26px;font-size:clamp(17px,1.8vw,26px);font-weight:700;line-height:1.4}
4565
+ .callout-hero.is-formula{font-family:Georgia,"Times New Roman",serif;text-align:center}
4566
+ .callout-row{flex-direction:row;align-items:center;padding:12px 18px}
4567
+ .slide-takeaway{
4568
+ margin-top:auto;background:var(--accent-soft);border:1px solid var(--hairline);border-left:4px solid var(--accent);
4569
+ border-radius:calc(var(--radius) * .85);padding:10px 18px;display:flex;align-items:center;gap:10px;
4570
+ font-size:clamp(13px,1.25vw,17px);font-weight:600;color:var(--fg);
4571
+ }
4572
+ .takeaway-arrow,.takeaway-prefix{color:var(--accent-text)}
4573
+ .slide-footer-strip{display:flex;justify-content:space-between;align-items:center;gap:16px;font-size:12px;color:var(--muted);padding-top:4px;font-variant-numeric:tabular-nums}
4574
+ .slide-folio{margin-left:auto}
4575
+ .slide[data-table-style="booktabs"] .deck-table th{background:transparent;border-top:2px solid var(--fg);border-bottom:1px solid var(--fg)}
4576
+ .slide[data-table-style="booktabs"] .deck-table td{background:transparent !important;border-bottom:0}
4577
+ .slide[data-table-style="booktabs"] .deck-table tbody tr:last-child td{border-bottom:2px solid var(--fg)}
4578
+ .slide[data-table-style="minimal"] .deck-table th{background:transparent;color:var(--accent-text);border-bottom:2px solid var(--accent)}
4579
+ .slide[data-table-style="minimal"] .deck-table tbody tr:nth-child(even){background:transparent}
4580
+ /* 5 Pro Diagrams CSS */
4581
+ .gantt-board{display:flex;flex-direction:column;gap:8px;width:100%}
4582
+ .gantt-head,.gantt-row{display:grid;grid-template-columns:minmax(220px,31%) 1fr;gap:12px;align-items:center}
4583
+ .gantt-corner{background:var(--surface2);border:1px solid var(--hairline);border-radius:calc(var(--radius) * .6);padding:8px 12px;font-size:12px;font-weight:700;color:var(--muted)}
4584
+ .gantt-col-heads{display:grid;grid-template-columns:repeat(var(--gantt-cols,4),minmax(0,1fr));border:1px solid var(--hairline);overflow:hidden}
4585
+ .gantt-col-head{background:var(--surface2);padding:8px 6px;text-align:center;font-weight:700;font-size:13px;border-right:1px solid var(--hairline)}
4586
+ .gantt-col-head:last-child{border-right:0}
4587
+ .gantt-rows{display:flex;flex-direction:column;gap:8px}
4588
+ .gantt-label{flex-direction:row;align-items:center;gap:10px;padding:8px 12px}
4589
+ .gantt-tag{background:var(--accent-soft);color:var(--accent-text);font-size:11px;font-weight:700;padding:2px 8px;border-radius:4px;white-space:nowrap}
4590
+ .gantt-task{font-weight:600;font-size:14px}
4591
+ .gantt-track{position:relative;height:38px;background:var(--surface1);border:1px solid var(--hairline);overflow:visible;background-image:repeating-linear-gradient(to right,transparent,transparent calc(100% / var(--gantt-cols,4) - 1px),var(--hairline) calc(100% / var(--gantt-cols,4) - 1px),var(--hairline) calc(100% / var(--gantt-cols,4)))}
4592
+ .gantt-bar{position:absolute;top:6px;bottom:6px;border-radius:calc(var(--radius) * .6);background:var(--accent);color:#FFF;font-size:12px;font-weight:700;display:flex;align-items:center;justify-content:center;padding:0 8px}
4593
+ .gantt-bar.tone-positive{background:var(--positive)}.gantt-bar.tone-warning{background:var(--warning)}.gantt-bar.tone-negative{background:var(--negative)}
4594
+ .gantt-milestone{position:absolute;top:50%;width:16px;height:16px;background:var(--accent);border:2px solid var(--bg);transform:translate(-50%,-50%) rotate(45deg)}
4595
+ .gantt-bar-milestone{position:absolute;right:-7px;top:50%;width:14px;height:14px;background:var(--accent);border:2px solid var(--bg);transform:translateY(-50%) rotate(45deg);z-index:2}
4596
+ .gantt-m-label{position:absolute;top:50%;transform:translate(14px,-50%);font-size:12px;font-weight:700;color:var(--accent-text);white-space:nowrap}
4597
+ .arch-board{display:grid;grid-template-columns:1fr;gap:16px;width:100%}
4598
+ .arch-board.has-sidecar{grid-template-columns:1fr minmax(210px,22%)}
4599
+ .arch-tiers{display:flex;flex-direction:column;gap:6px}
4600
+ .arch-tier{display:grid;grid-template-columns:minmax(160px,24%) 1fr;align-items:center;gap:14px;padding:12px 16px}
4601
+ .arch-tier-head .kicker{margin-bottom:2px;font-size:11px}
4602
+ .arch-modules{display:grid;gap:10px}
4603
+ .arch-module{background:var(--bg);border:1px solid var(--hairline);border-radius:calc(var(--radius) * .6);padding:8px 12px;text-align:center;font-size:14px}
4604
+ .arch-flow-arrows{display:flex;justify-content:space-around;color:var(--accent-text);font-weight:800;font-size:18px;line-height:1}
4605
+ .arch-sidecar-col{display:flex;flex-direction:column;gap:12px}
4606
+ .arch-sidecar{height:100%;justify-content:center}
4607
+ .harvey-table th.is-ours{background:var(--accent);color:var(--ink-on-accent);border-color:var(--accent)}
4608
+ .harvey-table td.is-ours{background:var(--accent-soft);font-weight:700}
4609
+ .harvey-cell{text-align:center}
4610
+ .harvey-ball{display:inline-block;width:22px;height:22px;border-radius:50%;border:2px solid var(--fg);vertical-align:middle}
4611
+ .harvey-table td.is-ours .harvey-ball{border-color:var(--accent)}
4612
+ .harvey-100{background:var(--fg)}.harvey-table td.is-ours .harvey-100{background:var(--accent)}
4613
+ .harvey-75{background:conic-gradient(var(--fg) 0 270deg,transparent 270deg 360deg)}.harvey-table td.is-ours .harvey-75{background:conic-gradient(var(--accent) 0 270deg,transparent 270deg 360deg)}
4614
+ .harvey-50{background:conic-gradient(var(--fg) 0 180deg,transparent 180deg 360deg)}.harvey-table td.is-ours .harvey-50{background:conic-gradient(var(--accent) 0 180deg,transparent 180deg 360deg)}
4615
+ .harvey-25{background:conic-gradient(var(--fg) 0 90deg,transparent 90deg 360deg)}.harvey-table td.is-ours .harvey-25{background:conic-gradient(var(--accent) 0 90deg,transparent 90deg 360deg)}
4616
+ .harvey-0{background:transparent;border-color:var(--muted)}
4617
+ .harvey-check{display:inline-flex;align-items:center;justify-content:center;width:24px;height:24px;border-radius:50%;font-weight:800;font-size:13px}
4618
+ .harvey-check.is-yes{background:var(--positive);color:#FFF}
4619
+ .harvey-check.is-no{background:var(--surface2);color:var(--muted)}
4620
+ .tam-board{display:grid;grid-template-columns:minmax(280px,43%) 1fr;gap:28px;align-items:center;width:100%}
4621
+ .tam-circles{position:relative;width:100%;aspect-ratio:1/1;max-height:380px;margin:0 auto}
4622
+ .tam-circle{position:absolute;left:50%;bottom:0;transform:translateX(-50%);border-radius:50%;border:2px solid var(--accent);display:flex;justify-content:center;padding-top:14px;background:var(--surface1)}
4623
+ .tam-ring-0{width:94%;height:94%}.tam-ring-1{width:64%;height:64%;background:var(--accent-soft)}.tam-ring-2{width:37%;height:37%;background:var(--accent);color:var(--ink-on-accent);align-items:center;padding-top:0}
4624
+ .tam-ring-label{font-family:var(--font-heading);font-weight:800;font-size:clamp(12px,1.15vw,15px);color:var(--accent-text);max-width:74%;text-align:center}
4625
+ .tam-ring-2 .tam-ring-label{color:var(--ink-on-accent)}
4626
+ .tam-cards{display:flex;flex-direction:column;gap:14px}
4627
+ .tam-card{flex-direction:row;align-items:center;gap:16px;padding:14px 18px}
4628
+ .tam-card-meta{display:flex;flex-direction:column;gap:4px;min-width:136px}
4629
+ .tam-card-val{font-family:var(--font-heading);font-size:clamp(18px,1.8vw,26px);color:var(--accent-text)}
4630
+ .funnel-val{color:var(--accent-text);font-weight:700}
4631
+ .process-step:first-child .funnel-val{color:inherit}
4632
+ .org-tree{display:flex;flex-direction:column;align-items:center;width:100%}
4633
+ .org-root-wrap{display:flex;justify-content:center;width:100%}
4634
+ .org-root{min-width:min(380px,60%);text-align:center;align-items:center}
4635
+ .org-trunk{width:2px;height:24px;background:var(--accent)}
4636
+ .org-children{display:grid;gap:16px;width:100%;border-top:2px solid var(--accent);padding-top:20px}
4637
+ .org-branch{position:relative}
4638
+ .org-branch::before{content:"";position:absolute;top:-20px;left:50%;width:2px;height:20px;background:var(--accent);transform:translateX(-50%)}
4639
+ .org-child{height:100%}
4640
+ .team-card{align-items:center;text-align:center}
4641
+ .team-avatar{width:62px;height:62px;border-radius:50%;background:var(--accent);color:var(--ink-on-accent);display:flex;align-items:center;justify-content:center;font-family:var(--font-heading);font-weight:800;font-size:20px}
4642
+ .team-role{display:inline-block;padding:3px 12px;border-radius:99px;background:var(--accent-soft);color:var(--accent-text);font-size:12px;font-weight:700}
4643
+ /* 6 Chrome Skeleton Differentiation */
4644
+ .slide[data-chrome="consulting-classic"] .consulting-header{display:flex;align-items:flex-start;justify-content:space-between;gap:20px}
4645
+ .slide[data-chrome="consulting-classic"] .consulting-tracker{border:1px solid var(--accent);background:var(--accent-soft);padding:5px 14px;border-radius:0;margin:0;white-space:nowrap}
4646
+ .slide[data-chrome="consulting-classic"] .surface-card,.slide[data-chrome="consulting-classic"] .bullets-list,.slide[data-chrome="consulting-classic"] .statement-card,.slide[data-chrome="consulting-classic"] .quote-card{border-radius:0;border-left:3.5px solid var(--accent)}
4647
+ .slide[data-chrome="consulting-classic"] .slide-takeaway{background:transparent;border:0;border-top:1.5px solid var(--accent);border-radius:0;padding:10px 0 2px}
4648
+ .slide[data-chrome="keynote-spatial"] .slide-header{border-bottom:0;padding-bottom:4px}
4649
+ .slide[data-chrome="keynote-spatial"] .slide-header .kicker{display:inline-block;background:var(--accent-soft);padding:4px 14px;border-radius:99px;letter-spacing:.1em}
4650
+ .slide[data-chrome="keynote-spatial"] .surface-card,.slide[data-chrome="keynote-spatial"] .bullets-list,.slide[data-chrome="keynote-spatial"] .statement-card,.slide[data-chrome="keynote-spatial"] .quote-card{border:0;border-radius:20px;box-shadow:none}
4651
+ .slide[data-chrome="keynote-spatial"] .slide-takeaway{background:transparent;border:0;justify-content:center;text-align:center;color:var(--ink-secondary);font-weight:500}
4652
+ .slide[data-chrome="editorial-folio"] .editorial-folio-bar{display:flex;justify-content:space-between;align-items:center;border-bottom:1px solid var(--hairline);padding-bottom:8px;margin-bottom:-8px;font-size:12px;color:var(--muted)}
4653
+ .slide[data-chrome="editorial-folio"] .editorial-folio-bar .kicker{margin-bottom:0}
4654
+ .slide[data-chrome="editorial-folio"] .slide-header{border-bottom-width:1px}
4655
+ .slide[data-chrome="editorial-folio"] .surface-card,.slide[data-chrome="editorial-folio"] .bullets-list,.slide[data-chrome="editorial-folio"] .statement-card,.slide[data-chrome="editorial-folio"] .quote-card{border-radius:0}
4656
+ .slide[data-chrome="editorial-folio"] .slide-takeaway{background:transparent;border:0;border-top:1px solid var(--hairline);border-radius:0;padding:10px 0 2px}
4657
+ .slide[data-chrome="saas-bento"] .surface-card{border-radius:13px}
4658
+ .slide[data-chrome="saas-bento"] .surface-card.is-hero,.slide[data-chrome="saas-bento"] .surface-card.is-focal,.slide[data-chrome="saas-bento"] .surface-card.is-active{border-top:3px solid var(--accent)}
4659
+ .slide[data-chrome="academic-minimal"]:not(.slide--cover):not(.slide--closing):not(.slide--section){padding-top:clamp(108px,13vw,148px);padding-bottom:clamp(46px,5.5vw,66px)}
4660
+ .slide[data-chrome="academic-minimal"] .beamer-header-band{position:absolute;top:0;left:0;right:0;background:var(--surface1);border-bottom:2.5px solid var(--accent);padding:clamp(14px,1.8vw,22px) clamp(36px,5.4vw,88px)}
4661
+ .slide[data-chrome="academic-minimal"] .beamer-status-bar{position:absolute;bottom:0;left:0;right:0;display:grid;grid-template-columns:1fr auto 1fr;align-items:center;gap:12px;background:var(--surface1);border-top:1px solid var(--hairline);padding:8px clamp(36px,5.4vw,88px);font-size:12px;color:var(--muted);font-variant-numeric:tabular-nums}
4662
+ .slide[data-chrome="academic-minimal"] .beamer-zone-mid{text-align:center;font-weight:600;color:var(--ink-secondary)}
4663
+ .slide[data-chrome="academic-minimal"] .beamer-zone-right{text-align:right;color:var(--accent-text);font-weight:700}
4664
+ .slide[data-chrome="academic-minimal"] .slide-takeaway{background:transparent;border:0;border-top:1px solid var(--accent);border-bottom:1px solid var(--hairline);border-radius:0;padding:8px 0}
4665
+ .slide[data-chrome="gov-ceremonial"] .gov-header{border-bottom:2px solid var(--accent);box-shadow:0 4px 0 0 var(--bg),0 5.5px 0 0 var(--accent2);padding-bottom:12px;margin-bottom:4px}
4666
+ .slide[data-chrome="gov-ceremonial"] .gov-ribbon{letter-spacing:.08em}
4667
+ @media (max-width:900px){
4668
+ .cols-3,.cols-4,.cols-5,.cols-6,.bento-grid.bento-3,.bento-grid.bento-4,.bento-grid.bento-5,.bento-grid.bento-6,.tam-board,.arch-board.has-sidecar,.org-children,.flywheel-stage{grid-template-columns:1fr}
4669
+ .bento-grid.bento-3 > :first-child,.bento-grid.bento-4 > *{grid-row:auto;grid-column:auto}
4670
+ .issue-action-row,.gantt-head,.gantt-row,.arch-tier{grid-template-columns:1fr}
4671
+ .flywheel-hub{position:static;transform:none;margin:0 auto}
4672
+ }
4673
+ `