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.
Files changed (73) hide show
  1. package/dist/chart/format-pane-3d.d.ts +1 -0
  2. package/dist/chart/format-pane-fill-kinds.d.ts +0 -1
  3. package/dist/chart/format-pane-targets.d.ts +0 -1
  4. package/dist/chart/format-pane-types.d.ts +0 -1
  5. package/dist/chart/format-pane-view.d.ts +0 -1
  6. package/dist/{chunk-2EFIFIPB.js → chunk-LNHFMJ2P.js} +1 -1
  7. package/dist/{chunk-FHO7TEWA.js → chunk-WYKMVMX4.js} +14 -1
  8. package/dist/{chunk-WBE2Q5DC.js → chunk-YMZFOG2U.js} +2 -2
  9. package/dist/comments/mentions.d.ts +63 -0
  10. package/dist/comments/mentions.d.ts.map +1 -0
  11. package/dist/form/checkable.d.ts +0 -1
  12. package/dist/index.js +3 -3
  13. package/dist/pptx/ai/host.cjs +121 -0
  14. package/dist/pptx/ai/host.d.ts +39 -0
  15. package/dist/pptx/ai/host.d.ts.map +1 -0
  16. package/dist/pptx/ai/host.mjs +4 -0
  17. package/dist/pptx/ai/index.cjs +120 -870
  18. package/dist/pptx/ai/index.mjs +6 -842
  19. package/dist/pptx/{chunk-WBFAVFD4.cjs → chunk-BXCXY4HB.cjs} +722 -279
  20. package/dist/pptx/{chunk-CT7UD6VL.mjs → chunk-DVLU476S.mjs} +688 -231
  21. package/dist/pptx/{chunk-MJACF7Y2.mjs → chunk-EHIQ4ANA.mjs} +5 -0
  22. package/dist/pptx/chunk-IY7H76CZ.cjs +874 -0
  23. package/dist/pptx/{chunk-GWKTHP6U.cjs → chunk-PATUICO4.cjs} +5 -0
  24. package/dist/pptx/{chunk-3AFB46RL.cjs → chunk-UTBHXIDK.cjs} +46 -46
  25. package/dist/pptx/{chunk-7OD74VJC.mjs → chunk-YO3EMGXD.mjs} +2 -2
  26. package/dist/pptx/chunk-YQANSI3A.mjs +844 -0
  27. package/dist/pptx/dom/glyph-outline-cache.d.ts +3 -1
  28. package/dist/pptx/dom/glyph-outline-cache.d.ts.map +1 -1
  29. package/dist/pptx/dom/index.cjs +399 -398
  30. package/dist/pptx/dom/index.mjs +15 -14
  31. package/dist/pptx/dom/load-presentation.d.ts +7 -1
  32. package/dist/pptx/dom/load-presentation.d.ts.map +1 -1
  33. package/dist/pptx/export/html2canvas-clone.cjs +4 -4
  34. package/dist/pptx/export/html2canvas-clone.mjs +1 -1
  35. package/dist/pptx/export/print-document.cjs +18 -18
  36. package/dist/pptx/export/print-document.mjs +2 -2
  37. package/dist/pptx/i18n/index.cjs +6 -6
  38. package/dist/pptx/i18n/index.mjs +1 -1
  39. package/dist/pptx/i18n/translations-en.d.ts.map +1 -1
  40. package/dist/pptx/index.cjs +3185 -3161
  41. package/dist/pptx/index.mjs +9 -9
  42. package/dist/pptx/render/comment-mentions.d.ts +16 -1
  43. package/dist/pptx/render/comment-mentions.d.ts.map +1 -1
  44. package/dist/pptx/render/comments-list.d.ts +11 -7
  45. package/dist/pptx/render/comments-list.d.ts.map +1 -1
  46. package/dist/pptx/render/embedded-font-trust.d.ts +7 -0
  47. package/dist/pptx/render/embedded-font-trust.d.ts.map +1 -1
  48. package/dist/pptx/render/embedded-fonts.d.ts +4 -3
  49. package/dist/pptx/render/embedded-fonts.d.ts.map +1 -1
  50. package/dist/pptx/render/glyph-outline-font-registration.d.ts +83 -0
  51. package/dist/pptx/render/glyph-outline-font-registration.d.ts.map +1 -0
  52. package/dist/pptx/render/index.d.ts +2 -0
  53. package/dist/pptx/render/index.d.ts.map +1 -1
  54. package/dist/pptx/render/load-limits.d.ts +18 -0
  55. package/dist/pptx/render/load-limits.d.ts.map +1 -0
  56. package/dist/pptx/render/text-warp-glyph-outline-lookup.d.ts +39 -0
  57. package/dist/pptx/render/text-warp-glyph-outline-lookup.d.ts.map +1 -0
  58. package/dist/pptx/render/text-warp-opentype-parser.d.ts +15 -2
  59. package/dist/pptx/render/text-warp-opentype-parser.d.ts.map +1 -1
  60. package/dist/pptx/render/text-warp-outline-font-cache.d.ts +116 -42
  61. package/dist/pptx/render/text-warp-outline-font-cache.d.ts.map +1 -1
  62. package/dist/pptx/render/viewer-props-manifest.d.ts.map +1 -1
  63. package/dist/pptx/{smartart-insert-preview-3BY6HNZL.cjs → smartart-insert-preview-DHQ47GXP.cjs} +11 -11
  64. package/dist/pptx/{smartart-insert-preview-7CRBDPYF.mjs → smartart-insert-preview-IQVC5LMF.mjs} +10 -10
  65. package/dist/{presentation-preview-KY56TONW.js → presentation-preview-XGJMARKI.js} +1 -1
  66. package/dist/teams/app/presentation-preview.d.ts +3 -0
  67. package/dist/teams.js +2 -2
  68. package/dist/xlsx.js +4 -4
  69. package/package.json +8 -8
  70. package/dist/pptx/{chunk-YMITEJST.cjs → chunk-3CYWRMYZ.cjs} +1 -1
  71. package/dist/pptx/{chunk-3LOVEO7U.mjs → chunk-5VSUIPDX.mjs} +1 -1
  72. /package/dist/pptx/{chunk-FM4C4MBJ.cjs → chunk-67UQWOEQ.cjs} +0 -0
  73. /package/dist/pptx/{chunk-AMW2AR7J.mjs → chunk-6MZFWTBS.mjs} +0 -0
