quoin-editor 1.1.1 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (132) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/dist/ai.cjs +78 -78
  3. package/dist/ai.js +6 -6
  4. package/dist/catalogue.cjs +24 -24
  5. package/dist/catalogue.js +16 -16
  6. package/dist/{chunk-DYWU4SQ2.js → chunk-3BCP6ZUM.js} +5 -6
  7. package/dist/chunk-3BCP6ZUM.js.map +1 -0
  8. package/dist/{chunk-L4D23LM2.js → chunk-4EU4BTLZ.js} +82 -34
  9. package/dist/chunk-4EU4BTLZ.js.map +1 -0
  10. package/dist/{chunk-VFSVN5IQ.cjs → chunk-4F2IWBFM.cjs} +294 -244
  11. package/dist/chunk-4F2IWBFM.cjs.map +1 -0
  12. package/dist/{chunk-HQ43EIYO.cjs → chunk-4T4TJ2QS.cjs} +9 -9
  13. package/dist/{chunk-HQ43EIYO.cjs.map → chunk-4T4TJ2QS.cjs.map} +1 -1
  14. package/dist/{chunk-7XQGOCUG.cjs → chunk-6X5A4DUQ.cjs} +290 -291
  15. package/dist/chunk-6X5A4DUQ.cjs.map +1 -0
  16. package/dist/{chunk-7FAVFJAS.js → chunk-AD3NY7NA.js} +3 -3
  17. package/dist/{chunk-7FAVFJAS.js.map → chunk-AD3NY7NA.js.map} +1 -1
  18. package/dist/{chunk-L6OW2FL3.js → chunk-BJTOLCRR.js} +84 -10
  19. package/dist/chunk-BJTOLCRR.js.map +1 -0
  20. package/dist/{chunk-HTLWPSMU.js → chunk-BKEHG4QV.js} +4 -4
  21. package/dist/{chunk-HTLWPSMU.js.map → chunk-BKEHG4QV.js.map} +1 -1
  22. package/dist/{chunk-7SVKLWDT.cjs → chunk-BM2GRZNM.cjs} +47 -43
  23. package/dist/chunk-BM2GRZNM.cjs.map +1 -0
  24. package/dist/{chunk-2EQ6FKSK.js → chunk-BXSWZEA5.js} +3 -3
  25. package/dist/{chunk-2EQ6FKSK.js.map → chunk-BXSWZEA5.js.map} +1 -1
  26. package/dist/{chunk-3BXUGX5F.js → chunk-CSKKSXCE.js} +38 -31
  27. package/dist/chunk-CSKKSXCE.js.map +1 -0
  28. package/dist/{chunk-U5BSCAMP.cjs → chunk-EQKFQK3C.cjs} +13 -13
  29. package/dist/{chunk-U5BSCAMP.cjs.map → chunk-EQKFQK3C.cjs.map} +1 -1
  30. package/dist/{chunk-TYZSB7JT.js → chunk-GHNQKJMD.js} +3 -3
  31. package/dist/{chunk-TYZSB7JT.js.map → chunk-GHNQKJMD.js.map} +1 -1
  32. package/dist/{chunk-RIIXJWBR.cjs → chunk-H3C3MJW5.cjs} +4 -4
  33. package/dist/{chunk-RIIXJWBR.cjs.map → chunk-H3C3MJW5.cjs.map} +1 -1
  34. package/dist/{chunk-UEVR4B5S.js → chunk-I4CSCA3O.js} +6 -6
  35. package/dist/{chunk-UEVR4B5S.js.map → chunk-I4CSCA3O.js.map} +1 -1
  36. package/dist/{chunk-SFMORPWB.js → chunk-I4NEX6SZ.js} +7 -7
  37. package/dist/{chunk-SFMORPWB.js.map → chunk-I4NEX6SZ.js.map} +1 -1
  38. package/dist/{chunk-L2QA2UTY.js → chunk-IHTHOAUY.js} +7 -7
  39. package/dist/{chunk-L2QA2UTY.js.map → chunk-IHTHOAUY.js.map} +1 -1
  40. package/dist/{chunk-KXRGY5LK.cjs → chunk-IQ2DE3Y3.cjs} +90 -90
  41. package/dist/{chunk-KXRGY5LK.cjs.map → chunk-IQ2DE3Y3.cjs.map} +1 -1
  42. package/dist/{chunk-W7B4WQ3L.cjs → chunk-K7E2DR5W.cjs} +24 -24
  43. package/dist/{chunk-W7B4WQ3L.cjs.map → chunk-K7E2DR5W.cjs.map} +1 -1
  44. package/dist/{chunk-QSXPKZ2F.js → chunk-KIU5MPZ4.js} +3 -3
  45. package/dist/{chunk-QSXPKZ2F.js.map → chunk-KIU5MPZ4.js.map} +1 -1
  46. package/dist/{chunk-MUIPM26J.js → chunk-MEXDDWJF.js} +6 -6
  47. package/dist/{chunk-MUIPM26J.js.map → chunk-MEXDDWJF.js.map} +1 -1
  48. package/dist/{chunk-IGZRZIAF.cjs → chunk-NNDLIP2C.cjs} +161 -136
  49. package/dist/chunk-NNDLIP2C.cjs.map +1 -0
  50. package/dist/{chunk-CKHKCPGL.js → chunk-OWX3Y5UU.js} +6 -6
  51. package/dist/{chunk-CKHKCPGL.js.map → chunk-OWX3Y5UU.js.map} +1 -1
  52. package/dist/{chunk-WAGBELKA.js → chunk-PMJ3VCSR.js} +5 -5
  53. package/dist/{chunk-WAGBELKA.js.map → chunk-PMJ3VCSR.js.map} +1 -1
  54. package/dist/{chunk-IEP7BPFN.js → chunk-PVCXTSUO.js} +49 -24
  55. package/dist/chunk-PVCXTSUO.js.map +1 -0
  56. package/dist/{chunk-7NAONESM.cjs → chunk-R45RJQRD.cjs} +31 -31
  57. package/dist/{chunk-7NAONESM.cjs.map → chunk-R45RJQRD.cjs.map} +1 -1
  58. package/dist/{chunk-VNRI5DAL.cjs → chunk-RENKFSFD.cjs} +28 -28
  59. package/dist/{chunk-VNRI5DAL.cjs.map → chunk-RENKFSFD.cjs.map} +1 -1
  60. package/dist/{chunk-KZ6ZFCGO.js → chunk-TG5T7BEJ.js} +8 -8
  61. package/dist/{chunk-KZ6ZFCGO.js.map → chunk-TG5T7BEJ.js.map} +1 -1
  62. package/dist/{chunk-WH56EW3H.cjs → chunk-TLMO46OV.cjs} +15 -15
  63. package/dist/{chunk-WH56EW3H.cjs.map → chunk-TLMO46OV.cjs.map} +1 -1
  64. package/dist/{chunk-XAS7LANM.cjs → chunk-TN32PKUI.cjs} +98 -98
  65. package/dist/{chunk-XAS7LANM.cjs.map → chunk-TN32PKUI.cjs.map} +1 -1
  66. package/dist/{chunk-JCEFSTVG.cjs → chunk-TWFMNDOC.cjs} +55 -55
  67. package/dist/{chunk-JCEFSTVG.cjs.map → chunk-TWFMNDOC.cjs.map} +1 -1
  68. package/dist/{chunk-OKWER2RV.cjs → chunk-UHAAYYMX.cjs} +45 -45
  69. package/dist/{chunk-OKWER2RV.cjs.map → chunk-UHAAYYMX.cjs.map} +1 -1
  70. package/dist/{chunk-EFRQMYZ6.cjs → chunk-UMTKQVOX.cjs} +4 -4
  71. package/dist/{chunk-EFRQMYZ6.cjs.map → chunk-UMTKQVOX.cjs.map} +1 -1
  72. package/dist/{chunk-OM7E43ZN.cjs → chunk-VNRBCUBV.cjs} +15 -15
  73. package/dist/{chunk-OM7E43ZN.cjs.map → chunk-VNRBCUBV.cjs.map} +1 -1
  74. package/dist/{chunk-RFLFRIPV.js → chunk-WCAUPASG.js} +6 -6
  75. package/dist/{chunk-RFLFRIPV.js.map → chunk-WCAUPASG.js.map} +1 -1
  76. package/dist/{chunk-AIS37SL2.cjs → chunk-WZA5S5EJ.cjs} +84 -9
  77. package/dist/chunk-WZA5S5EJ.cjs.map +1 -0
  78. package/dist/{chunk-VBJY2CSK.js → chunk-X4FDLUXJ.js} +6 -6
  79. package/dist/{chunk-VBJY2CSK.js.map → chunk-X4FDLUXJ.js.map} +1 -1
  80. package/dist/{chunk-3QRVAI53.cjs → chunk-XZ4NC3Q7.cjs} +6 -6
  81. package/dist/{chunk-3QRVAI53.cjs.map → chunk-XZ4NC3Q7.cjs.map} +1 -1
  82. package/dist/comments.cjs +58 -58
  83. package/dist/comments.js +7 -7
  84. package/dist/diff.cjs +29 -32
  85. package/dist/diff.cjs.map +1 -1
  86. package/dist/diff.js +8 -11
  87. package/dist/diff.js.map +1 -1
  88. package/dist/docx.cjs +30 -30
  89. package/dist/docx.js +3 -3
  90. package/dist/embed.cjs +9 -9
  91. package/dist/embed.js +7 -7
  92. package/dist/emoji.cjs +9 -9
  93. package/dist/emoji.js +6 -6
  94. package/dist/engine.cjs +58 -58
  95. package/dist/engine.d.cts +4 -1
  96. package/dist/engine.d.ts +4 -1
  97. package/dist/engine.js +3 -3
  98. package/dist/find.cjs +10 -10
  99. package/dist/find.js +6 -6
  100. package/dist/headless.cjs +74 -74
  101. package/dist/headless.js +4 -4
  102. package/dist/index.cjs +86 -86
  103. package/dist/index.js +5 -5
  104. package/dist/math.cjs +10 -10
  105. package/dist/math.js +8 -8
  106. package/dist/mention.cjs +10 -10
  107. package/dist/mention.js +8 -8
  108. package/dist/presence.cjs +38 -38
  109. package/dist/presence.js +7 -7
  110. package/dist/stats.cjs +10 -10
  111. package/dist/stats.js +7 -7
  112. package/dist/table.cjs +25 -25
  113. package/dist/table.js +6 -6
  114. package/dist/toc.cjs +9 -9
  115. package/dist/toc.js +6 -6
  116. package/dist/view.cjs +4 -4
  117. package/dist/view.js +2 -2
  118. package/dist/yjs.cjs +125 -120
  119. package/dist/yjs.cjs.map +1 -1
  120. package/dist/yjs.js +11 -6
  121. package/dist/yjs.js.map +1 -1
  122. package/package.json +1 -1
  123. package/dist/chunk-3BXUGX5F.js.map +0 -1
  124. package/dist/chunk-7SVKLWDT.cjs.map +0 -1
  125. package/dist/chunk-7XQGOCUG.cjs.map +0 -1
  126. package/dist/chunk-AIS37SL2.cjs.map +0 -1
  127. package/dist/chunk-DYWU4SQ2.js.map +0 -1
  128. package/dist/chunk-IEP7BPFN.js.map +0 -1
  129. package/dist/chunk-IGZRZIAF.cjs.map +0 -1
  130. package/dist/chunk-L4D23LM2.js.map +0 -1
  131. package/dist/chunk-L6OW2FL3.js.map +0 -1
  132. package/dist/chunk-VFSVN5IQ.cjs.map +0 -1
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var chunk7SVKLWDT_cjs = require('./chunk-7SVKLWDT.cjs');
4
- var chunkAIS37SL2_cjs = require('./chunk-AIS37SL2.cjs');
3
+ var chunkBM2GRZNM_cjs = require('./chunk-BM2GRZNM.cjs');
4
+ var chunkWZA5S5EJ_cjs = require('./chunk-WZA5S5EJ.cjs');
5
5
 
6
6
  // src/engine/transform/step.ts
7
7
  var StepError = class extends Error {
@@ -10,7 +10,7 @@ var identityMap = (pos) => pos;
10
10
 
11
11
  // src/engine/transform/step-access.ts
12
12
  function requireBlock(doc, id) {
13
- const block = chunkAIS37SL2_cjs.blockById(doc, id);
13
+ const block = chunkWZA5S5EJ_cjs.blockById(doc, id);
14
14
  if (block === void 0) throw new StepError(`no block "${id}"`);
15
15
  return block;
16
16
  }
@@ -20,7 +20,7 @@ function requireRegion(block, region) {
20
20
  }
21
21
  function requireRange(block, region, from, to) {
22
22
  const inline = requireRegion(block, region);
23
- const length = chunkAIS37SL2_cjs.inlineLength(inline);
23
+ const length = chunkWZA5S5EJ_cjs.inlineLength(inline);
24
24
  if (!(Number.isInteger(from) && Number.isInteger(to) && from >= 0 && from <= to && to <= length)) {
25
25
  throw new StepError(`range ${from} to ${to} is outside 0 to ${length} in "${block.id}" ${region}`);
26
26
  }
@@ -44,7 +44,7 @@ function patchAttrs(attrs, patch) {
44
44
  }
45
45
  function patchChangesAttrs(attrs, patch) {
46
46
  return Object.keys(patch).some(
47
- (key) => patch[key] === void 0 ? Object.hasOwn(attrs, key) : !chunk7SVKLWDT_cjs.sameValue(attrs[key], patch[key])
47
+ (key) => patch[key] === void 0 ? Object.hasOwn(attrs, key) : !chunkWZA5S5EJ_cjs.sameValue(attrs[key], patch[key])
48
48
  );
49
49
  }
50
50
  function previousValues(attrs, patch) {
@@ -66,7 +66,7 @@ function setAttrsStep(block, patch) {
66
66
  stepType: "setAttrs",
67
67
  apply(doc) {
68
68
  requireBlock(doc, block);
69
- return { doc: chunkAIS37SL2_cjs.updateBlock(doc, block, (b) => ({ ...b, attrs: patchAttrs(b.attrs, patch) })), map: identityMap };
69
+ return { doc: chunkWZA5S5EJ_cjs.updateBlock(doc, block, (b) => ({ ...b, attrs: patchAttrs(b.attrs, patch) })), map: identityMap };
70
70
  },
71
71
  invert: (before) => setAttrsStep(block, previousValues(requireBlock(before, block).attrs, patch)),
72
72
  toJSON: () => ({ stepType: "setAttrs", block, patch: patchToJSON(patch) })
@@ -80,7 +80,7 @@ function setIndentStep(block, indent2) {
80
80
  if (!Number.isInteger(indent2) || indent2 < 0) {
81
81
  throw new StepError(`indent ${indent2} is not a non-negative integer`);
82
82
  }
83
- return { doc: chunkAIS37SL2_cjs.updateBlock(doc, block, (b) => ({ ...b, indent: indent2 })), map: identityMap };
83
+ return { doc: chunkWZA5S5EJ_cjs.updateBlock(doc, block, (b) => ({ ...b, indent: indent2 })), map: identityMap };
84
84
  },
85
85
  invert: (before) => setIndentStep(block, requireBlock(before, block).indent),
86
86
  toJSON: () => ({ stepType: "setIndent", block, indent: indent2 })
@@ -89,7 +89,7 @@ function setIndentStep(block, indent2) {
89
89
 
90
90
  // src/engine/transform/block-edges.ts
91
91
  function orderedRegions(block) {
92
- return Object.keys(block.regions).sort(chunkAIS37SL2_cjs.compareRegionNames);
92
+ return Object.keys(block.regions).sort(chunkWZA5S5EJ_cjs.compareRegionNames);
93
93
  }
94
94
  function firstRegion(block) {
95
95
  return orderedRegions(block)[0] ?? null;
@@ -102,12 +102,12 @@ function blockEnd(block) {
102
102
  return {
103
103
  block: block.id,
104
104
  region: region ?? "",
105
- offset: region === void 0 ? 0 : chunkAIS37SL2_cjs.inlineLength(block.regions[region])
105
+ offset: region === void 0 ? 0 : chunkWZA5S5EJ_cjs.inlineLength(block.regions[region])
106
106
  };
107
107
  }
108
108
  function clampPos(block, pos) {
109
109
  if (!Object.hasOwn(block.regions, pos.region)) return blockStart(block);
110
- const length = chunkAIS37SL2_cjs.inlineLength(block.regions[pos.region]);
110
+ const length = chunkWZA5S5EJ_cjs.inlineLength(block.regions[pos.region]);
111
111
  return pos.offset > length ? { ...pos, offset: length } : pos;
112
112
  }
113
113
 
@@ -122,7 +122,7 @@ function insertBlocksStep(index, blocks) {
122
122
  if (doc.index.has(id) || ids.has(id)) throw new StepError(`block "${id}" is already in the document`);
123
123
  ids.add(id);
124
124
  }
125
- return { doc: chunkAIS37SL2_cjs.replaceBlocks(doc, index, 0, blocks), map: identityMap };
125
+ return { doc: chunkWZA5S5EJ_cjs.replaceBlocks(doc, index, 0, blocks), map: identityMap };
126
126
  },
127
127
  invert: () => removeBlocksStep(index, blocks.length),
128
128
  toJSON: () => ({ stepType: "insertBlocks", index, blocks })
@@ -142,7 +142,7 @@ function removeBlocksStep(index, count2) {
142
142
  const after = following && blockStart(following);
143
143
  return (assoc === -1 ? before ?? after : after ?? before) ?? pos;
144
144
  };
145
- return { doc: chunkAIS37SL2_cjs.replaceBlocks(doc, index, count2, []), map };
145
+ return { doc: chunkWZA5S5EJ_cjs.replaceBlocks(doc, index, count2, []), map };
146
146
  },
147
147
  invert: (before) => insertBlocksStep(index, before.blocks.slice(index, index + count2)),
148
148
  toJSON: () => ({ stepType: "removeBlocks", index, count: count2 })
@@ -156,14 +156,14 @@ function moveBlocksStep(from, count2, to) {
156
156
  requireSpan(to, count2, doc.blocks.length);
157
157
  const moved2 = doc.blocks.slice(from, from + count2);
158
158
  const rest = [...doc.blocks.slice(0, from), ...doc.blocks.slice(from + count2)];
159
- return { doc: chunkAIS37SL2_cjs.createDoc([...rest.slice(0, to), ...moved2, ...rest.slice(to)]), map: identityMap };
159
+ return { doc: chunkWZA5S5EJ_cjs.createDoc([...rest.slice(0, to), ...moved2, ...rest.slice(to)]), map: identityMap };
160
160
  },
161
161
  invert: () => moveBlocksStep(to, count2, from),
162
162
  toJSON: () => ({ stepType: "moveBlocks", from, count: count2, to })
163
163
  });
164
164
  }
165
165
  var keepsRegions = (before, after) => Object.entries(before.regions).every(
166
- ([name, inline]) => Object.hasOwn(after.regions, name) && chunkAIS37SL2_cjs.equalInline(inline, after.regions[name])
166
+ ([name, inline]) => Object.hasOwn(after.regions, name) && chunkWZA5S5EJ_cjs.equalInline(inline, after.regions[name])
167
167
  );
168
168
  function replaceBlockStep(block) {
169
169
  const clamp = (pos) => pos.block === block.id ? clampPos(block, pos) : pos;
@@ -171,61 +171,56 @@ function replaceBlockStep(block) {
171
171
  stepType: "replaceBlock",
172
172
  apply(doc) {
173
173
  const map = keepsRegions(requireBlock(doc, block.id), block) ? identityMap : clamp;
174
- return { doc: chunkAIS37SL2_cjs.updateBlock(doc, block.id, () => block), map };
174
+ return { doc: chunkWZA5S5EJ_cjs.updateBlock(doc, block.id, () => block), map };
175
175
  },
176
176
  invert: (before) => replaceBlockStep(requireBlock(before, block.id)),
177
177
  toJSON: () => ({ stepType: "replaceBlock", block })
178
178
  });
179
179
  }
