@lunejs/admin-ui 0.1.4 → 0.2.0

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