ooxml-core 1.37.1 → 1.38.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 (135) hide show
  1. package/README.md +7 -0
  2. package/dist/{PptxHandler-3T5DTNKA.mjs → PptxHandler-EB2WFF7F.mjs} +2 -2
  3. package/dist/PptxHandler-GOCSIX7N.cjs +14 -0
  4. package/dist/PptxHandler-IAKU53YW.mjs +5 -0
  5. package/dist/{PresentationBuilder-XHKNDJMD.mjs → PresentationBuilder-T2B5PPZA.mjs} +2 -2
  6. package/dist/{PresentationBuilder-HCMXZQDK.cjs → PresentationBuilder-TS4MR6KG.cjs} +6 -6
  7. package/dist/{PresentationBuilder-D6ZICJWN.mjs → PresentationBuilder-VMUWJF2X.mjs} +3 -3
  8. package/dist/automation/index.cjs +213 -208
  9. package/dist/automation/index.mjs +213 -208
  10. package/dist/{chunk-J43V3QOA.mjs → chunk-6XLWR7R6.mjs} +126 -42
  11. package/dist/{chunk-4YBSHQ76.mjs → chunk-7YOCVZRH.mjs} +2 -2
  12. package/dist/{chunk-GZOYXHDF.cjs → chunk-JXNUXGX3.cjs} +1266 -1266
  13. package/dist/{chunk-2TQJHNVU.mjs → chunk-LWNNHK2S.mjs} +259 -175
  14. package/dist/{chunk-OEM2ECAJ.mjs → chunk-RDMUNMGT.mjs} +1 -1
  15. package/dist/{chunk-RHQQS6LJ.mjs → chunk-SN5R5YNF.mjs} +2 -2
  16. package/dist/{chunk-CNIKTXAV.mjs → chunk-U54ZCZKG.mjs} +1 -1
  17. package/dist/{chunk-H2Q42P6P.mjs → chunk-UOEYAYAH.mjs} +1 -1
  18. package/dist/{chunk-SNID2FDY.cjs → chunk-WF4USSCT.cjs} +259 -175
  19. package/dist/{chunk-M2DFN3SP.mjs → chunk-XFLXQUTC.mjs} +645 -58
  20. package/dist/{chunk-AFALJ5TA.cjs → chunk-ZTX5YCSW.cjs} +3 -3
  21. package/dist/collab/merge-values.d.ts +14 -0
  22. package/dist/collab/merge-values.d.ts.map +1 -0
  23. package/dist/docx/embedded.cjs +476 -474
  24. package/dist/docx/embedded.mjs +476 -474
  25. package/dist/docx/index.cjs +1094 -719
  26. package/dist/docx/index.d.ts +1 -0
  27. package/dist/docx/index.d.ts.map +1 -1
  28. package/dist/docx/index.mjs +1094 -720
  29. package/dist/docx/layout/index.cjs +4 -0
  30. package/dist/docx/layout/index.mjs +4 -0
  31. package/dist/docx/load/index.cjs +164 -164
  32. package/dist/docx/load/index.mjs +164 -164
  33. package/dist/docx/merge-snapshots.d.ts +9 -0
  34. package/dist/docx/merge-snapshots.d.ts.map +1 -0
  35. package/dist/docx/ui/index.cjs +155 -155
  36. package/dist/docx/ui/index.mjs +155 -155
  37. package/dist/embedding/index.cjs +207 -0
  38. package/dist/embedding/index.d.ts +3 -0
  39. package/dist/embedding/index.d.ts.map +1 -1
  40. package/dist/embedding/index.mjs +205 -1
  41. package/dist/embedding/onedrive/client.d.ts +4 -0
  42. package/dist/embedding/onedrive/client.d.ts.map +1 -0
  43. package/dist/embedding/onedrive/index.cjs +617 -0
  44. package/dist/embedding/onedrive/index.d.ts +6 -0
  45. package/dist/embedding/onedrive/index.d.ts.map +1 -0
  46. package/dist/embedding/onedrive/index.mjs +611 -0
  47. package/dist/embedding/onedrive/metadata.d.ts +6 -0
  48. package/dist/embedding/onedrive/metadata.d.ts.map +1 -0
  49. package/dist/embedding/onedrive/requests.d.ts +8 -0
  50. package/dist/embedding/onedrive/requests.d.ts.map +1 -0
  51. package/dist/embedding/onedrive/session.d.ts +4 -0
  52. package/dist/embedding/onedrive/session.d.ts.map +1 -0
  53. package/dist/embedding/onedrive/transport.d.ts +9 -0
  54. package/dist/embedding/onedrive/transport.d.ts.map +1 -0
  55. package/dist/embedding/onedrive/types.d.ts +86 -0
  56. package/dist/embedding/onedrive/types.d.ts.map +1 -0
  57. package/dist/embedding/onedrive/upload.d.ts +3 -0
  58. package/dist/embedding/onedrive/upload.d.ts.map +1 -0
  59. package/dist/embedding/storage-merge.d.ts +8 -0
  60. package/dist/embedding/storage-merge.d.ts.map +1 -0
  61. package/dist/embedding/storage-session.d.ts +7 -0
  62. package/dist/embedding/storage-session.d.ts.map +1 -0
  63. package/dist/embedding/versioned-storage.d.ts +67 -0
  64. package/dist/embedding/versioned-storage.d.ts.map +1 -0
  65. package/dist/index.cjs +1032 -340
  66. package/dist/index.mjs +1032 -340
  67. package/dist/opc/index.cjs +699 -216
  68. package/dist/opc/index.d.ts +1 -0
  69. package/dist/opc/index.d.ts.map +1 -1
  70. package/dist/opc/index.mjs +699 -217
  71. package/dist/opc/merge-snapshots.d.ts +26 -0
  72. package/dist/opc/merge-snapshots.d.ts.map +1 -0
  73. package/dist/pptx/automation/index.cjs +165 -47
  74. package/dist/pptx/automation/index.d.ts +1 -1
  75. package/dist/pptx/automation/index.mjs +5 -5
  76. package/dist/pptx/chunks/{index-DC5m1m_8.d.ts → index-uDL5LUSK.d.ts} +20 -6
  77. package/dist/pptx/chunks/index-uDL5LUSK.d.ts.map +1 -0
  78. package/dist/pptx/cli/index.cjs +165 -47
  79. package/dist/pptx/cli/index.mjs +4 -4
  80. package/dist/pptx/converter/index.cjs +7 -0
  81. package/dist/pptx/converter/index.mjs +2 -2
  82. package/dist/pptx/editor/render/custom-show-operations.cjs +2 -2
  83. package/dist/pptx/editor/render/custom-show-operations.mjs +1 -1
  84. package/dist/pptx/editor/render/find-replace.cjs +15 -15
  85. package/dist/pptx/editor/render/find-replace.d.ts +1 -1
  86. package/dist/pptx/editor/render/find-replace.mjs +2 -2
  87. package/dist/pptx/editor/render/slide-operations.cjs +9 -9
  88. package/dist/pptx/editor/render/slide-operations.mjs +3 -3
  89. package/dist/pptx/index.cjs +6156 -5428
  90. package/dist/pptx/index.d.ts +2 -2
  91. package/dist/pptx/index.mjs +5 -5
  92. package/dist/teams/index.cjs +215 -201
  93. package/dist/teams/index.mjs +215 -201
  94. package/dist/text/index.cjs +193 -0
  95. package/dist/text/index.d.ts +1 -0
  96. package/dist/text/index.d.ts.map +1 -1
  97. package/dist/text/index.mjs +193 -1
  98. package/dist/text/merge-three-way.d.ts +9 -0
  99. package/dist/text/merge-three-way.d.ts.map +1 -0
  100. package/dist/visio/collab/index.cjs +226 -7
  101. package/dist/visio/collab/index.d.ts +1 -0
  102. package/dist/visio/collab/index.d.ts.map +1 -1
  103. package/dist/visio/collab/index.mjs +225 -7
  104. package/dist/visio/collab/merge-snapshots.d.ts +14 -0
  105. package/dist/visio/collab/merge-snapshots.d.ts.map +1 -0
  106. package/dist/visio/edit-shape-data-commands.d.ts.map +1 -1
  107. package/dist/visio/index.cjs +15 -10
  108. package/dist/visio/index.mjs +15 -10
  109. package/dist/visio/ui/index.cjs +19 -12
  110. package/dist/visio/ui/index.mjs +19 -12
  111. package/dist/visio/ui/text-dialog.d.ts.map +1 -1
  112. package/dist/xlsx/collab/index.cjs +49985 -507
  113. package/dist/xlsx/collab/index.d.ts +1 -0
  114. package/dist/xlsx/collab/index.d.ts.map +1 -1
  115. package/dist/xlsx/collab/index.mjs +49980 -507
  116. package/dist/xlsx/collab/merge-residual.d.ts +16 -0
  117. package/dist/xlsx/collab/merge-residual.d.ts.map +1 -0
  118. package/dist/xlsx/collab/merge-snapshots.d.ts +8 -0
  119. package/dist/xlsx/collab/merge-snapshots.d.ts.map +1 -0
  120. package/dist/xlsx/index.cjs +202 -202
  121. package/dist/xlsx/index.mjs +202 -202
  122. package/dist/xlsx/load/index.cjs +155 -155
  123. package/dist/xlsx/load/index.mjs +155 -155
  124. package/dist/xlsx/ui/index.cjs +202 -202
  125. package/dist/xlsx/ui/index.mjs +202 -202
  126. package/dist/xml/index.cjs +406 -22
  127. package/dist/xml/index.d.ts +1 -0
  128. package/dist/xml/index.d.ts.map +1 -1
  129. package/dist/xml/index.mjs +406 -23
  130. package/dist/xml/merge-three-way.d.ts +18 -0
  131. package/dist/xml/merge-three-way.d.ts.map +1 -0
  132. package/package.json +6 -1
  133. package/dist/PptxHandler-2JSQ22VD.cjs +0 -14
  134. package/dist/PptxHandler-7T7ZS7IK.mjs +0 -5
  135. package/dist/pptx/chunks/index-DC5m1m_8.d.ts.map +0 -1