180
180
 
181
- // src/engine/transform/replace-inline-step.ts
182
- function replaceInlineStep(block, region, from, to, slice) {
183
- const inserted = chunkAIS37SL2_cjs.inlineLength(slice);
184
- const map = (pos, assoc = 1) => {
185
- if (pos.block !== block || pos.region !== region || pos.offset < from) return pos;
186
- if (pos.offset > to) return { ...pos, offset: pos.offset + inserted - (to - from) };
187
- return { ...pos, offset: assoc === -1 ? from : from + inserted };
188
- };
181
+ // src/engine/transform/mark-steps.ts
182
+ function restoreMarksStep(block, region, from, to, slice) {
189
183
  return Object.freeze({
190
- stepType: "replaceInline",
184
+ stepType: "restoreMarks",
191
185
  apply(doc) {
192
186
  const inline = requireRange(requireBlock(doc, block), region, from, to);
193
- const next = chunkAIS37SL2_cjs.updateBlock(doc, block, (b) => withRegion(b, region, chunkAIS37SL2_cjs.replaceInline(inline, from, to, slice)));
194
- return { doc: next, map };
187
+ if (chunkWZA5S5EJ_cjs.inlineText(slice) !== chunkWZA5S5EJ_cjs.inlineText(chunkWZA5S5EJ_cjs.sliceInline(inline, from, to))) {
188
+ throw new StepError(`marks restored over other content in "${block}" ${region}`);
189
+ }
190
+ const next = chunkWZA5S5EJ_cjs.updateBlock(doc, block, (b) => withRegion(b, region, chunkWZA5S5EJ_cjs.replaceInline(inline, from, to, slice)));
191
+ return { doc: next, map: identityMap };
195
192
  },
196
193
  invert(before) {
197
194
  const inline = requireRange(requireBlock(before, block), region, from, to);
198
- return replaceInlineStep(block, region, from, from + inserted, chunkAIS37SL2_cjs.sliceInline(inline, from, to));
195
+ return restoreMarksStep(block, region, from, to, chunkWZA5S5EJ_cjs.sliceInline(inline, from, to));
199
196
  },
200
- toJSON: () => ({ stepType: "replaceInline", block, region, from, to, slice })
197
+ toJSON: () => ({ stepType: "restoreMarks", block, region, from, to, slice })
201
198
  });
202
199
  }
203
-
204
- // src/engine/transform/mark-steps.ts
205
200
  function markStep(stepType, target, mark, change) {
206
201
  const { block, region, from, to } = target;
207
202
  return Object.freeze({
208
203
  stepType,
209
204
  apply(doc) {
210
205
  const inline = requireRange(requireBlock(doc, block), region, from, to);
211
- return { doc: chunkAIS37SL2_cjs.updateBlock(doc, block, (b) => withRegion(b, region, change(inline))), map: identityMap };
206
+ return { doc: chunkWZA5S5EJ_cjs.updateBlock(doc, block, (b) => withRegion(b, region, change(inline))), map: identityMap };
212
207
  },
213
208
  invert(before) {
214
209
  const inline = requireRange(requireBlock(before, block), region, from, to);
215
- return replaceInlineStep(block, region, from, to, chunkAIS37SL2_cjs.sliceInline(inline, from, to));
210
+ return restoreMarksStep(block, region, from, to, chunkWZA5S5EJ_cjs.sliceInline(inline, from, to));
216
211
  },
217
212
  toJSON: () => ({ stepType, ...target, mark })
218
213
  });
219
214
  }
220
215
  function addMarkStep(block, region, from, to, mark) {
221
- return markStep("addMark", { block, region, from, to }, mark, (inline) => chunkAIS37SL2_cjs.addMarkRange(inline, from, to, mark));
216
+ return markStep("addMark", { block, region, from, to }, mark, (inline) => chunkWZA5S5EJ_cjs.addMarkRange(inline, from, to, mark));
222
217
  }
223
218
  function removeMarkStep(block, region, from, to, mark) {
224
219
  return markStep(
225
220
  "removeMark",
226
221
  { block, region, from, to },
227
222
  mark,
228
- (inline) => chunkAIS37SL2_cjs.removeMarkRange(inline, from, to, mark)
223
+ (inline) => chunkWZA5S5EJ_cjs.removeMarkRange(inline, from, to, mark)
229
224
  );
230
225
  }
231
226
 
@@ -255,7 +250,7 @@ function mapTextChange(before, after) {
255
250
  const ops = removed.length + added.length > DIFF_LIMIT ? [
256
251
  { op: "delete", items: removed },
257
252
  { op: "insert", items: added }
258
- ] : chunk7SVKLWDT_cjs.diffSequences(removed.split(""), added.split(""));
253
+ ] : chunkBM2GRZNM_cjs.diffSequences(removed.split(""), added.split(""));
259
254
  return (offset, assoc) => {
260
255
  let b = from;
261
256
  let a = from;
@@ -281,13 +276,13 @@ function replaceDocStep(next) {
281
276
  const regionMaps = /* @__PURE__ */ new Map();
282
277
  const map = (pos, assoc = 1) => {
283
278
  const { block, region } = pos;
284
- const survivor = chunkAIS37SL2_cjs.blockById(next, block);
279
+ const survivor = chunkWZA5S5EJ_cjs.blockById(next, block);
285
280
  if (survivor !== void 0) {
286
281
  const key = JSON.stringify([block, region]);
287
282
  let regionMap = regionMaps.get(key);
288
283
  if (regionMap === void 0) {
289
- const before = chunkAIS37SL2_cjs.inlineText(chunkAIS37SL2_cjs.blockById(doc, block)?.regions[region] ?? []);
290
- regionMap = mapTextChange(before, chunkAIS37SL2_cjs.inlineText(survivor.regions[region] ?? []));
284
+ const before = chunkWZA5S5EJ_cjs.inlineText(chunkWZA5S5EJ_cjs.blockById(doc, block)?.regions[region] ?? []);
285
+ regionMap = mapTextChange(before, chunkWZA5S5EJ_cjs.inlineText(survivor.regions[region] ?? []));
291
286
  regionMaps.set(key, regionMap);
292
287
  }
293
288
  const offset = regionMap(pos.offset, assoc);
@@ -303,6 +298,29 @@ function replaceDocStep(next) {
303
298
  });
304
299
  }
305
300
 
301
+ // src/engine/transform/replace-inline-step.ts
302
+ function replaceInlineStep(block, region, from, to, slice) {
303
+ const inserted = chunkWZA5S5EJ_cjs.inlineLength(slice);
304
+ const map = (pos, assoc = 1) => {
305
+ if (pos.block !== block || pos.region !== region || pos.offset < from) return pos;
306
+ if (pos.offset > to) return { ...pos, offset: pos.offset + inserted - (to - from) };
307
+ return { ...pos, offset: assoc === -1 ? from : from + inserted };
308
+ };
309
+ return Object.freeze({
310
+ stepType: "replaceInline",
311
+ apply(doc) {
312
+ const inline = requireRange(requireBlock(doc, block), region, from, to);
313
+ const next = chunkWZA5S5EJ_cjs.updateBlock(doc, block, (b) => withRegion(b, region, chunkWZA5S5EJ_cjs.replaceInline(inline, from, to, slice)));
314
+ return { doc: next, map };
315
+ },
316
+ invert(before) {
317
+ const inline = requireRange(requireBlock(before, block), region, from, to);
318
+ return replaceInlineStep(block, region, from, from + inserted, chunkWZA5S5EJ_cjs.sliceInline(inline, from, to));
319
+ },
320
+ toJSON: () => ({ stepType: "replaceInline", block, region, from, to, slice })
321
+ });
322
+ }
323
+
306
324
  // src/engine/transform/split-join-steps.ts
307
325
  function splitBlockStep(block, region, offset, created) {
308
326
  const map = (pos, assoc = 1) => {
@@ -321,10 +339,10 @@ function splitBlockStep(block, region, offset, created) {
321
339
  type: created.type,
322
340
  indent: created.indent,
323
341
  attrs: created.attrs,
324
- regions: { ...created.regions, [created.region]: chunkAIS37SL2_cjs.sliceInline(inline, offset, chunkAIS37SL2_cjs.inlineLength(inline)) }
342
+ regions: { ...created.regions, [created.region]: chunkWZA5S5EJ_cjs.sliceInline(inline, offset, chunkWZA5S5EJ_cjs.inlineLength(inline)) }
325
343
  };
326
- const head = withRegion(target, region, chunkAIS37SL2_cjs.sliceInline(inline, 0, offset));
327
- return { doc: chunkAIS37SL2_cjs.replaceBlocks(doc, chunkAIS37SL2_cjs.indexOfBlock(doc, block), 1, [head, tail]), map };
344
+ const head = withRegion(target, region, chunkWZA5S5EJ_cjs.sliceInline(inline, 0, offset));
345
+ return { doc: chunkWZA5S5EJ_cjs.replaceBlocks(doc, chunkWZA5S5EJ_cjs.indexOfBlock(doc, block), 1, [head, tail]), map };
328
346
  },
329
347
  invert: () => joinBlocksStep(block, region, created.id, created.region),
330
348
  toJSON: () => ({ stepType: "splitBlock", block, region, offset, created })
@@ -336,17 +354,17 @@ function joinBlocksStep(target, targetRegion, source, sourceRegion) {
336
354
  apply(doc) {
337
355
  const first = requireBlock(doc, target);
338
356
  const second = requireBlock(doc, source);
339
- const index = chunkAIS37SL2_cjs.indexOfBlock(doc, target);
340
- if (chunkAIS37SL2_cjs.indexOfBlock(doc, source) !== index + 1) throw new StepError(`block "${source}" does not follow "${target}"`);
357
+ const index = chunkWZA5S5EJ_cjs.indexOfBlock(doc, target);
358
+ if (chunkWZA5S5EJ_cjs.indexOfBlock(doc, source) !== index + 1) throw new StepError(`block "${source}" does not follow "${target}"`);
341
359
  const head = requireRegion(first, targetRegion);
342
- const length = chunkAIS37SL2_cjs.inlineLength(head);
343
- const merged = chunkAIS37SL2_cjs.replaceInline(head, length, length, requireRegion(second, sourceRegion));
360
+ const length = chunkWZA5S5EJ_cjs.inlineLength(head);
361
+ const merged = chunkWZA5S5EJ_cjs.replaceInline(head, length, length, requireRegion(second, sourceRegion));
344
362
  const map = (pos) => pos.block === source ? { block: target, region: targetRegion, offset: length + (pos.region === sourceRegion ? pos.offset : 0) } : pos;
345
- return { doc: chunkAIS37SL2_cjs.replaceBlocks(doc, index, 2, [withRegion(first, targetRegion, merged)]), map };
363
+ return { doc: chunkWZA5S5EJ_cjs.replaceBlocks(doc, index, 2, [withRegion(first, targetRegion, merged)]), map };
346
364
  },
347
365
  invert(before) {
348
366
  const { id, type, attrs, indent: indent2, regions } = requireBlock(before, source);
349
- const length = chunkAIS37SL2_cjs.inlineLength(requireRegion(requireBlock(before, target), targetRegion));
367
+ const length = chunkWZA5S5EJ_cjs.inlineLength(requireRegion(requireBlock(before, target), targetRegion));
350
368
  const created = { id, type, attrs, indent: indent2, region: sourceRegion, regions };
351
369
  return splitBlockStep(target, targetRegion, length, created);
352
370
  },
@@ -355,9 +373,9 @@ function joinBlocksStep(target, targetRegion, source, sourceRegion) {
355
373
  }
356
374
 
357
375
  // src/engine/transform/step-json.ts
358
- var isRegions = (value) => chunkAIS37SL2_cjs.isRecord(value) && Object.values(value).every(Array.isArray);
359
- var isMark = (value) => chunkAIS37SL2_cjs.isRecord(value) && typeof value.type === "string" && (value.attrs === void 0 || chunkAIS37SL2_cjs.isRecord(value.attrs));
360
- var isBlockShape = (value) => chunkAIS37SL2_cjs.isRecord(value) && typeof value.id === "string" && typeof value.type === "string" && Number.isInteger(value.indent) && chunkAIS37SL2_cjs.isRecord(value.attrs);
376
+ var isRegions = (value) => chunkWZA5S5EJ_cjs.isRecord(value) && Object.values(value).every(Array.isArray);
377
+ var isMark = (value) => chunkWZA5S5EJ_cjs.isRecord(value) && typeof value.type === "string" && (value.attrs === void 0 || chunkWZA5S5EJ_cjs.isRecord(value.attrs));
378
+ var isBlockShape = (value) => chunkWZA5S5EJ_cjs.isRecord(value) && typeof value.id === "string" && typeof value.type === "string" && Number.isInteger(value.indent) && chunkWZA5S5EJ_cjs.isRecord(value.attrs);
361
379
  var isBlock = (value) => isBlockShape(value) && isRegions(value.regions);
362
380
  var isCreated = (value) => isBlockShape(value) && typeof value.region === "string" && (value.regions === void 0 || isRegions(value.regions));
363
381
  var isString = (value) => typeof value === "string";
@@ -369,7 +387,7 @@ function docOf(blocks) {
369
387
  if (new Set(blocks.map((block) => block.id)).size !== blocks.length) {
370
388
  throw new StepError("a replaceDoc step repeats a block id");
371
389
  }
372
- return chunkAIS37SL2_cjs.createDoc(blocks);
390
+ return chunkWZA5S5EJ_cjs.createDoc(blocks);
373
391
  }
374
392
  function reader(json) {
375
393
  return (key, accept) => {
@@ -405,8 +423,16 @@ function stepFromJSON(json) {
405
423
  read("to", isInteger),
406
424
  read("mark", isMarkOrType)
407
425
  );
426
+ case "restoreMarks":
427
+ return restoreMarksStep(
428
+ read("block", isString),
429
+ read("region", isString),
430
+ read("from", isInteger),
431
+ read("to", isInteger),
432
+ read("slice", isInline)
433
+ );
408
434
  case "setAttrs":
409
- return setAttrsStep(read("block", isString), patchFromJSON(read("patch", chunkAIS37SL2_cjs.isRecord)));
435
+ return setAttrsStep(read("block", isString), patchFromJSON(read("patch", chunkWZA5S5EJ_cjs.isRecord)));
410
436
  case "setIndent":
411
437
  return setIndentStep(read("block", isString), read("indent", isInteger));
412
438
  case "insertBlocks":
@@ -440,7 +466,7 @@ function stepFromJSON(json) {
440
466
 
441
467
  // src/engine/model/position.ts
442
468
  function comparePos(doc, a, b) {
443
- return chunkAIS37SL2_cjs.requireBlockIndex(doc, a.block) - chunkAIS37SL2_cjs.requireBlockIndex(doc, b.block) || chunkAIS37SL2_cjs.compareRegionNames(a.region, b.region) || a.offset - b.offset;
469
+ return chunkWZA5S5EJ_cjs.requireBlockIndex(doc, a.block) - chunkWZA5S5EJ_cjs.requireBlockIndex(doc, b.block) || chunkWZA5S5EJ_cjs.compareRegionNames(a.region, b.region) || a.offset - b.offset;
444
470
  }
445
471
  function orderedRange(doc, anchor, head) {
446
472
  return comparePos(doc, anchor, head) <= 0 ? { from: anchor, to: head } : { from: head, to: anchor };
@@ -479,7 +505,7 @@ function selectedBlockIds(doc, selection) {
479
505
  if (selection === null) return [];
480
506
  if (selection.kind === "node") return [selection.block];
481
507
  const ends = selection.kind === "text" ? [selection.anchor.block, selection.head.block] : [selection.anchor, selection.head];
482
- const [first, second] = ends.map((id) => chunkAIS37SL2_cjs.requireBlockIndex(doc, id));
508
+ const [first, second] = ends.map((id) => chunkWZA5S5EJ_cjs.requireBlockIndex(doc, id));
483
509
  return doc.blocks.slice(Math.min(first, second), Math.max(first, second) + 1).map((block) => block.id);
484
510
  }
485
511
  function isBackward(doc, selection) {
@@ -487,7 +513,7 @@ function isBackward(doc, selection) {
487
513
  const { anchor, head } = selection;
488
514
  return doc.index.has(anchor.block) && doc.index.has(head.block) && comparePos(doc, anchor, head) > 0;
489
515
  }
490
- return doc.index.has(selection.anchor) && doc.index.has(selection.head) && chunkAIS37SL2_cjs.indexOfBlock(doc, selection.anchor) > chunkAIS37SL2_cjs.indexOfBlock(doc, selection.head);
516
+ return doc.index.has(selection.anchor) && doc.index.has(selection.head) && chunkWZA5S5EJ_cjs.indexOfBlock(doc, selection.anchor) > chunkWZA5S5EJ_cjs.indexOfBlock(doc, selection.head);
491
517
  }
492
518
  var blockProbe = (block) => ({ block, region: "", offset: 0 });
493
519
  function mapSelection(selection, map, doc) {
@@ -506,18 +532,18 @@ function mapSelection(selection, map, doc) {
506
532
  return anchor === selection.anchor && head === selection.head ? selection : textSelection(anchor, head);
507
533
  }
508
534
  function primaryRegion(schema, block) {
509
- const spec = chunkAIS37SL2_cjs.specFor(schema, block.type);
535
+ const spec = chunkWZA5S5EJ_cjs.specFor(schema, block.type);
510
536
  if (spec.flow === "text" && spec.primaryRegion !== void 0 && Object.hasOwn(block.regions, spec.primaryRegion)) {
511
537
  return spec.primaryRegion;
512
538
  }
513
539
  return firstRegion(block);
514
540
  }
515
541
  function flowEdge(schema, block, atEnd) {
516
- const region = chunkAIS37SL2_cjs.specFor(schema, block.type).flow === "text" ? primaryRegion(schema, block) : null;
517
- return region === null ? null : { block: block.id, region, offset: atEnd ? chunkAIS37SL2_cjs.inlineLength(block.regions[region]) : 0 };
542
+ const region = chunkWZA5S5EJ_cjs.specFor(schema, block.type).flow === "text" ? primaryRegion(schema, block) : null;
543
+ return region === null ? null : { block: block.id, region, offset: atEnd ? chunkWZA5S5EJ_cjs.inlineLength(block.regions[region]) : 0 };
518
544
  }
519
545
  function edge(doc, schema, blockId, atEnd) {
520
- const block = doc.blocks[chunkAIS37SL2_cjs.requireBlockIndex(doc, blockId)];
546
+ const block = doc.blocks[chunkWZA5S5EJ_cjs.requireBlockIndex(doc, blockId)];
521
547
  const flow = flowEdge(schema, block, atEnd);
522
548
  if (flow !== null) return textSelection(flow);
523
549
  if (Object.keys(block.regions).length === 0) return nodeSelection(blockId);
@@ -533,13 +559,13 @@ function defaultSelection(doc, schema) {
533
559
  return doc.blocks.length === 0 ? null : startOf(doc, schema, doc.blocks[0].id);
534
560
  }
535
561
  function validatePos(doc, schema, pos) {
536
- const block = chunkAIS37SL2_cjs.blockById(doc, pos.block);
562
+ const block = chunkWZA5S5EJ_cjs.blockById(doc, pos.block);
537
563
  if (block === void 0) return null;
538
564
  if (!Object.hasOwn(block.regions, pos.region)) {
539
565
  const region = primaryRegion(schema, block);
540
566
  return region === null ? nodeSelection(block.id) : { block: block.id, region, offset: 0 };
541
567
  }
542
- const length = chunkAIS37SL2_cjs.inlineLength(block.regions[pos.region]);
568
+ const length = chunkWZA5S5EJ_cjs.inlineLength(block.regions[pos.region]);
543
569
  return pos.offset >= 0 && pos.offset <= length ? pos : { ...pos, offset: Math.min(Math.max(pos.offset, 0), length) };
544
570
  }
545
571
  function nearestFlow(doc, schema, from, to, atEnd) {
@@ -550,14 +576,14 @@ function nearestFlow(doc, schema, from, to, atEnd) {
550
576
  }
551
577
  return null;
552
578
  }
553
- var inFlow = (doc, schema, pos) => flowEdge(schema, doc.blocks[chunkAIS37SL2_cjs.requireBlockIndex(doc, pos.block)], false)?.region === pos.region;
579
+ var inFlow = (doc, schema, pos) => flowEdge(schema, doc.blocks[chunkWZA5S5EJ_cjs.requireBlockIndex(doc, pos.block)], false)?.region === pos.region;
554
580
  function clampToFlow(doc, schema, selection) {
555
581
  const { anchor, head } = selection;
556
582
  if (anchor.block === head.block) return selection;
557
583
  const backward = comparePos(doc, anchor, head) > 0;
558
584
  const [from, to] = backward ? [head, anchor] : [anchor, head];
559
- const first = chunkAIS37SL2_cjs.requireBlockIndex(doc, from.block);
560
- const last = chunkAIS37SL2_cjs.requireBlockIndex(doc, to.block);
585
+ const first = chunkWZA5S5EJ_cjs.requireBlockIndex(doc, from.block);
586
+ const last = chunkWZA5S5EJ_cjs.requireBlockIndex(doc, to.block);
561
587
  const start = inFlow(doc, schema, from) ? from : nearestFlow(doc, schema, first + 1, last, false);
562
588
  const end = inFlow(doc, schema, to) ? to : nearestFlow(doc, schema, last - 1, first, true);
563
589
  if (start === from && end === to) return selection;
@@ -576,9 +602,9 @@ function validateText(doc, schema, selection) {
576
602
  return clampToFlow(doc, schema, valid);
577
603
  }
578
604
  function validateNode(doc, schema, selection) {
579
- const block = chunkAIS37SL2_cjs.blockById(doc, selection.block);
605
+ const block = chunkWZA5S5EJ_cjs.blockById(doc, selection.block);
580
606
  if (block === void 0) return defaultSelection(doc, schema);
581
- return chunkAIS37SL2_cjs.specFor(schema, block.type).flow === "text" ? startOf(doc, schema, block.id) : selection;
607
+ return chunkWZA5S5EJ_cjs.specFor(schema, block.type).flow === "text" ? startOf(doc, schema, block.id) : selection;
582
608
  }
583
609
  function validateSelection(doc, schema, selection) {
584
610
  if (doc.blocks.length === 0) return null;
@@ -609,7 +635,7 @@ function hidingToggle(doc, index, isClosed = isClosedToggle) {
609
635
  }
610
636
 
611
637
  // src/engine/state/visible-selection.ts
612
- var hiderOf = (doc, id) => hidingToggle(doc, chunkAIS37SL2_cjs.requireBlockIndex(doc, id) + 1);
638
+ var hiderOf = (doc, id) => hidingToggle(doc, chunkWZA5S5EJ_cjs.requireBlockIndex(doc, id) + 1);
613
639
  function toggleEnd(doc, schema, toggle) {
614
640
  const end = endOf(doc, schema, doc.blocks[toggle].id);
615
641
  return end.kind === "text" ? end.head : blockEnd(doc.blocks[toggle]);
@@ -623,7 +649,7 @@ function visibleText(doc, schema, selection) {
623
649
  }
624
650
  function visibleBlocks(doc, schema, selection) {
625
651
  const ids = [selection.anchor, selection.head];
626
- const indexes = ids.map((id) => chunkAIS37SL2_cjs.requireBlockIndex(doc, id));
652
+ const indexes = ids.map((id) => chunkWZA5S5EJ_cjs.requireBlockIndex(doc, id));
627
653
  const from = Math.min(...indexes);
628
654
  const to = Math.max(...indexes);
629
655
  const hiders = indexes.map((index) => hidingToggle(doc, index + 1));
@@ -804,8 +830,8 @@ var Transaction = class {
804
830
  // src/engine/commands/caret-marks.ts
805
831
  function caretMarks(doc, schema, storedMarks, pos) {
806
832
  if (storedMarks !== null) return storedMarks;
807
- const inline = chunkAIS37SL2_cjs.blockById(doc, pos.block)?.regions[pos.region] ?? [];
808
- return chunkAIS37SL2_cjs.marksAt(inline, pos.offset, (mark) => schema.marks.get(mark.type)?.inclusive ?? true);
833
+ const inline = chunkWZA5S5EJ_cjs.blockById(doc, pos.block)?.regions[pos.region] ?? [];
834
+ return chunkWZA5S5EJ_cjs.marksAt(inline, pos.offset, (mark) => schema.marks.get(mark.type)?.inclusive ?? true);
809
835
  }
810
836
 
811
837
  // src/engine/commands/run-commands.ts
@@ -849,12 +875,32 @@ function runCommands(state, commands) {
849
875
  return { ok: true, tr: parts.length === 0 ? null : combine(state, parts, current) };
850
876
  }
851
877
 
852
- // src/engine/transform/position-neutral.ts
878
+ // src/engine/transform/same-layout.ts
853
879
  function sameLayout(before, after) {
854
880
  return before.blocks.length === after.blocks.length && before.blocks.every(({ id, indent: indent2 }, index) => id === after.blocks[index].id && indent2 === after.blocks[index].indent);
855
881
  }
856
- function isPositionNeutral(before, { doc, map }) {
857
- return map === identityMap && sameLayout(before, doc);
882
+
883
+ // src/engine/transform/position-neutral.ts
884
+ function movesNoPosition(before, after, maps) {
885
+ return maps.every((map) => map === identityMap) && sameLayout(before, after);
886
+ }
887
+
888
+ // src/engine/state/history-adjacent.ts
889
+ function replacements(tr) {
890
+ const replaced = tr.steps.filter((step) => step.stepType === "replaceInline");
891
+ return replaced.map((step) => step.toJSON());
892
+ }
893
+ function editEnd(tr) {
894
+ const { selection } = tr;
895
+ if (selection?.kind === "text" && isCollapsed(selection)) return selection.head;
896
+ const last = replacements(tr).at(-1);
897
+ return last === void 0 ? null : { block: last.block, region: last.region, offset: last.from + chunkWZA5S5EJ_cjs.inlineLength(last.slice) };
898
+ }
899
+ function continuesEdit(tr, end) {
900
+ if (end === null || end === void 0) return true;
901
+ const first = replacements(tr)[0];
902
+ if (first === void 0) return true;
903
+ return first.block === end.block && first.region === end.region && first.from <= end.offset && end.offset <= first.to;
858
904
  }
859
905
 
860
906
  // src/engine/state/history.ts
@@ -885,9 +931,11 @@ function recorded(tr, value, { depth, groupDelay }) {
885
931
  const steps = invertTransaction(tr);
886
932
  const group = groupOf(tr);
887
933
  const last = value.done.at(-1);
888
- const merges = last !== void 0 && group !== null && group === value.lastGroup && tr.time - value.lastTime < groupDelay;
934
+ const named = tr.getMeta(HISTORY_GROUP) !== void 0;
935
+ const merges = last !== void 0 && group !== null && group === value.lastGroup && tr.time - value.lastTime < groupDelay && (named || continuesEdit(tr, value.lastEnd));
889
936
  const done = merges ? [...value.done.slice(0, -1), { ...last, steps: [...steps, ...last.steps] }] : newest([...value.done, { steps, selection: tr.before.selection, origin: tr.origin }], depth);
890
- return { done, undone: [], lastTime: tr.time, lastGroup: group, lastInputRule: inputRuleRecord(tr, steps) };
937
+ const lastEnd = editEnd(tr) ?? (merges ? value.lastEnd : null);
938
+ return { done, undone: [], lastTime: tr.time, lastGroup: group, lastEnd, lastInputRule: inputRuleRecord(tr, steps) };
891
939
  }
892
940
  function moved(tr, value, direction, depth) {
893
941
  const undoing = direction === "undo";
@@ -903,15 +951,15 @@ function moved(tr, value, direction, depth) {
903
951
  const stacks = undoing ? { done: rest, undone: target } : { done: target, undone: rest };
904
952
  return { ...value, ...stacks, lastGroup: null, lastInputRule: null };
905
953
  }
906
- var movesNoPosition = (tr) => tr.steps.every((_, i) => isPositionNeutral(tr.docs[i], { doc: tr.docs[i + 1] ?? tr.doc, map: tr.maps[i] }));
907
954
  function advance(tr, value, config) {
908
955
  if (tr.docChanged) {
909
956
  const direction = tr.getMeta("history");
910
957
  if (direction !== void 0) return moved(tr, value, direction, config.depth);
911
958
  if (tr.addToHistory && !foreignOrigins.includes(tr.origin)) return recorded(tr, value, config);
912
- if (!movesNoPosition(tr)) return emptyHistory;
959
+ if (!movesNoPosition(tr.before.doc, tr.doc, tr.maps)) return emptyHistory;
913
960
  }
914
- const closed = tr.getMeta("closeHistory") === true;
961
+ const local = tr.docChanged && !foreignOrigins.includes(tr.origin);
962
+ const closed = local || tr.getMeta("closeHistory") === true;
915
963
  const relocated = tr.selectionSet && !sameSelection(tr.before.selection, tr.selection);
916
964
  return {
917
965
  ...value,
@@ -949,7 +997,7 @@ var undoInputRule = (state, dispatch) => {
949
997
  const { steps, undoText, at, marks } = record;
950
998
  const tr = new Transaction(state).setMeta(UNFILTERED, true);
951
999
  steps.forEach((step) => tr.step(step));
952
- tr.step(replaceInlineStep(at.block, at.region, at.offset, at.offset, [chunkAIS37SL2_cjs.text(undoText, marks)]));
1000
+ tr.step(replaceInlineStep(at.block, at.region, at.offset, at.offset, [chunkWZA5S5EJ_cjs.text(undoText, marks)]));
953
1001
  dispatch(tr.setSelection(textSelection({ ...at, offset: at.offset + undoText.length })));
954
1002
  }
955
1003
  return true;
@@ -958,7 +1006,7 @@ var undoInputRule = (state, dispatch) => {
958
1006
  // src/engine/commands/block-helpers.ts
959
1007
  var ITEM_KINDS = /* @__PURE__ */ new Set(["bullet", "ordered", "task", "quote"]);
960
1008
  function specOf(schema, block) {
961
- return chunkAIS37SL2_cjs.specFor(schema, block.type);
1009
+ return chunkWZA5S5EJ_cjs.specFor(schema, block.type);
962
1010
  }
963
1011
  function isTextFlow(schema, block) {
964
1012
  return specOf(schema, block).flow === "text";
@@ -970,7 +1018,7 @@ function isItem(block) {
970
1018
  return block.type === "MARKDOWN" && typeof block.attrs.kind === "string" && ITEM_KINDS.has(block.attrs.kind);
971
1019
  }
972
1020
  function regionLength(block, region) {
973
- return Object.hasOwn(block.regions, region) ? chunkAIS37SL2_cjs.inlineLength(block.regions[region]) : 0;
1021
+ return Object.hasOwn(block.regions, region) ? chunkWZA5S5EJ_cjs.inlineLength(block.regions[region]) : 0;
974
1022
  }
975
1023
  function descendantsEnd(doc, index) {
976
1024
  const { indent: indent2 } = doc.blocks[index];
@@ -978,8 +1026,8 @@ function descendantsEnd(doc, index) {
978
1026
  while (end < doc.blocks.length && doc.blocks[end].indent > indent2) end++;
979
1027
  return end;
980
1028
  }
981
- function createBlock(schema, type, attrs = {}, indent2 = 0, id = chunkAIS37SL2_cjs.newId()) {
982
- const initial = chunkAIS37SL2_cjs.specFor(schema, type).initial();
1029
+ function createBlock(schema, type, attrs = {}, indent2 = 0, id = chunkWZA5S5EJ_cjs.newId()) {
1030
+ const initial = chunkWZA5S5EJ_cjs.specFor(schema, type).initial();
983
1031
  return { id, type, indent: indent2, attrs: { ...initial.attrs, ...attrs }, regions: initial.regions };
984
1032
  }
985
1033
  function withContent(schema, block, content) {
@@ -997,7 +1045,7 @@ function headBlockId(selection) {
997
1045
  function selectedBlockRange(doc, selection) {
998
1046
  const ids = selectedBlockIds(doc, selection);
999
1047
  if (ids.length === 0) return null;
1000
- const start = chunkAIS37SL2_cjs.indexOfBlock(doc, ids[0]);
1048
+ const start = chunkWZA5S5EJ_cjs.indexOfBlock(doc, ids[0]);
1001
1049
  let end = start + ids.length;
1002
1050
  for (let index = start; index < start + ids.length; index++) end = Math.max(end, descendantsEnd(doc, index));
1003
1051
  return { start, end };
@@ -1041,7 +1089,7 @@ function shiftSubtree(tr, index, delta) {
1041
1089
  // src/engine/commands/block-structure.ts
1042
1090
  var toggleTask = (state, dispatch) => {
1043
1091
  const { doc, selection } = state;
1044
- const tasks = selectedBlockIds(doc, selection).map((id) => doc.blocks[chunkAIS37SL2_cjs.requireBlockIndex(doc, id)]).filter((block) => block.type === "MARKDOWN" && block.attrs.kind === "task");
1092
+ const tasks = selectedBlockIds(doc, selection).map((id) => doc.blocks[chunkWZA5S5EJ_cjs.requireBlockIndex(doc, id)]).filter((block) => block.type === "MARKDOWN" && block.attrs.kind === "task");
1045
1093
  if (tasks.length === 0) return false;
1046
1094
  const checked = !tasks.every((block) => block.attrs.checked === true);
1047
1095
  const tr = new Transaction(state);
@@ -1106,7 +1154,7 @@ function copiedSelection(selection, copies) {
1106
1154
  }
1107
1155
  }
1108
1156
  function duplicateBlocks(options = {}) {
1109
- const makeId = options.newId ?? chunkAIS37SL2_cjs.newId;
1157
+ const makeId = options.newId ?? chunkWZA5S5EJ_cjs.newId;
1110
1158
  return (state, dispatch) => {
1111
1159
  const { doc, selection } = state;
1112
1160
  const range = selectedBlockRange(doc, selection);
@@ -1128,12 +1176,12 @@ var deleteBlocks = (state, dispatch) => {
1128
1176
  return true;
1129
1177
  };
1130
1178
  function insertBlockAfter(type, attrs, options = {}) {
1131
- const makeId = options.newId ?? chunkAIS37SL2_cjs.newId;
1179
+ const makeId = options.newId ?? chunkWZA5S5EJ_cjs.newId;
1132
1180
  return (state, dispatch) => {
1133
1181
  const { doc, schema } = state;
1134
1182
  const id = headBlockId(state.selection);
1135
1183
  if (id === null) return false;
1136
- const index = chunkAIS37SL2_cjs.requireBlockIndex(doc, id);
1184
+ const index = chunkWZA5S5EJ_cjs.requireBlockIndex(doc, id);
1137
1185
  const current = doc.blocks[index];
1138
1186
  const fillsCurrent = isParagraph(current) && regionLength(current, primaryRegion(schema, current) ?? "") === 0;
1139
1187
  const block = createBlock(schema, type, attrs, current.indent, fillsCurrent ? current.id : makeId());
@@ -1153,10 +1201,10 @@ function deleteWithinBlock(tr, from, to) {
1153
1201
  clear(tr, from, from.offset, to.offset);
1154
1202
  return from;
1155
1203
  }
1156
- const block = tr.doc.blocks[chunkAIS37SL2_cjs.requireBlockIndex(tr.doc, from.block)];
1204
+ const block = tr.doc.blocks[chunkWZA5S5EJ_cjs.requireBlockIndex(tr.doc, from.block)];
1157
1205
  clear(tr, from, from.offset, regionLength(block, from.region));
1158
1206
  for (const region of Object.keys(block.regions)) {
1159
- const between = chunkAIS37SL2_cjs.compareRegionNames(from.region, region) < 0 && chunkAIS37SL2_cjs.compareRegionNames(region, to.region) < 0;
1207
+ const between = chunkWZA5S5EJ_cjs.compareRegionNames(from.region, region) < 0 && chunkWZA5S5EJ_cjs.compareRegionNames(region, to.region) < 0;
1160
1208
  if (between) clear(tr, { ...from, region }, 0, regionLength(block, region));
1161
1209
  }
1162
1210
  clear(tr, to, 0, to.offset);
@@ -1165,8 +1213,8 @@ function deleteWithinBlock(tr, from, to) {
1165
1213
  function deleteRange(tr, schema, from, to, newId2) {
1166
1214
  if (from.block === to.block) return deleteWithinBlock(tr, from, to);
1167
1215
  const { doc } = tr;
1168
- const start = chunkAIS37SL2_cjs.requireBlockIndex(doc, from.block);
1169
- const end = chunkAIS37SL2_cjs.requireBlockIndex(doc, to.block);
1216
+ const start = chunkWZA5S5EJ_cjs.requireBlockIndex(doc, from.block);
1217
+ const end = chunkWZA5S5EJ_cjs.requireBlockIndex(doc, to.block);
1170
1218
  const first = doc.blocks[start];
1171
1219
  const last = doc.blocks[end];
1172
1220
  const keepFirst = isTextFlow(schema, first);
@@ -1193,7 +1241,7 @@ function deleteRange(tr, schema, from, to, newId2) {
1193
1241
 
1194
1242
  // src/engine/commands/insert-text-at.ts
1195
1243
  function insertTextAt(tr, schema, pos, value) {
1196
- const slice = [chunkAIS37SL2_cjs.text(value, caretMarks(tr.doc, schema, tr.storedMarks, pos))];
1244
+ const slice = [chunkWZA5S5EJ_cjs.text(value, caretMarks(tr.doc, schema, tr.storedMarks, pos))];
1197
1245
  tr.step(replaceInlineStep(pos.block, pos.region, pos.offset, pos.offset, slice));
1198
1246
  return { ...pos, offset: pos.offset + value.length };
1199
1247
  }
@@ -1205,12 +1253,12 @@ function replaceBlocksWithText(tr, schema, range, value, makeId) {
1205
1253
  const indent2 = range === null ? 0 : doc.blocks[index].indent;
1206
1254
  if (range !== null) tr.step(removeBlocksStep(index, range.end - range.start));
1207
1255
  const empty = createBlock(schema, schema.defaultTextBlock, {}, indent2, makeId());
1208
- const paragraph = withContent(schema, empty, [chunkAIS37SL2_cjs.text(value)]);
1256
+ const paragraph = withContent(schema, empty, [chunkWZA5S5EJ_cjs.text(value)]);
1209
1257
  tr.step(insertBlocksStep(index, [paragraph]));
1210
1258
  tr.setSelection(endOf(tr.doc, schema, paragraph.id));
1211
1259
  }
1212
1260
  function insertText(value, options = {}) {
1213
- const makeId = options.newId ?? chunkAIS37SL2_cjs.newId;
1261
+ const makeId = options.newId ?? chunkWZA5S5EJ_cjs.newId;
1214
1262
  return (state, dispatch) => {
1215
1263
  if (value === "") return false;
1216
1264
  const { doc, schema, selection } = state;
@@ -1233,9 +1281,9 @@ function markExtent(inline, offset, type) {
1233
1281
  let position = 0;
1234
1282
  for (const node of inline) {
1235
1283
  starts.push(position);
1236
- position += chunkAIS37SL2_cjs.nodeLength(node);
1284
+ position += chunkWZA5S5EJ_cjs.nodeLength(node);
1237
1285
  }
1238
- const containing = (at) => inline.findIndex((node, i) => starts[i] <= at && at < starts[i] + chunkAIS37SL2_cjs.nodeLength(node));
1286
+ const containing = (at) => inline.findIndex((node, i) => starts[i] <= at && at < starts[i] + chunkWZA5S5EJ_cjs.nodeLength(node));
1239
1287
  const markOf = (index) => inline[index]?.marks.find((mark2) => mark2.type === type);
1240
1288
  let seed = containing(offset);
1241
1289
  let mark = markOf(seed);
@@ -1244,29 +1292,29 @@ function markExtent(inline, offset, type) {
1244
1292
  mark = markOf(seed);
1245
1293
  }
1246
1294
  if (mark === void 0) return null;
1247
- const shares = (index) => inline[index].marks.some((other) => chunkAIS37SL2_cjs.sameMark(other, mark));
1295
+ const shares = (index) => inline[index].marks.some((other) => chunkWZA5S5EJ_cjs.sameMark(other, mark));
1248
1296
  let first = seed;
1249
1297
  while (first > 0 && shares(first - 1)) first--;
1250
1298
  let last = seed;
1251
1299
  while (last < inline.length - 1 && shares(last + 1)) last++;
1252
- return { from: starts[first], to: starts[last] + chunkAIS37SL2_cjs.nodeLength(inline[last]) };
1300
+ return { from: starts[first], to: starts[last] + chunkWZA5S5EJ_cjs.nodeLength(inline[last]) };
1253
1301
  }
1254
1302
 
1255
1303
  // src/engine/commands/storable-mark.ts
1256
1304
  function readsBack(inline) {
1257
- return chunkAIS37SL2_cjs.equalInline(chunkAIS37SL2_cjs.parseInline(chunkAIS37SL2_cjs.serializeInline(inline)), chunkAIS37SL2_cjs.normalizeInline(inline));
1305
+ return chunkWZA5S5EJ_cjs.equalInline(chunkWZA5S5EJ_cjs.parseInline(chunkWZA5S5EJ_cjs.serializeInline(inline)), chunkWZA5S5EJ_cjs.normalizeInline(inline));
1258
1306
  }
1259
1307
  function safeLink(mark) {
1260
1308
  const href = mark.attrs?.href;
1261
- const safe = typeof href === "string" ? chunkAIS37SL2_cjs.sanitizeHref(href) : null;
1309
+ const safe = typeof href === "string" ? chunkWZA5S5EJ_cjs.sanitizeHref(href) : null;
1262
1310
  return safe ? { type: "link", attrs: { ...mark.attrs, href: safe } } : null;
1263
1311
  }
1264
1312
  function storableMark(mark) {
1265
1313
  const candidate = mark.type === "link" ? safeLink(mark) : mark;
1266
- return candidate !== null && readsBack([chunkAIS37SL2_cjs.text("a", [candidate])]) ? candidate : null;
1314
+ return candidate !== null && readsBack([chunkWZA5S5EJ_cjs.text("a", [candidate])]) ? candidate : null;
1267
1315
  }
1268
1316
  function storableAtom(type, attrs) {
1269
- return readsBack([chunkAIS37SL2_cjs.atom(type, attrs)]);
1317
+ return readsBack([chunkWZA5S5EJ_cjs.atom(type, attrs)]);
1270
1318
  }
1271
1319
 
1272
1320
  // src/engine/commands/selection-marks.ts
@@ -1285,8 +1333,8 @@ function textRanges(state, selection) {
1285
1333
  if (from.region !== to.region) return [];
1286
1334
  return [{ block: from.block, region: from.region, from: from.offset, to: to.offset }];
1287
1335
  }
1288
- const first = chunkAIS37SL2_cjs.requireBlockIndex(doc, from.block);
1289
- const last = chunkAIS37SL2_cjs.requireBlockIndex(doc, to.block);
1336
+ const first = chunkWZA5S5EJ_cjs.requireBlockIndex(doc, from.block);
1337
+ const last = chunkWZA5S5EJ_cjs.requireBlockIndex(doc, to.block);
1290
1338
  return doc.blocks.slice(first, last + 1).flatMap((block, i) => {
1291
1339
  const whole = wholeRegion(schema, block);
1292
1340
  if (whole === null) return [];
@@ -1298,7 +1346,7 @@ function textRanges(state, selection) {
1298
1346
  function selectionRanges(state, selection) {
1299
1347
  if (selection.kind === "text") return textRanges(state, selection);
1300
1348
  return selectedBlockIds(state.doc, selection).flatMap((id) => {
1301
- const whole = wholeRegion(state.schema, state.doc.blocks[chunkAIS37SL2_cjs.requireBlockIndex(state.doc, id)]);
1349
+ const whole = wholeRegion(state.schema, state.doc.blocks[chunkWZA5S5EJ_cjs.requireBlockIndex(state.doc, id)]);
1302
1350
  return whole === null ? [] : [whole];
1303
1351
  });
1304
1352
  }
@@ -1307,8 +1355,8 @@ function markRanges(state) {
1307
1355
  return selection === null ? [] : selectionRanges(state, selection).filter((range) => range.from < range.to);
1308
1356
  }
1309
1357
  function rangeContent(state, range) {
1310
- const inline = chunkAIS37SL2_cjs.blockById(state.doc, range.block)?.regions[range.region] ?? [];
1311
- return chunkAIS37SL2_cjs.sliceInline(inline, range.from, range.to);
1358
+ const inline = chunkWZA5S5EJ_cjs.blockById(state.doc, range.block)?.regions[range.region] ?? [];
1359
+ return chunkWZA5S5EJ_cjs.sliceInline(inline, range.from, range.to);
1312
1360
  }
1313
1361
  function markCoverage(content, type, attrs) {
1314
1362
  const carries = (node) => node.marks.some((mark) => matchesMark(mark, type, attrs));
@@ -1351,8 +1399,8 @@ function applyMark(type, attrs, mode) {
1351
1399
  const current = caretMarks(state.doc, state.schema, state.storedMarks, caret);
1352
1400
  const active = current.some((existing) => matchesMark(existing, type, mark.attrs));
1353
1401
  const remove2 = mode === "remove" || mode === "toggle" && active;
1354
- const next = remove2 ? chunkAIS37SL2_cjs.removeMark(current, target) : chunkAIS37SL2_cjs.addMark(current, mark);
1355
- if (chunkAIS37SL2_cjs.sameMarkSet(next, current)) return false;
1402
+ const next = remove2 ? chunkWZA5S5EJ_cjs.removeMark(current, target) : chunkWZA5S5EJ_cjs.addMark(current, mark);
1403
+ if (chunkWZA5S5EJ_cjs.sameMarkSet(next, current)) return false;
1356
1404
  dispatch?.(new Transaction(state).setStoredMarks(next));
1357
1405
  return true;
1358
1406
  }
@@ -1376,17 +1424,17 @@ function unsetMark(type) {
1376
1424
  function linkRanges(state) {
1377
1425
  const caret = collapsedCaret(state);
1378
1426
  if (caret === null) return markRanges(state);
1379
- const inline = chunkAIS37SL2_cjs.blockById(state.doc, caret.block)?.regions[caret.region] ?? [];
1427
+ const inline = chunkWZA5S5EJ_cjs.blockById(state.doc, caret.block)?.regions[caret.region] ?? [];
1380
1428
  const extent = markExtent(inline, caret.offset, "link");
1381
1429
  return extent === null ? [] : [{ block: caret.block, region: caret.region, ...extent }];
1382
1430
  }
1383
1431
  function setLink(href, title) {
1384
- const safe = chunkAIS37SL2_cjs.sanitizeHref(href);
1432
+ const safe = chunkWZA5S5EJ_cjs.sanitizeHref(href);
1385
1433
  return (state, dispatch) => {
1386
1434
  if (safe === null || safe === "") return false;
1387
1435
  const link = { type: "link", attrs: title ? { href: safe, title } : { href: safe } };
1388
1436
  return editRanges(state, dispatch, linkRanges(state), (tr, { block, region, from, to }, content) => {
1389
- const linked2 = content.every((node) => node.marks.some((mark) => chunkAIS37SL2_cjs.sameMark(mark, link)));
1437
+ const linked2 = content.every((node) => node.marks.some((mark) => chunkWZA5S5EJ_cjs.sameMark(mark, link)));
1390
1438
  if (!linked2) tr.step(addMarkStep(block, region, from, to, link));
1391
1439
  });
1392
1440
  };
@@ -1416,7 +1464,7 @@ function insertAtom(type, attrs) {
1416
1464
  const tr = new Transaction(state);
1417
1465
  const { from, to } = orderedRange(doc, selection.anchor, selection.head);
1418
1466
  const caret = deleteRange(tr, schema, from, to);
1419
- const node = chunkAIS37SL2_cjs.atom(type, attrs, caretMarks(tr.doc, schema, tr.storedMarks, caret));
1467
+ const node = chunkWZA5S5EJ_cjs.atom(type, attrs, caretMarks(tr.doc, schema, tr.storedMarks, caret));
1420
1468
  tr.step(replaceInlineStep(caret.block, caret.region, caret.offset, caret.offset, [node]));
1421
1469
  tr.setSelection(textSelection({ ...caret, offset: caret.offset + 1 }));
1422
1470
  dispatch?.(tr);
@@ -1434,19 +1482,19 @@ var TEXT_ATTRIBUTE = /* @__PURE__ */ new Map([
1434
1482
  ["MATH", "latex"]
1435
1483
  ]);
1436
1484
  function holdsText(schema, type) {
1437
- return TEXT_ATTRIBUTE.has(type) || chunkAIS37SL2_cjs.specFor(schema, type).flow === "text";
1485
+ return TEXT_ATTRIBUTE.has(type) || chunkWZA5S5EJ_cjs.specFor(schema, type).flow === "text";
1438
1486
  }
1439
1487
  function sourceContent(schema, block) {
1440
1488
  const field = TEXT_ATTRIBUTE.get(block.type);
1441
1489
  if (field !== void 0) {
1442
1490
  const value = block.attrs[field];
1443
- return typeof value === "string" && value !== "" ? [chunkAIS37SL2_cjs.text(value)] : [];
1491
+ return typeof value === "string" && value !== "" ? [chunkWZA5S5EJ_cjs.text(value)] : [];
1444
1492
  }
1445
1493
  const region = primaryRegion(schema, block);
1446
1494
  return region === null ? [] : block.regions[region];
1447
1495
  }
1448
1496
  function plainText(schema, content) {
1449
- return chunkAIS37SL2_cjs.inlineText(content, (node) => schema.atoms.get(node.type)?.plainText(node.attrs) ?? "");
1497
+ return chunkWZA5S5EJ_cjs.inlineText(content, (node) => schema.atoms.get(node.type)?.plainText(node.attrs) ?? "");
1450
1498
  }
1451
1499
  function convert(schema, block, type, attrs) {
1452
1500
  const content = sourceContent(schema, block);
@@ -1465,7 +1513,7 @@ function setBlockType(type, attrs = {}) {
1465
1513
  if (!holdsText(schema, type)) return false;
1466
1514
  const ids = selectedBlockIds(doc, selection);
1467
1515
  const convertible = (block) => isTextFlow(schema, block) || selection?.kind === "node" && TEXT_ATTRIBUTE.has(block.type);
1468
- const blocks = ids.flatMap((id) => chunkAIS37SL2_cjs.blockById(doc, id) ?? []).filter(convertible);
1516
+ const blocks = ids.flatMap((id) => chunkWZA5S5EJ_cjs.blockById(doc, id) ?? []).filter(convertible);
1469
1517
  if (blocks.length === 0) return false;
1470
1518
  const tr = new Transaction(state);
1471
1519
  const moved2 = /* @__PURE__ */ new Map();
@@ -1479,7 +1527,7 @@ function setBlockType(type, attrs = {}) {
1479
1527
  tr.step(replaceBlockStep(next));
1480
1528
  const from = primaryRegion(schema, block);
1481
1529
  const to = primaryRegion(schema, next);
1482
- if (from !== null && to !== null) moved2.set(block.id, { from, to, length: chunkAIS37SL2_cjs.inlineLength(next.regions[to]) });
1530
+ if (from !== null && to !== null) moved2.set(block.id, { from, to, length: chunkWZA5S5EJ_cjs.inlineLength(next.regions[to]) });
1483
1531
  }
1484
1532
  if (!tr.docChanged) return false;
1485
1533
  if (selection?.kind === "text" && moved2.size > 0) {
@@ -1490,7 +1538,7 @@ function setBlockType(type, attrs = {}) {
1490
1538
  };
1491
1539
  tr.setSelection(textSelection(carry(selection.anchor), carry(selection.head)));
1492
1540
  }
1493
- const converted = selection?.kind === "node" ? chunkAIS37SL2_cjs.blockById(tr.doc, selection.block) : void 0;
1541
+ const converted = selection?.kind === "node" ? chunkWZA5S5EJ_cjs.blockById(tr.doc, selection.block) : void 0;
1494
1542
  if (converted !== void 0 && isTextFlow(schema, converted)) tr.setSelection(endOf(tr.doc, schema, converted.id));
1495
1543
  dispatch?.(tr);
1496
1544
  return true;
@@ -1508,10 +1556,10 @@ function ruleTransaction(state, rules, context) {
1508
1556
  const { selection, doc } = state;
1509
1557
  if (selection?.kind !== "text") return null;
1510
1558
  const { block: id, region, offset } = selection.head;
1511
- const block = doc.blocks[chunkAIS37SL2_cjs.requireBlockIndex(doc, id)];
1559
+ const block = doc.blocks[chunkWZA5S5EJ_cjs.requireBlockIndex(doc, id)];
1512
1560
  const inline = block.regions[region];
1513
- if (chunkAIS37SL2_cjs.hasMark(chunkAIS37SL2_cjs.marksAt(inline, offset, () => true), "code")) return null;
1514
- const before = chunkAIS37SL2_cjs.inlineText(chunkAIS37SL2_cjs.sliceInline(inline, 0, offset));
1561
+ if (chunkWZA5S5EJ_cjs.hasMark(chunkWZA5S5EJ_cjs.marksAt(inline, offset, () => true), "code")) return null;
1562
+ const before = chunkWZA5S5EJ_cjs.inlineText(chunkWZA5S5EJ_cjs.sliceInline(inline, 0, offset));
1515
1563
  for (const rule of rules) {
1516
1564
  const match = appliesTo(rule, block) ? rule.match.exec(before) : null;
1517
1565
  if (match === null) continue;
@@ -1521,7 +1569,7 @@ function ruleTransaction(state, rules, context) {
1521
1569
  return null;
1522
1570
  }
1523
1571
  function insertTextWithRules(value, rules, options = {}) {
1524
- const context = { newId: options.newId ?? chunkAIS37SL2_cjs.newId };
1572
+ const context = { newId: options.newId ?? chunkWZA5S5EJ_cjs.newId };
1525
1573
  const insert = insertText(value, { origin: "input", newId: context.newId });
1526
1574
  return (state, dispatch) => {
1527
1575
  let fired = false;
@@ -1569,11 +1617,11 @@ var divider = {
1569
1617
  kinds: PARAGRAPH,
1570
1618
  handler(state, _match, range, context) {
1571
1619
  const { doc, schema } = state;
1572
- const index = chunkAIS37SL2_cjs.requireBlockIndex(doc, range.block);
1620
+ const index = chunkWZA5S5EJ_cjs.requireBlockIndex(doc, range.block);
1573
1621
  const block = doc.blocks[index];
1574
1622
  const content = block.regions[range.region];
1575
- const tail = chunkAIS37SL2_cjs.sliceInline(content, range.to, chunkAIS37SL2_cjs.inlineLength(content));
1576
- const empty = createBlock(schema, schema.defaultTextBlock, {}, block.indent, (context?.newId ?? chunkAIS37SL2_cjs.newId)());
1623
+ const tail = chunkWZA5S5EJ_cjs.sliceInline(content, range.to, chunkWZA5S5EJ_cjs.inlineLength(content));
1624
+ const empty = createBlock(schema, schema.defaultTextBlock, {}, block.indent, (context?.newId ?? chunkWZA5S5EJ_cjs.newId)());
1577
1625
  const next = withContent(schema, empty, tail);
1578
1626
  const tr = new Transaction(state);
1579
1627
  tr.step(replaceBlockStep(createBlock(schema, "DIVIDER", {}, block.indent, block.id)));
@@ -1609,7 +1657,7 @@ var blockInputRules = [
1609
1657
 
1610
1658
  // src/engine/markdown/autolink-href.ts
1611
1659
  function autolinkHref(url) {
1612
- return chunkAIS37SL2_cjs.sanitizeHref(/^www\./i.test(url) ? `https://${url}` : url);
1660
+ return chunkWZA5S5EJ_cjs.sanitizeHref(/^www\./i.test(url) ? `https://${url}` : url);
1613
1661
  }
1614
1662
 
1615
1663
  // src/engine/markdown/trim-url-end.ts
@@ -1631,12 +1679,12 @@ function trimUrlEnd(url) {
1631
1679
 
1632
1680
  // src/engine/rules/region-inline.ts
1633
1681
  function regionInline(state, range) {
1634
- return state.doc.blocks[chunkAIS37SL2_cjs.requireBlockIndex(state.doc, range.block)].regions[range.region];
1682
+ return state.doc.blocks[chunkWZA5S5EJ_cjs.requireBlockIndex(state.doc, range.block)].regions[range.region];
1635
1683
  }
1636
1684
 
1637
1685
  // src/engine/rules/touches-mark.ts
1638
1686
  function touchesMark(inline, from, to, type) {
1639
- return chunkAIS37SL2_cjs.sliceInline(inline, from, to).some((node) => chunkAIS37SL2_cjs.hasMark(node.marks, type));
1687
+ return chunkWZA5S5EJ_cjs.sliceInline(inline, from, to).some((node) => chunkWZA5S5EJ_cjs.hasMark(node.marks, type));
1640
1688
  }
1641
1689
 
1642
1690
  // src/engine/rules/autolink.ts
@@ -1670,7 +1718,7 @@ function markRule({ name, match, open, close, wordBounded = false, mark }) {
1670
1718
  const contentTo = to - (close?.(found) ?? open);
1671
1719
  const contentFrom = contentTo - found[1].length;
1672
1720
  const from = contentFrom - open;
1673
- if (wordBounded && WORD_CHARACTER.test(chunkAIS37SL2_cjs.inlineText(chunkAIS37SL2_cjs.sliceInline(inline, to, to + 1)))) return null;
1721
+ if (wordBounded && WORD_CHARACTER.test(chunkWZA5S5EJ_cjs.inlineText(chunkWZA5S5EJ_cjs.sliceInline(inline, to, to + 1)))) return null;
1674
1722
  if (touchesMark(inline, from, contentFrom, "code") || touchesMark(inline, contentTo, to, "code")) return null;
1675
1723
  const tr = new Transaction(state);
1676
1724
  tr.step(addMarkStep(block, region, contentFrom, contentTo, added));
@@ -1678,7 +1726,7 @@ function markRule({ name, match, open, close, wordBounded = false, mark }) {
1678
1726
  tr.step(replaceInlineStep(block, region, from, contentFrom, []));
1679
1727
  const caret = { block, region, offset: from + found[1].length };
1680
1728
  const carried = caretMarks(tr.doc, state.schema, null, caret);
1681
- return tr.setSelection(textSelection(caret)).setStoredMarks(chunkAIS37SL2_cjs.removeMark(carried, added.type));
1729
+ return tr.setSelection(textSelection(caret)).setStoredMarks(chunkWZA5S5EJ_cjs.removeMark(carried, added.type));
1682
1730
  }
1683
1731
  };
1684
1732
  }
@@ -1699,7 +1747,7 @@ var markInputRules = [
1699
1747
  open: 1,
1700
1748
  close: (match) => match[2].length + 3,
1701
1749
  mark(match) {
1702
- const href = chunkAIS37SL2_cjs.sanitizeHref(match[2]);
1750
+ const href = chunkWZA5S5EJ_cjs.sanitizeHref(match[2]);
1703
1751
  return href === null ? null : { type: "link", attrs: { href } };
1704
1752
  }
1705
1753
  }),
@@ -1717,7 +1765,7 @@ function replacing(name, match, replacement) {
1717
1765
  handler(state, found, range) {
1718
1766
  const value = typeof replacement === "string" ? replacement : replacement(found);
1719
1767
  const from = range.to - (found[1] ?? found[0]).length;
1720
- const node = chunkAIS37SL2_cjs.text(value, chunkAIS37SL2_cjs.marksAt(regionInline(state, range), range.to, () => true));
1768
+ const node = chunkWZA5S5EJ_cjs.text(value, chunkWZA5S5EJ_cjs.marksAt(regionInline(state, range), range.to, () => true));
1721
1769
  return new Transaction(state).step(replaceInlineStep(range.block, range.region, from, range.to, [node]));
1722
1770
  }
1723
1771
  };
@@ -2001,7 +2049,7 @@ function nearestPaletteColor(css, kind) {
2001
2049
  const table = PALETTE_RGB[kind];
2002
2050
  let best = "default";
2003
2051
  let least = Infinity;
2004
- for (const name of chunkAIS37SL2_cjs.PALETTE) {
2052
+ for (const name of chunkWZA5S5EJ_cjs.PALETTE) {
2005
2053
  for (const reference of table[name]) {
2006
2054
  const gap = distance(rgb, reference);
2007
2055
  if (gap < least) {
@@ -2015,31 +2063,31 @@ function nearestPaletteColor(css, kind) {
2015
2063
 
2016
2064
  // src/engine/clipboard/html-marks.ts
2017
2065
  function linkMark(element) {
2018
- const href = chunkAIS37SL2_cjs.sanitizeHref(element.getAttribute("href") ?? "");
2066
+ const href = chunkWZA5S5EJ_cjs.sanitizeHref(element.getAttribute("href") ?? "");
2019
2067
  if (href === null || href === "") return null;
2020
2068
  const title = element.getAttribute("title");
2021
2069
  return { type: "link", attrs: title ? { href, title } : { href } };
2022
2070
  }
2023
2071
  function highlightMark(element) {
2024
2072
  const color = element.getAttribute("data-color") ?? "";
2025
- return chunkAIS37SL2_cjs.isPaletteColor(color) ? { type: "highlight", attrs: { color } } : { type: "highlight" };
2073
+ return chunkWZA5S5EJ_cjs.isPaletteColor(color) ? { type: "highlight", attrs: { color } } : { type: "highlight" };
2026
2074
  }
2027
2075
  function elementMarks(element, inherited) {
2028
2076
  const tag = tagName(element);
2029
2077
  const styles = parseStyle(element.getAttribute("style"));
2030
2078
  let marks = inherited;
2031
2079
  const add = (mark) => {
2032
- marks = chunkAIS37SL2_cjs.addMark(marks, mark);
2080
+ marks = chunkWZA5S5EJ_cjs.addMark(marks, mark);
2033
2081
  };
2034
2082
  const link = tag === "a" ? linkMark(element) : null;
2035
2083
  if (link !== null) add(link);
2036
- const linked2 = chunkAIS37SL2_cjs.hasMark(marks, "link");
2084
+ const linked2 = chunkWZA5S5EJ_cjs.hasMark(marks, "link");
2037
2085
  const weight = fontWeight(styles);
2038
2086
  if (weight !== null ? weight >= 600 : tag === "b" || tag === "strong") add({ type: "bold" });
2039
- else if (weight !== null) marks = chunkAIS37SL2_cjs.removeMark(marks, "bold");
2087
+ else if (weight !== null) marks = chunkWZA5S5EJ_cjs.removeMark(marks, "bold");
2040
2088
  const slanted = isItalicStyle(styles);
2041
2089
  if (slanted ?? (tag === "i" || tag === "em")) add({ type: "italic" });
2042
- else if (slanted === false) marks = chunkAIS37SL2_cjs.removeMark(marks, "italic");
2090
+ else if (slanted === false) marks = chunkWZA5S5EJ_cjs.removeMark(marks, "italic");
2043
2091
  if (tag === "u" || !linked2 && hasDecoration(styles, "underline")) add({ type: "underline" });
2044
2092
  if (tag === "s" || tag === "del" || tag === "strike" || hasDecoration(styles, "line-through")) {
2045
2093
  add({ type: "strike" });
@@ -2058,7 +2106,7 @@ function elementMarks(element, inherited) {
2058
2106
  }
2059
2107
 
2060
2108
  // src/engine/clipboard/hoist-spaces.ts
2061
- var shared = (a, b) => a.filter((mark) => b.some((other) => chunkAIS37SL2_cjs.sameMark(mark, other)));
2109
+ var shared = (a, b) => a.filter((mark) => b.some((other) => chunkWZA5S5EJ_cjs.sameMark(mark, other)));
2062
2110
  function hoistEdgeSpaces(pieces) {
2063
2111
  const result = [];
2064
2112
  pieces.forEach((piece, at) => {
@@ -2121,7 +2169,7 @@ function finish({ pieces }) {
2121
2169
  break;
2122
2170
  }
2123
2171
  }
2124
- const inline = chunkAIS37SL2_cjs.normalizeInline(hoistEdgeSpaces(pieces).map((piece) => chunkAIS37SL2_cjs.text(piece.text, piece.marks)));
2172
+ const inline = chunkWZA5S5EJ_cjs.normalizeInline(hoistEdgeSpaces(pieces).map((piece) => chunkWZA5S5EJ_cjs.text(piece.text, piece.marks)));
2125
2173
  return inline.every((node) => node.kind === "text" && node.text.trim() === "") ? [] : inline;
2126
2174
  }
2127
2175
  function visit(acc, node, style, depth) {
@@ -2218,7 +2266,7 @@ function wordListItem(paragraph, ctx, sink) {
2218
2266
 
2219
2267
  // src/engine/clipboard/html-media.ts
2220
2268
  function imageBlock(img, caption, ctx, sink) {
2221
- const url = chunkAIS37SL2_cjs.sanitizeHref(img.getAttribute("src") ?? "");
2269
+ const url = chunkWZA5S5EJ_cjs.sanitizeHref(img.getAttribute("src") ?? "");
2222
2270
  if (url === null || url === "") return;
2223
2271
  emit(sink, "IMAGE", ctx.indent, { storageKey: "", alt: img.getAttribute("alt") ?? "", url }, { caption });
2224
2272
  }
@@ -2256,7 +2304,7 @@ function tableBlock(table, ctx, sink) {
2256
2304
  rows.forEach((row, r) => {
2257
2305
  for (let c = 0; c < cols; c++) {
2258
2306
  const cell = row.cells[c];
2259
- regions[chunkAIS37SL2_cjs.cellKey(r, c)] = cell === void 0 ? [] : inlineFromNodes(cell.childNodes, ctx);
2307
+ regions[chunkWZA5S5EJ_cjs.cellKey(r, c)] = cell === void 0 ? [] : inlineFromNodes(cell.childNodes, ctx);
2260
2308
  }
2261
2309
  });
2262
2310
  const header = rows[0].head || rows[0].cells.some((cell) => tagName(cell) === "th");
@@ -2269,7 +2317,7 @@ var HEADING = /^h([1-6])$/;
2269
2317
  function emitRun(run, ctx, sink) {
2270
2318
  const inline = inlineFromNodes(run, ctx);
2271
2319
  if (inline.length === 0) return;
2272
- const plain = ctx.run.kind === "heading" ? chunkAIS37SL2_cjs.removeMarkRange(inline, 0, chunkAIS37SL2_cjs.inlineLength(inline), "bold") : inline;
2320
+ const plain = ctx.run.kind === "heading" ? chunkWZA5S5EJ_cjs.removeMarkRange(inline, 0, chunkWZA5S5EJ_cjs.inlineLength(inline), "bold") : inline;
2273
2321
  emitText(sink, ctx.indent, ctx.run, plain);
2274
2322
  }
2275
2323
  function details(element, ctx, sink) {
@@ -2354,8 +2402,8 @@ function availableParser(parser) {
2354
2402
  function fromHTML(html, options = {}) {
2355
2403
  const parser = availableParser(options.parser);
2356
2404
  if (parser === null) throw new Error("fromHTML needs a DOMParser");
2357
- const makeId = options.newId ?? chunkAIS37SL2_cjs.newId;
2358
- const codec = chunkAIS37SL2_cjs.createBlockCodec(chunkAIS37SL2_cjs.createSchema(), { newId: makeId });
2405
+ const makeId = options.newId ?? chunkWZA5S5EJ_cjs.newId;
2406
+ const codec = chunkWZA5S5EJ_cjs.createBlockCodec(chunkWZA5S5EJ_cjs.createSchema(), { newId: makeId });
2359
2407
  const { body } = parser.parseFromString(html, "text/html");
2360
2408
  return blocksFromBody(body, makeId).map((block) => codec.toQuoin(block));
2361
2409
  }
@@ -2376,7 +2424,7 @@ function quoteLines(text2) {
2376
2424
 
2377
2425
  // src/engine/markdown/document/block-forms.ts
2378
2426
  var ALERT_NAMES = new Map(
2379
- Object.entries(chunkAIS37SL2_cjs.ALERT_TONES).map(([name, tone]) => [tone, name])
2427
+ Object.entries(chunkWZA5S5EJ_cjs.ALERT_TONES).map(([name, tone]) => [tone, name])
2380
2428
  );
2381
2429
  var DELIMITERS = /* @__PURE__ */ new Map([
2382
2430
  ["left", ":--"],
@@ -2386,8 +2434,8 @@ var DELIMITERS = /* @__PURE__ */ new Map([
2386
2434
  var MIN_FENCE = 3;
2387
2435
  var FENCE_LIKE_MATH_LINE = /^ {0,3}\${2,}[ \t]*$/m;
2388
2436
  function calloutMarkdown(data) {
2389
- const name = ALERT_NAMES.get(chunkAIS37SL2_cjs.str(data.tone)) ?? "NOTE";
2390
- const body = chunkAIS37SL2_cjs.str(data.body);
2437
+ const name = ALERT_NAMES.get(chunkWZA5S5EJ_cjs.str(data.tone)) ?? "NOTE";
2438
+ const body = chunkWZA5S5EJ_cjs.str(data.body);
2391
2439
  return quoteLines(body === "" ? `[!${name}]` : `[!${name}]
2392
2440
  ${body}`);
2393
2441
  }
@@ -2401,18 +2449,18 @@ function longestRun(value, char) {
2401
2449
  return longest;
2402
2450
  }
2403
2451
  function codeMarkdown(data) {
2404
- const code = chunkAIS37SL2_cjs.str(data.code);
2405
- const info = chunkAIS37SL2_cjs.str(data.language);
2452
+ const code = chunkWZA5S5EJ_cjs.str(data.code);
2453
+ const info = chunkWZA5S5EJ_cjs.str(data.language);
2406
2454
  const char = info.includes("`") ? "~" : "`";
2407
2455
  const fence = char.repeat(Math.max(MIN_FENCE, longestRun(code, char) + 1));
2408
2456
  return [fence + info.replace(/[\\&]/g, "\\$&"), ...code === "" ? [] : code.split("\n"), fence].join("\n");
2409
2457
  }
2410
2458
  function mathMarkdown(data) {
2411
- const latex = chunkAIS37SL2_cjs.str(data.latex);
2459
+ const latex = chunkWZA5S5EJ_cjs.str(data.latex);
2412
2460
  if (FENCE_LIKE_MATH_LINE.test(latex)) return null;
2413
2461
  return ["$$", ...latex === "" ? [] : latex.split("\n"), "$$"].join("\n");
2414
2462
  }
2415
- var cellsOf = (row) => Array.isArray(row) ? row.map(chunkAIS37SL2_cjs.str) : [];
2463
+ var cellsOf = (row) => Array.isArray(row) ? row.map(chunkWZA5S5EJ_cjs.str) : [];
2416
2464
  var rowMarkdown = (cells) => `| ${cells.join(" | ")} |`;
2417
2465
  function tableMarkdown(data) {
2418
2466
  const rows = Array.isArray(data.rows) ? data.rows.map(cellsOf) : [];
@@ -2439,7 +2487,7 @@ function needsComment(block, residual, schema, ctx) {
2439
2487
  const native = NATIVE_KEYS.get(block.type);
2440
2488
  if (!native) return false;
2441
2489
  if (residual > 0) return true;
2442
- return Object.keys(chunkAIS37SL2_cjs.specFor(schema, block.type).toData(block, ctx)).some((key) => !native.includes(key));
2490
+ return Object.keys(chunkWZA5S5EJ_cjs.specFor(schema, block.type).toData(block, ctx)).some((key) => !native.includes(key));
2443
2491
  }
2444
2492
 
2445
2493
  // src/engine/markdown/document/comment-markdown.ts
@@ -2453,41 +2501,41 @@ function quoinComment(type, data, indent2) {
2453
2501
  // src/engine/markdown/document/link-forms.ts
2454
2502
  var oneLine = (value) => value.replace(/[\r\n]+/g, " ");
2455
2503
  function linked(label, href, ctx) {
2456
- return ctx.inline.serialize([chunkAIS37SL2_cjs.text(label || href, [{ type: "link", attrs: { href } }])]);
2504
+ return ctx.inline.serialize([chunkWZA5S5EJ_cjs.text(label || href, [{ type: "link", attrs: { href } }])]);
2457
2505
  }
2458
2506
  var assetUrl = (storageKey, ctx) => storageKey === "" ? "" : ctx.resolveAssetUrl(storageKey);
2459
2507
  function imageMarkdown(data, ctx) {
2460
- const href = chunkAIS37SL2_cjs.str(data.url) || assetUrl(chunkAIS37SL2_cjs.str(data.storageKey), ctx);
2508
+ const href = chunkWZA5S5EJ_cjs.str(data.url) || assetUrl(chunkWZA5S5EJ_cjs.str(data.storageKey), ctx);
2461
2509
  if (href === "") return null;
2462
- const caption = chunkAIS37SL2_cjs.str(data.caption);
2463
- const alt = ctx.inline.serialize([chunkAIS37SL2_cjs.text(oneLine(chunkAIS37SL2_cjs.str(data.alt)))]);
2464
- return `![${alt}${chunkAIS37SL2_cjs.linkClose({ type: "link", attrs: caption ? { href, title: caption } : { href } }, false)}`;
2510
+ const caption = chunkWZA5S5EJ_cjs.str(data.caption);
2511
+ const alt = ctx.inline.serialize([chunkWZA5S5EJ_cjs.text(oneLine(chunkWZA5S5EJ_cjs.str(data.alt)))]);
2512
+ return `![${alt}${chunkWZA5S5EJ_cjs.linkClose({ type: "link", attrs: caption ? { href, title: caption } : { href } }, false)}`;
2465
2513
  }
2466
2514
  function fileMarkdown(data, ctx) {
2467
- const href = assetUrl(chunkAIS37SL2_cjs.str(data.storageKey), ctx);
2468
- return href === "" ? null : linked(oneLine(chunkAIS37SL2_cjs.str(data.filename)), href, ctx);
2515
+ const href = assetUrl(chunkWZA5S5EJ_cjs.str(data.storageKey), ctx);
2516
+ return href === "" ? null : linked(oneLine(chunkWZA5S5EJ_cjs.str(data.filename)), href, ctx);
2469
2517
  }
2470
2518
  function embedMarkdown(data, ctx) {
2471
- const url = chunkAIS37SL2_cjs.str(data.url);
2519
+ const url = chunkWZA5S5EJ_cjs.str(data.url);
2472
2520
  return url === "" ? null : linked(url, url, ctx);
2473
2521
  }
2474
2522
  function bookmarkMarkdown(data, ctx) {
2475
- const url = chunkAIS37SL2_cjs.str(data.url);
2476
- return url === "" ? null : linked(oneLine(chunkAIS37SL2_cjs.str(data.title)), url, ctx);
2523
+ const url = chunkWZA5S5EJ_cjs.str(data.url);
2524
+ return url === "" ? null : linked(oneLine(chunkWZA5S5EJ_cjs.str(data.title)), url, ctx);
2477
2525
  }
2478
2526
 
2479
2527
  // src/engine/markdown/document/block-markdown.ts
2480
2528
  var QUOTE_PREFIX = "> ";
2481
2529
  function markdownLine(block, data) {
2482
2530
  const kind = block.attrs.kind ?? "paragraph";
2483
- const markdown = chunkAIS37SL2_cjs.str(data.markdown);
2484
- const empty = chunkAIS37SL2_cjs.inlineLength(block.regions.text ?? []) === 0;
2531
+ const markdown = chunkWZA5S5EJ_cjs.str(data.markdown);
2532
+ const empty = chunkWZA5S5EJ_cjs.inlineLength(block.regions.text ?? []) === 0;
2485
2533
  if (empty && (kind === "paragraph" || kind === "quote")) return null;
2486
2534
  return kind === "quote" ? quoteLines(markdown.slice(QUOTE_PREFIX.length)) : markdown;
2487
2535
  }
2488
2536
  function toggleMarkdown(data) {
2489
2537
  return `<details${data.open === true ? " open" : ""}>
2490
- <summary>${chunkAIS37SL2_cjs.str(data.markdown)}</summary>`;
2538
+ <summary>${chunkWZA5S5EJ_cjs.str(data.markdown)}</summary>`;
2491
2539
  }
2492
2540
  function coreMarkdown(block, data, env, residual) {
2493
2541
  switch (block.type) {
@@ -2520,9 +2568,9 @@ function coreMarkdown(block, data, env, residual) {
2520
2568
  }
2521
2569
  }
2522
2570
  function blockMarkdown(block, env, { residual, asComment }) {
2523
- const spec = chunkAIS37SL2_cjs.specFor(env.schema, block.type);
2571
+ const spec = chunkWZA5S5EJ_cjs.specFor(env.schema, block.type);
2524
2572
  const data = spec.toData(block, env.ctx);
2525
- const comment = () => chunkAIS37SL2_cjs.isQuoinType(block.type) ? quoinComment(block.type, data, residual) : null;
2573
+ const comment = () => chunkWZA5S5EJ_cjs.isQuoinType(block.type) ? quoinComment(block.type, data, residual) : null;
2526
2574
  if (asComment || env.lossless && !hasNativeForm(block.type)) return comment();
2527
2575
  const written = spec.toMarkdown ? spec.toMarkdown(block, env.ctx) : coreMarkdown(block, data, env, residual);
2528
2576
  if (written !== null) return written;
@@ -2552,7 +2600,7 @@ function createListContext() {
2552
2600
  let placed = block;
2553
2601
  let number = 1;
2554
2602
  if (line2 === "ordered") {
2555
- number = Math.min(runs.get(block.indent) ?? chunkAIS37SL2_cjs.orderedStart(block.attrs.start), chunkAIS37SL2_cjs.MAX_MARKER_NUMBER);
2603
+ number = Math.min(runs.get(block.indent) ?? chunkWZA5S5EJ_cjs.orderedStart(block.attrs.start), chunkWZA5S5EJ_cjs.MAX_MARKER_NUMBER);
2556
2604
  runs.set(block.indent, number + 1);
2557
2605
  if (number !== block.attrs.start) placed = { ...block, attrs: { ...block.attrs, start: number } };
2558
2606
  } else {
@@ -2562,7 +2610,7 @@ function createListContext() {
2562
2610
  const hang = isItem2 ? (line2 === "ordered" ? String(number).length : 0) + 2 : 0;
2563
2611
  const container = comment ? void 0 : openedBy(block, prefix, hang);
2564
2612
  if (container) stack.push(container);
2565
- const bare = !comment && (line2 === "bullet" || line2 === "ordered") && chunkAIS37SL2_cjs.inlineLength(block.regions.text ?? []) === 0;
2613
+ const bare = !comment && (line2 === "bullet" || line2 === "ordered") && chunkWZA5S5EJ_cjs.inlineLength(block.regions.text ?? []) === 0;
2566
2614
  const fragile = isItem2 && (bare || line2 === "ordered" && number !== 1);
2567
2615
  const shown = comment ? void 0 : line2;
2568
2616
  return { block: placed, line: shown, prefix, hang, residual, parent, container, closed, bare, fragile, comment };
@@ -2580,7 +2628,7 @@ function stripComments(block) {
2580
2628
  regions: Object.fromEntries(
2581
2629
  regions.map(([name, inline]) => [
2582
2630
  name,
2583
- hasCommentMark(inline) ? chunkAIS37SL2_cjs.removeMarkRange(inline, 0, chunkAIS37SL2_cjs.inlineLength(inline), "comment") : inline
2631
+ hasCommentMark(inline) ? chunkWZA5S5EJ_cjs.removeMarkRange(inline, 0, chunkWZA5S5EJ_cjs.inlineLength(inline), "comment") : inline
2584
2632
  ])
2585
2633
  )
2586
2634
  };
@@ -2609,7 +2657,7 @@ function pieceOf(text2, placement) {
2609
2657
  opened: placement.container,
2610
2658
  bare: placement.bare,
2611
2659
  fragile: placement.fragile,
2612
- leadsHtml: hang > 0 && chunkAIS37SL2_cjs.startsHtmlBlock(text2.split("\n")[0].slice(hang))
2660
+ leadsHtml: hang > 0 && chunkWZA5S5EJ_cjs.startsHtmlBlock(text2.split("\n")[0].slice(hang))
2613
2661
  };
2614
2662
  }
2615
2663
  function takenAsItemText(previous, { parent, line: line2 }) {
@@ -2634,8 +2682,8 @@ function join(pieces) {
2634
2682
  `;
2635
2683
  }
2636
2684
  function toMarkdown(blocks, options = {}) {
2637
- const schema = options.schema ?? chunkAIS37SL2_cjs.createSchema();
2638
- const codec = chunkAIS37SL2_cjs.createBlockCodec(schema);
2685
+ const schema = options.schema ?? chunkWZA5S5EJ_cjs.createSchema();
2686
+ const codec = chunkWZA5S5EJ_cjs.createBlockCodec(schema);
2639
2687
  const env = {
2640
2688
  schema,
2641
2689
  lossless: options.lossless === true,
@@ -2677,20 +2725,20 @@ function escapeAttr(value) {
2677
2725
 
2678
2726
  // src/engine/render/serialize-html.ts
2679
2727
  var VOID = /* @__PURE__ */ new Set(["br", "hr", "img", "input"]);
2680
- var attrsHtml = (node) => chunkAIS37SL2_cjs.writtenAttrs(node.attrs).map(([name, value]) => value === true ? ` ${name}` : ` ${name}="${escapeAttr(value)}"`).join("");
2728
+ var attrsHtml = (node) => chunkWZA5S5EJ_cjs.writtenAttrs(node.attrs).map(([name, value]) => value === true ? ` ${name}` : ` ${name}="${escapeAttr(value)}"`).join("");
2681
2729
  var serializeHtml = (nodes) => nodes.map(
2682
2730
  (node) => typeof node === "string" ? escapeHtml(node) : `<${node.tag}${attrsHtml(node)}>${VOID.has(node.tag) ? "" : `${node.html ?? serializeHtml(node.children)}</${node.tag}>`}`
2683
2731
  ).join("");
2684
2732
 
2685
2733
  // src/engine/render/to-html.ts
2686
- var toHTML = (blocks, options = {}) => serializeHtml(chunkAIS37SL2_cjs.documentNodes(blocks, options));
2734
+ var toHTML = (blocks, options = {}) => serializeHtml(chunkWZA5S5EJ_cjs.documentNodes(blocks, options));
2687
2735
 
2688
2736
  // src/engine/render/to-plain-text.ts
2689
2737
  function plainTextBlocks(blocks, schema) {
2690
- return chunkAIS37SL2_cjs.engineBlocksOf(blocks, schema).map((block) => chunkAIS37SL2_cjs.blockPlainText(block, schema));
2738
+ return chunkWZA5S5EJ_cjs.engineBlocksOf(blocks, schema).map((block) => chunkWZA5S5EJ_cjs.blockPlainText(block, schema));
2691
2739
  }
2692
2740
  function toPlainText(blocks, options = {}) {
2693
- return plainTextBlocks(blocks, options.schema ?? chunkAIS37SL2_cjs.createSchema()).join("\n");
2741
+ return plainTextBlocks(blocks, options.schema ?? chunkWZA5S5EJ_cjs.createSchema()).join("\n");
2694
2742
  }
2695
2743
 
2696
2744
  // src/engine/model/graphemes.ts
@@ -2742,7 +2790,7 @@ function countBlock(block, schema) {
2742
2790
  if (!blocks) counted.set(schema, blocks = /* @__PURE__ */ new WeakMap());
2743
2791
  const known = blocks.get(block);
2744
2792
  if (known) return known;
2745
- const text2 = chunkAIS37SL2_cjs.blockPlainText(block, schema);
2793
+ const text2 = chunkWZA5S5EJ_cjs.blockPlainText(block, schema);
2746
2794
  const stats = { characters: graphemeCount(text2), words: wordCount(text2) };
2747
2795
  blocks.set(block, stats);
2748
2796
  return stats;
@@ -2761,17 +2809,17 @@ function sum(blocks, schema) {
2761
2809
  return { characters, words: words2 };
2762
2810
  }
2763
2811
  function countText(blocks, options = {}) {
2764
- const schema = options.schema ?? (defaultSchema ??= chunkAIS37SL2_cjs.createSchema());
2765
- return sum(chunkAIS37SL2_cjs.engineBlocksOf(blocks, schema), schema);
2812
+ const schema = options.schema ?? (defaultSchema ??= chunkWZA5S5EJ_cjs.createSchema());
2813
+ return sum(chunkWZA5S5EJ_cjs.engineBlocksOf(blocks, schema), schema);
2766
2814
  }
2767
2815
  function countDoc(doc, options = {}) {
2768
- return sum(doc.blocks, options.schema ?? (defaultSchema ??= chunkAIS37SL2_cjs.createSchema()));
2816
+ return sum(doc.blocks, options.schema ?? (defaultSchema ??= chunkWZA5S5EJ_cjs.createSchema()));
2769
2817
  }
2770
2818
 
2771
2819
  // src/engine/commands/block-style.ts
2772
2820
  function patchBlocks(state, patch, only) {
2773
2821
  const changing = selectedBlockIds(state.doc, state.selection).filter((id) => {
2774
- const block = chunkAIS37SL2_cjs.blockById(state.doc, id);
2822
+ const block = chunkWZA5S5EJ_cjs.blockById(state.doc, id);
2775
2823
  return block !== void 0 && (only === void 0 || block.type === only) && patchChangesAttrs(block.attrs, patch);
2776
2824
  });
2777
2825
  if (changing.length === 0) return null;
@@ -2799,7 +2847,7 @@ function setBlockColor(colors) {
2799
2847
  const value = colors[key];
2800
2848
  if (value !== void 0) patch[key] = value ?? void 0;
2801
2849
  }
2802
- const valid = Object.values(patch).every((value) => value === void 0 || chunkAIS37SL2_cjs.isPaletteColor(value));
2850
+ const valid = Object.values(patch).every((value) => value === void 0 || chunkWZA5S5EJ_cjs.isPaletteColor(value));
2803
2851
  return valid ? patchCommand(patch, "MARKDOWN") : () => false;
2804
2852
  }
2805
2853
 
@@ -2819,7 +2867,7 @@ function textCaret(state) {
2819
2867
  const { doc, schema, selection } = state;
2820
2868
  if (selection?.kind !== "text" || !isCollapsed(selection)) return null;
2821
2869
  const pos = selection.head;
2822
- const index = chunkAIS37SL2_cjs.requireBlockIndex(doc, pos.block);
2870
+ const index = chunkWZA5S5EJ_cjs.requireBlockIndex(doc, pos.block);
2823
2871
  const block = doc.blocks[index];
2824
2872
  const inFlow2 = isTextFlow(schema, block) && pos.region === primaryRegion(schema, block);
2825
2873
  return inFlow2 ? { block, index, pos } : null;
@@ -2827,14 +2875,14 @@ function textCaret(state) {
2827
2875
  function joinInto(tr, schema, target, source) {
2828
2876
  const targetRegion = primaryRegion(schema, target) ?? "";
2829
2877
  tr.step(joinBlocksStep(target.id, targetRegion, source.id, primaryRegion(schema, source) ?? ""));
2830
- capIndents(tr, chunkAIS37SL2_cjs.requireBlockIndex(tr.doc, target.id) + 1);
2878
+ capIndents(tr, chunkWZA5S5EJ_cjs.requireBlockIndex(tr.doc, target.id) + 1);
2831
2879
  const offset = regionLength(target, targetRegion);
2832
2880
  tr.setSelection(textSelection({ block: target.id, region: targetRegion, offset }));
2833
2881
  }
2834
2882
  function joinIntoSummary(tr, schema, summary, source) {
2835
2883
  const region = primaryRegion(schema, summary) ?? "";
2836
2884
  const offset = regionLength(summary, region);
2837
- const index = chunkAIS37SL2_cjs.requireBlockIndex(tr.doc, source.id);
2885
+ const index = chunkWZA5S5EJ_cjs.requireBlockIndex(tr.doc, source.id);
2838
2886
  const content = source.regions[primaryRegion(schema, source) ?? ""];
2839
2887
  if (content.length > 0) tr.step(replaceInlineStep(summary.id, region, offset, offset, content));
2840
2888
  tr.step(removeBlocksStep(index, 1));
@@ -2906,7 +2954,7 @@ function deleteReaching(forward, reach) {
2906
2954
  const { selection } = state;
2907
2955
  if (selection?.kind !== "text" || !isCollapsed(selection)) return deleteSelection(state, dispatch);
2908
2956
  const { head } = selection;
2909
- const value = chunkAIS37SL2_cjs.inlineText(state.doc.blocks[chunkAIS37SL2_cjs.requireBlockIndex(state.doc, head.block)].regions[head.region]);
2957
+ const value = chunkWZA5S5EJ_cjs.inlineText(state.doc.blocks[chunkWZA5S5EJ_cjs.requireBlockIndex(state.doc, head.block)].regions[head.region]);
2910
2958
  if (forward ? head.offset >= value.length : head.offset <= 0) {
2911
2959
  return (forward ? deleteAtEnd : deleteAtStart)(state, dispatch);
2912
2960
  }
@@ -2960,8 +3008,8 @@ function movedBlockIds(doc, ids) {
2960
3008
  function gather(tr, runs, above) {
2961
3009
  let anchor = above;
2962
3010
  for (const run of runs) {
2963
- const from = chunkAIS37SL2_cjs.requireBlockIndex(tr.doc, run[0]);
2964
- const at = anchor === null ? -1 : chunkAIS37SL2_cjs.requireBlockIndex(tr.doc, anchor);
3011
+ const from = chunkWZA5S5EJ_cjs.requireBlockIndex(tr.doc, run[0]);
3012
+ const at = anchor === null ? -1 : chunkWZA5S5EJ_cjs.requireBlockIndex(tr.doc, anchor);
2965
3013
  const to = at < from ? at + 1 : at + 1 - run.length;
2966
3014
  if (to !== from) tr.step(moveBlocksStep(from, run.length, to));
2967
3015
  anchor = run[run.length - 1];
@@ -2989,7 +3037,7 @@ function moveBlocksTo(ids, toIndex, indent2) {
2989
3037
  const first = runs[0][0];
2990
3038
  const last = runs[runs.length - 1];
2991
3039
  const clamped = Math.min(Math.max(indent2, 0), above ? above.indent + 1 : 0);
2992
- reindent(tr, chunkAIS37SL2_cjs.requireBlockIndex(tr.doc, first), moved2.size, clamped);
3040
+ reindent(tr, chunkWZA5S5EJ_cjs.requireBlockIndex(tr.doc, first), moved2.size, clamped);
2993
3041
  if (!tr.docChanged) return false;
2994
3042
  dispatch?.(tr.setSelection(blockRangeSelection(first, last[last.length - 1])));
2995
3043
  return true;
@@ -3003,7 +3051,7 @@ var selectAll = (state, dispatch) => {
3003
3051
  let next = blockRangeSelection(doc.blocks[0].id, doc.blocks[doc.blocks.length - 1].id);
3004
3052
  if (selection?.kind === "text") {
3005
3053
  const { anchor, head } = selection;
3006
- const length = chunkAIS37SL2_cjs.inlineLength(doc.blocks[chunkAIS37SL2_cjs.requireBlockIndex(doc, head.block)].regions[head.region] ?? []);
3054
+ const length = chunkWZA5S5EJ_cjs.inlineLength(doc.blocks[chunkWZA5S5EJ_cjs.requireBlockIndex(doc, head.block)].regions[head.region] ?? []);
3007
3055
  const withinRegion = anchor.block === head.block && anchor.region === head.region;
3008
3056
  const covers = Math.min(anchor.offset, head.offset) === 0 && Math.max(anchor.offset, head.offset) === length;
3009
3057
  if (withinRegion && !covers) next = textSelection({ ...head, offset: 0 }, { ...head, offset: length });
@@ -3040,7 +3088,7 @@ function splitStep(schema, block, region, offset, id) {
3040
3088
  // src/engine/commands/split-at.ts
3041
3089
  function enterInHardBreakBlock({ tr, schema, block, index, pos, makeId }) {
3042
3090
  const length = regionLength(block, pos.region);
3043
- if (pos.offset === length && chunkAIS37SL2_cjs.inlineText(block.regions[pos.region]).endsWith("\n")) {
3091
+ if (pos.offset === length && chunkWZA5S5EJ_cjs.inlineText(block.regions[pos.region]).endsWith("\n")) {
3044
3092
  tr.step(replaceInlineStep(block.id, pos.region, length - 1, length, []));
3045
3093
  const paragraph = createBlock(schema, schema.defaultTextBlock, {}, block.indent, makeId());
3046
3094
  tr.step(insertBlocksStep(descendantsEnd(tr.doc, index), [paragraph]));
@@ -3063,7 +3111,7 @@ function insertEmptyBefore({ tr, schema, block, index, pos, makeId }) {
3063
3111
  function splitToggle({ tr, schema, block, index, pos, makeId }) {
3064
3112
  const length = regionLength(block, pos.region);
3065
3113
  const open = block.attrs.open === true;
3066
- const tail = chunkAIS37SL2_cjs.sliceInline(block.regions[pos.region], pos.offset, length);
3114
+ const tail = chunkWZA5S5EJ_cjs.sliceInline(block.regions[pos.region], pos.offset, length);
3067
3115
  const empty = createBlock(schema, schema.defaultTextBlock, {}, open ? block.indent + 1 : block.indent, makeId());
3068
3116
  if (pos.offset < length) tr.step(replaceInlineStep(block.id, pos.region, pos.offset, length, []));
3069
3117
  tr.step(insertBlocksStep(open ? index + 1 : descendantsEnd(tr.doc, index), [withContent(schema, empty, tail)]));
@@ -3075,7 +3123,7 @@ function splitInTwo({ tr, schema, block, pos, makeId }) {
3075
3123
  tr.setSelection(textSelection({ block: tail.id, region: tail.region, offset: 0 }));
3076
3124
  }
3077
3125
  function splitAt(tr, schema, pos, collapsed, makeId) {
3078
- const index = chunkAIS37SL2_cjs.requireBlockIndex(tr.doc, pos.block);
3126
+ const index = chunkWZA5S5EJ_cjs.requireBlockIndex(tr.doc, pos.block);
3079
3127
  const block = tr.doc.blocks[index];
3080
3128
  if (!isTextFlow(schema, block) || pos.region !== primaryRegion(schema, block)) return false;
3081
3129
  const target = { tr, schema, block, index, pos, makeId };
@@ -3090,13 +3138,13 @@ function splitAt(tr, schema, pos, collapsed, makeId) {
3090
3138
 
3091
3139
  // src/engine/commands/split-block.ts
3092
3140
  function splitBlock(options = {}) {
3093
- const makeId = options.newId ?? chunkAIS37SL2_cjs.newId;
3141
+ const makeId = options.newId ?? chunkWZA5S5EJ_cjs.newId;
3094
3142
  return (state, dispatch) => {
3095
3143
  const { doc, schema, selection } = state;
3096
3144
  if (selection === null || selection.kind === "blocks") return false;
3097
3145
  const tr = new Transaction(state).setMeta(LINE_SPLIT, true);
3098
3146
  if (selection.kind === "node") {
3099
- const index = chunkAIS37SL2_cjs.requireBlockIndex(doc, selection.block);
3147
+ const index = chunkWZA5S5EJ_cjs.requireBlockIndex(doc, selection.block);
3100
3148
  const paragraph = createBlock(schema, schema.defaultTextBlock, {}, doc.blocks[index].indent, makeId());
3101
3149
  tr.step(insertBlocksStep(descendantsEnd(doc, index), [paragraph]));
3102
3150
  tr.setSelection(startOf(tr.doc, schema, paragraph.id));
@@ -3206,7 +3254,7 @@ function replaceEmpty(tr, schema, index, blocks) {
3206
3254
  tr.setSelection(endOf(tr.doc, schema, blocks[blocks.length - 1].id));
3207
3255
  }
3208
3256
  function pasteAtCaret(tr, schema, caret, ends, pieces, makeId) {
3209
- const index = chunkAIS37SL2_cjs.requireBlockIndex(tr.doc, caret.block);
3257
+ const index = chunkWZA5S5EJ_cjs.requireBlockIndex(tr.doc, caret.block);
3210
3258
  const current = tr.doc.blocks[index];
3211
3259
  const { region } = caret;
3212
3260
  const first = pieces[0];
@@ -3215,7 +3263,7 @@ function pasteAtCaret(tr, schema, caret, ends, pieces, makeId) {
3215
3263
  if (pieces.length === 1 && ends.openStart && ends.openEnd && textual(first)) {
3216
3264
  const content = contentOf(schema, first);
3217
3265
  insertAt(tr, caret, content);
3218
- tr.setSelection(textSelection({ ...caret, offset: caret.offset + chunkAIS37SL2_cjs.inlineLength(content) }));
3266
+ tr.setSelection(textSelection({ ...caret, offset: caret.offset + chunkWZA5S5EJ_cjs.inlineLength(content) }));
3219
3267
  return;
3220
3268
  }
3221
3269
  const fresh = freshBlocks(pieces, current.indent, makeId);
@@ -3237,18 +3285,18 @@ function pasteAtCaret(tr, schema, caret, ends, pieces, makeId) {
3237
3285
  if (atStart && !atEnd) {
3238
3286
  if (middle.length > 0) insertCapped(tr, index, middle);
3239
3287
  insertAt(tr, { ...caret, offset: 0 }, lastContent);
3240
- tr.setSelection(textSelection({ ...caret, offset: chunkAIS37SL2_cjs.inlineLength(lastContent) }));
3288
+ tr.setSelection(textSelection({ ...caret, offset: chunkWZA5S5EJ_cjs.inlineLength(lastContent) }));
3241
3289
  return;
3242
3290
  }
3243
3291
  const firstContent = mergeFirst ? contentOf(schema, fresh[0]) : [];
3244
3292
  insertAt(tr, caret, firstContent);
3245
- const offset = caret.offset + chunkAIS37SL2_cjs.inlineLength(firstContent);
3293
+ const offset = caret.offset + chunkWZA5S5EJ_cjs.inlineLength(firstContent);
3246
3294
  const tail = !atEnd && (mergeLast || middle.length > 0) ? splitStep(schema, current, region, offset, makeId()) : null;
3247
3295
  if (tail !== null) tr.step(tail.step);
3248
3296
  if (middle.length > 0) insertCapped(tr, index + 1, middle);
3249
3297
  if (tail !== null && mergeLast) {
3250
3298
  insertAt(tr, { block: tail.tail.id, region: tail.tail.region, offset: 0 }, lastContent);
3251
- tr.setSelection(textSelection({ block: tail.tail.id, region: tail.tail.region, offset: chunkAIS37SL2_cjs.inlineLength(lastContent) }));
3299
+ tr.setSelection(textSelection({ block: tail.tail.id, region: tail.tail.region, offset: chunkWZA5S5EJ_cjs.inlineLength(lastContent) }));
3252
3300
  } else if (middle.length > 0) {
3253
3301
  tr.setSelection(endOf(tr.doc, schema, middle[middle.length - 1].id));
3254
3302
  } else {
@@ -3274,10 +3322,10 @@ function appendAtEnd(tr, schema, pieces, makeId) {
3274
3322
  tr.setSelection(endOf(tr.doc, schema, fresh[fresh.length - 1].id));
3275
3323
  }
3276
3324
  function insertSlice(slice, options = {}) {
3277
- const makeId = options.newId ?? chunkAIS37SL2_cjs.newId;
3325
+ const makeId = options.newId ?? chunkWZA5S5EJ_cjs.newId;
3278
3326
  return (state, dispatch) => {
3279
3327
  const { doc, schema, selection } = state;
3280
- const codec = chunkAIS37SL2_cjs.createBlockCodec(schema, { newId: makeId });
3328
+ const codec = chunkWZA5S5EJ_cjs.createBlockCodec(schema, { newId: makeId });
3281
3329
  const pieces = slice.blocks.flatMap((block) => codec.toEngineBlocks(block));
3282
3330
  if (pieces.length === 0) return false;
3283
3331
  const tr = new Transaction(state).setOrigin("paste");
@@ -3326,9 +3374,9 @@ function fenceTransaction(state) {
3326
3374
  const { selection, doc } = state;
3327
3375
  if (selection?.kind !== "text" || !isCollapsed(selection)) return null;
3328
3376
  const { block: id, region, offset } = selection.head;
3329
- const block = chunkAIS37SL2_cjs.blockById(doc, id);
3377
+ const block = chunkWZA5S5EJ_cjs.blockById(doc, id);
3330
3378
  if (block === void 0 || !isParagraph(block) || offset !== regionLength(block, region)) return null;
3331
- const fence = FENCE.exec(chunkAIS37SL2_cjs.inlineText(block.regions[region]));
3379
+ const fence = FENCE.exec(chunkWZA5S5EJ_cjs.inlineText(block.regions[region]));
3332
3380
  if (fence === null) return null;
3333
3381
  return convertPrefix(state, { block: id, region, from: 0, to: offset }, setBlockType("CODE", { language: fence[1] }));
3334
3382
  }
@@ -3395,9 +3443,9 @@ function coreExtensions(options = {}) {
3395
3443
  return [
3396
3444
  defineExtension({
3397
3445
  name: "core",
3398
- blocks: chunkAIS37SL2_cjs.coreBlockSpecs,
3399
- marks: chunkAIS37SL2_cjs.coreMarkSpecs,
3400
- atoms: chunkAIS37SL2_cjs.coreAtomSpecs,
3446
+ blocks: chunkWZA5S5EJ_cjs.coreBlockSpecs,
3447
+ marks: chunkWZA5S5EJ_cjs.coreMarkSpecs,
3448
+ atoms: chunkWZA5S5EJ_cjs.coreAtomSpecs,
3401
3449
  commands: coreCommands,
3402
3450
  pasteRules: [linkOverSelection]
3403
3451
  }),
@@ -3414,12 +3462,12 @@ function coreExtensions(options = {}) {
3414
3462
 
3415
3463
  // src/engine/clipboard/serialize-slice.ts
3416
3464
  function sliceText(slice, options) {
3417
- const schema = options.schema ?? chunkAIS37SL2_cjs.createSchema();
3465
+ const schema = options.schema ?? chunkWZA5S5EJ_cjs.createSchema();
3418
3466
  if (slice.blocks.length === 1 && slice.openStart && slice.openEnd) {
3419
- const pieces = chunkAIS37SL2_cjs.createBlockCodec(schema).toEngineBlocks(slice.blocks[0]);
3467
+ const pieces = chunkWZA5S5EJ_cjs.createBlockCodec(schema).toEngineBlocks(slice.blocks[0]);
3420
3468
  const block = pieces.length === 1 ? stripComments(pieces[0]) : null;
3421
3469
  const region = block === null || !isTextFlow(schema, block) ? null : primaryRegion(schema, block);
3422
- if (block !== null && region !== null) return chunkAIS37SL2_cjs.inlinePlainText(block.regions[region] ?? [], schema);
3470
+ if (block !== null && region !== null) return chunkWZA5S5EJ_cjs.inlinePlainText(block.regions[region] ?? [], schema);
3423
3471
  }
3424
3472
  const markdown = toMarkdown(slice.blocks, { schema, resolveAssetUrl: options.resolveAssetUrl, comments: false });
3425
3473
  return markdown.replace(/\n$/, "");
@@ -3437,17 +3485,17 @@ function isFlowRegion(schema, block, region) {
3437
3485
  return isTextFlow(schema, block) && region === primaryRegion(schema, block);
3438
3486
  }
3439
3487
  function trimmed(block, region, from, to) {
3440
- return { ...block, regions: { ...block.regions, [region]: chunkAIS37SL2_cjs.sliceInline(block.regions[region], from, to) } };
3488
+ return { ...block, regions: { ...block.regions, [region]: chunkWZA5S5EJ_cjs.sliceInline(block.regions[region], from, to) } };
3441
3489
  }
3442
3490
  function insideOneRegion(schema, block, region, from, to) {
3443
3491
  if (isFlowRegion(schema, block, region)) return trimmed(block, region, from, to);
3444
3492
  const paragraph = createBlock(schema, schema.defaultTextBlock, {}, block.indent, block.id);
3445
- return withContent(schema, paragraph, chunkAIS37SL2_cjs.sliceInline(block.regions[region], from, to));
3493
+ return withContent(schema, paragraph, chunkWZA5S5EJ_cjs.sliceInline(block.regions[region], from, to));
3446
3494
  }
3447
3495
  function textBlocks({ doc, schema }, selection) {
3448
3496
  const { from, to } = orderedRange(doc, selection.anchor, selection.head);
3449
- const start = chunkAIS37SL2_cjs.requireBlockIndex(doc, from.block);
3450
- const end = chunkAIS37SL2_cjs.requireBlockIndex(doc, to.block);
3497
+ const start = chunkWZA5S5EJ_cjs.requireBlockIndex(doc, from.block);
3498
+ const end = chunkWZA5S5EJ_cjs.requireBlockIndex(doc, to.block);
3451
3499
  const first = doc.blocks[start];
3452
3500
  if (start === end) {
3453
3501
  if (from.region !== to.region) return [first];
@@ -3493,18 +3541,18 @@ var INLINE_SYNTAX = [/\*\*[^*\n]+\*\*/, /__[^_\n]+__/, /\[[^\]\n]+\]\([^)\s]+[^)
3493
3541
  function looksLikeMarkdown(value) {
3494
3542
  return value.split(/\r\n|\r|\n/).some((line2) => BLOCK_MARKERS.some((marker) => marker.test(line2))) || INLINE_SYNTAX.some((syntax) => syntax.test(value));
3495
3543
  }
3496
- function plainTextToBlocks(value, makeId = chunkAIS37SL2_cjs.newId) {
3544
+ function plainTextToBlocks(value, makeId = chunkWZA5S5EJ_cjs.newId) {
3497
3545
  return value.split(/\r\n|\r|\n/).filter((line2) => line2.trim() !== "").map((line2) => ({
3498
3546
  id: makeId(),
3499
3547
  type: "MARKDOWN",
3500
- data: { markdown: chunkAIS37SL2_cjs.serializeInline([chunkAIS37SL2_cjs.text(line2)], { escapeLineStart: true }) }
3548
+ data: { markdown: chunkWZA5S5EJ_cjs.serializeInline([chunkWZA5S5EJ_cjs.text(line2)], { escapeLineStart: true }) }
3501
3549
  }));
3502
3550
  }
3503
3551
 
3504
3552
  // src/engine/clipboard/parse-slice-json.ts
3505
3553
  function isBlock2(value) {
3506
- if (!chunkAIS37SL2_cjs.isRecord(value) || typeof value.id !== "string" || typeof value.type !== "string") return false;
3507
- if (!chunkAIS37SL2_cjs.isRecord(value.data)) return false;
3554
+ if (!chunkWZA5S5EJ_cjs.isRecord(value) || typeof value.id !== "string" || typeof value.type !== "string") return false;
3555
+ if (!chunkWZA5S5EJ_cjs.isRecord(value.data)) return false;
3508
3556
  return value.indent === void 0 || Number.isInteger(value.indent) && value.indent >= 0;
3509
3557
  }
3510
3558
  function parseSliceJSON(json) {
@@ -3514,7 +3562,7 @@ function parseSliceJSON(json) {
3514
3562
  } catch {
3515
3563
  return null;
3516
3564
  }
3517
- if (!chunkAIS37SL2_cjs.isRecord(parsed) || parsed.quoin !== 1 || !chunkAIS37SL2_cjs.isRecord(parsed.slice)) return null;
3565
+ if (!chunkWZA5S5EJ_cjs.isRecord(parsed) || parsed.quoin !== 1 || !chunkWZA5S5EJ_cjs.isRecord(parsed.slice)) return null;
3518
3566
  const { blocks, openStart, openEnd } = parsed.slice;
3519
3567
  if (!Array.isArray(blocks) || blocks.length === 0 || !blocks.every(isBlock2)) return null;
3520
3568
  if (typeof openStart !== "boolean" || typeof openEnd !== "boolean") return null;
@@ -3522,7 +3570,7 @@ function parseSliceJSON(json) {
3522
3570
  }
3523
3571
 
3524
3572
  // src/engine/clipboard/slice-from-clipboard.ts
3525
- var isParagraph2 = (block) => block.type === "MARKDOWN" && chunkAIS37SL2_cjs.parseLine(String(block.data.markdown ?? "")).kind === "paragraph";
3573
+ var isParagraph2 = (block) => block.type === "MARKDOWN" && chunkWZA5S5EJ_cjs.parseLine(String(block.data.markdown ?? "")).kind === "paragraph";
3526
3574
  function openSlice(blocks, plainText2 = false) {
3527
3575
  if (blocks.length === 0) return null;
3528
3576
  const slice = { blocks, openStart: isParagraph2(blocks[0]), openEnd: isParagraph2(blocks[blocks.length - 1]) };
@@ -3532,14 +3580,14 @@ function linkBlocks(text2, makeId) {
3532
3580
  const link = pastedLink(text2);
3533
3581
  if (link === null) return null;
3534
3582
  const { url, href, rest } = link;
3535
- const linked2 = chunkAIS37SL2_cjs.text(url, [{ type: "link", attrs: { href } }]);
3536
- const markdown = chunkAIS37SL2_cjs.serializeInline(rest === "" ? [linked2] : [linked2, chunkAIS37SL2_cjs.text(rest)]);
3583
+ const linked2 = chunkWZA5S5EJ_cjs.text(url, [{ type: "link", attrs: { href } }]);
3584
+ const markdown = chunkWZA5S5EJ_cjs.serializeInline(rest === "" ? [linked2] : [linked2, chunkWZA5S5EJ_cjs.text(rest)]);
3537
3585
  return [{ id: makeId(), type: "MARKDOWN", data: { markdown } }];
3538
3586
  }
3539
3587
  function textBlocks2(text2, makeId) {
3540
3588
  const link = linkBlocks(text2, makeId);
3541
3589
  if (link !== null) return link;
3542
- return looksLikeMarkdown(text2) ? chunkAIS37SL2_cjs.fromMarkdown(text2, { newId: makeId }) : plainTextToBlocks(text2, makeId);
3590
+ return looksLikeMarkdown(text2) ? chunkWZA5S5EJ_cjs.fromMarkdown(text2, { newId: makeId }) : plainTextToBlocks(text2, makeId);
3543
3591
  }
3544
3592
  function htmlSlice(html, options) {
3545
3593
  if (html === void 0) return null;
@@ -3551,7 +3599,7 @@ function sliceFromClipboard(data, options = {}) {
3551
3599
  if (fromJson !== null) return fromJson;
3552
3600
  const fromHtml = htmlSlice(data.html, options);
3553
3601
  if (fromHtml !== null) return fromHtml;
3554
- return data.text === void 0 ? null : openSlice(textBlocks2(data.text, options.newId ?? chunkAIS37SL2_cjs.newId), true);
3602
+ return data.text === void 0 ? null : openSlice(textBlocks2(data.text, options.newId ?? chunkWZA5S5EJ_cjs.newId), true);
3555
3603
  }
3556
3604
 
3557
3605
  // src/engine/commands/is-active.ts
@@ -3560,7 +3608,7 @@ function hasAttrs(block, attrs) {
3560
3608
  }
3561
3609
  function isActive(state, name, attrs) {
3562
3610
  if (state.schema.marks.has(name)) return selectionHasMark(state, name, attrs);
3563
- const blocks = selectedBlockIds(state.doc, state.selection).flatMap((id) => chunkAIS37SL2_cjs.blockById(state.doc, id) ?? []);
3611
+ const blocks = selectedBlockIds(state.doc, state.selection).flatMap((id) => chunkWZA5S5EJ_cjs.blockById(state.doc, id) ?? []);
3564
3612
  const isBlockType = state.schema.blocks.has(name);
3565
3613
  const matches = (block) => isBlockType ? block.type === name : block.type === "MARKDOWN" && block.attrs.kind === name;
3566
3614
  return blocks.length > 0 && blocks.every((block) => matches(block) && hasAttrs(block, attrs));
@@ -3569,19 +3617,19 @@ function isActive(state, name, attrs) {
3569
3617
  // src/engine/model/same-doc.ts
3570
3618
  function sameDoc(a, b) {
3571
3619
  if (a === b) return true;
3572
- return a.blocks.length === b.blocks.length && a.blocks.every((block, i) => chunk7SVKLWDT_cjs.sameValue(block, b.blocks[i]));
3620
+ return a.blocks.length === b.blocks.length && a.blocks.every((block, i) => chunkWZA5S5EJ_cjs.sameValue(block, b.blocks[i]));
3573
3621
  }
3574
3622
 
3575
3623
  // src/engine/extension/same-blocks.ts
3576
3624
  function sameBlock(a, b) {
3577
- return a === b || a.id === b.id && a.type === b.type && (a.indent ?? 0) === (b.indent ?? 0) && chunk7SVKLWDT_cjs.sameValue(a.data, b.data);
3625
+ return a === b || a.id === b.id && a.type === b.type && (a.indent ?? 0) === (b.indent ?? 0) && chunkWZA5S5EJ_cjs.sameValue(a.data, b.data);
3578
3626
  }
3579
3627
  function sameBlocks(a, b) {
3580
- return a === b || chunkAIS37SL2_cjs.sameItems(a, b, sameBlock);
3628
+ return a === b || chunkWZA5S5EJ_cjs.sameItems(a, b, sameBlock);
3581
3629
  }
3582
3630
 
3583
3631
  // src/engine/extension/structural-echo.ts
3584
- var sameIds = (a, b) => chunkAIS37SL2_cjs.sameItems(a, b, (x, y) => x.id === y.id);
3632
+ var sameIds = (a, b) => chunkWZA5S5EJ_cjs.sameItems(a, b, (x, y) => x.id === y.id);
3585
3633
  function copiedSequence(emissions, incoming) {
3586
3634
  const verdicts = /* @__PURE__ */ new Map();
3587
3635
  const sameAt = (block, index) => {
@@ -3756,16 +3804,16 @@ function commandsOf(extensions) {
3756
3804
  }
3757
3805
  return Object.fromEntries(commands);
3758
3806
  }
3807
+ var priorityOf = (extension) => extension.priority ?? DEFAULT_PRIORITY;
3759
3808
  function resolveExtensions(extensions, isMac) {
3760
- const sorted = [...extensions].sort(
3761
- (a, b) => (b.priority ?? DEFAULT_PRIORITY) - (a.priority ?? DEFAULT_PRIORITY)
3762
- );
3809
+ const sorted = [...extensions].sort((a, b) => priorityOf(b) - priorityOf(a));
3810
+ const lowestFirst = [...extensions].sort((a, b) => priorityOf(a) - priorityOf(b));
3763
3811
  return {
3764
3812
  extensions: sorted,
3765
- schema: chunkAIS37SL2_cjs.createSchema({
3766
- blocks: sorted.flatMap((extension) => extension.blocks ?? []),
3767
- marks: sorted.flatMap((extension) => extension.marks ?? []),
3768
- atoms: sorted.flatMap((extension) => extension.atoms ?? [])
3813
+ schema: chunkWZA5S5EJ_cjs.createSchema({
3814
+ blocks: lowestFirst.flatMap((extension) => extension.blocks ?? []),
3815
+ marks: lowestFirst.flatMap((extension) => extension.marks ?? []),
3816
+ atoms: lowestFirst.flatMap((extension) => extension.atoms ?? [])
3769
3817
  }),
3770
3818
  inputRules: sorted.flatMap((extension) => extension.inputRules ?? []),
3771
3819
  pasteRules: sorted.flatMap((extension) => extension.pasteRules ?? []),
@@ -3786,7 +3834,7 @@ function createInternalEditor(options) {
3786
3834
  const isMac = options.isMac ?? detectMac();
3787
3835
  const resolved = resolveExtensions(options.extensions ?? coreExtensions({ newId: newId2 }), isMac);
3788
3836
  const { schema, plugins } = resolved;
3789
- const codec = chunkAIS37SL2_cjs.createBlockCodec(schema, { newId: newId2 });
3837
+ const codec = chunkWZA5S5EJ_cjs.createBlockCodec(schema, { newId: newId2 });
3790
3838
  const listeners = /* @__PURE__ */ new Set();
3791
3839
  const mounts = /* @__PURE__ */ new Set();
3792
3840
  let state = createState({ doc: codec.docFromBlocks(options.blocks), schema, plugins, clock: options.now });
@@ -3895,6 +3943,7 @@ exports.caretMarks = caretMarks;
3895
3943
  exports.commonPrefix = commonPrefix;
3896
3944
  exports.commonSuffix = commonSuffix;
3897
3945
  exports.comparePos = comparePos;
3946
+ exports.continuesEdit = continuesEdit;
3898
3947
  exports.coreExtensions = coreExtensions;
3899
3948
  exports.countBlock = countBlock;
3900
3949
  exports.countDoc = countDoc;
@@ -3916,6 +3965,7 @@ exports.deleteWordForward = deleteWordForward;
3916
3965
  exports.descendantsEnd = descendantsEnd;
3917
3966
  exports.detectMac = detectMac;
3918
3967
  exports.duplicateBlocks = duplicateBlocks;
3968
+ exports.editEnd = editEnd;
3919
3969
  exports.endOf = endOf;
3920
3970
  exports.freshBlocks = freshBlocks;
3921
3971
  exports.fromHTML = fromHTML;
@@ -4003,5 +4053,5 @@ exports.unsetMark = unsetMark;
4003
4053
  exports.validateSelection = validateSelection;
4004
4054
  exports.withContent = withContent;
4005
4055
  exports.wordCount = wordCount;
4006
- //# sourceMappingURL=chunk-VFSVN5IQ.cjs.map
4007
- //# sourceMappingURL=chunk-VFSVN5IQ.cjs.map
4056
+ //# sourceMappingURL=chunk-4F2IWBFM.cjs.map
4057
+ //# sourceMappingURL=chunk-4F2IWBFM.cjs.map