text: (()=>{"use strict";function t(t){this.content=t}t.prototype={constructor:t,find:function(t){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===t)return e;return-1},get:function(t){var e=this.find(t);return-1==e?void 0:this.content[e+1]},update:function(e,n,r){var o=r&&r!=e?this.remove(r):this,i=o.find(e),s=o.content.slice();return-1==i?s.push(r||e,n):(s[i+1]=n,r&&(s[i]=r)),new t(s)},remove:function(e){var n=this.find(e);if(-1==n)return this;var r=this.content.slice();return r.splice(n,2),new t(r)},addToStart:function(e,n){return new t([e,n].concat(this.remove(e).content))},addToEnd:function(e,n){var r=this.remove(e).content.slice();return r.push(e,n),new t(r)},addBefore:function(e,n,r){var o=this.remove(n),i=o.content.slice(),s=o.find(e);return i.splice(-1==s?i.length:s,0,n,r),new t(i)},forEach:function(t){for(var e=0;e<this.content.length;e+=2)t(this.content[e],this.content[e+1])},prepend:function(e){return(e=t.from(e)).size?new t(e.content.concat(this.subtract(e).content)):this},append:function(e){return(e=t.from(e)).size?new t(this.subtract(e).content.concat(e.content)):this},subtract:function(e){var n=this;e=t.from(e);for(var r=0;r<e.content.length;r+=2)n=n.remove(e.content[r]);return n},get size(){return this.content.length>>1}},t.from=function(e){if(e instanceof t)return e;var n=[];if(e)for(var r in e)n.push(r,e[r]);return new t(n)};const e=t;function n(t,e,r){for(var o=0;;o++){if(o==t.childCount||o==e.childCount)return t.childCount==e.childCount?null:r;var i=t.child(o),s=e.child(o);if(i!=s){if(!i.sameMarkup(s))return r;if(i.isText&&i.text!=s.text){for(var a=0;i.text[a]==s.text[a];a++)r++;return r}if(i.content.size||s.content.size){var c=n(i.content,s.content,r+1);if(null!=c)return c}r+=i.nodeSize}else r+=i.nodeSize}}function r(t,e,n,o){for(var i=t.childCount,s=e.childCount;;){if(0==i||0==s)return i==s?null:{a:n,b:o};var a=t.child(--i),c=e.child(--s),l=a.nodeSize;if(a!=c){if(!a.sameMarkup(c))return{a:n,b:o};if(a.isText&&a.text!=c.text){for(var h=0,p=Math.min(a.text.length,c.text.length);h<p&&a.text[a.text.length-h-1]==c.text[c.text.length-h-1];)h++,n--,o--;return{a:n,b:o}}if(a.content.size||c.content.size){var f=r(a.content,c.content,n-1,o-1);if(f)return f}n-=l,o-=l}else n-=l,o-=l}}var o=function(t,e){if(this.content=t,this.size=e||0,null==e)for(var n=0;n<t.length;n++)this.size+=t[n].nodeSize},i={firstChild:{configurable:!0},lastChild:{configurable:!0},childCount:{configurable:!0}};o.prototype.nodesBetween=function(t,e,n,r,o){void 0===r&&(r=0);for(var i=0,s=0;s<e;i++){var a=this.content[i],c=s+a.nodeSize;if(c>t&&!1!==n(a,r+s,o,i)&&a.content.size){var l=s+1;a.nodesBetween(Math.max(0,t-l),Math.min(a.content.size,e-l),n,r+l)}s=c}},o.prototype.descendants=function(t){this.nodesBetween(0,this.size,t)},o.prototype.textBetween=function(t,e,n,r){var o="",i=!0;return this.nodesBetween(t,e,(function(s,a){s.isText?(o+=s.text.slice(Math.max(t,a)-a,e-a),i=!n):s.isLeaf&&r?(o+=r,i=!n):!i&&s.isBlock&&(o+=n,i=!0)}),0),o},o.prototype.append=function(t){if(!t.size)return this;if(!this.size)return t;var e=this.lastChild,n=t.firstChild,r=this.content.slice(),i=0;for(e.isText&&e.sameMarkup(n)&&(r[r.length-1]=e.withText(e.text+n.text),i=1);i<t.content.length;i++)r.push(t.content[i]);return new o(r,this.size+t.size)},o.prototype.cut=function(t,e){if(null==e&&(e=this.size),0==t&&e==this.size)return this;var n=[],r=0;if(e>t)for(var i=0,s=0;s<e;i++){var a=this.content[i],c=s+a.nodeSize;c>t&&((s<t||c>e)&&(a=a.isText?a.cut(Math.max(0,t-s),Math.min(a.text.length,e-s)):a.cut(Math.max(0,t-s-1),Math.min(a.content.size,e-s-1))),n.push(a),r+=a.nodeSize),s=c}return new o(n,r)},o.prototype.cutByIndex=function(t,e){return t==e?o.empty:0==t&&e==this.content.length?this:new o(this.content.slice(t,e))},o.prototype.replaceChild=function(t,e){var n=this.content[t];if(n==e)return this;var r=this.content.slice(),i=this.size+e.nodeSize-n.nodeSize;return r[t]=e,new o(r,i)},o.prototype.addToStart=function(t){return new o([t].concat(this.content),this.size+t.nodeSize)},o.prototype.addToEnd=function(t){return new o(this.content.concat(t),this.size+t.nodeSize)},o.prototype.eq=function(t){if(this.content.length!=t.content.length)return!1;for(var e=0;e<this.content.length;e++)if(!this.content[e].eq(t.content[e]))return!1;return!0},i.firstChild.get=function(){return this.content.length?this.content[0]:null},i.lastChild.get=function(){return this.content.length?this.content[this.content.length-1]:null},i.childCount.get=function(){return this.content.length},o.prototype.child=function(t){var e=this.content[t];if(!e)throw new RangeError("Index "+t+" out of range for "+this);return e},o.prototype.maybeChild=function(t){return this.content[t]},o.prototype.forEach=function(t){for(var e=0,n=0;e<this.content.length;e++){var r=this.content[e];t(r,n,e),n+=r.nodeSize}},o.prototype.findDiffStart=function(t,e){return void 0===e&&(e=0),n(this,t,e)},o.prototype.findDiffEnd=function(t,e,n){return void 0===e&&(e=this.size),void 0===n&&(n=t.size),r(this,t,e,n)},o.prototype.findIndex=function(t,e){if(void 0===e&&(e=-1),0==t)return a(0,t);if(t==this.size)return a(this.content.length,t);if(t>this.size||t<0)throw new RangeError("Position "+t+" outside of fragment ("+this+")");for(var n=0,r=0;;n++){var o=r+this.child(n).nodeSize;if(o>=t)return o==t||e>0?a(n+1,o):a(n,r);r=o}},o.prototype.toString=function(){return"<"+this.toStringInner()+">"},o.prototype.toStringInner=function(){return this.content.join(", ")},o.prototype.toJSON=function(){return this.content.length?this.content.map((function(t){return t.toJSON()})):null},o.fromJSON=function(t,e){if(!e)return o.empty;if(!Array.isArray(e))throw new RangeError("Invalid input for Fragment.fromJSON");return new o(e.map(t.nodeFromJSON))},o.fromArray=function(t){if(!t.length)return o.empty;for(var e,n=0,r=0;r<t.length;r++){var i=t[r];n+=i.nodeSize,r&&i.isText&&t[r-1].sameMarkup(i)?(e||(e=t.slice(0,r)),e[e.length-1]=i.withText(e[e.length-1].text+i.text)):e&&e.push(i)}return new o(e||t,n)},o.from=function(t){if(!t)return o.empty;if(t instanceof o)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new o([t],t.nodeSize);throw new RangeError("Can not convert "+t+" to a Fragment"+(t.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))},Object.defineProperties(o.prototype,i);var s={index:0,offset:0};function a(t,e){return s.index=t,s.offset=e,s}function c(t,e){if(t===e)return!0;if(!t||"object"!=typeof t||!e||"object"!=typeof e)return!1;var n=Array.isArray(t);if(Array.isArray(e)!=n)return!1;if(n){if(t.length!=e.length)return!1;for(var r=0;r<t.length;r++)if(!c(t[r],e[r]))return!1}else{for(var o in t)if(!(o in e)||!c(t[o],e[o]))return!1;for(var i in e)if(!(i in t))return!1}return!0}o.empty=new o([],0);var l=function(t,e){this.type=t,this.attrs=e};function h(t){var e=Error.call(this,t);return e.__proto__=h.prototype,e}l.prototype.addToSet=function(t){for(var e,n=!1,r=0;r<t.length;r++){var o=t[r];if(this.eq(o))return t;if(this.type.excludes(o.type))e||(e=t.slice(0,r));else{if(o.type.excludes(this.type))return t;!n&&o.type.rank>this.type.rank&&(e||(e=t.slice(0,r)),e.push(this),n=!0),e&&e.push(o)}}return e||(e=t.slice()),n||e.push(this),e},l.prototype.removeFromSet=function(t){for(var e=0;e<t.length;e++)if(this.eq(t[e]))return t.slice(0,e).concat(t.slice(e+1));return t},l.prototype.isInSet=function(t){for(var e=0;e<t.length;e++)if(this.eq(t[e]))return!0;return!1},l.prototype.eq=function(t){return this==t||this.type==t.type&&c(this.attrs,t.attrs)},l.prototype.toJSON=function(){var t={type:this.type.name};for(var e in this.attrs){t.attrs=this.attrs;break}return t},l.fromJSON=function(t,e){if(!e)throw new RangeError("Invalid input for Mark.fromJSON");var n=t.marks[e.type];if(!n)throw new RangeError("There is no mark type "+e.type+" in this schema");return n.create(e.attrs)},l.sameSet=function(t,e){if(t==e)return!0;if(t.length!=e.length)return!1;for(var n=0;n<t.length;n++)if(!t[n].eq(e[n]))return!1;return!0},l.setFrom=function(t){if(!t||0==t.length)return l.none;if(t instanceof l)return[t];var e=t.slice();return e.sort((function(t,e){return t.type.rank-e.type.rank})),e},l.none=[],h.prototype=Object.create(Error.prototype),h.prototype.constructor=h,h.prototype.name="ReplaceError";var p=function(t,e,n){this.content=t,this.openStart=e,this.openEnd=n},f={size:{configurable:!0}};function d(t,e,n){var r=t.findIndex(e),o=r.index,i=r.offset,s=t.maybeChild(o),a=t.findIndex(n),c=a.index,l=a.offset;if(i==e||s.isText){if(l!=n&&!t.child(c).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(o!=c)throw new RangeError("Removing non-flat range");return t.replaceChild(o,s.copy(d(s.content,e-i-1,n-i-1)))}function u(t,e,n,r){var o=t.findIndex(e),i=o.index,s=o.offset,a=t.maybeChild(i);if(s==e||a.isText)return r&&!r.canReplace(i,i,n)?null:t.cut(0,e).append(n).append(t.cut(e));var c=u(a.content,e-s-1,n);return c&&t.replaceChild(i,a.copy(c))}function m(t,e,n){if(n.openStart>t.depth)throw new h("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new h("Inconsistent open depths");return v(t,e,n,0)}function v(t,e,n,r){var i=t.index(r),s=t.node(r);if(i==e.index(r)&&r<t.depth-n.openStart){var a=v(t,e,n,r+1);return s.copy(s.content.replaceChild(i,a))}if(n.content.size){if(n.openStart||n.openEnd||t.depth!=r||e.depth!=r){var c=function(t,e){for(var n=e.depth-t.openStart,r=e.node(n).copy(t.content),i=n-1;i>=0;i--)r=e.node(i).copy(o.from(r));return{start:r.resolveNoCache(t.openStart+n),end:r.resolveNoCache(r.content.size-t.openEnd-n)}}(n,t);return x(s,k(t,c.start,c.end,e,r))}var l=t.parent,h=l.content;return x(l,h.cut(0,t.parentOffset).append(n.content).append(h.cut(e.parentOffset)))}return x(s,S(t,e,r))}function g(t,e){if(!e.type.compatibleContent(t.type))throw new h("Cannot join "+e.type.name+" onto "+t.type.name)}function y(t,e,n){var r=t.node(n);return g(r,e.node(n)),r}function w(t,e){var n=e.length-1;n>=0&&t.isText&&t.sameMarkup(e[n])?e[n]=t.withText(e[n].text+t.text):e.push(t)}function b(t,e,n,r){var o=(e||t).node(n),i=0,s=e?e.index(n):o.childCount;t&&(i=t.index(n),t.depth>n?i++:t.textOffset&&(w(t.nodeAfter,r),i++));for(var a=i;a<s;a++)w(o.child(a),r);e&&e.depth==n&&e.textOffset&&w(e.nodeBefore,r)}function x(t,e){if(!t.type.validContent(e))throw new h("Invalid content for node "+t.type.name);return t.copy(e)}function k(t,e,n,r,i){var s=t.depth>i&&y(t,e,i+1),a=r.depth>i&&y(n,r,i+1),c=[];return b(null,t,i,c),s&&a&&e.index(i)==n.index(i)?(g(s,a),w(x(s,k(t,e,n,r,i+1)),c)):(s&&w(x(s,S(t,e,i+1)),c),b(e,n,i,c),a&&w(x(a,S(n,r,i+1)),c)),b(r,null,i,c),new o(c)}function S(t,e,n){var r=[];return b(null,t,n,r),t.depth>n&&w(x(y(t,e,n+1),S(t,e,n+1)),r),b(e,null,n,r),new o(r)}f.size.get=function(){return this.content.size-this.openStart-this.openEnd},p.prototype.insertAt=function(t,e){var n=u(this.content,t+this.openStart,e,null);return n&&new p(n,this.openStart,this.openEnd)},p.prototype.removeBetween=function(t,e){return new p(d(this.content,t+this.openStart,e+this.openStart),this.openStart,this.openEnd)},p.prototype.eq=function(t){return this.content.eq(t.content)&&this.openStart==t.openStart&&this.openEnd==t.openEnd},p.prototype.toString=function(){return this.content+"("+this.openStart+","+this.openEnd+")"},p.prototype.toJSON=function(){if(!this.content.size)return null;var t={content:this.content.toJSON()};return this.openStart>0&&(t.openStart=this.openStart),this.openEnd>0&&(t.openEnd=this.openEnd),t},p.fromJSON=function(t,e){if(!e)return p.empty;var n=e.openStart||0,r=e.openEnd||0;if("number"!=typeof n||"number"!=typeof r)throw new RangeError("Invalid input for Slice.fromJSON");return new p(o.fromJSON(t,e.content),n,r)},p.maxOpen=function(t,e){void 0===e&&(e=!0);for(var n=0,r=0,o=t.firstChild;o&&!o.isLeaf&&(e||!o.type.spec.isolating);o=o.firstChild)n++;for(var i=t.lastChild;i&&!i.isLeaf&&(e||!i.type.spec.isolating);i=i.lastChild)r++;return new p(t,n,r)},Object.defineProperties(p.prototype,f),p.empty=new p(o.empty,0,0);var C=function(t,e,n){this.pos=t,this.path=e,this.depth=e.length/3-1,this.parentOffset=n},M={parent:{configurable:!0},doc:{configurable:!0},textOffset:{configurable:!0},nodeAfter:{configurable:!0},nodeBefore:{configurable:!0}};C.prototype.resolveDepth=function(t){return null==t?this.depth:t<0?this.depth+t:t},M.parent.get=function(){return this.node(this.depth)},M.doc.get=function(){return this.node(0)},C.prototype.node=function(t){return this.path[3*this.resolveDepth(t)]},C.prototype.index=function(t){return this.path[3*this.resolveDepth(t)+1]},C.prototype.indexAfter=function(t){return t=this.resolveDepth(t),this.index(t)+(t!=this.depth||this.textOffset?1:0)},C.prototype.start=function(t){return 0==(t=this.resolveDepth(t))?0:this.path[3*t-1]+1},C.prototype.end=function(t){return t=this.resolveDepth(t),this.start(t)+this.node(t).content.size},C.prototype.before=function(t){if(!(t=this.resolveDepth(t)))throw new RangeError("There is no position before the top-level node");return t==this.depth+1?this.pos:this.path[3*t-1]},C.prototype.after=function(t){if(!(t=this.resolveDepth(t)))throw new RangeError("There is no position after the top-level node");return t==this.depth+1?this.pos:this.path[3*t-1]+this.path[3*t].nodeSize},M.textOffset.get=function(){return this.pos-this.path[this.path.length-1]},M.nodeAfter.get=function(){var t=this.parent,e=this.index(this.depth);if(e==t.childCount)return null;var n=this.pos-this.path[this.path.length-1],r=t.child(e);return n?t.child(e).cut(n):r},M.nodeBefore.get=function(){var t=this.index(this.depth),e=this.pos-this.path[this.path.length-1];return e?this.parent.child(t).cut(0,e):0==t?null:this.parent.child(t-1)},C.prototype.posAtIndex=function(t,e){e=this.resolveDepth(e);for(var n=this.path[3*e],r=0==e?0:this.path[3*e-1]+1,o=0;o<t;o++)r+=n.child(o).nodeSize;return r},C.prototype.marks=function(){var t=this.parent,e=this.index();if(0==t.content.size)return l.none;if(this.textOffset)return t.child(e).marks;var n=t.maybeChild(e-1),r=t.maybeChild(e);if(!n){var o=n;n=r,r=o}for(var i=n.marks,s=0;s<i.length;s++)!1!==i[s].type.spec.inclusive||r&&i[s].isInSet(r.marks)||(i=i[s--].removeFromSet(i));return i},C.prototype.marksAcross=function(t){var e=this.parent.maybeChild(this.index());if(!e||!e.isInline)return null;for(var n=e.marks,r=t.parent.maybeChild(t.index()),o=0;o<n.length;o++)!1!==n[o].type.spec.inclusive||r&&n[o].isInSet(r.marks)||(n=n[o--].removeFromSet(n));return n},C.prototype.sharedDepth=function(t){for(var e=this.depth;e>0;e--)if(this.start(e)<=t&&this.end(e)>=t)return e;return 0},C.prototype.blockRange=function(t,e){if(void 0===t&&(t=this),t.pos<this.pos)return t.blockRange(this);for(var n=this.depth-(this.parent.inlineContent||this.pos==t.pos?1:0);n>=0;n--)if(t.pos<=this.end(n)&&(!e||e(this.node(n))))return new T(this,t,n)},C.prototype.sameParent=function(t){return this.pos-this.parentOffset==t.pos-t.parentOffset},C.prototype.max=function(t){return t.pos>this.pos?t:this},C.prototype.min=function(t){return t.pos<this.pos?t:this},C.prototype.toString=function(){for(var t="",e=1;e<=this.depth;e++)t+=(t?"/":"")+this.node(e).type.name+"_"+this.index(e-1);return t+":"+this.parentOffset},C.resolve=function(t,e){if(!(e>=0&&e<=t.content.size))throw new RangeError("Position "+e+" out of range");for(var n=[],r=0,o=e,i=t;;){var s=i.content.findIndex(o),a=s.index,c=s.offset,l=o-c;if(n.push(i,a,r+c),!l)break;if((i=i.child(a)).isText)break;o=l-1,r+=c+1}return new C(e,n,o)},C.resolveCached=function(t,e){for(var n=0;n<O.length;n++){var r=O[n];if(r.pos==e&&r.doc==t)return r}var o=O[N]=C.resolve(t,e);return N=(N+1)%D,o},Object.defineProperties(C.prototype,M);var O=[],N=0,D=12,T=function(t,e,n){this.$from=t,this.$to=e,this.depth=n},E={start:{configurable:!0},end:{configurable:!0},parent:{configurable:!0},startIndex:{configurable:!0},endIndex:{configurable:!0}};E.start.get=function(){return this.$from.before(this.depth+1)},E.end.get=function(){return this.$to.after(this.depth+1)},E.parent.get=function(){return this.$from.node(this.depth)},E.startIndex.get=function(){return this.$from.index(this.depth)},E.endIndex.get=function(){return this.$to.indexAfter(this.depth)},Object.defineProperties(T.prototype,E);var A=Object.create(null),P=function(t,e,n,r){this.type=t,this.attrs=e,this.content=n||o.empty,this.marks=r||l.none},z={nodeSize:{configurable:!0},childCount:{configurable:!0},textContent:{configurable:!0},firstChild:{configurable:!0},lastChild:{configurable:!0},isBlock:{configurable:!0},isTextblock:{configurable:!0},inlineContent:{configurable:!0},isInline:{configurable:!0},isText:{configurable:!0},isLeaf:{configurable:!0},isAtom:{configurable:!0}};z.nodeSize.get=function(){return this.isLeaf?1:2+this.content.size},z.childCount.get=function(){return this.content.childCount},P.prototype.child=function(t){return this.content.child(t)},P.prototype.maybeChild=function(t){return this.content.maybeChild(t)},P.prototype.forEach=function(t){this.content.forEach(t)},P.prototype.nodesBetween=function(t,e,n,r){void 0===r&&(r=0),this.content.nodesBetween(t,e,n,r,this)},P.prototype.descendants=function(t){this.nodesBetween(0,this.content.size,t)},z.textContent.get=function(){return this.textBetween(0,this.content.size,"")},P.prototype.textBetween=function(t,e,n,r){return this.content.textBetween(t,e,n,r)},z.firstChild.get=function(){return this.content.firstChild},z.lastChild.get=function(){return this.content.lastChild},P.prototype.eq=function(t){return this==t||this.sameMarkup(t)&&this.content.eq(t.content)},P.prototype.sameMarkup=function(t){return this.hasMarkup(t.type,t.attrs,t.marks)},P.prototype.hasMarkup=function(t,e,n){return this.type==t&&c(this.attrs,e||t.defaultAttrs||A)&&l.sameSet(this.marks,n||l.none)},P.prototype.copy=function(t){return void 0===t&&(t=null),t==this.content?this:new this.constructor(this.type,this.attrs,t,this.marks)},P.prototype.mark=function(t){return t==this.marks?this:new this.constructor(this.type,this.attrs,this.content,t)},P.prototype.cut=function(t,e){return 0==t&&e==this.content.size?this:this.copy(this.content.cut(t,e))},P.prototype.slice=function(t,e,n){if(void 0===e&&(e=this.content.size),void 0===n&&(n=!1),t==e)return p.empty;var r=this.resolve(t),o=this.resolve(e),i=n?0:r.sharedDepth(e),s=r.start(i),a=r.node(i).content.cut(r.pos-s,o.pos-s);return new p(a,r.depth-i,o.depth-i)},P.prototype.replace=function(t,e,n){return m(this.resolve(t),this.resolve(e),n)},P.prototype.nodeAt=function(t){for(var e=this;;){var n=e.content.findIndex(t),r=n.index,o=n.offset;if(!(e=e.maybeChild(r)))return null;if(o==t||e.isText)return e;t-=o+1}},P.prototype.childAfter=function(t){var e=this.content.findIndex(t),n=e.index,r=e.offset;return{node:this.content.maybeChild(n),index:n,offset:r}},P.prototype.childBefore=function(t){if(0==t)return{node:null,index:0,offset:0};var e=this.content.findIndex(t),n=e.index,r=e.offset;if(r<t)return{node:this.content.child(n),index:n,offset:r};var o=this.content.child(n-1);return{node:o,index:n-1,offset:r-o.nodeSize}},P.prototype.resolve=function(t){return C.resolveCached(this,t)},P.prototype.resolveNoCache=function(t){return C.resolve(this,t)},P.prototype.rangeHasMark=function(t,e,n){var r=!1;return e>t&&this.nodesBetween(t,e,(function(t){return n.isInSet(t.marks)&&(r=!0),!r})),r},z.isBlock.get=function(){return this.type.isBlock},z.isTextblock.get=function(){return this.type.isTextblock},z.inlineContent.get=function(){return this.type.inlineContent},z.isInline.get=function(){return this.type.isInline},z.isText.get=function(){return this.type.isText},z.isLeaf.get=function(){return this.type.isLeaf},z.isAtom.get=function(){return this.type.isAtom},P.prototype.toString=function(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);var t=this.type.name;return this.content.size&&(t+="("+this.content.toStringInner()+")"),R(this.marks,t)},P.prototype.contentMatchAt=function(t){var e=this.type.contentMatch.matchFragment(this.content,0,t);if(!e)throw new Error("Called contentMatchAt on a node with invalid content");return e},P.prototype.canReplace=function(t,e,n,r,i){void 0===n&&(n=o.empty),void 0===r&&(r=0),void 0===i&&(i=n.childCount);var s=this.contentMatchAt(t).matchFragment(n,r,i),a=s&&s.matchFragment(this.content,e);if(!a||!a.validEnd)return!1;for(var c=r;c<i;c++)if(!this.type.allowsMarks(n.child(c).marks))return!1;return!0},P.prototype.canReplaceWith=function(t,e,n,r){if(r&&!this.type.allowsMarks(r))return!1;var o=this.contentMatchAt(t).matchType(n),i=o&&o.matchFragment(this.content,e);return!!i&&i.validEnd},P.prototype.canAppend=function(t){return t.content.size?this.canReplace(this.childCount,this.childCount,t.content):this.type.compatibleContent(t.type)},P.prototype.check=function(){if(!this.type.validContent(this.content))throw new RangeError("Invalid content for node "+this.type.name+": "+this.content.toString().slice(0,50));for(var t=l.none,e=0;e<this.marks.length;e++)t=this.marks[e].addToSet(t);if(!l.sameSet(t,this.marks))throw new RangeError("Invalid collection of marks for node "+this.type.name+": "+this.marks.map((function(t){return t.type.name})));this.content.forEach((function(t){return t.check()}))},P.prototype.toJSON=function(){var t={type:this.type.name};for(var e in this.attrs){t.attrs=this.attrs;break}return this.content.size&&(t.content=this.content.toJSON()),this.marks.length&&(t.marks=this.marks.map((function(t){return t.toJSON()}))),t},P.fromJSON=function(t,e){if(!e)throw new RangeError("Invalid input for Node.fromJSON");var n=null;if(e.marks){if(!Array.isArray(e.marks))throw new RangeError("Invalid mark data for Node.fromJSON");n=e.marks.map(t.markFromJSON)}if("text"==e.type){if("string"!=typeof e.text)throw new RangeError("Invalid text node in JSON");return t.text(e.text,n)}var r=o.fromJSON(t,e.content);return t.nodeType(e.type).create(e.attrs,r,n)},Object.defineProperties(P.prototype,z);var I=function(t){function e(e,n,r,o){if(t.call(this,e,n,null,o),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={textContent:{configurable:!0},nodeSize:{configurable:!0}};return e.prototype.toString=function(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):R(this.marks,JSON.stringify(this.text))},n.textContent.get=function(){return this.text},e.prototype.textBetween=function(t,e){return this.text.slice(t,e)},n.nodeSize.get=function(){return this.text.length},e.prototype.mark=function(t){return t==this.marks?this:new e(this.type,this.attrs,this.text,t)},e.prototype.withText=function(t){return t==this.text?this:new e(this.type,this.attrs,t,this.marks)},e.prototype.cut=function(t,e){return void 0===t&&(t=0),void 0===e&&(e=this.text.length),0==t&&e==this.text.length?this:this.withText(this.text.slice(t,e))},e.prototype.eq=function(t){return this.sameMarkup(t)&&this.text==t.text},e.prototype.toJSON=function(){var e=t.prototype.toJSON.call(this);return e.text=this.text,e},Object.defineProperties(e.prototype,n),e}(P);function R(t,e){for(var n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}var B=function(t){this.validEnd=t,this.next=[],this.wrapCache=[]},V={inlineContent:{configurable:!0},defaultType:{configurable:!0},edgeCount:{configurable:!0}};B.parse=function(t,e){var n=new F(t,e);if(null==n.next)return B.empty;var r=$(n);n.next&&n.err("Unexpected trailing text");var o,i,s=(o=function(t){var e=[[]];return o(function t(e,i){if("choice"==e.type)return e.exprs.reduce((function(e,n){return e.concat(t(n,i))}),[]);if("seq"==e.type)for(var s=0;;s++){var a=t(e.exprs[s],i);if(s==e.exprs.length-1)return a;o(a,i=n())}else{if("star"==e.type){var c=n();return r(i,c),o(t(e.expr,c),c),[r(c)]}if("plus"==e.type){var l=n();return o(t(e.expr,i),l),o(t(e.expr,l),l),[r(l)]}if("opt"==e.type)return[r(i)].concat(t(e.expr,i));if("range"==e.type){for(var h=i,p=0;p<e.min;p++){var f=n();o(t(e.expr,h),f),h=f}if(-1==e.max)o(t(e.expr,h),h);else for(var d=e.min;d<e.max;d++){var u=n();r(h,u),o(t(e.expr,h),u),h=u}return[r(h)]}if("name"==e.type)return[r(i,null,e.value)]}}(t,0),n()),e;function n(){return e.push([])-1}function r(t,n,r){var o={term:r,to:n};return e[t].push(o),o}function o(t,e){t.forEach((function(t){return t.to=e}))}}(r),i=Object.create(null),function t(e){var n=[];e.forEach((function(t){o[t].forEach((function(t){var e=t.term,r=t.to;if(e){var i=n.indexOf(e),s=i>-1&&n[i+1];K(o,r).forEach((function(t){s||n.push(e,s=[]),-1==s.indexOf(t)&&s.push(t)}))}}))}));for(var r=i[e.join(",")]=new B(e.indexOf(o.length-1)>-1),s=0;s<n.length;s+=2){var a=n[s+1].sort(J);r.next.push(n[s],i[a.join(",")]||t(a))}return r}(K(o,0)));return function(t,e){for(var n=0,r=[t];n<r.length;n++){for(var o=r[n],i=!o.validEnd,s=[],a=0;a<o.next.length;a+=2){var c=o.next[a],l=o.next[a+1];s.push(c.name),!i||c.isText||c.hasRequiredAttrs()||(i=!1),-1==r.indexOf(l)&&r.push(l)}i&&e.err("Only non-generatable nodes ("+s.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}(s,n),s},B.prototype.matchType=function(t){for(var e=0;e<this.next.length;e+=2)if(this.next[e]==t)return this.next[e+1];return null},B.prototype.matchFragment=function(t,e,n){void 0===e&&(e=0),void 0===n&&(n=t.childCount);for(var r=this,o=e;r&&o<n;o++)r=r.matchType(t.child(o).type);return r},V.inlineContent.get=function(){var t=this.next[0];return!!t&&t.isInline},V.defaultType.get=function(){for(var t=0;t<this.next.length;t+=2){var e=this.next[t];if(!e.isText&&!e.hasRequiredAttrs())return e}},B.prototype.compatible=function(t){for(var e=0;e<this.next.length;e+=2)for(var n=0;n<t.next.length;n+=2)if(this.next[e]==t.next[n])return!0;return!1},B.prototype.fillBefore=function(t,e,n){void 0===e&&(e=!1),void 0===n&&(n=0);var r=[this];return function i(s,a){var c=s.matchFragment(t,n);if(c&&(!e||c.validEnd))return o.from(a.map((function(t){return t.createAndFill()})));for(var l=0;l<s.next.length;l+=2){var h=s.next[l],p=s.next[l+1];if(!h.isText&&!h.hasRequiredAttrs()&&-1==r.indexOf(p)){r.push(p);var f=i(p,a.concat(h));if(f)return f}}}(this,[])},B.prototype.findWrapping=function(t){for(var e=0;e<this.wrapCache.length;e+=2)if(this.wrapCache[e]==t)return this.wrapCache[e+1];var n=this.computeWrapping(t);return this.wrapCache.push(t,n),n},B.prototype.computeWrapping=function(t){for(var e=Object.create(null),n=[{match:this,type:null,via:null}];n.length;){var r=n.shift(),o=r.match;if(o.matchType(t)){for(var i=[],s=r;s.type;s=s.via)i.push(s.type);return i.reverse()}for(var a=0;a<o.next.length;a+=2){var c=o.next[a];c.isLeaf||c.hasRequiredAttrs()||c.name in e||r.type&&!o.next[a+1].validEnd||(n.push({match:c.contentMatch,type:c,via:r}),e[c.name]=!0)}}},V.edgeCount.get=function(){return this.next.length>>1},B.prototype.edge=function(t){var e=t<<1;if(e>=this.next.length)throw new RangeError("There's no "+t+"th edge in this content match");return{type:this.next[e],next:this.next[e+1]}},B.prototype.toString=function(){var t=[];return function e(n){t.push(n);for(var r=1;r<n.next.length;r+=2)-1==t.indexOf(n.next[r])&&e(n.next[r])}(this),t.map((function(e,n){for(var r=n+(e.validEnd?"*":" ")+" ",o=0;o<e.next.length;o+=2)r+=(o?", ":"")+e.next[o].name+"->"+t.indexOf(e.next[o+1]);return r})).join("\n")},Object.defineProperties(B.prototype,V),B.empty=new B(!0);var F=function(t,e){this.string=t,this.nodeTypes=e,this.inline=null,this.pos=0,this.tokens=t.split(/\s*(?=\b|\W|$)/),""==this.tokens[this.tokens.length-1]&&this.tokens.pop(),""==this.tokens[0]&&this.tokens.shift()},q={next:{configurable:!0}};function $(t){var e=[];do{e.push(L(t))}while(t.eat("|"));return 1==e.length?e[0]:{type:"choice",exprs:e}}function L(t){var e=[];do{e.push(_(t))}while(t.next&&")"!=t.next&&"|"!=t.next);return 1==e.length?e[0]:{type:"seq",exprs:e}}function _(t){for(var e=function(t){if(t.eat("(")){var e=$(t);return t.eat(")")||t.err("Missing closing paren"),e}if(!/\W/.test(t.next)){var n=function(t,e){var n=t.nodeTypes,r=n[e];if(r)return[r];var o=[];for(var i in n){var s=n[i];s.groups.indexOf(e)>-1&&o.push(s)}return 0==o.length&&t.err("No node type or group '"+e+"' found"),o}(t,t.next).map((function(e){return null==t.inline?t.inline=e.isInline:t.inline!=e.isInline&&t.err("Mixing inline and block content"),{type:"name",value:e}}));return t.pos++,1==n.length?n[0]:{type:"choice",exprs:n}}t.err("Unexpected token '"+t.next+"'")}(t);;)if(t.eat("+"))e={type:"plus",expr:e};else if(t.eat("*"))e={type:"star",expr:e};else if(t.eat("?"))e={type:"opt",expr:e};else{if(!t.eat("{"))break;e=W(t,e)}return e}function j(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");var e=Number(t.next);return t.pos++,e}function W(t,e){var n=j(t),r=n;return t.eat(",")&&(r="}"!=t.next?j(t):-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function J(t,e){return e-t}function K(t,e){var n=[];return function e(r){var o=t[r];if(1==o.length&&!o[0].term)return e(o[0].to);n.push(r);for(var i=0;i<o.length;i++){var s=o[i],a=s.term,c=s.to;a||-1!=n.indexOf(c)||e(c)}}(e),n.sort(J)}function H(t){var e=Object.create(null);for(var n in t){var r=t[n];if(!r.hasDefault)return null;e[n]=r.default}return e}function U(t,e){var n=Object.create(null);for(var r in t){var o=e&&e[r];if(void 0===o){var i=t[r];if(!i.hasDefault)throw new RangeError("No value supplied for attribute "+r);o=i.default}n[r]=o}return n}function G(t){var e=Object.create(null);if(t)for(var n in t)e[n]=new Q(t[n]);return e}q.next.get=function(){return this.tokens[this.pos]},F.prototype.eat=function(t){return this.next==t&&(this.pos++||!0)},F.prototype.err=function(t){throw new SyntaxError(t+" (in content expression '"+this.string+"')")},Object.defineProperties(F.prototype,q);var X=function(t,e,n){this.name=t,this.schema=e,this.spec=n,this.groups=n.group?n.group.split(" "):[],this.attrs=G(n.attrs),this.defaultAttrs=H(this.attrs),this.contentMatch=null,this.markSet=null,this.inlineContent=null,this.isBlock=!(n.inline||"text"==t),this.isText="text"==t},Y={isInline:{configurable:!0},isTextblock:{configurable:!0},isLeaf:{configurable:!0},isAtom:{configurable:!0}};Y.isInline.get=function(){return!this.isBlock},Y.isTextblock.get=function(){return this.isBlock&&this.inlineContent},Y.isLeaf.get=function(){return this.contentMatch==B.empty},Y.isAtom.get=function(){return this.isLeaf||this.spec.atom},X.prototype.hasRequiredAttrs=function(){for(var t in this.attrs)if(this.attrs[t].isRequired)return!0;return!1},X.prototype.compatibleContent=function(t){return this==t||this.contentMatch.compatible(t.contentMatch)},X.prototype.computeAttrs=function(t){return!t&&this.defaultAttrs?this.defaultAttrs:U(this.attrs,t)},X.prototype.create=function(t,e,n){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new P(this,this.computeAttrs(t),o.from(e),l.setFrom(n))},X.prototype.createChecked=function(t,e,n){if(e=o.from(e),!this.validContent(e))throw new RangeError("Invalid content for node "+this.name);return new P(this,this.computeAttrs(t),e,l.setFrom(n))},X.prototype.createAndFill=function(t,e,n){if(t=this.computeAttrs(t),(e=o.from(e)).size){var r=this.contentMatch.fillBefore(e);if(!r)return null;e=r.append(e)}var i=this.contentMatch.matchFragment(e).fillBefore(o.empty,!0);return i?new P(this,t,e.append(i),l.setFrom(n)):null},X.prototype.validContent=function(t){var e=this.contentMatch.matchFragment(t);if(!e||!e.validEnd)return!1;for(var n=0;n<t.childCount;n++)if(!this.allowsMarks(t.child(n).marks))return!1;return!0},X.prototype.allowsMarkType=function(t){return null==this.markSet||this.markSet.indexOf(t)>-1},X.prototype.allowsMarks=function(t){if(null==this.markSet)return!0;for(var e=0;e<t.length;e++)if(!this.allowsMarkType(t[e].type))return!1;return!0},X.prototype.allowedMarks=function(t){if(null==this.markSet)return t;for(var e,n=0;n<t.length;n++)this.allowsMarkType(t[n].type)?e&&e.push(t[n]):e||(e=t.slice(0,n));return e?e.length?e:l.empty:t},X.compile=function(t,e){var n=Object.create(null);t.forEach((function(t,r){return n[t]=new X(t,e,r)}));var r=e.spec.topNode||"doc";if(!n[r])throw new RangeError("Schema is missing its top node type ('"+r+"')");if(!n.text)throw new RangeError("Every schema needs a 'text' type");for(var o in n.text.attrs)throw new RangeError("The text node type should not have attributes");return n},Object.defineProperties(X.prototype,Y);var Q=function(t){this.hasDefault=Object.prototype.hasOwnProperty.call(t,"default"),this.default=t.default},Z={isRequired:{configurable:!0}};Z.isRequired.get=function(){return!this.hasDefault},Object.defineProperties(Q.prototype,Z);var tt=function(t,e,n,r){this.name=t,this.schema=n,this.spec=r,this.attrs=G(r.attrs),this.rank=e,this.excluded=null;var o=H(this.attrs);this.instance=o&&new l(this,o)};tt.prototype.create=function(t){return!t&&this.instance?this.instance:new l(this,U(this.attrs,t))},tt.compile=function(t,e){var n=Object.create(null),r=0;return t.forEach((function(t,o){return n[t]=new tt(t,r++,e,o)})),n},tt.prototype.removeFromSet=function(t){for(var e=0;e<t.length;e++)t[e].type==this&&(t=t.slice(0,e).concat(t.slice(e+1)),e--);return t},tt.prototype.isInSet=function(t){for(var e=0;e<t.length;e++)if(t[e].type==this)return t[e]},tt.prototype.excludes=function(t){return this.excluded.indexOf(t)>-1};var et=function(t){for(var n in this.spec={},t)this.spec[n]=t[n];this.spec.nodes=e.from(t.nodes),this.spec.marks=e.from(t.marks),this.nodes=X.compile(this.spec.nodes,this),this.marks=tt.compile(this.spec.marks,this);var r=Object.create(null);for(var o in this.nodes){if(o in this.marks)throw new RangeError(o+" can not be both a node and a mark");var i=this.nodes[o],s=i.spec.content||"",a=i.spec.marks;i.contentMatch=r[s]||(r[s]=B.parse(s,this.nodes)),i.inlineContent=i.contentMatch.inlineContent,i.markSet="_"==a?null:a?nt(this,a.split(" ")):""!=a&&i.inlineContent?null:[]}for(var c in this.marks){var l=this.marks[c],h=l.spec.excludes;l.excluded=null==h?[l]:""==h?[]:nt(this,h.split(" "))}this.nodeFromJSON=this.nodeFromJSON.bind(this),this.markFromJSON=this.markFromJSON.bind(this),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached=Object.create(null),this.cached.wrappings=Object.create(null)};function nt(t,e){for(var n=[],r=0;r<e.length;r++){var o=e[r],i=t.marks[o],s=i;if(i)n.push(i);else for(var a in t.marks){var c=t.marks[a];("_"==o||c.spec.group&&c.spec.group.split(" ").indexOf(o)>-1)&&n.push(s=c)}if(!s)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return n}et.prototype.node=function(t,e,n,r){if("string"==typeof t)t=this.nodeType(t);else{if(!(t instanceof X))throw new RangeError("Invalid node type: "+t);if(t.schema!=this)throw new RangeError("Node type from different schema used ("+t.name+")")}return t.createChecked(e,n,r)},et.prototype.text=function(t,e){var n=this.nodes.text;return new I(n,n.defaultAttrs,t,l.setFrom(e))},et.prototype.mark=function(t,e){return"string"==typeof t&&(t=this.marks[t]),t.create(e)},et.prototype.nodeFromJSON=function(t){return P.fromJSON(this,t)},et.prototype.markFromJSON=function(t){return l.fromJSON(this,t)},et.prototype.nodeType=function(t){var e=this.nodes[t];if(!e)throw new RangeError("Unknown node type: "+t);return e};var rt=function(t,e){var n=this;this.schema=t,this.rules=e,this.tags=[],this.styles=[],e.forEach((function(t){t.tag?n.tags.push(t):t.style&&n.styles.push(t)})),this.normalizeLists=!this.tags.some((function(e){if(!/^(ul|ol)\b/.test(e.tag)||!e.node)return!1;var n=t.nodes[e.node];return n.contentMatch.matchType(n)}))};rt.prototype.parse=function(t,e){void 0===e&&(e={});var n=new lt(this,e,!1);return n.addAll(t,null,e.from,e.to),n.finish()},rt.prototype.parseSlice=function(t,e){void 0===e&&(e={});var n=new lt(this,e,!0);return n.addAll(t,null,e.from,e.to),p.maxOpen(n.finish())},rt.prototype.matchTag=function(t,e,n){for(var r=n?this.tags.indexOf(n)+1:0;r<this.tags.length;r++){var o=this.tags[r];if(pt(t,o.tag)&&(void 0===o.namespace||t.namespaceURI==o.namespace)&&(!o.context||e.matchesContext(o.context))){if(o.getAttrs){var i=o.getAttrs(t);if(!1===i)continue;o.attrs=i}return o}}},rt.prototype.matchStyle=function(t,e,n,r){for(var o=r?this.styles.indexOf(r)+1:0;o<this.styles.length;o++){var i=this.styles[o];if(!(0!=i.style.indexOf(t)||i.context&&!n.matchesContext(i.context)||i.style.length>t.length&&(61!=i.style.charCodeAt(t.length)||i.style.slice(t.length+1)!=e))){if(i.getAttrs){var s=i.getAttrs(e);if(!1===s)continue;i.attrs=s}return i}}},rt.schemaRules=function(t){var e=[];function n(t){for(var n=null==t.priority?50:t.priority,r=0;r<e.length;r++){var o=e[r];if((null==o.priority?50:o.priority)<n)break}e.splice(r,0,t)}var r,o=function(e){var r=t.marks[e].spec.parseDOM;r&&r.forEach((function(t){n(t=ft(t)),t.mark=e}))};for(var i in t.marks)o(i);for(var s in t.nodes)r=void 0,(r=t.nodes[s].spec.parseDOM)&&r.forEach((function(t){n(t=ft(t)),t.node=s}));return e},rt.fromSchema=function(t){return t.cached.domParser||(t.cached.domParser=new rt(t,rt.schemaRules(t)))};var ot={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},it={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},st={ol:!0,ul:!0};function at(t){return(t?1:0)|("full"===t?2:0)}var ct=function(t,e,n,r,o,i,s){this.type=t,this.attrs=e,this.solid=o,this.match=i||(4&s?null:t.contentMatch),this.options=s,this.content=[],this.marks=n,this.activeMarks=l.none,this.pendingMarks=r,this.stashMarks=[]};ct.prototype.findWrapping=function(t){if(!this.match){if(!this.type)return[];var e=this.type.contentMatch.fillBefore(o.from(t));if(!e){var n,r=this.type.contentMatch;return(n=r.findWrapping(t.type))?(this.match=r,n):null}this.match=this.type.contentMatch.matchFragment(e)}return this.match.findWrapping(t.type)},ct.prototype.finish=function(t){if(!(1&this.options)){var e,n=this.content[this.content.length-1];n&&n.isText&&(e=/[ \t\r\n\u000c]+$/.exec(n.text))&&(n.text.length==e[0].length?this.content.pop():this.content[this.content.length-1]=n.withText(n.text.slice(0,n.text.length-e[0].length)))}var r=o.from(this.content);return!t&&this.match&&(r=r.append(this.match.fillBefore(o.empty,!0))),this.type?this.type.create(this.attrs,r,this.marks):r},ct.prototype.popFromStashMark=function(t){for(var e=this.stashMarks.length-1;e>=0;e--)if(t.eq(this.stashMarks[e]))return this.stashMarks.splice(e,1)[0]},ct.prototype.applyPending=function(t){for(var e=0,n=this.pendingMarks;e<n.length;e++){var r=n[e];(this.type?this.type.allowsMarkType(r.type):dt(r.type,t))&&!r.isInSet(this.activeMarks)&&(this.activeMarks=r.addToSet(this.activeMarks),this.pendingMarks=r.removeFromSet(this.pendingMarks))}};var lt=function(t,e,n){this.parser=t,this.options=e,this.isOpen=n;var r,o=e.topNode,i=at(e.preserveWhitespace)|(n?4:0);r=o?new ct(o.type,o.attrs,l.none,l.none,!0,e.topMatch||o.type.contentMatch,i):new ct(n?null:t.schema.topNodeType,null,l.none,l.none,!0,null,i),this.nodes=[r],this.open=0,this.find=e.findPositions,this.needsBlock=!1},ht={top:{configurable:!0},currentPos:{configurable:!0}};function pt(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function ft(t){var e={};for(var n in t)e[n]=t[n];return e}function dt(t,e){var n=e.schema.nodes,r=function(r){var o=n[r];if(o.allowsMarkType(t)){var i=[],s=function(t){i.push(t);for(var n=0;n<t.edgeCount;n++){var r=t.edge(n),o=r.type,a=r.next;if(o==e)return!0;if(i.indexOf(a)<0&&s(a))return!0}};return s(o.contentMatch)?{v:!0}:void 0}};for(var o in n){var i=r(o);if(i)return i.v}}ht.top.get=function(){return this.nodes[this.open]},lt.prototype.addDOM=function(t){if(3==t.nodeType)this.addTextNode(t);else if(1==t.nodeType){var e=t.getAttribute("style"),n=e?this.readStyles(function(t){for(var e,n=/\s*([\w-]+)\s*:\s*([^;]+)/g,r=[];e=n.exec(t);)r.push(e[1],e[2].trim());return r}(e)):null,r=this.top;if(null!=n)for(var o=0;o<n.length;o++)this.addPendingMark(n[o]);if(this.addElement(t),null!=n)for(var i=0;i<n.length;i++)this.removePendingMark(n[i],r)}},lt.prototype.addTextNode=function(t){var e=t.nodeValue,n=this.top;if(2&n.options||(n.type?n.type.inlineContent:n.content.length&&n.content[0].isInline)||/[^ \t\r\n\u000c]/.test(e)){if(1&n.options)e=2&n.options?e.replace(/\r\n?/g,"\n"):e.replace(/\r?\n|\r/g," ");else if(e=e.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(e)&&this.open==this.nodes.length-1){var r=n.content[n.content.length-1],o=t.previousSibling;(!r||o&&"BR"==o.nodeName||r.isText&&/[ \t\r\n\u000c]$/.test(r.text))&&(e=e.slice(1))}e&&this.insertNode(this.parser.schema.text(e)),this.findInText(t)}else this.findInside(t)},lt.prototype.addElement=function(t,e){var n,r=t.nodeName.toLowerCase();st.hasOwnProperty(r)&&this.parser.normalizeLists&&function(t){for(var e=t.firstChild,n=null;e;e=e.nextSibling){var r=1==e.nodeType?e.nodeName.toLowerCase():null;r&&st.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):"li"==r?n=e:r&&(n=null)}}(t);var o=this.options.ruleFromNode&&this.options.ruleFromNode(t)||(n=this.parser.matchTag(t,this,e));if(o?o.ignore:it.hasOwnProperty(r))this.findInside(t),this.ignoreFallback(t);else if(!o||o.skip||o.closeParent){o&&o.closeParent?this.open=Math.max(0,this.open-1):o&&o.skip.nodeType&&(t=o.skip);var i,s=this.top,a=this.needsBlock;if(ot.hasOwnProperty(r))i=!0,s.type||(this.needsBlock=!0);else if(!t.firstChild)return void this.leafFallback(t);this.addAll(t),i&&this.sync(s),this.needsBlock=a}else this.addElementByRule(t,o,!1===o.consuming?n:null)},lt.prototype.leafFallback=function(t){"BR"==t.nodeName&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(t.ownerDocument.createTextNode("\n"))},lt.prototype.ignoreFallback=function(t){"BR"!=t.nodeName||this.top.type&&this.top.type.inlineContent||this.findPlace(this.parser.schema.text("-"))},lt.prototype.readStyles=function(t){var e=l.none;t:for(var n=0;n<t.length;n+=2)for(var r=null;;){var o=this.parser.matchStyle(t[n],t[n+1],this,r);if(!o)continue t;if(o.ignore)return null;if(e=this.parser.schema.marks[o.mark].create(o.attrs).addToSet(e),!1!==o.consuming)break;r=o}return e},lt.prototype.addElementByRule=function(t,e,n){var r,o,i,s=this;e.node?(o=this.parser.schema.nodes[e.node]).isLeaf?this.insertNode(o.create(e.attrs))||this.leafFallback(t):r=this.enter(o,e.attrs,e.preserveWhitespace):(i=this.parser.schema.marks[e.mark].create(e.attrs),this.addPendingMark(i));var a=this.top;if(o&&o.isLeaf)this.findInside(t);else if(n)this.addElement(t,n);else if(e.getContent)this.findInside(t),e.getContent(t,this.parser.schema).forEach((function(t){return s.insertNode(t)}));else{var c=e.contentElement;"string"==typeof c?c=t.querySelector(c):"function"==typeof c&&(c=c(t)),c||(c=t),this.findAround(t,c,!0),this.addAll(c,r)}r&&(this.sync(a),this.open--),i&&this.removePendingMark(i,a)},lt.prototype.addAll=function(t,e,n,r){for(var o=n||0,i=n?t.childNodes[n]:t.firstChild,s=null==r?null:t.childNodes[r];i!=s;i=i.nextSibling,++o)this.findAtPoint(t,o),this.addDOM(i),e&&ot.hasOwnProperty(i.nodeName.toLowerCase())&&this.sync(e);this.findAtPoint(t,o)},lt.prototype.findPlace=function(t){for(var e,n,r=this.open;r>=0;r--){var o=this.nodes[r],i=o.findWrapping(t);if(i&&(!e||e.length>i.length)&&(e=i,n=o,!i.length))break;if(o.solid)break}if(!e)return!1;this.sync(n);for(var s=0;s<e.length;s++)this.enterInner(e[s],null,!1);return!0},lt.prototype.insertNode=function(t){if(t.isInline&&this.needsBlock&&!this.top.type){var e=this.textblockFromContext();e&&this.enterInner(e)}if(this.findPlace(t)){this.closeExtra();var n=this.top;n.applyPending(t.type),n.match&&(n.match=n.match.matchType(t.type));for(var r=n.activeMarks,o=0;o<t.marks.length;o++)n.type&&!n.type.allowsMarkType(t.marks[o].type)||(r=t.marks[o].addToSet(r));return n.content.push(t.mark(r)),!0}return!1},lt.prototype.enter=function(t,e,n){var r=this.findPlace(t.create(e));return r&&this.enterInner(t,e,!0,n),r},lt.prototype.enterInner=function(t,e,n,r){this.closeExtra();var o=this.top;o.applyPending(t),o.match=o.match&&o.match.matchType(t,e);var i=null==r?-5&o.options:at(r);4&o.options&&0==o.content.length&&(i|=4),this.nodes.push(new ct(t,e,o.activeMarks,o.pendingMarks,n,null,i)),this.open++},lt.prototype.closeExtra=function(t){var e=this.nodes.length-1;if(e>this.open){for(;e>this.open;e--)this.nodes[e-1].content.push(this.nodes[e].finish(t));this.nodes.length=this.open+1}},lt.prototype.finish=function(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(this.isOpen||this.options.topOpen)},lt.prototype.sync=function(t){for(var e=this.open;e>=0;e--)if(this.nodes[e]==t)return void(this.open=e)},ht.currentPos.get=function(){this.closeExtra();for(var t=0,e=this.open;e>=0;e--){for(var n=this.nodes[e].content,r=n.length-1;r>=0;r--)t+=n[r].nodeSize;e&&t++}return t},lt.prototype.findAtPoint=function(t,e){if(this.find)for(var n=0;n<this.find.length;n++)this.find[n].node==t&&this.find[n].offset==e&&(this.find[n].pos=this.currentPos)},lt.prototype.findInside=function(t){if(this.find)for(var e=0;e<this.find.length;e++)null==this.find[e].pos&&1==t.nodeType&&t.contains(this.find[e].node)&&(this.find[e].pos=this.currentPos)},lt.prototype.findAround=function(t,e,n){if(t!=e&&this.find)for(var r=0;r<this.find.length;r++)null==this.find[r].pos&&1==t.nodeType&&t.contains(this.find[r].node)&&e.compareDocumentPosition(this.find[r].node)&(n?2:4)&&(this.find[r].pos=this.currentPos)},lt.prototype.findInText=function(t){if(this.find)for(var e=0;e<this.find.length;e++)this.find[e].node==t&&(this.find[e].pos=this.currentPos-(t.nodeValue.length-this.find[e].offset))},lt.prototype.matchesContext=function(t){var e=this;if(t.indexOf("|")>-1)return t.split(/\s*\|\s*/).some(this.matchesContext,this);var n=t.split("/"),r=this.options.context,o=!(this.isOpen||r&&r.parent.type!=this.nodes[0].type),i=-(r?r.depth+1:0)+(o?0:1),s=function(t,a){for(;t>=0;t--){var c=n[t];if(""==c){if(t==n.length-1||0==t)continue;for(;a>=i;a--)if(s(t-1,a))return!0;return!1}var l=a>0||0==a&&o?e.nodes[a].type:r&&a>=i?r.node(a-i).type:null;if(!l||l.name!=c&&-1==l.groups.indexOf(c))return!1;a--}return!0};return s(n.length-1,this.open)},lt.prototype.textblockFromContext=function(){var t=this.options.context;if(t)for(var e=t.depth;e>=0;e--){var n=t.node(e).contentMatchAt(t.indexAfter(e)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(var r in this.parser.schema.nodes){var o=this.parser.schema.nodes[r];if(o.isTextblock&&o.defaultAttrs)return o}},lt.prototype.addPendingMark=function(t){var e=function(t,e){for(var n=0;n<e.length;n++)if(t.eq(e[n]))return e[n]}(t,this.top.pendingMarks);e&&this.top.stashMarks.push(e),this.top.pendingMarks=t.addToSet(this.top.pendingMarks)},lt.prototype.removePendingMark=function(t,e){for(var n=this.open;n>=0;n--){var r=this.nodes[n];if(r.pendingMarks.lastIndexOf(t)>-1)r.pendingMarks=t.removeFromSet(r.pendingMarks);else{r.activeMarks=t.removeFromSet(r.activeMarks);var o=r.popFromStashMark(t);o&&r.type&&r.type.allowsMarkType(o.type)&&(r.activeMarks=o.addToSet(r.activeMarks))}if(r==e)break}},Object.defineProperties(lt.prototype,ht);var ut=function(t,e){this.nodes=t||{},this.marks=e||{}};function mt(t){var e={};for(var n in t){var r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function vt(t){return t.document||window.document}ut.prototype.serializeFragment=function(t,e,n){var r=this;void 0===e&&(e={}),n||(n=vt(e).createDocumentFragment());var o=n,i=null;return t.forEach((function(t){if(i||t.marks.length){i||(i=[]);for(var n=0,s=0;n<i.length&&s<t.marks.length;){var a=t.marks[s];if(r.marks[a.type.name]){if(!a.eq(i[n])||!1===a.type.spec.spanning)break;n+=2,s++}else s++}for(;n<i.length;)o=i.pop(),i.pop();for(;s<t.marks.length;){var c=t.marks[s++],l=r.serializeMark(c,t.isInline,e);l&&(i.push(c,o),o.appendChild(l.dom),o=l.contentDOM||l.dom)}}o.appendChild(r.serializeNode(t,e))})),n},ut.prototype.serializeNode=function(t,e){void 0===e&&(e={});var n=ut.renderSpec(vt(e),this.nodes[t.type.name](t)),r=n.dom,o=n.contentDOM;if(o){if(t.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");e.onContent?e.onContent(t,o,e):this.serializeFragment(t.content,e,o)}return r},ut.prototype.serializeNodeAndMarks=function(t,e){void 0===e&&(e={});for(var n=this.serializeNode(t,e),r=t.marks.length-1;r>=0;r--){var o=this.serializeMark(t.marks[r],t.isInline,e);o&&((o.contentDOM||o.dom).appendChild(n),n=o.dom)}return n},ut.prototype.serializeMark=function(t,e,n){void 0===n&&(n={});var r=this.marks[t.type.name];return r&&ut.renderSpec(vt(n),r(t,e))},ut.renderSpec=function(t,e,n){if(void 0===n&&(n=null),"string"==typeof e)return{dom:t.createTextNode(e)};if(null!=e.nodeType)return{dom:e};if(e.dom&&null!=e.dom.nodeType)return e;var r=e[0],o=r.indexOf(" ");o>0&&(n=r.slice(0,o),r=r.slice(o+1));var i=null,s=n?t.createElementNS(n,r):t.createElement(r),a=e[1],c=1;if(a&&"object"==typeof a&&null==a.nodeType&&!Array.isArray(a))for(var l in c=2,a)if(null!=a[l]){var h=l.indexOf(" ");h>0?s.setAttributeNS(l.slice(0,h),l.slice(h+1),a[l]):s.setAttribute(l,a[l])}for(var p=c;p<e.length;p++){var f=e[p];if(0===f){if(p<e.length-1||p>c)throw new RangeError("Content hole must be the only child of its parent node");return{dom:s,contentDOM:s}}var d=ut.renderSpec(t,f,n),u=d.dom,m=d.contentDOM;if(s.appendChild(u),m){if(i)throw new RangeError("Multiple content holes");i=m}}return{dom:s,contentDOM:i}},ut.fromSchema=function(t){return t.cached.domSerializer||(t.cached.domSerializer=new ut(this.nodesFromSchema(t),this.marksFromSchema(t)))},ut.nodesFromSchema=function(t){var e=mt(t.nodes);return e.text||(e.text=function(t){return t.text}),e},ut.marksFromSchema=function(t){return mt(t.marks)};var gt=["p",0],yt=["blockquote",0],wt=["hr"],bt=["pre",["code",0]],xt=["br"],kt=["em",0],St=["strong",0],Ct=["code",0],Mt=new et({nodes:{doc:{content:"block+"},paragraph:{content:"inline*",group:"block",parseDOM:[{tag:"p"}],toDOM:function(){return gt}},blockquote:{content:"block+",group:"block",defining:!0,parseDOM:[{tag:"blockquote"}],toDOM:function(){return yt}},horizontal_rule:{group:"block",parseDOM:[{tag:"hr"}],toDOM:function(){return wt}},heading:{attrs:{level:{default:1}},content:"inline*",group:"block",defining:!0,parseDOM:[{tag:"h1",attrs:{level:1}},{tag:"h2",attrs:{level:2}},{tag:"h3",attrs:{level:3}},{tag:"h4",attrs:{level:4}},{tag:"h5",attrs:{level:5}},{tag:"h6",attrs:{level:6}}],toDOM:function(t){return["h"+t.attrs.level,0]}},code_block:{content:"text*",marks:"",group:"block",code:!0,defining:!0,parseDOM:[{tag:"pre",preserveWhitespace:"full"}],toDOM:function(){return bt}},text:{group:"inline"},image:{inline:!0,attrs:{src:{},alt:{default:null},title:{default:null}},group:"inline",draggable:!0,parseDOM:[{tag:"img[src]",getAttrs:function(t){return{src:t.getAttribute("src"),title:t.getAttribute("title"),alt:t.getAttribute("alt")}}}],toDOM:function(t){var e=t.attrs;return["img",{src:e.src,alt:e.alt,title:e.title}]}},hard_break:{inline:!0,group:"inline",selectable:!1,parseDOM:[{tag:"br"}],toDOM:function(){return xt}}},marks:{link:{attrs:{href:{},title:{default:null}},inclusive:!1,parseDOM:[{tag:"a[href]",getAttrs:function(t){return{href:t.getAttribute("href"),title:t.getAttribute("title")}}}],toDOM:function(t){var e=t.attrs;return["a",{href:e.href,title:e.title},0]}},em:{parseDOM:[{tag:"i"},{tag:"em"},{style:"font-style=italic"}],toDOM:function(){return kt}},strong:{parseDOM:[{tag:"strong"},{tag:"b",getAttrs:function(t){return"normal"!=t.style.fontWeight&&null}},{style:"font-weight",getAttrs:function(t){return/^(bold(er)?|[5-9]\d{2,})$/.test(t)&&null}}],toDOM:function(){return St}},code:{parseDOM:[{tag:"code"}],toDOM:function(){return Ct}}}}),Ot=Math.pow(2,16);function Nt(t){return 65535&t}var Dt=function(t,e,n){void 0===e&&(e=!1),void 0===n&&(n=null),this.pos=t,this.deleted=e,this.recover=n},Tt=function(t,e){void 0===e&&(e=!1),this.ranges=t,this.inverted=e};Tt.prototype.recover=function(t){var e=0,n=Nt(t);if(!this.inverted)for(var r=0;r<n;r++)e+=this.ranges[3*r+2]-this.ranges[3*r+1];return this.ranges[3*n]+e+function(t){return(t-(65535&t))/Ot}(t)},Tt.prototype.mapResult=function(t,e){return void 0===e&&(e=1),this._map(t,e,!1)},Tt.prototype.map=function(t,e){return void 0===e&&(e=1),this._map(t,e,!0)},Tt.prototype._map=function(t,e,n){for(var r=0,o=this.inverted?2:1,i=this.inverted?1:2,s=0;s<this.ranges.length;s+=3){var a=this.ranges[s]-(this.inverted?r:0);if(a>t)break;var c=this.ranges[s+o],l=this.ranges[s+i],h=a+c;if(t<=h){var p=a+r+((c?t==a?-1:t==h?1:e:e)<0?0:l);return n?p:new Dt(p,e<0?t!=a:t!=h,t==(e<0?a:h)?null:s/3+(t-a)*Ot)}r+=l-c}return n?t+r:new Dt(t+r)},Tt.prototype.touches=function(t,e){for(var n=0,r=Nt(e),o=this.inverted?2:1,i=this.inverted?1:2,s=0;s<this.ranges.length;s+=3){var a=this.ranges[s]-(this.inverted?n:0);if(a>t)break;var c=this.ranges[s+o];if(t<=a+c&&s==3*r)return!0;n+=this.ranges[s+i]-c}return!1},Tt.prototype.forEach=function(t){for(var e=this.inverted?2:1,n=this.inverted?1:2,r=0,o=0;r<this.ranges.length;r+=3){var i=this.ranges[r],s=i-(this.inverted?o:0),a=i+(this.inverted?0:o),c=this.ranges[r+e],l=this.ranges[r+n];t(s,s+c,a,a+l),o+=l-c}},Tt.prototype.invert=function(){return new Tt(this.ranges,!this.inverted)},Tt.prototype.toString=function(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)},Tt.offset=function(t){return 0==t?Tt.empty:new Tt(t<0?[0,-t,0]:[0,0,t])},Tt.empty=new Tt([]);var Et=function(t,e,n,r){this.maps=t||[],this.from=n||0,this.to=null==r?this.maps.length:r,this.mirror=e};function At(t){var e=Error.call(this,t);return e.__proto__=At.prototype,e}Et.prototype.slice=function(t,e){return void 0===t&&(t=0),void 0===e&&(e=this.maps.length),new Et(this.maps,this.mirror,t,e)},Et.prototype.copy=function(){return new Et(this.maps.slice(),this.mirror&&this.mirror.slice(),this.from,this.to)},Et.prototype.appendMap=function(t,e){this.to=this.maps.push(t),null!=e&&this.setMirror(this.maps.length-1,e)},Et.prototype.appendMapping=function(t){for(var e=0,n=this.maps.length;e<t.maps.length;e++){var r=t.getMirror(e);this.appendMap(t.maps[e],null!=r&&r<e?n+r:null)}},Et.prototype.getMirror=function(t){if(this.mirror)for(var e=0;e<this.mirror.length;e++)if(this.mirror[e]==t)return this.mirror[e+(e%2?-1:1)]},Et.prototype.setMirror=function(t,e){this.mirror||(this.mirror=[]),this.mirror.push(t,e)},Et.prototype.appendMappingInverted=function(t){for(var e=t.maps.length-1,n=this.maps.length+t.maps.length;e>=0;e--){var r=t.getMirror(e);this.appendMap(t.maps[e].invert(),null!=r&&r>e?n-r-1:null)}},Et.prototype.invert=function(){var t=new Et;return t.appendMappingInverted(this),t},Et.prototype.map=function(t,e){if(void 0===e&&(e=1),this.mirror)return this._map(t,e,!0);for(var n=this.from;n<this.to;n++)t=this.maps[n].map(t,e);return t},Et.prototype.mapResult=function(t,e){return void 0===e&&(e=1),this._map(t,e,!1)},Et.prototype._map=function(t,e,n){for(var r=!1,o=this.from;o<this.to;o++){var i=this.maps[o].mapResult(t,e);if(null!=i.recover){var s=this.getMirror(o);if(null!=s&&s>o&&s<this.to){o=s,t=this.maps[s].recover(i.recover);continue}}i.deleted&&(r=!0),t=i.pos}return n?t:new Dt(t,r)},At.prototype=Object.create(Error.prototype),At.prototype.constructor=At,At.prototype.name="TransformError";var Pt=function(t){this.doc=t,this.steps=[],this.docs=[],this.mapping=new Et},zt={before:{configurable:!0},docChanged:{configurable:!0}};function It(){throw new Error("Override me")}zt.before.get=function(){return this.docs.length?this.docs[0]:this.doc},Pt.prototype.step=function(t){var e=this.maybeStep(t);if(e.failed)throw new At(e.failed);return this},Pt.prototype.maybeStep=function(t){var e=t.apply(this.doc);return e.failed||this.addStep(t,e.doc),e},zt.docChanged.get=function(){return this.steps.length>0},Pt.prototype.addStep=function(t,e){this.docs.push(this.doc),this.steps.push(t),this.mapping.appendMap(t.getMap()),this.doc=e},Object.defineProperties(Pt.prototype,zt);var Rt=Object.create(null),Bt=function(){};Bt.prototype.apply=function(t){return It()},Bt.prototype.getMap=function(){return Tt.empty},Bt.prototype.invert=function(t){return It()},Bt.prototype.map=function(t){return It()},Bt.prototype.merge=function(t){return null},Bt.prototype.toJSON=function(){return It()},Bt.fromJSON=function(t,e){if(!e||!e.stepType)throw new RangeError("Invalid input for Step.fromJSON");var n=Rt[e.stepType];if(!n)throw new RangeError("No step type "+e.stepType+" defined");return n.fromJSON(t,e)},Bt.jsonID=function(t,e){if(t in Rt)throw new RangeError("Duplicate use of step JSON ID "+t);return Rt[t]=e,e.prototype.jsonID=t,e};var Vt=function(t,e){this.doc=t,this.failed=e};Vt.ok=function(t){return new Vt(t,null)},Vt.fail=function(t){return new Vt(null,t)},Vt.fromReplace=function(t,e,n,r){try{return Vt.ok(t.replace(e,n,r))}catch(t){if(t instanceof h)return Vt.fail(t.message);throw t}};var Ft=function(t){function e(e,n,r,o){t.call(this),this.from=e,this.to=n,this.slice=r,this.structure=!!o}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.apply=function(t){return this.structure&&$t(t,this.from,this.to)?Vt.fail("Structure replace would overwrite content"):Vt.fromReplace(t,this.from,this.to,this.slice)},e.prototype.getMap=function(){return new Tt([this.from,this.to-this.from,this.slice.size])},e.prototype.invert=function(t){return new e(this.from,this.from+this.slice.size,t.slice(this.from,this.to))},e.prototype.map=function(t){var n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted?null:new e(n.pos,Math.max(n.pos,r.pos),this.slice)},e.prototype.merge=function(t){if(!(t instanceof e)||t.structure||this.structure)return null;if(this.from+this.slice.size!=t.from||this.slice.openEnd||t.slice.openStart){if(t.to!=this.from||this.slice.openStart||t.slice.openEnd)return null;var n=this.slice.size+t.slice.size==0?p.empty:new p(t.slice.content.append(this.slice.content),t.slice.openStart,this.slice.openEnd);return new e(t.from,this.to,n,this.structure)}var r=this.slice.size+t.slice.size==0?p.empty:new p(this.slice.content.append(t.slice.content),this.slice.openStart,t.slice.openEnd);return new e(this.from,this.to+(t.to-t.from),r,this.structure)},e.prototype.toJSON=function(){var t={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(t.slice=this.slice.toJSON()),this.structure&&(t.structure=!0),t},e.fromJSON=function(t,n){if("number"!=typeof n.from||"number"!=typeof n.to)throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new e(n.from,n.to,p.fromJSON(t,n.slice),!!n.structure)},e}(Bt);Bt.jsonID("replace",Ft);var qt=function(t){function e(e,n,r,o,i,s,a){t.call(this),this.from=e,this.to=n,this.gapFrom=r,this.gapTo=o,this.slice=i,this.insert=s,this.structure=!!a}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.apply=function(t){if(this.structure&&($t(t,this.from,this.gapFrom)||$t(t,this.gapTo,this.to)))return Vt.fail("Structure gap-replace would overwrite content");var e=t.slice(this.gapFrom,this.gapTo);if(e.openStart||e.openEnd)return Vt.fail("Gap is not a flat range");var n=this.slice.insertAt(this.insert,e.content);return n?Vt.fromReplace(t,this.from,this.to,n):Vt.fail("Content does not fit in gap")},e.prototype.getMap=function(){return new Tt([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])},e.prototype.invert=function(t){var n=this.gapTo-this.gapFrom;return new e(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,t.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)},e.prototype.map=function(t){var n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1),o=t.map(this.gapFrom,-1),i=t.map(this.gapTo,1);return n.deleted&&r.deleted||o<n.pos||i>r.pos?null:new e(n.pos,r.pos,o,i,this.slice,this.insert,this.structure)},e.prototype.toJSON=function(){var t={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(t.slice=this.slice.toJSON()),this.structure&&(t.structure=!0),t},e.fromJSON=function(t,n){if("number"!=typeof n.from||"number"!=typeof n.to||"number"!=typeof n.gapFrom||"number"!=typeof n.gapTo||"number"!=typeof n.insert)throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new e(n.from,n.to,n.gapFrom,n.gapTo,p.fromJSON(t,n.slice),n.insert,!!n.structure)},e}(Bt);function $t(t,e,n){for(var r=t.resolve(e),o=n-e,i=r.depth;o>0&&i>0&&r.indexAfter(i)==r.node(i).childCount;)i--,o--;if(o>0)for(var s=r.node(i).maybeChild(r.indexAfter(i));o>0;){if(!s||s.isLeaf)return!0;s=s.firstChild,o--}return!1}function Lt(t,e,n){return(0==e||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function _t(t){for(var e=t.parent.content.cutByIndex(t.startIndex,t.endIndex),n=t.depth;;--n){var r=t.$from.node(n),o=t.$from.index(n),i=t.$to.indexAfter(n);if(n<t.depth&&r.canReplace(o,i,e))return n;if(0==n||r.type.spec.isolating||!Lt(r,o,i))break}}function jt(t,e,n,r){void 0===r&&(r=t);var o=function(t,e){var n=t.parent,r=t.startIndex,o=t.endIndex,i=n.contentMatchAt(r).findWrapping(e);if(!i)return null;var s=i.length?i[0]:e;return n.canReplaceWith(r,o,s)?i:null}(t,e),i=o&&function(t,e){var n=t.parent,r=t.startIndex,o=t.endIndex,i=n.child(r),s=e.contentMatch.findWrapping(i.type);if(!s)return null;for(var a=(s.length?s[s.length-1]:e).contentMatch,c=r;a&&c<o;c++)a=a.matchType(n.child(c).type);return a&&a.validEnd?s:null}(r,e);return i?o.map(Wt).concat({type:e,attrs:n}).concat(i.map(Wt)):null}function Wt(t){return{type:t,attrs:null}}function Jt(t,e,n,r){void 0===n&&(n=1);var o=t.resolve(e),i=o.depth-n,s=r&&r[r.length-1]||o.parent;if(i<0||o.parent.type.spec.isolating||!o.parent.canReplace(o.index(),o.parent.childCount)||!s.type.validContent(o.parent.content.cutByIndex(o.index(),o.parent.childCount)))return!1;for(var a=o.depth-1,c=n-2;a>i;a--,c--){var l=o.node(a),h=o.index(a);if(l.type.spec.isolating)return!1;var p=l.content.cutByIndex(h,l.childCount),f=r&&r[c]||l;if(f!=l&&(p=p.replaceChild(0,f.type.create(f.attrs))),!l.canReplace(h+1,l.childCount)||!f.type.validContent(p))return!1}var d=o.indexAfter(i),u=r&&r[0];return o.node(i).canReplaceWith(d,d,u?u.type:o.node(i+1).type)}function Kt(t,e){var n=t.resolve(e),r=n.index();return Ht(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function Ht(t,e){return t&&e&&!t.isLeaf&&t.canAppend(e)}function Ut(t,e,n){void 0===n&&(n=-1);for(var r=t.resolve(e),o=r.depth;;o--){var i=void 0,s=void 0,a=r.index(o);if(o==r.depth?(i=r.nodeBefore,s=r.nodeAfter):n>0?(i=r.node(o+1),a++,s=r.node(o).maybeChild(a)):(i=r.node(o).maybeChild(a-1),s=r.node(o+1)),i&&!i.isTextblock&&Ht(i,s)&&r.node(o).canReplace(a,a+1))return e;if(0==o)break;e=n<0?r.before(o):r.after(o)}}function Gt(t,e,n){var r=t.resolve(e);if(!n.content.size)return e;for(var o=n.content,i=0;i<n.openStart;i++)o=o.firstChild.content;for(var s=1;s<=(0==n.openStart&&n.size?2:1);s++)for(var a=r.depth;a>=0;a--){var c=a==r.depth?0:r.pos<=(r.start(a+1)+r.end(a+1))/2?-1:1,l=r.index(a)+(c>0?1:0),h=r.node(a),p=!1;if(1==s)p=h.canReplace(l,l,o);else{var f=h.contentMatchAt(l).findWrapping(o.firstChild.type);p=f&&h.canReplaceWith(l,l,f[0])}if(p)return 0==c?r.pos:c<0?r.before(a+1):r.after(a+1)}return null}function Xt(t,e,n){for(var r=[],i=0;i<t.childCount;i++){var s=t.child(i);s.content.size&&(s=s.copy(Xt(s.content,e,s))),s.isInline&&(s=e(s,n,i)),r.push(s)}return o.fromArray(r)}Bt.jsonID("replaceAround",qt),Pt.prototype.lift=function(t,e){for(var n=t.$from,r=t.$to,i=t.depth,s=n.before(i+1),a=r.after(i+1),c=s,l=a,h=o.empty,f=0,d=i,u=!1;d>e;d--)u||n.index(d)>0?(u=!0,h=o.from(n.node(d).copy(h)),f++):c--;for(var m=o.empty,v=0,g=i,y=!1;g>e;g--)y||r.after(g+1)<r.end(g)?(y=!0,m=o.from(r.node(g).copy(m)),v++):l++;return this.step(new qt(c,l,s,a,new p(h.append(m),f,v),h.size-f,!0))},Pt.prototype.wrap=function(t,e){for(var n=o.empty,r=e.length-1;r>=0;r--)n=o.from(e[r].type.create(e[r].attrs,n));var i=t.start,s=t.end;return this.step(new qt(i,s,i,s,new p(n,0,0),e.length,!0))},Pt.prototype.setBlockType=function(t,e,n,r){var i=this;if(void 0===e&&(e=t),!n.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");var s=this.steps.length;return this.doc.nodesBetween(t,e,(function(t,e){if(t.isTextblock&&!t.hasMarkup(n,r)&&function(t,e,n){var r=t.resolve(e),o=r.index();return r.parent.canReplaceWith(o,o+1,n)}(i.doc,i.mapping.slice(s).map(e),n)){i.clearIncompatible(i.mapping.slice(s).map(e,1),n);var a=i.mapping.slice(s),c=a.map(e,1),l=a.map(e+t.nodeSize,1);return i.step(new qt(c,l,c+1,l-1,new p(o.from(n.create(r,null,t.marks)),0,0),1,!0)),!1}})),this},Pt.prototype.setNodeMarkup=function(t,e,n,r){var i=this.doc.nodeAt(t);if(!i)throw new RangeError("No node at given position");e||(e=i.type);var s=e.create(n,null,r||i.marks);if(i.isLeaf)return this.replaceWith(t,t+i.nodeSize,s);if(!e.validContent(i.content))throw new RangeError("Invalid content for node type "+e.name);return this.step(new qt(t,t+i.nodeSize,t+1,t+i.nodeSize-1,new p(o.from(s),0,0),1,!0))},Pt.prototype.split=function(t,e,n){void 0===e&&(e=1);for(var r=this.doc.resolve(t),i=o.empty,s=o.empty,a=r.depth,c=r.depth-e,l=e-1;a>c;a--,l--){i=o.from(r.node(a).copy(i));var h=n&&n[l];s=o.from(h?h.type.create(h.attrs,s):r.node(a).copy(s))}return this.step(new Ft(t,t,new p(i.append(s),e,e),!0))},Pt.prototype.join=function(t,e){void 0===e&&(e=1);var n=new Ft(t-e,t+e,p.empty,!0);return this.step(n)};var Yt=function(t){function e(e,n,r){t.call(this),this.from=e,this.to=n,this.mark=r}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.apply=function(t){var e=this,n=t.slice(this.from,this.to),r=t.resolve(this.from),o=r.node(r.sharedDepth(this.to)),i=new p(Xt(n.content,(function(t,n){return t.isAtom&&n.type.allowsMarkType(e.mark.type)?t.mark(e.mark.addToSet(t.marks)):t}),o),n.openStart,n.openEnd);return Vt.fromReplace(t,this.from,this.to,i)},e.prototype.invert=function(){return new Qt(this.from,this.to,this.mark)},e.prototype.map=function(t){var n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new e(n.pos,r.pos,this.mark)},e.prototype.merge=function(t){if(t instanceof e&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from)return new e(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark)},e.prototype.toJSON=function(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}},e.fromJSON=function(t,n){if("number"!=typeof n.from||"number"!=typeof n.to)throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new e(n.from,n.to,t.markFromJSON(n.mark))},e}(Bt);Bt.jsonID("addMark",Yt);var Qt=function(t){function e(e,n,r){t.call(this),this.from=e,this.to=n,this.mark=r}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.apply=function(t){var e=this,n=t.slice(this.from,this.to),r=new p(Xt(n.content,(function(t){return t.mark(e.mark.removeFromSet(t.marks))})),n.openStart,n.openEnd);return Vt.fromReplace(t,this.from,this.to,r)},e.prototype.invert=function(){return new Yt(this.from,this.to,this.mark)},e.prototype.map=function(t){var n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new e(n.pos,r.pos,this.mark)},e.prototype.merge=function(t){if(t instanceof e&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from)return new e(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark)},e.prototype.toJSON=function(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}},e.fromJSON=function(t,n){if("number"!=typeof n.from||"number"!=typeof n.to)throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new e(n.from,n.to,t.markFromJSON(n.mark))},e}(Bt);function Zt(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}Bt.jsonID("removeMark",Qt),Pt.prototype.addMark=function(t,e,n){var r=this,o=[],i=[],s=null,a=null;return this.doc.nodesBetween(t,e,(function(r,c,l){if(r.isInline){var h=r.marks;if(!n.isInSet(h)&&l.type.allowsMarkType(n.type)){for(var p=Math.max(c,t),f=Math.min(c+r.nodeSize,e),d=n.addToSet(h),u=0;u<h.length;u++)h[u].isInSet(d)||(s&&s.to==p&&s.mark.eq(h[u])?s.to=f:o.push(s=new Qt(p,f,h[u])));a&&a.to==p?a.to=f:i.push(a=new Yt(p,f,n))}}})),o.forEach((function(t){return r.step(t)})),i.forEach((function(t){return r.step(t)})),this},Pt.prototype.removeMark=function(t,e,n){var r=this;void 0===n&&(n=null);var o=[],i=0;return this.doc.nodesBetween(t,e,(function(r,s){if(r.isInline){i++;var a=null;if(n instanceof tt)for(var c,l=r.marks;c=n.isInSet(l);)(a||(a=[])).push(c),l=c.removeFromSet(l);else n?n.isInSet(r.marks)&&(a=[n]):a=r.marks;if(a&&a.length)for(var h=Math.min(s+r.nodeSize,e),p=0;p<a.length;p++){for(var f=a[p],d=void 0,u=0;u<o.length;u++){var m=o[u];m.step==i-1&&f.eq(o[u].style)&&(d=m)}d?(d.to=h,d.step=i):o.push({style:f,from:Math.max(s,t),to:h,step:i})}}})),o.forEach((function(t){return r.step(new Qt(t.from,t.to,t.style))})),this},Pt.prototype.clearIncompatible=function(t,e,n){void 0===n&&(n=e.contentMatch);for(var r=this.doc.nodeAt(t),i=[],s=t+1,a=0;a<r.childCount;a++){var c=r.child(a),l=s+c.nodeSize,h=n.matchType(c.type,c.attrs);if(h){n=h;for(var f=0;f<c.marks.length;f++)e.allowsMarkType(c.marks[f].type)||this.step(new Qt(s,l,c.marks[f]))}else i.push(new Ft(s,l,p.empty));s=l}if(!n.validEnd){var d=n.fillBefore(o.empty,!0);this.replace(s,s,new p(d,0,0))}for(var u=i.length-1;u>=0;u--)this.step(i[u]);return this},Pt.prototype.replace=function(t,e,n){void 0===e&&(e=t),void 0===n&&(n=p.empty);var r=function(t,e,n,r){if(void 0===n&&(n=e),void 0===r&&(r=p.empty),e==n&&!r.size)return null;var o=t.resolve(e),i=t.resolve(n);return Zt(o,i,r)?new Ft(e,n,r):new te(o,i,r).fit()}(this.doc,t,e,n);return r&&this.step(r),this},Pt.prototype.replaceWith=function(t,e,n){return this.replace(t,e,new p(o.from(n),0,0))},Pt.prototype.delete=function(t,e){return this.replace(t,e,p.empty)},Pt.prototype.insert=function(t,e){return this.replaceWith(t,t,e)};var te=function(t,e,n){this.$to=e,this.$from=t,this.unplaced=n,this.frontier=[];for(var r=0;r<=t.depth;r++){var i=t.node(r);this.frontier.push({type:i.type,match:i.contentMatchAt(t.indexAfter(r))})}this.placed=o.empty;for(var s=t.depth;s>0;s--)this.placed=o.from(t.node(s).copy(this.placed))},ee={depth:{configurable:!0}};function ne(t,e,n){return 0==e?t.cutByIndex(n):t.replaceChild(0,t.firstChild.copy(ne(t.firstChild.content,e-1,n)))}function re(t,e,n){return 0==e?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(re(t.lastChild.content,e-1,n)))}function oe(t,e){for(var n=0;n<e;n++)t=t.firstChild.content;return t}function ie(t,e,n){if(e<=0)return t;var r=t.content;return e>1&&(r=r.replaceChild(0,ie(r.firstChild,e-1,1==r.childCount?n-1:0))),e>0&&(r=t.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(t.type.contentMatch.matchFragment(r).fillBefore(o.empty,!0)))),t.copy(r)}function se(t,e,n,r,o){var i=t.node(e),s=o?t.indexAfter(e):t.index(e);if(s==i.childCount&&!n.compatibleContent(i.type))return null;var a=r.fillBefore(i.content,!0,s);return a&&!function(t,e,n){for(var r=n;r<e.childCount;r++)if(!t.allowsMarks(e.child(r).marks))return!0;return!1}(n,i.content,s)?a:null}function ae(t,e,n,r,i){if(e<n){var s=t.firstChild;t=t.replaceChild(0,s.copy(ae(s.content,e+1,n,r,s)))}if(e>r){var a=i.contentMatchAt(0),c=a.fillBefore(t).append(t);t=c.append(a.matchFragment(c).fillBefore(o.empty,!0))}return t}function ce(t,e){for(var n=[],r=Math.min(t.depth,e.depth);r>=0;r--){var o=t.start(r);if(o<t.pos-(t.depth-r)||e.end(r)>e.pos+(e.depth-r)||t.node(r).type.spec.isolating||e.node(r).type.spec.isolating)break;o==e.start(r)&&n.push(r)}return n}ee.depth.get=function(){return this.frontier.length-1},te.prototype.fit=function(){for(;this.unplaced.size;){var t=this.findFittable();t?this.placeNodes(t):this.openMore()||this.dropNode()}var e=this.mustMoveInline(),n=this.placed.size-this.depth-this.$from.depth,r=this.$from,o=this.close(e<0?this.$to:r.doc.resolve(e));if(!o)return null;for(var i=this.placed,s=r.depth,a=o.depth;s&&a&&1==i.childCount;)i=i.firstChild.content,s--,a--;var c=new p(i,s,a);return e>-1?new qt(r.pos,e,this.$to.pos,this.$to.end(),c,n):c.size||r.pos!=this.$to.pos?new Ft(r.pos,o.pos,c):void 0},te.prototype.findFittable=function(){for(var t=1;t<=2;t++)for(var e=this.unplaced.openStart;e>=0;e--)for(var n=void 0,r=(e?(n=oe(this.unplaced.content,e-1).firstChild).content:this.unplaced.content).firstChild,i=this.depth;i>=0;i--){var s=this.frontier[i],a=s.type,c=s.match,l=void 0,h=void 0;if(1==t&&(r?c.matchType(r.type)||(h=c.fillBefore(o.from(r),!1)):a.compatibleContent(n.type)))return{sliceDepth:e,frontierDepth:i,parent:n,inject:h};if(2==t&&r&&(l=c.findWrapping(r.type)))return{sliceDepth:e,frontierDepth:i,parent:n,wrap:l};if(n&&c.matchType(n.type))break}},te.prototype.openMore=function(){var t=this.unplaced,e=t.content,n=t.openStart,r=t.openEnd,o=oe(e,n);return!(!o.childCount||o.firstChild.isLeaf||(this.unplaced=new p(e,n+1,Math.max(r,o.size+n>=e.size-r?n+1:0)),0))},te.prototype.dropNode=function(){var t=this.unplaced,e=t.content,n=t.openStart,r=t.openEnd,o=oe(e,n);if(o.childCount<=1&&n>0){var i=e.size-n<=n+o.size;this.unplaced=new p(ne(e,n-1,1),n-1,i?n-1:r)}else this.unplaced=new p(ne(e,n,1),n,r)},te.prototype.placeNodes=function(t){for(var e=t.sliceDepth,n=t.frontierDepth,r=t.parent,i=t.inject,s=t.wrap;this.depth>n;)this.closeFrontierNode();if(s)for(var a=0;a<s.length;a++)this.openFrontierNode(s[a]);var c=this.unplaced,l=r?r.content:c.content,h=c.openStart-e,f=0,d=[],u=this.frontier[n],m=u.match,v=u.type;if(i){for(var g=0;g<i.childCount;g++)d.push(i.child(g));m=m.matchFragment(i)}for(var y=l.size+e-(c.content.size-c.openEnd);f<l.childCount;){var w=l.child(f),b=m.matchType(w.type);if(!b)break;(++f>1||0==h||w.content.size)&&(m=b,d.push(ie(w.mark(v.allowedMarks(w.marks)),1==f?h:0,f==l.childCount?y:-1)))}var x=f==l.childCount;x||(y=-1),this.placed=re(this.placed,n,o.from(d)),this.frontier[n].match=m,x&&y<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(var k=0,S=l;k<y;k++){var C=S.lastChild;this.frontier.push({type:C.type,match:C.contentMatchAt(C.childCount)}),S=C.content}this.unplaced=x?0==e?p.empty:new p(ne(c.content,e-1,1),e-1,y<0?c.openEnd:e-1):new p(ne(c.content,e,f),c.openStart,c.openEnd)},te.prototype.mustMoveInline=function(){if(!this.$to.parent.isTextblock||this.$to.end()==this.$to.pos)return-1;var t,e=this.frontier[this.depth];if(!e.type.isTextblock||!se(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(t=this.findCloseLevel(this.$to))&&t.depth==this.depth)return-1;for(var n=this.$to.depth,r=this.$to.after(n);n>1&&r==this.$to.end(--n);)++r;return r},te.prototype.findCloseLevel=function(t){t:for(var e=Math.min(this.depth,t.depth);e>=0;e--){var n=this.frontier[e],r=n.match,o=n.type,i=e<t.depth&&t.end(e+1)==t.pos+(t.depth-(e+1)),s=se(t,e,o,r,i);if(s){for(var a=e-1;a>=0;a--){var c=this.frontier[a],l=c.match,h=se(t,a,c.type,l,!0);if(!h||h.childCount)continue t}return{depth:e,fit:s,move:i?t.doc.resolve(t.after(e+1)):t}}}},te.prototype.close=function(t){var e=this.findCloseLevel(t);if(!e)return null;for(;this.depth>e.depth;)this.closeFrontierNode();e.fit.childCount&&(this.placed=re(this.placed,e.depth,e.fit)),t=e.move;for(var n=e.depth+1;n<=t.depth;n++){var r=t.node(n),o=r.type.contentMatch.fillBefore(r.content,!0,t.index(n));this.openFrontierNode(r.type,r.attrs,o)}return t},te.prototype.openFrontierNode=function(t,e,n){var r=this.frontier[this.depth];r.match=r.match.matchType(t),this.placed=re(this.placed,this.depth,o.from(t.create(e,n))),this.frontier.push({type:t,match:t.contentMatch})},te.prototype.closeFrontierNode=function(){var t=this.frontier.pop().match.fillBefore(o.empty,!0);t.childCount&&(this.placed=re(this.placed,this.frontier.length,t))},Object.defineProperties(te.prototype,ee),Pt.prototype.replaceRange=function(t,e,n){if(!n.size)return this.deleteRange(t,e);var r=this.doc.resolve(t),o=this.doc.resolve(e);if(Zt(r,o,n))return this.step(new Ft(t,e,n));var i=ce(r,this.doc.resolve(e));0==i[i.length-1]&&i.pop();var s=-(r.depth+1);i.unshift(s);for(var a=r.depth,c=r.pos-1;a>0;a--,c--){var l=r.node(a).type.spec;if(l.defining||l.isolating)break;i.indexOf(a)>-1?s=a:r.before(a)==c&&i.splice(1,0,-a)}for(var h=i.indexOf(s),f=[],d=n.openStart,u=n.content,m=0;;m++){var v=u.firstChild;if(f.push(v),m==n.openStart)break;u=v.content}d>0&&f[d-1].type.spec.defining&&r.node(h).type!=f[d-1].type?d-=1:d>=2&&f[d-1].isTextblock&&f[d-2].type.spec.defining&&r.node(h).type!=f[d-2].type&&(d-=2);for(var g=n.openStart;g>=0;g--){var y=(g+d+1)%(n.openStart+1),w=f[y];if(w)for(var b=0;b<i.length;b++){var x=i[(b+h)%i.length],k=!0;x<0&&(k=!1,x=-x);var S=r.node(x-1),C=r.index(x-1);if(S.canReplaceWith(C,C,w.type,w.marks))return this.replace(r.before(x),k?o.after(x):e,new p(ae(n.content,0,n.openStart,y),y,n.openEnd))}}for(var M=this.steps.length,O=i.length-1;O>=0&&(this.replace(t,e,n),!(this.steps.length>M));O--){var N=i[O];N<0||(t=r.before(N),e=o.after(N))}return this},Pt.prototype.replaceRangeWith=function(t,e,n){if(!n.isInline&&t==e&&this.doc.resolve(t).parent.content.size){var r=function(t,e,n){var r=t.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),n))return e;if(0==r.parentOffset)for(var o=r.depth-1;o>=0;o--){var i=r.index(o);if(r.node(o).canReplaceWith(i,i,n))return r.before(o+1);if(i>0)return null}if(r.parentOffset==r.parent.content.size)for(var s=r.depth-1;s>=0;s--){var a=r.indexAfter(s);if(r.node(s).canReplaceWith(a,a,n))return r.after(s+1);if(a<r.node(s).childCount)return null}}(this.doc,t,n.type);null!=r&&(t=e=r)}return this.replaceRange(t,e,new p(o.from(n),0,0))},Pt.prototype.deleteRange=function(t,e){for(var n=this.doc.resolve(t),r=this.doc.resolve(e),o=ce(n,r),i=0;i<o.length;i++){var s=o[i],a=i==o.length-1;if(a&&0==s||n.node(s).type.contentMatch.validEnd)return this.delete(n.start(s),r.end(s));if(s>0&&(a||n.node(s-1).canReplace(n.index(s-1),r.indexAfter(s-1))))return this.delete(n.before(s),r.after(s))}for(var c=1;c<=n.depth&&c<=r.depth;c++)if(t-n.start(c)==n.depth-c&&e>n.end(c)&&r.end(c)-e!=r.depth-c)return this.delete(n.before(c),e);return this.delete(t,e)};var le=Object.create(null),he=function(t,e,n){this.ranges=n||[new fe(t.min(e),t.max(e))],this.$anchor=t,this.$head=e},pe={anchor:{configurable:!0},head:{configurable:!0},from:{configurable:!0},to:{configurable:!0},$from:{configurable:!0},$to:{configurable:!0},empty:{configurable:!0}};pe.anchor.get=function(){return this.$anchor.pos},pe.head.get=function(){return this.$head.pos},pe.from.get=function(){return this.$from.pos},pe.to.get=function(){return this.$to.pos},pe.$from.get=function(){return this.ranges[0].$from},pe.$to.get=function(){return this.ranges[0].$to},pe.empty.get=function(){for(var t=this.ranges,e=0;e<t.length;e++)if(t[e].$from.pos!=t[e].$to.pos)return!1;return!0},he.prototype.content=function(){return this.$from.node(0).slice(this.from,this.to,!0)},he.prototype.replace=function(t,e){void 0===e&&(e=p.empty);for(var n=e.content.lastChild,r=null,o=0;o<e.openEnd;o++)r=n,n=n.lastChild;for(var i=t.steps.length,s=this.ranges,a=0;a<s.length;a++){var c=s[a],l=c.$from,h=c.$to,f=t.mapping.slice(i);t.replaceRange(f.map(l.pos),f.map(h.pos),a?p.empty:e),0==a&&be(t,i,(n?n.isInline:r&&r.isTextblock)?-1:1)}},he.prototype.replaceWith=function(t,e){for(var n=t.steps.length,r=this.ranges,o=0;o<r.length;o++){var i=r[o],s=i.$from,a=i.$to,c=t.mapping.slice(n),l=c.map(s.pos),h=c.map(a.pos);o?t.deleteRange(l,h):(t.replaceRangeWith(l,h,e),be(t,n,e.isInline?-1:1))}},he.findFrom=function(t,e,n){var r=t.parent.inlineContent?new de(t):we(t.node(0),t.parent,t.pos,t.index(),e,n);if(r)return r;for(var o=t.depth-1;o>=0;o--){var i=e<0?we(t.node(0),t.node(o),t.before(o+1),t.index(o),e,n):we(t.node(0),t.node(o),t.after(o+1),t.index(o)+1,e,n);if(i)return i}},he.near=function(t,e){return void 0===e&&(e=1),this.findFrom(t,e)||this.findFrom(t,-e)||new ge(t.node(0))},he.atStart=function(t){return we(t,t,0,0,1)||new ge(t)},he.atEnd=function(t){return we(t,t,t.content.size,t.childCount,-1)||new ge(t)},he.fromJSON=function(t,e){if(!e||!e.type)throw new RangeError("Invalid input for Selection.fromJSON");var n=le[e.type];if(!n)throw new RangeError("No selection type "+e.type+" defined");return n.fromJSON(t,e)},he.jsonID=function(t,e){if(t in le)throw new RangeError("Duplicate use of selection JSON ID "+t);return le[t]=e,e.prototype.jsonID=t,e},he.prototype.getBookmark=function(){return de.between(this.$anchor,this.$head).getBookmark()},Object.defineProperties(he.prototype,pe),he.prototype.visible=!0;var fe=function(t,e){this.$from=t,this.$to=e},de=function(t){function e(e,n){void 0===n&&(n=e),t.call(this,e,n)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={$cursor:{configurable:!0}};return n.$cursor.get=function(){return this.$anchor.pos==this.$head.pos?this.$head:null},e.prototype.map=function(n,r){var o=n.resolve(r.map(this.head));if(!o.parent.inlineContent)return t.near(o);var i=n.resolve(r.map(this.anchor));return new e(i.parent.inlineContent?i:o,o)},e.prototype.replace=function(e,n){if(void 0===n&&(n=p.empty),t.prototype.replace.call(this,e,n),n==p.empty){var r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}},e.prototype.eq=function(t){return t instanceof e&&t.anchor==this.anchor&&t.head==this.head},e.prototype.getBookmark=function(){return new ue(this.anchor,this.head)},e.prototype.toJSON=function(){return{type:"text",anchor:this.anchor,head:this.head}},e.fromJSON=function(t,n){if("number"!=typeof n.anchor||"number"!=typeof n.head)throw new RangeError("Invalid input for TextSelection.fromJSON");return new e(t.resolve(n.anchor),t.resolve(n.head))},e.create=function(t,e,n){void 0===n&&(n=e);var r=t.resolve(e);return new this(r,n==e?r:t.resolve(n))},e.between=function(n,r,o){var i=n.pos-r.pos;if(o&&!i||(o=i>=0?1:-1),!r.parent.inlineContent){var s=t.findFrom(r,o,!0)||t.findFrom(r,-o,!0);if(!s)return t.near(r,o);r=s.$head}return n.parent.inlineContent||(0==i||(n=(t.findFrom(n,-o,!0)||t.findFrom(n,o,!0)).$anchor).pos<r.pos!=i<0)&&(n=r),new e(n,r)},Object.defineProperties(e.prototype,n),e}(he);he.jsonID("text",de);var ue=function(t,e){this.anchor=t,this.head=e};ue.prototype.map=function(t){return new ue(t.map(this.anchor),t.map(this.head))},ue.prototype.resolve=function(t){return de.between(t.resolve(this.anchor),t.resolve(this.head))};var me=function(t){function e(e){var n=e.nodeAfter,r=e.node(0).resolve(e.pos+n.nodeSize);t.call(this,e,r),this.node=n}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.map=function(n,r){var o=r.mapResult(this.anchor),i=o.deleted,s=o.pos,a=n.resolve(s);return i?t.near(a):new e(a)},e.prototype.content=function(){return new p(o.from(this.node),0,0)},e.prototype.eq=function(t){return t instanceof e&&t.anchor==this.anchor},e.prototype.toJSON=function(){return{type:"node",anchor:this.anchor}},e.prototype.getBookmark=function(){return new ve(this.anchor)},e.fromJSON=function(t,n){if("number"!=typeof n.anchor)throw new RangeError("Invalid input for NodeSelection.fromJSON");return new e(t.resolve(n.anchor))},e.create=function(t,e){return new this(t.resolve(e))},e.isSelectable=function(t){return!t.isText&&!1!==t.type.spec.selectable},e}(he);me.prototype.visible=!1,he.jsonID("node",me);var ve=function(t){this.anchor=t};ve.prototype.map=function(t){var e=t.mapResult(this.anchor),n=e.deleted,r=e.pos;return n?new ue(r,r):new ve(r)},ve.prototype.resolve=function(t){var e=t.resolve(this.anchor),n=e.nodeAfter;return n&&me.isSelectable(n)?new me(e):he.near(e)};var ge=function(t){function e(e){t.call(this,e.resolve(0),e.resolve(e.content.size))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.replace=function(e,n){if(void 0===n&&(n=p.empty),n==p.empty){e.delete(0,e.doc.content.size);var r=t.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else t.prototype.replace.call(this,e,n)},e.prototype.toJSON=function(){return{type:"all"}},e.fromJSON=function(t){return new e(t)},e.prototype.map=function(t){return new e(t)},e.prototype.eq=function(t){return t instanceof e},e.prototype.getBookmark=function(){return ye},e}(he);he.jsonID("all",ge);var ye={map:function(){return this},resolve:function(t){return new ge(t)}};function we(t,e,n,r,o,i){if(e.inlineContent)return de.create(t,n);for(var s=r-(o>0?0:1);o>0?s<e.childCount:s>=0;s+=o){var a=e.child(s);if(a.isAtom){if(!i&&me.isSelectable(a))return me.create(t,n-(o<0?a.nodeSize:0))}else{var c=we(t,a,n+o,o<0?a.childCount:0,o,i);if(c)return c}n+=a.nodeSize*o}}function be(t,e,n){var r=t.steps.length-1;if(!(r<e)){var o,i=t.steps[r];(i instanceof Ft||i instanceof qt)&&(t.mapping.maps[r].forEach((function(t,e,n,r){null==o&&(o=r)})),t.setSelection(he.near(t.doc.resolve(o),n)))}}var xe=function(t){function e(e){t.call(this,e.doc),this.time=Date.now(),this.curSelection=e.selection,this.curSelectionFor=0,this.storedMarks=e.storedMarks,this.updated=0,this.meta=Object.create(null)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={selection:{configurable:!0},selectionSet:{configurable:!0},storedMarksSet:{configurable:!0},isGeneric:{configurable:!0},scrolledIntoView:{configurable:!0}};return n.selection.get=function(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection},e.prototype.setSelection=function(t){if(t.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=t,this.curSelectionFor=this.steps.length,this.updated=-3&(1|this.updated),this.storedMarks=null,this},n.selectionSet.get=function(){return(1&this.updated)>0},e.prototype.setStoredMarks=function(t){return this.storedMarks=t,this.updated|=2,this},e.prototype.ensureMarks=function(t){return l.sameSet(this.storedMarks||this.selection.$from.marks(),t)||this.setStoredMarks(t),this},e.prototype.addStoredMark=function(t){return this.ensureMarks(t.addToSet(this.storedMarks||this.selection.$head.marks()))},e.prototype.removeStoredMark=function(t){return this.ensureMarks(t.removeFromSet(this.storedMarks||this.selection.$head.marks()))},n.storedMarksSet.get=function(){return(2&this.updated)>0},e.prototype.addStep=function(e,n){t.prototype.addStep.call(this,e,n),this.updated=-3&this.updated,this.storedMarks=null},e.prototype.setTime=function(t){return this.time=t,this},e.prototype.replaceSelection=function(t){return this.selection.replace(this,t),this},e.prototype.replaceSelectionWith=function(t,e){var n=this.selection;return!1!==e&&(t=t.mark(this.storedMarks||(n.empty?n.$from.marks():n.$from.marksAcross(n.$to)||l.none))),n.replaceWith(this,t),this},e.prototype.deleteSelection=function(){return this.selection.replace(this),this},e.prototype.insertText=function(t,e,n){void 0===n&&(n=e);var r=this.doc.type.schema;if(null==e)return t?this.replaceSelectionWith(r.text(t),!0):this.deleteSelection();if(!t)return this.deleteRange(e,n);var o=this.storedMarks;if(!o){var i=this.doc.resolve(e);o=n==e?i.marks():i.marksAcross(this.doc.resolve(n))}return this.replaceRangeWith(e,n,r.text(t,o)),this.selection.empty||this.setSelection(he.near(this.selection.$to)),this},e.prototype.setMeta=function(t,e){return this.meta["string"==typeof t?t:t.key]=e,this},e.prototype.getMeta=function(t){return this.meta["string"==typeof t?t:t.key]},n.isGeneric.get=function(){for(var t in this.meta)return!1;return!0},e.prototype.scrollIntoView=function(){return this.updated|=4,this},n.scrolledIntoView.get=function(){return(4&this.updated)>0},Object.defineProperties(e.prototype,n),e}(Pt);function ke(t,e){return e&&t?t.bind(e):t}var Se=function(t,e,n){this.name=t,this.init=ke(e.init,n),this.apply=ke(e.apply,n)},Ce=[new Se("doc",{init:function(t){return t.doc||t.schema.topNodeType.createAndFill()},apply:function(t){return t.doc}}),new Se("selection",{init:function(t,e){return t.selection||he.atStart(e.doc)},apply:function(t){return t.selection}}),new Se("storedMarks",{init:function(t){return t.storedMarks||null},apply:function(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new Se("scrollToSelection",{init:function(){return 0},apply:function(t,e){return t.scrolledIntoView?e+1:e}})],Me=function(t,e){var n=this;this.schema=t,this.fields=Ce.concat(),this.plugins=[],this.pluginsByKey=Object.create(null),e&&e.forEach((function(t){if(n.pluginsByKey[t.key])throw new RangeError("Adding different instances of a keyed plugin ("+t.key+")");n.plugins.push(t),n.pluginsByKey[t.key]=t,t.spec.state&&n.fields.push(new Se(t.key,t.spec.state,t))}))},Oe=function(t){this.config=t},Ne={schema:{configurable:!0},plugins:{configurable:!0},tr:{configurable:!0}};Ne.schema.get=function(){return this.config.schema},Ne.plugins.get=function(){return this.config.plugins},Oe.prototype.apply=function(t){return this.applyTransaction(t).state},Oe.prototype.filterTransaction=function(t,e){void 0===e&&(e=-1);for(var n=0;n<this.config.plugins.length;n++)if(n!=e){var r=this.config.plugins[n];if(r.spec.filterTransaction&&!r.spec.filterTransaction.call(r,t,this))return!1}return!0},Oe.prototype.applyTransaction=function(t){if(!this.filterTransaction(t))return{state:this,transactions:[]};for(var e=[t],n=this.applyInner(t),r=null;;){for(var o=!1,i=0;i<this.config.plugins.length;i++){var s=this.config.plugins[i];if(s.spec.appendTransaction){var a=r?r[i].n:0,c=r?r[i].state:this,l=a<e.length&&s.spec.appendTransaction.call(s,a?e.slice(a):e,c,n);if(l&&n.filterTransaction(l,i)){if(l.setMeta("appendedTransaction",t),!r){r=[];for(var h=0;h<this.config.plugins.length;h++)r.push(h<i?{state:n,n:e.length}:{state:this,n:0})}e.push(l),n=n.applyInner(l),o=!0}r&&(r[i]={state:n,n:e.length})}}if(!o)return{state:n,transactions:e}}},Oe.prototype.applyInner=function(t){if(!t.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");for(var e=new Oe(this.config),n=this.config.fields,r=0;r<n.length;r++){var o=n[r];e[o.name]=o.apply(t,this[o.name],this,e)}for(var i=0;i<De.length;i++)De[i](this,t,e);return e},Ne.tr.get=function(){return new xe(this)},Oe.create=function(t){for(var e=new Me(t.doc?t.doc.type.schema:t.schema,t.plugins),n=new Oe(e),r=0;r<e.fields.length;r++)n[e.fields[r].name]=e.fields[r].init(t,n);return n},Oe.prototype.reconfigure=function(t){for(var e=new Me(this.schema,t.plugins),n=e.fields,r=new Oe(e),o=0;o<n.length;o++){var i=n[o].name;r[i]=this.hasOwnProperty(i)?this[i]:n[o].init(t,r)}return r},Oe.prototype.toJSON=function(t){var e={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(e.storedMarks=this.storedMarks.map((function(t){return t.toJSON()}))),t&&"object"==typeof t)for(var n in t){if("doc"==n||"selection"==n)throw new RangeError("The JSON fields `doc` and `selection` are reserved");var r=t[n],o=r.spec.state;o&&o.toJSON&&(e[n]=o.toJSON.call(r,this[r.key]))}return e},Oe.fromJSON=function(t,e,n){if(!e)throw new RangeError("Invalid input for EditorState.fromJSON");if(!t.schema)throw new RangeError("Required config field 'schema' missing");var r=new Me(t.schema,t.plugins),o=new Oe(r);return r.fields.forEach((function(r){if("doc"==r.name)o.doc=P.fromJSON(t.schema,e.doc);else if("selection"==r.name)o.selection=he.fromJSON(o.doc,e.selection);else if("storedMarks"==r.name)e.storedMarks&&(o.storedMarks=e.storedMarks.map(t.schema.markFromJSON));else{if(n)for(var i in n){var s=n[i],a=s.spec.state;if(s.key==r.name&&a&&a.fromJSON&&Object.prototype.hasOwnProperty.call(e,i))return void(o[r.name]=a.fromJSON.call(s,t,e[i],o))}o[r.name]=r.init(t,o)}})),o},Oe.addApplyListener=function(t){De.push(t)},Oe.removeApplyListener=function(t){var e=De.indexOf(t);e>-1&&De.splice(e,1)},Object.defineProperties(Oe.prototype,Ne);var De=[];function Te(t,e,n){for(var r in t){var o=t[r];o instanceof Function?o=o.bind(e):"handleDOMEvents"==r&&(o=Te(o,e,{})),n[r]=o}return n}var Ee=function(t){this.props={},t.props&&Te(t.props,this,this.props),this.spec=t,this.key=t.key?t.key.key:Pe("plugin")};Ee.prototype.getState=function(t){return t[this.key]};var Ae=Object.create(null);function Pe(t){return t in Ae?t+"$"+ ++Ae[t]:(Ae[t]=0,t+"$")}var ze=function(t){void 0===t&&(t="key"),this.key=Pe(t)};ze.prototype.get=function(t){return t.config.pluginsByKey[this.key]},ze.prototype.getState=function(t){return t[this.key]};var Ie={};if("undefined"!=typeof navigator&&"undefined"!=typeof document){var Re=/Edge\/(\d+)/.exec(navigator.userAgent),Be=/MSIE \d/.test(navigator.userAgent),Ve=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);Ie.mac=/Mac/.test(navigator.platform);var Fe=Ie.ie=!!(Be||Ve||Re);Ie.ie_version=Be?document.documentMode||6:Ve?+Ve[1]:Re?+Re[1]:null,Ie.gecko=!Fe&&/gecko\/(\d+)/i.test(navigator.userAgent),Ie.gecko_version=Ie.gecko&&+(/Firefox\/(\d+)/.exec(navigator.userAgent)||[0,0])[1];var qe=!Fe&&/Chrome\/(\d+)/.exec(navigator.userAgent);Ie.chrome=!!qe,Ie.chrome_version=qe&&+qe[1],Ie.safari=!Fe&&/Apple Computer/.test(navigator.vendor),Ie.ios=Ie.safari&&(/Mobile\/\w+/.test(navigator.userAgent)||navigator.maxTouchPoints>2),Ie.android=/Android \d/.test(navigator.userAgent),Ie.webkit="webkitFontSmoothing"in document.documentElement.style,Ie.webkit_version=Ie.webkit&&+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]}var $e=function(t){for(var e=0;;e++)if(!(t=t.previousSibling))return e},Le=function(t){var e=t.assignedSlot||t.parentNode;return e&&11==e.nodeType?e.host:e},_e=null,je=function(t,e,n){var r=_e||(_e=document.createRange());return r.setEnd(t,null==n?t.nodeValue.length:n),r.setStart(t,e||0),r},We=function(t,e,n,r){return n&&(Ke(t,e,n,r,-1)||Ke(t,e,n,r,1))},Je=/^(img|br|input|textarea|hr)$/i;function Ke(t,e,n,r,o){for(;;){if(t==n&&e==r)return!0;if(e==(o<0?0:He(t))){var i=t.parentNode;if(1!=i.nodeType||Ue(t)||Je.test(t.nodeName)||"false"==t.contentEditable)return!1;e=$e(t)+(o<0?0:1),t=i}else{if(1!=t.nodeType)return!1;if("false"==(t=t.childNodes[e+(o<0?-1:0)]).contentEditable)return!1;e=o<0?He(t):0}}}function He(t){return 3==t.nodeType?t.nodeValue.length:t.childNodes.length}function Ue(t){for(var e,n=t;n&&!(e=n.pmViewDesc);n=n.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==t||e.contentDOM==t)}var Ge=function(t){var e=t.isCollapsed;return e&&Ie.chrome&&t.rangeCount&&!t.getRangeAt(0).collapsed&&(e=!1),e};function Xe(t,e){var n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}function Ye(t){return{left:0,right:t.documentElement.clientWidth,top:0,bottom:t.documentElement.clientHeight}}function Qe(t,e){return"number"==typeof t?t:t[e]}function Ze(t){var e=t.getBoundingClientRect(),n=e.width/t.offsetWidth||1,r=e.height/t.offsetHeight||1;return{left:e.left,right:e.left+t.clientWidth*n,top:e.top,bottom:e.top+t.clientHeight*r}}function tn(t,e,n){for(var r=t.someProp("scrollThreshold")||0,o=t.someProp("scrollMargin")||5,i=t.dom.ownerDocument,s=n||t.dom;s;s=Le(s))if(1==s.nodeType){var a=s==i.body||1!=s.nodeType,c=a?Ye(i):Ze(s),l=0,h=0;if(e.top<c.top+Qe(r,"top")?h=-(c.top-e.top+Qe(o,"top")):e.bottom>c.bottom-Qe(r,"bottom")&&(h=e.bottom-c.bottom+Qe(o,"bottom")),e.left<c.left+Qe(r,"left")?l=-(c.left-e.left+Qe(o,"left")):e.right>c.right-Qe(r,"right")&&(l=e.right-c.right+Qe(o,"right")),l||h)if(a)i.defaultView.scrollBy(l,h);else{var p=s.scrollLeft,f=s.scrollTop;h&&(s.scrollTop+=h),l&&(s.scrollLeft+=l);var d=s.scrollLeft-p,u=s.scrollTop-f;e={left:e.left-d,top:e.top-u,right:e.right-d,bottom:e.bottom-u}}if(a)break}}function en(t){for(var e=[],n=t.ownerDocument;t&&(e.push({dom:t,top:t.scrollTop,left:t.scrollLeft}),t!=n);t=Le(t));return e}function nn(t,e){for(var n=0;n<t.length;n++){var r=t[n],o=r.dom,i=r.top,s=r.left;o.scrollTop!=i+e&&(o.scrollTop=i+e),o.scrollLeft!=s&&(o.scrollLeft=s)}}var rn=null;function on(t,e){for(var n,r,o=2e8,i=0,s=e.top,a=e.top,c=t.firstChild,l=0;c;c=c.nextSibling,l++){var h=void 0;if(1==c.nodeType)h=c.getClientRects();else{if(3!=c.nodeType)continue;h=je(c).getClientRects()}for(var p=0;p<h.length;p++){var f=h[p];if(f.top<=s&&f.bottom>=a){s=Math.max(f.bottom,s),a=Math.min(f.top,a);var d=f.left>e.left?f.left-e.left:f.right<e.left?e.left-f.right:0;if(d<o){n=c,o=d,r=d&&3==n.nodeType?{left:f.right<e.left?f.right:f.left,top:e.top}:e,1==c.nodeType&&d&&(i=l+(e.left>=(f.left+f.right)/2?1:0));continue}}!n&&(e.left>=f.right&&e.top>=f.top||e.left>=f.left&&e.top>=f.bottom)&&(i=l+1)}}return n&&3==n.nodeType?function(t,e){for(var n=t.nodeValue.length,r=document.createRange(),o=0;o<n;o++){r.setEnd(t,o+1),r.setStart(t,o);var i=ln(r,1);if(i.top!=i.bottom&&sn(e,i))return{node:t,offset:o+(e.left>=(i.left+i.right)/2?1:0)}}return{node:t,offset:0}}(n,r):!n||o&&1==n.nodeType?{node:t,offset:i}:on(n,r)}function sn(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function an(t,e,n){var r=t.childNodes.length;if(r&&n.top<n.bottom)for(var o=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-n.top)/(n.bottom-n.top))-2)),i=o;;){var s=t.childNodes[i];if(1==s.nodeType)for(var a=s.getClientRects(),c=0;c<a.length;c++){var l=a[c];if(sn(e,l))return an(s,e,l)}if((i=(i+1)%r)==o)break}return t}function cn(t,e){var n,r,o,i,s=t.root;if(s.caretPositionFromPoint)try{var a=s.caretPositionFromPoint(e.left,e.top);a&&(o=(n=a).offsetNode,i=n.offset)}catch(t){}if(!o&&s.caretRangeFromPoint){var c=s.caretRangeFromPoint(e.left,e.top);c&&(o=(r=c).startContainer,i=r.startOffset)}var l,h=s.elementFromPoint(e.left,e.top+1);if(!h||!t.dom.contains(1!=h.nodeType?h.parentNode:h)){var p=t.dom.getBoundingClientRect();if(!sn(e,p))return null;if(!(h=an(t.dom,e,p)))return null}if(Ie.safari&&h.draggable&&(o=i=null),h=function(t,e){var n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}(h,e),o){if(Ie.gecko&&1==o.nodeType&&(i=Math.min(i,o.childNodes.length))<o.childNodes.length){var f,d=o.childNodes[i];"IMG"==d.nodeName&&(f=d.getBoundingClientRect()).right<=e.left&&f.bottom>e.top&&i++}o==t.dom&&i==o.childNodes.length-1&&1==o.lastChild.nodeType&&e.top>o.lastChild.getBoundingClientRect().bottom?l=t.state.doc.content.size:0!=i&&1==o.nodeType&&"BR"==o.childNodes[i-1].nodeName||(l=function(t,e,n,r){for(var o=-1,i=e;i!=t.dom;){var s=t.docView.nearestDesc(i,!0);if(!s)return null;if(s.node.isBlock&&s.parent){var a=s.dom.getBoundingClientRect();if(a.left>r.left||a.top>r.top)o=s.posBefore;else{if(!(a.right<r.left||a.bottom<r.top))break;o=s.posAfter}}i=s.dom.parentNode}return o>-1?o:t.docView.posFromDOM(e,n)}(t,o,i,e))}null==l&&(l=function(t,e,n){var r=on(e,n),o=r.node,i=r.offset,s=-1;if(1==o.nodeType&&!o.firstChild){var a=o.getBoundingClientRect();s=a.left!=a.right&&n.left>(a.left+a.right)/2?1:-1}return t.docView.posFromDOM(o,i,s)}(t,h,e));var u=t.docView.nearestDesc(h,!0);return{pos:l,inside:u?u.posAtStart-u.border:-1}}function ln(t,e){var n=t.getClientRects();return n.length?n[e<0?0:n.length-1]:t.getBoundingClientRect()}var hn=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function pn(t,e,n){var r=t.docView.domFromPos(e,n<0?-1:1),o=r.node,i=r.offset,s=Ie.webkit||Ie.gecko;if(3==o.nodeType){if(!s||!hn.test(o.nodeValue)&&(n<0?i:i!=o.nodeValue.length)){var a=i,c=i,l=n<0?1:-1;return n<0&&!i?(c++,l=-1):n>=0&&i==o.nodeValue.length?(a--,l=1):n<0?a--:c++,fn(ln(je(o,a,c),l),l<0)}var h=ln(je(o,i,i),n);if(Ie.gecko&&i&&/\s/.test(o.nodeValue[i-1])&&i<o.nodeValue.length){var p=ln(je(o,i-1,i-1),-1);if(p.top==h.top){var f=ln(je(o,i,i+1),-1);if(f.top!=h.top)return fn(f,f.left<p.left)}}return h}if(!t.state.doc.resolve(e).parent.inlineContent){if(i&&(n<0||i==He(o))){var d=o.childNodes[i-1];if(1==d.nodeType)return dn(d.getBoundingClientRect(),!1)}if(i<He(o)){var u=o.childNodes[i];if(1==u.nodeType)return dn(u.getBoundingClientRect(),!0)}return dn(o.getBoundingClientRect(),n>=0)}if(i&&(n<0||i==He(o))){var m=o.childNodes[i-1],v=3==m.nodeType?je(m,He(m)-(s?0:1)):1!=m.nodeType||"BR"==m.nodeName&&m.nextSibling?null:m;if(v)return fn(ln(v,1),!1)}if(i<He(o)){var g=o.childNodes[i],y=3==g.nodeType?je(g,0,s?0:1):1==g.nodeType?g:null;if(y)return fn(ln(y,-1),!0)}return fn(ln(3==o.nodeType?je(o):o,-n),n>=0)}function fn(t,e){if(0==t.width)return t;var n=e?t.left:t.right;return{top:t.top,bottom:t.bottom,left:n,right:n}}function dn(t,e){if(0==t.height)return t;var n=e?t.top:t.bottom;return{top:n,bottom:n,left:t.left,right:t.right}}function un(t,e,n){var r=t.state,o=t.root.activeElement;r!=e&&t.updateState(e),o!=t.dom&&t.focus();try{return n()}finally{r!=e&&t.updateState(r),o!=t.dom&&o&&o.focus()}}var mn=/[\u0590-\u08ac]/,vn=null,gn=null,yn=!1;var wn=function(t,e,n,r){this.parent=t,this.children=e,this.dom=n,n.pmViewDesc=this,this.contentDOM=r,this.dirty=0},bn={beforePosition:{configurable:!0},size:{configurable:!0},border:{configurable:!0},posBefore:{configurable:!0},posAtStart:{configurable:!0},posAfter:{configurable:!0},posAtEnd:{configurable:!0},contentLost:{configurable:!0},domAtom:{configurable:!0}};wn.prototype.matchesWidget=function(){return!1},wn.prototype.matchesMark=function(){return!1},wn.prototype.matchesNode=function(){return!1},wn.prototype.matchesHack=function(){return!1},bn.beforePosition.get=function(){return!1},wn.prototype.parseRule=function(){return null},wn.prototype.stopEvent=function(){return!1},bn.size.get=function(){for(var t=0,e=0;e<this.children.length;e++)t+=this.children[e].size;return t},bn.border.get=function(){return 0},wn.prototype.destroy=function(){this.parent=null,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=null);for(var t=0;t<this.children.length;t++)this.children[t].destroy()},wn.prototype.posBeforeChild=function(t){for(var e=0,n=this.posAtStart;e<this.children.length;e++){var r=this.children[e];if(r==t)return n;n+=r.size}},bn.posBefore.get=function(){return this.parent.posBeforeChild(this)},bn.posAtStart.get=function(){return this.parent?this.parent.posBeforeChild(this)+this.border:0},bn.posAfter.get=function(){return this.posBefore+this.size},bn.posAtEnd.get=function(){return this.posAtStart+this.size-2*this.border},wn.prototype.localPosFromDOM=function(t,e,n){if(this.contentDOM&&this.contentDOM.contains(1==t.nodeType?t:t.parentNode)){if(n<0){var r,o;if(t==this.contentDOM)r=t.childNodes[e-1];else{for(;t.parentNode!=this.contentDOM;)t=t.parentNode;r=t.previousSibling}for(;r&&(!(o=r.pmViewDesc)||o.parent!=this);)r=r.previousSibling;return r?this.posBeforeChild(o)+o.size:this.posAtStart}var i,s;if(t==this.contentDOM)i=t.childNodes[e];else{for(;t.parentNode!=this.contentDOM;)t=t.parentNode;i=t.nextSibling}for(;i&&(!(s=i.pmViewDesc)||s.parent!=this);)i=i.nextSibling;return i?this.posBeforeChild(s):this.posAtEnd}var a;if(t==this.dom&&this.contentDOM)a=e>$e(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))a=2&t.compareDocumentPosition(this.contentDOM);else if(this.dom.firstChild){if(0==e)for(var c=t;;c=c.parentNode){if(c==this.dom){a=!1;break}if(c.parentNode.firstChild!=c)break}if(null==a&&e==t.childNodes.length)for(var l=t;;l=l.parentNode){if(l==this.dom){a=!0;break}if(l.parentNode.lastChild!=l)break}}return(null==a?n>0:a)?this.posAtEnd:this.posAtStart},wn.prototype.nearestDesc=function(t,e){for(var n=!0,r=t;r;r=r.parentNode){var o=this.getDesc(r);if(o&&(!e||o.node)){if(!n||!o.nodeDOM||(1==o.nodeDOM.nodeType?o.nodeDOM.contains(1==t.nodeType?t:t.parentNode):o.nodeDOM==t))return o;n=!1}}},wn.prototype.getDesc=function(t){for(var e=t.pmViewDesc,n=e;n;n=n.parent)if(n==this)return e},wn.prototype.posFromDOM=function(t,e,n){for(var r=t;r;r=r.parentNode){var o=this.getDesc(r);if(o)return o.localPosFromDOM(t,e,n)}return-1},wn.prototype.descAt=function(t){for(var e=0,n=0;e<this.children.length;e++){var r=this.children[e],o=n+r.size;if(n==t&&o!=n){for(;!r.border&&r.children.length;)r=r.children[0];return r}if(t<o)return r.descAt(t-n-r.border);n=o}},wn.prototype.domFromPos=function(t,e){if(!this.contentDOM)return{node:this.dom,offset:0};for(var n=0,r=0,o=!0;;r++,o=!1){for(;r<this.children.length&&(this.children[r].beforePosition||this.children[r].dom.parentNode!=this.contentDOM);)n+=this.children[r++].size;var i=r==this.children.length?null:this.children[r];if(n==t&&(0==e||!i||!i.size||i.border||e<0&&o)||i&&i.domAtom&&t<n+i.size)return{node:this.contentDOM,offset:i?$e(i.dom):this.contentDOM.childNodes.length};if(!i)throw new Error("Invalid position "+t);var s=n+i.size;if(!i.domAtom&&(e<0&&!i.border?s>=t:s>t)&&(s>t||r+1>=this.children.length||!this.children[r+1].beforePosition))return i.domFromPos(t-n-i.border,e);n=s}},wn.prototype.parseRange=function(t,e,n){if(void 0===n&&(n=0),0==this.children.length)return{node:this.contentDOM,from:t,to:e,fromOffset:0,toOffset:this.contentDOM.childNodes.length};for(var r=-1,o=-1,i=n,s=0;;s++){var a=this.children[s],c=i+a.size;if(-1==r&&t<=c){var l=i+a.border;if(t>=l&&e<=c-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(t,e,l);t=i;for(var h=s;h>0;h--){var p=this.children[h-1];if(p.size&&p.dom.parentNode==this.contentDOM&&!p.emptyChildAt(1)){r=$e(p.dom)+1;break}t-=p.size}-1==r&&(r=0)}if(r>-1&&(c>e||s==this.children.length-1)){e=c;for(var f=s+1;f<this.children.length;f++){var d=this.children[f];if(d.size&&d.dom.parentNode==this.contentDOM&&!d.emptyChildAt(-1)){o=$e(d.dom);break}e+=d.size}-1==o&&(o=this.contentDOM.childNodes.length);break}i=c}return{node:this.contentDOM,from:t,to:e,fromOffset:r,toOffset:o}},wn.prototype.emptyChildAt=function(t){if(this.border||!this.contentDOM||!this.children.length)return!1;var e=this.children[t<0?0:this.children.length-1];return 0==e.size||e.emptyChildAt(t)},wn.prototype.domAfterPos=function(t){var e=this.domFromPos(t,0),n=e.node,r=e.offset;if(1!=n.nodeType||r==n.childNodes.length)throw new RangeError("No node after pos "+t);return n.childNodes[r]},wn.prototype.setSelection=function(t,e,n,r){for(var o=Math.min(t,e),i=Math.max(t,e),s=0,a=0;s<this.children.length;s++){var c=this.children[s],l=a+c.size;if(o>a&&i<l)return c.setSelection(t-a-c.border,e-a-c.border,n,r);a=l}var h=this.domFromPos(t,t?-1:1),p=e==t?h:this.domFromPos(e,e?-1:1),f=n.getSelection(),d=!1;if((Ie.gecko||Ie.safari)&&t==e){var u=h.node,m=h.offset;if(3==u.nodeType)(d=m&&"\n"==u.nodeValue[m-1])&&m==u.nodeValue.length&&u.nextSibling&&"BR"==u.nextSibling.nodeName&&(h=p={node:u.parentNode,offset:$e(u)+1});else{var v=u.childNodes[m-1];d=v&&("BR"==v.nodeName||"false"==v.contentEditable)}}if(r||d&&Ie.safari||!We(h.node,h.offset,f.anchorNode,f.anchorOffset)||!We(p.node,p.offset,f.focusNode,f.focusOffset)){var g=!1;if((f.extend||t==e)&&!d){f.collapse(h.node,h.offset);try{t!=e&&f.extend(p.node,p.offset),g=!0}catch(t){if(!(t instanceof DOMException))throw t}}if(!g){if(t>e){var y=h;h=p,p=y}var w=document.createRange();w.setEnd(p.node,p.offset),w.setStart(h.node,h.offset),f.removeAllRanges(),f.addRange(w)}}},wn.prototype.ignoreMutation=function(t){return!this.contentDOM&&"selection"!=t.type},bn.contentLost.get=function(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)},wn.prototype.markDirty=function(t,e){for(var n=0,r=0;r<this.children.length;r++){var o=this.children[r],i=n+o.size;if(n==i?t<=i&&e>=n:t<i&&e>n){var s=n+o.border,a=i-o.border;if(t>=s&&e<=a)return this.dirty=t==n||e==i?2:1,void(t!=s||e!=a||!o.contentLost&&o.dom.parentNode==this.contentDOM?o.markDirty(t-s,e-s):o.dirty=3);o.dirty=3}n=i}this.dirty=2},wn.prototype.markParentsDirty=function(){for(var t=1,e=this.parent;e;e=e.parent,t++){var n=1==t?2:1;e.dirty<n&&(e.dirty=n)}},bn.domAtom.get=function(){return!1},Object.defineProperties(wn.prototype,bn);var xn=[],kn=function(t){function e(e,n,r,o){var i,s=n.type.toDOM;if("function"==typeof s&&(s=s(r,(function(){return i?i.parent?i.parent.posBeforeChild(i):void 0:o}))),!n.type.spec.raw){if(1!=s.nodeType){var a=document.createElement("span");a.appendChild(s),s=a}s.contentEditable=!1,s.classList.add("ProseMirror-widget")}t.call(this,e,xn,s,null),this.widget=n,i=this}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={beforePosition:{configurable:!0},domAtom:{configurable:!0}};return n.beforePosition.get=function(){return this.widget.type.side<0},e.prototype.matchesWidget=function(t){return 0==this.dirty&&t.type.eq(this.widget.type)},e.prototype.parseRule=function(){return{ignore:!0}},e.prototype.stopEvent=function(t){var e=this.widget.spec.stopEvent;return!!e&&e(t)},e.prototype.ignoreMutation=function(t){return"selection"!=t.type||this.widget.spec.ignoreSelection},n.domAtom.get=function(){return!0},Object.defineProperties(e.prototype,n),e}(wn),Sn=function(t){function e(e,n,r,o){t.call(this,e,xn,n,null),this.textDOM=r,this.text=o}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={size:{configurable:!0}};return n.size.get=function(){return this.text.length},e.prototype.localPosFromDOM=function(t,e){return t!=this.textDOM?this.posAtStart+(e?this.size:0):this.posAtStart+e},e.prototype.domFromPos=function(t){return{node:this.textDOM,offset:t}},e.prototype.ignoreMutation=function(t){return"characterData"===t.type&&t.target.nodeValue==t.oldValue},Object.defineProperties(e.prototype,n),e}(wn),Cn=function(t){function e(e,n,r,o){t.call(this,e,[],r,o),this.mark=n}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.create=function(t,n,r,o){var i=o.nodeViews[n.type.name],s=i&&i(n,o,r);return s&&s.dom||(s=ut.renderSpec(document,n.type.spec.toDOM(n,r))),new e(t,n,s.dom,s.contentDOM||s.dom)},e.prototype.parseRule=function(){return{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}},e.prototype.matchesMark=function(t){return 3!=this.dirty&&this.mark.eq(t)},e.prototype.markDirty=function(e,n){if(t.prototype.markDirty.call(this,e,n),0!=this.dirty){for(var r=this.parent;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=0}},e.prototype.slice=function(t,n,r){var o=e.create(this.parent,this.mark,!0,r),i=this.children,s=this.size;n<s&&(i=Ln(i,n,s,r)),t>0&&(i=Ln(i,0,t,r));for(var a=0;a<i.length;a++)i[a].parent=o;return o.children=i,o},e}(wn),Mn=function(t){function e(e,n,r,o,i,s,a,c,l){t.call(this,e,n.isLeaf?xn:[],i,s),this.nodeDOM=a,this.node=n,this.outerDeco=r,this.innerDeco=o,s&&this.updateChildren(c,l)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={size:{configurable:!0},border:{configurable:!0},domAtom:{configurable:!0}};return e.create=function(t,n,r,o,i,s){var a,c,l=i.nodeViews[n.type.name],h=l&&l(n,i,(function(){return c?c.parent?c.parent.posBeforeChild(c):void 0:s}),r,o),p=h&&h.dom,f=h&&h.contentDOM;if(n.isText)if(p){if(3!=p.nodeType)throw new RangeError("Text must be rendered as a DOM text node")}else p=document.createTextNode(n.text);else p||(p=(a=ut.renderSpec(document,n.type.spec.toDOM(n))).dom,f=a.contentDOM);f||n.isText||"BR"==p.nodeName||(p.hasAttribute("contenteditable")||(p.contentEditable=!1),n.type.spec.draggable&&(p.draggable=!0));var d=p;return p=Bn(p,r,n),h?c=new Tn(t,n,r,o,p,f,d,h,i,s+1):n.isText?new Nn(t,n,r,o,p,d,i):new e(t,n,r,o,p,f,d,i,s+1)},e.prototype.parseRule=function(){var t=this;if(this.node.type.spec.reparseInView)return null;var e={node:this.node.type.name,attrs:this.node.attrs};return this.node.type.spec.code&&(e.preserveWhitespace="full"),this.contentDOM&&!this.contentLost?e.contentElement=this.contentDOM:e.getContent=function(){return t.contentDOM?o.empty:t.node.content},e},e.prototype.matchesNode=function(t,e,n){return 0==this.dirty&&t.eq(this.node)&&Vn(e,this.outerDeco)&&n.eq(this.innerDeco)},n.size.get=function(){return this.node.nodeSize},n.border.get=function(){return this.node.isLeaf?0:1},e.prototype.updateChildren=function(t,e){var n=this,r=this.node.inlineContent,o=e,i=r&&t.composing&&this.localCompositionNode(t,e),s=new qn(this,i&&i.node);!function(t,e,n,r){var o=e.locals(t),i=0;if(0!=o.length)for(var s=0,a=[],c=null,l=0;;){if(s<o.length&&o[s].to==i){for(var h=o[s++],p=void 0;s<o.length&&o[s].to==i;)(p||(p=[h])).push(o[s++]);if(p){p.sort($n);for(var f=0;f<p.length;f++)n(p[f],l,!!c)}else n(h,l,!!c)}var d=void 0,u=void 0;if(c)u=-1,d=c,c=null;else{if(!(l<t.childCount))break;u=l,d=t.child(l++)}for(var m=0;m<a.length;m++)a[m].to<=i&&a.splice(m--,1);for(;s<o.length&&o[s].from<=i&&o[s].to>i;)a.push(o[s++]);var v=i+d.nodeSize;if(d.isText){var g=v;s<o.length&&o[s].from<g&&(g=o[s].from);for(var y=0;y<a.length;y++)a[y].to<g&&(g=a[y].to);g<v&&(c=d.cut(g-i),d=d.cut(0,g-i),v=g,u=-1)}r(d,a.length?d.isInline&&!d.isLeaf?a.filter((function(t){return!t.inline})):a.slice():xn,e.forChild(i,d),u),i=v}else for(var w=0;w<t.childCount;w++){var b=t.child(w);r(b,o,e.forChild(i,b),w),i+=b.nodeSize}}(this.node,this.innerDeco,(function(e,i,a){e.spec.marks?s.syncToMarks(e.spec.marks,r,t):e.type.side>=0&&!a&&s.syncToMarks(i==n.node.childCount?l.none:n.node.child(i).marks,r,t),s.placeWidget(e,t,o)}),(function(e,n,i,a){s.syncToMarks(e.marks,r,t),s.findNodeMatch(e,n,i,a)||s.updateNextNode(e,n,i,t,a)||s.addNode(e,n,i,t,o),o+=e.nodeSize})),s.syncToMarks(xn,r,t),this.node.isTextblock&&s.addTextblockHacks(),s.destroyRest(),(s.changed||2==this.dirty)&&(i&&this.protectLocalComposition(t,i),En(this.contentDOM,this.children,t),Ie.ios&&function(t){if("UL"==t.nodeName||"OL"==t.nodeName){var e=t.style.cssText;t.style.cssText=e+"; list-style: square !important",window.getComputedStyle(t).listStyle,t.style.cssText=e}}(this.dom))},e.prototype.localCompositionNode=function(t,e){var n=t.state.selection,r=n.from,o=n.to;if(!(!(t.state.selection instanceof de)||r<e||o>e+this.node.content.size)){var i=t.root.getSelection(),s=function(t,e){for(;;){if(3==t.nodeType)return t;if(1==t.nodeType&&e>0){if(t.childNodes.length>e&&3==t.childNodes[e].nodeType)return t.childNodes[e];e=He(t=t.childNodes[e-1])}else{if(!(1==t.nodeType&&e<t.childNodes.length))return null;t=t.childNodes[e],e=0}}}(i.focusNode,i.focusOffset);if(s&&this.dom.contains(s.parentNode)){var a=s.nodeValue,c=function(t,e,n,r){for(var o=0,i=0;o<t.childCount&&i<=r;){var s=t.child(o++),a=i;if(i+=s.nodeSize,s.isText){for(var c=s.text;o<t.childCount;){var l=t.child(o++);if(i+=l.nodeSize,!l.isText)break;c+=l.text}if(i>=n){var h=c.lastIndexOf(e,r-a);if(h>=0&&h+e.length+a>=n)return a+h}}}return-1}(this.node.content,a,r-e,o-e);return c<0?null:{node:s,pos:c,text:a}}}},e.prototype.protectLocalComposition=function(t,e){var n=e.node,r=e.pos,o=e.text;if(!this.getDesc(n)){for(var i=n;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=null)}var s=new Sn(this,i,n,o);t.compositionNodes.push(s),this.children=Ln(this.children,r,r+o.length,t,s)}},e.prototype.update=function(t,e,n,r){return!(3==this.dirty||!t.sameMarkup(this.node)||(this.updateInner(t,e,n,r),0))},e.prototype.updateInner=function(t,e,n,r){this.updateOuterDeco(e),this.node=t,this.innerDeco=n,this.contentDOM&&this.updateChildren(r,this.posAtStart),this.dirty=0},e.prototype.updateOuterDeco=function(t){if(!Vn(t,this.outerDeco)){var e=1!=this.nodeDOM.nodeType,n=this.dom;this.dom=In(this.dom,this.nodeDOM,zn(this.outerDeco,this.node,e),zn(t,this.node,e)),this.dom!=n&&(n.pmViewDesc=null,this.dom.pmViewDesc=this),this.outerDeco=t}},e.prototype.selectNode=function(){this.nodeDOM.classList.add("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||(this.dom.draggable=!0)},e.prototype.deselectNode=function(){this.nodeDOM.classList.remove("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||this.dom.removeAttribute("draggable")},n.domAtom.get=function(){return this.node.isAtom},Object.defineProperties(e.prototype,n),e}(wn);function On(t,e,n,r,o){return Bn(r,e,t),new Mn(null,t,e,n,r,r,r,o,0)}var Nn=function(t){function e(e,n,r,o,i,s,a){t.call(this,e,n,r,o,i,null,s,a)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={domAtom:{configurable:!0}};return e.prototype.parseRule=function(){for(var t=this.nodeDOM.parentNode;t&&t!=this.dom&&!t.pmIsDeco;)t=t.parentNode;return{skip:t||!0}},e.prototype.update=function(t,e,n,r){return!(3==this.dirty||0!=this.dirty&&!this.inParent()||!t.sameMarkup(this.node)||(this.updateOuterDeco(e),0==this.dirty&&t.text==this.node.text||t.text==this.nodeDOM.nodeValue||(this.nodeDOM.nodeValue=t.text,r.trackWrites==this.nodeDOM&&(r.trackWrites=null)),this.node=t,this.dirty=0,0))},e.prototype.inParent=function(){for(var t=this.parent.contentDOM,e=this.nodeDOM;e;e=e.parentNode)if(e==t)return!0;return!1},e.prototype.domFromPos=function(t){return{node:this.nodeDOM,offset:t}},e.prototype.localPosFromDOM=function(e,n,r){return e==this.nodeDOM?this.posAtStart+Math.min(n,this.node.text.length):t.prototype.localPosFromDOM.call(this,e,n,r)},e.prototype.ignoreMutation=function(t){return"characterData"!=t.type&&"selection"!=t.type},e.prototype.slice=function(t,n,r){var o=this.node.cut(t,n),i=document.createTextNode(o.text);return new e(this.parent,o,this.outerDeco,this.innerDeco,i,i,r)},n.domAtom.get=function(){return!1},Object.defineProperties(e.prototype,n),e}(Mn),Dn=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={domAtom:{configurable:!0}};return e.prototype.parseRule=function(){return{ignore:!0}},e.prototype.matchesHack=function(){return 0==this.dirty},n.domAtom.get=function(){return!0},Object.defineProperties(e.prototype,n),e}(wn),Tn=function(t){function e(e,n,r,o,i,s,a,c,l,h){t.call(this,e,n,r,o,i,s,a,l,h),this.spec=c}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.update=function(e,n,r,o){if(3==this.dirty)return!1;if(this.spec.update){var i=this.spec.update(e,n,r);return i&&this.updateInner(e,n,r,o),i}return!(!this.contentDOM&&!e.isLeaf)&&t.prototype.update.call(this,e,n,r,o)},e.prototype.selectNode=function(){this.spec.selectNode?this.spec.selectNode():t.prototype.selectNode.call(this)},e.prototype.deselectNode=function(){this.spec.deselectNode?this.spec.deselectNode():t.prototype.deselectNode.call(this)},e.prototype.setSelection=function(e,n,r,o){this.spec.setSelection?this.spec.setSelection(e,n,r):t.prototype.setSelection.call(this,e,n,r,o)},e.prototype.destroy=function(){this.spec.destroy&&this.spec.destroy(),t.prototype.destroy.call(this)},e.prototype.stopEvent=function(t){return!!this.spec.stopEvent&&this.spec.stopEvent(t)},e.prototype.ignoreMutation=function(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):t.prototype.ignoreMutation.call(this,e)},e}(Mn);function En(t,e,n){for(var r=t.firstChild,o=!1,i=0;i<e.length;i++){var s=e[i],a=s.dom;if(a.parentNode==t){for(;a!=r;)r=Fn(r),o=!0;r=r.nextSibling}else o=!0,t.insertBefore(a,r);if(s instanceof Cn){var c=r?r.previousSibling:t.lastChild;En(s.contentDOM,s.children,n),r=c?c.nextSibling:t.firstChild}}for(;r;)r=Fn(r),o=!0;o&&n.trackWrites==t&&(n.trackWrites=null)}function An(t){t&&(this.nodeName=t)}An.prototype=Object.create(null);var Pn=[new An];function zn(t,e,n){if(0==t.length)return Pn;for(var r=n?Pn[0]:new An,o=[r],i=0;i<t.length;i++){var s=t[i].type.attrs;if(s)for(var a in s.nodeName&&o.push(r=new An(s.nodeName)),s){var c=s[a];null!=c&&(n&&1==o.length&&o.push(r=new An(e.isInline?"span":"div")),"class"==a?r.class=(r.class?r.class+" ":"")+c:"style"==a?r.style=(r.style?r.style+";":"")+c:"nodeName"!=a&&(r[a]=c))}}return o}function In(t,e,n,r){if(n==Pn&&r==Pn)return e;for(var o=e,i=0;i<r.length;i++){var s=r[i],a=n[i];if(i){var c=void 0;a&&a.nodeName==s.nodeName&&o!=t&&(c=o.parentNode)&&c.tagName.toLowerCase()==s.nodeName||((c=document.createElement(s.nodeName)).pmIsDeco=!0,c.appendChild(o),a=Pn[0]),o=c}Rn(o,a||Pn[0],s)}return o}function Rn(t,e,n){for(var r in e)"class"==r||"style"==r||"nodeName"==r||r in n||t.removeAttribute(r);for(var o in n)"class"!=o&&"style"!=o&&"nodeName"!=o&&n[o]!=e[o]&&t.setAttribute(o,n[o]);if(e.class!=n.class){for(var i=e.class?e.class.split(" ").filter(Boolean):xn,s=n.class?n.class.split(" ").filter(Boolean):xn,a=0;a<i.length;a++)-1==s.indexOf(i[a])&&t.classList.remove(i[a]);for(var c=0;c<s.length;c++)-1==i.indexOf(s[c])&&t.classList.add(s[c])}if(e.style!=n.style){if(e.style)for(var l,h=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g;l=h.exec(e.style);)t.style.removeProperty(l[1]);n.style&&(t.style.cssText+=n.style)}}function Bn(t,e,n){return In(t,t,Pn,zn(e,n,1!=t.nodeType))}function Vn(t,e){if(t.length!=e.length)return!1;for(var n=0;n<t.length;n++)if(!t[n].type.eq(e[n].type))return!1;return!0}function Fn(t){var e=t.nextSibling;return t.parentNode.removeChild(t),e}var qn=function(t,e){this.top=t,this.lock=e,this.index=0,this.stack=[],this.changed=!1,this.preMatch=function(t,e){for(var n=t.childCount,r=e.length,o=new Map;n>0&&r>0;r--){var i=e[r-1],s=i.node;if(s){if(s!=t.child(n-1))break;--n,o.set(i,n)}}return{index:n,matched:o}}(t.node.content,t.children)};function $n(t,e){return t.type.side-e.type.side}function Ln(t,e,n,r,o){for(var i=[],s=0,a=0;s<t.length;s++){var c=t[s],l=a,h=a+=c.size;l>=n||h<=e?i.push(c):(l<e&&i.push(c.slice(0,e-l,r)),o&&(i.push(o),o=null),h>n&&i.push(c.slice(n-l,c.size,r)))}return i}function _n(t,e){var n=t.root.getSelection(),r=t.state.doc;if(!n.focusNode)return null;var o=t.docView.nearestDesc(n.focusNode),i=o&&0==o.size,s=t.docView.posFromDOM(n.focusNode,n.focusOffset);if(s<0)return null;var a,c,l=r.resolve(s);if(Ge(n)){for(a=l;o&&!o.node;)o=o.parent;if(o&&o.node.isAtom&&me.isSelectable(o.node)&&o.parent&&(!o.node.isInline||!function(t,e,n){for(var r=0==e,o=e==He(t);r||o;){if(t==n)return!0;var i=$e(t);if(!(t=t.parentNode))return!1;r=r&&0==i,o=o&&i==He(t)}}(n.focusNode,n.focusOffset,o.dom))){var h=o.posBefore;c=new me(s==h?l:r.resolve(h))}}else{var p=t.docView.posFromDOM(n.anchorNode,n.anchorOffset);if(p<0)return null;a=r.resolve(p)}return c||(c=Yn(t,a,l,"pointer"==e||t.state.selection.head<l.pos&&!i?1:-1)),c}function jn(t){return t.editable?t.hasFocus():Qn(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function Wn(t,e){var n=t.state.selection;if(Gn(t,n),jn(t)){if(t.domObserver.disconnectSelection(),t.cursorWrapper)!function(t){var e=t.root.getSelection(),n=document.createRange(),r=t.cursorWrapper.dom,o="IMG"==r.nodeName;o?n.setEnd(r.parentNode,$e(r)+1):n.setEnd(r,0),n.collapse(!1),e.removeAllRanges(),e.addRange(n),!o&&!t.state.selection.visible&&Ie.ie&&Ie.ie_version<=11&&(r.disabled=!0,r.disabled=!1)}(t);else{var r,o,i=n.anchor,s=n.head;!Jn||n instanceof de||(n.$from.parent.inlineContent||(r=Kn(t,n.from)),n.empty||n.$from.parent.inlineContent||(o=Kn(t,n.to))),t.docView.setSelection(i,s,t.root,e),Jn&&(r&&Un(r),o&&Un(o)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&function(t){var e=t.dom.ownerDocument;e.removeEventListener("selectionchange",t.hideSelectionGuard);var n=t.root.getSelection(),r=n.anchorNode,o=n.anchorOffset;e.addEventListener("selectionchange",t.hideSelectionGuard=function(){n.anchorNode==r&&n.anchorOffset==o||(e.removeEventListener("selectionchange",t.hideSelectionGuard),setTimeout((function(){jn(t)&&!t.state.selection.visible||t.dom.classList.remove("ProseMirror-hideselection")}),20))})}(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}qn.prototype.destroyBetween=function(t,e){if(t!=e){for(var n=t;n<e;n++)this.top.children[n].destroy();this.top.children.splice(t,e-t),this.changed=!0}},qn.prototype.destroyRest=function(){this.destroyBetween(this.index,this.top.children.length)},qn.prototype.syncToMarks=function(t,e,n){for(var r=0,o=this.stack.length>>1,i=Math.min(o,t.length);r<i&&(r==o-1?this.top:this.stack[r+1<<1]).matchesMark(t[r])&&!1!==t[r].type.spec.spanning;)r++;for(;r<o;)this.destroyRest(),this.top.dirty=0,this.index=this.stack.pop(),this.top=this.stack.pop(),o--;for(;o<t.length;){this.stack.push(this.top,this.index+1);for(var s=-1,a=this.index;a<Math.min(this.index+3,this.top.children.length);a++)if(this.top.children[a].matchesMark(t[o])){s=a;break}if(s>-1)s>this.index&&(this.changed=!0,this.destroyBetween(this.index,s)),this.top=this.top.children[this.index];else{var c=Cn.create(this.top,t[o],e,n);this.top.children.splice(this.index,0,c),this.top=c,this.changed=!0}this.index=0,o++}},qn.prototype.findNodeMatch=function(t,e,n,r){var o=this.top.children,i=-1;if(r>=this.preMatch.index){for(var s=this.index;s<o.length;s++)if(o[s].matchesNode(t,e,n)){i=s;break}}else for(var a=this.index,c=Math.min(o.length,a+1);a<c;a++){var l=o[a];if(l.matchesNode(t,e,n)&&!this.preMatch.matched.has(l)){i=a;break}}return!(i<0||(this.destroyBetween(this.index,i),this.index++,0))},qn.prototype.updateNextNode=function(t,e,n,r,o){for(var i=this.index;i<this.top.children.length;i++){var s=this.top.children[i];if(s instanceof Mn){var a=this.preMatch.matched.get(s);if(null!=a&&a!=o)return!1;var c=s.dom;if((!this.lock||!(c==this.lock||1==c.nodeType&&c.contains(this.lock.parentNode))||t.isText&&s.node&&s.node.isText&&s.nodeDOM.nodeValue==t.text&&3!=s.dirty&&Vn(e,s.outerDeco))&&s.update(t,e,n,r))return this.destroyBetween(this.index,i),s.dom!=c&&(this.changed=!0),this.index++,!0;break}}return!1},qn.prototype.addNode=function(t,e,n,r,o){this.top.children.splice(this.index++,0,Mn.create(this.top,t,e,n,r,o)),this.changed=!0},qn.prototype.placeWidget=function(t,e,n){var r=this.index<this.top.children.length?this.top.children[this.index]:null;if(!r||!r.matchesWidget(t)||t!=r.widget&&r.widget.type.toDOM.parentNode){var o=new kn(this.top,t,e,n);this.top.children.splice(this.index++,0,o),this.changed=!0}else this.index++},qn.prototype.addTextblockHacks=function(){for(var t=this.top.children[this.index-1];t instanceof Cn;)t=t.children[t.children.length-1];if(!t||!(t instanceof Nn)||/\n$/.test(t.node.text))if(this.index<this.top.children.length&&this.top.children[this.index].matchesHack())this.index++;else{var e=document.createElement("br");this.top.children.splice(this.index++,0,new Dn(this.top,xn,e,null)),this.changed=!0}};var Jn=Ie.safari||Ie.chrome&&Ie.chrome_version<63;function Kn(t,e){var n=t.docView.domFromPos(e,0),r=n.node,o=n.offset,i=o<r.childNodes.length?r.childNodes[o]:null,s=o?r.childNodes[o-1]:null;if(Ie.safari&&i&&"false"==i.contentEditable)return Hn(i);if(!(i&&"false"!=i.contentEditable||s&&"false"!=s.contentEditable)){if(i)return Hn(i);if(s)return Hn(s)}}function Hn(t){return t.contentEditable="true",Ie.safari&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function Un(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function Gn(t,e){if(e instanceof me){var n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(Xn(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else Xn(t)}function Xn(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=null)}function Yn(t,e,n,r){return t.someProp("createSelectionBetween",(function(r){return r(t,e,n)}))||de.between(e,n,r)}function Qn(t){var e=t.root.getSelection();if(!e.anchorNode)return!1;try{return t.dom.contains(3==e.anchorNode.nodeType?e.anchorNode.parentNode:e.anchorNode)&&(t.editable||t.dom.contains(3==e.focusNode.nodeType?e.focusNode.parentNode:e.focusNode))}catch(t){return!1}}function Zn(t,e){var n=t.selection,r=n.$anchor,o=n.$head,i=e>0?r.max(o):r.min(o),s=i.parent.inlineContent?i.depth?t.doc.resolve(e>0?i.after():i.before()):null:i;return s&&he.findFrom(s,e)}function tr(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function er(t,e,n){var r=t.state.selection;if(!(r instanceof de)){if(r instanceof me&&r.node.isInline)return tr(t,new de(e>0?r.$to:r.$from));var o=Zn(t.state,e);return!!o&&tr(t,o)}if(!r.empty||n.indexOf("s")>-1)return!1;if(t.endOfTextblock(e>0?"right":"left")){var i=Zn(t.state,e);return!!(i&&i instanceof me)&&tr(t,i)}if(!(Ie.mac&&n.indexOf("m")>-1)){var s,a=r.$head,c=a.textOffset?null:e<0?a.nodeBefore:a.nodeAfter;if(!c||c.isText)return!1;var l=e<0?a.pos-c.nodeSize:a.pos;return!!(c.isAtom||(s=t.docView.descAt(l))&&!s.contentDOM)&&(me.isSelectable(c)?tr(t,new me(e<0?t.state.doc.resolve(a.pos-c.nodeSize):a)):!!Ie.webkit&&tr(t,new de(t.state.doc.resolve(e<0?l:l+c.nodeSize))))}}function nr(t){return 3==t.nodeType?t.nodeValue.length:t.childNodes.length}function rr(t){var e=t.pmViewDesc;return e&&0==e.size&&(t.nextSibling||"BR"!=t.nodeName)}function or(t){var e=t.root.getSelection(),n=e.focusNode,r=e.focusOffset;if(n){var o,i,s=!1;for(Ie.gecko&&1==n.nodeType&&r<nr(n)&&rr(n.childNodes[r])&&(s=!0);;)if(r>0){if(1!=n.nodeType)break;var a=n.childNodes[r-1];if(rr(a))o=n,i=--r;else{if(3!=a.nodeType)break;r=(n=a).nodeValue.length}}else{if(sr(n))break;for(var c=n.previousSibling;c&&rr(c);)o=n.parentNode,i=$e(c),c=c.previousSibling;if(c)r=nr(n=c);else{if((n=n.parentNode)==t.dom)break;r=0}}s?ar(t,e,n,r):o&&ar(t,e,o,i)}}function ir(t){var e=t.root.getSelection(),n=e.focusNode,r=e.focusOffset;if(n){for(var o,i,s=nr(n);;)if(r<s){if(1!=n.nodeType)break;if(!rr(n.childNodes[r]))break;o=n,i=++r}else{if(sr(n))break;for(var a=n.nextSibling;a&&rr(a);)o=a.parentNode,i=$e(a)+1,a=a.nextSibling;if(a)r=0,s=nr(n=a);else{if((n=n.parentNode)==t.dom)break;r=s=0}}o&&ar(t,e,o,i)}}function sr(t){var e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function ar(t,e,n,r){if(Ge(e)){var o=document.createRange();o.setEnd(n,r),o.setStart(n,r),e.removeAllRanges(),e.addRange(o)}else e.extend&&e.extend(n,r);t.domObserver.setCurSelection();var i=t.state;setTimeout((function(){t.state==i&&Wn(t)}),50)}function cr(t,e,n){var r=t.state.selection;if(r instanceof de&&!r.empty||n.indexOf("s")>-1)return!1;if(Ie.mac&&n.indexOf("m")>-1)return!1;var o=r.$from,i=r.$to;if(!o.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){var s=Zn(t.state,e);if(s&&s instanceof me)return tr(t,s)}if(!o.parent.inlineContent){var a=e<0?o:i,c=r instanceof ge?he.near(a,e):he.findFrom(a,e);return!!c&&tr(t,c)}return!1}function lr(t,e){if(!(t.state.selection instanceof de))return!0;var n=t.state.selection,r=n.$head,o=n.$anchor,i=n.empty;if(!r.sameParent(o))return!0;if(!i)return!1;if(t.endOfTextblock(e>0?"forward":"backward"))return!0;var s=!r.textOffset&&(e<0?r.nodeBefore:r.nodeAfter);if(s&&!s.isText){var a=t.state.tr;return e<0?a.delete(r.pos-s.nodeSize,r.pos):a.delete(r.pos,r.pos+s.nodeSize),t.dispatch(a),!0}return!1}function hr(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function pr(t){var e=t.pmViewDesc;if(e)return e.parseRule();if("BR"==t.nodeName&&t.parentNode){if(Ie.safari&&/^(ul|ol)$/i.test(t.parentNode.nodeName)){var n=document.createElement("div");return n.appendChild(document.createElement("li")),{skip:n}}if(t.parentNode.lastChild==t||Ie.safari&&/^(tr|table)$/i.test(t.parentNode.nodeName))return{ignore:!0}}else if("IMG"==t.nodeName&&t.getAttribute("mark-placeholder"))return{ignore:!0}}function fr(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:Yn(t,e.resolve(n.anchor),e.resolve(n.head))}function dr(t,e,n){for(var r=t.depth,o=e?t.end():t.pos;r>0&&(e||t.indexAfter(r)==t.node(r).childCount);)r--,o++,e=!1;if(n)for(var i=t.node(r).maybeChild(t.indexAfter(r));i&&!i.isLeaf;)i=i.firstChild,o++;return o}function ur(t,e){for(var n=[],r=e.content,o=e.openStart,i=e.openEnd;o>1&&i>1&&1==r.childCount&&1==r.firstChild.childCount;){o--,i--;var s=r.firstChild;n.push(s.type.name,s.attrs!=s.type.defaultAttrs?s.attrs:null),r=s.content}var a=t.someProp("clipboardSerializer")||ut.fromSchema(t.state.schema),c=kr(),l=c.createElement("div");l.appendChild(a.serializeFragment(r,{document:c}));for(var h,p=l.firstChild;p&&1==p.nodeType&&(h=br[p.nodeName.toLowerCase()]);){for(var f=h.length-1;f>=0;f--){for(var d=c.createElement(h[f]);l.firstChild;)d.appendChild(l.firstChild);l.appendChild(d)}p=l.firstChild}return p&&1==p.nodeType&&p.setAttribute("data-pm-slice",o+" "+i+" "+JSON.stringify(n)),{dom:l,text:t.someProp("clipboardTextSerializer",(function(t){return t(e)}))||e.content.textBetween(0,e.content.size,"\n\n")}}function mr(t,e,n,r,i){var s,a,c=i.parent.type.spec.code;if(!n&&!e)return null;var l=e&&(r||c||!n);if(l){if(t.someProp("transformPastedText",(function(t){e=t(e,c||r)})),c)return new p(o.from(t.state.schema.text(e.replace(/\r\n?/g,"\n"))),0,0);var h=t.someProp("clipboardTextParser",(function(t){return t(e,i,r)}));h?a=h:(s=document.createElement("div"),e.trim().split(/(?:\r\n?|\n)+/).forEach((function(t){s.appendChild(document.createElement("p")).textContent=t})))}else t.someProp("transformPastedHTML",(function(t){n=t(n)})),s=function(t){var e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));var n,r=kr().createElement("div"),o=/<([a-z][^>\s]+)/i.exec(t);if((n=o&&br[o[1].toLowerCase()])&&(t=n.map((function(t){return"<"+t+">"})).join("")+t+n.map((function(t){return"</"+t+">"})).reverse().join("")),r.innerHTML=t,n)for(var i=0;i<n.length;i++)r=r.querySelector(n[i])||r;return r}(n);var f=s&&s.querySelector("[data-pm-slice]"),d=f&&/^(\d+) (\d+) (.*)/.exec(f.getAttribute("data-pm-slice"));if(!a){var u=t.someProp("clipboardParser")||t.someProp("domParser")||rt.fromSchema(t.state.schema);a=u.parseSlice(s,{preserveWhitespace:!(!l&&!d),context:i})}return a=d?function(t,e){if(!t.size)return t;var n,r=t.content.firstChild.type.schema;try{n=JSON.parse(e)}catch(e){return t}for(var i=t.content,s=t.openStart,a=t.openEnd,c=n.length-2;c>=0;c-=2){var l=r.nodes[n[c]];if(!l||l.hasRequiredAttrs())break;i=o.from(l.create(n[c+1],i)),s++,a++}return new p(i,s,a)}(function(t,e,n){return e<t.openStart&&(t=new p(wr(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new p(wr(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}(a,+d[1],+d[2]),d[3]):p.maxOpen(function(t,e){if(t.childCount<2)return t;for(var n=function(n){var r=e.node(n).contentMatchAt(e.index(n)),i=void 0,s=[];if(t.forEach((function(t){if(s){var e,n=r.findWrapping(t.type);if(!n)return s=null;if(e=s.length&&i.length&&gr(n,i,t,s[s.length-1],0))s[s.length-1]=e;else{s.length&&(s[s.length-1]=yr(s[s.length-1],i.length));var o=vr(t,n);s.push(o),r=r.matchType(o.type,o.attrs),i=n}}})),s)return{v:o.from(s)}},r=e.depth;r>=0;r--){var i=n(r);if(i)return i.v}return t}(a.content,i),!1),t.someProp("transformPasted",(function(t){a=t(a)})),a}function vr(t,e,n){void 0===n&&(n=0);for(var r=e.length-1;r>=n;r--)t=e[r].create(null,o.from(t));return t}function gr(t,e,n,r,i){if(i<t.length&&i<e.length&&t[i]==e[i]){var s=gr(t,e,n,r.lastChild,i+1);if(s)return r.copy(r.content.replaceChild(r.childCount-1,s));if(r.contentMatchAt(r.childCount).matchType(i==t.length-1?n.type:t[i+1]))return r.copy(r.content.append(o.from(vr(n,t,i+1))))}}function yr(t,e){if(0==e)return t;var n=t.content.replaceChild(t.childCount-1,yr(t.lastChild,e-1)),r=t.contentMatchAt(t.childCount).fillBefore(o.empty,!0);return t.copy(n.append(r))}function wr(t,e,n,r,i,s){var a=e<0?t.firstChild:t.lastChild,c=a.content;return i<r-1&&(c=wr(c,e,n,r,i+1,s)),i>=n&&(c=e<0?a.contentMatchAt(0).fillBefore(c,t.childCount>1||s<=i).append(c):c.append(a.contentMatchAt(a.childCount).fillBefore(o.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,a.copy(c))}var br={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]},xr=null;function kr(){return xr||(xr=document.implementation.createHTMLDocument("title"))}var Sr={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},Cr=Ie.ie&&Ie.ie_version<=11,Mr=function(){this.anchorNode=this.anchorOffset=this.focusNode=this.focusOffset=null};Mr.prototype.set=function(t){this.anchorNode=t.anchorNode,this.anchorOffset=t.anchorOffset,this.focusNode=t.focusNode,this.focusOffset=t.focusOffset},Mr.prototype.eq=function(t){return t.anchorNode==this.anchorNode&&t.anchorOffset==this.anchorOffset&&t.focusNode==this.focusNode&&t.focusOffset==this.focusOffset};var Or=function(t,e){var n=this;this.view=t,this.handleDOMChange=e,this.queue=[],this.flushingSoon=-1,this.observer=window.MutationObserver&&new window.MutationObserver((function(t){for(var e=0;e<t.length;e++)n.queue.push(t[e]);Ie.ie&&Ie.ie_version<=11&&t.some((function(t){return"childList"==t.type&&t.removedNodes.length||"characterData"==t.type&&t.oldValue.length>t.target.nodeValue.length}))?n.flushSoon():n.flush()})),this.currentSelection=new Mr,Cr&&(this.onCharData=function(t){n.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue}),n.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.suppressingSelectionUpdates=!1};Or.prototype.flushSoon=function(){var t=this;this.flushingSoon<0&&(this.flushingSoon=window.setTimeout((function(){t.flushingSoon=-1,t.flush()}),20))},Or.prototype.forceFlush=function(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())},Or.prototype.start=function(){this.observer&&this.observer.observe(this.view.dom,Sr),Cr&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()},Or.prototype.stop=function(){var t=this;if(this.observer){var e=this.observer.takeRecords();if(e.length){for(var n=0;n<e.length;n++)this.queue.push(e[n]);window.setTimeout((function(){return t.flush()}),20)}this.observer.disconnect()}Cr&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()},Or.prototype.connectSelection=function(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)},Or.prototype.disconnectSelection=function(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)},Or.prototype.suppressSelectionUpdates=function(){var t=this;this.suppressingSelectionUpdates=!0,setTimeout((function(){return t.suppressingSelectionUpdates=!1}),50)},Or.prototype.onSelectionChange=function(){if(function(t){return(!t.editable||t.root.activeElement==t.dom)&&Qn(t)}(this.view)){if(this.suppressingSelectionUpdates)return Wn(this.view);if(Ie.ie&&Ie.ie_version<=11&&!this.view.state.selection.empty){var t=this.view.root.getSelection();if(t.focusNode&&We(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset))return this.flushSoon()}this.flush()}},Or.prototype.setCurSelection=function(){this.currentSelection.set(this.view.root.getSelection())},Or.prototype.ignoreSelectionChange=function(t){if(0==t.rangeCount)return!0;var e=t.getRangeAt(0).commonAncestorContainer,n=this.view.docView.nearestDesc(e);return n&&n.ignoreMutation({type:"selection",target:3==e.nodeType?e.parentNode:e})?(this.setCurSelection(),!0):void 0},Or.prototype.flush=function(){if(this.view.docView&&!(this.flushingSoon>-1)){var t=this.observer?this.observer.takeRecords():[];this.queue.length&&(t=this.queue.concat(t),this.queue.length=0);var e=this.view.root.getSelection(),n=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(e)&&Qn(this.view)&&!this.ignoreSelectionChange(e),r=-1,o=-1,i=!1,s=[];if(this.view.editable)for(var a=0;a<t.length;a++){var c=this.registerMutation(t[a],s);c&&(r=r<0?c.from:Math.min(c.from,r),o=o<0?c.to:Math.max(c.to,o),c.typeOver&&(i=!0))}if(Ie.gecko&&s.length>1){var l=s.filter((function(t){return"BR"==t.nodeName}));if(2==l.length){var h=l[0],p=l[1];h.parentNode&&h.parentNode.parentNode==p.parentNode?p.remove():h.remove()}}(r>-1||n)&&(r>-1&&(this.view.docView.markDirty(r,o),function(t){Nr||(Nr=!0,"normal"==getComputedStyle(t.dom).whiteSpace&&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."))}(this.view)),this.handleDOMChange(r,o,i,s),this.view.docView.dirty?this.view.updateState(this.view.state):this.currentSelection.eq(e)||Wn(this.view),this.currentSelection.set(e))}},Or.prototype.registerMutation=function(t,e){if(e.indexOf(t.target)>-1)return null;var n=this.view.docView.nearestDesc(t.target);if("attributes"==t.type&&(n==this.view.docView||"contenteditable"==t.attributeName||"style"==t.attributeName&&!t.oldValue&&!t.target.getAttribute("style")))return null;if(!n||n.ignoreMutation(t))return null;if("childList"==t.type){for(var r=0;r<t.addedNodes.length;r++)e.push(t.addedNodes[r]);if(n.contentDOM&&n.contentDOM!=n.dom&&!n.contentDOM.contains(t.target))return{from:n.posBefore,to:n.posAfter};var o=t.previousSibling,i=t.nextSibling;if(Ie.ie&&Ie.ie_version<=11&&t.addedNodes.length)for(var s=0;s<t.addedNodes.length;s++){var a=t.addedNodes[s],c=a.previousSibling,l=a.nextSibling;(!c||Array.prototype.indexOf.call(t.addedNodes,c)<0)&&(o=c),(!l||Array.prototype.indexOf.call(t.addedNodes,l)<0)&&(i=l)}var h=o&&o.parentNode==t.target?$e(o)+1:0,p=n.localPosFromDOM(t.target,h,-1),f=i&&i.parentNode==t.target?$e(i):t.target.childNodes.length;return{from:p,to:n.localPosFromDOM(t.target,f,1)}}return"attributes"==t.type?{from:n.posAtStart-n.border,to:n.posAtEnd+n.border}:{from:n.posAtStart,to:n.posAtEnd,typeOver:t.target.nodeValue==t.oldValue}};var Nr=!1,Dr={},Tr={};function Er(t,e){t.lastSelectionOrigin=e,t.lastSelectionTime=Date.now()}function Ar(t){t.someProp("handleDOMEvents",(function(e){for(var n in e)t.eventHandlers[n]||t.dom.addEventListener(n,t.eventHandlers[n]=function(e){return Pr(t,e)})}))}function Pr(t,e){return t.someProp("handleDOMEvents",(function(n){var r=n[e.type];return!!r&&(r(t,e)||e.defaultPrevented)}))}function zr(t){return{left:t.clientX,top:t.clientY}}function Ir(t,e,n,r,o){if(-1==r)return!1;for(var i=t.state.doc.resolve(r),s=function(r){if(t.someProp(e,(function(e){return r>i.depth?e(t,n,i.nodeAfter,i.before(r),o,!0):e(t,n,i.node(r),i.before(r),o,!1)})))return{v:!0}},a=i.depth+1;a>0;a--){var c=s(a);if(c)return c.v}return!1}function Rr(t,e,n){t.focused||t.focus();var r=t.state.tr.setSelection(e);"pointer"==n&&r.setMeta("pointer",!0),t.dispatch(r)}function Br(t,e,n,r){return Ir(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",(function(n){return n(t,e,r)}))}function Vr(t,e,n,r){return Ir(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",(function(n){return n(t,e,r)}))||function(t,e){var n=t.state.doc;if(-1==e)return!!n.inlineContent&&(Rr(t,de.create(n,0,n.content.size),"pointer"),!0);for(var r=n.resolve(e),o=r.depth+1;o>0;o--){var i=o>r.depth?r.nodeAfter:r.node(o),s=r.before(o);if(i.inlineContent)Rr(t,de.create(n,s+1,s+1+i.content.size),"pointer");else{if(!me.isSelectable(i))continue;Rr(t,me.create(n,s),"pointer")}return!0}}(t,n)}function Fr(t){return Jr(t)}Tr.keydown=function(t,e){if(t.shiftKey=16==e.keyCode||e.shiftKey,!Lr(t,e))if(t.domObserver.forceFlush(),t.lastKeyCode=e.keyCode,t.lastKeyCodeTime=Date.now(),!Ie.ios||13!=e.keyCode||e.ctrlKey||e.altKey||e.metaKey)t.someProp("handleKeyDown",(function(n){return n(t,e)}))||function(t,e){var n=e.keyCode,r=function(t){var e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}(e);return 8==n||Ie.mac&&72==n&&"c"==r?lr(t,-1)||or(t):46==n||Ie.mac&&68==n&&"c"==r?lr(t,1)||ir(t):13==n||27==n||(37==n?er(t,-1,r)||or(t):39==n?er(t,1,r)||ir(t):38==n?cr(t,-1,r)||or(t):40==n?function(t){if(Ie.safari&&!(t.state.selection.$head.parentOffset>0)){var e=t.root.getSelection(),n=e.focusNode,r=e.focusOffset;if(n&&1==n.nodeType&&0==r&&n.firstChild&&"false"==n.firstChild.contentEditable){var o=n.firstChild;hr(t,o,!0),setTimeout((function(){return hr(t,o,!1)}),20)}}}(t)||cr(t,1,r)||ir(t):r==(Ie.mac?"m":"c")&&(66==n||73==n||89==n||90==n))}(t,e)?e.preventDefault():Er(t,"key");else{var n=Date.now();t.lastIOSEnter=n,t.lastIOSEnterFallbackTimeout=setTimeout((function(){t.lastIOSEnter==n&&(t.someProp("handleKeyDown",(function(e){return e(t,Xe(13,"Enter"))})),t.lastIOSEnter=0)}),200)}},Tr.keyup=function(t,e){16==e.keyCode&&(t.shiftKey=!1)},Tr.keypress=function(t,e){if(!(Lr(t,e)||!e.charCode||e.ctrlKey&&!e.altKey||Ie.mac&&e.metaKey))if(t.someProp("handleKeyPress",(function(n){return n(t,e)})))e.preventDefault();else{var n=t.state.selection;if(!(n instanceof de&&n.$from.sameParent(n.$to))){var r=String.fromCharCode(e.charCode);t.someProp("handleTextInput",(function(e){return e(t,n.$from.pos,n.$to.pos,r)}))||t.dispatch(t.state.tr.insertText(r).scrollIntoView()),e.preventDefault()}}};var qr=Ie.mac?"metaKey":"ctrlKey";Dr.mousedown=function(t,e){t.shiftKey=e.shiftKey;var n=Fr(t),r=Date.now(),o="singleClick";r-t.lastClick.time<500&&function(t,e){var n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}(e,t.lastClick)&&!e[qr]&&("singleClick"==t.lastClick.type?o="doubleClick":"doubleClick"==t.lastClick.type&&(o="tripleClick")),t.lastClick={time:r,x:e.clientX,y:e.clientY,type:o};var i=t.posAtCoords(zr(e));i&&("singleClick"==o?(t.mouseDown&&t.mouseDown.done(),t.mouseDown=new $r(t,i,e,n)):("doubleClick"==o?Br:Vr)(t,i.pos,i.inside,e)?e.preventDefault():Er(t,"pointer"))};var $r=function(t,e,n,r){var o,i,s=this;if(this.view=t,this.startDoc=t.state.doc,this.pos=e,this.event=n,this.flushed=r,this.selectNode=n[qr],this.allowDefault=n.shiftKey,e.inside>-1)o=t.state.doc.nodeAt(e.inside),i=e.inside;else{var a=t.state.doc.resolve(e.pos);o=a.parent,i=a.depth?a.before():0}this.mightDrag=null;var c=r?null:n.target,l=c?t.docView.nearestDesc(c,!0):null;this.target=l?l.dom:null,(o.type.spec.draggable&&!1!==o.type.spec.selectable||t.state.selection instanceof me&&i==t.state.selection.from)&&(this.mightDrag={node:o,pos:i,addAttr:this.target&&!this.target.draggable,setUneditable:this.target&&Ie.gecko&&!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((function(){s.view.mouseDown==s&&s.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)),Er(t,"pointer")};function Lr(t,e){return!!t.composing||!!(Ie.safari&&Math.abs(e.timeStamp-t.compositionEndedAt)<500)&&(t.compositionEndedAt=-2e8,!0)}$r.prototype.done=function(){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.view.mouseDown=null},$r.prototype.up=function(t){if(this.done(),this.view.dom.contains(3==t.target.nodeType?t.target.parentNode:t.target)){var e=this.pos;this.view.state.doc!=this.startDoc&&(e=this.view.posAtCoords(zr(t))),this.allowDefault||!e?Er(this.view,"pointer"):function(t,e,n,r,o){return Ir(t,"handleClickOn",e,n,r)||t.someProp("handleClick",(function(n){return n(t,e,r)}))||(o?function(t,e){if(-1==e)return!1;var n,r,o=t.state.selection;o instanceof me&&(n=o.node);for(var i=t.state.doc.resolve(e),s=i.depth+1;s>0;s--){var a=s>i.depth?i.nodeAfter:i.node(s);if(me.isSelectable(a)){r=n&&o.$from.depth>0&&s>=o.$from.depth&&i.before(o.$from.depth+1)==o.$from.pos?i.before(o.$from.depth):i.before(s);break}}return null!=r&&(Rr(t,me.create(t.state.doc,r),"pointer"),!0)}(t,n):function(t,e){if(-1==e)return!1;var n=t.state.doc.resolve(e),r=n.nodeAfter;return!!(r&&r.isAtom&&me.isSelectable(r))&&(Rr(t,new me(n),"pointer"),!0)}(t,n))}(this.view,e.pos,e.inside,t,this.selectNode)?t.preventDefault():this.flushed||Ie.safari&&this.mightDrag&&!this.mightDrag.node.isAtom||Ie.chrome&&!(this.view.state.selection instanceof de)&&(e.pos==this.view.state.selection.from||e.pos==this.view.state.selection.to)?(Rr(this.view,he.near(this.view.state.doc.resolve(e.pos)),"pointer"),t.preventDefault()):Er(this.view,"pointer")}},$r.prototype.move=function(t){!this.allowDefault&&(Math.abs(this.event.x-t.clientX)>4||Math.abs(this.event.y-t.clientY)>4)&&(this.allowDefault=!0),Er(this.view,"pointer"),0==t.buttons&&this.done()},Dr.touchdown=function(t){Fr(t),Er(t,"pointer")},Dr.contextmenu=function(t){return Fr(t)};var _r=Ie.android?5e3:-1;function jr(t,e){clearTimeout(t.composingTimeout),e>-1&&(t.composingTimeout=setTimeout((function(){return Jr(t)}),e))}function Wr(t){for(t.composing=!1;t.compositionNodes.length>0;)t.compositionNodes.pop().markParentsDirty()}function Jr(t,e){if(t.domObserver.forceFlush(),Wr(t),e||t.docView.dirty){var n=_n(t);return n&&!n.eq(t.state.selection)?t.dispatch(t.state.tr.setSelection(n)):t.updateState(t.state),!0}return!1}Tr.compositionstart=Tr.compositionupdate=function(t){if(!t.composing){t.domObserver.flush();var e=t.state,n=e.selection.$from;if(e.selection.empty&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some((function(t){return!1===t.type.spec.inclusive}))))t.markCursor=t.state.storedMarks||n.marks(),Jr(t,!0),t.markCursor=null;else if(Jr(t),Ie.gecko&&e.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length)for(var r=t.root.getSelection(),o=r.focusNode,i=r.focusOffset;o&&1==o.nodeType&&0!=i;){var s=i<0?o.lastChild:o.childNodes[i-1];if(!s)break;if(3==s.nodeType){r.collapse(s,s.nodeValue.length);break}o=s,i=-1}t.composing=!0}jr(t,_r)},Tr.compositionend=function(t,e){t.composing&&(t.composing=!1,t.compositionEndedAt=e.timeStamp,jr(t,20))};var Kr=Ie.ie&&Ie.ie_version<15||Ie.ios&&Ie.webkit_version<604;function Hr(t,e,n,r){var o=mr(t,e,n,t.shiftKey,t.state.selection.$from);if(t.someProp("handlePaste",(function(e){return e(t,r,o||p.empty)})))return!0;if(!o)return!1;var i=function(t){return 0==t.openStart&&0==t.openEnd&&1==t.content.childCount?t.content.firstChild:null}(o),s=i?t.state.tr.replaceSelectionWith(i,t.shiftKey):t.state.tr.replaceSelection(o);return t.dispatch(s.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}Dr.copy=Tr.cut=function(t,e){var n=t.state.selection,r="cut"==e.type;if(!n.empty){var o=Kr?null:e.clipboardData,i=ur(t,n.content()),s=i.dom,a=i.text;o?(e.preventDefault(),o.clearData(),o.setData("text/html",s.innerHTML),o.setData("text/plain",a)):function(t,e){if(t.dom.parentNode){var n=t.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(e),n.style.cssText="position: fixed; left: -10000px; top: 10px";var r=getSelection(),o=document.createRange();o.selectNodeContents(e),t.dom.blur(),r.removeAllRanges(),r.addRange(o),setTimeout((function(){n.parentNode&&n.parentNode.removeChild(n),t.focus()}),50)}}(t,s),r&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))}},Tr.paste=function(t,e){var n=Kr?null:e.clipboardData;n&&Hr(t,n.getData("text/plain"),n.getData("text/html"),e)?e.preventDefault():function(t,e){if(t.dom.parentNode){var n=t.shiftKey||t.state.selection.$from.parent.type.spec.code,r=t.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus(),setTimeout((function(){t.focus(),r.parentNode&&r.parentNode.removeChild(r),n?Hr(t,r.value,null,e):Hr(t,r.textContent,r.innerHTML,e)}),50)}}(t,e)};var Ur=function(t,e){this.slice=t,this.move=e},Gr=Ie.mac?"altKey":"ctrlKey";for(var Xr in Dr.dragstart=function(t,e){var n=t.mouseDown;if(n&&n.done(),e.dataTransfer){var r=t.state.selection,o=r.empty?null:t.posAtCoords(zr(e));if(o&&o.pos>=r.from&&o.pos<=(r instanceof me?r.to-1:r.to));else if(n&&n.mightDrag)t.dispatch(t.state.tr.setSelection(me.create(t.state.doc,n.mightDrag.pos)));else if(e.target&&1==e.target.nodeType){var i=t.docView.nearestDesc(e.target,!0);if(!i||!i.node.type.spec.draggable||i==t.docView)return;t.dispatch(t.state.tr.setSelection(me.create(t.state.doc,i.posBefore)))}var s=t.state.selection.content(),a=ur(t,s),c=a.dom,l=a.text;e.dataTransfer.clearData(),e.dataTransfer.setData(Kr?"Text":"text/html",c.innerHTML),e.dataTransfer.effectAllowed="copyMove",Kr||e.dataTransfer.setData("text/plain",l),t.dragging=new Ur(s,!e[Gr])}},Dr.dragend=function(t){var e=t.dragging;window.setTimeout((function(){t.dragging==e&&(t.dragging=null)}),50)},Tr.dragover=Tr.dragenter=function(t,e){return e.preventDefault()},Tr.drop=function(t,e){var n=t.dragging;if(t.dragging=null,e.dataTransfer){var r=t.posAtCoords(zr(e));if(r){var o=t.state.doc.resolve(r.pos);if(o){var i=n&&n.slice||mr(t,e.dataTransfer.getData(Kr?"Text":"text/plain"),Kr?null:e.dataTransfer.getData("text/html"),!1,o),s=n&&!e[Gr];if(t.someProp("handleDrop",(function(n){return n(t,e,i||p.empty,s)})))e.preventDefault();else if(i){e.preventDefault();var a=i?Gt(t.state.doc,o.pos,i):o.pos;null==a&&(a=o.pos);var c=t.state.tr;s&&c.deleteSelection();var l=c.mapping.map(a),h=0==i.openStart&&0==i.openEnd&&1==i.content.childCount,f=c.doc;if(h?c.replaceRangeWith(l,l,i.content.firstChild):c.replaceRange(l,l,i),!c.doc.eq(f)){var d=c.doc.resolve(l);if(h&&me.isSelectable(i.content.firstChild)&&d.nodeAfter&&d.nodeAfter.sameMarkup(i.content.firstChild))c.setSelection(new me(d));else{var u=c.mapping.map(a);c.mapping.maps[c.mapping.maps.length-1].forEach((function(t,e,n,r){return u=r})),c.setSelection(Yn(t,d,c.doc.resolve(u)))}t.focus(),t.dispatch(c.setMeta("uiEvent","drop"))}}}}}},Dr.focus=function(t){t.focused||(t.domObserver.stop(),t.dom.classList.add("ProseMirror-focused"),t.domObserver.start(),t.focused=!0,setTimeout((function(){t.docView&&t.hasFocus()&&!t.domObserver.currentSelection.eq(t.root.getSelection())&&Wn(t)}),20))},Dr.blur=function(t){t.focused&&(t.domObserver.stop(),t.dom.classList.remove("ProseMirror-focused"),t.domObserver.start(),t.domObserver.currentSelection.set({}),t.focused=!1)},Dr.beforeinput=function(t,e){if(Ie.chrome&&Ie.android&&"deleteContentBackward"==e.inputType){var n=t.domChangeCount;setTimeout((function(){if(t.domChangeCount==n&&(t.dom.blur(),t.focus(),!t.someProp("handleKeyDown",(function(e){return e(t,Xe(8,"Backspace"))})))){var e=t.state.selection.$cursor;e&&e.pos>0&&t.dispatch(t.state.tr.delete(e.pos-1,e.pos).scrollIntoView())}}),50)}},Tr)Dr[Xr]=Tr[Xr];function Yr(t,e){if(t==e)return!0;for(var n in t)if(t[n]!==e[n])return!1;for(var r in e)if(!(r in t))return!1;return!0}var Qr=function(t,e){this.spec=e||oo,this.side=this.spec.side||0,this.toDOM=t};Qr.prototype.map=function(t,e,n,r){var o=t.mapResult(e.from+r,this.side<0?-1:1),i=o.pos;return o.deleted?null:new eo(i-n,i-n,this)},Qr.prototype.valid=function(){return!0},Qr.prototype.eq=function(t){return this==t||t instanceof Qr&&(this.spec.key&&this.spec.key==t.spec.key||this.toDOM==t.toDOM&&Yr(this.spec,t.spec))};var Zr=function(t,e){this.spec=e||oo,this.attrs=t};Zr.prototype.map=function(t,e,n,r){var o=t.map(e.from+r,this.spec.inclusiveStart?-1:1)-n,i=t.map(e.to+r,this.spec.inclusiveEnd?1:-1)-n;return o>=i?null:new eo(o,i,this)},Zr.prototype.valid=function(t,e){return e.from<e.to},Zr.prototype.eq=function(t){return this==t||t instanceof Zr&&Yr(this.attrs,t.attrs)&&Yr(this.spec,t.spec)},Zr.is=function(t){return t.type instanceof Zr};var to=function(t,e){this.spec=e||oo,this.attrs=t};to.prototype.map=function(t,e,n,r){var o=t.mapResult(e.from+r,1);if(o.deleted)return null;var i=t.mapResult(e.to+r,-1);return i.deleted||i.pos<=o.pos?null:new eo(o.pos-n,i.pos-n,this)},to.prototype.valid=function(t,e){var n=t.content.findIndex(e.from),r=n.index,o=n.offset;return o==e.from&&o+t.child(r).nodeSize==e.to},to.prototype.eq=function(t){return this==t||t instanceof to&&Yr(this.attrs,t.attrs)&&Yr(this.spec,t.spec)};var eo=function(t,e,n){this.from=t,this.to=e,this.type=n},no={spec:{configurable:!0},inline:{configurable:!0}};eo.prototype.copy=function(t,e){return new eo(t,e,this.type)},eo.prototype.eq=function(t,e){return void 0===e&&(e=0),this.type.eq(t.type)&&this.from+e==t.from&&this.to+e==t.to},eo.prototype.map=function(t,e,n){return this.type.map(t,this,e,n)},eo.widget=function(t,e,n){return new eo(t,t,new Qr(e,n))},eo.inline=function(t,e,n,r){return new eo(t,e,new Zr(n,r))},eo.node=function(t,e,n,r){return new eo(t,e,new to(n,r))},no.spec.get=function(){return this.type.spec},no.inline.get=function(){return this.type instanceof Zr},Object.defineProperties(eo.prototype,no);var ro=[],oo={},io=function(t,e){this.local=t&&t.length?t:ro,this.children=e&&e.length?e:ro};io.create=function(t,e){return e.length?po(e,t,0,oo):so},io.prototype.find=function(t,e,n){var r=[];return this.findInner(null==t?0:t,null==e?1e9:e,r,0,n),r},io.prototype.findInner=function(t,e,n,r,o){for(var i=0;i<this.local.length;i++){var s=this.local[i];s.from<=e&&s.to>=t&&(!o||o(s.spec))&&n.push(s.copy(s.from+r,s.to+r))}for(var a=0;a<this.children.length;a+=3)if(this.children[a]<e&&this.children[a+1]>t){var c=this.children[a]+1;this.children[a+2].findInner(t-c,e-c,n,r+c,o)}},io.prototype.map=function(t,e,n){return this==so||0==t.maps.length?this:this.mapInner(t,e,0,0,n||oo)},io.prototype.mapInner=function(t,e,n,r,o){for(var i,s=0;s<this.local.length;s++){var a=this.local[s].map(t,n,r);a&&a.type.valid(e,a)?(i||(i=[])).push(a):o.onRemove&&o.onRemove(this.local[s].spec)}return this.children.length?function(t,e,n,r,o,i,s){for(var a=t.slice(),c=function(t,e,n,r){for(var s=0;s<a.length;s+=3){var c=a[s+1],l=void 0;-1==c||t>c+i||(e>=a[s]+i?a[s+1]=-1:n>=o&&(l=r-n-(e-t))&&(a[s]+=l,a[s+1]+=l))}},l=0;l<n.maps.length;l++)n.maps[l].forEach(c);for(var h=!1,p=0;p<a.length;p+=3)if(-1==a[p+1]){var f=n.map(t[p]+i),d=f-o;if(d<0||d>=r.content.size){h=!0;continue}var u=n.map(t[p+1]+i,-1)-o,m=r.content.findIndex(d),v=m.index,g=m.offset,y=r.maybeChild(v);if(y&&g==d&&g+y.nodeSize==u){var w=a[p+2].mapInner(n,y,f+1,t[p]+i+1,s);w!=so?(a[p]=d,a[p+1]=u,a[p+2]=w):(a[p+1]=-2,h=!0)}else h=!0}if(h){var b=po(function(t,e,n,r,o,i,s){function a(t,e){for(var i=0;i<t.local.length;i++){var c=t.local[i].map(r,o,e);c?n.push(c):s.onRemove&&s.onRemove(t.local[i].spec)}for(var l=0;l<t.children.length;l+=3)a(t.children[l+2],t.children[l]+e+1)}for(var c=0;c<t.length;c+=3)-1==t[c+1]&&a(t[c+2],e[c]+i+1);return n}(a,t,e||[],n,o,i,s),r,0,s);e=b.local;for(var x=0;x<a.length;x+=3)a[x+1]<0&&(a.splice(x,3),x-=3);for(var k=0,S=0;k<b.children.length;k+=3){for(var C=b.children[k];S<a.length&&a[S]<C;)S+=3;a.splice(S,0,b.children[k],b.children[k+1],b.children[k+2])}}return new io(e&&e.sort(fo),a)}(this.children,i,t,e,n,r,o):i?new io(i.sort(fo)):so},io.prototype.add=function(t,e){return e.length?this==so?io.create(t,e):this.addInner(t,e,0):this},io.prototype.addInner=function(t,e,n){var r,o=this,i=0;t.forEach((function(t,s){var a,c=s+n;if(a=lo(e,t,c)){for(r||(r=o.children.slice());i<r.length&&r[i]<s;)i+=3;r[i]==s?r[i+2]=r[i+2].addInner(t,a,c+1):r.splice(i,0,s,s+t.nodeSize,po(a,t,c+1,oo)),i+=3}}));for(var s=co(i?ho(e):e,-n),a=0;a<s.length;a++)s[a].type.valid(t,s[a])||s.splice(a--,1);return new io(s.length?this.local.concat(s).sort(fo):this.local,r||this.children)},io.prototype.remove=function(t){return 0==t.length||this==so?this:this.removeInner(t,0)},io.prototype.removeInner=function(t,e){for(var n=this.children,r=this.local,o=0;o<n.length;o+=3){for(var i=void 0,s=n[o]+e,a=n[o+1]+e,c=0,l=void 0;c<t.length;c++)(l=t[c])&&l.from>s&&l.to<a&&(t[c]=null,(i||(i=[])).push(l));if(i){n==this.children&&(n=this.children.slice());var h=n[o+2].removeInner(i,s+1);h!=so?n[o+2]=h:(n.splice(o,3),o-=3)}}if(r.length)for(var p=0,f=void 0;p<t.length;p++)if(f=t[p])for(var d=0;d<r.length;d++)r[d].eq(f,e)&&(r==this.local&&(r=this.local.slice()),r.splice(d--,1));return n==this.children&&r==this.local?this:r.length||n.length?new io(r,n):so},io.prototype.forChild=function(t,e){if(this==so)return this;if(e.isLeaf)return io.empty;for(var n,r,o=0;o<this.children.length;o+=3)if(this.children[o]>=t){this.children[o]==t&&(n=this.children[o+2]);break}for(var i=t+1,s=i+e.content.size,a=0;a<this.local.length;a++){var c=this.local[a];if(c.from<s&&c.to>i&&c.type instanceof Zr){var l=Math.max(i,c.from)-i,h=Math.min(s,c.to)-i;l<h&&(r||(r=[])).push(c.copy(l,h))}}if(r){var p=new io(r.sort(fo));return n?new ao([p,n]):p}return n||so},io.prototype.eq=function(t){if(this==t)return!0;if(!(t instanceof io)||this.local.length!=t.local.length||this.children.length!=t.children.length)return!1;for(var e=0;e<this.local.length;e++)if(!this.local[e].eq(t.local[e]))return!1;for(var n=0;n<this.children.length;n+=3)if(this.children[n]!=t.children[n]||this.children[n+1]!=t.children[n+1]||!this.children[n+2].eq(t.children[n+2]))return!1;return!0},io.prototype.locals=function(t){return uo(this.localsInner(t))},io.prototype.localsInner=function(t){if(this==so)return ro;if(t.inlineContent||!this.local.some(Zr.is))return this.local;for(var e=[],n=0;n<this.local.length;n++)this.local[n].type instanceof Zr||e.push(this.local[n]);return e};var so=new io;io.empty=so,io.removeOverlap=uo;var ao=function(t){this.members=t};function co(t,e){if(!e||!t.length)return t;for(var n=[],r=0;r<t.length;r++){var o=t[r];n.push(new eo(o.from+e,o.to+e,o.type))}return n}function lo(t,e,n){if(e.isLeaf)return null;for(var r=n+e.nodeSize,o=null,i=0,s=void 0;i<t.length;i++)(s=t[i])&&s.from>n&&s.to<r&&((o||(o=[])).push(s),t[i]=null);return o}function ho(t){for(var e=[],n=0;n<t.length;n++)null!=t[n]&&e.push(t[n]);return e}function po(t,e,n,r){var o=[],i=!1;e.forEach((function(e,s){var a=lo(t,e,s+n);if(a){i=!0;var c=po(a,e,n+s+1,r);c!=so&&o.push(s,s+e.nodeSize,c)}}));for(var s=co(i?ho(t):t,-n).sort(fo),a=0;a<s.length;a++)s[a].type.valid(e,s[a])||(r.onRemove&&r.onRemove(s[a].spec),s.splice(a--,1));return s.length||o.length?new io(s,o):so}function fo(t,e){return t.from-e.from||t.to-e.to}function uo(t){for(var e=t,n=0;n<e.length-1;n++){var r=e[n];if(r.from!=r.to)for(var o=n+1;o<e.length;o++){var i=e[o];if(i.from!=r.from){i.from<r.to&&(e==t&&(e=t.slice()),e[n]=r.copy(r.from,i.from),mo(e,o,r.copy(i.from,r.to)));break}i.to!=r.to&&(e==t&&(e=t.slice()),e[o]=i.copy(i.from,r.to),mo(e,o+1,i.copy(r.to,i.to)))}}return e}function mo(t,e,n){for(;e<t.length&&fo(n,t[e])>0;)e++;t.splice(e,0,n)}function vo(t){var e=[];return t.someProp("decorations",(function(n){var r=n(t.state);r&&r!=so&&e.push(r)})),t.cursorWrapper&&e.push(io.create(t.state.doc,[t.cursorWrapper.deco])),ao.from(e)}ao.prototype.forChild=function(t,e){if(e.isLeaf)return io.empty;for(var n=[],r=0;r<this.members.length;r++){var o=this.members[r].forChild(t,e);o!=so&&(o instanceof ao?n=n.concat(o.members):n.push(o))}return ao.from(n)},ao.prototype.eq=function(t){if(!(t instanceof ao)||t.members.length!=this.members.length)return!1;for(var e=0;e<this.members.length;e++)if(!this.members[e].eq(t.members[e]))return!1;return!0},ao.prototype.locals=function(t){for(var e,n=!0,r=0;r<this.members.length;r++){var o=this.members[r].localsInner(t);if(o.length)if(e){n&&(e=e.slice(),n=!1);for(var i=0;i<o.length;i++)e.push(o[i])}else e=o}return e?uo(n?e:e.sort(fo)):ro},ao.from=function(t){switch(t.length){case 0:return so;case 1:return t[0];default:return new ao(t)}};var go=function(t,e){this._props=e,this.state=e.state,this.dispatch=this.dispatch.bind(this),this._root=null,this.focused=!1,this.trackWrites=null,this.dom=t&&t.mount||document.createElement("div"),t&&(t.appendChild?t.appendChild(this.dom):t.apply?t(this.dom):t.mount&&(this.mounted=!0)),this.editable=xo(this),this.markCursor=null,this.cursorWrapper=null,bo(this),this.nodeViews=ko(this),this.docView=On(this.state.doc,wo(this),vo(this),this.dom,this),this.lastSelectedViewDesc=null,this.dragging=null,function(t){t.shiftKey=!1,t.mouseDown=null,t.lastKeyCode=null,t.lastKeyCodeTime=0,t.lastClick={time:0,x:0,y:0,type:""},t.lastSelectionOrigin=null,t.lastSelectionTime=0,t.lastIOSEnter=0,t.lastIOSEnterFallbackTimeout=null,t.lastAndroidDelete=0,t.composing=!1,t.composingTimeout=null,t.compositionNodes=[],t.compositionEndedAt=-2e8,t.domObserver=new Or(t,(function(e,n,r,i){return function(t,e,n,r,i){if(e<0){var s=t.lastSelectionTime>Date.now()-50?t.lastSelectionOrigin:null,a=_n(t,s);if(a&&!t.state.selection.eq(a)){var c=t.state.tr.setSelection(a);"pointer"==s?c.setMeta("pointer",!0):"key"==s&&c.scrollIntoView(),t.dispatch(c)}}else{var l=t.state.doc.resolve(e),h=l.sharedDepth(n);e=l.before(h+1),n=t.state.doc.resolve(n).after(h+1);var p=t.state.selection,f=function(t,e,n){var r=t.docView.parseRange(e,n),o=r.node,i=r.fromOffset,s=r.toOffset,a=r.from,c=r.to,l=t.root.getSelection(),h=null,p=l.anchorNode;if(p&&t.dom.contains(1==p.nodeType?p:p.parentNode)&&(h=[{node:p,offset:l.anchorOffset}],Ge(l)||h.push({node:l.focusNode,offset:l.focusOffset})),Ie.chrome&&8===t.lastKeyCode)for(var f=s;f>i;f--){var d=o.childNodes[f-1],u=d.pmViewDesc;if("BR"==d.nodeName&&!u){s=f;break}if(!u||u.size)break}var m=t.state.doc,v=t.someProp("domParser")||rt.fromSchema(t.state.schema),g=m.resolve(a),y=null,w=v.parse(o,{topNode:g.parent,topMatch:g.parent.contentMatchAt(g.index()),topOpen:!0,from:i,to:s,preserveWhitespace:!g.parent.type.spec.code||"full",editableContent:!0,findPositions:h,ruleFromNode:pr,context:g});if(h&&null!=h[0].pos){var b=h[0].pos,x=h[1]&&h[1].pos;null==x&&(x=b),y={anchor:b+a,head:x+a}}return{doc:w,sel:y,from:a,to:c}}(t,e,n);if(Ie.chrome&&t.cursorWrapper&&f.sel&&f.sel.anchor==t.cursorWrapper.deco.from){var d=t.cursorWrapper.deco.type.toDOM.nextSibling,u=d&&d.nodeValue?d.nodeValue.length:1;f.sel={anchor:f.sel.anchor+u,head:f.sel.anchor+u}}var m,v,g=t.state.doc,y=g.slice(f.from,f.to);8===t.lastKeyCode&&Date.now()-100<t.lastKeyCodeTime?(m=t.state.selection.to,v="end"):(m=t.state.selection.from,v="start"),t.lastKeyCode=null;var w=function(t,e,n,r,o){var i=t.findDiffStart(e,n);if(null==i)return null;var s=t.findDiffEnd(e,n+t.size,n+e.size),a=s.a,c=s.b;return"end"==o&&(r-=a+Math.max(0,i-Math.min(a,c))-i),a<i&&t.size<e.size?(c=(i-=r<=i&&r>=a?i-r:0)+(c-a),a=i):c<i&&(a=(i-=r<=i&&r>=c?i-r:0)+(a-c),c=i),{start:i,endA:a,endB:c}}(y.content,f.doc.content,f.from,m,v);if(!w){if(!(r&&p instanceof de&&!p.empty&&p.$head.sameParent(p.$anchor))||t.composing||f.sel&&f.sel.anchor!=f.sel.head){if((Ie.ios&&t.lastIOSEnter>Date.now()-225||Ie.android)&&i.some((function(t){return"DIV"==t.nodeName||"P"==t.nodeName}))&&t.someProp("handleKeyDown",(function(e){return e(t,Xe(13,"Enter"))})))return void(t.lastIOSEnter=0);if(f.sel){var b=fr(t,t.state.doc,f.sel);b&&!b.eq(t.state.selection)&&t.dispatch(t.state.tr.setSelection(b))}return}w={start:p.from,endA:p.to,endB:p.to}}t.domChangeCount++,t.state.selection.from<t.state.selection.to&&w.start==w.endB&&t.state.selection instanceof de&&(w.start>t.state.selection.from&&w.start<=t.state.selection.from+2?w.start=t.state.selection.from:w.endA<t.state.selection.to&&w.endA>=t.state.selection.to-2&&(w.endB+=t.state.selection.to-w.endA,w.endA=t.state.selection.to)),Ie.ie&&Ie.ie_version<=11&&w.endB==w.start+1&&w.endA==w.start&&w.start>f.from&&"  "==f.doc.textBetween(w.start-f.from-1,w.start-f.from+1)&&(w.start--,w.endA--,w.endB--);var x,k=f.doc.resolveNoCache(w.start-f.from),S=f.doc.resolveNoCache(w.endB-f.from),C=k.sameParent(S)&&k.parent.inlineContent;if((Ie.ios&&t.lastIOSEnter>Date.now()-225&&(!C||i.some((function(t){return"DIV"==t.nodeName||"P"==t.nodeName})))||!C&&k.pos<f.doc.content.size&&(x=he.findFrom(f.doc.resolve(k.pos+1),1,!0))&&x.head==S.pos)&&t.someProp("handleKeyDown",(function(e){return e(t,Xe(13,"Enter"))})))t.lastIOSEnter=0;else if(t.state.selection.anchor>w.start&&function(t,e,n,r,o){if(!r.parent.isTextblock||n-e<=o.pos-r.pos||dr(r,!0,!1)<o.pos)return!1;var i=t.resolve(e);if(i.parentOffset<i.parent.content.size||!i.parent.isTextblock)return!1;var s=t.resolve(dr(i,!0,!0));return!(!s.parent.isTextblock||s.pos>n||dr(s,!0,!1)<n)&&r.parent.content.cut(r.parentOffset).eq(s.parent.content)}(g,w.start,w.endA,k,S)&&t.someProp("handleKeyDown",(function(e){return e(t,Xe(8,"Backspace"))})))Ie.android&&Ie.chrome&&t.domObserver.suppressSelectionUpdates();else{Ie.chrome&&Ie.android&&w.toB==w.from&&(t.lastAndroidDelete=Date.now()),Ie.android&&!C&&k.start()!=S.start()&&0==S.parentOffset&&k.depth==S.depth&&f.sel&&f.sel.anchor==f.sel.head&&f.sel.head==w.endA&&(w.endB-=2,S=f.doc.resolveNoCache(w.endB-f.from),setTimeout((function(){t.someProp("handleKeyDown",(function(e){return e(t,Xe(13,"Enter"))}))}),20));var M,O,N,D,T=w.start,E=w.endA;if(C)if(k.pos==S.pos)Ie.ie&&Ie.ie_version<=11&&0==k.parentOffset&&(t.domObserver.suppressSelectionUpdates(),setTimeout((function(){return Wn(t)}),20)),M=t.state.tr.delete(T,E),O=g.resolve(w.start).marksAcross(g.resolve(w.endA));else if(w.endA==w.endB&&(D=g.resolve(w.start))&&(N=function(t,e){for(var n,r,i,s=t.firstChild.marks,a=e.firstChild.marks,c=s,l=a,h=0;h<a.length;h++)c=a[h].removeFromSet(c);for(var p=0;p<s.length;p++)l=s[p].removeFromSet(l);if(1==c.length&&0==l.length)r=c[0],n="add",i=function(t){return t.mark(r.addToSet(t.marks))};else{if(0!=c.length||1!=l.length)return null;r=l[0],n="remove",i=function(t){return t.mark(r.removeFromSet(t.marks))}}for(var f=[],d=0;d<e.childCount;d++)f.push(i(e.child(d)));if(o.from(f).eq(t))return{mark:r,type:n}}(k.parent.content.cut(k.parentOffset,S.parentOffset),D.parent.content.cut(D.parentOffset,w.endA-D.start()))))M=t.state.tr,"add"==N.type?M.addMark(T,E,N.mark):M.removeMark(T,E,N.mark);else if(k.parent.child(k.index()).isText&&k.index()==S.index()-(S.textOffset?0:1)){var A=k.parent.textBetween(k.parentOffset,S.parentOffset);if(t.someProp("handleTextInput",(function(e){return e(t,T,E,A)})))return;M=t.state.tr.insertText(A,T,E)}if(M||(M=t.state.tr.replace(T,E,f.doc.slice(w.start-f.from,w.endB-f.from))),f.sel){var P=fr(t,M.doc,f.sel);P&&!(Ie.chrome&&Ie.android&&t.composing&&P.empty&&(w.from!=w.toB||t.lastAndroidDelete<Date.now()-100)&&(P.head==T||P.head==M.mapping.map(E)-1)||Ie.ie&&P.empty&&P.head==T)&&M.setSelection(P)}O&&M.ensureMarks(O),t.dispatch(M.scrollIntoView())}}}(t,e,n,r,i)})),t.domObserver.start(),t.domChangeCount=0,t.eventHandlers=Object.create(null);var e=function(e){var n=Dr[e];t.dom.addEventListener(e,t.eventHandlers[e]=function(e){!function(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(var n=e.target;n!=t.dom;n=n.parentNode)if(!n||11==n.nodeType||n.pmViewDesc&&n.pmViewDesc.stopEvent(e))return!1;return!0}(t,e)||Pr(t,e)||!t.editable&&e.type in Tr||n(t,e)})};for(var n in Dr)e(n);Ie.safari&&t.dom.addEventListener("input",(function(){return null})),Ar(t)}(this),this.pluginViews=[],this.updatePluginViews()},yo={props:{configurable:!0},root:{configurable:!0}};function wo(t){var e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(t.editable),t.someProp("attributes",(function(n){if("function"==typeof n&&(n=n(t.state)),n)for(var r in n)"class"==r?e.class+=" "+n[r]:e[r]||"contenteditable"==r||"nodeName"==r||(e[r]=String(n[r]))})),[eo.node(0,t.state.doc.content.size,e)]}function bo(t){if(t.markCursor){var e=document.createElement("img");e.setAttribute("mark-placeholder","true"),t.cursorWrapper={dom:e,deco:eo.widget(t.state.selection.head,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function xo(t){return!t.someProp("editable",(function(e){return!1===e(t.state)}))}function ko(t){var e={};return t.someProp("nodeViews",(function(t){for(var n in t)Object.prototype.hasOwnProperty.call(e,n)||(e[n]=t[n])})),e}yo.props.get=function(){if(this._props.state!=this.state){var t=this._props;for(var e in this._props={},t)this._props[e]=t[e];this._props.state=this.state}return this._props},go.prototype.update=function(t){t.handleDOMEvents!=this._props.handleDOMEvents&&Ar(this),this._props=t,this.updateStateInner(t.state,!0)},go.prototype.setProps=function(t){var e={};for(var n in this._props)e[n]=this._props[n];for(var r in e.state=this.state,t)e[r]=t[r];this.update(e)},go.prototype.updateState=function(t){this.updateStateInner(t,this.state.plugins!=t.plugins)},go.prototype.updateStateInner=function(t,e){var n=this,r=this.state,o=!1,i=!1;if(t.storedMarks&&this.composing&&(Wr(this),i=!0),this.state=t,e){var s=ko(this);(function(t,e){var n=0,r=0;for(var o in t){if(t[o]!=e[o])return!0;n++}for(var i in e)r++;return n!=r})(s,this.nodeViews)&&(this.nodeViews=s,o=!0),Ar(this)}this.editable=xo(this),bo(this);var a=vo(this),c=wo(this),l=e?"reset":t.scrollToSelection>r.scrollToSelection?"to selection":"preserve",h=o||!this.docView.matchesNode(t.doc,c,a);!h&&t.selection.eq(r.selection)||(i=!0);var p,f,d,u,m,v,g,y="preserve"==l&&i&&null==this.dom.style.overflowAnchor&&function(t){for(var e,n,r=t.dom.getBoundingClientRect(),o=Math.max(0,r.top),i=(r.left+r.right)/2,s=o+1;s<Math.min(innerHeight,r.bottom);s+=5){var a=t.root.elementFromPoint(i,s);if(a!=t.dom&&t.dom.contains(a)){var c=a.getBoundingClientRect();if(c.top>=o-20){e=a,n=c.top;break}}}return{refDOM:e,refTop:n,stack:en(t.dom)}}(this);if(i){this.domObserver.stop();var w=h&&(Ie.ie||Ie.chrome)&&!this.composing&&!r.selection.empty&&!t.selection.empty&&(p=r.selection,f=t.selection,d=Math.min(p.$anchor.sharedDepth(p.head),f.$anchor.sharedDepth(f.head)),p.$anchor.start(d)!=f.$anchor.start(d));if(h){var b=Ie.chrome?this.trackWrites=this.root.getSelection().focusNode:null;!o&&this.docView.update(t.doc,c,a,this)||(this.docView.updateOuterDeco([]),this.docView.destroy(),this.docView=On(t.doc,c,a,this.dom,this)),b&&!this.trackWrites&&(w=!0)}w||!(this.mouseDown&&this.domObserver.currentSelection.eq(this.root.getSelection())&&function(t){var e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.root.getSelection();return We(e.node,e.offset,n.anchorNode,n.anchorOffset)}(this))?Wn(this,w):(Gn(this,t.selection),this.domObserver.setCurSelection()),this.domObserver.start()}if(this.updatePluginViews(r),"reset"==l)this.dom.scrollTop=0;else if("to selection"==l){var x=this.root.getSelection().focusNode;this.someProp("handleScrollToSelection",(function(t){return t(n)}))||(t.selection instanceof me?tn(this,this.docView.domAfterPos(t.selection.from).getBoundingClientRect(),x):tn(this,this.coordsAtPos(t.selection.head,1),x))}else y&&(m=(u=y).refDOM,v=u.refTop,nn(u.stack,0==(g=m?m.getBoundingClientRect().top:0)?0:g-v))},go.prototype.destroyPluginViews=function(){for(var t;t=this.pluginViews.pop();)t.destroy&&t.destroy()},go.prototype.updatePluginViews=function(t){if(t&&t.plugins==this.state.plugins)for(var e=0;e<this.pluginViews.length;e++){var n=this.pluginViews[e];n.update&&n.update(this,t)}else{this.destroyPluginViews();for(var r=0;r<this.state.plugins.length;r++){var o=this.state.plugins[r];o.spec.view&&this.pluginViews.push(o.spec.view(this))}}},go.prototype.someProp=function(t,e){var n,r=this._props&&this._props[t];if(null!=r&&(n=e?e(r):r))return n;var o=this.state.plugins;if(o)for(var i=0;i<o.length;i++){var s=o[i].props[t];if(null!=s&&(n=e?e(s):s))return n}},go.prototype.hasFocus=function(){return this.root.activeElement==this.dom},go.prototype.focus=function(){this.domObserver.stop(),this.editable&&function(t){if(t.setActive)return t.setActive();if(rn)return t.focus(rn);var e=en(t);t.focus(null==rn?{get preventScroll(){return rn={preventScroll:!0},!0}}:void 0),rn||(rn=!1,nn(e,0))}(this.dom),Wn(this),this.domObserver.start()},yo.root.get=function(){var t=this._root;if(null==t)for(var e=this.dom.parentNode;e;e=e.parentNode)if(9==e.nodeType||11==e.nodeType&&e.host)return e.getSelection||(Object.getPrototypeOf(e).getSelection=function(){return document.getSelection()}),this._root=e;return t||document},go.prototype.posAtCoords=function(t){return cn(this,t)},go.prototype.coordsAtPos=function(t,e){return void 0===e&&(e=1),pn(this,t,e)},go.prototype.domAtPos=function(t,e){return void 0===e&&(e=0),this.docView.domFromPos(t,e)},go.prototype.nodeDOM=function(t){var e=this.docView.descAt(t);return e?e.nodeDOM:null},go.prototype.posAtDOM=function(t,e,n){void 0===n&&(n=-1);var r=this.docView.posFromDOM(t,e,n);if(null==r)throw new RangeError("DOM position not inside the editor");return r},go.prototype.endOfTextblock=function(t,e){return function(t,e,n){return vn==e&&gn==n?yn:(vn=e,gn=n,yn="up"==n||"down"==n?function(t,e,n){var r=e.selection,o="up"==n?r.$from:r.$to;return un(t,e,(function(){for(var e=t.docView.domFromPos(o.pos,"up"==n?-1:1).node;;){var r=t.docView.nearestDesc(e,!0);if(!r)break;if(r.node.isBlock){e=r.dom;break}e=r.dom.parentNode}for(var i=pn(t,o.pos,1),s=e.firstChild;s;s=s.nextSibling){var a=void 0;if(1==s.nodeType)a=s.getClientRects();else{if(3!=s.nodeType)continue;a=je(s,0,s.nodeValue.length).getClientRects()}for(var c=0;c<a.length;c++){var l=a[c];if(l.bottom>l.top&&("up"==n?l.bottom<i.top+1:l.top>i.bottom-1))return!1}}return!0}))}(t,e,n):function(t,e,n){var r=e.selection.$head;if(!r.parent.isTextblock)return!1;var o=r.parentOffset,i=!o,s=o==r.parent.content.size,a=getSelection();return mn.test(r.parent.textContent)&&a.modify?un(t,e,(function(){var e=a.getRangeAt(0),o=a.focusNode,i=a.focusOffset,s=a.caretBidiLevel;a.modify("move",n,"character");var c=!(r.depth?t.docView.domAfterPos(r.before()):t.dom).contains(1==a.focusNode.nodeType?a.focusNode:a.focusNode.parentNode)||o==a.focusNode&&i==a.focusOffset;return a.removeAllRanges(),a.addRange(e),null!=s&&(a.caretBidiLevel=s),c})):"left"==n||"backward"==n?i:s}(t,e,n))}(this,e||this.state,t)},go.prototype.destroy=function(){this.docView&&(function(t){for(var e in t.domObserver.stop(),t.eventHandlers)t.dom.removeEventListener(e,t.eventHandlers[e]);clearTimeout(t.composingTimeout),clearTimeout(t.lastIOSEnterFallbackTimeout)}(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],vo(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null)},go.prototype.dispatchEvent=function(t){return function(t,e){Pr(t,e)||!Dr[e.type]||!t.editable&&e.type in Tr||Dr[e.type](t,e)}(this,t)},go.prototype.dispatch=function(t){var e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))},Object.defineProperties(go.prototype,yo);var So=["ol",0],Co=["ul",0],Mo=["li",0],Oo={attrs:{order:{default:1}},parseDOM:[{tag:"ol",getAttrs:function(t){return{order:t.hasAttribute("start")?+t.getAttribute("start"):1}}}],toDOM:function(t){return 1==t.attrs.order?So:["ol",{start:t.attrs.order},0]}},No={parseDOM:[{tag:"ul"}],toDOM:function(){return Co}},Do={parseDOM:[{tag:"li"}],toDOM:function(){return Mo},defining:!0};function To(t,e){var n={};for(var r in t)n[r]=t[r];for(var o in e)n[o]=e[o];return n}function Eo(t,e){return function(n,r){var i=n.selection,s=i.$from,a=i.$to,c=s.blockRange(a),l=!1,h=c;if(!c)return!1;if(c.depth>=2&&s.node(c.depth-1).type.compatibleContent(t)&&0==c.startIndex){if(0==s.index(c.depth-1))return!1;var f=n.doc.resolve(c.start-2);h=new T(f,f,c.depth),c.endIndex<c.parent.childCount&&(c=new T(s,n.doc.resolve(a.end(c.depth)),c.depth)),l=!0}var d=jt(h,t,e,c);return!!d&&(r&&r(function(t,e,n,r,i){for(var s=o.empty,a=n.length-1;a>=0;a--)s=o.from(n[a].type.create(n[a].attrs,s));t.step(new qt(e.start-(r?2:0),e.end,e.start,e.end,new p(s,0,0),n.length,!0));for(var c=0,l=0;l<n.length;l++)n[l].type==i&&(c=l+1);for(var h=n.length-c,f=e.start+n.length-(r?2:0),d=e.parent,u=e.startIndex,m=e.endIndex,v=!0;u<m;u++,v=!1)!v&&Jt(t.doc,f,h)&&(t.split(f,h),f+=2*h),f+=d.child(u).nodeSize;return t}(n.tr,c,d,l,t).scrollIntoView()),!0)}}for(var Ao={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'",229:"q"},Po={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"',229:"Q"},zo="undefined"!=typeof navigator&&/Chrome\/(\d+)/.exec(navigator.userAgent),Io="undefined"!=typeof navigator&&/Apple Computer/.test(navigator.vendor),Ro="undefined"!=typeof navigator&&/Gecko\/\d+/.test(navigator.userAgent),Bo="undefined"!=typeof navigator&&/Mac/.test(navigator.platform),Vo="undefined"!=typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),Fo=zo&&(Bo||+zo[1]<57)||Ro&&Bo,qo=0;qo<10;qo++)Ao[48+qo]=Ao[96+qo]=String(qo);for(qo=1;qo<=24;qo++)Ao[qo+111]="F"+qo;for(qo=65;qo<=90;qo++)Ao[qo]=String.fromCharCode(qo+32),Po[qo]=String.fromCharCode(qo);for(var $o in Ao)Po.hasOwnProperty($o)||(Po[$o]=Ao[$o]);var Lo="undefined"!=typeof navigator&&/Mac/.test(navigator.platform);function _o(t){var e,n,r,o,i=t.split(/-(?!$)/),s=i[i.length-1];"Space"==s&&(s=" ");for(var a=0;a<i.length-1;a++){var c=i[a];if(/^(cmd|meta|m)$/i.test(c))o=!0;else if(/^a(lt)?$/i.test(c))e=!0;else if(/^(c|ctrl|control)$/i.test(c))n=!0;else if(/^s(hift)?$/i.test(c))r=!0;else{if(!/^mod$/i.test(c))throw new Error("Unrecognized modifier name: "+c);Lo?o=!0:n=!0}}return e&&(s="Alt-"+s),n&&(s="Ctrl-"+s),o&&(s="Meta-"+s),r&&(s="Shift-"+s),s}function jo(t,e,n){return e.altKey&&(t="Alt-"+t),e.ctrlKey&&(t="Ctrl-"+t),e.metaKey&&(t="Meta-"+t),!1!==n&&e.shiftKey&&(t="Shift-"+t),t}function Wo(t){return new Ee({props:{handleKeyDown:Jo(t)}})}function Jo(t){var e=function(t){var e=Object.create(null);for(var n in t)e[_o(n)]=t[n];return e}(t);return function(t,n){var r,o=function(t){var e=!(Fo&&(t.ctrlKey||t.altKey||t.metaKey)||(Io||Vo)&&t.shiftKey&&t.key&&1==t.key.length)&&t.key||(t.shiftKey?Po:Ao)[t.keyCode]||t.key||"Unidentified";return"Esc"==e&&(e="Escape"),"Del"==e&&(e="Delete"),"Left"==e&&(e="ArrowLeft"),"Up"==e&&(e="ArrowUp"),"Right"==e&&(e="ArrowRight"),"Down"==e&&(e="ArrowDown"),e}(n),i=1==o.length&&" "!=o,s=e[jo(o,n,!i)];if(s&&s(t.state,t.dispatch,t))return!0;if(i&&(n.shiftKey||n.altKey||n.metaKey||o.charCodeAt(0)>127)&&(r=Ao[n.keyCode])&&r!=o){var a=e[jo(r,n,!0)];if(a&&a(t.state,t.dispatch,t))return!0}else if(i&&n.shiftKey){var c=e[jo(o,n,!0)];if(c&&c(t.state,t.dispatch,t))return!0}return!1}}var Ko=200,Ho=function(){};Ho.prototype.append=function(t){return t.length?(t=Ho.from(t),!this.length&&t||t.length<Ko&&this.leafAppend(t)||this.length<Ko&&t.leafPrepend(this)||this.appendInner(t)):this},Ho.prototype.prepend=function(t){return t.length?Ho.from(t).append(this):this},Ho.prototype.appendInner=function(t){return new Go(this,t)},Ho.prototype.slice=function(t,e){return void 0===t&&(t=0),void 0===e&&(e=this.length),t>=e?Ho.empty:this.sliceInner(Math.max(0,t),Math.min(this.length,e))},Ho.prototype.get=function(t){if(!(t<0||t>=this.length))return this.getInner(t)},Ho.prototype.forEach=function(t,e,n){void 0===e&&(e=0),void 0===n&&(n=this.length),e<=n?this.forEachInner(t,e,n,0):this.forEachInvertedInner(t,e,n,0)},Ho.prototype.map=function(t,e,n){void 0===e&&(e=0),void 0===n&&(n=this.length);var r=[];return this.forEach((function(e,n){return r.push(t(e,n))}),e,n),r},Ho.from=function(t){return t instanceof Ho?t:t&&t.length?new Uo(t):Ho.empty};var Uo=function(t){function e(e){t.call(this),this.values=e}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(t,n){return 0==t&&n==this.length?this:new e(this.values.slice(t,n))},e.prototype.getInner=function(t){return this.values[t]},e.prototype.forEachInner=function(t,e,n,r){for(var o=e;o<n;o++)if(!1===t(this.values[o],r+o))return!1},e.prototype.forEachInvertedInner=function(t,e,n,r){for(var o=e-1;o>=n;o--)if(!1===t(this.values[o],r+o))return!1},e.prototype.leafAppend=function(t){if(this.length+t.length<=Ko)return new e(this.values.concat(t.flatten()))},e.prototype.leafPrepend=function(t){if(this.length+t.length<=Ko)return new e(t.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(e.prototype,n),e}(Ho);Ho.empty=new Uo([]);var Go=function(t){function e(e,n){t.call(this),this.left=e,this.right=n,this.length=e.length+n.length,this.depth=Math.max(e.depth,n.depth)+1}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(t){return t<this.left.length?this.left.get(t):this.right.get(t-this.left.length)},e.prototype.forEachInner=function(t,e,n,r){var o=this.left.length;return!(e<o&&!1===this.left.forEachInner(t,e,Math.min(n,o),r))&&!(n>o&&!1===this.right.forEachInner(t,Math.max(e-o,0),Math.min(this.length,n)-o,r+o))&&void 0},e.prototype.forEachInvertedInner=function(t,e,n,r){var o=this.left.length;return!(e>o&&!1===this.right.forEachInvertedInner(t,e-o,Math.max(n,o)-o,r+o))&&!(n<o&&!1===this.left.forEachInvertedInner(t,Math.min(e,o),n,r))&&void 0},e.prototype.sliceInner=function(t,e){if(0==t&&e==this.length)return this;var n=this.left.length;return e<=n?this.left.slice(t,e):t>=n?this.right.slice(t-n,e-n):this.left.slice(t,n).append(this.right.slice(0,e-n))},e.prototype.leafAppend=function(t){var n=this.right.leafAppend(t);if(n)return new e(this.left,n)},e.prototype.leafPrepend=function(t){var n=this.left.leafPrepend(t);if(n)return new e(n,this.right)},e.prototype.appendInner=function(t){return this.left.depth>=Math.max(this.right.depth,t.depth)+1?new e(this.left,new e(this.right,t)):new e(this,t)},e}(Ho);const Xo=Ho;var Yo=function(t,e){this.items=t,this.eventCount=e};Yo.prototype.popEvent=function(t,e){var n=this;if(0==this.eventCount)return null;for(var r,o,i=this.items.length;;i--)if(this.items.get(i-1).selection){--i;break}e&&(r=this.remapping(i,this.items.length),o=r.maps.length);var s,a,c=t.tr,l=[],h=[];return this.items.forEach((function(t,e){if(!t.step)return r||(r=n.remapping(i,e+1),o=r.maps.length),o--,void h.push(t);if(r){h.push(new Qo(t.map));var p,f=t.step.map(r.slice(o));f&&c.maybeStep(f).doc&&(p=c.mapping.maps[c.mapping.maps.length-1],l.push(new Qo(p,null,null,l.length+h.length))),o--,p&&r.appendMap(p,o)}else c.maybeStep(t.step);return t.selection?(s=r?t.selection.map(r.slice(o)):t.selection,a=new Yo(n.items.slice(0,i).append(h.reverse().concat(l)),n.eventCount-1),!1):void 0}),this.items.length,0),{remaining:a,transform:c,selection:s}},Yo.prototype.addTransform=function(t,e,n,r){for(var o=[],i=this.eventCount,s=this.items,a=!r&&s.length?s.get(s.length-1):null,c=0;c<t.steps.length;c++){var l,h=t.steps[c].invert(t.docs[c]),p=new Qo(t.mapping.maps[c],h,e);(l=a&&a.merge(p))&&(p=l,c?o.pop():s=s.slice(0,s.length-1)),o.push(p),e&&(i++,e=null),r||(a=p)}var f,d,u,m=i-n.depth;return m>ti&&(d=m,(f=s).forEach((function(t,e){if(t.selection&&0==d--)return u=e,!1})),s=f.slice(u),i-=m),new Yo(s.append(o),i)},Yo.prototype.remapping=function(t,e){var n=new Et;return this.items.forEach((function(e,r){var o=null!=e.mirrorOffset&&r-e.mirrorOffset>=t?n.maps.length-e.mirrorOffset:null;n.appendMap(e.map,o)}),t,e),n},Yo.prototype.addMaps=function(t){return 0==this.eventCount?this:new Yo(this.items.append(t.map((function(t){return new Qo(t)}))),this.eventCount)},Yo.prototype.rebased=function(t,e){if(!this.eventCount)return this;var n=[],r=Math.max(0,this.items.length-e),o=t.mapping,i=t.steps.length,s=this.eventCount;this.items.forEach((function(t){t.selection&&s--}),r);var a=e;this.items.forEach((function(e){var r=o.getMirror(--a);if(null!=r){i=Math.min(i,r);var c=o.maps[r];if(e.step){var l=t.steps[r].invert(t.docs[r]),h=e.selection&&e.selection.map(o.slice(a+1,r));h&&s++,n.push(new Qo(c,l,h))}else n.push(new Qo(c))}}),r);for(var c=[],l=e;l<i;l++)c.push(new Qo(o.maps[l]));var h=this.items.slice(0,r).append(c).append(n),p=new Yo(h,s);return p.emptyItemCount()>500&&(p=p.compress(this.items.length-n.length)),p},Yo.prototype.emptyItemCount=function(){var t=0;return this.items.forEach((function(e){e.step||t++})),t},Yo.prototype.compress=function(t){void 0===t&&(t=this.items.length);var e=this.remapping(0,t),n=e.maps.length,r=[],o=0;return this.items.forEach((function(i,s){if(s>=t)r.push(i),i.selection&&o++;else if(i.step){var a=i.step.map(e.slice(n)),c=a&&a.getMap();if(n--,c&&e.appendMap(c,n),a){var l=i.selection&&i.selection.map(e.slice(n));l&&o++;var h,p=new Qo(c.invert(),a,l),f=r.length-1;(h=r.length&&r[f].merge(p))?r[f]=h:r.push(p)}}else i.map&&n--}),this.items.length,0),new Yo(Xo.from(r.reverse()),o)},Yo.empty=new Yo(Xo.empty,0);var Qo=function(t,e,n,r){this.map=t,this.step=e,this.selection=n,this.mirrorOffset=r};Qo.prototype.merge=function(t){if(this.step&&t.step&&!t.selection){var e=t.step.merge(this.step);if(e)return new Qo(e.getMap().invert(),e,this.selection)}};var Zo=function(t,e,n,r){this.done=t,this.undone=e,this.prevRanges=n,this.prevTime=r},ti=20;function ei(t){var e=[];return t.forEach((function(t,n,r,o){return e.push(r,o)})),e}function ni(t,e){if(!t)return null;for(var n=[],r=0;r<t.length;r+=2){var o=e.map(t[r],1),i=e.map(t[r+1],-1);o<=i&&n.push(o,i)}return n}function ri(t,e,n,r){var o=si(e),i=ai.get(e).spec.config,s=(r?t.undone:t.done).popEvent(e,o);if(s){var a=s.selection.resolve(s.transform.doc),c=(r?t.done:t.undone).addTransform(s.transform,e.selection.getBookmark(),i,o),l=new Zo(r?c:s.remaining,r?s.remaining:c,null,0);n(s.transform.setSelection(a).setMeta(ai,{redo:r,historyState:l}).scrollIntoView())}}var oi=!1,ii=null;function si(t){var e=t.plugins;if(ii!=e){oi=!1,ii=e;for(var n=0;n<e.length;n++)if(e[n].spec.historyPreserveItems){oi=!0;break}}return oi}var ai=new ze("history"),ci=new ze("closeHistory");function li(t,e){var n=ai.getState(t);return!(!n||0==n.done.eventCount||(e&&ri(n,t,e,!1),0))}function hi(t,e){var n=ai.getState(t);return!(!n||0==n.undone.eventCount||(e&&ri(n,t,e,!0),0))}function pi(t,e){return!t.selection.empty&&(e&&e(t.tr.deleteSelection().scrollIntoView()),!0)}function fi(t,e,n){for(;t;t="start"==e?t.firstChild:t.lastChild){if(t.isTextblock)return!0;if(n&&1!=t.childCount)return!1}return!1}function di(t){if(!t.parent.type.spec.isolating)for(var e=t.depth-1;e>=0;e--){if(t.index(e)>0)return t.doc.resolve(t.before(e+1));if(t.node(e).type.spec.isolating)break}return null}function ui(t){if(!t.parent.type.spec.isolating)for(var e=t.depth-1;e>=0;e--){var n=t.node(e);if(t.index(e)+1<n.childCount)return t.doc.resolve(t.after(e+1));if(n.type.spec.isolating)break}return null}function mi(t,e){var n,r=t.selection,o=r instanceof me;if(o){if(r.node.isTextblock||!Kt(t.doc,r.from))return!1;n=r.from}else if(null==(n=Ut(t.doc,r.from,-1)))return!1;if(e){var i=t.tr.join(n);o&&i.setSelection(me.create(i.doc,n-t.doc.resolve(n).nodeBefore.nodeSize)),e(i.scrollIntoView())}return!0}function vi(t,e){var n,r=t.selection;if(r instanceof me){if(r.node.isTextblock||!Kt(t.doc,r.to))return!1;n=r.to}else if(null==(n=Ut(t.doc,r.to,1)))return!1;return e&&e(t.tr.join(n).scrollIntoView()),!0}function gi(t,e){var n=t.selection,r=n.$from,o=n.$to,i=r.blockRange(o),s=i&&_t(i);return null!=s&&(e&&e(t.tr.lift(i,s).scrollIntoView()),!0)}function yi(t){for(var e=0;e<t.edgeCount;e++){var n=t.edge(e).type;if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}function wi(t,e){var n=t.selection,r=n.$head,o=n.$anchor;if(!r.parent.type.spec.code||!r.sameParent(o))return!1;var i=r.node(-1),s=r.indexAfter(-1),a=yi(i.contentMatchAt(s));if(!i.canReplaceWith(s,s,a))return!1;if(e){var c=r.after(),l=t.tr.replaceWith(c,c,a.createAndFill());l.setSelection(he.near(l.doc.resolve(c),1)),e(l.scrollIntoView())}return!0}function bi(t,e){var n,r=t.selection,o=r.$from,i=r.to,s=o.sharedDepth(i);return 0!=s&&(n=o.before(s),e&&e(t.tr.setSelection(me.create(t.doc,n))),!0)}function xi(t,e,n){var r,i,s=e.nodeBefore,a=e.nodeAfter;if(s.type.spec.isolating||a.type.spec.isolating)return!1;if(function(t,e,n){var r=e.nodeBefore,o=e.nodeAfter,i=e.index();return!(!(r&&o&&r.type.compatibleContent(o.type))||(!r.content.size&&e.parent.canReplace(i-1,i)?(n&&n(t.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),0):!e.parent.canReplace(i,i+1)||!o.isTextblock&&!Kt(t.doc,e.pos)||(n&&n(t.tr.clearIncompatible(e.pos,r.type,r.contentMatchAt(r.childCount)).join(e.pos).scrollIntoView()),0)))}(t,e,n))return!0;var c=e.parent.canReplace(e.index(),e.index()+1);if(c&&(r=(i=s.contentMatchAt(s.childCount)).findWrapping(a.type))&&i.matchType(r[0]||a.type).validEnd){if(n){for(var l=e.pos+a.nodeSize,h=o.empty,f=r.length-1;f>=0;f--)h=o.from(r[f].create(null,h));h=o.from(s.copy(h));var d=t.tr.step(new qt(e.pos-1,l,e.pos,l,new p(h,1,0),r.length,!0)),u=l+2*r.length;Kt(d.doc,u)&&d.join(u),n(d.scrollIntoView())}return!0}var m=he.findFrom(e,1),v=m&&m.$from.blockRange(m.$to),g=v&&_t(v);if(null!=g&&g>=e.depth)return n&&n(t.tr.lift(v,g).scrollIntoView()),!0;if(c&&fi(a,"start",!0)&&fi(s,"end")){for(var y=s,w=[];w.push(y),!y.isTextblock;)y=y.lastChild;for(var b=a,x=1;!b.isTextblock;b=b.firstChild)x++;if(y.canReplace(y.childCount,y.childCount,b.content)){if(n){for(var k=o.empty,S=w.length-1;S>=0;S--)k=o.from(w[S].copy(k));n(t.tr.step(new qt(e.pos-w.length,e.pos+a.nodeSize,e.pos+x,e.pos+a.nodeSize-x,new p(k,w.length,0),0,!0)).scrollIntoView())}return!0}}return!1}function ki(t,e){return function(n,r){var o=n.selection,i=o.$from,s=o.$to,a=i.blockRange(s),c=a&&jt(a,t,e);return!!c&&(r&&r(n.tr.wrap(a,c).scrollIntoView()),!0)}}function Si(t,e){return function(n,r){var o=n.selection,i=o.from,s=o.to,a=!1;return n.doc.nodesBetween(i,s,(function(r,o){if(a)return!1;if(r.isTextblock&&!r.hasMarkup(t,e))if(r.type==t)a=!0;else{var i=n.doc.resolve(o),s=i.index();a=i.parent.canReplaceWith(s,s+1,t)}})),!!a&&(r&&r(n.tr.setBlockType(i,s,t,e).scrollIntoView()),!0)}}function Ci(t,e){return function(n,r){var o=n.selection,i=o.empty,s=o.$cursor,a=o.ranges;if(i&&!s||!function(t,e,n){for(var r=function(r){var o=e[r],i=o.$from,s=o.$to,a=0==i.depth&&t.type.allowsMarkType(n);if(t.nodesBetween(i.pos,s.pos,(function(t){if(a)return!1;a=t.inlineContent&&t.type.allowsMarkType(n)})),a)return{v:!0}},o=0;o<e.length;o++){var i=r(o);if(i)return i.v}return!1}(n.doc,a,t))return!1;if(r)if(s)t.isInSet(n.storedMarks||s.marks())?r(n.tr.removeStoredMark(t)):r(n.tr.addStoredMark(t.create(e)));else{for(var c=!1,l=n.tr,h=0;!c&&h<a.length;h++){var p=a[h],f=p.$from,d=p.$to;c=n.doc.rangeHasMark(f.pos,d.pos,t)}for(var u=0;u<a.length;u++){var m=a[u],v=m.$from,g=m.$to;if(c)l.removeMark(v.pos,g.pos,t);else{var y=v.pos,w=g.pos,b=v.nodeAfter,x=g.nodeBefore,k=b&&b.isText?/^\s*/.exec(b.text)[0].length:0,S=x&&x.isText?/\s*$/.exec(x.text)[0].length:0;y+k<w&&(y+=k,w-=S),l.addMark(y,w,t.create(e))}}r(l.scrollIntoView())}return!0}}function Mi(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];return function(e,n,r){for(var o=0;o<t.length;o++)if(t[o](e,n,r))return!0;return!1}}var Oi=Mi(pi,(function(t,e,n){var r=t.selection.$cursor;if(!r||(n?!n.endOfTextblock("backward",t):r.parentOffset>0))return!1;var o=di(r);if(!o){var i=r.blockRange(),s=i&&_t(i);return null!=s&&(e&&e(t.tr.lift(i,s).scrollIntoView()),!0)}var a=o.nodeBefore;if(!a.type.spec.isolating&&xi(t,o,e))return!0;if(0==r.parent.content.size&&(fi(a,"end")||me.isSelectable(a))){if(e){var c=t.tr.deleteRange(r.before(),r.after());c.setSelection(fi(a,"end")?he.findFrom(c.doc.resolve(c.mapping.map(o.pos,-1)),-1):me.create(c.doc,o.pos-a.nodeSize)),e(c.scrollIntoView())}return!0}return!(!a.isAtom||o.depth!=r.depth-1||(e&&e(t.tr.delete(o.pos-a.nodeSize,o.pos).scrollIntoView()),0))}),(function(t,e,n){var r=t.selection,o=r.$head,i=o;if(!r.empty)return!1;if(o.parent.isTextblock){if(n?!n.endOfTextblock("backward",t):o.parentOffset>0)return!1;i=di(o)}var s=i&&i.nodeBefore;return!(!s||!me.isSelectable(s)||(e&&e(t.tr.setSelection(me.create(t.doc,i.pos-s.nodeSize)).scrollIntoView()),0))})),Ni=Mi(pi,(function(t,e,n){var r=t.selection.$cursor;if(!r||(n?!n.endOfTextblock("forward",t):r.parentOffset<r.parent.content.size))return!1;var o=ui(r);if(!o)return!1;var i=o.nodeAfter;if(xi(t,o,e))return!0;if(0==r.parent.content.size&&(fi(i,"start")||me.isSelectable(i))){if(e){var s=t.tr.deleteRange(r.before(),r.after());s.setSelection(fi(i,"start")?he.findFrom(s.doc.resolve(s.mapping.map(o.pos)),1):me.create(s.doc,s.mapping.map(o.pos))),e(s.scrollIntoView())}return!0}return!(!i.isAtom||o.depth!=r.depth-1||(e&&e(t.tr.delete(o.pos,o.pos+i.nodeSize).scrollIntoView()),0))}),(function(t,e,n){var r=t.selection,o=r.$head,i=o;if(!r.empty)return!1;if(o.parent.isTextblock){if(n?!n.endOfTextblock("forward",t):o.parentOffset<o.parent.content.size)return!1;i=ui(o)}var s=i&&i.nodeAfter;return!(!s||!me.isSelectable(s)||(e&&e(t.tr.setSelection(me.create(t.doc,i.pos)).scrollIntoView()),0))})),Di={Enter:Mi((function(t,e){var n=t.selection,r=n.$head,o=n.$anchor;return!(!r.parent.type.spec.code||!r.sameParent(o)||(e&&e(t.tr.insertText("\n").scrollIntoView()),0))}),(function(t,e){var n=t.selection,r=n.$from,o=n.$to;if(n instanceof ge||r.parent.inlineContent||o.parent.inlineContent)return!1;var i=yi(o.parent.contentMatchAt(o.indexAfter()));if(!i||!i.isTextblock)return!1;if(e){var s=(!r.parentOffset&&o.index()<o.parent.childCount?r:o).pos,a=t.tr.insert(s,i.createAndFill());a.setSelection(de.create(a.doc,s+1)),e(a.scrollIntoView())}return!0}),(function(t,e){var n=t.selection.$cursor;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){var r=n.before();if(Jt(t.doc,r))return e&&e(t.tr.split(r).scrollIntoView()),!0}var o=n.blockRange(),i=o&&_t(o);return null!=i&&(e&&e(t.tr.lift(o,i).scrollIntoView()),!0)}),(function(t,e){var n=t.selection,r=n.$from,o=n.$to;if(t.selection instanceof me&&t.selection.node.isBlock)return!(!r.parentOffset||!Jt(t.doc,r.pos)||(e&&e(t.tr.split(r.pos).scrollIntoView()),0));if(!r.parent.isBlock)return!1;if(e){var i=o.parentOffset==o.parent.content.size,s=t.tr;(t.selection instanceof de||t.selection instanceof ge)&&s.deleteSelection();var a=0==r.depth?null:yi(r.node(-1).contentMatchAt(r.indexAfter(-1))),c=i&&a?[{type:a}]:null,l=Jt(s.doc,s.mapping.map(r.pos),1,c);if(c||l||!Jt(s.doc,s.mapping.map(r.pos),1,a&&[{type:a}])||(c=[{type:a}],l=!0),l&&(s.split(s.mapping.map(r.pos),1,c),!i&&!r.parentOffset&&r.parent.type!=a)){var h=s.mapping.map(r.before()),p=s.doc.resolve(h);r.node(-1).canReplaceWith(p.index(),p.index()+1,a)&&s.setNodeMarkup(s.mapping.map(r.before()),a)}e(s.scrollIntoView())}return!0})),"Mod-Enter":wi,Backspace:Oi,"Mod-Backspace":Oi,Delete:Ni,"Mod-Delete":Ni,"Mod-a":function(t,e){return e&&e(t.tr.setSelection(new ge(t.doc))),!0}},Ti={"Ctrl-h":Di.Backspace,"Alt-Backspace":Di["Mod-Backspace"],"Ctrl-d":Di.Delete,"Ctrl-Alt-Backspace":Di["Mod-Delete"],"Alt-Delete":Di["Mod-Delete"],"Alt-d":Di["Mod-Delete"]};for(var Ei in Di)Ti[Ei]=Di[Ei];var Ai=("undefined"!=typeof navigator?/Mac/.test(navigator.platform):"undefined"!=typeof os&&"darwin"==os.platform())?Ti:Di;var Pi=function(t,e){var n=this;this.editorView=t,this.width=e.width||1,this.color=e.color||"black",this.class=e.class,this.cursorPos=null,this.element=null,this.timeout=null,this.handlers=["dragover","dragend","drop","dragleave"].map((function(e){var r=function(t){return n[e](t)};return t.dom.addEventListener(e,r),{name:e,handler:r}}))};function zi(t,e,n){for(var r=0;;r++){if(r==t.childCount||r==e.childCount)return t.childCount==e.childCount?null:n;var o=t.child(r),i=e.child(r);if(o!=i){if(!o.sameMarkup(i))return n;if(o.isText&&o.text!=i.text){for(var s=0;o.text[s]==i.text[s];s++)n++;return n}if(o.content.size||i.content.size){var a=zi(o.content,i.content,n+1);if(null!=a)return a}n+=o.nodeSize}else n+=o.nodeSize}}function Ii(t,e,n,r){for(var o=t.childCount,i=e.childCount;;){if(0==o||0==i)return o==i?null:{a:n,b:r};var s=t.child(--o),a=e.child(--i),c=s.nodeSize;if(s!=a){if(!s.sameMarkup(a))return{a:n,b:r};if(s.isText&&s.text!=a.text){for(var l=0,h=Math.min(s.text.length,a.text.length);l<h&&s.text[s.text.length-l-1]==a.text[a.text.length-l-1];)l++,n--,r--;return{a:n,b:r}}if(s.content.size||a.content.size){var p=Ii(s.content,a.content,n-1,r-1);if(p)return p}n-=c,r-=c}else n-=c,r-=c}}Pi.prototype.destroy=function(){var t=this;this.handlers.forEach((function(e){var n=e.name,r=e.handler;return t.editorView.dom.removeEventListener(n,r)}))},Pi.prototype.update=function(t,e){null!=this.cursorPos&&e.doc!=t.state.doc&&(this.cursorPos>t.state.doc.content.size?this.setCursor(null):this.updateOverlay())},Pi.prototype.setCursor=function(t){t!=this.cursorPos&&(this.cursorPos=t,null==t?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())},Pi.prototype.updateOverlay=function(){var t,e=this.editorView.state.doc.resolve(this.cursorPos);if(!e.parent.inlineContent){var n=e.nodeBefore,r=e.nodeAfter;if(n||r){var o=this.editorView.nodeDOM(this.cursorPos-(n?n.nodeSize:0)).getBoundingClientRect(),i=n?o.bottom:o.top;n&&r&&(i=(i+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2),t={left:o.left,right:o.right,top:i-this.width/2,bottom:i+this.width/2}}}if(!t){var s=this.editorView.coordsAtPos(this.cursorPos);t={left:s.left-this.width/2,right:s.left+this.width/2,top:s.top,bottom:s.bottom}}var a,c,l=this.editorView.dom.offsetParent;if(this.element||(this.element=l.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none; background-color: "+this.color),!l||l==document.body&&"static"==getComputedStyle(l).position)a=-pageXOffset,c=-pageYOffset;else{var h=l.getBoundingClientRect();a=h.left-l.scrollLeft,c=h.top-l.scrollTop}this.element.style.left=t.left-a+"px",this.element.style.top=t.top-c+"px",this.element.style.width=t.right-t.left+"px",this.element.style.height=t.bottom-t.top+"px"},Pi.prototype.scheduleRemoval=function(t){var e=this;clearTimeout(this.timeout),this.timeout=setTimeout((function(){return e.setCursor(null)}),t)},Pi.prototype.dragover=function(t){if(this.editorView.editable){var e=this.editorView.posAtCoords({left:t.clientX,top:t.clientY});if(e){var n=e.pos;if(this.editorView.dragging&&this.editorView.dragging.slice&&null==(n=Gt(this.editorView.state.doc,n,this.editorView.dragging.slice)))return this.setCursor(null);this.setCursor(n),this.scheduleRemoval(5e3)}}},Pi.prototype.dragend=function(){this.scheduleRemoval(20)},Pi.prototype.drop=function(){this.scheduleRemoval(20)},Pi.prototype.dragleave=function(t){t.target!=this.editorView.dom&&this.editorView.dom.contains(t.relatedTarget)||this.setCursor(null)};var Ri=function(t,e){if(this.content=t,this.size=e||0,null==e)for(var n=0;n<t.length;n++)this.size+=t[n].nodeSize},Bi={firstChild:{configurable:!0},lastChild:{configurable:!0},childCount:{configurable:!0}};Ri.prototype.nodesBetween=function(t,e,n,r,o){void 0===r&&(r=0);for(var i=0,s=0;s<e;i++){var a=this.content[i],c=s+a.nodeSize;if(c>t&&!1!==n(a,r+s,o,i)&&a.content.size){var l=s+1;a.nodesBetween(Math.max(0,t-l),Math.min(a.content.size,e-l),n,r+l)}s=c}},Ri.prototype.descendants=function(t){this.nodesBetween(0,this.size,t)},Ri.prototype.textBetween=function(t,e,n,r){var o="",i=!0;return this.nodesBetween(t,e,(function(s,a){s.isText?(o+=s.text.slice(Math.max(t,a)-a,e-a),i=!n):s.isLeaf&&r?(o+=r,i=!n):!i&&s.isBlock&&(o+=n,i=!0)}),0),o},Ri.prototype.append=function(t){if(!t.size)return this;if(!this.size)return t;var e=this.lastChild,n=t.firstChild,r=this.content.slice(),o=0;for(e.isText&&e.sameMarkup(n)&&(r[r.length-1]=e.withText(e.text+n.text),o=1);o<t.content.length;o++)r.push(t.content[o]);return new Ri(r,this.size+t.size)},Ri.prototype.cut=function(t,e){if(null==e&&(e=this.size),0==t&&e==this.size)return this;var n=[],r=0;if(e>t)for(var o=0,i=0;i<e;o++){var s=this.content[o],a=i+s.nodeSize;a>t&&((i<t||a>e)&&(s=s.isText?s.cut(Math.max(0,t-i),Math.min(s.text.length,e-i)):s.cut(Math.max(0,t-i-1),Math.min(s.content.size,e-i-1))),n.push(s),r+=s.nodeSize),i=a}return new Ri(n,r)},Ri.prototype.cutByIndex=function(t,e){return t==e?Ri.empty:0==t&&e==this.content.length?this:new Ri(this.content.slice(t,e))},Ri.prototype.replaceChild=function(t,e){var n=this.content[t];if(n==e)return this;var r=this.content.slice(),o=this.size+e.nodeSize-n.nodeSize;return r[t]=e,new Ri(r,o)},Ri.prototype.addToStart=function(t){return new Ri([t].concat(this.content),this.size+t.nodeSize)},Ri.prototype.addToEnd=function(t){return new Ri(this.content.concat(t),this.size+t.nodeSize)},Ri.prototype.eq=function(t){if(this.content.length!=t.content.length)return!1;for(var e=0;e<this.content.length;e++)if(!this.content[e].eq(t.content[e]))return!1;return!0},Bi.firstChild.get=function(){return this.content.length?this.content[0]:null},Bi.lastChild.get=function(){return this.content.length?this.content[this.content.length-1]:null},Bi.childCount.get=function(){return this.content.length},Ri.prototype.child=function(t){var e=this.content[t];if(!e)throw new RangeError("Index "+t+" out of range for "+this);return e},Ri.prototype.maybeChild=function(t){return this.content[t]},Ri.prototype.forEach=function(t){for(var e=0,n=0;e<this.content.length;e++){var r=this.content[e];t(r,n,e),n+=r.nodeSize}},Ri.prototype.findDiffStart=function(t,e){return void 0===e&&(e=0),zi(this,t,e)},Ri.prototype.findDiffEnd=function(t,e,n){return void 0===e&&(e=this.size),void 0===n&&(n=t.size),Ii(this,t,e,n)},Ri.prototype.findIndex=function(t,e){if(void 0===e&&(e=-1),0==t)return Fi(0,t);if(t==this.size)return Fi(this.content.length,t);if(t>this.size||t<0)throw new RangeError("Position "+t+" outside of fragment ("+this+")");for(var n=0,r=0;;n++){var o=r+this.child(n).nodeSize;if(o>=t)return o==t||e>0?Fi(n+1,o):Fi(n,r);r=o}},Ri.prototype.toString=function(){return"<"+this.toStringInner()+">"},Ri.prototype.toStringInner=function(){return this.content.join(", ")},Ri.prototype.toJSON=function(){return this.content.length?this.content.map((function(t){return t.toJSON()})):null},Ri.fromJSON=function(t,e){if(!e)return Ri.empty;if(!Array.isArray(e))throw new RangeError("Invalid input for Fragment.fromJSON");return new Ri(e.map(t.nodeFromJSON))},Ri.fromArray=function(t){if(!t.length)return Ri.empty;for(var e,n=0,r=0;r<t.length;r++){var o=t[r];n+=o.nodeSize,r&&o.isText&&t[r-1].sameMarkup(o)?(e||(e=t.slice(0,r)),e[e.length-1]=o.withText(e[e.length-1].text+o.text)):e&&e.push(o)}return new Ri(e||t,n)},Ri.from=function(t){if(!t)return Ri.empty;if(t instanceof Ri)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new Ri([t],t.nodeSize);throw new RangeError("Can not convert "+t+" to a Fragment"+(t.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))},Object.defineProperties(Ri.prototype,Bi);var Vi={index:0,offset:0};function Fi(t,e){return Vi.index=t,Vi.offset=e,Vi}function qi(t,e){if(t===e)return!0;if(!t||"object"!=typeof t||!e||"object"!=typeof e)return!1;var n=Array.isArray(t);if(Array.isArray(e)!=n)return!1;if(n){if(t.length!=e.length)return!1;for(var r=0;r<t.length;r++)if(!qi(t[r],e[r]))return!1}else{for(var o in t)if(!(o in e)||!qi(t[o],e[o]))return!1;for(var i in e)if(!(i in t))return!1}return!0}Ri.empty=new Ri([],0);var $i=function(t,e){this.type=t,this.attrs=e};function Li(t){var e=Error.call(this,t);return e.__proto__=Li.prototype,e}$i.prototype.addToSet=function(t){for(var e,n=!1,r=0;r<t.length;r++){var o=t[r];if(this.eq(o))return t;if(this.type.excludes(o.type))e||(e=t.slice(0,r));else{if(o.type.excludes(this.type))return t;!n&&o.type.rank>this.type.rank&&(e||(e=t.slice(0,r)),e.push(this),n=!0),e&&e.push(o)}}return e||(e=t.slice()),n||e.push(this),e},$i.prototype.removeFromSet=function(t){for(var e=0;e<t.length;e++)if(this.eq(t[e]))return t.slice(0,e).concat(t.slice(e+1));return t},$i.prototype.isInSet=function(t){for(var e=0;e<t.length;e++)if(this.eq(t[e]))return!0;return!1},$i.prototype.eq=function(t){return this==t||this.type==t.type&&qi(this.attrs,t.attrs)},$i.prototype.toJSON=function(){var t={type:this.type.name};for(var e in this.attrs){t.attrs=this.attrs;break}return t},$i.fromJSON=function(t,e){if(!e)throw new RangeError("Invalid input for Mark.fromJSON");var n=t.marks[e.type];if(!n)throw new RangeError("There is no mark type "+e.type+" in this schema");return n.create(e.attrs)},$i.sameSet=function(t,e){if(t==e)return!0;if(t.length!=e.length)return!1;for(var n=0;n<t.length;n++)if(!t[n].eq(e[n]))return!1;return!0},$i.setFrom=function(t){if(!t||0==t.length)return $i.none;if(t instanceof $i)return[t];var e=t.slice();return e.sort((function(t,e){return t.type.rank-e.type.rank})),e},$i.none=[],Li.prototype=Object.create(Error.prototype),Li.prototype.constructor=Li,Li.prototype.name="ReplaceError";var _i=function(t,e,n){this.content=t,this.openStart=e,this.openEnd=n},ji={size:{configurable:!0}};function Wi(t,e,n){var r=t.findIndex(e),o=r.index,i=r.offset,s=t.maybeChild(o),a=t.findIndex(n),c=a.index,l=a.offset;if(i==e||s.isText){if(l!=n&&!t.child(c).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(o!=c)throw new RangeError("Removing non-flat range");return t.replaceChild(o,s.copy(Wi(s.content,e-i-1,n-i-1)))}function Ji(t,e,n,r){var o=t.findIndex(e),i=o.index,s=o.offset,a=t.maybeChild(i);if(s==e||a.isText)return r&&!r.canReplace(i,i,n)?null:t.cut(0,e).append(n).append(t.cut(e));var c=Ji(a.content,e-s-1,n);return c&&t.replaceChild(i,a.copy(c))}function Ki(t,e,n){if(n.openStart>t.depth)throw new Li("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new Li("Inconsistent open depths");return Hi(t,e,n,0)}function Hi(t,e,n,r){var o=t.index(r),i=t.node(r);if(o==e.index(r)&&r<t.depth-n.openStart){var s=Hi(t,e,n,r+1);return i.copy(i.content.replaceChild(o,s))}if(n.content.size){if(n.openStart||n.openEnd||t.depth!=r||e.depth!=r){var a=function(t,e){for(var n=e.depth-t.openStart,r=e.node(n).copy(t.content),o=n-1;o>=0;o--)r=e.node(o).copy(Ri.from(r));return{start:r.resolveNoCache(t.openStart+n),end:r.resolveNoCache(r.content.size-t.openEnd-n)}}(n,t);return Qi(i,Zi(t,a.start,a.end,e,r))}var c=t.parent,l=c.content;return Qi(c,l.cut(0,t.parentOffset).append(n.content).append(l.cut(e.parentOffset)))}return Qi(i,ts(t,e,r))}function Ui(t,e){if(!e.type.compatibleContent(t.type))throw new Li("Cannot join "+e.type.name+" onto "+t.type.name)}function Gi(t,e,n){var r=t.node(n);return Ui(r,e.node(n)),r}function Xi(t,e){var n=e.length-1;n>=0&&t.isText&&t.sameMarkup(e[n])?e[n]=t.withText(e[n].text+t.text):e.push(t)}function Yi(t,e,n,r){var o=(e||t).node(n),i=0,s=e?e.index(n):o.childCount;t&&(i=t.index(n),t.depth>n?i++:t.textOffset&&(Xi(t.nodeAfter,r),i++));for(var a=i;a<s;a++)Xi(o.child(a),r);e&&e.depth==n&&e.textOffset&&Xi(e.nodeBefore,r)}function Qi(t,e){if(!t.type.validContent(e))throw new Li("Invalid content for node "+t.type.name);return t.copy(e)}function Zi(t,e,n,r,o){var i=t.depth>o&&Gi(t,e,o+1),s=r.depth>o&&Gi(n,r,o+1),a=[];return Yi(null,t,o,a),i&&s&&e.index(o)==n.index(o)?(Ui(i,s),Xi(Qi(i,Zi(t,e,n,r,o+1)),a)):(i&&Xi(Qi(i,ts(t,e,o+1)),a),Yi(e,n,o,a),s&&Xi(Qi(s,ts(n,r,o+1)),a)),Yi(r,null,o,a),new Ri(a)}function ts(t,e,n){var r=[];return Yi(null,t,n,r),t.depth>n&&Xi(Qi(Gi(t,e,n+1),ts(t,e,n+1)),r),Yi(e,null,n,r),new Ri(r)}ji.size.get=function(){return this.content.size-this.openStart-this.openEnd},_i.prototype.insertAt=function(t,e){var n=Ji(this.content,t+this.openStart,e,null);return n&&new _i(n,this.openStart,this.openEnd)},_i.prototype.removeBetween=function(t,e){return new _i(Wi(this.content,t+this.openStart,e+this.openStart),this.openStart,this.openEnd)},_i.prototype.eq=function(t){return this.content.eq(t.content)&&this.openStart==t.openStart&&this.openEnd==t.openEnd},_i.prototype.toString=function(){return this.content+"("+this.openStart+","+this.openEnd+")"},_i.prototype.toJSON=function(){if(!this.content.size)return null;var t={content:this.content.toJSON()};return this.openStart>0&&(t.openStart=this.openStart),this.openEnd>0&&(t.openEnd=this.openEnd),t},_i.fromJSON=function(t,e){if(!e)return _i.empty;var n=e.openStart||0,r=e.openEnd||0;if("number"!=typeof n||"number"!=typeof r)throw new RangeError("Invalid input for Slice.fromJSON");return new _i(Ri.fromJSON(t,e.content),n,r)},_i.maxOpen=function(t,e){void 0===e&&(e=!0);for(var n=0,r=0,o=t.firstChild;o&&!o.isLeaf&&(e||!o.type.spec.isolating);o=o.firstChild)n++;for(var i=t.lastChild;i&&!i.isLeaf&&(e||!i.type.spec.isolating);i=i.lastChild)r++;return new _i(t,n,r)},Object.defineProperties(_i.prototype,ji),_i.empty=new _i(Ri.empty,0,0);var es=function(t,e,n){this.pos=t,this.path=e,this.depth=e.length/3-1,this.parentOffset=n},ns={parent:{configurable:!0},doc:{configurable:!0},textOffset:{configurable:!0},nodeAfter:{configurable:!0},nodeBefore:{configurable:!0}};es.prototype.resolveDepth=function(t){return null==t?this.depth:t<0?this.depth+t:t},ns.parent.get=function(){return this.node(this.depth)},ns.doc.get=function(){return this.node(0)},es.prototype.node=function(t){return this.path[3*this.resolveDepth(t)]},es.prototype.index=function(t){return this.path[3*this.resolveDepth(t)+1]},es.prototype.indexAfter=function(t){return t=this.resolveDepth(t),this.index(t)+(t!=this.depth||this.textOffset?1:0)},es.prototype.start=function(t){return 0==(t=this.resolveDepth(t))?0:this.path[3*t-1]+1},es.prototype.end=function(t){return t=this.resolveDepth(t),this.start(t)+this.node(t).content.size},es.prototype.before=function(t){if(!(t=this.resolveDepth(t)))throw new RangeError("There is no position before the top-level node");return t==this.depth+1?this.pos:this.path[3*t-1]},es.prototype.after=function(t){if(!(t=this.resolveDepth(t)))throw new RangeError("There is no position after the top-level node");return t==this.depth+1?this.pos:this.path[3*t-1]+this.path[3*t].nodeSize},ns.textOffset.get=function(){return this.pos-this.path[this.path.length-1]},ns.nodeAfter.get=function(){var t=this.parent,e=this.index(this.depth);if(e==t.childCount)return null;var n=this.pos-this.path[this.path.length-1],r=t.child(e);return n?t.child(e).cut(n):r},ns.nodeBefore.get=function(){var t=this.index(this.depth),e=this.pos-this.path[this.path.length-1];return e?this.parent.child(t).cut(0,e):0==t?null:this.parent.child(t-1)},es.prototype.posAtIndex=function(t,e){e=this.resolveDepth(e);for(var n=this.path[3*e],r=0==e?0:this.path[3*e-1]+1,o=0;o<t;o++)r+=n.child(o).nodeSize;return r},es.prototype.marks=function(){var t=this.parent,e=this.index();if(0==t.content.size)return $i.none;if(this.textOffset)return t.child(e).marks;var n=t.maybeChild(e-1),r=t.maybeChild(e);if(!n){var o=n;n=r,r=o}for(var i=n.marks,s=0;s<i.length;s++)!1!==i[s].type.spec.inclusive||r&&i[s].isInSet(r.marks)||(i=i[s--].removeFromSet(i));return i},es.prototype.marksAcross=function(t){var e=this.parent.maybeChild(this.index());if(!e||!e.isInline)return null;for(var n=e.marks,r=t.parent.maybeChild(t.index()),o=0;o<n.length;o++)!1!==n[o].type.spec.inclusive||r&&n[o].isInSet(r.marks)||(n=n[o--].removeFromSet(n));return n},es.prototype.sharedDepth=function(t){for(var e=this.depth;e>0;e--)if(this.start(e)<=t&&this.end(e)>=t)return e;return 0},es.prototype.blockRange=function(t,e){if(void 0===t&&(t=this),t.pos<this.pos)return t.blockRange(this);for(var n=this.depth-(this.parent.inlineContent||this.pos==t.pos?1:0);n>=0;n--)if(t.pos<=this.end(n)&&(!e||e(this.node(n))))return new as(this,t,n)},es.prototype.sameParent=function(t){return this.pos-this.parentOffset==t.pos-t.parentOffset},es.prototype.max=function(t){return t.pos>this.pos?t:this},es.prototype.min=function(t){return t.pos<this.pos?t:this},es.prototype.toString=function(){for(var t="",e=1;e<=this.depth;e++)t+=(t?"/":"")+this.node(e).type.name+"_"+this.index(e-1);return t+":"+this.parentOffset},es.resolve=function(t,e){if(!(e>=0&&e<=t.content.size))throw new RangeError("Position "+e+" out of range");for(var n=[],r=0,o=e,i=t;;){var s=i.content.findIndex(o),a=s.index,c=s.offset,l=o-c;if(n.push(i,a,r+c),!l)break;if((i=i.child(a)).isText)break;o=l-1,r+=c+1}return new es(e,n,o)},es.resolveCached=function(t,e){for(var n=0;n<rs.length;n++){var r=rs[n];if(r.pos==e&&r.doc==t)return r}var o=rs[is]=es.resolve(t,e);return is=(is+1)%ss,o},Object.defineProperties(es.prototype,ns);var rs=[],is=0,ss=12,as=function(t,e,n){this.$from=t,this.$to=e,this.depth=n},cs={start:{configurable:!0},end:{configurable:!0},parent:{configurable:!0},startIndex:{configurable:!0},endIndex:{configurable:!0}};cs.start.get=function(){return this.$from.before(this.depth+1)},cs.end.get=function(){return this.$to.after(this.depth+1)},cs.parent.get=function(){return this.$from.node(this.depth)},cs.startIndex.get=function(){return this.$from.index(this.depth)},cs.endIndex.get=function(){return this.$to.indexAfter(this.depth)},Object.defineProperties(as.prototype,cs);var ls=Object.create(null),hs=function(t,e,n,r){this.type=t,this.attrs=e,this.content=n||Ri.empty,this.marks=r||$i.none},ps={nodeSize:{configurable:!0},childCount:{configurable:!0},textContent:{configurable:!0},firstChild:{configurable:!0},lastChild:{configurable:!0},isBlock:{configurable:!0},isTextblock:{configurable:!0},inlineContent:{configurable:!0},isInline:{configurable:!0},isText:{configurable:!0},isLeaf:{configurable:!0},isAtom:{configurable:!0}};ps.nodeSize.get=function(){return this.isLeaf?1:2+this.content.size},ps.childCount.get=function(){return this.content.childCount},hs.prototype.child=function(t){return this.content.child(t)},hs.prototype.maybeChild=function(t){return this.content.maybeChild(t)},hs.prototype.forEach=function(t){this.content.forEach(t)},hs.prototype.nodesBetween=function(t,e,n,r){void 0===r&&(r=0),this.content.nodesBetween(t,e,n,r,this)},hs.prototype.descendants=function(t){this.nodesBetween(0,this.content.size,t)},ps.textContent.get=function(){return this.textBetween(0,this.content.size,"")},hs.prototype.textBetween=function(t,e,n,r){return this.content.textBetween(t,e,n,r)},ps.firstChild.get=function(){return this.content.firstChild},ps.lastChild.get=function(){return this.content.lastChild},hs.prototype.eq=function(t){return this==t||this.sameMarkup(t)&&this.content.eq(t.content)},hs.prototype.sameMarkup=function(t){return this.hasMarkup(t.type,t.attrs,t.marks)},hs.prototype.hasMarkup=function(t,e,n){return this.type==t&&qi(this.attrs,e||t.defaultAttrs||ls)&&$i.sameSet(this.marks,n||$i.none)},hs.prototype.copy=function(t){return void 0===t&&(t=null),t==this.content?this:new this.constructor(this.type,this.attrs,t,this.marks)},hs.prototype.mark=function(t){return t==this.marks?this:new this.constructor(this.type,this.attrs,this.content,t)},hs.prototype.cut=function(t,e){return 0==t&&e==this.content.size?this:this.copy(this.content.cut(t,e))},hs.prototype.slice=function(t,e,n){if(void 0===e&&(e=this.content.size),void 0===n&&(n=!1),t==e)return _i.empty;var r=this.resolve(t),o=this.resolve(e),i=n?0:r.sharedDepth(e),s=r.start(i),a=r.node(i).content.cut(r.pos-s,o.pos-s);return new _i(a,r.depth-i,o.depth-i)},hs.prototype.replace=function(t,e,n){return Ki(this.resolve(t),this.resolve(e),n)},hs.prototype.nodeAt=function(t){for(var e=this;;){var n=e.content.findIndex(t),r=n.index,o=n.offset;if(!(e=e.maybeChild(r)))return null;if(o==t||e.isText)return e;t-=o+1}},hs.prototype.childAfter=function(t){var e=this.content.findIndex(t),n=e.index,r=e.offset;return{node:this.content.maybeChild(n),index:n,offset:r}},hs.prototype.childBefore=function(t){if(0==t)return{node:null,index:0,offset:0};var e=this.content.findIndex(t),n=e.index,r=e.offset;if(r<t)return{node:this.content.child(n),index:n,offset:r};var o=this.content.child(n-1);return{node:o,index:n-1,offset:r-o.nodeSize}},hs.prototype.resolve=function(t){return es.resolveCached(this,t)},hs.prototype.resolveNoCache=function(t){return es.resolve(this,t)},hs.prototype.rangeHasMark=function(t,e,n){var r=!1;return e>t&&this.nodesBetween(t,e,(function(t){return n.isInSet(t.marks)&&(r=!0),!r})),r},ps.isBlock.get=function(){return this.type.isBlock},ps.isTextblock.get=function(){return this.type.isTextblock},ps.inlineContent.get=function(){return this.type.inlineContent},ps.isInline.get=function(){return this.type.isInline},ps.isText.get=function(){return this.type.isText},ps.isLeaf.get=function(){return this.type.isLeaf},ps.isAtom.get=function(){return this.type.isAtom},hs.prototype.toString=function(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);var t=this.type.name;return this.content.size&&(t+="("+this.content.toStringInner()+")"),ds(this.marks,t)},hs.prototype.contentMatchAt=function(t){var e=this.type.contentMatch.matchFragment(this.content,0,t);if(!e)throw new Error("Called contentMatchAt on a node with invalid content");return e},hs.prototype.canReplace=function(t,e,n,r,o){void 0===n&&(n=Ri.empty),void 0===r&&(r=0),void 0===o&&(o=n.childCount);var i=this.contentMatchAt(t).matchFragment(n,r,o),s=i&&i.matchFragment(this.content,e);if(!s||!s.validEnd)return!1;for(var a=r;a<o;a++)if(!this.type.allowsMarks(n.child(a).marks))return!1;return!0},hs.prototype.canReplaceWith=function(t,e,n,r){if(r&&!this.type.allowsMarks(r))return!1;var o=this.contentMatchAt(t).matchType(n),i=o&&o.matchFragment(this.content,e);return!!i&&i.validEnd},hs.prototype.canAppend=function(t){return t.content.size?this.canReplace(this.childCount,this.childCount,t.content):this.type.compatibleContent(t.type)},hs.prototype.check=function(){if(!this.type.validContent(this.content))throw new RangeError("Invalid content for node "+this.type.name+": "+this.content.toString().slice(0,50));for(var t=$i.none,e=0;e<this.marks.length;e++)t=this.marks[e].addToSet(t);if(!$i.sameSet(t,this.marks))throw new RangeError("Invalid collection of marks for node "+this.type.name+": "+this.marks.map((function(t){return t.type.name})));this.content.forEach((function(t){return t.check()}))},hs.prototype.toJSON=function(){var t={type:this.type.name};for(var e in this.attrs){t.attrs=this.attrs;break}return this.content.size&&(t.content=this.content.toJSON()),this.marks.length&&(t.marks=this.marks.map((function(t){return t.toJSON()}))),t},hs.fromJSON=function(t,e){if(!e)throw new RangeError("Invalid input for Node.fromJSON");var n=null;if(e.marks){if(!Array.isArray(e.marks))throw new RangeError("Invalid mark data for Node.fromJSON");n=e.marks.map(t.markFromJSON)}if("text"==e.type){if("string"!=typeof e.text)throw new RangeError("Invalid text node in JSON");return t.text(e.text,n)}var r=Ri.fromJSON(t,e.content);return t.nodeType(e.type).create(e.attrs,r,n)},Object.defineProperties(hs.prototype,ps);var fs=function(t){function e(e,n,r,o){if(t.call(this,e,n,null,o),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={textContent:{configurable:!0},nodeSize:{configurable:!0}};return e.prototype.toString=function(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):ds(this.marks,JSON.stringify(this.text))},n.textContent.get=function(){return this.text},e.prototype.textBetween=function(t,e){return this.text.slice(t,e)},n.nodeSize.get=function(){return this.text.length},e.prototype.mark=function(t){return t==this.marks?this:new e(this.type,this.attrs,this.text,t)},e.prototype.withText=function(t){return t==this.text?this:new e(this.type,this.attrs,t,this.marks)},e.prototype.cut=function(t,e){return void 0===t&&(t=0),void 0===e&&(e=this.text.length),0==t&&e==this.text.length?this:this.withText(this.text.slice(t,e))},e.prototype.eq=function(t){return this.sameMarkup(t)&&this.text==t.text},e.prototype.toJSON=function(){var e=t.prototype.toJSON.call(this);return e.text=this.text,e},Object.defineProperties(e.prototype,n),e}(hs);function ds(t,e){for(var n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}var us=function(t){this.validEnd=t,this.next=[],this.wrapCache=[]},ms={inlineContent:{configurable:!0},defaultType:{configurable:!0},edgeCount:{configurable:!0}};us.parse=function(t,e){var n=new vs(t,e);if(null==n.next)return us.empty;var r=ys(n);n.next&&n.err("Unexpected trailing text");var o,i,s=(o=function(t){var e=[[]];return o(function t(e,i){if("choice"==e.type)return e.exprs.reduce((function(e,n){return e.concat(t(n,i))}),[]);if("seq"==e.type)for(var s=0;;s++){var a=t(e.exprs[s],i);if(s==e.exprs.length-1)return a;o(a,i=n())}else{if("star"==e.type){var c=n();return r(i,c),o(t(e.expr,c),c),[r(c)]}if("plus"==e.type){var l=n();return o(t(e.expr,i),l),o(t(e.expr,l),l),[r(l)]}if("opt"==e.type)return[r(i)].concat(t(e.expr,i));if("range"==e.type){for(var h=i,p=0;p<e.min;p++){var f=n();o(t(e.expr,h),f),h=f}if(-1==e.max)o(t(e.expr,h),h);else for(var d=e.min;d<e.max;d++){var u=n();r(h,u),o(t(e.expr,h),u),h=u}return[r(h)]}if("name"==e.type)return[r(i,null,e.value)]}}(t,0),n()),e;function n(){return e.push([])-1}function r(t,n,r){var o={term:r,to:n};return e[t].push(o),o}function o(t,e){t.forEach((function(t){return t.to=e}))}}(r),i=Object.create(null),function t(e){var n=[];e.forEach((function(t){o[t].forEach((function(t){var e=t.term,r=t.to;if(e){var i=n.indexOf(e),s=i>-1&&n[i+1];Cs(o,r).forEach((function(t){s||n.push(e,s=[]),-1==s.indexOf(t)&&s.push(t)}))}}))}));for(var r=i[e.join(",")]=new us(e.indexOf(o.length-1)>-1),s=0;s<n.length;s+=2){var a=n[s+1].sort(Ss);r.next.push(n[s],i[a.join(",")]||t(a))}return r}(Cs(o,0)));return function(t,e){for(var n=0,r=[t];n<r.length;n++){for(var o=r[n],i=!o.validEnd,s=[],a=0;a<o.next.length;a+=2){var c=o.next[a],l=o.next[a+1];s.push(c.name),!i||c.isText||c.hasRequiredAttrs()||(i=!1),-1==r.indexOf(l)&&r.push(l)}i&&e.err("Only non-generatable nodes ("+s.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}(s,n),s},us.prototype.matchType=function(t){for(var e=0;e<this.next.length;e+=2)if(this.next[e]==t)return this.next[e+1];return null},us.prototype.matchFragment=function(t,e,n){void 0===e&&(e=0),void 0===n&&(n=t.childCount);for(var r=this,o=e;r&&o<n;o++)r=r.matchType(t.child(o).type);return r},ms.inlineContent.get=function(){var t=this.next[0];return!!t&&t.isInline},ms.defaultType.get=function(){for(var t=0;t<this.next.length;t+=2){var e=this.next[t];if(!e.isText&&!e.hasRequiredAttrs())return e}},us.prototype.compatible=function(t){for(var e=0;e<this.next.length;e+=2)for(var n=0;n<t.next.length;n+=2)if(this.next[e]==t.next[n])return!0;return!1},us.prototype.fillBefore=function(t,e,n){void 0===e&&(e=!1),void 0===n&&(n=0);var r=[this];return function o(i,s){var a=i.matchFragment(t,n);if(a&&(!e||a.validEnd))return Ri.from(s.map((function(t){return t.createAndFill()})));for(var c=0;c<i.next.length;c+=2){var l=i.next[c],h=i.next[c+1];if(!l.isText&&!l.hasRequiredAttrs()&&-1==r.indexOf(h)){r.push(h);var p=o(h,s.concat(l));if(p)return p}}}(this,[])},us.prototype.findWrapping=function(t){for(var e=0;e<this.wrapCache.length;e+=2)if(this.wrapCache[e]==t)return this.wrapCache[e+1];var n=this.computeWrapping(t);return this.wrapCache.push(t,n),n},us.prototype.computeWrapping=function(t){for(var e=Object.create(null),n=[{match:this,type:null,via:null}];n.length;){var r=n.shift(),o=r.match;if(o.matchType(t)){for(var i=[],s=r;s.type;s=s.via)i.push(s.type);return i.reverse()}for(var a=0;a<o.next.length;a+=2){var c=o.next[a];c.isLeaf||c.hasRequiredAttrs()||c.name in e||r.type&&!o.next[a+1].validEnd||(n.push({match:c.contentMatch,type:c,via:r}),e[c.name]=!0)}}},ms.edgeCount.get=function(){return this.next.length>>1},us.prototype.edge=function(t){var e=t<<1;if(e>=this.next.length)throw new RangeError("There's no "+t+"th edge in this content match");return{type:this.next[e],next:this.next[e+1]}},us.prototype.toString=function(){var t=[];return function e(n){t.push(n);for(var r=1;r<n.next.length;r+=2)-1==t.indexOf(n.next[r])&&e(n.next[r])}(this),t.map((function(e,n){for(var r=n+(e.validEnd?"*":" ")+" ",o=0;o<e.next.length;o+=2)r+=(o?", ":"")+e.next[o].name+"->"+t.indexOf(e.next[o+1]);return r})).join("\n")},Object.defineProperties(us.prototype,ms),us.empty=new us(!0);var vs=function(t,e){this.string=t,this.nodeTypes=e,this.inline=null,this.pos=0,this.tokens=t.split(/\s*(?=\b|\W|$)/),""==this.tokens[this.tokens.length-1]&&this.tokens.pop(),""==this.tokens[0]&&this.tokens.shift()},gs={next:{configurable:!0}};function ys(t){var e=[];do{e.push(ws(t))}while(t.eat("|"));return 1==e.length?e[0]:{type:"choice",exprs:e}}function ws(t){var e=[];do{e.push(bs(t))}while(t.next&&")"!=t.next&&"|"!=t.next);return 1==e.length?e[0]:{type:"seq",exprs:e}}function bs(t){for(var e=function(t){if(t.eat("(")){var e=ys(t);return t.eat(")")||t.err("Missing closing paren"),e}if(!/\W/.test(t.next)){var n=function(t,e){var n=t.nodeTypes,r=n[e];if(r)return[r];var o=[];for(var i in n){var s=n[i];s.groups.indexOf(e)>-1&&o.push(s)}return 0==o.length&&t.err("No node type or group '"+e+"' found"),o}(t,t.next).map((function(e){return null==t.inline?t.inline=e.isInline:t.inline!=e.isInline&&t.err("Mixing inline and block content"),{type:"name",value:e}}));return t.pos++,1==n.length?n[0]:{type:"choice",exprs:n}}t.err("Unexpected token '"+t.next+"'")}(t);;)if(t.eat("+"))e={type:"plus",expr:e};else if(t.eat("*"))e={type:"star",expr:e};else if(t.eat("?"))e={type:"opt",expr:e};else{if(!t.eat("{"))break;e=ks(t,e)}return e}function xs(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");var e=Number(t.next);return t.pos++,e}function ks(t,e){var n=xs(t),r=n;return t.eat(",")&&(r="}"!=t.next?xs(t):-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function Ss(t,e){return e-t}function Cs(t,e){var n=[];return function e(r){var o=t[r];if(1==o.length&&!o[0].term)return e(o[0].to);n.push(r);for(var i=0;i<o.length;i++){var s=o[i],a=s.term,c=s.to;a||-1!=n.indexOf(c)||e(c)}}(e),n.sort(Ss)}function Ms(t){var e=Object.create(null);for(var n in t){var r=t[n];if(!r.hasDefault)return null;e[n]=r.default}return e}function Os(t,e){var n=Object.create(null);for(var r in t){var o=e&&e[r];if(void 0===o){var i=t[r];if(!i.hasDefault)throw new RangeError("No value supplied for attribute "+r);o=i.default}n[r]=o}return n}function Ns(t){var e=Object.create(null);if(t)for(var n in t)e[n]=new Es(t[n]);return e}gs.next.get=function(){return this.tokens[this.pos]},vs.prototype.eat=function(t){return this.next==t&&(this.pos++||!0)},vs.prototype.err=function(t){throw new SyntaxError(t+" (in content expression '"+this.string+"')")},Object.defineProperties(vs.prototype,gs);var Ds=function(t,e,n){this.name=t,this.schema=e,this.spec=n,this.groups=n.group?n.group.split(" "):[],this.attrs=Ns(n.attrs),this.defaultAttrs=Ms(this.attrs),this.contentMatch=null,this.markSet=null,this.inlineContent=null,this.isBlock=!(n.inline||"text"==t),this.isText="text"==t},Ts={isInline:{configurable:!0},isTextblock:{configurable:!0},isLeaf:{configurable:!0},isAtom:{configurable:!0}};Ts.isInline.get=function(){return!this.isBlock},Ts.isTextblock.get=function(){return this.isBlock&&this.inlineContent},Ts.isLeaf.get=function(){return this.contentMatch==us.empty},Ts.isAtom.get=function(){return this.isLeaf||this.spec.atom},Ds.prototype.hasRequiredAttrs=function(){for(var t in this.attrs)if(this.attrs[t].isRequired)return!0;return!1},Ds.prototype.compatibleContent=function(t){return this==t||this.contentMatch.compatible(t.contentMatch)},Ds.prototype.computeAttrs=function(t){return!t&&this.defaultAttrs?this.defaultAttrs:Os(this.attrs,t)},Ds.prototype.create=function(t,e,n){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new hs(this,this.computeAttrs(t),Ri.from(e),$i.setFrom(n))},Ds.prototype.createChecked=function(t,e,n){if(e=Ri.from(e),!this.validContent(e))throw new RangeError("Invalid content for node "+this.name);return new hs(this,this.computeAttrs(t),e,$i.setFrom(n))},Ds.prototype.createAndFill=function(t,e,n){if(t=this.computeAttrs(t),(e=Ri.from(e)).size){var r=this.contentMatch.fillBefore(e);if(!r)return null;e=r.append(e)}var o=this.contentMatch.matchFragment(e).fillBefore(Ri.empty,!0);return o?new hs(this,t,e.append(o),$i.setFrom(n)):null},Ds.prototype.validContent=function(t){var e=this.contentMatch.matchFragment(t);if(!e||!e.validEnd)return!1;for(var n=0;n<t.childCount;n++)if(!this.allowsMarks(t.child(n).marks))return!1;return!0},Ds.prototype.allowsMarkType=function(t){return null==this.markSet||this.markSet.indexOf(t)>-1},Ds.prototype.allowsMarks=function(t){if(null==this.markSet)return!0;for(var e=0;e<t.length;e++)if(!this.allowsMarkType(t[e].type))return!1;return!0},Ds.prototype.allowedMarks=function(t){if(null==this.markSet)return t;for(var e,n=0;n<t.length;n++)this.allowsMarkType(t[n].type)?e&&e.push(t[n]):e||(e=t.slice(0,n));return e?e.length?e:$i.empty:t},Ds.compile=function(t,e){var n=Object.create(null);t.forEach((function(t,r){return n[t]=new Ds(t,e,r)}));var r=e.spec.topNode||"doc";if(!n[r])throw new RangeError("Schema is missing its top node type ('"+r+"')");if(!n.text)throw new RangeError("Every schema needs a 'text' type");for(var o in n.text.attrs)throw new RangeError("The text node type should not have attributes");return n},Object.defineProperties(Ds.prototype,Ts);var Es=function(t){this.hasDefault=Object.prototype.hasOwnProperty.call(t,"default"),this.default=t.default},As={isRequired:{configurable:!0}};As.isRequired.get=function(){return!this.hasDefault},Object.defineProperties(Es.prototype,As);var Ps=function(t,e,n,r){this.name=t,this.schema=n,this.spec=r,this.attrs=Ns(r.attrs),this.rank=e,this.excluded=null;var o=Ms(this.attrs);this.instance=o&&new $i(this,o)};Ps.prototype.create=function(t){return!t&&this.instance?this.instance:new $i(this,Os(this.attrs,t))},Ps.compile=function(t,e){var n=Object.create(null),r=0;return t.forEach((function(t,o){return n[t]=new Ps(t,r++,e,o)})),n},Ps.prototype.removeFromSet=function(t){for(var e=0;e<t.length;e++)t[e].type==this&&(t=t.slice(0,e).concat(t.slice(e+1)),e--);return t},Ps.prototype.isInSet=function(t){for(var e=0;e<t.length;e++)if(t[e].type==this)return t[e]},Ps.prototype.excludes=function(t){return this.excluded.indexOf(t)>-1};var zs=function(t){for(var n in this.spec={},t)this.spec[n]=t[n];this.spec.nodes=e.from(t.nodes),this.spec.marks=e.from(t.marks),this.nodes=Ds.compile(this.spec.nodes,this),this.marks=Ps.compile(this.spec.marks,this);var r=Object.create(null);for(var o in this.nodes){if(o in this.marks)throw new RangeError(o+" can not be both a node and a mark");var i=this.nodes[o],s=i.spec.content||"",a=i.spec.marks;i.contentMatch=r[s]||(r[s]=us.parse(s,this.nodes)),i.inlineContent=i.contentMatch.inlineContent,i.markSet="_"==a?null:a?Is(this,a.split(" ")):""!=a&&i.inlineContent?null:[]}for(var c in this.marks){var l=this.marks[c],h=l.spec.excludes;l.excluded=null==h?[l]:""==h?[]:Is(this,h.split(" "))}this.nodeFromJSON=this.nodeFromJSON.bind(this),this.markFromJSON=this.markFromJSON.bind(this),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached=Object.create(null),this.cached.wrappings=Object.create(null)};function Is(t,e){for(var n=[],r=0;r<e.length;r++){var o=e[r],i=t.marks[o],s=i;if(i)n.push(i);else for(var a in t.marks){var c=t.marks[a];("_"==o||c.spec.group&&c.spec.group.split(" ").indexOf(o)>-1)&&n.push(s=c)}if(!s)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return n}zs.prototype.node=function(t,e,n,r){if("string"==typeof t)t=this.nodeType(t);else{if(!(t instanceof Ds))throw new RangeError("Invalid node type: "+t);if(t.schema!=this)throw new RangeError("Node type from different schema used ("+t.name+")")}return t.createChecked(e,n,r)},zs.prototype.text=function(t,e){var n=this.nodes.text;return new fs(n,n.defaultAttrs,t,$i.setFrom(e))},zs.prototype.mark=function(t,e){return"string"==typeof t&&(t=this.marks[t]),t.create(e)},zs.prototype.nodeFromJSON=function(t){return hs.fromJSON(this,t)},zs.prototype.markFromJSON=function(t){return $i.fromJSON(this,t)},zs.prototype.nodeType=function(t){var e=this.nodes[t];if(!e)throw new RangeError("Unknown node type: "+t);return e};var Rs=function(t,e){var n=this;this.schema=t,this.rules=e,this.tags=[],this.styles=[],e.forEach((function(t){t.tag?n.tags.push(t):t.style&&n.styles.push(t)})),this.normalizeLists=!this.tags.some((function(e){if(!/^(ul|ol)\b/.test(e.tag)||!e.node)return!1;var n=t.nodes[e.node];return n.contentMatch.matchType(n)}))};Rs.prototype.parse=function(t,e){void 0===e&&(e={});var n=new Ls(this,e,!1);return n.addAll(t,null,e.from,e.to),n.finish()},Rs.prototype.parseSlice=function(t,e){void 0===e&&(e={});var n=new Ls(this,e,!0);return n.addAll(t,null,e.from,e.to),_i.maxOpen(n.finish())},Rs.prototype.matchTag=function(t,e,n){for(var r=n?this.tags.indexOf(n)+1:0;r<this.tags.length;r++){var o=this.tags[r];if(js(t,o.tag)&&(void 0===o.namespace||t.namespaceURI==o.namespace)&&(!o.context||e.matchesContext(o.context))){if(o.getAttrs){var i=o.getAttrs(t);if(!1===i)continue;o.attrs=i}return o}}},Rs.prototype.matchStyle=function(t,e,n,r){for(var o=r?this.styles.indexOf(r)+1:0;o<this.styles.length;o++){var i=this.styles[o];if(!(0!=i.style.indexOf(t)||i.context&&!n.matchesContext(i.context)||i.style.length>t.length&&(61!=i.style.charCodeAt(t.length)||i.style.slice(t.length+1)!=e))){if(i.getAttrs){var s=i.getAttrs(e);if(!1===s)continue;i.attrs=s}return i}}},Rs.schemaRules=function(t){var e=[];function n(t){for(var n=null==t.priority?50:t.priority,r=0;r<e.length;r++){var o=e[r];if((null==o.priority?50:o.priority)<n)break}e.splice(r,0,t)}var r,o=function(e){var r=t.marks[e].spec.parseDOM;r&&r.forEach((function(t){n(t=Ws(t)),t.mark=e}))};for(var i in t.marks)o(i);for(var s in t.nodes)r=void 0,(r=t.nodes[s].spec.parseDOM)&&r.forEach((function(t){n(t=Ws(t)),t.node=s}));return e},Rs.fromSchema=function(t){return t.cached.domParser||(t.cached.domParser=new Rs(t,Rs.schemaRules(t)))};var Bs={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},Vs={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Fs={ol:!0,ul:!0};function qs(t){return(t?1:0)|("full"===t?2:0)}var $s=function(t,e,n,r,o,i,s){this.type=t,this.attrs=e,this.solid=o,this.match=i||(4&s?null:t.contentMatch),this.options=s,this.content=[],this.marks=n,this.activeMarks=$i.none,this.pendingMarks=r,this.stashMarks=[]};$s.prototype.findWrapping=function(t){if(!this.match){if(!this.type)return[];var e=this.type.contentMatch.fillBefore(Ri.from(t));if(!e){var n,r=this.type.contentMatch;return(n=r.findWrapping(t.type))?(this.match=r,n):null}this.match=this.type.contentMatch.matchFragment(e)}return this.match.findWrapping(t.type)},$s.prototype.finish=function(t){if(!(1&this.options)){var e,n=this.content[this.content.length-1];n&&n.isText&&(e=/[ \t\r\n\u000c]+$/.exec(n.text))&&(n.text.length==e[0].length?this.content.pop():this.content[this.content.length-1]=n.withText(n.text.slice(0,n.text.length-e[0].length)))}var r=Ri.from(this.content);return!t&&this.match&&(r=r.append(this.match.fillBefore(Ri.empty,!0))),this.type?this.type.create(this.attrs,r,this.marks):r},$s.prototype.popFromStashMark=function(t){for(var e=this.stashMarks.length-1;e>=0;e--)if(t.eq(this.stashMarks[e]))return this.stashMarks.splice(e,1)[0]},$s.prototype.applyPending=function(t){for(var e=0,n=this.pendingMarks;e<n.length;e++){var r=n[e];(this.type?this.type.allowsMarkType(r.type):Js(r.type,t))&&!r.isInSet(this.activeMarks)&&(this.activeMarks=r.addToSet(this.activeMarks),this.pendingMarks=r.removeFromSet(this.pendingMarks))}},$s.prototype.inlineContext=function(t){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:t.parentNode&&!Bs.hasOwnProperty(t.parentNode.nodeName.toLowerCase())};var Ls=function(t,e,n){this.parser=t,this.options=e,this.isOpen=n;var r,o=e.topNode,i=qs(e.preserveWhitespace)|(n?4:0);r=o?new $s(o.type,o.attrs,$i.none,$i.none,!0,e.topMatch||o.type.contentMatch,i):new $s(n?null:t.schema.topNodeType,null,$i.none,$i.none,!0,null,i),this.nodes=[r],this.open=0,this.find=e.findPositions,this.needsBlock=!1},_s={top:{configurable:!0},currentPos:{configurable:!0}};function js(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function Ws(t){var e={};for(var n in t)e[n]=t[n];return e}function Js(t,e){var n=e.schema.nodes,r=function(r){var o=n[r];if(o.allowsMarkType(t)){var i=[],s=function(t){i.push(t);for(var n=0;n<t.edgeCount;n++){var r=t.edge(n),o=r.type,a=r.next;if(o==e)return!0;if(i.indexOf(a)<0&&s(a))return!0}};return s(o.contentMatch)?{v:!0}:void 0}};for(var o in n){var i=r(o);if(i)return i.v}}_s.top.get=function(){return this.nodes[this.open]},Ls.prototype.addDOM=function(t){if(3==t.nodeType)this.addTextNode(t);else if(1==t.nodeType){var e=t.getAttribute("style"),n=e?this.readStyles(function(t){for(var e,n=/\s*([\w-]+)\s*:\s*([^;]+)/g,r=[];e=n.exec(t);)r.push(e[1],e[2].trim());return r}(e)):null,r=this.top;if(null!=n)for(var o=0;o<n.length;o++)this.addPendingMark(n[o]);if(this.addElement(t),null!=n)for(var i=0;i<n.length;i++)this.removePendingMark(n[i],r)}},Ls.prototype.addTextNode=function(t){var e=t.nodeValue,n=this.top;if(2&n.options||n.inlineContext(t)||/[^ \t\r\n\u000c]/.test(e)){if(1&n.options)e=2&n.options?e.replace(/\r\n?/g,"\n"):e.replace(/\r?\n|\r/g," ");else if(e=e.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(e)&&this.open==this.nodes.length-1){var r=n.content[n.content.length-1],o=t.previousSibling;(!r||o&&"BR"==o.nodeName||r.isText&&/[ \t\r\n\u000c]$/.test(r.text))&&(e=e.slice(1))}e&&this.insertNode(this.parser.schema.text(e)),this.findInText(t)}else this.findInside(t)},Ls.prototype.addElement=function(t,e){var n,r=t.nodeName.toLowerCase();Fs.hasOwnProperty(r)&&this.parser.normalizeLists&&function(t){for(var e=t.firstChild,n=null;e;e=e.nextSibling){var r=1==e.nodeType?e.nodeName.toLowerCase():null;r&&Fs.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):"li"==r?n=e:r&&(n=null)}}(t);var o=this.options.ruleFromNode&&this.options.ruleFromNode(t)||(n=this.parser.matchTag(t,this,e));if(o?o.ignore:Vs.hasOwnProperty(r))this.findInside(t),this.ignoreFallback(t);else if(!o||o.skip||o.closeParent){o&&o.closeParent?this.open=Math.max(0,this.open-1):o&&o.skip.nodeType&&(t=o.skip);var i,s=this.top,a=this.needsBlock;if(Bs.hasOwnProperty(r))i=!0,s.type||(this.needsBlock=!0);else if(!t.firstChild)return void this.leafFallback(t);this.addAll(t),i&&this.sync(s),this.needsBlock=a}else this.addElementByRule(t,o,!1===o.consuming?n:null)},Ls.prototype.leafFallback=function(t){"BR"==t.nodeName&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(t.ownerDocument.createTextNode("\n"))},Ls.prototype.ignoreFallback=function(t){"BR"!=t.nodeName||this.top.type&&this.top.type.inlineContent||this.findPlace(this.parser.schema.text("-"))},Ls.prototype.readStyles=function(t){var e=$i.none;t:for(var n=0;n<t.length;n+=2)for(var r=null;;){var o=this.parser.matchStyle(t[n],t[n+1],this,r);if(!o)continue t;if(o.ignore)return null;if(e=this.parser.schema.marks[o.mark].create(o.attrs).addToSet(e),!1!==o.consuming)break;r=o}return e},Ls.prototype.addElementByRule=function(t,e,n){var r,o,i,s=this;e.node?(o=this.parser.schema.nodes[e.node]).isLeaf?this.insertNode(o.create(e.attrs))||this.leafFallback(t):r=this.enter(o,e.attrs,e.preserveWhitespace):(i=this.parser.schema.marks[e.mark].create(e.attrs),this.addPendingMark(i));var a=this.top;if(o&&o.isLeaf)this.findInside(t);else if(n)this.addElement(t,n);else if(e.getContent)this.findInside(t),e.getContent(t,this.parser.schema).forEach((function(t){return s.insertNode(t)}));else{var c=e.contentElement;"string"==typeof c?c=t.querySelector(c):"function"==typeof c&&(c=c(t)),c||(c=t),this.findAround(t,c,!0),this.addAll(c,r)}r&&(this.sync(a),this.open--),i&&this.removePendingMark(i,a)},Ls.prototype.addAll=function(t,e,n,r){for(var o=n||0,i=n?t.childNodes[n]:t.firstChild,s=null==r?null:t.childNodes[r];i!=s;i=i.nextSibling,++o)this.findAtPoint(t,o),this.addDOM(i),e&&Bs.hasOwnProperty(i.nodeName.toLowerCase())&&this.sync(e);this.findAtPoint(t,o)},Ls.prototype.findPlace=function(t){for(var e,n,r=this.open;r>=0;r--){var o=this.nodes[r],i=o.findWrapping(t);if(i&&(!e||e.length>i.length)&&(e=i,n=o,!i.length))break;if(o.solid)break}if(!e)return!1;this.sync(n);for(var s=0;s<e.length;s++)this.enterInner(e[s],null,!1);return!0},Ls.prototype.insertNode=function(t){if(t.isInline&&this.needsBlock&&!this.top.type){var e=this.textblockFromContext();e&&this.enterInner(e)}if(this.findPlace(t)){this.closeExtra();var n=this.top;n.applyPending(t.type),n.match&&(n.match=n.match.matchType(t.type));for(var r=n.activeMarks,o=0;o<t.marks.length;o++)n.type&&!n.type.allowsMarkType(t.marks[o].type)||(r=t.marks[o].addToSet(r));return n.content.push(t.mark(r)),!0}return!1},Ls.prototype.enter=function(t,e,n){var r=this.findPlace(t.create(e));return r&&this.enterInner(t,e,!0,n),r},Ls.prototype.enterInner=function(t,e,n,r){this.closeExtra();var o=this.top;o.applyPending(t),o.match=o.match&&o.match.matchType(t,e);var i=null==r?-5&o.options:qs(r);4&o.options&&0==o.content.length&&(i|=4),this.nodes.push(new $s(t,e,o.activeMarks,o.pendingMarks,n,null,i)),this.open++},Ls.prototype.closeExtra=function(t){var e=this.nodes.length-1;if(e>this.open){for(;e>this.open;e--)this.nodes[e-1].content.push(this.nodes[e].finish(t));this.nodes.length=this.open+1}},Ls.prototype.finish=function(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(this.isOpen||this.options.topOpen)},Ls.prototype.sync=function(t){for(var e=this.open;e>=0;e--)if(this.nodes[e]==t)return void(this.open=e)},_s.currentPos.get=function(){this.closeExtra();for(var t=0,e=this.open;e>=0;e--){for(var n=this.nodes[e].content,r=n.length-1;r>=0;r--)t+=n[r].nodeSize;e&&t++}return t},Ls.prototype.findAtPoint=function(t,e){if(this.find)for(var n=0;n<this.find.length;n++)this.find[n].node==t&&this.find[n].offset==e&&(this.find[n].pos=this.currentPos)},Ls.prototype.findInside=function(t){if(this.find)for(var e=0;e<this.find.length;e++)null==this.find[e].pos&&1==t.nodeType&&t.contains(this.find[e].node)&&(this.find[e].pos=this.currentPos)},Ls.prototype.findAround=function(t,e,n){if(t!=e&&this.find)for(var r=0;r<this.find.length;r++)null==this.find[r].pos&&1==t.nodeType&&t.contains(this.find[r].node)&&e.compareDocumentPosition(this.find[r].node)&(n?2:4)&&(this.find[r].pos=this.currentPos)},Ls.prototype.findInText=function(t){if(this.find)for(var e=0;e<this.find.length;e++)this.find[e].node==t&&(this.find[e].pos=this.currentPos-(t.nodeValue.length-this.find[e].offset))},Ls.prototype.matchesContext=function(t){var e=this;if(t.indexOf("|")>-1)return t.split(/\s*\|\s*/).some(this.matchesContext,this);var n=t.split("/"),r=this.options.context,o=!(this.isOpen||r&&r.parent.type!=this.nodes[0].type),i=-(r?r.depth+1:0)+(o?0:1),s=function(t,a){for(;t>=0;t--){var c=n[t];if(""==c){if(t==n.length-1||0==t)continue;for(;a>=i;a--)if(s(t-1,a))return!0;return!1}var l=a>0||0==a&&o?e.nodes[a].type:r&&a>=i?r.node(a-i).type:null;if(!l||l.name!=c&&-1==l.groups.indexOf(c))return!1;a--}return!0};return s(n.length-1,this.open)},Ls.prototype.textblockFromContext=function(){var t=this.options.context;if(t)for(var e=t.depth;e>=0;e--){var n=t.node(e).contentMatchAt(t.indexAfter(e)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(var r in this.parser.schema.nodes){var o=this.parser.schema.nodes[r];if(o.isTextblock&&o.defaultAttrs)return o}},Ls.prototype.addPendingMark=function(t){var e=function(t,e){for(var n=0;n<e.length;n++)if(t.eq(e[n]))return e[n]}(t,this.top.pendingMarks);e&&this.top.stashMarks.push(e),this.top.pendingMarks=t.addToSet(this.top.pendingMarks)},Ls.prototype.removePendingMark=function(t,e){for(var n=this.open;n>=0;n--){var r=this.nodes[n];if(r.pendingMarks.lastIndexOf(t)>-1)r.pendingMarks=t.removeFromSet(r.pendingMarks);else{r.activeMarks=t.removeFromSet(r.activeMarks);var o=r.popFromStashMark(t);o&&r.type&&r.type.allowsMarkType(o.type)&&(r.activeMarks=o.addToSet(r.activeMarks))}if(r==e)break}},Object.defineProperties(Ls.prototype,_s);var Ks=function(t,e){this.nodes=t||{},this.marks=e||{}};function Hs(t){var e={};for(var n in t){var r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function Us(t){return t.document||window.document}Ks.prototype.serializeFragment=function(t,e,n){var r=this;void 0===e&&(e={}),n||(n=Us(e).createDocumentFragment());var o=n,i=null;return t.forEach((function(t){if(i||t.marks.length){i||(i=[]);for(var n=0,s=0;n<i.length&&s<t.marks.length;){var a=t.marks[s];if(r.marks[a.type.name]){if(!a.eq(i[n])||!1===a.type.spec.spanning)break;n+=2,s++}else s++}for(;n<i.length;)o=i.pop(),i.pop();for(;s<t.marks.length;){var c=t.marks[s++],l=r.serializeMark(c,t.isInline,e);l&&(i.push(c,o),o.appendChild(l.dom),o=l.contentDOM||l.dom)}}o.appendChild(r.serializeNodeInner(t,e))})),n},Ks.prototype.serializeNodeInner=function(t,e){void 0===e&&(e={});var n=Ks.renderSpec(Us(e),this.nodes[t.type.name](t)),r=n.dom,o=n.contentDOM;if(o){if(t.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");e.onContent?e.onContent(t,o,e):this.serializeFragment(t.content,e,o)}return r},Ks.prototype.serializeNode=function(t,e){void 0===e&&(e={});for(var n=this.serializeNodeInner(t,e),r=t.marks.length-1;r>=0;r--){var o=this.serializeMark(t.marks[r],t.isInline,e);o&&((o.contentDOM||o.dom).appendChild(n),n=o.dom)}return n},Ks.prototype.serializeMark=function(t,e,n){void 0===n&&(n={});var r=this.marks[t.type.name];return r&&Ks.renderSpec(Us(n),r(t,e))},Ks.renderSpec=function(t,e,n){if(void 0===n&&(n=null),"string"==typeof e)return{dom:t.createTextNode(e)};if(null!=e.nodeType)return{dom:e};if(e.dom&&null!=e.dom.nodeType)return e;var r=e[0],o=r.indexOf(" ");o>0&&(n=r.slice(0,o),r=r.slice(o+1));var i=null,s=n?t.createElementNS(n,r):t.createElement(r),a=e[1],c=1;if(a&&"object"==typeof a&&null==a.nodeType&&!Array.isArray(a))for(var l in c=2,a)if(null!=a[l]){var h=l.indexOf(" ");h>0?s.setAttributeNS(l.slice(0,h),l.slice(h+1),a[l]):s.setAttribute(l,a[l])}for(var p=c;p<e.length;p++){var f=e[p];if(0===f){if(p<e.length-1||p>c)throw new RangeError("Content hole must be the only child of its parent node");return{dom:s,contentDOM:s}}var d=Ks.renderSpec(t,f,n),u=d.dom,m=d.contentDOM;if(s.appendChild(u),m){if(i)throw new RangeError("Multiple content holes");i=m}}return{dom:s,contentDOM:i}},Ks.fromSchema=function(t){return t.cached.domSerializer||(t.cached.domSerializer=new Ks(this.nodesFromSchema(t),this.marksFromSchema(t)))},Ks.nodesFromSchema=function(t){var e=Hs(t.nodes);return e.text||(e.text=function(t){return t.text}),e},Ks.marksFromSchema=function(t){return Hs(t.marks)};var Gs={};if("undefined"!=typeof navigator&&"undefined"!=typeof document){var Xs=/Edge\/(\d+)/.exec(navigator.userAgent),Ys=/MSIE \d/.test(navigator.userAgent),Qs=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);Gs.mac=/Mac/.test(navigator.platform);var Zs=Gs.ie=!!(Ys||Qs||Xs);Gs.ie_version=Ys?document.documentMode||6:Qs?+Qs[1]:Xs?+Xs[1]:null,Gs.gecko=!Zs&&/gecko\/(\d+)/i.test(navigator.userAgent),Gs.gecko_version=Gs.gecko&&+(/Firefox\/(\d+)/.exec(navigator.userAgent)||[0,0])[1];var ta=!Zs&&/Chrome\/(\d+)/.exec(navigator.userAgent);Gs.chrome=!!ta,Gs.chrome_version=ta&&+ta[1],Gs.safari=!Zs&&/Apple Computer/.test(navigator.vendor),Gs.ios=Gs.safari&&(/Mobile\/\w+/.test(navigator.userAgent)||navigator.maxTouchPoints>2),Gs.android=/Android \d/.test(navigator.userAgent),Gs.webkit="webkitFontSmoothing"in document.documentElement.style,Gs.webkit_version=Gs.webkit&&+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]}var ea=function(t){for(var e=0;;e++)if(!(t=t.previousSibling))return e},na=function(t){var e=t.assignedSlot||t.parentNode;return e&&11==e.nodeType?e.host:e},ra=null,oa=function(t,e,n){var r=ra||(ra=document.createRange());return r.setEnd(t,null==n?t.nodeValue.length:n),r.setStart(t,e||0),r},ia=function(t,e,n,r){return n&&(aa(t,e,n,r,-1)||aa(t,e,n,r,1))},sa=/^(img|br|input|textarea|hr)$/i;function aa(t,e,n,r,o){for(;;){if(t==n&&e==r)return!0;if(e==(o<0?0:ca(t))){var i=t.parentNode;if(1!=i.nodeType||la(t)||sa.test(t.nodeName)||"false"==t.contentEditable)return!1;e=ea(t)+(o<0?0:1),t=i}else{if(1!=t.nodeType)return!1;if("false"==(t=t.childNodes[e+(o<0?-1:0)]).contentEditable)return!1;e=o<0?ca(t):0}}}function ca(t){return 3==t.nodeType?t.nodeValue.length:t.childNodes.length}function la(t){for(var e,n=t;n&&!(e=n.pmViewDesc);n=n.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==t||e.contentDOM==t)}var ha=function(t){var e=t.isCollapsed;return e&&Gs.chrome&&t.rangeCount&&!t.getRangeAt(0).collapsed&&(e=!1),e};function pa(t,e){var n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}function fa(t){return{left:0,right:t.documentElement.clientWidth,top:0,bottom:t.documentElement.clientHeight}}function da(t,e){return"number"==typeof t?t:t[e]}function ua(t){var e=t.getBoundingClientRect(),n=e.width/t.offsetWidth||1,r=e.height/t.offsetHeight||1;return{left:e.left,right:e.left+t.clientWidth*n,top:e.top,bottom:e.top+t.clientHeight*r}}function ma(t,e,n){for(var r=t.someProp("scrollThreshold")||0,o=t.someProp("scrollMargin")||5,i=t.dom.ownerDocument,s=n||t.dom;s;s=na(s))if(1==s.nodeType){var a=s==i.body||1!=s.nodeType,c=a?fa(i):ua(s),l=0,h=0;if(e.top<c.top+da(r,"top")?h=-(c.top-e.top+da(o,"top")):e.bottom>c.bottom-da(r,"bottom")&&(h=e.bottom-c.bottom+da(o,"bottom")),e.left<c.left+da(r,"left")?l=-(c.left-e.left+da(o,"left")):e.right>c.right-da(r,"right")&&(l=e.right-c.right+da(o,"right")),l||h)if(a)i.defaultView.scrollBy(l,h);else{var p=s.scrollLeft,f=s.scrollTop;h&&(s.scrollTop+=h),l&&(s.scrollLeft+=l);var d=s.scrollLeft-p,u=s.scrollTop-f;e={left:e.left-d,top:e.top-u,right:e.right-d,bottom:e.bottom-u}}if(a)break}}function va(t){for(var e=[],n=t.ownerDocument;t&&(e.push({dom:t,top:t.scrollTop,left:t.scrollLeft}),t!=n);t=na(t));return e}function ga(t,e){for(var n=0;n<t.length;n++){var r=t[n],o=r.dom,i=r.top,s=r.left;o.scrollTop!=i+e&&(o.scrollTop=i+e),o.scrollLeft!=s&&(o.scrollLeft=s)}}var ya=null;function wa(t,e){for(var n,r,o=2e8,i=0,s=e.top,a=e.top,c=t.firstChild,l=0;c;c=c.nextSibling,l++){var h=void 0;if(1==c.nodeType)h=c.getClientRects();else{if(3!=c.nodeType)continue;h=oa(c).getClientRects()}for(var p=0;p<h.length;p++){var f=h[p];if(f.top<=s&&f.bottom>=a){s=Math.max(f.bottom,s),a=Math.min(f.top,a);var d=f.left>e.left?f.left-e.left:f.right<e.left?e.left-f.right:0;if(d<o){n=c,o=d,r=d&&3==n.nodeType?{left:f.right<e.left?f.right:f.left,top:e.top}:e,1==c.nodeType&&d&&(i=l+(e.left>=(f.left+f.right)/2?1:0));continue}}!n&&(e.left>=f.right&&e.top>=f.top||e.left>=f.left&&e.top>=f.bottom)&&(i=l+1)}}return n&&3==n.nodeType?function(t,e){for(var n=t.nodeValue.length,r=document.createRange(),o=0;o<n;o++){r.setEnd(t,o+1),r.setStart(t,o);var i=Sa(r,1);if(i.top!=i.bottom&&ba(e,i))return{node:t,offset:o+(e.left>=(i.left+i.right)/2?1:0)}}return{node:t,offset:0}}(n,r):!n||o&&1==n.nodeType?{node:t,offset:i}:wa(n,r)}function ba(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function xa(t,e,n){var r=t.childNodes.length;if(r&&n.top<n.bottom)for(var o=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-n.top)/(n.bottom-n.top))-2)),i=o;;){var s=t.childNodes[i];if(1==s.nodeType)for(var a=s.getClientRects(),c=0;c<a.length;c++){var l=a[c];if(ba(e,l))return xa(s,e,l)}if((i=(i+1)%r)==o)break}return t}function ka(t,e){var n,r,o,i,s=t.root;if(s.caretPositionFromPoint)try{var a=s.caretPositionFromPoint(e.left,e.top);a&&(o=(n=a).offsetNode,i=n.offset)}catch(t){}if(!o&&s.caretRangeFromPoint){var c=s.caretRangeFromPoint(e.left,e.top);c&&(o=(r=c).startContainer,i=r.startOffset)}var l,h=s.elementFromPoint(e.left,e.top+1);if(!h||!t.dom.contains(1!=h.nodeType?h.parentNode:h)){var p=t.dom.getBoundingClientRect();if(!ba(e,p))return null;if(!(h=xa(t.dom,e,p)))return null}if(Gs.safari)for(var f=h;o&&f;f=na(f))f.draggable&&(o=i=null);if(h=function(t,e){var n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}(h,e),o){if(Gs.gecko&&1==o.nodeType&&(i=Math.min(i,o.childNodes.length))<o.childNodes.length){var d,u=o.childNodes[i];"IMG"==u.nodeName&&(d=u.getBoundingClientRect()).right<=e.left&&d.bottom>e.top&&i++}o==t.dom&&i==o.childNodes.length-1&&1==o.lastChild.nodeType&&e.top>o.lastChild.getBoundingClientRect().bottom?l=t.state.doc.content.size:0!=i&&1==o.nodeType&&"BR"==o.childNodes[i-1].nodeName||(l=function(t,e,n,r){for(var o=-1,i=e;i!=t.dom;){var s=t.docView.nearestDesc(i,!0);if(!s)return null;if(s.node.isBlock&&s.parent){var a=s.dom.getBoundingClientRect();if(a.left>r.left||a.top>r.top)o=s.posBefore;else{if(!(a.right<r.left||a.bottom<r.top))break;o=s.posAfter}}i=s.dom.parentNode}return o>-1?o:t.docView.posFromDOM(e,n)}(t,o,i,e))}null==l&&(l=function(t,e,n){var r=wa(e,n),o=r.node,i=r.offset,s=-1;if(1==o.nodeType&&!o.firstChild){var a=o.getBoundingClientRect();s=a.left!=a.right&&n.left>(a.left+a.right)/2?1:-1}return t.docView.posFromDOM(o,i,s)}(t,h,e));var m=t.docView.nearestDesc(h,!0);return{pos:l,inside:m?m.posAtStart-m.border:-1}}function Sa(t,e){var n=t.getClientRects();return n.length?n[e<0?0:n.length-1]:t.getBoundingClientRect()}var Ca=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Ma(t,e,n){var r=t.docView.domFromPos(e,n<0?-1:1),o=r.node,i=r.offset,s=Gs.webkit||Gs.gecko;if(3==o.nodeType){if(!s||!Ca.test(o.nodeValue)&&(n<0?i:i!=o.nodeValue.length)){var a=i,c=i,l=n<0?1:-1;return n<0&&!i?(c++,l=-1):n>=0&&i==o.nodeValue.length?(a--,l=1):n<0?a--:c++,Oa(Sa(oa(o,a,c),l),l<0)}var h=Sa(oa(o,i,i),n);if(Gs.gecko&&i&&/\s/.test(o.nodeValue[i-1])&&i<o.nodeValue.length){var p=Sa(oa(o,i-1,i-1),-1);if(p.top==h.top){var f=Sa(oa(o,i,i+1),-1);if(f.top!=h.top)return Oa(f,f.left<p.left)}}return h}if(!t.state.doc.resolve(e).parent.inlineContent){if(i&&(n<0||i==ca(o))){var d=o.childNodes[i-1];if(1==d.nodeType)return Na(d.getBoundingClientRect(),!1)}if(i<ca(o)){var u=o.childNodes[i];if(1==u.nodeType)return Na(u.getBoundingClientRect(),!0)}return Na(o.getBoundingClientRect(),n>=0)}if(i&&(n<0||i==ca(o))){var m=o.childNodes[i-1],v=3==m.nodeType?oa(m,ca(m)-(s?0:1)):1!=m.nodeType||"BR"==m.nodeName&&m.nextSibling?null:m;if(v)return Oa(Sa(v,1),!1)}if(i<ca(o)){for(var g=o.childNodes[i];g.pmViewDesc&&g.pmViewDesc.ignoreForCoords;)g=g.nextSibling;var y=g?3==g.nodeType?oa(g,0,s?0:1):1==g.nodeType?g:null:null;if(y)return Oa(Sa(y,-1),!0)}return Oa(Sa(3==o.nodeType?oa(o):o,-n),n>=0)}function Oa(t,e){if(0==t.width)return t;var n=e?t.left:t.right;return{top:t.top,bottom:t.bottom,left:n,right:n}}function Na(t,e){if(0==t.height)return t;var n=e?t.top:t.bottom;return{top:n,bottom:n,left:t.left,right:t.right}}function Da(t,e,n){var r=t.state,o=t.root.activeElement;r!=e&&t.updateState(e),o!=t.dom&&t.focus();try{return n()}finally{r!=e&&t.updateState(r),o!=t.dom&&o&&o.focus()}}var Ta=/[\u0590-\u08ac]/,Ea=null,Aa=null,Pa=!1;var za=function(t,e,n,r){this.parent=t,this.children=e,this.dom=n,n.pmViewDesc=this,this.contentDOM=r,this.dirty=0},Ia={size:{configurable:!0},border:{configurable:!0},posBefore:{configurable:!0},posAtStart:{configurable:!0},posAfter:{configurable:!0},posAtEnd:{configurable:!0},contentLost:{configurable:!0},domAtom:{configurable:!0},ignoreForCoords:{configurable:!0}};za.prototype.matchesWidget=function(){return!1},za.prototype.matchesMark=function(){return!1},za.prototype.matchesNode=function(){return!1},za.prototype.matchesHack=function(t){return!1},za.prototype.parseRule=function(){return null},za.prototype.stopEvent=function(){return!1},Ia.size.get=function(){for(var t=0,e=0;e<this.children.length;e++)t+=this.children[e].size;return t},Ia.border.get=function(){return 0},za.prototype.destroy=function(){this.parent=null,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=null);for(var t=0;t<this.children.length;t++)this.children[t].destroy()},za.prototype.posBeforeChild=function(t){for(var e=0,n=this.posAtStart;e<this.children.length;e++){var r=this.children[e];if(r==t)return n;n+=r.size}},Ia.posBefore.get=function(){return this.parent.posBeforeChild(this)},Ia.posAtStart.get=function(){return this.parent?this.parent.posBeforeChild(this)+this.border:0},Ia.posAfter.get=function(){return this.posBefore+this.size},Ia.posAtEnd.get=function(){return this.posAtStart+this.size-2*this.border},za.prototype.localPosFromDOM=function(t,e,n){if(this.contentDOM&&this.contentDOM.contains(1==t.nodeType?t:t.parentNode)){if(n<0){var r,o;if(t==this.contentDOM)r=t.childNodes[e-1];else{for(;t.parentNode!=this.contentDOM;)t=t.parentNode;r=t.previousSibling}for(;r&&(!(o=r.pmViewDesc)||o.parent!=this);)r=r.previousSibling;return r?this.posBeforeChild(o)+o.size:this.posAtStart}var i,s;if(t==this.contentDOM)i=t.childNodes[e];else{for(;t.parentNode!=this.contentDOM;)t=t.parentNode;i=t.nextSibling}for(;i&&(!(s=i.pmViewDesc)||s.parent!=this);)i=i.nextSibling;return i?this.posBeforeChild(s):this.posAtEnd}var a;if(t==this.dom&&this.contentDOM)a=e>ea(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))a=2&t.compareDocumentPosition(this.contentDOM);else if(this.dom.firstChild){if(0==e)for(var c=t;;c=c.parentNode){if(c==this.dom){a=!1;break}if(c.parentNode.firstChild!=c)break}if(null==a&&e==t.childNodes.length)for(var l=t;;l=l.parentNode){if(l==this.dom){a=!0;break}if(l.parentNode.lastChild!=l)break}}return(null==a?n>0:a)?this.posAtEnd:this.posAtStart},za.prototype.nearestDesc=function(t,e){for(var n=!0,r=t;r;r=r.parentNode){var o=this.getDesc(r);if(o&&(!e||o.node)){if(!n||!o.nodeDOM||(1==o.nodeDOM.nodeType?o.nodeDOM.contains(1==t.nodeType?t:t.parentNode):o.nodeDOM==t))return o;n=!1}}},za.prototype.getDesc=function(t){for(var e=t.pmViewDesc,n=e;n;n=n.parent)if(n==this)return e},za.prototype.posFromDOM=function(t,e,n){for(var r=t;r;r=r.parentNode){var o=this.getDesc(r);if(o)return o.localPosFromDOM(t,e,n)}return-1},za.prototype.descAt=function(t){for(var e=0,n=0;e<this.children.length;e++){var r=this.children[e],o=n+r.size;if(n==t&&o!=n){for(;!r.border&&r.children.length;)r=r.children[0];return r}if(t<o)return r.descAt(t-n-r.border);n=o}},za.prototype.domFromPos=function(t,e){if(!this.contentDOM)return{node:this.dom,offset:0};for(var n=0,r=0,o=0;n<this.children.length;n++){var i=this.children[n],s=o+i.size;if(s>t||i instanceof _a){r=t-o;break}o=s}if(r)return this.children[n].domFromPos(r-this.children[n].border,e);for(var a=void 0;n&&!(a=this.children[n-1]).size&&a instanceof Ba&&a.widget.type.side>=0;n--);if(e<=0){for(var c,l=!0;(c=n?this.children[n-1]:null)&&c.dom.parentNode!=this.contentDOM;n--,l=!1);return c&&e&&l&&!c.border&&!c.domAtom?c.domFromPos(c.size,e):{node:this.contentDOM,offset:c?ea(c.dom)+1:0}}for(var h,p=!0;(h=n<this.children.length?this.children[n]:null)&&h.dom.parentNode!=this.contentDOM;n++,p=!1);return h&&p&&!h.border&&!h.domAtom?h.domFromPos(0,e):{node:this.contentDOM,offset:h?ea(h.dom):this.contentDOM.childNodes.length}},za.prototype.parseRange=function(t,e,n){if(void 0===n&&(n=0),0==this.children.length)return{node:this.contentDOM,from:t,to:e,fromOffset:0,toOffset:this.contentDOM.childNodes.length};for(var r=-1,o=-1,i=n,s=0;;s++){var a=this.children[s],c=i+a.size;if(-1==r&&t<=c){var l=i+a.border;if(t>=l&&e<=c-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(t,e,l);t=i;for(var h=s;h>0;h--){var p=this.children[h-1];if(p.size&&p.dom.parentNode==this.contentDOM&&!p.emptyChildAt(1)){r=ea(p.dom)+1;break}t-=p.size}-1==r&&(r=0)}if(r>-1&&(c>e||s==this.children.length-1)){e=c;for(var f=s+1;f<this.children.length;f++){var d=this.children[f];if(d.size&&d.dom.parentNode==this.contentDOM&&!d.emptyChildAt(-1)){o=ea(d.dom);break}e+=d.size}-1==o&&(o=this.contentDOM.childNodes.length);break}i=c}return{node:this.contentDOM,from:t,to:e,fromOffset:r,toOffset:o}},za.prototype.emptyChildAt=function(t){if(this.border||!this.contentDOM||!this.children.length)return!1;var e=this.children[t<0?0:this.children.length-1];return 0==e.size||e.emptyChildAt(t)},za.prototype.domAfterPos=function(t){var e=this.domFromPos(t,0),n=e.node,r=e.offset;if(1!=n.nodeType||r==n.childNodes.length)throw new RangeError("No node after pos "+t);return n.childNodes[r]},za.prototype.setSelection=function(t,e,n,r){for(var o=Math.min(t,e),i=Math.max(t,e),s=0,a=0;s<this.children.length;s++){var c=this.children[s],l=a+c.size;if(o>a&&i<l)return c.setSelection(t-a-c.border,e-a-c.border,n,r);a=l}var h=this.domFromPos(t,t?-1:1),p=e==t?h:this.domFromPos(e,e?-1:1),f=n.getSelection(),d=!1;if((Gs.gecko||Gs.safari)&&t==e){var u=h.node,m=h.offset;if(3==u.nodeType){if((d=m&&"\n"==u.nodeValue[m-1])&&m==u.nodeValue.length)for(var v=u,g=void 0;v;v=v.parentNode){if(g=v.nextSibling){"BR"==g.nodeName&&(h=p={node:g.parentNode,offset:ea(g)+1});break}var y=v.pmViewDesc;if(y&&y.node&&y.node.isBlock)break}}else{var w=u.childNodes[m-1];d=w&&("BR"==w.nodeName||"false"==w.contentEditable)}}if(Gs.gecko&&f.focusNode&&f.focusNode!=p.node&&1==f.focusNode.nodeType){var b=f.focusNode.childNodes[f.focusOffset];b&&"false"==b.contentEditable&&(r=!0)}if(r||d&&Gs.safari||!ia(h.node,h.offset,f.anchorNode,f.anchorOffset)||!ia(p.node,p.offset,f.focusNode,f.focusOffset)){var x=!1;if((f.extend||t==e)&&!d){f.collapse(h.node,h.offset);try{t!=e&&f.extend(p.node,p.offset),x=!0}catch(t){if(!(t instanceof DOMException))throw t}}if(!x){if(t>e){var k=h;h=p,p=k}var S=document.createRange();S.setEnd(p.node,p.offset),S.setStart(h.node,h.offset),f.removeAllRanges(),f.addRange(S)}}},za.prototype.ignoreMutation=function(t){return!this.contentDOM&&"selection"!=t.type},Ia.contentLost.get=function(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)},za.prototype.markDirty=function(t,e){for(var n=0,r=0;r<this.children.length;r++){var o=this.children[r],i=n+o.size;if(n==i?t<=i&&e>=n:t<i&&e>n){var s=n+o.border,a=i-o.border;if(t>=s&&e<=a)return this.dirty=t==n||e==i?2:1,void(t!=s||e!=a||!o.contentLost&&o.dom.parentNode==this.contentDOM?o.markDirty(t-s,e-s):o.dirty=3);o.dirty=o.dom==o.contentDOM&&o.dom.parentNode==this.contentDOM?2:3}n=i}this.dirty=2},za.prototype.markParentsDirty=function(){for(var t=1,e=this.parent;e;e=e.parent,t++){var n=1==t?2:1;e.dirty<n&&(e.dirty=n)}},Ia.domAtom.get=function(){return!1},Ia.ignoreForCoords.get=function(){return!1},Object.defineProperties(za.prototype,Ia);var Ra=[],Ba=function(t){function e(e,n,r,o){var i,s=n.type.toDOM;if("function"==typeof s&&(s=s(r,(function(){return i?i.parent?i.parent.posBeforeChild(i):void 0:o}))),!n.type.spec.raw){if(1!=s.nodeType){var a=document.createElement("span");a.appendChild(s),s=a}s.contentEditable=!1,s.classList.add("ProseMirror-widget")}t.call(this,e,Ra,s,null),this.widget=n,i=this}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={domAtom:{configurable:!0}};return e.prototype.matchesWidget=function(t){return 0==this.dirty&&t.type.eq(this.widget.type)},e.prototype.parseRule=function(){return{ignore:!0}},e.prototype.stopEvent=function(t){var e=this.widget.spec.stopEvent;return!!e&&e(t)},e.prototype.ignoreMutation=function(t){return"selection"!=t.type||this.widget.spec.ignoreSelection},n.domAtom.get=function(){return!0},Object.defineProperties(e.prototype,n),e}(za),Va=function(t){function e(e,n,r,o){t.call(this,e,Ra,n,null),this.textDOM=r,this.text=o}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={size:{configurable:!0}};return n.size.get=function(){return this.text.length},e.prototype.localPosFromDOM=function(t,e){return t!=this.textDOM?this.posAtStart+(e?this.size:0):this.posAtStart+e},e.prototype.domFromPos=function(t){return{node:this.textDOM,offset:t}},e.prototype.ignoreMutation=function(t){return"characterData"===t.type&&t.target.nodeValue==t.oldValue},Object.defineProperties(e.prototype,n),e}(za),Fa=function(t){function e(e,n,r,o){t.call(this,e,[],r,o),this.mark=n}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.create=function(t,n,r,o){var i=o.nodeViews[n.type.name],s=i&&i(n,o,r);return s&&s.dom||(s=Ks.renderSpec(document,n.type.spec.toDOM(n,r))),new e(t,n,s.dom,s.contentDOM||s.dom)},e.prototype.parseRule=function(){return{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}},e.prototype.matchesMark=function(t){return 3!=this.dirty&&this.mark.eq(t)},e.prototype.markDirty=function(e,n){if(t.prototype.markDirty.call(this,e,n),0!=this.dirty){for(var r=this.parent;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=0}},e.prototype.slice=function(t,n,r){var o=e.create(this.parent,this.mark,!0,r),i=this.children,s=this.size;n<s&&(i=ec(i,n,s,r)),t>0&&(i=ec(i,0,t,r));for(var a=0;a<i.length;a++)i[a].parent=o;return o.children=i,o},e}(za),qa=function(t){function e(e,n,r,o,i,s,a,c,l){t.call(this,e,n.isLeaf?Ra:[],i,s),this.nodeDOM=a,this.node=n,this.outerDeco=r,this.innerDeco=o,s&&this.updateChildren(c,l)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={size:{configurable:!0},border:{configurable:!0},domAtom:{configurable:!0}};return e.create=function(t,n,r,o,i,s){var a,c,l=i.nodeViews[n.type.name],h=l&&l(n,i,(function(){return c?c.parent?c.parent.posBeforeChild(c):void 0:s}),r,o),p=h&&h.dom,f=h&&h.contentDOM;if(n.isText)if(p){if(3!=p.nodeType)throw new RangeError("Text must be rendered as a DOM text node")}else p=document.createTextNode(n.text);else p||(p=(a=Ks.renderSpec(document,n.type.spec.toDOM(n))).dom,f=a.contentDOM);f||n.isText||"BR"==p.nodeName||(p.hasAttribute("contenteditable")||(p.contentEditable=!1),n.type.spec.draggable&&(p.draggable=!0));var d=p;return p=Xa(p,r,n),h?c=new ja(t,n,r,o,p,f,d,h,i,s+1):n.isText?new La(t,n,r,o,p,d,i):new e(t,n,r,o,p,f,d,i,s+1)},e.prototype.parseRule=function(){var t=this;if(this.node.type.spec.reparseInView)return null;var e={node:this.node.type.name,attrs:this.node.attrs};return this.node.type.spec.code&&(e.preserveWhitespace="full"),this.contentDOM&&!this.contentLost?e.contentElement=this.contentDOM:e.getContent=function(){return t.contentDOM?Ri.empty:t.node.content},e},e.prototype.matchesNode=function(t,e,n){return 0==this.dirty&&t.eq(this.node)&&Ya(e,this.outerDeco)&&n.eq(this.innerDeco)},n.size.get=function(){return this.node.nodeSize},n.border.get=function(){return this.node.isLeaf?0:1},e.prototype.updateChildren=function(t,e){var n=this,r=this.node.inlineContent,o=e,i=t.composing&&this.localCompositionInfo(t,e),s=i&&i.pos>-1?i:null,a=i&&i.pos<0,c=new Za(this,s&&s.node);!function(t,e,n,r){var o=e.locals(t),i=0;if(0!=o.length)for(var s=0,a=[],c=null,l=0;;){if(s<o.length&&o[s].to==i){for(var h=o[s++],p=void 0;s<o.length&&o[s].to==i;)(p||(p=[h])).push(o[s++]);if(p){p.sort(tc);for(var f=0;f<p.length;f++)n(p[f],l,!!c)}else n(h,l,!!c)}var d=void 0,u=void 0;if(c)u=-1,d=c,c=null;else{if(!(l<t.childCount))break;u=l,d=t.child(l++)}for(var m=0;m<a.length;m++)a[m].to<=i&&a.splice(m--,1);for(;s<o.length&&o[s].from<=i&&o[s].to>i;)a.push(o[s++]);var v=i+d.nodeSize;if(d.isText){var g=v;s<o.length&&o[s].from<g&&(g=o[s].from);for(var y=0;y<a.length;y++)a[y].to<g&&(g=a[y].to);g<v&&(c=d.cut(g-i),d=d.cut(0,g-i),v=g,u=-1)}r(d,a.length?d.isInline&&!d.isLeaf?a.filter((function(t){return!t.inline})):a.slice():Ra,e.forChild(i,d),u),i=v}else for(var w=0;w<t.childCount;w++){var b=t.child(w);r(b,o,e.forChild(i,b),w),i+=b.nodeSize}}(this.node,this.innerDeco,(function(e,i,s){e.spec.marks?c.syncToMarks(e.spec.marks,r,t):e.type.side>=0&&!s&&c.syncToMarks(i==n.node.childCount?$i.none:n.node.child(i).marks,r,t),c.placeWidget(e,t,o)}),(function(e,n,s,l){var h;c.syncToMarks(e.marks,r,t),c.findNodeMatch(e,n,s,l)||a&&t.state.selection.from>o&&t.state.selection.to<o+e.nodeSize&&(h=c.findIndexWithChild(i.node))>-1&&c.updateNodeAt(e,n,s,h,t)||c.updateNextNode(e,n,s,t,l)||c.addNode(e,n,s,t,o),o+=e.nodeSize})),c.syncToMarks(Ra,r,t),this.node.isTextblock&&c.addTextblockHacks(),c.destroyRest(),(c.changed||2==this.dirty)&&(s&&this.protectLocalComposition(t,s),Wa(this.contentDOM,this.children,t),Gs.ios&&function(t){if("UL"==t.nodeName||"OL"==t.nodeName){var e=t.style.cssText;t.style.cssText=e+"; list-style: square !important",window.getComputedStyle(t).listStyle,t.style.cssText=e}}(this.dom))},e.prototype.localCompositionInfo=function(t,e){var n=t.state.selection,r=n.from,o=n.to;if(!(!(t.state.selection instanceof de)||r<e||o>e+this.node.content.size)){var i=t.root.getSelection(),s=function(t,e){for(;;){if(3==t.nodeType)return t;if(1==t.nodeType&&e>0){if(t.childNodes.length>e&&3==t.childNodes[e].nodeType)return t.childNodes[e];e=ca(t=t.childNodes[e-1])}else{if(!(1==t.nodeType&&e<t.childNodes.length))return null;t=t.childNodes[e],e=0}}}(i.focusNode,i.focusOffset);if(s&&this.dom.contains(s.parentNode)){if(this.node.inlineContent){var a=s.nodeValue,c=function(t,e,n,r){for(var o=0,i=0;o<t.childCount&&i<=r;){var s=t.child(o++),a=i;if(i+=s.nodeSize,s.isText){for(var c=s.text;o<t.childCount;){var l=t.child(o++);if(i+=l.nodeSize,!l.isText)break;c+=l.text}if(i>=n){var h=c.lastIndexOf(e,r-a);if(h>=0&&h+e.length+a>=n)return a+h}}}return-1}(this.node.content,a,r-e,o-e);return c<0?null:{node:s,pos:c,text:a}}return{node:s,pos:-1}}}},e.prototype.protectLocalComposition=function(t,e){var n=e.node,r=e.pos,o=e.text;if(!this.getDesc(n)){for(var i=n;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=null)}var s=new Va(this,i,n,o);t.compositionNodes.push(s),this.children=ec(this.children,r,r+o.length,t,s)}},e.prototype.update=function(t,e,n,r){return!(3==this.dirty||!t.sameMarkup(this.node)||(this.updateInner(t,e,n,r),0))},e.prototype.updateInner=function(t,e,n,r){this.updateOuterDeco(e),this.node=t,this.innerDeco=n,this.contentDOM&&this.updateChildren(r,this.posAtStart),this.dirty=0},e.prototype.updateOuterDeco=function(t){if(!Ya(t,this.outerDeco)){var e=1!=this.nodeDOM.nodeType,n=this.dom;this.dom=Ua(this.dom,this.nodeDOM,Ha(this.outerDeco,this.node,e),Ha(t,this.node,e)),this.dom!=n&&(n.pmViewDesc=null,this.dom.pmViewDesc=this),this.outerDeco=t}},e.prototype.selectNode=function(){this.nodeDOM.classList.add("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||(this.dom.draggable=!0)},e.prototype.deselectNode=function(){this.nodeDOM.classList.remove("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||this.dom.removeAttribute("draggable")},n.domAtom.get=function(){return this.node.isAtom},Object.defineProperties(e.prototype,n),e}(za);function $a(t,e,n,r,o){return Xa(r,e,t),new qa(null,t,e,n,r,r,r,o,0)}var La=function(t){function e(e,n,r,o,i,s,a){t.call(this,e,n,r,o,i,null,s,a)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={domAtom:{configurable:!0}};return e.prototype.parseRule=function(){for(var t=this.nodeDOM.parentNode;t&&t!=this.dom&&!t.pmIsDeco;)t=t.parentNode;return{skip:t||!0}},e.prototype.update=function(t,e,n,r){return!(3==this.dirty||0!=this.dirty&&!this.inParent()||!t.sameMarkup(this.node)||(this.updateOuterDeco(e),0==this.dirty&&t.text==this.node.text||t.text==this.nodeDOM.nodeValue||(this.nodeDOM.nodeValue=t.text,r.trackWrites==this.nodeDOM&&(r.trackWrites=null)),this.node=t,this.dirty=0,0))},e.prototype.inParent=function(){for(var t=this.parent.contentDOM,e=this.nodeDOM;e;e=e.parentNode)if(e==t)return!0;return!1},e.prototype.domFromPos=function(t){return{node:this.nodeDOM,offset:t}},e.prototype.localPosFromDOM=function(e,n,r){return e==this.nodeDOM?this.posAtStart+Math.min(n,this.node.text.length):t.prototype.localPosFromDOM.call(this,e,n,r)},e.prototype.ignoreMutation=function(t){return"characterData"!=t.type&&"selection"!=t.type},e.prototype.slice=function(t,n,r){var o=this.node.cut(t,n),i=document.createTextNode(o.text);return new e(this.parent,o,this.outerDeco,this.innerDeco,i,i,r)},e.prototype.markDirty=function(e,n){t.prototype.markDirty.call(this,e,n),this.dom==this.nodeDOM||0!=e&&n!=this.nodeDOM.nodeValue.length||(this.dirty=3)},n.domAtom.get=function(){return!1},Object.defineProperties(e.prototype,n),e}(qa),_a=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={domAtom:{configurable:!0},ignoreForCoords:{configurable:!0}};return e.prototype.parseRule=function(){return{ignore:!0}},e.prototype.matchesHack=function(t){return 0==this.dirty&&this.dom.nodeName==t},n.domAtom.get=function(){return!0},n.ignoreForCoords.get=function(){return"IMG"==this.dom.nodeName},Object.defineProperties(e.prototype,n),e}(za),ja=function(t){function e(e,n,r,o,i,s,a,c,l,h){t.call(this,e,n,r,o,i,s,a,l,h),this.spec=c}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.update=function(e,n,r,o){if(3==this.dirty)return!1;if(this.spec.update){var i=this.spec.update(e,n,r);return i&&this.updateInner(e,n,r,o),i}return!(!this.contentDOM&&!e.isLeaf)&&t.prototype.update.call(this,e,n,r,o)},e.prototype.selectNode=function(){this.spec.selectNode?this.spec.selectNode():t.prototype.selectNode.call(this)},e.prototype.deselectNode=function(){this.spec.deselectNode?this.spec.deselectNode():t.prototype.deselectNode.call(this)},e.prototype.setSelection=function(e,n,r,o){this.spec.setSelection?this.spec.setSelection(e,n,r):t.prototype.setSelection.call(this,e,n,r,o)},e.prototype.destroy=function(){this.spec.destroy&&this.spec.destroy(),t.prototype.destroy.call(this)},e.prototype.stopEvent=function(t){return!!this.spec.stopEvent&&this.spec.stopEvent(t)},e.prototype.ignoreMutation=function(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):t.prototype.ignoreMutation.call(this,e)},e}(qa);function Wa(t,e,n){for(var r=t.firstChild,o=!1,i=0;i<e.length;i++){var s=e[i],a=s.dom;if(a.parentNode==t){for(;a!=r;)r=Qa(r),o=!0;r=r.nextSibling}else o=!0,t.insertBefore(a,r);if(s instanceof Fa){var c=r?r.previousSibling:t.lastChild;Wa(s.contentDOM,s.children,n),r=c?c.nextSibling:t.firstChild}}for(;r;)r=Qa(r),o=!0;o&&n.trackWrites==t&&(n.trackWrites=null)}function Ja(t){t&&(this.nodeName=t)}Ja.prototype=Object.create(null);var Ka=[new Ja];function Ha(t,e,n){if(0==t.length)return Ka;for(var r=n?Ka[0]:new Ja,o=[r],i=0;i<t.length;i++){var s=t[i].type.attrs;if(s)for(var a in s.nodeName&&o.push(r=new Ja(s.nodeName)),s){var c=s[a];null!=c&&(n&&1==o.length&&o.push(r=new Ja(e.isInline?"span":"div")),"class"==a?r.class=(r.class?r.class+" ":"")+c:"style"==a?r.style=(r.style?r.style+";":"")+c:"nodeName"!=a&&(r[a]=c))}}return o}function Ua(t,e,n,r){if(n==Ka&&r==Ka)return e;for(var o=e,i=0;i<r.length;i++){var s=r[i],a=n[i];if(i){var c=void 0;a&&a.nodeName==s.nodeName&&o!=t&&(c=o.parentNode)&&c.tagName.toLowerCase()==s.nodeName||((c=document.createElement(s.nodeName)).pmIsDeco=!0,c.appendChild(o),a=Ka[0]),o=c}Ga(o,a||Ka[0],s)}return o}function Ga(t,e,n){for(var r in e)"class"==r||"style"==r||"nodeName"==r||r in n||t.removeAttribute(r);for(var o in n)"class"!=o&&"style"!=o&&"nodeName"!=o&&n[o]!=e[o]&&t.setAttribute(o,n[o]);if(e.class!=n.class){for(var i=e.class?e.class.split(" ").filter(Boolean):Ra,s=n.class?n.class.split(" ").filter(Boolean):Ra,a=0;a<i.length;a++)-1==s.indexOf(i[a])&&t.classList.remove(i[a]);for(var c=0;c<s.length;c++)-1==i.indexOf(s[c])&&t.classList.add(s[c])}if(e.style!=n.style){if(e.style)for(var l,h=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g;l=h.exec(e.style);)t.style.removeProperty(l[1]);n.style&&(t.style.cssText+=n.style)}}function Xa(t,e,n){return Ua(t,t,Ka,Ha(e,n,1!=t.nodeType))}function Ya(t,e){if(t.length!=e.length)return!1;for(var n=0;n<t.length;n++)if(!t[n].type.eq(e[n].type))return!1;return!0}function Qa(t){var e=t.nextSibling;return t.parentNode.removeChild(t),e}var Za=function(t,e){this.top=t,this.lock=e,this.index=0,this.stack=[],this.changed=!1,this.preMatch=function(t,e){for(var n=t.childCount,r=e.length,o=new Map;n>0&&r>0;r--){var i=e[r-1],s=i.node;if(s){if(s!=t.child(n-1))break;--n,o.set(i,n)}}return{index:n,matched:o}}(t.node.content,t.children)};function tc(t,e){return t.type.side-e.type.side}function ec(t,e,n,r,o){for(var i=[],s=0,a=0;s<t.length;s++){var c=t[s],l=a,h=a+=c.size;l>=n||h<=e?i.push(c):(l<e&&i.push(c.slice(0,e-l,r)),o&&(i.push(o),o=null),h>n&&i.push(c.slice(n-l,c.size,r)))}return i}function nc(t,e){var n=t.root.getSelection(),r=t.state.doc;if(!n.focusNode)return null;var o=t.docView.nearestDesc(n.focusNode),i=o&&0==o.size,s=t.docView.posFromDOM(n.focusNode,n.focusOffset);if(s<0)return null;var a,c,l=r.resolve(s);if(ha(n)){for(a=l;o&&!o.node;)o=o.parent;if(o&&o.node.isAtom&&me.isSelectable(o.node)&&o.parent&&(!o.node.isInline||!function(t,e,n){for(var r=0==e,o=e==ca(t);r||o;){if(t==n)return!0;var i=ea(t);if(!(t=t.parentNode))return!1;r=r&&0==i,o=o&&i==ca(t)}}(n.focusNode,n.focusOffset,o.dom))){var h=o.posBefore;c=new me(s==h?l:r.resolve(h))}}else{var p=t.docView.posFromDOM(n.anchorNode,n.anchorOffset);if(p<0)return null;a=r.resolve(p)}return c||(c=pc(t,a,l,"pointer"==e||t.state.selection.head<l.pos&&!i?1:-1)),c}function rc(t){return t.editable?t.hasFocus():fc(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function oc(t,e){var n=t.state.selection;if(lc(t,n),rc(t)){if(!e&&t.mouseDown&&t.mouseDown.allowDefault)return t.mouseDown.delayedSelectionSync=!0,void t.domObserver.setCurSelection();if(t.domObserver.disconnectSelection(),t.cursorWrapper)!function(t){var e=t.root.getSelection(),n=document.createRange(),r=t.cursorWrapper.dom,o="IMG"==r.nodeName;o?n.setEnd(r.parentNode,ea(r)+1):n.setEnd(r,0),n.collapse(!1),e.removeAllRanges(),e.addRange(n),!o&&!t.state.selection.visible&&Gs.ie&&Gs.ie_version<=11&&(r.disabled=!0,r.disabled=!1)}(t);else{var r,o,i=n.anchor,s=n.head;!ic||n instanceof de||(n.$from.parent.inlineContent||(r=sc(t,n.from)),n.empty||n.$from.parent.inlineContent||(o=sc(t,n.to))),t.docView.setSelection(i,s,t.root,e),ic&&(r&&cc(r),o&&cc(o)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&function(t){var e=t.dom.ownerDocument;e.removeEventListener("selectionchange",t.hideSelectionGuard);var n=t.root.getSelection(),r=n.anchorNode,o=n.anchorOffset;e.addEventListener("selectionchange",t.hideSelectionGuard=function(){n.anchorNode==r&&n.anchorOffset==o||(e.removeEventListener("selectionchange",t.hideSelectionGuard),setTimeout((function(){rc(t)&&!t.state.selection.visible||t.dom.classList.remove("ProseMirror-hideselection")}),20))})}(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}Za.prototype.destroyBetween=function(t,e){if(t!=e){for(var n=t;n<e;n++)this.top.children[n].destroy();this.top.children.splice(t,e-t),this.changed=!0}},Za.prototype.destroyRest=function(){this.destroyBetween(this.index,this.top.children.length)},Za.prototype.syncToMarks=function(t,e,n){for(var r=0,o=this.stack.length>>1,i=Math.min(o,t.length);r<i&&(r==o-1?this.top:this.stack[r+1<<1]).matchesMark(t[r])&&!1!==t[r].type.spec.spanning;)r++;for(;r<o;)this.destroyRest(),this.top.dirty=0,this.index=this.stack.pop(),this.top=this.stack.pop(),o--;for(;o<t.length;){this.stack.push(this.top,this.index+1);for(var s=-1,a=this.index;a<Math.min(this.index+3,this.top.children.length);a++)if(this.top.children[a].matchesMark(t[o])){s=a;break}if(s>-1)s>this.index&&(this.changed=!0,this.destroyBetween(this.index,s)),this.top=this.top.children[this.index];else{var c=Fa.create(this.top,t[o],e,n);this.top.children.splice(this.index,0,c),this.top=c,this.changed=!0}this.index=0,o++}},Za.prototype.findNodeMatch=function(t,e,n,r){var o=this.top.children,i=-1;if(r>=this.preMatch.index){for(var s=this.index;s<o.length;s++)if(o[s].matchesNode(t,e,n)){i=s;break}}else for(var a=this.index,c=Math.min(o.length,a+1);a<c;a++){var l=o[a];if(l.matchesNode(t,e,n)&&!this.preMatch.matched.has(l)){i=a;break}}return!(i<0||(this.destroyBetween(this.index,i),this.index++,0))},Za.prototype.updateNodeAt=function(t,e,n,r,o){return!!this.top.children[r].update(t,e,n,o)&&(this.destroyBetween(this.index,r),this.index=r+1,!0)},Za.prototype.findIndexWithChild=function(t){for(;;){var e=t.parentNode;if(!e)return-1;if(e==this.top.contentDOM){var n=t.pmViewDesc;if(n)for(var r=this.index;r<this.top.children.length;r++)if(this.top.children[r]==n)return r;return-1}t=e}},Za.prototype.updateNextNode=function(t,e,n,r,o){for(var i=this.index;i<this.top.children.length;i++){var s=this.top.children[i];if(s instanceof qa){var a=this.preMatch.matched.get(s);if(null!=a&&a!=o)return!1;var c=s.dom;if((!this.lock||!(c==this.lock||1==c.nodeType&&c.contains(this.lock.parentNode))||t.isText&&s.node&&s.node.isText&&s.nodeDOM.nodeValue==t.text&&3!=s.dirty&&Ya(e,s.outerDeco))&&s.update(t,e,n,r))return this.destroyBetween(this.index,i),s.dom!=c&&(this.changed=!0),this.index++,!0;break}}return!1},Za.prototype.addNode=function(t,e,n,r,o){this.top.children.splice(this.index++,0,qa.create(this.top,t,e,n,r,o)),this.changed=!0},Za.prototype.placeWidget=function(t,e,n){var r=this.index<this.top.children.length?this.top.children[this.index]:null;if(!r||!r.matchesWidget(t)||t!=r.widget&&r.widget.type.toDOM.parentNode){var o=new Ba(this.top,t,e,n);this.top.children.splice(this.index++,0,o),this.changed=!0}else this.index++},Za.prototype.addTextblockHacks=function(){for(var t=this.top.children[this.index-1];t instanceof Fa;)t=t.children[t.children.length-1];t&&t instanceof La&&!/\n$/.test(t.node.text)||((Gs.safari||Gs.chrome)&&t&&"false"==t.dom.contentEditable&&this.addHackNode("IMG"),this.addHackNode("BR"))},Za.prototype.addHackNode=function(t){if(this.index<this.top.children.length&&this.top.children[this.index].matchesHack(t))this.index++;else{var e=document.createElement(t);"IMG"==t&&(e.className="ProseMirror-separator"),this.top.children.splice(this.index++,0,new _a(this.top,Ra,e,null)),this.changed=!0}};var ic=Gs.safari||Gs.chrome&&Gs.chrome_version<63;function sc(t,e){var n=t.docView.domFromPos(e,0),r=n.node,o=n.offset,i=o<r.childNodes.length?r.childNodes[o]:null,s=o?r.childNodes[o-1]:null;if(Gs.safari&&i&&"false"==i.contentEditable)return ac(i);if(!(i&&"false"!=i.contentEditable||s&&"false"!=s.contentEditable)){if(i)return ac(i);if(s)return ac(s)}}function ac(t){return t.contentEditable="true",Gs.safari&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function cc(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function lc(t,e){if(e instanceof me){var n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(hc(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else hc(t)}function hc(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=null)}function pc(t,e,n,r){return t.someProp("createSelectionBetween",(function(r){return r(t,e,n)}))||de.between(e,n,r)}function fc(t){var e=t.root.getSelection();if(!e.anchorNode)return!1;try{return t.dom.contains(3==e.anchorNode.nodeType?e.anchorNode.parentNode:e.anchorNode)&&(t.editable||t.dom.contains(3==e.focusNode.nodeType?e.focusNode.parentNode:e.focusNode))}catch(t){return!1}}function dc(t,e){var n=t.selection,r=n.$anchor,o=n.$head,i=e>0?r.max(o):r.min(o),s=i.parent.inlineContent?i.depth?t.doc.resolve(e>0?i.after():i.before()):null:i;return s&&he.findFrom(s,e)}function uc(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function mc(t,e,n){var r=t.state.selection;if(!(r instanceof de)){if(r instanceof me&&r.node.isInline)return uc(t,new de(e>0?r.$to:r.$from));var o=dc(t.state,e);return!!o&&uc(t,o)}if(!r.empty||n.indexOf("s")>-1)return!1;if(t.endOfTextblock(e>0?"right":"left")){var i=dc(t.state,e);return!!(i&&i instanceof me)&&uc(t,i)}if(!(Gs.mac&&n.indexOf("m")>-1)){var s,a=r.$head,c=a.textOffset?null:e<0?a.nodeBefore:a.nodeAfter;if(!c||c.isText)return!1;var l=e<0?a.pos-c.nodeSize:a.pos;return!!(c.isAtom||(s=t.docView.descAt(l))&&!s.contentDOM)&&(me.isSelectable(c)?uc(t,new me(e<0?t.state.doc.resolve(a.pos-c.nodeSize):a)):!!Gs.webkit&&uc(t,new de(t.state.doc.resolve(e<0?l:l+c.nodeSize))))}}function vc(t){return 3==t.nodeType?t.nodeValue.length:t.childNodes.length}function gc(t){var e=t.pmViewDesc;return e&&0==e.size&&(t.nextSibling||"BR"!=t.nodeName)}function yc(t){var e=t.root.getSelection(),n=e.focusNode,r=e.focusOffset;if(n){var o,i,s=!1;for(Gs.gecko&&1==n.nodeType&&r<vc(n)&&gc(n.childNodes[r])&&(s=!0);;)if(r>0){if(1!=n.nodeType)break;var a=n.childNodes[r-1];if(gc(a))o=n,i=--r;else{if(3!=a.nodeType)break;r=(n=a).nodeValue.length}}else{if(bc(n))break;for(var c=n.previousSibling;c&&gc(c);)o=n.parentNode,i=ea(c),c=c.previousSibling;if(c)r=vc(n=c);else{if((n=n.parentNode)==t.dom)break;r=0}}s?xc(t,e,n,r):o&&xc(t,e,o,i)}}function wc(t){var e=t.root.getSelection(),n=e.focusNode,r=e.focusOffset;if(n){for(var o,i,s=vc(n);;)if(r<s){if(1!=n.nodeType)break;if(!gc(n.childNodes[r]))break;o=n,i=++r}else{if(bc(n))break;for(var a=n.nextSibling;a&&gc(a);)o=a.parentNode,i=ea(a)+1,a=a.nextSibling;if(a)r=0,s=vc(n=a);else{if((n=n.parentNode)==t.dom)break;r=s=0}}o&&xc(t,e,o,i)}}function bc(t){var e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function xc(t,e,n,r){if(ha(e)){var o=document.createRange();o.setEnd(n,r),o.setStart(n,r),e.removeAllRanges(),e.addRange(o)}else e.extend&&e.extend(n,r);t.domObserver.setCurSelection();var i=t.state;setTimeout((function(){t.state==i&&oc(t)}),50)}function kc(t,e,n){var r=t.state.selection;if(r instanceof de&&!r.empty||n.indexOf("s")>-1)return!1;if(Gs.mac&&n.indexOf("m")>-1)return!1;var o=r.$from,i=r.$to;if(!o.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){var s=dc(t.state,e);if(s&&s instanceof me)return uc(t,s)}if(!o.parent.inlineContent){var a=e<0?o:i,c=r instanceof ge?he.near(a,e):he.findFrom(a,e);return!!c&&uc(t,c)}return!1}function Sc(t,e){if(!(t.state.selection instanceof de))return!0;var n=t.state.selection,r=n.$head,o=n.$anchor,i=n.empty;if(!r.sameParent(o))return!0;if(!i)return!1;if(t.endOfTextblock(e>0?"forward":"backward"))return!0;var s=!r.textOffset&&(e<0?r.nodeBefore:r.nodeAfter);if(s&&!s.isText){var a=t.state.tr;return e<0?a.delete(r.pos-s.nodeSize,r.pos):a.delete(r.pos,r.pos+s.nodeSize),t.dispatch(a),!0}return!1}function Cc(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function Mc(t){var e=t.pmViewDesc;if(e)return e.parseRule();if("BR"==t.nodeName&&t.parentNode){if(Gs.safari&&/^(ul|ol)$/i.test(t.parentNode.nodeName)){var n=document.createElement("div");return n.appendChild(document.createElement("li")),{skip:n}}if(t.parentNode.lastChild==t||Gs.safari&&/^(tr|table)$/i.test(t.parentNode.nodeName))return{ignore:!0}}else if("IMG"==t.nodeName&&t.getAttribute("mark-placeholder"))return{ignore:!0}}function Oc(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:pc(t,e.resolve(n.anchor),e.resolve(n.head))}function Nc(t,e,n){for(var r=t.depth,o=e?t.end():t.pos;r>0&&(e||t.indexAfter(r)==t.node(r).childCount);)r--,o++,e=!1;if(n)for(var i=t.node(r).maybeChild(t.indexAfter(r));i&&!i.isLeaf;)i=i.firstChild,o++;return o}function Dc(t,e){for(var n=[],r=e.content,o=e.openStart,i=e.openEnd;o>1&&i>1&&1==r.childCount&&1==r.firstChild.childCount;){o--,i--;var s=r.firstChild;n.push(s.type.name,s.attrs!=s.type.defaultAttrs?s.attrs:null),r=s.content}var a=t.someProp("clipboardSerializer")||Ks.fromSchema(t.state.schema),c=Bc(),l=c.createElement("div");l.appendChild(a.serializeFragment(r,{document:c}));for(var h,p=l.firstChild;p&&1==p.nodeType&&(h=Ic[p.nodeName.toLowerCase()]);){for(var f=h.length-1;f>=0;f--){for(var d=c.createElement(h[f]);l.firstChild;)d.appendChild(l.firstChild);l.appendChild(d),"tbody"!=h[f]&&(o++,i++)}p=l.firstChild}return p&&1==p.nodeType&&p.setAttribute("data-pm-slice",o+" "+i+" "+JSON.stringify(n)),{dom:l,text:t.someProp("clipboardTextSerializer",(function(t){return t(e)}))||e.content.textBetween(0,e.content.size,"\n\n")}}function Tc(t,e,n,r,o){var i,s,a=o.parent.type.spec.code;if(!n&&!e)return null;var c=e&&(r||a||!n);if(c){if(t.someProp("transformPastedText",(function(t){e=t(e,a||r)})),a)return new _i(Ri.from(t.state.schema.text(e.replace(/\r\n?/g,"\n"))),0,0);var l=t.someProp("clipboardTextParser",(function(t){return t(e,o,r)}));if(l)s=l;else{var h=o.marks(),p=t.state.schema,f=Ks.fromSchema(p);i=document.createElement("div"),e.trim().split(/(?:\r\n?|\n)+/).forEach((function(t){i.appendChild(document.createElement("p")).appendChild(f.serializeNode(p.text(t,h)))}))}}else t.someProp("transformPastedHTML",(function(t){n=t(n)})),i=function(t){var e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));var n,r=Bc().createElement("div"),o=/<([a-z][^>\s]+)/i.exec(t);if((n=o&&Ic[o[1].toLowerCase()])&&(t=n.map((function(t){return"<"+t+">"})).join("")+t+n.map((function(t){return"</"+t+">"})).reverse().join("")),r.innerHTML=t,n)for(var i=0;i<n.length;i++)r=r.querySelector(n[i])||r;return r}(n),Gs.webkit&&function(t){for(var e=t.querySelectorAll(Gs.chrome?"span:not([class]):not([style])":"span.Apple-converted-space"),n=0;n<e.length;n++){var r=e[n];1==r.childNodes.length&&" "==r.textContent&&r.parentNode&&r.parentNode.replaceChild(t.ownerDocument.createTextNode(" "),r)}}(i);var d=i&&i.querySelector("[data-pm-slice]"),u=d&&/^(\d+) (\d+) (.*)/.exec(d.getAttribute("data-pm-slice"));if(!s){var m=t.someProp("clipboardParser")||t.someProp("domParser")||Rs.fromSchema(t.state.schema);s=m.parseSlice(i,{preserveWhitespace:!(!c&&!u),context:o})}return s=u?function(t,e){if(!t.size)return t;var n,r=t.content.firstChild.type.schema;try{n=JSON.parse(e)}catch(e){return t}for(var o=t.content,i=t.openStart,s=t.openEnd,a=n.length-2;a>=0;a-=2){var c=r.nodes[n[a]];if(!c||c.hasRequiredAttrs())break;o=Ri.from(c.create(n[a+1],o)),i++,s++}return new _i(o,i,s)}(function(t,e,n){return e<t.openStart&&(t=new _i(zc(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new _i(zc(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}(s,+u[1],+u[2]),u[3]):_i.maxOpen(function(t,e){if(t.childCount<2)return t;for(var n=function(n){var r=e.node(n).contentMatchAt(e.index(n)),o=void 0,i=[];if(t.forEach((function(t){if(i){var e,n=r.findWrapping(t.type);if(!n)return i=null;if(e=i.length&&o.length&&Ac(n,o,t,i[i.length-1],0))i[i.length-1]=e;else{i.length&&(i[i.length-1]=Pc(i[i.length-1],o.length));var s=Ec(t,n);i.push(s),r=r.matchType(s.type,s.attrs),o=n}}})),i)return{v:Ri.from(i)}},r=e.depth;r>=0;r--){var o=n(r);if(o)return o.v}return t}(s.content,o),!1),t.someProp("transformPasted",(function(t){s=t(s)})),s}function Ec(t,e,n){void 0===n&&(n=0);for(var r=e.length-1;r>=n;r--)t=e[r].create(null,Ri.from(t));return t}function Ac(t,e,n,r,o){if(o<t.length&&o<e.length&&t[o]==e[o]){var i=Ac(t,e,n,r.lastChild,o+1);if(i)return r.copy(r.content.replaceChild(r.childCount-1,i));if(r.contentMatchAt(r.childCount).matchType(o==t.length-1?n.type:t[o+1]))return r.copy(r.content.append(Ri.from(Ec(n,t,o+1))))}}function Pc(t,e){if(0==e)return t;var n=t.content.replaceChild(t.childCount-1,Pc(t.lastChild,e-1)),r=t.contentMatchAt(t.childCount).fillBefore(Ri.empty,!0);return t.copy(n.append(r))}function zc(t,e,n,r,o,i){var s=e<0?t.firstChild:t.lastChild,a=s.content;return o<r-1&&(a=zc(a,e,n,r,o+1,i)),o>=n&&(a=e<0?s.contentMatchAt(0).fillBefore(a,t.childCount>1||i<=o).append(a):a.append(s.contentMatchAt(s.childCount).fillBefore(Ri.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,s.copy(a))}var Ic={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]},Rc=null;function Bc(){return Rc||(Rc=document.implementation.createHTMLDocument("title"))}var Vc={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},Fc=Gs.ie&&Gs.ie_version<=11,qc=function(){this.anchorNode=this.anchorOffset=this.focusNode=this.focusOffset=null};qc.prototype.set=function(t){this.anchorNode=t.anchorNode,this.anchorOffset=t.anchorOffset,this.focusNode=t.focusNode,this.focusOffset=t.focusOffset},qc.prototype.eq=function(t){return t.anchorNode==this.anchorNode&&t.anchorOffset==this.anchorOffset&&t.focusNode==this.focusNode&&t.focusOffset==this.focusOffset};var $c=function(t,e){var n=this;this.view=t,this.handleDOMChange=e,this.queue=[],this.flushingSoon=-1,this.observer=window.MutationObserver&&new window.MutationObserver((function(t){for(var e=0;e<t.length;e++)n.queue.push(t[e]);Gs.ie&&Gs.ie_version<=11&&t.some((function(t){return"childList"==t.type&&t.removedNodes.length||"characterData"==t.type&&t.oldValue.length>t.target.nodeValue.length}))?n.flushSoon():n.flush()})),this.currentSelection=new qc,Fc&&(this.onCharData=function(t){n.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue}),n.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.suppressingSelectionUpdates=!1};$c.prototype.flushSoon=function(){var t=this;this.flushingSoon<0&&(this.flushingSoon=window.setTimeout((function(){t.flushingSoon=-1,t.flush()}),20))},$c.prototype.forceFlush=function(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())},$c.prototype.start=function(){this.observer&&this.observer.observe(this.view.dom,Vc),Fc&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()},$c.prototype.stop=function(){var t=this;if(this.observer){var e=this.observer.takeRecords();if(e.length){for(var n=0;n<e.length;n++)this.queue.push(e[n]);window.setTimeout((function(){return t.flush()}),20)}this.observer.disconnect()}Fc&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()},$c.prototype.connectSelection=function(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)},$c.prototype.disconnectSelection=function(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)},$c.prototype.suppressSelectionUpdates=function(){var t=this;this.suppressingSelectionUpdates=!0,setTimeout((function(){return t.suppressingSelectionUpdates=!1}),50)},$c.prototype.onSelectionChange=function(){if(function(t){return(!t.editable||t.root.activeElement==t.dom)&&fc(t)}(this.view)){if(this.suppressingSelectionUpdates)return oc(this.view);if(Gs.ie&&Gs.ie_version<=11&&!this.view.state.selection.empty){var t=this.view.root.getSelection();if(t.focusNode&&ia(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset))return this.flushSoon()}this.flush()}},$c.prototype.setCurSelection=function(){this.currentSelection.set(this.view.root.getSelection())},$c.prototype.ignoreSelectionChange=function(t){if(0==t.rangeCount)return!0;var e=t.getRangeAt(0).commonAncestorContainer,n=this.view.docView.nearestDesc(e);return n&&n.ignoreMutation({type:"selection",target:3==e.nodeType?e.parentNode:e})?(this.setCurSelection(),!0):void 0},$c.prototype.flush=function(){if(this.view.docView&&!(this.flushingSoon>-1)){var t=this.observer?this.observer.takeRecords():[];this.queue.length&&(t=this.queue.concat(t),this.queue.length=0);var e=this.view.root.getSelection(),n=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(e)&&fc(this.view)&&!this.ignoreSelectionChange(e),r=-1,o=-1,i=!1,s=[];if(this.view.editable)for(var a=0;a<t.length;a++){var c=this.registerMutation(t[a],s);c&&(r=r<0?c.from:Math.min(c.from,r),o=o<0?c.to:Math.max(c.to,o),c.typeOver&&(i=!0))}if(Gs.gecko&&s.length>1){var l=s.filter((function(t){return"BR"==t.nodeName}));if(2==l.length){var h=l[0],p=l[1];h.parentNode&&h.parentNode.parentNode==p.parentNode?p.remove():h.remove()}}(r>-1||n)&&(r>-1&&(this.view.docView.markDirty(r,o),function(t){Lc||(Lc=!0,"normal"==getComputedStyle(t.dom).whiteSpace&&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."))}(this.view)),this.handleDOMChange(r,o,i,s),this.view.docView.dirty?this.view.updateState(this.view.state):this.currentSelection.eq(e)||oc(this.view),this.currentSelection.set(e))}},$c.prototype.registerMutation=function(t,e){if(e.indexOf(t.target)>-1)return null;var n=this.view.docView.nearestDesc(t.target);if("attributes"==t.type&&(n==this.view.docView||"contenteditable"==t.attributeName||"style"==t.attributeName&&!t.oldValue&&!t.target.getAttribute("style")))return null;if(!n||n.ignoreMutation(t))return null;if("childList"==t.type){for(var r=0;r<t.addedNodes.length;r++)e.push(t.addedNodes[r]);if(n.contentDOM&&n.contentDOM!=n.dom&&!n.contentDOM.contains(t.target))return{from:n.posBefore,to:n.posAfter};var o=t.previousSibling,i=t.nextSibling;if(Gs.ie&&Gs.ie_version<=11&&t.addedNodes.length)for(var s=0;s<t.addedNodes.length;s++){var a=t.addedNodes[s],c=a.previousSibling,l=a.nextSibling;(!c||Array.prototype.indexOf.call(t.addedNodes,c)<0)&&(o=c),(!l||Array.prototype.indexOf.call(t.addedNodes,l)<0)&&(i=l)}var h=o&&o.parentNode==t.target?ea(o)+1:0,p=n.localPosFromDOM(t.target,h,-1),f=i&&i.parentNode==t.target?ea(i):t.target.childNodes.length;return{from:p,to:n.localPosFromDOM(t.target,f,1)}}return"attributes"==t.type?{from:n.posAtStart-n.border,to:n.posAtEnd+n.border}:{from:n.posAtStart,to:n.posAtEnd,typeOver:t.target.nodeValue==t.oldValue}};var Lc=!1,_c={},jc={};function Wc(t,e){t.lastSelectionOrigin=e,t.lastSelectionTime=Date.now()}function Jc(t){t.someProp("handleDOMEvents",(function(e){for(var n in e)t.eventHandlers[n]||t.dom.addEventListener(n,t.eventHandlers[n]=function(e){return Kc(t,e)})}))}function Kc(t,e){return t.someProp("handleDOMEvents",(function(n){var r=n[e.type];return!!r&&(r(t,e)||e.defaultPrevented)}))}function Hc(t){return{left:t.clientX,top:t.clientY}}function Uc(t,e,n,r,o){if(-1==r)return!1;for(var i=t.state.doc.resolve(r),s=function(r){if(t.someProp(e,(function(e){return r>i.depth?e(t,n,i.nodeAfter,i.before(r),o,!0):e(t,n,i.node(r),i.before(r),o,!1)})))return{v:!0}},a=i.depth+1;a>0;a--){var c=s(a);if(c)return c.v}return!1}function Gc(t,e,n){t.focused||t.focus();var r=t.state.tr.setSelection(e);"pointer"==n&&r.setMeta("pointer",!0),t.dispatch(r)}function Xc(t,e,n,r){return Uc(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",(function(n){return n(t,e,r)}))}function Yc(t,e,n,r){return Uc(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",(function(n){return n(t,e,r)}))||function(t,e,n){if(0!=n.button)return!1;var r=t.state.doc;if(-1==e)return!!r.inlineContent&&(Gc(t,de.create(r,0,r.content.size),"pointer"),!0);for(var o=r.resolve(e),i=o.depth+1;i>0;i--){var s=i>o.depth?o.nodeAfter:o.node(i),a=o.before(i);if(s.inlineContent)Gc(t,de.create(r,a+1,a+1+s.content.size),"pointer");else{if(!me.isSelectable(s))continue;Gc(t,me.create(r,a),"pointer")}return!0}}(t,n,r)}function Qc(t){return il(t)}jc.keydown=function(t,e){if(t.shiftKey=16==e.keyCode||e.shiftKey,!el(t,e))if(229!=e.keyCode&&t.domObserver.forceFlush(),t.lastKeyCode=e.keyCode,t.lastKeyCodeTime=Date.now(),!Gs.ios||13!=e.keyCode||e.ctrlKey||e.altKey||e.metaKey)t.someProp("handleKeyDown",(function(n){return n(t,e)}))||function(t,e){var n=e.keyCode,r=function(t){var e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}(e);return 8==n||Gs.mac&&72==n&&"c"==r?Sc(t,-1)||yc(t):46==n||Gs.mac&&68==n&&"c"==r?Sc(t,1)||wc(t):13==n||27==n||(37==n?mc(t,-1,r)||yc(t):39==n?mc(t,1,r)||wc(t):38==n?kc(t,-1,r)||yc(t):40==n?function(t){if(Gs.safari&&!(t.state.selection.$head.parentOffset>0)){var e=t.root.getSelection(),n=e.focusNode,r=e.focusOffset;if(n&&1==n.nodeType&&0==r&&n.firstChild&&"false"==n.firstChild.contentEditable){var o=n.firstChild;Cc(t,o,!0),setTimeout((function(){return Cc(t,o,!1)}),20)}}}(t)||kc(t,1,r)||wc(t):r==(Gs.mac?"m":"c")&&(66==n||73==n||89==n||90==n))}(t,e)?e.preventDefault():Wc(t,"key");else{var n=Date.now();t.lastIOSEnter=n,t.lastIOSEnterFallbackTimeout=setTimeout((function(){t.lastIOSEnter==n&&(t.someProp("handleKeyDown",(function(e){return e(t,pa(13,"Enter"))})),t.lastIOSEnter=0)}),200)}},jc.keyup=function(t,e){16==e.keyCode&&(t.shiftKey=!1)},jc.keypress=function(t,e){if(!(el(t,e)||!e.charCode||e.ctrlKey&&!e.altKey||Gs.mac&&e.metaKey))if(t.someProp("handleKeyPress",(function(n){return n(t,e)})))e.preventDefault();else{var n=t.state.selection;if(!(n instanceof de&&n.$from.sameParent(n.$to))){var r=String.fromCharCode(e.charCode);t.someProp("handleTextInput",(function(e){return e(t,n.$from.pos,n.$to.pos,r)}))||t.dispatch(t.state.tr.insertText(r).scrollIntoView()),e.preventDefault()}}};var Zc=Gs.mac?"metaKey":"ctrlKey";_c.mousedown=function(t,e){t.shiftKey=e.shiftKey;var n=Qc(t),r=Date.now(),o="singleClick";r-t.lastClick.time<500&&function(t,e){var n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}(e,t.lastClick)&&!e[Zc]&&("singleClick"==t.lastClick.type?o="doubleClick":"doubleClick"==t.lastClick.type&&(o="tripleClick")),t.lastClick={time:r,x:e.clientX,y:e.clientY,type:o};var i=t.posAtCoords(Hc(e));i&&("singleClick"==o?(t.mouseDown&&t.mouseDown.done(),t.mouseDown=new tl(t,i,e,n)):("doubleClick"==o?Xc:Yc)(t,i.pos,i.inside,e)?e.preventDefault():Wc(t,"pointer"))};var tl=function(t,e,n,r){var o,i,s=this;if(this.view=t,this.startDoc=t.state.doc,this.pos=e,this.event=n,this.flushed=r,this.selectNode=n[Zc],this.allowDefault=n.shiftKey,this.delayedSelectionSync=!1,e.inside>-1)o=t.state.doc.nodeAt(e.inside),i=e.inside;else{var a=t.state.doc.resolve(e.pos);o=a.parent,i=a.depth?a.before():0}this.mightDrag=null;var c=r?null:n.target,l=c?t.docView.nearestDesc(c,!0):null;this.target=l?l.dom:null;var h=t.state.selection;(0==n.button&&o.type.spec.draggable&&!1!==o.type.spec.selectable||h instanceof me&&h.from<=i&&h.to>i)&&(this.mightDrag={node:o,pos:i,addAttr:this.target&&!this.target.draggable,setUneditable:this.target&&Gs.gecko&&!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((function(){s.view.mouseDown==s&&s.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)),Wc(t,"pointer")};function el(t,e){return!!t.composing||!!(Gs.safari&&Math.abs(e.timeStamp-t.compositionEndedAt)<500)&&(t.compositionEndedAt=-2e8,!0)}tl.prototype.done=function(){var t=this;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((function(){return oc(t.view)})),this.view.mouseDown=null},tl.prototype.up=function(t){if(this.done(),this.view.dom.contains(3==t.target.nodeType?t.target.parentNode:t.target)){var e=this.pos;this.view.state.doc!=this.startDoc&&(e=this.view.posAtCoords(Hc(t))),this.allowDefault||!e?Wc(this.view,"pointer"):function(t,e,n,r,o){return Uc(t,"handleClickOn",e,n,r)||t.someProp("handleClick",(function(n){return n(t,e,r)}))||(o?function(t,e){if(-1==e)return!1;var n,r,o=t.state.selection;o instanceof me&&(n=o.node);for(var i=t.state.doc.resolve(e),s=i.depth+1;s>0;s--){var a=s>i.depth?i.nodeAfter:i.node(s);if(me.isSelectable(a)){r=n&&o.$from.depth>0&&s>=o.$from.depth&&i.before(o.$from.depth+1)==o.$from.pos?i.before(o.$from.depth):i.before(s);break}}return null!=r&&(Gc(t,me.create(t.state.doc,r),"pointer"),!0)}(t,n):function(t,e){if(-1==e)return!1;var n=t.state.doc.resolve(e),r=n.nodeAfter;return!!(r&&r.isAtom&&me.isSelectable(r))&&(Gc(t,new me(n),"pointer"),!0)}(t,n))}(this.view,e.pos,e.inside,t,this.selectNode)?t.preventDefault():0==t.button&&(this.flushed||Gs.safari&&this.mightDrag&&!this.mightDrag.node.isAtom||Gs.chrome&&!(this.view.state.selection instanceof de)&&Math.min(Math.abs(e.pos-this.view.state.selection.from),Math.abs(e.pos-this.view.state.selection.to))<=2)?(Gc(this.view,he.near(this.view.state.doc.resolve(e.pos)),"pointer"),t.preventDefault()):Wc(this.view,"pointer")}},tl.prototype.move=function(t){!this.allowDefault&&(Math.abs(this.event.x-t.clientX)>4||Math.abs(this.event.y-t.clientY)>4)&&(this.allowDefault=!0),Wc(this.view,"pointer"),0==t.buttons&&this.done()},_c.touchdown=function(t){Qc(t),Wc(t,"pointer")},_c.contextmenu=function(t){return Qc(t)};var nl=Gs.android?5e3:-1;function rl(t,e){clearTimeout(t.composingTimeout),e>-1&&(t.composingTimeout=setTimeout((function(){return il(t)}),e))}function ol(t){var e;for(t.composing&&(t.composing=!1,t.compositionEndedAt=((e=document.createEvent("Event")).initEvent("event",!0,!0),e.timeStamp));t.compositionNodes.length>0;)t.compositionNodes.pop().markParentsDirty()}function il(t,e){if(t.domObserver.forceFlush(),ol(t),e||t.docView.dirty){var n=nc(t);return n&&!n.eq(t.state.selection)?t.dispatch(t.state.tr.setSelection(n)):t.updateState(t.state),!0}return!1}jc.compositionstart=jc.compositionupdate=function(t){if(!t.composing){t.domObserver.flush();var e=t.state,n=e.selection.$from;if(e.selection.empty&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some((function(t){return!1===t.type.spec.inclusive}))))t.markCursor=t.state.storedMarks||n.marks(),il(t,!0),t.markCursor=null;else if(il(t),Gs.gecko&&e.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length)for(var r=t.root.getSelection(),o=r.focusNode,i=r.focusOffset;o&&1==o.nodeType&&0!=i;){var s=i<0?o.lastChild:o.childNodes[i-1];if(!s)break;if(3==s.nodeType){r.collapse(s,s.nodeValue.length);break}o=s,i=-1}t.composing=!0}rl(t,nl)},jc.compositionend=function(t,e){t.composing&&(t.composing=!1,t.compositionEndedAt=e.timeStamp,rl(t,20))};var sl=Gs.ie&&Gs.ie_version<15||Gs.ios&&Gs.webkit_version<604;function al(t,e,n,r){var o=Tc(t,e,n,t.shiftKey,t.state.selection.$from);if(t.someProp("handlePaste",(function(e){return e(t,r,o||_i.empty)})))return!0;if(!o)return!1;var i=function(t){return 0==t.openStart&&0==t.openEnd&&1==t.content.childCount?t.content.firstChild:null}(o),s=i?t.state.tr.replaceSelectionWith(i,t.shiftKey):t.state.tr.replaceSelection(o);return t.dispatch(s.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}_c.copy=jc.cut=function(t,e){var n=t.state.selection,r="cut"==e.type;if(!n.empty){var o=sl?null:e.clipboardData,i=Dc(t,n.content()),s=i.dom,a=i.text;o?(e.preventDefault(),o.clearData(),o.setData("text/html",s.innerHTML),o.setData("text/plain",a)):function(t,e){if(t.dom.parentNode){var n=t.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(e),n.style.cssText="position: fixed; left: -10000px; top: 10px";var r=getSelection(),o=document.createRange();o.selectNodeContents(e),t.dom.blur(),r.removeAllRanges(),r.addRange(o),setTimeout((function(){n.parentNode&&n.parentNode.removeChild(n),t.focus()}),50)}}(t,s),r&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))}},jc.paste=function(t,e){var n=sl?null:e.clipboardData;n&&al(t,n.getData("text/plain"),n.getData("text/html"),e)?e.preventDefault():function(t,e){if(t.dom.parentNode){var n=t.shiftKey||t.state.selection.$from.parent.type.spec.code,r=t.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus(),setTimeout((function(){t.focus(),r.parentNode&&r.parentNode.removeChild(r),n?al(t,r.value,null,e):al(t,r.textContent,r.innerHTML,e)}),50)}}(t,e)};var cl=function(t,e){this.slice=t,this.move=e},ll=Gs.mac?"altKey":"ctrlKey";for(var hl in _c.dragstart=function(t,e){var n=t.mouseDown;if(n&&n.done(),e.dataTransfer){var r=t.state.selection,o=r.empty?null:t.posAtCoords(Hc(e));if(o&&o.pos>=r.from&&o.pos<=(r instanceof me?r.to-1:r.to));else if(n&&n.mightDrag)t.dispatch(t.state.tr.setSelection(me.create(t.state.doc,n.mightDrag.pos)));else if(e.target&&1==e.target.nodeType){var i=t.docView.nearestDesc(e.target,!0);i&&i.node.type.spec.draggable&&i!=t.docView&&t.dispatch(t.state.tr.setSelection(me.create(t.state.doc,i.posBefore)))}var s=t.state.selection.content(),a=Dc(t,s),c=a.dom,l=a.text;e.dataTransfer.clearData(),e.dataTransfer.setData(sl?"Text":"text/html",c.innerHTML),e.dataTransfer.effectAllowed="copyMove",sl||e.dataTransfer.setData("text/plain",l),t.dragging=new cl(s,!e[ll])}},_c.dragend=function(t){var e=t.dragging;window.setTimeout((function(){t.dragging==e&&(t.dragging=null)}),50)},jc.dragover=jc.dragenter=function(t,e){return e.preventDefault()},jc.drop=function(t,e){var n=t.dragging;if(t.dragging=null,e.dataTransfer){var r=t.posAtCoords(Hc(e));if(r){var o=t.state.doc.resolve(r.pos);if(o){var i=n&&n.slice;i?t.someProp("transformPasted",(function(t){i=t(i)})):i=Tc(t,e.dataTransfer.getData(sl?"Text":"text/plain"),sl?null:e.dataTransfer.getData("text/html"),!1,o);var s=n&&!e[ll];if(t.someProp("handleDrop",(function(n){return n(t,e,i||_i.empty,s)})))e.preventDefault();else if(i){e.preventDefault();var a=i?Gt(t.state.doc,o.pos,i):o.pos;null==a&&(a=o.pos);var c=t.state.tr;s&&c.deleteSelection();var l=c.mapping.map(a),h=0==i.openStart&&0==i.openEnd&&1==i.content.childCount,p=c.doc;if(h?c.replaceRangeWith(l,l,i.content.firstChild):c.replaceRange(l,l,i),!c.doc.eq(p)){var f=c.doc.resolve(l);if(h&&me.isSelectable(i.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(i.content.firstChild))c.setSelection(new me(f));else{var d=c.mapping.map(a);c.mapping.maps[c.mapping.maps.length-1].forEach((function(t,e,n,r){return d=r})),c.setSelection(pc(t,f,c.doc.resolve(d)))}t.focus(),t.dispatch(c.setMeta("uiEvent","drop"))}}}}}},_c.focus=function(t){t.focused||(t.domObserver.stop(),t.dom.classList.add("ProseMirror-focused"),t.domObserver.start(),t.focused=!0,setTimeout((function(){t.docView&&t.hasFocus()&&!t.domObserver.currentSelection.eq(t.root.getSelection())&&oc(t)}),20))},_c.blur=function(t,e){t.focused&&(t.domObserver.stop(),t.dom.classList.remove("ProseMirror-focused"),t.domObserver.start(),e.relatedTarget&&t.dom.contains(e.relatedTarget)&&t.domObserver.currentSelection.set({}),t.focused=!1)},_c.beforeinput=function(t,e){if(Gs.chrome&&Gs.android&&"deleteContentBackward"==e.inputType){var n=t.domChangeCount;setTimeout((function(){if(t.domChangeCount==n&&(t.dom.blur(),t.focus(),!t.someProp("handleKeyDown",(function(e){return e(t,pa(8,"Backspace"))})))){var e=t.state.selection.$cursor;e&&e.pos>0&&t.dispatch(t.state.tr.delete(e.pos-1,e.pos).scrollIntoView())}}),50)}},jc)_c[hl]=jc[hl];function pl(t,e){if(t==e)return!0;for(var n in t)if(t[n]!==e[n])return!1;for(var r in e)if(!(r in t))return!1;return!0}var fl=function(t,e){this.spec=e||yl,this.side=this.spec.side||0,this.toDOM=t};fl.prototype.map=function(t,e,n,r){var o=t.mapResult(e.from+r,this.side<0?-1:1),i=o.pos;return o.deleted?null:new ml(i-n,i-n,this)},fl.prototype.valid=function(){return!0},fl.prototype.eq=function(t){return this==t||t instanceof fl&&(this.spec.key&&this.spec.key==t.spec.key||this.toDOM==t.toDOM&&pl(this.spec,t.spec))};var dl=function(t,e){this.spec=e||yl,this.attrs=t};dl.prototype.map=function(t,e,n,r){var o=t.map(e.from+r,this.spec.inclusiveStart?-1:1)-n,i=t.map(e.to+r,this.spec.inclusiveEnd?1:-1)-n;return o>=i?null:new ml(o,i,this)},dl.prototype.valid=function(t,e){return e.from<e.to},dl.prototype.eq=function(t){return this==t||t instanceof dl&&pl(this.attrs,t.attrs)&&pl(this.spec,t.spec)},dl.is=function(t){return t.type instanceof dl};var ul=function(t,e){this.spec=e||yl,this.attrs=t};ul.prototype.map=function(t,e,n,r){var o=t.mapResult(e.from+r,1);if(o.deleted)return null;var i=t.mapResult(e.to+r,-1);return i.deleted||i.pos<=o.pos?null:new ml(o.pos-n,i.pos-n,this)},ul.prototype.valid=function(t,e){var n,r=t.content.findIndex(e.from),o=r.index,i=r.offset;return i==e.from&&!(n=t.child(o)).isText&&i+n.nodeSize==e.to},ul.prototype.eq=function(t){return this==t||t instanceof ul&&pl(this.attrs,t.attrs)&&pl(this.spec,t.spec)};var ml=function(t,e,n){this.from=t,this.to=e,this.type=n},vl={spec:{configurable:!0},inline:{configurable:!0}};ml.prototype.copy=function(t,e){return new ml(t,e,this.type)},ml.prototype.eq=function(t,e){return void 0===e&&(e=0),this.type.eq(t.type)&&this.from+e==t.from&&this.to+e==t.to},ml.prototype.map=function(t,e,n){return this.type.map(t,this,e,n)},ml.widget=function(t,e,n){return new ml(t,t,new fl(e,n))},ml.inline=function(t,e,n,r){return new ml(t,e,new dl(n,r))},ml.node=function(t,e,n,r){return new ml(t,e,new ul(n,r))},vl.spec.get=function(){return this.type.spec},vl.inline.get=function(){return this.type instanceof dl},Object.defineProperties(ml.prototype,vl);var gl=[],yl={},wl=function(t,e){this.local=t&&t.length?t:gl,this.children=e&&e.length?e:gl};wl.create=function(t,e){return e.length?Ml(e,t,0,yl):bl},wl.prototype.find=function(t,e,n){var r=[];return this.findInner(null==t?0:t,null==e?1e9:e,r,0,n),r},wl.prototype.findInner=function(t,e,n,r,o){for(var i=0;i<this.local.length;i++){var s=this.local[i];s.from<=e&&s.to>=t&&(!o||o(s.spec))&&n.push(s.copy(s.from+r,s.to+r))}for(var a=0;a<this.children.length;a+=3)if(this.children[a]<e&&this.children[a+1]>t){var c=this.children[a]+1;this.children[a+2].findInner(t-c,e-c,n,r+c,o)}},wl.prototype.map=function(t,e,n){return this==bl||0==t.maps.length?this:this.mapInner(t,e,0,0,n||yl)},wl.prototype.mapInner=function(t,e,n,r,o){for(var i,s=0;s<this.local.length;s++){var a=this.local[s].map(t,n,r);a&&a.type.valid(e,a)?(i||(i=[])).push(a):o.onRemove&&o.onRemove(this.local[s].spec)}return this.children.length?function(t,e,n,r,o,i,s){for(var a=t.slice(),c=function(t,e,n,r){for(var s=0;s<a.length;s+=3){var c=a[s+1],l=void 0;-1==c||t>c+i||(e>=a[s]+i?a[s+1]=-1:n>=o&&(l=r-n-(e-t))&&(a[s]+=l,a[s+1]+=l))}},l=0;l<n.maps.length;l++)n.maps[l].forEach(c);for(var h=!1,p=0;p<a.length;p+=3)if(-1==a[p+1]){var f=n.map(t[p]+i),d=f-o;if(d<0||d>=r.content.size){h=!0;continue}var u=n.map(t[p+1]+i,-1)-o,m=r.content.findIndex(d),v=m.index,g=m.offset,y=r.maybeChild(v);if(y&&g==d&&g+y.nodeSize==u){var w=a[p+2].mapInner(n,y,f+1,t[p]+i+1,s);w!=bl?(a[p]=d,a[p+1]=u,a[p+2]=w):(a[p+1]=-2,h=!0)}else h=!0}if(h){var b=Ml(function(t,e,n,r,o,i,s){function a(t,e){for(var i=0;i<t.local.length;i++){var c=t.local[i].map(r,o,e);c?n.push(c):s.onRemove&&s.onRemove(t.local[i].spec)}for(var l=0;l<t.children.length;l+=3)a(t.children[l+2],t.children[l]+e+1)}for(var c=0;c<t.length;c+=3)-1==t[c+1]&&a(t[c+2],e[c]+i+1);return n}(a,t,e||[],n,o,i,s),r,0,s);e=b.local;for(var x=0;x<a.length;x+=3)a[x+1]<0&&(a.splice(x,3),x-=3);for(var k=0,S=0;k<b.children.length;k+=3){for(var C=b.children[k];S<a.length&&a[S]<C;)S+=3;a.splice(S,0,b.children[k],b.children[k+1],b.children[k+2])}}return new wl(e&&e.sort(Ol),a)}(this.children,i,t,e,n,r,o):i?new wl(i.sort(Ol)):bl},wl.prototype.add=function(t,e){return e.length?this==bl?wl.create(t,e):this.addInner(t,e,0):this},wl.prototype.addInner=function(t,e,n){var r,o=this,i=0;t.forEach((function(t,s){var a,c=s+n;if(a=Sl(e,t,c)){for(r||(r=o.children.slice());i<r.length&&r[i]<s;)i+=3;r[i]==s?r[i+2]=r[i+2].addInner(t,a,c+1):r.splice(i,0,s,s+t.nodeSize,Ml(a,t,c+1,yl)),i+=3}}));for(var s=kl(i?Cl(e):e,-n),a=0;a<s.length;a++)s[a].type.valid(t,s[a])||s.splice(a--,1);return new wl(s.length?this.local.concat(s).sort(Ol):this.local,r||this.children)},wl.prototype.remove=function(t){return 0==t.length||this==bl?this:this.removeInner(t,0)},wl.prototype.removeInner=function(t,e){for(var n=this.children,r=this.local,o=0;o<n.length;o+=3){for(var i=void 0,s=n[o]+e,a=n[o+1]+e,c=0,l=void 0;c<t.length;c++)(l=t[c])&&l.from>s&&l.to<a&&(t[c]=null,(i||(i=[])).push(l));if(i){n==this.children&&(n=this.children.slice());var h=n[o+2].removeInner(i,s+1);h!=bl?n[o+2]=h:(n.splice(o,3),o-=3)}}if(r.length)for(var p=0,f=void 0;p<t.length;p++)if(f=t[p])for(var d=0;d<r.length;d++)r[d].eq(f,e)&&(r==this.local&&(r=this.local.slice()),r.splice(d--,1));return n==this.children&&r==this.local?this:r.length||n.length?new wl(r,n):bl},wl.prototype.forChild=function(t,e){if(this==bl)return this;if(e.isLeaf)return wl.empty;for(var n,r,o=0;o<this.children.length;o+=3)if(this.children[o]>=t){this.children[o]==t&&(n=this.children[o+2]);break}for(var i=t+1,s=i+e.content.size,a=0;a<this.local.length;a++){var c=this.local[a];if(c.from<s&&c.to>i&&c.type instanceof dl){var l=Math.max(i,c.from)-i,h=Math.min(s,c.to)-i;l<h&&(r||(r=[])).push(c.copy(l,h))}}if(r){var p=new wl(r.sort(Ol));return n?new xl([p,n]):p}return n||bl},wl.prototype.eq=function(t){if(this==t)return!0;if(!(t instanceof wl)||this.local.length!=t.local.length||this.children.length!=t.children.length)return!1;for(var e=0;e<this.local.length;e++)if(!this.local[e].eq(t.local[e]))return!1;for(var n=0;n<this.children.length;n+=3)if(this.children[n]!=t.children[n]||this.children[n+1]!=t.children[n+1]||!this.children[n+2].eq(t.children[n+2]))return!1;return!0},wl.prototype.locals=function(t){return Nl(this.localsInner(t))},wl.prototype.localsInner=function(t){if(this==bl)return gl;if(t.inlineContent||!this.local.some(dl.is))return this.local;for(var e=[],n=0;n<this.local.length;n++)this.local[n].type instanceof dl||e.push(this.local[n]);return e};var bl=new wl;wl.empty=bl,wl.removeOverlap=Nl;var xl=function(t){this.members=t};function kl(t,e){if(!e||!t.length)return t;for(var n=[],r=0;r<t.length;r++){var o=t[r];n.push(new ml(o.from+e,o.to+e,o.type))}return n}function Sl(t,e,n){if(e.isLeaf)return null;for(var r=n+e.nodeSize,o=null,i=0,s=void 0;i<t.length;i++)(s=t[i])&&s.from>n&&s.to<r&&((o||(o=[])).push(s),t[i]=null);return o}function Cl(t){for(var e=[],n=0;n<t.length;n++)null!=t[n]&&e.push(t[n]);return e}function Ml(t,e,n,r){var o=[],i=!1;e.forEach((function(e,s){var a=Sl(t,e,s+n);if(a){i=!0;var c=Ml(a,e,n+s+1,r);c!=bl&&o.push(s,s+e.nodeSize,c)}}));for(var s=kl(i?Cl(t):t,-n).sort(Ol),a=0;a<s.length;a++)s[a].type.valid(e,s[a])||(r.onRemove&&r.onRemove(s[a].spec),s.splice(a--,1));return s.length||o.length?new wl(s,o):bl}function Ol(t,e){return t.from-e.from||t.to-e.to}function Nl(t){for(var e=t,n=0;n<e.length-1;n++){var r=e[n];if(r.from!=r.to)for(var o=n+1;o<e.length;o++){var i=e[o];if(i.from!=r.from){i.from<r.to&&(e==t&&(e=t.slice()),e[n]=r.copy(r.from,i.from),Dl(e,o,r.copy(i.from,r.to)));break}i.to!=r.to&&(e==t&&(e=t.slice()),e[o]=i.copy(i.from,r.to),Dl(e,o+1,i.copy(r.to,i.to)))}}return e}function Dl(t,e,n){for(;e<t.length&&Ol(n,t[e])>0;)e++;t.splice(e,0,n)}function Tl(t){var e=[];return t.someProp("decorations",(function(n){var r=n(t.state);r&&r!=bl&&e.push(r)})),t.cursorWrapper&&e.push(wl.create(t.state.doc,[t.cursorWrapper.deco])),xl.from(e)}xl.prototype.map=function(t,e){var n=this.members.map((function(n){return n.map(t,e,yl)}));return xl.from(n)},xl.prototype.forChild=function(t,e){if(e.isLeaf)return wl.empty;for(var n=[],r=0;r<this.members.length;r++){var o=this.members[r].forChild(t,e);o!=bl&&(o instanceof xl?n=n.concat(o.members):n.push(o))}return xl.from(n)},xl.prototype.eq=function(t){if(!(t instanceof xl)||t.members.length!=this.members.length)return!1;for(var e=0;e<this.members.length;e++)if(!this.members[e].eq(t.members[e]))return!1;return!0},xl.prototype.locals=function(t){for(var e,n=!0,r=0;r<this.members.length;r++){var o=this.members[r].localsInner(t);if(o.length)if(e){n&&(e=e.slice(),n=!1);for(var i=0;i<o.length;i++)e.push(o[i])}else e=o}return e?Nl(n?e:e.sort(Ol)):gl},xl.from=function(t){switch(t.length){case 0:return bl;case 1:return t[0];default:return new xl(t)}};var El=function(t,e){this._props=e,this.state=e.state,this.directPlugins=e.plugins||[],this.directPlugins.forEach(Bl),this.dispatch=this.dispatch.bind(this),this._root=null,this.focused=!1,this.trackWrites=null,this.dom=t&&t.mount||document.createElement("div"),t&&(t.appendChild?t.appendChild(this.dom):t.apply?t(this.dom):t.mount&&(this.mounted=!0)),this.editable=Il(this),this.markCursor=null,this.cursorWrapper=null,zl(this),this.nodeViews=Rl(this),this.docView=$a(this.state.doc,Pl(this),Tl(this),this.dom,this),this.lastSelectedViewDesc=null,this.dragging=null,function(t){t.shiftKey=!1,t.mouseDown=null,t.lastKeyCode=null,t.lastKeyCodeTime=0,t.lastClick={time:0,x:0,y:0,type:""},t.lastSelectionOrigin=null,t.lastSelectionTime=0,t.lastIOSEnter=0,t.lastIOSEnterFallbackTimeout=null,t.lastAndroidDelete=0,t.composing=!1,t.composingTimeout=null,t.compositionNodes=[],t.compositionEndedAt=-2e8,t.domObserver=new $c(t,(function(e,n,r,o){return function(t,e,n,r,o){if(e<0){var i=t.lastSelectionTime>Date.now()-50?t.lastSelectionOrigin:null,s=nc(t,i);if(s&&!t.state.selection.eq(s)){var a=t.state.tr.setSelection(s);"pointer"==i?a.setMeta("pointer",!0):"key"==i&&a.scrollIntoView(),t.dispatch(a)}}else{var c=t.state.doc.resolve(e),l=c.sharedDepth(n);e=c.before(l+1),n=t.state.doc.resolve(n).after(l+1);var h=t.state.selection,p=function(t,e,n){var r=t.docView.parseRange(e,n),o=r.node,i=r.fromOffset,s=r.toOffset,a=r.from,c=r.to,l=t.root.getSelection(),h=null,p=l.anchorNode;if(p&&t.dom.contains(1==p.nodeType?p:p.parentNode)&&(h=[{node:p,offset:l.anchorOffset}],ha(l)||h.push({node:l.focusNode,offset:l.focusOffset})),Gs.chrome&&8===t.lastKeyCode)for(var f=s;f>i;f--){var d=o.childNodes[f-1],u=d.pmViewDesc;if("BR"==d.nodeName&&!u){s=f;break}if(!u||u.size)break}var m=t.state.doc,v=t.someProp("domParser")||Rs.fromSchema(t.state.schema),g=m.resolve(a),y=null,w=v.parse(o,{topNode:g.parent,topMatch:g.parent.contentMatchAt(g.index()),topOpen:!0,from:i,to:s,preserveWhitespace:!g.parent.type.spec.code||"full",editableContent:!0,findPositions:h,ruleFromNode:Mc,context:g});if(h&&null!=h[0].pos){var b=h[0].pos,x=h[1]&&h[1].pos;null==x&&(x=b),y={anchor:b+a,head:x+a}}return{doc:w,sel:y,from:a,to:c}}(t,e,n);if(Gs.chrome&&t.cursorWrapper&&p.sel&&p.sel.anchor==t.cursorWrapper.deco.from){var f=t.cursorWrapper.deco.type.toDOM.nextSibling,d=f&&f.nodeValue?f.nodeValue.length:1;p.sel={anchor:p.sel.anchor+d,head:p.sel.anchor+d}}var u,m,v=t.state.doc,g=v.slice(p.from,p.to);8===t.lastKeyCode&&Date.now()-100<t.lastKeyCodeTime?(u=t.state.selection.to,m="end"):(u=t.state.selection.from,m="start"),t.lastKeyCode=null;var y=function(t,e,n,r,o){var i=t.findDiffStart(e,n);if(null==i)return null;var s=t.findDiffEnd(e,n+t.size,n+e.size),a=s.a,c=s.b;return"end"==o&&(r-=a+Math.max(0,i-Math.min(a,c))-i),a<i&&t.size<e.size?(c=(i-=r<=i&&r>=a?i-r:0)+(c-a),a=i):c<i&&(a=(i-=r<=i&&r>=c?i-r:0)+(a-c),c=i),{start:i,endA:a,endB:c}}(g.content,p.doc.content,p.from,u,m);if(!y){if(!(r&&h instanceof de&&!h.empty&&h.$head.sameParent(h.$anchor))||t.composing||p.sel&&p.sel.anchor!=p.sel.head){if((Gs.ios&&t.lastIOSEnter>Date.now()-225||Gs.android)&&o.some((function(t){return"DIV"==t.nodeName||"P"==t.nodeName}))&&t.someProp("handleKeyDown",(function(e){return e(t,pa(13,"Enter"))})))return void(t.lastIOSEnter=0);if(p.sel){var w=Oc(t,t.state.doc,p.sel);w&&!w.eq(t.state.selection)&&t.dispatch(t.state.tr.setSelection(w))}return}y={start:h.from,endA:h.to,endB:h.to}}t.domChangeCount++,t.state.selection.from<t.state.selection.to&&y.start==y.endB&&t.state.selection instanceof de&&(y.start>t.state.selection.from&&y.start<=t.state.selection.from+2?y.start=t.state.selection.from:y.endA<t.state.selection.to&&y.endA>=t.state.selection.to-2&&(y.endB+=t.state.selection.to-y.endA,y.endA=t.state.selection.to)),Gs.ie&&Gs.ie_version<=11&&y.endB==y.start+1&&y.endA==y.start&&y.start>p.from&&"  "==p.doc.textBetween(y.start-p.from-1,y.start-p.from+1)&&(y.start--,y.endA--,y.endB--);var b,x=p.doc.resolveNoCache(y.start-p.from),k=p.doc.resolveNoCache(y.endB-p.from),S=x.sameParent(k)&&x.parent.inlineContent;if((Gs.ios&&t.lastIOSEnter>Date.now()-225&&(!S||o.some((function(t){return"DIV"==t.nodeName||"P"==t.nodeName})))||!S&&x.pos<p.doc.content.size&&(b=he.findFrom(p.doc.resolve(x.pos+1),1,!0))&&b.head==k.pos)&&t.someProp("handleKeyDown",(function(e){return e(t,pa(13,"Enter"))})))t.lastIOSEnter=0;else if(t.state.selection.anchor>y.start&&function(t,e,n,r,o){if(!r.parent.isTextblock||n-e<=o.pos-r.pos||Nc(r,!0,!1)<o.pos)return!1;var i=t.resolve(e);if(i.parentOffset<i.parent.content.size||!i.parent.isTextblock)return!1;var s=t.resolve(Nc(i,!0,!0));return!(!s.parent.isTextblock||s.pos>n||Nc(s,!0,!1)<n)&&r.parent.content.cut(r.parentOffset).eq(s.parent.content)}(v,y.start,y.endA,x,k)&&t.someProp("handleKeyDown",(function(e){return e(t,pa(8,"Backspace"))})))Gs.android&&Gs.chrome&&t.domObserver.suppressSelectionUpdates();else{Gs.chrome&&Gs.android&&y.toB==y.from&&(t.lastAndroidDelete=Date.now()),Gs.android&&!S&&x.start()!=k.start()&&0==k.parentOffset&&x.depth==k.depth&&p.sel&&p.sel.anchor==p.sel.head&&p.sel.head==y.endA&&(y.endB-=2,k=p.doc.resolveNoCache(y.endB-p.from),setTimeout((function(){t.someProp("handleKeyDown",(function(e){return e(t,pa(13,"Enter"))}))}),20));var C,M,O,N,D=y.start,T=y.endA;if(S)if(x.pos==k.pos)Gs.ie&&Gs.ie_version<=11&&0==x.parentOffset&&(t.domObserver.suppressSelectionUpdates(),setTimeout((function(){return oc(t)}),20)),C=t.state.tr.delete(D,T),M=v.resolve(y.start).marksAcross(v.resolve(y.endA));else if(y.endA==y.endB&&(N=v.resolve(y.start))&&(O=function(t,e){for(var n,r,o,i=t.firstChild.marks,s=e.firstChild.marks,a=i,c=s,l=0;l<s.length;l++)a=s[l].removeFromSet(a);for(var h=0;h<i.length;h++)c=i[h].removeFromSet(c);if(1==a.length&&0==c.length)r=a[0],n="add",o=function(t){return t.mark(r.addToSet(t.marks))};else{if(0!=a.length||1!=c.length)return null;r=c[0],n="remove",o=function(t){return t.mark(r.removeFromSet(t.marks))}}for(var p=[],f=0;f<e.childCount;f++)p.push(o(e.child(f)));if(Ri.from(p).eq(t))return{mark:r,type:n}}(x.parent.content.cut(x.parentOffset,k.parentOffset),N.parent.content.cut(N.parentOffset,y.endA-N.start()))))C=t.state.tr,"add"==O.type?C.addMark(D,T,O.mark):C.removeMark(D,T,O.mark);else if(x.parent.child(x.index()).isText&&x.index()==k.index()-(k.textOffset?0:1)){var E=x.parent.textBetween(x.parentOffset,k.parentOffset);if(t.someProp("handleTextInput",(function(e){return e(t,D,T,E)})))return;C=t.state.tr.insertText(E,D,T)}if(C||(C=t.state.tr.replace(D,T,p.doc.slice(y.start-p.from,y.endB-p.from))),p.sel){var A=Oc(t,C.doc,p.sel);A&&!(Gs.chrome&&Gs.android&&t.composing&&A.empty&&(y.start!=y.endB||t.lastAndroidDelete<Date.now()-100)&&(A.head==D||A.head==C.mapping.map(T)-1)||Gs.ie&&A.empty&&A.head==D)&&C.setSelection(A)}M&&C.ensureMarks(M),t.dispatch(C.scrollIntoView())}}}(t,e,n,r,o)})),t.domObserver.start(),t.domChangeCount=0,t.eventHandlers=Object.create(null);var e=function(e){var n=_c[e];t.dom.addEventListener(e,t.eventHandlers[e]=function(e){!function(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(var n=e.target;n!=t.dom;n=n.parentNode)if(!n||11==n.nodeType||n.pmViewDesc&&n.pmViewDesc.stopEvent(e))return!1;return!0}(t,e)||Kc(t,e)||!t.editable&&e.type in jc||n(t,e)})};for(var n in _c)e(n);Gs.safari&&t.dom.addEventListener("input",(function(){return null})),Jc(t)}(this),this.prevDirectPlugins=[],this.pluginViews=[],this.updatePluginViews()},Al={props:{configurable:!0},root:{configurable:!0}};function Pl(t){var e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(t.editable),e.translate="no",t.someProp("attributes",(function(n){if("function"==typeof n&&(n=n(t.state)),n)for(var r in n)"class"==r?e.class+=" "+n[r]:e[r]||"contenteditable"==r||"nodeName"==r||(e[r]=String(n[r]))})),[ml.node(0,t.state.doc.content.size,e)]}function zl(t){if(t.markCursor){var e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),t.cursorWrapper={dom:e,deco:ml.widget(t.state.selection.head,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function Il(t){return!t.someProp("editable",(function(e){return!1===e(t.state)}))}function Rl(t){var e={};return t.someProp("nodeViews",(function(t){for(var n in t)Object.prototype.hasOwnProperty.call(e,n)||(e[n]=t[n])})),e}function Bl(t){if(t.spec.state||t.spec.filterTransaction||t.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}Al.props.get=function(){if(this._props.state!=this.state){var t=this._props;for(var e in this._props={},t)this._props[e]=t[e];this._props.state=this.state}return this._props},El.prototype.update=function(t){t.handleDOMEvents!=this._props.handleDOMEvents&&Jc(this),this._props=t,t.plugins&&(t.plugins.forEach(Bl),this.directPlugins=t.plugins),this.updateStateInner(t.state,!0)},El.prototype.setProps=function(t){var e={};for(var n in this._props)e[n]=this._props[n];for(var r in e.state=this.state,t)e[r]=t[r];this.update(e)},El.prototype.updateState=function(t){this.updateStateInner(t,this.state.plugins!=t.plugins)},El.prototype.updateStateInner=function(t,e){var n=this,r=this.state,o=!1,i=!1;if(t.storedMarks&&this.composing&&(ol(this),i=!0),this.state=t,e){var s=Rl(this);(function(t,e){var n=0,r=0;for(var o in t){if(t[o]!=e[o])return!0;n++}for(var i in e)r++;return n!=r})(s,this.nodeViews)&&(this.nodeViews=s,o=!0),Jc(this)}this.editable=Il(this),zl(this);var a=Tl(this),c=Pl(this),l=e?"reset":t.scrollToSelection>r.scrollToSelection?"to selection":"preserve",h=o||!this.docView.matchesNode(t.doc,c,a);!h&&t.selection.eq(r.selection)||(i=!0);var p,f,d,u,m,v,g,y="preserve"==l&&i&&null==this.dom.style.overflowAnchor&&function(t){for(var e,n,r=t.dom.getBoundingClientRect(),o=Math.max(0,r.top),i=(r.left+r.right)/2,s=o+1;s<Math.min(innerHeight,r.bottom);s+=5){var a=t.root.elementFromPoint(i,s);if(a!=t.dom&&t.dom.contains(a)){var c=a.getBoundingClientRect();if(c.top>=o-20){e=a,n=c.top;break}}}return{refDOM:e,refTop:n,stack:va(t.dom)}}(this);if(i){this.domObserver.stop();var w=h&&(Gs.ie||Gs.chrome)&&!this.composing&&!r.selection.empty&&!t.selection.empty&&(p=r.selection,f=t.selection,d=Math.min(p.$anchor.sharedDepth(p.head),f.$anchor.sharedDepth(f.head)),p.$anchor.start(d)!=f.$anchor.start(d));if(h){var b=Gs.chrome?this.trackWrites=this.root.getSelection().focusNode:null;!o&&this.docView.update(t.doc,c,a,this)||(this.docView.updateOuterDeco([]),this.docView.destroy(),this.docView=$a(t.doc,c,a,this.dom,this)),b&&!this.trackWrites&&(w=!0)}w||!(this.mouseDown&&this.domObserver.currentSelection.eq(this.root.getSelection())&&function(t){var e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.root.getSelection();return ia(e.node,e.offset,n.anchorNode,n.anchorOffset)}(this))?oc(this,w):(lc(this,t.selection),this.domObserver.setCurSelection()),this.domObserver.start()}if(this.updatePluginViews(r),"reset"==l)this.dom.scrollTop=0;else if("to selection"==l){var x=this.root.getSelection().focusNode;this.someProp("handleScrollToSelection",(function(t){return t(n)}))||(t.selection instanceof me?ma(this,this.docView.domAfterPos(t.selection.from).getBoundingClientRect(),x):ma(this,this.coordsAtPos(t.selection.head,1),x))}else y&&(m=(u=y).refDOM,v=u.refTop,ga(u.stack,0==(g=m?m.getBoundingClientRect().top:0)?0:g-v))},El.prototype.destroyPluginViews=function(){for(var t;t=this.pluginViews.pop();)t.destroy&&t.destroy()},El.prototype.updatePluginViews=function(t){if(t&&t.plugins==this.state.plugins&&this.directPlugins==this.prevDirectPlugins)for(var e=0;e<this.pluginViews.length;e++){var n=this.pluginViews[e];n.update&&n.update(this,t)}else{this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(var r=0;r<this.directPlugins.length;r++){var o=this.directPlugins[r];o.spec.view&&this.pluginViews.push(o.spec.view(this))}for(var i=0;i<this.state.plugins.length;i++){var s=this.state.plugins[i];s.spec.view&&this.pluginViews.push(s.spec.view(this))}}},El.prototype.someProp=function(t,e){var n,r=this._props&&this._props[t];if(null!=r&&(n=e?e(r):r))return n;for(var o=0;o<this.directPlugins.length;o++){var i=this.directPlugins[o].props[t];if(null!=i&&(n=e?e(i):i))return n}var s=this.state.plugins;if(s)for(var a=0;a<s.length;a++){var c=s[a].props[t];if(null!=c&&(n=e?e(c):c))return n}},El.prototype.hasFocus=function(){return this.root.activeElement==this.dom},El.prototype.focus=function(){this.domObserver.stop(),this.editable&&function(t){if(t.setActive)return t.setActive();if(ya)return t.focus(ya);var e=va(t);t.focus(null==ya?{get preventScroll(){return ya={preventScroll:!0},!0}}:void 0),ya||(ya=!1,ga(e,0))}(this.dom),oc(this),this.domObserver.start()},Al.root.get=function(){var t=this._root;if(null==t)for(var e=this.dom.parentNode;e;e=e.parentNode)if(9==e.nodeType||11==e.nodeType&&e.host)return e.getSelection||(Object.getPrototypeOf(e).getSelection=function(){return document.getSelection()}),this._root=e;return t||document},El.prototype.posAtCoords=function(t){return ka(this,t)},El.prototype.coordsAtPos=function(t,e){return void 0===e&&(e=1),Ma(this,t,e)},El.prototype.domAtPos=function(t,e){return void 0===e&&(e=0),this.docView.domFromPos(t,e)},El.prototype.nodeDOM=function(t){var e=this.docView.descAt(t);return e?e.nodeDOM:null},El.prototype.posAtDOM=function(t,e,n){void 0===n&&(n=-1);var r=this.docView.posFromDOM(t,e,n);if(null==r)throw new RangeError("DOM position not inside the editor");return r},El.prototype.endOfTextblock=function(t,e){return function(t,e,n){return Ea==e&&Aa==n?Pa:(Ea=e,Aa=n,Pa="up"==n||"down"==n?function(t,e,n){var r=e.selection,o="up"==n?r.$from:r.$to;return Da(t,e,(function(){for(var e=t.docView.domFromPos(o.pos,"up"==n?-1:1).node;;){var r=t.docView.nearestDesc(e,!0);if(!r)break;if(r.node.isBlock){e=r.dom;break}e=r.dom.parentNode}for(var i=Ma(t,o.pos,1),s=e.firstChild;s;s=s.nextSibling){var a=void 0;if(1==s.nodeType)a=s.getClientRects();else{if(3!=s.nodeType)continue;a=oa(s,0,s.nodeValue.length).getClientRects()}for(var c=0;c<a.length;c++){var l=a[c];if(l.bottom>l.top+1&&("up"==n?i.top-l.top>2*(l.bottom-i.top):l.bottom-i.bottom>2*(i.bottom-l.top)))return!1}}return!0}))}(t,e,n):function(t,e,n){var r=e.selection.$head;if(!r.parent.isTextblock)return!1;var o=r.parentOffset,i=!o,s=o==r.parent.content.size,a=t.root.getSelection();return Ta.test(r.parent.textContent)&&a.modify?Da(t,e,(function(){var e=a.getRangeAt(0),o=a.focusNode,i=a.focusOffset,s=a.caretBidiLevel;a.modify("move",n,"character");var c=!(r.depth?t.docView.domAfterPos(r.before()):t.dom).contains(1==a.focusNode.nodeType?a.focusNode:a.focusNode.parentNode)||o==a.focusNode&&i==a.focusOffset;return a.removeAllRanges(),a.addRange(e),null!=s&&(a.caretBidiLevel=s),c})):"left"==n||"backward"==n?i:s}(t,e,n))}(this,e||this.state,t)},El.prototype.destroy=function(){this.docView&&(function(t){for(var e in t.domObserver.stop(),t.eventHandlers)t.dom.removeEventListener(e,t.eventHandlers[e]);clearTimeout(t.composingTimeout),clearTimeout(t.lastIOSEnterFallbackTimeout)}(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Tl(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null)},El.prototype.dispatchEvent=function(t){return function(t,e){Kc(t,e)||!_c[e.type]||!t.editable&&e.type in jc||_c[e.type](t,e)}(this,t)},El.prototype.dispatch=function(t){var e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))},Object.defineProperties(El.prototype,Al);var Vl=function(t){function e(e){t.call(this,e,e)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.map=function(n,r){var o=n.resolve(r.map(this.head));return e.valid(o)?new e(o):t.near(o)},e.prototype.content=function(){return p.empty},e.prototype.eq=function(t){return t instanceof e&&t.head==this.head},e.prototype.toJSON=function(){return{type:"gapcursor",pos:this.head}},e.fromJSON=function(t,n){if("number"!=typeof n.pos)throw new RangeError("Invalid input for GapCursor.fromJSON");return new e(t.resolve(n.pos))},e.prototype.getBookmark=function(){return new Fl(this.anchor)},e.valid=function(t){var e=t.parent;if(e.isTextblock||!function(t){for(var e=t.depth;e>=0;e--){var n=t.index(e);if(0!=n)for(var r=t.node(e).child(n-1);;r=r.lastChild){if(0==r.childCount&&!r.inlineContent||r.isAtom||r.type.spec.isolating)return!0;if(r.inlineContent)return!1}}return!0}(t)||!function(t){for(var e=t.depth;e>=0;e--){var n=t.indexAfter(e),r=t.node(e);if(n!=r.childCount)for(var o=r.child(n);;o=o.firstChild){if(0==o.childCount&&!o.inlineContent||o.isAtom||o.type.spec.isolating)return!0;if(o.inlineContent)return!1}}return!0}(t))return!1;var n=e.type.spec.allowGapCursor;if(null!=n)return n;var r=e.contentMatchAt(t.index()).defaultType;return r&&r.isTextblock},e.findFrom=function(t,n,r){t:for(;;){if(!r&&e.valid(t))return t;for(var o=t.pos,i=null,s=t.depth;;s--){var a=t.node(s);if(n>0?t.indexAfter(s)<a.childCount:t.index(s)>0){i=a.child(n>0?t.indexAfter(s):t.index(s)-1);break}if(0==s)return null;o+=n;var c=t.doc.resolve(o);if(e.valid(c))return c}for(;;){var l=n>0?i.firstChild:i.lastChild;if(!l){if(i.isAtom&&!i.isText&&!me.isSelectable(i)){t=t.doc.resolve(o+i.nodeSize*n),r=!1;continue t}break}i=l,o+=n;var h=t.doc.resolve(o);if(e.valid(h))return h}return null}},e}(he);Vl.prototype.visible=!1,he.jsonID("gapcursor",Vl);var Fl=function(t){this.pos=t};Fl.prototype.map=function(t){return new Fl(t.map(this.pos))},Fl.prototype.resolve=function(t){var e=t.resolve(this.pos);return Vl.valid(e)?new Vl(e):he.near(e)};var ql=Jo({ArrowLeft:$l("horiz",-1),ArrowRight:$l("horiz",1),ArrowUp:$l("vert",-1),ArrowDown:$l("vert",1)});function $l(t,e){var n="vert"==t?e>0?"down":"up":e>0?"right":"left";return function(t,r,o){var i=t.selection,s=e>0?i.$to:i.$from,a=i.empty;if(i instanceof de){if(!o.endOfTextblock(n)||0==s.depth)return!1;a=!1,s=t.doc.resolve(e>0?s.after():s.before())}var c=Vl.findFrom(s,e,a);return!!c&&(r&&r(t.tr.setSelection(new Vl(c))),!0)}}function Ll(){var t=arguments[0];"string"==typeof t&&(t=document.createElement(t));var e=1,n=arguments[1];if(n&&"object"==typeof n&&null==n.nodeType&&!Array.isArray(n)){for(var r in n)if(Object.prototype.hasOwnProperty.call(n,r)){var o=n[r];"string"==typeof o?t.setAttribute(r,o):null!=o&&(t[r]=o)}e++}for(;e<arguments.length;e++)_l(t,arguments[e]);return t}function _l(t,e){if("string"==typeof e)t.appendChild(document.createTextNode(e));else if(null==e);else if(null!=e.nodeType)t.appendChild(e);else{if(!Array.isArray(e))throw new RangeError("Unsupported child node: "+e);for(var n=0;n<e.length;n++)_l(t,e[n])}}var jl="http://www.w3.org/2000/svg",Wl="ProseMirror-icon";var Jl="ProseMirror-menu",Kl=function(t){this.spec=t};function Hl(t,e){return t._props.translate?t._props.translate(e):e}Kl.prototype.render=function(t){var e=this.spec,n=e.render?e.render(t):e.icon?function(t){var e=document.createElement("div");if(e.className=Wl,t.path){var n="pm-icon-"+function(t){for(var e=0,n=0;n<t.length;n++)e=(e<<5)-e+t.charCodeAt(n)|0;return e}(t.path).toString(16);document.getElementById(n)||function(t,e){var n=document.getElementById(Wl+"-collection");n||((n=document.createElementNS(jl,"svg")).id=Wl+"-collection",n.style.display="none",document.body.insertBefore(n,document.body.firstChild));var r=document.createElementNS(jl,"symbol");r.id=t,r.setAttribute("viewBox","0 0 "+e.width+" "+e.height),r.appendChild(document.createElementNS(jl,"path")).setAttribute("d",e.path),n.appendChild(r)}(n,t);var r=e.appendChild(document.createElementNS(jl,"svg"));r.style.width=t.width/t.height+"em",r.appendChild(document.createElementNS(jl,"use")).setAttributeNS("http://www.w3.org/1999/xlink","href",/([^#]*)/.exec(document.location)[1]+"#"+n)}else t.dom?e.appendChild(t.dom.cloneNode(!0)):(e.appendChild(document.createElement("span")).textContent=t.text||"",t.css&&(e.firstChild.style.cssText=t.css));return e}(e.icon):e.label?Ll("div",null,Hl(t,e.label)):null;if(!n)throw new RangeError("MenuItem without icon or label property");if(e.title){var r="function"==typeof e.title?e.title(t.state):e.title;n.setAttribute("title",Hl(t,r))}return e.class&&n.classList.add(e.class),e.css&&(n.style.cssText+=e.css),n.addEventListener("mousedown",(function(r){r.preventDefault(),n.classList.contains(Jl+"-disabled")||e.run(t.state,t.dispatch,t,r)})),{dom:n,update:function(t){if(e.select){var r=e.select(t);if(n.style.display=r?"":"none",!r)return!1}var o=!0;if(e.enable&&(o=e.enable(t)||!1,ch(n,Jl+"-disabled",!o)),e.active){var i=o&&e.active(t)||!1;ch(n,Jl+"-active",i)}return!0}}};var Ul={time:0,node:null};function Gl(t){Ul.time=Date.now(),Ul.node=t.target}function Xl(t){return Date.now()-100<Ul.time&&Ul.node&&t.contains(Ul.node)}var Yl=function(t,e){this.options=e||{},this.content=Array.isArray(t)?t:[t]};function Ql(t,e){for(var n=[],r=[],o=0;o<t.length;o++){var i=t[o].render(e),s=i.dom,a=i.update;n.push(Ll("div",{class:Jl+"-dropdown-item"},s)),r.push(a)}return{dom:n,update:Zl(r,n)}}function Zl(t,e){return function(n){for(var r=!1,o=0;o<t.length;o++){var i=t[o](n);e[o].style.display=i?"":"none",i&&(r=!0)}return r}}Yl.prototype.render=function(t){var e=this,n=Ql(this.content,t),r=Ll("div",{class:Jl+"-dropdown "+(this.options.class||""),style:this.options.css},Hl(t,this.options.label));this.options.title&&r.setAttribute("title",Hl(t,this.options.title));var o=Ll("div",{class:Jl+"-dropdown-wrap"},r),i=null,s=null,a=function(){i&&i.close()&&(i=null,window.removeEventListener("mousedown",s))};return r.addEventListener("mousedown",(function(t){t.preventDefault(),Gl(t),i?a():(i=e.expand(o,n.dom),window.addEventListener("mousedown",s=function(){Xl(o)||a()}))})),{dom:o,update:function(t){var e=n.update(t);return o.style.display=e?"":"none",e}}},Yl.prototype.expand=function(t,e){var n=Ll("div",{class:Jl+"-dropdown-menu "+(this.options.class||"")},e),r=!1;return t.appendChild(n),{close:function(){if(!r)return r=!0,t.removeChild(n),!0},node:n}};var th=function(t,e){this.options=e||{},this.content=Array.isArray(t)?t:[t]};th.prototype.render=function(t){var e=Ql(this.content,t),n=Ll("div",{class:Jl+"-submenu-label"},Hl(t,this.options.label)),r=Ll("div",{class:Jl+"-submenu-wrap"},n,Ll("div",{class:Jl+"-submenu"},e.dom)),o=null;return n.addEventListener("mousedown",(function(t){t.preventDefault(),Gl(t),ch(r,Jl+"-submenu-wrap-active"),o||window.addEventListener("mousedown",o=function(){Xl(r)||(r.classList.remove(Jl+"-submenu-wrap-active"),window.removeEventListener("mousedown",o),o=null)})})),{dom:r,update:function(t){var n=e.update(t);return r.style.display=n?"":"none",n}}};var eh={join:{width:800,height:900,path:"M0 75h800v125h-800z M0 825h800v-125h-800z M250 400h100v-100h100v100h100v100h-100v100h-100v-100h-100z"},lift:{width:1024,height:1024,path:"M219 310v329q0 7-5 12t-12 5q-8 0-13-5l-164-164q-5-5-5-13t5-13l164-164q5-5 13-5 7 0 12 5t5 12zM1024 749v109q0 7-5 12t-12 5h-987q-7 0-12-5t-5-12v-109q0-7 5-12t12-5h987q7 0 12 5t5 12zM1024 530v109q0 7-5 12t-12 5h-621q-7 0-12-5t-5-12v-109q0-7 5-12t12-5h621q7 0 12 5t5 12zM1024 310v109q0 7-5 12t-12 5h-621q-7 0-12-5t-5-12v-109q0-7 5-12t12-5h621q7 0 12 5t5 12zM1024 91v109q0 7-5 12t-12 5h-987q-7 0-12-5t-5-12v-109q0-7 5-12t12-5h987q7 0 12 5t5 12z"},selectParentNode:{text:"⬚",css:"font-weight: bold"},undo:{width:1024,height:1024,path:"M761 1024c113-206 132-520-313-509v253l-384-384 384-384v248c534-13 594 472 313 775z"},redo:{width:1024,height:1024,path:"M576 248v-248l384 384-384 384v-253c-446-10-427 303-313 509-280-303-221-789 313-775z"},strong:{width:805,height:1024,path:"M317 869q42 18 80 18 214 0 214-191 0-65-23-102-15-25-35-42t-38-26-46-14-48-6-54-1q-41 0-57 5 0 30-0 90t-0 90q0 4-0 38t-0 55 2 47 6 38zM309 442q24 4 62 4 46 0 81-7t62-25 42-51 14-81q0-40-16-70t-45-46-61-24-70-8q-28 0-74 7 0 28 2 86t2 86q0 15-0 45t-0 45q0 26 0 39zM0 950l1-53q8-2 48-9t60-15q4-6 7-15t4-19 3-18 1-21 0-19v-37q0-561-12-585-2-4-12-8t-25-6-28-4-27-2-17-1l-2-47q56-1 194-6t213-5q13 0 39 0t38 0q40 0 78 7t73 24 61 40 42 59 16 78q0 29-9 54t-22 41-36 32-41 25-48 22q88 20 146 76t58 141q0 57-20 102t-53 74-78 48-93 27-100 8q-25 0-75-1t-75-1q-60 0-175 6t-132 6z"},em:{width:585,height:1024,path:"M0 949l9-48q3-1 46-12t63-21q16-20 23-57 0-4 35-165t65-310 29-169v-14q-13-7-31-10t-39-4-33-3l10-58q18 1 68 3t85 4 68 1q27 0 56-1t69-4 56-3q-2 22-10 50-17 5-58 16t-62 19q-4 10-8 24t-5 22-4 26-3 24q-15 84-50 239t-44 203q-1 5-7 33t-11 51-9 47-3 32l0 10q9 2 105 17-1 25-9 56-6 0-18 0t-18 0q-16 0-49-5t-49-5q-78-1-117-1-29 0-81 5t-69 6z"},code:{width:896,height:1024,path:"M608 192l-96 96 224 224-224 224 96 96 288-320-288-320zM288 192l-288 320 288 320 96-96-224-224 224-224-96-96z"},link:{width:951,height:1024,path:"M832 694q0-22-16-38l-118-118q-16-16-38-16-24 0-41 18 1 1 10 10t12 12 8 10 7 14 2 15q0 22-16 38t-38 16q-8 0-15-2t-14-7-10-8-12-12-10-10q-18 17-18 41 0 22 16 38l117 118q15 15 38 15 22 0 38-14l84-83q16-16 16-38zM430 292q0-22-16-38l-117-118q-16-16-38-16-22 0-38 15l-84 83q-16 16-16 38 0 22 16 38l118 118q15 15 38 15 24 0 41-17-1-1-10-10t-12-12-8-10-7-14-2-15q0-22 16-38t38-16q8 0 15 2t14 7 10 8 12 12 10 10q18-17 18-41zM941 694q0 68-48 116l-84 83q-47 47-116 47-69 0-116-48l-117-118q-47-47-47-116 0-70 50-119l-50-50q-49 50-118 50-68 0-116-48l-118-118q-48-48-48-116t48-116l84-83q47-47 116-47 69 0 116 48l117 118q47 47 47 116 0 70-50 119l50 50q49-50 118-50 68 0 116 48l118 118q48 48 48 116z"},bulletList:{width:768,height:896,path:"M0 512h128v-128h-128v128zM0 256h128v-128h-128v128zM0 768h128v-128h-128v128zM256 512h512v-128h-512v128zM256 256h512v-128h-512v128zM256 768h512v-128h-512v128z"},orderedList:{width:768,height:896,path:"M320 512h448v-128h-448v128zM320 768h448v-128h-448v128zM320 128v128h448v-128h-448zM79 384h78v-256h-36l-85 23v50l43-2v185zM189 590c0-36-12-78-96-78-33 0-64 6-83 16l1 66c21-10 42-15 67-15s32 11 32 28c0 26-30 58-110 112v50h192v-67l-91 2c49-30 87-66 87-113l1-1z"},blockquote:{width:640,height:896,path:"M0 448v256h256v-256h-128c0 0 0-128 128-128v-128c0 0-256 0-256 256zM640 320v-128c0 0-256 0-256 256v256h256v-256h-128c0 0 0-128 128-128z"}},nh=new Kl({title:"Join with above block",run:mi,select:function(t){return mi(t)},icon:eh.join}),rh=new Kl({title:"Lift out of enclosing block",run:gi,select:function(t){return gi(t)},icon:eh.lift}),oh=new Kl({title:"Select parent node",run:bi,select:function(t){return bi(t)},icon:eh.selectParentNode}),ih=new Kl({title:"Undo last change",run:li,enable:function(t){return li(t)},icon:eh.undo}),sh=new Kl({title:"Redo last undone change",run:hi,enable:function(t){return hi(t)},icon:eh.redo});function ah(t,e){var n=Si(t,e.attrs),r={run:n,enable:function(t){return n(t)},active:function(n){var r=n.selection,o=r.$from,i=r.to,s=r.node;return s?s.hasMarkup(t,e.attrs):i<=o.end()&&o.parent.hasMarkup(t,e.attrs)}};for(var o in e)r[o]=e[o];return new Kl(r)}function ch(t,e,n){n?t.classList.add(e):t.classList.remove(e)}var lh="ProseMirror-menubar",hh=function(t,e){var n=this;this.editorView=t,this.options=e,this.wrapper=Ll("div",{class:lh+"-wrapper"}),this.menu=this.wrapper.appendChild(Ll("div",{class:lh})),this.menu.className=lh,this.spacer=null,t.dom.parentNode.replaceChild(this.wrapper,t.dom),this.wrapper.appendChild(t.dom),this.maxHeight=0,this.widthForMaxHeight=0,this.floating=!1;var r=function(t,e){for(var n=document.createDocumentFragment(),r=[],o=[],i=0;i<e.length;i++){for(var s=e[i],a=[],c=[],l=0;l<s.length;l++){var h=s[l].render(t),p=h.dom,f=h.update,d=Ll("span",{class:Jl+"item"},p);n.appendChild(d),c.push(d),a.push(f)}a.length&&(r.push(Zl(a,c)),i<e.length-1&&o.push(n.appendChild(Ll("span",{class:Jl+"separator"}))))}return{dom:n,update:function(t){for(var e=!1,n=!1,i=0;i<r.length;i++){var s=r[i](t);i&&(o[i-1].style.display=n&&s?"":"none"),n=s,s&&(e=!0)}return e}}}(this.editorView,this.options.content),o=r.dom,i=r.update;if(this.contentUpdate=i,this.menu.appendChild(o),this.update(),e.floating&&!function(){if("undefined"==typeof navigator)return!1;var t=navigator.userAgent;return!/Edge\/\d/.test(t)&&/AppleWebKit/.test(t)&&/Mobile\/\w+/.test(t)}()){this.updateFloat();var s=function(t){for(var e=[window],n=t.parentNode;n;n=n.parentNode)e.push(n);return e}(this.wrapper);this.scrollFunc=function(t){var e=n.editorView.root;(e.body||e).contains(n.wrapper)?n.updateFloat(t.target.getBoundingClientRect&&t.target):s.forEach((function(t){return t.removeEventListener("scroll",n.scrollFunc)}))},s.forEach((function(t){return t.addEventListener("scroll",n.scrollFunc)}))}};hh.prototype.update=function(){this.contentUpdate(this.editorView.state),this.floating?this.updateScrollCursor():(this.menu.offsetWidth!=this.widthForMaxHeight&&(this.widthForMaxHeight=this.menu.offsetWidth,this.maxHeight=0),this.menu.offsetHeight>this.maxHeight&&(this.maxHeight=this.menu.offsetHeight,this.menu.style.minHeight=this.maxHeight+"px"))},hh.prototype.updateScrollCursor=function(){var t=this.editorView.root.getSelection();if(t.focusNode){var e=t.getRangeAt(0).getClientRects(),n=e[function(t){return t.anchorNode==t.focusNode?t.anchorOffset>t.focusOffset:t.anchorNode.compareDocumentPosition(t.focusNode)==Node.DOCUMENT_POSITION_FOLLOWING}(t)?0:e.length-1];if(n){var r=this.menu.getBoundingClientRect();if(n.top<r.bottom&&n.bottom>r.top){var o=function(t){for(var e=t.parentNode;e;e=e.parentNode)if(e.scrollHeight>e.clientHeight)return e}(this.wrapper);o&&(o.scrollTop-=r.bottom-n.top)}}}},hh.prototype.updateFloat=function(t){var e=this.wrapper,n=e.getBoundingClientRect(),r=t?Math.max(0,t.getBoundingClientRect().top):0;if(this.floating)if(n.top>=r||n.bottom<this.menu.offsetHeight+10)this.floating=!1,this.menu.style.position=this.menu.style.left=this.menu.style.top=this.menu.style.width="",this.menu.style.display="",this.spacer.parentNode.removeChild(this.spacer),this.spacer=null;else{var o=(e.offsetWidth-e.clientWidth)/2;this.menu.style.left=n.left+o+"px",this.menu.style.display=n.top>window.innerHeight?"none":"",t&&(this.menu.style.top=r+"px")}else if(n.top<r&&n.bottom>=this.menu.offsetHeight+10){this.floating=!0;var i=this.menu.getBoundingClientRect();this.menu.style.left=i.left+"px",this.menu.style.width=i.width+"px",t&&(this.menu.style.top=r+"px"),this.menu.style.position="fixed",this.spacer=Ll("div",{class:lh+"-spacer",style:"height: "+i.height+"px"}),e.insertBefore(this.spacer,this.menu)}},hh.prototype.destroy=function(){this.wrapper.parentNode&&this.wrapper.parentNode.replaceChild(this.editorView.dom,this.wrapper)};var ph=function(t,e){var n;this.match=t,this.handler="string"==typeof e?(n=e,function(t,e,r,o){var i=n;if(e[1]){var s=e[0].lastIndexOf(e[1]);i+=e[0].slice(s+e[1].length);var a=(r+=s)-o;a>0&&(i=e[0].slice(s-a,s)+i,r=o)}return t.tr.insertText(i,r,o)}):e};function fh(t,e,n,r,o,i){if(t.composing)return!1;var s=t.state,a=s.doc.resolve(e);if(a.parent.type.spec.code)return!1;for(var c=a.parent.textBetween(Math.max(0,a.parentOffset-500),a.parentOffset,null,"￼")+r,l=0;l<o.length;l++){var h=o[l].match.exec(c),p=h&&o[l].handler(s,h,e-(h[0].length-r.length),n);if(p)return t.dispatch(p.setMeta(i,{transform:p,from:e,to:n,text:r})),!0}return!1}function dh(t,e){for(var n=t.plugins,r=0;r<n.length;r++){var o=n[r],i=void 0;if(o.spec.isInputRules&&(i=o.getState(t))){if(e){for(var s=t.tr,a=i.transform,c=a.steps.length-1;c>=0;c--)s.step(a.steps[c].invert(a.docs[c]));if(i.text){var l=s.doc.resolve(i.from).marks();s.replaceWith(i.from,i.to,t.schema.text(i.text,l))}else s.delete(i.from,i.to);e(s)}return!0}}return!1}var uh=new ph(/--$/,"—"),mh=new ph(/\.\.\.$/,"…"),vh=[new ph(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,"“"),new ph(/"$/,"”"),new ph(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,"‘"),new ph(/'$/,"’")];function gh(t,e,n,r){return new ph(t,(function(t,o,i,s){var a=n instanceof Function?n(o):n,c=t.tr.delete(i,s),l=c.doc.resolve(i).blockRange(),h=l&&jt(l,e,a);if(!h)return null;c.wrap(l,h);var p=c.doc.resolve(i-1).nodeBefore;return p&&p.type==e&&Kt(c.doc,i-1)&&(!r||r(o,p))&&c.join(i-1),c}))}function yh(t,e,n){return new ph(t,(function(t,r,o,i){var s=t.doc.resolve(o),a=n instanceof Function?n(r):n;return s.node(-1).canReplaceWith(s.index(-1),s.indexAfter(-1),e)?t.tr.delete(o,i).setBlockType(o,o,e,a):null}))}var wh="ProseMirror-prompt";function bh(t){var e=document.body.appendChild(document.createElement("div"));e.className=wh;var n=function(t){e.contains(t.target)||r()};setTimeout((function(){return window.addEventListener("mousedown",n)}),50);var r=function(){window.removeEventListener("mousedown",n),e.parentNode&&e.parentNode.removeChild(e)},o=[];for(var i in t.fields)o.push(t.fields[i].render());var s=document.createElement("button");s.type="submit",s.className=wh+"-submit",s.textContent="OK";var a=document.createElement("button");a.type="button",a.className=wh+"-cancel",a.textContent="Cancel",a.addEventListener("click",r);var c=e.appendChild(document.createElement("form"));t.title&&(c.appendChild(document.createElement("h5")).textContent=t.title),o.forEach((function(t){c.appendChild(document.createElement("div")).appendChild(t)}));var l=c.appendChild(document.createElement("div"));l.className=wh+"-buttons",l.appendChild(s),l.appendChild(document.createTextNode(" ")),l.appendChild(a);var h=e.getBoundingClientRect();e.style.top=(window.innerHeight-h.height)/2+"px",e.style.left=(window.innerWidth-h.width)/2+"px";var p=function(){var e=function(t,e){var n=Object.create(null),r=0;for(var o in t){var i=t[o],s=e[r++],a=i.read(s),c=i.validate(a);if(c)return xh(s,c),null;n[o]=i.clean(a)}return n}(t.fields,o);e&&(r(),t.callback(e))};c.addEventListener("submit",(function(t){t.preventDefault(),p()})),c.addEventListener("keydown",(function(t){27==t.keyCode?(t.preventDefault(),r()):13!=t.keyCode||t.ctrlKey||t.metaKey||t.shiftKey?9==t.keyCode&&window.setTimeout((function(){e.contains(document.activeElement)||r()}),500):(t.preventDefault(),p())}));var f=c.elements[0];f&&f.focus()}function xh(t,e){var n=t.parentNode,r=n.appendChild(document.createElement("div"));r.style.left=t.offsetLeft+t.offsetWidth+2+"px",r.style.top=t.offsetTop-5+"px",r.className="ProseMirror-invalid",r.textContent=e,setTimeout((function(){return n.removeChild(r)}),1500)}var kh=function(t){this.options=t};kh.prototype.read=function(t){return t.value},kh.prototype.validateType=function(t){},kh.prototype.validate=function(t){return!t&&this.options.required?"Required field":this.validateType(t)||this.options.validate&&this.options.validate(t)},kh.prototype.clean=function(t){return this.options.clean?this.options.clean(t):t};var Sh=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.render=function(){var t=document.createElement("input");return t.type="text",t.placeholder=this.options.label,t.value=this.options.value||"",t.autocomplete="off",t},e}(kh);function Ch(t,e){for(var n=t.selection.$from,r=n.depth;r>=0;r--){var o=n.index(r);if(n.node(r).canReplaceWith(o,o,e))return!0}return!1}function Mh(t,e){var n={label:e.title,run:t};for(var r in e)n[r]=e[r];return e.enable&&!0!==e.enable||e.select||(n[e.enable?"enable":"select"]=function(e){return t(e)}),new Kl(n)}function Oh(t,e){var n=t.selection,r=n.from,o=n.$from,i=n.to;return n.empty?e.isInSet(t.storedMarks||o.marks()):t.doc.rangeHasMark(r,i,e)}function Nh(t,e){var n={active:function(e){return Oh(e,t)},enable:!0};for(var r in e)n[r]=e[r];return Mh(Ci(t),n)}function Dh(t,e){return Mh(Eo(t,e.attrs),e)}var Th="undefined"!=typeof navigator&&/Mac/.test(navigator.platform);const Eh=new ze("annotation"),Ah="addAnnotation",Ph="deleteAnnotation";class zh{constructor(t,e){this.id=t,this.comment=e}}function Ih(t,e,n,r){return"inline"===r?eo.inline(t,e,{nodeName:"span",class:"annotation-highlight","data-id":n.id},{annotation:n}):"node"===r?eo.node(t,e,{class:"annotation-highlight","data-id":n.id},{annotation:n}):void 0}class Rh{constructor(t){this.decorationSet=t}static init(t){const e=t.annotations.map((function(t){return Ih(t.from,t.to,new zh(t.id,t.comment),t.type)}));return new Rh(io.create(t.doc,e))}annotationsAt(t,e){const n=e?0:1;return this.decorationSet.find(t+n,t-n).map((function(t){return t.spec.annotation}))}findAnnotation(t){const e=this.decorationSet.find();for(let n=0;n<e.length;n++)if(e[n].spec.annotation.id===t)return e[n]}apply(t){const e=t.getMeta(Bh),n=e?.type;if(!e&&!t.docChanged)return this;let r=this.decorationSet.map(t.mapping,t.doc,{onRemove(t){console.log("removed",t)}});return n===Ah?r=r.add(t.doc,[Ih(e.from,e.to,e.annotation,e.decorationType)]):n===Ph&&(r=r.remove([this.findAnnotation(e.annotation.id)])),new Rh(r)}toJSON(){return this.decorationSet.find().map((function(t){const{id:e,comment:n}=t.spec.annotation;return{from:t.from,to:t.to,id:e,comment:n,type:t.inline?"inline":"node"}}))}fromJSON(t){return Rh.init(t)}}const Bh=new Ee({key:Eh,state:{init:Rh.init,apply:(t,e,n,r)=>e.apply(t),toJSON:t=>t.toJSON(),fromJSON:(t,e,n)=>e.fromJSON(t,n)},props:{decorations(t){return this.getState(t).decorationSet}}});function Vh(t,e,n){const r=document.createElement("div");r.classList.add("annotation-tooltip");const o=document.createElement("ul");return o.classList.add("annotation-tooltip-list"),t.forEach((function(t){const r=function(t,e,n){const r=document.createElement("li");r.classList.add("annotation-tooltip-item");const o=document.createElement("span");o.textContent=t.comment;const i=document.createElement("button");return i.classList.add("annotation-delete-button"),i.title="Delete annotation",i.textContent="x",i.addEventListener("mousedown",(function(){e(n.tr.setMeta(Bh,{type:Ph,annotation:t}))})),r.appendChild(i),r.appendChild(o),r}(t,e,n);o.appendChild(r)})),r.appendChild(o),r}function Fh(t,e){const n=document.createElement("div");n.classList.add("annotation-handle");const r=document.createElement("button");return r.classList.add("annotation-add-button"),r.textContent="Add annotation",r.addEventListener("mousedown",(function(){const n=prompt("Add annotation");if(n){const{selection:r,tr:o}=e;r.annotationAdded=!0,o.setSelection(new de(r.$from)),t(o.setMeta(Bh,{type:Ah,annotation:new zh(`0000-${Date.now()}-${Math.floor(4294967295*Math.random())}`,n),decorationType:r instanceof de?"inline":"node",from:r.from,to:r.to}))}})),n.appendChild(r),n}const qh=new et({nodes:(_h=Mt.spec.nodes,jh="block",_h.append({ordered_list:To(Oo,{content:"list_item+",group:jh}),bullet_list:To(No,{content:"list_item+",group:jh}),list_item:To(Do,{content:"paragraph block*"})})),marks:Mt.spec.marks}),$h=Oe.create({schema:qh,doc:rt.fromSchema(qh).parse(document.querySelector("#content")),plugins:[...(Jh={schema:qh},Kh=[function(t){var e,n=vh.concat(mh,uh);return(e=t.nodes.blockquote)&&n.push(gh(/^\s*>\s$/,e)),(e=t.nodes.ordered_list)&&n.push(gh(/^(\d+)\.\s$/,e,(function(t){return{order:+t[1]}}),(function(t,e){return e.childCount+e.attrs.order==+t[1]}))),(e=t.nodes.bullet_list)&&n.push(function(t){return gh(/^\s*([-+*])\s$/,t)}(e)),(e=t.nodes.code_block)&&n.push(function(t){return yh(/^```$/,t)}(e)),(e=t.nodes.heading)&&n.push(function(t,e){return yh(new RegExp("^(#{1,6})\\s$"),t,(function(t){return{level:t[1].length}}))}(e)),function(t){var e=t.rules,n=new Ee({state:{init:function(){return null},apply:function(t,e){return t.getMeta(this)||(t.selectionSet||t.docChanged?null:e)}},props:{handleTextInput:function(t,r,o,i){return fh(t,r,o,i,e,n)},handleDOMEvents:{compositionend:function(t){setTimeout((function(){var r=t.state.selection.$cursor;r&&fh(t,r.pos,r.pos,"",e,n)}))}}},isInputRules:!0});return n}({rules:n})}(Jh.schema),Wo(function(t,e){var n,r,i={};function s(t,n){if(e){var r=e[t];if(!1===r)return;r&&(t=r)}i[t]=n}if(s("Mod-z",li),s("Shift-Mod-z",hi),s("Backspace",dh),Th||s("Mod-y",hi),s("Alt-ArrowUp",mi),s("Alt-ArrowDown",vi),s("Mod-BracketLeft",gi),s("Escape",bi),(n=t.marks.strong)&&(s("Mod-b",Ci(n)),s("Mod-B",Ci(n))),(n=t.marks.em)&&(s("Mod-i",Ci(n)),s("Mod-I",Ci(n))),(n=t.marks.code)&&s("Mod-`",Ci(n)),(n=t.nodes.bullet_list)&&s("Shift-Ctrl-8",Eo(n)),(n=t.nodes.ordered_list)&&s("Shift-Ctrl-9",Eo(n)),(n=t.nodes.blockquote)&&s("Ctrl->",ki(n)),n=t.nodes.hard_break){var a=n,c=Mi(wi,(function(t,e){return e(t.tr.replaceSelectionWith(a.create()).scrollIntoView()),!0}));s("Mod-Enter",c),s("Shift-Enter",c),Th&&s("Ctrl-Enter",c)}if((n=t.nodes.list_item)&&(s("Enter",(r=n,function(t,e){var n=t.selection,i=n.$from,s=n.$to,a=n.node;if(a&&a.isBlock||i.depth<2||!i.sameParent(s))return!1;var c=i.node(-1);if(c.type!=r)return!1;if(0==i.parent.content.size&&i.node(-1).childCount==i.indexAfter(-1)){if(2==i.depth||i.node(-3).type!=r||i.index(-2)!=i.node(-2).childCount-1)return!1;if(e){for(var l=o.empty,h=i.index(-1)?1:i.index(-2)?2:3,f=i.depth-h;f>=i.depth-3;f--)l=o.from(i.node(f).copy(l));var d=i.indexAfter(-1)<i.node(-2).childCount?1:i.indexAfter(-2)<i.node(-3).childCount?2:3;l=l.append(o.from(r.createAndFill()));var u=i.before(i.depth-(h-1)),m=t.tr.replace(u,i.after(-d),new p(l,4-h,0)),v=-1;m.doc.nodesBetween(u,m.doc.content.size,(function(t,e){if(v>-1)return!1;t.isTextblock&&0==t.content.size&&(v=e+1)})),v>-1&&m.setSelection(t.selection.constructor.near(m.doc.resolve(v))),e(m.scrollIntoView())}return!0}var g=s.pos==i.end()?c.contentMatchAt(0).defaultType:null,y=t.tr.delete(i.pos,s.pos),w=g&&[null,{type:g}];return!!Jt(y.doc,i.pos,2,w)&&(e&&e(y.split(i.pos,2,w).scrollIntoView()),!0)})),s("Mod-[",function(t){return function(e,n){var r=e.selection,i=r.$from,s=r.$to,a=i.blockRange(s,(function(e){return e.childCount&&e.firstChild.type==t}));return!!a&&(!n||(i.node(a.depth-1).type==t?function(t,e,n,r){var i=t.tr,s=r.end,a=r.$to.end(r.depth);return s<a&&(i.step(new qt(s-1,a,s,a,new p(o.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new T(i.doc.resolve(r.$from.pos),i.doc.resolve(a),r.depth)),e(i.lift(r,_t(r)).scrollIntoView()),!0}(e,n,t,a):function(t,e,n){for(var r=t.tr,i=n.parent,s=n.end,a=n.endIndex-1,c=n.startIndex;a>c;a--)s-=i.child(a).nodeSize,r.delete(s-1,s+1);var l=r.doc.resolve(n.start),h=l.nodeAfter;if(r.mapping.map(n.end)!=n.start+l.nodeAfter.nodeSize)return!1;var f=0==n.startIndex,d=n.endIndex==i.childCount,u=l.node(-1),m=l.index(-1);if(!u.canReplace(m+(f?0:1),m+1,h.content.append(d?o.empty:o.from(i))))return!1;var v=l.pos,g=v+h.nodeSize;return r.step(new qt(v-(f?1:0),g+(d?1:0),v+1,g-1,new p((f?o.empty:o.from(i.copy(o.empty))).append(d?o.empty:o.from(i.copy(o.empty))),f?0:1,d?0:1),f?0:1)),e(r.scrollIntoView()),!0}(e,n,a)))}}(n)),s("Mod-]",function(t){return function(e,n){var r=e.selection,i=r.$from,s=r.$to,a=i.blockRange(s,(function(e){return e.childCount&&e.firstChild.type==t}));if(!a)return!1;var c=a.startIndex;if(0==c)return!1;var l=a.parent,h=l.child(c-1);if(h.type!=t)return!1;if(n){var f=h.lastChild&&h.lastChild.type==l.type,d=o.from(f?t.create():null),u=new p(o.from(t.create(null,o.from(l.type.create(null,d)))),f?3:1,0),m=a.start,v=a.end;n(e.tr.step(new qt(m-(f?3:1),v,m,v,u,1,!0)).scrollIntoView())}return!0}}(n))),(n=t.nodes.paragraph)&&s("Shift-Ctrl-0",Si(n)),(n=t.nodes.code_block)&&s("Shift-Ctrl-\\",Si(n)),n=t.nodes.heading)for(var l=1;l<=6;l++)s("Shift-Ctrl-"+l,Si(n,{level:l}));if(n=t.nodes.horizontal_rule){var h=n;s("Mod-_",(function(t,e){return e(t.tr.replaceSelectionWith(h.create()).scrollIntoView()),!0}))}return i}(Jh.schema,Jh.mapKeys)),Wo(Ai),function(t){return void 0===t&&(t={}),new Ee({view:function(e){return new Pi(e,t)}})}(),new Ee({props:{decorations:function(t){if(!(t.selection instanceof Vl))return null;var e=document.createElement("div");return e.className="ProseMirror-gapcursor",wl.create(t.doc,[ml.widget(t.selection.head,e,{key:"gapcursor"})])},createSelectionBetween:function(t,e,n){if(e.pos==n.pos&&Vl.valid(n))return new Vl(n)},handleClick:function(t,e,n){if(!t.editable)return!1;var r=t.state.doc.resolve(e);if(!Vl.valid(r))return!1;var o=t.posAtCoords({left:n.clientX,top:n.clientY}).inside;return!(o>-1&&me.isSelectable(t.state.doc.nodeAt(o))||(t.dispatch(t.state.tr.setSelection(new Vl(r))),0))},handleKeyDown:ql}})],!1!==Jh.menuBar&&Kh.push(function(t){return new Ee({view:function(e){return new hh(e,t)}})}({floating:!1!==Jh.floatingMenu,content:Jh.menuContent||function(t){var e,n,r,o={};if((e=t.marks.strong)&&(o.toggleStrong=Nh(e,{title:"Toggle strong style",icon:eh.strong})),(e=t.marks.em)&&(o.toggleEm=Nh(e,{title:"Toggle emphasis",icon:eh.em})),(e=t.marks.code)&&(o.toggleCode=Nh(e,{title:"Toggle code font",icon:eh.code})),(e=t.marks.link)&&(o.toggleLink=(n=e,new Kl({title:"Add or remove link",icon:eh.link,active:function(t){return Oh(t,n)},enable:function(t){return!t.selection.empty},run:function(t,e,r){if(Oh(t,n))return Ci(n)(t,e),!0;bh({title:"Create a link",fields:{href:new Sh({label:"Link target",required:!0}),title:new Sh({label:"Title"})},callback:function(t){Ci(n,t)(r.state,r.dispatch),r.focus()}})}}))),(e=t.nodes.image)&&(o.insertImage=(r=e,new Kl({title:"Insert image",label:"Image",enable:function(t){return Ch(t,r)},run:function(t,e,n){var o=t.selection,i=o.from,s=o.to,a=null;t.selection instanceof me&&t.selection.node.type==r&&(a=t.selection.node.attrs),bh({title:"Insert image",fields:{src:new Sh({label:"Location",required:!0,value:a&&a.src}),title:new Sh({label:"Title",value:a&&a.title}),alt:new Sh({label:"Description",value:a?a.alt:t.doc.textBetween(i,s," ")})},callback:function(t){n.dispatch(n.state.tr.replaceSelectionWith(r.createAndFill(t))),n.focus()}})}}))),(e=t.nodes.bullet_list)&&(o.wrapBulletList=Dh(e,{title:"Wrap in bullet list",icon:eh.bulletList})),(e=t.nodes.ordered_list)&&(o.wrapOrderedList=Dh(e,{title:"Wrap in ordered list",icon:eh.orderedList})),(e=t.nodes.blockquote)&&(o.wrapBlockQuote=function(t,e){var n={run:function(n,r){return ki(t,e.attrs)(n,r)},select:function(n){return ki(t,e.attrs instanceof Function?null:e.attrs)(n)}};for(var r in e)n[r]=e[r];return new Kl(n)}(e,{title:"Wrap in block quote",icon:eh.blockquote})),(e=t.nodes.paragraph)&&(o.makeParagraph=ah(e,{title:"Change to paragraph",label:"Plain"})),(e=t.nodes.code_block)&&(o.makeCodeBlock=ah(e,{title:"Change to code block",label:"Code"})),e=t.nodes.heading)for(var i=1;i<=10;i++)o["makeHead"+i]=ah(e,{title:"Change to heading "+i,label:"Level "+i,attrs:{level:i}});if(e=t.nodes.horizontal_rule){var s=e;o.insertHorizontalRule=new Kl({title:"Insert horizontal rule",label:"Horizontal rule",enable:function(t){return Ch(t,s)},run:function(t,e){e(t.tr.replaceSelectionWith(s.create()))}})}var a=function(t){return t.filter((function(t){return t}))};return o.insertMenu=new Yl(a([o.insertImage,o.insertHorizontalRule]),{label:"Insert"}),o.typeMenu=new Yl(a([o.makeParagraph,o.makeCodeBlock,o.makeHead1&&new th(a([o.makeHead1,o.makeHead2,o.makeHead3,o.makeHead4,o.makeHead5,o.makeHead6]),{label:"Heading"})]),{label:"Type..."}),o.inlineMenu=[a([o.toggleStrong,o.toggleEm,o.toggleCode,o.toggleLink])],o.blockMenu=[a([o.wrapBulletList,o.wrapOrderedList,o.wrapBlockQuote,nh,rh,oh])],o.fullMenu=o.inlineMenu.concat([[o.insertMenu,o.typeMenu]],[[ih,sh]],o.blockMenu),o}(Jh.schema).fullMenu})),!1!==Jh.history&&Kh.push((Lh={depth:Lh&&Lh.depth||100,newGroupDelay:Lh&&Lh.newGroupDelay||500},new Ee({key:ai,state:{init:function(){return new Zo(Yo.empty,Yo.empty,null,0)},apply:function(t,e,n){return function(t,e,n,r){var o,i=n.getMeta(ai);if(i)return i.historyState;n.getMeta(ci)&&(t=new Zo(t.done,t.undone,null,0));var s=n.getMeta("appendedTransaction");if(0==n.steps.length)return t;if(s&&s.getMeta(ai))return s.getMeta(ai).redo?new Zo(t.done.addTransform(n,null,r,si(e)),t.undone,ei(n.mapping.maps[n.steps.length-1]),t.prevTime):new Zo(t.done,t.undone.addTransform(n,null,r,si(e)),null,t.prevTime);if(!1===n.getMeta("addToHistory")||s&&!1===s.getMeta("addToHistory"))return(o=n.getMeta("rebased"))?new Zo(t.done.rebased(n,o),t.undone.rebased(n,o),ni(t.prevRanges,n.mapping),t.prevTime):new Zo(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),ni(t.prevRanges,n.mapping),t.prevTime);var a=0==t.prevTime||!s&&(t.prevTime<(n.time||0)-r.newGroupDelay||!function(t,e){if(!e)return!1;if(!t.docChanged)return!0;var n=!1;return t.mapping.maps[0].forEach((function(t,r){for(var o=0;o<e.length;o+=2)t<=e[o+1]&&r>=e[o]&&(n=!0)})),n}(n,t.prevRanges)),c=s?ni(t.prevRanges,n.mapping):ei(n.mapping.maps[n.steps.length-1]);return new Zo(t.done.addTransform(n,a?e.selection.getBookmark():null,r,si(e)),Yo.empty,c,n.time)}(e,n,t,Lh)}},config:Lh,props:{handleDOMEvents:{beforeinput:function(t,e){var n="historyUndo"==e.inputType?li(t.state,t.dispatch):"historyRedo"==e.inputType&&hi(t.state,t.dispatch);return n&&e.preventDefault(),n}}}}))),Kh.concat(new Ee({props:{attributes:{class:"ProseMirror-example-setup-style"}}}))),Bh,(Wh=t=>{const e=Hh.state.apply(t);Hh.updateState(e)},new Ee({props:{decorations(t){const e=t.selection;function n(n){return Bh.getState(t).annotationsAt(e.from,n)}function r(){return io.create(t.doc,[eo.widget(e.from,Fh(Wh,t))])}function o(n){return io.create(t.doc,[eo.widget(e.from,Vh(n,Wh,t))])}if(e.node){const t=n(!0);return t.length?o(t):r()}if(e.empty){const t=n(!1);return t.length?o(t):null}if(!e.annotationAdded)return r()}}}))],annotations:[{from:12,to:13,id:"0000-1632900931897-1795534064",comment:"This is a node!",type:"node"},{from:2,to:10,id:"0000-1632904224730-642213412",comment:"Overlapping!",type:"inline"},{from:3,to:5,id:"0000-1632900918678-1210060443",comment:"c34",type:"inline"},{from:7,to:9,id:"0000-1632900924387-1538760373",comment:"c78",type:"inline"},{from:18,to:20,id:"0000-1632900937947-1721039019",comment:"c56",type:"inline"}]});var Lh,_h,jh,Wh,Jh,Kh;const Hh=new go(document.querySelector("#editor"),{state:$h});document.querySelector("#get-current-annotations").addEventListener("click",(function(){const t=Eh.getState(editorView.state).toJSON();console.log("annotations",t)})),window.editorView=Hh,window.annotationPlugin=Bh,window.annotationPluginKey=Eh})();
  //# sourceMappingURL=bundle.js.map