@@ -1,8 +1,10 @@
1
+ import { createAiChangeAnimator } from '../chunk-YQANSI3A.mjs';
2
+ export { AI_CHANGE_ATTR, AI_TOOL_FLASH_MS, aiChangeAnimationCss, aiFixDirective, applyElementUpdate, applyShapeStyleUpdate, applyTextUpdate, buildChatLogExport, buildChatLogMarkdown, changeGhostStyle, collectStoredChats, computeFocusTargets, createAiChangeAnimator, createPptxAiBridge, createPptxAiPanelController, deckDataFieldChanged, diffChangedElements, exportAiChatLogs, extractReadyToolCalls, focusTargetChips, isAiFocusPinned, isTwoTableFocus, mergeTablesDirective, pptxAiDeckTitle, resolveAiEffectiveTargets, resolveChangeAnimationConfig, toLogChat, toRenderableParts, toolCallLine } from '../chunk-YQANSI3A.mjs';
1
3
  import { createChatHistoryStore } from '../chunk-LVDF75JU.mjs';
2
4
  export { createChatHistoryStore } from '../chunk-LVDF75JU.mjs';
3
- import { createControllerStore } from '../chunk-WM5SW737.mjs';
4
- import { updateTextSegmentStyle } from '../chunk-PEDGPFLR.mjs';
5
- import { ThemePresets, PptxMarkdownConverter, hasTextProperties, hasShapeProperties } from 'ooxml-core/pptx';
5
+ import '../chunk-WM5SW737.mjs';
6
+ import '../chunk-PEDGPFLR.mjs';
7
+ import { ThemePresets, PptxMarkdownConverter } from 'ooxml-core/pptx';
6
8
  import { z } from 'zod';
7
9
  import { mergeTableElements } from 'ooxml-core/pptx/editor/ai/table-merge';
8
10
  export { mergeTableElements } from 'ooxml-core/pptx/editor/ai/table-merge';
@@ -29,446 +31,6 @@ function resetAiSdkCache() {
29
31
  cached = void 0;
30
32
  }
31
33
 
