dsh-ppt 0.21.1 → 0.22.1

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