quoin-editor 1.0.2 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (224) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/dist/ai.cjs +169 -249
  3. package/dist/ai.cjs.map +1 -1
  4. package/dist/ai.js +38 -121
  5. package/dist/ai.js.map +1 -1
  6. package/dist/catalogue.cjs +29 -43
  7. package/dist/catalogue.cjs.map +1 -1
  8. package/dist/catalogue.js +21 -37
  9. package/dist/catalogue.js.map +1 -1
  10. package/dist/{chunk-DUE3HCZD.js → chunk-2EQ6FKSK.js} +19 -28
  11. package/dist/chunk-2EQ6FKSK.js.map +1 -0
  12. package/dist/{chunk-RJRX34BZ.js → chunk-3BXUGX5F.js} +4 -18
  13. package/dist/chunk-3BXUGX5F.js.map +1 -0
  14. package/dist/chunk-3QRVAI53.cjs +27 -0
  15. package/dist/chunk-3QRVAI53.cjs.map +1 -0
  16. package/dist/{chunk-U3LOLYAU.js → chunk-7FAVFJAS.js} +4 -10
  17. package/dist/chunk-7FAVFJAS.js.map +1 -0
  18. package/dist/{chunk-FDRUAL3Z.cjs → chunk-7NAONESM.cjs} +90 -153
  19. package/dist/chunk-7NAONESM.cjs.map +1 -0
  20. package/dist/{chunk-6V6GGBDK.cjs → chunk-7SVKLWDT.cjs} +24 -31
  21. package/dist/chunk-7SVKLWDT.cjs.map +1 -0
  22. package/dist/{chunk-CW3AFJBR.cjs → chunk-7XQGOCUG.cjs} +1332 -1772
  23. package/dist/chunk-7XQGOCUG.cjs.map +1 -0
  24. package/dist/{chunk-EH5KXQXY.cjs → chunk-A6PGQVTR.cjs} +36 -20
  25. package/dist/chunk-A6PGQVTR.cjs.map +1 -0
  26. package/dist/{chunk-4SLJNZSM.cjs → chunk-AIS37SL2.cjs} +201 -198
  27. package/dist/chunk-AIS37SL2.cjs.map +1 -0
  28. package/dist/{chunk-IQBMAE3F.js → chunk-CKHKCPGL.js} +34 -92
  29. package/dist/chunk-CKHKCPGL.js.map +1 -0
  30. package/dist/{chunk-T43RZTUT.js → chunk-DYWU4SQ2.js} +723 -1246
  31. package/dist/chunk-DYWU4SQ2.js.map +1 -0
  32. package/dist/chunk-EFRQMYZ6.cjs +33 -0
  33. package/dist/chunk-EFRQMYZ6.cjs.map +1 -0
  34. package/dist/{chunk-O4Z2WMFF.js → chunk-HDJ653LM.js} +25 -18
  35. package/dist/chunk-HDJ653LM.js.map +1 -0
  36. package/dist/chunk-HQ43EIYO.cjs +94 -0
  37. package/dist/chunk-HQ43EIYO.cjs.map +1 -0
  38. package/dist/{chunk-6NULZPVC.js → chunk-HTLWPSMU.js} +8 -61
  39. package/dist/chunk-HTLWPSMU.js.map +1 -0
  40. package/dist/{chunk-EPARJI4V.js → chunk-IEP7BPFN.js} +122 -267
  41. package/dist/chunk-IEP7BPFN.js.map +1 -0
  42. package/dist/{chunk-P6KYXFZC.cjs → chunk-IGZRZIAF.cjs} +440 -538
  43. package/dist/chunk-IGZRZIAF.cjs.map +1 -0
  44. package/dist/chunk-JCEFSTVG.cjs +483 -0
  45. package/dist/chunk-JCEFSTVG.cjs.map +1 -0
  46. package/dist/chunk-KXRGY5LK.cjs +612 -0
  47. package/dist/chunk-KXRGY5LK.cjs.map +1 -0
  48. package/dist/{chunk-JHQUHFLX.js → chunk-KZ6ZFCGO.js} +38 -120
  49. package/dist/chunk-KZ6ZFCGO.js.map +1 -0
  50. package/dist/{chunk-ADSJ42DO.js → chunk-L2QA2UTY.js} +17 -69
  51. package/dist/chunk-L2QA2UTY.js.map +1 -0
  52. package/dist/{chunk-OBMBSU2S.js → chunk-L4D23LM2.js} +5 -184
  53. package/dist/chunk-L4D23LM2.js.map +1 -0
  54. package/dist/{chunk-4XFXB37X.js → chunk-L6OW2FL3.js} +7 -90
  55. package/dist/chunk-L6OW2FL3.js.map +1 -0
  56. package/dist/chunk-LE5XMIFJ.cjs +4 -3
  57. package/dist/chunk-LE5XMIFJ.cjs.map +1 -1
  58. package/dist/chunk-MQUCCSWG.js +2 -3
  59. package/dist/chunk-MQUCCSWG.js.map +1 -1
  60. package/dist/{chunk-C23RQVRK.js → chunk-MUIPM26J.js} +66 -216
  61. package/dist/chunk-MUIPM26J.js.map +1 -0
  62. package/dist/{chunk-AUOEM3SF.cjs → chunk-OKWER2RV.cjs} +102 -155
  63. package/dist/chunk-OKWER2RV.cjs.map +1 -0
  64. package/dist/{chunk-TLGX43P6.cjs → chunk-OM7E43ZN.cjs} +89 -86
  65. package/dist/chunk-OM7E43ZN.cjs.map +1 -0
  66. package/dist/{chunk-NEZJ7ZP5.js → chunk-QSXPKZ2F.js} +4 -8
  67. package/dist/chunk-QSXPKZ2F.js.map +1 -0
  68. package/dist/{chunk-VCLL5C7J.js → chunk-RFLFRIPV.js} +14 -57
  69. package/dist/chunk-RFLFRIPV.js.map +1 -0
  70. package/dist/chunk-RIIXJWBR.cjs +24 -0
  71. package/dist/chunk-RIIXJWBR.cjs.map +1 -0
  72. package/dist/{chunk-VRS6WCEK.js → chunk-SFMORPWB.js} +60 -167
  73. package/dist/chunk-SFMORPWB.js.map +1 -0
  74. package/dist/{chunk-YBMUEEM5.js → chunk-TYZSB7JT.js} +4 -8
  75. package/dist/chunk-TYZSB7JT.js.map +1 -0
  76. package/dist/{chunk-BQANU5BH.cjs → chunk-U5BSCAMP.cjs} +34 -44
  77. package/dist/chunk-U5BSCAMP.cjs.map +1 -0
  78. package/dist/{chunk-OSHZQR3W.js → chunk-UEVR4B5S.js} +13 -45
  79. package/dist/chunk-UEVR4B5S.js.map +1 -0
  80. package/dist/{chunk-N4FGA3H4.js → chunk-VBJY2CSK.js} +38 -105
  81. package/dist/chunk-VBJY2CSK.js.map +1 -0
  82. package/dist/{chunk-ZKVOS57Q.cjs → chunk-VFSVN5IQ.cjs} +495 -551
  83. package/dist/chunk-VFSVN5IQ.cjs.map +1 -0
  84. package/dist/{chunk-X4HDKFW5.cjs → chunk-VNRI5DAL.cjs} +56 -105
  85. package/dist/chunk-VNRI5DAL.cjs.map +1 -0
  86. package/dist/chunk-W7B4WQ3L.cjs +200 -0
  87. package/dist/chunk-W7B4WQ3L.cjs.map +1 -0
  88. package/dist/{chunk-623AOJM2.js → chunk-WAGBELKA.js} +7 -25
  89. package/dist/chunk-WAGBELKA.js.map +1 -0
  90. package/dist/{chunk-WEYDDIBQ.cjs → chunk-WH56EW3H.cjs} +36 -64
  91. package/dist/chunk-WH56EW3H.cjs.map +1 -0
  92. package/dist/{chunk-5MAYUGTE.cjs → chunk-XAS7LANM.cjs} +233 -363
  93. package/dist/chunk-XAS7LANM.cjs.map +1 -0
  94. package/dist/comments.cjs +210 -290
  95. package/dist/comments.cjs.map +1 -1
  96. package/dist/comments.js +82 -186
  97. package/dist/comments.js.map +1 -1
  98. package/dist/diff.cjs +48 -65
  99. package/dist/diff.cjs.map +1 -1
  100. package/dist/diff.d.cts +2 -2
  101. package/dist/diff.d.ts +2 -2
  102. package/dist/diff.js +8 -32
  103. package/dist/diff.js.map +1 -1
  104. package/dist/docx.cjs +50 -63
  105. package/dist/docx.cjs.map +1 -1
  106. package/dist/docx.js +7 -22
  107. package/dist/docx.js.map +1 -1
  108. package/dist/embed.cjs +19 -12
  109. package/dist/embed.cjs.map +1 -1
  110. package/dist/embed.js +10 -16
  111. package/dist/embed.js.map +1 -1
  112. package/dist/emoji-data.cjs +7 -5
  113. package/dist/emoji-data.cjs.map +1 -1
  114. package/dist/emoji-data.js +3 -5
  115. package/dist/emoji-data.js.map +1 -1
  116. package/dist/emoji.cjs +26 -17
  117. package/dist/emoji.cjs.map +1 -1
  118. package/dist/emoji.js +9 -17
  119. package/dist/emoji.js.map +1 -1
  120. package/dist/engine.cjs +229 -118
  121. package/dist/engine.cjs.map +1 -1
  122. package/dist/engine.js +4 -118
  123. package/dist/engine.js.map +1 -1
  124. package/dist/find.cjs +30 -19
  125. package/dist/find.cjs.map +1 -1
  126. package/dist/find.js +9 -19
  127. package/dist/find.js.map +1 -1
  128. package/dist/headless.cjs +291 -151
  129. package/dist/headless.cjs.map +1 -1
  130. package/dist/headless.d.cts +5 -1
  131. package/dist/headless.d.ts +5 -1
  132. package/dist/headless.js +6 -151
  133. package/dist/headless.js.map +1 -1
  134. package/dist/index.cjs +349 -183
  135. package/dist/index.cjs.map +1 -1
  136. package/dist/index.d.cts +17 -4
  137. package/dist/index.d.ts +17 -4
  138. package/dist/index.js +8 -183
  139. package/dist/index.js.map +1 -1
  140. package/dist/math.cjs +20 -13
  141. package/dist/math.cjs.map +1 -1
  142. package/dist/math.js +11 -17
  143. package/dist/math.js.map +1 -1
  144. package/dist/mention.cjs +20 -13
  145. package/dist/mention.cjs.map +1 -1
  146. package/dist/mention.js +11 -17
  147. package/dist/mention.js.map +1 -1
  148. package/dist/presence.cjs +99 -132
  149. package/dist/presence.cjs.map +1 -1
  150. package/dist/presence.js +22 -78
  151. package/dist/presence.js.map +1 -1
  152. package/dist/{registry-CWBOSAHm.d.ts → registry-CXegaw5k.d.cts} +25 -2
  153. package/dist/{registry-CWBOSAHm.d.cts → registry-CXegaw5k.d.ts} +25 -2
  154. package/dist/stats.cjs +27 -18
  155. package/dist/stats.cjs.map +1 -1
  156. package/dist/stats.js +10 -18
  157. package/dist/stats.js.map +1 -1
  158. package/dist/styles.css +1 -1
  159. package/dist/table.cjs +90 -49
  160. package/dist/table.cjs.map +1 -1
  161. package/dist/table.js +9 -49
  162. package/dist/table.js.map +1 -1
  163. package/dist/toc.cjs +26 -17
  164. package/dist/toc.cjs.map +1 -1
  165. package/dist/toc.js +9 -17
  166. package/dist/toc.js.map +1 -1
  167. package/dist/view.cjs +13 -16
  168. package/dist/view.cjs.map +1 -1
  169. package/dist/view.d.cts +2 -2
  170. package/dist/view.d.ts +2 -2
  171. package/dist/view.js +7 -16
  172. package/dist/view.js.map +1 -1
  173. package/dist/yjs.cjs +186 -228
  174. package/dist/yjs.cjs.map +1 -1
  175. package/dist/yjs.js +12 -80
  176. package/dist/yjs.js.map +1 -1
  177. package/package.json +2 -1
  178. package/dist/chunk-4SLJNZSM.cjs.map +0 -1
  179. package/dist/chunk-4XFXB37X.js.map +0 -1
  180. package/dist/chunk-5MAYUGTE.cjs.map +0 -1
  181. package/dist/chunk-623AOJM2.js.map +0 -1
  182. package/dist/chunk-6NULZPVC.js.map +0 -1
  183. package/dist/chunk-6V6GGBDK.cjs.map +0 -1
  184. package/dist/chunk-73653CJ4.cjs +0 -34
  185. package/dist/chunk-73653CJ4.cjs.map +0 -1
  186. package/dist/chunk-ADSJ42DO.js.map +0 -1
  187. package/dist/chunk-AUOEM3SF.cjs.map +0 -1
  188. package/dist/chunk-BQANU5BH.cjs.map +0 -1
  189. package/dist/chunk-C23RQVRK.js.map +0 -1
  190. package/dist/chunk-CW3AFJBR.cjs.map +0 -1
  191. package/dist/chunk-DUE3HCZD.js.map +0 -1
  192. package/dist/chunk-EH5KXQXY.cjs.map +0 -1
  193. package/dist/chunk-EPARJI4V.js.map +0 -1
  194. package/dist/chunk-FDRUAL3Z.cjs.map +0 -1
  195. package/dist/chunk-IQBMAE3F.js.map +0 -1
  196. package/dist/chunk-JHQUHFLX.js.map +0 -1
  197. package/dist/chunk-KUYZMSMF.cjs +0 -100
  198. package/dist/chunk-KUYZMSMF.cjs.map +0 -1
  199. package/dist/chunk-LLTEGXWZ.cjs +0 -562
  200. package/dist/chunk-LLTEGXWZ.cjs.map +0 -1
  201. package/dist/chunk-N4FGA3H4.js.map +0 -1
  202. package/dist/chunk-NEZJ7ZP5.js.map +0 -1
  203. package/dist/chunk-O4Z2WMFF.js.map +0 -1
  204. package/dist/chunk-OBMBSU2S.js.map +0 -1
  205. package/dist/chunk-OSHZQR3W.js.map +0 -1
  206. package/dist/chunk-P6KYXFZC.cjs.map +0 -1
  207. package/dist/chunk-R2BLBV43.cjs +0 -239
  208. package/dist/chunk-R2BLBV43.cjs.map +0 -1
  209. package/dist/chunk-RJRX34BZ.js.map +0 -1
  210. package/dist/chunk-T43RZTUT.js.map +0 -1
  211. package/dist/chunk-TLGX43P6.cjs.map +0 -1
  212. package/dist/chunk-U3LOLYAU.js.map +0 -1
  213. package/dist/chunk-UEKXVCKC.cjs +0 -716
  214. package/dist/chunk-UEKXVCKC.cjs.map +0 -1
  215. package/dist/chunk-VCLL5C7J.js.map +0 -1
  216. package/dist/chunk-VRS6WCEK.js.map +0 -1
  217. package/dist/chunk-WEYDDIBQ.cjs.map +0 -1
  218. package/dist/chunk-X4HDKFW5.cjs.map +0 -1
  219. package/dist/chunk-X4P4TQXH.cjs +0 -30
  220. package/dist/chunk-X4P4TQXH.cjs.map +0 -1
  221. package/dist/chunk-XA3UEJIW.cjs +0 -25
  222. package/dist/chunk-XA3UEJIW.cjs.map +0 -1
  223. package/dist/chunk-YBMUEEM5.js.map +0 -1
  224. package/dist/chunk-ZKVOS57Q.cjs.map +0 -1
@@ -1,62 +1,7 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
1
+ 'use strict';
2
2
 
3
-
4
- var _chunk6V6GGBDKcjs = require('./chunk-6V6GGBDK.cjs');
5
-
6
-
7
-
8
-
9
-
10
-
11
-
12
-
13
-
14
-
15
-
16
-
17
-
18
-
19
-
20
-
21
-
22
-
23
-
24
-
25
-
26
-
27
-
28
-
29
-
30
-
31
-
32
-
33
-
34
-
35
-
36
-
37
-
38
-
39
-
40
-
41
-
42
-
43
-
44
-
45
-
46
-
47
-
48
-
49
-
50
-
51
-
52
-
53
-
54
-
55
-
56
-
57
-
58
-
59
- var _chunk4SLJNZSMcjs = require('./chunk-4SLJNZSM.cjs');
3
+ var chunk7SVKLWDT_cjs = require('./chunk-7SVKLWDT.cjs');
4
+ var chunkAIS37SL2_cjs = require('./chunk-AIS37SL2.cjs');
60
5
 
61
6
  // src/engine/transform/step.ts
62
7
  var StepError = class extends Error {
@@ -65,7 +10,7 @@ var identityMap = (pos) => pos;
65
10
 
66
11
  // src/engine/transform/step-access.ts
67
12
  function requireBlock(doc, id) {
68
- const block = _chunk4SLJNZSMcjs.blockById.call(void 0, doc, id);
13
+ const block = chunkAIS37SL2_cjs.blockById(doc, id);
69
14
  if (block === void 0) throw new StepError(`no block "${id}"`);
70
15
  return block;
71
16
  }
@@ -75,7 +20,7 @@ function requireRegion(block, region) {
75
20
  }
76
21
  function requireRange(block, region, from, to) {
77
22
  const inline = requireRegion(block, region);
78
- const length = _chunk4SLJNZSMcjs.inlineLength.call(void 0, inline);
23
+ const length = chunkAIS37SL2_cjs.inlineLength(inline);
79
24
  if (!(Number.isInteger(from) && Number.isInteger(to) && from >= 0 && from <= to && to <= length)) {
80
25
  throw new StepError(`range ${from} to ${to} is outside 0 to ${length} in "${block.id}" ${region}`);
81
26
  }
@@ -99,7 +44,7 @@ function patchAttrs(attrs, patch) {
99
44
  }
100
45
  function patchChangesAttrs(attrs, patch) {
101
46
  return Object.keys(patch).some(
102
- (key) => patch[key] === void 0 ? Object.hasOwn(attrs, key) : !_chunk6V6GGBDKcjs.sameValue.call(void 0, attrs[key], patch[key])
47
+ (key) => patch[key] === void 0 ? Object.hasOwn(attrs, key) : !chunk7SVKLWDT_cjs.sameValue(attrs[key], patch[key])
103
48
  );
104
49
  }
105
50
  function previousValues(attrs, patch) {
@@ -121,7 +66,7 @@ function setAttrsStep(block, patch) {
121
66
  stepType: "setAttrs",
122
67
  apply(doc) {
123
68
  requireBlock(doc, block);
124
- return { doc: _chunk4SLJNZSMcjs.updateBlock.call(void 0, doc, block, (b) => ({ ...b, attrs: patchAttrs(b.attrs, patch) })), map: identityMap };
69
+ return { doc: chunkAIS37SL2_cjs.updateBlock(doc, block, (b) => ({ ...b, attrs: patchAttrs(b.attrs, patch) })), map: identityMap };
125
70
  },
126
71
  invert: (before) => setAttrsStep(block, previousValues(requireBlock(before, block).attrs, patch)),
127
72
  toJSON: () => ({ stepType: "setAttrs", block, patch: patchToJSON(patch) })
@@ -135,7 +80,7 @@ function setIndentStep(block, indent2) {
135
80
  if (!Number.isInteger(indent2) || indent2 < 0) {
136
81
  throw new StepError(`indent ${indent2} is not a non-negative integer`);
137
82
  }
138
- return { doc: _chunk4SLJNZSMcjs.updateBlock.call(void 0, doc, block, (b) => ({ ...b, indent: indent2 })), map: identityMap };
83
+ return { doc: chunkAIS37SL2_cjs.updateBlock(doc, block, (b) => ({ ...b, indent: indent2 })), map: identityMap };
139
84
  },
140
85
  invert: (before) => setIndentStep(block, requireBlock(before, block).indent),
141
86
  toJSON: () => ({ stepType: "setIndent", block, indent: indent2 })
@@ -144,25 +89,25 @@ function setIndentStep(block, indent2) {
144
89
 
145
90
  // src/engine/transform/block-edges.ts
146
91
  function orderedRegions(block) {
147
- return Object.keys(block.regions).sort(_chunk4SLJNZSMcjs.compareRegionNames);
92
+ return Object.keys(block.regions).sort(chunkAIS37SL2_cjs.compareRegionNames);
148
93
  }
149
94
  function firstRegion(block) {
150
- return _nullishCoalesce(orderedRegions(block)[0], () => ( null));
95
+ return orderedRegions(block)[0] ?? null;
151
96
  }
152
97
  function blockStart(block) {
153
- return { block: block.id, region: _nullishCoalesce(firstRegion(block), () => ( "")), offset: 0 };
98
+ return { block: block.id, region: firstRegion(block) ?? "", offset: 0 };
154
99
  }
155
100
  function blockEnd(block) {
156
101
  const region = orderedRegions(block).at(-1);
157
102
  return {
158
103
  block: block.id,
159
- region: _nullishCoalesce(region, () => ( "")),
160
- offset: region === void 0 ? 0 : _chunk4SLJNZSMcjs.inlineLength.call(void 0, block.regions[region])
104
+ region: region ?? "",
105
+ offset: region === void 0 ? 0 : chunkAIS37SL2_cjs.inlineLength(block.regions[region])
161
106
  };
162
107
  }
163
108
  function clampPos(block, pos) {
164
109
  if (!Object.hasOwn(block.regions, pos.region)) return blockStart(block);
165
- const length = _chunk4SLJNZSMcjs.inlineLength.call(void 0, block.regions[pos.region]);
110
+ const length = chunkAIS37SL2_cjs.inlineLength(block.regions[pos.region]);
166
111
  return pos.offset > length ? { ...pos, offset: length } : pos;
167
112
  }
168
113
 
@@ -177,7 +122,7 @@ function insertBlocksStep(index, blocks) {
177
122
  if (doc.index.has(id) || ids.has(id)) throw new StepError(`block "${id}" is already in the document`);
178
123
  ids.add(id);
179
124
  }
180
- return { doc: _chunk4SLJNZSMcjs.replaceBlocks.call(void 0, doc, index, 0, blocks), map: identityMap };
125
+ return { doc: chunkAIS37SL2_cjs.replaceBlocks(doc, index, 0, blocks), map: identityMap };
181
126
  },
182
127
  invert: () => removeBlocksStep(index, blocks.length),
183
128
  toJSON: () => ({ stepType: "insertBlocks", index, blocks })
@@ -195,9 +140,9 @@ function removeBlocksStep(index, count2) {
195
140
  if (!removed.has(pos.block)) return pos;
196
141
  const before = preceding && blockEnd(preceding);
197
142
  const after = following && blockStart(following);
198
- return _nullishCoalesce((assoc === -1 ? _nullishCoalesce(before, () => ( after)) : _nullishCoalesce(after, () => ( before))), () => ( pos));
143
+ return (assoc === -1 ? before ?? after : after ?? before) ?? pos;
199
144
  };
200
- return { doc: _chunk4SLJNZSMcjs.replaceBlocks.call(void 0, doc, index, count2, []), map };
145
+ return { doc: chunkAIS37SL2_cjs.replaceBlocks(doc, index, count2, []), map };
201
146
  },
202
147
  invert: (before) => insertBlocksStep(index, before.blocks.slice(index, index + count2)),
203
148
  toJSON: () => ({ stepType: "removeBlocks", index, count: count2 })
@@ -211,14 +156,14 @@ function moveBlocksStep(from, count2, to) {
211
156
  requireSpan(to, count2, doc.blocks.length);
212
157
  const moved2 = doc.blocks.slice(from, from + count2);
213
158
  const rest = [...doc.blocks.slice(0, from), ...doc.blocks.slice(from + count2)];
214
- return { doc: _chunk4SLJNZSMcjs.createDoc.call(void 0, [...rest.slice(0, to), ...moved2, ...rest.slice(to)]), map: identityMap };
159
+ return { doc: chunkAIS37SL2_cjs.createDoc([...rest.slice(0, to), ...moved2, ...rest.slice(to)]), map: identityMap };
215
160
  },
216
161
  invert: () => moveBlocksStep(to, count2, from),
217
162
  toJSON: () => ({ stepType: "moveBlocks", from, count: count2, to })
218
163
  });
219
164
  }
220
165
  var keepsRegions = (before, after) => Object.entries(before.regions).every(
221
- ([name, inline]) => Object.hasOwn(after.regions, name) && _chunk4SLJNZSMcjs.equalInline.call(void 0, inline, after.regions[name])
166
+ ([name, inline]) => Object.hasOwn(after.regions, name) && chunkAIS37SL2_cjs.equalInline(inline, after.regions[name])
222
167
  );