@@ -1,7 +1,7 @@
1
- import { findText, replaceText, replaceTextInSlide, mergePresentation } from './chunk-OEM2ECAJ.mjs';
2
- import { PresentationBuilder, PptxHandler, SlideBuilder, validateSeriesIndex, removeEmptyDataPoint, ensureDataPoint, ensureChartData, assertChartGradientSupported, toChartGradientFill, chartFormatTargetKey, readChartElementFormat, hasGradientField, applyGradient, mirrorFlatFields, mirrorTextColor, withSeries, applyChartGroupOptionsInput, countExistingLayouts, addLayoutToSlideMaster, addLayoutContentType, createLayout, STANDARD_LAYOUTS, generateLayoutXml, layoutRelsXml, createTextElement, createShapeElement, createImageElement, createTableElement, createChartElement, createConnectorElement, createMediaElement, createGroupElement, clonePartGraph, buildBlankPresentationArchive, relativePartTarget, PptxXmlBuilder } from './chunk-RHQQS6LJ.mjs';
3
- import { EMU_PER_PIXEL, EMU_PER_INCH, parseXml, first, relationshipsPartFor, parseRelationships, resolvePartPath, elements, buildXml, buildRelationshipsXml, bytesToBase64, base64ToBytes, hasTextProperties, nextRelationshipId, escAttr } from './chunk-J43V3QOA.mjs';
4
- import { openPptxZip } from './chunk-EYCM7RVL.mjs';
1
+ import { findText, replaceText, replaceTextInSlide, mergePresentation } from './chunk-RDMUNMGT.mjs';
2
+ import { PresentationBuilder, PptxHandler, SlideBuilder, validateSeriesIndex, removeEmptyDataPoint, ensureDataPoint, ensureChartData, assertChartGradientSupported, toChartGradientFill, chartFormatTargetKey, readChartElementFormat, hasGradientField, applyGradient, mirrorFlatFields, mirrorTextColor, withSeries, applyChartGroupOptionsInput, countExistingLayouts, addLayoutToSlideMaster, addLayoutContentType, createLayout, STANDARD_LAYOUTS, generateLayoutXml, layoutRelsXml, createTextElement, createShapeElement, createImageElement, createTableElement, createChartElement, createConnectorElement, createMediaElement, createGroupElement, clonePartGraph, buildBlankPresentationArchive, FILL_CHOICE_ELEMENTS, relativePartTarget, PptxXmlBuilder } from './chunk-SN5R5YNF.mjs';
3
+ import { SP_PR_ORDER, EMU_PER_PIXEL, EMU_PER_INCH, parseXml, first, relationshipsPartFor, parseRelationships, resolvePartPath, elements, buildXml, buildRelationshipsXml, bytesToBase64, base64ToBytes, LN_CHILD_ORDER, BLIP_FILL_ORDER, EFFECT_LST_ORDER, SHAPE_STYLE_ORDER, TC_PR_BORDERS_ORDER, hasTextProperties, nextRelationshipId, escAttr, NS } from './chunk-6XLWR7R6.mjs';
4
+ import { openPptxZip, openZip } from './chunk-EYCM7RVL.mjs';
5
5
  import { cloneSlide, cloneElement } from './chunk-VDUNZTJC.mjs';
6
6
 
7
7
  // pptx/core/types/transition.ts
@@ -242,6 +242,488 @@ var THEME_PRESETS = [
242
242
  METROPOLITAN_PRESET
243
243
  ];
244
244
 
