@burdenoff/microfe-support 2026.819.2 → 2026.819.4

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 (105) hide show
  1. package/dist/_virtual/_rolldown/runtime.js +7 -0
  2. package/dist/generated/global-types.d.ts +217 -1
  3. package/dist/generated/global-types.js +16 -14
  4. package/dist/generated/global-types.js.map +1 -1
  5. package/dist/microfe-support.css +1 -1
  6. package/dist/node_modules/@tiptap/core/dist/index.js +3453 -0
  7. package/dist/node_modules/@tiptap/core/dist/index.js.map +1 -0
  8. package/dist/node_modules/@tiptap/core/dist/jsx-runtime/jsx-runtime.js +21 -0
  9. package/dist/node_modules/@tiptap/core/dist/jsx-runtime/jsx-runtime.js.map +1 -0
  10. package/dist/node_modules/@tiptap/extension-blockquote/dist/index.js +76 -0
  11. package/dist/node_modules/@tiptap/extension-blockquote/dist/index.js.map +1 -0
  12. package/dist/node_modules/@tiptap/extension-bold/dist/index.js +74 -0
  13. package/dist/node_modules/@tiptap/extension-bold/dist/index.js.map +1 -0
  14. package/dist/node_modules/@tiptap/extension-code/dist/index.js +68 -0
  15. package/dist/node_modules/@tiptap/extension-code/dist/index.js.map +1 -0
  16. package/dist/node_modules/@tiptap/extension-code-block/dist/index.js +160 -0
  17. package/dist/node_modules/@tiptap/extension-code-block/dist/index.js.map +1 -0
  18. package/dist/node_modules/@tiptap/extension-document/dist/index.js +12 -0
  19. package/dist/node_modules/@tiptap/extension-document/dist/index.js.map +1 -0
  20. package/dist/node_modules/@tiptap/extension-hard-break/dist/index.js +51 -0
  21. package/dist/node_modules/@tiptap/extension-hard-break/dist/index.js.map +1 -0
  22. package/dist/node_modules/@tiptap/extension-heading/dist/index.js +68 -0
  23. package/dist/node_modules/@tiptap/extension-heading/dist/index.js.map +1 -0
  24. package/dist/node_modules/@tiptap/extension-horizontal-rule/dist/index.js +50 -0
  25. package/dist/node_modules/@tiptap/extension-horizontal-rule/dist/index.js.map +1 -0
  26. package/dist/node_modules/@tiptap/extension-italic/dist/index.js +71 -0
  27. package/dist/node_modules/@tiptap/extension-italic/dist/index.js.map +1 -0
  28. package/dist/node_modules/@tiptap/extension-link/dist/index.js +373 -0
  29. package/dist/node_modules/@tiptap/extension-link/dist/index.js.map +1 -0
  30. package/dist/node_modules/@tiptap/extension-list/dist/index.js +964 -0
  31. package/dist/node_modules/@tiptap/extension-list/dist/index.js.map +1 -0
  32. package/dist/node_modules/@tiptap/extension-paragraph/dist/index.js +46 -0
  33. package/dist/node_modules/@tiptap/extension-paragraph/dist/index.js.map +1 -0
  34. package/dist/node_modules/@tiptap/extension-placeholder/dist/index.js +7 -0
  35. package/dist/node_modules/@tiptap/extension-placeholder/dist/index.js.map +1 -0
  36. package/dist/node_modules/@tiptap/extension-strike/dist/index.js +56 -0
  37. package/dist/node_modules/@tiptap/extension-strike/dist/index.js.map +1 -0
  38. package/dist/node_modules/@tiptap/extension-text/dist/index.js +15 -0
  39. package/dist/node_modules/@tiptap/extension-text/dist/index.js.map +1 -0
  40. package/dist/node_modules/@tiptap/extension-underline/dist/index.js +63 -0
  41. package/dist/node_modules/@tiptap/extension-underline/dist/index.js.map +1 -0
  42. package/dist/node_modules/@tiptap/extensions/dist/index.js +459 -0
  43. package/dist/node_modules/@tiptap/extensions/dist/index.js.map +1 -0
  44. package/dist/node_modules/@tiptap/react/dist/index.js +316 -0
  45. package/dist/node_modules/@tiptap/react/dist/index.js.map +1 -0
  46. package/dist/node_modules/@tiptap/starter-kit/dist/index.js +29 -0
  47. package/dist/node_modules/@tiptap/starter-kit/dist/index.js.map +1 -0
  48. package/dist/node_modules/fast-equals/dist/es/index.js +267 -0
  49. package/dist/node_modules/fast-equals/dist/es/index.js.map +1 -0
  50. package/dist/node_modules/linkifyjs/dist/linkify.js +514 -0
  51. package/dist/node_modules/linkifyjs/dist/linkify.js.map +1 -0
  52. package/dist/node_modules/orderedmap/dist/index.js +69 -0
  53. package/dist/node_modules/orderedmap/dist/index.js.map +1 -0
  54. package/dist/node_modules/prosemirror-commands/dist/index.js +335 -0
  55. package/dist/node_modules/prosemirror-commands/dist/index.js.map +1 -0
  56. package/dist/node_modules/prosemirror-dropcursor/dist/index.js +113 -0
  57. package/dist/node_modules/prosemirror-dropcursor/dist/index.js.map +1 -0
  58. package/dist/node_modules/prosemirror-gapcursor/dist/index.js +173 -0
  59. package/dist/node_modules/prosemirror-gapcursor/dist/index.js.map +1 -0
  60. package/dist/node_modules/prosemirror-history/dist/index.js +214 -0
  61. package/dist/node_modules/prosemirror-history/dist/index.js.map +1 -0
  62. package/dist/node_modules/prosemirror-keymap/dist/index.js +52 -0
  63. package/dist/node_modules/prosemirror-keymap/dist/index.js.map +1 -0
  64. package/dist/node_modules/prosemirror-model/dist/index.js +1786 -0
  65. package/dist/node_modules/prosemirror-model/dist/index.js.map +1 -0
  66. package/dist/node_modules/prosemirror-schema-list/dist/index.js +75 -0
  67. package/dist/node_modules/prosemirror-schema-list/dist/index.js.map +1 -0
  68. package/dist/node_modules/prosemirror-state/dist/index.js +527 -0
  69. package/dist/node_modules/prosemirror-state/dist/index.js.map +1 -0
  70. package/dist/node_modules/prosemirror-transform/dist/index.js +1153 -0
  71. package/dist/node_modules/prosemirror-transform/dist/index.js.map +1 -0
  72. package/dist/node_modules/prosemirror-view/dist/index.js +3296 -0
  73. package/dist/node_modules/prosemirror-view/dist/index.js.map +1 -0
  74. package/dist/node_modules/rope-sequence/dist/index.js +85 -0
  75. package/dist/node_modules/rope-sequence/dist/index.js.map +1 -0
  76. package/dist/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js +56 -0
  77. package/dist/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js.map +1 -0
  78. package/dist/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.js +54 -0
  79. package/dist/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.js.map +1 -0
  80. package/dist/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js +54 -0
  81. package/dist/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js.map +1 -0
  82. package/dist/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.js +46 -0
  83. package/dist/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.js.map +1 -0
  84. package/dist/node_modules/use-sync-external-store/shim/index.js +12 -0
  85. package/dist/node_modules/use-sync-external-store/shim/index.js.map +1 -0
  86. package/dist/node_modules/use-sync-external-store/shim/with-selector.js +12 -0
  87. package/dist/node_modules/use-sync-external-store/shim/with-selector.js.map +1 -0
  88. package/dist/node_modules/w3c-keyname/index.js +90 -0
  89. package/dist/node_modules/w3c-keyname/index.js.map +1 -0
  90. package/dist/support/components/careers/BulkCandidateDialogs.d.ts +2 -3
  91. package/dist/support/components/careers/BulkCandidateDialogs.js +178 -188
  92. package/dist/support/components/careers/BulkCandidateDialogs.js.map +1 -1
  93. package/dist/support/components/careers/RichTextEditor.d.ts +16 -0
  94. package/dist/support/components/careers/RichTextEditor.js +87 -0
  95. package/dist/support/components/careers/RichTextEditor.js.map +1 -0
  96. package/dist/support/pages/JobApplicationDetailPage.d.ts +1 -0
  97. package/dist/support/pages/JobApplicationDetailPage.js +338 -336
  98. package/dist/support/pages/JobApplicationDetailPage.js.map +1 -1
  99. package/dist/support/pages/JobApplicationsPage.js +383 -339
  100. package/dist/support/pages/JobApplicationsPage.js.map +1 -1
  101. package/dist/support/pages/JobPostingDetailPage.js +310 -303
  102. package/dist/support/pages/JobPostingDetailPage.js.map +1 -1
  103. package/dist/support/utils/bulkCandidateOperations.js +31 -65
  104. package/dist/support/utils/bulkCandidateOperations.js.map +1 -1
  105. package/package.json +4 -1
