@tiptap/extension-gapcursor 2.0.0-beta.2 → 2.0.0-beta.200

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +0,0 @@
1
- !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@tiptap/core")):"function"==typeof define&&define.amd?define(["exports","@tiptap/core"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self)["@tiptap/extension-gapcursor"]={},t["@tiptap/core"])}(this,(function(t,e){"use strict";for(var n={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"},r={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"},o="undefined"!=typeof navigator&&/Chrome\/(\d+)/.exec(navigator.userAgent),i="undefined"!=typeof navigator&&/Apple Computer/.test(navigator.vendor),s="undefined"!=typeof navigator&&/Gecko\/\d+/.test(navigator.userAgent),a="undefined"!=typeof navigator&&/Mac/.test(navigator.platform),c="undefined"!=typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),h=o&&(a||+o[1]<57)||s&&a,p=0;p<10;p++)n[48+p]=n[96+p]=String(p);for(p=1;p<=24;p++)n[p+111]="F"+p;for(p=65;p<=90;p++)n[p]=String.fromCharCode(p+32),r[p]=String.fromCharCode(p);for(var f in n)r.hasOwnProperty(f)||(r[f]=n[f]);function l(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=l(o.content,i.content,n+1);if(null!=a)return a}n+=o.nodeSize}else n+=o.nodeSize}}function u(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 h=0,p=Math.min(s.text.length,a.text.length);h<p&&s.text[s.text.length-h-1]==a.text[a.text.length-h-1];)h++,n--,r--;return{a:n,b:r}}if(s.content.size||a.content.size){var f=u(s.content,a.content,n-1,r-1);if(f)return f}n-=c,r-=c}else n-=c,r-=c}}var d=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},m={firstChild:{configurable:!0},lastChild:{configurable:!0},childCount:{configurable:!0}};d.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 h=s+1;a.nodesBetween(Math.max(0,t-h),Math.min(a.content.size,e-h),n,r+h)}s=c}},d.prototype.descendants=function(t){this.nodesBetween(0,this.size,t)},d.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},d.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 d(r,this.size+t.size)},d.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 d(n,r)},d.prototype.cutByIndex=function(t,e){return t==e?d.empty:0==t&&e==this.content.length?this:new d(this.content.slice(t,e))},d.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 d(r,o)},d.prototype.addToStart=function(t){return new d([t].concat(this.content),this.size+t.nodeSize)},d.prototype.addToEnd=function(t){return new d(this.content.concat(t),this.size+t.nodeSize)},d.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},m.firstChild.get=function(){return this.content.length?this.content[0]:null},m.lastChild.get=function(){return this.content.length?this.content[this.content.length-1]:null},m.childCount.get=function(){return this.content.length},d.prototype.child=function(t){var e=this.content[t];if(!e)throw new RangeError("Index "+t+" out of range for "+this);return e},d.prototype.maybeChild=function(t){return this.content[t]},d.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}},d.prototype.findDiffStart=function(t,e){return void 0===e&&(e=0),l(this,t,e)},d.prototype.findDiffEnd=function(t,e,n){return void 0===e&&(e=this.size),void 0===n&&(n=t.size),u(this,t,e,n)},d.prototype.findIndex=function(t,e){if(void 0===e&&(e=-1),0==t)return y(0,t);if(t==this.size)return y(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?y(n+1,o):y(n,r);r=o}},d.prototype.toString=function(){return"<"+this.toStringInner()+">"},d.prototype.toStringInner=function(){return this.content.join(", ")},d.prototype.toJSON=function(){return this.content.length?this.content.map((function(t){return t.toJSON()})):null},d.fromJSON=function(t,e){if(!e)return d.empty;if(!Array.isArray(e))throw new RangeError("Invalid input for Fragment.fromJSON");return new d(e.map(t.nodeFromJSON))},d.fromArray=function(t){if(!t.length)return d.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 d(e||t,n)},d.from=function(t){if(!t)return d.empty;if(t instanceof d)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new d([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(d.prototype,m);var v={index:0,offset:0};function y(t,e){return v.index=t,v.offset=e,v}function g(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(!g(t[r],e[r]))return!1}else{for(var o in t)if(!(o in e)||!g(t[o],e[o]))return!1;for(var i in e)if(!(i in t))return!1}return!0}d.empty=new d([],0);var w=function(t,e){this.type=t,this.attrs=e};function b(t){var e=Error.call(this,t);return e.__proto__=b.prototype,e}w.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},w.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},w.prototype.isInSet=function(t){for(var e=0;e<t.length;e++)if(this.eq(t[e]))return!0;return!1},w.prototype.eq=function(t){return this==t||this.type==t.type&&g(this.attrs,t.attrs)},w.prototype.toJSON=function(){var t={type:this.type.name};for(var e in this.attrs){t.attrs=this.attrs;break}return t},w.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)},w.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},w.setFrom=function(t){if(!t||0==t.length)return w.none;if(t instanceof w)return[t];var e=t.slice();return e.sort((function(t,e){return t.type.rank-e.type.rank})),e},w.none=[],b.prototype=Object.create(Error.prototype),b.prototype.constructor=b,b.prototype.name="ReplaceError";var S=function(t,e,n){this.content=t,this.openStart=e,this.openEnd=n},k={size:{configurable:!0}};function x(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,h=a.offset;if(i==e||s.isText){if(h!=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(x(s.content,e-i-1,n-i-1)))}function O(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=O(a.content,e-s-1,n);return c&&t.replaceChild(i,a.copy(c))}function C(t,e,n){if(n.openStart>t.depth)throw new b("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new b("Inconsistent open depths");return M(t,e,n,0)}function M(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=M(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(d.from(r));return{start:r.resolveNoCache(t.openStart+n),end:r.resolveNoCache(r.content.size-t.openEnd-n)}}(n,t);return E(i,R(t,a.start,a.end,e,r))}var c=t.parent,h=c.content;return E(c,h.cut(0,t.parentOffset).append(n.content).append(h.cut(e.parentOffset)))}return E(i,P(t,e,r))}function N(t,e){if(!e.type.compatibleContent(t.type))throw new b("Cannot join "+e.type.name+" onto "+t.type.name)}function D(t,e,n){var r=t.node(n);return N(r,e.node(n)),r}function T(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 A(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&&(T(t.nodeAfter,r),i++));for(var a=i;a<s;a++)T(o.child(a),r);e&&e.depth==n&&e.textOffset&&T(e.nodeBefore,r)}function E(t,e){if(!t.type.validContent(e))throw new b("Invalid content for node "+t.type.name);return t.copy(e)}function R(t,e,n,r,o){var i=t.depth>o&&D(t,e,o+1),s=r.depth>o&&D(n,r,o+1),a=[];return A(null,t,o,a),i&&s&&e.index(o)==n.index(o)?(N(i,s),T(E(i,R(t,e,n,r,o+1)),a)):(i&&T(E(i,P(t,e,o+1)),a),A(e,n,o,a),s&&T(E(s,P(n,r,o+1)),a)),A(r,null,o,a),new d(a)}function P(t,e,n){var r=[];(A(null,t,n,r),t.depth>n)&&T(E(D(t,e,n+1),P(t,e,n+1)),r);return A(e,null,n,r),new d(r)}k.size.get=function(){return this.content.size-this.openStart-this.openEnd},S.prototype.insertAt=function(t,e){var n=O(this.content,t+this.openStart,e,null);return n&&new S(n,this.openStart,this.openEnd)},S.prototype.removeBetween=function(t,e){return new S(x(this.content,t+this.openStart,e+this.openStart),this.openStart,this.openEnd)},S.prototype.eq=function(t){return this.content.eq(t.content)&&this.openStart==t.openStart&&this.openEnd==t.openEnd},S.prototype.toString=function(){return this.content+"("+this.openStart+","+this.openEnd+")"},S.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},S.fromJSON=function(t,e){if(!e)return S.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 S(d.fromJSON(t,e.content),n,r)},S.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 S(t,n,r)},Object.defineProperties(S.prototype,k),S.empty=new S(d.empty,0,0);var z=function(t,e,n){this.pos=t,this.path=e,this.depth=e.length/3-1,this.parentOffset=n},I={parent:{configurable:!0},doc:{configurable:!0},textOffset:{configurable:!0},nodeAfter:{configurable:!0},nodeBefore:{configurable:!0}};z.prototype.resolveDepth=function(t){return null==t?this.depth:t<0?this.depth+t:t},I.parent.get=function(){return this.node(this.depth)},I.doc.get=function(){return this.node(0)},z.prototype.node=function(t){return this.path[3*this.resolveDepth(t)]},z.prototype.index=function(t){return this.path[3*this.resolveDepth(t)+1]},z.prototype.indexAfter=function(t){return t=this.resolveDepth(t),this.index(t)+(t!=this.depth||this.textOffset?1:0)},z.prototype.start=function(t){return 0==(t=this.resolveDepth(t))?0:this.path[3*t-1]+1},z.prototype.end=function(t){return t=this.resolveDepth(t),this.start(t)+this.node(t).content.size},z.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]},z.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},I.textOffset.get=function(){return this.pos-this.path[this.path.length-1]},I.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},I.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)},z.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},z.prototype.marks=function(){var t=this.parent,e=this.index();if(0==t.content.size)return w.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},z.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},z.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},z.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 $(this,t,n)},z.prototype.sameParent=function(t){return this.pos-this.parentOffset==t.pos-t.parentOffset},z.prototype.max=function(t){return t.pos>this.pos?t:this},z.prototype.min=function(t){return t.pos<this.pos?t:this},z.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},z.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,h=o-c;if(n.push(i,a,r+c),!h)break;if((i=i.child(a)).isText)break;o=h-1,r+=c+1}return new z(e,n,o)},z.resolveCached=function(t,e){for(var n=0;n<B.length;n++){var r=B[n];if(r.pos==e&&r.doc==t)return r}var o=B[F]=z.resolve(t,e);return F=(F+1)%V,o},Object.defineProperties(z.prototype,I);var B=[],F=0,V=12,$=function(t,e,n){this.$from=t,this.$to=e,this.depth=n},_={start:{configurable:!0},end:{configurable:!0},parent:{configurable:!0},startIndex:{configurable:!0},endIndex:{configurable:!0}};_.start.get=function(){return this.$from.before(this.depth+1)},_.end.get=function(){return this.$to.after(this.depth+1)},_.parent.get=function(){return this.$from.node(this.depth)},_.startIndex.get=function(){return this.$from.index(this.depth)},_.endIndex.get=function(){return this.$to.indexAfter(this.depth)},Object.defineProperties($.prototype,_);var L=Object.create(null),j=function(t,e,n,r){this.type=t,this.attrs=e,this.content=n||d.empty,this.marks=r||w.none},J={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}};J.nodeSize.get=function(){return this.isLeaf?1:2+this.content.size},J.childCount.get=function(){return this.content.childCount},j.prototype.child=function(t){return this.content.child(t)},j.prototype.maybeChild=function(t){return this.content.maybeChild(t)},j.prototype.forEach=function(t){this.content.forEach(t)},j.prototype.nodesBetween=function(t,e,n,r){void 0===r&&(r=0),this.content.nodesBetween(t,e,n,r,this)},j.prototype.descendants=function(t){this.nodesBetween(0,this.content.size,t)},J.textContent.get=function(){return this.textBetween(0,this.content.size,"")},j.prototype.textBetween=function(t,e,n,r){return this.content.textBetween(t,e,n,r)},J.firstChild.get=function(){return this.content.firstChild},J.lastChild.get=function(){return this.content.lastChild},j.prototype.eq=function(t){return this==t||this.sameMarkup(t)&&this.content.eq(t.content)},j.prototype.sameMarkup=function(t){return this.hasMarkup(t.type,t.attrs,t.marks)},j.prototype.hasMarkup=function(t,e,n){return this.type==t&&g(this.attrs,e||t.defaultAttrs||L)&&w.sameSet(this.marks,n||w.none)},j.prototype.copy=function(t){return void 0===t&&(t=null),t==this.content?this:new this.constructor(this.type,this.attrs,t,this.marks)},j.prototype.mark=function(t){return t==this.marks?this:new this.constructor(this.type,this.attrs,this.content,t)},j.prototype.cut=function(t,e){return 0==t&&e==this.content.size?this:this.copy(this.content.cut(t,e))},j.prototype.slice=function(t,e,n){if(void 0===e&&(e=this.content.size),void 0===n&&(n=!1),t==e)return S.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 S(a,r.depth-i,o.depth-i)},j.prototype.replace=function(t,e,n){return C(this.resolve(t),this.resolve(e),n)},j.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}},j.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}},j.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}},j.prototype.resolve=function(t){return z.resolveCached(this,t)},j.prototype.resolveNoCache=function(t){return z.resolve(this,t)},j.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},J.isBlock.get=function(){return this.type.isBlock},J.isTextblock.get=function(){return this.type.isTextblock},J.inlineContent.get=function(){return this.type.inlineContent},J.isInline.get=function(){return this.type.isInline},J.isText.get=function(){return this.type.isText},J.isLeaf.get=function(){return this.type.isLeaf},J.isAtom.get=function(){return this.type.isAtom},j.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()+")"),function(t,e){for(var n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}(this.marks,t)},j.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},j.prototype.canReplace=function(t,e,n,r,o){void 0===n&&(n=d.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},j.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},j.prototype.canAppend=function(t){return t.content.size?this.canReplace(this.childCount,this.childCount,t.content):this.type.compatibleContent(t.type)},j.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));this.content.forEach((function(t){return t.check()}))},j.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},j.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=d.fromJSON(t,e.content);return t.nodeType(e.type).create(e.attrs,r,n)},Object.defineProperties(j.prototype,J);var q=function(t){this.validEnd=t,this.next=[],this.wrapCache=[]},W={inlineContent:{configurable:!0},defaultType:{configurable:!0},edgeCount:{configurable:!0}};q.parse=function(t,e){var n=new K(t,e);if(null==n.next)return q.empty;var r=H(n);n.next&&n.err("Unexpected trailing text");var o=function(t){var e=Object.create(null);return n(tt(t,0));function n(r){var o=[];r.forEach((function(e){t[e].forEach((function(e){var n=e.term,r=e.to;if(n){var i=o.indexOf(n),s=i>-1&&o[i+1];tt(t,r).forEach((function(t){s||o.push(n,s=[]),-1==s.indexOf(t)&&s.push(t)}))}}))}));for(var i=e[r.join(",")]=new q(r.indexOf(t.length-1)>-1),s=0;s<o.length;s+=2){var a=o[s+1].sort(Z);i.next.push(o[s],e[a.join(",")]||n(a))}return i}}(function(t){var e=[[]];return o(i(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}))}function i(t,e){if("choice"==t.type)return t.exprs.reduce((function(t,n){return t.concat(i(n,e))}),[]);if("seq"==t.type)for(var s=0;;s++){var a=i(t.exprs[s],e);if(s==t.exprs.length-1)return a;o(a,e=n())}else{if("star"==t.type){var c=n();return r(e,c),o(i(t.expr,c),c),[r(c)]}if("plus"==t.type){var h=n();return o(i(t.expr,e),h),o(i(t.expr,h),h),[r(h)]}if("opt"==t.type)return[r(e)].concat(i(t.expr,e));if("range"==t.type){for(var p=e,f=0;f<t.min;f++){var l=n();o(i(t.expr,p),l),p=l}if(-1==t.max)o(i(t.expr,p),p);else for(var u=t.min;u<t.max;u++){var d=n();r(p,d),o(i(t.expr,p),d),p=d}return[r(p)]}if("name"==t.type)return[r(e,null,t.value)]}}}(r));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],h=o.next[a+1];s.push(c.name),!i||c.isText||c.hasRequiredAttrs()||(i=!1),-1==r.indexOf(h)&&r.push(h)}i&&e.err("Only non-generatable nodes ("+s.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}(o,n),o},q.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},q.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},W.inlineContent.get=function(){var t=this.next[0];return!!t&&t.isInline},W.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}},q.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},q.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 d.from(s.map((function(t){return t.createAndFill()})));for(var c=0;c<i.next.length;c+=2){var h=i.next[c],p=i.next[c+1];if(!h.isText&&!h.hasRequiredAttrs()&&-1==r.indexOf(p)){r.push(p);var f=o(p,s.concat(h));if(f)return f}}}(this,[])},q.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},q.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)}}},W.edgeCount.get=function(){return this.next.length>>1},q.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]}},q.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(q.prototype,W),q.empty=new q(!0);var K=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()},U={next:{configurable:!0}};function H(t){var e=[];do{e.push(G(t))}while(t.eat("|"));return 1==e.length?e[0]:{type:"choice",exprs:e}}function G(t){var e=[];do{e.push(X(t))}while(t.next&&")"!=t.next&&"|"!=t.next);return 1==e.length?e[0]:{type:"seq",exprs:e}}function X(t){for(var e=function(t){if(t.eat("(")){var e=H(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)}0==o.length&&t.err("No node type or group '"+e+"' found");return 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=Q(t,e)}return e}function Y(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");var e=Number(t.next);return t.pos++,e}function Q(t,e){var n=Y(t),r=n;return t.eat(",")&&(r="}"!=t.next?Y(t):-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function Z(t,e){return e-t}function tt(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(Z)}function et(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 nt(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 rt(t){var e=Object.create(null);if(t)for(var n in t)e[n]=new st(t[n]);return e}U.next.get=function(){return this.tokens[this.pos]},K.prototype.eat=function(t){return this.next==t&&(this.pos++||!0)},K.prototype.err=function(t){throw new SyntaxError(t+" (in content expression '"+this.string+"')")},Object.defineProperties(K.prototype,U);var ot=function(t,e,n){this.name=t,this.schema=e,this.spec=n,this.groups=n.group?n.group.split(" "):[],this.attrs=rt(n.attrs),this.defaultAttrs=et(this.attrs),this.contentMatch=null,this.markSet=null,this.inlineContent=null,this.isBlock=!(n.inline||"text"==t),this.isText="text"==t},it={isInline:{configurable:!0},isTextblock:{configurable:!0},isLeaf:{configurable:!0},isAtom:{configurable:!0}};it.isInline.get=function(){return!this.isBlock},it.isTextblock.get=function(){return this.isBlock&&this.inlineContent},it.isLeaf.get=function(){return this.contentMatch==q.empty},it.isAtom.get=function(){return this.isLeaf||this.spec.atom},ot.prototype.hasRequiredAttrs=function(){for(var t in this.attrs)if(this.attrs[t].isRequired)return!0;return!1},ot.prototype.compatibleContent=function(t){return this==t||this.contentMatch.compatible(t.contentMatch)},ot.prototype.computeAttrs=function(t){return!t&&this.defaultAttrs?this.defaultAttrs:nt(this.attrs,t)},ot.prototype.create=function(t,e,n){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new j(this,this.computeAttrs(t),d.from(e),w.setFrom(n))},ot.prototype.createChecked=function(t,e,n){if(e=d.from(e),!this.validContent(e))throw new RangeError("Invalid content for node "+this.name);return new j(this,this.computeAttrs(t),e,w.setFrom(n))},ot.prototype.createAndFill=function(t,e,n){if(t=this.computeAttrs(t),(e=d.from(e)).size){var r=this.contentMatch.fillBefore(e);if(!r)return null;e=r.append(e)}var o=this.contentMatch.matchFragment(e).fillBefore(d.empty,!0);return o?new j(this,t,e.append(o),w.setFrom(n)):null},ot.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},ot.prototype.allowsMarkType=function(t){return null==this.markSet||this.markSet.indexOf(t)>-1},ot.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},ot.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:w.empty:t},ot.compile=function(t,e){var n=Object.create(null);t.forEach((function(t,r){return n[t]=new ot(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(ot.prototype,it);var st=function(t){this.hasDefault=Object.prototype.hasOwnProperty.call(t,"default"),this.default=t.default},at={isRequired:{configurable:!0}};at.isRequired.get=function(){return!this.hasDefault},Object.defineProperties(st.prototype,at);var ct=function(t,e,n,r){this.name=t,this.schema=n,this.spec=r,this.attrs=rt(r.attrs),this.rank=e,this.excluded=null;var o=et(this.attrs);this.instance=o&&new w(this,o)};ct.prototype.create=function(t){return!t&&this.instance?this.instance:new w(this,nt(this.attrs,t))},ct.compile=function(t,e){var n=Object.create(null),r=0;return t.forEach((function(t,o){return n[t]=new ct(t,r++,e,o)})),n},ct.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},ct.prototype.isInSet=function(t){for(var e=0;e<t.length;e++)if(t[e].type==this)return t[e]},ct.prototype.excludes=function(t){return this.excluded.indexOf(t)>-1};var ht=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)}))};ht.prototype.parse=function(t,e){void 0===e&&(e={});var n=new mt(this,e,!1);return n.addAll(t,null,e.from,e.to),n.finish()},ht.prototype.parseSlice=function(t,e){void 0===e&&(e={});var n=new mt(this,e,!0);return n.addAll(t,null,e.from,e.to),S.maxOpen(n.finish())},ht.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(yt(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}}},ht.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}}},ht.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=function(e){var r=t.marks[e].spec.parseDOM;r&&r.forEach((function(t){n(t=gt(t)),t.mark=e}))};for(var o in t.marks)r(o);var i;for(var s in t.nodes)i=void 0,(i=t.nodes[s].spec.parseDOM)&&i.forEach((function(t){n(t=gt(t)),t.node=s}));return e},ht.fromSchema=function(t){return t.cached.domParser||(t.cached.domParser=new ht(t,ht.schemaRules(t)))};var pt={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},ft={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},lt={ol:!0,ul:!0};function ut(t){return(t?1:0)|("full"===t?2:0)}var dt=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=w.none,this.pendingMarks=r,this.stashMarks=[]};dt.prototype.findWrapping=function(t){if(!this.match){if(!this.type)return[];var e=this.type.contentMatch.fillBefore(d.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)},dt.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=d.from(this.content);return!t&&this.match&&(r=r.append(this.match.fillBefore(d.empty,!0))),this.type?this.type.create(this.attrs,r,this.marks):r},dt.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]},dt.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):wt(r.type,t))&&!r.isInSet(this.activeMarks)&&(this.activeMarks=r.addToSet(this.activeMarks),this.pendingMarks=r.removeFromSet(this.pendingMarks))}};var mt=function(t,e,n){this.parser=t,this.options=e,this.isOpen=n;var r,o=e.topNode,i=ut(e.preserveWhitespace)|(n?4:0);r=o?new dt(o.type,o.attrs,w.none,w.none,!0,e.topMatch||o.type.contentMatch,i):new dt(n?null:t.schema.topNodeType,null,w.none,w.none,!0,null,i),this.nodes=[r],this.open=0,this.find=e.findPositions,this.needsBlock=!1},vt={top:{configurable:!0},currentPos:{configurable:!0}};function yt(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function gt(t){var e={};for(var n in t)e[n]=t[n];return e}function wt(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}}vt.top.get=function(){return this.nodes[this.open]},mt.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){var e,n=/\s*([\w-]+)\s*:\s*([^;]+)/g,r=[];for(;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)}},mt.prototype.addTextNode=function(t){var e=t.nodeValue,n=this.top;if((n.type?n.type.inlineContent:n.content.length&&n.content[0].isInline)||/[^ \t\r\n\u000c]/.test(e)){if(1&n.options)2&n.options||(e=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)},mt.prototype.addElement=function(t,e){var n,r=t.nodeName.toLowerCase();lt.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&&lt.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:ft.hasOwnProperty(r))this.findInside(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(pt.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)},mt.prototype.leafFallback=function(t){"BR"==t.nodeName&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(t.ownerDocument.createTextNode("\n"))},mt.prototype.readStyles=function(t){var e=w.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},mt.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)},mt.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&&pt.hasOwnProperty(i.nodeName.toLowerCase())&&this.sync(e);this.findAtPoint(t,o)},mt.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},mt.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},mt.prototype.enter=function(t,e,n){var r=this.findPlace(t.create(e));return r&&this.enterInner(t,e,!0,n),r},mt.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:ut(r);4&o.options&&0==o.content.length&&(i|=4),this.nodes.push(new dt(t,e,o.activeMarks,o.pendingMarks,n,null,i)),this.open++},mt.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}},mt.prototype.finish=function(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(this.isOpen||this.options.topOpen)},mt.prototype.sync=function(t){for(var e=this.open;e>=0;e--)if(this.nodes[e]==t)return void(this.open=e)},vt.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},mt.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)},mt.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)},mt.prototype.findAround=function(t,e,n){if(t!=e&&this.find)for(var r=0;r<this.find.length;r++){if(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)}},mt.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))},mt.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 h=a>0||0==a&&o?e.nodes[a].type:r&&a>=i?r.node(a-i).type:null;if(!h||h.name!=c&&-1==h.groups.indexOf(c))return!1;a--}return!0};return s(n.length-1,this.open)},mt.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}},mt.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)},mt.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(mt.prototype,vt);var bt=function(t,e){this.nodes=t||{},this.marks=e||{}};function St(t){var e={};for(var n in t){var r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function kt(t){return t.document||window.document}bt.prototype.serializeFragment=function(t,e,n){var r=this;void 0===e&&(e={}),n||(n=kt(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++],h=r.serializeMark(c,t.isInline,e);h&&(i.push(c,o),o.appendChild(h.dom),o=h.contentDOM||h.dom)}}o.appendChild(r.serializeNode(t,e))})),n},bt.prototype.serializeNode=function(t,e){void 0===e&&(e={});var n=bt.renderSpec(kt(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},bt.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},bt.prototype.serializeMark=function(t,e,n){void 0===n&&(n={});var r=this.marks[t.type.name];return r&&bt.renderSpec(kt(n),r(t,e))},bt.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 h in c=2,a)if(null!=a[h]){var p=h.indexOf(" ");p>0?s.setAttributeNS(h.slice(0,p),h.slice(p+1),a[h]):s.setAttribute(h,a[h])}for(var f=c;f<e.length;f++){var l=e[f];if(0===l){if(f<e.length-1||f>c)throw new RangeError("Content hole must be the only child of its parent node");return{dom:s,contentDOM:s}}var u=bt.renderSpec(t,l,n),d=u.dom,m=u.contentDOM;if(s.appendChild(d),m){if(i)throw new RangeError("Multiple content holes");i=m}}return{dom:s,contentDOM:i}},bt.fromSchema=function(t){return t.cached.domSerializer||(t.cached.domSerializer=new bt(this.nodesFromSchema(t),this.marksFromSchema(t)))},bt.nodesFromSchema=function(t){var e=St(t.nodes);return e.text||(e.text=function(t){return t.text}),e},bt.marksFromSchema=function(t){return St(t.marks)};var xt=Math.pow(2,16);function Ot(t){return 65535&t}var Ct=function(t,e,n){void 0===e&&(e=!1),void 0===n&&(n=null),this.pos=t,this.deleted=e,this.recover=n},Mt=function(t,e){void 0===e&&(e=!1),this.ranges=t,this.inverted=e};Mt.prototype.recover=function(t){var e=0,n=Ot(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))/xt}(t)},Mt.prototype.mapResult=function(t,e){return void 0===e&&(e=1),this._map(t,e,!1)},Mt.prototype.map=function(t,e){return void 0===e&&(e=1),this._map(t,e,!0)},Mt.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],h=this.ranges[s+i],p=a+c;if(t<=p){var f=a+r+((c?t==a?-1:t==p?1:e:e)<0?0:h);if(n)return f;var l=t==(e<0?a:p)?null:s/3+(t-a)*xt;return new Ct(f,e<0?t!=a:t!=p,l)}r+=h-c}return n?t+r:new Ct(t+r)},Mt.prototype.touches=function(t,e){for(var n=0,r=Ot(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},Mt.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],h=this.ranges[r+n];t(s,s+c,a,a+h),o+=h-c}},Mt.prototype.invert=function(){return new Mt(this.ranges,!this.inverted)},Mt.prototype.toString=function(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)},Mt.offset=function(t){return 0==t?Mt.empty:new Mt(t<0?[0,-t,0]:[0,0,t])},Mt.empty=new Mt([]);var Nt=function(t,e,n,r){this.maps=t||[],this.from=n||0,this.to=null==r?this.maps.length:r,this.mirror=e};function Dt(t){var e=Error.call(this,t);return e.__proto__=Dt.prototype,e}Nt.prototype.slice=function(t,e){return void 0===t&&(t=0),void 0===e&&(e=this.maps.length),new Nt(this.maps,this.mirror,t,e)},Nt.prototype.copy=function(){return new Nt(this.maps.slice(),this.mirror&&this.mirror.slice(),this.from,this.to)},Nt.prototype.appendMap=function(t,e){this.to=this.maps.push(t),null!=e&&this.setMirror(this.maps.length-1,e)},Nt.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)}},Nt.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)]},Nt.prototype.setMirror=function(t,e){this.mirror||(this.mirror=[]),this.mirror.push(t,e)},Nt.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)}},Nt.prototype.invert=function(){var t=new Nt;return t.appendMappingInverted(this),t},Nt.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},Nt.prototype.mapResult=function(t,e){return void 0===e&&(e=1),this._map(t,e,!1)},Nt.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 Ct(t,r)},Dt.prototype=Object.create(Error.prototype),Dt.prototype.constructor=Dt,Dt.prototype.name="TransformError";var Tt=function(t){this.doc=t,this.steps=[],this.docs=[],this.mapping=new Nt},At={before:{configurable:!0},docChanged:{configurable:!0}};function Et(){throw new Error("Override me")}At.before.get=function(){return this.docs.length?this.docs[0]:this.doc},Tt.prototype.step=function(t){var e=this.maybeStep(t);if(e.failed)throw new Dt(e.failed);return this},Tt.prototype.maybeStep=function(t){var e=t.apply(this.doc);return e.failed||this.addStep(t,e.doc),e},At.docChanged.get=function(){return this.steps.length>0},Tt.prototype.addStep=function(t,e){this.docs.push(this.doc),this.steps.push(t),this.mapping.appendMap(t.getMap()),this.doc=e},Object.defineProperties(Tt.prototype,At);var Rt=Object.create(null),Pt=function(){};Pt.prototype.apply=function(t){return Et()},Pt.prototype.getMap=function(){return Mt.empty},Pt.prototype.invert=function(t){return Et()},Pt.prototype.map=function(t){return Et()},Pt.prototype.merge=function(t){return null},Pt.prototype.toJSON=function(){return Et()},Pt.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)},Pt.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 zt=function(t,e){this.doc=t,this.failed=e};zt.ok=function(t){return new zt(t,null)},zt.fail=function(t){return new zt(null,t)},zt.fromReplace=function(t,e,n,r){try{return zt.ok(t.replace(e,n,r))}catch(t){if(t instanceof b)return zt.fail(t.message);throw t}};var It=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&&Ft(t,this.from,this.to)?zt.fail("Structure replace would overwrite content"):zt.fromReplace(t,this.from,this.to,this.slice)},e.prototype.getMap=function(){return new Mt([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?S.empty:new S(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?S.empty:new S(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,S.fromJSON(t,n.slice),!!n.structure)},e}(Pt);Pt.jsonID("replace",It);var Bt=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&&(Ft(t,this.from,this.gapFrom)||Ft(t,this.gapTo,this.to)))return zt.fail("Structure gap-replace would overwrite content");var e=t.slice(this.gapFrom,this.gapTo);if(e.openStart||e.openEnd)return zt.fail("Gap is not a flat range");var n=this.slice.insertAt(this.insert,e.content);return n?zt.fromReplace(t,this.from,this.to,n):zt.fail("Content does not fit in gap")},e.prototype.getMap=function(){return new Mt([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,S.fromJSON(t,n.slice),n.insert,!!n.structure)},e}(Pt);function Ft(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 Vt(t,e,n){for(var r=[],o=0;o<t.childCount;o++){var i=t.child(o);i.content.size&&(i=i.copy(Vt(i.content,e,i))),i.isInline&&(i=e(i,n,o)),r.push(i)}return d.fromArray(r)}Pt.jsonID("replaceAround",Bt),Tt.prototype.lift=function(t,e){for(var n=t.$from,r=t.$to,o=t.depth,i=n.before(o+1),s=r.after(o+1),a=i,c=s,h=d.empty,p=0,f=o,l=!1;f>e;f--)l||n.index(f)>0?(l=!0,h=d.from(n.node(f).copy(h)),p++):a--;for(var u=d.empty,m=0,v=o,y=!1;v>e;v--)y||r.after(v+1)<r.end(v)?(y=!0,u=d.from(r.node(v).copy(u)),m++):c++;return this.step(new Bt(a,c,i,s,new S(h.append(u),p,m),h.size-p,!0))},Tt.prototype.wrap=function(t,e){for(var n=d.empty,r=e.length-1;r>=0;r--)n=d.from(e[r].type.create(e[r].attrs,n));var o=t.start,i=t.end;return this.step(new Bt(o,i,o,i,new S(n,0,0),e.length,!0))},Tt.prototype.setBlockType=function(t,e,n,r){var o=this;if(void 0===e&&(e=t),!n.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");var i=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)}(o.doc,o.mapping.slice(i).map(e),n)){o.clearIncompatible(o.mapping.slice(i).map(e,1),n);var s=o.mapping.slice(i),a=s.map(e,1),c=s.map(e+t.nodeSize,1);return o.step(new Bt(a,c,a+1,c-1,new S(d.from(n.create(r,null,t.marks)),0,0),1,!0)),!1}})),this},Tt.prototype.setNodeMarkup=function(t,e,n,r){var o=this.doc.nodeAt(t);if(!o)throw new RangeError("No node at given position");e||(e=o.type);var i=e.create(n,null,r||o.marks);if(o.isLeaf)return this.replaceWith(t,t+o.nodeSize,i);if(!e.validContent(o.content))throw new RangeError("Invalid content for node type "+e.name);return this.step(new Bt(t,t+o.nodeSize,t+1,t+o.nodeSize-1,new S(d.from(i),0,0),1,!0))},Tt.prototype.split=function(t,e,n){void 0===e&&(e=1);for(var r=this.doc.resolve(t),o=d.empty,i=d.empty,s=r.depth,a=r.depth-e,c=e-1;s>a;s--,c--){o=d.from(r.node(s).copy(o));var h=n&&n[c];i=d.from(h?h.type.create(h.attrs,i):r.node(s).copy(i))}return this.step(new It(t,t,new S(o.append(i),e,e),!0))},Tt.prototype.join=function(t,e){void 0===e&&(e=1);var n=new It(t-e,t+e,S.empty,!0);return this.step(n)};var $t=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 S(Vt(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 zt.fromReplace(t,this.from,this.to,i)},e.prototype.invert=function(){return new _t(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}(Pt);Pt.jsonID("addMark",$t);var _t=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 S(Vt(n.content,(function(t){return t.mark(e.mark.removeFromSet(t.marks))})),n.openStart,n.openEnd);return zt.fromReplace(t,this.from,this.to,r)},e.prototype.invert=function(){return new $t(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}(Pt);function Lt(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}Pt.jsonID("removeMark",_t),Tt.prototype.addMark=function(t,e,n){var r=this,o=[],i=[],s=null,a=null;return this.doc.nodesBetween(t,e,(function(r,c,h){if(r.isInline){var p=r.marks;if(!n.isInSet(p)&&h.type.allowsMarkType(n.type)){for(var f=Math.max(c,t),l=Math.min(c+r.nodeSize,e),u=n.addToSet(p),d=0;d<p.length;d++)p[d].isInSet(u)||(s&&s.to==f&&s.mark.eq(p[d])?s.to=l:o.push(s=new _t(f,l,p[d])));a&&a.to==f?a.to=l:i.push(a=new $t(f,l,n))}}})),o.forEach((function(t){return r.step(t)})),i.forEach((function(t){return r.step(t)})),this},Tt.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 ct)for(var c,h=r.marks;c=n.isInSet(h);)(a||(a=[])).push(c),h=c.removeFromSet(h);else n?n.isInSet(r.marks)&&(a=[n]):a=r.marks;if(a&&a.length)for(var p=Math.min(s+r.nodeSize,e),f=0;f<a.length;f++){for(var l=a[f],u=void 0,d=0;d<o.length;d++){var m=o[d];m.step==i-1&&l.eq(o[d].style)&&(u=m)}u?(u.to=p,u.step=i):o.push({style:l,from:Math.max(s,t),to:p,step:i})}}})),o.forEach((function(t){return r.step(new _t(t.from,t.to,t.style))})),this},Tt.prototype.clearIncompatible=function(t,e,n){void 0===n&&(n=e.contentMatch);for(var r=this.doc.nodeAt(t),o=[],i=t+1,s=0;s<r.childCount;s++){var a=r.child(s),c=i+a.nodeSize,h=n.matchType(a.type,a.attrs);if(h){n=h;for(var p=0;p<a.marks.length;p++)e.allowsMarkType(a.marks[p].type)||this.step(new _t(i,c,a.marks[p]))}else o.push(new It(i,c,S.empty));i=c}if(!n.validEnd){var f=n.fillBefore(d.empty,!0);this.replace(i,i,new S(f,0,0))}for(var l=o.length-1;l>=0;l--)this.step(o[l]);return this},Tt.prototype.replace=function(t,e,n){void 0===e&&(e=t),void 0===n&&(n=S.empty);var r=function(t,e,n,r){if(void 0===n&&(n=e),void 0===r&&(r=S.empty),e==n&&!r.size)return null;var o=t.resolve(e),i=t.resolve(n);return Lt(o,i,r)?new It(e,n,r):new jt(o,i,r).fit()}(this.doc,t,e,n);return r&&this.step(r),this},Tt.prototype.replaceWith=function(t,e,n){return this.replace(t,e,new S(d.from(n),0,0))},Tt.prototype.delete=function(t,e){return this.replace(t,e,S.empty)},Tt.prototype.insert=function(t,e){return this.replaceWith(t,t,e)};var jt=function(t,e,n){this.$to=e,this.$from=t,this.unplaced=n,this.frontier=[];for(var r=0;r<=t.depth;r++){var o=t.node(r);this.frontier.push({type:o.type,match:o.contentMatchAt(t.indexAfter(r))})}this.placed=d.empty;for(var i=t.depth;i>0;i--)this.placed=d.from(t.node(i).copy(this.placed))},Jt={depth:{configurable:!0}};function qt(t,e,n){return 0==e?t.cutByIndex(n):t.replaceChild(0,t.firstChild.copy(qt(t.firstChild.content,e-1,n)))}function Wt(t,e,n){return 0==e?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(Wt(t.lastChild.content,e-1,n)))}function Kt(t,e){for(var n=0;n<e;n++)t=t.firstChild.content;return t}function Ut(t,e,n){if(e<=0)return t;var r=t.content;return e>1&&(r=r.replaceChild(0,Ut(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(d.empty,!0)))),t.copy(r)}function Ht(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 Gt(t,e,n,r,o){if(e<n){var i=t.firstChild;t=t.replaceChild(0,i.copy(Gt(i.content,e+1,n,r,i)))}if(e>r){var s=o.contentMatchAt(0),a=s.fillBefore(t).append(t);t=a.append(s.matchFragment(a).fillBefore(d.empty,!0))}return t}function Xt(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}Jt.depth.get=function(){return this.frontier.length-1},jt.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 S(i,s,a);return e>-1?new Bt(r.pos,e,this.$to.pos,this.$to.end(),c,n):c.size||r.pos!=this.$to.pos?new It(r.pos,o.pos,c):void 0},jt.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=Kt(this.unplaced.content,e-1).firstChild).content:this.unplaced.content).firstChild,o=this.depth;o>=0;o--){var i=this.frontier[o],s=i.type,a=i.match,c=void 0,h=void 0;if(1==t&&(r?a.matchType(r.type)||(h=a.fillBefore(d.from(r),!1)):s.compatibleContent(n.type)))return{sliceDepth:e,frontierDepth:o,parent:n,inject:h};if(2==t&&r&&(c=a.findWrapping(r.type)))return{sliceDepth:e,frontierDepth:o,parent:n,wrap:c};if(n&&a.matchType(n.type))break}},jt.prototype.openMore=function(){var t=this.unplaced,e=t.content,n=t.openStart,r=t.openEnd,o=Kt(e,n);return!(!o.childCount||o.firstChild.isLeaf)&&(this.unplaced=new S(e,n+1,Math.max(r,o.size+n>=e.size-r?n+1:0)),!0)},jt.prototype.dropNode=function(){var t=this.unplaced,e=t.content,n=t.openStart,r=t.openEnd,o=Kt(e,n);if(o.childCount<=1&&n>0){var i=e.size-n<=n+o.size;this.unplaced=new S(qt(e,n-1,1),n-1,i?n-1:r)}else this.unplaced=new S(qt(e,n,1),n,r)},jt.prototype.placeNodes=function(t){for(var e=t.sliceDepth,n=t.frontierDepth,r=t.parent,o=t.inject,i=t.wrap;this.depth>n;)this.closeFrontierNode();if(i)for(var s=0;s<i.length;s++)this.openFrontierNode(i[s]);var a=this.unplaced,c=r?r.content:a.content,h=a.openStart-e,p=0,f=[],l=this.frontier[n],u=l.match,m=l.type;if(o){for(var v=0;v<o.childCount;v++)f.push(o.child(v));u=u.matchFragment(o)}for(var y=c.size+e-(a.content.size-a.openEnd);p<c.childCount;){var g=c.child(p),w=u.matchType(g.type);if(!w)break;(++p>1||0==h||g.content.size)&&(u=w,f.push(Ut(g.mark(m.allowedMarks(g.marks)),1==p?h:0,p==c.childCount?y:-1)))}var b=p==c.childCount;b||(y=-1),this.placed=Wt(this.placed,n,d.from(f)),this.frontier[n].match=u,b&&y<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(var k=0,x=c;k<y;k++){var O=x.lastChild;this.frontier.push({type:O.type,match:O.contentMatchAt(O.childCount)}),x=O.content}this.unplaced=b?0==e?S.empty:new S(qt(a.content,e-1,1),e-1,y<0?a.openEnd:e-1):new S(qt(a.content,e,p),a.openStart,a.openEnd)},jt.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||!Ht(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},jt.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=Ht(t,e,o,r,i);if(s){for(var a=e-1;a>=0;a--){var c=this.frontier[a],h=c.match,p=Ht(t,a,c.type,h,!0);if(!p||p.childCount)continue t}return{depth:e,fit:s,move:i?t.doc.resolve(t.after(e+1)):t}}}},jt.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=Wt(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},jt.prototype.openFrontierNode=function(t,e,n){var r=this.frontier[this.depth];r.match=r.match.matchType(t),this.placed=Wt(this.placed,this.depth,d.from(t.create(e,n))),this.frontier.push({type:t,match:t.contentMatch})},jt.prototype.closeFrontierNode=function(){var t=this.frontier.pop().match.fillBefore(d.empty,!0);t.childCount&&(this.placed=Wt(this.placed,this.frontier.length,t))},Object.defineProperties(jt.prototype,Jt),Tt.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(Lt(r,o,n))return this.step(new It(t,e,n));var i=Xt(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 h=r.node(a).type.spec;if(h.defining||h.isolating)break;i.indexOf(a)>-1?s=a:r.before(a)==c&&i.splice(1,0,-a)}for(var p=i.indexOf(s),f=[],l=n.openStart,u=n.content,d=0;;d++){var m=u.firstChild;if(f.push(m),d==n.openStart)break;u=m.content}l>0&&f[l-1].type.spec.defining&&r.node(p).type!=f[l-1].type?l-=1:l>=2&&f[l-1].isTextblock&&f[l-2].type.spec.defining&&r.node(p).type!=f[l-2].type&&(l-=2);for(var v=n.openStart;v>=0;v--){var y=(v+l+1)%(n.openStart+1),g=f[y];if(g)for(var w=0;w<i.length;w++){var b=i[(w+p)%i.length],k=!0;b<0&&(k=!1,b=-b);var x=r.node(b-1),O=r.index(b-1);if(x.canReplaceWith(O,O,g.type,g.marks))return this.replace(r.before(b),k?o.after(b):e,new S(Gt(n.content,0,n.openStart,y),y,n.openEnd))}}for(var C=this.steps.length,M=i.length-1;M>=0&&(this.replace(t,e,n),!(this.steps.length>C));M--){var N=i[M];M<0||(t=r.before(N),e=o.after(N))}return this},Tt.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 S(d.from(n),0,0))},Tt.prototype.deleteRange=function(t,e){for(var n=this.doc.resolve(t),r=this.doc.resolve(e),o=Xt(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 Yt=Object.create(null),Qt=function(t,e,n){this.ranges=n||[new te(t.min(e),t.max(e))],this.$anchor=t,this.$head=e},Zt={anchor:{configurable:!0},head:{configurable:!0},from:{configurable:!0},to:{configurable:!0},$from:{configurable:!0},$to:{configurable:!0},empty:{configurable:!0}};Zt.anchor.get=function(){return this.$anchor.pos},Zt.head.get=function(){return this.$head.pos},Zt.from.get=function(){return this.$from.pos},Zt.to.get=function(){return this.$to.pos},Zt.$from.get=function(){return this.ranges[0].$from},Zt.$to.get=function(){return this.ranges[0].$to},Zt.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},Qt.prototype.content=function(){return this.$from.node(0).slice(this.from,this.to,!0)},Qt.prototype.replace=function(t,e){void 0===e&&(e=S.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],h=c.$from,p=c.$to,f=t.mapping.slice(i);t.replaceRange(f.map(h.pos),f.map(p.pos),a?S.empty:e),0==a&&ce(t,i,(n?n.isInline:r&&r.isTextblock)?-1:1)}},Qt.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),h=c.map(s.pos),p=c.map(a.pos);o?t.deleteRange(h,p):(t.replaceRangeWith(h,p,e),ce(t,n,e.isInline?-1:1))}},Qt.findFrom=function(t,e,n){var r=t.parent.inlineContent?new ee(t):ae(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?ae(t.node(0),t.node(o),t.before(o+1),t.index(o),e,n):ae(t.node(0),t.node(o),t.after(o+1),t.index(o)+1,e,n);if(i)return i}},Qt.near=function(t,e){return void 0===e&&(e=1),this.findFrom(t,e)||this.findFrom(t,-e)||new ie(t.node(0))},Qt.atStart=function(t){return ae(t,t,0,0,1)||new ie(t)},Qt.atEnd=function(t){return ae(t,t,t.content.size,t.childCount,-1)||new ie(t)},Qt.fromJSON=function(t,e){if(!e||!e.type)throw new RangeError("Invalid input for Selection.fromJSON");var n=Yt[e.type];if(!n)throw new RangeError("No selection type "+e.type+" defined");return n.fromJSON(t,e)},Qt.jsonID=function(t,e){if(t in Yt)throw new RangeError("Duplicate use of selection JSON ID "+t);return Yt[t]=e,e.prototype.jsonID=t,e},Qt.prototype.getBookmark=function(){return ee.between(this.$anchor,this.$head).getBookmark()},Object.defineProperties(Qt.prototype,Zt),Qt.prototype.visible=!0;var te=function(t,e){this.$from=t,this.$to=e},ee=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=S.empty),t.prototype.replace.call(this,e,n),n==S.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 ne(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}(Qt);Qt.jsonID("text",ee);var ne=function(t,e){this.anchor=t,this.head=e};ne.prototype.map=function(t){return new ne(t.map(this.anchor),t.map(this.head))},ne.prototype.resolve=function(t){return ee.between(t.resolve(this.anchor),t.resolve(this.head))};var re=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 S(d.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 oe(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}(Qt);re.prototype.visible=!1,Qt.jsonID("node",re);var oe=function(t){this.anchor=t};oe.prototype.map=function(t){var e=t.mapResult(this.anchor),n=e.deleted,r=e.pos;return n?new ne(r,r):new oe(r)},oe.prototype.resolve=function(t){var e=t.resolve(this.anchor),n=e.nodeAfter;return n&&re.isSelectable(n)?new re(e):Qt.near(e)};var ie=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=S.empty),n==S.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 se},e}(Qt);Qt.jsonID("all",ie);var se={map:function(){return this},resolve:function(t){return new ie(t)}};function ae(t,e,n,r,o,i){if(e.inlineContent)return ee.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&&re.isSelectable(a))return re.create(t,n-(o<0?a.nodeSize:0))}else{var c=ae(t,a,n+o,o<0?a.childCount:0,o,i);if(c)return c}n+=a.nodeSize*o}}function ce(t,e,n){var r=t.steps.length-1;if(!(r<e)){var o,i=t.steps[r];if(i instanceof It||i instanceof Bt)t.mapping.maps[r].forEach((function(t,e,n,r){null==o&&(o=r)})),t.setSelection(Qt.near(t.doc.resolve(o),n))}}var he=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 w.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)||w.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(Qt.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}(Tt);function pe(t,e){return e&&t?t.bind(e):t}var fe=function(t,e,n){this.name=t,this.init=pe(e.init,n),this.apply=pe(e.apply,n)},le=[new fe("doc",{init:function(t){return t.doc||t.schema.topNodeType.createAndFill()},apply:function(t){return t.doc}}),new fe("selection",{init:function(t,e){return t.selection||Qt.atStart(e.doc)},apply:function(t){return t.selection}}),new fe("storedMarks",{init:function(t){return t.storedMarks||null},apply:function(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new fe("scrollToSelection",{init:function(){return 0},apply:function(t,e){return t.scrolledIntoView?e+1:e}})],ue=function(t,e){var n=this;this.schema=t,this.fields=le.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 fe(t.key,t.spec.state,t))}))},de=function(t){this.config=t},me={schema:{configurable:!0},plugins:{configurable:!0},tr:{configurable:!0}};me.schema.get=function(){return this.config.schema},me.plugins.get=function(){return this.config.plugins},de.prototype.apply=function(t){return this.applyTransaction(t).state},de.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},de.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,h=a<e.length&&s.spec.appendTransaction.call(s,a?e.slice(a):e,c,n);if(h&&n.filterTransaction(h,i)){if(h.setMeta("appendedTransaction",t),!r){r=[];for(var p=0;p<this.config.plugins.length;p++)r.push(p<i?{state:n,n:e.length}:{state:this,n:0})}e.push(h),n=n.applyInner(h),o=!0}r&&(r[i]={state:n,n:e.length})}}if(!o)return{state:n,transactions:e}}},de.prototype.applyInner=function(t){if(!t.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");for(var e=new de(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<ve.length;i++)ve[i](this,t,e);return e},me.tr.get=function(){return new he(this)},de.create=function(t){for(var e=new ue(t.doc?t.doc.type.schema:t.schema,t.plugins),n=new de(e),r=0;r<e.fields.length;r++)n[e.fields[r].name]=e.fields[r].init(t,n);return n},de.prototype.reconfigure=function(t){for(var e=new ue(this.schema,t.plugins),n=e.fields,r=new de(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},de.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},de.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 ue(t.schema,t.plugins),o=new de(r);return r.fields.forEach((function(r){if("doc"==r.name)o.doc=j.fromJSON(t.schema,e.doc);else if("selection"==r.name)o.selection=Qt.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},de.addApplyListener=function(t){ve.push(t)},de.removeApplyListener=function(t){var e=ve.indexOf(t);e>-1&&ve.splice(e,1)},Object.defineProperties(de.prototype,me);var ve=[];function ye(t,e,n){for(var r in t){var o=t[r];o instanceof Function?o=o.bind(e):"handleDOMEvents"==r&&(o=ye(o,e,{})),n[r]=o}return n}var ge=function(t){this.props={},t.props&&ye(t.props,this,this.props),this.spec=t,this.key=t.key?t.key.key:function(t){if(t in we)return t+"$"+ ++we[t];return we[t]=0,t+"$"}("plugin")};ge.prototype.getState=function(t){return t[this.key]};var we=Object.create(null);var be="undefined"!=typeof navigator&&/Mac/.test(navigator.platform);function Se(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);be?o=!0:n=!0}}return e&&(s="Alt-"+s),n&&(s="Ctrl-"+s),o&&(s="Meta-"+s),r&&(s="Shift-"+s),s}function ke(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}var xe={};if("undefined"!=typeof navigator&&"undefined"!=typeof document){var Oe=/Edge\/(\d+)/.exec(navigator.userAgent),Ce=/MSIE \d/.test(navigator.userAgent),Me=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);xe.mac=/Mac/.test(navigator.platform);var Ne=xe.ie=!!(Ce||Me||Oe);xe.ie_version=Ce?document.documentMode||6:Me?+Me[1]:Oe?+Oe[1]:null,xe.gecko=!Ne&&/gecko\/(\d+)/i.test(navigator.userAgent),xe.gecko_version=xe.gecko&&+(/Firefox\/(\d+)/.exec(navigator.userAgent)||[0,0])[1];var De=!Ne&&/Chrome\/(\d+)/.exec(navigator.userAgent);xe.chrome=!!De,xe.chrome_version=De&&+De[1],xe.safari=!Ne&&/Apple Computer/.test(navigator.vendor),xe.ios=xe.safari&&(/Mobile\/\w+/.test(navigator.userAgent)||navigator.maxTouchPoints>2),xe.android=/Android \d/.test(navigator.userAgent),xe.webkit="webkitFontSmoothing"in document.documentElement.style,xe.webkit_version=xe.webkit&&+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]}var Te=function(t){for(var e=0;;e++)if(!(t=t.previousSibling))return e},Ae=function(t){var e=t.parentNode;return e&&11==e.nodeType?e.host:e},Ee=null,Re=function(t,e,n){var r=Ee||(Ee=document.createRange());return r.setEnd(t,null==n?t.nodeValue.length:n),r.setStart(t,e||0),r},Pe=function(t,e,n,r){return n&&(Ie(t,e,n,r,-1)||Ie(t,e,n,r,1))},ze=/^(img|br|input|textarea|hr)$/i;function Ie(t,e,n,r,o){for(;;){if(t==n&&e==r)return!0;if(e==(o<0?0:Be(t))){var i=t.parentNode;if(1!=i.nodeType||Fe(t)||ze.test(t.nodeName)||"false"==t.contentEditable)return!1;e=Te(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?Be(t):0}}}function Be(t){return 3==t.nodeType?t.nodeValue.length:t.childNodes.length}function Fe(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 Ve=function(t){var e=t.isCollapsed;return e&&xe.chrome&&t.rangeCount&&!t.getRangeAt(0).collapsed&&(e=!1),e};function $e(t,e){var n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}function _e(t){return{left:0,right:t.documentElement.clientWidth,top:0,bottom:t.documentElement.clientHeight}}function Le(t,e){return"number"==typeof t?t:t[e]}function je(t){var e=t.getBoundingClientRect();return{left:e.left,right:e.left+t.clientWidth,top:e.top,bottom:e.top+t.clientHeight}}function Je(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=Ae(s))if(1==s.nodeType){var a=s==i.body||1!=s.nodeType,c=a?_e(i):je(s),h=0,p=0;if(e.top<c.top+Le(r,"top")?p=-(c.top-e.top+Le(o,"top")):e.bottom>c.bottom-Le(r,"bottom")&&(p=e.bottom-c.bottom+Le(o,"bottom")),e.left<c.left+Le(r,"left")?h=-(c.left-e.left+Le(o,"left")):e.right>c.right-Le(r,"right")&&(h=e.right-c.right+Le(o,"right")),h||p)if(a)i.defaultView.scrollBy(h,p);else{var f=s.scrollLeft,l=s.scrollTop;p&&(s.scrollTop+=p),h&&(s.scrollLeft+=h);var u=s.scrollLeft-f,d=s.scrollTop-l;e={left:e.left-u,top:e.top-d,right:e.right-u,bottom:e.bottom-d}}if(a)break}}function qe(t){for(var e=[],n=t.ownerDocument;t&&(e.push({dom:t,top:t.scrollTop,left:t.scrollLeft}),t!=n);t=Ae(t));return e}function We(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 Ke=null;function Ue(t,e){for(var n,r,o=2e8,i=0,s=e.top,a=e.top,c=t.firstChild,h=0;c;c=c.nextSibling,h++){var p=void 0;if(1==c.nodeType)p=c.getClientRects();else{if(3!=c.nodeType)continue;p=Re(c).getClientRects()}for(var f=0;f<p.length;f++){var l=p[f];if(l.top<=s&&l.bottom>=a){s=Math.max(l.bottom,s),a=Math.min(l.top,a);var u=l.left>e.left?l.left-e.left:l.right<e.left?e.left-l.right:0;if(u<o){n=c,o=u,r=u&&3==n.nodeType?{left:l.right<e.left?l.right:l.left,top:e.top}:e,1==c.nodeType&&u&&(i=h+(e.left>=(l.left+l.right)/2?1:0));continue}}!n&&(e.left>=l.right&&e.top>=l.top||e.left>=l.left&&e.top>=l.bottom)&&(i=h+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=Ye(r,1);if(i.top!=i.bottom&&He(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}:Ue(n,r)}function He(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function Ge(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 h=a[c];if(He(e,h))return Ge(s,e,h)}if((i=(i+1)%r)==o)break}return t}function Xe(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 h,p=s.elementFromPoint(e.left,e.top+1);if(!p||!t.dom.contains(1!=p.nodeType?p.parentNode:p)){var f=t.dom.getBoundingClientRect();if(!He(e,f))return null;if(!(p=Ge(t.dom,e,f)))return null}if(xe.safari&&p.draggable&&(o=i=null),p=function(t,e){var n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}(p,e),o){if(xe.gecko&&1==o.nodeType&&(i=Math.min(i,o.childNodes.length))<o.childNodes.length){var l,u=o.childNodes[i];"IMG"==u.nodeName&&(l=u.getBoundingClientRect()).right<=e.left&&l.bottom>e.top&&i++}o==t.dom&&i==o.childNodes.length-1&&1==o.lastChild.nodeType&&e.top>o.lastChild.getBoundingClientRect().bottom?h=t.state.doc.content.size:0!=i&&1==o.nodeType&&"BR"==o.childNodes[i-1].nodeName||(h=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==h&&(h=function(t,e,n){var r=Ue(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,p,e));var d=t.docView.nearestDesc(p,!0);return{pos:h,inside:d?d.posAtStart-d.border:-1}}function Ye(t,e){var n=t.getClientRects();return n.length?n[e<0?0:n.length-1]:t.getBoundingClientRect()}var Qe=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Ze(t,e,n){var r=t.docView.domFromPos(e,n<0?-1:1),o=r.node,i=r.offset,s=xe.webkit||xe.gecko;if(3==o.nodeType){if(!s||!Qe.test(o.nodeValue)&&(n<0?i:i!=o.nodeValue.length)){var a=i,c=i,h=n<0?1:-1;return n<0&&!i?(c++,h=-1):n>=0&&i==o.nodeValue.length?(a--,h=1):n<0?a--:c++,tn(Ye(Re(o,a,c),h),h<0)}var p=Ye(Re(o,i,i),n);if(xe.gecko&&i&&/\s/.test(o.nodeValue[i-1])&&i<o.nodeValue.length){var f=Ye(Re(o,i-1,i-1),-1);if(f.top==p.top){var l=Ye(Re(o,i,i+1),-1);if(l.top!=p.top)return tn(l,l.left<f.left)}}return p}if(!t.state.doc.resolve(e).parent.inlineContent){if(i&&(n<0||i==Be(o))){var u=o.childNodes[i-1];if(1==u.nodeType)return en(u.getBoundingClientRect(),!1)}if(i<Be(o)){var d=o.childNodes[i];if(1==d.nodeType)return en(d.getBoundingClientRect(),!0)}return en(o.getBoundingClientRect(),n>=0)}if(i&&(n<0||i==Be(o))){var m=o.childNodes[i-1],v=3==m.nodeType?Re(m,Be(m)-(s?0:1)):1!=m.nodeType||"BR"==m.nodeName&&m.nextSibling?null:m;if(v)return tn(Ye(v,1),!1)}if(i<Be(o)){var y=o.childNodes[i],g=3==y.nodeType?Re(y,0,s?0:1):1==y.nodeType?y:null;if(g)return tn(Ye(g,-1),!0)}return tn(Ye(3==o.nodeType?Re(o):o,-n),n>=0)}function tn(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 en(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 nn(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 rn=/[\u0590-\u08ac]/;var on=null,sn=null,an=!1;function cn(t,e,n){return on==e&&sn==n?an:(on=e,sn=n,an="up"==n||"down"==n?function(t,e,n){var r=e.selection,o="up"==n?r.$from:r.$to;return nn(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=Ze(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=Re(s,0,s.nodeValue.length).getClientRects()}for(var c=0;c<a.length;c++){var h=a[c];if(h.bottom>h.top&&("up"==n?h.bottom<i.top+1:h.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 rn.test(r.parent.textContent)&&a.modify?nn(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))}var hn=function(t,e,n,r){this.parent=t,this.children=e,this.dom=n,n.pmViewDesc=this,this.contentDOM=r,this.dirty=0},pn={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}};hn.prototype.matchesWidget=function(){return!1},hn.prototype.matchesMark=function(){return!1},hn.prototype.matchesNode=function(){return!1},hn.prototype.matchesHack=function(){return!1},pn.beforePosition.get=function(){return!1},hn.prototype.parseRule=function(){return null},hn.prototype.stopEvent=function(){return!1},pn.size.get=function(){for(var t=0,e=0;e<this.children.length;e++)t+=this.children[e].size;return t},pn.border.get=function(){return 0},hn.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()},hn.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}},pn.posBefore.get=function(){return this.parent.posBeforeChild(this)},pn.posAtStart.get=function(){return this.parent?this.parent.posBeforeChild(this)+this.border:0},pn.posAfter.get=function(){return this.posBefore+this.size},pn.posAtEnd.get=function(){return this.posAtStart+this.size-2*this.border},hn.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>Te(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 h=t;;h=h.parentNode){if(h==this.dom){a=!0;break}if(h.parentNode.lastChild!=h)break}}return(null==a?n>0:a)?this.posAtEnd:this.posAtStart},hn.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}}},hn.prototype.getDesc=function(t){for(var e=t.pmViewDesc,n=e;n;n=n.parent)if(n==this)return e},hn.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},hn.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}},hn.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?Te(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}},hn.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 h=i+a.border;if(t>=h&&e<=c-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(t,e,h);t=i;for(var p=s;p>0;p--){var f=this.children[p-1];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(1)){r=Te(f.dom)+1;break}t-=f.size}-1==r&&(r=0)}if(r>-1&&(c>e||s==this.children.length-1)){e=c;for(var l=s+1;l<this.children.length;l++){var u=this.children[l];if(u.size&&u.dom.parentNode==this.contentDOM&&!u.emptyChildAt(-1)){o=Te(u.dom);break}e+=u.size}-1==o&&(o=this.contentDOM.childNodes.length);break}i=c}return{node:this.contentDOM,from:t,to:e,fromOffset:r,toOffset:o}},hn.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)},hn.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]},hn.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],h=a+c.size;if(o>a&&i<h)return c.setSelection(t-a-c.border,e-a-c.border,n,r);a=h}var p=this.domFromPos(t,t?-1:1),f=e==t?p:this.domFromPos(e,e?-1:1),l=n.getSelection(),u=!1;if((xe.gecko||xe.safari)&&t==e){var d=p.node,m=p.offset;if(3==d.nodeType)(u=m&&"\n"==d.nodeValue[m-1])&&m==d.nodeValue.length&&d.nextSibling&&"BR"==d.nextSibling.nodeName&&(p=f={node:d.parentNode,offset:Te(d)+1});else{var v=d.childNodes[m-1];u=v&&("BR"==v.nodeName||"false"==v.contentEditable)}}if(r||u&&xe.safari||!Pe(p.node,p.offset,l.anchorNode,l.anchorOffset)||!Pe(f.node,f.offset,l.focusNode,l.focusOffset)){var y=!1;if((l.extend||t==e)&&!u){l.collapse(p.node,p.offset);try{t!=e&&l.extend(f.node,f.offset),y=!0}catch(t){if(!(t instanceof DOMException))throw t}}if(!y){if(t>e){var g=p;p=f,f=g}var w=document.createRange();w.setEnd(f.node,f.offset),w.setStart(p.node,p.offset),l.removeAllRanges(),l.addRange(w)}}},hn.prototype.ignoreMutation=function(t){return!this.contentDOM&&"selection"!=t.type},pn.contentLost.get=function(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)},hn.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},hn.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)}},pn.domAtom.get=function(){return!1},Object.defineProperties(hn.prototype,pn);var fn=[],ln=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,fn,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}(hn),un=function(t){function e(e,n,r,o){t.call(this,e,fn,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}(hn),dn=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=bt.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=En(i,n,s,r)),t>0&&(i=En(i,0,t,r));for(var a=0;a<i.length;a++)i[a].parent=o;return o.children=i,o},e}(hn),mn=function(t){function e(e,n,r,o,i,s,a,c,h){t.call(this,e,n.isLeaf?fn:[],i,s),this.nodeDOM=a,this.node=n,this.outerDeco=r,this.innerDeco=o,s&&this.updateChildren(c,h)}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,h=i.nodeViews[n.type.name],p=h&&h(n,i,(function(){return c?c.parent?c.parent.posBeforeChild(c):void 0:s}),r,o),f=p&&p.dom,l=p&&p.contentDOM;if(n.isText)if(f){if(3!=f.nodeType)throw new RangeError("Text must be rendered as a DOM text node")}else f=document.createTextNode(n.text);else f||(f=(a=bt.renderSpec(document,n.type.spec.toDOM(n))).dom,l=a.contentDOM);l||n.isText||"BR"==f.nodeName||(f.hasAttribute("contenteditable")||(f.contentEditable=!1),n.type.spec.draggable&&(f.draggable=!0));var u=f;return f=Mn(f,r,n),p?c=new wn(t,n,r,o,f,l,u,p,i,s+1):n.isText?new yn(t,n,r,o,f,u,i):new e(t,n,r,o,f,l,u,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?d.empty:t.node.content},e},e.prototype.matchesNode=function(t,e,n){return 0==this.dirty&&t.eq(this.node)&&Nn(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 Tn(this,i&&i.node);!function(t,e,n,r){var o=e.locals(t),i=0;if(0==o.length){for(var s=0;s<t.childCount;s++){var a=t.child(s);r(a,o,e.forChild(i,a),s),i+=a.nodeSize}return}for(var c=0,h=[],p=null,f=0;;){if(c<o.length&&o[c].to==i){for(var l=o[c++],u=void 0;c<o.length&&o[c].to==i;)(u||(u=[l])).push(o[c++]);if(u){u.sort(An);for(var d=0;d<u.length;d++)n(u[d],f,!!p)}else n(l,f,!!p)}var m=void 0,v=void 0;if(p)v=-1,m=p,p=null;else{if(!(f<t.childCount))break;v=f,m=t.child(f++)}for(var y=0;y<h.length;y++)h[y].to<=i&&h.splice(y--,1);for(;c<o.length&&o[c].from<=i&&o[c].to>i;)h.push(o[c++]);var g=i+m.nodeSize;if(m.isText){var w=g;c<o.length&&o[c].from<w&&(w=o[c].from);for(var b=0;b<h.length;b++)h[b].to<w&&(w=h[b].to);w<g&&(p=m.cut(w-i),m=m.cut(0,w-i),g=w,v=-1)}r(m,h.length?m.isInline&&!m.isLeaf?h.filter((function(t){return!t.inline})):h.slice():fn,e.forChild(i,m),v),i=g}}(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?w.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(fn,r,t),this.node.isTextblock&&s.addTextblockHacks(),s.destroyRest(),(s.changed||2==this.dirty)&&(i&&this.protectLocalComposition(t,i),bn(this.contentDOM,this.children,t),xe.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 ee)||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=Be(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 h=t.child(o++);if(i+=h.nodeSize,!h.isText)break;c+=h.text}if(i>=n){var p=c.lastIndexOf(e,r-a);if(p>=0&&p+e.length+a>=n)return a+p}}}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 un(this,i,n,o);t.compositionNodes.push(s),this.children=En(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(!Nn(t,this.outerDeco)){var e=1!=this.nodeDOM.nodeType,n=this.dom;this.dom=On(this.dom,this.nodeDOM,xn(this.outerDeco,this.node,e),xn(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}(hn);function vn(t,e,n,r,o){return Mn(r,e,t),new mn(null,t,e,n,r,r,r,o,0)}var yn=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),gn=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}(hn),wn=function(t){function e(e,n,r,o,i,s,a,c,h,p){t.call(this,e,n,r,o,i,s,a,h,p),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 bn(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=Dn(r),o=!0;r=r.nextSibling}else o=!0,t.insertBefore(a,r);if(s instanceof dn){var c=r?r.previousSibling:t.lastChild;bn(s.contentDOM,s.children,n),r=c?c.nextSibling:t.firstChild}}for(;r;)r=Dn(r),o=!0;o&&n.trackWrites==t&&(n.trackWrites=null)}function Sn(t){t&&(this.nodeName=t)}Sn.prototype=Object.create(null);var kn=[new Sn];function xn(t,e,n){if(0==t.length)return kn;for(var r=n?kn[0]:new Sn,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 Sn(s.nodeName)),s){var c=s[a];null!=c&&(n&&1==o.length&&o.push(r=new Sn(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 On(t,e,n,r){if(n==kn&&r==kn)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=kn[0]),o=c}Cn(o,a||kn[0],s)}return o}function Cn(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(" "):fn,s=n.class?n.class.split(" "):fn,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 h,p=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g;h=p.exec(e.style);)t.style.removeProperty(h[1]);n.style&&(t.style.cssText+=n.style)}}function Mn(t,e,n){return On(t,t,kn,xn(e,n,1!=t.nodeType))}function Nn(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 Dn(t){var e=t.nextSibling;return t.parentNode.removeChild(t),e}var Tn=function(t,e){this.top=t,this.lock=e,this.index=0,this.stack=[],this.changed=!1;var n=function(t,e){for(var n=[],r=t.childCount,o=e.length-1;r>0&&o>=0;o--){var i=e[o],s=i.node;if(s){if(s!=t.child(r-1))break;n.push(i),--r}}return{nodes:n.reverse(),offset:r}}(t.node.content,t.children);this.preMatched=n.nodes,this.preMatchOffset=n.offset};function An(t,e){return t.type.side-e.type.side}function En(t,e,n,r,o){for(var i=[],s=0,a=0;s<t.length;s++){var c=t[s],h=a,p=a+=c.size;h>=n||p<=e?i.push(c):(h<e&&i.push(c.slice(0,e-h,r)),o&&(i.push(o),o=null),p>n&&i.push(c.slice(n-h,c.size,r)))}return i}function Rn(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,h=r.resolve(s);if(Ve(n)){for(a=h;o&&!o.node;)o=o.parent;if(o&&o.node.isAtom&&re.isSelectable(o.node)&&o.parent&&(!o.node.isInline||!function(t,e,n){for(var r=0==e,o=e==Be(t);r||o;){if(t==n)return!0;var i=Te(t);if(!(t=t.parentNode))return!1;r=r&&0==i,o=o&&i==Be(t)}}(n.focusNode,n.focusOffset,o.dom))){var p=o.posBefore;c=new re(s==p?h:r.resolve(p))}}else{var f=t.docView.posFromDOM(n.anchorNode,n.anchorOffset);if(f<0)return null;a=r.resolve(f)}c||(c=Ln(t,a,h,"pointer"==e||t.state.selection.head<h.pos&&!i?1:-1));return c}function Pn(t){return t.editable?t.hasFocus():jn(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function zn(t,e){var n=t.state.selection;if($n(t,n),Pn(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,Te(r)+1):n.setEnd(r,0);n.collapse(!1),e.removeAllRanges(),e.addRange(n),!o&&!t.state.selection.visible&&xe.ie&&xe.ie_version<=11&&(r.disabled=!0,r.disabled=!1)}(t);else{var r,o,i=n.anchor,s=n.head;!In||n instanceof ee||(n.$from.parent.inlineContent||(r=Bn(t,n.from)),n.empty||n.$from.parent.inlineContent||(o=Bn(t,n.to))),t.docView.setSelection(i,s,t.root,e),In&&(r&&Vn(r),o&&Vn(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(){Pn(t)&&!t.state.selection.visible||t.dom.classList.remove("ProseMirror-hideselection")}),20))})}(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}Tn.prototype.getPreMatch=function(t){return t>=this.preMatchOffset?this.preMatched[t-this.preMatchOffset]:null},Tn.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}},Tn.prototype.destroyRest=function(){this.destroyBetween(this.index,this.top.children.length)},Tn.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=dn.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++}},Tn.prototype.findNodeMatch=function(t,e,n,r){var o=-1,i=r<0?void 0:this.getPreMatch(r),s=this.top.children;if(i&&i.matchesNode(t,e,n))o=s.indexOf(i);else for(var a=this.index,c=Math.min(s.length,a+5);a<c;a++){var h=s[a];if(h.matchesNode(t,e,n)&&this.preMatched.indexOf(h)<0){o=a;break}}return!(o<0)&&(this.destroyBetween(this.index,o),this.index++,!0)},Tn.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.preMatched.indexOf(s);if(a>-1&&a+this.preMatchOffset!=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&&Nn(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},Tn.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},Tn.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 ln(this.top,t,e,n);this.top.children.splice(this.index++,0,o),this.changed=!0}else this.index++},Tn.prototype.addTextblockHacks=function(){for(var t=this.top.children[this.index-1];t instanceof dn;)t=t.children[t.children.length-1];if(!t||!(t instanceof yn)||/\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 gn(this.top,fn,e,null)),this.changed=!0}};var In=xe.safari||xe.chrome&&xe.chrome_version<63;function Bn(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(xe.safari&&i&&"false"==i.contentEditable)return Fn(i);if(!(i&&"false"!=i.contentEditable||s&&"false"!=s.contentEditable)){if(i)return Fn(i);if(s)return Fn(s)}}function Fn(t){return t.contentEditable="true",xe.safari&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function Vn(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function $n(t,e){if(e instanceof re){var n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(_n(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else _n(t)}function _n(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=null)}function Ln(t,e,n,r){return t.someProp("createSelectionBetween",(function(r){return r(t,e,n)}))||ee.between(e,n,r)}function jn(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 Jn(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&&Qt.findFrom(s,e)}function qn(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function Wn(t,e,n){var r=t.state.selection;if(!(r instanceof ee)){if(r instanceof re&&r.node.isInline)return qn(t,new ee(e>0?r.$to:r.$from));var o=Jn(t.state,e);return!!o&&qn(t,o)}if(!r.empty||n.indexOf("s")>-1)return!1;if(t.endOfTextblock(e>0?"right":"left")){var i=Jn(t.state,e);return!!(i&&i instanceof re)&&qn(t,i)}if(!(xe.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 h=e<0?a.pos-c.nodeSize:a.pos;return!!(c.isAtom||(s=t.docView.descAt(h))&&!s.contentDOM)&&(re.isSelectable(c)?qn(t,new re(e<0?t.state.doc.resolve(a.pos-c.nodeSize):a)):!!xe.webkit&&qn(t,new ee(t.state.doc.resolve(e<0?h:h+c.nodeSize))))}}function Kn(t){return 3==t.nodeType?t.nodeValue.length:t.childNodes.length}function Un(t){var e=t.pmViewDesc;return e&&0==e.size&&(t.nextSibling||"BR"!=t.nodeName)}function Hn(t){var e=t.root.getSelection(),n=e.focusNode,r=e.focusOffset;if(n){var o,i,s=!1;for(xe.gecko&&1==n.nodeType&&r<Kn(n)&&Un(n.childNodes[r])&&(s=!0);;)if(r>0){if(1!=n.nodeType)break;var a=n.childNodes[r-1];if(Un(a))o=n,i=--r;else{if(3!=a.nodeType)break;r=(n=a).nodeValue.length}}else{if(Xn(n))break;for(var c=n.previousSibling;c&&Un(c);)o=n.parentNode,i=Te(c),c=c.previousSibling;if(c)r=Kn(n=c);else{if((n=n.parentNode)==t.dom)break;r=0}}s?Yn(t,e,n,r):o&&Yn(t,e,o,i)}}function Gn(t){var e=t.root.getSelection(),n=e.focusNode,r=e.focusOffset;if(n){for(var o,i,s=Kn(n);;)if(r<s){if(1!=n.nodeType)break;if(!Un(n.childNodes[r]))break;o=n,i=++r}else{if(Xn(n))break;for(var a=n.nextSibling;a&&Un(a);)o=a.parentNode,i=Te(a)+1,a=a.nextSibling;if(a)r=0,s=Kn(n=a);else{if((n=n.parentNode)==t.dom)break;r=s=0}}o&&Yn(t,e,o,i)}}function Xn(t){var e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function Yn(t,e,n,r){if(Ve(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&&zn(t)}),50)}function Qn(t,e,n){var r=t.state.selection;if(r instanceof ee&&!r.empty||n.indexOf("s")>-1)return!1;if(xe.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=Jn(t.state,e);if(s&&s instanceof re)return qn(t,s)}if(!o.parent.inlineContent){var a=e<0?o:i,c=r instanceof ie?Qt.near(a,e):Qt.findFrom(a,e);return!!c&&qn(t,c)}return!1}function Zn(t,e){if(!(t.state.selection instanceof ee))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 tr(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function er(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||xe.mac&&72==n&&"c"==r?Zn(t,-1)||Hn(t):46==n||xe.mac&&68==n&&"c"==r?Zn(t,1)||Gn(t):13==n||27==n||(37==n?Wn(t,-1,r)||Hn(t):39==n?Wn(t,1,r)||Gn(t):38==n?Qn(t,-1,r)||Hn(t):40==n?function(t){if(xe.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;tr(t,o,!0),setTimeout((function(){return tr(t,o,!1)}),20)}}}(t)||Qn(t,1,r)||Gn(t):r==(xe.mac?"m":"c")&&(66==n||73==n||89==n||90==n))}function nr(t){var e=t.pmViewDesc;if(e)return e.parseRule();if("BR"==t.nodeName&&t.parentNode){if(xe.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||xe.safari&&/^(tr|table)$/i.test(t.parentNode.nodeName))return{ignore:!0}}else if("IMG"==t.nodeName&&t.getAttribute("mark-placeholder"))return{ignore:!0}}function rr(t,e,n,r,o){if(e<0){var i=t.lastSelectionTime>Date.now()-50?t.lastSelectionOrigin:null,s=Rn(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),h=c.sharedDepth(n);e=c.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,h=t.root.getSelection(),p=null,f=h.anchorNode;if(f&&t.dom.contains(1==f.nodeType?f:f.parentNode)&&(p=[{node:f,offset:h.anchorOffset}],Ve(h)||p.push({node:h.focusNode,offset:h.focusOffset})),xe.chrome&&8===t.lastKeyCode)for(var l=s;l>i;l--){var u=o.childNodes[l-1],d=u.pmViewDesc;if("BR"==u.nodeType&&!d){s=l;break}if(!d||d.size)break}var m=t.state.doc,v=t.someProp("domParser")||ht.fromSchema(t.state.schema),y=m.resolve(a),g=null,w=v.parse(o,{topNode:y.parent,topMatch:y.parent.contentMatchAt(y.index()),topOpen:!0,from:i,to:s,preserveWhitespace:!y.parent.type.spec.code||"full",editableContent:!0,findPositions:p,ruleFromNode:nr,context:y});if(p&&null!=p[0].pos){var b=p[0].pos,S=p[1]&&p[1].pos;null==S&&(S=b),g={anchor:b+a,head:S+a}}return{doc:w,sel:g,from:a,to:c}}(t,e,n);if(xe.chrome&&t.cursorWrapper&&f.sel&&f.sel.anchor==t.cursorWrapper.deco.from){var l=t.cursorWrapper.deco.type.toDOM.nextSibling,u=l&&l.nodeValue?l.nodeValue.length:1;f.sel={anchor:f.sel.anchor+u,head:f.sel.anchor+u}}var m,v,y=t.state.doc,g=y.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;if("end"==o){r-=a+Math.max(0,i-Math.min(a,c))-i}if(a<i&&t.size<e.size){c=(i-=r<=i&&r>=a?i-r:0)+(c-a),a=i}else if(c<i){a=(i-=r<=i&&r>=c?i-r:0)+(a-c),c=i}return{start:i,endA:a,endB:c}}(g.content,f.doc.content,f.from,m,v);if(!w){if(!(r&&p instanceof ee&&!p.empty&&p.$head.sameParent(p.$anchor))||t.composing||f.sel&&f.sel.anchor!=f.sel.head){if(xe.ios&&t.lastIOSEnter>Date.now()-225&&o.some((function(t){return"DIV"==t.nodeName||"P"==t.nodeName}))&&t.someProp("handleKeyDown",(function(e){return e(t,$e(13,"Enter"))})))return void(t.lastIOSEnter=0);if(f.sel){var b=or(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 ee&&(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)),xe.ie&&xe.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 S,k=f.doc.resolveNoCache(w.start-f.from),x=f.doc.resolveNoCache(w.endB-f.from),O=k.sameParent(x)&&k.parent.inlineContent;if((xe.ios&&t.lastIOSEnter>Date.now()-225&&(!O||o.some((function(t){return"DIV"==t.nodeName||"P"==t.nodeName})))||!O&&k.pos<f.doc.content.size&&(S=Qt.findFrom(f.doc.resolve(k.pos+1),1,!0))&&S.head==x.pos)&&t.someProp("handleKeyDown",(function(e){return e(t,$e(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||ir(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(ir(i,!0,!0));if(!s.parent.isTextblock||s.pos>n||ir(s,!0,!1)<n)return!1;return r.parent.content.cut(r.parentOffset).eq(s.parent.content)}(y,w.start,w.endA,k,x)&&t.someProp("handleKeyDown",(function(e){return e(t,$e(8,"Backspace"))})))xe.android&&xe.chrome&&t.domObserver.suppressSelectionUpdates();else{xe.android&&!O&&k.start()!=x.start()&&0==x.parentOffset&&k.depth==x.depth&&f.sel&&f.sel.anchor==f.sel.head&&f.sel.head==w.endA&&(w.endB-=2,x=f.doc.resolveNoCache(w.endB-f.from),setTimeout((function(){t.someProp("handleKeyDown",(function(e){return e(t,$e(13,"Enter"))}))}),20));var C,M,N,D,T=w.start,A=w.endA;if(O)if(k.pos==x.pos)xe.ie&&xe.ie_version<=11&&0==k.parentOffset&&(t.domObserver.suppressSelectionUpdates(),setTimeout((function(){return zn(t)}),20)),C=t.state.tr.delete(T,A),M=y.resolve(w.start).marksAcross(y.resolve(w.endA));else if(w.endA==w.endB&&(D=y.resolve(w.start))&&(N=function(t,e){for(var n,r,o,i=t.firstChild.marks,s=e.firstChild.marks,a=i,c=s,h=0;h<s.length;h++)a=s[h].removeFromSet(a);for(var p=0;p<i.length;p++)c=i[p].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 f=[],l=0;l<e.childCount;l++)f.push(o(e.child(l)));if(d.from(f).eq(t))return{mark:r,type:n}}(k.parent.content.cut(k.parentOffset,x.parentOffset),D.parent.content.cut(D.parentOffset,w.endA-D.start()))))C=t.state.tr,"add"==N.type?C.addMark(T,A,N.mark):C.removeMark(T,A,N.mark);else if(k.parent.child(k.index()).isText&&k.index()==x.index()-(x.textOffset?0:1)){var E=k.parent.textBetween(k.parentOffset,x.parentOffset);if(t.someProp("handleTextInput",(function(e){return e(t,T,A,E)})))return;C=t.state.tr.insertText(E,T,A)}if(C||(C=t.state.tr.replace(T,A,f.doc.slice(w.start-f.from,w.endB-f.from))),f.sel){var R=or(t,C.doc,f.sel);R&&!(xe.chrome&&xe.android&&t.composing&&R.empty&&(R.head==T||R.head==C.mapping.map(A)-1)||xe.ie&&R.empty&&R.head==T)&&C.setSelection(R)}M&&C.ensureMarks(M),t.dispatch(C.scrollIntoView())}}}function or(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:Ln(t,e.resolve(n.anchor),e.resolve(n.head))}function ir(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 sr(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")||bt.fromSchema(t.state.schema),c=dr(),h=c.createElement("div");h.appendChild(a.serializeFragment(r,{document:c}));for(var p,f=h.firstChild;f&&1==f.nodeType&&(p=lr[f.nodeName.toLowerCase()]);){for(var l=p.length-1;l>=0;l--){for(var u=c.createElement(p[l]);h.firstChild;)u.appendChild(h.firstChild);h.appendChild(u)}f=h.firstChild}return f&&1==f.nodeType&&f.setAttribute("data-pm-slice",o+" "+i+" "+JSON.stringify(n)),{dom:h,text:t.someProp("clipboardTextSerializer",(function(t){return t(e)}))||e.content.textBetween(0,e.content.size,"\n\n")}}function ar(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 S(d.from(t.state.schema.text(e)),0,0);var h=t.someProp("clipboardTextParser",(function(t){return t(e,o,r)}));h?s=h:(i=document.createElement("div"),e.trim().split(/(?:\r\n?|\n)+/).forEach((function(t){i.appendChild(document.createElement("p")).textContent=t})))}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=dr().createElement("div"),o=/(?:<meta [^>]*>)*<([a-z][^>\s]+)/i.exec(t),i=0;(n=o&&lr[o[1].toLowerCase()])&&(t=n.map((function(t){return"<"+t+">"})).join("")+t+n.map((function(t){return"</"+t+">"})).reverse().join(""),i=n.length);r.innerHTML=t;for(var s=0;s<i;s++)r=r.firstChild;return r}(n);var p=i&&i.querySelector("[data-pm-slice]"),f=p&&/^(\d+) (\d+) (.*)/.exec(p.getAttribute("data-pm-slice"));if(!s){var l=t.someProp("clipboardParser")||t.someProp("domParser")||ht.fromSchema(t.state.schema);s=l.parseSlice(i,{preserveWhitespace:!(!c&&!f),context:o})}return s=f?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=d.from(c.create(n[a+1],o)),i++,s++}return new S(o,i,s)}(function(t,e,n){e<t.openStart&&(t=new S(fr(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd));n<t.openEnd&&(t=new S(fr(t.content,1,n,t.openEnd,0,0),t.openStart,n));return t}(s,+f[1],+f[2]),f[3]):S.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&&hr(n,o,t,i[i.length-1],0))i[i.length-1]=e;else{i.length&&(i[i.length-1]=pr(i[i.length-1],o.length));var s=cr(t,n);i.push(s),r=r.matchType(s.type,s.attrs),o=n}}})),i)return{v:d.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 cr(t,e,n){void 0===n&&(n=0);for(var r=e.length-1;r>=n;r--)t=e[r].create(null,d.from(t));return t}function hr(t,e,n,r,o){if(o<t.length&&o<e.length&&t[o]==e[o]){var i=hr(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(d.from(cr(n,t,o+1))))}}function pr(t,e){if(0==e)return t;var n=t.content.replaceChild(t.childCount-1,pr(t.lastChild,e-1)),r=t.contentMatchAt(t.childCount).fillBefore(d.empty,!0);return t.copy(n.append(r))}function fr(t,e,n,r,o,i){var s=e<0?t.firstChild:t.lastChild,a=s.content;return o<r-1&&(a=fr(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(d.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,s.copy(a))}var lr={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]},ur=null;function dr(){return ur||(ur=document.implementation.createHTMLDocument("title"))}var mr={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},vr=xe.ie&&xe.ie_version<=11,yr=function(){this.anchorNode=this.anchorOffset=this.focusNode=this.focusOffset=null};yr.prototype.set=function(t){this.anchorNode=t.anchorNode,this.anchorOffset=t.anchorOffset,this.focusNode=t.focusNode,this.focusOffset=t.focusOffset},yr.prototype.eq=function(t){return t.anchorNode==this.anchorNode&&t.anchorOffset==this.anchorOffset&&t.focusNode==this.focusNode&&t.focusOffset==this.focusOffset};var gr=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]);xe.ie&&xe.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 yr,vr&&(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};gr.prototype.flushSoon=function(){var t=this;this.flushingSoon<0&&(this.flushingSoon=window.setTimeout((function(){t.flushingSoon=-1,t.flush()}),20))},gr.prototype.forceFlush=function(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())},gr.prototype.start=function(){this.observer&&this.observer.observe(this.view.dom,mr),vr&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()},gr.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()}vr&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()},gr.prototype.connectSelection=function(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)},gr.prototype.disconnectSelection=function(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)},gr.prototype.suppressSelectionUpdates=function(){var t=this;this.suppressingSelectionUpdates=!0,setTimeout((function(){return t.suppressingSelectionUpdates=!1}),50)},gr.prototype.onSelectionChange=function(){if((!(t=this.view).editable||t.root.activeElement==t.dom)&&jn(t)){var t;if(this.suppressingSelectionUpdates)return zn(this.view);if(xe.ie&&xe.ie_version<=11&&!this.view.state.selection.empty){var e=this.view.root.getSelection();if(e.focusNode&&Pe(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}},gr.prototype.setCurSelection=function(){this.currentSelection.set(this.view.root.getSelection())},gr.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},gr.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)&&jn(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(xe.gecko&&s.length>1){var h=s.filter((function(t){return"BR"==t.nodeName}));if(2==h.length){var p=h[0],f=h[1];p.parentNode&&p.parentNode.parentNode==f.parentNode?f.remove():p.remove()}}(r>-1||n)&&(r>-1&&(this.view.docView.markDirty(r,o),function(t){if(wr)return;wr=!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)||zn(this.view),this.currentSelection.set(e))}},gr.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){if(n.contentDOM&&n.contentDOM!=n.dom&&!n.contentDOM.contains(t.target))return{from:n.posBefore,to:n.posAfter};var r=t.previousSibling,o=t.nextSibling;if(xe.ie&&xe.ie_version<=11&&t.addedNodes.length)for(var i=0;i<t.addedNodes.length;i++){var s=t.addedNodes[i],a=s.previousSibling,c=s.nextSibling;(!a||Array.prototype.indexOf.call(t.addedNodes,a)<0)&&(r=a),(!c||Array.prototype.indexOf.call(t.addedNodes,c)<0)&&(o=c)}for(var h=r&&r.parentNode==t.target?Te(r)+1:0,p=n.localPosFromDOM(t.target,h,-1),f=o&&o.parentNode==t.target?Te(o):t.target.childNodes.length,l=0;l<t.addedNodes.length;l++)e.push(t.addedNodes[l]);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 wr=!1;var br={},Sr={};function kr(t,e){t.lastSelectionOrigin=e,t.lastSelectionTime=Date.now()}function xr(t){t.someProp("handleDOMEvents",(function(e){for(var n in e)t.eventHandlers[n]||t.dom.addEventListener(n,t.eventHandlers[n]=function(e){return Or(t,e)})}))}function Or(t,e){return t.someProp("handleDOMEvents",(function(n){var r=n[e.type];return!!r&&(r(t,e)||e.defaultPrevented)}))}function Cr(t){return{left:t.clientX,top:t.clientY}}function Mr(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 Nr(t,e,n){t.focused||t.focus();var r=t.state.tr.setSelection(e);"pointer"==n&&r.setMeta("pointer",!0),t.dispatch(r)}function Dr(t,e,n,r,o){return Mr(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 re&&(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(re.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&&(Nr(t,re.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&&re.isSelectable(r))&&(Nr(t,new re(n),"pointer"),!0)}(t,n))}function Tr(t,e,n,r){return Mr(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",(function(n){return n(t,e,r)}))}function Ar(t,e,n,r){return Mr(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&&(Nr(t,ee.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)Nr(t,ee.create(n,s+1,s+1+i.content.size),"pointer");else{if(!re.isSelectable(i))continue;Nr(t,re.create(n,s),"pointer")}return!0}}(t,n)}function Er(t){return Vr(t)}Sr.keydown=function(t,e){if(t.shiftKey=16==e.keyCode||e.shiftKey,!zr(t,e))if(t.domObserver.forceFlush(),t.lastKeyCode=e.keyCode,t.lastKeyCodeTime=Date.now(),!xe.ios||13!=e.keyCode||e.ctrlKey||e.altKey||e.metaKey)t.someProp("handleKeyDown",(function(n){return n(t,e)}))||er(t,e)?e.preventDefault():kr(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,$e(13,"Enter"))})),t.lastIOSEnter=0)}),200)}},Sr.keyup=function(t,e){16==e.keyCode&&(t.shiftKey=!1)},Sr.keypress=function(t,e){if(!(zr(t,e)||!e.charCode||e.ctrlKey&&!e.altKey||xe.mac&&e.metaKey))if(t.someProp("handleKeyPress",(function(n){return n(t,e)})))e.preventDefault();else{var n=t.state.selection;if(!(n instanceof ee&&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 Rr=xe.mac?"metaKey":"ctrlKey";br.mousedown=function(t,e){t.shiftKey=e.shiftKey;var n=Er(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[Rr]&&("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(Cr(e));i&&("singleClick"==o?t.mouseDown=new Pr(t,i,e,n):("doubleClick"==o?Tr:Ar)(t,i.pos,i.inside,e)?e.preventDefault():kr(t,"pointer"))};var Pr=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[Rr],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,h=c?t.docView.nearestDesc(c,!0):null;this.target=h?h.dom:null,(o.type.spec.draggable&&!1!==o.type.spec.selectable||t.state.selection instanceof re&&i==t.state.selection.from)&&(this.mightDrag={node:o,pos:i,addAttr:this.target&&!this.target.draggable,setUneditable:this.target&&xe.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(){return 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)),kr(t,"pointer")};function zr(t,e){return!!t.composing||!!(xe.safari&&Math.abs(e.timeStamp-t.compositionEndedAt)<500)&&(t.compositionEndedAt=-2e8,!0)}Pr.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},Pr.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(Cr(t))),this.allowDefault||!e?kr(this.view,"pointer"):Dr(this.view,e.pos,e.inside,t,this.selectNode)?t.preventDefault():this.flushed||xe.safari&&this.mightDrag&&!this.mightDrag.node.isAtom||xe.chrome&&!(this.view.state.selection instanceof ee)&&(e.pos==this.view.state.selection.from||e.pos==this.view.state.selection.to)?(Nr(this.view,Qt.near(this.view.state.doc.resolve(e.pos)),"pointer"),t.preventDefault()):kr(this.view,"pointer")}},Pr.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),kr(this.view,"pointer")},br.touchdown=function(t){Er(t),kr(t,"pointer")},br.contextmenu=function(t){return Er(t)};var Ir=xe.android?5e3:-1;function Br(t,e){clearTimeout(t.composingTimeout),e>-1&&(t.composingTimeout=setTimeout((function(){return Vr(t)}),e))}function Fr(t){for(t.composing=!1;t.compositionNodes.length>0;)t.compositionNodes.pop().markParentsDirty()}function Vr(t,e){if(t.domObserver.forceFlush(),Fr(t),e||t.docView.dirty){var n=Rn(t);return n&&!n.eq(t.state.selection)?t.dispatch(t.state.tr.setSelection(n)):t.updateState(t.state),!0}return!1}Sr.compositionstart=Sr.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(),Vr(t,!0),t.markCursor=null;else if(Vr(t),xe.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}Br(t,Ir)},Sr.compositionend=function(t,e){t.composing&&(t.composing=!1,t.compositionEndedAt=e.timeStamp,Br(t,20))};var $r=xe.ie&&xe.ie_version<15||xe.ios&&xe.webkit_version<604;function _r(t,e,n,r){var o=ar(t,e,n,t.shiftKey,t.state.selection.$from);if(t.someProp("handlePaste",(function(e){return e(t,r,o||S.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}br.copy=Sr.cut=function(t,e){var n=t.state.selection,r="cut"==e.type;if(!n.empty){var o=$r?null:e.clipboardData,i=sr(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"))}},Sr.paste=function(t,e){var n=$r?null:e.clipboardData;n&&_r(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?_r(t,r.value,null,e):_r(t,r.textContent,r.innerHTML,e)}),50)}}(t,e)};var Lr=function(t,e){this.slice=t,this.move=e},jr=xe.mac?"altKey":"ctrlKey";for(var Jr in br.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(Cr(e));if(o&&o.pos>=r.from&&o.pos<=(r instanceof re?r.to-1:r.to));else if(n&&n.mightDrag)t.dispatch(t.state.tr.setSelection(re.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(re.create(t.state.doc,i.posBefore)))}var s=t.state.selection.content(),a=sr(t,s),c=a.dom,h=a.text;e.dataTransfer.clearData(),e.dataTransfer.setData($r?"Text":"text/html",c.innerHTML),$r||e.dataTransfer.setData("text/plain",h),t.dragging=new Lr(s,!e[jr])}},br.dragend=function(t){var e=t.dragging;window.setTimeout((function(){t.dragging==e&&(t.dragging=null)}),50)},Sr.dragover=Sr.dragenter=function(t,e){return e.preventDefault()},Sr.drop=function(t,e){var n=t.dragging;if(t.dragging=null,e.dataTransfer){var r=t.posAtCoords(Cr(e));if(r){var o=t.state.doc.resolve(r.pos);if(o){var i=n&&n.slice||ar(t,e.dataTransfer.getData($r?"Text":"text/plain"),$r?null:e.dataTransfer.getData("text/html"),!1,o),s=n&&!e[jr];if(t.someProp("handleDrop",(function(n){return n(t,e,i||S.empty,s)})))e.preventDefault();else if(i){e.preventDefault();var a=i?function(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,h=r.index(a)+(c>0?1:0);if(1==s?r.node(a).canReplace(h,h,o):r.node(a).contentMatchAt(h).findWrapping(o.firstChild.type))return 0==c?r.pos:c<0?r.before(a+1):r.after(a+1)}return null}(t.state.doc,o.pos,i):o.pos;null==a&&(a=o.pos);var c=t.state.tr;s&&c.deleteSelection();var h=c.mapping.map(a),p=0==i.openStart&&0==i.openEnd&&1==i.content.childCount,f=c.doc;if(p?c.replaceRangeWith(h,h,i.content.firstChild):c.replaceRange(h,h,i),!c.doc.eq(f)){var l=c.doc.resolve(h);if(p&&re.isSelectable(i.content.firstChild)&&l.nodeAfter&&l.nodeAfter.sameMarkup(i.content.firstChild))c.setSelection(new re(l));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(Ln(t,l,c.doc.resolve(u)))}t.focus(),t.dispatch(c.setMeta("uiEvent","drop"))}}}}}},br.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())&&zn(t)}),20))},br.blur=function(t){t.focused&&(t.domObserver.stop(),t.dom.classList.remove("ProseMirror-focused"),t.domObserver.start(),t.domObserver.currentSelection.set({}),t.focused=!1)},br.beforeinput=function(t,e){if(xe.chrome&&xe.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,$e(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)}},Sr)br[Jr]=Sr[Jr];function qr(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 Wr=function(t,e){this.spec=e||Yr,this.side=this.spec.side||0,this.toDOM=t};Wr.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 Hr(i-n,i-n,this)},Wr.prototype.valid=function(){return!0},Wr.prototype.eq=function(t){return this==t||t instanceof Wr&&(this.spec.key&&this.spec.key==t.spec.key||this.toDOM==t.toDOM&&qr(this.spec,t.spec))};var Kr=function(t,e){this.spec=e||Yr,this.attrs=t};Kr.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 Hr(o,i,this)},Kr.prototype.valid=function(t,e){return e.from<e.to},Kr.prototype.eq=function(t){return this==t||t instanceof Kr&&qr(this.attrs,t.attrs)&&qr(this.spec,t.spec)},Kr.is=function(t){return t.type instanceof Kr};var Ur=function(t,e){this.spec=e||Yr,this.attrs=t};Ur.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 Hr(o.pos-n,i.pos-n,this)},Ur.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},Ur.prototype.eq=function(t){return this==t||t instanceof Ur&&qr(this.attrs,t.attrs)&&qr(this.spec,t.spec)};var Hr=function(t,e,n){this.from=t,this.to=e,this.type=n},Gr={spec:{configurable:!0},inline:{configurable:!0}};Hr.prototype.copy=function(t,e){return new Hr(t,e,this.type)},Hr.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},Hr.prototype.map=function(t,e,n){return this.type.map(t,this,e,n)},Hr.widget=function(t,e,n){return new Hr(t,t,new Wr(e,n))},Hr.inline=function(t,e,n,r){return new Hr(t,e,new Kr(n,r))},Hr.node=function(t,e,n,r){return new Hr(t,e,new Ur(n,r))},Gr.spec.get=function(){return this.type.spec},Gr.inline.get=function(){return this.type instanceof Kr},Object.defineProperties(Hr.prototype,Gr);var Xr=[],Yr={},Qr=function(t,e){this.local=t&&t.length?t:Xr,this.children=e&&e.length?e:Xr};Qr.create=function(t,e){return e.length?oo(e,t,0,Yr):Zr},Qr.prototype.find=function(t,e,n){var r=[];return this.findInner(null==t?0:t,null==e?1e9:e,r,0,n),r},Qr.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)}},Qr.prototype.map=function(t,e,n){return this==Zr||0==t.maps.length?this:this.mapInner(t,e,0,0,n||Yr)},Qr.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],h=void 0;-1==c||t>c+i||(e>=a[s]+i?a[s+1]=-1:n>=o&&(h=r-n-(e-t))&&(a[s]+=h,a[s+1]+=h))}},h=0;h<n.maps.length;h++)n.maps[h].forEach(c);for(var p=!1,f=0;f<a.length;f+=3)if(-1==a[f+1]){var l=n.map(t[f]+i),u=l-o;if(u<0||u>=r.content.size){p=!0;continue}var d=n.map(t[f+1]+i,-1)-o,m=r.content.findIndex(u),v=m.index,y=m.offset,g=r.maybeChild(v);if(g&&y==u&&y+g.nodeSize==d){var w=a[f+2].mapInner(n,g,l+1,t[f]+i+1,s);w!=Zr?(a[f]=u,a[f+1]=d,a[f+2]=w):(a[f+1]=-2,p=!0)}else p=!0}if(p){var b=oo(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 h=0;h<t.children.length;h+=3)a(t.children[h+2],t.children[h]+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 S=0;S<a.length;S+=3)a[S+1]<0&&(a.splice(S,3),S-=3);for(var k=0,x=0;k<b.children.length;k+=3){for(var O=b.children[k];x<a.length&&a[x]<O;)x+=3;a.splice(x,0,b.children[k],b.children[k+1],b.children[k+2])}}return new Qr(e&&e.sort(io),a)}(this.children,i,t,e,n,r,o):i?new Qr(i.sort(io)):Zr},Qr.prototype.add=function(t,e){return e.length?this==Zr?Qr.create(t,e):this.addInner(t,e,0):this},Qr.prototype.addInner=function(t,e,n){var r,o=this,i=0;t.forEach((function(t,s){var a,c=s+n;if(a=no(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,oo(a,t,c+1,Yr)),i+=3}}));for(var s=eo(i?ro(e):e,-n),a=0;a<s.length;a++)s[a].type.valid(t,s[a])||s.splice(a--,1);return new Qr(s.length?this.local.concat(s).sort(io):this.local,r||this.children)},Qr.prototype.remove=function(t){return 0==t.length||this==Zr?this:this.removeInner(t,0)},Qr.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,h=void 0;c<t.length;c++)(h=t[c])&&h.from>s&&h.to<a&&(t[c]=null,(i||(i=[])).push(h));if(i){n==this.children&&(n=this.children.slice());var p=n[o+2].removeInner(i,s+1);p!=Zr?n[o+2]=p:(n.splice(o,3),o-=3)}}if(r.length)for(var f=0,l=void 0;f<t.length;f++)if(l=t[f])for(var u=0;u<r.length;u++)r[u].eq(l,e)&&(r==this.local&&(r=this.local.slice()),r.splice(u--,1));return n==this.children&&r==this.local?this:r.length||n.length?new Qr(r,n):Zr},Qr.prototype.forChild=function(t,e){if(this==Zr)return this;if(e.isLeaf)return Qr.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 Kr){var h=Math.max(i,c.from)-i,p=Math.min(s,c.to)-i;h<p&&(r||(r=[])).push(c.copy(h,p))}}if(r){var f=new Qr(r.sort(io));return n?new to([f,n]):f}return n||Zr},Qr.prototype.eq=function(t){if(this==t)return!0;if(!(t instanceof Qr)||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},Qr.prototype.locals=function(t){return so(this.localsInner(t))},Qr.prototype.localsInner=function(t){if(this==Zr)return Xr;if(t.inlineContent||!this.local.some(Kr.is))return this.local;for(var e=[],n=0;n<this.local.length;n++)this.local[n].type instanceof Kr||e.push(this.local[n]);return e};var Zr=new Qr;Qr.empty=Zr,Qr.removeOverlap=so;var to=function(t){this.members=t};function eo(t,e){if(!e||!t.length)return t;for(var n=[],r=0;r<t.length;r++){var o=t[r];n.push(new Hr(o.from+e,o.to+e,o.type))}return n}function no(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 ro(t){for(var e=[],n=0;n<t.length;n++)null!=t[n]&&e.push(t[n]);return e}function oo(t,e,n,r){var o=[],i=!1;e.forEach((function(e,s){var a=no(t,e,s+n);if(a){i=!0;var c=oo(a,e,n+s+1,r);c!=Zr&&o.push(s,s+e.nodeSize,c)}}));for(var s=eo(i?ro(t):t,-n).sort(io),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 Qr(s,o):Zr}function io(t,e){return t.from-e.from||t.to-e.to}function so(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),ao(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),ao(e,o+1,i.copy(r.to,i.to)))}}return e}function ao(t,e,n){for(;e<t.length&&io(n,t[e])>0;)e++;t.splice(e,0,n)}function co(t){var e=[];return t.someProp("decorations",(function(n){var r=n(t.state);r&&r!=Zr&&e.push(r)})),t.cursorWrapper&&e.push(Qr.create(t.state.doc,[t.cursorWrapper.deco])),to.from(e)}to.prototype.forChild=function(t,e){if(e.isLeaf)return Qr.empty;for(var n=[],r=0;r<this.members.length;r++){var o=this.members[r].forChild(t,e);o!=Zr&&(o instanceof to?n=n.concat(o.members):n.push(o))}return to.from(n)},to.prototype.eq=function(t){if(!(t instanceof to)||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},to.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?so(n?e:e.sort(io)):Xr},to.from=function(t){switch(t.length){case 0:return Zr;case 1:return t[0];default:return new to(t)}};var ho=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=uo(this),this.markCursor=null,this.cursorWrapper=null,lo(this),this.nodeViews=mo(this),this.docView=vn(this.state.doc,fo(this),co(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.composing=!1,t.composingTimeout=null,t.compositionNodes=[],t.compositionEndedAt=-2e8,t.domObserver=new gr(t,(function(e,n,r,o){return rr(t,e,n,r,o)})),t.domObserver.start(),t.domChangeCount=0,t.eventHandlers=Object.create(null);var e=function(e){var n=br[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)||Or(t,e)||!t.editable&&e.type in Sr||n(t,e)})};for(var n in br)e(n);xe.safari&&t.dom.addEventListener("input",(function(){return null})),xr(t)}(this),this.pluginViews=[],this.updatePluginViews()},po={props:{configurable:!0},root:{configurable:!0}};function fo(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]))})),[Hr.node(0,t.state.doc.content.size,e)]}function lo(t){if(t.markCursor){var e=document.createElement("img");e.setAttribute("mark-placeholder","true"),t.cursorWrapper={dom:e,deco:Hr.widget(t.state.selection.head,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function uo(t){return!t.someProp("editable",(function(e){return!1===e(t.state)}))}function mo(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}po.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},ho.prototype.update=function(t){t.handleDOMEvents!=this._props.handleDOMEvents&&xr(this),this._props=t,this.updateStateInner(t.state,!0)},ho.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)},ho.prototype.updateState=function(t){this.updateStateInner(t,this.state.plugins!=t.plugins)},ho.prototype.updateStateInner=function(t,e){var n=this,r=this.state,o=!1,i=!1;if(t.storedMarks&&this.composing&&(Fr(this),i=!0),this.state=t,e){var s=mo(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),xr(this)}this.editable=uo(this),lo(this);var a=co(this),c=fo(this),h=e?"reset":t.scrollToSelection>r.scrollToSelection?"to selection":"preserve",p=o||!this.docView.matchesNode(t.doc,c,a);!p&&t.selection.eq(r.selection)||(i=!0);var f,l,u,d,m,v,y,g,w,b,S,k="preserve"==h&&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:qe(t.dom)}}(this);if(i){this.domObserver.stop();var x=p&&(xe.ie||xe.chrome)&&!this.composing&&!r.selection.empty&&!t.selection.empty&&(d=r.selection,m=t.selection,v=Math.min(d.$anchor.sharedDepth(d.head),m.$anchor.sharedDepth(m.head)),d.$anchor.start(v)!=m.$anchor.start(v));if(p){var O=xe.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=vn(t.doc,c,a,this.dom,this)),O&&!this.trackWrites&&(x=!0)}x||!(this.mouseDown&&this.domObserver.currentSelection.eq(this.root.getSelection())&&(f=this,l=f.docView.domFromPos(f.state.selection.anchor,0),u=f.root.getSelection(),Pe(l.node,l.offset,u.anchorNode,u.anchorOffset)))?zn(this,x):($n(this,t.selection),this.domObserver.setCurSelection()),this.domObserver.start()}if(this.updatePluginViews(r),"reset"==h)this.dom.scrollTop=0;else if("to selection"==h){var C=this.root.getSelection().focusNode;this.someProp("handleScrollToSelection",(function(t){return t(n)}))||(t.selection instanceof re?Je(this,this.docView.domAfterPos(t.selection.from).getBoundingClientRect(),C):Je(this,this.coordsAtPos(t.selection.head,1),C))}else k&&(g=(y=k).refDOM,w=y.refTop,b=y.stack,S=g?g.getBoundingClientRect().top:0,We(b,0==S?0:S-w))},ho.prototype.destroyPluginViews=function(){for(var t;t=this.pluginViews.pop();)t.destroy&&t.destroy()},ho.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))}}},ho.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}},ho.prototype.hasFocus=function(){return this.root.activeElement==this.dom},ho.prototype.focus=function(){this.domObserver.stop(),this.editable&&function(t){if(t.setActive)return t.setActive();if(Ke)return t.focus(Ke);var e=qe(t);t.focus(null==Ke?{get preventScroll(){return Ke={preventScroll:!0},!0}}:void 0),Ke||(Ke=!1,We(e,0))}(this.dom),zn(this),this.domObserver.start()},po.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},ho.prototype.posAtCoords=function(t){return Xe(this,t)},ho.prototype.coordsAtPos=function(t,e){return void 0===e&&(e=1),Ze(this,t,e)},ho.prototype.domAtPos=function(t,e){return void 0===e&&(e=0),this.docView.domFromPos(t,e)},ho.prototype.nodeDOM=function(t){var e=this.docView.descAt(t);return e?e.nodeDOM:null},ho.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},ho.prototype.endOfTextblock=function(t,e){return cn(this,e||this.state,t)},ho.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,[],co(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null)},ho.prototype.dispatchEvent=function(t){return function(t,e){Or(t,e)||!br[e.type]||!t.editable&&e.type in Sr||br[e.type](t,e)}(this,t)},ho.prototype.dispatch=function(t){var e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))},Object.defineProperties(ho.prototype,po);var vo=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 S.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 yo(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 h=n>0?i.firstChild:i.lastChild;if(!h){if(i.isAtom&&!i.isText&&!re.isSelectable(i)){t=t.doc.resolve(o+i.nodeSize*n),r=!1;continue t}break}i=h,o+=n;var p=t.doc.resolve(o);if(e.valid(p))return p}return null}},e}(Qt);vo.prototype.visible=!1,Qt.jsonID("gapcursor",vo);var yo=function(t){this.pos=t};yo.prototype.map=function(t){return new yo(t.map(this.pos))},yo.prototype.resolve=function(t){var e=t.resolve(this.pos);return vo.valid(e)?new vo(e):Qt.near(e)};var go,wo,bo=(go={ArrowLeft:So("horiz",-1),ArrowRight:So("horiz",1),ArrowUp:So("vert",-1),ArrowDown:So("vert",1)},wo=function(t){var e=Object.create(null);for(var n in t)e[Se(n)]=t[n];return e}(go),function(t,e){var o,s=function(t){var e=!(h&&(t.ctrlKey||t.altKey||t.metaKey)||(i||c)&&t.shiftKey&&t.key&&1==t.key.length)&&t.key||(t.shiftKey?r:n)[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}(e),a=1==s.length&&" "!=s,p=wo[ke(s,e,!a)];if(p&&p(t.state,t.dispatch,t))return!0;if(a&&(e.shiftKey||e.altKey||e.metaKey||s.charCodeAt(0)>127)&&(o=n[e.keyCode])&&o!=s){var f=wo[ke(o,e,!0)];if(f&&f(t.state,t.dispatch,t))return!0}else if(a&&e.shiftKey){var l=wo[ke(s,e,!0)];if(l&&l(t.state,t.dispatch,t))return!0}return!1});function So(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 ee){if(!o.endOfTextblock(n)||0==s.depth)return!1;a=!1,s=t.doc.resolve(e>0?s.after():s.before())}var c=vo.findFrom(s,e,a);return!!c&&(r&&r(t.tr.setSelection(new vo(c))),!0)}}function ko(t,e,n){if(!t.editable)return!1;var r=t.state.doc.resolve(e);if(!vo.valid(r))return!1;var o=t.posAtCoords({left:n.clientX,top:n.clientY}).inside;return!(o>-1&&re.isSelectable(t.state.doc.nodeAt(o)))&&(t.dispatch(t.state.tr.setSelection(new vo(r))),!0)}function xo(t){if(!(t.selection instanceof vo))return null;var e=document.createElement("div");return e.className="ProseMirror-gapcursor",Qr.create(t.doc,[Hr.widget(t.selection.head,e,{key:"gapcursor"})])}const Oo=e.Extension.create({name:"gapCursor",addProseMirrorPlugins:()=>[new ge({props:{decorations:xo,createSelectionBetween:function(t,e,n){if(e.pos==n.pos&&vo.valid(n))return new vo(n)},handleClick:ko,handleKeyDown:bo}})],extendNodeSchema(t){var n;const r={options:t.options};return{allowGapCursor:null!==(n=e.callOrReturn(t.config.allowGapCursor,r))&&void 0!==n?n:null}}});t.Gapcursor=Oo,t.default=Oo,Object.defineProperty(t,"__esModule",{value:!0})}));
2
- //# sourceMappingURL=tiptap-extension-gapcursor.bundle.umd.min.js.map