/* * Extracted from browser-delivered Turbopack chunk: 2a4e4dccbc3fdacb.bc4b655d5c.js * Module id: 675993 * For reading/searching only; this factory depends on the original Turbopack runtime. */ const moduleFactory = (e) => { "use strict"; var t = e.i(111092), n = e.i(47091), r = e.i(545773); let i = function (e) { for (var t = 0; ; t++) if (!(e = e.previousSibling)) return t; }, o = function (e) { let t = e.assignedSlot || e.parentNode; return t && 11 == t.nodeType ? t.host : t; }, s = null, l = function (e, t, n) { let r = s || (s = document.createRange()); return ( r.setEnd(e, null == n ? e.nodeValue.length : n), r.setStart(e, t || 0), r ); }, a = function () { s = null; }, d = function (e, t, n, r) { return n && (h(e, t, n, r, -1) || h(e, t, n, r, 1)); }, c = /^(img|br|input|textarea|hr)$/i; function h(e, t, n, r, o) { for (var s; ; ) { if (e == n && t == r) return !0; if (t == (o < 0 ? 0 : p(e))) { let n = e.parentNode; if ( !n || 1 != n.nodeType || u(e) || c.test(e.nodeName) || "false" == e.contentEditable ) return !1; (t = i(e) + (o < 0 ? 0 : 1)), (e = n); } else { if (1 != e.nodeType) return !1; let n = e.childNodes[t + (o < 0 ? -1 : 0)]; if (1 == n.nodeType && "false" == n.contentEditable) if (null == (s = n.pmViewDesc) || !s.ignoreForSelection) return !1; else t += o; else (e = n), (t = o < 0 ? p(e) : 0); } } } function p(e) { return 3 == e.nodeType ? e.nodeValue.length : e.childNodes.length; } function u(e) { let t; for (let n = e; n && !(t = n.pmViewDesc); n = n.parentNode); return t && t.node && t.node.isBlock && (t.dom == e || t.contentDOM == e); } let f = function (e) { return ( e.focusNode && d(e.focusNode, e.focusOffset, e.anchorNode, e.anchorOffset) ); }; function m(e, t) { let n = document.createEvent("Event"); return ( n.initEvent("keydown", !0, !0), (n.keyCode = e), (n.key = n.code = t), n ); } let g = "u" > typeof navigator ? navigator : null, y = "u" > typeof document ? document : null, b = (g && g.userAgent) || "", k = /Edge\/(\d+)/.exec(b), v = /MSIE \d/.exec(b), w = /Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(b), S = !!(v || w || k), x = v ? document.documentMode : w ? +w[1] : k ? +k[1] : 0, M = !S && /gecko\/(\d+)/i.test(b); M && (/Firefox\/(\d+)/.exec(b) || [0, 0])[1]; let C = !S && /Chrome\/(\d+)/.exec(b), T = !!C, N = C ? +C[1] : 0, E = !S && !!g && /Apple Computer/.test(g.vendor), O = E && (/Mobile\/\w+/.test(b) || (!!g && g.maxTouchPoints > 2)), A = O || (!!g && /Mac/.test(g.platform)), D = !!g && /Win/.test(g.platform), R = /Android \d/.test(b), I = !!y && "webkitFontSmoothing" in y.documentElement.style, P = I ? +(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent) || [0, 0])[1] : 0; function L(e, t) { return "number" == typeof e ? e : e[t]; } function z(e, t, n) { let r = e.someProp("scrollThreshold") || 0, i = e.someProp("scrollMargin") || 5, s = e.dom.ownerDocument; for (let l = n || e.dom; l; ) { if (1 != l.nodeType) { l = o(l); continue; } let e = l, n = e == s.body, a = n ? (function (e) { let t = e.defaultView && e.defaultView.visualViewport; return t ? { left: 0, right: t.width, top: 0, bottom: t.height } : { left: 0, right: e.documentElement.clientWidth, top: 0, bottom: e.documentElement.clientHeight, }; })(s) : (function (e) { let t = e.getBoundingClientRect(), n = t.width / e.offsetWidth || 1, r = t.height / e.offsetHeight || 1; return { left: t.left, right: t.left + e.clientWidth * n, top: t.top, bottom: t.top + e.clientHeight * r, }; })(e), d = 0, c = 0; if ( (t.top < a.top + L(r, "top") ? (c = -(a.top - t.top + L(i, "top"))) : t.bottom > a.bottom - L(r, "bottom") && (c = t.bottom - t.top > a.bottom - a.top ? t.top + L(i, "top") - a.top : t.bottom - a.bottom + L(i, "bottom")), t.left < a.left + L(r, "left") ? (d = -(a.left - t.left + L(i, "left"))) : t.right > a.right - L(r, "right") && (d = t.right - a.right + L(i, "right")), d || c) ) if (n) s.defaultView.scrollBy(d, c); else { let n = e.scrollLeft, r = e.scrollTop; c && (e.scrollTop += c), d && (e.scrollLeft += d); let i = e.scrollLeft - n, o = e.scrollTop - r; t = { left: t.left - i, top: t.top - o, right: t.right - i, bottom: t.bottom - o, }; } let h = n ? "fixed" : getComputedStyle(l).position; if (/^(fixed|sticky)$/.test(h)) break; l = "absolute" == h ? l.offsetParent : o(l); } } function B(e) { let t = [], n = e.ownerDocument; for ( let r = e; r && (t.push({ dom: r, top: r.scrollTop, left: r.scrollLeft }), e != n); r = o(r) ); return t; } function $(e, t) { for (let n = 0; n < e.length; n++) { let { dom: r, top: i, left: o } = e[n]; r.scrollTop != i + t && (r.scrollTop = i + t), r.scrollLeft != o && (r.scrollLeft = o); } } let j = null; function F(e, t) { return ( e.left >= t.left - 1 && e.left <= t.right + 1 && e.top >= t.top - 1 && e.top <= t.bottom + 1 ); } function V(e) { return e.top < e.bottom || e.left < e.right; } function H(e, t) { let n = e.getClientRects(); if (n.length) { let e = n[t < 0 ? 0 : n.length - 1]; if (V(e)) return e; } return Array.prototype.find.call(n, V) || e.getBoundingClientRect(); } let W = /[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/; function _(e, t, n) { let { node: r, offset: i, atom: o, } = e.docView.domFromPos(t, n < 0 ? -1 : 1), s = I || M; if (3 == r.nodeType) if ( s && (W.test(r.nodeValue) || (n < 0 ? !i : i == r.nodeValue.length)) ) { let e = H(l(r, i, i), n); if ( M && i && /\s/.test(r.nodeValue[i - 1]) && i < r.nodeValue.length ) { let t = H(l(r, i - 1, i - 1), -1); if (t.top == e.top) { let n = H(l(r, i, i + 1), -1); if (n.top != e.top) return q(n, n.left < t.left); } } return e; } else { let e = i, t = i, o = n < 0 ? 1 : -1; return ( n < 0 && !i ? (t++, (o = -1)) : n >= 0 && i == r.nodeValue.length ? (e--, (o = 1)) : n < 0 ? e-- : t++, q(H(l(r, e, t), o), o < 0) ); } if (!e.state.doc.resolve(t - (o || 0)).parent.inlineContent) { if (null == o && i && (n < 0 || i == p(r))) { let e = r.childNodes[i - 1]; if (1 == e.nodeType) return K(e.getBoundingClientRect(), !1); } if (null == o && i < p(r)) { let e = r.childNodes[i]; if (1 == e.nodeType) return K(e.getBoundingClientRect(), !0); } return K(r.getBoundingClientRect(), n >= 0); } if (null == o && i && (n < 0 || i == p(r))) { let e = r.childNodes[i - 1], t = 3 == e.nodeType ? l(e, p(e) - !s) : 1 != e.nodeType || ("BR" == e.nodeName && e.nextSibling) ? null : e; if (t) return q(H(t, 1), !1); } if (null == o && i < p(r)) { let e = r.childNodes[i]; for (; e.pmViewDesc && e.pmViewDesc.ignoreForCoords; ) e = e.nextSibling; let t = e ? 3 == e.nodeType ? l(e, 0, +!s) : 1 == e.nodeType ? e : null : null; if (t) return q(H(t, -1), !0); } return q(H(3 == r.nodeType ? l(r) : r, -n), n >= 0); } function q(e, t) { if (0 == e.width) return e; let n = t ? e.left : e.right; return { top: e.top, bottom: e.bottom, left: n, right: n }; } function K(e, t) { if (0 == e.height) return e; let n = t ? e.top : e.bottom; return { top: n, bottom: n, left: e.left, right: e.right }; } function U(e, t, n) { let r = e.state, i = e.root.activeElement; r != t && e.updateState(t), i != e.dom && e.focus(); try { return n(); } finally { r != t && e.updateState(r), i != e.dom && i && i.focus(); } } let J = /[\u0590-\u08ac]/, G = null, Y = null, Q = !1; class X { constructor(e, t, n, r) { (this.parent = e), (this.children = t), (this.dom = n), (this.contentDOM = r), (this.dirty = 0), (n.pmViewDesc = this); } matchesWidget(e) { return !1; } matchesMark(e) { return !1; } matchesNode(e, t, n) { return !1; } matchesHack(e) { return !1; } parseRule() { return null; } stopEvent(e) { return !1; } get size() { let e = 0; for (let t = 0; t < this.children.length; t++) e += this.children[t].size; return e; } get border() { return 0; } destroy() { (this.parent = void 0), this.dom.pmViewDesc == this && (this.dom.pmViewDesc = void 0); for (let e = 0; e < this.children.length; e++) this.children[e].destroy(); } posBeforeChild(e) { for (let t = 0, n = this.posAtStart; ; t++) { let r = this.children[t]; if (r == e) return n; n += r.size; } } get posBefore() { return this.parent.posBeforeChild(this); } get posAtStart() { return this.parent ? this.parent.posBeforeChild(this) + this.border : 0; } get posAfter() { return this.posBefore + this.size; } get posAtEnd() { return this.posAtStart + this.size - 2 * this.border; } localPosFromDOM(e, t, n) { let r; if ( this.contentDOM && this.contentDOM.contains(1 == e.nodeType ? e : e.parentNode) ) if (n < 0) { let n, r; if (e == this.contentDOM) n = e.childNodes[t - 1]; else { for (; e.parentNode != this.contentDOM; ) e = e.parentNode; n = e.previousSibling; } for (; n && !((r = n.pmViewDesc) && r.parent == this); ) n = n.previousSibling; return n ? this.posBeforeChild(r) + r.size : this.posAtStart; } else { let n, r; if (e == this.contentDOM) n = e.childNodes[t]; else { for (; e.parentNode != this.contentDOM; ) e = e.parentNode; n = e.nextSibling; } for (; n && !((r = n.pmViewDesc) && r.parent == this); ) n = n.nextSibling; return n ? this.posBeforeChild(r) : this.posAtEnd; } if (e == this.dom && this.contentDOM) r = t > i(this.contentDOM); else if ( this.contentDOM && this.contentDOM != this.dom && this.dom.contains(this.contentDOM) ) r = 2 & e.compareDocumentPosition(this.contentDOM); else if (this.dom.firstChild) { if (0 == t) for (let t = e; ; t = t.parentNode) { if (t == this.dom) { r = !1; break; } if (t.previousSibling) break; } if (null == r && t == e.childNodes.length) for (let t = e; ; t = t.parentNode) { if (t == this.dom) { r = !0; break; } if (t.nextSibling) break; } } return (null == r ? n > 0 : r) ? this.posAtEnd : this.posAtStart; } nearestDesc(e, t = !1) { for (let n = !0, r = e; r; r = r.parentNode) { let i = this.getDesc(r), o; if (i && (!t || i.node)) if ( !n || !(o = i.nodeDOM) || (1 == o.nodeType ? o.contains(1 == e.nodeType ? e : e.parentNode) : o == e) ) return i; else n = !1; } } getDesc(e) { let t = e.pmViewDesc; for (let e = t; e; e = e.parent) if (e == this) return t; } posFromDOM(e, t, n) { for (let r = e; r; r = r.parentNode) { let i = this.getDesc(r); if (i) return i.localPosFromDOM(e, t, n); } return -1; } descAt(e) { for (let t = 0, n = 0; t < this.children.length; t++) { let r = this.children[t], i = n + r.size; if (n == e && i != n) { for (; !r.border && r.children.length; ) for (let e = 0; e < r.children.length; e++) { let t = r.children[e]; if (t.size) { r = t; break; } } return r; } if (e < i) return r.descAt(e - n - r.border); n = i; } } domFromPos(e, t) { if (!this.contentDOM) return { node: this.dom, offset: 0, atom: e + 1 }; let n = 0, r = 0; for (let t = 0; n < this.children.length; n++) { let i = this.children[n], o = t + i.size; if (o > e || i instanceof eo) { r = e - t; break; } t = o; } if (r) return this.children[n].domFromPos(r - this.children[n].border, t); for ( let e; n && !(e = this.children[n - 1]).size && e instanceof Z && e.side >= 0; n-- ); if (t <= 0) { let e, r = !0; for ( ; (e = n ? this.children[n - 1] : null) && e.dom.parentNode != this.contentDOM; n--, r = !1 ); return e && t && r && !e.border && !e.domAtom ? e.domFromPos(e.size, t) : { node: this.contentDOM, offset: e ? i(e.dom) + 1 : 0 }; } { let e, r = !0; for ( ; (e = n < this.children.length ? this.children[n] : null) && e.dom.parentNode != this.contentDOM; n++, r = !1 ); return e && r && !e.border && !e.domAtom ? e.domFromPos(0, t) : { node: this.contentDOM, offset: e ? i(e.dom) : this.contentDOM.childNodes.length, }; } } parseRange(e, t, n = 0) { if (0 == this.children.length) return { node: this.contentDOM, from: e, to: t, fromOffset: 0, toOffset: this.contentDOM.childNodes.length, }; let r = -1, o = -1; for (let s = n, l = 0; ; l++) { let n = this.children[l], a = s + n.size; if (-1 == r && e <= a) { let o = s + n.border; if ( e >= o && t <= a - n.border && n.node && n.contentDOM && this.contentDOM.contains(n.contentDOM) ) return n.parseRange(e, t, o); e = s; for (let t = l; t > 0; t--) { let n = this.children[t - 1]; if ( n.size && n.dom.parentNode == this.contentDOM && !n.emptyChildAt(1) ) { r = i(n.dom) + 1; break; } e -= n.size; } -1 == r && (r = 0); } if (r > -1 && (a > t || l == this.children.length - 1)) { t = a; for (let e = l + 1; e < this.children.length; e++) { let n = this.children[e]; if ( n.size && n.dom.parentNode == this.contentDOM && !n.emptyChildAt(-1) ) { o = i(n.dom); break; } t += n.size; } -1 == o && (o = this.contentDOM.childNodes.length); break; } s = a; } return { node: this.contentDOM, from: e, to: t, fromOffset: r, toOffset: o, }; } emptyChildAt(e) { if (this.border || !this.contentDOM || !this.children.length) return !1; let t = this.children[e < 0 ? 0 : this.children.length - 1]; return 0 == t.size || t.emptyChildAt(e); } domAfterPos(e) { let { node: t, offset: n } = this.domFromPos(e, 0); if (1 != t.nodeType || n == t.childNodes.length) throw RangeError("No node after pos " + e); return t.childNodes[n]; } setSelection(e, t, n, r = !1) { let o = Math.min(e, t), s = Math.max(e, t); for (let i = 0, l = 0; i < this.children.length; i++) { let a = this.children[i], d = l + a.size; if (o > l && s < d) return a.setSelection(e - l - a.border, t - l - a.border, n, r); l = d; } let l = this.domFromPos(e, e ? -1 : 1), a = t == e ? l : this.domFromPos(t, t ? -1 : 1), c = n.root.getSelection(), h = n.domSelectionRange(), p = !1; if ((M || E) && e == t) { let { node: e, offset: t } = l; if (3 == e.nodeType) { if ( (p = !!(t && "\n" == e.nodeValue[t - 1])) && t == e.nodeValue.length ) for (let t = e, n; t; t = t.parentNode) { if ((n = t.nextSibling)) { "BR" == n.nodeName && (l = a = { node: n.parentNode, offset: i(n) + 1 }); break; } let e = t.pmViewDesc; if (e && e.node && e.node.isBlock) break; } } else { let n = e.childNodes[t - 1]; p = n && ("BR" == n.nodeName || "false" == n.contentEditable); } } if ( M && h.focusNode && h.focusNode != a.node && 1 == h.focusNode.nodeType ) { let e = h.focusNode.childNodes[h.focusOffset]; e && "false" == e.contentEditable && (r = !0); } if ( !(r || (p && E)) && d(l.node, l.offset, h.anchorNode, h.anchorOffset) && d(a.node, a.offset, h.focusNode, h.focusOffset) ) return; let u = !1; if ((c.extend || e == t) && !(p && M)) { c.collapse(l.node, l.offset); try { e != t && c.extend(a.node, a.offset), (u = !0); } catch (e) {} } if (!u) { if (e > t) { let e = l; (l = a), (a = e); } let n = document.createRange(); n.setEnd(a.node, a.offset), n.setStart(l.node, l.offset), c.removeAllRanges(), c.addRange(n); } } ignoreMutation(e) { return !this.contentDOM && "selection" != e.type; } get contentLost() { return ( this.contentDOM && this.contentDOM != this.dom && !this.dom.contains(this.contentDOM) ); } markDirty(e, t) { for (let n = 0, r = 0; r < this.children.length; r++) { let i = this.children[r], o = n + i.size; if (n == o ? e <= o && t >= n : e < o && t > n) { let r = n + i.border, s = o - i.border; if (e >= r && t <= s) { (this.dirty = e == n || t == o ? 2 : 1), e == r && t == s && (i.contentLost || i.dom.parentNode != this.contentDOM) ? (i.dirty = 3) : i.markDirty(e - r, t - r); return; } i.dirty = i.dom != i.contentDOM || i.dom.parentNode != this.contentDOM || i.children.length ? 3 : 2; } n = o; } this.dirty = 2; } markParentsDirty() { let e = 1; for (let t = this.parent; t; t = t.parent, e++) { let n = 1 == e ? 2 : 1; t.dirty < n && (t.dirty = n); } } get domAtom() { return !1; } get ignoreForCoords() { return !1; } get ignoreForSelection() { return !1; } isText(e) { return !1; } } class Z extends X { constructor(e, t, n, r) { let i, o = t.type.toDOM; if ( ("function" == typeof o && (o = o(n, () => i ? (i.parent ? i.parent.posBeforeChild(i) : void 0) : r, )), !t.type.spec.raw) ) { if (1 != o.nodeType) { let e = document.createElement("span"); e.appendChild(o), (o = e); } (o.contentEditable = "false"), o.classList.add("ProseMirror-widget"); } super(e, [], o, null), (this.widget = t), (this.widget = t), (i = this); } matchesWidget(e) { return 0 == this.dirty && e.type.eq(this.widget.type); } parseRule() { return { ignore: !0 }; } stopEvent(e) { let t = this.widget.spec.stopEvent; return !!t && t(e); } ignoreMutation(e) { return "selection" != e.type || this.widget.spec.ignoreSelection; } destroy() { this.widget.type.destroy(this.dom), super.destroy(); } get domAtom() { return !0; } get ignoreForSelection() { return !!this.widget.type.spec.relaxedSide; } get side() { return this.widget.type.side; } } class ee extends X { constructor(e, t, n, r) { super(e, [], t, null), (this.textDOM = n), (this.text = r); } get size() { return this.text.length; } localPosFromDOM(e, t) { return e != this.textDOM ? this.posAtStart + (t ? this.size : 0) : this.posAtStart + t; } domFromPos(e) { return { node: this.textDOM, offset: e }; } ignoreMutation(e) { return "characterData" === e.type && e.target.nodeValue == e.oldValue; } } class et extends X { constructor(e, t, n, r, i) { super(e, [], n, r), (this.mark = t), (this.spec = i); } static create(e, t, r, i) { let o = i.nodeViews[t.type.name], s = o && o(t, i, r); return ( (s && s.dom) || (s = n.DOMSerializer.renderSpec( document, t.type.spec.toDOM(t, r), null, t.attrs, )), new et(e, t, s.dom, s.contentDOM || s.dom, s) ); } parseRule() { return 3 & this.dirty || this.mark.type.spec.reparseInView ? null : { mark: this.mark.type.name, attrs: this.mark.attrs, contentElement: this.contentDOM, }; } matchesMark(e) { return 3 != this.dirty && this.mark.eq(e); } markDirty(e, t) { if ((super.markDirty(e, t), 0 != this.dirty)) { let e = this.parent; for (; !e.node; ) e = e.parent; e.dirty < this.dirty && (e.dirty = this.dirty), (this.dirty = 0); } } slice(e, t, n) { let r = et.create(this.parent, this.mark, !0, n), i = this.children, o = this.size; t < o && (i = eg(i, t, o, n)), e > 0 && (i = eg(i, 0, e, n)); for (let e = 0; e < i.length; e++) i[e].parent = r; return (r.children = i), r; } ignoreMutation(e) { return this.spec.ignoreMutation ? this.spec.ignoreMutation(e) : super.ignoreMutation(e); } destroy() { this.spec.destroy && this.spec.destroy(), super.destroy(); } } class en extends X { constructor(e, t, n, r, i, o, s, l, a) { super(e, [], i, o), (this.node = t), (this.outerDeco = n), (this.innerDeco = r), (this.nodeDOM = s); } static create(e, t, r, i, o, s) { let l = o.nodeViews[t.type.name], a, d = l && l( t, o, () => (a ? (a.parent ? a.parent.posBeforeChild(a) : void 0) : s), r, i, ), c = d && d.dom, h = d && d.contentDOM; if (t.isText) if (c) { if (3 != c.nodeType) throw RangeError("Text must be rendered as a DOM text node"); } else c = document.createTextNode(t.text); else if (!c) { let e = n.DOMSerializer.renderSpec( document, t.type.spec.toDOM(t), null, t.attrs, ); ({ dom: c, contentDOM: h } = e); } h || t.isText || "BR" == c.nodeName || (c.hasAttribute("contenteditable") || (c.contentEditable = "false"), t.type.spec.draggable && (c.draggable = !0)); let p = c; return ((c = eh(c, r, t)), d) ? (a = new es(e, t, r, i, c, h || null, p, d, o, s + 1)) : t.isText ? new ei(e, t, r, i, c, p, o) : new en(e, t, r, i, c, h || null, p, o, s + 1); } parseRule() { if (this.node.type.spec.reparseInView) return null; let e = { node: this.node.type.name, attrs: this.node.attrs }; if ( ("pre" == this.node.type.whitespace && (e.preserveWhitespace = "full"), this.contentDOM) ) if (this.contentLost) { for (let t = this.children.length - 1; t >= 0; t--) { let n = this.children[t]; if (this.dom.contains(n.dom.parentNode)) { e.contentElement = n.dom.parentNode; break; } } e.contentElement || (e.getContent = () => n.Fragment.empty); } else e.contentElement = this.contentDOM; else e.getContent = () => this.node.content; return e; } matchesNode(e, t, n) { return ( 0 == this.dirty && e.eq(this.node) && ep(t, this.outerDeco) && n.eq(this.innerDeco) ); } get size() { return this.node.nodeSize; } get border() { return +!this.node.isLeaf; } updateChildren(e, t) { let r = this.node.inlineContent, i = t, o = e.composing ? this.localCompositionInfo(e, t) : null, s = o && o.pos > -1 ? o : null, l = o && o.pos < 0, a = new ef(this, s && s.node, e); (function (e, t, n, r) { let i = t.locals(e), o = 0; if (0 == i.length) { for (let n = 0; n < e.childCount; n++) { let s = e.child(n); r(s, i, t.forChild(o, s), n), (o += s.nodeSize); } return; } let s = 0, l = [], a = null; for (let d = 0; ; ) { let c, h, p, u; for (; s < i.length && i[s].to == o; ) { let e = i[s++]; e.widget && (c ? (h || (h = [c])).push(e) : (c = e)); } if (c) if (h) { h.sort(em); for (let e = 0; e < h.length; e++) n(h[e], d, !!a); } else n(c, d, !!a); if (a) (u = -1), (p = a), (a = null); else if (d < e.childCount) (u = d), (p = e.child(d++)); else break; for (let e = 0; e < l.length; e++) l[e].to <= o && l.splice(e--, 1); for (; s < i.length && i[s].from <= o && i[s].to > o; ) l.push(i[s++]); let f = o + p.nodeSize; if (p.isText) { let e = f; s < i.length && i[s].from < e && (e = i[s].from); for (let t = 0; t < l.length; t++) l[t].to < e && (e = l[t].to); e < f && ((a = p.cut(e - o)), (p = p.cut(0, e - o)), (f = e), (u = -1)); } else for (; s < i.length && i[s].to < f; ) s++; let m = p.isInline && !p.isLeaf ? l.filter((e) => !e.inline) : l.slice(); r(p, m, t.forChild(o, p), u), (o = f); } })( this.node, this.innerDeco, (t, o, s) => { t.spec.marks ? a.syncToMarks(t.spec.marks, r, e, o) : t.type.side >= 0 && !s && a.syncToMarks( o == this.node.childCount ? n.Mark.none : this.node.child(o).marks, r, e, o, ), a.placeWidget(t, e, i); }, (t, n, s, d) => { let c; a.syncToMarks(t.marks, r, e, d), a.findNodeMatch(t, n, s, d) || (l && e.state.selection.from > i && e.state.selection.to < i + t.nodeSize && (c = a.findIndexWithChild(o.node)) > -1 && a.updateNodeAt(t, n, s, c, e)) || a.updateNextNode(t, n, s, e, d, i) || a.addNode(t, n, s, e, i), (i += t.nodeSize); }, ), a.syncToMarks([], r, e, 0), this.node.isTextblock && a.addTextblockHacks(), a.destroyRest(), (a.changed || 2 == this.dirty) && (s && this.protectLocalComposition(e, s), (function e(t, n, r) { let i = t.firstChild, o = !1; for (let s = 0; s < n.length; s++) { let l = n[s], a = l.dom; if (a.parentNode == t) { for (; a != i; ) (i = eu(i)), (o = !0); i = i.nextSibling; } else (o = !0), t.insertBefore(a, i); if (l instanceof et) { let n = i ? i.previousSibling : t.lastChild; e(l.contentDOM, l.children, r), (i = n ? n.nextSibling : t.firstChild); } } for (; i; ) (i = eu(i)), (o = !0); o && r.trackWrites == t && (r.trackWrites = null); })(this.contentDOM, this.children, e), O && (function (e) { if ("UL" == e.nodeName || "OL" == e.nodeName) { let t = e.style.cssText; (e.style.cssText = t + "; list-style: square !important"), window.getComputedStyle(e).listStyle, (e.style.cssText = t); } })(this.dom)); } localCompositionInfo(e, n) { let { from: r, to: i } = e.state.selection; if ( !(e.state.selection instanceof t.TextSelection) || r < n || i > n + this.node.content.size ) return null; let o = e.input.compositionNode; if (!o || !this.dom.contains(o.parentNode)) return null; if (!this.node.inlineContent) return { node: o, pos: -1, text: "" }; { let e = o.nodeValue, t = (function (e, t, n, r) { for (let i = 0, o = 0; i < e.childCount && o <= r; ) { let s = e.child(i++), l = o; if (((o += s.nodeSize), !s.isText)) continue; let a = s.text; for (; i < e.childCount; ) { let t = e.child(i++); if (((o += t.nodeSize), !t.isText)) break; a += t.text; } if (o >= n) { if (o >= r && a.slice(r - t.length - l, r - l) == t) return r - t.length; let e = l < r ? a.lastIndexOf(t, r - l - 1) : -1; if (e >= 0 && e + t.length + l >= n) return l + e; if ( n == r && a.length >= r + t.length - l && a.slice(r - l, r - l + t.length) == t ) return r; } } return -1; })(this.node.content, e, r - n, i - n); return t < 0 ? null : { node: o, pos: t, text: e }; } } protectLocalComposition(e, { node: t, pos: n, text: r }) { if (this.getDesc(t)) return; let i = t; for (; i.parentNode != this.contentDOM; i = i.parentNode) { for (; i.previousSibling; ) i.parentNode.removeChild(i.previousSibling); for (; i.nextSibling; ) i.parentNode.removeChild(i.nextSibling); i.pmViewDesc && (i.pmViewDesc = void 0); } let o = new ee(this, i, t, r); e.input.compositionNodes.push(o), (this.children = eg(this.children, n, n + r.length, e, o)); } update(e, t, n, r) { return ( 3 != this.dirty && !!e.sameMarkup(this.node) && (this.updateInner(e, t, n, r), !0) ); } updateInner(e, t, n, r) { this.updateOuterDeco(t), (this.node = e), (this.innerDeco = n), this.contentDOM && this.updateChildren(r, this.posAtStart), (this.dirty = 0); } updateOuterDeco(e) { if (ep(e, this.outerDeco)) return; let t = 1 != this.nodeDOM.nodeType, n = this.dom; (this.dom = ec( this.dom, this.nodeDOM, ed(this.outerDeco, this.node, t), ed(e, this.node, t), )), this.dom != n && ((n.pmViewDesc = void 0), (this.dom.pmViewDesc = this)), (this.outerDeco = e); } selectNode() { 1 == this.nodeDOM.nodeType && (this.nodeDOM.classList.add("ProseMirror-selectednode"), (this.contentDOM || !this.node.type.spec.draggable) && (this.nodeDOM.draggable = !0)); } deselectNode() { 1 == this.nodeDOM.nodeType && (this.nodeDOM.classList.remove("ProseMirror-selectednode"), (this.contentDOM || !this.node.type.spec.draggable) && this.nodeDOM.removeAttribute("draggable")); } get domAtom() { return this.node.isAtom; } } function er(e, t, n, r, i) { eh(r, t, e); let o = new en(void 0, e, t, n, r, r, r, i, 0); return o.contentDOM && o.updateChildren(i, 0), o; } class ei extends en { constructor(e, t, n, r, i, o, s) { super(e, t, n, r, i, null, o, s, 0); } parseRule() { let e = this.nodeDOM.parentNode; for (; e && e != this.dom && !e.pmIsDeco; ) e = e.parentNode; return { skip: e || !0 }; } update(e, t, n, r) { return ( 3 != this.dirty && (0 == this.dirty || !!this.inParent()) && !!e.sameMarkup(this.node) && (this.updateOuterDeco(t), (0 != this.dirty || e.text != this.node.text) && e.text != this.nodeDOM.nodeValue && ((this.nodeDOM.nodeValue = e.text), r.trackWrites == this.nodeDOM && (r.trackWrites = null)), (this.node = e), (this.dirty = 0), !0) ); } inParent() { let e = this.parent.contentDOM; for (let t = this.nodeDOM; t; t = t.parentNode) if (t == e) return !0; return !1; } domFromPos(e) { return { node: this.nodeDOM, offset: e }; } localPosFromDOM(e, t, n) { return e == this.nodeDOM ? this.posAtStart + Math.min(t, this.node.text.length) : super.localPosFromDOM(e, t, n); } ignoreMutation(e) { return "characterData" != e.type && "selection" != e.type; } slice(e, t, n) { let r = this.node.cut(e, t), i = document.createTextNode(r.text); return new ei(this.parent, r, this.outerDeco, this.innerDeco, i, i, n); } markDirty(e, t) { super.markDirty(e, t), this.dom != this.nodeDOM && (0 == e || t == this.nodeDOM.nodeValue.length) && (this.dirty = 3); } get domAtom() { return !1; } isText(e) { return this.node.text == e; } } class eo extends X { parseRule() { return { ignore: !0 }; } matchesHack(e) { return 0 == this.dirty && this.dom.nodeName == e; } get domAtom() { return !0; } get ignoreForCoords() { return "IMG" == this.dom.nodeName; } } class es extends en { constructor(e, t, n, r, i, o, s, l, a, d) { super(e, t, n, r, i, o, s, a, d), (this.spec = l); } update(e, t, n, r) { if (3 == this.dirty) return !1; if ( this.spec.update && (this.node.type == e.type || this.spec.multiType) ) { let i = this.spec.update(e, t, n); return i && this.updateInner(e, t, n, r), i; } return (!!this.contentDOM || !!e.isLeaf) && super.update(e, t, n, r); } selectNode() { this.spec.selectNode ? this.spec.selectNode() : super.selectNode(); } deselectNode() { this.spec.deselectNode ? this.spec.deselectNode() : super.deselectNode(); } setSelection(e, t, n, r) { this.spec.setSelection ? this.spec.setSelection(e, t, n.root) : super.setSelection(e, t, n, r); } destroy() { this.spec.destroy && this.spec.destroy(), super.destroy(); } stopEvent(e) { return !!this.spec.stopEvent && this.spec.stopEvent(e); } ignoreMutation(e) { return this.spec.ignoreMutation ? this.spec.ignoreMutation(e) : super.ignoreMutation(e); } } let el = function (e) { e && (this.nodeName = e); }; el.prototype = Object.create(null); let ea = [new el()]; function ed(e, t, n) { if (0 == e.length) return ea; let r = n ? ea[0] : new el(), i = [r]; for (let o = 0; o < e.length; o++) { let s = e[o].type.attrs; if (s) for (let e in (s.nodeName && i.push((r = new el(s.nodeName))), s)) { let o = s[e]; null != o && (n && 1 == i.length && i.push((r = new el(t.isInline ? "span" : "div"))), "class" == e ? (r.class = (r.class ? r.class + " " : "") + o) : "style" == e ? (r.style = (r.style ? r.style + ";" : "") + o) : "nodeName" != e && (r[e] = o)); } } return i; } function ec(e, t, n, r) { if (n == ea && r == ea) return t; let i = t; for (let t = 0; t < r.length; t++) { let o = r[t], s = n[t]; if (t) { let t; (s && s.nodeName == o.nodeName && i != e && (t = i.parentNode) && t.nodeName.toLowerCase() == o.nodeName) || (((t = document.createElement(o.nodeName)).pmIsDeco = !0), t.appendChild(i), (s = ea[0])), (i = t); } !(function (e, t, n) { for (let r in t) "class" == r || "style" == r || "nodeName" == r || r in n || e.removeAttribute(r); for (let r in n) "class" != r && "style" != r && "nodeName" != r && n[r] != t[r] && e.setAttribute(r, n[r]); if (t.class != n.class) { let r = t.class ? t.class.split(" ").filter(Boolean) : [], i = n.class ? n.class.split(" ").filter(Boolean) : []; for (let t = 0; t < r.length; t++) -1 == i.indexOf(r[t]) && e.classList.remove(r[t]); for (let t = 0; t < i.length; t++) -1 == r.indexOf(i[t]) && e.classList.add(i[t]); 0 == e.classList.length && e.removeAttribute("class"); } if (t.style != n.style) { if (t.style) { let n = /\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g, r; for (; (r = n.exec(t.style)); ) e.style.removeProperty(r[1]); } n.style && (e.style.cssText += n.style); } })(i, s || ea[0], o); } return i; } function eh(e, t, n) { return ec(e, e, ea, ed(t, n, 1 != e.nodeType)); } function ep(e, t) { if (e.length != t.length) return !1; for (let n = 0; n < e.length; n++) if (!e[n].type.eq(t[n].type)) return !1; return !0; } function eu(e) { let t = e.nextSibling; return e.parentNode.removeChild(e), t; } class ef { constructor(e, t, n) { (this.lock = t), (this.view = n), (this.index = 0), (this.stack = []), (this.changed = !1), (this.top = e), (this.preMatch = (function (e, t) { let n = t, r = n.children.length, i = e.childCount, o = new Map(), s = []; n: for (; i > 0; ) { let l; for (;;) if (r) { let e = n.children[r - 1]; if (e instanceof et) (n = e), (r = e.children.length); else { (l = e), r--; break; } } else if (n == t) break n; else (r = n.parent.children.indexOf(n)), (n = n.parent); let a = l.node; if (a) { if (a != e.child(i - 1)) break; --i, o.set(l, i), s.push(l); } } return { index: i, matched: o, matches: s.reverse() }; })(e.node.content, e)); } destroyBetween(e, t) { if (e != t) { for (let n = e; n < t; n++) this.top.children[n].destroy(); this.top.children.splice(e, t - e), (this.changed = !0); } } destroyRest() { this.destroyBetween(this.index, this.top.children.length); } syncToMarks(e, t, n, r) { let i = 0, o = this.stack.length >> 1, s = Math.min(o, e.length); for ( ; i < s && (i == o - 1 ? this.top : this.stack[(i + 1) << 1]).matchesMark( e[i], ) && !1 !== e[i].type.spec.spanning; ) i++; for (; i < o; ) this.destroyRest(), (this.top.dirty = 0), (this.index = this.stack.pop()), (this.top = this.stack.pop()), o--; for (; o < e.length; ) { this.stack.push(this.top, this.index + 1); let i = -1, s = this.top.children.length; r < this.preMatch.index && (s = Math.min(this.index + 3, s)); for (let t = this.index; t < s; t++) { let n = this.top.children[t]; if (n.matchesMark(e[o]) && !this.isLocked(n.dom)) { i = t; break; } } if (i > -1) i > this.index && ((this.changed = !0), this.destroyBetween(this.index, i)), (this.top = this.top.children[this.index]); else { let r = et.create(this.top, e[o], t, n); this.top.children.splice(this.index, 0, r), (this.top = r), (this.changed = !0); } (this.index = 0), o++; } } findNodeMatch(e, t, n, r) { let i = -1, o; if ( r >= this.preMatch.index && (o = this.preMatch.matches[r - this.preMatch.index]).parent == this.top && o.matchesNode(e, t, n) ) i = this.top.children.indexOf(o, this.index); else for ( let r = this.index, o = Math.min(this.top.children.length, r + 5); r < o; r++ ) { let o = this.top.children[r]; if (o.matchesNode(e, t, n) && !this.preMatch.matched.has(o)) { i = r; break; } } return ( !(i < 0) && (this.destroyBetween(this.index, i), this.index++, !0) ); } updateNodeAt(e, t, n, r, i) { let o = this.top.children[r]; return ( 3 == o.dirty && o.dom == o.contentDOM && (o.dirty = 2), !!o.update(e, t, n, i) && (this.destroyBetween(this.index, r), this.index++, !0) ); } findIndexWithChild(e) { for (;;) { let t = e.parentNode; if (!t) return -1; if (t == this.top.contentDOM) { let t = e.pmViewDesc; if (t) { for (let e = this.index; e < this.top.children.length; e++) if (this.top.children[e] == t) return e; } return -1; } e = t; } } updateNextNode(e, t, n, r, i, o) { for (let s = this.index; s < this.top.children.length; s++) { let l = this.top.children[s]; if (l instanceof en) { let a = this.preMatch.matched.get(l); if (null != a && a != i) return !1; let d = l.dom, c, h = this.isLocked(d) && !( e.isText && l.node && l.node.isText && l.nodeDOM.nodeValue == e.text && 3 != l.dirty && ep(t, l.outerDeco) ); if (!h && l.update(e, t, n, r)) return ( this.destroyBetween(this.index, s), l.dom != d && (this.changed = !0), this.index++, !0 ); if (!h && (c = this.recreateWrapper(l, e, t, n, r, o))) return ( this.destroyBetween(this.index, s), (this.top.children[this.index] = c), c.contentDOM && ((c.dirty = 2), c.updateChildren(r, o + 1), (c.dirty = 0)), (this.changed = !0), this.index++, !0 ); break; } } return !1; } recreateWrapper(e, t, n, r, i, o) { if ( e.dirty || t.isAtom || !e.children.length || !e.node.content.eq(t.content) || !ep(n, e.outerDeco) || !r.eq(e.innerDeco) ) return null; let s = en.create(this.top, t, n, r, i, o); if (s.contentDOM) for (let t of ((s.children = e.children), (e.children = []), s.children)) t.parent = s; return e.destroy(), s; } addNode(e, t, n, r, i) { let o = en.create(this.top, e, t, n, r, i); o.contentDOM && o.updateChildren(r, i + 1), this.top.children.splice(this.index++, 0, o), (this.changed = !0); } placeWidget(e, t, n) { let r = this.index < this.top.children.length ? this.top.children[this.index] : null; if ( r && r.matchesWidget(e) && (e == r.widget || !r.widget.type.toDOM.parentNode) ) this.index++; else { let r = new Z(this.top, e, t, n); this.top.children.splice(this.index++, 0, r), (this.changed = !0); } } addTextblockHacks() { let e = this.top.children[this.index - 1], t = this.top; for (; e instanceof et; ) e = (t = e).children[t.children.length - 1]; (!e || !(e instanceof ei) || /\n$/.test(e.node.text) || (this.view.requiresGeckoHackNode && /\s$/.test(e.node.text))) && ((E || T) && e && "false" == e.dom.contentEditable && this.addHackNode("IMG", t), this.addHackNode("BR", this.top)); } addHackNode(e, t) { if ( t == this.top && this.index < t.children.length && t.children[this.index].matchesHack(e) ) this.index++; else { let n = document.createElement(e); "IMG" == e && ((n.className = "ProseMirror-separator"), (n.alt = "")), "BR" == e && (n.className = "ProseMirror-trailingBreak"); let r = new eo(this.top, [], n, null); t != this.top ? t.children.push(r) : t.children.splice(this.index++, 0, r), (this.changed = !0); } } isLocked(e) { return ( this.lock && (e == this.lock || (1 == e.nodeType && e.contains(this.lock.parentNode))) ); } } function em(e, t) { return e.type.side - t.type.side; } function eg(e, t, n, r, i) { let o = []; for (let s = 0, l = 0; s < e.length; s++) { let a = e[s], d = l, c = (l += a.size); d >= n || c <= t ? o.push(a) : (d < t && o.push(a.slice(0, t - d, r)), i && (o.push(i), (i = void 0)), c > n && o.push(a.slice(n - d, a.size, r))); } return o; } function ey(e, n = null) { let r = e.domSelectionRange(), o = e.state.doc; if (!r.focusNode) return null; let s = e.docView.nearestDesc(r.focusNode), l = s && 0 == s.size, a = e.docView.posFromDOM(r.focusNode, r.focusOffset, 1); if (a < 0) return null; let d = o.resolve(a), c, h; if (f(r)) { for (c = a; s && !s.node; ) s = s.parent; let e = s.node; if ( s && e.isAtom && t.NodeSelection.isSelectable(e) && s.parent && !( e.isInline && (function (e, t, n) { for (let r = 0 == t, o = t == p(e); r || o; ) { if (e == n) return !0; let t = i(e); if (!(e = e.parentNode)) return !1; (r = r && 0 == t), (o = o && t == p(e)); } })(r.focusNode, r.focusOffset, s.dom) ) ) { let e = s.posBefore; h = new t.NodeSelection(a == e ? d : o.resolve(e)); } } else { if ( r instanceof e.dom.ownerDocument.defaultView.Selection && r.rangeCount > 1 ) { let t = a, n = a; for (let i = 0; i < r.rangeCount; i++) { let o = r.getRangeAt(i); (t = Math.min( t, e.docView.posFromDOM(o.startContainer, o.startOffset, 1), )), (n = Math.max( n, e.docView.posFromDOM(o.endContainer, o.endOffset, -1), )); } if (t < 0) return null; ([c, a] = n == e.state.selection.anchor ? [n, t] : [t, n]), (d = o.resolve(a)); } else c = e.docView.posFromDOM(r.anchorNode, r.anchorOffset, 1); if (c < 0) return null; } let u = o.resolve(c); if (!h) { let t = "pointer" == n || (e.state.selection.head < d.pos && !l) ? 1 : -1; h = eT(e, u, d, t); } return h; } function eb(e) { return e.editable ? e.hasFocus() : eE(e) && document.activeElement && document.activeElement.contains(e.dom); } function ek(e, n = !1) { let r = e.state.selection; if ((eM(e, r), eb(e))) { if (!n && e.input.mouseDown && e.input.mouseDown.allowDefault && T) { let t = e.domSelectionRange(), n = e.domObserver.currentSelection; if ( t.anchorNode && n.anchorNode && d(t.anchorNode, t.anchorOffset, n.anchorNode, n.anchorOffset) ) { (e.input.mouseDown.delayedSelectionSync = !0), e.domObserver.setCurSelection(); return; } } if ((e.domObserver.disconnectSelection(), e.cursorWrapper)) !(function (e) { let t = e.domSelection(); if (!t) return; let n = e.cursorWrapper.dom, r = "IMG" == n.nodeName; r ? t.collapse(n.parentNode, i(n) + 1) : t.collapse(n, 0), !r && !e.state.selection.visible && S && x <= 11 && ((n.disabled = !0), (n.disabled = !1)); })(e); else { var o; let i, s, l, a, { anchor: d, head: c } = r, h, p; ev && !(r instanceof t.TextSelection) && (r.$from.parent.inlineContent || (h = ew(e, r.from)), r.empty || r.$from.parent.inlineContent || (p = ew(e, r.to))), e.docView.setSelection(d, c, e, n), ev && (h && ex(h), p && ex(p)), r.visible ? e.dom.classList.remove("ProseMirror-hideselection") : (e.dom.classList.add("ProseMirror-hideselection"), "onselectionchange" in document && ((i = (o = e).dom.ownerDocument).removeEventListener( "selectionchange", o.input.hideSelectionGuard, ), (l = (s = o.domSelectionRange()).anchorNode), (a = s.anchorOffset), i.addEventListener( "selectionchange", (o.input.hideSelectionGuard = () => { (s.anchorNode != l || s.anchorOffset != a) && (i.removeEventListener( "selectionchange", o.input.hideSelectionGuard, ), setTimeout(() => { (!eb(o) || o.state.selection.visible) && o.dom.classList.remove("ProseMirror-hideselection"); }, 20)); }), ))); } e.domObserver.setCurSelection(), e.domObserver.connectSelection(); } } let ev = E || (T && N < 63); function ew(e, t) { let { node: n, offset: r } = e.docView.domFromPos(t, 0), i = r < n.childNodes.length ? n.childNodes[r] : null, o = r ? n.childNodes[r - 1] : null; if (E && i && "false" == i.contentEditable) return eS(i); if ( (!i || "false" == i.contentEditable) && (!o || "false" == o.contentEditable) ) { if (i) return eS(i); else if (o) return eS(o); } } function eS(e) { return ( (e.contentEditable = "true"), E && e.draggable && ((e.draggable = !1), (e.wasDraggable = !0)), e ); } function ex(e) { (e.contentEditable = "false"), e.wasDraggable && ((e.draggable = !0), (e.wasDraggable = null)); } function eM(e, n) { if (n instanceof t.NodeSelection) { let t = e.docView.descAt(n.from); t != e.lastSelectedViewDesc && (eC(e), t && t.selectNode(), (e.lastSelectedViewDesc = t)); } else eC(e); } function eC(e) { e.lastSelectedViewDesc && (e.lastSelectedViewDesc.parent && e.lastSelectedViewDesc.deselectNode(), (e.lastSelectedViewDesc = void 0)); } function eT(e, n, r, i) { return ( e.someProp("createSelectionBetween", (t) => t(e, n, r)) || t.TextSelection.between(n, r, i) ); } function eN(e) { return (!e.editable || !!e.hasFocus()) && eE(e); } function eE(e) { let t = e.domSelectionRange(); if (!t.anchorNode) return !1; try { return ( e.dom.contains( 3 == t.anchorNode.nodeType ? t.anchorNode.parentNode : t.anchorNode, ) && (e.editable || e.dom.contains( 3 == t.focusNode.nodeType ? t.focusNode.parentNode : t.focusNode, )) ); } catch (e) { return !1; } } function eO(e, n) { let { $anchor: r, $head: i } = e.selection, o = n > 0 ? r.max(i) : r.min(i), s = o.parent.inlineContent ? o.depth ? e.doc.resolve(n > 0 ? o.after() : o.before()) : null : o; return s && t.Selection.findFrom(s, n); } function eA(e, t) { return e.dispatch(e.state.tr.setSelection(t).scrollIntoView()), !0; } function eD(e, n, r) { let i = e.state.selection; if (i instanceof t.TextSelection) { if (r.indexOf("s") > -1) { let { $head: r } = i, o = r.textOffset ? null : n < 0 ? r.nodeBefore : r.nodeAfter; if (!o || o.isText || !o.isLeaf) return !1; let s = e.state.doc.resolve(r.pos + o.nodeSize * (n < 0 ? -1 : 1)); return eA(e, new t.TextSelection(i.$anchor, s)); } else if (!i.empty) return !1; else if (e.endOfTextblock(n > 0 ? "forward" : "backward")) { let r = eO(e.state, n); return !!r && r instanceof t.NodeSelection && eA(e, r); } else if (!(A && r.indexOf("m") > -1)) { let r = i.$head, o = r.textOffset ? null : n < 0 ? r.nodeBefore : r.nodeAfter, s; if (!o || o.isText) return !1; let l = n < 0 ? r.pos - o.nodeSize : r.pos; return ( !!(o.isAtom || ((s = e.docView.descAt(l)) && !s.contentDOM)) && (t.NodeSelection.isSelectable(o) ? eA( e, new t.NodeSelection( n < 0 ? e.state.doc.resolve(r.pos - o.nodeSize) : r, ), ) : !!I && eA( e, new t.TextSelection( e.state.doc.resolve(n < 0 ? l : l + o.nodeSize), ), )) ); } } else { if (i instanceof t.NodeSelection && i.node.isInline) return eA(e, new t.TextSelection(n > 0 ? i.$to : i.$from)); let r = eO(e.state, n); return !!r && eA(e, r); } } function eR(e) { return 3 == e.nodeType ? e.nodeValue.length : e.childNodes.length; } function eI(e, t) { let n = e.pmViewDesc; return n && 0 == n.size && (t < 0 || e.nextSibling || "BR" != e.nodeName); } function eP(e, t) { return t < 0 ? (function (e) { let t = e.domSelectionRange(), n = t.focusNode, r = t.focusOffset; if (!n) return; let o, s, l = !1; for ( M && 1 == n.nodeType && r < eR(n) && eI(n.childNodes[r], -1) && (l = !0); ; ) if (r > 0) if (1 != n.nodeType) break; else { let e = n.childNodes[r - 1]; if (eI(e, -1)) (o = n), (s = --r); else if (3 == e.nodeType) r = (n = e).nodeValue.length; else break; } else if (eL(n)) break; else { let t = n.previousSibling; for (; t && eI(t, -1); ) (o = n.parentNode), (s = i(t)), (t = t.previousSibling); if (t) r = eR((n = t)); else { if ((n = n.parentNode) == e.dom) break; r = 0; } } l ? ez(e, n, r) : o && ez(e, o, s); })(e) : (function (e) { let t, n, r = e.domSelectionRange(), o = r.focusNode, s = r.focusOffset; if (!o) return; let l = eR(o); for (;;) if (s < l) { if (1 != o.nodeType) break; if (eI(o.childNodes[s], 1)) (t = o), (n = ++s); else break; } else if (eL(o)) break; else { let r = o.nextSibling; for (; r && eI(r, 1); ) (t = r.parentNode), (n = i(r) + 1), (r = r.nextSibling); if (r) (s = 0), (l = eR((o = r))); else { if ((o = o.parentNode) == e.dom) break; s = l = 0; } } t && ez(e, t, n); })(e); } function eL(e) { let t = e.pmViewDesc; return t && t.node && t.node.isBlock; } function ez(e, t, n) { if (3 != t.nodeType) { let e, r; (r = (function (e, t) { for (; e && t == e.childNodes.length && !u(e); ) (t = i(e) + 1), (e = e.parentNode); for (; e && t < e.childNodes.length; ) { let n = e.childNodes[t]; if (3 == n.nodeType) return n; if (1 == n.nodeType && "false" == n.contentEditable) break; (e = n), (t = 0); } })(t, n)) ? ((t = r), (n = 0)) : (e = (function (e, t) { for (; e && !t && !u(e); ) (t = i(e)), (e = e.parentNode); for (; e && t; ) { let n = e.childNodes[t - 1]; if (3 == n.nodeType) return n; if (1 == n.nodeType && "false" == n.contentEditable) break; t = (e = n).childNodes.length; } })(t, n)) && ((t = e), (n = e.nodeValue.length)); } let r = e.domSelection(); if (!r) return; if (f(r)) { let e = document.createRange(); e.setEnd(t, n), e.setStart(t, n), r.removeAllRanges(), r.addRange(e); } else r.extend && r.extend(t, n); e.domObserver.setCurSelection(); let { state: o } = e; setTimeout(() => { e.state == o && ek(e); }, 50); } function eB(e, t) { let n = e.state.doc.resolve(t); if (!(T || D) && n.parent.inlineContent) { let r = e.coordsAtPos(t); if (t > n.start()) { let n = e.coordsAtPos(t - 1), i = (n.top + n.bottom) / 2; if (i > r.top && i < r.bottom && Math.abs(n.left - r.left) > 1) return n.left < r.left ? "ltr" : "rtl"; } if (t < n.end()) { let n = e.coordsAtPos(t + 1), i = (n.top + n.bottom) / 2; if (i > r.top && i < r.bottom && Math.abs(n.left - r.left) > 1) return n.left > r.left ? "ltr" : "rtl"; } } return "rtl" == getComputedStyle(e.dom).direction ? "rtl" : "ltr"; } function e$(e, n, r) { let i = e.state.selection; if ( (i instanceof t.TextSelection && !i.empty) || r.indexOf("s") > -1 || (A && r.indexOf("m") > -1) ) return !1; let { $from: o, $to: s } = i; if (!o.parent.inlineContent || e.endOfTextblock(n < 0 ? "up" : "down")) { let r = eO(e.state, n); if (r && r instanceof t.NodeSelection) return eA(e, r); } if (!o.parent.inlineContent) { let r = n < 0 ? o : s, l = i instanceof t.AllSelection ? t.Selection.near(r, n) : t.Selection.findFrom(r, n); return !!l && eA(e, l); } return !1; } function ej(e, n) { if (!(e.state.selection instanceof t.TextSelection)) return !0; let { $head: r, $anchor: i, empty: o } = e.state.selection; if (!r.sameParent(i)) return !0; if (!o) return !1; if (e.endOfTextblock(n > 0 ? "forward" : "backward")) return !0; let s = !r.textOffset && (n < 0 ? r.nodeBefore : r.nodeAfter); if (s && !s.isText) { let t = e.state.tr; return ( n < 0 ? t.delete(r.pos - s.nodeSize, r.pos) : t.delete(r.pos, r.pos + s.nodeSize), e.dispatch(t), !0 ); } return !1; } function eF(e, t, n) { e.domObserver.stop(), (t.contentEditable = n), e.domObserver.start(); } function eV(e, t) { e.someProp("transformCopied", (n) => { t = n(t, e); }); let r = [], { content: i, openStart: o, openEnd: s } = t; for ( ; o > 1 && s > 1 && 1 == i.childCount && 1 == i.firstChild.childCount; ) { o--, s--; let e = i.firstChild; r.push(e.type.name, e.attrs != e.type.defaultAttrs ? e.attrs : null), (i = e.content); } let l = e.someProp("clipboardSerializer") || n.DOMSerializer.fromSchema(e.state.schema), a = eG(), d = a.createElement("div"); d.appendChild(l.serializeFragment(i, { document: a })); let c = d.firstChild, h, p = 0; for (; c && 1 == c.nodeType && (h = eU[c.nodeName.toLowerCase()]); ) { for (let e = h.length - 1; e >= 0; e--) { let t = a.createElement(h[e]); for (; d.firstChild; ) t.appendChild(d.firstChild); d.appendChild(t), p++; } c = d.firstChild; } return ( c && 1 == c.nodeType && c.setAttribute( "data-pm-slice", `${o} ${s}${p ? ` -${p}` : ""} ${JSON.stringify(r)}`, ), { dom: d, text: e.someProp("clipboardTextSerializer", (n) => n(t, e)) || t.content.textBetween(0, t.content.size, "\n\n"), slice: t, } ); } function eH(e, t, r, i, o) { let s, l, a = o.parent.type.spec.code; if (!r && !t) return null; let d = !!t && (i || a || !r); if (d) { if ( (e.someProp("transformPastedText", (n) => { t = n(t, a || i, e); }), a) ) return ( (l = new n.Slice( n.Fragment.from(e.state.schema.text(t.replace(/\r\n?/g, "\n"))), 0, 0, )), e.someProp("transformPasted", (t) => { l = t(l, e, !0); }), l ); let r = e.someProp("clipboardTextParser", (n) => n(t, o, i, e)); if (r) l = r; else { let r = o.marks(), { schema: i } = e.state, l = n.DOMSerializer.fromSchema(i); (s = document.createElement("div")), t.split(/(?:\r\n?|\n)+/).forEach((e) => { let t = s.appendChild(document.createElement("p")); e && t.appendChild(l.serializeNode(i.text(e, r))); }); } } else e.someProp("transformPastedHTML", (t) => { r = t(r, e); }), (s = (function (e) { var t; let n, r = /^(\s*]*>)*/.exec(e); r && (e = e.slice(r[0].length)); let i = eG().createElement("div"), o = /<([a-z][^>\s]+)/i.exec(e), s; if ( ((s = o && eU[o[1].toLowerCase()]) && (e = s.map((e) => "<" + e + ">").join("") + e + s .map((e) => "") .reverse() .join("")), (i.innerHTML = ((t = e), (n = window.trustedTypes) ? (eY || (eY = n.defaultPolicy || n.createPolicy("ProseMirrorClipboard", { createHTML: (e) => e, })), eY.createHTML(t)) : t)), s) ) for (let e = 0; e < s.length; e++) i = i.querySelector(s[e]) || i; return i; })(r)), I && (function (e) { let t = e.querySelectorAll( T ? "span:not([class]):not([style])" : "span.Apple-converted-space", ); for (let n = 0; n < t.length; n++) { let r = t[n]; 1 == r.childNodes.length && " " == r.textContent && r.parentNode && r.parentNode.replaceChild( e.ownerDocument.createTextNode(" "), r, ); } })(s); let c = s && s.querySelector("[data-pm-slice]"), h = c && /^(\d+) (\d+)(?: -(\d+))? (.*)/.exec( c.getAttribute("data-pm-slice") || "", ); if (h && h[3]) for (let e = +h[3]; e > 0; e--) { let e = s.firstChild; for (; e && 1 != e.nodeType; ) e = e.nextSibling; if (!e) break; s = e; } if ( (l || (l = ( e.someProp("clipboardParser") || e.someProp("domParser") || n.DOMParser.fromSchema(e.state.schema) ).parseSlice(s, { preserveWhitespace: !!(d || h), context: o, ruleFromNode: (e) => "BR" != e.nodeName || e.nextSibling || !e.parentNode || eW.test(e.parentNode.nodeName) ? null : { ignore: !0 }, })), h) ) l = (function (e, t) { if (!e.size) return e; let r = e.content.firstChild.type.schema, i; try { i = JSON.parse(t); } catch (t) { return e; } let { content: o, openStart: s, openEnd: l } = e; for (let e = i.length - 2; e >= 0; e -= 2) { let t = r.nodes[i[e]]; if (!t || t.hasRequiredAttrs()) break; (o = n.Fragment.from(t.create(i[e + 1], o))), s++, l++; } return new n.Slice(o, s, l); })(eK(l, +h[1], +h[2]), h[4]); else if ( (l = n.Slice.maxOpen( (function (e, t) { if (e.childCount < 2) return e; for (let r = t.depth; r >= 0; r--) { let i = t.node(r).contentMatchAt(t.index(r)), o, s = []; if ( (e.forEach((e) => { if (!s) return; let t = i.findWrapping(e.type), r; if (!t) return (s = null); if ( (r = s.length && o.length && (function e(t, r, i, o, s) { if (s < t.length && s < r.length && t[s] == r[s]) { let l = e(t, r, i, o.lastChild, s + 1); if (l) return o.copy( o.content.replaceChild(o.childCount - 1, l), ); if ( o .contentMatchAt(o.childCount) .matchType(s == t.length - 1 ? i.type : t[s + 1]) ) return o.copy( o.content.append( n.Fragment.from(e_(i, t, s + 1)), ), ); } })(t, o, e, s[s.length - 1], 0)) ) s[s.length - 1] = r; else { s.length && (s[s.length - 1] = (function e(t, r) { if (0 == r) return t; let i = t.content.replaceChild( t.childCount - 1, e(t.lastChild, r - 1), ), o = t .contentMatchAt(t.childCount) .fillBefore(n.Fragment.empty, !0); return t.copy(i.append(o)); })(s[s.length - 1], o.length)); let r = e_(e, t); s.push(r), (i = i.matchType(r.type)), (o = t); } }), s) ) return n.Fragment.from(s); } return e; })(l.content, o), !0, )).openStart || l.openEnd ) { let e = 0, t = 0; for ( let t = l.content.firstChild; e < l.openStart && !t.type.spec.isolating; e++, t = t.firstChild ); for ( let e = l.content.lastChild; t < l.openEnd && !e.type.spec.isolating; t++, e = e.lastChild ); l = eK(l, e, t); } return ( e.someProp("transformPasted", (t) => { l = t(l, e, d); }), l ); } let eW = /^(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; function e_(e, t, r = 0) { for (let i = t.length - 1; i >= r; i--) e = t[i].create(null, n.Fragment.from(e)); return e; } function eq(e, t, r, i, o, s) { let l = t < 0 ? e.firstChild : e.lastChild, a = l.content; return ( e.childCount > 1 && (s = 0), o < i - 1 && (a = eq(a, t, r, i, o + 1, s)), o >= r && (a = t < 0 ? l .contentMatchAt(0) .fillBefore(a, s <= o) .append(a) : a.append( l .contentMatchAt(l.childCount) .fillBefore(n.Fragment.empty, !0), )), e.replaceChild(t < 0 ? 0 : e.childCount - 1, l.copy(a)) ); } function eK(e, t, r) { return ( t < e.openStart && (e = new n.Slice( eq(e.content, -1, t, e.openStart, 0, e.openEnd), t, e.openEnd, )), r < e.openEnd && (e = new n.Slice( eq(e.content, 1, r, e.openEnd, 0, 0), e.openStart, r, )), e ); } let eU = { thead: ["table"], tbody: ["table"], tfoot: ["table"], caption: ["table"], colgroup: ["table"], col: ["table", "colgroup"], tr: ["table", "tbody"], td: ["table", "tbody", "tr"], th: ["table", "tbody", "tr"], }, eJ = null; function eG() { return eJ || (eJ = document.implementation.createHTMLDocument("title")); } let eY = null, eQ = {}, eX = {}, eZ = { touchstart: !0, touchmove: !0 }; class e0 { constructor() { (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.badSafariComposition = !1), (this.compositionPendingChanges = 0), (this.domChangeCount = 0), (this.eventHandlers = Object.create(null)), (this.hideSelectionGuard = null); } } function e1(e, t) { (e.input.lastSelectionOrigin = t), (e.input.lastSelectionTime = Date.now()); } function e2(e) { e.someProp("handleDOMEvents", (t) => { for (let n in t) e.input.eventHandlers[n] || e.dom.addEventListener( n, (e.input.eventHandlers[n] = (t) => e3(e, t)), ); }); } function e3(e, t) { return e.someProp("handleDOMEvents", (n) => { let r = n[t.type]; return !!r && (r(e, t) || t.defaultPrevented); }); } function e4(e) { return { left: e.clientX, top: e.clientY }; } function e5(e, t, n, r, i) { if (-1 == r) return !1; let o = e.state.doc.resolve(r); for (let r = o.depth + 1; r > 0; r--) if ( e.someProp(t, (t) => r > o.depth ? t(e, n, o.nodeAfter, o.before(r), i, !0) : t(e, n, o.node(r), o.before(r), i, !1), ) ) return !0; return !1; } function e6(e, t, n) { if ((e.focused || e.focus(), e.state.selection.eq(t))) return; let r = e.state.tr.setSelection(t); "pointer" == n && r.setMeta("pointer", !0), e.dispatch(r); } (eX.keydown = (e, t) => { if ( ((e.input.shiftKey = 16 == t.keyCode || t.shiftKey), !e8(e, t)) && ((e.input.lastKeyCode = t.keyCode), (e.input.lastKeyCodeTime = Date.now()), !R || !T || 13 != t.keyCode) ) if ( (229 != t.keyCode && e.domObserver.forceFlush(), !O || 13 != t.keyCode || t.ctrlKey || t.altKey || t.metaKey) ) e.someProp("handleKeyDown", (n) => n(e, t)) || (function (e, t) { let n, r = t.keyCode, i = ((n = ""), t.ctrlKey && (n += "c"), t.metaKey && (n += "m"), t.altKey && (n += "a"), t.shiftKey && (n += "s"), n); if (8 == r || (A && 72 == r && "c" == i)) return ej(e, -1) || eP(e, -1); if ((46 == r && !t.shiftKey) || (A && 68 == r && "c" == i)) return ej(e, 1) || eP(e, 1); if (13 == r || 27 == r) return !0; if (37 == r || (A && 66 == r && "c" == i)) { let t = 37 == r ? "ltr" == eB(e, e.state.selection.from) ? -1 : 1 : -1; return eD(e, t, i) || eP(e, t); } if (39 == r || (A && 70 == r && "c" == i)) { let t = 39 == r ? ("ltr" == eB(e, e.state.selection.from) ? 1 : -1) : 1; return eD(e, t, i) || eP(e, t); } else if (38 == r || (A && 80 == r && "c" == i)) return e$(e, -1, i) || eP(e, -1); else if (40 == r || (A && 78 == r && "c" == i)) return ( (function (e) { if (!E || e.state.selection.$head.parentOffset > 0) return !1; let { focusNode: t, focusOffset: n } = e.domSelectionRange(); if ( t && 1 == t.nodeType && 0 == n && t.firstChild && "false" == t.firstChild.contentEditable ) { let n = t.firstChild; eF(e, n, "true"), setTimeout(() => eF(e, n, "false"), 20); } return !1; })(e) || e$(e, 1, i) || eP(e, 1) ); else if ( i == (A ? "m" : "c") && (66 == r || 73 == r || 89 == r || 90 == r) ) return !0; return !1; })(e, t) ? t.preventDefault() : e1(e, "key"); else { let t = Date.now(); (e.input.lastIOSEnter = t), (e.input.lastIOSEnterFallbackTimeout = setTimeout(() => { e.input.lastIOSEnter == t && (e.someProp("handleKeyDown", (t) => t(e, m(13, "Enter"))), (e.input.lastIOSEnter = 0)); }, 200)); } }), (eX.keyup = (e, t) => { 16 == t.keyCode && (e.input.shiftKey = !1); }), (eX.keypress = (e, n) => { if ( e8(e, n) || !n.charCode || (n.ctrlKey && !n.altKey) || (A && n.metaKey) ) return; if (e.someProp("handleKeyPress", (t) => t(e, n))) return void n.preventDefault(); let r = e.state.selection; if (!(r instanceof t.TextSelection) || !r.$from.sameParent(r.$to)) { let t = String.fromCharCode(n.charCode), i = () => e.state.tr.insertText(t).scrollIntoView(); /[\r\n]/.test(t) || e.someProp("handleTextInput", (n) => n(e, r.$from.pos, r.$to.pos, t, i), ) || e.dispatch(i()), n.preventDefault(); } }); let e9 = A ? "metaKey" : "ctrlKey"; eQ.mousedown = (e, n) => { var r; let i, o; e.input.shiftKey = n.shiftKey; let s = tr(e), l = Date.now(), a = "singleClick"; l - e.input.lastClick.time < 500 && (i = (r = e.input.lastClick).x - n.clientX) * i + (o = r.y - n.clientY) * o < 100 && !n[e9] && e.input.lastClick.button == n.button && ("singleClick" == e.input.lastClick.type ? (a = "doubleClick") : "doubleClick" == e.input.lastClick.type && (a = "tripleClick")), (e.input.lastClick = { time: l, x: n.clientX, y: n.clientY, type: a, button: n.button, }); let d = e.posAtCoords(e4(n)); d && ("singleClick" == a ? (e.input.mouseDown && e.input.mouseDown.done(), (e.input.mouseDown = new e7(e, d, n, !!s))) : ("doubleClick" == a ? function (e, t, n, r) { return ( e5(e, "handleDoubleClickOn", t, n, r) || e.someProp("handleDoubleClick", (n) => n(e, t, r)) ); } : function (e, n, r, i) { return ( e5(e, "handleTripleClickOn", n, r, i) || e.someProp("handleTripleClick", (t) => t(e, n, i)) || (function (e, n, r) { if (0 != r.button) return !1; let i = e.state.doc; if (-1 == n) return ( !!i.inlineContent && (e6( e, t.TextSelection.create(i, 0, i.content.size), "pointer", ), !0) ); let o = i.resolve(n); for (let n = o.depth + 1; n > 0; n--) { let r = n > o.depth ? o.nodeAfter : o.node(n), s = o.before(n); if (r.inlineContent) e6( e, t.TextSelection.create( i, s + 1, s + 1 + r.content.size, ), "pointer", ); else { if (!t.NodeSelection.isSelectable(r)) continue; e6(e, t.NodeSelection.create(i, s), "pointer"); } return !0; } })(e, r, i) ); })(e, d.pos, d.inside, n) ? n.preventDefault() : e1(e, "pointer")); }; class e7 { constructor(e, n, r, i) { let o, s; if ( ((this.view = e), (this.pos = n), (this.event = r), (this.flushed = i), (this.delayedSelectionSync = !1), (this.mightDrag = null), (this.startDoc = e.state.doc), (this.selectNode = !!r[e9]), (this.allowDefault = r.shiftKey), n.inside > -1) ) (o = e.state.doc.nodeAt(n.inside)), (s = n.inside); else { let t = e.state.doc.resolve(n.pos); (o = t.parent), (s = t.depth ? t.before() : 0); } const l = i ? null : r.target, a = l ? e.docView.nearestDesc(l, !0) : null; this.target = a && 1 == a.nodeDOM.nodeType ? a.nodeDOM : null; let { selection: d } = e.state; ((0 == r.button && o.type.spec.draggable && !1 !== o.type.spec.selectable) || (d instanceof t.NodeSelection && d.from <= s && d.to > s)) && (this.mightDrag = { node: o, pos: s, addAttr: !!(this.target && !this.target.draggable), setUneditable: !!( this.target && M && !this.target.hasAttribute("contentEditable") ), }), 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(() => { this.view.input.mouseDown == this && this.target.setAttribute("contentEditable", "false"); }, 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)), ), e1(e, "pointer"); } done() { 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(() => ek(this.view)), (this.view.input.mouseDown = null); } up(e) { if ((this.done(), !this.view.dom.contains(e.target))) return; let n = this.pos; if ( (this.view.state.doc != this.startDoc && (n = this.view.posAtCoords(e4(e))), this.updateAllowDefault(e), this.allowDefault || !n) ) e1(this.view, "pointer"); else { var r, i, o, s; ((r = this.view), (i = n.pos), (o = n.inside), (s = this.selectNode), e5(r, "handleClickOn", i, o, e) || r.someProp("handleClick", (t) => t(r, i, e)) || (s ? (function (e, n) { if (-1 == n) return !1; let r = e.state.selection, i, o; r instanceof t.NodeSelection && (i = r.node); let s = e.state.doc.resolve(n); for (let e = s.depth + 1; e > 0; e--) { let n = e > s.depth ? s.nodeAfter : s.node(e); if (t.NodeSelection.isSelectable(n)) { o = i && r.$from.depth > 0 && e >= r.$from.depth && s.before(r.$from.depth + 1) == r.$from.pos ? s.before(r.$from.depth) : s.before(e); break; } } return ( null != o && (e6(e, t.NodeSelection.create(e.state.doc, o), "pointer"), !0) ); })(r, o) : (function (e, n) { if (-1 == n) return !1; let r = e.state.doc.resolve(n), i = r.nodeAfter; return ( !!(i && i.isAtom && t.NodeSelection.isSelectable(i)) && (e6(e, new t.NodeSelection(r), "pointer"), !0) ); })(r, o))) ? e.preventDefault() : 0 == e.button && (this.flushed || (E && this.mightDrag && !this.mightDrag.node.isAtom) || (T && !this.view.state.selection.visible && 2 >= Math.min( Math.abs(n.pos - this.view.state.selection.from), Math.abs(n.pos - this.view.state.selection.to), ))) ? (e6( this.view, t.Selection.near(this.view.state.doc.resolve(n.pos)), "pointer", ), e.preventDefault()) : e1(this.view, "pointer"); } } move(e) { this.updateAllowDefault(e), e1(this.view, "pointer"), 0 == e.buttons && this.done(); } updateAllowDefault(e) { !this.allowDefault && (Math.abs(this.event.x - e.clientX) > 4 || Math.abs(this.event.y - e.clientY) > 4) && (this.allowDefault = !0); } } function e8(e, t) { return ( !!e.composing || (!!(E && 500 > Math.abs(t.timeStamp - e.input.compositionEndedAt)) && ((e.input.compositionEndedAt = -2e8), !0)) ); } (eQ.touchstart = (e) => { (e.input.lastTouch = Date.now()), tr(e), e1(e, "pointer"); }), (eQ.touchmove = (e) => { (e.input.lastTouch = Date.now()), e1(e, "pointer"); }), (eQ.contextmenu = (e) => tr(e)); let te = R ? 5e3 : -1; function tt(e, t) { clearTimeout(e.input.composingTimeout), t > -1 && (e.input.composingTimeout = setTimeout(() => tr(e), t)); } function tn(e) { let t; for ( e.composing && ((e.input.composing = !1), (e.input.compositionEndedAt = ((t = document.createEvent("Event")).initEvent("event", !0, !0), t.timeStamp))); e.input.compositionNodes.length > 0; ) e.input.compositionNodes.pop().markParentsDirty(); } function tr(e, t = !1) { if (!R || !(e.domObserver.flushingSoon >= 0)) { if ( (e.domObserver.forceFlush(), tn(e), t || (e.docView && e.docView.dirty)) ) { let n = ey(e), r = e.state.selection; return ( n && !n.eq(r) ? e.dispatch(e.state.tr.setSelection(n)) : (e.markCursor || t) && !r.$from.node(r.$from.sharedDepth(r.to)).inlineContent ? e.dispatch(e.state.tr.deleteSelection()) : e.updateState(e.state), !0 ); } return !1; } } (eX.compositionstart = eX.compositionupdate = (e) => { if (!e.composing) { e.domObserver.flush(); let { state: n } = e, r = n.selection.$to; if ( n.selection instanceof t.TextSelection && (n.storedMarks || (!r.textOffset && r.parentOffset && r.nodeBefore.marks.some((e) => !1 === e.type.spec.inclusive)) || (T && D && (function (e) { let { focusNode: t, focusOffset: n } = e.domSelectionRange(); if (!t || 1 != t.nodeType || n >= t.childNodes.length) return !1; let r = t.childNodes[n]; return 1 == r.nodeType && "false" == r.contentEditable; })(e))) ) (e.markCursor = e.state.storedMarks || r.marks()), tr(e, !0), (e.markCursor = null); else if ( (tr(e, !n.selection.empty), M && n.selection.empty && r.parentOffset && !r.textOffset && r.nodeBefore.marks.length) ) { let t = e.domSelectionRange(); for ( let n = t.focusNode, r = t.focusOffset; n && 1 == n.nodeType && 0 != r; ) { let t = r < 0 ? n.lastChild : n.childNodes[r - 1]; if (!t) break; if (3 == t.nodeType) { let n = e.domSelection(); n && n.collapse(t, t.nodeValue.length); break; } (n = t), (r = -1); } } e.input.composing = !0; } tt(e, te); }), (eX.compositionend = (e, t) => { e.composing && ((e.input.composing = !1), (e.input.compositionEndedAt = t.timeStamp), (e.input.compositionPendingChanges = e.domObserver.pendingRecords() .length ? e.input.compositionID : 0), (e.input.compositionNode = null), e.input.badSafariComposition ? e.domObserver.forceFlush() : e.input.compositionPendingChanges && Promise.resolve().then(() => e.domObserver.flush()), e.input.compositionID++, tt(e, 20)); }); let ti = (S && x < 15) || (O && P < 604); function to(e, t, r, i, o) { let s = eH(e, t, r, i, e.state.selection.$from); if (e.someProp("handlePaste", (t) => t(e, o, s || n.Slice.empty))) return !0; if (!s) return !1; let l = 0 == s.openStart && 0 == s.openEnd && 1 == s.content.childCount ? s.content.firstChild : null, a = l ? e.state.tr.replaceSelectionWith(l, i) : e.state.tr.replaceSelection(s); return ( e.dispatch( a.scrollIntoView().setMeta("paste", !0).setMeta("uiEvent", "paste"), ), !0 ); } function ts(e) { let t = e.getData("text/plain") || e.getData("Text"); if (t) return t; let n = e.getData("text/uri-list"); return n ? n.replace(/\r?\n/g, " ") : ""; } (eQ.copy = eX.cut = (e, t) => { let n = e.state.selection, r = "cut" == t.type; if (n.empty) return; let i = ti ? null : t.clipboardData, { dom: o, text: s } = eV(e, n.content()); i ? (t.preventDefault(), i.clearData(), i.setData("text/html", o.innerHTML), i.setData("text/plain", s)) : (function (e, t) { if (!e.dom.parentNode) return; let n = e.dom.parentNode.appendChild( document.createElement("div"), ); n.appendChild(t), (n.style.cssText = "position: fixed; left: -10000px; top: 10px"); let r = getSelection(), i = document.createRange(); i.selectNodeContents(t), e.dom.blur(), r.removeAllRanges(), r.addRange(i), setTimeout(() => { n.parentNode && n.parentNode.removeChild(n), e.focus(); }, 50); })(e, o), r && e.dispatch( e.state.tr .deleteSelection() .scrollIntoView() .setMeta("uiEvent", "cut"), ); }), (eX.paste = (e, t) => { if (e.composing && !R) return; let n = ti ? null : t.clipboardData, r = e.input.shiftKey && 45 != e.input.lastKeyCode; n && to(e, ts(n), n.getData("text/html"), r, t) ? t.preventDefault() : (function (e, t) { if (!e.dom.parentNode) return; let n = e.input.shiftKey || e.state.selection.$from.parent.type.spec.code, r = e.dom.parentNode.appendChild( document.createElement(n ? "textarea" : "div"), ); n || (r.contentEditable = "true"), (r.style.cssText = "position: fixed; left: -10000px; top: 10px"), r.focus(); let i = e.input.shiftKey && 45 != e.input.lastKeyCode; setTimeout(() => { e.focus(), r.parentNode && r.parentNode.removeChild(r), n ? to(e, r.value, null, i, t) : to(e, r.textContent, r.innerHTML, i, t); }, 50); })(e, t); }); class tl { constructor(e, t, n) { (this.slice = e), (this.move = t), (this.node = n); } } let ta = A ? "altKey" : "ctrlKey"; function td(e, t) { let n = e.someProp("dragCopies", (e) => !e(t)); return null != n ? n : !t[ta]; } for (let e in ((eQ.dragstart = (e, n) => { let r, i = e.input.mouseDown; if ((i && i.done(), !n.dataTransfer)) return; let o = e.state.selection, s = o.empty ? null : e.posAtCoords(e4(n)); if ( s && s.pos >= o.from && s.pos <= (o instanceof t.NodeSelection ? o.to - 1 : o.to) ); else if (i && i.mightDrag) r = t.NodeSelection.create(e.state.doc, i.mightDrag.pos); else if (n.target && 1 == n.target.nodeType) { let i = e.docView.nearestDesc(n.target, !0); i && i.node.type.spec.draggable && i != e.docView && (r = t.NodeSelection.create(e.state.doc, i.posBefore)); } let l = (r || e.state.selection).content(), { dom: a, text: d, slice: c } = eV(e, l); (n.dataTransfer.files.length && T && !(N > 120)) || n.dataTransfer.clearData(), n.dataTransfer.setData(ti ? "Text" : "text/html", a.innerHTML), (n.dataTransfer.effectAllowed = "copyMove"), ti || n.dataTransfer.setData("text/plain", d), (e.dragging = new tl(c, td(e, n), r)); }), (eQ.dragend = (e) => { let t = e.dragging; window.setTimeout(() => { e.dragging == t && (e.dragging = null); }, 50); }), (eX.dragover = eX.dragenter = (e, t) => t.preventDefault()), (eX.drop = (e, i) => { try { !(function (e, i, o) { if (!i.dataTransfer) return; let s = e.posAtCoords(e4(i)); if (!s) return; let l = e.state.doc.resolve(s.pos), a = o && o.slice; a ? e.someProp("transformPasted", (t) => { a = t(a, e, !1); }) : (a = eH( e, ts(i.dataTransfer), ti ? null : i.dataTransfer.getData("text/html"), !1, l, )); let d = !!(o && td(e, i)); if (e.someProp("handleDrop", (t) => t(e, i, a || n.Slice.empty, d))) return i.preventDefault(); if (!a) return; i.preventDefault(); let c = a ? (0, r.dropPoint)(e.state.doc, l.pos, a) : l.pos; null == c && (c = l.pos); let h = e.state.tr; if (d) { let { node: e } = o; e ? e.replace(h) : h.deleteSelection(); } let p = h.mapping.map(c), u = 0 == a.openStart && 0 == a.openEnd && 1 == a.content.childCount, f = h.doc; if ( (u ? h.replaceRangeWith(p, p, a.content.firstChild) : h.replaceRange(p, p, a), h.doc.eq(f)) ) return; let m = h.doc.resolve(p); if ( u && t.NodeSelection.isSelectable(a.content.firstChild) && m.nodeAfter && m.nodeAfter.sameMarkup(a.content.firstChild) ) h.setSelection(new t.NodeSelection(m)); else { let t = h.mapping.map(c); h.mapping.maps[h.mapping.maps.length - 1].forEach( (e, n, r, i) => (t = i), ), h.setSelection(eT(e, m, h.doc.resolve(t))); } e.focus(), e.dispatch(h.setMeta("uiEvent", "drop")); })(e, i, e.dragging); } finally { e.dragging = null; } }), (eQ.focus = (e) => { (e.input.lastFocus = Date.now()), e.focused || (e.domObserver.stop(), e.dom.classList.add("ProseMirror-focused"), e.domObserver.start(), (e.focused = !0), setTimeout(() => { e.docView && e.hasFocus() && !e.domObserver.currentSelection.eq(e.domSelectionRange()) && ek(e); }, 20)); }), (eQ.blur = (e, t) => { e.focused && (e.domObserver.stop(), e.dom.classList.remove("ProseMirror-focused"), e.domObserver.start(), t.relatedTarget && e.dom.contains(t.relatedTarget) && e.domObserver.currentSelection.clear(), (e.focused = !1)); }), (eQ.beforeinput = (e, t) => { if (T && R && "deleteContentBackward" == t.inputType) { e.domObserver.flushSoon(); let { domChangeCount: t } = e.input; setTimeout(() => { if ( e.input.domChangeCount != t || (e.dom.blur(), e.focus(), e.someProp("handleKeyDown", (t) => t(e, m(8, "Backspace")))) ) return; let { $cursor: n } = e.state.selection; n && n.pos > 0 && e.dispatch(e.state.tr.delete(n.pos - 1, n.pos).scrollIntoView()); }, 50); } }), eX)) eQ[e] = eX[e]; function tc(e, t) { if (e == t) return !0; for (let n in e) if (e[n] !== t[n]) return !1; for (let n in t) if (!(n in e)) return !1; return !0; } class th { constructor(e, t) { (this.toDOM = e), (this.spec = t || tg), (this.side = this.spec.side || 0); } map(e, t, n, r) { let { pos: i, deleted: o } = e.mapResult( t.from + r, this.side < 0 ? -1 : 1, ); return o ? null : new tf(i - n, i - n, this); } valid() { return !0; } eq(e) { return ( this == e || (e instanceof th && ((this.spec.key && this.spec.key == e.spec.key) || (this.toDOM == e.toDOM && tc(this.spec, e.spec)))) ); } destroy(e) { this.spec.destroy && this.spec.destroy(e); } } class tp { constructor(e, t) { (this.attrs = e), (this.spec = t || tg); } map(e, t, n, r) { let i = e.map(t.from + r, this.spec.inclusiveStart ? -1 : 1) - n, o = e.map(t.to + r, this.spec.inclusiveEnd ? 1 : -1) - n; return i >= o ? null : new tf(i, o, this); } valid(e, t) { return t.from < t.to; } eq(e) { return ( this == e || (e instanceof tp && tc(this.attrs, e.attrs) && tc(this.spec, e.spec)) ); } static is(e) { return e.type instanceof tp; } destroy() {} } class tu { constructor(e, t) { (this.attrs = e), (this.spec = t || tg); } map(e, t, n, r) { let i = e.mapResult(t.from + r, 1); if (i.deleted) return null; let o = e.mapResult(t.to + r, -1); return o.deleted || o.pos <= i.pos ? null : new tf(i.pos - n, o.pos - n, this); } valid(e, t) { let { index: n, offset: r } = e.content.findIndex(t.from), i; return ( r == t.from && !(i = e.child(n)).isText && r + i.nodeSize == t.to ); } eq(e) { return ( this == e || (e instanceof tu && tc(this.attrs, e.attrs) && tc(this.spec, e.spec)) ); } destroy() {} } class tf { constructor(e, t, n) { (this.from = e), (this.to = t), (this.type = n); } copy(e, t) { return new tf(e, t, this.type); } eq(e, t = 0) { return ( this.type.eq(e.type) && this.from + t == e.from && this.to + t == e.to ); } map(e, t, n) { return this.type.map(e, this, t, n); } static widget(e, t, n) { return new tf(e, e, new th(t, n)); } static inline(e, t, n, r) { return new tf(e, t, new tp(n, r)); } static node(e, t, n, r) { return new tf(e, t, new tu(n, r)); } get spec() { return this.type.spec; } get inline() { return this.type instanceof tp; } get widget() { return this.type instanceof th; } } let tm = [], tg = {}; class ty { constructor(e, t) { (this.local = e.length ? e : tm), (this.children = t.length ? t : tm); } static create(e, t) { return t.length ? tx(t, e, 0, tg) : tb; } find(e, t, n) { let r = []; return ( this.findInner(null == e ? 0 : e, null == t ? 1e9 : t, r, 0, n), r ); } findInner(e, t, n, r, i) { for (let o = 0; o < this.local.length; o++) { let s = this.local[o]; s.from <= t && s.to >= e && (!i || i(s.spec)) && n.push(s.copy(s.from + r, s.to + r)); } for (let o = 0; o < this.children.length; o += 3) if (this.children[o] < t && this.children[o + 1] > e) { let s = this.children[o] + 1; this.children[o + 2].findInner(e - s, t - s, n, r + s, i); } } map(e, t, n) { return this == tb || 0 == e.maps.length ? this : this.mapInner(e, t, 0, 0, n || tg); } mapInner(e, t, n, r, i) { let o; for (let s = 0; s < this.local.length; s++) { let l = this.local[s].map(e, n, r); l && l.type.valid(t, l) ? (o || (o = [])).push(l) : i.onRemove && i.onRemove(this.local[s].spec); } return this.children.length ? (function (e, t, n, r, i, o, s) { let l = e.slice(); for (let e = 0, t = o; e < n.maps.length; e++) { let r = 0; n.maps[e].forEach((e, n, i, o) => { let s = o - i - (n - e); for (let i = 0; i < l.length; i += 3) { let o = l[i + 1]; if (o < 0 || e > o + t - r) continue; let a = l[i] + t - r; n >= a ? (l[i + 1] = e <= a ? -2 : -1) : e >= t && s && ((l[i] += s), (l[i + 1] += s)); } r += s; }), (t = n.maps[e].map(t, -1)); } let a = !1; for (let t = 0; t < l.length; t += 3) if (l[t + 1] < 0) { if (-2 == l[t + 1]) { (a = !0), (l[t + 1] = -1); continue; } let d = n.map(e[t] + o), c = d - i; if (c < 0 || c >= r.content.size) { a = !0; continue; } let h = n.map(e[t + 1] + o, -1) - i, { index: p, offset: u } = r.content.findIndex(c), f = r.maybeChild(p); if (f && u == c && u + f.nodeSize == h) { let r = l[t + 2].mapInner(n, f, d + 1, e[t] + o + 1, s); r != tb ? ((l[t] = c), (l[t + 1] = h), (l[t + 2] = r)) : ((l[t + 1] = -2), (a = !0)); } else a = !0; } if (a) { let a = tx( (function (e, t, n, r, i, o, s) { for (let l = 0; l < e.length; l += 3) -1 == e[l + 1] && (function e(t, o) { for (let e = 0; e < t.local.length; e++) { let l = t.local[e].map(r, i, o); l ? n.push(l) : s.onRemove && s.onRemove(t.local[e].spec); } for (let n = 0; n < t.children.length; n += 3) e(t.children[n + 2], t.children[n] + o + 1); })(e[l + 2], t[l] + o + 1); return n; })(l, e, t, n, i, o, s), r, 0, s, ); t = a.local; for (let e = 0; e < l.length; e += 3) l[e + 1] < 0 && (l.splice(e, 3), (e -= 3)); for (let e = 0, t = 0; e < a.children.length; e += 3) { let n = a.children[e]; for (; t < l.length && l[t] < n; ) t += 3; l.splice( t, 0, a.children[e], a.children[e + 1], a.children[e + 2], ); } } return new ty(t.sort(tM), l); })(this.children, o || [], e, t, n, r, i) : o ? new ty(o.sort(tM), tm) : tb; } add(e, t) { return t.length ? this == tb ? ty.create(e, t) : this.addInner(e, t, 0) : this; } addInner(e, t, n) { let r, i = 0; e.forEach((e, o) => { let s = o + n, l; if ((l = tw(t, e, s))) { for (r || (r = this.children.slice()); i < r.length && r[i] < o; ) i += 3; r[i] == o ? (r[i + 2] = r[i + 2].addInner(e, l, s + 1)) : r.splice(i, 0, o, o + e.nodeSize, tx(l, e, s + 1, tg)), (i += 3); } }); let o = tv(i ? tS(t) : t, -n); for (let t = 0; t < o.length; t++) o[t].type.valid(e, o[t]) || o.splice(t--, 1); return new ty( o.length ? this.local.concat(o).sort(tM) : this.local, r || this.children, ); } remove(e) { return 0 == e.length || this == tb ? this : this.removeInner(e, 0); } removeInner(e, t) { let n = this.children, r = this.local; for (let r = 0; r < n.length; r += 3) { let i, o = n[r] + t, s = n[r + 1] + t; for (let t = 0, n; t < e.length; t++) (n = e[t]) && n.from > o && n.to < s && ((e[t] = null), (i || (i = [])).push(n)); if (!i) continue; n == this.children && (n = this.children.slice()); let l = n[r + 2].removeInner(i, o + 1); l != tb ? (n[r + 2] = l) : (n.splice(r, 3), (r -= 3)); } if (r.length) { for (let n = 0, i; n < e.length; n++) if ((i = e[n])) for (let e = 0; e < r.length; e++) r[e].eq(i, t) && (r == this.local && (r = this.local.slice()), r.splice(e--, 1)); } return n == this.children && r == this.local ? this : r.length || n.length ? new ty(r, n) : tb; } forChild(e, t) { let n, r; if (this == tb) return this; if (t.isLeaf) return ty.empty; for (let t = 0; t < this.children.length; t += 3) if (this.children[t] >= e) { this.children[t] == e && (n = this.children[t + 2]); break; } let i = e + 1, o = i + t.content.size; for (let e = 0; e < this.local.length; e++) { let t = this.local[e]; if (t.from < o && t.to > i && t.type instanceof tp) { let e = Math.max(i, t.from) - i, n = Math.min(o, t.to) - i; e < n && (r || (r = [])).push(t.copy(e, n)); } } if (r) { let e = new ty(r.sort(tM), tm); return n ? new tk([e, n]) : e; } return n || tb; } eq(e) { if (this == e) return !0; if ( !(e instanceof ty) || this.local.length != e.local.length || this.children.length != e.children.length ) return !1; for (let t = 0; t < this.local.length; t++) if (!this.local[t].eq(e.local[t])) return !1; for (let t = 0; t < this.children.length; t += 3) if ( this.children[t] != e.children[t] || this.children[t + 1] != e.children[t + 1] || !this.children[t + 2].eq(e.children[t + 2]) ) return !1; return !0; } locals(e) { return tC(this.localsInner(e)); } localsInner(e) { if (this == tb) return tm; if (e.inlineContent || !this.local.some(tp.is)) return this.local; let t = []; for (let e = 0; e < this.local.length; e++) this.local[e].type instanceof tp || t.push(this.local[e]); return t; } forEachSet(e) { e(this); } } (ty.empty = new ty([], [])), (ty.removeOverlap = tC); let tb = ty.empty; class tk { constructor(e) { this.members = e; } map(e, t) { let n = this.members.map((n) => n.map(e, t, tg)); return tk.from(n); } forChild(e, t) { if (t.isLeaf) return ty.empty; let n = []; for (let r = 0; r < this.members.length; r++) { let i = this.members[r].forChild(e, t); i != tb && (i instanceof tk ? (n = n.concat(i.members)) : n.push(i)); } return tk.from(n); } eq(e) { if (!(e instanceof tk) || e.members.length != this.members.length) return !1; for (let t = 0; t < this.members.length; t++) if (!this.members[t].eq(e.members[t])) return !1; return !0; } locals(e) { let t, n = !0; for (let r = 0; r < this.members.length; r++) { let i = this.members[r].localsInner(e); if (i.length) if (t) { n && ((t = t.slice()), (n = !1)); for (let e = 0; e < i.length; e++) t.push(i[e]); } else t = i; } return t ? tC(n ? t : t.sort(tM)) : tm; } static from(e) { switch (e.length) { case 0: return tb; case 1: return e[0]; default: return new tk( e.every((e) => e instanceof ty) ? e : e.reduce( (e, t) => e.concat(t instanceof ty ? t : t.members), [], ), ); } } forEachSet(e) { for (let t = 0; t < this.members.length; t++) this.members[t].forEachSet(e); } } function tv(e, t) { if (!t || !e.length) return e; let n = []; for (let r = 0; r < e.length; r++) { let i = e[r]; n.push(new tf(i.from + t, i.to + t, i.type)); } return n; } function tw(e, t, n) { if (t.isLeaf) return null; let r = n + t.nodeSize, i = null; for (let t = 0, o; t < e.length; t++) (o = e[t]) && o.from > n && o.to < r && ((i || (i = [])).push(o), (e[t] = null)); return i; } function tS(e) { let t = []; for (let n = 0; n < e.length; n++) null != e[n] && t.push(e[n]); return t; } function tx(e, t, n, r) { let i = [], o = !1; t.forEach((t, s) => { let l = tw(e, t, s + n); if (l) { o = !0; let e = tx(l, t, n + s + 1, r); e != tb && i.push(s, s + t.nodeSize, e); } }); let s = tv(o ? tS(e) : e, -n).sort(tM); for (let e = 0; e < s.length; e++) s[e].type.valid(t, s[e]) || (r.onRemove && r.onRemove(s[e].spec), s.splice(e--, 1)); return s.length || i.length ? new ty(s, i) : tb; } function tM(e, t) { return e.from - t.from || e.to - t.to; } function tC(e) { let t = e; for (let n = 0; n < t.length - 1; n++) { let r = t[n]; if (r.from != r.to) for (let i = n + 1; i < t.length; i++) { let o = t[i]; if (o.from == r.from) { o.to != r.to && (t == e && (t = e.slice()), (t[i] = o.copy(o.from, r.to)), tT(t, i + 1, o.copy(r.to, o.to))); continue; } o.from < r.to && (t == e && (t = e.slice()), (t[n] = r.copy(r.from, o.from)), tT(t, i, r.copy(o.from, r.to))); break; } } return t; } function tT(e, t, n) { for (; t < e.length && tM(n, e[t]) > 0; ) t++; e.splice(t, 0, n); } function tN(e) { let t = []; return ( e.someProp("decorations", (n) => { let r = n(e.state); r && r != tb && t.push(r); }), e.cursorWrapper && t.push(ty.create(e.state.doc, [e.cursorWrapper.deco])), tk.from(t) ); } let tE = { childList: !0, characterData: !0, characterDataOldValue: !0, attributes: !0, attributeOldValue: !0, subtree: !0, }, tO = S && x <= 11; class tA { constructor() { (this.anchorNode = null), (this.anchorOffset = 0), (this.focusNode = null), (this.focusOffset = 0); } set(e) { (this.anchorNode = e.anchorNode), (this.anchorOffset = e.anchorOffset), (this.focusNode = e.focusNode), (this.focusOffset = e.focusOffset); } clear() { this.anchorNode = this.focusNode = null; } eq(e) { return ( e.anchorNode == this.anchorNode && e.anchorOffset == this.anchorOffset && e.focusNode == this.focusNode && e.focusOffset == this.focusOffset ); } } class tD { constructor(e, t) { (this.view = e), (this.handleDOMChange = t), (this.queue = []), (this.flushingSoon = -1), (this.observer = null), (this.currentSelection = new tA()), (this.onCharData = null), (this.suppressingSelectionUpdates = !1), (this.lastChangedTextNode = null), (this.observer = window.MutationObserver && new window.MutationObserver((t) => { for (let e = 0; e < t.length; e++) this.queue.push(t[e]); S && x <= 11 && t.some( (e) => ("childList" == e.type && e.removedNodes.length) || ("characterData" == e.type && e.oldValue.length > e.target.nodeValue.length), ) ? this.flushSoon() : E && e.composing && t.some( (e) => "childList" == e.type && "TR" == e.target.nodeName, ) ? ((e.input.badSafariComposition = !0), this.flushSoon()) : this.flush(); })), tO && (this.onCharData = (e) => { this.queue.push({ target: e.target, type: "characterData", oldValue: e.prevValue, }), this.flushSoon(); }), (this.onSelectionChange = this.onSelectionChange.bind(this)); } flushSoon() { this.flushingSoon < 0 && (this.flushingSoon = window.setTimeout(() => { (this.flushingSoon = -1), this.flush(); }, 20)); } forceFlush() { this.flushingSoon > -1 && (window.clearTimeout(this.flushingSoon), (this.flushingSoon = -1), this.flush()); } start() { this.observer && (this.observer.takeRecords(), this.observer.observe(this.view.dom, tE)), this.onCharData && this.view.dom.addEventListener( "DOMCharacterDataModified", this.onCharData, ), this.connectSelection(); } stop() { if (this.observer) { let e = this.observer.takeRecords(); if (e.length) { for (let t = 0; t < e.length; t++) this.queue.push(e[t]); window.setTimeout(() => this.flush(), 20); } this.observer.disconnect(); } this.onCharData && this.view.dom.removeEventListener( "DOMCharacterDataModified", this.onCharData, ), this.disconnectSelection(); } connectSelection() { this.view.dom.ownerDocument.addEventListener( "selectionchange", this.onSelectionChange, ); } disconnectSelection() { this.view.dom.ownerDocument.removeEventListener( "selectionchange", this.onSelectionChange, ); } suppressSelectionUpdates() { (this.suppressingSelectionUpdates = !0), setTimeout(() => (this.suppressingSelectionUpdates = !1), 50); } onSelectionChange() { if (eN(this.view)) { if (this.suppressingSelectionUpdates) return ek(this.view); if (S && x <= 11 && !this.view.state.selection.empty) { let e = this.view.domSelectionRange(); if ( e.focusNode && d(e.focusNode, e.focusOffset, e.anchorNode, e.anchorOffset) ) return this.flushSoon(); } this.flush(); } } setCurSelection() { this.currentSelection.set(this.view.domSelectionRange()); } ignoreSelectionChange(e) { if (!e.focusNode) return !0; let t = new Set(), n; for (let n = e.focusNode; n; n = o(n)) t.add(n); for (let r = e.anchorNode; r; r = o(r)) if (t.has(r)) { n = r; break; } let r = n && this.view.docView.nearestDesc(n); if ( r && r.ignoreMutation({ type: "selection", target: 3 == n.nodeType ? n.parentNode : n, }) ) return this.setCurSelection(), !0; } pendingRecords() { if (this.observer) for (let e of this.observer.takeRecords()) this.queue.push(e); return this.queue; } flush() { var e; let { view: n } = this; if (!n.docView || this.flushingSoon > -1) return; let r = this.pendingRecords(); r.length && (this.queue = []); let i = n.domSelectionRange(), o = !this.suppressingSelectionUpdates && !this.currentSelection.eq(i) && eN(n) && !this.ignoreSelectionChange(i), s = -1, l = -1, a = !1, d = []; if (n.editable) for (let e = 0; e < r.length; e++) { let t = this.registerMutation(r[e], d); t && ((s = s < 0 ? t.from : Math.min(t.from, s)), (l = l < 0 ? t.to : Math.max(t.to, l)), t.typeOver && (a = !0)); } if (M && d.length) { let e = d.filter((e) => "BR" == e.nodeName); if (2 == e.length) { let [t, n] = e; t.parentNode && t.parentNode.parentNode == n.parentNode ? n.remove() : t.remove(); } else { let { focusNode: t } = this.currentSelection; for (let r of e) { let e = r.parentNode; e && "LI" == e.nodeName && (!t || (function (e, t) { for ( let n = t.parentNode; n && n != e.dom; n = n.parentNode ) { let t = e.docView.nearestDesc(n, !0); if (t && t.node.isBlock) return n; } return null; })(n, t) != e) && r.remove(); } } } else if ( (T || E) && d.some((e) => "BR" == e.nodeName) && (8 == n.input.lastKeyCode || 46 == n.input.lastKeyCode) ) { for (let e of d) if ("BR" == e.nodeName && e.parentNode) { let t = e.nextSibling; t && 1 == t.nodeType && "false" == t.contentEditable && e.parentNode.removeChild(e); } } let c = null; s < 0 && o && n.input.lastFocus > Date.now() - 200 && Math.max(n.input.lastTouch, n.input.lastClick.time) < Date.now() - 300 && f(i) && (c = ey(n)) && c.eq(t.Selection.near(n.state.doc.resolve(0), 1)) ? ((n.input.lastFocus = 0), ek(n), this.currentSelection.set(i), n.scrollToSelection()) : (s > -1 || o) && (s > -1 && (n.docView.markDirty(s, l), (e = n), !tR.has(e) && (tR.set(e, null), -1 !== ["normal", "nowrap", "pre-line"].indexOf( getComputedStyle(e.dom).whiteSpace, )) && ((e.requiresGeckoHackNode = M), tI || (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.", ), (tI = !0)))), n.input.badSafariComposition && ((n.input.badSafariComposition = !1), (function (e, t) { var n; let { focusNode: r, focusOffset: i } = e.domSelectionRange(); for (let o of t) if ( (null == (n = o.parentNode) ? void 0 : n.nodeName) == "TR" ) { let t = o.nextSibling; for (; t && "TD" != t.nodeName && "TH" != t.nodeName; ) t = t.nextSibling; if (t) { let n = t; for (;;) { let e = n.firstChild; if ( !e || 1 != e.nodeType || "false" == e.contentEditable || /^(BR|IMG)$/.test(e.nodeName) ) break; n = e; } n.insertBefore(o, n.firstChild), r == o && e.domSelection().collapse(o, i); } else o.parentNode.removeChild(o); } })(n, d)), this.handleDOMChange(s, l, a, d), n.docView && n.docView.dirty ? n.updateState(n.state) : this.currentSelection.eq(i) || ek(n), this.currentSelection.set(i)); } registerMutation(e, t) { if (t.indexOf(e.target) > -1) return null; let n = this.view.docView.nearestDesc(e.target); if ( ("attributes" == e.type && (n == this.view.docView || "contenteditable" == e.attributeName || ("style" == e.attributeName && !e.oldValue && !e.target.getAttribute("style")))) || !n || n.ignoreMutation(e) ) return null; if ("childList" == e.type) { for (let n = 0; n < e.addedNodes.length; n++) { let r = e.addedNodes[n]; t.push(r), 3 == r.nodeType && (this.lastChangedTextNode = r); } if ( n.contentDOM && n.contentDOM != n.dom && !n.contentDOM.contains(e.target) ) return { from: n.posBefore, to: n.posAfter }; let r = e.previousSibling, o = e.nextSibling; if (S && x <= 11 && e.addedNodes.length) for (let t = 0; t < e.addedNodes.length; t++) { let { previousSibling: n, nextSibling: i } = e.addedNodes[t]; (!n || 0 > Array.prototype.indexOf.call(e.addedNodes, n)) && (r = n), (!i || 0 > Array.prototype.indexOf.call(e.addedNodes, i)) && (o = i); } let s = r && r.parentNode == e.target ? i(r) + 1 : 0, l = n.localPosFromDOM(e.target, s, -1), a = o && o.parentNode == e.target ? i(o) : e.target.childNodes.length; return { from: l, to: n.localPosFromDOM(e.target, a, 1) }; } return "attributes" == e.type ? { from: n.posAtStart - n.border, to: n.posAtEnd + n.border } : ((this.lastChangedTextNode = e.target), { from: n.posAtStart, to: n.posAtEnd, typeOver: e.target.nodeValue == e.oldValue, }); } } let tR = new WeakMap(), tI = !1; function tP(e, t) { let n = t.startContainer, r = t.startOffset, i = t.endContainer, o = t.endOffset, s = e.domAtPos(e.state.selection.anchor); return ( d(s.node, s.offset, i, o) && ([n, r, i, o] = [i, o, n, r]), { anchorNode: n, anchorOffset: r, focusNode: i, focusOffset: o } ); } function tL(e) { let t = e.pmViewDesc; if (t) return t.parseRule(); if ("BR" == e.nodeName && e.parentNode) { if (E && /^(ul|ol)$/i.test(e.parentNode.nodeName)) { let e = document.createElement("div"); return e.appendChild(document.createElement("li")), { skip: e }; } else if ( e.parentNode.lastChild == e || (E && /^(tr|table)$/i.test(e.parentNode.nodeName)) ) return { ignore: !0 }; } else if ("IMG" == e.nodeName && e.getAttribute("mark-placeholder")) return { ignore: !0 }; return null; } let tz = /^(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; function tB(e, t, n) { return Math.max(n.anchor, n.head) > t.content.size ? null : eT(e, t.resolve(n.anchor), t.resolve(n.head)); } function t$(e, t, n) { let r = e.depth, i = t ? e.end() : e.pos; for (; r > 0 && (t || e.indexAfter(r) == e.node(r).childCount); ) r--, i++, (t = !1); if (n) { let t = e.node(r).maybeChild(e.indexAfter(r)); for (; t && !t.isLeaf; ) (t = t.firstChild), i++; } return i; } function tj(e) { if (2 != e.length) return !1; let t = e.charCodeAt(0), n = e.charCodeAt(1); return t >= 56320 && t <= 57343 && n >= 55296 && n <= 56319; } class tF { constructor(e, r) { (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 e0()), (this.prevDirectPlugins = []), (this.pluginViews = []), (this.requiresGeckoHackNode = !1), (this.dragging = null), (this._props = r), (this.state = r.state), (this.directPlugins = r.plugins || []), this.directPlugins.forEach(tq), (this.dispatch = this.dispatch.bind(this)), (this.dom = (e && e.mount) || document.createElement("div")), e && (e.appendChild ? e.appendChild(this.dom) : "function" == typeof e ? e(this.dom) : e.mount && (this.mounted = !0)), (this.editable = tW(this)), tH(this), (this.nodeViews = t_(this)), (this.docView = er( this.state.doc, tV(this), tN(this), this.dom, this, )), (this.domObserver = new tD(this, (e, r, i, o) => (function (e, r, i, o, s) { let l, a, d, c = e.input.compositionPendingChanges || (e.composing ? e.input.compositionID : 0); if (((e.input.compositionPendingChanges = 0), r < 0)) { let t = e.input.lastSelectionTime > Date.now() - 50 ? e.input.lastSelectionOrigin : null, n = ey(e, t); if (n && !e.state.selection.eq(n)) { if ( T && R && 13 === e.input.lastKeyCode && Date.now() - 100 < e.input.lastKeyCodeTime && e.someProp("handleKeyDown", (t) => t(e, m(13, "Enter"))) ) return; let r = e.state.tr.setSelection(n); "pointer" == t ? r.setMeta("pointer", !0) : "key" == t && r.scrollIntoView(), c && r.setMeta("composition", c), e.dispatch(r); } return; } let h = e.state.doc.resolve(r), p = h.sharedDepth(i); (r = h.before(p + 1)), (i = e.state.doc.resolve(i).after(p + 1)); let u = e.state.selection, g = (function (e, t, r) { let i, { node: o, fromOffset: s, toOffset: l, from: a, to: d, } = e.docView.parseRange(t, r), c = e.domSelectionRange(), h = c.anchorNode; if ( (h && e.dom.contains(1 == h.nodeType ? h : h.parentNode) && ((i = [{ node: h, offset: c.anchorOffset }]), f(c) || i.push({ node: c.focusNode, offset: c.focusOffset })), T && 8 === e.input.lastKeyCode) ) for (let e = l; e > s; e--) { let t = o.childNodes[e - 1], n = t.pmViewDesc; if ("BR" == t.nodeName && !n) { l = e; break; } if (!n || n.size) break; } let p = e.state.doc, u = e.someProp("domParser") || n.DOMParser.fromSchema(e.state.schema), m = p.resolve(a), g = null, y = u.parse(o, { topNode: m.parent, topMatch: m.parent.contentMatchAt(m.index()), topOpen: !0, from: s, to: l, preserveWhitespace: "pre" != m.parent.type.whitespace || "full", findPositions: i, ruleFromNode: tL, context: m, }); if (i && null != i[0].pos) { let e = i[0].pos, t = i[1] && i[1].pos; null == t && (t = e), (g = { anchor: e + a, head: t + a }); } return { doc: y, sel: g, from: a, to: d }; })(e, r, i), y = e.state.doc, b = y.slice(g.from, g.to); 8 === e.input.lastKeyCode && Date.now() - 100 < e.input.lastKeyCodeTime ? ((l = e.state.selection.to), (a = "end")) : ((l = e.state.selection.from), (a = "start")), (e.input.lastKeyCode = null); let k = (function (e, t, n, r, i) { let o = e.findDiffStart(t, n); if (null == o) return null; let { a: s, b: l } = e.findDiffEnd(t, n + e.size, n + t.size); if ("end" == i) { let e = Math.max(0, o - Math.min(s, l)); r -= s + e - o; } if (s < o && e.size < t.size) { let e = r <= o && r >= s ? o - r : 0; (o -= e) && o < t.size && tj(t.textBetween(o - 1, o + 1)) && (o += e ? 1 : -1), (l = o + (l - s)), (s = o); } else if (l < o) { let t = r <= o && r >= l ? o - r : 0; (o -= t) && o < e.size && tj(e.textBetween(o - 1, o + 1)) && (o += t ? 1 : -1), (s = o + (s - l)), (l = o); } return { start: o, endA: s, endB: l }; })(b.content, g.doc.content, g.from, l, a); if ( (k && e.input.domChangeCount++, ((O && e.input.lastIOSEnter > Date.now() - 225) || R) && s.some((e) => 1 == e.nodeType && !tz.test(e.nodeName)) && (!k || k.endA >= k.endB) && e.someProp("handleKeyDown", (t) => t(e, m(13, "Enter")))) ) { e.input.lastIOSEnter = 0; return; } if (!k) if ( o && u instanceof t.TextSelection && !u.empty && u.$head.sameParent(u.$anchor) && !e.composing && !(g.sel && g.sel.anchor != g.sel.head) ) k = { start: u.from, endA: u.to, endB: u.to }; else { if (g.sel) { let t = tB(e, e.state.doc, g.sel); if (t && !t.eq(e.state.selection)) { let n = e.state.tr.setSelection(t); c && n.setMeta("composition", c), e.dispatch(n); } } return; } e.state.selection.from < e.state.selection.to && k.start == k.endB && e.state.selection instanceof t.TextSelection && (k.start > e.state.selection.from && k.start <= e.state.selection.from + 2 && e.state.selection.from >= g.from ? (k.start = e.state.selection.from) : k.endA < e.state.selection.to && k.endA >= e.state.selection.to - 2 && e.state.selection.to <= g.to && ((k.endB += e.state.selection.to - k.endA), (k.endA = e.state.selection.to))), S && x <= 11 && k.endB == k.start + 1 && k.endA == k.start && k.start > g.from && "  " == g.doc.textBetween( k.start - g.from - 1, k.start - g.from + 1, ) && (k.start--, k.endA--, k.endB--); let v = g.doc.resolveNoCache(k.start - g.from), w = g.doc.resolveNoCache(k.endB - g.from), M = y.resolve(k.start), C = v.sameParent(w) && v.parent.inlineContent && M.end() >= k.endA; if ( ((O && e.input.lastIOSEnter > Date.now() - 225 && (!C || s.some((e) => "DIV" == e.nodeName || "P" == e.nodeName))) || (!C && v.pos < g.doc.content.size && (!v.sameParent(w) || !v.parent.inlineContent) && v.pos < w.pos && !/\S/.test(g.doc.textBetween(v.pos, w.pos, "", "")))) && e.someProp("handleKeyDown", (t) => t(e, m(13, "Enter"))) ) { e.input.lastIOSEnter = 0; return; } if ( e.state.selection.anchor > k.start && (function (e, t, n, r, i) { if (n - t <= i.pos - r.pos || t$(r, !0, !1) < i.pos) return !1; let o = e.resolve(t); if (!r.parent.isTextblock) { let e = o.nodeAfter; return null != e && n == t + e.nodeSize; } if ( o.parentOffset < o.parent.content.size || !o.parent.isTextblock ) return !1; let s = e.resolve(t$(o, !0, !0)); return ( !( !s.parent.isTextblock || s.pos > n || t$(s, !0, !1) < n ) && r.parent.content.cut(r.parentOffset).eq(s.parent.content) ); })(y, k.start, k.endA, v, w) && e.someProp("handleKeyDown", (t) => t(e, m(8, "Backspace"))) ) { R && T && e.domObserver.suppressSelectionUpdates(); return; } T && k.endB == k.start && (e.input.lastChromeDelete = Date.now()), R && !C && v.start() != w.start() && 0 == w.parentOffset && v.depth == w.depth && g.sel && g.sel.anchor == g.sel.head && g.sel.head == k.endA && ((k.endB -= 2), (w = g.doc.resolveNoCache(k.endB - g.from)), setTimeout(() => { e.someProp("handleKeyDown", function (t) { return t(e, m(13, "Enter")); }); }, 20)); let N = k.start, E = k.endA, A = (t) => { let n = t || e.state.tr.replace( N, E, g.doc.slice(k.start - g.from, k.endB - g.from), ); if (g.sel) { let t = tB(e, n.doc, g.sel); t && !( (T && e.composing && t.empty && (k.start != k.endB || e.input.lastChromeDelete < Date.now() - 100) && (t.head == N || t.head == n.mapping.map(E) - 1)) || (S && t.empty && t.head == N) ) && n.setSelection(t); } return c && n.setMeta("composition", c), n.scrollIntoView(); }; if (C) if (v.pos == w.pos) { S && x <= 11 && 0 == v.parentOffset && (e.domObserver.suppressSelectionUpdates(), setTimeout(() => ek(e), 20)); let t = A(e.state.tr.delete(N, E)), n = y.resolve(k.start).marksAcross(y.resolve(k.endA)); n && t.ensureMarks(n), e.dispatch(t); } else if ( k.endA == k.endB && (d = (function (e, t) { let r = e.firstChild.marks, i = t.firstChild.marks, o = r, s = i, l, a, d; for (let e = 0; e < i.length; e++) o = i[e].removeFromSet(o); for (let e = 0; e < r.length; e++) s = r[e].removeFromSet(s); if (1 == o.length && 0 == s.length) (a = o[0]), (l = "add"), (d = (e) => e.mark(a.addToSet(e.marks))); else { if (0 != o.length || 1 != s.length) return null; (a = s[0]), (l = "remove"), (d = (e) => e.mark(a.removeFromSet(e.marks))); } let c = []; for (let e = 0; e < t.childCount; e++) c.push(d(t.child(e))); if (n.Fragment.from(c).eq(e)) return { mark: a, type: l }; })( v.parent.content.cut(v.parentOffset, w.parentOffset), M.parent.content.cut(M.parentOffset, k.endA - M.start()), )) ) { let t = A(e.state.tr); "add" == d.type ? t.addMark(N, E, d.mark) : t.removeMark(N, E, d.mark), e.dispatch(t); } else if ( v.parent.child(v.index()).isText && v.index() == w.index() - !w.textOffset ) { let t = v.parent.textBetween(v.parentOffset, w.parentOffset), n = () => A(e.state.tr.insertText(t, N, E)); e.someProp("handleTextInput", (r) => r(e, N, E, t, n)) || e.dispatch(n()); } else e.dispatch(A()); else e.dispatch(A()); })(this, e, r, i, o), )), this.domObserver.start(), (function (e) { for (let t in eQ) { let n = eQ[t]; e.dom.addEventListener( t, (e.input.eventHandlers[t] = (t) => { !(function (e, t) { if (!t.bubbles) return !0; if (t.defaultPrevented) return !1; for (let n = t.target; n != e.dom; n = n.parentNode) if ( !n || 11 == n.nodeType || (n.pmViewDesc && n.pmViewDesc.stopEvent(t)) ) return !1; return !0; })(e, t) || e3(e, t) || (!e.editable && t.type in eX) || n(e, t); }), eZ[t] ? { passive: !0 } : void 0, ); } E && e.dom.addEventListener("input", () => null), e2(e); })(this), this.updatePluginViews(); } get composing() { return this.input.composing; } get props() { if (this._props.state != this.state) { let e = this._props; for (let t in ((this._props = {}), e)) this._props[t] = e[t]; this._props.state = this.state; } return this._props; } update(e) { e.handleDOMEvents != this._props.handleDOMEvents && e2(this); let t = this._props; (this._props = e), e.plugins && (e.plugins.forEach(tq), (this.directPlugins = e.plugins)), this.updateStateInner(e.state, t); } setProps(e) { let t = {}; for (let e in this._props) t[e] = this._props[e]; for (let n in ((t.state = this.state), e)) t[n] = e[n]; this.update(t); } updateState(e) { this.updateStateInner(e, this._props); } updateStateInner(e, t) { var n, r, o; let s = this.state, l = !1, a = !1; e.storedMarks && this.composing && (tn(this), (a = !0)), (this.state = e); let c = s.plugins != e.plugins || this._props.plugins != t.plugins; if ( c || this._props.plugins != t.plugins || this._props.nodeViews != t.nodeViews ) { let e = t_(this); (function (e, t) { let n = 0, r = 0; for (let r in e) { if (e[r] != t[r]) return !0; n++; } for (let e in t) r++; return n != r; })(e, this.nodeViews) && ((this.nodeViews = e), (l = !0)); } (c || t.handleDOMEvents != this._props.handleDOMEvents) && e2(this), (this.editable = tW(this)), tH(this); let h = tN(this), f = tV(this), m = s.plugins == e.plugins || s.doc.eq(e.doc) ? e.scrollToSelection > s.scrollToSelection ? "to selection" : "preserve" : "reset", g = l || !this.docView.matchesNode(e.doc, f, h); (g || !e.selection.eq(s.selection)) && (a = !0); let y = "preserve" == m && a && null == this.dom.style.overflowAnchor && (function (e) { let t, n, r = e.dom.getBoundingClientRect(), i = Math.max(0, r.top); for ( let o = (r.left + r.right) / 2, s = i + 1; s < Math.min(innerHeight, r.bottom); s += 5 ) { let r = e.root.elementFromPoint(o, s); if (!r || r == e.dom || !e.dom.contains(r)) continue; let l = r.getBoundingClientRect(); if (l.top >= i - 20) { (t = r), (n = l.top); break; } } return { refDOM: t, refTop: n, stack: B(e.dom) }; })(this); if (a) { let t, n, a; this.domObserver.stop(); let c = g && (S || T) && !this.composing && !s.selection.empty && !e.selection.empty && ((r = s.selection), (o = e.selection), (a = Math.min( r.$anchor.sharedDepth(r.head), o.$anchor.sharedDepth(o.head), )), r.$anchor.start(a) != o.$anchor.start(a)); if (g) { let t = T ? (this.trackWrites = this.domSelectionRange().focusNode) : null; this.composing && (this.input.compositionNode = (function (e) { let t = e.domSelectionRange(); if (!t.focusNode) return null; let n = (function (e, t) { for (;;) { if (3 == e.nodeType && t) return e; if (1 == e.nodeType && t > 0) { if ("false" == e.contentEditable) return null; t = p((e = e.childNodes[t - 1])); } else { if (!e.parentNode || u(e)) return null; (t = i(e)), (e = e.parentNode); } } })(t.focusNode, t.focusOffset), r = (function (e, t) { for (;;) { if (3 == e.nodeType && t < e.nodeValue.length) return e; if (1 == e.nodeType && t < e.childNodes.length) { if ("false" == e.contentEditable) return null; (e = e.childNodes[t]), (t = 0); } else { if (!e.parentNode || u(e)) return null; (t = i(e) + 1), (e = e.parentNode); } } })(t.focusNode, t.focusOffset); if (n && r && n != r) { let t = r.pmViewDesc, i = e.domObserver.lastChangedTextNode; if (n == i || r == i) return i; if (!t || !t.isText(r.nodeValue)) return r; if (e.input.compositionNode == r) { let e = n.pmViewDesc; if (!(!e || !e.isText(n.nodeValue))) return r; } } return n || r; })(this)), (l || !this.docView.update(e.doc, f, h, this)) && (this.docView.updateOuterDeco(f), this.docView.destroy(), (this.docView = er(e.doc, f, h, this.dom, this))), !t || (this.trackWrites && this.dom.contains(this.trackWrites)) || (c = !0); } c || !( this.input.mouseDown && this.domObserver.currentSelection.eq(this.domSelectionRange()) && ((t = this.docView.domFromPos(this.state.selection.anchor, 0)), (n = this.domSelectionRange()), d(t.node, t.offset, n.anchorNode, n.anchorOffset)) ) ? ek(this, c) : (eM(this, e.selection), this.domObserver.setCurSelection()), this.domObserver.start(); } this.updatePluginViews(s), (null == (n = this.dragging) ? void 0 : n.node) && !s.doc.eq(e.doc) && this.updateDraggedNode(this.dragging, s), "reset" == m ? (this.dom.scrollTop = 0) : "to selection" == m ? this.scrollToSelection() : y && (function ({ refDOM: e, refTop: t, stack: n }) { let r = e ? e.getBoundingClientRect().top : 0; $(n, 0 == r ? 0 : r - t); })(y); } scrollToSelection() { let e = this.domSelectionRange().focusNode; if (e && this.dom.contains(1 == e.nodeType ? e : e.parentNode)) if (this.someProp("handleScrollToSelection", (e) => e(this))); else if (this.state.selection instanceof t.NodeSelection) { let t = this.docView.domAfterPos(this.state.selection.from); 1 == t.nodeType && z(this, t.getBoundingClientRect(), e); } else z(this, this.coordsAtPos(this.state.selection.head, 1), e); } destroyPluginViews() { let e; for (; (e = this.pluginViews.pop()); ) e.destroy && e.destroy(); } updatePluginViews(e) { if ( e && e.plugins == this.state.plugins && this.directPlugins == this.prevDirectPlugins ) for (let t = 0; t < this.pluginViews.length; t++) { let n = this.pluginViews[t]; n.update && n.update(this, e); } else { (this.prevDirectPlugins = this.directPlugins), this.destroyPluginViews(); for (let e = 0; e < this.directPlugins.length; e++) { let t = this.directPlugins[e]; t.spec.view && this.pluginViews.push(t.spec.view(this)); } for (let e = 0; e < this.state.plugins.length; e++) { let t = this.state.plugins[e]; t.spec.view && this.pluginViews.push(t.spec.view(this)); } } } updateDraggedNode(e, n) { let r = e.node, i = -1; if (this.state.doc.nodeAt(r.from) == r.node) i = r.from; else { let e = r.from + (this.state.doc.content.size - n.doc.content.size); (e > 0 && this.state.doc.nodeAt(e)) == r.node && (i = e); } this.dragging = new tl( e.slice, e.move, i < 0 ? void 0 : t.NodeSelection.create(this.state.doc, i), ); } someProp(e, t) { let n = this._props && this._props[e], r; if (null != n && (r = t ? t(n) : n)) return r; for (let n = 0; n < this.directPlugins.length; n++) { let i = this.directPlugins[n].props[e]; if (null != i && (r = t ? t(i) : i)) return r; } let i = this.state.plugins; if (i) for (let n = 0; n < i.length; n++) { let o = i[n].props[e]; if (null != o && (r = t ? t(o) : o)) return r; } } hasFocus() { if (S) { let e = this.root.activeElement; if (e == this.dom) return !0; if (!e || !this.dom.contains(e)) return !1; for (; e && this.dom != e && this.dom.contains(e); ) { if ("false" == e.contentEditable) return !1; e = e.parentElement; } return !0; } return this.root.activeElement == this.dom; } focus() { this.domObserver.stop(), this.editable && (function (e) { if (e.setActive) return e.setActive(); if (j) return e.focus(j); let t = B(e); e.focus( null == j ? { get preventScroll() { return (j = { preventScroll: !0 }), !0; }, } : void 0, ), j || ((j = !1), $(t, 0)); })(this.dom), ek(this), this.domObserver.start(); } get root() { let e = this._root; if (null == e) { for (let e = this.dom.parentNode; e; e = e.parentNode) if (9 == e.nodeType || (11 == e.nodeType && e.host)) return ( e.getSelection || (Object.getPrototypeOf(e).getSelection = () => e.ownerDocument.getSelection()), (this._root = e) ); } return e || document; } updateRoot() { this._root = null; } posAtCoords(e) { return (function (e, t) { var n; let r, i, s = e.dom.ownerDocument, a, d = 0, c = (function (e, t, n) { if (e.caretPositionFromPoint) try { let r = e.caretPositionFromPoint(t, n); if (r) return { node: r.offsetNode, offset: Math.min(p(r.offsetNode), r.offset), }; } catch (e) {} if (e.caretRangeFromPoint) { let r = e.caretRangeFromPoint(t, n); if (r) return { node: r.startContainer, offset: Math.min(p(r.startContainer), r.startOffset), }; } })(s, t.left, t.top); c && ({ node: a, offset: d } = c); let h = (e.root.elementFromPoint ? e.root : s).elementFromPoint( t.left, t.top, ); if (!h || !e.dom.contains(1 != h.nodeType ? h.parentNode : h)) { let n = e.dom.getBoundingClientRect(); if ( !F(t, n) || !(h = (function e(t, n, r) { let i = t.childNodes.length; if (i && r.top < r.bottom) for ( let o = Math.max( 0, Math.min( i - 1, Math.floor( (i * (n.top - r.top)) / (r.bottom - r.top), ) - 2, ), ), s = o; ; ) { let r = t.childNodes[s]; if (1 == r.nodeType) { let t = r.getClientRects(); for (let i = 0; i < t.length; i++) { let o = t[i]; if (F(n, o)) return e(r, n, o); } } if ((s = (s + 1) % i) == o) break; } return t; })(e.dom, t, n)) ) return null; } if (E) for (let e = h; a && e; e = o(e)) e.draggable && (a = void 0); if ( ((h = (r = (n = h).parentNode) && /^li$/i.test(r.nodeName) && t.left < n.getBoundingClientRect().left ? r : n), a) ) { let n; if ( M && 1 == a.nodeType && (d = Math.min(d, a.childNodes.length)) < a.childNodes.length ) { let e = a.childNodes[d], n; "IMG" == e.nodeName && (n = e.getBoundingClientRect()).right <= t.left && n.bottom > t.top && d++; } I && d && 1 == a.nodeType && 1 == (n = a.childNodes[d - 1]).nodeType && "false" == n.contentEditable && n.getBoundingClientRect().top >= t.top && d--, a == e.dom && d == a.childNodes.length - 1 && 1 == a.lastChild.nodeType && t.top > a.lastChild.getBoundingClientRect().bottom ? (i = e.state.doc.content.size) : (0 == d || 1 != a.nodeType || "BR" != a.childNodes[d - 1].nodeName) && (i = (function (e, t, n, r) { let i = -1; for (let n = t, o = !1; n != e.dom; ) { let t = e.docView.nearestDesc(n, !0), s; if (!t) return null; if ( 1 == t.dom.nodeType && ((t.node.isBlock && t.parent) || !t.contentDOM) && ((s = t.dom.getBoundingClientRect()).width || s.height) && (t.node.isBlock && t.parent && !/^T(R|BODY|HEAD|FOOT)$/.test(t.dom.nodeName) && ((!o && s.left > r.left) || s.top > r.top ? (i = t.posBefore) : ((!o && s.right < r.left) || s.bottom < r.top) && (i = t.posAfter), (o = !0)), !t.contentDOM && i < 0 && !t.node.isText) ) return ( t.node.isBlock ? r.top < (s.top + s.bottom) / 2 : r.left < (s.left + s.right) / 2 ) ? t.posBefore : t.posAfter; n = t.dom.parentNode; } return i > -1 ? i : e.docView.posFromDOM(t, n, -1); })(e, a, d, t)); } null == i && (i = (function (e, t, n) { let { node: r, offset: i } = (function e(t, n) { let r, i, o, s = 2e8, a, d = 0, c = n.top, h = n.top; for (let e = t.firstChild, p = 0; e; e = e.nextSibling, p++) { let t; if (1 == e.nodeType) t = e.getClientRects(); else { if (3 != e.nodeType) continue; t = l(e).getClientRects(); } for (let l = 0; l < t.length; l++) { let u = t[l]; if (u.top <= c && u.bottom >= h) { (c = Math.max(u.bottom, c)), (h = Math.min(u.top, h)); let t = u.left > n.left ? u.left - n.left : u.right < n.left ? n.left - u.right : 0; if (t < s) { (o = e), (s = t), (a = t && 3 == o.nodeType ? { left: u.right < n.left ? u.right : u.left, top: n.top, } : n), 1 == e.nodeType && t && (d = p + +(n.left >= (u.left + u.right) / 2)); continue; } } else u.top > n.top && !r && u.left <= n.left && u.right >= n.left && ((r = e), (i = { left: Math.max(u.left, Math.min(u.right, n.left)), top: u.top, })); !o && ((n.left >= u.right && n.top >= u.top) || (n.left >= u.left && n.top >= u.bottom)) && (d = p + 1); } } return (!o && r && ((o = r), (a = i), (s = 0)), o && 3 == o.nodeType) ? (function (e, t) { let n = e.nodeValue.length, r = document.createRange(), i; for (let o = 0; o < n; o++) { r.setEnd(e, o + 1), r.setStart(e, o); let n = H(r, 1); if (n.top != n.bottom && F(t, n)) { i = { node: e, offset: o + +(t.left >= (n.left + n.right) / 2), }; break; } } return r.detach(), i || { node: e, offset: 0 }; })(o, a) : !o || (s && 1 == o.nodeType) ? { node: t, offset: d } : e(o, a); })(t, n), o = -1; if (1 == r.nodeType && !r.firstChild) { let e = r.getBoundingClientRect(); o = e.left != e.right && n.left > (e.left + e.right) / 2 ? 1 : -1; } return e.docView.posFromDOM(r, i, o); })(e, h, t)); let u = e.docView.nearestDesc(h, !0); return { pos: i, inside: u ? u.posAtStart - u.border : -1 }; })(this, e); } coordsAtPos(e, t = 1) { return _(this, e, t); } domAtPos(e, t = 0) { return this.docView.domFromPos(e, t); } nodeDOM(e) { let t = this.docView.descAt(e); return t ? t.nodeDOM : null; } posAtDOM(e, t, n = -1) { let r = this.docView.posFromDOM(e, t, n); if (null == r) throw RangeError("DOM position not inside the editor"); return r; } endOfTextblock(e, t) { return (function (e, t, n) { let r, i; return G == t && Y == n ? Q : ((G = t), (Y = n), (Q = "up" == n || "down" == n ? ((r = t.selection), (i = "up" == n ? r.$from : r.$to), U(e, t, () => { let { node: t } = e.docView.domFromPos( i.pos, "up" == n ? -1 : 1, ); for (;;) { let n = e.docView.nearestDesc(t, !0); if (!n) break; if (n.node.isBlock) { t = n.contentDOM || n.dom; break; } t = n.dom.parentNode; } let r = _(e, i.pos, 1); for (let e = t.firstChild; e; e = e.nextSibling) { let t; if (1 == e.nodeType) t = e.getClientRects(); else { if (3 != e.nodeType) continue; t = l(e, 0, e.nodeValue.length).getClientRects(); } for (let e = 0; e < t.length; e++) { let i = t[e]; if ( i.bottom > i.top + 1 && ("up" == n ? r.top - i.top > (i.bottom - r.top) * 2 : i.bottom - r.bottom > (r.bottom - i.top) * 2) ) return !1; } } return !0; })) : (function (e, t, n) { let { $head: r } = t.selection; if (!r.parent.isTextblock) return !1; let i = r.parentOffset, o = i == r.parent.content.size, s = e.domSelection(); return s ? J.test(r.parent.textContent) && s.modify ? U(e, t, () => { let { focusNode: t, focusOffset: i, anchorNode: o, anchorOffset: l, } = e.domSelectionRange(), a = s.caretBidiLevel; s.modify("move", n, "character"); let d = r.depth ? e.docView.domAfterPos(r.before()) : e.dom, { focusNode: c, focusOffset: h } = e.domSelectionRange(), p = (c && !d.contains( 1 == c.nodeType ? c : c.parentNode, )) || (t == c && i == h); try { s.collapse(o, l), t && (t != o || i != l) && s.extend && s.extend(t, i); } catch (e) {} return null != a && (s.caretBidiLevel = a), p; }) : "left" == n || "backward" == n ? !i : o : r.pos == r.start() || r.pos == r.end(); })(e, t, n))); })(this, t || this.state, e); } pasteHTML(e, t) { return to(this, "", e, !1, t || new ClipboardEvent("paste")); } pasteText(e, t) { return to(this, e, null, !0, t || new ClipboardEvent("paste")); } serializeForClipboard(e) { return eV(this, e); } destroy() { if (this.docView) { for (let e in (this.domObserver.stop(), this.input.eventHandlers)) this.dom.removeEventListener(e, this.input.eventHandlers[e]); clearTimeout(this.input.composingTimeout), clearTimeout(this.input.lastIOSEnterFallbackTimeout), this.destroyPluginViews(), this.mounted ? (this.docView.update(this.state.doc, [], tN(this), this), (this.dom.textContent = "")) : this.dom.parentNode && this.dom.parentNode.removeChild(this.dom), this.docView.destroy(), (this.docView = null), a(); } } get isDestroyed() { return null == this.docView; } dispatchEvent(e) { !e3(this, e) && eQ[e.type] && (this.editable || !(e.type in eX)) && eQ[e.type](this, e); } domSelectionRange() { let e = this.domSelection(); return e ? (E && 11 === this.root.nodeType && (function (e) { let t = e.activeElement; for (; t && t.shadowRoot; ) t = t.shadowRoot.activeElement; return t; })(this.dom.ownerDocument) == this.dom && (function (e, t) { let n; if (t.getComposedRanges) { let n = t.getComposedRanges(e.root)[0]; if (n) return tP(e, n); } function r(e) { e.preventDefault(), e.stopImmediatePropagation(), (n = e.getTargetRanges()[0]); } return ( e.dom.addEventListener("beforeinput", r, !0), document.execCommand("indent"), e.dom.removeEventListener("beforeinput", r, !0), n ? tP(e, n) : null ); })(this, e)) || e : { focusNode: null, focusOffset: 0, anchorNode: null, anchorOffset: 0, }; } domSelection() { return this.root.getSelection(); } } function tV(e) { let t = Object.create(null); return ( (t.class = "ProseMirror"), (t.contenteditable = String(e.editable)), e.someProp("attributes", (n) => { if (("function" == typeof n && (n = n(e.state)), n)) for (let e in n) "class" == e ? (t.class += " " + n[e]) : "style" == e ? (t.style = (t.style ? t.style + ";" : "") + n[e]) : t[e] || "contenteditable" == e || "nodeName" == e || (t[e] = String(n[e])); }), t.translate || (t.translate = "no"), [tf.node(0, e.state.doc.content.size, t)] ); } function tH(e) { if (e.markCursor) { let t = document.createElement("img"); (t.className = "ProseMirror-separator"), t.setAttribute("mark-placeholder", "true"), t.setAttribute("alt", ""), (e.cursorWrapper = { dom: t, deco: tf.widget(e.state.selection.from, t, { raw: !0, marks: e.markCursor, }), }); } else e.cursorWrapper = null; } function tW(e) { return !e.someProp("editable", (t) => !1 === t(e.state)); } function t_(e) { let t = Object.create(null); function n(e) { for (let n in e) Object.prototype.hasOwnProperty.call(t, n) || (t[n] = e[n]); } return e.someProp("nodeViews", n), e.someProp("markViews", n), t; } function tq(e) { if (e.spec.state || e.spec.filterTransaction || e.spec.appendTransaction) throw RangeError( "Plugins passed directly to the view must not have a state component", ); } (tF.prototype.dispatch = function (e) { let t = this._props.dispatchTransaction; t ? t.call(this, e) : this.updateState(this.state.apply(e)); }), e.s([ "Decoration", () => tf, "DecorationSet", () => ty, "EditorView", () => tF, ]); }; export default moduleFactory;