245
+ // text/text-diff.ts
246
+ var isLowSurrogate = (text, at) => {
247
+ const code = text.charCodeAt(at);
248
+ return code >= 56320 && code <= 57343;
249
+ };
250
+ function shortestEdit(n, m, same, maxEdits) {
251
+ const max = Math.min(n + m, maxEdits);
252
+ const offset = max + 1;
253
+ const v = new Int32Array(2 * max + 3);
254
+ const trace = [];
255
+ for (let d = 0; d <= max; d++) {
256
+ for (let k = -d; k <= d; k += 2) {
257
+ const down = k === -d || k !== d && v[offset + k - 1] < v[offset + k + 1];
258
+ let x = down ? v[offset + k + 1] : v[offset + k - 1] + 1;
259
+ let y = x - k;
260
+ while (x < n && y < m && same(x, y)) {
261
+ x++;
262
+ y++;
263
+ }
264
+ v[offset + k] = x;
265
+ if (x >= n && y >= m) return backtrack(trace, n, m, d);
266
+ }
267
+ trace.push(v.slice(offset - d, offset + d + 1));
268
+ }
269
+ return void 0;
270
+ }
271
+ function backtrack(trace, n, m, d) {
272
+ const edits = [];
273
+ let x = n;
274
+ let y = m;
275
+ for (let step = d; step > 0; step--) {
276
+ const previous = trace[step - 1];
277
+ const at = (k2) => previous[k2 + step - 1];
278
+ const k = x - y;
279
+ const down = k === -step || k !== step && at(k - 1) < at(k + 1);
280
+ const before = down ? k + 1 : k - 1;
281
+ const startX = at(before);
282
+ const startY = startX - before;
283
+ edits.push(down ? [startX, startY, true] : [startX, startY, false]);
284
+ x = startX;
285
+ y = startY;
286
+ }
287
+ return edits.reverse();
288
+ }
289
+ function changesOf(edits) {
290
+ const changes = [];
291
+ for (const [x, y, inserts] of edits) {
292
+ const last = changes.at(-1);
293
+ if (last && last.fromEnd === x && last.toEnd === y) {
294
+ if (inserts) last.toEnd++;
295
+ else last.fromEnd++;
296
+ } else
297
+ changes.push({
298
+ fromStart: x,
299
+ fromEnd: inserts ? x : x + 1,
300
+ toStart: y,
301
+ toEnd: inserts ? y + 1 : y
302
+ });
303
+ }
304
+ return changes;
305
+ }
306
+ function characterChanges(a, b, maxEdits) {
307
+ const edits = shortestEdit(
308
+ a.length,
309
+ b.length,
310
+ (x, y) => a.charCodeAt(x) === b.charCodeAt(y),
311
+ maxEdits
312
+ );
313
+ return edits && changesOf(edits);
314
+ }
315
+ var TOKEN = /[\p{L}\p{N}\p{M}]+|\s+|[\s\S]/gu;
316
+ function tokensOf(text, ids) {
317
+ const tokens = [];
318
+ const starts = [];
319
+ for (const match of text.matchAll(TOKEN)) {
320
+ let id = ids.get(match[0]);
321
+ if (id === void 0) ids.set(match[0], id = ids.size);
322
+ tokens.push(id);
323
+ starts.push(match.index);
324
+ }
325
+ starts.push(text.length);
326
+ return { tokens, starts };
327
+ }
328
+ function tokenChanges(a, b, maxEdits) {
329
+ const ids = /* @__PURE__ */ new Map();
330
+ const from = tokensOf(a, ids);
331
+ const to = tokensOf(b, ids);
332
+ const edits = shortestEdit(
333
+ from.tokens.length,
334
+ to.tokens.length,
335
+ (x, y) => from.tokens[x] === to.tokens[y],
336
+ maxEdits
337
+ );
338
+ if (!edits) return void 0;
339
+ let budget = maxEdits;
340
+ return changesOf(edits).flatMap((stretch) => {
341
+ const change = {
342
+ fromStart: from.starts[stretch.fromStart],
343
+ fromEnd: from.starts[stretch.fromEnd],
344
+ toStart: to.starts[stretch.toStart],
345
+ toEnd: to.starts[stretch.toEnd]
346
+ };
347
+ const inner = change.fromEnd > change.fromStart && change.toEnd > change.toStart ? characterChanges(
348
+ a.slice(change.fromStart, change.fromEnd),
349
+ b.slice(change.toStart, change.toEnd),
350
+ budget
351
+ ) : void 0;
352
+ if (!inner) return [change];
353
+ for (const found of inner)
354
+ budget -= found.fromEnd - found.fromStart + found.toEnd - found.toStart;
355
+ return inner.map((found) => ({
356
+ fromStart: found.fromStart + change.fromStart,
357
+ fromEnd: found.fromEnd + change.fromStart,
358
+ toStart: found.toStart + change.toStart,
359
+ toEnd: found.toEnd + change.toStart
360
+ }));
361
+ });
362
+ }
363
+ function diffText(from, to, maxEdits = 500) {
364
+ let start = 0;
365
+ while (start < from.length && start < to.length && from.charCodeAt(start) === to.charCodeAt(start))
366
+ start++;
367
+ let end = 0;
368
+ while (end < from.length - start && end < to.length - start && from.charCodeAt(from.length - 1 - end) === to.charCodeAt(to.length - 1 - end))
369
+ end++;
370
+ const a = from.slice(start, from.length - end);
371
+ const b = to.slice(start, to.length - end);
372
+ if (!a.length && !b.length) return [];
373
+ const found = a.length && b.length ? characterChanges(a, b, maxEdits) ?? tokenChanges(a, b, maxEdits) : void 0;
374
+ const changes = found ?? [{ fromStart: 0, fromEnd: a.length, toStart: 0, toEnd: b.length }];
375
+ const result = [];
376
+ for (const change of changes) {
377
+ const placed = {
378
+ fromStart: change.fromStart + start,
379
+ fromEnd: change.fromEnd + start,
380
+ toStart: change.toStart + start,
381
+ toEnd: change.toEnd + start
382
+ };
383
+ if (placed.fromStart > 0 && placed.toStart > 0 && (isLowSurrogate(from, placed.fromStart) || isLowSurrogate(to, placed.toStart))) {
384
+ placed.fromStart--;
385
+ placed.toStart--;
386
+ }
387
+ if (isLowSurrogate(from, placed.fromEnd) || isLowSurrogate(to, placed.toEnd)) {
388
+ placed.fromEnd++;
389
+ placed.toEnd++;
390
+ }
391
+ const last = result.at(-1);
392
+ if (last && placed.fromStart <= last.fromEnd) {
393
+ last.fromEnd = Math.max(last.fromEnd, placed.fromEnd);
394
+ last.toEnd = Math.max(last.toEnd, placed.toEnd);
395
+ } else result.push(placed);
396
+ }
397
+ return result;
398
+ }
399
+
400
+ // text/merge-three-way.ts
401
+ function mergeTextThreeWay(base, local, remote) {
402
+ if (local === remote || base === remote) return { status: "merged", text: local };
403
+ if (base === local) return { status: "merged", text: remote };
404
+ if (Math.max(base.length, local.length, remote.length) > 1e6)
405
+ return { status: "unresolved" };
406
+ const changes = (value) => diffText(base, value).map((change) => ({
407
+ start: change.fromStart,
408
+ end: change.fromEnd,
409
+ text: value.slice(change.toStart, change.toEnd)
410
+ }));
411
+ const edits = changes(local);
412
+ for (const next of changes(remote)) {
413
+ if (edits.some(
414
+ (edit) => edit.start === next.start && edit.end === next.end && edit.text === next.text
415
+ ))
416
+ continue;
417
+ if (edits.some((edit) => {
418
+ if (edit.start === edit.end && next.start === next.end) return false;
419
+ if (edit.start === edit.end) return edit.start > next.start && edit.start < next.end;
420
+ if (next.start === next.end) return next.start > edit.start && next.start < edit.end;
421
+ return edit.start < next.end && next.start < edit.end;
422
+ }))
423
+ return { status: "unresolved" };
424
+ edits.push(next);
425
+ }
426
+ edits.sort(
427
+ (a, b) => a.start - b.start || a.end - b.end || (a.text < b.text ? -1 : a.text > b.text ? 1 : 0)
428
+ );
429
+ let text = "", cursor = 0;
430
+ for (const edit of edits) {
431
+ text += base.slice(cursor, edit.start) + edit.text;
432
+ cursor = edit.end;
433
+ }
434
+ return { status: "merged", text: text + base.slice(cursor) };
435
+ }
436
+
437
+ // xml/merge-three-way.ts
438
+ var tag = (node) => `${node.namespaceURI ?? ""}|${node.localName ?? node.tagName}`;
439
+ var xml = (node) => node ? buildXml(node) : void 0;
440
+ function childrenByKey(parent, options, repeated) {
441
+ const result = /* @__PURE__ */ new Map();
442
+ const counts = /* @__PURE__ */ new Map();
443
+ for (const child of elements(parent)) {
444
+ const name = tag(child), explicit = options.keyElement?.(child, parent);
445
+ const index = counts.get(name) ?? 0;
446
+ counts.set(name, index + 1);
447
+ if (!explicit && repeated.has(name) && !options.allowPositional?.(parent))
448
+ throw new Error("Ambiguous repeated elements");
449
+ const key = explicit ? `${name}@${explicit}` : `${name}#${index}`;
450
+ if (result.has(key)) throw new Error("Duplicate element identity");
451
+ result.set(key, child);
452
+ }
453
+ return result;
454
+ }
455
+ function orderKeys(base, local, remote, isKeyed, childOrder) {
456
+ const same = (a, b) => a.length === b.length && a.every((key, index) => key === b[index]);
457
+ if (same(base, local)) return [...remote];
458
+ if (same(base, remote) || same(local, remote)) return [...local];
459
+ const keys = [.../* @__PURE__ */ new Set([...remote, ...local])].sort();
460
+ const edges = new Map(keys.map((key) => [key, /* @__PURE__ */ new Set()]));
461
+ const degree = new Map(keys.map((key) => [key, 0]));
462
+ const addSequence = (sequence2) => {
463
+ for (let i = 1; i < sequence2.length; i++) {
464
+ const previous = sequence2[i - 1], next = sequence2[i];
465
+ if (!edges.get(previous).has(next)) {
466
+ edges.get(previous).add(next);
467
+ degree.set(next, degree.get(next) + 1);
468
+ }
469
+ }
470
+ };
471
+ for (const sequence2 of [local, remote]) addSequence(sequence2);
472
+ const ranked = keys.flatMap((key) => {
473
+ const rank = childOrder(key);
474
+ return rank === void 0 ? [] : [{ key, rank }];
475
+ });
476
+ if (ranked.some(({ rank }) => !Number.isFinite(rank)) || new Set(ranked.map(({ rank }) => rank)).size !== ranked.length)
477
+ return void 0;
478
+ addSequence(ranked.sort((a, b) => a.rank - b.rank).map(({ key }) => key));
479
+ const out = [];
480
+ const ready = keys.filter((key) => degree.get(key) === 0);
481
+ while (ready.length) {
482
+ if (ready.length > 1 && ready.some((key) => !isKeyed(key))) return void 0;
483
+ const next = ready.sort().shift();
484
+ out.push(next);
485
+ for (const key of edges.get(next)) {
486
+ degree.set(key, degree.get(key) - 1);
487
+ if (degree.get(key) === 0) ready.push(key);
488
+ }
489
+ }
490
+ return out.length === keys.length ? out : void 0;
491
+ }
492
+ function mergeXmlThreeWay(baseXml, localXml, remoteXml, options = {}) {
493
+ if (localXml === remoteXml || baseXml === remoteXml) return { status: "merged", xml: localXml };
494
+ if (baseXml === localXml) return { status: "merged", xml: remoteXml };
495
+ const issues = [];
496
+ try {
497
+ let merge2 = function(b, l, r, path) {
498
+ const bx = xml(b), lx = xml(l), rx = xml(r);
499
+ if (lx === rx || bx === rx) return l ? copy(l) : void 0;
500
+ if (bx === lx) return r ? copy(r) : void 0;
501
+ if (!b && l && r && tag(l) === tag(r) && !elements(l).length && !elements(r).length) {
502
+ const resolved = options.resolveText?.(r, l, r);
503
+ if (resolved !== void 0) {
504
+ const node = copy(r);
505
+ node.textContent = resolved;
506
+ return node;
507
+ }
508
+ }
509
+ if (!b || !l || !r || tag(b) !== tag(l) || tag(b) !== tag(r)) {
510
+ issues.push(`${path}: overlapping structural changes`);
511
+ return void 0;
512
+ }
513
+ const out = remote.createElementNS(r.namespaceURI, r.tagName);
514
+ const attrs = (node) => new Map(
515
+ Array.from(node.attributes).map((a) => [
516
+ `${a.namespaceURI ?? ""}|${a.localName ?? a.name}`,
517
+ a
518
+ ])
519
+ );
520
+ const ba = attrs(b), la = attrs(l), ra = attrs(r);
521
+ for (const key of /* @__PURE__ */ new Set([...ba.keys(), ...la.keys(), ...ra.keys()])) {
522
+ const old = ba.get(key)?.value, left = la.get(key)?.value, right = ra.get(key)?.value;
523
+ const value = left === right || right === old ? left : left === old ? right : void 0;
524
+ if (left !== right && left !== old && right !== old) {
525
+ issues.push(`${path}: overlapping attribute ${key}`);
526
+ continue;
527
+ }
528
+ const source = ra.get(key) ?? la.get(key) ?? ba.get(key);
529
+ if (value !== void 0) out.setAttributeNS(source.namespaceURI, source.name, value);
530
+ }
531
+ const lists = [b, l, r].map(elements);
532
+ if (lists.every((list) => list.length === 0)) {
533
+ if ([b, l, r].some(
534
+ (node) => Array.from(node.childNodes).some(
535
+ (child) => child.nodeType !== 3 && child.nodeType !== 4
536
+ )
537
+ )) {
538
+ issues.push(`${path}: non-text leaf content requires explicit preservation`);
539
+ return void 0;
540
+ }
541
+ const texts = [b, l, r].map((node) => node.textContent ?? "");
542
+ const override = options.resolveText?.(b, l, r);
543
+ const value = override !== void 0 ? { status: "merged", text: override } : texts[1] === texts[2] || texts[0] === texts[2] ? { status: "merged", text: texts[1] } : texts[0] === texts[1] ? { status: "merged", text: texts[2] } : options.allowText?.(b) ? mergeTextThreeWay(texts[0], texts[1], texts[2]) : { status: "unresolved" };
544
+ if (value.status !== "merged") issues.push(`${path}: overlapping text changes`);
545
+ else if (value.text) out.appendChild(remote.createTextNode(value.text));
546
+ return out;
547
+ }
548
+ if ([b, l, r].some(
549
+ (node) => Array.from(node.childNodes).some(
550
+ (child) => child.nodeType !== 1 && (child.nodeType !== 3 || Boolean(child.textContent?.trim()))
551
+ )
552
+ )) {
553
+ issues.push(`${path}: mixed content cannot be matched safely`);
554
+ return void 0;
555
+ }
556
+ const repeated = /* @__PURE__ */ new Set();
557
+ const groups = lists.map((list) => {
558
+ const grouped = /* @__PURE__ */ new Map();
559
+ for (const child of list) {
560
+ const name = tag(child), group2 = grouped.get(name) ?? [];
561
+ group2.push(child);
562
+ grouped.set(name, group2);
563
+ if (group2.length > 1) repeated.add(name);
564
+ }
565
+ return grouped;
566
+ });
567
+ for (const name of repeated) {
568
+ const rows = groups.map((group2) => group2.get(name) ?? []);
569
+ if (rows.some((row) => row.some((child) => options.keyElement?.(child, b) !== void 0)))
570
+ continue;
571
+ if (rows.some((row) => row.length !== rows[0].length)) {
572
+ issues.push(`${path}: unkeyed structural changes`);
573
+ return void 0;
574
+ }
575
+ const before = rows[0].map((child) => buildXml(child));
576
+ const known = new Set(before);
577
+ for (const row of rows.slice(1))
578
+ if (row.some((child, i) => {
579
+ const value = buildXml(child);
580
+ return before[i] !== value && known.has(value);
581
+ })) {
582
+ issues.push(`${path}: reordered unkeyed elements`);
583
+ return void 0;
584
+ }
585
+ }
586
+ let maps;
587
+ try {
588
+ maps = [b, l, r].map((parent) => childrenByKey(parent, options, repeated));
589
+ } catch {
590
+ issues.push(`${path}: ambiguous element identities`);
591
+ return void 0;
592
+ }
593
+ const [bm, lm, rm] = maps;
594
+ const merged = /* @__PURE__ */ new Map();
595
+ for (const key of /* @__PURE__ */ new Set([...bm.keys(), ...lm.keys(), ...rm.keys()])) {
596
+ const node = merge2(bm.get(key), lm.get(key), rm.get(key), `${path}/${key}`);
597
+ if (node) merged.set(key, node);
598
+ }
599
+ const surviving = (map) => [...map.keys()].filter((key) => merged.has(key));
600
+ const order = orderKeys(
601
+ surviving(bm),
602
+ surviving(lm),
603
+ surviving(rm),
604
+ (key) => Boolean(options.keyElement?.(merged.get(key), out)),
605
+ (key) => options.childOrder?.(merged.get(key), out)
606
+ );
607
+ if (!order) {
608
+ issues.push(`${path}: incompatible element order`);
609
+ return void 0;
610
+ }
611
+ for (const key of order) out.appendChild(merged.get(key));
612
+ return out;
613
+ };
614
+ var merge = merge2;
615
+ const base = parseXml(baseXml, { warningsAsErrors: true });
616
+ const local = parseXml(localXml, { warningsAsErrors: true });
617
+ const remote = parseXml(remoteXml, { warningsAsErrors: true });
618
+ const copy = (node) => remote.importNode(node, true);
619
+ const root = merge2(base.documentElement, local.documentElement, remote.documentElement, "root");
620
+ if (!root || issues.length) return { status: "unresolved", issues };
621
+ remote.replaceChild(root, remote.documentElement);
622
+ return { status: "merged", xml: buildXml(remote) };
623
+ } catch {
624
+ return { status: "unresolved", issues: ["Invalid or unsupported XML input"] };
625
+ }
626
+ }
627
+
628
+ // opc/merge-snapshots.ts
629
+ var equal = (a, b) => a === b || Boolean(a && b && a.length === b.length && a.every((value, index) => value === b[index]));
630
+ var CORE_PROPERTIES = "http://schemas.openxmlformats.org/package/2006/metadata/core-properties";
631
+ var decoder = new TextDecoder("utf-8", { fatal: true });
632
+ var encoder = new TextEncoder();
633
+ function mergeManifest(input) {
634
+ const { path, base, local, remote } = input;
635
+ if (!base || !local || !remote) return void 0;
636
+ if (!path.endsWith(".rels") && path !== "[Content_Types].xml" && path !== "docProps/core.xml")
637
+ return void 0;
638
+ try {
639
+ const result = mergeXmlThreeWay(
640
+ decoder.decode(base),
641
+ decoder.decode(local),
642
+ decoder.decode(remote),
643
+ {
644
+ keyElement: (element, parent) => {
645
+ if (path === "docProps/core.xml" && parent.namespaceURI === CORE_PROPERTIES && parent.localName === "coreProperties")
646
+ return `${element.namespaceURI ?? ""}|${element.localName}`;
647
+ const attribute = element.localName === "Relationship" ? "Id" : element.localName === "Override" ? "PartName" : element.localName === "Default" ? "Extension" : void 0;
648
+ return attribute ? element.getAttribute(attribute) ?? void 0 : void 0;
649
+ },
650
+ resolveText: (_b, _l, r) => path === "docProps/core.xml" && (r.namespaceURI === "http://purl.org/dc/terms/" && r.localName === "modified" || r.namespaceURI === CORE_PROPERTIES && r.localName === "lastModifiedBy") ? r.textContent ?? "" : void 0
651
+ }
652
+ );
653
+ return result.status === "merged" ? { status: "merged", bytes: encoder.encode(result.xml) } : result;
654
+ } catch {
655
+ return { status: "unresolved", issues: [`${path}: invalid metadata XML`] };
656
+ }
657
+ }
658
+ async function mergeOpcSnapshots(baseBytes, localBytes, remoteBytes, options = {}) {
659
+ if (equal(localBytes, remoteBytes) || equal(baseBytes, remoteBytes))
660
+ return { status: "merged", bytes: localBytes.slice() };
661
+ if (equal(baseBytes, localBytes)) return { status: "merged", bytes: remoteBytes.slice() };
662
+ try {
663
+ const [base, local, remote] = await Promise.all([
664
+ openZip(baseBytes, { label: "Merge" }),
665
+ openZip(localBytes, { label: "Merge" }),
666
+ openZip(remoteBytes, { label: "Merge" })
667
+ ]);
668
+ const paths = [
669
+ ...new Set(
670
+ [base, local, remote].flatMap(
671
+ (zip) => Object.keys(zip.files).filter((path) => !zip.files[path].dir)
672
+ )
673
+ )
674
+ ].sort();
675
+ if (paths.some((path) => path.startsWith("_xmlsignatures/")))
676
+ return {
677
+ status: "unresolved",
678
+ issues: ["Signed packages require explicit signature handling before merging"]
679
+ };
680
+ const issues = [];
681
+ for (const path of paths) {
682
+ const [b, l, r] = await Promise.all(
683
+ [base, local, remote].map((zip) => zip.file(path)?.async("uint8array"))
684
+ );
685
+ let chosen;
686
+ if (equal(l, r) || equal(b, r)) chosen = l;
687
+ else if (equal(b, l)) chosen = r;
688
+ else {
689
+ const input = {
690
+ path,
691
+ ...b ? { base: b } : {},
692
+ ...l ? { local: l } : {},
693
+ ...r ? { remote: r } : {}
694
+ };
695
+ const result = mergeManifest(input) ?? await options.mergePart?.(input);
696
+ if (!result || result.status === "unresolved") {
697
+ issues.push(...result?.issues ?? [`${path}: both versions changed the same part`]);
698
+ continue;
699
+ }
700
+ chosen = result.bytes;
701
+ }
702
+ if (chosen) remote.file(path, chosen);
703
+ else remote.remove(path);
704
+ }
705
+ if (issues.length) return { status: "unresolved", issues };
706
+ for (const path of Object.keys(remote.files).filter((name) => name.endsWith(".rels"))) {
707
+ const source = path === "_rels/.rels" ? "" : path.replace(/(^|\/)_rels\/([^/]+)\.rels$/u, "$1$2");
708
+ for (const relation of parseRelationships(
709
+ await remote.file(path).async("string")
710
+ ).values()) {
711
+ if (relation.mode === "External") continue;
712
+ const target = resolvePartPath(source, relation.target.split("#")[0] ?? "");
713
+ if (!remote.file(target) && !remote.file(decodeURIComponent(target)))
714
+ issues.push(`${path}: merged relationship target is missing`);
715
+ }
716
+ }
717
+ if (issues.length) return { status: "unresolved", issues };
718
+ return {
719
+ status: "merged",
720
+ bytes: await remote.generateAsync({ type: "uint8array", compression: "DEFLATE" })
721
+ };
722
+ } catch {
723
+ return { status: "unresolved", issues: ["Invalid or oversized Office package"] };
724
+ }
725
+ }
726
+
245
727
  // pptx/core/builders/sdk/diff-operations.ts