32
- // src/pptx/ai/deck-data-diff.ts
33
- function deckDataFieldChanged(a, b) {
34
- return JSON.stringify(a) !== JSON.stringify(b);
35
- }
36
- function applyElementUpdate(el, u) {
37
- if (u.x !== void 0) {
38
- el.x = u.x;
39
- }
40
- if (u.y !== void 0) {
41
- el.y = u.y;
42
- }
43
- if (u.width !== void 0) {
44
- el.width = u.width;
45
- }
46
- if (u.height !== void 0) {
47
- el.height = u.height;
48
- }
49
- if (u.rotation !== void 0) {
50
- el.rotation = u.rotation;
51
- }
52
- if (u.opacity !== void 0) {
53
- el.opacity = u.opacity;
54
- }
55
- if (u.hidden !== void 0) {
56
- el.hidden = u.hidden;
57
- }
58
- if (u.flipHorizontal !== void 0) {
59
- el.flipHorizontal = u.flipHorizontal;
60
- }
61
- if (u.flipVertical !== void 0) {
62
- el.flipVertical = u.flipVertical;
63
- }
64
- applyTextUpdate(el, u);
65
- applyShapeStyleUpdate(el, u);
66
- }
67
- function applyTextUpdate(el, u) {
68
- if (!hasTextProperties(el)) {
69
- return;
70
- }
71
- const textEl = el;
72
- if (u.text !== void 0) {
73
- textEl.text = u.text;
74
- if (textEl.textSegments && textEl.textSegments.length > 0) {
75
- textEl.textSegments[0].text = u.text;
76
- } else {
77
- textEl.textSegments = [{ text: u.text, style: {} }];
78
- }
79
- }
80
- 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) {
81
- return;
82
- }
83
- const textStyle = {};
84
- if (u.fontSize !== void 0) {
85
- textStyle.fontSize = u.fontSize;
86
- }
87
- if (u.fontFamily !== void 0) {
88
- textStyle.fontFamily = u.fontFamily;
89
- }
90
- if (u.fontColor !== void 0) {
91
- textStyle.color = u.fontColor;
92
- }
93
- if (u.bold !== void 0) {
94
- textStyle.bold = u.bold;
95
- }
96
- if (u.italic !== void 0) {
97
- textStyle.italic = u.italic;
98
- }
99
- if (u.underline !== void 0) {
100
- textStyle.underline = u.underline;
101
- }
102
- if (u.align !== void 0) {
103
- textStyle.align = u.align;
104
- }
105
- textEl.textStyle = { ...textEl.textStyle, ...textStyle };
106
- if (textEl.textSegments) {
107
- textEl.textSegments = textEl.textSegments.map((seg) => updateTextSegmentStyle(seg, textStyle));
108
- }
109
- }
110
- function applyShapeStyleUpdate(el, u) {
111
- if (u.fillColor === void 0 && u.strokeColor === void 0 && u.strokeWidth === void 0) {
112
- return;
113
- }
114
- if (!hasShapeProperties(el)) {
115
- return;
116
- }
117
- const holder = el;
118
- holder.shapeStyle ??= {};
119
- const style = holder.shapeStyle;
120
- if (u.fillColor !== void 0) {
121
- style.fillColor = u.fillColor;
122
- }
123
- if (u.strokeColor !== void 0) {
124
- style.strokeColor = u.strokeColor;
125
- }
126
- if (u.strokeWidth !== void 0) {
127
- style.strokeWidth = u.strokeWidth;
128
- }
129
- }
130
-
131
- // src/pptx/ai/bridge-factory.ts
132
- var TITLE_MAX_LENGTH = 120;
133
- function pptxAiDeckTitle(slides) {
134
- for (const element of slides[0]?.elements ?? []) {
135
- const text = "text" in element && typeof element.text === "string" ? element.text.trim() : "";
136
- if (text) {
137
- return text.slice(0, TITLE_MAX_LENGTH);
138
- }
139
- }
140
- return void 0;
141
- }
142
- function copy(list) {
143
- return list ? [...list] : void 0;
144
- }
145
- function readDeckData(port) {
146
- const canvas = port.getCanvasSize();
147
- return {
148
- slides: [...port.getSlides()],
149
- width: canvas.width,
150
- height: canvas.height,
151
- theme: port.getTheme(),
152
- sections: copy(port.getSections()),
153
- presentationProperties: port.getPresentationProperties(),
154
- customProperties: copy(port.getCustomProperties()),
155
- coreProperties: port.getCoreProperties(),
156
- appProperties: port.getAppProperties(),
157
- viewProperties: port.getViewProperties(),
158
- tableStyleMap: port.getTableStyleMap(),
159
- tableStylesDefaultId: port.getTableStylesDefaultId(),
160
- tags: copy(port.getTagCollections())
161
- };
162
- }
163
- function commitDocumentProperties(port, before, after) {
164
- const differs = deckDataFieldChanged;
165
- const core = after.coreProperties ?? before.coreProperties;
166
- const app = after.appProperties ?? before.appProperties;
167
- const custom = after.customProperties ?? before.customProperties ?? [];
168
- const coreChanged = differs(before.coreProperties, core);
169
- if (!coreChanged && !differs(before.appProperties, app) && !differs(before.customProperties, custom)) {
170
- return false;
171
- }
172
- port.setDocumentProperties(core ?? {}, app ?? {}, custom);
173
- if (coreChanged && core) {
174
- port.onCorePropertiesChanged?.(core);
175
- }
176
- return true;
177
- }
178
- function commitDeckData(port, before, after, label) {
179
- const differs = deckDataFieldChanged;
180
- let changed = false;
181
- if (differs(before.slides, after.slides)) {
182
- port.updateSlides(() => after.slides, label);
183
- changed = true;
184
- }
185
- if (before.width !== after.width || before.height !== after.height) {
186
- port.setCanvasSize({ width: after.width, height: after.height });
187
- changed = true;
188
- }
189
- const sections = after.sections ?? before.sections ?? [];
190
- if (differs(before.sections, sections)) {
191
- port.setSections(sections);
192
- changed = true;
193
- }
194
- const presentation = after.presentationProperties ?? before.presentationProperties ?? {};
195
- if (differs(before.presentationProperties, presentation)) {
196
- port.setPresentationProperties(presentation);
197
- changed = true;
198
- }
199
- changed = commitDocumentProperties(port, before, after) || changed;
200
- if (differs(before.viewProperties, after.viewProperties)) {
201
- port.setViewProperties(after.viewProperties);
202
- changed = true;
203
- }
204
- if (differs(before.tableStyleMap, after.tableStyleMap)) {
205
- port.setTableStyleMap(after.tableStyleMap ?? {});
206
- changed = true;
207
- }
208
- if (differs(before.tableStylesDefaultId, after.tableStylesDefaultId)) {
209
- port.setTableStylesDefaultId(after.tableStylesDefaultId);
210
- changed = true;
211
- }
212
- const tags = after.tags ?? before.tags ?? [];
213
- if (differs(before.tags, tags)) {
214
- port.setTagCollections(tags);
215
- changed = true;
216
- }
217
- return changed;
218
- }
219
- function createPptxAiBridge(port) {
220
- const applySlidesUpdate = (updater, label) => {
221
- port.updateSlides((current) => updater(structuredClone([...current])), label);
222
- };
223
- const bridge = {
224
- getDeckMeta() {
225
- const slides = port.getSlides();
226
- const canvas = port.getCanvasSize();
227
- return {
228
- slideCount: slides.length,
229
- activeSlideIndex: port.getActiveSlideIndex(),
230
- title: port.getFileName?.() ?? pptxAiDeckTitle(slides),
231
- width: canvas.width,
232
- height: canvas.height
233
- };
234
- },
235
- getSlides: () => [...port.getSlides()],
236
- getActiveSlideIndex: () => port.getActiveSlideIndex(),
237
- getTheme: () => port.getTheme(),
238
- getHandler: () => port.getHandler() ?? void 0,
239
- goToSlide: (index) => port.goToSlide(index),
240
- selectElements: (slideIndex2, elementIds) => port.selectElements(slideIndex2, elementIds),
241
- applySlidesUpdate,
242
- updateElement(slideIndex2, elementId2, updates) {
243
- applySlidesUpdate((slides) => {
244
- const element = slides[slideIndex2]?.elements.find((el) => el.id === elementId2);
245
- if (element) {
246
- applyElementUpdate(element, updates);
247
- }
248
- return slides;
249
- }, `Update element ${elementId2}`);
250
- },
251
- applyTheme: (updates) => port.applyTheme(updates),
252
- getDeckData: () => readDeckData(port),
253
- applyDeckData(updater, label) {
254
- const before = readDeckData(port);
255
- const after = updater(structuredClone(before));
256
- if (commitDeckData(port, before, after, label)) {
257
- port.afterDeckUpdate?.();
258
- }
259
- }
260
- };
261
- if (port.getFocusedTargets) {
262
- bridge.getFocusedTargets = () => port.getFocusedTargets?.() ?? [];
263
- }
264
- if (port.notify) {
265
- bridge.notify = (message, level) => port.notify?.(message, level);
266
- }
267
- return bridge;
268
- }
269
-
270
- // src/pptx/ai/focus-targets.ts
271
- function computeFocusTargets(input) {
272
- const { activeSlideIndex, selectedElementIds, selectedElementId } = input;
273
- const ids = selectedElementIds.length > 0 ? [...selectedElementIds] : selectedElementId ? [selectedElementId] : [];
274
- if (ids.length === 0) {
275
- return [{ kind: "slide", slideIndex: activeSlideIndex }];
276
- }
277
- return ids.map((elementId2) => ({ kind: "element", slideIndex: activeSlideIndex, elementId: elementId2 }));
278
- }
279
- function elementTypeLabel(type) {
280
- if (type === "smartArt") {
281
- return "SmartArt";
282
- }
283
- if (type === "ole") {
284
- return "OLE";
285
- }
286
- return type.charAt(0).toUpperCase() + type.slice(1);
287
- }
288
- function shortElementId(id) {
289
- const trimmed = id.trimEnd();
290
- let start = trimmed.length;
291
- while (start > 0 && isAsciiDigit(trimmed.charCodeAt(start - 1))) {
292
- start -= 1;
293
- }
294
- if (start < trimmed.length) {
295
- return trimmed.slice(start);
296
- }
297
- const separator = Math.max(id.lastIndexOf("/"), id.lastIndexOf("."), id.lastIndexOf("-"));
298
- const tail = separator === -1 ? id : id.slice(separator + 1);
299
- return tail || id;
300
- }
301
- function isAsciiDigit(code) {
302
- return code >= 48 && code <= 57;
303
- }
304
- function focusTargetChips(targets, slides) {
305
- return targets.map((target, index) => {
306
- if (target.kind === "slide") {
307
- const label2 = `Slide ${target.slideIndex + 1}`;
308
- return { key: `slide-${target.slideIndex}-${index}`, label: label2, title: label2 };
309
- }
310
- const el = slides[target.slideIndex]?.elements.find((e) => e.id === target.elementId);
311
- const typeLabel = el ? elementTypeLabel(el.type) : "Element";
312
- const label = el ? `${typeLabel} ${shortElementId(target.elementId)}` : `${typeLabel} (missing)`;
313
- return {
314
- key: `el-${target.elementId}-${index}`,
315
- label,
316
- title: `${typeLabel}: ${target.elementId}`
317
- };
318
- });
319
- }
320
- function isTwoTableFocus(targets, slides) {
321
- if (targets.length !== 2 || targets.some((target) => target.kind !== "element")) {
322
- return false;
323
- }
324
- const [a, b] = targets;
325
- if (a.slideIndex !== b.slideIndex) {
326
- return false;
327
- }
328
- const slide = slides[a.slideIndex];
329
- const elA = slide?.elements.find((e) => e.id === a.elementId);
330
- const elB = slide?.elements.find((e) => e.id === b.elementId);
331
- if (elA?.type !== "table" || elB?.type !== "table") {
332
- return false;
333
- }
334
- return { slideIndex: a.slideIndex, elementIdA: a.elementId, elementIdB: b.elementId };
335
- }
336
- function mergeTablesDirective(slideIndex2, elementIdA, elementIdB) {
337
- return `Merge the two selected tables (elementIdA=${elementIdA}, elementIdB=${elementIdB}) on slide ${slideIndex2 + 1} using merge_tables; stage it now, do not ask me to confirm.`;
338
- }
339
-
340
- // src/pptx/ai/panel-controller.ts
341
- var AI_TOOL_FLASH_MS = 2600;
342
- function aiFixDirective(element, slideIndex2) {
343
- return `Review and fix any issues with this ${element.type} (id=${element.id}) on slide ${slideIndex2 + 1}.`;
344
- }
345
- function resolveAiEffectiveTargets(state, liveTargets) {
346
- if (state.pickTargets.length > 0) {
347
- return state.pickTargets;
348
- }
349
- if (state.pinnedFocus && state.pinnedFocus.length > 0) {
350
- return state.pinnedFocus;
351
- }
352
- return liveTargets;
353
- }
354
- function isAiFocusPinned(state) {
355
- return state.pickTargets.length === 0 && state.pinnedFocus !== null;
356
- }
357
- function buildHighlights(pickTargets, toolFocus) {
358
- const out = [];
359
- for (const target of pickTargets) {
360
- if (target.kind === "element") {
361
- out.push({ slideIndex: target.slideIndex, elementId: target.elementId, variant: "pick" });
362
- }
363
- }
364
- for (const elementId2 of toolFocus?.elementIds ?? []) {
365
- out.push({ slideIndex: toolFocus?.slideIndex ?? 0, elementId: elementId2, variant: "active" });
366
- }
367
- return out;
368
- }
369
- var INITIAL_STATE = {
370
- isOpen: false,
371
- pinnedFocus: null,
372
- prefill: { text: "", nonce: 0 },
373
- pickMode: false,
374
- pickTargets: [],
375
- canvasHighlights: [],
376
- canvasAnimating: false,
377
- changeBatch: null
378
- };
379
- function createPptxAiPanelController(deps) {
380
- const store = createControllerStore(INITIAL_STATE);
381
- let toolFocus = null;
382
- let flashing = false;
383
- let flashTimer = null;
384
- const update = (patch) => {
385
- store.update((current) => {
386
- const next = { ...current, ...patch };
387
- const canvasHighlights = buildHighlights(next.pickTargets, toolFocus);
388
- const sameHighlights = canvasHighlights.length === current.canvasHighlights.length && canvasHighlights.every((h, i) => {
389
- const prev = current.canvasHighlights[i];
390
- return prev?.elementId === h.elementId && prev.slideIndex === h.slideIndex && prev.variant === h.variant;
391
- });
392
- return {
393
- ...next,
394
- canvasHighlights: sameHighlights ? current.canvasHighlights : canvasHighlights,
395
- canvasAnimating: flashing || canvasHighlights.length > 0
396
- };
397
- });
398
- };
399
- const liveTargets = () => computeFocusTargets(deps.getSelection());
400
- const openPanel = (patch) => {
401
- update({ ...patch, isOpen: true });
402
- deps.onOpen?.();
403
- };
404
- const fixElement = (element, slideIndex2) => {
405
- const { prefill } = store.getSnapshot();
406
- openPanel({
407
- pinnedFocus: liveTargets(),
408
- prefill: {
409
- text: element ? aiFixDirective(element, slideIndex2) : "",
410
- nonce: prefill.nonce + 1
411
- }
412
- });
413
- };
414
- return {
415
- getSnapshot: store.getSnapshot,
416
- subscribe: store.subscribe,
417
- open: () => openPanel({}),
418
- close: () => update({ isOpen: false }),
419
- toggle() {
420
- if (store.getSnapshot().isOpen) {
421
- update({ isOpen: false });
422
- } else {
423
- openPanel({});
424
- }
425
- },
426
- getLiveTargets: liveTargets,
427
- getEffectiveTargets: () => resolveAiEffectiveTargets(store.getSnapshot(), liveTargets()),
428
- pinFocus: () => update({ pinnedFocus: liveTargets() }),
429
- clearPinnedFocus: () => update({ pinnedFocus: null }),
430
- askAboutSelection() {
431
- const { prefill } = store.getSnapshot();
432
- openPanel({ pinnedFocus: liveTargets(), prefill: { text: "", nonce: prefill.nonce + 1 } });
433
- },
434
- fixSelection() {
435
- fixElement(deps.getSelectedElement?.(), deps.getSelection().activeSlideIndex);
436
- },
437
- fixElement,
438
- startPicking: () => openPanel({ pickMode: true }),
439
- stopPicking: () => update({ pickMode: false }),
440
- addPick(slideIndex2, elementId2) {
441
- const { pickTargets } = store.getSnapshot();
442
- if (pickTargets.some((t) => t.kind === "element" && t.elementId === elementId2)) {
443
- return;
444
- }
445
- update({ pickTargets: [...pickTargets, { kind: "element", slideIndex: slideIndex2, elementId: elementId2 }] });
446
- },
447
- clearPicks: () => update({ pickTargets: [], pickMode: false }),
448
- flashToolTarget(target) {
449
- toolFocus = target && target.slideIndex !== void 0 && target.elementIds.length > 0 ? { slideIndex: target.slideIndex, elementIds: target.elementIds } : null;
450
- flashing = true;
451
- if (flashTimer) {
452
- clearTimeout(flashTimer);
453
- }
454
- flashTimer = setTimeout(() => {
455
- toolFocus = null;
456
- flashing = false;
457
- flashTimer = null;
458
- update({});
459
- }, AI_TOOL_FLASH_MS);
460
- update({});
461
- },
462
- showChangeBatch: (batch) => update({ changeBatch: batch }),
463
- dispose() {
464
- if (flashTimer) {
465
- clearTimeout(flashTimer);
466
- flashTimer = null;
467
- }
468
- }
469
- };
470
- }
471
-
472
34
  // src/pptx/ai/config.ts