223
168
  function replaceBlockStep(block) {
224
169
  const clamp = (pos) => pos.block === block.id ? clampPos(block, pos) : pos;
@@ -226,7 +171,7 @@ function replaceBlockStep(block) {
226
171
  stepType: "replaceBlock",
227
172
  apply(doc) {
228
173
  const map = keepsRegions(requireBlock(doc, block.id), block) ? identityMap : clamp;
229
- return { doc: _chunk4SLJNZSMcjs.updateBlock.call(void 0, doc, block.id, () => block), map };
174
+ return { doc: chunkAIS37SL2_cjs.updateBlock(doc, block.id, () => block), map };
230
175
  },
231
176
  invert: (before) => replaceBlockStep(requireBlock(before, block.id)),
232
177
  toJSON: () => ({ stepType: "replaceBlock", block })
@@ -235,7 +180,7 @@ function replaceBlockStep(block) {
235
180
 
236
181
  // src/engine/transform/replace-inline-step.ts
237
182
  function replaceInlineStep(block, region, from, to, slice) {
238
- const inserted = _chunk4SLJNZSMcjs.inlineLength.call(void 0, slice);
183
+ const inserted = chunkAIS37SL2_cjs.inlineLength(slice);
239
184
  const map = (pos, assoc = 1) => {
240
185
  if (pos.block !== block || pos.region !== region || pos.offset < from) return pos;
241
186
  if (pos.offset > to) return { ...pos, offset: pos.offset + inserted - (to - from) };
@@ -245,12 +190,12 @@ function replaceInlineStep(block, region, from, to, slice) {
245
190
  stepType: "replaceInline",
246
191
  apply(doc) {
247
192
  const inline = requireRange(requireBlock(doc, block), region, from, to);
248
- const next = _chunk4SLJNZSMcjs.updateBlock.call(void 0, doc, block, (b) => withRegion(b, region, _chunk4SLJNZSMcjs.replaceInline.call(void 0, inline, from, to, slice)));
193
+ const next = chunkAIS37SL2_cjs.updateBlock(doc, block, (b) => withRegion(b, region, chunkAIS37SL2_cjs.replaceInline(inline, from, to, slice)));
249
194
  return { doc: next, map };
250
195
  },
251
196
  invert(before) {
252
197
  const inline = requireRange(requireBlock(before, block), region, from, to);
253
- return replaceInlineStep(block, region, from, from + inserted, _chunk4SLJNZSMcjs.sliceInline.call(void 0, inline, from, to));
198
+ return replaceInlineStep(block, region, from, from + inserted, chunkAIS37SL2_cjs.sliceInline(inline, from, to));
254
199
  },
255
200
  toJSON: () => ({ stepType: "replaceInline", block, region, from, to, slice })
256
201
  });
@@ -263,24 +208,24 @@ function markStep(stepType, target, mark, change) {
263
208
  stepType,
264
209
  apply(doc) {
265
210
  const inline = requireRange(requireBlock(doc, block), region, from, to);
266
- return { doc: _chunk4SLJNZSMcjs.updateBlock.call(void 0, doc, block, (b) => withRegion(b, region, change(inline))), map: identityMap };
211
+ return { doc: chunkAIS37SL2_cjs.updateBlock(doc, block, (b) => withRegion(b, region, change(inline))), map: identityMap };
267
212
  },
268
213
  invert(before) {
269
214
  const inline = requireRange(requireBlock(before, block), region, from, to);
270
- return replaceInlineStep(block, region, from, to, _chunk4SLJNZSMcjs.sliceInline.call(void 0, inline, from, to));
215
+ return replaceInlineStep(block, region, from, to, chunkAIS37SL2_cjs.sliceInline(inline, from, to));
271
216
  },
272
217
  toJSON: () => ({ stepType, ...target, mark })
273
218
  });
274
219
  }
275
220
  function addMarkStep(block, region, from, to, mark) {
276
- return markStep("addMark", { block, region, from, to }, mark, (inline) => _chunk4SLJNZSMcjs.addMarkRange.call(void 0, inline, from, to, mark));
221
+ return markStep("addMark", { block, region, from, to }, mark, (inline) => chunkAIS37SL2_cjs.addMarkRange(inline, from, to, mark));
277
222
  }
278
223
  function removeMarkStep(block, region, from, to, mark) {
279
224
  return markStep(
280
225
  "removeMark",
281
226
  { block, region, from, to },
282
227
  mark,
283
- (inline) => _chunk4SLJNZSMcjs.removeMarkRange.call(void 0, inline, from, to, mark)
228
+ (inline) => chunkAIS37SL2_cjs.removeMarkRange(inline, from, to, mark)
284
229
  );
285
230
  }
286
231
 
@@ -310,7 +255,7 @@ function mapTextChange(before, after) {
310
255
  const ops = removed.length + added.length > DIFF_LIMIT ? [
311
256
  { op: "delete", items: removed },
312
257
  { op: "insert", items: added }
313
- ] : _chunk6V6GGBDKcjs.diffSequences.call(void 0, removed.split(""), added.split(""));
258
+ ] : chunk7SVKLWDT_cjs.diffSequences(removed.split(""), added.split(""));
314
259
  return (offset, assoc) => {
315
260
  let b = from;
316
261
  let a = from;
@@ -336,19 +281,19 @@ function replaceDocStep(next) {
336
281
  const regionMaps = /* @__PURE__ */ new Map();
337
282
  const map = (pos, assoc = 1) => {
338
283
  const { block, region } = pos;
339
- const survivor = _chunk4SLJNZSMcjs.blockById.call(void 0, next, block);
284
+ const survivor = chunkAIS37SL2_cjs.blockById(next, block);
340
285
  if (survivor !== void 0) {
341
286
  const key = JSON.stringify([block, region]);
342
287
  let regionMap = regionMaps.get(key);
343
288
  if (regionMap === void 0) {
344
- const before = _chunk4SLJNZSMcjs.inlineText.call(void 0, _nullishCoalesce(_optionalChain([_chunk4SLJNZSMcjs.blockById.call(void 0, doc, block), 'optionalAccess', _2 => _2.regions, 'access', _3 => _3[region]]), () => ( [])));
345
- regionMap = mapTextChange(before, _chunk4SLJNZSMcjs.inlineText.call(void 0, _nullishCoalesce(survivor.regions[region], () => ( []))));
289
+ const before = chunkAIS37SL2_cjs.inlineText(chunkAIS37SL2_cjs.blockById(doc, block)?.regions[region] ?? []);
290
+ regionMap = mapTextChange(before, chunkAIS37SL2_cjs.inlineText(survivor.regions[region] ?? []));
346
291
  regionMaps.set(key, regionMap);
347
292
  }
348
293
  const offset = regionMap(pos.offset, assoc);
349
294
  return clampPos(survivor, offset === pos.offset ? pos : { ...pos, offset });
350
295
  }
351
- const nearest = next.blocks[Math.min(_nullishCoalesce(doc.index.get(block), () => ( 0)), next.blocks.length - 1)];
296
+ const nearest = next.blocks[Math.min(doc.index.get(block) ?? 0, next.blocks.length - 1)];
352
297
  return nearest === void 0 ? pos : blockStart(nearest);
353
298
  };
354
299
  return { doc: next, map };
@@ -376,10 +321,10 @@ function splitBlockStep(block, region, offset, created) {
376
321
  type: created.type,
377
322
  indent: created.indent,
378
323
  attrs: created.attrs,
379
- regions: { ...created.regions, [created.region]: _chunk4SLJNZSMcjs.sliceInline.call(void 0, inline, offset, _chunk4SLJNZSMcjs.inlineLength.call(void 0, inline)) }
324
+ regions: { ...created.regions, [created.region]: chunkAIS37SL2_cjs.sliceInline(inline, offset, chunkAIS37SL2_cjs.inlineLength(inline)) }
380
325
  };
381
- const head = withRegion(target, region, _chunk4SLJNZSMcjs.sliceInline.call(void 0, inline, 0, offset));
382
- return { doc: _chunk4SLJNZSMcjs.replaceBlocks.call(void 0, doc, _chunk4SLJNZSMcjs.indexOfBlock.call(void 0, doc, block), 1, [head, tail]), map };
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 };
383
328
  },
384
329
  invert: () => joinBlocksStep(block, region, created.id, created.region),
385
330
  toJSON: () => ({ stepType: "splitBlock", block, region, offset, created })
@@ -391,17 +336,17 @@ function joinBlocksStep(target, targetRegion, source, sourceRegion) {
391
336
  apply(doc) {
392
337
  const first = requireBlock(doc, target);
393
338
  const second = requireBlock(doc, source);
394
- const index = _chunk4SLJNZSMcjs.indexOfBlock.call(void 0, doc, target);
395
- if (_chunk4SLJNZSMcjs.indexOfBlock.call(void 0, doc, source) !== index + 1) throw new StepError(`block "${source}" does not follow "${target}"`);
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}"`);
396
341
  const head = requireRegion(first, targetRegion);
397
- const length = _chunk4SLJNZSMcjs.inlineLength.call(void 0, head);
398
- const merged = _chunk4SLJNZSMcjs.replaceInline.call(void 0, head, length, length, requireRegion(second, sourceRegion));
342
+ const length = chunkAIS37SL2_cjs.inlineLength(head);
343
+ const merged = chunkAIS37SL2_cjs.replaceInline(head, length, length, requireRegion(second, sourceRegion));
399
344
  const map = (pos) => pos.block === source ? { block: target, region: targetRegion, offset: length + (pos.region === sourceRegion ? pos.offset : 0) } : pos;
400
- return { doc: _chunk4SLJNZSMcjs.replaceBlocks.call(void 0, doc, index, 2, [withRegion(first, targetRegion, merged)]), map };
345
+ return { doc: chunkAIS37SL2_cjs.replaceBlocks(doc, index, 2, [withRegion(first, targetRegion, merged)]), map };
401
346
  },
402
347
  invert(before) {
403
348
  const { id, type, attrs, indent: indent2, regions } = requireBlock(before, source);
404
- const length = _chunk4SLJNZSMcjs.inlineLength.call(void 0, requireRegion(requireBlock(before, target), targetRegion));
349
+ const length = chunkAIS37SL2_cjs.inlineLength(requireRegion(requireBlock(before, target), targetRegion));
405
350
  const created = { id, type, attrs, indent: indent2, region: sourceRegion, regions };
406
351
  return splitBlockStep(target, targetRegion, length, created);
407
352
  },
@@ -410,9 +355,9 @@ function joinBlocksStep(target, targetRegion, source, sourceRegion) {
410
355
  }
411
356
 
412
357
  // src/engine/transform/step-json.ts
413
- var isRegions = (value) => _chunk4SLJNZSMcjs.isRecord.call(void 0, value) && Object.values(value).every(Array.isArray);
414
- var isMark = (value) => _chunk4SLJNZSMcjs.isRecord.call(void 0, value) && typeof value.type === "string" && (value.attrs === void 0 || _chunk4SLJNZSMcjs.isRecord.call(void 0, value.attrs));
415
- var isBlockShape = (value) => _chunk4SLJNZSMcjs.isRecord.call(void 0, value) && typeof value.id === "string" && typeof value.type === "string" && Number.isInteger(value.indent) && _chunk4SLJNZSMcjs.isRecord.call(void 0, value.attrs);
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);
416
361
  var isBlock = (value) => isBlockShape(value) && isRegions(value.regions);
417
362
  var isCreated = (value) => isBlockShape(value) && typeof value.region === "string" && (value.regions === void 0 || isRegions(value.regions));
418
363
  var isString = (value) => typeof value === "string";
@@ -424,7 +369,7 @@ function docOf(blocks) {
424
369
  if (new Set(blocks.map((block) => block.id)).size !== blocks.length) {
425
370
  throw new StepError("a replaceDoc step repeats a block id");
426
371
  }
427
- return _chunk4SLJNZSMcjs.createDoc.call(void 0, blocks);
372
+ return chunkAIS37SL2_cjs.createDoc(blocks);
428
373
  }
429
374
  function reader(json) {
430
375
  return (key, accept) => {
@@ -461,7 +406,7 @@ function stepFromJSON(json) {
461
406
  read("mark", isMarkOrType)
462
407
  );
463
408
  case "setAttrs":
464
- return setAttrsStep(read("block", isString), patchFromJSON(read("patch", _chunk4SLJNZSMcjs.isRecord)));
409
+ return setAttrsStep(read("block", isString), patchFromJSON(read("patch", chunkAIS37SL2_cjs.isRecord)));
465
410
  case "setIndent":
466
411
  return setIndentStep(read("block", isString), read("indent", isInteger));
467
412
  case "insertBlocks":
@@ -495,7 +440,7 @@ function stepFromJSON(json) {
495
440
 
496
441
  // src/engine/model/position.ts
497
442
  function comparePos(doc, a, b) {
498
- return _chunk4SLJNZSMcjs.requireBlockIndex.call(void 0, doc, a.block) - _chunk4SLJNZSMcjs.requireBlockIndex.call(void 0, doc, b.block) || _chunk4SLJNZSMcjs.compareRegionNames.call(void 0, a.region, b.region) || a.offset - b.offset;
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;
499
444
  }
500
445
  function orderedRange(doc, anchor, head) {
501
446
  return comparePos(doc, anchor, head) <= 0 ? { from: anchor, to: head } : { from: head, to: anchor };
@@ -513,7 +458,7 @@ function blockRangeSelection(anchor, head = anchor) {
513
458
  }
514
459
  var samePos = (a, b) => a.block === b.block && a.region === b.region && a.offset === b.offset;
515
460
  function isCollapsed(selection) {
516
- return _optionalChain([selection, 'optionalAccess', _4 => _4.kind]) === "text" && samePos(selection.anchor, selection.head);
461
+ return selection?.kind === "text" && samePos(selection.anchor, selection.head);
517
462
  }
518
463
  function sameSelection(a, b) {
519
464
  if (a === b) return true;
@@ -528,13 +473,13 @@ function sameSelection(a, b) {
528
473
  }
529
474
  }
530
475
  function selectionRange(doc, selection) {
531
- return _optionalChain([selection, 'optionalAccess', _5 => _5.kind]) === "text" ? orderedRange(doc, selection.anchor, selection.head) : null;
476
+ return selection?.kind === "text" ? orderedRange(doc, selection.anchor, selection.head) : null;
532
477
  }
533
478
  function selectedBlockIds(doc, selection) {
534
479
  if (selection === null) return [];
535
480
  if (selection.kind === "node") return [selection.block];
536
481
  const ends = selection.kind === "text" ? [selection.anchor.block, selection.head.block] : [selection.anchor, selection.head];
537
- const [first, second] = ends.map((id) => _chunk4SLJNZSMcjs.requireBlockIndex.call(void 0, doc, id));
482
+ const [first, second] = ends.map((id) => chunkAIS37SL2_cjs.requireBlockIndex(doc, id));
538
483
  return doc.blocks.slice(Math.min(first, second), Math.max(first, second) + 1).map((block) => block.id);
539
484
  }
540
485
  function isBackward(doc, selection) {
@@ -542,7 +487,7 @@ function isBackward(doc, selection) {
542
487
  const { anchor, head } = selection;
543
488
  return doc.index.has(anchor.block) && doc.index.has(head.block) && comparePos(doc, anchor, head) > 0;
544
489
  }
545
- return doc.index.has(selection.anchor) && doc.index.has(selection.head) && _chunk4SLJNZSMcjs.indexOfBlock.call(void 0, doc, selection.anchor) > _chunk4SLJNZSMcjs.indexOfBlock.call(void 0, doc, selection.head);
490
+ return doc.index.has(selection.anchor) && doc.index.has(selection.head) && chunkAIS37SL2_cjs.indexOfBlock(doc, selection.anchor) > chunkAIS37SL2_cjs.indexOfBlock(doc, selection.head);
546
491
  }
547
492
  var blockProbe = (block) => ({ block, region: "", offset: 0 });
548
493
  function mapSelection(selection, map, doc) {
@@ -561,18 +506,18 @@ function mapSelection(selection, map, doc) {
561
506
  return anchor === selection.anchor && head === selection.head ? selection : textSelection(anchor, head);
562
507
  }
563
508
  function primaryRegion(schema, block) {
564
- const spec = _chunk4SLJNZSMcjs.specFor.call(void 0, schema, block.type);
509
+ const spec = chunkAIS37SL2_cjs.specFor(schema, block.type);
565
510
  if (spec.flow === "text" && spec.primaryRegion !== void 0 && Object.hasOwn(block.regions, spec.primaryRegion)) {
566
511
  return spec.primaryRegion;
567
512
  }
568
513
  return firstRegion(block);
569
514
  }
570
515
  function flowEdge(schema, block, atEnd) {
571
- const region = _chunk4SLJNZSMcjs.specFor.call(void 0, schema, block.type).flow === "text" ? primaryRegion(schema, block) : null;
572
- return region === null ? null : { block: block.id, region, offset: atEnd ? _chunk4SLJNZSMcjs.inlineLength.call(void 0, block.regions[region]) : 0 };
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 };
573
518
  }
574
519
  function edge(doc, schema, blockId, atEnd) {
575
- const block = doc.blocks[_chunk4SLJNZSMcjs.requireBlockIndex.call(void 0, doc, blockId)];
520
+ const block = doc.blocks[chunkAIS37SL2_cjs.requireBlockIndex(doc, blockId)];
576
521
  const flow = flowEdge(schema, block, atEnd);
577
522
  if (flow !== null) return textSelection(flow);
578
523
  if (Object.keys(block.regions).length === 0) return nodeSelection(blockId);
@@ -588,13 +533,13 @@ function defaultSelection(doc, schema) {
588
533
  return doc.blocks.length === 0 ? null : startOf(doc, schema, doc.blocks[0].id);
589
534
  }
590
535
  function validatePos(doc, schema, pos) {
591
- const block = _chunk4SLJNZSMcjs.blockById.call(void 0, doc, pos.block);
536
+ const block = chunkAIS37SL2_cjs.blockById(doc, pos.block);
592
537
  if (block === void 0) return null;
593
538
  if (!Object.hasOwn(block.regions, pos.region)) {
594
539
  const region = primaryRegion(schema, block);
595
540
  return region === null ? nodeSelection(block.id) : { block: block.id, region, offset: 0 };
596
541
  }
597
- const length = _chunk4SLJNZSMcjs.inlineLength.call(void 0, block.regions[pos.region]);
542
+ const length = chunkAIS37SL2_cjs.inlineLength(block.regions[pos.region]);
598
543
  return pos.offset >= 0 && pos.offset <= length ? pos : { ...pos, offset: Math.min(Math.max(pos.offset, 0), length) };
599
544
  }
600
545
  function nearestFlow(doc, schema, from, to, atEnd) {
@@ -605,14 +550,14 @@ function nearestFlow(doc, schema, from, to, atEnd) {
605
550
  }
606
551
  return null;
607
552
  }
608
- var inFlow = (doc, schema, pos) => _optionalChain([flowEdge, 'call', _6 => _6(schema, doc.blocks[_chunk4SLJNZSMcjs.requireBlockIndex.call(void 0, doc, pos.block)], false), 'optionalAccess', _7 => _7.region]) === pos.region;
553
+ var inFlow = (doc, schema, pos) => flowEdge(schema, doc.blocks[chunkAIS37SL2_cjs.requireBlockIndex(doc, pos.block)], false)?.region === pos.region;
609
554
  function clampToFlow(doc, schema, selection) {
610
555
  const { anchor, head } = selection;
611
556
  if (anchor.block === head.block) return selection;
612
557
  const backward = comparePos(doc, anchor, head) > 0;
613
558
  const [from, to] = backward ? [head, anchor] : [anchor, head];
614
- const first = _chunk4SLJNZSMcjs.requireBlockIndex.call(void 0, doc, from.block);
615
- const last = _chunk4SLJNZSMcjs.requireBlockIndex.call(void 0, doc, to.block);
559
+ const first = chunkAIS37SL2_cjs.requireBlockIndex(doc, from.block);
560
+ const last = chunkAIS37SL2_cjs.requireBlockIndex(doc, to.block);
616
561
  const start = inFlow(doc, schema, from) ? from : nearestFlow(doc, schema, first + 1, last, false);
617
562
  const end = inFlow(doc, schema, to) ? to : nearestFlow(doc, schema, last - 1, first, true);
618
563
  if (start === from && end === to) return selection;
@@ -631,9 +576,9 @@ function validateText(doc, schema, selection) {
631
576
  return clampToFlow(doc, schema, valid);
632
577
  }
633
578
  function validateNode(doc, schema, selection) {
634
- const block = _chunk4SLJNZSMcjs.blockById.call(void 0, doc, selection.block);
579
+ const block = chunkAIS37SL2_cjs.blockById(doc, selection.block);
635
580
  if (block === void 0) return defaultSelection(doc, schema);
636
- return _chunk4SLJNZSMcjs.specFor.call(void 0, schema, block.type).flow === "text" ? startOf(doc, schema, block.id) : selection;
581
+ return chunkAIS37SL2_cjs.specFor(schema, block.type).flow === "text" ? startOf(doc, schema, block.id) : selection;
637
582
  }
638
583
  function validateSelection(doc, schema, selection) {
639
584
  if (doc.blocks.length === 0) return null;
@@ -664,7 +609,7 @@ function hidingToggle(doc, index, isClosed = isClosedToggle) {
664
609
  }
665
610
 
666
611
  // src/engine/state/visible-selection.ts
667
- var hiderOf = (doc, id) => hidingToggle(doc, _chunk4SLJNZSMcjs.requireBlockIndex.call(void 0, doc, id) + 1);
612
+ var hiderOf = (doc, id) => hidingToggle(doc, chunkAIS37SL2_cjs.requireBlockIndex(doc, id) + 1);
668
613
  function toggleEnd(doc, schema, toggle) {
669
614
  const end = endOf(doc, schema, doc.blocks[toggle].id);
670
615
  return end.kind === "text" ? end.head : blockEnd(doc.blocks[toggle]);
@@ -678,7 +623,7 @@ function visibleText(doc, schema, selection) {
678
623
  }
679
624
  function visibleBlocks(doc, schema, selection) {
680
625
  const ids = [selection.anchor, selection.head];
681
- const indexes = ids.map((id) => _chunk4SLJNZSMcjs.requireBlockIndex.call(void 0, doc, id));
626
+ const indexes = ids.map((id) => chunkAIS37SL2_cjs.requireBlockIndex(doc, id));
682
627
  const from = Math.min(...indexes);
683
628
  const to = Math.max(...indexes);
684
629
  const hiders = indexes.map((index) => hidingToggle(doc, index + 1));
@@ -755,8 +700,8 @@ function createPluginKey(name) {
755
700
  var foreignOrigins = ["remote", "reconcile", "history"];
756
701
  var UNFILTERED = "unfiltered";
757
702
  var Transaction = class {
758
-
759
-
703
+ before;
704
+ time;
760
705
  #currentDoc;
761
706
  #currentSelection;
762
707
  #currentStoredMarks;
@@ -804,7 +749,7 @@ var Transaction = class {
804
749
  return this.#metaValues;
805
750
  }
806
751
  get origin() {
807
- return _nullishCoalesce(this.getMeta("origin"), () => ( "command"));
752
+ return this.getMeta("origin") ?? "command";
808
753
  }
809
754
  get addToHistory() {
810
755
  return this.getMeta("addToHistory") !== false;
@@ -859,8 +804,8 @@ var Transaction = class {
859
804
  // src/engine/commands/caret-marks.ts
860
805
  function caretMarks(doc, schema, storedMarks, pos) {
861
806
  if (storedMarks !== null) return storedMarks;
862
- const inline = _nullishCoalesce(_optionalChain([_chunk4SLJNZSMcjs.blockById.call(void 0, doc, pos.block), 'optionalAccess', _8 => _8.regions, 'access', _9 => _9[pos.region]]), () => ( []));
863
- return _chunk4SLJNZSMcjs.marksAt.call(void 0, inline, pos.offset, (mark) => _nullishCoalesce(_optionalChain([schema, 'access', _10 => _10.marks, 'access', _11 => _11.get, 'call', _12 => _12(mark.type), 'optionalAccess', _13 => _13.inclusive]), () => ( true)));
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);
864
809
  }
865
810
 
866
811
  // src/engine/commands/run-commands.ts
@@ -923,16 +868,16 @@ function invertTransaction(tr) {
923
868
  }
924
869
  var newest = (items, depth) => items.slice(Math.max(0, items.length - depth));
925
870
  function groupKey(selection) {
926
- return _optionalChain([selection, 'optionalAccess', _14 => _14.kind]) === "text" ? JSON.stringify([selection.head.block, selection.head.region]) : null;
871
+ return selection?.kind === "text" ? JSON.stringify([selection.head.block, selection.head.region]) : null;
927
872
  }
928
873
  function groupOf(tr) {
929
874
  if (tr.getMeta("closeHistory") === true) return null;
930
- return _nullishCoalesce(tr.getMeta(HISTORY_GROUP), () => ( (tr.origin === "input" ? groupKey(tr.before.selection) : null)));
875
+ return tr.getMeta(HISTORY_GROUP) ?? (tr.origin === "input" ? groupKey(tr.before.selection) : null);
931
876
  }
932
877
  function inputRuleRecord(tr, steps) {
933
878
  const rule = tr.getMeta("inputRule");
934
879
  const before = tr.before.selection;
935
- if (rule === void 0 || _optionalChain([before, 'optionalAccess', _15 => _15.kind]) !== "text" || !isCollapsed(before)) return null;
880
+ if (rule === void 0 || before?.kind !== "text" || !isCollapsed(before)) return null;
936
881
  const { doc, schema, storedMarks } = tr.before;
937
882
  return { steps, undoText: rule.undoText, at: before.head, marks: caretMarks(doc, schema, storedMarks, before.head) };
938
883
  }
@@ -947,18 +892,18 @@ function recorded(tr, value, { depth, groupDelay }) {
947
892
  function moved(tr, value, direction, depth) {
948
893
  const undoing = direction === "undo";
949
894
  const source = undoing ? value.done : value.undone;
950
- const applied = source.length - 1 - (_nullishCoalesce(tr.getMeta("historySkipped"), () => ( 0)));
895
+ const applied = source.length - 1 - (tr.getMeta("historySkipped") ?? 0);
951
896
  const inverse = {
952
897
  steps: invertTransaction(tr),
953
898
  selection: tr.before.selection,
954
- origin: _nullishCoalesce(_optionalChain([source, 'access', _16 => _16[applied], 'optionalAccess', _17 => _17.origin]), () => ( tr.origin))
899
+ origin: source[applied]?.origin ?? tr.origin
955
900
  };
956
901
  const rest = source.slice(0, applied);
957
902
  const target = newest([...undoing ? value.undone : value.done, inverse], depth);
958
903
  const stacks = undoing ? { done: rest, undone: target } : { done: target, undone: rest };
959
904
  return { ...value, ...stacks, lastGroup: null, lastInputRule: null };
960
905
  }
961
- var movesNoPosition = (tr) => tr.steps.every((_, i) => isPositionNeutral(tr.docs[i], { doc: _nullishCoalesce(tr.docs[i + 1], () => ( tr.doc)), map: tr.maps[i] }));
906
+ var movesNoPosition = (tr) => tr.steps.every((_, i) => isPositionNeutral(tr.docs[i], { doc: tr.docs[i + 1] ?? tr.doc, map: tr.maps[i] }));
962
907
  function advance(tr, value, config) {
963
908
  if (tr.docChanged) {
964
909
  const direction = tr.getMeta("history");
@@ -975,7 +920,7 @@ function advance(tr, value, config) {
975
920
  };
976
921
  }
977
922
  function historyPlugin(options = {}) {
978
- const config = { depth: _nullishCoalesce(options.depth, () => ( 200)), groupDelay: _nullishCoalesce(options.groupDelay, () => ( 500)) };
923
+ const config = { depth: options.depth ?? 200, groupDelay: options.groupDelay ?? 500 };
979
924
  return { key: historyKey, init: () => emptyHistory, apply: (tr, value) => advance(tr, value, config) };
980
925
  }
981
926
  function travel(direction) {
@@ -983,13 +928,13 @@ function travel(direction) {
983
928
  const provider = state.pluginState.get(HISTORY_PROVIDER);
984
929
  if (provider) return !(dispatch && chainDispatches.has(dispatch)) && provider[direction](!dispatch);
985
930
  const history = historyOf(state);
986
- const items = _nullishCoalesce((direction === "undo" ? _optionalChain([history, 'optionalAccess', _18 => _18.done]) : _optionalChain([history, 'optionalAccess', _19 => _19.undone])), () => ( []));
931
+ const items = (direction === "undo" ? history?.done : history?.undone) ?? [];
987
932
  for (let i = items.length - 1; i >= 0; i--) {
988
933
  const tr = new Transaction(state).setOrigin("history").setMeta("history", direction);
989
934
  if (!items[i].steps.every((step) => tr.maybeStep(step))) continue;
990
935
  const { selection } = items[i];
991
936
  if (selection !== null) tr.setSelection(selection);
992
- _optionalChain([dispatch, 'optionalCall', _20 => _20(tr.setMeta("historySkipped", items.length - 1 - i))]);
937
+ dispatch?.(tr.setMeta("historySkipped", items.length - 1 - i));
993
938
  return true;
994
939
  }
995
940
  return false;
@@ -998,13 +943,13 @@ function travel(direction) {
998
943
  var undo = travel("undo");
999
944
  var redo = travel("redo");
1000
945
  var undoInputRule = (state, dispatch) => {
1001
- const record = _optionalChain([historyOf, 'call', _21 => _21(state), 'optionalAccess', _22 => _22.lastInputRule]);
946
+ const record = historyOf(state)?.lastInputRule;
1002
947
  if (record === null || record === void 0) return false;
1003
948
  if (dispatch !== void 0) {
1004
949
  const { steps, undoText, at, marks } = record;
1005
950
  const tr = new Transaction(state).setMeta(UNFILTERED, true);
1006
951
  steps.forEach((step) => tr.step(step));
1007
- tr.step(replaceInlineStep(at.block, at.region, at.offset, at.offset, [_chunk4SLJNZSMcjs.text.call(void 0, undoText, marks)]));
952
+ tr.step(replaceInlineStep(at.block, at.region, at.offset, at.offset, [chunkAIS37SL2_cjs.text(undoText, marks)]));
1008
953
  dispatch(tr.setSelection(textSelection({ ...at, offset: at.offset + undoText.length })));
1009
954
  }
1010
955
  return true;
@@ -1013,7 +958,7 @@ var undoInputRule = (state, dispatch) => {
1013
958
  // src/engine/commands/block-helpers.ts
1014
959
  var ITEM_KINDS = /* @__PURE__ */ new Set(["bullet", "ordered", "task", "quote"]);
1015
960
  function specOf(schema, block) {
1016
- return _chunk4SLJNZSMcjs.specFor.call(void 0, schema, block.type);
961
+ return chunkAIS37SL2_cjs.specFor(schema, block.type);
1017
962
  }
1018
963
  function isTextFlow(schema, block) {
1019
964
  return specOf(schema, block).flow === "text";
@@ -1025,7 +970,7 @@ function isItem(block) {
1025
970
  return block.type === "MARKDOWN" && typeof block.attrs.kind === "string" && ITEM_KINDS.has(block.attrs.kind);
1026
971
  }
1027
972
  function regionLength(block, region) {
1028
- return Object.hasOwn(block.regions, region) ? _chunk4SLJNZSMcjs.inlineLength.call(void 0, block.regions[region]) : 0;
973
+ return Object.hasOwn(block.regions, region) ? chunkAIS37SL2_cjs.inlineLength(block.regions[region]) : 0;
1029
974
  }
1030
975
  function descendantsEnd(doc, index) {
1031
976
  const { indent: indent2 } = doc.blocks[index];
@@ -1033,16 +978,16 @@ function descendantsEnd(doc, index) {
1033
978
  while (end < doc.blocks.length && doc.blocks[end].indent > indent2) end++;
1034
979
  return end;
1035
980
  }
1036
- function createBlock(schema, type, attrs = {}, indent2 = 0, id = _chunk4SLJNZSMcjs.newId.call(void 0, )) {
1037
- const initial = _chunk4SLJNZSMcjs.specFor.call(void 0, schema, type).initial();
981
+ function createBlock(schema, type, attrs = {}, indent2 = 0, id = chunkAIS37SL2_cjs.newId()) {
982
+ const initial = chunkAIS37SL2_cjs.specFor(schema, type).initial();
1038
983
  return { id, type, indent: indent2, attrs: { ...initial.attrs, ...attrs }, regions: initial.regions };
1039
984
  }
1040
985
  function withContent(schema, block, content) {
1041
- const region = _nullishCoalesce(primaryRegion(schema, block), () => ( ""));
986
+ const region = primaryRegion(schema, block) ?? "";
1042
987
  return { ...block, regions: { ...block.regions, [region]: content } };
1043
988
  }
1044
989
  function startPos(schema, block) {
1045
- return { block: block.id, region: _nullishCoalesce(primaryRegion(schema, block), () => ( "")), offset: 0 };
990
+ return { block: block.id, region: primaryRegion(schema, block) ?? "", offset: 0 };
1046
991
  }
1047
992
  function headBlockId(selection) {
1048
993
  if (selection === null) return null;
@@ -1052,7 +997,7 @@ function headBlockId(selection) {
1052
997
  function selectedBlockRange(doc, selection) {
1053
998
  const ids = selectedBlockIds(doc, selection);
1054
999
  if (ids.length === 0) return null;
1055
- const start = _chunk4SLJNZSMcjs.indexOfBlock.call(void 0, doc, ids[0]);
1000
+ const start = chunkAIS37SL2_cjs.indexOfBlock(doc, ids[0]);
1056
1001
  let end = start + ids.length;
1057
1002
  for (let index = start; index < start + ids.length; index++) end = Math.max(end, descendantsEnd(doc, index));
1058
1003
  return { start, end };
@@ -1068,7 +1013,7 @@ function capIndents(tr, start, end = start) {
1068
1013
  let sibling;
1069
1014
  while (levels.length > 0 && levels[levels.length - 1].from >= indent2) sibling = levels.pop();
1070
1015
  const parent = levels.length > 0 ? levels[levels.length - 1].to : base;
1071
- const next = _optionalChain([sibling, 'optionalAccess', _23 => _23.from]) === indent2 ? sibling.to : Math.min(indent2, parent + 1);
1016
+ const next = sibling?.from === indent2 ? sibling.to : Math.min(indent2, parent + 1);
1072
1017
  if (next === indent2 && at >= end) return;
1073
1018
  if (next !== indent2) tr.step(setIndentStep(id, next));
1074
1019
  levels.push({ from: indent2, to: next });
@@ -1096,12 +1041,12 @@ function shiftSubtree(tr, index, delta) {
1096
1041
  // src/engine/commands/block-structure.ts
1097
1042
  var toggleTask = (state, dispatch) => {
1098
1043
  const { doc, selection } = state;
1099
- const tasks = selectedBlockIds(doc, selection).map((id) => doc.blocks[_chunk4SLJNZSMcjs.requireBlockIndex.call(void 0, doc, id)]).filter((block) => block.type === "MARKDOWN" && block.attrs.kind === "task");
1044
+ const tasks = selectedBlockIds(doc, selection).map((id) => doc.blocks[chunkAIS37SL2_cjs.requireBlockIndex(doc, id)]).filter((block) => block.type === "MARKDOWN" && block.attrs.kind === "task");
1100
1045
  if (tasks.length === 0) return false;
1101
1046
  const checked = !tasks.every((block) => block.attrs.checked === true);
1102
1047
  const tr = new Transaction(state);
1103
1048
  for (const block of tasks) tr.step(setAttrsStep(block.id, { checked }));
1104
- _optionalChain([dispatch, 'optionalCall', _24 => _24(tr)]);
1049
+ dispatch?.(tr);
1105
1050
  return true;
1106
1051
  };
1107
1052
  function reindentCommand(delta) {
@@ -1116,7 +1061,7 @@ function reindentCommand(delta) {
1116
1061
  if (shift !== 0) shiftSubtree(tr, root, shift);
1117
1062
  }
1118
1063
  if (!tr.docChanged) return false;
1119
- _optionalChain([dispatch, 'optionalCall', _25 => _25(tr)]);
1064
+ dispatch?.(tr);
1120
1065
  return true;
1121
1066
  };
1122
1067
  }
@@ -1142,14 +1087,14 @@ function moveCommand(direction) {
1142
1087
  const tr = new Transaction(state).step(moveBlocksStep(range.start, count2, to));
1143
1088
  capIndents(tr, to);
1144
1089
  capIndents(tr, to + count2);
1145
- _optionalChain([dispatch, 'optionalCall', _26 => _26(tr)]);
1090
+ dispatch?.(tr);
1146
1091
  return true;
1147
1092
  };
1148
1093
  }
1149
1094
  var moveBlocksUp = moveCommand("up");
1150
1095
  var moveBlocksDown = moveCommand("down");
1151
1096
  function copiedSelection(selection, copies) {
1152
- const copy = (id) => _nullishCoalesce(copies.get(id), () => ( id));
1097
+ const copy = (id) => copies.get(id) ?? id;
1153
1098
  const copyPos = (pos) => ({ ...pos, block: copy(pos.block) });
1154
1099
  switch (selection.kind) {
1155
1100
  case "text":
@@ -1161,7 +1106,7 @@ function copiedSelection(selection, copies) {
1161
1106
  }
1162
1107
  }
1163
1108
  function duplicateBlocks(options = {}) {
1164
- const makeId = _nullishCoalesce(options.newId, () => ( _chunk4SLJNZSMcjs.newId));
1109
+ const makeId = options.newId ?? chunkAIS37SL2_cjs.newId;
1165
1110
  return (state, dispatch) => {
1166
1111
  const { doc, selection } = state;
1167
1112
  const range = selectedBlockRange(doc, selection);
@@ -1170,7 +1115,7 @@ function duplicateBlocks(options = {}) {
1170
1115
  const copies = new Map(blocks.map((copy, i) => [doc.blocks[range.start + i].id, copy.id]));
1171
1116
  const tr = new Transaction(state).step(insertBlocksStep(range.end, blocks));
1172
1117
  capIndents(tr, range.end);
1173
- _optionalChain([dispatch, 'optionalCall', _27 => _27(tr.setSelection(copiedSelection(selection, copies)))]);
1118
+ dispatch?.(tr.setSelection(copiedSelection(selection, copies)));
1174
1119
  return true;
1175
1120
  };
1176
1121
  }
@@ -1179,22 +1124,22 @@ var deleteBlocks = (state, dispatch) => {
1179
1124
  if (range === null) return false;
1180
1125
  const tr = new Transaction(state);
1181
1126
  removeBlocks(tr, state.schema, range.start, range.end - range.start);
1182
- _optionalChain([dispatch, 'optionalCall', _28 => _28(tr)]);
1127
+ dispatch?.(tr);
1183
1128
  return true;
1184
1129
  };
1185
1130
  function insertBlockAfter(type, attrs, options = {}) {
1186
- const makeId = _nullishCoalesce(options.newId, () => ( _chunk4SLJNZSMcjs.newId));
1131
+ const makeId = options.newId ?? chunkAIS37SL2_cjs.newId;
1187
1132
  return (state, dispatch) => {
1188
1133
  const { doc, schema } = state;
1189
1134
  const id = headBlockId(state.selection);
1190
1135
  if (id === null) return false;
1191
- const index = _chunk4SLJNZSMcjs.requireBlockIndex.call(void 0, doc, id);
1136
+ const index = chunkAIS37SL2_cjs.requireBlockIndex(doc, id);
1192
1137
  const current = doc.blocks[index];
1193
- const fillsCurrent = isParagraph(current) && regionLength(current, _nullishCoalesce(primaryRegion(schema, current), () => ( ""))) === 0;
1138
+ const fillsCurrent = isParagraph(current) && regionLength(current, primaryRegion(schema, current) ?? "") === 0;
1194
1139
  const block = createBlock(schema, type, attrs, current.indent, fillsCurrent ? current.id : makeId());
1195
1140
  const step = fillsCurrent ? replaceBlockStep(block) : insertBlocksStep(descendantsEnd(doc, index), [block]);
1196
1141
  const tr = new Transaction(state).step(step);
1197
- _optionalChain([dispatch, 'optionalCall', _29 => _29(tr.setSelection(startOf(tr.doc, schema, block.id)))]);
1142
+ dispatch?.(tr.setSelection(startOf(tr.doc, schema, block.id)));
1198
1143
  return true;
1199
1144
  };
1200
1145
  }
@@ -1208,10 +1153,10 @@ function deleteWithinBlock(tr, from, to) {
1208
1153
  clear(tr, from, from.offset, to.offset);
1209
1154
  return from;
1210
1155
  }
1211
- const block = tr.doc.blocks[_chunk4SLJNZSMcjs.requireBlockIndex.call(void 0, tr.doc, from.block)];
1156
+ const block = tr.doc.blocks[chunkAIS37SL2_cjs.requireBlockIndex(tr.doc, from.block)];
1212
1157
  clear(tr, from, from.offset, regionLength(block, from.region));
1213
1158
  for (const region of Object.keys(block.regions)) {
1214
- const between = _chunk4SLJNZSMcjs.compareRegionNames.call(void 0, from.region, region) < 0 && _chunk4SLJNZSMcjs.compareRegionNames.call(void 0, region, to.region) < 0;
1159
+ const between = chunkAIS37SL2_cjs.compareRegionNames(from.region, region) < 0 && chunkAIS37SL2_cjs.compareRegionNames(region, to.region) < 0;
1215
1160
  if (between) clear(tr, { ...from, region }, 0, regionLength(block, region));
1216
1161
  }
1217
1162
  clear(tr, to, 0, to.offset);
@@ -1220,8 +1165,8 @@ function deleteWithinBlock(tr, from, to) {
1220
1165
  function deleteRange(tr, schema, from, to, newId2) {
1221
1166
  if (from.block === to.block) return deleteWithinBlock(tr, from, to);
1222
1167
  const { doc } = tr;
1223
- const start = _chunk4SLJNZSMcjs.requireBlockIndex.call(void 0, doc, from.block);
1224
- const end = _chunk4SLJNZSMcjs.requireBlockIndex.call(void 0, doc, to.block);
1168
+ const start = chunkAIS37SL2_cjs.requireBlockIndex(doc, from.block);
1169
+ const end = chunkAIS37SL2_cjs.requireBlockIndex(doc, to.block);
1225
1170
  const first = doc.blocks[start];
1226
1171
  const last = doc.blocks[end];
1227
1172
  const keepFirst = isTextFlow(schema, first);
@@ -1240,7 +1185,7 @@ function deleteRange(tr, schema, from, to, newId2) {
1240
1185
  capIndents(tr, start);
1241
1186
  return { block: last.id, region: to.region, offset: 0 };
1242
1187
  }
1243
- const filler = createBlock(schema, schema.defaultTextBlock, {}, first.indent, _optionalChain([newId2, 'optionalCall', _30 => _30()]));
1188
+ const filler = createBlock(schema, schema.defaultTextBlock, {}, first.indent, newId2?.());
1244
1189
  tr.step(insertBlocksStep(removeFrom, [filler]));
1245
1190
  capIndents(tr, start + 1);
1246
1191
  return startPos(schema, filler);
@@ -1248,7 +1193,7 @@ function deleteRange(tr, schema, from, to, newId2) {
1248
1193
 
1249
1194
  // src/engine/commands/insert-text-at.ts
1250
1195
  function insertTextAt(tr, schema, pos, value) {
1251
- const slice = [_chunk4SLJNZSMcjs.text.call(void 0, value, caretMarks(tr.doc, schema, tr.storedMarks, pos))];
1196
+ const slice = [chunkAIS37SL2_cjs.text(value, caretMarks(tr.doc, schema, tr.storedMarks, pos))];
1252
1197
  tr.step(replaceInlineStep(pos.block, pos.region, pos.offset, pos.offset, slice));
1253
1198
  return { ...pos, offset: pos.offset + value.length };
1254
1199
  }
@@ -1260,24 +1205,24 @@ function replaceBlocksWithText(tr, schema, range, value, makeId) {
1260
1205
  const indent2 = range === null ? 0 : doc.blocks[index].indent;
1261
1206
  if (range !== null) tr.step(removeBlocksStep(index, range.end - range.start));
1262
1207
  const empty = createBlock(schema, schema.defaultTextBlock, {}, indent2, makeId());
1263
- const paragraph = withContent(schema, empty, [_chunk4SLJNZSMcjs.text.call(void 0, value)]);
1208
+ const paragraph = withContent(schema, empty, [chunkAIS37SL2_cjs.text(value)]);
1264
1209
  tr.step(insertBlocksStep(index, [paragraph]));
1265
1210
  tr.setSelection(endOf(tr.doc, schema, paragraph.id));
1266
1211
  }
1267
1212
  function insertText(value, options = {}) {
1268
- const makeId = _nullishCoalesce(options.newId, () => ( _chunk4SLJNZSMcjs.newId));
1213
+ const makeId = options.newId ?? chunkAIS37SL2_cjs.newId;
1269
1214
  return (state, dispatch) => {
1270
1215
  if (value === "") return false;
1271
1216
  const { doc, schema, selection } = state;
1272
- const tr = new Transaction(state).setOrigin(_nullishCoalesce(options.origin, () => ( "command")));
1273
- if (_optionalChain([selection, 'optionalAccess', _31 => _31.kind]) === "text") {
1217
+ const tr = new Transaction(state).setOrigin(options.origin ?? "command");
1218
+ if (selection?.kind === "text") {
1274
1219
  const { from, to } = orderedRange(doc, selection.anchor, selection.head);
1275
1220
  const caret = deleteRange(tr, schema, from, to, makeId);
1276
1221
  tr.setSelection(textSelection(insertTextAt(tr, schema, caret, value)));
1277
1222
  } else {
1278
1223
  replaceBlocksWithText(tr, schema, selectedBlockRange(doc, selection), value, makeId);
1279
1224
  }
1280
- _optionalChain([dispatch, 'optionalCall', _32 => _32(tr)]);
1225
+ dispatch?.(tr);
1281
1226
  return true;
1282
1227
  };
1283
1228
  }
@@ -1288,10 +1233,10 @@ function markExtent(inline, offset, type) {
1288
1233
  let position = 0;
1289
1234
  for (const node of inline) {
1290
1235
  starts.push(position);
1291
- position += _chunk4SLJNZSMcjs.nodeLength.call(void 0, node);
1236
+ position += chunkAIS37SL2_cjs.nodeLength(node);
1292
1237
  }
1293
- const containing = (at) => inline.findIndex((node, i) => starts[i] <= at && at < starts[i] + _chunk4SLJNZSMcjs.nodeLength.call(void 0, node));
1294
- const markOf = (index) => _optionalChain([inline, 'access', _33 => _33[index], 'optionalAccess', _34 => _34.marks, 'access', _35 => _35.find, 'call', _36 => _36((mark2) => mark2.type === type)]);
1238
+ const containing = (at) => inline.findIndex((node, i) => starts[i] <= at && at < starts[i] + chunkAIS37SL2_cjs.nodeLength(node));
1239
+ const markOf = (index) => inline[index]?.marks.find((mark2) => mark2.type === type);
1295
1240
  let seed = containing(offset);
1296
1241
  let mark = markOf(seed);
1297
1242
  if (mark === void 0) {
@@ -1299,34 +1244,34 @@ function markExtent(inline, offset, type) {
1299
1244
  mark = markOf(seed);
1300
1245
  }
1301
1246
  if (mark === void 0) return null;
1302
- const shares = (index) => inline[index].marks.some((other) => _chunk4SLJNZSMcjs.sameMark.call(void 0, other, mark));
1247
+ const shares = (index) => inline[index].marks.some((other) => chunkAIS37SL2_cjs.sameMark(other, mark));
1303
1248
  let first = seed;
1304
1249
  while (first > 0 && shares(first - 1)) first--;
1305
1250
  let last = seed;
1306
1251
  while (last < inline.length - 1 && shares(last + 1)) last++;
1307
- return { from: starts[first], to: starts[last] + _chunk4SLJNZSMcjs.nodeLength.call(void 0, inline[last]) };
1252
+ return { from: starts[first], to: starts[last] + chunkAIS37SL2_cjs.nodeLength(inline[last]) };
1308
1253
  }
1309
1254
 
1310
1255
  // src/engine/commands/storable-mark.ts
1311
1256
  function readsBack(inline) {
1312
- return _chunk4SLJNZSMcjs.equalInline.call(void 0, _chunk4SLJNZSMcjs.parseInline.call(void 0, _chunk4SLJNZSMcjs.serializeInline.call(void 0, inline)), _chunk4SLJNZSMcjs.normalizeInline.call(void 0, inline));
1257
+ return chunkAIS37SL2_cjs.equalInline(chunkAIS37SL2_cjs.parseInline(chunkAIS37SL2_cjs.serializeInline(inline)), chunkAIS37SL2_cjs.normalizeInline(inline));
1313
1258
  }
1314
1259
  function safeLink(mark) {
1315
- const href = _optionalChain([mark, 'access', _37 => _37.attrs, 'optionalAccess', _38 => _38.href]);
1316
- const safe = typeof href === "string" ? _chunk4SLJNZSMcjs.sanitizeHref.call(void 0, href) : null;
1260
+ const href = mark.attrs?.href;
1261
+ const safe = typeof href === "string" ? chunkAIS37SL2_cjs.sanitizeHref(href) : null;
1317
1262
  return safe ? { type: "link", attrs: { ...mark.attrs, href: safe } } : null;
1318
1263
  }
1319
1264
  function storableMark(mark) {
1320
1265
  const candidate = mark.type === "link" ? safeLink(mark) : mark;
1321
- return candidate !== null && readsBack([_chunk4SLJNZSMcjs.text.call(void 0, "a", [candidate])]) ? candidate : null;
1266
+ return candidate !== null && readsBack([chunkAIS37SL2_cjs.text("a", [candidate])]) ? candidate : null;
1322
1267
  }
1323
1268
  function storableAtom(type, attrs) {
1324
- return readsBack([_chunk4SLJNZSMcjs.atom.call(void 0, type, attrs)]);
1269
+ return readsBack([chunkAIS37SL2_cjs.atom(type, attrs)]);
1325
1270
  }
1326
1271
 
1327
1272
  // src/engine/commands/selection-marks.ts
1328
1273
  function matchesMark(mark, type, attrs) {
1329
- return mark.type === type && Object.entries(_nullishCoalesce(attrs, () => ( {}))).every(([key, value]) => _optionalChain([mark, 'access', _39 => _39.attrs, 'optionalAccess', _40 => _40[key]]) === value);
1274
+ return mark.type === type && Object.entries(attrs ?? {}).every(([key, value]) => mark.attrs?.[key] === value);
1330
1275
  }
1331
1276
  function wholeRegion(schema, block) {
1332
1277
  const region = primaryRegion(schema, block);
@@ -1340,8 +1285,8 @@ function textRanges(state, selection) {
1340
1285
  if (from.region !== to.region) return [];
1341
1286
  return [{ block: from.block, region: from.region, from: from.offset, to: to.offset }];
1342
1287
  }
1343
- const first = _chunk4SLJNZSMcjs.requireBlockIndex.call(void 0, doc, from.block);
1344
- const last = _chunk4SLJNZSMcjs.requireBlockIndex.call(void 0, doc, to.block);
1288
+ const first = chunkAIS37SL2_cjs.requireBlockIndex(doc, from.block);
1289
+ const last = chunkAIS37SL2_cjs.requireBlockIndex(doc, to.block);
1345
1290
  return doc.blocks.slice(first, last + 1).flatMap((block, i) => {
1346
1291
  const whole = wholeRegion(schema, block);
1347
1292
  if (whole === null) return [];
@@ -1353,7 +1298,7 @@ function textRanges(state, selection) {
1353
1298
  function selectionRanges(state, selection) {
1354
1299
  if (selection.kind === "text") return textRanges(state, selection);
1355
1300
  return selectedBlockIds(state.doc, selection).flatMap((id) => {
1356
- const whole = wholeRegion(state.schema, state.doc.blocks[_chunk4SLJNZSMcjs.requireBlockIndex.call(void 0, state.doc, id)]);
1301
+ const whole = wholeRegion(state.schema, state.doc.blocks[chunkAIS37SL2_cjs.requireBlockIndex(state.doc, id)]);
1357
1302
  return whole === null ? [] : [whole];
1358
1303
  });
1359
1304
  }
@@ -1362,8 +1307,8 @@ function markRanges(state) {
1362
1307
  return selection === null ? [] : selectionRanges(state, selection).filter((range) => range.from < range.to);
1363
1308
  }
1364
1309
  function rangeContent(state, range) {
1365
- const inline = _nullishCoalesce(_optionalChain([_chunk4SLJNZSMcjs.blockById.call(void 0, state.doc, range.block), 'optionalAccess', _41 => _41.regions, 'access', _42 => _42[range.region]]), () => ( []));
1366
- return _chunk4SLJNZSMcjs.sliceInline.call(void 0, inline, range.from, range.to);
1310
+ const inline = chunkAIS37SL2_cjs.blockById(state.doc, range.block)?.regions[range.region] ?? [];
1311
+ return chunkAIS37SL2_cjs.sliceInline(inline, range.from, range.to);
1367
1312
  }
1368
1313
  function markCoverage(content, type, attrs) {
1369
1314
  const carries = (node) => node.marks.some((mark) => matchesMark(mark, type, attrs));
@@ -1371,7 +1316,7 @@ function markCoverage(content, type, attrs) {
1371
1316
  }
1372
1317
  function selectionHasMark(state, type, attrs) {
1373
1318
  const { selection } = state;
1374
- if (_optionalChain([selection, 'optionalAccess', _43 => _43.kind]) === "text" && isCollapsed(selection)) {
1319
+ if (selection?.kind === "text" && isCollapsed(selection)) {
1375
1320
  const marks = caretMarks(state.doc, state.schema, state.storedMarks, selection.head);
1376
1321
  return marks.some((mark) => matchesMark(mark, type, attrs));
1377
1322
  }
@@ -1386,13 +1331,13 @@ function makeMark(type, attrs) {
1386
1331
  }
1387
1332
  function collapsedCaret(state) {
1388
1333
  const { selection } = state;
1389
- return _optionalChain([selection, 'optionalAccess', _44 => _44.kind]) === "text" && isCollapsed(selection) ? selection.head : null;
1334
+ return selection?.kind === "text" && isCollapsed(selection) ? selection.head : null;
1390
1335
  }
1391
1336
  function editRanges(state, dispatch, ranges, edit) {
1392
1337
  const tr = new Transaction(state);
1393
1338
  for (const range of ranges) edit(tr, range, rangeContent(state, range));
1394
1339
  if (!tr.docChanged) return false;
1395
- _optionalChain([dispatch, 'optionalCall', _45 => _45(tr)]);
1340
+ dispatch?.(tr);
1396
1341
  return true;
1397
1342
  }
1398
1343
  function applyMark(type, attrs, mode) {
@@ -1406,9 +1351,9 @@ function applyMark(type, attrs, mode) {
1406
1351
  const current = caretMarks(state.doc, state.schema, state.storedMarks, caret);
1407
1352
  const active = current.some((existing) => matchesMark(existing, type, mark.attrs));
1408
1353
  const remove2 = mode === "remove" || mode === "toggle" && active;
1409
- const next = remove2 ? _chunk4SLJNZSMcjs.removeMark.call(void 0, current, target) : _chunk4SLJNZSMcjs.addMark.call(void 0, current, mark);
1410
- if (_chunk4SLJNZSMcjs.sameMarkSet.call(void 0, next, current)) return false;
1411
- _optionalChain([dispatch, 'optionalCall', _46 => _46(new Transaction(state).setStoredMarks(next))]);
1354
+ const next = remove2 ? chunkAIS37SL2_cjs.removeMark(current, target) : chunkAIS37SL2_cjs.addMark(current, mark);
1355
+ if (chunkAIS37SL2_cjs.sameMarkSet(next, current)) return false;
1356
+ dispatch?.(new Transaction(state).setStoredMarks(next));
1412
1357
  return true;
1413
1358
  }
1414
1359
  const remove = mode === "remove" || mode === "toggle" && selectionHasMark(state, type, mark.attrs);
@@ -1431,17 +1376,17 @@ function unsetMark(type) {
1431
1376
  function linkRanges(state) {
1432
1377
  const caret = collapsedCaret(state);
1433
1378
  if (caret === null) return markRanges(state);
1434
- const inline = _nullishCoalesce(_optionalChain([_chunk4SLJNZSMcjs.blockById.call(void 0, state.doc, caret.block), 'optionalAccess', _47 => _47.regions, 'access', _48 => _48[caret.region]]), () => ( []));
1379
+ const inline = chunkAIS37SL2_cjs.blockById(state.doc, caret.block)?.regions[caret.region] ?? [];
1435
1380
  const extent = markExtent(inline, caret.offset, "link");
1436
1381
  return extent === null ? [] : [{ block: caret.block, region: caret.region, ...extent }];
1437
1382
  }
1438
1383
  function setLink(href, title) {
1439
- const safe = _chunk4SLJNZSMcjs.sanitizeHref.call(void 0, href);
1384
+ const safe = chunkAIS37SL2_cjs.sanitizeHref(href);
1440
1385
  return (state, dispatch) => {
1441
1386
  if (safe === null || safe === "") return false;
1442
1387
  const link = { type: "link", attrs: title ? { href: safe, title } : { href: safe } };
1443
1388
  return editRanges(state, dispatch, linkRanges(state), (tr, { block, region, from, to }, content) => {
1444
- const linked2 = content.every((node) => node.marks.some((mark) => _chunk4SLJNZSMcjs.sameMark.call(void 0, mark, link)));
1389
+ const linked2 = content.every((node) => node.marks.some((mark) => chunkAIS37SL2_cjs.sameMark(mark, link)));
1445
1390
  if (!linked2) tr.step(addMarkStep(block, region, from, to, link));
1446
1391
  });
1447
1392
  };
@@ -1456,7 +1401,7 @@ var clearFormatting = (state, dispatch) => {
1456
1401
  const current = caretMarks(state.doc, state.schema, state.storedMarks, caret);
1457
1402
  const kept = current.filter((mark) => !clearable(mark));
1458
1403
  if (kept.length === current.length) return false;
1459
- _optionalChain([dispatch, 'optionalCall', _49 => _49(new Transaction(state).setStoredMarks(kept))]);
1404
+ dispatch?.(new Transaction(state).setStoredMarks(kept));
1460
1405
  return true;
1461
1406
  }
1462
1407
  return editRanges(state, dispatch, markRanges(state), (tr, { block, region, from, to }, content) => {
@@ -1467,14 +1412,14 @@ var clearFormatting = (state, dispatch) => {
1467
1412
  function insertAtom(type, attrs) {
1468
1413
  return (state, dispatch) => {
1469
1414
  const { doc, schema, selection } = state;
1470
- if (_optionalChain([selection, 'optionalAccess', _50 => _50.kind]) !== "text" || !storableAtom(type, attrs)) return false;
1415
+ if (selection?.kind !== "text" || !storableAtom(type, attrs)) return false;
1471
1416
  const tr = new Transaction(state);
1472
1417
  const { from, to } = orderedRange(doc, selection.anchor, selection.head);
1473
1418
  const caret = deleteRange(tr, schema, from, to);
1474
- const node = _chunk4SLJNZSMcjs.atom.call(void 0, type, attrs, caretMarks(tr.doc, schema, tr.storedMarks, caret));
1419
+ const node = chunkAIS37SL2_cjs.atom(type, attrs, caretMarks(tr.doc, schema, tr.storedMarks, caret));
1475
1420
  tr.step(replaceInlineStep(caret.block, caret.region, caret.offset, caret.offset, [node]));
1476
1421
  tr.setSelection(textSelection({ ...caret, offset: caret.offset + 1 }));
1477
- _optionalChain([dispatch, 'optionalCall', _51 => _51(tr)]);
1422
+ dispatch?.(tr);
1478
1423
  return true;
1479
1424
  };
1480
1425
  }
@@ -1489,19 +1434,19 @@ var TEXT_ATTRIBUTE = /* @__PURE__ */ new Map([
1489
1434
  ["MATH", "latex"]
1490
1435
  ]);
1491
1436
  function holdsText(schema, type) {
1492
- return TEXT_ATTRIBUTE.has(type) || _chunk4SLJNZSMcjs.specFor.call(void 0, schema, type).flow === "text";
1437
+ return TEXT_ATTRIBUTE.has(type) || chunkAIS37SL2_cjs.specFor(schema, type).flow === "text";
1493
1438
  }
1494
1439
  function sourceContent(schema, block) {
1495
1440
  const field = TEXT_ATTRIBUTE.get(block.type);
1496
1441
  if (field !== void 0) {
1497
1442
  const value = block.attrs[field];
1498
- return typeof value === "string" && value !== "" ? [_chunk4SLJNZSMcjs.text.call(void 0, value)] : [];
1443
+ return typeof value === "string" && value !== "" ? [chunkAIS37SL2_cjs.text(value)] : [];
1499
1444
  }
1500
1445
  const region = primaryRegion(schema, block);
1501
1446
  return region === null ? [] : block.regions[region];
1502
1447
  }
1503
1448
  function plainText(schema, content) {
1504
- return _chunk4SLJNZSMcjs.inlineText.call(void 0, content, (node) => _nullishCoalesce(_optionalChain([schema, 'access', _52 => _52.atoms, 'access', _53 => _53.get, 'call', _54 => _54(node.type), 'optionalAccess', _55 => _55.plainText, 'call', _56 => _56(node.attrs)]), () => ( "")));
1449
+ return chunkAIS37SL2_cjs.inlineText(content, (node) => schema.atoms.get(node.type)?.plainText(node.attrs) ?? "");
1505
1450
  }
1506
1451
  function convert(schema, block, type, attrs) {
1507
1452
  const content = sourceContent(schema, block);
@@ -1519,8 +1464,8 @@ function setBlockType(type, attrs = {}) {
1519
1464
  const { doc, schema, selection } = state;
1520
1465
  if (!holdsText(schema, type)) return false;
1521
1466
  const ids = selectedBlockIds(doc, selection);
1522
- const convertible = (block) => isTextFlow(schema, block) || _optionalChain([selection, 'optionalAccess', _57 => _57.kind]) === "node" && TEXT_ATTRIBUTE.has(block.type);
1523
- const blocks = ids.flatMap((id) => _nullishCoalesce(_chunk4SLJNZSMcjs.blockById.call(void 0, doc, id), () => ( []))).filter(convertible);
1467
+ 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);
1524
1469
  if (blocks.length === 0) return false;
1525
1470
  const tr = new Transaction(state);
1526
1471
  const moved2 = /* @__PURE__ */ new Map();
@@ -1534,10 +1479,10 @@ function setBlockType(type, attrs = {}) {
1534
1479
  tr.step(replaceBlockStep(next));
1535
1480
  const from = primaryRegion(schema, block);
1536
1481
  const to = primaryRegion(schema, next);
1537
- if (from !== null && to !== null) moved2.set(block.id, { from, to, length: _chunk4SLJNZSMcjs.inlineLength.call(void 0, next.regions[to]) });
1482
+ if (from !== null && to !== null) moved2.set(block.id, { from, to, length: chunkAIS37SL2_cjs.inlineLength(next.regions[to]) });
1538
1483
  }
1539
1484
  if (!tr.docChanged) return false;
1540
- if (_optionalChain([selection, 'optionalAccess', _58 => _58.kind]) === "text" && moved2.size > 0) {
1485
+ if (selection?.kind === "text" && moved2.size > 0) {
1541
1486
  const carry = (pos) => {
1542
1487
  const entry = moved2.get(pos.block);
1543
1488
  if (entry === void 0 || pos.region !== entry.from) return pos;
@@ -1545,9 +1490,9 @@ function setBlockType(type, attrs = {}) {
1545
1490
  };
1546
1491
  tr.setSelection(textSelection(carry(selection.anchor), carry(selection.head)));
1547
1492
  }
1548
- const converted = _optionalChain([selection, 'optionalAccess', _59 => _59.kind]) === "node" ? _chunk4SLJNZSMcjs.blockById.call(void 0, tr.doc, selection.block) : void 0;
1493
+ const converted = selection?.kind === "node" ? chunkAIS37SL2_cjs.blockById(tr.doc, selection.block) : void 0;
1549
1494
  if (converted !== void 0 && isTextFlow(schema, converted)) tr.setSelection(endOf(tr.doc, schema, converted.id));
1550
- _optionalChain([dispatch, 'optionalCall', _60 => _60(tr)]);
1495
+ dispatch?.(tr);
1551
1496
  return true;
1552
1497
  };
1553
1498
  }
@@ -1561,12 +1506,12 @@ function appliesTo(rule, block) {
1561
1506
  }
1562
1507
  function ruleTransaction(state, rules, context) {
1563
1508
  const { selection, doc } = state;
1564
- if (_optionalChain([selection, 'optionalAccess', _61 => _61.kind]) !== "text") return null;
1509
+ if (selection?.kind !== "text") return null;
1565
1510
  const { block: id, region, offset } = selection.head;
1566
- const block = doc.blocks[_chunk4SLJNZSMcjs.requireBlockIndex.call(void 0, doc, id)];
1511
+ const block = doc.blocks[chunkAIS37SL2_cjs.requireBlockIndex(doc, id)];
1567
1512
  const inline = block.regions[region];
1568
- if (_chunk4SLJNZSMcjs.hasMark.call(void 0, _chunk4SLJNZSMcjs.marksAt.call(void 0, inline, offset, () => true), "code")) return null;
1569
- const before = _chunk4SLJNZSMcjs.inlineText.call(void 0, _chunk4SLJNZSMcjs.sliceInline.call(void 0, inline, 0, offset));
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));
1570
1515
  for (const rule of rules) {
1571
1516
  const match = appliesTo(rule, block) ? rule.match.exec(before) : null;
1572
1517
  if (match === null) continue;
@@ -1576,7 +1521,7 @@ function ruleTransaction(state, rules, context) {
1576
1521
  return null;
1577
1522
  }
1578
1523
  function insertTextWithRules(value, rules, options = {}) {
1579
- const context = { newId: _nullishCoalesce(options.newId, () => ( _chunk4SLJNZSMcjs.newId)) };
1524
+ const context = { newId: options.newId ?? chunkAIS37SL2_cjs.newId };
1580
1525
  const insert = insertText(value, { origin: "input", newId: context.newId });
1581
1526
  return (state, dispatch) => {
1582
1527
  let fired = false;
@@ -1584,14 +1529,14 @@ function insertTextWithRules(value, rules, options = {}) {
1584
1529
  const tr2 = ruleTransaction(current, rules, context);
1585
1530
  if (tr2 !== null) {
1586
1531
  fired = true;
1587
- _optionalChain([emit2, 'optionalCall', _62 => _62(tr2.setOrigin("input"))]);
1532
+ emit2?.(tr2.setOrigin("input"));
1588
1533
  }
1589
1534
  return true;
1590
1535
  };
1591
1536
  const { ok, tr } = runCommands(state, [insert, applyRules]);
1592
1537
  if (!ok || tr === null) return false;
1593
1538
  if (fired) tr.setMeta("inputRule", { undoText: value });
1594
- _optionalChain([dispatch, 'optionalCall', _63 => _63(tr)]);
1539
+ dispatch?.(tr);
1595
1540
  return true;
1596
1541
  };
1597
1542
  }
@@ -1600,7 +1545,7 @@ function insertTextWithRules(value, rules, options = {}) {
1600
1545
  function convertPrefix(state, range, convert2) {
1601
1546
  const { block, region, from, to } = range;
1602
1547
  const removePrefix = (current, dispatch) => {
1603
- _optionalChain([dispatch, 'optionalCall', _64 => _64(new Transaction(current).step(replaceInlineStep(block, region, from, to, [])))]);
1548
+ dispatch?.(new Transaction(current).step(replaceInlineStep(block, region, from, to, [])));
1604
1549
  return true;
1605
1550
  };
1606
1551
  return runCommands(state, [removePrefix, convert2]).tr;
@@ -1624,11 +1569,11 @@ var divider = {
1624
1569
  kinds: PARAGRAPH,
1625
1570
  handler(state, _match, range, context) {
1626
1571
  const { doc, schema } = state;
1627
- const index = _chunk4SLJNZSMcjs.requireBlockIndex.call(void 0, doc, range.block);
1572
+ const index = chunkAIS37SL2_cjs.requireBlockIndex(doc, range.block);
1628
1573
  const block = doc.blocks[index];
1629
1574
  const content = block.regions[range.region];
1630
- const tail = _chunk4SLJNZSMcjs.sliceInline.call(void 0, content, range.to, _chunk4SLJNZSMcjs.inlineLength.call(void 0, content));
1631
- const empty = createBlock(schema, schema.defaultTextBlock, {}, block.indent, (_nullishCoalesce(_optionalChain([context, 'optionalAccess', _65 => _65.newId]), () => ( (0, _chunk4SLJNZSMcjs.newId))))());
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)());
1632
1577
  const next = withContent(schema, empty, tail);
1633
1578
  const tr = new Transaction(state);
1634
1579
  tr.step(replaceBlockStep(createBlock(schema, "DIVIDER", {}, block.indent, block.id)));
@@ -1664,7 +1609,7 @@ var blockInputRules = [
1664
1609
 
1665
1610
  // src/engine/markdown/autolink-href.ts
1666
1611
  function autolinkHref(url) {
1667
- return _chunk4SLJNZSMcjs.sanitizeHref.call(void 0, /^www\./i.test(url) ? `https://${url}` : url);
1612
+ return chunkAIS37SL2_cjs.sanitizeHref(/^www\./i.test(url) ? `https://${url}` : url);
1668
1613
  }
1669
1614
 
1670
1615
  // src/engine/markdown/trim-url-end.ts
@@ -1686,12 +1631,12 @@ function trimUrlEnd(url) {
1686
1631
 
1687
1632
  // src/engine/rules/region-inline.ts
1688
1633
  function regionInline(state, range) {
1689
- return state.doc.blocks[_chunk4SLJNZSMcjs.requireBlockIndex.call(void 0, state.doc, range.block)].regions[range.region];
1634
+ return state.doc.blocks[chunkAIS37SL2_cjs.requireBlockIndex(state.doc, range.block)].regions[range.region];
1690
1635
  }
1691
1636
 
1692
1637
  // src/engine/rules/touches-mark.ts
1693
1638
  function touchesMark(inline, from, to, type) {
1694
- return _chunk4SLJNZSMcjs.sliceInline.call(void 0, inline, from, to).some((node) => _chunk4SLJNZSMcjs.hasMark.call(void 0, node.marks, type));
1639
+ return chunkAIS37SL2_cjs.sliceInline(inline, from, to).some((node) => chunkAIS37SL2_cjs.hasMark(node.marks, type));
1695
1640
  }
1696
1641
 
1697
1642
  // src/engine/rules/autolink.ts
@@ -1722,10 +1667,10 @@ function markRule({ name, match, open, close, wordBounded = false, mark }) {
1722
1667
  if (added === null) return null;
1723
1668
  const { block, region, to } = range;
1724
1669
  const inline = regionInline(state, range);
1725
- const contentTo = to - (_nullishCoalesce(_optionalChain([close, 'optionalCall', _66 => _66(found)]), () => ( open)));
1670
+ const contentTo = to - (close?.(found) ?? open);
1726
1671
  const contentFrom = contentTo - found[1].length;
1727
1672
  const from = contentFrom - open;
1728
- if (wordBounded && WORD_CHARACTER.test(_chunk4SLJNZSMcjs.inlineText.call(void 0, _chunk4SLJNZSMcjs.sliceInline.call(void 0, inline, to, to + 1)))) return null;
1673
+ if (wordBounded && WORD_CHARACTER.test(chunkAIS37SL2_cjs.inlineText(chunkAIS37SL2_cjs.sliceInline(inline, to, to + 1)))) return null;
1729
1674
  if (touchesMark(inline, from, contentFrom, "code") || touchesMark(inline, contentTo, to, "code")) return null;
1730
1675
  const tr = new Transaction(state);
1731
1676
  tr.step(addMarkStep(block, region, contentFrom, contentTo, added));
@@ -1733,7 +1678,7 @@ function markRule({ name, match, open, close, wordBounded = false, mark }) {
1733
1678
  tr.step(replaceInlineStep(block, region, from, contentFrom, []));
1734
1679
  const caret = { block, region, offset: from + found[1].length };
1735
1680
  const carried = caretMarks(tr.doc, state.schema, null, caret);
1736
- return tr.setSelection(textSelection(caret)).setStoredMarks(_chunk4SLJNZSMcjs.removeMark.call(void 0, carried, added.type));
1681
+ return tr.setSelection(textSelection(caret)).setStoredMarks(chunkAIS37SL2_cjs.removeMark(carried, added.type));
1737
1682
  }
1738
1683
  };
1739
1684
  }
@@ -1754,7 +1699,7 @@ var markInputRules = [
1754
1699
  open: 1,
1755
1700
  close: (match) => match[2].length + 3,
1756
1701
  mark(match) {
1757
- const href = _chunk4SLJNZSMcjs.sanitizeHref.call(void 0, match[2]);
1702
+ const href = chunkAIS37SL2_cjs.sanitizeHref(match[2]);
1758
1703
  return href === null ? null : { type: "link", attrs: { href } };
1759
1704
  }
1760
1705
  }),
@@ -1771,8 +1716,8 @@ function replacing(name, match, replacement) {
1771
1716
  match,
1772
1717
  handler(state, found, range) {
1773
1718
  const value = typeof replacement === "string" ? replacement : replacement(found);
1774
- const from = range.to - (_nullishCoalesce(found[1], () => ( found[0]))).length;
1775
- const node = _chunk4SLJNZSMcjs.text.call(void 0, value, _chunk4SLJNZSMcjs.marksAt.call(void 0, regionInline(state, range), range.to, () => true));
1719
+ 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));
1776
1721
  return new Transaction(state).step(replaceInlineStep(range.block, range.region, from, range.to, [node]));
1777
1722
  }
1778
1723
  };
@@ -1891,7 +1836,7 @@ var isDropped = (element) => DROPPED.has(tagName(element));
1891
1836
  var isBlockTag = (element) => BLOCK_TAGS.has(tagName(element));
1892
1837
  var isBlockLevel = (element) => isBlockTag(element) || tagName(element) === "img";
1893
1838
  function hasClass(element, name) {
1894
- return (_nullishCoalesce(element.getAttribute("class"), () => ( ""))).split(/\s+/).includes(name);
1839
+ return (element.getAttribute("class") ?? "").split(/\s+/).includes(name);
1895
1840
  }
1896
1841
  function hasBlockDescendant(node, depth = 0) {
1897
1842
  if (depth > MAX_DEPTH) return false;
@@ -1906,7 +1851,7 @@ function flatText(root) {
1906
1851
  const parts = [];
1907
1852
  const pending = [root];
1908
1853
  for (let node = pending.pop(); node !== void 0; node = pending.pop()) {
1909
- if (node.nodeType === TEXT_NODE) parts.push(_nullishCoalesce(node.nodeValue, () => ( "")));
1854
+ if (node.nodeType === TEXT_NODE) parts.push(node.nodeValue ?? "");
1910
1855
  else if (!isElement(node) || !isDropped(node)) {
1911
1856
  for (let part = node.lastChild; part !== null; part = part.previousSibling) pending.push(part);
1912
1857
  }
@@ -1917,7 +1862,7 @@ function flatText(root) {
1917
1862
  // src/engine/clipboard/html-code.ts
1918
1863
  var LANGUAGE = /(?:^|\s)(?:language|lang)-(\S+)/;
1919
1864
  function preText(node, depth = 0) {
1920
- if (node.nodeType === TEXT_NODE) return _nullishCoalesce(node.nodeValue, () => ( ""));
1865
+ if (node.nodeType === TEXT_NODE) return node.nodeValue ?? "";
1921
1866
  if (!isElement(node)) return "";
1922
1867
  if (tagName(node) === "br") return "\n";
1923
1868
  if (depth > MAX_DEPTH) return flatText(node);
@@ -1925,10 +1870,10 @@ function preText(node, depth = 0) {
1925
1870
  return depth > 0 && isBlockTag(node) && !text2.endsWith("\n") ? `${text2}
1926
1871
  ` : text2;
1927
1872
  }
1928
- var languageOf = (element) => element ? _optionalChain([LANGUAGE, 'access', _67 => _67.exec, 'call', _68 => _68(_nullishCoalesce(element.getAttribute("class"), () => ( ""))), 'optionalAccess', _69 => _69[1]]) : void 0;
1873
+ var languageOf = (element) => element ? LANGUAGE.exec(element.getAttribute("class") ?? "")?.[1] : void 0;
1929
1874
  function codeBlock(pre, ctx, sink) {
1930
1875
  const code = preText(pre).replace(/\r\n?/g, "\n").replace(/\n$/, "");
1931
- const language = _nullishCoalesce(_nullishCoalesce(languageOf(pre), () => ( languageOf(pre.querySelector("code")))), () => ( ""));
1876
+ const language = languageOf(pre) ?? languageOf(pre.querySelector("code")) ?? "";
1932
1877
  emit(sink, "CODE", ctx.indent, { language, code }, {});
1933
1878
  }
1934
1879
 
@@ -1966,7 +1911,7 @@ var FUNCTION = /^rgba?\(([^)]*)\)$/i;
1966
1911
  var SEPARATORS = /[\s,/]+/;
1967
1912
  function parseStyle(style) {
1968
1913
  const declarations = /* @__PURE__ */ new Map();
1969
- for (const declaration of (_nullishCoalesce(style, () => ( ""))).split(";")) {
1914
+ for (const declaration of (style ?? "").split(";")) {
1970
1915
  const colon = declaration.indexOf(":");
1971
1916
  if (colon < 0) continue;
1972
1917
  const value = declaration.slice(colon + 1).replace(/!important\s*$/i, "").trim().toLowerCase();
@@ -1998,9 +1943,9 @@ function keepsWhitespace(styles) {
1998
1943
  if (PRESERVING.has(value)) return true;
1999
1944
  return COLLAPSING.has(value) ? false : null;
2000
1945
  }
2001
- var isMonospace = (styles) => MONOSPACE.test(_nullishCoalesce(styles.get("font-family"), () => ( "")));
1946
+ var isMonospace = (styles) => MONOSPACE.test(styles.get("font-family") ?? "");
2002
1947
  function hasDecoration(styles, line2) {
2003
- return (_nullishCoalesce(styles.get("text-decoration"), () => ( ""))).includes(line2) || (_nullishCoalesce(styles.get("text-decoration-line"), () => ( ""))).includes(line2);
1948
+ return (styles.get("text-decoration") ?? "").includes(line2) || (styles.get("text-decoration-line") ?? "").includes(line2);
2004
1949
  }
2005
1950
  function verticalAlign(styles) {
2006
1951
  const value = styles.get("vertical-align");
@@ -2056,7 +2001,7 @@ function nearestPaletteColor(css, kind) {
2056
2001
  const table = PALETTE_RGB[kind];
2057
2002
  let best = "default";
2058
2003
  let least = Infinity;
2059
- for (const name of _chunk4SLJNZSMcjs.PALETTE) {
2004
+ for (const name of chunkAIS37SL2_cjs.PALETTE) {
2060
2005
  for (const reference of table[name]) {
2061
2006
  const gap = distance(rgb, reference);
2062
2007
  if (gap < least) {
@@ -2070,31 +2015,31 @@ function nearestPaletteColor(css, kind) {
2070
2015
 
2071
2016
  // src/engine/clipboard/html-marks.ts
2072
2017
  function linkMark(element) {
2073
- const href = _chunk4SLJNZSMcjs.sanitizeHref.call(void 0, _nullishCoalesce(element.getAttribute("href"), () => ( "")));
2018
+ const href = chunkAIS37SL2_cjs.sanitizeHref(element.getAttribute("href") ?? "");
2074
2019
  if (href === null || href === "") return null;
2075
2020
  const title = element.getAttribute("title");
2076
2021
  return { type: "link", attrs: title ? { href, title } : { href } };
2077
2022
  }
2078
2023
  function highlightMark(element) {
2079
- const color = _nullishCoalesce(element.getAttribute("data-color"), () => ( ""));
2080
- return _chunk4SLJNZSMcjs.isPaletteColor.call(void 0, color) ? { type: "highlight", attrs: { color } } : { type: "highlight" };
2024
+ const color = element.getAttribute("data-color") ?? "";
2025
+ return chunkAIS37SL2_cjs.isPaletteColor(color) ? { type: "highlight", attrs: { color } } : { type: "highlight" };
2081
2026
  }
2082
2027
  function elementMarks(element, inherited) {
2083
2028
  const tag = tagName(element);
2084
2029
  const styles = parseStyle(element.getAttribute("style"));
2085
2030
  let marks = inherited;
2086
2031
  const add = (mark) => {
2087
- marks = _chunk4SLJNZSMcjs.addMark.call(void 0, marks, mark);
2032
+ marks = chunkAIS37SL2_cjs.addMark(marks, mark);
2088
2033
  };
2089
2034
  const link = tag === "a" ? linkMark(element) : null;
2090
2035
  if (link !== null) add(link);
2091
- const linked2 = _chunk4SLJNZSMcjs.hasMark.call(void 0, marks, "link");
2036
+ const linked2 = chunkAIS37SL2_cjs.hasMark(marks, "link");
2092
2037
  const weight = fontWeight(styles);
2093
2038
  if (weight !== null ? weight >= 600 : tag === "b" || tag === "strong") add({ type: "bold" });
2094
- else if (weight !== null) marks = _chunk4SLJNZSMcjs.removeMark.call(void 0, marks, "bold");
2039
+ else if (weight !== null) marks = chunkAIS37SL2_cjs.removeMark(marks, "bold");
2095
2040
  const slanted = isItalicStyle(styles);
2096
- if (_nullishCoalesce(slanted, () => ( (tag === "i" || tag === "em")))) add({ type: "italic" });
2097
- else if (slanted === false) marks = _chunk4SLJNZSMcjs.removeMark.call(void 0, marks, "italic");
2041
+ if (slanted ?? (tag === "i" || tag === "em")) add({ type: "italic" });
2042
+ else if (slanted === false) marks = chunkAIS37SL2_cjs.removeMark(marks, "italic");
2098
2043
  if (tag === "u" || !linked2 && hasDecoration(styles, "underline")) add({ type: "underline" });
2099
2044
  if (tag === "s" || tag === "del" || tag === "strike" || hasDecoration(styles, "line-through")) {
2100
2045
  add({ type: "strike" });
@@ -2105,15 +2050,15 @@ function elementMarks(element, inherited) {
2105
2050
  if (tag === "sup" || align === "super") add({ type: "sup" });
2106
2051
  if (tag === "mark") add(highlightMark(element));
2107
2052
  const pageColors = isFragmentRoot(element);
2108
- const color = linked2 || pageColors ? null : nearestPaletteColor(_nullishCoalesce(styles.get("color"), () => ( "")), "text");
2053
+ const color = linked2 || pageColors ? null : nearestPaletteColor(styles.get("color") ?? "", "text");
2109
2054
  if (color !== null) add({ type: "color", attrs: { color } });
2110
- const background = pageColors ? null : nearestPaletteColor(_nullishCoalesce(styles.get("background-color"), () => ( "")), "background");
2055
+ const background = pageColors ? null : nearestPaletteColor(styles.get("background-color") ?? "", "background");
2111
2056
  if (background !== null) add({ type: "background", attrs: { color: background } });
2112
2057
  return marks;
2113
2058
  }
2114
2059
 
2115
2060
  // src/engine/clipboard/hoist-spaces.ts
2116
- var shared = (a, b) => a.filter((mark) => b.some((other) => _chunk4SLJNZSMcjs.sameMark.call(void 0, mark, other)));
2061
+ var shared = (a, b) => a.filter((mark) => b.some((other) => chunkAIS37SL2_cjs.sameMark(mark, other)));
2117
2062
  function hoistEdgeSpaces(pieces) {
2118
2063
  const result = [];
2119
2064
  pieces.forEach((piece, at) => {
@@ -2136,7 +2081,7 @@ function hoistEdgeSpaces(pieces) {
2136
2081
  var COLLAPSIBLE = /[ \t\n\r\f]+/g;
2137
2082
  var MSO_IGNORED = "mso-list:ignore";
2138
2083
  function isMsoIgnored(element) {
2139
- return (_nullishCoalesce(element.getAttribute("style"), () => ( ""))).toLowerCase().replace(/\s+/g, "").includes(MSO_IGNORED);
2084
+ return (element.getAttribute("style") ?? "").toLowerCase().replace(/\s+/g, "").includes(MSO_IGNORED);
2140
2085
  }
2141
2086
  function lastChar({ pieces }) {
2142
2087
  const last = pieces[pieces.length - 1];
@@ -2176,19 +2121,19 @@ function finish({ pieces }) {
2176
2121
  break;
2177
2122
  }
2178
2123
  }
2179
- const inline = _chunk4SLJNZSMcjs.normalizeInline.call(void 0, hoistEdgeSpaces(pieces).map((piece) => _chunk4SLJNZSMcjs.text.call(void 0, piece.text, piece.marks)));
2124
+ const inline = chunkAIS37SL2_cjs.normalizeInline(hoistEdgeSpaces(pieces).map((piece) => chunkAIS37SL2_cjs.text(piece.text, piece.marks)));
2180
2125
  return inline.every((node) => node.kind === "text" && node.text.trim() === "") ? [] : inline;
2181
2126
  }
2182
2127
  function visit(acc, node, style, depth) {
2183
2128
  const { marks, preformatted } = style;
2184
- if (node.nodeType === TEXT_NODE) return append(acc, _nullishCoalesce(node.nodeValue, () => ( "")), marks, preformatted);
2129
+ if (node.nodeType === TEXT_NODE) return append(acc, node.nodeValue ?? "", marks, preformatted);
2185
2130
  if (node.nodeType !== ELEMENT_NODE || !isElement(node) || isDropped(node) || isMsoIgnored(node)) return;
2186
2131
  const tag = tagName(node);
2187
2132
  if (tag === "br") return addBreak(acc, marks, preformatted);
2188
2133
  if (tag === "img") return;
2189
2134
  const next = {
2190
2135
  marks: elementMarks(node, marks),
2191
- preformatted: _nullishCoalesce(keepsWhitespace(parseStyle(node.getAttribute("style"))), () => ( preformatted))
2136
+ preformatted: keepsWhitespace(parseStyle(node.getAttribute("style"))) ?? preformatted
2192
2137
  };
2193
2138
  if (depth > MAX_DEPTH) return append(acc, flatText(node), next.marks, next.preformatted);
2194
2139
  const block = isBlockTag(node);
@@ -2208,7 +2153,7 @@ var MARKER_NUMBER = /^(\d+)[.)]$/;
2208
2153
  var MARKER_LETTERS = /^[a-z]{1,4}[.)]$/i;
2209
2154
  function checkboxState(node) {
2210
2155
  if (!isElement(node)) return null;
2211
- if (tagName(node) === "input" && _optionalChain([node, 'access', _70 => _70.getAttribute, 'call', _71 => _71("type"), 'optionalAccess', _72 => _72.toLowerCase, 'call', _73 => _73()]) === "checkbox") {
2156
+ if (tagName(node) === "input" && node.getAttribute("type")?.toLowerCase() === "checkbox") {
2212
2157
  return node.hasAttribute("checked");
2213
2158
  }
2214
2159
  if (hasClass(node, "checkbox-on")) return true;
@@ -2228,7 +2173,7 @@ function listItem(item, base, ctx, sink) {
2228
2173
  let checked = own.checked;
2229
2174
  if (content.length === 0 && rest.length > 0 && isPlainWrapper(rest[0])) {
2230
2175
  const inner = takeCheckbox(Array.from(rest[0].childNodes));
2231
- checked = _nullishCoalesce(checked, () => ( inner.checked));
2176
+ checked = checked ?? inner.checked;
2232
2177
  content = inlineFromNodes(inner.rest, ctx);
2233
2178
  rest = rest.slice(1);
2234
2179
  }
@@ -2236,7 +2181,7 @@ function listItem(item, base, ctx, sink) {
2236
2181
  sink.walk(rest, child(ctx, { indent: ctx.indent + 1, run: PARAGRAPH2 }));
2237
2182
  }
2238
2183
  function firstNumber(list2) {
2239
- const start = Number.parseInt(_nullishCoalesce(list2.getAttribute("start"), () => ( "")), 10);
2184
+ const start = Number.parseInt(list2.getAttribute("start") ?? "", 10);
2240
2185
  return Number.isInteger(start) && start >= 0 ? start : 1;
2241
2186
  }
2242
2187
  function list(element, ctx, sink) {
@@ -2256,15 +2201,15 @@ function list(element, ctx, sink) {
2256
2201
  }
2257
2202
  function wordMarker(paragraph) {
2258
2203
  const ignored = Array.from(paragraph.querySelectorAll("[style]")).find(isMsoIgnored);
2259
- const marker = (_nullishCoalesce(_optionalChain([ignored, 'optionalAccess', _74 => _74.textContent]), () => ( ""))).replace(/\s+/g, "");
2204
+ const marker = (ignored?.textContent ?? "").replace(/\s+/g, "");
2260
2205
  const number = MARKER_NUMBER.exec(marker);
2261
2206
  if (number) return { kind: "ordered", start: Number(number[1]) };
2262
2207
  return MARKER_LETTERS.test(marker) ? { kind: "ordered", start: 1 } : { kind: "bullet" };
2263
2208
  }
2264
2209
  function wordListItem(paragraph, ctx, sink) {
2265
- const style = (_nullishCoalesce(paragraph.getAttribute("style"), () => ( ""))).toLowerCase();
2210
+ const style = (paragraph.getAttribute("style") ?? "").toLowerCase();
2266
2211
  const level = /mso-list:[^;]*\blevel(\d+)/.exec(style);
2267
- const listClass = (_nullishCoalesce(paragraph.getAttribute("class"), () => ( ""))).toLowerCase().includes("msolistparagraph");
2212
+ const listClass = (paragraph.getAttribute("class") ?? "").toLowerCase().includes("msolistparagraph");
2268
2213
  if (level === null && !listClass) return false;
2269
2214
  const depth = level === null ? 0 : Math.max(0, Number(level[1]) - 1);
2270
2215
  emitText(sink, ctx.indent + depth, wordMarker(paragraph), inlineFromNodes(paragraph.childNodes, ctx));
@@ -2273,9 +2218,9 @@ function wordListItem(paragraph, ctx, sink) {
2273
2218
 
2274
2219
  // src/engine/clipboard/html-media.ts
2275
2220
  function imageBlock(img, caption, ctx, sink) {
2276
- const url = _chunk4SLJNZSMcjs.sanitizeHref.call(void 0, _nullishCoalesce(img.getAttribute("src"), () => ( "")));
2221
+ const url = chunkAIS37SL2_cjs.sanitizeHref(img.getAttribute("src") ?? "");
2277
2222
  if (url === null || url === "") return;
2278
- emit(sink, "IMAGE", ctx.indent, { storageKey: "", alt: _nullishCoalesce(img.getAttribute("alt"), () => ( "")), url }, { caption });
2223
+ emit(sink, "IMAGE", ctx.indent, { storageKey: "", alt: img.getAttribute("alt") ?? "", url }, { caption });
2279
2224
  }
2280
2225
  function figure(element, ctx, sink) {
2281
2226
  const img = element.querySelector("img");
@@ -2311,7 +2256,7 @@ function tableBlock(table, ctx, sink) {
2311
2256
  rows.forEach((row, r) => {
2312
2257
  for (let c = 0; c < cols; c++) {
2313
2258
  const cell = row.cells[c];
2314
- regions[_chunk4SLJNZSMcjs.cellKey.call(void 0, r, c)] = cell === void 0 ? [] : inlineFromNodes(cell.childNodes, ctx);
2259
+ regions[chunkAIS37SL2_cjs.cellKey(r, c)] = cell === void 0 ? [] : inlineFromNodes(cell.childNodes, ctx);
2315
2260
  }
2316
2261
  });
2317
2262
  const header = rows[0].head || rows[0].cells.some((cell) => tagName(cell) === "th");
@@ -2324,7 +2269,7 @@ var HEADING = /^h([1-6])$/;
2324
2269
  function emitRun(run, ctx, sink) {
2325
2270
  const inline = inlineFromNodes(run, ctx);
2326
2271
  if (inline.length === 0) return;
2327
- const plain = ctx.run.kind === "heading" ? _chunk4SLJNZSMcjs.removeMarkRange.call(void 0, inline, 0, _chunk4SLJNZSMcjs.inlineLength.call(void 0, inline), "bold") : inline;
2272
+ const plain = ctx.run.kind === "heading" ? chunkAIS37SL2_cjs.removeMarkRange(inline, 0, chunkAIS37SL2_cjs.inlineLength(inline), "bold") : inline;
2328
2273
  emitText(sink, ctx.indent, ctx.run, plain);
2329
2274
  }
2330
2275
  function details(element, ctx, sink) {
@@ -2338,7 +2283,7 @@ function styledContext(element, outer) {
2338
2283
  const styles = parseStyle(element.getAttribute("style"));
2339
2284
  const keeps = keepsWhitespace(styles);
2340
2285
  const marks = elementMarks(element, outer.marks);
2341
- const ctx = { ...outer, marks, preformatted: _nullishCoalesce(keeps, () => ( outer.preformatted)) };
2286
+ const ctx = { ...outer, marks, preformatted: keeps ?? outer.preformatted };
2342
2287
  return { ctx, code: keeps === true && isMonospace(styles) };
2343
2288
  }
2344
2289
  function handleBlock(element, outer, sink) {
@@ -2409,8 +2354,8 @@ function availableParser(parser) {
2409
2354
  function fromHTML(html, options = {}) {
2410
2355
  const parser = availableParser(options.parser);
2411
2356
  if (parser === null) throw new Error("fromHTML needs a DOMParser");
2412
- const makeId = _nullishCoalesce(options.newId, () => ( _chunk4SLJNZSMcjs.newId));
2413
- const codec = _chunk4SLJNZSMcjs.createBlockCodec.call(void 0, _chunk4SLJNZSMcjs.createSchema.call(void 0, ), { newId: makeId });
2357
+ const makeId = options.newId ?? chunkAIS37SL2_cjs.newId;
2358
+ const codec = chunkAIS37SL2_cjs.createBlockCodec(chunkAIS37SL2_cjs.createSchema(), { newId: makeId });
2414
2359
  const { body } = parser.parseFromString(html, "text/html");
2415
2360
  return blocksFromBody(body, makeId).map((block) => codec.toQuoin(block));
2416
2361
  }
@@ -2431,7 +2376,7 @@ function quoteLines(text2) {
2431
2376
 
2432
2377
  // src/engine/markdown/document/block-forms.ts
2433
2378
  var ALERT_NAMES = new Map(
2434
- Object.entries(_chunk4SLJNZSMcjs.ALERT_TONES).map(([name, tone]) => [tone, name])
2379
+ Object.entries(chunkAIS37SL2_cjs.ALERT_TONES).map(([name, tone]) => [tone, name])
2435
2380
  );
2436
2381
  var DELIMITERS = /* @__PURE__ */ new Map([
2437
2382
  ["left", ":--"],
@@ -2441,8 +2386,8 @@ var DELIMITERS = /* @__PURE__ */ new Map([
2441
2386
  var MIN_FENCE = 3;
2442
2387
  var FENCE_LIKE_MATH_LINE = /^ {0,3}\${2,}[ \t]*$/m;
2443
2388
  function calloutMarkdown(data) {
2444
- const name = _nullishCoalesce(ALERT_NAMES.get(_chunk4SLJNZSMcjs.str.call(void 0, data.tone)), () => ( "NOTE"));
2445
- const body = _chunk4SLJNZSMcjs.str.call(void 0, data.body);
2389
+ const name = ALERT_NAMES.get(chunkAIS37SL2_cjs.str(data.tone)) ?? "NOTE";
2390
+ const body = chunkAIS37SL2_cjs.str(data.body);
2446
2391
  return quoteLines(body === "" ? `[!${name}]` : `[!${name}]
2447
2392
  ${body}`);
2448
2393
  }
@@ -2456,18 +2401,18 @@ function longestRun(value, char) {
2456
2401
  return longest;
2457
2402
  }
2458
2403
  function codeMarkdown(data) {
2459
- const code = _chunk4SLJNZSMcjs.str.call(void 0, data.code);
2460
- const info = _chunk4SLJNZSMcjs.str.call(void 0, data.language);
2404
+ const code = chunkAIS37SL2_cjs.str(data.code);
2405
+ const info = chunkAIS37SL2_cjs.str(data.language);
2461
2406
  const char = info.includes("`") ? "~" : "`";
2462
2407
  const fence = char.repeat(Math.max(MIN_FENCE, longestRun(code, char) + 1));
2463
2408
  return [fence + info.replace(/[\\&]/g, "\\$&"), ...code === "" ? [] : code.split("\n"), fence].join("\n");
2464
2409
  }
2465
2410
  function mathMarkdown(data) {
2466
- const latex = _chunk4SLJNZSMcjs.str.call(void 0, data.latex);
2411
+ const latex = chunkAIS37SL2_cjs.str(data.latex);
2467
2412
  if (FENCE_LIKE_MATH_LINE.test(latex)) return null;
2468
2413
  return ["$$", ...latex === "" ? [] : latex.split("\n"), "$$"].join("\n");
2469
2414
  }
2470
- var cellsOf = (row) => Array.isArray(row) ? row.map(_chunk4SLJNZSMcjs.str) : [];
2415
+ var cellsOf = (row) => Array.isArray(row) ? row.map(chunkAIS37SL2_cjs.str) : [];
2471
2416
  var rowMarkdown = (cells) => `| ${cells.join(" | ")} |`;
2472
2417
  function tableMarkdown(data) {
2473
2418
  const rows = Array.isArray(data.rows) ? data.rows.map(cellsOf) : [];
@@ -2477,8 +2422,8 @@ function tableMarkdown(data) {
2477
2422
  const headed = data.header !== false;
2478
2423
  const header = headed ? rows[0] : [];
2479
2424
  const body = headed ? rows.slice(1) : rows;
2480
- const pad = (cells) => Array.from({ length: cols }, (_, col) => _nullishCoalesce(cells[col], () => ( "")));
2481
- const delimiter = Array.from({ length: cols }, (_, col) => _nullishCoalesce(DELIMITERS.get(aligns[col]), () => ( "---")));
2425
+ const pad = (cells) => Array.from({ length: cols }, (_, col) => cells[col] ?? "");
2426
+ const delimiter = Array.from({ length: cols }, (_, col) => DELIMITERS.get(aligns[col]) ?? "---");
2482
2427
  return [header, delimiter, ...body].map((row) => rowMarkdown(pad(row))).join("\n");
2483
2428
  }
2484
2429
 
@@ -2494,7 +2439,7 @@ function needsComment(block, residual, schema, ctx) {
2494
2439
  const native = NATIVE_KEYS.get(block.type);
2495
2440
  if (!native) return false;
2496
2441
  if (residual > 0) return true;
2497
- return Object.keys(_chunk4SLJNZSMcjs.specFor.call(void 0, schema, block.type).toData(block, ctx)).some((key) => !native.includes(key));
2442
+ return Object.keys(chunkAIS37SL2_cjs.specFor(schema, block.type).toData(block, ctx)).some((key) => !native.includes(key));
2498
2443
  }
2499
2444
 
2500
2445
  // src/engine/markdown/document/comment-markdown.ts
@@ -2508,41 +2453,41 @@ function quoinComment(type, data, indent2) {
2508
2453
  // src/engine/markdown/document/link-forms.ts
2509
2454
  var oneLine = (value) => value.replace(/[\r\n]+/g, " ");
2510
2455
  function linked(label, href, ctx) {
2511
- return ctx.inline.serialize([_chunk4SLJNZSMcjs.text.call(void 0, label || href, [{ type: "link", attrs: { href } }])]);
2456
+ return ctx.inline.serialize([chunkAIS37SL2_cjs.text(label || href, [{ type: "link", attrs: { href } }])]);
2512
2457
  }
2513
2458
  var assetUrl = (storageKey, ctx) => storageKey === "" ? "" : ctx.resolveAssetUrl(storageKey);
2514
2459
  function imageMarkdown(data, ctx) {
2515
- const href = _chunk4SLJNZSMcjs.str.call(void 0, data.url) || assetUrl(_chunk4SLJNZSMcjs.str.call(void 0, data.storageKey), ctx);
2460
+ const href = chunkAIS37SL2_cjs.str(data.url) || assetUrl(chunkAIS37SL2_cjs.str(data.storageKey), ctx);
2516
2461
  if (href === "") return null;
2517
- const caption = _chunk4SLJNZSMcjs.str.call(void 0, data.caption);
2518
- const alt = ctx.inline.serialize([_chunk4SLJNZSMcjs.text.call(void 0, oneLine(_chunk4SLJNZSMcjs.str.call(void 0, data.alt)))]);
2519
- return `![${alt}${_chunk4SLJNZSMcjs.linkClose.call(void 0, { type: "link", attrs: caption ? { href, title: caption } : { href } }, false)}`;
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)}`;
2520
2465
  }
2521
2466
  function fileMarkdown(data, ctx) {
2522
- const href = assetUrl(_chunk4SLJNZSMcjs.str.call(void 0, data.storageKey), ctx);
2523
- return href === "" ? null : linked(oneLine(_chunk4SLJNZSMcjs.str.call(void 0, data.filename)), href, ctx);
2467
+ const href = assetUrl(chunkAIS37SL2_cjs.str(data.storageKey), ctx);
2468
+ return href === "" ? null : linked(oneLine(chunkAIS37SL2_cjs.str(data.filename)), href, ctx);
2524
2469
  }
2525
2470
  function embedMarkdown(data, ctx) {
2526
- const url = _chunk4SLJNZSMcjs.str.call(void 0, data.url);
2471
+ const url = chunkAIS37SL2_cjs.str(data.url);
2527
2472
  return url === "" ? null : linked(url, url, ctx);
2528
2473
  }
2529
2474
  function bookmarkMarkdown(data, ctx) {
2530
- const url = _chunk4SLJNZSMcjs.str.call(void 0, data.url);
2531
- return url === "" ? null : linked(oneLine(_chunk4SLJNZSMcjs.str.call(void 0, data.title)), url, ctx);
2475
+ const url = chunkAIS37SL2_cjs.str(data.url);
2476
+ return url === "" ? null : linked(oneLine(chunkAIS37SL2_cjs.str(data.title)), url, ctx);
2532
2477
  }
2533
2478
 
2534
2479
  // src/engine/markdown/document/block-markdown.ts
2535
2480
  var QUOTE_PREFIX = "> ";
2536
2481
  function markdownLine(block, data) {
2537
- const kind = _nullishCoalesce(block.attrs.kind, () => ( "paragraph"));
2538
- const markdown = _chunk4SLJNZSMcjs.str.call(void 0, data.markdown);
2539
- const empty = _chunk4SLJNZSMcjs.inlineLength.call(void 0, _nullishCoalesce(block.regions.text, () => ( []))) === 0;
2482
+ const kind = block.attrs.kind ?? "paragraph";
2483
+ const markdown = chunkAIS37SL2_cjs.str(data.markdown);
2484
+ const empty = chunkAIS37SL2_cjs.inlineLength(block.regions.text ?? []) === 0;
2540
2485
  if (empty && (kind === "paragraph" || kind === "quote")) return null;
2541
2486
  return kind === "quote" ? quoteLines(markdown.slice(QUOTE_PREFIX.length)) : markdown;
2542
2487
  }
2543
2488
  function toggleMarkdown(data) {
2544
2489
  return `<details${data.open === true ? " open" : ""}>
2545
- <summary>${_chunk4SLJNZSMcjs.str.call(void 0, data.markdown)}</summary>`;
2490
+ <summary>${chunkAIS37SL2_cjs.str(data.markdown)}</summary>`;
2546
2491
  }
2547
2492
  function coreMarkdown(block, data, env, residual) {
2548
2493
  switch (block.type) {
@@ -2575,9 +2520,9 @@ function coreMarkdown(block, data, env, residual) {
2575
2520
  }
2576
2521
  }
2577
2522
  function blockMarkdown(block, env, { residual, asComment }) {
2578
- const spec = _chunk4SLJNZSMcjs.specFor.call(void 0, env.schema, block.type);
2523
+ const spec = chunkAIS37SL2_cjs.specFor(env.schema, block.type);
2579
2524
  const data = spec.toData(block, env.ctx);
2580
- const comment = () => _chunk4SLJNZSMcjs.isQuoinType.call(void 0, block.type) ? quoinComment(block.type, data, residual) : null;
2525
+ const comment = () => chunkAIS37SL2_cjs.isQuoinType(block.type) ? quoinComment(block.type, data, residual) : null;
2581
2526
  if (asComment || env.lossless && !hasNativeForm(block.type)) return comment();
2582
2527
  const written = spec.toMarkdown ? spec.toMarkdown(block, env.ctx) : coreMarkdown(block, data, env, residual);
2583
2528
  if (written !== null) return written;
@@ -2586,7 +2531,7 @@ function blockMarkdown(block, env, { residual, asComment }) {
2586
2531
 
2587
2532
  // src/engine/markdown/document/list-context.ts
2588
2533
  var ITEM_KINDS2 = ["bullet", "ordered", "task"];
2589
- var lineKindOf = (block) => block.type === "MARKDOWN" ? _nullishCoalesce(block.attrs.kind, () => ( "paragraph")) : void 0;
2534
+ var lineKindOf = (block) => block.type === "MARKDOWN" ? block.attrs.kind ?? "paragraph" : void 0;
2590
2535
  function openedBy(block, prefix, hang) {
2591
2536
  if (hang > 0) return { kind: "item", indent: block.indent, prefix, childPrefix: prefix + " ".repeat(hang) };
2592
2537
  if (block.type === "TOGGLE") return { kind: "toggle", indent: block.indent, prefix, childPrefix: prefix };
@@ -2599,15 +2544,15 @@ function createListContext() {
2599
2544
  const closed = [];
2600
2545
  while (stack.length > 0 && stack[stack.length - 1].indent >= block.indent) closed.push(stack.pop());
2601
2546
  const parent = stack[stack.length - 1];
2602
- const prefix = _nullishCoalesce(_optionalChain([parent, 'optionalAccess', _75 => _75.childPrefix]), () => ( ""));
2547
+ const prefix = parent?.childPrefix ?? "";
2603
2548
  const line2 = lineKindOf(block);
2604
2549
  const residual = block.indent - stack.length;
2605
- const comment = _optionalChain([asComment, 'optionalCall', _76 => _76(residual)]) === true;
2550
+ const comment = asComment?.(residual) === true;
2606
2551
  for (const indent2 of [...runs.keys()]) if (indent2 > block.indent) runs.delete(indent2);
2607
2552
  let placed = block;
2608
2553
  let number = 1;
2609
2554
  if (line2 === "ordered") {
2610
- number = Math.min(_nullishCoalesce(runs.get(block.indent), () => ( _chunk4SLJNZSMcjs.orderedStart.call(void 0, block.attrs.start))), _chunk4SLJNZSMcjs.MAX_MARKER_NUMBER);
2555
+ number = Math.min(runs.get(block.indent) ?? chunkAIS37SL2_cjs.orderedStart(block.attrs.start), chunkAIS37SL2_cjs.MAX_MARKER_NUMBER);
2611
2556
  runs.set(block.indent, number + 1);
2612
2557
  if (number !== block.attrs.start) placed = { ...block, attrs: { ...block.attrs, start: number } };
2613
2558
  } else {
@@ -2617,7 +2562,7 @@ function createListContext() {
2617
2562
  const hang = isItem2 ? (line2 === "ordered" ? String(number).length : 0) + 2 : 0;
2618
2563
  const container = comment ? void 0 : openedBy(block, prefix, hang);
2619
2564
  if (container) stack.push(container);
2620
- const bare = !comment && (line2 === "bullet" || line2 === "ordered") && _chunk4SLJNZSMcjs.inlineLength.call(void 0, _nullishCoalesce(block.regions.text, () => ( []))) === 0;
2565
+ const bare = !comment && (line2 === "bullet" || line2 === "ordered") && chunkAIS37SL2_cjs.inlineLength(block.regions.text ?? []) === 0;
2621
2566
  const fragile = isItem2 && (bare || line2 === "ordered" && number !== 1);
2622
2567
  const shown = comment ? void 0 : line2;
2623
2568
  return { block: placed, line: shown, prefix, hang, residual, parent, container, closed, bare, fragile, comment };
@@ -2635,7 +2580,7 @@ function stripComments(block) {
2635
2580
  regions: Object.fromEntries(
2636
2581
  regions.map(([name, inline]) => [
2637
2582
  name,
2638
- hasCommentMark(inline) ? _chunk4SLJNZSMcjs.removeMarkRange.call(void 0, inline, 0, _chunk4SLJNZSMcjs.inlineLength.call(void 0, inline), "comment") : inline
2583
+ hasCommentMark(inline) ? chunkAIS37SL2_cjs.removeMarkRange(inline, 0, chunkAIS37SL2_cjs.inlineLength(inline), "comment") : inline
2639
2584
  ])
2640
2585
  )
2641
2586
  };
@@ -2664,11 +2609,11 @@ function pieceOf(text2, placement) {
2664
2609
  opened: placement.container,
2665
2610
  bare: placement.bare,
2666
2611
  fragile: placement.fragile,
2667
- leadsHtml: hang > 0 && _chunk4SLJNZSMcjs.startsHtmlBlock.call(void 0, text2.split("\n")[0].slice(hang))
2612
+ leadsHtml: hang > 0 && chunkAIS37SL2_cjs.startsHtmlBlock(text2.split("\n")[0].slice(hang))
2668
2613
  };
2669
2614
  }
2670
2615
  function takenAsItemText(previous, { parent, line: line2 }) {
2671
- return line2 === "paragraph" && parent !== void 0 && _optionalChain([previous, 'optionalAccess', _77 => _77.opened]) === parent && previous.bare;
2616
+ return line2 === "paragraph" && parent !== void 0 && previous?.opened === parent && previous.bare;
2672
2617
  }
2673
2618
  function separator(previous, next) {
2674
2619
  const nested = next.parent !== void 0 && next.parent === previous.opened;
@@ -2689,14 +2634,14 @@ function join(pieces) {
2689
2634
  `;
2690
2635
  }
2691
2636
  function toMarkdown(blocks, options = {}) {
2692
- const schema = _nullishCoalesce(options.schema, () => ( _chunk4SLJNZSMcjs.createSchema.call(void 0, )));
2693
- const codec = _chunk4SLJNZSMcjs.createBlockCodec.call(void 0, schema);
2637
+ const schema = options.schema ?? chunkAIS37SL2_cjs.createSchema();
2638
+ const codec = chunkAIS37SL2_cjs.createBlockCodec(schema);
2694
2639
  const env = {
2695
2640
  schema,
2696
2641
  lossless: options.lossless === true,
2697
2642
  ctx: {
2698
2643
  ...codec.context,
2699
- resolveAssetUrl: _nullishCoalesce(options.resolveAssetUrl, () => ( ((storageKey) => storageKey))),
2644
+ resolveAssetUrl: options.resolveAssetUrl ?? ((storageKey) => storageKey),
2700
2645
  comments: options.comments !== false
2701
2646
  }
2702
2647
  };
@@ -2732,20 +2677,20 @@ function escapeAttr(value) {
2732
2677
 
2733
2678
  // src/engine/render/serialize-html.ts
2734
2679
  var VOID = /* @__PURE__ */ new Set(["br", "hr", "img", "input"]);
2735
- var attrsHtml = (node) => _chunk4SLJNZSMcjs.writtenAttrs.call(void 0, node.attrs).map(([name, value]) => value === true ? ` ${name}` : ` ${name}="${escapeAttr(value)}"`).join("");
2680
+ var attrsHtml = (node) => chunkAIS37SL2_cjs.writtenAttrs(node.attrs).map(([name, value]) => value === true ? ` ${name}` : ` ${name}="${escapeAttr(value)}"`).join("");
2736
2681
  var serializeHtml = (nodes) => nodes.map(
2737
- (node) => typeof node === "string" ? escapeHtml(node) : `<${node.tag}${attrsHtml(node)}>${VOID.has(node.tag) ? "" : `${_nullishCoalesce(node.html, () => ( serializeHtml(node.children)))}</${node.tag}>`}`
2682
+ (node) => typeof node === "string" ? escapeHtml(node) : `<${node.tag}${attrsHtml(node)}>${VOID.has(node.tag) ? "" : `${node.html ?? serializeHtml(node.children)}</${node.tag}>`}`
2738
2683
  ).join("");
2739
2684
 
2740
2685
  // src/engine/render/to-html.ts
2741
- var toHTML = (blocks, options = {}) => serializeHtml(_chunk4SLJNZSMcjs.documentNodes.call(void 0, blocks, options));
2686
+ var toHTML = (blocks, options = {}) => serializeHtml(chunkAIS37SL2_cjs.documentNodes(blocks, options));
2742
2687
 
2743
2688
  // src/engine/render/to-plain-text.ts
2744
2689
  function plainTextBlocks(blocks, schema) {
2745
- return _chunk4SLJNZSMcjs.engineBlocksOf.call(void 0, blocks, schema).map((block) => _chunk4SLJNZSMcjs.blockPlainText.call(void 0, block, schema));
2690
+ return chunkAIS37SL2_cjs.engineBlocksOf(blocks, schema).map((block) => chunkAIS37SL2_cjs.blockPlainText(block, schema));
2746
2691
  }
2747
2692
  function toPlainText(blocks, options = {}) {
2748
- return plainTextBlocks(blocks, _nullishCoalesce(options.schema, () => ( _chunk4SLJNZSMcjs.createSchema.call(void 0, )))).join("\n");
2693
+ return plainTextBlocks(blocks, options.schema ?? chunkAIS37SL2_cjs.createSchema()).join("\n");
2749
2694
  }
2750
2695
 
2751
2696
  // src/engine/model/graphemes.ts
@@ -2778,16 +2723,16 @@ function wordCount(text2) {
2778
2723
  return words(text2).length;
2779
2724
  }
2780
2725
  function nextGraphemeOffset(text2, offset) {
2781
- return _nullishCoalesce(boundaries(text2).find((b) => b > offset), () => ( text2.length));
2726
+ return boundaries(text2).find((b) => b > offset) ?? text2.length;
2782
2727
  }
2783
2728
  function prevGraphemeOffset(text2, offset) {
2784
- return _nullishCoalesce(boundaries(text2).reverse().find((b) => b < offset), () => ( 0));
2729
+ return boundaries(text2).reverse().find((b) => b < offset) ?? 0;
2785
2730
  }
2786
2731
  function nextWordOffset(text2, offset) {
2787
- return _nullishCoalesce(_optionalChain([words, 'call', _78 => _78(text2), 'access', _79 => _79.find, 'call', _80 => _80((w) => w.end > offset), 'optionalAccess', _81 => _81.end]), () => ( text2.length));
2732
+ return words(text2).find((w) => w.end > offset)?.end ?? text2.length;
2788
2733
  }
2789
2734
  function prevWordOffset(text2, offset) {
2790
- return _nullishCoalesce(_optionalChain([words, 'call', _82 => _82(text2), 'access', _83 => _83.reverse, 'call', _84 => _84(), 'access', _85 => _85.find, 'call', _86 => _86((w) => w.start < offset), 'optionalAccess', _87 => _87.start]), () => ( 0));
2735
+ return words(text2).reverse().find((w) => w.start < offset)?.start ?? 0;
2791
2736
  }
2792
2737
 
2793
2738
  // src/engine/render/count-block.ts
@@ -2797,7 +2742,7 @@ function countBlock(block, schema) {
2797
2742
  if (!blocks) counted.set(schema, blocks = /* @__PURE__ */ new WeakMap());
2798
2743
  const known = blocks.get(block);
2799
2744
  if (known) return known;
2800
- const text2 = _chunk4SLJNZSMcjs.blockPlainText.call(void 0, block, schema);
2745
+ const text2 = chunkAIS37SL2_cjs.blockPlainText(block, schema);
2801
2746
  const stats = { characters: graphemeCount(text2), words: wordCount(text2) };
2802
2747
  blocks.set(block, stats);
2803
2748
  return stats;
@@ -2816,17 +2761,17 @@ function sum(blocks, schema) {
2816
2761
  return { characters, words: words2 };
2817
2762
  }
2818
2763
  function countText(blocks, options = {}) {
2819
- const schema = _nullishCoalesce(options.schema, () => ( (defaultSchema ??= _chunk4SLJNZSMcjs.createSchema.call(void 0, ))));
2820
- return sum(_chunk4SLJNZSMcjs.engineBlocksOf.call(void 0, blocks, schema), schema);
2764
+ const schema = options.schema ?? (defaultSchema ??= chunkAIS37SL2_cjs.createSchema());
2765
+ return sum(chunkAIS37SL2_cjs.engineBlocksOf(blocks, schema), schema);
2821
2766
  }
2822
2767
  function countDoc(doc, options = {}) {
2823
- return sum(doc.blocks, _nullishCoalesce(options.schema, () => ( (defaultSchema ??= _chunk4SLJNZSMcjs.createSchema.call(void 0, )))));
2768
+ return sum(doc.blocks, options.schema ?? (defaultSchema ??= chunkAIS37SL2_cjs.createSchema()));
2824
2769
  }
2825
2770
 
2826
2771
  // src/engine/commands/block-style.ts
2827
2772
  function patchBlocks(state, patch, only) {
2828
2773
  const changing = selectedBlockIds(state.doc, state.selection).filter((id) => {
2829
- const block = _chunk4SLJNZSMcjs.blockById.call(void 0, state.doc, id);
2774
+ const block = chunkAIS37SL2_cjs.blockById(state.doc, id);
2830
2775
  return block !== void 0 && (only === void 0 || block.type === only) && patchChangesAttrs(block.attrs, patch);
2831
2776
  });
2832
2777
  if (changing.length === 0) return null;
@@ -2838,7 +2783,7 @@ function patchCommand(patch, only) {
2838
2783
  return (state, dispatch) => {
2839
2784
  const tr = patchBlocks(state, patch, only);
2840
2785
  if (tr === null) return false;
2841
- _optionalChain([dispatch, 'optionalCall', _88 => _88(tr)]);
2786
+ dispatch?.(tr);
2842
2787
  return true;
2843
2788
  };
2844
2789
  }
@@ -2846,15 +2791,15 @@ function setAttrs(patch) {
2846
2791
  return patchCommand(patch);
2847
2792
  }
2848
2793
  function setTextAlign(align) {
2849
- return patchCommand({ align: _nullishCoalesce(align, () => ( void 0)) }, "MARKDOWN");
2794
+ return patchCommand({ align: align ?? void 0 }, "MARKDOWN");
2850
2795
  }
2851
2796
  function setBlockColor(colors) {
2852
2797
  const patch = {};
2853
2798
  for (const key of ["color", "background"]) {
2854
2799
  const value = colors[key];
2855
- if (value !== void 0) patch[key] = _nullishCoalesce(value, () => ( void 0));
2800
+ if (value !== void 0) patch[key] = value ?? void 0;
2856
2801
  }
2857
- const valid = Object.values(patch).every((value) => value === void 0 || _chunk4SLJNZSMcjs.isPaletteColor.call(void 0, value));
2802
+ const valid = Object.values(patch).every((value) => value === void 0 || chunkAIS37SL2_cjs.isPaletteColor(value));
2858
2803
  return valid ? patchCommand(patch, "MARKDOWN") : () => false;
2859
2804
  }
2860
2805
 
@@ -2872,25 +2817,25 @@ function paragraphStep(schema, block, region) {
2872
2817
  // src/engine/commands/delete-at-boundary.ts
2873
2818
  function textCaret(state) {
2874
2819
  const { doc, schema, selection } = state;
2875
- if (_optionalChain([selection, 'optionalAccess', _89 => _89.kind]) !== "text" || !isCollapsed(selection)) return null;
2820
+ if (selection?.kind !== "text" || !isCollapsed(selection)) return null;
2876
2821
  const pos = selection.head;
2877
- const index = _chunk4SLJNZSMcjs.requireBlockIndex.call(void 0, doc, pos.block);
2822
+ const index = chunkAIS37SL2_cjs.requireBlockIndex(doc, pos.block);
2878
2823
  const block = doc.blocks[index];
2879
2824
  const inFlow2 = isTextFlow(schema, block) && pos.region === primaryRegion(schema, block);
2880
2825
  return inFlow2 ? { block, index, pos } : null;
2881
2826
  }
2882
2827
  function joinInto(tr, schema, target, source) {
2883
- const targetRegion = _nullishCoalesce(primaryRegion(schema, target), () => ( ""));
2884
- tr.step(joinBlocksStep(target.id, targetRegion, source.id, _nullishCoalesce(primaryRegion(schema, source), () => ( ""))));
2885
- capIndents(tr, _chunk4SLJNZSMcjs.requireBlockIndex.call(void 0, tr.doc, target.id) + 1);
2828
+ const targetRegion = primaryRegion(schema, target) ?? "";
2829
+ tr.step(joinBlocksStep(target.id, targetRegion, source.id, primaryRegion(schema, source) ?? ""));
2830
+ capIndents(tr, chunkAIS37SL2_cjs.requireBlockIndex(tr.doc, target.id) + 1);
2886
2831
  const offset = regionLength(target, targetRegion);
2887
2832
  tr.setSelection(textSelection({ block: target.id, region: targetRegion, offset }));
2888
2833
  }
2889
2834
  function joinIntoSummary(tr, schema, summary, source) {
2890
- const region = _nullishCoalesce(primaryRegion(schema, summary), () => ( ""));
2835
+ const region = primaryRegion(schema, summary) ?? "";
2891
2836
  const offset = regionLength(summary, region);
2892
- const index = _chunk4SLJNZSMcjs.requireBlockIndex.call(void 0, tr.doc, source.id);
2893
- const content = source.regions[_nullishCoalesce(primaryRegion(schema, source), () => ( ""))];
2837
+ const index = chunkAIS37SL2_cjs.requireBlockIndex(tr.doc, source.id);
2838
+ const content = source.regions[primaryRegion(schema, source) ?? ""];
2894
2839
  if (content.length > 0) tr.step(replaceInlineStep(summary.id, region, offset, offset, content));
2895
2840
  tr.step(removeBlocksStep(index, 1));
2896
2841
  capIndents(tr, index);
@@ -2919,7 +2864,7 @@ var deleteAtStart = (state, dispatch) => {
2919
2864
  if (regionLength(block, pos.region) === 0) tr.step(removeBlocksStep(index, 1));
2920
2865
  tr.setSelection(nodeSelection(previous.id));
2921
2866
  }
2922
- _optionalChain([dispatch, 'optionalCall', _90 => _90(tr)]);
2867
+ dispatch?.(tr);
2923
2868
  return true;
2924
2869
  };
2925
2870
  var deleteAtEnd = (state, dispatch) => {
@@ -2942,26 +2887,26 @@ var deleteAtEnd = (state, dispatch) => {
2942
2887
  }
2943
2888
  tr.setSelection(nodeSelection(next.id));
2944
2889
  }
2945
- _optionalChain([dispatch, 'optionalCall', _91 => _91(tr)]);
2890
+ dispatch?.(tr);
2946
2891
  return true;
2947
2892
  };
2948
2893
 
2949
2894
  // src/engine/commands/delete-commands.ts
2950
2895
  var deleteSelection = (state, dispatch) => {
2951
2896
  const { doc, schema, selection } = state;
2952
- if (_optionalChain([selection, 'optionalAccess', _92 => _92.kind]) !== "text") return deleteBlocks(state, dispatch);
2897
+ if (selection?.kind !== "text") return deleteBlocks(state, dispatch);
2953
2898
  if (isCollapsed(selection)) return false;
2954
2899
  const tr = new Transaction(state);
2955
2900
  const { from, to } = orderedRange(doc, selection.anchor, selection.head);
2956
- _optionalChain([dispatch, 'optionalCall', _93 => _93(tr.setSelection(textSelection(deleteRange(tr, schema, from, to))))]);
2901
+ dispatch?.(tr.setSelection(textSelection(deleteRange(tr, schema, from, to))));
2957
2902
  return true;
2958
2903
  };
2959
2904
  function deleteReaching(forward, reach) {
2960
2905
  return (state, dispatch) => {
2961
2906
  const { selection } = state;
2962
- if (_optionalChain([selection, 'optionalAccess', _94 => _94.kind]) !== "text" || !isCollapsed(selection)) return deleteSelection(state, dispatch);
2907
+ if (selection?.kind !== "text" || !isCollapsed(selection)) return deleteSelection(state, dispatch);
2963
2908
  const { head } = selection;
2964
- const value = _chunk4SLJNZSMcjs.inlineText.call(void 0, state.doc.blocks[_chunk4SLJNZSMcjs.requireBlockIndex.call(void 0, state.doc, head.block)].regions[head.region]);
2909
+ const value = chunkAIS37SL2_cjs.inlineText(state.doc.blocks[chunkAIS37SL2_cjs.requireBlockIndex(state.doc, head.block)].regions[head.region]);
2965
2910
  if (forward ? head.offset >= value.length : head.offset <= 0) {
2966
2911
  return (forward ? deleteAtEnd : deleteAtStart)(state, dispatch);
2967
2912
  }
@@ -2970,7 +2915,7 @@ function deleteReaching(forward, reach) {
2970
2915
  const to = Math.max(head.offset, other);
2971
2916
  const tr = new Transaction(state).setOrigin("input");
2972
2917
  tr.step(replaceInlineStep(head.block, head.region, from, to, []));
2973
- _optionalChain([dispatch, 'optionalCall', _95 => _95(tr.setSelection(textSelection({ ...head, offset: from })))]);
2918
+ dispatch?.(tr.setSelection(textSelection({ ...head, offset: from })));
2974
2919
  return true;
2975
2920
  };
2976
2921
  }
@@ -3010,13 +2955,13 @@ function movedRuns(doc, ids) {
3010
2955
  return runs;
3011
2956
  }
3012
2957
  function movedBlockIds(doc, ids) {
3013
- return _nullishCoalesce(_optionalChain([movedRuns, 'call', _96 => _96(doc, ids), 'optionalAccess', _97 => _97.flat, 'call', _98 => _98()]), () => ( null));
2958
+ return movedRuns(doc, ids)?.flat() ?? null;
3014
2959
  }
3015
2960
  function gather(tr, runs, above) {
3016
2961
  let anchor = above;
3017
2962
  for (const run of runs) {
3018
- const from = _chunk4SLJNZSMcjs.requireBlockIndex.call(void 0, tr.doc, run[0]);
3019
- const at = anchor === null ? -1 : _chunk4SLJNZSMcjs.requireBlockIndex.call(void 0, tr.doc, anchor);
2963
+ const from = chunkAIS37SL2_cjs.requireBlockIndex(tr.doc, run[0]);
2964
+ const at = anchor === null ? -1 : chunkAIS37SL2_cjs.requireBlockIndex(tr.doc, anchor);
3020
2965
  const to = at < from ? at + 1 : at + 1 - run.length;
3021
2966
  if (to !== from) tr.step(moveBlocksStep(from, run.length, to));
3022
2967
  anchor = run[run.length - 1];
@@ -3040,13 +2985,13 @@ function moveBlocksTo(ids, toIndex, indent2) {
3040
2985
  if (toIndex < 0 || toIndex > rest.length) return false;
3041
2986
  const above = toIndex > 0 ? rest[toIndex - 1] : null;
3042
2987
  const tr = new Transaction(state);
3043
- gather(tr, runs, _nullishCoalesce(_optionalChain([above, 'optionalAccess', _99 => _99.id]), () => ( null)));
2988
+ gather(tr, runs, above?.id ?? null);
3044
2989
  const first = runs[0][0];
3045
2990
  const last = runs[runs.length - 1];
3046
2991
  const clamped = Math.min(Math.max(indent2, 0), above ? above.indent + 1 : 0);
3047
- reindent(tr, _chunk4SLJNZSMcjs.requireBlockIndex.call(void 0, tr.doc, first), moved2.size, clamped);
2992
+ reindent(tr, chunkAIS37SL2_cjs.requireBlockIndex(tr.doc, first), moved2.size, clamped);
3048
2993
  if (!tr.docChanged) return false;
3049
- _optionalChain([dispatch, 'optionalCall', _100 => _100(tr.setSelection(blockRangeSelection(first, last[last.length - 1])))]);
2994
+ dispatch?.(tr.setSelection(blockRangeSelection(first, last[last.length - 1])));
3050
2995
  return true;
3051
2996
  };
3052
2997
  }
@@ -3056,25 +3001,25 @@ var selectAll = (state, dispatch) => {
3056
3001
  const { doc, selection } = state;
3057
3002
  if (doc.blocks.length === 0) return false;
3058
3003
  let next = blockRangeSelection(doc.blocks[0].id, doc.blocks[doc.blocks.length - 1].id);
3059
- if (_optionalChain([selection, 'optionalAccess', _101 => _101.kind]) === "text") {
3004
+ if (selection?.kind === "text") {
3060
3005
  const { anchor, head } = selection;
3061
- const length = _chunk4SLJNZSMcjs.inlineLength.call(void 0, _nullishCoalesce(doc.blocks[_chunk4SLJNZSMcjs.requireBlockIndex.call(void 0, doc, head.block)].regions[head.region], () => ( [])));
3006
+ const length = chunkAIS37SL2_cjs.inlineLength(doc.blocks[chunkAIS37SL2_cjs.requireBlockIndex(doc, head.block)].regions[head.region] ?? []);
3062
3007
  const withinRegion = anchor.block === head.block && anchor.region === head.region;
3063
3008
  const covers = Math.min(anchor.offset, head.offset) === 0 && Math.max(anchor.offset, head.offset) === length;
3064
3009
  if (withinRegion && !covers) next = textSelection({ ...head, offset: 0 }, { ...head, offset: length });
3065
3010
  }
3066
- _optionalChain([dispatch, 'optionalCall', _102 => _102(new Transaction(state).setSelection(next))]);
3011
+ dispatch?.(new Transaction(state).setSelection(next));
3067
3012
  return true;
3068
3013
  };
3069
3014
  var selectBlock = (state, dispatch) => {
3070
3015
  const id = headBlockId(state.selection);
3071
3016
  if (id === null) return false;
3072
- _optionalChain([dispatch, 'optionalCall', _103 => _103(new Transaction(state).setSelection(blockRangeSelection(id)))]);
3017
+ dispatch?.(new Transaction(state).setSelection(blockRangeSelection(id)));
3073
3018
  return true;
3074
3019
  };
3075
3020
  function setSelection(selection) {
3076
3021
  return (state, dispatch) => {
3077
- _optionalChain([dispatch, 'optionalCall', _104 => _104(new Transaction(state).setSelection(selection))]);
3022
+ dispatch?.(new Transaction(state).setSelection(selection));
3078
3023
  return true;
3079
3024
  };
3080
3025
  }
@@ -3084,9 +3029,9 @@ var LINE_SPLIT = "lineSplit";
3084
3029
 
3085
3030
  // src/engine/commands/split-step.ts
3086
3031
  function splitStep(schema, block, region, offset, id) {
3087
- const next = _nullishCoalesce(_optionalChain([specOf, 'call', _105 => _105(schema, block), 'access', _106 => _106.splitAttrs, 'optionalCall', _107 => _107(block.attrs)]), () => ( { type: block.type, attrs: block.attrs }));
3032
+ const next = specOf(schema, block).splitAttrs?.(block.attrs) ?? { type: block.type, attrs: block.attrs };
3088
3033
  const created = createBlock(schema, next.type, next.attrs, block.indent, id);
3089
- const tailRegion = _nullishCoalesce(primaryRegion(schema, created), () => ( ""));
3034
+ const tailRegion = primaryRegion(schema, created) ?? "";
3090
3035
  const { type, attrs, indent: indent2, regions } = created;
3091
3036
  const step = splitBlockStep(block.id, region, offset, { id, type, attrs, indent: indent2, region: tailRegion, regions });
3092
3037
  return { step, tail: { id, region: tailRegion } };
@@ -3095,7 +3040,7 @@ function splitStep(schema, block, region, offset, id) {
3095
3040
  // src/engine/commands/split-at.ts
3096
3041
  function enterInHardBreakBlock({ tr, schema, block, index, pos, makeId }) {
3097
3042
  const length = regionLength(block, pos.region);
3098
- if (pos.offset === length && _chunk4SLJNZSMcjs.inlineText.call(void 0, block.regions[pos.region]).endsWith("\n")) {
3043
+ if (pos.offset === length && chunkAIS37SL2_cjs.inlineText(block.regions[pos.region]).endsWith("\n")) {
3099
3044
  tr.step(replaceInlineStep(block.id, pos.region, length - 1, length, []));
3100
3045
  const paragraph = createBlock(schema, schema.defaultTextBlock, {}, block.indent, makeId());
3101
3046
  tr.step(insertBlocksStep(descendantsEnd(tr.doc, index), [paragraph]));
@@ -3110,15 +3055,15 @@ function leaveItem({ tr, schema, block, index, pos }) {
3110
3055
  tr.setSelection(startOf(tr.doc, schema, block.id));
3111
3056
  }
3112
3057
  function insertEmptyBefore({ tr, schema, block, index, pos, makeId }) {
3113
- const next = _optionalChain([specOf, 'call', _108 => _108(schema, block), 'access', _109 => _109.splitAttrs, 'optionalCall', _110 => _110(block.attrs)]);
3114
- const empty = createBlock(schema, _nullishCoalesce(_optionalChain([next, 'optionalAccess', _111 => _111.type]), () => ( schema.defaultTextBlock)), _optionalChain([next, 'optionalAccess', _112 => _112.attrs]), block.indent, makeId());
3058
+ const next = specOf(schema, block).splitAttrs?.(block.attrs);
3059
+ const empty = createBlock(schema, next?.type ?? schema.defaultTextBlock, next?.attrs, block.indent, makeId());
3115
3060
  tr.step(insertBlocksStep(index, [empty]));
3116
3061
  tr.setSelection(textSelection(pos));
3117
3062
  }
3118
3063
  function splitToggle({ tr, schema, block, index, pos, makeId }) {
3119
3064
  const length = regionLength(block, pos.region);
3120
3065
  const open = block.attrs.open === true;
3121
- const tail = _chunk4SLJNZSMcjs.sliceInline.call(void 0, block.regions[pos.region], pos.offset, length);
3066
+ const tail = chunkAIS37SL2_cjs.sliceInline(block.regions[pos.region], pos.offset, length);
3122
3067
  const empty = createBlock(schema, schema.defaultTextBlock, {}, open ? block.indent + 1 : block.indent, makeId());
3123
3068
  if (pos.offset < length) tr.step(replaceInlineStep(block.id, pos.region, pos.offset, length, []));
3124
3069
  tr.step(insertBlocksStep(open ? index + 1 : descendantsEnd(tr.doc, index), [withContent(schema, empty, tail)]));
@@ -3130,7 +3075,7 @@ function splitInTwo({ tr, schema, block, pos, makeId }) {
3130
3075
  tr.setSelection(textSelection({ block: tail.id, region: tail.region, offset: 0 }));
3131
3076
  }
3132
3077
  function splitAt(tr, schema, pos, collapsed, makeId) {
3133
- const index = _chunk4SLJNZSMcjs.requireBlockIndex.call(void 0, tr.doc, pos.block);
3078
+ const index = chunkAIS37SL2_cjs.requireBlockIndex(tr.doc, pos.block);
3134
3079
  const block = tr.doc.blocks[index];
3135
3080
  if (!isTextFlow(schema, block) || pos.region !== primaryRegion(schema, block)) return false;
3136
3081
  const target = { tr, schema, block, index, pos, makeId };
@@ -3145,13 +3090,13 @@ function splitAt(tr, schema, pos, collapsed, makeId) {
3145
3090
 
3146
3091
  // src/engine/commands/split-block.ts
3147
3092
  function splitBlock(options = {}) {
3148
- const makeId = _nullishCoalesce(options.newId, () => ( _chunk4SLJNZSMcjs.newId));
3093
+ const makeId = options.newId ?? chunkAIS37SL2_cjs.newId;
3149
3094
  return (state, dispatch) => {
3150
3095
  const { doc, schema, selection } = state;
3151
3096
  if (selection === null || selection.kind === "blocks") return false;
3152
3097
  const tr = new Transaction(state).setMeta(LINE_SPLIT, true);
3153
3098
  if (selection.kind === "node") {
3154
- const index = _chunk4SLJNZSMcjs.requireBlockIndex.call(void 0, doc, selection.block);
3099
+ const index = chunkAIS37SL2_cjs.requireBlockIndex(doc, selection.block);
3155
3100
  const paragraph = createBlock(schema, schema.defaultTextBlock, {}, doc.blocks[index].indent, makeId());
3156
3101
  tr.step(insertBlocksStep(descendantsEnd(doc, index), [paragraph]));
3157
3102
  tr.setSelection(startOf(tr.doc, schema, paragraph.id));
@@ -3160,7 +3105,7 @@ function splitBlock(options = {}) {
3160
3105
  const caret = deleteRange(tr, schema, from, to, makeId);
3161
3106
  if (!splitAt(tr, schema, caret, isCollapsed(selection), makeId)) return false;
3162
3107
  }
3163
- _optionalChain([dispatch, 'optionalCall', _113 => _113(tr)]);
3108
+ dispatch?.(tr);
3164
3109
  return true;
3165
3110
  };
3166
3111
  }
@@ -3241,7 +3186,7 @@ function freshBlocks(pieces, baseIndent, makeId) {
3241
3186
 
3242
3187
  // src/engine/clipboard/paste-at-caret.ts
3243
3188
  function contentOf(schema, block) {
3244
- return _nullishCoalesce(block.regions[_nullishCoalesce(primaryRegion(schema, block), () => ( ""))], () => ( []));
3189
+ return block.regions[primaryRegion(schema, block) ?? ""] ?? [];
3245
3190
  }
3246
3191
  function insertAt(tr, pos, content) {
3247
3192
  if (content.length > 0) tr.step(replaceInlineStep(pos.block, pos.region, pos.offset, pos.offset, content));
@@ -3261,7 +3206,7 @@ function replaceEmpty(tr, schema, index, blocks) {
3261
3206
  tr.setSelection(endOf(tr.doc, schema, blocks[blocks.length - 1].id));
3262
3207
  }
3263
3208
  function pasteAtCaret(tr, schema, caret, ends, pieces, makeId) {
3264
- const index = _chunk4SLJNZSMcjs.requireBlockIndex.call(void 0, tr.doc, caret.block);
3209
+ const index = chunkAIS37SL2_cjs.requireBlockIndex(tr.doc, caret.block);
3265
3210
  const current = tr.doc.blocks[index];
3266
3211
  const { region } = caret;
3267
3212
  const first = pieces[0];
@@ -3270,7 +3215,7 @@ function pasteAtCaret(tr, schema, caret, ends, pieces, makeId) {
3270
3215
  if (pieces.length === 1 && ends.openStart && ends.openEnd && textual(first)) {
3271
3216
  const content = contentOf(schema, first);
3272
3217
  insertAt(tr, caret, content);
3273
- tr.setSelection(textSelection({ ...caret, offset: caret.offset + _chunk4SLJNZSMcjs.inlineLength.call(void 0, content) }));
3218
+ tr.setSelection(textSelection({ ...caret, offset: caret.offset + chunkAIS37SL2_cjs.inlineLength(content) }));
3274
3219
  return;
3275
3220
  }
3276
3221
  const fresh = freshBlocks(pieces, current.indent, makeId);
@@ -3292,18 +3237,18 @@ function pasteAtCaret(tr, schema, caret, ends, pieces, makeId) {
3292
3237
  if (atStart && !atEnd) {
3293
3238
  if (middle.length > 0) insertCapped(tr, index, middle);
3294
3239
  insertAt(tr, { ...caret, offset: 0 }, lastContent);
3295
- tr.setSelection(textSelection({ ...caret, offset: _chunk4SLJNZSMcjs.inlineLength.call(void 0, lastContent) }));
3240
+ tr.setSelection(textSelection({ ...caret, offset: chunkAIS37SL2_cjs.inlineLength(lastContent) }));
3296
3241
  return;
3297
3242
  }
3298
3243
  const firstContent = mergeFirst ? contentOf(schema, fresh[0]) : [];
3299
3244
  insertAt(tr, caret, firstContent);
3300
- const offset = caret.offset + _chunk4SLJNZSMcjs.inlineLength.call(void 0, firstContent);
3245
+ const offset = caret.offset + chunkAIS37SL2_cjs.inlineLength(firstContent);
3301
3246
  const tail = !atEnd && (mergeLast || middle.length > 0) ? splitStep(schema, current, region, offset, makeId()) : null;
3302
3247
  if (tail !== null) tr.step(tail.step);
3303
3248
  if (middle.length > 0) insertCapped(tr, index + 1, middle);
3304
3249
  if (tail !== null && mergeLast) {
3305
3250
  insertAt(tr, { block: tail.tail.id, region: tail.tail.region, offset: 0 }, lastContent);
3306
- tr.setSelection(textSelection({ block: tail.tail.id, region: tail.tail.region, offset: _chunk4SLJNZSMcjs.inlineLength.call(void 0, lastContent) }));
3251
+ tr.setSelection(textSelection({ block: tail.tail.id, region: tail.tail.region, offset: chunkAIS37SL2_cjs.inlineLength(lastContent) }));
3307
3252
  } else if (middle.length > 0) {
3308
3253
  tr.setSelection(endOf(tr.doc, schema, middle[middle.length - 1].id));
3309
3254
  } else {
@@ -3329,10 +3274,10 @@ function appendAtEnd(tr, schema, pieces, makeId) {
3329
3274
  tr.setSelection(endOf(tr.doc, schema, fresh[fresh.length - 1].id));
3330
3275
  }
3331
3276
  function insertSlice(slice, options = {}) {
3332
- const makeId = _nullishCoalesce(options.newId, () => ( _chunk4SLJNZSMcjs.newId));
3277
+ const makeId = options.newId ?? chunkAIS37SL2_cjs.newId;
3333
3278
  return (state, dispatch) => {
3334
3279
  const { doc, schema, selection } = state;
3335
- const codec = _chunk4SLJNZSMcjs.createBlockCodec.call(void 0, schema, { newId: makeId });
3280
+ const codec = chunkAIS37SL2_cjs.createBlockCodec(schema, { newId: makeId });
3336
3281
  const pieces = slice.blocks.flatMap((block) => codec.toEngineBlocks(block));
3337
3282
  if (pieces.length === 0) return false;
3338
3283
  const tr = new Transaction(state).setOrigin("paste");
@@ -3344,7 +3289,7 @@ function insertSlice(slice, options = {}) {
3344
3289
  } else {
3345
3290
  replaceSelected(tr, schema, selection, pieces, makeId);
3346
3291
  }
3347
- _optionalChain([dispatch, 'optionalCall', _114 => _114(tr)]);
3292
+ dispatch?.(tr);
3348
3293
  return true;
3349
3294
  };
3350
3295
  }
@@ -3366,11 +3311,11 @@ function pastedLink(text2, schemes = "http") {
3366
3311
 
3367
3312
  // src/engine/clipboard/paste-link.ts
3368
3313
  function pasteLinkOverSelection(text2) {
3369
- const href = _nullishCoalesce(_optionalChain([pastedLink, 'call', _115 => _115(text2, "linkable"), 'optionalAccess', _116 => _116.href]), () => ( null));
3370
- const link = setLink(_nullishCoalesce(href, () => ( "")));
3314
+ const href = pastedLink(text2, "linkable")?.href ?? null;
3315
+ const link = setLink(href ?? "");
3371
3316
  return (state, dispatch) => {
3372
3317
  const { selection } = state;
3373
- if (href === null || _optionalChain([selection, 'optionalAccess', _117 => _117.kind]) !== "text" || isCollapsed(selection)) return false;
3318
+ if (href === null || selection?.kind !== "text" || isCollapsed(selection)) return false;
3374
3319
  return link(state, dispatch && ((tr) => dispatch(tr.setOrigin("paste"))));
3375
3320
  };
3376
3321
  }
@@ -3379,11 +3324,11 @@ function pasteLinkOverSelection(text2) {
3379
3324
  var FENCE = /^```([\w+#.-]*)$/;
3380
3325
  function fenceTransaction(state) {
3381
3326
  const { selection, doc } = state;
3382
- if (_optionalChain([selection, 'optionalAccess', _118 => _118.kind]) !== "text" || !isCollapsed(selection)) return null;
3327
+ if (selection?.kind !== "text" || !isCollapsed(selection)) return null;
3383
3328
  const { block: id, region, offset } = selection.head;
3384
- const block = _chunk4SLJNZSMcjs.blockById.call(void 0, doc, id);
3329
+ const block = chunkAIS37SL2_cjs.blockById(doc, id);
3385
3330
  if (block === void 0 || !isParagraph(block) || offset !== regionLength(block, region)) return null;
3386
- const fence = FENCE.exec(_chunk4SLJNZSMcjs.inlineText.call(void 0, block.regions[region]));
3331
+ const fence = FENCE.exec(chunkAIS37SL2_cjs.inlineText(block.regions[region]));
3387
3332
  if (fence === null) return null;
3388
3333
  return convertPrefix(state, { block: id, region, from: 0, to: offset }, setBlockType("CODE", { language: fence[1] }));
3389
3334
  }
@@ -3392,7 +3337,7 @@ function splitBlockWithRules(options = {}) {
3392
3337
  return (state, dispatch) => {
3393
3338
  const tr = fenceTransaction(state);
3394
3339
  if (tr === null) return split(state, dispatch);
3395
- _optionalChain([dispatch, 'optionalCall', _119 => _119(tr)]);
3340
+ dispatch?.(tr);
3396
3341
  return true;
3397
3342
  };
3398
3343
  }
@@ -3450,9 +3395,9 @@ function coreExtensions(options = {}) {
3450
3395
  return [
3451
3396
  defineExtension({
3452
3397
  name: "core",
3453
- blocks: _chunk4SLJNZSMcjs.coreBlockSpecs,
3454
- marks: _chunk4SLJNZSMcjs.coreMarkSpecs,
3455
- atoms: _chunk4SLJNZSMcjs.coreAtomSpecs,
3398
+ blocks: chunkAIS37SL2_cjs.coreBlockSpecs,
3399
+ marks: chunkAIS37SL2_cjs.coreMarkSpecs,
3400
+ atoms: chunkAIS37SL2_cjs.coreAtomSpecs,
3456
3401
  commands: coreCommands,
3457
3402
  pasteRules: [linkOverSelection]
3458
3403
  }),
@@ -3469,12 +3414,12 @@ function coreExtensions(options = {}) {
3469
3414
 
3470
3415
  // src/engine/clipboard/serialize-slice.ts
3471
3416
  function sliceText(slice, options) {
3472
- const schema = _nullishCoalesce(options.schema, () => ( _chunk4SLJNZSMcjs.createSchema.call(void 0, )));
3417
+ const schema = options.schema ?? chunkAIS37SL2_cjs.createSchema();
3473
3418
  if (slice.blocks.length === 1 && slice.openStart && slice.openEnd) {
3474
- const pieces = _chunk4SLJNZSMcjs.createBlockCodec.call(void 0, schema).toEngineBlocks(slice.blocks[0]);
3419
+ const pieces = chunkAIS37SL2_cjs.createBlockCodec(schema).toEngineBlocks(slice.blocks[0]);
3475
3420
  const block = pieces.length === 1 ? stripComments(pieces[0]) : null;
3476
3421
  const region = block === null || !isTextFlow(schema, block) ? null : primaryRegion(schema, block);
3477
- if (block !== null && region !== null) return _chunk4SLJNZSMcjs.inlinePlainText.call(void 0, _nullishCoalesce(block.regions[region], () => ( [])), schema);
3422
+ if (block !== null && region !== null) return chunkAIS37SL2_cjs.inlinePlainText(block.regions[region] ?? [], schema);
3478
3423
  }
3479
3424
  const markdown = toMarkdown(slice.blocks, { schema, resolveAssetUrl: options.resolveAssetUrl, comments: false });
3480
3425
  return markdown.replace(/\n$/, "");
@@ -3492,17 +3437,17 @@ function isFlowRegion(schema, block, region) {
3492
3437
  return isTextFlow(schema, block) && region === primaryRegion(schema, block);
3493
3438
  }
3494
3439
  function trimmed(block, region, from, to) {
3495
- return { ...block, regions: { ...block.regions, [region]: _chunk4SLJNZSMcjs.sliceInline.call(void 0, block.regions[region], from, to) } };
3440
+ return { ...block, regions: { ...block.regions, [region]: chunkAIS37SL2_cjs.sliceInline(block.regions[region], from, to) } };
3496
3441
  }
3497
3442
  function insideOneRegion(schema, block, region, from, to) {
3498
3443
  if (isFlowRegion(schema, block, region)) return trimmed(block, region, from, to);
3499
3444
  const paragraph = createBlock(schema, schema.defaultTextBlock, {}, block.indent, block.id);
3500
- return withContent(schema, paragraph, _chunk4SLJNZSMcjs.sliceInline.call(void 0, block.regions[region], from, to));
3445
+ return withContent(schema, paragraph, chunkAIS37SL2_cjs.sliceInline(block.regions[region], from, to));
3501
3446
  }
3502
3447
  function textBlocks({ doc, schema }, selection) {
3503
3448
  const { from, to } = orderedRange(doc, selection.anchor, selection.head);
3504
- const start = _chunk4SLJNZSMcjs.requireBlockIndex.call(void 0, doc, from.block);
3505
- const end = _chunk4SLJNZSMcjs.requireBlockIndex.call(void 0, doc, to.block);
3449
+ const start = chunkAIS37SL2_cjs.requireBlockIndex(doc, from.block);
3450
+ const end = chunkAIS37SL2_cjs.requireBlockIndex(doc, to.block);
3506
3451
  const first = doc.blocks[start];
3507
3452
  if (start === end) {
3508
3453
  if (from.region !== to.region) return [first];
@@ -3517,7 +3462,7 @@ function textBlocks({ doc, schema }, selection) {
3517
3462
  }
3518
3463
  function selectedBlocks(state) {
3519
3464
  const { doc, selection } = state;
3520
- if (_optionalChain([selection, 'optionalAccess', _120 => _120.kind]) === "text") return textBlocks(state, selection);
3465
+ if (selection?.kind === "text") return textBlocks(state, selection);
3521
3466
  const range = selectedBlockRange(doc, selection);
3522
3467
  return range === null ? [] : doc.blocks.slice(range.start, range.end);
3523
3468
  }
@@ -3548,28 +3493,28 @@ var INLINE_SYNTAX = [/\*\*[^*\n]+\*\*/, /__[^_\n]+__/, /\[[^\]\n]+\]\([^)\s]+[^)
3548
3493
  function looksLikeMarkdown(value) {
3549
3494
  return value.split(/\r\n|\r|\n/).some((line2) => BLOCK_MARKERS.some((marker) => marker.test(line2))) || INLINE_SYNTAX.some((syntax) => syntax.test(value));
3550
3495
  }
3551
- function plainTextToBlocks(value, makeId = _chunk4SLJNZSMcjs.newId) {
3496
+ function plainTextToBlocks(value, makeId = chunkAIS37SL2_cjs.newId) {
3552
3497
  return value.split(/\r\n|\r|\n/).filter((line2) => line2.trim() !== "").map((line2) => ({
3553
3498
  id: makeId(),
3554
3499
  type: "MARKDOWN",
3555
- data: { markdown: _chunk4SLJNZSMcjs.serializeInline.call(void 0, [_chunk4SLJNZSMcjs.text.call(void 0, line2)], { escapeLineStart: true }) }
3500
+ data: { markdown: chunkAIS37SL2_cjs.serializeInline([chunkAIS37SL2_cjs.text(line2)], { escapeLineStart: true }) }
3556
3501
  }));
3557
3502
  }
3558
3503
 
3559
3504
  // src/engine/clipboard/parse-slice-json.ts
3560
3505
  function isBlock2(value) {
3561
- if (!_chunk4SLJNZSMcjs.isRecord.call(void 0, value) || typeof value.id !== "string" || typeof value.type !== "string") return false;
3562
- if (!_chunk4SLJNZSMcjs.isRecord.call(void 0, value.data)) return false;
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;
3563
3508
  return value.indent === void 0 || Number.isInteger(value.indent) && value.indent >= 0;
3564
3509
  }
3565
3510
  function parseSliceJSON(json) {
3566
3511
  let parsed;
3567
3512
  try {
3568
3513
  parsed = JSON.parse(json);
3569
- } catch (e) {
3514
+ } catch {
3570
3515
  return null;
3571
3516
  }
3572
- if (!_chunk4SLJNZSMcjs.isRecord.call(void 0, parsed) || parsed.quoin !== 1 || !_chunk4SLJNZSMcjs.isRecord.call(void 0, parsed.slice)) return null;
3517
+ if (!chunkAIS37SL2_cjs.isRecord(parsed) || parsed.quoin !== 1 || !chunkAIS37SL2_cjs.isRecord(parsed.slice)) return null;
3573
3518
  const { blocks, openStart, openEnd } = parsed.slice;
3574
3519
  if (!Array.isArray(blocks) || blocks.length === 0 || !blocks.every(isBlock2)) return null;
3575
3520
  if (typeof openStart !== "boolean" || typeof openEnd !== "boolean") return null;
@@ -3577,7 +3522,7 @@ function parseSliceJSON(json) {
3577
3522
  }
3578
3523
 
3579
3524
  // src/engine/clipboard/slice-from-clipboard.ts
3580
- var isParagraph2 = (block) => block.type === "MARKDOWN" && _chunk4SLJNZSMcjs.parseLine.call(void 0, String(_nullishCoalesce(block.data.markdown, () => ( "")))).kind === "paragraph";
3525
+ var isParagraph2 = (block) => block.type === "MARKDOWN" && chunkAIS37SL2_cjs.parseLine(String(block.data.markdown ?? "")).kind === "paragraph";
3581
3526
  function openSlice(blocks, plainText2 = false) {
3582
3527
  if (blocks.length === 0) return null;
3583
3528
  const slice = { blocks, openStart: isParagraph2(blocks[0]), openEnd: isParagraph2(blocks[blocks.length - 1]) };
@@ -3587,14 +3532,14 @@ function linkBlocks(text2, makeId) {
3587
3532
  const link = pastedLink(text2);
3588
3533
  if (link === null) return null;
3589
3534
  const { url, href, rest } = link;
3590
- const linked2 = _chunk4SLJNZSMcjs.text.call(void 0, url, [{ type: "link", attrs: { href } }]);
3591
- const markdown = _chunk4SLJNZSMcjs.serializeInline.call(void 0, rest === "" ? [linked2] : [linked2, _chunk4SLJNZSMcjs.text.call(void 0, rest)]);
3535
+ const linked2 = chunkAIS37SL2_cjs.text(url, [{ type: "link", attrs: { href } }]);
3536
+ const markdown = chunkAIS37SL2_cjs.serializeInline(rest === "" ? [linked2] : [linked2, chunkAIS37SL2_cjs.text(rest)]);
3592
3537
  return [{ id: makeId(), type: "MARKDOWN", data: { markdown } }];
3593
3538
  }
3594
3539
  function textBlocks2(text2, makeId) {
3595
3540
  const link = linkBlocks(text2, makeId);
3596
3541
  if (link !== null) return link;
3597
- return looksLikeMarkdown(text2) ? _chunk4SLJNZSMcjs.fromMarkdown.call(void 0, text2, { newId: makeId }) : plainTextToBlocks(text2, makeId);
3542
+ return looksLikeMarkdown(text2) ? chunkAIS37SL2_cjs.fromMarkdown(text2, { newId: makeId }) : plainTextToBlocks(text2, makeId);
3598
3543
  }
3599
3544
  function htmlSlice(html, options) {
3600
3545
  if (html === void 0) return null;
@@ -3606,16 +3551,16 @@ function sliceFromClipboard(data, options = {}) {
3606
3551
  if (fromJson !== null) return fromJson;
3607
3552
  const fromHtml = htmlSlice(data.html, options);
3608
3553
  if (fromHtml !== null) return fromHtml;
3609
- return data.text === void 0 ? null : openSlice(textBlocks2(data.text, _nullishCoalesce(options.newId, () => ( _chunk4SLJNZSMcjs.newId))), true);
3554
+ return data.text === void 0 ? null : openSlice(textBlocks2(data.text, options.newId ?? chunkAIS37SL2_cjs.newId), true);
3610
3555
  }
3611
3556
 
3612
3557
  // src/engine/commands/is-active.ts
3613
3558
  function hasAttrs(block, attrs) {
3614
- return Object.entries(_nullishCoalesce(attrs, () => ( {}))).every(([key, value]) => block.attrs[key] === value);
3559
+ return Object.entries(attrs ?? {}).every(([key, value]) => block.attrs[key] === value);
3615
3560
  }
3616
3561
  function isActive(state, name, attrs) {
3617
3562
  if (state.schema.marks.has(name)) return selectionHasMark(state, name, attrs);
3618
- const blocks = selectedBlockIds(state.doc, state.selection).flatMap((id) => _nullishCoalesce(_chunk4SLJNZSMcjs.blockById.call(void 0, state.doc, id), () => ( [])));
3563
+ const blocks = selectedBlockIds(state.doc, state.selection).flatMap((id) => chunkAIS37SL2_cjs.blockById(state.doc, id) ?? []);
3619
3564
  const isBlockType = state.schema.blocks.has(name);
3620
3565
  const matches = (block) => isBlockType ? block.type === name : block.type === "MARKDOWN" && block.attrs.kind === name;
3621
3566
  return blocks.length > 0 && blocks.every((block) => matches(block) && hasAttrs(block, attrs));
@@ -3624,19 +3569,19 @@ function isActive(state, name, attrs) {
3624
3569
  // src/engine/model/same-doc.ts
3625
3570
  function sameDoc(a, b) {
3626
3571
  if (a === b) return true;
3627
- return a.blocks.length === b.blocks.length && a.blocks.every((block, i) => _chunk6V6GGBDKcjs.sameValue.call(void 0, block, b.blocks[i]));
3572
+ return a.blocks.length === b.blocks.length && a.blocks.every((block, i) => chunk7SVKLWDT_cjs.sameValue(block, b.blocks[i]));
3628
3573
  }
3629
3574
 
3630
3575
  // src/engine/extension/same-blocks.ts
3631
3576
  function sameBlock(a, b) {
3632
- return a === b || a.id === b.id && a.type === b.type && (_nullishCoalesce(a.indent, () => ( 0))) === (_nullishCoalesce(b.indent, () => ( 0))) && _chunk6V6GGBDKcjs.sameValue.call(void 0, a.data, b.data);
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);
3633
3578
  }
3634
3579
  function sameBlocks(a, b) {
3635
- return a === b || _chunk4SLJNZSMcjs.sameItems.call(void 0, a, b, sameBlock);
3580
+ return a === b || chunkAIS37SL2_cjs.sameItems(a, b, sameBlock);
3636
3581
  }
3637
3582
 
3638
3583
  // src/engine/extension/structural-echo.ts
3639
- var sameIds = (a, b) => _chunk4SLJNZSMcjs.sameItems.call(void 0, a, b, (x, y) => x.id === y.id);
3584
+ var sameIds = (a, b) => chunkAIS37SL2_cjs.sameItems(a, b, (x, y) => x.id === y.id);
3640
3585
  function copiedSequence(emissions, incoming) {
3641
3586
  const verdicts = /* @__PURE__ */ new Map();
3642
3587
  const sameAt = (block, index) => {
@@ -3646,7 +3591,7 @@ function copiedSequence(emissions, incoming) {
3646
3591
  verdicts.set(block, same);
3647
3592
  return same;
3648
3593
  };
3649
- return _optionalChain([emissions, 'access', _121 => _121.find, 'call', _122 => _122(({ blocks }) => sameIds(blocks, incoming) && blocks.every(sameAt)), 'optionalAccess', _123 => _123.sequence]);
3594
+ return emissions.find(({ blocks }) => sameIds(blocks, incoming) && blocks.every(sameAt))?.sequence;
3650
3595
  }
3651
3596
 
3652
3597
  // src/engine/extension/echo-tracker.ts
@@ -3663,7 +3608,7 @@ function createEchoTracker() {
3663
3608
  if (outstanding.length > STRUCTURAL_ECHO_WINDOW) outstanding.shift();
3664
3609
  },
3665
3610
  classify(blocks) {
3666
- const sequence = _nullishCoalesce(sequences.get(blocks), () => ( copiedSequence(outstanding, blocks)));
3611
+ const sequence = sequences.get(blocks) ?? copiedSequence(outstanding, blocks);
3667
3612
  if (sequence === void 0 || sequence <= acknowledged) return "foreign";
3668
3613
  acknowledged = sequence;
3669
3614
  outstanding = outstanding.filter((emission) => emission.sequence > sequence);
@@ -3685,7 +3630,7 @@ function createControlledBlocks(config) {
3685
3630
  let converted = null;
3686
3631
  function getBlocks() {
3687
3632
  const { doc } = state();
3688
- if (_optionalChain([converted, 'optionalAccess', _124 => _124.doc]) !== doc) converted = { doc, blocks: codec.blocksFromDoc(doc) };
3633
+ if (converted?.doc !== doc) converted = { doc, blocks: codec.blocksFromDoc(doc) };
3689
3634
  return converted.blocks;
3690
3635
  }
3691
3636
  function reconcile(incoming) {
@@ -3710,7 +3655,7 @@ function createControlledBlocks(config) {
3710
3655
  if (!tr.docChanged || quiet.has(tr)) return;
3711
3656
  const blocks = getBlocks();
3712
3657
  tracker.emitted(blocks);
3713
- _optionalChain([onChange, 'optionalCall', _125 => _125(blocks)]);
3658
+ onChange?.(blocks);
3714
3659
  }
3715
3660
  };
3716
3661
  }
@@ -3773,10 +3718,10 @@ function normalizeKey(name, isMac) {
3773
3718
  return join2(held, lowerSingle(name.slice(split + 1)));
3774
3719
  }
3775
3720
  function eventKey({ key, code, shiftKey, altKey }, isMac) {
3776
- const typed2 = lowerSingle(_nullishCoalesce(key, () => ( "Unidentified")));
3721
+ const typed2 = lowerSingle(key ?? "Unidentified");
3777
3722
  if (!(shiftKey || isMac && altKey) || PLAIN_KEY.test(typed2)) return typed2;
3778
3723
  const physical = code === void 0 ? null : PHYSICAL_KEY.exec(code);
3779
- return physical === null ? typed2 : (_nullishCoalesce(physical[1], () => ( physical[2]))).toLowerCase();
3724
+ return physical === null ? typed2 : (physical[1] ?? physical[2]).toLowerCase();
3780
3725
  }
3781
3726
  function keyName(event, isMac) {
3782
3727
  const held = /* @__PURE__ */ new Set();
@@ -3787,7 +3732,7 @@ function keyName(event, isMac) {
3787
3732
  return join2(held, eventKey(event, isMac));
3788
3733
  }
3789
3734
  function runKeymap(keymap, state, dispatch, event, isMac) {
3790
- return (_nullishCoalesce(keymap.get(keyName(event, isMac)), () => ( []))).some((command) => command(state, dispatch));
3735
+ return (keymap.get(keyName(event, isMac)) ?? []).some((command) => command(state, dispatch));
3791
3736
  }
3792
3737
 
3793
3738
  // src/engine/extension/resolve-extensions.ts
@@ -3795,9 +3740,9 @@ var DEFAULT_PRIORITY = 100;
3795
3740
  function keymapOf(extensions, isMac) {
3796
3741
  const keymap = /* @__PURE__ */ new Map();
3797
3742
  for (const { keymap: bindings } of extensions) {
3798
- for (const [name, command] of Object.entries(_nullishCoalesce(bindings, () => ( {})))) {
3743
+ for (const [name, command] of Object.entries(bindings ?? {})) {
3799
3744
  const key = normalizeKey(name, isMac);
3800
- keymap.set(key, [..._nullishCoalesce(keymap.get(key), () => ( [])), command]);
3745
+ keymap.set(key, [...keymap.get(key) ?? [], command]);
3801
3746
  }
3802
3747
  }
3803
3748
  return keymap;
@@ -3805,7 +3750,7 @@ function keymapOf(extensions, isMac) {
3805
3750
  function commandsOf(extensions) {
3806
3751
  const commands = /* @__PURE__ */ new Map();
3807
3752
  for (const { commands: factories } of extensions) {
3808
- for (const [name, factory] of Object.entries(_nullishCoalesce(factories, () => ( {})))) {
3753
+ for (const [name, factory] of Object.entries(factories ?? {})) {
3809
3754
  if (!commands.has(name)) commands.set(name, factory);
3810
3755
  }
3811
3756
  }
@@ -3813,22 +3758,22 @@ function commandsOf(extensions) {
3813
3758
  }
3814
3759
  function resolveExtensions(extensions, isMac) {
3815
3760
  const sorted = [...extensions].sort(
3816
- (a, b) => (_nullishCoalesce(b.priority, () => ( DEFAULT_PRIORITY))) - (_nullishCoalesce(a.priority, () => ( DEFAULT_PRIORITY)))
3761
+ (a, b) => (b.priority ?? DEFAULT_PRIORITY) - (a.priority ?? DEFAULT_PRIORITY)
3817
3762
  );
3818
3763
  return {
3819
3764
  extensions: sorted,
3820
- schema: _chunk4SLJNZSMcjs.createSchema.call(void 0, {
3821
- blocks: sorted.flatMap((extension) => _nullishCoalesce(extension.blocks, () => ( []))),
3822
- marks: sorted.flatMap((extension) => _nullishCoalesce(extension.marks, () => ( []))),
3823
- atoms: sorted.flatMap((extension) => _nullishCoalesce(extension.atoms, () => ( [])))
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 ?? [])
3824
3769
  }),
3825
- inputRules: sorted.flatMap((extension) => _nullishCoalesce(extension.inputRules, () => ( []))),
3826
- pasteRules: sorted.flatMap((extension) => _nullishCoalesce(extension.pasteRules, () => ( []))),
3770
+ inputRules: sorted.flatMap((extension) => extension.inputRules ?? []),
3771
+ pasteRules: sorted.flatMap((extension) => extension.pasteRules ?? []),
3827
3772
  keymap: keymapOf(sorted, isMac),
3828
3773
  commands: commandsOf(sorted),
3829
- plugins: sorted.flatMap((extension) => _nullishCoalesce(extension.plugins, () => ( []))),
3830
- decorations: (state) => sorted.flatMap((extension) => _nullishCoalesce(_optionalChain([extension, 'access', _126 => _126.decorations, 'optionalCall', _127 => _127(state)]), () => ( []))),
3831
- filterTransaction: (tr, state) => sorted.every((extension) => _optionalChain([extension, 'access', _128 => _128.filterTransaction, 'optionalCall', _129 => _129(tr, state)]) !== false)
3774
+ plugins: sorted.flatMap((extension) => extension.plugins ?? []),
3775
+ decorations: (state) => sorted.flatMap((extension) => extension.decorations?.(state) ?? []),
3776
+ filterTransaction: (tr, state) => sorted.every((extension) => extension.filterTransaction?.(tr, state) !== false)
3832
3777
  };
3833
3778
  }
3834
3779
 
@@ -3838,10 +3783,10 @@ function createEditor(options) {
3838
3783
  }
3839
3784
  function createInternalEditor(options) {
3840
3785
  const { newId: newId2 } = options;
3841
- const isMac = _nullishCoalesce(options.isMac, () => ( detectMac()));
3842
- const resolved = resolveExtensions(_nullishCoalesce(options.extensions, () => ( coreExtensions({ newId: newId2 }))), isMac);
3786
+ const isMac = options.isMac ?? detectMac();
3787
+ const resolved = resolveExtensions(options.extensions ?? coreExtensions({ newId: newId2 }), isMac);
3843
3788
  const { schema, plugins } = resolved;
3844
- const codec = _chunk4SLJNZSMcjs.createBlockCodec.call(void 0, schema, { newId: newId2 });
3789
+ const codec = chunkAIS37SL2_cjs.createBlockCodec(schema, { newId: newId2 });
3845
3790
  const listeners = /* @__PURE__ */ new Set();
3846
3791
  const mounts = /* @__PURE__ */ new Set();
3847
3792
  let state = createState({ doc: codec.docFromBlocks(options.blocks), schema, plugins, clock: options.now });
@@ -3852,7 +3797,7 @@ function createInternalEditor(options) {
3852
3797
  state: () => state,
3853
3798
  dispatch,
3854
3799
  onChange: options.onChange,
3855
- accepts: (incoming) => resolved.extensions.every((extension) => _optionalChain([extension, 'access', _130 => _130.filterHostBlocks, 'optionalCall', _131 => _131(incoming, state)]) !== false)
3800
+ accepts: (incoming) => resolved.extensions.every((extension) => extension.filterHostBlocks?.(incoming, state) !== false)
3856
3801
  });
3857
3802
  const { getBlocks } = controlled;
3858
3803
  function commit(tr) {
@@ -3860,8 +3805,8 @@ function createInternalEditor(options) {
3860
3805
  if (!exempt && !resolved.filterTransaction(tr, state)) return;
3861
3806
  state = applyTransaction(state, tr);
3862
3807
  for (const listener of [...listeners]) listener(state, tr);
3863
- for (const extension of resolved.extensions) _optionalChain([extension, 'access', _132 => _132.onTransaction, 'optionalCall', _133 => _133(tr, state)]);
3864
- _optionalChain([options, 'access', _134 => _134.onTransaction, 'optionalCall', _135 => _135(tr, state)]);
3808
+ for (const extension of resolved.extensions) extension.onTransaction?.(tr, state);
3809
+ options.onTransaction?.(tr, state);
3865
3810
  controlled.committed(tr);
3866
3811
  }
3867
3812
  const queue = createDispatchQueue(() => state, commit);
@@ -3872,7 +3817,7 @@ function createInternalEditor(options) {
3872
3817
  function paste(data, parser) {
3873
3818
  if (destroyed) return false;
3874
3819
  const { text: text2 } = data;
3875
- const ruled = text2 !== void 0 && resolved.pasteRules.some((rule) => _optionalChain([rule, 'access', _136 => _136.match, 'call', _137 => _137(text2, state), 'optionalCall', _138 => _138(state, dispatch)]));
3820
+ const ruled = text2 !== void 0 && resolved.pasteRules.some((rule) => rule.match(text2, state)?.(state, dispatch));
3876
3821
  if (ruled) return true;
3877
3822
  const slice = sliceFromClipboard(data, { parser, newId: newId2 });
3878
3823
  return slice !== null && insertSlice(slice, { newId: newId2 })(state, dispatch);
@@ -3882,7 +3827,7 @@ function createInternalEditor(options) {
3882
3827
  return slice === null ? null : sliceToClipboard(slice, { schema, resolveAssetUrl: options.resolveAssetUrl });
3883
3828
  }
3884
3829
  function exportMarkdown(markdown = {}) {
3885
- const resolveAssetUrl = _nullishCoalesce(markdown.resolveAssetUrl, () => ( options.resolveAssetUrl));
3830
+ const resolveAssetUrl = markdown.resolveAssetUrl ?? options.resolveAssetUrl;
3886
3831
  return toMarkdown(getBlocks(), { schema, ...markdown, resolveAssetUrl });
3887
3832
  }
3888
3833
  const helpers = createCommandHelpers(() => state, dispatch, resolved.commands, () => !destroyed);
@@ -3912,11 +3857,11 @@ function createInternalEditor(options) {
3912
3857
  mount() {
3913
3858
  const stops = [];
3914
3859
  const unmount = () => {
3915
- if (mounts.delete(unmount)) for (const stop of stops) _optionalChain([stop, 'optionalCall', _139 => _139()]);
3860
+ if (mounts.delete(unmount)) for (const stop of stops) stop?.();
3916
3861
  };
3917
3862
  mounts.add(unmount);
3918
3863
  try {
3919
- if (!destroyed) for (const extension of resolved.extensions) stops.push(_optionalChain([extension, 'access', _140 => _140.onMount, 'optionalCall', _141 => _141(editor)]));
3864
+ if (!destroyed) for (const extension of resolved.extensions) stops.push(extension.onMount?.(editor));
3920
3865
  } catch (error) {
3921
3866
  unmount();
3922
3867
  throw error;
@@ -3936,128 +3881,127 @@ function createInternalEditor(options) {
3936
3881
  return editor;
3937
3882
  }
3938
3883
 
3939
-
3940
-
3941
-
3942
-
3943
-
3944
-
3945
-
3946
-
3947
-
3948
-
3949
-
3950
-
3951
-
3952
-
3953
-
3954
-
3955
-
3956
-
3957
-
3958
-
3959
-
3960
-
3961
-
3962
-
3963
-
3964
-
3965
-
3966
-
3967
-
3968
-
3969
-
3970
-
3971
-
3972
-
3973
-
3974
-
3975
-
3976
-
3977
-
3978
-
3979
-
3980
-
3981
-
3982
-
3983
-
3984
-
3985
-
3986
-
3987
-
3988
-
3989
-
3990
-
3991
-
3992
-
3993
-
3994
-
3995
-
3996
-
3997
-
3998
-
3999
-
4000
-
4001
-
4002
-
4003
-
4004
-
4005
-
4006
-
4007
-
4008
-
4009
-
4010
-
4011
-
4012
-
4013
-
4014
-
4015
-
4016
-
4017
-
4018
-
4019
-
4020
-
4021
-
4022
-
4023
-
4024
-
4025
-
4026
-
4027
-
4028
-
4029
-
4030
-
4031
-
4032
-
4033
-
4034
-
4035
-
4036
-
4037
-
4038
-
4039
-
4040
-
4041
-
4042
-
4043
-
4044
-
4045
-
4046
-
4047
-
4048
-
4049
-
4050
-
4051
-
4052
-
4053
-
4054
-
4055
-
4056
-
4057
-
4058
-
4059
-
4060
-
4061
-
4062
- exports.setAttrsStep = setAttrsStep; exports.setIndentStep = setIndentStep; exports.insertBlocksStep = insertBlocksStep; exports.removeBlocksStep = removeBlocksStep; exports.moveBlocksStep = moveBlocksStep; exports.replaceBlockStep = replaceBlockStep; exports.replaceInlineStep = replaceInlineStep; exports.addMarkStep = addMarkStep; exports.removeMarkStep = removeMarkStep; exports.commonPrefix = commonPrefix; exports.commonSuffix = commonSuffix; exports.replaceDocStep = replaceDocStep; exports.splitBlockStep = splitBlockStep; exports.joinBlocksStep = joinBlocksStep; exports.stepFromJSON = stepFromJSON; exports.comparePos = comparePos; exports.orderedRange = orderedRange; exports.textSelection = textSelection; exports.nodeSelection = nodeSelection; exports.blockRangeSelection = blockRangeSelection; exports.isCollapsed = isCollapsed; exports.sameSelection = sameSelection; exports.selectionRange = selectionRange; exports.selectedBlockIds = selectedBlockIds; exports.mapSelection = mapSelection; exports.primaryRegion = primaryRegion; exports.startOf = startOf; exports.endOf = endOf; exports.validateSelection = validateSelection; exports.isClosedToggle = isClosedToggle; exports.hidingToggle = hidingToggle; exports.createState = createState; exports.applyTransaction = applyTransaction; exports.getPluginState = getPluginState; exports.createPluginKey = createPluginKey; exports.Transaction = Transaction; exports.caretMarks = caretMarks; exports.runCommands = runCommands; exports.HISTORY_PROVIDER = HISTORY_PROVIDER; exports.HISTORY_GROUP = HISTORY_GROUP; exports.groupOf = groupOf; exports.undo = undo; exports.redo = redo; exports.undoInputRule = undoInputRule; exports.isTextFlow = isTextFlow; exports.isParagraph = isParagraph; exports.regionLength = regionLength; exports.descendantsEnd = descendantsEnd; exports.createBlock = createBlock; exports.withContent = withContent; exports.headBlockId = headBlockId; exports.selectedBlockRange = selectedBlockRange; exports.capIndents = capIndents; exports.toggleTask = toggleTask; exports.indent = indent; exports.outdent = outdent; exports.moveBlocksUp = moveBlocksUp; exports.moveBlocksDown = moveBlocksDown; exports.duplicateBlocks = duplicateBlocks; exports.deleteBlocks = deleteBlocks; exports.insertBlockAfter = insertBlockAfter; exports.deleteRange = deleteRange; exports.insertTextAt = insertTextAt; exports.insertText = insertText; exports.markExtent = markExtent; exports.markRanges = markRanges; exports.rangeContent = rangeContent; exports.markCoverage = markCoverage; exports.toggleMark = toggleMark; exports.setMark = setMark; exports.unsetMark = unsetMark; exports.setLink = setLink; exports.unsetLink = unsetLink; exports.insertMention = insertMention; exports.setBlockType = setBlockType; exports.insertTextWithRules = insertTextWithRules; exports.blockInputRules = blockInputRules; exports.regionInline = regionInline; exports.markInputRules = markInputRules; exports.typographyRules = typographyRules; exports.fromHTML = fromHTML; exports.toMarkdown = toMarkdown; exports.toHTML = toHTML; exports.toPlainText = toPlainText; exports.graphemeCount = graphemeCount; exports.wordCount = wordCount; exports.nextGraphemeOffset = nextGraphemeOffset; exports.prevGraphemeOffset = prevGraphemeOffset; exports.countBlock = countBlock; exports.countText = countText; exports.countDoc = countDoc; exports.setAttrs = setAttrs; exports.setTextAlign = setTextAlign; exports.setBlockColor = setBlockColor; exports.LINE_JOIN = LINE_JOIN; exports.deleteSelection = deleteSelection; exports.deleteBackward = deleteBackward; exports.deleteForward = deleteForward; exports.deleteWordBackward = deleteWordBackward; exports.deleteWordForward = deleteWordForward; exports.deleteToLineStart = deleteToLineStart; exports.deleteToLineEnd = deleteToLineEnd; exports.insertHardBreak = insertHardBreak; exports.movedBlockIds = movedBlockIds; exports.moveBlocksTo = moveBlocksTo; exports.selectAll = selectAll; exports.setSelection = setSelection; exports.LINE_SPLIT = LINE_SPLIT; exports.freshBlocks = freshBlocks; exports.pasteAtCaret = pasteAtCaret; exports.insertSlice = insertSlice; exports.pastedLink = pastedLink; exports.defineExtension = defineExtension; exports.coreExtensions = coreExtensions; exports.sliceFromSelection = sliceFromSelection; exports.sliceFromClipboard = sliceFromClipboard; exports.isActive = isActive; exports.sameDoc = sameDoc; exports.detectMac = detectMac; exports.normalizeKey = normalizeKey; exports.keyName = keyName; exports.createEditor = createEditor;
4063
- //# sourceMappingURL=chunk-ZKVOS57Q.cjs.map
3884
+ exports.HISTORY_GROUP = HISTORY_GROUP;
3885
+ exports.HISTORY_PROVIDER = HISTORY_PROVIDER;
3886
+ exports.LINE_JOIN = LINE_JOIN;
3887
+ exports.LINE_SPLIT = LINE_SPLIT;
3888
+ exports.Transaction = Transaction;
3889
+ exports.addMarkStep = addMarkStep;
3890
+ exports.applyTransaction = applyTransaction;
3891
+ exports.blockInputRules = blockInputRules;
3892
+ exports.blockRangeSelection = blockRangeSelection;
3893
+ exports.capIndents = capIndents;
3894
+ exports.caretMarks = caretMarks;
3895
+ exports.commonPrefix = commonPrefix;
3896
+ exports.commonSuffix = commonSuffix;
3897
+ exports.comparePos = comparePos;
3898
+ exports.coreExtensions = coreExtensions;
3899
+ exports.countBlock = countBlock;
3900
+ exports.countDoc = countDoc;
3901
+ exports.countText = countText;
3902
+ exports.createBlock = createBlock;
3903
+ exports.createEditor = createEditor;
3904
+ exports.createPluginKey = createPluginKey;
3905
+ exports.createState = createState;
3906
+ exports.defineExtension = defineExtension;
3907
+ exports.deleteBackward = deleteBackward;
3908
+ exports.deleteBlocks = deleteBlocks;
3909
+ exports.deleteForward = deleteForward;
3910
+ exports.deleteRange = deleteRange;
3911
+ exports.deleteSelection = deleteSelection;
3912
+ exports.deleteToLineEnd = deleteToLineEnd;
3913
+ exports.deleteToLineStart = deleteToLineStart;
3914
+ exports.deleteWordBackward = deleteWordBackward;
3915
+ exports.deleteWordForward = deleteWordForward;
3916
+ exports.descendantsEnd = descendantsEnd;
3917
+ exports.detectMac = detectMac;
3918
+ exports.duplicateBlocks = duplicateBlocks;
3919
+ exports.endOf = endOf;
3920
+ exports.freshBlocks = freshBlocks;
3921
+ exports.fromHTML = fromHTML;
3922
+ exports.getPluginState = getPluginState;
3923
+ exports.graphemeCount = graphemeCount;
3924
+ exports.groupOf = groupOf;
3925
+ exports.headBlockId = headBlockId;
3926
+ exports.hidingToggle = hidingToggle;
3927
+ exports.indent = indent;
3928
+ exports.insertBlockAfter = insertBlockAfter;
3929
+ exports.insertBlocksStep = insertBlocksStep;
3930
+ exports.insertHardBreak = insertHardBreak;
3931
+ exports.insertMention = insertMention;
3932
+ exports.insertSlice = insertSlice;
3933
+ exports.insertText = insertText;
3934
+ exports.insertTextAt = insertTextAt;
3935
+ exports.insertTextWithRules = insertTextWithRules;
3936
+ exports.isActive = isActive;
3937
+ exports.isClosedToggle = isClosedToggle;
3938
+ exports.isCollapsed = isCollapsed;
3939
+ exports.isParagraph = isParagraph;
3940
+ exports.isTextFlow = isTextFlow;
3941
+ exports.joinBlocksStep = joinBlocksStep;
3942
+ exports.keyName = keyName;
3943
+ exports.mapSelection = mapSelection;
3944
+ exports.markCoverage = markCoverage;
3945
+ exports.markExtent = markExtent;
3946
+ exports.markInputRules = markInputRules;
3947
+ exports.markRanges = markRanges;
3948
+ exports.moveBlocksDown = moveBlocksDown;
3949
+ exports.moveBlocksStep = moveBlocksStep;
3950
+ exports.moveBlocksTo = moveBlocksTo;
3951
+ exports.moveBlocksUp = moveBlocksUp;
3952
+ exports.movedBlockIds = movedBlockIds;
3953
+ exports.nextGraphemeOffset = nextGraphemeOffset;
3954
+ exports.nodeSelection = nodeSelection;
3955
+ exports.normalizeKey = normalizeKey;
3956
+ exports.orderedRange = orderedRange;
3957
+ exports.outdent = outdent;
3958
+ exports.pasteAtCaret = pasteAtCaret;
3959
+ exports.pastedLink = pastedLink;
3960
+ exports.prevGraphemeOffset = prevGraphemeOffset;
3961
+ exports.primaryRegion = primaryRegion;
3962
+ exports.rangeContent = rangeContent;
3963
+ exports.redo = redo;
3964
+ exports.regionInline = regionInline;
3965
+ exports.regionLength = regionLength;
3966
+ exports.removeBlocksStep = removeBlocksStep;
3967
+ exports.removeMarkStep = removeMarkStep;
3968
+ exports.replaceBlockStep = replaceBlockStep;
3969
+ exports.replaceDocStep = replaceDocStep;
3970
+ exports.replaceInlineStep = replaceInlineStep;
3971
+ exports.runCommands = runCommands;
3972
+ exports.sameDoc = sameDoc;
3973
+ exports.sameSelection = sameSelection;
3974
+ exports.selectAll = selectAll;
3975
+ exports.selectedBlockIds = selectedBlockIds;
3976
+ exports.selectedBlockRange = selectedBlockRange;
3977
+ exports.selectionRange = selectionRange;
3978
+ exports.setAttrs = setAttrs;
3979
+ exports.setAttrsStep = setAttrsStep;
3980
+ exports.setBlockColor = setBlockColor;
3981
+ exports.setBlockType = setBlockType;
3982
+ exports.setIndentStep = setIndentStep;
3983
+ exports.setLink = setLink;
3984
+ exports.setMark = setMark;
3985
+ exports.setSelection = setSelection;
3986
+ exports.setTextAlign = setTextAlign;
3987
+ exports.sliceFromClipboard = sliceFromClipboard;
3988
+ exports.sliceFromSelection = sliceFromSelection;
3989
+ exports.splitBlockStep = splitBlockStep;
3990
+ exports.startOf = startOf;
3991
+ exports.stepFromJSON = stepFromJSON;
3992
+ exports.textSelection = textSelection;
3993
+ exports.toHTML = toHTML;
3994
+ exports.toMarkdown = toMarkdown;
3995
+ exports.toPlainText = toPlainText;
3996
+ exports.toggleMark = toggleMark;
3997
+ exports.toggleTask = toggleTask;
3998
+ exports.typographyRules = typographyRules;
3999
+ exports.undo = undo;
4000
+ exports.undoInputRule = undoInputRule;
4001
+ exports.unsetLink = unsetLink;
4002
+ exports.unsetMark = unsetMark;
4003
+ exports.validateSelection = validateSelection;
4004
+ exports.withContent = withContent;
4005
+ exports.wordCount = wordCount;
4006
+ //# sourceMappingURL=chunk-VFSVN5IQ.cjs.map
4007
+ //# sourceMappingURL=chunk-VFSVN5IQ.cjs.map