246
728
  var ELEMENT_SKIP_KEYS = /* @__PURE__ */ new Set([
247
729
  "rawXml",
@@ -881,8 +1363,8 @@ function processElements(elements2, data) {
881
1363
  const tableEl = element;
882
1364
  if (tableEl.tableData?.rows) {
883
1365
  for (const row of tableEl.tableData.rows) {
884
- for (const cell of row.cells) {
885
- cell.text = replaceTokensInString(cell.text, data);
1366
+ for (const cell2 of row.cells) {
1367
+ cell2.text = replaceTokensInString(cell2.text, data);
886
1368
  }
887
1369
  }
888
1370
  }
@@ -1046,8 +1528,8 @@ function findPlaceholders(data) {
1046
1528
  const tableEl = element;
1047
1529
  if (tableEl.tableData?.rows) {
1048
1530
  for (const row of tableEl.tableData.rows) {
1049
- for (const cell of row.cells) {
1050
- extractPlaceholdersFromText(cell.text, found);
1531
+ for (const cell2 of row.cells) {
1532
+ extractPlaceholdersFromText(cell2.text, found);
1051
1533
  }
1052
1534
  }
1053
1535
  }
@@ -1465,10 +1947,10 @@ var Presentation = class _Presentation {
1465
1947
  };
1466
1948
 
1467
1949
  // pptx/core/builders/sdk/chart-formatting-operations.ts
1468
- function setChartDataPointStyle(element, seriesIndex, pointIndex, style) {
1950
+ function setChartDataPointStyle(element, seriesIndex, pointIndex, style2) {
1469
1951
  validateSeriesIndex(element, seriesIndex);
1470
1952
  const series = element.chartData.series[seriesIndex];
1471
- if (style === null) {
1953
+ if (style2 === null) {
1472
1954
  const dp2 = series.dataPoints?.find((p) => p.idx === pointIndex);
1473
1955
  if (dp2) {
1474
1956
  dp2.spPr = void 0;
@@ -1478,20 +1960,20 @@ function setChartDataPointStyle(element, seriesIndex, pointIndex, style) {
1478
1960
  return;
1479
1961
  }
1480
1962
  const dp = ensureDataPoint(series, pointIndex);
1481
- dp.spPr = { ...dp.spPr ?? {}, ...style };
1482
- if (style.fillColor !== void 0) {
1963
+ dp.spPr = { ...dp.spPr ?? {}, ...style2 };
1964
+ if (style2.fillColor !== void 0) {
1483
1965
  delete dp.gradientFill;
1484
1966
  }
1485
1967
  }
1486
1968
  var HELPER_LINE_CHART_TYPES = /* @__PURE__ */ new Set(["line", "stock", "combo"]);
1487
- function setChartHelperLine(element, line, style) {
1969
+ function setChartHelperLine(element, line2, style2) {
1488
1970
  ensureChartData(element);
1489
1971
  if (!HELPER_LINE_CHART_TYPES.has(element.chartData.chartType)) {
1490
1972
  throw new Error(
1491
- `${line} is only valid on line, stock, or combo charts (got "${element.chartData.chartType}").`
1973
+ `${line2} is only valid on line, stock, or combo charts (got "${element.chartData.chartType}").`
1492
1974
  );
1493
1975
  }
1494
- element.chartData[line] = style;
1976
+ element.chartData[line2] = style2;
1495
1977
  }
1496
1978
  function setChartColorMapOverride(element, overrides28) {
1497
1979
  ensureChartData(element);
@@ -1588,13 +2070,13 @@ function withChartElementFormat(data, target, patch) {
1588
2070
  entry.fill = fill;
1589
2071
  }
1590
2072
  }
1591
- let line;
2073
+ let line2;
1592
2074
  if (patch.line) {
1593
- line = { ...view.line, ...patch.line };
1594
- if (line.kind !== "gradient") {
1595
- delete line.gradient;
2075
+ line2 = { ...view.line, ...patch.line };
2076
+ if (line2.kind !== "gradient") {
2077
+ delete line2.gradient;
1596
2078
  }
1597
- entry.line = line;
2079
+ entry.line = line2;
1598
2080
  }
1599
2081
  if (patch.effects) {
1600
2082
  entry.effects = { ...view.effects, ...patch.effects };
@@ -1616,7 +2098,7 @@ function withChartElementFormat(data, target, patch) {
1616
2098
  }
1617
2099
  entry.text = text;
1618
2100
  }
1619
- next = mirrorFlatFields(next, target, fill, line);
2101
+ next = mirrorFlatFields(next, target, fill, line2);
1620
2102
  if (patch.text?.fill && entry.text) {
1621
2103
  next = mirrorTextColor(next, target, entry.text);
1622
2104
  }
@@ -1628,11 +2110,11 @@ function resetChartElementFormat(data, target) {
1628
2110
  switch (target.kind) {
1629
2111
  case "chartArea":
1630
2112
  case "plotArea": {
1631
- const style = { ...data.style };
1632
- delete style[`${target.kind}Fill`];
1633
- delete style[`${target.kind}Gradient`];
1634
- delete style[`${target.kind}Border`];
1635
- next = { ...data, style };
2113
+ const style2 = { ...data.style };
2114
+ delete style2[`${target.kind}Fill`];
2115
+ delete style2[`${target.kind}Gradient`];
2116
+ delete style2[`${target.kind}Border`];
2117
+ next = { ...data, style: style2 };
1636
2118
  break;
1637
2119
  }
1638
2120
  case "title":
@@ -1747,27 +2229,27 @@ function withChartAxisOptions(data, axisIndex, edit) {
1747
2229
  return { ...data, axes };
1748
2230
  }
1749
2231
  function withChartLegendOptions(data, edit) {
1750
- const style = { ...data.style };
2232
+ const style2 = { ...data.style };
1751
2233
  if (edit.show !== void 0) {
1752
- style.hasLegend = edit.show;
2234
+ style2.hasLegend = edit.show;
1753
2235
  }
1754
2236
  if (edit.position !== void 0) {
1755
- style.legendPosition = edit.position;
1756
- style.hasLegend = style.hasLegend ?? true;
2237
+ style2.legendPosition = edit.position;
2238
+ style2.hasLegend = style2.hasLegend ?? true;
1757
2239
  }
1758
2240
  if (edit.overlay !== void 0) {
1759
- style.legendOverlay = edit.overlay;
2241
+ style2.legendOverlay = edit.overlay;
1760
2242
  }
1761
- return { ...data, style };
2243
+ return { ...data, style: style2 };
1762
2244
  }
1763
2245
  function withChartDataLabelOptions(data, edit, seriesIndex) {
1764
2246
  if (seriesIndex !== void 0) {
1765
2247
  return withSeriesDataLabelOptions(data, edit, seriesIndex);
1766
2248
  }
1767
- const style = { ...data.style };
1768
- const labels = { ...style.dataLabels };
2249
+ const style2 = { ...data.style };
2250
+ const labels = { ...style2.dataLabels };
1769
2251
  if (edit.show !== void 0) {
1770
- style.hasDataLabels = edit.show;
2252
+ style2.hasDataLabels = edit.show;
1771
2253
  }
1772
2254
  for (const key of [
1773
2255
  "showValue",
@@ -1778,7 +2260,7 @@ function withChartDataLabelOptions(data, edit, seriesIndex) {
1778
2260
  ]) {
1779
2261
  if (edit[key] !== void 0) {
1780
2262
  labels[key] = edit[key];
1781
- style.hasDataLabels = style.hasDataLabels ?? true;
2263
+ style2.hasDataLabels = style2.hasDataLabels ?? true;
1782
2264
  }
1783
2265
  }
1784
2266
  if (edit.position !== void 0) {
@@ -1788,8 +2270,8 @@ function withChartDataLabelOptions(data, edit, seriesIndex) {
1788
2270
  labels.position = edit.position;
1789
2271
  }
1790
2272
  }
1791
- style.dataLabels = labels;
1792
- return { ...data, style };
2273
+ style2.dataLabels = labels;
2274
+ return { ...data, style: style2 };
1793
2275
  }
1794
2276
  var LABEL_FLAGS = [
1795
2277
  "showValue",
@@ -1818,18 +2300,18 @@ function withSeriesDataLabelOptions(data, edit, seriesIndex) {
1818
2300
  labels.position = edit.position;
1819
2301
  }
1820
2302
  }
1821
- const style = { ...data.style };
1822
- if (style.hasDataLabels !== true && LABEL_FLAGS.some((key) => labels[key])) {
1823
- style.hasDataLabels = true;
1824
- const off = { ...style.dataLabels };
2303
+ const style2 = { ...data.style };
2304
+ if (style2.hasDataLabels !== true && LABEL_FLAGS.some((key) => labels[key])) {
2305
+ style2.hasDataLabels = true;
2306
+ const off = { ...style2.dataLabels };
1825
2307
  for (const key of LABEL_FLAGS) {
1826
2308
  off[key] ??= false;
1827
2309
  }
1828
- style.dataLabels = off;
2310
+ style2.dataLabels = off;
1829
2311
  }
1830
2312
  return {
1831
2313
  ...data,
1832
- style,
2314
+ style: style2,
1833
2315
  series: data.series.map((s, i) => i === seriesIndex ? { ...s, dataLabelOptions: labels } : s)
1834
2316
  };
1835
2317
  }
@@ -2022,16 +2504,16 @@ function validateShapeIndex(element, index) {
2022
2504
  function listChartUserShapes(element) {
2023
2505
  return element.chartData?.userShapes ?? [];
2024
2506
  }
2025
- function addChartUserShape(element, shape) {
2507
+ function addChartUserShape(element, shape2) {
2026
2508
  ensureChartData2(element);
2027
2509
  const existing = element.chartData.userShapes ?? [];
2028
- element.chartData.userShapes = [...existing, shape];
2510
+ element.chartData.userShapes = [...existing, shape2];
2029
2511
  }
2030
2512
  function updateChartUserShape(element, index, patch) {
2031
2513
  validateShapeIndex(element, index);
2032
2514
  const shapes = element.chartData.userShapes;
2033
2515
  element.chartData.userShapes = shapes.map(
2034
- (shape, i) => i === index ? { ...shape, ...patch } : shape
2516
+ (shape2, i) => i === index ? { ...shape2, ...patch } : shape2
2035
2517
  );
2036
2518
  }
2037
2519
  function removeChartUserShape(element, index) {
@@ -2245,22 +2727,22 @@ async function removeMasterFromPresentation(zip, masterPath) {
2245
2727
  const idRe = new RegExp(`\\s*<p:sldMasterId[^>]*r:id="${match[1]}"[^>]*/>`);
2246
2728
  zip.file(presPath, presContent.replace(idRe, ""));
2247
2729
  }
2248
- function withCSldName(xml, name) {
2730
+ function withCSldName(xml2, name) {
2249
2731
  const escaped = escAttr(name);
2250
- if (/<p:cSld[^>]*\sname="/.test(xml)) {
2251
- return xml.replace(/(<p:cSld[^>]*\sname=")[^"]*(")/, `$1${escaped}$2`);
2732
+ if (/<p:cSld[^>]*\sname="/.test(xml2)) {
2733
+ return xml2.replace(/(<p:cSld[^>]*\sname=")[^"]*(")/, `$1${escaped}$2`);
2252
2734
  }
2253
- return xml.replace(/<p:cSld(?=[\s>])/, `<p:cSld name="${escaped}"`);
2735
+ return xml2.replace(/<p:cSld(?=[\s>])/, `<p:cSld name="${escaped}"`);
2254
2736
  }
2255
2737
  var MASTER_XMLNS = 'xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:p="http://schemas.openxmlformats.org/presentationml/2006/main"';
2256
2738
  var FALLBACK_CLR_MAP = '<p:clrMap bg1="lt1" tx1="dk1" bg2="lt2" tx2="dk2" accent1="accent1" accent2="accent2" accent3="accent3" accent4="accent4" accent5="accent5" accent6="accent6" hlink="hlink" folHlink="folHlink"/>';
2257
2739
  var FALLBACK_TX_STYLES = '<p:txStyles><p:titleStyle><a:lvl1pPr algn="l"><a:defRPr sz="4400" kern="1200"><a:solidFill><a:schemeClr val="tx1"/></a:solidFill><a:latin typeface="+mj-lt"/></a:defRPr></a:lvl1pPr></p:titleStyle><p:bodyStyle><a:lvl1pPr algn="l"><a:defRPr sz="3200" kern="1200"><a:solidFill><a:schemeClr val="tx1"/></a:solidFill><a:latin typeface="+mn-lt"/></a:defRPr></a:lvl1pPr></p:bodyStyle><p:otherStyle><a:defPPr><a:defRPr lang="en-US"/></a:defPPr></p:otherStyle></p:txStyles>';
2258
- function extractTag(xml, tag) {
2259
- const container = xml.match(new RegExp(`<${tag}(?:\\s[^>]*)?>[^]*?</${tag}>`));
2740
+ function extractTag(xml2, tag2) {
2741
+ const container = xml2.match(new RegExp(`<${tag2}(?:\\s[^>]*)?>[^]*?</${tag2}>`));
2260
2742
  if (container) {
2261
2743
  return container[0];
2262
2744
  }
2263
- const selfClosed = xml.match(new RegExp(`<${tag}(?:\\s[^>]*)?/>`));
2745
+ const selfClosed = xml2.match(new RegExp(`<${tag2}(?:\\s[^>]*)?/>`));
2264
2746
  return selfClosed ? selfClosed[0] : "";
2265
2747
  }
2266
2748
  function newMasterXmlFromSource(sourceMasterXml, sldLayoutIdLst) {
@@ -3158,8 +3640,8 @@ var ShapeBuilder = class _ShapeBuilder {
3158
3640
  *
3159
3641
  * @param style - A partial {@link TextStyleInput} for font, size, color, etc.
3160
3642
  */
3161
- textStyle(style) {
3162
- this._options.textStyle = style;
3643
+ textStyle(style2) {
3644
+ this._options.textStyle = style2;
3163
3645
  return this;
3164
3646
  }
3165
3647
  /**
@@ -14472,6 +14954,111 @@ function listUnassessedOpenXmlCoverage(vocabulary) {
14472
14954
  );
14473
14955
  }
14474
14956
 
14957
+ // pptx/merge-child-order.ts
14958
+ function sequence(order, choices = []) {
14959
+ const ranks = new Map(order.map((name, index) => [name, index]));
14960
+ for (const choice of choices) {
14961
+ const positions = choice.flatMap((name) => {
14962
+ const position2 = ranks.get(name);
14963
+ return position2 === void 0 ? [] : [position2];
14964
+ });
14965
+ if (!positions.length) continue;
14966
+ const position = Math.min(...positions);
14967
+ for (const name of choice) if (ranks.has(name)) ranks.set(name, position);
14968
+ }
14969
+ return ranks;
14970
+ }
14971
+ var shapeChoices = [
14972
+ ["a:custGeom", "a:prstGeom"],
14973
+ FILL_CHOICE_ELEMENTS,
14974
+ ["a:effectLst", "a:effectDag"]
14975
+ ];
14976
+ var shape = sequence(SP_PR_ORDER, shapeChoices);
14977
+ var group = sequence(
14978
+ SP_PR_ORDER.filter((name) => !["a:custGeom", "a:prstGeom", "a:ln", "a:sp3d"].includes(name)),
14979
+ shapeChoices
14980
+ );
14981
+ var line = sequence(LN_CHILD_ORDER, [
14982
+ FILL_CHOICE_ELEMENTS,
14983
+ ["a:prstDash", "a:custDash"],
14984
+ ["a:round", "a:bevel", "a:miter"]
14985
+ ]);
14986
+ var blip = sequence(BLIP_FILL_ORDER, [["a:tile", "a:stretch"]]);
14987
+ var effects = sequence(EFFECT_LST_ORDER);
14988
+ var style = sequence(SHAPE_STYLE_ORDER);
14989
+ var cell = sequence(TC_PR_BORDERS_ORDER, [FILL_CHOICE_ELEMENTS]);
14990
+ function pptxChildOrder(element, parent) {
14991
+ if (element.namespaceURI !== NS.a) return void 0;
14992
+ let ranks;
14993
+ if (parent.namespaceURI === NS.p) {
14994
+ switch (parent.localName) {
14995
+ case "spPr":
14996
+ ranks = shape;
14997
+ break;
14998
+ case "grpSpPr":
14999
+ ranks = group;
15000
+ break;
15001
+ case "blipFill":
15002
+ ranks = blip;
15003
+ break;
15004
+ case "style":
15005
+ ranks = style;
15006
+ break;
15007
+ }
15008
+ } else if (parent.namespaceURI === NS.a) {
15009
+ switch (parent.localName) {
15010
+ case "ln":
15011
+ ranks = line;
15012
+ break;
15013
+ case "blipFill":
15014
+ ranks = blip;
15015
+ break;
15016
+ case "effectLst":
15017
+ ranks = effects;
15018
+ break;
15019
+ case "tcPr":
15020
+ ranks = cell;
15021
+ break;
15022
+ }
15023
+ }
15024
+ return ranks?.get("a:" + element.localName);
15025
+ }
15026
+
15027
+ // pptx/merge-snapshots.ts
15028
+ var SLIDE_PART = /^ppt\/(?:slides\/slide\d+|notesSlides\/notesSlide\d+)\.xml$/u;
15029
+ var SHAPES = /* @__PURE__ */ new Set(["sp", "pic", "cxnSp", "graphicFrame", "grpSp"]);
15030
+ var POSITIONAL = /* @__PURE__ */ new Set(["txBody", "p", "r", "fld"]);
15031
+ function keyElement(element, parent) {
15032
+ if (element.namespaceURI !== NS.p || !SHAPES.has(element.localName) || parent.namespaceURI !== NS.p || parent.localName !== "spTree" && parent.localName !== "grpSp")
15033
+ return void 0;
15034
+ const id = element.getElementsByTagNameNS(NS.p, "cNvPr")[0]?.getAttribute("id");
15035
+ return id ? `shape:${id}` : void 0;
15036
+ }
15037
+ function mergePptxSnapshots(base, local, remote) {
15038
+ return mergeOpcSnapshots(base, local, remote, {
15039
+ async mergePart(input) {
15040
+ if (!SLIDE_PART.test(input.path) || !input.base || !input.local || !input.remote)
15041
+ return {
15042
+ status: "unresolved",
15043
+ issues: [`Concurrent unsupported PPTX part: ${input.path}`]
15044
+ };
15045
+ const decoder2 = new TextDecoder();
15046
+ const result = mergeXmlThreeWay(
15047
+ decoder2.decode(input.base),
15048
+ decoder2.decode(input.local),
15049
+ decoder2.decode(input.remote),
15050
+ {
15051
+ keyElement,
15052
+ childOrder: pptxChildOrder,
15053
+ allowPositional: (parent) => (parent.namespaceURI === NS.a || parent.namespaceURI === NS.p) && POSITIONAL.has(parent.localName),
15054
+ allowText: (element) => element.namespaceURI === NS.a && element.localName === "t"
15055
+ }
15056
+ );
15057
+ return result.status === "merged" ? { status: "merged", bytes: new TextEncoder().encode(result.xml) } : { status: "unresolved", issues: result.issues.map((issue) => `${input.path}: ${issue}`) };
15058
+ }
15059
+ });
15060
+ }
15061
+
14475
15062
  // pptx/core/utils/suite-text.ts
14476
15063
  async function inspectPresentationText(bytes) {
14477
15064
  const data = await new PptxHandler().load(new Uint8Array(bytes).buffer);
@@ -14511,7 +15098,7 @@ async function setPresentationRunText(bytes, slideIndex, elementId, runIndex, te
14511
15098
  async function createPresentationFromOutline(slides, options = {}) {
14512
15099
  if (!(slides instanceof Array) || !slides.length || slides.length > 200)
14513
15100
  throw new Error("A presentation outline has 1 to 200 slides");
14514
- const { PresentationBuilder: PresentationBuilder2 } = await import('./PresentationBuilder-XHKNDJMD.mjs');
15101
+ const { PresentationBuilder: PresentationBuilder2 } = await import('./PresentationBuilder-T2B5PPZA.mjs');
14515
15102
  const { handler, data, createSlide } = await PresentationBuilder2.create({
14516
15103
  ...options.title ? { title: options.title } : {}
14517
15104
  });
@@ -14547,4 +15134,4 @@ async function createPresentationFromOutline(slides, options = {}) {
14547
15134
  return handler.save(data.slides);
14548
15135
  }
14549
15136
 
14550
- export { ChartBuilder, ConnectorBuilder, GroupBuilder, ImageBuilder, MediaBuilder, OPENXML_COVERAGE, OPENXML_SCHEMA_CONSTRUCT_IDS, OPENXML_STRICT_SCHEMA_CONSTRUCT_IDS, OPENXML_TRANSITIONAL_SCHEMA_CONSTRUCT_IDS, Presentation, SLIDE_PACKAGE_CLIPBOARD_MIME, ShapeBuilder, SlideSizes, THEME_PRESETS, TRANSITION_PATTERN_OPTIONS, TRANSITION_THRUBLK_TYPES, TRANSITION_VALID_DIRECTIONS, TableBuilder, TextBuilder, ThemePresets, addChartUserShape, addChartUserShapeGroupChild, addSection, applyTemplate, chartSupportsSecondaryAxis, cm, cmToEmu, collectLayoutNames, collectMasterNames, createPresentationFromOutline, createSlideClipboardPackage, deleteLayout, deleteSlideMaster, deserializeSlidePackageClipboard, diffPresentations, diffSlides, duplicateElement, duplicateLayout, duplicateSlide, duplicateSlideMaster, emuToPixels, findOpenXmlCoverage, findPlaceholders, getChartUserShapeAtPath, getSectionForSlide, getThemePreset, importSlidePackage, inches, inchesToEmu, insertLayout, insertSlideMaster, inspectPresentationText, interpolateShapeGeometry, isChartSeriesOnSecondaryAxis, listChartUserShapes, listUnassessedOpenXmlCoverage, mailMerge, mm, moveSlidesToSection, parseSvgPath, pixelsToEmu, pt, removeChartUserShape, removeChartUserShapeAtPath, removeSection, renameLayout, renameSlideMaster, reorderSections, replaceShapeGeometry, replaceWithCustomGeometry, resetChartElementFormat, resetCloneIdCounter, resetSectionIdCounter, serializeSlidePackageClipboard, serializeSvgPath, setChartColorMapOverride, setChartDataPointGradient, setChartDataPointStyle, setChartHelperLine, setChartSeriesGradient, setElementLocked, setPresentationRunText, summarizeOpenXmlCoverage, summarizeOpenXmlCoverageByVocabulary, uniqueDisplayName, uniquePrefixedName, updateChartUserShape, updateChartUserShapeAtPath, withChartAxisOptions, withChartDataLabelOptions, withChartElementFormat, withChartLegendOptions, withChartSeriesOnSecondaryAxis, withChartSeriesOptions };
15137
+ export { ChartBuilder, ConnectorBuilder, GroupBuilder, ImageBuilder, MediaBuilder, OPENXML_COVERAGE, OPENXML_SCHEMA_CONSTRUCT_IDS, OPENXML_STRICT_SCHEMA_CONSTRUCT_IDS, OPENXML_TRANSITIONAL_SCHEMA_CONSTRUCT_IDS, Presentation, SLIDE_PACKAGE_CLIPBOARD_MIME, ShapeBuilder, SlideSizes, THEME_PRESETS, TRANSITION_PATTERN_OPTIONS, TRANSITION_THRUBLK_TYPES, TRANSITION_VALID_DIRECTIONS, TableBuilder, TextBuilder, ThemePresets, addChartUserShape, addChartUserShapeGroupChild, addSection, applyTemplate, chartSupportsSecondaryAxis, cm, cmToEmu, collectLayoutNames, collectMasterNames, createPresentationFromOutline, createSlideClipboardPackage, deleteLayout, deleteSlideMaster, deserializeSlidePackageClipboard, diffPresentations, diffSlides, duplicateElement, duplicateLayout, duplicateSlide, duplicateSlideMaster, emuToPixels, findOpenXmlCoverage, findPlaceholders, getChartUserShapeAtPath, getSectionForSlide, getThemePreset, importSlidePackage, inches, inchesToEmu, insertLayout, insertSlideMaster, inspectPresentationText, interpolateShapeGeometry, isChartSeriesOnSecondaryAxis, listChartUserShapes, listUnassessedOpenXmlCoverage, mailMerge, mergePptxSnapshots, mm, moveSlidesToSection, parseSvgPath, pixelsToEmu, pt, removeChartUserShape, removeChartUserShapeAtPath, removeSection, renameLayout, renameSlideMaster, reorderSections, replaceShapeGeometry, replaceWithCustomGeometry, resetChartElementFormat, resetCloneIdCounter, resetSectionIdCounter, serializeSlidePackageClipboard, serializeSvgPath, setChartColorMapOverride, setChartDataPointGradient, setChartDataPointStyle, setChartHelperLine, setChartSeriesGradient, setElementLocked, setPresentationRunText, summarizeOpenXmlCoverage, summarizeOpenXmlCoverageByVocabulary, uniqueDisplayName, uniquePrefixedName, updateChartUserShape, updateChartUserShapeAtPath, withChartAxisOptions, withChartDataLabelOptions, withChartElementFormat, withChartLegendOptions, withChartSeriesOnSecondaryAxis, withChartSeriesOptions };