/*!
Copyright (c) 2026 Lenovo SSG BASD. All rights reserved.
@license Proprietary

This software is the confidential and proprietary property of Lenovo SSG BASD.
You shall not disclose such Confidential Information and shall use it only in
accordance with the terms of the license agreement.

--- Build Info ---
Version: 1.1.1
Build Time: 2026/2/26 17:21:00
Build Commit: 81e556ed827e2f043668506dae6fae8dbb9ef395
*/
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../prosemirror-state/dist/index.js"),t=require("../../prosemirror-model/dist/index.js"),n=require("../../prosemirror-transform/dist/index.js"),o=function(e){for(var t=0;;t++)if(!(e=e.previousSibling))return t},i=function(e){let t=e.assignedSlot||e.parentNode;return t&&11==t.nodeType?t.host:t};let r=null;const s=function(e,t,n){let o=r||(r=document.createRange());return o.setEnd(e,null==n?e.nodeValue.length:n),o.setStart(e,t||0),o},l=function(e,t,n,o){return n&&(a(e,t,n,o,-1)||a(e,t,n,o,1))},d=/^(img|br|input|textarea|hr)$/i;function a(e,t,n,i,r){for(var s;;){if(e==n&&t==i)return!0;if(t==(r<0?0:c(e))){let n=e.parentNode;if(!n||1!=n.nodeType||h(e)||d.test(e.nodeName)||"false"==e.contentEditable)return!1;t=o(e)+(r<0?0:1),e=n}else{if(1!=e.nodeType)return!1;{let n=e.childNodes[t+(r<0?-1:0)];if(1==n.nodeType&&"false"==n.contentEditable){if(!(null===(s=n.pmViewDesc)||void 0===s?void 0:s.ignoreForSelection))return!1;t+=r}else e=n,t=r<0?c(e):0}}}}function c(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function h(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)}const f=function(e){return e.focusNode&&l(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)};function u(e,t){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=e,n.key=n.code=t,n}const p="undefined"!=typeof navigator?navigator:null,m="undefined"!=typeof document?document:null,g=p&&p.userAgent||"",y=/Edge\/(\d+)/.exec(g),b=/MSIE \d/.exec(g),v=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(g),w=!!(b||v||y),S=b?document.documentMode:v?+v[1]:y?+y[1]:0,N=!w&&/gecko\/(\d+)/i.test(g);N&&(/Firefox\/(\d+)/.exec(g)||[0,0])[1];const D=!w&&/Chrome\/(\d+)/.exec(g),O=!!D,C=D?+D[1]:0,x=!w&&!!p&&/Apple Computer/.test(p.vendor),M=x&&(/Mobile\/\w+/.test(g)||!!p&&p.maxTouchPoints>2),T=M||!!p&&/Mac/.test(p.platform),k=!!p&&/Win/.test(p.platform),E=/Android \d/.test(g),P=!!m&&"webkitFontSmoothing"in m.documentElement.style,A=P?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function V(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}}function R(e,t){return"number"==typeof e?e:e[t]}function B(e){let t=e.getBoundingClientRect(),n=t.width/e.offsetWidth||1,o=t.height/e.offsetHeight||1;return{left:t.left,right:t.left+e.clientWidth*n,top:t.top,bottom:t.top+e.clientHeight*o}}function z(e,t,n){let o=e.someProp("scrollThreshold")||0,r=e.someProp("scrollMargin")||5,s=e.dom.ownerDocument;for(let l=n||e.dom;l;){if(1!=l.nodeType){l=i(l);continue}let e=l,n=e==s.body,d=n?V(s):B(e),a=0,c=0;if(t.top<d.top+R(o,"top")?c=-(d.top-t.top+R(r,"top")):t.bottom>d.bottom-R(o,"bottom")&&(c=t.bottom-t.top>d.bottom-d.top?t.top+R(r,"top")-d.top:t.bottom-d.bottom+R(r,"bottom")),t.left<d.left+R(o,"left")?a=-(d.left-t.left+R(r,"left")):t.right>d.right-R(o,"right")&&(a=t.right-d.right+R(r,"right")),a||c)if(n)s.defaultView.scrollBy(a,c);else{let n=e.scrollLeft,o=e.scrollTop;c&&(e.scrollTop+=c),a&&(e.scrollLeft+=a);let i=e.scrollLeft-n,r=e.scrollTop-o;t={left:t.left-i,top:t.top-r,right:t.right-i,bottom:t.bottom-r}}let h=n?"fixed":getComputedStyle(l).position;if(/^(fixed|sticky)$/.test(h))break;l="absolute"==h?l.offsetParent:i(l)}}function F(e){let t=[],n=e.ownerDocument;for(let o=e;o&&(t.push({dom:o,top:o.scrollTop,left:o.scrollLeft}),e!=n);o=i(o));return t}function I(e,t){for(let n=0;n<e.length;n++){let{dom:o,top:i,left:r}=e[n];o.scrollTop!=i+t&&(o.scrollTop=i+t),o.scrollLeft!=r&&(o.scrollLeft=r)}}let L=null;function q(e,t){let n,o,i,r,l=2e8,d=0,a=t.top,c=t.top;for(let h=e.firstChild,f=0;h;h=h.nextSibling,f++){let e;if(1==h.nodeType)e=h.getClientRects();else{if(3!=h.nodeType)continue;e=s(h).getClientRects()}for(let s=0;s<e.length;s++){let u=e[s];if(u.top<=a&&u.bottom>=c){a=Math.max(u.bottom,a),c=Math.min(u.top,c);let e=u.left>t.left?u.left-t.left:u.right<t.left?t.left-u.right:0;if(e<l){n=h,l=e,o=e&&3==n.nodeType?{left:u.right<t.left?u.right:u.left,top:t.top}:t,1==h.nodeType&&e&&(d=f+(t.left>=(u.left+u.right)/2?1:0));continue}}else u.top>t.top&&!i&&u.left<=t.left&&u.right>=t.left&&(i=h,r={left:Math.max(u.left,Math.min(u.right,t.left)),top:u.top});!n&&(t.left>=u.right&&t.top>=u.top||t.left>=u.left&&t.top>=u.bottom)&&(d=f+1)}}return!n&&i&&(n=i,o=r,l=0),n&&3==n.nodeType?function(e,t){let n,o=e.nodeValue.length,i=document.createRange();for(let r=0;r<o;r++){i.setEnd(e,r+1),i.setStart(e,r);let o=_(i,1);if(o.top!=o.bottom&&$(t,o)){n={node:e,offset:r+(t.left>=(o.left+o.right)/2?1:0)};break}}return i.detach(),n||{node:e,offset:0}}(n,o):!n||l&&1==n.nodeType?{node:e,offset:d}:q(n,o)}function $(e,t){return e.left>=t.left-1&&e.left<=t.right+1&&e.top>=t.top-1&&e.top<=t.bottom+1}function K(e,t,n){let o=e.childNodes.length;if(o&&n.top<n.bottom)for(let i=Math.max(0,Math.min(o-1,Math.floor(o*(t.top-n.top)/(n.bottom-n.top))-2)),r=i;;){let n=e.childNodes[r];if(1==n.nodeType){let e=n.getClientRects();for(let o=0;o<e.length;o++){let i=e[o];if($(t,i))return K(n,t,i)}}if((r=(r+1)%o)==i)break}return e}function W(e,t){let n,o=e.dom.ownerDocument,r=0,s=function(e,t,n){if(e.caretPositionFromPoint)try{let o=e.caretPositionFromPoint(t,n);if(o)return{node:o.offsetNode,offset:Math.min(c(o.offsetNode),o.offset)}}catch(o){}if(e.caretRangeFromPoint){let o=e.caretRangeFromPoint(t,n);if(o)return{node:o.startContainer,offset:Math.min(c(o.startContainer),o.startOffset)}}}(o,t.left,t.top);s&&({node:n,offset:r}=s);let l,d=(e.root.elementFromPoint?e.root:o).elementFromPoint(t.left,t.top);if(!d||!e.dom.contains(1!=d.nodeType?d.parentNode:d)){let n=e.dom.getBoundingClientRect();if(!$(t,n))return null;if(d=K(e.dom,t,n),!d)return null}if(x)for(let c=d;n&&c;c=i(c))c.draggable&&(n=void 0);if(d=function(e,t){let n=e.parentNode;return n&&/^li$/i.test(n.nodeName)&&t.left<e.getBoundingClientRect().left?n:e}(d,t),n){if(N&&1==n.nodeType&&(r=Math.min(r,n.childNodes.length),r<n.childNodes.length)){let e,o=n.childNodes[r];"IMG"==o.nodeName&&(e=o.getBoundingClientRect()).right<=t.left&&e.bottom>t.top&&r++}let o;P&&r&&1==n.nodeType&&1==(o=n.childNodes[r-1]).nodeType&&"false"==o.contentEditable&&o.getBoundingClientRect().top>=t.top&&r--,n==e.dom&&r==n.childNodes.length-1&&1==n.lastChild.nodeType&&t.top>n.lastChild.getBoundingClientRect().bottom?l=e.state.doc.content.size:0!=r&&1==n.nodeType&&"BR"==n.childNodes[r-1].nodeName||(l=function(e,t,n,o){let i=-1;for(let r=t,s=!1;r!=e.dom;){let t,n=e.docView.nearestDesc(r,!0);if(!n)return null;if(1==n.dom.nodeType&&(n.node.isBlock&&n.parent||!n.contentDOM)&&((t=n.dom.getBoundingClientRect()).width||t.height)&&(n.node.isBlock&&n.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(n.dom.nodeName)&&(!s&&t.left>o.left||t.top>o.top?i=n.posBefore:(!s&&t.right<o.left||t.bottom<o.top)&&(i=n.posAfter),s=!0),!n.contentDOM&&i<0&&!n.node.isText))return(n.node.isBlock?o.top<(t.top+t.bottom)/2:o.left<(t.left+t.right)/2)?n.posBefore:n.posAfter;r=n.dom.parentNode}return i>-1?i:e.docView.posFromDOM(t,n,-1)}(e,n,r,t))}null==l&&(l=function(e,t,n){let{node:o,offset:i}=q(t,n),r=-1;if(1==o.nodeType&&!o.firstChild){let e=o.getBoundingClientRect();r=e.left!=e.right&&n.left>(e.left+e.right)/2?1:-1}return e.docView.posFromDOM(o,i,r)}(e,d,t));let a=e.docView.nearestDesc(d,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function H(e){return e.top<e.bottom||e.left<e.right}function _(e,t){let n=e.getClientRects();if(n.length){let e=n[t<0?0:n.length-1];if(H(e))return e}return Array.prototype.find.call(n,H)||e.getBoundingClientRect()}const G=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function U(e,t,n){let{node:o,offset:i,atom:r}=e.docView.domFromPos(t,n<0?-1:1),l=P||N;if(3==o.nodeType){if(!l||!G.test(o.nodeValue)&&(n<0?i:i!=o.nodeValue.length)){let e=i,t=i,r=n<0?1:-1;return n<0&&!i?(t++,r=-1):n>=0&&i==o.nodeValue.length?(e--,r=1):n<0?e--:t++,j(_(s(o,e,t),r),r<0)}{let e=_(s(o,i,i),n);if(N&&i&&/\s/.test(o.nodeValue[i-1])&&i<o.nodeValue.length){let t=_(s(o,i-1,i-1),-1);if(t.top==e.top){let n=_(s(o,i,i+1),-1);if(n.top!=e.top)return j(n,n.left<t.left)}}return e}}if(!e.state.doc.resolve(t-(r||0)).parent.inlineContent){if(null==r&&i&&(n<0||i==c(o))){let e=o.childNodes[i-1];if(1==e.nodeType)return Y(e.getBoundingClientRect(),!1)}if(null==r&&i<c(o)){let e=o.childNodes[i];if(1==e.nodeType)return Y(e.getBoundingClientRect(),!0)}return Y(o.getBoundingClientRect(),n>=0)}if(null==r&&i&&(n<0||i==c(o))){let e=o.childNodes[i-1],t=3==e.nodeType?s(e,c(e)-(l?0:1)):1!=e.nodeType||"BR"==e.nodeName&&e.nextSibling?null:e;if(t)return j(_(t,1),!1)}if(null==r&&i<c(o)){let e=o.childNodes[i];for(;e.pmViewDesc&&e.pmViewDesc.ignoreForCoords;)e=e.nextSibling;let t=e?3==e.nodeType?s(e,0,l?0:1):1==e.nodeType?e:null:null;if(t)return j(_(t,-1),!0)}return j(_(3==o.nodeType?s(o):o,-n),n>=0)}function j(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 Y(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 X(e,t,n){let o=e.state,i=e.root.activeElement;o!=t&&e.updateState(t),i!=e.dom&&e.focus();try{return n()}finally{o!=t&&e.updateState(o),i!=e.dom&&i&&i.focus()}}const J=/[\u0590-\u08ac]/;let Q=null,Z=null,ee=!1;function te(e,t,n){return Q==t&&Z==n?ee:(Q=t,Z=n,ee="up"==n||"down"==n?function(e,t,n){let o=t.selection,i="up"==n?o.$from:o.$to;return X(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 o=U(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=s(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?o.top-i.top>2*(i.bottom-o.top):i.bottom-o.bottom>2*(o.bottom-i.top)))return!1}}return!0})}(e,t,n):function(e,t,n){let{$head:o}=t.selection;if(!o.parent.isTextblock)return!1;let i=o.parentOffset,r=!i,s=i==o.parent.content.size,l=e.domSelection();return l?J.test(o.parent.textContent)&&l.modify?X(e,t,()=>{let{focusNode:t,focusOffset:i,anchorNode:r,anchorOffset:s}=e.domSelectionRange(),d=l.caretBidiLevel;l.modify("move",n,"character");let a=o.depth?e.docView.domAfterPos(o.before()):e.dom,{focusNode:c,focusOffset:h}=e.domSelectionRange(),f=c&&!a.contains(1==c.nodeType?c:c.parentNode)||t==c&&i==h;try{l.collapse(r,s),t&&(t!=r||i!=s)&&l.extend&&l.extend(t,i)}catch(u){}return null!=d&&(l.caretBidiLevel=d),f}):"left"==n||"backward"==n?r:s:o.pos==o.start()||o.pos==o.end()}(e,t,n))}class ne{constructor(e,t,n,o){this.parent=e,this.children=t,this.dom=n,this.contentDOM=o,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 o=this.children[t];if(o==e)return n;n+=o.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){if(this.contentDOM&&this.contentDOM.contains(1==e.nodeType?e:e.parentNode)){if(n<0){let n,o;if(e==this.contentDOM)n=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;n=e.previousSibling}for(;n&&(!(o=n.pmViewDesc)||o.parent!=this);)n=n.previousSibling;return n?this.posBeforeChild(o)+o.size:this.posAtStart}{let n,o;if(e==this.contentDOM)n=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;n=e.nextSibling}for(;n&&(!(o=n.pmViewDesc)||o.parent!=this);)n=n.nextSibling;return n?this.posBeforeChild(o):this.posAtEnd}}let i;if(e==this.dom&&this.contentDOM)i=t>o(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))i=2&e.compareDocumentPosition(this.contentDOM);else if(this.dom.firstChild){if(0==t)for(let t=e;;t=t.parentNode){if(t==this.dom){i=!1;break}if(t.previousSibling)break}if(null==i&&t==e.childNodes.length)for(let t=e;;t=t.parentNode){if(t==this.dom){i=!0;break}if(t.nextSibling)break}}return(null==i?n>0:i)?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let n=!0,o=e;o;o=o.parentNode){let i,r=this.getDesc(o);if(r&&(!t||r.node)){if(!n||!(i=r.nodeDOM)||(1==i.nodeType?i.contains(1==e.nodeType?e:e.parentNode):i==e))return r;n=!1}}}getDesc(e){let t=e.pmViewDesc;for(let n=t;n;n=n.parent)if(n==this)return t}posFromDOM(e,t,n){for(let o=e;o;o=o.parentNode){let i=this.getDesc(o);if(i)return i.localPosFromDOM(e,t,n)}return-1}descAt(e){for(let t=0,n=0;t<this.children.length;t++){let o=this.children[t],i=n+o.size;if(n==e&&i!=n){for(;!o.border&&o.children.length;)for(let e=0;e<o.children.length;e++){let t=o.children[e];if(t.size){o=t;break}}return o}if(e<i)return o.descAt(e-n-o.border);n=i}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let n=0,i=0;for(let o=0;n<this.children.length;n++){let t=this.children[n],r=o+t.size;if(r>e||t instanceof ae){i=e-o;break}o=r}if(i)return this.children[n].domFromPos(i-this.children[n].border,t);for(let o;n&&!(o=this.children[n-1]).size&&o instanceof oe&&o.side>=0;n--);if(t<=0){let e,i=!0;for(;e=n?this.children[n-1]:null,e&&e.dom.parentNode!=this.contentDOM;n--,i=!1);return e&&t&&i&&!e.border&&!e.domAtom?e.domFromPos(e.size,t):{node:this.contentDOM,offset:e?o(e.dom)+1:0}}{let e,i=!0;for(;e=n<this.children.length?this.children[n]:null,e&&e.dom.parentNode!=this.contentDOM;n++,i=!1);return e&&i&&!e.border&&!e.domAtom?e.domFromPos(0,t):{node:this.contentDOM,offset:e?o(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 i=-1,r=-1;for(let s=n,l=0;;l++){let n=this.children[l],d=s+n.size;if(-1==i&&e<=d){let r=s+n.border;if(e>=r&&t<=d-n.border&&n.node&&n.contentDOM&&this.contentDOM.contains(n.contentDOM))return n.parseRange(e,t,r);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)){i=o(n.dom)+1;break}e-=n.size}-1==i&&(i=0)}if(i>-1&&(d>t||l==this.children.length-1)){t=d;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)){r=o(n.dom);break}t+=n.size}-1==r&&(r=this.contentDOM.childNodes.length);break}s=d}return{node:this.contentDOM,from:e,to:t,fromOffset:i,toOffset:r}}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 new RangeError("No node after pos "+e);return t.childNodes[n]}setSelection(e,t,n,i=!1){let r=Math.min(e,t),s=Math.max(e,t);for(let o=0,l=0;o<this.children.length;o++){let d=this.children[o],a=l+d.size;if(r>l&&s<a)return d.setSelection(e-l-d.border,t-l-d.border,n,i);l=a}let d=this.domFromPos(e,e?-1:1),a=t==e?d:this.domFromPos(t,t?-1:1),c=n.root.getSelection(),h=n.domSelectionRange(),f=!1;if((N||x)&&e==t){let{node:e,offset:t}=d;if(3==e.nodeType){if(f=!(!t||"\n"!=e.nodeValue[t-1]),f&&t==e.nodeValue.length)for(let n,i=e;i;i=i.parentNode){if(n=i.nextSibling){"BR"==n.nodeName&&(d=a={node:n.parentNode,offset:o(n)+1});break}let e=i.pmViewDesc;if(e&&e.node&&e.node.isBlock)break}}else{let n=e.childNodes[t-1];f=n&&("BR"==n.nodeName||"false"==n.contentEditable)}}if(N&&h.focusNode&&h.focusNode!=a.node&&1==h.focusNode.nodeType){let e=h.focusNode.childNodes[h.focusOffset];e&&"false"==e.contentEditable&&(i=!0)}if(!(i||f&&x)&&l(d.node,d.offset,h.anchorNode,h.anchorOffset)&&l(a.node,a.offset,h.focusNode,h.focusOffset))return;let u=!1;if((c.extend||e==t)&&(!f||!N)){c.collapse(d.node,d.offset);try{e!=t&&c.extend(a.node,a.offset),u=!0}catch(p){}}if(!u){if(e>t){let e=d;d=a,a=e}let n=document.createRange();n.setEnd(a.node,a.offset),n.setStart(d.node,d.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,o=0;o<this.children.length;o++){let i=this.children[o],r=n+i.size;if(n==r?e<=r&&t>=n:e<r&&t>n){let o=n+i.border,s=r-i.border;if(e>=o&&t<=s)return this.dirty=e==n||t==r?2:1,void(e!=o||t!=s||!i.contentLost&&i.dom.parentNode==this.contentDOM?i.markDirty(e-o,t-o):i.dirty=3);i.dirty=i.dom!=i.contentDOM||i.dom.parentNode!=this.contentDOM||i.children.length?3:2}n=r}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 oe extends ne{constructor(e,t,n,o){let i,r=t.type.toDOM;if("function"==typeof r&&(r=r(n,()=>i?i.parent?i.parent.posBeforeChild(i):void 0:o)),!t.type.spec.raw){if(1!=r.nodeType){let e=document.createElement("span");e.appendChild(r),r=e}r.contentEditable="false",r.classList.add("ProseMirror-widget")}super(e,[],r,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 ie extends ne{constructor(e,t,n,o){super(e,[],t,null),this.textDOM=n,this.text=o}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 re extends ne{constructor(e,t,n,o,i){super(e,[],n,o),this.mark=t,this.spec=i}static create(e,n,o,i){let r=i.nodeViews[n.type.name],s=r&&r(n,i,o);return s&&s.dom||(s=t.DOMSerializer.renderSpec(document,n.type.spec.toDOM(n,o),null,n.attrs)),new re(e,n,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 o=re.create(this.parent,this.mark,!0,n),i=this.children,r=this.size;t<r&&(i=Ne(i,t,r,n)),e>0&&(i=Ne(i,0,e,n));for(let s=0;s<i.length;s++)i[s].parent=o;return o.children=i,o}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class se extends ne{constructor(e,t,n,o,i,r,s,l,d){super(e,[],i,r),this.node=t,this.outerDeco=n,this.innerDeco=o,this.nodeDOM=s}static create(e,n,o,i,r,s){let l,d=r.nodeViews[n.type.name],a=d&&d(n,r,()=>l?l.parent?l.parent.posBeforeChild(l):void 0:s,o,i),c=a&&a.dom,h=a&&a.contentDOM;if(n.isText)if(c){if(3!=c.nodeType)throw new RangeError("Text must be rendered as a DOM text node")}else c=document.createTextNode(n.text);else if(!c){let e=t.DOMSerializer.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs);({dom:c,contentDOM:h}=e)}h||n.isText||"BR"==c.nodeName||(c.hasAttribute("contenteditable")||(c.contentEditable="false"),n.type.spec.draggable&&(c.draggable=!0));let f=c;return c=ye(c,o,n),a?l=new ce(e,n,o,i,c,h||null,f,a,r,s+1):n.isText?new de(e,n,o,i,c,f,r):new se(e,n,o,i,c,h||null,f,r,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=()=>t.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)&&be(t,this.outerDeco)&&n.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,n){let o=this.node.inlineContent,i=n,r=e.composing?this.localCompositionInfo(e,n):null,s=r&&r.pos>-1?r:null,l=r&&r.pos<0,d=new we(this,s&&s.node,e);!function(e,t,n,o){let i=t.locals(e),r=0;if(0==i.length){for(let n=0;n<e.childCount;n++){let s=e.child(n);o(s,i,t.forChild(r,s),n),r+=s.nodeSize}return}let s=0,l=[],d=null;for(let a=0;;){let c,h,f,u;for(;s<i.length&&i[s].to==r;){let e=i[s++];e.widget&&(c?(h||(h=[c])).push(e):c=e)}if(c)if(h){h.sort(Se);for(let e=0;e<h.length;e++)n(h[e],a,!!d)}else n(c,a,!!d);if(d)u=-1,f=d,d=null;else{if(!(a<e.childCount))break;u=a,f=e.child(a++)}for(let e=0;e<l.length;e++)l[e].to<=r&&l.splice(e--,1);for(;s<i.length&&i[s].from<=r&&i[s].to>r;)l.push(i[s++]);let p=r+f.nodeSize;if(f.isText){let e=p;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<p&&(d=f.cut(e-r),f=f.cut(0,e-r),p=e,u=-1)}else for(;s<i.length&&i[s].to<p;)s++;o(f,f.isInline&&!f.isLeaf?l.filter(e=>!e.inline):l.slice(),t.forChild(r,f),u),r=p}}(this.node,this.innerDeco,(n,r,s)=>{n.spec.marks?d.syncToMarks(n.spec.marks,o,e,r):n.type.side>=0&&!s&&d.syncToMarks(r==this.node.childCount?t.Mark.none:this.node.child(r).marks,o,e,r),d.placeWidget(n,e,i)},(t,n,s,a)=>{let c;d.syncToMarks(t.marks,o,e,a),d.findNodeMatch(t,n,s,a)||l&&e.state.selection.from>i&&e.state.selection.to<i+t.nodeSize&&(c=d.findIndexWithChild(r.node))>-1&&d.updateNodeAt(t,n,s,c,e)||d.updateNextNode(t,n,s,e,a,i)||d.addNode(t,n,s,e,i),i+=t.nodeSize}),d.syncToMarks([],o,e,0),this.node.isTextblock&&d.addTextblockHacks(),d.destroyRest(),(d.changed||2==this.dirty)&&(s&&this.protectLocalComposition(e,s),he(this.contentDOM,this.children,e),M&&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(t,n){let{from:o,to:i}=t.state.selection;if(!(t.state.selection instanceof e.TextSelection)||o<n||i>n+this.node.content.size)return null;let r=t.input.compositionNode;if(!r||!this.dom.contains(r.parentNode))return null;if(this.node.inlineContent){let e=r.nodeValue,t=function(e,t,n,o){for(let i=0,r=0;i<e.childCount&&r<=o;){let s=e.child(i++),l=r;if(r+=s.nodeSize,!s.isText)continue;let d=s.text;for(;i<e.childCount;){let t=e.child(i++);if(r+=t.nodeSize,!t.isText)break;d+=t.text}if(r>=n){if(r>=o&&d.slice(o-t.length-l,o-l)==t)return o-t.length;let e=l<o?d.lastIndexOf(t,o-l-1):-1;if(e>=0&&e+t.length+l>=n)return l+e;if(n==o&&d.length>=o+t.length-l&&d.slice(o-l,o-l+t.length)==t)return o}}return-1}(this.node.content,e,o-n,i-n);return t<0?null:{node:r,pos:t,text:e}}return{node:r,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:n,text:o}){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 r=new ie(this,i,t,o);e.input.compositionNodes.push(r),this.children=Ne(this.children,n,n+o.length,e,r)}update(e,t,n,o){return!(3==this.dirty||!e.sameMarkup(this.node))&&(this.updateInner(e,t,n,o),!0)}updateInner(e,t,n,o){this.updateOuterDeco(t),this.node=e,this.innerDeco=n,this.contentDOM&&this.updateChildren(o,this.posAtStart),this.dirty=0}updateOuterDeco(e){if(be(e,this.outerDeco))return;let t=1!=this.nodeDOM.nodeType,n=this.dom;this.dom=me(this.dom,this.nodeDOM,pe(this.outerDeco,this.node,t),pe(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 le(e,t,n,o,i){ye(o,t,e);let r=new se(void 0,e,t,n,o,o,o,i,0);return r.contentDOM&&r.updateChildren(i,0),r}class de extends se{constructor(e,t,n,o,i,r,s){super(e,t,n,o,i,null,r,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,o){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,o.trackWrites==this.nodeDOM&&(o.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 o=this.node.cut(e,t),i=document.createTextNode(o.text);return new de(this.parent,o,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 ae extends ne{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 ce extends se{constructor(e,t,n,o,i,r,s,l,d,a){super(e,t,n,o,i,r,s,d,a),this.spec=l}update(e,t,n,o){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,o),i}return!(!this.contentDOM&&!e.isLeaf)&&super.update(e,t,n,o)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,n,o){this.spec.setSelection?this.spec.setSelection(e,t,n.root):super.setSelection(e,t,n,o)}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)}}function he(e,t,n){let o=e.firstChild,i=!1;for(let r=0;r<t.length;r++){let s=t[r],l=s.dom;if(l.parentNode==e){for(;l!=o;)o=ve(o),i=!0;o=o.nextSibling}else i=!0,e.insertBefore(l,o);if(s instanceof re){let t=o?o.previousSibling:e.lastChild;he(s.contentDOM,s.children,n),o=t?t.nextSibling:e.firstChild}}for(;o;)o=ve(o),i=!0;i&&n.trackWrites==e&&(n.trackWrites=null)}const fe=function(e){e&&(this.nodeName=e)};fe.prototype=Object.create(null);const ue=[new fe];function pe(e,t,n){if(0==e.length)return ue;let o=n?ue[0]:new fe,i=[o];for(let r=0;r<e.length;r++){let s=e[r].type.attrs;if(s){s.nodeName&&i.push(o=new fe(s.nodeName));for(let e in s){let r=s[e];null!=r&&(n&&1==i.length&&i.push(o=new fe(t.isInline?"span":"div")),"class"==e?o.class=(o.class?o.class+" ":"")+r:"style"==e?o.style=(o.style?o.style+";":"")+r:"nodeName"!=e&&(o[e]=r))}}}return i}function me(e,t,n,o){if(n==ue&&o==ue)return t;let i=t;for(let r=0;r<o.length;r++){let t=o[r],s=n[r];if(r){let n;s&&s.nodeName==t.nodeName&&i!=e&&(n=i.parentNode)&&n.nodeName.toLowerCase()==t.nodeName||(n=document.createElement(t.nodeName),n.pmIsDeco=!0,n.appendChild(i),s=ue[0]),i=n}ge(i,s||ue[0],t)}return i}function ge(e,t,n){for(let o in t)"class"==o||"style"==o||"nodeName"==o||o in n||e.removeAttribute(o);for(let o in n)"class"!=o&&"style"!=o&&"nodeName"!=o&&n[o]!=t[o]&&e.setAttribute(o,n[o]);if(t.class!=n.class){let o=t.class?t.class.split(" ").filter(Boolean):[],i=n.class?n.class.split(" ").filter(Boolean):[];for(let t=0;t<o.length;t++)-1==i.indexOf(o[t])&&e.classList.remove(o[t]);for(let t=0;t<i.length;t++)-1==o.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,o=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g;for(;n=o.exec(t.style);)e.style.removeProperty(n[1])}n.style&&(e.style.cssText+=n.style)}}function ye(e,t,n){return me(e,e,ue,pe(t,n,1!=e.nodeType))}function be(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 ve(e){let t=e.nextSibling;return e.parentNode.removeChild(e),t}class we{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,o=n.children.length,i=e.childCount,r=new Map,s=[];e:for(;i>0;){let l;for(;;)if(o){let e=n.children[o-1];if(!(e instanceof re)){l=e,o--;break}n=e,o=e.children.length}else{if(n==t)break e;o=n.parent.children.indexOf(n),n=n.parent}let d=l.node;if(d){if(d!=e.child(i-1))break;--i,r.set(l,i),s.push(l)}}return{index:i,matched:r,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,o){let i=0,r=this.stack.length>>1,s=Math.min(r,e.length);for(;i<s&&(i==r-1?this.top:this.stack[i+1<<1]).matchesMark(e[i])&&!1!==e[i].type.spec.spanning;)i++;for(;i<r;)this.destroyRest(),this.top.dirty=0,this.index=this.stack.pop(),this.top=this.stack.pop(),r--;for(;r<e.length;){this.stack.push(this.top,this.index+1);let i=-1,s=this.top.children.length;o<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[r])&&!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 o=re.create(this.top,e[r],t,n);this.top.children.splice(this.index,0,o),this.top=o,this.changed=!0}this.index=0,r++}}findNodeMatch(e,t,n,o){let i,r=-1;if(o>=this.preMatch.index&&(i=this.preMatch.matches[o-this.preMatch.index]).parent==this.top&&i.matchesNode(e,t,n))r=this.top.children.indexOf(i,this.index);else for(let s=this.index,l=Math.min(this.top.children.length,s+5);s<l;s++){let o=this.top.children[s];if(o.matchesNode(e,t,n)&&!this.preMatch.matched.has(o)){r=s;break}}return!(r<0)&&(this.destroyBetween(this.index,r),this.index++,!0)}updateNodeAt(e,t,n,o,i){let r=this.top.children[o];return 3==r.dirty&&r.dom==r.contentDOM&&(r.dirty=2),!!r.update(e,t,n,i)&&(this.destroyBetween(this.index,o),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,o,i,r){for(let s=this.index;s<this.top.children.length;s++){let l=this.top.children[s];if(l instanceof se){let d=this.preMatch.matched.get(l);if(null!=d&&d!=i)return!1;let a,c=l.dom,h=this.isLocked(c)&&!(e.isText&&l.node&&l.node.isText&&l.nodeDOM.nodeValue==e.text&&3!=l.dirty&&be(t,l.outerDeco));if(!h&&l.update(e,t,n,o))return this.destroyBetween(this.index,s),l.dom!=c&&(this.changed=!0),this.index++,!0;if(!h&&(a=this.recreateWrapper(l,e,t,n,o,r)))return this.destroyBetween(this.index,s),this.top.children[this.index]=a,a.contentDOM&&(a.dirty=2,a.updateChildren(o,r+1),a.dirty=0),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,n,o,i,r){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!be(n,e.outerDeco)||!o.eq(e.innerDeco))return null;let s=se.create(this.top,t,n,o,i,r);if(s.contentDOM){s.children=e.children,e.children=[];for(let e of s.children)e.parent=s}return e.destroy(),s}addNode(e,t,n,o,i){let r=se.create(this.top,e,t,n,o,i);r.contentDOM&&r.updateChildren(o,i+1),this.top.children.splice(this.index++,0,r),this.changed=!0}placeWidget(e,t,n){let o=this.index<this.top.children.length?this.top.children[this.index]:null;if(!o||!o.matchesWidget(e)||e!=o.widget&&o.widget.type.toDOM.parentNode){let o=new oe(this.top,e,t,n);this.top.children.splice(this.index++,0,o),this.changed=!0}else this.index++}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof re;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof de)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((x||O)&&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 o=new ae(this.top,[],n,null);t!=this.top?t.children.push(o):t.children.splice(this.index++,0,o),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||1==e.nodeType&&e.contains(this.lock.parentNode))}}function Se(e,t){return e.type.side-t.type.side}function Ne(e,t,n,o,i){let r=[];for(let s=0,l=0;s<e.length;s++){let d=e[s],a=l,c=l+=d.size;a>=n||c<=t?r.push(d):(a<t&&r.push(d.slice(0,t-a,o)),i&&(r.push(i),i=void 0),c>n&&r.push(d.slice(n-a,d.size,o)))}return r}function De(t,n=null){let i=t.domSelectionRange(),r=t.state.doc;if(!i.focusNode)return null;let s=t.docView.nearestDesc(i.focusNode),l=s&&0==s.size,d=t.docView.posFromDOM(i.focusNode,i.focusOffset,1);if(d<0)return null;let a,h,u=r.resolve(d);if(f(i)){for(a=d;s&&!s.node;)s=s.parent;let t=s.node;if(s&&t.isAtom&&e.NodeSelection.isSelectable(t)&&s.parent&&(!t.isInline||!function(e,t,n){for(let i=0==t,r=t==c(e);i||r;){if(e==n)return!0;let t=o(e);if(!(e=e.parentNode))return!1;i=i&&0==t,r=r&&t==c(e)}}(i.focusNode,i.focusOffset,s.dom))){let t=s.posBefore;h=new e.NodeSelection(d==t?u:r.resolve(t))}}else{if(i instanceof t.dom.ownerDocument.defaultView.Selection&&i.rangeCount>1){let e=d,n=d;for(let o=0;o<i.rangeCount;o++){let r=i.getRangeAt(o);e=Math.min(e,t.docView.posFromDOM(r.startContainer,r.startOffset,1)),n=Math.max(n,t.docView.posFromDOM(r.endContainer,r.endOffset,-1))}if(e<0)return null;[a,d]=n==t.state.selection.anchor?[n,e]:[e,n],u=r.resolve(d)}else a=t.docView.posFromDOM(i.anchorNode,i.anchorOffset,1);if(a<0)return null}let p=r.resolve(a);if(!h){h=Ae(t,p,u,"pointer"==n||t.state.selection.head<u.pos&&!l?1:-1)}return h}function Oe(e){return e.editable?e.hasFocus():Re(e)&&document.activeElement&&document.activeElement.contains(e.dom)}function Ce(t,n=!1){let i=t.state.selection;if(Ee(t,i),Oe(t)){if(!n&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&O){let e=t.domSelectionRange(),n=t.domObserver.currentSelection;if(e.anchorNode&&n.anchorNode&&l(e.anchorNode,e.anchorOffset,n.anchorNode,n.anchorOffset))return t.input.mouseDown.delayedSelectionSync=!0,void t.domObserver.setCurSelection()}if(t.domObserver.disconnectSelection(),t.cursorWrapper)!function(e){let t=e.domSelection();if(!t)return;let n=e.cursorWrapper.dom,i="IMG"==n.nodeName;i?t.collapse(n.parentNode,o(n)+1):t.collapse(n,0);!i&&!e.state.selection.visible&&w&&S<=11&&(n.disabled=!0,n.disabled=!1)}(t);else{let o,r,{anchor:s,head:l}=i;!xe||i instanceof e.TextSelection||(i.$from.parent.inlineContent||(o=Me(t,i.from)),i.empty||i.$from.parent.inlineContent||(r=Me(t,i.to))),t.docView.setSelection(s,l,t,n),xe&&(o&&ke(o),r&&ke(r)),i.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&function(e){let t=e.dom.ownerDocument;t.removeEventListener("selectionchange",e.input.hideSelectionGuard);let n=e.domSelectionRange(),o=n.anchorNode,i=n.anchorOffset;t.addEventListener("selectionchange",e.input.hideSelectionGuard=()=>{n.anchorNode==o&&n.anchorOffset==i||(t.removeEventListener("selectionchange",e.input.hideSelectionGuard),setTimeout(()=>{Oe(e)&&!e.state.selection.visible||e.dom.classList.remove("ProseMirror-hideselection")},20))})}(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}const xe=x||O&&C<63;function Me(e,t){let{node:n,offset:o}=e.docView.domFromPos(t,0),i=o<n.childNodes.length?n.childNodes[o]:null,r=o?n.childNodes[o-1]:null;if(x&&i&&"false"==i.contentEditable)return Te(i);if(!(i&&"false"!=i.contentEditable||r&&"false"!=r.contentEditable)){if(i)return Te(i);if(r)return Te(r)}}function Te(e){return e.contentEditable="true",x&&e.draggable&&(e.draggable=!1,e.wasDraggable=!0),e}function ke(e){e.contentEditable="false",e.wasDraggable&&(e.draggable=!0,e.wasDraggable=null)}function Ee(t,n){if(n instanceof e.NodeSelection){let e=t.docView.descAt(n.from);e!=t.lastSelectedViewDesc&&(Pe(t),e&&e.selectNode(),t.lastSelectedViewDesc=e)}else Pe(t)}function Pe(e){e.lastSelectedViewDesc&&(e.lastSelectedViewDesc.parent&&e.lastSelectedViewDesc.deselectNode(),e.lastSelectedViewDesc=void 0)}function Ae(t,n,o,i){return t.someProp("createSelectionBetween",e=>e(t,n,o))||e.TextSelection.between(n,o,i)}function Ve(e){return!(e.editable&&!e.hasFocus())&&Re(e)}function Re(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(n){return!1}}function Be(t,n){let{$anchor:o,$head:i}=t.selection,r=n>0?o.max(i):o.min(i),s=r.parent.inlineContent?r.depth?t.doc.resolve(n>0?r.after():r.before()):null:r;return s&&e.Selection.findFrom(s,n)}function ze(e,t){return e.dispatch(e.state.tr.setSelection(t).scrollIntoView()),!0}function Fe(t,n,o){let i=t.state.selection;if(!(i instanceof e.TextSelection)){if(i instanceof e.NodeSelection&&i.node.isInline)return ze(t,new e.TextSelection(n>0?i.$to:i.$from));{let e=Be(t.state,n);return!!e&&ze(t,e)}}if(o.indexOf("s")>-1){let{$head:o}=i,r=o.textOffset?null:n<0?o.nodeBefore:o.nodeAfter;if(!r||r.isText||!r.isLeaf)return!1;let s=t.state.doc.resolve(o.pos+r.nodeSize*(n<0?-1:1));return ze(t,new e.TextSelection(i.$anchor,s))}if(!i.empty)return!1;if(t.endOfTextblock(n>0?"forward":"backward")){let o=Be(t.state,n);return!!(o&&o instanceof e.NodeSelection)&&ze(t,o)}if(!(T&&o.indexOf("m")>-1)){let o,r=i.$head,s=r.textOffset?null:n<0?r.nodeBefore:r.nodeAfter;if(!s||s.isText)return!1;let l=n<0?r.pos-s.nodeSize:r.pos;return!!(s.isAtom||(o=t.docView.descAt(l))&&!o.contentDOM)&&(e.NodeSelection.isSelectable(s)?ze(t,new e.NodeSelection(n<0?t.state.doc.resolve(r.pos-s.nodeSize):r)):!!P&&ze(t,new e.TextSelection(t.state.doc.resolve(n<0?l:l+s.nodeSize))))}}function Ie(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function Le(e,t){let n=e.pmViewDesc;return n&&0==n.size&&(t<0||e.nextSibling||"BR"!=e.nodeName)}function qe(e,t){return t<0?function(e){let t=e.domSelectionRange(),n=t.focusNode,i=t.focusOffset;if(!n)return;let r,s,l=!1;N&&1==n.nodeType&&i<Ie(n)&&Le(n.childNodes[i],-1)&&(l=!0);for(;;)if(i>0){if(1!=n.nodeType)break;{let e=n.childNodes[i-1];if(Le(e,-1))r=n,s=--i;else{if(3!=e.nodeType)break;n=e,i=n.nodeValue.length}}}else{if($e(n))break;{let t=n.previousSibling;for(;t&&Le(t,-1);)r=n.parentNode,s=o(t),t=t.previousSibling;if(t)n=t,i=Ie(n);else{if(n=n.parentNode,n==e.dom)break;i=0}}}l?Ke(e,n,i):r&&Ke(e,r,s)}(e):function(e){let t=e.domSelectionRange(),n=t.focusNode,i=t.focusOffset;if(!n)return;let r,s,l=Ie(n);for(;;)if(i<l){if(1!=n.nodeType)break;if(!Le(n.childNodes[i],1))break;r=n,s=++i}else{if($e(n))break;{let t=n.nextSibling;for(;t&&Le(t,1);)r=t.parentNode,s=o(t)+1,t=t.nextSibling;if(t)n=t,i=0,l=Ie(n);else{if(n=n.parentNode,n==e.dom)break;i=l=0}}}r&&Ke(e,r,s)}(e)}function $e(e){let t=e.pmViewDesc;return t&&t.node&&t.node.isBlock}function Ke(e,t,n){if(3!=t.nodeType){let e,i;(i=function(e,t){for(;e&&t==e.childNodes.length&&!h(e);)t=o(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=i,n=0):(e=function(e,t){for(;e&&!t&&!h(e);)t=o(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 i=e.domSelection();if(!i)return;if(f(i)){let e=document.createRange();e.setEnd(t,n),e.setStart(t,n),i.removeAllRanges(),i.addRange(e)}else i.extend&&i.extend(t,n);e.domObserver.setCurSelection();let{state:r}=e;setTimeout(()=>{e.state==r&&Ce(e)},50)}function We(e,t){let n=e.state.doc.resolve(t);if(!O&&!k&&n.parent.inlineContent){let o=e.coordsAtPos(t);if(t>n.start()){let n=e.coordsAtPos(t-1),i=(n.top+n.bottom)/2;if(i>o.top&&i<o.bottom&&Math.abs(n.left-o.left)>1)return n.left<o.left?"ltr":"rtl"}if(t<n.end()){let n=e.coordsAtPos(t+1),i=(n.top+n.bottom)/2;if(i>o.top&&i<o.bottom&&Math.abs(n.left-o.left)>1)return n.left>o.left?"ltr":"rtl"}}return"rtl"==getComputedStyle(e.dom).direction?"rtl":"ltr"}function He(t,n,o){let i=t.state.selection;if(i instanceof e.TextSelection&&!i.empty||o.indexOf("s")>-1)return!1;if(T&&o.indexOf("m")>-1)return!1;let{$from:r,$to:s}=i;if(!r.parent.inlineContent||t.endOfTextblock(n<0?"up":"down")){let o=Be(t.state,n);if(o&&o instanceof e.NodeSelection)return ze(t,o)}if(!r.parent.inlineContent){let o=n<0?r:s,l=i instanceof e.AllSelection?e.Selection.near(o,n):e.Selection.findFrom(o,n);return!!l&&ze(t,l)}return!1}function _e(t,n){if(!(t.state.selection instanceof e.TextSelection))return!0;let{$head:o,$anchor:i,empty:r}=t.state.selection;if(!o.sameParent(i))return!0;if(!r)return!1;if(t.endOfTextblock(n>0?"forward":"backward"))return!0;let s=!o.textOffset&&(n<0?o.nodeBefore:o.nodeAfter);if(s&&!s.isText){let e=t.state.tr;return n<0?e.delete(o.pos-s.nodeSize,o.pos):e.delete(o.pos,o.pos+s.nodeSize),t.dispatch(e),!0}return!1}function Ge(e,t,n){e.domObserver.stop(),t.contentEditable=n,e.domObserver.start()}function Ue(e,t){let n=t.keyCode,o=function(e){let t="";return e.ctrlKey&&(t+="c"),e.metaKey&&(t+="m"),e.altKey&&(t+="a"),e.shiftKey&&(t+="s"),t}(t);if(8==n||T&&72==n&&"c"==o)return _e(e,-1)||qe(e,-1);if(46==n&&!t.shiftKey||T&&68==n&&"c"==o)return _e(e,1)||qe(e,1);if(13==n||27==n)return!0;if(37==n||T&&66==n&&"c"==o){let t=37==n?"ltr"==We(e,e.state.selection.from)?-1:1:-1;return Fe(e,t,o)||qe(e,t)}if(39==n||T&&70==n&&"c"==o){let t=39==n?"ltr"==We(e,e.state.selection.from)?1:-1:1;return Fe(e,t,o)||qe(e,t)}return 38==n||T&&80==n&&"c"==o?He(e,-1,o)||qe(e,-1):40==n||T&&78==n&&"c"==o?function(e){if(!x||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;Ge(e,n,"true"),setTimeout(()=>Ge(e,n,"false"),20)}return!1}(e)||He(e,1,o)||qe(e,1):o==(T?"m":"c")&&(66==n||73==n||89==n||90==n)}function je(e,n){e.someProp("transformCopied",t=>{n=t(n,e)});let o=[],{content:i,openStart:r,openEnd:s}=n;for(;r>1&&s>1&&1==i.childCount&&1==i.firstChild.childCount;){r--,s--;let e=i.firstChild;o.push(e.type.name,e.attrs!=e.type.defaultAttrs?e.attrs:null),i=e.content}let l=e.someProp("clipboardSerializer")||t.DOMSerializer.fromSchema(e.state.schema),d=it(),a=d.createElement("div");a.appendChild(l.serializeFragment(i,{document:d}));let c,h=a.firstChild,f=0;for(;h&&1==h.nodeType&&(c=nt[h.nodeName.toLowerCase()]);){for(let e=c.length-1;e>=0;e--){let t=d.createElement(c[e]);for(;a.firstChild;)t.appendChild(a.firstChild);a.appendChild(t),f++}h=a.firstChild}return h&&1==h.nodeType&&h.setAttribute("data-pm-slice",`${r} ${s}${f?` -${f}`:""} ${JSON.stringify(o)}`),{dom:a,text:e.someProp("clipboardTextSerializer",t=>t(n,e))||n.content.textBetween(0,n.content.size,"\n\n"),slice:n}}function Ye(e,n,o,i,r){let s,l,d=r.parent.type.spec.code;if(!o&&!n)return null;let a=!!n&&(i||d||!o);if(a){if(e.someProp("transformPastedText",t=>{n=t(n,d||i,e)}),d)return l=new t.Slice(t.Fragment.from(e.state.schema.text(n.replace(/\r\n?/g,"\n"))),0,0),e.someProp("transformPasted",t=>{l=t(l,e,!0)}),l;let o=e.someProp("clipboardTextParser",t=>t(n,r,i,e));if(o)l=o;else{let o=r.marks(),{schema:i}=e.state,l=t.DOMSerializer.fromSchema(i);s=document.createElement("div"),n.split(/(?:\r\n?|\n)+/).forEach(e=>{let t=s.appendChild(document.createElement("p"));e&&t.appendChild(l.serializeNode(i.text(e,o)))})}}else e.someProp("transformPastedHTML",t=>{o=t(o,e)}),s=function(e){let t=/^(\s*<meta [^>]*>)*/.exec(e);t&&(e=e.slice(t[0].length));let n,o=it().createElement("div"),i=/<([a-z][^>\s]+)/i.exec(e);(n=i&&nt[i[1].toLowerCase()])&&(e=n.map(e=>"<"+e+">").join("")+e+n.map(e=>"</"+e+">").reverse().join(""));if(o.innerHTML=function(e){let t=window.trustedTypes;if(!t)return e;rt||(rt=t.defaultPolicy||t.createPolicy("ProseMirrorClipboard",{createHTML:e=>e}));return rt.createHTML(e)}(e),n)for(let r=0;r<n.length;r++)o=o.querySelector(n[r])||o;return o}(o),P&&function(e){let t=e.querySelectorAll(O?"span:not([class]):not([style])":"span.Apple-converted-space");for(let n=0;n<t.length;n++){let o=t[n];1==o.childNodes.length&&" "==o.textContent&&o.parentNode&&o.parentNode.replaceChild(e.ownerDocument.createTextNode(" "),o)}}(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 t=+h[3];t>0;t--){let e=s.firstChild;for(;e&&1!=e.nodeType;)e=e.nextSibling;if(!e)break;s=e}if(!l){let n=e.someProp("clipboardParser")||e.someProp("domParser")||t.DOMParser.fromSchema(e.state.schema);l=n.parseSlice(s,{preserveWhitespace:!(!a&&!h),context:r,ruleFromNode:e=>"BR"!=e.nodeName||e.nextSibling||!e.parentNode||Xe.test(e.parentNode.nodeName)?null:{ignore:!0}})}if(h)l=function(e,n){if(!e.size)return e;let o,i=e.content.firstChild.type.schema;try{o=JSON.parse(n)}catch(d){return e}let{content:r,openStart:s,openEnd:l}=e;for(let a=o.length-2;a>=0;a-=2){let e=i.nodes[o[a]];if(!e||e.hasRequiredAttrs())break;r=t.Fragment.from(e.create(o[a+1],r)),s++,l++}return new t.Slice(r,s,l)}(tt(l,+h[1],+h[2]),h[4]);else if(l=t.Slice.maxOpen(function(e,n){if(e.childCount<2)return e;for(let o=n.depth;o>=0;o--){let i,r=n.node(o).contentMatchAt(n.index(o)),s=[];if(e.forEach(e=>{if(!s)return;let t,n=r.findWrapping(e.type);if(!n)return s=null;if(t=s.length&&i.length&&Qe(n,i,e,s[s.length-1],0))s[s.length-1]=t;else{s.length&&(s[s.length-1]=Ze(s[s.length-1],i.length));let t=Je(e,n);s.push(t),r=r.matchType(t.type),i=n}}),s)return t.Fragment.from(s)}return e}(l.content,r),!0),l.openStart||l.openEnd){let e=0,t=0;for(let n=l.content.firstChild;e<l.openStart&&!n.type.spec.isolating;e++,n=n.firstChild);for(let n=l.content.lastChild;t<l.openEnd&&!n.type.spec.isolating;t++,n=n.lastChild);l=tt(l,e,t)}return e.someProp("transformPasted",t=>{l=t(l,e,a)}),l}const Xe=/^(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 Je(e,n,o=0){for(let i=n.length-1;i>=o;i--)e=n[i].create(null,t.Fragment.from(e));return e}function Qe(e,n,o,i,r){if(r<e.length&&r<n.length&&e[r]==n[r]){let s=Qe(e,n,o,i.lastChild,r+1);if(s)return i.copy(i.content.replaceChild(i.childCount-1,s));if(i.contentMatchAt(i.childCount).matchType(r==e.length-1?o.type:e[r+1]))return i.copy(i.content.append(t.Fragment.from(Je(o,e,r+1))))}}function Ze(e,n){if(0==n)return e;let o=e.content.replaceChild(e.childCount-1,Ze(e.lastChild,n-1)),i=e.contentMatchAt(e.childCount).fillBefore(t.Fragment.empty,!0);return e.copy(o.append(i))}function et(e,n,o,i,r,s){let l=n<0?e.firstChild:e.lastChild,d=l.content;return e.childCount>1&&(s=0),r<i-1&&(d=et(d,n,o,i,r+1,s)),r>=o&&(d=n<0?l.contentMatchAt(0).fillBefore(d,s<=r).append(d):d.append(l.contentMatchAt(l.childCount).fillBefore(t.Fragment.empty,!0))),e.replaceChild(n<0?0:e.childCount-1,l.copy(d))}function tt(e,n,o){return n<e.openStart&&(e=new t.Slice(et(e.content,-1,n,e.openStart,0,e.openEnd),n,e.openEnd)),o<e.openEnd&&(e=new t.Slice(et(e.content,1,o,e.openEnd,0,0),e.openStart,o)),e}const nt={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};let ot=null;function it(){return ot||(ot=document.implementation.createHTMLDocument("title"))}let rt=null;const st={},lt={},dt={touchstart:!0,touchmove:!0};class at{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 ct(e,t){e.input.lastSelectionOrigin=t,e.input.lastSelectionTime=Date.now()}function ht(e){e.someProp("handleDOMEvents",t=>{for(let n in t)e.input.eventHandlers[n]||e.dom.addEventListener(n,e.input.eventHandlers[n]=t=>ft(e,t))})}function ft(e,t){return e.someProp("handleDOMEvents",n=>{let o=n[t.type];return!!o&&(o(e,t)||t.defaultPrevented)})}function ut(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}function pt(e){return{left:e.clientX,top:e.clientY}}function mt(e,t,n,o,i){if(-1==o)return!1;let r=e.state.doc.resolve(o);for(let s=r.depth+1;s>0;s--)if(e.someProp(t,t=>s>r.depth?t(e,n,r.nodeAfter,r.before(s),i,!0):t(e,n,r.node(s),r.before(s),i,!1)))return!0;return!1}function gt(e,t,n){if(e.focused||e.focus(),e.state.selection.eq(t))return;let o=e.state.tr.setSelection(t);o.setMeta("pointer",!0),e.dispatch(o)}function yt(t,n,o,i,r){return mt(t,"handleClickOn",n,o,i)||t.someProp("handleClick",e=>e(t,n,i))||(r?function(t,n){if(-1==n)return!1;let o,i,r=t.state.selection;r instanceof e.NodeSelection&&(o=r.node);let s=t.state.doc.resolve(n);for(let l=s.depth+1;l>0;l--){let t=l>s.depth?s.nodeAfter:s.node(l);if(e.NodeSelection.isSelectable(t)){i=o&&r.$from.depth>0&&l>=r.$from.depth&&s.before(r.$from.depth+1)==r.$from.pos?s.before(r.$from.depth):s.before(l);break}}return null!=i&&(gt(t,e.NodeSelection.create(t.state.doc,i)),!0)}(t,o):function(t,n){if(-1==n)return!1;let o=t.state.doc.resolve(n),i=o.nodeAfter;return!!(i&&i.isAtom&&e.NodeSelection.isSelectable(i))&&(gt(t,new e.NodeSelection(o)),!0)}(t,o))}function bt(e,t,n,o){return mt(e,"handleDoubleClickOn",t,n,o)||e.someProp("handleDoubleClick",n=>n(e,t,o))}function vt(t,n,o,i){return mt(t,"handleTripleClickOn",n,o,i)||t.someProp("handleTripleClick",e=>e(t,n,i))||function(t,n,o){if(0!=o.button)return!1;let i=t.state.doc;if(-1==n)return!!i.inlineContent&&(gt(t,e.TextSelection.create(i,0,i.content.size)),!0);let r=i.resolve(n);for(let s=r.depth+1;s>0;s--){let n=s>r.depth?r.nodeAfter:r.node(s),o=r.before(s);if(n.inlineContent)gt(t,e.TextSelection.create(i,o+1,o+1+n.content.size));else{if(!e.NodeSelection.isSelectable(n))continue;gt(t,e.NodeSelection.create(i,o))}return!0}}(t,o,i)}function wt(e){return Tt(e)}lt.keydown=(e,t)=>{let n=t;if(e.input.shiftKey=16==n.keyCode||n.shiftKey,!Dt(e,n)&&(e.input.lastKeyCode=n.keyCode,e.input.lastKeyCodeTime=Date.now(),!E||!O||13!=n.keyCode))if(229!=n.keyCode&&e.domObserver.forceFlush(),!M||13!=n.keyCode||n.ctrlKey||n.altKey||n.metaKey)e.someProp("handleKeyDown",t=>t(e,n))||Ue(e,n)?n.preventDefault():ct(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,u(13,"Enter"))),e.input.lastIOSEnter=0)},200)}},lt.keyup=(e,t)=>{16==t.keyCode&&(e.input.shiftKey=!1)},lt.keypress=(t,n)=>{let o=n;if(Dt(t,o)||!o.charCode||o.ctrlKey&&!o.altKey||T&&o.metaKey)return;if(t.someProp("handleKeyPress",e=>e(t,o)))return void o.preventDefault();let i=t.state.selection;if(!(i instanceof e.TextSelection&&i.$from.sameParent(i.$to))){let e=String.fromCharCode(o.charCode),n=()=>t.state.tr.insertText(e).scrollIntoView();/[\r\n]/.test(e)||t.someProp("handleTextInput",o=>o(t,i.$from.pos,i.$to.pos,e,n))||t.dispatch(n()),o.preventDefault()}};const St=T?"metaKey":"ctrlKey";st.mousedown=(e,t)=>{let n=t;e.input.shiftKey=n.shiftKey;let o=wt(e),i=Date.now(),r="singleClick";i-e.input.lastClick.time<500&&function(e,t){let n=t.x-e.clientX,o=t.y-e.clientY;return n*n+o*o<100}(n,e.input.lastClick)&&!n[St]&&e.input.lastClick.button==n.button&&("singleClick"==e.input.lastClick.type?r="doubleClick":"doubleClick"==e.input.lastClick.type&&(r="tripleClick")),e.input.lastClick={time:i,x:n.clientX,y:n.clientY,type:r,button:n.button};let s=e.posAtCoords(pt(n));s&&("singleClick"==r?(e.input.mouseDown&&e.input.mouseDown.done(),e.input.mouseDown=new Nt(e,s,n,!!o)):("doubleClick"==r?bt:vt)(e,s.pos,s.inside,n)?n.preventDefault():ct(e,"pointer"))};class Nt{constructor(t,n,o,i){let r,s;if(this.view=t,this.pos=n,this.event=o,this.flushed=i,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=t.state.doc,this.selectNode=!!o[St],this.allowDefault=o.shiftKey,n.inside>-1)r=t.state.doc.nodeAt(n.inside),s=n.inside;else{let e=t.state.doc.resolve(n.pos);r=e.parent,s=e.depth?e.before():0}const l=i?null:o.target,d=l?t.docView.nearestDesc(l,!0):null;this.target=d&&1==d.nodeDOM.nodeType?d.nodeDOM:null;let{selection:a}=t.state;(0==o.button&&r.type.spec.draggable&&!1!==r.type.spec.selectable||a instanceof e.NodeSelection&&a.from<=s&&a.to>s)&&(this.mightDrag={node:r,pos:s,addAttr:!(!this.target||this.target.draggable),setUneditable:!(!this.target||!N||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()),t.root.addEventListener("mouseup",this.up=this.up.bind(this)),t.root.addEventListener("mousemove",this.move=this.move.bind(this)),ct(t,"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(()=>Ce(this.view)),this.view.input.mouseDown=null}up(t){if(this.done(),!this.view.dom.contains(t.target))return;let n=this.pos;this.view.state.doc!=this.startDoc&&(n=this.view.posAtCoords(pt(t))),this.updateAllowDefault(t),this.allowDefault||!n?ct(this.view,"pointer"):yt(this.view,n.pos,n.inside,t,this.selectNode)?t.preventDefault():0==t.button&&(this.flushed||x&&this.mightDrag&&!this.mightDrag.node.isAtom||O&&!this.view.state.selection.visible&&Math.min(Math.abs(n.pos-this.view.state.selection.from),Math.abs(n.pos-this.view.state.selection.to))<=2)?(gt(this.view,e.Selection.near(this.view.state.doc.resolve(n.pos))),t.preventDefault()):ct(this.view,"pointer")}move(e){this.updateAllowDefault(e),ct(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 Dt(e,t){return!!e.composing||!!(x&&Math.abs(t.timeStamp-e.input.compositionEndedAt)<500)&&(e.input.compositionEndedAt=-2e8,!0)}st.touchstart=e=>{e.input.lastTouch=Date.now(),wt(e),ct(e,"pointer")},st.touchmove=e=>{e.input.lastTouch=Date.now(),ct(e,"pointer")},st.contextmenu=e=>wt(e);const Ot=E?5e3:-1;function Ct(e,t){clearTimeout(e.input.composingTimeout),t>-1&&(e.input.composingTimeout=setTimeout(()=>Tt(e),t))}function xt(e){for(e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=function(){let e=document.createEvent("Event");return e.initEvent("event",!0,!0),e.timeStamp}());e.input.compositionNodes.length>0;)e.input.compositionNodes.pop().markParentsDirty()}function Mt(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=c(e=e.childNodes[t-1])}else{if(!e.parentNode||h(e))return null;t=o(e),e=e.parentNode}}}(t.focusNode,t.focusOffset),i=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||h(e))return null;t=o(e)+1,e=e.parentNode}}}(t.focusNode,t.focusOffset);if(n&&i&&n!=i){let t=i.pmViewDesc,o=e.domObserver.lastChangedTextNode;if(n==o||i==o)return o;if(!t||!t.isText(i.nodeValue))return i;if(e.input.compositionNode==i){let e=n.pmViewDesc;if(e&&e.isText(n.nodeValue))return i}}return n||i}function Tt(e,t=!1){if(!(E&&e.domObserver.flushingSoon>=0)){if(e.domObserver.forceFlush(),xt(e),t||e.docView&&e.docView.dirty){let n=De(e),o=e.state.selection;return n&&!n.eq(o)?e.dispatch(e.state.tr.setSelection(n)):!e.markCursor&&!t||o.$from.node(o.$from.sharedDepth(o.to)).inlineContent?e.updateState(e.state):e.dispatch(e.state.tr.deleteSelection()),!0}return!1}}lt.compositionstart=lt.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:n}=t,o=n.selection.$to;if(n.selection instanceof e.TextSelection&&(n.storedMarks||!o.textOffset&&o.parentOffset&&o.nodeBefore.marks.some(e=>!1===e.type.spec.inclusive)||O&&k&&function(e){let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(!t||1!=t.nodeType||n>=t.childNodes.length)return!1;let o=t.childNodes[n];return 1==o.nodeType&&"false"==o.contentEditable}(t)))t.markCursor=t.state.storedMarks||o.marks(),Tt(t,!0),t.markCursor=null;else if(Tt(t,!n.selection.empty),N&&n.selection.empty&&o.parentOffset&&!o.textOffset&&o.nodeBefore.marks.length){let e=t.domSelectionRange();for(let n=e.focusNode,o=e.focusOffset;n&&1==n.nodeType&&0!=o;){let e=o<0?n.lastChild:n.childNodes[o-1];if(!e)break;if(3==e.nodeType){let n=t.domSelection();n&&n.collapse(e,e.nodeValue.length);break}n=e,o=-1}}t.input.composing=!0}Ct(t,Ot)},lt.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++,Ct(e,20))};const kt=w&&S<15||M&&A<604;function Et(e,n,o,i,r){let s=Ye(e,n,o,i,e.state.selection.$from);if(e.someProp("handlePaste",n=>n(e,r,s||t.Slice.empty)))return!0;if(!s)return!1;let l=function(e){return 0==e.openStart&&0==e.openEnd&&1==e.content.childCount?e.content.firstChild:null}(s),d=l?e.state.tr.replaceSelectionWith(l,i):e.state.tr.replaceSelection(s);return e.dispatch(d.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Pt(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," "):""}st.copy=lt.cut=(e,t)=>{let n=t,o=e.state.selection,i="cut"==n.type;if(o.empty)return;let r=kt?null:n.clipboardData,s=o.content(),{dom:l,text:d}=je(e,s);r?(n.preventDefault(),r.clearData(),r.setData("text/html",l.innerHTML),r.setData("text/plain",d)):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 o=getSelection(),i=document.createRange();i.selectNodeContents(t),e.dom.blur(),o.removeAllRanges(),o.addRange(i),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),e.focus()},50)}(e,l),i&&e.dispatch(e.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))},lt.paste=(e,t)=>{let n=t;if(e.composing&&!E)return;let o=kt?null:n.clipboardData,i=e.input.shiftKey&&45!=e.input.lastKeyCode;o&&Et(e,Pt(o),o.getData("text/html"),i,n)?n.preventDefault():function(e,t){if(!e.dom.parentNode)return;let n=e.input.shiftKey||e.state.selection.$from.parent.type.spec.code,o=e.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(o.contentEditable="true"),o.style.cssText="position: fixed; left: -10000px; top: 10px",o.focus();let i=e.input.shiftKey&&45!=e.input.lastKeyCode;setTimeout(()=>{e.focus(),o.parentNode&&o.parentNode.removeChild(o),n?Et(e,o.value,null,i,t):Et(e,o.textContent,o.innerHTML,i,t)},50)}(e,n)};class At{constructor(e,t,n){this.slice=e,this.move=t,this.node=n}}const Vt=T?"altKey":"ctrlKey";function Rt(e,t){let n=e.someProp("dragCopies",e=>!e(t));return null!=n?n:!t[Vt]}st.dragstart=(t,n)=>{let o=n,i=t.input.mouseDown;if(i&&i.done(),!o.dataTransfer)return;let r,s=t.state.selection,l=s.empty?null:t.posAtCoords(pt(o));if(l&&l.pos>=s.from&&l.pos<=(s instanceof e.NodeSelection?s.to-1:s.to));else if(i&&i.mightDrag)r=e.NodeSelection.create(t.state.doc,i.mightDrag.pos);else if(o.target&&1==o.target.nodeType){let n=t.docView.nearestDesc(o.target,!0);n&&n.node.type.spec.draggable&&n!=t.docView&&(r=e.NodeSelection.create(t.state.doc,n.posBefore))}let d=(r||t.state.selection).content(),{dom:a,text:c,slice:h}=je(t,d);(!o.dataTransfer.files.length||!O||C>120)&&o.dataTransfer.clearData(),o.dataTransfer.setData(kt?"Text":"text/html",a.innerHTML),o.dataTransfer.effectAllowed="copyMove",kt||o.dataTransfer.setData("text/plain",c),t.dragging=new At(h,Rt(t,o),r)},st.dragend=e=>{let t=e.dragging;window.setTimeout(()=>{e.dragging==t&&(e.dragging=null)},50)},lt.dragover=lt.dragenter=(e,t)=>t.preventDefault(),lt.drop=(o,i)=>{try{!function(o,i,r){if(!i.dataTransfer)return;let s=o.posAtCoords(pt(i));if(!s)return;let l=o.state.doc.resolve(s.pos),d=r&&r.slice;d?o.someProp("transformPasted",e=>{d=e(d,o,!1)}):d=Ye(o,Pt(i.dataTransfer),kt?null:i.dataTransfer.getData("text/html"),!1,l);let a=!(!r||!Rt(o,i));if(o.someProp("handleDrop",e=>e(o,i,d||t.Slice.empty,a)))return void i.preventDefault();if(!d)return;i.preventDefault();let c=d?n.dropPoint(o.state.doc,l.pos,d):l.pos;null==c&&(c=l.pos);let h=o.state.tr;if(a){let{node:e}=r;e?e.replace(h):h.deleteSelection()}let f=h.mapping.map(c),u=0==d.openStart&&0==d.openEnd&&1==d.content.childCount,p=h.doc;u?h.replaceRangeWith(f,f,d.content.firstChild):h.replaceRange(f,f,d);if(h.doc.eq(p))return;let m=h.doc.resolve(f);if(u&&e.NodeSelection.isSelectable(d.content.firstChild)&&m.nodeAfter&&m.nodeAfter.sameMarkup(d.content.firstChild))h.setSelection(new e.NodeSelection(m));else{let e=h.mapping.map(c);h.mapping.maps[h.mapping.maps.length-1].forEach((t,n,o,i)=>e=i),h.setSelection(Ae(o,m,h.doc.resolve(e)))}o.focus(),o.dispatch(h.setMeta("uiEvent","drop"))}(o,i,o.dragging)}finally{o.dragging=null}},st.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())&&Ce(e)},20))},st.blur=(e,t)=>{let n=t;e.focused&&(e.domObserver.stop(),e.dom.classList.remove("ProseMirror-focused"),e.domObserver.start(),n.relatedTarget&&e.dom.contains(n.relatedTarget)&&e.domObserver.currentSelection.clear(),e.focused=!1)},st.beforeinput=(e,t)=>{if(O&&E&&"deleteContentBackward"==t.inputType){e.domObserver.flushSoon();let{domChangeCount:t}=e.input;setTimeout(()=>{if(e.input.domChangeCount!=t)return;if(e.dom.blur(),e.focus(),e.someProp("handleKeyDown",t=>t(e,u(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)}};for(let wn in lt)st[wn]=lt[wn];function Bt(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 zt{constructor(e,t){this.toDOM=e,this.spec=t||$t,this.side=this.spec.side||0}map(e,t,n,o){let{pos:i,deleted:r}=e.mapResult(t.from+o,this.side<0?-1:1);return r?null:new Lt(i-n,i-n,this)}valid(){return!0}eq(e){return this==e||e instanceof zt&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Bt(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Ft{constructor(e,t){this.attrs=e,this.spec=t||$t}map(e,t,n,o){let i=e.map(t.from+o,this.spec.inclusiveStart?-1:1)-n,r=e.map(t.to+o,this.spec.inclusiveEnd?1:-1)-n;return i>=r?null:new Lt(i,r,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof Ft&&Bt(this.attrs,e.attrs)&&Bt(this.spec,e.spec)}static is(e){return e.type instanceof Ft}destroy(){}}class It{constructor(e,t){this.attrs=e,this.spec=t||$t}map(e,t,n,o){let i=e.mapResult(t.from+o,1);if(i.deleted)return null;let r=e.mapResult(t.to+o,-1);return r.deleted||r.pos<=i.pos?null:new Lt(i.pos-n,r.pos-n,this)}valid(e,t){let n,{index:o,offset:i}=e.content.findIndex(t.from);return i==t.from&&!(n=e.child(o)).isText&&i+n.nodeSize==t.to}eq(e){return this==e||e instanceof It&&Bt(this.attrs,e.attrs)&&Bt(this.spec,e.spec)}destroy(){}}class Lt{constructor(e,t,n){this.from=e,this.to=t,this.type=n}copy(e,t){return new Lt(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 Lt(e,e,new zt(t,n))}static inline(e,t,n,o){return new Lt(e,t,new Ft(n,o))}static node(e,t,n,o){return new Lt(e,t,new It(n,o))}get spec(){return this.type.spec}get inline(){return this.type instanceof Ft}get widget(){return this.type instanceof zt}}const qt=[],$t={};class Kt{constructor(e,t){this.local=e.length?e:qt,this.children=t.length?t:qt}static create(e,t){return t.length?jt(t,e,0,$t):Wt}find(e,t,n){let o=[];return this.findInner(null==e?0:e,null==t?1e9:t,o,0,n),o}findInner(e,t,n,o,i){for(let r=0;r<this.local.length;r++){let s=this.local[r];s.from<=t&&s.to>=e&&(!i||i(s.spec))&&n.push(s.copy(s.from+o,s.to+o))}for(let r=0;r<this.children.length;r+=3)if(this.children[r]<t&&this.children[r+1]>e){let s=this.children[r]+1;this.children[r+2].findInner(e-s,t-s,n,o+s,i)}}map(e,t,n){return this==Wt||0==e.maps.length?this:this.mapInner(e,t,0,0,n||$t)}mapInner(e,t,n,o,i){let r;for(let s=0;s<this.local.length;s++){let l=this.local[s].map(e,n,o);l&&l.type.valid(t,l)?(r||(r=[])).push(l):i.onRemove&&i.onRemove(this.local[s].spec)}return this.children.length?function(e,t,n,o,i,r,s){let l=e.slice();for(let a=0,c=r;a<n.maps.length;a++){let e=0;n.maps[a].forEach((t,n,o,i)=>{let r=i-o-(n-t);for(let s=0;s<l.length;s+=3){let o=l[s+1];if(o<0||t>o+c-e)continue;let i=l[s]+c-e;n>=i?l[s+1]=t<=i?-2:-1:t>=c&&r&&(l[s]+=r,l[s+1]+=r)}e+=r}),c=n.maps[a].map(c,-1)}let d=!1;for(let a=0;a<l.length;a+=3)if(l[a+1]<0){if(-2==l[a+1]){d=!0,l[a+1]=-1;continue}let t=n.map(e[a]+r),c=t-i;if(c<0||c>=o.content.size){d=!0;continue}let h=n.map(e[a+1]+r,-1)-i,{index:f,offset:u}=o.content.findIndex(c),p=o.maybeChild(f);if(p&&u==c&&u+p.nodeSize==h){let o=l[a+2].mapInner(n,p,t+1,e[a]+r+1,s);o!=Wt?(l[a]=c,l[a+1]=h,l[a+2]=o):(l[a+1]=-2,d=!0)}else d=!0}if(d){let d=function(e,t,n,o,i,r,s){function l(e,t){for(let r=0;r<e.local.length;r++){let l=e.local[r].map(o,i,t);l?n.push(l):s.onRemove&&s.onRemove(e.local[r].spec)}for(let n=0;n<e.children.length;n+=3)l(e.children[n+2],e.children[n]+t+1)}for(let d=0;d<e.length;d+=3)-1==e[d+1]&&l(e[d+2],t[d]+r+1);return n}(l,e,t,n,i,r,s),a=jt(d,o,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 Kt(t.sort(Yt),l)}(this.children,r||[],e,t,n,o,i):r?new Kt(r.sort(Yt),qt):Wt}add(e,t){return t.length?this==Wt?Kt.create(e,t):this.addInner(e,t,0):this}addInner(e,t,n){let o,i=0;e.forEach((e,r)=>{let s,l=r+n;if(s=Gt(t,e,l)){for(o||(o=this.children.slice());i<o.length&&o[i]<r;)i+=3;o[i]==r?o[i+2]=o[i+2].addInner(e,s,l+1):o.splice(i,0,r,r+e.nodeSize,jt(s,e,l+1,$t)),i+=3}});let r=_t(i?Ut(t):t,-n);for(let s=0;s<r.length;s++)r[s].type.valid(e,r[s])||r.splice(s--,1);return new Kt(r.length?this.local.concat(r).sort(Yt):this.local,o||this.children)}remove(e){return 0==e.length||this==Wt?this:this.removeInner(e,0)}removeInner(e,t){let n=this.children,o=this.local;for(let i=0;i<n.length;i+=3){let o,r=n[i]+t,s=n[i+1]+t;for(let t,n=0;n<e.length;n++)(t=e[n])&&t.from>r&&t.to<s&&(e[n]=null,(o||(o=[])).push(t));if(!o)continue;n==this.children&&(n=this.children.slice());let l=n[i+2].removeInner(o,r+1);l!=Wt?n[i+2]=l:(n.splice(i,3),i-=3)}if(o.length)for(let i,r=0;r<e.length;r++)if(i=e[r])for(let e=0;e<o.length;e++)o[e].eq(i,t)&&(o==this.local&&(o=this.local.slice()),o.splice(e--,1));return n==this.children&&o==this.local?this:o.length||n.length?new Kt(o,n):Wt}forChild(e,t){if(this==Wt)return this;if(t.isLeaf)return Kt.empty;let n,o;for(let s=0;s<this.children.length;s+=3)if(this.children[s]>=e){this.children[s]==e&&(n=this.children[s+2]);break}let i=e+1,r=i+t.content.size;for(let s=0;s<this.local.length;s++){let e=this.local[s];if(e.from<r&&e.to>i&&e.type instanceof Ft){let t=Math.max(i,e.from)-i,n=Math.min(r,e.to)-i;t<n&&(o||(o=[])).push(e.copy(t,n))}}if(o){let e=new Kt(o.sort(Yt),qt);return n?new Ht([e,n]):e}return n||Wt}eq(e){if(this==e)return!0;if(!(e instanceof Kt)||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 Xt(this.localsInner(e))}localsInner(e){if(this==Wt)return qt;if(e.inlineContent||!this.local.some(Ft.is))return this.local;let t=[];for(let n=0;n<this.local.length;n++)this.local[n].type instanceof Ft||t.push(this.local[n]);return t}forEachSet(e){e(this)}}Kt.empty=new Kt([],[]),Kt.removeOverlap=Xt;const Wt=Kt.empty;class Ht{constructor(e){this.members=e}map(e,t){const n=this.members.map(n=>n.map(e,t,$t));return Ht.from(n)}forChild(e,t){if(t.isLeaf)return Kt.empty;let n=[];for(let o=0;o<this.members.length;o++){let i=this.members[o].forChild(e,t);i!=Wt&&(i instanceof Ht?n=n.concat(i.members):n.push(i))}return Ht.from(n)}eq(e){if(!(e instanceof Ht)||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 o=0;o<this.members.length;o++){let i=this.members[o].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?Xt(n?t:t.sort(Yt)):qt}static from(e){switch(e.length){case 0:return Wt;case 1:return e[0];default:return new Ht(e.every(e=>e instanceof Kt)?e:e.reduce((e,t)=>e.concat(t instanceof Kt?t:t.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}}function _t(e,t){if(!t||!e.length)return e;let n=[];for(let o=0;o<e.length;o++){let i=e[o];n.push(new Lt(i.from+t,i.to+t,i.type))}return n}function Gt(e,t,n){if(t.isLeaf)return null;let o=n+t.nodeSize,i=null;for(let r,s=0;s<e.length;s++)(r=e[s])&&r.from>n&&r.to<o&&((i||(i=[])).push(r),e[s]=null);return i}function Ut(e){let t=[];for(let n=0;n<e.length;n++)null!=e[n]&&t.push(e[n]);return t}function jt(e,t,n,o){let i=[],r=!1;t.forEach((t,s)=>{let l=Gt(e,t,s+n);if(l){r=!0;let e=jt(l,t,n+s+1,o);e!=Wt&&i.push(s,s+t.nodeSize,e)}});let s=_t(r?Ut(e):e,-n).sort(Yt);for(let l=0;l<s.length;l++)s[l].type.valid(t,s[l])||(o.onRemove&&o.onRemove(s[l].spec),s.splice(l--,1));return s.length||i.length?new Kt(s,i):Wt}function Yt(e,t){return e.from-t.from||e.to-t.to}function Xt(e){let t=e;for(let n=0;n<t.length-1;n++){let o=t[n];if(o.from!=o.to)for(let i=n+1;i<t.length;i++){let r=t[i];if(r.from!=o.from){r.from<o.to&&(t==e&&(t=e.slice()),t[n]=o.copy(o.from,r.from),Jt(t,i,o.copy(r.from,o.to)));break}r.to!=o.to&&(t==e&&(t=e.slice()),t[i]=r.copy(r.from,o.to),Jt(t,i+1,r.copy(o.to,r.to)))}}return t}function Jt(e,t,n){for(;t<e.length&&Yt(n,e[t])>0;)t++;e.splice(t,0,n)}function Qt(e){let t=[];return e.someProp("decorations",n=>{let o=n(e.state);o&&o!=Wt&&t.push(o)}),e.cursorWrapper&&t.push(Kt.create(e.state.doc,[e.cursorWrapper.deco])),Ht.from(t)}const Zt={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},en=w&&S<=11;class tn{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 nn{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new tn,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]);w&&S<=11&&t.some(e=>"childList"==e.type&&e.removedNodes.length||"characterData"==e.type&&e.oldValue.length>e.target.nodeValue.length)?this.flushSoon():x&&e.composing&&t.some(e=>"childList"==e.type&&"TR"==e.target.nodeName)?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),en&&(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,Zt)),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(Ve(this.view)){if(this.suppressingSelectionUpdates)return Ce(this.view);if(w&&S<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&l(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,n=new Set;for(let r=e.focusNode;r;r=i(r))n.add(r);for(let r=e.anchorNode;r;r=i(r))if(n.has(r)){t=r;break}let o=t&&this.view.docView.nearestDesc(t);return o&&o.ignoreMutation({type:"selection",target:3==t.nodeType?t.parentNode:t})?(this.setCurSelection(),!0):void 0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:t}=this;if(!t.docView||this.flushingSoon>-1)return;let n=this.pendingRecords();n.length&&(this.queue=[]);let o=t.domSelectionRange(),i=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(o)&&Ve(t)&&!this.ignoreSelectionChange(o),r=-1,s=-1,l=!1,d=[];if(t.editable)for(let e=0;e<n.length;e++){let t=this.registerMutation(n[e],d);t&&(r=r<0?t.from:Math.min(t.from,r),s=s<0?t.to:Math.max(t.to,s),t.typeOver&&(l=!0))}if(!d.some(e=>"BR"==e.nodeName)||8!=t.input.lastKeyCode&&46!=t.input.lastKeyCode){if(N&&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:n}=this.currentSelection;for(let o of e){let e=o.parentNode;!e||"LI"!=e.nodeName||n&&ln(t,n)==e||o.remove()}}}}else 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 a=null;r<0&&i&&t.input.lastFocus>Date.now()-200&&Math.max(t.input.lastTouch,t.input.lastClick.time)<Date.now()-300&&f(o)&&(a=De(t))&&a.eq(e.Selection.near(t.state.doc.resolve(0),1))?(t.input.lastFocus=0,Ce(t),this.currentSelection.set(o),t.scrollToSelection()):(r>-1||i)&&(r>-1&&(t.docView.markDirty(r,s),function(e){if(on.has(e))return;if(on.set(e,null),-1!==["normal","nowrap","pre-line"].indexOf(getComputedStyle(e.dom).whiteSpace)){if(e.requiresGeckoHackNode=N,rn)return;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."),rn=!0}}(t)),t.input.badSafariComposition&&(t.input.badSafariComposition=!1,function(e,t){var n;let{focusNode:o,focusOffset:i}=e.domSelectionRange();for(let r of t)if("TR"==(null===(n=r.parentNode)||void 0===n?void 0:n.nodeName)){let t=r.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(r,n.firstChild),o==r&&e.domSelection().collapse(r,i)}else r.parentNode.removeChild(r)}}(t,d)),this.handleDOMChange(r,s,l,d),t.docView&&t.docView.dirty?t.updateState(t.state):this.currentSelection.eq(o)||Ce(t),this.currentSelection.set(o))}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")))return null;if(!n||n.ignoreMutation(e))return null;if("childList"==e.type){for(let n=0;n<e.addedNodes.length;n++){let o=e.addedNodes[n];t.push(o),3==o.nodeType&&(this.lastChangedTextNode=o)}if(n.contentDOM&&n.contentDOM!=n.dom&&!n.contentDOM.contains(e.target))return{from:n.posBefore,to:n.posAfter};let i=e.previousSibling,r=e.nextSibling;if(w&&S<=11&&e.addedNodes.length)for(let t=0;t<e.addedNodes.length;t++){let{previousSibling:n,nextSibling:o}=e.addedNodes[t];(!n||Array.prototype.indexOf.call(e.addedNodes,n)<0)&&(i=n),(!o||Array.prototype.indexOf.call(e.addedNodes,o)<0)&&(r=o)}let s=i&&i.parentNode==e.target?o(i)+1:0,l=n.localPosFromDOM(e.target,s,-1),d=r&&r.parentNode==e.target?o(r):e.target.childNodes.length;return{from:l,to:n.localPosFromDOM(e.target,d,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 on=new WeakMap,rn=!1;function sn(e,t){let n=t.startContainer,o=t.startOffset,i=t.endContainer,r=t.endOffset,s=e.domAtPos(e.state.selection.anchor);return l(s.node,s.offset,i,r)&&([n,o,i,r]=[i,r,n,o]),{anchorNode:n,anchorOffset:o,focusNode:i,focusOffset:r}}function ln(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}function dn(e){let t=e.pmViewDesc;if(t)return t.parseRule();if("BR"==e.nodeName&&e.parentNode){if(x&&/^(ul|ol)$/i.test(e.parentNode.nodeName)){let e=document.createElement("div");return e.appendChild(document.createElement("li")),{skip:e}}if(e.parentNode.lastChild==e||x&&/^(tr|table)$/i.test(e.parentNode.nodeName))return{ignore:!0}}else if("IMG"==e.nodeName&&e.getAttribute("mark-placeholder"))return{ignore:!0};return null}const an=/^(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 cn(n,o,i,r,s){let l=n.input.compositionPendingChanges||(n.composing?n.input.compositionID:0);if(n.input.compositionPendingChanges=0,o<0){let e=n.input.lastSelectionTime>Date.now()-50?n.input.lastSelectionOrigin:null,t=De(n,e);if(t&&!n.state.selection.eq(t)){if(O&&E&&13===n.input.lastKeyCode&&Date.now()-100<n.input.lastKeyCodeTime&&n.someProp("handleKeyDown",e=>e(n,u(13,"Enter"))))return;let o=n.state.tr.setSelection(t);"pointer"==e?o.setMeta("pointer",!0):"key"==e&&o.scrollIntoView(),l&&o.setMeta("composition",l),n.dispatch(o)}return}let d=n.state.doc.resolve(o),a=d.sharedDepth(i);o=d.before(a+1),i=n.state.doc.resolve(i).after(a+1);let c,h,p=n.state.selection,m=function(e,n,o){let i,{node:r,fromOffset:s,toOffset:l,from:d,to:a}=e.docView.parseRange(n,o),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})),O&&8===e.input.lastKeyCode)for(let t=l;t>s;t--){let e=r.childNodes[t-1],n=e.pmViewDesc;if("BR"==e.nodeName&&!n){l=t;break}if(!n||n.size)break}let u=e.state.doc,p=e.someProp("domParser")||t.DOMParser.fromSchema(e.state.schema),m=u.resolve(d),g=null,y=p.parse(r,{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:dn,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+d,head:t+d}}return{doc:y,sel:g,from:d,to:a}}(n,o,i),g=n.state.doc,y=g.slice(m.from,m.to);8===n.input.lastKeyCode&&Date.now()-100<n.input.lastKeyCodeTime?(c=n.state.selection.to,h="end"):(c=n.state.selection.from,h="start"),n.input.lastKeyCode=null;let b=function(e,t,n,o,i){let r=e.findDiffStart(t,n);if(null==r)return null;let{a:s,b:l}=e.findDiffEnd(t,n+e.size,n+t.size);if("end"==i){o-=s+Math.max(0,r-Math.min(s,l))-r}if(s<r&&e.size<t.size){let e=o<=r&&o>=s?r-o:0;r-=e,r&&r<t.size&&un(t.textBetween(r-1,r+1))&&(r+=e?1:-1),l=r+(l-s),s=r}else if(l<r){let t=o<=r&&o>=l?r-o:0;r-=t,r&&r<e.size&&un(e.textBetween(r-1,r+1))&&(r+=t?1:-1),s=r+(s-l),l=r}return{start:r,endA:s,endB:l}}(y.content,m.doc.content,m.from,c,h);if(b&&n.input.domChangeCount++,(M&&n.input.lastIOSEnter>Date.now()-225||E)&&s.some(e=>1==e.nodeType&&!an.test(e.nodeName))&&(!b||b.endA>=b.endB)&&n.someProp("handleKeyDown",e=>e(n,u(13,"Enter"))))return void(n.input.lastIOSEnter=0);if(!b){if(!(r&&p instanceof e.TextSelection&&!p.empty&&p.$head.sameParent(p.$anchor))||n.composing||m.sel&&m.sel.anchor!=m.sel.head){if(m.sel){let e=hn(n,n.state.doc,m.sel);if(e&&!e.eq(n.state.selection)){let t=n.state.tr.setSelection(e);l&&t.setMeta("composition",l),n.dispatch(t)}}return}b={start:p.from,endA:p.to,endB:p.to}}n.state.selection.from<n.state.selection.to&&b.start==b.endB&&n.state.selection instanceof e.TextSelection&&(b.start>n.state.selection.from&&b.start<=n.state.selection.from+2&&n.state.selection.from>=m.from?b.start=n.state.selection.from:b.endA<n.state.selection.to&&b.endA>=n.state.selection.to-2&&n.state.selection.to<=m.to&&(b.endB+=n.state.selection.to-b.endA,b.endA=n.state.selection.to)),w&&S<=11&&b.endB==b.start+1&&b.endA==b.start&&b.start>m.from&&"  "==m.doc.textBetween(b.start-m.from-1,b.start-m.from+1)&&(b.start--,b.endA--,b.endB--);let v=m.doc.resolveNoCache(b.start-m.from),N=m.doc.resolveNoCache(b.endB-m.from),D=g.resolve(b.start),C=v.sameParent(N)&&v.parent.inlineContent&&D.end()>=b.endA;if((M&&n.input.lastIOSEnter>Date.now()-225&&(!C||s.some(e=>"DIV"==e.nodeName||"P"==e.nodeName))||!C&&v.pos<m.doc.content.size&&(!v.sameParent(N)||!v.parent.inlineContent)&&v.pos<N.pos&&!/\S/.test(m.doc.textBetween(v.pos,N.pos,"","")))&&n.someProp("handleKeyDown",e=>e(n,u(13,"Enter"))))return void(n.input.lastIOSEnter=0);if(n.state.selection.anchor>b.start&&function(e,t,n,o,i){if(n-t<=i.pos-o.pos||fn(o,!0,!1)<i.pos)return!1;let r=e.resolve(t);if(!o.parent.isTextblock){let e=r.nodeAfter;return null!=e&&n==t+e.nodeSize}if(r.parentOffset<r.parent.content.size||!r.parent.isTextblock)return!1;let s=e.resolve(fn(r,!0,!0));return!(!s.parent.isTextblock||s.pos>n||fn(s,!0,!1)<n)&&o.parent.content.cut(o.parentOffset).eq(s.parent.content)}(g,b.start,b.endA,v,N)&&n.someProp("handleKeyDown",e=>e(n,u(8,"Backspace"))))return void(E&&O&&n.domObserver.suppressSelectionUpdates());O&&b.endB==b.start&&(n.input.lastChromeDelete=Date.now()),E&&!C&&v.start()!=N.start()&&0==N.parentOffset&&v.depth==N.depth&&m.sel&&m.sel.anchor==m.sel.head&&m.sel.head==b.endA&&(b.endB-=2,N=m.doc.resolveNoCache(b.endB-m.from),setTimeout(()=>{n.someProp("handleKeyDown",function(e){return e(n,u(13,"Enter"))})},20));let x,T=b.start,k=b.endA,P=e=>{let t=e||n.state.tr.replace(T,k,m.doc.slice(b.start-m.from,b.endB-m.from));if(m.sel){let e=hn(n,t.doc,m.sel);e&&!(O&&n.composing&&e.empty&&(b.start!=b.endB||n.input.lastChromeDelete<Date.now()-100)&&(e.head==T||e.head==t.mapping.map(k)-1)||w&&e.empty&&e.head==T)&&t.setSelection(e)}return l&&t.setMeta("composition",l),t.scrollIntoView()};if(C)if(v.pos==N.pos){w&&S<=11&&0==v.parentOffset&&(n.domObserver.suppressSelectionUpdates(),setTimeout(()=>Ce(n),20));let e=P(n.state.tr.delete(T,k)),t=g.resolve(b.start).marksAcross(g.resolve(b.endA));t&&e.ensureMarks(t),n.dispatch(e)}else if(b.endA==b.endB&&(x=function(e,n){let o,i,r,s=e.firstChild.marks,l=n.firstChild.marks,d=s,a=l;for(let t=0;t<l.length;t++)d=l[t].removeFromSet(d);for(let t=0;t<s.length;t++)a=s[t].removeFromSet(a);if(1==d.length&&0==a.length)i=d[0],o="add",r=e=>e.mark(i.addToSet(e.marks));else{if(0!=d.length||1!=a.length)return null;i=a[0],o="remove",r=e=>e.mark(i.removeFromSet(e.marks))}let c=[];for(let t=0;t<n.childCount;t++)c.push(r(n.child(t)));if(t.Fragment.from(c).eq(e))return{mark:i,type:o}}(v.parent.content.cut(v.parentOffset,N.parentOffset),D.parent.content.cut(D.parentOffset,b.endA-D.start())))){let e=P(n.state.tr);"add"==x.type?e.addMark(T,k,x.mark):e.removeMark(T,k,x.mark),n.dispatch(e)}else if(v.parent.child(v.index()).isText&&v.index()==N.index()-(N.textOffset?0:1)){let e=v.parent.textBetween(v.parentOffset,N.parentOffset),t=()=>P(n.state.tr.insertText(e,T,k));n.someProp("handleTextInput",o=>o(n,T,k,e,t))||n.dispatch(t())}else n.dispatch(P());else n.dispatch(P())}function hn(e,t,n){return Math.max(n.anchor,n.head)>t.content.size?null:Ae(e,t.resolve(n.anchor),t.resolve(n.head))}function fn(e,t,n){let o=e.depth,i=t?e.end():e.pos;for(;o>0&&(t||e.indexAfter(o)==e.node(o).childCount);)o--,i++,t=!1;if(n){let t=e.node(o).maybeChild(e.indexAfter(o));for(;t&&!t.isLeaf;)t=t.firstChild,i++}return i}function un(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 pn{constructor(e,t){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 at,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(vn),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=yn(this),gn(this),this.nodeViews=bn(this),this.docView=le(this.state.doc,mn(this),Qt(this),this.dom,this),this.domObserver=new nn(this,(e,t,n,o)=>cn(this,e,t,n,o)),this.domObserver.start(),function(e){for(let t in st){let n=st[t];e.dom.addEventListener(t,e.input.eventHandlers[t]=t=>{!ut(e,t)||ft(e,t)||!e.editable&&t.type in lt||n(e,t)},dt[t]?{passive:!0}:void 0)}x&&e.dom.addEventListener("input",()=>null),ht(e)}(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let t in e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&ht(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(vn),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let n in this._props)t[n]=this._props[n];t.state=this.state;for(let n in e)t[n]=e[n];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var n;let o=this.state,i=!1,r=!1;e.storedMarks&&this.composing&&(xt(this),r=!0),this.state=e;let s=o.plugins!=e.plugins||this._props.plugins!=t.plugins;if(s||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let e=bn(this);(function(e,t){let n=0,o=0;for(let i in e){if(e[i]!=t[i])return!0;n++}for(let i in t)o++;return n!=o})(e,this.nodeViews)&&(this.nodeViews=e,i=!0)}(s||t.handleDOMEvents!=this._props.handleDOMEvents)&&ht(this),this.editable=yn(this),gn(this);let d=Qt(this),a=mn(this),c=o.plugins==e.plugins||o.doc.eq(e.doc)?e.scrollToSelection>o.scrollToSelection?"to selection":"preserve":"reset",h=i||!this.docView.matchesNode(e.doc,a,d);!h&&e.selection.eq(o.selection)||(r=!0);let f="preserve"==c&&r&&null==this.dom.style.overflowAnchor&&function(e){let t,n,o=e.dom.getBoundingClientRect(),i=Math.max(0,o.top);for(let r=(o.left+o.right)/2,s=i+1;s<Math.min(innerHeight,o.bottom);s+=5){let o=e.root.elementFromPoint(r,s);if(!o||o==e.dom||!e.dom.contains(o))continue;let l=o.getBoundingClientRect();if(l.top>=i-20){t=o,n=l.top;break}}return{refDOM:t,refTop:n,stack:F(e.dom)}}(this);if(r){this.domObserver.stop();let t=h&&(w||O)&&!this.composing&&!o.selection.empty&&!e.selection.empty&&function(e,t){let n=Math.min(e.$anchor.sharedDepth(e.head),t.$anchor.sharedDepth(t.head));return e.$anchor.start(n)!=t.$anchor.start(n)}(o.selection,e.selection);if(h){let n=O?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=Mt(this)),!i&&this.docView.update(e.doc,a,d,this)||(this.docView.updateOuterDeco(a),this.docView.destroy(),this.docView=le(e.doc,a,d,this.dom,this)),!n||this.trackWrites&&this.dom.contains(this.trackWrites)||(t=!0)}t||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&function(e){let t=e.docView.domFromPos(e.state.selection.anchor,0),n=e.domSelectionRange();return l(t.node,t.offset,n.anchorNode,n.anchorOffset)}(this))?Ce(this,t):(Ee(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(o),(null===(n=this.dragging)||void 0===n?void 0:n.node)&&!o.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,o),"reset"==c?this.dom.scrollTop=0:"to selection"==c?this.scrollToSelection():f&&function({refDOM:e,refTop:t,stack:n}){let o=e?e.getBoundingClientRect().top:0;I(n,0==o?0:o-t)}(f)}scrollToSelection(){let t=this.domSelectionRange().focusNode;if(t&&this.dom.contains(1==t.nodeType?t:t.parentNode))if(this.someProp("handleScrollToSelection",e=>e(this)));else if(this.state.selection instanceof e.NodeSelection){let e=this.docView.domAfterPos(this.state.selection.from);1==e.nodeType&&z(this,e.getBoundingClientRect(),t)}else z(this,this.coordsAtPos(this.state.selection.head,1),t);else;}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(t,n){let o=t.node,i=-1;if(this.state.doc.nodeAt(o.from)==o.node)i=o.from;else{let e=o.from+(this.state.doc.content.size-n.doc.content.size);(e>0&&this.state.doc.nodeAt(e))==o.node&&(i=e)}this.dragging=new At(t.slice,t.move,i<0?void 0:e.NodeSelection.create(this.state.doc,i))}someProp(e,t){let n,o=this._props&&this._props[e];if(null!=o&&(n=t?t(o):o))return n;for(let r=0;r<this.directPlugins.length;r++){let o=this.directPlugins[r].props[e];if(null!=o&&(n=t?t(o):o))return n}let i=this.state.plugins;if(i)for(let r=0;r<i.length;r++){let o=i[r].props[e];if(null!=o&&(n=t?t(o):o))return n}}hasFocus(){if(w){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(L)return e.focus(L);let t=F(e);e.focus(null==L?{get preventScroll(){return L={preventScroll:!0},!0}}:void 0),L||(L=!1,I(t,0))}(this.dom),Ce(this),this.domObserver.start()}get root(){let e=this._root;if(null==e)for(let t=this.dom.parentNode;t;t=t.parentNode)if(9==t.nodeType||11==t.nodeType&&t.host)return t.getSelection||(Object.getPrototypeOf(t).getSelection=()=>t.ownerDocument.getSelection()),this._root=t;return e||document}updateRoot(){this._root=null}posAtCoords(e){return W(this,e)}coordsAtPos(e,t=1){return U(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 o=this.docView.posFromDOM(e,t,n);if(null==o)throw new RangeError("DOM position not inside the editor");return o}endOfTextblock(e,t){return te(this,t||this.state,e)}pasteHTML(e,t){return Et(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return Et(this,e,null,!0,t||new ClipboardEvent("paste"))}serializeForClipboard(e){return je(this,e)}destroy(){this.docView&&(!function(e){e.domObserver.stop();for(let t in e.input.eventHandlers)e.dom.removeEventListener(t,e.input.eventHandlers[t]);clearTimeout(e.input.composingTimeout),clearTimeout(e.input.lastIOSEnterFallbackTimeout)}(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Qt(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,r=null)}get isDestroyed(){return null==this.docView}dispatchEvent(e){return function(e,t){ft(e,t)||!st[t.type]||!e.editable&&t.type in lt||st[t.type](e,t)}(this,e)}domSelectionRange(){let e=this.domSelection();return e?x&&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){if(t.getComposedRanges){let n=t.getComposedRanges(e.root)[0];if(n)return sn(e,n)}let n;function o(e){e.preventDefault(),e.stopImmediatePropagation(),n=e.getTargetRanges()[0]}return e.dom.addEventListener("beforeinput",o,!0),document.execCommand("indent"),e.dom.removeEventListener("beforeinput",o,!0),n?sn(e,n):null}(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}function mn(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"),[Lt.node(0,e.state.doc.content.size,t)]}function gn(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:Lt.widget(e.state.selection.from,t,{raw:!0,marks:e.markCursor})}}else e.cursorWrapper=null}function yn(e){return!e.someProp("editable",t=>!1===t(e.state))}function bn(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 vn(e){if(e.spec.state||e.spec.filterTransaction||e.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}pn.prototype.dispatch=function(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))},exports.Decoration=Lt,exports.DecorationSet=Kt,exports.EditorView=pn;