zt-react-milkdown 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (174) hide show
  1. package/README.md +149 -0
  2. package/dist/commands-CDrea4WB.cjs +1 -0
  3. package/dist/commands-DoqeX5uJ.js +36 -0
  4. package/dist/debounce-Bqj_3iJs.cjs +1 -0
  5. package/dist/debounce-Cuk3VGPr.js +118 -0
  6. package/dist/dist-BCCSKc3M.cjs +5 -0
  7. package/dist/dist-C0PSMrs7.cjs +37 -0
  8. package/dist/dist-CPVooDwj.cjs +2 -0
  9. package/dist/dist-CxZn1qUo.js +1584 -0
  10. package/dist/dist-Cxaq2crg.js +409 -0
  11. package/dist/dist-DaM7GJv6.js +3499 -0
  12. package/dist/dist-Dhukmh4L.js +7562 -0
  13. package/dist/dist-mOpTMw1E.cjs +1 -0
  14. package/dist/floating-ui.dom-CKbcbmJV.js +883 -0
  15. package/dist/floating-ui.dom-VaZZ2gzS.cjs +1 -0
  16. package/dist/index.browser-5LtNN9G9.cjs +1 -0
  17. package/dist/index.browser-D2DmEB8o.js +26 -0
  18. package/dist/index.cjs +393 -0
  19. package/dist/index.d.ts +1 -0
  20. package/dist/index.mjs +43325 -0
  21. package/dist/lib-38nxOnTd.cjs +4 -0
  22. package/dist/lib-8Tr6mAln.cjs +1 -0
  23. package/dist/lib-B0rHJ9lJ.js +28 -0
  24. package/dist/lib-BJgvZywM.cjs +3 -0
  25. package/dist/lib-BNOSyYeU.cjs +3 -0
  26. package/dist/lib-C5AzmhNY.cjs +5 -0
  27. package/dist/lib-C8xOD1Bp.cjs +1 -0
  28. package/dist/lib-CCUU16r8.js +1081 -0
  29. package/dist/lib-CK9MEMX-.js +73 -0
  30. package/dist/lib-D4HMdvmK.cjs +1 -0
  31. package/dist/lib-DWZA8C0h.cjs +1 -0
  32. package/dist/lib-Dbe-cVjv.js +367 -0
  33. package/dist/lib-DkE7Uq2b.js +1886 -0
  34. package/dist/lib-DzK_kn7a.js +21 -0
  35. package/dist/lib-IahjxPWM.cjs +3 -0
  36. package/dist/lib-m8lKZKxK.js +80 -0
  37. package/dist/lib-r5eNG0sa.js +754 -0
  38. package/dist/lib-wmHesNI0.js +2223 -0
  39. package/dist/rolldown-runtime-CerMd-t8.cjs +1 -0
  40. package/dist/rolldown-runtime-DnwLefa7.js +23 -0
  41. package/dist/schema-list-DSdBEAWW.js +171 -0
  42. package/dist/schema-list-bL8FNes5.cjs +1 -0
  43. package/dist/src/components/ui/button.d.ts +16 -0
  44. package/dist/src/components/ui/button.d.ts.map +1 -0
  45. package/dist/src/components/ui/dialog.d.ts +36 -0
  46. package/dist/src/components/ui/dialog.d.ts.map +1 -0
  47. package/dist/src/components/ui/popover.d.ts +14 -0
  48. package/dist/src/components/ui/popover.d.ts.map +1 -0
  49. package/dist/src/core/commands.d.ts +7 -0
  50. package/dist/src/core/commands.d.ts.map +1 -0
  51. package/dist/src/core/createEditor.d.ts +6 -0
  52. package/dist/src/core/createEditor.d.ts.map +1 -0
  53. package/dist/src/core/schema.d.ts +8 -0
  54. package/dist/src/core/schema.d.ts.map +1 -0
  55. package/dist/src/index.d.ts +4 -0
  56. package/dist/src/index.d.ts.map +1 -0
  57. package/dist/src/lib/editor-overlay-position.d.ts +83 -0
  58. package/dist/src/lib/editor-overlay-position.d.ts.map +1 -0
  59. package/dist/src/lib/global-scroll-listener.d.ts +9 -0
  60. package/dist/src/lib/global-scroll-listener.d.ts.map +1 -0
  61. package/dist/src/lib/utils.d.ts +6 -0
  62. package/dist/src/lib/utils.d.ts.map +1 -0
  63. package/dist/src/local/en-US.d.ts +6 -0
  64. package/dist/src/local/en-US.d.ts.map +1 -0
  65. package/dist/src/local/i18n.d.ts +10 -0
  66. package/dist/src/local/i18n.d.ts.map +1 -0
  67. package/dist/src/local/zh-CN.d.ts +6 -0
  68. package/dist/src/local/zh-CN.d.ts.map +1 -0
  69. package/dist/src/plugins/custom/blockquote/blockquote-backspace-lift.d.ts +5 -0
  70. package/dist/src/plugins/custom/blockquote/blockquote-backspace-lift.d.ts.map +1 -0
  71. package/dist/src/plugins/custom/blockquote/index.d.ts +3 -0
  72. package/dist/src/plugins/custom/blockquote/index.d.ts.map +1 -0
  73. package/dist/src/plugins/custom/code-block/code-block-editable.d.ts +7 -0
  74. package/dist/src/plugins/custom/code-block/code-block-editable.d.ts.map +1 -0
  75. package/dist/src/plugins/custom/code-block/code-block-language-picker.d.ts +7 -0
  76. package/dist/src/plugins/custom/code-block/code-block-language-picker.d.ts.map +1 -0
  77. package/dist/src/plugins/custom/code-block/code-block-mod-a-select.d.ts +5 -0
  78. package/dist/src/plugins/custom/code-block/code-block-mod-a-select.d.ts.map +1 -0
  79. package/dist/src/plugins/custom/code-block/code-block-prism.d.ts +5 -0
  80. package/dist/src/plugins/custom/code-block/code-block-prism.d.ts.map +1 -0
  81. package/dist/src/plugins/custom/code-block/index.d.ts +9 -0
  82. package/dist/src/plugins/custom/code-block/index.d.ts.map +1 -0
  83. package/dist/src/plugins/custom/cursor/drop-cursor.d.ts +5 -0
  84. package/dist/src/plugins/custom/cursor/drop-cursor.d.ts.map +1 -0
  85. package/dist/src/plugins/custom/cursor/gap-cursor.d.ts +5 -0
  86. package/dist/src/plugins/custom/cursor/gap-cursor.d.ts.map +1 -0
  87. package/dist/src/plugins/custom/cursor/index.d.ts +5 -0
  88. package/dist/src/plugins/custom/cursor/index.d.ts.map +1 -0
  89. package/dist/src/plugins/custom/image/image-editable.d.ts +7 -0
  90. package/dist/src/plugins/custom/image/image-editable.d.ts.map +1 -0
  91. package/dist/src/plugins/custom/image/image-resizable-schema.d.ts +41 -0
  92. package/dist/src/plugins/custom/image/image-resizable-schema.d.ts.map +1 -0
  93. package/dist/src/plugins/custom/image/image-upload-dialog/ImageUploadDialog.d.ts +31 -0
  94. package/dist/src/plugins/custom/image/image-upload-dialog/ImageUploadDialog.d.ts.map +1 -0
  95. package/dist/src/plugins/custom/image/image-upload-dialog/index.d.ts +20 -0
  96. package/dist/src/plugins/custom/image/image-upload-dialog/index.d.ts.map +1 -0
  97. package/dist/src/plugins/custom/image/index.d.ts +7 -0
  98. package/dist/src/plugins/custom/image/index.d.ts.map +1 -0
  99. package/dist/src/plugins/custom/indent/index.d.ts +3 -0
  100. package/dist/src/plugins/custom/indent/index.d.ts.map +1 -0
  101. package/dist/src/plugins/custom/indent/tab-space-indent.d.ts +5 -0
  102. package/dist/src/plugins/custom/indent/tab-space-indent.d.ts.map +1 -0
  103. package/dist/src/plugins/custom/list/index.d.ts +3 -0
  104. package/dist/src/plugins/custom/list/index.d.ts.map +1 -0
  105. package/dist/src/plugins/custom/list/task-list-toggle.d.ts +5 -0
  106. package/dist/src/plugins/custom/list/task-list-toggle.d.ts.map +1 -0
  107. package/dist/src/plugins/custom/math/index.d.ts +7 -0
  108. package/dist/src/plugins/custom/math/index.d.ts.map +1 -0
  109. package/dist/src/plugins/custom/math/math-backspace-entry.d.ts +5 -0
  110. package/dist/src/plugins/custom/math/math-backspace-entry.d.ts.map +1 -0
  111. package/dist/src/plugins/custom/math/math-block-editable.d.ts +7 -0
  112. package/dist/src/plugins/custom/math/math-block-editable.d.ts.map +1 -0
  113. package/dist/src/plugins/custom/math/math-plugin.d.ts +47 -0
  114. package/dist/src/plugins/custom/math/math-plugin.d.ts.map +1 -0
  115. package/dist/src/plugins/custom/selection-tooltip/constants.d.ts +7 -0
  116. package/dist/src/plugins/custom/selection-tooltip/constants.d.ts.map +1 -0
  117. package/dist/src/plugins/custom/selection-tooltip/index.d.ts +7 -0
  118. package/dist/src/plugins/custom/selection-tooltip/index.d.ts.map +1 -0
  119. package/dist/src/plugins/custom/selection-tooltip/mark-logic.d.ts +25 -0
  120. package/dist/src/plugins/custom/selection-tooltip/mark-logic.d.ts.map +1 -0
  121. package/dist/src/plugins/custom/selection-tooltip/tooltip-view.d.ts +21 -0
  122. package/dist/src/plugins/custom/selection-tooltip/tooltip-view.d.ts.map +1 -0
  123. package/dist/src/plugins/custom/selection-tooltip/types.d.ts +58 -0
  124. package/dist/src/plugins/custom/selection-tooltip/types.d.ts.map +1 -0
  125. package/dist/src/plugins/custom/slash-menu/index.d.ts +9 -0
  126. package/dist/src/plugins/custom/slash-menu/index.d.ts.map +1 -0
  127. package/dist/src/plugins/custom/slash-menu/slash-menu-commands.d.ts +6 -0
  128. package/dist/src/plugins/custom/slash-menu/slash-menu-commands.d.ts.map +1 -0
  129. package/dist/src/plugins/custom/slash-menu/slash-menu-logic.d.ts +23 -0
  130. package/dist/src/plugins/custom/slash-menu/slash-menu-logic.d.ts.map +1 -0
  131. package/dist/src/plugins/custom/slash-menu/slash-menu-view.d.ts +50 -0
  132. package/dist/src/plugins/custom/slash-menu/slash-menu-view.d.ts.map +1 -0
  133. package/dist/src/plugins/custom/slash-menu/slash-menu.d.ts +15 -0
  134. package/dist/src/plugins/custom/slash-menu/slash-menu.d.ts.map +1 -0
  135. package/dist/src/plugins/custom/table/index.d.ts +13 -0
  136. package/dist/src/plugins/custom/table/index.d.ts.map +1 -0
  137. package/dist/src/plugins/custom/table/table-arrow-entry.d.ts +5 -0
  138. package/dist/src/plugins/custom/table/table-arrow-entry.d.ts.map +1 -0
  139. package/dist/src/plugins/custom/table/table-deletion-actions.d.ts +10 -0
  140. package/dist/src/plugins/custom/table/table-deletion-actions.d.ts.map +1 -0
  141. package/dist/src/plugins/custom/table/table-focus-actions.d.ts +7 -0
  142. package/dist/src/plugins/custom/table/table-focus-actions.d.ts.map +1 -0
  143. package/dist/src/plugins/custom/table/table-more-actions.d.ts +37 -0
  144. package/dist/src/plugins/custom/table/table-more-actions.d.ts.map +1 -0
  145. package/dist/src/plugins/custom/table/table-row-insertion.d.ts +35 -0
  146. package/dist/src/plugins/custom/table/table-row-insertion.d.ts.map +1 -0
  147. package/dist/src/plugins/custom/table/table-selection.d.ts +30 -0
  148. package/dist/src/plugins/custom/table/table-selection.d.ts.map +1 -0
  149. package/dist/src/plugins/preset-common.d.ts +56 -0
  150. package/dist/src/plugins/preset-common.d.ts.map +1 -0
  151. package/dist/src/react/components/MilkdownEditor.d.ts +7 -0
  152. package/dist/src/react/components/MilkdownEditor.d.ts.map +1 -0
  153. package/dist/src/react/components/index.d.ts +2 -0
  154. package/dist/src/react/components/index.d.ts.map +1 -0
  155. package/dist/src/react/context/EditorContext.d.ts +16 -0
  156. package/dist/src/react/context/EditorContext.d.ts.map +1 -0
  157. package/dist/src/react/hooks/useCloseOnGlobalScroll.d.ts +5 -0
  158. package/dist/src/react/hooks/useCloseOnGlobalScroll.d.ts.map +1 -0
  159. package/dist/src/react/hooks/useControlledState.d.ts +9 -0
  160. package/dist/src/react/hooks/useControlledState.d.ts.map +1 -0
  161. package/dist/src/react/hooks/useMilkdownEditor.d.ts +35 -0
  162. package/dist/src/react/hooks/useMilkdownEditor.d.ts.map +1 -0
  163. package/dist/src/types/editor.d.ts +233 -0
  164. package/dist/src/types/editor.d.ts.map +1 -0
  165. package/dist/src/types/plugin.d.ts +10 -0
  166. package/dist/src/types/plugin.d.ts.map +1 -0
  167. package/dist/src/utils/guard.d.ts +5 -0
  168. package/dist/src/utils/guard.d.ts.map +1 -0
  169. package/dist/src/utils/markdown.d.ts +9 -0
  170. package/dist/src/utils/markdown.d.ts.map +1 -0
  171. package/dist/state-CHAiIqOA.cjs +1 -0
  172. package/dist/state-DNxqltZl.js +16 -0
  173. package/dist/style.css +3 -0
  174. package/package.json +89 -0
