-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsimpla-richtext-behavior.html
1 lines (1 loc) · 193 KB
/
simpla-richtext-behavior.html
1
<script>!function(){"use strict";function t(t,e){return e={exports:{}},t(e,e.exports),e.exports}function e(t,n,r){for(var o=0;;o++){if(o==t.childCount||o==n.childCount)return t.childCount==n.childCount?null:r;var i=t.child(o),s=n.child(o);if(i!=s){if(!i.sameMarkup(s))return r;if(i.isText&&i.text!=s.text){for(var a=0;i.text[a]==s.text[a];a++)r++;return r}if(i.content.size||s.content.size){var c=e(i.content,s.content,r+1);if(null!=c)return c}r+=i.nodeSize}else r+=i.nodeSize}}function n(t,e,r,o){for(var i=t.childCount,s=e.childCount;;){if(0==i||0==s)return i==s?null:{a:r,b:o};var a=t.child(--i),c=e.child(--s),p=a.nodeSize;if(a!=c){if(!a.sameMarkup(c))return{a:r,b:o};if(a.isText&&a.text!=c.text){for(var l=0,u=Math.min(a.text.length,c.text.length);l<u&&a.text[a.text.length-l-1]==c.text[c.text.length-l-1];)l++,r--,o--;return{a:r,b:o}}if(a.content.size||c.content.size){var h=n(a.content,c.content,r-1,o-1);if(h)return h}r-=p,o-=p}else r-=p,o-=p}}function r(t,e){return Jr.index=t,Jr.offset=e,Jr}function o(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(!o(t[r],e[r]))return!1}else{for(var i in t)if(!(i in e&&o(t[i],e[i])))return!1;for(var s in e)if(!(s in t))return!1}return!0}function i(){!Zr&&"undefined"!=typeof console&&console.warn&&(Zr=!0,console.warn("Slice.openLeft has been renamed to openStart, and Slice.openRight to openEnd"))}function s(t,e,n){var r=t.findIndex(e),o=r.index,i=r.offset,a=t.maybeChild(o),c=t.findIndex(n),p=c.index,l=c.offset;if(i==e||a.isText){if(l!=n&&!t.child(p).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(o!=p)throw new RangeError("Removing non-flat range");return t.replaceChild(o,a.copy(s(a.content,e-i-1,n-i-1)))}function a(t,e,n,r){var o=t.findIndex(e),i=o.index,s=o.offset,c=t.maybeChild(i);if(s==e||c.isText)return r&&!r.canReplace(i,i,n)?null:t.cut(0,e).append(n).append(t.cut(e));var p=a(c.content,e-s-1,n);return p&&t.replaceChild(i,c.copy(p))}function c(t,e,n){if(n.openStart>t.depth)throw new Xr("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new Xr("Inconsistent open depths");return p(t,e,n,0)}function p(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=p(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=g(n,t);return d(i,m(t,a.start,a.end,e,r))}var c=t.parent,l=c.content;return d(c,l.cut(0,t.parentOffset).append(n.content).append(l.cut(e.parentOffset)))}return d(i,v(t,e,r))}function l(t,e){if(!e.type.compatibleContent(t.type))throw new Xr("Cannot join "+e.type.name+" onto "+t.type.name)}function u(t,e,n){var r=t.node(n);return l(r,e.node(n)),r}function h(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 f(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&&(h(t.nodeAfter,r),i++));for(var a=i;a<s;a++)h(o.child(a),r);e&&e.depth==n&&e.textOffset&&h(e.nodeBefore,r)}function d(t,e){if(!t.type.validContent(e,t.attrs))throw new Xr("Invalid content for node "+t.type.name);return t.copy(e)}function m(t,e,n,r,o){var i=t.depth>o&&u(t,e,o+1),s=r.depth>o&&u(n,r,o+1),a=[];return f(null,t,o,a),i&&s&&e.index(o)==n.index(o)?(l(i,s),h(d(i,m(t,e,n,r,o+1)),a)):(i&&h(d(i,v(t,e,o+1)),a),f(e,n,o,a),s&&h(d(s,v(n,r,o+1)),a)),f(r,null,o,a),new Gr(a)}function v(t,e,n){var r=[];return f(null,t,n,r),t.depth>n&&h(d(u(t,e,n+1),v(t,e,n+1)),r),f(e,null,n,r),new Gr(r)}function g(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(Gr.from(r));return{start:r.resolveNoCache(t.openStart+n),end:r.resolveNoCache(r.content.size-t.openEnd-n)}}function y(t,e){for(var n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}function w(t){this.content=t}function b(t,e){if("."==e.charAt(0)){var n=e.slice(1);if(!t.attrs[n])throw new SyntaxError("Node type "+t.name+" has no attribute "+n);return new Po(n)}return JSON.parse(e)}function k(t,e,n){if(!(t instanceof Po))return t;var r=e&&e[t.attr];return void 0!==r?r:n.nodeType.defaultAttrs[t.attr]}function S(t,e,n,r){return e>=k(t.min,n,r)&&e<=k(t.max,n,r)}function x(t,e){var n=[];return e.forEach(function(e){var r=t.nodes[e];if(r)-1==n.indexOf(r)&&n.push(r);else for(var o in t.nodes){var i=t.nodes[o];i.groups.indexOf(e)>-1&&-1==n.indexOf(i)&&(r=n.push(i))}if(!r)throw new SyntaxError("Node type or group '"+e+"' does not exist")}),n}function M(t,e){var n=1,r=1;if(e&&("+"==e[1]?r=zo:"*"==e[1]?(n=0,r=zo):"?"==e[1]?n=0:e[2]&&(n=b(t,e[2]),r=e[3]?e[4]?b(t,e[4]):zo:n),0==r||n>r))throw new SyntaxError("Invalid repeat count in '"+e[0]+"'");return{min:n,max:r}}function O(t,e){for(var n=e.split(/\s*,\s*/),r=Object.create(null),o=0;o<n.length;o++){var i=/^(\w+)=(\w+|\"(?:\\.|[^\\])*\"|\.\w+)$/.exec(n[o]);if(!i)throw new SyntaxError("Invalid attribute syntax: "+n[o]);r[i[1]]=b(t,i[2])}return r}function C(t){var e=Object.create(null);for(var n in t){var r=t[n];if(void 0===r.default)return null;e[n]=r.default}return e}function D(t,e){var n=Object.create(null);for(var r in t){var o=e&&e[r];if(null==o){var i=t[r];if(void 0!==i.default)o=i.default;else{if(!i.compute)throw new RangeError("No value supplied for attribute "+r);o=i.compute()}}n[r]=o}return n}function T(t){var e=Object.create(null);if(t)for(var n in t)e[n]=new qo(t[n]);return e}function E(t){return(t?ii:0)|("full"===t?si:0)}function A(t){for(var e=t.firstChild,n=null;e;e=e.nextSibling){var r=1==e.nodeType?e.nodeName.toLowerCase():null;r&&oi.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):"li"==r?n=e:r&&(n=null)}}function N(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function R(t){for(var e,n=/\s*([\w-]+)\s*:\s*([^;]+)/g,r=[];e=n.exec(t);)r.push(e[1],e[2].trim());return r}function I(t){var e={};for(var n in t)e[n]=t[n];return e}function P(t){var e={};for(var n in t){var r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function z(t){return t.document||window.document}function F(t,e,n,r,o,i){if(e.inlineContent)return Oi.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&&Ti.isSelectable(a))return Ti.create(t,n-(o<0?a.nodeSize:0))}else{var c=F(t,a,n+o,o<0?a.childCount:0,o,i);if(c)return c}n+=a.nodeSize*o}}function B(t,e,n){if(t.steps.length!=e){var r;t.mapping.maps[t.mapping.maps.length-1].forEach(function(t,e,n,o){return r=o}),null!=r&&t.setSelection(bi.near(t.doc.resolve(r),n))}}function $(t,e){return t+e*Fi}function _(t){return t&zi}function V(t){return(t-(t&zi))/Fi}function j(){throw new Error("Override me")}function L(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 J(t,e,n){return(0==e||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function W(t){for(var e=t.parent.content.cutByIndex(t.startIndex,t.endIndex),n=t.depth;;--n){var r=t.$from.node(n);if(r.type.spec.isolating)break;var o=t.$from.index(n),i=t.$to.indexAfter(n);if(n<t.depth&&r.canReplace(o,i,e))return n;if(0==n||!J(r,o,i))break}}function q(t,e,n,r){void 0===r&&(r=t);var o={type:e,attrs:n},i=K(t,o),s=i&&H(r,o);return s?i.concat(o).concat(s):null}function K(t,e){var n=t.parent,r=t.startIndex,o=t.endIndex,i=n.contentMatchAt(r).findWrapping(e.type,e.attrs);if(!i)return null;var s=i.length?i[0]:e;return n.canReplaceWith(r,o,s.type,s.attrs)?i:null}function H(t,e){var n=t.parent,r=t.startIndex,o=t.endIndex,i=n.child(r),s=e.type.contentExpr.start(e.attrs).findWrappingFor(i);if(!s)return null;for(var a=s.length?s[s.length-1]:e,c=a.type.contentExpr.start(a.attrs),p=r;p<o;p++)c=c&&c.matchNode(n.child(p));return c&&c.validEnd()?s:null}function U(t,e,n,r){void 0===n&&(n=1);var o=t.resolve(e),i=o.depth-n;if(i<0||!o.parent.canReplace(o.index(),o.parent.childCount)||!o.parent.canReplace(0,o.indexAfter()))return!1;for(var s=o.depth-1,a=n-1;s>i;s--,a--){var c=o.node(s),p=o.index(s),l=r&&r[a];if(!c.canReplace(0,p)||!c.canReplaceWith(p,c.childCount,l?l.type:o.node(s+1).type,l?l.attrs:o.node(s+1).attrs))return!1}var u=o.indexAfter(i),h=r&&r[0];return o.node(i).canReplaceWith(u,u,h?h.type:o.node(i+1).type,h?h.attrs:o.node(i+1).attrs)}function Q(t,e){var n=t.resolve(e),r=n.index();return G(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function G(t,e){return t&&e&&!t.isLeaf&&t.canAppend(e)}function X(t,e,n){void 0===n&&(n=-1);for(var r=t.resolve(e),o=r.depth;;o--){var i=void 0,s=void 0;if(o==r.depth?(i=r.nodeBefore,s=r.nodeAfter):n>0?(i=r.node(o+1),s=r.node(o).maybeChild(r.index(o)+1)):(i=r.node(o).maybeChild(r.index(o)-1),s=r.node(o+1)),i&&!i.isTextblock&&G(i,s))return e;if(0==o)break;e=n<0?r.before(o):r.after(o)}}function Y(t,e,n,r){var o=t.resolve(e);if(o.parent.canReplaceWith(o.index(),o.index(),n,r))return e;if(0==o.parentOffset)for(var i=o.depth-1;i>=0;i--){var s=o.index(i);if(o.node(i).canReplaceWith(s,s,n,r))return o.before(i+1);if(s>0)return null}if(o.parentOffset==o.parent.content.size)for(var a=o.depth-1;a>=0;a--){var c=o.indexAfter(a);if(o.node(a).canReplaceWith(c,c,n,r))return o.after(a+1);if(c<o.node(a).childCount)return null}}function Z(t,e,n){for(var r=[],o=0;o<t.childCount;o++){var i=t.child(o);i.content.size&&(i=i.copy(Z(i.content,e,i))),i.isInline&&(i=e(i,n,o)),r.push(i)}return xs.fromArray(r)}function tt(t,e,n,r,o){if(e<n){var i=t.firstChild;t=t.replaceChild(0,i.copy(tt(i.content,e+1,n,r,i)))}return e>r&&(t=o.contentMatchAt(0).fillBefore(t).append(t)),t}function et(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}function nt(t,e,n,r){if(void 0===n&&(n=e),void 0===r&&(r=Vs.empty),e==n&&!r.size)return null;var o=t.resolve(e),i=t.resolve(n);if(lt(o,i,r))return new js(e,n,r);var s=ot(o,dt(o,r)),a=pt(o,i,s);if(!a)return null;if(s.size!=a.size&&ut(o,i,s)){for(var c=i.depth,p=i.after(c);c>1&&p==i.end(--c);)++p;var l=pt(o,t.resolve(p),s);if(l)return new Ls(e,p,n,i.end(),l,s.size)}return new js(e,n,a)}function rt(t,e,n,r){var o=_s.empty,i=0,s=n[e];if(t.depth>e){var a=rt(t,e+1,n,r||s);i=a.openEnd+1,o=_s.from(t.node(e+1).copy(a.content))}return s&&(o=o.append(s.content),i=s.openEnd),r&&(o=o.append(t.node(e).contentMatchAt(t.indexAfter(e)).fillBefore(_s.empty,!0)),i=0),{content:o,openEnd:i}}function ot(t,e){var n=rt(t,0,e,!1),r=n.content,o=n.openEnd;return new Vs(r,t.depth,o||0)}function it(t,e,n,r,o,i,s){var a,c=t.childCount,p=c-(s>0?1:0);a=i<0?e.contentMatchAt(p):1==c&&s>0?n.node(o).contentMatchAt(i?n.index(o):n.indexAfter(o)):n.node(o).contentMatchAt(n.indexAfter(o)).matchFragment(t,c>0&&i?1:0,p);var l=r.node(o);if(s>0&&o<r.depth){var u=l.content.cutByIndex(r.indexAfter(o)).addToStart(t.lastChild),h=a.fillBefore(u,!0);if(h&&h.size&&i>0&&1==c&&(h=null),h){var f=it(t.lastChild.content,t.lastChild,n,r,o+1,1==c?i-1:-1,s-1);if(f){var d=t.lastChild.copy(f);return h.size?t.cutByIndex(0,c-1).append(h).addToEnd(d):t.replaceChild(c-1,d)}}}s>0&&(a=a.matchNode(1==c&&i>0?n.node(o+1):t.lastChild));var m=r.index(o);if(m==l.childCount&&!l.type.compatibleContent(e.type))return null;var v=a.fillBefore(l.content,!0,m);if(!v)return null;if(s>0){var g=st(t.lastChild,s-1,n,o+1,1==c?i-1:-1);t=t.replaceChild(c-1,g)}return t=t.append(v),r.depth>o&&(t=t.addToEnd(at(r,o+1))),t}function st(t,e,n,r,o){var i,s=t.content,a=s.childCount;if(i=o>=0?n.node(r).contentMatchAt(n.indexAfter(r)).matchFragment(s,o>0?1:0,a):t.contentMatchAt(a),e>0){var c=st(s.lastChild,e-1,n,r+1,1==a?o-1:-1);s=s.replaceChild(a-1,c)}return t.copy(s.append(i.fillBefore(_s.empty,!0)))}function at(t,e){var n=t.node(e),r=n.contentMatchAt(0).fillBefore(n.content,!0,t.index(e));return t.depth>e&&(r=r.addToEnd(at(t,e+1))),n.copy(r)}function ct(t,e,n){for(;e>0&&n>0&&1==t.childCount;)t=t.firstChild.content,e--,n--;return new Vs(t,e,n)}function pt(t,e,n){var r=it(n.content,t.node(0),t,e,0,n.openStart,n.openEnd);return r?ct(r,n.openStart,e.depth):null}function lt(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}function ut(t,e,n){if(!e.parent.isTextblock)return!1;var r;if(n.openEnd){var o=ft(n.content,n.openEnd);if(!o.isTextblock)return!1;r=o.contentMatchAt(o.childCount)}else{var i=t.node(t.depth-(n.openStart-n.openEnd));if(!i.isTextblock)return!1;r=i.contentMatchAt(i.childCount),n.size&&(r=r.matchFragment(n.content,n.openStart?1:0))}return(r=r.matchFragment(e.parent.content,e.index()))&&r.validEnd()}function ht(t,e){for(var n=1;n<e;n++)t=t.firstChild.content;return t.firstChild}function ft(t,e){for(var n=1;n<e;n++)t=t.lastChild.content;return t.lastChild}function dt(t,e){for(var n=t.depth,r=null,o=[],i=null,s=e.openStart;;--s){var a=void 0,c=void 0,p=void 0;if(s>=0){if(s>0){var l;a=(l=ht(e.content,s)).type,c=l.attrs,p=l.content}else 0==s&&(p=e.content);s<e.openStart&&(p=p.cut(p.firstChild.nodeSize))}else{p=_s.empty;var u=i[i.length+s-1];a=u.type,c=u.attrs}if(r&&(p=p.addToStart(r)),0==p.size&&s<=0)break;var h=vt(p,t,n,o);if(h&&yt(t,n,h.depth,e,s)&&(h=null),h){if(h.fragment.size>0&&(o[h.depth]={content:h.fragment,openEnd:mt(e,s)?e.openEnd-s:0,depth:h.depth}),s<=0)break;r=null,n=h.depth-(a==t.node(h.depth).type?1:0)}else{if(0==s){var f=t.node(0),d=f.contentMatchAt(t.index(0)).findWrappingFor(p.firstChild);if(!d||0==d.length)break;var m=d[d.length-1];if(!m.type.contentExpr.matches(m.attrs,p))break;i=[{type:f.type,attrs:f.attrs}].concat(d);var v;a=(v=m).type,c=v.attrs}p.size?(p=a.contentExpr.start(c).fillBefore(p,!0).append(p),r=a.create(c,p)):r=null}}return o}function mt(t,e){for(var n=0,r=t.content;n<e;n++){if(r.childCount>1)return!1;r=r.firstChild.content}return!0}function vt(t,e,n,r){for(var o=!1,i=0;i<t.childCount;i++)t.child(i).marks.length&&(o=!0);for(var s=n;s>=0;s--){var a=e.node(s).contentMatchAt(e.indexAfter(s)),c=r[s];c&&(a=a.matchFragment(c.content));var p=a.fillBefore(t);if(p)return{depth:s,fragment:(c?c.content.append(p):p).append(t)};if(o){var l=gt(a,t);if(l)return{depth:s,fragment:c?c.content.append(l):l}}}}function gt(t,e){for(var n=[],r=0;r<e.childCount;r++){var o=e.child(r),i=o.mark(o.marks.filter(function(e){return t.allowsMark(e.type)}));if(!(t=t.matchNode(i)))return null;n.push(i)}return _s.from(n)}function yt(t,e,n,r,o){if(o<1)return!1;for(;e>n;e--)for(var i=t.node(e).contentMatchAt(t.indexAfter(e)),s=o-1;s>=0;s--)if(i.matchNode(ht(r.content,s)))return!0;return!1}function wt(t,e){return e&&t?t.bind(e):t}function bt(t,e,n){for(var r in t){var o=t[r];o instanceof Function?o=o.bind(e):"handleDOMEvents"==r&&(o=bt(o,e,{})),n[r]=o}return n}function kt(t){return t in pa?t+"$"+ ++pa[t]:(pa[t]=0,t+"$")}function St(){return{left:0,right:window.innerWidth,top:0,bottom:window.innerHeight}}function xt(t,e){var n=t.someProp("scrollThreshold")||0,r=t.someProp("scrollMargin");null==r&&(r=5);for(var o=t.dom;o;o=ka(o)){var i=o==document.body,s=i?St():o.getBoundingClientRect(),a=0,c=0;if(e.top<s.top+n?c=-(s.top-e.top+r):e.bottom>s.bottom-n&&(c=e.bottom-s.bottom+r),e.left<s.left+n?a=-(s.left-e.left+r):e.right>s.right-n&&(a=e.right-s.right+r),(a||c)&&(i?window.scrollBy(a,c):(c&&(o.scrollTop+=c),a&&(o.scrollLeft+=a))),i)break}}function Mt(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}}}for(var p=[],l=t.dom;l&&(p.push({dom:l,top:l.scrollTop,left:l.scrollLeft}),l!=document.body);l=ka(l));return{refDOM:e,refTop:n,stack:p}}function Ot(t){for(var e=t.refDOM,n=t.refTop,r=t.stack,o=e?e.getBoundingClientRect().top:0,i=0==o?0:o-n,s=0;s<r.length;s++){var a=r[s],c=a.dom,p=a.top,l=a.left;c.scrollTop!=p+i&&(c.scrollTop=p+i),c.scrollLeft!=l&&(c.scrollLeft=l)}}function Ct(t,e){for(var n,r,o=2e8,i=0,s=e.top,a=e.top,c=t.firstChild,p=0;c;c=c.nextSibling,p++){var l=void 0;if(1==c.nodeType)l=c.getClientRects();else{if(3!=c.nodeType)continue;l=ba(c).getClientRects()}for(var u=0;u<l.length;u++){var h=l[u];if(h.top<=s&&h.bottom>=a){s=Math.max(h.bottom,s),a=Math.min(h.top,a);var f=h.left>e.left?h.left-e.left:h.right<e.left?e.left-h.right:0;if(f<o){n=c,o=f,r=f&&3==n.nodeType?{left:h.right<e.left?h.right:h.left,top:e.top}:e,1==c.nodeType&&f&&(i=p+(e.left>=(h.left+h.right)/2?1:0));continue}}!n&&(e.left>=h.right&&e.top>=h.top||e.left>=h.left&&e.top>=h.bottom)&&(i=p+1)}}return n&&3==n.nodeType?Dt(n,r):!n||o&&1==n.nodeType?{node:t,offset:i}:Ct(n,r)}function Dt(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=Rt(r,1);if(i.top!=i.bottom&&(i.left-1<=e.left&&i.right+1>=e.left&&i.top-1<=e.top&&i.bottom+1>=e.top))return{node:t,offset:o+(e.left>=(i.left+i.right)/2?1:0)}}return{node:t,offset:0}}function Tt(t,e){if(/^[uo]l$/i.test(t.nodeName))for(var n=t.firstChild;n;n=n.nextSibling)if(n.pmViewDesc&&/^li$/i.test(n.nodeName)){var r=n.getBoundingClientRect();if(e.left>r.left-2)break;if(r.top<=e.top&&r.bottom>=e.top)return n}return t}function Et(t,e,n){if(e=Tt(e,n),!t.dom.contains(1!=e.nodeType?e.parentNode:e))return null;var r=Ct(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)}function At(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)}function Nt(t,e){var n,r,o=t.root;if(o.caretPositionFromPoint){var i=o.caretPositionFromPoint(e.left,e.top);if(i){var s;n=(s=i).offsetNode,r=s.offset}}if(!n&&o.caretRangeFromPoint){var a=o.caretRangeFromPoint(e.left,e.top);if(a){var c;n=(c=a).startContainer,r=c.startOffset}}var p,l=o.elementFromPoint(e.left,e.top+1);if(!l)return null;if(n&&(p=At(t,n,r,e)),null==p&&null==(p=Et(t,l,e)))return null;var u=t.docView.nearestDesc(l,!0);return{pos:p,inside:u?u.posAtStart-u.border:-1}}function Rt(t,e){var n=t.getClientRects();return n.length?n[e<0?0:n.length-1]:t.getBoundingClientRect()}function It(t,e){var n,r,o=t.docView.domFromPos(e),i=o.node,s=o.offset;if(3==i.nodeType)s<i.nodeValue.length&&(r=Rt(ba(i,s,s+1),-1),n="left"),r&&r.left!=r.right||!s||(r=Rt(ba(i,s-1,s),1),n="right");else if(i.firstChild){if(s<i.childNodes.length){var a=i.childNodes[s];r=Rt(3==a.nodeType?ba(a):a,-1),n="left"}if((!r||r.top==r.bottom)&&s){var c=i.childNodes[s-1];r=Rt(3==c.nodeType?ba(c):c,1),n="right"}}else r=i.getBoundingClientRect(),n="left";var p=r[n];return{top:r.top,bottom:r.bottom,left:p,right:p}}function Pt(t,e,n){var r=t.state,o=t.root.activeElement;r==e&&t.inDOMChange||t.updateState(e),o!=t.dom&&t.focus();try{return n()}finally{r!=e&&t.updateState(r),o!=t.dom&&o.focus()}}function zt(t,e,n){var r=e.selection,o="up"==n?r.$anchor.min(r.$head):r.$anchor.max(r.$head);return!!o.depth&&Pt(t,e,function(){for(var e=t.docView.domAfterPos(o.before()),r=It(t,o.pos),i=e.firstChild;i;i=i.nextSibling){var s=void 0;if(1==i.nodeType)s=i.getClientRects();else{if(3!=i.nodeType)continue;s=ba(i,0,i.nodeValue.length).getClientRects()}for(var a=0;a<s.length;a++){var c=s[a];if("up"==n?c.bottom<r.top+1:c.top>r.bottom-1)return!1}}return!0})}function Ft(t,e,n){var r=e.selection.$head;if(!r.parent.isTextblock||!r.depth)return!1;var o=r.parentOffset,i=!o,s=o==r.parent.content.size,a=getSelection();return Sa.test(r.parent.textContent)&&a.modify?Pt(t,e,function(){var e=a.getRangeAt(0),o=a.focusNode,i=a.focusOffset;a.modify("move",n,"character");var s=!t.docView.domAfterPos(r.before()).contains(1==a.focusNode.nodeType?a.focusNode:a.focusNode.parentNode)||o==a.focusNode&&i==a.focusOffset;return a.removeAllRanges(),a.addRange(e),s}):"left"==n||"backward"==n?i:s}function Bt(t,e,n){return xa==e&&Ma==n?Oa:(xa=e,Ma=n,Oa="up"==n||"down"==n?zt(t,e,n):Ft(t,e,n))}function $t(t,e,n,r,o){return Wt(r,e,t),new Ba(null,t,e,n,r,r,r,o)}function _t(t,e){for(var n=t.firstChild,r=0;r<e.length;r++){var o=e[r],i=o.dom;if(i.parentNode==t){for(;i!=n;)n=Kt(n);n=n.nextSibling}else t.insertBefore(i,n);if(o instanceof Fa){var s=n?n.previousSibling:t.lastChild;_t(o.contentDOM,o.children),n=s?s.nextSibling:t.firstChild}}for(;n;)n=Kt(n)}function Vt(t){t&&(this.nodeName=t)}function jt(t,e,n){if(0==t.length)return La;for(var r=n?La[0]:new Vt,o=[r],i=0;i<t.length;i++){var s=t[i].type.attrs,a=r;if(s){s.nodeName&&o.push(a=new Vt(s.nodeName));for(var c in s){var p=s[c];null!=p&&(n&&1==o.length&&o.push(a=r=new Vt(e.isInline?"span":"div")),"class"==c?a.class=(a.class?a.class+" ":"")+p:"style"==c?a.style=(a.style?a.style+";":"")+p:"nodeName"!=c&&(a[c]=p))}}}return o}function Lt(t,e,n,r){if(n==La&&r==La)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=e.parentNode)&&c.tagName.toLowerCase()==s.nodeName?o=c:((c=document.createElement(s.nodeName)).appendChild(o),o=c)}Jt(o,a||La[0],s)}return o}function Jt(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(" "):Ia,s=n.class?n.class.split(" "):Ia,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){var p,l=t.style.cssText;e.style&&(p=l.indexOf(e.style))>-1&&(l=l.slice(0,p)+l.slice(p+e.style.length)),t.style.cssText=l+(n.style||"")}}function Wt(t,e,n){return Lt(t,t,La,jt(e,n,1!=t.nodeType))}function qt(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 Kt(t){var e=t.nextSibling;return t.parentNode.removeChild(t),e}function Ht(t,e,n,r){var o=e.locals(t),i=0;if(0!=o.length)for(var s=0,a=[],c=null,p=0;;){if(s<o.length&&o[s].to==i){for(var l=o[s++],u=void 0;s<o.length&&o[s].to==i;)(u||(u=[l])).push(o[s++]);u?(u.sort(function(t,e){return t.type.side-e.type.side}),u.forEach(n)):n(l)}var h=void 0;if(c)h=c,c=null;else{if(!(p<t.childCount))break;h=t.child(p++)}for(var f=0;f<a.length;f++)a[f].to<=i&&a.splice(f--,1);for(;s<o.length&&o[s].from==i;)a.push(o[s++]);var d=i+h.nodeSize;if(h.isText){var m=d;s<o.length&&o[s].from<m&&(m=o[s].from);for(var v=0;v<a.length;v++)a[v].to<m&&(m=a[v].to);m<d&&(c=h.cut(m-i),h=h.cut(0,m-i),d=m)}r(h,a.length?a.slice():Ia,e.forChild(i,h),p-1),i=d}else for(var g=0;g<t.childCount;g++){var y=t.child(g);r(y,o,e.forChild(i,y),g),i+=y.nodeSize}}function Ut(t){return qa==t._props?Wa:(qa=t._props,Wa=Qt(t))}function Qt(t){var e={};return t.someProp("nodeViews",function(t){for(var n in t)Object.prototype.hasOwnProperty.call(e,n)||(e[n]=t[n])}),e}function Gt(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}}function Xt(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&&Ha.findFrom(s,e)}function Yt(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function Zt(t,e){var n=t.state.selection;if(n instanceof Qa){if(n.empty){if(t.endOfTextblock(e>0?"right":"left")){var r=Xt(t.state,e);return!!(r&&r instanceof Ua)&&Yt(t,r)}var o=n.$head,i=o.textOffset?null:e<0?o.nodeBefore:o.nodeAfter;return!(!i||!Ua.isSelectable(i))&&Yt(t,new Ua(e<0?t.state.doc.resolve(o.pos-i.nodeSize):o))}return!1}if(n instanceof Ua&&n.node.isInline)return Yt(t,new Qa(e>0?n.$to:n.$from));var s=Xt(t.state,e);return!!s&&Yt(t,s)}function te(t){return 3==t.nodeType?t.nodeValue.length:t.childNodes.length}function ee(t){var e=t.pmViewDesc;return e&&0==e.size}function ne(t){for(var e,n,r=t.root.getSelection(),o=r.anchorNode,i=r.anchorOffset;;)if(i>0)if(1!=o.nodeType){if(3!=o.nodeType||"\ufeff"!=o.nodeValue.charAt(i-1))break;e=o,n=--i}else{var s=o.childNodes[i-1];if(ee(s))e=o,n=--i;else{if(3!=s.nodeType)break;i=(o=s).nodeValue.length}}else{if(oe(o))break;for(var a=o.previousSibling;a&&ee(a);)e=o.parentNode,n=Ga(a),a=a.previousSibling;if(a)i=te(o=a);else{if((o=o.parentNode)==t.dom)break;i=0}}e&&ie(r,e,n)}function re(t){for(var e,n,r=t.root.getSelection(),o=r.anchorNode,i=r.anchorOffset,s=te(o);;)if(i<s){if(1!=o.nodeType)break;if(!ee(o.childNodes[i]))break;e=o,n=++i}else{if(oe(o))break;for(var a=o.nextSibling;a&&ee(a);)e=a.parentNode,n=Ga(a)+1,a=a.nextSibling;if(a)i=0,s=te(o=a);else{if((o=o.parentNode)==t.dom)break;i=s=0}}e&&ie(r,e,n)}function oe(t){var e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function ie(t,e,n){var r=document.createRange();r.setEnd(e,n),r.setStart(e,n),t.removeAllRanges(),t.addRange(r)}function se(t,e){var n=t.state.selection;if(n instanceof Qa&&!n.empty)return!1;var r=n.$from,o=n.$to;if(!r.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){var i=Xt(t.state,e);if(i&&i instanceof Ua)return Yt(t,i)}if(!r.parent.inlineContent){var s=Ha.findFrom(e<0?r:o,e);return!s||Yt(t,s)}return!1}function ae(t,e){if(!(t.state.selection instanceof Qa))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 ce(t){var e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function pe(t,e){var n=e.keyCode,r=ce(e);return 8==n||ya.mac&&72==n&&"c"==r?ae(t,-1)||ne(t):46==n||ya.mac&&68==n&&"c"==r?ae(t,1)||re(t):13==n||27==n||(37==n?Zt(t,-1)||ne(t):39==n?Zt(t,1)||re(t):38==n?se(t,-1):40==n?se(t,1):r==(ya.mac?"m":"c")&&(66==n||73==n||89==n||90==n))}function le(t){return new("onselectionchange"in document?cc:pc)(t)}function ue(t,e){var n=t.state.selection;if(me(t,n),!t.hasFocus()){if(!e)return;ya.gecko&&t.editable&&(t.selectionReader.ignoreUpdates=!0,t.dom.focus(),t.selectionReader.ignoreUpdates=!1)}var r=t.selectionReader;if(!r.lastSelection||!r.lastSelection.eq(n)||r.domChanged()){if(r.ignoreUpdates=!0,t.cursorWrapper)de(t);else{var o,i,s=n.anchor,a=n.head;!ya.webkit||n instanceof rc||(n.$from.parent.inlineContent||(o=he(t,n.from)),n.empty||n.$from.parent.inlineContent||(i=he(t,n.to))),t.docView.setSelection(s,a,t.root),ya.webkit&&(o&&(o.contentEditable="false"),i&&(i.contentEditable="false")),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&fe(t))}r.storeDOMState(n),r.ignoreUpdates=!1}}function he(t,e){var n=t.docView.domFromPos(e),r=n.node,o=n.offset,i=o<r.childNodes.length?r.childNodes[o]:null,s=o?r.childNodes[o-1]:null;if(!(i&&"false"!=i.contentEditable||s&&"false"!=s.contentEditable)){if(i)return i.contentEditable="true",i;if(s)return s.contentEditable="true",s}}function fe(t){document.removeEventListener("selectionchange",t.hideSelectionGuard);var e=t.root.getSelection(),n=e.anchorNode,r=e.anchorOffset;document.addEventListener("selectionchange",t.hideSelectionGuard=function(){e.anchorNode==n&&e.anchorOffset==r||(document.removeEventListener("selectionchange",t.hideSelectionGuard),t.dom.classList.remove("ProseMirror-hideselection"))})}function de(t){var e=t.root.getSelection(),n=document.createRange(),r=t.cursorWrapper.type.widget;n.setEnd(r,r.childNodes.length),n.collapse(!1),e.removeAllRanges(),e.addRange(n)}function me(t,e){if(e instanceof oc){var n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(ve(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else ve(t)}function ve(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=null)}function ge(t,e,n,r){return t.someProp("createSelectionBetween",function(r){return r(t,e,n)})||rc.between(e,n,r)}function ye(t){if(t.editable&&t.root.activeElement!=t.dom)return!1;var e=t.root.getSelection();return e.anchorNode&&t.dom.contains(3==e.anchorNode.nodeType?e.anchorNode.parentNode:e.anchorNode)}function we(t,e,n){var r=t.docView.parseRange(n.from,n.to),o=r.node,i=r.fromOffset,s=r.toOffset,a=r.from,c=r.to,p=t.root.getSelection(),l=null,u=p.anchorNode;u&&t.dom.contains(1==u.nodeType?u:u.parentNode)&&(l=[{node:u,offset:p.anchorOffset}],gc(p)||l.push({node:p.focusNode,offset:p.focusOffset}));var h=e.doc,f=t.someProp("domParser")||hc.fromSchema(t.state.schema),d=h.resolve(a),m=null,v=f.parse(o,{topNode:d.parent.copy(),topStart:d.index(),topOpen:!0,from:i,to:s,preserveWhitespace:!d.parent.type.spec.code||"full",editableContent:!0,findPositions:l,ruleFromNode:be,context:d});if(l&&null!=l[0].pos){var g=l[0].pos,y=l[1]&&l[1].pos;null==y&&(y=g),m={anchor:g+a,head:y+a}}return{doc:v,sel:m,from:a,to:c}}function be(t){var e=t.pmViewDesc;return e?e.parseRule():"BR"==t.nodeName&&t.parentNode&&t.parentNode.lastChild==t?{ignore:!0}:void 0}function ke(t,e){for(var n=e||0;n<t.depth;n++)if(t.index(n)+1<t.node(n).childCount)return!1;return t.parentOffset==t.parent.content.size}function Se(t,e){for(var n=e||0;n<t.depth;n++)if(t.index(0)>0)return!1;return 0==t.parentOffset}function xe(t){var e=t.$anchor.min(t.$head),n=t.$anchor.max(t.$head);if(e.sameParent(n)&&e.parent.inlineContent&&e.parentOffset&&n.parentOffset<n.parent.content.size){var r=Math.max(0,e.parentOffset),o=e.parent.content.size,i=Math.min(o,n.parentOffset);if(r>0&&(r=e.parent.childBefore(r).offset),i<o){var s=e.parent.childAfter(i);i=s.offset+s.node.nodeSize}var a=e.start();return{from:a+r,to:a+i}}for(var c=0;;c++){var p=Se(e,c+1),l=ke(n,c+1);if(p||l||e.index(c)!=n.index(c)||n.node(c).isTextblock){var u=e.before(c+1),h=n.after(c+1);return p&&e.index(c)>0&&(u-=e.node(c).child(e.index(c)-1).nodeSize),l&&n.index(c)+1<n.node(c).childCount&&(h+=n.node(c).child(n.index(c)+1).nodeSize),{from:u,to:h}}}}function Me(t,e){var n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}function Oe(t,e,n,r){var o=we(t,n,r),i=n.doc,s=Ae(i.slice(o.from,o.to).content,o.doc.content,o.from,n.selection.from);if(s){var a,c=o.doc.resolveNoCache(s.start-o.from),p=o.doc.resolveNoCache(s.endB-o.from);if(!(!c.sameParent(p)&&c.pos<o.doc.content.size&&(a=fc.findFrom(o.doc.resolve(c.pos+1),1,!0))&&a.head==p.pos&&t.someProp("handleKeyDown",function(e){return e(t,Me(13,"Enter"))})||n.selection.anchor>s.start&&Te(i,s.start,s.endA,c,p)&&t.someProp("handleKeyDown",function(e){return e(t,Me(8,"Backspace"))}))){var l,u,h,f,d=e.map(s.start),m=e.map(s.endA,-1);if(c.sameParent(p)&&c.parent.inlineContent)if(c.pos==p.pos){l=t.state.tr.delete(d,m);var v=i.resolve(s.start);v.parentOffset<v.parent.content.size&&(u=v.marks(!0))}else if(s.endA==s.endB&&(f=i.resolve(s.start))&&(h=De(c.parent.content.cut(c.parentOffset,p.parentOffset),f.parent.content.cut(f.parentOffset,s.endA-f.start()))))l=t.state.tr,"add"==h.type?l.addMark(d,m,h.mark):l.removeMark(d,m,h.mark);else if(c.parent.child(c.index()).isText&&c.index()==p.index()-(p.textOffset?0:1)){var g=c.parent.textBetween(c.parentOffset,p.parentOffset);if(t.someProp("handleTextInput",function(e){return e(t,d,m,g)}))return;l=t.state.tr.insertText(g,d,m)}if(l||(l=t.state.tr.replace(d,m,o.doc.slice(s.start-o.from,s.endB-o.from))),o.sel){var y=Ce(t,l.doc,e,o.sel);y&&l.setSelection(y)}u&&l.ensureMarks(u),t.dispatch(l.scrollIntoView())}}else if(o.sel){var w=Ce(t,t.state.doc,e,o.sel);w&&!w.eq(t.state.selection)&&t.dispatch(t.state.tr.setSelection(w))}}function Ce(t,e,n,r){return Math.max(r.anchor,r.head)>e.content.size?null:vc(t,e.resolve(n.map(r.anchor)),e.resolve(n.map(r.head)))}function De(t,e){for(var n,r,o,i=t.firstChild.marks,s=e.firstChild.marks,a=i,c=s,p=0;p<s.length;p++)a=s[p].removeFromSet(a);for(var l=0;l<i.length;l++)c=i[l].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 u=[],h=0;h<e.childCount;h++)u.push(o(e.child(h)));if(uc.from(u).eq(t))return{mark:r,type:n}}function Te(t,e,n,r,o){if(!r.parent.isTextblock||n-e<=o.pos-r.pos||Ee(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(Ee(i,!0,!0));return!(!s.parent.isTextblock||s.pos>n||Ee(s,!0,!1)<n)&&r.parent.content.cut(r.parentOffset).eq(s.parent.content)}function Ee(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 Ae(t,e,n,r){var o=t.findDiffStart(e,n);if(null==o)return null;var i=t.findDiffEnd(e,n+t.size,n+e.size),s=i.a,a=i.b;return s<o&&t.size<e.size?(a=(o-=r<=o&&r>=s?o-r:0)+(a-s),s=o):a<o&&(s=(o-=r<=o&&r>=a?o-r:0)+(s-a),a=o),{start:o,endA:s,endB:a}}function Ne(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.type.hasRequiredAttrs()?s.attrs:null),r=s.content}var a=t.someProp("clipboardSerializer")||xc.fromSchema(t.state.schema),c=document.createElement("div");c.appendChild(a.serializeFragment(r));for(var p,l=c.firstChild;l&&1==l.nodeType&&(p=Mc[l.nodeName.toLowerCase()]);){for(var u=0;u<p.length;u++){for(var h=document.createElement(p[u]);c.firstChild;)h.appendChild(c.firstChild);c.appendChild(h)}l=c.firstChild}if(l&&1==l.nodeType){var f=0==e.openStart&&0==e.openEnd&&1==e.content.childCount&&!e.content.firstChild.isText;l.setAttribute("data-pm-context",f?"none":JSON.stringify(n))}return c}function Re(t,e,n,r,o){var i,s=o.parent.type.spec.code;if(!n&&!e)return null;if((r||s||!n)&&e){if(t.someProp("transformPastedText",function(t){return e=t(e)}),s)return new bc(kc.from(t.state.schema.text(e)),0,0);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){return n=t(n)}),i=Be(n);var a=(t.someProp("clipboardParser")||t.someProp("domParser")||Sc.fromSchema(t.state.schema)).parseSlice(i,{preserveWhitespace:!0,context:o});a=_e(a);var c=i.querySelector("[data-pm-context]"),p=c&&c.getAttribute("data-pm-context");return a="none"==p?new bc(a.content,0,0):p?$e(a,p):Ie(a,o),t.someProp("transformPasted",function(t){a=t(a)}),a}function Ie(t,e){if(t.content.childCount<2)return t;for(var n=e.depth;n>=0;n--){var r=function(n){var r=e.node(n).contentMatchAt(e.index(n)),o=void 0,i=[];if(t.content.forEach(function(t){if(i){var e,n=r.findWrappingFor(t);if(!n)return i=null;if(e=i.length&&o.length&&ze(n,o,t,i[i.length-1],0))i[i.length-1]=e;else{i.length&&(i[i.length-1]=Fe(i[i.length-1],o.length));var s=Pe(t,n);i.push(s),r=r.matchType(s.type,s.attrs),o=n}}}),i)return{v:bc.maxOpen(kc.from(i))}}(n);if(r)return r.v}return t}function Pe(t,e,n){void 0===n&&(n=0);for(var r=e.length-1;r>=n;r--)t=e[r].type.create(e[r].attrs,kc.from(t));return t}function ze(t,e,n,r,o){if(o<t.length&&o<e.length&&t[o].type==e[o].type){var i=ze(t,e,n,r.lastChild,o+1);if(i)return r.copy(r.content.replaceChild(r.childCount-1,i));var s=r.contentMatchAt(r.childCount);if(o==t.length-1?s.matchNode(n):s.matchType(t[o+1].type,t[o+1].attrs))return r.copy(r.content.append(kc.from(Pe(n,t,o+1))))}}function Fe(t,e){if(0==e)return t;var n=t.content.replaceChild(t.childCount-1,Fe(t.lastChild,e-1)),r=t.contentMatchAt(t.childCount).fillBefore(kc.empty,!0);return t.copy(n.append(r))}function Be(t){var e=/(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));var n,r=(Oc||(Oc=document.implementation.createHTMLDocument("title"))).createElement("div"),o=/(?:<meta [^>]*>)*<([a-z][^>\s]+)/i.exec(t),i=0;(n=o&&Mc[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}function $e(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=kc.from(c.create(n[a+1],o)),i++,s++}return new bc(o,i,s)}function _e(t){for(var e=0,n=t.content,r=1;r<=t.openStart;r++){var o=n.firstChild;if(o.type.spec.isolating){e=r;break}n=o.content}return 0==e?t:new bc(Ve(t.content,e,t.openEnd),t.openStart-e,t.openEnd)}function Ve(t,e,n){if(0==e)return t;var r=t.firstChild,o=Ve(r.content,e-1,n-1),i=r.contentMatchAt(0).fillBefore(r.content,n<=0);return t.replaceChild(0,r.copy(i.append(o)))}function je(t){t.shiftKey=!1,t.mouseDown=null,t.dragging=null,t.inDOMChange=null,t.domObserver=new Vc(t),t.domObserver.start();for(var e in Lc)!function(e){var n=Lc[e];t.dom.addEventListener(e,function(e){!qe(t,e)||We(t,e)||!t.editable&&e.type in Jc||n(t,e)})}(e);t.extraHandlers=Object.create(null),Je(t)}function Le(t){t.domObserver.stop(),t.inDOMChange&&t.inDOMChange.destroy()}function Je(t){t.someProp("handleDOMEvents",function(e){for(var n in e)t.extraHandlers[n]||Lc.hasOwnProperty(n)||(t.extraHandlers[n]=!0,t.dom.addEventListener(n,function(e){return We(t,e)}))})}function We(t,e){return t.someProp("handleDOMEvents",function(n){var r=n[e.type];return!!r&&(r(t,e)||e.defaultPrevented)})}function qe(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}function Ke(t,e){We(t,e)||!Lc[e.type]||!t.editable&&e.type in Jc||Lc[e.type](t,e)}function He(t){return{left:t.clientX,top:t.clientY}}function Ue(t,e){var n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function Qe(t,e,n,r,o){if(-1==r)return!1;for(var i=t.state.doc.resolve(r),s=i.depth+1;s>0;s--){var a=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}}(s);if(a)return a.v}return!1}function Ge(t,e,n){t.focused||t.focus();var r=t.state.tr.setSelection(e);"pointer"==n&&r.setMeta("pointer",!0),t.dispatch(r)}function Xe(t,e){if(-1==e)return!1;var n=t.state.doc.resolve(e),r=n.nodeAfter;return!!(r&&r.isAtom&&Pc.isSelectable(r))&&(Ge(t,new Pc(n),"pointer"),!0)}function Ye(t,e){if(-1==e)return!1;var n,r,o=t.state.selection;o instanceof Pc&&(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(Pc.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&&(Ge(t,Pc.create(t.state.doc,r),"pointer"),!0)}function Ze(t,e,n,r,o){return Qe(t,"handleClickOn",e,n,r)||t.someProp("handleClick",function(n){return n(t,e,r)})||(o?Ye(t,n):Xe(t,n))}function tn(t,e,n,r){return Qe(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",function(n){return n(t,e,r)})}function en(t,e,n,r){return Qe(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",function(n){return n(t,e,r)})||nn(t,n)}function nn(t,e){var n=t.state.doc;if(-1==e)return!!n.inlineContent&&(Ge(t,zc.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)Ge(t,zc.create(n,s+1,s+1+i.content.size),"pointer");else{if(!Pc.isSelectable(i))continue;Ge(t,Pc.create(n,s),"pointer")}return!0}}function rn(t){return!!t.inDOMChange&&(t.inDOMChange.finish(!0),!0)}function on(t,e){var n=document.body.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),r.removeAllRanges(),r.addRange(o),setTimeout(function(){document.body.removeChild(n),t.focus()},50)}function sn(t){return 0==t.openStart&&0==t.openEnd&&1==t.content.childCount?t.content.firstChild:null}function an(t,e){var n=t.shiftKey||t.state.selection.$from.parent.type.spec.code,r=document.body.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(),document.body.removeChild(r),n?cn(t,r.value,null,e):cn(t,r.textContent,r.innerHTML,e)},50)}function cn(t,e,n,r){var o=$c(t,e,n,t.shiftKey,t.state.selection.$from);if(!o)return!1;if(t.someProp("handlePaste",function(e){return e(t,r,o)}))return!0;var i=sn(o),s=i?t.state.tr.replaceSelectionWith(i):t.state.tr.replaceSelection(o);return t.dispatch(s.scrollIntoView()),!0}function pn(t,e){if(!t||!t.content.size)return e.pos;for(var n=t.content,r=0;r<t.openStart;r++)n=n.firstChild.content;for(var o=e.depth;o>=0;o--){var i=o==e.depth?0:e.pos<=(e.start(o+1)+e.end(o+1))/2?-1:1,s=e.index(o)+(i>0?1:0);if(e.node(o).canReplace(s,s,n))return 0==i?e.pos:i<0?e.before(o+1):e.after(o+1)}return e.pos}function ln(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}function un(t,e,n,r,o,i,s){for(var a=t.slice(),c=function(t,e,n,r){for(var o=0;o<a.length;o+=3){var s=a[o+1],c=void 0;-1==s||t>s+i||(e>=a[o]+i?a[o+1]=-1:(c=r-n-(e-t))&&(a[o]+=c,a[o+1]+=c))}},p=0;p<n.maps.length;p++)n.maps[p].forEach(c);for(var l=!1,u=0;u<a.length;u+=3)if(-1==a[u+1]){var h=n.map(a[u]+i),f=h-o;if(f<0||f>=r.content.size){l=!0;continue}var d=n.map(t[u+1]+i,-1)-o,m=r.content.findIndex(f),v=m.index,g=m.offset,y=r.maybeChild(v);if(y&&g==f&&g+y.nodeSize==d){var w=a[u+2].mapInner(n,y,h+1,a[u]+i+1,s);w!=fp?(a[u]=f,a[u+1]=d,a[u+2]=w):(a.splice(u,3),u-=3)}else l=!0}if(l){var b=vn(fn(a,e?hn(e,o):[],n,i,s),r,0,s);e=b.local;for(var k=0;k<a.length;k+=3)-1==a[k+1]&&(a.splice(k,3),k-=3);for(var S=0,x=0;S<b.children.length;S+=3){for(var M=b.children[S];x<a.length&&a[x]<M;)x+=3;a.splice(x,0,b.children[S],b.children[S+1],b.children[S+2])}}return new up(e&&e.sort(gn),a)}function hn(t,e){if(!e||!t.length)return t;for(var n=[],r=0;r<t.length;r++){var o=t[r];n.push(new sp(o.from+e,o.to+e,o.type))}return n}function fn(t,e,n,r,o){function i(t,r){for(var s=0;s<t.local.length;s++){var a=t.local[s].map(n,0,r);a?e.push(a):o.onRemove&&o.onRemove(t.local[s].spec)}for(var c=0;c<t.children.length;c+=3)i(t.children[c+2],t.children[c]+r+1)}for(var s=0;s<t.length;s+=3)-1==t[s+1]&&i(t[s+2],t[s]+r+1);return e}function dn(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 mn(t){for(var e=[],n=0;n<t.length;n++)null!=t[n]&&e.push(t[n]);return e}function vn(t,e,n,r){var o=[],i=!1;e.forEach(function(e,s){var a=dn(t,e,s+n);if(a){i=!0;var c=vn(a,e,n+s+1,r);c!=fp&&o.push(s,s+e.nodeSize,c)}});for(var s=hn(i?mn(t):t,-n).sort(gn),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 up(s,o):fp}function gn(t,e){return t.from-e.from||t.to-e.to}function yn(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),wn(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),wn(e,o+1,i.copy(r.to,i.to)))}}}return e}function wn(t,e,n){for(;e<t.length&&gn(n,t[e])>0;)e++;t.splice(e,0,n)}function bn(t){var e=[];return t.someProp("decorations",function(n){var r=n(t.state);r&&r!=fp&&e.push(r)}),t.cursorWrapper&&e.push(up.create(t.state.doc,[t.cursorWrapper])),dp.from(e)}function kn(t){var e=(!xp||!t.ctrlKey&&!t.altKey&&!t.metaKey)&&t.key||(t.shiftKey?kp:bp)[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}function Sn(t){var e=t.split(/-(?!$)/),n=e[e.length-1];"Space"==n&&(n=" ");for(var r,o,i,s,a=0;a<e.length-1;a++){var c=e[a];if(/^(cmd|meta|m)$/i.test(c))s=!0;else if(/^a(lt)?$/i.test(c))r=!0;else if(/^(c|ctrl|control)$/i.test(c))o=!0;else if(/^s(hift)?$/i.test(c))i=!0;else{if(!/^mod$/i.test(c))throw new Error("Unrecognized modifier name: "+c);Tp?s=!0:o=!0}}return r&&(n="Alt-"+n),o&&(n="Ctrl-"+n),s&&(n="Meta-"+n),i&&(n="Shift-"+n),n}function xn(t){var e=Object.create(null);for(var n in t)e[Sn(n)]=t[n];return e}function Mn(t,e,n){return e.altKey&&(t="Alt-"+t),e.ctrlKey&&(t="Ctrl-"+t),e.metaKey&&(t="Meta-"+t),!1!==n&&e.shiftKey&&(t="Shift-"+t),t}function On(t){return new Dp({props:{handleKeyDown:Cn(t)}})}function Cn(t){var e=xn(t);return function(t,n){var r,o=Cp(n),i=1==o.length&&" "!=o,s=e[Mn(o,n,!i)];if(s&&s(t.state,t.dispatch,t))return!0;if(n.shiftKey&&i&&(r=Cp.base[n.keyCode])){var a=e[Mn(r,n,!0)];if(a&&a(t.state,t.dispatch,t))return!0}return!1}}function Dn(t,e){return!t.selection.empty&&(e&&e(t.tr.deleteSelection().scrollIntoView()),!0)}function Tn(t,e,n){var r=t.selection.$cursor;if(!r||(n?!n.endOfTextblock("backward",t):r.parentOffset>0))return!1;var o,i,s;if(!r.parent.type.spec.isolating)for(var a=r.depth-1;!o&&a>=0&&(r.index(a)>0&&(i=r.before(a+1),o=r.node(a).child(r.index(a)-1),s=a),!r.node(a).type.spec.isolating);a--);if(!o){var c=r.blockRange(),p=c&&Ip(c);return null!=p&&(e&&e(t.tr.lift(c,p).scrollIntoView()),!0)}if(o.isAtom&&Vp.isSelectable(o)&&0==r.parent.content.size){if(e){var l=t.tr.delete(i,i+r.parent.nodeSize);l.setSelection(Vp.create(l.doc,i-o.nodeSize)),e(l.scrollIntoView())}return!0}return o.isLeaf&&s==r.depth-1?(e&&e(t.tr.delete(i-o.nodeSize,i).scrollIntoView()),!0):!o.type.spec.isolating&&jn(t,i,e)||Ln(t,i,-1,e)}function En(t,e,n){var r=t.selection.$cursor;if(!r||(n?!n.endOfTextblock("forward",t):r.parentOffset<r.parent.content.size))return!1;var o,i,s;if(!r.parent.type.spec.isolating)for(var a=r.depth-1;!o&&a>=0;a--){var c=r.node(a);if(r.index(a)+1<c.childCount&&(o=c.child(r.index(a)+1),i=r.after(a+1),s=a),c.type.spec.isolating)break}return!!o&&(o.isLeaf&&s==r.depth-1?(e&&e(t.tr.delete(i,i+o.nodeSize).scrollIntoView()),!0):jn(t,i,e)||Ln(t,i,1,e))}function An(t,e){var n,r=t.selection,o=r instanceof Vp;if(o){if(r.node.isTextblock||!Np(t.doc,r.from))return!1;n=r.from}else if(null==(n=Ap(t.doc,r.from,-1)))return!1;if(e){var i=t.tr.join(n);o&&i.setSelection(Vp.create(i.doc,n-t.doc.resolve(n).nodeBefore.nodeSize)),e(i.scrollIntoView())}return!0}function Nn(t,e){var n,r=t.selection;if(r instanceof Vp){if(r.node.isTextblock||!Np(t.doc,r.to))return!1;n=r.to}else if(null==(n=Ap(t.doc,r.to,1)))return!1;return e&&e(t.tr.join(n).scrollIntoView()),!0}function Rn(t,e){var n=t.selection,r=n.$from,o=n.$to,i=r.blockRange(o),s=i&&Ip(i);return null!=s&&(e&&e(t.tr.lift(i,s).scrollIntoView()),!0)}function In(t,e){var n=t.selection,r=n.$head,o=n.$anchor;return!(!r.parent.type.spec.code||!r.sameParent(o))&&(e&&e(t.tr.insertText("\n").scrollIntoView()),!0)}function Pn(t,e){var n=t.selection,r=n.$head,o=n.$anchor;if(!r.parent.type.spec.code||!r.sameParent(o))return!1;var i=r.node(-1),s=r.indexAfter(-1),a=i.defaultContentType(s);if(!i.canReplaceWith(s,s,a))return!1;if(e){var c=r.after(),p=t.tr.replaceWith(c,c,a.createAndFill());p.setSelection($p.near(p.doc.resolve(c),1)),e(p.scrollIntoView())}return!0}function zn(t,e){var n=t.selection,r=n.$from,o=n.$to;if(r.parent.inlineContent||o.parent.inlineContent)return!1;var i=r.parent.defaultContentType(o.indexAfter());if(!i||!i.isTextblock)return!1;if(e){var s=(!r.parentOffset&&o.index()<o.parent.childCount?r:o).pos,a=t.tr.insert(s,i.createAndFill());a.setSelection(_p.create(a.doc,s+1)),e(a.scrollIntoView())}return!0}function Fn(t,e){var n=t.selection.$cursor;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){var r=n.before();if(Pp(t.doc,r))return e&&e(t.tr.split(r).scrollIntoView()),!0}var o=n.blockRange(),i=o&&Ip(o);return null!=i&&(e&&e(t.tr.lift(o,i).scrollIntoView()),!0)}function Bn(t,e){var n=t.selection,r=n.$from,o=n.$to;if(t.selection instanceof Vp&&t.selection.node.isBlock)return!(!r.parentOffset||!Pp(t.doc,r.pos))&&(e&&e(t.tr.split(r.pos).scrollIntoView()),!0);if(e){var i=o.parentOffset==o.parent.content.size,s=t.tr;t.selection instanceof _p&&s.deleteSelection();var a=0==r.depth?null:r.node(-1).defaultContentType(r.indexAfter(-1)),c=i?[{type:a}]:null,p=Pp(s.doc,r.pos,1,c);c||p||!Pp(s.doc,s.mapping.map(r.pos),1,[{type:a}])||(c=[{type:a}],p=!0),p&&(s.split(s.mapping.map(r.pos),1,c),i||r.parentOffset||r.parent.type==a||!r.node(-1).canReplace(r.index(-1),r.indexAfter(-1),Bp.from(a.create(),r.parent))||s.setNodeType(s.mapping.map(r.before()),a)),e(s.scrollIntoView())}return!0}function $n(t,e){var n,r=t.selection,o=r.$from,i=r.to,s=o.sharedDepth(i);return 0!=s&&(n=o.before(s),e&&e(t.tr.setSelection(Vp.create(t.doc,n))),!0)}function _n(t,e){return e&&e(t.tr.setSelection(new jp(t.doc))),!0}function Vn(t,e,n){var r=e.nodeBefore,o=e.nodeAfter,i=e.index();return!!(r&&o&&r.type.compatibleContent(o.type))&&(!r.content.size&&e.parent.canReplace(i-1,i)?(n&&n(t.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!(!e.parent.canReplace(i,i+1)||!o.isTextblock&&!Np(t.doc,e.pos))&&(n&&n(t.tr.clearNonMatching(e.pos,r.contentMatchAt(r.childCount)).join(e.pos).scrollIntoView()),!0))}function jn(t,e,n){var r,o,i=t.doc.resolve(e),s=i.nodeBefore,a=i.nodeAfter;if(Vn(t,i,n))return!0;if(i.parent.canReplace(i.index(),i.index()+1)&&(r=(o=s.contentMatchAt(s.childCount)).findWrappingFor(a))&&o.matchType((r[0]||a).type,(r[0]||a).attrs).validEnd()){if(n){for(var c=e+a.nodeSize,p=Bp.empty,l=r.length-1;l>=0;l--)p=Bp.from(r[l].type.create(r[l].attrs,p));p=Bp.from(s.copy(p));var u=t.tr.step(new zp(e-1,c,e,c,new Fp(p,1,0),r.length,!0)),h=c+2*r.length;Np(u.doc,h)&&u.join(h),n(u.scrollIntoView())}return!0}var f=$p.findFrom(i,1),d=f&&f.$from.blockRange(f.$to),m=d&&Ip(d);return null!=m&&m>=i.depth&&(n&&n(t.tr.lift(d,m).scrollIntoView()),!0)}function Ln(t,e,n,r){var o=t.doc.resolve(e),i=n>0?o.nodeAfter:o.nodeBefore;return!(!i||!Vp.isSelectable(i))&&(r&&r(t.tr.setSelection(Vp.create(t.doc,e-(n>0?0:i.nodeSize))).scrollIntoView()),!0)}function Jn(t,e){return function(n,r){var o=n.selection,i=o.$from,s=o.$to,a=i.blockRange(s),c=a&&Rp(a,t,e);return!!c&&(r&&r(n.tr.wrap(a,c).scrollIntoView()),!0)}}function Wn(t,e){return function(n,r){var o,i,s=n.selection,a=s.$from,c=s.$to;if(n.selection instanceof Vp)o=a.depth,i=n.selection.node;else{if(!a.depth||c.pos>a.end())return!1;o=a.depth-1,i=a.parent}if(!i.isTextblock||i.hasMarkup(t,e))return!1;var p=a.index(o);if(!a.node(o).canReplaceWith(p,p+1,t))return!1;if(r){var l=a.before(o+1);r(n.tr.clearNonMatching(l,t.contentExpr.start(e)).setNodeType(l,t,e).scrollIntoView())}return!0}}function qn(t,e,n){for(var r=0;r<e.length;r++){var o=function(r){var o=e[r],i=o.$from,s=o.$to,a=0==i.depth&&t.contentMatchAt(0).allowsMark(n);if(t.nodesBetween(i.pos,s.pos,function(t){if(a)return!1;a=t.inlineContent&&t.contentMatchAt(0).allowsMark(n)}),a)return{v:!0}}(r);if(o)return o.v}return!1}function Kn(t,e){return function(n,r){var o=n.selection,i=o.empty,s=o.$cursor,a=o.ranges;if(i&&!s||!qn(n.doc,a,t))return!1;if(r)if(s)r(t.isInSet(n.storedMarks||s.marks())?n.tr.removeStoredMark(t):n.tr.addStoredMark(t.create(e)));else{for(var c=!1,p=n.tr,l=0;!c&&l<a.length;l++){var u=a[l],h=u.$from,f=u.$to;c=n.doc.rangeHasMark(h.pos,f.pos,t)}for(var d=0;d<a.length;d++){var m=a[d],v=m.$from,g=m.$to;c?p.removeMark(v.pos,g.pos,t):p.addMark(v.pos,g.pos,t.create(e))}r(p.scrollIntoView())}return!0}}function Hn(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];return function(e,n,r){for(var o=0;o<t.length;o++)if(t[o](e,n,r))return!0;return!1}}function Un(t,e){var n;return t.forEach(function(t,r){if(t.selection&&0==e--)return n=r,!1}),t.slice(n)}function Qn(t,e,n,r){var o,i=n.getMeta(pl);if(i)return i;n.getMeta(ll)&&(t=new al(t.done,t.undone,null,0));var s=n.getMeta("appendedTransaction");if(0==n.steps.length)return t;if(!1!==(s||n).getMeta("addToHistory")){var a=t.prevTime<(n.time||0)-r.newGroupDelay||!s&&!Gn(n,t.prevMap,t.done);return new al(t.done.addTransform(n,a?e.getBookmark():null,r),il.empty,n.mapping.maps[n.steps.length-1],n.time)}return(o=n.getMeta("rebased"))?new al(t.done.rebased(n,o),t.undone.rebased(n,o),t.prevMap&&n.mapping.maps[n.steps.length-1],t.prevTime):new al(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),t.prevMap,t.prevTime)}function Gn(t,e,n){if(!e)return!1;var r=t.mapping.maps[0],o=!1;return!r||(r.forEach(function(t,r){n.items.forEach(function(n){if(n.step)return e.forEach(function(e,n,i,s){t<=s&&r>=i&&(o=!0)}),!1;t=n.map.invert().map(t,-1),r=n.map.invert().map(r,1)},n.items.length,0)}),o)}function Xn(t,e,n,r){var o=pl.get(e).spec.config,i=(r?t.undone:t.done).popEvent(e,o.preserveItems);if(i){var s=e.selection,a=i.selection.resolve(i.transform.doc),c=(r?t.done:t.undone).addTransform(i.transform,s.getBookmark(),o),p=new al(r?c:i.remaining,r?i.remaining:c,null,0);n(i.transform.setSelection(a).setMeta(pl,p).scrollIntoView())}}function Yn(t){return t={depth:t&&t.depth||100,preserveItems:!(!t||!t.preserveItems),newGroupDelay:t&&t.newGroupDelay||500},new rl({key:pl,state:{init:function(){return new al(il.empty,il.empty,null,0)},apply:function(e,n,r){return Qn(n,r.selection,e,t)}},config:t})}function Zn(t,e){var n=pl.getState(t);return!(!n||0==n.done.eventCount)&&(e&&Xn(n,t,e,!1),!0)}function tr(t,e){var n=pl.getState(t);return!(!n||0==n.undone.eventCount)&&(e&&Xn(n,t,e,!0),!0)}function er(t){return function(e,n){var r=e.selection,o=r.$from,i=r.$to,s=r.node;if(s&&s.isBlock||!o.parent.content.size||o.depth<2||!o.sameParent(i))return!1;var a=o.node(-1);if(a.type!=t)return!1;var c=i.pos==o.end()?a.defaultContentType(0):null,p=e.tr.delete(o.pos,i.pos),l=c&&[null,{type:c}];return!!dl(p.doc,o.pos,2,l)&&(n&&n(p.split(o.pos,2,l).scrollIntoView()),!0)}}function nr(t){return t.reduce(function(t,e){return{nodes:Sl({},t.nodes,e.nodes),marks:Sl({},t.marks,e.marks)}},{nodes:{},marks:{}})}function rr(t){return t.reduce(function(t,e){return Array.isArray(e)?t.concat(rr(e)):[].concat(Ol(t),[e])},[])}function or(t,e){var n=window.toString.call(t),r=void 0;if(n!==toString.call(e))return!1;switch(n){case"[object String]":case"[object Number]":case"[object Boolean]":case"[object Null]":case"[object Undefined]":return t===e}return Array.isArray(t)?t.length===e.length&&t.every(function(t){return function(e,n){return or(e,t[n])}}(e)):(r=Object.keys(t)).length===Object.keys(e).length&&r.every(function(t,e){return function(n){return n in t&&n in e&&or(t[n],e[n])}}(t,e))}function ir(t){return new RegExp(t.toString().replace(" ","( | )").slice(1,-1))}function sr(){return Hp(Jp,function(t,e){return e(t.tr.replaceSelectionWith(t.schema.nodes.hardBreak.create()).scrollIntoView()),!0})}function ar(t){var e=t.inline;return Ep(Sl({},Xp,kl({"Mod-z":hl,"Shift-Mod-z":fl},e?"Enter":"Mod-Enter",sr())))}function cr(t){return function(e,n,r,o){var i=t;if(n[1]){var s=n[0].lastIndexOf(n[1]);i+=n[0].slice(s+n[1].length);var a=(r+=s)-o;a>0&&(i=n[0].slice(s-a,s)+i,r=o)}var c=e.doc.resolve(r).marks();return e.tr.replaceWith(r,o,e.schema.text(i,c))}}function pr(t){var e=t.rules;return new tu({state:{init:function(){return null},apply:function(t,e){var n=t.getMeta(this);return n||(t.selectionSet||t.docChanged?null:e)}},props:{handleTextInput:function(t,n,r,o){for(var i=this,s=t.state,a=s.doc.resolve(n),c=a.parent.textBetween(Math.max(0,a.parentOffset-eu),a.parentOffset,null,"")+o,p=0;p<e.length;p++){var l=e[p].match.exec(c),u=l&&e[p].handler(s,l,n-(l[0].length-o.length),r);if(u)return t.dispatch(u.setMeta(i,{transform:u,from:n,to:r,text:o})),!0}return!1}},isInputRules:!0})}function lr(t,e){for(var n=t.plugins,r=0;r<n.length;r++){var o=n[r],i=void 0;if(o.spec.isInputRules&&(i=o.getState(t))){if(e){for(var s=t.tr,a=i.transform,c=a.steps.length-1;c>=0;c--)s.step(a.steps[c].invert(a.docs[c]));var p=s.doc.resolve(i.from).marks();e(s.replaceWith(i.from,i.to,t.schema.text(i.text,p)))}return!0}}return!1}function ur(t,e,n,r){return new gu(t,function(t,o,i,s){var a=n instanceof Function?n(o):n,c=t.tr.delete(i,s),p=c.doc.resolve(i).blockRange(),l=p&&yu(p,e,a);if(!l)return null;c.wrap(p,l);var u=c.doc.resolve(i-1).nodeBefore;return u&&u.type==e&&wu(c.doc,i-1)&&(!r||r(o,u))&&c.join(i-1),c})}function hr(t,e,n){return new gu(t,function(t,r,o,i){var s=t.doc.resolve(o),a=n instanceof Function?n(r):n;return s.node(-1).canReplaceWith(s.index(-1),s.indexAfter(-1),e,a)?t.tr.delete(o,i).setBlockType(o,o,e,a):null})}function fr(t){return ur(/^\s*> $/,t)}function dr(t){return ur(/^(\d+)\. $/,t,function(t){return{order:+t[1]}},function(t,e){return e.childCount+e.attrs.order==+t[1]})}function mr(t){return ur(/^\s*([-+*]) $/,t)}function vr(t){return hr(/^```$/,t)}function gr(t,e){return hr(new RegExp("^(#{1,"+e+"}) $"),t,function(t){return{level:t[1].length}})}function yr(t){var e=t.name,n=t.keys;return{name:e,type:Cu,keymap:n?kl({},n,Kl(e)()):void 0,toggle:Kl(e),apply:Hl(e),remove:Ul(e),isApplied:Dl(e),isApplicable:Tl(e),getMeta:Vl(Cl(e))}}function wr(t){return t.doc.childCount>0}function br(t){return wr(t)?1:0}function kr(t){var e=document.createElement("span");return e.className=_u,e.setAttribute(Vu,t),e}function Sr(){var t=document.createElement("style");return t.innerHTML=ju,t}function xr(t){var e=t.doc,n=!wr(t),r=1===e.childCount&&e.firstChild.isTextblock&&0===e.firstChild.content.size;return Lu.getState(t).viewIsEditable&&(n||r)}function Mr(t){Lu.getState(t.state).viewIsEditable!==t.editable&&t.dispatch(t.state.tr.setMeta(Lu,{viewIsEditable:t.editable}))}function Or(t){return gp.widget(br(t),document.createTextNode($u),{key:"padding"})}function Cr(t,e){return gp.widget(br(t),kr(e),{key:"placeholder"})}function Dr(t){return gp.widget(br(t),Sr(),{key:"placeholder-styles"})}function Tr(t){var e=t.state.doc.content.size>0?1:0,n=fa.create(t.state.doc,e);t.dispatch(t.state.tr.setSelection(n))}function Er(t){var e=t.text;return new va({key:Lu,view:function(t){return Mr(t),{update:Mr}},state:{init:function(){return{viewIsEditable:!1}},apply:function(t,e){return t.getMeta(Lu)||e}},props:{onFocus:function(t){xr(t.state)&&Tr(t)},decorations:function(t){if(xr(t))return yp.create(t.doc,[Or(t),Cr(t,e),Dr(t)])},handleClick:function(t,e,n){if(n.target.classList.contains(_u)){var r=t.state.doc.content.size>0?1:0,o=fa.create(t.state.doc,r);t.dispatch(t.state.tr.setSelection(o))}if(t.hasFocus()&&xr(t.state))return Tr(t),!0},handleKeyDown:function(t,e){var n=t.hasFocus(),r=xr(t.state),o=37===e.keyCode||39===e.keyCode;if(n&&r&&o)return!0}},toJSON:function(t){return Sl({},t)},fromJSON:function(t){return Object.ssign({},t)}})}function Ar(t){var e=t.onBlur,n=t.onFocus,r=t.onSelect,o=t.onInput;return new va({key:new ga("events"),props:{onBlur:function(t,n){return e(n)},onFocus:function(t,e){return n(e)}},state:{init:function(t,e){return{selection:e.selection}},apply:function(t,e,n,i){var s=void 0;return s=i.selection,e.selection.eq(s)||Promise.resolve().then(function(){return r(s)}),t.docChanged&&Promise.resolve().then(o),{selection:s}}}})}function Nr(){var t=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).editable,e=void 0!==t&&t;return new va({key:new ga("editable"),props:{editable:function(t){return this.getState(t).editable}},state:{init:function(){return{editable:e}},apply:function(t,e){var n=t.getMeta(this.key);return void 0!==n?{editable:n}:e}}})}function Rr(t){var e=document.createElement("style");return e.innerHTML=Ju.map(function(e){return t+" "+e}).join(",")+"{ white-space: pre-wrap; }",e}function Ir(t){return gp.widget(0,Rr(t),{key:"pre-wrap-styles"})}function Pr(t){var e=t.element.tagName.toLowerCase();return new va({props:{decorations:function(t){return yp.create(t.doc,[Ir(e)])}}})}function zr(){var t=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).rules;return Su({rules:void 0===t?xu:t})}function Fr(t){return t=t||Object.create(null),{on:function(e,n){(t[e]||(t[e]=[])).push(n)},off:function(e,n){t[e]&&t[e].splice(t[e].indexOf(n)>>>0,1)},emit:function(e,n){(t[e]||[]).map(function(t){t(n)}),(t["*"]||[]).map(function(t){t(e,n)})}}}var Br={findDiffStart:e,findDiffEnd:n},$r=Br.findDiffStart,_r=Br.findDiffEnd,Vr=function(t,e){var n=this;if(this.content=t,this.size=e||0,null==e)for(var r=0;r<t.length;r++)n.size+=t[r].nodeSize},jr={firstChild:{},lastChild:{},childCount:{}};Vr.prototype.nodesBetween=function(t,e,n,r,o){var i=this;void 0===r&&(r=0);for(var s=0,a=0;a<e;s++){var c=i.content[s],p=a+c.nodeSize;if(p>t&&!1!==n(c,r+a,o,s)&&c.content.size){var l=a+1;c.nodesBetween(Math.max(0,t-l),Math.min(c.content.size,e-l),n,r+l)}a=p}},Vr.prototype.descendants=function(t){this.nodesBetween(0,this.size,t)},Vr.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},Vr.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 Vr(r,this.size+t.size)},Vr.prototype.cut=function(t,e){var n=this;if(null==e&&(e=this.size),0==t&&e==this.size)return this;var r=[],o=0;if(e>t)for(var i=0,s=0;s<e;i++){var a=n.content[i],c=s+a.nodeSize;c>t&&((s<t||c>e)&&(a=a.isText?a.cut(Math.max(0,t-s),Math.min(a.text.length,e-s)):a.cut(Math.max(0,t-s-1),Math.min(a.content.size,e-s-1))),r.push(a),o+=a.nodeSize),s=c}return new Vr(r,o)},Vr.prototype.cutByIndex=function(t,e){return t==e?Vr.empty:0==t&&e==this.content.length?this:new Vr(this.content.slice(t,e))},Vr.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 Vr(r,o)},Vr.prototype.addToStart=function(t){return new Vr([t].concat(this.content),this.size+t.nodeSize)},Vr.prototype.addToEnd=function(t){return new Vr(this.content.concat(t),this.size+t.nodeSize)},Vr.prototype.eq=function(t){var e=this;if(this.content.length!=t.content.length)return!1;for(var n=0;n<this.content.length;n++)if(!e.content[n].eq(t.content[n]))return!1;return!0},jr.firstChild.get=function(){return this.content.length?this.content[0]:null},jr.lastChild.get=function(){return this.content.length?this.content[this.content.length-1]:null},jr.childCount.get=function(){return this.content.length},Vr.prototype.child=function(t){var e=this.content[t];if(!e)throw new RangeError("Index "+t+" out of range for "+this);return e},Vr.prototype.offsetAt=function(t){for(var e=this,n=0,r=0;r<t;r++)n+=e.content[r].nodeSize;return n},Vr.prototype.maybeChild=function(t){return this.content[t]},Vr.prototype.forEach=function(t){for(var e=this,n=0,r=0;n<this.content.length;n++){var o=e.content[n];t(o,r,n),r+=o.nodeSize}},Vr.prototype.findDiffStart=function(t,e){return void 0===e&&(e=0),$r(this,t,e)},Vr.prototype.findDiffEnd=function(t,e,n){return void 0===e&&(e=this.size),void 0===n&&(n=t.size),_r(this,t,e,n)},Vr.prototype.findIndex=function(t,e){var n=this;if(void 0===e&&(e=-1),0==t)return r(0,t);if(t==this.size)return r(this.content.length,t);if(t>this.size||t<0)throw new RangeError("Position "+t+" outside of fragment ("+this+")");for(var o=0,i=0;;o++){var s=i+n.child(o).nodeSize;if(s>=t)return s==t||e>0?r(o+1,s):r(o,i);i=s}},Vr.prototype.toString=function(){return"<"+this.toStringInner()+">"},Vr.prototype.toStringInner=function(){return this.content.join(", ")},Vr.prototype.toJSON=function(){return this.content.length?this.content.map(function(t){return t.toJSON()}):null},Vr.fromJSON=function(t,e){return e?new Vr(e.map(t.nodeFromJSON)):Vr.empty},Vr.fromArray=function(t){if(!t.length)return Vr.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 Vr(e||t,n)},Vr.from=function(t){return t?t instanceof Vr?t:Array.isArray(t)?this.fromArray(t):new Vr([t],t.nodeSize):Vr.empty},Object.defineProperties(Vr.prototype,jr);var Lr=Vr,Jr={index:0,offset:0};Vr.empty=new Vr([],0);var Wr={Fragment:Lr},qr={compareDeep:o},Kr=qr.compareDeep,Hr=function(t,e){this.type=t,this.attrs=e};Hr.prototype.addToSet=function(t){for(var e,n=this,r=!1,o=0;o<t.length;o++){var i=t[o];if(n.eq(i))return t;if(n.type.excludes(i.type))e||(e=t.slice(0,o));else{if(i.type.excludes(n.type))return t;!r&&i.type.rank>n.type.rank&&(e||(e=t.slice(0,o)),e.push(n),r=!0),e&&e.push(i)}}return e||(e=t.slice()),r||e.push(this),e},Hr.prototype.removeFromSet=function(t){for(var e=this,n=0;n<t.length;n++)if(e.eq(t[n]))return t.slice(0,n).concat(t.slice(n+1));return t},Hr.prototype.isInSet=function(t){for(var e=this,n=0;n<t.length;n++)if(e.eq(t[n]))return!0;return!1},Hr.prototype.eq=function(t){return this==t||this.type==t.type&&Kr(this.attrs,t.attrs)},Hr.prototype.toJSON=function(){var t=this,e={type:this.type.name};for(var n in t.attrs){e.attrs=t.attrs;break}return e},Hr.fromJSON=function(t,e){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)},Hr.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},Hr.setFrom=function(t){if(!t||0==t.length)return Hr.none;if(t instanceof Hr)return[t];var e=t.slice();return e.sort(function(t,e){return t.type.rank-e.type.rank}),e};var Ur=Hr;Hr.none=[];var Qr={Mark:Ur},Gr=Wr.Fragment,Xr=function(t){function e(e){t.call(this,e),this.message=e}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={name:{}};return n.name.get=function(){return"ReplaceError"},Object.defineProperties(e.prototype,n),e}(Error),Yr=Xr,Zr=!1,to=function(t,e,n){this.content=t,this.openStart=e,this.openEnd=n},eo={openLeft:{},openRight:{},size:{}};eo.openLeft.get=function(){return i(),this.openStart},eo.openRight.get=function(){return i(),this.openEnd},eo.size.get=function(){return this.content.size-this.openStart-this.openEnd},to.prototype.insertAt=function(t,e){var n=a(this.content,t+this.openStart,e,null);return n&&new to(n,this.openStart,this.openEnd)},to.prototype.removeBetween=function(t,e){return new to(s(this.content,t+this.openStart,e+this.openStart),this.openStart,this.openEnd)},to.prototype.eq=function(t){return this.content.eq(t.content)&&this.openStart==t.openStart&&this.openEnd==t.openEnd},to.prototype.toString=function(){return this.content+"("+this.openStart+","+this.openEnd+")"},to.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},to.fromJSON=function(t,e){return e?new to(Gr.fromJSON(t,e.content),e.openStart||0,e.openEnd||0):to.empty},to.maxOpen=function(t){for(var e=0,n=0,r=t.firstChild;r&&!r.isLeaf;r=r.firstChild)e++;for(var o=t.lastChild;o&&!o.isLeaf;o=o.lastChild)n++;return new to(t,e,n)},Object.defineProperties(to.prototype,eo);var no=to;to.empty=new to(Gr.empty,0,0);var ro={ReplaceError:Yr,Slice:no,replace:c},oo=Qr.Mark,io=function(t,e,n){this.pos=t,this.path=e,this.depth=e.length/3-1,this.parentOffset=n},so={parent:{},textOffset:{},nodeAfter:{},nodeBefore:{}};io.prototype.resolveDepth=function(t){return null==t?this.depth:t<0?this.depth+t:t},so.parent.get=function(){return this.node(this.depth)},io.prototype.node=function(t){return this.path[3*this.resolveDepth(t)]},io.prototype.index=function(t){return this.path[3*this.resolveDepth(t)+1]},io.prototype.indexAfter=function(t){return t=this.resolveDepth(t),this.index(t)+(t!=this.depth||this.textOffset?1:0)},io.prototype.start=function(t){return t=this.resolveDepth(t),0==t?0:this.path[3*t-1]+1},io.prototype.end=function(t){return t=this.resolveDepth(t),this.start(t)+this.node(t).content.size},io.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]},io.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},so.textOffset.get=function(){return this.pos-this.path[this.path.length-1]},so.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},so.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)},io.prototype.marks=function(t){var e=this.parent,n=this.index();if(0==e.content.size)return oo.none;if(this.textOffset)return e.child(n).marks;var r=e.maybeChild(n-1),o=e.maybeChild(n);if(t&&o||!r){var i=r;r=o,o=i}for(var s=r.marks,a=0;a<s.length;a++)!1!==s[a].type.spec.inclusive||o&&s[a].isInSet(o.marks)||(s=s[a--].removeFromSet(s));return s},io.prototype.sharedDepth=function(t){for(var e=this,n=this.depth;n>0;n--)if(e.start(n)<=t&&e.end(n)>=t)return n;return 0},io.prototype.blockRange=function(t,e){var n=this;if(void 0===t&&(t=this),t.pos<this.pos)return t.blockRange(this);for(var r=this.depth-(this.parent.inlineContent||this.pos==t.pos?1:0);r>=0;r--)if(t.pos<=n.end(r)&&(!e||e(n.node(r))))return new uo(n,t,r)},io.prototype.sameParent=function(t){return this.pos-this.parentOffset==t.pos-t.parentOffset},io.prototype.max=function(t){return t.pos>this.pos?t:this},io.prototype.min=function(t){return t.pos<this.pos?t:this},io.prototype.toString=function(){for(var t=this,e="",n=1;n<=this.depth;n++)e+=(e?"/":"")+t.node(n).type.name+"_"+t.index(n-1);return e+":"+this.parentOffset},io.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,p=o-c;if(n.push(i,a,r+c),!p)break;if((i=i.child(a)).isText)break;o=p-1,r+=c+1}return new io(e,n,o)},io.resolveCached=function(t,e){for(var n=0;n<co.length;n++){var r=co[n];if(r.pos==e&&r.node(0)==t)return r}var o=co[po]=io.resolve(t,e);return po=(po+1)%lo,o},Object.defineProperties(io.prototype,so);var ao=io,co=[],po=0,lo=6,uo=function(t,e,n){this.$from=t,this.$to=e,this.depth=n},ho={start:{},end:{},parent:{},startIndex:{},endIndex:{}};ho.start.get=function(){return this.$from.before(this.depth+1)},ho.end.get=function(){return this.$to.after(this.depth+1)},ho.parent.get=function(){return this.$from.node(this.depth)},ho.startIndex.get=function(){return this.$from.index(this.depth)},ho.endIndex.get=function(){return this.$to.indexAfter(this.depth)},Object.defineProperties(uo.prototype,ho);var fo={ResolvedPos:ao,NodeRange:uo},mo=Wr.Fragment,vo=Qr.Mark,go=ro.Slice,yo=ro.replace,wo=fo.ResolvedPos,bo=qr.compareDeep,ko=Object.create(null),So=function(t,e,n,r){this.type=t,this.attrs=e,this.content=n||mo.empty,this.marks=r||vo.none},xo={nodeSize:{},childCount:{},textContent:{},firstChild:{},lastChild:{},isBlock:{},isTextblock:{},inlineContent:{},isInline:{},isText:{},isLeaf:{},isAtom:{}};xo.nodeSize.get=function(){return this.isLeaf?1:2+this.content.size},xo.childCount.get=function(){return this.content.childCount},So.prototype.child=function(t){return this.content.child(t)},So.prototype.maybeChild=function(t){return this.content.maybeChild(t)},So.prototype.forEach=function(t){this.content.forEach(t)},So.prototype.nodesBetween=function(t,e,n,r){void 0===r&&(r=0),this.content.nodesBetween(t,e,n,r,this)},So.prototype.descendants=function(t){this.nodesBetween(0,this.content.size,t)},xo.textContent.get=function(){return this.textBetween(0,this.content.size,"")},So.prototype.textBetween=function(t,e,n,r){return this.content.textBetween(t,e,n,r)},xo.firstChild.get=function(){return this.content.firstChild},xo.lastChild.get=function(){return this.content.lastChild},So.prototype.eq=function(t){return this==t||this.sameMarkup(t)&&this.content.eq(t.content)},So.prototype.sameMarkup=function(t){return this.hasMarkup(t.type,t.attrs,t.marks)},So.prototype.hasMarkup=function(t,e,n){return this.type==t&&bo(this.attrs,e||t.defaultAttrs||ko)&&vo.sameSet(this.marks,n||vo.none)},So.prototype.copy=function(t){return void 0===t&&(t=null),t==this.content?this:new this.constructor(this.type,this.attrs,t,this.marks)},So.prototype.mark=function(t){return t==this.marks?this:new this.constructor(this.type,this.attrs,this.content,t)},So.prototype.cut=function(t,e){return 0==t&&e==this.content.size?this:this.copy(this.content.cut(t,e))},So.prototype.slice=function(t,e,n){if(void 0===e&&(e=this.content.size),void 0===n&&(n=!1),t==e)return go.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 go(a,r.depth-i,o.depth-i)},So.prototype.replace=function(t,e,n){return yo(this.resolve(t),this.resolve(e),n)},So.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}},So.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}},So.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}},So.prototype.resolve=function(t){return wo.resolveCached(this,t)},So.prototype.resolveNoCache=function(t){return wo.resolve(this,t)},So.prototype.rangeHasMark=function(t,e,n){var r=!1;return this.nodesBetween(t,e,function(t){return n.isInSet(t.marks)&&(r=!0),!r}),r},xo.isBlock.get=function(){return this.type.isBlock},xo.isTextblock.get=function(){return this.type.isTextblock},xo.inlineContent.get=function(){return this.type.inlineContent},xo.isInline.get=function(){return this.type.isInline},xo.isText.get=function(){return this.type.isText},xo.isLeaf.get=function(){return this.type.isLeaf},xo.isAtom.get=function(){return this.type.isAtom},So.prototype.toString=function(){var t=this.type.name;return this.content.size&&(t+="("+this.content.toStringInner()+")"),y(this.marks,t)},So.prototype.contentMatchAt=function(t){return this.type.contentExpr.getMatchAt(this.attrs,this.content,t)},So.prototype.canReplace=function(t,e,n,r,o){return this.type.contentExpr.checkReplace(this.attrs,this.content,t,e,n,r,o)},So.prototype.canReplaceWith=function(t,e,n,r,o){return this.type.contentExpr.checkReplaceWith(this.attrs,this.content,t,e,n,r,o||vo.none)},So.prototype.canAppend=function(t){return t.content.size?this.canReplace(this.childCount,this.childCount,t.content):this.type.compatibleContent(t.type)},So.prototype.defaultContentType=function(t){var e=this.contentMatchAt(t).nextElement;return e&&e.defaultType()},So.prototype.check=function(){if(!this.type.validContent(this.content,this.attrs))throw new RangeError("Invalid content for node "+this.type.name+": "+this.content.toString().slice(0,50));this.content.forEach(function(t){return t.check()})},So.prototype.toJSON=function(){var t=this,e={type:this.type.name};for(var n in t.attrs){e.attrs=t.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(function(t){return t.toJSON()})),e},So.fromJSON=function(t,e){var n=e.marks&&e.marks.map(t.markFromJSON);if("text"==e.type)return t.text(e.text,n);var r=t.nodeType(e.type);if(!r)throw new RangeError("There is no node type "+e.type+" in this schema");return r.create(e.attrs,mo.fromJSON(t,e.content),n)},Object.defineProperties(So.prototype,xo);var Mo={Node:So,TextNode:function(t){function e(e,n,r,o){if(t.call(this,e,n,null,o),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={textContent:{},nodeSize:{}};return e.prototype.toString=function(){return y(this.marks,JSON.stringify(this.text))},n.textContent.get=function(){return this.text},e.prototype.textBetween=function(t,e){return this.text.slice(t,e)},n.nodeSize.get=function(){return this.text.length},e.prototype.mark=function(t){return new e(this.type,this.attrs,this.text,t)},e.prototype.withText=function(t){return t==this.text?this:new e(this.type,this.attrs,t,this.marks)},e.prototype.cut=function(t,e){return void 0===t&&(t=0),void 0===e&&(e=this.text.length),0==t&&e==this.text.length?this:this.withText(this.text.slice(t,e))},e.prototype.eq=function(t){return this.sameMarkup(t)&&this.text==t.text},e.prototype.toJSON=function(){var e=t.prototype.toJSON.call(this);return e.text=this.text,e},Object.defineProperties(e.prototype,n),e}(So)};w.prototype={constructor:w,find:function(t){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===t)return e;return-1},get:function(t){var e=this.find(t);return-1==e?void 0:this.content[e+1]},update:function(t,e,n){var r=n&&n!=t?this.remove(n):this,o=r.find(t),i=r.content.slice();return-1==o?i.push(n||t,e):(i[o+1]=e,n&&(i[o]=n)),new w(i)},remove:function(t){var e=this.find(t);if(-1==e)return this;var n=this.content.slice();return n.splice(e,2),new w(n)},addToStart:function(t,e){return new w([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new w(n)},addBefore:function(t,e,n){var r=this.remove(e),o=r.content.slice(),i=r.find(t);return o.splice(-1==i?o.length:i,0,e,n),new w(o)},forEach:function(t){for(var e=0;e<this.content.length;e+=2)t(this.content[e],this.content[e+1])},prepend:function(t){return t=w.from(t),t.size?new w(t.content.concat(this.subtract(t).content)):this},append:function(t){return t=w.from(t),t.size?new w(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=w.from(t);for(var n=0;n<t.content.length;n+=2)e=e.remove(t.content[n]);return e},get size(){return this.content.length>>1}},w.from=function(t){if(t instanceof w)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new w(e)};var Oo=w,Co=Wr.Fragment,Do=Qr.Mark,To=function(t,e,n){this.nodeType=t,this.elements=e,this.inlineContent=n},Eo={isLeaf:{}};Eo.isLeaf.get=function(){return 0==this.elements.length},To.prototype.start=function(t){return new Ro(this,t,0,0)},To.prototype.atType=function(t,e,n,r){var o=this;void 0===r&&(r=Do.none);for(var i=0;i<this.elements.length;i++)if(o.elements[i].matchesType(e,n,r,t,o))return new Ro(o,t,i,0)},To.prototype.matches=function(t,e,n,r){return this.start(t).matchToEnd(e,n,r)},To.prototype.getMatchAt=function(t,e,n){return void 0===n&&(n=e.childCount),1==this.elements.length?new Ro(this,t,0,n):this.start(t).matchFragment(e,0,n)},To.prototype.checkReplace=function(t,e,n,r,o,i,s){var a=this;if(void 0===o&&(o=Co.empty),void 0===i&&(i=0),void 0===s&&(s=o.childCount),1==this.elements.length){var c=this.elements[0];if(!S(c,e.childCount-(r-n)+(s-i),t,this))return!1;for(var p=i;p<s;p++)if(!c.matches(o.child(p),t,a))return!1;return!0}var l=this.getMatchAt(t,e,n).matchFragment(o,i,s);return!!l&&l.matchToEnd(e,r)},To.prototype.checkReplaceWith=function(t,e,n,r,o,i,s){if(1==this.elements.length){var a=this.elements[0];return!!S(a,e.childCount-(r-n)+1,t,this)&&a.matchesType(o,i,s,t,this)}var c=this.getMatchAt(t,e,n).matchType(o,i,s);return!!c&&c.matchToEnd(e,r)},To.prototype.compatible=function(t){for(var e=this,n=0;n<this.elements.length;n++)for(var r=e.elements[n],o=0;o<t.elements.length;o++)if(t.elements[o].compatible(r))return!0;return!1},To.prototype.generateContent=function(t){return this.start(t).fillBefore(Co.empty,!0)},To.parse=function(t,e){for(var n=this,r=[],o=0,i=null;(o+=/^\s*/.exec(e.slice(o))[0].length)!=e.length;){var s=/^(?:(\w+)|\(\s*(\w+(?:\s*\|\s*\w+)*)\s*\))/.exec(e.slice(o));if(!s)throw new SyntaxError("Invalid content expression '"+e+"' at "+o);o+=s[0].length;var a=/^\[([^\]]+)\]/.exec(e.slice(o));a&&(o+=a[0].length);var c=/^<(?:(_)|\s*(\w+(?:\s+\w+)*)\s*)>/.exec(e.slice(o));c&&(o+=c[0].length);var p=/^(?:([+*?])|\{\s*(\d+|\.\w+)\s*(,\s*(\d+|\.\w+)?)?\s*\})/.exec(e.slice(o));p&&(o+=p[0].length);for(var l=x(t.schema,s[1]?[s[1]]:s[2].split(/\s*\|\s*/)),u=0;u<l.length;u++)if(null==i)i=l[u].isInline;else if(i!=l[u].isInline)throw new SyntaxError("Mixing inline and block content in a single node");var h=a?O(t,a[1]):null,f=!!c&&(!!c[1]||n.gatherMarks(t.schema,c[2].split(/\s+/))),d=M(t,p),m=d.min,v=d.max;if(0!=m&&(l[0].hasRequiredAttrs(h)||l[0].isText))throw new SyntaxError("Node type "+s[0]+" in type "+t.name+" is required, but has non-optional attributes");for(var g=new No(l,h,f,m,v),y=r.length-1;y>=0;y--){var w=r[y];if(w.min!=w.max&&w.overlaps(g))throw new SyntaxError("Possibly ambiguous overlapping adjacent content expressions in '"+e+"'");if(0!=w.min)break}r.push(g)}return new To(t,r,!!i)},To.gatherMarks=function(t,e){for(var n=[],r=0;r<e.length;r++){var o=e[r],i=t.marks[o],s=i;if(i)n.push(i);else for(var a in t.marks){var c=t.marks[a];("_"==o||c.spec.group&&c.spec.group.split(" ").indexOf(o)>-1)&&n.push(s=c)}if(!s)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return n},Object.defineProperties(To.prototype,Eo);var Ao=To,No=function(t,e,n,r,o){this.nodeTypes=t,this.attrs=e,this.marks=n,this.min=r,this.max=o};No.prototype.matchesType=function(t,e,n,r,o){var i=this;if(-1==this.nodeTypes.indexOf(t))return!1;if(this.attrs){if(!e)return!1;for(var s in i.attrs)if(e[s]!=k(i.attrs[s],r,o))return!1}if(!0===this.marks)return!0;if(!1===this.marks)return 0==n.length;for(var a=0;a<n.length;a++)if(-1==i.marks.indexOf(n[a].type))return!1;return!0},No.prototype.matches=function(t,e,n){return this.matchesType(t.type,t.attrs,t.marks,e,n)},No.prototype.compatible=function(t){for(var e=this,n=0;n<this.nodeTypes.length;n++)if(-1!=t.nodeTypes.indexOf(e.nodeTypes[n]))return!0;return!1},No.prototype.constrainedAttrs=function(t,e){var n=this;if(!this.attrs)return null;var r=Object.create(null);for(var o in n.attrs)r[o]=k(n.attrs[o],t,e);return r},No.prototype.createFiller=function(t,e){var n=this.nodeTypes[0],r=n.computeAttrs(this.constrainedAttrs(t,e));return n.create(r,n.contentExpr.generateContent(r))},No.prototype.defaultType=function(){var t=this.nodeTypes[0];if(!t.hasRequiredAttrs()&&!t.isText)return t},No.prototype.overlaps=function(t){return this.nodeTypes.some(function(e){return t.nodeTypes.indexOf(e)>-1})},No.prototype.allowsMark=function(t){return!0===this.marks||this.marks&&this.marks.indexOf(t)>-1};var Ro=function(t,e,n,r){this.expr=t,this.attrs=e,this.index=n,this.count=r},Io={element:{},nextElement:{}};Io.element.get=function(){return this.expr.elements[this.index]},Io.nextElement.get=function(){for(var t=this,e=this.index,n=this.count;e<this.expr.elements.length;e++){var r=t.expr.elements[e];if(t.resolveValue(r.max)>n)return r;n=0}},Ro.prototype.move=function(t,e){return new Ro(this.expr,this.attrs,t,e)},Ro.prototype.resolveValue=function(t){return t instanceof Po?k(t,this.attrs,this.expr):t},Ro.prototype.matchNode=function(t){return this.matchType(t.type,t.attrs,t.marks)},Ro.prototype.matchType=function(t,e,n){var r=this;void 0===n&&(n=Do.none);for(var o=this,i=o.index,s=o.count;i<this.expr.elements.length;i++,s=0){var a=r.expr.elements[i];if(s<r.resolveValue(a.max)&&a.matchesType(t,e,n,r.attrs,r.expr))return s++,r.move(i,s);if(s<r.resolveValue(a.min))return null}},Ro.prototype.matchFragment=function(t,e,n){var r=this;if(void 0===e&&(e=0),void 0===n&&(n=t.childCount),e==n)return this;for(var o=e,i=this.expr.elements.length,s=this,a=s.index,c=s.count;a<i;a++,c=0){for(var p=r.expr.elements[a],l=r.resolveValue(p.max);c<l&&o<n&&p.matches(t.child(o),r.attrs,r.expr);)if(c++,++o==n)return r.move(a,c);if(c<r.resolveValue(p.min))return null}return!1},Ro.prototype.matchToEnd=function(t,e,n){var r=this.matchFragment(t,e,n);return r&&r.validEnd()||!1},Ro.prototype.validEnd=function(){for(var t=this,e=this.index,n=this.count;e<this.expr.elements.length;e++,n=0)if(n<t.resolveValue(t.expr.elements[e].min))return!1;return!0},Ro.prototype.fillBefore=function(t,e,n){for(var r=this,o=[],i=this,s=n||0,a=this.expr.elements.length;;){var c=i.matchFragment(t,s);if(c&&(!e||c.validEnd()))return Co.from(o);if(!1===c)return null;var p=i.element;if(i.count<r.resolveValue(p.min))o.push(p.createFiller(r.attrs,r.expr)),i=i.move(i.index,i.count+1);else{if(!(i.index<a))return t.childCount>s?null:Co.from(o);i=i.move(i.index+1,0)}}},Ro.prototype.possibleContent=function(){for(var t=this,e=[],n=this.index,r=this.count;n<this.expr.elements.length;n++,r=0){var o=t.expr.elements[n],i=o.constrainedAttrs(t.attrs,t.expr);if(r<t.resolveValue(o.max))for(var s=0;s<o.nodeTypes.length;s++){var a=o.nodeTypes[s];a.hasRequiredAttrs(i)||a.isText||e.push({type:a,attrs:i})}if(t.resolveValue(o.min)>r)break}return e},Ro.prototype.allowsMark=function(t){return this.element.allowsMark(t)},Ro.prototype.findWrapping=function(t,e,n){for(var r=Object.create(null),o={match:this,via:null},i=[o];i.length;){var s=i.shift(),a=s.match;if(a.matchType(t,e,n)){for(var c=[],p=s;p!=o;p=p.via)c.push({type:p.match.expr.nodeType,attrs:p.match.attrs});return c.reverse()}for(var l=a.possibleContent(),u=0;u<l.length;u++){var h=l[u],f=h.type,d=h.attrs,m=f.computeAttrs(d);f.isLeaf||f.name in r||s!=o&&!a.matchType(f,m).validEnd()||(i.push({match:f.contentExpr.start(m),via:s}),r[f.name]=!0)}}},Ro.prototype.findWrappingFor=function(t){return this.findWrapping(t.type,t.attrs,t.marks)},Object.defineProperties(Ro.prototype,Io);var Po=function(t){this.attr=t},zo=2e9,Fo={ContentExpr:Ao,ContentMatch:Ro},Bo=Mo.Node,$o=Mo.TextNode,_o=Wr.Fragment,Vo=Qr.Mark,jo=Fo.ContentExpr,Lo=function(t,e,n){this.name=t,this.schema=e,this.spec=n,this.groups=n.group?n.group.split(" "):[],this.attrs=T(n.attrs),this.defaultAttrs=C(this.attrs),this.contentExpr=null,this.isBlock=!(n.inline||"text"==t),this.isText="text"==t},Jo={isInline:{},isTextblock:{},inlineContent:{},isLeaf:{},isAtom:{}};Jo.isInline.get=function(){return!this.isBlock},Jo.isTextblock.get=function(){return this.isBlock&&this.contentExpr.inlineContent},Jo.inlineContent.get=function(){return this.contentExpr.inlineContent},Jo.isLeaf.get=function(){return this.contentExpr.isLeaf},Jo.isAtom.get=function(){return this.isLeaf||this.spec.atom},Lo.prototype.hasRequiredAttrs=function(t){var e=this;for(var n in e.attrs)if(e.attrs[n].isRequired&&(!t||!(n in t)))return!0;return!1},Lo.prototype.compatibleContent=function(t){return this==t||this.contentExpr.compatible(t.contentExpr)},Lo.prototype.computeAttrs=function(t){return!t&&this.defaultAttrs?this.defaultAttrs:D(this.attrs,t)},Lo.prototype.create=function(t,e,n){if("string"==typeof e)throw new Error("Calling create with string");if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Bo(this,this.computeAttrs(t),_o.from(e),Vo.setFrom(n))},Lo.prototype.createChecked=function(t,e,n){if(t=this.computeAttrs(t),e=_o.from(e),!this.validContent(e,t))throw new RangeError("Invalid content for node "+this.name);return new Bo(this,t,e,Vo.setFrom(n))},Lo.prototype.createAndFill=function(t,e,n){if(t=this.computeAttrs(t),(e=_o.from(e)).size){var r=this.contentExpr.start(t).fillBefore(e);if(!r)return null;e=r.append(e)}var o=this.contentExpr.getMatchAt(t,e).fillBefore(_o.empty,!0);return o?new Bo(this,t,e.append(o),Vo.setFrom(n)):null},Lo.prototype.validContent=function(t,e){return this.contentExpr.matches(e,t)},Lo.compile=function(t,e){var n=Object.create(null);t.forEach(function(t,r){return n[t]=new Lo(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(Lo.prototype,Jo);var Wo=Lo,qo=function(t){this.default=t.default,this.compute=t.compute},Ko={isRequired:{}};Ko.isRequired.get=function(){return void 0===this.default&&!this.compute},Object.defineProperties(qo.prototype,Ko);var Ho=function(t,e,n,r){this.name=t,this.schema=n,this.spec=r,this.attrs=T(r.attrs),this.rank=e,this.excluded=null;var o=C(this.attrs);this.instance=o&&new Vo(this,o)};Ho.prototype.create=function(t){return!t&&this.instance?this.instance:new Vo(this,D(this.attrs,t))},Ho.compile=function(t,e){var n=Object.create(null),r=0;return t.forEach(function(t,o){return n[t]=new Ho(t,r++,e,o)}),n},Ho.prototype.removeFromSet=function(t){for(var e=this,n=0;n<t.length;n++)if(t[n].type==e)return t.slice(0,n).concat(t.slice(n+1));return t},Ho.prototype.isInSet=function(t){for(var e=this,n=0;n<t.length;n++)if(t[n].type==e)return t[n]},Ho.prototype.excludes=function(t){return this.excluded.indexOf(t)>-1};var Uo=Ho,Qo=function(t){var e=this;this.spec={};for(var n in t)e.spec[n]=t[n];this.spec.nodes=Oo.from(t.nodes),this.spec.marks=Oo.from(t.marks),this.nodes=Lo.compile(this.spec.nodes,this),this.marks=Ho.compile(this.spec.marks,this);for(var r in e.nodes){if(r in e.marks)throw new RangeError(r+" can not be both a node and a mark");var o=e.nodes[r];o.contentExpr=jo.parse(o,e.spec.nodes.get(r).content||"")}for(var i in e.marks){var s=e.marks[i],a=s.spec.excludes;s.excluded=null==a?[s]:""==a?[]:jo.gatherMarks(e,a.split(" "))}this.cached=Object.create(null),this.cached.wrappings=Object.create(null),this.nodeFromJSON=this.nodeFromJSON.bind(this),this.markFromJSON=this.markFromJSON.bind(this),this.topNodeType=this.nodes[this.spec.topNode||"doc"]};Qo.prototype.node=function(t,e,n,r){if("string"==typeof t)t=this.nodeType(t);else{if(!(t instanceof Lo))throw new RangeError("Invalid node type: "+t);if(t.schema!=this)throw new RangeError("Node type from different schema used ("+t.name+")")}return t.createChecked(e,n,r)},Qo.prototype.text=function(t,e){var n=this.nodes.text;return new $o(n,n.defaultAttrs,t,Vo.setFrom(e))},Qo.prototype.mark=function(t,e){return"string"==typeof t&&(t=this.marks[t]),t.create(e)},Qo.prototype.nodeFromJSON=function(t){return Bo.fromJSON(this,t)},Qo.prototype.markFromJSON=function(t){return Vo.fromJSON(this,t)},Qo.prototype.nodeType=function(t){var e=this.nodes[t];if(!e)throw new RangeError("Unknown node type: "+t);return e};var Go={NodeType:Wo,MarkType:Uo,Schema:Qo},Xo=Wr.Fragment,Yo=ro.Slice,Zo=Qr.Mark,ti=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)})};ti.prototype.parse=function(t,e){void 0===e&&(e={});var n=new ci(this,e,!1);return n.addAll(t,null,e.from,e.to),n.finish()},ti.prototype.parseSlice=function(t,e){void 0===e&&(e={});var n=new ci(this,e,!0);return n.addAll(t,null,e.from,e.to),Yo.maxOpen(n.finish())},ti.prototype.matchTag=function(t,e){for(var n=this,r=0;r<this.tags.length;r++){var o=n.tags[r];if(N(t,o.tag)&&(!o.context||e.matchesContext(o.context))){if(o.getAttrs){var i=o.getAttrs(t);if(!1===i)continue;o.attrs=i}return o}}},ti.prototype.matchStyle=function(t,e,n){for(var r=this,o=0;o<this.styles.length;o++){var i=r.styles[o];if(i.style==t&&(!i.context||n.matchesContext(i.context))){if(i.getAttrs){var s=i.getAttrs(e);if(!1===s)continue;i.attrs=s}return i}}},ti.schemaRules=function(t){function e(t){for(var e=null==t.priority?50:t.priority,r=0;r<n.length;r++){var o=n[r];if((null==o.priority?50:o.priority)<e)break}n.splice(r,0,t)}var n=[];for(var r in t.marks)!function(n){var r=t.marks[n].spec.parseDOM;r&&r.forEach(function(t){e(t=I(t)),t.mark=n})}(r);for(var o in t.nodes)!function(n){var r=t.nodes[o].spec.parseDOM;r&&r.forEach(function(t){e(t=I(t)),t.node=o})}();return n},ti.fromSchema=function(t){return t.cached.domParser||(t.cached.domParser=new ti(t,ti.schemaRules(t)))};var ei=ti,ni={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},ri={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},oi={ol:!0,ul:!0},ii=1,si=2,ai=function(t,e,n,r,o){this.type=t,this.attrs=e,this.solid=n,this.match=r||(4&o?null:t.contentExpr.start(e)),this.options=o,this.content=[]};ai.prototype.findWrapping=function(t,e){if(!this.match){if(!this.type)return[];var n=this.type.contentExpr.atType(this.attrs,t,e);if(!n){var r,o=this.type.contentExpr.start(this.attrs);if(r=o.findWrapping(t,e))return this.match=o,r}if(!n)return null;this.match=n}return this.match.findWrapping(t,e)},ai.prototype.finish=function(t){if(!(this.options&ii)){var e,n=this.content[this.content.length-1];n&&n.isText&&(e=/\s+$/.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=Xo.from(this.content);return!t&&this.match&&(r=r.append(this.match.fillBefore(Xo.empty,!0))),this.type?this.type.create(this.attrs,r):r};var ci=function(t,e,n){this.parser=t,this.options=e,this.isOpen=n;var r,o=e.topNode,i=E(e.preserveWhitespace)|(n?4:0);r=o?new ai(o.type,o.attrs,!0,o.contentMatchAt(e.topStart||0),i):n?new ai(null,null,!0,null,i):new ai(t.schema.topNodeType,null,!0,null,i),this.nodes=[r],this.marks=Zo.none,this.open=0,this.find=e.findPositions},pi={top:{},currentPos:{}};pi.top.get=function(){return this.nodes[this.open]},ci.prototype.addMark=function(t){var e=this.marks;return this.marks=t.addToSet(this.marks),e},ci.prototype.addDOM=function(t){if(3==t.nodeType)this.addTextNode(t);else if(1==t.nodeType){var e=t.getAttribute("style");e?this.addElementWithStyles(R(e),t):this.addElement(t)}},ci.prototype.addTextNode=function(t){var e=t.nodeValue,n=this.top;if(n.type&&n.type.inlineContent||/\S/.test(e)){if(n.options&ii)n.options&si||(e=e.replace(/\r?\n|\r/g," "));else if(e=e.replace(/\s+/g," "),/^\s/.test(e)&&this.open==this.nodes.length-1){var r=n.content[n.content.length-1];(!r||r.isText&&/\s$/.test(r.text))&&(e=e.slice(1))}e&&this.insertNode(this.parser.schema.text(e,this.marks)),this.findInText(t)}else this.findInside(t)},ci.prototype.addElement=function(t){var e=t.nodeName.toLowerCase();oi.hasOwnProperty(e)&&A(t);var n=this.options.ruleFromNode&&this.options.ruleFromNode(t)||this.parser.matchTag(t,this);if(n?n.ignore:ri.hasOwnProperty(e))this.findInside(t);else if(!n||n.skip){n&&n.skip.nodeType&&(t=n.skip);var r=ni.hasOwnProperty(e)&&this.top;this.addAll(t),r&&this.sync(r)}else this.addElementByRule(t,n)},ci.prototype.addElementWithStyles=function(t,e){for(var n=this,r=this.marks,o=!1,i=0;i<t.length;i+=2){var s=n.parser.matchStyle(t[i],t[i+1],n);if(s){if(s.ignore){o=!0;break}n.addMark(n.parser.schema.marks[s.mark].create(s.attrs))}}o||this.addElement(e),this.marks=r},ci.prototype.addElementByRule=function(t,e){var n,r,o,i,s,a=this;if(e.node?(o=this.parser.schema.nodes[e.node]).isLeaf?this.insertNode(o.create(e.attrs,null,this.marks)):n=this.enter(o,e.attrs,e.preserveWhitespace)&&this.top:(i=this.parser.schema.marks[e.mark],r=this.addMark(s=i.create(e.attrs))),o&&o.isLeaf)this.findInside(t);else if(e.getContent)this.findInside(t),e.getContent(t).forEach(function(t){return a.insertNode(s?t.mark(s.addToSet(t.marks)):t)});else{var c=e.contentElement;"string"==typeof c&&(c=t.querySelector(c)),c||(c=t),this.findAround(t,c,!0),this.addAll(c,n)}return n?(this.sync(n),this.open--):r&&(this.marks=r),!0},ci.prototype.addAll=function(t,e,n,r){for(var o=this,i=n||0,s=n?t.childNodes[n]:t.firstChild,a=null==r?null:t.childNodes[r];s!=a;s=s.nextSibling,++i)o.findAtPoint(t,i),o.addDOM(s),e&&ni.hasOwnProperty(s.nodeName.toLowerCase())&&o.sync(e);this.findAtPoint(t,i)},ci.prototype.findPlace=function(t,e){for(var n,r,o=this,i=this.open;i>=0;i--){var s=o.nodes[i],a=s.findWrapping(t,e);if(a&&(!n||n.length>a.length)&&(n=a,r=s,!a.length))break;if(s.solid)break}if(!n)return!1;this.sync(r);for(var c=0;c<n.length;c++)o.enterInner(n[c].type,n[c].attrs,!1);return!0},ci.prototype.insertNode=function(t){if(this.findPlace(t.type,t.attrs)){this.closeExtra();var e=this.top;if(e.match){var n=e.match.matchNode(t);n||(t=t.mark(t.marks.filter(function(t){return e.match.allowsMark(t.type)})),n=e.match.matchNode(t)),e.match=n}e.content.push(t)}},ci.prototype.enter=function(t,e,n){var r=this.findPlace(t,e);return r&&this.enterInner(t,e,!0,n),r},ci.prototype.enterInner=function(t,e,n,r){this.closeExtra();var o=this.top;o.match=o.match&&o.match.matchType(t,e);var i=null==r?-5&o.options:E(r);4&o.options&&0==o.content.length&&(i|=4),this.nodes.push(new ai(t,e,n,null,i)),this.open++},ci.prototype.closeExtra=function(t){var e=this,n=this.nodes.length-1;if(n>this.open){for(this.marks=Zo.none;n>this.open;n--)e.nodes[n-1].content.push(e.nodes[n].finish(t));this.nodes.length=this.open+1}},ci.prototype.finish=function(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(this.isOpen||this.options.topOpen)},ci.prototype.sync=function(t){for(var e=this,n=this.open;n>=0;n--)if(e.nodes[n]==t)return void(e.open=n)},pi.currentPos.get=function(){var t=this;this.closeExtra();for(var e=0,n=this.open;n>=0;n--){for(var r=t.nodes[n].content,o=r.length-1;o>=0;o--)e+=r[o].nodeSize;n&&e++}return e},ci.prototype.findAtPoint=function(t,e){var n=this;if(this.find)for(var r=0;r<this.find.length;r++)n.find[r].node==t&&n.find[r].offset==e&&(n.find[r].pos=n.currentPos)},ci.prototype.findInside=function(t){var e=this;if(this.find)for(var n=0;n<this.find.length;n++)null==e.find[n].pos&&1==t.nodeType&&t.contains(e.find[n].node)&&(e.find[n].pos=e.currentPos)},ci.prototype.findAround=function(t,e,n){var r=this;if(t!=e&&this.find)for(var o=0;o<this.find.length;o++)null==r.find[o].pos&&1==t.nodeType&&t.contains(r.find[o].node)&&e.compareDocumentPosition(r.find[o].node)&(n?2:4)&&(r.find[o].pos=r.currentPos)},ci.prototype.findInText=function(t){var e=this;if(this.find)for(var n=0;n<this.find.length;n++)e.find[n].node==t&&(e.find[n].pos=e.currentPos-(t.nodeValue.length-e.find[n].offset))},ci.prototype.matchesContext=function(t){var e=this,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 p=a>0||0==a&&o?e.nodes[a].type:r&&a>=i?r.node(a-i).type:null;if(!p||p.name!=c&&-1==p.groups.indexOf(c))return!1;a--}return!0};return s(n.length-1,this.open)},Object.defineProperties(ci.prototype,pi);var li={DOMParser:ei},ui=function(t,e){this.nodes=t||{},this.marks=e||{}};ui.prototype.serializeFragment=function(t,e,n){var r=this;void 0===e&&(e={}),n||(n=z(e).createDocumentFragment());var o=n,i=null;return t.forEach(function(t){if(i||t.marks.length){i||(i=[]);for(var n=0;n<Math.min(i.length,t.marks.length)&&t.marks[n].eq(i[n]);++n);for(;n<i.length;){var s=i.pop();r.marks[s.type.name]&&(o=o.parentNode)}for(;i.length<t.marks.length;){var a=t.marks[i.length];i.push(a);var c=r.serializeMark(a,t.isInline,e);c&&(o=o.appendChild(c))}}o.appendChild(r.serializeNode(t,e))}),n},ui.prototype.serializeNode=function(t,e){return void 0===e&&(e={}),this.renderStructure(this.nodes[t.type.name](t),t,e)},ui.prototype.serializeNodeAndMarks=function(t,e){var n=this;void 0===e&&(e={});for(var r=this.serializeNode(t,e),o=t.marks.length-1;o>=0;o--){var i=n.serializeMark(t.marks[o],t.isInline,e);i&&(i.appendChild(r),r=i)}return r},ui.prototype.serializeMark=function(t,e,n){void 0===n&&(n={});var r=this.marks[t.type.name];return r&&this.renderStructure(r(t,e),null,n)},ui.renderSpec=function(t,e){if("string"==typeof e)return{dom:t.createTextNode(e)};if(null!=e.nodeType)return{dom:e};var n=t.createElement(e[0]),r=null,o=e[1],i=1;if(o&&"object"==typeof o&&null==o.nodeType&&!Array.isArray(o)){i=2;for(var s in o)"style"==s?n.style.cssText=o[s]:null!=o[s]&&n.setAttribute(s,o[s])}for(var a=i;a<e.length;a++){var c=e[a];if(0===c){if(a<e.length-1||a>i)throw new RangeError("Content hole must be the only child of its parent node");return{dom:n,contentDOM:n}}var p=ui.renderSpec(t,c),l=p.dom,u=p.contentDOM;if(n.appendChild(l),u){if(r)throw new RangeError("Multiple content holes");r=u}}return{dom:n,contentDOM:r}},ui.prototype.renderStructure=function(t,e,n){var r=ui.renderSpec(z(n),t),o=r.dom,i=r.contentDOM;if(i){if(!e||e.isLeaf)throw new RangeError("Content hole not allowed in a mark or leaf node spec");n.onContent?n.onContent(e,i,n):this.serializeFragment(e.content,n,i)}return o},ui.fromSchema=function(t){return t.cached.domSerializer||(t.cached.domSerializer=new ui(this.nodesFromSchema(t),this.marksFromSchema(t)))},ui.nodesFromSchema=function(t){var e=P(t.nodes);return e.text||(e.text=function(t){return t.text}),e},ui.marksFromSchema=function(t){return P(t.marks)};var hi={DOMSerializer:ui},fi=t(function(t,e){e.Node=Mo.Node;var n;n=fo,e.ResolvedPos=n.ResolvedPos,e.NodeRange=n.NodeRange,e.Fragment=Wr.Fragment;var r;r=ro,e.Slice=r.Slice,e.ReplaceError=r.ReplaceError,e.Mark=Qr.Mark;var o;o=Go,e.Schema=o.Schema,e.NodeType=o.NodeType,e.MarkType=o.MarkType;var i;i=Fo,e.ContentMatch=i.ContentMatch,e.DOMParser=li.DOMParser,e.DOMSerializer=hi.DOMSerializer}),di=fi.Schema,mi=fi.DOMParser,vi=fi.DOMSerializer,gi=fi.Slice,yi=fi.Fragment,wi=Object.create(null),bi=function(t,e,n){this.ranges=n||[new xi(t.min(e),t.max(e))],this.$anchor=t,this.$head=e},ki={anchor:{},head:{},from:{},to:{},$from:{},$to:{},empty:{}};ki.anchor.get=function(){return this.$anchor.pos},ki.head.get=function(){return this.$head.pos},ki.from.get=function(){return this.$from.pos},ki.to.get=function(){return this.$to.pos},ki.$from.get=function(){return this.ranges[0].$from},ki.$to.get=function(){return this.ranges[0].$to},ki.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},bi.prototype.content=function(){return this.$from.node(0).slice(this.from,this.to,!0)},bi.prototype.replace=function(t,e){void 0===e&&(e=gi.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],p=c.$from,l=c.$to,u=t.mapping.slice(i);t.replaceRange(u.map(p.pos),u.map(l.pos),a?gi.empty:e),0==a&&B(t,i,(n?n.isInline:r&&r.isTextblock)?-1:1)}},bi.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),p=c.map(s.pos),l=c.map(a.pos);o?t.deleteRange(p,l):(t.replaceRangeWith(p,l,e),B(t,n,e.isInline?-1:1))}},bi.findFrom=function(t,e,n){var r=t.parent.inlineContent?new Oi(t):F(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?F(t.node(0),t.node(o),t.before(o+1),t.index(o),e,n):F(t.node(0),t.node(o),t.after(o+1),t.index(o)+1,e,n);if(i)return i}},bi.near=function(t,e){return void 0===e&&(e=1),this.findFrom(t,e)||this.findFrom(t,-e)||new Ni(t.node(0))},bi.atStart=function(t){return F(t,t,0,0,1)||new Ni(t)},bi.atEnd=function(t){return F(t,t,t.content.size,t.childCount,-1)||new Ni(t)},bi.fromJSON=function(t,e){var n=wi[e.type];return n?n.fromJSON(t,e):this.backwardsCompatFromJSON(t,e)},bi.backwardsCompatFromJSON=function(t,e){if(null!=e.anchor)return Oi.fromJSON(t,e);if(null!=e.node)return Ti.fromJSON(t,{anchor:e.node,head:e.after});throw new RangeError("Unrecognized JSON data "+JSON.stringify(e))},bi.jsonID=function(t,e){if(t in wi)throw new RangeError("Duplicate use of selection JSON ID "+t);return wi[t]=e,e.prototype.jsonID=t,e},bi.prototype.getBookmark=function(){return Oi.between(this.anchor,this.head).getBookmark()},Object.defineProperties(bi.prototype,ki);var Si=bi;bi.prototype.visible=!0;var xi=function(t,e){this.$from=t,this.$to=e},Mi=xi,Oi=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:{}};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){void 0===n&&(n=gi.empty),t.prototype.replace.call(this,e,n),n==gi.empty&&this.$from.parentOffset<this.$from.parent.content.size&&e.ensureMarks(this.$from.marks(!0))},e.prototype.eq=function(t){return t instanceof e&&t.anchor==this.anchor&&t.head==this.head},e.prototype.getBookmark=function(){return new Di(this.anchor,this.head)},e.prototype.toJSON=function(){return{type:"text",anchor:this.anchor,head:this.head}},e.fromJSON=function(t,n){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=r:(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}(bi),Ci=Oi;bi.jsonID("text",Oi);var Di=function(t,e){this.anchor=t,this.head=e};Di.prototype.map=function(t){return new Di(t.map(this.anchor),t.map(this.head))},Di.prototype.resolve=function(t){return Oi.between(t.resolve(this.anchor),t.resolve(this.head))};var Ti=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 gi(yi.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 Ai(this.anchor)},e.fromJSON=function(t,n){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}(bi),Ei=Ti;Ti.prototype.visible=!1,bi.jsonID("node",Ti);var Ai=function(t){this.anchor=t};Ai.prototype.map=function(t){var e=t.mapResult(this.anchor),n=e.deleted,r=e.pos;return n?new Di(r,r):new Ai(r)},Ai.prototype.resolve=function(t){var e=t.resolve(this.anchor),n=e.nodeAfter;return n&&Ti.isSelectable(n)?new Ti(e):bi.near(e)};var Ni=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.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 Ii},e}(bi),Ri=Ni;bi.jsonID("all",Ni);var Ii={map:function(){return this},resolve:function(t){return new Ni(t)}},Pi={Selection:Si,SelectionRange:Mi,TextSelection:Ci,NodeSelection:Ei,AllSelection:Ri},zi=65535,Fi=Math.pow(2,16),Bi=function(t,e,n){void 0===e&&(e=!1),void 0===n&&(n=null),this.pos=t,this.deleted=e,this.recover=n},$i=Bi,_i=function(t,e){void 0===e&&(e=!1),this.ranges=t,this.inverted=e};_i.prototype.recover=function(t){var e=this,n=0,r=_(t);if(!this.inverted)for(var o=0;o<r;o++)n+=e.ranges[3*o+2]-e.ranges[3*o+1];return this.ranges[3*r]+n+V(t)},_i.prototype.mapResult=function(t,e){return this._map(t,e,!1)},_i.prototype.map=function(t,e){return this._map(t,e,!0)},_i.prototype._map=function(t,e,n){for(var r=this,o=0,i=this.inverted?2:1,s=this.inverted?1:2,a=0;a<this.ranges.length;a+=3){var c=r.ranges[a]-(r.inverted?o:0);if(c>t)break;var p=r.ranges[a+i],l=r.ranges[a+s],u=c+p;if(t<=u){var h=c+o+((p?t==c?-1:t==u?1:e:e)<0?0:l);if(n)return h;var f=$(a/3,t-c);return new Bi(h,e<0?t!=c:t!=u,f)}o+=l-p}return n?t+o:new Bi(t+o)},_i.prototype.touches=function(t,e){for(var n=this,r=0,o=_(e),i=this.inverted?2:1,s=this.inverted?1:2,a=0;a<this.ranges.length;a+=3){var c=n.ranges[a]-(n.inverted?r:0);if(c>t)break;var p=n.ranges[a+i];if(t<=c+p&&a==3*o)return!0;r+=n.ranges[a+s]-p}return!1},_i.prototype.forEach=function(t){for(var e=this,n=this.inverted?2:1,r=this.inverted?1:2,o=0,i=0;o<this.ranges.length;o+=3){var s=e.ranges[o],a=s-(e.inverted?i:0),c=s+(e.inverted?0:i),p=e.ranges[o+n],l=e.ranges[o+r];t(a,a+p,c,c+l),i+=l-p}},_i.prototype.invert=function(){return new _i(this.ranges,!this.inverted)},_i.prototype.toString=function(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)};var Vi=_i;_i.empty=new _i([]);var ji=function(t,e,n,r){this.maps=t||[],this.from=n||0,this.to=null==r?this.maps.length:r,this.mirror=e};ji.prototype.slice=function(t,e){return void 0===t&&(t=0),void 0===e&&(e=this.maps.length),new ji(this.maps,this.mirror,t,e)},ji.prototype.copy=function(){return new ji(this.maps.slice(),this.mirror&&this.mirror.slice(),this.from,this.to)},ji.prototype.getMirror=function(t){var e=this;if(this.mirror)for(var n=0;n<this.mirror.length;n++)if(e.mirror[n]==t)return e.mirror[n+(n%2?-1:1)]},ji.prototype.setMirror=function(t,e){this.mirror||(this.mirror=[]),this.mirror.push(t,e)},ji.prototype.appendMap=function(t,e){this.to=this.maps.push(t),null!=e&&this.setMirror(this.maps.length-1,e)},ji.prototype.appendMapping=function(t){for(var e=this,n=0,r=this.maps.length;n<t.maps.length;n++){var o=t.getMirror(n);e.appendMap(t.maps[n],null!=o&&o<n?r+o:null)}},ji.prototype.appendMappingInverted=function(t){for(var e=this,n=t.maps.length-1,r=this.maps.length+t.maps.length;n>=0;n--){var o=t.getMirror(n);e.appendMap(t.maps[n].invert(),null!=o&&o>n?r-o-1:null)}},ji.prototype.invert=function(){var t=new ji;return t.appendMappingInverted(this),t},ji.prototype.map=function(t,e){var n=this;if(this.mirror)return this._map(t,e,!0);for(var r=this.from;r<this.to;r++)t=n.maps[r].map(t,e);return t},ji.prototype.mapResult=function(t,e){return this._map(t,e,!1)},ji.prototype._map=function(t,e,n){for(var r=this,o=!1,i=null,s=this.from;s<this.to;s++){var a=r.maps[s],c=i&&i[s];if(null!=c&&a.touches(t,c))t=a.recover(c);else{var p=a.mapResult(t,e);if(null!=p.recover){var l=r.getMirror(s);if(null!=l&&l>s&&l<r.to){if(p.deleted){s=l,t=r.maps[l].recover(p.recover);continue}(i||(i=Object.create(null)))[l]=p.recover}}p.deleted&&(o=!0),t=p.pos}}return n?t:new Bi(t,o)};var Li={MapResult:$i,StepMap:Vi,Mapping:ji},Ji=Li.Mapping,Wi=function(t){function e(e){t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={name:{}};return n.name.get=function(){return"TransformError"},Object.defineProperties(e.prototype,n),e}(Error),qi=Wi,Ki=function(t){this.doc=t,this.steps=[],this.docs=[],this.mapping=new Ji},Hi={before:{},docChanged:{}};Hi.before.get=function(){return this.docs.length?this.docs[0]:this.doc},Ki.prototype.step=function(t){var e=this.maybeStep(t);if(e.failed)throw new Wi(e.failed);return this},Ki.prototype.maybeStep=function(t){var e=t.apply(this.doc);return e.failed||this.addStep(t,e.doc),e},Hi.docChanged.get=function(){return this.steps.length>0},Ki.prototype.addStep=function(t,e){this.docs.push(this.doc),this.steps.push(t),this.mapping.appendMap(t.getMap()),this.doc=e},Object.defineProperties(Ki.prototype,Hi);var Ui={TransformError:qi,Transform:Ki},Qi=fi.ReplaceError,Gi=Li.StepMap,Xi=Object.create(null),Yi=function(){};Yi.prototype.apply=function(t){return j()},Yi.prototype.getMap=function(){return Gi.empty},Yi.prototype.invert=function(t){return j()},Yi.prototype.map=function(t){return j()},Yi.prototype.merge=function(t){return null},Yi.prototype.offset=function(t){return j()},Yi.prototype.toJSON=function(){var t=this,e={stepType:this.jsonID};for(var n in t)if(t.hasOwnProperty(n)){var r=t[n];e[n]=r&&r.toJSON?r.toJSON():r}return e},Yi.fromJSON=function(t,e){return Xi[e.stepType].fromJSON(t,e)},Yi.jsonID=function(t,e){if(t in Xi)throw new RangeError("Duplicate use of step JSON ID "+t);return Xi[t]=e,e.prototype.jsonID=t,e};var Zi=Yi,ts=function(t,e){this.doc=t,this.failed=e};ts.ok=function(t){return new ts(t,null)},ts.fail=function(t){return new ts(null,t)},ts.fromReplace=function(t,e,n,r){try{return ts.ok(t.replace(e,n,r))}catch(t){if(t instanceof Qi)return ts.fail(t.message);throw t}};var es={Step:Zi,StepResult:ts},ns=fi.Slice,rs=es.Step,is=es.StepResult,ss=Li.StepMap,as=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&&L(t,this.from,this.to)?is.fail("Structure replace would overwrite content"):is.fromReplace(t,this.from,this.to,this.slice)},e.prototype.getMap=function(){return new ss([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?ns.empty:new ns(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?ns.empty:new ns(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.prototype.offset=function(t){return new e(this.from+t,this.to+t,this.slice,this.structure)},e.fromJSON=function(t,n){return new e(n.from,n.to,ns.fromJSON(t,n.slice),!!n.structure)},e}(rs),cs=as;rs.jsonID("replace",as);var ps=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&&(L(t,this.from,this.gapFrom)||L(t,this.gapTo,this.to)))return is.fail("Structure gap-replace would overwrite content");var e=t.slice(this.gapFrom,this.gapTo);if(e.openStart||e.openEnd)return is.fail("Gap is not a flat range");var n=this.slice.insertAt(this.insert,e.content);return n?is.fromReplace(t,this.from,this.to,n):is.fail("Content does not fit in gap")},e.prototype.getMap=function(){return new ss([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.toJSON=function(){var t={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,slice:this.slice.toJSON()};return this.structure&&(t.structure=!0),!0},e.prototype.offset=function(t){return new e(this.from+t,this.to+t,this.gapFrom+t,this.gapTo+t,this.slice,this.insert,this.structure)},e.fromJSON=function(t,n){return new e(n.from,n.to,n.gapFrom,n.gapTo,ns.fromJSON(t,n.slice),n.insert,!!n.structure)},e}(rs),ls=ps;rs.jsonID("replaceAround",ps);var us={ReplaceStep:cs,ReplaceAroundStep:ls},hs=fi.Slice,fs=fi.Fragment,ds=Ui.Transform,ms=us.ReplaceStep,vs=us.ReplaceAroundStep,gs=W;ds.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,p=fs.empty,l=0,u=o,h=!1;u>e;u--)h||n.index(u)>0?(h=!0,p=fs.from(n.node(u).copy(p)),l++):a--;for(var f=fs.empty,d=0,m=o,v=!1;m>e;m--)v||r.after(m+1)<r.end(m)?(v=!0,f=fs.from(r.node(m).copy(f)),d++):c++;return this.step(new vs(a,c,i,s,new hs(p.append(f),l,d),p.size-l,!0))};var ys=q;ds.prototype.wrap=function(t,e){for(var n=fs.empty,r=e.length-1;r>=0;r--)n=fs.from(e[r].type.create(e[r].attrs,n));var o=t.start,i=t.end;return this.step(new vs(o,i,o,i,new hs(n,0,0),e.length,!0))},ds.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)){o.clearNonMatching(o.mapping.slice(i).map(e,1),n.contentExpr.start(r));var s=o.mapping.slice(i),a=s.map(e,1),c=s.map(e+t.nodeSize,1);return o.step(new vs(a,c,a+1,c-1,new hs(fs.from(n.create(r)),0,0),1,!0)),!1}}),this},ds.prototype.setNodeType=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,n))throw new RangeError("Invalid content for node type "+e.name);return this.step(new vs(t,t+o.nodeSize,t+1,t+o.nodeSize-1,new hs(fs.from(i),0,0),1,!0))};var ws=U;ds.prototype.split=function(t,e,n){void 0===e&&(e=1);for(var r=this.doc.resolve(t),o=fs.empty,i=fs.empty,s=r.depth,a=r.depth-e,c=e-1;s>a;s--,c--){o=fs.from(r.node(s).copy(o));var p=n&&n[c];i=fs.from(p?p.type.create(p.attrs,i):r.node(s).copy(i))}return this.step(new ms(t,t,new hs(o.append(i),e,e,!0)))};var bs=Q,ks=X;ds.prototype.join=function(t,e){void 0===e&&(e=1);var n=new ms(t-e,t+e,hs.empty,!0);return this.step(n)};var Ss={liftTarget:gs,findWrapping:ys,canSplit:ws,canJoin:bs,joinPoint:ks,insertPoint:Y},xs=fi.Fragment,Ms=fi.Slice,Os=es.Step,Cs=es.StepResult,Ds=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 Ms(Z(n.content,function(t,n,r){return n.contentMatchAt(r+1).allowsMark(e.mark.type)?t.mark(e.mark.addToSet(t.marks)):t},o),n.openStart,n.openEnd);return Cs.fromReplace(t,this.from,this.to,i)},e.prototype.invert=function(){return new Es(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.offset=function(t){return new e(this.from+t,this.to+t,this.mark)},e.fromJSON=function(t,n){return new e(n.from,n.to,t.markFromJSON(n.mark))},e}(Os),Ts=Ds;Os.jsonID("addMark",Ds);var Es=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 Ms(Z(n.content,function(t){return t.mark(e.mark.removeFromSet(t.marks))}),n.openStart,n.openEnd);return Cs.fromReplace(t,this.from,this.to,r)},e.prototype.invert=function(){return new Ds(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.offset=function(t){return new e(this.from+t,this.to+t,this.mark)},e.fromJSON=function(t,n){return new e(n.from,n.to,t.markFromJSON(n.mark))},e}(Os),As=Es;Os.jsonID("removeMark",Es);var Ns={AddMarkStep:Ts,RemoveMarkStep:As},Rs=fi.MarkType,Is=fi.Slice,Ps=fi.Fragment,zs=Ui.Transform,Fs=Ns.AddMarkStep,Bs=Ns.RemoveMarkStep,$s=us.ReplaceStep;zs.prototype.addMark=function(t,e,n){var r=this,o=[],i=[],s=null,a=null;return this.doc.nodesBetween(t,e,function(r,c,p,l){if(r.isInline){var u=r.marks;if(!n.isInSet(u)&&p.contentMatchAt(l+1).allowsMark(n.type)){for(var h=Math.max(c,t),f=Math.min(c+r.nodeSize,e),d=n.addToSet(u),m=0;m<u.length;m++)u[m].isInSet(d)||(s&&s.to==h&&s.mark.eq(u[m])?s.to=f:o.push(s=new Bs(h,f,u[m])));a&&a.to==h?a.to=f:i.push(a=new Fs(h,f,n))}}}),o.forEach(function(t){return r.step(t)}),i.forEach(function(t){return r.step(t)}),this},zs.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 Rs){var c=n.isInSet(r.marks);c&&(a=[c])}else n?n.isInSet(r.marks)&&(a=[n]):a=r.marks;if(a&&a.length)for(var p=Math.min(s+r.nodeSize,e),l=0;l<a.length;l++){for(var u=a[l],h=void 0,f=0;f<o.length;f++){var d=o[f];d.step==i-1&&u.eq(o[f].style)&&(h=d)}h?(h.to=p,h.step=i):o.push({style:u,from:Math.max(s,t),to:p,step:i})}}}),o.forEach(function(t){return r.step(new Bs(t.from,t.to,t.style))}),this},zs.prototype.clearMarkup=function(t,e){var n=this,r=[];this.doc.nodesBetween(t,e,function(o,i){if(o.isInline){if(!o.type.isText)return void r.push(new $s(i,i+o.nodeSize,Is.empty));for(var s=0;s<o.marks.length;s++)n.step(new Bs(Math.max(i,t),Math.min(i+o.nodeSize,e),o.marks[s]))}});for(var o=r.length-1;o>=0;o--)n.step(r[o]);return this},zs.prototype.clearNonMatching=function(t,e){for(var n=this,r=this.doc.nodeAt(t),o=[],i=t+1,s=0;s<r.childCount;s++){var a=r.child(s),c=i+a.nodeSize,p=e.matchType(a.type,a.attrs);if(p){e=p;for(var l=0;l<a.marks.length;l++)e.allowsMark(a.marks[l])||n.step(new Bs(i,c,a.marks[l]))}else o.push(new $s(i,c,Is.empty));i=c}if(!e.validEnd()){var u=e.fillBefore(Ps.empty,!0);this.replace(i,i,new Is(u,0,0))}for(var h=o.length-1;h>=0;h--)n.step(o[h]);return this};var _s=fi.Fragment,Vs=fi.Slice,js=us.ReplaceStep,Ls=us.ReplaceAroundStep,Js=Ui.Transform,Ws=Ss.insertPoint;Js.prototype.replaceRange=function(t,e,n){var r=this;if(!n.size)return this.deleteRange(t,e);var o=this.doc.resolve(t),i=this.doc.resolve(e);if(lt(o,i,n))return this.step(new js(t,e,n));var s=et(o,this.doc.resolve(e)),a=0;0==s[s.length-1]&&s.pop(),s.unshift(o.depth+1);for(var c=o.depth;c>0&&!o.node(c).type.spec.defining;c--){var p=s.indexOf(c,1);p>-1&&(a=p)}for(var l=[],u=n.openStart,h=n.content,f=0;;f++){var d=h.firstChild;if(l.push(d),f==n.openStart)break;h=d.content}u>0&&l[u-1].type.spec.defining?u-=1:u>=2&&l[u-1].isTextblock&&l[u-2].type.spec.defining&&(u-=2);for(var m=n.openStart;m>=0;m--){var v=(m+u+1)%(n.openStart+1),g=l[v];if(g)for(var y=0;y<s.length;y++){var w=s[(y+a)%s.length],b=o.node(w-1),k=o.index(w-1);if(b.canReplaceWith(k,k,g.type,g.attrs,g.marks))return r.replace(o.before(w),w>o.depth?e:i.after(w),new Vs(tt(n.content,0,n.openStart,v),v,n.openEnd))}}return this.replace(t,e,n)},Js.prototype.replaceRangeWith=function(t,e,n){if(!n.isInline&&t==e&&this.doc.resolve(t).parent.content.size){var r=Ws(this.doc,t,n.type,n.attrs);null!=r&&(t=e=r)}return this.replaceRange(t,e,new Vs(_s.from(n),0,0))},Js.prototype.deleteRange=function(t,e){for(var n=this.doc.resolve(t),r=this.doc.resolve(e),o=et(n,r),i=0;i<o.length;i++){var s=o[i],a=i==o.length-1;if(a&&0==s||n.node(s).contentMatchAt(0).validEnd()){t=n.start(s),e=r.end(s);break}if(s>0&&(a||n.node(s-1).canReplace(n.index(s-1),r.indexAfter(s-1)))){t=n.before(s),e=r.after(s);break}}return this.delete(t,e)},Js.prototype.delete=function(t,e){return this.replace(t,e,Vs.empty)};var qs=nt;Js.prototype.replace=function(t,e,n){void 0===e&&(e=t),void 0===n&&(n=Vs.empty);var r=nt(this.doc,t,e,n);return r&&this.step(r),this},Js.prototype.replaceWith=function(t,e,n){return this.replace(t,e,new Vs(_s.from(n),0,0))},Js.prototype.insert=function(t,e){return this.replaceWith(t,t,e)};var Ks={replaceStep:qs},Hs=t(function(t,e){var n;n=Ui,e.Transform=n.Transform,e.TransformError=n.TransformError;var r;r=es,e.Step=r.Step,e.StepResult=r.StepResult;var o;o=Ss,e.joinPoint=o.joinPoint,e.canJoin=o.canJoin,e.canSplit=o.canSplit,e.insertPoint=o.insertPoint,e.liftTarget=o.liftTarget,e.findWrapping=o.findWrapping;var i;i=Li,e.StepMap=i.StepMap,e.MapResult=i.MapResult,e.Mapping=i.Mapping;var s;s=Ns,e.AddMarkStep=s.AddMarkStep,e.RemoveMarkStep=s.RemoveMarkStep;var a;a=us,e.ReplaceStep=a.ReplaceStep,e.ReplaceAroundStep=a.ReplaceAroundStep;var c;c=Ks,e.replaceStep=c.replaceStep}),Us=Hs.Transform,Qs=fi.Mark,Gs={Transaction: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:{},selectionSet:{},storedMarksSet:{},isGeneric:{},scrolledIntoView:{}};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){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 Qs.sameSet(this.storedMarks||this.selection.$from.marks(),t)||this.setStoredMarks(t),this},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.$from.marks(n.to>n.from))),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=r.text(t,this.storedMarks||this.doc.resolve(e).marks(n>e));return this.replaceRangeWith(e,n,o)},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(){var t=this;for(var e in t.meta)return!1;return!0},e.prototype.scrollIntoView=function(){return this.updated|=4,this},n.scrolledIntoView.get=function(){return(4&this.updated)>0},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()))},Object.defineProperties(e.prototype,n),e}(Us)},Xs=fi.Node,Ys=Pi.Selection,Zs=Gs.Transaction,ta=function(t,e,n){this.name=t,this.init=wt(e.init,n),this.apply=wt(e.apply,n)},ea=[new ta("doc",{init:function(t){return t.doc||t.schema.topNodeType.createAndFill()},apply:function(t){return t.doc}}),new ta("selection",{init:function(t,e){return t.selection||Ys.atStart(e.doc)},apply:function(t){return t.selection}}),new ta("storedMarks",{init:function(){return null},apply:function(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new ta("scrollToSelection",{init:function(){return 0},apply:function(t,e){return t.scrolledIntoView?e+1:e}})],na=function(t,e){var n=this;this.schema=t,this.fields=ea.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 ta(t.key,t.spec.state,t))})},ra=function(t){this.config=t},oa={schema:{},plugins:{},tr:{}};oa.schema.get=function(){return this.config.schema},oa.plugins.get=function(){return this.config.plugins},ra.prototype.apply=function(t){return this.applyTransaction(t).state},ra.prototype.filterTransaction=function(t,e){var n=this;void 0===e&&(e=-1);for(var r=0;r<this.config.plugins.length;r++)if(r!=e){var o=n.config.plugins[r];if(o.spec.filterTransaction&&!o.spec.filterTransaction.call(o,t,n))return!1}return!0},ra.prototype.applyTransaction=function(t){var e=this;if(!this.filterTransaction(t))return{state:this,transactions:[]};for(var n=[t],r=this.applyInner(t),o=null;;){for(var i=!1,s=0;s<this.config.plugins.length;s++){var a=e.config.plugins[s];if(a.spec.appendTransaction){var c=o?o[s].n:0,p=o?o[s].state:e,l=c<n.length&&a.spec.appendTransaction.call(a,c?n.slice(c):n,p,r);if(l&&r.filterTransaction(l,s)){if(l.setMeta("appendedTransaction",l),!o){o=[];for(var u=0;u<this.config.plugins.length;u++)o.push(u<s?{state:r,n:n.length}:{state:e,n:0})}n.push(l),r=r.applyInner(l),i=!0}o&&(o[s]={state:r,n:n.length})}}if(!i)return{state:r,transactions:n}}},ra.prototype.applyInner=function(t){var e=this;if(!t.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");for(var n=new ra(this.config),r=this.config.fields,o=0;o<r.length;o++){var i=r[o];n[i.name]=i.apply(t,e[i.name],e,n)}for(var s=0;s<ia.length;s++)ia[s](e,t,n);return n},oa.tr.get=function(){return new Zs(this)},ra.create=function(t){for(var e=new na(t.schema||t.doc.type.schema,t.plugins),n=new ra(e),r=0;r<e.fields.length;r++)n[e.fields[r].name]=e.fields[r].init(t,n);return n},ra.prototype.reconfigure=function(t){for(var e=this,n=new na(t.schema||this.schema,t.plugins),r=n.fields,o=new ra(n),i=0;i<r.length;i++){var s=r[i].name;o[s]=e.hasOwnProperty(s)?e[s]:r[i].init(t,o)}return o},ra.prototype.toJSON=function(t){var e=this,n={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(t)for(var r in t){if("doc"==r||"selection"==r)throw new RangeError("The JSON fields `doc` and `selection` are reserved");var o=t[r],i=o.spec.state;i&&i.toJSON&&(n[r]=i.toJSON.call(o,e[o.key]))}return n},ra.fromJSON=function(t,e,n){if(!t.schema)throw new RangeError("Required config field 'schema' missing");var r=new na(t.schema,t.plugins),o=new ra(r);return r.fields.forEach(function(r){if("doc"==r.name)o.doc=Xs.fromJSON(t.schema,e.doc);else if("selection"==r.name)o.selection=Ys.fromJSON(o.doc,e.selection);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},ra.addApplyListener=function(t){ia.push(t)},ra.removeApplyListener=function(t){var e=ia.indexOf(t);e>-1&&ia.splice(e,1)},Object.defineProperties(ra.prototype,oa);var ia=[],sa={EditorState:ra},aa=function(t){this.props={},t.props&&bt(t.props,this,this.props),this.spec=t,this.key=t.key?t.key.key:kt("plugin")};aa.prototype.getState=function(t){return t[this.key]};var ca=aa,pa=Object.create(null),la=function(t){void 0===t&&(t="key"),this.key=kt(t)};la.prototype.get=function(t){return t.config.pluginsByKey[this.key]},la.prototype.getState=function(t){return t[this.key]};var ua={Plugin:ca,PluginKey:la},ha=t(function(t,e){var n;n=Pi,e.Selection=n.Selection,e.SelectionRange=n.SelectionRange,e.TextSelection=n.TextSelection,e.NodeSelection=n.NodeSelection,e.AllSelection=n.AllSelection,e.Transaction=Gs.Transaction,e.EditorState=sa.EditorState;var r;r=ua,e.Plugin=r.Plugin,e.PluginKey=r.PluginKey}),fa=ha.TextSelection,da=ha.NodeSelection,ma=ha.EditorState,va=ha.Plugin,ga=ha.PluginKey,ya=t(function(t){var e=t.exports={};if("undefined"!=typeof navigator){var n=/Edge\/(\d+)/.exec(navigator.userAgent),r=/MSIE \d/.test(navigator.userAgent),o=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);e.mac=/Mac/.test(navigator.platform);var i=e.ie=!!(r||o||n);e.ie_version=r?document.documentMode||6:o?+o[1]:n?+n[1]:null,e.gecko=!i&&/gecko\/\d/i.test(navigator.userAgent),e.chrome=!i&&/Chrome\//.test(navigator.userAgent),e.ios=!i&&/AppleWebKit/.test(navigator.userAgent)&&/Mobile\/\w+/.test(navigator.userAgent),e.webkit=!i&&"WebkitAppearance"in document.documentElement.style}}),wa=t(function(t,e){function n(t,e,n,a,c){for(;;){if(t==n&&e==a)return!0;if(e==(c<0?0:r(t))){var p=t.parentNode;if(1!=p.nodeType||o(t)||s.test(t.nodeName))return!1;e=i(t)+(c<0?0:1),t=p}else{if(1!=t.nodeType)return!1;t=t.childNodes[e+(c<0?-1:0)],e=c<0?r(t):0}}}function r(t){return 3==t.nodeType?t.nodeValue.length:t.childNodes.length}function o(t){var e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}var i=e.domIndex=function(t){for(var e=0;;e++)if(!(t=t.previousSibling))return e};e.parentNode=function(t){var e=t.parentNode;return e&&11==e.nodeType?e.host:e},e.textRange=function(t,e,n){var r=document.createRange();return r.setEnd(t,null==n?t.nodeValue.length:n),r.setStart(t,e||0),r},e.isEquivalentPosition=function(t,e,r,o){return r&&(n(t,e,r,o,-1)||n(t,e,r,o,1))};var s=/^(img|br|input|textarea|hr)$/i;e.selectionCollapsed=function(t){var e=t.isCollapsed;return e&&ya.chrome&&t.rangeCount&&!t.getRangeAt(0).collapsed&&(e=!1),e}}),ba=wa.textRange,ka=wa.parentNode,Sa=/[\u0590-\u08ac]/,xa=null,Ma=null,Oa=!1,Ca={scrollRectIntoView:xt,storeScrollPos:Mt,resetScrollPos:Ot,posAtCoords:Nt,coordsAtPos:It,endOfTextblock:Bt},Da=fi.DOMSerializer,Ta=fi.Fragment,Ea=wa.domIndex,Aa=wa.isEquivalentPosition,Na=function(t,e,n,r){this.parent=t,this.children=e,this.dom=n,n.pmViewDesc=this,this.contentDOM=r,this.dirty=0},Ra={beforePosition:{},size:{},border:{},posBefore:{},posAtStart:{},posAfter:{},posAtEnd:{},contentLost:{}};Na.prototype.matchesWidget=function(){return!1},Na.prototype.matchesMark=function(){return!1},Na.prototype.matchesNode=function(){return!1},Na.prototype.matchesHack=function(){return!1},Ra.beforePosition.get=function(){return!1},Na.prototype.parseRule=function(){return null},Na.prototype.stopEvent=function(){return!1},Ra.size.get=function(){for(var t=this,e=0,n=0;n<this.children.length;n++)e+=t.children[n].size;return e},Ra.border.get=function(){return 0},Na.prototype.destroy=function(){var t=this;this.parent=null,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=null);for(var e=0;e<this.children.length;e++)t.children[e].destroy()},Na.prototype.posBeforeChild=function(t){for(var e=this,n=0,r=this.posAtStart;n<this.children.length;n++){var o=e.children[n];if(o==t)return r;r+=o.size}},Ra.posBefore.get=function(){return this.parent.posBeforeChild(this)},Ra.posAtStart.get=function(){return this.parent?this.parent.posBeforeChild(this)+this.border:0},Ra.posAfter.get=function(){return this.posBefore+this.size},Ra.posAtEnd.get=function(){return this.posAtStart+this.size-2*this.border},Na.prototype.localPosFromDOM=function(t,e,n){var r=this;if(this.contentDOM&&this.contentDOM.contains(1==t.nodeType?t:t.parentNode)){if(n<0){var o,i;if(t==this.contentDOM)o=t.childNodes[e-1];else{for(;t.parentNode!=this.contentDOM;)t=t.parentNode;o=t.previousSibling}for(;o&&(!(i=o.pmViewDesc)||i.parent!=this);)o=o.previousSibling;return o?this.posBeforeChild(i)+i.size:this.posAtStart}var s,a;if(t==this.contentDOM)s=t.childNodes[e];else{for(;t.parentNode!=this.contentDOM;)t=t.parentNode;s=t.nextSibling}for(;s&&(!(a=s.pmViewDesc)||a.parent!=this);)s=s.nextSibling;return s?this.posBeforeChild(a):this.posAtEnd}var c;if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))c=2&t.compareDocumentPosition(this.contentDOM);else if(this.dom.firstChild){if(0==e)for(var p=t;;p=p.parentNode){if(p==r.dom){c=!1;break}if(p.parentNode.firstChild!=p)break}if(null==c&&e==t.childNodes.length)for(var l=t;;l=l.parentNode){if(l==r.dom){c=!0;break}if(l.parentNode.lastChild!=l)break}}return(null==c?n>0:c)?this.posAtEnd:this.posAtStart},Na.prototype.nearestDesc=function(t,e){for(var n=this,r=!0,o=t;o;o=o.parentNode){var i=n.getDesc(o);if(i&&(!e||i.node)){if(!r||!i.nodeDOM||(1==i.nodeDOM.nodeType?i.nodeDOM.contains(t):i.nodeDOM==t))return i;r=!1}}},Na.prototype.getDesc=function(t){for(var e=this,n=t.pmViewDesc,r=n;r;r=r.parent)if(r==e)return n},Na.prototype.posFromDOM=function(t,e,n){for(var r=this,o=t;;o=o.parentNode){var i=r.getDesc(o);if(i)return i.localPosFromDOM(t,e,n)}},Na.prototype.descAt=function(t){for(var e=this,n=0,r=0;n<this.children.length;n++){var o=e.children[n],i=r+o.size;if(r==t&&i!=r){for(;!o.border&&o.children.length;)o=o.children[0];return o}if(t<i)return o.descAt(t-r-o.border);r=i}},Na.prototype.domFromPos=function(t){var e=this;if(!this.contentDOM)return{node:this.dom,offset:0};for(var n=0,r=0;;r++){if(n==t){for(;r<this.children.length&&this.children[r].beforePosition;)r++;return{node:e.contentDOM,offset:r}}if(r==e.children.length)throw new Error("Invalid position "+t);var o=e.children[r],i=n+o.size;if(t<i)return o.domFromPos(t-n-o.border);n=i}},Na.prototype.parseRange=function(t,e,n){var r=this;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 o=-1,i=-1,s=0,a=0;;a++){var c=r.children[a],p=s+c.size;if(-1==o&&t<=p){var l=s+c.border;if(t>=l&&e<=p-c.border&&c.node&&c.contentDOM&&r.contentDOM.contains(c.contentDOM))return c.parseRange(t-l,e-l,n+l);t=n+s;for(var u=a;u>0;u--){var h=r.children[u-1];if(h.size&&h.dom.parentNode==r.contentDOM&&!h.emptyChildAt(1)){o=Ea(h.dom)+1;break}t-=h.size}-1==o&&(o=0)}if(o>-1&&e<=p){e=n+p;for(var f=a+1;f<this.children.length;f++){var d=r.children[f];if(d.size&&d.dom.parentNode==r.contentDOM&&!d.emptyChildAt(-1)){i=Ea(d.dom);break}e+=d.size}-1==i&&(i=r.contentDOM.childNodes.length);break}s=p}return{node:this.contentDOM,from:t,to:e,fromOffset:o,toOffset:i}},Na.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)},Na.prototype.domAfterPos=function(t){var e=this.domFromPos(t),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]},Na.prototype.setSelection=function(t,e,n){for(var r=this,o=Math.min(t,e),i=Math.max(t,e),s=0,a=0;s<this.children.length;s++){var c=r.children[s],p=a+c.size;if(o>a&&i<p)return c.setSelection(t-a-c.border,e-a-c.border,n);a=p}var l=this.domFromPos(t),u=this.domFromPos(e),h=n.getSelection(),f=document.createRange();if(!Aa(l.node,l.offset,h.anchorNode,h.anchorOffset)||!Aa(u.node,u.offset,h.focusNode,h.focusOffset)){if(h.extend)f.setEnd(l.node,l.offset),f.collapse(!1);else{if(t>e){var d=l;l=u,u=d}f.setEnd(u.node,u.offset),f.setStart(l.node,l.offset)}h.removeAllRanges(),h.addRange(f),h.extend&&h.extend(u.node,u.offset)}},Na.prototype.ignoreMutation=function(t){return!this.contentDOM},Ra.contentLost.get=function(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)},Na.prototype.markDirty=function(t,e){for(var n=this,r=0,o=0;o<this.children.length;o++){var i=n.children[o],s=r+i.size;if(r==s?t<=s&&e>=r:t<s&&e>r){var a=r+i.border,c=s-i.border;if(t>=a&&e<=c)return n.dirty=t==r||e==s?2:1,void(t==a&&e==c&&i.contentLost?i.dirty=3:i.markDirty(t-a,e-a));i.dirty=3}r=s}this.dirty=2},Object.defineProperties(Na.prototype,Ra);var Ia=[],Pa=function(t){function e(e,n){t.call(this,e,Ia,n.type.widget,null),this.widget=n}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={beforePosition:{}};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)},Object.defineProperties(e.prototype,n),e}(Na),za=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.parseRule=function(){for(var e,n=this.dom.firstChild;n;n=n.nextSibling){var r=void 0;if(3==n.nodeType){var o=n.nodeValue.replace(/\ufeff/g,"");if(!o)continue;r=document.createTextNode(o)}else{if("\ufeff"==n.textContent)continue;r=n.cloneNode(!0)}e||(e=document.createDocumentFragment()),e.appendChild(r)}return e?{skip:e}:t.prototype.parseRule.call(this)},e.prototype.ignoreMutation=function(){return!1},e}(Pa),Fa=function(t){function e(e,n,r){t.call(this,e,[],r,r),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){var o=Ut(r)[n.type.name],i=o&&o(n,r);return new e(t,n,i&&i.dom||Da.renderSpec(document,n.type.spec.toDOM(n)).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}(Na),Ba=function(t){function e(e,n,r,o,i,s,a,c){t.call(this,e,n.isLeaf?Ia:[],i,s),this.nodeDOM=a,this.node=n,this.outerDeco=r,this.innerDeco=o,s&&this.updateChildren(c)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={size:{},border:{}};return e.create=function(t,n,r,o,i){var s,a=Ut(i)[n.type.name],c=a&&a(n,i,function(){if(s&&s.parent)return s.parent.posBeforeChild(s)},r),p=c&&c.dom,l=c&&c.contentDOM;if(n.isText)if(p){if(3!=p.nodeType)throw new RangeError("Text must be rendered as a DOM text node")}else p=document.createTextNode(n.text);else if(!p){var u;p=(u=Da.renderSpec(document,n.type.spec.toDOM(n))).dom,l=u.contentDOM}l||n.isText||(p.contentEditable=!1);var h=p;return p=Wt(p,r,n),c?s=new ja(t,n,r,o,p,l,h,c,i):n.isText?new _a(t,n,r,o,p,h,i):new e(t,n,r,o,p,l,h,i)},e.prototype.parseRule=function(){var t=this;return this.contentDOM&&!this.contentLost?{node:this.node.type.name,attrs:this.node.attrs,contentElement:this.contentDOM}:{node:this.node.type.name,attrs:this.node.attrs,getContent:function(){return t.contentDOM?Ta.empty:t.node.content}}},e.prototype.matchesNode=function(t,e,n){return 0==this.dirty&&t.eq(this.node)&&qt(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){var e=this,n=new Ja(this);Ht(this.node,this.innerDeco,function(e){e.spec.isCursorWrapper&&n.syncToMarks(e.spec.marks,t),n.placeWidget(e)},function(r,o,i,s){n.syncToMarks(r.marks,t),n.findNodeMatch(r,o,i)||n.updateNextNode(r,o,i,t,e.node.content,s)||n.addNode(r,o,i,t)}),n.syncToMarks(Ia,t),this.node.isTextblock&&n.addTextblockHacks(),n.destroyRest(),(n.changed||2==this.dirty)&&this.renderChildren()},e.prototype.renderChildren=function(){_t(this.contentDOM,this.children,e.is),ya.ios&&Gt(this.dom)},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.dirty=0},e.prototype.updateOuterDeco=function(t){if(!qt(t,this.outerDeco)){var e=1!=this.nodeDOM.nodeType,n=this.dom;this.dom=Lt(this.dom,this.nodeDOM,jt(this.outerDeco,this.node,e),jt(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")},e.prototype.deselectNode=function(){this.nodeDOM.classList.remove("ProseMirror-selectednode")},Object.defineProperties(e.prototype,n),e}(Na),$a=$t,_a=function(t){function e(e,n,r,o,i,s,a){t.call(this,e,n,r,o,i,null,s,a)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.parseRule=function(){var t=this.nodeDOM.parentNode;return t?{skip:t}:{ignore:!0}},e.prototype.update=function(t,e){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),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},e}(Ba),Va=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.parseRule=function(){return{ignore:!0}},e.prototype.matchesHack=function(){return 0==this.dirty},e}(Na),ja=function(t){function e(e,n,r,o,i,s,a,c,p){t.call(this,e,n,r,o,i,s,a,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);return i&&this.updateInner(e,n,r,o),i}return!(!this.contentDOM&&!e.isLeaf)&&t.prototype.update.call(this,e,n,this.contentDOM?this.innerDeco: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){this.spec.setSelection?this.spec.setSelection(e,n,r):t.prototype.setSelection.call(this,e,n,r)},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}(Ba);Vt.prototype=Object.create(null);var La=[new Vt],Ja=function(t){this.top=t,this.index=0,this.stack=[],this.changed=!1};Ja.prototype.destroyBetween=function(t,e){var n=this;if(t!=e){for(var r=t;r<e;r++)n.top.children[r].destroy();this.top.children.splice(t,e-t),this.changed=!0}},Ja.prototype.destroyRest=function(){this.destroyBetween(this.index,this.top.children.length)},Ja.prototype.syncToMarks=function(t,e){for(var n,r=this,o=0,i=this.stack.length>>1,s=Math.min(i,t.length);o<s&&(o==i-1?this.top:this.stack[o+1<<1]).matchesMark(t[o]);)o++;for(;o<i;)r.destroyRest(),r.top.dirty=0,r.index=r.stack.pop(),r.top=r.stack.pop(),i--;for(;i<t.length;){if(r.stack.push(r.top,r.index+1),r.index<r.top.children.length&&(n=r.top.children[r.index]).matchesMark(t[i]))r.top=n;else{var a=Fa.create(r.top,t[i],e);r.top.children.splice(r.index,0,a),r.top=a,r.changed=!0}r.index=0,i++}},Ja.prototype.findNodeMatch=function(t,e,n){for(var r=this,o=this.index,i=this.top.children,s=Math.min(i.length,o+5);o<s;o++)if(i[o].matchesNode(t,e,n))return r.destroyBetween(r.index,o),r.index++,!0;return!1},Ja.prototype.updateNextNode=function(t,e,n,r,o,i){if(this.index==this.top.children.length)return!1;var s=this.top.children[this.index];if(s instanceof Ba){for(var a=i+1,c=Math.min(o.childCount,a+5);a<c;a++)if(s.node==o.child(a))return!1;var p=s.dom;if(s.update(t,e,n,r))return s.dom!=p&&(this.changed=!0),this.index++,!0}return!1},Ja.prototype.addNode=function(t,e,n,r){this.top.children.splice(this.index++,0,Ba.create(this.top,t,e,n,r)),this.changed=!0},Ja.prototype.placeWidget=function(t){if(this.index<this.top.children.length&&this.top.children[this.index].matchesWidget(t))this.index++;else{var e=new(t.spec.isCursorWrapper?za:Pa)(this.top,t);this.top.children.splice(this.index++,0,e),this.changed=!0}},Ja.prototype.addTextblockHacks=function(){for(var t=this.top.children[this.index-1];t instanceof Fa;)t=t.children[t.children.length-1];if(!t||!(t instanceof _a)||/\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 Va(this.top,Ia,e,null)),this.changed=!0}};var Wa,qa,Ka={docViewDesc:$a},Ha=ha.Selection,Ua=ha.NodeSelection,Qa=ha.TextSelection,Ga=wa.domIndex,Xa={captureKeyDown:pe},Ya=ha.EditorState,Za=Hs.Mapping,tc=function(t,e,n){this.prev=t,this.mapping=e,this.state=n},ec=function(t){this.seen=[new tc(null,null,t)],Ya.addApplyListener(this.track=this.track.bind(this))};ec.prototype.destroy=function(){Ya.removeApplyListener(this.track)},ec.prototype.find=function(t){for(var e=this,n=this.seen.length-1;n>=0;n--){var r=e.seen[n];if(r.state==t)return r}},ec.prototype.track=function(t,e,n){var r=this.seen.length<200?this.find(t):null;r&&this.seen.push(new tc(r,e.docChanged?e.mapping:null,n))},ec.prototype.getMapping=function(t,e){var n=this.find(t);if(!n)return null;for(var r=[],o=n;o;o=o.prev)o.mapping&&r.push(o.mapping);for(var i=e||new Za,s=r.length-1;s>=0;s--)i.appendMapping(r[s]);return i};var nc={TrackMappings:ec},rc=ha.TextSelection,oc=ha.NodeSelection,ic=wa.selectionCollapsed,sc=function(t){var e=this;this.view=t,this.lastAnchorNode=this.lastHeadNode=this.lastAnchorOffset=this.lastHeadOffset=null,this.lastSelection=t.state.selection,this.ignoreUpdates=!1,this.poller=le(this),t.dom.addEventListener("focus",function(){return e.poller.start()}),t.dom.addEventListener("blur",function(){return e.poller.stop()}),t.editable||this.poller.start()};sc.prototype.destroy=function(){this.poller.stop()},sc.prototype.poll=function(t){this.poller.poll(t)},sc.prototype.editableChanged=function(){this.view.editable?ye(this.view)||this.poller.stop():this.poller.start()},sc.prototype.domChanged=function(){var t=this.view.root.getSelection();return t.anchorNode!=this.lastAnchorNode||t.anchorOffset!=this.lastAnchorOffset||t.focusNode!=this.lastHeadNode||t.focusOffset!=this.lastHeadOffset},sc.prototype.storeDOMState=function(t){var e=this.view.root.getSelection();this.lastAnchorNode=e.anchorNode,this.lastAnchorOffset=e.anchorOffset,this.lastHeadNode=e.focusNode,this.lastHeadOffset=e.focusOffset,this.lastSelection=t},sc.prototype.clearDOMState=function(){this.lastAnchorNode=this.lastSelection=null},sc.prototype.readFromDOM=function(t){if(!this.ignoreUpdates&&this.domChanged()&&ye(this.view)&&(this.view.inDOMChange||this.view.domObserver.flush(),!this.view.inDOMChange)){var e=this.view.root.getSelection(),n=this.view.state.doc,r=this.view.docView.nearestDesc(e.focusNode);if(!r.size)return void this.storeDOMState();var o,i,s=this.view.docView.posFromDOM(e.focusNode,e.focusOffset),a=n.resolve(s);if(ic(e)){for(o=a;r&&!r.node;)r=r.parent;if(r&&r.node.isAtom&&oc.isSelectable(r.node)&&r.parent){var c=r.posBefore;i=new oc(s==c?a:n.resolve(c))}}else o=n.resolve(this.view.docView.posFromDOM(e.anchorNode,e.anchorOffset));if(!i){var p="pointer"==t||this.view.state.selection.head<a.pos?1:-1;i=ge(this.view,o,a,p)}if(s==i.head&&o.pos==i.anchor&&this.storeDOMState(i),!this.view.state.selection.eq(i)){var l=this.view.state.tr.setSelection(i);"pointer"==t&&l.setMeta("pointer",!0),this.view.dispatch(l)}}};var ac=sc,cc=function(t){var e=this;this.listening=!1,this.curOrigin=null,this.originTime=0,this.reader=t,this.readFunc=function(){return t.readFromDOM(e.originTime>Date.now()-50?e.curOrigin:null)}};cc.prototype.poll=function(t){this.curOrigin=t,this.originTime=Date.now()},cc.prototype.start=function(){this.listening||(document.addEventListener("selectionchange",this.readFunc),this.listening=!0,ye(this.reader.view)&&this.readFunc())},cc.prototype.stop=function(){this.listening&&(document.removeEventListener("selectionchange",this.readFunc),this.listening=!1)};var pc=function(t){this.polling=null,this.reader=t,this.pollFunc=this.doPoll.bind(this,null)};pc.prototype.doPoll=function(t){var e=this.reader.view;e.focused||!e.editable?(this.reader.readFromDOM(t),this.polling=setTimeout(this.pollFunc,100)):this.polling=null},pc.prototype.poll=function(t){clearTimeout(this.polling),this.polling=setTimeout(t?this.doPoll.bind(this,t):this.pollFunc,0)},pc.prototype.start=function(){null==this.polling&&this.poll()},pc.prototype.stop=function(){clearTimeout(this.polling),this.polling=null};var lc={SelectionReader:ac,selectionToDOM:ue,selectionBetween:ge},uc=fi.Fragment,hc=fi.DOMParser,fc=ha.Selection,dc=Hs.Mapping,mc=nc.TrackMappings,vc=lc.selectionBetween,gc=wa.selectionCollapsed,yc=function(t,e){var n=this;this.view=t,this.state=t.state,this.composing=e,this.from=this.to=null,this.timeout=e?null:setTimeout(function(){return n.finish()},20),this.trackMappings=new mc(t.state),this.mapping=new dc,this.mappingTo=t.state};yc.prototype.addRange=function(t,e){null==this.from?(this.from=t,this.to=e):(this.from=Math.min(t,this.from),this.to=Math.max(e,this.to))},yc.prototype.changedRange=function(){if(null==this.from)return xe(this.state.selection);var t=this.state.doc.resolve(Math.min(this.from,this.state.selection.from)),e=this.state.doc.resolve(this.to),n=t.sharedDepth(this.to);return{from:t.before(n+1),to:e.after(n+1)}},yc.prototype.markDirty=function(t){null==this.from?this.view.docView.markDirty((t=t||this.changedRange()).from,t.to):this.view.docView.markDirty(this.from,this.to)},yc.prototype.stateUpdated=function(t){return this.trackMappings.getMapping(t,this.mapping)?(this.trackMappings.destroy(),this.trackMappings=new mc(t),this.mappingTo=t,!0):(this.markDirty(),this.destroy(),!1)},yc.prototype.finish=function(t){if(clearTimeout(this.timeout),!this.composing||t){this.view.domObserver.flush();var e=this.changedRange();this.markDirty(e),this.destroy(),Oe(this.view,this.mapping,this.state,e),this.view.docView.dirty&&this.view.updateState(this.view.state)}},yc.prototype.destroy=function(){clearTimeout(this.timeout),this.trackMappings.destroy(),this.view.inDOMChange=null},yc.prototype.compositionEnd=function(){var t=this;this.composing&&(this.composing=!1,this.timeout=setTimeout(function(){return t.finish()},50))},yc.start=function(t,e){return t.inDOMChange?e&&(clearTimeout(t.inDOMChange.timeout),t.inDOMChange.composing=!0):t.inDOMChange=new yc(t,e),t.inDOMChange};var wc={DOMChange:yc},bc=fi.Slice,kc=fi.Fragment,Sc=fi.DOMParser,xc=fi.DOMSerializer,Mc={thead:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]},Oc=null,Cc={serializeForClipboard:Ne,parseFromClipboard:Re},Dc=wc.DOMChange,Tc=wa.domIndex,Ec={childList:!0,characterData:!0,attributes:!0,subtree:!0},Ac=ya.ie&&ya.ie_version<=11,Nc=function(t){var e=this;this.view=t,this.observer=window.MutationObserver&&new window.MutationObserver(function(t){return e.registerMutations(t)}),Ac&&(this.onCharData=function(t){return e.registerMutation({target:t.target,type:"characterData"})})};Nc.prototype.start=function(){this.observer&&this.observer.observe(this.view.dom,Ec),Ac&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData)},Nc.prototype.stop=function(){this.observer&&(this.flush(),this.observer.disconnect()),Ac&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData)},Nc.prototype.flush=function(){this.observer&&this.registerMutations(this.observer.takeRecords())},Nc.prototype.registerMutations=function(t){for(var e=this,n=0;n<t.length;n++)e.registerMutation(t[n])},Nc.prototype.registerMutation=function(t){if(this.view.editable){var e=this.view.docView.nearestDesc(t.target);if(("attributes"!=t.type||e!=this.view.docView&&"contenteditable"!=t.attributeName)&&e&&!e.ignoreMutation(t)){var n,r;if("childList"==t.type){var o=t.previousSibling&&t.previousSibling.parentNode==t.target?Tc(t.previousSibling)+1:0;if(-1==o)return;n=e.localPosFromDOM(t.target,o,-1);var i=t.nextSibling&&t.nextSibling.parentNode==t.target?Tc(t.nextSibling):t.target.childNodes.length;if(-1==i)return;r=e.localPosFromDOM(t.target,i,1)}else"attributes"==t.type?(n=e.posAtStart-e.border,r=e.posAtEnd+e.border):(n=e.posAtStart,r=e.posAtEnd);Dc.start(this.view).addRange(n,r)}}};var Rc={DOMObserver:Nc},Ic=ha.Selection,Pc=ha.NodeSelection,zc=ha.TextSelection,Fc=Xa.captureKeyDown,Bc=wc.DOMChange,$c=Cc.parseFromClipboard,_c=Cc.serializeForClipboard,Vc=Rc.DOMObserver,jc=lc.selectionBetween,Lc={},Jc={},Wc=je,qc=Le,Kc=Je,Hc=Ke;Jc.keydown=function(t,e){16==e.keyCode&&(t.shiftKey=!0),t.inDOMChange||(t.someProp("handleKeyDown",function(n){return n(t,e)})||Fc(t,e)?e.preventDefault():t.selectionReader.poll())},Jc.keyup=function(t,e){16==e.keyCode&&(t.shiftKey=!1)},Jc.keypress=function(t,e){if(!(t.inDOMChange||!e.charCode||e.ctrlKey&&!e.altKey||ya.mac&&e.metaKey)){if(t.someProp("handleKeyPress",function(n){return n(t,e)}))return void e.preventDefault();var n=t.state.selection;if(!(n instanceof zc&&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 Uc={time:0,x:0,y:0},Qc=Uc,Gc=ya.mac?"metaKey":"ctrlKey";Lc.mousedown=function(t,e){var n,r=rn(t),o=Date.now();n=o-Uc.time>=500||!Ue(e,Uc)||e[Gc]?"singleClick":o-Qc.time>=600||!Ue(e,Qc)?"doubleClick":"tripleClick",Qc=Uc,Uc={time:o,x:e.clientX,y:e.clientY};var i=t.posAtCoords(He(e));i&&("singleClick"==n?t.mouseDown=new Xc(t,i,e,r):("doubleClick"==n?tn:en)(t,i.pos,i.inside,e)?e.preventDefault():t.selectionReader.poll("pointer"))};var Xc=function(t,e,n,r){var o=this;this.view=t,this.pos=e,this.event=n,this.flushed=r,this.selectNode=n[Gc],this.allowDefault=n.shiftKey;var i,s;if(e.inside>-1)i=t.state.doc.nodeAt(e.inside),s=e.inside;else{var a=t.state.doc.resolve(e.pos);i=a.parent,s=a.depth?a.before():0}this.mightDrag=null,(i.type.spec.draggable&&!1!==i.type.spec.selectable||t.state.selection instanceof Pc&&s==t.state.selection.from)&&(this.mightDrag={node:i,pos:s}),this.target=r?null:n.target,this.target&&this.mightDrag&&(this.view.domObserver.stop(),this.target.draggable=!0,ya.gecko&&(this.setContentEditable=!this.target.hasAttribute("contentEditable"))&&setTimeout(function(){return o.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)),t.selectionReader.poll("pointer")};Xc.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.target.draggable=!1,ya.gecko&&this.setContentEditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start())},Xc.prototype.up=function(t){this.done(),this.view.dom.contains(3==t.target.nodeType?t.target.parentNode:t.target)&&(this.allowDefault?this.view.selectionReader.poll("pointer"):Ze(this.view,this.pos.pos,this.pos.inside,t,this.selectNode)?t.preventDefault():this.flushed?(Ge(this.view,Ic.near(this.view.state.doc.resolve(this.pos.pos)),"pointer"),t.preventDefault()):this.view.selectionReader.poll("pointer"))},Xc.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),this.view.selectionReader.poll("pointer")},Lc.touchdown=function(t){rn(t),t.selectionReader.poll("pointer")},Lc.contextmenu=function(t,e){rn(t);var n=t.posAtCoords(He(e));n&&t.someProp("handleContextMenu",function(r){return r(t,n.pos,e)})&&e.preventDefault()},Jc.compositionstart=Jc.compositionupdate=function(t){Bc.start(t,!0)},Jc.compositionend=function(t,e){if(!t.inDOMChange){if(!e.data)return;Bc.start(t,!0)}t.inDOMChange.compositionEnd()},Jc.input=function(t){return Bc.start(t)};var Yc=ya.ie||ya.ios;Lc.copy=Jc.cut=function(t,e){var n=t.state.selection,r="cut"==e.type;if(!n.empty){var o=Yc?null:e.clipboardData,i=n.content(),s=_c(t,i);o?(e.preventDefault(),o.clearData(),o.setData("text/html",s.innerHTML),o.setData("text/plain",i.content.textBetween(0,i.content.size,"\n\n"))):on(t,s),r&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView())}},Jc.paste=function(t,e){var n=Yc?null:e.clipboardData;n&&cn(t,n.getData("text/plain"),n.getData("text/html"),e)?e.preventDefault():an(t,e)};var Zc=function(t,e){this.slice=t,this.move=e};Lc.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(He(e));if(o&&o.pos>=r.from&&o.pos<=r.to);else{if(!n||!n.mightDrag)return;t.dispatch(t.state.tr.setSelection(Pc.create(t.state.doc,n.mightDrag.pos)))}var i=t.state.selection.content(),s=_c(t,i);e.dataTransfer.clearData(),e.dataTransfer.setData("text/html",s.innerHTML),e.dataTransfer.setData("text/plain",i.content.textBetween(0,i.content.size,"\n\n")),t.dragging=new Zc(i,!e.ctrlKey)}},Lc.dragend=function(t){window.setTimeout(function(){return t.dragging=null},50)},Jc.dragover=Jc.dragenter=function(t,e){return e.preventDefault()},Jc.drop=function(t,e){var n=t.dragging;if(t.dragging=null,e.dataTransfer){var r=t.state.doc.resolve(t.posAtCoords(He(e)).pos);if(r){var o=n&&n.slice||$c(t,e.dataTransfer.getData("text/plain"),e.dataTransfer.getData("text/html"),!1,r);if(o&&(e.preventDefault(),!t.someProp("handleDrop",function(r){return r(t,e,o,n&&n.move)}))){var i=pn(o,t.state.doc.resolve(r.pos)),s=t.state.tr;n&&n.move&&s.deleteSelection();var a=s.mapping.map(i),c=0==o.openStart&&0==o.openEnd&&1==o.content.childCount;c?s.replaceRangeWith(a,a,o.content.firstChild):s.replaceRange(a,a,o);var p=s.doc.resolve(a);c&&Pc.isSelectable(o.content.firstChild)&&p.nodeAfter&&p.nodeAfter.sameMarkup(o.content.firstChild)?s.setSelection(new Pc(p)):s.setSelection(jc(t,p,s.doc.resolve(s.mapping.map(i)))),t.focus(),t.dispatch(s)}}}},Lc.focus=function(t,e){t.focused||(t.dom.classList.add("ProseMirror-focused"),t.focused=!0),t.someProp("onFocus",function(n){n(t,e)})},Lc.blur=function(t,e){t.focused&&(t.dom.classList.remove("ProseMirror-focused"),t.focused=!1),t.someProp("onBlur",function(n){n(t,e)})};for(var tp in Jc)Lc[tp]=Jc[tp];var ep={initInput:Wc,destroyInput:qc,ensureListeners:Kc,dispatchEvent:Hc},np=!1,rp=function(t,e){if(this.spec=e||lp,this.side=this.spec.side||0,"left"==this.spec.associative&&null==this.spec.side&&(!np&&"undefined"!=typeof console&&console.warn&&(np=!0,console.warn("Widget decoration associativity should now be expressed with the `side` option.")),this.side=-1),!this.spec.raw){if(1!=t.nodeType){var n=document.createElement("span");n.appendChild(t),t=n}t.contentEditable=!1,t.classList.add("ProseMirror-widget")}this.widget=t};rp.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 sp(i-n,i-n,this)},rp.prototype.valid=function(){return!0},rp.prototype.eq=function(t){return this==t||t instanceof rp&&(this.widget==t.widget||this.spec.key)&&ln(this.spec,t.spec)};var op=function(t,e){this.spec=e||lp,this.attrs=t};op.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 sp(o,i,this)},op.prototype.valid=function(t,e){return e.from<e.to},op.prototype.eq=function(t){return this==t||t instanceof op&&ln(this.attrs,t.attrs)&&ln(this.spec,t.spec)},op.is=function(t){return t.type instanceof op};var ip=function(t,e){this.spec=e||lp,this.attrs=t};ip.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 sp(o.pos-n,i.pos-n,this)},ip.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},ip.prototype.eq=function(t){return this==t||t instanceof ip&&ln(this.attrs,t.attrs)&&ln(this.spec,t.spec)};var sp=function(t,e,n){this.from=t,this.to=e,this.type=n},ap={spec:{}};sp.prototype.copy=function(t,e){return new sp(t,e,this.type)},sp.prototype.eq=function(t){return this.type.eq(t.type)&&this.from==t.from&&this.to==t.to},sp.prototype.map=function(t,e,n){return this.type.map(t,this,e,n)},sp.widget=function(t,e,n){return new sp(t,t,new rp(e,n))},sp.inline=function(t,e,n,r){return new sp(t,e,new op(n,r))},sp.node=function(t,e,n,r){return new sp(t,e,new ip(n,r))},ap.spec.get=function(){return this.type.spec},Object.defineProperties(sp.prototype,ap);var cp=sp,pp=[],lp={},up=function(t,e){this.local=t&&t.length?t:pp,this.children=e&&e.length?e:pp};up.create=function(t,e){return e.length?vn(e,t,0,lp):fp},up.prototype.find=function(t,e){var n=[];return this.findInner(null==t?0:t,null==e?1e9:e,n,0),n},up.prototype.findInner=function(t,e,n,r){for(var o=this,i=0;i<this.local.length;i++){var s=o.local[i];s.from<=e&&s.to>=t&&n.push(s.copy(s.from+r,s.to+r))}for(var a=0;a<this.children.length;a+=3)if(o.children[a]<e&&o.children[a+1]>t){var c=o.children[a]+1;o.children[a+2].findInner(t-c,e-c,n,r+c)}},up.prototype.map=function(t,e,n){return this==fp||0==t.maps.length?this:this.mapInner(t,e,0,0,n||lp)},up.prototype.mapInner=function(t,e,n,r,o){for(var i,s=this,a=0;a<this.local.length;a++){var c=s.local[a].map(t,n,r);c&&c.type.valid(e,c)?(i||(i=[])).push(c):o.onRemove&&o.onRemove(s.local[a].spec)}return this.children.length?un(this.children,i,t,e,n,r,o):i?new up(i.sort(gn)):fp},up.prototype.add=function(t,e){return e.length?this==fp?up.create(t,e):this.addInner(t,e,0):this},up.prototype.addInner=function(t,e,n){var r,o=this,i=0;t.forEach(function(t,s){var a,c=s+n;if(a=dn(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,vn(a,t,c+1,lp)),i+=3}});var s=hn(i?mn(e):e,-n);return new up(s.length?this.local.concat(s).sort(gn):this.local,r||this.children)},up.prototype.remove=function(t){return 0==t.length||this==fp?this:this.removeInner(t,0)},up.prototype.removeInner=function(t,e){for(var n=this,r=this.children,o=this.local,i=0;i<r.length;i+=3){for(var s=void 0,a=r[i]+e,c=r[i+1]+e,p=0,l=void 0;p<t.length;p++)(l=t[p])&&l.from>a&&l.to<c&&(t[p]=null,(s||(s=[])).push(l));if(s){r==n.children&&(r=n.children.slice());var u=r[i+2].removeInner(s,a+1);u!=fp?r[i+2]=u:(r.splice(i,3),i-=3)}}if(o.length)for(var h=0,f=void 0;h<t.length;h++)if(f=t[h])for(var d=0;d<o.length;d++)o[d].type==f.type&&(o==n.local&&(o=n.local.slice()),o.splice(d--,1));return r==this.children&&o==this.local?this:o.length||r.length?new up(o,r):fp},up.prototype.forChild=function(t,e){var n=this;if(this==fp)return this;if(e.isLeaf)return up.empty;for(var r,o,i=0;i<this.children.length;i+=3)if(n.children[i]>=t){n.children[i]==t&&(r=n.children[i+2]);break}for(var s=t+1,a=s+e.content.size,c=0;c<this.local.length;c++){var p=n.local[c];if(p.from<a&&p.to>s&&p.type instanceof op){var l=Math.max(s,p.from)-s,u=Math.min(a,p.to)-s;l<u&&(o||(o=[])).push(p.copy(l,u))}}if(o){var h=new up(o);return r?new dp([h,r]):h}return r||fp},up.prototype.eq=function(t){var e=this;if(this==t)return!0;if(!(t instanceof up)||this.local.length!=t.local.length||this.children.length!=t.children.length)return!1;for(var n=0;n<this.local.length;n++)if(!e.local[n].eq(t.local[n]))return!1;for(var r=0;r<this.children.length;r+=3)if(e.children[r]!=t.children[r]||e.children[r+1]!=t.children[r+1]||!e.children[r+2].eq(t.children[r+2]))return!1;return!1},up.prototype.locals=function(t){return yn(this.localsInner(t))},up.prototype.localsInner=function(t){var e=this;if(this==fp)return pp;if(t.inlineContent||!this.local.some(op.is))return this.local;for(var n=[],r=0;r<this.local.length;r++)e.local[r].type instanceof op||n.push(e.local[r]);return n};var hp=up,fp=new up;up.empty=fp;var dp=function(t){this.members=t};dp.prototype.forChild=function(t,e){var n=this;if(e.isLeaf)return up.empty;for(var r=[],o=0;o<this.members.length;o++){var i=n.members[o].forChild(t,e);i!=fp&&(i instanceof dp?r=r.concat(i.members):r.push(i))}return dp.from(r)},dp.prototype.eq=function(t){var e=this;if(!(t instanceof dp)||t.members.length!=this.members.length)return!1;for(var n=0;n<this.members.length;n++)if(!e.members[n].eq(t.members[n]))return!1;return!0},dp.prototype.locals=function(t){for(var e,n=this,r=!0,o=0;o<this.members.length;o++){var i=n.members[o].localsInner(t);if(i.length)if(e){r&&(e=e.slice(),r=!1);for(var s=0;s<i.length;s++)e.push(i[s])}else e=i}return e?yn(r?e:e.sort(gn)):pp},dp.from=function(t){switch(t.length){case 0:return fp;case 1:return t[0];default:return new dp(t)}};for(var mp={Decoration:cp,DecorationSet:hp,removeOverlap:yn,viewDecorations:bn},vp=t(function(t,e){function n(t){var e=Object.create(null);return e.class="ProseMirror"+(t.focused?" ProseMirror-focused":""),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]))}),[x.node(0,t.state.doc.content.size,e)]}function r(t){return!1===t.type.spec.inclusive}function o(){var t=document.createElement("span");return t.textContent="\ufeff",t}function i(t){var e=t.state.selection.$cursor;if(e&&(t.state.storedMarks||0==e.parent.content.length||e.parentOffset&&!e.textOffset&&e.nodeBefore.marks.some(r))){var n=t.state.storedMarks||e.marks(),i={isCursorWrapper:!0,marks:n,raw:!0};t.cursorWrapper&&c.sameSet(t.cursorWrapper.spec.marks,n)&&"\ufeff"==t.cursorWrapper.type.widget.textContent?t.cursorWrapper.pos!=e.pos&&(t.cursorWrapper=x.widget(e.pos,t.cursorWrapper.type.widget,i)):t.cursorWrapper=x.widget(e.pos,o(),i)}else t.cursorWrapper=null}function s(t){return!t.someProp("editable",function(e){return!1===e(t.state)})}var a,c=fi.Mark,p=ha.NodeSelection,l=Ca.scrollRectIntoView,u=Ca.posAtCoords,h=Ca.coordsAtPos,f=Ca.endOfTextblock,d=Ca.storeScrollPos,m=Ca.resetScrollPos,v=Ka.docViewDesc,g=ep.initInput,y=ep.destroyInput,w=ep.dispatchEvent,b=ep.ensureListeners,k=lc.SelectionReader,S=lc.selectionToDOM,x=mp.Decoration,M=mp.viewDecorations;a=mp,e.Decoration=a.Decoration,e.DecorationSet=a.DecorationSet;var O=function(t,e){this._props=e,this.state=e.state,this.dispatch=this.dispatch.bind(this),this._root=null,this.focused=!1,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=s(this),this.cursorWrapper=null,i(this),this.docView=v(this.state.doc,n(this),M(this),this.dom,this),this.lastSelectedViewDesc=null,this.selectionReader=new k(this),g(this),this.pluginViews=[],this.updatePluginViews()},C={props:{},root:{}};C.props.get=function(){var t=this;if(this._props.state!=this.state){var e=this._props;this._props={};for(var n in e)t._props[n]=e[n];this._props.state=this.state}return this._props},O.prototype.update=function(t){t.handleDOMEvents!=this._props.handleDOMEvents&&b(this),this._props=t,this.updateState(t.state)},O.prototype.setProps=function(t){var e=this,n={};for(var r in e._props)n[r]=e._props[r];n.state=this.state;for(var o in t)n[o]=t[o];this.update(n)},O.prototype.updateState=function(t){var e=this.state;if(this.state=t,e.plugins!=t.plugins&&b(this),this.domObserver.flush(),!this.inDOMChange||!this.inDOMChange.stateUpdated(t)){var r=this.editable;this.editable=s(this),i(this);var o=M(this),a=n(this),c=t.scrollToSelection>e.scrollToSelection||e.config!=t.config,u=!this.docView.matchesNode(t.doc,a,o),h=u||!t.selection.eq(e.selection)||this.selectionReader.domChanged(),f=!c&&h&&d(this);h&&(this.domObserver.stop(),u&&(this.docView.update(t.doc,a,o,this)||(this.docView.destroy(),this.docView=v(t.doc,a,o,this.dom,this)),this.selectionReader.clearDOMState()),S(this),this.domObserver.start()),r!=this.editable&&this.selectionReader.editableChanged(),this.updatePluginViews(e),c?t.selection instanceof p?l(this,this.docView.domAfterPos(t.selection.from).getBoundingClientRect()):l(this,this.coordsAtPos(t.selection.head)):f&&m(f)}},O.prototype.destroyPluginViews=function(){for(var t;t=this.pluginViews.pop();)t.destroy&&t.destroy()},O.prototype.updatePluginViews=function(t){var e=this,n=this.state.plugins;if(t&&t.plugins==n)for(var r=0;r<this.pluginViews.length;r++){var o=e.pluginViews[r];o.update&&o.update(e,t)}else{this.destroyPluginViews();for(var i=0;i<n.length;i++){var s=n[i];s.spec.view&&e.pluginViews.push(s.spec.view(e))}}},O.prototype.hasFocus=function(){return this.root.activeElement==this.dom},O.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}},O.prototype.focus=function(){this.domObserver.stop(),S(this,!0),this.domObserver.start(),this.editable&&this.dom.focus()},C.root.get=function(){var t=this,e=this._root;if(null==e)for(var n=this.dom.parentNode;n;n=n.parentNode)if(9==n.nodeType||11==n.nodeType&&n.host)return t._root=n;return e||document},O.prototype.posAtCoords=function(t){var e=u(this,t);return this.inDOMChange&&e&&(e.pos=this.inDOMChange.mapping.map(e),-1!=e.inside&&(e.inside=this.inDOMChange.mapping.map(e.inside))),e},O.prototype.coordsAtPos=function(t){return this.inDOMChange&&(t=this.inDOMChange.mapping.invert().map(t)),h(this,t)},O.prototype.endOfTextblock=function(t,e){return f(this,e||this.state,t)},O.prototype.destroy=function(){this.docView&&(y(this),this.destroyPluginViews(),this.selectionReader.destroy(),this.mounted?(this.docView.update(this.state.doc,[],M(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null)},O.prototype.dispatchEvent=function(t){return w(this,t)},O.prototype.dispatch=function(t){var e=this._props.dispatchTransaction;e?e(t):this.updateState(this.state.apply(t))},Object.defineProperties(O.prototype,C),e.EditorView=O}),gp=vp.Decoration,yp=vp.DecorationSet,wp=vp.EditorView,bp={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"},kp={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"},Sp="undefined"!=typeof navigator&&/Chrome\/(\d+)/.exec(navigator.userAgent),xp=Sp&&+Sp[1]<57,Mp=0;Mp<10;Mp++)bp[48+Mp]=bp[96+Mp]=String(Mp);for(Mp=1;Mp<=24;Mp++)bp[Mp+111]="F"+Mp;for(Mp=65;Mp<=90;Mp++)bp[Mp]=String.fromCharCode(Mp+32),kp[Mp]=String.fromCharCode(Mp);for(var Op in bp)kp.hasOwnProperty(Op)||(kp[Op]=bp[Op]);var Cp=kn;kn.base=bp,kn.shift=kp;var Dp=ha.Plugin,Tp="undefined"!=typeof navigator&&/Mac/.test(navigator.platform),Ep=On,Ap=Hs.joinPoint,Np=Hs.canJoin,Rp=Hs.findWrapping,Ip=Hs.liftTarget,Pp=Hs.canSplit,zp=Hs.ReplaceAroundStep,Fp=fi.Slice,Bp=fi.Fragment,$p=ha.Selection,_p=ha.TextSelection,Vp=ha.NodeSelection,jp=ha.AllSelection,Lp=Rn,Jp=Pn,Wp=Jn,qp=Wn,Kp=Kn,Hp=Hn,Up={Enter:Hn(In,zn,Fn,Bn),"Mod-Enter":Pn,Backspace:Hn(Dn,Tn),"Mod-Backspace":Hn(Dn,Tn),Delete:Hn(Dn,En),"Mod-Delete":Hn(Dn,En),"Alt-ArrowUp":An,"Alt-ArrowDown":Nn,"Mod-BracketLeft":Rn,Escape:$n,"Mod-a":_n};if("undefined"!=typeof navigator?/Mac/.test(navigator.platform):"undefined"!=typeof os&&"darwin"==os.platform()){var Qp={"Ctrl-h":Up.Backspace,"Alt-Backspace":Up["Mod-Backspace"],"Ctrl-d":Up.Delete,"Ctrl-Alt-Backspace":Up["Mod-Delete"],"Alt-Delete":Up["Mod-Delete"],"Alt-d":Up["Mod-Delete"]};for(var Gp in Qp)Up[Gp]=Qp[Gp]}var Xp=Up,Yp=function(){};Yp.prototype.append=function(t){return t.length?(t=Yp.from(t),!this.length&&t||t.length<200&&this.leafAppend(t)||this.length<200&&t.leafPrepend(this)||this.appendInner(t)):this},Yp.prototype.prepend=function(t){return t.length?Yp.from(t).append(this):this},Yp.prototype.appendInner=function(t){return new tl(this,t)},Yp.prototype.slice=function(t,e){return void 0===t&&(t=0),void 0===e&&(e=this.length),t>=e?Yp.empty:this.sliceInner(Math.max(0,t),Math.min(this.length,e))},Yp.prototype.get=function(t){if(!(t<0||t>=this.length))return this.getInner(t)},Yp.prototype.forEach=function(t,e,n){void 0===e&&(e=0),void 0===n&&(n=this.length),e<=n?this.forEachInner(t,e,n,0):this.forEachInvertedInner(t,e,n,0)},Yp.prototype.map=function(t,e,n){void 0===e&&(e=0),void 0===n&&(n=this.length);var r=[];return this.forEach(function(e,n){return r.push(t(e,n))},e,n),r},Yp.from=function(t){return t instanceof Yp?t:t&&t.length?new Zp(t):Yp.empty};var Zp=function(t){function e(e){t.call(this),this.values=e}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={length:{},depth:{}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(t,n){return 0==t&&n==this.length?this:new e(this.values.slice(t,n))},e.prototype.getInner=function(t){return this.values[t]},e.prototype.forEachInner=function(t,e,n,r){for(var o=this,i=e;i<n;i++)if(!1===t(o.values[i],r+i))return!1},e.prototype.forEachInvertedInner=function(t,e,n,r){for(var o=this,i=e-1;i>=n;i--)if(!1===t(o.values[i],r+i))return!1},e.prototype.leafAppend=function(t){if(this.length+t.length<=200)return new e(this.values.concat(t.flatten()))},e.prototype.leafPrepend=function(t){if(this.length+t.length<=200)return new e(t.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(e.prototype,n),e}(Yp);Yp.empty=new Zp([]);var tl=function(t){function e(e,n){t.call(this),this.left=e,this.right=n,this.length=e.length+n.length,this.depth=Math.max(e.depth,n.depth)+1}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(t){return t<this.left.length?this.left.get(t):this.right.get(t-this.left.length)},e.prototype.forEachInner=function(t,e,n,r){var o=this.left.length;return!(e<o&&!1===this.left.forEachInner(t,e,Math.min(n,o),r))&&(!(n>o&&!1===this.right.forEachInner(t,Math.max(e-o,0),Math.min(this.length,n)-o,r+o))&&void 0)},e.prototype.forEachInvertedInner=function(t,e,n,r){var o=this.left.length;return!(e>o&&!1===this.right.forEachInvertedInner(t,e-o,Math.max(n,o)-o,r+o))&&(!(n<o&&!1===this.left.forEachInvertedInner(t,Math.min(e,o),n,r))&&void 0)},e.prototype.sliceInner=function(t,e){if(0==t&&e==this.length)return this;var n=this.left.length;return e<=n?this.left.slice(t,e):t>=n?this.right.slice(t-n,e-n):this.left.slice(t,n).append(this.right.slice(0,e-n))},e.prototype.leafAppend=function(t){var n=this.right.leafAppend(t);if(n)return new e(this.left,n)},e.prototype.leafPrepend=function(t){var n=this.left.leafPrepend(t);if(n)return new e(n,this.right)},e.prototype.appendInner=function(t){return this.left.depth>=Math.max(this.right.depth,t.depth)+1?new e(this.left,new e(this.right,t)):new e(this,t)},e}(Yp),el=Yp,nl=Hs.Mapping,rl=ha.Plugin,ol=ha.PluginKey,il=function(t,e){this.items=t,this.eventCount=e};il.prototype.popEvent=function(t,e){var n=this;if(0==this.eventCount)return null;for(var r=this.items.length;;r--)if(n.items.get(r-1).selection){--r;break}var o,i;e&&(o=this.remapping(r,this.items.length),i=o.maps.length);var s,a,c=t.tr,p=[],l=[];return this.items.forEach(function(t,e){if(!t.step)return o||(o=n.remapping(r,e+1),i=o.maps.length),i--,void l.push(t);if(o){l.push(new sl(t.map));var u,h=t.step.map(o.slice(i));h&&c.maybeStep(h).doc&&(u=c.mapping.maps[c.mapping.maps.length-1],p.push(new sl(u,null,null,p.length+l.length))),i--,u&&o.appendMap(u,i)}else c.maybeStep(t.step);return t.selection?(s=o?t.selection.map(o.slice(i)):t.selection,a=new il(n.items.slice(0,r).append(l.reverse().concat(p)),n.eventCount-1),!1):void 0},this.items.length,0),{remaining:a,transform:c,selection:s}},il.prototype.addTransform=function(t,e,n){for(var r=[],o=this.eventCount+(e?1:0),i=this.items,s=!n.preserveItems&&i.length?i.get(i.length-1):null,a=0;a<t.steps.length;a++){var c=t.steps[a].invert(t.docs[a]),p=new sl(t.mapping.maps[a],c,e),l=void 0;(l=s&&s.merge(p))&&(p=l,a?r.pop():i=i.slice(0,i.length-1)),r.push(p),e=null,n.preserveItems||(s=p)}var u=o-n.depth;return u>cl&&(i=Un(i,u),o-=u),new il(i.append(r),o)},il.prototype.remapping=function(t,e){var n=[],r=[];return this.items.forEach(function(e,o){null!=e.mirrorOffset&&o-e.mirrorOffset>=t&&r.push(n.length-e.mirrorOffset,n.length),n.push(e.map)},t,e),new nl(n,r)},il.prototype.addMaps=function(t){return 0==this.eventCount?this:new il(this.items.append(t.map(function(t){return new sl(t)})),this.eventCount)},il.prototype.rebased=function(t,e){if(!this.eventCount)return this;var n=[],r=Math.max(0,this.items.length-e),o=t.mapping,i=t.steps.length,s=this.eventCount,a=e;this.items.forEach(function(e){var r=o.getMirror(--a);if(null!=r){i=Math.min(i,r);var c=o.maps[r];if(e.step){var p=t.steps[r].invert(t.docs[r]),l=e.selection&&e.selection.map(o.slice(a,r));n.push(new sl(c,p,l))}else e.selection&&s--,n.push(new sl(c))}},r);for(var c=[],p=e;p<i;p++)c.push(new sl(o.maps[p]));var l=this.items.slice(0,r).append(c).append(n),u=new il(l,s);return u.emptyItemCount()>500&&(u=u.compress(this.items.length-n.length)),u},il.prototype.emptyItemCount=function(){var t=0;return this.items.forEach(function(e){e.step||t++}),t},il.prototype.compress=function(t){void 0===t&&(t=this.items.length);var e=this.remapping(0,t),n=e.maps.length,r=[],o=0;return this.items.forEach(function(i,s){if(s>=t)r.push(i),i.selection&&o++;else if(i.step){var a=i.step.map(e.slice(n)),c=a&&a.getMap();if(n--,c&&e.appendMap(c,n),a){var p=i.selection&&i.selection.map(e.slice(n));p&&o++;var l,u=new sl(c.invert(),a,p),h=r.length-1;(l=r.length&&r[h].merge(u))?r[h]=l:r.push(u)}}else i.map&&n--},this.items.length,0),new il(el.from(r.reverse()),o)},il.empty=new il(el.empty,0);var sl=function(t,e,n,r){this.map=t,this.step=e,this.selection=n,this.mirrorOffset=r};sl.prototype.merge=function(t){if(this.step&&t.step&&!t.selection){var e=t.step.merge(this.step);if(e)return new sl(e.getMap().invert(),e,this.selection)}};var al=function(t,e,n,r){this.done=t,this.undone=e,this.prevMap=n,this.prevTime=r},cl=20,pl=new ol("history"),ll=new ol("closeHistory"),ul=Yn,hl=Zn,fl=tr,dl=(Hs.findWrapping,Hs.liftTarget,Hs.canSplit),ml=(Hs.ReplaceAroundStep,fi.Slice,fi.Fragment,fi.NodeRange,{attrs:{order:{default:1}},parseDOM:[{tag:"ol",getAttrs:function(t){return{order:t.hasAttribute("start")?+t.getAttribute("start"):1}}}],toDOM:function(t){return["ol",{start:1==t.attrs.order?null:t.attrs.order},0]}}),vl={parseDOM:[{tag:"ul"}],toDOM:function(){return["ul",0]}},gl={parseDOM:[{tag:"li"}],toDOM:function(){return["li",0]},defining:!0},yl=er,wl=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},bl=function(){function t(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),e}}(),kl=function(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t},Sl=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},xl=function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)},Ml=function(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e},Ol=function(t){if(Array.isArray(t)){for(var e=0,n=Array(t.length);e<t.length;e++)n[e]=t[e];return n}return Array.from(t)},Cl=function(t){return function(e){var n=null,r=e.doc,o=e.selection,i=e.schema,s=o.from,a=o.to,c=i.marks[t];return r.nodesBetween(s,a,function(t){for(var e=t.marks,r=0,o=e.length;!n&&r<o;r++)e[r].type===c&&(n=e[r]);return!n}),n}},Dl=function(t){return function(e){return!!Cl(t)(e)}},Tl=function(t){return Kl(t)()},El=function(t){return function(e){var n=e.selection,r=n.$from,o=n.$to,i=t>=0?t+r.depth:t;return e.selection instanceof da?e.selection.node:!r.depth||o.pos>r.end()?null:r.node(i)}},Al=El(0),Nl=El(-1),Rl=function(t){return function(e){var n=Al(e);return!(!n||n.type!==e.schema.nodes[t])}},Il=function(t){return function(e){var n=Nl(e);return!(!n||n.type!==e.schema.nodes[t])}},Pl=function(t,e,n){return function(r){return function(o){return function(i,s){return(t(r)(i)?e:n)(r)(o)(i,s)}}}},zl=function(t){return function(e){return function(n){return function(r){return function(o,i){return e(o.schema[t][n],r)(o,i)}}}}},Fl=zl("marks"),Bl=zl("nodes"),$l=function(t){var e=Al(t);return e&&0===e.content.size},_l=function(t){return function(e){return e.selection.$from.depth===t}},Vl=function(t){return function(e){var n=t(e);return n?n.attrs:null}},jl=function(){var t={};return function(e){return window.Symbol?Symbol(e):(t[e]=t[e]?t[e]+1:0,"__"+e+"$"+t[e])}}(),Ll=function(t){return function(){return function(){return function(){return t}}}},Jl=Bl(qp),Wl=function(){return Jl("paragraph")},ql=Pl(Rl,Wl,Jl),Kl=Fl(Kp),Hl=Pl(Dl,Ll(!1),Kl),Ul=Pl(Dl,Kl,Ll(!1)),Ql=Pl(Il,Ll(!1),Bl(Wp)),Gl=Pl(Il,function(){return function(){return Lp}},Ll(!1)),Xl=Pl(Il,Gl,Ql),Yl=Bl(yl),Zl=Pl(Rl,function(t){return function(e){return function(n,r){var o=n.schema.nodes[t],i=n.tr.replaceSelectionWith(o.createAndFill(e));return r(i.setSelection(da.create(i.doc,n.selection.from))),!0}}},function(t){return function(e){return function(n,r){var o=n.schema.nodes[t],i=n.selection.from;return r(n.tr.insert(i-1,o.createAndFill(e))),!0}}}),tu=ha.Plugin,eu=500,nu={InputRule:function(t,e){this.match=t,this.handler="string"==typeof e?cr(e):e},inputRules:pr,undoInputRule:lr},ru=nu.InputRule,ou=new ru(/--$/,"—"),iu=ou,su=new ru(/\.\.\.$/,"…"),au=su,cu=new ru(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,"“"),pu=cu,lu=new ru(/"$/,"”"),uu=lu,hu=new ru(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,"‘"),fu=hu,du=new ru(/'$/,"’"),mu=[cu,lu,hu,du],vu={emDash:iu,ellipsis:au,openDoubleQuote:pu,closeDoubleQuote:uu,openSingleQuote:fu,closeSingleQuote:du,smartQuotes:mu,allInputRules:[ou,su].concat(mu)},gu=nu.InputRule,yu=Hs.findWrapping,wu=Hs.canJoin,bu={wrappingInputRule:ur,textblockTypeInputRule:hr,blockQuoteRule:fr,orderedListRule:dr,bulletListRule:mr,codeBlockRule:vr,headingRule:gr},ku=t(function(t,e){var n;n=nu,e.InputRule=n.InputRule,e.inputRules=n.inputRules,e.undoInputRule=n.undoInputRule;var r;r=vu,e.emDash=r.emDash,e.ellipsis=r.ellipsis,e.openDoubleQuote=r.openDoubleQuote,e.closeDoubleQuote=r.closeDoubleQuote,e.openSingleQuote=r.openSingleQuote,e.closeSingleQuote=r.closeSingleQuote,e.smartQuotes=r.smartQuotes,e.allInputRules=r.allInputRules;var o;o=bu,e.wrappingInputRule=o.wrappingInputRule,e.textblockTypeInputRule=o.textblockTypeInputRule,e.blockQuoteRule=o.blockQuoteRule,e.orderedListRule=o.orderedListRule,e.bulletListRule=o.bulletListRule,e.codeBlockRule=o.codeBlockRule,e.headingRule=o.headingRule}),Su=ku.inputRules,xu=ku.allInputRules,Mu=ku.orderedListRule,Ou=ku.bulletListRule,Cu="Format",Du=yr({name:"link"}),Tu=yr({name:"bold",keys:"Mod-b"}),Eu=yr({name:"italic",keys:"Mod-i"}),Au=yr({name:"underline",keys:"Mod-u"}),Nu={name:"heading",type:Cu,apply:Jl("heading"),remove:Wl(),toggle:ql("heading"),isApplied:Rl("heading"),isApplicable:function(t){return ql(t)()}("heading"),getMeta:Vl(Al)},Ru={name:"blockquote",type:Cu,apply:Ql("blockquote"),remove:Gl("blockquote"),toggle:Xl("blockquote"),isApplicable:function(t){return Xl(t)()}("blockquote"),isApplied:Il("blockquote")},Iu={name:"list",type:"Input",keymap:{Enter:Yl("list_item")()},isApplied:function(){},isApplicable:function(){},getInputRules:function(t){var e=t.schema,n=Mu(e.nodes.orderedList),r=Ou(e.nodes.unorderedList);return n.match=ir(n.match),r.match=ir(r.match),[n,r]}},Pu={name:"image",type:"Embed",embed:Zl("image"),isApplicable:function(t){return function(e){return _l(1)(e)&&$l(e)||Rl(t)(e)}}("image"),isApplied:Rl("image"),getMeta:Vl(Al)},zu=Object.freeze({link:Du,bold:Tu,italic:Eu,underline:Au,heading:Nu,blockquote:Ru,list:Iu,image:Pu}),Fu=function(t){function e(t){var n=t.definition,r=t.onChange;wl(this,e);var o=n.type,i=n.name,s=n.isApplicable,a=n.isApplied,c=n.getMeta,p=function(t){return{name:i,type:o,applicable:s(t),applied:a(t),meta:c?c(t):null}},l=Ml(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,{key:new ga(i),state:{init:function(t,e){var n=p(e);return r(n),n},apply:function(t,e,n,o){var i=p(o);return or(e,i)?e:(r(i),i)}}}));return l.name=i,l.type=o,l.definition=n,l}return xl(e,t),e}(va),Bu=function(t){var e=t.plugins,n=t.onChange,r=t.schema;return e.map(function(t){var e=zu[t],o=[new Fu({definition:e,onChange:n})];return e.keymap&&o.push(Ep(e.keymap)),e.getInputRules&&o.push(Su({rules:e.getInputRules({schema:r})})),o})},$u="",_u="simpla-text-placeholder",Vu="data-placeholder",ju="\n."+_u+" {\ndisplay: inline-block;\ncursor: text;\n}\n."+_u+"::before {\ncontent: attr("+Vu+");\nopacity: 0.5;\n}",Lu=new ga("placeholder"),Ju=["p","h1","h2"],Wu={doc:{content:"block+"},paragraph:{content:"inline<_>*",group:"block",parseDOM:[{tag:"p"}],toDOM:function(){return["p",0]}},blockquote:{content:"block+",group:"block",defining:!0,parseDOM:[{tag:"blockquote"}],toDOM:function(){return["blockquote",0]}},horizontal_rule:{group:"block",parseDOM:[{tag:"hr"}],toDOM:function(){return["hr"]}},heading:{attrs:{level:{default:1}},content:"inline<_>*",group:"block",defining:!0,parseDOM:[{tag:"h1",attrs:{level:1}},{tag:"h2",attrs:{level:2}},{tag:"h3",attrs:{level:3}},{tag:"h4",attrs:{level:4}},{tag:"h5",attrs:{level:5}},{tag:"h6",attrs:{level:6}}],toDOM:function(t){return["h"+t.attrs.level,0]}},code_block:{content:"text*",group:"block",code:!0,defining:!0,parseDOM:[{tag:"pre",preserveWhitespace:"full"}],toDOM:function(){return["pre",["code",0]]}},text:{group:"inline"},image:{inline:!0,attrs:{src:{},alt:{default:null},title:{default:null}},group:"inline",draggable:!0,parseDOM:[{tag:"img[src]",getAttrs:function(t){return{src:t.getAttribute("src"),title:t.getAttribute("title"),alt:t.getAttribute("alt")}}}],toDOM:function(t){return["img",t.attrs]}},hard_break:{inline:!0,group:"inline",selectable:!1,parseDOM:[{tag:"br"}],toDOM:function(){return["br"]}}},qu=Wu,Ku={link:{attrs:{href:{},title:{default:null}},inclusive:!1,parseDOM:[{tag:"a[href]",getAttrs:function(t){return{href:t.getAttribute("href"),title:t.getAttribute("title")}}}],toDOM:function(t){return["a",t.attrs]}},em:{parseDOM:[{tag:"i"},{tag:"em"},{style:"font-style",getAttrs:function(t){return"italic"==t&&null}}],toDOM:function(){return["em"]}},strong:{parseDOM:[{tag:"strong"},{tag:"b",getAttrs:function(t){return"normal"!=t.style.fontWeight&&null}},{style:"font-weight",getAttrs:function(t){return/^(bold(er)?|[5-9]\d{2,})$/.test(t)&&null}}],toDOM:function(){return["strong"]}},code:{parseDOM:[{tag:"code"}],toDOM:function(){return["code"]}}},Hu=Ku,Uu=(new(0,fi.Schema)({nodes:Wu,marks:Ku}),{content:"list_item+",group:"block"}),Qu={parseDOM:[{tag:"u"},{style:"font-style",getAttrs:function(t){if("underline"===t)return!0}}],toDOM:function(){return["u"]}},Gu={attrs:{src:{},alt:{default:null},title:{default:null},alignment:{default:"center"}},group:"block",draggable:!0,parseDOM:[{tag:"img[src]",getAttrs:function(t){var e={src:t.getAttribute("src"),title:t.getAttribute("title"),alt:t.getAttribute("alt")};return"left"!==t.style.float&&"right"!==t.style.float||(e.alignment=t.style.float),e}}],toDOM:function(t){var e=t.attrs,n=e.src,r=e.alt,o=e.title,i=e.alignment,s="";switch(i){case"center":s="display: block; margin-left: auto; margin-right: auto;";break;case"left":case"right":s="float: "+i+";"}return["img",{src:n,alt:r,title:o,style:s,"data-alignment":i}]}},Xu={marks:{italic:Hu.em}},Yu={marks:{bold:Hu.strong}},Zu={marks:{link:Hu.link}},th={marks:{underline:Qu}},eh={nodes:{blockquote:qu.blockquote}},nh={nodes:{heading:qu.heading}},rh={nodes:{image:Gu}},oh={nodes:{orderedList:Sl({},Uu,ml),unorderedList:Sl({},Uu,vl),list_item:Sl({content:"paragraph block*"},gl)}},ih={nodes:{doc:{content:"inline<_>*"},text:qu.text,hardBreak:qu.hard_break}},sh={nodes:{doc:{content:"block+"},text:qu.text,hardBreak:qu.hard_break,paragraph:qu.paragraph}},ah=Object.freeze({italic:Xu,bold:Yu,link:Zu,underline:th,blockquote:eh,heading:nh,image:rh,list:oh,inline:ih,block:sh}),ch=jl("setup"),ph=jl("view"),lh=jl("parser"),uh=jl("serializer"),hh=jl("emitter"),fh=jl("withPlugin"),dh=jl("editableKey"),mh=jl("inline"),vh=jl("placeholder"),gh=jl("element"),yh=jl("selection"),wh=jl("typographer"),bh=jl("plugins"),kh=jl("selectedPlugins"),Sh=function(){function t(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};wl(this,t);var r=n.plugins,o=void 0===r?[]:r,i=n.inline,s=void 0!==i&&i,a=n.typographer,c=void 0!==a&&a,p=n.placeholder,l=void 0===p?"":p,u=n.editable,h=void 0!==u&&u;this[kh]=o,this[bh]={},this[gh]=e,this[mh]=s,this[wh]=c,this[vh]=l,this[hh]=Fr(),this[ch]({editable:h})}return bl(t,[{key:ch,value:function(){var t=this,e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).editable,n=void 0,r=void 0,o=void 0,i=void 0,s=void 0,a=void 0,c=void 0;s=this[kh],this[bh]=s.reduce(function(t,e){return t[e]={},{}},{}),o=this[hh].emit,r=new di(nr([this.inline?ih:sh].concat(Ol(s.map(function(t){return ah[t]}))))),this[lh]=mi.fromSchema(r),this[uh]=vi.fromSchema(r),n=this[lh].parse(this.element),a=Nr({editable:e||this.editable}),this[dh]=a.key,c=rr([this.typographer?zr():[],a,Bu({schema:r,plugins:s,onChange:function(e){t[bh][e.name]=e,o("plugin",e)}}),Pr({element:this[gh]}),ul(),ar({inline:this.inline}),Er({text:this.placeholder}),Ar({onBlur:function(t){return o("blur",t)},onFocus:function(t){return o("focus",t)},onInput:function(){return o("input")},onSelect:function(e){t[yh]={native:t[ph].root.getSelection(),empty:e.empty},o("select",t[yh])}})]),i=ma.create({doc:n,schema:r,plugins:c}),this[ph]?this[ph].updateState(i):this[ph]=new wp({mount:this.element},{state:i}),this[yh]={native:this[ph].root.getSelection(),empty:i.selection.empty}}},{key:"getSelectionBounds",value:function(){var t=this[ph],e=t.state.selection,n=void 0,r=void 0,o=void 0,i=void 0,s=void 0,a=void 0;if(s=t.coordsAtPos(e.from),a=t.coordsAtPos(e.to),n=Math.min(s.top,a.top),i=Math.max(s.bottom,a.bottom),r=Math.min(s.left,a.left),o=Math.max(s.right,a.right),s.top!==a.top){var c=this.element.getBoundingClientRect();r=c.left,o=c.right}return{top:n,bottom:i,left:r,right:o,height:i-n,width:o-r}}},{key:"on",value:function(t,e){this[hh].on(t,e)}},{key:"off",value:function(t,e){this[hh].off(t,e)}},{key:"focus",value:function(){this[ph].focus()}},{key:"setHTML",value:function(t){var e=document.createElement("div"),n=this[ph],r=this[lh],o=n.state.doc,i=void 0;e.innerHTML=t,i=r.parseSlice(e,{preserveWhitespace:!0}),n.dispatch(n.state.tr.replace(0,o.content.size,i))}},{key:"getHTML",value:function(){var t=this[ph],e=this[uh].serializeFragment(t.state.doc.content),n=document.createElement("div");return n.appendChild(e),n.innerHTML}},{key:"embed",value:function(t,e){this[fh](t,"embed",e)}},{key:"format",value:function(t,e){this[fh](t,"apply",e)}},{key:"removeFormat",value:function(t){this[fh](t,"remove")}},{key:"toggleFormat",value:function(t,e){this[fh](t,"toggle",e)}},{key:"enablePlugins",value:function(t){var e=this[kh],n=void 0;n=function(t){return-1===e.indexOf(t)},this[kh]=t.filter(n).concat(e),this[ch]()}},{key:"disablePlugins",value:function(t){var e=function(e){return-1===t.indexOf(e)};this[kh]=this[kh].filter(e),this[ch]()}},{key:fh,value:function(t,e,n){for(var r=this[ph],o=r.state,i=r.dispatch,s=void 0,a=0,c=o.plugins.length;a<c&&!s;a++)o.plugins[a].name===t&&(s=o.plugins[a].definition);if(!s)throw new Error(s.type+" for '"+t+"' not found");if(!this.plugins[t].applicable)throw new Error(s.type+" not currently applicable");return s[e](n)(o,i)}},{key:"editable",get:function(){return!(!this[ph]||!this[ph].editable)},set:function(t){var e=this[ph].state;this[ph].updateState(e.apply(e.tr.setMeta(this[dh],t)))}},{key:"inline",get:function(){return this[mh]}},{key:"placeholder",get:function(){return this[vh]}},{key:"typographer",get:function(){return this[wh]}},{key:"selection",get:function(){return this[yh]}},{key:"element",get:function(){return this[gh]}},{key:"plugins",get:function(){return this[bh]}}]),t}();window.SimplaBehaviors=window.SimplaBehaviors||{},window.SimplaBehaviors.RichText=Sh}()</script>