@harbour-enterprises/superdoc 0.23.0-next.14 → 0.23.0-next.16

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 (36) hide show
  1. package/dist/chunks/{PdfViewer-D3cgkd9j.cjs → PdfViewer-CJrsZCLf.cjs} +1 -1
  2. package/dist/chunks/{PdfViewer-BaaVD5bX.es.js → PdfViewer-DfGIeWvO.es.js} +1 -1
  3. package/dist/chunks/{eventemitter3-CR2eBWft.es.js → eventemitter3-BWEnUdTY.es.js} +1 -1
  4. package/dist/chunks/{eventemitter3-DSRogsNq.cjs → eventemitter3-DkXkH2rT.cjs} +1 -1
  5. package/dist/chunks/{index-CESuSQe2.es.js → index-CwhKMy0h.es.js} +27 -332
  6. package/dist/chunks/{index-CAHkANZY.cjs → index-DGSQ4Gfx.cjs} +160 -465
  7. package/dist/chunks/{super-editor.es-BYutUrPg.cjs → super-editor.es-b9ACFl9D.cjs} +649 -125
  8. package/dist/chunks/{super-editor.es-BKb7p4fi.es.js → super-editor.es-bIibjiHo.es.js} +649 -125
  9. package/dist/chunks/{xml-js-CWV8R-ek.cjs → xml-js-D_ZIzxu0.cjs} +1 -1
  10. package/dist/chunks/xml-js-Dx4FIjnp.es.js +2 -0
  11. package/dist/core/types/index.d.ts +19 -1
  12. package/dist/core/types/index.d.ts.map +1 -1
  13. package/dist/super-editor/ai-writer.es.js +2 -2
  14. package/dist/super-editor/chunks/{converter-DD7uNz2k.js → converter-vEmAnrOg.js} +665 -249
  15. package/dist/super-editor/chunks/{docx-zipper-DraPR30Z.js → docx-zipper-DA00N7eN.js} +1 -1
  16. package/dist/super-editor/chunks/{editor-xzhKWRFZ.js → editor-CVzagv2Y.js} +127 -19
  17. package/dist/super-editor/chunks/{toolbar-D6SJTVWT.js → toolbar-BCJtFyig.js} +2 -2
  18. package/dist/super-editor/converter.es.js +1 -1
  19. package/dist/super-editor/docx-zipper.es.js +2 -2
  20. package/dist/super-editor/editor.es.js +3 -3
  21. package/dist/super-editor/file-zipper.es.js +1 -1
  22. package/dist/super-editor/src/core/Editor.d.ts +57 -3
  23. package/dist/super-editor/src/core/super-converter/SuperConverter.d.ts +58 -2
  24. package/dist/super-editor/src/core/super-converter/exporter-docx-defs.d.ts +28 -39
  25. package/dist/super-editor/super-editor.es.js +6 -6
  26. package/dist/super-editor/toolbar.es.js +2 -2
  27. package/dist/super-editor.cjs +1 -1
  28. package/dist/super-editor.es.js +1 -1
  29. package/dist/superdoc.cjs +2 -3
  30. package/dist/superdoc.es.js +2 -3
  31. package/dist/superdoc.umd.js +674 -455
  32. package/dist/superdoc.umd.js.map +1 -1
  33. package/package.json +1 -1
  34. package/dist/chunks/xml-js-Bbc0NeKa.es.js +0 -2
  35. package/dist/chunks/{jszip-DAXEPCUv.es.js → jszip-BDk3JBqp.es.js} +3 -3
  36. package/dist/chunks/{jszip-B4LDL19y.cjs → jszip-u4dvXAKa.cjs} +3 -3
@@ -7,12 +7,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
7
7
  var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
8
8
  var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
9
9
  var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
10
- var _a, _DocxExporter_instances, generate_xml_as_list_fn, replaceSpecialCharacters_fn, generateXml_fn, _SuperConverter_instances, exportNumberingFile_fn, prepareCommentsXmlFilesForExport_fn, exportProcessHeadersFooters_fn, exportProcessNewRelationships_fn, exportProcessMediaFiles_fn;
10
+ var _a, _DocxExporter_instances, generate_xml_as_list_fn, replaceSpecialCharacters_fn, generateXml_fn, _SuperConverter_instances, generateDocumentHash_fn, exportNumberingFile_fn, prepareCommentsXmlFilesForExport_fn, exportProcessHeadersFooters_fn, exportProcessNewRelationships_fn, exportProcessMediaFiles_fn;
11
11
  import { createElementBlock, openBlock, createElementVNode } from "vue";
12
- var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
13
- function getDefaultExportFromCjs$1(x) {
14
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
15
- }
16
12
  var buffer = {};
17
13
  var base64Js = {};
18
14
  base64Js.byteLength = byteLength;
@@ -1779,6 +1775,10 @@ ieee754.write = function(buffer2, value, offset, isLE, mLen, nBytes) {
1779
1775
  }
1780
1776
  })(buffer);
1781
1777
  const Buffer2 = buffer.Buffer;
1778
+ var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
1779
+ function getDefaultExportFromCjs$2(x) {
1780
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
1781
+ }
1782
1782
  var sax = {};
1783
1783
  var events = { exports: {} };
1784
1784
  var hasRequiredEvents;
@@ -2093,9 +2093,9 @@ function requireEvents() {
2093
2093
  copy2[i] = arr[i];
2094
2094
  return copy2;
2095
2095
  }