@@ -0,0 +1,3499 @@
1
+ //#region node_modules/.pnpm/orderedmap@2.1.1/node_modules/orderedmap/dist/index.js
2
+ function e(e) {
3
+ this.content = e;
4
+ }
5
+ e.prototype = {
6
+ constructor: e,
7
+ find: function(e) {
8
+ for (var t = 0; t < this.content.length; t += 2) if (this.content[t] === e) return t;
9
+ return -1;
10
+ },
11
+ get: function(e) {
12
+ var t = this.find(e);
13
+ return t == -1 ? void 0 : this.content[t + 1];
14
+ },
15
+ update: function(t, n, r) {
16
+ var i = r && r != t ? this.remove(r) : this, a = i.find(t), o = i.content.slice();
17
+ return a == -1 ? o.push(r || t, n) : (o[a + 1] = n, r && (o[a] = r)), new e(o);
18
+ },
19
+ remove: function(t) {
20
+ var n = this.find(t);
21
+ if (n == -1) return this;
22
+ var r = this.content.slice();
23
+ return r.splice(n, 2), new e(r);
24
+ },
25
+ addToStart: function(t, n) {
26
+ return new e([t, n].concat(this.remove(t).content));
27
+ },
28
+ addToEnd: function(t, n) {
29
+ var r = this.remove(t).content.slice();
30
+ return r.push(t, n), new e(r);
31
+ },
32
+ addBefore: function(t, n, r) {
33
+ var i = this.remove(n), a = i.content.slice(), o = i.find(t);
34
+ return a.splice(o == -1 ? a.length : o, 0, n, r), new e(a);
35
+ },
36
+ forEach: function(e) {
37
+ for (var t = 0; t < this.content.length; t += 2) e(this.content[t], this.content[t + 1]);
38
+ },
39
+ prepend: function(t) {
40
+ return t = e.from(t), t.size ? new e(t.content.concat(this.subtract(t).content)) : this;
41
+ },
42
+ append: function(t) {
43
+ return t = e.from(t), t.size ? new e(this.subtract(t).content.concat(t.content)) : this;
44
+ },
45
+ subtract: function(t) {
46
+ var n = this;
47
+ t = e.from(t);
48
+ for (var r = 0; r < t.content.length; r += 2) n = n.remove(t.content[r]);
49
+ return n;
50
+ },
51
+ toObject: function() {
52
+ var e = {};
53
+ return this.forEach(function(t, n) {
54
+ e[t] = n;
55
+ }), e;
56
+ },
57
+ get size() {
58
+ return this.content.length >> 1;
59
+ }
60
+ }, e.from = function(t) {
61
+ if (t instanceof e) return t;
62
+ var n = [];
63
+ if (t) for (var r in t) n.push(r, t[r]);
64
+ return new e(n);
65
+ };
66
+ //#endregion
67
+ //#region node_modules/.pnpm/prosemirror-model@1.25.4/node_modules/prosemirror-model/dist/index.js
68
+ function t(e, n, r) {
69
+ for (let i = 0;; i++) {
70
+ if (i == e.childCount || i == n.childCount) return e.childCount == n.childCount ? null : r;
71
+ let a = e.child(i), o = n.child(i);
72
+ if (a == o) {
73
+ r += a.nodeSize;
74
+ continue;
75
+ }
76
+ if (!a.sameMarkup(o)) return r;
77
+ if (a.isText && a.text != o.text) {
78
+ for (let e = 0; a.text[e] == o.text[e]; e++) r++;
79
+ return r;
80
+ }
81
+ if (a.content.size || o.content.size) {
82
+ let e = t(a.content, o.content, r + 1);
83
+ if (e != null) return e;
84
+ }
85
+ r += a.nodeSize;
86
+ }
87
+ }
88
+ function n(e, t, r, i) {
89
+ for (let a = e.childCount, o = t.childCount;;) {
90
+ if (a == 0 || o == 0) return a == o ? null : {
91
+ a: r,
92
+ b: i
93
+ };
94
+ let s = e.child(--a), c = t.child(--o), l = s.nodeSize;
95
+ if (s == c) {
96
+ r -= l, i -= l;
97
+ continue;
98
+ }
99
+ if (!s.sameMarkup(c)) return {
100
+ a: r,
101
+ b: i
102
+ };
103
+ if (s.isText && s.text != c.text) {
104
+ let e = 0, t = Math.min(s.text.length, c.text.length);
105
+ for (; e < t && s.text[s.text.length - e - 1] == c.text[c.text.length - e - 1];) e++, r--, i--;
106
+ return {
107
+ a: r,
108
+ b: i
109
+ };
110
+ }
111
+ if (s.content.size || c.content.size) {
112
+ let e = n(s.content, c.content, r - 1, i - 1);
113
+ if (e) return e;
114
+ }
115
+ r -= l, i -= l;
116
+ }
117
+ }
118
+ var r = class e {
119
+ constructor(e, t) {
120
+ if (this.content = e, this.size = t || 0, t == null) for (let t = 0; t < e.length; t++) this.size += e[t].nodeSize;
121
+ }
122
+ nodesBetween(e, t, n, r = 0, i) {
123
+ for (let a = 0, o = 0; o < t; a++) {
124
+ let s = this.content[a], c = o + s.nodeSize;
125
+ if (c > e && n(s, r + o, i || null, a) !== !1 && s.content.size) {
126
+ let i = o + 1;
127
+ s.nodesBetween(Math.max(0, e - i), Math.min(s.content.size, t - i), n, r + i);
128
+ }
129
+ o = c;
130
+ }
131
+ }
132
+ descendants(e) {
133
+ this.nodesBetween(0, this.size, e);
134
+ }
135
+ textBetween(e, t, n, r) {
136
+ let i = "", a = !0;
137
+ return this.nodesBetween(e, t, (o, s) => {
138
+ let c = o.isText ? o.text.slice(Math.max(e, s) - s, t - s) : o.isLeaf ? r ? typeof r == "function" ? r(o) : r : o.type.spec.leafText ? o.type.spec.leafText(o) : "" : "";
139
+ o.isBlock && (o.isLeaf && c || o.isTextblock) && n && (a ? a = !1 : i += n), i += c;
140
+ }, 0), i;
141
+ }
142
+ append(t) {
143
+ if (!t.size) return this;
144
+ if (!this.size) return t;
145
+ let n = this.lastChild, r = t.firstChild, i = this.content.slice(), a = 0;
146
+ for (n.isText && n.sameMarkup(r) && (i[i.length - 1] = n.withText(n.text + r.text), a = 1); a < t.content.length; a++) i.push(t.content[a]);
147
+ return new e(i, this.size + t.size);
148
+ }
149
+ cut(t, n = this.size) {
150
+ if (t == 0 && n == this.size) return this;
151
+ let r = [], i = 0;
152
+ if (n > t) for (let e = 0, a = 0; a < n; e++) {
153
+ let o = this.content[e], s = a + o.nodeSize;
154
+ s > t && ((a < t || s > n) && (o = o.isText ? o.cut(Math.max(0, t - a), Math.min(o.text.length, n - a)) : o.cut(Math.max(0, t - a - 1), Math.min(o.content.size, n - a - 1))), r.push(o), i += o.nodeSize), a = s;
155
+ }
156
+ return new e(r, i);
157
+ }
158
+ cutByIndex(t, n) {
159
+ return t == n ? e.empty : t == 0 && n == this.content.length ? this : new e(this.content.slice(t, n));
160
+ }
161
+ replaceChild(t, n) {
162
+ let r = this.content[t];
163
+ if (r == n) return this;
164
+ let i = this.content.slice(), a = this.size + n.nodeSize - r.nodeSize;
165
+ return i[t] = n, new e(i, a);
166
+ }
167
+ addToStart(t) {
168
+ return new e([t].concat(this.content), this.size + t.nodeSize);
169
+ }
170
+ addToEnd(t) {
171
+ return new e(this.content.concat(t), this.size + t.nodeSize);
172
+ }
173
+ eq(e) {
174
+ if (this.content.length != e.content.length) return !1;
175
+ for (let t = 0; t < this.content.length; t++) if (!this.content[t].eq(e.content[t])) return !1;
176
+ return !0;
177
+ }
178
+ get firstChild() {
179
+ return this.content.length ? this.content[0] : null;
180
+ }
181
+ get lastChild() {
182
+ return this.content.length ? this.content[this.content.length - 1] : null;
183
+ }
184
+ get childCount() {
185
+ return this.content.length;
186
+ }
187
+ child(e) {
188
+ let t = this.content[e];
189
+ if (!t) throw RangeError("Index " + e + " out of range for " + this);
190
+ return t;
191
+ }
192
+ maybeChild(e) {
193
+ return this.content[e] || null;
194
+ }
195
+ forEach(e) {
196
+ for (let t = 0, n = 0; t < this.content.length; t++) {
197
+ let r = this.content[t];
198
+ e(r, n, t), n += r.nodeSize;
199
+ }
200
+ }
201
+ findDiffStart(e, n = 0) {
202
+ return t(this, e, n);
203
+ }
204
+ findDiffEnd(e, t = this.size, r = e.size) {
205
+ return n(this, e, t, r);
206
+ }
207
+ findIndex(e) {
208
+ if (e == 0) return a(0, e);
209
+ if (e == this.size) return a(this.content.length, e);
210
+ if (e > this.size || e < 0) throw RangeError(`Position ${e} outside of fragment (${this})`);
211
+ for (let t = 0, n = 0;; t++) {
212
+ let r = this.child(t), i = n + r.nodeSize;
213
+ if (i >= e) return i == e ? a(t + 1, i) : a(t, n);
214
+ n = i;
215
+ }
216
+ }
217
+ toString() {
218
+ return "<" + this.toStringInner() + ">";
219
+ }
220
+ toStringInner() {
221
+ return this.content.join(", ");
222
+ }
223
+ toJSON() {
224
+ return this.content.length ? this.content.map((e) => e.toJSON()) : null;
225
+ }
226
+ static fromJSON(t, n) {
227
+ if (!n) return e.empty;
228
+ if (!Array.isArray(n)) throw RangeError("Invalid input for Fragment.fromJSON");
229
+ return new e(n.map(t.nodeFromJSON));
230
+ }
231
+ static fromArray(t) {
232
+ if (!t.length) return e.empty;
233
+ let n, r = 0;
234
+ for (let e = 0; e < t.length; e++) {
235
+ let i = t[e];
236
+ r += i.nodeSize, e && i.isText && t[e - 1].sameMarkup(i) ? (n ||= t.slice(0, e), n[n.length - 1] = i.withText(n[n.length - 1].text + i.text)) : n && n.push(i);
237
+ }
238
+ return new e(n || t, r);
239
+ }
240
+ static from(t) {
241
+ if (!t) return e.empty;
242
+ if (t instanceof e) return t;
243
+ if (Array.isArray(t)) return this.fromArray(t);
244
+ if (t.attrs) return new e([t], t.nodeSize);
245
+ throw RangeError("Can not convert " + t + " to a Fragment" + (t.nodesBetween ? " (looks like multiple versions of prosemirror-model were loaded)" : ""));
246
+ }
247
+ };
248
+ r.empty = new r([], 0);
249
+ var i = {
250
+ index: 0,
251
+ offset: 0
252
+ };
253
+ function a(e, t) {
254
+ return i.index = e, i.offset = t, i;
255
+ }
256
+ function o(e, t) {
257
+ if (e === t) return !0;
258
+ if (!(e && typeof e == "object") || !(t && typeof t == "object")) return !1;
259
+ let n = Array.isArray(e);
260
+ if (Array.isArray(t) != n) return !1;
261
+ if (n) {
262
+ if (e.length != t.length) return !1;
263
+ for (let n = 0; n < e.length; n++) if (!o(e[n], t[n])) return !1;
264
+ } else {
265
+ for (let n in e) if (!(n in t) || !o(e[n], t[n])) return !1;
266
+ for (let n in t) if (!(n in e)) return !1;
267
+ }
268
+ return !0;
269
+ }
270
+ var s = class e {
271
+ constructor(e, t) {
272
+ this.type = e, this.attrs = t;
273
+ }
274
+ addToSet(e) {
275
+ let t, n = !1;
276
+ for (let r = 0; r < e.length; r++) {
277
+ let i = e[r];
278
+ if (this.eq(i)) return e;
279
+ if (this.type.excludes(i.type)) t ||= e.slice(0, r);
280
+ else if (i.type.excludes(this.type)) return e;
281
+ else !n && i.type.rank > this.type.rank && (t ||= e.slice(0, r), t.push(this), n = !0), t && t.push(i);
282
+ }
283
+ return t ||= e.slice(), n || t.push(this), t;
284
+ }
285
+ removeFromSet(e) {
286
+ for (let t = 0; t < e.length; t++) if (this.eq(e[t])) return e.slice(0, t).concat(e.slice(t + 1));
287
+ return e;
288
+ }
289
+ isInSet(e) {
290
+ for (let t = 0; t < e.length; t++) if (this.eq(e[t])) return !0;
291
+ return !1;
292
+ }
293
+ eq(e) {
294
+ return this == e || this.type == e.type && o(this.attrs, e.attrs);
295
+ }
296
+ toJSON() {
297
+ let e = { type: this.type.name };
298
+ for (let t in this.attrs) {
299
+ e.attrs = this.attrs;
300
+ break;
301
+ }
302
+ return e;
303
+ }
304
+ static fromJSON(e, t) {
305
+ if (!t) throw RangeError("Invalid input for Mark.fromJSON");
306
+ let n = e.marks[t.type];
307
+ if (!n) throw RangeError(`There is no mark type ${t.type} in this schema`);
308
+ let r = n.create(t.attrs);
309
+ return n.checkAttrs(r.attrs), r;
310
+ }
311
+ static sameSet(e, t) {
312
+ if (e == t) return !0;
313
+ if (e.length != t.length) return !1;
314
+ for (let n = 0; n < e.length; n++) if (!e[n].eq(t[n])) return !1;
315
+ return !0;
316
+ }
317
+ static setFrom(t) {
318
+ if (!t || Array.isArray(t) && t.length == 0) return e.none;
319
+ if (t instanceof e) return [t];
320
+ let n = t.slice();
321
+ return n.sort((e, t) => e.type.rank - t.type.rank), n;
322
+ }
323
+ };
324
+ s.none = [];
325
+ var c = class extends Error {}, l = class e {
326
+ constructor(e, t, n) {
327
+ this.content = e, this.openStart = t, this.openEnd = n;
328
+ }
329
+ get size() {
330
+ return this.content.size - this.openStart - this.openEnd;
331
+ }
332
+ insertAt(t, n) {
333
+ let r = d(this.content, t + this.openStart, n);
334
+ return r && new e(r, this.openStart, this.openEnd);
335
+ }
336
+ removeBetween(t, n) {
337
+ return new e(u(this.content, t + this.openStart, n + this.openStart), this.openStart, this.openEnd);
338
+ }
339
+ eq(e) {
340
+ return this.content.eq(e.content) && this.openStart == e.openStart && this.openEnd == e.openEnd;
341
+ }
342
+ toString() {
343
+ return this.content + "(" + this.openStart + "," + this.openEnd + ")";
344
+ }
345
+ toJSON() {
346
+ if (!this.content.size) return null;
347
+ let e = { content: this.content.toJSON() };
348
+ return this.openStart > 0 && (e.openStart = this.openStart), this.openEnd > 0 && (e.openEnd = this.openEnd), e;
349
+ }
350
+ static fromJSON(t, n) {
351
+ if (!n) return e.empty;
352
+ let i = n.openStart || 0, a = n.openEnd || 0;
353
+ if (typeof i != "number" || typeof a != "number") throw RangeError("Invalid input for Slice.fromJSON");
354
+ return new e(r.fromJSON(t, n.content), i, a);
355
+ }
356
+ static maxOpen(t, n = !0) {
357
+ let r = 0, i = 0;
358
+ for (let e = t.firstChild; e && !e.isLeaf && (n || !e.type.spec.isolating); e = e.firstChild) r++;
359
+ for (let e = t.lastChild; e && !e.isLeaf && (n || !e.type.spec.isolating); e = e.lastChild) i++;
360
+ return new e(t, r, i);
361
+ }
362
+ };
363
+ l.empty = new l(r.empty, 0, 0);
364
+ function u(e, t, n) {
365
+ let { index: r, offset: i } = e.findIndex(t), a = e.maybeChild(r), { index: o, offset: s } = e.findIndex(n);
366
+ if (i == t || a.isText) {
367
+ if (s != n && !e.child(o).isText) throw RangeError("Removing non-flat range");
368
+ return e.cut(0, t).append(e.cut(n));
369
+ }
370
+ if (r != o) throw RangeError("Removing non-flat range");
371
+ return e.replaceChild(r, a.copy(u(a.content, t - i - 1, n - i - 1)));
372
+ }
373
+ function d(e, t, n, r) {
374
+ let { index: i, offset: a } = e.findIndex(t), o = e.maybeChild(i);
375
+ if (a == t || o.isText) return r && !r.canReplace(i, i, n) ? null : e.cut(0, t).append(n).append(e.cut(t));
376
+ let s = d(o.content, t - a - 1, n, o);
377
+ return s && e.replaceChild(i, o.copy(s));
378
+ }
379
+ function f(e, t, n) {
380
+ if (n.openStart > e.depth) throw new c("Inserted content deeper than insertion position");
381
+ if (e.depth - n.openStart != t.depth - n.openEnd) throw new c("Inconsistent open depths");
382
+ return p(e, t, n, 0);
383
+ }
384
+ function p(e, t, n, r) {
385
+ let i = e.index(r), a = e.node(r);
386
+ if (i == t.index(r) && r < e.depth - n.openStart) {
387
+ let o = p(e, t, n, r + 1);
388
+ return a.copy(a.content.replaceChild(i, o));
389
+ } else if (!n.content.size) return v(a, y(e, t, r));
390
+ else if (!n.openStart && !n.openEnd && e.depth == r && t.depth == r) {
391
+ let r = e.parent, i = r.content;
392
+ return v(r, i.cut(0, e.parentOffset).append(n.content).append(i.cut(t.parentOffset)));
393
+ } else {
394
+ let { start: i, end: o } = te(n, e);
395
+ return v(a, ee(e, i, o, t, r));
396
+ }
397
+ }
398
+ function m(e, t) {
399
+ if (!t.type.compatibleContent(e.type)) throw new c("Cannot join " + t.type.name + " onto " + e.type.name);
400
+ }
401
+ function h(e, t, n) {
402
+ let r = e.node(n);
403
+ return m(r, t.node(n)), r;
404
+ }
405
+ function g(e, t) {
406
+ let n = t.length - 1;
407
+ n >= 0 && e.isText && e.sameMarkup(t[n]) ? t[n] = e.withText(t[n].text + e.text) : t.push(e);
408
+ }
409
+ function _(e, t, n, r) {
410
+ let i = (t || e).node(n), a = 0, o = t ? t.index(n) : i.childCount;
411
+ e && (a = e.index(n), e.depth > n ? a++ : e.textOffset && (g(e.nodeAfter, r), a++));
412
+ for (let e = a; e < o; e++) g(i.child(e), r);
413
+ t && t.depth == n && t.textOffset && g(t.nodeBefore, r);
414
+ }
415
+ function v(e, t) {
416
+ return e.type.checkContent(t), e.copy(t);
417
+ }
418
+ function ee(e, t, n, i, a) {
419
+ let o = e.depth > a && h(e, t, a + 1), s = i.depth > a && h(n, i, a + 1), c = [];
420
+ return _(null, e, a, c), o && s && t.index(a) == n.index(a) ? (m(o, s), g(v(o, ee(e, t, n, i, a + 1)), c)) : (o && g(v(o, y(e, t, a + 1)), c), _(t, n, a, c), s && g(v(s, y(n, i, a + 1)), c)), _(i, null, a, c), new r(c);
421
+ }
422
+ function y(e, t, n) {
423
+ let i = [];
424
+ return _(null, e, n, i), e.depth > n && g(v(h(e, t, n + 1), y(e, t, n + 1)), i), _(t, null, n, i), new r(i);
425
+ }
426
+ function te(e, t) {
427
+ let n = t.depth - e.openStart, i = t.node(n).copy(e.content);
428
+ for (let e = n - 1; e >= 0; e--) i = t.node(e).copy(r.from(i));
429
+ return {
430
+ start: i.resolveNoCache(e.openStart + n),
431
+ end: i.resolveNoCache(i.content.size - e.openEnd - n)
432
+ };
433
+ }
434
+ var ne = class e {
435
+ constructor(e, t, n) {
436
+ this.pos = e, this.path = t, this.parentOffset = n, this.depth = t.length / 3 - 1;
437
+ }
438
+ resolveDepth(e) {
439
+ return e == null ? this.depth : e < 0 ? this.depth + e : e;
440
+ }
441
+ get parent() {
442
+ return this.node(this.depth);
443
+ }
444
+ get doc() {
445
+ return this.node(0);
446
+ }
447
+ node(e) {
448
+ return this.path[this.resolveDepth(e) * 3];
449
+ }
450
+ index(e) {
451
+ return this.path[this.resolveDepth(e) * 3 + 1];
452
+ }
453
+ indexAfter(e) {
454
+ return e = this.resolveDepth(e), this.index(e) + (e == this.depth && !this.textOffset ? 0 : 1);
455
+ }
456
+ start(e) {
457
+ return e = this.resolveDepth(e), e == 0 ? 0 : this.path[e * 3 - 1] + 1;
458
+ }
459
+ end(e) {
460
+ return e = this.resolveDepth(e), this.start(e) + this.node(e).content.size;
461
+ }
462
+ before(e) {
463
+ if (e = this.resolveDepth(e), !e) throw RangeError("There is no position before the top-level node");
464
+ return e == this.depth + 1 ? this.pos : this.path[e * 3 - 1];
465
+ }
466
+ after(e) {
467
+ if (e = this.resolveDepth(e), !e) throw RangeError("There is no position after the top-level node");
468
+ return e == this.depth + 1 ? this.pos : this.path[e * 3 - 1] + this.path[e * 3].nodeSize;
469
+ }
470
+ get textOffset() {
471
+ return this.pos - this.path[this.path.length - 1];
472
+ }
473
+ get nodeAfter() {
474
+ let e = this.parent, t = this.index(this.depth);
475
+ if (t == e.childCount) return null;
476
+ let n = this.pos - this.path[this.path.length - 1], r = e.child(t);
477
+ return n ? e.child(t).cut(n) : r;
478
+ }
479
+ get nodeBefore() {
480
+ let e = this.index(this.depth), t = this.pos - this.path[this.path.length - 1];
481
+ return t ? this.parent.child(e).cut(0, t) : e == 0 ? null : this.parent.child(e - 1);
482
+ }
483
+ posAtIndex(e, t) {
484
+ t = this.resolveDepth(t);
485
+ let n = this.path[t * 3], r = t == 0 ? 0 : this.path[t * 3 - 1] + 1;
486
+ for (let t = 0; t < e; t++) r += n.child(t).nodeSize;
487
+ return r;
488
+ }
489
+ marks() {
490
+ let e = this.parent, t = this.index();
491
+ if (e.content.size == 0) return s.none;
492
+ if (this.textOffset) return e.child(t).marks;
493
+ let n = e.maybeChild(t - 1), r = e.maybeChild(t);
494
+ if (!n) {
495
+ let e = n;
496
+ n = r, r = e;
497
+ }
498
+ let i = n.marks;
499
+ for (var a = 0; a < i.length; a++) i[a].type.spec.inclusive === !1 && (!r || !i[a].isInSet(r.marks)) && (i = i[a--].removeFromSet(i));
500
+ return i;
501
+ }
502
+ marksAcross(e) {
503
+ let t = this.parent.maybeChild(this.index());
504
+ if (!t || !t.isInline) return null;
505
+ let n = t.marks, r = e.parent.maybeChild(e.index());
506
+ for (var i = 0; i < n.length; i++) n[i].type.spec.inclusive === !1 && (!r || !n[i].isInSet(r.marks)) && (n = n[i--].removeFromSet(n));
507
+ return n;
508
+ }
509
+ sharedDepth(e) {
510
+ for (let t = this.depth; t > 0; t--) if (this.start(t) <= e && this.end(t) >= e) return t;
511
+ return 0;
512
+ }
513
+ blockRange(e = this, t) {
514
+ if (e.pos < this.pos) return e.blockRange(this);
515
+ for (let n = this.depth - (this.parent.inlineContent || this.pos == e.pos ? 1 : 0); n >= 0; n--) if (e.pos <= this.end(n) && (!t || t(this.node(n)))) return new oe(this, e, n);
516
+ return null;
517
+ }
518
+ sameParent(e) {
519
+ return this.pos - this.parentOffset == e.pos - e.parentOffset;
520
+ }
521
+ max(e) {
522
+ return e.pos > this.pos ? e : this;
523
+ }
524
+ min(e) {
525
+ return e.pos < this.pos ? e : this;
526
+ }
527
+ toString() {
528
+ let e = "";
529
+ for (let t = 1; t <= this.depth; t++) e += (e ? "/" : "") + this.node(t).type.name + "_" + this.index(t - 1);
530
+ return e + ":" + this.parentOffset;
531
+ }
532
+ static resolve(t, n) {
533
+ if (!(n >= 0 && n <= t.content.size)) throw RangeError("Position " + n + " out of range");
534
+ let r = [], i = 0, a = n;
535
+ for (let e = t;;) {
536
+ let { index: t, offset: n } = e.content.findIndex(a), o = a - n;
537
+ if (r.push(e, t, i + n), !o || (e = e.child(t), e.isText)) break;
538
+ a = o - 1, i += n + 1;
539
+ }
540
+ return new e(n, r, a);
541
+ }
542
+ static resolveCached(t, n) {
543
+ let r = ae.get(t);
544
+ if (r) for (let e = 0; e < r.elts.length; e++) {
545
+ let t = r.elts[e];
546
+ if (t.pos == n) return t;
547
+ }
548
+ else ae.set(t, r = new re());
549
+ let i = r.elts[r.i] = e.resolve(t, n);
550
+ return r.i = (r.i + 1) % ie, i;
551
+ }
552
+ }, re = class {
553
+ constructor() {
554
+ this.elts = [], this.i = 0;
555
+ }
556
+ }, ie = 12, ae = /* @__PURE__ */ new WeakMap(), oe = class {
557
+ constructor(e, t, n) {
558
+ this.$from = e, this.$to = t, this.depth = n;
559
+ }
560
+ get start() {
561
+ return this.$from.before(this.depth + 1);
562
+ }
563
+ get end() {
564
+ return this.$to.after(this.depth + 1);
565
+ }
566
+ get parent() {
567
+ return this.$from.node(this.depth);
568
+ }
569
+ get startIndex() {
570
+ return this.$from.index(this.depth);
571
+ }
572
+ get endIndex() {
573
+ return this.$to.indexAfter(this.depth);
574
+ }
575
+ }, se = Object.create(null), b = class e {
576
+ constructor(e, t, n, i = s.none) {
577
+ this.type = e, this.attrs = t, this.marks = i, this.content = n || r.empty;
578
+ }
579
+ get children() {
580
+ return this.content.content;
581
+ }
582
+ get nodeSize() {
583
+ return this.isLeaf ? 1 : 2 + this.content.size;
584
+ }
585
+ get childCount() {
586
+ return this.content.childCount;
587
+ }
588
+ child(e) {
589
+ return this.content.child(e);
590
+ }
591
+ maybeChild(e) {
592
+ return this.content.maybeChild(e);
593
+ }
594
+ forEach(e) {
595
+ this.content.forEach(e);
596
+ }
597
+ nodesBetween(e, t, n, r = 0) {
598
+ this.content.nodesBetween(e, t, n, r, this);
599
+ }
600
+ descendants(e) {
601
+ this.nodesBetween(0, this.content.size, e);
602
+ }
603
+ get textContent() {
604
+ return this.isLeaf && this.type.spec.leafText ? this.type.spec.leafText(this) : this.textBetween(0, this.content.size, "");
605
+ }
606
+ textBetween(e, t, n, r) {
607
+ return this.content.textBetween(e, t, n, r);
608
+ }
609
+ get firstChild() {
610
+ return this.content.firstChild;
611
+ }
612
+ get lastChild() {
613
+ return this.content.lastChild;
614
+ }
615
+ eq(e) {
616
+ return this == e || this.sameMarkup(e) && this.content.eq(e.content);
617
+ }
618
+ sameMarkup(e) {
619
+ return this.hasMarkup(e.type, e.attrs, e.marks);
620
+ }
621
+ hasMarkup(e, t, n) {
622
+ return this.type == e && o(this.attrs, t || e.defaultAttrs || se) && s.sameSet(this.marks, n || s.none);
623
+ }
624
+ copy(t = null) {
625
+ return t == this.content ? this : new e(this.type, this.attrs, t, this.marks);
626
+ }
627
+ mark(t) {
628
+ return t == this.marks ? this : new e(this.type, this.attrs, this.content, t);
629
+ }
630
+ cut(e, t = this.content.size) {
631
+ return e == 0 && t == this.content.size ? this : this.copy(this.content.cut(e, t));
632
+ }
633
+ slice(e, t = this.content.size, n = !1) {
634
+ if (e == t) return l.empty;
635
+ let r = this.resolve(e), i = this.resolve(t), a = n ? 0 : r.sharedDepth(t), o = r.start(a);
636
+ return new l(r.node(a).content.cut(r.pos - o, i.pos - o), r.depth - a, i.depth - a);
637
+ }
638
+ replace(e, t, n) {
639
+ return f(this.resolve(e), this.resolve(t), n);
640
+ }
641
+ nodeAt(e) {
642
+ for (let t = this;;) {
643
+ let { index: n, offset: r } = t.content.findIndex(e);
644
+ if (t = t.maybeChild(n), !t) return null;
645
+ if (r == e || t.isText) return t;
646
+ e -= r + 1;
647
+ }
648
+ }
649
+ childAfter(e) {
650
+ let { index: t, offset: n } = this.content.findIndex(e);
651
+ return {
652
+ node: this.content.maybeChild(t),
653
+ index: t,
654
+ offset: n
655
+ };
656
+ }
657
+ childBefore(e) {
658
+ if (e == 0) return {
659
+ node: null,
660
+ index: 0,
661
+ offset: 0
662
+ };
663
+ let { index: t, offset: n } = this.content.findIndex(e);
664
+ if (n < e) return {
665
+ node: this.content.child(t),
666
+ index: t,
667
+ offset: n
668
+ };
669
+ let r = this.content.child(t - 1);
670
+ return {
671
+ node: r,
672
+ index: t - 1,
673
+ offset: n - r.nodeSize
674
+ };
675
+ }
676
+ resolve(e) {
677
+ return ne.resolveCached(this, e);
678
+ }
679
+ resolveNoCache(e) {
680
+ return ne.resolve(this, e);
681
+ }
682
+ rangeHasMark(e, t, n) {
683
+ let r = !1;
684
+ return t > e && this.nodesBetween(e, t, (e) => (n.isInSet(e.marks) && (r = !0), !r)), r;
685
+ }
686
+ get isBlock() {
687
+ return this.type.isBlock;
688
+ }
689
+ get isTextblock() {
690
+ return this.type.isTextblock;
691
+ }
692
+ get inlineContent() {
693
+ return this.type.inlineContent;
694
+ }
695
+ get isInline() {
696
+ return this.type.isInline;
697
+ }
698
+ get isText() {
699
+ return this.type.isText;
700
+ }
701
+ get isLeaf() {
702
+ return this.type.isLeaf;
703
+ }
704
+ get isAtom() {
705
+ return this.type.isAtom;
706
+ }
707
+ toString() {
708
+ if (this.type.spec.toDebugString) return this.type.spec.toDebugString(this);
709
+ let e = this.type.name;
710
+ return this.content.size && (e += "(" + this.content.toStringInner() + ")"), le(this.marks, e);
711
+ }
712
+ contentMatchAt(e) {
713
+ let t = this.type.contentMatch.matchFragment(this.content, 0, e);
714
+ if (!t) throw Error("Called contentMatchAt on a node with invalid content");
715
+ return t;
716
+ }
717
+ canReplace(e, t, n = r.empty, i = 0, a = n.childCount) {
718
+ let o = this.contentMatchAt(e).matchFragment(n, i, a), s = o && o.matchFragment(this.content, t);
719
+ if (!s || !s.validEnd) return !1;
720
+ for (let e = i; e < a; e++) if (!this.type.allowsMarks(n.child(e).marks)) return !1;
721
+ return !0;
722
+ }
723
+ canReplaceWith(e, t, n, r) {
724
+ if (r && !this.type.allowsMarks(r)) return !1;
725
+ let i = this.contentMatchAt(e).matchType(n), a = i && i.matchFragment(this.content, t);
726
+ return a ? a.validEnd : !1;
727
+ }
728
+ canAppend(e) {
729
+ return e.content.size ? this.canReplace(this.childCount, this.childCount, e.content) : this.type.compatibleContent(e.type);
730
+ }
731
+ check() {
732
+ this.type.checkContent(this.content), this.type.checkAttrs(this.attrs);
733
+ let e = s.none;
734
+ for (let t = 0; t < this.marks.length; t++) {
735
+ let n = this.marks[t];
736
+ n.type.checkAttrs(n.attrs), e = n.addToSet(e);
737
+ }
738
+ if (!s.sameSet(e, this.marks)) throw RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map((e) => e.type.name)}`);
739
+ this.content.forEach((e) => e.check());
740
+ }
741
+ toJSON() {
742
+ let e = { type: this.type.name };
743
+ for (let t in this.attrs) {
744
+ e.attrs = this.attrs;
745
+ break;
746
+ }
747
+ return this.content.size && (e.content = this.content.toJSON()), this.marks.length && (e.marks = this.marks.map((e) => e.toJSON())), e;
748
+ }
749
+ static fromJSON(e, t) {
750
+ if (!t) throw RangeError("Invalid input for Node.fromJSON");
751
+ let n;
752
+ if (t.marks) {
753
+ if (!Array.isArray(t.marks)) throw RangeError("Invalid mark data for Node.fromJSON");
754
+ n = t.marks.map(e.markFromJSON);
755
+ }
756
+ if (t.type == "text") {
757
+ if (typeof t.text != "string") throw RangeError("Invalid text node in JSON");
758
+ return e.text(t.text, n);
759
+ }
760
+ let i = r.fromJSON(e, t.content), a = e.nodeType(t.type).create(t.attrs, i, n);
761
+ return a.type.checkAttrs(a.attrs), a;
762
+ }
763
+ };
764
+ b.prototype.text = void 0;
765
+ var ce = class e extends b {
766
+ constructor(e, t, n, r) {
767
+ if (super(e, t, null, r), !n) throw RangeError("Empty text nodes are not allowed");
768
+ this.text = n;
769
+ }
770
+ toString() {
771
+ return this.type.spec.toDebugString ? this.type.spec.toDebugString(this) : le(this.marks, JSON.stringify(this.text));
772
+ }
773
+ get textContent() {
774
+ return this.text;
775
+ }
776
+ textBetween(e, t) {
777
+ return this.text.slice(e, t);
778
+ }
779
+ get nodeSize() {
780
+ return this.text.length;
781
+ }
782
+ mark(t) {
783
+ return t == this.marks ? this : new e(this.type, this.attrs, this.text, t);
784
+ }
785
+ withText(t) {
786
+ return t == this.text ? this : new e(this.type, this.attrs, t, this.marks);
787
+ }
788
+ cut(e = 0, t = this.text.length) {
789
+ return e == 0 && t == this.text.length ? this : this.withText(this.text.slice(e, t));
790
+ }
791
+ eq(e) {
792
+ return this.sameMarkup(e) && this.text == e.text;
793
+ }
794
+ toJSON() {
795
+ let e = super.toJSON();
796
+ return e.text = this.text, e;
797
+ }
798
+ };
799
+ function le(e, t) {
800
+ for (let n = e.length - 1; n >= 0; n--) t = e[n].type.name + "(" + t + ")";
801
+ return t;
802
+ }
803
+ var x = class e {
804
+ constructor(e) {
805
+ this.validEnd = e, this.next = [], this.wrapCache = [];
806
+ }
807
+ static parse(t, n) {
808
+ let r = new ue(t, n);
809
+ if (r.next == null) return e.empty;
810
+ let i = de(r);
811
+ r.next && r.err("Unexpected trailing text");
812
+ let a = xe(ve(i));
813
+ return Se(a, r), a;
814
+ }
815
+ matchType(e) {
816
+ for (let t = 0; t < this.next.length; t++) if (this.next[t].type == e) return this.next[t].next;
817
+ return null;
818
+ }
819
+ matchFragment(e, t = 0, n = e.childCount) {
820
+ let r = this;
821
+ for (let i = t; r && i < n; i++) r = r.matchType(e.child(i).type);
822
+ return r;
823
+ }
824
+ get inlineContent() {
825
+ return this.next.length != 0 && this.next[0].type.isInline;
826
+ }
827
+ get defaultType() {
828
+ for (let e = 0; e < this.next.length; e++) {
829
+ let { type: t } = this.next[e];
830
+ if (!(t.isText || t.hasRequiredAttrs())) return t;
831
+ }
832
+ return null;
833
+ }
834
+ compatible(e) {
835
+ for (let t = 0; t < this.next.length; t++) for (let n = 0; n < e.next.length; n++) if (this.next[t].type == e.next[n].type) return !0;
836
+ return !1;
837
+ }
838
+ fillBefore(e, t = !1, n = 0) {
839
+ let i = [this];
840
+ function a(o, s) {
841
+ let c = o.matchFragment(e, n);
842
+ if (c && (!t || c.validEnd)) return r.from(s.map((e) => e.createAndFill()));
843
+ for (let e = 0; e < o.next.length; e++) {
844
+ let { type: t, next: n } = o.next[e];
845
+ if (!(t.isText || t.hasRequiredAttrs()) && i.indexOf(n) == -1) {
846
+ i.push(n);
847
+ let e = a(n, s.concat(t));
848
+ if (e) return e;
849
+ }
850
+ }
851
+ return null;
852
+ }
853
+ return a(this, []);
854
+ }
855
+ findWrapping(e) {
856
+ for (let t = 0; t < this.wrapCache.length; t += 2) if (this.wrapCache[t] == e) return this.wrapCache[t + 1];
857
+ let t = this.computeWrapping(e);
858
+ return this.wrapCache.push(e, t), t;
859
+ }
860
+ computeWrapping(e) {
861
+ let t = Object.create(null), n = [{
862
+ match: this,
863
+ type: null,
864
+ via: null
865
+ }];
866
+ for (; n.length;) {
867
+ let r = n.shift(), i = r.match;
868
+ if (i.matchType(e)) {
869
+ let e = [];
870
+ for (let t = r; t.type; t = t.via) e.push(t.type);
871
+ return e.reverse();
872
+ }
873
+ for (let e = 0; e < i.next.length; e++) {
874
+ let { type: a, next: o } = i.next[e];
875
+ !a.isLeaf && !a.hasRequiredAttrs() && !(a.name in t) && (!r.type || o.validEnd) && (n.push({
876
+ match: a.contentMatch,
877
+ type: a,
878
+ via: r
879
+ }), t[a.name] = !0);
880
+ }
881
+ }
882
+ return null;
883
+ }
884
+ get edgeCount() {
885
+ return this.next.length;
886
+ }
887
+ edge(e) {
888
+ if (e >= this.next.length) throw RangeError(`There's no ${e}th edge in this content match`);
889
+ return this.next[e];
890
+ }
891
+ toString() {
892
+ let e = [];
893
+ function t(n) {
894
+ e.push(n);
895
+ for (let r = 0; r < n.next.length; r++) e.indexOf(n.next[r].next) == -1 && t(n.next[r].next);
896
+ }
897
+ return t(this), e.map((t, n) => {
898
+ let r = n + (t.validEnd ? "*" : " ") + " ";
899
+ for (let n = 0; n < t.next.length; n++) r += (n ? ", " : "") + t.next[n].type.name + "->" + e.indexOf(t.next[n].next);
900
+ return r;
901
+ }).join("\n");
902
+ }
903
+ };
904
+ x.empty = new x(!0);
905
+ var ue = class {
906
+ constructor(e, t) {
907
+ this.string = e, this.nodeTypes = t, this.inline = null, this.pos = 0, this.tokens = e.split(/\s*(?=\b|\W|$)/), this.tokens[this.tokens.length - 1] == "" && this.tokens.pop(), this.tokens[0] == "" && this.tokens.shift();
908
+ }
909
+ get next() {
910
+ return this.tokens[this.pos];
911
+ }
912
+ eat(e) {
913
+ return this.next == e && (this.pos++ || !0);
914
+ }
915
+ err(e) {
916
+ throw SyntaxError(e + " (in content expression '" + this.string + "')");
917
+ }
918
+ };
919
+ function de(e) {
920
+ let t = [];
921
+ do
922
+ t.push(fe(e));
923
+ while (e.eat("|"));
924
+ return t.length == 1 ? t[0] : {
925
+ type: "choice",
926
+ exprs: t
927
+ };
928
+ }
929
+ function fe(e) {
930
+ let t = [];
931
+ do
932
+ t.push(pe(e));
933
+ while (e.next && e.next != ")" && e.next != "|");
934
+ return t.length == 1 ? t[0] : {
935
+ type: "seq",
936
+ exprs: t
937
+ };
938
+ }
939
+ function pe(e) {
940
+ let t = _e(e);
941
+ for (;;) if (e.eat("+")) t = {
942
+ type: "plus",
943
+ expr: t
944
+ };
945
+ else if (e.eat("*")) t = {
946
+ type: "star",
947
+ expr: t
948
+ };
949
+ else if (e.eat("?")) t = {
950
+ type: "opt",
951
+ expr: t
952
+ };
953
+ else if (e.eat("{")) t = he(e, t);
954
+ else break;
955
+ return t;
956
+ }
957
+ function me(e) {
958
+ /\D/.test(e.next) && e.err("Expected number, got '" + e.next + "'");
959
+ let t = Number(e.next);
960
+ return e.pos++, t;
961
+ }
962
+ function he(e, t) {
963
+ let n = me(e), r = n;
964
+ return e.eat(",") && (r = e.next == "}" ? -1 : me(e)), e.eat("}") || e.err("Unclosed braced range"), {
965
+ type: "range",
966
+ min: n,
967
+ max: r,
968
+ expr: t
969
+ };
970
+ }
971
+ function ge(e, t) {
972
+ let n = e.nodeTypes, r = n[t];
973
+ if (r) return [r];
974
+ let i = [];
975
+ for (let e in n) {
976
+ let r = n[e];
977
+ r.isInGroup(t) && i.push(r);
978
+ }
979
+ return i.length == 0 && e.err("No node type or group '" + t + "' found"), i;
980
+ }
981
+ function _e(e) {
982
+ if (e.eat("(")) {
983
+ let t = de(e);
984
+ return e.eat(")") || e.err("Missing closing paren"), t;
985
+ } else if (/\W/.test(e.next)) e.err("Unexpected token '" + e.next + "'");
986
+ else {
987
+ let t = ge(e, e.next).map((t) => (e.inline == null ? e.inline = t.isInline : e.inline != t.isInline && e.err("Mixing inline and block content"), {
988
+ type: "name",
989
+ value: t
990
+ }));
991
+ return e.pos++, t.length == 1 ? t[0] : {
992
+ type: "choice",
993
+ exprs: t
994
+ };
995
+ }
996
+ }
997
+ function ve(e) {
998
+ let t = [[]];
999
+ return i(a(e, 0), n()), t;
1000
+ function n() {
1001
+ return t.push([]) - 1;
1002
+ }
1003
+ function r(e, n, r) {
1004
+ let i = {
1005
+ term: r,
1006
+ to: n
1007
+ };
1008
+ return t[e].push(i), i;
1009
+ }
1010
+ function i(e, t) {
1011
+ e.forEach((e) => e.to = t);
1012
+ }
1013
+ function a(e, t) {
1014
+ if (e.type == "choice") return e.exprs.reduce((e, n) => e.concat(a(n, t)), []);
1015
+ if (e.type == "seq") for (let r = 0;; r++) {
1016
+ let o = a(e.exprs[r], t);
1017
+ if (r == e.exprs.length - 1) return o;
1018
+ i(o, t = n());
1019
+ }
1020
+ else if (e.type == "star") {
1021
+ let o = n();
1022
+ return r(t, o), i(a(e.expr, o), o), [r(o)];
1023
+ } else if (e.type == "plus") {
1024
+ let o = n();
1025
+ return i(a(e.expr, t), o), i(a(e.expr, o), o), [r(o)];
1026
+ } else if (e.type == "opt") return [r(t)].concat(a(e.expr, t));
1027
+ else if (e.type == "range") {
1028
+ let o = t;
1029
+ for (let t = 0; t < e.min; t++) {
1030
+ let t = n();
1031
+ i(a(e.expr, o), t), o = t;
1032
+ }
1033
+ if (e.max == -1) i(a(e.expr, o), o);
1034
+ else for (let t = e.min; t < e.max; t++) {
1035
+ let t = n();
1036
+ r(o, t), i(a(e.expr, o), t), o = t;
1037
+ }
1038
+ return [r(o)];
1039
+ } else if (e.type == "name") return [r(t, void 0, e.value)];
1040
+ else throw Error("Unknown expr type");
1041
+ }
1042
+ }
1043
+ function ye(e, t) {
1044
+ return t - e;
1045
+ }
1046
+ function be(e, t) {
1047
+ let n = [];
1048
+ return r(t), n.sort(ye);
1049
+ function r(t) {
1050
+ let i = e[t];
1051
+ if (i.length == 1 && !i[0].term) return r(i[0].to);
1052
+ n.push(t);
1053
+ for (let e = 0; e < i.length; e++) {
1054
+ let { term: t, to: a } = i[e];
1055
+ !t && n.indexOf(a) == -1 && r(a);
1056
+ }
1057
+ }
1058
+ }
1059
+ function xe(e) {
1060
+ let t = Object.create(null);
1061
+ return n(be(e, 0));
1062
+ function n(r) {
1063
+ let i = [];
1064
+ r.forEach((t) => {
1065
+ e[t].forEach(({ term: t, to: n }) => {
1066
+ if (!t) return;
1067
+ let r;
1068
+ for (let e = 0; e < i.length; e++) i[e][0] == t && (r = i[e][1]);
1069
+ be(e, n).forEach((e) => {
1070
+ r || i.push([t, r = []]), r.indexOf(e) == -1 && r.push(e);
1071
+ });
1072
+ });
1073
+ });
1074
+ let a = t[r.join(",")] = new x(r.indexOf(e.length - 1) > -1);
1075
+ for (let e = 0; e < i.length; e++) {
1076
+ let r = i[e][1].sort(ye);
1077
+ a.next.push({
1078
+ type: i[e][0],
1079
+ next: t[r.join(",")] || n(r)
1080
+ });
1081
+ }
1082
+ return a;
1083
+ }
1084
+ }
1085
+ function Se(e, t) {
1086
+ for (let n = 0, r = [e]; n < r.length; n++) {
1087
+ let e = r[n], i = !e.validEnd, a = [];
1088
+ for (let t = 0; t < e.next.length; t++) {
1089
+ let { type: n, next: o } = e.next[t];
1090
+ a.push(n.name), i && !(n.isText || n.hasRequiredAttrs()) && (i = !1), r.indexOf(o) == -1 && r.push(o);
1091
+ }
1092
+ i && t.err("Only non-generatable nodes (" + a.join(", ") + ") in a required position (see https://prosemirror.net/docs/guide/#generatable)");
1093
+ }
1094
+ }
1095
+ function Ce(e) {
1096
+ let t = Object.create(null);
1097
+ for (let n in e) {
1098
+ let r = e[n];
1099
+ if (!r.hasDefault) return null;
1100
+ t[n] = r.default;
1101
+ }
1102
+ return t;
1103
+ }
1104
+ function we(e, t) {
1105
+ let n = Object.create(null);
1106
+ for (let r in e) {
1107
+ let i = t && t[r];
1108
+ if (i === void 0) {
1109
+ let t = e[r];
1110
+ if (t.hasDefault) i = t.default;
1111
+ else throw RangeError("No value supplied for attribute " + r);
1112
+ }
1113
+ n[r] = i;
1114
+ }
1115
+ return n;
1116
+ }
1117
+ function Te(e, t, n, r) {
1118
+ for (let r in t) if (!(r in e)) throw RangeError(`Unsupported attribute ${r} for ${n} of type ${r}`);
1119
+ for (let n in e) {
1120
+ let r = e[n];
1121
+ r.validate && r.validate(t[n]);
1122
+ }
1123
+ }
1124
+ function Ee(e, t) {
1125
+ let n = Object.create(null);
1126
+ if (t) for (let r in t) n[r] = new Oe(e, r, t[r]);
1127
+ return n;
1128
+ }
1129
+ var S = class e {
1130
+ constructor(e, t, n) {
1131
+ this.name = e, this.schema = t, this.spec = n, this.markSet = null, this.groups = n.group ? n.group.split(" ") : [], this.attrs = Ee(e, n.attrs), this.defaultAttrs = Ce(this.attrs), this.contentMatch = null, this.inlineContent = null, this.isBlock = !(n.inline || e == "text"), this.isText = e == "text";
1132
+ }
1133
+ get isInline() {
1134
+ return !this.isBlock;
1135
+ }
1136
+ get isTextblock() {
1137
+ return this.isBlock && this.inlineContent;
1138
+ }
1139
+ get isLeaf() {
1140
+ return this.contentMatch == x.empty;
1141
+ }
1142
+ get isAtom() {
1143
+ return this.isLeaf || !!this.spec.atom;
1144
+ }
1145
+ isInGroup(e) {
1146
+ return this.groups.indexOf(e) > -1;
1147
+ }
1148
+ get whitespace() {
1149
+ return this.spec.whitespace || (this.spec.code ? "pre" : "normal");
1150
+ }
1151
+ hasRequiredAttrs() {
1152
+ for (let e in this.attrs) if (this.attrs[e].isRequired) return !0;
1153
+ return !1;
1154
+ }
1155
+ compatibleContent(e) {
1156
+ return this == e || this.contentMatch.compatible(e.contentMatch);
1157
+ }
1158
+ computeAttrs(e) {
1159
+ return !e && this.defaultAttrs ? this.defaultAttrs : we(this.attrs, e);
1160
+ }
1161
+ create(e = null, t, n) {
1162
+ if (this.isText) throw Error("NodeType.create can't construct text nodes");
1163
+ return new b(this, this.computeAttrs(e), r.from(t), s.setFrom(n));
1164
+ }
1165
+ createChecked(e = null, t, n) {
1166
+ return t = r.from(t), this.checkContent(t), new b(this, this.computeAttrs(e), t, s.setFrom(n));
1167
+ }
1168
+ createAndFill(e = null, t, n) {
1169
+ if (e = this.computeAttrs(e), t = r.from(t), t.size) {
1170
+ let e = this.contentMatch.fillBefore(t);
1171
+ if (!e) return null;
1172
+ t = e.append(t);
1173
+ }
1174
+ let i = this.contentMatch.matchFragment(t), a = i && i.fillBefore(r.empty, !0);
1175
+ return a ? new b(this, e, t.append(a), s.setFrom(n)) : null;
1176
+ }
1177
+ validContent(e) {
1178
+ let t = this.contentMatch.matchFragment(e);
1179
+ if (!t || !t.validEnd) return !1;
1180
+ for (let t = 0; t < e.childCount; t++) if (!this.allowsMarks(e.child(t).marks)) return !1;
1181
+ return !0;
1182
+ }
1183
+ checkContent(e) {
1184
+ if (!this.validContent(e)) throw RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0, 50)}`);
1185
+ }
1186
+ checkAttrs(e) {
1187
+ Te(this.attrs, e, "node", this.name);
1188
+ }
1189
+ allowsMarkType(e) {
1190
+ return this.markSet == null || this.markSet.indexOf(e) > -1;
1191
+ }
1192
+ allowsMarks(e) {
1193
+ if (this.markSet == null) return !0;
1194
+ for (let t = 0; t < e.length; t++) if (!this.allowsMarkType(e[t].type)) return !1;
1195
+ return !0;
1196
+ }
1197
+ allowedMarks(e) {
1198
+ if (this.markSet == null) return e;
1199
+ let t;
1200
+ for (let n = 0; n < e.length; n++) this.allowsMarkType(e[n].type) ? t && t.push(e[n]) : t ||= e.slice(0, n);
1201
+ return t ? t.length ? t : s.none : e;
1202
+ }
1203
+ static compile(t, n) {
1204
+ let r = Object.create(null);
1205
+ t.forEach((t, i) => r[t] = new e(t, n, i));
1206
+ let i = n.spec.topNode || "doc";
1207
+ if (!r[i]) throw RangeError("Schema is missing its top node type ('" + i + "')");
1208
+ if (!r.text) throw RangeError("Every schema needs a 'text' type");
1209
+ for (let e in r.text.attrs) throw RangeError("The text node type should not have attributes");
1210
+ return r;
1211
+ }
1212
+ };
1213
+ function De(e, t, n) {
1214
+ let r = n.split("|");
1215
+ return (n) => {
1216
+ let i = n === null ? "null" : typeof n;
1217
+ if (r.indexOf(i) < 0) throw RangeError(`Expected value of type ${r} for attribute ${t} on type ${e}, got ${i}`);
1218
+ };
1219
+ }
1220
+ var Oe = class {
1221
+ constructor(e, t, n) {
1222
+ this.hasDefault = Object.prototype.hasOwnProperty.call(n, "default"), this.default = n.default, this.validate = typeof n.validate == "string" ? De(e, t, n.validate) : n.validate;
1223
+ }
1224
+ get isRequired() {
1225
+ return !this.hasDefault;
1226
+ }
1227
+ }, ke = class e {
1228
+ constructor(e, t, n, r) {
1229
+ this.name = e, this.rank = t, this.schema = n, this.spec = r, this.attrs = Ee(e, r.attrs), this.excluded = null;
1230
+ let i = Ce(this.attrs);
1231
+ this.instance = i ? new s(this, i) : null;
1232
+ }
1233
+ create(e = null) {
1234
+ return !e && this.instance ? this.instance : new s(this, we(this.attrs, e));
1235
+ }
1236
+ static compile(t, n) {
1237
+ let r = Object.create(null), i = 0;
1238
+ return t.forEach((t, a) => r[t] = new e(t, i++, n, a)), r;
1239
+ }
1240
+ removeFromSet(e) {
1241
+ for (var t = 0; t < e.length; t++) e[t].type == this && (e = e.slice(0, t).concat(e.slice(t + 1)), t--);
1242
+ return e;
1243
+ }
1244
+ isInSet(e) {
1245
+ for (let t = 0; t < e.length; t++) if (e[t].type == this) return e[t];
1246
+ }
1247
+ checkAttrs(e) {
1248
+ Te(this.attrs, e, "mark", this.name);
1249
+ }
1250
+ excludes(e) {
1251
+ return this.excluded.indexOf(e) > -1;
1252
+ }
1253
+ }, Ae = class {
1254
+ constructor(t) {
1255
+ this.linebreakReplacement = null, this.cached = Object.create(null);
1256
+ let n = this.spec = {};
1257
+ for (let e in t) n[e] = t[e];
1258
+ n.nodes = e.from(t.nodes), n.marks = e.from(t.marks || {}), this.nodes = S.compile(this.spec.nodes, this), this.marks = ke.compile(this.spec.marks, this);
1259
+ let r = Object.create(null);
1260
+ for (let e in this.nodes) {
1261
+ if (e in this.marks) throw RangeError(e + " can not be both a node and a mark");
1262
+ let t = this.nodes[e], n = t.spec.content || "", i = t.spec.marks;
1263
+ if (t.contentMatch = r[n] || (r[n] = x.parse(n, this.nodes)), t.inlineContent = t.contentMatch.inlineContent, t.spec.linebreakReplacement) {
1264
+ if (this.linebreakReplacement) throw RangeError("Multiple linebreak nodes defined");
1265
+ if (!t.isInline || !t.isLeaf) throw RangeError("Linebreak replacement nodes must be inline leaf nodes");
1266
+ this.linebreakReplacement = t;
1267
+ }
1268
+ t.markSet = i == "_" ? null : i ? je(this, i.split(" ")) : i == "" || !t.inlineContent ? [] : null;
1269
+ }
1270
+ for (let e in this.marks) {
1271
+ let t = this.marks[e], n = t.spec.excludes;
1272
+ t.excluded = n == null ? [t] : n == "" ? [] : je(this, n.split(" "));
1273
+ }
1274
+ this.nodeFromJSON = (e) => b.fromJSON(this, e), this.markFromJSON = (e) => s.fromJSON(this, e), this.topNodeType = this.nodes[this.spec.topNode || "doc"], this.cached.wrappings = Object.create(null);
1275
+ }
1276
+ node(e, t = null, n, r) {
1277
+ if (typeof e == "string") e = this.nodeType(e);
1278
+ else if (!(e instanceof S)) throw RangeError("Invalid node type: " + e);
1279
+ else if (e.schema != this) throw RangeError("Node type from different schema used (" + e.name + ")");
1280
+ return e.createChecked(t, n, r);
1281
+ }
1282
+ text(e, t) {
1283
+ let n = this.nodes.text;
1284
+ return new ce(n, n.defaultAttrs, e, s.setFrom(t));
1285
+ }
1286
+ mark(e, t) {
1287
+ return typeof e == "string" && (e = this.marks[e]), e.create(t);
1288
+ }
1289
+ nodeType(e) {
1290
+ let t = this.nodes[e];
1291
+ if (!t) throw RangeError("Unknown node type: " + e);
1292
+ return t;
1293
+ }
1294
+ };
1295
+ function je(e, t) {
1296
+ let n = [];
1297
+ for (let r = 0; r < t.length; r++) {
1298
+ let i = t[r], a = e.marks[i], o = a;
1299
+ if (a) n.push(a);
1300
+ else for (let t in e.marks) {
1301
+ let r = e.marks[t];
1302
+ (i == "_" || r.spec.group && r.spec.group.split(" ").indexOf(i) > -1) && n.push(o = r);
1303
+ }
1304
+ if (!o) throw SyntaxError("Unknown mark type: '" + t[r] + "'");
1305
+ }
1306
+ return n;
1307
+ }
1308
+ function Me(e) {
1309
+ return e.tag != null;
1310
+ }
1311
+ function Ne(e) {
1312
+ return e.style != null;
1313
+ }
1314
+ var Pe = class e {
1315
+ constructor(e, t) {
1316
+ this.schema = e, this.rules = t, this.tags = [], this.styles = [];
1317
+ let n = this.matchedStyles = [];
1318
+ t.forEach((e) => {
1319
+ if (Me(e)) this.tags.push(e);
1320
+ else if (Ne(e)) {
1321
+ let t = /[^=]*/.exec(e.style)[0];
1322
+ n.indexOf(t) < 0 && n.push(t), this.styles.push(e);
1323
+ }
1324
+ }), this.normalizeLists = !this.tags.some((t) => {
1325
+ if (!/^(ul|ol)\b/.test(t.tag) || !t.node) return !1;
1326
+ let n = e.nodes[t.node];
1327
+ return n.contentMatch.matchType(n);
1328
+ });
1329
+ }
1330
+ parse(e, t = {}) {
1331
+ let n = new ze(this, t, !1);
1332
+ return n.addAll(e, s.none, t.from, t.to), n.finish();
1333
+ }
1334
+ parseSlice(e, t = {}) {
1335
+ let n = new ze(this, t, !0);
1336
+ return n.addAll(e, s.none, t.from, t.to), l.maxOpen(n.finish());
1337
+ }
1338
+ matchTag(e, t, n) {
1339
+ for (let r = n ? this.tags.indexOf(n) + 1 : 0; r < this.tags.length; r++) {
1340
+ let n = this.tags[r];
1341
+ if (Ve(e, n.tag) && (n.namespace === void 0 || e.namespaceURI == n.namespace) && (!n.context || t.matchesContext(n.context))) {
1342
+ if (n.getAttrs) {
1343
+ let t = n.getAttrs(e);
1344
+ if (t === !1) continue;
1345
+ n.attrs = t || void 0;
1346
+ }
1347
+ return n;
1348
+ }
1349
+ }
1350
+ }
1351
+ matchStyle(e, t, n, r) {
1352
+ for (let i = r ? this.styles.indexOf(r) + 1 : 0; i < this.styles.length; i++) {
1353
+ let r = this.styles[i], a = r.style;
1354
+ if (!(a.indexOf(e) != 0 || r.context && !n.matchesContext(r.context) || a.length > e.length && (a.charCodeAt(e.length) != 61 || a.slice(e.length + 1) != t))) {
1355
+ if (r.getAttrs) {
1356
+ let e = r.getAttrs(t);
1357
+ if (e === !1) continue;
1358
+ r.attrs = e || void 0;
1359
+ }
1360
+ return r;
1361
+ }
1362
+ }
1363
+ }
1364
+ static schemaRules(e) {
1365
+ let t = [];
1366
+ function n(e) {
1367
+ let n = e.priority == null ? 50 : e.priority, r = 0;
1368
+ for (; r < t.length; r++) {
1369
+ let e = t[r];
1370
+ if ((e.priority == null ? 50 : e.priority) < n) break;
1371
+ }
1372
+ t.splice(r, 0, e);
1373
+ }
1374
+ for (let t in e.marks) {
1375
+ let r = e.marks[t].spec.parseDOM;
1376
+ r && r.forEach((e) => {
1377
+ n(e = He(e)), e.mark || e.ignore || e.clearMark || (e.mark = t);
1378
+ });
1379
+ }
1380
+ for (let t in e.nodes) {
1381
+ let r = e.nodes[t].spec.parseDOM;
1382
+ r && r.forEach((e) => {
1383
+ n(e = He(e)), e.node || e.ignore || e.mark || (e.node = t);
1384
+ });
1385
+ }
1386
+ return t;
1387
+ }
1388
+ static fromSchema(t) {
1389
+ return t.cached.domParser || (t.cached.domParser = new e(t, e.schemaRules(t)));
1390
+ }
1391
+ }, Fe = {
1392
+ address: !0,
1393
+ article: !0,
1394
+ aside: !0,
1395
+ blockquote: !0,
1396
+ canvas: !0,
1397
+ dd: !0,
1398
+ div: !0,
1399
+ dl: !0,
1400
+ fieldset: !0,
1401
+ figcaption: !0,
1402
+ figure: !0,
1403
+ footer: !0,
1404
+ form: !0,
1405
+ h1: !0,
1406
+ h2: !0,
1407
+ h3: !0,
1408
+ h4: !0,
1409
+ h5: !0,
1410
+ h6: !0,
1411
+ header: !0,
1412
+ hgroup: !0,
1413
+ hr: !0,
1414
+ li: !0,
1415
+ noscript: !0,
1416
+ ol: !0,
1417
+ output: !0,
1418
+ p: !0,
1419
+ pre: !0,
1420
+ section: !0,
1421
+ table: !0,
1422
+ tfoot: !0,
1423
+ ul: !0
1424
+ }, Ie = {
1425
+ head: !0,
1426
+ noscript: !0,
1427
+ object: !0,
1428
+ script: !0,
1429
+ style: !0,
1430
+ title: !0
1431
+ }, Le = {
1432
+ ol: !0,
1433
+ ul: !0
1434
+ }, C = 1, w = 2, T = 4;
1435
+ function Re(e, t, n) {
1436
+ return t == null ? e && e.whitespace == "pre" ? C | w : n & ~T : (t ? C : 0) | (t === "full" ? w : 0);
1437
+ }
1438
+ var E = class {
1439
+ constructor(e, t, n, r, i, a) {
1440
+ this.type = e, this.attrs = t, this.marks = n, this.solid = r, this.options = a, this.content = [], this.activeMarks = s.none, this.match = i || (a & T ? null : e.contentMatch);
1441
+ }
1442
+ findWrapping(e) {
1443
+ if (!this.match) {
1444
+ if (!this.type) return [];
1445
+ let t = this.type.contentMatch.fillBefore(r.from(e));
1446
+ if (t) this.match = this.type.contentMatch.matchFragment(t);
1447
+ else {
1448
+ let t = this.type.contentMatch, n;
1449
+ return (n = t.findWrapping(e.type)) ? (this.match = t, n) : null;
1450
+ }
1451
+ }
1452
+ return this.match.findWrapping(e.type);
1453
+ }
1454
+ finish(e) {
1455
+ if (!(this.options & C)) {
1456
+ let e = this.content[this.content.length - 1], t;
1457
+ if (e && e.isText && (t = /[ \t\r\n\u000c]+$/.exec(e.text))) {
1458
+ let n = e;
1459
+ e.text.length == t[0].length ? this.content.pop() : this.content[this.content.length - 1] = n.withText(n.text.slice(0, n.text.length - t[0].length));
1460
+ }
1461
+ }
1462
+ let t = r.from(this.content);
1463
+ return !e && this.match && (t = t.append(this.match.fillBefore(r.empty, !0))), this.type ? this.type.create(this.attrs, t, this.marks) : t;
1464
+ }
1465
+ inlineContext(e) {
1466
+ return this.type ? this.type.inlineContent : this.content.length ? this.content[0].isInline : e.parentNode && !Fe.hasOwnProperty(e.parentNode.nodeName.toLowerCase());
1467
+ }
1468
+ }, ze = class {
1469
+ constructor(e, t, n) {
1470
+ this.parser = e, this.options = t, this.isOpen = n, this.open = 0, this.localPreserveWS = !1;
1471
+ let r = t.topNode, i, a = Re(null, t.preserveWhitespace, 0) | (n ? T : 0);
1472
+ i = r ? new E(r.type, r.attrs, s.none, !0, t.topMatch || r.type.contentMatch, a) : n ? new E(null, null, s.none, !0, null, a) : new E(e.schema.topNodeType, null, s.none, !0, null, a), this.nodes = [i], this.find = t.findPositions, this.needsBlock = !1;
1473
+ }
1474
+ get top() {
1475
+ return this.nodes[this.open];
1476
+ }
1477
+ addDOM(e, t) {
1478
+ e.nodeType == 3 ? this.addTextNode(e, t) : e.nodeType == 1 && this.addElement(e, t);
1479
+ }
1480
+ addTextNode(e, t) {
1481
+ let n = e.nodeValue, r = this.top, i = r.options & w ? "full" : this.localPreserveWS || (r.options & C) > 0, { schema: a } = this.parser;
1482
+ if (i === "full" || r.inlineContext(e) || /[^ \t\r\n\u000c]/.test(n)) {
1483
+ if (!i) {
1484
+ if (n = n.replace(/[ \t\r\n\u000c]+/g, " "), /^[ \t\r\n\u000c]/.test(n) && this.open == this.nodes.length - 1) {
1485
+ let t = r.content[r.content.length - 1], i = e.previousSibling;
1486
+ (!t || i && i.nodeName == "BR" || t.isText && /[ \t\r\n\u000c]$/.test(t.text)) && (n = n.slice(1));
1487
+ }
1488
+ } else if (i === "full") n = n.replace(/\r\n?/g, "\n");
1489
+ else if (a.linebreakReplacement && /[\r\n]/.test(n) && this.top.findWrapping(a.linebreakReplacement.create())) {
1490
+ let e = n.split(/\r?\n|\r/);
1491
+ for (let n = 0; n < e.length; n++) n && this.insertNode(a.linebreakReplacement.create(), t, !0), e[n] && this.insertNode(a.text(e[n]), t, !/\S/.test(e[n]));
1492
+ n = "";
1493
+ } else n = n.replace(/\r?\n|\r/g, " ");
1494
+ n && this.insertNode(a.text(n), t, !/\S/.test(n)), this.findInText(e);
1495
+ } else this.findInside(e);
1496
+ }
1497
+ addElement(e, t, n) {
1498
+ let r = this.localPreserveWS, i = this.top;
1499
+ (e.tagName == "PRE" || /pre/.test(e.style && e.style.whiteSpace)) && (this.localPreserveWS = !0);
1500
+ let a = e.nodeName.toLowerCase(), o;
1501
+ Le.hasOwnProperty(a) && this.parser.normalizeLists && Be(e);
1502
+ let s = this.options.ruleFromNode && this.options.ruleFromNode(e) || (o = this.parser.matchTag(e, this, n));
1503
+ out: if (s ? s.ignore : Ie.hasOwnProperty(a)) this.findInside(e), this.ignoreFallback(e, t);
1504
+ else if (!s || s.skip || s.closeParent) {
1505
+ s && s.closeParent ? this.open = Math.max(0, this.open - 1) : s && s.skip.nodeType && (e = s.skip);
1506
+ let n, r = this.needsBlock;
1507
+ if (Fe.hasOwnProperty(a)) i.content.length && i.content[0].isInline && this.open && (this.open--, i = this.top), n = !0, i.type || (this.needsBlock = !0);
1508
+ else if (!e.firstChild) {
1509
+ this.leafFallback(e, t);
1510
+ break out;
1511
+ }
1512
+ let o = s && s.skip ? t : this.readStyles(e, t);
1513
+ o && this.addAll(e, o), n && this.sync(i), this.needsBlock = r;
1514
+ } else {
1515
+ let n = this.readStyles(e, t);
1516
+ n && this.addElementByRule(e, s, n, s.consuming === !1 ? o : void 0);
1517
+ }
1518
+ this.localPreserveWS = r;
1519
+ }
1520
+ leafFallback(e, t) {
1521
+ e.nodeName == "BR" && this.top.type && this.top.type.inlineContent && this.addTextNode(e.ownerDocument.createTextNode("\n"), t);
1522
+ }
1523
+ ignoreFallback(e, t) {
1524
+ e.nodeName == "BR" && (!this.top.type || !this.top.type.inlineContent) && this.findPlace(this.parser.schema.text("-"), t, !0);
1525
+ }
1526
+ readStyles(e, t) {
1527
+ let n = e.style;
1528
+ if (n && n.length) for (let e = 0; e < this.parser.matchedStyles.length; e++) {
1529
+ let r = this.parser.matchedStyles[e], i = n.getPropertyValue(r);
1530
+ if (i) for (let e;;) {
1531
+ let n = this.parser.matchStyle(r, i, this, e);
1532
+ if (!n) break;
1533
+ if (n.ignore) return null;
1534
+ if (t = n.clearMark ? t.filter((e) => !n.clearMark(e)) : t.concat(this.parser.schema.marks[n.mark].create(n.attrs)), n.consuming === !1) e = n;
1535
+ else break;
1536
+ }
1537
+ }
1538
+ return t;
1539
+ }
1540
+ addElementByRule(e, t, n, r) {
1541
+ let i, a;
1542
+ if (t.node) if (a = this.parser.schema.nodes[t.node], a.isLeaf) this.insertNode(a.create(t.attrs), n, e.nodeName == "BR") || this.leafFallback(e, n);
1543
+ else {
1544
+ let e = this.enter(a, t.attrs || null, n, t.preserveWhitespace);
1545
+ e && (i = !0, n = e);
1546
+ }
1547
+ else {
1548
+ let e = this.parser.schema.marks[t.mark];
1549
+ n = n.concat(e.create(t.attrs));
1550
+ }
1551
+ let o = this.top;
1552
+ if (a && a.isLeaf) this.findInside(e);
1553
+ else if (r) this.addElement(e, n, r);
1554
+ else if (t.getContent) this.findInside(e), t.getContent(e, this.parser.schema).forEach((e) => this.insertNode(e, n, !1));
1555
+ else {
1556
+ let r = e;
1557
+ typeof t.contentElement == "string" ? r = e.querySelector(t.contentElement) : typeof t.contentElement == "function" ? r = t.contentElement(e) : t.contentElement && (r = t.contentElement), this.findAround(e, r, !0), this.addAll(r, n), this.findAround(e, r, !1);
1558
+ }
1559
+ i && this.sync(o) && this.open--;
1560
+ }
1561
+ addAll(e, t, n, r) {
1562
+ let i = n || 0;
1563
+ for (let a = n ? e.childNodes[n] : e.firstChild, o = r == null ? null : e.childNodes[r]; a != o; a = a.nextSibling, ++i) this.findAtPoint(e, i), this.addDOM(a, t);
1564
+ this.findAtPoint(e, i);
1565
+ }
1566
+ findPlace(e, t, n) {
1567
+ let r, i;
1568
+ for (let t = this.open, a = 0; t >= 0; t--) {
1569
+ let o = this.nodes[t], s = o.findWrapping(e);
1570
+ if (s && (!r || r.length > s.length + a) && (r = s, i = o, !s.length)) break;
1571
+ if (o.solid) {
1572
+ if (n) break;
1573
+ a += 2;
1574
+ }
1575
+ }
1576
+ if (!r) return null;
1577
+ this.sync(i);
1578
+ for (let e = 0; e < r.length; e++) t = this.enterInner(r[e], null, t, !1);
1579
+ return t;
1580
+ }
1581
+ insertNode(e, t, n) {
1582
+ if (e.isInline && this.needsBlock && !this.top.type) {
1583
+ let e = this.textblockFromContext();
1584
+ e && (t = this.enterInner(e, null, t));
1585
+ }
1586
+ let r = this.findPlace(e, t, n);
1587
+ if (r) {
1588
+ this.closeExtra();
1589
+ let t = this.top;
1590
+ t.match &&= t.match.matchType(e.type);
1591
+ let n = s.none;
1592
+ for (let i of r.concat(e.marks)) (t.type ? t.type.allowsMarkType(i.type) : Ue(i.type, e.type)) && (n = i.addToSet(n));
1593
+ return t.content.push(e.mark(n)), !0;
1594
+ }
1595
+ return !1;
1596
+ }
1597
+ enter(e, t, n, r) {
1598
+ let i = this.findPlace(e.create(t), n, !1);
1599
+ return i &&= this.enterInner(e, t, n, !0, r), i;
1600
+ }
1601
+ enterInner(e, t, n, r = !1, i) {
1602
+ this.closeExtra();
1603
+ let a = this.top;
1604
+ a.match = a.match && a.match.matchType(e);
1605
+ let o = Re(e, i, a.options);
1606
+ a.options & T && a.content.length == 0 && (o |= T);
1607
+ let c = s.none;
1608
+ return n = n.filter((t) => (a.type ? a.type.allowsMarkType(t.type) : Ue(t.type, e)) ? (c = t.addToSet(c), !1) : !0), this.nodes.push(new E(e, t, c, r, null, o)), this.open++, n;
1609
+ }
1610
+ closeExtra(e = !1) {
1611
+ let t = this.nodes.length - 1;
1612
+ if (t > this.open) {
1613
+ for (; t > this.open; t--) this.nodes[t - 1].content.push(this.nodes[t].finish(e));
1614
+ this.nodes.length = this.open + 1;
1615
+ }
1616
+ }
1617
+ finish() {
1618
+ return this.open = 0, this.closeExtra(this.isOpen), this.nodes[0].finish(!!(this.isOpen || this.options.topOpen));
1619
+ }
1620
+ sync(e) {
1621
+ for (let t = this.open; t >= 0; t--) if (this.nodes[t] == e) return this.open = t, !0;
1622
+ else this.localPreserveWS && (this.nodes[t].options |= C);
1623
+ return !1;
1624
+ }
1625
+ get currentPos() {
1626
+ this.closeExtra();
1627
+ let e = 0;
1628
+ for (let t = this.open; t >= 0; t--) {
1629
+ let n = this.nodes[t].content;
1630
+ for (let t = n.length - 1; t >= 0; t--) e += n[t].nodeSize;
1631
+ t && e++;
1632
+ }
1633
+ return e;
1634
+ }
1635
+ findAtPoint(e, t) {
1636
+ if (this.find) for (let n = 0; n < this.find.length; n++) this.find[n].node == e && this.find[n].offset == t && (this.find[n].pos = this.currentPos);
1637
+ }
1638
+ findInside(e) {
1639
+ if (this.find) for (let t = 0; t < this.find.length; t++) this.find[t].pos == null && e.nodeType == 1 && e.contains(this.find[t].node) && (this.find[t].pos = this.currentPos);
1640
+ }
1641
+ findAround(e, t, n) {
1642
+ if (e != t && this.find) for (let r = 0; r < this.find.length; r++) this.find[r].pos == null && e.nodeType == 1 && e.contains(this.find[r].node) && t.compareDocumentPosition(this.find[r].node) & (n ? 2 : 4) && (this.find[r].pos = this.currentPos);
1643
+ }
1644
+ findInText(e) {
1645
+ if (this.find) for (let t = 0; t < this.find.length; t++) this.find[t].node == e && (this.find[t].pos = this.currentPos - (e.nodeValue.length - this.find[t].offset));
1646
+ }
1647
+ matchesContext(e) {
1648
+ if (e.indexOf("|") > -1) return e.split(/\s*\|\s*/).some(this.matchesContext, this);
1649
+ let t = e.split("/"), n = this.options.context, r = !this.isOpen && (!n || n.parent.type == this.nodes[0].type), i = -(n ? n.depth + 1 : 0) + +!r, a = (e, o) => {
1650
+ for (; e >= 0; e--) {
1651
+ let s = t[e];
1652
+ if (s == "") {
1653
+ if (e == t.length - 1 || e == 0) continue;
1654
+ for (; o >= i; o--) if (a(e - 1, o)) return !0;
1655
+ return !1;
1656
+ } else {
1657
+ let e = o > 0 || o == 0 && r ? this.nodes[o].type : n && o >= i ? n.node(o - i).type : null;
1658
+ if (!e || e.name != s && !e.isInGroup(s)) return !1;
1659
+ o--;
1660
+ }
1661
+ }
1662
+ return !0;
1663
+ };
1664
+ return a(t.length - 1, this.open);
1665
+ }
1666
+ textblockFromContext() {
1667
+ let e = this.options.context;
1668
+ if (e) for (let t = e.depth; t >= 0; t--) {
1669
+ let n = e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;
1670
+ if (n && n.isTextblock && n.defaultAttrs) return n;
1671
+ }
1672
+ for (let e in this.parser.schema.nodes) {
1673
+ let t = this.parser.schema.nodes[e];
1674
+ if (t.isTextblock && t.defaultAttrs) return t;
1675
+ }
1676
+ }
1677
+ };
1678
+ function Be(e) {
1679
+ for (let t = e.firstChild, n = null; t; t = t.nextSibling) {
1680
+ let e = t.nodeType == 1 ? t.nodeName.toLowerCase() : null;
1681
+ e && Le.hasOwnProperty(e) && n ? (n.appendChild(t), t = n) : e == "li" ? n = t : e && (n = null);
1682
+ }
1683
+ }
1684
+ function Ve(e, t) {
1685
+ return (e.matches || e.msMatchesSelector || e.webkitMatchesSelector || e.mozMatchesSelector).call(e, t);
1686
+ }
1687
+ function He(e) {
1688
+ let t = {};
1689
+ for (let n in e) t[n] = e[n];
1690
+ return t;
1691
+ }
1692
+ function Ue(e, t) {
1693
+ let n = t.schema.nodes;
1694
+ for (let r in n) {
1695
+ let i = n[r];
1696
+ if (!i.allowsMarkType(e)) continue;
1697
+ let a = [], o = (e) => {
1698
+ a.push(e);
1699
+ for (let n = 0; n < e.edgeCount; n++) {
1700
+ let { type: r, next: i } = e.edge(n);
1701
+ if (r == t || a.indexOf(i) < 0 && o(i)) return !0;
1702
+ }
1703
+ };
1704
+ if (o(i.contentMatch)) return !0;
1705
+ }
1706
+ }
1707
+ var We = class e {
1708
+ constructor(e, t) {
1709
+ this.nodes = e, this.marks = t;
1710
+ }
1711
+ serializeFragment(e, t = {}, n) {
1712
+ n ||= D(t).createDocumentFragment();
1713
+ let r = n, i = [];
1714
+ return e.forEach((e) => {
1715
+ if (i.length || e.marks.length) {
1716
+ let n = 0, a = 0;
1717
+ for (; n < i.length && a < e.marks.length;) {
1718
+ let t = e.marks[a];
1719
+ if (!this.marks[t.type.name]) {
1720
+ a++;
1721
+ continue;
1722
+ }
1723
+ if (!t.eq(i[n][0]) || t.type.spec.spanning === !1) break;
1724
+ n++, a++;
1725
+ }
1726
+ for (; n < i.length;) r = i.pop()[1];
1727
+ for (; a < e.marks.length;) {
1728
+ let n = e.marks[a++], o = this.serializeMark(n, e.isInline, t);
1729
+ o && (i.push([n, r]), r.appendChild(o.dom), r = o.contentDOM || o.dom);
1730
+ }
1731
+ }
1732
+ r.appendChild(this.serializeNodeInner(e, t));
1733
+ }), n;
1734
+ }
1735
+ serializeNodeInner(e, t) {
1736
+ let { dom: n, contentDOM: r } = O(D(t), this.nodes[e.type.name](e), null, e.attrs);
1737
+ if (r) {
1738
+ if (e.isLeaf) throw RangeError("Content hole not allowed in a leaf node spec");
1739
+ this.serializeFragment(e.content, t, r);
1740
+ }
1741
+ return n;
1742
+ }
1743
+ serializeNode(e, t = {}) {
1744
+ let n = this.serializeNodeInner(e, t);
1745
+ for (let r = e.marks.length - 1; r >= 0; r--) {
1746
+ let i = this.serializeMark(e.marks[r], e.isInline, t);
1747
+ i && ((i.contentDOM || i.dom).appendChild(n), n = i.dom);
1748
+ }
1749
+ return n;
1750
+ }
1751
+ serializeMark(e, t, n = {}) {
1752
+ let r = this.marks[e.type.name];
1753
+ return r && O(D(n), r(e, t), null, e.attrs);
1754
+ }
1755
+ static renderSpec(e, t, n = null, r) {
1756
+ return O(e, t, n, r);
1757
+ }
1758
+ static fromSchema(t) {
1759
+ return t.cached.domSerializer || (t.cached.domSerializer = new e(this.nodesFromSchema(t), this.marksFromSchema(t)));
1760
+ }
1761
+ static nodesFromSchema(e) {
1762
+ let t = Ge(e.nodes);
1763
+ return t.text ||= (e) => e.text, t;
1764
+ }
1765
+ static marksFromSchema(e) {
1766
+ return Ge(e.marks);
1767
+ }
1768
+ };
1769
+ function Ge(e) {
1770
+ let t = {};
1771
+ for (let n in e) {
1772
+ let r = e[n].spec.toDOM;
1773
+ r && (t[n] = r);
1774
+ }
1775
+ return t;
1776
+ }
1777
+ function D(e) {
1778
+ return e.document || window.document;
1779
+ }
1780
+ var Ke = /* @__PURE__ */ new WeakMap();
1781
+ function qe(e) {
1782
+ let t = Ke.get(e);
1783
+ return t === void 0 && Ke.set(e, t = Je(e)), t;
1784
+ }
1785
+ function Je(e) {
1786
+ let t = null;
1787
+ function n(e) {
1788
+ if (e && typeof e == "object") if (Array.isArray(e)) if (typeof e[0] == "string") t ||= [], t.push(e);
1789
+ else for (let t = 0; t < e.length; t++) n(e[t]);
1790
+ else for (let t in e) n(e[t]);
1791
+ }
1792
+ return n(e), t;
1793
+ }
1794
+ function O(e, t, n, r) {
1795
+ if (typeof t == "string") return { dom: e.createTextNode(t) };
1796
+ if (t.nodeType != null) return { dom: t };
1797
+ if (t.dom && t.dom.nodeType != null) return t;
1798
+ let i = t[0], a;
1799
+ if (typeof i != "string") throw RangeError("Invalid array passed to renderSpec");
1800
+ if (r && (a = qe(r)) && a.indexOf(t) > -1) throw RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");
1801
+ let o = i.indexOf(" ");
1802
+ o > 0 && (n = i.slice(0, o), i = i.slice(o + 1));
1803
+ let s, c = n ? e.createElementNS(n, i) : e.createElement(i), l = t[1], u = 1;
1804
+ if (l && typeof l == "object" && l.nodeType == null && !Array.isArray(l)) {
1805
+ u = 2;
1806
+ for (let e in l) if (l[e] != null) {
1807
+ let t = e.indexOf(" ");
1808
+ t > 0 ? c.setAttributeNS(e.slice(0, t), e.slice(t + 1), l[e]) : e == "style" && c.style ? c.style.cssText = l[e] : c.setAttribute(e, l[e]);
1809
+ }
1810
+ }
1811
+ for (let i = u; i < t.length; i++) {
1812
+ let a = t[i];
1813
+ if (a === 0) {
1814
+ if (i < t.length - 1 || i > u) throw RangeError("Content hole must be the only child of its parent node");
1815
+ return {
1816
+ dom: c,
1817
+ contentDOM: c
1818
+ };
1819
+ } else {
1820
+ let { dom: t, contentDOM: i } = O(e, a, n, r);
1821
+ if (c.appendChild(t), i) {
1822
+ if (s) throw RangeError("Multiple content holes");
1823
+ s = i;
1824
+ }
1825
+ }
1826
+ }
1827
+ return {
1828
+ dom: c,
1829
+ contentDOM: s
1830
+ };
1831
+ }
1832
+ //#endregion
1833
+ //#region node_modules/.pnpm/prosemirror-transform@1.12.0/node_modules/prosemirror-transform/dist/index.js
1834
+ var Ye = 65535, Xe = 2 ** 16;
1835
+ function Ze(e, t) {
1836
+ return e + t * Xe;
1837
+ }
1838
+ function Qe(e) {
1839
+ return e & Ye;
1840
+ }
1841
+ function $e(e) {
1842
+ return (e - (e & Ye)) / Xe;
1843
+ }
1844
+ var et = 1, tt = 2, k = 4, nt = 8, rt = class {
1845
+ constructor(e, t, n) {
1846
+ this.pos = e, this.delInfo = t, this.recover = n;
1847
+ }
1848
+ get deleted() {
1849
+ return (this.delInfo & nt) > 0;
1850
+ }
1851
+ get deletedBefore() {
1852
+ return (this.delInfo & (et | k)) > 0;
1853
+ }
1854
+ get deletedAfter() {
1855
+ return (this.delInfo & (tt | k)) > 0;
1856
+ }
1857
+ get deletedAcross() {
1858
+ return (this.delInfo & k) > 0;
1859
+ }
1860
+ }, A = class e {
1861
+ constructor(t, n = !1) {
1862
+ if (this.ranges = t, this.inverted = n, !t.length && e.empty) return e.empty;
1863
+ }
1864
+ recover(e) {
1865
+ let t = 0, n = Qe(e);
1866
+ if (!this.inverted) for (let e = 0; e < n; e++) t += this.ranges[e * 3 + 2] - this.ranges[e * 3 + 1];
1867
+ return this.ranges[n * 3] + t + $e(e);
1868
+ }
1869
+ mapResult(e, t = 1) {
1870
+ return this._map(e, t, !1);
1871
+ }
1872
+ map(e, t = 1) {
1873
+ return this._map(e, t, !0);
1874
+ }
1875
+ _map(e, t, n) {
1876
+ let r = 0, i = this.inverted ? 2 : 1, a = this.inverted ? 1 : 2;
1877
+ for (let o = 0; o < this.ranges.length; o += 3) {
1878
+ let s = this.ranges[o] - (this.inverted ? r : 0);
1879
+ if (s > e) break;
1880
+ let c = this.ranges[o + i], l = this.ranges[o + a], u = s + c;
1881
+ if (e <= u) {
1882
+ let i = c ? e == s ? -1 : e == u ? 1 : t : t, a = s + r + (i < 0 ? 0 : l);
1883
+ if (n) return a;
1884
+ let d = e == (t < 0 ? s : u) ? null : Ze(o / 3, e - s), f = e == s ? tt : e == u ? et : k;
1885
+ return (t < 0 ? e != s : e != u) && (f |= nt), new rt(a, f, d);
1886
+ }
1887
+ r += l - c;
1888
+ }
1889
+ return n ? e + r : new rt(e + r, 0, null);
1890
+ }
1891
+ touches(e, t) {
1892
+ let n = 0, r = Qe(t), i = this.inverted ? 2 : 1, a = this.inverted ? 1 : 2;
1893
+ for (let t = 0; t < this.ranges.length; t += 3) {
1894
+ let o = this.ranges[t] - (this.inverted ? n : 0);
1895
+ if (o > e) break;
1896
+ let s = this.ranges[t + i];
1897
+ if (e <= o + s && t == r * 3) return !0;
1898
+ n += this.ranges[t + a] - s;
1899
+ }
1900
+ return !1;
1901
+ }
1902
+ forEach(e) {
1903
+ let t = this.inverted ? 2 : 1, n = this.inverted ? 1 : 2;
1904
+ for (let r = 0, i = 0; r < this.ranges.length; r += 3) {
1905
+ let a = this.ranges[r], o = a - (this.inverted ? i : 0), s = a + (this.inverted ? 0 : i), c = this.ranges[r + t], l = this.ranges[r + n];
1906
+ e(o, o + c, s, s + l), i += l - c;
1907
+ }
1908
+ }
1909
+ invert() {
1910
+ return new e(this.ranges, !this.inverted);
1911
+ }
1912
+ toString() {
1913
+ return (this.inverted ? "-" : "") + JSON.stringify(this.ranges);
1914
+ }
1915
+ static offset(t) {
1916
+ return t == 0 ? e.empty : new e(t < 0 ? [
1917
+ 0,
1918
+ -t,
1919
+ 0
1920
+ ] : [
1921
+ 0,
1922
+ 0,
1923
+ t
1924
+ ]);
1925
+ }
1926
+ };
1927
+ A.empty = new A([]);
1928
+ var it = class e {
1929
+ constructor(e, t, n = 0, r = e ? e.length : 0) {
1930
+ this.mirror = t, this.from = n, this.to = r, this._maps = e || [], this.ownData = !(e || t);
1931
+ }
1932
+ get maps() {
1933
+ return this._maps;
1934
+ }
1935
+ slice(t = 0, n = this.maps.length) {
1936
+ return new e(this._maps, this.mirror, t, n);
1937
+ }
1938
+ appendMap(e, t) {
1939
+ this.ownData ||= (this._maps = this._maps.slice(), this.mirror = this.mirror && this.mirror.slice(), !0), this.to = this._maps.push(e), t != null && this.setMirror(this._maps.length - 1, t);
1940
+ }
1941
+ appendMapping(e) {
1942
+ for (let t = 0, n = this._maps.length; t < e._maps.length; t++) {
1943
+ let r = e.getMirror(t);
1944
+ this.appendMap(e._maps[t], r != null && r < t ? n + r : void 0);
1945
+ }
1946
+ }
1947
+ getMirror(e) {
1948
+ if (this.mirror) {
1949
+ for (let t = 0; t < this.mirror.length; t++) if (this.mirror[t] == e) return this.mirror[t + (t % 2 ? -1 : 1)];
1950
+ }
1951
+ }
1952
+ setMirror(e, t) {
1953
+ this.mirror ||= [], this.mirror.push(e, t);
1954
+ }
1955
+ appendMappingInverted(e) {
1956
+ for (let t = e.maps.length - 1, n = this._maps.length + e._maps.length; t >= 0; t--) {
1957
+ let r = e.getMirror(t);
1958
+ this.appendMap(e._maps[t].invert(), r != null && r > t ? n - r - 1 : void 0);
1959
+ }
1960
+ }
1961
+ invert() {
1962
+ let t = new e();
1963
+ return t.appendMappingInverted(this), t;
1964
+ }
1965
+ map(e, t = 1) {
1966
+ if (this.mirror) return this._map(e, t, !0);
1967
+ for (let n = this.from; n < this.to; n++) e = this._maps[n].map(e, t);
1968
+ return e;
1969
+ }
1970
+ mapResult(e, t = 1) {
1971
+ return this._map(e, t, !1);
1972
+ }
1973
+ _map(e, t, n) {
1974
+ let r = 0;
1975
+ for (let n = this.from; n < this.to; n++) {
1976
+ let i = this._maps[n].mapResult(e, t);
1977
+ if (i.recover != null) {
1978
+ let t = this.getMirror(n);
1979
+ if (t != null && t > n && t < this.to) {
1980
+ n = t, e = this._maps[t].recover(i.recover);
1981
+ continue;
1982
+ }
1983
+ }
1984
+ r |= i.delInfo, e = i.pos;
1985
+ }
1986
+ return n ? e : new rt(e, r, null);
1987
+ }
1988
+ }, j = Object.create(null), M = class {
1989
+ getMap() {
1990
+ return A.empty;
1991
+ }
1992
+ merge(e) {
1993
+ return null;
1994
+ }
1995
+ static fromJSON(e, t) {
1996
+ if (!t || !t.stepType) throw RangeError("Invalid input for Step.fromJSON");
1997
+ let n = j[t.stepType];
1998
+ if (!n) throw RangeError(`No step type ${t.stepType} defined`);
1999
+ return n.fromJSON(e, t);
2000
+ }
2001
+ static jsonID(e, t) {
2002
+ if (e in j) throw RangeError("Duplicate use of step JSON ID " + e);
2003
+ return j[e] = t, t.prototype.jsonID = e, t;
2004
+ }
2005
+ }, N = class e {
2006
+ constructor(e, t) {
2007
+ this.doc = e, this.failed = t;
2008
+ }
2009
+ static ok(t) {
2010
+ return new e(t, null);
2011
+ }
2012
+ static fail(t) {
2013
+ return new e(null, t);
2014
+ }
2015
+ static fromReplace(t, n, r, i) {
2016
+ try {
2017
+ return e.ok(t.replace(n, r, i));
2018
+ } catch (t) {
2019
+ if (t instanceof c) return e.fail(t.message);
2020
+ throw t;
2021
+ }
2022
+ }
2023
+ };
2024
+ function at(e, t, n) {
2025
+ let i = [];
2026
+ for (let r = 0; r < e.childCount; r++) {
2027
+ let a = e.child(r);
2028
+ a.content.size && (a = a.copy(at(a.content, t, a))), a.isInline && (a = t(a, n, r)), i.push(a);
2029
+ }
2030
+ return r.fromArray(i);
2031
+ }
2032
+ var P = class e extends M {
2033
+ constructor(e, t, n) {
2034
+ super(), this.from = e, this.to = t, this.mark = n;
2035
+ }
2036
+ apply(e) {
2037
+ let t = e.slice(this.from, this.to), n = e.resolve(this.from), r = n.node(n.sharedDepth(this.to)), i = new l(at(t.content, (e, t) => !e.isAtom || !t.type.allowsMarkType(this.mark.type) ? e : e.mark(this.mark.addToSet(e.marks)), r), t.openStart, t.openEnd);
2038
+ return N.fromReplace(e, this.from, this.to, i);
2039
+ }
2040
+ invert() {
2041
+ return new F(this.from, this.to, this.mark);
2042
+ }
2043
+ map(t) {
2044
+ let n = t.mapResult(this.from, 1), r = t.mapResult(this.to, -1);
2045
+ return n.deleted && r.deleted || n.pos >= r.pos ? null : new e(n.pos, r.pos, this.mark);
2046
+ }
2047
+ merge(t) {
2048
+ return t instanceof e && t.mark.eq(this.mark) && this.from <= t.to && this.to >= t.from ? new e(Math.min(this.from, t.from), Math.max(this.to, t.to), this.mark) : null;
2049
+ }
2050
+ toJSON() {
2051
+ return {
2052
+ stepType: "addMark",
2053
+ mark: this.mark.toJSON(),
2054
+ from: this.from,
2055
+ to: this.to
2056
+ };
2057
+ }
2058
+ static fromJSON(t, n) {
2059
+ if (typeof n.from != "number" || typeof n.to != "number") throw RangeError("Invalid input for AddMarkStep.fromJSON");
2060
+ return new e(n.from, n.to, t.markFromJSON(n.mark));
2061
+ }
2062
+ };
2063
+ M.jsonID("addMark", P);
2064
+ var F = class e extends M {
2065
+ constructor(e, t, n) {
2066
+ super(), this.from = e, this.to = t, this.mark = n;
2067
+ }
2068
+ apply(e) {
2069
+ let t = e.slice(this.from, this.to), n = new l(at(t.content, (e) => e.mark(this.mark.removeFromSet(e.marks)), e), t.openStart, t.openEnd);
2070
+ return N.fromReplace(e, this.from, this.to, n);
2071
+ }
2072
+ invert() {
2073
+ return new P(this.from, this.to, this.mark);
2074
+ }
2075
+ map(t) {
2076
+ let n = t.mapResult(this.from, 1), r = t.mapResult(this.to, -1);
2077
+ return n.deleted && r.deleted || n.pos >= r.pos ? null : new e(n.pos, r.pos, this.mark);
2078
+ }
2079
+ merge(t) {
2080
+ return t instanceof e && t.mark.eq(this.mark) && this.from <= t.to && this.to >= t.from ? new e(Math.min(this.from, t.from), Math.max(this.to, t.to), this.mark) : null;
2081
+ }
2082
+ toJSON() {
2083
+ return {
2084
+ stepType: "removeMark",
2085
+ mark: this.mark.toJSON(),
2086
+ from: this.from,
2087
+ to: this.to
2088
+ };
2089
+ }
2090
+ static fromJSON(t, n) {
2091
+ if (typeof n.from != "number" || typeof n.to != "number") throw RangeError("Invalid input for RemoveMarkStep.fromJSON");
2092
+ return new e(n.from, n.to, t.markFromJSON(n.mark));
2093
+ }
2094
+ };
2095
+ M.jsonID("removeMark", F);
2096
+ var I = class e extends M {
2097
+ constructor(e, t) {
2098
+ super(), this.pos = e, this.mark = t;
2099
+ }
2100
+ apply(e) {
2101
+ let t = e.nodeAt(this.pos);
2102
+ if (!t) return N.fail("No node at mark step's position");
2103
+ let n = t.type.create(t.attrs, null, this.mark.addToSet(t.marks));
2104
+ return N.fromReplace(e, this.pos, this.pos + 1, new l(r.from(n), 0, +!t.isLeaf));
2105
+ }
2106
+ invert(t) {
2107
+ let n = t.nodeAt(this.pos);
2108
+ if (n) {
2109
+ let t = this.mark.addToSet(n.marks);
2110
+ if (t.length == n.marks.length) {
2111
+ for (let r = 0; r < n.marks.length; r++) if (!n.marks[r].isInSet(t)) return new e(this.pos, n.marks[r]);
2112
+ return new e(this.pos, this.mark);
2113
+ }
2114
+ }
2115
+ return new L(this.pos, this.mark);
2116
+ }
2117
+ map(t) {
2118
+ let n = t.mapResult(this.pos, 1);
2119
+ return n.deletedAfter ? null : new e(n.pos, this.mark);
2120
+ }
2121
+ toJSON() {
2122
+ return {
2123
+ stepType: "addNodeMark",
2124
+ pos: this.pos,
2125
+ mark: this.mark.toJSON()
2126
+ };
2127
+ }
2128
+ static fromJSON(t, n) {
2129
+ if (typeof n.pos != "number") throw RangeError("Invalid input for AddNodeMarkStep.fromJSON");
2130
+ return new e(n.pos, t.markFromJSON(n.mark));
2131
+ }
2132
+ };
2133
+ M.jsonID("addNodeMark", I);
2134
+ var L = class e extends M {
2135
+ constructor(e, t) {
2136
+ super(), this.pos = e, this.mark = t;
2137
+ }
2138
+ apply(e) {
2139
+ let t = e.nodeAt(this.pos);
2140
+ if (!t) return N.fail("No node at mark step's position");
2141
+ let n = t.type.create(t.attrs, null, this.mark.removeFromSet(t.marks));
2142
+ return N.fromReplace(e, this.pos, this.pos + 1, new l(r.from(n), 0, +!t.isLeaf));
2143
+ }
2144
+ invert(e) {
2145
+ let t = e.nodeAt(this.pos);
2146
+ return !t || !this.mark.isInSet(t.marks) ? this : new I(this.pos, this.mark);
2147
+ }
2148
+ map(t) {
2149
+ let n = t.mapResult(this.pos, 1);
2150
+ return n.deletedAfter ? null : new e(n.pos, this.mark);
2151
+ }
2152
+ toJSON() {
2153
+ return {
2154
+ stepType: "removeNodeMark",
2155
+ pos: this.pos,
2156
+ mark: this.mark.toJSON()
2157
+ };
2158
+ }
2159
+ static fromJSON(t, n) {
2160
+ if (typeof n.pos != "number") throw RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");
2161
+ return new e(n.pos, t.markFromJSON(n.mark));
2162
+ }
2163
+ };
2164
+ M.jsonID("removeNodeMark", L);
2165
+ var R = class e extends M {
2166
+ constructor(e, t, n, r = !1) {
2167
+ super(), this.from = e, this.to = t, this.slice = n, this.structure = r;
2168
+ }
2169
+ apply(e) {
2170
+ return this.structure && ot(e, this.from, this.to) ? N.fail("Structure replace would overwrite content") : N.fromReplace(e, this.from, this.to, this.slice);
2171
+ }
2172
+ getMap() {
2173
+ return new A([
2174
+ this.from,
2175
+ this.to - this.from,
2176
+ this.slice.size
2177
+ ]);
2178
+ }
2179
+ invert(t) {
2180
+ return new e(this.from, this.from + this.slice.size, t.slice(this.from, this.to));
2181
+ }
2182
+ map(t) {
2183
+ let n = t.mapResult(this.to, -1), r = this.from == this.to && e.MAP_BIAS < 0 ? n : t.mapResult(this.from, 1);
2184
+ return r.deletedAcross && n.deletedAcross ? null : new e(r.pos, Math.max(r.pos, n.pos), this.slice, this.structure);
2185
+ }
2186
+ merge(t) {
2187
+ if (!(t instanceof e) || t.structure || this.structure) return null;
2188
+ if (this.from + this.slice.size == t.from && !this.slice.openEnd && !t.slice.openStart) {
2189
+ let n = this.slice.size + t.slice.size == 0 ? l.empty : new l(this.slice.content.append(t.slice.content), this.slice.openStart, t.slice.openEnd);
2190
+ return new e(this.from, this.to + (t.to - t.from), n, this.structure);
2191
+ } else if (t.to == this.from && !this.slice.openStart && !t.slice.openEnd) {
2192
+ let n = this.slice.size + t.slice.size == 0 ? l.empty : new l(t.slice.content.append(this.slice.content), t.slice.openStart, this.slice.openEnd);
2193
+ return new e(t.from, this.to, n, this.structure);
2194
+ } else return null;
2195
+ }
2196
+ toJSON() {
2197
+ let e = {
2198
+ stepType: "replace",
2199
+ from: this.from,
2200
+ to: this.to
2201
+ };
2202
+ return this.slice.size && (e.slice = this.slice.toJSON()), this.structure && (e.structure = !0), e;
2203
+ }
2204
+ static fromJSON(t, n) {
2205
+ if (typeof n.from != "number" || typeof n.to != "number") throw RangeError("Invalid input for ReplaceStep.fromJSON");
2206
+ return new e(n.from, n.to, l.fromJSON(t, n.slice), !!n.structure);
2207
+ }
2208
+ };
2209
+ R.MAP_BIAS = 1, M.jsonID("replace", R);
2210
+ var z = class e extends M {
2211
+ constructor(e, t, n, r, i, a, o = !1) {
2212
+ super(), this.from = e, this.to = t, this.gapFrom = n, this.gapTo = r, this.slice = i, this.insert = a, this.structure = o;
2213
+ }
2214
+ apply(e) {
2215
+ if (this.structure && (ot(e, this.from, this.gapFrom) || ot(e, this.gapTo, this.to))) return N.fail("Structure gap-replace would overwrite content");
2216
+ let t = e.slice(this.gapFrom, this.gapTo);
2217
+ if (t.openStart || t.openEnd) return N.fail("Gap is not a flat range");
2218
+ let n = this.slice.insertAt(this.insert, t.content);
2219
+ return n ? N.fromReplace(e, this.from, this.to, n) : N.fail("Content does not fit in gap");
2220
+ }
2221
+ getMap() {
2222
+ return new A([
2223
+ this.from,
2224
+ this.gapFrom - this.from,
2225
+ this.insert,
2226
+ this.gapTo,
2227
+ this.to - this.gapTo,
2228
+ this.slice.size - this.insert
2229
+ ]);
2230
+ }
2231
+ invert(t) {
2232
+ let n = this.gapTo - this.gapFrom;
2233
+ return new e(this.from, this.from + this.slice.size + n, this.from + this.insert, this.from + this.insert + n, t.slice(this.from, this.to).removeBetween(this.gapFrom - this.from, this.gapTo - this.from), this.gapFrom - this.from, this.structure);
2234
+ }
2235
+ map(t) {
2236
+ let n = t.mapResult(this.from, 1), r = t.mapResult(this.to, -1), i = this.from == this.gapFrom ? n.pos : t.map(this.gapFrom, -1), a = this.to == this.gapTo ? r.pos : t.map(this.gapTo, 1);
2237
+ return n.deletedAcross && r.deletedAcross || i < n.pos || a > r.pos ? null : new e(n.pos, r.pos, i, a, this.slice, this.insert, this.structure);
2238
+ }
2239
+ toJSON() {
2240
+ let e = {
2241
+ stepType: "replaceAround",
2242
+ from: this.from,
2243
+ to: this.to,
2244
+ gapFrom: this.gapFrom,
2245
+ gapTo: this.gapTo,
2246
+ insert: this.insert
2247
+ };
2248
+ return this.slice.size && (e.slice = this.slice.toJSON()), this.structure && (e.structure = !0), e;
2249
+ }
2250
+ static fromJSON(t, n) {
2251
+ if (typeof n.from != "number" || typeof n.to != "number" || typeof n.gapFrom != "number" || typeof n.gapTo != "number" || typeof n.insert != "number") throw RangeError("Invalid input for ReplaceAroundStep.fromJSON");
2252
+ return new e(n.from, n.to, n.gapFrom, n.gapTo, l.fromJSON(t, n.slice), n.insert, !!n.structure);
2253
+ }
2254
+ };
2255
+ M.jsonID("replaceAround", z);
2256
+ function ot(e, t, n) {
2257
+ let r = e.resolve(t), i = n - t, a = r.depth;
2258
+ for (; i > 0 && a > 0 && r.indexAfter(a) == r.node(a).childCount;) a--, i--;
2259
+ if (i > 0) {
2260
+ let e = r.node(a).maybeChild(r.indexAfter(a));
2261
+ for (; i > 0;) {
2262
+ if (!e || e.isLeaf) return !0;
2263
+ e = e.firstChild, i--;
2264
+ }
2265
+ }
2266
+ return !1;
2267
+ }
2268
+ function st(e, t, n, r) {
2269
+ let i = [], a = [], o, s;
2270
+ e.doc.nodesBetween(t, n, (e, c, l) => {
2271
+ if (!e.isInline) return;
2272
+ let u = e.marks;
2273
+ if (!r.isInSet(u) && l.type.allowsMarkType(r.type)) {
2274
+ let l = Math.max(c, t), d = Math.min(c + e.nodeSize, n), f = r.addToSet(u);
2275
+ for (let e = 0; e < u.length; e++) u[e].isInSet(f) || (o && o.to == l && o.mark.eq(u[e]) ? o.to = d : i.push(o = new F(l, d, u[e])));
2276
+ s && s.to == l ? s.to = d : a.push(s = new P(l, d, r));
2277
+ }
2278
+ }), i.forEach((t) => e.step(t)), a.forEach((t) => e.step(t));
2279
+ }
2280
+ function ct(e, t, n, r) {
2281
+ let i = [], a = 0;
2282
+ e.doc.nodesBetween(t, n, (e, o) => {
2283
+ if (!e.isInline) return;
2284
+ a++;
2285
+ let s = null;
2286
+ if (r instanceof ke) {
2287
+ let t = e.marks, n;
2288
+ for (; n = r.isInSet(t);) (s ||= []).push(n), t = n.removeFromSet(t);
2289
+ } else r ? r.isInSet(e.marks) && (s = [r]) : s = e.marks;
2290
+ if (s && s.length) {
2291
+ let r = Math.min(o + e.nodeSize, n);
2292
+ for (let e = 0; e < s.length; e++) {
2293
+ let n = s[e], c;
2294
+ for (let e = 0; e < i.length; e++) {
2295
+ let t = i[e];
2296
+ t.step == a - 1 && n.eq(i[e].style) && (c = t);
2297
+ }
2298
+ c ? (c.to = r, c.step = a) : i.push({
2299
+ style: n,
2300
+ from: Math.max(o, t),
2301
+ to: r,
2302
+ step: a
2303
+ });
2304
+ }
2305
+ }
2306
+ }), i.forEach((t) => e.step(new F(t.from, t.to, t.style)));
2307
+ }
2308
+ function lt(e, t, n, i = n.contentMatch, a = !0) {
2309
+ let o = e.doc.nodeAt(t), s = [], c = t + 1;
2310
+ for (let t = 0; t < o.childCount; t++) {
2311
+ let u = o.child(t), d = c + u.nodeSize, f = i.matchType(u.type);
2312
+ if (!f) s.push(new R(c, d, l.empty));
2313
+ else {
2314
+ i = f;
2315
+ for (let t = 0; t < u.marks.length; t++) n.allowsMarkType(u.marks[t].type) || e.step(new F(c, d, u.marks[t]));
2316
+ if (a && u.isText && n.whitespace != "pre") {
2317
+ let e, t = /\r?\n|\r/g, i;
2318
+ for (; e = t.exec(u.text);) i ||= new l(r.from(n.schema.text(" ", n.allowedMarks(u.marks))), 0, 0), s.push(new R(c + e.index, c + e.index + e[0].length, i));
2319
+ }
2320
+ }
2321
+ c = d;
2322
+ }
2323
+ if (!i.validEnd) {
2324
+ let t = i.fillBefore(r.empty, !0);
2325
+ e.replace(c, c, new l(t, 0, 0));
2326
+ }
2327
+ for (let t = s.length - 1; t >= 0; t--) e.step(s[t]);
2328
+ }
2329
+ function ut(e, t, n) {
2330
+ return (t == 0 || e.canReplace(t, e.childCount)) && (n == e.childCount || e.canReplace(0, n));
2331
+ }
2332
+ function dt(e) {
2333
+ let t = e.parent.content.cutByIndex(e.startIndex, e.endIndex);
2334
+ for (let n = e.depth, r = 0, i = 0;; --n) {
2335
+ let a = e.$from.node(n), o = e.$from.index(n) + r, s = e.$to.indexAfter(n) - i;
2336
+ if (n < e.depth && a.canReplace(o, s, t)) return n;
2337
+ if (n == 0 || a.type.spec.isolating || !ut(a, o, s)) break;
2338
+ o && (r = 1), s < a.childCount && (i = 1);
2339
+ }
2340
+ return null;
2341
+ }
2342
+ function ft(e, t, n) {
2343
+ let { $from: i, $to: a, depth: o } = t, s = i.before(o + 1), c = a.after(o + 1), u = s, d = c, f = r.empty, p = 0;
2344
+ for (let e = o, t = !1; e > n; e--) t || i.index(e) > 0 ? (t = !0, f = r.from(i.node(e).copy(f)), p++) : u--;
2345
+ let m = r.empty, h = 0;
2346
+ for (let e = o, t = !1; e > n; e--) t || a.after(e + 1) < a.end(e) ? (t = !0, m = r.from(a.node(e).copy(m)), h++) : d++;
2347
+ e.step(new z(u, d, s, c, new l(f.append(m), p, h), f.size - p, !0));
2348
+ }
2349
+ function pt(e, t, n = null, r = e) {
2350
+ let i = ht(e, t), a = i && gt(r, t);
2351
+ return a ? i.map(mt).concat({
2352
+ type: t,
2353
+ attrs: n
2354
+ }).concat(a.map(mt)) : null;
2355
+ }
2356
+ function mt(e) {
2357
+ return {
2358
+ type: e,
2359
+ attrs: null
2360
+ };
2361
+ }
2362
+ function ht(e, t) {
2363
+ let { parent: n, startIndex: r, endIndex: i } = e, a = n.contentMatchAt(r).findWrapping(t);
2364
+ if (!a) return null;
2365
+ let o = a.length ? a[0] : t;
2366
+ return n.canReplaceWith(r, i, o) ? a : null;
2367
+ }
2368
+ function gt(e, t) {
2369
+ let { parent: n, startIndex: r, endIndex: i } = e, a = n.child(r), o = t.contentMatch.findWrapping(a.type);
2370
+ if (!o) return null;
2371
+ let s = (o.length ? o[o.length - 1] : t).contentMatch;
2372
+ for (let e = r; s && e < i; e++) s = s.matchType(n.child(e).type);
2373
+ return !s || !s.validEnd ? null : o;
2374
+ }
2375
+ function _t(e, t, n) {
2376
+ let i = r.empty;
2377
+ for (let e = n.length - 1; e >= 0; e--) {
2378
+ if (i.size) {
2379
+ let t = n[e].type.contentMatch.matchFragment(i);
2380
+ if (!t || !t.validEnd) throw RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper");
2381
+ }
2382
+ i = r.from(n[e].type.create(n[e].attrs, i));
2383
+ }
2384
+ let a = t.start, o = t.end;
2385
+ e.step(new z(a, o, a, o, new l(i, 0, 0), n.length, !0));
2386
+ }
2387
+ function vt(e, t, n, i, a) {
2388
+ if (!i.isTextblock) throw RangeError("Type given to setBlockType should be a textblock");
2389
+ let o = e.steps.length;
2390
+ e.doc.nodesBetween(t, n, (t, n) => {
2391
+ let s = typeof a == "function" ? a(t) : a;
2392
+ if (t.isTextblock && !t.hasMarkup(i, s) && xt(e.doc, e.mapping.slice(o).map(n), i)) {
2393
+ let a = null;
2394
+ if (i.schema.linebreakReplacement) {
2395
+ let e = i.whitespace == "pre", t = !!i.contentMatch.matchType(i.schema.linebreakReplacement);
2396
+ e && !t ? a = !1 : !e && t && (a = !0);
2397
+ }
2398
+ a === !1 && bt(e, t, n, o), lt(e, e.mapping.slice(o).map(n, 1), i, void 0, a === null);
2399
+ let c = e.mapping.slice(o), u = c.map(n, 1), d = c.map(n + t.nodeSize, 1);
2400
+ return e.step(new z(u, d, u + 1, d - 1, new l(r.from(i.create(s, null, t.marks)), 0, 0), 1, !0)), a === !0 && yt(e, t, n, o), !1;
2401
+ }
2402
+ });
2403
+ }
2404
+ function yt(e, t, n, r) {
2405
+ t.forEach((i, a) => {
2406
+ if (i.isText) {
2407
+ let o, s = /\r?\n|\r/g;
2408
+ for (; o = s.exec(i.text);) {
2409
+ let i = e.mapping.slice(r).map(n + 1 + a + o.index);
2410
+ e.replaceWith(i, i + 1, t.type.schema.linebreakReplacement.create());
2411
+ }
2412
+ }
2413
+ });
2414
+ }
2415
+ function bt(e, t, n, r) {
2416
+ t.forEach((i, a) => {
2417
+ if (i.type == i.type.schema.linebreakReplacement) {
2418
+ let i = e.mapping.slice(r).map(n + 1 + a);
2419
+ e.replaceWith(i, i + 1, t.type.schema.text("\n"));
2420
+ }
2421
+ });
2422
+ }
2423
+ function xt(e, t, n) {
2424
+ let r = e.resolve(t), i = r.index();
2425
+ return r.parent.canReplaceWith(i, i + 1, n);
2426
+ }
2427
+ function St(e, t, n, i, a) {
2428
+ let o = e.doc.nodeAt(t);
2429
+ if (!o) throw RangeError("No node at given position");
2430
+ n ||= o.type;
2431
+ let s = n.create(i, null, a || o.marks);
2432
+ if (o.isLeaf) return e.replaceWith(t, t + o.nodeSize, s);
2433
+ if (!n.validContent(o.content)) throw RangeError("Invalid content for node type " + n.name);
2434
+ e.step(new z(t, t + o.nodeSize, t + 1, t + o.nodeSize - 1, new l(r.from(s), 0, 0), 1, !0));
2435
+ }
2436
+ function Ct(e, t, n = 1, r) {
2437
+ let i = e.resolve(t), a = i.depth - n, o = r && r[r.length - 1] || i.parent;
2438
+ if (a < 0 || i.parent.type.spec.isolating || !i.parent.canReplace(i.index(), i.parent.childCount) || !o.type.validContent(i.parent.content.cutByIndex(i.index(), i.parent.childCount))) return !1;
2439
+ for (let e = i.depth - 1, t = n - 2; e > a; e--, t--) {
2440
+ let n = i.node(e), a = i.index(e);
2441
+ if (n.type.spec.isolating) return !1;
2442
+ let o = n.content.cutByIndex(a, n.childCount), s = r && r[t + 1];
2443
+ s && (o = o.replaceChild(0, s.type.create(s.attrs)));
2444
+ let c = r && r[t] || n;
2445
+ if (!n.canReplace(a + 1, n.childCount) || !c.type.validContent(o)) return !1;
2446
+ }
2447
+ let s = i.indexAfter(a), c = r && r[0];
2448
+ return i.node(a).canReplaceWith(s, s, c ? c.type : i.node(a + 1).type);
2449
+ }
2450
+ function wt(e, t, n = 1, i) {
2451
+ let a = e.doc.resolve(t), o = r.empty, s = r.empty;
2452
+ for (let e = a.depth, t = a.depth - n, c = n - 1; e > t; e--, c--) {
2453
+ o = r.from(a.node(e).copy(o));
2454
+ let t = i && i[c];
2455
+ s = r.from(t ? t.type.create(t.attrs, s) : a.node(e).copy(s));
2456
+ }
2457
+ e.step(new R(t, t, new l(o.append(s), n, n), !0));
2458
+ }
2459
+ function Tt(e, t) {
2460
+ let n = e.resolve(t), r = n.index();
2461
+ return Dt(n.nodeBefore, n.nodeAfter) && n.parent.canReplace(r, r + 1);
2462
+ }
2463
+ function Et(e, t) {
2464
+ t.content.size || e.type.compatibleContent(t.type);
2465
+ let n = e.contentMatchAt(e.childCount), { linebreakReplacement: r } = e.type.schema;
2466
+ for (let i = 0; i < t.childCount; i++) {
2467
+ let a = t.child(i), o = a.type == r ? e.type.schema.nodes.text : a.type;
2468
+ if (n = n.matchType(o), !n || !e.type.allowsMarks(a.marks)) return !1;
2469
+ }
2470
+ return n.validEnd;
2471
+ }
2472
+ function Dt(e, t) {
2473
+ return !!(e && t && !e.isLeaf && Et(e, t));
2474
+ }
2475
+ function Ot(e, t, n = -1) {
2476
+ let r = e.resolve(t);
2477
+ for (let e = r.depth;; e--) {
2478
+ let i, a, o = r.index(e);
2479
+ if (e == r.depth ? (i = r.nodeBefore, a = r.nodeAfter) : n > 0 ? (i = r.node(e + 1), o++, a = r.node(e).maybeChild(o)) : (i = r.node(e).maybeChild(o - 1), a = r.node(e + 1)), i && !i.isTextblock && Dt(i, a) && r.node(e).canReplace(o, o + 1)) return t;
2480
+ if (e == 0) break;
2481
+ t = n < 0 ? r.before(e) : r.after(e);
2482
+ }
2483
+ }
2484
+ function kt(e, t, n) {
2485
+ let r = null, { linebreakReplacement: i } = e.doc.type.schema, a = e.doc.resolve(t - n), o = a.node().type;
2486
+ if (i && o.inlineContent) {
2487
+ let e = o.whitespace == "pre", t = !!o.contentMatch.matchType(i);
2488
+ e && !t ? r = !1 : !e && t && (r = !0);
2489
+ }
2490
+ let s = e.steps.length;
2491
+ if (r === !1) {
2492
+ let r = e.doc.resolve(t + n);
2493
+ bt(e, r.node(), r.before(), s);
2494
+ }
2495
+ o.inlineContent && lt(e, t + n - 1, o, a.node().contentMatchAt(a.index()), r == null);
2496
+ let c = e.mapping.slice(s), u = c.map(t - n);
2497
+ if (e.step(new R(u, c.map(t + n, -1), l.empty, !0)), r === !0) {
2498
+ let t = e.doc.resolve(u);
2499
+ yt(e, t.node(), t.before(), e.steps.length);
2500
+ }
2501
+ return e;
2502
+ }
2503
+ function At(e, t, n) {
2504
+ let r = e.resolve(t);
2505
+ if (r.parent.canReplaceWith(r.index(), r.index(), n)) return t;
2506
+ if (r.parentOffset == 0) for (let e = r.depth - 1; e >= 0; e--) {
2507
+ let t = r.index(e);
2508
+ if (r.node(e).canReplaceWith(t, t, n)) return r.before(e + 1);
2509
+ if (t > 0) return null;
2510
+ }
2511
+ if (r.parentOffset == r.parent.content.size) for (let e = r.depth - 1; e >= 0; e--) {
2512
+ let t = r.indexAfter(e);
2513
+ if (r.node(e).canReplaceWith(t, t, n)) return r.after(e + 1);
2514
+ if (t < r.node(e).childCount) return null;
2515
+ }
2516
+ return null;
2517
+ }
2518
+ function jt(e, t, n) {
2519
+ let r = e.resolve(t);
2520
+ if (!n.content.size) return t;
2521
+ let i = n.content;
2522
+ for (let e = 0; e < n.openStart; e++) i = i.firstChild.content;
2523
+ for (let e = 1; e <= (n.openStart == 0 && n.size ? 2 : 1); e++) for (let t = r.depth; t >= 0; t--) {
2524
+ let n = t == r.depth ? 0 : r.pos <= (r.start(t + 1) + r.end(t + 1)) / 2 ? -1 : 1, a = r.index(t) + +(n > 0), o = r.node(t), s = !1;
2525
+ if (e == 1) s = o.canReplace(a, a, i);
2526
+ else {
2527
+ let e = o.contentMatchAt(a).findWrapping(i.firstChild.type);
2528
+ s = e && o.canReplaceWith(a, a, e[0]);
2529
+ }
2530
+ if (s) return n == 0 ? r.pos : n < 0 ? r.before(t + 1) : r.after(t + 1);
2531
+ }
2532
+ return null;
2533
+ }
2534
+ function Mt(e, t, n = t, r = l.empty) {
2535
+ if (t == n && !r.size) return null;
2536
+ let i = e.resolve(t), a = e.resolve(n);
2537
+ return Nt(i, a, r) ? new R(t, n, r) : new Pt(i, a, r).fit();
2538
+ }
2539
+ function Nt(e, t, n) {
2540
+ return !n.openStart && !n.openEnd && e.start() == t.start() && e.parent.canReplace(e.index(), t.index(), n.content);
2541
+ }
2542
+ var Pt = class {
2543
+ constructor(e, t, n) {
2544
+ this.$from = e, this.$to = t, this.unplaced = n, this.frontier = [], this.placed = r.empty;
2545
+ for (let t = 0; t <= e.depth; t++) {
2546
+ let n = e.node(t);
2547
+ this.frontier.push({
2548
+ type: n.type,
2549
+ match: n.contentMatchAt(e.indexAfter(t))
2550
+ });
2551
+ }
2552
+ for (let t = e.depth; t > 0; t--) this.placed = r.from(e.node(t).copy(this.placed));
2553
+ }
2554
+ get depth() {
2555
+ return this.frontier.length - 1;
2556
+ }
2557
+ fit() {
2558
+ for (; this.unplaced.size;) {
2559
+ let e = this.findFittable();
2560
+ e ? this.placeNodes(e) : this.openMore() || this.dropNode();
2561
+ }
2562
+ let e = this.mustMoveInline(), t = this.placed.size - this.depth - this.$from.depth, n = this.$from, r = this.close(e < 0 ? this.$to : n.doc.resolve(e));
2563
+ if (!r) return null;
2564
+ let i = this.placed, a = n.depth, o = r.depth;
2565
+ for (; a && o && i.childCount == 1;) i = i.firstChild.content, a--, o--;
2566
+ let s = new l(i, a, o);
2567
+ return e > -1 ? new z(n.pos, e, this.$to.pos, this.$to.end(), s, t) : s.size || n.pos != this.$to.pos ? new R(n.pos, r.pos, s) : null;
2568
+ }
2569
+ findFittable() {
2570
+ let e = this.unplaced.openStart;
2571
+ for (let t = this.unplaced.content, n = 0, r = this.unplaced.openEnd; n < e; n++) {
2572
+ let i = t.firstChild;
2573
+ if (t.childCount > 1 && (r = 0), i.type.spec.isolating && r <= n) {
2574
+ e = n;
2575
+ break;
2576
+ }
2577
+ t = i.content;
2578
+ }
2579
+ for (let t = 1; t <= 2; t++) for (let n = t == 1 ? e : this.unplaced.openStart; n >= 0; n--) {
2580
+ let e, i = null;
2581
+ n ? (i = H(this.unplaced.content, n - 1).firstChild, e = i.content) : e = this.unplaced.content;
2582
+ let a = e.firstChild;
2583
+ for (let e = this.depth; e >= 0; e--) {
2584
+ let { type: o, match: s } = this.frontier[e], c, l = null;
2585
+ if (t == 1 && (a ? s.matchType(a.type) || (l = s.fillBefore(r.from(a), !1)) : i && o.compatibleContent(i.type))) return {
2586
+ sliceDepth: n,
2587
+ frontierDepth: e,
2588
+ parent: i,
2589
+ inject: l
2590
+ };
2591
+ if (t == 2 && a && (c = s.findWrapping(a.type))) return {
2592
+ sliceDepth: n,
2593
+ frontierDepth: e,
2594
+ parent: i,
2595
+ wrap: c
2596
+ };
2597
+ if (i && s.matchType(i.type)) break;
2598
+ }
2599
+ }
2600
+ }
2601
+ openMore() {
2602
+ let { content: e, openStart: t, openEnd: n } = this.unplaced, r = H(e, t);
2603
+ return !r.childCount || r.firstChild.isLeaf ? !1 : (this.unplaced = new l(e, t + 1, Math.max(n, r.size + t >= e.size - n ? t + 1 : 0)), !0);
2604
+ }
2605
+ dropNode() {
2606
+ let { content: e, openStart: t, openEnd: n } = this.unplaced, r = H(e, t);
2607
+ if (r.childCount <= 1 && t > 0) {
2608
+ let i = e.size - t <= t + r.size;
2609
+ this.unplaced = new l(B(e, t - 1, 1), t - 1, i ? t - 1 : n);
2610
+ } else this.unplaced = new l(B(e, t, 1), t, n);
2611
+ }
2612
+ placeNodes({ sliceDepth: e, frontierDepth: t, parent: n, inject: i, wrap: a }) {
2613
+ for (; this.depth > t;) this.closeFrontierNode();
2614
+ if (a) for (let e = 0; e < a.length; e++) this.openFrontierNode(a[e]);
2615
+ let o = this.unplaced, s = n ? n.content : o.content, c = o.openStart - e, u = 0, d = [], { match: f, type: p } = this.frontier[t];
2616
+ if (i) {
2617
+ for (let e = 0; e < i.childCount; e++) d.push(i.child(e));
2618
+ f = f.matchFragment(i);
2619
+ }
2620
+ let m = s.size + e - (o.content.size - o.openEnd);
2621
+ for (; u < s.childCount;) {
2622
+ let e = s.child(u), t = f.matchType(e.type);
2623
+ if (!t) break;
2624
+ u++, (u > 1 || c == 0 || e.content.size) && (f = t, d.push(Ft(e.mark(p.allowedMarks(e.marks)), u == 1 ? c : 0, u == s.childCount ? m : -1)));
2625
+ }
2626
+ let h = u == s.childCount;
2627
+ h || (m = -1), this.placed = V(this.placed, t, r.from(d)), this.frontier[t].match = f, h && m < 0 && n && n.type == this.frontier[this.depth].type && this.frontier.length > 1 && this.closeFrontierNode();
2628
+ for (let e = 0, t = s; e < m; e++) {
2629
+ let e = t.lastChild;
2630
+ this.frontier.push({
2631
+ type: e.type,
2632
+ match: e.contentMatchAt(e.childCount)
2633
+ }), t = e.content;
2634
+ }
2635
+ this.unplaced = h ? e == 0 ? l.empty : new l(B(o.content, e - 1, 1), e - 1, m < 0 ? o.openEnd : e - 1) : new l(B(o.content, e, u), o.openStart, o.openEnd);
2636
+ }
2637
+ mustMoveInline() {
2638
+ if (!this.$to.parent.isTextblock) return -1;
2639
+ let e = this.frontier[this.depth], t;
2640
+ if (!e.type.isTextblock || !U(this.$to, this.$to.depth, e.type, e.match, !1) || this.$to.depth == this.depth && (t = this.findCloseLevel(this.$to)) && t.depth == this.depth) return -1;
2641
+ let { depth: n } = this.$to, r = this.$to.after(n);
2642
+ for (; n > 1 && r == this.$to.end(--n);) ++r;
2643
+ return r;
2644
+ }
2645
+ findCloseLevel(e) {
2646
+ scan: for (let t = Math.min(this.depth, e.depth); t >= 0; t--) {
2647
+ let { match: n, type: r } = this.frontier[t], i = t < e.depth && e.end(t + 1) == e.pos + (e.depth - (t + 1)), a = U(e, t, r, n, i);
2648
+ if (a) {
2649
+ for (let n = t - 1; n >= 0; n--) {
2650
+ let { match: t, type: r } = this.frontier[n], i = U(e, n, r, t, !0);
2651
+ if (!i || i.childCount) continue scan;
2652
+ }
2653
+ return {
2654
+ depth: t,
2655
+ fit: a,
2656
+ move: i ? e.doc.resolve(e.after(t + 1)) : e
2657
+ };
2658
+ }
2659
+ }
2660
+ }
2661
+ close(e) {
2662
+ let t = this.findCloseLevel(e);
2663
+ if (!t) return null;
2664
+ for (; this.depth > t.depth;) this.closeFrontierNode();
2665
+ t.fit.childCount && (this.placed = V(this.placed, t.depth, t.fit)), e = t.move;
2666
+ for (let n = t.depth + 1; n <= e.depth; n++) {
2667
+ let t = e.node(n), r = t.type.contentMatch.fillBefore(t.content, !0, e.index(n));
2668
+ this.openFrontierNode(t.type, t.attrs, r);
2669
+ }
2670
+ return e;
2671
+ }
2672
+ openFrontierNode(e, t = null, n) {
2673
+ let i = this.frontier[this.depth];
2674
+ i.match = i.match.matchType(e), this.placed = V(this.placed, this.depth, r.from(e.create(t, n))), this.frontier.push({
2675
+ type: e,
2676
+ match: e.contentMatch
2677
+ });
2678
+ }
2679
+ closeFrontierNode() {
2680
+ let e = this.frontier.pop().match.fillBefore(r.empty, !0);
2681
+ e.childCount && (this.placed = V(this.placed, this.frontier.length, e));
2682
+ }
2683
+ };
2684
+ function B(e, t, n) {
2685
+ return t == 0 ? e.cutByIndex(n, e.childCount) : e.replaceChild(0, e.firstChild.copy(B(e.firstChild.content, t - 1, n)));
2686
+ }
2687
+ function V(e, t, n) {
2688
+ return t == 0 ? e.append(n) : e.replaceChild(e.childCount - 1, e.lastChild.copy(V(e.lastChild.content, t - 1, n)));
2689
+ }
2690
+ function H(e, t) {
2691
+ for (let n = 0; n < t; n++) e = e.firstChild.content;
2692
+ return e;
2693
+ }
2694
+ function Ft(e, t, n) {
2695
+ if (t <= 0) return e;
2696
+ let i = e.content;
2697
+ return t > 1 && (i = i.replaceChild(0, Ft(i.firstChild, t - 1, i.childCount == 1 ? n - 1 : 0))), t > 0 && (i = e.type.contentMatch.fillBefore(i).append(i), n <= 0 && (i = i.append(e.type.contentMatch.matchFragment(i).fillBefore(r.empty, !0)))), e.copy(i);
2698
+ }
2699
+ function U(e, t, n, r, i) {
2700
+ let a = e.node(t), o = i ? e.indexAfter(t) : e.index(t);
2701
+ if (o == a.childCount && !n.compatibleContent(a.type)) return null;
2702
+ let s = r.fillBefore(a.content, !0, o);
2703
+ return s && !It(n, a.content, o) ? s : null;
2704
+ }
2705
+ function It(e, t, n) {
2706
+ for (let r = n; r < t.childCount; r++) if (!e.allowsMarks(t.child(r).marks)) return !0;
2707
+ return !1;
2708
+ }
2709
+ function Lt(e) {
2710
+ return e.spec.defining || e.spec.definingForContent;
2711
+ }
2712
+ function Rt(e, t, n, r) {
2713
+ if (!r.size) return e.deleteRange(t, n);
2714
+ let i = e.doc.resolve(t), a = e.doc.resolve(n);
2715
+ if (Nt(i, a, r)) return e.step(new R(t, n, r));
2716
+ let o = Ht(i, a);
2717
+ o[o.length - 1] == 0 && o.pop();
2718
+ let s = -(i.depth + 1);
2719
+ o.unshift(s);
2720
+ for (let e = i.depth, t = i.pos - 1; e > 0; e--, t--) {
2721
+ let n = i.node(e).type.spec;
2722
+ if (n.defining || n.definingAsContext || n.isolating) break;
2723
+ o.indexOf(e) > -1 ? s = e : i.before(e) == t && o.splice(1, 0, -e);
2724
+ }
2725
+ let c = o.indexOf(s), u = [], d = r.openStart;
2726
+ for (let e = r.content, t = 0;; t++) {
2727
+ let n = e.firstChild;
2728
+ if (u.push(n), t == r.openStart) break;
2729
+ e = n.content;
2730
+ }
2731
+ for (let e = d - 1; e >= 0; e--) {
2732
+ let t = u[e], n = Lt(t.type);
2733
+ if (n && !t.sameMarkup(i.node(Math.abs(s) - 1))) d = e;
2734
+ else if (n || !t.type.isTextblock) break;
2735
+ }
2736
+ for (let t = r.openStart; t >= 0; t--) {
2737
+ let s = (t + d + 1) % (r.openStart + 1), f = u[s];
2738
+ if (f) for (let t = 0; t < o.length; t++) {
2739
+ let u = o[(t + c) % o.length], d = !0;
2740
+ u < 0 && (d = !1, u = -u);
2741
+ let p = i.node(u - 1), m = i.index(u - 1);
2742
+ if (p.canReplaceWith(m, m, f.type, f.marks)) return e.replace(i.before(u), d ? a.after(u) : n, new l(zt(r.content, 0, r.openStart, s), s, r.openEnd));
2743
+ }
2744
+ }
2745
+ let f = e.steps.length;
2746
+ for (let s = o.length - 1; s >= 0 && (e.replace(t, n, r), !(e.steps.length > f)); s--) {
2747
+ let e = o[s];
2748
+ e < 0 || (t = i.before(e), n = a.after(e));
2749
+ }
2750
+ }
2751
+ function zt(e, t, n, i, a) {
2752
+ if (t < n) {
2753
+ let r = e.firstChild;
2754
+ e = e.replaceChild(0, r.copy(zt(r.content, t + 1, n, i, r)));
2755
+ }
2756
+ if (t > i) {
2757
+ let t = a.contentMatchAt(0), n = t.fillBefore(e).append(e);
2758
+ e = n.append(t.matchFragment(n).fillBefore(r.empty, !0));
2759
+ }
2760
+ return e;
2761
+ }
2762
+ function Bt(e, t, n, i) {
2763
+ if (!i.isInline && t == n && e.doc.resolve(t).parent.content.size) {
2764
+ let r = At(e.doc, t, i.type);
2765
+ r != null && (t = n = r);
2766
+ }
2767
+ e.replaceRange(t, n, new l(r.from(i), 0, 0));
2768
+ }
2769
+ function Vt(e, t, n) {
2770
+ let r = e.doc.resolve(t), i = e.doc.resolve(n);
2771
+ if (r.parent.isTextblock && i.parent.isTextblock && r.start() != i.start() && r.parentOffset == 0 && i.parentOffset == 0) {
2772
+ let a = r.sharedDepth(n), o = !1;
2773
+ for (let e = r.depth; e > a; e--) r.node(e).type.spec.isolating && (o = !0);
2774
+ for (let e = i.depth; e > a; e--) i.node(e).type.spec.isolating && (o = !0);
2775
+ if (!o) {
2776
+ for (let e = r.depth; e > 0 && t == r.start(e); e--) t = r.before(e);
2777
+ for (let e = i.depth; e > 0 && n == i.start(e); e--) n = i.before(e);
2778
+ r = e.doc.resolve(t), i = e.doc.resolve(n);
2779
+ }
2780
+ }
2781
+ let a = Ht(r, i);
2782
+ for (let t = 0; t < a.length; t++) {
2783
+ let n = a[t], o = t == a.length - 1;
2784
+ if (o && n == 0 || r.node(n).type.contentMatch.validEnd) return e.delete(r.start(n), i.end(n));
2785
+ if (n > 0 && (o || r.node(n - 1).canReplace(r.index(n - 1), i.indexAfter(n - 1)))) return e.delete(r.before(n), i.after(n));
2786
+ }
2787
+ for (let a = 1; a <= r.depth && a <= i.depth; a++) if (t - r.start(a) == r.depth - a && n > r.end(a) && i.end(a) - n != i.depth - a && r.start(a - 1) == i.start(a - 1) && r.node(a - 1).canReplace(r.index(a - 1), i.index(a - 1))) return e.delete(r.before(a), n);
2788
+ e.delete(t, n);
2789
+ }
2790
+ function Ht(e, t) {
2791
+ let n = [], r = Math.min(e.depth, t.depth);
2792
+ for (let i = r; i >= 0; i--) {
2793
+ let r = e.start(i);
2794
+ if (r < e.pos - (e.depth - i) || t.end(i) > t.pos + (t.depth - i) || e.node(i).type.spec.isolating || t.node(i).type.spec.isolating) break;
2795
+ (r == t.start(i) || i == e.depth && i == t.depth && e.parent.inlineContent && t.parent.inlineContent && i && t.start(i - 1) == r - 1) && n.push(i);
2796
+ }
2797
+ return n;
2798
+ }
2799
+ var Ut = class e extends M {
2800
+ constructor(e, t, n) {
2801
+ super(), this.pos = e, this.attr = t, this.value = n;
2802
+ }
2803
+ apply(e) {
2804
+ let t = e.nodeAt(this.pos);
2805
+ if (!t) return N.fail("No node at attribute step's position");
2806
+ let n = Object.create(null);
2807
+ for (let e in t.attrs) n[e] = t.attrs[e];
2808
+ n[this.attr] = this.value;
2809
+ let i = t.type.create(n, null, t.marks);
2810
+ return N.fromReplace(e, this.pos, this.pos + 1, new l(r.from(i), 0, +!t.isLeaf));
2811
+ }
2812
+ getMap() {
2813
+ return A.empty;
2814
+ }
2815
+ invert(t) {
2816
+ return new e(this.pos, this.attr, t.nodeAt(this.pos).attrs[this.attr]);
2817
+ }
2818
+ map(t) {
2819
+ let n = t.mapResult(this.pos, 1);
2820
+ return n.deletedAfter ? null : new e(n.pos, this.attr, this.value);
2821
+ }
2822
+ toJSON() {
2823
+ return {
2824
+ stepType: "attr",
2825
+ pos: this.pos,
2826
+ attr: this.attr,
2827
+ value: this.value
2828
+ };
2829
+ }
2830
+ static fromJSON(t, n) {
2831
+ if (typeof n.pos != "number" || typeof n.attr != "string") throw RangeError("Invalid input for AttrStep.fromJSON");
2832
+ return new e(n.pos, n.attr, n.value);
2833
+ }
2834
+ };
2835
+ M.jsonID("attr", Ut);
2836
+ var Wt = class e extends M {
2837
+ constructor(e, t) {
2838
+ super(), this.attr = e, this.value = t;
2839
+ }
2840
+ apply(e) {
2841
+ let t = Object.create(null);
2842
+ for (let n in e.attrs) t[n] = e.attrs[n];
2843
+ t[this.attr] = this.value;
2844
+ let n = e.type.create(t, e.content, e.marks);
2845
+ return N.ok(n);
2846
+ }
2847
+ getMap() {
2848
+ return A.empty;
2849
+ }
2850
+ invert(t) {
2851
+ return new e(this.attr, t.attrs[this.attr]);
2852
+ }
2853
+ map(e) {
2854
+ return this;
2855
+ }
2856
+ toJSON() {
2857
+ return {
2858
+ stepType: "docAttr",
2859
+ attr: this.attr,
2860
+ value: this.value
2861
+ };
2862
+ }
2863
+ static fromJSON(t, n) {
2864
+ if (typeof n.attr != "string") throw RangeError("Invalid input for DocAttrStep.fromJSON");
2865
+ return new e(n.attr, n.value);
2866
+ }
2867
+ };
2868
+ M.jsonID("docAttr", Wt);
2869
+ var W = class extends Error {};
2870
+ W = function e(t) {
2871
+ let n = Error.call(this, t);
2872
+ return n.__proto__ = e.prototype, n;
2873
+ }, W.prototype = Object.create(Error.prototype), W.prototype.constructor = W, W.prototype.name = "TransformError";
2874
+ var Gt = class {
2875
+ constructor(e) {
2876
+ this.doc = e, this.steps = [], this.docs = [], this.mapping = new it();
2877
+ }
2878
+ get before() {
2879
+ return this.docs.length ? this.docs[0] : this.doc;
2880
+ }
2881
+ step(e) {
2882
+ let t = this.maybeStep(e);
2883
+ if (t.failed) throw new W(t.failed);
2884
+ return this;
2885
+ }
2886
+ maybeStep(e) {
2887
+ let t = e.apply(this.doc);
2888
+ return t.failed || this.addStep(e, t.doc), t;
2889
+ }
2890
+ get docChanged() {
2891
+ return this.steps.length > 0;
2892
+ }
2893
+ changedRange() {
2894
+ let e = 1e9, t = -1e9;
2895
+ for (let n = 0; n < this.mapping.maps.length; n++) {
2896
+ let r = this.mapping.maps[n];
2897
+ n && (e = r.map(e, 1), t = r.map(t, -1)), r.forEach((n, r, i, a) => {
2898
+ e = Math.min(e, i), t = Math.max(t, a);
2899
+ });
2900
+ }
2901
+ return e == 1e9 ? null : {
2902
+ from: e,
2903
+ to: t
2904
+ };
2905
+ }
2906
+ addStep(e, t) {
2907
+ this.docs.push(this.doc), this.steps.push(e), this.mapping.appendMap(e.getMap()), this.doc = t;
2908
+ }
2909
+ replace(e, t = e, n = l.empty) {
2910
+ let r = Mt(this.doc, e, t, n);
2911
+ return r && this.step(r), this;
2912
+ }
2913
+ replaceWith(e, t, n) {
2914
+ return this.replace(e, t, new l(r.from(n), 0, 0));
2915
+ }
2916
+ delete(e, t) {
2917
+ return this.replace(e, t, l.empty);
2918
+ }
2919
+ insert(e, t) {
2920
+ return this.replaceWith(e, e, t);
2921
+ }
2922
+ replaceRange(e, t, n) {
2923
+ return Rt(this, e, t, n), this;
2924
+ }
2925
+ replaceRangeWith(e, t, n) {
2926
+ return Bt(this, e, t, n), this;
2927
+ }
2928
+ deleteRange(e, t) {
2929
+ return Vt(this, e, t), this;
2930
+ }
2931
+ lift(e, t) {
2932
+ return ft(this, e, t), this;
2933
+ }
2934
+ join(e, t = 1) {
2935
+ return kt(this, e, t), this;
2936
+ }
2937
+ wrap(e, t) {
2938
+ return _t(this, e, t), this;
2939
+ }
2940
+ setBlockType(e, t = e, n, r = null) {
2941
+ return vt(this, e, t, n, r), this;
2942
+ }
2943
+ setNodeMarkup(e, t, n = null, r) {
2944
+ return St(this, e, t, n, r), this;
2945
+ }
2946
+ setNodeAttribute(e, t, n) {
2947
+ return this.step(new Ut(e, t, n)), this;
2948
+ }
2949
+ setDocAttribute(e, t) {
2950
+ return this.step(new Wt(e, t)), this;
2951
+ }
2952
+ addNodeMark(e, t) {
2953
+ return this.step(new I(e, t)), this;
2954
+ }
2955
+ removeNodeMark(e, t) {
2956
+ let n = this.doc.nodeAt(e);
2957
+ if (!n) throw RangeError("No node at position " + e);
2958
+ if (t instanceof s) t.isInSet(n.marks) && this.step(new L(e, t));
2959
+ else {
2960
+ let r = n.marks, i, a = [];
2961
+ for (; i = t.isInSet(r);) a.push(new L(e, i)), r = i.removeFromSet(r);
2962
+ for (let e = a.length - 1; e >= 0; e--) this.step(a[e]);
2963
+ }
2964
+ return this;
2965
+ }
2966
+ split(e, t = 1, n) {
2967
+ return wt(this, e, t, n), this;
2968
+ }
2969
+ addMark(e, t, n) {
2970
+ return st(this, e, t, n), this;
2971
+ }
2972
+ removeMark(e, t, n) {
2973
+ return ct(this, e, t, n), this;
2974
+ }
2975
+ clearIncompatible(e, t, n) {
2976
+ return lt(this, e, t, n), this;
2977
+ }
2978
+ }, G = Object.create(null), K = class {
2979
+ constructor(e, t, n) {
2980
+ this.$anchor = e, this.$head = t, this.ranges = n || [new Kt(e.min(t), e.max(t))];
2981
+ }
2982
+ get anchor() {
2983
+ return this.$anchor.pos;
2984
+ }
2985
+ get head() {
2986
+ return this.$head.pos;
2987
+ }
2988
+ get from() {
2989
+ return this.$from.pos;
2990
+ }
2991
+ get to() {
2992
+ return this.$to.pos;
2993
+ }
2994
+ get $from() {
2995
+ return this.ranges[0].$from;
2996
+ }
2997
+ get $to() {
2998
+ return this.ranges[0].$to;
2999
+ }
3000
+ get empty() {
3001
+ let e = this.ranges;
3002
+ for (let t = 0; t < e.length; t++) if (e[t].$from.pos != e[t].$to.pos) return !1;
3003
+ return !0;
3004
+ }
3005
+ content() {
3006
+ return this.$from.doc.slice(this.from, this.to, !0);
3007
+ }
3008
+ replace(e, t = l.empty) {
3009
+ let n = t.content.lastChild, r = null;
3010
+ for (let e = 0; e < t.openEnd; e++) r = n, n = n.lastChild;
3011
+ let i = e.steps.length, a = this.ranges;
3012
+ for (let o = 0; o < a.length; o++) {
3013
+ let { $from: s, $to: c } = a[o], u = e.mapping.slice(i);
3014
+ e.replaceRange(u.map(s.pos), u.map(c.pos), o ? l.empty : t), o == 0 && Qt(e, i, (n ? n.isInline : r && r.isTextblock) ? -1 : 1);
3015
+ }
3016
+ }
3017
+ replaceWith(e, t) {
3018
+ let n = e.steps.length, r = this.ranges;
3019
+ for (let i = 0; i < r.length; i++) {
3020
+ let { $from: a, $to: o } = r[i], s = e.mapping.slice(n), c = s.map(a.pos), l = s.map(o.pos);
3021
+ i ? e.deleteRange(c, l) : (e.replaceRangeWith(c, l, t), Qt(e, n, t.isInline ? -1 : 1));
3022
+ }
3023
+ }
3024
+ static findFrom(e, t, n = !1) {
3025
+ let r = e.parent.inlineContent ? new q(e) : X(e.node(0), e.parent, e.pos, e.index(), t, n);
3026
+ if (r) return r;
3027
+ for (let r = e.depth - 1; r >= 0; r--) {
3028
+ let i = t < 0 ? X(e.node(0), e.node(r), e.before(r + 1), e.index(r), t, n) : X(e.node(0), e.node(r), e.after(r + 1), e.index(r) + 1, t, n);
3029
+ if (i) return i;
3030
+ }
3031
+ return null;
3032
+ }
3033
+ static near(e, t = 1) {
3034
+ return this.findFrom(e, t) || this.findFrom(e, -t) || new Y(e.node(0));
3035
+ }
3036
+ static atStart(e) {
3037
+ return X(e, e, 0, 0, 1) || new Y(e);
3038
+ }
3039
+ static atEnd(e) {
3040
+ return X(e, e, e.content.size, e.childCount, -1) || new Y(e);
3041
+ }
3042
+ static fromJSON(e, t) {
3043
+ if (!t || !t.type) throw RangeError("Invalid input for Selection.fromJSON");
3044
+ let n = G[t.type];
3045
+ if (!n) throw RangeError(`No selection type ${t.type} defined`);
3046
+ return n.fromJSON(e, t);
3047
+ }
3048
+ static jsonID(e, t) {
3049
+ if (e in G) throw RangeError("Duplicate use of selection JSON ID " + e);
3050
+ return G[e] = t, t.prototype.jsonID = e, t;
3051
+ }
3052
+ getBookmark() {
3053
+ return q.between(this.$anchor, this.$head).getBookmark();
3054
+ }
3055
+ };
3056
+ K.prototype.visible = !0;
3057
+ var Kt = class {
3058
+ constructor(e, t) {
3059
+ this.$from = e, this.$to = t;
3060
+ }
3061
+ }, qt = !1;
3062
+ function Jt(e) {
3063
+ !qt && !e.parent.inlineContent && (qt = !0, console.warn("TextSelection endpoint not pointing into a node with inline content (" + e.parent.type.name + ")"));
3064
+ }
3065
+ var q = class e extends K {
3066
+ constructor(e, t = e) {
3067
+ Jt(e), Jt(t), super(e, t);
3068
+ }
3069
+ get $cursor() {
3070
+ return this.$anchor.pos == this.$head.pos ? this.$head : null;
3071
+ }
3072
+ map(t, n) {
3073
+ let r = t.resolve(n.map(this.head));
3074
+ if (!r.parent.inlineContent) return K.near(r);
3075
+ let i = t.resolve(n.map(this.anchor));
3076
+ return new e(i.parent.inlineContent ? i : r, r);
3077
+ }
3078
+ replace(e, t = l.empty) {
3079
+ if (super.replace(e, t), t == l.empty) {
3080
+ let t = this.$from.marksAcross(this.$to);
3081
+ t && e.ensureMarks(t);
3082
+ }
3083
+ }
3084
+ eq(t) {
3085
+ return t instanceof e && t.anchor == this.anchor && t.head == this.head;
3086
+ }
3087
+ getBookmark() {
3088
+ return new Yt(this.anchor, this.head);
3089
+ }
3090
+ toJSON() {
3091
+ return {
3092
+ type: "text",
3093
+ anchor: this.anchor,
3094
+ head: this.head
3095
+ };
3096
+ }
3097
+ static fromJSON(t, n) {
3098
+ if (typeof n.anchor != "number" || typeof n.head != "number") throw RangeError("Invalid input for TextSelection.fromJSON");
3099
+ return new e(t.resolve(n.anchor), t.resolve(n.head));
3100
+ }
3101
+ static create(e, t, n = t) {
3102
+ let r = e.resolve(t);
3103
+ return new this(r, n == t ? r : e.resolve(n));
3104
+ }
3105
+ static between(t, n, r) {
3106
+ let i = t.pos - n.pos;
3107
+ if ((!r || i) && (r = i >= 0 ? 1 : -1), !n.parent.inlineContent) {
3108
+ let e = K.findFrom(n, r, !0) || K.findFrom(n, -r, !0);
3109
+ if (e) n = e.$head;
3110
+ else return K.near(n, r);
3111
+ }
3112
+ return t.parent.inlineContent || (i == 0 ? t = n : (t = (K.findFrom(t, -r, !0) || K.findFrom(t, r, !0)).$anchor, t.pos < n.pos != i < 0 && (t = n))), new e(t, n);
3113
+ }
3114
+ };
3115
+ K.jsonID("text", q);
3116
+ var Yt = class e {
3117
+ constructor(e, t) {
3118
+ this.anchor = e, this.head = t;
3119
+ }
3120
+ map(t) {
3121
+ return new e(t.map(this.anchor), t.map(this.head));
3122
+ }
3123
+ resolve(e) {
3124
+ return q.between(e.resolve(this.anchor), e.resolve(this.head));
3125
+ }
3126
+ }, J = class e extends K {
3127
+ constructor(e) {
3128
+ let t = e.nodeAfter, n = e.node(0).resolve(e.pos + t.nodeSize);
3129
+ super(e, n), this.node = t;
3130
+ }
3131
+ map(t, n) {
3132
+ let { deleted: r, pos: i } = n.mapResult(this.anchor), a = t.resolve(i);
3133
+ return r ? K.near(a) : new e(a);
3134
+ }
3135
+ content() {
3136
+ return new l(r.from(this.node), 0, 0);
3137
+ }
3138
+ eq(t) {
3139
+ return t instanceof e && t.anchor == this.anchor;
3140
+ }
3141
+ toJSON() {
3142
+ return {
3143
+ type: "node",
3144
+ anchor: this.anchor
3145
+ };
3146
+ }
3147
+ getBookmark() {
3148
+ return new Xt(this.anchor);
3149
+ }
3150
+ static fromJSON(t, n) {
3151
+ if (typeof n.anchor != "number") throw RangeError("Invalid input for NodeSelection.fromJSON");
3152
+ return new e(t.resolve(n.anchor));
3153
+ }
3154
+ static create(t, n) {
3155
+ return new e(t.resolve(n));
3156
+ }
3157
+ static isSelectable(e) {
3158
+ return !e.isText && e.type.spec.selectable !== !1;
3159
+ }
3160
+ };
3161
+ J.prototype.visible = !1, K.jsonID("node", J);
3162
+ var Xt = class e {
3163
+ constructor(e) {
3164
+ this.anchor = e;
3165
+ }
3166
+ map(t) {
3167
+ let { deleted: n, pos: r } = t.mapResult(this.anchor);
3168
+ return n ? new Yt(r, r) : new e(r);
3169
+ }
3170
+ resolve(e) {
3171
+ let t = e.resolve(this.anchor), n = t.nodeAfter;
3172
+ return n && J.isSelectable(n) ? new J(t) : K.near(t);
3173
+ }
3174
+ }, Y = class e extends K {
3175
+ constructor(e) {
3176
+ super(e.resolve(0), e.resolve(e.content.size));
3177
+ }
3178
+ replace(e, t = l.empty) {
3179
+ if (t == l.empty) {
3180
+ e.delete(0, e.doc.content.size);
3181
+ let t = K.atStart(e.doc);
3182
+ t.eq(e.selection) || e.setSelection(t);
3183
+ } else super.replace(e, t);
3184
+ }
3185
+ toJSON() {
3186
+ return { type: "all" };
3187
+ }
3188
+ static fromJSON(t) {
3189
+ return new e(t);
3190
+ }
3191
+ map(t) {
3192
+ return new e(t);
3193
+ }
3194
+ eq(t) {
3195
+ return t instanceof e;
3196
+ }
3197
+ getBookmark() {
3198
+ return Zt;
3199
+ }
3200
+ };
3201
+ K.jsonID("all", Y);
3202
+ var Zt = {
3203
+ map() {
3204
+ return this;
3205
+ },
3206
+ resolve(e) {
3207
+ return new Y(e);
3208
+ }
3209
+ };
3210
+ function X(e, t, n, r, i, a = !1) {
3211
+ if (t.inlineContent) return q.create(e, n);
3212
+ for (let o = r - (i > 0 ? 0 : 1); i > 0 ? o < t.childCount : o >= 0; o += i) {
3213
+ let r = t.child(o);
3214
+ if (!r.isAtom) {
3215
+ let t = X(e, r, n + i, i < 0 ? r.childCount : 0, i, a);
3216
+ if (t) return t;
3217
+ } else if (!a && J.isSelectable(r)) return J.create(e, n - (i < 0 ? r.nodeSize : 0));
3218
+ n += r.nodeSize * i;
3219
+ }
3220
+ return null;
3221
+ }
3222
+ function Qt(e, t, n) {
3223
+ let r = e.steps.length - 1;
3224
+ if (r < t) return;
3225
+ let i = e.steps[r];
3226
+ if (!(i instanceof R || i instanceof z)) return;
3227
+ let a = e.mapping.maps[r], o;
3228
+ a.forEach((e, t, n, r) => {
3229
+ o ??= r;
3230
+ }), e.setSelection(K.near(e.doc.resolve(o), n));
3231
+ }
3232
+ var $t = 1, Z = 2, en = 4, tn = class extends Gt {
3233
+ constructor(e) {
3234
+ super(e.doc), this.curSelectionFor = 0, this.updated = 0, this.meta = Object.create(null), this.time = Date.now(), this.curSelection = e.selection, this.storedMarks = e.storedMarks;
3235
+ }
3236
+ get selection() {
3237
+ return this.curSelectionFor < this.steps.length && (this.curSelection = this.curSelection.map(this.doc, this.mapping.slice(this.curSelectionFor)), this.curSelectionFor = this.steps.length), this.curSelection;
3238
+ }
3239
+ setSelection(e) {
3240
+ if (e.$from.doc != this.doc) throw RangeError("Selection passed to setSelection must point at the current document");
3241
+ return this.curSelection = e, this.curSelectionFor = this.steps.length, this.updated = (this.updated | $t) & ~Z, this.storedMarks = null, this;
3242
+ }
3243
+ get selectionSet() {
3244
+ return (this.updated & $t) > 0;
3245
+ }
3246
+ setStoredMarks(e) {
3247
+ return this.storedMarks = e, this.updated |= Z, this;
3248
+ }
3249
+ ensureMarks(e) {
3250
+ return s.sameSet(this.storedMarks || this.selection.$from.marks(), e) || this.setStoredMarks(e), this;
3251
+ }
3252
+ addStoredMark(e) {
3253
+ return this.ensureMarks(e.addToSet(this.storedMarks || this.selection.$head.marks()));
3254
+ }
3255
+ removeStoredMark(e) {
3256
+ return this.ensureMarks(e.removeFromSet(this.storedMarks || this.selection.$head.marks()));
3257
+ }
3258
+ get storedMarksSet() {
3259
+ return (this.updated & Z) > 0;
3260
+ }
3261
+ addStep(e, t) {
3262
+ super.addStep(e, t), this.updated &= ~Z, this.storedMarks = null;
3263
+ }
3264
+ setTime(e) {
3265
+ return this.time = e, this;
3266
+ }
3267
+ replaceSelection(e) {
3268
+ return this.selection.replace(this, e), this;
3269
+ }
3270
+ replaceSelectionWith(e, t = !0) {
3271
+ let n = this.selection;
3272
+ return t && (e = e.mark(this.storedMarks || (n.empty ? n.$from.marks() : n.$from.marksAcross(n.$to) || s.none))), n.replaceWith(this, e), this;
3273
+ }
3274
+ deleteSelection() {
3275
+ return this.selection.replace(this), this;
3276
+ }
3277
+ insertText(e, t, n) {
3278
+ let r = this.doc.type.schema;
3279
+ if (t == null) return e ? this.replaceSelectionWith(r.text(e), !0) : this.deleteSelection();
3280
+ {
3281
+ if (n ??= t, !e) return this.deleteRange(t, n);
3282
+ let i = this.storedMarks;
3283
+ if (!i) {
3284
+ let e = this.doc.resolve(t);
3285
+ i = n == t ? e.marks() : e.marksAcross(this.doc.resolve(n));
3286
+ }
3287
+ return this.replaceRangeWith(t, n, r.text(e, i)), !this.selection.empty && this.selection.to == t + e.length && this.setSelection(K.near(this.selection.$to)), this;
3288
+ }
3289
+ }
3290
+ setMeta(e, t) {
3291
+ return this.meta[typeof e == "string" ? e : e.key] = t, this;
3292
+ }
3293
+ getMeta(e) {
3294
+ return this.meta[typeof e == "string" ? e : e.key];
3295
+ }
3296
+ get isGeneric() {
3297
+ for (let e in this.meta) return !1;
3298
+ return !0;
3299
+ }
3300
+ scrollIntoView() {
3301
+ return this.updated |= en, this;
3302
+ }
3303
+ get scrolledIntoView() {
3304
+ return (this.updated & en) > 0;
3305
+ }
3306
+ };
3307
+ function nn(e, t) {
3308
+ return !t || !e ? e : e.bind(t);
3309
+ }
3310
+ var Q = class {
3311
+ constructor(e, t, n) {
3312
+ this.name = e, this.init = nn(t.init, n), this.apply = nn(t.apply, n);
3313
+ }
3314
+ }, rn = [
3315
+ new Q("doc", {
3316
+ init(e) {
3317
+ return e.doc || e.schema.topNodeType.createAndFill();
3318
+ },
3319
+ apply(e) {
3320
+ return e.doc;
3321
+ }
3322
+ }),
3323
+ new Q("selection", {
3324
+ init(e, t) {
3325
+ return e.selection || K.atStart(t.doc);
3326
+ },
3327
+ apply(e) {
3328
+ return e.selection;
3329
+ }
3330
+ }),
3331
+ new Q("storedMarks", {
3332
+ init(e) {
3333
+ return e.storedMarks || null;
3334
+ },
3335
+ apply(e, t, n, r) {
3336
+ return r.selection.$cursor ? e.storedMarks : null;
3337
+ }
3338
+ }),
3339
+ new Q("scrollToSelection", {
3340
+ init() {
3341
+ return 0;
3342
+ },
3343
+ apply(e, t) {
3344
+ return e.scrolledIntoView ? t + 1 : t;
3345
+ }
3346
+ })
3347
+ ], an = class {
3348
+ constructor(e, t) {
3349
+ this.schema = e, this.plugins = [], this.pluginsByKey = Object.create(null), this.fields = rn.slice(), t && t.forEach((e) => {
3350
+ if (this.pluginsByKey[e.key]) throw RangeError("Adding different instances of a keyed plugin (" + e.key + ")");
3351
+ this.plugins.push(e), this.pluginsByKey[e.key] = e, e.spec.state && this.fields.push(new Q(e.key, e.spec.state, e));
3352
+ });
3353
+ }
3354
+ }, on = class e {
3355
+ constructor(e) {
3356
+ this.config = e;
3357
+ }
3358
+ get schema() {
3359
+ return this.config.schema;
3360
+ }
3361
+ get plugins() {
3362
+ return this.config.plugins;
3363
+ }
3364
+ apply(e) {
3365
+ return this.applyTransaction(e).state;
3366
+ }
3367
+ filterTransaction(e, t = -1) {
3368
+ for (let n = 0; n < this.config.plugins.length; n++) if (n != t) {
3369
+ let t = this.config.plugins[n];
3370
+ if (t.spec.filterTransaction && !t.spec.filterTransaction.call(t, e, this)) return !1;
3371
+ }
3372
+ return !0;
3373
+ }
3374
+ applyTransaction(e) {
3375
+ if (!this.filterTransaction(e)) return {
3376
+ state: this,
3377
+ transactions: []
3378
+ };
3379
+ let t = [e], n = this.applyInner(e), r = null;
3380
+ for (;;) {
3381
+ let i = !1;
3382
+ for (let a = 0; a < this.config.plugins.length; a++) {
3383
+ let o = this.config.plugins[a];
3384
+ if (o.spec.appendTransaction) {
3385
+ let s = r ? r[a].n : 0, c = r ? r[a].state : this, l = s < t.length && o.spec.appendTransaction.call(o, s ? t.slice(s) : t, c, n);
3386
+ if (l && n.filterTransaction(l, a)) {
3387
+ if (l.setMeta("appendedTransaction", e), !r) {
3388
+ r = [];
3389
+ for (let e = 0; e < this.config.plugins.length; e++) r.push(e < a ? {
3390
+ state: n,
3391
+ n: t.length
3392
+ } : {
3393
+ state: this,
3394
+ n: 0
3395
+ });
3396
+ }
3397
+ t.push(l), n = n.applyInner(l), i = !0;
3398
+ }
3399
+ r && (r[a] = {
3400
+ state: n,
3401
+ n: t.length
3402
+ });
3403
+ }
3404
+ }
3405
+ if (!i) return {
3406
+ state: n,
3407
+ transactions: t
3408
+ };
3409
+ }
3410
+ }
3411
+ applyInner(t) {
3412
+ if (!t.before.eq(this.doc)) throw RangeError("Applying a mismatched transaction");
3413
+ let n = new e(this.config), r = this.config.fields;
3414
+ for (let e = 0; e < r.length; e++) {
3415
+ let i = r[e];
3416
+ n[i.name] = i.apply(t, this[i.name], this, n);
3417
+ }
3418
+ return n;
3419
+ }
3420
+ get tr() {
3421
+ return new tn(this);
3422
+ }
3423
+ static create(t) {
3424
+ let n = new an(t.doc ? t.doc.type.schema : t.schema, t.plugins), r = new e(n);
3425
+ for (let e = 0; e < n.fields.length; e++) r[n.fields[e].name] = n.fields[e].init(t, r);
3426
+ return r;
3427
+ }
3428
+ reconfigure(t) {
3429
+ let n = new an(this.schema, t.plugins), r = n.fields, i = new e(n);
3430
+ for (let e = 0; e < r.length; e++) {
3431
+ let n = r[e].name;
3432
+ i[n] = this.hasOwnProperty(n) ? this[n] : r[e].init(t, i);
3433
+ }
3434
+ return i;
3435
+ }
3436
+ toJSON(e) {
3437
+ let t = {
3438
+ doc: this.doc.toJSON(),
3439
+ selection: this.selection.toJSON()
3440
+ };
3441
+ if (this.storedMarks && (t.storedMarks = this.storedMarks.map((e) => e.toJSON())), e && typeof e == "object") for (let n in e) {
3442
+ if (n == "doc" || n == "selection") throw RangeError("The JSON fields `doc` and `selection` are reserved");
3443
+ let r = e[n], i = r.spec.state;
3444
+ i && i.toJSON && (t[n] = i.toJSON.call(r, this[r.key]));
3445
+ }
3446
+ return t;
3447
+ }
3448
+ static fromJSON(t, n, r) {
3449
+ if (!n) throw RangeError("Invalid input for EditorState.fromJSON");
3450
+ if (!t.schema) throw RangeError("Required config field 'schema' missing");
3451
+ let i = new an(t.schema, t.plugins), a = new e(i);
3452
+ return i.fields.forEach((e) => {
3453
+ if (e.name == "doc") a.doc = b.fromJSON(t.schema, n.doc);
3454
+ else if (e.name == "selection") a.selection = K.fromJSON(a.doc, n.selection);
3455
+ else if (e.name == "storedMarks") n.storedMarks && (a.storedMarks = n.storedMarks.map(t.schema.markFromJSON));
3456
+ else {
3457
+ if (r) for (let i in r) {
3458
+ let o = r[i], s = o.spec.state;
3459
+ if (o.key == e.name && s && s.fromJSON && Object.prototype.hasOwnProperty.call(n, i)) {
3460
+ a[e.name] = s.fromJSON.call(o, t, n[i], a);
3461
+ return;
3462
+ }
3463
+ }
3464
+ a[e.name] = e.init(t, a);
3465
+ }
3466
+ }), a;
3467
+ }
3468
+ };
3469
+ function sn(e, t, n) {
3470
+ for (let r in e) {
3471
+ let i = e[r];
3472
+ i instanceof Function ? i = i.bind(t) : r == "handleDOMEvents" && (i = sn(i, t, {})), n[r] = i;
3473
+ }
3474
+ return n;
3475
+ }
3476
+ var cn = class {
3477
+ constructor(e) {
3478
+ this.spec = e, this.props = {}, e.props && sn(e.props, this, this.props), this.key = e.key ? e.key.key : ln("plugin");
3479
+ }
3480
+ getState(e) {
3481
+ return e[this.key];
3482
+ }
3483
+ }, $ = Object.create(null);
3484
+ function ln(e) {
3485
+ return e in $ ? e + "$" + ++$[e] : ($[e] = 0, e + "$");
3486
+ }
3487
+ var un = class {
3488
+ constructor(e = "key") {
3489
+ this.key = ln(e);
3490
+ }
3491
+ get(e) {
3492
+ return e.config.pluginsByKey[this.key];
3493
+ }
3494
+ getState(e) {
3495
+ return e[this.key];
3496
+ }
3497
+ };
3498
+ //#endregion
3499
+ export { r as C, S as D, oe as E, Ae as O, We as S, b as T, pt as _, un as a, Mt as b, q as c, z as d, R as f, jt as g, Ct as h, cn as i, l as k, tn as l, Tt as m, on as n, K as o, Gt as p, J as r, Kt as s, Y as t, P as u, Ot as v, s as w, Pe as x, dt as y };