473
35
  function resolveChatTransport(options) {
474
36
  const { sdk, connection } = options;
@@ -1692,145 +1254,6 @@ function buildToolSet(sdk, config, executors, options) {
1692
1254
  return { ...tools, ...config.tools?.extra ?? {} };
1693
1255
  }
1694
1256
 
1695
- // src/pptx/ai/change-diff.ts
1696
- function bounds2(el) {
1697
- return { x: el.x, y: el.y, width: el.width, height: el.height };
1698
- }
1699
- function moved(a, b) {
1700
- return Math.abs(a.x - b.x) > 0.5 || Math.abs(a.y - b.y) > 0.5;
1701
- }
1702
- function resized(a, b) {
1703
- return Math.abs(a.width - b.width) > 0.5 || Math.abs(a.height - b.height) > 0.5;
1704
- }
1705
- function textOf(el) {
1706
- return "text" in el && typeof el.text === "string" ? el.text : void 0;
1707
- }
1708
- function styleSignature(el) {
1709
- const rest = { ...el };
1710
- delete rest["x"];
1711
- delete rest["y"];
1712
- delete rest["width"];
1713
- delete rest["height"];
1714
- delete rest["id"];
1715
- delete rest["rotation"];
1716
- return JSON.stringify(rest);
1717
- }
1718
- function classify(before, after) {
1719
- if (moved(before, after)) {
1720
- return "moved";
1721
- }
1722
- if (resized(before, after)) {
1723
- return "resized";
1724
- }
1725
- if (textOf(before) !== textOf(after)) {
1726
- return "text";
1727
- }
1728
- if (styleSignature(before) !== styleSignature(after)) {
1729
- return "restyled";
1730
- }
1731
- return null;
1732
- }
1733
- function diffChangedElements(before, after) {
1734
- const changes = [];
1735
- const beforeById = new Map(before.map((s) => [s.id, s]));
1736
- after.forEach((afterSlide, slideIndex2) => {
1737
- const beforeSlide = beforeById.get(afterSlide.id) ?? before[slideIndex2];
1738
- const beforeEls = new Map((beforeSlide?.elements ?? []).map((e) => [e.id, e]));
1739
- const afterIds = new Set(afterSlide.elements.map((e) => e.id));
1740
- for (const el of afterSlide.elements) {
1741
- const prev = beforeEls.get(el.id);
1742
- if (!prev) {
1743
- changes.push({ slideIndex: slideIndex2, elementId: el.id, kind: "added", to: bounds2(el) });
1744
- continue;
1745
- }
1746
- const kind = classify(prev, el);
1747
- if (kind) {
1748
- changes.push({ slideIndex: slideIndex2, elementId: el.id, kind, from: bounds2(prev), to: bounds2(el) });
1749
- }
1750
- }
1751
- for (const prev of beforeSlide?.elements ?? []) {
1752
- if (!afterIds.has(prev.id)) {
1753
- changes.push({
1754
- slideIndex: slideIndex2,
1755
- elementId: prev.id,
1756
- kind: "removed",
1757
- from: bounds2(prev)
1758
- });
1759
- }
1760
- }
1761
- });
1762
- return changes;
1763
- }
1764
-
1765
- // src/pptx/ai/change-animator.ts
1766
- var DEFAULTS = {
1767
- enabled: true,
1768
- durationMs: 900,
1769
- glow: true,
1770
- tween: true,
1771
- color: "rgba(59,130,246,1)"
1772
- };
1773
- function resolveChangeAnimationConfig(config) {
1774
- return {
1775
- enabled: config?.enabled ?? DEFAULTS.enabled,
1776
- durationMs: config?.durationMs ?? DEFAULTS.durationMs,
1777
- glow: config?.glow ?? DEFAULTS.glow,
1778
- tween: config?.tween ?? DEFAULTS.tween,
1779
- color: config?.color ?? DEFAULTS.color
1780
- };
1781
- }
1782
- var defaultSchedule = (fn, ms) => {
1783
- const id = setTimeout(fn, ms);
1784
- return () => clearTimeout(id);
1785
- };
1786
- function createAiChangeAnimator(config, schedule = defaultSchedule) {
1787
- let resolved = resolveChangeAnimationConfig(config);
1788
- let batch = null;
1789
- let nonce = 0;
1790
- let cancelClear = null;
1791
- const listeners = /* @__PURE__ */ new Set();
1792
- const emit = () => {
1793
- for (const l of listeners) {
1794
- l(batch);
1795
- }
1796
- };
1797
- return {
1798
- publish(before, after) {
1799
- if (!resolved.enabled) {
1800
- return null;
1801
- }
1802
- const changes = diffChangedElements(before, after);
1803
- if (changes.length === 0) {
1804
- return null;
1805
- }
1806
- cancelClear?.();
1807
- nonce += 1;
1808
- batch = { changes, slideIndex: changes[0].slideIndex, nonce, config: resolved };
1809
- emit();
1810
- cancelClear = schedule(() => {
1811
- batch = null;
1812
- cancelClear = null;
1813
- emit();
1814
- }, resolved.durationMs + 250);
1815
- return batch;
1816
- },
1817
- subscribe(listener) {
1818
- listeners.add(listener);
1819
- return () => listeners.delete(listener);
1820
- },
1821
- current: () => batch,
1822
- configure(next) {
1823
- resolved = resolveChangeAnimationConfig(next);
1824
- },
1825
- dispose() {
1826
- cancelClear?.();
1827
- cancelClear = null;
1828
- listeners.clear();
1829
- batch = null;
1830
- }
1831
- };
1832
- }
1833
-
1834
1257
  // src/pptx/ai/session.ts
1835
1258
  async function createAiChatSession(bridge, config) {
1836
1259
  const sdk = await loadAiSdk();
@@ -1875,265 +1298,6 @@ async function createAiChatSession(bridge, config) {
1875
1298
  };
1876
1299
  }
1877
1300
 
1878
- // src/pptx/ai/change-animation-css.ts
1879
- var AI_CHANGE_ATTR = "data-pptx-ai-changed";
1880
- function aiChangeAnimationCss(config) {
1881
- const { color, durationMs } = config;
1882
- return `
1883
- @keyframes pptx-ai-change-glow {
1884
- 0% { box-shadow: 0 0 0 0 ${color}, 0 0 0 0 ${color}; }
1885
- 50% { box-shadow: 0 0 0 4px transparent, 0 0 16px 5px ${color}; }
1886
- 100% { box-shadow: 0 0 0 0 transparent, 0 0 10px 2px transparent; }
1887
- }
1888
- [${AI_CHANGE_ATTR}] {
1889
- animation: pptx-ai-change-glow ${durationMs}ms ease-out;
1890
- outline: 2px solid ${color};
1891
- outline-offset: 1px;
1892
- border-radius: 3px;
1893
- transition: color ${Math.round(durationMs / 2)}ms ease, fill ${Math.round(durationMs / 2)}ms ease,
1894
- stroke ${Math.round(durationMs / 2)}ms ease, background-color ${Math.round(durationMs / 2)}ms ease;
1895
- }
1896
- `;
1897
- }
1898
- var PAD = 3;
1899
- function changeGhostStyle(change, phase, config) {
1900
- const at = phase === "start" ? change.from ?? change.to : change.to ?? change.from;
1901
- const box = at ?? { x: 0, y: 0, width: 0, height: 0 };
1902
- const ms = config.durationMs;
1903
- const tween = config.tween;
1904
- let opacity = 1;
1905
- let transform = "scale(1)";
1906
- if (change.kind === "added") {
1907
- opacity = phase === "start" ? 0 : 1;
1908
- transform = phase === "start" ? "scale(0.92)" : "scale(1)";
1909
- } else if (change.kind === "removed") {
1910
- opacity = phase === "start" ? 0.9 : 0;
1911
- transform = phase === "start" ? "scale(1)" : "scale(0.92)";
1912
- } else {
1913
- opacity = phase === "start" ? 0.85 : 0;
1914
- }
1915
- 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`;
1916
- return {
1917
- position: "absolute",
1918
- left: box.x - PAD,
1919
- top: box.y - PAD,
1920
- width: box.width + PAD * 2,
1921
- height: box.height + PAD * 2,
1922
- opacity,
1923
- transform,
1924
- transition,
1925
- boxShadow: config.glow ? `0 0 14px 3px ${config.color}` : "none",
1926
- border: `2px solid ${config.color}`,
1927
- borderRadius: "4px",
1928
- pointerEvents: "none",
1929
- zIndex: 9997
1930
- };
1931
- }
1932
-
1933
- // src/pptx/ai/ui-parts.ts
1934
- function isTextPart(part) {
1935
- return part.type === "text";
1936
- }
1937
- function isToolPart(part) {
1938
- return typeof part.type === "string" && part.type.startsWith("tool-");
1939
- }
1940
- function isDynamicToolPart(part) {
1941
- return part.type === "dynamic-tool";
1942
- }
1943
- function toolNameOf(part) {
1944
- if (isDynamicToolPart(part)) {
1945
- return part.toolName ?? "tool";
1946
- }
1947
- return typeof part.type === "string" ? part.type.slice("tool-".length) : "tool";
1948
- }
1949
- var READY_TOOL_STATES = /* @__PURE__ */ new Set([
1950
- "input-available",
1951
- "output-available",
1952
- "output-error"
1953
- ]);
1954
- function extractReadyToolCalls(messages) {
1955
- const out = [];
1956
- for (const message of messages) {
1957
- for (const rawPart of message.parts) {
1958
- const part = rawPart;
1959
- if (!isToolPart(part) && !isDynamicToolPart(part)) {
1960
- continue;
1961
- }
1962
- const toolCallId = part.toolCallId ?? "";
1963
- if (toolCallId.length === 0 || part.input === void 0) {
1964
- continue;
1965
- }
1966
- if (!READY_TOOL_STATES.has(part.state ?? "")) {
1967
- continue;
1968
- }
1969
- out.push({ toolName: toolNameOf(part), toolCallId, input: part.input });
1970
- }
1971
- }
1972
- return out;
1973
- }
1974
- function toRenderableParts(message) {
1975
- const out = [];
1976
- for (const rawPart of message.parts) {
1977
- const part = rawPart;
1978
- if (isTextPart(part)) {
1979
- const text = part.text ?? "";
1980
- if (text.trim().length > 0) {
1981
- out.push({ kind: "text", text });
1982
- }
1983
- continue;
1984
- }
1985
- if (isToolPart(part) || isDynamicToolPart(part)) {
1986
- out.push({
1987
- kind: "tool",
1988
- toolName: toolNameOf(part),
1989
- toolCallId: part.toolCallId ?? "",
1990
- state: part.state ?? "input-streaming",
1991
- input: part.input,
1992
- output: part.output,
1993
- errorText: part.errorText
1994
- });
1995
- }
1996
- }
1997
- return out;
1998
- }
1999
-
2000
- // src/pptx/ai/chat-log-export.ts
2001
- function isoOf(ms) {
2002
- const n = Number.isFinite(ms) ? ms : 0;
2003
- return new Date(n).toISOString();
2004
- }
2005
- function toLogChat(chat, detailed) {
2006
- const messages = chat.messages.map((message) => {
2007
- const parts = toRenderableParts(message);
2008
- const textRuns = [];
2009
- const toolCalls = [];
2010
- for (const part of parts) {
2011
- if (part.kind === "text") {
2012
- textRuns.push(part.text);
2013
- continue;
2014
- }
2015
- toolCalls.push({
2016
- toolName: part.toolName,
2017
- toolCallId: part.toolCallId,
2018
- state: part.state,
2019
- input: detailed ? part.input : void 0,
2020
- output: detailed ? part.output : void 0,
2021
- errorText: part.errorText
2022
- });
2023
- }
2024
- return {
2025
- role: message.role,
2026
- text: textRuns.join("\n\n"),
2027
- toolCalls
2028
- };
2029
- });
2030
- return {
2031
- id: chat.id,
2032
- title: chat.title,
2033
- deckId: chat.deckId,
2034
- createdAt: chat.createdAt,
2035
- updatedAt: chat.updatedAt,
2036
- createdAtIso: isoOf(chat.createdAt),
2037
- updatedAtIso: isoOf(chat.updatedAt),
2038
- messageCount: chat.messages.length,
2039
- messages
2040
- };
2041
- }
2042
- function buildChatLogExport(chats, options) {
2043
- const detailed = options?.detailed ?? true;
2044
- const now = options?.now ?? Date.now();
2045
- return {
2046
- format: "pptx-ai-chat-log",
2047
- version: 1,
2048
- exportedAt: isoOf(now),
2049
- detailed,
2050
- chatCount: chats.length,
2051
- chats: chats.map((chat) => toLogChat(chat, detailed))
2052
- };
2053
- }
2054
- function toolCallLine(call, detailed) {
2055
- const lines = [`- Tool \`${call.toolName}\` (${call.state})`];
2056
- if (call.errorText) {
2057
- lines.push(` - error: ${call.errorText}`);
2058
- }
2059
- if (detailed) {
2060
- lines.push(" - input:");
2061
- lines.push(" ```json");
2062
- lines.push(JSON.stringify(call.input ?? null, null, 2));
2063
- lines.push(" ```");
2064
- lines.push(" - output:");
2065
- lines.push(" ```json");
2066
- lines.push(JSON.stringify(call.output ?? null, null, 2));
2067
- lines.push(" ```");
2068
- }
2069
- return lines.join("\n");
2070
- }
2071
- function buildChatLogMarkdown(doc) {
2072
- const out = [
2073
- `# AI chat logs`,
2074
- "",
2075
- `Exported: ${doc.exportedAt}`,
2076
- `Chats: ${doc.chatCount}`,
2077
- ""
2078
- ];
2079
- for (const chat of doc.chats) {
2080
- out.push(`## ${chat.title || chat.id}`);
2081
- out.push("");
2082
- out.push(`- id: ${chat.id}`);
2083
- if (chat.deckId) {
2084
- out.push(`- deck: ${chat.deckId}`);
2085
- }
2086
- out.push(`- created: ${chat.createdAtIso}`);
2087
- out.push(`- updated: ${chat.updatedAtIso}`);
2088
- out.push(`- messages: ${chat.messageCount}`);
2089
- out.push("");
2090
- for (const message of chat.messages) {
2091
- out.push(`### ${message.role}`);
2092
- out.push("");
2093
- if (message.text) {
2094
- out.push(message.text);
2095
- out.push("");
2096
- }
2097
- for (const call of message.toolCalls) {
2098
- out.push(toolCallLine(call, doc.detailed));
2099
- out.push("");
2100
- }
2101
- }
2102
- }
2103
- return out.join("\n");
2104
- }
2105
- async function collectStoredChats(store = createChatHistoryStore()) {
2106
- const summaries = await store.listChats();
2107
- const chats = [];
2108
- for (const summary of summaries) {
2109
- const chat = await store.loadChat(summary.id);
2110
- if (chat) {
2111
- chats.push(chat);
2112
- }
2113
- }
2114
- return chats;
2115
- }
2116
- function timestampSlug(now) {
2117
- const d = new Date(now);
2118
- const p = (n) => String(n).padStart(2, "0");
2119
- return `${d.getFullYear()}${p(d.getMonth() + 1)}${p(d.getDate())}-${p(d.getHours())}${p(d.getMinutes())}${p(d.getSeconds())}`;
2120
- }
2121
- function exportAiChatLogs(chats, meta, save) {
2122
- if (chats.length === 0) {
2123
- return 0;
2124
- }
2125
- const now = meta?.now ?? Date.now();
2126
- const doc = buildChatLogExport(chats, { detailed: meta?.detailed ?? true, now });
2127
- const slug = timestampSlug(now);
2128
- const format = meta?.format ?? "json";
2129
- if (format === "markdown") {
2130
- save(`pptx-ai-chats-${slug}.md`, buildChatLogMarkdown(doc), "text/markdown");
2131
- } else {
2132
- save(`pptx-ai-chats-${slug}.json`, JSON.stringify(doc, null, 2), "application/json");
2133
- }
2134
- return chats.length;
2135
- }
2136
-
2137
1301
  // src/pptx/ai/chat-history-controller.ts
