@progress/kendo-editor-common 1.12.1 → 1.12.2-develop.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).KendoEditorCommon={})}(this,(function(e){"use strict";function t(e){this.content=e}function n(e,t,o){for(let r=0;;r++){if(r==e.childCount||r==t.childCount)return e.childCount==t.childCount?null:o;let i=e.child(r),s=t.child(r);if(i!=s){if(!i.sameMarkup(s))return o;if(i.isText&&i.text!=s.text){for(let e=0;i.text[e]==s.text[e];e++)o++;return o}if(i.content.size||s.content.size){let e=n(i.content,s.content,o+1);if(null!=e)return e}o+=i.nodeSize}else o+=i.nodeSize}}function o(e,t,n,r){for(let i=e.childCount,s=t.childCount;;){if(0==i||0==s)return i==s?null:{a:n,b:r};let l=e.child(--i),a=t.child(--s),c=l.nodeSize;if(l!=a){if(!l.sameMarkup(a))return{a:n,b:r};if(l.isText&&l.text!=a.text){let e=0,t=Math.min(l.text.length,a.text.length);for(;e<t&&l.text[l.text.length-e-1]==a.text[a.text.length-e-1];)e++,n--,r--;return{a:n,b:r}}if(l.content.size||a.content.size){let e=o(l.content,a.content,n-1,r-1);if(e)return e}n-=c,r-=c}else n-=c,r-=c}}t.prototype={constructor:t,find:function(e){for(var t=0;t<this.content.length;t+=2)if(this.content[t]===e)return t;return-1},get:function(e){var t=this.find(e);return-1==t?void 0:this.content[t+1]},update:function(e,n,o){var r=o&&o!=e?this.remove(o):this,i=r.find(e),s=r.content.slice();return-1==i?s.push(o||e,n):(s[i+1]=n,o&&(s[i]=o)),new t(s)},remove:function(e){var n=this.find(e);if(-1==n)return this;var o=this.content.slice();return o.splice(n,2),new t(o)},addToStart:function(e,n){return new t([e,n].concat(this.remove(e).content))},addToEnd:function(e,n){var o=this.remove(e).content.slice();return o.push(e,n),new t(o)},addBefore:function(e,n,o){var r=this.remove(n),i=r.content.slice(),s=r.find(e);return i.splice(-1==s?i.length:s,0,n,o),new t(i)},forEach:function(e){for(var t=0;t<this.content.length;t+=2)e(this.content[t],this.content[t+1])},prepend:function(e){return(e=t.from(e)).size?new t(e.content.concat(this.subtract(e).content)):this},append:function(e){return(e=t.from(e)).size?new t(this.subtract(e).content.concat(e.content)):this},subtract:function(e){var n=this;e=t.from(e);for(var o=0;o<e.content.length;o+=2)n=n.remove(e.content[o]);return n},toObject:function(){var e={};return this.forEach((function(t,n){e[t]=n})),e},get size(){return this.content.length>>1}},t.from=function(e){if(e instanceof t)return e;var n=[];if(e)for(var o in e)n.push(o,e[o]);return new t(n)};class r{constructor(e,t){if(this.content=e,this.size=t||0,null==t)for(let t=0;t<e.length;t++)this.size+=e[t].nodeSize}nodesBetween(e,t,n,o=0,r){for(let i=0,s=0;s<t;i++){let l=this.content[i],a=s+l.nodeSize;if(a>e&&!1!==n(l,o+s,r||null,i)&&l.content.size){let r=s+1;l.nodesBetween(Math.max(0,e-r),Math.min(l.content.size,t-r),n,o+r)}s=a}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,n,o){let r="",i=!0;return this.nodesBetween(e,t,((s,l)=>{let a=s.isText?s.text.slice(Math.max(e,l)-l,t-l):s.isLeaf?o?"function"==typeof o?o(s):o:s.type.spec.leafText?s.type.spec.leafText(s):"":"";s.isBlock&&(s.isLeaf&&a||s.isTextblock)&&n&&(i?i=!1:r+=n),r+=a}),0),r}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,n=e.firstChild,o=this.content.slice(),i=0;for(t.isText&&t.sameMarkup(n)&&(o[o.length-1]=t.withText(t.text+n.text),i=1);i<e.content.length;i++)o.push(e.content[i]);return new r(o,this.size+e.size)}cut(e,t=this.size){if(0==e&&t==this.size)return this;let n=[],o=0;if(t>e)for(let r=0,i=0;i<t;r++){let s=this.content[r],l=i+s.nodeSize;l>e&&((i<e||l>t)&&(s=s.isText?s.cut(Math.max(0,e-i),Math.min(s.text.length,t-i)):s.cut(Math.max(0,e-i-1),Math.min(s.content.size,t-i-1))),n.push(s),o+=s.nodeSize),i=l}return new r(n,o)}cutByIndex(e,t){return e==t?r.empty:0==e&&t==this.content.length?this:new r(this.content.slice(e,t))}replaceChild(e,t){let n=this.content[e];if(n==t)return this;let o=this.content.slice(),i=this.size+t.nodeSize-n.nodeSize;return o[e]=t,new r(o,i)}addToStart(e){return new r([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new r(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw new RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,n=0;t<this.content.length;t++){let o=this.content[t];e(o,n,t),n+=o.nodeSize}}findDiffStart(e,t=0){return n(this,e,t)}findDiffEnd(e,t=this.size,n=e.size){return o(this,e,t,n)}findIndex(e,t=-1){if(0==e)return s(0,e);if(e==this.size)return s(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let n=0,o=0;;n++){let r=o+this.child(n).nodeSize;if(r>=e)return r==e||t>0?s(n+1,r):s(n,o);o=r}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map((e=>e.toJSON())):null}static fromJSON(e,t){if(!t)return r.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new r(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return r.empty;let t,n=0;for(let o=0;o<e.length;o++){let r=e[o];n+=r.nodeSize,o&&r.isText&&e[o-1].sameMarkup(r)?(t||(t=e.slice(0,o)),t[t.length-1]=r.withText(t[t.length-1].text+r.text)):t&&t.push(r)}return new r(t||e,n)}static from(e){if(!e)return r.empty;if(e instanceof r)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new r([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}r.empty=new r([],0);const i={index:0,offset:0};function s(e,t){return i.index=e,i.offset=t,i}function l(e,t){if(e===t)return!0;if(!e||"object"!=typeof e||!t||"object"!=typeof t)return!1;let n=Array.isArray(e);if(Array.isArray(t)!=n)return!1;if(n){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!l(e[n],t[n]))return!1}else{for(let n in e)if(!(n in t)||!l(e[n],t[n]))return!1;for(let n in t)if(!(n in e))return!1}return!0}class a{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,n=!1;for(let o=0;o<e.length;o++){let r=e[o];if(this.eq(r))return e;if(this.type.excludes(r.type))t||(t=e.slice(0,o));else{if(r.type.excludes(this.type))return e;!n&&r.type.rank>this.type.rank&&(t||(t=e.slice(0,o)),t.push(this),n=!0),t&&t.push(r)}}return t||(t=e.slice()),n||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&l(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Mark.fromJSON");let n=e.marks[t.type];if(!n)throw new RangeError(`There is no mark type ${t.type} in this schema`);let o=n.create(t.attrs);return n.checkAttrs(o.attrs),o}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].eq(t[n]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&0==e.length)return a.none;if(e instanceof a)return[e];let t=e.slice();return t.sort(((e,t)=>e.type.rank-t.type.rank)),t}}a.none=[];class c extends Error{}class d{constructor(e,t,n){this.content=e,this.openStart=t,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let n=p(this.content,e+this.openStart,t);return n&&new d(n,this.openStart,this.openEnd)}removeBetween(e,t){return new d(h(this.content,e+this.openStart,t+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,t){if(!t)return d.empty;let n=t.openStart||0,o=t.openEnd||0;if("number"!=typeof n||"number"!=typeof o)throw new RangeError("Invalid input for Slice.fromJSON");return new d(r.fromJSON(e,t.content),n,o)}static maxOpen(e,t=!0){let n=0,o=0;for(let o=e.firstChild;o&&!o.isLeaf&&(t||!o.type.spec.isolating);o=o.firstChild)n++;for(let n=e.lastChild;n&&!n.isLeaf&&(t||!n.type.spec.isolating);n=n.lastChild)o++;return new d(e,n,o)}}function h(e,t,n){let{index:o,offset:r}=e.findIndex(t),i=e.maybeChild(o),{index:s,offset:l}=e.findIndex(n);if(r==t||i.isText){if(l!=n&&!e.child(s).isText)throw new RangeError("Removing non-flat range");return e.cut(0,t).append(e.cut(n))}if(o!=s)throw new RangeError("Removing non-flat range");return e.replaceChild(o,i.copy(h(i.content,t-r-1,n-r-1)))}function p(e,t,n,o){let{index:r,offset:i}=e.findIndex(t),s=e.maybeChild(r);if(i==t||s.isText)return e.cut(0,t).append(n).append(e.cut(t));let l=p(s.content,t-i-1,n);return l&&e.replaceChild(r,s.copy(l))}function u(e,t,n){if(n.openStart>e.depth)throw new c("Inserted content deeper than insertion position");if(e.depth-n.openStart!=t.depth-n.openEnd)throw new c("Inconsistent open depths");return f(e,t,n,0)}function f(e,t,n,o){let i=e.index(o),s=e.node(o);if(i==t.index(o)&&o<e.depth-n.openStart){let r=f(e,t,n,o+1);return s.copy(s.content.replaceChild(i,r))}if(n.content.size){if(n.openStart||n.openEnd||e.depth!=o||t.depth!=o){let{start:i,end:l}=function(e,t){let n=t.depth-e.openStart,o=t.node(n).copy(e.content);for(let e=n-1;e>=0;e--)o=t.node(e).copy(r.from(o));return{start:o.resolveNoCache(e.openStart+n),end:o.resolveNoCache(o.content.size-e.openEnd-n)}}(n,e);return v(s,b(e,i,l,t,o))}{let o=e.parent,r=o.content;return v(o,r.cut(0,e.parentOffset).append(n.content).append(r.cut(t.parentOffset)))}}return v(s,k(e,t,o))}function m(e,t){if(!t.type.compatibleContent(e.type))throw new c("Cannot join "+t.type.name+" onto "+e.type.name)}function g(e,t,n){let o=e.node(n);return m(o,t.node(n)),o}function y(e,t){let n=t.length-1;n>=0&&e.isText&&e.sameMarkup(t[n])?t[n]=e.withText(t[n].text+e.text):t.push(e)}function w(e,t,n,o){let r=(t||e).node(n),i=0,s=t?t.index(n):r.childCount;e&&(i=e.index(n),e.depth>n?i++:e.textOffset&&(y(e.nodeAfter,o),i++));for(let e=i;e<s;e++)y(r.child(e),o);t&&t.depth==n&&t.textOffset&&y(t.nodeBefore,o)}function v(e,t){return e.type.checkContent(t),e.copy(t)}function b(e,t,n,o,i){let s=e.depth>i&&g(e,t,i+1),l=o.depth>i&&g(n,o,i+1),a=[];return w(null,e,i,a),s&&l&&t.index(i)==n.index(i)?(m(s,l),y(v(s,b(e,t,n,o,i+1)),a)):(s&&y(v(s,k(e,t,i+1)),a),w(t,n,i,a),l&&y(v(l,k(n,o,i+1)),a)),w(o,null,i,a),new r(a)}function k(e,t,n){let o=[];if(w(null,e,n,o),e.depth>n){y(v(g(e,t,n+1),k(e,t,n+1)),o)}return w(t,null,n,o),new r(o)}d.empty=new d(r.empty,0,0);class x{constructor(e,t,n){this.pos=e,this.path=t,this.parentOffset=n,this.depth=t.length/3-1}resolveDepth(e){return null==e?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[3*this.resolveDepth(e)]}index(e){return this.path[3*this.resolveDepth(e)+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e!=this.depth||this.textOffset?1:0)}start(e){return 0==(e=this.resolveDepth(e))?0:this.path[3*e-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(!(e=this.resolveDepth(e)))throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[3*e-1]}after(e){if(!(e=this.resolveDepth(e)))throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[3*e-1]+this.path[3*e].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let n=this.pos-this.path[this.path.length-1],o=e.child(t);return n?e.child(t).cut(n):o}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):0==e?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let n=this.path[3*t],o=0==t?0:this.path[3*t-1]+1;for(let t=0;t<e;t++)o+=n.child(t).nodeSize;return o}marks(){let e=this.parent,t=this.index();if(0==e.content.size)return a.none;if(this.textOffset)return e.child(t).marks;let n=e.maybeChild(t-1),o=e.maybeChild(t);if(!n){let e=n;n=o,o=e}let r=n.marks;for(var i=0;i<r.length;i++)!1!==r[i].type.spec.inclusive||o&&r[i].isInSet(o.marks)||(r=r[i--].removeFromSet(r));return r}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let n=t.marks,o=e.parent.maybeChild(e.index());for(var r=0;r<n.length;r++)!1!==n[r].type.spec.inclusive||o&&n[r].isInSet(o.marks)||(n=n[r--].removeFromSet(n));return n}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let n=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);n>=0;n--)if(e.pos<=this.end(n)&&(!t||t(this.node(n))))return new N(this,e,n);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset}static resolve(e,t){if(!(t>=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let n=[],o=0,r=t;for(let t=e;;){let{index:e,offset:i}=t.content.findIndex(r),s=r-i;if(n.push(t,e,o+i),!s)break;if(t=t.child(e),t.isText)break;r=s-1,o+=i+1}return new x(t,n,r)}static resolveCached(e,t){let n=M.get(e);if(n)for(let e=0;e<n.elts.length;e++){let o=n.elts[e];if(o.pos==t)return o}else M.set(e,n=new S);let o=n.elts[n.i]=x.resolve(e,t);return n.i=(n.i+1)%C,o}}class S{constructor(){this.elts=[],this.i=0}}const C=12,M=new WeakMap;class N{constructor(e,t,n){this.$from=e,this.$to=t,this.depth=n}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const O=Object.create(null);let A=class e{constructor(e,t,n,o=a.none){this.type=e,this.attrs=t,this.marks=o,this.content=n||r.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,n,o=0){this.content.nodesBetween(e,t,n,o,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,t,n,o){return this.content.textBetween(e,t,n,o)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,n){return this.type==e&&l(this.attrs,t||e.defaultAttrs||O)&&a.sameSet(this.marks,n||a.none)}copy(t=null){return t==this.content?this:new e(this.type,this.attrs,t,this.marks)}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.content,t)}cut(e,t=this.content.size){return 0==e&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,n=!1){if(e==t)return d.empty;let o=this.resolve(e),r=this.resolve(t),i=n?0:o.sharedDepth(t),s=o.start(i),l=o.node(i).content.cut(o.pos-s,r.pos-s);return new d(l,o.depth-i,r.depth-i)}replace(e,t,n){return u(this.resolve(e),this.resolve(t),n)}nodeAt(e){for(let t=this;;){let{index:n,offset:o}=t.content.findIndex(e);if(t=t.maybeChild(n),!t)return null;if(o==e||t.isText)return t;e-=o+1}}childAfter(e){let{index:t,offset:n}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:n}}childBefore(e){if(0==e)return{node:null,index:0,offset:0};let{index:t,offset:n}=this.content.findIndex(e);if(n<e)return{node:this.content.child(t),index:t,offset:n};let o=this.content.child(t-1);return{node:o,index:t-1,offset:n-o.nodeSize}}resolve(e){return x.resolveCached(this,e)}resolveNoCache(e){return x.resolve(this,e)}rangeHasMark(e,t,n){let o=!1;return t>e&&this.nodesBetween(e,t,(e=>(n.isInSet(e.marks)&&(o=!0),!o))),o}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),D(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,n=r.empty,o=0,i=n.childCount){let s=this.contentMatchAt(e).matchFragment(n,o,i),l=s&&s.matchFragment(this.content,t);if(!l||!l.validEnd)return!1;for(let e=o;e<i;e++)if(!this.type.allowsMarks(n.child(e).marks))return!1;return!0}canReplaceWith(e,t,n,o){if(o&&!this.type.allowsMarks(o))return!1;let r=this.contentMatchAt(e).matchType(n),i=r&&r.matchFragment(this.content,t);return!!i&&i.validEnd}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=a.none;for(let t=0;t<this.marks.length;t++){let n=this.marks[t];n.type.checkAttrs(n.attrs),e=n.addToSet(e)}if(!a.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map((e=>e.type.name))}`);this.content.forEach((e=>e.check()))}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map((e=>e.toJSON()))),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let n;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");n=t.marks.map(e.markFromJSON)}if("text"==t.type){if("string"!=typeof t.text)throw new RangeError("Invalid text node in JSON");return e.text(t.text,n)}let o=r.fromJSON(e,t.content),i=e.nodeType(t.type).create(t.attrs,o,n);return i.type.checkAttrs(i.attrs),i}};A.prototype.text=void 0;class T extends A{constructor(e,t,n,o){if(super(e,t,null,o),!n)throw new RangeError("Empty text nodes are not allowed");this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):D(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new T(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new T(this.type,this.attrs,e,this.marks)}cut(e=0,t=this.text.length){return 0==e&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function D(e,t){for(let n=e.length-1;n>=0;n--)t=e[n].type.name+"("+t+")";return t}class E{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let n=new R(e,t);if(null==n.next)return E.empty;let o=$(n);n.next&&n.err("Unexpected trailing text");let r=function(e){let t=Object.create(null);return n(F(e,0));function n(o){let r=[];o.forEach((t=>{e[t].forEach((({term:t,to:n})=>{if(!t)return;let o;for(let e=0;e<r.length;e++)r[e][0]==t&&(o=r[e][1]);F(e,n).forEach((e=>{o||r.push([t,o=[]]),-1==o.indexOf(e)&&o.push(e)}))}))}));let i=t[o.join(",")]=new E(o.indexOf(e.length-1)>-1);for(let e=0;e<r.length;e++){let o=r[e][1].sort(V);i.next.push({type:r[e][0],next:t[o.join(",")]||n(o)})}return i}}(function(e){let t=[[]];return r(i(e,0),n()),t;function n(){return t.push([])-1}function o(e,n,o){let r={term:o,to:n};return t[e].push(r),r}function r(e,t){e.forEach((e=>e.to=t))}function i(e,t){if("choice"==e.type)return e.exprs.reduce(((e,n)=>e.concat(i(n,t))),[]);if("seq"!=e.type){if("star"==e.type){let s=n();return o(t,s),r(i(e.expr,s),s),[o(s)]}if("plus"==e.type){let s=n();return r(i(e.expr,t),s),r(i(e.expr,s),s),[o(s)]}if("opt"==e.type)return[o(t)].concat(i(e.expr,t));if("range"==e.type){let s=t;for(let t=0;t<e.min;t++){let t=n();r(i(e.expr,s),t),s=t}if(-1==e.max)r(i(e.expr,s),s);else for(let t=e.min;t<e.max;t++){let t=n();o(s,t),r(i(e.expr,s),t),s=t}return[o(s)]}if("name"==e.type)return[o(t,void 0,e.value)];throw new Error("Unknown expr type")}for(let o=0;;o++){let s=i(e.exprs[o],t);if(o==e.exprs.length-1)return s;r(s,t=n())}}}(o));return function(e,t){for(let n=0,o=[e];n<o.length;n++){let e=o[n],r=!e.validEnd,i=[];for(let t=0;t<e.next.length;t++){let{type:n,next:s}=e.next[t];i.push(n.name),!r||n.isText||n.hasRequiredAttrs()||(r=!1),-1==o.indexOf(s)&&o.push(s)}r&&t.err("Only non-generatable nodes ("+i.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}(r,n),r}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,n=e.childCount){let o=this;for(let r=t;o&&r<n;r++)o=o.matchType(e.child(r).type);return o}get inlineContent(){return 0!=this.next.length&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!t.isText&&!t.hasRequiredAttrs())return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let n=0;n<e.next.length;n++)if(this.next[t].type==e.next[n].type)return!0;return!1}fillBefore(e,t=!1,n=0){let o=[this];return function i(s,l){let a=s.matchFragment(e,n);if(a&&(!t||a.validEnd))return r.from(l.map((e=>e.createAndFill())));for(let e=0;e<s.next.length;e++){let{type:t,next:n}=s.next[e];if(!t.isText&&!t.hasRequiredAttrs()&&-1==o.indexOf(n)){o.push(n);let e=i(n,l.concat(t));if(e)return e}}return null}(this,[])}findWrapping(e){for(let t=0;t<this.wrapCache.length;t+=2)if(this.wrapCache[t]==e)return this.wrapCache[t+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),n=[{match:this,type:null,via:null}];for(;n.length;){let o=n.shift(),r=o.match;if(r.matchType(e)){let e=[];for(let t=o;t.type;t=t.via)e.push(t.type);return e.reverse()}for(let e=0;e<r.next.length;e++){let{type:i,next:s}=r.next[e];i.isLeaf||i.hasRequiredAttrs()||i.name in t||o.type&&!s.validEnd||(n.push({match:i.contentMatch,type:i,via:o}),t[i.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];return function t(n){e.push(n);for(let o=0;o<n.next.length;o++)-1==e.indexOf(n.next[o].next)&&t(n.next[o].next)}(this),e.map(((t,n)=>{let o=n+(t.validEnd?"*":" ")+" ";for(let n=0;n<t.next.length;n++)o+=(n?", ":"")+t.next[n].type.name+"->"+e.indexOf(t.next[n].next);return o})).join("\n")}}E.empty=new E(!0);class R{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),""==this.tokens[this.tokens.length-1]&&this.tokens.pop(),""==this.tokens[0]&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}function $(e){let t=[];do{t.push(I(e))}while(e.eat("|"));return 1==t.length?t[0]:{type:"choice",exprs:t}}function I(e){let t=[];do{t.push(z(e))}while(e.next&&")"!=e.next&&"|"!=e.next);return 1==t.length?t[0]:{type:"seq",exprs:t}}function z(e){let t=function(e){if(e.eat("(")){let t=$(e);return e.eat(")")||e.err("Missing closing paren"),t}if(!/\W/.test(e.next)){let t=function(e,t){let n=e.nodeTypes,o=n[t];if(o)return[o];let r=[];for(let e in n){let o=n[e];o.isInGroup(t)&&r.push(o)}0==r.length&&e.err("No node type or group '"+t+"' found");return r}(e,e.next).map((t=>(null==e.inline?e.inline=t.isInline:e.inline!=t.isInline&&e.err("Mixing inline and block content"),{type:"name",value:t})));return e.pos++,1==t.length?t[0]:{type:"choice",exprs:t}}e.err("Unexpected token '"+e.next+"'")}(e);for(;;)if(e.eat("+"))t={type:"plus",expr:t};else if(e.eat("*"))t={type:"star",expr:t};else if(e.eat("?"))t={type:"opt",expr:t};else{if(!e.eat("{"))break;t=P(e,t)}return t}function B(e){/\D/.test(e.next)&&e.err("Expected number, got '"+e.next+"'");let t=Number(e.next);return e.pos++,t}function P(e,t){let n=B(e),o=n;return e.eat(",")&&(o="}"!=e.next?B(e):-1),e.eat("}")||e.err("Unclosed braced range"),{type:"range",min:n,max:o,expr:t}}function V(e,t){return t-e}function F(e,t){let n=[];return function t(o){let r=e[o];if(1==r.length&&!r[0].term)return t(r[0].to);n.push(o);for(let e=0;e<r.length;e++){let{term:o,to:i}=r[e];o||-1!=n.indexOf(i)||t(i)}}(t),n.sort(V)}function L(e){let t=Object.create(null);for(let n in e){let o=e[n];if(!o.hasDefault)return null;t[n]=o.default}return t}function H(e,t){let n=Object.create(null);for(let o in e){let r=t&&t[o];if(void 0===r){let t=e[o];if(!t.hasDefault)throw new RangeError("No value supplied for attribute "+o);r=t.default}n[o]=r}return n}function _(e,t,n,o){for(let o in t)if(!(o in e))throw new RangeError(`Unsupported attribute ${o} for ${n} of type ${o}`);for(let n in e){let o=e[n];o.validate&&o.validate(t[n])}}function W(e,t){let n=Object.create(null);if(t)for(let o in t)n[o]=new J(e,o,t[o]);return n}let q=class e{constructor(e,t,n){this.name=e,this.schema=t,this.spec=n,this.markSet=null,this.groups=n.group?n.group.split(" "):[],this.attrs=W(e,n.attrs),this.defaultAttrs=L(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(n.inline||"text"==e),this.isText="text"==e}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==E.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:H(this.attrs,e)}create(e=null,t,n){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new A(this,this.computeAttrs(e),r.from(t),a.setFrom(n))}createChecked(e=null,t,n){return t=r.from(t),this.checkContent(t),new A(this,this.computeAttrs(e),t,a.setFrom(n))}createAndFill(e=null,t,n){if(e=this.computeAttrs(e),(t=r.from(t)).size){let e=this.contentMatch.fillBefore(t);if(!e)return null;t=e.append(t)}let o=this.contentMatch.matchFragment(t),i=o&&o.fillBefore(r.empty,!0);return i?new A(this,e,t.append(i),a.setFrom(n)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let t=0;t<e.childCount;t++)if(!this.allowsMarks(e.child(t).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){_(this.attrs,e,"node",this.name)}allowsMarkType(e){return null==this.markSet||this.markSet.indexOf(e)>-1}allowsMarks(e){if(null==this.markSet)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(null==this.markSet)return e;let t;for(let n=0;n<e.length;n++)this.allowsMarkType(e[n].type)?t&&t.push(e[n]):t||(t=e.slice(0,n));return t?t.length?t:a.none:e}static compile(t,n){let o=Object.create(null);t.forEach(((t,r)=>o[t]=new e(t,n,r)));let r=n.spec.topNode||"doc";if(!o[r])throw new RangeError("Schema is missing its top node type ('"+r+"')");if(!o.text)throw new RangeError("Every schema needs a 'text' type");for(let e in o.text.attrs)throw new RangeError("The text node type should not have attributes");return o}};class J{constructor(e,t,n){this.hasDefault=Object.prototype.hasOwnProperty.call(n,"default"),this.default=n.default,this.validate="string"==typeof n.validate?function(e,t,n){let o=n.split("|");return n=>{let r=null===n?"null":typeof n;if(o.indexOf(r)<0)throw new RangeError(`Expected value of type ${o} for attribute ${t} on type ${e}, got ${r}`)}}(e,t,n.validate):n.validate}get isRequired(){return!this.hasDefault}}class j{constructor(e,t,n,o){this.name=e,this.rank=t,this.schema=n,this.spec=o,this.attrs=W(e,o.attrs),this.excluded=null;let r=L(this.attrs);this.instance=r?new a(this,r):null}create(e=null){return!e&&this.instance?this.instance:new a(this,H(this.attrs,e))}static compile(e,t){let n=Object.create(null),o=0;return e.forEach(((e,r)=>n[e]=new j(e,o++,t,r))),n}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}checkAttrs(e){_(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class K{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let n=this.spec={};for(let t in e)n[t]=e[t];n.nodes=t.from(e.nodes),n.marks=t.from(e.marks||{}),this.nodes=q.compile(this.spec.nodes,this),this.marks=j.compile(this.spec.marks,this);let o=Object.create(null);for(let e in this.nodes){if(e in this.marks)throw new RangeError(e+" can not be both a node and a mark");let t=this.nodes[e],n=t.spec.content||"",r=t.spec.marks;if(t.contentMatch=o[n]||(o[n]=E.parse(n,this.nodes)),t.inlineContent=t.contentMatch.inlineContent,t.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!t.isInline||!t.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=t}t.markSet="_"==r?null:r?X(this,r.split(" ")):""!=r&&t.inlineContent?null:[]}for(let e in this.marks){let t=this.marks[e],n=t.spec.excludes;t.excluded=null==n?[t]:""==n?[]:X(this,n.split(" "))}this.nodeFromJSON=this.nodeFromJSON.bind(this),this.markFromJSON=this.markFromJSON.bind(this),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,n,o){if("string"==typeof e)e=this.nodeType(e);else{if(!(e instanceof q))throw new RangeError("Invalid node type: "+e);if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}return e.createChecked(t,n,o)}text(e,t){let n=this.nodes.text;return new T(n,n.defaultAttrs,e,a.setFrom(t))}mark(e,t){return"string"==typeof e&&(e=this.marks[e]),e.create(t)}nodeFromJSON(e){return A.fromJSON(this,e)}markFromJSON(e){return a.fromJSON(this,e)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}}function X(e,t){let n=[];for(let o=0;o<t.length;o++){let r=t[o],i=e.marks[r],s=i;if(i)n.push(i);else for(let t in e.marks){let o=e.marks[t];("_"==r||o.spec.group&&o.spec.group.split(" ").indexOf(r)>-1)&&n.push(s=o)}if(!s)throw new SyntaxError("Unknown mark type: '"+t[o]+"'")}return n}class U{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let n=this.matchedStyles=[];t.forEach((e=>{if(function(e){return null!=e.tag}(e))this.tags.push(e);else if(function(e){return null!=e.style}(e)){let t=/[^=]*/.exec(e.style)[0];n.indexOf(t)<0&&n.push(t),this.styles.push(e)}})),this.normalizeLists=!this.tags.some((t=>{if(!/^(ul|ol)\b/.test(t.tag)||!t.node)return!1;let n=e.nodes[t.node];return n.contentMatch.matchType(n)}))}parse(e,t={}){let n=new te(this,t,!1);return n.addAll(e,a.none,t.from,t.to),n.finish()}parseSlice(e,t={}){let n=new te(this,t,!0);return n.addAll(e,a.none,t.from,t.to),d.maxOpen(n.finish())}matchTag(e,t,n){for(let o=n?this.tags.indexOf(n)+1:0;o<this.tags.length;o++){let n=this.tags[o];if(ne(e,n.tag)&&(void 0===n.namespace||e.namespaceURI==n.namespace)&&(!n.context||t.matchesContext(n.context))){if(n.getAttrs){let t=n.getAttrs(e);if(!1===t)continue;n.attrs=t||void 0}return n}}}matchStyle(e,t,n,o){for(let r=o?this.styles.indexOf(o)+1:0;r<this.styles.length;r++){let o=this.styles[r],i=o.style;if(!(0!=i.indexOf(e)||o.context&&!n.matchesContext(o.context)||i.length>e.length&&(61!=i.charCodeAt(e.length)||i.slice(e.length+1)!=t))){if(o.getAttrs){let e=o.getAttrs(t);if(!1===e)continue;o.attrs=e||void 0}return o}}}static schemaRules(e){let t=[];function n(e){let n=null==e.priority?50:e.priority,o=0;for(;o<t.length;o++){let e=t[o];if((null==e.priority?50:e.priority)<n)break}t.splice(o,0,e)}for(let t in e.marks){let o=e.marks[t].spec.parseDOM;o&&o.forEach((e=>{n(e=oe(e)),e.mark||e.ignore||e.clearMark||(e.mark=t)}))}for(let t in e.nodes){let o=e.nodes[t].spec.parseDOM;o&&o.forEach((e=>{n(e=oe(e)),e.node||e.ignore||e.mark||(e.node=t)}))}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new U(e,U.schemaRules(e)))}}const G={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},Y={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Q={ol:!0,ul:!0};function Z(e,t,n){return null!=t?(t?1:0)|("full"===t?2:0):e&&"pre"==e.whitespace?3:-5&n}class ee{constructor(e,t,n,o,r,i){this.type=e,this.attrs=t,this.marks=n,this.solid=o,this.options=i,this.content=[],this.activeMarks=a.none,this.match=r||(4&i?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(r.from(e));if(!t){let t,n=this.type.contentMatch;return(t=n.findWrapping(e.type))?(this.match=n,t):null}this.match=this.type.contentMatch.matchFragment(t)}return this.match.findWrapping(e.type)}finish(e){if(!(1&this.options)){let e,t=this.content[this.content.length-1];if(t&&t.isText&&(e=/[ \t\r\n\u000c]+$/.exec(t.text))){let n=t;t.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))}}let t=r.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(r.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!G.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class te{constructor(e,t,n){this.parser=e,this.options=t,this.isOpen=n,this.open=0,this.localPreserveWS=!1;let o,r=t.topNode,i=Z(null,t.preserveWhitespace,0)|(n?4:0);o=r?new ee(r.type,r.attrs,a.none,!0,t.topMatch||r.type.contentMatch,i):new ee(n?null:e.schema.topNodeType,null,a.none,!0,null,i),this.nodes=[o],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){3==e.nodeType?this.addTextNode(e,t):1==e.nodeType&&this.addElement(e,t)}addTextNode(e,t){let n=e.nodeValue,o=this.top,r=2&o.options?"full":this.localPreserveWS||(1&o.options)>0;if("full"===r||o.inlineContext(e)||/[^ \t\r\n\u000c]/.test(n)){if(r)n="full"!==r?n.replace(/\r?\n|\r/g," "):n.replace(/\r\n?/g,"\n");else if(n=n.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(n)&&this.open==this.nodes.length-1){let t=o.content[o.content.length-1],r=e.previousSibling;(!t||r&&"BR"==r.nodeName||t.isText&&/[ \t\r\n\u000c]$/.test(t.text))&&(n=n.slice(1))}n&&this.insertNode(this.parser.schema.text(n),t),this.findInText(e)}else this.findInside(e)}addElement(e,t,n){let o=this.localPreserveWS,r=this.top;("PRE"==e.tagName||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let i,s=e.nodeName.toLowerCase();Q.hasOwnProperty(s)&&this.parser.normalizeLists&&function(e){for(let t=e.firstChild,n=null;t;t=t.nextSibling){let e=1==t.nodeType?t.nodeName.toLowerCase():null;e&&Q.hasOwnProperty(e)&&n?(n.appendChild(t),t=n):"li"==e?n=t:e&&(n=null)}}(e);let l=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(i=this.parser.matchTag(e,this,n));e:if(l?l.ignore:Y.hasOwnProperty(s))this.findInside(e),this.ignoreFallback(e,t);else if(!l||l.skip||l.closeParent){l&&l.closeParent?this.open=Math.max(0,this.open-1):l&&l.skip.nodeType&&(e=l.skip);let n,o=this.needsBlock;if(G.hasOwnProperty(s))r.content.length&&r.content[0].isInline&&this.open&&(this.open--,r=this.top),n=!0,r.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break e}let i=l&&l.skip?t:this.readStyles(e,t);i&&this.addAll(e,i),n&&this.sync(r),this.needsBlock=o}else{let n=this.readStyles(e,t);n&&this.addElementByRule(e,l,n,!1===l.consuming?i:void 0)}this.localPreserveWS=o}leafFallback(e,t){"BR"==e.nodeName&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode("\n"),t)}ignoreFallback(e,t){"BR"!=e.nodeName||this.top.type&&this.top.type.inlineContent||this.findPlace(this.parser.schema.text("-"),t)}readStyles(e,t){let n=e.style;if(n&&n.length)for(let e=0;e<this.parser.matchedStyles.length;e++){let o=this.parser.matchedStyles[e],r=n.getPropertyValue(o);if(r)for(let e;;){let n=this.parser.matchStyle(o,r,this,e);if(!n)break;if(n.ignore)return null;if(t=n.clearMark?t.filter((e=>!n.clearMark(e))):t.concat(this.parser.schema.marks[n.mark].create(n.attrs)),!1!==n.consuming)break;e=n}}return t}addElementByRule(e,t,n,o){let r,i;if(t.node)if(i=this.parser.schema.nodes[t.node],i.isLeaf)this.insertNode(i.create(t.attrs),n)||this.leafFallback(e,n);else{let e=this.enter(i,t.attrs||null,n,t.preserveWhitespace);e&&(r=!0,n=e)}else{let e=this.parser.schema.marks[t.mark];n=n.concat(e.create(t.attrs))}let s=this.top;if(i&&i.isLeaf)this.findInside(e);else if(o)this.addElement(e,n,o);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach((e=>this.insertNode(e,n)));else{let o=e;"string"==typeof t.contentElement?o=e.querySelector(t.contentElement):"function"==typeof t.contentElement?o=t.contentElement(e):t.contentElement&&(o=t.contentElement),this.findAround(e,o,!0),this.addAll(o,n),this.findAround(e,o,!1)}r&&this.sync(s)&&this.open--}addAll(e,t,n,o){let r=n||0;for(let i=n?e.childNodes[n]:e.firstChild,s=null==o?null:e.childNodes[o];i!=s;i=i.nextSibling,++r)this.findAtPoint(e,r),this.addDOM(i,t);this.findAtPoint(e,r)}findPlace(e,t){let n,o;for(let t=this.open;t>=0;t--){let r=this.nodes[t],i=r.findWrapping(e);if(i&&(!n||n.length>i.length)&&(n=i,o=r,!i.length))break;if(r.solid)break}if(!n)return null;this.sync(o);for(let e=0;e<n.length;e++)t=this.enterInner(n[e],null,t,!1);return t}insertNode(e,t){if(e.isInline&&this.needsBlock&&!this.top.type){let e=this.textblockFromContext();e&&(t=this.enterInner(e,null,t))}let n=this.findPlace(e,t);if(n){this.closeExtra();let t=this.top;t.match&&(t.match=t.match.matchType(e.type));let o=a.none;for(let r of n.concat(e.marks))(t.type?t.type.allowsMarkType(r.type):re(r.type,e.type))&&(o=r.addToSet(o));return t.content.push(e.mark(o)),!0}return!1}enter(e,t,n,o){let r=this.findPlace(e.create(t),n);return r&&(r=this.enterInner(e,t,n,!0,o)),r}enterInner(e,t,n,o=!1,r){this.closeExtra();let i=this.top;i.match=i.match&&i.match.matchType(e);let s=Z(e,r,i.options);4&i.options&&0==i.content.length&&(s|=4);let l=a.none;return n=n.filter((t=>!(i.type?i.type.allowsMarkType(t.type):re(t.type,e))||(l=t.addToSet(l),!1))),this.nodes.push(new ee(e,t,l,o,null,s)),this.open++,n}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!(!this.isOpen&&!this.options.topOpen))}sync(e){for(let t=this.open;t>=0;t--){if(this.nodes[t]==e)return this.open=t,!0;this.localPreserveWS&&(this.nodes[t].options|=1)}return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let n=this.nodes[t].content;for(let t=n.length-1;t>=0;t--)e+=n[t].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&this.find[n].offset==t&&(this.find[n].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)null==this.find[t].pos&&1==e.nodeType&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,n){if(e!=t&&this.find)for(let o=0;o<this.find.length;o++)if(null==this.find[o].pos&&1==e.nodeType&&e.contains(this.find[o].node)){t.compareDocumentPosition(this.find[o].node)&(n?2:4)&&(this.find[o].pos=this.currentPos)}}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),n=this.options.context,o=!(this.isOpen||n&&n.parent.type!=this.nodes[0].type),r=-(n?n.depth+1:0)+(o?0:1),i=(e,s)=>{for(;e>=0;e--){let l=t[e];if(""==l){if(e==t.length-1||0==e)continue;for(;s>=r;s--)if(i(e-1,s))return!0;return!1}{let e=s>0||0==s&&o?this.nodes[s].type:n&&s>=r?n.node(s-r).type:null;if(!e||e.name!=l&&!e.isInGroup(l))return!1;s--}}return!0};return i(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let n=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(let e in this.parser.schema.nodes){let t=this.parser.schema.nodes[e];if(t.isTextblock&&t.defaultAttrs)return t}}}function ne(e,t){return(e.matches||e.msMatchesSelector||e.webkitMatchesSelector||e.mozMatchesSelector).call(e,t)}function oe(e){let t={};for(let n in e)t[n]=e[n];return t}function re(e,t){let n=t.schema.nodes;for(let o in n){let r=n[o];if(!r.allowsMarkType(e))continue;let i=[],s=e=>{i.push(e);for(let n=0;n<e.edgeCount;n++){let{type:o,next:r}=e.edge(n);if(o==t)return!0;if(i.indexOf(r)<0&&s(r))return!0}};if(s(r.contentMatch))return!0}}let ie=class e{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},n){n||(n=le(t).createDocumentFragment());let o=n,r=[];return e.forEach((e=>{if(r.length||e.marks.length){let n=0,i=0;for(;n<r.length&&i<e.marks.length;){let t=e.marks[i];if(this.marks[t.type.name]){if(!t.eq(r[n][0])||!1===t.type.spec.spanning)break;n++,i++}else i++}for(;n<r.length;)o=r.pop()[1];for(;i<e.marks.length;){let n=e.marks[i++],s=this.serializeMark(n,e.isInline,t);s&&(r.push([n,o]),o.appendChild(s.dom),o=s.contentDOM||s.dom)}}o.appendChild(this.serializeNodeInner(e,t))})),n}serializeNodeInner(e,t){let{dom:n,contentDOM:o}=de(le(t),this.nodes[e.type.name](e),null,e.attrs);if(o){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,o)}return n}serializeNode(e,t={}){let n=this.serializeNodeInner(e,t);for(let o=e.marks.length-1;o>=0;o--){let r=this.serializeMark(e.marks[o],e.isInline,t);r&&((r.contentDOM||r.dom).appendChild(n),n=r.dom)}return n}serializeMark(e,t,n={}){let o=this.marks[e.type.name];return o&&de(le(n),o(e,t),null,e.attrs)}static renderSpec(e,t,n=null,o){return de(e,t,n,o)}static fromSchema(t){return t.cached.domSerializer||(t.cached.domSerializer=new e(this.nodesFromSchema(t),this.marksFromSchema(t)))}static nodesFromSchema(e){let t=se(e.nodes);return t.text||(t.text=e=>e.text),t}static marksFromSchema(e){return se(e.marks)}};function se(e){let t={};for(let n in e){let o=e[n].spec.toDOM;o&&(t[n]=o)}return t}function le(e){return e.document||window.document}const ae=new WeakMap;function ce(e){let t=ae.get(e);return void 0===t&&ae.set(e,t=function(e){let t=null;function n(e){if(e&&"object"==typeof e)if(Array.isArray(e))if("string"==typeof e[0])t||(t=[]),t.push(e);else for(let t=0;t<e.length;t++)n(e[t]);else for(let t in e)n(e[t])}return n(e),t}(e)),t}function de(e,t,n,o){if("string"==typeof t)return{dom:e.createTextNode(t)};if(null!=t.nodeType)return{dom:t};if(t.dom&&null!=t.dom.nodeType)return t;let r,i=t[0];if("string"!=typeof i)throw new RangeError("Invalid array passed to renderSpec");if(o&&(r=ce(o))&&r.indexOf(t)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let s,l=i.indexOf(" ");l>0&&(n=i.slice(0,l),i=i.slice(l+1));let a=n?e.createElementNS(n,i):e.createElement(i),c=t[1],d=1;if(c&&"object"==typeof c&&null==c.nodeType&&!Array.isArray(c)){d=2;for(let e in c)if(null!=c[e]){let t=e.indexOf(" ");t>0?a.setAttributeNS(e.slice(0,t),e.slice(t+1),c[e]):a.setAttribute(e,c[e])}}for(let r=d;r<t.length;r++){let i=t[r];if(0===i){if(r<t.length-1||r>d)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}{let{dom:t,contentDOM:r}=de(e,i,n,o);if(a.appendChild(t),r){if(s)throw new RangeError("Multiple content holes");s=r}}}return{dom:a,contentDOM:s}}const he=Math.pow(2,16);function pe(e){return 65535&e}class ue{constructor(e,t,n){this.pos=e,this.delInfo=t,this.recover=n}get deleted(){return(8&this.delInfo)>0}get deletedBefore(){return(5&this.delInfo)>0}get deletedAfter(){return(6&this.delInfo)>0}get deletedAcross(){return(4&this.delInfo)>0}}class fe{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&fe.empty)return fe.empty}recover(e){let t=0,n=pe(e);if(!this.inverted)for(let e=0;e<n;e++)t+=this.ranges[3*e+2]-this.ranges[3*e+1];return this.ranges[3*n]+t+function(e){return(e-(65535&e))/he}(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,n){let o=0,r=this.inverted?2:1,i=this.inverted?1:2;for(let s=0;s<this.ranges.length;s+=3){let l=this.ranges[s]-(this.inverted?o:0);if(l>e)break;let a=this.ranges[s+r],c=this.ranges[s+i],d=l+a;if(e<=d){let r=l+o+((a?e==l?-1:e==d?1:t:t)<0?0:c);if(n)return r;let i=e==(t<0?l:d)?null:s/3+(e-l)*he,h=e==l?2:e==d?1:4;return(t<0?e!=l:e!=d)&&(h|=8),new ue(r,h,i)}o+=c-a}return n?e+o:new ue(e+o,0,null)}touches(e,t){let n=0,o=pe(t),r=this.inverted?2:1,i=this.inverted?1:2;for(let t=0;t<this.ranges.length;t+=3){let s=this.ranges[t]-(this.inverted?n:0);if(s>e)break;let l=this.ranges[t+r];if(e<=s+l&&t==3*o)return!0;n+=this.ranges[t+i]-l}return!1}forEach(e){let t=this.inverted?2:1,n=this.inverted?1:2;for(let o=0,r=0;o<this.ranges.length;o+=3){let i=this.ranges[o],s=i-(this.inverted?r:0),l=i+(this.inverted?0:r),a=this.ranges[o+t],c=this.ranges[o+n];e(s,s+a,l,l+c),r+=c-a}}invert(){return new fe(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return 0==e?fe.empty:new fe(e<0?[0,-e,0]:[0,0,e])}}fe.empty=new fe([]);class me{constructor(e=[],t,n=0,o=e.length){this.maps=e,this.mirror=t,this.from=n,this.to=o}slice(e=0,t=this.maps.length){return new me(this.maps,this.mirror,e,t)}copy(){return new me(this.maps.slice(),this.mirror&&this.mirror.slice(),this.from,this.to)}appendMap(e,t){this.to=this.maps.push(e),null!=t&&this.setMirror(this.maps.length-1,t)}appendMapping(e){for(let t=0,n=this.maps.length;t<e.maps.length;t++){let o=e.getMirror(t);this.appendMap(e.maps[t],null!=o&&o<t?n+o:void 0)}}getMirror(e){if(this.mirror)for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}setMirror(e,t){this.mirror||(this.mirror=[]),this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,n=this.maps.length+e.maps.length;t>=0;t--){let o=e.getMirror(t);this.appendMap(e.maps[t].invert(),null!=o&&o>t?n-o-1:void 0)}}invert(){let e=new me;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let n=this.from;n<this.to;n++)e=this.maps[n].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,n){let o=0;for(let n=this.from;n<this.to;n++){let r=this.maps[n].mapResult(e,t);if(null!=r.recover){let t=this.getMirror(n);if(null!=t&&t>n&&t<this.to){n=t,e=this.maps[t].recover(r.recover);continue}}o|=r.delInfo,e=r.pos}return n?e:new ue(e,o,null)}}const ge=Object.create(null);class ye{getMap(){return fe.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let n=ge[t.stepType];if(!n)throw new RangeError(`No step type ${t.stepType} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in ge)throw new RangeError("Duplicate use of step JSON ID "+e);return ge[e]=t,t.prototype.jsonID=e,t}}class we{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new we(e,null)}static fail(e){return new we(null,e)}static fromReplace(e,t,n,o){try{return we.ok(e.replace(t,n,o))}catch(e){if(e instanceof c)return we.fail(e.message);throw e}}}function ve(e,t,n){let o=[];for(let r=0;r<e.childCount;r++){let i=e.child(r);i.content.size&&(i=i.copy(ve(i.content,t,i))),i.isInline&&(i=t(i,n,r)),o.push(i)}return r.fromArray(o)}class be extends ye{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=e.resolve(this.from),o=n.node(n.sharedDepth(this.to)),r=new d(ve(t.content,((e,t)=>e.isAtom&&t.type.allowsMarkType(this.mark.type)?e.mark(this.mark.addToSet(e.marks)):e),o),t.openStart,t.openEnd);return we.fromReplace(e,this.from,this.to,r)}invert(){return new ke(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return t.deleted&&n.deleted||t.pos>=n.pos?null:new be(t.pos,n.pos,this.mark)}merge(e){return e instanceof be&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new be(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if("number"!=typeof t.from||"number"!=typeof t.to)throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new be(t.from,t.to,e.markFromJSON(t.mark))}}ye.jsonID("addMark",be);class ke extends ye{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=new d(ve(t.content,(e=>e.mark(this.mark.removeFromSet(e.marks))),e),t.openStart,t.openEnd);return we.fromReplace(e,this.from,this.to,n)}invert(){return new be(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return t.deleted&&n.deleted||t.pos>=n.pos?null:new ke(t.pos,n.pos,this.mark)}merge(e){return e instanceof ke&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new ke(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if("number"!=typeof t.from||"number"!=typeof t.to)throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new ke(t.from,t.to,e.markFromJSON(t.mark))}}ye.jsonID("removeMark",ke);class xe extends ye{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return we.fail("No node at mark step's position");let n=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return we.fromReplace(e,this.pos,this.pos+1,new d(r.from(n),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let e=this.mark.addToSet(t.marks);if(e.length==t.marks.length){for(let n=0;n<t.marks.length;n++)if(!t.marks[n].isInSet(e))return new xe(this.pos,t.marks[n]);return new xe(this.pos,this.mark)}}return new Se(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new xe(t.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if("number"!=typeof t.pos)throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new xe(t.pos,e.markFromJSON(t.mark))}}ye.jsonID("addNodeMark",xe);class Se extends ye{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return we.fail("No node at mark step's position");let n=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return we.fromReplace(e,this.pos,this.pos+1,new d(r.from(n),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return t&&this.mark.isInSet(t.marks)?new xe(this.pos,this.mark):this}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Se(t.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if("number"!=typeof t.pos)throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new Se(t.pos,e.markFromJSON(t.mark))}}ye.jsonID("removeNodeMark",Se);class Ce extends ye{constructor(e,t,n,o=!1){super(),this.from=e,this.to=t,this.slice=n,this.structure=o}apply(e){return this.structure&&Ne(e,this.from,this.to)?we.fail("Structure replace would overwrite content"):we.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new fe([this.from,this.to-this.from,this.slice.size])}invert(e){return new Ce(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return t.deletedAcross&&n.deletedAcross?null:new Ce(t.pos,Math.max(t.pos,n.pos),this.slice)}merge(e){if(!(e instanceof Ce)||e.structure||this.structure)return null;if(this.from+this.slice.size!=e.from||this.slice.openEnd||e.slice.openStart){if(e.to!=this.from||this.slice.openStart||e.slice.openEnd)return null;{let t=this.slice.size+e.slice.size==0?d.empty:new d(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new Ce(e.from,this.to,t,this.structure)}}{let t=this.slice.size+e.slice.size==0?d.empty:new d(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new Ce(this.from,this.to+(e.to-e.from),t,this.structure)}}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if("number"!=typeof t.from||"number"!=typeof t.to)throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new Ce(t.from,t.to,d.fromJSON(e,t.slice),!!t.structure)}}ye.jsonID("replace",Ce);class Me extends ye{constructor(e,t,n,o,r,i,s=!1){super(),this.from=e,this.to=t,this.gapFrom=n,this.gapTo=o,this.slice=r,this.insert=i,this.structure=s}apply(e){if(this.structure&&(Ne(e,this.from,this.gapFrom)||Ne(e,this.gapTo,this.to)))return we.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return we.fail("Gap is not a flat range");let n=this.slice.insertAt(this.insert,t.content);return n?we.fromReplace(e,this.from,this.to,n):we.fail("Content does not fit in gap")}getMap(){return new fe([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let t=this.gapTo-this.gapFrom;return new Me(this.from,this.from+this.slice.size+t,this.from+this.insert,this.from+this.insert+t,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1),o=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),r=this.to==this.gapTo?n.pos:e.map(this.gapTo,1);return t.deletedAcross&&n.deletedAcross||o<t.pos||r>n.pos?null:new Me(t.pos,n.pos,o,r,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if("number"!=typeof t.from||"number"!=typeof t.to||"number"!=typeof t.gapFrom||"number"!=typeof t.gapTo||"number"!=typeof t.insert)throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new Me(t.from,t.to,t.gapFrom,t.gapTo,d.fromJSON(e,t.slice),t.insert,!!t.structure)}}function Ne(e,t,n){let o=e.resolve(t),r=n-t,i=o.depth;for(;r>0&&i>0&&o.indexAfter(i)==o.node(i).childCount;)i--,r--;if(r>0){let e=o.node(i).maybeChild(o.indexAfter(i));for(;r>0;){if(!e||e.isLeaf)return!0;e=e.firstChild,r--}}return!1}function Oe(e,t,n,o=n.contentMatch,i=!0){let s=e.doc.nodeAt(t),l=[],a=t+1;for(let t=0;t<s.childCount;t++){let c=s.child(t),h=a+c.nodeSize,p=o.matchType(c.type);if(p){o=p;for(let t=0;t<c.marks.length;t++)n.allowsMarkType(c.marks[t].type)||e.step(new ke(a,h,c.marks[t]));if(i&&c.isText&&"pre"!=n.whitespace){let e,t,o=/\r?\n|\r/g;for(;e=o.exec(c.text);)t||(t=new d(r.from(n.schema.text(" ",n.allowedMarks(c.marks))),0,0)),l.push(new Ce(a+e.index,a+e.index+e[0].length,t))}}else l.push(new Ce(a,h,d.empty));a=h}if(!o.validEnd){let t=o.fillBefore(r.empty,!0);e.replace(a,a,new d(t,0,0))}for(let t=l.length-1;t>=0;t--)e.step(l[t])}function Ae(e,t,n){return(0==t||e.canReplace(t,e.childCount))&&(n==e.childCount||e.canReplace(0,n))}function Te(e){let t=e.parent.content.cutByIndex(e.startIndex,e.endIndex);for(let n=e.depth;;--n){let o=e.$from.node(n),r=e.$from.index(n),i=e.$to.indexAfter(n);if(n<e.depth&&o.canReplace(r,i,t))return n;if(0==n||o.type.spec.isolating||!Ae(o,r,i))break}return null}function De(e,t,n=null,o=e){let r=function(e,t){let{parent:n,startIndex:o,endIndex:r}=e,i=n.contentMatchAt(o).findWrapping(t);if(!i)return null;let s=i.length?i[0]:t;return n.canReplaceWith(o,r,s)?i:null}(e,t),i=r&&function(e,t){let{parent:n,startIndex:o,endIndex:r}=e,i=n.child(o),s=t.contentMatch.findWrapping(i.type);if(!s)return null;let l=(s.length?s[s.length-1]:t).contentMatch;for(let e=o;l&&e<r;e++)l=l.matchType(n.child(e).type);return l&&l.validEnd?s:null}(o,t);return i?r.map(Ee).concat({type:t,attrs:n}).concat(i.map(Ee)):null}function Ee(e){return{type:e,attrs:null}}function Re(e,t,n,o){t.forEach(((r,i)=>{if(r.isText){let s,l=/\r?\n|\r/g;for(;s=l.exec(r.text);){let r=e.mapping.slice(o).map(n+1+i+s.index);e.replaceWith(r,r+1,t.type.schema.linebreakReplacement.create())}}}))}function $e(e,t,n,o){t.forEach(((r,i)=>{if(r.type==r.type.schema.linebreakReplacement){let r=e.mapping.slice(o).map(n+1+i);e.replaceWith(r,r+1,t.type.schema.text("\n"))}}))}function Ie(e,t,n=1,o){let r=e.resolve(t),i=r.depth-n,s=o&&o[o.length-1]||r.parent;if(i<0||r.parent.type.spec.isolating||!r.parent.canReplace(r.index(),r.parent.childCount)||!s.type.validContent(r.parent.content.cutByIndex(r.index(),r.parent.childCount)))return!1;for(let e=r.depth-1,t=n-2;e>i;e--,t--){let n=r.node(e),i=r.index(e);if(n.type.spec.isolating)return!1;let s=n.content.cutByIndex(i,n.childCount),l=o&&o[t+1];l&&(s=s.replaceChild(0,l.type.create(l.attrs)));let a=o&&o[t]||n;if(!n.canReplace(i+1,n.childCount)||!a.type.validContent(s))return!1}let l=r.indexAfter(i),a=o&&o[0];return r.node(i).canReplaceWith(l,l,a?a.type:r.node(i+1).type)}function ze(e,t){let n=e.resolve(t),o=n.index();return Be(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(o,o+1)}function Be(e,t){return!(!e||!t||e.isLeaf||!function(e,t){t.content.size||e.type.compatibleContent(t.type);let n=e.contentMatchAt(e.childCount),{linebreakReplacement:o}=e.type.schema;for(let r=0;r<t.childCount;r++){let i=t.child(r),s=i.type==o?e.type.schema.nodes.text:i.type;if(n=n.matchType(s),!n)return!1;if(!e.type.allowsMarks(i.marks))return!1}return n.validEnd}(e,t))}function Pe(e,t,n=-1){let o=e.resolve(t);for(let e=o.depth;;e--){let r,i,s=o.index(e);if(e==o.depth?(r=o.nodeBefore,i=o.nodeAfter):n>0?(r=o.node(e+1),s++,i=o.node(e).maybeChild(s)):(r=o.node(e).maybeChild(s-1),i=o.node(e+1)),r&&!r.isTextblock&&Be(r,i)&&o.node(e).canReplace(s,s+1))return t;if(0==e)break;t=n<0?o.before(e):o.after(e)}}function Ve(e,t,n){let o=e.resolve(t);if(o.parent.canReplaceWith(o.index(),o.index(),n))return t;if(0==o.parentOffset)for(let e=o.depth-1;e>=0;e--){let t=o.index(e);if(o.node(e).canReplaceWith(t,t,n))return o.before(e+1);if(t>0)return null}if(o.parentOffset==o.parent.content.size)for(let e=o.depth-1;e>=0;e--){let t=o.indexAfter(e);if(o.node(e).canReplaceWith(t,t,n))return o.after(e+1);if(t<o.node(e).childCount)return null}return null}function Fe(e,t,n){let o=e.resolve(t);if(!n.content.size)return t;let r=n.content;for(let e=0;e<n.openStart;e++)r=r.firstChild.content;for(let e=1;e<=(0==n.openStart&&n.size?2:1);e++)for(let t=o.depth;t>=0;t--){let n=t==o.depth?0:o.pos<=(o.start(t+1)+o.end(t+1))/2?-1:1,i=o.index(t)+(n>0?1:0),s=o.node(t),l=!1;if(1==e)l=s.canReplace(i,i,r);else{let e=s.contentMatchAt(i).findWrapping(r.firstChild.type);l=e&&s.canReplaceWith(i,i,e[0])}if(l)return 0==n?o.pos:n<0?o.before(t+1):o.after(t+1)}return null}function Le(e,t,n=t,o=d.empty){if(t==n&&!o.size)return null;let r=e.resolve(t),i=e.resolve(n);return He(r,i,o)?new Ce(t,n,o):new _e(r,i,o).fit()}function He(e,t,n){return!n.openStart&&!n.openEnd&&e.start()==t.start()&&e.parent.canReplace(e.index(),t.index(),n.content)}ye.jsonID("replaceAround",Me);class _e{constructor(e,t,n){this.$from=e,this.$to=t,this.unplaced=n,this.frontier=[],this.placed=r.empty;for(let t=0;t<=e.depth;t++){let n=e.node(t);this.frontier.push({type:n.type,match:n.contentMatchAt(e.indexAfter(t))})}for(let t=e.depth;t>0;t--)this.placed=r.from(e.node(t).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let e=this.findFittable();e?this.placeNodes(e):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,n=this.$from,o=this.close(e<0?this.$to:n.doc.resolve(e));if(!o)return null;let r=this.placed,i=n.depth,s=o.depth;for(;i&&s&&1==r.childCount;)r=r.firstChild.content,i--,s--;let l=new d(r,i,s);return e>-1?new Me(n.pos,e,this.$to.pos,this.$to.end(),l,t):l.size||n.pos!=this.$to.pos?new Ce(n.pos,o.pos,l):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,n=0,o=this.unplaced.openEnd;n<e;n++){let r=t.firstChild;if(t.childCount>1&&(o=0),r.type.spec.isolating&&o<=n){e=n;break}t=r.content}for(let t=1;t<=2;t++)for(let n=1==t?e:this.unplaced.openStart;n>=0;n--){let e,o=null;n?(o=Je(this.unplaced.content,n-1).firstChild,e=o.content):e=this.unplaced.content;let i=e.firstChild;for(let e=this.depth;e>=0;e--){let s,{type:l,match:a}=this.frontier[e],c=null;if(1==t&&(i?a.matchType(i.type)||(c=a.fillBefore(r.from(i),!1)):o&&l.compatibleContent(o.type)))return{sliceDepth:n,frontierDepth:e,parent:o,inject:c};if(2==t&&i&&(s=a.findWrapping(i.type)))return{sliceDepth:n,frontierDepth:e,parent:o,wrap:s};if(o&&a.matchType(o.type))break}}}openMore(){let{content:e,openStart:t,openEnd:n}=this.unplaced,o=Je(e,t);return!(!o.childCount||o.firstChild.isLeaf)&&(this.unplaced=new d(e,t+1,Math.max(n,o.size+t>=e.size-n?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:n}=this.unplaced,o=Je(e,t);if(o.childCount<=1&&t>0){let r=e.size-t<=t+o.size;this.unplaced=new d(We(e,t-1,1),t-1,r?t-1:n)}else this.unplaced=new d(We(e,t,1),t,n)}placeNodes({sliceDepth:e,frontierDepth:t,parent:n,inject:o,wrap:i}){for(;this.depth>t;)this.closeFrontierNode();if(i)for(let e=0;e<i.length;e++)this.openFrontierNode(i[e]);let s=this.unplaced,l=n?n.content:s.content,a=s.openStart-e,c=0,h=[],{match:p,type:u}=this.frontier[t];if(o){for(let e=0;e<o.childCount;e++)h.push(o.child(e));p=p.matchFragment(o)}let f=l.size+e-(s.content.size-s.openEnd);for(;c<l.childCount;){let e=l.child(c),t=p.matchType(e.type);if(!t)break;c++,(c>1||0==a||e.content.size)&&(p=t,h.push(je(e.mark(u.allowedMarks(e.marks)),1==c?a:0,c==l.childCount?f:-1)))}let m=c==l.childCount;m||(f=-1),this.placed=qe(this.placed,t,r.from(h)),this.frontier[t].match=p,m&&f<0&&n&&n.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let e=0,t=l;e<f;e++){let e=t.lastChild;this.frontier.push({type:e.type,match:e.contentMatchAt(e.childCount)}),t=e.content}this.unplaced=m?0==e?d.empty:new d(We(s.content,e-1,1),e-1,f<0?s.openEnd:e-1):new d(We(s.content,e,c),s.openStart,s.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e,t=this.frontier[this.depth];if(!t.type.isTextblock||!Ke(this.$to,this.$to.depth,t.type,t.match,!1)||this.$to.depth==this.depth&&(e=this.findCloseLevel(this.$to))&&e.depth==this.depth)return-1;let{depth:n}=this.$to,o=this.$to.after(n);for(;n>1&&o==this.$to.end(--n);)++o;return o}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:n,type:o}=this.frontier[t],r=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),i=Ke(e,t,o,n,r);if(i){for(let n=t-1;n>=0;n--){let{match:t,type:o}=this.frontier[n],r=Ke(e,n,o,t,!0);if(!r||r.childCount)continue e}return{depth:t,fit:i,move:r?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=qe(this.placed,t.depth,t.fit)),e=t.move;for(let n=t.depth+1;n<=e.depth;n++){let t=e.node(n),o=t.type.contentMatch.fillBefore(t.content,!0,e.index(n));this.openFrontierNode(t.type,t.attrs,o)}return e}openFrontierNode(e,t=null,n){let o=this.frontier[this.depth];o.match=o.match.matchType(e),this.placed=qe(this.placed,this.depth,r.from(e.create(t,n))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let e=this.frontier.pop().match.fillBefore(r.empty,!0);e.childCount&&(this.placed=qe(this.placed,this.frontier.length,e))}}function We(e,t,n){return 0==t?e.cutByIndex(n,e.childCount):e.replaceChild(0,e.firstChild.copy(We(e.firstChild.content,t-1,n)))}function qe(e,t,n){return 0==t?e.append(n):e.replaceChild(e.childCount-1,e.lastChild.copy(qe(e.lastChild.content,t-1,n)))}function Je(e,t){for(let n=0;n<t;n++)e=e.firstChild.content;return e}function je(e,t,n){if(t<=0)return e;let o=e.content;return t>1&&(o=o.replaceChild(0,je(o.firstChild,t-1,1==o.childCount?n-1:0))),t>0&&(o=e.type.contentMatch.fillBefore(o).append(o),n<=0&&(o=o.append(e.type.contentMatch.matchFragment(o).fillBefore(r.empty,!0)))),e.copy(o)}function Ke(e,t,n,o,r){let i=e.node(t),s=r?e.indexAfter(t):e.index(t);if(s==i.childCount&&!n.compatibleContent(i.type))return null;let l=o.fillBefore(i.content,!0,s);return l&&!function(e,t,n){for(let o=n;o<t.childCount;o++)if(!e.allowsMarks(t.child(o).marks))return!0;return!1}(n,i.content,s)?l:null}function Xe(e,t,n,o,i){if(t<n){let r=e.firstChild;e=e.replaceChild(0,r.copy(Xe(r.content,t+1,n,o,r)))}if(t>o){let t=i.contentMatchAt(0),n=t.fillBefore(e).append(e);e=n.append(t.matchFragment(n).fillBefore(r.empty,!0))}return e}function Ue(e,t){let n=[];for(let o=Math.min(e.depth,t.depth);o>=0;o--){let r=e.start(o);if(r<e.pos-(e.depth-o)||t.end(o)>t.pos+(t.depth-o)||e.node(o).type.spec.isolating||t.node(o).type.spec.isolating)break;(r==t.start(o)||o==e.depth&&o==t.depth&&e.parent.inlineContent&&t.parent.inlineContent&&o&&t.start(o-1)==r-1)&&n.push(o)}return n}class Ge extends ye{constructor(e,t,n){super(),this.pos=e,this.attr=t,this.value=n}apply(e){let t=e.nodeAt(this.pos);if(!t)return we.fail("No node at attribute step's position");let n=Object.create(null);for(let e in t.attrs)n[e]=t.attrs[e];n[this.attr]=this.value;let o=t.type.create(n,null,t.marks);return we.fromReplace(e,this.pos,this.pos+1,new d(r.from(o),0,t.isLeaf?0:1))}getMap(){return fe.empty}invert(e){return new Ge(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Ge(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if("number"!=typeof t.pos||"string"!=typeof t.attr)throw new RangeError("Invalid input for AttrStep.fromJSON");return new Ge(t.pos,t.attr,t.value)}}ye.jsonID("attr",Ge);class Ye extends ye{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let n in e.attrs)t[n]=e.attrs[n];t[this.attr]=this.value;let n=e.type.create(t,e.content,e.marks);return we.ok(n)}getMap(){return fe.empty}invert(e){return new Ye(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,t){if("string"!=typeof t.attr)throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new Ye(t.attr,t.value)}}ye.jsonID("docAttr",Ye),e.TransformError=class extends Error{},e.TransformError=function e(t){let n=Error.call(this,t);return n.__proto__=e.prototype,n},e.TransformError.prototype=Object.create(Error.prototype),e.TransformError.prototype.constructor=e.TransformError,e.TransformError.prototype.name="TransformError";class Qe{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new me}get before(){return this.docs.length?this.docs[0]:this.doc}step(t){let n=this.maybeStep(t);if(n.failed)throw new e.TransformError(n.failed);return this}maybeStep(e){let t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}get docChanged(){return this.steps.length>0}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,n=d.empty){let o=Le(this.doc,e,t,n);return o&&this.step(o),this}replaceWith(e,t,n){return this.replace(e,t,new d(r.from(n),0,0))}delete(e,t){return this.replace(e,t,d.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,n){return function(e,t,n,o){if(!o.size)return e.deleteRange(t,n);let r=e.doc.resolve(t),i=e.doc.resolve(n);if(He(r,i,o))return e.step(new Ce(t,n,o));let s=Ue(r,e.doc.resolve(n));0==s[s.length-1]&&s.pop();let l=-(r.depth+1);s.unshift(l);for(let e=r.depth,t=r.pos-1;e>0;e--,t--){let n=r.node(e).type.spec;if(n.defining||n.definingAsContext||n.isolating)break;s.indexOf(e)>-1?l=e:r.before(e)==t&&s.splice(1,0,-e)}let a=s.indexOf(l),c=[],h=o.openStart;for(let e=o.content,t=0;;t++){let n=e.firstChild;if(c.push(n),t==o.openStart)break;e=n.content}for(let e=h-1;e>=0;e--){let t=c[e],n=(p=t.type).spec.defining||p.spec.definingForContent;if(n&&!t.sameMarkup(r.node(Math.abs(l)-1)))h=e;else if(n||!t.type.isTextblock)break}var p;for(let t=o.openStart;t>=0;t--){let l=(t+h+1)%(o.openStart+1),p=c[l];if(p)for(let t=0;t<s.length;t++){let c=s[(t+a)%s.length],h=!0;c<0&&(h=!1,c=-c);let u=r.node(c-1),f=r.index(c-1);if(u.canReplaceWith(f,f,p.type,p.marks))return e.replace(r.before(c),h?i.after(c):n,new d(Xe(o.content,0,o.openStart,l),l,o.openEnd))}}let u=e.steps.length;for(let l=s.length-1;l>=0&&(e.replace(t,n,o),!(e.steps.length>u));l--){let e=s[l];e<0||(t=r.before(e),n=i.after(e))}}(this,e,t,n),this}replaceRangeWith(e,t,n){return function(e,t,n,o){if(!o.isInline&&t==n&&e.doc.resolve(t).parent.content.size){let r=Ve(e.doc,t,o.type);null!=r&&(t=n=r)}e.replaceRange(t,n,new d(r.from(o),0,0))}(this,e,t,n),this}deleteRange(e,t){return function(e,t,n){let o=e.doc.resolve(t),r=e.doc.resolve(n),i=Ue(o,r);for(let t=0;t<i.length;t++){let n=i[t],s=t==i.length-1;if(s&&0==n||o.node(n).type.contentMatch.validEnd)return e.delete(o.start(n),r.end(n));if(n>0&&(s||o.node(n-1).canReplace(o.index(n-1),r.indexAfter(n-1))))return e.delete(o.before(n),r.after(n))}for(let i=1;i<=o.depth&&i<=r.depth;i++)if(t-o.start(i)==o.depth-i&&n>o.end(i)&&r.end(i)-n!=r.depth-i&&o.start(i-1)==r.start(i-1)&&o.node(i-1).canReplace(o.index(i-1),r.index(i-1)))return e.delete(o.before(i),n);e.delete(t,n)}(this,e,t),this}lift(e,t){return function(e,t,n){let{$from:o,$to:i,depth:s}=t,l=o.before(s+1),a=i.after(s+1),c=l,h=a,p=r.empty,u=0;for(let e=s,t=!1;e>n;e--)t||o.index(e)>0?(t=!0,p=r.from(o.node(e).copy(p)),u++):c--;let f=r.empty,m=0;for(let e=s,t=!1;e>n;e--)t||i.after(e+1)<i.end(e)?(t=!0,f=r.from(i.node(e).copy(f)),m++):h++;e.step(new Me(c,h,l,a,new d(p.append(f),u,m),p.size-u,!0))}(this,e,t),this}join(e,t=1){return function(e,t,n){let o=null,{linebreakReplacement:r}=e.doc.type.schema,i=e.doc.resolve(t-n),s=i.node().type;if(r&&s.inlineContent){let e="pre"==s.whitespace,t=!!s.contentMatch.matchType(r);e&&!t?o=!1:!e&&t&&(o=!0)}let l=e.steps.length;if(!1===o){let o=e.doc.resolve(t+n);$e(e,o.node(),o.before(),l)}s.inlineContent&&Oe(e,t+n-1,s,i.node().contentMatchAt(i.index()),null==o);let a=e.mapping.slice(l),c=a.map(t-n);if(e.step(new Ce(c,a.map(t+n,-1),d.empty,!0)),!0===o){let t=e.doc.resolve(c);Re(e,t.node(),t.before(),e.steps.length)}}(this,e,t),this}wrap(e,t){return function(e,t,n){let o=r.empty;for(let e=n.length-1;e>=0;e--){if(o.size){let t=n[e].type.contentMatch.matchFragment(o);if(!t||!t.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}o=r.from(n[e].type.create(n[e].attrs,o))}let i=t.start,s=t.end;e.step(new Me(i,s,i,s,new d(o,0,0),n.length,!0))}(this,e,t),this}setBlockType(e,t=e,n,o=null){return function(e,t,n,o,i){if(!o.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let s=e.steps.length;e.doc.nodesBetween(t,n,((t,n)=>{let l="function"==typeof i?i(t):i;if(t.isTextblock&&!t.hasMarkup(o,l)&&function(e,t,n){let o=e.resolve(t),r=o.index();return o.parent.canReplaceWith(r,r+1,n)}(e.doc,e.mapping.slice(s).map(n),o)){let i=null;if(o.schema.linebreakReplacement){let e="pre"==o.whitespace,t=!!o.contentMatch.matchType(o.schema.linebreakReplacement);e&&!t?i=!1:!e&&t&&(i=!0)}!1===i&&$e(e,t,n,s),Oe(e,e.mapping.slice(s).map(n,1),o,void 0,null===i);let a=e.mapping.slice(s),c=a.map(n,1),h=a.map(n+t.nodeSize,1);return e.step(new Me(c,h,c+1,h-1,new d(r.from(o.create(l,null,t.marks)),0,0),1,!0)),!0===i&&Re(e,t,n,s),!1}}))}(this,e,t,n,o),this}setNodeMarkup(e,t,n=null,o){return function(e,t,n,o,i){let s=e.doc.nodeAt(t);if(!s)throw new RangeError("No node at given position");n||(n=s.type);let l=n.create(o,null,i||s.marks);if(s.isLeaf)return e.replaceWith(t,t+s.nodeSize,l);if(!n.validContent(s.content))throw new RangeError("Invalid content for node type "+n.name);e.step(new Me(t,t+s.nodeSize,t+1,t+s.nodeSize-1,new d(r.from(l),0,0),1,!0))}(this,e,t,n,o),this}setNodeAttribute(e,t,n){return this.step(new Ge(e,t,n)),this}setDocAttribute(e,t){return this.step(new Ye(e,t)),this}addNodeMark(e,t){return this.step(new xe(e,t)),this}removeNodeMark(e,t){if(!(t instanceof a)){let n=this.doc.nodeAt(e);if(!n)throw new RangeError("No node at position "+e);if(!(t=t.isInSet(n.marks)))return this}return this.step(new Se(e,t)),this}split(e,t=1,n){return function(e,t,n=1,o){let i=e.doc.resolve(t),s=r.empty,l=r.empty;for(let e=i.depth,t=i.depth-n,a=n-1;e>t;e--,a--){s=r.from(i.node(e).copy(s));let t=o&&o[a];l=r.from(t?t.type.create(t.attrs,l):i.node(e).copy(l))}e.step(new Ce(t,t,new d(s.append(l),n,n),!0))}(this,e,t,n),this}addMark(e,t,n){return function(e,t,n,o){let r,i,s=[],l=[];e.doc.nodesBetween(t,n,((e,a,c)=>{if(!e.isInline)return;let d=e.marks;if(!o.isInSet(d)&&c.type.allowsMarkType(o.type)){let c=Math.max(a,t),h=Math.min(a+e.nodeSize,n),p=o.addToSet(d);for(let e=0;e<d.length;e++)d[e].isInSet(p)||(r&&r.to==c&&r.mark.eq(d[e])?r.to=h:s.push(r=new ke(c,h,d[e])));i&&i.to==c?i.to=h:l.push(i=new be(c,h,o))}})),s.forEach((t=>e.step(t))),l.forEach((t=>e.step(t)))}(this,e,t,n),this}removeMark(e,t,n){return function(e,t,n,o){let r=[],i=0;e.doc.nodesBetween(t,n,((e,s)=>{if(!e.isInline)return;i++;let l=null;if(o instanceof j){let t,n=e.marks;for(;t=o.isInSet(n);)(l||(l=[])).push(t),n=t.removeFromSet(n)}else o?o.isInSet(e.marks)&&(l=[o]):l=e.marks;if(l&&l.length){let o=Math.min(s+e.nodeSize,n);for(let e=0;e<l.length;e++){let n,a=l[e];for(let e=0;e<r.length;e++){let t=r[e];t.step==i-1&&a.eq(r[e].style)&&(n=t)}n?(n.to=o,n.step=i):r.push({style:a,from:Math.max(s,t),to:o,step:i})}}})),r.forEach((t=>e.step(new ke(t.from,t.to,t.style))))}(this,e,t,n),this}clearIncompatible(e,t,n){return Oe(this,e,t,n),this}}const Ze=Object.create(null);class et{constructor(e,t,n){this.$anchor=e,this.$head=t,this.ranges=n||[new tt(e.min(t),e.max(t))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let t=0;t<e.length;t++)if(e[t].$from.pos!=e[t].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,t=d.empty){let n=t.content.lastChild,o=null;for(let e=0;e<t.openEnd;e++)o=n,n=n.lastChild;let r=e.steps.length,i=this.ranges;for(let s=0;s<i.length;s++){let{$from:l,$to:a}=i[s],c=e.mapping.slice(r);e.replaceRange(c.map(l.pos),c.map(a.pos),s?d.empty:t),0==s&&ht(e,r,(n?n.isInline:o&&o.isTextblock)?-1:1)}}replaceWith(e,t){let n=e.steps.length,o=this.ranges;for(let r=0;r<o.length;r++){let{$from:i,$to:s}=o[r],l=e.mapping.slice(n),a=l.map(i.pos),c=l.map(s.pos);r?e.deleteRange(a,c):(e.replaceRangeWith(a,c,t),ht(e,n,t.isInline?-1:1))}}static findFrom(e,t,n=!1){let o=e.parent.inlineContent?new rt(e):dt(e.node(0),e.parent,e.pos,e.index(),t,n);if(o)return o;for(let o=e.depth-1;o>=0;o--){let r=t<0?dt(e.node(0),e.node(o),e.before(o+1),e.index(o),t,n):dt(e.node(0),e.node(o),e.after(o+1),e.index(o)+1,t,n);if(r)return r}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new at(e.node(0))}static atStart(e){return dt(e,e,0,0,1)||new at(e)}static atEnd(e){return dt(e,e,e.content.size,e.childCount,-1)||new at(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let n=Ze[t.type];if(!n)throw new RangeError(`No selection type ${t.type} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in Ze)throw new RangeError("Duplicate use of selection JSON ID "+e);return Ze[e]=t,t.prototype.jsonID=e,t}getBookmark(){return rt.between(this.$anchor,this.$head).getBookmark()}}et.prototype.visible=!0;class tt{constructor(e,t){this.$from=e,this.$to=t}}let nt=!1;function ot(e){nt||e.parent.inlineContent||(nt=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+e.parent.type.name+")"))}class rt extends et{constructor(e,t=e){ot(e),ot(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let n=e.resolve(t.map(this.head));if(!n.parent.inlineContent)return et.near(n);let o=e.resolve(t.map(this.anchor));return new rt(o.parent.inlineContent?o:n,n)}replace(e,t=d.empty){if(super.replace(e,t),t==d.empty){let t=this.$from.marksAcross(this.$to);t&&e.ensureMarks(t)}}eq(e){return e instanceof rt&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new it(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if("number"!=typeof t.anchor||"number"!=typeof t.head)throw new RangeError("Invalid input for TextSelection.fromJSON");return new rt(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,n=t){let o=e.resolve(t);return new this(o,n==t?o:e.resolve(n))}static between(e,t,n){let o=e.pos-t.pos;if(n&&!o||(n=o>=0?1:-1),!t.parent.inlineContent){let e=et.findFrom(t,n,!0)||et.findFrom(t,-n,!0);if(!e)return et.near(t,n);t=e.$head}return e.parent.inlineContent||(0==o||(e=(et.findFrom(e,-n,!0)||et.findFrom(e,n,!0)).$anchor).pos<t.pos!=o<0)&&(e=t),new rt(e,t)}}et.jsonID("text",rt);class it{constructor(e,t){this.anchor=e,this.head=t}map(e){return new it(e.map(this.anchor),e.map(this.head))}resolve(e){return rt.between(e.resolve(this.anchor),e.resolve(this.head))}}class st extends et{constructor(e){let t=e.nodeAfter,n=e.node(0).resolve(e.pos+t.nodeSize);super(e,n),this.node=t}map(e,t){let{deleted:n,pos:o}=t.mapResult(this.anchor),r=e.resolve(o);return n?et.near(r):new st(r)}content(){return new d(r.from(this.node),0,0)}eq(e){return e instanceof st&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new lt(this.anchor)}static fromJSON(e,t){if("number"!=typeof t.anchor)throw new RangeError("Invalid input for NodeSelection.fromJSON");return new st(e.resolve(t.anchor))}static create(e,t){return new st(e.resolve(t))}static isSelectable(e){return!e.isText&&!1!==e.type.spec.selectable}}st.prototype.visible=!1,et.jsonID("node",st);class lt{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:n}=e.mapResult(this.anchor);return t?new it(n,n):new lt(n)}resolve(e){let t=e.resolve(this.anchor),n=t.nodeAfter;return n&&st.isSelectable(n)?new st(t):et.near(t)}}class at extends et{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=d.empty){if(t==d.empty){e.delete(0,e.doc.content.size);let t=et.atStart(e.doc);t.eq(e.selection)||e.setSelection(t)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new at(e)}map(e){return new at(e)}eq(e){return e instanceof at}getBookmark(){return ct}}et.jsonID("all",at);const ct={map(){return this},resolve:e=>new at(e)};function dt(e,t,n,o,r,i=!1){if(t.inlineContent)return rt.create(e,n);for(let s=o-(r>0?0:1);r>0?s<t.childCount:s>=0;s+=r){let o=t.child(s);if(o.isAtom){if(!i&&st.isSelectable(o))return st.create(e,n-(r<0?o.nodeSize:0))}else{let t=dt(e,o,n+r,r<0?o.childCount:0,r,i);if(t)return t}n+=o.nodeSize*r}return null}function ht(e,t,n){let o=e.steps.length-1;if(o<t)return;let r,i=e.steps[o];(i instanceof Ce||i instanceof Me)&&(e.mapping.maps[o].forEach(((e,t,n,o)=>{null==r&&(r=o)})),e.setSelection(et.near(e.doc.resolve(r),n)))}class pt extends Qe{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){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}setSelection(e){if(e.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=-3&this.updated|1,this.storedMarks=null,this}get selectionSet(){return(1&this.updated)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=2,this}ensureMarks(e){return a.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(2&this.updated)>0}addStep(e,t){super.addStep(e,t),this.updated=-3&this.updated,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let n=this.selection;return t&&(e=e.mark(this.storedMarks||(n.empty?n.$from.marks():n.$from.marksAcross(n.$to)||a.none))),n.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,n){let o=this.doc.type.schema;if(null==t)return e?this.replaceSelectionWith(o.text(e),!0):this.deleteSelection();{if(null==n&&(n=t),n=null==n?t:n,!e)return this.deleteRange(t,n);let r=this.storedMarks;if(!r){let e=this.doc.resolve(t);r=n==t?e.marks():e.marksAcross(this.doc.resolve(n))}return this.replaceRangeWith(t,n,o.text(e,r)),this.selection.empty||this.setSelection(et.near(this.selection.$to)),this}}setMeta(e,t){return this.meta["string"==typeof e?e:e.key]=t,this}getMeta(e){return this.meta["string"==typeof e?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=4,this}get scrolledIntoView(){return(4&this.updated)>0}}function ut(e,t){return t&&e?e.bind(t):e}class ft{constructor(e,t,n){this.name=e,this.init=ut(t.init,n),this.apply=ut(t.apply,n)}}const mt=[new ft("doc",{init:e=>e.doc||e.schema.topNodeType.createAndFill(),apply:e=>e.doc}),new ft("selection",{init:(e,t)=>e.selection||et.atStart(t.doc),apply:e=>e.selection}),new ft("storedMarks",{init:e=>e.storedMarks||null,apply:(e,t,n,o)=>o.selection.$cursor?e.storedMarks:null}),new ft("scrollToSelection",{init:()=>0,apply:(e,t)=>e.scrolledIntoView?t+1:t})];class gt{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=mt.slice(),t&&t.forEach((e=>{if(this.pluginsByKey[e.key])throw new RangeError("Adding different instances of a keyed plugin ("+e.key+")");this.plugins.push(e),this.pluginsByKey[e.key]=e,e.spec.state&&this.fields.push(new ft(e.key,e.spec.state,e))}))}}class yt{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,t=-1){for(let n=0;n<this.config.plugins.length;n++)if(n!=t){let t=this.config.plugins[n];if(t.spec.filterTransaction&&!t.spec.filterTransaction.call(t,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],n=this.applyInner(e),o=null;for(;;){let r=!1;for(let i=0;i<this.config.plugins.length;i++){let s=this.config.plugins[i];if(s.spec.appendTransaction){let l=o?o[i].n:0,a=o?o[i].state:this,c=l<t.length&&s.spec.appendTransaction.call(s,l?t.slice(l):t,a,n);if(c&&n.filterTransaction(c,i)){if(c.setMeta("appendedTransaction",e),!o){o=[];for(let e=0;e<this.config.plugins.length;e++)o.push(e<i?{state:n,n:t.length}:{state:this,n:0})}t.push(c),n=n.applyInner(c),r=!0}o&&(o[i]={state:n,n:t.length})}}if(!r)return{state:n,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let t=new yt(this.config),n=this.config.fields;for(let o=0;o<n.length;o++){let r=n[o];t[r.name]=r.apply(e,this[r.name],this,t)}return t}get tr(){return new pt(this)}static create(e){let t=new gt(e.doc?e.doc.type.schema:e.schema,e.plugins),n=new yt(t);for(let o=0;o<t.fields.length;o++)n[t.fields[o].name]=t.fields[o].init(e,n);return n}reconfigure(e){let t=new gt(this.schema,e.plugins),n=t.fields,o=new yt(t);for(let t=0;t<n.length;t++){let r=n[t].name;o[r]=this.hasOwnProperty(r)?this[r]:n[t].init(e,o)}return o}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map((e=>e.toJSON()))),e&&"object"==typeof e)for(let n in e){if("doc"==n||"selection"==n)throw new RangeError("The JSON fields `doc` and `selection` are reserved");let o=e[n],r=o.spec.state;r&&r.toJSON&&(t[n]=r.toJSON.call(o,this[o.key]))}return t}static fromJSON(e,t,n){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let o=new gt(e.schema,e.plugins),r=new yt(o);return o.fields.forEach((o=>{if("doc"==o.name)r.doc=A.fromJSON(e.schema,t.doc);else if("selection"==o.name)r.selection=et.fromJSON(r.doc,t.selection);else if("storedMarks"==o.name)t.storedMarks&&(r.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(n)for(let i in n){let s=n[i],l=s.spec.state;if(s.key==o.name&&l&&l.fromJSON&&Object.prototype.hasOwnProperty.call(t,i))return void(r[o.name]=l.fromJSON.call(s,e,t[i],r))}r[o.name]=o.init(e,r)}})),r}}function wt(e,t,n){for(let o in e){let r=e[o];r instanceof Function?r=r.bind(t):"handleDOMEvents"==o&&(r=wt(r,t,{})),n[o]=r}return n}class vt{constructor(e){this.spec=e,this.props={},e.props&&wt(e.props,this,this.props),this.key=e.key?e.key.key:kt("plugin")}getState(e){return e[this.key]}}const bt=Object.create(null);function kt(e){return e in bt?e+"$"+ ++bt[e]:(bt[e]=0,e+"$")}class xt{constructor(e="key"){this.key=kt(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const St="k-parent-node",Ct="k-colgroup-data",Mt="k-resizable-node",Nt="k-editor-resize-handle",Ot="data-dir-table-resize",At="data-dir-image-resize";var Tt={wp:/(Windows Phone(?: OS)?)\s(\d+)\.(\d+(\.\d+)?)/,fire:/(Silk)\/(\d+)\.(\d+(\.\d+)?)/,android:/(Android|Android.*(?:Opera|Firefox).*?\/)\s*(\d+)(\.(\d+(\.\d+)?))?/,iphone:/(iPhone|iPod).*OS\s+(\d+)[\._]([\d\._]+)/,ipad:/(iPad).*OS\s+(\d+)[\._]([\d_]+)/,meego:/(MeeGo).+NokiaBrowser\/(\d+)\.([\d\._]+)/,webos:/(webOS)\/(\d+)\.(\d+(\.\d+)?)/,blackberry:/(BlackBerry|BB10).*?Version\/(\d+)\.(\d+(\.\d+)?)/,playbook:/(PlayBook).*?Tablet\s*OS\s*(\d+)\.(\d+(\.\d+)?)/,windows:/(MSIE)\s+(\d+)\.(\d+(\.\d+)?)/,tizen:/(tizen).*?Version\/(\d+)\.(\d+(\.\d+)?)/i,sailfish:/(sailfish).*rv:(\d+)\.(\d+(\.\d+)?).*firefox/i,ffos:/(Mobile).*rv:(\d+)\.(\d+(\.\d+)?).*Firefox/},Dt={ios:/^i(phone|pad|pod)$/i,android:/^android|fire$/i,blackberry:/^blackberry|playbook/i,windows:/windows/,wp:/wp/,flat:/sailfish|ffos|tizen/i,meego:/meego/},Et={edge:/(edge)[ \/]([\w.]+)/i,webkit:/(chrome)[ \/]([\w.]+)/i,safari:/(webkit)[ \/]([\w.]+)/i,opera:/(opera)(?:.*version|)[ \/]([\w.]+)/i,msie:/(msie\s|trident.*? rv:)([\w.]+)/i,mozilla:/(mozilla)(?:.*? rv:([\w.]+)|)/i},Rt={omini:/Opera\sMini/i,omobile:/Opera\sMobi/i,firefox:/Firefox|Fennec/i,mobilesafari:/version\/.*safari/i,ie:/MSIE|Windows\sPhone/i,chrome:/chrome|crios/i,webkit:/webkit/i},$t=function(e,t,n){for(var o in t)if(t.hasOwnProperty(o)&&t[o].test(e))return o;return void 0!==n?n:e},It="undefined"!=typeof window&&window.navigator?window.navigator.userAgent:null,zt=It?function(e){var t=null,n=[];for(var o in Et)if(Et.hasOwnProperty(o)&&(n=e.match(Et[o]))){(t={})[o]=!0,t[n[1].toLowerCase().split(" ")[0].split("/")[0]]=!0,t.version=parseInt(document.documentMode||n[2],10);break}return t}(It):null;It&&function(e){var t,n=[];for(var o in Tt)if(Tt.hasOwnProperty(o)){if(!(n=e.match(Tt[o])))continue;if("windows"===o&&"plugins"in window.navigator)return null;var r={};return r.device=o,r.browser=$t(e,Rt,"default"),r.name=$t(o,Dt),r[r.name]=!0,r.majorVersion=n[2],r.minorVersion=n[3]?n[3].replace("_","."):".0",t=r.minorVersion.replace(".","").substr(0,2),r.flatVersion=r.majorVersion+t+new Array(3-(t.length<3?t.length:2)).join("0"),r.cordova=void 0!==typeof window.PhoneGap||void 0!==typeof window.cordova,r.appMode=window.navigator.standalone||/file|local|wmapp/.test(window.location.protocol)||r.cordova,r}}(It),zt&&!zt.chrome&&window.MSPointerEvent,zt&&!zt.chrome&&window.PointerEvent;var Bt=/\/\*[\s\S]*?\*\//g,Pt=/([^\s:;]+?)\s*:\s*((?:(?:url\(\s*(?:(?:[^"')\\]|\\.)*|"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*')\s*\)|"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'|[^;"'])*?)\s*)(?=;|$)/gi,Vt=/&quot;|&#34;|&#x22;/gi,Ft=/&apos;|&#39;|&#x27;/gi;function Lt(e){for(var t,n,o={},r=(e||"").replace(Bt,"").replace(Vt,'"').replace(Ft,"'"),i=Pt.exec(r);null!==i;)t=i[1].trim(),n=i[2].trim(),o[t]=n,i=Pt.exec(r);return o}const Ht=(e,t)=>{const n=t.style,o=t.value,r=t.newValue;if(!e)return{changed:!1,style:null};const i=Zt(e),s=Object.keys(i),l=[];for(let e=0;e<s.length;e++){const t=s[e];t.toLowerCase()===n&&o.test(i[t])||l.push(`${t}: ${i[t]}`)}return r&&l.push(`${n}: ${r}`),{style:l.join("; ")+(l.length?";":""),changed:Boolean(r)||l.length!==s.length}},_t=/^.+$/;function Wt(e,t,n){let o;if(new RegExp("[^-]?"+t+":").test(e.style||"")){const{style:r}=Ht(e.style||"",{style:t,value:_t,newValue:n});o={...e,style:r}}else o=e.style?{...e,style:e.style.replace(/;$/,"")+"; "+t+": "+n+";"}:{...e,style:t+": "+n+";"};return o}const qt=e=>e instanceof A?e.type.name:e.name,Jt=(e,t=1)=>n=>((e,t=1)=>n=>{const{$from:o}=n;for(let n=o.depth;n>0;n--){const r=o.node(n);if(e(r)&&0==(t-=1))return{depth:n,node:r}}})((t=>qt(t)===qt(e)),t)(n);function jt(e,t){for(let n=e.depth;n>0;n--){const o=e.node(n);if(t(o))return{node:o,depth:n}}return null}const Kt=e=>{const t={};for(const n in e)n&&(e[n]||0===e[n])&&(t[n]=e[n]);return t},Xt=(e,t)=>(n,o)=>{const{selection:r,tr:i}=n;r instanceof st&&r.node.type.name===e.type.name&&e.isLeaf&&!e.isText&&1===e.nodeSize?(i.setNodeMarkup(r.from,null,{...Kt(r.node.attrs),...Kt(e.attrs)}),i.setSelection(st.create(i.doc,r.from))):i.replaceSelectionWith(e),t&&i.scrollIntoView(),o(i)},Ut=e=>{const t=e.selection;if(t instanceof rt||t instanceof at){const e=t.content().content;return e.textBetween(0,e.size)}return""},Gt={before:/[^ !,?.\[\]{}()]+$/i,after:/^[^ !,?.\[\]{}()]+/i},Yt=(e,t,n)=>{if(!n.applyToWord||!e.selection.empty)return{state:e,dispatch:t};const o=!0===n.applyToWord?Gt:n.applyToWord;let r=null;const i=e.tr,s=e.selection,l=s.$head.nodeBefore,a=s.$head.nodeAfter;if(l&&"text"===l.type.name&&l.text&&a&&"text"===a.type.name&&a.text){const n=[];s.$head.parent.descendants(((e,t)=>(n.push({node:e,pos:t}),!1)));let l=s.$head.parentOffset;const a=n.findIndex((({node:e,pos:t})=>t<=l&&t+e.nodeSize>=l));let c=n[a].node.text,d=!1;for(let e=a-1;e>=0;e--){const t=n[e];!d&&t&&"text"===t.node.type.name?c=t.node.text+c:(d=!0,l-=t.node.nodeSize)}for(let e=a+1;e<n.length;e++){const t=n[e];if(!t||"text"!==t.node.type.name)break;c+=t.node.text}const h=c.substring(0,l),p=c.substring(l),u=o.before.exec(h),f=o.after.exec(p);if(u&&f){const n=u[0].length,o=f[0].length,l=r=s.from;i.setSelection(rt.create(e.doc,l-n,l+o));return{state:{tr:i,selection:i.selection,doc:i.doc,storedMarks:null,schema:i.doc.type.schema},dispatch:e=>{e.setSelection(rt.create(e.doc,r)),t(e)}}}}return{state:e,dispatch:t}},Qt=(e,t)=>(n,o)=>{const{state:r,dispatch:i}=Yt(n,o,t);return e(t)(r,i)},Zt=e=>Lt(e),en=(e,t,n)=>{const o=Zt(e);o[t]=n;const r=Object.keys(o).map((e=>o[e]?`${e}: ${o[e]}`:null)).filter(Boolean).join("; ");return r?r+";":null},tn=(e,t)=>{const n=Zt(t);for(const t in n)t&&void 0!==e.style[t]&&(e.style[t]=n[t])},nn=(e,t,n)=>{const o=e.getAttribute(t);void 0!==n&&n!==o?"style"===t?(e.removeAttribute(t),tn(e,n)):e.setAttribute(t,n):void 0===n&&e.removeAttribute(t)};class on{static renderSpec(e,t,n=null){if("string"==typeof t)return{dom:e.createTextNode(t)};if(null!=t.nodeType)return{dom:t};if(t.dom&&null!=t.dom.nodeType)return t;let o,r=t[0],i=r.indexOf(" ");i>0&&(n=r.slice(0,i),r=r.slice(i+1));const s=n?e.createElementNS(n,r):e.createElement(r);let l=t[1],a=1;if(l&&"object"==typeof l&&null==l.nodeType&&!Array.isArray(l)){a=2;for(const e in l)null!=l[e]&&(i=e.indexOf(" "),i>0?s.setAttributeNS(e.slice(0,i),e.slice(i+1),l[e]):nn(s,e,l[e]))}for(let r=a;r<t.length;r++){const i=t[r];if(0===i){if(r<t.length-1||r>a)throw new RangeError("Content hole must be the only child of its parent node");return{dom:s,contentDOM:s}}{const{dom:t,contentDOM:r}=on.renderSpec(e,i,n);if(s.appendChild(t),r){if(o)throw new RangeError("Multiple content holes");o=r}}}return{dom:s,contentDOM:o}}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new on(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){const t=rn(e.nodes);return t.text||(t.text=e=>e.text),t}static marksFromSchema(e){return rn(e.marks)}constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},n){n||(n=sn(t).createDocumentFragment());let o=n,r=[];return e.forEach((e=>{if(r.length||e.marks.length){let n=0,i=0;for(;n<r.length&&i<e.marks.length;){const t=e.marks[i];if(this.marks[t.type.name]){if(!t.eq(r[n][0])||!1===t.type.spec.spanning)break;n++,i++}else i++}for(;n<r.length;)o=r.pop()[1];for(;i<e.marks.length;){const n=e.marks[i++],s=this.serializeMark(n,e.isInline,t);s&&(r.push([n,o]),o.appendChild(s.dom),o=s.contentDOM||s.dom)}}o.appendChild(this.serializeNodeInner(e,t))})),n}serializeNode(e,t={}){let n=this.serializeNodeInner(e,t);for(let o=e.marks.length-1;o>=0;o--){const r=this.serializeMark(e.marks[o],e.isInline,t);r&&((r.contentDOM||r.dom).appendChild(n),n=r.dom)}return n}serializeMark(e,t,n={}){const o=this.marks[e.type.name];return o&&on.renderSpec(sn(n),o(e,t))}serializeNodeInner(e,t){const{dom:n,contentDOM:o}=on.renderSpec(sn(t),this.nodes[e.type.name](e));if(o){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,o)}return n}}function rn(e){const t={};for(const n in e)if(e[n]){const o=e[n].spec.toDOM;o&&(t[n]=o)}return t}function sn(e){return e.document||window.document}const ln=["div","ol","ul","li","table","tbody","thead","tfoot","caption","td","th","p","tr","col","colgroup","article","main","nav","header","footer","aside","section"],an=(e,t)=>{const n=(e.ownerDocument||document).createElement(t);Array.from(e.rows).filter((e=>e.getAttribute(St)===t)).forEach((e=>{e.removeAttribute(St),n.appendChild(e)})),n.children.length&&e.appendChild(n)},cn=(e,t)=>{const n=t.toUpperCase();e.filter((e=>e.nodeName===n)).forEach((e=>{Array.from(e.children).forEach((n=>{n.setAttribute(St,t),e.parentNode&&e.parentNode.insertBefore(n,e)})),e.remove()}))},dn="data-style",hn=" "+dn+"=",pn=/<[^>]+>/gm,un=/\sstyle=/gm,fn=e=>e.replace(un,hn),mn=e=>{const t=document.createElement("template");var n;return t.innerHTML=(e=>e.replace(pn,fn))(e),n=t.content,Array.from(n.querySelectorAll("["+dn+"]")).forEach((e=>{const t=e.getAttribute(dn);e.removeAttribute(dn),tn(e,t)})),t.content.cloneNode(!0)},gn=e=>Array.from(e.childNodes).reduce(((e,t)=>e+(t.outerHTML||t.textContent||"")),""),yn=e=>{const t=on.fromSchema(e.type.schema).serializeFragment(e.content);return(e=>{Array.from(e.querySelectorAll("table")).forEach((e=>{an(e,"thead"),an(e,"tbody"),an(e,"tfoot");const t=Array.from(e.children).find((e=>0===e.children.length));t&&t.remove();const n=e.parentNode instanceof HTMLDivElement?e.parentNode:null;if(n&&n.matches("div[table]")){e.style.marginLeft=n.style.marginLeft,e.style.marginRight=n.style.marginRight;const t=Array.from(n.children).find((e=>e.matches("div[caption]")));if(t&&"<img>"!==t.innerHTML){const n=e.createCaption();for(t.id&&(n.id=t.id),t.className&&(n.className=t.className),Array.from(t.style).forEach((e=>{n.style[e]=t.style[e]}));t.firstChild;)n.appendChild(t.firstChild)}n.style.width&&!e.style.width&&(e.style.width=n.style.width),n.parentNode.insertBefore(e,n),n.parentNode.removeChild(n)}}))})(t),t},wn=(e,t,n)=>U.fromSchema(t).parse(e,n),vn=(e,t,n)=>{const o=mn(e);var r;return r=o,Array.from(r.querySelectorAll("table")).forEach((e=>{const t=Array.from(e.children);t.some((e=>"THEAD"===e.nodeName||"TFOOT"===e.nodeName))&&(cn(t,"thead"),cn(t,"tbody"),cn(t,"tfoot"));const n=t.find((e=>"COLGROUP"===e.nodeName));if(n&&(e.setAttribute(Ct,n.outerHTML),n.remove()),e.caption||e.style.marginLeft||e.style.marginRight){const t=document.createElement("div");if(t.setAttribute("table",""),t.style.display="table",t.style.marginLeft=e.style.marginLeft,t.style.marginRight=e.style.marginRight,e.caption){const n=document.createElement("div");for(n.setAttribute("caption",""),e.caption.id&&(n.id=e.caption.id),e.caption.className&&(n.className=e.caption.className),Array.from(e.caption.style).forEach((t=>{n.style[t]=e.caption.style[t]}));e.caption.firstChild;)n.appendChild(e.caption.firstChild);e.removeChild(e.caption),t.appendChild(n)}e.parentNode.insertBefore(t,e),t.appendChild(e),/%/.test(e.style.width)&&(t.style.width=e.style.width,e.style.width="")}})),wn(o,t,n)},bn=e=>{var t;const n=e.ownerDocument.createNodeIterator(e,NodeFilter.SHOW_COMMENT);let o=n.nextNode();for(;o;)null===(t=o.parentNode)||void 0===t||t.removeChild(o),o=n.nextNode()};class kn{constructor(e){this.extractBefore=e=>this._traverseSide({edge:e,next:function(e){return e.previousSibling},insert:function(e,t){e.insertBefore(t,e.firstChild)}}),this.extractAfter=e=>this._traverseSide({edge:e,next:function(e){return e.nextSibling},insert:function(e,t){e.appendChild(t)}}),this._traverseSide=e=>{const t=this.top,n=t.ownerDocument.createDocumentFragment();let o=e.edge;do{const r=o.parentNode;for(o=e.next(o);o;){const t=e.next(o);e.insert(n,o),o=t}if(t===r||t.contains(r)){const t=r.cloneNode(!1);t.innerHTML="",t.appendChild(n),e.insert(n,t)}o=r}while(o&&o!==t);return n},this.top=e}}const xn=e=>e.querySelector("span span"),Sn=e=>1===e.childNodes.length&&"SPAN"===e.firstChild.nodeName&&0===e.firstChild.childNodes.length,Cn=(e,t,n)=>{const o=o=>{const r=t[o],i=r.$from,s=r.$to;let l=0===i.depth&&e.type.allowsMarkType(n);if(e.nodesBetween(i.pos,s.pos,(e=>{if(l)return!1;l=e.inlineContent&&e.type.allowsMarkType(n)})),l)return{v:!0}};for(let e=0;e<t.length;e++){const t=o(e);if(t)return t.v}return!1},Mn=(e,t,n)=>(o,r)=>{const{empty:i,$cursor:s,ranges:l}=o.selection;if(i&&!s||!Cn(o.doc,l,e))return!1;if(r)if(s)e.isInSet(o.storedMarks||s.marks())?r(n.removeStoredMark(e)):r(n.addStoredMark(e.create(t)));else{let i=!1;for(let t=0;!i&&t<l.length;t++){const{$from:n,$to:r}=l[t];i=o.doc.rangeHasMark(n.pos,r.pos,e)}for(let o=0;o<l.length;o++){const{$from:r,$to:s}=l[o];i?n.removeMark(r.pos,s.pos,e):n.addMark(r.pos,s.pos,e.create(t))}r(n.scrollIntoView())}return!0},Nn=(e,t,n,o)=>{void 0===o&&(o=null);let r=[],i=0;return e.doc.nodesBetween(t,n,((e,s)=>{if(!e.isInline)return;i++;let l=null;if(o instanceof j){const t=o.isInSet(e.marks);t&&(l=[t])}else o?o.isInSet(e.marks)&&(l=[o]):l=e.marks;if(l&&l.length){const o=Math.min(s+e.nodeSize,n);for(let e=0;e<l.length;e++){let n,a=l[e];for(let e=0;e<r.length;e++){const t=r[e];t.step===i-1&&a.eq(t.style)&&(n=t)}n?(n.to=o,n.step=i):r.push({style:a,from:Math.max(s,t),to:o,step:i})}}})),r.forEach((t=>e.step(new ke(t.from,t.to,t.style)))),e},On=(e,{except:t})=>{const{doc:n,selection:o}=e,r=n.type.schema,{empty:i,ranges:s}=o,l=(t||[]).map((e=>e.name));if(!i){const t=Object.keys(r.marks).map((e=>r.marks[e])).filter((e=>-1===l.indexOf(e.name)));s.forEach((({$from:n,$to:o})=>{t.forEach((t=>e.removeMark(n.pos,o.pos,t)))}))}},An=(e,t)=>{const n=e.schema.marks,o=(t.altMarks||[]).filter((e=>n[e])),r=t.altStyle,{from:i,$from:s,to:l,empty:a}=e.selection,c=n[t.mark],d=e.doc;let h,p=!1;return a?(h=e.storedMarks||s.marks(),p=c&&c.isInSet(h)||o.some((e=>n[e].isInSet(h)))):p=c&&d.rangeHasMark(i,l,c)||o.some((e=>d.rangeHasMark(i,l,n[e]))),!p&&r&&n.style?Dn(e,n.style).some((e=>null!==Tn(e,r))):Boolean(p)},Tn=(e,t)=>{const n=e&&e.attrs.style||"",o=Zt(n),r=Object.keys(o);for(let e=0;e<r.length;e++){const n=r[e];if(n.toLowerCase()===t.name&&t.value.test(o[n]))return o[n]}return null},Dn=(e,t)=>{const{from:n,$from:o,to:r,empty:i}=e.selection,s=[];return i?s.push(t.isInSet(e.storedMarks||o.marks())):e.doc.nodesBetween(n,r,(e=>{e.isInline&&s.push(t.isInSet(e.marks))})),s},En=(e,t)=>{const n=e.find((e=>"style"===e.type.name)),o=n&&n.attrs.style;return Ht(o,t)},Rn=(e,t,n,o,r)=>{const i=r.create({style:o.style});let s=[],l=[],a=null,c=null;return e.doc.nodesBetween(t,n,((e,d,h)=>{if(!e.isInline)return;const p=e.marks;if(!i.isInSet(p)&&h.type.allowsMarkType(i.type)){const i=Math.max(d,t),h=Math.min(d+e.nodeSize,n),u=En(p,o);if(u.changed||o.newValue){const e=u.changed?{style:u.style||null}:{style:`${[o.style]}: ${o.newValue};`},t=r.isInSet(p)?p.find((e=>"style"===e.type.name)):null,n=t?{...t.attrs,...e}:e,d=r.create(n),f=d.addToSet(p);for(let e=0;e<p.length;e++)p[e].isInSet(f)||(a&&a.to===i&&a.mark.eq(p[e])?a.to=h:(a=new ke(i,h,p[e]),s.push(a)));const m=c&&c.to===i,g=m&&d.attrs.style===c.mark.attrs.style;m&&g?c.to=h:Object.keys(n).some((e=>null!==n[e]))&&(c=new be(i,h,d),l.push(c))}}})),s.forEach((t=>e.step(t))),l.forEach((t=>e.step(t))),s.length+l.length>0},$n=(e,t)=>function(n,o,r){const{empty:i,ranges:s}=n.selection,l=n.selection instanceof rt&&n.selection.$cursor;if(i&&!l||!Cn(n.doc,s,e))return!1;let a=!1;if(o){const i=r||n.tr;if(l){const r=n.storedMarks||l.marks();if(e.isInSet(r)){const n=En(r,t),s=r.find((e=>"style"===e.type.name)),l={...s?s.attrs:{},style:n.style||null};if(((e,t)=>{const n=Object.keys(e),o=Object.keys(t);return n.length===o.length&&n.every((n=>e[n]===t[n]))})(s.attrs,l))return!1;o(i.removeStoredMark(e)),Object.keys(l).some((e=>null!==l[e]))&&o(i.addStoredMark(e.create(l))),a=!0}}else{for(let n=0;n<s.length;n++){const{$from:o,$to:r}=s[n];a=Rn(i,o.pos,r.pos,t,e)||a}a&&(i.scrollIntoView(),o(i))}}return a},In=(e,t,n)=>(o,r)=>{const i=o.schema.marks,{altStyle:s,altMarks:l=[],mark:a}=e,c=t||o.tr;let d=!1,h=!1;const p=()=>h=!0;if(s&&i.style){d=$n(i.style,{style:s.name,value:s.value})(o,p,c)}const u=[a,...l].filter((e=>i[e])).map((e=>An(o,{mark:e})&&i[e])).filter((e=>e));return u.length?((e,t,n,o)=>{const{$cursor:r,ranges:i}=t.selection;if(o=o||t.tr,r)e.forEach((e=>{e.isInSet(t.storedMarks||r.marks())&&n(o.removeStoredMark(e))}));else{for(let t=0;t<i.length;t++){const{$from:n,$to:r}=i[t];e.forEach((e=>{Nn(o,n.pos,r.pos,e)}))}n(o.scrollIntoView())}})(u,o,p,c):d||Mn(i[a],n,c)(o,p),h&&r(c),h},zn=(e,t)=>(n,o)=>{const{$cursor:r}=n.selection;if(r){const i=r.parent,s=r.index(),l=n.schema.marks[e.mark],a=i.child(s).marks.find((e=>e.type===l)),c=i.childCount;let d,h,p=r.pos-r.textOffset,u=i.child(s).nodeSize;for(d=s-1;d>=0&&a.isInSet(i.child(d).marks);)h=i.child(d).nodeSize,u+=h,p-=h,d-=1;for(d=s+1;d<c&&a.isInSet(i.child(d).marks);)u+=i.child(d).nodeSize,d+=1;o(Nn(t||n.tr,p,p+u,a))}else In(e,t)(n,o)},Bn=(e,t,n,o)=>{if(!n.isTextblock)return!1;const{ranges:i}=e.selection;i.forEach((i=>{const s=e.steps.length,l=i.$from.pos,a=i.$to.pos;e.doc.nodesBetween(l,a,((i,l)=>{if(i.eq(t)&&i.isTextblock&&!i.hasMarkup(n,o)&&((e,t,n)=>{const o=e.resolve(t),r=o.index();return o.parent.canReplaceWith(r,r+1,n)})(e.doc,e.mapping.slice(s).map(l),n)){e.clearIncompatible(e.mapping.slice(s).map(l,1),n);const t=e.mapping.slice(s),a=t.map(l,1),c=t.map(l+i.nodeSize,1),h=new d(r.from(n.create(o,null,i.marks)),0,0);return e.step(new Me(a,c,a+1,c-1,h,1,!0)),!1}}))}))},Pn=(e,t={blocksInSelection:!1})=>{const{doc:n,selection:o}=e,{$from:r,ranges:i}=o,{blocksInSelection:s}=t,l=[],a=o instanceof st?o.node:void 0;return a?a.isBlock?(l.push(a),a.nodesBetween(0,a.content.size,(e=>{e.isBlock&&l.push(e)}))):!s&&r.parent&&r.parent.isBlock&&l.push(r.parent):i.forEach((e=>{const t=e.$from.pos,o=e.$to.pos;n.nodesBetween(t,o,((e,n)=>{e.isBlock&&(!s||n>=t&&n+e.content.size+2<=o)&&l.push(e)}))})),l},Vn=(e,t={blocksInSelection:!0})=>{const{doc:n,selection:o}=e,{blocksInSelection:r,blockNodeType:i}=t;Pn({doc:n,selection:o},{blocksInSelection:r}).filter((e=>e.isTextblock)).forEach((t=>{const{style:n="",class:o="",...r}=t.attrs||{},s=i||t.type;(n||o||s!==t.type)&&Bn(e,t,s,r)}))},Fn=e=>{const t=Pn(e),n=e.schema.nodes,o=[];return t.forEach((e=>{e.type===n.paragraph?o.push("p"):e.type===n.heading?o.push(`h${e.attrs.level}`):e.type===n.blockquote&&n.blockquote.isTextblock&&o.push("blockquote")})),o},Ln=(e,t)=>{let n,o,r=e.attrs.style;r&&t.forEach((e=>{o={style:e.name,value:/^.+$/,newValue:e.value},n=Ht(r,o),r=n.changed?n.style:r}));return r=r||t.reduce(((e,t)=>(e&&t.value?e+" ":"")+t.value?`${t.name}: ${t.value};`:""),""),Object.assign({},e.attrs,{style:r||null})},Hn=(e,t)=>{const{from:n,to:o}=e.selection;let r=!1;return e.doc.nodesBetween(n,o,(e=>(r=r||e.type===t,!r))),r},_n=e=>{const t=Fn(e);return 1===new Set(t).size?t[0]:null},Wn=["ol",0],qn=["ul",0],Jn=["li",0],jn={attrs:{order:{default:1,validate:"number"}},parseDOM:[{tag:"ol",getAttrs:e=>({order:e.hasAttribute("start")?+e.getAttribute("start"):1})}],toDOM:e=>1==e.attrs.order?Wn:["ol",{start:e.attrs.order},0]},Kn={parseDOM:[{tag:"ul"}],toDOM:()=>qn},Xn={parseDOM:[{tag:"li"}],toDOM:()=>Jn,defining:!0};function Un(e,t){let n={};for(let t in e)n[t]=e[t];for(let e in t)n[e]=t[e];return n}function Gn(e,t=null){return function(n,o){let{$from:r,$to:i}=n.selection,s=r.blockRange(i);if(!s)return!1;let l=o?n.tr:null;return!!Yn(l,s,e,t)&&(o&&o(l.scrollIntoView()),!0)}}function Yn(e,t,n,o=null){let i=!1,s=t,l=t.$from.doc;if(t.depth>=2&&t.$from.node(t.depth-1).type.compatibleContent(n)&&0==t.startIndex){if(0==t.$from.index(t.depth-1))return!1;let e=l.resolve(t.start-2);s=new N(e,e,t.depth),t.endIndex<t.parent.childCount&&(t=new N(t.$from,l.resolve(t.$to.end(t.depth)),t.depth)),i=!0}let a=De(s,n,o,t);return!!a&&(e&&function(e,t,n,o,i){let s=r.empty;for(let e=n.length-1;e>=0;e--)s=r.from(n[e].type.create(n[e].attrs,s));e.step(new Me(t.start-(o?2:0),t.end,t.start,t.end,new d(s,0,0),n.length,!0));let l=0;for(let e=0;e<n.length;e++)n[e].type==i&&(l=e+1);let a=n.length-l,c=t.start+n.length-(o?2:0),h=t.parent;for(let n=t.startIndex,o=t.endIndex,r=!0;n<o;n++,r=!1)!r&&Ie(e.doc,c,a)&&(e.split(c,a),c+=2*a),c+=h.child(n).nodeSize}(e,t,a,i,n),!0)}function Qn(e,t){return function(n,o){let{$from:i,$to:s,node:l}=n.selection;if(l&&l.isBlock||i.depth<2||!i.sameParent(s))return!1;let a=i.node(-1);if(a.type!=e)return!1;if(0==i.parent.content.size&&i.node(-1).childCount==i.indexAfter(-1)){if(3==i.depth||i.node(-3).type!=e||i.index(-2)!=i.node(-2).childCount-1)return!1;if(o){let t=r.empty,s=i.index(-1)?1:i.index(-2)?2:3;for(let e=i.depth-s;e>=i.depth-3;e--)t=r.from(i.node(e).copy(t));let l=i.indexAfter(-1)<i.node(-2).childCount?1:i.indexAfter(-2)<i.node(-3).childCount?2:3;t=t.append(r.from(e.createAndFill()));let a=i.before(i.depth-(s-1)),c=n.tr.replace(a,i.after(-l),new d(t,4-s,0)),h=-1;c.doc.nodesBetween(a,c.doc.content.size,((e,t)=>{if(h>-1)return!1;e.isTextblock&&0==e.content.size&&(h=t+1)})),h>-1&&c.setSelection(et.near(c.doc.resolve(h))),o(c.scrollIntoView())}return!0}let c=s.pos==i.end()?a.contentMatchAt(0).defaultType:null,h=n.tr.delete(i.pos,s.pos),p=c?[t?{type:e,attrs:t}:null,{type:c}]:void 0;return!!Ie(h.doc,i.pos,2,p)&&(o&&o(h.split(i.pos,2,p).scrollIntoView()),!0)}}function Zn(e){return function(t,n){let{$from:o,$to:i}=t.selection,s=o.blockRange(i,(t=>t.childCount>0&&t.firstChild.type==e));return!!s&&(!n||(o.node(s.depth-1).type==e?function(e,t,n,o){let i=e.tr,s=o.end,l=o.$to.end(o.depth);s<l&&(i.step(new Me(s-1,l,s,l,new d(r.from(n.create(null,o.parent.copy())),1,0),1,!0)),o=new N(i.doc.resolve(o.$from.pos),i.doc.resolve(l),o.depth));const a=Te(o);if(null==a)return!1;i.lift(o,a);let c=i.mapping.map(s,-1)-1;ze(i.doc,c)&&i.join(c);return t(i.scrollIntoView()),!0}(t,n,e,s):function(e,t,n){let o=e.tr,i=n.parent;for(let e=n.end,t=n.endIndex-1,r=n.startIndex;t>r;t--)e-=i.child(t).nodeSize,o.delete(e-1,e+1);let s=o.doc.resolve(n.start),l=s.nodeAfter;if(o.mapping.map(n.end)!=n.start+s.nodeAfter.nodeSize)return!1;let a=0==n.startIndex,c=n.endIndex==i.childCount,h=s.node(-1),p=s.index(-1);if(!h.canReplace(p+(a?0:1),p+1,l.content.append(c?r.empty:r.from(i))))return!1;let u=s.pos,f=u+l.nodeSize;return o.step(new Me(u-(a?1:0),f+(c?1:0),u+1,f-1,new d((a?r.empty:r.from(i.copy(r.empty))).append(c?r.empty:r.from(i.copy(r.empty))),a?0:1,c?0:1),a?0:1)),t(o.scrollIntoView()),!0}(t,n,s)))}}function eo(e){return function(t,n){let{$from:o,$to:i}=t.selection,s=o.blockRange(i,(t=>t.childCount>0&&t.firstChild.type==e));if(!s)return!1;let l=s.startIndex;if(0==l)return!1;let a=s.parent,c=a.child(l-1);if(c.type!=e)return!1;if(n){let o=c.lastChild&&c.lastChild.type==a.type,i=r.from(o?e.create():null),l=new d(r.from(e.create(null,r.from(a.type.create(null,i)))),o?3:1,0),h=s.start,p=s.end;n(t.tr.step(new Me(h-(o?3:1),p,h,p,l,1,!0)).scrollIntoView())}return!0}}const to={orderedList:"ordered_list",bulletList:"bullet_list",listItem:"list_item"},no={listType:to.orderedList,types:{...to}},oo={listType:to.bulletList,types:{...to}},ro={nodes:[{node:"paragraph",style:"margin-left",rtlStyle:"margin-right",step:30,unit:"px"},{node:"heading",style:"margin-left",rtlStyle:"margin-right",step:30,unit:"px"}],listsTypes:{...to}},io={nodes:[{node:"paragraph",style:"margin-left",rtlStyle:"margin-right",step:-30,unit:"px"},{node:"heading",style:"margin-left",rtlStyle:"margin-right",step:-30,unit:"px"}],listsTypes:{...to}},so=(e,t)=>!e.selection.empty&&(t&&t(e.tr.deleteSelection().scrollIntoView()),!0);function lo(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock("backward",e):n.parentOffset>0)?null:n}const ao=(e,t,n)=>{let o=lo(e,n);if(!o)return!1;let r=uo(o);if(!r){let n=o.blockRange(),r=n&&Te(n);return null!=r&&(t&&t(e.tr.lift(n,r).scrollIntoView()),!0)}let i=r.nodeBefore;if(Oo(e,r,t,-1))return!0;if(0==o.parent.content.size&&(ho(i,"end")||st.isSelectable(i)))for(let n=o.depth;;n--){let s=Le(e.doc,o.before(n),o.after(n),d.empty);if(s&&s.slice.size<s.to-s.from){if(t){let n=e.tr.step(s);n.setSelection(ho(i,"end")?et.findFrom(n.doc.resolve(n.mapping.map(r.pos,-1)),-1):st.create(n.doc,r.pos-i.nodeSize)),t(n.scrollIntoView())}return!0}if(1==n||o.node(n-1).childCount>1)break}return!(!i.isAtom||r.depth!=o.depth-1)&&(t&&t(e.tr.delete(r.pos-i.nodeSize,r.pos).scrollIntoView()),!0)};function co(e,t,n){let o=t.nodeBefore,r=t.pos-1;for(;!o.isTextblock;r--){if(o.type.spec.isolating)return!1;let e=o.lastChild;if(!e)return!1;o=e}let i=t.nodeAfter,s=t.pos+1;for(;!i.isTextblock;s++){if(i.type.spec.isolating)return!1;let e=i.firstChild;if(!e)return!1;i=e}let l=Le(e.doc,r,s,d.empty);if(!l||l.from!=r||l instanceof Ce&&l.slice.size>=s-r)return!1;if(n){let t=e.tr.step(l);t.setSelection(rt.create(t.doc,r)),n(t.scrollIntoView())}return!0}function ho(e,t,n=!1){for(let o=e;o;o="start"==t?o.firstChild:o.lastChild){if(o.isTextblock)return!0;if(n&&1!=o.childCount)return!1}return!1}const po=(e,t,n)=>{let{$head:o,empty:r}=e.selection,i=o;if(!r)return!1;if(o.parent.isTextblock){if(n?!n.endOfTextblock("backward",e):o.parentOffset>0)return!1;i=uo(o)}let s=i&&i.nodeBefore;return!(!s||!st.isSelectable(s))&&(t&&t(e.tr.setSelection(st.create(e.doc,i.pos-s.nodeSize)).scrollIntoView()),!0)};function uo(e){if(!e.parent.type.spec.isolating)for(let t=e.depth-1;t>=0;t--){if(e.index(t)>0)return e.doc.resolve(e.before(t+1));if(e.node(t).type.spec.isolating)break}return null}function fo(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock("forward",e):n.parentOffset<n.parent.content.size)?null:n}const mo=(e,t,n)=>{let o=fo(e,n);if(!o)return!1;let r=yo(o);if(!r)return!1;let i=r.nodeAfter;if(Oo(e,r,t,1))return!0;if(0==o.parent.content.size&&(ho(i,"start")||st.isSelectable(i))){let n=Le(e.doc,o.before(),o.after(),d.empty);if(n&&n.slice.size<n.to-n.from){if(t){let o=e.tr.step(n);o.setSelection(ho(i,"start")?et.findFrom(o.doc.resolve(o.mapping.map(r.pos)),1):st.create(o.doc,o.mapping.map(r.pos))),t(o.scrollIntoView())}return!0}}return!(!i.isAtom||r.depth!=o.depth-1)&&(t&&t(e.tr.delete(r.pos,r.pos+i.nodeSize).scrollIntoView()),!0)},go=(e,t,n)=>{let{$head:o,empty:r}=e.selection,i=o;if(!r)return!1;if(o.parent.isTextblock){if(n?!n.endOfTextblock("forward",e):o.parentOffset<o.parent.content.size)return!1;i=yo(o)}let s=i&&i.nodeAfter;return!(!s||!st.isSelectable(s))&&(t&&t(e.tr.setSelection(st.create(e.doc,i.pos)).scrollIntoView()),!0)};function yo(e){if(!e.parent.type.spec.isolating)for(let t=e.depth-1;t>=0;t--){let n=e.node(t);if(e.index(t)+1<n.childCount)return e.doc.resolve(e.after(t+1));if(n.type.spec.isolating)break}return null}const wo=(e,t)=>{let{$head:n,$anchor:o}=e.selection;return!(!n.parent.type.spec.code||!n.sameParent(o))&&(t&&t(e.tr.insertText("\n").scrollIntoView()),!0)};function vo(e){for(let t=0;t<e.edgeCount;t++){let{type:n}=e.edge(t);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}const bo=(e,t)=>{let{$head:n,$anchor:o}=e.selection;if(!n.parent.type.spec.code||!n.sameParent(o))return!1;let r=n.node(-1),i=n.indexAfter(-1),s=vo(r.contentMatchAt(i));if(!s||!r.canReplaceWith(i,i,s))return!1;if(t){let o=n.after(),r=e.tr.replaceWith(o,o,s.createAndFill());r.setSelection(et.near(r.doc.resolve(o),1)),t(r.scrollIntoView())}return!0},ko=(e,t)=>{let n=e.selection,{$from:o,$to:r}=n;if(n instanceof at||o.parent.inlineContent||r.parent.inlineContent)return!1;let i=vo(r.parent.contentMatchAt(r.indexAfter()));if(!i||!i.isTextblock)return!1;if(t){let n=(!o.parentOffset&&r.index()<r.parent.childCount?o:r).pos,s=e.tr.insert(n,i.createAndFill());s.setSelection(rt.create(s.doc,n+1)),t(s.scrollIntoView())}return!0},xo=(e,t)=>{let{$cursor:n}=e.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let o=n.before();if(Ie(e.doc,o))return t&&t(e.tr.split(o).scrollIntoView()),!0}let o=n.blockRange(),r=o&&Te(o);return null!=r&&(t&&t(e.tr.lift(o,r).scrollIntoView()),!0)};function So(e){return(t,n)=>{let{$from:o,$to:r}=t.selection;if(t.selection instanceof st&&t.selection.node.isBlock)return!(!o.parentOffset||!Ie(t.doc,o.pos))&&(n&&n(t.tr.split(o.pos).scrollIntoView()),!0);if(!o.depth)return!1;let i,s,l=[],a=!1,c=!1;for(let t=o.depth;;t--){if(o.node(t).isBlock){a=o.end(t)==o.pos+(o.depth-t),c=o.start(t)==o.pos-(o.depth-t),s=vo(o.node(t-1).contentMatchAt(o.indexAfter(t-1)));let n=e&&e(r.parent,a,o);l.unshift(n||(a&&s?{type:s}:null)),i=t;break}if(1==t)return!1;l.unshift(null)}let d=t.tr;(t.selection instanceof rt||t.selection instanceof at)&&d.deleteSelection();let h=d.mapping.map(o.pos),p=Ie(d.doc,h,l.length,l);if(p||(l[0]=s?{type:s}:null,p=Ie(d.doc,h,l.length,l)),d.split(h,l.length,l),!a&&c&&o.node(i).type!=s){let e=d.mapping.map(o.before(i)),t=d.doc.resolve(e);s&&o.node(i-1).canReplaceWith(t.index(),t.index()+1,s)&&d.setNodeMarkup(d.mapping.map(o.before(i)),s)}return n&&n(d.scrollIntoView()),!0}}const Co=So(),Mo=(e,t)=>Co(e,t&&(n=>{let o=e.storedMarks||e.selection.$to.parentOffset&&e.selection.$from.marks();o&&n.ensureMarks(o),t(n)})),No=(e,t)=>(t&&t(e.tr.setSelection(new at(e.doc))),!0);function Oo(e,t,n,o){let i,s,l=t.nodeBefore,a=t.nodeAfter,c=l.type.spec.isolating||a.type.spec.isolating;if(!c&&function(e,t,n){let o=t.nodeBefore,r=t.nodeAfter,i=t.index();return!(!(o&&r&&o.type.compatibleContent(r.type))||(!o.content.size&&t.parent.canReplace(i-1,i)?(n&&n(e.tr.delete(t.pos-o.nodeSize,t.pos).scrollIntoView()),0):!t.parent.canReplace(i,i+1)||!r.isTextblock&&!ze(e.doc,t.pos)||(n&&n(e.tr.join(t.pos).scrollIntoView()),0)))}(e,t,n))return!0;let h=!c&&t.parent.canReplace(t.index(),t.index()+1);if(h&&(i=(s=l.contentMatchAt(l.childCount)).findWrapping(a.type))&&s.matchType(i[0]||a.type).validEnd){if(n){let o=t.pos+a.nodeSize,s=r.empty;for(let e=i.length-1;e>=0;e--)s=r.from(i[e].create(null,s));s=r.from(l.copy(s));let c=e.tr.step(new Me(t.pos-1,o,t.pos,o,new d(s,1,0),i.length,!0)),h=c.doc.resolve(o+2*i.length);h.nodeAfter&&h.nodeAfter.type==l.type&&ze(c.doc,h.pos)&&c.join(h.pos),n(c.scrollIntoView())}return!0}let p=a.type.spec.isolating||o>0&&c?null:et.findFrom(t,1),u=p&&p.$from.blockRange(p.$to),f=u&&Te(u);if(null!=f&&f>=t.depth)return n&&n(e.tr.lift(u,f).scrollIntoView()),!0;if(h&&ho(a,"start",!0)&&ho(l,"end")){let o=l,i=[];for(;i.push(o),!o.isTextblock;)o=o.lastChild;let s=a,c=1;for(;!s.isTextblock;s=s.firstChild)c++;if(o.canReplace(o.childCount,o.childCount,s.content)){if(n){let o=r.empty;for(let e=i.length-1;e>=0;e--)o=r.from(i[e].copy(o));n(e.tr.step(new Me(t.pos-i.length,t.pos+a.nodeSize,t.pos+c,t.pos+a.nodeSize-c,new d(o,i.length,0),0,!0)).scrollIntoView())}return!0}}return!1}function Ao(e){return function(t,n){let o=t.selection,r=e<0?o.$from:o.$to,i=r.depth;for(;r.node(i).isInline;){if(!i)return!1;i--}return!!r.node(i).isTextblock&&(n&&n(t.tr.setSelection(rt.create(t.doc,e<0?r.start(i):r.end(i)))),!0)}}const To=Ao(-1),Do=Ao(1);function Eo(e,t=null){return function(n,o){let{$from:r,$to:i}=n.selection,s=r.blockRange(i),l=s&&De(s,e,t);return!!l&&(o&&o(n.tr.wrap(s,l).scrollIntoView()),!0)}}function Ro(e,t){return n=>{if(!n.isGeneric)return e(n);let o=[];for(let e=0;e<n.mapping.maps.length;e++){let t=n.mapping.maps[e];for(let e=0;e<o.length;e++)o[e]=t.map(o[e]);t.forEach(((e,t,n,r)=>o.push(n,r)))}let r=[];for(let e=0;e<o.length;e+=2){let i=o[e],s=o[e+1],l=n.doc.resolve(i),a=l.sharedDepth(s),c=l.node(a);for(let e=l.indexAfter(a),n=l.after(a+1);n<=s;++e){let o=c.maybeChild(e);if(!o)break;if(e&&-1==r.indexOf(n)){let i=c.child(e-1);i.type==o.type&&t(i,o)&&r.push(n)}n+=o.nodeSize}}r.sort(((e,t)=>e-t));for(let e=r.length-1;e>=0;e--)ze(n.doc,r[e])&&n.join(r[e]);e(n)}}function $o(e,t){let n=Array.isArray(t)?e=>t.indexOf(e.type.name)>-1:t;return(t,o,r)=>e(t,o&&Ro(o,n),r)}function Io(...e){return function(t,n,o){for(let r=0;r<e.length;r++)if(e[r](t,n,o))return!0;return!1}}let zo=Io(so,ao,po),Bo=Io(so,mo,go);const Po={Enter:Io(wo,ko,xo,Co),"Mod-Enter":bo,Backspace:zo,"Mod-Backspace":zo,"Shift-Backspace":zo,Delete:Bo,"Mod-Delete":Bo,"Mod-a":No},Vo={"Ctrl-h":Po.Backspace,"Alt-Backspace":Po["Mod-Backspace"],"Ctrl-d":Po.Delete,"Ctrl-Alt-Backspace":Po["Mod-Delete"],"Alt-Delete":Po["Mod-Delete"],"Alt-d":Po["Mod-Delete"],"Ctrl-a":To,"Ctrl-e":Do};for(let e in Po)Vo[e]=Po[e];const Fo=("undefined"!=typeof navigator?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!("undefined"==typeof os||!os.platform)&&"darwin"==os.platform())?Vo:Po,Lo=(e,t)=>{const{$from:n,$to:o}=e.selection,r=e.schema.nodes.blockquote,i=e.doc;let s=-1;const l=n.blockRange(o);l&&i.nodesBetween(l.start,l.end,((e,t)=>{e.type===r&&(s=t)}));const a=-1!==s;return t&&a&&t(e.tr.lift(l,i.resolve(s).depth)),a},Ho=(e,t,n)=>(o,r)=>{const i=Pn(o),s=o.tr;s.setMeta("commandName",t),i.forEach((t=>{if(t.type.isTextblock){let o;const r=e.find((e=>e.node===t.type.name));if(r){const e="rtl"===n?r.rtlStyle:r.style,i={name:e,value:r.step>0?`${r.step}${r.unit}`:""};if(t.attrs.style){const n=new RegExp(`${e}:\\s?(\\d+)${r.unit}`,"i"),o=t.attrs.style.match(n);if(o){let e=parseFloat(o[1])+r.step;e=e<=0?"":e,i.value=`${e}${e?r.unit:""}`}}o=Ln(t,[i])}o&&Bn(s,t,t.type,o)}}));const l=s.docChanged;return l&&r(s.scrollIntoView()),l},_o=(e,t,n)=>{const o=Pn(e);let r=!1;return o.forEach((e=>{if(!r&&e.type.isTextblock&&e.attrs.style){const o=t.find((t=>t.node===e.type.name));if(o){const t="rtl"===n?o.rtlStyle:o.style,i=new RegExp(`${t}:\\s?\\d+${o.unit}`,"i");r=i.test(e.attrs.style)}}})),r},Wo=(e,t)=>eo(t)(e),qo=(e,t)=>{const n=e.schema.nodes[t.listsTypes.listItem],o=e.schema.nodes[t.listsTypes.orderedList],r=e.schema.nodes[t.listsTypes.bulletList],i=!!Jt(o,2)(e.selection),s=!!Jt(r,2)(e.selection);return(i||s)&&Zn(n)(e)},Jo=(e,t)=>{const n=e.schema.nodes,o=n[ro.listsTypes.listItem];return(_o(e,t.nodes)||ro.nodes.some((t=>n[t.node]&&Hn(e,n[t.node]))))&&!Hn(e,o)},jo=(e,t,n)=>{let o=t.depth;const r=e.nodes[n.bulletList],i=e.nodes[n.orderedList],s=e.nodes[n.listItem];for(let e=t.depth;e>0;e--){const n=t.node(e);if(n.type!==r&&n.type!==i||(o=e),n.type!==r&&n.type!==i&&n.type!==s)break}return o-1};function Ko(e){return function(t,n,o){if(!o)return!1;const r=(t=o.state).schema.nodes[e.listType],{$from:i,$to:s}=t.selection,l=i.node(-2),a=i.node(-3),c=function(e,t,n,o){return 0===function(e,t,n){const o=[],r=function(e,t){const n=["blockquote","bulletList","orderedList"];if(1===t.depth)return t;let o=t.node(t.depth),r=t;for(;t.depth>=1;)o=(t=e.resolve(t.before(t.depth))).node(t.depth),o&&-1!==n.indexOf(o.type.name)&&(r=t);return r}(e,t).depth;let i=e.resolve(t.start(r));for(;i.pos<=n.start(n.depth);){const t=Math.min(i.depth,r),n=i.node(t);if(n&&o.push(n),0===t)break;let s=e.resolve(i.after(t));if(s.start(t)>=e.nodeSize-2)break;s.depth!==i.depth&&(s=e.resolve(s.pos+2)),i=s.depth?e.resolve(s.start(s.depth)):e.resolve(s.end(s.depth))}return o}(e,t,n).filter((e=>e.type!==o)).length}(t.doc,i,s,r);return(l&&l.type===r||a&&a.type===r)&&c?Uo(e)(t,n):(c||(Uo(e)(t,n),t=o.state),function(e,t={}){return $o(Gn(e,t),((t,n)=>t.type===n.type&&t.type===e))}(r,e.listAttrs)(t,n))}}function Xo(e,t,n,o){const i=o||e.schema.nodes.listItem,{$from:s,$to:l}=t;let a=s.blockRange(l,(e=>e.childCount&&e.firstChild.type===i));if(!a||a.depth<2||s.node(a.depth-1).type!==i)return n;const c=a.end,h=l.end(a.depth);return c<h&&(n.step(new Me(c-1,h,c,h,new d(r.from(i.create(void 0,a.parent.copy())),1,0),1,!0)),a=new N(n.doc.resolve(s.pos),n.doc.resolve(h),a.depth)),n.lift(a,Te(a)).scrollIntoView()}function Uo(e){return function(t,n){const{tr:o}=t,{$from:r,$to:i}=t.selection;return o.doc.nodesBetween(r.pos,i.pos,((n,r)=>{if(n.isTextblock||"blockquote"===n.type.name||"div"===n.type.name){const n=new st(o.doc.resolve(o.mapping.map(r))),i=n.$from.blockRange(n.$to);if(!i||n.$from.parent.type!==t.schema.nodes[e.listItem])return;const s=i&&Te(i);if(null==s)return!1;o.lift(i,s)}})),n&&n(o),!0}}const Go=/list\-style\-type:\s?([\w-]+)/,Yo=e=>{const t=e.style||"",n=Go.exec(t);return n&&n[1]||""},Qo=(e,t,n,o,r)=>{const{listType:i,listAttrs:s={style:null}}=o,{selection:l}=e,a=l.$from.node(l.$from.depth-2),c=l.$to.node(l.$to.depth-2);if(a&&a.type.name===i&&Yo(a.attrs)===Yo(s)&&c&&c.type.name===i&&Yo(c.attrs)===Yo(s)){const i=n.state.schema.nodes,s={bulletList:i[o.bulletList],orderedList:i[o.orderedList],listItem:i[o.listItem]},a=((e,t)=>{const{bulletList:n,orderedList:o,listItem:r}=t;let i;for(let t=e.depth-1;t>0;t--){const s=e.node(t);if(s.type!==n&&s.type!==o||(i=t),s.type!==n&&s.type!==o&&s.type!==r)break}return i})(l.$to,s);let c=function(e,t,n,o,r,i){i||(i=e.schema.nodes.listItem);let s=!1;return r.doc.nodesBetween(t,n,((n,l)=>{if(!s&&n.type===i&&l>t){s=!0;let t=o+3;for(;t>o+2;){const o=r.doc.resolve(r.mapping.map(l));t=o.depth;const s=r.doc.resolve(r.mapping.map(l+n.textContent.length)),a=new rt(o,s);r=Xo(e,a,r,i)}}})),r}(e,l.$to.pos,l.$to.end(a),a,n.state.tr,s.listItem);return c=function(e,t,n){const{from:o,to:r}=e.selection,{paragraph:i,heading:s}=e.schema.nodes,l=[];t.doc.nodesBetween(o,r,((e,t)=>{e.type!==i&&e.type!==s||l.push({node:e,pos:t})}));for(let o=l.length-1;o>=0;o--){const r=l[o],i=t.doc.resolve(t.mapping.map(r.pos));if(i.depth>0){let o;o=r.node.textContent&&r.node.textContent.length>0?t.doc.resolve(t.mapping.map(r.pos+r.node.textContent.length)):t.doc.resolve(t.mapping.map(r.pos+1));const s=i.blockRange(o);s&&t.lift(s,jo(e.schema,i,n))}}return t}(e,c,o),c.setMeta("commandName",r),t(c),!0}return Ko(o)(e,t,n)};const Zo=(e,t)=>({name:e,value:t}),er=[{node:"paragraph",style:[Zo("text-align","left")]},{node:"heading",style:[Zo("text-align","left")]},{node:"table_caption_external",style:[Zo("text-align","left")]}],tr=[{node:"paragraph",style:[Zo("text-align","right")]},{node:"heading",style:[Zo("text-align","right")]},{node:"table_caption_external",style:[Zo("text-align","right")]}],nr=[{node:"paragraph",style:[Zo("text-align","center")]},{node:"heading",style:[Zo("text-align","center")]},{node:"table_caption_external",style:[Zo("text-align","center")]}],or=[{node:"paragraph",style:[Zo("text-align","justify")]},{node:"heading",style:[Zo("text-align","justify")]},{node:"table_caption_external",style:[Zo("text-align","justify")]}],rr=[{node:"paragraph",style:[Zo("text-align","")]},{node:"heading",style:[Zo("text-align","")]},{node:"table_caption_external",style:[Zo("text-align","")]}],ir=function(e){for(var t=0;;t++)if(!(e=e.previousSibling))return t},sr=function(e){let t=e.assignedSlot||e.parentNode;return t&&11==t.nodeType?t.host:t};let lr=null;const ar=function(e,t,n){let o=lr||(lr=document.createRange());return o.setEnd(e,null==n?e.nodeValue.length:n),o.setStart(e,t||0),o},cr=function(e,t,n,o){return n&&(hr(e,t,n,o,-1)||hr(e,t,n,o,1))},dr=/^(img|br|input|textarea|hr)$/i;function hr(e,t,n,o,r){for(;;){if(e==n&&t==o)return!0;if(t==(r<0?0:pr(e))){let n=e.parentNode;if(!n||1!=n.nodeType||ur(e)||dr.test(e.nodeName)||"false"==e.contentEditable)return!1;t=ir(e)+(r<0?0:1),e=n}else{if(1!=e.nodeType)return!1;if("false"==(e=e.childNodes[t+(r<0?-1:0)]).contentEditable)return!1;t=r<0?pr(e):0}}}function pr(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function ur(e){let t;for(let n=e;n&&!(t=n.pmViewDesc);n=n.parentNode);return t&&t.node&&t.node.isBlock&&(t.dom==e||t.contentDOM==e)}const fr=function(e){return e.focusNode&&cr(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)};function mr(e,t){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=e,n.key=n.code=t,n}const gr="undefined"!=typeof navigator?navigator:null,yr="undefined"!=typeof document?document:null,wr=gr&&gr.userAgent||"",vr=/Edge\/(\d+)/.exec(wr),br=/MSIE \d/.exec(wr),kr=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(wr),xr=!!(br||kr||vr),Sr=br?document.documentMode:kr?+kr[1]:vr?+vr[1]:0,Cr=!xr&&/gecko\/(\d+)/i.test(wr);Cr&&(/Firefox\/(\d+)/.exec(wr)||[0,0])[1];const Mr=!xr&&/Chrome\/(\d+)/.exec(wr),Nr=!!Mr,Or=Mr?+Mr[1]:0,Ar=!xr&&!!gr&&/Apple Computer/.test(gr.vendor),Tr=Ar&&(/Mobile\/\w+/.test(wr)||!!gr&&gr.maxTouchPoints>2),Dr=Tr||!!gr&&/Mac/.test(gr.platform),Er=!!gr&&/Win/.test(gr.platform),Rr=/Android \d/.test(wr),$r=!!yr&&"webkitFontSmoothing"in yr.documentElement.style,Ir=$r?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function zr(e){let t=e.defaultView&&e.defaultView.visualViewport;return t?{left:0,right:t.width,top:0,bottom:t.height}:{left:0,right:e.documentElement.clientWidth,top:0,bottom:e.documentElement.clientHeight}}function Br(e,t){return"number"==typeof e?e:e[t]}function Pr(e){let t=e.getBoundingClientRect(),n=t.width/e.offsetWidth||1,o=t.height/e.offsetHeight||1;return{left:t.left,right:t.left+e.clientWidth*n,top:t.top,bottom:t.top+e.clientHeight*o}}function Vr(e,t,n){let o=e.someProp("scrollThreshold")||0,r=e.someProp("scrollMargin")||5,i=e.dom.ownerDocument;for(let s=n||e.dom;s;s=sr(s)){if(1!=s.nodeType)continue;let e=s,n=e==i.body,l=n?zr(i):Pr(e),a=0,c=0;if(t.top<l.top+Br(o,"top")?c=-(l.top-t.top+Br(r,"top")):t.bottom>l.bottom-Br(o,"bottom")&&(c=t.bottom-t.top>l.bottom-l.top?t.top+Br(r,"top")-l.top:t.bottom-l.bottom+Br(r,"bottom")),t.left<l.left+Br(o,"left")?a=-(l.left-t.left+Br(r,"left")):t.right>l.right-Br(o,"right")&&(a=t.right-l.right+Br(r,"right")),a||c)if(n)i.defaultView.scrollBy(a,c);else{let n=e.scrollLeft,o=e.scrollTop;c&&(e.scrollTop+=c),a&&(e.scrollLeft+=a);let r=e.scrollLeft-n,i=e.scrollTop-o;t={left:t.left-r,top:t.top-i,right:t.right-r,bottom:t.bottom-i}}if(n||/^(fixed|sticky)$/.test(getComputedStyle(s).position))break}}function Fr(e){let t=[],n=e.ownerDocument;for(let o=e;o&&(t.push({dom:o,top:o.scrollTop,left:o.scrollLeft}),e!=n);o=sr(o));return t}function Lr(e,t){for(let n=0;n<e.length;n++){let{dom:o,top:r,left:i}=e[n];o.scrollTop!=r+t&&(o.scrollTop=r+t),o.scrollLeft!=i&&(o.scrollLeft=i)}}let Hr=null;function _r(e,t){let n,o,r,i,s=2e8,l=0,a=t.top,c=t.top;for(let d=e.firstChild,h=0;d;d=d.nextSibling,h++){let e;if(1==d.nodeType)e=d.getClientRects();else{if(3!=d.nodeType)continue;e=ar(d).getClientRects()}for(let p=0;p<e.length;p++){let u=e[p];if(u.top<=a&&u.bottom>=c){a=Math.max(u.bottom,a),c=Math.min(u.top,c);let e=u.left>t.left?u.left-t.left:u.right<t.left?t.left-u.right:0;if(e<s){n=d,s=e,o=e&&3==n.nodeType?{left:u.right<t.left?u.right:u.left,top:t.top}:t,1==d.nodeType&&e&&(l=h+(t.left>=(u.left+u.right)/2?1:0));continue}}else u.top>t.top&&!r&&u.left<=t.left&&u.right>=t.left&&(r=d,i={left:Math.max(u.left,Math.min(u.right,t.left)),top:u.top});!n&&(t.left>=u.right&&t.top>=u.top||t.left>=u.left&&t.top>=u.bottom)&&(l=h+1)}}return!n&&r&&(n=r,o=i,s=0),n&&3==n.nodeType?function(e,t){let n=e.nodeValue.length,o=document.createRange();for(let r=0;r<n;r++){o.setEnd(e,r+1),o.setStart(e,r);let n=Kr(o,1);if(n.top!=n.bottom&&Wr(t,n))return{node:e,offset:r+(t.left>=(n.left+n.right)/2?1:0)}}return{node:e,offset:0}}(n,o):!n||s&&1==n.nodeType?{node:e,offset:l}:_r(n,o)}function Wr(e,t){return e.left>=t.left-1&&e.left<=t.right+1&&e.top>=t.top-1&&e.top<=t.bottom+1}function qr(e,t,n){let o=e.childNodes.length;if(o&&n.top<n.bottom)for(let r=Math.max(0,Math.min(o-1,Math.floor(o*(t.top-n.top)/(n.bottom-n.top))-2)),i=r;;){let n=e.childNodes[i];if(1==n.nodeType){let e=n.getClientRects();for(let o=0;o<e.length;o++){let r=e[o];if(Wr(t,r))return qr(n,t,r)}}if((i=(i+1)%o)==r)break}return e}function Jr(e,t){let n,o=e.dom.ownerDocument,r=0,i=function(e,t,n){if(e.caretPositionFromPoint)try{let o=e.caretPositionFromPoint(t,n);if(o)return{node:o.offsetNode,offset:Math.min(pr(o.offsetNode),o.offset)}}catch(e){}if(e.caretRangeFromPoint){let o=e.caretRangeFromPoint(t,n);if(o)return{node:o.startContainer,offset:Math.min(pr(o.startContainer),o.startOffset)}}}(o,t.left,t.top);i&&({node:n,offset:r}=i);let s,l=(e.root.elementFromPoint?e.root:o).elementFromPoint(t.left,t.top);if(!l||!e.dom.contains(1!=l.nodeType?l.parentNode:l)){let n=e.dom.getBoundingClientRect();if(!Wr(t,n))return null;if(l=qr(e.dom,t,n),!l)return null}if(Ar)for(let e=l;n&&e;e=sr(e))e.draggable&&(n=void 0);if(l=function(e,t){let n=e.parentNode;return n&&/^li$/i.test(n.nodeName)&&t.left<e.getBoundingClientRect().left?n:e}(l,t),n){if(Cr&&1==n.nodeType&&(r=Math.min(r,n.childNodes.length),r<n.childNodes.length)){let e,o=n.childNodes[r];"IMG"==o.nodeName&&(e=o.getBoundingClientRect()).right<=t.left&&e.bottom>t.top&&r++}let o;$r&&r&&1==n.nodeType&&1==(o=n.childNodes[r-1]).nodeType&&"false"==o.contentEditable&&o.getBoundingClientRect().top>=t.top&&r--,n==e.dom&&r==n.childNodes.length-1&&1==n.lastChild.nodeType&&t.top>n.lastChild.getBoundingClientRect().bottom?s=e.state.doc.content.size:0!=r&&1==n.nodeType&&"BR"==n.childNodes[r-1].nodeName||(s=function(e,t,n,o){let r=-1;for(let n=t,i=!1;n!=e.dom;){let t,s=e.docView.nearestDesc(n,!0);if(!s)return null;if(1==s.dom.nodeType&&(s.node.isBlock&&s.parent||!s.contentDOM)&&((t=s.dom.getBoundingClientRect()).width||t.height)&&(s.node.isBlock&&s.parent&&(!i&&t.left>o.left||t.top>o.top?r=s.posBefore:(!i&&t.right<o.left||t.bottom<o.top)&&(r=s.posAfter),i=!0),!s.contentDOM&&r<0&&!s.node.isText))return(s.node.isBlock?o.top<(t.top+t.bottom)/2:o.left<(t.left+t.right)/2)?s.posBefore:s.posAfter;n=s.dom.parentNode}return r>-1?r:e.docView.posFromDOM(t,n,-1)}(e,n,r,t))}null==s&&(s=function(e,t,n){let{node:o,offset:r}=_r(t,n),i=-1;if(1==o.nodeType&&!o.firstChild){let e=o.getBoundingClientRect();i=e.left!=e.right&&n.left>(e.left+e.right)/2?1:-1}return e.docView.posFromDOM(o,r,i)}(e,l,t));let a=e.docView.nearestDesc(l,!0);return{pos:s,inside:a?a.posAtStart-a.border:-1}}function jr(e){return e.top<e.bottom||e.left<e.right}function Kr(e,t){let n=e.getClientRects();if(n.length){let e=n[t<0?0:n.length-1];if(jr(e))return e}return Array.prototype.find.call(n,jr)||e.getBoundingClientRect()}const Xr=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Ur(e,t,n){let{node:o,offset:r,atom:i}=e.docView.domFromPos(t,n<0?-1:1),s=$r||Cr;if(3==o.nodeType){if(!s||!Xr.test(o.nodeValue)&&(n<0?r:r!=o.nodeValue.length)){let e=r,t=r,i=n<0?1:-1;return n<0&&!r?(t++,i=-1):n>=0&&r==o.nodeValue.length?(e--,i=1):n<0?e--:t++,Gr(Kr(ar(o,e,t),i),i<0)}{let e=Kr(ar(o,r,r),n);if(Cr&&r&&/\s/.test(o.nodeValue[r-1])&&r<o.nodeValue.length){let t=Kr(ar(o,r-1,r-1),-1);if(t.top==e.top){let n=Kr(ar(o,r,r+1),-1);if(n.top!=e.top)return Gr(n,n.left<t.left)}}return e}}if(!e.state.doc.resolve(t-(i||0)).parent.inlineContent){if(null==i&&r&&(n<0||r==pr(o))){let e=o.childNodes[r-1];if(1==e.nodeType)return Yr(e.getBoundingClientRect(),!1)}if(null==i&&r<pr(o)){let e=o.childNodes[r];if(1==e.nodeType)return Yr(e.getBoundingClientRect(),!0)}return Yr(o.getBoundingClientRect(),n>=0)}if(null==i&&r&&(n<0||r==pr(o))){let e=o.childNodes[r-1],t=3==e.nodeType?ar(e,pr(e)-(s?0:1)):1!=e.nodeType||"BR"==e.nodeName&&e.nextSibling?null:e;if(t)return Gr(Kr(t,1),!1)}if(null==i&&r<pr(o)){let e=o.childNodes[r];for(;e.pmViewDesc&&e.pmViewDesc.ignoreForCoords;)e=e.nextSibling;let t=e?3==e.nodeType?ar(e,0,s?0:1):1==e.nodeType?e:null:null;if(t)return Gr(Kr(t,-1),!0)}return Gr(Kr(3==o.nodeType?ar(o):o,-n),n>=0)}function Gr(e,t){if(0==e.width)return e;let n=t?e.left:e.right;return{top:e.top,bottom:e.bottom,left:n,right:n}}function Yr(e,t){if(0==e.height)return e;let n=t?e.top:e.bottom;return{top:n,bottom:n,left:e.left,right:e.right}}function Qr(e,t,n){let o=e.state,r=e.root.activeElement;o!=t&&e.updateState(t),r!=e.dom&&e.focus();try{return n()}finally{o!=t&&e.updateState(o),r!=e.dom&&r&&r.focus()}}const Zr=/[\u0590-\u08ac]/;let ei=null,ti=null,ni=!1;function oi(e,t,n){return ei==t&&ti==n?ni:(ei=t,ti=n,ni="up"==n||"down"==n?function(e,t,n){let o=t.selection,r="up"==n?o.$from:o.$to;return Qr(e,t,(()=>{let{node:t}=e.docView.domFromPos(r.pos,"up"==n?-1:1);for(;;){let n=e.docView.nearestDesc(t,!0);if(!n)break;if(n.node.isBlock){t=n.contentDOM||n.dom;break}t=n.dom.parentNode}let o=Ur(e,r.pos,1);for(let e=t.firstChild;e;e=e.nextSibling){let t;if(1==e.nodeType)t=e.getClientRects();else{if(3!=e.nodeType)continue;t=ar(e,0,e.nodeValue.length).getClientRects()}for(let e=0;e<t.length;e++){let r=t[e];if(r.bottom>r.top+1&&("up"==n?o.top-r.top>2*(r.bottom-o.top):r.bottom-o.bottom>2*(o.bottom-r.top)))return!1}}return!0}))}(e,t,n):function(e,t,n){let{$head:o}=t.selection;if(!o.parent.isTextblock)return!1;let r=o.parentOffset,i=!r,s=r==o.parent.content.size,l=e.domSelection();return l?Zr.test(o.parent.textContent)&&l.modify?Qr(e,t,(()=>{let{focusNode:t,focusOffset:r,anchorNode:i,anchorOffset:s}=e.domSelectionRange(),a=l.caretBidiLevel;l.modify("move",n,"character");let c=o.depth?e.docView.domAfterPos(o.before()):e.dom,{focusNode:d,focusOffset:h}=e.domSelectionRange(),p=d&&!c.contains(1==d.nodeType?d:d.parentNode)||t==d&&r==h;try{l.collapse(i,s),t&&(t!=i||r!=s)&&l.extend&&l.extend(t,r)}catch(e){}return null!=a&&(l.caretBidiLevel=a),p})):"left"==n||"backward"==n?i:s:o.pos==o.start()||o.pos==o.end()}(e,t,n))}class ri{constructor(e,t,n,o){this.parent=e,this.children=t,this.dom=n,this.contentDOM=o,this.dirty=0,n.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,n){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;t<this.children.length;t++)e+=this.children[t].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let t=0,n=this.posAtStart;;t++){let o=this.children[t];if(o==e)return n;n+=o.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,t,n){if(this.contentDOM&&this.contentDOM.contains(1==e.nodeType?e:e.parentNode)){if(n<0){let n,o;if(e==this.contentDOM)n=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;n=e.previousSibling}for(;n&&(!(o=n.pmViewDesc)||o.parent!=this);)n=n.previousSibling;return n?this.posBeforeChild(o)+o.size:this.posAtStart}{let n,o;if(e==this.contentDOM)n=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;n=e.nextSibling}for(;n&&(!(o=n.pmViewDesc)||o.parent!=this);)n=n.nextSibling;return n?this.posBeforeChild(o):this.posAtEnd}}let o;if(e==this.dom&&this.contentDOM)o=t>ir(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))o=2&e.compareDocumentPosition(this.contentDOM);else if(this.dom.firstChild){if(0==t)for(let t=e;;t=t.parentNode){if(t==this.dom){o=!1;break}if(t.previousSibling)break}if(null==o&&t==e.childNodes.length)for(let t=e;;t=t.parentNode){if(t==this.dom){o=!0;break}if(t.nextSibling)break}}return(null==o?n>0:o)?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let n=!0,o=e;o;o=o.parentNode){let r,i=this.getDesc(o);if(i&&(!t||i.node)){if(!n||!(r=i.nodeDOM)||(1==r.nodeType?r.contains(1==e.nodeType?e:e.parentNode):r==e))return i;n=!1}}}getDesc(e){let t=e.pmViewDesc;for(let e=t;e;e=e.parent)if(e==this)return t}posFromDOM(e,t,n){for(let o=e;o;o=o.parentNode){let r=this.getDesc(o);if(r)return r.localPosFromDOM(e,t,n)}return-1}descAt(e){for(let t=0,n=0;t<this.children.length;t++){let o=this.children[t],r=n+o.size;if(n==e&&r!=n){for(;!o.border&&o.children.length;)o=o.children[0];return o}if(e<r)return o.descAt(e-n-o.border);n=r}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let n=0,o=0;for(let t=0;n<this.children.length;n++){let r=this.children[n],i=t+r.size;if(i>e||r instanceof hi){o=e-t;break}t=i}if(o)return this.children[n].domFromPos(o-this.children[n].border,t);for(let e;n&&!(e=this.children[n-1]).size&&e instanceof ii&&e.side>=0;n--);if(t<=0){let e,o=!0;for(;e=n?this.children[n-1]:null,e&&e.dom.parentNode!=this.contentDOM;n--,o=!1);return e&&t&&o&&!e.border&&!e.domAtom?e.domFromPos(e.size,t):{node:this.contentDOM,offset:e?ir(e.dom)+1:0}}{let e,o=!0;for(;e=n<this.children.length?this.children[n]:null,e&&e.dom.parentNode!=this.contentDOM;n++,o=!1);return e&&o&&!e.border&&!e.domAtom?e.domFromPos(0,t):{node:this.contentDOM,offset:e?ir(e.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,n=0){if(0==this.children.length)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let o=-1,r=-1;for(let i=n,s=0;;s++){let n=this.children[s],l=i+n.size;if(-1==o&&e<=l){let r=i+n.border;if(e>=r&&t<=l-n.border&&n.node&&n.contentDOM&&this.contentDOM.contains(n.contentDOM))return n.parseRange(e,t,r);e=i;for(let t=s;t>0;t--){let n=this.children[t-1];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(1)){o=ir(n.dom)+1;break}e-=n.size}-1==o&&(o=0)}if(o>-1&&(l>t||s==this.children.length-1)){t=l;for(let e=s+1;e<this.children.length;e++){let n=this.children[e];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(-1)){r=ir(n.dom);break}t+=n.size}-1==r&&(r=this.contentDOM.childNodes.length);break}i=l}return{node:this.contentDOM,from:e,to:t,fromOffset:o,toOffset:r}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let t=this.children[e<0?0:this.children.length-1];return 0==t.size||t.emptyChildAt(e)}domAfterPos(e){let{node:t,offset:n}=this.domFromPos(e,0);if(1!=t.nodeType||n==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[n]}setSelection(e,t,n,o=!1){let r=Math.min(e,t),i=Math.max(e,t);for(let s=0,l=0;s<this.children.length;s++){let a=this.children[s],c=l+a.size;if(r>l&&i<c)return a.setSelection(e-l-a.border,t-l-a.border,n,o);l=c}let s=this.domFromPos(e,e?-1:1),l=t==e?s:this.domFromPos(t,t?-1:1),a=n.root.getSelection(),c=n.domSelectionRange(),d=!1;if((Cr||Ar)&&e==t){let{node:e,offset:t}=s;if(3==e.nodeType){if(d=!(!t||"\n"!=e.nodeValue[t-1]),d&&t==e.nodeValue.length)for(let t,n=e;n;n=n.parentNode){if(t=n.nextSibling){"BR"==t.nodeName&&(s=l={node:t.parentNode,offset:ir(t)+1});break}let e=n.pmViewDesc;if(e&&e.node&&e.node.isBlock)break}}else{let n=e.childNodes[t-1];d=n&&("BR"==n.nodeName||"false"==n.contentEditable)}}if(Cr&&c.focusNode&&c.focusNode!=l.node&&1==c.focusNode.nodeType){let e=c.focusNode.childNodes[c.focusOffset];e&&"false"==e.contentEditable&&(o=!0)}if(!(o||d&&Ar)&&cr(s.node,s.offset,c.anchorNode,c.anchorOffset)&&cr(l.node,l.offset,c.focusNode,c.focusOffset))return;let h=!1;if((a.extend||e==t)&&!d){a.collapse(s.node,s.offset);try{e!=t&&a.extend(l.node,l.offset),h=!0}catch(e){}}if(!h){if(e>t){let e=s;s=l,l=e}let n=document.createRange();n.setEnd(l.node,l.offset),n.setStart(s.node,s.offset),a.removeAllRanges(),a.addRange(n)}}ignoreMutation(e){return!this.contentDOM&&"selection"!=e.type}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let n=0,o=0;o<this.children.length;o++){let r=this.children[o],i=n+r.size;if(n==i?e<=i&&t>=n:e<i&&t>n){let o=n+r.border,s=i-r.border;if(e>=o&&t<=s)return this.dirty=e==n||t==i?2:1,void(e!=o||t!=s||!r.contentLost&&r.dom.parentNode==this.contentDOM?r.markDirty(e-o,t-o):r.dirty=3);r.dirty=r.dom!=r.contentDOM||r.dom.parentNode!=this.contentDOM||r.children.length?3:2}n=i}this.dirty=2}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let n=1==e?2:1;t.dirty<n&&(t.dirty=n)}}get domAtom(){return!1}get ignoreForCoords(){return!1}isText(e){return!1}}class ii extends ri{constructor(e,t,n,o){let r,i=t.type.toDOM;if("function"==typeof i&&(i=i(n,(()=>r?r.parent?r.parent.posBeforeChild(r):void 0:o))),!t.type.spec.raw){if(1!=i.nodeType){let e=document.createElement("span");e.appendChild(i),i=e}i.contentEditable="false",i.classList.add("ProseMirror-widget")}super(e,[],i,null),this.widget=t,this.widget=t,r=this}matchesWidget(e){return 0==this.dirty&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return!!t&&t(e)}ignoreMutation(e){return"selection"!=e.type||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get side(){return this.widget.type.side}}class si extends ri{constructor(e,t,n,o){super(e,[],t,null),this.textDOM=n,this.text=o}get size(){return this.text.length}localPosFromDOM(e,t){return e!=this.textDOM?this.posAtStart+(t?this.size:0):this.posAtStart+t}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return"characterData"===e.type&&e.target.nodeValue==e.oldValue}}class li extends ri{constructor(e,t,n,o,r){super(e,[],n,o),this.mark=t,this.spec=r}static create(e,t,n,o){let r=o.nodeViews[t.type.name],i=r&&r(t,o,n);return i&&i.dom||(i=ie.renderSpec(document,t.type.spec.toDOM(t,n),null,t.attrs)),new li(e,t,i.dom,i.contentDOM||i.dom,i)}parseRule(){return 3&this.dirty||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return 3!=this.dirty&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),0!=this.dirty){let e=this.parent;for(;!e.node;)e=e.parent;e.dirty<this.dirty&&(e.dirty=this.dirty),this.dirty=0}}slice(e,t,n){let o=li.create(this.parent,this.mark,!0,n),r=this.children,i=this.size;t<i&&(r=Ci(r,t,i,n)),e>0&&(r=Ci(r,0,e,n));for(let e=0;e<r.length;e++)r[e].parent=o;return o.children=r,o}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class ai extends ri{constructor(e,t,n,o,r,i,s,l,a){super(e,[],r,i),this.node=t,this.outerDeco=n,this.innerDeco=o,this.nodeDOM=s}static create(e,t,n,o,r,i){let s,l=r.nodeViews[t.type.name],a=l&&l(t,r,(()=>s?s.parent?s.parent.posBeforeChild(s):void 0:i),n,o),c=a&&a.dom,d=a&&a.contentDOM;if(t.isText)if(c){if(3!=c.nodeType)throw new RangeError("Text must be rendered as a DOM text node")}else c=document.createTextNode(t.text);else if(!c){let e=ie.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs);({dom:c,contentDOM:d}=e)}d||t.isText||"BR"==c.nodeName||(c.hasAttribute("contenteditable")||(c.contentEditable="false"),t.type.spec.draggable&&(c.draggable=!0));let h=c;return c=vi(c,n,t),a?s=new pi(e,t,n,o,c,d||null,h,a,r,i+1):t.isText?new di(e,t,n,o,c,h,r):new ai(e,t,n,o,c,d||null,h,r,i+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if("pre"==this.node.type.whitespace&&(e.preserveWhitespace="full"),this.contentDOM)if(this.contentLost){for(let t=this.children.length-1;t>=0;t--){let n=this.children[t];if(this.dom.contains(n.dom.parentNode)){e.contentElement=n.dom.parentNode;break}}e.contentElement||(e.getContent=()=>r.empty)}else e.contentElement=this.contentDOM;else e.getContent=()=>this.node.content;return e}matchesNode(e,t,n){return 0==this.dirty&&e.eq(this.node)&&bi(t,this.outerDeco)&&n.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let n=this.node.inlineContent,o=t,r=e.composing?this.localCompositionInfo(e,t):null,i=r&&r.pos>-1?r:null,s=r&&r.pos<0,l=new xi(this,i&&i.node,e);!function(e,t,n,o){let r=t.locals(e),i=0;if(0==r.length){for(let n=0;n<e.childCount;n++){let s=e.child(n);o(s,r,t.forChild(i,s),n),i+=s.nodeSize}return}let s=0,l=[],a=null;for(let c=0;;){let d,h,p,u;for(;s<r.length&&r[s].to==i;){let e=r[s++];e.widget&&(d?(h||(h=[d])).push(e):d=e)}if(d)if(h){h.sort(Si);for(let e=0;e<h.length;e++)n(h[e],c,!!a)}else n(d,c,!!a);if(a)u=-1,p=a,a=null;else{if(!(c<e.childCount))break;u=c,p=e.child(c++)}for(let e=0;e<l.length;e++)l[e].to<=i&&l.splice(e--,1);for(;s<r.length&&r[s].from<=i&&r[s].to>i;)l.push(r[s++]);let f=i+p.nodeSize;if(p.isText){let e=f;s<r.length&&r[s].from<e&&(e=r[s].from);for(let t=0;t<l.length;t++)l[t].to<e&&(e=l[t].to);e<f&&(a=p.cut(e-i),p=p.cut(0,e-i),f=e,u=-1)}else for(;s<r.length&&r[s].to<f;)s++;o(p,p.isInline&&!p.isLeaf?l.filter((e=>!e.inline)):l.slice(),t.forChild(i,p),u),i=f}}(this.node,this.innerDeco,((t,r,i)=>{t.spec.marks?l.syncToMarks(t.spec.marks,n,e):t.type.side>=0&&!i&&l.syncToMarks(r==this.node.childCount?a.none:this.node.child(r).marks,n,e),l.placeWidget(t,e,o)}),((t,i,a,c)=>{let d;l.syncToMarks(t.marks,n,e),l.findNodeMatch(t,i,a,c)||s&&e.state.selection.from>o&&e.state.selection.to<o+t.nodeSize&&(d=l.findIndexWithChild(r.node))>-1&&l.updateNodeAt(t,i,a,d,e)||l.updateNextNode(t,i,a,e,c,o)||l.addNode(t,i,a,e,o),o+=t.nodeSize})),l.syncToMarks([],n,e),this.node.isTextblock&&l.addTextblockHacks(),l.destroyRest(),(l.changed||2==this.dirty)&&(i&&this.protectLocalComposition(e,i),ui(this.contentDOM,this.children,e),Tr&&function(e){if("UL"==e.nodeName||"OL"==e.nodeName){let t=e.style.cssText;e.style.cssText=t+"; list-style: square !important",window.getComputedStyle(e).listStyle,e.style.cssText=t}}(this.dom))}localCompositionInfo(e,t){let{from:n,to:o}=e.state.selection;if(!(e.state.selection instanceof rt)||n<t||o>t+this.node.content.size)return null;let r=e.input.compositionNode;if(!r||!this.dom.contains(r.parentNode))return null;if(this.node.inlineContent){let e=r.nodeValue,i=function(e,t,n,o){for(let r=0,i=0;r<e.childCount&&i<=o;){let s=e.child(r++),l=i;if(i+=s.nodeSize,!s.isText)continue;let a=s.text;for(;r<e.childCount;){let t=e.child(r++);if(i+=t.nodeSize,!t.isText)break;a+=t.text}if(i>=n){if(i>=o&&a.slice(o-t.length-l,o-l)==t)return o-t.length;let e=l<o?a.lastIndexOf(t,o-l-1):-1;if(e>=0&&e+t.length+l>=n)return l+e;if(n==o&&a.length>=o+t.length-l&&a.slice(o-l,o-l+t.length)==t)return o}}return-1}(this.node.content,e,n-t,o-t);return i<0?null:{node:r,pos:i,text:e}}return{node:r,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:n,text:o}){if(this.getDesc(t))return;let r=t;for(;r.parentNode!=this.contentDOM;r=r.parentNode){for(;r.previousSibling;)r.parentNode.removeChild(r.previousSibling);for(;r.nextSibling;)r.parentNode.removeChild(r.nextSibling);r.pmViewDesc&&(r.pmViewDesc=void 0)}let i=new si(this,r,t,o);e.input.compositionNodes.push(i),this.children=Ci(this.children,n,n+o.length,e,i)}update(e,t,n,o){return!(3==this.dirty||!e.sameMarkup(this.node))&&(this.updateInner(e,t,n,o),!0)}updateInner(e,t,n,o){this.updateOuterDeco(t),this.node=e,this.innerDeco=n,this.contentDOM&&this.updateChildren(o,this.posAtStart),this.dirty=0}updateOuterDeco(e){if(bi(e,this.outerDeco))return;let t=1!=this.nodeDOM.nodeType,n=this.dom;this.dom=yi(this.dom,this.nodeDOM,gi(this.outerDeco,this.node,t),gi(e,this.node,t)),this.dom!=n&&(n.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){1==this.nodeDOM.nodeType&&this.nodeDOM.classList.add("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||(this.dom.draggable=!0)}deselectNode(){1==this.nodeDOM.nodeType&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||this.dom.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function ci(e,t,n,o,r){vi(o,t,e);let i=new ai(void 0,e,t,n,o,o,o,r,0);return i.contentDOM&&i.updateChildren(r,0),i}class di extends ai{constructor(e,t,n,o,r,i,s){super(e,t,n,o,r,null,i,s,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,n,o){return!(3==this.dirty||0!=this.dirty&&!this.inParent()||!e.sameMarkup(this.node))&&(this.updateOuterDeco(t),0==this.dirty&&e.text==this.node.text||e.text==this.nodeDOM.nodeValue||(this.nodeDOM.nodeValue=e.text,o.trackWrites==this.nodeDOM&&(o.trackWrites=null)),this.node=e,this.dirty=0,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,n){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,n)}ignoreMutation(e){return"characterData"!=e.type&&"selection"!=e.type}slice(e,t,n){let o=this.node.cut(e,t),r=document.createTextNode(o.text);return new di(this.parent,o,this.outerDeco,this.innerDeco,r,r,n)}markDirty(e,t){super.markDirty(e,t),this.dom==this.nodeDOM||0!=e&&t!=this.nodeDOM.nodeValue.length||(this.dirty=3)}get domAtom(){return!1}isText(e){return this.node.text==e}}class hi extends ri{parseRule(){return{ignore:!0}}matchesHack(e){return 0==this.dirty&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return"IMG"==this.dom.nodeName}}class pi extends ai{constructor(e,t,n,o,r,i,s,l,a,c){super(e,t,n,o,r,i,s,a,c),this.spec=l}update(e,t,n,o){if(3==this.dirty)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let r=this.spec.update(e,t,n);return r&&this.updateInner(e,t,n,o),r}return!(!this.contentDOM&&!e.isLeaf)&&super.update(e,t,n,o)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,n,o){this.spec.setSelection?this.spec.setSelection(e,t,n.root):super.setSelection(e,t,n,o)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return!!this.spec.stopEvent&&this.spec.stopEvent(e)}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function ui(e,t,n){let o=e.firstChild,r=!1;for(let i=0;i<t.length;i++){let s=t[i],l=s.dom;if(l.parentNode==e){for(;l!=o;)o=ki(o),r=!0;o=o.nextSibling}else r=!0,e.insertBefore(l,o);if(s instanceof li){let t=o?o.previousSibling:e.lastChild;ui(s.contentDOM,s.children,n),o=t?t.nextSibling:e.firstChild}}for(;o;)o=ki(o),r=!0;r&&n.trackWrites==e&&(n.trackWrites=null)}const fi=function(e){e&&(this.nodeName=e)};fi.prototype=Object.create(null);const mi=[new fi];function gi(e,t,n){if(0==e.length)return mi;let o=n?mi[0]:new fi,r=[o];for(let i=0;i<e.length;i++){let s=e[i].type.attrs;if(s){s.nodeName&&r.push(o=new fi(s.nodeName));for(let e in s){let i=s[e];null!=i&&(n&&1==r.length&&r.push(o=new fi(t.isInline?"span":"div")),"class"==e?o.class=(o.class?o.class+" ":"")+i:"style"==e?o.style=(o.style?o.style+";":"")+i:"nodeName"!=e&&(o[e]=i))}}}return r}function yi(e,t,n,o){if(n==mi&&o==mi)return t;let r=t;for(let t=0;t<o.length;t++){let i=o[t],s=n[t];if(t){let t;s&&s.nodeName==i.nodeName&&r!=e&&(t=r.parentNode)&&t.nodeName.toLowerCase()==i.nodeName||(t=document.createElement(i.nodeName),t.pmIsDeco=!0,t.appendChild(r),s=mi[0]),r=t}wi(r,s||mi[0],i)}return r}function wi(e,t,n){for(let o in t)"class"==o||"style"==o||"nodeName"==o||o in n||e.removeAttribute(o);for(let o in n)"class"!=o&&"style"!=o&&"nodeName"!=o&&n[o]!=t[o]&&e.setAttribute(o,n[o]);if(t.class!=n.class){let o=t.class?t.class.split(" ").filter(Boolean):[],r=n.class?n.class.split(" ").filter(Boolean):[];for(let t=0;t<o.length;t++)-1==r.indexOf(o[t])&&e.classList.remove(o[t]);for(let t=0;t<r.length;t++)-1==o.indexOf(r[t])&&e.classList.add(r[t]);0==e.classList.length&&e.removeAttribute("class")}if(t.style!=n.style){if(t.style){let n,o=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g;for(;n=o.exec(t.style);)e.style.removeProperty(n[1])}n.style&&(e.style.cssText+=n.style)}}function vi(e,t,n){return yi(e,e,mi,gi(t,n,1!=e.nodeType))}function bi(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].type.eq(t[n].type))return!1;return!0}function ki(e){let t=e.nextSibling;return e.parentNode.removeChild(e),t}class xi{constructor(e,t,n){this.lock=t,this.view=n,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=function(e,t){let n=t,o=n.children.length,r=e.childCount,i=new Map,s=[];e:for(;r>0;){let l;for(;;)if(o){let e=n.children[o-1];if(!(e instanceof li)){l=e,o--;break}n=e,o=e.children.length}else{if(n==t)break e;o=n.parent.children.indexOf(n),n=n.parent}let a=l.node;if(a){if(a!=e.child(r-1))break;--r,i.set(l,r),s.push(l)}}return{index:r,matched:i,matches:s.reverse()}}(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let n=e;n<t;n++)this.top.children[n].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,n){let o=0,r=this.stack.length>>1,i=Math.min(r,e.length);for(;o<i&&(o==r-1?this.top:this.stack[o+1<<1]).matchesMark(e[o])&&!1!==e[o].type.spec.spanning;)o++;for(;o<r;)this.destroyRest(),this.top.dirty=0,this.index=this.stack.pop(),this.top=this.stack.pop(),r--;for(;r<e.length;){this.stack.push(this.top,this.index+1);let o=-1;for(let t=this.index;t<Math.min(this.index+3,this.top.children.length);t++){let n=this.top.children[t];if(n.matchesMark(e[r])&&!this.isLocked(n.dom)){o=t;break}}if(o>-1)o>this.index&&(this.changed=!0,this.destroyBetween(this.index,o)),this.top=this.top.children[this.index];else{let o=li.create(this.top,e[r],t,n);this.top.children.splice(this.index,0,o),this.top=o,this.changed=!0}this.index=0,r++}}findNodeMatch(e,t,n,o){let r,i=-1;if(o>=this.preMatch.index&&(r=this.preMatch.matches[o-this.preMatch.index]).parent==this.top&&r.matchesNode(e,t,n))i=this.top.children.indexOf(r,this.index);else for(let o=this.index,r=Math.min(this.top.children.length,o+5);o<r;o++){let r=this.top.children[o];if(r.matchesNode(e,t,n)&&!this.preMatch.matched.has(r)){i=o;break}}return!(i<0)&&(this.destroyBetween(this.index,i),this.index++,!0)}updateNodeAt(e,t,n,o,r){let i=this.top.children[o];return 3==i.dirty&&i.dom==i.contentDOM&&(i.dirty=2),!!i.update(e,t,n,r)&&(this.destroyBetween(this.index,o),this.index++,!0)}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let t=e.pmViewDesc;if(t)for(let e=this.index;e<this.top.children.length;e++)if(this.top.children[e]==t)return e;return-1}e=t}}updateNextNode(e,t,n,o,r,i){for(let s=this.index;s<this.top.children.length;s++){let l=this.top.children[s];if(l instanceof ai){let a=this.preMatch.matched.get(l);if(null!=a&&a!=r)return!1;let c,d=l.dom,h=this.isLocked(d)&&!(e.isText&&l.node&&l.node.isText&&l.nodeDOM.nodeValue==e.text&&3!=l.dirty&&bi(t,l.outerDeco));if(!h&&l.update(e,t,n,o))return this.destroyBetween(this.index,s),l.dom!=d&&(this.changed=!0),this.index++,!0;if(!h&&(c=this.recreateWrapper(l,e,t,n,o,i)))return this.destroyBetween(this.index,s),this.top.children[this.index]=c,c.contentDOM&&(c.dirty=2,c.updateChildren(o,i+1),c.dirty=0),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,n,o,r,i){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!bi(n,e.outerDeco)||!o.eq(e.innerDeco))return null;let s=ai.create(this.top,t,n,o,r,i);if(s.contentDOM){s.children=e.children,e.children=[];for(let e of s.children)e.parent=s}return e.destroy(),s}addNode(e,t,n,o,r){let i=ai.create(this.top,e,t,n,o,r);i.contentDOM&&i.updateChildren(o,r+1),this.top.children.splice(this.index++,0,i),this.changed=!0}placeWidget(e,t,n){let o=this.index<this.top.children.length?this.top.children[this.index]:null;if(!o||!o.matchesWidget(e)||e!=o.widget&&o.widget.type.toDOM.parentNode){let o=new ii(this.top,e,t,n);this.top.children.splice(this.index++,0,o),this.changed=!0}else this.index++}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof li;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof di)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((Ar||Nr)&&e&&"false"==e.dom.contentEditable&&this.addHackNode("IMG",t),this.addHackNode("BR",this.top))}addHackNode(e,t){if(t==this.top&&this.index<t.children.length&&t.children[this.index].matchesHack(e))this.index++;else{let n=document.createElement(e);"IMG"==e&&(n.className="ProseMirror-separator",n.alt=""),"BR"==e&&(n.className="ProseMirror-trailingBreak");let o=new hi(this.top,[],n,null);t!=this.top?t.children.push(o):t.children.splice(this.index++,0,o),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||1==e.nodeType&&e.contains(this.lock.parentNode))}}function Si(e,t){return e.type.side-t.type.side}function Ci(e,t,n,o,r){let i=[];for(let s=0,l=0;s<e.length;s++){let a=e[s],c=l,d=l+=a.size;c>=n||d<=t?i.push(a):(c<t&&i.push(a.slice(0,t-c,o)),r&&(i.push(r),r=void 0),d>n&&i.push(a.slice(n-c,a.size,o)))}return i}function Mi(e,t=null){let n=e.domSelectionRange(),o=e.state.doc;if(!n.focusNode)return null;let r=e.docView.nearestDesc(n.focusNode),i=r&&0==r.size,s=e.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(s<0)return null;let l,a,c=o.resolve(s);if(fr(n)){for(l=s;r&&!r.node;)r=r.parent;let e=r.node;if(r&&e.isAtom&&st.isSelectable(e)&&r.parent&&(!e.isInline||!function(e,t,n){for(let o=0==t,r=t==pr(e);o||r;){if(e==n)return!0;let t=ir(e);if(!(e=e.parentNode))return!1;o=o&&0==t,r=r&&t==pr(e)}}(n.focusNode,n.focusOffset,r.dom))){let e=r.posBefore;a=new st(s==e?c:o.resolve(e))}}else{if(n instanceof e.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let t=s,r=s;for(let o=0;o<n.rangeCount;o++){let i=n.getRangeAt(o);t=Math.min(t,e.docView.posFromDOM(i.startContainer,i.startOffset,1)),r=Math.max(r,e.docView.posFromDOM(i.endContainer,i.endOffset,-1))}if(t<0)return null;[l,s]=r==e.state.selection.anchor?[r,t]:[t,r],c=o.resolve(s)}else l=e.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(l<0)return null}let d=o.resolve(l);if(!a){a=Ii(e,d,c,"pointer"==t||e.state.selection.head<c.pos&&!i?1:-1)}return a}function Ni(e){return e.editable?e.hasFocus():Bi(e)&&document.activeElement&&document.activeElement.contains(e.dom)}function Oi(e,t=!1){let n=e.state.selection;if(Ri(e,n),Ni(e)){if(!t&&e.input.mouseDown&&e.input.mouseDown.allowDefault&&Nr){let t=e.domSelectionRange(),n=e.domObserver.currentSelection;if(t.anchorNode&&n.anchorNode&&cr(t.anchorNode,t.anchorOffset,n.anchorNode,n.anchorOffset))return e.input.mouseDown.delayedSelectionSync=!0,void e.domObserver.setCurSelection()}if(e.domObserver.disconnectSelection(),e.cursorWrapper)!function(e){let t=e.domSelection(),n=document.createRange();if(!t)return;let o=e.cursorWrapper.dom,r="IMG"==o.nodeName;r?n.setStart(o.parentNode,ir(o)+1):n.setStart(o,0);n.collapse(!0),t.removeAllRanges(),t.addRange(n),!r&&!e.state.selection.visible&&xr&&Sr<=11&&(o.disabled=!0,o.disabled=!1)}(e);else{let o,r,{anchor:i,head:s}=n;!Ai||n instanceof rt||(n.$from.parent.inlineContent||(o=Ti(e,n.from)),n.empty||n.$from.parent.inlineContent||(r=Ti(e,n.to))),e.docView.setSelection(i,s,e,t),Ai&&(o&&Ei(o),r&&Ei(r)),n.visible?e.dom.classList.remove("ProseMirror-hideselection"):(e.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&function(e){let t=e.dom.ownerDocument;t.removeEventListener("selectionchange",e.input.hideSelectionGuard);let n=e.domSelectionRange(),o=n.anchorNode,r=n.anchorOffset;t.addEventListener("selectionchange",e.input.hideSelectionGuard=()=>{n.anchorNode==o&&n.anchorOffset==r||(t.removeEventListener("selectionchange",e.input.hideSelectionGuard),setTimeout((()=>{Ni(e)&&!e.state.selection.visible||e.dom.classList.remove("ProseMirror-hideselection")}),20))})}(e))}e.domObserver.setCurSelection(),e.domObserver.connectSelection()}}const Ai=Ar||Nr&&Or<63;function Ti(e,t){let{node:n,offset:o}=e.docView.domFromPos(t,0),r=o<n.childNodes.length?n.childNodes[o]:null,i=o?n.childNodes[o-1]:null;if(Ar&&r&&"false"==r.contentEditable)return Di(r);if(!(r&&"false"!=r.contentEditable||i&&"false"!=i.contentEditable)){if(r)return Di(r);if(i)return Di(i)}}function Di(e){return e.contentEditable="true",Ar&&e.draggable&&(e.draggable=!1,e.wasDraggable=!0),e}function Ei(e){e.contentEditable="false",e.wasDraggable&&(e.draggable=!0,e.wasDraggable=null)}function Ri(e,t){if(t instanceof st){let n=e.docView.descAt(t.from);n!=e.lastSelectedViewDesc&&($i(e),n&&n.selectNode(),e.lastSelectedViewDesc=n)}else $i(e)}function $i(e){e.lastSelectedViewDesc&&(e.lastSelectedViewDesc.parent&&e.lastSelectedViewDesc.deselectNode(),e.lastSelectedViewDesc=void 0)}function Ii(e,t,n,o){return e.someProp("createSelectionBetween",(o=>o(e,t,n)))||rt.between(t,n,o)}function zi(e){return!(e.editable&&!e.hasFocus())&&Bi(e)}function Bi(e){let t=e.domSelectionRange();if(!t.anchorNode)return!1;try{return e.dom.contains(3==t.anchorNode.nodeType?t.anchorNode.parentNode:t.anchorNode)&&(e.editable||e.dom.contains(3==t.focusNode.nodeType?t.focusNode.parentNode:t.focusNode))}catch(e){return!1}}function Pi(e,t){let{$anchor:n,$head:o}=e.selection,r=t>0?n.max(o):n.min(o),i=r.parent.inlineContent?r.depth?e.doc.resolve(t>0?r.after():r.before()):null:r;return i&&et.findFrom(i,t)}function Vi(e,t){return e.dispatch(e.state.tr.setSelection(t).scrollIntoView()),!0}function Fi(e,t,n){let o=e.state.selection;if(!(o instanceof rt)){if(o instanceof st&&o.node.isInline)return Vi(e,new rt(t>0?o.$to:o.$from));{let n=Pi(e.state,t);return!!n&&Vi(e,n)}}if(n.indexOf("s")>-1){let{$head:n}=o,r=n.textOffset?null:t<0?n.nodeBefore:n.nodeAfter;if(!r||r.isText||!r.isLeaf)return!1;let i=e.state.doc.resolve(n.pos+r.nodeSize*(t<0?-1:1));return Vi(e,new rt(o.$anchor,i))}if(!o.empty)return!1;if(e.endOfTextblock(t>0?"forward":"backward")){let n=Pi(e.state,t);return!!(n&&n instanceof st)&&Vi(e,n)}if(!(Dr&&n.indexOf("m")>-1)){let n,r=o.$head,i=r.textOffset?null:t<0?r.nodeBefore:r.nodeAfter;if(!i||i.isText)return!1;let s=t<0?r.pos-i.nodeSize:r.pos;return!!(i.isAtom||(n=e.docView.descAt(s))&&!n.contentDOM)&&(st.isSelectable(i)?Vi(e,new st(t<0?e.state.doc.resolve(r.pos-i.nodeSize):r)):!!$r&&Vi(e,new rt(e.state.doc.resolve(t<0?s:s+i.nodeSize))))}}function Li(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function Hi(e,t){let n=e.pmViewDesc;return n&&0==n.size&&(t<0||e.nextSibling||"BR"!=e.nodeName)}function _i(e,t){return t<0?function(e){let t=e.domSelectionRange(),n=t.focusNode,o=t.focusOffset;if(!n)return;let r,i,s=!1;Cr&&1==n.nodeType&&o<Li(n)&&Hi(n.childNodes[o],-1)&&(s=!0);for(;;)if(o>0){if(1!=n.nodeType)break;{let e=n.childNodes[o-1];if(Hi(e,-1))r=n,i=--o;else{if(3!=e.nodeType)break;n=e,o=n.nodeValue.length}}}else{if(Wi(n))break;{let t=n.previousSibling;for(;t&&Hi(t,-1);)r=n.parentNode,i=ir(t),t=t.previousSibling;if(t)n=t,o=Li(n);else{if(n=n.parentNode,n==e.dom)break;o=0}}}s?qi(e,n,o):r&&qi(e,r,i)}(e):function(e){let t=e.domSelectionRange(),n=t.focusNode,o=t.focusOffset;if(!n)return;let r,i,s=Li(n);for(;;)if(o<s){if(1!=n.nodeType)break;if(!Hi(n.childNodes[o],1))break;r=n,i=++o}else{if(Wi(n))break;{let t=n.nextSibling;for(;t&&Hi(t,1);)r=t.parentNode,i=ir(t)+1,t=t.nextSibling;if(t)n=t,o=0,s=Li(n);else{if(n=n.parentNode,n==e.dom)break;o=s=0}}}r&&qi(e,r,i)}(e)}function Wi(e){let t=e.pmViewDesc;return t&&t.node&&t.node.isBlock}function qi(e,t,n){if(3!=t.nodeType){let e,o;(o=function(e,t){for(;e&&t==e.childNodes.length&&!ur(e);)t=ir(e)+1,e=e.parentNode;for(;e&&t<e.childNodes.length;){let n=e.childNodes[t];if(3==n.nodeType)return n;if(1==n.nodeType&&"false"==n.contentEditable)break;e=n,t=0}}(t,n))?(t=o,n=0):(e=function(e,t){for(;e&&!t&&!ur(e);)t=ir(e),e=e.parentNode;for(;e&&t;){let n=e.childNodes[t-1];if(3==n.nodeType)return n;if(1==n.nodeType&&"false"==n.contentEditable)break;t=(e=n).childNodes.length}}(t,n))&&(t=e,n=e.nodeValue.length)}let o=e.domSelection();if(!o)return;if(fr(o)){let e=document.createRange();e.setEnd(t,n),e.setStart(t,n),o.removeAllRanges(),o.addRange(e)}else o.extend&&o.extend(t,n);e.domObserver.setCurSelection();let{state:r}=e;setTimeout((()=>{e.state==r&&Oi(e)}),50)}function Ji(e,t){let n=e.state.doc.resolve(t);if(!Nr&&!Er&&n.parent.inlineContent){let o=e.coordsAtPos(t);if(t>n.start()){let n=e.coordsAtPos(t-1),r=(n.top+n.bottom)/2;if(r>o.top&&r<o.bottom&&Math.abs(n.left-o.left)>1)return n.left<o.left?"ltr":"rtl"}if(t<n.end()){let n=e.coordsAtPos(t+1),r=(n.top+n.bottom)/2;if(r>o.top&&r<o.bottom&&Math.abs(n.left-o.left)>1)return n.left>o.left?"ltr":"rtl"}}return"rtl"==getComputedStyle(e.dom).direction?"rtl":"ltr"}function ji(e,t,n){let o=e.state.selection;if(o instanceof rt&&!o.empty||n.indexOf("s")>-1)return!1;if(Dr&&n.indexOf("m")>-1)return!1;let{$from:r,$to:i}=o;if(!r.parent.inlineContent||e.endOfTextblock(t<0?"up":"down")){let n=Pi(e.state,t);if(n&&n instanceof st)return Vi(e,n)}if(!r.parent.inlineContent){let n=t<0?r:i,s=o instanceof at?et.near(n,t):et.findFrom(n,t);return!!s&&Vi(e,s)}return!1}function Ki(e,t){if(!(e.state.selection instanceof rt))return!0;let{$head:n,$anchor:o,empty:r}=e.state.selection;if(!n.sameParent(o))return!0;if(!r)return!1;if(e.endOfTextblock(t>0?"forward":"backward"))return!0;let i=!n.textOffset&&(t<0?n.nodeBefore:n.nodeAfter);if(i&&!i.isText){let o=e.state.tr;return t<0?o.delete(n.pos-i.nodeSize,n.pos):o.delete(n.pos,n.pos+i.nodeSize),e.dispatch(o),!0}return!1}function Xi(e,t,n){e.domObserver.stop(),t.contentEditable=n,e.domObserver.start()}function Ui(e,t){let n=t.keyCode,o=function(e){let t="";return e.ctrlKey&&(t+="c"),e.metaKey&&(t+="m"),e.altKey&&(t+="a"),e.shiftKey&&(t+="s"),t}(t);if(8==n||Dr&&72==n&&"c"==o)return Ki(e,-1)||_i(e,-1);if(46==n&&!t.shiftKey||Dr&&68==n&&"c"==o)return Ki(e,1)||_i(e,1);if(13==n||27==n)return!0;if(37==n||Dr&&66==n&&"c"==o){let t=37==n?"ltr"==Ji(e,e.state.selection.from)?-1:1:-1;return Fi(e,t,o)||_i(e,t)}if(39==n||Dr&&70==n&&"c"==o){let t=39==n?"ltr"==Ji(e,e.state.selection.from)?1:-1:1;return Fi(e,t,o)||_i(e,t)}return 38==n||Dr&&80==n&&"c"==o?ji(e,-1,o)||_i(e,-1):40==n||Dr&&78==n&&"c"==o?function(e){if(!Ar||e.state.selection.$head.parentOffset>0)return!1;let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(t&&1==t.nodeType&&0==n&&t.firstChild&&"false"==t.firstChild.contentEditable){let n=t.firstChild;Xi(e,n,"true"),setTimeout((()=>Xi(e,n,"false")),20)}return!1}(e)||ji(e,1,o)||_i(e,1):o==(Dr?"m":"c")&&(66==n||73==n||89==n||90==n)}function Gi(e,t){e.someProp("transformCopied",(n=>{t=n(t,e)}));let n=[],{content:o,openStart:r,openEnd:i}=t;for(;r>1&&i>1&&1==o.childCount&&1==o.firstChild.childCount;){r--,i--;let e=o.firstChild;n.push(e.type.name,e.attrs!=e.type.defaultAttrs?e.attrs:null),o=e.content}let s=e.someProp("clipboardSerializer")||ie.fromSchema(e.state.schema),l=ls(),a=l.createElement("div");a.appendChild(s.serializeFragment(o,{document:l}));let c,d=a.firstChild,h=0;for(;d&&1==d.nodeType&&(c=is[d.nodeName.toLowerCase()]);){for(let e=c.length-1;e>=0;e--){let t=l.createElement(c[e]);for(;a.firstChild;)t.appendChild(a.firstChild);a.appendChild(t),h++}d=a.firstChild}return d&&1==d.nodeType&&d.setAttribute("data-pm-slice",`${r} ${i}${h?` -${h}`:""} ${JSON.stringify(n)}`),{dom:a,text:e.someProp("clipboardTextSerializer",(n=>n(t,e)))||t.content.textBetween(0,t.content.size,"\n\n"),slice:t}}function Yi(e,t,n,o,i){let s,l,a=i.parent.type.spec.code;if(!n&&!t)return null;let c=t&&(o||a||!n);if(c){if(e.someProp("transformPastedText",(n=>{t=n(t,a||o,e)})),a)return t?new d(r.from(e.state.schema.text(t.replace(/\r\n?/g,"\n"))),0,0):d.empty;let n=e.someProp("clipboardTextParser",(n=>n(t,i,o,e)));if(n)l=n;else{let n=i.marks(),{schema:o}=e.state,r=ie.fromSchema(o);s=document.createElement("div"),t.split(/(?:\r\n?|\n)+/).forEach((e=>{let t=s.appendChild(document.createElement("p"));e&&t.appendChild(r.serializeNode(o.text(e,n)))}))}}else e.someProp("transformPastedHTML",(t=>{n=t(n,e)})),s=function(e){let t=/^(\s*<meta [^>]*>)*/.exec(e);t&&(e=e.slice(t[0].length));let n,o=ls().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(e);(n=r&&is[r[1].toLowerCase()])&&(e=n.map((e=>"<"+e+">")).join("")+e+n.map((e=>"</"+e+">")).reverse().join(""));if(o.innerHTML=function(e){let t=window.trustedTypes;if(!t)return e;as||(as=t.createPolicy("ProseMirrorClipboard",{createHTML:e=>e}));return as.createHTML(e)}(e),n)for(let e=0;e<n.length;e++)o=o.querySelector(n[e])||o;return o}(n),$r&&function(e){let t=e.querySelectorAll(Nr?"span:not([class]):not([style])":"span.Apple-converted-space");for(let n=0;n<t.length;n++){let o=t[n];1==o.childNodes.length&&" "==o.textContent&&o.parentNode&&o.parentNode.replaceChild(e.ownerDocument.createTextNode(" "),o)}}(s);let h=s&&s.querySelector("[data-pm-slice]"),p=h&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(h.getAttribute("data-pm-slice")||"");if(p&&p[3])for(let e=+p[3];e>0;e--){let e=s.firstChild;for(;e&&1!=e.nodeType;)e=e.nextSibling;if(!e)break;s=e}if(!l){let t=e.someProp("clipboardParser")||e.someProp("domParser")||U.fromSchema(e.state.schema);l=t.parseSlice(s,{preserveWhitespace:!(!c&&!p),context:i,ruleFromNode:e=>"BR"!=e.nodeName||e.nextSibling||!e.parentNode||Qi.test(e.parentNode.nodeName)?null:{ignore:!0}})}if(p)l=function(e,t){if(!e.size)return e;let n,o=e.content.firstChild.type.schema;try{n=JSON.parse(t)}catch(t){return e}let{content:i,openStart:s,openEnd:l}=e;for(let e=n.length-2;e>=0;e-=2){let t=o.nodes[n[e]];if(!t||t.hasRequiredAttrs())break;i=r.from(t.create(n[e+1],i)),s++,l++}return new d(i,s,l)}(rs(l,+p[1],+p[2]),p[4]);else if(l=d.maxOpen(function(e,t){if(e.childCount<2)return e;for(let n=t.depth;n>=0;n--){let o,i=t.node(n).contentMatchAt(t.index(n)),s=[];if(e.forEach((e=>{if(!s)return;let t,n=i.findWrapping(e.type);if(!n)return s=null;if(t=s.length&&o.length&&es(n,o,e,s[s.length-1],0))s[s.length-1]=t;else{s.length&&(s[s.length-1]=ts(s[s.length-1],o.length));let t=Zi(e,n);s.push(t),i=i.matchType(t.type),o=n}})),s)return r.from(s)}return e}(l.content,i),!0),l.openStart||l.openEnd){let e=0,t=0;for(let t=l.content.firstChild;e<l.openStart&&!t.type.spec.isolating;e++,t=t.firstChild);for(let e=l.content.lastChild;t<l.openEnd&&!e.type.spec.isolating;t++,e=e.lastChild);l=rs(l,e,t)}return e.someProp("transformPasted",(t=>{l=t(l,e)})),l}const Qi=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function Zi(e,t,n=0){for(let o=t.length-1;o>=n;o--)e=t[o].create(null,r.from(e));return e}function es(e,t,n,o,i){if(i<e.length&&i<t.length&&e[i]==t[i]){let s=es(e,t,n,o.lastChild,i+1);if(s)return o.copy(o.content.replaceChild(o.childCount-1,s));if(o.contentMatchAt(o.childCount).matchType(i==e.length-1?n.type:e[i+1]))return o.copy(o.content.append(r.from(Zi(n,e,i+1))))}}function ts(e,t){if(0==t)return e;let n=e.content.replaceChild(e.childCount-1,ts(e.lastChild,t-1)),o=e.contentMatchAt(e.childCount).fillBefore(r.empty,!0);return e.copy(n.append(o))}function ns(e,t,n,o,i,s){let l=t<0?e.firstChild:e.lastChild,a=l.content;return e.childCount>1&&(s=0),i<o-1&&(a=ns(a,t,n,o,i+1,s)),i>=n&&(a=t<0?l.contentMatchAt(0).fillBefore(a,s<=i).append(a):a.append(l.contentMatchAt(l.childCount).fillBefore(r.empty,!0))),e.replaceChild(t<0?0:e.childCount-1,l.copy(a))}function rs(e,t,n){return t<e.openStart&&(e=new d(ns(e.content,-1,t,e.openStart,0,e.openEnd),t,e.openEnd)),n<e.openEnd&&(e=new d(ns(e.content,1,n,e.openEnd,0,0),e.openStart,n)),e}const is={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};let ss=null;function ls(){return ss||(ss=document.implementation.createHTMLDocument("title"))}let as=null;const cs={},ds={},hs={touchstart:!0,touchmove:!0};class ps{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:""},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function us(e,t){e.input.lastSelectionOrigin=t,e.input.lastSelectionTime=Date.now()}function fs(e){e.someProp("handleDOMEvents",(t=>{for(let n in t)e.input.eventHandlers[n]||e.dom.addEventListener(n,e.input.eventHandlers[n]=t=>ms(e,t))}))}function ms(e,t){return e.someProp("handleDOMEvents",(n=>{let o=n[t.type];return!!o&&(o(e,t)||t.defaultPrevented)}))}function gs(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let n=t.target;n!=e.dom;n=n.parentNode)if(!n||11==n.nodeType||n.pmViewDesc&&n.pmViewDesc.stopEvent(t))return!1;return!0}function ys(e){return{left:e.clientX,top:e.clientY}}function ws(e,t,n,o,r){if(-1==o)return!1;let i=e.state.doc.resolve(o);for(let o=i.depth+1;o>0;o--)if(e.someProp(t,(t=>o>i.depth?t(e,n,i.nodeAfter,i.before(o),r,!0):t(e,n,i.node(o),i.before(o),r,!1))))return!0;return!1}function vs(e,t,n){if(e.focused||e.focus(),e.state.selection.eq(t))return;let o=e.state.tr.setSelection(t);o.setMeta("pointer",!0),e.dispatch(o)}function bs(e,t,n,o,r){return ws(e,"handleClickOn",t,n,o)||e.someProp("handleClick",(n=>n(e,t,o)))||(r?function(e,t){if(-1==t)return!1;let n,o,r=e.state.selection;r instanceof st&&(n=r.node);let i=e.state.doc.resolve(t);for(let e=i.depth+1;e>0;e--){let t=e>i.depth?i.nodeAfter:i.node(e);if(st.isSelectable(t)){o=n&&r.$from.depth>0&&e>=r.$from.depth&&i.before(r.$from.depth+1)==r.$from.pos?i.before(r.$from.depth):i.before(e);break}}return null!=o&&(vs(e,st.create(e.state.doc,o)),!0)}(e,n):function(e,t){if(-1==t)return!1;let n=e.state.doc.resolve(t),o=n.nodeAfter;return!!(o&&o.isAtom&&st.isSelectable(o))&&(vs(e,new st(n)),!0)}(e,n))}function ks(e,t,n,o){return ws(e,"handleDoubleClickOn",t,n,o)||e.someProp("handleDoubleClick",(n=>n(e,t,o)))}function xs(e,t,n,o){return ws(e,"handleTripleClickOn",t,n,o)||e.someProp("handleTripleClick",(n=>n(e,t,o)))||function(e,t,n){if(0!=n.button)return!1;let o=e.state.doc;if(-1==t)return!!o.inlineContent&&(vs(e,rt.create(o,0,o.content.size)),!0);let r=o.resolve(t);for(let t=r.depth+1;t>0;t--){let n=t>r.depth?r.nodeAfter:r.node(t),i=r.before(t);if(n.inlineContent)vs(e,rt.create(o,i+1,i+1+n.content.size));else{if(!st.isSelectable(n))continue;vs(e,st.create(o,i))}return!0}}(e,n,o)}function Ss(e){return Es(e)}ds.keydown=(e,t)=>{let n=t;if(e.input.shiftKey=16==n.keyCode||n.shiftKey,!Ns(e,n)&&(e.input.lastKeyCode=n.keyCode,e.input.lastKeyCodeTime=Date.now(),!Rr||!Nr||13!=n.keyCode))if(229!=n.keyCode&&e.domObserver.forceFlush(),!Tr||13!=n.keyCode||n.ctrlKey||n.altKey||n.metaKey)e.someProp("handleKeyDown",(t=>t(e,n)))||Ui(e,n)?n.preventDefault():us(e,"key");else{let t=Date.now();e.input.lastIOSEnter=t,e.input.lastIOSEnterFallbackTimeout=setTimeout((()=>{e.input.lastIOSEnter==t&&(e.someProp("handleKeyDown",(t=>t(e,mr(13,"Enter")))),e.input.lastIOSEnter=0)}),200)}},ds.keyup=(e,t)=>{16==t.keyCode&&(e.input.shiftKey=!1)},ds.keypress=(e,t)=>{let n=t;if(Ns(e,n)||!n.charCode||n.ctrlKey&&!n.altKey||Dr&&n.metaKey)return;if(e.someProp("handleKeyPress",(t=>t(e,n))))return void n.preventDefault();let o=e.state.selection;if(!(o instanceof rt&&o.$from.sameParent(o.$to))){let t=String.fromCharCode(n.charCode);/[\r\n]/.test(t)||e.someProp("handleTextInput",(n=>n(e,o.$from.pos,o.$to.pos,t)))||e.dispatch(e.state.tr.insertText(t).scrollIntoView()),n.preventDefault()}};const Cs=Dr?"metaKey":"ctrlKey";cs.mousedown=(e,t)=>{let n=t;e.input.shiftKey=n.shiftKey;let o=Ss(e),r=Date.now(),i="singleClick";r-e.input.lastClick.time<500&&function(e,t){let n=t.x-e.clientX,o=t.y-e.clientY;return n*n+o*o<100}(n,e.input.lastClick)&&!n[Cs]&&("singleClick"==e.input.lastClick.type?i="doubleClick":"doubleClick"==e.input.lastClick.type&&(i="tripleClick")),e.input.lastClick={time:r,x:n.clientX,y:n.clientY,type:i};let s=e.posAtCoords(ys(n));s&&("singleClick"==i?(e.input.mouseDown&&e.input.mouseDown.done(),e.input.mouseDown=new Ms(e,s,n,!!o)):("doubleClick"==i?ks:xs)(e,s.pos,s.inside,n)?n.preventDefault():us(e,"pointer"))};class Ms{constructor(e,t,n,o){let r,i;if(this.view=e,this.pos=t,this.event=n,this.flushed=o,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!n[Cs],this.allowDefault=n.shiftKey,t.inside>-1)r=e.state.doc.nodeAt(t.inside),i=t.inside;else{let n=e.state.doc.resolve(t.pos);r=n.parent,i=n.depth?n.before():0}const s=o?null:n.target,l=s?e.docView.nearestDesc(s,!0):null;this.target=l&&1==l.dom.nodeType?l.dom:null;let{selection:a}=e.state;(0==n.button&&r.type.spec.draggable&&!1!==r.type.spec.selectable||a instanceof st&&a.from<=i&&a.to>i)&&(this.mightDrag={node:r,pos:i,addAttr:!(!this.target||this.target.draggable),setUneditable:!(!this.target||!Cr||this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout((()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")}),20),this.view.domObserver.start()),e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this)),us(e,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout((()=>Oi(this.view))),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(ys(e))),this.updateAllowDefault(e),this.allowDefault||!t?us(this.view,"pointer"):bs(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():0==e.button&&(this.flushed||Ar&&this.mightDrag&&!this.mightDrag.node.isAtom||Nr&&!this.view.state.selection.visible&&Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2)?(vs(this.view,et.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):us(this.view,"pointer")}move(e){this.updateAllowDefault(e),us(this.view,"pointer"),0==e.buttons&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}}function Ns(e,t){return!!e.composing||!!(Ar&&Math.abs(t.timeStamp-e.input.compositionEndedAt)<500)&&(e.input.compositionEndedAt=-2e8,!0)}cs.touchstart=e=>{e.input.lastTouch=Date.now(),Ss(e),us(e,"pointer")},cs.touchmove=e=>{e.input.lastTouch=Date.now(),us(e,"pointer")},cs.contextmenu=e=>Ss(e);const Os=Rr?5e3:-1;function As(e,t){clearTimeout(e.input.composingTimeout),t>-1&&(e.input.composingTimeout=setTimeout((()=>Es(e)),t))}function Ts(e){for(e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=function(){let e=document.createEvent("Event");return e.initEvent("event",!0,!0),e.timeStamp}());e.input.compositionNodes.length>0;)e.input.compositionNodes.pop().markParentsDirty()}function Ds(e){let t=e.domSelectionRange();if(!t.focusNode)return null;let n=function(e,t){for(;;){if(3==e.nodeType&&t)return e;if(1==e.nodeType&&t>0){if("false"==e.contentEditable)return null;t=pr(e=e.childNodes[t-1])}else{if(!e.parentNode||ur(e))return null;t=ir(e),e=e.parentNode}}}(t.focusNode,t.focusOffset),o=function(e,t){for(;;){if(3==e.nodeType&&t<e.nodeValue.length)return e;if(1==e.nodeType&&t<e.childNodes.length){if("false"==e.contentEditable)return null;e=e.childNodes[t],t=0}else{if(!e.parentNode||ur(e))return null;t=ir(e)+1,e=e.parentNode}}}(t.focusNode,t.focusOffset);if(n&&o&&n!=o){let t=o.pmViewDesc,r=e.domObserver.lastChangedTextNode;if(n==r||o==r)return r;if(!t||!t.isText(o.nodeValue))return o;if(e.input.compositionNode==o){let e=n.pmViewDesc;if(e&&e.isText(n.nodeValue))return o}}return n||o}function Es(e,t=!1){if(!(Rr&&e.domObserver.flushingSoon>=0)){if(e.domObserver.forceFlush(),Ts(e),t||e.docView&&e.docView.dirty){let n=Mi(e);return n&&!n.eq(e.state.selection)?e.dispatch(e.state.tr.setSelection(n)):!e.markCursor&&!t||e.state.selection.empty?e.updateState(e.state):e.dispatch(e.state.tr.deleteSelection()),!0}return!1}}ds.compositionstart=ds.compositionupdate=e=>{if(!e.composing){e.domObserver.flush();let{state:t}=e,n=t.selection.$to;if(t.selection instanceof rt&&(t.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some((e=>!1===e.type.spec.inclusive))))e.markCursor=e.state.storedMarks||n.marks(),Es(e,!0),e.markCursor=null;else if(Es(e,!t.selection.empty),Cr&&t.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let t=e.domSelectionRange();for(let n=t.focusNode,o=t.focusOffset;n&&1==n.nodeType&&0!=o;){let t=o<0?n.lastChild:n.childNodes[o-1];if(!t)break;if(3==t.nodeType){let n=e.domSelection();n&&n.collapse(t,t.nodeValue.length);break}n=t,o=-1}}e.input.composing=!0}As(e,Os)},ds.compositionend=(e,t)=>{e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=t.timeStamp,e.input.compositionPendingChanges=e.domObserver.pendingRecords().length?e.input.compositionID:0,e.input.compositionNode=null,e.input.compositionPendingChanges&&Promise.resolve().then((()=>e.domObserver.flush())),e.input.compositionID++,As(e,20))};const Rs=xr&&Sr<15||Tr&&Ir<604;function $s(e,t,n,o,r){let i=Yi(e,t,n,o,e.state.selection.$from);if(e.someProp("handlePaste",(t=>t(e,r,i||d.empty))))return!0;if(!i)return!1;let s=function(e){return 0==e.openStart&&0==e.openEnd&&1==e.content.childCount?e.content.firstChild:null}(i),l=s?e.state.tr.replaceSelectionWith(s,o):e.state.tr.replaceSelection(i);return e.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Is(e){let t=e.getData("text/plain")||e.getData("Text");if(t)return t;let n=e.getData("text/uri-list");return n?n.replace(/\r?\n/g," "):""}cs.copy=ds.cut=(e,t)=>{let n=t,o=e.state.selection,r="cut"==n.type;if(o.empty)return;let i=Rs?null:n.clipboardData,s=o.content(),{dom:l,text:a}=Gi(e,s);i?(n.preventDefault(),i.clearData(),i.setData("text/html",l.innerHTML),i.setData("text/plain",a)):function(e,t){if(!e.dom.parentNode)return;let n=e.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(t),n.style.cssText="position: fixed; left: -10000px; top: 10px";let o=getSelection(),r=document.createRange();r.selectNodeContents(t),e.dom.blur(),o.removeAllRanges(),o.addRange(r),setTimeout((()=>{n.parentNode&&n.parentNode.removeChild(n),e.focus()}),50)}(e,l),r&&e.dispatch(e.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))},ds.paste=(e,t)=>{let n=t;if(e.composing&&!Rr)return;let o=Rs?null:n.clipboardData,r=e.input.shiftKey&&45!=e.input.lastKeyCode;o&&$s(e,Is(o),o.getData("text/html"),r,n)?n.preventDefault():function(e,t){if(!e.dom.parentNode)return;let n=e.input.shiftKey||e.state.selection.$from.parent.type.spec.code,o=e.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(o.contentEditable="true"),o.style.cssText="position: fixed; left: -10000px; top: 10px",o.focus();let r=e.input.shiftKey&&45!=e.input.lastKeyCode;setTimeout((()=>{e.focus(),o.parentNode&&o.parentNode.removeChild(o),n?$s(e,o.value,null,r,t):$s(e,o.textContent,o.innerHTML,r,t)}),50)}(e,n)};class zs{constructor(e,t,n){this.slice=e,this.move=t,this.node=n}}const Bs=Dr?"altKey":"ctrlKey";cs.dragstart=(e,t)=>{let n=t,o=e.input.mouseDown;if(o&&o.done(),!n.dataTransfer)return;let r,i=e.state.selection,s=i.empty?null:e.posAtCoords(ys(n));if(s&&s.pos>=i.from&&s.pos<=(i instanceof st?i.to-1:i.to));else if(o&&o.mightDrag)r=st.create(e.state.doc,o.mightDrag.pos);else if(n.target&&1==n.target.nodeType){let t=e.docView.nearestDesc(n.target,!0);t&&t.node.type.spec.draggable&&t!=e.docView&&(r=st.create(e.state.doc,t.posBefore))}let l=(r||e.state.selection).content(),{dom:a,text:c,slice:d}=Gi(e,l);(!n.dataTransfer.files.length||!Nr||Or>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(Rs?"Text":"text/html",a.innerHTML),n.dataTransfer.effectAllowed="copyMove",Rs||n.dataTransfer.setData("text/plain",c),e.dragging=new zs(d,!n[Bs],r)},cs.dragend=e=>{let t=e.dragging;window.setTimeout((()=>{e.dragging==t&&(e.dragging=null)}),50)},ds.dragover=ds.dragenter=(e,t)=>t.preventDefault(),ds.drop=(e,t)=>{let n=t,o=e.dragging;if(e.dragging=null,!n.dataTransfer)return;let r=e.posAtCoords(ys(n));if(!r)return;let i=e.state.doc.resolve(r.pos),s=o&&o.slice;s?e.someProp("transformPasted",(t=>{s=t(s,e)})):s=Yi(e,Is(n.dataTransfer),Rs?null:n.dataTransfer.getData("text/html"),!1,i);let l=!(!o||n[Bs]);if(e.someProp("handleDrop",(t=>t(e,n,s||d.empty,l))))return void n.preventDefault();if(!s)return;n.preventDefault();let a=s?Fe(e.state.doc,i.pos,s):i.pos;null==a&&(a=i.pos);let c=e.state.tr;if(l){let{node:e}=o;e?e.replace(c):c.deleteSelection()}let h=c.mapping.map(a),p=0==s.openStart&&0==s.openEnd&&1==s.content.childCount,u=c.doc;if(p?c.replaceRangeWith(h,h,s.content.firstChild):c.replaceRange(h,h,s),c.doc.eq(u))return;let f=c.doc.resolve(h);if(p&&st.isSelectable(s.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(s.content.firstChild))c.setSelection(new st(f));else{let t=c.mapping.map(a);c.mapping.maps[c.mapping.maps.length-1].forEach(((e,n,o,r)=>t=r)),c.setSelection(Ii(e,f,c.doc.resolve(t)))}e.focus(),e.dispatch(c.setMeta("uiEvent","drop"))},cs.focus=e=>{e.input.lastFocus=Date.now(),e.focused||(e.domObserver.stop(),e.dom.classList.add("ProseMirror-focused"),e.domObserver.start(),e.focused=!0,setTimeout((()=>{e.docView&&e.hasFocus()&&!e.domObserver.currentSelection.eq(e.domSelectionRange())&&Oi(e)}),20))},cs.blur=(e,t)=>{let n=t;e.focused&&(e.domObserver.stop(),e.dom.classList.remove("ProseMirror-focused"),e.domObserver.start(),n.relatedTarget&&e.dom.contains(n.relatedTarget)&&e.domObserver.currentSelection.clear(),e.focused=!1)},cs.beforeinput=(e,t)=>{if(Nr&&Rr&&"deleteContentBackward"==t.inputType){e.domObserver.flushSoon();let{domChangeCount:t}=e.input;setTimeout((()=>{if(e.input.domChangeCount!=t)return;if(e.dom.blur(),e.focus(),e.someProp("handleKeyDown",(t=>t(e,mr(8,"Backspace")))))return;let{$cursor:n}=e.state.selection;n&&n.pos>0&&e.dispatch(e.state.tr.delete(n.pos-1,n.pos).scrollIntoView())}),50)}};for(let e in ds)cs[e]=ds[e];function Ps(e,t){if(e==t)return!0;for(let n in e)if(e[n]!==t[n])return!1;for(let n in t)if(!(n in e))return!1;return!0}class Vs{constructor(e,t){this.toDOM=e,this.spec=t||Ws,this.side=this.spec.side||0}map(e,t,n,o){let{pos:r,deleted:i}=e.mapResult(t.from+o,this.side<0?-1:1);return i?null:new Hs(r-n,r-n,this)}valid(){return!0}eq(e){return this==e||e instanceof Vs&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Ps(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Fs{constructor(e,t){this.attrs=e,this.spec=t||Ws}map(e,t,n,o){let r=e.map(t.from+o,this.spec.inclusiveStart?-1:1)-n,i=e.map(t.to+o,this.spec.inclusiveEnd?1:-1)-n;return r>=i?null:new Hs(r,i,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof Fs&&Ps(this.attrs,e.attrs)&&Ps(this.spec,e.spec)}static is(e){return e.type instanceof Fs}destroy(){}}class Ls{constructor(e,t){this.attrs=e,this.spec=t||Ws}map(e,t,n,o){let r=e.mapResult(t.from+o,1);if(r.deleted)return null;let i=e.mapResult(t.to+o,-1);return i.deleted||i.pos<=r.pos?null:new Hs(r.pos-n,i.pos-n,this)}valid(e,t){let n,{index:o,offset:r}=e.content.findIndex(t.from);return r==t.from&&!(n=e.child(o)).isText&&r+n.nodeSize==t.to}eq(e){return this==e||e instanceof Ls&&Ps(this.attrs,e.attrs)&&Ps(this.spec,e.spec)}destroy(){}}class Hs{constructor(e,t,n){this.from=e,this.to=t,this.type=n}copy(e,t){return new Hs(e,t,this.type)}eq(e,t=0){return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}map(e,t,n){return this.type.map(e,this,t,n)}static widget(e,t,n){return new Hs(e,e,new Vs(t,n))}static inline(e,t,n,o){return new Hs(e,t,new Fs(n,o))}static node(e,t,n,o){return new Hs(e,t,new Ls(n,o))}get spec(){return this.type.spec}get inline(){return this.type instanceof Fs}get widget(){return this.type instanceof Vs}}const _s=[],Ws={};class qs{constructor(e,t){this.local=e.length?e:_s,this.children=t.length?t:_s}static create(e,t){return t.length?Gs(t,e,0,Ws):Js}find(e,t,n){let o=[];return this.findInner(null==e?0:e,null==t?1e9:t,o,0,n),o}findInner(e,t,n,o,r){for(let i=0;i<this.local.length;i++){let s=this.local[i];s.from<=t&&s.to>=e&&(!r||r(s.spec))&&n.push(s.copy(s.from+o,s.to+o))}for(let i=0;i<this.children.length;i+=3)if(this.children[i]<t&&this.children[i+1]>e){let s=this.children[i]+1;this.children[i+2].findInner(e-s,t-s,n,o+s,r)}}map(e,t,n){return this==Js||0==e.maps.length?this:this.mapInner(e,t,0,0,n||Ws)}mapInner(e,t,n,o,r){let i;for(let s=0;s<this.local.length;s++){let l=this.local[s].map(e,n,o);l&&l.type.valid(t,l)?(i||(i=[])).push(l):r.onRemove&&r.onRemove(this.local[s].spec)}return this.children.length?function(e,t,n,o,r,i,s){let l=e.slice();for(let e=0,t=i;e<n.maps.length;e++){let o=0;n.maps[e].forEach(((e,n,r,i)=>{let s=i-r-(n-e);for(let r=0;r<l.length;r+=3){let i=l[r+1];if(i<0||e>i+t-o)continue;let a=l[r]+t-o;n>=a?l[r+1]=e<=a?-2:-1:e>=t&&s&&(l[r]+=s,l[r+1]+=s)}o+=s})),t=n.maps[e].map(t,-1)}let a=!1;for(let t=0;t<l.length;t+=3)if(l[t+1]<0){if(-2==l[t+1]){a=!0,l[t+1]=-1;continue}let c=n.map(e[t]+i),d=c-r;if(d<0||d>=o.content.size){a=!0;continue}let h=n.map(e[t+1]+i,-1)-r,{index:p,offset:u}=o.content.findIndex(d),f=o.maybeChild(p);if(f&&u==d&&u+f.nodeSize==h){let o=l[t+2].mapInner(n,f,c+1,e[t]+i+1,s);o!=Js?(l[t]=d,l[t+1]=h,l[t+2]=o):(l[t+1]=-2,a=!0)}else a=!0}if(a){let a=function(e,t,n,o,r,i,s){function l(e,t){for(let i=0;i<e.local.length;i++){let l=e.local[i].map(o,r,t);l?n.push(l):s.onRemove&&s.onRemove(e.local[i].spec)}for(let n=0;n<e.children.length;n+=3)l(e.children[n+2],e.children[n]+t+1)}for(let n=0;n<e.length;n+=3)-1==e[n+1]&&l(e[n+2],t[n]+i+1);return n}(l,e,t,n,r,i,s),c=Gs(a,o,0,s);t=c.local;for(let e=0;e<l.length;e+=3)l[e+1]<0&&(l.splice(e,3),e-=3);for(let e=0,t=0;e<c.children.length;e+=3){let n=c.children[e];for(;t<l.length&&l[t]<n;)t+=3;l.splice(t,0,c.children[e],c.children[e+1],c.children[e+2])}}return new qs(t.sort(Ys),l)}(this.children,i||[],e,t,n,o,r):i?new qs(i.sort(Ys),_s):Js}add(e,t){return t.length?this==Js?qs.create(e,t):this.addInner(e,t,0):this}addInner(e,t,n){let o,r=0;e.forEach(((e,i)=>{let s,l=i+n;if(s=Xs(t,e,l)){for(o||(o=this.children.slice());r<o.length&&o[r]<i;)r+=3;o[r]==i?o[r+2]=o[r+2].addInner(e,s,l+1):o.splice(r,0,i,i+e.nodeSize,Gs(s,e,l+1,Ws)),r+=3}}));let i=Ks(r?Us(t):t,-n);for(let t=0;t<i.length;t++)i[t].type.valid(e,i[t])||i.splice(t--,1);return new qs(i.length?this.local.concat(i).sort(Ys):this.local,o||this.children)}remove(e){return 0==e.length||this==Js?this:this.removeInner(e,0)}removeInner(e,t){let n=this.children,o=this.local;for(let o=0;o<n.length;o+=3){let r,i=n[o]+t,s=n[o+1]+t;for(let t,n=0;n<e.length;n++)(t=e[n])&&t.from>i&&t.to<s&&(e[n]=null,(r||(r=[])).push(t));if(!r)continue;n==this.children&&(n=this.children.slice());let l=n[o+2].removeInner(r,i+1);l!=Js?n[o+2]=l:(n.splice(o,3),o-=3)}if(o.length)for(let n,r=0;r<e.length;r++)if(n=e[r])for(let e=0;e<o.length;e++)o[e].eq(n,t)&&(o==this.local&&(o=this.local.slice()),o.splice(e--,1));return n==this.children&&o==this.local?this:o.length||n.length?new qs(o,n):Js}forChild(e,t){if(this==Js)return this;if(t.isLeaf)return qs.empty;let n,o;for(let t=0;t<this.children.length;t+=3)if(this.children[t]>=e){this.children[t]==e&&(n=this.children[t+2]);break}let r=e+1,i=r+t.content.size;for(let e=0;e<this.local.length;e++){let t=this.local[e];if(t.from<i&&t.to>r&&t.type instanceof Fs){let e=Math.max(r,t.from)-r,n=Math.min(i,t.to)-r;e<n&&(o||(o=[])).push(t.copy(e,n))}}if(o){let e=new qs(o.sort(Ys),_s);return n?new js([e,n]):e}return n||Js}eq(e){if(this==e)return!0;if(!(e instanceof qs)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let t=0;t<this.local.length;t++)if(!this.local[t].eq(e.local[t]))return!1;for(let t=0;t<this.children.length;t+=3)if(this.children[t]!=e.children[t]||this.children[t+1]!=e.children[t+1]||!this.children[t+2].eq(e.children[t+2]))return!1;return!0}locals(e){return Qs(this.localsInner(e))}localsInner(e){if(this==Js)return _s;if(e.inlineContent||!this.local.some(Fs.is))return this.local;let t=[];for(let e=0;e<this.local.length;e++)this.local[e].type instanceof Fs||t.push(this.local[e]);return t}forEachSet(e){e(this)}}qs.empty=new qs([],[]),qs.removeOverlap=Qs;const Js=qs.empty;class js{constructor(e){this.members=e}map(e,t){const n=this.members.map((n=>n.map(e,t,Ws)));return js.from(n)}forChild(e,t){if(t.isLeaf)return qs.empty;let n=[];for(let o=0;o<this.members.length;o++){let r=this.members[o].forChild(e,t);r!=Js&&(r instanceof js?n=n.concat(r.members):n.push(r))}return js.from(n)}eq(e){if(!(e instanceof js)||e.members.length!=this.members.length)return!1;for(let t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0}locals(e){let t,n=!0;for(let o=0;o<this.members.length;o++){let r=this.members[o].localsInner(e);if(r.length)if(t){n&&(t=t.slice(),n=!1);for(let e=0;e<r.length;e++)t.push(r[e])}else t=r}return t?Qs(n?t:t.sort(Ys)):_s}static from(e){switch(e.length){case 0:return Js;case 1:return e[0];default:return new js(e.every((e=>e instanceof qs))?e:e.reduce(((e,t)=>e.concat(t instanceof qs?t:t.members)),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}}function Ks(e,t){if(!t||!e.length)return e;let n=[];for(let o=0;o<e.length;o++){let r=e[o];n.push(new Hs(r.from+t,r.to+t,r.type))}return n}function Xs(e,t,n){if(t.isLeaf)return null;let o=n+t.nodeSize,r=null;for(let t,i=0;i<e.length;i++)(t=e[i])&&t.from>n&&t.to<o&&((r||(r=[])).push(t),e[i]=null);return r}function Us(e){let t=[];for(let n=0;n<e.length;n++)null!=e[n]&&t.push(e[n]);return t}function Gs(e,t,n,o){let r=[],i=!1;t.forEach(((t,s)=>{let l=Xs(e,t,s+n);if(l){i=!0;let e=Gs(l,t,n+s+1,o);e!=Js&&r.push(s,s+t.nodeSize,e)}}));let s=Ks(i?Us(e):e,-n).sort(Ys);for(let e=0;e<s.length;e++)s[e].type.valid(t,s[e])||(o.onRemove&&o.onRemove(s[e].spec),s.splice(e--,1));return s.length||r.length?new qs(s,r):Js}function Ys(e,t){return e.from-t.from||e.to-t.to}function Qs(e){let t=e;for(let n=0;n<t.length-1;n++){let o=t[n];if(o.from!=o.to)for(let r=n+1;r<t.length;r++){let i=t[r];if(i.from!=o.from){i.from<o.to&&(t==e&&(t=e.slice()),t[n]=o.copy(o.from,i.from),Zs(t,r,o.copy(i.from,o.to)));break}i.to!=o.to&&(t==e&&(t=e.slice()),t[r]=i.copy(i.from,o.to),Zs(t,r+1,i.copy(o.to,i.to)))}}return t}function Zs(e,t,n){for(;t<e.length&&Ys(n,e[t])>0;)t++;e.splice(t,0,n)}function el(e){let t=[];return e.someProp("decorations",(n=>{let o=n(e.state);o&&o!=Js&&t.push(o)})),e.cursorWrapper&&t.push(qs.create(e.state.doc,[e.cursorWrapper.deco])),js.from(t)}const tl={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},nl=xr&&Sr<=11;class ol{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}}class rl{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new ol,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver((e=>{for(let t=0;t<e.length;t++)this.queue.push(e[t]);xr&&Sr<=11&&e.some((e=>"childList"==e.type&&e.removedNodes.length||"characterData"==e.type&&e.oldValue.length>e.target.nodeValue.length))?this.flushSoon():this.flush()})),nl&&(this.onCharData=e=>{this.queue.push({target:e.target,type:"characterData",oldValue:e.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout((()=>{this.flushingSoon=-1,this.flush()}),20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,tl)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let t=0;t<e.length;t++)this.queue.push(e[t]);window.setTimeout((()=>this.flush()),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout((()=>this.suppressingSelectionUpdates=!1),50)}onSelectionChange(){if(zi(this.view)){if(this.suppressingSelectionUpdates)return Oi(this.view);if(xr&&Sr<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&cr(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t,n=new Set;for(let t=e.focusNode;t;t=sr(t))n.add(t);for(let o=e.anchorNode;o;o=sr(o))if(n.has(o)){t=o;break}let o=t&&this.view.docView.nearestDesc(t);return o&&o.ignoreMutation({type:"selection",target:3==t.nodeType?t.parentNode:t})?(this.setCurSelection(),!0):void 0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let n=e.domSelectionRange(),o=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(n)&&zi(e)&&!this.ignoreSelectionChange(n),r=-1,i=-1,s=!1,l=[];if(e.editable)for(let e=0;e<t.length;e++){let n=this.registerMutation(t[e],l);n&&(r=r<0?n.from:Math.min(n.from,r),i=i<0?n.to:Math.max(n.to,i),n.typeOver&&(s=!0))}if(Cr&&l.length){let t=l.filter((e=>"BR"==e.nodeName));if(2==t.length){let[e,n]=t;e.parentNode&&e.parentNode.parentNode==n.parentNode?n.remove():e.remove()}else{let{focusNode:n}=this.currentSelection;for(let o of t){let t=o.parentNode;!t||"LI"!=t.nodeName||n&&al(e,n)==t||o.remove()}}}let a=null;r<0&&o&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&fr(n)&&(a=Mi(e))&&a.eq(et.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,Oi(e),this.currentSelection.set(n),e.scrollToSelection()):(r>-1||o)&&(r>-1&&(e.docView.markDirty(r,i),function(e){if(il.has(e))return;if(il.set(e,null),-1!==["normal","nowrap","pre-line"].indexOf(getComputedStyle(e.dom).whiteSpace)){if(e.requiresGeckoHackNode=Cr,sl)return;console.warn("ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package."),sl=!0}}(e)),this.handleDOMChange(r,i,s,l),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(n)||Oi(e),this.currentSelection.set(n))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let n=this.view.docView.nearestDesc(e.target);if("attributes"==e.type&&(n==this.view.docView||"contenteditable"==e.attributeName||"style"==e.attributeName&&!e.oldValue&&!e.target.getAttribute("style")))return null;if(!n||n.ignoreMutation(e))return null;if("childList"==e.type){for(let n=0;n<e.addedNodes.length;n++){let o=e.addedNodes[n];t.push(o),3==o.nodeType&&(this.lastChangedTextNode=o)}if(n.contentDOM&&n.contentDOM!=n.dom&&!n.contentDOM.contains(e.target))return{from:n.posBefore,to:n.posAfter};let o=e.previousSibling,r=e.nextSibling;if(xr&&Sr<=11&&e.addedNodes.length)for(let t=0;t<e.addedNodes.length;t++){let{previousSibling:n,nextSibling:i}=e.addedNodes[t];(!n||Array.prototype.indexOf.call(e.addedNodes,n)<0)&&(o=n),(!i||Array.prototype.indexOf.call(e.addedNodes,i)<0)&&(r=i)}let i=o&&o.parentNode==e.target?ir(o)+1:0,s=n.localPosFromDOM(e.target,i,-1),l=r&&r.parentNode==e.target?ir(r):e.target.childNodes.length;return{from:s,to:n.localPosFromDOM(e.target,l,1)}}return"attributes"==e.type?{from:n.posAtStart-n.border,to:n.posAtEnd+n.border}:(this.lastChangedTextNode=e.target,{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let il=new WeakMap,sl=!1;function ll(e,t){let n=t.startContainer,o=t.startOffset,r=t.endContainer,i=t.endOffset,s=e.domAtPos(e.state.selection.anchor);return cr(s.node,s.offset,r,i)&&([n,o,r,i]=[r,i,n,o]),{anchorNode:n,anchorOffset:o,focusNode:r,focusOffset:i}}function al(e,t){for(let n=t.parentNode;n&&n!=e.dom;n=n.parentNode){let t=e.docView.nearestDesc(n,!0);if(t&&t.node.isBlock)return n}return null}function cl(e){let t=e.pmViewDesc;if(t)return t.parseRule();if("BR"==e.nodeName&&e.parentNode){if(Ar&&/^(ul|ol)$/i.test(e.parentNode.nodeName)){let e=document.createElement("div");return e.appendChild(document.createElement("li")),{skip:e}}if(e.parentNode.lastChild==e||Ar&&/^(tr|table)$/i.test(e.parentNode.nodeName))return{ignore:!0}}else if("IMG"==e.nodeName&&e.getAttribute("mark-placeholder"))return{ignore:!0};return null}const dl=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function hl(e,t,n,o,i){let s=e.input.compositionPendingChanges||(e.composing?e.input.compositionID:0);if(e.input.compositionPendingChanges=0,t<0){let t=e.input.lastSelectionTime>Date.now()-50?e.input.lastSelectionOrigin:null,n=Mi(e,t);if(n&&!e.state.selection.eq(n)){if(Nr&&Rr&&13===e.input.lastKeyCode&&Date.now()-100<e.input.lastKeyCodeTime&&e.someProp("handleKeyDown",(t=>t(e,mr(13,"Enter")))))return;let o=e.state.tr.setSelection(n);"pointer"==t?o.setMeta("pointer",!0):"key"==t&&o.scrollIntoView(),s&&o.setMeta("composition",s),e.dispatch(o)}return}let l=e.state.doc.resolve(t),a=l.sharedDepth(n);t=l.before(a+1),n=e.state.doc.resolve(n).after(a+1);let c,d,h=e.state.selection,p=function(e,t,n){let o,{node:r,fromOffset:i,toOffset:s,from:l,to:a}=e.docView.parseRange(t,n),c=e.domSelectionRange(),d=c.anchorNode;if(d&&e.dom.contains(1==d.nodeType?d:d.parentNode)&&(o=[{node:d,offset:c.anchorOffset}],fr(c)||o.push({node:c.focusNode,offset:c.focusOffset})),Nr&&8===e.input.lastKeyCode)for(let e=s;e>i;e--){let t=r.childNodes[e-1],n=t.pmViewDesc;if("BR"==t.nodeName&&!n){s=e;break}if(!n||n.size)break}let h=e.state.doc,p=e.someProp("domParser")||U.fromSchema(e.state.schema),u=h.resolve(l),f=null,m=p.parse(r,{topNode:u.parent,topMatch:u.parent.contentMatchAt(u.index()),topOpen:!0,from:i,to:s,preserveWhitespace:"pre"!=u.parent.type.whitespace||"full",findPositions:o,ruleFromNode:cl,context:u});if(o&&null!=o[0].pos){let e=o[0].pos,t=o[1]&&o[1].pos;null==t&&(t=e),f={anchor:e+l,head:t+l}}return{doc:m,sel:f,from:l,to:a}}(e,t,n),u=e.state.doc,f=u.slice(p.from,p.to);8===e.input.lastKeyCode&&Date.now()-100<e.input.lastKeyCodeTime?(c=e.state.selection.to,d="end"):(c=e.state.selection.from,d="start"),e.input.lastKeyCode=null;let m=function(e,t,n,o,r){let i=e.findDiffStart(t,n);if(null==i)return null;let{a:s,b:l}=e.findDiffEnd(t,n+e.size,n+t.size);if("end"==r){o-=s+Math.max(0,i-Math.min(s,l))-i}if(s<i&&e.size<t.size){let e=o<=i&&o>=s?i-o:0;i-=e,i&&i<t.size&&fl(t.textBetween(i-1,i+1))&&(i+=e?1:-1),l=i+(l-s),s=i}else if(l<i){let t=o<=i&&o>=l?i-o:0;i-=t,i&&i<e.size&&fl(e.textBetween(i-1,i+1))&&(i+=t?1:-1),s=i+(s-l),l=i}return{start:i,endA:s,endB:l}}(f.content,p.doc.content,p.from,c,d);if(m&&e.input.domChangeCount++,(Tr&&e.input.lastIOSEnter>Date.now()-225||Rr)&&i.some((e=>1==e.nodeType&&!dl.test(e.nodeName)))&&(!m||m.endA>=m.endB)&&e.someProp("handleKeyDown",(t=>t(e,mr(13,"Enter")))))return void(e.input.lastIOSEnter=0);if(!m){if(!(o&&h instanceof rt&&!h.empty&&h.$head.sameParent(h.$anchor))||e.composing||p.sel&&p.sel.anchor!=p.sel.head){if(p.sel){let t=pl(e,e.state.doc,p.sel);if(t&&!t.eq(e.state.selection)){let n=e.state.tr.setSelection(t);s&&n.setMeta("composition",s),e.dispatch(n)}}return}m={start:h.from,endA:h.to,endB:h.to}}e.state.selection.from<e.state.selection.to&&m.start==m.endB&&e.state.selection instanceof rt&&(m.start>e.state.selection.from&&m.start<=e.state.selection.from+2&&e.state.selection.from>=p.from?m.start=e.state.selection.from:m.endA<e.state.selection.to&&m.endA>=e.state.selection.to-2&&e.state.selection.to<=p.to&&(m.endB+=e.state.selection.to-m.endA,m.endA=e.state.selection.to)),xr&&Sr<=11&&m.endB==m.start+1&&m.endA==m.start&&m.start>p.from&&"  "==p.doc.textBetween(m.start-p.from-1,m.start-p.from+1)&&(m.start--,m.endA--,m.endB--);let g,y=p.doc.resolveNoCache(m.start-p.from),w=p.doc.resolveNoCache(m.endB-p.from),v=u.resolve(m.start),b=y.sameParent(w)&&y.parent.inlineContent&&v.end()>=m.endA;if((Tr&&e.input.lastIOSEnter>Date.now()-225&&(!b||i.some((e=>"DIV"==e.nodeName||"P"==e.nodeName)))||!b&&y.pos<p.doc.content.size&&!y.sameParent(w)&&(g=et.findFrom(p.doc.resolve(y.pos+1),1,!0))&&g.head==w.pos)&&e.someProp("handleKeyDown",(t=>t(e,mr(13,"Enter")))))return void(e.input.lastIOSEnter=0);if(e.state.selection.anchor>m.start&&function(e,t,n,o,r){if(n-t<=r.pos-o.pos||ul(o,!0,!1)<r.pos)return!1;let i=e.resolve(t);if(!o.parent.isTextblock){let e=i.nodeAfter;return null!=e&&n==t+e.nodeSize}if(i.parentOffset<i.parent.content.size||!i.parent.isTextblock)return!1;let s=e.resolve(ul(i,!0,!0));return!(!s.parent.isTextblock||s.pos>n||ul(s,!0,!1)<n)&&o.parent.content.cut(o.parentOffset).eq(s.parent.content)}(u,m.start,m.endA,y,w)&&e.someProp("handleKeyDown",(t=>t(e,mr(8,"Backspace")))))return void(Rr&&Nr&&e.domObserver.suppressSelectionUpdates());Nr&&m.endB==m.start&&(e.input.lastChromeDelete=Date.now()),Rr&&!b&&y.start()!=w.start()&&0==w.parentOffset&&y.depth==w.depth&&p.sel&&p.sel.anchor==p.sel.head&&p.sel.head==m.endA&&(m.endB-=2,w=p.doc.resolveNoCache(m.endB-p.from),setTimeout((()=>{e.someProp("handleKeyDown",(function(t){return t(e,mr(13,"Enter"))}))}),20));let k,x,S,C=m.start,M=m.endA;if(b)if(y.pos==w.pos)xr&&Sr<=11&&0==y.parentOffset&&(e.domObserver.suppressSelectionUpdates(),setTimeout((()=>Oi(e)),20)),k=e.state.tr.delete(C,M),x=u.resolve(m.start).marksAcross(u.resolve(m.endA));else if(m.endA==m.endB&&(S=function(e,t){let n,o,i,s=e.firstChild.marks,l=t.firstChild.marks,a=s,c=l;for(let e=0;e<l.length;e++)a=l[e].removeFromSet(a);for(let e=0;e<s.length;e++)c=s[e].removeFromSet(c);if(1==a.length&&0==c.length)o=a[0],n="add",i=e=>e.mark(o.addToSet(e.marks));else{if(0!=a.length||1!=c.length)return null;o=c[0],n="remove",i=e=>e.mark(o.removeFromSet(e.marks))}let d=[];for(let e=0;e<t.childCount;e++)d.push(i(t.child(e)));if(r.from(d).eq(e))return{mark:o,type:n}}(y.parent.content.cut(y.parentOffset,w.parentOffset),v.parent.content.cut(v.parentOffset,m.endA-v.start()))))k=e.state.tr,"add"==S.type?k.addMark(C,M,S.mark):k.removeMark(C,M,S.mark);else if(y.parent.child(y.index()).isText&&y.index()==w.index()-(w.textOffset?0:1)){let t=y.parent.textBetween(y.parentOffset,w.parentOffset);if(e.someProp("handleTextInput",(n=>n(e,C,M,t))))return;k=e.state.tr.insertText(t,C,M)}if(k||(k=e.state.tr.replace(C,M,p.doc.slice(m.start-p.from,m.endB-p.from))),p.sel){let t=pl(e,k.doc,p.sel);t&&!(Nr&&e.composing&&t.empty&&(m.start!=m.endB||e.input.lastChromeDelete<Date.now()-100)&&(t.head==C||t.head==k.mapping.map(M)-1)||xr&&t.empty&&t.head==C)&&k.setSelection(t)}x&&k.ensureMarks(x),s&&k.setMeta("composition",s),e.dispatch(k.scrollIntoView())}function pl(e,t,n){return Math.max(n.anchor,n.head)>t.content.size?null:Ii(e,t.resolve(n.anchor),t.resolve(n.head))}function ul(e,t,n){let o=e.depth,r=t?e.end():e.pos;for(;o>0&&(t||e.indexAfter(o)==e.node(o).childCount);)o--,r++,t=!1;if(n){let t=e.node(o).maybeChild(e.indexAfter(o));for(;t&&!t.isLeaf;)t=t.firstChild,r++}return r}function fl(e){if(2!=e.length)return!1;let t=e.charCodeAt(0),n=e.charCodeAt(1);return t>=56320&&t<=57343&&n>=55296&&n<=56319}const ml=Gi,gl=Yi,yl=Es;function wl(e){let t=Object.create(null);return t.class="ProseMirror",t.contenteditable=String(e.editable),e.someProp("attributes",(n=>{if("function"==typeof n&&(n=n(e.state)),n)for(let e in n)"class"==e?t.class+=" "+n[e]:"style"==e?t.style=(t.style?t.style+";":"")+n[e]:t[e]||"contenteditable"==e||"nodeName"==e||(t[e]=String(n[e]))})),t.translate||(t.translate="no"),[Hs.node(0,e.state.doc.content.size,t)]}function vl(e){if(e.markCursor){let t=document.createElement("img");t.className="ProseMirror-separator",t.setAttribute("mark-placeholder","true"),t.setAttribute("alt",""),e.cursorWrapper={dom:t,deco:Hs.widget(e.state.selection.from,t,{raw:!0,marks:e.markCursor})}}else e.cursorWrapper=null}function bl(e){return!e.someProp("editable",(t=>!1===t(e.state)))}function kl(e){let t=Object.create(null);function n(e){for(let n in e)Object.prototype.hasOwnProperty.call(t,n)||(t[n]=e[n])}return e.someProp("nodeViews",n),e.someProp("markViews",n),t}function xl(e){if(e.spec.state||e.spec.filterTransaction||e.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}for(var Sl={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:"'"},Cl={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Ml="undefined"!=typeof navigator&&/Mac/.test(navigator.platform),Nl="undefined"!=typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),Ol=0;Ol<10;Ol++)Sl[48+Ol]=Sl[96+Ol]=String(Ol);for(Ol=1;Ol<=24;Ol++)Sl[Ol+111]="F"+Ol;for(Ol=65;Ol<=90;Ol++)Sl[Ol]=String.fromCharCode(Ol+32),Cl[Ol]=String.fromCharCode(Ol);for(var Al in Sl)Cl.hasOwnProperty(Al)||(Cl[Al]=Sl[Al]);const Tl="undefined"!=typeof navigator&&/Mac|iP(hone|[oa]d)/.test(navigator.platform);function Dl(e){let t,n,o,r,i=e.split(/-(?!$)/),s=i[i.length-1];"Space"==s&&(s=" ");for(let e=0;e<i.length-1;e++){let s=i[e];if(/^(cmd|meta|m)$/i.test(s))r=!0;else if(/^a(lt)?$/i.test(s))t=!0;else if(/^(c|ctrl|control)$/i.test(s))n=!0;else if(/^s(hift)?$/i.test(s))o=!0;else{if(!/^mod$/i.test(s))throw new Error("Unrecognized modifier name: "+s);Tl?r=!0:n=!0}}return t&&(s="Alt-"+s),n&&(s="Ctrl-"+s),r&&(s="Meta-"+s),o&&(s="Shift-"+s),s}function El(e,t,n=!0){return t.altKey&&(e="Alt-"+e),t.ctrlKey&&(e="Ctrl-"+e),t.metaKey&&(e="Meta-"+e),n&&t.shiftKey&&(e="Shift-"+e),e}function Rl(e){let t=function(e){let t=Object.create(null);for(let n in e)t[Dl(n)]=e[n];return t}(e);return function(e,n){let o,r=function(e){var t=!(Ml&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||Nl&&e.shiftKey&&e.key&&1==e.key.length||"Unidentified"==e.key)&&e.key||(e.shiftKey?Cl:Sl)[e.keyCode]||e.key||"Unidentified";return"Esc"==t&&(t="Escape"),"Del"==t&&(t="Delete"),"Left"==t&&(t="ArrowLeft"),"Up"==t&&(t="ArrowUp"),"Right"==t&&(t="ArrowRight"),"Down"==t&&(t="ArrowDown"),t}(n),i=t[El(r,n)];if(i&&i(e.state,e.dispatch,e))return!0;if(1==r.length&&" "!=r){if(n.shiftKey){let o=t[El(r,n,!1)];if(o&&o(e.state,e.dispatch,e))return!0}if((n.shiftKey||n.altKey||n.metaKey||r.charCodeAt(0)>127)&&(o=Sl[n.keyCode])&&o!=r){let r=t[El(o,n)];if(r&&r(e.state,e.dispatch,e))return!0}}return!1}}var $l,Il;if("undefined"!=typeof WeakMap){let e=new WeakMap;$l=t=>e.get(t),Il=(t,n)=>(e.set(t,n),n)}else{const e=[],t=10;let n=0;$l=t=>{for(let n=0;n<e.length;n+=2)if(e[n]==t)return e[n+1]},Il=(o,r)=>(n==t&&(n=0),e[n++]=o,e[n++]=r)}var zl=class{constructor(e,t,n,o){this.width=e,this.height=t,this.map=n,this.problems=o}findCell(e){for(let t=0;t<this.map.length;t++){const n=this.map[t];if(n!=e)continue;const o=t%this.width,r=t/this.width|0;let i=o+1,s=r+1;for(let e=1;i<this.width&&this.map[t+e]==n;e++)i++;for(let e=1;s<this.height&&this.map[t+this.width*e]==n;e++)s++;return{left:o,top:r,right:i,bottom:s}}throw new RangeError(`No cell with offset ${e} found`)}colCount(e){for(let t=0;t<this.map.length;t++)if(this.map[t]==e)return t%this.width;throw new RangeError(`No cell with offset ${e} found`)}nextCell(e,t,n){const{left:o,right:r,top:i,bottom:s}=this.findCell(e);return"horiz"==t?(n<0?0==o:r==this.width)?null:this.map[i*this.width+(n<0?o-1:r)]:(n<0?0==i:s==this.height)?null:this.map[o+this.width*(n<0?i-1:s)]}rectBetween(e,t){const{left:n,right:o,top:r,bottom:i}=this.findCell(e),{left:s,right:l,top:a,bottom:c}=this.findCell(t);return{left:Math.min(n,s),top:Math.min(r,a),right:Math.max(o,l),bottom:Math.max(i,c)}}cellsInRect(e){const t=[],n={};for(let o=e.top;o<e.bottom;o++)for(let r=e.left;r<e.right;r++){const i=o*this.width+r,s=this.map[i];n[s]||(n[s]=!0,r==e.left&&r&&this.map[i-1]==s||o==e.top&&o&&this.map[i-this.width]==s||t.push(s))}return t}positionAt(e,t,n){for(let o=0,r=0;;o++){const i=r+n.child(o).nodeSize;if(o==e){let n=t+e*this.width;const o=(e+1)*this.width;for(;n<o&&this.map[n]<r;)n++;return n==o?i-1:this.map[n]}r=i}}static get(e){return $l(e)||Il(e,function(e){if("table"!=e.type.spec.tableRole)throw new RangeError("Not a table node: "+e.type.name);const t=function(e){let t=-1,n=!1;for(let o=0;o<e.childCount;o++){const r=e.child(o);let i=0;if(n)for(let t=0;t<o;t++){const n=e.child(t);for(let e=0;e<n.childCount;e++){const r=n.child(e);t+r.attrs.rowspan>o&&(i+=r.attrs.colspan)}}for(let e=0;e<r.childCount;e++){const t=r.child(e);i+=t.attrs.colspan,t.attrs.rowspan>1&&(n=!0)}-1==t?t=i:t!=i&&(t=Math.max(t,i))}return t}(e),n=e.childCount,o=[];let r=0,i=null;const s=[];for(let e=0,r=t*n;e<r;e++)o[e]=0;for(let l=0,a=0;l<n;l++){const c=e.child(l);a++;for(let e=0;;e++){for(;r<o.length&&0!=o[r];)r++;if(e==c.childCount)break;const d=c.child(e),{colspan:h,rowspan:p,colwidth:u}=d.attrs;for(let e=0;e<p;e++){if(e+l>=n){(i||(i=[])).push({type:"overlong_rowspan",pos:a,n:p-e});break}const c=r+e*t;for(let e=0;e<h;e++){0==o[c+e]?o[c+e]=a:(i||(i=[])).push({type:"collision",row:l,pos:a,n:h-e});const n=u&&u[e];if(n){const o=(c+e)%t*2,r=s[o];null==r||r!=n&&1==s[o+1]?(s[o]=n,s[o+1]=1):r==n&&s[o+1]++}}}r+=h,a+=d.nodeSize}const d=(l+1)*t;let h=0;for(;r<d;)0==o[r++]&&h++;h&&(i||(i=[])).push({type:"missing",row:l,n:h}),a++}const l=new zl(t,n,o,i);let a=!1;for(let e=0;!a&&e<s.length;e+=2)null!=s[e]&&s[e+1]<n&&(a=!0);a&&function(e,t,n){e.problems||(e.problems=[]);const o={};for(let r=0;r<e.map.length;r++){const i=e.map[r];if(o[i])continue;o[i]=!0;const s=n.nodeAt(i);if(!s)throw new RangeError(`No cell with offset ${i} found`);let l=null;const a=s.attrs;for(let n=0;n<a.colspan;n++){const o=t[2*((r+n)%e.width)];null==o||a.colwidth&&a.colwidth[n]==o||((l||(l=Bl(a)))[n]=o)}l&&e.problems.unshift({type:"colwidth mismatch",pos:i,colwidth:l})}}(l,s,e);return l}(e))}};function Bl(e){if(e.colwidth)return e.colwidth.slice();const t=[];for(let n=0;n<e.colspan;n++)t.push(0);return t}function Pl(e,t){if("string"==typeof e)return{};const n=e.getAttribute("data-colwidth"),o=n&&/^\d+(,\d+)*$/.test(n)?n.split(",").map((e=>Number(e))):null,r=Number(e.getAttribute("colspan")||1),i={colspan:r,rowspan:Number(e.getAttribute("rowspan")||1),colwidth:o&&o.length==r?o:null};for(const n in t){const o=t[n].getFromDOM,r=o&&o(e);null!=r&&(i[n]=r)}return i}function Vl(e,t){const n={};1!=e.attrs.colspan&&(n.colspan=e.attrs.colspan),1!=e.attrs.rowspan&&(n.rowspan=e.attrs.rowspan),e.attrs.colwidth&&(n["data-colwidth"]=e.attrs.colwidth.join(","));for(const o in t){const r=t[o].setDOMAttr;r&&r(e.attrs[o],n)}return n}function Fl(e){const t=e.cellAttributes||{},n={colspan:{default:1},rowspan:{default:1},colwidth:{default:null}};for(const e in t)n[e]={default:t[e].default};return{table:{content:"table_row+",tableRole:"table",isolating:!0,group:e.tableGroup,parseDOM:[{tag:"table"}],toDOM:()=>["table",["tbody",0]]},table_row:{content:"(table_cell | table_header)*",tableRole:"row",parseDOM:[{tag:"tr"}],toDOM:()=>["tr",0]},table_cell:{content:e.cellContent,attrs:n,tableRole:"cell",isolating:!0,parseDOM:[{tag:"td",getAttrs:e=>Pl(e,t)}],toDOM:e=>["td",Vl(e,t),0]},table_header:{content:e.cellContent,attrs:n,tableRole:"header_cell",isolating:!0,parseDOM:[{tag:"th",getAttrs:e=>Pl(e,t)}],toDOM:e=>["th",Vl(e,t),0]}}}function Ll(e){let t=e.cached.tableNodeTypes;if(!t){t=e.cached.tableNodeTypes={};for(const n in e.nodes){const o=e.nodes[n],r=o.spec.tableRole;r&&(t[r]=o)}}return t}var Hl=new xt("selectingCells");function _l(e){for(let t=e.depth-1;t>0;t--)if("row"==e.node(t).type.spec.tableRole)return e.node(0).resolve(e.before(t+1));return null}function Wl(e){const t=e.selection.$head;for(let e=t.depth;e>0;e--)if("row"==t.node(e).type.spec.tableRole)return!0;return!1}function ql(e){const t=e.selection;if("$anchorCell"in t&&t.$anchorCell)return t.$anchorCell.pos>t.$headCell.pos?t.$anchorCell:t.$headCell;if("node"in t&&t.node&&"cell"==t.node.type.spec.tableRole)return t.$anchor;const n=_l(t.$head)||function(e){for(let t=e.nodeAfter,n=e.pos;t;t=t.firstChild,n++){const o=t.type.spec.tableRole;if("cell"==o||"header_cell"==o)return e.doc.resolve(n)}for(let t=e.nodeBefore,n=e.pos;t;t=t.lastChild,n--){const o=t.type.spec.tableRole;if("cell"==o||"header_cell"==o)return e.doc.resolve(n-t.nodeSize)}}(t.$head);if(n)return n;throw new RangeError(`No cell found around position ${t.head}`)}function Jl(e){return"row"==e.parent.type.spec.tableRole&&!!e.nodeAfter}function jl(e){return e.node(0).resolve(e.pos+e.nodeAfter.nodeSize)}function Kl(e,t){return e.depth==t.depth&&e.pos>=t.start(-1)&&e.pos<=t.end(-1)}function Xl(e,t,n){const o=e.node(-1),r=zl.get(o),i=e.start(-1),s=r.nextCell(e.pos-i,t,n);return null==s?null:e.node(0).resolve(i+s)}function Ul(e,t,n=1){const o={...e,colspan:e.colspan-n};return o.colwidth&&(o.colwidth=o.colwidth.slice(),o.colwidth.splice(t,n),o.colwidth.some((e=>e>0))||(o.colwidth=null)),o}function Gl(e,t,n=1){const o={...e,colspan:e.colspan+n};if(o.colwidth){o.colwidth=o.colwidth.slice();for(let e=0;e<n;e++)o.colwidth.splice(t,0,0)}return o}function Yl(e,t,n){const o=Ll(t.type.schema).header_cell;for(let r=0;r<e.height;r++)if(t.nodeAt(e.map[n+r*e.width]).type!=o)return!1;return!0}var Ql=class e extends et{constructor(e,t=e){const n=e.node(-1),o=zl.get(n),r=e.start(-1),i=o.rectBetween(e.pos-r,t.pos-r),s=e.node(0),l=o.cellsInRect(i).filter((e=>e!=t.pos-r));l.unshift(t.pos-r);const a=l.map((e=>{const t=n.nodeAt(e);if(!t)throw RangeError(`No cell with offset ${e} found`);const o=r+e+1;return new tt(s.resolve(o),s.resolve(o+t.content.size))}));super(a[0].$from,a[0].$to,a),this.$anchorCell=e,this.$headCell=t}map(t,n){const o=t.resolve(n.map(this.$anchorCell.pos)),r=t.resolve(n.map(this.$headCell.pos));if(Jl(o)&&Jl(r)&&Kl(o,r)){const t=this.$anchorCell.node(-1)!=o.node(-1);return t&&this.isRowSelection()?e.rowSelection(o,r):t&&this.isColSelection()?e.colSelection(o,r):new e(o,r)}return rt.between(o,r)}content(){const e=this.$anchorCell.node(-1),t=zl.get(e),n=this.$anchorCell.start(-1),o=t.rectBetween(this.$anchorCell.pos-n,this.$headCell.pos-n),i={},s=[];for(let n=o.top;n<o.bottom;n++){const l=[];for(let r=n*t.width+o.left,s=o.left;s<o.right;s++,r++){const n=t.map[r];if(i[n])continue;i[n]=!0;const s=t.findCell(n);let a=e.nodeAt(n);if(!a)throw RangeError(`No cell with offset ${n} found`);const c=o.left-s.left,d=s.right-o.right;if(c>0||d>0){let e=a.attrs;if(c>0&&(e=Ul(e,0,c)),d>0&&(e=Ul(e,e.colspan-d,d)),s.left<o.left){if(a=a.type.createAndFill(e),!a)throw RangeError(`Could not create cell with attrs ${JSON.stringify(e)}`)}else a=a.type.create(e,a.content)}if(s.top<o.top||s.bottom>o.bottom){const e={...a.attrs,rowspan:Math.min(s.bottom,o.bottom)-Math.max(s.top,o.top)};a=s.top<o.top?a.type.createAndFill(e):a.type.create(e,a.content)}l.push(a)}s.push(e.child(n).copy(r.from(l)))}const l=this.isColSelection()&&this.isRowSelection()?e:s;return new d(r.from(l),1,1)}replace(e,t=d.empty){const n=e.steps.length,o=this.ranges;for(let r=0;r<o.length;r++){const{$from:i,$to:s}=o[r],l=e.mapping.slice(n);e.replace(l.map(i.pos),l.map(s.pos),r?d.empty:t)}const r=et.findFrom(e.doc.resolve(e.mapping.slice(n).map(this.to)),-1);r&&e.setSelection(r)}replaceWith(e,t){this.replace(e,new d(r.from(t),0,0))}forEachCell(e){const t=this.$anchorCell.node(-1),n=zl.get(t),o=this.$anchorCell.start(-1),r=n.cellsInRect(n.rectBetween(this.$anchorCell.pos-o,this.$headCell.pos-o));for(let n=0;n<r.length;n++)e(t.nodeAt(r[n]),o+r[n])}isColSelection(){const e=this.$anchorCell.index(-1),t=this.$headCell.index(-1);if(Math.min(e,t)>0)return!1;const n=e+this.$anchorCell.nodeAfter.attrs.rowspan,o=t+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(n,o)==this.$headCell.node(-1).childCount}static colSelection(t,n=t){const o=t.node(-1),r=zl.get(o),i=t.start(-1),s=r.findCell(t.pos-i),l=r.findCell(n.pos-i),a=t.node(0);return s.top<=l.top?(s.top>0&&(t=a.resolve(i+r.map[s.left])),l.bottom<r.height&&(n=a.resolve(i+r.map[r.width*(r.height-1)+l.right-1]))):(l.top>0&&(n=a.resolve(i+r.map[l.left])),s.bottom<r.height&&(t=a.resolve(i+r.map[r.width*(r.height-1)+s.right-1]))),new e(t,n)}isRowSelection(){const e=this.$anchorCell.node(-1),t=zl.get(e),n=this.$anchorCell.start(-1),o=t.colCount(this.$anchorCell.pos-n),r=t.colCount(this.$headCell.pos-n);if(Math.min(o,r)>0)return!1;const i=o+this.$anchorCell.nodeAfter.attrs.colspan,s=r+this.$headCell.nodeAfter.attrs.colspan;return Math.max(i,s)==t.width}eq(t){return t instanceof e&&t.$anchorCell.pos==this.$anchorCell.pos&&t.$headCell.pos==this.$headCell.pos}static rowSelection(t,n=t){const o=t.node(-1),r=zl.get(o),i=t.start(-1),s=r.findCell(t.pos-i),l=r.findCell(n.pos-i),a=t.node(0);return s.left<=l.left?(s.left>0&&(t=a.resolve(i+r.map[s.top*r.width])),l.right<r.width&&(n=a.resolve(i+r.map[r.width*(l.top+1)-1]))):(l.left>0&&(n=a.resolve(i+r.map[l.top*r.width])),s.right<r.width&&(t=a.resolve(i+r.map[r.width*(s.top+1)-1]))),new e(t,n)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(t,n){return new e(t.resolve(n.anchor),t.resolve(n.head))}static create(t,n,o=n){return new e(t.resolve(n),t.resolve(o))}getBookmark(){return new Zl(this.$anchorCell.pos,this.$headCell.pos)}};Ql.prototype.visible=!1,et.jsonID("cell",Ql);var Zl=class e{constructor(e,t){this.anchor=e,this.head=t}map(t){return new e(t.map(this.anchor),t.map(this.head))}resolve(e){const t=e.resolve(this.anchor),n=e.resolve(this.head);return"row"==t.parent.type.spec.tableRole&&"row"==n.parent.type.spec.tableRole&&t.index()<t.parent.childCount&&n.index()<n.parent.childCount&&Kl(t,n)?new Ql(t,n):et.near(n,1)}};function ea(e){if(!(e.selection instanceof Ql))return null;const t=[];return e.selection.forEachCell(((e,n)=>{t.push(Hs.node(n,n+e.nodeSize,{class:"selectedCell"}))})),qs.create(e.doc,t)}var ta=new xt("fix-tables");function na(e,t,n,o){const r=e.childCount,i=t.childCount;e:for(let s=0,l=0;s<i;s++){const i=t.child(s);for(let t=l,o=Math.min(r,s+3);t<o;t++)if(e.child(t)==i){l=t+1,n+=i.nodeSize;continue e}o(i,n),l<r&&e.child(l).sameMarkup(i)?na(e.child(l),i,n+1,o):i.nodesBetween(0,i.content.size,o,n+1),n+=i.nodeSize}}function oa(e,t){let n;const o=(t,o)=>{"table"==t.type.spec.tableRole&&(n=function(e,t,n,o){const r=zl.get(t);if(!r.problems)return o;o||(o=e.tr);const i=[];for(let e=0;e<r.height;e++)i.push(0);for(let e=0;e<r.problems.length;e++){const s=r.problems[e];if("collision"==s.type){const e=t.nodeAt(s.pos);if(!e)continue;const r=e.attrs;for(let e=0;e<r.rowspan;e++)i[s.row+e]+=s.n;o.setNodeMarkup(o.mapping.map(n+1+s.pos),null,Ul(r,r.colspan-s.n,s.n))}else if("missing"==s.type)i[s.row]+=s.n;else if("overlong_rowspan"==s.type){const e=t.nodeAt(s.pos);if(!e)continue;o.setNodeMarkup(o.mapping.map(n+1+s.pos),null,{...e.attrs,rowspan:e.attrs.rowspan-s.n})}else if("colwidth mismatch"==s.type){const e=t.nodeAt(s.pos);if(!e)continue;o.setNodeMarkup(o.mapping.map(n+1+s.pos),null,{...e.attrs,colwidth:s.colwidth})}}let s,l;for(let e=0;e<i.length;e++)i[e]&&(null==s&&(s=e),l=e);for(let a=0,c=n+1;a<r.height;a++){const n=t.child(a),r=c+n.nodeSize,d=i[a];if(d>0){let t="cell";n.firstChild&&(t=n.firstChild.type.spec.tableRole);const i=[];for(let n=0;n<d;n++){const n=Ll(e.schema)[t].createAndFill();n&&i.push(n)}const h=0!=a&&s!=a-1||l!=a?r-1:c+1;o.insert(o.mapping.map(h),i)}c=r}return o.setMeta(ta,{fixTables:!0})}(e,t,o,n))};return t?t.doc!=e.doc&&na(t.doc,e.doc,0,o):e.doc.descendants(o),n}function ra(e){const t=e.selection,n=ql(e),o=n.node(-1),r=n.start(-1),i=zl.get(o);return{...t instanceof Ql?i.rectBetween(t.$anchorCell.pos-r,t.$headCell.pos-r):i.findCell(n.pos-r),tableStart:r,map:i,table:o}}function ia(e,{map:t,tableStart:n,table:o},r){let i=r>0?-1:0;Yl(t,o,r+i)&&(i=0==r||r==t.width?null:0);for(let s=0;s<t.height;s++){const l=s*t.width+r;if(r>0&&r<t.width&&t.map[l-1]==t.map[l]){const i=t.map[l],a=o.nodeAt(i);e.setNodeMarkup(e.mapping.map(n+i),null,Gl(a.attrs,r-t.colCount(i))),s+=a.attrs.rowspan-1}else{const a=null==i?Ll(o.type.schema).cell:o.nodeAt(t.map[l+i]).type,c=t.positionAt(s,r,o);e.insert(e.mapping.map(n+c),a.createAndFill())}}return e}function sa(e,t){if(!Wl(e))return!1;if(t){const n=ra(e);t(ia(e.tr,n,n.left))}return!0}function la(e,t){if(!Wl(e))return!1;if(t){const n=ra(e);t(ia(e.tr,n,n.right))}return!0}function aa(e,{map:t,table:n,tableStart:o},r){const i=e.mapping.maps.length;for(let s=0;s<t.height;){const l=s*t.width+r,a=t.map[l],c=n.nodeAt(a),d=c.attrs;if(r>0&&t.map[l-1]==a||r<t.width-1&&t.map[l+1]==a)e.setNodeMarkup(e.mapping.slice(i).map(o+a),null,Ul(d,r-t.colCount(a)));else{const t=e.mapping.slice(i).map(o+a);e.delete(t,t+c.nodeSize)}s+=d.rowspan}}function ca(e,t){if(!Wl(e))return!1;if(t){const n=ra(e),o=e.tr;if(0==n.left&&n.right==n.map.width)return!1;for(let e=n.right-1;aa(o,n,e),e!=n.left;e--){const e=n.tableStart?o.doc.nodeAt(n.tableStart-1):o.doc;if(!e)throw RangeError("No table found");n.table=e,n.map=zl.get(e)}t(o)}return!0}function da(e,t,n){var o;const r=Ll(t.type.schema).header_cell;for(let i=0;i<e.width;i++)if((null==(o=t.nodeAt(e.map[i+n*e.width]))?void 0:o.type)!=r)return!1;return!0}function ha(e,{map:t,tableStart:n,table:o},r){var i;let s=n;for(let e=0;e<r;e++)s+=o.child(e).nodeSize;const l=[];let a=r>0?-1:0;da(t,o,r+a)&&(a=0==r||r==t.height?null:0);for(let s=0,c=t.width*r;s<t.width;s++,c++)if(r>0&&r<t.height&&t.map[c]==t.map[c-t.width]){const r=t.map[c],i=o.nodeAt(r).attrs;e.setNodeMarkup(n+r,null,{...i,rowspan:i.rowspan+1}),s+=i.colspan-1}else{const e=null==a?Ll(o.type.schema).cell:null==(i=o.nodeAt(t.map[c+a*t.width]))?void 0:i.type,n=null==e?void 0:e.createAndFill();n&&l.push(n)}return e.insert(s,Ll(o.type.schema).row.create(null,l)),e}function pa(e,t){if(!Wl(e))return!1;if(t){const n=ra(e);t(ha(e.tr,n,n.top))}return!0}function ua(e,t){if(!Wl(e))return!1;if(t){const n=ra(e);t(ha(e.tr,n,n.bottom))}return!0}function fa(e,{map:t,table:n,tableStart:o},r){let i=0;for(let e=0;e<r;e++)i+=n.child(e).nodeSize;const s=i+n.child(r).nodeSize,l=e.mapping.maps.length;e.delete(i+o,s+o);const a=new Set;for(let i=0,s=r*t.width;i<t.width;i++,s++){const c=t.map[s];if(!a.has(c))if(a.add(c),r>0&&c==t.map[s-t.width]){const t=n.nodeAt(c).attrs;e.setNodeMarkup(e.mapping.slice(l).map(c+o),null,{...t,rowspan:t.rowspan-1}),i+=t.colspan-1}else if(r<t.height&&c==t.map[s+t.width]){const s=n.nodeAt(c),a=s.attrs,d=s.type.create({...a,rowspan:s.attrs.rowspan-1},s.content),h=t.positionAt(r+1,i,n);e.insert(e.mapping.slice(l).map(o+h),d),i+=a.colspan-1}}}function ma(e){const t=e.content;return 1==t.childCount&&t.child(0).isTextblock&&0==t.child(0).childCount}function ga(e){return(t,n)=>{var o;const r=t.selection;let i,s;if(r instanceof Ql){if(r.$anchorCell.pos!=r.$headCell.pos)return!1;i=r.$anchorCell.nodeAfter,s=r.$anchorCell.pos}else{if(i=function(e){for(let t=e.depth;t>0;t--){const n=e.node(t).type.spec.tableRole;if("cell"===n||"header_cell"===n)return e.node(t)}return null}(r.$from),!i)return!1;s=null==(o=_l(r.$from))?void 0:o.pos}if(null==i||null==s)return!1;if(1==i.attrs.colspan&&1==i.attrs.rowspan)return!1;if(n){let o=i.attrs;const l=[],a=o.colwidth;o.rowspan>1&&(o={...o,rowspan:1}),o.colspan>1&&(o={...o,colspan:1});const c=ra(t),d=t.tr;for(let e=0;e<c.right-c.left;e++)l.push(a?{...o,colwidth:a&&a[e]?[a[e]]:null}:o);let h;for(let t=c.top;t<c.bottom;t++){let n=c.map.positionAt(t,c.left,c.table);t==c.top&&(n+=i.nodeSize);for(let o=c.left,r=0;o<c.right;o++,r++)o==c.left&&t==c.top||d.insert(h=d.mapping.map(n+c.tableStart,1),e({node:i,row:t,col:o}).createAndFill(l[r]))}d.setNodeMarkup(s,e({node:i,row:c.top,col:c.left}),l[0]),r instanceof Ql&&d.setSelection(new Ql(d.doc.resolve(r.$anchorCell.pos),h?d.doc.resolve(h):void 0)),n(d)}return!0}}function ya(e,t,n){const o=t.map.cellsInRect({left:0,top:0,right:"row"==e?t.map.width:1,bottom:"column"==e?t.map.height:1});for(let e=0;e<o.length;e++){const r=t.table.nodeAt(o[e]);if(r&&r.type!==n.header_cell)return!1}return!0}function wa(e,t){return(t=t||{useDeprecatedLogic:!1}).useDeprecatedLogic?function(e){return function(t,n){if(!Wl(t))return!1;if(n){const o=Ll(t.schema),r=ra(t),i=t.tr,s=r.map.cellsInRect("column"==e?{left:r.left,top:0,right:r.right,bottom:r.map.height}:"row"==e?{left:0,top:r.top,right:r.map.width,bottom:r.bottom}:r),l=s.map((e=>r.table.nodeAt(e)));for(let e=0;e<s.length;e++)l[e].type==o.header_cell&&i.setNodeMarkup(r.tableStart+s[e],o.cell,l[e].attrs);if(0==i.steps.length)for(let e=0;e<s.length;e++)i.setNodeMarkup(r.tableStart+s[e],o.header_cell,l[e].attrs);n(i)}return!0}}(e):function(t,n){if(!Wl(t))return!1;if(n){const o=Ll(t.schema),r=ra(t),i=t.tr,s=ya("row",r,o),l=ya("column",r,o),a=("column"===e?s:"row"===e&&l)?1:0,c="column"==e?{left:0,top:a,right:1,bottom:r.map.height}:"row"==e?{left:a,top:0,right:r.map.width,bottom:1}:r,d="column"==e?l?o.cell:o.header_cell:"row"==e?s?o.cell:o.header_cell:o.cell;r.map.cellsInRect(c).forEach((e=>{const t=e+r.tableStart,n=i.doc.nodeAt(t);n&&i.setNodeMarkup(t,d,n.attrs)})),n(i)}return!0}}var va=wa("row",{useDeprecatedLogic:!0}),ba=wa("column",{useDeprecatedLogic:!0}),ka=wa("cell",{useDeprecatedLogic:!0});function xa(e,t){const n=e.selection;if(!(n instanceof Ql))return!1;if(t){const o=e.tr,r=Ll(e.schema).cell.createAndFill().content;n.forEachCell(((e,t)=>{e.content.eq(r)||o.replace(o.mapping.map(t+1),o.mapping.map(t+e.nodeSize-1),new d(r,0,0))})),o.docChanged&&t(o)}return!0}function Sa(e){if(!e.size)return null;let{content:t,openStart:n,openEnd:o}=e;for(;1==t.childCount&&(n>0&&o>0||"table"==t.child(0).type.spec.tableRole);)n--,o--,t=t.child(0).content;const i=t.child(0),s=i.type.spec.tableRole,l=i.type.schema,a=[];if("row"==s)for(let e=0;e<t.childCount;e++){let r=t.child(e).content;const i=e?0:Math.max(0,n-1),s=e<t.childCount-1?0:Math.max(0,o-1);(i||s)&&(r=Ca(Ll(l).row,new d(r,i,s)).content),a.push(r)}else{if("cell"!=s&&"header_cell"!=s)return null;a.push(n||o?Ca(Ll(l).row,new d(t,n,o)).content:t)}return function(e,t){const n=[];for(let e=0;e<t.length;e++){const o=t[e];for(let t=o.childCount-1;t>=0;t--){const{rowspan:r,colspan:i}=o.child(t).attrs;for(let t=e;t<e+r;t++)n[t]=(n[t]||0)+i}}let o=0;for(let e=0;e<n.length;e++)o=Math.max(o,n[e]);for(let i=0;i<n.length;i++)if(i>=t.length&&t.push(r.empty),n[i]<o){const s=Ll(e).cell.createAndFill(),l=[];for(let e=n[i];e<o;e++)l.push(s);t[i]=t[i].append(r.from(l))}return{height:t.length,width:o,rows:t}}(l,a)}function Ca(e,t){const n=e.createAndFill();return new Qe(n).replace(0,n.content.size,t).doc}function Ma(e,t,n,o,r,i,s,l){if(0==s||s==t.height)return!1;let a=!1;for(let c=r;c<i;c++){const r=s*t.width+c,i=t.map[r];if(t.map[r-t.width]==i){a=!0;const r=n.nodeAt(i),{top:d,left:h}=t.findCell(i);e.setNodeMarkup(e.mapping.slice(l).map(i+o),null,{...r.attrs,rowspan:s-d}),e.insert(e.mapping.slice(l).map(t.positionAt(s,h,n)),r.type.createAndFill({...r.attrs,rowspan:d+r.attrs.rowspan-s})),c+=r.attrs.colspan-1}}return a}function Na(e,t,n,o,r,i,s,l){if(0==s||s==t.width)return!1;let a=!1;for(let c=r;c<i;c++){const r=c*t.width+s,i=t.map[r];if(t.map[r-1]==i){a=!0;const r=n.nodeAt(i),d=t.colCount(i),h=e.mapping.slice(l).map(i+o);e.setNodeMarkup(h,null,Ul(r.attrs,s-d,r.attrs.colspan-(s-d))),e.insert(h+r.nodeSize,r.type.createAndFill(Ul(r.attrs,0,s-d))),c+=r.attrs.rowspan-1}}return a}function Oa(e,t,n,o,i){let s=n?e.doc.nodeAt(n-1):e.doc;if(!s)throw new Error("No table found");let l=zl.get(s);const{top:a,left:c}=o,h=c+i.width,p=a+i.height,u=e.tr;let f=0;function m(){if(s=n?u.doc.nodeAt(n-1):u.doc,!s)throw new Error("No table found");l=zl.get(s),f=u.mapping.maps.length}(function(e,t,n,o,i,s,l){const a=Ll(e.doc.type.schema);let c,d;if(i>t.width)for(let r=0,s=0;r<t.height;r++){const h=n.child(r);s+=h.nodeSize;const p=[];let u;u=null==h.lastChild||h.lastChild.type==a.cell?c||(c=a.cell.createAndFill()):d||(d=a.header_cell.createAndFill());for(let e=t.width;e<i;e++)p.push(u);e.insert(e.mapping.slice(l).map(s-1+o),p)}if(s>t.height){const h=[];for(let e=0,o=(t.height-1)*t.width;e<Math.max(t.width,i);e++){const r=!(e>=t.width)&&n.nodeAt(t.map[o+e]).type==a.header_cell;h.push(r?d||(d=a.header_cell.createAndFill()):c||(c=a.cell.createAndFill()))}const p=a.row.create(null,r.from(h)),u=[];for(let e=t.height;e<s;e++)u.push(p);e.insert(e.mapping.slice(l).map(o+n.nodeSize-2),u)}return!(!c&&!d)})(u,l,s,n,h,p,f)&&m(),Ma(u,l,s,n,c,h,a,f)&&m(),Ma(u,l,s,n,c,h,p,f)&&m(),Na(u,l,s,n,a,p,c,f)&&m(),Na(u,l,s,n,a,p,h,f)&&m();for(let e=a;e<p;e++){const t=l.positionAt(e,c,s),o=l.positionAt(e,h,s);u.replace(u.mapping.slice(f).map(t+n),u.mapping.slice(f).map(o+n),new d(i.rows[e-a],0,0))}m(),u.setSelection(new Ql(u.doc.resolve(n+l.positionAt(a,c,s)),u.doc.resolve(n+l.positionAt(p-1,h-1,s)))),t(u)}var Aa=Rl({ArrowLeft:Da("horiz",-1),ArrowRight:Da("horiz",1),ArrowUp:Da("vert",-1),ArrowDown:Da("vert",1),"Shift-ArrowLeft":Ea("horiz",-1),"Shift-ArrowRight":Ea("horiz",1),"Shift-ArrowUp":Ea("vert",-1),"Shift-ArrowDown":Ea("vert",1),Backspace:xa,"Mod-Backspace":xa,Delete:xa,"Mod-Delete":xa});function Ta(e,t,n){return!n.eq(e.selection)&&(t&&t(e.tr.setSelection(n).scrollIntoView()),!0)}function Da(e,t){return(n,o,r)=>{if(!r)return!1;const i=n.selection;if(i instanceof Ql)return Ta(n,o,et.near(i.$headCell,t));if("horiz"!=e&&!i.empty)return!1;const s=za(r,e,t);if(null==s)return!1;if("horiz"==e)return Ta(n,o,et.near(n.doc.resolve(i.head+t),t));{const r=n.doc.resolve(s),i=Xl(r,e,t);let l;return l=i?et.near(i,1):t<0?et.near(n.doc.resolve(r.before(-1)),-1):et.near(n.doc.resolve(r.after(-1)),1),Ta(n,o,l)}}}function Ea(e,t){return(n,o,r)=>{if(!r)return!1;const i=n.selection;let s;if(i instanceof Ql)s=i;else{const o=za(r,e,t);if(null==o)return!1;s=new Ql(n.doc.resolve(o))}const l=Xl(s.$headCell,e,t);return!!l&&Ta(n,o,new Ql(s.$anchorCell,l))}}function Ra(e,t){const n=_l(e.state.doc.resolve(t));return!!n&&(e.dispatch(e.state.tr.setSelection(new Ql(n))),!0)}function $a(e,t,n){if(!Wl(e.state))return!1;let o=Sa(n);const i=e.state.selection;if(i instanceof Ql){o||(o={width:1,height:1,rows:[r.from(Ca(Ll(e.state.schema).cell,n))]});const t=i.$anchorCell.node(-1),s=i.$anchorCell.start(-1),l=zl.get(t).rectBetween(i.$anchorCell.pos-s,i.$headCell.pos-s);return o=function({width:e,height:t,rows:n},o,i){if(e!=o){const t=[],i=[];for(let e=0;e<n.length;e++){const s=n[e],l=[];for(let n=t[e]||0,r=0;n<o;r++){let i=s.child(r%s.childCount);n+i.attrs.colspan>o&&(i=i.type.createChecked(Ul(i.attrs,i.attrs.colspan,n+i.attrs.colspan-o),i.content)),l.push(i),n+=i.attrs.colspan;for(let n=1;n<i.attrs.rowspan;n++)t[e+n]=(t[e+n]||0)+i.attrs.colspan}i.push(r.from(l))}n=i,e=o}if(t!=i){const e=[];for(let o=0,s=0;o<i;o++,s++){const l=[],a=n[s%t];for(let e=0;e<a.childCount;e++){let t=a.child(e);o+t.attrs.rowspan>i&&(t=t.type.create({...t.attrs,rowspan:Math.max(1,i-t.attrs.rowspan)},t.content)),l.push(t)}e.push(r.from(l))}n=e,t=i}return{width:e,height:t,rows:n}}(o,l.right-l.left,l.bottom-l.top),Oa(e.state,e.dispatch,s,l,o),!0}if(o){const t=ql(e.state),n=t.start(-1);return Oa(e.state,e.dispatch,n,zl.get(t.node(-1)).findCell(t.pos-n),o),!0}return!1}function Ia(e,t){var n;if(t.ctrlKey||t.metaKey)return;const o=Ba(e,t.target);let r;if(t.shiftKey&&e.state.selection instanceof Ql)i(e.state.selection.$anchorCell,t),t.preventDefault();else if(t.shiftKey&&o&&null!=(r=_l(e.state.selection.$anchor))&&(null==(n=Pa(e,t))?void 0:n.pos)!=r.pos)i(r,t),t.preventDefault();else if(!o)return;function i(t,n){let o=Pa(e,n);const r=null==Hl.getState(e.state);if(!o||!Kl(t,o)){if(!r)return;o=t}const i=new Ql(t,o);if(r||!e.state.selection.eq(i)){const n=e.state.tr.setSelection(i);r&&n.setMeta(Hl,t.pos),e.dispatch(n)}}function s(){e.root.removeEventListener("mouseup",s),e.root.removeEventListener("dragstart",s),e.root.removeEventListener("mousemove",l),null!=Hl.getState(e.state)&&e.dispatch(e.state.tr.setMeta(Hl,-1))}function l(n){const r=n,l=Hl.getState(e.state);let a;if(null!=l)a=e.state.doc.resolve(l);else if(Ba(e,r.target)!=o&&(a=Pa(e,t),!a))return s();a&&i(a,r)}e.root.addEventListener("mouseup",s),e.root.addEventListener("dragstart",s),e.root.addEventListener("mousemove",l)}function za(e,t,n){if(!(e.state.selection instanceof rt))return null;const{$head:o}=e.state.selection;for(let r=o.depth-1;r>=0;r--){const i=o.node(r);if((n<0?o.index(r):o.indexAfter(r))!=(n<0?0:i.childCount))return null;if("cell"==i.type.spec.tableRole||"header_cell"==i.type.spec.tableRole){const i=o.before(r),s="vert"==t?n>0?"down":"up":n>0?"right":"left";return e.endOfTextblock(s)?i:null}}return null}function Ba(e,t){for(;t&&t!=e.dom;t=t.parentNode)if("TD"==t.nodeName||"TH"==t.nodeName)return t;return null}function Pa(e,t){const n=e.posAtCoords({left:t.clientX,top:t.clientY});return n&&n?_l(e.state.doc.resolve(n.pos)):null}var Va=class{constructor(e,t){this.node=e,this.defaultCellMinWidth=t,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.table.style.setProperty("--default-cell-min-width",`${t}px`),this.colgroup=this.table.appendChild(document.createElement("colgroup")),Fa(e,this.colgroup,this.table,t),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type==this.node.type&&(this.node=e,Fa(e,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(e){return"attributes"==e.type&&(e.target==this.table||this.colgroup.contains(e.target))}};function Fa(e,t,n,o,r,i){var s;let l=0,a=!0,c=t.firstChild;const d=e.firstChild;if(d){for(let e=0,n=0;e<d.childCount;e++){const{colspan:s,colwidth:h}=d.child(e).attrs;for(let e=0;e<s;e++,n++){const s=r==n?i:h&&h[e],d=s?s+"px":"";if(l+=s||o,s||(a=!1),c)c.style.width!=d&&(c.style.width=d),c=c.nextSibling;else{const e=document.createElement("col");e.style.width=d,t.appendChild(e)}}}for(;c;){const e=c.nextSibling;null==(s=c.parentNode)||s.removeChild(c),c=e}a?(n.style.width=l+"px",n.style.minWidth=""):(n.style.width="",n.style.minWidth=l+"px")}}var La=new xt("tableColumnResizing");var Ha=class e{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(t){const n=this,o=t.getMeta(La);if(o&&null!=o.setHandle)return new e(o.setHandle,!1);if(o&&void 0!==o.setDragging)return new e(n.activeHandle,o.setDragging);if(n.activeHandle>-1&&t.docChanged){let o=t.mapping.map(n.activeHandle,-1);return Jl(t.doc.resolve(o))||(o=-1),new e(o,n.dragging)}return n}};function _a(e,t,n,o){const r="right"==n?-o:o,i=e.posAtCoords({left:t.clientX+r,top:t.clientY});if(!i)return-1;const{pos:s}=i,l=_l(e.state.doc.resolve(s));if(!l)return-1;if("right"==n)return l.pos;const a=zl.get(l.node(-1)),c=l.start(-1),d=a.map.indexOf(l.pos-c);return d%a.width==0?-1:c+a.map[d-1]}function Wa(e,t,n){const o=t.clientX-e.startX;return Math.max(n,e.startWidth+o)}function qa(e,t){e.dispatch(e.state.tr.setMeta(La,{setHandle:t}))}function Ja(e,t,n,o){const r=e.state.doc.resolve(t),i=r.node(-1),s=r.start(-1),l=zl.get(i).colCount(r.pos-s)+r.nodeAfter.attrs.colspan-1;let a=e.domAtPos(r.start(-1)).node;for(;a&&"TABLE"!=a.nodeName;)a=a.parentNode;a&&Fa(i,a.firstChild,a,o,l,n)}function ja(e){return Array(e).fill(0)}const Ka=["blockquote",0],Xa=["hr"],Ua=["pre",["code",0]],Ga=["ol",0],Ya=["ul",0],Qa=["li",0],Za=e=>{const t={},n=e.attributes;let o;for(let e=0;e<n.length;e++)o=n[e],t[o.name]=o.value;return t},ec=e=>{const t={};return e.forEach((e=>{t[e]={default:null}})),t},tc=()=>ec(["style","class","id"]),nc=(e,t)=>{for(const n in e)if(n&&null!==e[n]&&n!==t)return!0;return!1},oc=(e,t=[])=>{const n={};for(const o in e)o&&null!==e[o]&&!t.find((e=>e===o))&&(n[o]=e[o]);return n},rc=e=>({[e]:{name:e,inclusive:!0,parseDOM:[{tag:e}],toDOM:()=>[e,0]}}),ic={link:{attrs:{...tc(),href:{default:null},target:{default:null},title:{default:null}},inclusive:!1,parseDOM:[{tag:"a",getAttrs:Za}],toDOM:e=>["a",oc(e.attrs),0]},...rc("strong"),...rc("b"),...rc("em"),...rc("i"),...rc("del"),...rc("sub"),...rc("sup"),...rc("code"),style:{attrs:{...tc()},parseDOM:[{tag:"span",getAttrs:Za}],toDOM:e=>nc(e.attrs)?["span",oc(e.attrs),0]:["span",0]},...rc("u")},sc=e=>({[e]:{default:null,getFromDOM:t=>t.getAttribute(e),setDOMAttr:(t,n)=>{n[e]=t}}}),lc={...sc("style"),...sc("class"),...sc("id"),...sc("headers"),...sc("scope")},ac=new K({nodes:{doc:{content:"colgroup*"},col:{attrs:ec(["id","class","style","span"]),parseDOM:[{getAttrs:Za,tag:"col"}],toDOM:e=>["col",e.attrs]},colgroup:{attrs:ec(["id","class","style","span"]),content:"col*",parseDOM:[{getAttrs:Za,tag:"colgroup"}],toDOM:e=>["colgroup",e.attrs,0]},text:{inline:!0,group:"inline"}},marks:{}}),cc=e=>{const t=wn(mn(e),ac,{preserveWhitespace:!1});return yn(t).firstChild},dc=Fl({tableGroup:"block",cellContent:"block+",cellAttributes:lc});dc.table_row.attrs={...dc.table_row.attrs,...ec([St,"style","class","id"])},dc.table_row.toDOM=e=>["tr",oc(e.attrs),0],dc.table_row.parseDOM=[{tag:"tr",getAttrs:Za}],dc.table.attrs={...dc.table.attrs,...ec(["style","class","id",Ct,Mt])},dc.table.toDOM=e=>{const t=nc(e.attrs)?oc(e.attrs,[Ct,Mt]):{};let n=null;if(e.attrs[Ct]&&!(e=>{let t=!1;const n=e.child(0);for(let e=0;e<n.childCount;e++)if(n.child(e).attrs.colwidth){t=!0;break}return t})(e)){const t=cc(e.attrs[Ct]);if(t){const e=Array.from(t.children).map((e=>["col",Za(e)]));n=["colgroup",Za(t)].concat(e)}}return n?["table",t,n,["tbody",0]]:["table",t,["tbody",0]]},dc.table.parseDOM=[{tag:"table",getAttrs:e=>{const t=Za(e),n=Array.from(e.childNodes).find((e=>"COLGROUP"===e.nodeName));return n&&(t[Ct]=n.outerHTML),t}}];const hc={doc:{content:"block+"},paragraph:{content:"inline*",group:"block",attrs:{...tc()},parseDOM:[{tag:"p",getAttrs:Za}],toDOM:e=>nc(e.attrs)?["p",oc(e.attrs),0]:["p",0]},table_wrapper:{content:"(table_caption_external | table)+",group:"block",defining:!0,attrs:{table:{default:null},style:{default:null}},parseDOM:[{tag:"div[table]",getAttrs:Za}],toDOM:e=>nc(e.attrs)?["div",oc(e.attrs),0]:["div",0]},table_caption_external:{content:"inline+",group:"block",attrs:{caption:{default:null},...tc()},parseDOM:[{tag:"div[caption]",getAttrs:Za}],toDOM:e=>nc(e.attrs)?["div",oc(e.attrs),0]:["div",0]},div:{content:"block*",group:"block",attrs:{...tc()},parseDOM:[{tag:"div",getAttrs:Za}],toDOM:e=>nc(e.attrs)?["div",oc(e.attrs),0]:["div",0]},blockquote:{attrs:{...tc()},content:"block+",group:"block",defining:!0,parseDOM:[{tag:"blockquote",getAttrs:Za}],toDOM:e=>nc(e.attrs)?["blockquote",oc(e.attrs),0]:Ka},horizontal_rule:{group:"block",parseDOM:[{tag:"hr"}],toDOM:()=>Xa},heading:{attrs:{...tc(),level:{default:1}},content:"inline*",group:"block",defining:!0,parseDOM:[{tag:"h1",getAttrs:e=>({...Za(e),level:1})},{tag:"h2",getAttrs:e=>({...Za(e),level:2})},{tag:"h3",getAttrs:e=>({...Za(e),level:3})},{tag:"h4",getAttrs:e=>({...Za(e),level:4})},{tag:"h5",getAttrs:e=>({...Za(e),level:5})},{tag:"h6",getAttrs:e=>({...Za(e),level:6})}],toDOM:e=>nc(e.attrs,"level")?["h"+e.attrs.level,oc(e.attrs,["level"]),0]:["h"+e.attrs.level,0]},code_block:{content:"text*",marks:"",group:"block",code:!0,defining:!0,parseDOM:[{tag:"pre",preserveWhitespace:"full"}],toDOM:()=>Ua},text:{inline:!0,group:"inline"},image:{inline:!0,attrs:{src:{default:null},alt:{default:null},title:{default:null},width:{default:null},height:{default:null},...tc()},group:"inline",draggable:!0,parseDOM:[{tag:"img",getAttrs:Za}],toDOM:e=>nc(e.attrs)?["img",oc(e.attrs)]:["img"]},hard_break:{inline:!0,attrs:{...tc()},group:"inline",selectable:!1,parseDOM:[{tag:"br",getAttrs:Za}],toDOM:e=>nc(e.attrs)?["br",oc(e.attrs)]:["br"]},ordered_list:{content:"list_item+",group:"block",attrs:{...tc(),type:{default:null},order:{default:1}},parseDOM:[{tag:"ol",getAttrs:e=>({...Za(e),order:e.hasAttribute("start")?parseInt(e.getAttribute("start")||"1",10):1})}],toDOM:e=>1===e.attrs.order?nc(e.attrs,"order")?["ol",oc(e.attrs,["order"]),0]:Ga:["ol",{...oc(e.attrs,["order"]),start:e.attrs.order},0]},bullet_list:{content:"list_item+",group:"block",attrs:{...tc()},parseDOM:[{tag:"ul",getAttrs:Za}],toDOM:e=>nc(e.attrs)?["ul",oc(e.attrs),0]:Ya},list_item:{content:"(paragraph | heading) block*",attrs:{...tc()},parseDOM:[{tag:"li",getAttrs:Za}],toDOM:e=>nc(e.attrs)?["li",oc(e.attrs),0]:Qa,defining:!0},...dc};var pc=200,uc=function(){};uc.prototype.append=function(e){return e.length?(e=uc.from(e),!this.length&&e||e.length<pc&&this.leafAppend(e)||this.length<pc&&e.leafPrepend(this)||this.appendInner(e)):this},uc.prototype.prepend=function(e){return e.length?uc.from(e).append(this):this},uc.prototype.appendInner=function(e){return new mc(this,e)},uc.prototype.slice=function(e,t){return void 0===e&&(e=0),void 0===t&&(t=this.length),e>=t?uc.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},uc.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},uc.prototype.forEach=function(e,t,n){void 0===t&&(t=0),void 0===n&&(n=this.length),t<=n?this.forEachInner(e,t,n,0):this.forEachInvertedInner(e,t,n,0)},uc.prototype.map=function(e,t,n){void 0===t&&(t=0),void 0===n&&(n=this.length);var o=[];return this.forEach((function(t,n){return o.push(e(t,n))}),t,n),o},uc.from=function(e){return e instanceof uc?e:e&&e.length?new fc(e):uc.empty};var fc=function(e){function t(t){e.call(this),this.values=t}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var n={length:{configurable:!0},depth:{configurable:!0}};return t.prototype.flatten=function(){return this.values},t.prototype.sliceInner=function(e,n){return 0==e&&n==this.length?this:new t(this.values.slice(e,n))},t.prototype.getInner=function(e){return this.values[e]},t.prototype.forEachInner=function(e,t,n,o){for(var r=t;r<n;r++)if(!1===e(this.values[r],o+r))return!1},t.prototype.forEachInvertedInner=function(e,t,n,o){for(var r=t-1;r>=n;r--)if(!1===e(this.values[r],o+r))return!1},t.prototype.leafAppend=function(e){if(this.length+e.length<=pc)return new t(this.values.concat(e.flatten()))},t.prototype.leafPrepend=function(e){if(this.length+e.length<=pc)return new t(e.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(t.prototype,n),t}(uc);uc.empty=new fc([]);var mc=function(e){function t(t,n){e.call(this),this.left=t,this.right=n,this.length=t.length+n.length,this.depth=Math.max(t.depth,n.depth)+1}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},t.prototype.getInner=function(e){return e<this.left.length?this.left.get(e):this.right.get(e-this.left.length)},t.prototype.forEachInner=function(e,t,n,o){var r=this.left.length;return!(t<r&&!1===this.left.forEachInner(e,t,Math.min(n,r),o))&&(!(n>r&&!1===this.right.forEachInner(e,Math.max(t-r,0),Math.min(this.length,n)-r,o+r))&&void 0)},t.prototype.forEachInvertedInner=function(e,t,n,o){var r=this.left.length;return!(t>r&&!1===this.right.forEachInvertedInner(e,t-r,Math.max(n,r)-r,o+r))&&(!(n<r&&!1===this.left.forEachInvertedInner(e,Math.min(t,r),n,o))&&void 0)},t.prototype.sliceInner=function(e,t){if(0==e&&t==this.length)return this;var n=this.left.length;return t<=n?this.left.slice(e,t):e>=n?this.right.slice(e-n,t-n):this.left.slice(e,n).append(this.right.slice(0,t-n))},t.prototype.leafAppend=function(e){var n=this.right.leafAppend(e);if(n)return new t(this.left,n)},t.prototype.leafPrepend=function(e){var n=this.left.leafPrepend(e);if(n)return new t(n,this.right)},t.prototype.appendInner=function(e){return this.left.depth>=Math.max(this.right.depth,e.depth)+1?new t(this.left,new t(this.right,e)):new t(this,e)},t}(uc);class gc{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(0==this.eventCount)return null;let n,o,r=this.items.length;for(;;r--){if(this.items.get(r-1).selection){--r;break}}t&&(n=this.remapping(r,this.items.length),o=n.maps.length);let i,s,l=e.tr,a=[],c=[];return this.items.forEach(((e,t)=>{if(!e.step)return n||(n=this.remapping(r,t+1),o=n.maps.length),o--,void c.push(e);if(n){c.push(new yc(e.map));let t,r=e.step.map(n.slice(o));r&&l.maybeStep(r).doc&&(t=l.mapping.maps[l.mapping.maps.length-1],a.push(new yc(t,void 0,void 0,a.length+c.length))),o--,t&&n.appendMap(t,o)}else l.maybeStep(e.step);return e.selection?(i=n?e.selection.map(n.slice(o)):e.selection,s=new gc(this.items.slice(0,r).append(c.reverse().concat(a)),this.eventCount-1),!1):void 0}),this.items.length,0),{remaining:s,transform:l,selection:i}}addTransform(e,t,n,o){let r=[],i=this.eventCount,s=this.items,l=!o&&s.length?s.get(s.length-1):null;for(let n=0;n<e.steps.length;n++){let a,c=e.steps[n].invert(e.docs[n]),d=new yc(e.mapping.maps[n],c,t);(a=l&&l.merge(d))&&(d=a,n?r.pop():s=s.slice(0,s.length-1)),r.push(d),t&&(i++,t=void 0),o||(l=d)}let a=i-n.depth;return a>vc&&(s=function(e,t){let n;return e.forEach(((e,o)=>{if(e.selection&&0==t--)return n=o,!1})),e.slice(n)}(s,a),i-=a),new gc(s.append(r),i)}remapping(e,t){let n=new me;return this.items.forEach(((t,o)=>{let r=null!=t.mirrorOffset&&o-t.mirrorOffset>=e?n.maps.length-t.mirrorOffset:void 0;n.appendMap(t.map,r)}),e,t),n}addMaps(e){return 0==this.eventCount?this:new gc(this.items.append(e.map((e=>new yc(e)))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let n=[],o=Math.max(0,this.items.length-t),r=e.mapping,i=e.steps.length,s=this.eventCount;this.items.forEach((e=>{e.selection&&s--}),o);let l=t;this.items.forEach((t=>{let o=r.getMirror(--l);if(null==o)return;i=Math.min(i,o);let a=r.maps[o];if(t.step){let i=e.steps[o].invert(e.docs[o]),c=t.selection&&t.selection.map(r.slice(l+1,o));c&&s++,n.push(new yc(a,i,c))}else n.push(new yc(a))}),o);let a=[];for(let e=t;e<i;e++)a.push(new yc(r.maps[e]));let c=this.items.slice(0,o).append(a).append(n),d=new gc(c,s);return d.emptyItemCount()>500&&(d=d.compress(this.items.length-n.length)),d}emptyItemCount(){let e=0;return this.items.forEach((t=>{t.step||e++})),e}compress(e=this.items.length){let t=this.remapping(0,e),n=t.maps.length,o=[],r=0;return this.items.forEach(((i,s)=>{if(s>=e)o.push(i),i.selection&&r++;else if(i.step){let e=i.step.map(t.slice(n)),s=e&&e.getMap();if(n--,s&&t.appendMap(s,n),e){let l=i.selection&&i.selection.map(t.slice(n));l&&r++;let a,c=new yc(s.invert(),e,l),d=o.length-1;(a=o.length&&o[d].merge(c))?o[d]=a:o.push(c)}}else i.map&&n--}),this.items.length,0),new gc(uc.from(o.reverse()),r)}}gc.empty=new gc(uc.empty,0);class yc{constructor(e,t,n,o){this.map=e,this.step=t,this.selection=n,this.mirrorOffset=o}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new yc(t.getMap().invert(),t,this.selection)}}}class wc{constructor(e,t,n,o,r){this.done=e,this.undone=t,this.prevRanges=n,this.prevTime=o,this.prevComposition=r}}const vc=20;function bc(e){let t=[];for(let n=e.length-1;n>=0&&0==t.length;n--)e[n].forEach(((e,n,o,r)=>t.push(o,r)));return t}function kc(e,t){if(!e)return null;let n=[];for(let o=0;o<e.length;o+=2){let r=t.map(e[o],1),i=t.map(e[o+1],-1);r<=i&&n.push(r,i)}return n}let xc=!1,Sc=null;function Cc(e){let t=e.plugins;if(Sc!=t){xc=!1,Sc=t;for(let e=0;e<t.length;e++)if(t[e].spec.historyPreserveItems){xc=!0;break}}return xc}const Mc=new xt("history"),Nc=new xt("closeHistory");function Oc(e,t){return(n,o)=>{let r=Mc.getState(n);if(!r||0==(e?r.undone:r.done).eventCount)return!1;if(o){let i=function(e,t,n){let o=Cc(t),r=Mc.get(t).spec.config,i=(n?e.undone:e.done).popEvent(t,o);if(!i)return null;let s=i.selection.resolve(i.transform.doc),l=(n?e.done:e.undone).addTransform(i.transform,t.selection.getBookmark(),r,o),a=new wc(n?l:i.remaining,n?i.remaining:l,null,0,-1);return i.transform.setSelection(s).setMeta(Mc,{redo:n,historyState:a})}(r,n,e);i&&o(t?i.scrollIntoView():i)}return!0}}const Ac=Oc(!1,!0),Tc=Oc(!0,!0),Dc=Oc(!1,!1),Ec=Oc(!0,!1);class Rc{constructor(e,t,n={}){var o;this.match=e,this.match=e,this.handler="string"==typeof t?(o=t,function(e,t,n,r){let i=o;if(t[1]){let e=t[0].lastIndexOf(t[1]);i+=t[0].slice(e+t[1].length);let o=(n+=e)-r;o>0&&(i=t[0].slice(e-o,e)+i,n=r)}return e.tr.insertText(i,n,r)}):t,this.undoable=!1!==n.undoable,this.inCode=n.inCode||!1}}function $c(e,t,n,o,r,i){if(e.composing)return!1;let s=e.state,l=s.doc.resolve(t),a=l.parent.textBetween(Math.max(0,l.parentOffset-500),l.parentOffset,null,"")+o;for(let c=0;c<r.length;c++){let d=r[c];if(l.parent.type.spec.code){if(!d.inCode)continue}else if("only"===d.inCode)continue;let h=d.match.exec(a),p=h&&d.handler(s,h,t-(h[0].length-o.length),n);if(p)return d.undoable&&p.setMeta(i,{transform:p,from:t,to:n,text:o}),e.dispatch(p),!0}return!1}const Ic=(e,t)=>{let n=e.plugins;for(let o=0;o<n.length;o++){let r,i=n[o];if(i.spec.isInputRules&&(r=i.getState(e))){if(t){let n=e.tr,o=r.transform;for(let e=o.steps.length-1;e>=0;e--)n.step(o.steps[e].invert(o.docs[e]));if(r.text){let t=n.doc.resolve(r.from).marks();n.replaceWith(r.from,r.to,e.schema.text(r.text,t))}else n.delete(r.from,r.to);t(n)}return!0}}return!1},zc=new Rc(/--$/,"—"),Bc=new Rc(/\.\.\.$/,"…"),Pc=new Rc(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,"“"),Vc=new Rc(/"$/,"”"),Fc=new Rc(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,"‘"),Lc=new Rc(/'$/,"’"),Hc=[Pc,Vc,Fc,Lc];const _c={mark:"strong",altMarks:["b"],altStyle:{name:"font-weight",value:/^(bold(er)?|[5-9]\d{2,})$/}},Wc={mark:"em",altMarks:["i"],altStyle:{name:"font-style",value:/^italic$/i}},qc={mark:"u",altStyle:{name:"text-decoration",value:/^underline$/i}},Jc="undefined"!=typeof navigator&&/Mac/.test(navigator.platform),jc=/style=['"]?[^'"]*?mso-list:\s*[a-zA-Z]+(\d+)\s[a-zA-Z]+(\d+)\s(\w+)/gi,Kc=e=>/^MsoListParagraph/.test(e.className),Xc=e=>e.textContent,Uc=(e,t)=>{const n=document.createElement(e);return n.style.listStyleType=t,n},Gc=e=>{let t=null;return/^\d/.test(e)||(t=(/^[a-z]/.test(e)?"lower-":"upper-")+(/^[ivxlcdm]/i.test(e)?"roman":"alpha")),t},Yc=(e,t)=>{let n=[];Array.from(e).forEach((e=>{if(e.nodeType!==Node.ELEMENT_NODE)return;const o=e;o.getAttribute("datalist")?(n.push(e),t.add(n)):Kc(o)&&n.length?n.push(e):(n=[],"DIV"===o.nodeName?Yc(o.children,t):"TABLE"===o.nodeName&&Array.from(o.querySelectorAll("td,th")).forEach((e=>{Yc(e.children,t)})))}))},Qc=e=>{const t=e.textContent,n=e=>e.replace(/^(?:&nbsp;|[\u00a0\n\r\s])+/,"");return/^[\u2022\u00b7\u00a7\u00d8oØüvn][\u00a0 ]+/.test(t)?{tag:"ul",style:(o=n(Xc(e)),/^[\u2022\u00b7\u00FC\u00D8\u002dv-]/.test(o)?null:/^o/.test(o)?"circle":"square")}:/^\s*\w+[\.\)][\u00a0 ]{2,}/.test(t)?{tag:"ol",style:Gc(n(Xc(e)))}:void 0;var o},Zc=e=>{let t,n=e.nodeName.toLowerCase();e.firstChild&&e.firstChild.nodeType===Node.COMMENT_NODE&&e.removeChild(e.firstChild),1===e.childNodes.length?t=e.firstChild.nodeType===Node.TEXT_NODE?Xc(e):e.firstChild.innerHTML.replace(/^\w+[\.\)](&nbsp;)+ /,""):(e.removeChild(e.firstChild),3===e.firstChild.nodeType&&/^[ivxlcdm]+\.$/i.test(e.firstChild.nodeValue)&&e.removeChild(e.firstChild),/^(&nbsp;|\s)+$/i.test(e.firstChild.innerHTML)&&e.removeChild(e.firstChild),t="p"!==n?"<"+n+">"+e.innerHTML+"</"+n+">":e.innerHTML),e.parentNode.removeChild(e);const o=document.createElement("li");return o.appendChild(mn(t)),o},ed=e=>{const t=mn((e=>e.replace(jc,((e,t,n)=>`datalist="${t}" datalevel="${n}" ${e}`)))(e)),n=new Set;return Yc(t.children,n),n.forEach((e=>(e=>{let t,n,o,r,i,s,l,a,c,d,h,p,u,f=-1,m={};for(a=0;a<e.length;a++){c=e[a],u={datalist:c.getAttribute("datalist"),datalevel:c.getAttribute("datalevel")};const g=u.datalist,y=Qc(c);if(d=y&&y.tag,!d){!t||i&&!Kc(c)||(c.style.marginLeft&&(c.style.marginLeft=""),c.style.marginLeft&&(c.style.margin=""),t.appendChild(c));continue}if(h=u.datalevel||parseFloat(c.style.marginLeft||0),!u.datalevel&&!c.style.marginLeft)continue;const w=d+g;m[h]||(m[h]={}),(!n||n<0)&&(n=h,o=g,l=e.filter((e=>e.getAttribute("datalist")===String(o))),r=l[l.length-1],s=Uc(d,y&&y.style),c.parentNode.insertBefore(s,c),f=h,m[h][w]=s),i=r===c,p=m[h][w],(h>f||!p)&&(p=Uc(d,y&&y.style),m[h][w]=p,t.appendChild(p)),t=Zc(c),p.appendChild(t),i?n=f=-1:f=h}})(e))),gn(t)},td=(e,t)=>e.replace(new RegExp("<\\/?("+t+")(?:\\s[^>]*?)?>","gi"),""),nd=e=>{e.ownerElement&&e.ownerElement.removeAttribute(e.name)};function od(e){const t=e.length,n=new Array(t/2);for(let o=0;o<t;o+=2)n[o]=String.fromCharCode(parseInt(e.substring(o,o+2),16));return btoa(n.join(""))}const rd=/<img\s[^>]*?src=(?:'|")file:\/[^'"]+(?:'|")[^>]*>/gi,id=/{\\pict[\s\S]+?\\bliptag-?\d+(\\blipupi-?\d+)?({\\\*\\blipuid\s?[\da-fA-F]+)?[\s}]*?/,sd=new RegExp("(?:("+id.source+"))([\\da-fA-F\\s]+)\\}","g"),ld=/[^\da-fA-F]/g,ad=/file:\/[^'"]+\.(jpg|png|gif)/i,cd=/\\(png|jpeg)blip\\/,dd="text/rtf",hd=(e,t,n,o,r)=>{let i,s,l,a,c,d,h=[];const p=[],{matchCase:u,matchWord:f,useRegExp:m}=t;let g=t.text;if(m&&(/^\\$/.test(g)||/[^\\]\\$/.test(g))&&(g=g.substring(0,g.length-1)),!g)return h;const y=u?"g":"gi",w=m?new RegExp(g,y):md(g,y);return e.nodesBetween(n,o,((t,u)=>{if(r(h))return!1;t.inlineContent&&u+t.content.size>=n&&(p.length=0,t.nodesBetween(0,t.content.size,((t,m,g,y)=>{if(r(h))return!1;const v=1+u+m;if(t.isText&&v+t.nodeSize>=n){if(c=t.text||"",d=g.childCount-1>=y+1&&g.child(y+1),p.push(n<=v?{text:c,start:v}:{text:c.slice(n-v),start:n}),d&&d.isText)return;for(s=p.map((e=>e.text)).join(""),i=w.exec(s);null!==i&&(l=p[0].start+i.index,a=l+i[0].length,n<=l&&o>=a&&fd(i,f)&&h.push(rt.create(e,l,a)),!r(h));)i=w.exec(s)}else p.length=0})))})),h},pd=(e,t)=>hd(e,t,0,e.content.size,(()=>!1)),ud=/^[\s0-9~`!@#$%\^&*\(\)_\-=+\\|\[\]{};:'"\?/.,<>]?$/,fd=(e,t)=>{if(t){if(!0===t){const t=e.input,n=t.charAt(e.index-1),o=t.charAt(e.index+e[0].length);return ud.test(n)&&ud.test(o)}return t(e)}return!0},md=(e,t)=>{const n=e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d").replace(/\s/g,"\\s");return new RegExp(n,t)};const gd=/\s+/g,yd=/text-align/,wd=(e,t)=>{for(const n in t)n&&nn(e,n,t[n])};class vd{constructor(e,t,n,o=!1){this.node=e,this.view=t,this.dom=document.createElement(n),wd(this.dom,e.attrs),this.contentDOM=o?void 0:this.dom}}class bd{constructor(e,t){this.mark=e,this.view=t,this.dom=document.createElement("span"),wd(this.dom,e.attrs),this.contentDOM=this.dom}}const kd=new xt("highlight");const xd={southeast:{x:1,y:1},east:{x:1,y:0},south:{x:0,y:1},north:{x:0,y:-1},west:{x:-1,y:0},southwest:{x:-1,y:1},northwest:{x:-1,y:-1},northeast:{x:1,y:-1}},Sd=Object.keys(xd),Cd=new xt("image-resize"),Md=(e,t,n)=>{e.style[t]=n+"px"},Nd=/[^\-]width:|[^\-]height:/,Od=/^.+$/;let Ad=class e{constructor(e,t,n,o){this.activeHandle=e,this.dragging=t,this.rect=n,this.nodePosition=o}apply(t){const n=t.getMeta(Cd);return n?new e(n.activeHandle,n.setDragging,n.rect,n.nodePosition):this}};const Td=(e,t,n)=>{const o=t.target.getAttribute(At);if(!o)return!1;const r=Cd.getState(e.state);t.preventDefault();const i=e.state.tr;function s(t){((e,t,n)=>{const o=Cd.getState(e.state),{rect:r,dragging:i,nodePosition:s,activeHandle:l}=o;if(!i||!r)return;const a=e.nodeDOM(s),c=xd[l],d=(t.clientX-i.startX)*c.x,h=(t.clientY-i.startY)*c.y;let p=c.x?d+a.width:r.width,u=c.y?h+a.height:r.height;if(n.lockRatio&&c.x&&c.y){const e=Math.min(p/a.width,u/a.height),n=a.width*e,o=a.height*e;i.startX=t.clientX-(p-n)*c.x,i.startY=t.clientY-(u-o)*c.y,p=n,u=o}else i.startX=c.x?t.clientX:i.startX,i.startY=c.y?t.clientY:i.startY;Md(a,"width",p),Md(a,"height",u),r.top=a.offsetTop,r.left=a.offsetLeft,r.width=a.offsetWidth,r.height=a.offsetHeight;const f=a.nextElementSibling;f.style.width=r.width+"px",f.style.height=r.height+"px",f.style.top=r.top+"px",f.style.left=r.left+"px"})(e,t,n)}return i.setMeta(Cd,{setDragging:{startX:t.clientX,startY:t.clientY},activeHandle:o,rect:r.rect,nodePosition:r.nodePosition}),i.setMeta("addToHistory",!1),e.dispatch(i),t.view.addEventListener("mouseup",(function t(n){n.view.removeEventListener("mouseup",t),n.view.removeEventListener("mousemove",s),(e=>{const{rect:t,dragging:n,nodePosition:o}=Cd.getState(e.state);if(n&&t){const n=e.state.selection;if(n instanceof st){const r=n.node.attrs,i=t.width,s=t.height;let l;if(Nd.test(r.style||"")){const e=Ht(r.style,{style:"width",value:Od,newValue:i+"px"}),{style:t}=Ht(e.style||"",{style:"height",value:Od,newValue:s+"px"});l={...r,style:t}}else l={...r,width:i,height:s};const a=n.node.type.createAndFill(l);if(a){const n=e.state.tr;n.replaceWith(o,o+1,a),n.setSelection(st.create(n.doc,o)),n.setMeta("commandName","image-resize"),n.setMeta("args",l),n.setMeta(Cd,{setDragging:null,activeHandle:null,rect:t,nodePosition:o}),e.dispatch(n)}}}})(e)})),t.view.addEventListener("mousemove",s),!0},Dd=new xt("caret-color");class Ed{constructor(e,t){this.node=e,this.view=t,this.dom=document.createElement("div"),this.dom.className="k-editor-resize-wrap-element",this.table=this.dom.appendChild(document.createElement("table")),e.attrs[Ct]&&this.renderColgroup(e.attrs[Ct]);const n=this.table.appendChild(document.createElement("tbody"));this.setAttributes(this.table,e.attrs),this.resizeHandles=Sd.map((e=>{const t=document.createElement("span");return t.className=Nt+" "+e,t.setAttribute(Ot,e),t})),this.contentDOM=n}update(e){if(e.type!==this.node.type)return!1;const t=this.node;return this.node=e,e.attrs[Mt]?this.resizeHandles.forEach((e=>{this.dom.appendChild(e)})):Array.from(this.dom.children).filter((e=>e.classList.contains(Nt))).forEach((e=>e.remove())),this.setAttributes(this.table,e.attrs),t.attrs[Ct]!==e.attrs[Ct]&&this.renderColgroup(e.attrs[Ct]),!0}ignoreMutation(e){return"attributes"===e.type&&(e.target===this.table||e.target.firstChild===this.table||this.colgroup&&this.colgroup.contains(e.target))}destroy(){this.node=void 0,this.view=void 0,this.table=void 0,this.colgroup=void 0,this.resizeHandles=void 0}renderColgroup(e){this.table&&this.table.firstChild&&"COLGROUP"===this.table.firstChild.nodeName&&this.table.removeChild(this.table.firstChild),e&&(this.colgroup=cc(e),this.table.insertBefore(this.colgroup,this.table.firstChild))}setAttributes(e,t){const n=[Ct,Mt];for(const o in t)o&&-1===n.indexOf(o)&&nn(e,o,t[o]);/%$/.test(e.style.width)?(this.dom.style.width=e.style.width,e.style.width=""):this.dom.style.width=""}}class Rd{constructor(e,t){this.node=e,this.view=t,this.dom=document.createElement("div"),this.setAttributes(this.dom,e.attrs),this.contentDOM=this.dom}update(e){return e.type===this.node.type&&(this.node=e,this.setAttributes(this.dom,e.attrs),!0)}ignoreMutation(e){return"attributes"===e.type&&"style"===e.attributeName}destroy(){this.node=void 0,this.view=void 0}setAttributes(e,t){for(const n in t)n&&nn(e,n,t[n]);if(e.setAttribute("table",""),/%/.test(e.style.width)){const t=this.node&&this.node.lastChild,n=(t?Zt(t.attrs.style):{}).width||"";n&&!/%/.test(n)&&(e.style.width="")}}}const $d=new xt("table-resize"),Id=new xt("table-column-resizing"),zd=new xt("table-row-resizing");function Bd(e,t){let n=!1;return n=n||e!==$d&&Boolean($d.get(t))&&$d.getState(t).dragging,n=n||e!==Id&&Boolean(Id.get(t))&&Id.getState(t).dragging,n=n||e!==zd&&Boolean(zd.get(t))&&zd.getState(t).dragging,n}function Pd(e,t){let n=!1;return n=n||e!==Id&&Boolean(Id.get(t))&&Id.getState(t).activeHandle>-1,n=n||e!==zd&&Boolean(zd.get(t))&&zd.getState(t).activeHandle>-1,n}function Vd(e){return e&&e.firstChild&&"TABLE"===e.firstChild.nodeName?e.firstChild:e}function Fd(e){for(;e&&"TD"!==e.nodeName&&"TH"!==e.nodeName;)e=e.classList.contains("ProseMirror")?null:e.parentNode;return e}function Ld(e){const t=function(e){const t=Array.from(e&&e.rows||[]),n=Array.from(t&&t[0]&&t[0].cells||[]).map((e=>e.colSpan)).reduce(((e,t)=>e+t),0),o=t.map((()=>new Array(n)));return t.forEach(((e,t)=>{let n=0;Array.from(e.cells).forEach((e=>{for(let r=0;r<e.colSpan;r++){for(let r=0;r<e.rowSpan;r++){const i=o[t+r].findIndex(((e,t)=>t>=n&&!e));o[t+r][i]=e}n++}}))})),o}(e.closest("table"));let n=null;for(let o=0;o<t.length;o++){if(t[o].forEach(((t,r)=>{e===t&&(n={rowIndex:o,cellIndex:r})})),n)break}return n||{rowIndex:-1,cellIndex:-1}}function Hd(e,t,n){const o=e.posAtCoords({left:t.clientX,top:t.clientY});if(!o)return-1;const r=e.state.doc.resolve(o.pos),i=jt(r,(e=>"table"===e.type.spec.tableRole));if(null===i)return-1;const s=r.start(i.depth),l=i.node,a=zl.get(l);return s+a.map[a.width*n.rowIndex+n.cellIndex]}function _d(){const e=new vt({key:Id,state:{init:()=>new Wd(-1,null),apply:(e,t)=>t.apply(e)},props:{attributes(e){if(Pd(Id,e))return null;return Id.getState(e).activeHandle>-1?{class:"resize-cursor"}:null},handleDOMEvents:{mousemove:(e,t)=>(Bd(Id,e.state)||function(e,t,n){const o=Id.getState(e.state);if(!o.dragging){const r=Fd(t.target);let i=-1;if(r){const o=Ld(r),{left:s,right:l}=r.getBoundingClientRect();Math.abs(t.clientX-s)<=n&&o.cellIndex>0?(o.cellIndex-=r.colSpan,i=Hd(e,t,o)):l-t.clientX>0&&l-t.clientX<=n&&(i=Hd(e,t,o))}i!==o.activeHandle&&qd(e,i)}}(e,t,5),!1),mouseleave:e=>(function(e){const t=Id.getState(e.state);t.activeHandle>-1&&!t.dragging&&qd(e,-1)}(e),!1),mousedown:(e,t)=>function(e,t,n){const o=Id.getState(e.state);if(-1===o.activeHandle||o.dragging)return!1;const r=e.state.doc.resolve(o.activeHandle),i=r.parent,s=r.index();let l=0;for(let e=0;e<=s;e++)l+=i.child(e).attrs.colspan;const a=r.node(r.depth-1),c=e.domAtPos(o.activeHandle),d=c.node.childNodes[c.offset].closest("table");let h,p;if(a.attrs[Ct]){h=d.firstChild.children[l-1],h.style.width||(h.style.width=h.offsetWidth+"px")}else{let e=0;for(let t=0;t<i.childCount;t++)e+=i.child(t).attrs.colspan;const t=document.createElement("colgroup"),n=new Array(e);for(let o=0;o<e;o++)n[o]=document.createElement("col"),t.appendChild(n[o]);d.insertBefore(t,d.firstChild),h=n[s],h.style.width=h.offsetWidth+"px",p={...a.attrs,[Ct]:"<colgroup>"+n.reduce(((e,t)=>e+t.outerHTML),"")+"</colgroup>"}}const u=parseFloat(h.style.width),f=e.state.tr.setMeta(Id,{setDragging:{startX:t.clientX,startWidth:u}});if(!d.style.width){const e=Array.from(h.parentNode.children).map((e=>e.style.width));if(e.every(Boolean)){const t=e.reduce(((e,t)=>e+parseFloat(t)),0);p=Wt(p||a.attrs,"width",t+"px")}}if(p){const e=r.posAtIndex(0,r.depth-1)-1;f.setNodeMarkup(e,null,p)}function m(t){t.view.removeEventListener("mouseup",m),t.view.removeEventListener("mousemove",g);const n=Id.getState(e.state);if(n.dragging){const t=e.state.tr;!function(e,t,n){const o=e.state.doc.resolve(n),r=o.node(-1),i=o.start(-1),s=o.posAtIndex(0,o.depth-1)-1,l=e.nodeDOM(i).closest("table");let a=r.attrs;if(r&&a[Ct]){const e=l.firstChild;a={...a,[Ct]:e.outerHTML}}const c=l.style.width;l&&c&&Zt(a.style).width!==c&&(a=Wt(a,"width",c));t.setNodeMarkup(s,null,a)}(e,t,n.activeHandle),e.dispatch(t.setMeta(Id,{setDragging:null}))}}function g(t){if(!t.which)return m(t);const o=Id.getState(e.state),r=function(e,t,n){const o=t.clientX-e.startX;return Math.max(n,e.startWidth+o)}(o.dragging,t,n);!function(e,t,n){const o=e.state.doc.resolve(t),r=o.node(-1),i=o.start(-1),s=zl.get(r).colCount(o.pos-i)+o.nodeAfter.attrs.colspan-1;let l=e.domAtPos(o.start(-1)).node;"TABLE"!==l.nodeName&&(l=l.closest("table"));const a=l,c=a.firstChild,d=Array.from(c.children);if(d[s].style.width=n+"px",a.style.width){const e=d.map((e=>e.style.width));if(e.every(Boolean)){const t=e.reduce(((e,t)=>e+parseFloat(t)),0);a.style.width=t+"px"}}}(e,o.activeHandle,r)}return e.dispatch(f),t.view.addEventListener("mouseup",m),t.view.addEventListener("mousemove",g),t.preventDefault(),!0}(e,t,25)},decorations(e){if(!Bd(Id,e)){const t=Id.getState(e);if(t.activeHandle>-1)return function(e,t){const n=[],o=e.doc.resolve(t),r=o.node(-1),i=zl.get(r),s=o.start(-1),l=[],a=t-s;let c=-1;for(let e=0;e<i.height;e++)l.push(i.map.slice(e*i.width,e*i.width+i.width)),-1===c&&(c=l[e].lastIndexOf(a));const d=[];return l.forEach((e=>{const t=e[c];e[c]!==e[c+1]&&d.push(t)})),d.forEach((e=>{const t=s+e+r.nodeAt(e).nodeSize-1,o=document.createElement("div");o.className="column-resize-handle",n.push(Hs.widget(t,o))})),qs.create(e.doc,n)}(e,t.activeHandle)}return qs.empty},nodeViews:{table_wrapper:(e,t)=>new Rd(e,t),table:(e,t)=>new Ed(e,t)}}});return e}let Wd=class e{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(t){let n;const o=t.getMeta(Id);if(o&&null!=o.setHandle)return new e(o.setHandle,null);if(o&&void 0!==o.setDragging)return new e(this.activeHandle,o.setDragging);if(this.activeHandle>-1&&t.docChanged){let o=t.mapping.map(this.activeHandle,-1);r=t.doc.resolve(o),Boolean("row"===r.parent.type.spec.tableRole&&r.nodeAfter)||(o=-1),n=new e(o,this.dragging)}var r;return n||this}};function qd(e,t){const n=e.state.tr;n.setMeta("addToHistory",!1),n.setMeta(Id,{setHandle:t}),e.dispatch(n)}const Jd={southeast:!0,southwest:!0,northwest:!0,northeast:!0},jd={east:!0,west:!0,...Jd},Kd={south:!0,north:!0,...Jd};let Xd=class e{constructor(e,t,n){this.activeHandle=e,this.dragging=t,this.nodePosition=n}apply(t){const n=t.getMeta($d);if(n){return new e(n.activeHandle,n.setDragging,n.nodePosition)}return this}};const Ud=e=>{const t=Array.from(e.firstChild.children).map((e=>e.offsetWidth)),n=Array.from(e.rows).map((e=>e.offsetHeight)),o=t.reduce(((e,t)=>e+t),0),r=n.reduce(((e,t)=>e+t),0),i=e.offsetHeight;return{width:o,height:r,colsWidth:t,rowsHeight:n,offsetWidth:e.offsetWidth,offsetHeight:i}},Gd=e=>{const{dragging:t,nodePosition:n,activeHandle:o}=$d.getState(e.state);if(t){const t=e.state.doc.nodeAt(n),r=Vd(e.nodeDOM(n)),i=Ud(r);if(t){const s=i.offsetWidth+"px",l=i.offsetHeight+"px",a=e.state.tr;let c=t.attrs;const d=Zt(c.style);if(jd[o]&&r.style.width&&d.width!==s&&(c=Wt(c,"width",s)),Kd[o]&&r.style.height&&d.height!==l&&(c=Wt(c,"height",l)),c=((e,t,n,o)=>{const r=e.state.doc.nodeAt(n),i=Vd(e.nodeDOM(n)),s=(i.ownerDocument&&i.ownerDocument.defaultView||window).getComputedStyle,l=Array.from(i.rows);r.forEach(((e,o,r)=>{const i=Zt(e.attrs.style).height;i&&!/px$/.test(i)&&t.setNodeMarkup(n+o+1,null,Wt(e.attrs,"height",s(l[r]).height))}));const a=i.firstChild,c=Array.from(a&&a.children||[]);let d=!1;c.forEach(((e,t)=>{e.style.width&&!/px$/.test(e.style.width)&&(e.style.width=s(c[t]).width,d=!0)}));const h={...o};return d&&(h[Ct]=a.outerHTML),h})(e,a,n,c),a.setNodeMarkup(n,null,c),a.setMeta("commandName","node-resize"),a.setMeta("args",c),a.setMeta($d,{setDragging:null,activeHandle:null,nodePosition:n}),!/%/.test(Zt(c.style).width||"")){const e=a.doc.resolve(n),t=jt(e,(e=>"table_wrapper"===e.type.name));if(t&&/%/.test(Zt(t.node.attrs.style).width||"")){const n=Wt(t.node.attrs,"width",""),o=e.start(t.depth)-1;a.setNodeMarkup(o,null,n)}}e.dispatch(a)}}},Yd=(e,t)=>{const n=t.target.getAttribute(Ot);if(!n)return!1;const o=$d.getState(e.state);t.preventDefault();const r=e.state.tr;r.setMeta($d,{setDragging:{startX:t.clientX,startY:t.clientY},activeHandle:n,nodePosition:o.nodePosition}),r.setMeta("addToHistory",!1),((e,t,n)=>{const o=e.state.doc.nodeAt(n),r=Vd(e.nodeDOM(n)),{width:i,height:s,colsWidth:l,rowsHeight:a,offsetWidth:c,offsetHeight:d}=Ud(r),h=r.firstChild,p=Array.from(h&&h.children||[]);let u=!1;p.forEach(((e,t)=>{e.style.width&&!/%$/.test(e.style.width)&&(e.style.width=100*l[t]/i+"%",u=!0)}));let f=!1;o.forEach(((e,o,r)=>{const i=Zt(e.attrs.style).height;i&&!/%$/.test(i)&&(t.setNodeMarkup(n+o+1,null,Wt(e.attrs,"height",100*a[r]/s+"%")),f=!0)}));let m=o.attrs;Zt(m.style).width!==c+"px"&&(m=Wt(m,"width",c+"px")),u&&(m[Ct]=h.outerHTML),f&&(m=Wt(m,"height",d+"px")),(u||f)&&t.setNodeMarkup(n,null,m)})(e,r,o.nodePosition),e.dispatch(r);const i=t.view||window;function s(t){((e,t)=>{var n;const o=$d.getState(e.state),{dragging:r,nodePosition:i,activeHandle:s}=o;if(i<0||!r)return;const l=Vd(e.nodeDOM(i)),a=l.getBoundingClientRect(),c=xd[s],d=(t.clientX-r.startX)*c.x,h=(t.clientY-r.startY)*c.y,p=(l.ownerDocument&&l.ownerDocument.defaultView||window).getComputedStyle(l),u=/px/.test(p.width)?parseFloat(p.width):l.offsetWidth,f=/px/.test(p.height)?parseFloat(p.height):l.offsetHeight,m=c.x?d+u:a.width,g=c.y?h+f:a.height;if(r.startX=c.x?t.clientX:r.startX,r.startY=c.y?t.clientY:r.startY,jd[s]&&(l.style.width=m+"px"),Kd[s]&&(l.style.height=g+"px"),/px/.test(l.style.width)){const e=null===(n=l.parentNode)||void 0===n?void 0:n.parentNode;e instanceof HTMLDivElement&&e.matches("div[table]")&&/%/.test(e.style.width)&&(e.style.width="")}})(e,t)}return i.addEventListener("mouseup",(function t(){i.removeEventListener("mouseup",t),i.removeEventListener("mousemove",s),Gd(e)})),i.addEventListener("mousemove",s),!0},Qd=(e={node:"table"})=>new vt({key:$d,view:()=>({selectedNode(e,t){const n=e.selection;if(n instanceof st&&t===n.node.type&&n instanceof st)return{node:n.node,pos:n.from};const o=jt(n.$from,(e=>e.type===t)),r=o&&o.node;if(r){return{node:r,pos:n.$from.start(o.depth)-1}}return null},update(t,n){const o=t.state,r=o.schema.nodes[e.node],i=this.selectedNode(o,r),s=this.selectedNode(n,r);if((i||!s||n.doc.eq(t.state.doc))&&(i||s)){const e=o.tr;if(e.setMeta("addToHistory",!1),i&&s&&i.pos!==s.pos){e.setMeta($d,{nodePosition:i.pos});const n=e.doc.nodeAt(s.pos);n&&n.type.name===r.name&&e.setNodeMarkup(s.pos,r,{...s.node.attrs,[Mt]:!1}),e.setNodeMarkup(i.pos,r,{...i.node.attrs,[Mt]:!0}),t.dispatch(e)}else i&&s&&i.pos===s.pos&&!i.node.attrs[Mt]&&!o.selection.eq(n.selection)?(e.setMeta($d,{nodePosition:i.pos}),t.dispatch(e.setNodeMarkup(i.pos,r,{...i.node.attrs,[Mt]:!0}))):i&&!s?(e.setMeta($d,{nodePosition:i.pos}),t.dispatch(e.setNodeMarkup(i.pos,r,{...i.node.attrs,[Mt]:!0}))):!i&&s&&(e.setMeta($d,{nodePosition:-1}),t.dispatch(e.setNodeMarkup(s.pos,r,{...s.node.attrs,[Mt]:!1})))}}}),state:{init:()=>new Xd("",null,-1),apply:(e,t)=>t.apply(e)},props:{handleDOMEvents:{mousedown:(e,t)=>Yd(e,t)}}});class Zd{ignoreMutation(e){return"attributes"===e.type&&"style"===e.attributeName&&"TR"===e.target.nodeName}}function eh(){const e=new vt({key:zd,state:{init(e,t){return this.spec.props.nodeViews[Ll(t.schema).row.name]=()=>new Zd,new th(-1,null)},apply:(e,t)=>t.apply(e)},props:{attributes(e){if(Pd(zd,e))return null;return zd.getState(e).activeHandle>-1?{class:"resize-cursor-vertical"}:null},handleDOMEvents:{mousemove:(e,t)=>(Bd(zd,e.state)||function(e,t,n){const o=zd.getState(e.state);if(!o.dragging){let r=Fd(t.target),i=-1;if(r){const o=Ld(r),{top:s,bottom:l}=r.getBoundingClientRect();Math.abs(t.clientY-s)<=n&&o.rowIndex>0?(o.rowIndex-=r.rowSpan,i=Hd(e,t,o)):l-t.clientY>0&&l-t.clientY<=n&&(i=Hd(e,t,o))}i!==o.activeHandle&&nh(e,i)}}(e,t,5),!1),mouseleave:e=>(function(e){const t=zd.getState(e.state);t.activeHandle>-1&&!t.dragging&&nh(e,-1)}(e),!1),mousedown:(e,t)=>function(e,t){const n=zd.getState(e.state);if(-1===n.activeHandle||n.dragging)return!1;const o=e.state.doc,r=o.resolve(n.activeHandle),i=r.parent,s=r.node(-1),l=Zt(i.attrs.style).height,a=Zt(s.attrs.style).height;let c=l?parseFloat(l):0;if(!l){c=e.nodeDOM(n.activeHandle).offsetHeight}function d(t){t.view.removeEventListener("mouseup",d),t.view.removeEventListener("mousemove",h);const n=zd.getState(e.state);if(n.dragging){const t=e.state.tr.setMeta(zd,{setDragging:null});!function(e,t,n){const o=e.state.doc,r=o.resolve(n),i=r.parent,s=r.posAtIndex(0)-1,l=e.nodeDOM(s),a=l.ownerDocument&&l.ownerDocument.defaultView||window;l.style.height=a.getComputedStyle(l).height,t.setNodeMarkup(s,null,Wt(i.attrs,"height",l.style.height));const c=l&&l.closest("table"),d=c&&c.style.height;if(d){const e=o.resolve(s),n=e.start(e.depth)-1;t.setNodeMarkup(n,null,Wt(e.parent.attrs,"height",d))}}(e,t,n.activeHandle),e.dispatch(t)}}function h(t){if(!t.which)return d(t);const n=zd.getState(e.state),o=function(e,t){const n=t.clientY-e.startY;return e.startHeight.rowHeight+n}(n.dragging,t),r=t.clientY-n.dragging.startY;!function(e,t,n,o,r){const i=e.nodeDOM(t),s=i&&i.parentNode;if(s){s.style.height=n+"px";const e=s.ownerDocument&&s.ownerDocument.defaultView||window;s.style.height=e.getComputedStyle(s).height;const t=s.closest("table"),i=parseFloat(r)+o+"px",l=t&&t.style.height;l&&l!==i&&(t.style.height=parseFloat(r)+o+"px",t.style.height=e.getComputedStyle(t).height)}}(e,n.activeHandle,o,r,a)}return e.dispatch(e.state.tr.setMeta(zd,{setDragging:{startY:t.clientY,startHeight:{rowHeight:c,tableHeight:a}}})),t.view.addEventListener("mouseup",d),t.view.addEventListener("mousemove",h),t.preventDefault(),!0}(e,t)},decorations(e){if(Bd(zd,e))return qs.empty;const t=zd.getState(e);return t.activeHandle>-1?function(e,t){const n=[];if("number"!=typeof t)return qs.empty;const o=e.doc.resolve(t),r=o.node(-1),i=zl.get(r),s=o.start(-1),l=[],a=t-s;let c=-1;for(let e=0;e<i.height;e++)l.push(i.map.slice(e*i.width,e*i.width+i.width)),-1!==l[e].indexOf(a)&&(c=e);const d=[];return l[c].forEach(((e,t)=>{l[c+1]&&e===l[c+1][t]||d.push(e)})),d.forEach((e=>{const t=r.nodeAt(e),o=s+e+(t?t.nodeSize:0)-1,i=document.createElement("div");i.className="row-resize-handle",n.push(Hs.widget(o,i))})),qs.create(e.doc,n)}(e,t.activeHandle):void 0},nodeViews:{}}});return e}class th{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(e){let t,n=e.getMeta(zd);if(n&&null!=n.setHandle)return new th(n.setHandle,null);if(n&&void 0!==n.setDragging)return new th(this.activeHandle,n.setDragging);if(this.activeHandle>-1){let n=e.mapping.map(this.activeHandle,-1);"row"===(o=e.doc.resolve(n)).parent.type.spec.tableRole&&o.nodeAfter||(n=null),t=new th(n,this.dragging)}var o;return t||this}}function nh(e,t){const n=e.state.tr;n.setMeta("addToHistory",!1),n.setMeta(zd,{setHandle:t}),e.dispatch(n)}const oh=(e,t,n,o,r)=>{const i=r.resolve(e),s=r.resolve(t),l=o.type.name;let a,c;return!i.nodeBefore&&(a=i.node(i.depth),c=i.node(i.depth-1),a&&c&&c.firstChild===a&&c.type.name===l)?n+o.content.size<=t:!s.nodeAfter&&(a=s.node(s.depth),c=s.node(s.depth-1),a&&c&&c.lastChild===a&&c.type.name===l)?e<=n:e<=n&&n+o.content.size<=t},rh={listItem:"list_item",resetValues:{"font-size":"","font-family":"",color:""}};class ih{constructor(e,t){var n;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=null!==(n=t.width)&&void 0!==n?n:1,this.color=!1===t.color?void 0:t.color||"black",this.class=t.class,this.handlers=["dragover","dragend","drop","dragleave"].map((t=>{let n=e=>{this[t](e)};return e.dom.addEventListener(t,n),{name:t,handler:n}}))}destroy(){this.handlers.forEach((({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t)))}update(e,t){null!=this.cursorPos&&t.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,null==e?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e,t=this.editorView.state.doc.resolve(this.cursorPos),n=!t.parent.inlineContent;if(n){let n=t.nodeBefore,o=t.nodeAfter;if(n||o){let t=this.editorView.nodeDOM(this.cursorPos-(n?n.nodeSize:0));if(t){let r=t.getBoundingClientRect(),i=n?r.bottom:r.top;n&&o&&(i=(i+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2),e={left:r.left,right:r.right,top:i-this.width/2,bottom:i+this.width/2}}}}if(!e){let t=this.editorView.coordsAtPos(this.cursorPos);e={left:t.left-this.width/2,right:t.left+this.width/2,top:t.top,bottom:t.bottom}}let o,r,i=this.editorView.dom.offsetParent;if(this.element||(this.element=i.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",n),this.element.classList.toggle("prosemirror-dropcursor-inline",!n),!i||i==document.body&&"static"==getComputedStyle(i).position)o=-pageXOffset,r=-pageYOffset;else{let e=i.getBoundingClientRect();o=e.left-i.scrollLeft,r=e.top-i.scrollTop}this.element.style.left=e.left-o+"px",this.element.style.top=e.top-r+"px",this.element.style.width=e.right-e.left+"px",this.element.style.height=e.bottom-e.top+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout((()=>this.setCursor(null)),e)}dragover(e){if(!this.editorView.editable)return;let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),n=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),o=n&&n.type.spec.disableDropCursor,r="function"==typeof o?o(this.editorView,t,e):o;if(t&&!r){let e=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let t=Fe(this.editorView.state.doc,e,this.editorView.dragging.slice);null!=t&&(e=t)}this.setCursor(e),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){e.target!=this.editorView.dom&&this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}class sh extends et{constructor(e){super(e,e)}map(e,t){let n=e.resolve(t.map(this.head));return sh.valid(n)?new sh(n):et.near(n)}content(){return d.empty}eq(e){return e instanceof sh&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,t){if("number"!=typeof t.pos)throw new RangeError("Invalid input for GapCursor.fromJSON");return new sh(e.resolve(t.pos))}getBookmark(){return new lh(this.anchor)}static valid(e){let t=e.parent;if(t.isTextblock||!function(e){for(let t=e.depth;t>=0;t--){let n=e.index(t),o=e.node(t);if(0!=n)for(let e=o.child(n-1);;e=e.lastChild){if(0==e.childCount&&!e.inlineContent||e.isAtom||e.type.spec.isolating)return!0;if(e.inlineContent)return!1}else if(o.type.spec.isolating)return!0}return!0}(e)||!function(e){for(let t=e.depth;t>=0;t--){let n=e.indexAfter(t),o=e.node(t);if(n!=o.childCount)for(let e=o.child(n);;e=e.firstChild){if(0==e.childCount&&!e.inlineContent||e.isAtom||e.type.spec.isolating)return!0;if(e.inlineContent)return!1}else if(o.type.spec.isolating)return!0}return!0}(e))return!1;let n=t.type.spec.allowGapCursor;if(null!=n)return n;let o=t.contentMatchAt(e.index()).defaultType;return o&&o.isTextblock}static findGapCursorFrom(e,t,n=!1){e:for(;;){if(!n&&sh.valid(e))return e;let o=e.pos,r=null;for(let n=e.depth;;n--){let i=e.node(n);if(t>0?e.indexAfter(n)<i.childCount:e.index(n)>0){r=i.child(t>0?e.indexAfter(n):e.index(n)-1);break}if(0==n)return null;o+=t;let s=e.doc.resolve(o);if(sh.valid(s))return s}for(;;){let i=t>0?r.firstChild:r.lastChild;if(!i){if(r.isAtom&&!r.isText&&!st.isSelectable(r)){e=e.doc.resolve(o+r.nodeSize*t),n=!1;continue e}break}r=i,o+=t;let s=e.doc.resolve(o);if(sh.valid(s))return s}return null}}}sh.prototype.visible=!1,sh.findFrom=sh.findGapCursorFrom,et.jsonID("gapcursor",sh);class lh{constructor(e){this.pos=e}map(e){return new lh(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return sh.valid(t)?new sh(t):et.near(t)}}const ah=Rl({ArrowLeft:ch("horiz",-1),ArrowRight:ch("horiz",1),ArrowUp:ch("vert",-1),ArrowDown:ch("vert",1)});function ch(e,t){const n="vert"==e?t>0?"down":"up":t>0?"right":"left";return function(e,o,r){let i=e.selection,s=t>0?i.$to:i.$from,l=i.empty;if(i instanceof rt){if(!r.endOfTextblock(n)||0==s.depth)return!1;l=!1,s=e.doc.resolve(t>0?s.after():s.before())}let a=sh.findGapCursorFrom(s,t,l);return!!a&&(o&&o(e.tr.setSelection(new sh(a))),!0)}}function dh(e,t,n){if(!e||!e.editable)return!1;let o=e.state.doc.resolve(t);if(!sh.valid(o))return!1;let r=e.posAtCoords({left:n.clientX,top:n.clientY});return!(r&&r.inside>-1&&st.isSelectable(e.state.doc.nodeAt(r.inside)))&&(e.dispatch(e.state.tr.setSelection(new sh(o))),!0)}function hh(e,t){if("insertCompositionText"!=t.inputType||!(e.state.selection instanceof sh))return!1;let{$from:n}=e.state.selection,o=n.parent.contentMatchAt(n.index()).findWrapping(e.state.schema.nodes.text);if(!o)return!1;let i=r.empty;for(let e=o.length-1;e>=0;e--)i=r.from(o[e].createAndFill(null,i));let s=e.state.tr.replace(n.pos,n.pos,new d(i,0,0));return s.setSelection(rt.near(s.doc.resolve(n.pos+1))),e.dispatch(s),!1}function ph(e){if(!(e.selection instanceof sh))return null;let t=document.createElement("div");return t.className="ProseMirror-gapcursor",qs.create(e.doc,[Hs.widget(e.selection.head,t,{key:"gapcursor"})])}const uh=/^table$/,fh=/^table_row$/,mh=/^table_cell|table_header$/,gh=(e,t)=>{const n=e.$head;for(let e=n.depth;e>0;e--){const o=n.node(e);if(t.test(o.type.name))return{pos:n.before(e),node:o}}return null},yh=(e,t)=>{if(!e)return-1;const n=zl.get(e.node),o=gh(t,mh),r=n.map.indexOf(o.pos-e.pos-1);let i=-1;return-1!==r&&(i=r%n.width),i},wh=(e,t,n)=>{const o=yh(t,e.selection),r=cc(t.node.attrs[Ct]);r.insertBefore(r.ownerDocument.createElement("col"),r.children[o+n]),e.setNodeMarkup(t.pos,null,{...t.node.attrs,[Ct]:r.outerHTML})};e.AddMarkStep=be,e.AddNodeMarkStep=xe,e.AllSelection=at,e.AttrStep=Ge,e.CellSelection=Ql,e.ContentMatch=E,e.DOMParser=U,e.DOMSerializer=ie,e.Decoration=Hs,e.DecorationSet=qs,e.DocAttrStep=Ye,e.EditorState=yt,e.EditorView=class{constructor(e,t){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new ps,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(xl),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):"function"==typeof e?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=bl(this),vl(this),this.nodeViews=kl(this),this.docView=ci(this.state.doc,wl(this),el(this),this.dom,this),this.domObserver=new rl(this,((e,t,n,o)=>hl(this,e,t,n,o))),this.domObserver.start(),function(e){for(let t in cs){let n=cs[t];e.dom.addEventListener(t,e.input.eventHandlers[t]=t=>{!gs(e,t)||ms(e,t)||!e.editable&&t.type in ds||n(e,t)},hs[t]?{passive:!0}:void 0)}Ar&&e.dom.addEventListener("input",(()=>null)),fs(e)}(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let t in e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&fs(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(xl),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let e in this._props)t[e]=this._props[e];t.state=this.state;for(let n in e)t[n]=e[n];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var n;let o=this.state,r=!1,i=!1;e.storedMarks&&this.composing&&(Ts(this),i=!0),this.state=e;let s=o.plugins!=e.plugins||this._props.plugins!=t.plugins;if(s||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let e=kl(this);(function(e,t){let n=0,o=0;for(let o in e){if(e[o]!=t[o])return!0;n++}for(let e in t)o++;return n!=o})(e,this.nodeViews)&&(this.nodeViews=e,r=!0)}(s||t.handleDOMEvents!=this._props.handleDOMEvents)&&fs(this),this.editable=bl(this),vl(this);let l=el(this),a=wl(this),c=o.plugins==e.plugins||o.doc.eq(e.doc)?e.scrollToSelection>o.scrollToSelection?"to selection":"preserve":"reset",d=r||!this.docView.matchesNode(e.doc,a,l);!d&&e.selection.eq(o.selection)||(i=!0);let h="preserve"==c&&i&&null==this.dom.style.overflowAnchor&&function(e){let t,n,o=e.dom.getBoundingClientRect(),r=Math.max(0,o.top);for(let i=(o.left+o.right)/2,s=r+1;s<Math.min(innerHeight,o.bottom);s+=5){let o=e.root.elementFromPoint(i,s);if(!o||o==e.dom||!e.dom.contains(o))continue;let l=o.getBoundingClientRect();if(l.top>=r-20){t=o,n=l.top;break}}return{refDOM:t,refTop:n,stack:Fr(e.dom)}}(this);if(i){this.domObserver.stop();let t=d&&(xr||Nr)&&!this.composing&&!o.selection.empty&&!e.selection.empty&&function(e,t){let n=Math.min(e.$anchor.sharedDepth(e.head),t.$anchor.sharedDepth(t.head));return e.$anchor.start(n)!=t.$anchor.start(n)}(o.selection,e.selection);if(d){let n=Nr?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=Ds(this)),!r&&this.docView.update(e.doc,a,l,this)||(this.docView.updateOuterDeco(a),this.docView.destroy(),this.docView=ci(e.doc,a,l,this.dom,this)),n&&!this.trackWrites&&(t=!0)}t||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&function(e){let t=e.docView.domFromPos(e.state.selection.anchor,0),n=e.domSelectionRange();return cr(t.node,t.offset,n.anchorNode,n.anchorOffset)}(this))?Oi(this,t):(Ri(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(o),(null===(n=this.dragging)||void 0===n?void 0:n.node)&&!o.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,o),"reset"==c?this.dom.scrollTop=0:"to selection"==c?this.scrollToSelection():h&&function({refDOM:e,refTop:t,stack:n}){let o=e?e.getBoundingClientRect().top:0;Lr(n,0==o?0:o-t)}(h)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(this.someProp("handleScrollToSelection",(e=>e(this))));else if(this.state.selection instanceof st){let t=this.docView.domAfterPos(this.state.selection.from);1==t.nodeType&&Vr(this,t.getBoundingClientRect(),e)}else Vr(this,this.coordsAtPos(this.state.selection.head,1),e)}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(e&&e.plugins==this.state.plugins&&this.directPlugins==this.prevDirectPlugins)for(let t=0;t<this.pluginViews.length;t++){let n=this.pluginViews[t];n.update&&n.update(this,e)}else{this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let e=0;e<this.directPlugins.length;e++){let t=this.directPlugins[e];t.spec.view&&this.pluginViews.push(t.spec.view(this))}for(let e=0;e<this.state.plugins.length;e++){let t=this.state.plugins[e];t.spec.view&&this.pluginViews.push(t.spec.view(this))}}}updateDraggedNode(e,t){let n=e.node,o=-1;if(this.state.doc.nodeAt(n.from)==n.node)o=n.from;else{let e=n.from+(this.state.doc.content.size-t.doc.content.size);(e>0&&this.state.doc.nodeAt(e))==n.node&&(o=e)}this.dragging=new zs(e.slice,e.move,o<0?void 0:st.create(this.state.doc,o))}someProp(e,t){let n,o=this._props&&this._props[e];if(null!=o&&(n=t?t(o):o))return n;for(let o=0;o<this.directPlugins.length;o++){let r=this.directPlugins[o].props[e];if(null!=r&&(n=t?t(r):r))return n}let r=this.state.plugins;if(r)for(let o=0;o<r.length;o++){let i=r[o].props[e];if(null!=i&&(n=t?t(i):i))return n}}hasFocus(){if(xr){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if("false"==e.contentEditable)return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&function(e){if(e.setActive)return e.setActive();if(Hr)return e.focus(Hr);let t=Fr(e);e.focus(null==Hr?{get preventScroll(){return Hr={preventScroll:!0},!0}}:void 0),Hr||(Hr=!1,Lr(t,0))}(this.dom),Oi(this),this.domObserver.start()}get root(){let e=this._root;if(null==e)for(let e=this.dom.parentNode;e;e=e.parentNode)if(9==e.nodeType||11==e.nodeType&&e.host)return e.getSelection||(Object.getPrototypeOf(e).getSelection=()=>e.ownerDocument.getSelection()),this._root=e;return e||document}updateRoot(){this._root=null}posAtCoords(e){return Jr(this,e)}coordsAtPos(e,t=1){return Ur(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,n=-1){let o=this.docView.posFromDOM(e,t,n);if(null==o)throw new RangeError("DOM position not inside the editor");return o}endOfTextblock(e,t){return oi(this,t||this.state,e)}pasteHTML(e,t){return $s(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return $s(this,e,null,!0,t||new ClipboardEvent("paste"))}destroy(){this.docView&&(!function(e){e.domObserver.stop();for(let t in e.input.eventHandlers)e.dom.removeEventListener(t,e.input.eventHandlers[t]);clearTimeout(e.input.composingTimeout),clearTimeout(e.input.lastIOSEnterFallbackTimeout)}(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],el(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,lr=null)}get isDestroyed(){return null==this.docView}dispatchEvent(e){return function(e,t){ms(e,t)||!cs[t.type]||!e.editable&&t.type in ds||cs[t.type](e,t)}(this,e)}dispatch(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))}domSelectionRange(){let e=this.domSelection();return e?Ar&&11===this.root.nodeType&&function(e){let t=e.activeElement;for(;t&&t.shadowRoot;)t=t.shadowRoot.activeElement;return t}(this.dom.ownerDocument)==this.dom&&function(e,t){if(t.getComposedRanges){let n=t.getComposedRanges(e.root)[0];if(n)return ll(e,n)}let n;function o(e){e.preventDefault(),e.stopImmediatePropagation(),n=e.getTargetRanges()[0]}return e.dom.addEventListener("beforeinput",o,!0),document.execCommand("indent"),e.dom.removeEventListener("beforeinput",o,!0),n?ll(e,n):null}(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}},e.Fragment=r,e.GapCursor=sh,e.InputRule=Rc,e.MapResult=ue,e.Mapping=me,e.Mark=a,e.MarkType=j,e.Node=A,e.NodeRange=N,e.NodeSelection=st,e.NodeType=q,e.Plugin=vt,e.PluginKey=xt,e.RemoveMarkStep=ke,e.RemoveNodeMarkStep=Se,e.ReplaceAroundStep=Me,e.ReplaceError=c,e.ReplaceStep=Ce,e.ResolvedPos=x,e.Schema=K,e.Selection=et,e.SelectionRange=tt,e.Slice=d,e.Step=ye,e.StepMap=fe,e.StepResult=we,e.TableMap=zl,e.TextSelection=rt,e.Transaction=pt,e.Transform=Qe,e.__endComposition=yl,e.__parseFromClipboard=gl,e.__serializeForClipboard=ml,e.activeNode=e=>({tag:_n(e)||""}),e.addColSpan=Gl,e.addColumn=ia,e.addColumnAfter=(e,t)=>la(e,t&&(e=>{const n=gh(e.selection,uh);return n.node.attrs[Ct]?(wh(e,n,1),t(e)):t(e)})),e.addColumnBefore=(e,t)=>sa(e,t&&(e=>{const n=gh(e.selection,uh);return n.node.attrs[Ct]?(wh(e,n,-1),t(e)):t(e)})),e.addListNodes=function(e,t,n){return e.append({ordered_list:Un(jn,{content:"list_item+",group:n}),bullet_list:Un(Kn,{content:"list_item+",group:n}),list_item:Un(Xn,{content:t})})},e.addRow=ha,e.addRowAfter=(e,t)=>ua(e,t&&(e=>{const n=gh(e.selection,fh);if(n&&n.node.attrs[St]){const t=n.pos+n.node.nodeSize;e.setNodeMarkup(t,void 0,{[St]:n.node.attrs[St]})}return t(e)})),e.addRowBefore=(e,t)=>{const n=t&&(e=>{const n=gh(e.selection,fh),o=gh(e.selection,uh);if(n&&o&&n.node.attrs[St]){let t=0;for(let e=0;e<o.node.nodeSize;e++)if(o.node.child(e).eq(n.node)){t=e;break}const r=o.node.child(t-1),i=n.pos-r.nodeSize;e.setNodeMarkup(i,void 0,{[St]:n.node.attrs[St]})}return t(e)});return pa(e,n)},e.alignBlocks=(e,t)=>(n,o)=>{const r=Pn(n),i=n.tr;i.setMeta("commandName",t),r.forEach((t=>{if(t.type.isTextblock){const n=e.find((e=>e.node===t.type.name));if(n){const e=Ln(t,n.style);Bn(i,t,t.type,e)}}}));const s=i.docChanged;return s&&o(i.scrollIntoView()),s},e.alignCenterRules=nr,e.alignJustifyRules=or,e.alignLeftRules=er,e.alignRemoveRules=rr,e.alignRightRules=tr,e.applyInlineStyle=(e,t)=>(n,o)=>{const r=n.schema.marks.style,i={style:e.style,value:/^.+$/,newValue:e.value},s=n.tr;t&&s.setMeta("commandName",t),s.setMeta("args",e);const{empty:l,$cursor:a,ranges:c}=n.selection;if(l&&!a||!r||!Cn(n.doc,c,r))return!1;if(a){const e=n.storedMarks||a.marks(),t=r.isInSet(e)?e.find((e=>"style"===e.type.name)):null,l={style:null};if(t&&t.attrs.style){const e=Ht(t.attrs.style,i);e.changed&&e.style&&(l.style=e.style)}else i.newValue&&(l.style=`${[i.style]}: ${i.newValue};`);const c=t?{...t.attrs,...l}:l;return Object.keys(c).some((e=>null!==c[e]))?o(s.addStoredMark(r.create(c))):o(s.removeStoredMark(r)),!0}return $n(r,i)(n,o,s)},e.applyLink=({mark:e,attrs:t},n="link")=>(o,r)=>{const i=o.schema.marks,s=o.tr;n&&(s.setMeta("commandName",n),s.setMeta("args",t));let l=!1;const a=()=>l=!0;if(((e,t)=>{const n=Dn(e,t);return 1===n.length&&n[0]?n[0]:null})(o,i[e]))((e,t)=>(n,o)=>{const{$cursor:r,from:i,to:s}=n.selection,l=n.schema.marks[e.mark];if(r){const n=r.parent,i=r.index(),s=n.child(i).marks.find((e=>e.type===l)),a=n.childCount;let c,d,h=r.pos-r.textOffset,p=n.child(i).nodeSize;for(c=i-1;c>=0&&s.isInSet(n.child(c).marks);)d=n.child(c).nodeSize,p+=d,h-=d,c-=1;for(c=i+1;c<a&&s.isInSet(n.child(c).marks);)p+=n.child(c).nodeSize,c+=1;t.removeMark(h,h+p,l),t.addMark(h,h+p,l.create(e.attrs)),o(t)}else t.doc.nodesBetween(i,s,((n,r)=>{n.isInline&&l.isInSet(n.marks)&&(t.removeMark(r,r+n.nodeSize,l),t.addMark(r,r+n.nodeSize,l.create(e.attrs)),o(t))}))})({mark:e,attrs:t},s)(o,a);else{let n=o;An(o,{mark:e})&&(zn({mark:e,attrs:t},s)(o,a),n=yt.create({doc:s.doc,selection:s.selection})),l?Mn(i[e],t,s)(n,a):In({mark:e},s,t)(n,a)}return l&&r(s),l},e.autoJoin=$o,e.baseKeymap=Fo,e.blockNodes=Pn,e.blockquote=(e,t)=>Eo(e.schema.nodes.blockquote)(e,t),e.bold=_c,e.buildKeymap=(e,t)=>{const n={},o=t&&t.applyToWord||!1;if(n["Mod-z"]=Ac,n["Shift-Mod-z"]=Tc,n.Backspace=Io(Ic,so,ao,po),n.Enter=Io(wo,ko,xo,Mo),Jc||(n["Mod-y"]=Tc),e.marks.strong&&(n["Mod-b"]=Qt(In,{..._c,applyToWord:o})),e.marks.em&&(n["Mod-i"]=Qt(In,{...Wc,applyToWord:o})),e.marks.u&&(n["Mod-u"]=Qt(In,{...qc,applyToWord:o})),e.nodes.hard_break){const t=e.nodes.hard_break,o=Io(bo,((e,n)=>(n(e.tr.replaceSelectionWith(t.create()).scrollIntoView()),!0)));n["Shift-Enter"]=o}return n},e.buildListKeymap=e=>{const t={};var n;return e.nodes.list_item&&(t.Enter=(n=e.nodes.list_item,(e,t)=>Qn(n)(e,(n=>{const o=e.storedMarks||e.selection.$to.parentOffset&&e.selection.$from.marks();o&&n.ensureMarks(o),t(n)})))),t},e.bulletList=Kn,e.canBeIndented=Jo,e.canIndentAsListItem=Wo,e.canInsert=(e,t)=>{const n=e.selection.$from;for(let e=n.depth;e>=0;e--){const o=n.index(e);if(n.node(e).canReplaceWith(o,o,t))return!0}return!1},e.canJoin=ze,e.canOutdentAsListItem=qo,e.canSplit=Ie,e.caretColor=function(){return new vt({key:Dd,props:{decorations:e=>{const{doc:t,selection:n,storedMarks:o}=e;if(!n.empty||!o)return qs.empty;const r=Tn((o||[]).find((e=>"style"===e.type.name)),{name:"color",value:/^.+$/});if(!r)return qs.empty;const i=n.$anchor.parent,s=[];return t.descendants(((e,t)=>{e.eq(i)&&s.push(Hs.node(t,t+e.nodeSize,{style:"caret-color: "+r}))})),qs.create(t,s)}}})},e.caretColorKey=Dd,e.cellAround=_l,e.chainCommands=Io,e.changeTextBlock=Bn,e.cleanFormatting=(e={blocksInSelection:!0})=>(t,n)=>{const o=t.tr,{blocksInSelection:r,blockNodeType:i,exceptMarks:s}=e,l=(s||[t.schema.marks.link]).filter(Boolean);On(o,{except:l}),Vn(o,{blocksInSelection:r,blockNodeType:i});const a=o.docChanged;return a&&n&&n(o),a},e.cleanMarks=On,e.cleanTextBlockFormatting=Vn,e.closeDoubleQuote=Vc,e.closeHistory=function(e){return e.setMeta(Nc,!0)},e.closeSingleQuote=Lc,e.colCount=function(e){return zl.get(e.node(-1)).colCount(e.pos-e.start(-1))},e.columnIsHeader=Yl,e.columnResizing=function({handleWidth:e=5,cellMinWidth:t=25,defaultCellMinWidth:n=100,View:o=Va,lastColumnResizable:r=!0}={}){const i=new vt({key:La,state:{init(e,t){var r,s;const l=null==(s=null==(r=i.spec)?void 0:r.props)?void 0:s.nodeViews,a=Ll(t.schema).table.name;return o&&l&&(l[a]=(e,t)=>new o(e,n,t)),new Ha(-1,!1)},apply:(e,t)=>t.apply(e)},props:{attributes:e=>{const t=La.getState(e);return t&&t.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(t,n)=>{!function(e,t,n,o){const r=La.getState(e.state);if(!r)return;if(!r.dragging){const i=function(e){for(;e&&"TD"!=e.nodeName&&"TH"!=e.nodeName;)e=e.classList&&e.classList.contains("ProseMirror")?null:e.parentNode;return e}(t.target);let s=-1;if(i){const{left:o,right:r}=i.getBoundingClientRect();t.clientX-o<=n?s=_a(e,t,"left",n):r-t.clientX<=n&&(s=_a(e,t,"right",n))}if(s!=r.activeHandle){if(!o&&-1!==s){const t=e.state.doc.resolve(s),n=t.node(-1),o=zl.get(n),r=t.start(-1);if(o.colCount(t.pos-r)+t.nodeAfter.attrs.colspan-1==o.width-1)return}qa(e,s)}}}(t,n,e,r)},mouseleave:e=>{!function(e){const t=La.getState(e.state);t&&t.activeHandle>-1&&!t.dragging&&qa(e,-1)}(e)},mousedown:(e,o)=>{!function(e,t,n,o){var r;const i=null!=(r=e.dom.ownerDocument.defaultView)?r:window,s=La.getState(e.state);if(!s||-1==s.activeHandle||s.dragging)return!1;const l=e.state.doc.nodeAt(s.activeHandle),a=function(e,t,{colspan:n,colwidth:o}){const r=o&&o[o.length-1];if(r)return r;const i=e.domAtPos(t);let s=i.node.childNodes[i.offset].offsetWidth,l=n;if(o)for(let e=0;e<n;e++)o[e]&&(s-=o[e],l--);return s/l}(e,s.activeHandle,l.attrs);function c(t){i.removeEventListener("mouseup",c),i.removeEventListener("mousemove",d);const o=La.getState(e.state);(null==o?void 0:o.dragging)&&(!function(e,t,n){const o=e.state.doc.resolve(t),r=o.node(-1),i=zl.get(r),s=o.start(-1),l=i.colCount(o.pos-s)+o.nodeAfter.attrs.colspan-1,a=e.state.tr;for(let e=0;e<i.height;e++){const t=e*i.width+l;if(e&&i.map[t]==i.map[t-i.width])continue;const o=i.map[t],c=r.nodeAt(o).attrs,d=1==c.colspan?0:l-i.colCount(o);if(c.colwidth&&c.colwidth[d]==n)continue;const h=c.colwidth?c.colwidth.slice():ja(c.colspan);h[d]=n,a.setNodeMarkup(s+o,null,{...c,colwidth:h})}a.docChanged&&e.dispatch(a)}(e,o.activeHandle,Wa(o.dragging,t,n)),e.dispatch(e.state.tr.setMeta(La,{setDragging:null})))}function d(t){if(!t.which)return c(t);const r=La.getState(e.state);if(r&&r.dragging){const i=Wa(r.dragging,t,n);Ja(e,r.activeHandle,i,o)}}e.dispatch(e.state.tr.setMeta(La,{setDragging:{startX:t.clientX,startWidth:a}})),Ja(e,s.activeHandle,a,o),i.addEventListener("mouseup",c),i.addEventListener("mousemove",d),t.preventDefault()}(e,o,t,n)}},decorations:e=>{const t=La.getState(e);if(t&&t.activeHandle>-1)return function(e,t){var n;const o=[],r=e.doc.resolve(t),i=r.node(-1);if(!i)return qs.empty;const s=zl.get(i),l=r.start(-1),a=s.colCount(r.pos-l)+r.nodeAfter.attrs.colspan-1;for(let t=0;t<s.height;t++){const r=a+t*s.width;if(!(a!=s.width-1&&s.map[r]==s.map[r+1]||0!=t&&s.map[r]==s.map[r-s.width])){const t=s.map[r],a=l+t+i.nodeAt(t).nodeSize-1,c=document.createElement("div");c.className="column-resize-handle",(null==(n=La.getState(e))?void 0:n.dragging)&&o.push(Hs.node(l+t,l+t+i.nodeAt(t).nodeSize,{class:"column-resize-dragging"})),o.push(Hs.widget(a,c))}}return qs.create(e.doc,o)}(e,t.activeHandle)},nodeViews:{}}});return i},e.columnResizingPluginKey=La,e.convertMsLists=ed,e.createParagraphNear=ko,e.createTable=(e,t,n)=>{const{table:o,table_row:r,table_cell:i}=e,s=[];let l;for(let e=0;e<t+1;e++){l=[];for(let e=0;e<n+1;e++)l.push(i.createAndFill());s.push(r.createAndFill(void 0,l))}return o.createAndFill(void 0,s)},e.cspFix=()=>new vt({key:new xt("csp-fix"),props:{nodeViews:{paragraph:(e,t)=>new vd(e,t,"p"),div:(e,t)=>new vd(e,t,"div"),table_wrapper:(e,t)=>new vd(e,t,"div"),table_caption_external:(e,t)=>new vd(e,t,"div"),table:(e,t)=>new vd(e,t,"table"),table_row:(e,t)=>new vd(e,t,"tr"),table_cell:(e,t)=>new vd(e,t,"td"),table_header:(e,t)=>new vd(e,t,"th"),image:(e,t)=>new vd(e,t,"img",!0)},markViews:{style:(e,t)=>new bd(e,t)}}}),e.deleteColumn=(e,t)=>{const n=gh(e.selection,uh),o=n&&n.node.attrs[Ct],r=yh(n,e.selection),i=t&&(e=>{if(!o)return t(e);const i=e.doc.nodeAt(n.pos);return((e,t,n)=>{const o=cc(t.node.attrs[Ct]);o.removeChild(o.children[n]),e.setNodeMarkup(t.pos,null,{...t.node.attrs,[Ct]:o.outerHTML})})(e,{node:i,pos:n.pos},r),t(e)});return ca(e,i)},e.deleteRow=function(e,t){if(!Wl(e))return!1;if(t){const n=ra(e),o=e.tr;if(0==n.top&&n.bottom==n.map.height)return!1;for(let e=n.bottom-1;fa(o,n,e),e!=n.top;e--){const e=n.tableStart?o.doc.nodeAt(n.tableStart-1):o.doc;if(!e)throw RangeError("No table found");n.table=e,n.map=zl.get(n.table)}t(o)}return!0},e.deleteSelection=so,e.deleteTable=function(e,t){const n=e.selection.$anchor;for(let o=n.depth;o>0;o--){if("table"==n.node(o).type.spec.tableRole)return t&&t(e.tr.delete(n.before(o),n.after(o)).scrollIntoView()),!0}return!1},e.domToPmDoc=wn,e.dropCursor=function(e={}){return new vt({view:t=>new ih(t,e)})},e.dropPoint=Fe,e.ellipsis=Bc,e.emDash=zc,e.exitCode=bo,e.expandSelection=Yt,e.expandToWordWrap=Qt,e.find=(e,t)=>{const{backward:n,matchCyclic:o,...r}=t,i=n?()=>!1:e=>e.length>0,{doc:s,selection:l}=e;let a=[];return n?(a=hd(s,r,0,l.from,i),!a.length&&o&&(a=hd(s,r,l.from,s.content.size,i))):(a=hd(s,r,l.to,s.content.size,i),!a.length&&o&&(a=hd(s,r,0,l.to,i))),a.length?a[a.length-1]:null},e.findAll=pd,e.findAt=hd,e.findCell=function(e){return zl.get(e.node(-1)).findCell(e.pos-e.start(-1))},e.findWrapping=De,e.fixTables=oa,e.fixTablesKey=ta,e.flattenNestedSpans=e=>{const t=mn(e);let n=xn(t);for(;n;){const e=n.parentNode.closest("span");if(e){const t=new kn(e),o=t.extractAfter(n),r=t.extractBefore(n);for(let t=0;t<n.style.length;t++){const o=n.style.item(t);e.style[o]=n.style.getPropertyValue(o)}n.removeAttribute("style"),n.classList.length&&Array.from(n.classList).forEach((t=>{e.classList.contains(t)||e.classList.add(t)})),n.removeAttribute("class");for(let t=0;t<n.attributes.length;t++){const o=n.attributes.item(t);o&&null!==o.nodeValue&&e.setAttribute(o.nodeName,o.nodeValue)}for(;n.firstChild&&n.parentNode;)n.parentNode.insertBefore(n.firstChild,n);n.parentNode&&n.parentNode.removeChild(n),e.parentNode&&(Sn(r)||e.parentNode.insertBefore(r,e),Sn(o)||e.parentNode.insertBefore(o,e.nextSibling))}n=xn(t)}return gn(t)},e.formatBlockElements=(e,t)=>(n,o)=>{const r=Pn(n),i=n.schema.nodes,s=n.tr;s.setMeta("commandName",t),s.setMeta("args",{value:e}),r.forEach((t=>{if(t.type.isTextblock)if("p"===e)Bn(s,t,i.paragraph,t.attrs);else if(/^h[1-6]$/i.test(e)){const n=parseInt(e.substr(1),10);Bn(s,t,i.heading,{...t.attrs,level:n})}else"blockquote"===e&&Bn(s,t,i.blockquote,t.attrs)}));const l=s.docChanged;return l&&o(s.scrollIntoView()),l},e.fragmentToHtml=gn,e.gapCursor=function(){return new vt({props:{decorations:ph,createSelectionBetween:(e,t,n)=>t.pos==n.pos&&sh.valid(n)?new sh(n):null,handleClick:dh,handleKeyDown:ah,handleDOMEvents:{beforeinput:hh}}})},e.getActiveMarks=(e,t)=>{const n=Dn(e,t),o=n.filter((e=>Boolean(e)));return{hasNodesWithoutMarks:n.length!==o.length,marks:o}},e.getBlockFormats=Fn,e.getHtml=e=>{const t=yn(e.doc);return gn(t)},e.getInlineStyles=(e,t)=>{const n=e.schema.marks.style;return(n?Dn(e,n):[]).map((e=>Tn(e,t))).filter((e=>null!==e))},e.getMark=(e,t)=>{const n=Dn(e,t),o=n.filter((e=>Boolean(e)));return n.length===o.length?n[0]:void 0},e.getNodeFromSelection=e=>{if(e.selection instanceof st)return e.selection.node},e.getSelectionText=Ut,e.goToNextCell=function(e){return function(t,n){if(!Wl(t))return!1;const o=function(e,t){if(t<0){const t=e.nodeBefore;if(t)return e.pos-t.nodeSize;for(let t=e.index(-1)-1,n=e.before();t>=0;t--){const o=e.node(-1).child(t),r=o.lastChild;if(r)return n-1-r.nodeSize;n-=o.nodeSize}}else{if(e.index()<e.parent.childCount-1)return e.pos+e.nodeAfter.nodeSize;const t=e.node(-1);for(let n=e.indexAfter(-1),o=e.after();n<t.childCount;n++){const e=t.child(n);if(e.childCount)return o+1;o+=e.nodeSize}}return null}(ql(t),e);if(null==o)return!1;if(n){const e=t.doc.resolve(o);n(t.tr.setSelection(rt.between(e,jl(e))).scrollIntoView())}return!0}},e.hasMark=An,e.hasNode=Hn,e.hasSameMarkup=(e,t,n,o)=>{const i=r.from(vn(e,n,o)),s=r.from(vn(t,n,o));return i.eq(s)},e.history=function(e={}){return e={depth:e.depth||100,newGroupDelay:e.newGroupDelay||500},new vt({key:Mc,state:{init:()=>new wc(gc.empty,gc.empty,null,0,-1),apply:(t,n,o)=>function(e,t,n,o){let r,i=n.getMeta(Mc);if(i)return i.historyState;n.getMeta(Nc)&&(e=new wc(e.done,e.undone,null,0,-1));let s=n.getMeta("appendedTransaction");if(0==n.steps.length)return e;if(s&&s.getMeta(Mc))return s.getMeta(Mc).redo?new wc(e.done.addTransform(n,void 0,o,Cc(t)),e.undone,bc(n.mapping.maps),e.prevTime,e.prevComposition):new wc(e.done,e.undone.addTransform(n,void 0,o,Cc(t)),null,e.prevTime,e.prevComposition);if(!1===n.getMeta("addToHistory")||s&&!1===s.getMeta("addToHistory"))return(r=n.getMeta("rebased"))?new wc(e.done.rebased(n,r),e.undone.rebased(n,r),kc(e.prevRanges,n.mapping),e.prevTime,e.prevComposition):new wc(e.done.addMaps(n.mapping.maps),e.undone.addMaps(n.mapping.maps),kc(e.prevRanges,n.mapping),e.prevTime,e.prevComposition);{let r=n.getMeta("composition"),i=0==e.prevTime||!s&&e.prevComposition!=r&&(e.prevTime<(n.time||0)-o.newGroupDelay||!function(e,t){if(!t)return!1;if(!e.docChanged)return!0;let n=!1;return e.mapping.maps[0].forEach(((e,o)=>{for(let r=0;r<t.length;r+=2)e<=t[r+1]&&o>=t[r]&&(n=!0)})),n}(n,e.prevRanges)),l=s?kc(e.prevRanges,n.mapping):bc(n.mapping.maps);return new wc(e.done.addTransform(n,i?t.selection.getBookmark():void 0,o,Cc(t)),gc.empty,l,n.time,null==r?e.prevComposition:r)}}(n,o,t,e)},config:e,props:{handleDOMEvents:{beforeinput(e,t){let n=t.inputType,o="historyUndo"==n?Ac:"historyRedo"==n?Tc:null;return!!o&&(t.preventDefault(),o(e.state,e.dispatch))}}}})},e.htmlToFragment=mn,e.imageResizeKey=Cd,e.imageResizing=(e={node:"image",lockRatio:!0})=>new vt({key:Cd,view:t=>({resize(){Cd.getState(t.state).rect&&t.dispatch(t.state.tr.setMeta("resize",!0))},get window(){return t.dom.ownerDocument&&t.dom.ownerDocument.defaultView},attachResize(){const e=this.window;e&&(e.removeEventListener("resize",this.resize),e.addEventListener("resize",this.resize))},removeResize(){const e=this.window;e&&e.removeEventListener("resize",this.resize)},update(t,n){const o=t.state,r=o.selection,i=o.schema.nodes[e.node],s=Cd.getState(o),l=s.rect;if(r instanceof st&&i===r.node.type){const e=t.nodeDOM(r.from),i={top:e.offsetTop,left:e.offsetLeft,width:e.offsetWidth,height:e.offsetHeight};if(!n.selection.eq(r)||l&&(l.width!==i.width||l.height!==i.height||l.top!==i.top||l.left!==i.left)){const e=o.tr;e.setMeta(Cd,{rect:i,nodePosition:r.from}),t.dispatch(e),this.attachResize()}}else l&&(s.rect=null,s.nodePosition=-1)},destroy(){this.removeResize()}}),state:{init:()=>new Ad("",null,null,-1),apply:(e,t)=>t.apply(e)},props:{handleDOMEvents:{mousedown:(t,n)=>Td(t,n,e)},decorations(t){const n=t.selection,o=t.schema.nodes[e.node],r=Cd.getState(t).rect;if(r&&n instanceof st&&o===n.node.type){const e=document.createElement("div");e.className="k-editor-resize-handles-wrapper",e.style.width=r.width+"px",e.style.height=r.height+"px",e.style.top=r.top+"px",e.style.left=r.left+"px";for(let t=0;t<Sd.length;t++){const n=document.createElement("div");n.className=Nt+" "+Sd[t],n.setAttribute(At,Sd[t]),e.appendChild(n)}return qs.create(t.doc,[Hs.widget(t.selection.from+1,e)])}return qs.empty}}}),e.inSameTable=Kl,e.indent=(e,t)=>{const n=e.schema.nodes[ro.listsTypes.listItem],o=Jo(e,ro);Wo(e,n)?eo(n)(e,t):o&&Ho(ro.nodes)(e,t)},e.indentBlocks=Ho,e.indentHtml=e=>e.replace(/<\/(p|li|ul|ol|h[1-6]|table|tr|td|th)>/gi,"</$1>\n").replace(/<(ul|ol)([^>]*)><li/gi,"<$1$2>\n<li").replace(/<br \/>/gi,"<br />\n").replace(/\n$/,""),e.indentRules=ro,e.inputRules=function({rules:e}){let t=new vt({state:{init:()=>null,apply(e,t){let n=e.getMeta(this);return n||(e.selectionSet||e.docChanged?null:t)}},props:{handleTextInput:(n,o,r,i)=>$c(n,o,r,i,e,t),handleDOMEvents:{compositionend:n=>{setTimeout((()=>{let{$cursor:o}=n.state.selection;o&&$c(n,o.pos,o.pos,"",e,t)}))}}},isInputRules:!0});return t},e.insertImage=e=>(t,n)=>{const{image:o}=t.schema.nodes,r=o.createAndFill(e);Xt(r)(t,(t=>n(t.setMeta("commandName","insertImage").setMeta("args",e))))},e.insertNode=Xt,e.insertPoint=Ve,e.insertText=e=>(t,n)=>{n(t.tr.insertText(e.text,e.from,e.to))},e.isAligned=(e,t)=>{const n=Pn(e);let o=!1;return n.forEach((e=>{if(!o&&e.type.isTextblock&&e.attrs.style){const n=t.find((t=>t.node===e.type.name));n&&(o=n.style.every((t=>!!t.value&&new RegExp(`${t.name}:\\s?${t.value}`,"i").test(e.attrs.style))))}})),o},e.isInTable=Wl,e.isIndented=_o,e.italic=Wc,e.joinBackward=ao,e.joinDown=(e,t)=>{let n,o=e.selection;if(o instanceof st){if(o.node.isTextblock||!ze(e.doc,o.to))return!1;n=o.to}else if(n=Pe(e.doc,o.to,1),null==n)return!1;return t&&t(e.tr.join(n).scrollIntoView()),!0},e.joinForward=mo,e.joinPoint=Pe,e.joinTextblockBackward=(e,t,n)=>{let o=lo(e,n);if(!o)return!1;let r=uo(o);return!!r&&co(e,r,t)},e.joinTextblockForward=(e,t,n)=>{let o=fo(e,n);if(!o)return!1;let r=yo(o);return!!r&&co(e,r,t)},e.joinUp=(e,t)=>{let n,o=e.selection,r=o instanceof st;if(r){if(o.node.isTextblock||!ze(e.doc,o.from))return!1;n=o.from}else if(n=Pe(e.doc,o.from,-1),null==n)return!1;if(t){let o=e.tr.join(n);r&&o.setSelection(st.create(o.doc,n-e.doc.resolve(n).nodeBefore.nodeSize)),t(o.scrollIntoView())}return!0},e.keydownHandler=Rl,e.keymap=function(e){return new vt({props:{handleKeyDown:Rl(e)}})},e.lift=(e,t)=>{let{$from:n,$to:o}=e.selection,r=n.blockRange(o),i=r&&Te(r);return null!=i&&(t&&t(e.tr.lift(r,i).scrollIntoView()),!0)},e.liftBlockquote=Lo,e.liftEmptyBlock=xo,e.liftListItem=Zn,e.liftTarget=Te,e.link={mark:"link"},e.listItem=Xn,e.listMarkersStyles=function(e=rh){return new vt({key:new xt("list-markers-styles"),appendTransaction:(t,n,o)=>{const r=t.slice().pop(),i=r.getMeta("commandName");let s;return"FontSize"===i||"FontName"===i||"ForeColor"===i?s=((e,t,n)=>{const{tr:o,doc:r,selection:{from:i,to:s}}=t,l=e.getMeta("args");return r.nodesBetween(i,s,((e,t)=>{e.type.name===n.listItem&&oh(i,s,t,e,r)&&o.setNodeMarkup(t,null,{...e.attrs,style:en(e.attrs.style,l.style,l.value)})})),o.docChanged?o:void 0})(r,o,e):"CleanFormatting"===i&&(s=((e,t,n)=>{const o=Object.keys(n.resetValues),{tr:r,doc:i,selection:{from:s,to:l}}=t;return i.nodesBetween(s,l,((e,t)=>{if(e.type.name===n.listItem&&oh(s,l,t,e,i)){let n=e.attrs;const i=Zt(e.attrs.style);o.forEach((e=>{i[e]&&(n={...n,style:en(n.style,e,"")})})),n!==e.attrs&&r.setNodeMarkup(t,null,n)}})),e.steps.forEach((e=>{if(e instanceof ke){const t=e.mark;if("style"===t.type.name&&t.attrs.style){const[o]=t.attrs.style.split(/\s*:\s*/),i=jt(r.doc.resolve(e.from),(e=>e.type.name===n.listItem));if(i&&Zt(i.node.attrs.style)[o]&&n.resetValues[o]){const i=t.type.create({style:`${o}: ${n.resetValues[o]};`});r.addMark(e.from,e.to,i)}}}})),r.docChanged?r:void 0})(r,o,e)),s&&s.setMeta("addToHistory",!0),s}})},e.listStyle=Yo,e.macBaseKeymap=Vo,e.marks=ic,e.mergeCells=function(e,t){const n=e.selection;if(!(n instanceof Ql)||n.$anchorCell.pos==n.$headCell.pos)return!1;const o=ra(e),{map:i}=o;if(function({width:e,height:t,map:n},o){let r=o.top*e+o.left,i=r,s=(o.bottom-1)*e+o.left,l=r+(o.right-o.left-1);for(let t=o.top;t<o.bottom;t++){if(o.left>0&&n[i]==n[i-1]||o.right<e&&n[l]==n[l+1])return!0;i+=e,l+=e}for(let i=o.left;i<o.right;i++){if(o.top>0&&n[r]==n[r-e]||o.bottom<t&&n[s]==n[s+e])return!0;r++,s++}return!1}(i,o))return!1;if(t){const n=e.tr,s={};let l,a,c=r.empty;for(let e=o.top;e<o.bottom;e++)for(let t=o.left;t<o.right;t++){const r=i.map[e*i.width+t],d=o.table.nodeAt(r);if(!s[r]&&d)if(s[r]=!0,null==l)l=r,a=d;else{ma(d)||(c=c.append(d.content));const e=n.mapping.map(r+o.tableStart);n.delete(e,e+d.nodeSize)}}if(null==l||null==a)return!0;if(n.setNodeMarkup(l+o.tableStart,null,{...Gl(a.attrs,a.attrs.colspan,o.right-o.left-a.attrs.colspan),rowspan:o.bottom-o.top}),c.size){const e=l+1+a.content.size,t=ma(a)?l+1:e;n.replaceWith(t+o.tableStart,e+o.tableStart,c)}n.setSelection(new Ql(n.doc.resolve(l+o.tableStart))),t(n)}return!0},e.moveCellForward=jl,e.newlineInCode=wo,e.nextCell=Xl,e.nodes=hc,e.openDoubleQuote=Pc,e.openSingleQuote=Fc,e.orderedList=jn,e.outdent=(e,t)=>{const n=e.schema.nodes,o=n[io.listsTypes.listItem],r=Jo(e,io);Hn(e,n.blockquote)?Lo(e,t):qo(e,io)?Zn(o)(e,t):r&&Ho(io.nodes)(e,t)},e.outdentRules=io,e.parentBlockFormat=_n,e.parentNode=jt,e.parseContent=vn,e.pasteCleanup=(e,t)=>{let n=e;if(t.convertMsLists&&(n=ed(n)),t.stripTags&&(n=td(n,t.stripTags)),t.attributes){const e=mn(n);Array.from(e.querySelectorAll("*")).forEach((e=>((e,t)=>{if(e.nodeType===Node.ELEMENT_NODE){for(let n=e.attributes.length-1;n>=0;n--){const o=e.attributes[n];t[o.name]?t[o.name](o):t["*"]&&t["*"](o)}"SPAN"===e.nodeName&&0===e.attributes.length&&(e=>{const t=e.parentNode;if(t){for(;e.firstChild;)t.insertBefore(e.firstChild,e);t.removeChild(e)}})(e)}})(e,t.attributes))),n=gn(e)}return n},e.pcBaseKeymap=Po,e.placeholder=function(e){const t={class:"k-placeholder","data-placeholder":e};return new vt({key:new xt("placeholder"),props:{decorations:e=>{const{doc:n}=e,o=n.content.firstChild;if(!(0===n.childCount||1===n.childCount&&o.inlineContent&&0===o.childCount))return qs.empty;const r=[];return n.descendants(((e,n)=>{r.push(Hs.node(n,n+e.nodeSize,t))})),qs.create(n,r)}}})},e.pmAddColumnAfter=la,e.pmAddColumnBefore=sa,e.pmAddRowAfter=ua,e.pmAddRowBefore=pa,e.pmDeleteColumn=ca,e.pmDocToFragment=yn,e.redo=Tc,e.redoDepth=function(e){let t=Mc.getState(e);return t?t.undone.eventCount:0},e.redoNoScroll=Ec,e.removeAllMarks=({except:e=[]}={})=>(t,n)=>{const o=t.tr;var r;On(o,{except:(r=e,r instanceof Array?r:[r])}),o.docChanged&&n(o)},e.removeAttribute=nd,e.removeColSpan=Ul,e.removeComments=e=>{const t=mn(e);return bn(t),gn(t)},e.removeLink=zn,e.removeTag=td,e.replace=(e,t,n)=>{const{from:o,to:r}=e;return n.insertText(t,o,r).setSelection(rt.create(n.doc,o,o+t.length)),n},e.replaceAll=(e,t,n)=>{const o=pd(e.doc,n);if(0===o.length)return null;const r=e.tr;for(let e=o.length-1;e>=0;e--)r.insertText(t,o[e].from,o[e].to);return r},e.replaceImageSourcesFromRtf=(e,t)=>{const n=e.match(rd);if(!n||-1===t.types.indexOf(dd))return e;const o=t.getData(dd),r=[],i=o.match(sd);if(!o||!i)return e;for(const e of i){const t=cd.exec(e);if(t){const n=e.replace(id,"").replace(ld,"");r.push(`data:image/${t[1]};base64,${od(n)}`)}}return n.length!==r.length?e:e.replace(rd,(e=>{const t=r.shift()||"";return e.replace(ad,t)}))},e.replaceStep=Le,e.rowIsHeader=da,e.sanitize=e=>{let t;e=(e=(e=(e=e.replace(/^[\s\S]+?<!--StartFragment-->\s*([\s\S]*?)\s*<!--EndFragment-->[\s\S]+$/,"$1")).replace(/<\/?[ovw]:[^>]*?>/gi,"")).replace(/<\\?\??xml[^>]*>/gi,"")).replace(/<(?:link|meta) [^>]+?>/gi,"");do{t=e,e=e.replace(/<style[^>]*?>\s*<\/style>/gi,"")}while(e!==t);return e=(e=(e=(e=(e=e.replace(/<\/?st1:.*?>/gi,"")).replace(/<a name="[a-zA-Z0-9_]+">/gim,"")).replace(/v:shapes?="[^"]+"/gi,"")).replace(/<!\[if !supportLists\]>/gi,"")).replace(/<!\[endif\]>/gi,"")},e.sanitizeClassAttr=e=>{/^Mso/.test(e.value)&&nd(e)},e.sanitizeStyleAttr=e=>{const t=Zt(e.value),n=e.ownerElement.style;let o="";Object.keys(t).forEach((e=>{void 0!==n[e]&&(o+=`${e}: ${t[e]}; `)})),o=o.trim(),o?e.value=o:nd(e)},e.selectAll=No,e.selectNodeBackward=po,e.selectNodeForward=go,e.selectParentNode=(e,t)=>{let n,{$from:o,to:r}=e.selection,i=o.sharedDepth(r);return 0!=i&&(n=o.before(i),t&&t(e.tr.setSelection(st.create(e.doc,n))),!0)},e.selectTextblockEnd=Do,e.selectTextblockStart=To,e.selectedLineTextOnly=e=>{let t="",n=!1;const{selection:o,doc:r}=e,{$from:i,$to:s,from:l,to:a}=o;return i.sameParent(s)&&(r.nodesBetween(l,a,(e=>{n=n||e.isLeaf&&!e.isText})),n||(t=Ut(e))),t},e.selectedRect=ra,e.selectionCell=ql,e.selectionMarks=Dn,e.setBlockType=function(e,t=null){return function(n,o){let r=!1;for(let o=0;o<n.selection.ranges.length&&!r;o++){let{$from:{pos:i},$to:{pos:s}}=n.selection.ranges[o];n.doc.nodesBetween(i,s,((o,i)=>{if(r)return!1;if(o.isTextblock&&!o.hasMarkup(e,t))if(o.type==e)r=!0;else{let t=n.doc.resolve(i),o=t.index();r=t.parent.canReplaceWith(o,o+1,e)}}))}if(!r)return!1;if(o){let r=n.tr;for(let o=0;o<n.selection.ranges.length;o++){let{$from:{pos:i},$to:{pos:s}}=n.selection.ranges[o];r.setBlockType(i,s,e,t)}o(r.scrollIntoView())}return!0}},e.setCellAttr=function(e,t){return function(n,o){if(!Wl(n))return!1;const r=ql(n);if(r.nodeAfter.attrs[e]===t)return!1;if(o){const i=n.tr;n.selection instanceof Ql?n.selection.forEachCell(((n,o)=>{n.attrs[e]!==t&&i.setNodeMarkup(o,null,{...n.attrs,[e]:t})})):i.setNodeMarkup(r.pos,null,{...r.nodeAfter.attrs,[e]:t}),o(i)}return!0}},e.setHtml=(e,t="setHTML",n={preserveWhitespace:"full"})=>(o,r)=>r(o.tr.setSelection(new at(o.doc)).replaceSelectionWith(vn(e,o.schema,n)).setMeta("commandName",t)),e.sinkListItem=eo,e.smartQuotes=Hc,e.spacesFix=()=>new vt({key:new xt("spaces-fix"),props:{decorations:e=>{const t=[],n=e.doc;let o,r,i,s;return n.nodesBetween(0,n.content.size,((e,n,l)=>{if(e.type.isText&&(e=>yd.test(e&&e.attrs&&e.attrs.style||""))(l))for(r=gd.exec(e.text||"");null!==r;){if(o=n+r.index,i=r[0].length,r.index+i<r.input.length)for(s=0;s<=i-1;s+=2)t.push(Hs.inline(o+s,o+s+1,{style:"white-space: normal"}));r=gd.exec(e.text||"")}})),qs.create(n,t)}}}),e.splitBlock=Co,e.splitBlockAs=So,e.splitBlockKeepMarks=Mo,e.splitCell=function(e,t){const n=Ll(e.schema);return ga((({node:e})=>n[e.type.spec.tableRole]))(e,t)},e.splitCellWithType=ga,e.splitListItem=Qn,e.splitListItemKeepMarks=function(e,t){let n=Qn(e,t);return(e,t)=>n(e,t&&(n=>{let o=e.storedMarks||e.selection.$to.parentOffset&&e.selection.$from.marks();o&&n.ensureMarks(o),t(n)}))},e.strikethrough={mark:"del",altStyle:{name:"text-decoration",value:/^line-through$/i}},e.subscript={mark:"sub"},e.superscript={mark:"sup"},e.tableColumnResizeKey=Id,e.tableEditing=function({allowTableNodeSelection:e=!1}={}){return new vt({key:Hl,state:{init:()=>null,apply(e,t){const n=e.getMeta(Hl);if(null!=n)return-1==n?null:n;if(null==t||!e.docChanged)return t;const{deleted:o,pos:r}=e.mapping.mapResult(t);return o?null:r}},props:{decorations:ea,handleDOMEvents:{mousedown:Ia},createSelectionBetween:e=>null!=Hl.getState(e.state)?e.state.selection:null,handleTripleClick:Ra,handleKeyDown:Aa,handlePaste:$a},appendTransaction:(t,n,o)=>function(e,t,n){const o=(t||e).selection,r=(t||e).doc;let i,s;if(o instanceof st&&(s=o.node.type.spec.tableRole)){if("cell"==s||"header_cell"==s)i=Ql.create(r,o.from);else if("row"==s){const e=r.resolve(o.from+1);i=Ql.rowSelection(e,e)}else if(!n){const e=zl.get(o.node),t=o.from+1,n=t+e.map[e.width*e.height-1];i=Ql.create(r,t+1,n)}}else o instanceof rt&&function({$from:e,$to:t}){if(e.pos==t.pos||e.pos<t.pos-6)return!1;let n=e.pos,o=t.pos,r=e.depth;for(;r>=0&&!(e.after(r+1)<e.end(r));r--,n++);for(let e=t.depth;e>=0&&!(t.before(e+1)>t.start(e));e--,o--);return n==o&&/row|table/.test(e.node(r).type.spec.tableRole)}(o)?i=rt.create(r,o.from):o instanceof rt&&function({$from:e,$to:t}){let n,o;for(let t=e.depth;t>0;t--){const o=e.node(t);if("cell"===o.type.spec.tableRole||"header_cell"===o.type.spec.tableRole){n=o;break}}for(let e=t.depth;e>0;e--){const n=t.node(e);if("cell"===n.type.spec.tableRole||"header_cell"===n.type.spec.tableRole){o=n;break}}return n!==o&&0===t.parentOffset}(o)&&(i=rt.create(r,o.$from.start(),o.$from.end()));return i&&(t||(t=e.tr)).setSelection(i),t}(o,oa(o,n),e)})},e.tableEditingKey=Hl,e.tableNodeTypes=Ll,e.tableNodes=Fl,e.tableResizeKey=$d,e.tableResizing=()=>[Qd(),_d(),eh()],e.tableRowResizeKey=zd,e.textHighlight=function(e=kd){return new vt({key:e,state:{init:()=>null,apply(e){return e.getMeta(this.spec.key)}},props:{decorations(e){const t=(this.spec.key.getState(e)||[]).map((e=>Hs.inline(e.from,e.to,e.attrs)));return qs.create(e.doc,t)}}})},e.textHighlightKey=kd,e.textblockTypeInputRule=function(e,t,n=null){return new Rc(e,((e,o,r,i)=>{let s=e.doc.resolve(r),l=n instanceof Function?n(o):n;return s.node(-1).canReplaceWith(s.index(-1),s.indexAfter(-1),t)?e.tr.delete(r,i).setBlockType(r,r,t,l):null}))},e.toggleHeader=wa,e.toggleHeaderCell=ka,e.toggleHeaderColumn=ba,e.toggleHeaderRow=va,e.toggleInlineFormat=In,e.toggleList=Qo,e.toggleMark=function(e,t=null,n){let o=!1!==(n&&n.removeWhenPresent),r=!1!==(n&&n.enterInlineAtoms);return function(n,i){let{empty:s,$cursor:l,ranges:a}=n.selection;if(s&&!l||!function(e,t,n,o){for(let r=0;r<t.length;r++){let{$from:i,$to:s}=t[r],l=0==i.depth&&e.inlineContent&&e.type.allowsMarkType(n);if(e.nodesBetween(i.pos,s.pos,((e,t)=>{if(l||!o&&e.isAtom&&e.isInline&&t>=i.pos&&t+e.nodeSize<=s.pos)return!1;l=e.inlineContent&&e.type.allowsMarkType(n)})),l)return!0}return!1}(n.doc,a,e,r))return!1;if(i)if(l)e.isInSet(n.storedMarks||l.marks())?i(n.tr.removeStoredMark(e)):i(n.tr.addStoredMark(e.create(t)));else{let s,l=n.tr;r||(a=function(e){let t=[];for(let n=0;n<e.length;n++){let{$from:o,$to:r}=e[n];o.doc.nodesBetween(o.pos,r.pos,((e,n)=>{if(e.isAtom&&e.content.size&&e.isInline&&n>=o.pos&&n+e.nodeSize<=r.pos)return n+1>o.pos&&t.push(new tt(o,o.doc.resolve(n+1))),o=o.doc.resolve(n+1+e.content.size),!1})),o.pos<r.pos&&t.push(new tt(o,r))}return t}(a)),s=o?!a.some((t=>n.doc.rangeHasMark(t.$from.pos,t.$to.pos,e))):!a.every((t=>{let n=!1;return l.doc.nodesBetween(t.$from.pos,t.$to.pos,((o,r,i)=>{if(n)return!1;n=!e.isInSet(o.marks)&&!!i&&i.type.allowsMarkType(e)&&!(o.isText&&/^\s*$/.test(o.textBetween(Math.max(0,t.$from.pos-r),Math.min(o.nodeSize,t.$to.pos-r))))})),!n}));for(let n=0;n<a.length;n++){let{$from:o,$to:r}=a[n];if(s){let n=o.pos,i=r.pos,s=o.nodeAfter,a=r.nodeBefore,c=s&&s.isText?/^\s*/.exec(s.text)[0].length:0,d=a&&a.isText?/\s*$/.exec(a.text)[0].length:0;n+c<i&&(n+=c,i-=d),l.addMark(n,i,e.create(t))}else l.removeMark(o.pos,r.pos,e)}i(l.scrollIntoView())}return!0}},e.toggleOrderedList=function(e,t,n){return Qo(e,t,n,{listType:no.listType,...no.types})},e.toggleUnorderedList=function(e,t,n){return Qo(e,t,n,{listType:oo.listType,...oo.types})},e.trimWhitespace=(e,t=ln)=>{const n=t.join("|");return e.replace(new RegExp("\\s*(<(?:"+n+")(?:\\s[^>]*?)?>)","g"),"$1").replace(new RegExp("(<\\/(?:"+n+")(?:\\s[^>]*?)?>)\\s*","g"),"$1")},e.underline=qc,e.undo=Ac,e.undoDepth=function(e){let t=Mc.getState(e);return t?t.done.eventCount:0},e.undoInputRule=Ic,e.undoNoScroll=Dc,e.updateColumnsOnResize=Fa,e.wrapIn=Eo,e.wrapInList=Gn,e.wrapRangeInList=Yn,e.wrappingInputRule=function(e,t,n=null,o){return new Rc(e,((e,r,i,s)=>{let l=n instanceof Function?n(r):n,a=e.tr.delete(i,s),c=a.doc.resolve(i).blockRange(),d=c&&De(c,t,l);if(!d)return null;a.wrap(c,d);let h=a.doc.resolve(i-1).nodeBefore;return h&&h.type==t&&ze(a.doc,i-1)&&(!o||o(r,h))&&a.join(i-1),a}))}}));
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).KendoEditorCommon={})}(this,(function(e){"use strict";function t(e){this.content=e}function n(e,t,o){for(let r=0;;r++){if(r==e.childCount||r==t.childCount)return e.childCount==t.childCount?null:o;let i=e.child(r),s=t.child(r);if(i!=s){if(!i.sameMarkup(s))return o;if(i.isText&&i.text!=s.text){for(let e=0;i.text[e]==s.text[e];e++)o++;return o}if(i.content.size||s.content.size){let e=n(i.content,s.content,o+1);if(null!=e)return e}o+=i.nodeSize}else o+=i.nodeSize}}function o(e,t,n,r){for(let i=e.childCount,s=t.childCount;;){if(0==i||0==s)return i==s?null:{a:n,b:r};let l=e.child(--i),a=t.child(--s),c=l.nodeSize;if(l!=a){if(!l.sameMarkup(a))return{a:n,b:r};if(l.isText&&l.text!=a.text){let e=0,t=Math.min(l.text.length,a.text.length);for(;e<t&&l.text[l.text.length-e-1]==a.text[a.text.length-e-1];)e++,n--,r--;return{a:n,b:r}}if(l.content.size||a.content.size){let e=o(l.content,a.content,n-1,r-1);if(e)return e}n-=c,r-=c}else n-=c,r-=c}}t.prototype={constructor:t,find:function(e){for(var t=0;t<this.content.length;t+=2)if(this.content[t]===e)return t;return-1},get:function(e){var t=this.find(e);return-1==t?void 0:this.content[t+1]},update:function(e,n,o){var r=o&&o!=e?this.remove(o):this,i=r.find(e),s=r.content.slice();return-1==i?s.push(o||e,n):(s[i+1]=n,o&&(s[i]=o)),new t(s)},remove:function(e){var n=this.find(e);if(-1==n)return this;var o=this.content.slice();return o.splice(n,2),new t(o)},addToStart:function(e,n){return new t([e,n].concat(this.remove(e).content))},addToEnd:function(e,n){var o=this.remove(e).content.slice();return o.push(e,n),new t(o)},addBefore:function(e,n,o){var r=this.remove(n),i=r.content.slice(),s=r.find(e);return i.splice(-1==s?i.length:s,0,n,o),new t(i)},forEach:function(e){for(var t=0;t<this.content.length;t+=2)e(this.content[t],this.content[t+1])},prepend:function(e){return(e=t.from(e)).size?new t(e.content.concat(this.subtract(e).content)):this},append:function(e){return(e=t.from(e)).size?new t(this.subtract(e).content.concat(e.content)):this},subtract:function(e){var n=this;e=t.from(e);for(var o=0;o<e.content.length;o+=2)n=n.remove(e.content[o]);return n},toObject:function(){var e={};return this.forEach((function(t,n){e[t]=n})),e},get size(){return this.content.length>>1}},t.from=function(e){if(e instanceof t)return e;var n=[];if(e)for(var o in e)n.push(o,e[o]);return new t(n)};class r{constructor(e,t){if(this.content=e,this.size=t||0,null==t)for(let t=0;t<e.length;t++)this.size+=e[t].nodeSize}nodesBetween(e,t,n,o=0,r){for(let i=0,s=0;s<t;i++){let l=this.content[i],a=s+l.nodeSize;if(a>e&&!1!==n(l,o+s,r||null,i)&&l.content.size){let r=s+1;l.nodesBetween(Math.max(0,e-r),Math.min(l.content.size,t-r),n,o+r)}s=a}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,n,o){let r="",i=!0;return this.nodesBetween(e,t,((s,l)=>{let a=s.isText?s.text.slice(Math.max(e,l)-l,t-l):s.isLeaf?o?"function"==typeof o?o(s):o:s.type.spec.leafText?s.type.spec.leafText(s):"":"";s.isBlock&&(s.isLeaf&&a||s.isTextblock)&&n&&(i?i=!1:r+=n),r+=a}),0),r}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,n=e.firstChild,o=this.content.slice(),i=0;for(t.isText&&t.sameMarkup(n)&&(o[o.length-1]=t.withText(t.text+n.text),i=1);i<e.content.length;i++)o.push(e.content[i]);return new r(o,this.size+e.size)}cut(e,t=this.size){if(0==e&&t==this.size)return this;let n=[],o=0;if(t>e)for(let r=0,i=0;i<t;r++){let s=this.content[r],l=i+s.nodeSize;l>e&&((i<e||l>t)&&(s=s.isText?s.cut(Math.max(0,e-i),Math.min(s.text.length,t-i)):s.cut(Math.max(0,e-i-1),Math.min(s.content.size,t-i-1))),n.push(s),o+=s.nodeSize),i=l}return new r(n,o)}cutByIndex(e,t){return e==t?r.empty:0==e&&t==this.content.length?this:new r(this.content.slice(e,t))}replaceChild(e,t){let n=this.content[e];if(n==t)return this;let o=this.content.slice(),i=this.size+t.nodeSize-n.nodeSize;return o[e]=t,new r(o,i)}addToStart(e){return new r([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new r(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw new RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,n=0;t<this.content.length;t++){let o=this.content[t];e(o,n,t),n+=o.nodeSize}}findDiffStart(e,t=0){return n(this,e,t)}findDiffEnd(e,t=this.size,n=e.size){return o(this,e,t,n)}findIndex(e,t=-1){if(0==e)return s(0,e);if(e==this.size)return s(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let n=0,o=0;;n++){let r=o+this.child(n).nodeSize;if(r>=e)return r==e||t>0?s(n+1,r):s(n,o);o=r}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map((e=>e.toJSON())):null}static fromJSON(e,t){if(!t)return r.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new r(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return r.empty;let t,n=0;for(let o=0;o<e.length;o++){let r=e[o];n+=r.nodeSize,o&&r.isText&&e[o-1].sameMarkup(r)?(t||(t=e.slice(0,o)),t[t.length-1]=r.withText(t[t.length-1].text+r.text)):t&&t.push(r)}return new r(t||e,n)}static from(e){if(!e)return r.empty;if(e instanceof r)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new r([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}r.empty=new r([],0);const i={index:0,offset:0};function s(e,t){return i.index=e,i.offset=t,i}function l(e,t){if(e===t)return!0;if(!e||"object"!=typeof e||!t||"object"!=typeof t)return!1;let n=Array.isArray(e);if(Array.isArray(t)!=n)return!1;if(n){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!l(e[n],t[n]))return!1}else{for(let n in e)if(!(n in t)||!l(e[n],t[n]))return!1;for(let n in t)if(!(n in e))return!1}return!0}class a{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,n=!1;for(let o=0;o<e.length;o++){let r=e[o];if(this.eq(r))return e;if(this.type.excludes(r.type))t||(t=e.slice(0,o));else{if(r.type.excludes(this.type))return e;!n&&r.type.rank>this.type.rank&&(t||(t=e.slice(0,o)),t.push(this),n=!0),t&&t.push(r)}}return t||(t=e.slice()),n||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&l(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Mark.fromJSON");let n=e.marks[t.type];if(!n)throw new RangeError(`There is no mark type ${t.type} in this schema`);let o=n.create(t.attrs);return n.checkAttrs(o.attrs),o}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].eq(t[n]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&0==e.length)return a.none;if(e instanceof a)return[e];let t=e.slice();return t.sort(((e,t)=>e.type.rank-t.type.rank)),t}}a.none=[];class c extends Error{}class d{constructor(e,t,n){this.content=e,this.openStart=t,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let n=p(this.content,e+this.openStart,t);return n&&new d(n,this.openStart,this.openEnd)}removeBetween(e,t){return new d(h(this.content,e+this.openStart,t+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,t){if(!t)return d.empty;let n=t.openStart||0,o=t.openEnd||0;if("number"!=typeof n||"number"!=typeof o)throw new RangeError("Invalid input for Slice.fromJSON");return new d(r.fromJSON(e,t.content),n,o)}static maxOpen(e,t=!0){let n=0,o=0;for(let o=e.firstChild;o&&!o.isLeaf&&(t||!o.type.spec.isolating);o=o.firstChild)n++;for(let n=e.lastChild;n&&!n.isLeaf&&(t||!n.type.spec.isolating);n=n.lastChild)o++;return new d(e,n,o)}}function h(e,t,n){let{index:o,offset:r}=e.findIndex(t),i=e.maybeChild(o),{index:s,offset:l}=e.findIndex(n);if(r==t||i.isText){if(l!=n&&!e.child(s).isText)throw new RangeError("Removing non-flat range");return e.cut(0,t).append(e.cut(n))}if(o!=s)throw new RangeError("Removing non-flat range");return e.replaceChild(o,i.copy(h(i.content,t-r-1,n-r-1)))}function p(e,t,n,o){let{index:r,offset:i}=e.findIndex(t),s=e.maybeChild(r);if(i==t||s.isText)return e.cut(0,t).append(n).append(e.cut(t));let l=p(s.content,t-i-1,n);return l&&e.replaceChild(r,s.copy(l))}function u(e,t,n){if(n.openStart>e.depth)throw new c("Inserted content deeper than insertion position");if(e.depth-n.openStart!=t.depth-n.openEnd)throw new c("Inconsistent open depths");return f(e,t,n,0)}function f(e,t,n,o){let i=e.index(o),s=e.node(o);if(i==t.index(o)&&o<e.depth-n.openStart){let r=f(e,t,n,o+1);return s.copy(s.content.replaceChild(i,r))}if(n.content.size){if(n.openStart||n.openEnd||e.depth!=o||t.depth!=o){let{start:i,end:l}=function(e,t){let n=t.depth-e.openStart,o=t.node(n).copy(e.content);for(let e=n-1;e>=0;e--)o=t.node(e).copy(r.from(o));return{start:o.resolveNoCache(e.openStart+n),end:o.resolveNoCache(o.content.size-e.openEnd-n)}}(n,e);return v(s,b(e,i,l,t,o))}{let o=e.parent,r=o.content;return v(o,r.cut(0,e.parentOffset).append(n.content).append(r.cut(t.parentOffset)))}}return v(s,k(e,t,o))}function m(e,t){if(!t.type.compatibleContent(e.type))throw new c("Cannot join "+t.type.name+" onto "+e.type.name)}function g(e,t,n){let o=e.node(n);return m(o,t.node(n)),o}function y(e,t){let n=t.length-1;n>=0&&e.isText&&e.sameMarkup(t[n])?t[n]=e.withText(t[n].text+e.text):t.push(e)}function w(e,t,n,o){let r=(t||e).node(n),i=0,s=t?t.index(n):r.childCount;e&&(i=e.index(n),e.depth>n?i++:e.textOffset&&(y(e.nodeAfter,o),i++));for(let e=i;e<s;e++)y(r.child(e),o);t&&t.depth==n&&t.textOffset&&y(t.nodeBefore,o)}function v(e,t){return e.type.checkContent(t),e.copy(t)}function b(e,t,n,o,i){let s=e.depth>i&&g(e,t,i+1),l=o.depth>i&&g(n,o,i+1),a=[];return w(null,e,i,a),s&&l&&t.index(i)==n.index(i)?(m(s,l),y(v(s,b(e,t,n,o,i+1)),a)):(s&&y(v(s,k(e,t,i+1)),a),w(t,n,i,a),l&&y(v(l,k(n,o,i+1)),a)),w(o,null,i,a),new r(a)}function k(e,t,n){let o=[];if(w(null,e,n,o),e.depth>n){y(v(g(e,t,n+1),k(e,t,n+1)),o)}return w(t,null,n,o),new r(o)}d.empty=new d(r.empty,0,0);class x{constructor(e,t,n){this.pos=e,this.path=t,this.parentOffset=n,this.depth=t.length/3-1}resolveDepth(e){return null==e?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[3*this.resolveDepth(e)]}index(e){return this.path[3*this.resolveDepth(e)+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e!=this.depth||this.textOffset?1:0)}start(e){return 0==(e=this.resolveDepth(e))?0:this.path[3*e-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(!(e=this.resolveDepth(e)))throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[3*e-1]}after(e){if(!(e=this.resolveDepth(e)))throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[3*e-1]+this.path[3*e].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let n=this.pos-this.path[this.path.length-1],o=e.child(t);return n?e.child(t).cut(n):o}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):0==e?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let n=this.path[3*t],o=0==t?0:this.path[3*t-1]+1;for(let t=0;t<e;t++)o+=n.child(t).nodeSize;return o}marks(){let e=this.parent,t=this.index();if(0==e.content.size)return a.none;if(this.textOffset)return e.child(t).marks;let n=e.maybeChild(t-1),o=e.maybeChild(t);if(!n){let e=n;n=o,o=e}let r=n.marks;for(var i=0;i<r.length;i++)!1!==r[i].type.spec.inclusive||o&&r[i].isInSet(o.marks)||(r=r[i--].removeFromSet(r));return r}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let n=t.marks,o=e.parent.maybeChild(e.index());for(var r=0;r<n.length;r++)!1!==n[r].type.spec.inclusive||o&&n[r].isInSet(o.marks)||(n=n[r--].removeFromSet(n));return n}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let n=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);n>=0;n--)if(e.pos<=this.end(n)&&(!t||t(this.node(n))))return new N(this,e,n);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset}static resolve(e,t){if(!(t>=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let n=[],o=0,r=t;for(let t=e;;){let{index:e,offset:i}=t.content.findIndex(r),s=r-i;if(n.push(t,e,o+i),!s)break;if(t=t.child(e),t.isText)break;r=s-1,o+=i+1}return new x(t,n,r)}static resolveCached(e,t){let n=M.get(e);if(n)for(let e=0;e<n.elts.length;e++){let o=n.elts[e];if(o.pos==t)return o}else M.set(e,n=new S);let o=n.elts[n.i]=x.resolve(e,t);return n.i=(n.i+1)%C,o}}class S{constructor(){this.elts=[],this.i=0}}const C=12,M=new WeakMap;class N{constructor(e,t,n){this.$from=e,this.$to=t,this.depth=n}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const O=Object.create(null);let A=class e{constructor(e,t,n,o=a.none){this.type=e,this.attrs=t,this.marks=o,this.content=n||r.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,n,o=0){this.content.nodesBetween(e,t,n,o,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,t,n,o){return this.content.textBetween(e,t,n,o)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,n){return this.type==e&&l(this.attrs,t||e.defaultAttrs||O)&&a.sameSet(this.marks,n||a.none)}copy(t=null){return t==this.content?this:new e(this.type,this.attrs,t,this.marks)}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.content,t)}cut(e,t=this.content.size){return 0==e&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,n=!1){if(e==t)return d.empty;let o=this.resolve(e),r=this.resolve(t),i=n?0:o.sharedDepth(t),s=o.start(i),l=o.node(i).content.cut(o.pos-s,r.pos-s);return new d(l,o.depth-i,r.depth-i)}replace(e,t,n){return u(this.resolve(e),this.resolve(t),n)}nodeAt(e){for(let t=this;;){let{index:n,offset:o}=t.content.findIndex(e);if(t=t.maybeChild(n),!t)return null;if(o==e||t.isText)return t;e-=o+1}}childAfter(e){let{index:t,offset:n}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:n}}childBefore(e){if(0==e)return{node:null,index:0,offset:0};let{index:t,offset:n}=this.content.findIndex(e);if(n<e)return{node:this.content.child(t),index:t,offset:n};let o=this.content.child(t-1);return{node:o,index:t-1,offset:n-o.nodeSize}}resolve(e){return x.resolveCached(this,e)}resolveNoCache(e){return x.resolve(this,e)}rangeHasMark(e,t,n){let o=!1;return t>e&&this.nodesBetween(e,t,(e=>(n.isInSet(e.marks)&&(o=!0),!o))),o}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),D(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,n=r.empty,o=0,i=n.childCount){let s=this.contentMatchAt(e).matchFragment(n,o,i),l=s&&s.matchFragment(this.content,t);if(!l||!l.validEnd)return!1;for(let e=o;e<i;e++)if(!this.type.allowsMarks(n.child(e).marks))return!1;return!0}canReplaceWith(e,t,n,o){if(o&&!this.type.allowsMarks(o))return!1;let r=this.contentMatchAt(e).matchType(n),i=r&&r.matchFragment(this.content,t);return!!i&&i.validEnd}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=a.none;for(let t=0;t<this.marks.length;t++){let n=this.marks[t];n.type.checkAttrs(n.attrs),e=n.addToSet(e)}if(!a.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map((e=>e.type.name))}`);this.content.forEach((e=>e.check()))}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map((e=>e.toJSON()))),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let n;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");n=t.marks.map(e.markFromJSON)}if("text"==t.type){if("string"!=typeof t.text)throw new RangeError("Invalid text node in JSON");return e.text(t.text,n)}let o=r.fromJSON(e,t.content),i=e.nodeType(t.type).create(t.attrs,o,n);return i.type.checkAttrs(i.attrs),i}};A.prototype.text=void 0;class T extends A{constructor(e,t,n,o){if(super(e,t,null,o),!n)throw new RangeError("Empty text nodes are not allowed");this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):D(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new T(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new T(this.type,this.attrs,e,this.marks)}cut(e=0,t=this.text.length){return 0==e&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function D(e,t){for(let n=e.length-1;n>=0;n--)t=e[n].type.name+"("+t+")";return t}class E{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let n=new R(e,t);if(null==n.next)return E.empty;let o=$(n);n.next&&n.err("Unexpected trailing text");let r=function(e){let t=Object.create(null);return n(F(e,0));function n(o){let r=[];o.forEach((t=>{e[t].forEach((({term:t,to:n})=>{if(!t)return;let o;for(let e=0;e<r.length;e++)r[e][0]==t&&(o=r[e][1]);F(e,n).forEach((e=>{o||r.push([t,o=[]]),-1==o.indexOf(e)&&o.push(e)}))}))}));let i=t[o.join(",")]=new E(o.indexOf(e.length-1)>-1);for(let e=0;e<r.length;e++){let o=r[e][1].sort(V);i.next.push({type:r[e][0],next:t[o.join(",")]||n(o)})}return i}}(function(e){let t=[[]];return r(i(e,0),n()),t;function n(){return t.push([])-1}function o(e,n,o){let r={term:o,to:n};return t[e].push(r),r}function r(e,t){e.forEach((e=>e.to=t))}function i(e,t){if("choice"==e.type)return e.exprs.reduce(((e,n)=>e.concat(i(n,t))),[]);if("seq"!=e.type){if("star"==e.type){let s=n();return o(t,s),r(i(e.expr,s),s),[o(s)]}if("plus"==e.type){let s=n();return r(i(e.expr,t),s),r(i(e.expr,s),s),[o(s)]}if("opt"==e.type)return[o(t)].concat(i(e.expr,t));if("range"==e.type){let s=t;for(let t=0;t<e.min;t++){let t=n();r(i(e.expr,s),t),s=t}if(-1==e.max)r(i(e.expr,s),s);else for(let t=e.min;t<e.max;t++){let t=n();o(s,t),r(i(e.expr,s),t),s=t}return[o(s)]}if("name"==e.type)return[o(t,void 0,e.value)];throw new Error("Unknown expr type")}for(let o=0;;o++){let s=i(e.exprs[o],t);if(o==e.exprs.length-1)return s;r(s,t=n())}}}(o));return function(e,t){for(let n=0,o=[e];n<o.length;n++){let e=o[n],r=!e.validEnd,i=[];for(let t=0;t<e.next.length;t++){let{type:n,next:s}=e.next[t];i.push(n.name),!r||n.isText||n.hasRequiredAttrs()||(r=!1),-1==o.indexOf(s)&&o.push(s)}r&&t.err("Only non-generatable nodes ("+i.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}(r,n),r}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,n=e.childCount){let o=this;for(let r=t;o&&r<n;r++)o=o.matchType(e.child(r).type);return o}get inlineContent(){return 0!=this.next.length&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!t.isText&&!t.hasRequiredAttrs())return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let n=0;n<e.next.length;n++)if(this.next[t].type==e.next[n].type)return!0;return!1}fillBefore(e,t=!1,n=0){let o=[this];return function i(s,l){let a=s.matchFragment(e,n);if(a&&(!t||a.validEnd))return r.from(l.map((e=>e.createAndFill())));for(let e=0;e<s.next.length;e++){let{type:t,next:n}=s.next[e];if(!t.isText&&!t.hasRequiredAttrs()&&-1==o.indexOf(n)){o.push(n);let e=i(n,l.concat(t));if(e)return e}}return null}(this,[])}findWrapping(e){for(let t=0;t<this.wrapCache.length;t+=2)if(this.wrapCache[t]==e)return this.wrapCache[t+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),n=[{match:this,type:null,via:null}];for(;n.length;){let o=n.shift(),r=o.match;if(r.matchType(e)){let e=[];for(let t=o;t.type;t=t.via)e.push(t.type);return e.reverse()}for(let e=0;e<r.next.length;e++){let{type:i,next:s}=r.next[e];i.isLeaf||i.hasRequiredAttrs()||i.name in t||o.type&&!s.validEnd||(n.push({match:i.contentMatch,type:i,via:o}),t[i.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];return function t(n){e.push(n);for(let o=0;o<n.next.length;o++)-1==e.indexOf(n.next[o].next)&&t(n.next[o].next)}(this),e.map(((t,n)=>{let o=n+(t.validEnd?"*":" ")+" ";for(let n=0;n<t.next.length;n++)o+=(n?", ":"")+t.next[n].type.name+"->"+e.indexOf(t.next[n].next);return o})).join("\n")}}E.empty=new E(!0);class R{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),""==this.tokens[this.tokens.length-1]&&this.tokens.pop(),""==this.tokens[0]&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}function $(e){let t=[];do{t.push(I(e))}while(e.eat("|"));return 1==t.length?t[0]:{type:"choice",exprs:t}}function I(e){let t=[];do{t.push(z(e))}while(e.next&&")"!=e.next&&"|"!=e.next);return 1==t.length?t[0]:{type:"seq",exprs:t}}function z(e){let t=function(e){if(e.eat("(")){let t=$(e);return e.eat(")")||e.err("Missing closing paren"),t}if(!/\W/.test(e.next)){let t=function(e,t){let n=e.nodeTypes,o=n[t];if(o)return[o];let r=[];for(let e in n){let o=n[e];o.isInGroup(t)&&r.push(o)}0==r.length&&e.err("No node type or group '"+t+"' found");return r}(e,e.next).map((t=>(null==e.inline?e.inline=t.isInline:e.inline!=t.isInline&&e.err("Mixing inline and block content"),{type:"name",value:t})));return e.pos++,1==t.length?t[0]:{type:"choice",exprs:t}}e.err("Unexpected token '"+e.next+"'")}(e);for(;;)if(e.eat("+"))t={type:"plus",expr:t};else if(e.eat("*"))t={type:"star",expr:t};else if(e.eat("?"))t={type:"opt",expr:t};else{if(!e.eat("{"))break;t=P(e,t)}return t}function B(e){/\D/.test(e.next)&&e.err("Expected number, got '"+e.next+"'");let t=Number(e.next);return e.pos++,t}function P(e,t){let n=B(e),o=n;return e.eat(",")&&(o="}"!=e.next?B(e):-1),e.eat("}")||e.err("Unclosed braced range"),{type:"range",min:n,max:o,expr:t}}function V(e,t){return t-e}function F(e,t){let n=[];return function t(o){let r=e[o];if(1==r.length&&!r[0].term)return t(r[0].to);n.push(o);for(let e=0;e<r.length;e++){let{term:o,to:i}=r[e];o||-1!=n.indexOf(i)||t(i)}}(t),n.sort(V)}function L(e){let t=Object.create(null);for(let n in e){let o=e[n];if(!o.hasDefault)return null;t[n]=o.default}return t}function H(e,t){let n=Object.create(null);for(let o in e){let r=t&&t[o];if(void 0===r){let t=e[o];if(!t.hasDefault)throw new RangeError("No value supplied for attribute "+o);r=t.default}n[o]=r}return n}function _(e,t,n,o){for(let o in t)if(!(o in e))throw new RangeError(`Unsupported attribute ${o} for ${n} of type ${o}`);for(let n in e){let o=e[n];o.validate&&o.validate(t[n])}}function W(e,t){let n=Object.create(null);if(t)for(let o in t)n[o]=new J(e,o,t[o]);return n}let q=class e{constructor(e,t,n){this.name=e,this.schema=t,this.spec=n,this.markSet=null,this.groups=n.group?n.group.split(" "):[],this.attrs=W(e,n.attrs),this.defaultAttrs=L(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(n.inline||"text"==e),this.isText="text"==e}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==E.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:H(this.attrs,e)}create(e=null,t,n){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new A(this,this.computeAttrs(e),r.from(t),a.setFrom(n))}createChecked(e=null,t,n){return t=r.from(t),this.checkContent(t),new A(this,this.computeAttrs(e),t,a.setFrom(n))}createAndFill(e=null,t,n){if(e=this.computeAttrs(e),(t=r.from(t)).size){let e=this.contentMatch.fillBefore(t);if(!e)return null;t=e.append(t)}let o=this.contentMatch.matchFragment(t),i=o&&o.fillBefore(r.empty,!0);return i?new A(this,e,t.append(i),a.setFrom(n)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let t=0;t<e.childCount;t++)if(!this.allowsMarks(e.child(t).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){_(this.attrs,e,"node",this.name)}allowsMarkType(e){return null==this.markSet||this.markSet.indexOf(e)>-1}allowsMarks(e){if(null==this.markSet)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(null==this.markSet)return e;let t;for(let n=0;n<e.length;n++)this.allowsMarkType(e[n].type)?t&&t.push(e[n]):t||(t=e.slice(0,n));return t?t.length?t:a.none:e}static compile(t,n){let o=Object.create(null);t.forEach(((t,r)=>o[t]=new e(t,n,r)));let r=n.spec.topNode||"doc";if(!o[r])throw new RangeError("Schema is missing its top node type ('"+r+"')");if(!o.text)throw new RangeError("Every schema needs a 'text' type");for(let e in o.text.attrs)throw new RangeError("The text node type should not have attributes");return o}};class J{constructor(e,t,n){this.hasDefault=Object.prototype.hasOwnProperty.call(n,"default"),this.default=n.default,this.validate="string"==typeof n.validate?function(e,t,n){let o=n.split("|");return n=>{let r=null===n?"null":typeof n;if(o.indexOf(r)<0)throw new RangeError(`Expected value of type ${o} for attribute ${t} on type ${e}, got ${r}`)}}(e,t,n.validate):n.validate}get isRequired(){return!this.hasDefault}}class j{constructor(e,t,n,o){this.name=e,this.rank=t,this.schema=n,this.spec=o,this.attrs=W(e,o.attrs),this.excluded=null;let r=L(this.attrs);this.instance=r?new a(this,r):null}create(e=null){return!e&&this.instance?this.instance:new a(this,H(this.attrs,e))}static compile(e,t){let n=Object.create(null),o=0;return e.forEach(((e,r)=>n[e]=new j(e,o++,t,r))),n}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}checkAttrs(e){_(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class K{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let n=this.spec={};for(let t in e)n[t]=e[t];n.nodes=t.from(e.nodes),n.marks=t.from(e.marks||{}),this.nodes=q.compile(this.spec.nodes,this),this.marks=j.compile(this.spec.marks,this);let o=Object.create(null);for(let e in this.nodes){if(e in this.marks)throw new RangeError(e+" can not be both a node and a mark");let t=this.nodes[e],n=t.spec.content||"",r=t.spec.marks;if(t.contentMatch=o[n]||(o[n]=E.parse(n,this.nodes)),t.inlineContent=t.contentMatch.inlineContent,t.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!t.isInline||!t.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=t}t.markSet="_"==r?null:r?X(this,r.split(" ")):""!=r&&t.inlineContent?null:[]}for(let e in this.marks){let t=this.marks[e],n=t.spec.excludes;t.excluded=null==n?[t]:""==n?[]:X(this,n.split(" "))}this.nodeFromJSON=this.nodeFromJSON.bind(this),this.markFromJSON=this.markFromJSON.bind(this),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,n,o){if("string"==typeof e)e=this.nodeType(e);else{if(!(e instanceof q))throw new RangeError("Invalid node type: "+e);if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}return e.createChecked(t,n,o)}text(e,t){let n=this.nodes.text;return new T(n,n.defaultAttrs,e,a.setFrom(t))}mark(e,t){return"string"==typeof e&&(e=this.marks[e]),e.create(t)}nodeFromJSON(e){return A.fromJSON(this,e)}markFromJSON(e){return a.fromJSON(this,e)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}}function X(e,t){let n=[];for(let o=0;o<t.length;o++){let r=t[o],i=e.marks[r],s=i;if(i)n.push(i);else for(let t in e.marks){let o=e.marks[t];("_"==r||o.spec.group&&o.spec.group.split(" ").indexOf(r)>-1)&&n.push(s=o)}if(!s)throw new SyntaxError("Unknown mark type: '"+t[o]+"'")}return n}class U{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let n=this.matchedStyles=[];t.forEach((e=>{if(function(e){return null!=e.tag}(e))this.tags.push(e);else if(function(e){return null!=e.style}(e)){let t=/[^=]*/.exec(e.style)[0];n.indexOf(t)<0&&n.push(t),this.styles.push(e)}})),this.normalizeLists=!this.tags.some((t=>{if(!/^(ul|ol)\b/.test(t.tag)||!t.node)return!1;let n=e.nodes[t.node];return n.contentMatch.matchType(n)}))}parse(e,t={}){let n=new te(this,t,!1);return n.addAll(e,a.none,t.from,t.to),n.finish()}parseSlice(e,t={}){let n=new te(this,t,!0);return n.addAll(e,a.none,t.from,t.to),d.maxOpen(n.finish())}matchTag(e,t,n){for(let o=n?this.tags.indexOf(n)+1:0;o<this.tags.length;o++){let n=this.tags[o];if(ne(e,n.tag)&&(void 0===n.namespace||e.namespaceURI==n.namespace)&&(!n.context||t.matchesContext(n.context))){if(n.getAttrs){let t=n.getAttrs(e);if(!1===t)continue;n.attrs=t||void 0}return n}}}matchStyle(e,t,n,o){for(let r=o?this.styles.indexOf(o)+1:0;r<this.styles.length;r++){let o=this.styles[r],i=o.style;if(!(0!=i.indexOf(e)||o.context&&!n.matchesContext(o.context)||i.length>e.length&&(61!=i.charCodeAt(e.length)||i.slice(e.length+1)!=t))){if(o.getAttrs){let e=o.getAttrs(t);if(!1===e)continue;o.attrs=e||void 0}return o}}}static schemaRules(e){let t=[];function n(e){let n=null==e.priority?50:e.priority,o=0;for(;o<t.length;o++){let e=t[o];if((null==e.priority?50:e.priority)<n)break}t.splice(o,0,e)}for(let t in e.marks){let o=e.marks[t].spec.parseDOM;o&&o.forEach((e=>{n(e=oe(e)),e.mark||e.ignore||e.clearMark||(e.mark=t)}))}for(let t in e.nodes){let o=e.nodes[t].spec.parseDOM;o&&o.forEach((e=>{n(e=oe(e)),e.node||e.ignore||e.mark||(e.node=t)}))}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new U(e,U.schemaRules(e)))}}const G={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},Y={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Q={ol:!0,ul:!0};function Z(e,t,n){return null!=t?(t?1:0)|("full"===t?2:0):e&&"pre"==e.whitespace?3:-5&n}class ee{constructor(e,t,n,o,r,i){this.type=e,this.attrs=t,this.marks=n,this.solid=o,this.options=i,this.content=[],this.activeMarks=a.none,this.match=r||(4&i?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(r.from(e));if(!t){let t,n=this.type.contentMatch;return(t=n.findWrapping(e.type))?(this.match=n,t):null}this.match=this.type.contentMatch.matchFragment(t)}return this.match.findWrapping(e.type)}finish(e){if(!(1&this.options)){let e,t=this.content[this.content.length-1];if(t&&t.isText&&(e=/[ \t\r\n\u000c]+$/.exec(t.text))){let n=t;t.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))}}let t=r.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(r.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!G.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class te{constructor(e,t,n){this.parser=e,this.options=t,this.isOpen=n,this.open=0,this.localPreserveWS=!1;let o,r=t.topNode,i=Z(null,t.preserveWhitespace,0)|(n?4:0);o=r?new ee(r.type,r.attrs,a.none,!0,t.topMatch||r.type.contentMatch,i):new ee(n?null:e.schema.topNodeType,null,a.none,!0,null,i),this.nodes=[o],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){3==e.nodeType?this.addTextNode(e,t):1==e.nodeType&&this.addElement(e,t)}addTextNode(e,t){let n=e.nodeValue,o=this.top,r=2&o.options?"full":this.localPreserveWS||(1&o.options)>0;if("full"===r||o.inlineContext(e)||/[^ \t\r\n\u000c]/.test(n)){if(r)n="full"!==r?n.replace(/\r?\n|\r/g," "):n.replace(/\r\n?/g,"\n");else if(n=n.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(n)&&this.open==this.nodes.length-1){let t=o.content[o.content.length-1],r=e.previousSibling;(!t||r&&"BR"==r.nodeName||t.isText&&/[ \t\r\n\u000c]$/.test(t.text))&&(n=n.slice(1))}n&&this.insertNode(this.parser.schema.text(n),t),this.findInText(e)}else this.findInside(e)}addElement(e,t,n){let o=this.localPreserveWS,r=this.top;("PRE"==e.tagName||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let i,s=e.nodeName.toLowerCase();Q.hasOwnProperty(s)&&this.parser.normalizeLists&&function(e){for(let t=e.firstChild,n=null;t;t=t.nextSibling){let e=1==t.nodeType?t.nodeName.toLowerCase():null;e&&Q.hasOwnProperty(e)&&n?(n.appendChild(t),t=n):"li"==e?n=t:e&&(n=null)}}(e);let l=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(i=this.parser.matchTag(e,this,n));e:if(l?l.ignore:Y.hasOwnProperty(s))this.findInside(e),this.ignoreFallback(e,t);else if(!l||l.skip||l.closeParent){l&&l.closeParent?this.open=Math.max(0,this.open-1):l&&l.skip.nodeType&&(e=l.skip);let n,o=this.needsBlock;if(G.hasOwnProperty(s))r.content.length&&r.content[0].isInline&&this.open&&(this.open--,r=this.top),n=!0,r.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break e}let i=l&&l.skip?t:this.readStyles(e,t);i&&this.addAll(e,i),n&&this.sync(r),this.needsBlock=o}else{let n=this.readStyles(e,t);n&&this.addElementByRule(e,l,n,!1===l.consuming?i:void 0)}this.localPreserveWS=o}leafFallback(e,t){"BR"==e.nodeName&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode("\n"),t)}ignoreFallback(e,t){"BR"!=e.nodeName||this.top.type&&this.top.type.inlineContent||this.findPlace(this.parser.schema.text("-"),t)}readStyles(e,t){let n=e.style;if(n&&n.length)for(let e=0;e<this.parser.matchedStyles.length;e++){let o=this.parser.matchedStyles[e],r=n.getPropertyValue(o);if(r)for(let e;;){let n=this.parser.matchStyle(o,r,this,e);if(!n)break;if(n.ignore)return null;if(t=n.clearMark?t.filter((e=>!n.clearMark(e))):t.concat(this.parser.schema.marks[n.mark].create(n.attrs)),!1!==n.consuming)break;e=n}}return t}addElementByRule(e,t,n,o){let r,i;if(t.node)if(i=this.parser.schema.nodes[t.node],i.isLeaf)this.insertNode(i.create(t.attrs),n)||this.leafFallback(e,n);else{let e=this.enter(i,t.attrs||null,n,t.preserveWhitespace);e&&(r=!0,n=e)}else{let e=this.parser.schema.marks[t.mark];n=n.concat(e.create(t.attrs))}let s=this.top;if(i&&i.isLeaf)this.findInside(e);else if(o)this.addElement(e,n,o);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach((e=>this.insertNode(e,n)));else{let o=e;"string"==typeof t.contentElement?o=e.querySelector(t.contentElement):"function"==typeof t.contentElement?o=t.contentElement(e):t.contentElement&&(o=t.contentElement),this.findAround(e,o,!0),this.addAll(o,n),this.findAround(e,o,!1)}r&&this.sync(s)&&this.open--}addAll(e,t,n,o){let r=n||0;for(let i=n?e.childNodes[n]:e.firstChild,s=null==o?null:e.childNodes[o];i!=s;i=i.nextSibling,++r)this.findAtPoint(e,r),this.addDOM(i,t);this.findAtPoint(e,r)}findPlace(e,t){let n,o;for(let t=this.open;t>=0;t--){let r=this.nodes[t],i=r.findWrapping(e);if(i&&(!n||n.length>i.length)&&(n=i,o=r,!i.length))break;if(r.solid)break}if(!n)return null;this.sync(o);for(let e=0;e<n.length;e++)t=this.enterInner(n[e],null,t,!1);return t}insertNode(e,t){if(e.isInline&&this.needsBlock&&!this.top.type){let e=this.textblockFromContext();e&&(t=this.enterInner(e,null,t))}let n=this.findPlace(e,t);if(n){this.closeExtra();let t=this.top;t.match&&(t.match=t.match.matchType(e.type));let o=a.none;for(let r of n.concat(e.marks))(t.type?t.type.allowsMarkType(r.type):re(r.type,e.type))&&(o=r.addToSet(o));return t.content.push(e.mark(o)),!0}return!1}enter(e,t,n,o){let r=this.findPlace(e.create(t),n);return r&&(r=this.enterInner(e,t,n,!0,o)),r}enterInner(e,t,n,o=!1,r){this.closeExtra();let i=this.top;i.match=i.match&&i.match.matchType(e);let s=Z(e,r,i.options);4&i.options&&0==i.content.length&&(s|=4);let l=a.none;return n=n.filter((t=>!(i.type?i.type.allowsMarkType(t.type):re(t.type,e))||(l=t.addToSet(l),!1))),this.nodes.push(new ee(e,t,l,o,null,s)),this.open++,n}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!(!this.isOpen&&!this.options.topOpen))}sync(e){for(let t=this.open;t>=0;t--){if(this.nodes[t]==e)return this.open=t,!0;this.localPreserveWS&&(this.nodes[t].options|=1)}return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let n=this.nodes[t].content;for(let t=n.length-1;t>=0;t--)e+=n[t].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&this.find[n].offset==t&&(this.find[n].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)null==this.find[t].pos&&1==e.nodeType&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,n){if(e!=t&&this.find)for(let o=0;o<this.find.length;o++)if(null==this.find[o].pos&&1==e.nodeType&&e.contains(this.find[o].node)){t.compareDocumentPosition(this.find[o].node)&(n?2:4)&&(this.find[o].pos=this.currentPos)}}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),n=this.options.context,o=!(this.isOpen||n&&n.parent.type!=this.nodes[0].type),r=-(n?n.depth+1:0)+(o?0:1),i=(e,s)=>{for(;e>=0;e--){let l=t[e];if(""==l){if(e==t.length-1||0==e)continue;for(;s>=r;s--)if(i(e-1,s))return!0;return!1}{let e=s>0||0==s&&o?this.nodes[s].type:n&&s>=r?n.node(s-r).type:null;if(!e||e.name!=l&&!e.isInGroup(l))return!1;s--}}return!0};return i(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let n=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(let e in this.parser.schema.nodes){let t=this.parser.schema.nodes[e];if(t.isTextblock&&t.defaultAttrs)return t}}}function ne(e,t){return(e.matches||e.msMatchesSelector||e.webkitMatchesSelector||e.mozMatchesSelector).call(e,t)}function oe(e){let t={};for(let n in e)t[n]=e[n];return t}function re(e,t){let n=t.schema.nodes;for(let o in n){let r=n[o];if(!r.allowsMarkType(e))continue;let i=[],s=e=>{i.push(e);for(let n=0;n<e.edgeCount;n++){let{type:o,next:r}=e.edge(n);if(o==t)return!0;if(i.indexOf(r)<0&&s(r))return!0}};if(s(r.contentMatch))return!0}}let ie=class e{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},n){n||(n=le(t).createDocumentFragment());let o=n,r=[];return e.forEach((e=>{if(r.length||e.marks.length){let n=0,i=0;for(;n<r.length&&i<e.marks.length;){let t=e.marks[i];if(this.marks[t.type.name]){if(!t.eq(r[n][0])||!1===t.type.spec.spanning)break;n++,i++}else i++}for(;n<r.length;)o=r.pop()[1];for(;i<e.marks.length;){let n=e.marks[i++],s=this.serializeMark(n,e.isInline,t);s&&(r.push([n,o]),o.appendChild(s.dom),o=s.contentDOM||s.dom)}}o.appendChild(this.serializeNodeInner(e,t))})),n}serializeNodeInner(e,t){let{dom:n,contentDOM:o}=de(le(t),this.nodes[e.type.name](e),null,e.attrs);if(o){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,o)}return n}serializeNode(e,t={}){let n=this.serializeNodeInner(e,t);for(let o=e.marks.length-1;o>=0;o--){let r=this.serializeMark(e.marks[o],e.isInline,t);r&&((r.contentDOM||r.dom).appendChild(n),n=r.dom)}return n}serializeMark(e,t,n={}){let o=this.marks[e.type.name];return o&&de(le(n),o(e,t),null,e.attrs)}static renderSpec(e,t,n=null,o){return de(e,t,n,o)}static fromSchema(t){return t.cached.domSerializer||(t.cached.domSerializer=new e(this.nodesFromSchema(t),this.marksFromSchema(t)))}static nodesFromSchema(e){let t=se(e.nodes);return t.text||(t.text=e=>e.text),t}static marksFromSchema(e){return se(e.marks)}};function se(e){let t={};for(let n in e){let o=e[n].spec.toDOM;o&&(t[n]=o)}return t}function le(e){return e.document||window.document}const ae=new WeakMap;function ce(e){let t=ae.get(e);return void 0===t&&ae.set(e,t=function(e){let t=null;function n(e){if(e&&"object"==typeof e)if(Array.isArray(e))if("string"==typeof e[0])t||(t=[]),t.push(e);else for(let t=0;t<e.length;t++)n(e[t]);else for(let t in e)n(e[t])}return n(e),t}(e)),t}function de(e,t,n,o){if("string"==typeof t)return{dom:e.createTextNode(t)};if(null!=t.nodeType)return{dom:t};if(t.dom&&null!=t.dom.nodeType)return t;let r,i=t[0];if("string"!=typeof i)throw new RangeError("Invalid array passed to renderSpec");if(o&&(r=ce(o))&&r.indexOf(t)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let s,l=i.indexOf(" ");l>0&&(n=i.slice(0,l),i=i.slice(l+1));let a=n?e.createElementNS(n,i):e.createElement(i),c=t[1],d=1;if(c&&"object"==typeof c&&null==c.nodeType&&!Array.isArray(c)){d=2;for(let e in c)if(null!=c[e]){let t=e.indexOf(" ");t>0?a.setAttributeNS(e.slice(0,t),e.slice(t+1),c[e]):a.setAttribute(e,c[e])}}for(let r=d;r<t.length;r++){let i=t[r];if(0===i){if(r<t.length-1||r>d)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}{let{dom:t,contentDOM:r}=de(e,i,n,o);if(a.appendChild(t),r){if(s)throw new RangeError("Multiple content holes");s=r}}}return{dom:a,contentDOM:s}}const he=Math.pow(2,16);function pe(e){return 65535&e}class ue{constructor(e,t,n){this.pos=e,this.delInfo=t,this.recover=n}get deleted(){return(8&this.delInfo)>0}get deletedBefore(){return(5&this.delInfo)>0}get deletedAfter(){return(6&this.delInfo)>0}get deletedAcross(){return(4&this.delInfo)>0}}class fe{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&fe.empty)return fe.empty}recover(e){let t=0,n=pe(e);if(!this.inverted)for(let e=0;e<n;e++)t+=this.ranges[3*e+2]-this.ranges[3*e+1];return this.ranges[3*n]+t+function(e){return(e-(65535&e))/he}(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,n){let o=0,r=this.inverted?2:1,i=this.inverted?1:2;for(let s=0;s<this.ranges.length;s+=3){let l=this.ranges[s]-(this.inverted?o:0);if(l>e)break;let a=this.ranges[s+r],c=this.ranges[s+i],d=l+a;if(e<=d){let r=l+o+((a?e==l?-1:e==d?1:t:t)<0?0:c);if(n)return r;let i=e==(t<0?l:d)?null:s/3+(e-l)*he,h=e==l?2:e==d?1:4;return(t<0?e!=l:e!=d)&&(h|=8),new ue(r,h,i)}o+=c-a}return n?e+o:new ue(e+o,0,null)}touches(e,t){let n=0,o=pe(t),r=this.inverted?2:1,i=this.inverted?1:2;for(let t=0;t<this.ranges.length;t+=3){let s=this.ranges[t]-(this.inverted?n:0);if(s>e)break;let l=this.ranges[t+r];if(e<=s+l&&t==3*o)return!0;n+=this.ranges[t+i]-l}return!1}forEach(e){let t=this.inverted?2:1,n=this.inverted?1:2;for(let o=0,r=0;o<this.ranges.length;o+=3){let i=this.ranges[o],s=i-(this.inverted?r:0),l=i+(this.inverted?0:r),a=this.ranges[o+t],c=this.ranges[o+n];e(s,s+a,l,l+c),r+=c-a}}invert(){return new fe(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return 0==e?fe.empty:new fe(e<0?[0,-e,0]:[0,0,e])}}fe.empty=new fe([]);class me{constructor(e=[],t,n=0,o=e.length){this.maps=e,this.mirror=t,this.from=n,this.to=o}slice(e=0,t=this.maps.length){return new me(this.maps,this.mirror,e,t)}copy(){return new me(this.maps.slice(),this.mirror&&this.mirror.slice(),this.from,this.to)}appendMap(e,t){this.to=this.maps.push(e),null!=t&&this.setMirror(this.maps.length-1,t)}appendMapping(e){for(let t=0,n=this.maps.length;t<e.maps.length;t++){let o=e.getMirror(t);this.appendMap(e.maps[t],null!=o&&o<t?n+o:void 0)}}getMirror(e){if(this.mirror)for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}setMirror(e,t){this.mirror||(this.mirror=[]),this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,n=this.maps.length+e.maps.length;t>=0;t--){let o=e.getMirror(t);this.appendMap(e.maps[t].invert(),null!=o&&o>t?n-o-1:void 0)}}invert(){let e=new me;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let n=this.from;n<this.to;n++)e=this.maps[n].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,n){let o=0;for(let n=this.from;n<this.to;n++){let r=this.maps[n].mapResult(e,t);if(null!=r.recover){let t=this.getMirror(n);if(null!=t&&t>n&&t<this.to){n=t,e=this.maps[t].recover(r.recover);continue}}o|=r.delInfo,e=r.pos}return n?e:new ue(e,o,null)}}const ge=Object.create(null);class ye{getMap(){return fe.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let n=ge[t.stepType];if(!n)throw new RangeError(`No step type ${t.stepType} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in ge)throw new RangeError("Duplicate use of step JSON ID "+e);return ge[e]=t,t.prototype.jsonID=e,t}}class we{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new we(e,null)}static fail(e){return new we(null,e)}static fromReplace(e,t,n,o){try{return we.ok(e.replace(t,n,o))}catch(e){if(e instanceof c)return we.fail(e.message);throw e}}}function ve(e,t,n){let o=[];for(let r=0;r<e.childCount;r++){let i=e.child(r);i.content.size&&(i=i.copy(ve(i.content,t,i))),i.isInline&&(i=t(i,n,r)),o.push(i)}return r.fromArray(o)}class be extends ye{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=e.resolve(this.from),o=n.node(n.sharedDepth(this.to)),r=new d(ve(t.content,((e,t)=>e.isAtom&&t.type.allowsMarkType(this.mark.type)?e.mark(this.mark.addToSet(e.marks)):e),o),t.openStart,t.openEnd);return we.fromReplace(e,this.from,this.to,r)}invert(){return new ke(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return t.deleted&&n.deleted||t.pos>=n.pos?null:new be(t.pos,n.pos,this.mark)}merge(e){return e instanceof be&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new be(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if("number"!=typeof t.from||"number"!=typeof t.to)throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new be(t.from,t.to,e.markFromJSON(t.mark))}}ye.jsonID("addMark",be);class ke extends ye{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=new d(ve(t.content,(e=>e.mark(this.mark.removeFromSet(e.marks))),e),t.openStart,t.openEnd);return we.fromReplace(e,this.from,this.to,n)}invert(){return new be(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return t.deleted&&n.deleted||t.pos>=n.pos?null:new ke(t.pos,n.pos,this.mark)}merge(e){return e instanceof ke&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new ke(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if("number"!=typeof t.from||"number"!=typeof t.to)throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new ke(t.from,t.to,e.markFromJSON(t.mark))}}ye.jsonID("removeMark",ke);class xe extends ye{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return we.fail("No node at mark step's position");let n=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return we.fromReplace(e,this.pos,this.pos+1,new d(r.from(n),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let e=this.mark.addToSet(t.marks);if(e.length==t.marks.length){for(let n=0;n<t.marks.length;n++)if(!t.marks[n].isInSet(e))return new xe(this.pos,t.marks[n]);return new xe(this.pos,this.mark)}}return new Se(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new xe(t.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if("number"!=typeof t.pos)throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new xe(t.pos,e.markFromJSON(t.mark))}}ye.jsonID("addNodeMark",xe);class Se extends ye{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return we.fail("No node at mark step's position");let n=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return we.fromReplace(e,this.pos,this.pos+1,new d(r.from(n),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return t&&this.mark.isInSet(t.marks)?new xe(this.pos,this.mark):this}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Se(t.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if("number"!=typeof t.pos)throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new Se(t.pos,e.markFromJSON(t.mark))}}ye.jsonID("removeNodeMark",Se);class Ce extends ye{constructor(e,t,n,o=!1){super(),this.from=e,this.to=t,this.slice=n,this.structure=o}apply(e){return this.structure&&Ne(e,this.from,this.to)?we.fail("Structure replace would overwrite content"):we.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new fe([this.from,this.to-this.from,this.slice.size])}invert(e){return new Ce(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return t.deletedAcross&&n.deletedAcross?null:new Ce(t.pos,Math.max(t.pos,n.pos),this.slice)}merge(e){if(!(e instanceof Ce)||e.structure||this.structure)return null;if(this.from+this.slice.size!=e.from||this.slice.openEnd||e.slice.openStart){if(e.to!=this.from||this.slice.openStart||e.slice.openEnd)return null;{let t=this.slice.size+e.slice.size==0?d.empty:new d(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new Ce(e.from,this.to,t,this.structure)}}{let t=this.slice.size+e.slice.size==0?d.empty:new d(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new Ce(this.from,this.to+(e.to-e.from),t,this.structure)}}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if("number"!=typeof t.from||"number"!=typeof t.to)throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new Ce(t.from,t.to,d.fromJSON(e,t.slice),!!t.structure)}}ye.jsonID("replace",Ce);class Me extends ye{constructor(e,t,n,o,r,i,s=!1){super(),this.from=e,this.to=t,this.gapFrom=n,this.gapTo=o,this.slice=r,this.insert=i,this.structure=s}apply(e){if(this.structure&&(Ne(e,this.from,this.gapFrom)||Ne(e,this.gapTo,this.to)))return we.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return we.fail("Gap is not a flat range");let n=this.slice.insertAt(this.insert,t.content);return n?we.fromReplace(e,this.from,this.to,n):we.fail("Content does not fit in gap")}getMap(){return new fe([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let t=this.gapTo-this.gapFrom;return new Me(this.from,this.from+this.slice.size+t,this.from+this.insert,this.from+this.insert+t,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1),o=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),r=this.to==this.gapTo?n.pos:e.map(this.gapTo,1);return t.deletedAcross&&n.deletedAcross||o<t.pos||r>n.pos?null:new Me(t.pos,n.pos,o,r,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if("number"!=typeof t.from||"number"!=typeof t.to||"number"!=typeof t.gapFrom||"number"!=typeof t.gapTo||"number"!=typeof t.insert)throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new Me(t.from,t.to,t.gapFrom,t.gapTo,d.fromJSON(e,t.slice),t.insert,!!t.structure)}}function Ne(e,t,n){let o=e.resolve(t),r=n-t,i=o.depth;for(;r>0&&i>0&&o.indexAfter(i)==o.node(i).childCount;)i--,r--;if(r>0){let e=o.node(i).maybeChild(o.indexAfter(i));for(;r>0;){if(!e||e.isLeaf)return!0;e=e.firstChild,r--}}return!1}function Oe(e,t,n,o=n.contentMatch,i=!0){let s=e.doc.nodeAt(t),l=[],a=t+1;for(let t=0;t<s.childCount;t++){let c=s.child(t),h=a+c.nodeSize,p=o.matchType(c.type);if(p){o=p;for(let t=0;t<c.marks.length;t++)n.allowsMarkType(c.marks[t].type)||e.step(new ke(a,h,c.marks[t]));if(i&&c.isText&&"pre"!=n.whitespace){let e,t,o=/\r?\n|\r/g;for(;e=o.exec(c.text);)t||(t=new d(r.from(n.schema.text(" ",n.allowedMarks(c.marks))),0,0)),l.push(new Ce(a+e.index,a+e.index+e[0].length,t))}}else l.push(new Ce(a,h,d.empty));a=h}if(!o.validEnd){let t=o.fillBefore(r.empty,!0);e.replace(a,a,new d(t,0,0))}for(let t=l.length-1;t>=0;t--)e.step(l[t])}function Ae(e,t,n){return(0==t||e.canReplace(t,e.childCount))&&(n==e.childCount||e.canReplace(0,n))}function Te(e){let t=e.parent.content.cutByIndex(e.startIndex,e.endIndex);for(let n=e.depth;;--n){let o=e.$from.node(n),r=e.$from.index(n),i=e.$to.indexAfter(n);if(n<e.depth&&o.canReplace(r,i,t))return n;if(0==n||o.type.spec.isolating||!Ae(o,r,i))break}return null}function De(e,t,n=null,o=e){let r=function(e,t){let{parent:n,startIndex:o,endIndex:r}=e,i=n.contentMatchAt(o).findWrapping(t);if(!i)return null;let s=i.length?i[0]:t;return n.canReplaceWith(o,r,s)?i:null}(e,t),i=r&&function(e,t){let{parent:n,startIndex:o,endIndex:r}=e,i=n.child(o),s=t.contentMatch.findWrapping(i.type);if(!s)return null;let l=(s.length?s[s.length-1]:t).contentMatch;for(let e=o;l&&e<r;e++)l=l.matchType(n.child(e).type);return l&&l.validEnd?s:null}(o,t);return i?r.map(Ee).concat({type:t,attrs:n}).concat(i.map(Ee)):null}function Ee(e){return{type:e,attrs:null}}function Re(e,t,n,o){t.forEach(((r,i)=>{if(r.isText){let s,l=/\r?\n|\r/g;for(;s=l.exec(r.text);){let r=e.mapping.slice(o).map(n+1+i+s.index);e.replaceWith(r,r+1,t.type.schema.linebreakReplacement.create())}}}))}function $e(e,t,n,o){t.forEach(((r,i)=>{if(r.type==r.type.schema.linebreakReplacement){let r=e.mapping.slice(o).map(n+1+i);e.replaceWith(r,r+1,t.type.schema.text("\n"))}}))}function Ie(e,t,n=1,o){let r=e.resolve(t),i=r.depth-n,s=o&&o[o.length-1]||r.parent;if(i<0||r.parent.type.spec.isolating||!r.parent.canReplace(r.index(),r.parent.childCount)||!s.type.validContent(r.parent.content.cutByIndex(r.index(),r.parent.childCount)))return!1;for(let e=r.depth-1,t=n-2;e>i;e--,t--){let n=r.node(e),i=r.index(e);if(n.type.spec.isolating)return!1;let s=n.content.cutByIndex(i,n.childCount),l=o&&o[t+1];l&&(s=s.replaceChild(0,l.type.create(l.attrs)));let a=o&&o[t]||n;if(!n.canReplace(i+1,n.childCount)||!a.type.validContent(s))return!1}let l=r.indexAfter(i),a=o&&o[0];return r.node(i).canReplaceWith(l,l,a?a.type:r.node(i+1).type)}function ze(e,t){let n=e.resolve(t),o=n.index();return Be(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(o,o+1)}function Be(e,t){return!(!e||!t||e.isLeaf||!function(e,t){t.content.size||e.type.compatibleContent(t.type);let n=e.contentMatchAt(e.childCount),{linebreakReplacement:o}=e.type.schema;for(let r=0;r<t.childCount;r++){let i=t.child(r),s=i.type==o?e.type.schema.nodes.text:i.type;if(n=n.matchType(s),!n)return!1;if(!e.type.allowsMarks(i.marks))return!1}return n.validEnd}(e,t))}function Pe(e,t,n=-1){let o=e.resolve(t);for(let e=o.depth;;e--){let r,i,s=o.index(e);if(e==o.depth?(r=o.nodeBefore,i=o.nodeAfter):n>0?(r=o.node(e+1),s++,i=o.node(e).maybeChild(s)):(r=o.node(e).maybeChild(s-1),i=o.node(e+1)),r&&!r.isTextblock&&Be(r,i)&&o.node(e).canReplace(s,s+1))return t;if(0==e)break;t=n<0?o.before(e):o.after(e)}}function Ve(e,t,n){let o=e.resolve(t);if(o.parent.canReplaceWith(o.index(),o.index(),n))return t;if(0==o.parentOffset)for(let e=o.depth-1;e>=0;e--){let t=o.index(e);if(o.node(e).canReplaceWith(t,t,n))return o.before(e+1);if(t>0)return null}if(o.parentOffset==o.parent.content.size)for(let e=o.depth-1;e>=0;e--){let t=o.indexAfter(e);if(o.node(e).canReplaceWith(t,t,n))return o.after(e+1);if(t<o.node(e).childCount)return null}return null}function Fe(e,t,n){let o=e.resolve(t);if(!n.content.size)return t;let r=n.content;for(let e=0;e<n.openStart;e++)r=r.firstChild.content;for(let e=1;e<=(0==n.openStart&&n.size?2:1);e++)for(let t=o.depth;t>=0;t--){let n=t==o.depth?0:o.pos<=(o.start(t+1)+o.end(t+1))/2?-1:1,i=o.index(t)+(n>0?1:0),s=o.node(t),l=!1;if(1==e)l=s.canReplace(i,i,r);else{let e=s.contentMatchAt(i).findWrapping(r.firstChild.type);l=e&&s.canReplaceWith(i,i,e[0])}if(l)return 0==n?o.pos:n<0?o.before(t+1):o.after(t+1)}return null}function Le(e,t,n=t,o=d.empty){if(t==n&&!o.size)return null;let r=e.resolve(t),i=e.resolve(n);return He(r,i,o)?new Ce(t,n,o):new _e(r,i,o).fit()}function He(e,t,n){return!n.openStart&&!n.openEnd&&e.start()==t.start()&&e.parent.canReplace(e.index(),t.index(),n.content)}ye.jsonID("replaceAround",Me);class _e{constructor(e,t,n){this.$from=e,this.$to=t,this.unplaced=n,this.frontier=[],this.placed=r.empty;for(let t=0;t<=e.depth;t++){let n=e.node(t);this.frontier.push({type:n.type,match:n.contentMatchAt(e.indexAfter(t))})}for(let t=e.depth;t>0;t--)this.placed=r.from(e.node(t).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let e=this.findFittable();e?this.placeNodes(e):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,n=this.$from,o=this.close(e<0?this.$to:n.doc.resolve(e));if(!o)return null;let r=this.placed,i=n.depth,s=o.depth;for(;i&&s&&1==r.childCount;)r=r.firstChild.content,i--,s--;let l=new d(r,i,s);return e>-1?new Me(n.pos,e,this.$to.pos,this.$to.end(),l,t):l.size||n.pos!=this.$to.pos?new Ce(n.pos,o.pos,l):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,n=0,o=this.unplaced.openEnd;n<e;n++){let r=t.firstChild;if(t.childCount>1&&(o=0),r.type.spec.isolating&&o<=n){e=n;break}t=r.content}for(let t=1;t<=2;t++)for(let n=1==t?e:this.unplaced.openStart;n>=0;n--){let e,o=null;n?(o=Je(this.unplaced.content,n-1).firstChild,e=o.content):e=this.unplaced.content;let i=e.firstChild;for(let e=this.depth;e>=0;e--){let s,{type:l,match:a}=this.frontier[e],c=null;if(1==t&&(i?a.matchType(i.type)||(c=a.fillBefore(r.from(i),!1)):o&&l.compatibleContent(o.type)))return{sliceDepth:n,frontierDepth:e,parent:o,inject:c};if(2==t&&i&&(s=a.findWrapping(i.type)))return{sliceDepth:n,frontierDepth:e,parent:o,wrap:s};if(o&&a.matchType(o.type))break}}}openMore(){let{content:e,openStart:t,openEnd:n}=this.unplaced,o=Je(e,t);return!(!o.childCount||o.firstChild.isLeaf)&&(this.unplaced=new d(e,t+1,Math.max(n,o.size+t>=e.size-n?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:n}=this.unplaced,o=Je(e,t);if(o.childCount<=1&&t>0){let r=e.size-t<=t+o.size;this.unplaced=new d(We(e,t-1,1),t-1,r?t-1:n)}else this.unplaced=new d(We(e,t,1),t,n)}placeNodes({sliceDepth:e,frontierDepth:t,parent:n,inject:o,wrap:i}){for(;this.depth>t;)this.closeFrontierNode();if(i)for(let e=0;e<i.length;e++)this.openFrontierNode(i[e]);let s=this.unplaced,l=n?n.content:s.content,a=s.openStart-e,c=0,h=[],{match:p,type:u}=this.frontier[t];if(o){for(let e=0;e<o.childCount;e++)h.push(o.child(e));p=p.matchFragment(o)}let f=l.size+e-(s.content.size-s.openEnd);for(;c<l.childCount;){let e=l.child(c),t=p.matchType(e.type);if(!t)break;c++,(c>1||0==a||e.content.size)&&(p=t,h.push(je(e.mark(u.allowedMarks(e.marks)),1==c?a:0,c==l.childCount?f:-1)))}let m=c==l.childCount;m||(f=-1),this.placed=qe(this.placed,t,r.from(h)),this.frontier[t].match=p,m&&f<0&&n&&n.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let e=0,t=l;e<f;e++){let e=t.lastChild;this.frontier.push({type:e.type,match:e.contentMatchAt(e.childCount)}),t=e.content}this.unplaced=m?0==e?d.empty:new d(We(s.content,e-1,1),e-1,f<0?s.openEnd:e-1):new d(We(s.content,e,c),s.openStart,s.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e,t=this.frontier[this.depth];if(!t.type.isTextblock||!Ke(this.$to,this.$to.depth,t.type,t.match,!1)||this.$to.depth==this.depth&&(e=this.findCloseLevel(this.$to))&&e.depth==this.depth)return-1;let{depth:n}=this.$to,o=this.$to.after(n);for(;n>1&&o==this.$to.end(--n);)++o;return o}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:n,type:o}=this.frontier[t],r=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),i=Ke(e,t,o,n,r);if(i){for(let n=t-1;n>=0;n--){let{match:t,type:o}=this.frontier[n],r=Ke(e,n,o,t,!0);if(!r||r.childCount)continue e}return{depth:t,fit:i,move:r?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=qe(this.placed,t.depth,t.fit)),e=t.move;for(let n=t.depth+1;n<=e.depth;n++){let t=e.node(n),o=t.type.contentMatch.fillBefore(t.content,!0,e.index(n));this.openFrontierNode(t.type,t.attrs,o)}return e}openFrontierNode(e,t=null,n){let o=this.frontier[this.depth];o.match=o.match.matchType(e),this.placed=qe(this.placed,this.depth,r.from(e.create(t,n))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let e=this.frontier.pop().match.fillBefore(r.empty,!0);e.childCount&&(this.placed=qe(this.placed,this.frontier.length,e))}}function We(e,t,n){return 0==t?e.cutByIndex(n,e.childCount):e.replaceChild(0,e.firstChild.copy(We(e.firstChild.content,t-1,n)))}function qe(e,t,n){return 0==t?e.append(n):e.replaceChild(e.childCount-1,e.lastChild.copy(qe(e.lastChild.content,t-1,n)))}function Je(e,t){for(let n=0;n<t;n++)e=e.firstChild.content;return e}function je(e,t,n){if(t<=0)return e;let o=e.content;return t>1&&(o=o.replaceChild(0,je(o.firstChild,t-1,1==o.childCount?n-1:0))),t>0&&(o=e.type.contentMatch.fillBefore(o).append(o),n<=0&&(o=o.append(e.type.contentMatch.matchFragment(o).fillBefore(r.empty,!0)))),e.copy(o)}function Ke(e,t,n,o,r){let i=e.node(t),s=r?e.indexAfter(t):e.index(t);if(s==i.childCount&&!n.compatibleContent(i.type))return null;let l=o.fillBefore(i.content,!0,s);return l&&!function(e,t,n){for(let o=n;o<t.childCount;o++)if(!e.allowsMarks(t.child(o).marks))return!0;return!1}(n,i.content,s)?l:null}function Xe(e,t,n,o,i){if(t<n){let r=e.firstChild;e=e.replaceChild(0,r.copy(Xe(r.content,t+1,n,o,r)))}if(t>o){let t=i.contentMatchAt(0),n=t.fillBefore(e).append(e);e=n.append(t.matchFragment(n).fillBefore(r.empty,!0))}return e}function Ue(e,t){let n=[];for(let o=Math.min(e.depth,t.depth);o>=0;o--){let r=e.start(o);if(r<e.pos-(e.depth-o)||t.end(o)>t.pos+(t.depth-o)||e.node(o).type.spec.isolating||t.node(o).type.spec.isolating)break;(r==t.start(o)||o==e.depth&&o==t.depth&&e.parent.inlineContent&&t.parent.inlineContent&&o&&t.start(o-1)==r-1)&&n.push(o)}return n}class Ge extends ye{constructor(e,t,n){super(),this.pos=e,this.attr=t,this.value=n}apply(e){let t=e.nodeAt(this.pos);if(!t)return we.fail("No node at attribute step's position");let n=Object.create(null);for(let e in t.attrs)n[e]=t.attrs[e];n[this.attr]=this.value;let o=t.type.create(n,null,t.marks);return we.fromReplace(e,this.pos,this.pos+1,new d(r.from(o),0,t.isLeaf?0:1))}getMap(){return fe.empty}invert(e){return new Ge(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Ge(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if("number"!=typeof t.pos||"string"!=typeof t.attr)throw new RangeError("Invalid input for AttrStep.fromJSON");return new Ge(t.pos,t.attr,t.value)}}ye.jsonID("attr",Ge);class Ye extends ye{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let n in e.attrs)t[n]=e.attrs[n];t[this.attr]=this.value;let n=e.type.create(t,e.content,e.marks);return we.ok(n)}getMap(){return fe.empty}invert(e){return new Ye(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,t){if("string"!=typeof t.attr)throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new Ye(t.attr,t.value)}}ye.jsonID("docAttr",Ye),e.TransformError=class extends Error{},e.TransformError=function e(t){let n=Error.call(this,t);return n.__proto__=e.prototype,n},e.TransformError.prototype=Object.create(Error.prototype),e.TransformError.prototype.constructor=e.TransformError,e.TransformError.prototype.name="TransformError";class Qe{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new me}get before(){return this.docs.length?this.docs[0]:this.doc}step(t){let n=this.maybeStep(t);if(n.failed)throw new e.TransformError(n.failed);return this}maybeStep(e){let t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}get docChanged(){return this.steps.length>0}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,n=d.empty){let o=Le(this.doc,e,t,n);return o&&this.step(o),this}replaceWith(e,t,n){return this.replace(e,t,new d(r.from(n),0,0))}delete(e,t){return this.replace(e,t,d.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,n){return function(e,t,n,o){if(!o.size)return e.deleteRange(t,n);let r=e.doc.resolve(t),i=e.doc.resolve(n);if(He(r,i,o))return e.step(new Ce(t,n,o));let s=Ue(r,e.doc.resolve(n));0==s[s.length-1]&&s.pop();let l=-(r.depth+1);s.unshift(l);for(let e=r.depth,t=r.pos-1;e>0;e--,t--){let n=r.node(e).type.spec;if(n.defining||n.definingAsContext||n.isolating)break;s.indexOf(e)>-1?l=e:r.before(e)==t&&s.splice(1,0,-e)}let a=s.indexOf(l),c=[],h=o.openStart;for(let e=o.content,t=0;;t++){let n=e.firstChild;if(c.push(n),t==o.openStart)break;e=n.content}for(let e=h-1;e>=0;e--){let t=c[e],n=(p=t.type).spec.defining||p.spec.definingForContent;if(n&&!t.sameMarkup(r.node(Math.abs(l)-1)))h=e;else if(n||!t.type.isTextblock)break}var p;for(let t=o.openStart;t>=0;t--){let l=(t+h+1)%(o.openStart+1),p=c[l];if(p)for(let t=0;t<s.length;t++){let c=s[(t+a)%s.length],h=!0;c<0&&(h=!1,c=-c);let u=r.node(c-1),f=r.index(c-1);if(u.canReplaceWith(f,f,p.type,p.marks))return e.replace(r.before(c),h?i.after(c):n,new d(Xe(o.content,0,o.openStart,l),l,o.openEnd))}}let u=e.steps.length;for(let l=s.length-1;l>=0&&(e.replace(t,n,o),!(e.steps.length>u));l--){let e=s[l];e<0||(t=r.before(e),n=i.after(e))}}(this,e,t,n),this}replaceRangeWith(e,t,n){return function(e,t,n,o){if(!o.isInline&&t==n&&e.doc.resolve(t).parent.content.size){let r=Ve(e.doc,t,o.type);null!=r&&(t=n=r)}e.replaceRange(t,n,new d(r.from(o),0,0))}(this,e,t,n),this}deleteRange(e,t){return function(e,t,n){let o=e.doc.resolve(t),r=e.doc.resolve(n),i=Ue(o,r);for(let t=0;t<i.length;t++){let n=i[t],s=t==i.length-1;if(s&&0==n||o.node(n).type.contentMatch.validEnd)return e.delete(o.start(n),r.end(n));if(n>0&&(s||o.node(n-1).canReplace(o.index(n-1),r.indexAfter(n-1))))return e.delete(o.before(n),r.after(n))}for(let i=1;i<=o.depth&&i<=r.depth;i++)if(t-o.start(i)==o.depth-i&&n>o.end(i)&&r.end(i)-n!=r.depth-i&&o.start(i-1)==r.start(i-1)&&o.node(i-1).canReplace(o.index(i-1),r.index(i-1)))return e.delete(o.before(i),n);e.delete(t,n)}(this,e,t),this}lift(e,t){return function(e,t,n){let{$from:o,$to:i,depth:s}=t,l=o.before(s+1),a=i.after(s+1),c=l,h=a,p=r.empty,u=0;for(let e=s,t=!1;e>n;e--)t||o.index(e)>0?(t=!0,p=r.from(o.node(e).copy(p)),u++):c--;let f=r.empty,m=0;for(let e=s,t=!1;e>n;e--)t||i.after(e+1)<i.end(e)?(t=!0,f=r.from(i.node(e).copy(f)),m++):h++;e.step(new Me(c,h,l,a,new d(p.append(f),u,m),p.size-u,!0))}(this,e,t),this}join(e,t=1){return function(e,t,n){let o=null,{linebreakReplacement:r}=e.doc.type.schema,i=e.doc.resolve(t-n),s=i.node().type;if(r&&s.inlineContent){let e="pre"==s.whitespace,t=!!s.contentMatch.matchType(r);e&&!t?o=!1:!e&&t&&(o=!0)}let l=e.steps.length;if(!1===o){let o=e.doc.resolve(t+n);$e(e,o.node(),o.before(),l)}s.inlineContent&&Oe(e,t+n-1,s,i.node().contentMatchAt(i.index()),null==o);let a=e.mapping.slice(l),c=a.map(t-n);if(e.step(new Ce(c,a.map(t+n,-1),d.empty,!0)),!0===o){let t=e.doc.resolve(c);Re(e,t.node(),t.before(),e.steps.length)}}(this,e,t),this}wrap(e,t){return function(e,t,n){let o=r.empty;for(let e=n.length-1;e>=0;e--){if(o.size){let t=n[e].type.contentMatch.matchFragment(o);if(!t||!t.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}o=r.from(n[e].type.create(n[e].attrs,o))}let i=t.start,s=t.end;e.step(new Me(i,s,i,s,new d(o,0,0),n.length,!0))}(this,e,t),this}setBlockType(e,t=e,n,o=null){return function(e,t,n,o,i){if(!o.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let s=e.steps.length;e.doc.nodesBetween(t,n,((t,n)=>{let l="function"==typeof i?i(t):i;if(t.isTextblock&&!t.hasMarkup(o,l)&&function(e,t,n){let o=e.resolve(t),r=o.index();return o.parent.canReplaceWith(r,r+1,n)}(e.doc,e.mapping.slice(s).map(n),o)){let i=null;if(o.schema.linebreakReplacement){let e="pre"==o.whitespace,t=!!o.contentMatch.matchType(o.schema.linebreakReplacement);e&&!t?i=!1:!e&&t&&(i=!0)}!1===i&&$e(e,t,n,s),Oe(e,e.mapping.slice(s).map(n,1),o,void 0,null===i);let a=e.mapping.slice(s),c=a.map(n,1),h=a.map(n+t.nodeSize,1);return e.step(new Me(c,h,c+1,h-1,new d(r.from(o.create(l,null,t.marks)),0,0),1,!0)),!0===i&&Re(e,t,n,s),!1}}))}(this,e,t,n,o),this}setNodeMarkup(e,t,n=null,o){return function(e,t,n,o,i){let s=e.doc.nodeAt(t);if(!s)throw new RangeError("No node at given position");n||(n=s.type);let l=n.create(o,null,i||s.marks);if(s.isLeaf)return e.replaceWith(t,t+s.nodeSize,l);if(!n.validContent(s.content))throw new RangeError("Invalid content for node type "+n.name);e.step(new Me(t,t+s.nodeSize,t+1,t+s.nodeSize-1,new d(r.from(l),0,0),1,!0))}(this,e,t,n,o),this}setNodeAttribute(e,t,n){return this.step(new Ge(e,t,n)),this}setDocAttribute(e,t){return this.step(new Ye(e,t)),this}addNodeMark(e,t){return this.step(new xe(e,t)),this}removeNodeMark(e,t){if(!(t instanceof a)){let n=this.doc.nodeAt(e);if(!n)throw new RangeError("No node at position "+e);if(!(t=t.isInSet(n.marks)))return this}return this.step(new Se(e,t)),this}split(e,t=1,n){return function(e,t,n=1,o){let i=e.doc.resolve(t),s=r.empty,l=r.empty;for(let e=i.depth,t=i.depth-n,a=n-1;e>t;e--,a--){s=r.from(i.node(e).copy(s));let t=o&&o[a];l=r.from(t?t.type.create(t.attrs,l):i.node(e).copy(l))}e.step(new Ce(t,t,new d(s.append(l),n,n),!0))}(this,e,t,n),this}addMark(e,t,n){return function(e,t,n,o){let r,i,s=[],l=[];e.doc.nodesBetween(t,n,((e,a,c)=>{if(!e.isInline)return;let d=e.marks;if(!o.isInSet(d)&&c.type.allowsMarkType(o.type)){let c=Math.max(a,t),h=Math.min(a+e.nodeSize,n),p=o.addToSet(d);for(let e=0;e<d.length;e++)d[e].isInSet(p)||(r&&r.to==c&&r.mark.eq(d[e])?r.to=h:s.push(r=new ke(c,h,d[e])));i&&i.to==c?i.to=h:l.push(i=new be(c,h,o))}})),s.forEach((t=>e.step(t))),l.forEach((t=>e.step(t)))}(this,e,t,n),this}removeMark(e,t,n){return function(e,t,n,o){let r=[],i=0;e.doc.nodesBetween(t,n,((e,s)=>{if(!e.isInline)return;i++;let l=null;if(o instanceof j){let t,n=e.marks;for(;t=o.isInSet(n);)(l||(l=[])).push(t),n=t.removeFromSet(n)}else o?o.isInSet(e.marks)&&(l=[o]):l=e.marks;if(l&&l.length){let o=Math.min(s+e.nodeSize,n);for(let e=0;e<l.length;e++){let n,a=l[e];for(let e=0;e<r.length;e++){let t=r[e];t.step==i-1&&a.eq(r[e].style)&&(n=t)}n?(n.to=o,n.step=i):r.push({style:a,from:Math.max(s,t),to:o,step:i})}}})),r.forEach((t=>e.step(new ke(t.from,t.to,t.style))))}(this,e,t,n),this}clearIncompatible(e,t,n){return Oe(this,e,t,n),this}}const Ze=Object.create(null);class et{constructor(e,t,n){this.$anchor=e,this.$head=t,this.ranges=n||[new tt(e.min(t),e.max(t))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let t=0;t<e.length;t++)if(e[t].$from.pos!=e[t].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,t=d.empty){let n=t.content.lastChild,o=null;for(let e=0;e<t.openEnd;e++)o=n,n=n.lastChild;let r=e.steps.length,i=this.ranges;for(let s=0;s<i.length;s++){let{$from:l,$to:a}=i[s],c=e.mapping.slice(r);e.replaceRange(c.map(l.pos),c.map(a.pos),s?d.empty:t),0==s&&ht(e,r,(n?n.isInline:o&&o.isTextblock)?-1:1)}}replaceWith(e,t){let n=e.steps.length,o=this.ranges;for(let r=0;r<o.length;r++){let{$from:i,$to:s}=o[r],l=e.mapping.slice(n),a=l.map(i.pos),c=l.map(s.pos);r?e.deleteRange(a,c):(e.replaceRangeWith(a,c,t),ht(e,n,t.isInline?-1:1))}}static findFrom(e,t,n=!1){let o=e.parent.inlineContent?new rt(e):dt(e.node(0),e.parent,e.pos,e.index(),t,n);if(o)return o;for(let o=e.depth-1;o>=0;o--){let r=t<0?dt(e.node(0),e.node(o),e.before(o+1),e.index(o),t,n):dt(e.node(0),e.node(o),e.after(o+1),e.index(o)+1,t,n);if(r)return r}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new at(e.node(0))}static atStart(e){return dt(e,e,0,0,1)||new at(e)}static atEnd(e){return dt(e,e,e.content.size,e.childCount,-1)||new at(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let n=Ze[t.type];if(!n)throw new RangeError(`No selection type ${t.type} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in Ze)throw new RangeError("Duplicate use of selection JSON ID "+e);return Ze[e]=t,t.prototype.jsonID=e,t}getBookmark(){return rt.between(this.$anchor,this.$head).getBookmark()}}et.prototype.visible=!0;class tt{constructor(e,t){this.$from=e,this.$to=t}}let nt=!1;function ot(e){nt||e.parent.inlineContent||(nt=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+e.parent.type.name+")"))}class rt extends et{constructor(e,t=e){ot(e),ot(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let n=e.resolve(t.map(this.head));if(!n.parent.inlineContent)return et.near(n);let o=e.resolve(t.map(this.anchor));return new rt(o.parent.inlineContent?o:n,n)}replace(e,t=d.empty){if(super.replace(e,t),t==d.empty){let t=this.$from.marksAcross(this.$to);t&&e.ensureMarks(t)}}eq(e){return e instanceof rt&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new it(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if("number"!=typeof t.anchor||"number"!=typeof t.head)throw new RangeError("Invalid input for TextSelection.fromJSON");return new rt(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,n=t){let o=e.resolve(t);return new this(o,n==t?o:e.resolve(n))}static between(e,t,n){let o=e.pos-t.pos;if(n&&!o||(n=o>=0?1:-1),!t.parent.inlineContent){let e=et.findFrom(t,n,!0)||et.findFrom(t,-n,!0);if(!e)return et.near(t,n);t=e.$head}return e.parent.inlineContent||(0==o||(e=(et.findFrom(e,-n,!0)||et.findFrom(e,n,!0)).$anchor).pos<t.pos!=o<0)&&(e=t),new rt(e,t)}}et.jsonID("text",rt);class it{constructor(e,t){this.anchor=e,this.head=t}map(e){return new it(e.map(this.anchor),e.map(this.head))}resolve(e){return rt.between(e.resolve(this.anchor),e.resolve(this.head))}}class st extends et{constructor(e){let t=e.nodeAfter,n=e.node(0).resolve(e.pos+t.nodeSize);super(e,n),this.node=t}map(e,t){let{deleted:n,pos:o}=t.mapResult(this.anchor),r=e.resolve(o);return n?et.near(r):new st(r)}content(){return new d(r.from(this.node),0,0)}eq(e){return e instanceof st&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new lt(this.anchor)}static fromJSON(e,t){if("number"!=typeof t.anchor)throw new RangeError("Invalid input for NodeSelection.fromJSON");return new st(e.resolve(t.anchor))}static create(e,t){return new st(e.resolve(t))}static isSelectable(e){return!e.isText&&!1!==e.type.spec.selectable}}st.prototype.visible=!1,et.jsonID("node",st);class lt{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:n}=e.mapResult(this.anchor);return t?new it(n,n):new lt(n)}resolve(e){let t=e.resolve(this.anchor),n=t.nodeAfter;return n&&st.isSelectable(n)?new st(t):et.near(t)}}class at extends et{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=d.empty){if(t==d.empty){e.delete(0,e.doc.content.size);let t=et.atStart(e.doc);t.eq(e.selection)||e.setSelection(t)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new at(e)}map(e){return new at(e)}eq(e){return e instanceof at}getBookmark(){return ct}}et.jsonID("all",at);const ct={map(){return this},resolve:e=>new at(e)};function dt(e,t,n,o,r,i=!1){if(t.inlineContent)return rt.create(e,n);for(let s=o-(r>0?0:1);r>0?s<t.childCount:s>=0;s+=r){let o=t.child(s);if(o.isAtom){if(!i&&st.isSelectable(o))return st.create(e,n-(r<0?o.nodeSize:0))}else{let t=dt(e,o,n+r,r<0?o.childCount:0,r,i);if(t)return t}n+=o.nodeSize*r}return null}function ht(e,t,n){let o=e.steps.length-1;if(o<t)return;let r,i=e.steps[o];(i instanceof Ce||i instanceof Me)&&(e.mapping.maps[o].forEach(((e,t,n,o)=>{null==r&&(r=o)})),e.setSelection(et.near(e.doc.resolve(r),n)))}class pt extends Qe{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){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}setSelection(e){if(e.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=-3&this.updated|1,this.storedMarks=null,this}get selectionSet(){return(1&this.updated)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=2,this}ensureMarks(e){return a.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(2&this.updated)>0}addStep(e,t){super.addStep(e,t),this.updated=-3&this.updated,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let n=this.selection;return t&&(e=e.mark(this.storedMarks||(n.empty?n.$from.marks():n.$from.marksAcross(n.$to)||a.none))),n.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,n){let o=this.doc.type.schema;if(null==t)return e?this.replaceSelectionWith(o.text(e),!0):this.deleteSelection();{if(null==n&&(n=t),n=null==n?t:n,!e)return this.deleteRange(t,n);let r=this.storedMarks;if(!r){let e=this.doc.resolve(t);r=n==t?e.marks():e.marksAcross(this.doc.resolve(n))}return this.replaceRangeWith(t,n,o.text(e,r)),this.selection.empty||this.setSelection(et.near(this.selection.$to)),this}}setMeta(e,t){return this.meta["string"==typeof e?e:e.key]=t,this}getMeta(e){return this.meta["string"==typeof e?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=4,this}get scrolledIntoView(){return(4&this.updated)>0}}function ut(e,t){return t&&e?e.bind(t):e}class ft{constructor(e,t,n){this.name=e,this.init=ut(t.init,n),this.apply=ut(t.apply,n)}}const mt=[new ft("doc",{init:e=>e.doc||e.schema.topNodeType.createAndFill(),apply:e=>e.doc}),new ft("selection",{init:(e,t)=>e.selection||et.atStart(t.doc),apply:e=>e.selection}),new ft("storedMarks",{init:e=>e.storedMarks||null,apply:(e,t,n,o)=>o.selection.$cursor?e.storedMarks:null}),new ft("scrollToSelection",{init:()=>0,apply:(e,t)=>e.scrolledIntoView?t+1:t})];class gt{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=mt.slice(),t&&t.forEach((e=>{if(this.pluginsByKey[e.key])throw new RangeError("Adding different instances of a keyed plugin ("+e.key+")");this.plugins.push(e),this.pluginsByKey[e.key]=e,e.spec.state&&this.fields.push(new ft(e.key,e.spec.state,e))}))}}class yt{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,t=-1){for(let n=0;n<this.config.plugins.length;n++)if(n!=t){let t=this.config.plugins[n];if(t.spec.filterTransaction&&!t.spec.filterTransaction.call(t,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],n=this.applyInner(e),o=null;for(;;){let r=!1;for(let i=0;i<this.config.plugins.length;i++){let s=this.config.plugins[i];if(s.spec.appendTransaction){let l=o?o[i].n:0,a=o?o[i].state:this,c=l<t.length&&s.spec.appendTransaction.call(s,l?t.slice(l):t,a,n);if(c&&n.filterTransaction(c,i)){if(c.setMeta("appendedTransaction",e),!o){o=[];for(let e=0;e<this.config.plugins.length;e++)o.push(e<i?{state:n,n:t.length}:{state:this,n:0})}t.push(c),n=n.applyInner(c),r=!0}o&&(o[i]={state:n,n:t.length})}}if(!r)return{state:n,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let t=new yt(this.config),n=this.config.fields;for(let o=0;o<n.length;o++){let r=n[o];t[r.name]=r.apply(e,this[r.name],this,t)}return t}get tr(){return new pt(this)}static create(e){let t=new gt(e.doc?e.doc.type.schema:e.schema,e.plugins),n=new yt(t);for(let o=0;o<t.fields.length;o++)n[t.fields[o].name]=t.fields[o].init(e,n);return n}reconfigure(e){let t=new gt(this.schema,e.plugins),n=t.fields,o=new yt(t);for(let t=0;t<n.length;t++){let r=n[t].name;o[r]=this.hasOwnProperty(r)?this[r]:n[t].init(e,o)}return o}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map((e=>e.toJSON()))),e&&"object"==typeof e)for(let n in e){if("doc"==n||"selection"==n)throw new RangeError("The JSON fields `doc` and `selection` are reserved");let o=e[n],r=o.spec.state;r&&r.toJSON&&(t[n]=r.toJSON.call(o,this[o.key]))}return t}static fromJSON(e,t,n){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let o=new gt(e.schema,e.plugins),r=new yt(o);return o.fields.forEach((o=>{if("doc"==o.name)r.doc=A.fromJSON(e.schema,t.doc);else if("selection"==o.name)r.selection=et.fromJSON(r.doc,t.selection);else if("storedMarks"==o.name)t.storedMarks&&(r.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(n)for(let i in n){let s=n[i],l=s.spec.state;if(s.key==o.name&&l&&l.fromJSON&&Object.prototype.hasOwnProperty.call(t,i))return void(r[o.name]=l.fromJSON.call(s,e,t[i],r))}r[o.name]=o.init(e,r)}})),r}}function wt(e,t,n){for(let o in e){let r=e[o];r instanceof Function?r=r.bind(t):"handleDOMEvents"==o&&(r=wt(r,t,{})),n[o]=r}return n}class vt{constructor(e){this.spec=e,this.props={},e.props&&wt(e.props,this,this.props),this.key=e.key?e.key.key:kt("plugin")}getState(e){return e[this.key]}}const bt=Object.create(null);function kt(e){return e in bt?e+"$"+ ++bt[e]:(bt[e]=0,e+"$")}class xt{constructor(e="key"){this.key=kt(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const St="k-parent-node",Ct="k-colgroup-data",Mt="k-resizable-node",Nt="k-editor-resize-handle",Ot="data-dir-table-resize",At="data-dir-image-resize";var Tt={wp:/(Windows Phone(?: OS)?)\s(\d+)\.(\d+(\.\d+)?)/,fire:/(Silk)\/(\d+)\.(\d+(\.\d+)?)/,android:/(Android|Android.*(?:Opera|Firefox).*?\/)\s*(\d+)(\.(\d+(\.\d+)?))?/,iphone:/(iPhone|iPod).*OS\s+(\d+)[\._]([\d\._]+)/,ipad:/(iPad).*OS\s+(\d+)[\._]([\d_]+)/,meego:/(MeeGo).+NokiaBrowser\/(\d+)\.([\d\._]+)/,webos:/(webOS)\/(\d+)\.(\d+(\.\d+)?)/,blackberry:/(BlackBerry|BB10).*?Version\/(\d+)\.(\d+(\.\d+)?)/,playbook:/(PlayBook).*?Tablet\s*OS\s*(\d+)\.(\d+(\.\d+)?)/,windows:/(MSIE)\s+(\d+)\.(\d+(\.\d+)?)/,tizen:/(tizen).*?Version\/(\d+)\.(\d+(\.\d+)?)/i,sailfish:/(sailfish).*rv:(\d+)\.(\d+(\.\d+)?).*firefox/i,ffos:/(Mobile).*rv:(\d+)\.(\d+(\.\d+)?).*Firefox/},Dt={ios:/^i(phone|pad|pod)$/i,android:/^android|fire$/i,blackberry:/^blackberry|playbook/i,windows:/windows/,wp:/wp/,flat:/sailfish|ffos|tizen/i,meego:/meego/},Et={edge:/(edge)[ \/]([\w.]+)/i,webkit:/(chrome)[ \/]([\w.]+)/i,safari:/(webkit)[ \/]([\w.]+)/i,opera:/(opera)(?:.*version|)[ \/]([\w.]+)/i,msie:/(msie\s|trident.*? rv:)([\w.]+)/i,mozilla:/(mozilla)(?:.*? rv:([\w.]+)|)/i},Rt={omini:/Opera\sMini/i,omobile:/Opera\sMobi/i,firefox:/Firefox|Fennec/i,mobilesafari:/version\/.*safari/i,ie:/MSIE|Windows\sPhone/i,chrome:/chrome|crios/i,webkit:/webkit/i},$t=function(e,t,n){for(var o in t)if(t.hasOwnProperty(o)&&t[o].test(e))return o;return void 0!==n?n:e},It="undefined"!=typeof window&&window.navigator?window.navigator.userAgent:null,zt=It?function(e){var t=null,n=[];for(var o in Et)if(Et.hasOwnProperty(o)&&(n=e.match(Et[o]))){(t={})[o]=!0,t[n[1].toLowerCase().split(" ")[0].split("/")[0]]=!0,t.version=parseInt(document.documentMode||n[2],10);break}return t}(It):null;It&&function(e){var t,n=[];for(var o in Tt)if(Tt.hasOwnProperty(o)){if(!(n=e.match(Tt[o])))continue;if("windows"===o&&"plugins"in window.navigator)return null;var r={};return r.device=o,r.browser=$t(e,Rt,"default"),r.name=$t(o,Dt),r[r.name]=!0,r.majorVersion=n[2],r.minorVersion=n[3]?n[3].replace("_","."):".0",t=r.minorVersion.replace(".","").substr(0,2),r.flatVersion=r.majorVersion+t+new Array(3-(t.length<3?t.length:2)).join("0"),r.cordova=void 0!==typeof window.PhoneGap||void 0!==typeof window.cordova,r.appMode=window.navigator.standalone||/file|local|wmapp/.test(window.location.protocol)||r.cordova,r}}(It),zt&&!zt.chrome&&window.MSPointerEvent,zt&&!zt.chrome&&window.PointerEvent;var Bt=/\/\*[\s\S]*?\*\//g,Pt=/([^\s:;]+?)\s*:\s*((?:(?:url\(\s*(?:(?:[^"')\\]|\\.)*|"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*')\s*\)|"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'|[^;"'])*?)\s*)(?=;|$)/gi,Vt=/&quot;|&#34;|&#x22;/gi,Ft=/&apos;|&#39;|&#x27;/gi;function Lt(e){for(var t,n,o={},r=(e||"").replace(Bt,"").replace(Vt,'"').replace(Ft,"'"),i=Pt.exec(r);null!==i;)t=i[1].trim(),n=i[2].trim(),o[t]=n,i=Pt.exec(r);return o}const Ht=(e,t)=>{const n=t.style,o=t.value,r=t.newValue;if(!e)return{changed:!1,style:null};const i=Zt(e),s=Object.keys(i),l=[];for(let e=0;e<s.length;e++){const t=s[e];t.toLowerCase()===n&&o.test(i[t])||l.push(`${t}: ${i[t]}`)}return r&&l.push(`${n}: ${r}`),{style:l.join("; ")+(l.length?";":""),changed:Boolean(r)||l.length!==s.length}},_t=/^.+$/;function Wt(e,t,n){let o;if(new RegExp("[^-]?"+t+":").test(e.style||"")){const{style:r}=Ht(e.style||"",{style:t,value:_t,newValue:n});o={...e,style:r}}else o=e.style?{...e,style:e.style.replace(/;$/,"")+"; "+t+": "+n+";"}:{...e,style:t+": "+n+";"};return o}const qt=e=>e instanceof A?e.type.name:e.name,Jt=(e,t=1)=>n=>((e,t=1)=>n=>{const{$from:o}=n;for(let n=o.depth;n>0;n--){const r=o.node(n);if(e(r)&&0==(t-=1))return{depth:n,node:r}}})((t=>qt(t)===qt(e)),t)(n);function jt(e,t){for(let n=e.depth;n>0;n--){const o=e.node(n);if(t(o))return{node:o,depth:n}}return null}const Kt=e=>{const t={};for(const n in e)n&&(e[n]||0===e[n])&&(t[n]=e[n]);return t},Xt=(e,t)=>(n,o)=>{const{selection:r,tr:i}=n;r instanceof st&&r.node.type.name===e.type.name&&e.isLeaf&&!e.isText&&1===e.nodeSize?(i.setNodeMarkup(r.from,null,{...Kt(r.node.attrs),...Kt(e.attrs)}),i.setSelection(st.create(i.doc,r.from))):i.replaceSelectionWith(e),t&&i.scrollIntoView(),o(i)},Ut=e=>{const t=e.selection;if(t instanceof rt||t instanceof at){const e=t.content().content;return e.textBetween(0,e.size)}return""},Gt={before:/[^ !,?.\[\]{}()]+$/i,after:/^[^ !,?.\[\]{}()]+/i},Yt=(e,t,n)=>{if(!n.applyToWord||!e.selection.empty)return{state:e,dispatch:t};const o=!0===n.applyToWord?Gt:n.applyToWord;let r=null;const i=e.tr,s=e.selection,l=s.$head.nodeBefore,a=s.$head.nodeAfter;if(l&&"text"===l.type.name&&l.text&&a&&"text"===a.type.name&&a.text){const n=[];s.$head.parent.descendants(((e,t)=>(n.push({node:e,pos:t}),!1)));let l=s.$head.parentOffset;const a=n.findIndex((({node:e,pos:t})=>t<=l&&t+e.nodeSize>=l));let c=n[a].node.text,d=!1;for(let e=a-1;e>=0;e--){const t=n[e];!d&&t&&"text"===t.node.type.name?c=t.node.text+c:(d=!0,l-=t.node.nodeSize)}for(let e=a+1;e<n.length;e++){const t=n[e];if(!t||"text"!==t.node.type.name)break;c+=t.node.text}const h=c.substring(0,l),p=c.substring(l),u=o.before.exec(h),f=o.after.exec(p);if(u&&f){const n=u[0].length,o=f[0].length,l=r=s.from;i.setSelection(rt.create(e.doc,l-n,l+o));return{state:{tr:i,selection:i.selection,doc:i.doc,storedMarks:null,schema:i.doc.type.schema},dispatch:e=>{e.setSelection(rt.create(e.doc,r)),t(e)}}}}return{state:e,dispatch:t}},Qt=(e,t)=>(n,o)=>{const{state:r,dispatch:i}=Yt(n,o,t);return e(t)(r,i)},Zt=e=>Lt(e),en=(e,t,n)=>{const o=Zt(e);o[t]=n;const r=Object.keys(o).map((e=>o[e]?`${e}: ${o[e]}`:null)).filter(Boolean).join("; ");return r?r+";":null},tn=(e,t)=>{const n=Zt(t);for(const t in n)t&&void 0!==e.style[t]&&(e.style[t]=n[t])},nn=(e,t,n)=>{const o=e.getAttribute(t);void 0!==n&&n!==o?"style"===t?(e.removeAttribute(t),tn(e,n)):e.setAttribute(t,n):void 0===n&&e.removeAttribute(t)};class on{static renderSpec(e,t,n=null){if("string"==typeof t)return{dom:e.createTextNode(t)};if(null!=t.nodeType)return{dom:t};if(t.dom&&null!=t.dom.nodeType)return t;let o,r=t[0],i=r.indexOf(" ");i>0&&(n=r.slice(0,i),r=r.slice(i+1));const s=n?e.createElementNS(n,r):e.createElement(r);let l=t[1],a=1;if(l&&"object"==typeof l&&null==l.nodeType&&!Array.isArray(l)){a=2;for(const e in l)null!=l[e]&&(i=e.indexOf(" "),i>0?s.setAttributeNS(e.slice(0,i),e.slice(i+1),l[e]):nn(s,e,l[e]))}for(let r=a;r<t.length;r++){const i=t[r];if(0===i){if(r<t.length-1||r>a)throw new RangeError("Content hole must be the only child of its parent node");return{dom:s,contentDOM:s}}{const{dom:t,contentDOM:r}=on.renderSpec(e,i,n);if(s.appendChild(t),r){if(o)throw new RangeError("Multiple content holes");o=r}}}return{dom:s,contentDOM:o}}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new on(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){const t=rn(e.nodes);return t.text||(t.text=e=>e.text),t}static marksFromSchema(e){return rn(e.marks)}constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},n){n||(n=sn(t).createDocumentFragment());let o=n,r=[];return e.forEach((e=>{if(r.length||e.marks.length){let n=0,i=0;for(;n<r.length&&i<e.marks.length;){const t=e.marks[i];if(this.marks[t.type.name]){if(!t.eq(r[n][0])||!1===t.type.spec.spanning)break;n++,i++}else i++}for(;n<r.length;)o=r.pop()[1];for(;i<e.marks.length;){const n=e.marks[i++],s=this.serializeMark(n,e.isInline,t);s&&(r.push([n,o]),o.appendChild(s.dom),o=s.contentDOM||s.dom)}}o.appendChild(this.serializeNodeInner(e,t))})),n}serializeNode(e,t={}){let n=this.serializeNodeInner(e,t);for(let o=e.marks.length-1;o>=0;o--){const r=this.serializeMark(e.marks[o],e.isInline,t);r&&((r.contentDOM||r.dom).appendChild(n),n=r.dom)}return n}serializeMark(e,t,n={}){const o=this.marks[e.type.name];return o&&on.renderSpec(sn(n),o(e,t))}serializeNodeInner(e,t){const{dom:n,contentDOM:o}=on.renderSpec(sn(t),this.nodes[e.type.name](e));if(o){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,o)}return n}}function rn(e){const t={};for(const n in e)if(e[n]){const o=e[n].spec.toDOM;o&&(t[n]=o)}return t}function sn(e){return e.document||window.document}const ln=["div","ol","ul","li","table","tbody","thead","tfoot","caption","td","th","p","tr","col","colgroup","article","main","nav","header","footer","aside","section"],an=(e,t)=>{const n=(e.ownerDocument||document).createElement(t);Array.from(e.rows).filter((e=>e.getAttribute(St)===t)).forEach((e=>{e.removeAttribute(St),n.appendChild(e)})),n.children.length&&e.appendChild(n)},cn=(e,t)=>{const n=t.toUpperCase();e.filter((e=>e.nodeName===n)).forEach((e=>{Array.from(e.children).forEach((n=>{n.setAttribute(St,t),e.parentNode&&e.parentNode.insertBefore(n,e)})),e.remove()}))},dn="data-style",hn=" "+dn+"=",pn=/<[^>]+>/gm,un=/\sstyle=/gm,fn=e=>e.replace(un,hn),mn=e=>{const t=document.createElement("template");var n;return t.innerHTML=(e=>e.replace(pn,fn))(e),n=t.content,Array.from(n.querySelectorAll("["+dn+"]")).forEach((e=>{const t=e.getAttribute(dn);e.removeAttribute(dn),tn(e,t)})),t.content.cloneNode(!0)},gn=e=>Array.from(e.childNodes).reduce(((e,t)=>e+(t.outerHTML||t.textContent||"")),""),yn=e=>{const t=on.fromSchema(e.type.schema).serializeFragment(e.content);return(e=>{Array.from(e.querySelectorAll("table")).forEach((e=>{an(e,"thead"),an(e,"tbody"),an(e,"tfoot");const t=Array.from(e.children).find((e=>0===e.children.length));t&&t.remove();const n=e.parentNode instanceof HTMLDivElement?e.parentNode:null;if(n&&n.matches("div[table]")){e.style.marginLeft=n.style.marginLeft,e.style.marginRight=n.style.marginRight;const t=Array.from(n.children).find((e=>e.matches("div[caption]")));if(t&&"<img>"!==t.innerHTML){const n=e.createCaption();for(t.id&&(n.id=t.id),t.className&&(n.className=t.className),Array.from(t.style).forEach((e=>{n.style[e]=t.style[e]}));t.firstChild;)n.appendChild(t.firstChild)}n.style.width&&!e.style.width&&(e.style.width=n.style.width),n.parentNode.insertBefore(e,n),n.parentNode.removeChild(n)}}))})(t),t},wn=(e,t,n)=>U.fromSchema(t).parse(e,n),vn=(e,t,n)=>{const o=mn(e);var r;return r=o,Array.from(r.querySelectorAll("table")).forEach((e=>{const t=Array.from(e.children);t.some((e=>"THEAD"===e.nodeName||"TFOOT"===e.nodeName))&&(cn(t,"thead"),cn(t,"tbody"),cn(t,"tfoot"));const n=t.find((e=>"COLGROUP"===e.nodeName));if(n&&(e.setAttribute(Ct,n.outerHTML),n.remove()),e.caption||e.style.marginLeft||e.style.marginRight){const t=document.createElement("div");if(t.setAttribute("table",""),t.style.display="table",t.style.marginLeft=e.style.marginLeft,t.style.marginRight=e.style.marginRight,e.caption){const n=document.createElement("div");for(n.setAttribute("caption",""),e.caption.id&&(n.id=e.caption.id),e.caption.className&&(n.className=e.caption.className),Array.from(e.caption.style).forEach((t=>{n.style[t]=e.caption.style[t]}));e.caption.firstChild;)n.appendChild(e.caption.firstChild);e.removeChild(e.caption),t.appendChild(n)}e.parentNode.insertBefore(t,e),t.appendChild(e),/%/.test(e.style.width)&&(t.style.width=e.style.width,e.style.width="")}})),wn(o,t,n)},bn=e=>{var t;const n=e.ownerDocument.createNodeIterator(e,NodeFilter.SHOW_COMMENT);let o=n.nextNode();for(;o;)null===(t=o.parentNode)||void 0===t||t.removeChild(o),o=n.nextNode()};class kn{constructor(e){this.extractBefore=e=>this._traverseSide({edge:e,next:function(e){return e.previousSibling},insert:function(e,t){e.insertBefore(t,e.firstChild)}}),this.extractAfter=e=>this._traverseSide({edge:e,next:function(e){return e.nextSibling},insert:function(e,t){e.appendChild(t)}}),this._traverseSide=e=>{const t=this.top,n=t.ownerDocument.createDocumentFragment();let o=e.edge;do{const r=o.parentNode;for(o=e.next(o);o;){const t=e.next(o);e.insert(n,o),o=t}if(t===r||t.contains(r)){const t=r.cloneNode(!1);t.innerHTML="",t.appendChild(n),e.insert(n,t)}o=r}while(o&&o!==t);return n},this.top=e}}const xn=e=>e.querySelector("span span"),Sn=e=>1===e.childNodes.length&&"SPAN"===e.firstChild.nodeName&&0===e.firstChild.childNodes.length,Cn=(e,t,n)=>{const o=o=>{const r=t[o],i=r.$from,s=r.$to;let l=0===i.depth&&e.type.allowsMarkType(n);if(e.nodesBetween(i.pos,s.pos,(e=>{if(l)return!1;l=e.inlineContent&&e.type.allowsMarkType(n)})),l)return{v:!0}};for(let e=0;e<t.length;e++){const t=o(e);if(t)return t.v}return!1},Mn=(e,t,n)=>(o,r)=>{const{empty:i,$cursor:s,ranges:l}=o.selection;if(i&&!s||!Cn(o.doc,l,e))return!1;if(r)if(s)e.isInSet(o.storedMarks||s.marks())?r(n.removeStoredMark(e)):r(n.addStoredMark(e.create(t)));else{let i=!1;for(let t=0;!i&&t<l.length;t++){const{$from:n,$to:r}=l[t];i=o.doc.rangeHasMark(n.pos,r.pos,e)}for(let o=0;o<l.length;o++){const{$from:r,$to:s}=l[o];i?n.removeMark(r.pos,s.pos,e):n.addMark(r.pos,s.pos,e.create(t))}r(n.scrollIntoView())}return!0},Nn=(e,t,n,o)=>{void 0===o&&(o=null);let r=[],i=0;return e.doc.nodesBetween(t,n,((e,s)=>{if(!e.isInline)return;i++;let l=null;if(o instanceof j){const t=o.isInSet(e.marks);t&&(l=[t])}else o?o.isInSet(e.marks)&&(l=[o]):l=e.marks;if(l&&l.length){const o=Math.min(s+e.nodeSize,n);for(let e=0;e<l.length;e++){let n,a=l[e];for(let e=0;e<r.length;e++){const t=r[e];t.step===i-1&&a.eq(t.style)&&(n=t)}n?(n.to=o,n.step=i):r.push({style:a,from:Math.max(s,t),to:o,step:i})}}})),r.forEach((t=>e.step(new ke(t.from,t.to,t.style)))),e},On=(e,{except:t})=>{const{doc:n,selection:o}=e,r=n.type.schema,{empty:i,ranges:s}=o,l=(t||[]).map((e=>e.name));if(!i){const t=Object.keys(r.marks).map((e=>r.marks[e])).filter((e=>-1===l.indexOf(e.name)));s.forEach((({$from:n,$to:o})=>{t.forEach((t=>e.removeMark(n.pos,o.pos,t)))}))}},An=(e,t)=>{const n=e.schema.marks,o=(t.altMarks||[]).filter((e=>n[e])),r=t.altStyle,{from:i,$from:s,to:l,empty:a}=e.selection,c=n[t.mark],d=e.doc;let h,p=!1;return a?(h=e.storedMarks||s.marks(),p=c&&c.isInSet(h)||o.some((e=>n[e].isInSet(h)))):p=c&&d.rangeHasMark(i,l,c)||o.some((e=>d.rangeHasMark(i,l,n[e]))),!p&&r&&n.style?Dn(e,n.style).some((e=>null!==Tn(e,r))):Boolean(p)},Tn=(e,t)=>{const n=e&&e.attrs.style||"",o=Zt(n),r=Object.keys(o);for(let e=0;e<r.length;e++){const n=r[e];if(n.toLowerCase()===t.name&&t.value.test(o[n]))return o[n]}return null},Dn=(e,t)=>{const{from:n,$from:o,to:r,empty:i}=e.selection,s=[];return i?s.push(t.isInSet(e.storedMarks||o.marks())):e.doc.nodesBetween(n,r,(e=>{e.isInline&&s.push(t.isInSet(e.marks))})),s},En=(e,t)=>{const n=e.find((e=>"style"===e.type.name)),o=n&&n.attrs.style;return Ht(o,t)},Rn=(e,t,n,o,r)=>{const i=r.create({style:o.style});let s=[],l=[],a=null,c=null;return e.doc.nodesBetween(t,n,((e,d,h)=>{if(!e.isInline)return;const p=e.marks;if(!i.isInSet(p)&&h.type.allowsMarkType(i.type)){const i=Math.max(d,t),h=Math.min(d+e.nodeSize,n),u=En(p,o);if(u.changed||o.newValue){const e=u.changed?{style:u.style||null}:{style:`${[o.style]}: ${o.newValue};`},t=r.isInSet(p)?p.find((e=>"style"===e.type.name)):null,n=t?{...t.attrs,...e}:e,d=r.create(n),f=d.addToSet(p);for(let e=0;e<p.length;e++)p[e].isInSet(f)||(a&&a.to===i&&a.mark.eq(p[e])?a.to=h:(a=new ke(i,h,p[e]),s.push(a)));const m=c&&c.to===i,g=m&&d.attrs.style===c.mark.attrs.style;m&&g?c.to=h:Object.keys(n).some((e=>null!==n[e]))&&(c=new be(i,h,d),l.push(c))}}})),s.forEach((t=>e.step(t))),l.forEach((t=>e.step(t))),s.length+l.length>0},$n=(e,t)=>function(n,o,r){const{empty:i,ranges:s}=n.selection,l=n.selection instanceof rt&&n.selection.$cursor;if(i&&!l||!Cn(n.doc,s,e))return!1;let a=!1;if(o){const i=r||n.tr;if(l){const r=n.storedMarks||l.marks();if(e.isInSet(r)){const n=En(r,t),s=r.find((e=>"style"===e.type.name)),l={...s?s.attrs:{},style:n.style||null};if(((e,t)=>{const n=Object.keys(e),o=Object.keys(t);return n.length===o.length&&n.every((n=>e[n]===t[n]))})(s.attrs,l))return!1;o(i.removeStoredMark(e)),Object.keys(l).some((e=>null!==l[e]))&&o(i.addStoredMark(e.create(l))),a=!0}}else{for(let n=0;n<s.length;n++){const{$from:o,$to:r}=s[n];a=Rn(i,o.pos,r.pos,t,e)||a}a&&(i.scrollIntoView(),o(i))}}return a},In=(e,t,n)=>(o,r)=>{const i=o.schema.marks,{altStyle:s,altMarks:l=[],mark:a}=e,c=t||o.tr;let d=!1,h=!1;const p=()=>h=!0;if(s&&i.style){d=$n(i.style,{style:s.name,value:s.value})(o,p,c)}const u=[a,...l].filter((e=>i[e])).map((e=>An(o,{mark:e})&&i[e])).filter((e=>e));return u.length?((e,t,n,o)=>{const{$cursor:r,ranges:i}=t.selection;if(o=o||t.tr,r)e.forEach((e=>{e.isInSet(t.storedMarks||r.marks())&&n(o.removeStoredMark(e))}));else{for(let t=0;t<i.length;t++){const{$from:n,$to:r}=i[t];e.forEach((e=>{Nn(o,n.pos,r.pos,e)}))}n(o.scrollIntoView())}})(u,o,p,c):d||Mn(i[a],n,c)(o,p),h&&r(c),h},zn=(e,t)=>(n,o)=>{const{$cursor:r}=n.selection;if(r){const i=r.parent,s=r.index(),l=n.schema.marks[e.mark],a=i.child(s).marks.find((e=>e.type===l)),c=i.childCount;let d,h,p=r.pos-r.textOffset,u=i.child(s).nodeSize;for(d=s-1;d>=0&&a.isInSet(i.child(d).marks);)h=i.child(d).nodeSize,u+=h,p-=h,d-=1;for(d=s+1;d<c&&a.isInSet(i.child(d).marks);)u+=i.child(d).nodeSize,d+=1;o(Nn(t||n.tr,p,p+u,a))}else In(e,t)(n,o)},Bn=(e,t,n,o)=>{if(!n.isTextblock)return!1;const{ranges:i}=e.selection;i.forEach((i=>{const s=e.steps.length,l=i.$from.pos,a=i.$to.pos;e.doc.nodesBetween(l,a,((i,l)=>{if(i.eq(t)&&i.isTextblock&&!i.hasMarkup(n,o)&&((e,t,n)=>{const o=e.resolve(t),r=o.index();return o.parent.canReplaceWith(r,r+1,n)})(e.doc,e.mapping.slice(s).map(l),n)){e.clearIncompatible(e.mapping.slice(s).map(l,1),n);const t=e.mapping.slice(s),a=t.map(l,1),c=t.map(l+i.nodeSize,1),h=new d(r.from(n.create(o,null,i.marks)),0,0);return e.step(new Me(a,c,a+1,c-1,h,1,!0)),!1}}))}))},Pn=(e,t={blocksInSelection:!1})=>{const{doc:n,selection:o}=e,{$from:r,ranges:i}=o,{blocksInSelection:s}=t,l=[],a=o instanceof st?o.node:void 0;return a?a.isBlock?(l.push(a),a.nodesBetween(0,a.content.size,(e=>{e.isBlock&&l.push(e)}))):!s&&r.parent&&r.parent.isBlock&&l.push(r.parent):i.forEach((e=>{const t=e.$from.pos,o=e.$to.pos;n.nodesBetween(t,o,((e,n)=>{e.isBlock&&(!s||n>=t&&n+e.content.size+2<=o)&&l.push(e)}))})),l},Vn=(e,t={blocksInSelection:!0})=>{const{doc:n,selection:o}=e,{blocksInSelection:r,blockNodeType:i}=t;Pn({doc:n,selection:o},{blocksInSelection:r}).filter((e=>e.isTextblock)).forEach((t=>{const{style:n="",class:o="",...r}=t.attrs||{},s=i||t.type;(n||o||s!==t.type)&&Bn(e,t,s,r)}))},Fn=e=>{const t=Pn(e),n=e.schema.nodes,o=[];return t.forEach((e=>{e.type===n.paragraph?o.push("p"):e.type===n.heading?o.push(`h${e.attrs.level}`):e.type===n.blockquote&&n.blockquote.isTextblock&&o.push("blockquote")})),o},Ln=(e,t)=>{let n,o,r=e.attrs.style;r&&t.forEach((e=>{o={style:e.name,value:/^.+$/,newValue:e.value},n=Ht(r,o),r=n.changed?n.style:r}));return r=r||t.reduce(((e,t)=>(e&&t.value?e+" ":"")+t.value?`${t.name}: ${t.value};`:""),""),Object.assign({},e.attrs,{style:r||null})},Hn=(e,t)=>{const{from:n,to:o}=e.selection;let r=!1;return e.doc.nodesBetween(n,o,(e=>(r=r||e.type===t,!r))),r},_n=e=>{const t=Fn(e);return 1===new Set(t).size?t[0]:null},Wn=["ol",0],qn=["ul",0],Jn=["li",0],jn={attrs:{order:{default:1,validate:"number"}},parseDOM:[{tag:"ol",getAttrs:e=>({order:e.hasAttribute("start")?+e.getAttribute("start"):1})}],toDOM:e=>1==e.attrs.order?Wn:["ol",{start:e.attrs.order},0]},Kn={parseDOM:[{tag:"ul"}],toDOM:()=>qn},Xn={parseDOM:[{tag:"li"}],toDOM:()=>Jn,defining:!0};function Un(e,t){let n={};for(let t in e)n[t]=e[t];for(let e in t)n[e]=t[e];return n}function Gn(e,t=null){return function(n,o){let{$from:r,$to:i}=n.selection,s=r.blockRange(i);if(!s)return!1;let l=o?n.tr:null;return!!Yn(l,s,e,t)&&(o&&o(l.scrollIntoView()),!0)}}function Yn(e,t,n,o=null){let i=!1,s=t,l=t.$from.doc;if(t.depth>=2&&t.$from.node(t.depth-1).type.compatibleContent(n)&&0==t.startIndex){if(0==t.$from.index(t.depth-1))return!1;let e=l.resolve(t.start-2);s=new N(e,e,t.depth),t.endIndex<t.parent.childCount&&(t=new N(t.$from,l.resolve(t.$to.end(t.depth)),t.depth)),i=!0}let a=De(s,n,o,t);return!!a&&(e&&function(e,t,n,o,i){let s=r.empty;for(let e=n.length-1;e>=0;e--)s=r.from(n[e].type.create(n[e].attrs,s));e.step(new Me(t.start-(o?2:0),t.end,t.start,t.end,new d(s,0,0),n.length,!0));let l=0;for(let e=0;e<n.length;e++)n[e].type==i&&(l=e+1);let a=n.length-l,c=t.start+n.length-(o?2:0),h=t.parent;for(let n=t.startIndex,o=t.endIndex,r=!0;n<o;n++,r=!1)!r&&Ie(e.doc,c,a)&&(e.split(c,a),c+=2*a),c+=h.child(n).nodeSize}(e,t,a,i,n),!0)}function Qn(e,t){return function(n,o){let{$from:i,$to:s,node:l}=n.selection;if(l&&l.isBlock||i.depth<2||!i.sameParent(s))return!1;let a=i.node(-1);if(a.type!=e)return!1;if(0==i.parent.content.size&&i.node(-1).childCount==i.indexAfter(-1)){if(3==i.depth||i.node(-3).type!=e||i.index(-2)!=i.node(-2).childCount-1)return!1;if(o){let t=r.empty,s=i.index(-1)?1:i.index(-2)?2:3;for(let e=i.depth-s;e>=i.depth-3;e--)t=r.from(i.node(e).copy(t));let l=i.indexAfter(-1)<i.node(-2).childCount?1:i.indexAfter(-2)<i.node(-3).childCount?2:3;t=t.append(r.from(e.createAndFill()));let a=i.before(i.depth-(s-1)),c=n.tr.replace(a,i.after(-l),new d(t,4-s,0)),h=-1;c.doc.nodesBetween(a,c.doc.content.size,((e,t)=>{if(h>-1)return!1;e.isTextblock&&0==e.content.size&&(h=t+1)})),h>-1&&c.setSelection(et.near(c.doc.resolve(h))),o(c.scrollIntoView())}return!0}let c=s.pos==i.end()?a.contentMatchAt(0).defaultType:null,h=n.tr.delete(i.pos,s.pos),p=c?[t?{type:e,attrs:t}:null,{type:c}]:void 0;return!!Ie(h.doc,i.pos,2,p)&&(o&&o(h.split(i.pos,2,p).scrollIntoView()),!0)}}function Zn(e){return function(t,n){let{$from:o,$to:i}=t.selection,s=o.blockRange(i,(t=>t.childCount>0&&t.firstChild.type==e));return!!s&&(!n||(o.node(s.depth-1).type==e?function(e,t,n,o){let i=e.tr,s=o.end,l=o.$to.end(o.depth);s<l&&(i.step(new Me(s-1,l,s,l,new d(r.from(n.create(null,o.parent.copy())),1,0),1,!0)),o=new N(i.doc.resolve(o.$from.pos),i.doc.resolve(l),o.depth));const a=Te(o);if(null==a)return!1;i.lift(o,a);let c=i.mapping.map(s,-1)-1;ze(i.doc,c)&&i.join(c);return t(i.scrollIntoView()),!0}(t,n,e,s):function(e,t,n){let o=e.tr,i=n.parent;for(let e=n.end,t=n.endIndex-1,r=n.startIndex;t>r;t--)e-=i.child(t).nodeSize,o.delete(e-1,e+1);let s=o.doc.resolve(n.start),l=s.nodeAfter;if(o.mapping.map(n.end)!=n.start+s.nodeAfter.nodeSize)return!1;let a=0==n.startIndex,c=n.endIndex==i.childCount,h=s.node(-1),p=s.index(-1);if(!h.canReplace(p+(a?0:1),p+1,l.content.append(c?r.empty:r.from(i))))return!1;let u=s.pos,f=u+l.nodeSize;return o.step(new Me(u-(a?1:0),f+(c?1:0),u+1,f-1,new d((a?r.empty:r.from(i.copy(r.empty))).append(c?r.empty:r.from(i.copy(r.empty))),a?0:1,c?0:1),a?0:1)),t(o.scrollIntoView()),!0}(t,n,s)))}}function eo(e){return function(t,n){let{$from:o,$to:i}=t.selection,s=o.blockRange(i,(t=>t.childCount>0&&t.firstChild.type==e));if(!s)return!1;let l=s.startIndex;if(0==l)return!1;let a=s.parent,c=a.child(l-1);if(c.type!=e)return!1;if(n){let o=c.lastChild&&c.lastChild.type==a.type,i=r.from(o?e.create():null),l=new d(r.from(e.create(null,r.from(a.type.create(null,i)))),o?3:1,0),h=s.start,p=s.end;n(t.tr.step(new Me(h-(o?3:1),p,h,p,l,1,!0)).scrollIntoView())}return!0}}const to={orderedList:"ordered_list",bulletList:"bullet_list",listItem:"list_item"},no={listType:to.orderedList,types:{...to}},oo={listType:to.bulletList,types:{...to}},ro={nodes:[{node:"paragraph",style:"margin-left",rtlStyle:"margin-right",step:30,unit:"px"},{node:"heading",style:"margin-left",rtlStyle:"margin-right",step:30,unit:"px"}],listsTypes:{...to}},io={nodes:[{node:"paragraph",style:"margin-left",rtlStyle:"margin-right",step:-30,unit:"px"},{node:"heading",style:"margin-left",rtlStyle:"margin-right",step:-30,unit:"px"}],listsTypes:{...to}},so=(e,t)=>!e.selection.empty&&(t&&t(e.tr.deleteSelection().scrollIntoView()),!0);function lo(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock("backward",e):n.parentOffset>0)?null:n}const ao=(e,t,n)=>{let o=lo(e,n);if(!o)return!1;let r=uo(o);if(!r){let n=o.blockRange(),r=n&&Te(n);return null!=r&&(t&&t(e.tr.lift(n,r).scrollIntoView()),!0)}let i=r.nodeBefore;if(Oo(e,r,t,-1))return!0;if(0==o.parent.content.size&&(ho(i,"end")||st.isSelectable(i)))for(let n=o.depth;;n--){let s=Le(e.doc,o.before(n),o.after(n),d.empty);if(s&&s.slice.size<s.to-s.from){if(t){let n=e.tr.step(s);n.setSelection(ho(i,"end")?et.findFrom(n.doc.resolve(n.mapping.map(r.pos,-1)),-1):st.create(n.doc,r.pos-i.nodeSize)),t(n.scrollIntoView())}return!0}if(1==n||o.node(n-1).childCount>1)break}return!(!i.isAtom||r.depth!=o.depth-1)&&(t&&t(e.tr.delete(r.pos-i.nodeSize,r.pos).scrollIntoView()),!0)};function co(e,t,n){let o=t.nodeBefore,r=t.pos-1;for(;!o.isTextblock;r--){if(o.type.spec.isolating)return!1;let e=o.lastChild;if(!e)return!1;o=e}let i=t.nodeAfter,s=t.pos+1;for(;!i.isTextblock;s++){if(i.type.spec.isolating)return!1;let e=i.firstChild;if(!e)return!1;i=e}let l=Le(e.doc,r,s,d.empty);if(!l||l.from!=r||l instanceof Ce&&l.slice.size>=s-r)return!1;if(n){let t=e.tr.step(l);t.setSelection(rt.create(t.doc,r)),n(t.scrollIntoView())}return!0}function ho(e,t,n=!1){for(let o=e;o;o="start"==t?o.firstChild:o.lastChild){if(o.isTextblock)return!0;if(n&&1!=o.childCount)return!1}return!1}const po=(e,t,n)=>{let{$head:o,empty:r}=e.selection,i=o;if(!r)return!1;if(o.parent.isTextblock){if(n?!n.endOfTextblock("backward",e):o.parentOffset>0)return!1;i=uo(o)}let s=i&&i.nodeBefore;return!(!s||!st.isSelectable(s))&&(t&&t(e.tr.setSelection(st.create(e.doc,i.pos-s.nodeSize)).scrollIntoView()),!0)};function uo(e){if(!e.parent.type.spec.isolating)for(let t=e.depth-1;t>=0;t--){if(e.index(t)>0)return e.doc.resolve(e.before(t+1));if(e.node(t).type.spec.isolating)break}return null}function fo(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock("forward",e):n.parentOffset<n.parent.content.size)?null:n}const mo=(e,t,n)=>{let o=fo(e,n);if(!o)return!1;let r=yo(o);if(!r)return!1;let i=r.nodeAfter;if(Oo(e,r,t,1))return!0;if(0==o.parent.content.size&&(ho(i,"start")||st.isSelectable(i))){let n=Le(e.doc,o.before(),o.after(),d.empty);if(n&&n.slice.size<n.to-n.from){if(t){let o=e.tr.step(n);o.setSelection(ho(i,"start")?et.findFrom(o.doc.resolve(o.mapping.map(r.pos)),1):st.create(o.doc,o.mapping.map(r.pos))),t(o.scrollIntoView())}return!0}}return!(!i.isAtom||r.depth!=o.depth-1)&&(t&&t(e.tr.delete(r.pos,r.pos+i.nodeSize).scrollIntoView()),!0)},go=(e,t,n)=>{let{$head:o,empty:r}=e.selection,i=o;if(!r)return!1;if(o.parent.isTextblock){if(n?!n.endOfTextblock("forward",e):o.parentOffset<o.parent.content.size)return!1;i=yo(o)}let s=i&&i.nodeAfter;return!(!s||!st.isSelectable(s))&&(t&&t(e.tr.setSelection(st.create(e.doc,i.pos)).scrollIntoView()),!0)};function yo(e){if(!e.parent.type.spec.isolating)for(let t=e.depth-1;t>=0;t--){let n=e.node(t);if(e.index(t)+1<n.childCount)return e.doc.resolve(e.after(t+1));if(n.type.spec.isolating)break}return null}const wo=(e,t)=>{let{$head:n,$anchor:o}=e.selection;return!(!n.parent.type.spec.code||!n.sameParent(o))&&(t&&t(e.tr.insertText("\n").scrollIntoView()),!0)};function vo(e){for(let t=0;t<e.edgeCount;t++){let{type:n}=e.edge(t);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}const bo=(e,t)=>{let{$head:n,$anchor:o}=e.selection;if(!n.parent.type.spec.code||!n.sameParent(o))return!1;let r=n.node(-1),i=n.indexAfter(-1),s=vo(r.contentMatchAt(i));if(!s||!r.canReplaceWith(i,i,s))return!1;if(t){let o=n.after(),r=e.tr.replaceWith(o,o,s.createAndFill());r.setSelection(et.near(r.doc.resolve(o),1)),t(r.scrollIntoView())}return!0},ko=(e,t)=>{let n=e.selection,{$from:o,$to:r}=n;if(n instanceof at||o.parent.inlineContent||r.parent.inlineContent)return!1;let i=vo(r.parent.contentMatchAt(r.indexAfter()));if(!i||!i.isTextblock)return!1;if(t){let n=(!o.parentOffset&&r.index()<r.parent.childCount?o:r).pos,s=e.tr.insert(n,i.createAndFill());s.setSelection(rt.create(s.doc,n+1)),t(s.scrollIntoView())}return!0},xo=(e,t)=>{let{$cursor:n}=e.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let o=n.before();if(Ie(e.doc,o))return t&&t(e.tr.split(o).scrollIntoView()),!0}let o=n.blockRange(),r=o&&Te(o);return null!=r&&(t&&t(e.tr.lift(o,r).scrollIntoView()),!0)};function So(e){return(t,n)=>{let{$from:o,$to:r}=t.selection;if(t.selection instanceof st&&t.selection.node.isBlock)return!(!o.parentOffset||!Ie(t.doc,o.pos))&&(n&&n(t.tr.split(o.pos).scrollIntoView()),!0);if(!o.depth)return!1;let i,s,l=[],a=!1,c=!1;for(let t=o.depth;;t--){if(o.node(t).isBlock){a=o.end(t)==o.pos+(o.depth-t),c=o.start(t)==o.pos-(o.depth-t),s=vo(o.node(t-1).contentMatchAt(o.indexAfter(t-1)));let n=e&&e(r.parent,a,o);l.unshift(n||(a&&s?{type:s}:null)),i=t;break}if(1==t)return!1;l.unshift(null)}let d=t.tr;(t.selection instanceof rt||t.selection instanceof at)&&d.deleteSelection();let h=d.mapping.map(o.pos),p=Ie(d.doc,h,l.length,l);if(p||(l[0]=s?{type:s}:null,p=Ie(d.doc,h,l.length,l)),d.split(h,l.length,l),!a&&c&&o.node(i).type!=s){let e=d.mapping.map(o.before(i)),t=d.doc.resolve(e);s&&o.node(i-1).canReplaceWith(t.index(),t.index()+1,s)&&d.setNodeMarkup(d.mapping.map(o.before(i)),s)}return n&&n(d.scrollIntoView()),!0}}const Co=So(),Mo=(e,t)=>Co(e,t&&(n=>{let o=e.storedMarks||e.selection.$to.parentOffset&&e.selection.$from.marks();o&&n.ensureMarks(o),t(n)})),No=(e,t)=>(t&&t(e.tr.setSelection(new at(e.doc))),!0);function Oo(e,t,n,o){let i,s,l=t.nodeBefore,a=t.nodeAfter,c=l.type.spec.isolating||a.type.spec.isolating;if(!c&&function(e,t,n){let o=t.nodeBefore,r=t.nodeAfter,i=t.index();return!(!(o&&r&&o.type.compatibleContent(r.type))||(!o.content.size&&t.parent.canReplace(i-1,i)?(n&&n(e.tr.delete(t.pos-o.nodeSize,t.pos).scrollIntoView()),0):!t.parent.canReplace(i,i+1)||!r.isTextblock&&!ze(e.doc,t.pos)||(n&&n(e.tr.join(t.pos).scrollIntoView()),0)))}(e,t,n))return!0;let h=!c&&t.parent.canReplace(t.index(),t.index()+1);if(h&&(i=(s=l.contentMatchAt(l.childCount)).findWrapping(a.type))&&s.matchType(i[0]||a.type).validEnd){if(n){let o=t.pos+a.nodeSize,s=r.empty;for(let e=i.length-1;e>=0;e--)s=r.from(i[e].create(null,s));s=r.from(l.copy(s));let c=e.tr.step(new Me(t.pos-1,o,t.pos,o,new d(s,1,0),i.length,!0)),h=c.doc.resolve(o+2*i.length);h.nodeAfter&&h.nodeAfter.type==l.type&&ze(c.doc,h.pos)&&c.join(h.pos),n(c.scrollIntoView())}return!0}let p=a.type.spec.isolating||o>0&&c?null:et.findFrom(t,1),u=p&&p.$from.blockRange(p.$to),f=u&&Te(u);if(null!=f&&f>=t.depth)return n&&n(e.tr.lift(u,f).scrollIntoView()),!0;if(h&&ho(a,"start",!0)&&ho(l,"end")){let o=l,i=[];for(;i.push(o),!o.isTextblock;)o=o.lastChild;let s=a,c=1;for(;!s.isTextblock;s=s.firstChild)c++;if(o.canReplace(o.childCount,o.childCount,s.content)){if(n){let o=r.empty;for(let e=i.length-1;e>=0;e--)o=r.from(i[e].copy(o));n(e.tr.step(new Me(t.pos-i.length,t.pos+a.nodeSize,t.pos+c,t.pos+a.nodeSize-c,new d(o,i.length,0),0,!0)).scrollIntoView())}return!0}}return!1}function Ao(e){return function(t,n){let o=t.selection,r=e<0?o.$from:o.$to,i=r.depth;for(;r.node(i).isInline;){if(!i)return!1;i--}return!!r.node(i).isTextblock&&(n&&n(t.tr.setSelection(rt.create(t.doc,e<0?r.start(i):r.end(i)))),!0)}}const To=Ao(-1),Do=Ao(1);function Eo(e,t=null){return function(n,o){let{$from:r,$to:i}=n.selection,s=r.blockRange(i),l=s&&De(s,e,t);return!!l&&(o&&o(n.tr.wrap(s,l).scrollIntoView()),!0)}}function Ro(e,t){return n=>{if(!n.isGeneric)return e(n);let o=[];for(let e=0;e<n.mapping.maps.length;e++){let t=n.mapping.maps[e];for(let e=0;e<o.length;e++)o[e]=t.map(o[e]);t.forEach(((e,t,n,r)=>o.push(n,r)))}let r=[];for(let e=0;e<o.length;e+=2){let i=o[e],s=o[e+1],l=n.doc.resolve(i),a=l.sharedDepth(s),c=l.node(a);for(let e=l.indexAfter(a),n=l.after(a+1);n<=s;++e){let o=c.maybeChild(e);if(!o)break;if(e&&-1==r.indexOf(n)){let i=c.child(e-1);i.type==o.type&&t(i,o)&&r.push(n)}n+=o.nodeSize}}r.sort(((e,t)=>e-t));for(let e=r.length-1;e>=0;e--)ze(n.doc,r[e])&&n.join(r[e]);e(n)}}function $o(e,t){let n=Array.isArray(t)?e=>t.indexOf(e.type.name)>-1:t;return(t,o,r)=>e(t,o&&Ro(o,n),r)}function Io(...e){return function(t,n,o){for(let r=0;r<e.length;r++)if(e[r](t,n,o))return!0;return!1}}let zo=Io(so,ao,po),Bo=Io(so,mo,go);const Po={Enter:Io(wo,ko,xo,Co),"Mod-Enter":bo,Backspace:zo,"Mod-Backspace":zo,"Shift-Backspace":zo,Delete:Bo,"Mod-Delete":Bo,"Mod-a":No},Vo={"Ctrl-h":Po.Backspace,"Alt-Backspace":Po["Mod-Backspace"],"Ctrl-d":Po.Delete,"Ctrl-Alt-Backspace":Po["Mod-Delete"],"Alt-Delete":Po["Mod-Delete"],"Alt-d":Po["Mod-Delete"],"Ctrl-a":To,"Ctrl-e":Do};for(let e in Po)Vo[e]=Po[e];const Fo=("undefined"!=typeof navigator?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!("undefined"==typeof os||!os.platform)&&"darwin"==os.platform())?Vo:Po,Lo=(e,t)=>{const{$from:n,$to:o}=e.selection,r=e.schema.nodes.blockquote,i=e.doc;let s=-1;const l=n.blockRange(o);l&&i.nodesBetween(l.start,l.end,((e,t)=>{e.type===r&&(s=t)}));const a=-1!==s;return t&&a&&t(e.tr.lift(l,i.resolve(s).depth)),a},Ho=(e,t,n)=>(o,r)=>{const i=Pn(o),s=o.tr;s.setMeta("commandName",t),i.forEach((t=>{if(t.type.isTextblock){let o;const r=e.find((e=>e.node===t.type.name));if(r){const e="rtl"===n?r.rtlStyle:r.style,i={name:e,value:r.step>0?`${r.step}${r.unit}`:""};if(t.attrs.style){const n=new RegExp(`${e}:\\s?(\\d+)${r.unit}`,"i"),o=t.attrs.style.match(n);if(o){let e=parseFloat(o[1])+r.step;e=e<=0?"":e,i.value=`${e}${e?r.unit:""}`}}o=Ln(t,[i])}o&&Bn(s,t,t.type,o)}}));const l=s.docChanged;return l&&r(s.scrollIntoView()),l},_o=(e,t,n)=>{const o=Pn(e);let r=!1;return o.forEach((e=>{if(!r&&e.type.isTextblock&&e.attrs.style){const o=t.find((t=>t.node===e.type.name));if(o){const t="rtl"===n?o.rtlStyle:o.style,i=new RegExp(`${t}:\\s?\\d+${o.unit}`,"i");r=i.test(e.attrs.style)}}})),r},Wo=(e,t)=>eo(t)(e),qo=(e,t)=>{const n=e.schema.nodes[t.listsTypes.listItem],o=e.schema.nodes[t.listsTypes.orderedList],r=e.schema.nodes[t.listsTypes.bulletList],i=!!Jt(o,2)(e.selection),s=!!Jt(r,2)(e.selection);return(i||s)&&Zn(n)(e)},Jo=(e,t)=>{const n=e.schema.nodes,o=n[ro.listsTypes.listItem];return(_o(e,t.nodes)||ro.nodes.some((t=>n[t.node]&&Hn(e,n[t.node]))))&&!Hn(e,o)},jo=(e,t,n)=>{let o=t.depth;const r=e.nodes[n.bulletList],i=e.nodes[n.orderedList],s=e.nodes[n.listItem];for(let e=t.depth;e>0;e--){const n=t.node(e);if(n.type!==r&&n.type!==i||(o=e),n.type!==r&&n.type!==i&&n.type!==s)break}return o-1};function Ko(e){return function(t,n,o){if(!o)return!1;const r=(t=o.state).schema.nodes[e.listType],{$from:i,$to:s}=t.selection,l=i.node(-2),a=i.node(-3),c=function(e,t,n,o){return 0===function(e,t,n){const o=[],r=function(e,t){const n=["blockquote","bulletList","orderedList"];if(1===t.depth)return t;let o=t.node(t.depth),r=t;for(;t.depth>=1;)o=(t=e.resolve(t.before(t.depth))).node(t.depth),o&&-1!==n.indexOf(o.type.name)&&(r=t);return r}(e,t).depth;let i=e.resolve(t.start(r));for(;i.pos<=n.start(n.depth);){const t=Math.min(i.depth,r),n=i.node(t);if(n&&o.push(n),0===t)break;let s=e.resolve(i.after(t));if(s.start(t)>=e.nodeSize-2)break;s.depth!==i.depth&&(s=e.resolve(s.pos+2)),i=s.depth?e.resolve(s.start(s.depth)):e.resolve(s.end(s.depth))}return o}(e,t,n).filter((e=>e.type!==o)).length}(t.doc,i,s,r);return(l&&l.type===r||a&&a.type===r)&&c?Uo(e)(t,n):(c||(Uo(e)(t,n),t=o.state),function(e,t={}){return $o(Gn(e,t),((t,n)=>t.type===n.type&&t.type===e))}(r,e.listAttrs)(t,n))}}function Xo(e,t,n,o){const i=o||e.schema.nodes.listItem,{$from:s,$to:l}=t;let a=s.blockRange(l,(e=>e.childCount&&e.firstChild.type===i));if(!a||a.depth<2||s.node(a.depth-1).type!==i)return n;const c=a.end,h=l.end(a.depth);return c<h&&(n.step(new Me(c-1,h,c,h,new d(r.from(i.create(void 0,a.parent.copy())),1,0),1,!0)),a=new N(n.doc.resolve(s.pos),n.doc.resolve(h),a.depth)),n.lift(a,Te(a)).scrollIntoView()}function Uo(e){return function(t,n){const{tr:o}=t,{$from:r,$to:i}=t.selection;return o.doc.nodesBetween(r.pos,i.pos,((n,r)=>{if(n.isTextblock||"blockquote"===n.type.name||"div"===n.type.name){const n=new st(o.doc.resolve(o.mapping.map(r))),i=n.$from.blockRange(n.$to);if(!i||n.$from.parent.type!==t.schema.nodes[e.listItem])return;const s=i&&Te(i);if(null==s)return!1;o.lift(i,s)}})),n&&n(o),!0}}const Go=/list\-style\-type:\s?([\w-]+)/,Yo=e=>{const t=e.style||"",n=Go.exec(t);return n&&n[1]||""},Qo=(e,t,n,o,r)=>{const{listType:i,listAttrs:s={style:null}}=o,{selection:l}=e,a=l.$from.node(l.$from.depth-2),c=l.$to.node(l.$to.depth-2);if(a&&a.type.name===i&&Yo(a.attrs)===Yo(s)&&c&&c.type.name===i&&Yo(c.attrs)===Yo(s)){const i=n.state.schema.nodes,s={bulletList:i[o.bulletList],orderedList:i[o.orderedList],listItem:i[o.listItem]},a=((e,t)=>{const{bulletList:n,orderedList:o,listItem:r}=t;let i;for(let t=e.depth-1;t>0;t--){const s=e.node(t);if(s.type!==n&&s.type!==o||(i=t),s.type!==n&&s.type!==o&&s.type!==r)break}return i})(l.$to,s);let c=function(e,t,n,o,r,i){i||(i=e.schema.nodes.listItem);let s=!1;return r.doc.nodesBetween(t,n,((n,l)=>{if(!s&&n.type===i&&l>t){s=!0;let t=o+3;for(;t>o+2;){const o=r.doc.resolve(r.mapping.map(l));t=o.depth;const s=r.doc.resolve(r.mapping.map(l+n.textContent.length)),a=new rt(o,s);r=Xo(e,a,r,i)}}})),r}(e,l.$to.pos,l.$to.end(a),a,n.state.tr,s.listItem);return c=function(e,t,n){const{from:o,to:r}=e.selection,{paragraph:i,heading:s}=e.schema.nodes,l=[];t.doc.nodesBetween(o,r,((e,t)=>{e.type!==i&&e.type!==s||l.push({node:e,pos:t})}));for(let o=l.length-1;o>=0;o--){const r=l[o],i=t.doc.resolve(t.mapping.map(r.pos));if(i.depth>0){let o;o=r.node.textContent&&r.node.textContent.length>0?t.doc.resolve(t.mapping.map(r.pos+r.node.textContent.length)):t.doc.resolve(t.mapping.map(r.pos+1));const s=i.blockRange(o);s&&t.lift(s,jo(e.schema,i,n))}}return t}(e,c,o),c.setMeta("commandName",r),t(c),!0}return Ko(o)(e,t,n)};const Zo=(e,t)=>({name:e,value:t}),er=[{node:"paragraph",style:[Zo("text-align","left")]},{node:"heading",style:[Zo("text-align","left")]},{node:"table_caption_external",style:[Zo("text-align","left")]}],tr=[{node:"paragraph",style:[Zo("text-align","right")]},{node:"heading",style:[Zo("text-align","right")]},{node:"table_caption_external",style:[Zo("text-align","right")]}],nr=[{node:"paragraph",style:[Zo("text-align","center")]},{node:"heading",style:[Zo("text-align","center")]},{node:"table_caption_external",style:[Zo("text-align","center")]}],or=[{node:"paragraph",style:[Zo("text-align","justify")]},{node:"heading",style:[Zo("text-align","justify")]},{node:"table_caption_external",style:[Zo("text-align","justify")]}],rr=[{node:"paragraph",style:[Zo("text-align","")]},{node:"heading",style:[Zo("text-align","")]},{node:"table_caption_external",style:[Zo("text-align","")]}],ir=function(e){for(var t=0;;t++)if(!(e=e.previousSibling))return t},sr=function(e){let t=e.assignedSlot||e.parentNode;return t&&11==t.nodeType?t.host:t};let lr=null;const ar=function(e,t,n){let o=lr||(lr=document.createRange());return o.setEnd(e,null==n?e.nodeValue.length:n),o.setStart(e,t||0),o},cr=function(e,t,n,o){return n&&(hr(e,t,n,o,-1)||hr(e,t,n,o,1))},dr=/^(img|br|input|textarea|hr)$/i;function hr(e,t,n,o,r){for(;;){if(e==n&&t==o)return!0;if(t==(r<0?0:pr(e))){let n=e.parentNode;if(!n||1!=n.nodeType||ur(e)||dr.test(e.nodeName)||"false"==e.contentEditable)return!1;t=ir(e)+(r<0?0:1),e=n}else{if(1!=e.nodeType)return!1;if("false"==(e=e.childNodes[t+(r<0?-1:0)]).contentEditable)return!1;t=r<0?pr(e):0}}}function pr(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function ur(e){let t;for(let n=e;n&&!(t=n.pmViewDesc);n=n.parentNode);return t&&t.node&&t.node.isBlock&&(t.dom==e||t.contentDOM==e)}const fr=function(e){return e.focusNode&&cr(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)};function mr(e,t){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=e,n.key=n.code=t,n}const gr="undefined"!=typeof navigator?navigator:null,yr="undefined"!=typeof document?document:null,wr=gr&&gr.userAgent||"",vr=/Edge\/(\d+)/.exec(wr),br=/MSIE \d/.exec(wr),kr=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(wr),xr=!!(br||kr||vr),Sr=br?document.documentMode:kr?+kr[1]:vr?+vr[1]:0,Cr=!xr&&/gecko\/(\d+)/i.test(wr);Cr&&(/Firefox\/(\d+)/.exec(wr)||[0,0])[1];const Mr=!xr&&/Chrome\/(\d+)/.exec(wr),Nr=!!Mr,Or=Mr?+Mr[1]:0,Ar=!xr&&!!gr&&/Apple Computer/.test(gr.vendor),Tr=Ar&&(/Mobile\/\w+/.test(wr)||!!gr&&gr.maxTouchPoints>2),Dr=Tr||!!gr&&/Mac/.test(gr.platform),Er=!!gr&&/Win/.test(gr.platform),Rr=/Android \d/.test(wr),$r=!!yr&&"webkitFontSmoothing"in yr.documentElement.style,Ir=$r?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function zr(e){let t=e.defaultView&&e.defaultView.visualViewport;return t?{left:0,right:t.width,top:0,bottom:t.height}:{left:0,right:e.documentElement.clientWidth,top:0,bottom:e.documentElement.clientHeight}}function Br(e,t){return"number"==typeof e?e:e[t]}function Pr(e){let t=e.getBoundingClientRect(),n=t.width/e.offsetWidth||1,o=t.height/e.offsetHeight||1;return{left:t.left,right:t.left+e.clientWidth*n,top:t.top,bottom:t.top+e.clientHeight*o}}function Vr(e,t,n){let o=e.someProp("scrollThreshold")||0,r=e.someProp("scrollMargin")||5,i=e.dom.ownerDocument;for(let s=n||e.dom;s;s=sr(s)){if(1!=s.nodeType)continue;let e=s,n=e==i.body,l=n?zr(i):Pr(e),a=0,c=0;if(t.top<l.top+Br(o,"top")?c=-(l.top-t.top+Br(r,"top")):t.bottom>l.bottom-Br(o,"bottom")&&(c=t.bottom-t.top>l.bottom-l.top?t.top+Br(r,"top")-l.top:t.bottom-l.bottom+Br(r,"bottom")),t.left<l.left+Br(o,"left")?a=-(l.left-t.left+Br(r,"left")):t.right>l.right-Br(o,"right")&&(a=t.right-l.right+Br(r,"right")),a||c)if(n)i.defaultView.scrollBy(a,c);else{let n=e.scrollLeft,o=e.scrollTop;c&&(e.scrollTop+=c),a&&(e.scrollLeft+=a);let r=e.scrollLeft-n,i=e.scrollTop-o;t={left:t.left-r,top:t.top-i,right:t.right-r,bottom:t.bottom-i}}if(n||/^(fixed|sticky)$/.test(getComputedStyle(s).position))break}}function Fr(e){let t=[],n=e.ownerDocument;for(let o=e;o&&(t.push({dom:o,top:o.scrollTop,left:o.scrollLeft}),e!=n);o=sr(o));return t}function Lr(e,t){for(let n=0;n<e.length;n++){let{dom:o,top:r,left:i}=e[n];o.scrollTop!=r+t&&(o.scrollTop=r+t),o.scrollLeft!=i&&(o.scrollLeft=i)}}let Hr=null;function _r(e,t){let n,o,r,i,s=2e8,l=0,a=t.top,c=t.top;for(let d=e.firstChild,h=0;d;d=d.nextSibling,h++){let e;if(1==d.nodeType)e=d.getClientRects();else{if(3!=d.nodeType)continue;e=ar(d).getClientRects()}for(let p=0;p<e.length;p++){let u=e[p];if(u.top<=a&&u.bottom>=c){a=Math.max(u.bottom,a),c=Math.min(u.top,c);let e=u.left>t.left?u.left-t.left:u.right<t.left?t.left-u.right:0;if(e<s){n=d,s=e,o=e&&3==n.nodeType?{left:u.right<t.left?u.right:u.left,top:t.top}:t,1==d.nodeType&&e&&(l=h+(t.left>=(u.left+u.right)/2?1:0));continue}}else u.top>t.top&&!r&&u.left<=t.left&&u.right>=t.left&&(r=d,i={left:Math.max(u.left,Math.min(u.right,t.left)),top:u.top});!n&&(t.left>=u.right&&t.top>=u.top||t.left>=u.left&&t.top>=u.bottom)&&(l=h+1)}}return!n&&r&&(n=r,o=i,s=0),n&&3==n.nodeType?function(e,t){let n=e.nodeValue.length,o=document.createRange();for(let r=0;r<n;r++){o.setEnd(e,r+1),o.setStart(e,r);let n=Kr(o,1);if(n.top!=n.bottom&&Wr(t,n))return{node:e,offset:r+(t.left>=(n.left+n.right)/2?1:0)}}return{node:e,offset:0}}(n,o):!n||s&&1==n.nodeType?{node:e,offset:l}:_r(n,o)}function Wr(e,t){return e.left>=t.left-1&&e.left<=t.right+1&&e.top>=t.top-1&&e.top<=t.bottom+1}function qr(e,t,n){let o=e.childNodes.length;if(o&&n.top<n.bottom)for(let r=Math.max(0,Math.min(o-1,Math.floor(o*(t.top-n.top)/(n.bottom-n.top))-2)),i=r;;){let n=e.childNodes[i];if(1==n.nodeType){let e=n.getClientRects();for(let o=0;o<e.length;o++){let r=e[o];if(Wr(t,r))return qr(n,t,r)}}if((i=(i+1)%o)==r)break}return e}function Jr(e,t){let n,o=e.dom.ownerDocument,r=0,i=function(e,t,n){if(e.caretPositionFromPoint)try{let o=e.caretPositionFromPoint(t,n);if(o)return{node:o.offsetNode,offset:Math.min(pr(o.offsetNode),o.offset)}}catch(e){}if(e.caretRangeFromPoint){let o=e.caretRangeFromPoint(t,n);if(o)return{node:o.startContainer,offset:Math.min(pr(o.startContainer),o.startOffset)}}}(o,t.left,t.top);i&&({node:n,offset:r}=i);let s,l=(e.root.elementFromPoint?e.root:o).elementFromPoint(t.left,t.top);if(!l||!e.dom.contains(1!=l.nodeType?l.parentNode:l)){let n=e.dom.getBoundingClientRect();if(!Wr(t,n))return null;if(l=qr(e.dom,t,n),!l)return null}if(Ar)for(let e=l;n&&e;e=sr(e))e.draggable&&(n=void 0);if(l=function(e,t){let n=e.parentNode;return n&&/^li$/i.test(n.nodeName)&&t.left<e.getBoundingClientRect().left?n:e}(l,t),n){if(Cr&&1==n.nodeType&&(r=Math.min(r,n.childNodes.length),r<n.childNodes.length)){let e,o=n.childNodes[r];"IMG"==o.nodeName&&(e=o.getBoundingClientRect()).right<=t.left&&e.bottom>t.top&&r++}let o;$r&&r&&1==n.nodeType&&1==(o=n.childNodes[r-1]).nodeType&&"false"==o.contentEditable&&o.getBoundingClientRect().top>=t.top&&r--,n==e.dom&&r==n.childNodes.length-1&&1==n.lastChild.nodeType&&t.top>n.lastChild.getBoundingClientRect().bottom?s=e.state.doc.content.size:0!=r&&1==n.nodeType&&"BR"==n.childNodes[r-1].nodeName||(s=function(e,t,n,o){let r=-1;for(let n=t,i=!1;n!=e.dom;){let t,s=e.docView.nearestDesc(n,!0);if(!s)return null;if(1==s.dom.nodeType&&(s.node.isBlock&&s.parent||!s.contentDOM)&&((t=s.dom.getBoundingClientRect()).width||t.height)&&(s.node.isBlock&&s.parent&&(!i&&t.left>o.left||t.top>o.top?r=s.posBefore:(!i&&t.right<o.left||t.bottom<o.top)&&(r=s.posAfter),i=!0),!s.contentDOM&&r<0&&!s.node.isText))return(s.node.isBlock?o.top<(t.top+t.bottom)/2:o.left<(t.left+t.right)/2)?s.posBefore:s.posAfter;n=s.dom.parentNode}return r>-1?r:e.docView.posFromDOM(t,n,-1)}(e,n,r,t))}null==s&&(s=function(e,t,n){let{node:o,offset:r}=_r(t,n),i=-1;if(1==o.nodeType&&!o.firstChild){let e=o.getBoundingClientRect();i=e.left!=e.right&&n.left>(e.left+e.right)/2?1:-1}return e.docView.posFromDOM(o,r,i)}(e,l,t));let a=e.docView.nearestDesc(l,!0);return{pos:s,inside:a?a.posAtStart-a.border:-1}}function jr(e){return e.top<e.bottom||e.left<e.right}function Kr(e,t){let n=e.getClientRects();if(n.length){let e=n[t<0?0:n.length-1];if(jr(e))return e}return Array.prototype.find.call(n,jr)||e.getBoundingClientRect()}const Xr=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Ur(e,t,n){let{node:o,offset:r,atom:i}=e.docView.domFromPos(t,n<0?-1:1),s=$r||Cr;if(3==o.nodeType){if(!s||!Xr.test(o.nodeValue)&&(n<0?r:r!=o.nodeValue.length)){let e=r,t=r,i=n<0?1:-1;return n<0&&!r?(t++,i=-1):n>=0&&r==o.nodeValue.length?(e--,i=1):n<0?e--:t++,Gr(Kr(ar(o,e,t),i),i<0)}{let e=Kr(ar(o,r,r),n);if(Cr&&r&&/\s/.test(o.nodeValue[r-1])&&r<o.nodeValue.length){let t=Kr(ar(o,r-1,r-1),-1);if(t.top==e.top){let n=Kr(ar(o,r,r+1),-1);if(n.top!=e.top)return Gr(n,n.left<t.left)}}return e}}if(!e.state.doc.resolve(t-(i||0)).parent.inlineContent){if(null==i&&r&&(n<0||r==pr(o))){let e=o.childNodes[r-1];if(1==e.nodeType)return Yr(e.getBoundingClientRect(),!1)}if(null==i&&r<pr(o)){let e=o.childNodes[r];if(1==e.nodeType)return Yr(e.getBoundingClientRect(),!0)}return Yr(o.getBoundingClientRect(),n>=0)}if(null==i&&r&&(n<0||r==pr(o))){let e=o.childNodes[r-1],t=3==e.nodeType?ar(e,pr(e)-(s?0:1)):1!=e.nodeType||"BR"==e.nodeName&&e.nextSibling?null:e;if(t)return Gr(Kr(t,1),!1)}if(null==i&&r<pr(o)){let e=o.childNodes[r];for(;e.pmViewDesc&&e.pmViewDesc.ignoreForCoords;)e=e.nextSibling;let t=e?3==e.nodeType?ar(e,0,s?0:1):1==e.nodeType?e:null:null;if(t)return Gr(Kr(t,-1),!0)}return Gr(Kr(3==o.nodeType?ar(o):o,-n),n>=0)}function Gr(e,t){if(0==e.width)return e;let n=t?e.left:e.right;return{top:e.top,bottom:e.bottom,left:n,right:n}}function Yr(e,t){if(0==e.height)return e;let n=t?e.top:e.bottom;return{top:n,bottom:n,left:e.left,right:e.right}}function Qr(e,t,n){let o=e.state,r=e.root.activeElement;o!=t&&e.updateState(t),r!=e.dom&&e.focus();try{return n()}finally{o!=t&&e.updateState(o),r!=e.dom&&r&&r.focus()}}const Zr=/[\u0590-\u08ac]/;let ei=null,ti=null,ni=!1;function oi(e,t,n){return ei==t&&ti==n?ni:(ei=t,ti=n,ni="up"==n||"down"==n?function(e,t,n){let o=t.selection,r="up"==n?o.$from:o.$to;return Qr(e,t,(()=>{let{node:t}=e.docView.domFromPos(r.pos,"up"==n?-1:1);for(;;){let n=e.docView.nearestDesc(t,!0);if(!n)break;if(n.node.isBlock){t=n.contentDOM||n.dom;break}t=n.dom.parentNode}let o=Ur(e,r.pos,1);for(let e=t.firstChild;e;e=e.nextSibling){let t;if(1==e.nodeType)t=e.getClientRects();else{if(3!=e.nodeType)continue;t=ar(e,0,e.nodeValue.length).getClientRects()}for(let e=0;e<t.length;e++){let r=t[e];if(r.bottom>r.top+1&&("up"==n?o.top-r.top>2*(r.bottom-o.top):r.bottom-o.bottom>2*(o.bottom-r.top)))return!1}}return!0}))}(e,t,n):function(e,t,n){let{$head:o}=t.selection;if(!o.parent.isTextblock)return!1;let r=o.parentOffset,i=!r,s=r==o.parent.content.size,l=e.domSelection();return l?Zr.test(o.parent.textContent)&&l.modify?Qr(e,t,(()=>{let{focusNode:t,focusOffset:r,anchorNode:i,anchorOffset:s}=e.domSelectionRange(),a=l.caretBidiLevel;l.modify("move",n,"character");let c=o.depth?e.docView.domAfterPos(o.before()):e.dom,{focusNode:d,focusOffset:h}=e.domSelectionRange(),p=d&&!c.contains(1==d.nodeType?d:d.parentNode)||t==d&&r==h;try{l.collapse(i,s),t&&(t!=i||r!=s)&&l.extend&&l.extend(t,r)}catch(e){}return null!=a&&(l.caretBidiLevel=a),p})):"left"==n||"backward"==n?i:s:o.pos==o.start()||o.pos==o.end()}(e,t,n))}class ri{constructor(e,t,n,o){this.parent=e,this.children=t,this.dom=n,this.contentDOM=o,this.dirty=0,n.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,n){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;t<this.children.length;t++)e+=this.children[t].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let t=0,n=this.posAtStart;;t++){let o=this.children[t];if(o==e)return n;n+=o.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,t,n){if(this.contentDOM&&this.contentDOM.contains(1==e.nodeType?e:e.parentNode)){if(n<0){let n,o;if(e==this.contentDOM)n=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;n=e.previousSibling}for(;n&&(!(o=n.pmViewDesc)||o.parent!=this);)n=n.previousSibling;return n?this.posBeforeChild(o)+o.size:this.posAtStart}{let n,o;if(e==this.contentDOM)n=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;n=e.nextSibling}for(;n&&(!(o=n.pmViewDesc)||o.parent!=this);)n=n.nextSibling;return n?this.posBeforeChild(o):this.posAtEnd}}let o;if(e==this.dom&&this.contentDOM)o=t>ir(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))o=2&e.compareDocumentPosition(this.contentDOM);else if(this.dom.firstChild){if(0==t)for(let t=e;;t=t.parentNode){if(t==this.dom){o=!1;break}if(t.previousSibling)break}if(null==o&&t==e.childNodes.length)for(let t=e;;t=t.parentNode){if(t==this.dom){o=!0;break}if(t.nextSibling)break}}return(null==o?n>0:o)?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let n=!0,o=e;o;o=o.parentNode){let r,i=this.getDesc(o);if(i&&(!t||i.node)){if(!n||!(r=i.nodeDOM)||(1==r.nodeType?r.contains(1==e.nodeType?e:e.parentNode):r==e))return i;n=!1}}}getDesc(e){let t=e.pmViewDesc;for(let e=t;e;e=e.parent)if(e==this)return t}posFromDOM(e,t,n){for(let o=e;o;o=o.parentNode){let r=this.getDesc(o);if(r)return r.localPosFromDOM(e,t,n)}return-1}descAt(e){for(let t=0,n=0;t<this.children.length;t++){let o=this.children[t],r=n+o.size;if(n==e&&r!=n){for(;!o.border&&o.children.length;)for(let e=0;e<o.children.length;e++){let t=o.children[e];if(t.size){o=t;break}}return o}if(e<r)return o.descAt(e-n-o.border);n=r}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let n=0,o=0;for(let t=0;n<this.children.length;n++){let r=this.children[n],i=t+r.size;if(i>e||r instanceof hi){o=e-t;break}t=i}if(o)return this.children[n].domFromPos(o-this.children[n].border,t);for(let e;n&&!(e=this.children[n-1]).size&&e instanceof ii&&e.side>=0;n--);if(t<=0){let e,o=!0;for(;e=n?this.children[n-1]:null,e&&e.dom.parentNode!=this.contentDOM;n--,o=!1);return e&&t&&o&&!e.border&&!e.domAtom?e.domFromPos(e.size,t):{node:this.contentDOM,offset:e?ir(e.dom)+1:0}}{let e,o=!0;for(;e=n<this.children.length?this.children[n]:null,e&&e.dom.parentNode!=this.contentDOM;n++,o=!1);return e&&o&&!e.border&&!e.domAtom?e.domFromPos(0,t):{node:this.contentDOM,offset:e?ir(e.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,n=0){if(0==this.children.length)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let o=-1,r=-1;for(let i=n,s=0;;s++){let n=this.children[s],l=i+n.size;if(-1==o&&e<=l){let r=i+n.border;if(e>=r&&t<=l-n.border&&n.node&&n.contentDOM&&this.contentDOM.contains(n.contentDOM))return n.parseRange(e,t,r);e=i;for(let t=s;t>0;t--){let n=this.children[t-1];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(1)){o=ir(n.dom)+1;break}e-=n.size}-1==o&&(o=0)}if(o>-1&&(l>t||s==this.children.length-1)){t=l;for(let e=s+1;e<this.children.length;e++){let n=this.children[e];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(-1)){r=ir(n.dom);break}t+=n.size}-1==r&&(r=this.contentDOM.childNodes.length);break}i=l}return{node:this.contentDOM,from:e,to:t,fromOffset:o,toOffset:r}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let t=this.children[e<0?0:this.children.length-1];return 0==t.size||t.emptyChildAt(e)}domAfterPos(e){let{node:t,offset:n}=this.domFromPos(e,0);if(1!=t.nodeType||n==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[n]}setSelection(e,t,n,o=!1){let r=Math.min(e,t),i=Math.max(e,t);for(let s=0,l=0;s<this.children.length;s++){let a=this.children[s],c=l+a.size;if(r>l&&i<c)return a.setSelection(e-l-a.border,t-l-a.border,n,o);l=c}let s=this.domFromPos(e,e?-1:1),l=t==e?s:this.domFromPos(t,t?-1:1),a=n.root.getSelection(),c=n.domSelectionRange(),d=!1;if((Cr||Ar)&&e==t){let{node:e,offset:t}=s;if(3==e.nodeType){if(d=!(!t||"\n"!=e.nodeValue[t-1]),d&&t==e.nodeValue.length)for(let t,n=e;n;n=n.parentNode){if(t=n.nextSibling){"BR"==t.nodeName&&(s=l={node:t.parentNode,offset:ir(t)+1});break}let e=n.pmViewDesc;if(e&&e.node&&e.node.isBlock)break}}else{let n=e.childNodes[t-1];d=n&&("BR"==n.nodeName||"false"==n.contentEditable)}}if(Cr&&c.focusNode&&c.focusNode!=l.node&&1==c.focusNode.nodeType){let e=c.focusNode.childNodes[c.focusOffset];e&&"false"==e.contentEditable&&(o=!0)}if(!(o||d&&Ar)&&cr(s.node,s.offset,c.anchorNode,c.anchorOffset)&&cr(l.node,l.offset,c.focusNode,c.focusOffset))return;let h=!1;if((a.extend||e==t)&&!d){a.collapse(s.node,s.offset);try{e!=t&&a.extend(l.node,l.offset),h=!0}catch(e){}}if(!h){if(e>t){let e=s;s=l,l=e}let n=document.createRange();n.setEnd(l.node,l.offset),n.setStart(s.node,s.offset),a.removeAllRanges(),a.addRange(n)}}ignoreMutation(e){return!this.contentDOM&&"selection"!=e.type}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let n=0,o=0;o<this.children.length;o++){let r=this.children[o],i=n+r.size;if(n==i?e<=i&&t>=n:e<i&&t>n){let o=n+r.border,s=i-r.border;if(e>=o&&t<=s)return this.dirty=e==n||t==i?2:1,void(e!=o||t!=s||!r.contentLost&&r.dom.parentNode==this.contentDOM?r.markDirty(e-o,t-o):r.dirty=3);r.dirty=r.dom!=r.contentDOM||r.dom.parentNode!=this.contentDOM||r.children.length?3:2}n=i}this.dirty=2}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let n=1==e?2:1;t.dirty<n&&(t.dirty=n)}}get domAtom(){return!1}get ignoreForCoords(){return!1}isText(e){return!1}}class ii extends ri{constructor(e,t,n,o){let r,i=t.type.toDOM;if("function"==typeof i&&(i=i(n,(()=>r?r.parent?r.parent.posBeforeChild(r):void 0:o))),!t.type.spec.raw){if(1!=i.nodeType){let e=document.createElement("span");e.appendChild(i),i=e}i.contentEditable="false",i.classList.add("ProseMirror-widget")}super(e,[],i,null),this.widget=t,this.widget=t,r=this}matchesWidget(e){return 0==this.dirty&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return!!t&&t(e)}ignoreMutation(e){return"selection"!=e.type||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get side(){return this.widget.type.side}}class si extends ri{constructor(e,t,n,o){super(e,[],t,null),this.textDOM=n,this.text=o}get size(){return this.text.length}localPosFromDOM(e,t){return e!=this.textDOM?this.posAtStart+(t?this.size:0):this.posAtStart+t}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return"characterData"===e.type&&e.target.nodeValue==e.oldValue}}class li extends ri{constructor(e,t,n,o,r){super(e,[],n,o),this.mark=t,this.spec=r}static create(e,t,n,o){let r=o.nodeViews[t.type.name],i=r&&r(t,o,n);return i&&i.dom||(i=ie.renderSpec(document,t.type.spec.toDOM(t,n),null,t.attrs)),new li(e,t,i.dom,i.contentDOM||i.dom,i)}parseRule(){return 3&this.dirty||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return 3!=this.dirty&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),0!=this.dirty){let e=this.parent;for(;!e.node;)e=e.parent;e.dirty<this.dirty&&(e.dirty=this.dirty),this.dirty=0}}slice(e,t,n){let o=li.create(this.parent,this.mark,!0,n),r=this.children,i=this.size;t<i&&(r=Ci(r,t,i,n)),e>0&&(r=Ci(r,0,e,n));for(let e=0;e<r.length;e++)r[e].parent=o;return o.children=r,o}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class ai extends ri{constructor(e,t,n,o,r,i,s,l,a){super(e,[],r,i),this.node=t,this.outerDeco=n,this.innerDeco=o,this.nodeDOM=s}static create(e,t,n,o,r,i){let s,l=r.nodeViews[t.type.name],a=l&&l(t,r,(()=>s?s.parent?s.parent.posBeforeChild(s):void 0:i),n,o),c=a&&a.dom,d=a&&a.contentDOM;if(t.isText)if(c){if(3!=c.nodeType)throw new RangeError("Text must be rendered as a DOM text node")}else c=document.createTextNode(t.text);else if(!c){let e=ie.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs);({dom:c,contentDOM:d}=e)}d||t.isText||"BR"==c.nodeName||(c.hasAttribute("contenteditable")||(c.contentEditable="false"),t.type.spec.draggable&&(c.draggable=!0));let h=c;return c=vi(c,n,t),a?s=new pi(e,t,n,o,c,d||null,h,a,r,i+1):t.isText?new di(e,t,n,o,c,h,r):new ai(e,t,n,o,c,d||null,h,r,i+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if("pre"==this.node.type.whitespace&&(e.preserveWhitespace="full"),this.contentDOM)if(this.contentLost){for(let t=this.children.length-1;t>=0;t--){let n=this.children[t];if(this.dom.contains(n.dom.parentNode)){e.contentElement=n.dom.parentNode;break}}e.contentElement||(e.getContent=()=>r.empty)}else e.contentElement=this.contentDOM;else e.getContent=()=>this.node.content;return e}matchesNode(e,t,n){return 0==this.dirty&&e.eq(this.node)&&bi(t,this.outerDeco)&&n.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let n=this.node.inlineContent,o=t,r=e.composing?this.localCompositionInfo(e,t):null,i=r&&r.pos>-1?r:null,s=r&&r.pos<0,l=new xi(this,i&&i.node,e);!function(e,t,n,o){let r=t.locals(e),i=0;if(0==r.length){for(let n=0;n<e.childCount;n++){let s=e.child(n);o(s,r,t.forChild(i,s),n),i+=s.nodeSize}return}let s=0,l=[],a=null;for(let c=0;;){let d,h,p,u;for(;s<r.length&&r[s].to==i;){let e=r[s++];e.widget&&(d?(h||(h=[d])).push(e):d=e)}if(d)if(h){h.sort(Si);for(let e=0;e<h.length;e++)n(h[e],c,!!a)}else n(d,c,!!a);if(a)u=-1,p=a,a=null;else{if(!(c<e.childCount))break;u=c,p=e.child(c++)}for(let e=0;e<l.length;e++)l[e].to<=i&&l.splice(e--,1);for(;s<r.length&&r[s].from<=i&&r[s].to>i;)l.push(r[s++]);let f=i+p.nodeSize;if(p.isText){let e=f;s<r.length&&r[s].from<e&&(e=r[s].from);for(let t=0;t<l.length;t++)l[t].to<e&&(e=l[t].to);e<f&&(a=p.cut(e-i),p=p.cut(0,e-i),f=e,u=-1)}else for(;s<r.length&&r[s].to<f;)s++;o(p,p.isInline&&!p.isLeaf?l.filter((e=>!e.inline)):l.slice(),t.forChild(i,p),u),i=f}}(this.node,this.innerDeco,((t,r,i)=>{t.spec.marks?l.syncToMarks(t.spec.marks,n,e):t.type.side>=0&&!i&&l.syncToMarks(r==this.node.childCount?a.none:this.node.child(r).marks,n,e),l.placeWidget(t,e,o)}),((t,i,a,c)=>{let d;l.syncToMarks(t.marks,n,e),l.findNodeMatch(t,i,a,c)||s&&e.state.selection.from>o&&e.state.selection.to<o+t.nodeSize&&(d=l.findIndexWithChild(r.node))>-1&&l.updateNodeAt(t,i,a,d,e)||l.updateNextNode(t,i,a,e,c,o)||l.addNode(t,i,a,e,o),o+=t.nodeSize})),l.syncToMarks([],n,e),this.node.isTextblock&&l.addTextblockHacks(),l.destroyRest(),(l.changed||2==this.dirty)&&(i&&this.protectLocalComposition(e,i),ui(this.contentDOM,this.children,e),Tr&&function(e){if("UL"==e.nodeName||"OL"==e.nodeName){let t=e.style.cssText;e.style.cssText=t+"; list-style: square !important",window.getComputedStyle(e).listStyle,e.style.cssText=t}}(this.dom))}localCompositionInfo(e,t){let{from:n,to:o}=e.state.selection;if(!(e.state.selection instanceof rt)||n<t||o>t+this.node.content.size)return null;let r=e.input.compositionNode;if(!r||!this.dom.contains(r.parentNode))return null;if(this.node.inlineContent){let e=r.nodeValue,i=function(e,t,n,o){for(let r=0,i=0;r<e.childCount&&i<=o;){let s=e.child(r++),l=i;if(i+=s.nodeSize,!s.isText)continue;let a=s.text;for(;r<e.childCount;){let t=e.child(r++);if(i+=t.nodeSize,!t.isText)break;a+=t.text}if(i>=n){if(i>=o&&a.slice(o-t.length-l,o-l)==t)return o-t.length;let e=l<o?a.lastIndexOf(t,o-l-1):-1;if(e>=0&&e+t.length+l>=n)return l+e;if(n==o&&a.length>=o+t.length-l&&a.slice(o-l,o-l+t.length)==t)return o}}return-1}(this.node.content,e,n-t,o-t);return i<0?null:{node:r,pos:i,text:e}}return{node:r,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:n,text:o}){if(this.getDesc(t))return;let r=t;for(;r.parentNode!=this.contentDOM;r=r.parentNode){for(;r.previousSibling;)r.parentNode.removeChild(r.previousSibling);for(;r.nextSibling;)r.parentNode.removeChild(r.nextSibling);r.pmViewDesc&&(r.pmViewDesc=void 0)}let i=new si(this,r,t,o);e.input.compositionNodes.push(i),this.children=Ci(this.children,n,n+o.length,e,i)}update(e,t,n,o){return!(3==this.dirty||!e.sameMarkup(this.node))&&(this.updateInner(e,t,n,o),!0)}updateInner(e,t,n,o){this.updateOuterDeco(t),this.node=e,this.innerDeco=n,this.contentDOM&&this.updateChildren(o,this.posAtStart),this.dirty=0}updateOuterDeco(e){if(bi(e,this.outerDeco))return;let t=1!=this.nodeDOM.nodeType,n=this.dom;this.dom=yi(this.dom,this.nodeDOM,gi(this.outerDeco,this.node,t),gi(e,this.node,t)),this.dom!=n&&(n.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){1==this.nodeDOM.nodeType&&this.nodeDOM.classList.add("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||(this.dom.draggable=!0)}deselectNode(){1==this.nodeDOM.nodeType&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||this.dom.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function ci(e,t,n,o,r){vi(o,t,e);let i=new ai(void 0,e,t,n,o,o,o,r,0);return i.contentDOM&&i.updateChildren(r,0),i}class di extends ai{constructor(e,t,n,o,r,i,s){super(e,t,n,o,r,null,i,s,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,n,o){return!(3==this.dirty||0!=this.dirty&&!this.inParent()||!e.sameMarkup(this.node))&&(this.updateOuterDeco(t),0==this.dirty&&e.text==this.node.text||e.text==this.nodeDOM.nodeValue||(this.nodeDOM.nodeValue=e.text,o.trackWrites==this.nodeDOM&&(o.trackWrites=null)),this.node=e,this.dirty=0,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,n){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,n)}ignoreMutation(e){return"characterData"!=e.type&&"selection"!=e.type}slice(e,t,n){let o=this.node.cut(e,t),r=document.createTextNode(o.text);return new di(this.parent,o,this.outerDeco,this.innerDeco,r,r,n)}markDirty(e,t){super.markDirty(e,t),this.dom==this.nodeDOM||0!=e&&t!=this.nodeDOM.nodeValue.length||(this.dirty=3)}get domAtom(){return!1}isText(e){return this.node.text==e}}class hi extends ri{parseRule(){return{ignore:!0}}matchesHack(e){return 0==this.dirty&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return"IMG"==this.dom.nodeName}}class pi extends ai{constructor(e,t,n,o,r,i,s,l,a,c){super(e,t,n,o,r,i,s,a,c),this.spec=l}update(e,t,n,o){if(3==this.dirty)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let r=this.spec.update(e,t,n);return r&&this.updateInner(e,t,n,o),r}return!(!this.contentDOM&&!e.isLeaf)&&super.update(e,t,n,o)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,n,o){this.spec.setSelection?this.spec.setSelection(e,t,n.root):super.setSelection(e,t,n,o)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return!!this.spec.stopEvent&&this.spec.stopEvent(e)}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function ui(e,t,n){let o=e.firstChild,r=!1;for(let i=0;i<t.length;i++){let s=t[i],l=s.dom;if(l.parentNode==e){for(;l!=o;)o=ki(o),r=!0;o=o.nextSibling}else r=!0,e.insertBefore(l,o);if(s instanceof li){let t=o?o.previousSibling:e.lastChild;ui(s.contentDOM,s.children,n),o=t?t.nextSibling:e.firstChild}}for(;o;)o=ki(o),r=!0;r&&n.trackWrites==e&&(n.trackWrites=null)}const fi=function(e){e&&(this.nodeName=e)};fi.prototype=Object.create(null);const mi=[new fi];function gi(e,t,n){if(0==e.length)return mi;let o=n?mi[0]:new fi,r=[o];for(let i=0;i<e.length;i++){let s=e[i].type.attrs;if(s){s.nodeName&&r.push(o=new fi(s.nodeName));for(let e in s){let i=s[e];null!=i&&(n&&1==r.length&&r.push(o=new fi(t.isInline?"span":"div")),"class"==e?o.class=(o.class?o.class+" ":"")+i:"style"==e?o.style=(o.style?o.style+";":"")+i:"nodeName"!=e&&(o[e]=i))}}}return r}function yi(e,t,n,o){if(n==mi&&o==mi)return t;let r=t;for(let t=0;t<o.length;t++){let i=o[t],s=n[t];if(t){let t;s&&s.nodeName==i.nodeName&&r!=e&&(t=r.parentNode)&&t.nodeName.toLowerCase()==i.nodeName||(t=document.createElement(i.nodeName),t.pmIsDeco=!0,t.appendChild(r),s=mi[0]),r=t}wi(r,s||mi[0],i)}return r}function wi(e,t,n){for(let o in t)"class"==o||"style"==o||"nodeName"==o||o in n||e.removeAttribute(o);for(let o in n)"class"!=o&&"style"!=o&&"nodeName"!=o&&n[o]!=t[o]&&e.setAttribute(o,n[o]);if(t.class!=n.class){let o=t.class?t.class.split(" ").filter(Boolean):[],r=n.class?n.class.split(" ").filter(Boolean):[];for(let t=0;t<o.length;t++)-1==r.indexOf(o[t])&&e.classList.remove(o[t]);for(let t=0;t<r.length;t++)-1==o.indexOf(r[t])&&e.classList.add(r[t]);0==e.classList.length&&e.removeAttribute("class")}if(t.style!=n.style){if(t.style){let n,o=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g;for(;n=o.exec(t.style);)e.style.removeProperty(n[1])}n.style&&(e.style.cssText+=n.style)}}function vi(e,t,n){return yi(e,e,mi,gi(t,n,1!=e.nodeType))}function bi(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].type.eq(t[n].type))return!1;return!0}function ki(e){let t=e.nextSibling;return e.parentNode.removeChild(e),t}class xi{constructor(e,t,n){this.lock=t,this.view=n,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=function(e,t){let n=t,o=n.children.length,r=e.childCount,i=new Map,s=[];e:for(;r>0;){let l;for(;;)if(o){let e=n.children[o-1];if(!(e instanceof li)){l=e,o--;break}n=e,o=e.children.length}else{if(n==t)break e;o=n.parent.children.indexOf(n),n=n.parent}let a=l.node;if(a){if(a!=e.child(r-1))break;--r,i.set(l,r),s.push(l)}}return{index:r,matched:i,matches:s.reverse()}}(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let n=e;n<t;n++)this.top.children[n].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,n){let o=0,r=this.stack.length>>1,i=Math.min(r,e.length);for(;o<i&&(o==r-1?this.top:this.stack[o+1<<1]).matchesMark(e[o])&&!1!==e[o].type.spec.spanning;)o++;for(;o<r;)this.destroyRest(),this.top.dirty=0,this.index=this.stack.pop(),this.top=this.stack.pop(),r--;for(;r<e.length;){this.stack.push(this.top,this.index+1);let o=-1;for(let t=this.index;t<Math.min(this.index+3,this.top.children.length);t++){let n=this.top.children[t];if(n.matchesMark(e[r])&&!this.isLocked(n.dom)){o=t;break}}if(o>-1)o>this.index&&(this.changed=!0,this.destroyBetween(this.index,o)),this.top=this.top.children[this.index];else{let o=li.create(this.top,e[r],t,n);this.top.children.splice(this.index,0,o),this.top=o,this.changed=!0}this.index=0,r++}}findNodeMatch(e,t,n,o){let r,i=-1;if(o>=this.preMatch.index&&(r=this.preMatch.matches[o-this.preMatch.index]).parent==this.top&&r.matchesNode(e,t,n))i=this.top.children.indexOf(r,this.index);else for(let o=this.index,r=Math.min(this.top.children.length,o+5);o<r;o++){let r=this.top.children[o];if(r.matchesNode(e,t,n)&&!this.preMatch.matched.has(r)){i=o;break}}return!(i<0)&&(this.destroyBetween(this.index,i),this.index++,!0)}updateNodeAt(e,t,n,o,r){let i=this.top.children[o];return 3==i.dirty&&i.dom==i.contentDOM&&(i.dirty=2),!!i.update(e,t,n,r)&&(this.destroyBetween(this.index,o),this.index++,!0)}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let t=e.pmViewDesc;if(t)for(let e=this.index;e<this.top.children.length;e++)if(this.top.children[e]==t)return e;return-1}e=t}}updateNextNode(e,t,n,o,r,i){for(let s=this.index;s<this.top.children.length;s++){let l=this.top.children[s];if(l instanceof ai){let a=this.preMatch.matched.get(l);if(null!=a&&a!=r)return!1;let c,d=l.dom,h=this.isLocked(d)&&!(e.isText&&l.node&&l.node.isText&&l.nodeDOM.nodeValue==e.text&&3!=l.dirty&&bi(t,l.outerDeco));if(!h&&l.update(e,t,n,o))return this.destroyBetween(this.index,s),l.dom!=d&&(this.changed=!0),this.index++,!0;if(!h&&(c=this.recreateWrapper(l,e,t,n,o,i)))return this.destroyBetween(this.index,s),this.top.children[this.index]=c,c.contentDOM&&(c.dirty=2,c.updateChildren(o,i+1),c.dirty=0),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,n,o,r,i){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!bi(n,e.outerDeco)||!o.eq(e.innerDeco))return null;let s=ai.create(this.top,t,n,o,r,i);if(s.contentDOM){s.children=e.children,e.children=[];for(let e of s.children)e.parent=s}return e.destroy(),s}addNode(e,t,n,o,r){let i=ai.create(this.top,e,t,n,o,r);i.contentDOM&&i.updateChildren(o,r+1),this.top.children.splice(this.index++,0,i),this.changed=!0}placeWidget(e,t,n){let o=this.index<this.top.children.length?this.top.children[this.index]:null;if(!o||!o.matchesWidget(e)||e!=o.widget&&o.widget.type.toDOM.parentNode){let o=new ii(this.top,e,t,n);this.top.children.splice(this.index++,0,o),this.changed=!0}else this.index++}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof li;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof di)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((Ar||Nr)&&e&&"false"==e.dom.contentEditable&&this.addHackNode("IMG",t),this.addHackNode("BR",this.top))}addHackNode(e,t){if(t==this.top&&this.index<t.children.length&&t.children[this.index].matchesHack(e))this.index++;else{let n=document.createElement(e);"IMG"==e&&(n.className="ProseMirror-separator",n.alt=""),"BR"==e&&(n.className="ProseMirror-trailingBreak");let o=new hi(this.top,[],n,null);t!=this.top?t.children.push(o):t.children.splice(this.index++,0,o),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||1==e.nodeType&&e.contains(this.lock.parentNode))}}function Si(e,t){return e.type.side-t.type.side}function Ci(e,t,n,o,r){let i=[];for(let s=0,l=0;s<e.length;s++){let a=e[s],c=l,d=l+=a.size;c>=n||d<=t?i.push(a):(c<t&&i.push(a.slice(0,t-c,o)),r&&(i.push(r),r=void 0),d>n&&i.push(a.slice(n-c,a.size,o)))}return i}function Mi(e,t=null){let n=e.domSelectionRange(),o=e.state.doc;if(!n.focusNode)return null;let r=e.docView.nearestDesc(n.focusNode),i=r&&0==r.size,s=e.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(s<0)return null;let l,a,c=o.resolve(s);if(fr(n)){for(l=s;r&&!r.node;)r=r.parent;let e=r.node;if(r&&e.isAtom&&st.isSelectable(e)&&r.parent&&(!e.isInline||!function(e,t,n){for(let o=0==t,r=t==pr(e);o||r;){if(e==n)return!0;let t=ir(e);if(!(e=e.parentNode))return!1;o=o&&0==t,r=r&&t==pr(e)}}(n.focusNode,n.focusOffset,r.dom))){let e=r.posBefore;a=new st(s==e?c:o.resolve(e))}}else{if(n instanceof e.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let t=s,r=s;for(let o=0;o<n.rangeCount;o++){let i=n.getRangeAt(o);t=Math.min(t,e.docView.posFromDOM(i.startContainer,i.startOffset,1)),r=Math.max(r,e.docView.posFromDOM(i.endContainer,i.endOffset,-1))}if(t<0)return null;[l,s]=r==e.state.selection.anchor?[r,t]:[t,r],c=o.resolve(s)}else l=e.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(l<0)return null}let d=o.resolve(l);if(!a){a=Ii(e,d,c,"pointer"==t||e.state.selection.head<c.pos&&!i?1:-1)}return a}function Ni(e){return e.editable?e.hasFocus():Bi(e)&&document.activeElement&&document.activeElement.contains(e.dom)}function Oi(e,t=!1){let n=e.state.selection;if(Ri(e,n),Ni(e)){if(!t&&e.input.mouseDown&&e.input.mouseDown.allowDefault&&Nr){let t=e.domSelectionRange(),n=e.domObserver.currentSelection;if(t.anchorNode&&n.anchorNode&&cr(t.anchorNode,t.anchorOffset,n.anchorNode,n.anchorOffset))return e.input.mouseDown.delayedSelectionSync=!0,void e.domObserver.setCurSelection()}if(e.domObserver.disconnectSelection(),e.cursorWrapper)!function(e){let t=e.domSelection(),n=document.createRange();if(!t)return;let o=e.cursorWrapper.dom,r="IMG"==o.nodeName;r?n.setStart(o.parentNode,ir(o)+1):n.setStart(o,0);n.collapse(!0),t.removeAllRanges(),t.addRange(n),!r&&!e.state.selection.visible&&xr&&Sr<=11&&(o.disabled=!0,o.disabled=!1)}(e);else{let o,r,{anchor:i,head:s}=n;!Ai||n instanceof rt||(n.$from.parent.inlineContent||(o=Ti(e,n.from)),n.empty||n.$from.parent.inlineContent||(r=Ti(e,n.to))),e.docView.setSelection(i,s,e,t),Ai&&(o&&Ei(o),r&&Ei(r)),n.visible?e.dom.classList.remove("ProseMirror-hideselection"):(e.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&function(e){let t=e.dom.ownerDocument;t.removeEventListener("selectionchange",e.input.hideSelectionGuard);let n=e.domSelectionRange(),o=n.anchorNode,r=n.anchorOffset;t.addEventListener("selectionchange",e.input.hideSelectionGuard=()=>{n.anchorNode==o&&n.anchorOffset==r||(t.removeEventListener("selectionchange",e.input.hideSelectionGuard),setTimeout((()=>{Ni(e)&&!e.state.selection.visible||e.dom.classList.remove("ProseMirror-hideselection")}),20))})}(e))}e.domObserver.setCurSelection(),e.domObserver.connectSelection()}}const Ai=Ar||Nr&&Or<63;function Ti(e,t){let{node:n,offset:o}=e.docView.domFromPos(t,0),r=o<n.childNodes.length?n.childNodes[o]:null,i=o?n.childNodes[o-1]:null;if(Ar&&r&&"false"==r.contentEditable)return Di(r);if(!(r&&"false"!=r.contentEditable||i&&"false"!=i.contentEditable)){if(r)return Di(r);if(i)return Di(i)}}function Di(e){return e.contentEditable="true",Ar&&e.draggable&&(e.draggable=!1,e.wasDraggable=!0),e}function Ei(e){e.contentEditable="false",e.wasDraggable&&(e.draggable=!0,e.wasDraggable=null)}function Ri(e,t){if(t instanceof st){let n=e.docView.descAt(t.from);n!=e.lastSelectedViewDesc&&($i(e),n&&n.selectNode(),e.lastSelectedViewDesc=n)}else $i(e)}function $i(e){e.lastSelectedViewDesc&&(e.lastSelectedViewDesc.parent&&e.lastSelectedViewDesc.deselectNode(),e.lastSelectedViewDesc=void 0)}function Ii(e,t,n,o){return e.someProp("createSelectionBetween",(o=>o(e,t,n)))||rt.between(t,n,o)}function zi(e){return!(e.editable&&!e.hasFocus())&&Bi(e)}function Bi(e){let t=e.domSelectionRange();if(!t.anchorNode)return!1;try{return e.dom.contains(3==t.anchorNode.nodeType?t.anchorNode.parentNode:t.anchorNode)&&(e.editable||e.dom.contains(3==t.focusNode.nodeType?t.focusNode.parentNode:t.focusNode))}catch(e){return!1}}function Pi(e,t){let{$anchor:n,$head:o}=e.selection,r=t>0?n.max(o):n.min(o),i=r.parent.inlineContent?r.depth?e.doc.resolve(t>0?r.after():r.before()):null:r;return i&&et.findFrom(i,t)}function Vi(e,t){return e.dispatch(e.state.tr.setSelection(t).scrollIntoView()),!0}function Fi(e,t,n){let o=e.state.selection;if(!(o instanceof rt)){if(o instanceof st&&o.node.isInline)return Vi(e,new rt(t>0?o.$to:o.$from));{let n=Pi(e.state,t);return!!n&&Vi(e,n)}}if(n.indexOf("s")>-1){let{$head:n}=o,r=n.textOffset?null:t<0?n.nodeBefore:n.nodeAfter;if(!r||r.isText||!r.isLeaf)return!1;let i=e.state.doc.resolve(n.pos+r.nodeSize*(t<0?-1:1));return Vi(e,new rt(o.$anchor,i))}if(!o.empty)return!1;if(e.endOfTextblock(t>0?"forward":"backward")){let n=Pi(e.state,t);return!!(n&&n instanceof st)&&Vi(e,n)}if(!(Dr&&n.indexOf("m")>-1)){let n,r=o.$head,i=r.textOffset?null:t<0?r.nodeBefore:r.nodeAfter;if(!i||i.isText)return!1;let s=t<0?r.pos-i.nodeSize:r.pos;return!!(i.isAtom||(n=e.docView.descAt(s))&&!n.contentDOM)&&(st.isSelectable(i)?Vi(e,new st(t<0?e.state.doc.resolve(r.pos-i.nodeSize):r)):!!$r&&Vi(e,new rt(e.state.doc.resolve(t<0?s:s+i.nodeSize))))}}function Li(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function Hi(e,t){let n=e.pmViewDesc;return n&&0==n.size&&(t<0||e.nextSibling||"BR"!=e.nodeName)}function _i(e,t){return t<0?function(e){let t=e.domSelectionRange(),n=t.focusNode,o=t.focusOffset;if(!n)return;let r,i,s=!1;Cr&&1==n.nodeType&&o<Li(n)&&Hi(n.childNodes[o],-1)&&(s=!0);for(;;)if(o>0){if(1!=n.nodeType)break;{let e=n.childNodes[o-1];if(Hi(e,-1))r=n,i=--o;else{if(3!=e.nodeType)break;n=e,o=n.nodeValue.length}}}else{if(Wi(n))break;{let t=n.previousSibling;for(;t&&Hi(t,-1);)r=n.parentNode,i=ir(t),t=t.previousSibling;if(t)n=t,o=Li(n);else{if(n=n.parentNode,n==e.dom)break;o=0}}}s?qi(e,n,o):r&&qi(e,r,i)}(e):function(e){let t=e.domSelectionRange(),n=t.focusNode,o=t.focusOffset;if(!n)return;let r,i,s=Li(n);for(;;)if(o<s){if(1!=n.nodeType)break;if(!Hi(n.childNodes[o],1))break;r=n,i=++o}else{if(Wi(n))break;{let t=n.nextSibling;for(;t&&Hi(t,1);)r=t.parentNode,i=ir(t)+1,t=t.nextSibling;if(t)n=t,o=0,s=Li(n);else{if(n=n.parentNode,n==e.dom)break;o=s=0}}}r&&qi(e,r,i)}(e)}function Wi(e){let t=e.pmViewDesc;return t&&t.node&&t.node.isBlock}function qi(e,t,n){if(3!=t.nodeType){let e,o;(o=function(e,t){for(;e&&t==e.childNodes.length&&!ur(e);)t=ir(e)+1,e=e.parentNode;for(;e&&t<e.childNodes.length;){let n=e.childNodes[t];if(3==n.nodeType)return n;if(1==n.nodeType&&"false"==n.contentEditable)break;e=n,t=0}}(t,n))?(t=o,n=0):(e=function(e,t){for(;e&&!t&&!ur(e);)t=ir(e),e=e.parentNode;for(;e&&t;){let n=e.childNodes[t-1];if(3==n.nodeType)return n;if(1==n.nodeType&&"false"==n.contentEditable)break;t=(e=n).childNodes.length}}(t,n))&&(t=e,n=e.nodeValue.length)}let o=e.domSelection();if(!o)return;if(fr(o)){let e=document.createRange();e.setEnd(t,n),e.setStart(t,n),o.removeAllRanges(),o.addRange(e)}else o.extend&&o.extend(t,n);e.domObserver.setCurSelection();let{state:r}=e;setTimeout((()=>{e.state==r&&Oi(e)}),50)}function Ji(e,t){let n=e.state.doc.resolve(t);if(!Nr&&!Er&&n.parent.inlineContent){let o=e.coordsAtPos(t);if(t>n.start()){let n=e.coordsAtPos(t-1),r=(n.top+n.bottom)/2;if(r>o.top&&r<o.bottom&&Math.abs(n.left-o.left)>1)return n.left<o.left?"ltr":"rtl"}if(t<n.end()){let n=e.coordsAtPos(t+1),r=(n.top+n.bottom)/2;if(r>o.top&&r<o.bottom&&Math.abs(n.left-o.left)>1)return n.left>o.left?"ltr":"rtl"}}return"rtl"==getComputedStyle(e.dom).direction?"rtl":"ltr"}function ji(e,t,n){let o=e.state.selection;if(o instanceof rt&&!o.empty||n.indexOf("s")>-1)return!1;if(Dr&&n.indexOf("m")>-1)return!1;let{$from:r,$to:i}=o;if(!r.parent.inlineContent||e.endOfTextblock(t<0?"up":"down")){let n=Pi(e.state,t);if(n&&n instanceof st)return Vi(e,n)}if(!r.parent.inlineContent){let n=t<0?r:i,s=o instanceof at?et.near(n,t):et.findFrom(n,t);return!!s&&Vi(e,s)}return!1}function Ki(e,t){if(!(e.state.selection instanceof rt))return!0;let{$head:n,$anchor:o,empty:r}=e.state.selection;if(!n.sameParent(o))return!0;if(!r)return!1;if(e.endOfTextblock(t>0?"forward":"backward"))return!0;let i=!n.textOffset&&(t<0?n.nodeBefore:n.nodeAfter);if(i&&!i.isText){let o=e.state.tr;return t<0?o.delete(n.pos-i.nodeSize,n.pos):o.delete(n.pos,n.pos+i.nodeSize),e.dispatch(o),!0}return!1}function Xi(e,t,n){e.domObserver.stop(),t.contentEditable=n,e.domObserver.start()}function Ui(e,t){let n=t.keyCode,o=function(e){let t="";return e.ctrlKey&&(t+="c"),e.metaKey&&(t+="m"),e.altKey&&(t+="a"),e.shiftKey&&(t+="s"),t}(t);if(8==n||Dr&&72==n&&"c"==o)return Ki(e,-1)||_i(e,-1);if(46==n&&!t.shiftKey||Dr&&68==n&&"c"==o)return Ki(e,1)||_i(e,1);if(13==n||27==n)return!0;if(37==n||Dr&&66==n&&"c"==o){let t=37==n?"ltr"==Ji(e,e.state.selection.from)?-1:1:-1;return Fi(e,t,o)||_i(e,t)}if(39==n||Dr&&70==n&&"c"==o){let t=39==n?"ltr"==Ji(e,e.state.selection.from)?1:-1:1;return Fi(e,t,o)||_i(e,t)}return 38==n||Dr&&80==n&&"c"==o?ji(e,-1,o)||_i(e,-1):40==n||Dr&&78==n&&"c"==o?function(e){if(!Ar||e.state.selection.$head.parentOffset>0)return!1;let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(t&&1==t.nodeType&&0==n&&t.firstChild&&"false"==t.firstChild.contentEditable){let n=t.firstChild;Xi(e,n,"true"),setTimeout((()=>Xi(e,n,"false")),20)}return!1}(e)||ji(e,1,o)||_i(e,1):o==(Dr?"m":"c")&&(66==n||73==n||89==n||90==n)}function Gi(e,t){e.someProp("transformCopied",(n=>{t=n(t,e)}));let n=[],{content:o,openStart:r,openEnd:i}=t;for(;r>1&&i>1&&1==o.childCount&&1==o.firstChild.childCount;){r--,i--;let e=o.firstChild;n.push(e.type.name,e.attrs!=e.type.defaultAttrs?e.attrs:null),o=e.content}let s=e.someProp("clipboardSerializer")||ie.fromSchema(e.state.schema),l=ls(),a=l.createElement("div");a.appendChild(s.serializeFragment(o,{document:l}));let c,d=a.firstChild,h=0;for(;d&&1==d.nodeType&&(c=is[d.nodeName.toLowerCase()]);){for(let e=c.length-1;e>=0;e--){let t=l.createElement(c[e]);for(;a.firstChild;)t.appendChild(a.firstChild);a.appendChild(t),h++}d=a.firstChild}return d&&1==d.nodeType&&d.setAttribute("data-pm-slice",`${r} ${i}${h?` -${h}`:""} ${JSON.stringify(n)}`),{dom:a,text:e.someProp("clipboardTextSerializer",(n=>n(t,e)))||t.content.textBetween(0,t.content.size,"\n\n"),slice:t}}function Yi(e,t,n,o,i){let s,l,a=i.parent.type.spec.code;if(!n&&!t)return null;let c=t&&(o||a||!n);if(c){if(e.someProp("transformPastedText",(n=>{t=n(t,a||o,e)})),a)return t?new d(r.from(e.state.schema.text(t.replace(/\r\n?/g,"\n"))),0,0):d.empty;let n=e.someProp("clipboardTextParser",(n=>n(t,i,o,e)));if(n)l=n;else{let n=i.marks(),{schema:o}=e.state,r=ie.fromSchema(o);s=document.createElement("div"),t.split(/(?:\r\n?|\n)+/).forEach((e=>{let t=s.appendChild(document.createElement("p"));e&&t.appendChild(r.serializeNode(o.text(e,n)))}))}}else e.someProp("transformPastedHTML",(t=>{n=t(n,e)})),s=function(e){let t=/^(\s*<meta [^>]*>)*/.exec(e);t&&(e=e.slice(t[0].length));let n,o=ls().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(e);(n=r&&is[r[1].toLowerCase()])&&(e=n.map((e=>"<"+e+">")).join("")+e+n.map((e=>"</"+e+">")).reverse().join(""));if(o.innerHTML=function(e){let t=window.trustedTypes;if(!t)return e;as||(as=t.createPolicy("ProseMirrorClipboard",{createHTML:e=>e}));return as.createHTML(e)}(e),n)for(let e=0;e<n.length;e++)o=o.querySelector(n[e])||o;return o}(n),$r&&function(e){let t=e.querySelectorAll(Nr?"span:not([class]):not([style])":"span.Apple-converted-space");for(let n=0;n<t.length;n++){let o=t[n];1==o.childNodes.length&&" "==o.textContent&&o.parentNode&&o.parentNode.replaceChild(e.ownerDocument.createTextNode(" "),o)}}(s);let h=s&&s.querySelector("[data-pm-slice]"),p=h&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(h.getAttribute("data-pm-slice")||"");if(p&&p[3])for(let e=+p[3];e>0;e--){let e=s.firstChild;for(;e&&1!=e.nodeType;)e=e.nextSibling;if(!e)break;s=e}if(!l){let t=e.someProp("clipboardParser")||e.someProp("domParser")||U.fromSchema(e.state.schema);l=t.parseSlice(s,{preserveWhitespace:!(!c&&!p),context:i,ruleFromNode:e=>"BR"!=e.nodeName||e.nextSibling||!e.parentNode||Qi.test(e.parentNode.nodeName)?null:{ignore:!0}})}if(p)l=function(e,t){if(!e.size)return e;let n,o=e.content.firstChild.type.schema;try{n=JSON.parse(t)}catch(t){return e}let{content:i,openStart:s,openEnd:l}=e;for(let e=n.length-2;e>=0;e-=2){let t=o.nodes[n[e]];if(!t||t.hasRequiredAttrs())break;i=r.from(t.create(n[e+1],i)),s++,l++}return new d(i,s,l)}(rs(l,+p[1],+p[2]),p[4]);else if(l=d.maxOpen(function(e,t){if(e.childCount<2)return e;for(let n=t.depth;n>=0;n--){let o,i=t.node(n).contentMatchAt(t.index(n)),s=[];if(e.forEach((e=>{if(!s)return;let t,n=i.findWrapping(e.type);if(!n)return s=null;if(t=s.length&&o.length&&es(n,o,e,s[s.length-1],0))s[s.length-1]=t;else{s.length&&(s[s.length-1]=ts(s[s.length-1],o.length));let t=Zi(e,n);s.push(t),i=i.matchType(t.type),o=n}})),s)return r.from(s)}return e}(l.content,i),!0),l.openStart||l.openEnd){let e=0,t=0;for(let t=l.content.firstChild;e<l.openStart&&!t.type.spec.isolating;e++,t=t.firstChild);for(let e=l.content.lastChild;t<l.openEnd&&!e.type.spec.isolating;t++,e=e.lastChild);l=rs(l,e,t)}return e.someProp("transformPasted",(t=>{l=t(l,e)})),l}const Qi=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function Zi(e,t,n=0){for(let o=t.length-1;o>=n;o--)e=t[o].create(null,r.from(e));return e}function es(e,t,n,o,i){if(i<e.length&&i<t.length&&e[i]==t[i]){let s=es(e,t,n,o.lastChild,i+1);if(s)return o.copy(o.content.replaceChild(o.childCount-1,s));if(o.contentMatchAt(o.childCount).matchType(i==e.length-1?n.type:e[i+1]))return o.copy(o.content.append(r.from(Zi(n,e,i+1))))}}function ts(e,t){if(0==t)return e;let n=e.content.replaceChild(e.childCount-1,ts(e.lastChild,t-1)),o=e.contentMatchAt(e.childCount).fillBefore(r.empty,!0);return e.copy(n.append(o))}function ns(e,t,n,o,i,s){let l=t<0?e.firstChild:e.lastChild,a=l.content;return e.childCount>1&&(s=0),i<o-1&&(a=ns(a,t,n,o,i+1,s)),i>=n&&(a=t<0?l.contentMatchAt(0).fillBefore(a,s<=i).append(a):a.append(l.contentMatchAt(l.childCount).fillBefore(r.empty,!0))),e.replaceChild(t<0?0:e.childCount-1,l.copy(a))}function rs(e,t,n){return t<e.openStart&&(e=new d(ns(e.content,-1,t,e.openStart,0,e.openEnd),t,e.openEnd)),n<e.openEnd&&(e=new d(ns(e.content,1,n,e.openEnd,0,0),e.openStart,n)),e}const is={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};let ss=null;function ls(){return ss||(ss=document.implementation.createHTMLDocument("title"))}let as=null;const cs={},ds={},hs={touchstart:!0,touchmove:!0};class ps{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:""},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function us(e,t){e.input.lastSelectionOrigin=t,e.input.lastSelectionTime=Date.now()}function fs(e){e.someProp("handleDOMEvents",(t=>{for(let n in t)e.input.eventHandlers[n]||e.dom.addEventListener(n,e.input.eventHandlers[n]=t=>ms(e,t))}))}function ms(e,t){return e.someProp("handleDOMEvents",(n=>{let o=n[t.type];return!!o&&(o(e,t)||t.defaultPrevented)}))}function gs(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let n=t.target;n!=e.dom;n=n.parentNode)if(!n||11==n.nodeType||n.pmViewDesc&&n.pmViewDesc.stopEvent(t))return!1;return!0}function ys(e){return{left:e.clientX,top:e.clientY}}function ws(e,t,n,o,r){if(-1==o)return!1;let i=e.state.doc.resolve(o);for(let o=i.depth+1;o>0;o--)if(e.someProp(t,(t=>o>i.depth?t(e,n,i.nodeAfter,i.before(o),r,!0):t(e,n,i.node(o),i.before(o),r,!1))))return!0;return!1}function vs(e,t,n){if(e.focused||e.focus(),e.state.selection.eq(t))return;let o=e.state.tr.setSelection(t);o.setMeta("pointer",!0),e.dispatch(o)}function bs(e,t,n,o,r){return ws(e,"handleClickOn",t,n,o)||e.someProp("handleClick",(n=>n(e,t,o)))||(r?function(e,t){if(-1==t)return!1;let n,o,r=e.state.selection;r instanceof st&&(n=r.node);let i=e.state.doc.resolve(t);for(let e=i.depth+1;e>0;e--){let t=e>i.depth?i.nodeAfter:i.node(e);if(st.isSelectable(t)){o=n&&r.$from.depth>0&&e>=r.$from.depth&&i.before(r.$from.depth+1)==r.$from.pos?i.before(r.$from.depth):i.before(e);break}}return null!=o&&(vs(e,st.create(e.state.doc,o)),!0)}(e,n):function(e,t){if(-1==t)return!1;let n=e.state.doc.resolve(t),o=n.nodeAfter;return!!(o&&o.isAtom&&st.isSelectable(o))&&(vs(e,new st(n)),!0)}(e,n))}function ks(e,t,n,o){return ws(e,"handleDoubleClickOn",t,n,o)||e.someProp("handleDoubleClick",(n=>n(e,t,o)))}function xs(e,t,n,o){return ws(e,"handleTripleClickOn",t,n,o)||e.someProp("handleTripleClick",(n=>n(e,t,o)))||function(e,t,n){if(0!=n.button)return!1;let o=e.state.doc;if(-1==t)return!!o.inlineContent&&(vs(e,rt.create(o,0,o.content.size)),!0);let r=o.resolve(t);for(let t=r.depth+1;t>0;t--){let n=t>r.depth?r.nodeAfter:r.node(t),i=r.before(t);if(n.inlineContent)vs(e,rt.create(o,i+1,i+1+n.content.size));else{if(!st.isSelectable(n))continue;vs(e,st.create(o,i))}return!0}}(e,n,o)}function Ss(e){return Es(e)}ds.keydown=(e,t)=>{let n=t;if(e.input.shiftKey=16==n.keyCode||n.shiftKey,!Ns(e,n)&&(e.input.lastKeyCode=n.keyCode,e.input.lastKeyCodeTime=Date.now(),!Rr||!Nr||13!=n.keyCode))if(229!=n.keyCode&&e.domObserver.forceFlush(),!Tr||13!=n.keyCode||n.ctrlKey||n.altKey||n.metaKey)e.someProp("handleKeyDown",(t=>t(e,n)))||Ui(e,n)?n.preventDefault():us(e,"key");else{let t=Date.now();e.input.lastIOSEnter=t,e.input.lastIOSEnterFallbackTimeout=setTimeout((()=>{e.input.lastIOSEnter==t&&(e.someProp("handleKeyDown",(t=>t(e,mr(13,"Enter")))),e.input.lastIOSEnter=0)}),200)}},ds.keyup=(e,t)=>{16==t.keyCode&&(e.input.shiftKey=!1)},ds.keypress=(e,t)=>{let n=t;if(Ns(e,n)||!n.charCode||n.ctrlKey&&!n.altKey||Dr&&n.metaKey)return;if(e.someProp("handleKeyPress",(t=>t(e,n))))return void n.preventDefault();let o=e.state.selection;if(!(o instanceof rt&&o.$from.sameParent(o.$to))){let t=String.fromCharCode(n.charCode);/[\r\n]/.test(t)||e.someProp("handleTextInput",(n=>n(e,o.$from.pos,o.$to.pos,t)))||e.dispatch(e.state.tr.insertText(t).scrollIntoView()),n.preventDefault()}};const Cs=Dr?"metaKey":"ctrlKey";cs.mousedown=(e,t)=>{let n=t;e.input.shiftKey=n.shiftKey;let o=Ss(e),r=Date.now(),i="singleClick";r-e.input.lastClick.time<500&&function(e,t){let n=t.x-e.clientX,o=t.y-e.clientY;return n*n+o*o<100}(n,e.input.lastClick)&&!n[Cs]&&("singleClick"==e.input.lastClick.type?i="doubleClick":"doubleClick"==e.input.lastClick.type&&(i="tripleClick")),e.input.lastClick={time:r,x:n.clientX,y:n.clientY,type:i};let s=e.posAtCoords(ys(n));s&&("singleClick"==i?(e.input.mouseDown&&e.input.mouseDown.done(),e.input.mouseDown=new Ms(e,s,n,!!o)):("doubleClick"==i?ks:xs)(e,s.pos,s.inside,n)?n.preventDefault():us(e,"pointer"))};class Ms{constructor(e,t,n,o){let r,i;if(this.view=e,this.pos=t,this.event=n,this.flushed=o,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!n[Cs],this.allowDefault=n.shiftKey,t.inside>-1)r=e.state.doc.nodeAt(t.inside),i=t.inside;else{let n=e.state.doc.resolve(t.pos);r=n.parent,i=n.depth?n.before():0}const s=o?null:n.target,l=s?e.docView.nearestDesc(s,!0):null;this.target=l&&1==l.dom.nodeType?l.dom:null;let{selection:a}=e.state;(0==n.button&&r.type.spec.draggable&&!1!==r.type.spec.selectable||a instanceof st&&a.from<=i&&a.to>i)&&(this.mightDrag={node:r,pos:i,addAttr:!(!this.target||this.target.draggable),setUneditable:!(!this.target||!Cr||this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout((()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")}),20),this.view.domObserver.start()),e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this)),us(e,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout((()=>Oi(this.view))),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(ys(e))),this.updateAllowDefault(e),this.allowDefault||!t?us(this.view,"pointer"):bs(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():0==e.button&&(this.flushed||Ar&&this.mightDrag&&!this.mightDrag.node.isAtom||Nr&&!this.view.state.selection.visible&&Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2)?(vs(this.view,et.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):us(this.view,"pointer")}move(e){this.updateAllowDefault(e),us(this.view,"pointer"),0==e.buttons&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}}function Ns(e,t){return!!e.composing||!!(Ar&&Math.abs(t.timeStamp-e.input.compositionEndedAt)<500)&&(e.input.compositionEndedAt=-2e8,!0)}cs.touchstart=e=>{e.input.lastTouch=Date.now(),Ss(e),us(e,"pointer")},cs.touchmove=e=>{e.input.lastTouch=Date.now(),us(e,"pointer")},cs.contextmenu=e=>Ss(e);const Os=Rr?5e3:-1;function As(e,t){clearTimeout(e.input.composingTimeout),t>-1&&(e.input.composingTimeout=setTimeout((()=>Es(e)),t))}function Ts(e){for(e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=function(){let e=document.createEvent("Event");return e.initEvent("event",!0,!0),e.timeStamp}());e.input.compositionNodes.length>0;)e.input.compositionNodes.pop().markParentsDirty()}function Ds(e){let t=e.domSelectionRange();if(!t.focusNode)return null;let n=function(e,t){for(;;){if(3==e.nodeType&&t)return e;if(1==e.nodeType&&t>0){if("false"==e.contentEditable)return null;t=pr(e=e.childNodes[t-1])}else{if(!e.parentNode||ur(e))return null;t=ir(e),e=e.parentNode}}}(t.focusNode,t.focusOffset),o=function(e,t){for(;;){if(3==e.nodeType&&t<e.nodeValue.length)return e;if(1==e.nodeType&&t<e.childNodes.length){if("false"==e.contentEditable)return null;e=e.childNodes[t],t=0}else{if(!e.parentNode||ur(e))return null;t=ir(e)+1,e=e.parentNode}}}(t.focusNode,t.focusOffset);if(n&&o&&n!=o){let t=o.pmViewDesc,r=e.domObserver.lastChangedTextNode;if(n==r||o==r)return r;if(!t||!t.isText(o.nodeValue))return o;if(e.input.compositionNode==o){let e=n.pmViewDesc;if(e&&e.isText(n.nodeValue))return o}}return n||o}function Es(e,t=!1){if(!(Rr&&e.domObserver.flushingSoon>=0)){if(e.domObserver.forceFlush(),Ts(e),t||e.docView&&e.docView.dirty){let n=Mi(e);return n&&!n.eq(e.state.selection)?e.dispatch(e.state.tr.setSelection(n)):!e.markCursor&&!t||e.state.selection.empty?e.updateState(e.state):e.dispatch(e.state.tr.deleteSelection()),!0}return!1}}ds.compositionstart=ds.compositionupdate=e=>{if(!e.composing){e.domObserver.flush();let{state:t}=e,n=t.selection.$to;if(t.selection instanceof rt&&(t.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some((e=>!1===e.type.spec.inclusive))))e.markCursor=e.state.storedMarks||n.marks(),Es(e,!0),e.markCursor=null;else if(Es(e,!t.selection.empty),Cr&&t.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let t=e.domSelectionRange();for(let n=t.focusNode,o=t.focusOffset;n&&1==n.nodeType&&0!=o;){let t=o<0?n.lastChild:n.childNodes[o-1];if(!t)break;if(3==t.nodeType){let n=e.domSelection();n&&n.collapse(t,t.nodeValue.length);break}n=t,o=-1}}e.input.composing=!0}As(e,Os)},ds.compositionend=(e,t)=>{e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=t.timeStamp,e.input.compositionPendingChanges=e.domObserver.pendingRecords().length?e.input.compositionID:0,e.input.compositionNode=null,e.input.compositionPendingChanges&&Promise.resolve().then((()=>e.domObserver.flush())),e.input.compositionID++,As(e,20))};const Rs=xr&&Sr<15||Tr&&Ir<604;function $s(e,t,n,o,r){let i=Yi(e,t,n,o,e.state.selection.$from);if(e.someProp("handlePaste",(t=>t(e,r,i||d.empty))))return!0;if(!i)return!1;let s=function(e){return 0==e.openStart&&0==e.openEnd&&1==e.content.childCount?e.content.firstChild:null}(i),l=s?e.state.tr.replaceSelectionWith(s,o):e.state.tr.replaceSelection(i);return e.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Is(e){let t=e.getData("text/plain")||e.getData("Text");if(t)return t;let n=e.getData("text/uri-list");return n?n.replace(/\r?\n/g," "):""}cs.copy=ds.cut=(e,t)=>{let n=t,o=e.state.selection,r="cut"==n.type;if(o.empty)return;let i=Rs?null:n.clipboardData,s=o.content(),{dom:l,text:a}=Gi(e,s);i?(n.preventDefault(),i.clearData(),i.setData("text/html",l.innerHTML),i.setData("text/plain",a)):function(e,t){if(!e.dom.parentNode)return;let n=e.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(t),n.style.cssText="position: fixed; left: -10000px; top: 10px";let o=getSelection(),r=document.createRange();r.selectNodeContents(t),e.dom.blur(),o.removeAllRanges(),o.addRange(r),setTimeout((()=>{n.parentNode&&n.parentNode.removeChild(n),e.focus()}),50)}(e,l),r&&e.dispatch(e.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))},ds.paste=(e,t)=>{let n=t;if(e.composing&&!Rr)return;let o=Rs?null:n.clipboardData,r=e.input.shiftKey&&45!=e.input.lastKeyCode;o&&$s(e,Is(o),o.getData("text/html"),r,n)?n.preventDefault():function(e,t){if(!e.dom.parentNode)return;let n=e.input.shiftKey||e.state.selection.$from.parent.type.spec.code,o=e.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(o.contentEditable="true"),o.style.cssText="position: fixed; left: -10000px; top: 10px",o.focus();let r=e.input.shiftKey&&45!=e.input.lastKeyCode;setTimeout((()=>{e.focus(),o.parentNode&&o.parentNode.removeChild(o),n?$s(e,o.value,null,r,t):$s(e,o.textContent,o.innerHTML,r,t)}),50)}(e,n)};class zs{constructor(e,t,n){this.slice=e,this.move=t,this.node=n}}const Bs=Dr?"altKey":"ctrlKey";cs.dragstart=(e,t)=>{let n=t,o=e.input.mouseDown;if(o&&o.done(),!n.dataTransfer)return;let r,i=e.state.selection,s=i.empty?null:e.posAtCoords(ys(n));if(s&&s.pos>=i.from&&s.pos<=(i instanceof st?i.to-1:i.to));else if(o&&o.mightDrag)r=st.create(e.state.doc,o.mightDrag.pos);else if(n.target&&1==n.target.nodeType){let t=e.docView.nearestDesc(n.target,!0);t&&t.node.type.spec.draggable&&t!=e.docView&&(r=st.create(e.state.doc,t.posBefore))}let l=(r||e.state.selection).content(),{dom:a,text:c,slice:d}=Gi(e,l);(!n.dataTransfer.files.length||!Nr||Or>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(Rs?"Text":"text/html",a.innerHTML),n.dataTransfer.effectAllowed="copyMove",Rs||n.dataTransfer.setData("text/plain",c),e.dragging=new zs(d,!n[Bs],r)},cs.dragend=e=>{let t=e.dragging;window.setTimeout((()=>{e.dragging==t&&(e.dragging=null)}),50)},ds.dragover=ds.dragenter=(e,t)=>t.preventDefault(),ds.drop=(e,t)=>{let n=t,o=e.dragging;if(e.dragging=null,!n.dataTransfer)return;let r=e.posAtCoords(ys(n));if(!r)return;let i=e.state.doc.resolve(r.pos),s=o&&o.slice;s?e.someProp("transformPasted",(t=>{s=t(s,e)})):s=Yi(e,Is(n.dataTransfer),Rs?null:n.dataTransfer.getData("text/html"),!1,i);let l=!(!o||n[Bs]);if(e.someProp("handleDrop",(t=>t(e,n,s||d.empty,l))))return void n.preventDefault();if(!s)return;n.preventDefault();let a=s?Fe(e.state.doc,i.pos,s):i.pos;null==a&&(a=i.pos);let c=e.state.tr;if(l){let{node:e}=o;e?e.replace(c):c.deleteSelection()}let h=c.mapping.map(a),p=0==s.openStart&&0==s.openEnd&&1==s.content.childCount,u=c.doc;if(p?c.replaceRangeWith(h,h,s.content.firstChild):c.replaceRange(h,h,s),c.doc.eq(u))return;let f=c.doc.resolve(h);if(p&&st.isSelectable(s.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(s.content.firstChild))c.setSelection(new st(f));else{let t=c.mapping.map(a);c.mapping.maps[c.mapping.maps.length-1].forEach(((e,n,o,r)=>t=r)),c.setSelection(Ii(e,f,c.doc.resolve(t)))}e.focus(),e.dispatch(c.setMeta("uiEvent","drop"))},cs.focus=e=>{e.input.lastFocus=Date.now(),e.focused||(e.domObserver.stop(),e.dom.classList.add("ProseMirror-focused"),e.domObserver.start(),e.focused=!0,setTimeout((()=>{e.docView&&e.hasFocus()&&!e.domObserver.currentSelection.eq(e.domSelectionRange())&&Oi(e)}),20))},cs.blur=(e,t)=>{let n=t;e.focused&&(e.domObserver.stop(),e.dom.classList.remove("ProseMirror-focused"),e.domObserver.start(),n.relatedTarget&&e.dom.contains(n.relatedTarget)&&e.domObserver.currentSelection.clear(),e.focused=!1)},cs.beforeinput=(e,t)=>{if(Nr&&Rr&&"deleteContentBackward"==t.inputType){e.domObserver.flushSoon();let{domChangeCount:t}=e.input;setTimeout((()=>{if(e.input.domChangeCount!=t)return;if(e.dom.blur(),e.focus(),e.someProp("handleKeyDown",(t=>t(e,mr(8,"Backspace")))))return;let{$cursor:n}=e.state.selection;n&&n.pos>0&&e.dispatch(e.state.tr.delete(n.pos-1,n.pos).scrollIntoView())}),50)}};for(let e in ds)cs[e]=ds[e];function Ps(e,t){if(e==t)return!0;for(let n in e)if(e[n]!==t[n])return!1;for(let n in t)if(!(n in e))return!1;return!0}class Vs{constructor(e,t){this.toDOM=e,this.spec=t||Ws,this.side=this.spec.side||0}map(e,t,n,o){let{pos:r,deleted:i}=e.mapResult(t.from+o,this.side<0?-1:1);return i?null:new Hs(r-n,r-n,this)}valid(){return!0}eq(e){return this==e||e instanceof Vs&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Ps(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Fs{constructor(e,t){this.attrs=e,this.spec=t||Ws}map(e,t,n,o){let r=e.map(t.from+o,this.spec.inclusiveStart?-1:1)-n,i=e.map(t.to+o,this.spec.inclusiveEnd?1:-1)-n;return r>=i?null:new Hs(r,i,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof Fs&&Ps(this.attrs,e.attrs)&&Ps(this.spec,e.spec)}static is(e){return e.type instanceof Fs}destroy(){}}class Ls{constructor(e,t){this.attrs=e,this.spec=t||Ws}map(e,t,n,o){let r=e.mapResult(t.from+o,1);if(r.deleted)return null;let i=e.mapResult(t.to+o,-1);return i.deleted||i.pos<=r.pos?null:new Hs(r.pos-n,i.pos-n,this)}valid(e,t){let n,{index:o,offset:r}=e.content.findIndex(t.from);return r==t.from&&!(n=e.child(o)).isText&&r+n.nodeSize==t.to}eq(e){return this==e||e instanceof Ls&&Ps(this.attrs,e.attrs)&&Ps(this.spec,e.spec)}destroy(){}}class Hs{constructor(e,t,n){this.from=e,this.to=t,this.type=n}copy(e,t){return new Hs(e,t,this.type)}eq(e,t=0){return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}map(e,t,n){return this.type.map(e,this,t,n)}static widget(e,t,n){return new Hs(e,e,new Vs(t,n))}static inline(e,t,n,o){return new Hs(e,t,new Fs(n,o))}static node(e,t,n,o){return new Hs(e,t,new Ls(n,o))}get spec(){return this.type.spec}get inline(){return this.type instanceof Fs}get widget(){return this.type instanceof Vs}}const _s=[],Ws={};class qs{constructor(e,t){this.local=e.length?e:_s,this.children=t.length?t:_s}static create(e,t){return t.length?Gs(t,e,0,Ws):Js}find(e,t,n){let o=[];return this.findInner(null==e?0:e,null==t?1e9:t,o,0,n),o}findInner(e,t,n,o,r){for(let i=0;i<this.local.length;i++){let s=this.local[i];s.from<=t&&s.to>=e&&(!r||r(s.spec))&&n.push(s.copy(s.from+o,s.to+o))}for(let i=0;i<this.children.length;i+=3)if(this.children[i]<t&&this.children[i+1]>e){let s=this.children[i]+1;this.children[i+2].findInner(e-s,t-s,n,o+s,r)}}map(e,t,n){return this==Js||0==e.maps.length?this:this.mapInner(e,t,0,0,n||Ws)}mapInner(e,t,n,o,r){let i;for(let s=0;s<this.local.length;s++){let l=this.local[s].map(e,n,o);l&&l.type.valid(t,l)?(i||(i=[])).push(l):r.onRemove&&r.onRemove(this.local[s].spec)}return this.children.length?function(e,t,n,o,r,i,s){let l=e.slice();for(let e=0,t=i;e<n.maps.length;e++){let o=0;n.maps[e].forEach(((e,n,r,i)=>{let s=i-r-(n-e);for(let r=0;r<l.length;r+=3){let i=l[r+1];if(i<0||e>i+t-o)continue;let a=l[r]+t-o;n>=a?l[r+1]=e<=a?-2:-1:e>=t&&s&&(l[r]+=s,l[r+1]+=s)}o+=s})),t=n.maps[e].map(t,-1)}let a=!1;for(let t=0;t<l.length;t+=3)if(l[t+1]<0){if(-2==l[t+1]){a=!0,l[t+1]=-1;continue}let c=n.map(e[t]+i),d=c-r;if(d<0||d>=o.content.size){a=!0;continue}let h=n.map(e[t+1]+i,-1)-r,{index:p,offset:u}=o.content.findIndex(d),f=o.maybeChild(p);if(f&&u==d&&u+f.nodeSize==h){let o=l[t+2].mapInner(n,f,c+1,e[t]+i+1,s);o!=Js?(l[t]=d,l[t+1]=h,l[t+2]=o):(l[t+1]=-2,a=!0)}else a=!0}if(a){let a=function(e,t,n,o,r,i,s){function l(e,t){for(let i=0;i<e.local.length;i++){let l=e.local[i].map(o,r,t);l?n.push(l):s.onRemove&&s.onRemove(e.local[i].spec)}for(let n=0;n<e.children.length;n+=3)l(e.children[n+2],e.children[n]+t+1)}for(let n=0;n<e.length;n+=3)-1==e[n+1]&&l(e[n+2],t[n]+i+1);return n}(l,e,t,n,r,i,s),c=Gs(a,o,0,s);t=c.local;for(let e=0;e<l.length;e+=3)l[e+1]<0&&(l.splice(e,3),e-=3);for(let e=0,t=0;e<c.children.length;e+=3){let n=c.children[e];for(;t<l.length&&l[t]<n;)t+=3;l.splice(t,0,c.children[e],c.children[e+1],c.children[e+2])}}return new qs(t.sort(Ys),l)}(this.children,i||[],e,t,n,o,r):i?new qs(i.sort(Ys),_s):Js}add(e,t){return t.length?this==Js?qs.create(e,t):this.addInner(e,t,0):this}addInner(e,t,n){let o,r=0;e.forEach(((e,i)=>{let s,l=i+n;if(s=Xs(t,e,l)){for(o||(o=this.children.slice());r<o.length&&o[r]<i;)r+=3;o[r]==i?o[r+2]=o[r+2].addInner(e,s,l+1):o.splice(r,0,i,i+e.nodeSize,Gs(s,e,l+1,Ws)),r+=3}}));let i=Ks(r?Us(t):t,-n);for(let t=0;t<i.length;t++)i[t].type.valid(e,i[t])||i.splice(t--,1);return new qs(i.length?this.local.concat(i).sort(Ys):this.local,o||this.children)}remove(e){return 0==e.length||this==Js?this:this.removeInner(e,0)}removeInner(e,t){let n=this.children,o=this.local;for(let o=0;o<n.length;o+=3){let r,i=n[o]+t,s=n[o+1]+t;for(let t,n=0;n<e.length;n++)(t=e[n])&&t.from>i&&t.to<s&&(e[n]=null,(r||(r=[])).push(t));if(!r)continue;n==this.children&&(n=this.children.slice());let l=n[o+2].removeInner(r,i+1);l!=Js?n[o+2]=l:(n.splice(o,3),o-=3)}if(o.length)for(let n,r=0;r<e.length;r++)if(n=e[r])for(let e=0;e<o.length;e++)o[e].eq(n,t)&&(o==this.local&&(o=this.local.slice()),o.splice(e--,1));return n==this.children&&o==this.local?this:o.length||n.length?new qs(o,n):Js}forChild(e,t){if(this==Js)return this;if(t.isLeaf)return qs.empty;let n,o;for(let t=0;t<this.children.length;t+=3)if(this.children[t]>=e){this.children[t]==e&&(n=this.children[t+2]);break}let r=e+1,i=r+t.content.size;for(let e=0;e<this.local.length;e++){let t=this.local[e];if(t.from<i&&t.to>r&&t.type instanceof Fs){let e=Math.max(r,t.from)-r,n=Math.min(i,t.to)-r;e<n&&(o||(o=[])).push(t.copy(e,n))}}if(o){let e=new qs(o.sort(Ys),_s);return n?new js([e,n]):e}return n||Js}eq(e){if(this==e)return!0;if(!(e instanceof qs)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let t=0;t<this.local.length;t++)if(!this.local[t].eq(e.local[t]))return!1;for(let t=0;t<this.children.length;t+=3)if(this.children[t]!=e.children[t]||this.children[t+1]!=e.children[t+1]||!this.children[t+2].eq(e.children[t+2]))return!1;return!0}locals(e){return Qs(this.localsInner(e))}localsInner(e){if(this==Js)return _s;if(e.inlineContent||!this.local.some(Fs.is))return this.local;let t=[];for(let e=0;e<this.local.length;e++)this.local[e].type instanceof Fs||t.push(this.local[e]);return t}forEachSet(e){e(this)}}qs.empty=new qs([],[]),qs.removeOverlap=Qs;const Js=qs.empty;class js{constructor(e){this.members=e}map(e,t){const n=this.members.map((n=>n.map(e,t,Ws)));return js.from(n)}forChild(e,t){if(t.isLeaf)return qs.empty;let n=[];for(let o=0;o<this.members.length;o++){let r=this.members[o].forChild(e,t);r!=Js&&(r instanceof js?n=n.concat(r.members):n.push(r))}return js.from(n)}eq(e){if(!(e instanceof js)||e.members.length!=this.members.length)return!1;for(let t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0}locals(e){let t,n=!0;for(let o=0;o<this.members.length;o++){let r=this.members[o].localsInner(e);if(r.length)if(t){n&&(t=t.slice(),n=!1);for(let e=0;e<r.length;e++)t.push(r[e])}else t=r}return t?Qs(n?t:t.sort(Ys)):_s}static from(e){switch(e.length){case 0:return Js;case 1:return e[0];default:return new js(e.every((e=>e instanceof qs))?e:e.reduce(((e,t)=>e.concat(t instanceof qs?t:t.members)),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}}function Ks(e,t){if(!t||!e.length)return e;let n=[];for(let o=0;o<e.length;o++){let r=e[o];n.push(new Hs(r.from+t,r.to+t,r.type))}return n}function Xs(e,t,n){if(t.isLeaf)return null;let o=n+t.nodeSize,r=null;for(let t,i=0;i<e.length;i++)(t=e[i])&&t.from>n&&t.to<o&&((r||(r=[])).push(t),e[i]=null);return r}function Us(e){let t=[];for(let n=0;n<e.length;n++)null!=e[n]&&t.push(e[n]);return t}function Gs(e,t,n,o){let r=[],i=!1;t.forEach(((t,s)=>{let l=Xs(e,t,s+n);if(l){i=!0;let e=Gs(l,t,n+s+1,o);e!=Js&&r.push(s,s+t.nodeSize,e)}}));let s=Ks(i?Us(e):e,-n).sort(Ys);for(let e=0;e<s.length;e++)s[e].type.valid(t,s[e])||(o.onRemove&&o.onRemove(s[e].spec),s.splice(e--,1));return s.length||r.length?new qs(s,r):Js}function Ys(e,t){return e.from-t.from||e.to-t.to}function Qs(e){let t=e;for(let n=0;n<t.length-1;n++){let o=t[n];if(o.from!=o.to)for(let r=n+1;r<t.length;r++){let i=t[r];if(i.from!=o.from){i.from<o.to&&(t==e&&(t=e.slice()),t[n]=o.copy(o.from,i.from),Zs(t,r,o.copy(i.from,o.to)));break}i.to!=o.to&&(t==e&&(t=e.slice()),t[r]=i.copy(i.from,o.to),Zs(t,r+1,i.copy(o.to,i.to)))}}return t}function Zs(e,t,n){for(;t<e.length&&Ys(n,e[t])>0;)t++;e.splice(t,0,n)}function el(e){let t=[];return e.someProp("decorations",(n=>{let o=n(e.state);o&&o!=Js&&t.push(o)})),e.cursorWrapper&&t.push(qs.create(e.state.doc,[e.cursorWrapper.deco])),js.from(t)}const tl={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},nl=xr&&Sr<=11;class ol{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}}class rl{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new ol,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver((e=>{for(let t=0;t<e.length;t++)this.queue.push(e[t]);xr&&Sr<=11&&e.some((e=>"childList"==e.type&&e.removedNodes.length||"characterData"==e.type&&e.oldValue.length>e.target.nodeValue.length))?this.flushSoon():this.flush()})),nl&&(this.onCharData=e=>{this.queue.push({target:e.target,type:"characterData",oldValue:e.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout((()=>{this.flushingSoon=-1,this.flush()}),20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,tl)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let t=0;t<e.length;t++)this.queue.push(e[t]);window.setTimeout((()=>this.flush()),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout((()=>this.suppressingSelectionUpdates=!1),50)}onSelectionChange(){if(zi(this.view)){if(this.suppressingSelectionUpdates)return Oi(this.view);if(xr&&Sr<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&cr(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t,n=new Set;for(let t=e.focusNode;t;t=sr(t))n.add(t);for(let o=e.anchorNode;o;o=sr(o))if(n.has(o)){t=o;break}let o=t&&this.view.docView.nearestDesc(t);return o&&o.ignoreMutation({type:"selection",target:3==t.nodeType?t.parentNode:t})?(this.setCurSelection(),!0):void 0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let n=e.domSelectionRange(),o=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(n)&&zi(e)&&!this.ignoreSelectionChange(n),r=-1,i=-1,s=!1,l=[];if(e.editable)for(let e=0;e<t.length;e++){let n=this.registerMutation(t[e],l);n&&(r=r<0?n.from:Math.min(n.from,r),i=i<0?n.to:Math.max(n.to,i),n.typeOver&&(s=!0))}if(Cr&&l.length){let t=l.filter((e=>"BR"==e.nodeName));if(2==t.length){let[e,n]=t;e.parentNode&&e.parentNode.parentNode==n.parentNode?n.remove():e.remove()}else{let{focusNode:n}=this.currentSelection;for(let o of t){let t=o.parentNode;!t||"LI"!=t.nodeName||n&&al(e,n)==t||o.remove()}}}let a=null;r<0&&o&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&fr(n)&&(a=Mi(e))&&a.eq(et.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,Oi(e),this.currentSelection.set(n),e.scrollToSelection()):(r>-1||o)&&(r>-1&&(e.docView.markDirty(r,i),function(e){if(il.has(e))return;if(il.set(e,null),-1!==["normal","nowrap","pre-line"].indexOf(getComputedStyle(e.dom).whiteSpace)){if(e.requiresGeckoHackNode=Cr,sl)return;console.warn("ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package."),sl=!0}}(e)),this.handleDOMChange(r,i,s,l),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(n)||Oi(e),this.currentSelection.set(n))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let n=this.view.docView.nearestDesc(e.target);if("attributes"==e.type&&(n==this.view.docView||"contenteditable"==e.attributeName||"style"==e.attributeName&&!e.oldValue&&!e.target.getAttribute("style")))return null;if(!n||n.ignoreMutation(e))return null;if("childList"==e.type){for(let n=0;n<e.addedNodes.length;n++){let o=e.addedNodes[n];t.push(o),3==o.nodeType&&(this.lastChangedTextNode=o)}if(n.contentDOM&&n.contentDOM!=n.dom&&!n.contentDOM.contains(e.target))return{from:n.posBefore,to:n.posAfter};let o=e.previousSibling,r=e.nextSibling;if(xr&&Sr<=11&&e.addedNodes.length)for(let t=0;t<e.addedNodes.length;t++){let{previousSibling:n,nextSibling:i}=e.addedNodes[t];(!n||Array.prototype.indexOf.call(e.addedNodes,n)<0)&&(o=n),(!i||Array.prototype.indexOf.call(e.addedNodes,i)<0)&&(r=i)}let i=o&&o.parentNode==e.target?ir(o)+1:0,s=n.localPosFromDOM(e.target,i,-1),l=r&&r.parentNode==e.target?ir(r):e.target.childNodes.length;return{from:s,to:n.localPosFromDOM(e.target,l,1)}}return"attributes"==e.type?{from:n.posAtStart-n.border,to:n.posAtEnd+n.border}:(this.lastChangedTextNode=e.target,{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let il=new WeakMap,sl=!1;function ll(e,t){let n=t.startContainer,o=t.startOffset,r=t.endContainer,i=t.endOffset,s=e.domAtPos(e.state.selection.anchor);return cr(s.node,s.offset,r,i)&&([n,o,r,i]=[r,i,n,o]),{anchorNode:n,anchorOffset:o,focusNode:r,focusOffset:i}}function al(e,t){for(let n=t.parentNode;n&&n!=e.dom;n=n.parentNode){let t=e.docView.nearestDesc(n,!0);if(t&&t.node.isBlock)return n}return null}function cl(e){let t=e.pmViewDesc;if(t)return t.parseRule();if("BR"==e.nodeName&&e.parentNode){if(Ar&&/^(ul|ol)$/i.test(e.parentNode.nodeName)){let e=document.createElement("div");return e.appendChild(document.createElement("li")),{skip:e}}if(e.parentNode.lastChild==e||Ar&&/^(tr|table)$/i.test(e.parentNode.nodeName))return{ignore:!0}}else if("IMG"==e.nodeName&&e.getAttribute("mark-placeholder"))return{ignore:!0};return null}const dl=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function hl(e,t,n,o,i){let s=e.input.compositionPendingChanges||(e.composing?e.input.compositionID:0);if(e.input.compositionPendingChanges=0,t<0){let t=e.input.lastSelectionTime>Date.now()-50?e.input.lastSelectionOrigin:null,n=Mi(e,t);if(n&&!e.state.selection.eq(n)){if(Nr&&Rr&&13===e.input.lastKeyCode&&Date.now()-100<e.input.lastKeyCodeTime&&e.someProp("handleKeyDown",(t=>t(e,mr(13,"Enter")))))return;let o=e.state.tr.setSelection(n);"pointer"==t?o.setMeta("pointer",!0):"key"==t&&o.scrollIntoView(),s&&o.setMeta("composition",s),e.dispatch(o)}return}let l=e.state.doc.resolve(t),a=l.sharedDepth(n);t=l.before(a+1),n=e.state.doc.resolve(n).after(a+1);let c,d,h=e.state.selection,p=function(e,t,n){let o,{node:r,fromOffset:i,toOffset:s,from:l,to:a}=e.docView.parseRange(t,n),c=e.domSelectionRange(),d=c.anchorNode;if(d&&e.dom.contains(1==d.nodeType?d:d.parentNode)&&(o=[{node:d,offset:c.anchorOffset}],fr(c)||o.push({node:c.focusNode,offset:c.focusOffset})),Nr&&8===e.input.lastKeyCode)for(let e=s;e>i;e--){let t=r.childNodes[e-1],n=t.pmViewDesc;if("BR"==t.nodeName&&!n){s=e;break}if(!n||n.size)break}let h=e.state.doc,p=e.someProp("domParser")||U.fromSchema(e.state.schema),u=h.resolve(l),f=null,m=p.parse(r,{topNode:u.parent,topMatch:u.parent.contentMatchAt(u.index()),topOpen:!0,from:i,to:s,preserveWhitespace:"pre"!=u.parent.type.whitespace||"full",findPositions:o,ruleFromNode:cl,context:u});if(o&&null!=o[0].pos){let e=o[0].pos,t=o[1]&&o[1].pos;null==t&&(t=e),f={anchor:e+l,head:t+l}}return{doc:m,sel:f,from:l,to:a}}(e,t,n),u=e.state.doc,f=u.slice(p.from,p.to);8===e.input.lastKeyCode&&Date.now()-100<e.input.lastKeyCodeTime?(c=e.state.selection.to,d="end"):(c=e.state.selection.from,d="start"),e.input.lastKeyCode=null;let m=function(e,t,n,o,r){let i=e.findDiffStart(t,n);if(null==i)return null;let{a:s,b:l}=e.findDiffEnd(t,n+e.size,n+t.size);if("end"==r){o-=s+Math.max(0,i-Math.min(s,l))-i}if(s<i&&e.size<t.size){let e=o<=i&&o>=s?i-o:0;i-=e,i&&i<t.size&&fl(t.textBetween(i-1,i+1))&&(i+=e?1:-1),l=i+(l-s),s=i}else if(l<i){let t=o<=i&&o>=l?i-o:0;i-=t,i&&i<e.size&&fl(e.textBetween(i-1,i+1))&&(i+=t?1:-1),s=i+(s-l),l=i}return{start:i,endA:s,endB:l}}(f.content,p.doc.content,p.from,c,d);if(m&&e.input.domChangeCount++,(Tr&&e.input.lastIOSEnter>Date.now()-225||Rr)&&i.some((e=>1==e.nodeType&&!dl.test(e.nodeName)))&&(!m||m.endA>=m.endB)&&e.someProp("handleKeyDown",(t=>t(e,mr(13,"Enter")))))return void(e.input.lastIOSEnter=0);if(!m){if(!(o&&h instanceof rt&&!h.empty&&h.$head.sameParent(h.$anchor))||e.composing||p.sel&&p.sel.anchor!=p.sel.head){if(p.sel){let t=pl(e,e.state.doc,p.sel);if(t&&!t.eq(e.state.selection)){let n=e.state.tr.setSelection(t);s&&n.setMeta("composition",s),e.dispatch(n)}}return}m={start:h.from,endA:h.to,endB:h.to}}e.state.selection.from<e.state.selection.to&&m.start==m.endB&&e.state.selection instanceof rt&&(m.start>e.state.selection.from&&m.start<=e.state.selection.from+2&&e.state.selection.from>=p.from?m.start=e.state.selection.from:m.endA<e.state.selection.to&&m.endA>=e.state.selection.to-2&&e.state.selection.to<=p.to&&(m.endB+=e.state.selection.to-m.endA,m.endA=e.state.selection.to)),xr&&Sr<=11&&m.endB==m.start+1&&m.endA==m.start&&m.start>p.from&&"  "==p.doc.textBetween(m.start-p.from-1,m.start-p.from+1)&&(m.start--,m.endA--,m.endB--);let g,y=p.doc.resolveNoCache(m.start-p.from),w=p.doc.resolveNoCache(m.endB-p.from),v=u.resolve(m.start),b=y.sameParent(w)&&y.parent.inlineContent&&v.end()>=m.endA;if((Tr&&e.input.lastIOSEnter>Date.now()-225&&(!b||i.some((e=>"DIV"==e.nodeName||"P"==e.nodeName)))||!b&&y.pos<p.doc.content.size&&!y.sameParent(w)&&(g=et.findFrom(p.doc.resolve(y.pos+1),1,!0))&&g.head==w.pos)&&e.someProp("handleKeyDown",(t=>t(e,mr(13,"Enter")))))return void(e.input.lastIOSEnter=0);if(e.state.selection.anchor>m.start&&function(e,t,n,o,r){if(n-t<=r.pos-o.pos||ul(o,!0,!1)<r.pos)return!1;let i=e.resolve(t);if(!o.parent.isTextblock){let e=i.nodeAfter;return null!=e&&n==t+e.nodeSize}if(i.parentOffset<i.parent.content.size||!i.parent.isTextblock)return!1;let s=e.resolve(ul(i,!0,!0));return!(!s.parent.isTextblock||s.pos>n||ul(s,!0,!1)<n)&&o.parent.content.cut(o.parentOffset).eq(s.parent.content)}(u,m.start,m.endA,y,w)&&e.someProp("handleKeyDown",(t=>t(e,mr(8,"Backspace")))))return void(Rr&&Nr&&e.domObserver.suppressSelectionUpdates());Nr&&m.endB==m.start&&(e.input.lastChromeDelete=Date.now()),Rr&&!b&&y.start()!=w.start()&&0==w.parentOffset&&y.depth==w.depth&&p.sel&&p.sel.anchor==p.sel.head&&p.sel.head==m.endA&&(m.endB-=2,w=p.doc.resolveNoCache(m.endB-p.from),setTimeout((()=>{e.someProp("handleKeyDown",(function(t){return t(e,mr(13,"Enter"))}))}),20));let k,x,S,C=m.start,M=m.endA;if(b)if(y.pos==w.pos)xr&&Sr<=11&&0==y.parentOffset&&(e.domObserver.suppressSelectionUpdates(),setTimeout((()=>Oi(e)),20)),k=e.state.tr.delete(C,M),x=u.resolve(m.start).marksAcross(u.resolve(m.endA));else if(m.endA==m.endB&&(S=function(e,t){let n,o,i,s=e.firstChild.marks,l=t.firstChild.marks,a=s,c=l;for(let e=0;e<l.length;e++)a=l[e].removeFromSet(a);for(let e=0;e<s.length;e++)c=s[e].removeFromSet(c);if(1==a.length&&0==c.length)o=a[0],n="add",i=e=>e.mark(o.addToSet(e.marks));else{if(0!=a.length||1!=c.length)return null;o=c[0],n="remove",i=e=>e.mark(o.removeFromSet(e.marks))}let d=[];for(let e=0;e<t.childCount;e++)d.push(i(t.child(e)));if(r.from(d).eq(e))return{mark:o,type:n}}(y.parent.content.cut(y.parentOffset,w.parentOffset),v.parent.content.cut(v.parentOffset,m.endA-v.start()))))k=e.state.tr,"add"==S.type?k.addMark(C,M,S.mark):k.removeMark(C,M,S.mark);else if(y.parent.child(y.index()).isText&&y.index()==w.index()-(w.textOffset?0:1)){let t=y.parent.textBetween(y.parentOffset,w.parentOffset);if(e.someProp("handleTextInput",(n=>n(e,C,M,t))))return;k=e.state.tr.insertText(t,C,M)}if(k||(k=e.state.tr.replace(C,M,p.doc.slice(m.start-p.from,m.endB-p.from))),p.sel){let t=pl(e,k.doc,p.sel);t&&!(Nr&&e.composing&&t.empty&&(m.start!=m.endB||e.input.lastChromeDelete<Date.now()-100)&&(t.head==C||t.head==k.mapping.map(M)-1)||xr&&t.empty&&t.head==C)&&k.setSelection(t)}x&&k.ensureMarks(x),s&&k.setMeta("composition",s),e.dispatch(k.scrollIntoView())}function pl(e,t,n){return Math.max(n.anchor,n.head)>t.content.size?null:Ii(e,t.resolve(n.anchor),t.resolve(n.head))}function ul(e,t,n){let o=e.depth,r=t?e.end():e.pos;for(;o>0&&(t||e.indexAfter(o)==e.node(o).childCount);)o--,r++,t=!1;if(n){let t=e.node(o).maybeChild(e.indexAfter(o));for(;t&&!t.isLeaf;)t=t.firstChild,r++}return r}function fl(e){if(2!=e.length)return!1;let t=e.charCodeAt(0),n=e.charCodeAt(1);return t>=56320&&t<=57343&&n>=55296&&n<=56319}const ml=Gi,gl=Yi,yl=Es;function wl(e){let t=Object.create(null);return t.class="ProseMirror",t.contenteditable=String(e.editable),e.someProp("attributes",(n=>{if("function"==typeof n&&(n=n(e.state)),n)for(let e in n)"class"==e?t.class+=" "+n[e]:"style"==e?t.style=(t.style?t.style+";":"")+n[e]:t[e]||"contenteditable"==e||"nodeName"==e||(t[e]=String(n[e]))})),t.translate||(t.translate="no"),[Hs.node(0,e.state.doc.content.size,t)]}function vl(e){if(e.markCursor){let t=document.createElement("img");t.className="ProseMirror-separator",t.setAttribute("mark-placeholder","true"),t.setAttribute("alt",""),e.cursorWrapper={dom:t,deco:Hs.widget(e.state.selection.from,t,{raw:!0,marks:e.markCursor})}}else e.cursorWrapper=null}function bl(e){return!e.someProp("editable",(t=>!1===t(e.state)))}function kl(e){let t=Object.create(null);function n(e){for(let n in e)Object.prototype.hasOwnProperty.call(t,n)||(t[n]=e[n])}return e.someProp("nodeViews",n),e.someProp("markViews",n),t}function xl(e){if(e.spec.state||e.spec.filterTransaction||e.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}for(var Sl={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:"'"},Cl={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Ml="undefined"!=typeof navigator&&/Mac/.test(navigator.platform),Nl="undefined"!=typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),Ol=0;Ol<10;Ol++)Sl[48+Ol]=Sl[96+Ol]=String(Ol);for(Ol=1;Ol<=24;Ol++)Sl[Ol+111]="F"+Ol;for(Ol=65;Ol<=90;Ol++)Sl[Ol]=String.fromCharCode(Ol+32),Cl[Ol]=String.fromCharCode(Ol);for(var Al in Sl)Cl.hasOwnProperty(Al)||(Cl[Al]=Sl[Al]);const Tl="undefined"!=typeof navigator&&/Mac|iP(hone|[oa]d)/.test(navigator.platform);function Dl(e){let t,n,o,r,i=e.split(/-(?!$)/),s=i[i.length-1];"Space"==s&&(s=" ");for(let e=0;e<i.length-1;e++){let s=i[e];if(/^(cmd|meta|m)$/i.test(s))r=!0;else if(/^a(lt)?$/i.test(s))t=!0;else if(/^(c|ctrl|control)$/i.test(s))n=!0;else if(/^s(hift)?$/i.test(s))o=!0;else{if(!/^mod$/i.test(s))throw new Error("Unrecognized modifier name: "+s);Tl?r=!0:n=!0}}return t&&(s="Alt-"+s),n&&(s="Ctrl-"+s),r&&(s="Meta-"+s),o&&(s="Shift-"+s),s}function El(e,t,n=!0){return t.altKey&&(e="Alt-"+e),t.ctrlKey&&(e="Ctrl-"+e),t.metaKey&&(e="Meta-"+e),n&&t.shiftKey&&(e="Shift-"+e),e}function Rl(e){let t=function(e){let t=Object.create(null);for(let n in e)t[Dl(n)]=e[n];return t}(e);return function(e,n){let o,r=function(e){var t=!(Ml&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||Nl&&e.shiftKey&&e.key&&1==e.key.length||"Unidentified"==e.key)&&e.key||(e.shiftKey?Cl:Sl)[e.keyCode]||e.key||"Unidentified";return"Esc"==t&&(t="Escape"),"Del"==t&&(t="Delete"),"Left"==t&&(t="ArrowLeft"),"Up"==t&&(t="ArrowUp"),"Right"==t&&(t="ArrowRight"),"Down"==t&&(t="ArrowDown"),t}(n),i=t[El(r,n)];if(i&&i(e.state,e.dispatch,e))return!0;if(1==r.length&&" "!=r){if(n.shiftKey){let o=t[El(r,n,!1)];if(o&&o(e.state,e.dispatch,e))return!0}if((n.shiftKey||n.altKey||n.metaKey||r.charCodeAt(0)>127)&&(o=Sl[n.keyCode])&&o!=r){let r=t[El(o,n)];if(r&&r(e.state,e.dispatch,e))return!0}}return!1}}var $l,Il;if("undefined"!=typeof WeakMap){let e=new WeakMap;$l=t=>e.get(t),Il=(t,n)=>(e.set(t,n),n)}else{const e=[],t=10;let n=0;$l=t=>{for(let n=0;n<e.length;n+=2)if(e[n]==t)return e[n+1]},Il=(o,r)=>(n==t&&(n=0),e[n++]=o,e[n++]=r)}var zl=class{constructor(e,t,n,o){this.width=e,this.height=t,this.map=n,this.problems=o}findCell(e){for(let t=0;t<this.map.length;t++){const n=this.map[t];if(n!=e)continue;const o=t%this.width,r=t/this.width|0;let i=o+1,s=r+1;for(let e=1;i<this.width&&this.map[t+e]==n;e++)i++;for(let e=1;s<this.height&&this.map[t+this.width*e]==n;e++)s++;return{left:o,top:r,right:i,bottom:s}}throw new RangeError(`No cell with offset ${e} found`)}colCount(e){for(let t=0;t<this.map.length;t++)if(this.map[t]==e)return t%this.width;throw new RangeError(`No cell with offset ${e} found`)}nextCell(e,t,n){const{left:o,right:r,top:i,bottom:s}=this.findCell(e);return"horiz"==t?(n<0?0==o:r==this.width)?null:this.map[i*this.width+(n<0?o-1:r)]:(n<0?0==i:s==this.height)?null:this.map[o+this.width*(n<0?i-1:s)]}rectBetween(e,t){const{left:n,right:o,top:r,bottom:i}=this.findCell(e),{left:s,right:l,top:a,bottom:c}=this.findCell(t);return{left:Math.min(n,s),top:Math.min(r,a),right:Math.max(o,l),bottom:Math.max(i,c)}}cellsInRect(e){const t=[],n={};for(let o=e.top;o<e.bottom;o++)for(let r=e.left;r<e.right;r++){const i=o*this.width+r,s=this.map[i];n[s]||(n[s]=!0,r==e.left&&r&&this.map[i-1]==s||o==e.top&&o&&this.map[i-this.width]==s||t.push(s))}return t}positionAt(e,t,n){for(let o=0,r=0;;o++){const i=r+n.child(o).nodeSize;if(o==e){let n=t+e*this.width;const o=(e+1)*this.width;for(;n<o&&this.map[n]<r;)n++;return n==o?i-1:this.map[n]}r=i}}static get(e){return $l(e)||Il(e,function(e){if("table"!=e.type.spec.tableRole)throw new RangeError("Not a table node: "+e.type.name);const t=function(e){let t=-1,n=!1;for(let o=0;o<e.childCount;o++){const r=e.child(o);let i=0;if(n)for(let t=0;t<o;t++){const n=e.child(t);for(let e=0;e<n.childCount;e++){const r=n.child(e);t+r.attrs.rowspan>o&&(i+=r.attrs.colspan)}}for(let e=0;e<r.childCount;e++){const t=r.child(e);i+=t.attrs.colspan,t.attrs.rowspan>1&&(n=!0)}-1==t?t=i:t!=i&&(t=Math.max(t,i))}return t}(e),n=e.childCount,o=[];let r=0,i=null;const s=[];for(let e=0,r=t*n;e<r;e++)o[e]=0;for(let l=0,a=0;l<n;l++){const c=e.child(l);a++;for(let e=0;;e++){for(;r<o.length&&0!=o[r];)r++;if(e==c.childCount)break;const d=c.child(e),{colspan:h,rowspan:p,colwidth:u}=d.attrs;for(let e=0;e<p;e++){if(e+l>=n){(i||(i=[])).push({type:"overlong_rowspan",pos:a,n:p-e});break}const c=r+e*t;for(let e=0;e<h;e++){0==o[c+e]?o[c+e]=a:(i||(i=[])).push({type:"collision",row:l,pos:a,n:h-e});const n=u&&u[e];if(n){const o=(c+e)%t*2,r=s[o];null==r||r!=n&&1==s[o+1]?(s[o]=n,s[o+1]=1):r==n&&s[o+1]++}}}r+=h,a+=d.nodeSize}const d=(l+1)*t;let h=0;for(;r<d;)0==o[r++]&&h++;h&&(i||(i=[])).push({type:"missing",row:l,n:h}),a++}const l=new zl(t,n,o,i);let a=!1;for(let e=0;!a&&e<s.length;e+=2)null!=s[e]&&s[e+1]<n&&(a=!0);a&&function(e,t,n){e.problems||(e.problems=[]);const o={};for(let r=0;r<e.map.length;r++){const i=e.map[r];if(o[i])continue;o[i]=!0;const s=n.nodeAt(i);if(!s)throw new RangeError(`No cell with offset ${i} found`);let l=null;const a=s.attrs;for(let n=0;n<a.colspan;n++){const o=t[2*((r+n)%e.width)];null==o||a.colwidth&&a.colwidth[n]==o||((l||(l=Bl(a)))[n]=o)}l&&e.problems.unshift({type:"colwidth mismatch",pos:i,colwidth:l})}}(l,s,e);return l}(e))}};function Bl(e){if(e.colwidth)return e.colwidth.slice();const t=[];for(let n=0;n<e.colspan;n++)t.push(0);return t}function Pl(e,t){if("string"==typeof e)return{};const n=e.getAttribute("data-colwidth"),o=n&&/^\d+(,\d+)*$/.test(n)?n.split(",").map((e=>Number(e))):null,r=Number(e.getAttribute("colspan")||1),i={colspan:r,rowspan:Number(e.getAttribute("rowspan")||1),colwidth:o&&o.length==r?o:null};for(const n in t){const o=t[n].getFromDOM,r=o&&o(e);null!=r&&(i[n]=r)}return i}function Vl(e,t){const n={};1!=e.attrs.colspan&&(n.colspan=e.attrs.colspan),1!=e.attrs.rowspan&&(n.rowspan=e.attrs.rowspan),e.attrs.colwidth&&(n["data-colwidth"]=e.attrs.colwidth.join(","));for(const o in t){const r=t[o].setDOMAttr;r&&r(e.attrs[o],n)}return n}function Fl(e){const t=e.cellAttributes||{},n={colspan:{default:1},rowspan:{default:1},colwidth:{default:null}};for(const e in t)n[e]={default:t[e].default};return{table:{content:"table_row+",tableRole:"table",isolating:!0,group:e.tableGroup,parseDOM:[{tag:"table"}],toDOM:()=>["table",["tbody",0]]},table_row:{content:"(table_cell | table_header)*",tableRole:"row",parseDOM:[{tag:"tr"}],toDOM:()=>["tr",0]},table_cell:{content:e.cellContent,attrs:n,tableRole:"cell",isolating:!0,parseDOM:[{tag:"td",getAttrs:e=>Pl(e,t)}],toDOM:e=>["td",Vl(e,t),0]},table_header:{content:e.cellContent,attrs:n,tableRole:"header_cell",isolating:!0,parseDOM:[{tag:"th",getAttrs:e=>Pl(e,t)}],toDOM:e=>["th",Vl(e,t),0]}}}function Ll(e){let t=e.cached.tableNodeTypes;if(!t){t=e.cached.tableNodeTypes={};for(const n in e.nodes){const o=e.nodes[n],r=o.spec.tableRole;r&&(t[r]=o)}}return t}var Hl=new xt("selectingCells");function _l(e){for(let t=e.depth-1;t>0;t--)if("row"==e.node(t).type.spec.tableRole)return e.node(0).resolve(e.before(t+1));return null}function Wl(e){const t=e.selection.$head;for(let e=t.depth;e>0;e--)if("row"==t.node(e).type.spec.tableRole)return!0;return!1}function ql(e){const t=e.selection;if("$anchorCell"in t&&t.$anchorCell)return t.$anchorCell.pos>t.$headCell.pos?t.$anchorCell:t.$headCell;if("node"in t&&t.node&&"cell"==t.node.type.spec.tableRole)return t.$anchor;const n=_l(t.$head)||function(e){for(let t=e.nodeAfter,n=e.pos;t;t=t.firstChild,n++){const o=t.type.spec.tableRole;if("cell"==o||"header_cell"==o)return e.doc.resolve(n)}for(let t=e.nodeBefore,n=e.pos;t;t=t.lastChild,n--){const o=t.type.spec.tableRole;if("cell"==o||"header_cell"==o)return e.doc.resolve(n-t.nodeSize)}}(t.$head);if(n)return n;throw new RangeError(`No cell found around position ${t.head}`)}function Jl(e){return"row"==e.parent.type.spec.tableRole&&!!e.nodeAfter}function jl(e){return e.node(0).resolve(e.pos+e.nodeAfter.nodeSize)}function Kl(e,t){return e.depth==t.depth&&e.pos>=t.start(-1)&&e.pos<=t.end(-1)}function Xl(e,t,n){const o=e.node(-1),r=zl.get(o),i=e.start(-1),s=r.nextCell(e.pos-i,t,n);return null==s?null:e.node(0).resolve(i+s)}function Ul(e,t,n=1){const o={...e,colspan:e.colspan-n};return o.colwidth&&(o.colwidth=o.colwidth.slice(),o.colwidth.splice(t,n),o.colwidth.some((e=>e>0))||(o.colwidth=null)),o}function Gl(e,t,n=1){const o={...e,colspan:e.colspan+n};if(o.colwidth){o.colwidth=o.colwidth.slice();for(let e=0;e<n;e++)o.colwidth.splice(t,0,0)}return o}function Yl(e,t,n){const o=Ll(t.type.schema).header_cell;for(let r=0;r<e.height;r++)if(t.nodeAt(e.map[n+r*e.width]).type!=o)return!1;return!0}var Ql=class e extends et{constructor(e,t=e){const n=e.node(-1),o=zl.get(n),r=e.start(-1),i=o.rectBetween(e.pos-r,t.pos-r),s=e.node(0),l=o.cellsInRect(i).filter((e=>e!=t.pos-r));l.unshift(t.pos-r);const a=l.map((e=>{const t=n.nodeAt(e);if(!t)throw RangeError(`No cell with offset ${e} found`);const o=r+e+1;return new tt(s.resolve(o),s.resolve(o+t.content.size))}));super(a[0].$from,a[0].$to,a),this.$anchorCell=e,this.$headCell=t}map(t,n){const o=t.resolve(n.map(this.$anchorCell.pos)),r=t.resolve(n.map(this.$headCell.pos));if(Jl(o)&&Jl(r)&&Kl(o,r)){const t=this.$anchorCell.node(-1)!=o.node(-1);return t&&this.isRowSelection()?e.rowSelection(o,r):t&&this.isColSelection()?e.colSelection(o,r):new e(o,r)}return rt.between(o,r)}content(){const e=this.$anchorCell.node(-1),t=zl.get(e),n=this.$anchorCell.start(-1),o=t.rectBetween(this.$anchorCell.pos-n,this.$headCell.pos-n),i={},s=[];for(let n=o.top;n<o.bottom;n++){const l=[];for(let r=n*t.width+o.left,s=o.left;s<o.right;s++,r++){const n=t.map[r];if(i[n])continue;i[n]=!0;const s=t.findCell(n);let a=e.nodeAt(n);if(!a)throw RangeError(`No cell with offset ${n} found`);const c=o.left-s.left,d=s.right-o.right;if(c>0||d>0){let e=a.attrs;if(c>0&&(e=Ul(e,0,c)),d>0&&(e=Ul(e,e.colspan-d,d)),s.left<o.left){if(a=a.type.createAndFill(e),!a)throw RangeError(`Could not create cell with attrs ${JSON.stringify(e)}`)}else a=a.type.create(e,a.content)}if(s.top<o.top||s.bottom>o.bottom){const e={...a.attrs,rowspan:Math.min(s.bottom,o.bottom)-Math.max(s.top,o.top)};a=s.top<o.top?a.type.createAndFill(e):a.type.create(e,a.content)}l.push(a)}s.push(e.child(n).copy(r.from(l)))}const l=this.isColSelection()&&this.isRowSelection()?e:s;return new d(r.from(l),1,1)}replace(e,t=d.empty){const n=e.steps.length,o=this.ranges;for(let r=0;r<o.length;r++){const{$from:i,$to:s}=o[r],l=e.mapping.slice(n);e.replace(l.map(i.pos),l.map(s.pos),r?d.empty:t)}const r=et.findFrom(e.doc.resolve(e.mapping.slice(n).map(this.to)),-1);r&&e.setSelection(r)}replaceWith(e,t){this.replace(e,new d(r.from(t),0,0))}forEachCell(e){const t=this.$anchorCell.node(-1),n=zl.get(t),o=this.$anchorCell.start(-1),r=n.cellsInRect(n.rectBetween(this.$anchorCell.pos-o,this.$headCell.pos-o));for(let n=0;n<r.length;n++)e(t.nodeAt(r[n]),o+r[n])}isColSelection(){const e=this.$anchorCell.index(-1),t=this.$headCell.index(-1);if(Math.min(e,t)>0)return!1;const n=e+this.$anchorCell.nodeAfter.attrs.rowspan,o=t+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(n,o)==this.$headCell.node(-1).childCount}static colSelection(t,n=t){const o=t.node(-1),r=zl.get(o),i=t.start(-1),s=r.findCell(t.pos-i),l=r.findCell(n.pos-i),a=t.node(0);return s.top<=l.top?(s.top>0&&(t=a.resolve(i+r.map[s.left])),l.bottom<r.height&&(n=a.resolve(i+r.map[r.width*(r.height-1)+l.right-1]))):(l.top>0&&(n=a.resolve(i+r.map[l.left])),s.bottom<r.height&&(t=a.resolve(i+r.map[r.width*(r.height-1)+s.right-1]))),new e(t,n)}isRowSelection(){const e=this.$anchorCell.node(-1),t=zl.get(e),n=this.$anchorCell.start(-1),o=t.colCount(this.$anchorCell.pos-n),r=t.colCount(this.$headCell.pos-n);if(Math.min(o,r)>0)return!1;const i=o+this.$anchorCell.nodeAfter.attrs.colspan,s=r+this.$headCell.nodeAfter.attrs.colspan;return Math.max(i,s)==t.width}eq(t){return t instanceof e&&t.$anchorCell.pos==this.$anchorCell.pos&&t.$headCell.pos==this.$headCell.pos}static rowSelection(t,n=t){const o=t.node(-1),r=zl.get(o),i=t.start(-1),s=r.findCell(t.pos-i),l=r.findCell(n.pos-i),a=t.node(0);return s.left<=l.left?(s.left>0&&(t=a.resolve(i+r.map[s.top*r.width])),l.right<r.width&&(n=a.resolve(i+r.map[r.width*(l.top+1)-1]))):(l.left>0&&(n=a.resolve(i+r.map[l.top*r.width])),s.right<r.width&&(t=a.resolve(i+r.map[r.width*(s.top+1)-1]))),new e(t,n)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(t,n){return new e(t.resolve(n.anchor),t.resolve(n.head))}static create(t,n,o=n){return new e(t.resolve(n),t.resolve(o))}getBookmark(){return new Zl(this.$anchorCell.pos,this.$headCell.pos)}};Ql.prototype.visible=!1,et.jsonID("cell",Ql);var Zl=class e{constructor(e,t){this.anchor=e,this.head=t}map(t){return new e(t.map(this.anchor),t.map(this.head))}resolve(e){const t=e.resolve(this.anchor),n=e.resolve(this.head);return"row"==t.parent.type.spec.tableRole&&"row"==n.parent.type.spec.tableRole&&t.index()<t.parent.childCount&&n.index()<n.parent.childCount&&Kl(t,n)?new Ql(t,n):et.near(n,1)}};function ea(e){if(!(e.selection instanceof Ql))return null;const t=[];return e.selection.forEachCell(((e,n)=>{t.push(Hs.node(n,n+e.nodeSize,{class:"selectedCell"}))})),qs.create(e.doc,t)}var ta=new xt("fix-tables");function na(e,t,n,o){const r=e.childCount,i=t.childCount;e:for(let s=0,l=0;s<i;s++){const i=t.child(s);for(let t=l,o=Math.min(r,s+3);t<o;t++)if(e.child(t)==i){l=t+1,n+=i.nodeSize;continue e}o(i,n),l<r&&e.child(l).sameMarkup(i)?na(e.child(l),i,n+1,o):i.nodesBetween(0,i.content.size,o,n+1),n+=i.nodeSize}}function oa(e,t){let n;const o=(t,o)=>{"table"==t.type.spec.tableRole&&(n=function(e,t,n,o){const r=zl.get(t);if(!r.problems)return o;o||(o=e.tr);const i=[];for(let e=0;e<r.height;e++)i.push(0);for(let e=0;e<r.problems.length;e++){const s=r.problems[e];if("collision"==s.type){const e=t.nodeAt(s.pos);if(!e)continue;const r=e.attrs;for(let e=0;e<r.rowspan;e++)i[s.row+e]+=s.n;o.setNodeMarkup(o.mapping.map(n+1+s.pos),null,Ul(r,r.colspan-s.n,s.n))}else if("missing"==s.type)i[s.row]+=s.n;else if("overlong_rowspan"==s.type){const e=t.nodeAt(s.pos);if(!e)continue;o.setNodeMarkup(o.mapping.map(n+1+s.pos),null,{...e.attrs,rowspan:e.attrs.rowspan-s.n})}else if("colwidth mismatch"==s.type){const e=t.nodeAt(s.pos);if(!e)continue;o.setNodeMarkup(o.mapping.map(n+1+s.pos),null,{...e.attrs,colwidth:s.colwidth})}}let s,l;for(let e=0;e<i.length;e++)i[e]&&(null==s&&(s=e),l=e);for(let a=0,c=n+1;a<r.height;a++){const n=t.child(a),r=c+n.nodeSize,d=i[a];if(d>0){let t="cell";n.firstChild&&(t=n.firstChild.type.spec.tableRole);const i=[];for(let n=0;n<d;n++){const n=Ll(e.schema)[t].createAndFill();n&&i.push(n)}const h=0!=a&&s!=a-1||l!=a?r-1:c+1;o.insert(o.mapping.map(h),i)}c=r}return o.setMeta(ta,{fixTables:!0})}(e,t,o,n))};return t?t.doc!=e.doc&&na(t.doc,e.doc,0,o):e.doc.descendants(o),n}function ra(e){const t=e.selection,n=ql(e),o=n.node(-1),r=n.start(-1),i=zl.get(o);return{...t instanceof Ql?i.rectBetween(t.$anchorCell.pos-r,t.$headCell.pos-r):i.findCell(n.pos-r),tableStart:r,map:i,table:o}}function ia(e,{map:t,tableStart:n,table:o},r){let i=r>0?-1:0;Yl(t,o,r+i)&&(i=0==r||r==t.width?null:0);for(let s=0;s<t.height;s++){const l=s*t.width+r;if(r>0&&r<t.width&&t.map[l-1]==t.map[l]){const i=t.map[l],a=o.nodeAt(i);e.setNodeMarkup(e.mapping.map(n+i),null,Gl(a.attrs,r-t.colCount(i))),s+=a.attrs.rowspan-1}else{const a=null==i?Ll(o.type.schema).cell:o.nodeAt(t.map[l+i]).type,c=t.positionAt(s,r,o);e.insert(e.mapping.map(n+c),a.createAndFill())}}return e}function sa(e,t){if(!Wl(e))return!1;if(t){const n=ra(e);t(ia(e.tr,n,n.left))}return!0}function la(e,t){if(!Wl(e))return!1;if(t){const n=ra(e);t(ia(e.tr,n,n.right))}return!0}function aa(e,{map:t,table:n,tableStart:o},r){const i=e.mapping.maps.length;for(let s=0;s<t.height;){const l=s*t.width+r,a=t.map[l],c=n.nodeAt(a),d=c.attrs;if(r>0&&t.map[l-1]==a||r<t.width-1&&t.map[l+1]==a)e.setNodeMarkup(e.mapping.slice(i).map(o+a),null,Ul(d,r-t.colCount(a)));else{const t=e.mapping.slice(i).map(o+a);e.delete(t,t+c.nodeSize)}s+=d.rowspan}}function ca(e,t){if(!Wl(e))return!1;if(t){const n=ra(e),o=e.tr;if(0==n.left&&n.right==n.map.width)return!1;for(let e=n.right-1;aa(o,n,e),e!=n.left;e--){const e=n.tableStart?o.doc.nodeAt(n.tableStart-1):o.doc;if(!e)throw RangeError("No table found");n.table=e,n.map=zl.get(e)}t(o)}return!0}function da(e,t,n){var o;const r=Ll(t.type.schema).header_cell;for(let i=0;i<e.width;i++)if((null==(o=t.nodeAt(e.map[i+n*e.width]))?void 0:o.type)!=r)return!1;return!0}function ha(e,{map:t,tableStart:n,table:o},r){var i;let s=n;for(let e=0;e<r;e++)s+=o.child(e).nodeSize;const l=[];let a=r>0?-1:0;da(t,o,r+a)&&(a=0==r||r==t.height?null:0);for(let s=0,c=t.width*r;s<t.width;s++,c++)if(r>0&&r<t.height&&t.map[c]==t.map[c-t.width]){const r=t.map[c],i=o.nodeAt(r).attrs;e.setNodeMarkup(n+r,null,{...i,rowspan:i.rowspan+1}),s+=i.colspan-1}else{const e=null==a?Ll(o.type.schema).cell:null==(i=o.nodeAt(t.map[c+a*t.width]))?void 0:i.type,n=null==e?void 0:e.createAndFill();n&&l.push(n)}return e.insert(s,Ll(o.type.schema).row.create(null,l)),e}function pa(e,t){if(!Wl(e))return!1;if(t){const n=ra(e);t(ha(e.tr,n,n.top))}return!0}function ua(e,t){if(!Wl(e))return!1;if(t){const n=ra(e);t(ha(e.tr,n,n.bottom))}return!0}function fa(e,{map:t,table:n,tableStart:o},r){let i=0;for(let e=0;e<r;e++)i+=n.child(e).nodeSize;const s=i+n.child(r).nodeSize,l=e.mapping.maps.length;e.delete(i+o,s+o);const a=new Set;for(let i=0,s=r*t.width;i<t.width;i++,s++){const c=t.map[s];if(!a.has(c))if(a.add(c),r>0&&c==t.map[s-t.width]){const t=n.nodeAt(c).attrs;e.setNodeMarkup(e.mapping.slice(l).map(c+o),null,{...t,rowspan:t.rowspan-1}),i+=t.colspan-1}else if(r<t.height&&c==t.map[s+t.width]){const s=n.nodeAt(c),a=s.attrs,d=s.type.create({...a,rowspan:s.attrs.rowspan-1},s.content),h=t.positionAt(r+1,i,n);e.insert(e.mapping.slice(l).map(o+h),d),i+=a.colspan-1}}}function ma(e){const t=e.content;return 1==t.childCount&&t.child(0).isTextblock&&0==t.child(0).childCount}function ga(e){return(t,n)=>{var o;const r=t.selection;let i,s;if(r instanceof Ql){if(r.$anchorCell.pos!=r.$headCell.pos)return!1;i=r.$anchorCell.nodeAfter,s=r.$anchorCell.pos}else{if(i=function(e){for(let t=e.depth;t>0;t--){const n=e.node(t).type.spec.tableRole;if("cell"===n||"header_cell"===n)return e.node(t)}return null}(r.$from),!i)return!1;s=null==(o=_l(r.$from))?void 0:o.pos}if(null==i||null==s)return!1;if(1==i.attrs.colspan&&1==i.attrs.rowspan)return!1;if(n){let o=i.attrs;const l=[],a=o.colwidth;o.rowspan>1&&(o={...o,rowspan:1}),o.colspan>1&&(o={...o,colspan:1});const c=ra(t),d=t.tr;for(let e=0;e<c.right-c.left;e++)l.push(a?{...o,colwidth:a&&a[e]?[a[e]]:null}:o);let h;for(let t=c.top;t<c.bottom;t++){let n=c.map.positionAt(t,c.left,c.table);t==c.top&&(n+=i.nodeSize);for(let o=c.left,r=0;o<c.right;o++,r++)o==c.left&&t==c.top||d.insert(h=d.mapping.map(n+c.tableStart,1),e({node:i,row:t,col:o}).createAndFill(l[r]))}d.setNodeMarkup(s,e({node:i,row:c.top,col:c.left}),l[0]),r instanceof Ql&&d.setSelection(new Ql(d.doc.resolve(r.$anchorCell.pos),h?d.doc.resolve(h):void 0)),n(d)}return!0}}function ya(e,t,n){const o=t.map.cellsInRect({left:0,top:0,right:"row"==e?t.map.width:1,bottom:"column"==e?t.map.height:1});for(let e=0;e<o.length;e++){const r=t.table.nodeAt(o[e]);if(r&&r.type!==n.header_cell)return!1}return!0}function wa(e,t){return(t=t||{useDeprecatedLogic:!1}).useDeprecatedLogic?function(e){return function(t,n){if(!Wl(t))return!1;if(n){const o=Ll(t.schema),r=ra(t),i=t.tr,s=r.map.cellsInRect("column"==e?{left:r.left,top:0,right:r.right,bottom:r.map.height}:"row"==e?{left:0,top:r.top,right:r.map.width,bottom:r.bottom}:r),l=s.map((e=>r.table.nodeAt(e)));for(let e=0;e<s.length;e++)l[e].type==o.header_cell&&i.setNodeMarkup(r.tableStart+s[e],o.cell,l[e].attrs);if(0==i.steps.length)for(let e=0;e<s.length;e++)i.setNodeMarkup(r.tableStart+s[e],o.header_cell,l[e].attrs);n(i)}return!0}}(e):function(t,n){if(!Wl(t))return!1;if(n){const o=Ll(t.schema),r=ra(t),i=t.tr,s=ya("row",r,o),l=ya("column",r,o),a=("column"===e?s:"row"===e&&l)?1:0,c="column"==e?{left:0,top:a,right:1,bottom:r.map.height}:"row"==e?{left:a,top:0,right:r.map.width,bottom:1}:r,d="column"==e?l?o.cell:o.header_cell:"row"==e?s?o.cell:o.header_cell:o.cell;r.map.cellsInRect(c).forEach((e=>{const t=e+r.tableStart,n=i.doc.nodeAt(t);n&&i.setNodeMarkup(t,d,n.attrs)})),n(i)}return!0}}var va=wa("row",{useDeprecatedLogic:!0}),ba=wa("column",{useDeprecatedLogic:!0}),ka=wa("cell",{useDeprecatedLogic:!0});function xa(e,t){const n=e.selection;if(!(n instanceof Ql))return!1;if(t){const o=e.tr,r=Ll(e.schema).cell.createAndFill().content;n.forEachCell(((e,t)=>{e.content.eq(r)||o.replace(o.mapping.map(t+1),o.mapping.map(t+e.nodeSize-1),new d(r,0,0))})),o.docChanged&&t(o)}return!0}function Sa(e){if(!e.size)return null;let{content:t,openStart:n,openEnd:o}=e;for(;1==t.childCount&&(n>0&&o>0||"table"==t.child(0).type.spec.tableRole);)n--,o--,t=t.child(0).content;const i=t.child(0),s=i.type.spec.tableRole,l=i.type.schema,a=[];if("row"==s)for(let e=0;e<t.childCount;e++){let r=t.child(e).content;const i=e?0:Math.max(0,n-1),s=e<t.childCount-1?0:Math.max(0,o-1);(i||s)&&(r=Ca(Ll(l).row,new d(r,i,s)).content),a.push(r)}else{if("cell"!=s&&"header_cell"!=s)return null;a.push(n||o?Ca(Ll(l).row,new d(t,n,o)).content:t)}return function(e,t){const n=[];for(let e=0;e<t.length;e++){const o=t[e];for(let t=o.childCount-1;t>=0;t--){const{rowspan:r,colspan:i}=o.child(t).attrs;for(let t=e;t<e+r;t++)n[t]=(n[t]||0)+i}}let o=0;for(let e=0;e<n.length;e++)o=Math.max(o,n[e]);for(let i=0;i<n.length;i++)if(i>=t.length&&t.push(r.empty),n[i]<o){const s=Ll(e).cell.createAndFill(),l=[];for(let e=n[i];e<o;e++)l.push(s);t[i]=t[i].append(r.from(l))}return{height:t.length,width:o,rows:t}}(l,a)}function Ca(e,t){const n=e.createAndFill();return new Qe(n).replace(0,n.content.size,t).doc}function Ma(e,t,n,o,r,i,s,l){if(0==s||s==t.height)return!1;let a=!1;for(let c=r;c<i;c++){const r=s*t.width+c,i=t.map[r];if(t.map[r-t.width]==i){a=!0;const r=n.nodeAt(i),{top:d,left:h}=t.findCell(i);e.setNodeMarkup(e.mapping.slice(l).map(i+o),null,{...r.attrs,rowspan:s-d}),e.insert(e.mapping.slice(l).map(t.positionAt(s,h,n)),r.type.createAndFill({...r.attrs,rowspan:d+r.attrs.rowspan-s})),c+=r.attrs.colspan-1}}return a}function Na(e,t,n,o,r,i,s,l){if(0==s||s==t.width)return!1;let a=!1;for(let c=r;c<i;c++){const r=c*t.width+s,i=t.map[r];if(t.map[r-1]==i){a=!0;const r=n.nodeAt(i),d=t.colCount(i),h=e.mapping.slice(l).map(i+o);e.setNodeMarkup(h,null,Ul(r.attrs,s-d,r.attrs.colspan-(s-d))),e.insert(h+r.nodeSize,r.type.createAndFill(Ul(r.attrs,0,s-d))),c+=r.attrs.rowspan-1}}return a}function Oa(e,t,n,o,i){let s=n?e.doc.nodeAt(n-1):e.doc;if(!s)throw new Error("No table found");let l=zl.get(s);const{top:a,left:c}=o,h=c+i.width,p=a+i.height,u=e.tr;let f=0;function m(){if(s=n?u.doc.nodeAt(n-1):u.doc,!s)throw new Error("No table found");l=zl.get(s),f=u.mapping.maps.length}(function(e,t,n,o,i,s,l){const a=Ll(e.doc.type.schema);let c,d;if(i>t.width)for(let r=0,s=0;r<t.height;r++){const h=n.child(r);s+=h.nodeSize;const p=[];let u;u=null==h.lastChild||h.lastChild.type==a.cell?c||(c=a.cell.createAndFill()):d||(d=a.header_cell.createAndFill());for(let e=t.width;e<i;e++)p.push(u);e.insert(e.mapping.slice(l).map(s-1+o),p)}if(s>t.height){const h=[];for(let e=0,o=(t.height-1)*t.width;e<Math.max(t.width,i);e++){const r=!(e>=t.width)&&n.nodeAt(t.map[o+e]).type==a.header_cell;h.push(r?d||(d=a.header_cell.createAndFill()):c||(c=a.cell.createAndFill()))}const p=a.row.create(null,r.from(h)),u=[];for(let e=t.height;e<s;e++)u.push(p);e.insert(e.mapping.slice(l).map(o+n.nodeSize-2),u)}return!(!c&&!d)})(u,l,s,n,h,p,f)&&m(),Ma(u,l,s,n,c,h,a,f)&&m(),Ma(u,l,s,n,c,h,p,f)&&m(),Na(u,l,s,n,a,p,c,f)&&m(),Na(u,l,s,n,a,p,h,f)&&m();for(let e=a;e<p;e++){const t=l.positionAt(e,c,s),o=l.positionAt(e,h,s);u.replace(u.mapping.slice(f).map(t+n),u.mapping.slice(f).map(o+n),new d(i.rows[e-a],0,0))}m(),u.setSelection(new Ql(u.doc.resolve(n+l.positionAt(a,c,s)),u.doc.resolve(n+l.positionAt(p-1,h-1,s)))),t(u)}var Aa=Rl({ArrowLeft:Da("horiz",-1),ArrowRight:Da("horiz",1),ArrowUp:Da("vert",-1),ArrowDown:Da("vert",1),"Shift-ArrowLeft":Ea("horiz",-1),"Shift-ArrowRight":Ea("horiz",1),"Shift-ArrowUp":Ea("vert",-1),"Shift-ArrowDown":Ea("vert",1),Backspace:xa,"Mod-Backspace":xa,Delete:xa,"Mod-Delete":xa});function Ta(e,t,n){return!n.eq(e.selection)&&(t&&t(e.tr.setSelection(n).scrollIntoView()),!0)}function Da(e,t){return(n,o,r)=>{if(!r)return!1;const i=n.selection;if(i instanceof Ql)return Ta(n,o,et.near(i.$headCell,t));if("horiz"!=e&&!i.empty)return!1;const s=za(r,e,t);if(null==s)return!1;if("horiz"==e)return Ta(n,o,et.near(n.doc.resolve(i.head+t),t));{const r=n.doc.resolve(s),i=Xl(r,e,t);let l;return l=i?et.near(i,1):t<0?et.near(n.doc.resolve(r.before(-1)),-1):et.near(n.doc.resolve(r.after(-1)),1),Ta(n,o,l)}}}function Ea(e,t){return(n,o,r)=>{if(!r)return!1;const i=n.selection;let s;if(i instanceof Ql)s=i;else{const o=za(r,e,t);if(null==o)return!1;s=new Ql(n.doc.resolve(o))}const l=Xl(s.$headCell,e,t);return!!l&&Ta(n,o,new Ql(s.$anchorCell,l))}}function Ra(e,t){const n=_l(e.state.doc.resolve(t));return!!n&&(e.dispatch(e.state.tr.setSelection(new Ql(n))),!0)}function $a(e,t,n){if(!Wl(e.state))return!1;let o=Sa(n);const i=e.state.selection;if(i instanceof Ql){o||(o={width:1,height:1,rows:[r.from(Ca(Ll(e.state.schema).cell,n))]});const t=i.$anchorCell.node(-1),s=i.$anchorCell.start(-1),l=zl.get(t).rectBetween(i.$anchorCell.pos-s,i.$headCell.pos-s);return o=function({width:e,height:t,rows:n},o,i){if(e!=o){const t=[],i=[];for(let e=0;e<n.length;e++){const s=n[e],l=[];for(let n=t[e]||0,r=0;n<o;r++){let i=s.child(r%s.childCount);n+i.attrs.colspan>o&&(i=i.type.createChecked(Ul(i.attrs,i.attrs.colspan,n+i.attrs.colspan-o),i.content)),l.push(i),n+=i.attrs.colspan;for(let n=1;n<i.attrs.rowspan;n++)t[e+n]=(t[e+n]||0)+i.attrs.colspan}i.push(r.from(l))}n=i,e=o}if(t!=i){const e=[];for(let o=0,s=0;o<i;o++,s++){const l=[],a=n[s%t];for(let e=0;e<a.childCount;e++){let t=a.child(e);o+t.attrs.rowspan>i&&(t=t.type.create({...t.attrs,rowspan:Math.max(1,i-t.attrs.rowspan)},t.content)),l.push(t)}e.push(r.from(l))}n=e,t=i}return{width:e,height:t,rows:n}}(o,l.right-l.left,l.bottom-l.top),Oa(e.state,e.dispatch,s,l,o),!0}if(o){const t=ql(e.state),n=t.start(-1);return Oa(e.state,e.dispatch,n,zl.get(t.node(-1)).findCell(t.pos-n),o),!0}return!1}function Ia(e,t){var n;if(t.ctrlKey||t.metaKey)return;const o=Ba(e,t.target);let r;if(t.shiftKey&&e.state.selection instanceof Ql)i(e.state.selection.$anchorCell,t),t.preventDefault();else if(t.shiftKey&&o&&null!=(r=_l(e.state.selection.$anchor))&&(null==(n=Pa(e,t))?void 0:n.pos)!=r.pos)i(r,t),t.preventDefault();else if(!o)return;function i(t,n){let o=Pa(e,n);const r=null==Hl.getState(e.state);if(!o||!Kl(t,o)){if(!r)return;o=t}const i=new Ql(t,o);if(r||!e.state.selection.eq(i)){const n=e.state.tr.setSelection(i);r&&n.setMeta(Hl,t.pos),e.dispatch(n)}}function s(){e.root.removeEventListener("mouseup",s),e.root.removeEventListener("dragstart",s),e.root.removeEventListener("mousemove",l),null!=Hl.getState(e.state)&&e.dispatch(e.state.tr.setMeta(Hl,-1))}function l(n){const r=n,l=Hl.getState(e.state);let a;if(null!=l)a=e.state.doc.resolve(l);else if(Ba(e,r.target)!=o&&(a=Pa(e,t),!a))return s();a&&i(a,r)}e.root.addEventListener("mouseup",s),e.root.addEventListener("dragstart",s),e.root.addEventListener("mousemove",l)}function za(e,t,n){if(!(e.state.selection instanceof rt))return null;const{$head:o}=e.state.selection;for(let r=o.depth-1;r>=0;r--){const i=o.node(r);if((n<0?o.index(r):o.indexAfter(r))!=(n<0?0:i.childCount))return null;if("cell"==i.type.spec.tableRole||"header_cell"==i.type.spec.tableRole){const i=o.before(r),s="vert"==t?n>0?"down":"up":n>0?"right":"left";return e.endOfTextblock(s)?i:null}}return null}function Ba(e,t){for(;t&&t!=e.dom;t=t.parentNode)if("TD"==t.nodeName||"TH"==t.nodeName)return t;return null}function Pa(e,t){const n=e.posAtCoords({left:t.clientX,top:t.clientY});return n&&n?_l(e.state.doc.resolve(n.pos)):null}var Va=class{constructor(e,t){this.node=e,this.defaultCellMinWidth=t,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.table.style.setProperty("--default-cell-min-width",`${t}px`),this.colgroup=this.table.appendChild(document.createElement("colgroup")),Fa(e,this.colgroup,this.table,t),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type==this.node.type&&(this.node=e,Fa(e,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(e){return"attributes"==e.type&&(e.target==this.table||this.colgroup.contains(e.target))}};function Fa(e,t,n,o,r,i){var s;let l=0,a=!0,c=t.firstChild;const d=e.firstChild;if(d){for(let e=0,n=0;e<d.childCount;e++){const{colspan:s,colwidth:h}=d.child(e).attrs;for(let e=0;e<s;e++,n++){const s=r==n?i:h&&h[e],d=s?s+"px":"";if(l+=s||o,s||(a=!1),c)c.style.width!=d&&(c.style.width=d),c=c.nextSibling;else{const e=document.createElement("col");e.style.width=d,t.appendChild(e)}}}for(;c;){const e=c.nextSibling;null==(s=c.parentNode)||s.removeChild(c),c=e}a?(n.style.width=l+"px",n.style.minWidth=""):(n.style.width="",n.style.minWidth=l+"px")}}var La=new xt("tableColumnResizing");var Ha=class e{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(t){const n=this,o=t.getMeta(La);if(o&&null!=o.setHandle)return new e(o.setHandle,!1);if(o&&void 0!==o.setDragging)return new e(n.activeHandle,o.setDragging);if(n.activeHandle>-1&&t.docChanged){let o=t.mapping.map(n.activeHandle,-1);return Jl(t.doc.resolve(o))||(o=-1),new e(o,n.dragging)}return n}};function _a(e,t,n,o){const r="right"==n?-o:o,i=e.posAtCoords({left:t.clientX+r,top:t.clientY});if(!i)return-1;const{pos:s}=i,l=_l(e.state.doc.resolve(s));if(!l)return-1;if("right"==n)return l.pos;const a=zl.get(l.node(-1)),c=l.start(-1),d=a.map.indexOf(l.pos-c);return d%a.width==0?-1:c+a.map[d-1]}function Wa(e,t,n){const o=t.clientX-e.startX;return Math.max(n,e.startWidth+o)}function qa(e,t){e.dispatch(e.state.tr.setMeta(La,{setHandle:t}))}function Ja(e,t,n,o){const r=e.state.doc.resolve(t),i=r.node(-1),s=r.start(-1),l=zl.get(i).colCount(r.pos-s)+r.nodeAfter.attrs.colspan-1;let a=e.domAtPos(r.start(-1)).node;for(;a&&"TABLE"!=a.nodeName;)a=a.parentNode;a&&Fa(i,a.firstChild,a,o,l,n)}function ja(e){return Array(e).fill(0)}const Ka=["blockquote",0],Xa=["hr"],Ua=["pre",["code",0]],Ga=["ol",0],Ya=["ul",0],Qa=["li",0],Za=e=>{const t={},n=e.attributes;let o;for(let e=0;e<n.length;e++)o=n[e],t[o.name]=o.value;return t},ec=e=>{const t={};return e.forEach((e=>{t[e]={default:null}})),t},tc=()=>ec(["style","class","id"]),nc=(e,t)=>{for(const n in e)if(n&&null!==e[n]&&n!==t)return!0;return!1},oc=(e,t=[])=>{const n={};for(const o in e)o&&null!==e[o]&&!t.find((e=>e===o))&&(n[o]=e[o]);return n},rc=e=>({[e]:{name:e,inclusive:!0,parseDOM:[{tag:e}],toDOM:()=>[e,0]}}),ic={link:{attrs:{...tc(),href:{default:null},target:{default:null},title:{default:null}},inclusive:!1,parseDOM:[{tag:"a",getAttrs:Za}],toDOM:e=>["a",oc(e.attrs),0]},...rc("strong"),...rc("b"),...rc("em"),...rc("i"),...rc("del"),...rc("sub"),...rc("sup"),...rc("code"),style:{attrs:{...tc()},parseDOM:[{tag:"span",getAttrs:Za}],toDOM:e=>nc(e.attrs)?["span",oc(e.attrs),0]:["span",0]},...rc("u")},sc=e=>({[e]:{default:null,getFromDOM:t=>t.getAttribute(e),setDOMAttr:(t,n)=>{n[e]=t}}}),lc={...sc("style"),...sc("class"),...sc("id"),...sc("headers"),...sc("scope")},ac=new K({nodes:{doc:{content:"colgroup*"},col:{attrs:ec(["id","class","style","span"]),parseDOM:[{getAttrs:Za,tag:"col"}],toDOM:e=>["col",e.attrs]},colgroup:{attrs:ec(["id","class","style","span"]),content:"col*",parseDOM:[{getAttrs:Za,tag:"colgroup"}],toDOM:e=>["colgroup",e.attrs,0]},text:{inline:!0,group:"inline"}},marks:{}}),cc=e=>{const t=wn(mn(e),ac,{preserveWhitespace:!1});return yn(t).firstChild},dc=Fl({tableGroup:"block",cellContent:"block+",cellAttributes:lc});dc.table_row.attrs={...dc.table_row.attrs,...ec([St,"style","class","id"])},dc.table_row.toDOM=e=>["tr",oc(e.attrs),0],dc.table_row.parseDOM=[{tag:"tr",getAttrs:Za}],dc.table.attrs={...dc.table.attrs,...ec(["style","class","id",Ct,Mt])},dc.table.toDOM=e=>{const t=nc(e.attrs)?oc(e.attrs,[Ct,Mt]):{};let n=null;if(e.attrs[Ct]&&!(e=>{let t=!1;const n=e.child(0);for(let e=0;e<n.childCount;e++)if(n.child(e).attrs.colwidth){t=!0;break}return t})(e)){const t=cc(e.attrs[Ct]);if(t){const e=Array.from(t.children).map((e=>["col",Za(e)]));n=["colgroup",Za(t)].concat(e)}}return n?["table",t,n,["tbody",0]]:["table",t,["tbody",0]]},dc.table.parseDOM=[{tag:"table",getAttrs:e=>{const t=Za(e),n=Array.from(e.childNodes).find((e=>"COLGROUP"===e.nodeName));return n&&(t[Ct]=n.outerHTML),t}}];const hc={doc:{content:"block+"},paragraph:{content:"inline*",group:"block",attrs:{...tc()},parseDOM:[{tag:"p",getAttrs:Za}],toDOM:e=>nc(e.attrs)?["p",oc(e.attrs),0]:["p",0]},table_wrapper:{content:"(table_caption_external | table)+",group:"block",defining:!0,attrs:{table:{default:null},style:{default:null}},parseDOM:[{tag:"div[table]",getAttrs:Za}],toDOM:e=>nc(e.attrs)?["div",oc(e.attrs),0]:["div",0]},table_caption_external:{content:"inline+",group:"block",attrs:{caption:{default:null},...tc()},parseDOM:[{tag:"div[caption]",getAttrs:Za}],toDOM:e=>nc(e.attrs)?["div",oc(e.attrs),0]:["div",0]},div:{content:"block*",group:"block",attrs:{...tc()},parseDOM:[{tag:"div",getAttrs:Za}],toDOM:e=>nc(e.attrs)?["div",oc(e.attrs),0]:["div",0]},blockquote:{attrs:{...tc()},content:"block+",group:"block",defining:!0,parseDOM:[{tag:"blockquote",getAttrs:Za}],toDOM:e=>nc(e.attrs)?["blockquote",oc(e.attrs),0]:Ka},horizontal_rule:{group:"block",parseDOM:[{tag:"hr"}],toDOM:()=>Xa},heading:{attrs:{...tc(),level:{default:1}},content:"inline*",group:"block",defining:!0,parseDOM:[{tag:"h1",getAttrs:e=>({...Za(e),level:1})},{tag:"h2",getAttrs:e=>({...Za(e),level:2})},{tag:"h3",getAttrs:e=>({...Za(e),level:3})},{tag:"h4",getAttrs:e=>({...Za(e),level:4})},{tag:"h5",getAttrs:e=>({...Za(e),level:5})},{tag:"h6",getAttrs:e=>({...Za(e),level:6})}],toDOM:e=>nc(e.attrs,"level")?["h"+e.attrs.level,oc(e.attrs,["level"]),0]:["h"+e.attrs.level,0]},code_block:{content:"text*",marks:"",group:"block",code:!0,defining:!0,parseDOM:[{tag:"pre",preserveWhitespace:"full"}],toDOM:()=>Ua},text:{inline:!0,group:"inline"},image:{inline:!0,attrs:{src:{default:null},alt:{default:null},title:{default:null},width:{default:null},height:{default:null},...tc()},group:"inline",draggable:!0,parseDOM:[{tag:"img",getAttrs:Za}],toDOM:e=>nc(e.attrs)?["img",oc(e.attrs)]:["img"]},hard_break:{inline:!0,attrs:{...tc()},group:"inline",selectable:!1,parseDOM:[{tag:"br",getAttrs:Za}],toDOM:e=>nc(e.attrs)?["br",oc(e.attrs)]:["br"]},ordered_list:{content:"list_item+",group:"block",attrs:{...tc(),type:{default:null},order:{default:1}},parseDOM:[{tag:"ol",getAttrs:e=>({...Za(e),order:e.hasAttribute("start")?parseInt(e.getAttribute("start")||"1",10):1})}],toDOM:e=>1===e.attrs.order?nc(e.attrs,"order")?["ol",oc(e.attrs,["order"]),0]:Ga:["ol",{...oc(e.attrs,["order"]),start:e.attrs.order},0]},bullet_list:{content:"list_item+",group:"block",attrs:{...tc()},parseDOM:[{tag:"ul",getAttrs:Za}],toDOM:e=>nc(e.attrs)?["ul",oc(e.attrs),0]:Ya},list_item:{content:"(paragraph | heading) block*",attrs:{...tc()},parseDOM:[{tag:"li",getAttrs:Za}],toDOM:e=>nc(e.attrs)?["li",oc(e.attrs),0]:Qa,defining:!0},...dc};var pc=200,uc=function(){};uc.prototype.append=function(e){return e.length?(e=uc.from(e),!this.length&&e||e.length<pc&&this.leafAppend(e)||this.length<pc&&e.leafPrepend(this)||this.appendInner(e)):this},uc.prototype.prepend=function(e){return e.length?uc.from(e).append(this):this},uc.prototype.appendInner=function(e){return new mc(this,e)},uc.prototype.slice=function(e,t){return void 0===e&&(e=0),void 0===t&&(t=this.length),e>=t?uc.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},uc.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},uc.prototype.forEach=function(e,t,n){void 0===t&&(t=0),void 0===n&&(n=this.length),t<=n?this.forEachInner(e,t,n,0):this.forEachInvertedInner(e,t,n,0)},uc.prototype.map=function(e,t,n){void 0===t&&(t=0),void 0===n&&(n=this.length);var o=[];return this.forEach((function(t,n){return o.push(e(t,n))}),t,n),o},uc.from=function(e){return e instanceof uc?e:e&&e.length?new fc(e):uc.empty};var fc=function(e){function t(t){e.call(this),this.values=t}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var n={length:{configurable:!0},depth:{configurable:!0}};return t.prototype.flatten=function(){return this.values},t.prototype.sliceInner=function(e,n){return 0==e&&n==this.length?this:new t(this.values.slice(e,n))},t.prototype.getInner=function(e){return this.values[e]},t.prototype.forEachInner=function(e,t,n,o){for(var r=t;r<n;r++)if(!1===e(this.values[r],o+r))return!1},t.prototype.forEachInvertedInner=function(e,t,n,o){for(var r=t-1;r>=n;r--)if(!1===e(this.values[r],o+r))return!1},t.prototype.leafAppend=function(e){if(this.length+e.length<=pc)return new t(this.values.concat(e.flatten()))},t.prototype.leafPrepend=function(e){if(this.length+e.length<=pc)return new t(e.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(t.prototype,n),t}(uc);uc.empty=new fc([]);var mc=function(e){function t(t,n){e.call(this),this.left=t,this.right=n,this.length=t.length+n.length,this.depth=Math.max(t.depth,n.depth)+1}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},t.prototype.getInner=function(e){return e<this.left.length?this.left.get(e):this.right.get(e-this.left.length)},t.prototype.forEachInner=function(e,t,n,o){var r=this.left.length;return!(t<r&&!1===this.left.forEachInner(e,t,Math.min(n,r),o))&&(!(n>r&&!1===this.right.forEachInner(e,Math.max(t-r,0),Math.min(this.length,n)-r,o+r))&&void 0)},t.prototype.forEachInvertedInner=function(e,t,n,o){var r=this.left.length;return!(t>r&&!1===this.right.forEachInvertedInner(e,t-r,Math.max(n,r)-r,o+r))&&(!(n<r&&!1===this.left.forEachInvertedInner(e,Math.min(t,r),n,o))&&void 0)},t.prototype.sliceInner=function(e,t){if(0==e&&t==this.length)return this;var n=this.left.length;return t<=n?this.left.slice(e,t):e>=n?this.right.slice(e-n,t-n):this.left.slice(e,n).append(this.right.slice(0,t-n))},t.prototype.leafAppend=function(e){var n=this.right.leafAppend(e);if(n)return new t(this.left,n)},t.prototype.leafPrepend=function(e){var n=this.left.leafPrepend(e);if(n)return new t(n,this.right)},t.prototype.appendInner=function(e){return this.left.depth>=Math.max(this.right.depth,e.depth)+1?new t(this.left,new t(this.right,e)):new t(this,e)},t}(uc);class gc{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(0==this.eventCount)return null;let n,o,r=this.items.length;for(;;r--){if(this.items.get(r-1).selection){--r;break}}t&&(n=this.remapping(r,this.items.length),o=n.maps.length);let i,s,l=e.tr,a=[],c=[];return this.items.forEach(((e,t)=>{if(!e.step)return n||(n=this.remapping(r,t+1),o=n.maps.length),o--,void c.push(e);if(n){c.push(new yc(e.map));let t,r=e.step.map(n.slice(o));r&&l.maybeStep(r).doc&&(t=l.mapping.maps[l.mapping.maps.length-1],a.push(new yc(t,void 0,void 0,a.length+c.length))),o--,t&&n.appendMap(t,o)}else l.maybeStep(e.step);return e.selection?(i=n?e.selection.map(n.slice(o)):e.selection,s=new gc(this.items.slice(0,r).append(c.reverse().concat(a)),this.eventCount-1),!1):void 0}),this.items.length,0),{remaining:s,transform:l,selection:i}}addTransform(e,t,n,o){let r=[],i=this.eventCount,s=this.items,l=!o&&s.length?s.get(s.length-1):null;for(let n=0;n<e.steps.length;n++){let a,c=e.steps[n].invert(e.docs[n]),d=new yc(e.mapping.maps[n],c,t);(a=l&&l.merge(d))&&(d=a,n?r.pop():s=s.slice(0,s.length-1)),r.push(d),t&&(i++,t=void 0),o||(l=d)}let a=i-n.depth;return a>vc&&(s=function(e,t){let n;return e.forEach(((e,o)=>{if(e.selection&&0==t--)return n=o,!1})),e.slice(n)}(s,a),i-=a),new gc(s.append(r),i)}remapping(e,t){let n=new me;return this.items.forEach(((t,o)=>{let r=null!=t.mirrorOffset&&o-t.mirrorOffset>=e?n.maps.length-t.mirrorOffset:void 0;n.appendMap(t.map,r)}),e,t),n}addMaps(e){return 0==this.eventCount?this:new gc(this.items.append(e.map((e=>new yc(e)))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let n=[],o=Math.max(0,this.items.length-t),r=e.mapping,i=e.steps.length,s=this.eventCount;this.items.forEach((e=>{e.selection&&s--}),o);let l=t;this.items.forEach((t=>{let o=r.getMirror(--l);if(null==o)return;i=Math.min(i,o);let a=r.maps[o];if(t.step){let i=e.steps[o].invert(e.docs[o]),c=t.selection&&t.selection.map(r.slice(l+1,o));c&&s++,n.push(new yc(a,i,c))}else n.push(new yc(a))}),o);let a=[];for(let e=t;e<i;e++)a.push(new yc(r.maps[e]));let c=this.items.slice(0,o).append(a).append(n),d=new gc(c,s);return d.emptyItemCount()>500&&(d=d.compress(this.items.length-n.length)),d}emptyItemCount(){let e=0;return this.items.forEach((t=>{t.step||e++})),e}compress(e=this.items.length){let t=this.remapping(0,e),n=t.maps.length,o=[],r=0;return this.items.forEach(((i,s)=>{if(s>=e)o.push(i),i.selection&&r++;else if(i.step){let e=i.step.map(t.slice(n)),s=e&&e.getMap();if(n--,s&&t.appendMap(s,n),e){let l=i.selection&&i.selection.map(t.slice(n));l&&r++;let a,c=new yc(s.invert(),e,l),d=o.length-1;(a=o.length&&o[d].merge(c))?o[d]=a:o.push(c)}}else i.map&&n--}),this.items.length,0),new gc(uc.from(o.reverse()),r)}}gc.empty=new gc(uc.empty,0);class yc{constructor(e,t,n,o){this.map=e,this.step=t,this.selection=n,this.mirrorOffset=o}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new yc(t.getMap().invert(),t,this.selection)}}}class wc{constructor(e,t,n,o,r){this.done=e,this.undone=t,this.prevRanges=n,this.prevTime=o,this.prevComposition=r}}const vc=20;function bc(e){let t=[];for(let n=e.length-1;n>=0&&0==t.length;n--)e[n].forEach(((e,n,o,r)=>t.push(o,r)));return t}function kc(e,t){if(!e)return null;let n=[];for(let o=0;o<e.length;o+=2){let r=t.map(e[o],1),i=t.map(e[o+1],-1);r<=i&&n.push(r,i)}return n}let xc=!1,Sc=null;function Cc(e){let t=e.plugins;if(Sc!=t){xc=!1,Sc=t;for(let e=0;e<t.length;e++)if(t[e].spec.historyPreserveItems){xc=!0;break}}return xc}const Mc=new xt("history"),Nc=new xt("closeHistory");function Oc(e,t){return(n,o)=>{let r=Mc.getState(n);if(!r||0==(e?r.undone:r.done).eventCount)return!1;if(o){let i=function(e,t,n){let o=Cc(t),r=Mc.get(t).spec.config,i=(n?e.undone:e.done).popEvent(t,o);if(!i)return null;let s=i.selection.resolve(i.transform.doc),l=(n?e.done:e.undone).addTransform(i.transform,t.selection.getBookmark(),r,o),a=new wc(n?l:i.remaining,n?i.remaining:l,null,0,-1);return i.transform.setSelection(s).setMeta(Mc,{redo:n,historyState:a})}(r,n,e);i&&o(t?i.scrollIntoView():i)}return!0}}const Ac=Oc(!1,!0),Tc=Oc(!0,!0),Dc=Oc(!1,!1),Ec=Oc(!0,!1);class Rc{constructor(e,t,n={}){var o;this.match=e,this.match=e,this.handler="string"==typeof t?(o=t,function(e,t,n,r){let i=o;if(t[1]){let e=t[0].lastIndexOf(t[1]);i+=t[0].slice(e+t[1].length);let o=(n+=e)-r;o>0&&(i=t[0].slice(e-o,e)+i,n=r)}return e.tr.insertText(i,n,r)}):t,this.undoable=!1!==n.undoable,this.inCode=n.inCode||!1}}function $c(e,t,n,o,r,i){if(e.composing)return!1;let s=e.state,l=s.doc.resolve(t),a=l.parent.textBetween(Math.max(0,l.parentOffset-500),l.parentOffset,null,"")+o;for(let c=0;c<r.length;c++){let d=r[c];if(l.parent.type.spec.code){if(!d.inCode)continue}else if("only"===d.inCode)continue;let h=d.match.exec(a),p=h&&d.handler(s,h,t-(h[0].length-o.length),n);if(p)return d.undoable&&p.setMeta(i,{transform:p,from:t,to:n,text:o}),e.dispatch(p),!0}return!1}const Ic=(e,t)=>{let n=e.plugins;for(let o=0;o<n.length;o++){let r,i=n[o];if(i.spec.isInputRules&&(r=i.getState(e))){if(t){let n=e.tr,o=r.transform;for(let e=o.steps.length-1;e>=0;e--)n.step(o.steps[e].invert(o.docs[e]));if(r.text){let t=n.doc.resolve(r.from).marks();n.replaceWith(r.from,r.to,e.schema.text(r.text,t))}else n.delete(r.from,r.to);t(n)}return!0}}return!1},zc=new Rc(/--$/,"—"),Bc=new Rc(/\.\.\.$/,"…"),Pc=new Rc(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,"“"),Vc=new Rc(/"$/,"”"),Fc=new Rc(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,"‘"),Lc=new Rc(/'$/,"’"),Hc=[Pc,Vc,Fc,Lc];const _c={mark:"strong",altMarks:["b"],altStyle:{name:"font-weight",value:/^(bold(er)?|[5-9]\d{2,})$/}},Wc={mark:"em",altMarks:["i"],altStyle:{name:"font-style",value:/^italic$/i}},qc={mark:"u",altStyle:{name:"text-decoration",value:/^underline$/i}},Jc="undefined"!=typeof navigator&&/Mac/.test(navigator.platform),jc=/style=['"]?[^'"]*?mso-list:\s*[a-zA-Z]+(\d+)\s[a-zA-Z]+(\d+)\s(\w+)/gi,Kc=e=>/^MsoListParagraph/.test(e.className),Xc=e=>e.textContent,Uc=(e,t)=>{const n=document.createElement(e);return n.style.listStyleType=t,n},Gc=e=>{let t=null;return/^\d/.test(e)||(t=(/^[a-z]/.test(e)?"lower-":"upper-")+(/^[ivxlcdm]/i.test(e)?"roman":"alpha")),t},Yc=(e,t)=>{let n=[];Array.from(e).forEach((e=>{if(e.nodeType!==Node.ELEMENT_NODE)return;const o=e;o.getAttribute("datalist")?(n.push(e),t.add(n)):Kc(o)&&n.length?n.push(e):(n=[],"DIV"===o.nodeName?Yc(o.children,t):"TABLE"===o.nodeName&&Array.from(o.querySelectorAll("td,th")).forEach((e=>{Yc(e.children,t)})))}))},Qc=e=>{const t=e.textContent,n=e=>e.replace(/^(?:&nbsp;|[\u00a0\n\r\s])+/,"");return/^[\u2022\u00b7\u00a7\u00d8oØüvn][\u00a0 ]+/.test(t)?{tag:"ul",style:(o=n(Xc(e)),/^[\u2022\u00b7\u00FC\u00D8\u002dv-]/.test(o)?null:/^o/.test(o)?"circle":"square")}:/^\s*\w+[\.\)][\u00a0 ]{2,}/.test(t)?{tag:"ol",style:Gc(n(Xc(e)))}:void 0;var o},Zc=e=>{let t,n=e.nodeName.toLowerCase();e.firstChild&&e.firstChild.nodeType===Node.COMMENT_NODE&&e.removeChild(e.firstChild),1===e.childNodes.length?t=e.firstChild.nodeType===Node.TEXT_NODE?Xc(e):e.firstChild.innerHTML.replace(/^\w+[\.\)](&nbsp;)+ /,""):(e.removeChild(e.firstChild),3===e.firstChild.nodeType&&/^[ivxlcdm]+\.$/i.test(e.firstChild.nodeValue)&&e.removeChild(e.firstChild),/^(&nbsp;|\s)+$/i.test(e.firstChild.innerHTML)&&e.removeChild(e.firstChild),t="p"!==n?"<"+n+">"+e.innerHTML+"</"+n+">":e.innerHTML),e.parentNode.removeChild(e);const o=document.createElement("li");return o.appendChild(mn(t)),o},ed=e=>{const t=mn((e=>e.replace(jc,((e,t,n)=>`datalist="${t}" datalevel="${n}" ${e}`)))(e)),n=new Set;return Yc(t.children,n),n.forEach((e=>(e=>{let t,n,o,r,i,s,l,a,c,d,h,p,u,f=-1,m={};for(a=0;a<e.length;a++){c=e[a],u={datalist:c.getAttribute("datalist"),datalevel:c.getAttribute("datalevel")};const g=u.datalist,y=Qc(c);if(d=y&&y.tag,!d){!t||i&&!Kc(c)||(c.style.marginLeft&&(c.style.marginLeft=""),c.style.marginLeft&&(c.style.margin=""),t.appendChild(c));continue}if(h=u.datalevel||parseFloat(c.style.marginLeft||0),!u.datalevel&&!c.style.marginLeft)continue;const w=d+g;m[h]||(m[h]={}),(!n||n<0)&&(n=h,o=g,l=e.filter((e=>e.getAttribute("datalist")===String(o))),r=l[l.length-1],s=Uc(d,y&&y.style),c.parentNode.insertBefore(s,c),f=h,m[h][w]=s),i=r===c,p=m[h][w],(h>f||!p)&&(p=Uc(d,y&&y.style),m[h][w]=p,t.appendChild(p)),t=Zc(c),p.appendChild(t),i?n=f=-1:f=h}})(e))),gn(t)},td=(e,t)=>e.replace(new RegExp("<\\/?("+t+")(?:\\s[^>]*?)?>","gi"),""),nd=e=>{e.ownerElement&&e.ownerElement.removeAttribute(e.name)};function od(e){const t=e.length,n=new Array(t/2);for(let o=0;o<t;o+=2)n[o]=String.fromCharCode(parseInt(e.substring(o,o+2),16));return btoa(n.join(""))}const rd=/<img\s[^>]*?src=(?:'|")file:\/[^'"]+(?:'|")[^>]*>/gi,id=/{\\pict[\s\S]+?\\bliptag-?\d+(\\blipupi-?\d+)?({\\\*\\blipuid\s?[\da-fA-F]+)?[\s}]*?/,sd=new RegExp("(?:("+id.source+"))([\\da-fA-F\\s]+)\\}","g"),ld=/[^\da-fA-F]/g,ad=/file:\/[^'"]+\.(jpg|png|gif)/i,cd=/\\(png|jpeg)blip\\/,dd="text/rtf",hd=(e,t,n,o,r)=>{let i,s,l,a,c,d,h=[];const p=[],{matchCase:u,matchWord:f,useRegExp:m}=t;let g=t.text;if(m&&(/^\\$/.test(g)||/[^\\]\\$/.test(g))&&(g=g.substring(0,g.length-1)),!g)return h;const y=u?"g":"gi",w=m?new RegExp(g,y):md(g,y);return e.nodesBetween(n,o,((t,u)=>{if(r(h))return!1;t.inlineContent&&u+t.content.size>=n&&(p.length=0,t.nodesBetween(0,t.content.size,((t,m,g,y)=>{if(r(h))return!1;const v=1+u+m;if(t.isText&&v+t.nodeSize>=n){if(c=t.text||"",d=g.childCount-1>=y+1&&g.child(y+1),p.push(n<=v?{text:c,start:v}:{text:c.slice(n-v),start:n}),d&&d.isText)return;for(s=p.map((e=>e.text)).join(""),i=w.exec(s);null!==i&&(l=p[0].start+i.index,a=l+i[0].length,n<=l&&o>=a&&fd(i,f)&&h.push(rt.create(e,l,a)),!r(h));)i=w.exec(s)}else p.length=0})))})),h},pd=(e,t)=>hd(e,t,0,e.content.size,(()=>!1)),ud=/^[\s0-9~`!@#$%\^&*\(\)_\-=+\\|\[\]{};:'"\?/.,<>]?$/,fd=(e,t)=>{if(t){if(!0===t){const t=e.input,n=t.charAt(e.index-1),o=t.charAt(e.index+e[0].length);return ud.test(n)&&ud.test(o)}return t(e)}return!0},md=(e,t)=>{const n=e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d").replace(/\s/g,"\\s");return new RegExp(n,t)};const gd=/\s+/g,yd=/text-align/,wd=(e,t)=>{for(const n in t)n&&nn(e,n,t[n])};class vd{constructor(e,t,n,o=!1){this.node=e,this.view=t,this.dom=document.createElement(n),wd(this.dom,e.attrs),this.contentDOM=o?void 0:this.dom}}class bd{constructor(e,t){this.mark=e,this.view=t,this.dom=document.createElement("span"),wd(this.dom,e.attrs),this.contentDOM=this.dom}}const kd=new xt("highlight");const xd={southeast:{x:1,y:1},east:{x:1,y:0},south:{x:0,y:1},north:{x:0,y:-1},west:{x:-1,y:0},southwest:{x:-1,y:1},northwest:{x:-1,y:-1},northeast:{x:1,y:-1}},Sd=Object.keys(xd),Cd=new xt("image-resize"),Md=(e,t,n)=>{e.style[t]=n+"px"},Nd=/[^\-]width:|[^\-]height:/,Od=/^.+$/;let Ad=class e{constructor(e,t,n,o){this.activeHandle=e,this.dragging=t,this.rect=n,this.nodePosition=o}apply(t){const n=t.getMeta(Cd);return n?new e(n.activeHandle,n.setDragging,n.rect,n.nodePosition):this}};const Td=(e,t,n)=>{const o=t.target.getAttribute(At);if(!o)return!1;const r=Cd.getState(e.state);t.preventDefault();const i=e.state.tr;function s(t){((e,t,n)=>{const o=Cd.getState(e.state),{rect:r,dragging:i,nodePosition:s,activeHandle:l}=o;if(!i||!r)return;const a=e.nodeDOM(s),c=xd[l],d=(t.clientX-i.startX)*c.x,h=(t.clientY-i.startY)*c.y;let p=c.x?d+a.width:r.width,u=c.y?h+a.height:r.height;if(n.lockRatio&&c.x&&c.y){const e=Math.min(p/a.width,u/a.height),n=a.width*e,o=a.height*e;i.startX=t.clientX-(p-n)*c.x,i.startY=t.clientY-(u-o)*c.y,p=n,u=o}else i.startX=c.x?t.clientX:i.startX,i.startY=c.y?t.clientY:i.startY;Md(a,"width",p),Md(a,"height",u),r.top=a.offsetTop,r.left=a.offsetLeft,r.width=a.offsetWidth,r.height=a.offsetHeight;const f=a.nextElementSibling;f.style.width=r.width+"px",f.style.height=r.height+"px",f.style.top=r.top+"px",f.style.left=r.left+"px"})(e,t,n)}return i.setMeta(Cd,{setDragging:{startX:t.clientX,startY:t.clientY},activeHandle:o,rect:r.rect,nodePosition:r.nodePosition}),i.setMeta("addToHistory",!1),e.dispatch(i),t.view.addEventListener("mouseup",(function t(n){n.view.removeEventListener("mouseup",t),n.view.removeEventListener("mousemove",s),(e=>{const{rect:t,dragging:n,nodePosition:o}=Cd.getState(e.state);if(n&&t){const n=e.state.selection;if(n instanceof st){const r=n.node.attrs,i=t.width,s=t.height;let l;if(Nd.test(r.style||"")){const e=Ht(r.style,{style:"width",value:Od,newValue:i+"px"}),{style:t}=Ht(e.style||"",{style:"height",value:Od,newValue:s+"px"});l={...r,style:t}}else l={...r,width:i,height:s};const a=n.node.type.createAndFill(l);if(a){const n=e.state.tr;n.replaceWith(o,o+1,a),n.setSelection(st.create(n.doc,o)),n.setMeta("commandName","image-resize"),n.setMeta("args",l),n.setMeta(Cd,{setDragging:null,activeHandle:null,rect:t,nodePosition:o}),e.dispatch(n)}}}})(e)})),t.view.addEventListener("mousemove",s),!0},Dd=new xt("caret-color");class Ed{constructor(e,t){this.node=e,this.view=t,this.dom=document.createElement("div"),this.dom.className="k-editor-resize-wrap-element",this.table=this.dom.appendChild(document.createElement("table")),e.attrs[Ct]&&this.renderColgroup(e.attrs[Ct]);const n=this.table.appendChild(document.createElement("tbody"));this.setAttributes(this.table,e.attrs),this.resizeHandles=Sd.map((e=>{const t=document.createElement("span");return t.className=Nt+" "+e,t.setAttribute(Ot,e),t})),this.contentDOM=n}update(e){if(e.type!==this.node.type)return!1;const t=this.node;return this.node=e,e.attrs[Mt]?this.resizeHandles.forEach((e=>{this.dom.appendChild(e)})):Array.from(this.dom.children).filter((e=>e.classList.contains(Nt))).forEach((e=>e.remove())),this.setAttributes(this.table,e.attrs),t.attrs[Ct]!==e.attrs[Ct]&&this.renderColgroup(e.attrs[Ct]),!0}ignoreMutation(e){return"attributes"===e.type&&(e.target===this.table||e.target.firstChild===this.table||this.colgroup&&this.colgroup.contains(e.target))}destroy(){this.node=void 0,this.view=void 0,this.table=void 0,this.colgroup=void 0,this.resizeHandles=void 0}renderColgroup(e){this.table&&this.table.firstChild&&"COLGROUP"===this.table.firstChild.nodeName&&this.table.removeChild(this.table.firstChild),e&&(this.colgroup=cc(e),this.table.insertBefore(this.colgroup,this.table.firstChild))}setAttributes(e,t){const n=[Ct,Mt];for(const o in t)o&&-1===n.indexOf(o)&&nn(e,o,t[o]);/%$/.test(e.style.width)?(this.dom.style.width=e.style.width,e.style.width=""):this.dom.style.width=""}}class Rd{constructor(e,t){this.node=e,this.view=t,this.dom=document.createElement("div"),this.setAttributes(this.dom,e.attrs),this.contentDOM=this.dom}update(e){return e.type===this.node.type&&(this.node=e,this.setAttributes(this.dom,e.attrs),!0)}ignoreMutation(e){return"attributes"===e.type&&"style"===e.attributeName}destroy(){this.node=void 0,this.view=void 0}setAttributes(e,t){for(const n in t)n&&nn(e,n,t[n]);if(e.setAttribute("table",""),/%/.test(e.style.width)){const t=this.node&&this.node.lastChild,n=(t?Zt(t.attrs.style):{}).width||"";n&&!/%/.test(n)&&(e.style.width="")}}}const $d=new xt("table-resize"),Id=new xt("table-column-resizing"),zd=new xt("table-row-resizing");function Bd(e,t){let n=!1;return n=n||e!==$d&&Boolean($d.get(t))&&$d.getState(t).dragging,n=n||e!==Id&&Boolean(Id.get(t))&&Id.getState(t).dragging,n=n||e!==zd&&Boolean(zd.get(t))&&zd.getState(t).dragging,n}function Pd(e,t){let n=!1;return n=n||e!==Id&&Boolean(Id.get(t))&&Id.getState(t).activeHandle>-1,n=n||e!==zd&&Boolean(zd.get(t))&&zd.getState(t).activeHandle>-1,n}function Vd(e){return e&&e.firstChild&&"TABLE"===e.firstChild.nodeName?e.firstChild:e}function Fd(e){for(;e&&"TD"!==e.nodeName&&"TH"!==e.nodeName;)e=e.classList.contains("ProseMirror")?null:e.parentNode;return e}function Ld(e){const t=function(e){const t=Array.from(e&&e.rows||[]),n=Array.from(t&&t[0]&&t[0].cells||[]).map((e=>e.colSpan)).reduce(((e,t)=>e+t),0),o=t.map((()=>new Array(n)));return t.forEach(((e,t)=>{let n=0;Array.from(e.cells).forEach((e=>{for(let r=0;r<e.colSpan;r++){for(let r=0;r<e.rowSpan;r++){const i=o[t+r].findIndex(((e,t)=>t>=n&&!e));o[t+r][i]=e}n++}}))})),o}(e.closest("table"));let n=null;for(let o=0;o<t.length;o++){if(t[o].forEach(((t,r)=>{e===t&&(n={rowIndex:o,cellIndex:r})})),n)break}return n||{rowIndex:-1,cellIndex:-1}}function Hd(e,t,n){const o=e.posAtCoords({left:t.clientX,top:t.clientY});if(!o)return-1;const r=e.state.doc.resolve(o.pos),i=jt(r,(e=>"table"===e.type.spec.tableRole));if(null===i)return-1;const s=r.start(i.depth),l=i.node,a=zl.get(l);return s+a.map[a.width*n.rowIndex+n.cellIndex]}function _d(){const e=new vt({key:Id,state:{init:()=>new Wd(-1,null),apply:(e,t)=>t.apply(e)},props:{attributes(e){if(Pd(Id,e))return null;return Id.getState(e).activeHandle>-1?{class:"resize-cursor"}:null},handleDOMEvents:{mousemove:(e,t)=>(Bd(Id,e.state)||function(e,t,n){const o=Id.getState(e.state);if(!o.dragging){const r=Fd(t.target);let i=-1;if(r){const o=Ld(r),{left:s,right:l}=r.getBoundingClientRect();Math.abs(t.clientX-s)<=n&&o.cellIndex>0?(o.cellIndex-=r.colSpan,i=Hd(e,t,o)):l-t.clientX>0&&l-t.clientX<=n&&(i=Hd(e,t,o))}i!==o.activeHandle&&qd(e,i)}}(e,t,5),!1),mouseleave:e=>(function(e){const t=Id.getState(e.state);t.activeHandle>-1&&!t.dragging&&qd(e,-1)}(e),!1),mousedown:(e,t)=>function(e,t,n){const o=Id.getState(e.state);if(-1===o.activeHandle||o.dragging)return!1;const r=e.state.doc.resolve(o.activeHandle),i=r.parent,s=r.index();let l=0;for(let e=0;e<=s;e++)l+=i.child(e).attrs.colspan;const a=r.node(r.depth-1),c=e.domAtPos(o.activeHandle),d=c.node.childNodes[c.offset].closest("table");let h,p;if(a.attrs[Ct]){h=d.firstChild.children[l-1],h.style.width||(h.style.width=h.offsetWidth+"px")}else{let e=0;for(let t=0;t<i.childCount;t++)e+=i.child(t).attrs.colspan;const t=document.createElement("colgroup"),n=new Array(e);for(let o=0;o<e;o++)n[o]=document.createElement("col"),t.appendChild(n[o]);d.insertBefore(t,d.firstChild),h=n[s],h.style.width=h.offsetWidth+"px",p={...a.attrs,[Ct]:"<colgroup>"+n.reduce(((e,t)=>e+t.outerHTML),"")+"</colgroup>"}}const u=parseFloat(h.style.width),f=e.state.tr.setMeta(Id,{setDragging:{startX:t.clientX,startWidth:u}});if(!d.style.width){const e=Array.from(h.parentNode.children).map((e=>e.style.width));if(e.every(Boolean)){const t=e.reduce(((e,t)=>e+parseFloat(t)),0);p=Wt(p||a.attrs,"width",t+"px")}}if(p){const e=r.posAtIndex(0,r.depth-1)-1;f.setNodeMarkup(e,null,p)}function m(t){t.view.removeEventListener("mouseup",m),t.view.removeEventListener("mousemove",g);const n=Id.getState(e.state);if(n.dragging){const t=e.state.tr;!function(e,t,n){const o=e.state.doc.resolve(n),r=o.node(-1),i=o.start(-1),s=o.posAtIndex(0,o.depth-1)-1,l=e.nodeDOM(i).closest("table");let a=r.attrs;if(r&&a[Ct]){const e=l.firstChild;a={...a,[Ct]:e.outerHTML}}const c=l.style.width;l&&c&&Zt(a.style).width!==c&&(a=Wt(a,"width",c));t.setNodeMarkup(s,null,a)}(e,t,n.activeHandle),e.dispatch(t.setMeta(Id,{setDragging:null}))}}function g(t){if(!t.which)return m(t);const o=Id.getState(e.state),r=function(e,t,n){const o=t.clientX-e.startX;return Math.max(n,e.startWidth+o)}(o.dragging,t,n);!function(e,t,n){const o=e.state.doc.resolve(t),r=o.node(-1),i=o.start(-1),s=zl.get(r).colCount(o.pos-i)+o.nodeAfter.attrs.colspan-1;let l=e.domAtPos(o.start(-1)).node;"TABLE"!==l.nodeName&&(l=l.closest("table"));const a=l,c=a.firstChild,d=Array.from(c.children);if(d[s].style.width=n+"px",a.style.width){const e=d.map((e=>e.style.width));if(e.every(Boolean)){const t=e.reduce(((e,t)=>e+parseFloat(t)),0);a.style.width=t+"px"}}}(e,o.activeHandle,r)}return e.dispatch(f),t.view.addEventListener("mouseup",m),t.view.addEventListener("mousemove",g),t.preventDefault(),!0}(e,t,25)},decorations(e){if(!Bd(Id,e)){const t=Id.getState(e);if(t.activeHandle>-1)return function(e,t){const n=[],o=e.doc.resolve(t),r=o.node(-1),i=zl.get(r),s=o.start(-1),l=[],a=t-s;let c=-1;for(let e=0;e<i.height;e++)l.push(i.map.slice(e*i.width,e*i.width+i.width)),-1===c&&(c=l[e].lastIndexOf(a));const d=[];return l.forEach((e=>{const t=e[c];e[c]!==e[c+1]&&d.push(t)})),d.forEach((e=>{const t=s+e+r.nodeAt(e).nodeSize-1,o=document.createElement("div");o.className="column-resize-handle",n.push(Hs.widget(t,o))})),qs.create(e.doc,n)}(e,t.activeHandle)}return qs.empty},nodeViews:{table_wrapper:(e,t)=>new Rd(e,t),table:(e,t)=>new Ed(e,t)}}});return e}let Wd=class e{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(t){let n;const o=t.getMeta(Id);if(o&&null!=o.setHandle)return new e(o.setHandle,null);if(o&&void 0!==o.setDragging)return new e(this.activeHandle,o.setDragging);if(this.activeHandle>-1&&t.docChanged){let o=t.mapping.map(this.activeHandle,-1);r=t.doc.resolve(o),Boolean("row"===r.parent.type.spec.tableRole&&r.nodeAfter)||(o=-1),n=new e(o,this.dragging)}var r;return n||this}};function qd(e,t){const n=e.state.tr;n.setMeta("addToHistory",!1),n.setMeta(Id,{setHandle:t}),e.dispatch(n)}const Jd={southeast:!0,southwest:!0,northwest:!0,northeast:!0},jd={east:!0,west:!0,...Jd},Kd={south:!0,north:!0,...Jd};let Xd=class e{constructor(e,t,n){this.activeHandle=e,this.dragging=t,this.nodePosition=n}apply(t){const n=t.getMeta($d);if(n){return new e(n.activeHandle,n.setDragging,n.nodePosition)}return this}};const Ud=e=>{const t=Array.from(e.firstChild.children).map((e=>e.offsetWidth)),n=Array.from(e.rows).map((e=>e.offsetHeight)),o=t.reduce(((e,t)=>e+t),0),r=n.reduce(((e,t)=>e+t),0),i=e.offsetHeight;return{width:o,height:r,colsWidth:t,rowsHeight:n,offsetWidth:e.offsetWidth,offsetHeight:i}},Gd=e=>{const{dragging:t,nodePosition:n,activeHandle:o}=$d.getState(e.state);if(t){const t=e.state.doc.nodeAt(n),r=Vd(e.nodeDOM(n)),i=Ud(r);if(t){const s=i.offsetWidth+"px",l=i.offsetHeight+"px",a=e.state.tr;let c=t.attrs;const d=Zt(c.style);if(jd[o]&&r.style.width&&d.width!==s&&(c=Wt(c,"width",s)),Kd[o]&&r.style.height&&d.height!==l&&(c=Wt(c,"height",l)),c=((e,t,n,o)=>{const r=e.state.doc.nodeAt(n),i=Vd(e.nodeDOM(n)),s=(i.ownerDocument&&i.ownerDocument.defaultView||window).getComputedStyle,l=Array.from(i.rows);r.forEach(((e,o,r)=>{const i=Zt(e.attrs.style).height;i&&!/px$/.test(i)&&t.setNodeMarkup(n+o+1,null,Wt(e.attrs,"height",s(l[r]).height))}));const a=i.firstChild,c=Array.from(a&&a.children||[]);let d=!1;c.forEach(((e,t)=>{e.style.width&&!/px$/.test(e.style.width)&&(e.style.width=s(c[t]).width,d=!0)}));const h={...o};return d&&(h[Ct]=a.outerHTML),h})(e,a,n,c),a.setNodeMarkup(n,null,c),a.setMeta("commandName","node-resize"),a.setMeta("args",c),a.setMeta($d,{setDragging:null,activeHandle:null,nodePosition:n}),!/%/.test(Zt(c.style).width||"")){const e=a.doc.resolve(n),t=jt(e,(e=>"table_wrapper"===e.type.name));if(t&&/%/.test(Zt(t.node.attrs.style).width||"")){const n=Wt(t.node.attrs,"width",""),o=e.start(t.depth)-1;a.setNodeMarkup(o,null,n)}}e.dispatch(a)}}},Yd=(e,t)=>{const n=t.target.getAttribute(Ot);if(!n)return!1;const o=$d.getState(e.state);t.preventDefault();const r=e.state.tr;r.setMeta($d,{setDragging:{startX:t.clientX,startY:t.clientY},activeHandle:n,nodePosition:o.nodePosition}),r.setMeta("addToHistory",!1),((e,t,n)=>{const o=e.state.doc.nodeAt(n),r=Vd(e.nodeDOM(n)),{width:i,height:s,colsWidth:l,rowsHeight:a,offsetWidth:c,offsetHeight:d}=Ud(r),h=r.firstChild,p=Array.from(h&&h.children||[]);let u=!1;p.forEach(((e,t)=>{e.style.width&&!/%$/.test(e.style.width)&&(e.style.width=100*l[t]/i+"%",u=!0)}));let f=!1;o.forEach(((e,o,r)=>{const i=Zt(e.attrs.style).height;i&&!/%$/.test(i)&&(t.setNodeMarkup(n+o+1,null,Wt(e.attrs,"height",100*a[r]/s+"%")),f=!0)}));let m=o.attrs;Zt(m.style).width!==c+"px"&&(m=Wt(m,"width",c+"px")),u&&(m[Ct]=h.outerHTML),f&&(m=Wt(m,"height",d+"px")),(u||f)&&t.setNodeMarkup(n,null,m)})(e,r,o.nodePosition),e.dispatch(r);const i=t.view||window;function s(t){((e,t)=>{var n;const o=$d.getState(e.state),{dragging:r,nodePosition:i,activeHandle:s}=o;if(i<0||!r)return;const l=Vd(e.nodeDOM(i)),a=l.getBoundingClientRect(),c=xd[s],d=(t.clientX-r.startX)*c.x,h=(t.clientY-r.startY)*c.y,p=(l.ownerDocument&&l.ownerDocument.defaultView||window).getComputedStyle(l),u=/px/.test(p.width)?parseFloat(p.width):l.offsetWidth,f=/px/.test(p.height)?parseFloat(p.height):l.offsetHeight,m=c.x?d+u:a.width,g=c.y?h+f:a.height;if(r.startX=c.x?t.clientX:r.startX,r.startY=c.y?t.clientY:r.startY,jd[s]&&(l.style.width=m+"px"),Kd[s]&&(l.style.height=g+"px"),/px/.test(l.style.width)){const e=null===(n=l.parentNode)||void 0===n?void 0:n.parentNode;e instanceof HTMLDivElement&&e.matches("div[table]")&&/%/.test(e.style.width)&&(e.style.width="")}})(e,t)}return i.addEventListener("mouseup",(function t(){i.removeEventListener("mouseup",t),i.removeEventListener("mousemove",s),Gd(e)})),i.addEventListener("mousemove",s),!0},Qd=(e={node:"table"})=>new vt({key:$d,view:()=>({selectedNode(e,t){const n=e.selection;if(n instanceof st&&t===n.node.type&&n instanceof st)return{node:n.node,pos:n.from};const o=jt(n.$from,(e=>e.type===t)),r=o&&o.node;if(r){return{node:r,pos:n.$from.start(o.depth)-1}}return null},update(t,n){const o=t.state,r=o.schema.nodes[e.node],i=this.selectedNode(o,r),s=this.selectedNode(n,r);if((i||!s||n.doc.eq(t.state.doc))&&(i||s)){const e=o.tr;if(e.setMeta("addToHistory",!1),i&&s&&i.pos!==s.pos){e.setMeta($d,{nodePosition:i.pos});const n=e.doc.nodeAt(s.pos);n&&n.type.name===r.name&&e.setNodeMarkup(s.pos,r,{...s.node.attrs,[Mt]:!1}),e.setNodeMarkup(i.pos,r,{...i.node.attrs,[Mt]:!0}),t.dispatch(e)}else i&&s&&i.pos===s.pos&&!i.node.attrs[Mt]&&!o.selection.eq(n.selection)?(e.setMeta($d,{nodePosition:i.pos}),t.dispatch(e.setNodeMarkup(i.pos,r,{...i.node.attrs,[Mt]:!0}))):i&&!s?(e.setMeta($d,{nodePosition:i.pos}),t.dispatch(e.setNodeMarkup(i.pos,r,{...i.node.attrs,[Mt]:!0}))):!i&&s&&(e.setMeta($d,{nodePosition:-1}),t.dispatch(e.setNodeMarkup(s.pos,r,{...s.node.attrs,[Mt]:!1})))}}}),state:{init:()=>new Xd("",null,-1),apply:(e,t)=>t.apply(e)},props:{handleDOMEvents:{mousedown:(e,t)=>Yd(e,t)}}});class Zd{ignoreMutation(e){return"attributes"===e.type&&"style"===e.attributeName&&"TR"===e.target.nodeName}}function eh(){const e=new vt({key:zd,state:{init(e,t){return this.spec.props.nodeViews[Ll(t.schema).row.name]=()=>new Zd,new th(-1,null)},apply:(e,t)=>t.apply(e)},props:{attributes(e){if(Pd(zd,e))return null;return zd.getState(e).activeHandle>-1?{class:"resize-cursor-vertical"}:null},handleDOMEvents:{mousemove:(e,t)=>(Bd(zd,e.state)||function(e,t,n){const o=zd.getState(e.state);if(!o.dragging){let r=Fd(t.target),i=-1;if(r){const o=Ld(r),{top:s,bottom:l}=r.getBoundingClientRect();Math.abs(t.clientY-s)<=n&&o.rowIndex>0?(o.rowIndex-=r.rowSpan,i=Hd(e,t,o)):l-t.clientY>0&&l-t.clientY<=n&&(i=Hd(e,t,o))}i!==o.activeHandle&&nh(e,i)}}(e,t,5),!1),mouseleave:e=>(function(e){const t=zd.getState(e.state);t.activeHandle>-1&&!t.dragging&&nh(e,-1)}(e),!1),mousedown:(e,t)=>function(e,t){const n=zd.getState(e.state);if(-1===n.activeHandle||n.dragging)return!1;const o=e.state.doc,r=o.resolve(n.activeHandle),i=r.parent,s=r.node(-1),l=Zt(i.attrs.style).height,a=Zt(s.attrs.style).height;let c=l?parseFloat(l):0;if(!l){c=e.nodeDOM(n.activeHandle).offsetHeight}function d(t){t.view.removeEventListener("mouseup",d),t.view.removeEventListener("mousemove",h);const n=zd.getState(e.state);if(n.dragging){const t=e.state.tr.setMeta(zd,{setDragging:null});!function(e,t,n){const o=e.state.doc,r=o.resolve(n),i=r.parent,s=r.posAtIndex(0)-1,l=e.nodeDOM(s),a=l.ownerDocument&&l.ownerDocument.defaultView||window;l.style.height=a.getComputedStyle(l).height,t.setNodeMarkup(s,null,Wt(i.attrs,"height",l.style.height));const c=l&&l.closest("table"),d=c&&c.style.height;if(d){const e=o.resolve(s),n=e.start(e.depth)-1;t.setNodeMarkup(n,null,Wt(e.parent.attrs,"height",d))}}(e,t,n.activeHandle),e.dispatch(t)}}function h(t){if(!t.which)return d(t);const n=zd.getState(e.state),o=function(e,t){const n=t.clientY-e.startY;return e.startHeight.rowHeight+n}(n.dragging,t),r=t.clientY-n.dragging.startY;!function(e,t,n,o,r){const i=e.nodeDOM(t),s=i&&i.parentNode;if(s){s.style.height=n+"px";const e=s.ownerDocument&&s.ownerDocument.defaultView||window;s.style.height=e.getComputedStyle(s).height;const t=s.closest("table"),i=parseFloat(r)+o+"px",l=t&&t.style.height;l&&l!==i&&(t.style.height=parseFloat(r)+o+"px",t.style.height=e.getComputedStyle(t).height)}}(e,n.activeHandle,o,r,a)}return e.dispatch(e.state.tr.setMeta(zd,{setDragging:{startY:t.clientY,startHeight:{rowHeight:c,tableHeight:a}}})),t.view.addEventListener("mouseup",d),t.view.addEventListener("mousemove",h),t.preventDefault(),!0}(e,t)},decorations(e){if(Bd(zd,e))return qs.empty;const t=zd.getState(e);return t.activeHandle>-1?function(e,t){const n=[];if("number"!=typeof t)return qs.empty;const o=e.doc.resolve(t),r=o.node(-1),i=zl.get(r),s=o.start(-1),l=[],a=t-s;let c=-1;for(let e=0;e<i.height;e++)l.push(i.map.slice(e*i.width,e*i.width+i.width)),-1!==l[e].indexOf(a)&&(c=e);const d=[];return l[c].forEach(((e,t)=>{l[c+1]&&e===l[c+1][t]||d.push(e)})),d.forEach((e=>{const t=r.nodeAt(e),o=s+e+(t?t.nodeSize:0)-1,i=document.createElement("div");i.className="row-resize-handle",n.push(Hs.widget(o,i))})),qs.create(e.doc,n)}(e,t.activeHandle):void 0},nodeViews:{}}});return e}class th{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(e){let t,n=e.getMeta(zd);if(n&&null!=n.setHandle)return new th(n.setHandle,null);if(n&&void 0!==n.setDragging)return new th(this.activeHandle,n.setDragging);if(this.activeHandle>-1){let n=e.mapping.map(this.activeHandle,-1);"row"===(o=e.doc.resolve(n)).parent.type.spec.tableRole&&o.nodeAfter||(n=null),t=new th(n,this.dragging)}var o;return t||this}}function nh(e,t){const n=e.state.tr;n.setMeta("addToHistory",!1),n.setMeta(zd,{setHandle:t}),e.dispatch(n)}const oh=(e,t,n,o,r)=>{const i=r.resolve(e),s=r.resolve(t),l=o.type.name;let a,c;return!i.nodeBefore&&(a=i.node(i.depth),c=i.node(i.depth-1),a&&c&&c.firstChild===a&&c.type.name===l)?n+o.content.size<=t:!s.nodeAfter&&(a=s.node(s.depth),c=s.node(s.depth-1),a&&c&&c.lastChild===a&&c.type.name===l)?e<=n:e<=n&&n+o.content.size<=t},rh={listItem:"list_item",resetValues:{"font-size":"","font-family":"",color:""}};class ih{constructor(e,t){var n;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=null!==(n=t.width)&&void 0!==n?n:1,this.color=!1===t.color?void 0:t.color||"black",this.class=t.class,this.handlers=["dragover","dragend","drop","dragleave"].map((t=>{let n=e=>{this[t](e)};return e.dom.addEventListener(t,n),{name:t,handler:n}}))}destroy(){this.handlers.forEach((({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t)))}update(e,t){null!=this.cursorPos&&t.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,null==e?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e,t=this.editorView.state.doc.resolve(this.cursorPos),n=!t.parent.inlineContent;if(n){let n=t.nodeBefore,o=t.nodeAfter;if(n||o){let t=this.editorView.nodeDOM(this.cursorPos-(n?n.nodeSize:0));if(t){let r=t.getBoundingClientRect(),i=n?r.bottom:r.top;n&&o&&(i=(i+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2),e={left:r.left,right:r.right,top:i-this.width/2,bottom:i+this.width/2}}}}if(!e){let t=this.editorView.coordsAtPos(this.cursorPos);e={left:t.left-this.width/2,right:t.left+this.width/2,top:t.top,bottom:t.bottom}}let o,r,i=this.editorView.dom.offsetParent;if(this.element||(this.element=i.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",n),this.element.classList.toggle("prosemirror-dropcursor-inline",!n),!i||i==document.body&&"static"==getComputedStyle(i).position)o=-pageXOffset,r=-pageYOffset;else{let e=i.getBoundingClientRect();o=e.left-i.scrollLeft,r=e.top-i.scrollTop}this.element.style.left=e.left-o+"px",this.element.style.top=e.top-r+"px",this.element.style.width=e.right-e.left+"px",this.element.style.height=e.bottom-e.top+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout((()=>this.setCursor(null)),e)}dragover(e){if(!this.editorView.editable)return;let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),n=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),o=n&&n.type.spec.disableDropCursor,r="function"==typeof o?o(this.editorView,t,e):o;if(t&&!r){let e=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let t=Fe(this.editorView.state.doc,e,this.editorView.dragging.slice);null!=t&&(e=t)}this.setCursor(e),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){e.target!=this.editorView.dom&&this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}class sh extends et{constructor(e){super(e,e)}map(e,t){let n=e.resolve(t.map(this.head));return sh.valid(n)?new sh(n):et.near(n)}content(){return d.empty}eq(e){return e instanceof sh&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,t){if("number"!=typeof t.pos)throw new RangeError("Invalid input for GapCursor.fromJSON");return new sh(e.resolve(t.pos))}getBookmark(){return new lh(this.anchor)}static valid(e){let t=e.parent;if(t.isTextblock||!function(e){for(let t=e.depth;t>=0;t--){let n=e.index(t),o=e.node(t);if(0!=n)for(let e=o.child(n-1);;e=e.lastChild){if(0==e.childCount&&!e.inlineContent||e.isAtom||e.type.spec.isolating)return!0;if(e.inlineContent)return!1}else if(o.type.spec.isolating)return!0}return!0}(e)||!function(e){for(let t=e.depth;t>=0;t--){let n=e.indexAfter(t),o=e.node(t);if(n!=o.childCount)for(let e=o.child(n);;e=e.firstChild){if(0==e.childCount&&!e.inlineContent||e.isAtom||e.type.spec.isolating)return!0;if(e.inlineContent)return!1}else if(o.type.spec.isolating)return!0}return!0}(e))return!1;let n=t.type.spec.allowGapCursor;if(null!=n)return n;let o=t.contentMatchAt(e.index()).defaultType;return o&&o.isTextblock}static findGapCursorFrom(e,t,n=!1){e:for(;;){if(!n&&sh.valid(e))return e;let o=e.pos,r=null;for(let n=e.depth;;n--){let i=e.node(n);if(t>0?e.indexAfter(n)<i.childCount:e.index(n)>0){r=i.child(t>0?e.indexAfter(n):e.index(n)-1);break}if(0==n)return null;o+=t;let s=e.doc.resolve(o);if(sh.valid(s))return s}for(;;){let i=t>0?r.firstChild:r.lastChild;if(!i){if(r.isAtom&&!r.isText&&!st.isSelectable(r)){e=e.doc.resolve(o+r.nodeSize*t),n=!1;continue e}break}r=i,o+=t;let s=e.doc.resolve(o);if(sh.valid(s))return s}return null}}}sh.prototype.visible=!1,sh.findFrom=sh.findGapCursorFrom,et.jsonID("gapcursor",sh);class lh{constructor(e){this.pos=e}map(e){return new lh(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return sh.valid(t)?new sh(t):et.near(t)}}const ah=Rl({ArrowLeft:ch("horiz",-1),ArrowRight:ch("horiz",1),ArrowUp:ch("vert",-1),ArrowDown:ch("vert",1)});function ch(e,t){const n="vert"==e?t>0?"down":"up":t>0?"right":"left";return function(e,o,r){let i=e.selection,s=t>0?i.$to:i.$from,l=i.empty;if(i instanceof rt){if(!r.endOfTextblock(n)||0==s.depth)return!1;l=!1,s=e.doc.resolve(t>0?s.after():s.before())}let a=sh.findGapCursorFrom(s,t,l);return!!a&&(o&&o(e.tr.setSelection(new sh(a))),!0)}}function dh(e,t,n){if(!e||!e.editable)return!1;let o=e.state.doc.resolve(t);if(!sh.valid(o))return!1;let r=e.posAtCoords({left:n.clientX,top:n.clientY});return!(r&&r.inside>-1&&st.isSelectable(e.state.doc.nodeAt(r.inside)))&&(e.dispatch(e.state.tr.setSelection(new sh(o))),!0)}function hh(e,t){if("insertCompositionText"!=t.inputType||!(e.state.selection instanceof sh))return!1;let{$from:n}=e.state.selection,o=n.parent.contentMatchAt(n.index()).findWrapping(e.state.schema.nodes.text);if(!o)return!1;let i=r.empty;for(let e=o.length-1;e>=0;e--)i=r.from(o[e].createAndFill(null,i));let s=e.state.tr.replace(n.pos,n.pos,new d(i,0,0));return s.setSelection(rt.near(s.doc.resolve(n.pos+1))),e.dispatch(s),!1}function ph(e){if(!(e.selection instanceof sh))return null;let t=document.createElement("div");return t.className="ProseMirror-gapcursor",qs.create(e.doc,[Hs.widget(e.selection.head,t,{key:"gapcursor"})])}const uh=/^table$/,fh=/^table_row$/,mh=/^table_cell|table_header$/,gh=(e,t)=>{const n=e.$head;for(let e=n.depth;e>0;e--){const o=n.node(e);if(t.test(o.type.name))return{pos:n.before(e),node:o}}return null},yh=(e,t)=>{if(!e)return-1;const n=zl.get(e.node),o=gh(t,mh),r=n.map.indexOf(o.pos-e.pos-1);let i=-1;return-1!==r&&(i=r%n.width),i},wh=(e,t,n)=>{const o=yh(t,e.selection),r=cc(t.node.attrs[Ct]);r.insertBefore(r.ownerDocument.createElement("col"),r.children[o+n]),e.setNodeMarkup(t.pos,null,{...t.node.attrs,[Ct]:r.outerHTML})};e.AddMarkStep=be,e.AddNodeMarkStep=xe,e.AllSelection=at,e.AttrStep=Ge,e.CellSelection=Ql,e.ContentMatch=E,e.DOMParser=U,e.DOMSerializer=ie,e.Decoration=Hs,e.DecorationSet=qs,e.DocAttrStep=Ye,e.EditorState=yt,e.EditorView=class{constructor(e,t){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new ps,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(xl),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):"function"==typeof e?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=bl(this),vl(this),this.nodeViews=kl(this),this.docView=ci(this.state.doc,wl(this),el(this),this.dom,this),this.domObserver=new rl(this,((e,t,n,o)=>hl(this,e,t,n,o))),this.domObserver.start(),function(e){for(let t in cs){let n=cs[t];e.dom.addEventListener(t,e.input.eventHandlers[t]=t=>{!gs(e,t)||ms(e,t)||!e.editable&&t.type in ds||n(e,t)},hs[t]?{passive:!0}:void 0)}Ar&&e.dom.addEventListener("input",(()=>null)),fs(e)}(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let t in e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&fs(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(xl),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let e in this._props)t[e]=this._props[e];t.state=this.state;for(let n in e)t[n]=e[n];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var n;let o=this.state,r=!1,i=!1;e.storedMarks&&this.composing&&(Ts(this),i=!0),this.state=e;let s=o.plugins!=e.plugins||this._props.plugins!=t.plugins;if(s||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let e=kl(this);(function(e,t){let n=0,o=0;for(let o in e){if(e[o]!=t[o])return!0;n++}for(let e in t)o++;return n!=o})(e,this.nodeViews)&&(this.nodeViews=e,r=!0)}(s||t.handleDOMEvents!=this._props.handleDOMEvents)&&fs(this),this.editable=bl(this),vl(this);let l=el(this),a=wl(this),c=o.plugins==e.plugins||o.doc.eq(e.doc)?e.scrollToSelection>o.scrollToSelection?"to selection":"preserve":"reset",d=r||!this.docView.matchesNode(e.doc,a,l);!d&&e.selection.eq(o.selection)||(i=!0);let h="preserve"==c&&i&&null==this.dom.style.overflowAnchor&&function(e){let t,n,o=e.dom.getBoundingClientRect(),r=Math.max(0,o.top);for(let i=(o.left+o.right)/2,s=r+1;s<Math.min(innerHeight,o.bottom);s+=5){let o=e.root.elementFromPoint(i,s);if(!o||o==e.dom||!e.dom.contains(o))continue;let l=o.getBoundingClientRect();if(l.top>=r-20){t=o,n=l.top;break}}return{refDOM:t,refTop:n,stack:Fr(e.dom)}}(this);if(i){this.domObserver.stop();let t=d&&(xr||Nr)&&!this.composing&&!o.selection.empty&&!e.selection.empty&&function(e,t){let n=Math.min(e.$anchor.sharedDepth(e.head),t.$anchor.sharedDepth(t.head));return e.$anchor.start(n)!=t.$anchor.start(n)}(o.selection,e.selection);if(d){let n=Nr?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=Ds(this)),!r&&this.docView.update(e.doc,a,l,this)||(this.docView.updateOuterDeco(a),this.docView.destroy(),this.docView=ci(e.doc,a,l,this.dom,this)),n&&!this.trackWrites&&(t=!0)}t||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&function(e){let t=e.docView.domFromPos(e.state.selection.anchor,0),n=e.domSelectionRange();return cr(t.node,t.offset,n.anchorNode,n.anchorOffset)}(this))?Oi(this,t):(Ri(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(o),(null===(n=this.dragging)||void 0===n?void 0:n.node)&&!o.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,o),"reset"==c?this.dom.scrollTop=0:"to selection"==c?this.scrollToSelection():h&&function({refDOM:e,refTop:t,stack:n}){let o=e?e.getBoundingClientRect().top:0;Lr(n,0==o?0:o-t)}(h)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(e&&this.dom.contains(1==e.nodeType?e:e.parentNode))if(this.someProp("handleScrollToSelection",(e=>e(this))));else if(this.state.selection instanceof st){let t=this.docView.domAfterPos(this.state.selection.from);1==t.nodeType&&Vr(this,t.getBoundingClientRect(),e)}else Vr(this,this.coordsAtPos(this.state.selection.head,1),e);else;}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(e&&e.plugins==this.state.plugins&&this.directPlugins==this.prevDirectPlugins)for(let t=0;t<this.pluginViews.length;t++){let n=this.pluginViews[t];n.update&&n.update(this,e)}else{this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let e=0;e<this.directPlugins.length;e++){let t=this.directPlugins[e];t.spec.view&&this.pluginViews.push(t.spec.view(this))}for(let e=0;e<this.state.plugins.length;e++){let t=this.state.plugins[e];t.spec.view&&this.pluginViews.push(t.spec.view(this))}}}updateDraggedNode(e,t){let n=e.node,o=-1;if(this.state.doc.nodeAt(n.from)==n.node)o=n.from;else{let e=n.from+(this.state.doc.content.size-t.doc.content.size);(e>0&&this.state.doc.nodeAt(e))==n.node&&(o=e)}this.dragging=new zs(e.slice,e.move,o<0?void 0:st.create(this.state.doc,o))}someProp(e,t){let n,o=this._props&&this._props[e];if(null!=o&&(n=t?t(o):o))return n;for(let o=0;o<this.directPlugins.length;o++){let r=this.directPlugins[o].props[e];if(null!=r&&(n=t?t(r):r))return n}let r=this.state.plugins;if(r)for(let o=0;o<r.length;o++){let i=r[o].props[e];if(null!=i&&(n=t?t(i):i))return n}}hasFocus(){if(xr){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if("false"==e.contentEditable)return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&function(e){if(e.setActive)return e.setActive();if(Hr)return e.focus(Hr);let t=Fr(e);e.focus(null==Hr?{get preventScroll(){return Hr={preventScroll:!0},!0}}:void 0),Hr||(Hr=!1,Lr(t,0))}(this.dom),Oi(this),this.domObserver.start()}get root(){let e=this._root;if(null==e)for(let e=this.dom.parentNode;e;e=e.parentNode)if(9==e.nodeType||11==e.nodeType&&e.host)return e.getSelection||(Object.getPrototypeOf(e).getSelection=()=>e.ownerDocument.getSelection()),this._root=e;return e||document}updateRoot(){this._root=null}posAtCoords(e){return Jr(this,e)}coordsAtPos(e,t=1){return Ur(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,n=-1){let o=this.docView.posFromDOM(e,t,n);if(null==o)throw new RangeError("DOM position not inside the editor");return o}endOfTextblock(e,t){return oi(this,t||this.state,e)}pasteHTML(e,t){return $s(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return $s(this,e,null,!0,t||new ClipboardEvent("paste"))}destroy(){this.docView&&(!function(e){e.domObserver.stop();for(let t in e.input.eventHandlers)e.dom.removeEventListener(t,e.input.eventHandlers[t]);clearTimeout(e.input.composingTimeout),clearTimeout(e.input.lastIOSEnterFallbackTimeout)}(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],el(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,lr=null)}get isDestroyed(){return null==this.docView}dispatchEvent(e){return function(e,t){ms(e,t)||!cs[t.type]||!e.editable&&t.type in ds||cs[t.type](e,t)}(this,e)}dispatch(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))}domSelectionRange(){let e=this.domSelection();return e?Ar&&11===this.root.nodeType&&function(e){let t=e.activeElement;for(;t&&t.shadowRoot;)t=t.shadowRoot.activeElement;return t}(this.dom.ownerDocument)==this.dom&&function(e,t){if(t.getComposedRanges){let n=t.getComposedRanges(e.root)[0];if(n)return ll(e,n)}let n;function o(e){e.preventDefault(),e.stopImmediatePropagation(),n=e.getTargetRanges()[0]}return e.dom.addEventListener("beforeinput",o,!0),document.execCommand("indent"),e.dom.removeEventListener("beforeinput",o,!0),n?ll(e,n):null}(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}},e.Fragment=r,e.GapCursor=sh,e.InputRule=Rc,e.MapResult=ue,e.Mapping=me,e.Mark=a,e.MarkType=j,e.Node=A,e.NodeRange=N,e.NodeSelection=st,e.NodeType=q,e.Plugin=vt,e.PluginKey=xt,e.RemoveMarkStep=ke,e.RemoveNodeMarkStep=Se,e.ReplaceAroundStep=Me,e.ReplaceError=c,e.ReplaceStep=Ce,e.ResolvedPos=x,e.Schema=K,e.Selection=et,e.SelectionRange=tt,e.Slice=d,e.Step=ye,e.StepMap=fe,e.StepResult=we,e.TableMap=zl,e.TextSelection=rt,e.Transaction=pt,e.Transform=Qe,e.__endComposition=yl,e.__parseFromClipboard=gl,e.__serializeForClipboard=ml,e.activeNode=e=>({tag:_n(e)||""}),e.addColSpan=Gl,e.addColumn=ia,e.addColumnAfter=(e,t)=>la(e,t&&(e=>{const n=gh(e.selection,uh);return n.node.attrs[Ct]?(wh(e,n,1),t(e)):t(e)})),e.addColumnBefore=(e,t)=>sa(e,t&&(e=>{const n=gh(e.selection,uh);return n.node.attrs[Ct]?(wh(e,n,-1),t(e)):t(e)})),e.addListNodes=function(e,t,n){return e.append({ordered_list:Un(jn,{content:"list_item+",group:n}),bullet_list:Un(Kn,{content:"list_item+",group:n}),list_item:Un(Xn,{content:t})})},e.addRow=ha,e.addRowAfter=(e,t)=>ua(e,t&&(e=>{const n=gh(e.selection,fh);if(n&&n.node.attrs[St]){const t=n.pos+n.node.nodeSize;e.setNodeMarkup(t,void 0,{[St]:n.node.attrs[St]})}return t(e)})),e.addRowBefore=(e,t)=>{const n=t&&(e=>{const n=gh(e.selection,fh),o=gh(e.selection,uh);if(n&&o&&n.node.attrs[St]){let t=0;for(let e=0;e<o.node.nodeSize;e++)if(o.node.child(e).eq(n.node)){t=e;break}const r=o.node.child(t-1),i=n.pos-r.nodeSize;e.setNodeMarkup(i,void 0,{[St]:n.node.attrs[St]})}return t(e)});return pa(e,n)},e.alignBlocks=(e,t)=>(n,o)=>{const r=Pn(n),i=n.tr;i.setMeta("commandName",t),r.forEach((t=>{if(t.type.isTextblock){const n=e.find((e=>e.node===t.type.name));if(n){const e=Ln(t,n.style);Bn(i,t,t.type,e)}}}));const s=i.docChanged;return s&&o(i.scrollIntoView()),s},e.alignCenterRules=nr,e.alignJustifyRules=or,e.alignLeftRules=er,e.alignRemoveRules=rr,e.alignRightRules=tr,e.applyInlineStyle=(e,t)=>(n,o)=>{const r=n.schema.marks.style,i={style:e.style,value:/^.+$/,newValue:e.value},s=n.tr;t&&s.setMeta("commandName",t),s.setMeta("args",e);const{empty:l,$cursor:a,ranges:c}=n.selection;if(l&&!a||!r||!Cn(n.doc,c,r))return!1;if(a){const e=n.storedMarks||a.marks(),t=r.isInSet(e)?e.find((e=>"style"===e.type.name)):null,l={style:null};if(t&&t.attrs.style){const e=Ht(t.attrs.style,i);e.changed&&e.style&&(l.style=e.style)}else i.newValue&&(l.style=`${[i.style]}: ${i.newValue};`);const c=t?{...t.attrs,...l}:l;return Object.keys(c).some((e=>null!==c[e]))?o(s.addStoredMark(r.create(c))):o(s.removeStoredMark(r)),!0}return $n(r,i)(n,o,s)},e.applyLink=({mark:e,attrs:t},n="link")=>(o,r)=>{const i=o.schema.marks,s=o.tr;n&&(s.setMeta("commandName",n),s.setMeta("args",t));let l=!1;const a=()=>l=!0;if(((e,t)=>{const n=Dn(e,t);return 1===n.length&&n[0]?n[0]:null})(o,i[e]))((e,t)=>(n,o)=>{const{$cursor:r,from:i,to:s}=n.selection,l=n.schema.marks[e.mark];if(r){const n=r.parent,i=r.index(),s=n.child(i).marks.find((e=>e.type===l)),a=n.childCount;let c,d,h=r.pos-r.textOffset,p=n.child(i).nodeSize;for(c=i-1;c>=0&&s.isInSet(n.child(c).marks);)d=n.child(c).nodeSize,p+=d,h-=d,c-=1;for(c=i+1;c<a&&s.isInSet(n.child(c).marks);)p+=n.child(c).nodeSize,c+=1;t.removeMark(h,h+p,l),t.addMark(h,h+p,l.create(e.attrs)),o(t)}else t.doc.nodesBetween(i,s,((n,r)=>{n.isInline&&l.isInSet(n.marks)&&(t.removeMark(r,r+n.nodeSize,l),t.addMark(r,r+n.nodeSize,l.create(e.attrs)),o(t))}))})({mark:e,attrs:t},s)(o,a);else{let n=o;An(o,{mark:e})&&(zn({mark:e,attrs:t},s)(o,a),n=yt.create({doc:s.doc,selection:s.selection})),l?Mn(i[e],t,s)(n,a):In({mark:e},s,t)(n,a)}return l&&r(s),l},e.autoJoin=$o,e.baseKeymap=Fo,e.blockNodes=Pn,e.blockquote=(e,t)=>Eo(e.schema.nodes.blockquote)(e,t),e.bold=_c,e.buildKeymap=(e,t)=>{const n={},o=t&&t.applyToWord||!1;if(n["Mod-z"]=Ac,n["Shift-Mod-z"]=Tc,n.Backspace=Io(Ic,so,ao,po),n.Enter=Io(wo,ko,xo,Mo),Jc||(n["Mod-y"]=Tc),e.marks.strong&&(n["Mod-b"]=Qt(In,{..._c,applyToWord:o})),e.marks.em&&(n["Mod-i"]=Qt(In,{...Wc,applyToWord:o})),e.marks.u&&(n["Mod-u"]=Qt(In,{...qc,applyToWord:o})),e.nodes.hard_break){const t=e.nodes.hard_break,o=Io(bo,((e,n)=>(n(e.tr.replaceSelectionWith(t.create()).scrollIntoView()),!0)));n["Shift-Enter"]=o}return n},e.buildListKeymap=e=>{const t={};var n;return e.nodes.list_item&&(t.Enter=(n=e.nodes.list_item,(e,t)=>Qn(n)(e,(n=>{const o=e.storedMarks||e.selection.$to.parentOffset&&e.selection.$from.marks();o&&n.ensureMarks(o),t(n)})))),t},e.bulletList=Kn,e.canBeIndented=Jo,e.canIndentAsListItem=Wo,e.canInsert=(e,t)=>{const n=e.selection.$from;for(let e=n.depth;e>=0;e--){const o=n.index(e);if(n.node(e).canReplaceWith(o,o,t))return!0}return!1},e.canJoin=ze,e.canOutdentAsListItem=qo,e.canSplit=Ie,e.caretColor=function(){return new vt({key:Dd,props:{decorations:e=>{const{doc:t,selection:n,storedMarks:o}=e;if(!n.empty||!o)return qs.empty;const r=Tn((o||[]).find((e=>"style"===e.type.name)),{name:"color",value:/^.+$/});if(!r)return qs.empty;const i=n.$anchor.parent,s=[];return t.descendants(((e,t)=>{e.eq(i)&&s.push(Hs.node(t,t+e.nodeSize,{style:"caret-color: "+r}))})),qs.create(t,s)}}})},e.caretColorKey=Dd,e.cellAround=_l,e.chainCommands=Io,e.changeTextBlock=Bn,e.cleanFormatting=(e={blocksInSelection:!0})=>(t,n)=>{const o=t.tr,{blocksInSelection:r,blockNodeType:i,exceptMarks:s}=e,l=(s||[t.schema.marks.link]).filter(Boolean);On(o,{except:l}),Vn(o,{blocksInSelection:r,blockNodeType:i});const a=o.docChanged;return a&&n&&n(o),a},e.cleanMarks=On,e.cleanTextBlockFormatting=Vn,e.closeDoubleQuote=Vc,e.closeHistory=function(e){return e.setMeta(Nc,!0)},e.closeSingleQuote=Lc,e.colCount=function(e){return zl.get(e.node(-1)).colCount(e.pos-e.start(-1))},e.columnIsHeader=Yl,e.columnResizing=function({handleWidth:e=5,cellMinWidth:t=25,defaultCellMinWidth:n=100,View:o=Va,lastColumnResizable:r=!0}={}){const i=new vt({key:La,state:{init(e,t){var r,s;const l=null==(s=null==(r=i.spec)?void 0:r.props)?void 0:s.nodeViews,a=Ll(t.schema).table.name;return o&&l&&(l[a]=(e,t)=>new o(e,n,t)),new Ha(-1,!1)},apply:(e,t)=>t.apply(e)},props:{attributes:e=>{const t=La.getState(e);return t&&t.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(t,n)=>{!function(e,t,n,o){const r=La.getState(e.state);if(!r)return;if(!r.dragging){const i=function(e){for(;e&&"TD"!=e.nodeName&&"TH"!=e.nodeName;)e=e.classList&&e.classList.contains("ProseMirror")?null:e.parentNode;return e}(t.target);let s=-1;if(i){const{left:o,right:r}=i.getBoundingClientRect();t.clientX-o<=n?s=_a(e,t,"left",n):r-t.clientX<=n&&(s=_a(e,t,"right",n))}if(s!=r.activeHandle){if(!o&&-1!==s){const t=e.state.doc.resolve(s),n=t.node(-1),o=zl.get(n),r=t.start(-1);if(o.colCount(t.pos-r)+t.nodeAfter.attrs.colspan-1==o.width-1)return}qa(e,s)}}}(t,n,e,r)},mouseleave:e=>{!function(e){const t=La.getState(e.state);t&&t.activeHandle>-1&&!t.dragging&&qa(e,-1)}(e)},mousedown:(e,o)=>{!function(e,t,n,o){var r;const i=null!=(r=e.dom.ownerDocument.defaultView)?r:window,s=La.getState(e.state);if(!s||-1==s.activeHandle||s.dragging)return!1;const l=e.state.doc.nodeAt(s.activeHandle),a=function(e,t,{colspan:n,colwidth:o}){const r=o&&o[o.length-1];if(r)return r;const i=e.domAtPos(t);let s=i.node.childNodes[i.offset].offsetWidth,l=n;if(o)for(let e=0;e<n;e++)o[e]&&(s-=o[e],l--);return s/l}(e,s.activeHandle,l.attrs);function c(t){i.removeEventListener("mouseup",c),i.removeEventListener("mousemove",d);const o=La.getState(e.state);(null==o?void 0:o.dragging)&&(!function(e,t,n){const o=e.state.doc.resolve(t),r=o.node(-1),i=zl.get(r),s=o.start(-1),l=i.colCount(o.pos-s)+o.nodeAfter.attrs.colspan-1,a=e.state.tr;for(let e=0;e<i.height;e++){const t=e*i.width+l;if(e&&i.map[t]==i.map[t-i.width])continue;const o=i.map[t],c=r.nodeAt(o).attrs,d=1==c.colspan?0:l-i.colCount(o);if(c.colwidth&&c.colwidth[d]==n)continue;const h=c.colwidth?c.colwidth.slice():ja(c.colspan);h[d]=n,a.setNodeMarkup(s+o,null,{...c,colwidth:h})}a.docChanged&&e.dispatch(a)}(e,o.activeHandle,Wa(o.dragging,t,n)),e.dispatch(e.state.tr.setMeta(La,{setDragging:null})))}function d(t){if(!t.which)return c(t);const r=La.getState(e.state);if(r&&r.dragging){const i=Wa(r.dragging,t,n);Ja(e,r.activeHandle,i,o)}}e.dispatch(e.state.tr.setMeta(La,{setDragging:{startX:t.clientX,startWidth:a}})),Ja(e,s.activeHandle,a,o),i.addEventListener("mouseup",c),i.addEventListener("mousemove",d),t.preventDefault()}(e,o,t,n)}},decorations:e=>{const t=La.getState(e);if(t&&t.activeHandle>-1)return function(e,t){var n;const o=[],r=e.doc.resolve(t),i=r.node(-1);if(!i)return qs.empty;const s=zl.get(i),l=r.start(-1),a=s.colCount(r.pos-l)+r.nodeAfter.attrs.colspan-1;for(let t=0;t<s.height;t++){const r=a+t*s.width;if(!(a!=s.width-1&&s.map[r]==s.map[r+1]||0!=t&&s.map[r]==s.map[r-s.width])){const t=s.map[r],a=l+t+i.nodeAt(t).nodeSize-1,c=document.createElement("div");c.className="column-resize-handle",(null==(n=La.getState(e))?void 0:n.dragging)&&o.push(Hs.node(l+t,l+t+i.nodeAt(t).nodeSize,{class:"column-resize-dragging"})),o.push(Hs.widget(a,c))}}return qs.create(e.doc,o)}(e,t.activeHandle)},nodeViews:{}}});return i},e.columnResizingPluginKey=La,e.convertMsLists=ed,e.createParagraphNear=ko,e.createTable=(e,t,n)=>{const{table:o,table_row:r,table_cell:i}=e,s=[];let l;for(let e=0;e<t+1;e++){l=[];for(let e=0;e<n+1;e++)l.push(i.createAndFill());s.push(r.createAndFill(void 0,l))}return o.createAndFill(void 0,s)},e.cspFix=()=>new vt({key:new xt("csp-fix"),props:{nodeViews:{paragraph:(e,t)=>new vd(e,t,"p"),div:(e,t)=>new vd(e,t,"div"),table_wrapper:(e,t)=>new vd(e,t,"div"),table_caption_external:(e,t)=>new vd(e,t,"div"),table:(e,t)=>new vd(e,t,"table"),table_row:(e,t)=>new vd(e,t,"tr"),table_cell:(e,t)=>new vd(e,t,"td"),table_header:(e,t)=>new vd(e,t,"th"),image:(e,t)=>new vd(e,t,"img",!0)},markViews:{style:(e,t)=>new bd(e,t)}}}),e.deleteColumn=(e,t)=>{const n=gh(e.selection,uh),o=n&&n.node.attrs[Ct],r=yh(n,e.selection),i=t&&(e=>{if(!o)return t(e);const i=e.doc.nodeAt(n.pos);return((e,t,n)=>{const o=cc(t.node.attrs[Ct]);o.removeChild(o.children[n]),e.setNodeMarkup(t.pos,null,{...t.node.attrs,[Ct]:o.outerHTML})})(e,{node:i,pos:n.pos},r),t(e)});return ca(e,i)},e.deleteRow=function(e,t){if(!Wl(e))return!1;if(t){const n=ra(e),o=e.tr;if(0==n.top&&n.bottom==n.map.height)return!1;for(let e=n.bottom-1;fa(o,n,e),e!=n.top;e--){const e=n.tableStart?o.doc.nodeAt(n.tableStart-1):o.doc;if(!e)throw RangeError("No table found");n.table=e,n.map=zl.get(n.table)}t(o)}return!0},e.deleteSelection=so,e.deleteTable=function(e,t){const n=e.selection.$anchor;for(let o=n.depth;o>0;o--){if("table"==n.node(o).type.spec.tableRole)return t&&t(e.tr.delete(n.before(o),n.after(o)).scrollIntoView()),!0}return!1},e.domToPmDoc=wn,e.dropCursor=function(e={}){return new vt({view:t=>new ih(t,e)})},e.dropPoint=Fe,e.ellipsis=Bc,e.emDash=zc,e.exitCode=bo,e.expandSelection=Yt,e.expandToWordWrap=Qt,e.find=(e,t)=>{const{backward:n,matchCyclic:o,...r}=t,i=n?()=>!1:e=>e.length>0,{doc:s,selection:l}=e;let a=[];return n?(a=hd(s,r,0,l.from,i),!a.length&&o&&(a=hd(s,r,l.from,s.content.size,i))):(a=hd(s,r,l.to,s.content.size,i),!a.length&&o&&(a=hd(s,r,0,l.to,i))),a.length?a[a.length-1]:null},e.findAll=pd,e.findAt=hd,e.findCell=function(e){return zl.get(e.node(-1)).findCell(e.pos-e.start(-1))},e.findWrapping=De,e.fixTables=oa,e.fixTablesKey=ta,e.flattenNestedSpans=e=>{const t=mn(e);let n=xn(t);for(;n;){const e=n.parentNode.closest("span");if(e){const t=new kn(e),o=t.extractAfter(n),r=t.extractBefore(n);for(let t=0;t<n.style.length;t++){const o=n.style.item(t);e.style[o]=n.style.getPropertyValue(o)}n.removeAttribute("style"),n.classList.length&&Array.from(n.classList).forEach((t=>{e.classList.contains(t)||e.classList.add(t)})),n.removeAttribute("class");for(let t=0;t<n.attributes.length;t++){const o=n.attributes.item(t);o&&null!==o.nodeValue&&e.setAttribute(o.nodeName,o.nodeValue)}for(;n.firstChild&&n.parentNode;)n.parentNode.insertBefore(n.firstChild,n);n.parentNode&&n.parentNode.removeChild(n),e.parentNode&&(Sn(r)||e.parentNode.insertBefore(r,e),Sn(o)||e.parentNode.insertBefore(o,e.nextSibling))}n=xn(t)}return gn(t)},e.formatBlockElements=(e,t)=>(n,o)=>{const r=Pn(n),i=n.schema.nodes,s=n.tr;s.setMeta("commandName",t),s.setMeta("args",{value:e}),r.forEach((t=>{if(t.type.isTextblock)if("p"===e)Bn(s,t,i.paragraph,t.attrs);else if(/^h[1-6]$/i.test(e)){const n=parseInt(e.substr(1),10);Bn(s,t,i.heading,{...t.attrs,level:n})}else"blockquote"===e&&Bn(s,t,i.blockquote,t.attrs)}));const l=s.docChanged;return l&&o(s.scrollIntoView()),l},e.fragmentToHtml=gn,e.gapCursor=function(){return new vt({props:{decorations:ph,createSelectionBetween:(e,t,n)=>t.pos==n.pos&&sh.valid(n)?new sh(n):null,handleClick:dh,handleKeyDown:ah,handleDOMEvents:{beforeinput:hh}}})},e.getActiveMarks=(e,t)=>{const n=Dn(e,t),o=n.filter((e=>Boolean(e)));return{hasNodesWithoutMarks:n.length!==o.length,marks:o}},e.getBlockFormats=Fn,e.getHtml=e=>{const t=yn(e.doc);return gn(t)},e.getInlineStyles=(e,t)=>{const n=e.schema.marks.style;return(n?Dn(e,n):[]).map((e=>Tn(e,t))).filter((e=>null!==e))},e.getMark=(e,t)=>{const n=Dn(e,t),o=n.filter((e=>Boolean(e)));return n.length===o.length?n[0]:void 0},e.getNodeFromSelection=e=>{if(e.selection instanceof st)return e.selection.node},e.getSelectionText=Ut,e.goToNextCell=function(e){return function(t,n){if(!Wl(t))return!1;const o=function(e,t){if(t<0){const t=e.nodeBefore;if(t)return e.pos-t.nodeSize;for(let t=e.index(-1)-1,n=e.before();t>=0;t--){const o=e.node(-1).child(t),r=o.lastChild;if(r)return n-1-r.nodeSize;n-=o.nodeSize}}else{if(e.index()<e.parent.childCount-1)return e.pos+e.nodeAfter.nodeSize;const t=e.node(-1);for(let n=e.indexAfter(-1),o=e.after();n<t.childCount;n++){const e=t.child(n);if(e.childCount)return o+1;o+=e.nodeSize}}return null}(ql(t),e);if(null==o)return!1;if(n){const e=t.doc.resolve(o);n(t.tr.setSelection(rt.between(e,jl(e))).scrollIntoView())}return!0}},e.hasMark=An,e.hasNode=Hn,e.hasSameMarkup=(e,t,n,o)=>{const i=r.from(vn(e,n,o)),s=r.from(vn(t,n,o));return i.eq(s)},e.history=function(e={}){return e={depth:e.depth||100,newGroupDelay:e.newGroupDelay||500},new vt({key:Mc,state:{init:()=>new wc(gc.empty,gc.empty,null,0,-1),apply:(t,n,o)=>function(e,t,n,o){let r,i=n.getMeta(Mc);if(i)return i.historyState;n.getMeta(Nc)&&(e=new wc(e.done,e.undone,null,0,-1));let s=n.getMeta("appendedTransaction");if(0==n.steps.length)return e;if(s&&s.getMeta(Mc))return s.getMeta(Mc).redo?new wc(e.done.addTransform(n,void 0,o,Cc(t)),e.undone,bc(n.mapping.maps),e.prevTime,e.prevComposition):new wc(e.done,e.undone.addTransform(n,void 0,o,Cc(t)),null,e.prevTime,e.prevComposition);if(!1===n.getMeta("addToHistory")||s&&!1===s.getMeta("addToHistory"))return(r=n.getMeta("rebased"))?new wc(e.done.rebased(n,r),e.undone.rebased(n,r),kc(e.prevRanges,n.mapping),e.prevTime,e.prevComposition):new wc(e.done.addMaps(n.mapping.maps),e.undone.addMaps(n.mapping.maps),kc(e.prevRanges,n.mapping),e.prevTime,e.prevComposition);{let r=n.getMeta("composition"),i=0==e.prevTime||!s&&e.prevComposition!=r&&(e.prevTime<(n.time||0)-o.newGroupDelay||!function(e,t){if(!t)return!1;if(!e.docChanged)return!0;let n=!1;return e.mapping.maps[0].forEach(((e,o)=>{for(let r=0;r<t.length;r+=2)e<=t[r+1]&&o>=t[r]&&(n=!0)})),n}(n,e.prevRanges)),l=s?kc(e.prevRanges,n.mapping):bc(n.mapping.maps);return new wc(e.done.addTransform(n,i?t.selection.getBookmark():void 0,o,Cc(t)),gc.empty,l,n.time,null==r?e.prevComposition:r)}}(n,o,t,e)},config:e,props:{handleDOMEvents:{beforeinput(e,t){let n=t.inputType,o="historyUndo"==n?Ac:"historyRedo"==n?Tc:null;return!!o&&(t.preventDefault(),o(e.state,e.dispatch))}}}})},e.htmlToFragment=mn,e.imageResizeKey=Cd,e.imageResizing=(e={node:"image",lockRatio:!0})=>new vt({key:Cd,view:t=>({resize(){Cd.getState(t.state).rect&&t.dispatch(t.state.tr.setMeta("resize",!0))},get window(){return t.dom.ownerDocument&&t.dom.ownerDocument.defaultView},attachResize(){const e=this.window;e&&(e.removeEventListener("resize",this.resize),e.addEventListener("resize",this.resize))},removeResize(){const e=this.window;e&&e.removeEventListener("resize",this.resize)},update(t,n){const o=t.state,r=o.selection,i=o.schema.nodes[e.node],s=Cd.getState(o),l=s.rect;if(r instanceof st&&i===r.node.type){const e=t.nodeDOM(r.from),i={top:e.offsetTop,left:e.offsetLeft,width:e.offsetWidth,height:e.offsetHeight};if(!n.selection.eq(r)||l&&(l.width!==i.width||l.height!==i.height||l.top!==i.top||l.left!==i.left)){const e=o.tr;e.setMeta(Cd,{rect:i,nodePosition:r.from}),t.dispatch(e),this.attachResize()}}else l&&(s.rect=null,s.nodePosition=-1)},destroy(){this.removeResize()}}),state:{init:()=>new Ad("",null,null,-1),apply:(e,t)=>t.apply(e)},props:{handleDOMEvents:{mousedown:(t,n)=>Td(t,n,e)},decorations(t){const n=t.selection,o=t.schema.nodes[e.node],r=Cd.getState(t).rect;if(r&&n instanceof st&&o===n.node.type){const e=document.createElement("div");e.className="k-editor-resize-handles-wrapper",e.style.width=r.width+"px",e.style.height=r.height+"px",e.style.top=r.top+"px",e.style.left=r.left+"px";for(let t=0;t<Sd.length;t++){const n=document.createElement("div");n.className=Nt+" "+Sd[t],n.setAttribute(At,Sd[t]),e.appendChild(n)}return qs.create(t.doc,[Hs.widget(t.selection.from+1,e)])}return qs.empty}}}),e.inSameTable=Kl,e.indent=(e,t)=>{const n=e.schema.nodes[ro.listsTypes.listItem],o=Jo(e,ro);Wo(e,n)?eo(n)(e,t):o&&Ho(ro.nodes)(e,t)},e.indentBlocks=Ho,e.indentHtml=e=>e.replace(/<\/(p|li|ul|ol|h[1-6]|table|tr|td|th)>/gi,"</$1>\n").replace(/<(ul|ol)([^>]*)><li/gi,"<$1$2>\n<li").replace(/<br \/>/gi,"<br />\n").replace(/\n$/,""),e.indentRules=ro,e.inputRules=function({rules:e}){let t=new vt({state:{init:()=>null,apply(e,t){let n=e.getMeta(this);return n||(e.selectionSet||e.docChanged?null:t)}},props:{handleTextInput:(n,o,r,i)=>$c(n,o,r,i,e,t),handleDOMEvents:{compositionend:n=>{setTimeout((()=>{let{$cursor:o}=n.state.selection;o&&$c(n,o.pos,o.pos,"",e,t)}))}}},isInputRules:!0});return t},e.insertImage=e=>(t,n)=>{const{image:o}=t.schema.nodes,r=o.createAndFill(e);Xt(r)(t,(t=>n(t.setMeta("commandName","insertImage").setMeta("args",e))))},e.insertNode=Xt,e.insertPoint=Ve,e.insertText=e=>(t,n)=>{n(t.tr.insertText(e.text,e.from,e.to))},e.isAligned=(e,t)=>{const n=Pn(e);let o=!1;return n.forEach((e=>{if(!o&&e.type.isTextblock&&e.attrs.style){const n=t.find((t=>t.node===e.type.name));n&&(o=n.style.every((t=>!!t.value&&new RegExp(`${t.name}:\\s?${t.value}`,"i").test(e.attrs.style))))}})),o},e.isInTable=Wl,e.isIndented=_o,e.italic=Wc,e.joinBackward=ao,e.joinDown=(e,t)=>{let n,o=e.selection;if(o instanceof st){if(o.node.isTextblock||!ze(e.doc,o.to))return!1;n=o.to}else if(n=Pe(e.doc,o.to,1),null==n)return!1;return t&&t(e.tr.join(n).scrollIntoView()),!0},e.joinForward=mo,e.joinPoint=Pe,e.joinTextblockBackward=(e,t,n)=>{let o=lo(e,n);if(!o)return!1;let r=uo(o);return!!r&&co(e,r,t)},e.joinTextblockForward=(e,t,n)=>{let o=fo(e,n);if(!o)return!1;let r=yo(o);return!!r&&co(e,r,t)},e.joinUp=(e,t)=>{let n,o=e.selection,r=o instanceof st;if(r){if(o.node.isTextblock||!ze(e.doc,o.from))return!1;n=o.from}else if(n=Pe(e.doc,o.from,-1),null==n)return!1;if(t){let o=e.tr.join(n);r&&o.setSelection(st.create(o.doc,n-e.doc.resolve(n).nodeBefore.nodeSize)),t(o.scrollIntoView())}return!0},e.keydownHandler=Rl,e.keymap=function(e){return new vt({props:{handleKeyDown:Rl(e)}})},e.lift=(e,t)=>{let{$from:n,$to:o}=e.selection,r=n.blockRange(o),i=r&&Te(r);return null!=i&&(t&&t(e.tr.lift(r,i).scrollIntoView()),!0)},e.liftBlockquote=Lo,e.liftEmptyBlock=xo,e.liftListItem=Zn,e.liftTarget=Te,e.link={mark:"link"},e.listItem=Xn,e.listMarkersStyles=function(e=rh){return new vt({key:new xt("list-markers-styles"),appendTransaction:(t,n,o)=>{const r=t.slice().pop(),i=r.getMeta("commandName");let s;return"FontSize"===i||"FontName"===i||"ForeColor"===i?s=((e,t,n)=>{const{tr:o,doc:r,selection:{from:i,to:s}}=t,l=e.getMeta("args");return r.nodesBetween(i,s,((e,t)=>{e.type.name===n.listItem&&oh(i,s,t,e,r)&&o.setNodeMarkup(t,null,{...e.attrs,style:en(e.attrs.style,l.style,l.value)})})),o.docChanged?o:void 0})(r,o,e):"CleanFormatting"===i&&(s=((e,t,n)=>{const o=Object.keys(n.resetValues),{tr:r,doc:i,selection:{from:s,to:l}}=t;return i.nodesBetween(s,l,((e,t)=>{if(e.type.name===n.listItem&&oh(s,l,t,e,i)){let n=e.attrs;const i=Zt(e.attrs.style);o.forEach((e=>{i[e]&&(n={...n,style:en(n.style,e,"")})})),n!==e.attrs&&r.setNodeMarkup(t,null,n)}})),e.steps.forEach((e=>{if(e instanceof ke){const t=e.mark;if("style"===t.type.name&&t.attrs.style){const[o]=t.attrs.style.split(/\s*:\s*/),i=jt(r.doc.resolve(e.from),(e=>e.type.name===n.listItem));if(i&&Zt(i.node.attrs.style)[o]&&n.resetValues[o]){const i=t.type.create({style:`${o}: ${n.resetValues[o]};`});r.addMark(e.from,e.to,i)}}}})),r.docChanged?r:void 0})(r,o,e)),s&&s.setMeta("addToHistory",!0),s}})},e.listStyle=Yo,e.macBaseKeymap=Vo,e.marks=ic,e.mergeCells=function(e,t){const n=e.selection;if(!(n instanceof Ql)||n.$anchorCell.pos==n.$headCell.pos)return!1;const o=ra(e),{map:i}=o;if(function({width:e,height:t,map:n},o){let r=o.top*e+o.left,i=r,s=(o.bottom-1)*e+o.left,l=r+(o.right-o.left-1);for(let t=o.top;t<o.bottom;t++){if(o.left>0&&n[i]==n[i-1]||o.right<e&&n[l]==n[l+1])return!0;i+=e,l+=e}for(let i=o.left;i<o.right;i++){if(o.top>0&&n[r]==n[r-e]||o.bottom<t&&n[s]==n[s+e])return!0;r++,s++}return!1}(i,o))return!1;if(t){const n=e.tr,s={};let l,a,c=r.empty;for(let e=o.top;e<o.bottom;e++)for(let t=o.left;t<o.right;t++){const r=i.map[e*i.width+t],d=o.table.nodeAt(r);if(!s[r]&&d)if(s[r]=!0,null==l)l=r,a=d;else{ma(d)||(c=c.append(d.content));const e=n.mapping.map(r+o.tableStart);n.delete(e,e+d.nodeSize)}}if(null==l||null==a)return!0;if(n.setNodeMarkup(l+o.tableStart,null,{...Gl(a.attrs,a.attrs.colspan,o.right-o.left-a.attrs.colspan),rowspan:o.bottom-o.top}),c.size){const e=l+1+a.content.size,t=ma(a)?l+1:e;n.replaceWith(t+o.tableStart,e+o.tableStart,c)}n.setSelection(new Ql(n.doc.resolve(l+o.tableStart))),t(n)}return!0},e.moveCellForward=jl,e.newlineInCode=wo,e.nextCell=Xl,e.nodes=hc,e.openDoubleQuote=Pc,e.openSingleQuote=Fc,e.orderedList=jn,e.outdent=(e,t)=>{const n=e.schema.nodes,o=n[io.listsTypes.listItem],r=Jo(e,io);Hn(e,n.blockquote)?Lo(e,t):qo(e,io)?Zn(o)(e,t):r&&Ho(io.nodes)(e,t)},e.outdentRules=io,e.parentBlockFormat=_n,e.parentNode=jt,e.parseContent=vn,e.pasteCleanup=(e,t)=>{let n=e;if(t.convertMsLists&&(n=ed(n)),t.stripTags&&(n=td(n,t.stripTags)),t.attributes){const e=mn(n);Array.from(e.querySelectorAll("*")).forEach((e=>((e,t)=>{if(e.nodeType===Node.ELEMENT_NODE){for(let n=e.attributes.length-1;n>=0;n--){const o=e.attributes[n];t[o.name]?t[o.name](o):t["*"]&&t["*"](o)}"SPAN"===e.nodeName&&0===e.attributes.length&&(e=>{const t=e.parentNode;if(t){for(;e.firstChild;)t.insertBefore(e.firstChild,e);t.removeChild(e)}})(e)}})(e,t.attributes))),n=gn(e)}return n},e.pcBaseKeymap=Po,e.placeholder=function(e){const t={class:"k-placeholder","data-placeholder":e};return new vt({key:new xt("placeholder"),props:{decorations:e=>{const{doc:n}=e,o=n.content.firstChild;if(!(0===n.childCount||1===n.childCount&&o.inlineContent&&0===o.childCount))return qs.empty;const r=[];return n.descendants(((e,n)=>{r.push(Hs.node(n,n+e.nodeSize,t))})),qs.create(n,r)}}})},e.pmAddColumnAfter=la,e.pmAddColumnBefore=sa,e.pmAddRowAfter=ua,e.pmAddRowBefore=pa,e.pmDeleteColumn=ca,e.pmDocToFragment=yn,e.redo=Tc,e.redoDepth=function(e){let t=Mc.getState(e);return t?t.undone.eventCount:0},e.redoNoScroll=Ec,e.removeAllMarks=({except:e=[]}={})=>(t,n)=>{const o=t.tr;var r;On(o,{except:(r=e,r instanceof Array?r:[r])}),o.docChanged&&n(o)},e.removeAttribute=nd,e.removeColSpan=Ul,e.removeComments=e=>{const t=mn(e);return bn(t),gn(t)},e.removeLink=zn,e.removeTag=td,e.replace=(e,t,n)=>{const{from:o,to:r}=e;return n.insertText(t,o,r).setSelection(rt.create(n.doc,o,o+t.length)),n},e.replaceAll=(e,t,n)=>{const o=pd(e.doc,n);if(0===o.length)return null;const r=e.tr;for(let e=o.length-1;e>=0;e--)r.insertText(t,o[e].from,o[e].to);return r},e.replaceImageSourcesFromRtf=(e,t)=>{const n=e.match(rd);if(!n||-1===t.types.indexOf(dd))return e;const o=t.getData(dd),r=[],i=o.match(sd);if(!o||!i)return e;for(const e of i){const t=cd.exec(e);if(t){const n=e.replace(id,"").replace(ld,"");r.push(`data:image/${t[1]};base64,${od(n)}`)}}return n.length!==r.length?e:e.replace(rd,(e=>{const t=r.shift()||"";return e.replace(ad,t)}))},e.replaceStep=Le,e.rowIsHeader=da,e.sanitize=e=>{let t;e=(e=(e=(e=e.replace(/^[\s\S]+?<!--StartFragment-->\s*([\s\S]*?)\s*<!--EndFragment-->[\s\S]+$/,"$1")).replace(/<\/?[ovw]:[^>]*?>/gi,"")).replace(/<\\?\??xml[^>]*>/gi,"")).replace(/<(?:link|meta) [^>]+?>/gi,"");do{t=e,e=e.replace(/<style[^>]*?>\s*<\/style>/gi,"")}while(e!==t);return e=(e=(e=(e=(e=e.replace(/<\/?st1:.*?>/gi,"")).replace(/<a name="[a-zA-Z0-9_]+">/gim,"")).replace(/v:shapes?="[^"]+"/gi,"")).replace(/<!\[if !supportLists\]>/gi,"")).replace(/<!\[endif\]>/gi,"")},e.sanitizeClassAttr=e=>{/^Mso/.test(e.value)&&nd(e)},e.sanitizeStyleAttr=e=>{const t=Zt(e.value),n=e.ownerElement.style;let o="";Object.keys(t).forEach((e=>{void 0!==n[e]&&(o+=`${e}: ${t[e]}; `)})),o=o.trim(),o?e.value=o:nd(e)},e.selectAll=No,e.selectNodeBackward=po,e.selectNodeForward=go,e.selectParentNode=(e,t)=>{let n,{$from:o,to:r}=e.selection,i=o.sharedDepth(r);return 0!=i&&(n=o.before(i),t&&t(e.tr.setSelection(st.create(e.doc,n))),!0)},e.selectTextblockEnd=Do,e.selectTextblockStart=To,e.selectedLineTextOnly=e=>{let t="",n=!1;const{selection:o,doc:r}=e,{$from:i,$to:s,from:l,to:a}=o;return i.sameParent(s)&&(r.nodesBetween(l,a,(e=>{n=n||e.isLeaf&&!e.isText})),n||(t=Ut(e))),t},e.selectedRect=ra,e.selectionCell=ql,e.selectionMarks=Dn,e.setBlockType=function(e,t=null){return function(n,o){let r=!1;for(let o=0;o<n.selection.ranges.length&&!r;o++){let{$from:{pos:i},$to:{pos:s}}=n.selection.ranges[o];n.doc.nodesBetween(i,s,((o,i)=>{if(r)return!1;if(o.isTextblock&&!o.hasMarkup(e,t))if(o.type==e)r=!0;else{let t=n.doc.resolve(i),o=t.index();r=t.parent.canReplaceWith(o,o+1,e)}}))}if(!r)return!1;if(o){let r=n.tr;for(let o=0;o<n.selection.ranges.length;o++){let{$from:{pos:i},$to:{pos:s}}=n.selection.ranges[o];r.setBlockType(i,s,e,t)}o(r.scrollIntoView())}return!0}},e.setCellAttr=function(e,t){return function(n,o){if(!Wl(n))return!1;const r=ql(n);if(r.nodeAfter.attrs[e]===t)return!1;if(o){const i=n.tr;n.selection instanceof Ql?n.selection.forEachCell(((n,o)=>{n.attrs[e]!==t&&i.setNodeMarkup(o,null,{...n.attrs,[e]:t})})):i.setNodeMarkup(r.pos,null,{...r.nodeAfter.attrs,[e]:t}),o(i)}return!0}},e.setHtml=(e,t="setHTML",n={preserveWhitespace:"full"})=>(o,r)=>r(o.tr.setSelection(new at(o.doc)).replaceSelectionWith(vn(e,o.schema,n)).setMeta("commandName",t)),e.sinkListItem=eo,e.smartQuotes=Hc,e.spacesFix=()=>new vt({key:new xt("spaces-fix"),props:{decorations:e=>{const t=[],n=e.doc;let o,r,i,s;return n.nodesBetween(0,n.content.size,((e,n,l)=>{if(e.type.isText&&(e=>yd.test(e&&e.attrs&&e.attrs.style||""))(l))for(r=gd.exec(e.text||"");null!==r;){if(o=n+r.index,i=r[0].length,r.index+i<r.input.length)for(s=0;s<=i-1;s+=2)t.push(Hs.inline(o+s,o+s+1,{style:"white-space: normal"}));r=gd.exec(e.text||"")}})),qs.create(n,t)}}}),e.splitBlock=Co,e.splitBlockAs=So,e.splitBlockKeepMarks=Mo,e.splitCell=function(e,t){const n=Ll(e.schema);return ga((({node:e})=>n[e.type.spec.tableRole]))(e,t)},e.splitCellWithType=ga,e.splitListItem=Qn,e.splitListItemKeepMarks=function(e,t){let n=Qn(e,t);return(e,t)=>n(e,t&&(n=>{let o=e.storedMarks||e.selection.$to.parentOffset&&e.selection.$from.marks();o&&n.ensureMarks(o),t(n)}))},e.strikethrough={mark:"del",altStyle:{name:"text-decoration",value:/^line-through$/i}},e.subscript={mark:"sub"},e.superscript={mark:"sup"},e.tableColumnResizeKey=Id,e.tableEditing=function({allowTableNodeSelection:e=!1}={}){return new vt({key:Hl,state:{init:()=>null,apply(e,t){const n=e.getMeta(Hl);if(null!=n)return-1==n?null:n;if(null==t||!e.docChanged)return t;const{deleted:o,pos:r}=e.mapping.mapResult(t);return o?null:r}},props:{decorations:ea,handleDOMEvents:{mousedown:Ia},createSelectionBetween:e=>null!=Hl.getState(e.state)?e.state.selection:null,handleTripleClick:Ra,handleKeyDown:Aa,handlePaste:$a},appendTransaction:(t,n,o)=>function(e,t,n){const o=(t||e).selection,r=(t||e).doc;let i,s;if(o instanceof st&&(s=o.node.type.spec.tableRole)){if("cell"==s||"header_cell"==s)i=Ql.create(r,o.from);else if("row"==s){const e=r.resolve(o.from+1);i=Ql.rowSelection(e,e)}else if(!n){const e=zl.get(o.node),t=o.from+1,n=t+e.map[e.width*e.height-1];i=Ql.create(r,t+1,n)}}else o instanceof rt&&function({$from:e,$to:t}){if(e.pos==t.pos||e.pos<t.pos-6)return!1;let n=e.pos,o=t.pos,r=e.depth;for(;r>=0&&!(e.after(r+1)<e.end(r));r--,n++);for(let e=t.depth;e>=0&&!(t.before(e+1)>t.start(e));e--,o--);return n==o&&/row|table/.test(e.node(r).type.spec.tableRole)}(o)?i=rt.create(r,o.from):o instanceof rt&&function({$from:e,$to:t}){let n,o;for(let t=e.depth;t>0;t--){const o=e.node(t);if("cell"===o.type.spec.tableRole||"header_cell"===o.type.spec.tableRole){n=o;break}}for(let e=t.depth;e>0;e--){const n=t.node(e);if("cell"===n.type.spec.tableRole||"header_cell"===n.type.spec.tableRole){o=n;break}}return n!==o&&0===t.parentOffset}(o)&&(i=rt.create(r,o.$from.start(),o.$from.end()));return i&&(t||(t=e.tr)).setSelection(i),t}(o,oa(o,n),e)})},e.tableEditingKey=Hl,e.tableNodeTypes=Ll,e.tableNodes=Fl,e.tableResizeKey=$d,e.tableResizing=()=>[Qd(),_d(),eh()],e.tableRowResizeKey=zd,e.textHighlight=function(e=kd){return new vt({key:e,state:{init:()=>null,apply(e){return e.getMeta(this.spec.key)}},props:{decorations(e){const t=(this.spec.key.getState(e)||[]).map((e=>Hs.inline(e.from,e.to,e.attrs)));return qs.create(e.doc,t)}}})},e.textHighlightKey=kd,e.textblockTypeInputRule=function(e,t,n=null){return new Rc(e,((e,o,r,i)=>{let s=e.doc.resolve(r),l=n instanceof Function?n(o):n;return s.node(-1).canReplaceWith(s.index(-1),s.indexAfter(-1),t)?e.tr.delete(r,i).setBlockType(r,r,t,l):null}))},e.toggleHeader=wa,e.toggleHeaderCell=ka,e.toggleHeaderColumn=ba,e.toggleHeaderRow=va,e.toggleInlineFormat=In,e.toggleList=Qo,e.toggleMark=function(e,t=null,n){let o=!1!==(n&&n.removeWhenPresent),r=!1!==(n&&n.enterInlineAtoms);return function(n,i){let{empty:s,$cursor:l,ranges:a}=n.selection;if(s&&!l||!function(e,t,n,o){for(let r=0;r<t.length;r++){let{$from:i,$to:s}=t[r],l=0==i.depth&&e.inlineContent&&e.type.allowsMarkType(n);if(e.nodesBetween(i.pos,s.pos,((e,t)=>{if(l||!o&&e.isAtom&&e.isInline&&t>=i.pos&&t+e.nodeSize<=s.pos)return!1;l=e.inlineContent&&e.type.allowsMarkType(n)})),l)return!0}return!1}(n.doc,a,e,r))return!1;if(i)if(l)e.isInSet(n.storedMarks||l.marks())?i(n.tr.removeStoredMark(e)):i(n.tr.addStoredMark(e.create(t)));else{let s,l=n.tr;r||(a=function(e){let t=[];for(let n=0;n<e.length;n++){let{$from:o,$to:r}=e[n];o.doc.nodesBetween(o.pos,r.pos,((e,n)=>{if(e.isAtom&&e.content.size&&e.isInline&&n>=o.pos&&n+e.nodeSize<=r.pos)return n+1>o.pos&&t.push(new tt(o,o.doc.resolve(n+1))),o=o.doc.resolve(n+1+e.content.size),!1})),o.pos<r.pos&&t.push(new tt(o,r))}return t}(a)),s=o?!a.some((t=>n.doc.rangeHasMark(t.$from.pos,t.$to.pos,e))):!a.every((t=>{let n=!1;return l.doc.nodesBetween(t.$from.pos,t.$to.pos,((o,r,i)=>{if(n)return!1;n=!e.isInSet(o.marks)&&!!i&&i.type.allowsMarkType(e)&&!(o.isText&&/^\s*$/.test(o.textBetween(Math.max(0,t.$from.pos-r),Math.min(o.nodeSize,t.$to.pos-r))))})),!n}));for(let n=0;n<a.length;n++){let{$from:o,$to:r}=a[n];if(s){let n=o.pos,i=r.pos,s=o.nodeAfter,a=r.nodeBefore,c=s&&s.isText?/^\s*/.exec(s.text)[0].length:0,d=a&&a.isText?/\s*$/.exec(a.text)[0].length:0;n+c<i&&(n+=c,i-=d),l.addMark(n,i,e.create(t))}else l.removeMark(o.pos,r.pos,e)}i(l.scrollIntoView())}return!0}},e.toggleOrderedList=function(e,t,n){return Qo(e,t,n,{listType:no.listType,...no.types})},e.toggleUnorderedList=function(e,t,n){return Qo(e,t,n,{listType:oo.listType,...oo.types})},e.trimWhitespace=(e,t=ln)=>{const n=t.join("|");return e.replace(new RegExp("\\s*(<(?:"+n+")(?:\\s[^>]*?)?>)","g"),"$1").replace(new RegExp("(<\\/(?:"+n+")(?:\\s[^>]*?)?>)\\s*","g"),"$1")},e.underline=qc,e.undo=Ac,e.undoDepth=function(e){let t=Mc.getState(e);return t?t.done.eventCount:0},e.undoInputRule=Ic,e.undoNoScroll=Dc,e.updateColumnsOnResize=Fa,e.wrapIn=Eo,e.wrapInList=Gn,e.wrapRangeInList=Yn,e.wrappingInputRule=function(e,t,n=null,o){return new Rc(e,((e,r,i,s)=>{let l=n instanceof Function?n(r):n,a=e.tr.delete(i,s),c=a.doc.resolve(i).blockRange(),d=c&&De(c,t,l);if(!d)return null;a.wrap(c,d);let h=a.doc.resolve(i-1).nodeBefore;return h&&h.type==t&&ze(a.doc,i-1)&&(!o||o(r,h))&&a.join(i-1),a}))}}));