@@ -0,0 +1,3296 @@
1
+ import { DOMParser as e, DOMSerializer as t, Fragment as n, Mark as r, Slice as i } from "../../prosemirror-model/dist/index.js";
2
+ import { dropPoint as a } from "../../prosemirror-transform/dist/index.js";
3
+ import { AllSelection as o, NodeSelection as s, Selection as c, TextSelection as l } from "../../prosemirror-state/dist/index.js";
4
+ //#region node_modules/prosemirror-view/dist/index.js
5
+ var u = function(e) {
6
+ for (var t = 0;; t++) if (e = e.previousSibling, !e) return t;
7
+ }, d = function(e) {
8
+ let t = e.assignedSlot || e.parentNode;
9
+ return t && t.nodeType == 11 ? t.host : t;
10
+ }, f = null, p = function(e, t, n) {
11
+ let r = f ||= document.createRange();
12
+ return r.setEnd(e, n ?? e.nodeValue.length), r.setStart(e, t || 0), r;
13
+ }, m = function() {
14
+ f = null;
15
+ }, h = function(e, t, n, r) {
16
+ return n && (_(e, t, n, r, -1) || _(e, t, n, r, 1));
17
+ }, g = /^(img|br|input|textarea|hr)$/i;
18
+ function _(e, t, n, r, i) {
19
+ for (;;) {
20
+ if (e == n && t == r) return !0;
21
+ if (t == (i < 0 ? 0 : v(e))) {
22
+ let n = e.parentNode;
23
+ if (!n || n.nodeType != 1 || x(e) || g.test(e.nodeName) || e.contentEditable == "false") return !1;
24
+ t = u(e) + (i < 0 ? 0 : 1), e = n;
25
+ } else if (e.nodeType == 1) {
26
+ let n = e.childNodes[t + (i < 0 ? -1 : 0)];
27
+ if (n.nodeType == 1 && n.contentEditable == "false") {
28
+ if (n.pmViewDesc?.ignoreForSelection) t += i;
29
+ else return !1;
30
+ } else e = n, t = i < 0 ? v(e) : 0;
31
+ } else return !1;
32
+ }
33
+ }
34
+ function v(e) {
35
+ return e.nodeType == 3 ? e.nodeValue.length : e.childNodes.length;
36
+ }
37
+ function ee(e, t) {
38
+ for (;;) {
39
+ if (e.nodeType == 3 && t) return e;
40
+ if (e.nodeType == 1 && t > 0) {
41
+ if (e.contentEditable == "false") return null;
42
+ e = e.childNodes[t - 1], t = v(e);
43
+ } else if (e.parentNode && !x(e)) t = u(e), e = e.parentNode;
44
+ else return null;
45
+ }
46
+ }
47
+ function y(e, t) {
48
+ for (;;) {
49
+ if (e.nodeType == 3 && t < e.nodeValue.length) return e;
50
+ if (e.nodeType == 1 && t < e.childNodes.length) {
51
+ if (e.contentEditable == "false") return null;
52
+ e = e.childNodes[t], t = 0;
53
+ } else if (e.parentNode && !x(e)) t = u(e) + 1, e = e.parentNode;
54
+ else return null;
55
+ }
56
+ }
57
+ function b(e, t, n) {
58
+ for (let r = t == 0, i = t == v(e); r || i;) {
59
+ if (e == n) return !0;
60
+ let t = u(e);
61
+ if (e = e.parentNode, !e) return !1;
62
+ r &&= t == 0, i &&= t == v(e);
63
+ }
64
+ }
65
+ function x(e) {
66
+ let t;
67
+ for (let n = e; n && !(t = n.pmViewDesc); n = n.parentNode);
68
+ return t && t.node && t.node.isBlock && (t.dom == e || t.contentDOM == e);
69
+ }
70
+ var S = function(e) {
71
+ return e.focusNode && h(e.focusNode, e.focusOffset, e.anchorNode, e.anchorOffset);
72
+ };
73
+ function C(e, t) {
74
+ let n = document.createEvent("Event");
75
+ return n.initEvent("keydown", !0, !0), n.keyCode = e, n.key = n.code = t, n;
76
+ }
77
+ function te(e) {
78
+ let t = e.activeElement;
79
+ for (; t && t.shadowRoot;) t = t.shadowRoot.activeElement;
80
+ return t;
81
+ }
82
+ function ne(e, t, n) {
83
+ if (e.caretPositionFromPoint) try {
84
+ let r = e.caretPositionFromPoint(t, n);
85
+ if (r) return {
86
+ node: r.offsetNode,
87
+ offset: Math.min(v(r.offsetNode), r.offset)
88
+ };
89
+ } catch {}
90
+ if (e.caretRangeFromPoint) {
91
+ let r = e.caretRangeFromPoint(t, n);
92
+ if (r) return {
93
+ node: r.startContainer,
94
+ offset: Math.min(v(r.startContainer), r.startOffset)
95
+ };
96
+ }
97
+ }
98
+ var w = typeof navigator < "u" ? navigator : null, re = typeof document < "u" ? document : null, T = w && w.userAgent || "", ie = /Edge\/(\d+)/.exec(T), ae = /MSIE \d/.exec(T), oe = /Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(T), E = !!(ae || oe || ie), D = ae ? document.documentMode : oe ? +oe[1] : ie ? +ie[1] : 0, O = !E && /gecko\/(\d+)/i.test(T);
99
+ O && +(/Firefox\/(\d+)/.exec(T) || [0, 0])[1];
100
+ var se = !E && /Chrome\/(\d+)/.exec(T), k = !!se, ce = se ? +se[1] : 0, A = !E && !!w && /Apple Computer/.test(w.vendor), j = A && (/Mobile\/\w+/.test(T) || !!w && w.maxTouchPoints > 2), M = j || (w ? /Mac/.test(w.platform) : !1), le = w ? /Win/.test(w.platform) : !1, N = /Android \d/.test(T), ue = !!re && "webkitFontSmoothing" in re.documentElement.style, de = ue ? +(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent) || [0, 0])[1] : 0;
101
+ function fe(e) {
102
+ let t = e.defaultView && e.defaultView.visualViewport;
103
+ return t ? {
104
+ left: 0,
105
+ right: t.width,
106
+ top: 0,
107
+ bottom: t.height
108
+ } : {
109
+ left: 0,
110
+ right: e.documentElement.clientWidth,
111
+ top: 0,
112
+ bottom: e.documentElement.clientHeight
113
+ };
114
+ }
115
+ function P(e, t) {
116
+ return typeof e == "number" ? e : e[t];
117
+ }
118
+ function pe(e) {
119
+ let t = e.getBoundingClientRect(), n = t.width / e.offsetWidth || 1, r = t.height / e.offsetHeight || 1;
120
+ return {
121
+ left: t.left,
122
+ right: t.left + e.clientWidth * n,
123
+ top: t.top,
124
+ bottom: t.top + e.clientHeight * r
125
+ };
126
+ }
127
+ function me(e, t, n) {
128
+ if (!Oe(t) && t.left == 0) return;
129
+ let r = e.someProp("scrollThreshold") || 0, i = e.someProp("scrollMargin") || 5, a = e.dom.ownerDocument;
130
+ for (let o = n || e.dom; o;) {
131
+ if (o.nodeType != 1) {
132
+ o = d(o);
133
+ continue;
134
+ }
135
+ let e = o, n = e == a.body, s = n ? fe(a) : pe(e), c = 0, l = 0;
136
+ if (t.top < s.top + P(r, "top") ? l = -(s.top - t.top + P(i, "top")) : t.bottom > s.bottom - P(r, "bottom") && (l = t.bottom - t.top > s.bottom - s.top ? t.top + P(i, "top") - s.top : t.bottom - s.bottom + P(i, "bottom")), t.left < s.left + P(r, "left") ? c = -(s.left - t.left + P(i, "left")) : t.right > s.right - P(r, "right") && (c = t.right - s.right + P(i, "right")), c || l) {
137
+ if (n) a.defaultView.scrollBy(c, l);
138
+ else {
139
+ let n = e.scrollLeft, r = e.scrollTop;
140
+ l && (e.scrollTop += l), c && (e.scrollLeft += c);
141
+ let i = e.scrollLeft - n, a = e.scrollTop - r;
142
+ t = {
143
+ left: t.left - i,
144
+ top: t.top - a,
145
+ right: t.right - i,
146
+ bottom: t.bottom - a
147
+ };
148
+ }
149
+ }
150
+ let u = n ? "fixed" : getComputedStyle(o).position;
151
+ if (/^(fixed|sticky)$/.test(u)) break;
152
+ o = u == "absolute" ? o.offsetParent : d(o);
153
+ }
154
+ }
155
+ function he(e) {
156
+ let t = e.dom.getBoundingClientRect(), n = Math.max(0, t.top), r, i;
157
+ for (let a = (t.left + t.right) / 2, o = n + 1; o < Math.min(innerHeight, t.bottom); o += 5) {
158
+ let t = e.root.elementFromPoint(a, o);
159
+ if (!t || t == e.dom || !e.dom.contains(t)) continue;
160
+ let s = t.getBoundingClientRect();
161
+ if (s.top >= n - 20) {
162
+ r = t, i = s.top;
163
+ break;
164
+ }
165
+ }
166
+ return {
167
+ refDOM: r,
168
+ refTop: i,
169
+ stack: ge(e.dom)
170
+ };
171
+ }
172
+ function ge(e) {
173
+ let t = [], n = e.ownerDocument;
174
+ for (let r = e; r && (t.push({
175
+ dom: r,
176
+ top: r.scrollTop,
177
+ left: r.scrollLeft
178
+ }), e != n); r = d(r));
179
+ return t;
180
+ }
181
+ function _e({ refDOM: e, refTop: t, stack: n }) {
182
+ let r = e ? e.getBoundingClientRect().top : 0;
183
+ ve(n, r == 0 ? 0 : r - t);
184
+ }
185
+ function ve(e, t) {
186
+ for (let n = 0; n < e.length; n++) {
187
+ let { dom: r, top: i, left: a } = e[n];
188
+ r.scrollTop != i + t && (r.scrollTop = i + t), r.scrollLeft != a && (r.scrollLeft = a);
189
+ }
190
+ }
191
+ var F = null;
192
+ function ye(e) {
193
+ if (e.setActive) return e.setActive();
194
+ if (F) return e.focus(F);
195
+ let t = ge(e);
196
+ e.focus(F == null ? { get preventScroll() {
197
+ return F = { preventScroll: !0 }, !0;
198
+ } } : void 0), F || (F = !1, ve(t, 0));
199
+ }
200
+ function be(e, t) {
201
+ let n, r = 2e8, i, a = 0, o = t.top, s = t.top, c, l;
202
+ for (let u = e.firstChild, d = 0; u; u = u.nextSibling, d++) {
203
+ let e;
204
+ if (u.nodeType == 1) e = u.getClientRects();
205
+ else if (u.nodeType == 3) e = p(u).getClientRects();
206
+ else continue;
207
+ for (let f = 0; f < e.length; f++) {
208
+ let p = e[f];
209
+ if (p.top <= o && p.bottom >= s) {
210
+ o = Math.max(p.bottom, o), s = Math.min(p.top, s);
211
+ let e = p.left > t.left ? p.left - t.left : p.right < t.left ? t.left - p.right : 0;
212
+ if (e < r) {
213
+ n = u, r = e, i = e && n.nodeType == 3 ? {
214
+ left: p.right < t.left ? p.right : p.left,
215
+ top: t.top
216
+ } : t, u.nodeType == 1 && e && (a = d + +(t.left >= (p.left + p.right) / 2));
217
+ continue;
218
+ }
219
+ } else p.top > t.top && !c && p.left <= t.left && p.right >= t.left && (c = u, l = {
220
+ left: Math.max(p.left, Math.min(p.right, t.left)),
221
+ top: p.top
222
+ });
223
+ !n && (t.left >= p.right && t.top >= p.top || t.left >= p.left && t.top >= p.bottom) && (a = d + 1);
224
+ }
225
+ }
226
+ return !n && c && (n = c, i = l, r = 0), n && n.nodeType == 3 ? xe(n, i) : !n || r && n.nodeType == 1 ? {
227
+ node: e,
228
+ offset: a
229
+ } : be(n, i);
230
+ }
231
+ function xe(e, t) {
232
+ let n = e.nodeValue.length, r = document.createRange(), i;
233
+ for (let a = 0; a < n; a++) {
234
+ r.setEnd(e, a + 1), r.setStart(e, a);
235
+ let n = I(r, 1);
236
+ if (n.top != n.bottom && Se(t, n)) {
237
+ i = {
238
+ node: e,
239
+ offset: a + +(t.left >= (n.left + n.right) / 2)
240
+ };
241
+ break;
242
+ }
243
+ }
244
+ return r.detach(), i || {
245
+ node: e,
246
+ offset: 0
247
+ };
248
+ }
249
+ function Se(e, t) {
250
+ return e.left >= t.left - 1 && e.left <= t.right + 1 && e.top >= t.top - 1 && e.top <= t.bottom + 1;
251
+ }
252
+ function Ce(e, t) {
253
+ let n = e.parentNode;
254
+ return n && /^li$/i.test(n.nodeName) && t.left < e.getBoundingClientRect().left ? n : e;
255
+ }
256
+ function we(e, t, n) {
257
+ let { node: r, offset: i } = be(t, n), a = -1;
258
+ if (r.nodeType == 1 && !r.firstChild) {
259
+ let e = r.getBoundingClientRect();
260
+ a = e.left != e.right && n.left > (e.left + e.right) / 2 ? 1 : -1;
261
+ }
262
+ return e.docView.posFromDOM(r, i, a);
263
+ }
264
+ function Te(e, t, n, r) {
265
+ let i = -1;
266
+ for (let n = t, a = !1; n != e.dom;) {
267
+ let t = e.docView.nearestDesc(n, !0), o;
268
+ if (!t) return null;
269
+ if (t.dom.nodeType == 1 && (t.node.isBlock && t.parent || !t.contentDOM) && ((o = t.dom.getBoundingClientRect()).width || o.height) && (t.node.isBlock && t.parent && !/^T(R|BODY|HEAD|FOOT)$/.test(t.dom.nodeName) && (!a && o.left > r.left || o.top > r.top ? i = t.posBefore : (!a && o.right < r.left || o.bottom < r.top) && (i = t.posAfter), a = !0), !t.contentDOM && i < 0 && !t.node.isText)) return (t.node.isBlock ? r.top < (o.top + o.bottom) / 2 : r.left < (o.left + o.right) / 2) ? t.posBefore : t.posAfter;
270
+ n = t.dom.parentNode;
271
+ }
272
+ return i > -1 ? i : e.docView.posFromDOM(t, n, -1);
273
+ }
274
+ function Ee(e, t, n) {
275
+ let r = e.childNodes.length;
276
+ if (r && n.top < n.bottom) for (let i = Math.max(0, Math.min(r - 1, Math.floor(r * (t.top - n.top) / (n.bottom - n.top)) - 2)), a = i;;) {
277
+ let n = e.childNodes[a];
278
+ if (n.nodeType == 1) {
279
+ let e = n.getClientRects();
280
+ for (let r = 0; r < e.length; r++) {
281
+ let i = e[r];
282
+ if (Se(t, i)) return Ee(n, t, i);
283
+ }
284
+ }
285
+ if ((a = (a + 1) % r) == i) break;
286
+ }
287
+ return e;
288
+ }
289
+ function De(e, t) {
290
+ let n = e.dom.ownerDocument, r, i = 0, a = ne(n, t.left, t.top);
291
+ a && ({node: r, offset: i} = a);
292
+ let o = (e.root.elementFromPoint ? e.root : n).elementFromPoint(t.left, t.top), s;
293
+ if (!o || !e.dom.contains(o.nodeType == 1 ? o : o.parentNode)) {
294
+ let n = e.dom.getBoundingClientRect();
295
+ if (!Se(t, n) || (o = Ee(e.dom, t, n), !o)) return null;
296
+ }
297
+ if (A) for (let e = o; r && e; e = d(e)) e.draggable && (r = void 0);
298
+ if (o = Ce(o, t), r) {
299
+ if (O && r.nodeType == 1 && (i = Math.min(i, r.childNodes.length), i < r.childNodes.length)) {
300
+ let e = r.childNodes[i], n;
301
+ e.nodeName == "IMG" && (n = e.getBoundingClientRect()).right <= t.left && n.bottom > t.top && i++;
302
+ }
303
+ let n;
304
+ ue && i && r.nodeType == 1 && (n = r.childNodes[i - 1]).nodeType == 1 && n.contentEditable == "false" && n.getBoundingClientRect().top >= t.top && i--, r == e.dom && i == r.childNodes.length - 1 && r.lastChild.nodeType == 1 && t.top > r.lastChild.getBoundingClientRect().bottom ? s = e.state.doc.content.size : (i == 0 || r.nodeType != 1 || r.childNodes[i - 1].nodeName != "BR") && (s = Te(e, r, i, t));
305
+ }
306
+ s ??= we(e, o, t);
307
+ let c = e.docView.nearestDesc(o, !0);
308
+ return {
309
+ pos: s,
310
+ inside: c ? c.posAtStart - c.border : -1
311
+ };
312
+ }
313
+ function Oe(e) {
314
+ return e.top < e.bottom || e.left < e.right;
315
+ }
316
+ function I(e, t) {
317
+ let n = e.getClientRects();
318
+ if (n.length) {
319
+ let e = n[t < 0 ? 0 : n.length - 1];
320
+ if (Oe(e)) return e;
321
+ }
322
+ return Array.prototype.find.call(n, Oe) || e.getBoundingClientRect();
323
+ }
324
+ var ke = /[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;
325
+ function Ae(e, t, n) {
326
+ let { node: r, offset: i, atom: a } = e.docView.domFromPos(t, n < 0 ? -1 : 1), o = ue || O;
327
+ if (r.nodeType == 3) {
328
+ if (o && (ke.test(r.nodeValue) || (n < 0 ? !i : i == r.nodeValue.length))) {
329
+ let e = I(p(r, i, i), n);
330
+ if (O && i && /\s/.test(r.nodeValue[i - 1]) && i < r.nodeValue.length) {
331
+ let t = I(p(r, i - 1, i - 1), -1);
332
+ if (t.top == e.top) {
333
+ let n = I(p(r, i, i + 1), -1);
334
+ if (n.top != e.top) return je(n, n.left < t.left);
335
+ }
336
+ }
337
+ return e;
338
+ }
339
+ {
340
+ let e = i, t = i, a = n < 0 ? 1 : -1;
341
+ return n < 0 && !i ? (t++, a = -1) : n >= 0 && i == r.nodeValue.length ? (e--, a = 1) : n < 0 ? e-- : t++, je(I(p(r, e, t), a), a < 0);
342
+ }
343
+ }
344
+ if (!e.state.doc.resolve(t - (a || 0)).parent.inlineContent) {
345
+ if (a == null && i && (n < 0 || i == v(r))) {
346
+ let e = r.childNodes[i - 1];
347
+ if (e.nodeType == 1) return Me(e.getBoundingClientRect(), !1);
348
+ }
349
+ if (a == null && i < v(r)) {
350
+ let e = r.childNodes[i];
351
+ if (e.nodeType == 1) return Me(e.getBoundingClientRect(), !0);
352
+ }
353
+ return Me(r.getBoundingClientRect(), n >= 0);
354
+ }
355
+ if (a == null && i && (n < 0 || i == v(r))) {
356
+ let e = r.childNodes[i - 1], t = e.nodeType == 3 ? p(e, v(e) - +!o) : e.nodeType == 1 && (e.nodeName != "BR" || !e.nextSibling) ? e : null;
357
+ if (t) return je(I(t, 1), !1);
358
+ }
359
+ if (a == null && i < v(r)) {
360
+ let e = r.childNodes[i];
361
+ for (; e.pmViewDesc && e.pmViewDesc.ignoreForCoords;) e = e.nextSibling;
362
+ let t = e ? e.nodeType == 3 ? p(e, 0, +!o) : e.nodeType == 1 ? e : null : null;
363
+ if (t) return je(I(t, -1), !0);
364
+ }
365
+ return je(I(r.nodeType == 3 ? p(r) : r, -n), n >= 0);
366
+ }
367
+ function je(e, t) {
368
+ if (e.width == 0) return e;
369
+ let n = t ? e.left : e.right;
370
+ return {
371
+ top: e.top,
372
+ bottom: e.bottom,
373
+ left: n,
374
+ right: n
375
+ };
376
+ }
377
+ function Me(e, t) {
378
+ if (e.height == 0) return e;
379
+ let n = t ? e.top : e.bottom;
380
+ return {
381
+ top: n,
382
+ bottom: n,
383
+ left: e.left,
384
+ right: e.right
385
+ };
386
+ }
387
+ function Ne(e, t, n) {
388
+ let r = e.state, i = e.root.activeElement;
389
+ r != t && e.updateState(t), i != e.dom && e.focus();
390
+ try {
391
+ return n();
392
+ } finally {
393
+ r != t && e.updateState(r), i != e.dom && i && i.focus();
394
+ }
395
+ }
396
+ function Pe(e, t, n) {
397
+ let r = t.selection, i = n == "up" ? r.$from : r.$to;
398
+ return Ne(e, t, () => {
399
+ let { node: t } = e.docView.domFromPos(i.pos, n == "up" ? -1 : 1);
400
+ for (;;) {
401
+ let n = e.docView.nearestDesc(t, !0);
402
+ if (!n) break;
403
+ if (n.node.isBlock) {
404
+ t = n.contentDOM || n.dom;
405
+ break;
406
+ }
407
+ t = n.dom.parentNode;
408
+ }
409
+ let r = Ae(e, i.pos, 1);
410
+ for (let e = t.firstChild; e; e = e.nextSibling) {
411
+ let t;
412
+ if (e.nodeType == 1) t = e.getClientRects();
413
+ else if (e.nodeType == 3) t = p(e, 0, e.nodeValue.length).getClientRects();
414
+ else continue;
415
+ for (let e = 0; e < t.length; e++) {
416
+ let i = t[e];
417
+ if (i.bottom > i.top + 1 && (n == "up" ? r.top - i.top > (i.bottom - r.top) * 2 : i.bottom - r.bottom > (r.bottom - i.top) * 2)) return !1;
418
+ }
419
+ }
420
+ return !0;
421
+ });
422
+ }
423
+ var Fe = /[\u0590-\u08ac]/;
424
+ function Ie(e, t, n) {
425
+ let { $head: r } = t.selection;
426
+ if (!r.parent.isTextblock) return !1;
427
+ let i = r.parentOffset, a = !i, o = i == r.parent.content.size, s = e.domSelection();
428
+ return s ? !Fe.test(r.parent.textContent) || !s.modify ? n == "left" || n == "backward" ? a : o : Ne(e, t, () => {
429
+ let { focusNode: t, focusOffset: i, anchorNode: a, anchorOffset: o } = e.domSelectionRange(), c = s.caretBidiLevel;
430
+ s.modify("move", n, "character");
431
+ let l = r.depth ? e.docView.domAfterPos(r.before()) : e.dom, { focusNode: u, focusOffset: d } = e.domSelectionRange(), f = u && !l.contains(u.nodeType == 1 ? u : u.parentNode) || t == u && i == d;
432
+ try {
433
+ s.collapse(a, o), t && (t != a || i != o) && s.extend && s.extend(t, i);
434
+ } catch {}
435
+ return c != null && (s.caretBidiLevel = c), f;
436
+ }) : r.pos == r.start() || r.pos == r.end();
437
+ }
438
+ var Le = null, Re = null, ze = !1;
439
+ function Be(e, t, n) {
440
+ return Le == t && Re == n ? ze : (Le = t, Re = n, ze = n == "up" || n == "down" ? Pe(e, t, n) : Ie(e, t, n));
441
+ }
442
+ var L = 0, Ve = 1, R = 2, z = 3, He = class {
443
+ constructor(e, t, n, r) {
444
+ this.parent = e, this.children = t, this.dom = n, this.contentDOM = r, this.dirty = L, n.pmViewDesc = this;
445
+ }
446
+ matchesWidget(e) {
447
+ return !1;
448
+ }
449
+ matchesMark(e) {
450
+ return !1;
451
+ }
452
+ matchesNode(e, t, n) {
453
+ return !1;
454
+ }
455
+ matchesHack(e) {
456
+ return !1;
457
+ }
458
+ parseRule(e) {
459
+ return null;
460
+ }
461
+ stopEvent(e) {
462
+ return !1;
463
+ }
464
+ get size() {
465
+ let e = 0;
466
+ for (let t = 0; t < this.children.length; t++) e += this.children[t].size;
467
+ return e;
468
+ }
469
+ get border() {
470
+ return 0;
471
+ }
472
+ destroy() {
473
+ this.parent = void 0, this.dom.pmViewDesc == this && (this.dom.pmViewDesc = void 0);
474
+ for (let e = 0; e < this.children.length; e++) this.children[e].destroy();
475
+ }
476
+ posBeforeChild(e) {
477
+ for (let t = 0, n = this.posAtStart;; t++) {
478
+ let r = this.children[t];
479
+ if (r == e) return n;
480
+ n += r.size;
481
+ }
482
+ }
483
+ get posBefore() {
484
+ return this.parent.posBeforeChild(this);
485
+ }
486
+ get posAtStart() {
487
+ return this.parent ? this.parent.posBeforeChild(this) + this.border : 0;
488
+ }
489
+ get posAfter() {
490
+ return this.posBefore + this.size;
491
+ }
492
+ get posAtEnd() {
493
+ return this.posAtStart + this.size - 2 * this.border;
494
+ }
495
+ localPosFromDOM(e, t, n) {
496
+ if (this.contentDOM && this.contentDOM.contains(e.nodeType == 1 ? e : e.parentNode)) {
497
+ if (n < 0) {
498
+ let n, r;
499
+ if (e == this.contentDOM) n = e.childNodes[t - 1];
500
+ else {
501
+ for (; e.parentNode != this.contentDOM;) e = e.parentNode;
502
+ n = e.previousSibling;
503
+ }
504
+ for (; n && !((r = n.pmViewDesc) && r.parent == this);) n = n.previousSibling;
505
+ return n ? this.posBeforeChild(r) + r.size : this.posAtStart;
506
+ }
507
+ {
508
+ let n, r;
509
+ if (e == this.contentDOM) n = e.childNodes[t];
510
+ else {
511
+ for (; e.parentNode != this.contentDOM;) e = e.parentNode;
512
+ n = e.nextSibling;
513
+ }
514
+ for (; n && !((r = n.pmViewDesc) && r.parent == this);) n = n.nextSibling;
515
+ return n ? this.posBeforeChild(r) : this.posAtEnd;
516
+ }
517
+ }
518
+ let r;
519
+ if (e == this.dom && this.contentDOM) r = t > u(this.contentDOM);
520
+ else if (this.contentDOM && this.contentDOM != this.dom && this.dom.contains(this.contentDOM)) r = e.compareDocumentPosition(this.contentDOM) & 2;
521
+ else if (this.dom.firstChild) {
522
+ if (t == 0) for (let t = e;; t = t.parentNode) {
523
+ if (t == this.dom) {
524
+ r = !1;
525
+ break;
526
+ }
527
+ if (t.previousSibling) break;
528
+ }
529
+ if (r == null && t == e.childNodes.length) for (let t = e;; t = t.parentNode) {
530
+ if (t == this.dom) {
531
+ r = !0;
532
+ break;
533
+ }
534
+ if (t.nextSibling) break;
535
+ }
536
+ }
537
+ return r ?? n > 0 ? this.posAtEnd : this.posAtStart;
538
+ }
539
+ nearestDesc(e, t = !1) {
540
+ for (let n = !0, r = e; r; r = r.parentNode) {
541
+ let i = this.getDesc(r), a;
542
+ if (i && (!t || i.node)) {
543
+ if (n && (a = i.nodeDOM) && !(a.nodeType == 1 ? a.contains(e.nodeType == 1 ? e : e.parentNode) : a == e)) n = !1;
544
+ else return i;
545
+ }
546
+ }
547
+ }
548
+ getDesc(e) {
549
+ let t = e.pmViewDesc;
550
+ for (let e = t; e; e = e.parent) if (e == this) return t;
551
+ }
552
+ posFromDOM(e, t, n) {
553
+ for (let r = e; r; r = r.parentNode) {
554
+ let i = this.getDesc(r);
555
+ if (i) return i.localPosFromDOM(e, t, n);
556
+ }
557
+ return -1;
558
+ }
559
+ descAt(e) {
560
+ for (let t = 0, n = 0; t < this.children.length; t++) {
561
+ let r = this.children[t], i = n + r.size;
562
+ if (n == e && i != n) {
563
+ for (; !r.border && r.children.length;) for (let e = 0; e < r.children.length; e++) {
564
+ let t = r.children[e];
565
+ if (t.size) {
566
+ r = t;
567
+ break;
568
+ }
569
+ }
570
+ return r;
571
+ }
572
+ if (e < i) return r.descAt(e - n - r.border);
573
+ n = i;
574
+ }
575
+ }
576
+ domFromPos(e, t) {
577
+ if (!this.contentDOM) return {
578
+ node: this.dom,
579
+ offset: 0,
580
+ atom: e + 1
581
+ };
582
+ let n = 0, r = 0;
583
+ for (let t = 0; n < this.children.length; n++) {
584
+ let i = this.children[n], a = t + i.size;
585
+ if (a > e || i instanceof Je) {
586
+ r = e - t;
587
+ break;
588
+ }
589
+ t = a;
590
+ }
591
+ if (r) return this.children[n].domFromPos(r - this.children[n].border, t);
592
+ for (let e; n && !(e = this.children[n - 1]).size && e instanceof Ue && e.side >= 0; n--);
593
+ if (t <= 0) {
594
+ let e, r = !0;
595
+ for (; e = n ? this.children[n - 1] : null, !(!e || e.dom.parentNode == this.contentDOM); n--, r = !1);
596
+ return e && t && r && !e.border && !e.domAtom ? e.domFromPos(e.size, t) : {
597
+ node: this.contentDOM,
598
+ offset: e ? u(e.dom) + 1 : 0
599
+ };
600
+ }
601
+ {
602
+ let e, r = !0;
603
+ for (; e = n < this.children.length ? this.children[n] : null, !(!e || e.dom.parentNode == this.contentDOM); n++, r = !1);
604
+ return e && r && !e.border && !e.domAtom ? e.domFromPos(0, t) : {
605
+ node: this.contentDOM,
606
+ offset: e ? u(e.dom) : this.contentDOM.childNodes.length
607
+ };
608
+ }
609
+ }
610
+ parseRange(e, t, n = 0) {
611
+ if (this.children.length == 0) return {
612
+ node: this.contentDOM,
613
+ from: e,
614
+ to: t,
615
+ fromOffset: 0,
616
+ toOffset: this.contentDOM.childNodes.length
617
+ };
618
+ let r = -1, i = -1;
619
+ for (let a = n, o = 0;; o++) {
620
+ let n = this.children[o], s = a + n.size;
621
+ if (r == -1 && e <= s) {
622
+ let i = a + n.border;
623
+ if (e >= i && t <= s - n.border && n.node && n.contentDOM && this.contentDOM.contains(n.contentDOM)) return n.parseRange(e, t, i);
624
+ e = a;
625
+ for (let t = o; t > 0; t--) {
626
+ let n = this.children[t - 1];
627
+ if (n.size && n.dom.parentNode == this.contentDOM && !n.emptyChildAt(1)) {
628
+ r = u(n.dom) + 1;
629
+ break;
630
+ }
631
+ e -= n.size;
632
+ }
633
+ r == -1 && (r = 0);
634
+ }
635
+ if (r > -1 && (s > t || o == this.children.length - 1)) {
636
+ t = s;
637
+ for (let e = o + 1; e < this.children.length; e++) {
638
+ let n = this.children[e];
639
+ if (n.size && n.dom.parentNode == this.contentDOM && !n.emptyChildAt(-1)) {
640
+ i = u(n.dom);
641
+ break;
642
+ }
643
+ t += n.size;
644
+ }
645
+ i == -1 && (i = this.contentDOM.childNodes.length);
646
+ break;
647
+ }
648
+ a = s;
649
+ }
650
+ return {
651
+ node: this.contentDOM,
652
+ from: e,
653
+ to: t,
654
+ fromOffset: r,
655
+ toOffset: i
656
+ };
657
+ }
658
+ emptyChildAt(e) {
659
+ if (this.border || !this.contentDOM || !this.children.length) return !1;
660
+ let t = this.children[e < 0 ? 0 : this.children.length - 1];
661
+ return t.size == 0 || t.emptyChildAt(e);
662
+ }
663
+ domAfterPos(e) {
664
+ let { node: t, offset: n } = this.domFromPos(e, 0);
665
+ if (t.nodeType != 1 || n == t.childNodes.length) throw RangeError("No node after pos " + e);
666
+ return t.childNodes[n];
667
+ }
668
+ setSelection(e, t, n, r = !1) {
669
+ let i = Math.min(e, t), a = Math.max(e, t);
670
+ for (let o = 0, s = 0; o < this.children.length; o++) {
671
+ let c = this.children[o], l = s + c.size;
672
+ if (i > s && a < l) return c.setSelection(e - s - c.border, t - s - c.border, n, r);
673
+ s = l;
674
+ }
675
+ let o = this.domFromPos(e, e ? -1 : 1), s = t == e ? o : this.domFromPos(t, t ? -1 : 1), c = n.root.getSelection(), l = n.domSelectionRange(), d = !1;
676
+ if ((O || A) && e == t) {
677
+ let { node: e, offset: t } = o;
678
+ if (e.nodeType == 3) {
679
+ if (d = !!(t && e.nodeValue[t - 1] == "\n"), d && t == e.nodeValue.length) for (let t = e, n; t; t = t.parentNode) {
680
+ if (n = t.nextSibling) {
681
+ n.nodeName == "BR" && (o = s = {
682
+ node: n.parentNode,
683
+ offset: u(n) + 1
684
+ });
685
+ break;
686
+ }
687
+ let e = t.pmViewDesc;
688
+ if (e && e.node && e.node.isBlock) break;
689
+ }
690
+ } else {
691
+ let n = e.childNodes[t - 1];
692
+ d = n && (n.nodeName == "BR" || n.contentEditable == "false");
693
+ }
694
+ }
695
+ if (O && l.focusNode && l.focusNode != s.node && l.focusNode.nodeType == 1) {
696
+ let e = l.focusNode.childNodes[l.focusOffset];
697
+ e && e.contentEditable == "false" && (r = !0);
698
+ }
699
+ if (!(r || d && A) && h(o.node, o.offset, l.anchorNode, l.anchorOffset) && h(s.node, s.offset, l.focusNode, l.focusOffset)) return;
700
+ let f = !1;
701
+ if ((c.extend || e == t) && !(d && O)) {
702
+ c.collapse(o.node, o.offset);
703
+ try {
704
+ e != t && c.extend(s.node, s.offset), f = !0;
705
+ } catch {}
706
+ }
707
+ if (!f) {
708
+ if (e > t) {
709
+ let e = o;
710
+ o = s, s = e;
711
+ }
712
+ let n = document.createRange();
713
+ n.setEnd(s.node, s.offset), n.setStart(o.node, o.offset), c.removeAllRanges(), c.addRange(n);
714
+ }
715
+ }
716
+ ignoreMutation(e) {
717
+ return !this.contentDOM && e.type != "selection";
718
+ }
719
+ get contentLost() {
720
+ return this.contentDOM && this.contentDOM != this.dom && !this.dom.contains(this.contentDOM);
721
+ }
722
+ markDirty(e, t) {
723
+ for (let n = 0, r = 0; r < this.children.length; r++) {
724
+ let i = this.children[r], a = n + i.size;
725
+ if (n == a ? e <= a && t >= n : e < a && t > n) {
726
+ let r = n + i.border, o = a - i.border;
727
+ if (e >= r && t <= o) {
728
+ this.dirty = e == n || t == a ? R : Ve, e == r && t == o && (i.contentLost || i.dom.parentNode != this.contentDOM) ? i.dirty = z : i.markDirty(e - r, t - r);
729
+ return;
730
+ }
731
+ i.dirty = i.dom == i.contentDOM && i.dom.parentNode == this.contentDOM && !i.children.length ? R : z;
732
+ }
733
+ n = a;
734
+ }
735
+ this.dirty = R;
736
+ }
737
+ markParentsDirty() {
738
+ let e = 1;
739
+ for (let t = this.parent; t; t = t.parent, e++) {
740
+ let n = e == 1 ? R : Ve;
741
+ t.dirty < n && (t.dirty = n);
742
+ }
743
+ }
744
+ get domAtom() {
745
+ return !1;
746
+ }
747
+ get ignoreForCoords() {
748
+ return !1;
749
+ }
750
+ get ignoreForSelection() {
751
+ return !1;
752
+ }
753
+ isText(e) {
754
+ return !1;
755
+ }
756
+ }, Ue = class extends He {
757
+ constructor(e, t, n, r) {
758
+ let i, a = t.type.toDOM;
759
+ if (typeof a == "function" && (a = a(n, () => {
760
+ if (!i) return r;
761
+ if (i.parent) return i.parent.posBeforeChild(i);
762
+ })), !t.type.spec.raw) {
763
+ if (a.nodeType != 1) {
764
+ let e = document.createElement("span");
765
+ e.appendChild(a), a = e;
766
+ }
767
+ a.contentEditable = "false", a.classList.add("ProseMirror-widget");
768
+ }
769
+ super(e, [], a, null), this.widget = t, this.widget = t, i = this;
770
+ }
771
+ matchesWidget(e) {
772
+ return this.dirty == L && e.type.eq(this.widget.type);
773
+ }
774
+ parseRule() {
775
+ return { ignore: !0 };
776
+ }
777
+ stopEvent(e) {
778
+ let t = this.widget.spec.stopEvent;
779
+ return t ? t(e) : !1;
780
+ }
781
+ ignoreMutation(e) {
782
+ return e.type != "selection" || this.widget.spec.ignoreSelection;
783
+ }
784
+ destroy() {
785
+ this.widget.type.destroy(this.dom), super.destroy();
786
+ }
787
+ get domAtom() {
788
+ return !0;
789
+ }
790
+ get ignoreForSelection() {
791
+ return !!this.widget.type.spec.relaxedSide;
792
+ }
793
+ get side() {
794
+ return this.widget.type.side;
795
+ }
796
+ }, We = class extends He {
797
+ constructor(e, t, n, r) {
798
+ super(e, [], t, null), this.textDOM = n, this.text = r;
799
+ }
800
+ get size() {
801
+ return this.text.length;
802
+ }
803
+ localPosFromDOM(e, t) {
804
+ return e == this.textDOM ? this.posAtStart + t : this.posAtStart + (t ? this.size : 0);
805
+ }
806
+ domFromPos(e) {
807
+ return {
808
+ node: this.textDOM,
809
+ offset: e
810
+ };
811
+ }
812
+ ignoreMutation(e) {
813
+ return e.type === "characterData" && e.target.nodeValue == e.oldValue;
814
+ }
815
+ }, Ge = class e extends He {
816
+ constructor(e, t, n, r, i) {
817
+ super(e, [], n, r), this.mark = t, this.spec = i;
818
+ }
819
+ static create(n, r, i, a) {
820
+ let o = a.nodeViews[r.type.name], s = o && o(r, a, i);
821
+ return (!s || !s.dom) && (s = t.renderSpec(document, r.type.spec.toDOM(r, i), null, r.attrs)), new e(n, r, s.dom, s.contentDOM || s.dom, s);
822
+ }
823
+ parseRule() {
824
+ return this.dirty & z || this.mark.type.spec.reparseInView ? null : {
825
+ mark: this.mark.type.name,
826
+ attrs: this.mark.attrs,
827
+ contentElement: this.contentDOM
828
+ };
829
+ }
830
+ matchesMark(e) {
831
+ return this.dirty != z && this.mark.eq(e);
832
+ }
833
+ markDirty(e, t) {
834
+ if (super.markDirty(e, t), this.dirty != L) {
835
+ let e = this.parent;
836
+ for (; !e.node;) e = e.parent;
837
+ e.dirty < this.dirty && (e.dirty = this.dirty), this.dirty = L;
838
+ }
839
+ }
840
+ slice(t, n, r) {
841
+ let i = e.create(this.parent, this.mark, !0, r), a = this.children, o = this.size;
842
+ n < o && (a = ut(a, n, o, r)), t > 0 && (a = ut(a, 0, t, r));
843
+ for (let e = 0; e < a.length; e++) a[e].parent = i;
844
+ return i.children = a, i;
845
+ }
846
+ ignoreMutation(e) {
847
+ return this.spec.ignoreMutation ? this.spec.ignoreMutation(e) : super.ignoreMutation(e);
848
+ }
849
+ destroy() {
850
+ this.spec.destroy && this.spec.destroy(), super.destroy();
851
+ }
852
+ }, B = class e extends He {
853
+ constructor(e, t, n, r, i, a, o) {
854
+ super(e, [], i, a), this.node = t, this.outerDeco = n, this.innerDeco = r, this.nodeDOM = o;
855
+ }
856
+ static create(n, r, i, a, o, s) {
857
+ let c = o.nodeViews[r.type.name], l, u = c && c(r, o, () => {
858
+ if (!l) return s;
859
+ if (l.parent) return l.parent.posBeforeChild(l);
860
+ }, i, a), d = u && u.dom, f = u && u.contentDOM;
861
+ if (r.isText) {
862
+ if (!d) d = document.createTextNode(r.text);
863
+ else if (d.nodeType != 3) throw RangeError("Text must be rendered as a DOM text node");
864
+ } else if (!d) {
865
+ let e = t.renderSpec(document, r.type.spec.toDOM(r), null, r.attrs);
866
+ ({dom: d, contentDOM: f} = e);
867
+ }
868
+ !f && !r.isText && d.nodeName != "BR" && (d.hasAttribute("contenteditable") || (d.contentEditable = "false"), r.type.spec.draggable && (d.draggable = !0));
869
+ let p = d;
870
+ return d = tt(d, i, r), u ? l = new Ye(n, r, i, a, d, f || null, p, u) : r.isText ? new qe(n, r, i, a, d, p) : new e(n, r, i, a, d, f || null, p);
871
+ }
872
+ parseRule(e) {
873
+ if (this.node.type.spec.reparseInView) return null;
874
+ let t = {
875
+ node: this.node.type.name,
876
+ attrs: this.node.attrs
877
+ };
878
+ if (this.node.type.whitespace == "pre" && (t.preserveWhitespace = "full"), !this.contentDOM) t.getContent = () => this.node.content;
879
+ else if (!this.contentLost) t.contentElement = this.contentDOM;
880
+ else {
881
+ for (let e = this.children.length - 1; e >= 0; e--) {
882
+ let n = this.children[e];
883
+ if (this.dom.contains(n.dom.parentNode)) {
884
+ t.contentElement = n.dom.parentNode;
885
+ break;
886
+ }
887
+ }
888
+ if (!t.contentElement) {
889
+ let r = e && e.find((t) => t.nodeType == 1 && e.indexOf(t.parentNode) < 0 && this.dom.contains(t));
890
+ r ? t.contentElement = r : t.getContent = () => n.empty;
891
+ }
892
+ }
893
+ return t;
894
+ }
895
+ matchesNode(e, t, n) {
896
+ return this.dirty == L && e.eq(this.node) && nt(t, this.outerDeco) && n.eq(this.innerDeco);
897
+ }
898
+ get size() {
899
+ return this.node.nodeSize;
900
+ }
901
+ get border() {
902
+ return +!this.node.isLeaf;
903
+ }
904
+ updateChildren(e, t) {
905
+ let n = this.node.inlineContent, i = t, a = e.composing ? this.localCompositionInfo(e, t) : null, o = a && a.pos > -1 ? a : null, s = a && a.pos < 0, c = new it(this, o && o.node, e);
906
+ st(this.node, this.innerDeco, (t, a, o) => {
907
+ t.spec.marks ? c.syncToMarks(t.spec.marks, n, e, a) : t.type.side >= 0 && !o && c.syncToMarks(a == this.node.childCount ? r.none : this.node.child(a).marks, n, e, a), c.placeWidget(t, e, i);
908
+ }, (t, r, o, l) => {
909
+ c.syncToMarks(t.marks, n, e, l);
910
+ let u;
911
+ c.findNodeMatch(t, r, o, l) || s && e.state.selection.from > i && e.state.selection.to < i + t.nodeSize && (u = c.findIndexWithChild(a.node)) > -1 && c.updateNodeAt(t, r, o, u, e) || c.updateNextNode(t, r, o, e, l, i) || c.addNode(t, r, o, e, i), i += t.nodeSize;
912
+ }), c.syncToMarks([], n, e, 0), this.node.isTextblock && c.addTextblockHacks(), c.destroyRest(), (c.changed || this.dirty == R) && (o && this.protectLocalComposition(e, o), Xe(this.contentDOM, this.children, e), j && ct(this.dom));
913
+ }
914
+ localCompositionInfo(e, t) {
915
+ let { from: n, to: r } = e.state.selection;
916
+ if (!(e.state.selection instanceof l) || n < t || r > t + this.node.content.size) return null;
917
+ let i = e.input.compositionNode;
918
+ if (!i || !this.dom.contains(i.parentNode)) return null;
919
+ if (this.node.inlineContent) {
920
+ let e = i.nodeValue, a = lt(this.node.content, e, n - t, r - t);
921
+ return a < 0 ? null : {
922
+ node: i,
923
+ pos: a,
924
+ text: e
925
+ };
926
+ }
927
+ return {
928
+ node: i,
929
+ pos: -1,
930
+ text: ""
931
+ };
932
+ }
933
+ protectLocalComposition(e, { node: t, pos: n, text: r }) {
934
+ if (this.getDesc(t)) return;
935
+ let i = t;
936
+ for (; i.parentNode != this.contentDOM; i = i.parentNode) {
937
+ for (; i.previousSibling;) i.parentNode.removeChild(i.previousSibling);
938
+ for (; i.nextSibling;) i.parentNode.removeChild(i.nextSibling);
939
+ i.pmViewDesc && (i.pmViewDesc = void 0);
940
+ }
941
+ let a = new We(this, i, t, r);
942
+ e.input.compositionNodes.push(a), this.children = ut(this.children, n, n + r.length, e, a);
943
+ }
944
+ update(e, t, n, r) {
945
+ return this.dirty == z || !e.sameMarkup(this.node) ? !1 : (this.updateInner(e, t, n, r), !0);
946
+ }
947
+ updateInner(e, t, n, r) {
948
+ this.updateOuterDeco(t), this.node = e, this.innerDeco = n, this.contentDOM && this.updateChildren(r, this.posAtStart), this.dirty = L;
949
+ }
950
+ updateOuterDeco(e) {
951
+ if (nt(e, this.outerDeco)) return;
952
+ let t = this.nodeDOM.nodeType != 1, n = this.dom;
953
+ this.dom = $e(this.dom, this.nodeDOM, Qe(this.outerDeco, this.node, t), Qe(e, this.node, t)), this.dom != n && (n.pmViewDesc = void 0, this.dom.pmViewDesc = this), this.outerDeco = e;
954
+ }
955
+ selectNode() {
956
+ this.nodeDOM.nodeType == 1 && (this.nodeDOM.classList.add("ProseMirror-selectednode"), (this.contentDOM || !this.node.type.spec.draggable) && (this.nodeDOM.draggable = !0));
957
+ }
958
+ deselectNode() {
959
+ this.nodeDOM.nodeType == 1 && (this.nodeDOM.classList.remove("ProseMirror-selectednode"), (this.contentDOM || !this.node.type.spec.draggable) && this.nodeDOM.removeAttribute("draggable"));
960
+ }
961
+ get domAtom() {
962
+ return this.node.isAtom;
963
+ }
964
+ };
965
+ function Ke(e, t, n, r, i) {
966
+ tt(r, t, e);
967
+ let a = new B(void 0, e, t, n, r, r, r);
968
+ return a.contentDOM && a.updateChildren(i, 0), a;
969
+ }
970
+ var qe = class e extends B {
971
+ constructor(e, t, n, r, i, a) {
972
+ super(e, t, n, r, i, null, a);
973
+ }
974
+ parseRule() {
975
+ let e = this.nodeDOM.parentNode;
976
+ for (; e && e != this.dom && !e.pmIsDeco;) e = e.parentNode;
977
+ return { skip: e || !0 };
978
+ }
979
+ update(e, t, n, r) {
980
+ return this.dirty == z || this.dirty != L && !this.inParent() || !e.sameMarkup(this.node) ? !1 : (this.updateOuterDeco(t), (this.dirty != L || e.text != this.node.text) && e.text != this.nodeDOM.nodeValue && (this.nodeDOM.nodeValue = e.text, r.trackWrites == this.nodeDOM && (r.trackWrites = null)), this.node = e, this.dirty = L, !0);
981
+ }
982
+ inParent() {
983
+ let e = this.parent.contentDOM;
984
+ for (let t = this.nodeDOM; t; t = t.parentNode) if (t == e) return !0;
985
+ return !1;
986
+ }
987
+ domFromPos(e) {
988
+ return {
989
+ node: this.nodeDOM,
990
+ offset: e
991
+ };
992
+ }
993
+ localPosFromDOM(e, t, n) {
994
+ return e == this.nodeDOM ? this.posAtStart + Math.min(t, this.node.text.length) : super.localPosFromDOM(e, t, n);
995
+ }
996
+ ignoreMutation(e) {
997
+ return e.type != "characterData" && e.type != "selection";
998
+ }
999
+ slice(t, n, r) {
1000
+ let i = this.node.cut(t, n), a = document.createTextNode(i.text);
1001
+ return new e(this.parent, i, this.outerDeco, this.innerDeco, a, a);
1002
+ }
1003
+ markDirty(e, t) {
1004
+ super.markDirty(e, t), this.dom != this.nodeDOM && (e == 0 || t == this.nodeDOM.nodeValue.length) && (this.dirty = z);
1005
+ }
1006
+ get domAtom() {
1007
+ return !1;
1008
+ }
1009
+ isText(e) {
1010
+ return this.node.text == e;
1011
+ }
1012
+ }, Je = class extends He {
1013
+ parseRule() {
1014
+ return { ignore: !0 };
1015
+ }
1016
+ matchesHack(e) {
1017
+ return this.dirty == L && this.dom.nodeName == e;
1018
+ }
1019
+ get domAtom() {
1020
+ return !0;
1021
+ }
1022
+ get ignoreForCoords() {
1023
+ return this.dom.nodeName == "IMG";
1024
+ }
1025
+ }, Ye = class extends B {
1026
+ constructor(e, t, n, r, i, a, o, s) {
1027
+ super(e, t, n, r, i, a, o), this.spec = s;
1028
+ }
1029
+ update(e, t, n, r) {
1030
+ if (this.dirty == z) return !1;
1031
+ if (this.spec.update && (this.node.type == e.type || this.spec.multiType)) {
1032
+ let i = this.spec.update(e, t, n);
1033
+ return i && this.updateInner(e, t, n, r), i;
1034
+ }
1035
+ return !this.contentDOM && !e.isLeaf ? !1 : super.update(e, t, n, r);
1036
+ }
1037
+ selectNode() {
1038
+ this.spec.selectNode ? this.spec.selectNode() : super.selectNode();
1039
+ }
1040
+ deselectNode() {
1041
+ this.spec.deselectNode ? this.spec.deselectNode() : super.deselectNode();
1042
+ }
1043
+ setSelection(e, t, n, r) {
1044
+ this.spec.setSelection ? this.spec.setSelection(e, t, n.root) : super.setSelection(e, t, n, r);
1045
+ }
1046
+ destroy() {
1047
+ this.spec.destroy && this.spec.destroy(), super.destroy();
1048
+ }
1049
+ stopEvent(e) {
1050
+ return this.spec.stopEvent ? this.spec.stopEvent(e) : !1;
1051
+ }
1052
+ ignoreMutation(e) {
1053
+ return this.spec.ignoreMutation ? this.spec.ignoreMutation(e) : super.ignoreMutation(e);
1054
+ }
1055
+ };
1056
+ function Xe(e, t, n) {
1057
+ let r = e.firstChild, i = !1;
1058
+ for (let a = 0; a < t.length; a++) {
1059
+ let o = t[a], s = o.dom;
1060
+ if (s.parentNode == e) {
1061
+ for (; s != r;) r = rt(r), i = !0;
1062
+ r = r.nextSibling;
1063
+ } else i = !0, e.insertBefore(s, r);
1064
+ if (o instanceof Ge) {
1065
+ let t = r ? r.previousSibling : e.lastChild;
1066
+ Xe(o.contentDOM, o.children, n), r = t ? t.nextSibling : e.firstChild;
1067
+ }
1068
+ }
1069
+ for (; r;) r = rt(r), i = !0;
1070
+ i && n.trackWrites == e && (n.trackWrites = null);
1071
+ }
1072
+ var Ze = function(e) {
1073
+ e && (this.nodeName = e);
1074
+ };
1075
+ Ze.prototype = Object.create(null);
1076
+ var V = [new Ze()];
1077
+ function Qe(e, t, n) {
1078
+ if (e.length == 0) return V;
1079
+ let r = n ? V[0] : new Ze(), i = [r];
1080
+ for (let a = 0; a < e.length; a++) {
1081
+ let o = e[a].type.attrs;
1082
+ if (o) {
1083
+ o.nodeName && i.push(r = new Ze(o.nodeName));
1084
+ for (let e in o) {
1085
+ let a = o[e];
1086
+ a != null && (n && i.length == 1 && i.push(r = new Ze(t.isInline ? "span" : "div")), e == "class" ? r.class = (r.class ? r.class + " " : "") + a : e == "style" ? r.style = (r.style ? r.style + ";" : "") + a : e != "nodeName" && (r[e] = a));
1087
+ }
1088
+ }
1089
+ }
1090
+ return i;
1091
+ }
1092
+ function $e(e, t, n, r) {
1093
+ if (n == V && r == V) return t;
1094
+ let i = t;
1095
+ for (let t = 0; t < r.length; t++) {
1096
+ let a = r[t], o = n[t];
1097
+ if (t) {
1098
+ let t;
1099
+ o && o.nodeName == a.nodeName && i != e && (t = i.parentNode) && t.nodeName.toLowerCase() == a.nodeName ? i = t : (t = document.createElement(a.nodeName), t.pmIsDeco = !0, t.appendChild(i), o = V[0], i = t);
1100
+ }
1101
+ et(i, o || V[0], a);
1102
+ }
1103
+ return i;
1104
+ }
1105
+ function et(e, t, n) {
1106
+ for (let r in t) r != "class" && r != "style" && r != "nodeName" && !(r in n) && e.removeAttribute(r);
1107
+ for (let r in n) r != "class" && r != "style" && r != "nodeName" && n[r] != t[r] && e.setAttribute(r, n[r]);
1108
+ if (t.class != n.class) {
1109
+ let r = t.class ? t.class.split(" ").filter(Boolean) : [], i = n.class ? n.class.split(" ").filter(Boolean) : [];
1110
+ for (let t = 0; t < r.length; t++) i.indexOf(r[t]) == -1 && e.classList.remove(r[t]);
1111
+ for (let t = 0; t < i.length; t++) r.indexOf(i[t]) == -1 && e.classList.add(i[t]);
1112
+ e.classList.length == 0 && e.removeAttribute("class");
1113
+ }
1114
+ if (t.style != n.style) {
1115
+ if (t.style) {
1116
+ let n = /\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g, r;
1117
+ for (; r = n.exec(t.style);) e.style.removeProperty(r[1]);
1118
+ }
1119
+ n.style && (e.style.cssText += n.style);
1120
+ }
1121
+ }
1122
+ function tt(e, t, n) {
1123
+ return $e(e, e, V, Qe(t, n, e.nodeType != 1));
1124
+ }
1125
+ function nt(e, t) {
1126
+ if (e.length != t.length) return !1;
1127
+ for (let n = 0; n < e.length; n++) if (!e[n].type.eq(t[n].type)) return !1;
1128
+ return !0;
1129
+ }
1130
+ function rt(e) {
1131
+ let t = e.nextSibling;
1132
+ return e.parentNode.removeChild(e), t;
1133
+ }
1134
+ var it = class {
1135
+ constructor(e, t, n) {
1136
+ this.lock = t, this.view = n, this.index = 0, this.stack = [], this.changed = !1, this.top = e, this.preMatch = at(e.node.content, e);
1137
+ }
1138
+ destroyBetween(e, t) {
1139
+ if (e != t) {
1140
+ for (let n = e; n < t; n++) this.top.children[n].destroy();
1141
+ this.top.children.splice(e, t - e), this.changed = !0;
1142
+ }
1143
+ }
1144
+ destroyRest() {
1145
+ this.destroyBetween(this.index, this.top.children.length);
1146
+ }
1147
+ syncToMarks(e, t, n, r) {
1148
+ let i = 0, a = this.stack.length >> 1, o = Math.min(a, e.length);
1149
+ for (; i < o && (i == a - 1 ? this.top : this.stack[i + 1 << 1]).matchesMark(e[i]) && e[i].type.spec.spanning !== !1;) i++;
1150
+ for (; i < a;) this.destroyRest(), this.top.dirty = L, this.index = this.stack.pop(), this.top = this.stack.pop(), a--;
1151
+ for (; a < e.length;) {
1152
+ this.stack.push(this.top, this.index + 1);
1153
+ let i = -1, o = this.top.children.length;
1154
+ r < this.preMatch.index && (o = Math.min(this.index + 3, o));
1155
+ for (let t = this.index; t < o; t++) {
1156
+ let n = this.top.children[t];
1157
+ if (n.matchesMark(e[a]) && !this.isLocked(n.dom)) {
1158
+ i = t;
1159
+ break;
1160
+ }
1161
+ }
1162
+ if (i < 0 && this.index < this.top.children.length) {
1163
+ let t = this.top.children[this.index];
1164
+ t instanceof Ge && t.dirty != z && t.mark.type == e[a].type && t.spec.update && !this.isLocked(t.dom) && t.spec.update(e[a]) && (t.mark = e[a], i = this.index, this.changed = !0);
1165
+ }
1166
+ if (i > -1) i > this.index && (this.changed = !0, this.destroyBetween(this.index, i)), this.top = this.top.children[this.index];
1167
+ else {
1168
+ let r = Ge.create(this.top, e[a], t, n);
1169
+ this.top.children.splice(this.index, 0, r), this.top = r, this.changed = !0;
1170
+ }
1171
+ this.index = 0, a++;
1172
+ }
1173
+ }
1174
+ findNodeMatch(e, t, n, r) {
1175
+ let i = -1, a;
1176
+ if (r >= this.preMatch.index && (a = this.preMatch.matches[r - this.preMatch.index]).parent == this.top && a.matchesNode(e, t, n)) i = this.top.children.indexOf(a, this.index);
1177
+ else for (let r = this.index, a = Math.min(this.top.children.length, r + 5); r < a; r++) {
1178
+ let a = this.top.children[r];
1179
+ if (a.matchesNode(e, t, n) && !this.preMatch.matched.has(a)) {
1180
+ i = r;
1181
+ break;
1182
+ }
1183
+ }
1184
+ return i < 0 ? !1 : (this.destroyBetween(this.index, i), this.index++, !0);
1185
+ }
1186
+ updateNodeAt(e, t, n, r, i) {
1187
+ let a = this.top.children[r];
1188
+ return a.dirty == z && a.dom == a.contentDOM && (a.dirty = R), a.update(e, t, n, i) ? (this.destroyBetween(this.index, r), this.index++, !0) : !1;
1189
+ }
1190
+ findIndexWithChild(e) {
1191
+ for (;;) {
1192
+ let t = e.parentNode;
1193
+ if (!t) return -1;
1194
+ if (t == this.top.contentDOM) {
1195
+ let t = e.pmViewDesc;
1196
+ if (t) {
1197
+ for (let e = this.index; e < this.top.children.length; e++) if (this.top.children[e] == t) return e;
1198
+ }
1199
+ return -1;
1200
+ }
1201
+ e = t;
1202
+ }
1203
+ }
1204
+ updateNextNode(e, t, n, r, i, a) {
1205
+ for (let o = this.index; o < this.top.children.length; o++) {
1206
+ let s = this.top.children[o];
1207
+ if (s instanceof B) {
1208
+ let c = this.preMatch.matched.get(s);
1209
+ if (c != null && c != i) return !1;
1210
+ let l = s.dom, u, d = this.isLocked(l) && !(e.isText && s.node && s.node.isText && s.nodeDOM.nodeValue == e.text && s.dirty != z && nt(t, s.outerDeco));
1211
+ if (!d && s.update(e, t, n, r)) return this.destroyBetween(this.index, o), s.dom != l && (this.changed = !0), this.index++, !0;
1212
+ if (!d && (u = this.recreateWrapper(s, e, t, n, r, a))) return this.destroyBetween(this.index, o), this.top.children[this.index] = u, u.contentDOM && (u.dirty = R, u.updateChildren(r, a + 1), u.dirty = L), this.changed = !0, this.index++, !0;
1213
+ break;
1214
+ }
1215
+ }
1216
+ return !1;
1217
+ }
1218
+ recreateWrapper(e, t, n, r, i, a) {
1219
+ if (e.dirty || t.isAtom || !e.children.length || !e.node.content.eq(t.content) || !nt(n, e.outerDeco) || !r.eq(e.innerDeco)) return null;
1220
+ let o = B.create(this.top, t, n, r, i, a);
1221
+ if (o.contentDOM) {
1222
+ o.children = e.children, e.children = [];
1223
+ for (let e of o.children) e.parent = o;
1224
+ }
1225
+ return e.destroy(), o;
1226
+ }
1227
+ addNode(e, t, n, r, i) {
1228
+ let a = B.create(this.top, e, t, n, r, i);
1229
+ a.contentDOM && a.updateChildren(r, i + 1), this.top.children.splice(this.index++, 0, a), this.changed = !0;
1230
+ }
1231
+ placeWidget(e, t, n) {
1232
+ let r = this.index < this.top.children.length ? this.top.children[this.index] : null;
1233
+ if (r && r.matchesWidget(e) && (e == r.widget || !r.widget.type.toDOM.parentNode)) this.index++;
1234
+ else {
1235
+ let r = new Ue(this.top, e, t, n);
1236
+ this.top.children.splice(this.index++, 0, r), this.changed = !0;
1237
+ }
1238
+ }
1239
+ addTextblockHacks() {
1240
+ let e = this.top.children[this.index - 1], t = this.top;
1241
+ for (; e instanceof Ge;) t = e, e = t.children[t.children.length - 1];
1242
+ (!e || !(e instanceof qe) || /\n$/.test(e.node.text) || this.view.requiresGeckoHackNode && /\s$/.test(e.node.text)) && ((A || k) && e && e.dom.contentEditable == "false" && this.addHackNode("IMG", t), this.addHackNode("BR", this.top));
1243
+ }
1244
+ addHackNode(e, t) {
1245
+ if (t == this.top && this.index < t.children.length && t.children[this.index].matchesHack(e)) this.index++;
1246
+ else {
1247
+ let n = document.createElement(e);
1248
+ e == "IMG" && (n.className = "ProseMirror-separator", n.alt = ""), e == "BR" && (n.className = "ProseMirror-trailingBreak");
1249
+ let r = new Je(this.top, [], n, null);
1250
+ t == this.top ? t.children.splice(this.index++, 0, r) : t.children.push(r), this.changed = !0;
1251
+ }
1252
+ }
1253
+ isLocked(e) {
1254
+ return this.lock && (e == this.lock || e.nodeType == 1 && e.contains(this.lock.parentNode));
1255
+ }
1256
+ };
1257
+ function at(e, t) {
1258
+ let n = t, r = n.children.length, i = e.childCount, a = /* @__PURE__ */ new Map(), o = [];
1259
+ outer: for (; i > 0;) {
1260
+ let s;
1261
+ for (;;) if (r) {
1262
+ let e = n.children[r - 1];
1263
+ if (e instanceof Ge) n = e, r = e.children.length;
1264
+ else {
1265
+ s = e, r--;
1266
+ break;
1267
+ }
1268
+ } else if (n == t) break outer;
1269
+ else r = n.parent.children.indexOf(n), n = n.parent;
1270
+ let c = s.node;
1271
+ if (c) {
1272
+ if (c != e.child(i - 1)) break;
1273
+ --i, a.set(s, i), o.push(s);
1274
+ }
1275
+ }
1276
+ return {
1277
+ index: i,
1278
+ matched: a,
1279
+ matches: o.reverse()
1280
+ };
1281
+ }
1282
+ function ot(e, t) {
1283
+ return e.type.side - t.type.side;
1284
+ }
1285
+ function st(e, t, n, r) {
1286
+ let i = t.locals(e), a = 0;
1287
+ if (i.length == 0) {
1288
+ for (let n = 0; n < e.childCount; n++) {
1289
+ let o = e.child(n);
1290
+ r(o, i, t.forChild(a, o), n), a += o.nodeSize;
1291
+ }
1292
+ return;
1293
+ }
1294
+ let o = 0, s = [], c = null;
1295
+ for (let l = 0;;) {
1296
+ let u, d;
1297
+ for (; o < i.length && i[o].to == a;) {
1298
+ let e = i[o++];
1299
+ e.widget && (u ? (d ||= [u]).push(e) : u = e);
1300
+ }
1301
+ if (u) {
1302
+ if (d) {
1303
+ d.sort(ot);
1304
+ for (let e = 0; e < d.length; e++) n(d[e], l, !!c);
1305
+ } else n(u, l, !!c);
1306
+ }
1307
+ let f, p;
1308
+ if (c) p = -1, f = c, c = null;
1309
+ else if (l < e.childCount) p = l, f = e.child(l++);
1310
+ else break;
1311
+ for (let e = 0; e < s.length; e++) s[e].to <= a && s.splice(e--, 1);
1312
+ for (; o < i.length && i[o].from <= a && i[o].to > a;) s.push(i[o++]);
1313
+ let m = a + f.nodeSize;
1314
+ if (f.isText) {
1315
+ let e = m;
1316
+ o < i.length && i[o].from < e && (e = i[o].from);
1317
+ for (let t = 0; t < s.length; t++) s[t].to < e && (e = s[t].to);
1318
+ e < m && (c = f.cut(e - a), f = f.cut(0, e - a), m = e, p = -1);
1319
+ } else for (; o < i.length && i[o].to < m;) o++;
1320
+ let h = f.isInline && !f.isLeaf ? s.filter((e) => !e.inline) : s.slice();
1321
+ r(f, h, t.forChild(a, f), p), a = m;
1322
+ }
1323
+ }
1324
+ function ct(e) {
1325
+ if (e.nodeName == "UL" || e.nodeName == "OL") {
1326
+ let t = e.style.cssText;
1327
+ e.style.cssText = t + "; list-style: square !important", window.getComputedStyle(e).listStyle, e.style.cssText = t;
1328
+ }
1329
+ }
1330
+ function lt(e, t, n, r) {
1331
+ for (let i = 0, a = 0; i < e.childCount && a <= r;) {
1332
+ let o = e.child(i++), s = a;
1333
+ if (a += o.nodeSize, !o.isText) continue;
1334
+ let c = o.text;
1335
+ for (; i < e.childCount;) {
1336
+ let t = e.child(i++);
1337
+ if (a += t.nodeSize, !t.isText) break;
1338
+ c += t.text;
1339
+ }
1340
+ if (a >= n) {
1341
+ if (a >= r && c.slice(r - t.length - s, r - s) == t) return r - t.length;
1342
+ let e = s < r ? c.lastIndexOf(t, r - s - 1) : -1;
1343
+ if (e >= 0 && e + t.length + s >= n) return s + e;
1344
+ if (n == r && c.length >= r + t.length - s && c.slice(r - s, r - s + t.length) == t) return r;
1345
+ }
1346
+ }
1347
+ return -1;
1348
+ }
1349
+ function ut(e, t, n, r, i) {
1350
+ let a = [];
1351
+ for (let o = 0, s = 0; o < e.length; o++) {
1352
+ let c = e[o], l = s, u = s += c.size;
1353
+ l >= n || u <= t ? a.push(c) : (l < t && a.push(c.slice(0, t - l, r)), i &&= (a.push(i), void 0), u > n && a.push(c.slice(n - l, c.size, r)));
1354
+ }
1355
+ return a;
1356
+ }
1357
+ function dt(e, t = null) {
1358
+ let n = e.domSelectionRange(), r = e.state.doc;
1359
+ if (!n.focusNode) return null;
1360
+ let i = e.docView.nearestDesc(n.focusNode), a = i && i.size == 0, o = e.docView.posFromDOM(n.focusNode, n.focusOffset, 1);
1361
+ if (o < 0) return null;
1362
+ let c = r.resolve(o), l, u;
1363
+ if (S(n)) {
1364
+ for (l = o; i && !i.node;) i = i.parent;
1365
+ let e = i.node;
1366
+ if (i && e.isAtom && s.isSelectable(e) && i.parent && !(e.isInline && b(n.focusNode, n.focusOffset, i.dom))) {
1367
+ let e = i.posBefore;
1368
+ u = new s(o == e ? c : r.resolve(e));
1369
+ }
1370
+ } else {
1371
+ if (n instanceof e.dom.ownerDocument.defaultView.Selection && n.rangeCount > 1) {
1372
+ let t = o, i = o;
1373
+ for (let r = 0; r < n.rangeCount; r++) {
1374
+ let a = n.getRangeAt(r);
1375
+ t = Math.min(t, e.docView.posFromDOM(a.startContainer, a.startOffset, 1)), i = Math.max(i, e.docView.posFromDOM(a.endContainer, a.endOffset, -1));
1376
+ }
1377
+ if (t < 0) return null;
1378
+ [l, o] = i == e.state.selection.anchor ? [i, t] : [t, i], c = r.resolve(o);
1379
+ } else l = e.docView.posFromDOM(n.anchorNode, n.anchorOffset, 1);
1380
+ if (l < 0) return null;
1381
+ }
1382
+ let d = r.resolve(l);
1383
+ if (!u) {
1384
+ let n = t == "pointer" || e.state.selection.head < c.pos && !a ? 1 : -1;
1385
+ u = xt(e, d, c, n);
1386
+ }
1387
+ return u;
1388
+ }
1389
+ function ft(e) {
1390
+ return e.editable ? e.hasFocus() : Ct(e) && document.activeElement && document.activeElement.contains(e.dom);
1391
+ }
1392
+ function H(e, t = !1) {
1393
+ let n = e.state.selection;
1394
+ if (yt(e, n), !ft(e)) return;
1395
+ let r = e.input.mouseDown;
1396
+ if (!t && k && r) {
1397
+ let t = e.domSelectionRange(), n = e.domObserver.currentSelection;
1398
+ if (t.anchorNode && n.anchorNode && h(t.anchorNode, t.anchorOffset, n.anchorNode, n.anchorOffset) && r.delaySelUpdate()) {
1399
+ e.domObserver.setCurSelection();
1400
+ return;
1401
+ }
1402
+ }
1403
+ if (e.domObserver.disconnectSelection(), e.cursorWrapper) vt(e);
1404
+ else {
1405
+ let { anchor: r, head: i } = n, a, o;
1406
+ pt && !(n instanceof l) && (n.$from.parent.inlineContent || (a = mt(e, n.from)), !n.empty && !n.$from.parent.inlineContent && (o = mt(e, n.to))), e.docView.setSelection(r, i, e, t), pt && (a && gt(a), o && gt(o)), n.visible ? e.dom.classList.remove("ProseMirror-hideselection") : (e.dom.classList.add("ProseMirror-hideselection"), "onselectionchange" in document && _t(e));
1407
+ }
1408
+ e.domObserver.setCurSelection(), e.domObserver.connectSelection();
1409
+ }
1410
+ var pt = A || k && ce < 63;
1411
+ function mt(e, t) {
1412
+ let { node: n, offset: r } = e.docView.domFromPos(t, 0), i = r < n.childNodes.length ? n.childNodes[r] : null, a = r ? n.childNodes[r - 1] : null;
1413
+ if (A && i && i.contentEditable == "false") return ht(i);
1414
+ if ((!i || i.contentEditable == "false") && (!a || a.contentEditable == "false")) {
1415
+ if (i) return ht(i);
1416
+ if (a) return ht(a);
1417
+ }
1418
+ }
1419
+ function ht(e) {
1420
+ return e.contentEditable = "true", A && e.draggable && (e.draggable = !1, e.wasDraggable = !0), e;
1421
+ }
1422
+ function gt(e) {
1423
+ e.contentEditable = "false", e.wasDraggable &&= (e.draggable = !0, null);
1424
+ }
1425
+ function _t(e) {
1426
+ let t = e.dom.ownerDocument;
1427
+ t.removeEventListener("selectionchange", e.input.hideSelectionGuard);
1428
+ let n = e.domSelectionRange(), r = n.anchorNode, i = n.anchorOffset;
1429
+ t.addEventListener("selectionchange", e.input.hideSelectionGuard = () => {
1430
+ (n.anchorNode != r || n.anchorOffset != i) && (t.removeEventListener("selectionchange", e.input.hideSelectionGuard), setTimeout(() => {
1431
+ (!ft(e) || e.state.selection.visible) && e.dom.classList.remove("ProseMirror-hideselection");
1432
+ }, 20));
1433
+ });
1434
+ }
1435
+ function vt(e) {
1436
+ let t = e.domSelection();
1437
+ if (!t) return;
1438
+ let n = e.cursorWrapper.dom, r = n.nodeName == "IMG";
1439
+ r ? t.collapse(n.parentNode, u(n) + 1) : t.collapse(n, 0), !r && !e.state.selection.visible && E && D <= 11 && (n.disabled = !0, n.disabled = !1);
1440
+ }
1441
+ function yt(e, t) {
1442
+ if (t instanceof s) {
1443
+ let n = e.docView.descAt(t.from);
1444
+ n != e.lastSelectedViewDesc && (bt(e), n && n.selectNode(), e.lastSelectedViewDesc = n);
1445
+ } else bt(e);
1446
+ }
1447
+ function bt(e) {
1448
+ e.lastSelectedViewDesc &&= (e.lastSelectedViewDesc.parent && e.lastSelectedViewDesc.deselectNode(), void 0);
1449
+ }
1450
+ function xt(e, t, n, r) {
1451
+ return e.someProp("createSelectionBetween", (r) => r(e, t, n)) || l.between(t, n, r);
1452
+ }
1453
+ function St(e) {
1454
+ return e.editable && !e.hasFocus() ? !1 : Ct(e);
1455
+ }
1456
+ function Ct(e) {
1457
+ let t = e.domSelectionRange();
1458
+ if (!t.anchorNode) return !1;
1459
+ try {
1460
+ return e.dom.contains(t.anchorNode.nodeType == 3 ? t.anchorNode.parentNode : t.anchorNode) && (e.editable || e.dom.contains(t.focusNode.nodeType == 3 ? t.focusNode.parentNode : t.focusNode));
1461
+ } catch {
1462
+ return !1;
1463
+ }
1464
+ }
1465
+ function wt(e) {
1466
+ let t = e.docView.domFromPos(e.state.selection.anchor, 0), n = e.domSelectionRange();
1467
+ return h(t.node, t.offset, n.anchorNode, n.anchorOffset);
1468
+ }
1469
+ function Tt(e, t) {
1470
+ let { $anchor: n, $head: r } = e.selection, i = t > 0 ? n.max(r) : n.min(r), a = i.parent.inlineContent ? i.depth ? e.doc.resolve(t > 0 ? i.after() : i.before()) : null : i;
1471
+ return a && c.findFrom(a, t);
1472
+ }
1473
+ function U(e, t) {
1474
+ return e.dispatch(e.state.tr.setSelection(t).scrollIntoView()), !0;
1475
+ }
1476
+ function Et(e, t, n) {
1477
+ let r = e.state.selection;
1478
+ if (r instanceof l) {
1479
+ if (n.indexOf("s") > -1) {
1480
+ let { $head: n } = r, i = n.textOffset ? null : t < 0 ? n.nodeBefore : n.nodeAfter;
1481
+ if (!i || i.isText || !i.isLeaf) return !1;
1482
+ let a = e.state.doc.resolve(n.pos + i.nodeSize * (t < 0 ? -1 : 1));
1483
+ return U(e, new l(r.$anchor, a));
1484
+ }
1485
+ if (!r.empty) return !1;
1486
+ if (e.endOfTextblock(t > 0 ? "forward" : "backward")) {
1487
+ let n = Tt(e.state, t);
1488
+ return n && n instanceof s ? U(e, n) : !1;
1489
+ }
1490
+ if (!(M && n.indexOf("m") > -1)) {
1491
+ let n = r.$head, i = n.textOffset ? null : t < 0 ? n.nodeBefore : n.nodeAfter, a;
1492
+ if (!i || i.isText) return !1;
1493
+ let o = t < 0 ? n.pos - i.nodeSize : n.pos;
1494
+ return i.isAtom || (a = e.docView.descAt(o)) && !a.contentDOM ? s.isSelectable(i) ? U(e, new s(t < 0 ? e.state.doc.resolve(n.pos - i.nodeSize) : n)) : ue ? U(e, new l(e.state.doc.resolve(t < 0 ? o : o + i.nodeSize))) : !1 : !1;
1495
+ }
1496
+ } else if (r instanceof s && r.node.isInline) return U(e, new l(t > 0 ? r.$to : r.$from));
1497
+ else {
1498
+ let n = Tt(e.state, t);
1499
+ return n ? U(e, n) : !1;
1500
+ }
1501
+ }
1502
+ function Dt(e) {
1503
+ return e.nodeType == 3 ? e.nodeValue.length : e.childNodes.length;
1504
+ }
1505
+ function Ot(e, t) {
1506
+ let n = e.pmViewDesc;
1507
+ return n && n.size == 0 && (t < 0 || e.nextSibling || e.nodeName != "BR");
1508
+ }
1509
+ function W(e, t) {
1510
+ return t < 0 ? kt(e) : At(e);
1511
+ }
1512
+ function kt(e) {
1513
+ let t = e.domSelectionRange(), n = t.focusNode, r = t.focusOffset;
1514
+ if (!n) return;
1515
+ let i, a, o = !1;
1516
+ for (O && n.nodeType == 1 && r < Dt(n) && Ot(n.childNodes[r], -1) && (o = !0);;) if (r > 0) {
1517
+ if (n.nodeType != 1) break;
1518
+ {
1519
+ let e = n.childNodes[r - 1];
1520
+ if (Ot(e, -1)) i = n, a = --r;
1521
+ else if (e.nodeType == 3) n = e, r = n.nodeValue.length;
1522
+ else break;
1523
+ }
1524
+ } else if (jt(n)) break;
1525
+ else {
1526
+ let t = n.previousSibling;
1527
+ for (; t && Ot(t, -1);) i = n.parentNode, a = u(t), t = t.previousSibling;
1528
+ if (t) n = t, r = Dt(n);
1529
+ else {
1530
+ if (n = n.parentNode, n == e.dom) break;
1531
+ r = 0;
1532
+ }
1533
+ }
1534
+ o ? Pt(e, n, r) : i && Pt(e, i, a);
1535
+ }
1536
+ function At(e) {
1537
+ let t = e.domSelectionRange(), n = t.focusNode, r = t.focusOffset;
1538
+ if (!n) return;
1539
+ let i = Dt(n), a, o;
1540
+ for (;;) if (r < i) {
1541
+ if (n.nodeType != 1) break;
1542
+ let e = n.childNodes[r];
1543
+ if (Ot(e, 1)) a = n, o = ++r;
1544
+ else break;
1545
+ } else if (jt(n)) break;
1546
+ else {
1547
+ let t = n.nextSibling;
1548
+ for (; t && Ot(t, 1);) a = t.parentNode, o = u(t) + 1, t = t.nextSibling;
1549
+ if (t) n = t, r = 0, i = Dt(n);
1550
+ else {
1551
+ if (n = n.parentNode, n == e.dom) break;
1552
+ r = i = 0;
1553
+ }
1554
+ }
1555
+ a && Pt(e, a, o);
1556
+ }
1557
+ function jt(e) {
1558
+ let t = e.pmViewDesc;
1559
+ return t && t.node && t.node.isBlock;
1560
+ }
1561
+ function Mt(e, t) {
1562
+ for (; e && t == e.childNodes.length && !x(e);) t = u(e) + 1, e = e.parentNode;
1563
+ for (; e && t < e.childNodes.length;) {
1564
+ let n = e.childNodes[t];
1565
+ if (n.nodeType == 3) return n;
1566
+ if (n.nodeType == 1 && n.contentEditable == "false") break;
1567
+ e = n, t = 0;
1568
+ }
1569
+ }
1570
+ function Nt(e, t) {
1571
+ for (; e && !t && !x(e);) t = u(e), e = e.parentNode;
1572
+ for (; e && t;) {
1573
+ let n = e.childNodes[t - 1];
1574
+ if (n.nodeType == 3) return n;
1575
+ if (n.nodeType == 1 && n.contentEditable == "false") break;
1576
+ e = n, t = e.childNodes.length;
1577
+ }
1578
+ }
1579
+ function Pt(e, t, n) {
1580
+ if (t.nodeType != 3) {
1581
+ let e, r;
1582
+ (r = Mt(t, n)) ? (t = r, n = 0) : (e = Nt(t, n)) && (t = e, n = e.nodeValue.length);
1583
+ }
1584
+ let r = e.domSelection();
1585
+ if (!r) return;
1586
+ if (S(r)) {
1587
+ let e = document.createRange();
1588
+ e.setEnd(t, n), e.setStart(t, n), r.removeAllRanges(), r.addRange(e);
1589
+ } else r.extend && r.extend(t, n);
1590
+ e.domObserver.setCurSelection();
1591
+ let { state: i } = e;
1592
+ setTimeout(() => {
1593
+ e.state == i && H(e);
1594
+ }, 50);
1595
+ }
1596
+ function Ft(e, t) {
1597
+ let n = e.state.doc.resolve(t);
1598
+ if (!(k || le) && n.parent.inlineContent) {
1599
+ let r = e.coordsAtPos(t);
1600
+ if (t > n.start()) {
1601
+ let n = e.coordsAtPos(t - 1), i = (n.top + n.bottom) / 2;
1602
+ if (i > r.top && i < r.bottom && Math.abs(n.left - r.left) > 1) return n.left < r.left ? "ltr" : "rtl";
1603
+ }
1604
+ if (t < n.end()) {
1605
+ let n = e.coordsAtPos(t + 1), i = (n.top + n.bottom) / 2;
1606
+ if (i > r.top && i < r.bottom && Math.abs(n.left - r.left) > 1) return n.left > r.left ? "ltr" : "rtl";
1607
+ }
1608
+ }
1609
+ return getComputedStyle(e.dom).direction == "rtl" ? "rtl" : "ltr";
1610
+ }
1611
+ function It(e, t, n) {
1612
+ let r = e.state.selection;
1613
+ if (r instanceof l && !r.empty || n.indexOf("s") > -1 || M && n.indexOf("m") > -1) return !1;
1614
+ let { $from: i, $to: a } = r;
1615
+ if (!i.parent.inlineContent || e.endOfTextblock(t < 0 ? "up" : "down")) {
1616
+ let n = Tt(e.state, t);
1617
+ if (n && n instanceof s) return U(e, n);
1618
+ }
1619
+ if (!i.parent.inlineContent) {
1620
+ let n = t < 0 ? i : a, s = r instanceof o ? c.near(n, t) : c.findFrom(n, t);
1621
+ return s ? U(e, s) : !1;
1622
+ }
1623
+ return !1;
1624
+ }
1625
+ function Lt(e, t) {
1626
+ if (!(e.state.selection instanceof l)) return !0;
1627
+ let { $head: n, $anchor: r, empty: i } = e.state.selection;
1628
+ if (!n.sameParent(r)) return !0;
1629
+ if (!i) return !1;
1630
+ if (e.endOfTextblock(t > 0 ? "forward" : "backward")) return !0;
1631
+ let a = !n.textOffset && (t < 0 ? n.nodeBefore : n.nodeAfter);
1632
+ if (a && !a.isText) {
1633
+ let r = e.state.tr;
1634
+ return t < 0 ? r.delete(n.pos - a.nodeSize, n.pos) : r.delete(n.pos, n.pos + a.nodeSize), e.dispatch(r), !0;
1635
+ }
1636
+ return !1;
1637
+ }
1638
+ function Rt(e, t, n) {
1639
+ e.domObserver.stop(), t.contentEditable = n, e.domObserver.start();
1640
+ }
1641
+ function zt(e) {
1642
+ if (!A || e.state.selection.$head.parentOffset > 0) return !1;
1643
+ let { focusNode: t, focusOffset: n } = e.domSelectionRange();
1644
+ if (t && t.nodeType == 1 && n == 0 && t.firstChild && t.firstChild.contentEditable == "false") {
1645
+ let n = t.firstChild;
1646
+ Rt(e, n, "true"), setTimeout(() => Rt(e, n, "false"), 20);
1647
+ }
1648
+ return !1;
1649
+ }
1650
+ function Bt(e) {
1651
+ let t = "";
1652
+ return e.ctrlKey && (t += "c"), e.metaKey && (t += "m"), e.altKey && (t += "a"), e.shiftKey && (t += "s"), t;
1653
+ }
1654
+ function Vt(e, t) {
1655
+ let n = t.keyCode, r = Bt(t);
1656
+ if (n == 8 || M && n == 72 && r == "c") return Lt(e, -1) || W(e, -1);
1657
+ if (n == 46 && !t.shiftKey || M && n == 68 && r == "c") return Lt(e, 1) || W(e, 1);
1658
+ if (n == 13 || n == 27) return !0;
1659
+ if (n == 37 || M && n == 66 && r == "c") {
1660
+ let t = n == 37 ? Ft(e, e.state.selection.from) == "ltr" ? -1 : 1 : -1;
1661
+ return Et(e, t, r) || W(e, t);
1662
+ }
1663
+ if (n == 39 || M && n == 70 && r == "c") {
1664
+ let t = n == 39 ? Ft(e, e.state.selection.from) == "ltr" ? 1 : -1 : 1;
1665
+ return Et(e, t, r) || W(e, t);
1666
+ }
1667
+ return n == 38 || M && n == 80 && r == "c" ? It(e, -1, r) || W(e, -1) : n == 40 || M && n == 78 && r == "c" ? zt(e) || It(e, 1, r) || W(e, 1) : !(r != (M ? "m" : "c") || n != 66 && n != 73 && n != 89 && n != 90);
1668
+ }
1669
+ function Ht(e, n) {
1670
+ e.someProp("transformCopied", (t) => {
1671
+ n = t(n, e);
1672
+ });
1673
+ let r = [], { content: i, openStart: a, openEnd: o } = n;
1674
+ for (; a > 1 && o > 1 && i.childCount == 1 && i.firstChild.childCount == 1;) {
1675
+ a--, o--;
1676
+ let e = i.firstChild;
1677
+ r.push(e.type.name, e.attrs == e.type.defaultAttrs ? null : e.attrs), i = e.content;
1678
+ }
1679
+ let s = e.someProp("clipboardSerializer") || t.fromSchema(e.state.schema), c = Qt(), l = c.createElement("div");
1680
+ l.appendChild(s.serializeFragment(i, { document: c }));
1681
+ let u = l.firstChild, d, f = 0;
1682
+ for (; u && u.nodeType == 1 && (d = Zt[u.nodeName.toLowerCase()]);) {
1683
+ for (let e = d.length - 1; e >= 0; e--) {
1684
+ let t = c.createElement(d[e]);
1685
+ for (; l.firstChild;) t.appendChild(l.firstChild);
1686
+ l.appendChild(t), f++;
1687
+ }
1688
+ u = l.firstChild;
1689
+ }
1690
+ return u && u.nodeType == 1 && u.setAttribute("data-pm-slice", `${a} ${o}${f ? ` -${f}` : ""} ${JSON.stringify(r)}`), {
1691
+ dom: l,
1692
+ text: e.someProp("clipboardTextSerializer", (t) => t(n, e)) || n.content.textBetween(0, n.content.size, "\n\n"),
1693
+ slice: n
1694
+ };
1695
+ }
1696
+ function Ut(r, a, o, s, c) {
1697
+ let l = c.parent.type.spec.code, u, d;
1698
+ if (!o && !a) return null;
1699
+ let f = !!a && (s || l || !o);
1700
+ if (f) {
1701
+ if (r.someProp("transformPastedText", (e) => {
1702
+ a = e(a, l || s, r);
1703
+ }), l) return d = new i(n.from(r.state.schema.text(a.replace(/\r\n?/g, "\n"))), 0, 0), r.someProp("transformPasted", (e) => {
1704
+ d = e(d, r, !0);
1705
+ }), d;
1706
+ let e = r.someProp("clipboardTextParser", (e) => e(a, c, s, r));
1707
+ if (e) d = e;
1708
+ else {
1709
+ let e = c.marks(), { schema: n } = r.state, i = t.fromSchema(n);
1710
+ u = document.createElement("div"), a.split(/(?:\r\n?|\n)+/).forEach((t) => {
1711
+ let r = u.appendChild(document.createElement("p"));
1712
+ t && r.appendChild(i.serializeNode(n.text(t, e)));
1713
+ });
1714
+ }
1715
+ } else r.someProp("transformPastedHTML", (e) => {
1716
+ o = e(o, r);
1717
+ }), u = tn(o), ue && nn(u);
1718
+ let p = u && u.querySelector("[data-pm-slice]"), m = p && /^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(p.getAttribute("data-pm-slice") || "");
1719
+ if (m && m[3]) for (let e = +m[3]; e > 0; e--) {
1720
+ let e = u.firstChild;
1721
+ for (; e && e.nodeType != 1;) e = e.nextSibling;
1722
+ if (!e) break;
1723
+ u = e;
1724
+ }
1725
+ if (d ||= (r.someProp("clipboardParser") || r.someProp("domParser") || e.fromSchema(r.state.schema)).parseSlice(u, {
1726
+ preserveWhitespace: !!(f || m),
1727
+ context: c,
1728
+ ruleFromNode(e) {
1729
+ return e.nodeName == "BR" && !e.nextSibling && e.parentNode && !Wt.test(e.parentNode.nodeName) ? { ignore: !0 } : null;
1730
+ }
1731
+ }), m) d = rn(Xt(d, +m[1], +m[2]), m[4]);
1732
+ else if (d = i.maxOpen(Gt(d.content, c), !0), d.openStart || d.openEnd) {
1733
+ let e = 0, t = 0;
1734
+ for (let t = d.content.firstChild; e < d.openStart && !t.type.spec.isolating; e++, t = t.firstChild);
1735
+ for (let e = d.content.lastChild; t < d.openEnd && !e.type.spec.isolating; t++, e = e.lastChild);
1736
+ d = Xt(d, e, t);
1737
+ }
1738
+ return r.someProp("transformPasted", (e) => {
1739
+ d = e(d, r, f);
1740
+ }), d;
1741
+ }
1742
+ var Wt = /^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;
1743
+ function Gt(e, t) {
1744
+ if (e.childCount < 2) return e;
1745
+ for (let r = t.depth; r >= 0; r--) {
1746
+ let i = t.node(r).contentMatchAt(t.index(r)), a, o = [];
1747
+ if (e.forEach((e) => {
1748
+ if (!o) return;
1749
+ let t = i.findWrapping(e.type), n;
1750
+ if (!t) return o = null;
1751
+ if (n = o.length && a.length && qt(t, a, e, o[o.length - 1], 0)) o[o.length - 1] = n;
1752
+ else {
1753
+ o.length && (o[o.length - 1] = Jt(o[o.length - 1], a.length));
1754
+ let n = Kt(e, t);
1755
+ o.push(n), i = i.matchType(n.type), a = t;
1756
+ }
1757
+ }), o) return n.from(o);
1758
+ }
1759
+ return e;
1760
+ }
1761
+ function Kt(e, t, r = 0) {
1762
+ for (let i = t.length - 1; i >= r; i--) e = t[i].create(null, n.from(e));
1763
+ return e;
1764
+ }
1765
+ function qt(e, t, r, i, a) {
1766
+ if (a < e.length && a < t.length && e[a] == t[a]) {
1767
+ let o = qt(e, t, r, i.lastChild, a + 1);
1768
+ if (o) return i.copy(i.content.replaceChild(i.childCount - 1, o));
1769
+ if (i.contentMatchAt(i.childCount).matchType(a == e.length - 1 ? r.type : e[a + 1])) return i.copy(i.content.append(n.from(Kt(r, e, a + 1))));
1770
+ }
1771
+ }
1772
+ function Jt(e, t) {
1773
+ if (t == 0) return e;
1774
+ let r = e.content.replaceChild(e.childCount - 1, Jt(e.lastChild, t - 1)), i = e.contentMatchAt(e.childCount).fillBefore(n.empty, !0);
1775
+ return e.copy(r.append(i));
1776
+ }
1777
+ function Yt(e, t, r, i, a, o) {
1778
+ let s = t < 0 ? e.firstChild : e.lastChild, c = s.content;
1779
+ return e.childCount > 1 && (o = 0), a < i - 1 && (c = Yt(c, t, r, i, a + 1, o)), a >= r && (c = t < 0 ? s.contentMatchAt(0).fillBefore(c, o <= a).append(c) : c.append(s.contentMatchAt(s.childCount).fillBefore(n.empty, !0))), e.replaceChild(t < 0 ? 0 : e.childCount - 1, s.copy(c));
1780
+ }
1781
+ function Xt(e, t, n) {
1782
+ return t < e.openStart && (e = new i(Yt(e.content, -1, t, e.openStart, 0, e.openEnd), t, e.openEnd)), n < e.openEnd && (e = new i(Yt(e.content, 1, n, e.openEnd, 0, 0), e.openStart, n)), e;
1783
+ }
1784
+ var Zt = {
1785
+ thead: ["table"],
1786
+ tbody: ["table"],
1787
+ tfoot: ["table"],
1788
+ caption: ["table"],
1789
+ colgroup: ["table"],
1790
+ col: ["table", "colgroup"],
1791
+ tr: ["table", "tbody"],
1792
+ td: [
1793
+ "table",
1794
+ "tbody",
1795
+ "tr"
1796
+ ],
1797
+ th: [
1798
+ "table",
1799
+ "tbody",
1800
+ "tr"
1801
+ ]
1802
+ };
1803
+ function Qt() {
1804
+ return document.implementation.createHTMLDocument("title");
1805
+ }
1806
+ var $t = null;
1807
+ function en(e) {
1808
+ let t = window.trustedTypes;
1809
+ return t ? ($t ||= t.defaultPolicy || t.createPolicy("ProseMirrorClipboard", { createHTML: (e) => e }), $t.createHTML(e)) : e;
1810
+ }
1811
+ function tn(e) {
1812
+ let t = /^(\s*<meta [^>]*>)*/.exec(e);
1813
+ t && (e = e.slice(t[0].length));
1814
+ let n = Qt(), r = n.body, i = /<([a-z][^>\s]+)/i.exec(e), a;
1815
+ if ((a = i && Zt[i[1].toLowerCase()]) && (e = a.map((e) => "<" + e + ">").join("") + e + a.map((e) => "</" + e + ">").reverse().join("")), r.innerHTML = en(e), a) for (let e = 0; e < a.length; e++) r = r.querySelector(a[e]) || r;
1816
+ for (let e = 0; e < n.styleSheets.length; e++) {
1817
+ let t = n.styleSheets[e];
1818
+ for (let e = 0; e < t.rules.length; e++) {
1819
+ let n = t.rules[e];
1820
+ if (n instanceof CSSStyleRule) {
1821
+ let e = r.querySelectorAll(n.selectorText);
1822
+ for (let t = 0; t < e.length; t++) e[t].style.cssText += n.style.cssText;
1823
+ }
1824
+ }
1825
+ }
1826
+ return r;
1827
+ }
1828
+ function nn(e) {
1829
+ let t = e.querySelectorAll(k ? "span:not([class]):not([style])" : "span.Apple-converted-space");
1830
+ for (let n = 0; n < t.length; n++) {
1831
+ let r = t[n];
1832
+ r.childNodes.length == 1 && r.textContent == "\xA0" && r.parentNode && r.parentNode.replaceChild(e.ownerDocument.createTextNode(" "), r);
1833
+ }
1834
+ }
1835
+ function rn(e, t) {
1836
+ if (!e.size) return e;
1837
+ let r = e.content.firstChild.type.schema, a;
1838
+ try {
1839
+ a = JSON.parse(t);
1840
+ } catch {
1841
+ return e;
1842
+ }
1843
+ let { content: o, openStart: s, openEnd: c } = e;
1844
+ for (let e = a.length - 2; e >= 0; e -= 2) {
1845
+ let t = r.nodes[a[e]];
1846
+ if (!t || t.hasRequiredAttrs()) break;
1847
+ o = n.from(t.create(a[e + 1], o)), s++, c++;
1848
+ }
1849
+ return new i(o, s, c);
1850
+ }
1851
+ var G = {}, K = {}, an = {
1852
+ touchstart: !0,
1853
+ touchmove: !0
1854
+ }, on = class {
1855
+ constructor() {
1856
+ this.shiftKey = !1, this.mouseDown = null, this.lastKeyCode = null, this.lastKeyCodeTime = 0, this.lastClick = {
1857
+ time: 0,
1858
+ x: 0,
1859
+ y: 0,
1860
+ type: "",
1861
+ button: 0
1862
+ }, this.lastSelectionOrigin = null, this.lastSelectionTime = 0, this.lastIOSEnter = 0, this.lastIOSEnterFallbackTimeout = -1, this.lastFocus = 0, this.lastTouch = 0, this.lastChromeDelete = 0, this.composing = !1, this.compositionNode = null, this.composingTimeout = -1, this.compositionNodes = [], this.compositionEndedAt = -2e8, this.compositionID = 1, this.badSafariComposition = !1, this.compositionPendingChanges = 0, this.domChangeCount = 0, this.eventHandlers = Object.create(null), this.hideSelectionGuard = null;
1863
+ }
1864
+ };
1865
+ function sn(e) {
1866
+ for (let t in G) {
1867
+ let n = G[t];
1868
+ e.dom.addEventListener(t, e.input.eventHandlers[t] = (t) => {
1869
+ dn(e, t) && !un(e, t) && (e.editable || !(t.type in K)) && n(e, t);
1870
+ }, an[t] ? { passive: !0 } : void 0);
1871
+ }
1872
+ A && e.dom.addEventListener("input", () => null), ln(e);
1873
+ }
1874
+ function q(e, t) {
1875
+ e.input.lastSelectionOrigin = t, e.input.lastSelectionTime = Date.now();
1876
+ }
1877
+ function cn(e) {
1878
+ e.input.mouseDown && e.input.mouseDown.done(), e.domObserver.stop();
1879
+ for (let t in e.input.eventHandlers) e.dom.removeEventListener(t, e.input.eventHandlers[t]);
1880
+ clearTimeout(e.input.composingTimeout), clearTimeout(e.input.lastIOSEnterFallbackTimeout);
1881
+ }
1882
+ function ln(e) {
1883
+ e.someProp("handleDOMEvents", (t) => {
1884
+ for (let n in t) e.input.eventHandlers[n] || e.dom.addEventListener(n, e.input.eventHandlers[n] = (t) => un(e, t));
1885
+ });
1886
+ }
1887
+ function un(e, t) {
1888
+ return e.someProp("handleDOMEvents", (n) => {
1889
+ let r = n[t.type];
1890
+ return r ? r(e, t) || t.defaultPrevented : !1;
1891
+ });
1892
+ }
1893
+ function dn(e, t) {
1894
+ if (!t.bubbles) return !0;
1895
+ if (t.defaultPrevented) return !1;
1896
+ for (let n = t.target; n != e.dom; n = n.parentNode) if (!n || n.nodeType == 11 || n.pmViewDesc && n.pmViewDesc.stopEvent(t)) return !1;
1897
+ return !0;
1898
+ }
1899
+ function fn(e, t) {
1900
+ !un(e, t) && G[t.type] && (e.editable || !(t.type in K)) && G[t.type](e, t);
1901
+ }
1902
+ K.keydown = (e, t) => {
1903
+ let n = t;
1904
+ if (e.input.shiftKey = n.keyCode == 16 || n.shiftKey, !kn(e) && (e.input.lastKeyCode = n.keyCode, e.input.lastKeyCodeTime = Date.now(), !(N && k && n.keyCode == 13))) {
1905
+ if (n.keyCode != 229 && e.domObserver.forceFlush(), j && n.keyCode == 13 && !n.ctrlKey && !n.altKey && !n.metaKey) {
1906
+ let t = Date.now();
1907
+ e.input.lastIOSEnter = t, e.input.lastIOSEnterFallbackTimeout = setTimeout(() => {
1908
+ e.input.lastIOSEnter == t && (e.someProp("handleKeyDown", (t) => t(e, C(13, "Enter"))), e.input.lastIOSEnter = 0);
1909
+ }, 200);
1910
+ } else e.someProp("handleKeyDown", (t) => t(e, n)) || Vt(e, n) ? n.preventDefault() : q(e, "key");
1911
+ }
1912
+ }, K.keyup = (e, t) => {
1913
+ t.keyCode == 16 && (e.input.shiftKey = !1);
1914
+ }, K.keypress = (e, t) => {
1915
+ let n = t;
1916
+ if (kn(e) || !n.charCode || n.ctrlKey && !n.altKey || M && n.metaKey) return;
1917
+ if (e.someProp("handleKeyPress", (t) => t(e, n))) {
1918
+ n.preventDefault();
1919
+ return;
1920
+ }
1921
+ let r = e.state.selection;
1922
+ if (!(r instanceof l) || !r.$from.sameParent(r.$to)) {
1923
+ let t = String.fromCharCode(n.charCode), i = () => e.state.tr.insertText(t).scrollIntoView();
1924
+ !/[\r\n]/.test(t) && !e.someProp("handleTextInput", (n) => n(e, r.$from.pos, r.$to.pos, t, i)) && e.dispatch(i()), n.preventDefault();
1925
+ }
1926
+ };
1927
+ function pn(e) {
1928
+ return {
1929
+ left: e.clientX,
1930
+ top: e.clientY
1931
+ };
1932
+ }
1933
+ function mn(e, t) {
1934
+ let n = t.x - e.clientX, r = t.y - e.clientY;
1935
+ return n * n + r * r < 100;
1936
+ }
1937
+ function hn(e, t, n, r, i) {
1938
+ if (r == -1) return !1;
1939
+ let a = e.state.doc.resolve(r);
1940
+ for (let r = a.depth + 1; r > 0; r--) if (e.someProp(t, (t) => r > a.depth ? t(e, n, a.nodeAfter, a.before(r), i, !0) : t(e, n, a.node(r), a.before(r), i, !1))) return !0;
1941
+ return !1;
1942
+ }
1943
+ function gn(e, t, n) {
1944
+ if (e.focused || e.focus(), e.state.selection.eq(t)) return;
1945
+ let r = e.state.tr.setSelection(t);
1946
+ n == "pointer" && r.setMeta("pointer", !0), e.dispatch(r);
1947
+ }
1948
+ function _n(e, t) {
1949
+ if (t == -1) return !1;
1950
+ let n = e.state.doc.resolve(t), r = n.nodeAfter;
1951
+ return r && r.isAtom && s.isSelectable(r) ? (gn(e, new s(n), "pointer"), !0) : !1;
1952
+ }
1953
+ function vn(e, t) {
1954
+ if (t == -1) return !1;
1955
+ let n = e.state.selection, r, i;
1956
+ n instanceof s && (r = n.node);
1957
+ let a = e.state.doc.resolve(t);
1958
+ for (let e = a.depth + 1; e > 0; e--) {
1959
+ let t = e > a.depth ? a.nodeAfter : a.node(e);
1960
+ if (s.isSelectable(t)) {
1961
+ i = r && n.$from.depth > 0 && e >= n.$from.depth && a.before(n.$from.depth + 1) == n.$from.pos ? a.before(n.$from.depth) : a.before(e);
1962
+ break;
1963
+ }
1964
+ }
1965
+ return i != null && (gn(e, s.create(e.state.doc, i), "pointer"), !0);
1966
+ }
1967
+ function yn(e, t, n, r, i) {
1968
+ return hn(e, "handleClickOn", t, n, r) || e.someProp("handleClick", (n) => n(e, t, r)) || (i ? vn(e, n) : _n(e, n));
1969
+ }
1970
+ function bn(e, t, n, r) {
1971
+ return hn(e, "handleDoubleClickOn", t, n, r) || e.someProp("handleDoubleClick", (n) => n(e, t, r));
1972
+ }
1973
+ function xn(e, t, n, r) {
1974
+ return hn(e, "handleTripleClickOn", t, n, r) || e.someProp("handleTripleClick", (n) => n(e, t, r)) || Sn(e, n, r);
1975
+ }
1976
+ function Sn(e, t, n) {
1977
+ if (n.button != 0) return !1;
1978
+ let r = Cn(e, t, !0), i = e.state.doc;
1979
+ return r ? (gn(e, r, "pointer"), r instanceof l && i.eq(e.state.doc) && (e.input.mouseDown = new On(e, r)), !0) : !1;
1980
+ }
1981
+ function Cn(e, t, n) {
1982
+ let r = e.state.doc;
1983
+ if (t == -1) return r.inlineContent ? l.create(r, 0, r.content.size) : null;
1984
+ let i = r.resolve(t);
1985
+ for (let e = i.depth + 1; e > 0; e--) {
1986
+ let t = e > i.depth ? i.nodeAfter : i.node(e), a = i.before(e);
1987
+ if (t.inlineContent) return l.create(r, a + 1, a + 1 + t.content.size);
1988
+ if (n && s.isSelectable(t)) return s.create(r, a);
1989
+ }
1990
+ return null;
1991
+ }
1992
+ function wn(e) {
1993
+ return Fn(e);
1994
+ }
1995
+ var Tn = M ? "metaKey" : "ctrlKey";
1996
+ G.mousedown = (e, t) => {
1997
+ let n = t;
1998
+ e.input.shiftKey = n.shiftKey;
1999
+ let r = wn(e), i = Date.now(), a = "singleClick";
2000
+ i - e.input.lastClick.time < 500 && mn(n, e.input.lastClick) && !n[Tn] && e.input.lastClick.button == n.button && (e.input.lastClick.type == "singleClick" ? a = "doubleClick" : e.input.lastClick.type == "doubleClick" && (a = "tripleClick")), e.input.lastClick = {
2001
+ time: i,
2002
+ x: n.clientX,
2003
+ y: n.clientY,
2004
+ type: a,
2005
+ button: n.button
2006
+ }, e.input.mouseDown && e.input.mouseDown.done();
2007
+ let o = e.posAtCoords(pn(n));
2008
+ o && (a == "singleClick" ? e.input.mouseDown = new Dn(e, o, n, !!r) : (a == "doubleClick" ? bn : xn)(e, o.pos, o.inside, n) ? n.preventDefault() : q(e, "pointer"));
2009
+ };
2010
+ var En = class {
2011
+ constructor(e) {
2012
+ this.view = e, this.mightDrag = null, e.root.addEventListener("mouseup", this.up = this.up.bind(this)), e.root.addEventListener("mousemove", this.move = this.move.bind(this));
2013
+ }
2014
+ up(e) {
2015
+ this.done();
2016
+ }
2017
+ move(e) {
2018
+ e.buttons == 0 && this.done();
2019
+ }
2020
+ done() {
2021
+ this.view.root.removeEventListener("mouseup", this.up), this.view.root.removeEventListener("mousemove", this.move), this.view.input.mouseDown == this && (this.view.input.mouseDown = null);
2022
+ }
2023
+ delaySelUpdate() {
2024
+ return !1;
2025
+ }
2026
+ }, Dn = class extends En {
2027
+ constructor(e, t, n, r) {
2028
+ super(e), this.pos = t, this.event = n, this.flushed = r, this.delayedSelectionSync = !1, this.startDoc = e.state.doc, this.selectNode = !!n[Tn], this.allowDefault = n.shiftKey;
2029
+ let i, a;
2030
+ if (t.inside > -1) i = e.state.doc.nodeAt(t.inside), a = t.inside;
2031
+ else {
2032
+ let n = e.state.doc.resolve(t.pos);
2033
+ i = n.parent, a = n.depth ? n.before() : 0;
2034
+ }
2035
+ let o = r ? null : n.target, c = o ? e.docView.nearestDesc(o, !0) : null;
2036
+ this.target = c && c.nodeDOM.nodeType == 1 ? c.nodeDOM : null;
2037
+ let { selection: l } = e.state;
2038
+ n.button == 0 && (i.type.spec.draggable && i.type.spec.selectable !== !1 || l instanceof s && l.from <= a && l.to > a) && (this.mightDrag = {
2039
+ node: i,
2040
+ pos: a,
2041
+ addAttr: !!(this.target && !this.target.draggable),
2042
+ setUneditable: !!(this.target && O && !this.target.hasAttribute("contentEditable"))
2043
+ }), this.target && this.mightDrag && (this.mightDrag.addAttr || this.mightDrag.setUneditable) && (this.view.domObserver.stop(), this.mightDrag.addAttr && (this.target.draggable = !0), this.mightDrag.setUneditable && setTimeout(() => {
2044
+ this.view.input.mouseDown == this && this.target.setAttribute("contentEditable", "false");
2045
+ }, 20), this.view.domObserver.start()), q(e, "pointer");
2046
+ }
2047
+ done() {
2048
+ super.done(), this.mightDrag && this.target && (this.view.domObserver.stop(), this.mightDrag.addAttr && this.target.removeAttribute("draggable"), this.mightDrag.setUneditable && this.target.removeAttribute("contentEditable"), this.view.domObserver.start()), this.delayedSelectionSync && setTimeout(() => {
2049
+ this.view.isDestroyed || H(this.view);
2050
+ });
2051
+ }
2052
+ up(e) {
2053
+ if (this.done(), !this.view.dom.contains(e.target)) return;
2054
+ let t = this.pos;
2055
+ this.view.state.doc != this.startDoc && (t = this.view.posAtCoords(pn(e))), this.updateAllowDefault(e), this.allowDefault || !t ? q(this.view, "pointer") : yn(this.view, t.pos, t.inside, e, this.selectNode) ? e.preventDefault() : e.button == 0 && (this.flushed || A && this.mightDrag && !this.mightDrag.node.isAtom || k && !this.view.state.selection.visible && Math.min(Math.abs(t.pos - this.view.state.selection.from), Math.abs(t.pos - this.view.state.selection.to)) <= 2) ? (gn(this.view, c.near(this.view.state.doc.resolve(t.pos)), "pointer"), e.preventDefault()) : q(this.view, "pointer");
2056
+ }
2057
+ move(e) {
2058
+ this.updateAllowDefault(e), q(this.view, "pointer"), super.move(e);
2059
+ }
2060
+ updateAllowDefault(e) {
2061
+ !this.allowDefault && (Math.abs(this.event.x - e.clientX) > 4 || Math.abs(this.event.y - e.clientY) > 4) && (this.allowDefault = !0);
2062
+ }
2063
+ delaySelUpdate() {
2064
+ return this.allowDefault ? (this.delayedSelectionSync = !0, !0) : !1;
2065
+ }
2066
+ }, On = class extends En {
2067
+ constructor(e, t) {
2068
+ super(e), this.startSelection = t, this.startDoc = e.state.doc;
2069
+ }
2070
+ move(e) {
2071
+ if (e.buttons == 0 || this.view.isDestroyed || !this.view.state.doc.eq(this.startDoc)) {
2072
+ this.done();
2073
+ return;
2074
+ }
2075
+ e.preventDefault(), q(this.view, "pointer");
2076
+ let t = this.view.posAtCoords(pn(e)), n = t && Cn(this.view, t.inside, !1);
2077
+ if (!n) return;
2078
+ let { doc: r } = this.view.state, i = this.startSelection, [a, o] = n.from < i.from ? [i.to, n.from] : [i.from, n.to];
2079
+ gn(this.view, l.create(r, a, o), "pointer");
2080
+ }
2081
+ };
2082
+ G.touchstart = (e) => {
2083
+ e.input.lastTouch = Date.now(), wn(e), q(e, "pointer");
2084
+ }, G.touchmove = (e) => {
2085
+ e.input.lastTouch = Date.now(), q(e, "pointer");
2086
+ }, G.contextmenu = (e) => wn(e);
2087
+ function kn(e, t) {
2088
+ return e.composing ? !0 : A && Math.abs(Date.now() - e.input.compositionEndedAt) < 500 ? (e.input.compositionEndedAt = -2e8, !0) : !1;
2089
+ }
2090
+ var An = N ? 5e3 : -1;
2091
+ K.compositionstart = K.compositionupdate = (e) => {
2092
+ if (!e.composing) {
2093
+ e.domObserver.flush();
2094
+ let { state: t } = e, n = t.selection.$to;
2095
+ if (t.selection instanceof l && (t.storedMarks || !n.textOffset && n.parentOffset && n.nodeBefore.marks.some((e) => e.type.spec.inclusive === !1) || k && le && jn(e))) e.markCursor = e.state.storedMarks || n.marks(), Fn(e, !0), e.markCursor = null;
2096
+ else if (Fn(e, !t.selection.empty), O && t.selection.empty && n.parentOffset && !n.textOffset && n.nodeBefore.marks.length) {
2097
+ let t = e.domSelectionRange();
2098
+ for (let n = t.focusNode, r = t.focusOffset; n && n.nodeType == 1 && r != 0;) {
2099
+ let t = r < 0 ? n.lastChild : n.childNodes[r - 1];
2100
+ if (!t) break;
2101
+ if (t.nodeType == 3) {
2102
+ let n = e.domSelection();
2103
+ n && n.collapse(t, t.nodeValue.length);
2104
+ break;
2105
+ }
2106
+ n = t, r = -1;
2107
+ }
2108
+ }
2109
+ e.input.composing = !0;
2110
+ }
2111
+ Mn(e, An);
2112
+ };
2113
+ function jn(e) {
2114
+ let { focusNode: t, focusOffset: n } = e.domSelectionRange();
2115
+ if (!t || t.nodeType != 1 || n >= t.childNodes.length) return !1;
2116
+ let r = t.childNodes[n];
2117
+ return r.nodeType == 1 && r.contentEditable == "false";
2118
+ }
2119
+ K.compositionend = (e, t) => {
2120
+ e.composing && (e.input.composing = !1, e.input.compositionEndedAt = Date.now(), e.input.compositionPendingChanges = e.domObserver.pendingRecords().length ? e.input.compositionID : 0, e.input.compositionNode = null, e.input.badSafariComposition ? e.domObserver.forceFlush() : e.input.compositionPendingChanges && Promise.resolve().then(() => e.domObserver.flush()), e.input.compositionID++, Mn(e, 20));
2121
+ };
2122
+ function Mn(e, t) {
2123
+ clearTimeout(e.input.composingTimeout), t > -1 && (e.input.composingTimeout = setTimeout(() => Fn(e), t));
2124
+ }
2125
+ function Nn(e) {
2126
+ for (e.composing && (e.input.composing = !1, e.input.compositionEndedAt = Date.now()); e.input.compositionNodes.length > 0;) e.input.compositionNodes.pop().markParentsDirty();
2127
+ }
2128
+ function Pn(e) {
2129
+ let t = e.domSelectionRange();
2130
+ if (!t.focusNode) return null;
2131
+ let n = ee(t.focusNode, t.focusOffset), r = y(t.focusNode, t.focusOffset);
2132
+ if (n && r && n != r) {
2133
+ let t = r.pmViewDesc, i = e.domObserver.lastChangedTextNode;
2134
+ if (n == i || r == i) return i;
2135
+ if (!t || !t.isText(r.nodeValue)) return r;
2136
+ if (e.input.compositionNode == r) {
2137
+ let e = n.pmViewDesc;
2138
+ if (!(!e || !e.isText(n.nodeValue))) return r;
2139
+ }
2140
+ }
2141
+ return n || r;
2142
+ }
2143
+ function Fn(e, t = !1) {
2144
+ if (!(N && e.domObserver.flushingSoon >= 0)) {
2145
+ if (e.domObserver.forceFlush(), Nn(e), t || e.docView && e.docView.dirty) {
2146
+ let n = dt(e), r = e.state.selection;
2147
+ return n && !n.eq(r) ? e.dispatch(e.state.tr.setSelection(n)) : (e.markCursor || t) && !r.$from.node(r.$from.sharedDepth(r.to)).inlineContent ? e.dispatch(e.state.tr.deleteSelection()) : e.updateState(e.state), !0;
2148
+ }
2149
+ return !1;
2150
+ }
2151
+ }
2152
+ function In(e, t) {
2153
+ if (!e.dom.parentNode) return;
2154
+ let n = e.dom.parentNode.appendChild(document.createElement("div"));
2155
+ n.appendChild(t), n.style.cssText = "position: fixed; left: -10000px; top: 10px";
2156
+ let r = getSelection(), i = document.createRange();
2157
+ i.selectNodeContents(t), e.dom.blur(), r.removeAllRanges(), r.addRange(i), setTimeout(() => {
2158
+ n.parentNode && n.parentNode.removeChild(n), e.focus();
2159
+ }, 50);
2160
+ }
2161
+ var Ln = E && D < 15 || j && de < 604;
2162
+ G.copy = K.cut = (e, t) => {
2163
+ let n = t, r = e.state.selection, i = n.type == "cut";
2164
+ if (r.empty) return;
2165
+ let a = Ln ? null : n.clipboardData, { dom: o, text: s } = Ht(e, r.content());
2166
+ a ? (n.preventDefault(), a.clearData(), a.setData("text/html", o.innerHTML), a.setData("text/plain", s)) : In(e, o), i && e.dispatch(e.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent", "cut"));
2167
+ };
2168
+ function Rn(e) {
2169
+ return e.openStart == 0 && e.openEnd == 0 && e.content.childCount == 1 ? e.content.firstChild : null;
2170
+ }
2171
+ function zn(e, t) {
2172
+ if (!e.dom.parentNode) return;
2173
+ let n = e.input.shiftKey || e.state.selection.$from.parent.type.spec.code, r = e.dom.parentNode.appendChild(document.createElement(n ? "textarea" : "div"));
2174
+ n || (r.contentEditable = "true"), r.style.cssText = "position: fixed; left: -10000px; top: 10px", r.focus();
2175
+ let i = e.input.shiftKey && e.input.lastKeyCode != 45;
2176
+ setTimeout(() => {
2177
+ e.focus(), r.parentNode && r.parentNode.removeChild(r), n ? Bn(e, r.value, null, i, t) : Bn(e, r.textContent, r.innerHTML, i, t);
2178
+ }, 50);
2179
+ }
2180
+ function Bn(e, t, n, r, a) {
2181
+ let o = Ut(e, t, n, r, e.state.selection.$from);
2182
+ if (e.someProp("handlePaste", (t) => t(e, a, o || i.empty))) return !0;
2183
+ if (!o) return !1;
2184
+ let s = Rn(o), c = s ? e.state.tr.replaceSelectionWith(s, r) : e.state.tr.replaceSelection(o);
2185
+ return e.dispatch(c.scrollIntoView().setMeta("paste", !0).setMeta("uiEvent", "paste")), !0;
2186
+ }
2187
+ function Vn(e) {
2188
+ let t = e.getData("text/plain") || e.getData("Text");
2189
+ if (t) return t;
2190
+ let n = e.getData("text/uri-list");
2191
+ return n ? n.replace(/\r?\n/g, " ") : "";
2192
+ }
2193
+ K.paste = (e, t) => {
2194
+ let n = t;
2195
+ if (e.composing && !N) return;
2196
+ let r = Ln ? null : n.clipboardData, i = e.input.shiftKey && e.input.lastKeyCode != 45;
2197
+ r && Bn(e, Vn(r), r.getData("text/html"), i, n) ? n.preventDefault() : zn(e, n);
2198
+ };
2199
+ var Hn = class {
2200
+ constructor(e, t, n) {
2201
+ this.slice = e, this.move = t, this.node = n;
2202
+ }
2203
+ }, Un = M ? "altKey" : "ctrlKey";
2204
+ function Wn(e, t) {
2205
+ let n;
2206
+ return e.someProp("dragCopies", (e) => {
2207
+ n ||= e(t);
2208
+ }), n == null ? !t[Un] : !n;
2209
+ }
2210
+ G.dragstart = (e, t) => {
2211
+ let n = t, r = e.input.mouseDown;
2212
+ if (r && r.done(), !n.dataTransfer) return;
2213
+ let i = e.state.selection, a = i.empty ? null : e.posAtCoords(pn(n)), o;
2214
+ if (!(a && a.pos >= i.from && a.pos <= (i instanceof s ? i.to - 1 : i.to))) {
2215
+ if (r && r.mightDrag) o = s.create(e.state.doc, r.mightDrag.pos);
2216
+ else if (n.target && n.target.nodeType == 1) {
2217
+ let t = e.docView.nearestDesc(n.target, !0);
2218
+ t && t.node.type.spec.draggable && t != e.docView && (o = s.create(e.state.doc, t.posBefore));
2219
+ }
2220
+ }
2221
+ let { dom: c, text: l, slice: u } = Ht(e, (o || e.state.selection).content());
2222
+ (!n.dataTransfer.files.length || !k || ce > 120) && n.dataTransfer.clearData(), n.dataTransfer.setData(Ln ? "Text" : "text/html", c.innerHTML), n.dataTransfer.effectAllowed = "copyMove", Ln || n.dataTransfer.setData("text/plain", l), e.dragging = new Hn(u, Wn(e, n), o);
2223
+ }, G.dragend = (e) => {
2224
+ let t = e.dragging;
2225
+ window.setTimeout(() => {
2226
+ e.dragging == t && (e.dragging = null);
2227
+ }, 50);
2228
+ }, K.dragover = K.dragenter = (e, t) => t.preventDefault(), K.drop = (e, t) => {
2229
+ try {
2230
+ Gn(e, t, e.dragging);
2231
+ } finally {
2232
+ e.dragging = null;
2233
+ }
2234
+ };
2235
+ function Gn(e, t, n) {
2236
+ if (!t.dataTransfer) return;
2237
+ let r = e.posAtCoords(pn(t));
2238
+ if (!r) return;
2239
+ let o = e.state.doc.resolve(r.pos), c = n && n.slice;
2240
+ c ? e.someProp("transformPasted", (t) => {
2241
+ c = t(c, e, !1);
2242
+ }) : c = Ut(e, Vn(t.dataTransfer), Ln ? null : t.dataTransfer.getData("text/html"), !1, o);
2243
+ let l = !!(n && Wn(e, t));
2244
+ if (e.someProp("handleDrop", (n) => n(e, t, c || i.empty, l))) {
2245
+ t.preventDefault();
2246
+ return;
2247
+ }
2248
+ if (!c) return;
2249
+ t.preventDefault();
2250
+ let u = c ? a(e.state.doc, o.pos, c) : o.pos;
2251
+ u ??= o.pos;
2252
+ let d = e.state.tr;
2253
+ if (l) {
2254
+ let { node: e } = n;
2255
+ e ? e.replace(d) : d.deleteSelection();
2256
+ }
2257
+ let f = d.mapping.map(u), p = c.openStart == 0 && c.openEnd == 0 && c.content.childCount == 1, m = d.doc;
2258
+ if (p ? d.replaceRangeWith(f, f, c.content.firstChild) : d.replaceRange(f, f, c), d.doc.eq(m)) return;
2259
+ let h = d.doc.resolve(f);
2260
+ if (p && s.isSelectable(c.content.firstChild) && h.nodeAfter && h.nodeAfter.sameMarkup(c.content.firstChild)) d.setSelection(new s(h));
2261
+ else {
2262
+ let t = d.mapping.map(u);
2263
+ d.mapping.maps[d.mapping.maps.length - 1].forEach((e, n, r, i) => t = i), d.setSelection(xt(e, h, d.doc.resolve(t)));
2264
+ }
2265
+ e.focus(), e.dispatch(d.setMeta("uiEvent", "drop"));
2266
+ }
2267
+ G.focus = (e) => {
2268
+ e.input.lastFocus = Date.now(), e.focused || (e.domObserver.stop(), e.dom.classList.add("ProseMirror-focused"), e.domObserver.start(), e.focused = !0, setTimeout(() => {
2269
+ e.docView && e.hasFocus() && !e.domObserver.currentSelection.eq(e.domSelectionRange()) && H(e);
2270
+ }, 20));
2271
+ }, G.blur = (e, t) => {
2272
+ let n = t;
2273
+ e.focused &&= (e.domObserver.stop(), e.dom.classList.remove("ProseMirror-focused"), e.domObserver.start(), n.relatedTarget && e.dom.contains(n.relatedTarget) && e.domObserver.currentSelection.clear(), !1);
2274
+ }, G.beforeinput = (e, t) => {
2275
+ if (N && t.inputType == "deleteContentBackward") {
2276
+ e.domObserver.flushSoon();
2277
+ let { domChangeCount: t } = e.input;
2278
+ setTimeout(() => {
2279
+ if (e.input.domChangeCount != t || (e.dom.blur(), e.focus(), e.someProp("handleKeyDown", (t) => t(e, C(8, "Backspace"))))) return;
2280
+ let { $cursor: n } = e.state.selection;
2281
+ n && n.pos > 0 && e.dispatch(e.state.tr.delete(n.pos - 1, n.pos).scrollIntoView());
2282
+ }, 50);
2283
+ }
2284
+ };
2285
+ for (let e in K) G[e] = K[e];
2286
+ function Kn(e, t) {
2287
+ if (e == t) return !0;
2288
+ for (let n in e) if (e[n] !== t[n]) return !1;
2289
+ for (let n in t) if (!(n in e)) return !1;
2290
+ return !0;
2291
+ }
2292
+ var qn = class e {
2293
+ constructor(e, t) {
2294
+ this.toDOM = e, this.spec = t || X, this.side = this.spec.side || 0;
2295
+ }
2296
+ map(e, t, n, r) {
2297
+ let { pos: i, deleted: a } = e.mapResult(t.from + r, this.side < 0 ? -1 : 1);
2298
+ return a ? null : new J(i - n, i - n, this);
2299
+ }
2300
+ valid() {
2301
+ return !0;
2302
+ }
2303
+ eq(t) {
2304
+ return this == t || t instanceof e && (this.spec.key && this.spec.key == t.spec.key || this.toDOM == t.toDOM && Kn(this.spec, t.spec));
2305
+ }
2306
+ destroy(e) {
2307
+ this.spec.destroy && this.spec.destroy(e);
2308
+ }
2309
+ }, Jn = class e {
2310
+ constructor(e, t) {
2311
+ this.attrs = e, this.spec = t || X;
2312
+ }
2313
+ map(e, t, n, r) {
2314
+ let i = e.map(t.from + r, this.spec.inclusiveStart ? -1 : 1) - n, a = e.map(t.to + r, this.spec.inclusiveEnd ? 1 : -1) - n;
2315
+ return i >= a ? null : new J(i, a, this);
2316
+ }
2317
+ valid(e, t) {
2318
+ return t.from < t.to;
2319
+ }
2320
+ eq(t) {
2321
+ return this == t || t instanceof e && Kn(this.attrs, t.attrs) && Kn(this.spec, t.spec);
2322
+ }
2323
+ static is(t) {
2324
+ return t.type instanceof e;
2325
+ }
2326
+ destroy() {}
2327
+ }, Yn = class e {
2328
+ constructor(e, t) {
2329
+ this.attrs = e, this.spec = t || X;
2330
+ }
2331
+ map(e, t, n, r) {
2332
+ let i = e.mapResult(t.from + r, 1);
2333
+ if (i.deleted) return null;
2334
+ let a = e.mapResult(t.to + r, -1);
2335
+ return a.deleted || a.pos <= i.pos ? null : new J(i.pos - n, a.pos - n, this);
2336
+ }
2337
+ valid(e, t) {
2338
+ let { index: n, offset: r } = e.content.findIndex(t.from), i;
2339
+ return r == t.from && !(i = e.child(n)).isText && r + i.nodeSize == t.to;
2340
+ }
2341
+ eq(t) {
2342
+ return this == t || t instanceof e && Kn(this.attrs, t.attrs) && Kn(this.spec, t.spec);
2343
+ }
2344
+ destroy() {}
2345
+ }, J = class e {
2346
+ constructor(e, t, n) {
2347
+ this.from = e, this.to = t, this.type = n;
2348
+ }
2349
+ copy(t, n) {
2350
+ return new e(t, n, this.type);
2351
+ }
2352
+ eq(e, t = 0) {
2353
+ return this.type.eq(e.type) && this.from + t == e.from && this.to + t == e.to;
2354
+ }
2355
+ map(e, t, n) {
2356
+ return this.type.map(e, this, t, n);
2357
+ }
2358
+ static widget(t, n, r) {
2359
+ return new e(t, t, new qn(n, r));
2360
+ }
2361
+ static inline(t, n, r, i) {
2362
+ return new e(t, n, new Jn(r, i));
2363
+ }
2364
+ static node(t, n, r, i) {
2365
+ return new e(t, n, new Yn(r, i));
2366
+ }
2367
+ get spec() {
2368
+ return this.type.spec;
2369
+ }
2370
+ get inline() {
2371
+ return this.type instanceof Jn;
2372
+ }
2373
+ get widget() {
2374
+ return this.type instanceof qn;
2375
+ }
2376
+ }, Y = [], X = {}, Z = class e {
2377
+ constructor(e, t) {
2378
+ this.local = e.length ? e : Y, this.children = t.length ? t : Y;
2379
+ }
2380
+ static create(e, t) {
2381
+ return t.length ? nr(t, e, 0, X) : Q;
2382
+ }
2383
+ find(e, t, n) {
2384
+ let r = [];
2385
+ return this.findInner(e ?? 0, t ?? 1e9, r, 0, n), r;
2386
+ }
2387
+ findInner(e, t, n, r, i) {
2388
+ for (let a = 0; a < this.local.length; a++) {
2389
+ let o = this.local[a];
2390
+ o.from <= t && o.to >= e && (!i || i(o.spec)) && n.push(o.copy(o.from + r, o.to + r));
2391
+ }
2392
+ for (let a = 0; a < this.children.length; a += 3) if (this.children[a] < t && this.children[a + 1] > e) {
2393
+ let o = this.children[a] + 1;
2394
+ this.children[a + 2].findInner(e - o, t - o, n, r + o, i);
2395
+ }
2396
+ }
2397
+ map(e, t, n) {
2398
+ return this == Q || e.maps.length == 0 ? this : this.mapInner(e, t, 0, 0, n || X);
2399
+ }
2400
+ mapInner(t, n, r, i, a) {
2401
+ let o;
2402
+ for (let e = 0; e < this.local.length; e++) {
2403
+ let s = this.local[e].map(t, r, i);
2404
+ s && s.type.valid(n, s) ? (o ||= []).push(s) : a.onRemove && a.onRemove(this.local[e].spec);
2405
+ }
2406
+ return this.children.length ? Zn(this.children, o || [], t, n, r, i, a) : o ? new e(o.sort($), Y) : Q;
2407
+ }
2408
+ add(t, n) {
2409
+ return n.length ? this == Q ? e.create(t, n) : this.addInner(t, n, 0) : this;
2410
+ }
2411
+ addInner(t, n, r) {
2412
+ let i, a = 0;
2413
+ t.forEach((e, t) => {
2414
+ let o = t + r, s;
2415
+ if (s = er(n, e, o)) {
2416
+ for (i ||= this.children.slice(); a < i.length && i[a] < t;) a += 3;
2417
+ i[a] == t ? i[a + 2] = i[a + 2].addInner(e, s, o + 1) : i.splice(a, 0, t, t + e.nodeSize, nr(s, e, o + 1, X)), a += 3;
2418
+ }
2419
+ });
2420
+ let o = Qn(a ? tr(n) : n, -r);
2421
+ for (let e = 0; e < o.length; e++) o[e].type.valid(t, o[e]) || o.splice(e--, 1);
2422
+ return new e(o.length ? this.local.concat(o).sort($) : this.local, i || this.children);
2423
+ }
2424
+ remove(e) {
2425
+ return e.length == 0 || this == Q ? this : this.removeInner(e, 0);
2426
+ }
2427
+ removeInner(t, n) {
2428
+ let r = this.children, i = this.local;
2429
+ for (let e = 0; e < r.length; e += 3) {
2430
+ let i, a = r[e] + n, o = r[e + 1] + n;
2431
+ for (let e = 0, n; e < t.length; e++) (n = t[e]) && n.from > a && n.to < o && (t[e] = null, (i ||= []).push(n));
2432
+ if (!i) continue;
2433
+ r == this.children && (r = this.children.slice());
2434
+ let s = r[e + 2].removeInner(i, a + 1);
2435
+ s == Q ? (r.splice(e, 3), e -= 3) : r[e + 2] = s;
2436
+ }
2437
+ if (i.length) {
2438
+ for (let e = 0, r; e < t.length; e++) if (r = t[e]) for (let e = 0; e < i.length; e++) i[e].eq(r, n) && (i == this.local && (i = this.local.slice()), i.splice(e--, 1));
2439
+ }
2440
+ return r == this.children && i == this.local ? this : i.length || r.length ? new e(i, r) : Q;
2441
+ }
2442
+ forChild(t, n) {
2443
+ if (this == Q) return this;
2444
+ if (n.isLeaf) return e.empty;
2445
+ let r, i;
2446
+ for (let e = 0; e < this.children.length; e += 3) if (this.children[e] >= t) {
2447
+ this.children[e] == t && (r = this.children[e + 2]);
2448
+ break;
2449
+ }
2450
+ let a = t + 1, o = a + n.content.size;
2451
+ for (let e = 0; e < this.local.length; e++) {
2452
+ let t = this.local[e];
2453
+ if (t.from < o && t.to > a && t.type instanceof Jn) {
2454
+ let e = Math.max(a, t.from) - a, n = Math.min(o, t.to) - a;
2455
+ e < n && (i ||= []).push(t.copy(e, n));
2456
+ }
2457
+ }
2458
+ if (i) {
2459
+ let t = new e(i.sort($), Y);
2460
+ return r ? new Xn([t, r]) : t;
2461
+ }
2462
+ return r || Q;
2463
+ }
2464
+ eq(t) {
2465
+ if (this == t) return !0;
2466
+ if (!(t instanceof e) || this.local.length != t.local.length || this.children.length != t.children.length) return !1;
2467
+ for (let e = 0; e < this.local.length; e++) if (!this.local[e].eq(t.local[e])) return !1;
2468
+ for (let e = 0; e < this.children.length; e += 3) if (this.children[e] != t.children[e] || this.children[e + 1] != t.children[e + 1] || !this.children[e + 2].eq(t.children[e + 2])) return !1;
2469
+ return !0;
2470
+ }
2471
+ locals(e) {
2472
+ return rr(this.localsInner(e));
2473
+ }
2474
+ localsInner(e) {
2475
+ if (this == Q) return Y;
2476
+ if (e.inlineContent || !this.local.some(Jn.is)) return this.local;
2477
+ let t = [];
2478
+ for (let e = 0; e < this.local.length; e++) this.local[e].type instanceof Jn || t.push(this.local[e]);
2479
+ return t;
2480
+ }
2481
+ forEachSet(e) {
2482
+ e(this);
2483
+ }
2484
+ };
2485
+ Z.empty = new Z([], []), Z.removeOverlap = rr;
2486
+ var Q = Z.empty, Xn = class e {
2487
+ constructor(e) {
2488
+ this.members = e;
2489
+ }
2490
+ map(t, n) {
2491
+ let r = this.members.map((e) => e.map(t, n, X));
2492
+ return e.from(r);
2493
+ }
2494
+ forChild(t, n) {
2495
+ if (n.isLeaf) return Z.empty;
2496
+ let r = [];
2497
+ for (let i = 0; i < this.members.length; i++) {
2498
+ let a = this.members[i].forChild(t, n);
2499
+ a != Q && (a instanceof e ? r = r.concat(a.members) : r.push(a));
2500
+ }
2501
+ return e.from(r);
2502
+ }
2503
+ eq(t) {
2504
+ if (!(t instanceof e) || t.members.length != this.members.length) return !1;
2505
+ for (let e = 0; e < this.members.length; e++) if (!this.members[e].eq(t.members[e])) return !1;
2506
+ return !0;
2507
+ }
2508
+ locals(e) {
2509
+ let t, n = !0;
2510
+ for (let r = 0; r < this.members.length; r++) {
2511
+ let i = this.members[r].localsInner(e);
2512
+ if (i.length) {
2513
+ if (!t) t = i;
2514
+ else {
2515
+ n &&= (t = t.slice(), !1);
2516
+ for (let e = 0; e < i.length; e++) t.push(i[e]);
2517
+ }
2518
+ }
2519
+ }
2520
+ return t ? rr(n ? t : t.sort($)) : Y;
2521
+ }
2522
+ static from(t) {
2523
+ switch (t.length) {
2524
+ case 0: return Q;
2525
+ case 1: return t[0];
2526
+ default: return new e(t.every((e) => e instanceof Z) ? t : t.reduce((e, t) => e.concat(t instanceof Z ? t : t.members), []));
2527
+ }
2528
+ }
2529
+ forEachSet(e) {
2530
+ for (let t = 0; t < this.members.length; t++) this.members[t].forEachSet(e);
2531
+ }
2532
+ };
2533
+ function Zn(e, t, n, r, i, a, o) {
2534
+ let s = e.slice();
2535
+ for (let e = 0, t = a; e < n.maps.length; e++) {
2536
+ let r = 0;
2537
+ n.maps[e].forEach((e, n, i, a) => {
2538
+ let o = a - i - (n - e);
2539
+ for (let i = 0; i < s.length; i += 3) {
2540
+ let a = s[i + 1];
2541
+ if (a < 0 || e > a + t - r) continue;
2542
+ let c = s[i] + t - r;
2543
+ n >= c ? s[i + 1] = e <= c ? -2 : -1 : e >= t && o && (s[i] += o, s[i + 1] += o);
2544
+ }
2545
+ r += o;
2546
+ }), t = n.maps[e].map(t, -1);
2547
+ }
2548
+ let c = !1;
2549
+ for (let t = 0; t < s.length; t += 3) if (s[t + 1] < 0) {
2550
+ if (s[t + 1] == -2) {
2551
+ c = !0, s[t + 1] = -1;
2552
+ continue;
2553
+ }
2554
+ let l = n.map(e[t] + a), u = l - i;
2555
+ if (u < 0 || u >= r.content.size) {
2556
+ c = !0;
2557
+ continue;
2558
+ }
2559
+ let d = n.map(e[t + 1] + a, -1) - i, { index: f, offset: p } = r.content.findIndex(u), m = r.maybeChild(f);
2560
+ if (m && p == u && p + m.nodeSize == d) {
2561
+ let r = s[t + 2].mapInner(n, m, l + 1, e[t] + a + 1, o);
2562
+ r == Q ? (s[t + 1] = -2, c = !0) : (s[t] = u, s[t + 1] = d, s[t + 2] = r);
2563
+ } else c = !0;
2564
+ }
2565
+ if (c) {
2566
+ let c = nr($n(s, e, t, n, i, a, o), r, 0, o);
2567
+ t = c.local;
2568
+ for (let e = 0; e < s.length; e += 3) s[e + 1] < 0 && (s.splice(e, 3), e -= 3);
2569
+ for (let e = 0, t = 0; e < c.children.length; e += 3) {
2570
+ let n = c.children[e];
2571
+ for (; t < s.length && s[t] < n;) t += 3;
2572
+ s.splice(t, 0, c.children[e], c.children[e + 1], c.children[e + 2]);
2573
+ }
2574
+ }
2575
+ return new Z(t.sort($), s);
2576
+ }
2577
+ function Qn(e, t) {
2578
+ if (!t || !e.length) return e;
2579
+ let n = [];
2580
+ for (let r = 0; r < e.length; r++) {
2581
+ let i = e[r];
2582
+ n.push(new J(i.from + t, i.to + t, i.type));
2583
+ }
2584
+ return n;
2585
+ }
2586
+ function $n(e, t, n, r, i, a, o) {
2587
+ function s(e, t) {
2588
+ for (let a = 0; a < e.local.length; a++) {
2589
+ let s = e.local[a].map(r, i, t);
2590
+ s ? n.push(s) : o.onRemove && o.onRemove(e.local[a].spec);
2591
+ }
2592
+ for (let n = 0; n < e.children.length; n += 3) s(e.children[n + 2], e.children[n] + t + 1);
2593
+ }
2594
+ for (let n = 0; n < e.length; n += 3) e[n + 1] == -1 && s(e[n + 2], t[n] + a + 1);
2595
+ return n;
2596
+ }
2597
+ function er(e, t, n) {
2598
+ if (t.isLeaf) return null;
2599
+ let r = n + t.nodeSize, i = null;
2600
+ for (let t = 0, a; t < e.length; t++) (a = e[t]) && a.from > n && a.to < r && ((i ||= []).push(a), e[t] = null);
2601
+ return i;
2602
+ }
2603
+ function tr(e) {
2604
+ let t = [];
2605
+ for (let n = 0; n < e.length; n++) e[n] != null && t.push(e[n]);
2606
+ return t;
2607
+ }
2608
+ function nr(e, t, n, r) {
2609
+ let i = [], a = !1;
2610
+ t.forEach((t, o) => {
2611
+ let s = er(e, t, o + n);
2612
+ if (s) {
2613
+ a = !0;
2614
+ let e = nr(s, t, n + o + 1, r);
2615
+ e != Q && i.push(o, o + t.nodeSize, e);
2616
+ }
2617
+ });
2618
+ let o = Qn(a ? tr(e) : e, -n).sort($);
2619
+ for (let e = 0; e < o.length; e++) o[e].type.valid(t, o[e]) || (r.onRemove && r.onRemove(o[e].spec), o.splice(e--, 1));
2620
+ return o.length || i.length ? new Z(o, i) : Q;
2621
+ }
2622
+ function $(e, t) {
2623
+ return e.from - t.from || e.to - t.to;
2624
+ }
2625
+ function rr(e) {
2626
+ let t = e;
2627
+ for (let n = 0; n < t.length - 1; n++) {
2628
+ let r = t[n];
2629
+ if (r.from != r.to) for (let i = n + 1; i < t.length; i++) {
2630
+ let a = t[i];
2631
+ if (a.from == r.from) {
2632
+ a.to != r.to && (t == e && (t = e.slice()), t[i] = a.copy(a.from, r.to), ir(t, i + 1, a.copy(r.to, a.to)));
2633
+ continue;
2634
+ }
2635
+ a.from < r.to && (t == e && (t = e.slice()), t[n] = r.copy(r.from, a.from), ir(t, i, r.copy(a.from, r.to)));
2636
+ break;
2637
+ }
2638
+ }
2639
+ return t;
2640
+ }
2641
+ function ir(e, t, n) {
2642
+ for (; t < e.length && $(n, e[t]) > 0;) t++;
2643
+ e.splice(t, 0, n);
2644
+ }
2645
+ function ar(e) {
2646
+ let t = [];
2647
+ return e.someProp("decorations", (n) => {
2648
+ let r = n(e.state);
2649
+ r && r != Q && t.push(r);
2650
+ }), e.cursorWrapper && t.push(Z.create(e.state.doc, [e.cursorWrapper.deco])), Xn.from(t);
2651
+ }
2652
+ var or = {
2653
+ childList: !0,
2654
+ characterData: !0,
2655
+ characterDataOldValue: !0,
2656
+ attributes: !0,
2657
+ attributeOldValue: !0,
2658
+ subtree: !0
2659
+ }, sr = E && D <= 11, cr = class {
2660
+ constructor() {
2661
+ this.anchorNode = null, this.anchorOffset = 0, this.focusNode = null, this.focusOffset = 0;
2662
+ }
2663
+ set(e) {
2664
+ this.anchorNode = e.anchorNode, this.anchorOffset = e.anchorOffset, this.focusNode = e.focusNode, this.focusOffset = e.focusOffset;
2665
+ }
2666
+ clear() {
2667
+ this.anchorNode = this.focusNode = null;
2668
+ }
2669
+ eq(e) {
2670
+ return e.anchorNode == this.anchorNode && e.anchorOffset == this.anchorOffset && e.focusNode == this.focusNode && e.focusOffset == this.focusOffset;
2671
+ }
2672
+ }, lr = class {
2673
+ constructor(e, t) {
2674
+ this.view = e, this.handleDOMChange = t, this.queue = [], this.flushingSoon = -1, this.observer = null, this.currentSelection = new cr(), this.onCharData = null, this.suppressingSelectionUpdates = !1, this.lastChangedTextNode = null, this.observer = window.MutationObserver && new window.MutationObserver((t) => {
2675
+ for (let e = 0; e < t.length; e++) this.queue.push(t[e]);
2676
+ E && D <= 11 && t.some((e) => e.type == "childList" && e.removedNodes.length || e.type == "characterData" && e.oldValue.length > e.target.nodeValue.length) ? this.flushSoon() : A && e.composing && t.some((e) => e.type == "childList" && e.target.nodeName == "TR") ? (e.input.badSafariComposition = !0, this.flushSoon()) : this.flush();
2677
+ }), sr && (this.onCharData = (e) => {
2678
+ this.queue.push({
2679
+ target: e.target,
2680
+ type: "characterData",
2681
+ oldValue: e.prevValue
2682
+ }), this.flushSoon();
2683
+ }), this.onSelectionChange = this.onSelectionChange.bind(this);
2684
+ }
2685
+ flushSoon() {
2686
+ this.flushingSoon < 0 && (this.flushingSoon = window.setTimeout(() => {
2687
+ this.flushingSoon = -1, this.flush();
2688
+ }, 20));
2689
+ }
2690
+ forceFlush() {
2691
+ this.flushingSoon > -1 && (window.clearTimeout(this.flushingSoon), this.flushingSoon = -1, this.flush());
2692
+ }
2693
+ start() {
2694
+ this.observer && (this.observer.takeRecords(), this.observer.observe(this.view.dom, or)), this.onCharData && this.view.dom.addEventListener("DOMCharacterDataModified", this.onCharData), this.connectSelection();
2695
+ }
2696
+ stop() {
2697
+ if (this.observer) {
2698
+ let e = this.observer.takeRecords();
2699
+ if (e.length) {
2700
+ for (let t = 0; t < e.length; t++) this.queue.push(e[t]);
2701
+ window.setTimeout(() => this.flush(), 20);
2702
+ }
2703
+ this.observer.disconnect();
2704
+ }
2705
+ this.onCharData && this.view.dom.removeEventListener("DOMCharacterDataModified", this.onCharData), this.disconnectSelection();
2706
+ }
2707
+ connectSelection() {
2708
+ this.view.dom.ownerDocument.addEventListener("selectionchange", this.onSelectionChange);
2709
+ }
2710
+ disconnectSelection() {
2711
+ this.view.dom.ownerDocument.removeEventListener("selectionchange", this.onSelectionChange);
2712
+ }
2713
+ suppressSelectionUpdates() {
2714
+ this.suppressingSelectionUpdates = !0, setTimeout(() => this.suppressingSelectionUpdates = !1, 50);
2715
+ }
2716
+ onSelectionChange() {
2717
+ if (St(this.view)) {
2718
+ if (this.suppressingSelectionUpdates) return H(this.view);
2719
+ if (E && D <= 11 && !this.view.state.selection.empty) {
2720
+ let e = this.view.domSelectionRange();
2721
+ if (e.focusNode && h(e.focusNode, e.focusOffset, e.anchorNode, e.anchorOffset)) return this.flushSoon();
2722
+ }
2723
+ this.flush();
2724
+ }
2725
+ }
2726
+ setCurSelection() {
2727
+ this.currentSelection.set(this.view.domSelectionRange());
2728
+ }
2729
+ ignoreSelectionChange(e) {
2730
+ if (!e.focusNode) return !0;
2731
+ let t = /* @__PURE__ */ new Set(), n;
2732
+ for (let n = e.focusNode; n; n = d(n)) t.add(n);
2733
+ for (let r = e.anchorNode; r; r = d(r)) if (t.has(r)) {
2734
+ n = r;
2735
+ break;
2736
+ }
2737
+ let r = n && this.view.docView.nearestDesc(n);
2738
+ if (r && r.ignoreMutation({
2739
+ type: "selection",
2740
+ target: n.nodeType == 3 ? n.parentNode : n
2741
+ })) return this.setCurSelection(), !0;
2742
+ }
2743
+ pendingRecords() {
2744
+ if (this.observer) for (let e of this.observer.takeRecords()) this.queue.push(e);
2745
+ return this.queue;
2746
+ }
2747
+ flush() {
2748
+ let { view: e } = this;
2749
+ if (!e.docView || this.flushingSoon > -1) return;
2750
+ let t = this.pendingRecords();
2751
+ t.length && (this.queue = []);
2752
+ let n = e.domSelectionRange(), r = !this.suppressingSelectionUpdates && !this.currentSelection.eq(n) && St(e) && !this.ignoreSelectionChange(n), i = -1, a = -1, o = !1, s = [];
2753
+ if (e.editable) for (let e = 0; e < t.length; e++) {
2754
+ let n = this.registerMutation(t[e], s);
2755
+ n && (i = i < 0 ? n.from : Math.min(n.from, i), a = a < 0 ? n.to : Math.max(n.to, a), n.typeOver && (o = !0));
2756
+ }
2757
+ if (s.some((e) => e.nodeName == "BR") && (e.input.lastKeyCode == 8 || e.input.lastKeyCode == 46 || k && (e.composing || e.input.compositionEndedAt > Date.now() - 50) && t.some((e) => e.type == "childList" && e.removedNodes.length))) {
2758
+ for (let e of s) if (e.nodeName == "BR" && e.parentNode) {
2759
+ let t = e.nextSibling;
2760
+ for (; t && t.nodeType == 1;) {
2761
+ if (t.contentEditable == "false") {
2762
+ e.parentNode.removeChild(e);
2763
+ break;
2764
+ }
2765
+ t = t.firstChild;
2766
+ }
2767
+ }
2768
+ } else if (O && s.length) {
2769
+ let t = s.filter((e) => e.nodeName == "BR");
2770
+ if (t.length == 2) {
2771
+ let [e, n] = t;
2772
+ e.parentNode && e.parentNode.parentNode == n.parentNode ? n.remove() : e.remove();
2773
+ } else {
2774
+ let { focusNode: n } = this.currentSelection;
2775
+ for (let r of t) {
2776
+ let t = r.parentNode;
2777
+ t && t.nodeName == "LI" && (!n || hr(e, n) != t) && r.remove();
2778
+ }
2779
+ }
2780
+ }
2781
+ let l = null;
2782
+ i < 0 && r && e.input.lastFocus > Date.now() - 200 && Math.max(e.input.lastTouch, e.input.lastClick.time) < Date.now() - 300 && S(n) && (l = dt(e)) && l.eq(c.near(e.state.doc.resolve(0), 1)) ? (e.input.lastFocus = 0, H(e), this.currentSelection.set(n), e.scrollToSelection()) : (i > -1 || r) && (i > -1 && (e.docView.markDirty(i, a), fr(e)), e.input.badSafariComposition && (e.input.badSafariComposition = !1, gr(e, s)), this.handleDOMChange(i, a, o, s), e.docView && e.docView.dirty ? e.updateState(e.state) : this.currentSelection.eq(n) || H(e), this.currentSelection.set(n));
2783
+ }
2784
+ registerMutation(e, t) {
2785
+ if (t.indexOf(e.target) > -1) return null;
2786
+ let n = this.view.docView.nearestDesc(e.target);
2787
+ if (e.type == "attributes" && (n == this.view.docView || e.attributeName == "contenteditable" || e.attributeName == "style" && !e.oldValue && !e.target.getAttribute("style")) || !n || n.ignoreMutation(e)) return null;
2788
+ if (e.type == "childList") {
2789
+ for (let n = 0; n < e.addedNodes.length; n++) {
2790
+ let r = e.addedNodes[n];
2791
+ t.push(r), r.nodeType == 3 && (this.lastChangedTextNode = r);
2792
+ }
2793
+ if (n.contentDOM && n.contentDOM != n.dom && !n.contentDOM.contains(e.target)) return {
2794
+ from: n.posBefore,
2795
+ to: n.posAfter
2796
+ };
2797
+ let r = e.previousSibling, i = e.nextSibling;
2798
+ if (E && D <= 11 && e.addedNodes.length) for (let t = 0; t < e.addedNodes.length; t++) {
2799
+ let { previousSibling: n, nextSibling: a } = e.addedNodes[t];
2800
+ (!n || Array.prototype.indexOf.call(e.addedNodes, n) < 0) && (r = n), (!a || Array.prototype.indexOf.call(e.addedNodes, a) < 0) && (i = a);
2801
+ }
2802
+ let a = r && r.parentNode == e.target ? u(r) + 1 : 0, o = n.localPosFromDOM(e.target, a, -1), s = i && i.parentNode == e.target ? u(i) : e.target.childNodes.length;
2803
+ return {
2804
+ from: o,
2805
+ to: n.localPosFromDOM(e.target, s, 1)
2806
+ };
2807
+ }
2808
+ return e.type == "attributes" ? {
2809
+ from: n.posAtStart - n.border,
2810
+ to: n.posAtEnd + n.border
2811
+ } : (this.lastChangedTextNode = e.target, {
2812
+ from: n.posAtStart,
2813
+ to: n.posAtEnd,
2814
+ typeOver: e.target.nodeValue == e.oldValue
2815
+ });
2816
+ }
2817
+ }, ur = /* @__PURE__ */ new WeakMap(), dr = !1;
2818
+ function fr(e) {
2819
+ if (!ur.has(e) && (ur.set(e, null), [
2820
+ "normal",
2821
+ "nowrap",
2822
+ "pre-line"
2823
+ ].indexOf(getComputedStyle(e.dom).whiteSpace) !== -1)) {
2824
+ if (e.requiresGeckoHackNode = O, dr) return;
2825
+ console.warn("ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package."), dr = !0;
2826
+ }
2827
+ }
2828
+ function pr(e, t) {
2829
+ let n = t.startContainer, r = t.startOffset, i = t.endContainer, a = t.endOffset, o = e.domAtPos(e.state.selection.anchor);
2830
+ return h(o.node, o.offset, i, a) && ([n, r, i, a] = [
2831
+ i,
2832
+ a,
2833
+ n,
2834
+ r
2835
+ ]), {
2836
+ anchorNode: n,
2837
+ anchorOffset: r,
2838
+ focusNode: i,
2839
+ focusOffset: a
2840
+ };
2841
+ }
2842
+ function mr(e, t) {
2843
+ if (t.getComposedRanges) {
2844
+ let n = t.getComposedRanges(e.root)[0];
2845
+ if (n) return pr(e, n);
2846
+ }
2847
+ let n;
2848
+ function r(e) {
2849
+ e.preventDefault(), e.stopImmediatePropagation(), n = e.getTargetRanges()[0];
2850
+ }
2851
+ return e.dom.addEventListener("beforeinput", r, !0), document.execCommand("indent"), e.dom.removeEventListener("beforeinput", r, !0), n ? pr(e, n) : null;
2852
+ }
2853
+ function hr(e, t) {
2854
+ for (let n = t.parentNode; n && n != e.dom; n = n.parentNode) {
2855
+ let t = e.docView.nearestDesc(n, !0);
2856
+ if (t && t.node.isBlock) return n;
2857
+ }
2858
+ return null;
2859
+ }
2860
+ function gr(e, t) {
2861
+ let { focusNode: n, focusOffset: r } = e.domSelectionRange();
2862
+ for (let i of t) if (i.parentNode?.nodeName == "TR") {
2863
+ let t = i.nextSibling;
2864
+ for (; t && t.nodeName != "TD" && t.nodeName != "TH";) t = t.nextSibling;
2865
+ if (t) {
2866
+ let a = t;
2867
+ for (;;) {
2868
+ let e = a.firstChild;
2869
+ if (!e || e.nodeType != 1 || e.contentEditable == "false" || /^(BR|IMG)$/.test(e.nodeName)) break;
2870
+ a = e;
2871
+ }
2872
+ a.insertBefore(i, a.firstChild), n == i && e.domSelection().collapse(i, r);
2873
+ } else i.parentNode.removeChild(i);
2874
+ }
2875
+ }
2876
+ function _r(t, n, r, i) {
2877
+ let { node: a, fromOffset: o, toOffset: s, from: c, to: l } = t.docView.parseRange(n, r), u = t.domSelectionRange(), d, f = u.anchorNode;
2878
+ if (f && t.dom.contains(f.nodeType == 1 ? f : f.parentNode) && (d = [{
2879
+ node: f,
2880
+ offset: u.anchorOffset
2881
+ }], S(u) || d.push({
2882
+ node: u.focusNode,
2883
+ offset: u.focusOffset
2884
+ })), k && t.input.lastKeyCode === 8) for (let e = s; e > o; e--) {
2885
+ let t = a.childNodes[e - 1], n = t.pmViewDesc;
2886
+ if (t.nodeName == "BR" && !n) {
2887
+ s = e;
2888
+ break;
2889
+ }
2890
+ if (!n || n.size) break;
2891
+ }
2892
+ let p = t.state.doc, m = t.someProp("domParser") || e.fromSchema(t.state.schema), h = p.resolve(c), g = null, _ = m.parse(a, {
2893
+ topNode: h.parent,
2894
+ topMatch: h.parent.contentMatchAt(h.index()),
2895
+ topOpen: !0,
2896
+ from: o,
2897
+ to: s,
2898
+ preserveWhitespace: h.parent.type.whitespace != "pre" || "full",
2899
+ findPositions: d,
2900
+ ruleFromNode: vr(i),
2901
+ context: h
2902
+ });
2903
+ if (d && d[0].pos != null) {
2904
+ let e = d[0].pos, t = d[1] && d[1].pos;
2905
+ t ??= e, g = {
2906
+ anchor: e + c,
2907
+ head: t + c
2908
+ };
2909
+ }
2910
+ return {
2911
+ doc: _,
2912
+ sel: g,
2913
+ from: c,
2914
+ to: l
2915
+ };
2916
+ }
2917
+ var vr = (e) => (t) => {
2918
+ let n = t.pmViewDesc;
2919
+ if (n) return n.parseRule(e);
2920
+ if (t.nodeName == "BR" && t.parentNode) {
2921
+ if (A && /^(ul|ol)$/i.test(t.parentNode.nodeName)) {
2922
+ let e = document.createElement("div");
2923
+ return e.appendChild(document.createElement("li")), { skip: e };
2924
+ }
2925
+ if (t.parentNode.lastChild == t || A && /^(tr|table)$/i.test(t.parentNode.nodeName)) return { ignore: !0 };
2926
+ } else if (t.nodeName == "IMG" && t.getAttribute("mark-placeholder")) return { ignore: !0 };
2927
+ return null;
2928
+ }, yr = /^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;
2929
+ function br(e, t, n, r, i) {
2930
+ let a = e.input.compositionPendingChanges || (e.composing ? e.input.compositionID : 0);
2931
+ if (e.input.compositionPendingChanges = 0, t < 0) {
2932
+ let t = e.input.lastSelectionTime > Date.now() - 50 ? e.input.lastSelectionOrigin : null, n = dt(e, t);
2933
+ if (n && !e.state.selection.eq(n)) {
2934
+ if (k && N && e.input.lastKeyCode === 13 && Date.now() - 100 < e.input.lastKeyCodeTime && e.someProp("handleKeyDown", (t) => t(e, C(13, "Enter")))) return;
2935
+ let r = e.state.tr.setSelection(n);
2936
+ t == "pointer" ? r.setMeta("pointer", !0) : t == "key" && r.scrollIntoView(), a && r.setMeta("composition", a), e.dispatch(r);
2937
+ }
2938
+ return;
2939
+ }
2940
+ let o = e.state.doc.resolve(t), s = o.sharedDepth(n);
2941
+ t = o.before(s + 1), n = e.state.doc.resolve(n).after(s + 1);
2942
+ let c = e.state.selection, u = _r(e, t, n, i), d = e.state.doc, f = d.slice(u.from, u.to), p, m;
2943
+ e.input.lastKeyCode === 8 && Date.now() - 100 < e.input.lastKeyCodeTime ? (p = e.state.selection.to, m = "end") : (p = e.state.selection.from, m = "start"), e.input.lastKeyCode = null;
2944
+ let h = Tr(f.content, u.doc.content, u.from, p, m);
2945
+ if (h && e.input.domChangeCount++, (j && e.input.lastIOSEnter > Date.now() - 225 || N) && i.some((e) => e.nodeType == 1 && !yr.test(e.nodeName)) && (!h || h.endA >= h.endB) && e.someProp("handleKeyDown", (t) => t(e, C(13, "Enter")))) {
2946
+ e.input.lastIOSEnter = 0;
2947
+ return;
2948
+ }
2949
+ if (!h) {
2950
+ if (r && c instanceof l && !c.empty && c.$head.sameParent(c.$anchor) && !e.composing && !(u.sel && u.sel.anchor != u.sel.head)) h = {
2951
+ start: c.from,
2952
+ endA: c.to,
2953
+ endB: c.to
2954
+ };
2955
+ else {
2956
+ if (u.sel) {
2957
+ let t = xr(e, e.state.doc, u.sel);
2958
+ if (t && !t.eq(e.state.selection)) {
2959
+ let n = e.state.tr.setSelection(t);
2960
+ a && n.setMeta("composition", a), e.dispatch(n);
2961
+ }
2962
+ }
2963
+ return;
2964
+ }
2965
+ }
2966
+ e.state.selection.from < e.state.selection.to && h.start == h.endB && e.state.selection instanceof l && (h.start > e.state.selection.from && h.start <= e.state.selection.from + 2 && e.state.selection.from >= u.from ? h.start = e.state.selection.from : h.endA < e.state.selection.to && h.endA >= e.state.selection.to - 2 && e.state.selection.to <= u.to && (h.endB += e.state.selection.to - h.endA, h.endA = e.state.selection.to)), E && D <= 11 && h.endB == h.start + 1 && h.endA == h.start && h.start > u.from && u.doc.textBetween(h.start - u.from - 1, h.start - u.from + 1) == " \xA0" && (h.start--, h.endA--, h.endB--);
2967
+ let g = u.doc.resolveNoCache(h.start - u.from), _ = u.doc.resolveNoCache(h.endB - u.from), v = d.resolve(h.start), ee = g.sameParent(_) && g.parent.inlineContent && v.end() >= h.endA;
2968
+ if ((j && e.input.lastIOSEnter > Date.now() - 225 && (!ee || i.some((e) => e.nodeName == "DIV" || e.nodeName == "P")) || !ee && g.pos < u.doc.content.size && (!g.sameParent(_) || !g.parent.inlineContent) && g.pos < _.pos && !/\S/.test(u.doc.textBetween(g.pos, _.pos, "", ""))) && e.someProp("handleKeyDown", (t) => t(e, C(13, "Enter")))) {
2969
+ e.input.lastIOSEnter = 0;
2970
+ return;
2971
+ }
2972
+ if (e.state.selection.anchor > h.start && Cr(d, h.start, h.endA, g, _) && e.someProp("handleKeyDown", (t) => t(e, C(8, "Backspace")))) {
2973
+ N && k && e.domObserver.suppressSelectionUpdates();
2974
+ return;
2975
+ }
2976
+ k && h.endB == h.start && (e.input.lastChromeDelete = Date.now()), N && !ee && g.start() != _.start() && _.parentOffset == 0 && g.depth == _.depth && u.sel && u.sel.anchor == u.sel.head && u.sel.head == h.endA && (h.endB -= 2, _ = u.doc.resolveNoCache(h.endB - u.from), setTimeout(() => {
2977
+ e.someProp("handleKeyDown", function(t) {
2978
+ return t(e, C(13, "Enter"));
2979
+ });
2980
+ }, 20));
2981
+ let y = h.start, b = h.endA, x = (t) => {
2982
+ let n = t || e.state.tr.replace(y, b, u.doc.slice(h.start - u.from, h.endB - u.from));
2983
+ if (u.sel) {
2984
+ let t = xr(e, n.doc, u.sel);
2985
+ t && !(k && e.composing && t.empty && (h.start != h.endB || e.input.lastChromeDelete < Date.now() - 100) && (t.head == y || t.head == n.mapping.map(b) - 1) || E && t.empty && t.head == y) && n.setSelection(t);
2986
+ }
2987
+ return a && n.setMeta("composition", a), n.scrollIntoView();
2988
+ }, S;
2989
+ if (ee) {
2990
+ if (g.pos == _.pos) {
2991
+ E && D <= 11 && g.parentOffset == 0 && (e.domObserver.suppressSelectionUpdates(), setTimeout(() => H(e), 20));
2992
+ let t = x(e.state.tr.delete(y, b)), n = d.resolve(h.start).marksAcross(d.resolve(h.endA));
2993
+ n && t.ensureMarks(n), e.dispatch(t);
2994
+ } else if (h.endA == h.endB && (S = Sr(g.parent.content.cut(g.parentOffset, _.parentOffset), v.parent.content.cut(v.parentOffset, h.endA - v.start())))) {
2995
+ let t = x(e.state.tr);
2996
+ S.type == "add" ? t.addMark(y, b, S.mark) : t.removeMark(y, b, S.mark), e.dispatch(t);
2997
+ } else if (g.parent.child(g.index()).isText && g.index() == _.index() - +!_.textOffset) {
2998
+ let t = g.parent.textBetween(g.parentOffset, _.parentOffset), n = () => x(e.state.tr.insertText(t, y, b));
2999
+ e.someProp("handleTextInput", (r) => r(e, y, b, t, n)) || e.dispatch(n());
3000
+ } else e.dispatch(x());
3001
+ } else e.dispatch(x());
3002
+ }
3003
+ function xr(e, t, n) {
3004
+ return Math.max(n.anchor, n.head) > t.content.size ? null : xt(e, t.resolve(n.anchor), t.resolve(n.head));
3005
+ }
3006
+ function Sr(e, t) {
3007
+ let r = e.firstChild.marks, i = t.firstChild.marks, a = r, o = i, s, c, l;
3008
+ for (let e = 0; e < i.length; e++) a = i[e].removeFromSet(a);
3009
+ for (let e = 0; e < r.length; e++) o = r[e].removeFromSet(o);
3010
+ if (a.length == 1 && o.length == 0) c = a[0], s = "add", l = (e) => e.mark(c.addToSet(e.marks));
3011
+ else if (a.length == 0 && o.length == 1) c = o[0], s = "remove", l = (e) => e.mark(c.removeFromSet(e.marks));
3012
+ else return null;
3013
+ let u = [];
3014
+ for (let e = 0; e < t.childCount; e++) u.push(l(t.child(e)));
3015
+ if (n.from(u).eq(e)) return {
3016
+ mark: c,
3017
+ type: s
3018
+ };
3019
+ }
3020
+ function Cr(e, t, n, r, i) {
3021
+ if (n - t <= i.pos - r.pos || wr(r, !0, !1) < i.pos) return !1;
3022
+ let a = e.resolve(t);
3023
+ if (!r.parent.isTextblock) {
3024
+ let e = a.nodeAfter;
3025
+ return e != null && n == t + e.nodeSize;
3026
+ }
3027
+ if (a.parentOffset < a.parent.content.size || !a.parent.isTextblock) return !1;
3028
+ let o = e.resolve(wr(a, !0, !0));
3029
+ return !o.parent.isTextblock || o.pos > n || wr(o, !0, !1) < n ? !1 : r.parent.content.cut(r.parentOffset).eq(o.parent.content);
3030
+ }
3031
+ function wr(e, t, n) {
3032
+ let r = e.depth, i = t ? e.end() : e.pos;
3033
+ for (; r > 0 && (t || e.indexAfter(r) == e.node(r).childCount);) r--, i++, t = !1;
3034
+ if (n) {
3035
+ let t = e.node(r).maybeChild(e.indexAfter(r));
3036
+ for (; t && !t.isLeaf;) t = t.firstChild, i++;
3037
+ }
3038
+ return i;
3039
+ }
3040
+ function Tr(e, t, n, r, i) {
3041
+ let a = e.findDiffStart(t, n), o = n + e.size, s = n + t.size;
3042
+ if (a == null) return null;
3043
+ let { a: c, b: l } = e.findDiffEnd(t, o, s);
3044
+ if (i == "end") {
3045
+ let e = Math.max(0, a - Math.min(c, l));
3046
+ r -= c + e - a;
3047
+ }
3048
+ if (c < a && o < s) {
3049
+ let e = r <= a && r >= c ? a - r : 0;
3050
+ a -= e, l = a + (l - c), c = a;
3051
+ } else if (l < a) {
3052
+ let e = r <= a && r >= l ? a - r : 0;
3053
+ a -= e, c = a + (c - l), l = a;
3054
+ }
3055
+ return {
3056
+ start: a,
3057
+ endA: c,
3058
+ endB: l
3059
+ };
3060
+ }
3061
+ var Er = class {
3062
+ constructor(e, t) {
3063
+ this._root = null, this.focused = !1, this.trackWrites = null, this.mounted = !1, this.markCursor = null, this.cursorWrapper = null, this.lastSelectedViewDesc = void 0, this.input = new on(), this.prevDirectPlugins = [], this.pluginViews = [], this.requiresGeckoHackNode = !1, this.dragging = null, this._props = t, this.state = t.state, this.directPlugins = t.plugins || [], this.directPlugins.forEach(Nr), this.dispatch = this.dispatch.bind(this), this.dom = e && e.mount || document.createElement("div"), e && (e.appendChild ? e.appendChild(this.dom) : typeof e == "function" ? e(this.dom) : e.mount && (this.mounted = !0)), this.editable = kr(this), Or(this), this.nodeViews = jr(this), this.docView = Ke(this.state.doc, Dr(this), ar(this), this.dom, this), this.domObserver = new lr(this, (e, t, n, r) => br(this, e, t, n, r)), this.domObserver.start(), sn(this), this.updatePluginViews();
3064
+ }
3065
+ get composing() {
3066
+ return this.input.composing;
3067
+ }
3068
+ get props() {
3069
+ if (this._props.state != this.state) {
3070
+ let e = this._props;
3071
+ this._props = {};
3072
+ for (let t in e) this._props[t] = e[t];
3073
+ this._props.state = this.state;
3074
+ }
3075
+ return this._props;
3076
+ }
3077
+ update(e) {
3078
+ e.handleDOMEvents != this._props.handleDOMEvents && ln(this);
3079
+ let t = this._props;
3080
+ this._props = e, e.plugins && (e.plugins.forEach(Nr), this.directPlugins = e.plugins), this.updateStateInner(e.state, t);
3081
+ }
3082
+ setProps(e) {
3083
+ let t = {};
3084
+ for (let e in this._props) t[e] = this._props[e];
3085
+ t.state = this.state;
3086
+ for (let n in e) t[n] = e[n];
3087
+ this.update(t);
3088
+ }
3089
+ updateState(e) {
3090
+ this.updateStateInner(e, this._props);
3091
+ }
3092
+ updateStateInner(e, t) {
3093
+ let n = this.state, r = !1, i = !1;
3094
+ e.storedMarks && this.composing && (Nn(this), i = !0), this.state = e;
3095
+ let a = n.plugins != e.plugins || this._props.plugins != t.plugins;
3096
+ if (a || this._props.plugins != t.plugins || this._props.nodeViews != t.nodeViews) {
3097
+ let e = jr(this);
3098
+ Mr(e, this.nodeViews) && (this.nodeViews = e, r = !0);
3099
+ }
3100
+ (a || t.handleDOMEvents != this._props.handleDOMEvents) && ln(this), this.editable = kr(this), Or(this);
3101
+ let o = ar(this), s = Dr(this), c = n.plugins != e.plugins && !n.doc.eq(e.doc) ? "reset" : e.scrollToSelection > n.scrollToSelection ? "to selection" : "preserve", l = r || !this.docView.matchesNode(e.doc, s, o);
3102
+ (l || !e.selection.eq(n.selection)) && (i = !0);
3103
+ let u = c == "preserve" && i && this.dom.style.overflowAnchor == null && he(this);
3104
+ if (i) {
3105
+ this.domObserver.stop();
3106
+ let t = l && (E || k) && !this.composing && !n.selection.empty && !e.selection.empty && Ar(n.selection, e.selection);
3107
+ if (l) {
3108
+ let n = k ? this.trackWrites = this.domSelectionRange().focusNode : null;
3109
+ this.composing && (this.input.compositionNode = Pn(this)), (r || !this.docView.update(e.doc, s, o, this)) && (this.docView.updateOuterDeco(s), this.docView.destroy(), this.docView = Ke(e.doc, s, o, this.dom, this)), n && (!this.trackWrites || !this.dom.contains(this.trackWrites)) && (t = !0);
3110
+ }
3111
+ let i = this.input.mouseDown;
3112
+ t || !(i && this.domObserver.currentSelection.eq(this.domSelectionRange()) && wt(this) && i.delaySelUpdate()) ? H(this, t) : (yt(this, e.selection), this.domObserver.setCurSelection()), this.domObserver.start();
3113
+ }
3114
+ this.updatePluginViews(n), this.dragging?.node && !n.doc.eq(e.doc) && this.updateDraggedNode(this.dragging, n), c == "reset" ? this.dom.scrollTop = 0 : c == "to selection" ? this.scrollToSelection() : u && _e(u);
3115
+ }
3116
+ scrollToSelection() {
3117
+ let e = this.domSelectionRange().focusNode;
3118
+ if (!(!e || !this.dom.contains(e.nodeType == 1 ? e : e.parentNode)) && !this.someProp("handleScrollToSelection", (e) => e(this))) {
3119
+ if (this.state.selection instanceof s) {
3120
+ let t = this.docView.domAfterPos(this.state.selection.from);
3121
+ t.nodeType == 1 && me(this, t.getBoundingClientRect(), e);
3122
+ } else me(this, this.coordsAtPos(this.state.selection.head, 1), e);
3123
+ }
3124
+ }
3125
+ destroyPluginViews() {
3126
+ let e;
3127
+ for (; e = this.pluginViews.pop();) e.destroy && e.destroy();
3128
+ }
3129
+ updatePluginViews(e) {
3130
+ if (!e || e.plugins != this.state.plugins || this.directPlugins != this.prevDirectPlugins) {
3131
+ this.prevDirectPlugins = this.directPlugins, this.destroyPluginViews();
3132
+ for (let e = 0; e < this.directPlugins.length; e++) {
3133
+ let t = this.directPlugins[e];
3134
+ t.spec.view && this.pluginViews.push(t.spec.view(this));
3135
+ }
3136
+ for (let e = 0; e < this.state.plugins.length; e++) {
3137
+ let t = this.state.plugins[e];
3138
+ t.spec.view && this.pluginViews.push(t.spec.view(this));
3139
+ }
3140
+ } else for (let t = 0; t < this.pluginViews.length; t++) {
3141
+ let n = this.pluginViews[t];
3142
+ n.update && n.update(this, e);
3143
+ }
3144
+ }
3145
+ updateDraggedNode(e, t) {
3146
+ let n = e.node, r = -1;
3147
+ if (n.from < this.state.doc.content.size && this.state.doc.nodeAt(n.from) == n.node) r = n.from;
3148
+ else {
3149
+ let e = n.from + (this.state.doc.content.size - t.doc.content.size);
3150
+ (e > 0 && e < this.state.doc.content.size && this.state.doc.nodeAt(e)) == n.node && (r = e);
3151
+ }
3152
+ this.dragging = new Hn(e.slice, e.move, r < 0 ? void 0 : s.create(this.state.doc, r));
3153
+ }
3154
+ someProp(e, t) {
3155
+ let n = this._props && this._props[e], r;
3156
+ if (n != null && (r = t ? t(n) : n)) return r;
3157
+ for (let n = 0; n < this.directPlugins.length; n++) {
3158
+ let i = this.directPlugins[n].props[e];
3159
+ if (i != null && (r = t ? t(i) : i)) return r;
3160
+ }
3161
+ let i = this.state.plugins;
3162
+ if (i) for (let n = 0; n < i.length; n++) {
3163
+ let a = i[n].props[e];
3164
+ if (a != null && (r = t ? t(a) : a)) return r;
3165
+ }
3166
+ }
3167
+ hasFocus() {
3168
+ if (E) {
3169
+ let e = this.root.activeElement;
3170
+ if (e == this.dom) return !0;
3171
+ if (!e || !this.dom.contains(e)) return !1;
3172
+ for (; e && this.dom != e && this.dom.contains(e);) {
3173
+ if (e.contentEditable == "false") return !1;
3174
+ e = e.parentElement;
3175
+ }
3176
+ return !0;
3177
+ }
3178
+ return this.root.activeElement == this.dom;
3179
+ }
3180
+ focus() {
3181
+ this.domObserver.stop(), this.editable && ye(this.dom), H(this), this.domObserver.start();
3182
+ }
3183
+ get root() {
3184
+ let e = this._root;
3185
+ if (e == null) {
3186
+ for (let e = this.dom.parentNode; e; e = e.parentNode) if (e.nodeType == 9 || e.nodeType == 11 && e.host) return e.getSelection || (Object.getPrototypeOf(e).getSelection = () => e.ownerDocument.getSelection()), this._root = e;
3187
+ }
3188
+ return e || document;
3189
+ }
3190
+ updateRoot() {
3191
+ this._root = null;
3192
+ }
3193
+ posAtCoords(e) {
3194
+ return De(this, e);
3195
+ }
3196
+ coordsAtPos(e, t = 1) {
3197
+ return Ae(this, e, t);
3198
+ }
3199
+ domAtPos(e, t = 0) {
3200
+ return this.docView.domFromPos(e, t);
3201
+ }
3202
+ nodeDOM(e) {
3203
+ let t = this.docView.descAt(e);
3204
+ return t ? t.nodeDOM : null;
3205
+ }
3206
+ posAtDOM(e, t, n = -1) {
3207
+ let r = this.docView.posFromDOM(e, t, n);
3208
+ if (r == null) throw RangeError("DOM position not inside the editor");
3209
+ return r;
3210
+ }
3211
+ endOfTextblock(e, t) {
3212
+ return Be(this, t || this.state, e);
3213
+ }
3214
+ pasteHTML(e, t) {
3215
+ return Bn(this, "", e, !1, t || new ClipboardEvent("paste"));
3216
+ }
3217
+ pasteText(e, t) {
3218
+ return Bn(this, e, null, !0, t || new ClipboardEvent("paste"));
3219
+ }
3220
+ serializeForClipboard(e) {
3221
+ return Ht(this, e);
3222
+ }
3223
+ destroy() {
3224
+ this.docView && (cn(this), this.destroyPluginViews(), this.mounted ? (this.docView.update(this.state.doc, [], ar(this), this), this.dom.textContent = "") : this.dom.parentNode && this.dom.parentNode.removeChild(this.dom), this.docView.destroy(), this.docView = null, m());
3225
+ }
3226
+ get isDestroyed() {
3227
+ return this.docView == null;
3228
+ }
3229
+ dispatchEvent(e) {
3230
+ return fn(this, e);
3231
+ }
3232
+ domSelectionRange() {
3233
+ let e = this.domSelection();
3234
+ return e ? A && this.root.nodeType === 11 && te(this.dom.ownerDocument) == this.dom && mr(this, e) || e : {
3235
+ focusNode: null,
3236
+ focusOffset: 0,
3237
+ anchorNode: null,
3238
+ anchorOffset: 0
3239
+ };
3240
+ }
3241
+ domSelection() {
3242
+ return this.root.getSelection();
3243
+ }
3244
+ };
3245
+ Er.prototype.dispatch = function(e) {
3246
+ let t = this._props.dispatchTransaction;
3247
+ t ? t.call(this, e) : this.updateState(this.state.apply(e));
3248
+ };
3249
+ function Dr(e) {
3250
+ let t = Object.create(null);
3251
+ return t.class = "ProseMirror", t.contenteditable = String(e.editable), e.someProp("attributes", (n) => {
3252
+ if (typeof n == "function" && (n = n(e.state)), n) for (let e in n) e == "class" ? t.class += " " + n[e] : e == "style" ? t.style = (t.style ? t.style + ";" : "") + n[e] : !t[e] && e != "contenteditable" && e != "nodeName" && (t[e] = String(n[e]));
3253
+ }), t.translate ||= "no", [J.node(0, e.state.doc.content.size, t)];
3254
+ }
3255
+ function Or(e) {
3256
+ if (e.markCursor) {
3257
+ let t = document.createElement("img");
3258
+ t.className = "ProseMirror-separator", t.setAttribute("mark-placeholder", "true"), t.setAttribute("alt", ""), e.cursorWrapper = {
3259
+ dom: t,
3260
+ deco: J.widget(e.state.selection.from, t, {
3261
+ raw: !0,
3262
+ marks: e.markCursor
3263
+ })
3264
+ };
3265
+ } else e.cursorWrapper = null;
3266
+ }
3267
+ function kr(e) {
3268
+ return !e.someProp("editable", (t) => t(e.state) === !1);
3269
+ }
3270
+ function Ar(e, t) {
3271
+ let n = Math.min(e.$anchor.sharedDepth(e.head), t.$anchor.sharedDepth(t.head));
3272
+ return e.$anchor.start(n) != t.$anchor.start(n);
3273
+ }
3274
+ function jr(e) {
3275
+ let t = Object.create(null);
3276
+ function n(e) {
3277
+ for (let n in e) Object.prototype.hasOwnProperty.call(t, n) || (t[n] = e[n]);
3278
+ }
3279
+ return e.someProp("nodeViews", n), e.someProp("markViews", n), t;
3280
+ }
3281
+ function Mr(e, t) {
3282
+ let n = 0, r = 0;
3283
+ for (let r in e) {
3284
+ if (e[r] != t[r]) return !0;
3285
+ n++;
3286
+ }
3287
+ for (let e in t) r++;
3288
+ return n != r;
3289
+ }
3290
+ function Nr(e) {
3291
+ if (e.spec.state || e.spec.filterTransaction || e.spec.appendTransaction) throw RangeError("Plugins passed directly to the view must not have a state component");
3292
+ }
3293
+ //#endregion
3294
+ export { J as Decoration, Z as DecorationSet, Er as EditorView };
3295
+
3296
+ //# sourceMappingURL=index.js.map