2138
1302
  var SAVE_DEBOUNCE_MS = 800;
2139
1303
  var TITLE_MAX = 40;
@@ -2762,4 +1926,4 @@ function toolCanvasTarget(toolName, input) {
2762
1926
  return { slideIndex: slideIndex2, elementIds };
2763
1927
  }
2764
1928
 
2765
- export { AI_CHANGE_ATTR, AI_TOOL_FLASH_MS, BASE_SYSTEM_PROMPT, BESPOKE_TOOL_ENTRIES, MCP_TOOL_ENTRIES, ProposalStore, aiChangeAnimationCss, aiFixDirective, allToolNames, applyElementUpdate, applyShapeStyleUpdate, applyTextUpdate, buildChatLogExport, buildChatLogMarkdown, buildDeckContext, buildDeckOutline, buildFocusedTargetsContext, buildPptxAiSystemPrompt, buildPptxAiTools, buildSlideMarkdown, buildSystemPrompt, buildToolExecutors, buildToolSet, changeGhostStyle, clampToTokenBudget, collectStoredChats, computeFocusTargets, createAiChangeAnimator, createAiChatHistoryController, createAiChatSession, createPptxAiBridge, createPptxAiPanelController, createVanillaChat, deckDataFieldChanged, deckIdFromBridge, deriveChatTitle, describeToolActivity, diffChangedElements, diffSlides, enabledToolNames, estimateTokens, exportAiChatLogs, extractReadyToolCalls, focusTargetChips, humanizeDiffLine, isAiAvailable, isAiFocusPinned, isTwoTableFocus, loadAiSdk, mergeTablesDirective, newChatId, pptxAiDeckTitle, requireElement, requireSlide, resetAiSdkCache, resolveAiEffectiveTargets, resolveChangeAnimationConfig, resolveChatTransport, routeWrite, runSharedTool, slideTitle, summarizeToolArgs, toLogChat, toRenderableParts, toolCallLine, toolCanvasTarget, toolLabel };
1929
+ export { BASE_SYSTEM_PROMPT, BESPOKE_TOOL_ENTRIES, MCP_TOOL_ENTRIES, ProposalStore, allToolNames, buildDeckContext, buildDeckOutline, buildFocusedTargetsContext, buildPptxAiSystemPrompt, buildPptxAiTools, buildSlideMarkdown, buildSystemPrompt, buildToolExecutors, buildToolSet, clampToTokenBudget, createAiChatHistoryController, createAiChatSession, createVanillaChat, deckIdFromBridge, deriveChatTitle, describeToolActivity, diffSlides, enabledToolNames, estimateTokens, humanizeDiffLine, isAiAvailable, loadAiSdk, newChatId, requireElement, requireSlide, resetAiSdkCache, resolveChatTransport, routeWrite, runSharedTool, slideTitle, summarizeToolArgs, toolCanvasTarget, toolLabel };