2096
- function spliceOne(list, index) {
2097
- for (; index + 1 < list.length; index++)
2098
- list[index] = list[index + 1];
2096
+ function spliceOne(list, index2) {
2097
+ for (; index2 + 1 < list.length; index2++)
2098
+ list[index2] = list[index2 + 1];
2099
2099
  list.pop();
2100
2100
  }
2101
2101
  function unwrapListeners(arr) {
@@ -2181,7 +2181,7 @@ function requireInherits_browser() {
2181
2181
  }
2182
2182
  return inherits_browser.exports;
2183
2183
  }
2184
- function getDefaultExportFromCjs(x) {
2184
+ function getDefaultExportFromCjs$1(x) {
2185
2185
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
2186
2186
  }
2187
2187
  var browser$1 = { exports: {} };
@@ -2342,7 +2342,7 @@ process.umask = function() {
2342
2342
  return 0;
2343
2343
  };
2344
2344
  var browserExports = browser$1.exports;
2345
- const process$1 = /* @__PURE__ */ getDefaultExportFromCjs(browserExports);
2345
+ const process$1 = /* @__PURE__ */ getDefaultExportFromCjs$1(browserExports);
2346
2346
  var streamBrowser;
2347
2347
  var hasRequiredStreamBrowser;
2348
2348
  function requireStreamBrowser() {
@@ -8552,9 +8552,9 @@ function require_stream_readable() {
8552
8552
  });
8553
8553
  return this;
8554
8554
  }
8555
- var index = indexOf(state2.pipes, dest);
8556
- if (index === -1) return this;
8557
- state2.pipes.splice(index, 1);
8555
+ var index2 = indexOf(state2.pipes, dest);
8556
+ if (index2 === -1) return this;
8557
+ state2.pipes.splice(index2, 1);
8558
8558
  state2.pipesCount -= 1;
8559
8559
  if (state2.pipesCount === 1) state2.pipes = state2.pipes[0];
8560
8560
  dest.emit("unpipe", this, unpipeInfo);
@@ -10491,14 +10491,14 @@ function requireSax() {
10491
10491
  var codeUnits = [];
10492
10492
  var highSurrogate;
10493
10493
  var lowSurrogate;
10494
- var index = -1;
10494
+ var index2 = -1;
10495
10495
  var length = arguments.length;
10496
10496
  if (!length) {
10497
10497
  return "";
10498
10498
  }
10499
10499
  var result = "";
10500
- while (++index < length) {
10501
- var codePoint = Number(arguments[index]);
10500
+ while (++index2 < length) {
10501
+ var codePoint = Number(arguments[index2]);
10502
10502
  if (!isFinite(codePoint) || // `NaN`, `+Infinity`, or `-Infinity`
10503
10503
  codePoint < 0 || // not a valid Unicode code point
10504
10504
  codePoint > 1114111 || // not a valid Unicode code point
@@ -10513,7 +10513,7 @@ function requireSax() {
10513
10513
  lowSurrogate = codePoint % 1024 + 56320;
10514
10514
  codeUnits.push(highSurrogate, lowSurrogate);
10515
10515
  }
10516
- if (index + 1 === length || codeUnits.length > MAX_SIZE) {
10516
+ if (index2 + 1 === length || codeUnits.length > MAX_SIZE) {
10517
10517
  result += stringFromCharCode.apply(null, codeUnits);
10518
10518
  codeUnits.length = 0;
10519
10519
  }
@@ -11327,7 +11327,7 @@ function requireLib() {
11327
11327
  return lib;
11328
11328
  }
11329
11329
  var libExports = requireLib();
11330
- const xmljs = /* @__PURE__ */ getDefaultExportFromCjs$1(libExports);
11330
+ const xmljs = /* @__PURE__ */ getDefaultExportFromCjs$2(libExports);
11331
11331
  var getRandomValues;
11332
11332
  var rnds8 = new Uint8Array(16);
11333
11333
  function rng() {
@@ -11362,6 +11362,306 @@ function v4(options, buf, offset) {
11362
11362
  rnds[8] = rnds[8] & 63 | 128;
11363
11363
  return stringify(rnds);
11364
11364
  }
11365
+ function getDefaultExportFromCjs(x) {
11366
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
11367
+ }
11368
+ const CRC_TABLE = new Int32Array([
11369
+ 0,
11370
+ 1996959894,
11371
+ 3993919788,
11372
+ 2567524794,
11373
+ 124634137,
11374
+ 1886057615,
11375
+ 3915621685,
11376
+ 2657392035,
11377
+ 249268274,
11378
+ 2044508324,
11379
+ 3772115230,
11380
+ 2547177864,
11381
+ 162941995,
11382
+ 2125561021,
11383
+ 3887607047,
11384
+ 2428444049,
11385
+ 498536548,
11386
+ 1789927666,
11387
+ 4089016648,
11388
+ 2227061214,
11389
+ 450548861,
11390
+ 1843258603,
11391
+ 4107580753,
11392
+ 2211677639,
11393
+ 325883990,
11394
+ 1684777152,
11395
+ 4251122042,
11396
+ 2321926636,
11397
+ 335633487,
11398
+ 1661365465,
11399
+ 4195302755,
11400
+ 2366115317,
11401
+ 997073096,
11402
+ 1281953886,
11403
+ 3579855332,
11404
+ 2724688242,
11405
+ 1006888145,
11406
+ 1258607687,
11407
+ 3524101629,
11408
+ 2768942443,
11409
+ 901097722,
11410
+ 1119000684,
11411
+ 3686517206,
11412
+ 2898065728,
11413
+ 853044451,
11414
+ 1172266101,
11415
+ 3705015759,
11416
+ 2882616665,
11417
+ 651767980,
11418
+ 1373503546,
11419
+ 3369554304,
11420
+ 3218104598,
11421
+ 565507253,
11422
+ 1454621731,
11423
+ 3485111705,
11424
+ 3099436303,
11425
+ 671266974,
11426
+ 1594198024,
11427
+ 3322730930,
11428
+ 2970347812,
11429
+ 795835527,
11430
+ 1483230225,
11431
+ 3244367275,
11432
+ 3060149565,
11433
+ 1994146192,
11434
+ 31158534,
11435
+ 2563907772,
11436
+ 4023717930,
11437
+ 1907459465,
11438
+ 112637215,
11439
+ 2680153253,
11440
+ 3904427059,
11441
+ 2013776290,
11442
+ 251722036,
11443
+ 2517215374,
11444
+ 3775830040,
11445
+ 2137656763,
11446
+ 141376813,
11447
+ 2439277719,
11448
+ 3865271297,
11449
+ 1802195444,
11450
+ 476864866,
11451
+ 2238001368,
11452
+ 4066508878,
11453
+ 1812370925,
11454
+ 453092731,
11455
+ 2181625025,
11456
+ 4111451223,
11457
+ 1706088902,
11458
+ 314042704,
11459
+ 2344532202,
11460
+ 4240017532,
11461
+ 1658658271,
11462
+ 366619977,
11463
+ 2362670323,
11464
+ 4224994405,
11465
+ 1303535960,
11466
+ 984961486,
11467
+ 2747007092,
11468
+ 3569037538,
11469
+ 1256170817,
11470
+ 1037604311,
11471
+ 2765210733,
11472
+ 3554079995,
11473
+ 1131014506,
11474
+ 879679996,
11475
+ 2909243462,
11476
+ 3663771856,
11477
+ 1141124467,
11478
+ 855842277,
11479
+ 2852801631,
11480
+ 3708648649,
11481
+ 1342533948,
11482
+ 654459306,
11483
+ 3188396048,
11484
+ 3373015174,
11485
+ 1466479909,
11486
+ 544179635,
11487
+ 3110523913,
11488
+ 3462522015,
11489
+ 1591671054,
11490
+ 702138776,
11491
+ 2966460450,
11492
+ 3352799412,
11493
+ 1504918807,
11494
+ 783551873,
11495
+ 3082640443,
11496
+ 3233442989,
11497
+ 3988292384,
11498
+ 2596254646,
11499
+ 62317068,
11500
+ 1957810842,
11501
+ 3939845945,
11502
+ 2647816111,
11503
+ 81470997,
11504
+ 1943803523,
11505
+ 3814918930,
11506
+ 2489596804,
11507
+ 225274430,
11508
+ 2053790376,
11509
+ 3826175755,
11510
+ 2466906013,
11511
+ 167816743,
11512
+ 2097651377,
11513
+ 4027552580,
11514
+ 2265490386,
11515
+ 503444072,
11516
+ 1762050814,
11517
+ 4150417245,
11518
+ 2154129355,
11519
+ 426522225,
11520
+ 1852507879,
11521
+ 4275313526,
11522
+ 2312317920,
11523
+ 282753626,
11524
+ 1742555852,
11525
+ 4189708143,
11526
+ 2394877945,
11527
+ 397917763,
11528
+ 1622183637,
11529
+ 3604390888,
11530
+ 2714866558,
11531
+ 953729732,
11532
+ 1340076626,
11533
+ 3518719985,
11534
+ 2797360999,
11535
+ 1068828381,
11536
+ 1219638859,
11537
+ 3624741850,
11538
+ 2936675148,
11539
+ 906185462,
11540
+ 1090812512,
11541
+ 3747672003,
11542
+ 2825379669,
11543
+ 829329135,
11544
+ 1181335161,
11545
+ 3412177804,
11546
+ 3160834842,
11547
+ 628085408,
11548
+ 1382605366,
11549
+ 3423369109,
11550
+ 3138078467,
11551
+ 570562233,
11552
+ 1426400815,
11553
+ 3317316542,
11554
+ 2998733608,
11555
+ 733239954,
11556
+ 1555261956,
11557
+ 3268935591,
11558
+ 3050360625,
11559
+ 752459403,
11560
+ 1541320221,
11561
+ 2607071920,
11562
+ 3965973030,
11563
+ 1969922972,
11564
+ 40735498,
11565
+ 2617837225,
11566
+ 3943577151,
11567
+ 1913087877,
11568
+ 83908371,
11569
+ 2512341634,
11570
+ 3803740692,
11571
+ 2075208622,
11572
+ 213261112,
11573
+ 2463272603,
11574
+ 3855990285,
11575
+ 2094854071,
11576
+ 198958881,
11577
+ 2262029012,
11578
+ 4057260610,
11579
+ 1759359992,
11580
+ 534414190,
11581
+ 2176718541,
11582
+ 4139329115,
11583
+ 1873836001,
11584
+ 414664567,
11585
+ 2282248934,
11586
+ 4279200368,
11587
+ 1711684554,
11588
+ 285281116,
11589
+ 2405801727,
11590
+ 4167216745,
11591
+ 1634467795,
11592
+ 376229701,
11593
+ 2685067896,
11594
+ 3608007406,
11595
+ 1308918612,
11596
+ 956543938,
11597
+ 2808555105,
11598
+ 3495958263,
11599
+ 1231636301,
11600
+ 1047427035,
11601
+ 2932959818,
11602
+ 3654703836,
11603
+ 1088359270,
11604
+ 936918e3,
11605
+ 2847714899,
11606
+ 3736837829,
11607
+ 1202900863,
11608
+ 817233897,
11609
+ 3183342108,
11610
+ 3401237130,
11611
+ 1404277552,
11612
+ 615818150,
11613
+ 3134207493,
11614
+ 3453421203,
11615
+ 1423857449,
11616
+ 601450431,
11617
+ 3009837614,
11618
+ 3294710456,
11619
+ 1567103746,
11620
+ 711928724,
11621
+ 3020668471,
11622
+ 3272380065,
11623
+ 1510334235,
11624
+ 755167117
11625
+ ]);
11626
+ function ensureBuffer(input) {
11627
+ if (Buffer2.isBuffer(input)) {
11628
+ return input;
11629
+ }
11630
+ if (typeof input === "number") {
11631
+ return Buffer2.alloc(input);
11632
+ } else if (typeof input === "string") {
11633
+ return Buffer2.from(input);
11634
+ } else {
11635
+ throw new Error("input must be buffer, number, or string, received " + typeof input);
11636
+ }
11637
+ }
11638
+ function bufferizeInt(num) {
11639
+ const tmp = ensureBuffer(4);
11640
+ tmp.writeInt32BE(num, 0);
11641
+ return tmp;
11642
+ }
11643
+ function _crc32(buf, previous) {
11644
+ buf = ensureBuffer(buf);
11645
+ if (Buffer2.isBuffer(previous)) {
11646
+ previous = previous.readUInt32BE(0);
11647
+ }
11648
+ let crc = ~~previous ^ -1;
11649
+ for (var n = 0; n < buf.length; n++) {
11650
+ crc = CRC_TABLE[(crc ^ buf[n]) & 255] ^ crc >>> 8;
11651
+ }
11652
+ return crc ^ -1;
11653
+ }
11654
+ function crc32() {
11655
+ return bufferizeInt(_crc32.apply(null, arguments));
11656
+ }
11657
+ crc32.signed = function() {
11658
+ return _crc32.apply(null, arguments);
11659
+ };
11660
+ crc32.unsigned = function() {
11661
+ return _crc32.apply(null, arguments) >>> 0;
11662
+ };
11663
+ var bufferCrc32 = crc32;
11664
+ const index = /* @__PURE__ */ getDefaultExportFromCjs(bufferCrc32);
11365
11665
  function callOrGet(value, context = null, ...props) {
11366
11666
  if (typeof value === "function") {
11367
11667
  if (context) return value.bind(context)(...props);
@@ -11691,13 +11991,13 @@ class Fragment {
11691
11991
  Create a new fragment in which the node at the given index is
11692
11992
  replaced by the given node.
11693
11993
  */
11694
- replaceChild(index, node) {
11695
- let current = this.content[index];
11994
+ replaceChild(index2, node) {
11995
+ let current = this.content[index2];
11696
11996
  if (current == node)
11697
11997
  return this;
11698
11998
  let copy2 = this.content.slice();
11699
11999
  let size = this.size + node.nodeSize - current.nodeSize;
11700
- copy2[index] = node;
12000
+ copy2[index2] = node;
11701
12001
  return new Fragment(copy2, size);
11702
12002
  }
11703
12003
  /**
@@ -11747,17 +12047,17 @@ class Fragment {
11747
12047
  Get the child node at the given index. Raise an error when the
11748
12048
  index is out of range.
11749
12049
  */
11750
- child(index) {
11751
- let found2 = this.content[index];
12050
+ child(index2) {
12051
+ let found2 = this.content[index2];
11752
12052
  if (!found2)
11753
- throw new RangeError("Index " + index + " out of range for " + this);
12053
+ throw new RangeError("Index " + index2 + " out of range for " + this);
11754
12054
  return found2;
11755
12055
  }
11756
12056
  /**
11757
12057
  Get the child node at the given index, if it exists.
11758
12058
  */
11759
- maybeChild(index) {
11760
- return this.content[index] || null;
12059
+ maybeChild(index2) {
12060
+ return this.content[index2] || null;
11761
12061
  }
11762
12062
  /**
11763
12063
  Call `f` for every child node, passing the node, its offset
@@ -11877,8 +12177,8 @@ class Fragment {
11877
12177
  }
11878
12178
  Fragment.empty = new Fragment([], 0);
11879
12179
  const found = { index: 0, offset: 0 };
11880
- function retIndex(index, offset) {
11881
- found.index = index;
12180
+ function retIndex(index2, offset) {
12181
+ found.index = index2;
11882
12182
  found.offset = offset;
11883
12183
  return found;
11884
12184
  }
@@ -12117,26 +12417,26 @@ class Slice {
12117
12417
  }
12118
12418
  Slice.empty = new Slice(Fragment.empty, 0, 0);
12119
12419
  function removeRange(content, from, to) {
12120
- let { index, offset } = content.findIndex(from), child = content.maybeChild(index);
12420
+ let { index: index2, offset } = content.findIndex(from), child = content.maybeChild(index2);
12121
12421
  let { index: indexTo, offset: offsetTo } = content.findIndex(to);
12122
12422
  if (offset == from || child.isText) {
12123
12423
  if (offsetTo != to && !content.child(indexTo).isText)
12124
12424
  throw new RangeError("Removing non-flat range");
12125
12425
  return content.cut(0, from).append(content.cut(to));
12126
12426
  }
12127
- if (index != indexTo)
12427
+ if (index2 != indexTo)
12128
12428
  throw new RangeError("Removing non-flat range");
12129
- return content.replaceChild(index, child.copy(removeRange(child.content, from - offset - 1, to - offset - 1)));
12429
+ return content.replaceChild(index2, child.copy(removeRange(child.content, from - offset - 1, to - offset - 1)));
12130
12430
  }
12131
12431
  function insertInto(content, dist2, insert, parent) {
12132
- let { index, offset } = content.findIndex(dist2), child = content.maybeChild(index);
12432
+ let { index: index2, offset } = content.findIndex(dist2), child = content.maybeChild(index2);
12133
12433
  if (offset == dist2 || child.isText) {
12134
- if (parent && !parent.canReplace(index, index, insert))
12434
+ if (parent && !parent.canReplace(index2, index2, insert))
12135
12435
  return null;
12136
12436
  return content.cut(0, dist2).append(insert).append(content.cut(dist2));
12137
12437
  }
12138
12438
  let inner = insertInto(child.content, dist2 - offset - 1, insert, child);
12139
- return inner && content.replaceChild(index, child.copy(inner));
12439
+ return inner && content.replaceChild(index2, child.copy(inner));
12140
12440
  }
12141
12441
  function replace($from, $to, slice) {
12142
12442
  if (slice.openStart > $from.depth)
@@ -12146,10 +12446,10 @@ function replace($from, $to, slice) {
12146
12446
  return replaceOuter($from, $to, slice, 0);
12147
12447
  }
12148
12448
  function replaceOuter($from, $to, slice, depth) {
12149
- let index = $from.index(depth), node = $from.node(depth);
12150
- if (index == $to.index(depth) && depth < $from.depth - slice.openStart) {
12449
+ let index2 = $from.index(depth), node = $from.node(depth);
12450
+ if (index2 == $to.index(depth) && depth < $from.depth - slice.openStart) {
12151
12451
  let inner = replaceOuter($from, $to, slice, depth + 1);
12152
- return node.copy(node.content.replaceChild(index, inner));
12452
+ return node.copy(node.content.replaceChild(index2, inner));
12153
12453
  } else if (!slice.content.size) {
12154
12454
  return close(node, replaceTwoWay($from, $to, depth));
12155
12455
  } else if (!slice.openStart && !slice.openEnd && $from.depth == depth && $to.depth == depth) {
@@ -12343,11 +12643,11 @@ class ResolvedPos {
12343
12643
  position is returned.
12344
12644
  */
12345
12645
  get nodeAfter() {
12346
- let parent = this.parent, index = this.index(this.depth);
12347
- if (index == parent.childCount)
12646
+ let parent = this.parent, index2 = this.index(this.depth);
12647
+ if (index2 == parent.childCount)
12348
12648
  return null;
12349
- let dOff = this.pos - this.path[this.path.length - 1], child = parent.child(index);
12350
- return dOff ? parent.child(index).cut(dOff) : child;
12649
+ let dOff = this.pos - this.path[this.path.length - 1], child = parent.child(index2);
12650
+ return dOff ? parent.child(index2).cut(dOff) : child;
12351
12651
  }
12352
12652
  /**
12353
12653
  Get the node directly before the position, if any. If the
@@ -12355,20 +12655,20 @@ class ResolvedPos {
12355
12655
  before the position is returned.
12356
12656
  */
12357
12657
  get nodeBefore() {
12358
- let index = this.index(this.depth);
12658
+ let index2 = this.index(this.depth);
12359
12659
  let dOff = this.pos - this.path[this.path.length - 1];
12360
12660
  if (dOff)
12361
- return this.parent.child(index).cut(0, dOff);
12362
- return index == 0 ? null : this.parent.child(index - 1);
12661
+ return this.parent.child(index2).cut(0, dOff);
12662
+ return index2 == 0 ? null : this.parent.child(index2 - 1);
12363
12663
  }
12364
12664
  /**
12365
12665
  Get the position at the given index in the parent node at the
12366
12666
  given depth (which defaults to `this.depth`).
12367
12667
  */
12368
- posAtIndex(index, depth) {
12668
+ posAtIndex(index2, depth) {
12369
12669
  depth = this.resolveDepth(depth);
12370
12670
  let node = this.path[depth * 3], pos = depth == 0 ? 0 : this.path[depth * 3 - 1] + 1;
12371
- for (let i = 0; i < index; i++)
12671
+ for (let i = 0; i < index2; i++)
12372
12672
  pos += node.child(i).nodeSize;
12373
12673
  return pos;
12374
12674
  }
@@ -12379,12 +12679,12 @@ class ResolvedPos {
12379
12679
  node after it (if any) are returned.
12380
12680
  */
12381
12681
  marks() {
12382
- let parent = this.parent, index = this.index();
12682
+ let parent = this.parent, index2 = this.index();
12383
12683
  if (parent.content.size == 0)
12384
12684
  return Mark.none;
12385
12685
  if (this.textOffset)
12386
- return parent.child(index).marks;
12387
- let main = parent.maybeChild(index - 1), other = parent.maybeChild(index);
12686
+ return parent.child(index2).marks;
12687
+ let main = parent.maybeChild(index2 - 1), other = parent.maybeChild(index2);
12388
12688
  if (!main) {
12389
12689
  let tmp = main;
12390
12690
  main = other;
@@ -12477,12 +12777,12 @@ class ResolvedPos {
12477
12777
  let path = [];
12478
12778
  let start = 0, parentOffset = pos;
12479
12779
  for (let node = doc2; ; ) {
12480
- let { index, offset } = node.content.findIndex(parentOffset);
12780
+ let { index: index2, offset } = node.content.findIndex(parentOffset);
12481
12781
  let rem = parentOffset - offset;
12482
- path.push(node, index, start + offset);
12782
+ path.push(node, index2, start + offset);
12483
12783
  if (!rem)
12484
12784
  break;
12485
- node = node.child(index);
12785
+ node = node.child(index2);
12486
12786
  if (node.isText)
12487
12787
  break;
12488
12788
  parentOffset = rem - 1;
@@ -12595,14 +12895,14 @@ let Node$1 = class Node2 {
12595
12895
  Get the child node at the given index. Raises an error when the
12596
12896
  index is out of range.
12597
12897
  */
12598
- child(index) {
12599
- return this.content.child(index);
12898
+ child(index2) {
12899
+ return this.content.child(index2);
12600
12900
  }
12601
12901
  /**
12602
12902
  Get the child node at the given index, if it exists.
12603
12903
  */
12604
- maybeChild(index) {
12605
- return this.content.maybeChild(index);
12904
+ maybeChild(index2) {
12905
+ return this.content.maybeChild(index2);
12606
12906
  }
12607
12907
  /**
12608
12908
  Call `f` for every child node, passing the node, its offset
@@ -12737,8 +13037,8 @@ let Node$1 = class Node2 {
12737
13037
  */
12738
13038
  nodeAt(pos) {
12739
13039
  for (let node = this; ; ) {
12740
- let { index, offset } = node.content.findIndex(pos);
12741
- node = node.maybeChild(index);
13040
+ let { index: index2, offset } = node.content.findIndex(pos);
13041
+ node = node.maybeChild(index2);
12742
13042
  if (!node)
12743
13043
  return null;
12744
13044
  if (offset == pos || node.isText)
@@ -12752,8 +13052,8 @@ let Node$1 = class Node2 {
12752
13052
  node.
12753
13053
  */
12754
13054
  childAfter(pos) {
12755
- let { index, offset } = this.content.findIndex(pos);
12756
- return { node: this.content.maybeChild(index), index, offset };
13055
+ let { index: index2, offset } = this.content.findIndex(pos);
13056
+ return { node: this.content.maybeChild(index2), index: index2, offset };
12757
13057
  }
12758
13058
  /**
12759
13059
  Find the (direct) child node before the given offset, if any,
@@ -12763,11 +13063,11 @@ let Node$1 = class Node2 {
12763
13063
  childBefore(pos) {
12764
13064
  if (pos == 0)
12765
13065
  return { node: null, index: 0, offset: 0 };
12766
- let { index, offset } = this.content.findIndex(pos);
13066
+ let { index: index2, offset } = this.content.findIndex(pos);
12767
13067
  if (offset < pos)
12768
- return { node: this.content.child(index), index, offset };
12769
- let node = this.content.child(index - 1);
12770
- return { node, index: index - 1, offset: offset - node.nodeSize };
13068
+ return { node: this.content.child(index2), index: index2, offset };
13069
+ let node = this.content.child(index2 - 1);
13070
+ return { node, index: index2 - 1, offset: offset - node.nodeSize };
12771
13071
  }
12772
13072
  /**
12773
13073
  Resolve the given position in the document, returning an
@@ -12859,8 +13159,8 @@ let Node$1 = class Node2 {
12859
13159
  /**
12860
13160
  Get the content match in this node at the given index.
12861
13161
  */
12862
- contentMatchAt(index) {
12863
- let match = this.type.contentMatch.matchFragment(this.content, 0, index);
13162
+ contentMatchAt(index2) {
13163
+ let match = this.type.contentMatch.matchFragment(this.content, 0, index2);
12864
13164
  if (!match)
12865
13165
  throw new Error("Called contentMatchAt on a node with invalid content");
12866
13166
  return match;
@@ -14262,12 +14562,12 @@ class ParseContext {
14262
14562
  // whole node, if not given). If `sync` is passed, use it to
14263
14563
  // synchronize after every block element.
14264
14564
  addAll(parent, marks, startIndex, endIndex) {
14265
- let index = startIndex || 0;
14266
- for (let dom = startIndex ? parent.childNodes[startIndex] : parent.firstChild, end = endIndex == null ? null : parent.childNodes[endIndex]; dom != end; dom = dom.nextSibling, ++index) {
14267
- this.findAtPoint(parent, index);
14565
+ let index2 = startIndex || 0;
14566
+ for (let dom = startIndex ? parent.childNodes[startIndex] : parent.firstChild, end = endIndex == null ? null : parent.childNodes[endIndex]; dom != end; dom = dom.nextSibling, ++index2) {
14567
+ this.findAtPoint(parent, index2);
14268
14568
  this.addDOM(dom, marks);
14269
14569
  }
14270
- this.findAtPoint(parent, index);
14570
+ this.findAtPoint(parent, index2);
14271
14571
  }
14272
14572
  // Try to find a way to fit the given node type into the current
14273
14573
  // context. May add intermediate wrappers and/or leave non-solid
@@ -15043,18 +15343,6 @@ const DEFAULT_CUSTOM_XML = {
15043
15343
  }
15044
15344
  ]
15045
15345
  };
15046
- const SETTINGS_CUSTOM_XML = {
15047
- elements: [
15048
- {
15049
- type: "element",
15050
- name: "w:settings",
15051
- attributes: {
15052
- "xmlns:w": "http://schemas.openxmlformats.org/wordprocessingml/2006/main"
15053
- },
15054
- elements: []
15055
- }
15056
- ]
15057
- };
15058
15346
  const COMMENT_REF = {
15059
15347
  type: "element",
15060
15348
  name: "w:r",
@@ -16429,8 +16717,8 @@ const prepareCommentsXmlFilesForExport = ({ convertedXml, defs, commentsWithPara
16429
16717
  };
16430
16718
  const lower16 = 65535;
16431
16719
  const factor16 = Math.pow(2, 16);
16432
- function makeRecover(index, offset) {
16433
- return index + offset * factor16;
16720
+ function makeRecover(index2, offset) {
16721
+ return index2 + offset * factor16;
16434
16722
  }
16435
16723
  function recoverIndex(value) {
16436
16724
  return value & lower16;
@@ -16493,11 +16781,11 @@ class StepMap {
16493
16781
  @internal
16494
16782
  */
16495
16783
  recover(value) {
16496
- let diff = 0, index = recoverIndex(value);
16784
+ let diff = 0, index2 = recoverIndex(value);
16497
16785
  if (!this.inverted)
16498
- for (let i = 0; i < index; i++)
16786
+ for (let i = 0; i < index2; i++)
16499
16787
  diff += this.ranges[i * 3 + 2] - this.ranges[i * 3 + 1];
16500
- return this.ranges[index * 3] + diff + recoverOffset(value);
16788
+ return this.ranges[index2 * 3] + diff + recoverOffset(value);
16501
16789
  }
16502
16790
  mapResult(pos, assoc = 1) {
16503
16791
  return this._map(pos, assoc, false);
@@ -16534,14 +16822,14 @@ class StepMap {
16534
16822
  @internal
16535
16823
  */
16536
16824
  touches(pos, recover) {
16537
- let diff = 0, index = recoverIndex(recover);
16825
+ let diff = 0, index2 = recoverIndex(recover);
16538
16826
  let oldIndex = this.inverted ? 2 : 1, newIndex = this.inverted ? 1 : 2;
16539
16827
  for (let i = 0; i < this.ranges.length; i += 3) {
16540
16828
  let start = this.ranges[i] - (this.inverted ? diff : 0);
16541
16829
  if (start > pos)
16542
16830
  break;
16543
16831
  let oldSize = this.ranges[i + oldIndex], end = start + oldSize;
16544
- if (pos <= end && i == index * 3)
16832
+ if (pos <= end && i == index2 * 3)
16545
16833
  return true;
16546
16834
  diff += this.ranges[i + newIndex] - oldSize;
16547
16835
  }
@@ -17245,10 +17533,10 @@ function liftTarget(range2) {
17245
17533
  let content = parent.content.cutByIndex(range2.startIndex, range2.endIndex);
17246
17534
  for (let depth = range2.depth; ; --depth) {
17247
17535
  let node = range2.$from.node(depth);
17248
- let index = range2.$from.index(depth), endIndex = range2.$to.indexAfter(depth);
17249
- if (depth < range2.depth && node.canReplace(index, endIndex, content))
17536
+ let index2 = range2.$from.index(depth), endIndex = range2.$to.indexAfter(depth);
17537
+ if (depth < range2.depth && node.canReplace(index2, endIndex, content))
17250
17538
  return depth;
17251
- if (depth == 0 || node.type.spec.isolating || !canCut(node, index, endIndex))
17539
+ if (depth == 0 || node.type.spec.isolating || !canCut(node, index2, endIndex))
17252
17540
  break;
17253
17541
  }
17254
17542
  return null;
@@ -17369,8 +17657,8 @@ function replaceLinebreaks(tr, node, pos, mapFrom) {
17369
17657
  });
17370
17658
  }
17371
17659
  function canChangeType(doc2, pos, type2) {
17372
- let $pos = doc2.resolve(pos), index = $pos.index();
17373
- return $pos.parent.canReplaceWith(index, index + 1, type2);
17660
+ let $pos = doc2.resolve(pos), index2 = $pos.index();
17661
+ return $pos.parent.canReplaceWith(index2, index2 + 1, type2);
17374
17662
  }
17375
17663
  function setNodeMarkup(tr, pos, type2, attrs, marks) {
17376
17664
  let node = tr.doc.nodeAt(pos);
@@ -17391,20 +17679,20 @@ function canSplit(doc2, pos, depth = 1, typesAfter) {
17391
17679
  if (base < 0 || $pos.parent.type.spec.isolating || !$pos.parent.canReplace($pos.index(), $pos.parent.childCount) || !innerType.type.validContent($pos.parent.content.cutByIndex($pos.index(), $pos.parent.childCount)))
17392
17680
  return false;
17393
17681
  for (let d2 = $pos.depth - 1, i = depth - 2; d2 > base; d2--, i--) {
17394
- let node = $pos.node(d2), index2 = $pos.index(d2);
17682
+ let node = $pos.node(d2), index3 = $pos.index(d2);
17395
17683
  if (node.type.spec.isolating)
17396
17684
  return false;
17397
- let rest = node.content.cutByIndex(index2, node.childCount);
17685
+ let rest = node.content.cutByIndex(index3, node.childCount);
17398
17686
  let overrideChild = typesAfter && typesAfter[i + 1];
17399
17687
  if (overrideChild)
17400
17688
  rest = rest.replaceChild(0, overrideChild.type.create(overrideChild.attrs));
17401
17689
  let after = typesAfter && typesAfter[i] || node;
17402
- if (!node.canReplace(index2 + 1, node.childCount) || !after.type.validContent(rest))
17690
+ if (!node.canReplace(index3 + 1, node.childCount) || !after.type.validContent(rest))
17403
17691
  return false;
17404
17692
  }
17405
- let index = $pos.indexAfter(base);
17693
+ let index2 = $pos.indexAfter(base);
17406
17694
  let baseType = typesAfter && typesAfter[0];
17407
- return $pos.node(base).canReplaceWith(index, index, baseType ? baseType.type : $pos.node(base + 1).type);
17695
+ return $pos.node(base).canReplaceWith(index2, index2, baseType ? baseType.type : $pos.node(base + 1).type);
17408
17696
  }
17409
17697
  function split(tr, pos, depth = 1, typesAfter) {
17410
17698
  let $pos = tr.doc.resolve(pos), before = Fragment.empty, after = Fragment.empty;
@@ -17416,8 +17704,8 @@ function split(tr, pos, depth = 1, typesAfter) {
17416
17704
  tr.step(new ReplaceStep(pos, pos, new Slice(before.append(after), depth, depth), true));
17417
17705
  }
17418
17706
  function canJoin(doc2, pos) {
17419
- let $pos = doc2.resolve(pos), index = $pos.index();
17420
- return joinable($pos.nodeBefore, $pos.nodeAfter) && $pos.parent.canReplace(index, index + 1);
17707
+ let $pos = doc2.resolve(pos), index2 = $pos.index();
17708
+ return joinable($pos.nodeBefore, $pos.nodeAfter) && $pos.parent.canReplace(index2, index2 + 1);
17421
17709
  }
17422
17710
  function canAppendWithSubstitutedLinebreaks(a, b2) {
17423
17711
  if (!b2.content.size)
@@ -17441,19 +17729,19 @@ function joinable(a, b2) {
17441
17729
  function joinPoint(doc2, pos, dir = -1) {
17442
17730
  let $pos = doc2.resolve(pos);
17443
17731
  for (let d2 = $pos.depth; ; d2--) {
17444
- let before, after, index = $pos.index(d2);
17732
+ let before, after, index2 = $pos.index(d2);
17445
17733
  if (d2 == $pos.depth) {
17446
17734
  before = $pos.nodeBefore;
17447
17735
  after = $pos.nodeAfter;
17448
17736
  } else if (dir > 0) {
17449
17737
  before = $pos.node(d2 + 1);
17450
- index++;
17451
- after = $pos.node(d2).maybeChild(index);
17738
+ index2++;
17739
+ after = $pos.node(d2).maybeChild(index2);
17452
17740
  } else {
17453
- before = $pos.node(d2).maybeChild(index - 1);
17741
+ before = $pos.node(d2).maybeChild(index2 - 1);
17454
17742
  after = $pos.node(d2 + 1);
17455
17743
  }
17456
- if (before && !before.isTextblock && joinable(before, after) && $pos.node(d2).canReplace(index, index + 1))
17744
+ if (before && !before.isTextblock && joinable(before, after) && $pos.node(d2).canReplace(index2, index2 + 1))
17457
17745
  return pos;
17458
17746
  if (d2 == 0)
17459
17747
  break;
@@ -17493,18 +17781,18 @@ function insertPoint(doc2, pos, nodeType) {
17493
17781
  return pos;
17494
17782
  if ($pos.parentOffset == 0)
17495
17783
  for (let d2 = $pos.depth - 1; d2 >= 0; d2--) {
17496
- let index = $pos.index(d2);
17497
- if ($pos.node(d2).canReplaceWith(index, index, nodeType))
17784
+ let index2 = $pos.index(d2);
17785
+ if ($pos.node(d2).canReplaceWith(index2, index2, nodeType))
17498
17786
  return $pos.before(d2 + 1);
17499
- if (index > 0)
17787
+ if (index2 > 0)
17500
17788
  return null;
17501
17789
  }
17502
17790
  if ($pos.parentOffset == $pos.parent.content.size)
17503
17791
  for (let d2 = $pos.depth - 1; d2 >= 0; d2--) {
17504
- let index = $pos.indexAfter(d2);
17505
- if ($pos.node(d2).canReplaceWith(index, index, nodeType))
17792
+ let index2 = $pos.indexAfter(d2);
17793
+ if ($pos.node(d2).canReplaceWith(index2, index2, nodeType))
17506
17794
  return $pos.after(d2 + 1);
17507
- if (index < $pos.node(d2).childCount)
17795
+ if (index2 < $pos.node(d2).childCount)
17508
17796
  return null;
17509
17797
  }
17510
17798
  return null;
@@ -17771,11 +18059,11 @@ function closeNodeStart(node, openStart, openEnd) {
17771
18059
  return node.copy(frag);
17772
18060
  }
17773
18061
  function contentAfterFits($to, depth, type2, match, open) {
17774
- let node = $to.node(depth), index = open ? $to.indexAfter(depth) : $to.index(depth);
17775
- if (index == node.childCount && !type2.compatibleContent(node.type))
18062
+ let node = $to.node(depth), index2 = open ? $to.indexAfter(depth) : $to.index(depth);
18063
+ if (index2 == node.childCount && !type2.compatibleContent(node.type))
17776
18064
  return null;
17777
- let fit = match.fillBefore(node.content, true, index);
17778
- return fit && !invalidMarks(type2, node.content, index) ? fit : null;
18065
+ let fit = match.fillBefore(node.content, true, index2);
18066
+ return fit && !invalidMarks(type2, node.content, index2) ? fit : null;
17779
18067
  }
17780
18068
  function invalidMarks(type2, fragment, start) {
17781
18069
  for (let i = start; i < fragment.childCount; i++)
@@ -17833,8 +18121,8 @@ function replaceRange(tr, from, to, slice) {
17833
18121
  expand = false;
17834
18122
  targetDepth = -targetDepth;
17835
18123
  }
17836
- let parent = $from.node(targetDepth - 1), index = $from.index(targetDepth - 1);
17837
- if (parent.canReplaceWith(index, index, insert.type, insert.marks))
18124
+ let parent = $from.node(targetDepth - 1), index2 = $from.index(targetDepth - 1);
18125
+ if (parent.canReplaceWith(index2, index2, insert.type, insert.marks))
17838
18126
  return tr.replace($from.before(targetDepth), expand ? $to.after(targetDepth) : to, new Slice(closeFragment(slice.content, 0, slice.openStart, openDepth), openDepth, slice.openEnd));
17839
18127
  }
17840
18128
  }
@@ -18646,10 +18934,10 @@ const AllBookmark = {
18646
18934
  return new AllSelection(doc2);
18647
18935
  }
18648
18936
  };
18649
- function findSelectionIn(doc2, node, pos, index, dir, text = false) {
18937
+ function findSelectionIn(doc2, node, pos, index2, dir, text = false) {
18650
18938
  if (node.inlineContent)
18651
18939
  return TextSelection.create(doc2, pos);
18652
- for (let i = index - (dir > 0 ? 0 : 1); dir > 0 ? i < node.childCount : i >= 0; i += dir) {
18940
+ for (let i = index2 - (dir > 0 ? 0 : 1); dir > 0 ? i < node.childCount : i >= 0; i += dir) {
18653
18941
  let child = node.child(i);
18654
18942
  if (!child.isAtom) {
18655
18943
  let inner = findSelectionIn(doc2, child, pos + dir, dir < 0 ? child.childCount : 0, dir, text);
@@ -19250,10 +19538,10 @@ function handleListNodes(params, node) {
19250
19538
  const firstElement = innerParagraph.content[0];
19251
19539
  firstElement?.marks?.find((mark) => mark.type === "textStyle");
19252
19540
  attrs.indent = listpPrs?.indent;
19253
- const processedContents = listContents.map((el, index) => {
19541
+ const processedContents = listContents.map((el, index2) => {
19254
19542
  const { attrs: elementAttrs } = el;
19255
19543
  const { indent, textIndent, paragraphProperties, ...rest } = elementAttrs;
19256
- if (index === 0 && !attrs.indent) attrs.indent = indent;
19544
+ if (index2 === 0 && !attrs.indent) attrs.indent = indent;
19257
19545
  return {
19258
19546
  ...el,
19259
19547
  attrs: rest
@@ -22981,16 +23269,16 @@ function translateChildNodes(params) {
22981
23269
  if (!nodes) return [];
22982
23270
  const translatedNodes = [];
22983
23271
  const hyperlinkGroup = [];
22984
- let index = 0;
22985
- while (index < nodes.length) {
22986
- const node = nodes[index];
23272
+ let index2 = 0;
23273
+ while (index2 < nodes.length) {
23274
+ const node = nodes[index2];
22987
23275
  const linkMark = _isLinkNode(node);
22988
23276
  if (linkMark) {
22989
23277
  hyperlinkGroup.push(node);
22990
- const nextNode = index + 1 < nodes.length ? nodes[index + 1] : null;
23278
+ const nextNode = index2 + 1 < nodes.length ? nodes[index2 + 1] : null;
22991
23279
  const nextIsLink = _isLinkNode(nextNode, linkMark);
22992
23280
  if (nextIsLink) {
22993
- index++;
23281
+ index2++;
22994
23282
  continue;
22995
23283
  } else {
22996
23284
  let translatedLinkGroup = exportSchemaToJson({
@@ -23001,14 +23289,14 @@ function translateChildNodes(params) {
23001
23289
  if (translatedLinkGroup instanceof Array) translatedNodes.push(...translatedLinkGroup);
23002
23290
  else translatedNodes.push(translatedLinkGroup);
23003
23291
  hyperlinkGroup.length = 0;
23004
- index++;
23292
+ index2++;
23005
23293
  continue;
23006
23294
  }
23007
23295
  }
23008
23296
  let translatedNode = exportSchemaToJson({ ...params, node });
23009
23297
  if (translatedNode instanceof Array) translatedNodes.push(...translatedNode);
23010
23298
  else translatedNodes.push(translatedNode);
23011
- index++;
23299
+ index2++;
23012
23300
  }
23013
23301
  return translatedNodes.filter((n) => n);
23014
23302
  }
@@ -29056,12 +29344,12 @@ function getHTMLFromFragment(fragment, schema) {
29056
29344
  const getTextContentFromNodes = ($from, maxMatch = 500) => {
29057
29345
  let textBefore = "";
29058
29346
  const sliceEndPos = $from.parentOffset;
29059
- $from.parent.nodesBetween(Math.max(0, sliceEndPos - maxMatch), sliceEndPos, (node, pos, parent, index) => {
29347
+ $from.parent.nodesBetween(Math.max(0, sliceEndPos - maxMatch), sliceEndPos, (node, pos, parent, index2) => {
29060
29348
  const chunk = node.type.spec.toText?.({
29061
29349
  node,
29062
29350
  pos,
29063
29351
  parent,
29064
- index
29352
+ index: index2
29065
29353
  }) || node.textContent || "%leaf%";
29066
29354
  textBefore += node.isAtom && !node.isText ? chunk : chunk.slice(0, Math.max(0, sliceEndPos - pos));
29067
29355
  });
@@ -29291,12 +29579,12 @@ function extractAndRemoveConditionalPrefix(item) {
29291
29579
  let fontFamily = null;
29292
29580
  let fontSize = null;
29293
29581
  let start = -1, end = -1;
29294
- nodes.forEach((node, index) => {
29582
+ nodes.forEach((node, index2) => {
29295
29583
  if (node.nodeType === Node.COMMENT_NODE && node.nodeValue.includes("[if !supportLists]")) {
29296
- start = index;
29584
+ start = index2;
29297
29585
  }
29298
29586
  if (start !== -1 && node.nodeType === Node.COMMENT_NODE && node.nodeValue.includes("[endif]")) {
29299
- end = index;
29587
+ end = index2;
29300
29588
  }
29301
29589
  });
29302
29590
  if (start !== -1 && end !== -1) {
@@ -29434,16 +29722,16 @@ function unflattenListsInHtml(html) {
29434
29722
  const allNodes = [...doc2.body.children];
29435
29723
  const listSequences = [];
29436
29724
  let currentSequence = null;
29437
- allNodes.forEach((node, index) => {
29725
+ allNodes.forEach((node, index2) => {
29438
29726
  const isFlattenList = node.tagName && (node.tagName === "OL" || node.tagName === "UL") && node.hasAttribute("data-list-id");
29439
29727
  if (isFlattenList) {
29440
29728
  const listId = node.getAttribute("data-list-id");
29441
29729
  if (currentSequence && currentSequence.id === listId) {
29442
- currentSequence.lists.push({ element: node, index });
29730
+ currentSequence.lists.push({ element: node, index: index2 });
29443
29731
  } else {
29444
29732
  currentSequence = {
29445
29733
  id: listId,
29446
- lists: [{ element: node, index }]
29734
+ lists: [{ element: node, index: index2 }]
29447
29735
  };
29448
29736
  listSequences.push(currentSequence);
29449
29737
  }
@@ -29623,8 +29911,8 @@ function mergeSeparateLists(container) {
29623
29911
  const hasStartAttr = rootLevelLists.some((list) => list.getAttribute("start") !== null);
29624
29912
  if (hasStartAttr) {
29625
29913
  const listsWithStartAttr = rootLevelLists.filter((list) => list.getAttribute("start") !== null);
29626
- for (let [index, item] of listsWithStartAttr.entries()) {
29627
- if (item.getAttribute("start") === (index + 2).toString()) {
29914
+ for (let [index2, item] of listsWithStartAttr.entries()) {
29915
+ if (item.getAttribute("start") === (index2 + 2).toString()) {
29628
29916
  mainList.append(...item.childNodes);
29629
29917
  item.remove();
29630
29918
  }
@@ -29815,10 +30103,10 @@ function handleHtmlPaste(html, editor, source) {
29815
30103
  dispatch(tr);
29816
30104
  } else if (isInParagraph) {
29817
30105
  const allContent = [];
29818
- doc2.content.forEach((node, index) => {
30106
+ doc2.content.forEach((node, index2) => {
29819
30107
  if (node.type.name === "paragraph") {
29820
30108
  allContent.push(...node.content.content);
29821
- if (index < doc2.content.childCount - 1) {
30109
+ if (index2 < doc2.content.childCount - 1) {
29822
30110
  allContent.push(editor.schema.text("\n"));
29823
30111
  }
29824
30112
  }
@@ -29946,10 +30234,10 @@ function requireHe() {
29946
30234
  return hasOwnProperty.call(object2, propertyName);
29947
30235
  };
29948
30236
  var contains = function(array, value) {
29949
- var index = -1;
30237
+ var index2 = -1;
29950
30238
  var length = array.length;
29951
- while (++index < length) {
29952
- if (array[index] == value) {
30239
+ while (++index2 < length) {
30240
+ if (array[index2] == value) {
29953
30241
  return true;
29954
30242
  }
29955
30243
  }
@@ -30147,7 +30435,7 @@ function requireHe() {
30147
30435
  return he$2.exports;
30148
30436
  }
30149
30437
  var heExports = requireHe();
30150
- const he = /* @__PURE__ */ getDefaultExportFromCjs$1(heExports);
30438
+ const he = /* @__PURE__ */ getDefaultExportFromCjs$2(heExports);
30151
30439
  function translateFieldAnnotation(params) {
30152
30440
  const { node, isFinalDoc, fieldsHighlightColor } = params;
30153
30441
  const { attrs = {} } = node;
@@ -31541,11 +31829,11 @@ function translateList(params) {
31541
31829
  let outputNode = exportSchemaToJson({ ...params, node: collapsedParagraphNode });
31542
31830
  if (Array.isArray(outputNode) && params.isFinalDoc) {
31543
31831
  const parsedElements = [];
31544
- outputNode?.forEach((node2, index) => {
31832
+ outputNode?.forEach((node2, index2) => {
31545
31833
  if (node2?.elements) {
31546
31834
  const runs = node2.elements?.filter((n) => n.name === "w:r");
31547
31835
  parsedElements.push(...runs);
31548
- if (node2.name === "w:p" && index < outputNode.length - 1) {
31836
+ if (node2.name === "w:p" && index2 < outputNode.length - 1) {
31549
31837
  parsedElements.push({
31550
31838
  name: "w:br"
31551
31839
  });
@@ -31566,7 +31854,7 @@ function translateList(params) {
31566
31854
  const foundRun = sdtContent.elements?.find((el) => el.name === "w:r");
31567
31855
  if (sdtContent && sdtContent.elements && !foundRun) {
31568
31856
  const parsedElements = [];
31569
- sdtContent.elements.forEach((element, index) => {
31857
+ sdtContent.elements.forEach((element, index2) => {
31570
31858
  if (element.name === "w:rPr" && element.elements?.length) {
31571
31859
  parsedElements.push(element);
31572
31860
  }
@@ -31574,7 +31862,7 @@ function translateList(params) {
31574
31862
  if (runs && runs.length) {
31575
31863
  parsedElements.push(...runs);
31576
31864
  }
31577
- if (element.name === "w:p" && index < sdtContent.elements.length - 1) {
31865
+ if (element.name === "w:p" && index2 < sdtContent.elements.length - 1) {
31578
31866
  parsedElements.push({
31579
31867
  name: "w:br"
31580
31868
  });
@@ -31611,9 +31899,9 @@ const convertMultipleListItemsIntoSingleNode = (listItem) => {
31611
31899
  ...firstParagraph,
31612
31900
  content: []
31613
31901
  };
31614
- content.forEach((item, index) => {
31902
+ content.forEach((item, index2) => {
31615
31903
  if (item.type === "paragraph") {
31616
- if (index > 0) {
31904
+ if (index2 > 0) {
31617
31905
  collapsedParagraph.content.push({
31618
31906
  type: "lineBreak",
31619
31907
  attrs: {},
@@ -31627,9 +31915,9 @@ const convertMultipleListItemsIntoSingleNode = (listItem) => {
31627
31915
  collapsedParagraph.content.push(item);
31628
31916
  }
31629
31917
  });
31630
- collapsedParagraph.content = collapsedParagraph.content.filter((node, index, nodes) => {
31918
+ collapsedParagraph.content = collapsedParagraph.content.filter((node, index2, nodes) => {
31631
31919
  if (!isLineBreakOnlyRun(node)) return true;
31632
- const prevNode = nodes[index - 1];
31920
+ const prevNode = nodes[index2 - 1];
31633
31921
  return !(prevNode && isLineBreakOnlyRun(prevNode));
31634
31922
  });
31635
31923
  return collapsedParagraph;
@@ -33312,7 +33600,7 @@ const createDocumentJson = (docx, converter, editor) => {
33312
33600
  fileType: filePath.split(".").pop()
33313
33601
  };
33314
33602
  });
33315
- converter.telemetry.trackFileStructure(
33603
+ const trackStructure = (documentIdentifier = null) => converter.telemetry.trackFileStructure(
33316
33604
  {
33317
33605
  totalFiles: files.length,
33318
33606
  maxDepth: Math.max(...files.map((f) => f.fileDepth)),
@@ -33320,9 +33608,20 @@ const createDocumentJson = (docx, converter, editor) => {
33320
33608
  files
33321
33609
  },
33322
33610
  converter.fileSource,
33323
- converter.documentId,
33611
+ converter.documentGuid ?? converter.documentId ?? null,
33612
+ documentIdentifier ?? converter.documentId ?? null,
33324
33613
  converter.documentInternalId
33325
33614
  );
33615
+ try {
33616
+ const identifierResult = converter.getDocumentIdentifier?.();
33617
+ if (identifierResult && typeof identifierResult.then === "function") {
33618
+ identifierResult.then(trackStructure).catch(() => trackStructure());
33619
+ } else {
33620
+ trackStructure(identifierResult);
33621
+ }
33622
+ } catch (error) {
33623
+ trackStructure();
33624
+ }
33326
33625
  }
33327
33626
  const nodeListHandler = defaultNodeListHandler();
33328
33627
  const bodyNode = json.elements[0].elements.find((el) => el.name === "w:body");
@@ -33399,15 +33698,15 @@ const defaultNodeListHandler = () => {
33399
33698
  };
33400
33699
  };
33401
33700
  const createNodeListHandler = (nodeHandlers) => {
33402
- const getSafeElementContext = (elements, index, processedNode, path) => {
33403
- if (!elements || index < 0 || index >= elements.length) {
33701
+ const getSafeElementContext = (elements, index2, processedNode, path) => {
33702
+ if (!elements || index2 < 0 || index2 >= elements.length) {
33404
33703
  return {
33405
- elementIndex: index,
33704
+ elementIndex: index2,
33406
33705
  error: "index_out_of_bounds",
33407
33706
  arrayLength: elements?.length
33408
33707
  };
33409
33708
  }
33410
- const element = elements[index];
33709
+ const element = elements[index2];
33411
33710
  return {
33412
33711
  elementName: element?.name,
33413
33712
  attributes: processedNode?.attrs,
@@ -33433,9 +33732,9 @@ const createNodeListHandler = (nodeHandlers) => {
33433
33732
  if (!filteredElements.length) return [];
33434
33733
  const processedElements = [];
33435
33734
  try {
33436
- for (let index = 0; index < filteredElements.length; index++) {
33735
+ for (let index2 = 0; index2 < filteredElements.length; index2++) {
33437
33736
  try {
33438
- const nodesToHandle = filteredElements.slice(index);
33737
+ const nodesToHandle = filteredElements.slice(index2);
33439
33738
  if (!nodesToHandle || nodesToHandle.length === 0) {
33440
33739
  continue;
33441
33740
  }
@@ -33459,7 +33758,7 @@ const createNodeListHandler = (nodeHandlers) => {
33459
33758
  );
33460
33759
  const context = getSafeElementContext(
33461
33760
  filteredElements,
33462
- index,
33761
+ index2,
33463
33762
  nodes[0],
33464
33763
  `/word/${filename || "document.xml"}`
33465
33764
  );
@@ -33481,7 +33780,7 @@ const createNodeListHandler = (nodeHandlers) => {
33481
33780
  }
33482
33781
  }
33483
33782
  if (consumed > 0) {
33484
- index += consumed - 1;
33783
+ index2 += consumed - 1;
33485
33784
  }
33486
33785
  if (nodes) {
33487
33786
  nodes.forEach((node) => {
@@ -33873,6 +34172,9 @@ const _SuperConverter = class _SuperConverter {
33873
34172
  this.documentInternalId = null;
33874
34173
  this.fileSource = params?.fileSource || null;
33875
34174
  this.documentId = params?.documentId || null;
34175
+ this.documentGuid = null;
34176
+ this.documentHash = null;
34177
+ this.documentModified = false;
33876
34178
  if (this.docx.length || this.xml) this.parseFromXml();
33877
34179
  }
33878
34180
  static getFontTableEntry(docx, fontName) {
@@ -33920,50 +34222,177 @@ const _SuperConverter = class _SuperConverter {
33920
34222
  this.initialJSON = this.convertedXml["word/document.xml"];
33921
34223
  if (!this.initialJSON) this.initialJSON = this.parseXmlToJson(this.xml);
33922
34224
  this.declaration = this.initialJSON?.declaration;
34225
+ this.resolveDocumentGuid();
33923
34226
  }
33924
34227
  parseXmlToJson(xml) {
33925
34228
  const newXml = xml.replace(/(<w:t xml:space="preserve">)(\s+)(<\/w:t>)/g, "$1[[sdspace]]$2[[sdspace]]$3");
33926
34229
  return JSON.parse(xmljs.xml2json(newXml, null, 2));
33927
34230
  }
33928
- static getStoredSuperdocVersion(docx) {
34231
+ /**
34232
+ * Generic method to get a stored custom property from docx
34233
+ * @static
34234
+ * @param {Array} docx - Array of docx file objects
34235
+ * @param {string} propertyName - Name of the property to retrieve
34236
+ * @returns {string|null} The property value or null if not found
34237
+ */
34238
+ static getStoredCustomProperty(docx, propertyName) {
33929
34239
  try {
33930
34240
  const customXml = docx.find((doc2) => doc2.name === "docProps/custom.xml");
33931
- if (!customXml) return;
34241
+ if (!customXml) return null;
33932
34242
  const converter = new _SuperConverter();
33933
34243
  const content = customXml.content;
33934
34244
  const contentJson = converter.parseXmlToJson(content);
33935
34245
  const properties = contentJson.elements.find((el) => el.name === "Properties");
33936
- if (!properties.elements) return;
33937
- const superdocVersion = properties.elements.find(
33938
- (el) => el.name === "property" && el.attributes.name === "SuperdocVersion"
33939
- );
33940
- if (!superdocVersion) return;
33941
- const version = superdocVersion.elements[0].elements[0].text;
33942
- return version;
34246
+ if (!properties.elements) return null;
34247
+ const property = properties.elements.find((el) => el.name === "property" && el.attributes.name === propertyName);
34248
+ if (!property) return null;
34249
+ return property.elements[0].elements[0].text;
33943
34250
  } catch (e) {
33944
- console.warn("Error getting Superdoc version", e);
33945
- return;
34251
+ console.warn(`Error getting custom property ${propertyName}:`, e);
34252
+ return null;
33946
34253
  }
33947
34254
  }
33948
- static updateDocumentVersion(docx = this.convertedXml, version = "0.22.0") {
34255
+ /**
34256
+ * Generic method to set a stored custom property in docx
34257
+ * @static
34258
+ * @param {Object} docx - The docx object to store the property in
34259
+ * @param {string} propertyName - Name of the property
34260
+ * @param {string|Function} value - Value or function that returns the value
34261
+ * @param {boolean} preserveExisting - If true, won't overwrite existing values
34262
+ * @returns {string} The stored value
34263
+ */
34264
+ static setStoredCustomProperty(docx, propertyName, value, preserveExisting = false) {
33949
34265
  const customLocation = "docProps/custom.xml";
33950
- if (!docx[customLocation]) {
33951
- docx[customLocation] = generateCustomXml();
33952
- }
33953
- const customXml = docx["docProps/custom.xml"];
33954
- if (!customXml) return;
33955
- const properties = customXml.elements.find((el) => el.name === "Properties");
34266
+ if (!docx[customLocation]) docx[customLocation] = generateCustomXml();
34267
+ const customXml = docx[customLocation];
34268
+ const properties = customXml.elements?.find((el) => el.name === "Properties");
34269
+ if (!properties) return null;
33956
34270
  if (!properties.elements) properties.elements = [];
33957
- const superdocVersion = properties.elements.find(
33958
- (el) => el.name === "property" && el.attributes.name === "SuperdocVersion"
33959
- );
33960
- if (!superdocVersion) {
33961
- const newCustomXml = generateSuperdocVersion();
33962
- properties.elements.push(newCustomXml);
34271
+ let property = properties.elements.find((el) => el.name === "property" && el.attributes.name === propertyName);
34272
+ if (property && preserveExisting) {
34273
+ return property.elements[0].elements[0].text;
34274
+ }
34275
+ const finalValue = typeof value === "function" ? value() : value;
34276
+ if (!property) {
34277
+ const existingPids = properties.elements.filter((el) => el.attributes?.pid).map((el) => parseInt(el.attributes.pid, 10)).filter(Number.isInteger);
34278
+ const pid = existingPids.length > 0 ? Math.max(...existingPids) + 1 : 2;
34279
+ property = {
34280
+ type: "element",
34281
+ name: "property",
34282
+ attributes: {
34283
+ name: propertyName,
34284
+ fmtid: "{D5CDD505-2E9C-101B-9397-08002B2CF9AE}",
34285
+ pid
34286
+ },
34287
+ elements: [
34288
+ {
34289
+ type: "element",
34290
+ name: "vt:lpwstr",
34291
+ elements: [
34292
+ {
34293
+ type: "text",
34294
+ text: finalValue
34295
+ }
34296
+ ]
34297
+ }
34298
+ ]
34299
+ };
34300
+ properties.elements.push(property);
33963
34301
  } else {
33964
- superdocVersion.elements[0].elements[0].elements[0].text = version;
34302
+ property.elements[0].elements[0].text = finalValue;
34303
+ }
34304
+ return finalValue;
34305
+ }
34306
+ static getStoredSuperdocVersion(docx) {
34307
+ return _SuperConverter.getStoredCustomProperty(docx, "SuperdocVersion");
34308
+ }
34309
+ static setStoredSuperdocVersion(docx = this.convertedXml, version = "0.22.0") {
34310
+ return _SuperConverter.setStoredCustomProperty(docx, "SuperdocVersion", version, false);
34311
+ }
34312
+ /**
34313
+ * Get document GUID from docx files (static method)
34314
+ * @static
34315
+ * @param {Array} docx - Array of docx file objects
34316
+ * @returns {string|null} The document GUID
34317
+ */
34318
+ static extractDocumentGuid(docx) {
34319
+ try {
34320
+ const settingsXml = docx.find((doc2) => doc2.name === "word/settings.xml");
34321
+ if (!settingsXml) return null;
34322
+ const converter = new _SuperConverter();
34323
+ const settingsJson = converter.parseXmlToJson(settingsXml.content);
34324
+ const settings = settingsJson.elements?.[0];
34325
+ if (!settings) return null;
34326
+ const docIdElement = settings.elements?.find((el) => el.name === "w15:docId");
34327
+ if (docIdElement?.attributes?.["w15:val"]) {
34328
+ return docIdElement.attributes["w15:val"].replace(/[{}]/g, "");
34329
+ }
34330
+ } catch {
33965
34331
  }
33966
- return docx;
34332
+ return _SuperConverter.getStoredCustomProperty(docx, "DocumentGuid");
34333
+ }
34334
+ /**
34335
+ * Get the permanent document GUID
34336
+ * @returns {string|null} The document GUID (only for modified documents)
34337
+ */
34338
+ getDocumentGuid() {
34339
+ return this.documentGuid;
34340
+ }
34341
+ /**
34342
+ * Get the SuperDoc version for this converter instance
34343
+ * @returns {string|null} The SuperDoc version or null if not available
34344
+ */
34345
+ getSuperdocVersion() {
34346
+ if (this.docx) {
34347
+ return _SuperConverter.getStoredSuperdocVersion(this.docx);
34348
+ }
34349
+ return null;
34350
+ }
34351
+ /**
34352
+ * Resolve existing document GUID (synchronous)
34353
+ */
34354
+ resolveDocumentGuid() {
34355
+ const microsoftGuid = this.getMicrosoftDocId();
34356
+ if (microsoftGuid) {
34357
+ this.documentGuid = microsoftGuid;
34358
+ return;
34359
+ }
34360
+ const customGuid = _SuperConverter.getStoredCustomProperty(this.docx, "DocumentGuid");
34361
+ if (customGuid) {
34362
+ this.documentGuid = customGuid;
34363
+ }
34364
+ }
34365
+ /**
34366
+ * Get Microsoft's docId from settings.xml (READ ONLY)
34367
+ */
34368
+ getMicrosoftDocId() {
34369
+ this.getDocumentInternalId();
34370
+ if (this.documentInternalId) {
34371
+ return this.documentInternalId.replace(/[{}]/g, "");
34372
+ }
34373
+ return null;
34374
+ }
34375
+ /**
34376
+ * Get document identifier (GUID or hash) - async for lazy hash generation
34377
+ */
34378
+ async getDocumentIdentifier() {
34379
+ if (this.documentGuid) {
34380
+ return this.documentGuid;
34381
+ }
34382
+ if (!this.documentHash && this.fileSource) {
34383
+ this.documentHash = await __privateMethod(this, _SuperConverter_instances, generateDocumentHash_fn).call(this);
34384
+ }
34385
+ return this.documentHash;
34386
+ }
34387
+ /**
34388
+ * Promote from hash to GUID on first edit
34389
+ */
34390
+ promoteToGuid() {
34391
+ if (this.documentGuid) return this.documentGuid;
34392
+ this.documentGuid = this.getMicrosoftDocId() || v4();
34393
+ this.documentModified = true;
34394
+ this.documentHash = null;
34395
+ return this.documentGuid;
33967
34396
  }
33968
34397
  getDocumentDefaultStyles() {
33969
34398
  const styles = this.convertedXml["word/styles.xml"];
@@ -34052,20 +34481,14 @@ const _SuperConverter = class _SuperConverter {
34052
34481
  getDocumentInternalId() {
34053
34482
  const settingsLocation = "word/settings.xml";
34054
34483
  if (!this.convertedXml[settingsLocation]) {
34055
- this.convertedXml[settingsLocation] = SETTINGS_CUSTOM_XML;
34484
+ return;
34056
34485
  }
34057
- const settings = Object.assign({}, this.convertedXml[settingsLocation]);
34058
- if (!settings.elements[0]?.elements?.length) {
34059
- const idElement = this.createDocumentIdElement(settings);
34060
- settings.elements[0].elements = [idElement];
34061
- if (!settings.elements[0].attributes["xmlns:w15"]) {
34062
- settings.elements[0].attributes["xmlns:w15"] = "http://schemas.microsoft.com/office/word/2012/wordml";
34063
- }
34064
- this.convertedXml[settingsLocation] = settings;
34486
+ const settings = this.convertedXml[settingsLocation];
34487
+ if (!settings.elements?.[0]?.elements?.length) {
34065
34488
  return;
34066
34489
  }
34067
34490
  const w15DocId = settings.elements[0].elements.find((el) => el.name === "w15:docId");
34068
- this.documentInternalId = w15DocId?.attributes["w15:val"];
34491
+ this.documentInternalId = w15DocId?.attributes?.["w15:val"];
34069
34492
  }
34070
34493
  createDocumentIdElement() {
34071
34494
  const docId = v4().toUpperCase();
@@ -34120,7 +34543,7 @@ const _SuperConverter = class _SuperConverter {
34120
34543
  async exportToDocx(jsonData, editorSchema, documentMedia, isFinalDoc = false, commentsExportType, comments = [], editor, exportJsonOnly = false, fieldsHighlightColor) {
34121
34544
  const commentsWithParaIds = comments.map((c) => prepareCommentParaIds(c));
34122
34545
  const commentDefinitions = commentsWithParaIds.map(
34123
- (c, index) => getCommentDefinition(c, index, commentsWithParaIds, editor)
34546
+ (c, index2) => getCommentDefinition(c, index2, commentsWithParaIds, editor)
34124
34547
  );
34125
34548
  const { result, params } = this.exportToXmlJson({
34126
34549
  data: jsonData,
@@ -34154,7 +34577,13 @@ const _SuperConverter = class _SuperConverter {
34154
34577
  this.convertedXml = { ...this.convertedXml, ...updatedXml };
34155
34578
  const headFootRels = __privateMethod(this, _SuperConverter_instances, exportProcessHeadersFooters_fn).call(this, { isFinalDoc });
34156
34579
  __privateMethod(this, _SuperConverter_instances, exportProcessNewRelationships_fn).call(this, [...params.relationships, ...commentsRels, ...headFootRels]);
34157
- storeSuperdocVersion(this.convertedXml);
34580
+ _SuperConverter.setStoredSuperdocVersion(this.convertedXml);
34581
+ if (this.documentModified || this.documentGuid) {
34582
+ if (!this.documentGuid) {
34583
+ this.documentGuid = this.getMicrosoftDocId() || v4();
34584
+ }
34585
+ _SuperConverter.setStoredCustomProperty(this.convertedXml, "DocumentGuid", this.documentGuid, true);
34586
+ }
34158
34587
  __privateMethod(this, _SuperConverter_instances, exportNumberingFile_fn).call(this, params);
34159
34588
  return xml;
34160
34589
  }
@@ -34189,8 +34618,38 @@ const _SuperConverter = class _SuperConverter {
34189
34618
  });
34190
34619
  return { result, params };
34191
34620
  }
34621
+ // Deprecated methods for backward compatibility
34622
+ static getStoredSuperdocId(docx) {
34623
+ console.warn("getStoredSuperdocId is deprecated, use getDocumentGuid instead");
34624
+ return _SuperConverter.extractDocumentGuid(docx);
34625
+ }
34626
+ static updateDocumentVersion(docx, version) {
34627
+ console.warn("updateDocumentVersion is deprecated, use setStoredSuperdocVersion instead");
34628
+ return _SuperConverter.setStoredSuperdocVersion(docx, version);
34629
+ }
34192
34630
  };
34193
34631
  _SuperConverter_instances = new WeakSet();
34632
+ generateDocumentHash_fn = async function() {
34633
+ if (!this.fileSource) return `HASH-${Date.now()}`;
34634
+ try {
34635
+ let buffer2;
34636
+ if (Buffer2.isBuffer(this.fileSource)) {
34637
+ buffer2 = this.fileSource;
34638
+ } else if (this.fileSource instanceof ArrayBuffer) {
34639
+ buffer2 = Buffer2.from(this.fileSource);
34640
+ } else if (this.fileSource instanceof Blob || this.fileSource instanceof File) {
34641
+ const arrayBuffer = await this.fileSource.arrayBuffer();
34642
+ buffer2 = Buffer2.from(arrayBuffer);
34643
+ } else {
34644
+ return `HASH-${Date.now()}`;
34645
+ }
34646
+ const hash = index(buffer2);
34647
+ return `HASH-${hash.toString("hex").toUpperCase()}`;
34648
+ } catch (e) {
34649
+ console.warn("Could not generate document hash:", e);
34650
+ return `HASH-${Date.now()}`;
34651
+ }
34652
+ };
34194
34653
  exportNumberingFile_fn = function() {
34195
34654
  const numberingPath = "word/numbering.xml";
34196
34655
  let numberingXml = this.convertedXml[numberingPath];
@@ -34218,8 +34677,8 @@ exportProcessHeadersFooters_fn = function({ isFinalDoc = false }) {
34218
34677
  const relsData = this.convertedXml["word/_rels/document.xml.rels"];
34219
34678
  const relationships = relsData.elements.find((x) => x.name === "Relationships");
34220
34679
  const newDocRels = [];
34221
- Object.entries(this.headers).forEach(([id, header], index) => {
34222
- const fileName = relationships.elements.find((el) => el.attributes.Id === id)?.attributes.Target || `header${index + 1}.xml`;
34680
+ Object.entries(this.headers).forEach(([id, header], index2) => {
34681
+ const fileName = relationships.elements.find((el) => el.attributes.Id === id)?.attributes.Target || `header${index2 + 1}.xml`;
34223
34682
  const headerEditor = this.headerEditors.find((item) => item.id === id);
34224
34683
  if (!headerEditor) return;
34225
34684
  const { result, params } = this.exportToXmlJson({
@@ -34272,8 +34731,8 @@ exportProcessHeadersFooters_fn = function({ isFinalDoc = false }) {
34272
34731
  };
34273
34732
  }
34274
34733
  });
34275
- Object.entries(this.footers).forEach(([id, footer], index) => {
34276
- const fileName = relationships.elements.find((el) => el.attributes.Id === id)?.attributes.Target || `footer${index + 1}.xml`;
34734
+ Object.entries(this.footers).forEach(([id, footer], index2) => {
34735
+ const fileName = relationships.elements.find((el) => el.attributes.Id === id)?.attributes.Target || `footer${index2 + 1}.xml`;
34277
34736
  const footerEditor = this.footerEditors.find((item) => item.id === id);
34278
34737
  if (!footerEditor) return;
34279
34738
  const { result, params } = this.exportToXmlJson({
@@ -34414,52 +34873,9 @@ __publicField(_SuperConverter, "propertyTypes", Object.freeze({
34414
34873
  }));
34415
34874
  __publicField(_SuperConverter, "elements", /* @__PURE__ */ new Set(["w:document", "w:body", "w:p", "w:r", "w:t", "w:delText"]));
34416
34875
  let SuperConverter = _SuperConverter;
34417
- function storeSuperdocVersion(docx) {
34418
- const customLocation = "docProps/custom.xml";
34419
- if (!docx[customLocation]) docx[customLocation] = generateCustomXml();
34420
- const customXml = docx[customLocation];
34421
- const properties = customXml.elements.find((el) => el.name === "Properties");
34422
- if (!properties.elements) properties.elements = [];
34423
- const elements = properties.elements;
34424
- const cleanProperties = elements.filter((prop) => typeof prop === "object" && prop !== null).filter((prop) => {
34425
- const { attributes } = prop;
34426
- return attributes.name !== "SuperdocVersion";
34427
- });
34428
- let pid = 2;
34429
- try {
34430
- pid = cleanProperties.length ? Math.max(...elements.map((el) => el.attributes.pid)) + 1 : 2;
34431
- } catch {
34432
- }
34433
- cleanProperties.push(generateSuperdocVersion(pid));
34434
- properties.elements = cleanProperties;
34435
- return docx;
34436
- }
34437
34876
  function generateCustomXml() {
34438
34877
  return DEFAULT_CUSTOM_XML;
34439
34878
  }
34440
- function generateSuperdocVersion(pid = 2, version = "0.22.0") {
34441
- return {
34442
- type: "element",
34443
- name: "property",
34444
- attributes: {
34445
- name: "SuperdocVersion",
34446
- fmtid: "{D5CDD505-2E9C-101B-9397-08002B2CF9AE}",
34447
- pid
34448
- },
34449
- elements: [
34450
- {
34451
- type: "element",
34452
- name: "vt:lpwstr",
34453
- elements: [
34454
- {
34455
- type: "text",
34456
- text: version
34457
- }
34458
- ]
34459
- }
34460
- ]
34461
- };
34462
- }
34463
34879
  export {
34464
34880
  RemoveMarkStep as $,
34465
34881
  AllSelection as A,
@@ -34551,7 +34967,7 @@ export {
34551
34967
  generateDocxRandomId as au,
34552
34968
  insertNewRelationship as av,
34553
34969
  commonjsGlobal as aw,
34554
- getDefaultExportFromCjs$1 as ax,
34970
+ getDefaultExportFromCjs$2 as ax,
34555
34971
  getContentTypesFromXml as ay,
34556
34972
  xmljs as az,
34557
34973
  Slice as b,