ooxml-ui 1.28.0 → 1.29.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chart/format-pane-3d.d.ts +1 -0
- package/dist/chart/format-pane-fill-kinds.d.ts +0 -1
- package/dist/chart/format-pane-targets.d.ts +0 -1
- package/dist/chart/format-pane-types.d.ts +0 -1
- package/dist/chart/format-pane-view.d.ts +0 -1
- package/dist/{chunk-2EFIFIPB.js → chunk-LNHFMJ2P.js} +1 -1
- package/dist/{chunk-FHO7TEWA.js → chunk-WYKMVMX4.js} +14 -1
- package/dist/{chunk-WBE2Q5DC.js → chunk-YMZFOG2U.js} +2 -2
- package/dist/comments/mentions.d.ts +63 -0
- package/dist/comments/mentions.d.ts.map +1 -0
- package/dist/form/checkable.d.ts +0 -1
- package/dist/index.js +3 -3
- package/dist/pptx/ai/host.cjs +121 -0
- package/dist/pptx/ai/host.d.ts +39 -0
- package/dist/pptx/ai/host.d.ts.map +1 -0
- package/dist/pptx/ai/host.mjs +4 -0
- package/dist/pptx/ai/index.cjs +120 -870
- package/dist/pptx/ai/index.mjs +6 -842
- package/dist/pptx/{chunk-WBFAVFD4.cjs → chunk-BXCXY4HB.cjs} +722 -279
- package/dist/pptx/{chunk-CT7UD6VL.mjs → chunk-DVLU476S.mjs} +688 -231
- package/dist/pptx/{chunk-MJACF7Y2.mjs → chunk-EHIQ4ANA.mjs} +5 -0
- package/dist/pptx/chunk-IY7H76CZ.cjs +874 -0
- package/dist/pptx/{chunk-GWKTHP6U.cjs → chunk-PATUICO4.cjs} +5 -0
- package/dist/pptx/{chunk-3AFB46RL.cjs → chunk-UTBHXIDK.cjs} +46 -46
- package/dist/pptx/{chunk-7OD74VJC.mjs → chunk-YO3EMGXD.mjs} +2 -2
- package/dist/pptx/chunk-YQANSI3A.mjs +844 -0
- package/dist/pptx/dom/glyph-outline-cache.d.ts +3 -1
- package/dist/pptx/dom/glyph-outline-cache.d.ts.map +1 -1
- package/dist/pptx/dom/index.cjs +399 -398
- package/dist/pptx/dom/index.mjs +15 -14
- package/dist/pptx/dom/load-presentation.d.ts +7 -1
- package/dist/pptx/dom/load-presentation.d.ts.map +1 -1
- package/dist/pptx/export/html2canvas-clone.cjs +4 -4
- package/dist/pptx/export/html2canvas-clone.mjs +1 -1
- package/dist/pptx/export/print-document.cjs +18 -18
- package/dist/pptx/export/print-document.mjs +2 -2
- package/dist/pptx/i18n/index.cjs +6 -6
- package/dist/pptx/i18n/index.mjs +1 -1
- package/dist/pptx/i18n/translations-en.d.ts.map +1 -1
- package/dist/pptx/index.cjs +3185 -3161
- package/dist/pptx/index.mjs +9 -9
- package/dist/pptx/render/comment-mentions.d.ts +16 -1
- package/dist/pptx/render/comment-mentions.d.ts.map +1 -1
- package/dist/pptx/render/comments-list.d.ts +11 -7
- package/dist/pptx/render/comments-list.d.ts.map +1 -1
- package/dist/pptx/render/embedded-font-trust.d.ts +7 -0
- package/dist/pptx/render/embedded-font-trust.d.ts.map +1 -1
- package/dist/pptx/render/embedded-fonts.d.ts +4 -3
- package/dist/pptx/render/embedded-fonts.d.ts.map +1 -1
- package/dist/pptx/render/glyph-outline-font-registration.d.ts +83 -0
- package/dist/pptx/render/glyph-outline-font-registration.d.ts.map +1 -0
- package/dist/pptx/render/index.d.ts +2 -0
- package/dist/pptx/render/index.d.ts.map +1 -1
- package/dist/pptx/render/load-limits.d.ts +18 -0
- package/dist/pptx/render/load-limits.d.ts.map +1 -0
- package/dist/pptx/render/text-warp-glyph-outline-lookup.d.ts +39 -0
- package/dist/pptx/render/text-warp-glyph-outline-lookup.d.ts.map +1 -0
- package/dist/pptx/render/text-warp-opentype-parser.d.ts +15 -2
- package/dist/pptx/render/text-warp-opentype-parser.d.ts.map +1 -1
- package/dist/pptx/render/text-warp-outline-font-cache.d.ts +116 -42
- package/dist/pptx/render/text-warp-outline-font-cache.d.ts.map +1 -1
- package/dist/pptx/render/viewer-props-manifest.d.ts.map +1 -1
- package/dist/pptx/{smartart-insert-preview-3BY6HNZL.cjs → smartart-insert-preview-DHQ47GXP.cjs} +11 -11
- package/dist/pptx/{smartart-insert-preview-7CRBDPYF.mjs → smartart-insert-preview-IQVC5LMF.mjs} +10 -10
- package/dist/{presentation-preview-KY56TONW.js → presentation-preview-XGJMARKI.js} +1 -1
- package/dist/teams/app/presentation-preview.d.ts +3 -0
- package/dist/teams.js +2 -2
- package/dist/xlsx.js +4 -4
- package/package.json +8 -8
- package/dist/pptx/{chunk-YMITEJST.cjs → chunk-3CYWRMYZ.cjs} +1 -1
- package/dist/pptx/{chunk-3LOVEO7U.mjs → chunk-5VSUIPDX.mjs} +1 -1
- /package/dist/pptx/{chunk-FM4C4MBJ.cjs → chunk-67UQWOEQ.cjs} +0 -0
- /package/dist/pptx/{chunk-AMW2AR7J.mjs → chunk-6MZFWTBS.mjs} +0 -0
|
@@ -0,0 +1,874 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkA5MANNJR_cjs = require('./chunk-A5MANNJR.cjs');
|
|
4
|
+
var chunkY6DO6SVT_cjs = require('./chunk-Y6DO6SVT.cjs');
|
|
5
|
+
var chunkPBZWDEXQ_cjs = require('./chunk-PBZWDEXQ.cjs');
|
|
6
|
+
var pptx = require('ooxml-core/pptx');
|
|
7
|
+
|
|
8
|
+
// src/pptx/ai/deck-data-diff.ts
|
|
9
|
+
function deckDataFieldChanged(a, b) {
|
|
10
|
+
return JSON.stringify(a) !== JSON.stringify(b);
|
|
11
|
+
}
|
|
12
|
+
function applyElementUpdate(el, u) {
|
|
13
|
+
if (u.x !== void 0) {
|
|
14
|
+
el.x = u.x;
|
|
15
|
+
}
|
|
16
|
+
if (u.y !== void 0) {
|
|
17
|
+
el.y = u.y;
|
|
18
|
+
}
|
|
19
|
+
if (u.width !== void 0) {
|
|
20
|
+
el.width = u.width;
|
|
21
|
+
}
|
|
22
|
+
if (u.height !== void 0) {
|
|
23
|
+
el.height = u.height;
|
|
24
|
+
}
|
|
25
|
+
if (u.rotation !== void 0) {
|
|
26
|
+
el.rotation = u.rotation;
|
|
27
|
+
}
|
|
28
|
+
if (u.opacity !== void 0) {
|
|
29
|
+
el.opacity = u.opacity;
|
|
30
|
+
}
|
|
31
|
+
if (u.hidden !== void 0) {
|
|
32
|
+
el.hidden = u.hidden;
|
|
33
|
+
}
|
|
34
|
+
if (u.flipHorizontal !== void 0) {
|
|
35
|
+
el.flipHorizontal = u.flipHorizontal;
|
|
36
|
+
}
|
|
37
|
+
if (u.flipVertical !== void 0) {
|
|
38
|
+
el.flipVertical = u.flipVertical;
|
|
39
|
+
}
|
|
40
|
+
applyTextUpdate(el, u);
|
|
41
|
+
applyShapeStyleUpdate(el, u);
|
|
42
|
+
}
|
|
43
|
+
function applyTextUpdate(el, u) {
|
|
44
|
+
if (!pptx.hasTextProperties(el)) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
const textEl = el;
|
|
48
|
+
if (u.text !== void 0) {
|
|
49
|
+
textEl.text = u.text;
|
|
50
|
+
if (textEl.textSegments && textEl.textSegments.length > 0) {
|
|
51
|
+
textEl.textSegments[0].text = u.text;
|
|
52
|
+
} else {
|
|
53
|
+
textEl.textSegments = [{ text: u.text, style: {} }];
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
if (u.fontSize === void 0 && u.fontFamily === void 0 && u.fontColor === void 0 && u.bold === void 0 && u.italic === void 0 && u.underline === void 0 && u.align === void 0) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
const textStyle = {};
|
|
60
|
+
if (u.fontSize !== void 0) {
|
|
61
|
+
textStyle.fontSize = u.fontSize;
|
|
62
|
+
}
|
|
63
|
+
if (u.fontFamily !== void 0) {
|
|
64
|
+
textStyle.fontFamily = u.fontFamily;
|
|
65
|
+
}
|
|
66
|
+
if (u.fontColor !== void 0) {
|
|
67
|
+
textStyle.color = u.fontColor;
|
|
68
|
+
}
|
|
69
|
+
if (u.bold !== void 0) {
|
|
70
|
+
textStyle.bold = u.bold;
|
|
71
|
+
}
|
|
72
|
+
if (u.italic !== void 0) {
|
|
73
|
+
textStyle.italic = u.italic;
|
|
74
|
+
}
|
|
75
|
+
if (u.underline !== void 0) {
|
|
76
|
+
textStyle.underline = u.underline;
|
|
77
|
+
}
|
|
78
|
+
if (u.align !== void 0) {
|
|
79
|
+
textStyle.align = u.align;
|
|
80
|
+
}
|
|
81
|
+
textEl.textStyle = { ...textEl.textStyle, ...textStyle };
|
|
82
|
+
if (textEl.textSegments) {
|
|
83
|
+
textEl.textSegments = textEl.textSegments.map((seg) => chunkPBZWDEXQ_cjs.updateTextSegmentStyle(seg, textStyle));
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
function applyShapeStyleUpdate(el, u) {
|
|
87
|
+
if (u.fillColor === void 0 && u.strokeColor === void 0 && u.strokeWidth === void 0) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
if (!pptx.hasShapeProperties(el)) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
const holder = el;
|
|
94
|
+
holder.shapeStyle ??= {};
|
|
95
|
+
const style = holder.shapeStyle;
|
|
96
|
+
if (u.fillColor !== void 0) {
|
|
97
|
+
style.fillColor = u.fillColor;
|
|
98
|
+
}
|
|
99
|
+
if (u.strokeColor !== void 0) {
|
|
100
|
+
style.strokeColor = u.strokeColor;
|
|
101
|
+
}
|
|
102
|
+
if (u.strokeWidth !== void 0) {
|
|
103
|
+
style.strokeWidth = u.strokeWidth;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// src/pptx/ai/bridge-factory.ts
|
|
108
|
+
var TITLE_MAX_LENGTH = 120;
|
|
109
|
+
function pptxAiDeckTitle(slides) {
|
|
110
|
+
for (const element of slides[0]?.elements ?? []) {
|
|
111
|
+
const text = "text" in element && typeof element.text === "string" ? element.text.trim() : "";
|
|
112
|
+
if (text) {
|
|
113
|
+
return text.slice(0, TITLE_MAX_LENGTH);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return void 0;
|
|
117
|
+
}
|
|
118
|
+
function copy(list) {
|
|
119
|
+
return list ? [...list] : void 0;
|
|
120
|
+
}
|
|
121
|
+
function readDeckData(port) {
|
|
122
|
+
const canvas = port.getCanvasSize();
|
|
123
|
+
return {
|
|
124
|
+
slides: [...port.getSlides()],
|
|
125
|
+
width: canvas.width,
|
|
126
|
+
height: canvas.height,
|
|
127
|
+
theme: port.getTheme(),
|
|
128
|
+
sections: copy(port.getSections()),
|
|
129
|
+
presentationProperties: port.getPresentationProperties(),
|
|
130
|
+
customProperties: copy(port.getCustomProperties()),
|
|
131
|
+
coreProperties: port.getCoreProperties(),
|
|
132
|
+
appProperties: port.getAppProperties(),
|
|
133
|
+
viewProperties: port.getViewProperties(),
|
|
134
|
+
tableStyleMap: port.getTableStyleMap(),
|
|
135
|
+
tableStylesDefaultId: port.getTableStylesDefaultId(),
|
|
136
|
+
tags: copy(port.getTagCollections())
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
function commitDocumentProperties(port, before, after) {
|
|
140
|
+
const differs = deckDataFieldChanged;
|
|
141
|
+
const core = after.coreProperties ?? before.coreProperties;
|
|
142
|
+
const app = after.appProperties ?? before.appProperties;
|
|
143
|
+
const custom = after.customProperties ?? before.customProperties ?? [];
|
|
144
|
+
const coreChanged = differs(before.coreProperties, core);
|
|
145
|
+
if (!coreChanged && !differs(before.appProperties, app) && !differs(before.customProperties, custom)) {
|
|
146
|
+
return false;
|
|
147
|
+
}
|
|
148
|
+
port.setDocumentProperties(core ?? {}, app ?? {}, custom);
|
|
149
|
+
if (coreChanged && core) {
|
|
150
|
+
port.onCorePropertiesChanged?.(core);
|
|
151
|
+
}
|
|
152
|
+
return true;
|
|
153
|
+
}
|
|
154
|
+
function commitDeckData(port, before, after, label) {
|
|
155
|
+
const differs = deckDataFieldChanged;
|
|
156
|
+
let changed = false;
|
|
157
|
+
if (differs(before.slides, after.slides)) {
|
|
158
|
+
port.updateSlides(() => after.slides, label);
|
|
159
|
+
changed = true;
|
|
160
|
+
}
|
|
161
|
+
if (before.width !== after.width || before.height !== after.height) {
|
|
162
|
+
port.setCanvasSize({ width: after.width, height: after.height });
|
|
163
|
+
changed = true;
|
|
164
|
+
}
|
|
165
|
+
const sections = after.sections ?? before.sections ?? [];
|
|
166
|
+
if (differs(before.sections, sections)) {
|
|
167
|
+
port.setSections(sections);
|
|
168
|
+
changed = true;
|
|
169
|
+
}
|
|
170
|
+
const presentation = after.presentationProperties ?? before.presentationProperties ?? {};
|
|
171
|
+
if (differs(before.presentationProperties, presentation)) {
|
|
172
|
+
port.setPresentationProperties(presentation);
|
|
173
|
+
changed = true;
|
|
174
|
+
}
|
|
175
|
+
changed = commitDocumentProperties(port, before, after) || changed;
|
|
176
|
+
if (differs(before.viewProperties, after.viewProperties)) {
|
|
177
|
+
port.setViewProperties(after.viewProperties);
|
|
178
|
+
changed = true;
|
|
179
|
+
}
|
|
180
|
+
if (differs(before.tableStyleMap, after.tableStyleMap)) {
|
|
181
|
+
port.setTableStyleMap(after.tableStyleMap ?? {});
|
|
182
|
+
changed = true;
|
|
183
|
+
}
|
|
184
|
+
if (differs(before.tableStylesDefaultId, after.tableStylesDefaultId)) {
|
|
185
|
+
port.setTableStylesDefaultId(after.tableStylesDefaultId);
|
|
186
|
+
changed = true;
|
|
187
|
+
}
|
|
188
|
+
const tags = after.tags ?? before.tags ?? [];
|
|
189
|
+
if (differs(before.tags, tags)) {
|
|
190
|
+
port.setTagCollections(tags);
|
|
191
|
+
changed = true;
|
|
192
|
+
}
|
|
193
|
+
return changed;
|
|
194
|
+
}
|
|
195
|
+
function createPptxAiBridge(port) {
|
|
196
|
+
const applySlidesUpdate = (updater, label) => {
|
|
197
|
+
port.updateSlides((current) => updater(structuredClone([...current])), label);
|
|
198
|
+
};
|
|
199
|
+
const bridge = {
|
|
200
|
+
getDeckMeta() {
|
|
201
|
+
const slides = port.getSlides();
|
|
202
|
+
const canvas = port.getCanvasSize();
|
|
203
|
+
return {
|
|
204
|
+
slideCount: slides.length,
|
|
205
|
+
activeSlideIndex: port.getActiveSlideIndex(),
|
|
206
|
+
title: port.getFileName?.() ?? pptxAiDeckTitle(slides),
|
|
207
|
+
width: canvas.width,
|
|
208
|
+
height: canvas.height
|
|
209
|
+
};
|
|
210
|
+
},
|
|
211
|
+
getSlides: () => [...port.getSlides()],
|
|
212
|
+
getActiveSlideIndex: () => port.getActiveSlideIndex(),
|
|
213
|
+
getTheme: () => port.getTheme(),
|
|
214
|
+
getHandler: () => port.getHandler() ?? void 0,
|
|
215
|
+
goToSlide: (index) => port.goToSlide(index),
|
|
216
|
+
selectElements: (slideIndex, elementIds) => port.selectElements(slideIndex, elementIds),
|
|
217
|
+
applySlidesUpdate,
|
|
218
|
+
updateElement(slideIndex, elementId, updates) {
|
|
219
|
+
applySlidesUpdate((slides) => {
|
|
220
|
+
const element = slides[slideIndex]?.elements.find((el) => el.id === elementId);
|
|
221
|
+
if (element) {
|
|
222
|
+
applyElementUpdate(element, updates);
|
|
223
|
+
}
|
|
224
|
+
return slides;
|
|
225
|
+
}, `Update element ${elementId}`);
|
|
226
|
+
},
|
|
227
|
+
applyTheme: (updates) => port.applyTheme(updates),
|
|
228
|
+
getDeckData: () => readDeckData(port),
|
|
229
|
+
applyDeckData(updater, label) {
|
|
230
|
+
const before = readDeckData(port);
|
|
231
|
+
const after = updater(structuredClone(before));
|
|
232
|
+
if (commitDeckData(port, before, after, label)) {
|
|
233
|
+
port.afterDeckUpdate?.();
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
};
|
|
237
|
+
if (port.getFocusedTargets) {
|
|
238
|
+
bridge.getFocusedTargets = () => port.getFocusedTargets?.() ?? [];
|
|
239
|
+
}
|
|
240
|
+
if (port.notify) {
|
|
241
|
+
bridge.notify = (message, level) => port.notify?.(message, level);
|
|
242
|
+
}
|
|
243
|
+
return bridge;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
// src/pptx/ai/focus-targets.ts
|
|
247
|
+
function computeFocusTargets(input) {
|
|
248
|
+
const { activeSlideIndex, selectedElementIds, selectedElementId } = input;
|
|
249
|
+
const ids = selectedElementIds.length > 0 ? [...selectedElementIds] : selectedElementId ? [selectedElementId] : [];
|
|
250
|
+
if (ids.length === 0) {
|
|
251
|
+
return [{ kind: "slide", slideIndex: activeSlideIndex }];
|
|
252
|
+
}
|
|
253
|
+
return ids.map((elementId) => ({ kind: "element", slideIndex: activeSlideIndex, elementId }));
|
|
254
|
+
}
|
|
255
|
+
function elementTypeLabel(type) {
|
|
256
|
+
if (type === "smartArt") {
|
|
257
|
+
return "SmartArt";
|
|
258
|
+
}
|
|
259
|
+
if (type === "ole") {
|
|
260
|
+
return "OLE";
|
|
261
|
+
}
|
|
262
|
+
return type.charAt(0).toUpperCase() + type.slice(1);
|
|
263
|
+
}
|
|
264
|
+
function shortElementId(id) {
|
|
265
|
+
const trimmed = id.trimEnd();
|
|
266
|
+
let start = trimmed.length;
|
|
267
|
+
while (start > 0 && isAsciiDigit(trimmed.charCodeAt(start - 1))) {
|
|
268
|
+
start -= 1;
|
|
269
|
+
}
|
|
270
|
+
if (start < trimmed.length) {
|
|
271
|
+
return trimmed.slice(start);
|
|
272
|
+
}
|
|
273
|
+
const separator = Math.max(id.lastIndexOf("/"), id.lastIndexOf("."), id.lastIndexOf("-"));
|
|
274
|
+
const tail = separator === -1 ? id : id.slice(separator + 1);
|
|
275
|
+
return tail || id;
|
|
276
|
+
}
|
|
277
|
+
function isAsciiDigit(code) {
|
|
278
|
+
return code >= 48 && code <= 57;
|
|
279
|
+
}
|
|
280
|
+
function focusTargetChips(targets, slides) {
|
|
281
|
+
return targets.map((target, index) => {
|
|
282
|
+
if (target.kind === "slide") {
|
|
283
|
+
const label2 = `Slide ${target.slideIndex + 1}`;
|
|
284
|
+
return { key: `slide-${target.slideIndex}-${index}`, label: label2, title: label2 };
|
|
285
|
+
}
|
|
286
|
+
const el = slides[target.slideIndex]?.elements.find((e) => e.id === target.elementId);
|
|
287
|
+
const typeLabel = el ? elementTypeLabel(el.type) : "Element";
|
|
288
|
+
const label = el ? `${typeLabel} ${shortElementId(target.elementId)}` : `${typeLabel} (missing)`;
|
|
289
|
+
return {
|
|
290
|
+
key: `el-${target.elementId}-${index}`,
|
|
291
|
+
label,
|
|
292
|
+
title: `${typeLabel}: ${target.elementId}`
|
|
293
|
+
};
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
function isTwoTableFocus(targets, slides) {
|
|
297
|
+
if (targets.length !== 2 || targets.some((target) => target.kind !== "element")) {
|
|
298
|
+
return false;
|
|
299
|
+
}
|
|
300
|
+
const [a, b] = targets;
|
|
301
|
+
if (a.slideIndex !== b.slideIndex) {
|
|
302
|
+
return false;
|
|
303
|
+
}
|
|
304
|
+
const slide = slides[a.slideIndex];
|
|
305
|
+
const elA = slide?.elements.find((e) => e.id === a.elementId);
|
|
306
|
+
const elB = slide?.elements.find((e) => e.id === b.elementId);
|
|
307
|
+
if (elA?.type !== "table" || elB?.type !== "table") {
|
|
308
|
+
return false;
|
|
309
|
+
}
|
|
310
|
+
return { slideIndex: a.slideIndex, elementIdA: a.elementId, elementIdB: b.elementId };
|
|
311
|
+
}
|
|
312
|
+
function mergeTablesDirective(slideIndex, elementIdA, elementIdB) {
|
|
313
|
+
return `Merge the two selected tables (elementIdA=${elementIdA}, elementIdB=${elementIdB}) on slide ${slideIndex + 1} using merge_tables; stage it now, do not ask me to confirm.`;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
// src/pptx/ai/panel-controller.ts
|
|
317
|
+
var AI_TOOL_FLASH_MS = 2600;
|
|
318
|
+
function aiFixDirective(element, slideIndex) {
|
|
319
|
+
return `Review and fix any issues with this ${element.type} (id=${element.id}) on slide ${slideIndex + 1}.`;
|
|
320
|
+
}
|
|
321
|
+
function resolveAiEffectiveTargets(state, liveTargets) {
|
|
322
|
+
if (state.pickTargets.length > 0) {
|
|
323
|
+
return state.pickTargets;
|
|
324
|
+
}
|
|
325
|
+
if (state.pinnedFocus && state.pinnedFocus.length > 0) {
|
|
326
|
+
return state.pinnedFocus;
|
|
327
|
+
}
|
|
328
|
+
return liveTargets;
|
|
329
|
+
}
|
|
330
|
+
function isAiFocusPinned(state) {
|
|
331
|
+
return state.pickTargets.length === 0 && state.pinnedFocus !== null;
|
|
332
|
+
}
|
|
333
|
+
function buildHighlights(pickTargets, toolFocus) {
|
|
334
|
+
const out = [];
|
|
335
|
+
for (const target of pickTargets) {
|
|
336
|
+
if (target.kind === "element") {
|
|
337
|
+
out.push({ slideIndex: target.slideIndex, elementId: target.elementId, variant: "pick" });
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
for (const elementId of toolFocus?.elementIds ?? []) {
|
|
341
|
+
out.push({ slideIndex: toolFocus?.slideIndex ?? 0, elementId, variant: "active" });
|
|
342
|
+
}
|
|
343
|
+
return out;
|
|
344
|
+
}
|
|
345
|
+
var INITIAL_STATE = {
|
|
346
|
+
isOpen: false,
|
|
347
|
+
pinnedFocus: null,
|
|
348
|
+
prefill: { text: "", nonce: 0 },
|
|
349
|
+
pickMode: false,
|
|
350
|
+
pickTargets: [],
|
|
351
|
+
canvasHighlights: [],
|
|
352
|
+
canvasAnimating: false,
|
|
353
|
+
changeBatch: null
|
|
354
|
+
};
|
|
355
|
+
function createPptxAiPanelController(deps) {
|
|
356
|
+
const store = chunkY6DO6SVT_cjs.createControllerStore(INITIAL_STATE);
|
|
357
|
+
let toolFocus = null;
|
|
358
|
+
let flashing = false;
|
|
359
|
+
let flashTimer = null;
|
|
360
|
+
const update = (patch) => {
|
|
361
|
+
store.update((current) => {
|
|
362
|
+
const next = { ...current, ...patch };
|
|
363
|
+
const canvasHighlights = buildHighlights(next.pickTargets, toolFocus);
|
|
364
|
+
const sameHighlights = canvasHighlights.length === current.canvasHighlights.length && canvasHighlights.every((h, i) => {
|
|
365
|
+
const prev = current.canvasHighlights[i];
|
|
366
|
+
return prev?.elementId === h.elementId && prev.slideIndex === h.slideIndex && prev.variant === h.variant;
|
|
367
|
+
});
|
|
368
|
+
return {
|
|
369
|
+
...next,
|
|
370
|
+
canvasHighlights: sameHighlights ? current.canvasHighlights : canvasHighlights,
|
|
371
|
+
canvasAnimating: flashing || canvasHighlights.length > 0
|
|
372
|
+
};
|
|
373
|
+
});
|
|
374
|
+
};
|
|
375
|
+
const liveTargets = () => computeFocusTargets(deps.getSelection());
|
|
376
|
+
const openPanel = (patch) => {
|
|
377
|
+
update({ ...patch, isOpen: true });
|
|
378
|
+
deps.onOpen?.();
|
|
379
|
+
};
|
|
380
|
+
const fixElement = (element, slideIndex) => {
|
|
381
|
+
const { prefill } = store.getSnapshot();
|
|
382
|
+
openPanel({
|
|
383
|
+
pinnedFocus: liveTargets(),
|
|
384
|
+
prefill: {
|
|
385
|
+
text: element ? aiFixDirective(element, slideIndex) : "",
|
|
386
|
+
nonce: prefill.nonce + 1
|
|
387
|
+
}
|
|
388
|
+
});
|
|
389
|
+
};
|
|
390
|
+
return {
|
|
391
|
+
getSnapshot: store.getSnapshot,
|
|
392
|
+
subscribe: store.subscribe,
|
|
393
|
+
open: () => openPanel({}),
|
|
394
|
+
close: () => update({ isOpen: false }),
|
|
395
|
+
toggle() {
|
|
396
|
+
if (store.getSnapshot().isOpen) {
|
|
397
|
+
update({ isOpen: false });
|
|
398
|
+
} else {
|
|
399
|
+
openPanel({});
|
|
400
|
+
}
|
|
401
|
+
},
|
|
402
|
+
getLiveTargets: liveTargets,
|
|
403
|
+
getEffectiveTargets: () => resolveAiEffectiveTargets(store.getSnapshot(), liveTargets()),
|
|
404
|
+
pinFocus: () => update({ pinnedFocus: liveTargets() }),
|
|
405
|
+
clearPinnedFocus: () => update({ pinnedFocus: null }),
|
|
406
|
+
askAboutSelection() {
|
|
407
|
+
const { prefill } = store.getSnapshot();
|
|
408
|
+
openPanel({ pinnedFocus: liveTargets(), prefill: { text: "", nonce: prefill.nonce + 1 } });
|
|
409
|
+
},
|
|
410
|
+
fixSelection() {
|
|
411
|
+
fixElement(deps.getSelectedElement?.(), deps.getSelection().activeSlideIndex);
|
|
412
|
+
},
|
|
413
|
+
fixElement,
|
|
414
|
+
startPicking: () => openPanel({ pickMode: true }),
|
|
415
|
+
stopPicking: () => update({ pickMode: false }),
|
|
416
|
+
addPick(slideIndex, elementId) {
|
|
417
|
+
const { pickTargets } = store.getSnapshot();
|
|
418
|
+
if (pickTargets.some((t) => t.kind === "element" && t.elementId === elementId)) {
|
|
419
|
+
return;
|
|
420
|
+
}
|
|
421
|
+
update({ pickTargets: [...pickTargets, { kind: "element", slideIndex, elementId }] });
|
|
422
|
+
},
|
|
423
|
+
clearPicks: () => update({ pickTargets: [], pickMode: false }),
|
|
424
|
+
flashToolTarget(target) {
|
|
425
|
+
toolFocus = target && target.slideIndex !== void 0 && target.elementIds.length > 0 ? { slideIndex: target.slideIndex, elementIds: target.elementIds } : null;
|
|
426
|
+
flashing = true;
|
|
427
|
+
if (flashTimer) {
|
|
428
|
+
clearTimeout(flashTimer);
|
|
429
|
+
}
|
|
430
|
+
flashTimer = setTimeout(() => {
|
|
431
|
+
toolFocus = null;
|
|
432
|
+
flashing = false;
|
|
433
|
+
flashTimer = null;
|
|
434
|
+
update({});
|
|
435
|
+
}, AI_TOOL_FLASH_MS);
|
|
436
|
+
update({});
|
|
437
|
+
},
|
|
438
|
+
showChangeBatch: (batch) => update({ changeBatch: batch }),
|
|
439
|
+
dispose() {
|
|
440
|
+
if (flashTimer) {
|
|
441
|
+
clearTimeout(flashTimer);
|
|
442
|
+
flashTimer = null;
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
};
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
// src/pptx/ai/change-diff.ts
|
|
449
|
+
function bounds(el) {
|
|
450
|
+
return { x: el.x, y: el.y, width: el.width, height: el.height };
|
|
451
|
+
}
|
|
452
|
+
function moved(a, b) {
|
|
453
|
+
return Math.abs(a.x - b.x) > 0.5 || Math.abs(a.y - b.y) > 0.5;
|
|
454
|
+
}
|
|
455
|
+
function resized(a, b) {
|
|
456
|
+
return Math.abs(a.width - b.width) > 0.5 || Math.abs(a.height - b.height) > 0.5;
|
|
457
|
+
}
|
|
458
|
+
function textOf(el) {
|
|
459
|
+
return "text" in el && typeof el.text === "string" ? el.text : void 0;
|
|
460
|
+
}
|
|
461
|
+
function styleSignature(el) {
|
|
462
|
+
const rest = { ...el };
|
|
463
|
+
delete rest["x"];
|
|
464
|
+
delete rest["y"];
|
|
465
|
+
delete rest["width"];
|
|
466
|
+
delete rest["height"];
|
|
467
|
+
delete rest["id"];
|
|
468
|
+
delete rest["rotation"];
|
|
469
|
+
return JSON.stringify(rest);
|
|
470
|
+
}
|
|
471
|
+
function classify(before, after) {
|
|
472
|
+
if (moved(before, after)) {
|
|
473
|
+
return "moved";
|
|
474
|
+
}
|
|
475
|
+
if (resized(before, after)) {
|
|
476
|
+
return "resized";
|
|
477
|
+
}
|
|
478
|
+
if (textOf(before) !== textOf(after)) {
|
|
479
|
+
return "text";
|
|
480
|
+
}
|
|
481
|
+
if (styleSignature(before) !== styleSignature(after)) {
|
|
482
|
+
return "restyled";
|
|
483
|
+
}
|
|
484
|
+
return null;
|
|
485
|
+
}
|
|
486
|
+
function diffChangedElements(before, after) {
|
|
487
|
+
const changes = [];
|
|
488
|
+
const beforeById = new Map(before.map((s) => [s.id, s]));
|
|
489
|
+
after.forEach((afterSlide, slideIndex) => {
|
|
490
|
+
const beforeSlide = beforeById.get(afterSlide.id) ?? before[slideIndex];
|
|
491
|
+
const beforeEls = new Map((beforeSlide?.elements ?? []).map((e) => [e.id, e]));
|
|
492
|
+
const afterIds = new Set(afterSlide.elements.map((e) => e.id));
|
|
493
|
+
for (const el of afterSlide.elements) {
|
|
494
|
+
const prev = beforeEls.get(el.id);
|
|
495
|
+
if (!prev) {
|
|
496
|
+
changes.push({ slideIndex, elementId: el.id, kind: "added", to: bounds(el) });
|
|
497
|
+
continue;
|
|
498
|
+
}
|
|
499
|
+
const kind = classify(prev, el);
|
|
500
|
+
if (kind) {
|
|
501
|
+
changes.push({ slideIndex, elementId: el.id, kind, from: bounds(prev), to: bounds(el) });
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
for (const prev of beforeSlide?.elements ?? []) {
|
|
505
|
+
if (!afterIds.has(prev.id)) {
|
|
506
|
+
changes.push({
|
|
507
|
+
slideIndex,
|
|
508
|
+
elementId: prev.id,
|
|
509
|
+
kind: "removed",
|
|
510
|
+
from: bounds(prev)
|
|
511
|
+
});
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
});
|
|
515
|
+
return changes;
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
// src/pptx/ai/change-animator.ts
|
|
519
|
+
var DEFAULTS = {
|
|
520
|
+
enabled: true,
|
|
521
|
+
durationMs: 900,
|
|
522
|
+
glow: true,
|
|
523
|
+
tween: true,
|
|
524
|
+
color: "rgba(59,130,246,1)"
|
|
525
|
+
};
|
|
526
|
+
function resolveChangeAnimationConfig(config) {
|
|
527
|
+
return {
|
|
528
|
+
enabled: config?.enabled ?? DEFAULTS.enabled,
|
|
529
|
+
durationMs: config?.durationMs ?? DEFAULTS.durationMs,
|
|
530
|
+
glow: config?.glow ?? DEFAULTS.glow,
|
|
531
|
+
tween: config?.tween ?? DEFAULTS.tween,
|
|
532
|
+
color: config?.color ?? DEFAULTS.color
|
|
533
|
+
};
|
|
534
|
+
}
|
|
535
|
+
var defaultSchedule = (fn, ms) => {
|
|
536
|
+
const id = setTimeout(fn, ms);
|
|
537
|
+
return () => clearTimeout(id);
|
|
538
|
+
};
|
|
539
|
+
function createAiChangeAnimator(config, schedule = defaultSchedule) {
|
|
540
|
+
let resolved = resolveChangeAnimationConfig(config);
|
|
541
|
+
let batch = null;
|
|
542
|
+
let nonce = 0;
|
|
543
|
+
let cancelClear = null;
|
|
544
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
545
|
+
const emit = () => {
|
|
546
|
+
for (const l of listeners) {
|
|
547
|
+
l(batch);
|
|
548
|
+
}
|
|
549
|
+
};
|
|
550
|
+
return {
|
|
551
|
+
publish(before, after) {
|
|
552
|
+
if (!resolved.enabled) {
|
|
553
|
+
return null;
|
|
554
|
+
}
|
|
555
|
+
const changes = diffChangedElements(before, after);
|
|
556
|
+
if (changes.length === 0) {
|
|
557
|
+
return null;
|
|
558
|
+
}
|
|
559
|
+
cancelClear?.();
|
|
560
|
+
nonce += 1;
|
|
561
|
+
batch = { changes, slideIndex: changes[0].slideIndex, nonce, config: resolved };
|
|
562
|
+
emit();
|
|
563
|
+
cancelClear = schedule(() => {
|
|
564
|
+
batch = null;
|
|
565
|
+
cancelClear = null;
|
|
566
|
+
emit();
|
|
567
|
+
}, resolved.durationMs + 250);
|
|
568
|
+
return batch;
|
|
569
|
+
},
|
|
570
|
+
subscribe(listener) {
|
|
571
|
+
listeners.add(listener);
|
|
572
|
+
return () => listeners.delete(listener);
|
|
573
|
+
},
|
|
574
|
+
current: () => batch,
|
|
575
|
+
configure(next) {
|
|
576
|
+
resolved = resolveChangeAnimationConfig(next);
|
|
577
|
+
},
|
|
578
|
+
dispose() {
|
|
579
|
+
cancelClear?.();
|
|
580
|
+
cancelClear = null;
|
|
581
|
+
listeners.clear();
|
|
582
|
+
batch = null;
|
|
583
|
+
}
|
|
584
|
+
};
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
// src/pptx/ai/change-animation-css.ts
|
|
588
|
+
var AI_CHANGE_ATTR = "data-pptx-ai-changed";
|
|
589
|
+
function aiChangeAnimationCss(config) {
|
|
590
|
+
const { color, durationMs } = config;
|
|
591
|
+
return `
|
|
592
|
+
@keyframes pptx-ai-change-glow {
|
|
593
|
+
0% { box-shadow: 0 0 0 0 ${color}, 0 0 0 0 ${color}; }
|
|
594
|
+
50% { box-shadow: 0 0 0 4px transparent, 0 0 16px 5px ${color}; }
|
|
595
|
+
100% { box-shadow: 0 0 0 0 transparent, 0 0 10px 2px transparent; }
|
|
596
|
+
}
|
|
597
|
+
[${AI_CHANGE_ATTR}] {
|
|
598
|
+
animation: pptx-ai-change-glow ${durationMs}ms ease-out;
|
|
599
|
+
outline: 2px solid ${color};
|
|
600
|
+
outline-offset: 1px;
|
|
601
|
+
border-radius: 3px;
|
|
602
|
+
transition: color ${Math.round(durationMs / 2)}ms ease, fill ${Math.round(durationMs / 2)}ms ease,
|
|
603
|
+
stroke ${Math.round(durationMs / 2)}ms ease, background-color ${Math.round(durationMs / 2)}ms ease;
|
|
604
|
+
}
|
|
605
|
+
`;
|
|
606
|
+
}
|
|
607
|
+
var PAD = 3;
|
|
608
|
+
function changeGhostStyle(change, phase, config) {
|
|
609
|
+
const at = phase === "start" ? change.from ?? change.to : change.to ?? change.from;
|
|
610
|
+
const box = at ?? { x: 0, y: 0, width: 0, height: 0 };
|
|
611
|
+
const ms = config.durationMs;
|
|
612
|
+
const tween = config.tween;
|
|
613
|
+
let opacity = 1;
|
|
614
|
+
let transform = "scale(1)";
|
|
615
|
+
if (change.kind === "added") {
|
|
616
|
+
opacity = phase === "start" ? 0 : 1;
|
|
617
|
+
transform = phase === "start" ? "scale(0.92)" : "scale(1)";
|
|
618
|
+
} else if (change.kind === "removed") {
|
|
619
|
+
opacity = phase === "start" ? 0.9 : 0;
|
|
620
|
+
transform = phase === "start" ? "scale(1)" : "scale(0.92)";
|
|
621
|
+
} else {
|
|
622
|
+
opacity = phase === "start" ? 0.85 : 0;
|
|
623
|
+
}
|
|
624
|
+
const transition = tween ? `left ${ms}ms ease, top ${ms}ms ease, width ${ms}ms ease, height ${ms}ms ease, opacity ${ms}ms ease, transform ${ms}ms ease` : `opacity ${ms}ms ease`;
|
|
625
|
+
return {
|
|
626
|
+
position: "absolute",
|
|
627
|
+
left: box.x - PAD,
|
|
628
|
+
top: box.y - PAD,
|
|
629
|
+
width: box.width + PAD * 2,
|
|
630
|
+
height: box.height + PAD * 2,
|
|
631
|
+
opacity,
|
|
632
|
+
transform,
|
|
633
|
+
transition,
|
|
634
|
+
boxShadow: config.glow ? `0 0 14px 3px ${config.color}` : "none",
|
|
635
|
+
border: `2px solid ${config.color}`,
|
|
636
|
+
borderRadius: "4px",
|
|
637
|
+
pointerEvents: "none",
|
|
638
|
+
zIndex: 9997
|
|
639
|
+
};
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
// src/pptx/ai/ui-parts.ts
|
|
643
|
+
function isTextPart(part) {
|
|
644
|
+
return part.type === "text";
|
|
645
|
+
}
|
|
646
|
+
function isToolPart(part) {
|
|
647
|
+
return typeof part.type === "string" && part.type.startsWith("tool-");
|
|
648
|
+
}
|
|
649
|
+
function isDynamicToolPart(part) {
|
|
650
|
+
return part.type === "dynamic-tool";
|
|
651
|
+
}
|
|
652
|
+
function toolNameOf(part) {
|
|
653
|
+
if (isDynamicToolPart(part)) {
|
|
654
|
+
return part.toolName ?? "tool";
|
|
655
|
+
}
|
|
656
|
+
return typeof part.type === "string" ? part.type.slice("tool-".length) : "tool";
|
|
657
|
+
}
|
|
658
|
+
var READY_TOOL_STATES = /* @__PURE__ */ new Set([
|
|
659
|
+
"input-available",
|
|
660
|
+
"output-available",
|
|
661
|
+
"output-error"
|
|
662
|
+
]);
|
|
663
|
+
function extractReadyToolCalls(messages) {
|
|
664
|
+
const out = [];
|
|
665
|
+
for (const message of messages) {
|
|
666
|
+
for (const rawPart of message.parts) {
|
|
667
|
+
const part = rawPart;
|
|
668
|
+
if (!isToolPart(part) && !isDynamicToolPart(part)) {
|
|
669
|
+
continue;
|
|
670
|
+
}
|
|
671
|
+
const toolCallId = part.toolCallId ?? "";
|
|
672
|
+
if (toolCallId.length === 0 || part.input === void 0) {
|
|
673
|
+
continue;
|
|
674
|
+
}
|
|
675
|
+
if (!READY_TOOL_STATES.has(part.state ?? "")) {
|
|
676
|
+
continue;
|
|
677
|
+
}
|
|
678
|
+
out.push({ toolName: toolNameOf(part), toolCallId, input: part.input });
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
return out;
|
|
682
|
+
}
|
|
683
|
+
function toRenderableParts(message) {
|
|
684
|
+
const out = [];
|
|
685
|
+
for (const rawPart of message.parts) {
|
|
686
|
+
const part = rawPart;
|
|
687
|
+
if (isTextPart(part)) {
|
|
688
|
+
const text = part.text ?? "";
|
|
689
|
+
if (text.trim().length > 0) {
|
|
690
|
+
out.push({ kind: "text", text });
|
|
691
|
+
}
|
|
692
|
+
continue;
|
|
693
|
+
}
|
|
694
|
+
if (isToolPart(part) || isDynamicToolPart(part)) {
|
|
695
|
+
out.push({
|
|
696
|
+
kind: "tool",
|
|
697
|
+
toolName: toolNameOf(part),
|
|
698
|
+
toolCallId: part.toolCallId ?? "",
|
|
699
|
+
state: part.state ?? "input-streaming",
|
|
700
|
+
input: part.input,
|
|
701
|
+
output: part.output,
|
|
702
|
+
errorText: part.errorText
|
|
703
|
+
});
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
return out;
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
// src/pptx/ai/chat-log-export.ts
|
|
710
|
+
function isoOf(ms) {
|
|
711
|
+
const n = Number.isFinite(ms) ? ms : 0;
|
|
712
|
+
return new Date(n).toISOString();
|
|
713
|
+
}
|
|
714
|
+
function toLogChat(chat, detailed) {
|
|
715
|
+
const messages = chat.messages.map((message) => {
|
|
716
|
+
const parts = toRenderableParts(message);
|
|
717
|
+
const textRuns = [];
|
|
718
|
+
const toolCalls = [];
|
|
719
|
+
for (const part of parts) {
|
|
720
|
+
if (part.kind === "text") {
|
|
721
|
+
textRuns.push(part.text);
|
|
722
|
+
continue;
|
|
723
|
+
}
|
|
724
|
+
toolCalls.push({
|
|
725
|
+
toolName: part.toolName,
|
|
726
|
+
toolCallId: part.toolCallId,
|
|
727
|
+
state: part.state,
|
|
728
|
+
input: detailed ? part.input : void 0,
|
|
729
|
+
output: detailed ? part.output : void 0,
|
|
730
|
+
errorText: part.errorText
|
|
731
|
+
});
|
|
732
|
+
}
|
|
733
|
+
return {
|
|
734
|
+
role: message.role,
|
|
735
|
+
text: textRuns.join("\n\n"),
|
|
736
|
+
toolCalls
|
|
737
|
+
};
|
|
738
|
+
});
|
|
739
|
+
return {
|
|
740
|
+
id: chat.id,
|
|
741
|
+
title: chat.title,
|
|
742
|
+
deckId: chat.deckId,
|
|
743
|
+
createdAt: chat.createdAt,
|
|
744
|
+
updatedAt: chat.updatedAt,
|
|
745
|
+
createdAtIso: isoOf(chat.createdAt),
|
|
746
|
+
updatedAtIso: isoOf(chat.updatedAt),
|
|
747
|
+
messageCount: chat.messages.length,
|
|
748
|
+
messages
|
|
749
|
+
};
|
|
750
|
+
}
|
|
751
|
+
function buildChatLogExport(chats, options) {
|
|
752
|
+
const detailed = options?.detailed ?? true;
|
|
753
|
+
const now = options?.now ?? Date.now();
|
|
754
|
+
return {
|
|
755
|
+
format: "pptx-ai-chat-log",
|
|
756
|
+
version: 1,
|
|
757
|
+
exportedAt: isoOf(now),
|
|
758
|
+
detailed,
|
|
759
|
+
chatCount: chats.length,
|
|
760
|
+
chats: chats.map((chat) => toLogChat(chat, detailed))
|
|
761
|
+
};
|
|
762
|
+
}
|
|
763
|
+
function toolCallLine(call, detailed) {
|
|
764
|
+
const lines = [`- Tool \`${call.toolName}\` (${call.state})`];
|
|
765
|
+
if (call.errorText) {
|
|
766
|
+
lines.push(` - error: ${call.errorText}`);
|
|
767
|
+
}
|
|
768
|
+
if (detailed) {
|
|
769
|
+
lines.push(" - input:");
|
|
770
|
+
lines.push(" ```json");
|
|
771
|
+
lines.push(JSON.stringify(call.input ?? null, null, 2));
|
|
772
|
+
lines.push(" ```");
|
|
773
|
+
lines.push(" - output:");
|
|
774
|
+
lines.push(" ```json");
|
|
775
|
+
lines.push(JSON.stringify(call.output ?? null, null, 2));
|
|
776
|
+
lines.push(" ```");
|
|
777
|
+
}
|
|
778
|
+
return lines.join("\n");
|
|
779
|
+
}
|
|
780
|
+
function buildChatLogMarkdown(doc) {
|
|
781
|
+
const out = [
|
|
782
|
+
`# AI chat logs`,
|
|
783
|
+
"",
|
|
784
|
+
`Exported: ${doc.exportedAt}`,
|
|
785
|
+
`Chats: ${doc.chatCount}`,
|
|
786
|
+
""
|
|
787
|
+
];
|
|
788
|
+
for (const chat of doc.chats) {
|
|
789
|
+
out.push(`## ${chat.title || chat.id}`);
|
|
790
|
+
out.push("");
|
|
791
|
+
out.push(`- id: ${chat.id}`);
|
|
792
|
+
if (chat.deckId) {
|
|
793
|
+
out.push(`- deck: ${chat.deckId}`);
|
|
794
|
+
}
|
|
795
|
+
out.push(`- created: ${chat.createdAtIso}`);
|
|
796
|
+
out.push(`- updated: ${chat.updatedAtIso}`);
|
|
797
|
+
out.push(`- messages: ${chat.messageCount}`);
|
|
798
|
+
out.push("");
|
|
799
|
+
for (const message of chat.messages) {
|
|
800
|
+
out.push(`### ${message.role}`);
|
|
801
|
+
out.push("");
|
|
802
|
+
if (message.text) {
|
|
803
|
+
out.push(message.text);
|
|
804
|
+
out.push("");
|
|
805
|
+
}
|
|
806
|
+
for (const call of message.toolCalls) {
|
|
807
|
+
out.push(toolCallLine(call, doc.detailed));
|
|
808
|
+
out.push("");
|
|
809
|
+
}
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
return out.join("\n");
|
|
813
|
+
}
|
|
814
|
+
async function collectStoredChats(store = chunkA5MANNJR_cjs.createChatHistoryStore()) {
|
|
815
|
+
const summaries = await store.listChats();
|
|
816
|
+
const chats = [];
|
|
817
|
+
for (const summary of summaries) {
|
|
818
|
+
const chat = await store.loadChat(summary.id);
|
|
819
|
+
if (chat) {
|
|
820
|
+
chats.push(chat);
|
|
821
|
+
}
|
|
822
|
+
}
|
|
823
|
+
return chats;
|
|
824
|
+
}
|
|
825
|
+
function timestampSlug(now) {
|
|
826
|
+
const d = new Date(now);
|
|
827
|
+
const p = (n) => String(n).padStart(2, "0");
|
|
828
|
+
return `${d.getFullYear()}${p(d.getMonth() + 1)}${p(d.getDate())}-${p(d.getHours())}${p(d.getMinutes())}${p(d.getSeconds())}`;
|
|
829
|
+
}
|
|
830
|
+
function exportAiChatLogs(chats, meta, save) {
|
|
831
|
+
if (chats.length === 0) {
|
|
832
|
+
return 0;
|
|
833
|
+
}
|
|
834
|
+
const now = meta?.now ?? Date.now();
|
|
835
|
+
const doc = buildChatLogExport(chats, { detailed: meta?.detailed ?? true, now });
|
|
836
|
+
const slug = timestampSlug(now);
|
|
837
|
+
const format = meta?.format ?? "json";
|
|
838
|
+
if (format === "markdown") {
|
|
839
|
+
save(`pptx-ai-chats-${slug}.md`, buildChatLogMarkdown(doc), "text/markdown");
|
|
840
|
+
} else {
|
|
841
|
+
save(`pptx-ai-chats-${slug}.json`, JSON.stringify(doc, null, 2), "application/json");
|
|
842
|
+
}
|
|
843
|
+
return chats.length;
|
|
844
|
+
}
|
|
845
|
+
|
|
846
|
+
exports.AI_CHANGE_ATTR = AI_CHANGE_ATTR;
|
|
847
|
+
exports.AI_TOOL_FLASH_MS = AI_TOOL_FLASH_MS;
|
|
848
|
+
exports.aiChangeAnimationCss = aiChangeAnimationCss;
|
|
849
|
+
exports.aiFixDirective = aiFixDirective;
|
|
850
|
+
exports.applyElementUpdate = applyElementUpdate;
|
|
851
|
+
exports.applyShapeStyleUpdate = applyShapeStyleUpdate;
|
|
852
|
+
exports.applyTextUpdate = applyTextUpdate;
|
|
853
|
+
exports.buildChatLogExport = buildChatLogExport;
|
|
854
|
+
exports.buildChatLogMarkdown = buildChatLogMarkdown;
|
|
855
|
+
exports.changeGhostStyle = changeGhostStyle;
|
|
856
|
+
exports.collectStoredChats = collectStoredChats;
|
|
857
|
+
exports.computeFocusTargets = computeFocusTargets;
|
|
858
|
+
exports.createAiChangeAnimator = createAiChangeAnimator;
|
|
859
|
+
exports.createPptxAiBridge = createPptxAiBridge;
|
|
860
|
+
exports.createPptxAiPanelController = createPptxAiPanelController;
|
|
861
|
+
exports.deckDataFieldChanged = deckDataFieldChanged;
|
|
862
|
+
exports.diffChangedElements = diffChangedElements;
|
|
863
|
+
exports.exportAiChatLogs = exportAiChatLogs;
|
|
864
|
+
exports.extractReadyToolCalls = extractReadyToolCalls;
|
|
865
|
+
exports.focusTargetChips = focusTargetChips;
|
|
866
|
+
exports.isAiFocusPinned = isAiFocusPinned;
|
|
867
|
+
exports.isTwoTableFocus = isTwoTableFocus;
|
|
868
|
+
exports.mergeTablesDirective = mergeTablesDirective;
|
|
869
|
+
exports.pptxAiDeckTitle = pptxAiDeckTitle;
|
|
870
|
+
exports.resolveAiEffectiveTargets = resolveAiEffectiveTargets;
|
|
871
|
+
exports.resolveChangeAnimationConfig = resolveChangeAnimationConfig;
|
|
872
|
+
exports.toLogChat = toLogChat;
|
|
873
|
+
exports.toRenderableParts = toRenderableParts;
|
|
874
|
+
exports.toolCallLine = toolCallLine;
|