@progress/kendo-editor-common 1.10.1 → 1.10.2-dev.202307310739

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&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.KendoEditorCommon=t():e.KendoEditorCommon=t()}(window,(function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=26)}([function(e,t,n){"use strict";function r(e){this.content=e}n.r(t),n.d(t,"ContentMatch",(function(){return T})),n.d(t,"DOMParser",(function(){return W})),n.d(t,"DOMSerializer",(function(){return te})),n.d(t,"Fragment",(function(){return i})),n.d(t,"Mark",(function(){return c})),n.d(t,"MarkType",(function(){return V})),n.d(t,"Node",(function(){return M})),n.d(t,"NodeRange",(function(){return x})),n.d(t,"NodeType",(function(){return $})),n.d(t,"ReplaceError",(function(){return d})),n.d(t,"ResolvedPos",(function(){return b})),n.d(t,"Schema",(function(){return K})),n.d(t,"Slice",(function(){return u})),r.prototype={constructor:r,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,t,n){var o=n&&n!=e?this.remove(n):this,i=o.find(e),s=o.content.slice();return-1==i?s.push(n||e,t):(s[i+1]=t,n&&(s[i]=n)),new r(s)},remove:function(e){var t=this.find(e);if(-1==t)return this;var n=this.content.slice();return n.splice(t,2),new r(n)},addToStart:function(e,t){return new r([e,t].concat(this.remove(e).content))},addToEnd:function(e,t){var n=this.remove(e).content.slice();return n.push(e,t),new r(n)},addBefore:function(e,t,n){var o=this.remove(t),i=o.content.slice(),s=o.find(e);return i.splice(-1==s?i.length:s,0,t,n),new r(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=r.from(e)).size?new r(e.content.concat(this.subtract(e).content)):this},append:function(e){return(e=r.from(e)).size?new r(this.subtract(e).content.concat(e.content)):this},subtract:function(e){var t=this;e=r.from(e);for(var n=0;n<e.content.length;n+=2)t=t.remove(e.content[n]);return t},toObject:function(){var e={};return this.forEach((function(t,n){e[t]=n})),e},get size(){return this.content.length>>1}},r.from=function(e){if(e instanceof r)return e;var t=[];if(e)for(var n in e)t.push(n,e[n]);return new r(t)};var o=r;class i{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,r=0,o){for(let i=0,s=0;s<t;i++){let l=this.content[i],a=s+l.nodeSize;if(a>e&&!1!==n(l,r+s,o||null,i)&&l.content.size){let o=s+1;l.nodesBetween(Math.max(0,e-o),Math.min(l.content.size,t-o),n,r+o)}s=a}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,n,r){let o="",i=!0;return this.nodesBetween(e,t,(s,l)=>{s.isText?(o+=s.text.slice(Math.max(e,l)-l,t-l),i=!n):s.isLeaf?(r?o+="function"==typeof r?r(s):r:s.type.spec.leafText&&(o+=s.type.spec.leafText(s)),i=!n):!i&&s.isBlock&&(o+=n,i=!0)},0),o}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,n=e.firstChild,r=this.content.slice(),o=0;for(t.isText&&t.sameMarkup(n)&&(r[r.length-1]=t.withText(t.text+n.text),o=1);o<e.content.length;o++)r.push(e.content[o]);return new i(r,this.size+e.size)}cut(e,t=this.size){if(0==e&&t==this.size)return this;let n=[],r=0;if(t>e)for(let o=0,i=0;i<t;o++){let s=this.content[o],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),r+=s.nodeSize),i=l}return new i(n,r)}cutByIndex(e,t){return e==t?i.empty:0==e&&t==this.content.length?this:new i(this.content.slice(e,t))}replaceChild(e,t){let n=this.content[e];if(n==t)return this;let r=this.content.slice(),o=this.size+t.nodeSize-n.nodeSize;return r[e]=t,new i(r,o)}addToStart(e){return new i([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new i(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 r=this.content[t];e(r,n,t),n+=r.nodeSize}}findDiffStart(e,t=0){return function e(t,n,r){for(let o=0;;o++){if(o==t.childCount||o==n.childCount)return t.childCount==n.childCount?null:r;let i=t.child(o),s=n.child(o);if(i!=s){if(!i.sameMarkup(s))return r;if(i.isText&&i.text!=s.text){for(let e=0;i.text[e]==s.text[e];e++)r++;return r}if(i.content.size||s.content.size){let t=e(i.content,s.content,r+1);if(null!=t)return t}r+=i.nodeSize}else r+=i.nodeSize}}(this,e,t)}findDiffEnd(e,t=this.size,n=e.size){return function e(t,n,r,o){for(let i=t.childCount,s=n.childCount;;){if(0==i||0==s)return i==s?null:{a:r,b:o};let l=t.child(--i),a=n.child(--s),c=l.nodeSize;if(l!=a){if(!l.sameMarkup(a))return{a:r,b:o};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++,r--,o--;return{a:r,b:o}}if(l.content.size||a.content.size){let t=e(l.content,a.content,r-1,o-1);if(t)return t}r-=c,o-=c}else r-=c,o-=c}}(this,e,t,n)}findIndex(e,t=-1){if(0==e)return l(0,e);if(e==this.size)return l(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let n=0,r=0;;n++){let o=r+this.child(n).nodeSize;if(o>=e)return o==e||t>0?l(n+1,o):l(n,r);r=o}}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 i.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new i(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return i.empty;let t,n=0;for(let r=0;r<e.length;r++){let o=e[r];n+=o.nodeSize,r&&o.isText&&e[r-1].sameMarkup(o)?(t||(t=e.slice(0,r)),t[t.length-1]=o.withText(t[t.length-1].text+o.text)):t&&t.push(o)}return new i(t||e,n)}static from(e){if(!e)return i.empty;if(e instanceof i)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new i([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}i.empty=new i([],0);const s={index:0,offset:0};function l(e,t){return s.index=e,s.offset=t,s}function a(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(!a(e[n],t[n]))return!1}else{for(let n in e)if(!(n in t)||!a(e[n],t[n]))return!1;for(let n in t)if(!(n in e))return!1}return!0}class c{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,n=!1;for(let r=0;r<e.length;r++){let o=e[r];if(this.eq(o))return e;if(this.type.excludes(o.type))t||(t=e.slice(0,r));else{if(o.type.excludes(this.type))return e;!n&&o.type.rank>this.type.rank&&(t||(t=e.slice(0,r)),t.push(this),n=!0),t&&t.push(o)}}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&&a(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`);return n.create(t.attrs)}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 c.none;if(e instanceof c)return[e];let t=e.slice();return t.sort((e,t)=>e.type.rank-t.type.rank),t}}c.none=[];class d extends Error{}class u{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=function e(t,n,r,o){let{index:i,offset:s}=t.findIndex(n),l=t.maybeChild(i);if(s==n||l.isText)return o&&!o.canReplace(i,i,r)?null:t.cut(0,n).append(r).append(t.cut(n));let a=e(l.content,n-s-1,r);return a&&t.replaceChild(i,l.copy(a))}(this.content,e+this.openStart,t);return n&&new u(n,this.openStart,this.openEnd)}removeBetween(e,t){return new u(function e(t,n,r){let{index:o,offset:i}=t.findIndex(n),s=t.maybeChild(o),{index:l,offset:a}=t.findIndex(r);if(i==n||s.isText){if(a!=r&&!t.child(l).isText)throw new RangeError("Removing non-flat range");return t.cut(0,n).append(t.cut(r))}if(o!=l)throw new RangeError("Removing non-flat range");return t.replaceChild(o,s.copy(e(s.content,n-i-1,r-i-1)))}(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 u.empty;let n=t.openStart||0,r=t.openEnd||0;if("number"!=typeof n||"number"!=typeof r)throw new RangeError("Invalid input for Slice.fromJSON");return new u(i.fromJSON(e,t.content),n,r)}static maxOpen(e,t=!0){let n=0,r=0;for(let r=e.firstChild;r&&!r.isLeaf&&(t||!r.type.spec.isolating);r=r.firstChild)n++;for(let n=e.lastChild;n&&!n.isLeaf&&(t||!n.type.spec.isolating);n=n.lastChild)r++;return new u(e,n,r)}}function h(e,t,n){if(n.openStart>e.depth)throw new d("Inserted content deeper than insertion position");if(e.depth-n.openStart!=t.depth-n.openEnd)throw new d("Inconsistent open depths");return function e(t,n,r,o){let s=t.index(o),l=t.node(o);if(s==n.index(o)&&o<t.depth-r.openStart){let i=e(t,n,r,o+1);return l.copy(l.content.replaceChild(s,i))}if(r.content.size){if(r.openStart||r.openEnd||t.depth!=o||n.depth!=o){let{start:e,end:s}=function(e,t){let n=t.depth-e.openStart,r=t.node(n).copy(e.content);for(let e=n-1;e>=0;e--)r=t.node(e).copy(i.from(r));return{start:r.resolveNoCache(e.openStart+n),end:r.resolveNoCache(r.content.size-e.openEnd-n)}}(r,t);return y(l,function e(t,n,r,o,s){let l=t.depth>s&&f(t,n,s+1),a=o.depth>s&&f(r,o,s+1),c=[];g(null,t,s,c),l&&a&&n.index(s)==r.index(s)?(p(l,a),m(y(l,e(t,n,r,o,s+1)),c)):(l&&m(y(l,v(t,n,s+1)),c),g(n,r,s,c),a&&m(y(a,v(r,o,s+1)),c));return g(o,null,s,c),new i(c)}(t,e,s,n,o))}{let e=t.parent,o=e.content;return y(e,o.cut(0,t.parentOffset).append(r.content).append(o.cut(n.parentOffset)))}}return y(l,v(t,n,o))}(e,t,n,0)}function p(e,t){if(!t.type.compatibleContent(e.type))throw new d("Cannot join "+t.type.name+" onto "+e.type.name)}function f(e,t,n){let r=e.node(n);return p(r,t.node(n)),r}function m(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 g(e,t,n,r){let o=(t||e).node(n),i=0,s=t?t.index(n):o.childCount;e&&(i=e.index(n),e.depth>n?i++:e.textOffset&&(m(e.nodeAfter,r),i++));for(let e=i;e<s;e++)m(o.child(e),r);t&&t.depth==n&&t.textOffset&&m(t.nodeBefore,r)}function y(e,t){return e.type.checkContent(t),e.copy(t)}function v(e,t,n){let r=[];if(g(null,e,n,r),e.depth>n){m(y(f(e,t,n+1),v(e,t,n+1)),r)}return g(t,null,n,r),new i(r)}u.empty=new u(i.empty,0,0);class b{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],r=e.child(t);return n?e.child(t).cut(n):r}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],r=0==t?0:this.path[3*t-1]+1;for(let t=0;t<e;t++)r+=n.child(t).nodeSize;return r}marks(){let e=this.parent,t=this.index();if(0==e.content.size)return c.none;if(this.textOffset)return e.child(t).marks;let n=e.maybeChild(t-1),r=e.maybeChild(t);if(!n){let e=n;n=r,r=e}let o=n.marks;for(var i=0;i<o.length;i++)!1!==o[i].type.spec.inclusive||r&&o[i].isInSet(r.marks)||(o=o[i--].removeFromSet(o));return o}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let n=t.marks,r=e.parent.maybeChild(e.index());for(var o=0;o<n.length;o++)!1!==n[o].type.spec.inclusive||r&&n[o].isInSet(r.marks)||(n=n[o--].removeFromSet(n));return n}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 x(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=[],r=0,o=t;for(let t=e;;){let{index:e,offset:i}=t.content.findIndex(o),s=o-i;if(n.push(t,e,r+i),!s)break;if(t=t.child(e),t.isText)break;o=s-1,r+=i+1}return new b(t,n,o)}static resolveCached(e,t){for(let n=0;n<w.length;n++){let r=w[n];if(r.pos==t&&r.doc==e)return r}let n=w[S]=b.resolve(e,t);return S=(S+1)%k,n}}let w=[],S=0,k=12;class x{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 C=Object.create(null);class M{constructor(e,t,n,r=c.none){this.type=e,this.attrs=t,this.marks=r,this.content=n||i.empty}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,r=0){this.content.nodesBetween(e,t,n,r,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,r){return this.content.textBetween(e,t,n,r)}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&&a(this.attrs,t||e.defaultAttrs||C)&&c.sameSet(this.marks,n||c.none)}copy(e=null){return e==this.content?this:new M(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new M(this.type,this.attrs,this.content,e)}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 u.empty;let r=this.resolve(e),o=this.resolve(t),i=n?0:r.sharedDepth(t),s=r.start(i),l=r.node(i).content.cut(r.pos-s,o.pos-s);return new u(l,r.depth-i,o.depth-i)}replace(e,t,n){return h(this.resolve(e),this.resolve(t),n)}nodeAt(e){for(let t=this;;){let{index:n,offset:r}=t.content.findIndex(e);if(t=t.maybeChild(n),!t)return null;if(r==e||t.isText)return t;e-=r+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 r=this.content.child(t-1);return{node:r,index:t-1,offset:n-r.nodeSize}}resolve(e){return b.resolveCached(this,e)}resolveNoCache(e){return b.resolve(this,e)}rangeHasMark(e,t,n){let r=!1;return t>e&&this.nodesBetween(e,t,e=>(n.isInSet(e.marks)&&(r=!0),!r)),r}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()+")"),A(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=i.empty,r=0,o=n.childCount){let s=this.contentMatchAt(e).matchFragment(n,r,o),l=s&&s.matchFragment(this.content,t);if(!l||!l.validEnd)return!1;for(let e=r;e<o;e++)if(!this.type.allowsMarks(n.child(e).marks))return!1;return!0}canReplaceWith(e,t,n,r){if(r&&!this.type.allowsMarks(r))return!1;let o=this.contentMatchAt(e).matchType(n),i=o&&o.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);let e=c.none;for(let t=0;t<this.marks.length;t++)e=this.marks[t].addToSet(e);if(!c.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=null;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 r=i.fromJSON(e,t.content);return e.nodeType(t.type).create(t.attrs,r,n)}}M.prototype.text=void 0;class O extends M{constructor(e,t,n,r){if(super(e,t,null,r),!n)throw new RangeError("Empty text nodes are not allowed");this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):A(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 O(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new O(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 A(e,t){for(let n=e.length-1;n>=0;n--)t=e[n].type.name+"("+t+")";return t}class T{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let n=new N(e,t);if(null==n.next)return T.empty;let r=R(n);n.next&&n.err("Unexpected trailing text");let o=function(e){let t=Object.create(null);return function n(r){let o=[];r.forEach(t=>{e[t].forEach(({term:t,to:n})=>{if(!t)return;let r;for(let e=0;e<o.length;e++)o[e][0]==t&&(r=o[e][1]);I(e,n).forEach(e=>{r||o.push([t,r=[]]),-1==r.indexOf(e)&&r.push(e)})})});let i=t[r.join(",")]=new T(r.indexOf(e.length-1)>-1);for(let e=0;e<o.length;e++){let r=o[e][1].sort(z);i.next.push({type:o[e][0],next:t[r.join(",")]||n(r)})}return i}(I(e,0))}(function(e){let t=[[]];return o(function e(t,i){if("choice"==t.type)return t.exprs.reduce((t,n)=>t.concat(e(n,i)),[]);if("seq"!=t.type){if("star"==t.type){let s=n();return r(i,s),o(e(t.expr,s),s),[r(s)]}if("plus"==t.type){let s=n();return o(e(t.expr,i),s),o(e(t.expr,s),s),[r(s)]}if("opt"==t.type)return[r(i)].concat(e(t.expr,i));if("range"==t.type){let s=i;for(let r=0;r<t.min;r++){let r=n();o(e(t.expr,s),r),s=r}if(-1==t.max)o(e(t.expr,s),s);else for(let i=t.min;i<t.max;i++){let i=n();r(s,i),o(e(t.expr,s),i),s=i}return[r(s)]}if("name"==t.type)return[r(i,void 0,t.value)];throw new Error("Unknown expr type")}for(let r=0;;r++){let s=e(t.exprs[r],i);if(r==t.exprs.length-1)return s;o(s,i=n())}}(e,0),n()),t;function n(){return t.push([])-1}function r(e,n,r){let o={term:r,to:n};return t[e].push(o),o}function o(e,t){e.forEach(e=>e.to=t)}}(r));return function(e,t){for(let n=0,r=[e];n<r.length;n++){let e=r[n],o=!e.validEnd,i=[];for(let t=0;t<e.next.length;t++){let{type:n,next:s}=e.next[t];i.push(n.name),!o||n.isText||n.hasRequiredAttrs()||(o=!1),-1==r.indexOf(s)&&r.push(s)}o&&t.err("Only non-generatable nodes ("+i.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}(o,n),o}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 r=this;for(let o=t;r&&o<n;o++)r=r.matchType(e.child(o).type);return r}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 r=[this];return function o(s,l){let a=s.matchFragment(e,n);if(a&&(!t||a.validEnd))return i.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==r.indexOf(n)){r.push(n);let e=o(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 r=n.shift(),o=r.match;if(o.matchType(e)){let e=[];for(let t=r;t.type;t=t.via)e.push(t.type);return e.reverse()}for(let e=0;e<o.next.length;e++){let{type:i,next:s}=o.next[e];i.isLeaf||i.hasRequiredAttrs()||i.name in t||r.type&&!s.validEnd||(n.push({match:i.contentMatch,type:i,via:r}),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 r=0;r<n.next.length;r++)-1==e.indexOf(n.next[r].next)&&t(n.next[r].next)}(this),e.map((t,n)=>{let r=n+(t.validEnd?"*":" ")+" ";for(let n=0;n<t.next.length;n++)r+=(n?", ":"")+t.next[n].type.name+"->"+e.indexOf(t.next[n].next);return r}).join("\n")}}T.empty=new T(!0);class N{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 R(e){let t=[];do{t.push(D(e))}while(e.eat("|"));return 1==t.length?t[0]:{type:"choice",exprs:t}}function D(e){let t=[];do{t.push(_(e))}while(e.next&&")"!=e.next&&"|"!=e.next);return 1==t.length?t[0]:{type:"seq",exprs:t}}function _(e){let t=function(e){if(e.eat("(")){let t=R(e);return e.eat(")")||e.err("Missing closing paren"),t}if(!/\W/.test(e.next)){let t=function(e,t){let n=e.nodeTypes,r=n[t];if(r)return[r];let o=[];for(let e in n){let r=n[e];r.groups.indexOf(t)>-1&&o.push(r)}0==o.length&&e.err("No node type or group '"+t+"' found");return o}(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 E(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=E(e),r=n;return e.eat(",")&&(r="}"!=e.next?E(e):-1),e.eat("}")||e.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:t}}function z(e,t){return t-e}function I(e,t){let n=[];return function t(r){let o=e[r];if(1==o.length&&!o[0].term)return t(o[0].to);n.push(r);for(let e=0;e<o.length;e++){let{term:r,to:i}=o[e];r||-1!=n.indexOf(i)||t(i)}}(t),n.sort(z)}function F(e){let t=Object.create(null);for(let n in e){let r=e[n];if(!r.hasDefault)return null;t[n]=r.default}return t}function B(e,t){let n=Object.create(null);for(let r in e){let o=t&&t[r];if(void 0===o){let t=e[r];if(!t.hasDefault)throw new RangeError("No value supplied for attribute "+r);o=t.default}n[r]=o}return n}function j(e){let t=Object.create(null);if(e)for(let n in e)t[n]=new L(e[n]);return t}class ${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=j(n.attrs),this.defaultAttrs=F(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==T.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}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:B(this.attrs,e)}create(e=null,t,n){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new M(this,this.computeAttrs(e),i.from(t),c.setFrom(n))}createChecked(e=null,t,n){return t=i.from(t),this.checkContent(t),new M(this,this.computeAttrs(e),t,c.setFrom(n))}createAndFill(e=null,t,n){if(e=this.computeAttrs(e),(t=i.from(t)).size){let e=this.contentMatch.fillBefore(t);if(!e)return null;t=e.append(t)}let r=this.contentMatch.matchFragment(t),o=r&&r.fillBefore(i.empty,!0);return o?new M(this,e,t.append(o),c.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)}`)}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:c.none:e}static compile(e,t){let n=Object.create(null);e.forEach((e,r)=>n[e]=new $(e,t,r));let r=t.spec.topNode||"doc";if(!n[r])throw new RangeError("Schema is missing its top node type ('"+r+"')");if(!n.text)throw new RangeError("Every schema needs a 'text' type");for(let e in n.text.attrs)throw new RangeError("The text node type should not have attributes");return n}}class L{constructor(e){this.hasDefault=Object.prototype.hasOwnProperty.call(e,"default"),this.default=e.default}get isRequired(){return!this.hasDefault}}class V{constructor(e,t,n,r){this.name=e,this.rank=t,this.schema=n,this.spec=r,this.attrs=j(r.attrs),this.excluded=null;let o=F(this.attrs);this.instance=o?new c(this,o):null}create(e=null){return!e&&this.instance?this.instance:new c(this,B(this.attrs,e))}static compile(e,t){let n=Object.create(null),r=0;return e.forEach((e,o)=>n[e]=new V(e,r++,t,o)),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]}excludes(e){return this.excluded.indexOf(e)>-1}}class K{constructor(e){this.cached=Object.create(null);let t=this.spec={};for(let n in e)t[n]=e[n];t.nodes=o.from(e.nodes),t.marks=o.from(e.marks||{}),this.nodes=$.compile(this.spec.nodes,this),this.marks=V.compile(this.spec.marks,this);let n=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],r=t.spec.content||"",o=t.spec.marks;t.contentMatch=n[r]||(n[r]=T.parse(r,this.nodes)),t.inlineContent=t.contentMatch.inlineContent,t.markSet="_"==o?null:o?H(this,o.split(" ")):""!=o&&t.inlineContent?null:[]}for(let e in this.marks){let t=this.marks[e],n=t.spec.excludes;t.excluded=null==n?[t]:""==n?[]:H(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,r){if("string"==typeof e)e=this.nodeType(e);else{if(!(e instanceof $))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,r)}text(e,t){let n=this.nodes.text;return new O(n,n.defaultAttrs,e,c.setFrom(t))}mark(e,t){return"string"==typeof e&&(e=this.marks[e]),e.create(t)}nodeFromJSON(e){return M.fromJSON(this,e)}markFromJSON(e){return c.fromJSON(this,e)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}}function H(e,t){let n=[];for(let r=0;r<t.length;r++){let o=t[r],i=e.marks[o],s=i;if(i)n.push(i);else for(let t in e.marks){let r=e.marks[t];("_"==o||r.spec.group&&r.spec.group.split(" ").indexOf(o)>-1)&&n.push(s=r)}if(!s)throw new SyntaxError("Unknown mark type: '"+t[r]+"'")}return n}class W{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[],t.forEach(e=>{e.tag?this.tags.push(e):e.style&&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 Y(this,t,!1);return n.addAll(e,t.from,t.to),n.finish()}parseSlice(e,t={}){let n=new Y(this,t,!0);return n.addAll(e,t.from,t.to),u.maxOpen(n.finish())}matchTag(e,t,n){for(let r=n?this.tags.indexOf(n)+1:0;r<this.tags.length;r++){let n=this.tags[r];if(Q(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,r){for(let o=r?this.styles.indexOf(r)+1:0;o<this.styles.length;o++){let r=this.styles[o],i=r.style;if(!(0!=i.indexOf(e)||r.context&&!n.matchesContext(r.context)||i.length>e.length&&(61!=i.charCodeAt(e.length)||i.slice(e.length+1)!=t))){if(r.getAttrs){let e=r.getAttrs(t);if(!1===e)continue;r.attrs=e||void 0}return r}}}static schemaRules(e){let t=[];function n(e){let n=null==e.priority?50:e.priority,r=0;for(;r<t.length;r++){let e=t[r];if((null==e.priority?50:e.priority)<n)break}t.splice(r,0,e)}for(let t in e.marks){let r=e.marks[t].spec.parseDOM;r&&r.forEach(e=>{n(e=Z(e)),e.mark||e.ignore||e.clearMark||(e.mark=t)})}for(let t in e.nodes){let r=e.nodes[t].spec.parseDOM;r&&r.forEach(e=>{n(e=Z(e)),e.node||e.ignore||e.mark||(e.node=t)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new W(e,W.schemaRules(e)))}}const q={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},J={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},U={ol:!0,ul:!0};function X(e,t,n){return null!=t?(t?1:0)|("full"===t?2:0):e&&"pre"==e.whitespace?3:-5&n}class G{constructor(e,t,n,r,o,i,s){this.type=e,this.attrs=t,this.marks=n,this.pendingMarks=r,this.solid=o,this.options=s,this.content=[],this.activeMarks=c.none,this.stashMarks=[],this.match=i||(4&s?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(i.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=i.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(i.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}popFromStashMark(e){for(let t=this.stashMarks.length-1;t>=0;t--)if(e.eq(this.stashMarks[t]))return this.stashMarks.splice(t,1)[0]}applyPending(e){for(let t=0,n=this.pendingMarks;t<n.length;t++){let r=n[t];(this.type?this.type.allowsMarkType(r.type):ee(r.type,e))&&!r.isInSet(this.activeMarks)&&(this.activeMarks=r.addToSet(this.activeMarks),this.pendingMarks=r.removeFromSet(this.pendingMarks))}}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!q.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class Y{constructor(e,t,n){this.parser=e,this.options=t,this.isOpen=n,this.open=0;let r,o=t.topNode,i=X(null,t.preserveWhitespace,0)|(n?4:0);r=o?new G(o.type,o.attrs,c.none,c.none,!0,t.topMatch||o.type.contentMatch,i):new G(n?null:e.schema.topNodeType,null,c.none,c.none,!0,null,i),this.nodes=[r],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e){3==e.nodeType?this.addTextNode(e):1==e.nodeType&&this.addElement(e)}withStyleRules(e,t){let n=e.getAttribute("style");if(!n)return t();let r=this.readStyles(function(e){let t,n=/\s*([\w-]+)\s*:\s*([^;]+)/g,r=[];for(;t=n.exec(e);)r.push(t[1],t[2].trim());return r}(n));if(!r)return;let[o,i]=r,s=this.top;for(let e=0;e<i.length;e++)this.removePendingMark(i[e],s);for(let e=0;e<o.length;e++)this.addPendingMark(o[e]);t();for(let e=0;e<o.length;e++)this.removePendingMark(o[e],s);for(let e=0;e<i.length;e++)this.addPendingMark(i[e])}addTextNode(e){let t=e.nodeValue,n=this.top;if(2&n.options||n.inlineContext(e)||/[^ \t\r\n\u000c]/.test(t)){if(1&n.options)t=2&n.options?t.replace(/\r\n?/g,"\n"):t.replace(/\r?\n|\r/g," ");else if(t=t.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(t)&&this.open==this.nodes.length-1){let r=n.content[n.content.length-1],o=e.previousSibling;(!r||o&&"BR"==o.nodeName||r.isText&&/[ \t\r\n\u000c]$/.test(r.text))&&(t=t.slice(1))}t&&this.insertNode(this.parser.schema.text(t)),this.findInText(e)}else this.findInside(e)}addElement(e,t){let n,r=e.nodeName.toLowerCase();U.hasOwnProperty(r)&&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&&U.hasOwnProperty(e)&&n?(n.appendChild(t),t=n):"li"==e?n=t:e&&(n=null)}}(e);let o=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(n=this.parser.matchTag(e,this,t));if(o?o.ignore:J.hasOwnProperty(r))this.findInside(e),this.ignoreFallback(e);else if(!o||o.skip||o.closeParent){o&&o.closeParent?this.open=Math.max(0,this.open-1):o&&o.skip.nodeType&&(e=o.skip);let t,n=this.top,i=this.needsBlock;if(q.hasOwnProperty(r))n.content.length&&n.content[0].isInline&&this.open&&(this.open--,n=this.top),t=!0,n.type||(this.needsBlock=!0);else if(!e.firstChild)return void this.leafFallback(e);o&&o.skip?this.addAll(e):this.withStyleRules(e,()=>this.addAll(e)),t&&this.sync(n),this.needsBlock=i}else this.withStyleRules(e,()=>{this.addElementByRule(e,o,!1===o.consuming?n:void 0)})}leafFallback(e){"BR"==e.nodeName&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode("\n"))}ignoreFallback(e){"BR"!=e.nodeName||this.top.type&&this.top.type.inlineContent||this.findPlace(this.parser.schema.text("-"))}readStyles(e){let t=c.none,n=c.none;for(let r=0;r<e.length;r+=2)for(let o=void 0;;){let i=this.parser.matchStyle(e[r],e[r+1],this,o);if(!i)break;if(i.ignore)return null;if(i.clearMark?this.top.pendingMarks.concat(this.top.activeMarks).forEach(e=>{i.clearMark(e)&&(n=e.addToSet(n))}):t=this.parser.schema.marks[i.mark].create(i.attrs).addToSet(t),!1!==i.consuming)break;o=i}return[t,n]}addElementByRule(e,t,n){let r,o,i;if(t.node)o=this.parser.schema.nodes[t.node],o.isLeaf?this.insertNode(o.create(t.attrs))||this.leafFallback(e):r=this.enter(o,t.attrs||null,t.preserveWhitespace);else{i=this.parser.schema.marks[t.mark].create(t.attrs),this.addPendingMark(i)}let s=this.top;if(o&&o.isLeaf)this.findInside(e);else if(n)this.addElement(e,n);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(e=>this.insertNode(e));else{let n=e;"string"==typeof t.contentElement?n=e.querySelector(t.contentElement):"function"==typeof t.contentElement?n=t.contentElement(e):t.contentElement&&(n=t.contentElement),this.findAround(e,n,!0),this.addAll(n)}r&&this.sync(s)&&this.open--,i&&this.removePendingMark(i,s)}addAll(e,t,n){let r=t||0;for(let o=t?e.childNodes[t]:e.firstChild,i=null==n?null:e.childNodes[n];o!=i;o=o.nextSibling,++r)this.findAtPoint(e,r),this.addDOM(o);this.findAtPoint(e,r)}findPlace(e){let t,n;for(let r=this.open;r>=0;r--){let o=this.nodes[r],i=o.findWrapping(e);if(i&&(!t||t.length>i.length)&&(t=i,n=o,!i.length))break;if(o.solid)break}if(!t)return!1;this.sync(n);for(let e=0;e<t.length;e++)this.enterInner(t[e],null,!1);return!0}insertNode(e){if(e.isInline&&this.needsBlock&&!this.top.type){let e=this.textblockFromContext();e&&this.enterInner(e)}if(this.findPlace(e)){this.closeExtra();let t=this.top;t.applyPending(e.type),t.match&&(t.match=t.match.matchType(e.type));let n=t.activeMarks;for(let r=0;r<e.marks.length;r++)t.type&&!t.type.allowsMarkType(e.marks[r].type)||(n=e.marks[r].addToSet(n));return t.content.push(e.mark(n)),!0}return!1}enter(e,t,n){let r=this.findPlace(e.create(t));return r&&this.enterInner(e,t,!0,n),r}enterInner(e,t=null,n=!1,r){this.closeExtra();let o=this.top;o.applyPending(e),o.match=o.match&&o.match.matchType(e);let i=X(e,r,o.options);4&o.options&&0==o.content.length&&(i|=4),this.nodes.push(new G(e,t,o.activeMarks,o.pendingMarks,n,null,i)),this.open++}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;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 r=0;r<this.find.length;r++)if(null==this.find[r].pos&&1==e.nodeType&&e.contains(this.find[r].node)){t.compareDocumentPosition(this.find[r].node)&(n?2:4)&&(this.find[r].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,r=!(this.isOpen||n&&n.parent.type!=this.nodes[0].type),o=-(n?n.depth+1:0)+(r?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>=o;s--)if(i(e-1,s))return!0;return!1}{let e=s>0||0==s&&r?this.nodes[s].type:n&&s>=o?n.node(s-o).type:null;if(!e||e.name!=l&&-1==e.groups.indexOf(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}}addPendingMark(e){let t=function(e,t){for(let n=0;n<t.length;n++)if(e.eq(t[n]))return t[n]}(e,this.top.pendingMarks);t&&this.top.stashMarks.push(t),this.top.pendingMarks=e.addToSet(this.top.pendingMarks)}removePendingMark(e,t){for(let n=this.open;n>=0;n--){let r=this.nodes[n];if(r.pendingMarks.lastIndexOf(e)>-1)r.pendingMarks=e.removeFromSet(r.pendingMarks);else{r.activeMarks=e.removeFromSet(r.activeMarks);let t=r.popFromStashMark(e);t&&r.type&&r.type.allowsMarkType(t.type)&&(r.activeMarks=t.addToSet(r.activeMarks))}if(r==t)break}}}function Q(e,t){return(e.matches||e.msMatchesSelector||e.webkitMatchesSelector||e.mozMatchesSelector).call(e,t)}function Z(e){let t={};for(let n in e)t[n]=e[n];return t}function ee(e,t){let n=t.schema.nodes;for(let r in n){let o=n[r];if(!o.allowsMarkType(e))continue;let i=[],s=e=>{i.push(e);for(let n=0;n<e.edgeCount;n++){let{type:r,next:o}=e.edge(n);if(r==t)return!0;if(i.indexOf(o)<0&&s(o))return!0}};if(s(o.contentMatch))return!0}}class te{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},n){n||(n=re(t).createDocumentFragment());let r=n,o=[];return e.forEach(e=>{if(o.length||e.marks.length){let n=0,i=0;for(;n<o.length&&i<e.marks.length;){let t=e.marks[i];if(this.marks[t.type.name]){if(!t.eq(o[n][0])||!1===t.type.spec.spanning)break;n++,i++}else i++}for(;n<o.length;)r=o.pop()[1];for(;i<e.marks.length;){let n=e.marks[i++],s=this.serializeMark(n,e.isInline,t);s&&(o.push([n,r]),r.appendChild(s.dom),r=s.contentDOM||s.dom)}}r.appendChild(this.serializeNodeInner(e,t))}),n}serializeNodeInner(e,t){let{dom:n,contentDOM:r}=te.renderSpec(re(t),this.nodes[e.type.name](e));if(r){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,r)}return n}serializeNode(e,t={}){let n=this.serializeNodeInner(e,t);for(let r=e.marks.length-1;r>=0;r--){let o=this.serializeMark(e.marks[r],e.isInline,t);o&&((o.contentDOM||o.dom).appendChild(n),n=o.dom)}return n}serializeMark(e,t,n={}){let r=this.marks[e.type.name];return r&&te.renderSpec(re(n),r(e,t))}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 r,o=t[0],i=o.indexOf(" ");i>0&&(n=o.slice(0,i),o=o.slice(i+1));let s=n?e.createElementNS(n,o):e.createElement(o),l=t[1],a=1;if(l&&"object"==typeof l&&null==l.nodeType&&!Array.isArray(l)){a=2;for(let e in l)if(null!=l[e]){let t=e.indexOf(" ");t>0?s.setAttributeNS(e.slice(0,t),e.slice(t+1),l[e]):s.setAttribute(e,l[e])}}for(let o=a;o<t.length;o++){let i=t[o];if(0===i){if(o<t.length-1||o>a)throw new RangeError("Content hole must be the only child of its parent node");return{dom:s,contentDOM:s}}{let{dom:t,contentDOM:o}=te.renderSpec(e,i,n);if(s.appendChild(t),o){if(r)throw new RangeError("Multiple content holes");r=o}}}return{dom:s,contentDOM:r}}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new te(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=ne(e.nodes);return t.text||(t.text=e=>e.text),t}static marksFromSchema(e){return ne(e.marks)}}function ne(e){let t={};for(let n in e){let r=e[n].spec.toDOM;r&&(t[n]=r)}return t}function re(e){return e.document||window.document}},function(e,t,n){"use strict";n.r(t),n.d(t,"AllSelection",(function(){return f})),n.d(t,"EditorState",(function(){return x})),n.d(t,"NodeSelection",(function(){return h})),n.d(t,"Plugin",(function(){return C})),n.d(t,"PluginKey",(function(){return A})),n.d(t,"Selection",(function(){return s})),n.d(t,"SelectionRange",(function(){return l})),n.d(t,"TextSelection",(function(){return d})),n.d(t,"Transaction",(function(){return v}));var r=n(0),o=n(2);const i=Object.create(null);class s{constructor(e,t,n){this.$anchor=e,this.$head=t,this.ranges=n||[new l(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=r.Slice.empty){let n=t.content.lastChild,o=null;for(let e=0;e<t.openEnd;e++)o=n,n=n.lastChild;let i=e.steps.length,s=this.ranges;for(let l=0;l<s.length;l++){let{$from:a,$to:c}=s[l],d=e.mapping.slice(i);e.replaceRange(d.map(a.pos),d.map(c.pos),l?r.Slice.empty:t),0==l&&y(e,i,(n?n.isInline:o&&o.isTextblock)?-1:1)}}replaceWith(e,t){let n=e.steps.length,r=this.ranges;for(let o=0;o<r.length;o++){let{$from:i,$to:s}=r[o],l=e.mapping.slice(n),a=l.map(i.pos),c=l.map(s.pos);o?e.deleteRange(a,c):(e.replaceRangeWith(a,c,t),y(e,n,t.isInline?-1:1))}}static findFrom(e,t,n=!1){let r=e.parent.inlineContent?new d(e):g(e.node(0),e.parent,e.pos,e.index(),t,n);if(r)return r;for(let r=e.depth-1;r>=0;r--){let o=t<0?g(e.node(0),e.node(r),e.before(r+1),e.index(r),t,n):g(e.node(0),e.node(r),e.after(r+1),e.index(r)+1,t,n);if(o)return o}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new f(e.node(0))}static atStart(e){return g(e,e,0,0,1)||new f(e)}static atEnd(e){return g(e,e,e.content.size,e.childCount,-1)||new f(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let n=i[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 i)throw new RangeError("Duplicate use of selection JSON ID "+e);return i[e]=t,t.prototype.jsonID=e,t}getBookmark(){return d.between(this.$anchor,this.$head).getBookmark()}}s.prototype.visible=!0;class l{constructor(e,t){this.$from=e,this.$to=t}}let a=!1;function c(e){a||e.parent.inlineContent||(a=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+e.parent.type.name+")"))}class d extends s{constructor(e,t=e){c(e),c(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 s.near(n);let r=e.resolve(t.map(this.anchor));return new d(r.parent.inlineContent?r:n,n)}replace(e,t=r.Slice.empty){if(super.replace(e,t),t==r.Slice.empty){let t=this.$from.marksAcross(this.$to);t&&e.ensureMarks(t)}}eq(e){return e instanceof d&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new u(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 d(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,n=t){let r=e.resolve(t);return new this(r,n==t?r:e.resolve(n))}static between(e,t,n){let r=e.pos-t.pos;if(n&&!r||(n=r>=0?1:-1),!t.parent.inlineContent){let e=s.findFrom(t,n,!0)||s.findFrom(t,-n,!0);if(!e)return s.near(t,n);t=e.$head}return e.parent.inlineContent||(0==r||(e=(s.findFrom(e,-n,!0)||s.findFrom(e,n,!0)).$anchor).pos<t.pos!=r<0)&&(e=t),new d(e,t)}}s.jsonID("text",d);class u{constructor(e,t){this.anchor=e,this.head=t}map(e){return new u(e.map(this.anchor),e.map(this.head))}resolve(e){return d.between(e.resolve(this.anchor),e.resolve(this.head))}}class h extends s{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:r}=t.mapResult(this.anchor),o=e.resolve(r);return n?s.near(o):new h(o)}content(){return new r.Slice(r.Fragment.from(this.node),0,0)}eq(e){return e instanceof h&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new p(this.anchor)}static fromJSON(e,t){if("number"!=typeof t.anchor)throw new RangeError("Invalid input for NodeSelection.fromJSON");return new h(e.resolve(t.anchor))}static create(e,t){return new h(e.resolve(t))}static isSelectable(e){return!e.isText&&!1!==e.type.spec.selectable}}h.prototype.visible=!1,s.jsonID("node",h);class p{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:n}=e.mapResult(this.anchor);return t?new u(n,n):new p(n)}resolve(e){let t=e.resolve(this.anchor),n=t.nodeAfter;return n&&h.isSelectable(n)?new h(t):s.near(t)}}class f extends s{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=r.Slice.empty){if(t==r.Slice.empty){e.delete(0,e.doc.content.size);let t=s.atStart(e.doc);t.eq(e.selection)||e.setSelection(t)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new f(e)}map(e){return new f(e)}eq(e){return e instanceof f}getBookmark(){return m}}s.jsonID("all",f);const m={map(){return this},resolve:e=>new f(e)};function g(e,t,n,r,o,i=!1){if(t.inlineContent)return d.create(e,n);for(let s=r-(o>0?0:1);o>0?s<t.childCount:s>=0;s+=o){let r=t.child(s);if(r.isAtom){if(!i&&h.isSelectable(r))return h.create(e,n-(o<0?r.nodeSize:0))}else{let t=g(e,r,n+o,o<0?r.childCount:0,o,i);if(t)return t}n+=r.nodeSize*o}return null}function y(e,t,n){let r=e.steps.length-1;if(r<t)return;let i,l=e.steps[r];(l instanceof o.ReplaceStep||l instanceof o.ReplaceAroundStep)&&(e.mapping.maps[r].forEach((e,t,n,r)=>{null==i&&(i=r)}),e.setSelection(s.near(e.doc.resolve(i),n)))}class v extends o.Transform{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&(1|this.updated),this.storedMarks=null,this}get selectionSet(){return(1&this.updated)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=2,this}ensureMarks(e){return r.Mark.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)||r.Mark.none))),n.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,n){let r=this.doc.type.schema;if(null==t)return e?this.replaceSelectionWith(r.text(e),!0):this.deleteSelection();{if(null==n&&(n=t),n=null==n?t:n,!e)return this.deleteRange(t,n);let o=this.storedMarks;if(!o){let e=this.doc.resolve(t);o=n==t?e.marks():e.marksAcross(this.doc.resolve(n))}return this.replaceRangeWith(t,n,r.text(e,o)),this.selection.empty||this.setSelection(s.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 b(e,t){return t&&e?e.bind(t):e}class w{constructor(e,t,n){this.name=e,this.init=b(t.init,n),this.apply=b(t.apply,n)}}const S=[new w("doc",{init:e=>e.doc||e.schema.topNodeType.createAndFill(),apply:e=>e.doc}),new w("selection",{init:(e,t)=>e.selection||s.atStart(t.doc),apply:e=>e.selection}),new w("storedMarks",{init:e=>e.storedMarks||null,apply:(e,t,n,r)=>r.selection.$cursor?e.storedMarks:null}),new w("scrollToSelection",{init:()=>0,apply:(e,t)=>e.scrolledIntoView?t+1:t})];class k{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=S.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 w(e.key,e.spec.state,e))})}}class x{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),r=null;for(;;){let o=!1;for(let i=0;i<this.config.plugins.length;i++){let s=this.config.plugins[i];if(s.spec.appendTransaction){let l=r?r[i].n:0,a=r?r[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),!r){r=[];for(let e=0;e<this.config.plugins.length;e++)r.push(e<i?{state:n,n:t.length}:{state:this,n:0})}t.push(c),n=n.applyInner(c),o=!0}r&&(r[i]={state:n,n:t.length})}}if(!o)return{state:n,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let t=new x(this.config),n=this.config.fields;for(let r=0;r<n.length;r++){let o=n[r];t[o.name]=o.apply(e,this[o.name],this,t)}return t}get tr(){return new v(this)}static create(e){let t=new k(e.doc?e.doc.type.schema:e.schema,e.plugins),n=new x(t);for(let r=0;r<t.fields.length;r++)n[t.fields[r].name]=t.fields[r].init(e,n);return n}reconfigure(e){let t=new k(this.schema,e.plugins),n=t.fields,r=new x(t);for(let t=0;t<n.length;t++){let o=n[t].name;r[o]=this.hasOwnProperty(o)?this[o]:n[t].init(e,r)}return r}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 r=e[n],o=r.spec.state;o&&o.toJSON&&(t[n]=o.toJSON.call(r,this[r.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 k(e.schema,e.plugins),i=new x(o);return o.fields.forEach(o=>{if("doc"==o.name)i.doc=r.Node.fromJSON(e.schema,t.doc);else if("selection"==o.name)i.selection=s.fromJSON(i.doc,t.selection);else if("storedMarks"==o.name)t.storedMarks&&(i.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(n)for(let r in n){let s=n[r],l=s.spec.state;if(s.key==o.name&&l&&l.fromJSON&&Object.prototype.hasOwnProperty.call(t,r))return void(i[o.name]=l.fromJSON.call(s,e,t[r],i))}i[o.name]=o.init(e,i)}}),i}}class C{constructor(e){this.spec=e,this.props={},e.props&&function e(t,n,r){for(let o in t){let i=t[o];i instanceof Function?i=i.bind(n):"handleDOMEvents"==o&&(i=e(i,n,{})),r[o]=i}return r}(e.props,this,this.props),this.key=e.key?e.key.key:O("plugin")}getState(e){return e[this.key]}}const M=Object.create(null);function O(e){return e in M?e+"$"+ ++M[e]:(M[e]=0,e+"$")}class A{constructor(e="key"){this.key=O(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}},function(e,t,n){"use strict";n.r(t),n.d(t,"AddMarkStep",(function(){return p})),n.d(t,"AddNodeMarkStep",(function(){return m})),n.d(t,"AttrStep",(function(){return L})),n.d(t,"MapResult",(function(){return s})),n.d(t,"Mapping",(function(){return a})),n.d(t,"RemoveMarkStep",(function(){return f})),n.d(t,"RemoveNodeMarkStep",(function(){return g})),n.d(t,"ReplaceAroundStep",(function(){return v})),n.d(t,"ReplaceStep",(function(){return y})),n.d(t,"Step",(function(){return d})),n.d(t,"StepMap",(function(){return l})),n.d(t,"StepResult",(function(){return u})),n.d(t,"Transform",(function(){return K})),n.d(t,"TransformError",(function(){return V})),n.d(t,"canJoin",(function(){return M})),n.d(t,"canSplit",(function(){return C})),n.d(t,"dropPoint",(function(){return N})),n.d(t,"findWrapping",(function(){return k})),n.d(t,"insertPoint",(function(){return T})),n.d(t,"joinPoint",(function(){return A})),n.d(t,"liftTarget",(function(){return S})),n.d(t,"replaceStep",(function(){return R}));var r=n(0);const o=Math.pow(2,16);function i(e){return 65535&e}class s{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 l{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&l.empty)return l.empty}recover(e){let t=0,n=i(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))/o}(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 r=0,i=this.inverted?2:1,l=this.inverted?1:2;for(let a=0;a<this.ranges.length;a+=3){let c=this.ranges[a]-(this.inverted?r:0);if(c>e)break;let d=this.ranges[a+i],u=this.ranges[a+l],h=c+d;if(e<=h){let i=c+r+((d?e==c?-1:e==h?1:t:t)<0?0:u);if(n)return i;let l=e==(t<0?c:h)?null:a/3+(e-c)*o,p=e==c?2:e==h?1:4;return(t<0?e!=c:e!=h)&&(p|=8),new s(i,p,l)}r+=u-d}return n?e+r:new s(e+r,0,null)}touches(e,t){let n=0,r=i(t),o=this.inverted?2:1,s=this.inverted?1:2;for(let t=0;t<this.ranges.length;t+=3){let i=this.ranges[t]-(this.inverted?n:0);if(i>e)break;let l=this.ranges[t+o];if(e<=i+l&&t==3*r)return!0;n+=this.ranges[t+s]-l}return!1}forEach(e){let t=this.inverted?2:1,n=this.inverted?1:2;for(let r=0,o=0;r<this.ranges.length;r+=3){let i=this.ranges[r],s=i-(this.inverted?o:0),l=i+(this.inverted?0:o),a=this.ranges[r+t],c=this.ranges[r+n];e(s,s+a,l,l+c),o+=c-a}}invert(){return new l(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return 0==e?l.empty:new l(e<0?[0,-e,0]:[0,0,e])}}l.empty=new l([]);class a{constructor(e=[],t,n=0,r=e.length){this.maps=e,this.mirror=t,this.from=n,this.to=r}slice(e=0,t=this.maps.length){return new a(this.maps,this.mirror,e,t)}copy(){return new a(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 r=e.getMirror(t);this.appendMap(e.maps[t],null!=r&&r<t?n+r: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 r=e.getMirror(t);this.appendMap(e.maps[t].invert(),null!=r&&r>t?n-r-1:void 0)}}invert(){let e=new a;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 r=0;for(let n=this.from;n<this.to;n++){let o=this.maps[n].mapResult(e,t);if(null!=o.recover){let t=this.getMirror(n);if(null!=t&&t>n&&t<this.to){n=t,e=this.maps[t].recover(o.recover);continue}}r|=o.delInfo,e=o.pos}return n?e:new s(e,r,null)}}const c=Object.create(null);class d{getMap(){return l.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let n=c[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 c)throw new RangeError("Duplicate use of step JSON ID "+e);return c[e]=t,t.prototype.jsonID=e,t}}class u{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new u(e,null)}static fail(e){return new u(null,e)}static fromReplace(e,t,n,o){try{return u.ok(e.replace(t,n,o))}catch(e){if(e instanceof r.ReplaceError)return u.fail(e.message);throw e}}}function h(e,t,n){let o=[];for(let r=0;r<e.childCount;r++){let i=e.child(r);i.content.size&&(i=i.copy(h(i.content,t,i))),i.isInline&&(i=t(i,n,r)),o.push(i)}return r.Fragment.fromArray(o)}class p extends d{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)),i=new r.Slice(h(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 u.fromReplace(e,this.from,this.to,i)}invert(){return new f(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 p(t.pos,n.pos,this.mark)}merge(e){return e instanceof p&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new p(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 p(t.from,t.to,e.markFromJSON(t.mark))}}d.jsonID("addMark",p);class f extends d{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 r.Slice(h(t.content,e=>e.mark(this.mark.removeFromSet(e.marks)),e),t.openStart,t.openEnd);return u.fromReplace(e,this.from,this.to,n)}invert(){return new p(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 f(t.pos,n.pos,this.mark)}merge(e){return e instanceof f&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new f(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 f(t.from,t.to,e.markFromJSON(t.mark))}}d.jsonID("removeMark",f);class m extends d{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return u.fail("No node at mark step's position");let n=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return u.fromReplace(e,this.pos,this.pos+1,new r.Slice(r.Fragment.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 m(this.pos,t.marks[n]);return new m(this.pos,this.mark)}}return new g(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new m(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 m(t.pos,e.markFromJSON(t.mark))}}d.jsonID("addNodeMark",m);class g extends d{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return u.fail("No node at mark step's position");let n=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return u.fromReplace(e,this.pos,this.pos+1,new r.Slice(r.Fragment.from(n),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return t&&this.mark.isInSet(t.marks)?new m(this.pos,this.mark):this}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new g(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 g(t.pos,e.markFromJSON(t.mark))}}d.jsonID("removeNodeMark",g);class y extends d{constructor(e,t,n,r=!1){super(),this.from=e,this.to=t,this.slice=n,this.structure=r}apply(e){return this.structure&&b(e,this.from,this.to)?u.fail("Structure replace would overwrite content"):u.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new l([this.from,this.to-this.from,this.slice.size])}invert(e){return new y(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 y(t.pos,Math.max(t.pos,n.pos),this.slice)}merge(e){if(!(e instanceof y)||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?r.Slice.empty:new r.Slice(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new y(e.from,this.to,t,this.structure)}}{let t=this.slice.size+e.slice.size==0?r.Slice.empty:new r.Slice(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new y(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 y(t.from,t.to,r.Slice.fromJSON(e,t.slice),!!t.structure)}}d.jsonID("replace",y);class v extends d{constructor(e,t,n,r,o,i,s=!1){super(),this.from=e,this.to=t,this.gapFrom=n,this.gapTo=r,this.slice=o,this.insert=i,this.structure=s}apply(e){if(this.structure&&(b(e,this.from,this.gapFrom)||b(e,this.gapTo,this.to)))return u.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return u.fail("Gap is not a flat range");let n=this.slice.insertAt(this.insert,t.content);return n?u.fromReplace(e,this.from,this.to,n):u.fail("Content does not fit in gap")}getMap(){return new l([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 v(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),r=e.map(this.gapFrom,-1),o=e.map(this.gapTo,1);return t.deletedAcross&&n.deletedAcross||r<t.pos||o>n.pos?null:new v(t.pos,n.pos,r,o,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 v(t.from,t.to,t.gapFrom,t.gapTo,r.Slice.fromJSON(e,t.slice),t.insert,!!t.structure)}}function b(e,t,n){let r=e.resolve(t),o=n-t,i=r.depth;for(;o>0&&i>0&&r.indexAfter(i)==r.node(i).childCount;)i--,o--;if(o>0){let e=r.node(i).maybeChild(r.indexAfter(i));for(;o>0;){if(!e||e.isLeaf)return!0;e=e.firstChild,o--}}return!1}function w(e,t,n){return(0==t||e.canReplace(t,e.childCount))&&(n==e.childCount||e.canReplace(0,n))}function S(e){let t=e.parent.content.cutByIndex(e.startIndex,e.endIndex);for(let n=e.depth;;--n){let r=e.$from.node(n),o=e.$from.index(n),i=e.$to.indexAfter(n);if(n<e.depth&&r.canReplace(o,i,t))return n;if(0==n||r.type.spec.isolating||!w(r,o,i))break}return null}function k(e,t,n=null,r=e){let o=function(e,t){let{parent:n,startIndex:r,endIndex:o}=e,i=n.contentMatchAt(r).findWrapping(t);if(!i)return null;let s=i.length?i[0]:t;return n.canReplaceWith(r,o,s)?i:null}(e,t),i=o&&function(e,t){let{parent:n,startIndex:r,endIndex:o}=e,i=n.child(r),s=t.contentMatch.findWrapping(i.type);if(!s)return null;let l=(s.length?s[s.length-1]:t).contentMatch;for(let e=r;l&&e<o;e++)l=l.matchType(n.child(e).type);return l&&l.validEnd?s:null}(r,t);return i?o.map(x).concat({type:t,attrs:n}).concat(i.map(x)):null}function x(e){return{type:e,attrs:null}}function C(e,t,n=1,r){let o=e.resolve(t),i=o.depth-n,s=r&&r[r.length-1]||o.parent;if(i<0||o.parent.type.spec.isolating||!o.parent.canReplace(o.index(),o.parent.childCount)||!s.type.validContent(o.parent.content.cutByIndex(o.index(),o.parent.childCount)))return!1;for(let e=o.depth-1,t=n-2;e>i;e--,t--){let n=o.node(e),i=o.index(e);if(n.type.spec.isolating)return!1;let s=n.content.cutByIndex(i,n.childCount),l=r&&r[t+1];l&&(s=s.replaceChild(0,l.type.create(l.attrs)));let a=r&&r[t]||n;if(!n.canReplace(i+1,n.childCount)||!a.type.validContent(s))return!1}let l=o.indexAfter(i),a=r&&r[0];return o.node(i).canReplaceWith(l,l,a?a.type:o.node(i+1).type)}function M(e,t){let n=e.resolve(t),r=n.index();return O(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function O(e,t){return!(!e||!t||e.isLeaf||!e.canAppend(t))}function A(e,t,n=-1){let r=e.resolve(t);for(let e=r.depth;;e--){let o,i,s=r.index(e);if(e==r.depth?(o=r.nodeBefore,i=r.nodeAfter):n>0?(o=r.node(e+1),s++,i=r.node(e).maybeChild(s)):(o=r.node(e).maybeChild(s-1),i=r.node(e+1)),o&&!o.isTextblock&&O(o,i)&&r.node(e).canReplace(s,s+1))return t;if(0==e)break;t=n<0?r.before(e):r.after(e)}}function T(e,t,n){let r=e.resolve(t);if(r.parent.canReplaceWith(r.index(),r.index(),n))return t;if(0==r.parentOffset)for(let e=r.depth-1;e>=0;e--){let t=r.index(e);if(r.node(e).canReplaceWith(t,t,n))return r.before(e+1);if(t>0)return null}if(r.parentOffset==r.parent.content.size)for(let e=r.depth-1;e>=0;e--){let t=r.indexAfter(e);if(r.node(e).canReplaceWith(t,t,n))return r.after(e+1);if(t<r.node(e).childCount)return null}return null}function N(e,t,n){let r=e.resolve(t);if(!n.content.size)return t;let o=n.content;for(let e=0;e<n.openStart;e++)o=o.firstChild.content;for(let e=1;e<=(0==n.openStart&&n.size?2:1);e++)for(let t=r.depth;t>=0;t--){let n=t==r.depth?0:r.pos<=(r.start(t+1)+r.end(t+1))/2?-1:1,i=r.index(t)+(n>0?1:0),s=r.node(t),l=!1;if(1==e)l=s.canReplace(i,i,o);else{let e=s.contentMatchAt(i).findWrapping(o.firstChild.type);l=e&&s.canReplaceWith(i,i,e[0])}if(l)return 0==n?r.pos:n<0?r.before(t+1):r.after(t+1)}return null}function R(e,t,n=t,o=r.Slice.empty){if(t==n&&!o.size)return null;let i=e.resolve(t),s=e.resolve(n);return D(i,s,o)?new y(t,n,o):new _(i,s,o).fit()}function D(e,t,n){return!n.openStart&&!n.openEnd&&e.start()==t.start()&&e.parent.canReplace(e.index(),t.index(),n.content)}d.jsonID("replaceAround",v);class _{constructor(e,t,n){this.$from=e,this.$to=t,this.unplaced=n,this.frontier=[],this.placed=r.Fragment.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.Fragment.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 i=this.placed,s=n.depth,l=o.depth;for(;s&&l&&1==i.childCount;)i=i.firstChild.content,s--,l--;let a=new r.Slice(i,s,l);return e>-1?new v(n.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||n.pos!=this.$to.pos?new y(n.pos,o.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,n=0,r=this.unplaced.openEnd;n<e;n++){let o=t.firstChild;if(t.childCount>1&&(r=0),o.type.spec.isolating&&r<=n){e=n;break}t=o.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=z(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.Fragment.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=z(e,t);return!(!o.childCount||o.firstChild.isLeaf)&&(this.unplaced=new r.Slice(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=z(e,t);if(o.childCount<=1&&t>0){let i=e.size-t<=t+o.size;this.unplaced=new r.Slice(E(e,t-1,1),t-1,i?t-1:n)}else this.unplaced=new r.Slice(E(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,d=[],{match:u,type:h}=this.frontier[t];if(o){for(let e=0;e<o.childCount;e++)d.push(o.child(e));u=u.matchFragment(o)}let p=l.size+e-(s.content.size-s.openEnd);for(;c<l.childCount;){let e=l.child(c),t=u.matchType(e.type);if(!t)break;c++,(c>1||0==a||e.content.size)&&(u=t,d.push(I(e.mark(h.allowedMarks(e.marks)),1==c?a:0,c==l.childCount?p:-1)))}let f=c==l.childCount;f||(p=-1),this.placed=P(this.placed,t,r.Fragment.from(d)),this.frontier[t].match=u,f&&p<0&&n&&n.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let e=0,t=l;e<p;e++){let e=t.lastChild;this.frontier.push({type:e.type,match:e.contentMatchAt(e.childCount)}),t=e.content}this.unplaced=f?0==e?r.Slice.empty:new r.Slice(E(s.content,e-1,1),e-1,p<0?s.openEnd:e-1):new r.Slice(E(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||!F(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,r=this.$to.after(n);for(;n>1&&r==this.$to.end(--n);)++r;return r}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:n,type:r}=this.frontier[t],o=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),i=F(e,t,r,n,o);if(i){for(let n=t-1;n>=0;n--){let{match:t,type:r}=this.frontier[n],o=F(e,n,r,t,!0);if(!o||o.childCount)continue e}return{depth:t,fit:i,move:o?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=P(this.placed,t.depth,t.fit)),e=t.move;for(let n=t.depth+1;n<=e.depth;n++){let t=e.node(n),r=t.type.contentMatch.fillBefore(t.content,!0,e.index(n));this.openFrontierNode(t.type,t.attrs,r)}return e}openFrontierNode(e,t=null,n){let o=this.frontier[this.depth];o.match=o.match.matchType(e),this.placed=P(this.placed,this.depth,r.Fragment.from(e.create(t,n))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let e=this.frontier.pop().match.fillBefore(r.Fragment.empty,!0);e.childCount&&(this.placed=P(this.placed,this.frontier.length,e))}}function E(e,t,n){return 0==t?e.cutByIndex(n,e.childCount):e.replaceChild(0,e.firstChild.copy(E(e.firstChild.content,t-1,n)))}function P(e,t,n){return 0==t?e.append(n):e.replaceChild(e.childCount-1,e.lastChild.copy(P(e.lastChild.content,t-1,n)))}function z(e,t){for(let n=0;n<t;n++)e=e.firstChild.content;return e}function I(e,t,n){if(t<=0)return e;let o=e.content;return t>1&&(o=o.replaceChild(0,I(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.Fragment.empty,!0)))),e.copy(o)}function F(e,t,n,r,o){let i=e.node(t),s=o?e.indexAfter(t):e.index(t);if(s==i.childCount&&!n.compatibleContent(i.type))return null;let l=r.fillBefore(i.content,!0,s);return l&&!function(e,t,n){for(let r=n;r<t.childCount;r++)if(!e.allowsMarks(t.child(r).marks))return!0;return!1}(n,i.content,s)?l:null}function B(e){return e.spec.defining||e.spec.definingForContent}function j(e,t,n,o,i){if(t<n){let r=e.firstChild;e=e.replaceChild(0,r.copy(j(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.Fragment.empty,!0))}return e}function $(e,t){let n=[];for(let r=Math.min(e.depth,t.depth);r>=0;r--){let o=e.start(r);if(o<e.pos-(e.depth-r)||t.end(r)>t.pos+(t.depth-r)||e.node(r).type.spec.isolating||t.node(r).type.spec.isolating)break;(o==t.start(r)||r==e.depth&&r==t.depth&&e.parent.inlineContent&&t.parent.inlineContent&&r&&t.start(r-1)==o-1)&&n.push(r)}return n}class L extends d{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 u.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 u.fromReplace(e,this.pos,this.pos+1,new r.Slice(r.Fragment.from(o),0,t.isLeaf?0:1))}getMap(){return l.empty}invert(e){return new L(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 L(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 L(t.pos,t.attr,t.value)}}d.jsonID("attr",L);let V=class extends Error{};V=function e(t){let n=Error.call(this,t);return n.__proto__=e.prototype,n},V.prototype=Object.create(Error.prototype),V.prototype.constructor=V,V.prototype.name="TransformError";class K{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new a}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new V(t.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=r.Slice.empty){let o=R(this.doc,e,t,n);return o&&this.step(o),this}replaceWith(e,t,n){return this.replace(e,t,new r.Slice(r.Fragment.from(n),0,0))}delete(e,t){return this.replace(e,t,r.Slice.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 i=e.doc.resolve(t),s=e.doc.resolve(n);if(D(i,s,o))return e.step(new y(t,n,o));let l=$(i,e.doc.resolve(n));0==l[l.length-1]&&l.pop();let a=-(i.depth+1);l.unshift(a);for(let e=i.depth,t=i.pos-1;e>0;e--,t--){let n=i.node(e).type.spec;if(n.defining||n.definingAsContext||n.isolating)break;l.indexOf(e)>-1?a=e:i.before(e)==t&&l.splice(1,0,-e)}let c=l.indexOf(a),d=[],u=o.openStart;for(let e=o.content,t=0;;t++){let n=e.firstChild;if(d.push(n),t==o.openStart)break;e=n.content}for(let e=u-1;e>=0;e--){let t=d[e].type,n=B(t);if(n&&i.node(c).type!=t)u=e;else if(n||!t.isTextblock)break}for(let t=o.openStart;t>=0;t--){let a=(t+u+1)%(o.openStart+1),h=d[a];if(h)for(let t=0;t<l.length;t++){let d=l[(t+c)%l.length],u=!0;d<0&&(u=!1,d=-d);let p=i.node(d-1),f=i.index(d-1);if(p.canReplaceWith(f,f,h.type,h.marks))return e.replace(i.before(d),u?s.after(d):n,new r.Slice(j(o.content,0,o.openStart,a),a,o.openEnd))}}let h=e.steps.length;for(let r=l.length-1;r>=0&&(e.replace(t,n,o),!(e.steps.length>h));r--){let e=l[r];e<0||(t=i.before(e),n=s.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=T(e.doc,t,o.type);null!=r&&(t=n=r)}e.replaceRange(t,n,new r.Slice(r.Fragment.from(o),0,0))}(this,e,t,n),this}deleteRange(e,t){return function(e,t,n){let r=e.doc.resolve(t),o=e.doc.resolve(n),i=$(r,o);for(let t=0;t<i.length;t++){let n=i[t],s=t==i.length-1;if(s&&0==n||r.node(n).type.contentMatch.validEnd)return e.delete(r.start(n),o.end(n));if(n>0&&(s||r.node(n-1).canReplace(r.index(n-1),o.indexAfter(n-1))))return e.delete(r.before(n),o.after(n))}for(let i=1;i<=r.depth&&i<=o.depth;i++)if(t-r.start(i)==r.depth-i&&n>r.end(i)&&o.end(i)-n!=o.depth-i)return e.delete(r.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,d=a,u=r.Fragment.empty,h=0;for(let e=s,t=!1;e>n;e--)t||o.index(e)>0?(t=!0,u=r.Fragment.from(o.node(e).copy(u)),h++):c--;let p=r.Fragment.empty,f=0;for(let e=s,t=!1;e>n;e--)t||i.after(e+1)<i.end(e)?(t=!0,p=r.Fragment.from(i.node(e).copy(p)),f++):d++;e.step(new v(c,d,l,a,new r.Slice(u.append(p),h,f),u.size-h,!0))}(this,e,t),this}join(e,t=1){return function(e,t,n){let o=new y(t-n,t+n,r.Slice.empty,!0);e.step(o)}(this,e,t),this}wrap(e,t){return function(e,t,n){let o=r.Fragment.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.Fragment.from(n[e].type.create(n[e].attrs,o))}let i=t.start,s=t.end;e.step(new v(i,s,i,s,new r.Slice(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)=>{if(t.isTextblock&&!t.hasMarkup(o,i)&&function(e,t,n){let r=e.resolve(t),o=r.index();return r.parent.canReplaceWith(o,o+1,n)}(e.doc,e.mapping.slice(s).map(n),o)){e.clearIncompatible(e.mapping.slice(s).map(n,1),o);let l=e.mapping.slice(s),a=l.map(n,1),c=l.map(n+t.nodeSize,1);return e.step(new v(a,c,a+1,c-1,new r.Slice(r.Fragment.from(o.create(i,null,t.marks)),0,0),1,!0)),!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 v(t,t+s.nodeSize,t+1,t+s.nodeSize-1,new r.Slice(r.Fragment.from(l),0,0),1,!0))}(this,e,t,n,o),this}setNodeAttribute(e,t,n){return this.step(new L(e,t,n)),this}addNodeMark(e,t){return this.step(new m(e,t)),this}removeNodeMark(e,t){if(!(t instanceof r.Mark)){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 g(e,t)),this}split(e,t=1,n){return function(e,t,n=1,o){let i=e.doc.resolve(t),s=r.Fragment.empty,l=r.Fragment.empty;for(let e=i.depth,t=i.depth-n,a=n-1;e>t;e--,a--){s=r.Fragment.from(i.node(e).copy(s));let t=o&&o[a];l=r.Fragment.from(t?t.type.create(t.attrs,l):i.node(e).copy(l))}e.step(new y(t,t,new r.Slice(s.append(l),n,n),!0))}(this,e,t,n),this}addMark(e,t,n){return function(e,t,n,r){let o,i,s=[],l=[];e.doc.nodesBetween(t,n,(e,a,c)=>{if(!e.isInline)return;let d=e.marks;if(!r.isInSet(d)&&c.type.allowsMarkType(r.type)){let c=Math.max(a,t),u=Math.min(a+e.nodeSize,n),h=r.addToSet(d);for(let e=0;e<d.length;e++)d[e].isInSet(h)||(o&&o.to==c&&o.mark.eq(d[e])?o.to=u:s.push(o=new f(c,u,d[e])));i&&i.to==c?i.to=u:l.push(i=new p(c,u,r))}}),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 i=[],s=0;e.doc.nodesBetween(t,n,(e,l)=>{if(!e.isInline)return;s++;let a=null;if(o instanceof r.MarkType){let t,n=e.marks;for(;t=o.isInSet(n);)(a||(a=[])).push(t),n=t.removeFromSet(n)}else o?o.isInSet(e.marks)&&(a=[o]):a=e.marks;if(a&&a.length){let r=Math.min(l+e.nodeSize,n);for(let e=0;e<a.length;e++){let n,o=a[e];for(let e=0;e<i.length;e++){let t=i[e];t.step==s-1&&o.eq(i[e].style)&&(n=t)}n?(n.to=r,n.step=s):i.push({style:o,from:Math.max(l,t),to:r,step:s})}}}),i.forEach(t=>e.step(new f(t.from,t.to,t.style)))}(this,e,t,n),this}clearIncompatible(e,t,n){return function(e,t,n,o=n.contentMatch){let i=e.doc.nodeAt(t),s=[],l=t+1;for(let t=0;t<i.childCount;t++){let a=i.child(t),c=l+a.nodeSize,d=o.matchType(a.type);if(d){o=d;for(let t=0;t<a.marks.length;t++)n.allowsMarkType(a.marks[t].type)||e.step(new f(l,c,a.marks[t]))}else s.push(new y(l,c,r.Slice.empty));l=c}if(!o.validEnd){let t=o.fillBefore(r.Fragment.empty,!0);e.replace(l,l,new r.Slice(t,0,0))}for(let t=s.length-1;t>=0;t--)e.step(s[t])}(this,e,t,n),this}}},function(e,t,n){"use strict";n.r(t),n.d(t,"Decoration",(function(){return Ft})),n.d(t,"DecorationSet",(function(){return $t})),n.d(t,"EditorView",(function(){return hn})),n.d(t,"__endComposition",(function(){return un})),n.d(t,"__parseFromClipboard",(function(){return dn})),n.d(t,"__serializeForClipboard",(function(){return cn}));var r=n(1),o=n(0),i=n(2);const s=function(e){for(var t=0;;t++)if(!(e=e.previousSibling))return t},l=function(e){let t=e.assignedSlot||e.parentNode;return t&&11==t.nodeType?t.host:t};let a=null;const c=function(e,t,n){let r=a||(a=document.createRange());return r.setEnd(e,null==n?e.nodeValue.length:n),r.setStart(e,t||0),r},d=function(e,t,n,r){return n&&(h(e,t,n,r,-1)||h(e,t,n,r,1))},u=/^(img|br|input|textarea|hr)$/i;function h(e,t,n,r,o){for(;;){if(e==n&&t==r)return!0;if(t==(o<0?0:p(e))){let n=e.parentNode;if(!n||1!=n.nodeType||f(e)||u.test(e.nodeName)||"false"==e.contentEditable)return!1;t=s(e)+(o<0?0:1),e=n}else{if(1!=e.nodeType)return!1;if("false"==(e=e.childNodes[t+(o<0?-1:0)]).contentEditable)return!1;t=o<0?p(e):0}}}function p(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function f(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 m=function(e){return e.focusNode&&d(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)};function g(e,t){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=e,n.key=n.code=t,n}const y="undefined"!=typeof navigator?navigator:null,v="undefined"!=typeof document?document:null,b=y&&y.userAgent||"",w=/Edge\/(\d+)/.exec(b),S=/MSIE \d/.exec(b),k=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(b),x=!!(S||k||w),C=S?document.documentMode:k?+k[1]:w?+w[1]:0,M=!x&&/gecko\/(\d+)/i.test(b);M&&(/Firefox\/(\d+)/.exec(b)||[0,0])[1];const O=!x&&/Chrome\/(\d+)/.exec(b),A=!!O,T=O?+O[1]:0,N=!x&&!!y&&/Apple Computer/.test(y.vendor),R=N&&(/Mobile\/\w+/.test(b)||!!y&&y.maxTouchPoints>2),D=R||!!y&&/Mac/.test(y.platform),_=!!y&&/Win/.test(y.platform),E=/Android \d/.test(b),P=!!v&&"webkitFontSmoothing"in v.documentElement.style,z=P?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function I(e){return{left:0,right:e.documentElement.clientWidth,top:0,bottom:e.documentElement.clientHeight}}function F(e,t){return"number"==typeof e?e:e[t]}function B(e){let t=e.getBoundingClientRect(),n=t.width/e.offsetWidth||1,r=t.height/e.offsetHeight||1;return{left:t.left,right:t.left+e.clientWidth*n,top:t.top,bottom:t.top+e.clientHeight*r}}function j(e,t,n){let r=e.someProp("scrollThreshold")||0,o=e.someProp("scrollMargin")||5,i=e.dom.ownerDocument;for(let s=n||e.dom;s;s=l(s)){if(1!=s.nodeType)continue;let e=s,n=e==i.body,l=n?I(i):B(e),a=0,c=0;if(t.top<l.top+F(r,"top")?c=-(l.top-t.top+F(o,"top")):t.bottom>l.bottom-F(r,"bottom")&&(c=t.bottom-l.bottom+F(o,"bottom")),t.left<l.left+F(r,"left")?a=-(l.left-t.left+F(o,"left")):t.right>l.right-F(r,"right")&&(a=t.right-l.right+F(o,"right")),a||c)if(n)i.defaultView.scrollBy(a,c);else{let n=e.scrollLeft,r=e.scrollTop;c&&(e.scrollTop+=c),a&&(e.scrollLeft+=a);let o=e.scrollLeft-n,i=e.scrollTop-r;t={left:t.left-o,top:t.top-i,right:t.right-o,bottom:t.bottom-i}}if(n||/^(fixed|sticky)$/.test(getComputedStyle(s).position))break}}function $(e){let t=[],n=e.ownerDocument;for(let r=e;r&&(t.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),e!=n);r=l(r));return t}function L(e,t){for(let n=0;n<e.length;n++){let{dom:r,top:o,left:i}=e[n];r.scrollTop!=o+t&&(r.scrollTop=o+t),r.scrollLeft!=i&&(r.scrollLeft=i)}}let V=null;function K(e,t){let n,r,o,i,s=2e8,l=0,a=t.top,d=t.top;for(let u=e.firstChild,h=0;u;u=u.nextSibling,h++){let e;if(1==u.nodeType)e=u.getClientRects();else{if(3!=u.nodeType)continue;e=c(u).getClientRects()}for(let c=0;c<e.length;c++){let p=e[c];if(p.top<=a&&p.bottom>=d){a=Math.max(p.bottom,a),d=Math.min(p.top,d);let e=p.left>t.left?p.left-t.left:p.right<t.left?t.left-p.right:0;if(e<s){n=u,s=e,r=e&&3==n.nodeType?{left:p.right<t.left?p.right:p.left,top:t.top}:t,1==u.nodeType&&e&&(l=h+(t.left>=(p.left+p.right)/2?1:0));continue}}else p.top>t.top&&!o&&p.left<=t.left&&p.right>=t.left&&(o=u,i={left:Math.max(p.left,Math.min(p.right,t.left)),top:p.top});!n&&(t.left>=p.right&&t.top>=p.top||t.left>=p.left&&t.top>=p.bottom)&&(l=h+1)}}return!n&&o&&(n=o,r=i,s=0),n&&3==n.nodeType?function(e,t){let n=e.nodeValue.length,r=document.createRange();for(let o=0;o<n;o++){r.setEnd(e,o+1),r.setStart(e,o);let n=J(r,1);if(n.top!=n.bottom&&H(t,n))return{node:e,offset:o+(t.left>=(n.left+n.right)/2?1:0)}}return{node:e,offset:0}}(n,r):!n||s&&1==n.nodeType?{node:e,offset:l}:K(n,r)}function H(e,t){return e.left>=t.left-1&&e.left<=t.right+1&&e.top>=t.top-1&&e.top<=t.bottom+1}function W(e,t){let n,r=e.dom.ownerDocument,o=0,i=function(e,t,n){if(e.caretPositionFromPoint)try{let r=e.caretPositionFromPoint(t,n);if(r)return{node:r.offsetNode,offset:r.offset}}catch(e){}if(e.caretRangeFromPoint){let r=e.caretRangeFromPoint(t,n);if(r)return{node:r.startContainer,offset:r.startOffset}}}(r,t.left,t.top);i&&({node:n,offset:o}=i);let s,a=(e.root.elementFromPoint?e.root:r).elementFromPoint(t.left,t.top);if(!a||!e.dom.contains(1!=a.nodeType?a.parentNode:a)){let n=e.dom.getBoundingClientRect();if(!H(t,n))return null;if(a=function e(t,n,r){let o=t.childNodes.length;if(o&&r.top<r.bottom)for(let i=Math.max(0,Math.min(o-1,Math.floor(o*(n.top-r.top)/(r.bottom-r.top))-2)),s=i;;){let r=t.childNodes[s];if(1==r.nodeType){let t=r.getClientRects();for(let o=0;o<t.length;o++){let i=t[o];if(H(n,i))return e(r,n,i)}}if((s=(s+1)%o)==i)break}return t}(e.dom,t,n),!a)return null}if(N)for(let e=a;n&&e;e=l(e))e.draggable&&(n=void 0);if(a=function(e,t){let n=e.parentNode;return n&&/^li$/i.test(n.nodeName)&&t.left<e.getBoundingClientRect().left?n:e}(a,t),n){if(M&&1==n.nodeType&&(o=Math.min(o,n.childNodes.length),o<n.childNodes.length)){let e,r=n.childNodes[o];"IMG"==r.nodeName&&(e=r.getBoundingClientRect()).right<=t.left&&e.bottom>t.top&&o++}n==e.dom&&o==n.childNodes.length-1&&1==n.lastChild.nodeType&&t.top>n.lastChild.getBoundingClientRect().bottom?s=e.state.doc.content.size:0!=o&&1==n.nodeType&&"BR"==n.childNodes[o-1].nodeName||(s=function(e,t,n,r){let o=-1;for(let n=t,i=!1;n!=e.dom;){let t=e.docView.nearestDesc(n,!0);if(!t)return null;if(1==t.dom.nodeType&&(t.node.isBlock&&t.parent&&!i||!t.contentDOM)){let e=t.dom.getBoundingClientRect();if(t.node.isBlock&&t.parent&&!i&&(i=!0,e.left>r.left||e.top>r.top?o=t.posBefore:(e.right<r.left||e.bottom<r.top)&&(o=t.posAfter)),!t.contentDOM&&o<0&&!t.node.isText){return(t.node.isBlock?r.top<(e.top+e.bottom)/2:r.left<(e.left+e.right)/2)?t.posBefore:t.posAfter}}n=t.dom.parentNode}return o>-1?o:e.docView.posFromDOM(t,n,-1)}(e,n,o,t))}null==s&&(s=function(e,t,n){let{node:r,offset:o}=K(t,n),i=-1;if(1==r.nodeType&&!r.firstChild){let e=r.getBoundingClientRect();i=e.left!=e.right&&n.left>(e.left+e.right)/2?1:-1}return e.docView.posFromDOM(r,o,i)}(e,a,t));let c=e.docView.nearestDesc(a,!0);return{pos:s,inside:c?c.posAtStart-c.border:-1}}function q(e){return e.top<e.bottom||e.left<e.right}function J(e,t){let n=e.getClientRects();if(n.length){let e=n[t<0?0:n.length-1];if(q(e))return e}return Array.prototype.find.call(n,q)||e.getBoundingClientRect()}const U=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function X(e,t,n){let{node:r,offset:o,atom:i}=e.docView.domFromPos(t,n<0?-1:1),s=P||M;if(3==r.nodeType){if(!s||!U.test(r.nodeValue)&&(n<0?o:o!=r.nodeValue.length)){let e=o,t=o,i=n<0?1:-1;return n<0&&!o?(t++,i=-1):n>=0&&o==r.nodeValue.length?(e--,i=1):n<0?e--:t++,G(J(c(r,e,t),i),i<0)}{let e=J(c(r,o,o),n);if(M&&o&&/\s/.test(r.nodeValue[o-1])&&o<r.nodeValue.length){let t=J(c(r,o-1,o-1),-1);if(t.top==e.top){let n=J(c(r,o,o+1),-1);if(n.top!=e.top)return G(n,n.left<t.left)}}return e}}if(!e.state.doc.resolve(t-(i||0)).parent.inlineContent){if(null==i&&o&&(n<0||o==p(r))){let e=r.childNodes[o-1];if(1==e.nodeType)return Y(e.getBoundingClientRect(),!1)}if(null==i&&o<p(r)){let e=r.childNodes[o];if(1==e.nodeType)return Y(e.getBoundingClientRect(),!0)}return Y(r.getBoundingClientRect(),n>=0)}if(null==i&&o&&(n<0||o==p(r))){let e=r.childNodes[o-1],t=3==e.nodeType?c(e,p(e)-(s?0:1)):1!=e.nodeType||"BR"==e.nodeName&&e.nextSibling?null:e;if(t)return G(J(t,1),!1)}if(null==i&&o<p(r)){let e=r.childNodes[o];for(;e.pmViewDesc&&e.pmViewDesc.ignoreForCoords;)e=e.nextSibling;let t=e?3==e.nodeType?c(e,0,s?0:1):1==e.nodeType?e:null:null;if(t)return G(J(t,-1),!0)}return G(J(3==r.nodeType?c(r):r,-n),n>=0)}function G(e,t){if(0==e.width)return e;let n=t?e.left:e.right;return{top:e.top,bottom:e.bottom,left:n,right:n}}function Y(e,t){if(0==e.height)return e;let n=t?e.top:e.bottom;return{top:n,bottom:n,left:e.left,right:e.right}}function Q(e,t,n){let r=e.state,o=e.root.activeElement;r!=t&&e.updateState(t),o!=e.dom&&e.focus();try{return n()}finally{r!=t&&e.updateState(r),o!=e.dom&&o&&o.focus()}}const Z=/[\u0590-\u08ac]/;let ee=null,te=null,ne=!1;function re(e,t,n){return ee==t&&te==n?ne:(ee=t,te=n,ne="up"==n||"down"==n?function(e,t,n){let r=t.selection,o="up"==n?r.$from:r.$to;return Q(e,t,()=>{let{node:t}=e.docView.domFromPos(o.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 r=X(e,o.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=c(e,0,e.nodeValue.length).getClientRects()}for(let e=0;e<t.length;e++){let o=t[e];if(o.bottom>o.top+1&&("up"==n?r.top-o.top>2*(o.bottom-r.top):o.bottom-r.bottom>2*(r.bottom-o.top)))return!1}}return!0})}(e,t,n):function(e,t,n){let{$head:r}=t.selection;if(!r.parent.isTextblock)return!1;let o=r.parentOffset,i=!o,s=o==r.parent.content.size,l=e.domSelection();return Z.test(r.parent.textContent)&&l.modify?Q(e,t,()=>{let{focusNode:t,focusOffset:o,anchorNode:i,anchorOffset:s}=e.domSelectionRange(),a=l.caretBidiLevel;l.modify("move",n,"character");let c=r.depth?e.docView.domAfterPos(r.before()):e.dom,{focusNode:d,focusOffset:u}=e.domSelectionRange(),h=d&&!c.contains(1==d.nodeType?d:d.parentNode)||t==d&&o==u;try{l.collapse(i,s),t&&(t!=i||o!=s)&&l.extend&&l.extend(t,o)}catch(e){}return null!=a&&(l.caretBidiLevel=a),h}):"left"==n||"backward"==n?i:s}(e,t,n))}class oe{constructor(e,t,n,r){this.parent=e,this.children=t,this.dom=n,this.contentDOM=r,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 r=this.children[t];if(r==e)return n;n+=r.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,r;if(e==this.contentDOM)n=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;n=e.previousSibling}for(;n&&(!(r=n.pmViewDesc)||r.parent!=this);)n=n.previousSibling;return n?this.posBeforeChild(r)+r.size:this.posAtStart}{let n,r;if(e==this.contentDOM)n=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;n=e.nextSibling}for(;n&&(!(r=n.pmViewDesc)||r.parent!=this);)n=n.nextSibling;return n?this.posBeforeChild(r):this.posAtEnd}}let r;if(e==this.dom&&this.contentDOM)r=t>s(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))r=2&e.compareDocumentPosition(this.contentDOM);else if(this.dom.firstChild){if(0==t)for(let t=e;;t=t.parentNode){if(t==this.dom){r=!1;break}if(t.previousSibling)break}if(null==r&&t==e.childNodes.length)for(let t=e;;t=t.parentNode){if(t==this.dom){r=!0;break}if(t.nextSibling)break}}return(null==r?n>0:r)?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let n=!0,r=e;r;r=r.parentNode){let o,i=this.getDesc(r);if(i&&(!t||i.node)){if(!n||!(o=i.nodeDOM)||(1==o.nodeType?o.contains(1==e.nodeType?e:e.parentNode):o==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 r=e;r;r=r.parentNode){let o=this.getDesc(r);if(o)return o.localPosFromDOM(e,t,n)}return-1}descAt(e){for(let t=0,n=0;t<this.children.length;t++){let r=this.children[t],o=n+r.size;if(n==e&&o!=n){for(;!r.border&&r.children.length;)r=r.children[0];return r}if(e<o)return r.descAt(e-n-r.border);n=o}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let n,r=0,o=0;for(let t=0;r<this.children.length;r++){let n=this.children[r],i=t+n.size;if(i>e||n instanceof ue){o=e-t;break}t=i}if(o)return this.children[r].domFromPos(o-this.children[r].border,t);for(;r&&!(n=this.children[r-1]).size&&n instanceof ie&&n.side>=0;r--);if(t<=0){let e,n=!0;for(;e=r?this.children[r-1]:null,e&&e.dom.parentNode!=this.contentDOM;r--,n=!1);return e&&t&&n&&!e.border&&!e.domAtom?e.domFromPos(e.size,t):{node:this.contentDOM,offset:e?s(e.dom)+1:0}}{let e,n=!0;for(;e=r<this.children.length?this.children[r]:null,e&&e.dom.parentNode!=this.contentDOM;r++,n=!1);return e&&n&&!e.border&&!e.domAtom?e.domFromPos(0,t):{node:this.contentDOM,offset:e?s(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 r=-1,o=-1;for(let i=n,l=0;;l++){let n=this.children[l],a=i+n.size;if(-1==r&&e<=a){let o=i+n.border;if(e>=o&&t<=a-n.border&&n.node&&n.contentDOM&&this.contentDOM.contains(n.contentDOM))return n.parseRange(e,t,o);e=i;for(let t=l;t>0;t--){let n=this.children[t-1];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(1)){r=s(n.dom)+1;break}e-=n.size}-1==r&&(r=0)}if(r>-1&&(a>t||l==this.children.length-1)){t=a;for(let e=l+1;e<this.children.length;e++){let n=this.children[e];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(-1)){o=s(n.dom);break}t+=n.size}-1==o&&(o=this.contentDOM.childNodes.length);break}i=a}return{node:this.contentDOM,from:e,to:t,fromOffset:r,toOffset:o}}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,r=!1){let o=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(o>l&&i<c)return a.setSelection(e-l-a.border,t-l-a.border,n,r);l=c}let l=this.domFromPos(e,e?-1:1),a=t==e?l:this.domFromPos(t,t?-1:1),c=n.getSelection(),u=!1;if((M||N)&&e==t){let{node:e,offset:t}=l;if(3==e.nodeType){if(u=!(!t||"\n"!=e.nodeValue[t-1]),u&&t==e.nodeValue.length)for(let t,n=e;n;n=n.parentNode){if(t=n.nextSibling){"BR"==t.nodeName&&(l=a={node:t.parentNode,offset:s(t)+1});break}let e=n.pmViewDesc;if(e&&e.node&&e.node.isBlock)break}}else{let n=e.childNodes[t-1];u=n&&("BR"==n.nodeName||"false"==n.contentEditable)}}if(M&&c.focusNode&&c.focusNode!=a.node&&1==c.focusNode.nodeType){let e=c.focusNode.childNodes[c.focusOffset];e&&"false"==e.contentEditable&&(r=!0)}if(!(r||u&&N)&&d(l.node,l.offset,c.anchorNode,c.anchorOffset)&&d(a.node,a.offset,c.focusNode,c.focusOffset))return;let h=!1;if((c.extend||e==t)&&!u){c.collapse(l.node,l.offset);try{e!=t&&c.extend(a.node,a.offset),h=!0}catch(e){}}if(!h){if(e>t){let e=l;l=a,a=e}let n=document.createRange();n.setEnd(a.node,a.offset),n.setStart(l.node,l.offset),c.removeAllRanges(),c.addRange(n)}}ignoreMutation(e){return!this.contentDOM&&"selection"!=e.type}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let n=0,r=0;r<this.children.length;r++){let o=this.children[r],i=n+o.size;if(n==i?e<=i&&t>=n:e<i&&t>n){let r=n+o.border,s=i-o.border;if(e>=r&&t<=s)return this.dirty=e==n||t==i?2:1,void(e!=r||t!=s||!o.contentLost&&o.dom.parentNode==this.contentDOM?o.markDirty(e-r,t-r):o.dirty=3);o.dirty=o.dom!=o.contentDOM||o.dom.parentNode!=this.contentDOM||o.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}}class ie extends oe{constructor(e,t,n,r){let o,i=t.type.toDOM;if("function"==typeof i&&(i=i(n,()=>o?o.parent?o.parent.posBeforeChild(o):void 0:r)),!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,o=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 se extends oe{constructor(e,t,n,r){super(e,[],t,null),this.textDOM=n,this.text=r}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 le extends oe{constructor(e,t,n,r){super(e,[],n,r),this.mark=t}static create(e,t,n,r){let i=r.nodeViews[t.type.name],s=i&&i(t,r,n);return s&&s.dom||(s=o.DOMSerializer.renderSpec(document,t.type.spec.toDOM(t,n))),new le(e,t,s.dom,s.contentDOM||s.dom)}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 r=le.create(this.parent,this.mark,!0,n),o=this.children,i=this.size;t<i&&(o=xe(o,t,i,n)),e>0&&(o=xe(o,0,e,n));for(let e=0;e<o.length;e++)o[e].parent=r;return r.children=o,r}}class ae extends oe{constructor(e,t,n,r,o,i,s,l,a){super(e,[],o,i),this.node=t,this.outerDeco=n,this.innerDeco=r,this.nodeDOM=s}static create(e,t,n,r,i,s){let l,a=i.nodeViews[t.type.name],c=a&&a(t,i,()=>l?l.parent?l.parent.posBeforeChild(l):void 0:s,n,r),d=c&&c.dom,u=c&&c.contentDOM;if(t.isText)if(d){if(3!=d.nodeType)throw new RangeError("Text must be rendered as a DOM text node")}else d=document.createTextNode(t.text);else d||({dom:d,contentDOM:u}=o.DOMSerializer.renderSpec(document,t.type.spec.toDOM(t)));u||t.isText||"BR"==d.nodeName||(d.hasAttribute("contenteditable")||(d.contentEditable="false"),t.type.spec.draggable&&(d.draggable=!0));let h=d;return d=ve(d,n,t),c?l=new he(e,t,n,r,d,u||null,h,c,i,s+1):t.isText?new de(e,t,n,r,d,h,i):new ae(e,t,n,r,d,u||null,h,i,s+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if("pre"==this.node.type.whitespace&&(e.preserveWhitespace="full"),this.contentDOM)if(this.contentLost){for(let t=this.children.length-1;t>=0;t--){let n=this.children[t];if(this.dom.contains(n.dom.parentNode)){e.contentElement=n.dom.parentNode;break}}e.contentElement||(e.getContent=()=>o.Fragment.empty)}else e.contentElement=this.contentDOM;else e.getContent=()=>this.node.content;return e}matchesNode(e,t,n){return 0==this.dirty&&e.eq(this.node)&&be(t,this.outerDeco)&&n.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let n=this.node.inlineContent,r=t,i=e.composing?this.localCompositionInfo(e,t):null,s=i&&i.pos>-1?i:null,l=i&&i.pos<0,a=new Se(this,s&&s.node,e);!function(e,t,n,r){let o=t.locals(e),i=0;if(0==o.length){for(let n=0;n<e.childCount;n++){let s=e.child(n);r(s,o,t.forChild(i,s),n),i+=s.nodeSize}return}let s=0,l=[],a=null;for(let c=0;;){if(s<o.length&&o[s].to==i){let e,t=o[s++];for(;s<o.length&&o[s].to==i;)(e||(e=[t])).push(o[s++]);if(e){e.sort(ke);for(let t=0;t<e.length;t++)n(e[t],c,!!a)}else n(t,c,!!a)}let d,u;if(a)u=-1,d=a,a=null;else{if(!(c<e.childCount))break;u=c,d=e.child(c++)}for(let e=0;e<l.length;e++)l[e].to<=i&&l.splice(e--,1);for(;s<o.length&&o[s].from<=i&&o[s].to>i;)l.push(o[s++]);let h=i+d.nodeSize;if(d.isText){let e=h;s<o.length&&o[s].from<e&&(e=o[s].from);for(let t=0;t<l.length;t++)l[t].to<e&&(e=l[t].to);e<h&&(a=d.cut(e-i),d=d.cut(0,e-i),h=e,u=-1)}let p=d.isInline&&!d.isLeaf?l.filter(e=>!e.inline):l.slice();r(d,p,t.forChild(i,d),u),i=h}}(this.node,this.innerDeco,(t,i,s)=>{t.spec.marks?a.syncToMarks(t.spec.marks,n,e):t.type.side>=0&&!s&&a.syncToMarks(i==this.node.childCount?o.Mark.none:this.node.child(i).marks,n,e),a.placeWidget(t,e,r)},(t,o,s,c)=>{let d;a.syncToMarks(t.marks,n,e),a.findNodeMatch(t,o,s,c)||l&&e.state.selection.from>r&&e.state.selection.to<r+t.nodeSize&&(d=a.findIndexWithChild(i.node))>-1&&a.updateNodeAt(t,o,s,d,e)||a.updateNextNode(t,o,s,e,c,r)||a.addNode(t,o,s,e,r),r+=t.nodeSize}),a.syncToMarks([],n,e),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||2==this.dirty)&&(s&&this.protectLocalComposition(e,s),function e(t,n,r){let o=t.firstChild,i=!1;for(let s=0;s<n.length;s++){let l=n[s],a=l.dom;if(a.parentNode==t){for(;a!=o;)o=we(o),i=!0;o=o.nextSibling}else i=!0,t.insertBefore(a,o);if(l instanceof le){let n=o?o.previousSibling:t.lastChild;e(l.contentDOM,l.children,r),o=n?n.nextSibling:t.firstChild}}for(;o;)o=we(o),i=!0;i&&r.trackWrites==t&&(r.trackWrites=null)}(this.contentDOM,this.children,e),R&&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 r.TextSelection)||n<t||o>t+this.node.content.size)return null;let i=e.domSelectionRange(),s=function(e,t){for(;;){if(3==e.nodeType)return e;if(1==e.nodeType&&t>0){if(e.childNodes.length>t&&3==e.childNodes[t].nodeType)return e.childNodes[t];e=e.childNodes[t-1],t=p(e)}else{if(!(1==e.nodeType&&t<e.childNodes.length))return null;e=e.childNodes[t],t=0}}}(i.focusNode,i.focusOffset);if(!s||!this.dom.contains(s.parentNode))return null;if(this.node.inlineContent){let e=s.nodeValue,r=function(e,t,n,r){for(let o=0,i=0;o<e.childCount&&i<=r;){let s=e.child(o++),l=i;if(i+=s.nodeSize,!s.isText)continue;let a=s.text;for(;o<e.childCount;){let t=e.child(o++);if(i+=t.nodeSize,!t.isText)break;a+=t.text}if(i>=n){let e=l<r?a.lastIndexOf(t,r-l-1):-1;if(e>=0&&e+t.length+l>=n)return l+e;if(n==r&&a.length>=r+t.length-l&&a.slice(r-l,r-l+t.length)==t)return r}}return-1}(this.node.content,e,n-t,o-t);return r<0?null:{node:s,pos:r,text:e}}return{node:s,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:n,text:r}){if(this.getDesc(t))return;let o=t;for(;o.parentNode!=this.contentDOM;o=o.parentNode){for(;o.previousSibling;)o.parentNode.removeChild(o.previousSibling);for(;o.nextSibling;)o.parentNode.removeChild(o.nextSibling);o.pmViewDesc&&(o.pmViewDesc=void 0)}let i=new se(this,o,t,r);e.input.compositionNodes.push(i),this.children=xe(this.children,n,n+r.length,e,i)}update(e,t,n,r){return!(3==this.dirty||!e.sameMarkup(this.node))&&(this.updateInner(e,t,n,r),!0)}updateInner(e,t,n,r){this.updateOuterDeco(t),this.node=e,this.innerDeco=n,this.contentDOM&&this.updateChildren(r,this.posAtStart),this.dirty=0}updateOuterDeco(e){if(be(e,this.outerDeco))return;let t=1!=this.nodeDOM.nodeType,n=this.dom;this.dom=ge(this.dom,this.nodeDOM,me(this.outerDeco,this.node,t),me(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 ce(e,t,n,r,o){ve(r,t,e);let i=new ae(void 0,e,t,n,r,r,r,o,0);return i.contentDOM&&i.updateChildren(o,0),i}class de extends ae{constructor(e,t,n,r,o,i,s){super(e,t,n,r,o,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,r){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,r.trackWrites==this.nodeDOM&&(r.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 r=this.node.cut(e,t),o=document.createTextNode(r.text);return new de(this.parent,r,this.outerDeco,this.innerDeco,o,o,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}}class ue extends oe{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 he extends ae{constructor(e,t,n,r,o,i,s,l,a,c){super(e,t,n,r,o,i,s,a,c),this.spec=l}update(e,t,n,r){if(3==this.dirty)return!1;if(this.spec.update){let o=this.spec.update(e,t,n);return o&&this.updateInner(e,t,n,r),o}return!(!this.contentDOM&&!e.isLeaf)&&super.update(e,t,n,r)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,n,r){this.spec.setSelection?this.spec.setSelection(e,t,n):super.setSelection(e,t,n,r)}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)}}const pe=function(e){e&&(this.nodeName=e)};pe.prototype=Object.create(null);const fe=[new pe];function me(e,t,n){if(0==e.length)return fe;let r=n?fe[0]:new pe,o=[r];for(let i=0;i<e.length;i++){let s=e[i].type.attrs;if(s){s.nodeName&&o.push(r=new pe(s.nodeName));for(let e in s){let i=s[e];null!=i&&(n&&1==o.length&&o.push(r=new pe(t.isInline?"span":"div")),"class"==e?r.class=(r.class?r.class+" ":"")+i:"style"==e?r.style=(r.style?r.style+";":"")+i:"nodeName"!=e&&(r[e]=i))}}}return o}function ge(e,t,n,r){if(n==fe&&r==fe)return t;let o=t;for(let t=0;t<r.length;t++){let i=r[t],s=n[t];if(t){let t;s&&s.nodeName==i.nodeName&&o!=e&&(t=o.parentNode)&&t.nodeName.toLowerCase()==i.nodeName||(t=document.createElement(i.nodeName),t.pmIsDeco=!0,t.appendChild(o),s=fe[0]),o=t}ye(o,s||fe[0],i)}return o}function ye(e,t,n){for(let r in t)"class"==r||"style"==r||"nodeName"==r||r in n||e.removeAttribute(r);for(let r in n)"class"!=r&&"style"!=r&&"nodeName"!=r&&n[r]!=t[r]&&e.setAttribute(r,n[r]);if(t.class!=n.class){let r=t.class?t.class.split(" ").filter(Boolean):[],o=n.class?n.class.split(" ").filter(Boolean):[];for(let t=0;t<r.length;t++)-1==o.indexOf(r[t])&&e.classList.remove(r[t]);for(let t=0;t<o.length;t++)-1==r.indexOf(o[t])&&e.classList.add(o[t]);0==e.classList.length&&e.removeAttribute("class")}if(t.style!=n.style){if(t.style){let n,r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g;for(;n=r.exec(t.style);)e.style.removeProperty(n[1])}n.style&&(e.style.cssText+=n.style)}}function ve(e,t,n){return ge(e,e,fe,me(t,n,1!=e.nodeType))}function be(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].type.eq(t[n].type))return!1;return!0}function we(e){let t=e.nextSibling;return e.parentNode.removeChild(e),t}class Se{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,r=n.children.length,o=e.childCount,i=new Map,s=[];e:for(;o>0;){let l;for(;;)if(r){let e=n.children[r-1];if(!(e instanceof le)){l=e,r--;break}n=e,r=e.children.length}else{if(n==t)break e;r=n.parent.children.indexOf(n),n=n.parent}let a=l.node;if(a){if(a!=e.child(o-1))break;--o,i.set(l,o),s.push(l)}}return{index:o,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 r=0,o=this.stack.length>>1,i=Math.min(o,e.length);for(;r<i&&(r==o-1?this.top:this.stack[r+1<<1]).matchesMark(e[r])&&!1!==e[r].type.spec.spanning;)r++;for(;r<o;)this.destroyRest(),this.top.dirty=0,this.index=this.stack.pop(),this.top=this.stack.pop(),o--;for(;o<e.length;){this.stack.push(this.top,this.index+1);let r=-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[o])&&!this.isLocked(n.dom)){r=t;break}}if(r>-1)r>this.index&&(this.changed=!0,this.destroyBetween(this.index,r)),this.top=this.top.children[this.index];else{let r=le.create(this.top,e[o],t,n);this.top.children.splice(this.index,0,r),this.top=r,this.changed=!0}this.index=0,o++}}findNodeMatch(e,t,n,r){let o,i=-1;if(r>=this.preMatch.index&&(o=this.preMatch.matches[r-this.preMatch.index]).parent==this.top&&o.matchesNode(e,t,n))i=this.top.children.indexOf(o,this.index);else for(let r=this.index,o=Math.min(this.top.children.length,r+5);r<o;r++){let o=this.top.children[r];if(o.matchesNode(e,t,n)&&!this.preMatch.matched.has(o)){i=r;break}}return!(i<0)&&(this.destroyBetween(this.index,i),this.index++,!0)}updateNodeAt(e,t,n,r,o){let i=this.top.children[r];return 3==i.dirty&&i.dom==i.contentDOM&&(i.dirty=2),!!i.update(e,t,n,o)&&(this.destroyBetween(this.index,r),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,r,o,i){for(let s=this.index;s<this.top.children.length;s++){let l=this.top.children[s];if(l instanceof ae){let a=this.preMatch.matched.get(l);if(null!=a&&a!=o)return!1;let c,d=l.dom,u=this.isLocked(d)&&!(e.isText&&l.node&&l.node.isText&&l.nodeDOM.nodeValue==e.text&&3!=l.dirty&&be(t,l.outerDeco));if(!u&&l.update(e,t,n,r))return this.destroyBetween(this.index,s),l.dom!=d&&(this.changed=!0),this.index++,!0;if(!u&&(c=this.recreateWrapper(l,e,t,n,r,i)))return this.top.children[this.index]=c,c.dirty=2,c.updateChildren(r,i+1),c.dirty=0,this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,n,r,o,i){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content))return null;let s=ae.create(this.top,t,n,r,o,i);if(!s.contentDOM)return null;s.children=e.children,e.children=[],e.destroy();for(let e of s.children)e.parent=s;return s}addNode(e,t,n,r,o){let i=ae.create(this.top,e,t,n,r,o);i.contentDOM&&i.updateChildren(r,o+1),this.top.children.splice(this.index++,0,i),this.changed=!0}placeWidget(e,t,n){let r=this.index<this.top.children.length?this.top.children[this.index]:null;if(!r||!r.matchesWidget(e)||e!=r.widget&&r.widget.type.toDOM.parentNode){let r=new ie(this.top,e,t,n);this.top.children.splice(this.index++,0,r),this.changed=!0}else this.index++}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof le;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof de)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((N||A)&&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 r=new ue(this.top,[],n,null);t!=this.top?t.children.push(r):t.children.splice(this.index++,0,r),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||1==e.nodeType&&e.contains(this.lock.parentNode))}}function ke(e,t){return e.type.side-t.type.side}function xe(e,t,n,r,o){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,r)),o&&(i.push(o),o=void 0),d>n&&i.push(a.slice(n-c,a.size,r)))}return i}function Ce(e,t=null){let n=e.domSelectionRange(),o=e.state.doc;if(!n.focusNode)return null;let i=e.docView.nearestDesc(n.focusNode),l=i&&0==i.size,a=e.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(a<0)return null;let c,d,u=o.resolve(a);if(m(n)){for(c=u;i&&!i.node;)i=i.parent;let e=i.node;if(i&&e.isAtom&&r.NodeSelection.isSelectable(e)&&i.parent&&(!e.isInline||!function(e,t,n){for(let r=0==t,o=t==p(e);r||o;){if(e==n)return!0;let t=s(e);if(!(e=e.parentNode))return!1;r=r&&0==t,o=o&&t==p(e)}}(n.focusNode,n.focusOffset,i.dom))){let e=i.posBefore;d=new r.NodeSelection(a==e?u:o.resolve(e))}}else{let t=e.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(t<0)return null;c=o.resolve(t)}if(!d){d=Ee(e,c,u,"pointer"==t||e.state.selection.head<u.pos&&!l?1:-1)}return d}function Me(e){return e.editable?e.hasFocus():ze(e)&&document.activeElement&&document.activeElement.contains(e.dom)}function Oe(e,t=!1){let n=e.state.selection;if(De(e,n),Me(e)){if(!t&&e.input.mouseDown&&e.input.mouseDown.allowDefault&&A){let t=e.domSelectionRange(),n=e.domObserver.currentSelection;if(t.anchorNode&&n.anchorNode&&d(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(),r=e.cursorWrapper.dom,o="IMG"==r.nodeName;o?n.setEnd(r.parentNode,s(r)+1):n.setEnd(r,0);n.collapse(!1),t.removeAllRanges(),t.addRange(n),!o&&!e.state.selection.visible&&x&&C<=11&&(r.disabled=!0,r.disabled=!1)}(e);else{let o,i,{anchor:s,head:l}=n;!Ae||n instanceof r.TextSelection||(n.$from.parent.inlineContent||(o=Te(e,n.from)),n.empty||n.$from.parent.inlineContent||(i=Te(e,n.to))),e.docView.setSelection(s,l,e.root,t),Ae&&(o&&Re(o),i&&Re(i)),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(),r=n.anchorNode,o=n.anchorOffset;t.addEventListener("selectionchange",e.input.hideSelectionGuard=()=>{n.anchorNode==r&&n.anchorOffset==o||(t.removeEventListener("selectionchange",e.input.hideSelectionGuard),setTimeout(()=>{Me(e)&&!e.state.selection.visible||e.dom.classList.remove("ProseMirror-hideselection")},20))})}(e))}e.domObserver.setCurSelection(),e.domObserver.connectSelection()}}const Ae=N||A&&T<63;function Te(e,t){let{node:n,offset:r}=e.docView.domFromPos(t,0),o=r<n.childNodes.length?n.childNodes[r]:null,i=r?n.childNodes[r-1]:null;if(N&&o&&"false"==o.contentEditable)return Ne(o);if(!(o&&"false"!=o.contentEditable||i&&"false"!=i.contentEditable)){if(o)return Ne(o);if(i)return Ne(i)}}function Ne(e){return e.contentEditable="true",N&&e.draggable&&(e.draggable=!1,e.wasDraggable=!0),e}function Re(e){e.contentEditable="false",e.wasDraggable&&(e.draggable=!0,e.wasDraggable=null)}function De(e,t){if(t instanceof r.NodeSelection){let n=e.docView.descAt(t.from);n!=e.lastSelectedViewDesc&&(_e(e),n&&n.selectNode(),e.lastSelectedViewDesc=n)}else _e(e)}function _e(e){e.lastSelectedViewDesc&&(e.lastSelectedViewDesc.parent&&e.lastSelectedViewDesc.deselectNode(),e.lastSelectedViewDesc=void 0)}function Ee(e,t,n,o){return e.someProp("createSelectionBetween",r=>r(e,t,n))||r.TextSelection.between(t,n,o)}function Pe(e){return!(e.editable&&!e.hasFocus())&&ze(e)}function ze(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 Ie(e,t){let{$anchor:n,$head:o}=e.selection,i=t>0?n.max(o):n.min(o),s=i.parent.inlineContent?i.depth?e.doc.resolve(t>0?i.after():i.before()):null:i;return s&&r.Selection.findFrom(s,t)}function Fe(e,t){return e.dispatch(e.state.tr.setSelection(t).scrollIntoView()),!0}function Be(e,t,n){let o=e.state.selection;if(!(o instanceof r.TextSelection)){if(o instanceof r.NodeSelection&&o.node.isInline)return Fe(e,new r.TextSelection(t>0?o.$to:o.$from));{let n=Ie(e.state,t);return!!n&&Fe(e,n)}}if(!o.empty||n.indexOf("s")>-1)return!1;if(e.endOfTextblock(t>0?"forward":"backward")){let n=Ie(e.state,t);return!!(n&&n instanceof r.NodeSelection)&&Fe(e,n)}if(!(D&&n.indexOf("m")>-1)){let n,i=o.$head,s=i.textOffset?null:t<0?i.nodeBefore:i.nodeAfter;if(!s||s.isText)return!1;let l=t<0?i.pos-s.nodeSize:i.pos;return!!(s.isAtom||(n=e.docView.descAt(l))&&!n.contentDOM)&&(r.NodeSelection.isSelectable(s)?Fe(e,new r.NodeSelection(t<0?e.state.doc.resolve(i.pos-s.nodeSize):i)):!!P&&Fe(e,new r.TextSelection(e.state.doc.resolve(t<0?l:l+s.nodeSize))))}}function je(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function $e(e){let t=e.pmViewDesc;return t&&0==t.size&&(e.nextSibling||"BR"!=e.nodeName)}function Le(e,t){return t<0?function(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let o,i,l=!1;M&&1==n.nodeType&&r<je(n)&&$e(n.childNodes[r])&&(l=!0);for(;;)if(r>0){if(1!=n.nodeType)break;{let e=n.childNodes[r-1];if($e(e))o=n,i=--r;else{if(3!=e.nodeType)break;n=e,r=n.nodeValue.length}}}else{if(Ke(n))break;{let t=n.previousSibling;for(;t&&$e(t);)o=n.parentNode,i=s(t),t=t.previousSibling;if(t)n=t,r=je(n);else{if(n=n.parentNode,n==e.dom)break;r=0}}}l?He(e,n,r):o&&He(e,o,i)}(e):Ve(e)}function Ve(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let o,i,l=je(n);for(;;)if(r<l){if(1!=n.nodeType)break;if(!$e(n.childNodes[r]))break;o=n,i=++r}else{if(Ke(n))break;{let t=n.nextSibling;for(;t&&$e(t);)o=t.parentNode,i=s(t)+1,t=t.nextSibling;if(t)n=t,r=0,l=je(n);else{if(n=n.parentNode,n==e.dom)break;r=l=0}}}o&&He(e,o,i)}function Ke(e){let t=e.pmViewDesc;return t&&t.node&&t.node.isBlock}function He(e,t,n){let r=e.domSelection();if(m(r)){let e=document.createRange();e.setEnd(t,n),e.setStart(t,n),r.removeAllRanges(),r.addRange(e)}else r.extend&&r.extend(t,n);e.domObserver.setCurSelection();let{state:o}=e;setTimeout(()=>{e.state==o&&Oe(e)},50)}function We(e,t){let n=e.state.doc.resolve(t);if(!A&&!_&&n.parent.inlineContent){let r=e.coordsAtPos(t);if(t>n.start()){let n=e.coordsAtPos(t-1),o=(n.top+n.bottom)/2;if(o>r.top&&o<r.bottom&&Math.abs(n.left-r.left)>1)return n.left<r.left?"ltr":"rtl"}if(t<n.end()){let n=e.coordsAtPos(t+1),o=(n.top+n.bottom)/2;if(o>r.top&&o<r.bottom&&Math.abs(n.left-r.left)>1)return n.left>r.left?"ltr":"rtl"}}return"rtl"==getComputedStyle(e.dom).direction?"rtl":"ltr"}function qe(e,t,n){let o=e.state.selection;if(o instanceof r.TextSelection&&!o.empty||n.indexOf("s")>-1)return!1;if(D&&n.indexOf("m")>-1)return!1;let{$from:i,$to:s}=o;if(!i.parent.inlineContent||e.endOfTextblock(t<0?"up":"down")){let n=Ie(e.state,t);if(n&&n instanceof r.NodeSelection)return Fe(e,n)}if(!i.parent.inlineContent){let n=t<0?i:s,l=o instanceof r.AllSelection?r.Selection.near(n,t):r.Selection.findFrom(n,t);return!!l&&Fe(e,l)}return!1}function Je(e,t){if(!(e.state.selection instanceof r.TextSelection))return!0;let{$head:n,$anchor:o,empty:i}=e.state.selection;if(!n.sameParent(o))return!0;if(!i)return!1;if(e.endOfTextblock(t>0?"forward":"backward"))return!0;let s=!n.textOffset&&(t<0?n.nodeBefore:n.nodeAfter);if(s&&!s.isText){let r=e.state.tr;return t<0?r.delete(n.pos-s.nodeSize,n.pos):r.delete(n.pos,n.pos+s.nodeSize),e.dispatch(r),!0}return!1}function Ue(e,t,n){e.domObserver.stop(),t.contentEditable=n,e.domObserver.start()}function Xe(e,t){let n=t.keyCode,r=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||D&&72==n&&"c"==r)return Je(e,-1)||Le(e,-1);if(46==n&&!t.shiftKey||D&&68==n&&"c"==r)return Je(e,1)||Le(e,1);if(13==n||27==n)return!0;if(37==n||D&&66==n&&"c"==r){let t=37==n?"ltr"==We(e,e.state.selection.from)?-1:1:-1;return Be(e,t,r)||Le(e,t)}if(39==n||D&&70==n&&"c"==r){let t=39==n?"ltr"==We(e,e.state.selection.from)?1:-1:1;return Be(e,t,r)||Le(e,t)}return 38==n||D&&80==n&&"c"==r?qe(e,-1,r)||Le(e,-1):40==n||D&&78==n&&"c"==r?function(e){if(!N||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;Ue(e,n,"true"),setTimeout(()=>Ue(e,n,"false"),20)}return!1}(e)||qe(e,1,r)||Ve(e):r==(D?"m":"c")&&(66==n||73==n||89==n||90==n)}function Ge(e,t){e.someProp("transformCopied",n=>{t=n(t,e)});let n=[],{content:r,openStart:i,openEnd:s}=t;for(;i>1&&s>1&&1==r.childCount&&1==r.firstChild.childCount;){i--,s--;let e=r.firstChild;n.push(e.type.name,e.attrs!=e.type.defaultAttrs?e.attrs:null),r=e.content}let l=e.someProp("clipboardSerializer")||o.DOMSerializer.fromSchema(e.state.schema),a=st(),c=a.createElement("div");c.appendChild(l.serializeFragment(r,{document:a}));let d,u=c.firstChild,h=0;for(;u&&1==u.nodeType&&(d=ot[u.nodeName.toLowerCase()]);){for(let e=d.length-1;e>=0;e--){let t=a.createElement(d[e]);for(;c.firstChild;)t.appendChild(c.firstChild);c.appendChild(t),h++}u=c.firstChild}return u&&1==u.nodeType&&u.setAttribute("data-pm-slice",`${i} ${s}${h?" -"+h:""} ${JSON.stringify(n)}`),{dom:c,text:e.someProp("clipboardTextSerializer",n=>n(t,e))||t.content.textBetween(0,t.content.size,"\n\n")}}function Ye(e,t,n,r,i){let s,l,a=i.parent.type.spec.code;if(!n&&!t)return null;let c=t&&(r||a||!n);if(c){if(e.someProp("transformPastedText",n=>{t=n(t,a||r,e)}),a)return t?new o.Slice(o.Fragment.from(e.state.schema.text(t.replace(/\r\n?/g,"\n"))),0,0):o.Slice.empty;let n=e.someProp("clipboardTextParser",n=>n(t,i,r,e));if(n)l=n;else{let n=i.marks(),{schema:r}=e.state,l=o.DOMSerializer.fromSchema(r);s=document.createElement("div"),t.split(/(?:\r\n?|\n)+/).forEach(e=>{let t=s.appendChild(document.createElement("p"));e&&t.appendChild(l.serializeNode(r.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,r=st().createElement("div"),o=/<([a-z][^>\s]+)/i.exec(e);(n=o&&ot[o[1].toLowerCase()])&&(e=n.map(e=>"<"+e+">").join("")+e+n.map(e=>"</"+e+">").reverse().join(""));if(r.innerHTML=e,n)for(let e=0;e<n.length;e++)r=r.querySelector(n[e])||r;return r}(n),P&&function(e){let t=e.querySelectorAll(A?"span:not([class]):not([style])":"span.Apple-converted-space");for(let n=0;n<t.length;n++){let r=t[n];1==r.childNodes.length&&" "==r.textContent&&r.parentNode&&r.parentNode.replaceChild(e.ownerDocument.createTextNode(" "),r)}}(s);let d=s&&s.querySelector("[data-pm-slice]"),u=d&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(d.getAttribute("data-pm-slice")||"");if(u&&u[3])for(let e=+u[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")||o.DOMParser.fromSchema(e.state.schema);l=t.parseSlice(s,{preserveWhitespace:!(!c&&!u),context:i,ruleFromNode:e=>"BR"!=e.nodeName||e.nextSibling||!e.parentNode||Qe.test(e.parentNode.nodeName)?null:{ignore:!0}})}if(u)l=function(e,t){if(!e.size)return e;let n,r=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=r.nodes[n[e]];if(!t||t.hasRequiredAttrs())break;i=o.Fragment.from(t.create(n[e+1],i)),s++,l++}return new o.Slice(i,s,l)}(rt(l,+u[1],+u[2]),u[4]);else if(l=o.Slice.maxOpen(function(e,t){if(e.childCount<2)return e;for(let n=t.depth;n>=0;n--){let r,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&&r.length&&et(n,r,e,s[s.length-1],0))s[s.length-1]=t;else{s.length&&(s[s.length-1]=tt(s[s.length-1],r.length));let t=Ze(e,n);s.push(t),i=i.matchType(t.type),r=n}}),s)return o.Fragment.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=rt(l,e,t)}return e.someProp("transformPasted",t=>{l=t(l,e)}),l}const Qe=/^(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 Ze(e,t,n=0){for(let r=t.length-1;r>=n;r--)e=t[r].create(null,o.Fragment.from(e));return e}function et(e,t,n,r,i){if(i<e.length&&i<t.length&&e[i]==t[i]){let s=et(e,t,n,r.lastChild,i+1);if(s)return r.copy(r.content.replaceChild(r.childCount-1,s));if(r.contentMatchAt(r.childCount).matchType(i==e.length-1?n.type:e[i+1]))return r.copy(r.content.append(o.Fragment.from(Ze(n,e,i+1))))}}function tt(e,t){if(0==t)return e;let n=e.content.replaceChild(e.childCount-1,tt(e.lastChild,t-1)),r=e.contentMatchAt(e.childCount).fillBefore(o.Fragment.empty,!0);return e.copy(n.append(r))}function nt(e,t,n,r,i,s){let l=t<0?e.firstChild:e.lastChild,a=l.content;return e.childCount>1&&(s=0),i<r-1&&(a=nt(a,t,n,r,i+1,s)),i>=n&&(a=t<0?l.contentMatchAt(0).fillBefore(a,s<=i).append(a):a.append(l.contentMatchAt(l.childCount).fillBefore(o.Fragment.empty,!0))),e.replaceChild(t<0?0:e.childCount-1,l.copy(a))}function rt(e,t,n){return t<e.openStart&&(e=new o.Slice(nt(e.content,-1,t,e.openStart,0,e.openEnd),t,e.openEnd)),n<e.openEnd&&(e=new o.Slice(nt(e.content,1,n,e.openEnd,0,0),e.openStart,n)),e}const ot={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 it=null;function st(){return it||(it=document.implementation.createHTMLDocument("title"))}const lt={},at={},ct={touchstart:!0,touchmove:!0};class dt{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.lastAndroidDelete=0,this.composing=!1,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function ut(e,t){e.input.lastSelectionOrigin=t,e.input.lastSelectionTime=Date.now()}function ht(e){e.someProp("handleDOMEvents",t=>{for(let n in t)e.input.eventHandlers[n]||e.dom.addEventListener(n,e.input.eventHandlers[n]=t=>pt(e,t))})}function pt(e,t){return e.someProp("handleDOMEvents",n=>{let r=n[t.type];return!!r&&(r(e,t)||t.defaultPrevented)})}function ft(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 mt(e){return{left:e.clientX,top:e.clientY}}function gt(e,t,n,r,o){if(-1==r)return!1;let i=e.state.doc.resolve(r);for(let r=i.depth+1;r>0;r--)if(e.someProp(t,t=>r>i.depth?t(e,n,i.nodeAfter,i.before(r),o,!0):t(e,n,i.node(r),i.before(r),o,!1)))return!0;return!1}function yt(e,t,n){e.focused||e.focus();let r=e.state.tr.setSelection(t);"pointer"==n&&r.setMeta("pointer",!0),e.dispatch(r)}function vt(e,t,n,o,i){return gt(e,"handleClickOn",t,n,o)||e.someProp("handleClick",n=>n(e,t,o))||(i?function(e,t){if(-1==t)return!1;let n,o,i=e.state.selection;i instanceof r.NodeSelection&&(n=i.node);let s=e.state.doc.resolve(t);for(let e=s.depth+1;e>0;e--){let t=e>s.depth?s.nodeAfter:s.node(e);if(r.NodeSelection.isSelectable(t)){o=n&&i.$from.depth>0&&e>=i.$from.depth&&s.before(i.$from.depth+1)==i.$from.pos?s.before(i.$from.depth):s.before(e);break}}return null!=o&&(yt(e,r.NodeSelection.create(e.state.doc,o),"pointer"),!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&&r.NodeSelection.isSelectable(o))&&(yt(e,new r.NodeSelection(n),"pointer"),!0)}(e,n))}function bt(e,t,n,r){return gt(e,"handleDoubleClickOn",t,n,r)||e.someProp("handleDoubleClick",n=>n(e,t,r))}function wt(e,t,n,o){return gt(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&&(yt(e,r.TextSelection.create(o,0,o.content.size),"pointer"),!0);let i=o.resolve(t);for(let t=i.depth+1;t>0;t--){let n=t>i.depth?i.nodeAfter:i.node(t),s=i.before(t);if(n.inlineContent)yt(e,r.TextSelection.create(o,s+1,s+1+n.content.size),"pointer");else{if(!r.NodeSelection.isSelectable(n))continue;yt(e,r.NodeSelection.create(o,s),"pointer")}return!0}}(e,n,o)}function St(e){return Tt(e)}at.keydown=(e,t)=>{let n=t;if(e.input.shiftKey=16==n.keyCode||n.shiftKey,!Ct(e,n)&&(e.input.lastKeyCode=n.keyCode,e.input.lastKeyCodeTime=Date.now(),!E||!A||13!=n.keyCode))if(229!=n.keyCode&&e.domObserver.forceFlush(),!R||13!=n.keyCode||n.ctrlKey||n.altKey||n.metaKey)e.someProp("handleKeyDown",t=>t(e,n))||Xe(e,n)?n.preventDefault():ut(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,g(13,"Enter"))),e.input.lastIOSEnter=0)},200)}},at.keyup=(e,t)=>{16==t.keyCode&&(e.input.shiftKey=!1)},at.keypress=(e,t)=>{let n=t;if(Ct(e,n)||!n.charCode||n.ctrlKey&&!n.altKey||D&&n.metaKey)return;if(e.someProp("handleKeyPress",t=>t(e,n)))return void n.preventDefault();let o=e.state.selection;if(!(o instanceof r.TextSelection&&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 kt=D?"metaKey":"ctrlKey";lt.mousedown=(e,t)=>{let n=t;e.input.shiftKey=n.shiftKey;let r=St(e),o=Date.now(),i="singleClick";o-e.input.lastClick.time<500&&function(e,t){let n=t.x-e.clientX,r=t.y-e.clientY;return n*n+r*r<100}(n,e.input.lastClick)&&!n[kt]&&("singleClick"==e.input.lastClick.type?i="doubleClick":"doubleClick"==e.input.lastClick.type&&(i="tripleClick")),e.input.lastClick={time:o,x:n.clientX,y:n.clientY,type:i};let s=e.posAtCoords(mt(n));s&&("singleClick"==i?(e.input.mouseDown&&e.input.mouseDown.done(),e.input.mouseDown=new xt(e,s,n,!!r)):("doubleClick"==i?bt:wt)(e,s.pos,s.inside,n)?n.preventDefault():ut(e,"pointer"))};class xt{constructor(e,t,n,o){let i,s;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[kt],this.allowDefault=n.shiftKey,t.inside>-1)i=e.state.doc.nodeAt(t.inside),s=t.inside;else{let n=e.state.doc.resolve(t.pos);i=n.parent,s=n.depth?n.before():0}const l=o?null:n.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a?a.dom:null;let{selection:c}=e.state;(0==n.button&&i.type.spec.draggable&&!1!==i.type.spec.selectable||c instanceof r.NodeSelection&&c.from<=s&&c.to>s)&&(this.mightDrag={node:i,pos:s,addAttr:!(!this.target||this.target.draggable),setUneditable:!(!this.target||!M||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)),ut(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(()=>Oe(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(mt(e))),this.updateAllowDefault(e),this.allowDefault||!t?ut(this.view,"pointer"):vt(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():0==e.button&&(this.flushed||N&&this.mightDrag&&!this.mightDrag.node.isAtom||A&&!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)?(yt(this.view,r.Selection.near(this.view.state.doc.resolve(t.pos)),"pointer"),e.preventDefault()):ut(this.view,"pointer")}move(e){this.updateAllowDefault(e),ut(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 Ct(e,t){return!!e.composing||!!(N&&Math.abs(t.timeStamp-e.input.compositionEndedAt)<500)&&(e.input.compositionEndedAt=-2e8,!0)}lt.touchstart=e=>{e.input.lastTouch=Date.now(),St(e),ut(e,"pointer")},lt.touchmove=e=>{e.input.lastTouch=Date.now(),ut(e,"pointer")},lt.contextmenu=e=>St(e);const Mt=E?5e3:-1;function Ot(e,t){clearTimeout(e.input.composingTimeout),t>-1&&(e.input.composingTimeout=setTimeout(()=>Tt(e),t))}function At(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 Tt(e,t=!1){if(!(E&&e.domObserver.flushingSoon>=0)){if(e.domObserver.forceFlush(),At(e),t||e.docView&&e.docView.dirty){let t=Ce(e);return t&&!t.eq(e.state.selection)?e.dispatch(e.state.tr.setSelection(t)):e.updateState(e.state),!0}return!1}}at.compositionstart=at.compositionupdate=e=>{if(!e.composing){e.domObserver.flush();let{state:t}=e,n=t.selection.$from;if(t.selection.empty&&(t.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(e=>!1===e.type.spec.inclusive)))e.markCursor=e.state.storedMarks||n.marks(),Tt(e,!0),e.markCursor=null;else if(Tt(e),M&&t.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let t=e.domSelectionRange();for(let n=t.focusNode,r=t.focusOffset;n&&1==n.nodeType&&0!=r;){let t=r<0?n.lastChild:n.childNodes[r-1];if(!t)break;if(3==t.nodeType){e.domSelection().collapse(t,t.nodeValue.length);break}n=t,r=-1}}e.input.composing=!0}Ot(e,Mt)},at.compositionend=(e,t)=>{e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=t.timeStamp,e.input.compositionID++,Ot(e,20))};const Nt=x&&C<15||R&&z<604;function Rt(e,t,n,r,i){let s=Ye(e,t,n,r,e.state.selection.$from);if(e.someProp("handlePaste",t=>t(e,i,s||o.Slice.empty)))return!0;if(!s)return!1;let l=function(e){return 0==e.openStart&&0==e.openEnd&&1==e.content.childCount?e.content.firstChild:null}(s),a=l?e.state.tr.replaceSelectionWith(l,r):e.state.tr.replaceSelection(s);return e.dispatch(a.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}lt.copy=at.cut=(e,t)=>{let n=t,r=e.state.selection,o="cut"==n.type;if(r.empty)return;let i=Nt?null:n.clipboardData,s=r.content(),{dom:l,text:a}=Ge(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 r=getSelection(),o=document.createRange();o.selectNodeContents(t),e.dom.blur(),r.removeAllRanges(),r.addRange(o),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),e.focus()},50)}(e,l),o&&e.dispatch(e.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))},at.paste=(e,t)=>{let n=t;if(e.composing&&!E)return;let r=Nt?null:n.clipboardData,o=e.input.shiftKey&&45!=e.input.lastKeyCode;r&&Rt(e,r.getData("text/plain"),r.getData("text/html"),o,n)?n.preventDefault():function(e,t){if(!e.dom.parentNode)return;let n=e.input.shiftKey||e.state.selection.$from.parent.type.spec.code,r=e.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let o=e.input.shiftKey&&45!=e.input.lastKeyCode;setTimeout(()=>{e.focus(),r.parentNode&&r.parentNode.removeChild(r),n?Rt(e,r.value,null,o,t):Rt(e,r.textContent,r.innerHTML,o,t)},50)}(e,n)};class Dt{constructor(e,t){this.slice=e,this.move=t}}const _t=D?"altKey":"ctrlKey";lt.dragstart=(e,t)=>{let n=t,o=e.input.mouseDown;if(o&&o.done(),!n.dataTransfer)return;let i=e.state.selection,s=i.empty?null:e.posAtCoords(mt(n));if(s&&s.pos>=i.from&&s.pos<=(i instanceof r.NodeSelection?i.to-1:i.to));else if(o&&o.mightDrag)e.dispatch(e.state.tr.setSelection(r.NodeSelection.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&&e.dispatch(e.state.tr.setSelection(r.NodeSelection.create(e.state.doc,t.posBefore)))}let l=e.state.selection.content(),{dom:a,text:c}=Ge(e,l);n.dataTransfer.clearData(),n.dataTransfer.setData(Nt?"Text":"text/html",a.innerHTML),n.dataTransfer.effectAllowed="copyMove",Nt||n.dataTransfer.setData("text/plain",c),e.dragging=new Dt(l,!n[_t])},lt.dragend=e=>{let t=e.dragging;window.setTimeout(()=>{e.dragging==t&&(e.dragging=null)},50)},at.dragover=at.dragenter=(e,t)=>t.preventDefault(),at.drop=(e,t)=>{let n=t,s=e.dragging;if(e.dragging=null,!n.dataTransfer)return;let l=e.posAtCoords(mt(n));if(!l)return;let a=e.state.doc.resolve(l.pos),c=s&&s.slice;c?e.someProp("transformPasted",t=>{c=t(c,e)}):c=Ye(e,n.dataTransfer.getData(Nt?"Text":"text/plain"),Nt?null:n.dataTransfer.getData("text/html"),!1,a);let d=!(!s||n[_t]);if(e.someProp("handleDrop",t=>t(e,n,c||o.Slice.empty,d)))return void n.preventDefault();if(!c)return;n.preventDefault();let u=c?Object(i.dropPoint)(e.state.doc,a.pos,c):a.pos;null==u&&(u=a.pos);let h=e.state.tr;d&&h.deleteSelection();let p=h.mapping.map(u),f=0==c.openStart&&0==c.openEnd&&1==c.content.childCount,m=h.doc;if(f?h.replaceRangeWith(p,p,c.content.firstChild):h.replaceRange(p,p,c),h.doc.eq(m))return;let g=h.doc.resolve(p);if(f&&r.NodeSelection.isSelectable(c.content.firstChild)&&g.nodeAfter&&g.nodeAfter.sameMarkup(c.content.firstChild))h.setSelection(new r.NodeSelection(g));else{let t=h.mapping.map(u);h.mapping.maps[h.mapping.maps.length-1].forEach((e,n,r,o)=>t=o),h.setSelection(Ee(e,g,h.doc.resolve(t)))}e.focus(),e.dispatch(h.setMeta("uiEvent","drop"))},lt.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())&&Oe(e)},20))},lt.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)},lt.beforeinput=(e,t)=>{if(A&&E&&"deleteContentBackward"==t.inputType){e.domObserver.flushSoon();let{domChangeCount:t}=e.input;setTimeout(()=>{if(e.input.domChangeCount!=t)return;if(e.dom.blur(),e.focus(),e.someProp("handleKeyDown",t=>t(e,g(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 at)lt[e]=at[e];function Et(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 Pt{constructor(e,t){this.toDOM=e,this.spec=t||jt,this.side=this.spec.side||0}map(e,t,n,r){let{pos:o,deleted:i}=e.mapResult(t.from+r,this.side<0?-1:1);return i?null:new Ft(o-n,o-n,this)}valid(){return!0}eq(e){return this==e||e instanceof Pt&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Et(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class zt{constructor(e,t){this.attrs=e,this.spec=t||jt}map(e,t,n,r){let o=e.map(t.from+r,this.spec.inclusiveStart?-1:1)-n,i=e.map(t.to+r,this.spec.inclusiveEnd?1:-1)-n;return o>=i?null:new Ft(o,i,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof zt&&Et(this.attrs,e.attrs)&&Et(this.spec,e.spec)}static is(e){return e.type instanceof zt}destroy(){}}class It{constructor(e,t){this.attrs=e,this.spec=t||jt}map(e,t,n,r){let o=e.mapResult(t.from+r,1);if(o.deleted)return null;let i=e.mapResult(t.to+r,-1);return i.deleted||i.pos<=o.pos?null:new Ft(o.pos-n,i.pos-n,this)}valid(e,t){let n,{index:r,offset:o}=e.content.findIndex(t.from);return o==t.from&&!(n=e.child(r)).isText&&o+n.nodeSize==t.to}eq(e){return this==e||e instanceof It&&Et(this.attrs,e.attrs)&&Et(this.spec,e.spec)}destroy(){}}class Ft{constructor(e,t,n){this.from=e,this.to=t,this.type=n}copy(e,t){return new Ft(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 Ft(e,e,new Pt(t,n))}static inline(e,t,n,r){return new Ft(e,t,new zt(n,r))}static node(e,t,n,r){return new Ft(e,t,new It(n,r))}get spec(){return this.type.spec}get inline(){return this.type instanceof zt}}const Bt=[],jt={};class $t{constructor(e,t){this.local=e.length?e:Bt,this.children=t.length?t:Bt}static create(e,t){return t.length?qt(t,e,0,jt):Lt}find(e,t,n){let r=[];return this.findInner(null==e?0:e,null==t?1e9:t,r,0,n),r}findInner(e,t,n,r,o){for(let i=0;i<this.local.length;i++){let s=this.local[i];s.from<=t&&s.to>=e&&(!o||o(s.spec))&&n.push(s.copy(s.from+r,s.to+r))}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,r+s,o)}}map(e,t,n){return this==Lt||0==e.maps.length?this:this.mapInner(e,t,0,0,n||jt)}mapInner(e,t,n,r,o){let i;for(let s=0;s<this.local.length;s++){let l=this.local[s].map(e,n,r);l&&l.type.valid(t,l)?(i||(i=[])).push(l):o.onRemove&&o.onRemove(this.local[s].spec)}return this.children.length?function(e,t,n,r,o,i,s){let l=e.slice();for(let e=0,t=i;e<n.maps.length;e++){let r=0;n.maps[e].forEach((e,n,i,s)=>{let a=s-i-(n-e);for(let s=0;s<l.length;s+=3){let c=l[s+1];if(c<0||e>c+t-r)continue;let d=l[s]+t-r;n>=d?l[s+1]=e<=d?-2:-1:i>=o&&a&&(l[s]+=a,l[s+1]+=a)}r+=a}),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-o;if(d<0||d>=r.content.size){a=!0;continue}let u=n.map(e[t+1]+i,-1)-o,{index:h,offset:p}=r.content.findIndex(d),f=r.maybeChild(h);if(f&&p==d&&p+f.nodeSize==u){let r=l[t+2].mapInner(n,f,c+1,e[t]+i+1,s);r!=Lt?(l[t]=d,l[t+1]=u,l[t+2]=r):(l[t+1]=-2,a=!0)}else a=!0}if(a){let a=qt(function(e,t,n,r,o,i,s){function l(e,t){for(let i=0;i<e.local.length;i++){let l=e.local[i].map(r,o,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,o,i,s),r,0,s);t=a.local;for(let e=0;e<l.length;e+=3)l[e+1]<0&&(l.splice(e,3),e-=3);for(let e=0,t=0;e<a.children.length;e+=3){let n=a.children[e];for(;t<l.length&&l[t]<n;)t+=3;l.splice(t,0,a.children[e],a.children[e+1],a.children[e+2])}}return new $t(t.sort(Jt),l)}(this.children,i||[],e,t,n,r,o):i?new $t(i.sort(Jt),Bt):Lt}add(e,t){return t.length?this==Lt?$t.create(e,t):this.addInner(e,t,0):this}addInner(e,t,n){let r,o=0;e.forEach((e,i)=>{let s,l=i+n;if(s=Ht(t,e,l)){for(r||(r=this.children.slice());o<r.length&&r[o]<i;)o+=3;r[o]==i?r[o+2]=r[o+2].addInner(e,s,l+1):r.splice(o,0,i,i+e.nodeSize,qt(s,e,l+1,jt)),o+=3}});let i=Kt(o?Wt(t):t,-n);for(let t=0;t<i.length;t++)i[t].type.valid(e,i[t])||i.splice(t--,1);return new $t(i.length?this.local.concat(i).sort(Jt):this.local,r||this.children)}remove(e){return 0==e.length||this==Lt?this:this.removeInner(e,0)}removeInner(e,t){let n=this.children,r=this.local;for(let r=0;r<n.length;r+=3){let o,i=n[r]+t,s=n[r+1]+t;for(let t,n=0;n<e.length;n++)(t=e[n])&&t.from>i&&t.to<s&&(e[n]=null,(o||(o=[])).push(t));if(!o)continue;n==this.children&&(n=this.children.slice());let l=n[r+2].removeInner(o,i+1);l!=Lt?n[r+2]=l:(n.splice(r,3),r-=3)}if(r.length)for(let n,o=0;o<e.length;o++)if(n=e[o])for(let e=0;e<r.length;e++)r[e].eq(n,t)&&(r==this.local&&(r=this.local.slice()),r.splice(e--,1));return n==this.children&&r==this.local?this:r.length||n.length?new $t(r,n):Lt}forChild(e,t){if(this==Lt)return this;if(t.isLeaf)return $t.empty;let n,r;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 o=e+1,i=o+t.content.size;for(let e=0;e<this.local.length;e++){let t=this.local[e];if(t.from<i&&t.to>o&&t.type instanceof zt){let e=Math.max(o,t.from)-o,n=Math.min(i,t.to)-o;e<n&&(r||(r=[])).push(t.copy(e,n))}}if(r){let e=new $t(r.sort(Jt),Bt);return n?new Vt([e,n]):e}return n||Lt}eq(e){if(this==e)return!0;if(!(e instanceof $t)||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 Ut(this.localsInner(e))}localsInner(e){if(this==Lt)return Bt;if(e.inlineContent||!this.local.some(zt.is))return this.local;let t=[];for(let e=0;e<this.local.length;e++)this.local[e].type instanceof zt||t.push(this.local[e]);return t}}$t.empty=new $t([],[]),$t.removeOverlap=Ut;const Lt=$t.empty;class Vt{constructor(e){this.members=e}map(e,t){const n=this.members.map(n=>n.map(e,t,jt));return Vt.from(n)}forChild(e,t){if(t.isLeaf)return $t.empty;let n=[];for(let r=0;r<this.members.length;r++){let o=this.members[r].forChild(e,t);o!=Lt&&(o instanceof Vt?n=n.concat(o.members):n.push(o))}return Vt.from(n)}eq(e){if(!(e instanceof Vt)||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 r=0;r<this.members.length;r++){let o=this.members[r].localsInner(e);if(o.length)if(t){n&&(t=t.slice(),n=!1);for(let e=0;e<o.length;e++)t.push(o[e])}else t=o}return t?Ut(n?t:t.sort(Jt)):Bt}static from(e){switch(e.length){case 0:return Lt;case 1:return e[0];default:return new Vt(e.every(e=>e instanceof $t)?e:e.reduce((e,t)=>e.concat(t instanceof $t?t:t.members),[]))}}}function Kt(e,t){if(!t||!e.length)return e;let n=[];for(let r=0;r<e.length;r++){let o=e[r];n.push(new Ft(o.from+t,o.to+t,o.type))}return n}function Ht(e,t,n){if(t.isLeaf)return null;let r=n+t.nodeSize,o=null;for(let t,i=0;i<e.length;i++)(t=e[i])&&t.from>n&&t.to<r&&((o||(o=[])).push(t),e[i]=null);return o}function Wt(e){let t=[];for(let n=0;n<e.length;n++)null!=e[n]&&t.push(e[n]);return t}function qt(e,t,n,r){let o=[],i=!1;t.forEach((t,s)=>{let l=Ht(e,t,s+n);if(l){i=!0;let e=qt(l,t,n+s+1,r);e!=Lt&&o.push(s,s+t.nodeSize,e)}});let s=Kt(i?Wt(e):e,-n).sort(Jt);for(let e=0;e<s.length;e++)s[e].type.valid(t,s[e])||(r.onRemove&&r.onRemove(s[e].spec),s.splice(e--,1));return s.length||o.length?new $t(s,o):Lt}function Jt(e,t){return e.from-t.from||e.to-t.to}function Ut(e){let t=e;for(let n=0;n<t.length-1;n++){let r=t[n];if(r.from!=r.to)for(let o=n+1;o<t.length;o++){let i=t[o];if(i.from!=r.from){i.from<r.to&&(t==e&&(t=e.slice()),t[n]=r.copy(r.from,i.from),Xt(t,o,r.copy(i.from,r.to)));break}i.to!=r.to&&(t==e&&(t=e.slice()),t[o]=i.copy(i.from,r.to),Xt(t,o+1,i.copy(r.to,i.to)))}}return t}function Xt(e,t,n){for(;t<e.length&&Jt(n,e[t])>0;)t++;e.splice(t,0,n)}function Gt(e){let t=[];return e.someProp("decorations",n=>{let r=n(e.state);r&&r!=Lt&&t.push(r)}),e.cursorWrapper&&t.push($t.create(e.state.doc,[e.cursorWrapper.deco])),Vt.from(t)}const Yt={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},Qt=x&&C<=11;class Zt{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 en{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new Zt,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.observer=window.MutationObserver&&new window.MutationObserver(e=>{for(let t=0;t<e.length;t++)this.queue.push(e[t]);x&&C<=11&&e.some(e=>"childList"==e.type&&e.removedNodes.length||"characterData"==e.type&&e.oldValue.length>e.target.nodeValue.length)?this.flushSoon():this.flush()}),Qt&&(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,Yt)),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(Pe(this.view)){if(this.suppressingSelectionUpdates)return Oe(this.view);if(x&&C<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&d(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=l(t))n.add(t);for(let r=e.anchorNode;r;r=l(r))if(n.has(r)){t=r;break}let r=t&&this.view.docView.nearestDesc(t);return r&&r.ignoreMutation({type:"selection",target:3==t.nodeType?t.parentNode:t})?(this.setCurSelection(),!0):void 0}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.observer?this.observer.takeRecords():[];this.queue.length&&(t=this.queue.concat(t),this.queue.length=0);let n=e.domSelectionRange(),o=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(n)&&Pe(e)&&!this.ignoreSelectionChange(n),i=-1,s=-1,l=!1,a=[];if(e.editable)for(let e=0;e<t.length;e++){let n=this.registerMutation(t[e],a);n&&(i=i<0?n.from:Math.min(n.from,i),s=s<0?n.to:Math.max(n.to,s),n.typeOver&&(l=!0))}if(M&&a.length>1){let e=a.filter(e=>"BR"==e.nodeName);if(2==e.length){let t=e[0],n=e[1];t.parentNode&&t.parentNode.parentNode==n.parentNode?n.remove():t.remove()}}let c=null;i<0&&o&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&m(n)&&(c=Ce(e))&&c.eq(r.Selection.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,Oe(e),this.currentSelection.set(n),e.scrollToSelection()):(i>-1||o)&&(i>-1&&(e.docView.markDirty(i,s),function(e){if(tn.has(e))return;if(tn.set(e,null),-1!==["normal","nowrap","pre-line"].indexOf(getComputedStyle(e.dom).whiteSpace)){if(e.requiresGeckoHackNode=M,nn)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."),nn=!0}}(e)),this.handleDOMChange(i,s,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(n)||Oe(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++)t.push(e.addedNodes[n]);if(n.contentDOM&&n.contentDOM!=n.dom&&!n.contentDOM.contains(e.target))return{from:n.posBefore,to:n.posAfter};let r=e.previousSibling,o=e.nextSibling;if(x&&C<=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)&&(r=n),(!i||Array.prototype.indexOf.call(e.addedNodes,i)<0)&&(o=i)}let i=r&&r.parentNode==e.target?s(r)+1:0,l=n.localPosFromDOM(e.target,i,-1),a=o&&o.parentNode==e.target?s(o):e.target.childNodes.length;return{from:l,to:n.localPosFromDOM(e.target,a,1)}}return"attributes"==e.type?{from:n.posAtStart-n.border,to:n.posAtEnd+n.border}:{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}}}let tn=new WeakMap,nn=!1;function rn(e){let t=e.pmViewDesc;if(t)return t.parseRule();if("BR"==e.nodeName&&e.parentNode){if(N&&/^(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||N&&/^(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 on=/^(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 sn(e,t,n,i,s){if(t<0){let t=e.input.lastSelectionTime>Date.now()-50?e.input.lastSelectionOrigin:null,n=Ce(e,t);if(n&&!e.state.selection.eq(n)){if(A&&E&&13===e.input.lastKeyCode&&Date.now()-100<e.input.lastKeyCodeTime&&e.someProp("handleKeyDown",t=>t(e,g(13,"Enter"))))return;let r=e.state.tr.setSelection(n);"pointer"==t?r.setMeta("pointer",!0):"key"==t&&r.scrollIntoView(),e.composing&&r.setMeta("composition",e.input.compositionID),e.dispatch(r)}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,u=e.state.selection,h=function(e,t,n){let r,{node:i,fromOffset:s,toOffset:l,from:a,to:c}=e.docView.parseRange(t,n),d=e.domSelectionRange(),u=d.anchorNode;if(u&&e.dom.contains(1==u.nodeType?u:u.parentNode)&&(r=[{node:u,offset:d.anchorOffset}],m(d)||r.push({node:d.focusNode,offset:d.focusOffset})),A&&8===e.input.lastKeyCode)for(let e=l;e>s;e--){let t=i.childNodes[e-1],n=t.pmViewDesc;if("BR"==t.nodeName&&!n){l=e;break}if(!n||n.size)break}let h=e.state.doc,p=e.someProp("domParser")||o.DOMParser.fromSchema(e.state.schema),f=h.resolve(a),g=null,y=p.parse(i,{topNode:f.parent,topMatch:f.parent.contentMatchAt(f.index()),topOpen:!0,from:s,to:l,preserveWhitespace:"pre"!=f.parent.type.whitespace||"full",findPositions:r,ruleFromNode:rn,context:f});if(r&&null!=r[0].pos){let e=r[0].pos,t=r[1]&&r[1].pos;null==t&&(t=e),g={anchor:e+a,head:t+a}}return{doc:y,sel:g,from:a,to:c}}(e,t,n),p=e.state.doc,f=p.slice(h.from,h.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 y=function(e,t,n,r,o){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"==o){let e=Math.max(0,i-Math.min(s,l));r-=s+e-i}if(s<i&&e.size<t.size){i-=r<=i&&r>=s?i-r:0,l=i+(l-s),s=i}else if(l<i){i-=r<=i&&r>=l?i-r:0,s=i+(s-l),l=i}return{start:i,endA:s,endB:l}}(f.content,h.doc.content,h.from,c,d);if((R&&e.input.lastIOSEnter>Date.now()-225||E)&&s.some(e=>1==e.nodeType&&!on.test(e.nodeName))&&(!y||y.endA>=y.endB)&&e.someProp("handleKeyDown",t=>t(e,g(13,"Enter"))))return void(e.input.lastIOSEnter=0);if(!y){if(!(i&&u instanceof r.TextSelection&&!u.empty&&u.$head.sameParent(u.$anchor))||e.composing||h.sel&&h.sel.anchor!=h.sel.head){if(h.sel){let t=ln(e,e.state.doc,h.sel);if(t&&!t.eq(e.state.selection)){let n=e.state.tr.setSelection(t);e.composing&&n.setMeta("composition",e.input.compositionID),e.dispatch(n)}}return}y={start:u.from,endA:u.to,endB:u.to}}if(A&&e.cursorWrapper&&h.sel&&h.sel.anchor==e.cursorWrapper.deco.from&&h.sel.head==h.sel.anchor){let e=y.endB-y.start;h.sel={anchor:h.sel.anchor+e,head:h.sel.anchor+e}}e.input.domChangeCount++,e.state.selection.from<e.state.selection.to&&y.start==y.endB&&e.state.selection instanceof r.TextSelection&&(y.start>e.state.selection.from&&y.start<=e.state.selection.from+2&&e.state.selection.from>=h.from?y.start=e.state.selection.from:y.endA<e.state.selection.to&&y.endA>=e.state.selection.to-2&&e.state.selection.to<=h.to&&(y.endB+=e.state.selection.to-y.endA,y.endA=e.state.selection.to)),x&&C<=11&&y.endB==y.start+1&&y.endA==y.start&&y.start>h.from&&"  "==h.doc.textBetween(y.start-h.from-1,y.start-h.from+1)&&(y.start--,y.endA--,y.endB--);let v,b=h.doc.resolveNoCache(y.start-h.from),w=h.doc.resolveNoCache(y.endB-h.from),S=p.resolve(y.start),k=b.sameParent(w)&&b.parent.inlineContent&&S.end()>=y.endA;if((R&&e.input.lastIOSEnter>Date.now()-225&&(!k||s.some(e=>"DIV"==e.nodeName||"P"==e.nodeName))||!k&&b.pos<h.doc.content.size&&!b.sameParent(w)&&(v=r.Selection.findFrom(h.doc.resolve(b.pos+1),1,!0))&&v.head==w.pos)&&e.someProp("handleKeyDown",t=>t(e,g(13,"Enter"))))return void(e.input.lastIOSEnter=0);if(e.state.selection.anchor>y.start&&function(e,t,n,r,o){if(!r.parent.isTextblock||n-t<=o.pos-r.pos||an(r,!0,!1)<o.pos)return!1;let i=e.resolve(t);if(i.parentOffset<i.parent.content.size||!i.parent.isTextblock)return!1;let s=e.resolve(an(i,!0,!0));return!(!s.parent.isTextblock||s.pos>n||an(s,!0,!1)<n)&&r.parent.content.cut(r.parentOffset).eq(s.parent.content)}(p,y.start,y.endA,b,w)&&e.someProp("handleKeyDown",t=>t(e,g(8,"Backspace"))))return void(E&&A&&e.domObserver.suppressSelectionUpdates());A&&E&&y.endB==y.start&&(e.input.lastAndroidDelete=Date.now()),E&&!k&&b.start()!=w.start()&&0==w.parentOffset&&b.depth==w.depth&&h.sel&&h.sel.anchor==h.sel.head&&h.sel.head==y.endA&&(y.endB-=2,w=h.doc.resolveNoCache(y.endB-h.from),setTimeout(()=>{e.someProp("handleKeyDown",(function(t){return t(e,g(13,"Enter"))}))},20));let M,O,T,N=y.start,D=y.endA;if(k)if(b.pos==w.pos)x&&C<=11&&0==b.parentOffset&&(e.domObserver.suppressSelectionUpdates(),setTimeout(()=>Oe(e),20)),M=e.state.tr.delete(N,D),O=p.resolve(y.start).marksAcross(p.resolve(y.endA));else if(y.endA==y.endB&&(T=function(e,t){let n,r,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)r=a[0],n="add",i=e=>e.mark(r.addToSet(e.marks));else{if(0!=a.length||1!=c.length)return null;r=c[0],n="remove",i=e=>e.mark(r.removeFromSet(e.marks))}let d=[];for(let e=0;e<t.childCount;e++)d.push(i(t.child(e)));if(o.Fragment.from(d).eq(e))return{mark:r,type:n}}(b.parent.content.cut(b.parentOffset,w.parentOffset),S.parent.content.cut(S.parentOffset,y.endA-S.start()))))M=e.state.tr,"add"==T.type?M.addMark(N,D,T.mark):M.removeMark(N,D,T.mark);else if(b.parent.child(b.index()).isText&&b.index()==w.index()-(w.textOffset?0:1)){let t=b.parent.textBetween(b.parentOffset,w.parentOffset);if(e.someProp("handleTextInput",n=>n(e,N,D,t)))return;M=e.state.tr.insertText(t,N,D)}if(M||(M=e.state.tr.replace(N,D,h.doc.slice(y.start-h.from,y.endB-h.from))),h.sel){let t=ln(e,M.doc,h.sel);t&&!(A&&E&&e.composing&&t.empty&&(y.start!=y.endB||e.input.lastAndroidDelete<Date.now()-100)&&(t.head==N||t.head==M.mapping.map(D)-1)||x&&t.empty&&t.head==N)&&M.setSelection(t)}O&&M.ensureMarks(O),e.composing&&M.setMeta("composition",e.input.compositionID),e.dispatch(M.scrollIntoView())}function ln(e,t,n){return Math.max(n.anchor,n.head)>t.content.size?null:Ee(e,t.resolve(n.anchor),t.resolve(n.head))}function an(e,t,n){let r=e.depth,o=t?e.end():e.pos;for(;r>0&&(t||e.indexAfter(r)==e.node(r).childCount);)r--,o++,t=!1;if(n){let t=e.node(r).maybeChild(e.indexAfter(r));for(;t&&!t.isLeaf;)t=t.firstChild,o++}return o}const cn=Ge,dn=Ye,un=Tt;class hn{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 dt,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(yn),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=mn(this),fn(this),this.nodeViews=gn(this),this.docView=ce(this.state.doc,pn(this),Gt(this),this.dom,this),this.domObserver=new en(this,(e,t,n,r)=>sn(this,e,t,n,r)),this.domObserver.start(),function(e){for(let t in lt){let n=lt[t];e.dom.addEventListener(t,e.input.eventHandlers[t]=t=>{!ft(e,t)||pt(e,t)||!e.editable&&t.type in at||n(e,t)},ct[t]?{passive:!0}:void 0)}N&&e.dom.addEventListener("input",()=>null),ht(e)}(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let t in e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&ht(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(yn),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){let n=this.state,r=!1,o=!1;e.storedMarks&&this.composing&&(At(this),o=!0),this.state=e;let i=n.plugins!=e.plugins||this._props.plugins!=t.plugins;if(i||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let e=gn(this);(function(e,t){let n=0,r=0;for(let r in e){if(e[r]!=t[r])return!0;n++}for(let e in t)r++;return n!=r})(e,this.nodeViews)&&(this.nodeViews=e,r=!0)}(i||t.handleDOMEvents!=this._props.handleDOMEvents)&&ht(this),this.editable=mn(this),fn(this);let s=Gt(this),l=pn(this),a=n.plugins==e.plugins||n.doc.eq(e.doc)?e.scrollToSelection>n.scrollToSelection?"to selection":"preserve":"reset",c=r||!this.docView.matchesNode(e.doc,l,s);!c&&e.selection.eq(n.selection)||(o=!0);let u="preserve"==a&&o&&null==this.dom.style.overflowAnchor&&function(e){let t,n,r=e.dom.getBoundingClientRect(),o=Math.max(0,r.top);for(let i=(r.left+r.right)/2,s=o+1;s<Math.min(innerHeight,r.bottom);s+=5){let r=e.root.elementFromPoint(i,s);if(!r||r==e.dom||!e.dom.contains(r))continue;let l=r.getBoundingClientRect();if(l.top>=o-20){t=r,n=l.top;break}}return{refDOM:t,refTop:n,stack:$(e.dom)}}(this);if(o){this.domObserver.stop();let t=c&&(x||A)&&!this.composing&&!n.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)}(n.selection,e.selection);if(c){let n=A?this.trackWrites=this.domSelectionRange().focusNode:null;!r&&this.docView.update(e.doc,l,s,this)||(this.docView.updateOuterDeco([]),this.docView.destroy(),this.docView=ce(e.doc,l,s,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 d(t.node,t.offset,n.anchorNode,n.anchorOffset)}(this))?Oe(this,t):(De(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(n),"reset"==a?this.dom.scrollTop=0:"to selection"==a?this.scrollToSelection():u&&function({refDOM:e,refTop:t,stack:n}){let r=e?e.getBoundingClientRect().top:0;L(n,0==r?0:r-t)}(u)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(this.someProp("handleScrollToSelection",e=>e(this)));else if(this.state.selection instanceof r.NodeSelection){let t=this.docView.domAfterPos(this.state.selection.from);1==t.nodeType&&j(this,t.getBoundingClientRect(),e)}else j(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))}}}someProp(e,t){let n,r=this._props&&this._props[e];if(null!=r&&(n=t?t(r):r))return n;for(let r=0;r<this.directPlugins.length;r++){let o=this.directPlugins[r].props[e];if(null!=o&&(n=t?t(o):o))return n}let o=this.state.plugins;if(o)for(let r=0;r<o.length;r++){let i=o[r].props[e];if(null!=i&&(n=t?t(i):i))return n}}hasFocus(){if(x){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(V)return e.focus(V);let t=$(e);e.focus(null==V?{get preventScroll(){return V={preventScroll:!0},!0}}:void 0),V||(V=!1,L(t,0))}(this.dom),Oe(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}posAtCoords(e){return W(this,e)}coordsAtPos(e,t=1){return X(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 r=this.docView.posFromDOM(e,t,n);if(null==r)throw new RangeError("DOM position not inside the editor");return r}endOfTextblock(e,t){return re(this,t||this.state,e)}pasteHTML(e,t){return Rt(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return Rt(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,[],Gt(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null)}get isDestroyed(){return null==this.docView}dispatchEvent(e){return function(e,t){pt(e,t)||!lt[t.type]||!e.editable&&t.type in at||lt[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(){return N&&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){let t;function n(e){e.preventDefault(),e.stopImmediatePropagation(),t=e.getTargetRanges()[0]}e.dom.addEventListener("beforeinput",n,!0),document.execCommand("indent"),e.dom.removeEventListener("beforeinput",n,!0);let r=t.startContainer,o=t.startOffset,i=t.endContainer,s=t.endOffset,l=e.domAtPos(e.state.selection.anchor);return d(l.node,l.offset,i,s)&&([r,o,i,s]=[i,s,r,o]),{anchorNode:r,anchorOffset:o,focusNode:i,focusOffset:s}}(this):this.domSelection()}domSelection(){return this.root.getSelection()}}function pn(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"),[Ft.node(0,e.state.doc.content.size,t)]}function fn(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:Ft.widget(e.state.selection.head,t,{raw:!0,marks:e.markCursor})}}else e.cursorWrapper=null}function mn(e){return!e.someProp("editable",t=>!1===t(e.state))}function gn(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 yn(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")}},function(e,t,n){"use strict";n.r(t),n.d(t,"__extends",(function(){return o})),n.d(t,"__assign",(function(){return i})),n.d(t,"__rest",(function(){return s})),n.d(t,"__decorate",(function(){return l})),n.d(t,"__param",(function(){return a})),n.d(t,"__esDecorate",(function(){return c})),n.d(t,"__runInitializers",(function(){return d})),n.d(t,"__propKey",(function(){return u})),n.d(t,"__setFunctionName",(function(){return h})),n.d(t,"__metadata",(function(){return p})),n.d(t,"__awaiter",(function(){return f})),n.d(t,"__generator",(function(){return m})),n.d(t,"__createBinding",(function(){return g})),n.d(t,"__exportStar",(function(){return y})),n.d(t,"__values",(function(){return v})),n.d(t,"__read",(function(){return b})),n.d(t,"__spread",(function(){return w})),n.d(t,"__spreadArrays",(function(){return S})),n.d(t,"__spreadArray",(function(){return k})),n.d(t,"__await",(function(){return x})),n.d(t,"__asyncGenerator",(function(){return C})),n.d(t,"__asyncDelegator",(function(){return M})),n.d(t,"__asyncValues",(function(){return O})),n.d(t,"__makeTemplateObject",(function(){return A})),n.d(t,"__importStar",(function(){return N})),n.d(t,"__importDefault",(function(){return R})),n.d(t,"__classPrivateFieldGet",(function(){return D})),n.d(t,"__classPrivateFieldSet",(function(){return _})),n.d(t,"__classPrivateFieldIn",(function(){return E})),n.d(t,"__addDisposableResource",(function(){return P})),n.d(t,"__disposeResources",(function(){return I}));var r=function(e,t){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,t)};function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var i=function(){return(i=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function s(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}function l(e,t,n,r){var o,i=arguments.length,s=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var l=e.length-1;l>=0;l--)(o=e[l])&&(s=(i<3?o(s):i>3?o(t,n,s):o(t,n))||s);return i>3&&s&&Object.defineProperty(t,n,s),s}function a(e,t){return function(n,r){t(n,r,e)}}function c(e,t,n,r,o,i){function s(e){if(void 0!==e&&"function"!=typeof e)throw new TypeError("Function expected");return e}for(var l,a=r.kind,c="getter"===a?"get":"setter"===a?"set":"value",d=!t&&e?r.static?e:e.prototype:null,u=t||(d?Object.getOwnPropertyDescriptor(d,r.name):{}),h=!1,p=n.length-1;p>=0;p--){var f={};for(var m in r)f[m]="access"===m?{}:r[m];for(var m in r.access)f.access[m]=r.access[m];f.addInitializer=function(e){if(h)throw new TypeError("Cannot add initializers after decoration has completed");i.push(s(e||null))};var g=(0,n[p])("accessor"===a?{get:u.get,set:u.set}:u[c],f);if("accessor"===a){if(void 0===g)continue;if(null===g||"object"!=typeof g)throw new TypeError("Object expected");(l=s(g.get))&&(u.get=l),(l=s(g.set))&&(u.set=l),(l=s(g.init))&&o.unshift(l)}else(l=s(g))&&("field"===a?o.unshift(l):u[c]=l)}d&&Object.defineProperty(d,r.name,u),h=!0}function d(e,t,n){for(var r=arguments.length>2,o=0;o<t.length;o++)n=r?t[o].call(e,n):t[o].call(e);return r?n:void 0}function u(e){return"symbol"==typeof e?e:"".concat(e)}function h(e,t,n){return"symbol"==typeof t&&(t=t.description?"[".concat(t.description,"]"):""),Object.defineProperty(e,"name",{configurable:!0,value:n?"".concat(n," ",t):t})}function p(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function f(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{a(r.next(e))}catch(e){i(e)}}function l(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,l)}a((r=r.apply(e,t||[])).next())}))}function m(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function l(l){return function(a){return function(l){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,l[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&l[0]?r.return:l[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,l[1])).done)return o;switch(r=0,o&&(l=[2&l[0],o.value]),l[0]){case 0:case 1:o=l;break;case 4:return s.label++,{value:l[1],done:!1};case 5:s.label++,r=l[1],l=[0];continue;case 7:l=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==l[0]&&2!==l[0])){s=0;continue}if(3===l[0]&&(!o||l[1]>o[0]&&l[1]<o[3])){s.label=l[1];break}if(6===l[0]&&s.label<o[1]){s.label=o[1],o=l;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(l);break}o[2]&&s.ops.pop(),s.trys.pop();continue}l=t.call(e,s)}catch(e){l=[6,e],r=0}finally{n=o=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}([l,a])}}}var g=Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]};function y(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||g(t,e,n)}function v(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function b(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,i=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return s}function w(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(b(arguments[t]));return e}function S(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;var r=Array(e),o=0;for(t=0;t<n;t++)for(var i=arguments[t],s=0,l=i.length;s<l;s++,o++)r[o]=i[s];return r}function k(e,t,n){if(n||2===arguments.length)for(var r,o=0,i=t.length;o<i;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))}function x(e){return this instanceof x?(this.v=e,this):new x(e)}function C(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r,o=n.apply(e,t||[]),i=[];return r={},s("next"),s("throw"),s("return"),r[Symbol.asyncIterator]=function(){return this},r;function s(e){o[e]&&(r[e]=function(t){return new Promise((function(n,r){i.push([e,t,n,r])>1||l(e,t)}))})}function l(e,t){try{(n=o[e](t)).value instanceof x?Promise.resolve(n.value.v).then(a,c):d(i[0][2],n)}catch(e){d(i[0][3],e)}var n}function a(e){l("next",e)}function c(e){l("throw",e)}function d(e,t){e(t),i.shift(),i.length&&l(i[0][0],i[0][1])}}function M(e){var t,n;return t={},r("next"),r("throw",(function(e){throw e})),r("return"),t[Symbol.iterator]=function(){return this},t;function r(r,o){t[r]=e[r]?function(t){return(n=!n)?{value:x(e[r](t)),done:!1}:o?o(t):t}:o}}function O(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,n=e[Symbol.asyncIterator];return n?n.call(e):(e=v(e),t={},r("next"),r("throw"),r("return"),t[Symbol.asyncIterator]=function(){return this},t);function r(n){t[n]=e[n]&&function(t){return new Promise((function(r,o){(function(e,t,n,r){Promise.resolve(r).then((function(t){e({value:t,done:n})}),t)})(r,o,(t=e[n](t)).done,t.value)}))}}}function A(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}var T=Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t};function N(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&g(t,e,n);return T(t,e),t}function R(e){return e&&e.__esModule?e:{default:e}}function D(e,t,n,r){if("a"===n&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?r:"a"===n?r.call(e):r?r.value:t.get(e)}function _(e,t,n,r,o){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?o.call(e,n):o?o.value=n:t.set(e,n),n}function E(e,t){if(null===t||"object"!=typeof t&&"function"!=typeof t)throw new TypeError("Cannot use 'in' operator on non-object");return"function"==typeof e?t===e:e.has(t)}function P(e,t,n){if(null!=t){if("object"!=typeof t)throw new TypeError("Object expected.");var r;if(n){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");r=t[Symbol.asyncDispose]}if(void 0===r){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");r=t[Symbol.dispose]}if("function"!=typeof r)throw new TypeError("Object not disposable.");e.stack.push({value:t,dispose:r,async:n})}else n&&e.stack.push({async:!0});return t}var z="function"==typeof SuppressedError?SuppressedError:function(e,t,n){var r=new Error(n);return r.name="SuppressedError",r.error=e,r.suppressed=t,r};function I(e){function t(t){e.error=e.hasError?new z(t,e.error,"An error was suppressed during disposal."):t,e.hasError=!0}return function n(){for(;e.stack.length;){var r=e.stack.pop();try{var o=r.dispose&&r.dispose.call(r.value);if(r.async)return Promise.resolve(o).then(n,(function(e){return t(e),n()}))}catch(e){t(e)}}if(e.hasError)throw e.error}()}t.default={__extends:o,__assign:i,__rest:s,__decorate:l,__param:a,__metadata:p,__awaiter:f,__generator:m,__createBinding:g,__exportStar:y,__values:v,__read:b,__spread:w,__spreadArrays:S,__spreadArray:k,__await:x,__asyncGenerator:C,__asyncDelegator:M,__asyncValues:O,__makeTemplateObject:A,__importStar:N,__importDefault:R,__classPrivateFieldGet:D,__classPrivateFieldSet:_,__classPrivateFieldIn:E,__addDisposableResource:P,__disposeResources:I}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.expandToWordWrap=t.expandSelection=t.shallowEqual=t.indentHtml=t.selectedLineTextOnly=t.getNodeFromSelection=t.getSelectionText=t.hasSameMarkup=t.insertNode=t.findNthParentNodeOfType=t.canInsert=t.changeStylesString=void 0;var r=n(4),o=n(0),i=n(1),s=n(8);t.changeStylesString=function(e,t){var n=t.style,r=t.value,o=t.newValue;if(!e)return{changed:!1,style:null};var i=e.split(/\s*;\s*/).filter((function(e){return Boolean(e)})),s=i.filter((function(e){var t=e.split(/\s*:\s*/);return!(t[0].toLowerCase()===n&&r.test(t[1]))}));return o&&s.push(n+": "+o),{style:s.join("; ")+(s.length?";":""),changed:Boolean(o)||s.length!==i.length}};t.canInsert=function(e,t){for(var n=e.selection.$from,r=n.depth;r>=0;r--){var o=n.index(r);if(n.node(r).canReplaceWith(o,o,t))return!0}return!1};var l=function(e){return e instanceof o.Node?e.type.name:e.name};t.findNthParentNodeOfType=function(e,t){return void 0===t&&(t=1),function(n){return function(e,t){return void 0===t&&(t=1),function(n){for(var r=n.$from,o=r.depth;o>0;o--){var i=r.node(o);if(e(i)&&0===(t-=1))return{depth:o,node:i}}}}((function(t){return l(t)===l(e)}),t)(n)}};var a=function(e){var t={};for(var n in e)n&&(e[n]||0===e[n])&&(t[n]=e[n]);return t};t.insertNode=function(e,t){return function(n,o){var s=n.selection,l=n.tr;s instanceof i.NodeSelection&&s.node.type.name===e.type.name&&e.isLeaf&&!e.isText&&1===e.nodeSize?(l.setNodeMarkup(s.from,null,r.__assign(r.__assign({},a(s.node.attrs)),a(e.attrs))),l.setSelection(i.NodeSelection.create(l.doc,s.from))):l.replaceSelectionWith(e),t&&l.scrollIntoView(),o(l)}};t.hasSameMarkup=function(e,t,n,r){var i=o.Fragment.from(s.parseContent(e,n,r)),l=o.Fragment.from(s.parseContent(t,n,r));return i.eq(l)};t.getSelectionText=function(e){var t=e.selection;if(t instanceof i.TextSelection||t instanceof i.AllSelection){var n=t.content().content;return n.textBetween(0,n.size)}return""};t.getNodeFromSelection=function(e){if(e.selection instanceof i.NodeSelection)return e.selection.node};t.selectedLineTextOnly=function(e){var n="",r=!1,o=e.selection,i=e.doc,s=o.$from,l=o.$to,a=o.from,c=o.to;return s.sameParent(l)&&(i.nodesBetween(a,c,(function(e){r=r||e.isLeaf&&!e.isText})),r||(n=t.getSelectionText(e))),n};t.indentHtml=function(e){return 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$/,"")};t.shallowEqual=function(e,t){var n=Object.keys(e),r=Object.keys(t);return n.length===r.length&&n.every((function(n){return e[n]===t[n]}))};var c={before:/[^ !,?.\[\]{}()]+$/i,after:/^[^ !,?.\[\]{}()]+/i};t.expandSelection=function(e,t,n){if(!n.applyToWord||!e.selection.empty)return{state:e,dispatch:t};var r=!0===n.applyToWord?c:n.applyToWord,o=null,s=e.tr,l=e.selection,a=l.$head.nodeBefore,d=l.$head.nodeAfter;if(a&&"text"===a.type.name&&a.text&&d&&"text"===d.type.name&&d.text){var u=[];l.$head.parent.descendants((function(e,t){return u.push({node:e,pos:t}),!1}));for(var h=l.$head.parentOffset,p=u.findIndex((function(e){var t=e.node,n=e.pos;return n<=h&&n+t.nodeSize>=h})),f=u[p].node.text,m=!1,g=p-1;g>=0;g--){var y=u[g];!m&&y&&"text"===y.node.type.name?f=y.node.text+f:(m=!0,h-=y.node.nodeSize)}for(g=p+1;g<u.length;g++){if(!(y=u[g])||"text"!==y.node.type.name)break;f+=y.node.text}var v=f.substring(0,h),b=f.substring(h),w=r.before.exec(v),S=r.after.exec(b);if(w&&S){var k=w[0].length,x=S[0].length,C=o=l.from;s.setSelection(i.TextSelection.create(e.doc,C-k,C+x));return{state:{tr:s,selection:s.selection,doc:s.doc,storedMarks:null,schema:s.doc.type.schema},dispatch:function(e){e.setSelection(i.TextSelection.create(e.doc,o)),t(e)}}}}return{state:e,dispatch:t}};t.expandToWordWrap=function(e,n){return function(r,o,i){var s=t.expandSelection(r,o,n),l=s.state,a=s.dispatch;return e(n)(l,a)}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dataResizeDirImage=t.dataResizeDirTable=t.resizeHandle=t.resizableWrap=t.resizableAttr=t.colgroupAttr=t.rowTypeAttr=void 0,t.rowTypeAttr="k-parent-node",t.colgroupAttr="k-colgroup-data",t.resizableAttr="k-resizable-node",t.resizableWrap="k-editor-resize-wrap-element",t.resizeHandle="k-editor-resize-handle",t.dataResizeDirTable="data-dir-table-resize",t.dataResizeDirImage="data-dir-image-resize"},function(e,t,n){"use strict";n.r(t),n.d(t,"CellBookmark",(function(){return R})),n.d(t,"CellSelection",(function(){return N})),n.d(t,"ResizeState",(function(){return te})),n.d(t,"TableMap",(function(){return d})),n.d(t,"TableView",(function(){return Y})),n.d(t,"__clipCells",(function(){return I})),n.d(t,"__insertCells",(function(){return j})),n.d(t,"__pastedCells",(function(){return P})),n.d(t,"addColSpan",(function(){return A})),n.d(t,"addColumn",(function(){return se})),n.d(t,"addColumnAfter",(function(){return ae})),n.d(t,"addColumnBefore",(function(){return le})),n.d(t,"addRow",(function(){return he})),n.d(t,"addRowAfter",(function(){return fe})),n.d(t,"addRowBefore",(function(){return pe})),n.d(t,"cellAround",(function(){return y})),n.d(t,"colCount",(function(){return C})),n.d(t,"columnIsHeader",(function(){return T})),n.d(t,"columnResizing",(function(){return ee})),n.d(t,"columnResizingPluginKey",(function(){return Z})),n.d(t,"deleteColumn",(function(){return de})),n.d(t,"deleteRow",(function(){return ge})),n.d(t,"deleteTable",(function(){return Te})),n.d(t,"findCell",(function(){return x})),n.d(t,"fixTables",(function(){return E})),n.d(t,"fixTablesKey",(function(){return _})),n.d(t,"goToNextCell",(function(){return Ae})),n.d(t,"handlePaste",(function(){return q})),n.d(t,"inSameTable",(function(){return k})),n.d(t,"isInTable",(function(){return v})),n.d(t,"mergeCells",(function(){return ve})),n.d(t,"moveCellForward",(function(){return S})),n.d(t,"nextCell",(function(){return M})),n.d(t,"pointsAtCell",(function(){return w})),n.d(t,"removeColSpan",(function(){return O})),n.d(t,"removeColumn",(function(){return ce})),n.d(t,"removeRow",(function(){return me})),n.d(t,"rowIsHeader",(function(){return ue})),n.d(t,"selectedRect",(function(){return ie})),n.d(t,"selectionCell",(function(){return b})),n.d(t,"setCellAttr",(function(){return Se})),n.d(t,"splitCell",(function(){return be})),n.d(t,"splitCellWithType",(function(){return we})),n.d(t,"tableEditing",(function(){return Ne})),n.d(t,"tableEditingKey",(function(){return g})),n.d(t,"tableNodeTypes",(function(){return m})),n.d(t,"tableNodes",(function(){return f})),n.d(t,"toggleHeader",(function(){return xe})),n.d(t,"toggleHeaderCell",(function(){return Oe})),n.d(t,"toggleHeaderColumn",(function(){return Me})),n.d(t,"toggleHeaderRow",(function(){return Ce})),n.d(t,"updateColumnsOnResize",(function(){return Q}));var r,o,i=n(1),s=n(0),l=n(3),a=n(11),c=n(2);if("undefined"!=typeof WeakMap){let e=new WeakMap;r=t=>e.get(t),o=(t,n)=>(e.set(t,n),n)}else{const e=[],t=10;let n=0;r=t=>{for(let n=0;n<e.length;n+=2)if(e[n]==t)return e[n+1]},o=(r,o)=>(n==t&&(n=0),e[n++]=r,e[n++]=o)}var d=class{constructor(e,t,n,r){this.width=e,this.height=t,this.map=n,this.problems=r}findCell(e){for(let t=0;t<this.map.length;t++){const n=this.map[t];if(n!=e)continue;const r=t%this.width,o=t/this.width|0;let i=r+1,s=o+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:r,top:o,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:r,right:o,top:i,bottom:s}=this.findCell(e);return"horiz"==t?(n<0?0==r:o==this.width)?null:this.map[i*this.width+(n<0?r-1:o)]:(n<0?0==i:s==this.height)?null:this.map[r+this.width*(n<0?i-1:s)]}rectBetween(e,t){const{left:n,right:r,top:o,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(o,a),right:Math.max(r,l),bottom:Math.max(i,c)}}cellsInRect(e){const t=[],n={};for(let r=e.top;r<e.bottom;r++)for(let o=e.left;o<e.right;o++){const i=r*this.width+o,s=this.map[i];n[s]||(n[s]=!0,o==e.left&&o&&this.map[i-1]==s||r==e.top&&r&&this.map[i-this.width]==s||t.push(s))}return t}positionAt(e,t,n){for(let r=0,o=0;;r++){const i=o+n.child(r).nodeSize;if(r==e){let n=t+e*this.width;const r=(e+1)*this.width;for(;n<r&&this.map[n]<o;)n++;return n==r?i-1:this.map[n]}o=i}}static get(e){return r(e)||o(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 r=0;r<e.childCount;r++){const o=e.child(r);let i=0;if(n)for(let t=0;t<r;t++){const n=e.child(t);for(let e=0;e<n.childCount;e++){const o=n.child(e);t+o.attrs.rowspan>r&&(i+=o.attrs.colspan)}}for(let e=0;e<o.childCount;e++){const t=o.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,r=[];let o=0,i=null;const s=[];for(let e=0,o=t*n;e<o;e++)r[e]=0;for(let l=0,a=0;l<n;l++){const c=e.child(l);a++;for(let e=0;;e++){for(;o<r.length&&0!=r[o];)o++;if(e==c.childCount)break;const d=c.child(e),{colspan:u,rowspan:h,colwidth:p}=d.attrs;for(let e=0;e<h;e++){if(e+l>=n){(i||(i=[])).push({type:"overlong_rowspan",pos:a,n:h-e});break}const c=o+e*t;for(let e=0;e<u;e++){0==r[c+e]?r[c+e]=a:(i||(i=[])).push({type:"collision",row:l,pos:a,n:u-e});const n=p&&p[e];if(n){const r=(c+e)%t*2,o=s[r];null==o||o!=n&&1==s[r+1]?(s[r]=n,s[r+1]=1):o==n&&s[r+1]++}}}o+=u,a+=d.nodeSize}const d=(l+1)*t;let u=0;for(;o<d;)0==r[o++]&&u++;u&&(i||(i=[])).push({type:"missing",row:l,n:u}),a++}const l=new d(t,n,r,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 r={};for(let o=0;o<e.map.length;o++){const i=e.map[o];if(r[i])continue;r[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 r=(o+n)%e.width,i=t[2*r];null==i||a.colwidth&&a.colwidth[n]==i||((l||(l=u(a)))[n]=i)}l&&e.problems.unshift({type:"colwidth mismatch",pos:i,colwidth:l})}}(l,s,e);return l}(e))}};function u(e){if(e.colwidth)return e.colwidth.slice();const t=[];for(let n=0;n<e.colspan;n++)t.push(0);return t}function h(e,t){if("string"==typeof e)return{};const n=e.getAttribute("data-colwidth"),r=n&&/^\d+(,\d+)*$/.test(n)?n.split(",").map(e=>Number(e)):null,o=Number(e.getAttribute("colspan")||1),i={colspan:o,rowspan:Number(e.getAttribute("rowspan")||1),colwidth:r&&r.length==o?r:null};for(const n in t){const r=t[n].getFromDOM,o=r&&r(e);null!=o&&(i[n]=o)}return i}function p(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 r in t){const o=t[r].setDOMAttr;o&&o(e.attrs[r],n)}return n}function f(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=>h(e,t)}],toDOM:e=>["td",p(e,t),0]},table_header:{content:e.cellContent,attrs:n,tableRole:"header_cell",isolating:!0,parseDOM:[{tag:"th",getAttrs:e=>h(e,t)}],toDOM:e=>["th",p(e,t),0]}}}function m(e){let t=e.cached.tableNodeTypes;if(!t){t=e.cached.tableNodeTypes={};for(const n in e.nodes){const r=e.nodes[n],o=r.spec.tableRole;o&&(t[o]=r)}}return t}var g=new i.PluginKey("selectingCells");function y(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 v(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 b(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=y(t.$head)||function(e){for(let t=e.nodeAfter,n=e.pos;t;t=t.firstChild,n++){const r=t.type.spec.tableRole;if("cell"==r||"header_cell"==r)return e.doc.resolve(n)}for(let t=e.nodeBefore,n=e.pos;t;t=t.lastChild,n--){const r=t.type.spec.tableRole;if("cell"==r||"header_cell"==r)return e.doc.resolve(n-t.nodeSize)}}(t.$head);if(n)return n;throw new RangeError("No cell found around position "+t.head)}function w(e){return"row"==e.parent.type.spec.tableRole&&!!e.nodeAfter}function S(e){return e.node(0).resolve(e.pos+e.nodeAfter.nodeSize)}function k(e,t){return e.depth==t.depth&&e.pos>=t.start(-1)&&e.pos<=t.end(-1)}function x(e){return d.get(e.node(-1)).findCell(e.pos-e.start(-1))}function C(e){return d.get(e.node(-1)).colCount(e.pos-e.start(-1))}function M(e,t,n){const r=e.node(-1),o=d.get(r),i=e.start(-1),s=o.nextCell(e.pos-i,t,n);return null==s?null:e.node(0).resolve(i+s)}function O(e,t,n=1){const r={...e,colspan:e.colspan-n};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(t,n),r.colwidth.some(e=>e>0)||(r.colwidth=null)),r}function A(e,t,n=1){const r={...e,colspan:e.colspan+n};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let e=0;e<n;e++)r.colwidth.splice(t,0,0)}return r}function T(e,t,n){const r=m(t.type.schema).header_cell;for(let o=0;o<e.height;o++)if(t.nodeAt(e.map[n+o*e.width]).type!=r)return!1;return!0}var N=class extends i.Selection{constructor(e,t=e){const n=e.node(-1),r=d.get(n),o=e.start(-1),s=r.rectBetween(e.pos-o,t.pos-o),l=e.node(0),a=r.cellsInRect(s).filter(e=>e!=t.pos-o);a.unshift(t.pos-o);const c=a.map(e=>{const t=n.nodeAt(e);if(!t)throw RangeError(`No cell with offset ${e} found`);const r=o+e+1;return new i.SelectionRange(l.resolve(r),l.resolve(r+t.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=t}map(e,t){const n=e.resolve(t.map(this.$anchorCell.pos)),r=e.resolve(t.map(this.$headCell.pos));if(w(n)&&w(r)&&k(n,r)){const e=this.$anchorCell.node(-1)!=n.node(-1);return e&&this.isRowSelection()?N.rowSelection(n,r):e&&this.isColSelection()?N.colSelection(n,r):new N(n,r)}return i.TextSelection.between(n,r)}content(){const e=this.$anchorCell.node(-1),t=d.get(e),n=this.$anchorCell.start(-1),r=t.rectBetween(this.$anchorCell.pos-n,this.$headCell.pos-n),o={},i=[];for(let n=r.top;n<r.bottom;n++){const l=[];for(let i=n*t.width+r.left,s=r.left;s<r.right;s++,i++){const n=t.map[i];if(o[n])continue;o[n]=!0;const s=t.findCell(n);let a=e.nodeAt(n);if(!a)throw RangeError(`No cell with offset ${n} found`);const c=r.left-s.left,d=s.right-r.right;if(c>0||d>0){let e=a.attrs;if(c>0&&(e=O(e,0,c)),d>0&&(e=O(e,e.colspan-d,d)),s.left<r.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<r.top||s.bottom>r.bottom){const e={...a.attrs,rowspan:Math.min(s.bottom,r.bottom)-Math.max(s.top,r.top)};a=s.top<r.top?a.type.createAndFill(e):a.type.create(e,a.content)}l.push(a)}i.push(e.child(n).copy(s.Fragment.from(l)))}const l=this.isColSelection()&&this.isRowSelection()?e:i;return new s.Slice(s.Fragment.from(l),1,1)}replace(e,t=s.Slice.empty){const n=e.steps.length,r=this.ranges;for(let o=0;o<r.length;o++){const{$from:i,$to:l}=r[o],a=e.mapping.slice(n);e.replace(a.map(i.pos),a.map(l.pos),o?s.Slice.empty:t)}const o=i.Selection.findFrom(e.doc.resolve(e.mapping.slice(n).map(this.to)),-1);o&&e.setSelection(o)}replaceWith(e,t){this.replace(e,new s.Slice(s.Fragment.from(t),0,0))}forEachCell(e){const t=this.$anchorCell.node(-1),n=d.get(t),r=this.$anchorCell.start(-1),o=n.cellsInRect(n.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r));for(let n=0;n<o.length;n++)e(t.nodeAt(o[n]),r+o[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,r=t+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(n,r)==this.$headCell.node(-1).childCount}static colSelection(e,t=e){const n=e.node(-1),r=d.get(n),o=e.start(-1),i=r.findCell(e.pos-o),s=r.findCell(t.pos-o),l=e.node(0);return i.top<=s.top?(i.top>0&&(e=l.resolve(o+r.map[i.left])),s.bottom<r.height&&(t=l.resolve(o+r.map[r.width*(r.height-1)+s.right-1]))):(s.top>0&&(t=l.resolve(o+r.map[s.left])),i.bottom<r.height&&(e=l.resolve(o+r.map[r.width*(r.height-1)+i.right-1]))),new N(e,t)}isRowSelection(){const e=this.$anchorCell.node(-1),t=d.get(e),n=this.$anchorCell.start(-1),r=t.colCount(this.$anchorCell.pos-n),o=t.colCount(this.$headCell.pos-n);if(Math.min(r,o)>0)return!1;const i=r+this.$anchorCell.nodeAfter.attrs.colspan,s=o+this.$headCell.nodeAfter.attrs.colspan;return Math.max(i,s)==t.width}eq(e){return e instanceof N&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,t=e){const n=e.node(-1),r=d.get(n),o=e.start(-1),i=r.findCell(e.pos-o),s=r.findCell(t.pos-o),l=e.node(0);return i.left<=s.left?(i.left>0&&(e=l.resolve(o+r.map[i.top*r.width])),s.right<r.width&&(t=l.resolve(o+r.map[r.width*(s.top+1)-1]))):(s.left>0&&(t=l.resolve(o+r.map[s.top*r.width])),i.right<r.width&&(e=l.resolve(o+r.map[r.width*(i.top+1)-1]))),new N(e,t)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,t){return new N(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,n=t){return new N(e.resolve(t),e.resolve(n))}getBookmark(){return new R(this.$anchorCell.pos,this.$headCell.pos)}};N.prototype.visible=!1,i.Selection.jsonID("cell",N);var R=class{constructor(e,t){this.anchor=e,this.head=t}map(e){return new R(e.map(this.anchor),e.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&&k(t,n)?new N(t,n):i.Selection.near(n,1)}};function D(e){if(!(e.selection instanceof N))return null;const t=[];return e.selection.forEachCell((e,n)=>{t.push(l.Decoration.node(n,n+e.nodeSize,{class:"selectedCell"}))}),l.DecorationSet.create(e.doc,t)}var _=new i.PluginKey("fix-tables");function E(e,t){let n;const r=(t,r)=>{"table"==t.type.spec.tableRole&&(n=function(e,t,n,r){const o=d.get(t);if(!o.problems)return r;r||(r=e.tr);const i=[];for(let e=0;e<o.height;e++)i.push(0);for(let e=0;e<o.problems.length;e++){const s=o.problems[e];if("collision"==s.type){const e=t.nodeAt(s.pos);if(!e)continue;const o=e.attrs;for(let e=0;e<o.rowspan;e++)i[s.row+e]+=s.n;r.setNodeMarkup(r.mapping.map(n+1+s.pos),null,O(o,o.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;r.setNodeMarkup(r.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;r.setNodeMarkup(r.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<o.height;a++){const n=t.child(a),o=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=m(e.schema)[t].createAndFill();n&&i.push(n)}const u=0!=a&&s!=a-1||l!=a?o-1:c+1;r.insert(r.mapping.map(u),i)}c=o}return r.setMeta(_,{fixTables:!0})}(e,t,r,n))};return t?t.doc!=e.doc&&function e(t,n,r,o){const i=t.childCount,s=n.childCount;e:for(let l=0,a=0;l<s;l++){const s=n.child(l);for(let e=a,n=Math.min(i,l+3);e<n;e++)if(t.child(e)==s){a=e+1,r+=s.nodeSize;continue e}o(s,r),a<i&&t.child(a).sameMarkup(s)?e(t.child(a),s,r+1,o):s.nodesBetween(0,s.content.size,o,r+1),r+=s.nodeSize}}(t.doc,e.doc,0,r):e.doc.descendants(r),n}function P(e){if(!e.size)return null;let{content:t,openStart:n,openEnd:r}=e;for(;1==t.childCount&&(n>0&&r>0||"table"==t.child(0).type.spec.tableRole);)n--,r--,t=t.child(0).content;const o=t.child(0),i=o.type.spec.tableRole,l=o.type.schema,a=[];if("row"==i)for(let e=0;e<t.childCount;e++){let o=t.child(e).content;const i=e?0:Math.max(0,n-1),c=e<t.childCount-1?0:Math.max(0,r-1);(i||c)&&(o=z(m(l).row,new s.Slice(o,i,c)).content),a.push(o)}else{if("cell"!=i&&"header_cell"!=i)return null;a.push(n||r?z(m(l).row,new s.Slice(t,n,r)).content:t)}return function(e,t){const n=[];for(let e=0;e<t.length;e++){const r=t[e];for(let t=r.childCount-1;t>=0;t--){const{rowspan:o,colspan:i}=r.child(t).attrs;for(let t=e;t<e+o;t++)n[t]=(n[t]||0)+i}}let r=0;for(let e=0;e<n.length;e++)r=Math.max(r,n[e]);for(let o=0;o<n.length;o++)if(o>=t.length&&t.push(s.Fragment.empty),n[o]<r){const i=m(e).cell.createAndFill(),l=[];for(let e=n[o];e<r;e++)l.push(i);t[o]=t[o].append(s.Fragment.from(l))}return{height:t.length,width:r,rows:t}}(l,a)}function z(e,t){const n=e.createAndFill();return new c.Transform(n).replace(0,n.content.size,t).doc}function I({width:e,height:t,rows:n},r,o){if(e!=r){const t=[],o=[];for(let e=0;e<n.length;e++){const i=n[e],l=[];for(let n=t[e]||0,o=0;n<r;o++){let s=i.child(o%i.childCount);n+s.attrs.colspan>r&&(s=s.type.createChecked(O(s.attrs,s.attrs.colspan,n+s.attrs.colspan-r),s.content)),l.push(s),n+=s.attrs.colspan;for(let n=1;n<s.attrs.rowspan;n++)t[e+n]=(t[e+n]||0)+s.attrs.colspan}o.push(s.Fragment.from(l))}n=o,e=r}if(t!=o){const e=[];for(let r=0,i=0;r<o;r++,i++){const l=[],a=n[i%t];for(let e=0;e<a.childCount;e++){let t=a.child(e);r+t.attrs.rowspan>o&&(t=t.type.create({...t.attrs,rowspan:Math.max(1,o-t.attrs.rowspan)},t.content)),l.push(t)}e.push(s.Fragment.from(l))}n=e,t=o}return{width:e,height:t,rows:n}}function F(e,t,n,r,o,i,s,l){if(0==s||s==t.height)return!1;let a=!1;for(let c=o;c<i;c++){const o=s*t.width+c,i=t.map[o];if(t.map[o-t.width]==i){a=!0;const o=n.nodeAt(i),{top:d,left:u}=t.findCell(i);e.setNodeMarkup(e.mapping.slice(l).map(i+r),null,{...o.attrs,rowspan:s-d}),e.insert(e.mapping.slice(l).map(t.positionAt(s,u,n)),o.type.createAndFill({...o.attrs,rowspan:d+o.attrs.rowspan-s})),c+=o.attrs.colspan-1}}return a}function B(e,t,n,r,o,i,s,l){if(0==s||s==t.width)return!1;let a=!1;for(let c=o;c<i;c++){const o=c*t.width+s,i=t.map[o];if(t.map[o-1]==i){a=!0;const o=n.nodeAt(i),d=t.colCount(i),u=e.mapping.slice(l).map(i+r);e.setNodeMarkup(u,null,O(o.attrs,s-d,o.attrs.colspan-(s-d))),e.insert(u+o.nodeSize,o.type.createAndFill(O(o.attrs,0,s-d))),c+=o.attrs.rowspan-1}}return a}function j(e,t,n,r,o){let i=n?e.doc.nodeAt(n-1):e.doc;if(!i)throw new Error("No table found");let l=d.get(i);const{top:a,left:c}=r,u=c+o.width,h=a+o.height,p=e.tr;let f=0;function g(){if(i=n?p.doc.nodeAt(n-1):p.doc,!i)throw new Error("No table found");l=d.get(i),f=p.mapping.maps.length}(function(e,t,n,r,o,i,l){const a=m(e.doc.type.schema);let c,d;if(o>t.width)for(let i=0,s=0;i<t.height;i++){const u=n.child(i);s+=u.nodeSize;const h=[];let p;p=null==u.lastChild||u.lastChild.type==a.cell?c||(c=a.cell.createAndFill()):d||(d=a.header_cell.createAndFill());for(let e=t.width;e<o;e++)h.push(p);e.insert(e.mapping.slice(l).map(s-1+r),h)}if(i>t.height){const u=[];for(let e=0,r=(t.height-1)*t.width;e<Math.max(t.width,o);e++){const o=!(e>=t.width)&&n.nodeAt(t.map[r+e]).type==a.header_cell;u.push(o?d||(d=a.header_cell.createAndFill()):c||(c=a.cell.createAndFill()))}const h=a.row.create(null,s.Fragment.from(u)),p=[];for(let e=t.height;e<i;e++)p.push(h);e.insert(e.mapping.slice(l).map(r+n.nodeSize-2),p)}return!(!c&&!d)})(p,l,i,n,u,h,f)&&g(),F(p,l,i,n,c,u,a,f)&&g(),F(p,l,i,n,c,u,h,f)&&g(),B(p,l,i,n,a,h,c,f)&&g(),B(p,l,i,n,a,h,u,f)&&g();for(let e=a;e<h;e++){const t=l.positionAt(e,c,i),r=l.positionAt(e,u,i);p.replace(p.mapping.slice(f).map(t+n),p.mapping.slice(f).map(r+n),new s.Slice(o.rows[e-a],0,0))}g(),p.setSelection(new N(p.doc.resolve(n+l.positionAt(a,c,i)),p.doc.resolve(n+l.positionAt(h-1,u-1,i)))),t(p)}var $=Object(a.keydownHandler)({ArrowLeft:V("horiz",-1),ArrowRight:V("horiz",1),ArrowUp:V("vert",-1),ArrowDown:V("vert",1),"Shift-ArrowLeft":K("horiz",-1),"Shift-ArrowRight":K("horiz",1),"Shift-ArrowUp":K("vert",-1),"Shift-ArrowDown":K("vert",1),Backspace:H,"Mod-Backspace":H,Delete:H,"Mod-Delete":H});function L(e,t,n){return!n.eq(e.selection)&&(t&&t(e.tr.setSelection(n).scrollIntoView()),!0)}function V(e,t){return(n,r,o)=>{if(!o)return!1;const s=n.selection;if(s instanceof N)return L(n,r,i.Selection.near(s.$headCell,t));if("horiz"!=e&&!s.empty)return!1;const l=U(o,e,t);if(null==l)return!1;if("horiz"==e)return L(n,r,i.Selection.near(n.doc.resolve(s.head+t),t));{const o=n.doc.resolve(l),s=M(o,e,t);let a;return a=s?i.Selection.near(s,1):t<0?i.Selection.near(n.doc.resolve(o.before(-1)),-1):i.Selection.near(n.doc.resolve(o.after(-1)),1),L(n,r,a)}}}function K(e,t){return(n,r,o)=>{if(!o)return!1;const i=n.selection;let s;if(i instanceof N)s=i;else{const r=U(o,e,t);if(null==r)return!1;s=new N(n.doc.resolve(r))}const l=M(s.$headCell,e,t);return!!l&&L(n,r,new N(s.$anchorCell,l))}}function H(e,t){const n=e.selection;if(!(n instanceof N))return!1;if(t){const r=e.tr,o=m(e.schema).cell.createAndFill().content;n.forEachCell((e,t)=>{e.content.eq(o)||r.replace(r.mapping.map(t+1),r.mapping.map(t+e.nodeSize-1),new s.Slice(o,0,0))}),r.docChanged&&t(r)}return!0}function W(e,t){const n=y(e.state.doc.resolve(t));return!!n&&(e.dispatch(e.state.tr.setSelection(new N(n))),!0)}function q(e,t,n){if(!v(e.state))return!1;let r=P(n);const o=e.state.selection;if(o instanceof N){r||(r={width:1,height:1,rows:[s.Fragment.from(z(m(e.state.schema).cell,n))]});const t=o.$anchorCell.node(-1),i=o.$anchorCell.start(-1),l=d.get(t).rectBetween(o.$anchorCell.pos-i,o.$headCell.pos-i);return r=I(r,l.right-l.left,l.bottom-l.top),j(e.state,e.dispatch,i,l,r),!0}if(r){const t=b(e.state),n=t.start(-1);return j(e.state,e.dispatch,n,d.get(t.node(-1)).findCell(t.pos-n),r),!0}return!1}function J(e,t){var n;if(t.ctrlKey||t.metaKey)return;const r=X(e,t.target);let o;if(t.shiftKey&&e.state.selection instanceof N)i(e.state.selection.$anchorCell,t),t.preventDefault();else if(t.shiftKey&&r&&null!=(o=y(e.state.selection.$anchor))&&(null==(n=G(e,t))?void 0:n.pos)!=o.pos)i(o,t),t.preventDefault();else if(!r)return;function i(t,n){let r=G(e,n);const o=null==g.getState(e.state);if(!r||!k(t,r)){if(!o)return;r=t}const i=new N(t,r);if(o||!e.state.selection.eq(i)){const n=e.state.tr.setSelection(i);o&&n.setMeta(g,t.pos),e.dispatch(n)}}function s(){e.root.removeEventListener("mouseup",s),e.root.removeEventListener("dragstart",s),e.root.removeEventListener("mousemove",l),null!=g.getState(e.state)&&e.dispatch(e.state.tr.setMeta(g,-1))}function l(n){const o=n,l=g.getState(e.state);let a;if(null!=l)a=e.state.doc.resolve(l);else if(X(e,o.target)!=r&&(a=G(e,t),!a))return s();a&&i(a,o)}e.root.addEventListener("mouseup",s),e.root.addEventListener("dragstart",s),e.root.addEventListener("mousemove",l)}function U(e,t,n){if(!(e.state.selection instanceof i.TextSelection))return null;const{$head:r}=e.state.selection;for(let o=r.depth-1;o>=0;o--){const i=r.node(o);if((n<0?r.index(o):r.indexAfter(o))!=(n<0?0:i.childCount))return null;if("cell"==i.type.spec.tableRole||"header_cell"==i.type.spec.tableRole){const i=r.before(o),s="vert"==t?n>0?"down":"up":n>0?"right":"left";return e.endOfTextblock(s)?i:null}}return null}function X(e,t){for(;t&&t!=e.dom;t=t.parentNode)if("TD"==t.nodeName||"TH"==t.nodeName)return t;return null}function G(e,t){const n=e.posAtCoords({left:t.clientX,top:t.clientY});return n&&n?y(e.state.doc.resolve(n.pos)):null}var Y=class{constructor(e,t){this.node=e,this.cellMinWidth=t,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.colgroup=this.table.appendChild(document.createElement("colgroup")),Q(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,Q(e,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(e){return"attributes"==e.type&&(e.target==this.table||this.colgroup.contains(e.target))}};function Q(e,t,n,r,o,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:u}=d.child(e).attrs;for(let e=0;e<s;e++,n++){const s=o==n?i:u&&u[e],d=s?s+"px":"";l+=s||r,s||(a=!1),c?(c.style.width!=d&&(c.style.width=d),c=c.nextSibling):t.appendChild(document.createElement("col")).style.width=d}}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 Z=new i.PluginKey("tableColumnResizing");function ee({handleWidth:e=5,cellMinWidth:t=25,View:n=Y,lastColumnResizable:r=!0}={}){const o=new i.Plugin({key:Z,state:{init:(e,r)=>(o.spec.props.nodeViews[m(r.schema).table.name]=(e,r)=>new n(e,t,r),new te(-1,!1)),apply:(e,t)=>t.apply(e)},props:{attributes:e=>{const t=Z.getState(e);return t&&t.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(t,n)=>{!function(e,t,n,r,o){const i=Z.getState(e.state);if(!i)return;if(!i.dragging){const r=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(r){const{left:o,right:i}=r.getBoundingClientRect();t.clientX-o<=n?s=ne(e,t,"left",n):i-t.clientX<=n&&(s=ne(e,t,"right",n))}if(s!=i.activeHandle){if(!o&&-1!==s){const t=e.state.doc.resolve(s),n=t.node(-1),r=d.get(n),o=t.start(-1);if(r.colCount(t.pos-o)+t.nodeAfter.attrs.colspan-1==r.width-1)return}oe(e,s)}}}(t,n,e,0,r)},mouseleave:e=>{!function(e){const t=Z.getState(e.state);t&&t.activeHandle>-1&&!t.dragging&&oe(e,-1)}(e)},mousedown:(e,n)=>{!function(e,t,n){const r=Z.getState(e.state);if(!r||-1==r.activeHandle||r.dragging)return!1;const o=e.state.doc.nodeAt(r.activeHandle),i=function(e,t,{colspan:n,colwidth:r}){const o=r&&r[r.length-1];if(o)return o;const i=e.domAtPos(t);let s=i.node.childNodes[i.offset].offsetWidth,l=n;if(r)for(let e=0;e<n;e++)r[e]&&(s-=r[e],l--);return s/l}(e,r.activeHandle,o.attrs);function s(t){window.removeEventListener("mouseup",s),window.removeEventListener("mousemove",l);const r=Z.getState(e.state);(null==r?void 0:r.dragging)&&(!function(e,t,n){const r=e.state.doc.resolve(t),o=r.node(-1),i=d.get(o),s=r.start(-1),l=i.colCount(r.pos-s)+r.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 r=i.map[t],d=o.nodeAt(r).attrs,u=1==d.colspan?0:l-i.colCount(r);if(d.colwidth&&d.colwidth[u]==n)continue;const h=d.colwidth?d.colwidth.slice():(c=d.colspan,Array(c).fill(0));h[u]=n,a.setNodeMarkup(s+r,null,{...d,colwidth:h})}var c;a.docChanged&&e.dispatch(a)}(e,r.activeHandle,re(r.dragging,t,n)),e.dispatch(e.state.tr.setMeta(Z,{setDragging:null})))}function l(t){if(!t.which)return s(t);const r=Z.getState(e.state);if(r&&r.dragging){const o=re(r.dragging,t,n);!function(e,t,n,r){const o=e.state.doc.resolve(t),i=o.node(-1),s=o.start(-1),l=d.get(i).colCount(o.pos-s)+o.nodeAfter.attrs.colspan-1;let a=e.domAtPos(o.start(-1)).node;for(;a&&"TABLE"!=a.nodeName;)a=a.parentNode;if(!a)return;Q(i,a.firstChild,a,r,l,n)}(e,r.activeHandle,o,n)}}e.dispatch(e.state.tr.setMeta(Z,{setDragging:{startX:t.clientX,startWidth:i}})),window.addEventListener("mouseup",s),window.addEventListener("mousemove",l),t.preventDefault()}(e,n,t)}},decorations:e=>{const t=Z.getState(e);if(t&&t.activeHandle>-1)return function(e,t){const n=[],r=e.doc.resolve(t),o=r.node(-1);if(!o)return l.DecorationSet.empty;const i=d.get(o),s=r.start(-1),a=i.colCount(r.pos-s)+r.nodeAfter.attrs.colspan;for(let e=0;e<i.height;e++){const t=a+e*i.width-1;if(!(a!=i.width&&i.map[t]==i.map[t+1]||0!=e&&i.map[t]==i.map[t-i.width])){const e=i.map[t],r=s+e+o.nodeAt(e).nodeSize-1,a=document.createElement("div");a.className="column-resize-handle",n.push(l.Decoration.widget(r,a))}}return l.DecorationSet.create(e.doc,n)}(e,t.activeHandle)},nodeViews:{}}});return o}var te=class{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(e){const t=this,n=e.getMeta(Z);if(n&&null!=n.setHandle)return new te(n.setHandle,!1);if(n&&void 0!==n.setDragging)return new te(t.activeHandle,n.setDragging);if(t.activeHandle>-1&&e.docChanged){let n=e.mapping.map(t.activeHandle,-1);return w(e.doc.resolve(n))||(n=-1),new te(n,t.dragging)}return t}};function ne(e,t,n,r){const o="right"==n?-r:r,i=e.posAtCoords({left:t.clientX+o,top:t.clientY});if(!i)return-1;const{pos:s}=i,l=y(e.state.doc.resolve(s));if(!l)return-1;if("right"==n)return l.pos;const a=d.get(l.node(-1)),c=l.start(-1),u=a.map.indexOf(l.pos-c);return u%a.width==0?-1:c+a.map[u-1]}function re(e,t,n){const r=t.clientX-e.startX;return Math.max(n,e.startWidth+r)}function oe(e,t){e.dispatch(e.state.tr.setMeta(Z,{setHandle:t}))}function ie(e){const t=e.selection,n=b(e),r=n.node(-1),o=n.start(-1),i=d.get(r);return{...t instanceof N?i.rectBetween(t.$anchorCell.pos-o,t.$headCell.pos-o):i.findCell(n.pos-o),tableStart:o,map:i,table:r}}function se(e,{map:t,tableStart:n,table:r},o){let i=o>0?-1:0;T(t,r,o+i)&&(i=0==o||o==t.width?null:0);for(let s=0;s<t.height;s++){const l=s*t.width+o;if(o>0&&o<t.width&&t.map[l-1]==t.map[l]){const i=t.map[l],a=r.nodeAt(i);e.setNodeMarkup(e.mapping.map(n+i),null,A(a.attrs,o-t.colCount(i))),s+=a.attrs.rowspan-1}else{const a=null==i?m(r.type.schema).cell:r.nodeAt(t.map[l+i]).type,c=t.positionAt(s,o,r);e.insert(e.mapping.map(n+c),a.createAndFill())}}return e}function le(e,t){if(!v(e))return!1;if(t){const n=ie(e);t(se(e.tr,n,n.left))}return!0}function ae(e,t){if(!v(e))return!1;if(t){const n=ie(e);t(se(e.tr,n,n.right))}return!0}function ce(e,{map:t,table:n,tableStart:r},o){const i=e.mapping.maps.length;for(let s=0;s<t.height;){const l=s*t.width+o,a=t.map[l],c=n.nodeAt(a),d=c.attrs;if(o>0&&t.map[l-1]==a||o<t.width-1&&t.map[l+1]==a)e.setNodeMarkup(e.mapping.slice(i).map(r+a),null,O(d,o-t.colCount(a)));else{const t=e.mapping.slice(i).map(r+a);e.delete(t,t+c.nodeSize)}s+=d.rowspan}}function de(e,t){if(!v(e))return!1;if(t){const n=ie(e),r=e.tr;if(0==n.left&&n.right==n.map.width)return!1;for(let e=n.right-1;ce(r,n,e),e!=n.left;e--){const e=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!e)throw RangeError("No table found");n.table=e,n.map=d.get(e)}t(r)}return!0}function ue(e,t,n){var r;const o=m(t.type.schema).header_cell;for(let i=0;i<e.width;i++)if((null==(r=t.nodeAt(e.map[i+n*e.width]))?void 0:r.type)!=o)return!1;return!0}function he(e,{map:t,tableStart:n,table:r},o){var i;let s=n;for(let e=0;e<o;e++)s+=r.child(e).nodeSize;const l=[];let a=o>0?-1:0;ue(t,r,o+a)&&(a=0==o||o==t.height?null:0);for(let s=0,c=t.width*o;s<t.width;s++,c++)if(o>0&&o<t.height&&t.map[c]==t.map[c-t.width]){const o=t.map[c],i=r.nodeAt(o).attrs;e.setNodeMarkup(n+o,null,{...i,rowspan:i.rowspan+1}),s+=i.colspan-1}else{const e=null==a?m(r.type.schema).cell:null==(i=r.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,m(r.type.schema).row.create(null,l)),e}function pe(e,t){if(!v(e))return!1;if(t){const n=ie(e);t(he(e.tr,n,n.top))}return!0}function fe(e,t){if(!v(e))return!1;if(t){const n=ie(e);t(he(e.tr,n,n.bottom))}return!0}function me(e,{map:t,table:n,tableStart:r},o){let i=0;for(let e=0;e<o;e++)i+=n.child(e).nodeSize;const s=i+n.child(o).nodeSize,l=e.mapping.maps.length;e.delete(i+r,s+r);for(let i=0,s=o*t.width;i<t.width;i++,s++){const a=t.map[s];if(o>0&&a==t.map[s-t.width]){const t=n.nodeAt(a).attrs;e.setNodeMarkup(e.mapping.slice(l).map(a+r),null,{...t,rowspan:t.rowspan-1}),i+=t.colspan-1}else if(o<t.width&&a==t.map[s+t.width]){const s=n.nodeAt(a),c=s.attrs,d=s.type.create({...c,rowspan:s.attrs.rowspan-1},s.content),u=t.positionAt(o+1,i,n);e.insert(e.mapping.slice(l).map(r+u),d),i+=c.colspan-1}}}function ge(e,t){if(!v(e))return!1;if(t){const n=ie(e),r=e.tr;if(0==n.top&&n.bottom==n.map.height)return!1;for(let e=n.bottom-1;me(r,n,e),e!=n.top;e--){const e=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!e)throw RangeError("No table found");n.table=e,n.map=d.get(n.table)}t(r)}return!0}function ye(e){const t=e.content;return 1==t.childCount&&t.child(0).isTextblock&&0==t.child(0).childCount}function ve(e,t){const n=e.selection;if(!(n instanceof N)||n.$anchorCell.pos==n.$headCell.pos)return!1;const r=ie(e),{map:o}=r;if(function({width:e,height:t,map:n},r){let o=r.top*e+r.left,i=o,s=(r.bottom-1)*e+r.left,l=o+(r.right-r.left-1);for(let t=r.top;t<r.bottom;t++){if(r.left>0&&n[i]==n[i-1]||r.right<e&&n[l]==n[l+1])return!0;i+=e,l+=e}for(let i=r.left;i<r.right;i++){if(r.top>0&&n[o]==n[o-e]||r.bottom<t&&n[s]==n[s+e])return!0;o++,s++}return!1}(o,r))return!1;if(t){const n=e.tr,i={};let l,a,c=s.Fragment.empty;for(let e=r.top;e<r.bottom;e++)for(let t=r.left;t<r.right;t++){const s=o.map[e*o.width+t],d=r.table.nodeAt(s);if(!i[s]&&d)if(i[s]=!0,null==l)l=s,a=d;else{ye(d)||(c=c.append(d.content));const e=n.mapping.map(s+r.tableStart);n.delete(e,e+d.nodeSize)}}if(null==l||null==a)return!0;if(n.setNodeMarkup(l+r.tableStart,null,{...A(a.attrs,a.attrs.colspan,r.right-r.left-a.attrs.colspan),rowspan:r.bottom-r.top}),c.size){const e=l+1+a.content.size,t=ye(a)?l+1:e;n.replaceWith(t+r.tableStart,e+r.tableStart,c)}n.setSelection(new N(n.doc.resolve(l+r.tableStart))),t(n)}return!0}function be(e,t){const n=m(e.schema);return we(({node:e})=>n[e.type.spec.tableRole])(e,t)}function we(e){return(t,n)=>{var r;const o=t.selection;let i,s;if(o instanceof N){if(o.$anchorCell.pos!=o.$headCell.pos)return!1;i=o.$anchorCell.nodeAfter,s=o.$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}(o.$from),!i)return!1;s=null==(r=y(o.$from))?void 0:r.pos}if(null==i||null==s)return!1;if(1==i.attrs.colspan&&1==i.attrs.rowspan)return!1;if(n){let r=i.attrs;const l=[],a=r.colwidth;r.rowspan>1&&(r={...r,rowspan:1}),r.colspan>1&&(r={...r,colspan:1});const c=ie(t),d=t.tr;for(let e=0;e<c.right-c.left;e++)l.push(a?{...r,colwidth:a&&a[e]?[a[e]]:null}:r);let u;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 r=c.left,o=0;r<c.right;r++,o++)r==c.left&&t==c.top||d.insert(u=d.mapping.map(n+c.tableStart,1),e({node:i,row:t,col:r}).createAndFill(l[o]))}d.setNodeMarkup(s,e({node:i,row:c.top,col:c.left}),l[0]),o instanceof N&&d.setSelection(new N(d.doc.resolve(o.$anchorCell.pos),u?d.doc.resolve(u):void 0)),n(d)}return!0}}function Se(e,t){return function(n,r){if(!v(n))return!1;const o=b(n);if(o.nodeAfter.attrs[e]===t)return!1;if(r){const i=n.tr;n.selection instanceof N?n.selection.forEachCell((n,r)=>{n.attrs[e]!==t&&i.setNodeMarkup(r,null,{...n.attrs,[e]:t})}):i.setNodeMarkup(o.pos,null,{...o.nodeAfter.attrs,[e]:t}),r(i)}return!0}}function ke(e,t,n){const r=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<r.length;e++){const o=t.table.nodeAt(r[e]);if(o&&o.type!==n.header_cell)return!1}return!0}function xe(e,t){return(t=t||{useDeprecatedLogic:!1}).useDeprecatedLogic?function(e){return function(t,n){if(!v(t))return!1;if(n){const r=m(t.schema),o=ie(t),i=t.tr,s=o.map.cellsInRect("column"==e?{left:o.left,top:0,right:o.right,bottom:o.map.height}:"row"==e?{left:0,top:o.top,right:o.map.width,bottom:o.bottom}:o),l=s.map(e=>o.table.nodeAt(e));for(let e=0;e<s.length;e++)l[e].type==r.header_cell&&i.setNodeMarkup(o.tableStart+s[e],r.cell,l[e].attrs);if(0==i.steps.length)for(let e=0;e<s.length;e++)i.setNodeMarkup(o.tableStart+s[e],r.header_cell,l[e].attrs);n(i)}return!0}}(e):function(t,n){if(!v(t))return!1;if(n){const r=m(t.schema),o=ie(t),i=t.tr,s=ke("row",o,r),l=ke("column",o,r),a=("column"===e?s:"row"===e&&l)?1:0,c="column"==e?{left:0,top:a,right:1,bottom:o.map.height}:"row"==e?{left:a,top:0,right:o.map.width,bottom:1}:o,d="column"==e?l?r.cell:r.header_cell:"row"==e?s?r.cell:r.header_cell:r.cell;o.map.cellsInRect(c).forEach(e=>{const t=e+o.tableStart,n=i.doc.nodeAt(t);n&&i.setNodeMarkup(t,d,n.attrs)}),n(i)}return!0}}var Ce=xe("row",{useDeprecatedLogic:!0}),Me=xe("column",{useDeprecatedLogic:!0}),Oe=xe("cell",{useDeprecatedLogic:!0});function Ae(e){return function(t,n){if(!v(t))return!1;const r=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 r=e.node(-1).child(t),o=r.lastChild;if(o)return n-1-o.nodeSize;n-=r.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),r=e.after();n<t.childCount;n++){const e=t.child(n);if(e.childCount)return r+1;r+=e.nodeSize}}return null}(b(t),e);if(null==r)return!1;if(n){const e=t.doc.resolve(r);n(t.tr.setSelection(i.TextSelection.between(e,S(e))).scrollIntoView())}return!0}}function Te(e,t){const n=e.selection.$anchor;for(let r=n.depth;r>0;r--){if("table"==n.node(r).type.spec.tableRole)return t&&t(e.tr.delete(n.before(r),n.after(r)).scrollIntoView()),!0}return!1}function Ne({allowTableNodeSelection:e=!1}={}){return new i.Plugin({key:g,state:{init:()=>null,apply(e,t){const n=e.getMeta(g);if(null!=n)return-1==n?null:n;if(null==t||!e.docChanged)return t;const{deleted:r,pos:o}=e.mapping.mapResult(t);return r?null:o}},props:{decorations:D,handleDOMEvents:{mousedown:J},createSelectionBetween:e=>null!=g.getState(e.state)?e.state.selection:null,handleTripleClick:W,handleKeyDown:$,handlePaste:q},appendTransaction:(t,n,r)=>function(e,t,n){const r=(t||e).selection,o=(t||e).doc;let s,l;if(r instanceof i.NodeSelection&&(l=r.node.type.spec.tableRole)){if("cell"==l||"header_cell"==l)s=N.create(o,r.from);else if("row"==l){const e=o.resolve(r.from+1);s=N.rowSelection(e,e)}else if(!n){const e=d.get(r.node),t=r.from+1,n=t+e.map[e.width*e.height-1];s=N.create(o,t+1,n)}}else r instanceof i.TextSelection&&function({$from:e,$to:t}){if(e.pos==t.pos||e.pos<e.pos-6)return!1;let n=e.pos,r=t.pos,o=e.depth;for(;o>=0&&!(e.after(o+1)<e.end(o));o--,n++);for(let e=t.depth;e>=0&&!(t.before(e+1)>t.start(e));e--,r--);return n==r&&/row|table/.test(e.node(o).type.spec.tableRole)}(r)?s=i.TextSelection.create(o,r.from):r instanceof i.TextSelection&&function({$from:e,$to:t}){let n,r;for(let t=e.depth;t>0;t--){const r=e.node(t);if("cell"===r.type.spec.tableRole||"header_cell"===r.type.spec.tableRole){n=r;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){r=n;break}}return n!==r&&0===t.parentOffset}(r)&&(s=i.TextSelection.create(o,r.$from.start(),r.$from.end()));return s&&(t||(t=e.tr)).setSelection(s),t}(r,E(r,n),e)})}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setHtml=t.getHtml=t.parseContent=t.domToPmDoc=t.pmDocToFragment=t.fragmentToHtml=t.htmlToFragment=t.trimWhitespace=void 0;var r=n(0),o=n(1),i=n(6),s=["div","ol","ul","li","table","tbody","thead","tfoot","caption","td","th","p","tr","col","colgroup","article","main","nav","header","footer","aside","section"],l=function(e,t){var n=(e.ownerDocument||document).createElement(t);Array.from(e.rows).filter((function(e){return e.getAttribute(i.rowTypeAttr)===t})).forEach((function(e){e.removeAttribute(i.rowTypeAttr),n.appendChild(e)})),n.children.length&&e.appendChild(n)},a=function(e,t){var n=t.toUpperCase();e.filter((function(e){return e.nodeName===n})).forEach((function(e){Array.from(e.children).forEach((function(n){n.setAttribute(i.rowTypeAttr,t),e.parentNode&&e.parentNode.insertBefore(n,e)})),e.remove()}))};t.trimWhitespace=function(e,t){void 0===t&&(t=s);var n=t.join("|");return e.replace(new RegExp("\\s*(<(?:"+n+")(?:\\s[^>]*?)?>)","g"),"$1").replace(new RegExp("(<\\/(?:"+n+")(?:\\s[^>]*?)?>)\\s*","g"),"$1")};t.htmlToFragment=function(e){var t,n=document.createElement("template");if("content"in n)n.innerHTML=e,t=n.content;else{var r=(new DOMParser).parseFromString(e,"text/html");t=document.createDocumentFragment();for(var o=r.body;o&&o.firstChild;)t.appendChild(o.firstChild)}return t};t.fragmentToHtml=function(e){return Array.from(e.childNodes).reduce((function(e,t){return e+(t.outerHTML||t.textContent||"")}),"")};t.pmDocToFragment=function(e){var t=r.DOMSerializer.fromSchema(e.type.schema).serializeFragment(e.content);return function(e){Array.from(e.querySelectorAll("table")).forEach((function(e){l(e,"thead"),l(e,"tbody"),l(e,"tfoot");var t=Array.from(e.children).find((function(e){return 0===e.children.length}));t&&t.remove();var 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;var r=Array.from(n.children).find((function(e){return e.matches("div[caption]")}));if(r&&"<img>"!==r.innerHTML){var o=e.createCaption();for(r.id&&(o.id=r.id),r.className&&(o.className=r.className),Array.from(r.style).forEach((function(e){o.style[e]=r.style[e]}));r.firstChild;)o.appendChild(r.firstChild)}n.style.width&&!e.style.width&&(e.style.width=n.style.width),n.parentNode.insertBefore(e,n),n.parentNode.removeChild(n)}}))}(t),t};t.domToPmDoc=function(e,t,n){return r.DOMParser.fromSchema(t).parse(e,n)};t.parseContent=function(e,n,r){var o,s=t.htmlToFragment(e);return o=s,Array.from(o.querySelectorAll("table")).forEach((function(e){var t=Array.from(e.children);t.some((function(e){return"THEAD"===e.nodeName||"TFOOT"===e.nodeName}))&&(a(t,"thead"),a(t,"tbody"),a(t,"tfoot"));var n=t.find((function(e){return"COLGROUP"===e.nodeName}));if(n&&(e.setAttribute(i.colgroupAttr,n.outerHTML),n.remove()),e.caption||e.style.marginLeft||e.style.marginRight){var r=document.createElement("div");if(r.setAttribute("table",""),r.style.display="table",r.style.marginLeft=e.style.marginLeft,r.style.marginRight=e.style.marginRight,e.caption){var o=document.createElement("div");for(o.setAttribute("caption",""),e.caption.id&&(o.id=e.caption.id),e.caption.className&&(o.className=e.caption.className),Array.from(e.caption.style).forEach((function(t){o.style[t]=e.caption.style[t]}));e.caption.firstChild;)o.appendChild(e.caption.firstChild);e.removeChild(e.caption),r.appendChild(o)}e.parentNode.insertBefore(r,e),r.appendChild(e),/%/.test(e.style.width)&&(r.style.width=e.style.width,e.style.width="")}})),t.domToPmDoc(s,n,r)};t.getHtml=function(e){var n=t.pmDocToFragment(e.doc),r=document.createElement("div");return r.appendChild(n),r.innerHTML};t.setHtml=function(e,n,r){return void 0===n&&(n="setHTML"),void 0===r&&(r={preserveWhitespace:"full"}),function(i,s){return s(i.tr.setSelection(new o.AllSelection(i.doc)).replaceSelectionWith(t.parseContent(e,i.schema,r)).setMeta("commandName",n))}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getActiveMarks=t.getMark=t.selectionMarks=t.styleValue=t.hasMark=t.cleanMarks=t.removeAllMarks=t.removeMarks=t.removeMark=t.toggleMark=t.markApplies=void 0;var r=n(2),o=n(0);t.markApplies=function(e,t,n){for(var r=function(r){var o=t[r],i=o.$from,s=o.$to,l=0===i.depth&&e.type.allowsMarkType(n);if(e.nodesBetween(i.pos,s.pos,(function(e){if(l)return!1;l=e.inlineContent&&e.type.allowsMarkType(n)})),l)return{v:!0}},o=0;o<t.length;o++){var i=r(o);if(i)return i.v}return!1};t.toggleMark=function(e,n,r){return function(o,i){var s=o.selection,l=s.empty,a=s.$cursor,c=s.ranges;if(l&&!a||!t.markApplies(o.doc,c,e))return!1;if(i)if(a)e.isInSet(o.storedMarks||a.marks())?i(r.removeStoredMark(e)):i(r.addStoredMark(e.create(n)));else{for(var d=!1,u=0;!d&&u<c.length;u++){var h=c[u],p=h.$from,f=h.$to;d=o.doc.rangeHasMark(p.pos,f.pos,e)}for(u=0;u<c.length;u++){var m=c[u];p=m.$from,f=m.$to;d?r.removeMark(p.pos,f.pos,e):r.addMark(p.pos,f.pos,e.create(n))}i(r.scrollIntoView())}return!0}};t.removeMark=function(e,t,n,i){void 0===i&&(i=null);var s=[],l=0;return e.doc.nodesBetween(t,n,(function(e,r){if(e.isInline){l++;var a=null;if(i instanceof o.MarkType){var c=i.isInSet(e.marks);c&&(a=[c])}else i?i.isInSet(e.marks)&&(a=[i]):a=e.marks;if(a&&a.length)for(var d=Math.min(r+e.nodeSize,n),u=0;u<a.length;u++){for(var h=a[u],p=void 0,f=0;f<s.length;f++){var m=s[f];m.step===l-1&&h.eq(m.style)&&(p=m)}p?(p.to=d,p.step=l):s.push({style:h,from:Math.max(r,t),to:d,step:l})}}})),s.forEach((function(t){return e.step(new r.RemoveMarkStep(t.from,t.to,t.style))})),e};t.removeMarks=function(e,n,r,o){var i=n.selection,s=i.$cursor,l=i.ranges;if(o=o||n.tr,s)e.forEach((function(e){e.isInSet(n.storedMarks||s.marks())&&r(o.removeStoredMark(e))}));else{for(var a=function(n){var r=l[n],i=r.$from,s=r.$to;e.forEach((function(e){t.removeMark(o,i.pos,s.pos,e)}))},c=0;c<l.length;c++)a(c);r(o.scrollIntoView())}return!0};t.removeAllMarks=function(e){var n=(void 0===e?{}:e).except,r=void 0===n?[]:n;return function(e,n){var o,i=e.tr;t.cleanMarks(i,{except:(o=r,o instanceof Array?o:[o])}),i.docChanged&&n(i)}};t.cleanMarks=function(e,t){var n=t.except,r=e.doc,o=e.selection,i=r.type.schema,s=o.empty,l=o.ranges,a=(n||[]).map((function(e){return e.name}));if(!s){var c=Object.keys(i.marks).map((function(e){return i.marks[e]})).filter((function(e){return-1===a.indexOf(e.name)}));l.forEach((function(t){var n=t.$from,r=t.$to;c.forEach((function(t){return e.removeMark(n.pos,r.pos,t)}))}))}};t.hasMark=function(e,n){var r,o=e.schema.marks,i=(n.altMarks||[]).filter((function(e){return o[e]})),s=n.altStyle,l=e.selection,a=l.from,c=l.$from,d=l.to,u=l.empty,h=o[n.mark],p=e.doc,f=!1;return u?(r=e.storedMarks||c.marks(),f=h&&h.isInSet(r)||i.some((function(e){return o[e].isInSet(r)}))):f=h&&p.rangeHasMark(a,d,h)||i.some((function(e){return p.rangeHasMark(a,d,o[e])})),!f&&s&&o.style?t.selectionMarks(e,o.style).some((function(e){return null!==t.styleValue(e,s)})):Boolean(f)};t.styleValue=function(e,t){for(var n=(e&&e.attrs.style||"").split(/\s*;\s*/).filter((function(e){return Boolean(e)})),r=0;r<n.length;r++){var o=n[r].split(/\s*:\s*/);if(o[0].toLowerCase()===t.name&&t.value.test(o[1]))return o[1]}return null};t.selectionMarks=function(e,t){var n=e.selection,r=n.from,o=n.$from,i=n.to,s=n.empty,l=[];return s?l.push(t.isInSet(e.storedMarks||o.marks())):e.doc.nodesBetween(r,i,(function(e){e.isInline&&l.push(t.isInSet(e.marks))})),l};t.getMark=function(e,n){var r=t.selectionMarks(e,n),o=r.filter((function(e){return Boolean(e)}));return r.length===o.length?r[0]:void 0};t.getActiveMarks=function(e,n){var r=t.selectionMarks(e,n),o=r.filter((function(e){return Boolean(e)}));return{hasNodesWithoutMarks:r.length!==o.length,marks:o}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.edgeCell=t.parentNode=t.cellIndexes=t.domCellAround=t.getTable=t.otherResizeHandle=t.otherResizing=t.tableRowResizeKey=t.tableColumnResizeKey=t.tableResizeKey=t.setNodeStyle=t.parseStyle=t.reAnyValue=void 0;var r=n(4),o=n(1),i=n(7),s=n(5);t.reAnyValue=/^.+$/;function l(e,t){for(var n=e.depth;n>0;n--){var r=e.node(n);if(t(r))return{node:r,depth:n}}return null}t.parseStyle=function(e){return(e||"").split(/\s*;\s*/).filter(Boolean).map((function(e){var t,n=e.split(/\s*:\s*/);return(t={})[n[0]]=n[1],t})).reduce((function(e,t){return r.__assign(r.__assign({},e),t)}),{})},t.setNodeStyle=function(e,n,o){var i;if(new RegExp("[^-]?"+n+":").test(e.style||"")){var l=s.changeStylesString(e.style||"",{style:n,value:t.reAnyValue,newValue:o}).style;i=r.__assign(r.__assign({},e),{style:l})}else i=e.style?r.__assign(r.__assign({},e),{style:e.style.replace(/;$/,"")+"; "+n+": "+o+";"}):r.__assign(r.__assign({},e),{style:n+": "+o+";"});return i},t.tableResizeKey=new o.PluginKey("table-resize"),t.tableColumnResizeKey=new o.PluginKey("table-column-resizing"),t.tableRowResizeKey=new o.PluginKey("table-row-resizing"),t.otherResizing=function(e,n){var r=!1;return r=(r=(r=r||e!==t.tableResizeKey&&Boolean(t.tableResizeKey.get(n))&&t.tableResizeKey.getState(n).dragging)||e!==t.tableColumnResizeKey&&Boolean(t.tableColumnResizeKey.get(n))&&t.tableColumnResizeKey.getState(n).dragging)||e!==t.tableRowResizeKey&&Boolean(t.tableRowResizeKey.get(n))&&t.tableRowResizeKey.getState(n).dragging},t.otherResizeHandle=function(e,n){var r=!1;return r=(r=r||e!==t.tableColumnResizeKey&&Boolean(t.tableColumnResizeKey.get(n))&&t.tableColumnResizeKey.getState(n).activeHandle>-1)||e!==t.tableRowResizeKey&&Boolean(t.tableRowResizeKey.get(n))&&t.tableRowResizeKey.getState(n).activeHandle>-1},t.getTable=function(e){return e&&e.firstChild&&"TABLE"===e.firstChild.nodeName?e.firstChild:e},t.domCellAround=function(e){for(;e&&"TD"!==e.nodeName&&"TH"!==e.nodeName;)e=e.classList.contains("ProseMirror")?null:e.parentNode;return e},t.cellIndexes=function(e){for(var t=function(e){var t=Array.from(e&&e.rows||[]),n=Array.from(t&&t[0]&&t[0].cells||[]).map((function(e){return e.colSpan})).reduce((function(e,t){return e+t}),0),r=t.map((function(){return new Array(n)}));return t.forEach((function(e,t){var n=0;Array.from(e.cells).forEach((function(e){for(var o=0;o<e.colSpan;o++){for(var i=0;i<e.rowSpan;i++){var s=r[t+i].findIndex((function(e,t){return t>=n&&!e}));r[t+i][s]=e}n++}}))})),r}(e.closest("table")),n=null,r=function(r){if(t[r].forEach((function(t,o){e===t&&(n={rowIndex:r,cellIndex:o})})),n)return"break"},o=0;o<t.length;o++){if("break"===r(o))break}return n||{rowIndex:-1,cellIndex:-1}},t.parentNode=l,t.edgeCell=function(e,t,n){var r=e.posAtCoords({left:t.clientX,top:t.clientY});if(!r)return-1;var o=e.state.doc.resolve(r.pos),s=l(o,(function(e){return"table"===e.type.spec.tableRole}));if(null===s)return-1;var a=o.start(s.depth),c=s.node,d=i.TableMap.get(c);return a+d.map[d.width*n.rowIndex+n.cellIndex]}},function(e,t,n){"use strict";n.r(t),n.d(t,"keydownHandler",(function(){return f})),n.d(t,"keymap",(function(){return p}));for(var r={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:"'"},o={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},i="undefined"!=typeof navigator&&/Mac/.test(navigator.platform),s="undefined"!=typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),l=0;l<10;l++)r[48+l]=r[96+l]=String(l);for(l=1;l<=24;l++)r[l+111]="F"+l;for(l=65;l<=90;l++)r[l]=String.fromCharCode(l+32),o[l]=String.fromCharCode(l);for(var a in r)o.hasOwnProperty(a)||(o[a]=r[a]);var c=n(1);const d="undefined"!=typeof navigator&&/Mac|iP(hone|[oa]d)/.test(navigator.platform);function u(e){let t,n,r,o,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))o=!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))r=!0;else{if(!/^mod$/i.test(s))throw new Error("Unrecognized modifier name: "+s);d?o=!0:n=!0}}return t&&(s="Alt-"+s),n&&(s="Ctrl-"+s),o&&(s="Meta-"+s),r&&(s="Shift-"+s),s}function h(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 p(e){return new c.Plugin({props:{handleKeyDown:f(e)}})}function f(e){let t=function(e){let t=Object.create(null);for(let n in e)t[u(n)]=e[n];return t}(e);return function(e,n){let l,a=function(e){var t=!(i&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||s&&e.shiftKey&&e.key&&1==e.key.length||"Unidentified"==e.key)&&e.key||(e.shiftKey?o:r)[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),c=t[h(a,n)];if(c&&c(e.state,e.dispatch,e))return!0;if(1==a.length&&" "!=a){if(n.shiftKey){let r=t[h(a,n,!1)];if(r&&r(e.state,e.dispatch,e))return!0}if((n.shiftKey||n.altKey||n.metaKey||a.charCodeAt(0)>127)&&(l=r[n.keyCode])&&l!=a){let r=t[h(l,n)];if(r&&r(e.state,e.dispatch,e))return!0}}return!1}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.activeNode=t.parentBlockFormat=t.hasNode=t.addStyles=t.getBlockFormats=t.cleanTextBlockFormatting=t.formatBlockElements=t.blockNodes=t.changeTextBlock=void 0;var r=n(4),o=n(5),i=n(2),s=n(0),l=n(1);t.changeTextBlock=function(e,t,n,r){if(!n.isTextblock)return!1;e.selection.ranges.forEach((function(o){var l=e.steps.length,a=o.$from.pos,c=o.$to.pos;e.doc.nodesBetween(a,c,(function(o,a){if(o.eq(t)&&o.isTextblock&&!o.hasMarkup(n,r)&&function(e,t,n){var r=e.resolve(t),o=r.index();return r.parent.canReplaceWith(o,o+1,n)}(e.doc,e.mapping.slice(l).map(a),n)){e.clearIncompatible(e.mapping.slice(l).map(a,1),n);var c=e.mapping.slice(l),d=c.map(a,1),u=c.map(a+o.nodeSize,1),h=new s.Slice(s.Fragment.from(n.create(r,null,o.marks)),0,0);return e.step(new i.ReplaceAroundStep(d,u,d+1,u-1,h,1,!0)),!1}}))}))};t.blockNodes=function(e,t){void 0===t&&(t={blocksInSelection:!1});var n=e.doc,r=e.selection,o=r.$from,i=r.ranges,s=t.blocksInSelection,a=[],c=r instanceof l.NodeSelection?r.node:void 0;return c?c.isBlock?(a.push(c),c.nodesBetween(0,c.content.size,(function(e){e.isBlock&&a.push(e)}))):!s&&o.parent&&o.parent.isBlock&&a.push(o.parent):i.forEach((function(e){var t=e.$from.pos,r=e.$to.pos;n.nodesBetween(t,r,(function(e,n,o,i){e.isBlock&&(!s||n>=t&&n+e.content.size+2<=r)&&a.push(e)}))})),a};t.formatBlockElements=function(e,n){return function(o,i){var s=t.blockNodes(o),l=o.schema.nodes,a=o.tr;a.setMeta("commandName",n),a.setMeta("args",{value:e}),s.forEach((function(n){if(n.type.isTextblock)if("p"===e){var o=n.attrs,i=o.level,s=r.__rest(o,["level"]);t.changeTextBlock(a,n,l.paragraph,s)}else if(/^h[1-6]$/i.test(e)){i=parseInt(e.substr(1),10);t.changeTextBlock(a,n,l.heading,r.__assign(r.__assign({},n.attrs),{level:i}))}else if("blockquote"===e){var c=n.attrs;i=c.level,s=r.__rest(c,["level"]);t.changeTextBlock(a,n,l.blockquote,s)}}));var c=a.docChanged;return c&&i(a.scrollIntoView()),c}};t.cleanTextBlockFormatting=function(e,n){void 0===n&&(n={blocksInSelection:!0});var o=e.doc,i=e.selection,s=n.blocksInSelection,l=n.blockNodeType;t.blockNodes({doc:o,selection:i},{blocksInSelection:s}).filter((function(e){return e.isTextblock})).forEach((function(n){var o=n.attrs||{},i=o.style,s=void 0===i?"":i,a=o.class,c=void 0===a?"":a,d=r.__rest(o,["style","class"]),u=l||n.type;(s||c||u!==n.type)&&t.changeTextBlock(e,n,u,d)}))};t.getBlockFormats=function(e){var n=t.blockNodes(e),r=e.schema.nodes,o=[];return n.forEach((function(e){e.type===r.paragraph?o.push("p"):e.type===r.heading?o.push("h"+e.attrs.level):e.type===r.blockquote&&r.blockquote.isTextblock&&o.push("blockquote")})),o};t.addStyles=function(e,t){var n,r,i=e.attrs.style;i&&t.forEach((function(e){r={style:e.name,value:/^.+$/,newValue:e.value},n=o.changeStylesString(i,r),i=n.changed?n.style:i}));return i=i||t.reduce((function(e,t){return(e&&t.value?e+" ":"")+t.value?t.name+": "+t.value+";":""}),""),Object.assign({},e.attrs,{style:i||null})};t.hasNode=function(e,t){var n=e.selection,r=n.from,o=n.to,i=!1;return e.doc.nodesBetween(r,o,(function(e){return!(i=i||e.type===t)})),i};t.parentBlockFormat=function(e){var n=t.getBlockFormats(e);return 1===new Set(n).size?n[0]:null};t.activeNode=function(e){return{tag:t.parentBlockFormat(e)||""}}},function(e,t,n){"use strict";n.r(t),n.d(t,"autoJoin",(function(){return j})),n.d(t,"baseKeymap",(function(){return W})),n.d(t,"chainCommands",(function(){return $})),n.d(t,"createParagraphNear",(function(){return M})),n.d(t,"deleteSelection",(function(){return s})),n.d(t,"exitCode",(function(){return C})),n.d(t,"joinBackward",(function(){return a})),n.d(t,"joinDown",(function(){return w})),n.d(t,"joinForward",(function(){return g})),n.d(t,"joinTextblockBackward",(function(){return c})),n.d(t,"joinTextblockForward",(function(){return d})),n.d(t,"joinUp",(function(){return b})),n.d(t,"lift",(function(){return S})),n.d(t,"liftEmptyBlock",(function(){return O})),n.d(t,"macBaseKeymap",(function(){return H})),n.d(t,"newlineInCode",(function(){return k})),n.d(t,"pcBaseKeymap",(function(){return K})),n.d(t,"selectAll",(function(){return D})),n.d(t,"selectNodeBackward",(function(){return p})),n.d(t,"selectNodeForward",(function(){return y})),n.d(t,"selectParentNode",(function(){return R})),n.d(t,"selectTextblockEnd",(function(){return z})),n.d(t,"selectTextblockStart",(function(){return P})),n.d(t,"setBlockType",(function(){return F})),n.d(t,"splitBlock",(function(){return T})),n.d(t,"splitBlockAs",(function(){return A})),n.d(t,"splitBlockKeepMarks",(function(){return N})),n.d(t,"toggleMark",(function(){return B})),n.d(t,"wrapIn",(function(){return I}));var r=n(2),o=n(0),i=n(1);const s=(e,t)=>!e.selection.empty&&(t&&t(e.tr.deleteSelection().scrollIntoView()),!0);function l(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock("backward",e):n.parentOffset>0)?null:n}const a=(e,t,n)=>{let s=l(e,n);if(!s)return!1;let a=f(s);if(!a){let n=s.blockRange(),o=n&&Object(r.liftTarget)(n);return null!=o&&(t&&t(e.tr.lift(n,o).scrollIntoView()),!0)}let c=a.nodeBefore;if(!c.type.spec.isolating&&_(e,a,t))return!0;if(0==s.parent.content.size&&(h(c,"end")||i.NodeSelection.isSelectable(c))){let n=Object(r.replaceStep)(e.doc,s.before(),s.after(),o.Slice.empty);if(n&&n.slice.size<n.to-n.from){if(t){let r=e.tr.step(n);r.setSelection(h(c,"end")?i.Selection.findFrom(r.doc.resolve(r.mapping.map(a.pos,-1)),-1):i.NodeSelection.create(r.doc,a.pos-c.nodeSize)),t(r.scrollIntoView())}return!0}}return!(!c.isAtom||a.depth!=s.depth-1)&&(t&&t(e.tr.delete(a.pos-c.nodeSize,a.pos).scrollIntoView()),!0)},c=(e,t,n)=>{let r=l(e,n);if(!r)return!1;let o=f(r);return!!o&&u(e,o,t)},d=(e,t,n)=>{let r=m(e,n);if(!r)return!1;let o=v(r);return!!o&&u(e,o,t)};function u(e,t,n){let s=t.nodeBefore,l=t.pos-1;for(;!s.isTextblock;l--){if(s.type.spec.isolating)return!1;let e=s.lastChild;if(!e)return!1;s=e}let a=t.nodeAfter,c=t.pos+1;for(;!a.isTextblock;c++){if(a.type.spec.isolating)return!1;let e=a.firstChild;if(!e)return!1;a=e}let d=Object(r.replaceStep)(e.doc,l,c,o.Slice.empty);if(!d||d.from!=l||d instanceof r.ReplaceStep&&d.slice.size>=c-l)return!1;if(n){let t=e.tr.step(d);t.setSelection(i.TextSelection.create(t.doc,l)),n(t.scrollIntoView())}return!0}function h(e,t,n=!1){for(let r=e;r;r="start"==t?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&1!=r.childCount)return!1}return!1}const p=(e,t,n)=>{let{$head:r,empty:o}=e.selection,s=r;if(!o)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",e):r.parentOffset>0)return!1;s=f(r)}let l=s&&s.nodeBefore;return!(!l||!i.NodeSelection.isSelectable(l))&&(t&&t(e.tr.setSelection(i.NodeSelection.create(e.doc,s.pos-l.nodeSize)).scrollIntoView()),!0)};function f(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 m(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock("forward",e):n.parentOffset<n.parent.content.size)?null:n}const g=(e,t,n)=>{let s=m(e,n);if(!s)return!1;let l=v(s);if(!l)return!1;let a=l.nodeAfter;if(_(e,l,t))return!0;if(0==s.parent.content.size&&(h(a,"start")||i.NodeSelection.isSelectable(a))){let n=Object(r.replaceStep)(e.doc,s.before(),s.after(),o.Slice.empty);if(n&&n.slice.size<n.to-n.from){if(t){let r=e.tr.step(n);r.setSelection(h(a,"start")?i.Selection.findFrom(r.doc.resolve(r.mapping.map(l.pos)),1):i.NodeSelection.create(r.doc,r.mapping.map(l.pos))),t(r.scrollIntoView())}return!0}}return!(!a.isAtom||l.depth!=s.depth-1)&&(t&&t(e.tr.delete(l.pos,l.pos+a.nodeSize).scrollIntoView()),!0)},y=(e,t,n)=>{let{$head:r,empty:o}=e.selection,s=r;if(!o)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",e):r.parentOffset<r.parent.content.size)return!1;s=v(r)}let l=s&&s.nodeAfter;return!(!l||!i.NodeSelection.isSelectable(l))&&(t&&t(e.tr.setSelection(i.NodeSelection.create(e.doc,s.pos)).scrollIntoView()),!0)};function v(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 b=(e,t)=>{let n,o=e.selection,s=o instanceof i.NodeSelection;if(s){if(o.node.isTextblock||!Object(r.canJoin)(e.doc,o.from))return!1;n=o.from}else if(n=Object(r.joinPoint)(e.doc,o.from,-1),null==n)return!1;if(t){let r=e.tr.join(n);s&&r.setSelection(i.NodeSelection.create(r.doc,n-e.doc.resolve(n).nodeBefore.nodeSize)),t(r.scrollIntoView())}return!0},w=(e,t)=>{let n,o=e.selection;if(o instanceof i.NodeSelection){if(o.node.isTextblock||!Object(r.canJoin)(e.doc,o.to))return!1;n=o.to}else if(n=Object(r.joinPoint)(e.doc,o.to,1),null==n)return!1;return t&&t(e.tr.join(n).scrollIntoView()),!0},S=(e,t)=>{let{$from:n,$to:o}=e.selection,i=n.blockRange(o),s=i&&Object(r.liftTarget)(i);return null!=s&&(t&&t(e.tr.lift(i,s).scrollIntoView()),!0)},k=(e,t)=>{let{$head:n,$anchor:r}=e.selection;return!(!n.parent.type.spec.code||!n.sameParent(r))&&(t&&t(e.tr.insertText("\n").scrollIntoView()),!0)};function x(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 C=(e,t)=>{let{$head:n,$anchor:r}=e.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let o=n.node(-1),s=n.indexAfter(-1),l=x(o.contentMatchAt(s));if(!l||!o.canReplaceWith(s,s,l))return!1;if(t){let r=n.after(),o=e.tr.replaceWith(r,r,l.createAndFill());o.setSelection(i.Selection.near(o.doc.resolve(r),1)),t(o.scrollIntoView())}return!0},M=(e,t)=>{let n=e.selection,{$from:r,$to:o}=n;if(n instanceof i.AllSelection||r.parent.inlineContent||o.parent.inlineContent)return!1;let s=x(o.parent.contentMatchAt(o.indexAfter()));if(!s||!s.isTextblock)return!1;if(t){let n=(!r.parentOffset&&o.index()<o.parent.childCount?r:o).pos,l=e.tr.insert(n,s.createAndFill());l.setSelection(i.TextSelection.create(l.doc,n+1)),t(l.scrollIntoView())}return!0},O=(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(Object(r.canSplit)(e.doc,o))return t&&t(e.tr.split(o).scrollIntoView()),!0}let o=n.blockRange(),i=o&&Object(r.liftTarget)(o);return null!=i&&(t&&t(e.tr.lift(o,i).scrollIntoView()),!0)};function A(e){return(t,n)=>{let{$from:o,$to:s}=t.selection;if(t.selection instanceof i.NodeSelection&&t.selection.node.isBlock)return!(!o.parentOffset||!Object(r.canSplit)(t.doc,o.pos))&&(n&&n(t.tr.split(o.pos).scrollIntoView()),!0);if(!o.parent.isBlock)return!1;if(n){let l=s.parentOffset==s.parent.content.size,a=t.tr;(t.selection instanceof i.TextSelection||t.selection instanceof i.AllSelection)&&a.deleteSelection();let c=0==o.depth?null:x(o.node(-1).contentMatchAt(o.indexAfter(-1))),d=e&&e(s.parent,l),u=d?[d]:l&&c?[{type:c}]:void 0,h=Object(r.canSplit)(a.doc,a.mapping.map(o.pos),1,u);if(u||h||!Object(r.canSplit)(a.doc,a.mapping.map(o.pos),1,c?[{type:c}]:void 0)||(c&&(u=[{type:c}]),h=!0),h&&(a.split(a.mapping.map(o.pos),1,u),!l&&!o.parentOffset&&o.parent.type!=c)){let e=a.mapping.map(o.before()),t=a.doc.resolve(e);c&&o.node(-1).canReplaceWith(t.index(),t.index()+1,c)&&a.setNodeMarkup(a.mapping.map(o.before()),c)}n(a.scrollIntoView())}return!0}}const T=A(),N=(e,t)=>T(e,t&&(n=>{let r=e.storedMarks||e.selection.$to.parentOffset&&e.selection.$from.marks();r&&n.ensureMarks(r),t(n)})),R=(e,t)=>{let n,{$from:r,to:o}=e.selection,s=r.sharedDepth(o);return 0!=s&&(n=r.before(s),t&&t(e.tr.setSelection(i.NodeSelection.create(e.doc,n))),!0)},D=(e,t)=>(t&&t(e.tr.setSelection(new i.AllSelection(e.doc))),!0);function _(e,t,n){let s,l,a=t.nodeBefore,c=t.nodeAfter;if(a.type.spec.isolating||c.type.spec.isolating)return!1;if(function(e,t,n){let o=t.nodeBefore,i=t.nodeAfter,s=t.index();return!!(o&&i&&o.type.compatibleContent(i.type))&&(!o.content.size&&t.parent.canReplace(s-1,s)?(n&&n(e.tr.delete(t.pos-o.nodeSize,t.pos).scrollIntoView()),!0):!(!t.parent.canReplace(s,s+1)||!i.isTextblock&&!Object(r.canJoin)(e.doc,t.pos))&&(n&&n(e.tr.clearIncompatible(t.pos,o.type,o.contentMatchAt(o.childCount)).join(t.pos).scrollIntoView()),!0))}(e,t,n))return!0;let d=t.parent.canReplace(t.index(),t.index()+1);if(d&&(s=(l=a.contentMatchAt(a.childCount)).findWrapping(c.type))&&l.matchType(s[0]||c.type).validEnd){if(n){let i=t.pos+c.nodeSize,l=o.Fragment.empty;for(let e=s.length-1;e>=0;e--)l=o.Fragment.from(s[e].create(null,l));l=o.Fragment.from(a.copy(l));let d=e.tr.step(new r.ReplaceAroundStep(t.pos-1,i,t.pos,i,new o.Slice(l,1,0),s.length,!0)),u=i+2*s.length;Object(r.canJoin)(d.doc,u)&&d.join(u),n(d.scrollIntoView())}return!0}let u=i.Selection.findFrom(t,1),p=u&&u.$from.blockRange(u.$to),f=p&&Object(r.liftTarget)(p);if(null!=f&&f>=t.depth)return n&&n(e.tr.lift(p,f).scrollIntoView()),!0;if(d&&h(c,"start",!0)&&h(a,"end")){let i=a,s=[];for(;s.push(i),!i.isTextblock;)i=i.lastChild;let l=c,d=1;for(;!l.isTextblock;l=l.firstChild)d++;if(i.canReplace(i.childCount,i.childCount,l.content)){if(n){let i=o.Fragment.empty;for(let e=s.length-1;e>=0;e--)i=o.Fragment.from(s[e].copy(i));n(e.tr.step(new r.ReplaceAroundStep(t.pos-s.length,t.pos+c.nodeSize,t.pos+d,t.pos+c.nodeSize-d,new o.Slice(i,s.length,0),0,!0)).scrollIntoView())}return!0}}return!1}function E(e){return function(t,n){let r=t.selection,o=e<0?r.$from:r.$to,s=o.depth;for(;o.node(s).isInline;){if(!s)return!1;s--}return!!o.node(s).isTextblock&&(n&&n(t.tr.setSelection(i.TextSelection.create(t.doc,e<0?o.start(s):o.end(s)))),!0)}}const P=E(-1),z=E(1);function I(e,t=null){return function(n,o){let{$from:i,$to:s}=n.selection,l=i.blockRange(s),a=l&&Object(r.findWrapping)(l,e,t);return!!a&&(o&&o(n.tr.wrap(l,a).scrollIntoView()),!0)}}function F(e,t=null){return function(n,r){let o=!1;for(let r=0;r<n.selection.ranges.length&&!o;r++){let{$from:{pos:i},$to:{pos:s}}=n.selection.ranges[r];n.doc.nodesBetween(i,s,(r,i)=>{if(o)return!1;if(r.isTextblock&&!r.hasMarkup(e,t))if(r.type==e)o=!0;else{let t=n.doc.resolve(i),r=t.index();o=t.parent.canReplaceWith(r,r+1,e)}})}if(!o)return!1;if(r){let o=n.tr;for(let r=0;r<n.selection.ranges.length;r++){let{$from:{pos:i},$to:{pos:s}}=n.selection.ranges[r];o.setBlockType(i,s,e,t)}r(o.scrollIntoView())}return!0}}function B(e,t=null){return function(n,r){let{empty:o,$cursor:i,ranges:s}=n.selection;if(o&&!i||!function(e,t,n){for(let r=0;r<t.length;r++){let{$from:o,$to:i}=t[r],s=0==o.depth&&(e.inlineContent&&e.type.allowsMarkType(n));if(e.nodesBetween(o.pos,i.pos,e=>{if(s)return!1;s=e.inlineContent&&e.type.allowsMarkType(n)}),s)return!0}return!1}(n.doc,s,e))return!1;if(r)if(i)e.isInSet(n.storedMarks||i.marks())?r(n.tr.removeStoredMark(e)):r(n.tr.addStoredMark(e.create(t)));else{let o=!1,i=n.tr;for(let t=0;!o&&t<s.length;t++){let{$from:r,$to:i}=s[t];o=n.doc.rangeHasMark(r.pos,i.pos,e)}for(let n=0;n<s.length;n++){let{$from:r,$to:l}=s[n];if(o)i.removeMark(r.pos,l.pos,e);else{let n=r.pos,o=l.pos,s=r.nodeAfter,a=l.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<o&&(n+=c,o-=d),i.addMark(n,o,e.create(t))}}r(i.scrollIntoView())}return!0}}function j(e,t){let n=Array.isArray(t)?e=>t.indexOf(e.type.name)>-1:t;return(t,o,i)=>e(t,o&&function(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 i=[];for(let e=0;e<o.length;e+=2){let r=o[e],s=o[e+1],l=n.doc.resolve(r),a=l.sharedDepth(s),c=l.node(a);for(let e=l.indexAfter(a),n=l.after(a+1);n<=s;++e){let r=c.maybeChild(e);if(!r)break;if(e&&-1==i.indexOf(n)){let o=c.child(e-1);o.type==r.type&&t(o,r)&&i.push(n)}n+=r.nodeSize}}i.sort((e,t)=>e-t);for(let e=i.length-1;e>=0;e--)Object(r.canJoin)(n.doc,i[e])&&n.join(i[e]);e(n)}}(o,n),i)}function $(...e){return function(t,n,r){for(let o=0;o<e.length;o++)if(e[o](t,n,r))return!0;return!1}}let L=$(s,a,p),V=$(s,g,y);const K={Enter:$(k,M,O,T),"Mod-Enter":C,Backspace:L,"Mod-Backspace":L,"Shift-Backspace":L,Delete:V,"Mod-Delete":V,"Mod-a":D},H={"Ctrl-h":K.Backspace,"Alt-Backspace":K["Mod-Backspace"],"Ctrl-d":K.Delete,"Ctrl-Alt-Backspace":K["Mod-Delete"],"Alt-Delete":K["Mod-Delete"],"Alt-d":K["Mod-Delete"],"Ctrl-a":P,"Ctrl-e":z};for(let e in K)H[e]=K[e];const W=("undefined"!=typeof navigator?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!("undefined"==typeof os||!os.platform)&&"darwin"==os.platform())?H:K},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.applyInlineStyle=t.toggleInlineFormat=t.getInlineStyles=void 0;var r=n(4),o=n(2),i=n(5),s=n(9),l=function(e,t){var n=e.find((function(e){return"style"===e.type.name})),r=n&&n.attrs.style;return i.changeStylesString(r,t)},a=function(e,t,n,i,s){var a=s.create({style:i.style}),c=[],d=[],u=null,h=null;return e.doc.nodesBetween(t,n,(function(e,p,f){if(e.isInline){var m=e.marks;if(!a.isInSet(m)&&f.type.allowsMarkType(a.type)){var g=Math.max(p,t),y=Math.min(p+e.nodeSize,n),v=l(m,i);if(v.changed||i.newValue){for(var b=v.changed?{style:v.style||null}:{style:[i.style]+": "+i.newValue+";"},w=s.isInSet(m)?m.find((function(e){return"style"===e.type.name})):null,S=w?r.__assign(r.__assign({},w.attrs),b):b,k=s.create(S),x=k.addToSet(m),C=0;C<m.length;C++)m[C].isInSet(x)||(u&&u.to===g&&u.mark.eq(m[C])?u.to=y:(u=new o.RemoveMarkStep(g,y,m[C]),c.push(u)));var M=h&&h.to===g,O=M&&k.attrs.style===h.mark.attrs.style;M&&O?h.to=y:Object.keys(S).some((function(e){return null!==S[e]}))&&(h=new o.AddMarkStep(g,y,k),d.push(h))}}}})),c.forEach((function(t){return e.step(t)})),d.forEach((function(t){return e.step(t)})),c.length+d.length>0};t.getInlineStyles=function(e,t){var n=e.schema.marks.style;return(n?s.selectionMarks(e,n):[]).map((function(e){return s.styleValue(e,t)})).filter((function(e){return null!==e}))};var c=function(e,t){return function(n,o,c){var d=n.selection,u=d.empty,h=d.$cursor,p=d.ranges;if(u&&!h||!s.markApplies(n.doc,p,e))return!1;var f=!1;if(o){var m=c||n.tr;if(h){var g=n.storedMarks||h.marks();if(e.isInSet(g)){var y=l(g,t),v=g.find((function(e){return"style"===e.type.name})),b=r.__assign(r.__assign({},v?v.attrs:{}),{style:y.style||null});if(i.shallowEqual(v.attrs,b))return!1;o(m.removeStoredMark(e)),Object.keys(b).some((function(e){return null!==b[e]}))&&o(m.addStoredMark(e.create(b))),f=!0}}else{for(var w=0;w<p.length;w++){var S=p[w],k=S.$from,x=S.$to;f=a(m,k.pos,x.pos,t,e)}f&&(m.scrollIntoView(),o(m))}}return f}};t.toggleInlineFormat=function(e,t,n){return function(o,i){var l=o.schema.marks,a=e.altStyle,d=e.altMarks,u=void 0===d?[]:d,h=e.mark,p=t||o.tr,f=!1,m=!1,g=function(){return m=!0};a&&l.style&&(f=c(l.style,{style:a.name,value:a.value})(o,g,p));var y=r.__spreadArray([h],u).filter((function(e){return l[e]})).map((function(e){return s.hasMark(o,{mark:e})&&l[e]})).filter((function(e){return e}));return y.length?s.removeMarks(y,o,g,p):f||s.toggleMark(l[h],n,p)(o,g),m&&i(p),m}};t.applyInlineStyle=function(e,t){return function(n,o){var l=n.schema.marks.style,a={style:e.style,value:/^.+$/,newValue:e.value},d=n.tr;t&&d.setMeta("commandName",t),d.setMeta("args",e);var u=n.selection,h=u.empty,p=u.$cursor,f=u.ranges;if(h&&!p||!l||!s.markApplies(n.doc,f,l))return!1;if(p){var m=n.storedMarks||p.marks(),g=l.isInSet(m)?m.find((function(e){return"style"===e.type.name})):null,y={style:null};if(g&&g.attrs.style){var v=i.changeStylesString(g.attrs.style,a);v.changed&&v.style&&(y.style=v.style)}else a.newValue&&(y.style=[a.style]+": "+a.newValue+";");var b=g?r.__assign(r.__assign({},g.attrs),y):y;return Object.keys(b).some((function(e){return null!==b[e]}))?o(d.addStoredMark(l.create(b))):o(d.removeStoredMark(l)),!0}return c(l,a)(n,o,d)}}},function(e,t,n){"use strict";n.r(t),n.d(t,"addListNodes",(function(){return p})),n.d(t,"bulletList",(function(){return d})),n.d(t,"liftListItem",(function(){return g})),n.d(t,"listItem",(function(){return u})),n.d(t,"orderedList",(function(){return c})),n.d(t,"sinkListItem",(function(){return y})),n.d(t,"splitListItem",(function(){return m})),n.d(t,"wrapInList",(function(){return f}));var r=n(2),o=n(0),i=n(1);const s=["ol",0],l=["ul",0],a=["li",0],c={attrs:{order:{default:1}},parseDOM:[{tag:"ol",getAttrs:e=>({order:e.hasAttribute("start")?+e.getAttribute("start"):1})}],toDOM:e=>1==e.attrs.order?s:["ol",{start:e.attrs.order},0]},d={parseDOM:[{tag:"ul"}],toDOM:()=>l},u={parseDOM:[{tag:"li"}],toDOM:()=>a,defining:!0};function h(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 p(e,t,n){return e.append({ordered_list:h(c,{content:"list_item+",group:n}),bullet_list:h(d,{content:"list_item+",group:n}),list_item:h(u,{content:t})})}function f(e,t=null){return function(n,i){let{$from:s,$to:l}=n.selection,a=s.blockRange(l),c=!1,d=a;if(!a)return!1;if(a.depth>=2&&s.node(a.depth-1).type.compatibleContent(e)&&0==a.startIndex){if(0==s.index(a.depth-1))return!1;let e=n.doc.resolve(a.start-2);d=new o.NodeRange(e,e,a.depth),a.endIndex<a.parent.childCount&&(a=new o.NodeRange(s,n.doc.resolve(l.end(a.depth)),a.depth)),c=!0}let u=Object(r.findWrapping)(d,e,t,a);return!!u&&(i&&i(function(e,t,n,i,s){let l=o.Fragment.empty;for(let e=n.length-1;e>=0;e--)l=o.Fragment.from(n[e].type.create(n[e].attrs,l));e.step(new r.ReplaceAroundStep(t.start-(i?2:0),t.end,t.start,t.end,new o.Slice(l,0,0),n.length,!0));let a=0;for(let e=0;e<n.length;e++)n[e].type==s&&(a=e+1);let c=n.length-a,d=t.start+n.length-(i?2:0),u=t.parent;for(let n=t.startIndex,o=t.endIndex,i=!0;n<o;n++,i=!1)!i&&Object(r.canSplit)(e.doc,d,c)&&(e.split(d,c),d+=2*c),d+=u.child(n).nodeSize;return e}(n.tr,a,u,c,e).scrollIntoView()),!0)}}function m(e,t){return function(n,s){let{$from:l,$to:a,node:c}=n.selection;if(c&&c.isBlock||l.depth<2||!l.sameParent(a))return!1;let d=l.node(-1);if(d.type!=e)return!1;if(0==l.parent.content.size&&l.node(-1).childCount==l.indexAfter(-1)){if(3==l.depth||l.node(-3).type!=e||l.index(-2)!=l.node(-2).childCount-1)return!1;if(s){let t=o.Fragment.empty,r=l.index(-1)?1:l.index(-2)?2:3;for(let e=l.depth-r;e>=l.depth-3;e--)t=o.Fragment.from(l.node(e).copy(t));let a=l.indexAfter(-1)<l.node(-2).childCount?1:l.indexAfter(-2)<l.node(-3).childCount?2:3;t=t.append(o.Fragment.from(e.createAndFill()));let c=l.before(l.depth-(r-1)),d=n.tr.replace(c,l.after(-a),new o.Slice(t,4-r,0)),u=-1;d.doc.nodesBetween(c,d.doc.content.size,(e,t)=>{if(u>-1)return!1;e.isTextblock&&0==e.content.size&&(u=t+1)}),u>-1&&d.setSelection(i.Selection.near(d.doc.resolve(u))),s(d.scrollIntoView())}return!0}let u=a.pos==l.end()?d.contentMatchAt(0).defaultType:null,h=n.tr.delete(l.pos,a.pos),p=u?[t?{type:e,attrs:t}:null,{type:u}]:void 0;return!!Object(r.canSplit)(h.doc,l.pos,2,p)&&(s&&s(h.split(l.pos,2,p).scrollIntoView()),!0)}}function g(e){return function(t,n){let{$from:i,$to:s}=t.selection,l=i.blockRange(s,t=>t.childCount>0&&t.firstChild.type==e);return!!l&&(!n||(i.node(l.depth-1).type==e?function(e,t,n,i){let s=e.tr,l=i.end,a=i.$to.end(i.depth);l<a&&(s.step(new r.ReplaceAroundStep(l-1,a,l,a,new o.Slice(o.Fragment.from(n.create(null,i.parent.copy())),1,0),1,!0)),i=new o.NodeRange(s.doc.resolve(i.$from.pos),s.doc.resolve(a),i.depth));const c=Object(r.liftTarget)(i);if(null==c)return!1;s.lift(i,c);let d=s.mapping.map(l,-1)-1;Object(r.canJoin)(s.doc,d)&&s.join(d);return t(s.scrollIntoView()),!0}(t,n,e,l):function(e,t,n){let i=e.tr,s=n.parent;for(let e=n.end,t=n.endIndex-1,r=n.startIndex;t>r;t--)e-=s.child(t).nodeSize,i.delete(e-1,e+1);let l=i.doc.resolve(n.start),a=l.nodeAfter;if(i.mapping.map(n.end)!=n.start+l.nodeAfter.nodeSize)return!1;let c=0==n.startIndex,d=n.endIndex==s.childCount,u=l.node(-1),h=l.index(-1);if(!u.canReplace(h+(c?0:1),h+1,a.content.append(d?o.Fragment.empty:o.Fragment.from(s))))return!1;let p=l.pos,f=p+a.nodeSize;return i.step(new r.ReplaceAroundStep(p-(c?1:0),f+(d?1:0),p+1,f-1,new o.Slice((c?o.Fragment.empty:o.Fragment.from(s.copy(o.Fragment.empty))).append(d?o.Fragment.empty:o.Fragment.from(s.copy(o.Fragment.empty))),c?0:1,d?0:1),c?0:1)),t(i.scrollIntoView()),!0}(t,n,l)))}}function y(e){return function(t,n){let{$from:i,$to:s}=t.selection,l=i.blockRange(s,t=>t.childCount>0&&t.firstChild.type==e);if(!l)return!1;let a=l.startIndex;if(0==a)return!1;let c=l.parent,d=c.child(a-1);if(d.type!=e)return!1;if(n){let i=d.lastChild&&d.lastChild.type==c.type,s=o.Fragment.from(i?e.create():null),a=new o.Slice(o.Fragment.from(e.create(null,o.Fragment.from(c.type.create(null,s)))),i?3:1,0),u=l.start,h=l.end;n(t.tr.step(new r.ReplaceAroundStep(u-(i?3:1),h,u,h,a,1,!0)).scrollIntoView())}return!0}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.marks=t.nodes=t.parseStrColgroup=void 0;var r=n(4),o=n(0),i=n(7),s=n(8),l=n(6),a=["blockquote",0],c=["hr"],d=["pre",["code",0]],u=["ol",0],h=["ul",0],p=["li",0],f=function(e){for(var t,n={},r=e.attributes,o=0;o<r.length;o++)n[(t=r[o]).name]=t.value;return n},m=function(e){var t={};return e.forEach((function(e){t[e]={default:null}})),t},g=function(){return m(["style","class","id"])},y=function(e,t){for(var n in e)if(n&&null!==e[n]&&n!==t)return!0;return!1},v=function(e,t){void 0===t&&(t=[]);var n={},r=function(r){r&&null!==e[r]&&!t.find((function(e){return e===r}))&&(n[r]=e[r])};for(var o in e)r(o);return n},b=function(e){var t;return(t={})[e]={name:e,inclusive:!0,parseDOM:[{tag:e}],toDOM:function(){return[e,0]}},t},w=r.__assign(r.__assign(r.__assign(r.__assign(r.__assign(r.__assign(r.__assign(r.__assign(r.__assign(r.__assign({link:{attrs:r.__assign(r.__assign({},g()),{href:{default:null},target:{default:null},title:{default:null}}),inclusive:!1,parseDOM:[{tag:"a",getAttrs:f}],toDOM:function(e){return["a",v(e.attrs),0]}}},b("strong")),b("b")),b("em")),b("i")),b("del")),b("sub")),b("sup")),b("code")),{style:{attrs:r.__assign({},g()),parseDOM:[{tag:"span",getAttrs:f}],toDOM:function(e){return y(e.attrs)?["span",v(e.attrs),0]:["span",0]}}}),b("u"));t.marks=w;var S=function(e){var t;return(t={})[e]={default:null,getFromDOM:function(t){return t.getAttribute(e)},setDOMAttr:function(t,n){n[e]=t}},t},k=r.__assign(r.__assign(r.__assign(r.__assign(r.__assign({},S("style")),S("class")),S("id")),S("headers")),S("scope")),x={doc:{content:"colgroup*"},col:{attrs:m(["id","class","style","span"]),parseDOM:[{getAttrs:f,tag:"col"}],toDOM:function(e){return["col",e.attrs]}},colgroup:{attrs:m(["id","class","style","span"]),content:"col*",parseDOM:[{getAttrs:f,tag:"colgroup"}],toDOM:function(e){return["colgroup",e.attrs,0]}},text:{inline:!0,group:"inline"}},C=new o.Schema({nodes:x,marks:{}});t.parseStrColgroup=function(e){var t=s.domToPmDoc(s.htmlToFragment(e),C,{preserveWhitespace:!1});return s.pmDocToFragment(t).firstChild};var M=i.tableNodes({tableGroup:"block",cellContent:"block+",cellAttributes:k});M.table_row.attrs=r.__assign(r.__assign({},M.table_row.attrs),m([l.rowTypeAttr,"style","class","id"])),M.table_row.toDOM=function(e){return["tr",v(e.attrs),0]},M.table_row.parseDOM=[{tag:"tr",getAttrs:f}],M.table.attrs=r.__assign(r.__assign({},M.table.attrs),m(["style","class","id",l.colgroupAttr,l.resizableAttr])),M.table.toDOM=function(e){var n=y(e.attrs)?v(e.attrs,[l.colgroupAttr,l.resizableAttr]):{},r=null;if(e.attrs[l.colgroupAttr]&&!function(e){for(var t=!1,n=e.child(0),r=0;r<n.childCount;r++){if(n.child(r).attrs.colwidth){t=!0;break}}return t}(e)){var o=t.parseStrColgroup(e.attrs[l.colgroupAttr]);if(o){var i=Array.from(o.children).map((function(e){return["col",f(e)]}));r=["colgroup",f(o)].concat(i)}}return r?["table",n,r,["tbody",0]]:["table",n,["tbody",0]]},M.table.parseDOM=[{tag:"table",getAttrs:function(e){var t=f(e),n=Array.from(e.childNodes).find((function(e){return"COLGROUP"===e.nodeName}));return n&&(t[l.colgroupAttr]=n.outerHTML),t}}];var O=r.__assign({doc:{content:"block+"},paragraph:{content:"inline*",group:"block",attrs:r.__assign({},g()),parseDOM:[{tag:"p",getAttrs:f}],toDOM:function(e){return y(e.attrs)?["p",v(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:f}],toDOM:function(e){return y(e.attrs)?["div",v(e.attrs),0]:["div",0]}},table_caption_external:{content:"inline+",group:"block",attrs:r.__assign({caption:{default:null}},g()),parseDOM:[{tag:"div[caption]",getAttrs:f}],toDOM:function(e){return y(e.attrs)?["div",v(e.attrs),0]:["div",0]}},div:{content:"block*",group:"block",attrs:r.__assign({},g()),parseDOM:[{tag:"div",getAttrs:f}],toDOM:function(e){return y(e.attrs)?["div",v(e.attrs),0]:["div",0]}},blockquote:{attrs:r.__assign({},g()),content:"block+",group:"block",defining:!0,parseDOM:[{tag:"blockquote",getAttrs:f}],toDOM:function(e){return y(e.attrs)?["blockquote",v(e.attrs),0]:a}},horizontal_rule:{group:"block",parseDOM:[{tag:"hr"}],toDOM:function(){return c}},heading:{attrs:r.__assign(r.__assign({},g()),{level:{default:1}}),content:"inline*",group:"block",defining:!0,parseDOM:[{tag:"h1",getAttrs:function(e){return r.__assign(r.__assign({},f(e)),{level:1})}},{tag:"h2",getAttrs:function(e){return r.__assign(r.__assign({},f(e)),{level:2})}},{tag:"h3",getAttrs:function(e){return r.__assign(r.__assign({},f(e)),{level:3})}},{tag:"h4",getAttrs:function(e){return r.__assign(r.__assign({},f(e)),{level:4})}},{tag:"h5",getAttrs:function(e){return r.__assign(r.__assign({},f(e)),{level:5})}},{tag:"h6",getAttrs:function(e){return r.__assign(r.__assign({},f(e)),{level:6})}}],toDOM:function(e){return y(e.attrs,"level")?["h"+e.attrs.level,v(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:function(){return d}},text:{inline:!0,group:"inline"},image:{inline:!0,attrs:r.__assign({src:{default:null},alt:{default:null},title:{default:null},width:{default:null},height:{default:null}},g()),group:"inline",draggable:!0,parseDOM:[{tag:"img",getAttrs:f}],toDOM:function(e){return y(e.attrs)?["img",v(e.attrs)]:["img"]}},hard_break:{inline:!0,attrs:r.__assign({},g()),group:"inline",selectable:!1,parseDOM:[{tag:"br",getAttrs:f}],toDOM:function(e){return y(e.attrs)?["br",v(e.attrs)]:["br"]}},ordered_list:{content:"list_item+",group:"block",attrs:r.__assign(r.__assign({},g()),{type:{default:null},order:{default:1}}),parseDOM:[{tag:"ol",getAttrs:function(e){return r.__assign(r.__assign({},f(e)),{order:e.hasAttribute("start")?parseInt(e.getAttribute("start")||"1",10):1})}}],toDOM:function(e){return 1===e.attrs.order?y(e.attrs,"order")?["ol",v(e.attrs,["order"]),0]:u:["ol",r.__assign(r.__assign({},v(e.attrs,["order"])),{start:e.attrs.order}),0]}},bullet_list:{content:"list_item+",group:"block",attrs:r.__assign({},g()),parseDOM:[{tag:"ul",getAttrs:f}],toDOM:function(e){return y(e.attrs)?["ul",v(e.attrs),0]:h}},list_item:{content:"(paragraph | heading) block*",attrs:r.__assign({},g()),parseDOM:[{tag:"li",getAttrs:f}],toDOM:function(e){return y(e.attrs)?["li",v(e.attrs),0]:p},defining:!0}},M);t.nodes=O},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.handles=t.directions=void 0,t.directions={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}},t.handles=Object.keys(t.directions)},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.outdentRules=t.indentRules=void 0;var r=n(4),o=n(19);t.indentRules={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:r.__assign({},o.listsTypes)},t.outdentRules={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:r.__assign({},o.listsTypes)}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.bulletList=t.orderedList=t.listsTypes=void 0;var r=n(4);t.listsTypes={orderedList:"ordered_list",bulletList:"bullet_list",listItem:"list_item"},t.orderedList={listType:t.listsTypes.orderedList,types:r.__assign({},t.listsTypes)},t.bulletList={listType:t.listsTypes.bulletList,types:r.__assign({},t.listsTypes)}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.liftBlockquote=t.blockquote=void 0;var r=n(13);t.blockquote=function(e,t){return r.wrapIn(e.schema.nodes.blockquote)(e,t)};t.liftBlockquote=function(e,t){var n=e.selection,r=n.$from,o=n.$to,i=e.schema.nodes.blockquote,s=e.doc,l=-1,a=r.blockRange(o);a&&s.nodesBetween(a.start,a.end,(function(e,t,n,r){e.type===i&&(l=t)}));var c=-1!==l;return t&&c&&t(e.tr.lift(a,s.resolve(l).depth)),c}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.splitListItemKeepMarks=t.toggleOrderedList=t.toggleUnorderedList=t.toggleList=t.listStyle=void 0;var r=n(4),o=n(0),i=n(1),s=n(2),l=n(13),a=n(15),c=n(19),d=function(e,t,n){for(var r=t.depth,o=e.nodes[n.bulletList],i=e.nodes[n.orderedList],s=e.nodes[n.listItem],l=t.depth;l>0;l--){var a=t.node(l);if(a.type!==o&&a.type!==i||(r=l),a.type!==o&&a.type!==i&&a.type!==s)break}return r-1};function u(e){return function(t,n,r){if(!r)return!1;var o=(t=r.state).schema.nodes[e.listType],i=t.selection,s=i.$from,c=i.$to,d=s.node(-2),u=s.node(-3),h=function(e,t,n,r){return 0===function(e,t,n){var r=Array(),o=function(e,t){var n=["blockquote","bulletList","orderedList"];if(1===t.depth)return t;var r=t.node(t.depth),o=t;for(;t.depth>=1;)t=e.resolve(t.before(t.depth)),(r=t.node(t.depth))&&-1!==n.indexOf(r.type.name)&&(o=t);return o}(e,t).depth,i=e.resolve(t.start(o));for(;i.pos<=n.start(n.depth);){var s=Math.min(i.depth,o),l=i.node(s);if(l&&r.push(l),0===s)break;var a=e.resolve(i.after(s));if(a.start(s)>=e.nodeSize-2)break;a.depth!==i.depth&&(a=e.resolve(a.pos+2)),i=a.depth?e.resolve(a.start(a.depth)):e.resolve(a.end(a.depth))}return r}(e,t,n).filter((function(e){return e.type!==r})).length}(t.doc,s,c,o);return(d&&d.type===o||u&&u.type===o)&&h?p(e)(t,n):(h||(p(e)(t,n),t=r.state),function(e,t){void 0===t&&(t={});return l.autoJoin(a.wrapInList(e,t),(function(t,n){return t.type===n.type&&t.type===e}))}(o,e.listAttrs)(t,n))}}function h(e,t,n,r){var i=r||e.schema.nodes.listItem,l=t.$from,a=t.$to,c=l.blockRange(a,(function(e){return e.childCount&&e.firstChild.type===i}));if(!c||c.depth<2||l.node(c.depth-1).type!==i)return n;var d=c.end,u=a.end(c.depth);return d<u&&(n.step(new s.ReplaceAroundStep(d-1,u,d,u,new o.Slice(o.Fragment.from(i.create(void 0,c.parent.copy())),1,0),1,!0)),c=new o.NodeRange(n.doc.resolve(l.pos),n.doc.resolve(u),c.depth)),n.lift(c,s.liftTarget(c)).scrollIntoView()}function p(e){return function(t,n){var r=t.tr,o=t.selection,l=o.$from,a=o.$to;return r.doc.nodesBetween(l.pos,a.pos,(function(n,o){if(n.isTextblock||"blockquote"===n.type.name||"div"===n.type.name){var l=new i.NodeSelection(r.doc.resolve(r.mapping.map(o))),a=l.$from.blockRange(l.$to);if(!a||l.$from.parent.type!==t.schema.nodes[e.listItem])return!1;var c=a&&s.liftTarget(a);if(null==c)return!1;r.lift(a,c)}})),n&&n(r),!0}}var f=/list\-style\-type:\s?([\w-]+)/;t.listStyle=function(e){var t=e.style||"",n=f.exec(t);return n&&n[1]||""};t.toggleList=function(e,n,r,o,s){var l=o.listType,a=o.listAttrs,c=void 0===a?{style:null}:a,p=e.selection,f=p.$from.node(p.$from.depth-2),m=p.$to.node(p.$to.depth-2);if(f&&f.type.name===l&&t.listStyle(f.attrs)===t.listStyle(c)&&m&&m.type.name===l&&t.listStyle(m.attrs)===t.listStyle(c)){var g=r.state.schema.nodes,y={bulletList:g[o.bulletList],orderedList:g[o.orderedList],listItem:g[o.listItem]},v=function(e,t){for(var n,r=t.bulletList,o=t.orderedList,i=t.listItem,s=e.depth-1;s>0;s--){var l=e.node(s);if(l.type!==r&&l.type!==o||(n=s),l.type!==r&&l.type!==o&&l.type!==i)break}return n}(p.$to,y),b=function(e,t,n,r,o,s){s||(s=e.schema.nodes.listItem);var l=!1;return o.doc.nodesBetween(t,n,(function(n,a){if(!l&&n.type===s&&a>t){l=!0;for(var c=r+3;c>r+2;){var d=o.doc.resolve(o.mapping.map(a));c=d.depth;var u=o.doc.resolve(o.mapping.map(a+n.textContent.length)),p=new i.TextSelection(d,u);o=h(e,p,o,s)}}})),o}(e,p.$to.pos,p.$to.end(v),v,r.state.tr,y.listItem);return(b=function(e,t,n){var r=e.selection,o=r.from,i=r.to,s=e.schema.nodes,l=s.paragraph,a=s.heading,c=[];t.doc.nodesBetween(o,i,(function(e,t){e.type!==l&&e.type!==a||c.push({node:e,pos:t})}));for(var u=c.length-1;u>=0;u--){var h=c[u],p=t.doc.resolve(t.mapping.map(h.pos));if(p.depth>0){var f=void 0;f=h.node.textContent&&h.node.textContent.length>0?t.doc.resolve(t.mapping.map(h.pos+h.node.textContent.length)):t.doc.resolve(t.mapping.map(h.pos+1));var m=p.blockRange(f);m&&t.lift(m,d(e.schema,p,n))}}return t}(e,b,o)).setMeta("commandName",s),n(b),!0}return u(o)(e,n,r)},t.toggleUnorderedList=function(e,n,o){return t.toggleList(e,n,o,r.__assign({listType:c.bulletList.listType},c.bulletList.types))},t.toggleOrderedList=function(e,n,o){return t.toggleList(e,n,o,r.__assign({listType:c.orderedList.listType},c.orderedList.types))};t.splitListItemKeepMarks=function(e){return function(t,n){return a.splitListItem(e)(t,(function(e){var r=t.storedMarks||t.selection.$to.parentOffset&&t.selection.$from.marks();r&&e.ensureMarks(r),n(e)}))}}},function(e,t,n){"use strict";n.r(t),n.d(t,"InputRule",(function(){return i})),n.d(t,"closeDoubleQuote",(function(){return h})),n.d(t,"closeSingleQuote",(function(){return f})),n.d(t,"ellipsis",(function(){return d})),n.d(t,"emDash",(function(){return c})),n.d(t,"inputRules",(function(){return s})),n.d(t,"openDoubleQuote",(function(){return u})),n.d(t,"openSingleQuote",(function(){return p})),n.d(t,"smartQuotes",(function(){return m})),n.d(t,"textblockTypeInputRule",(function(){return y})),n.d(t,"undoInputRule",(function(){return a})),n.d(t,"wrappingInputRule",(function(){return g}));var r=n(1),o=n(2);class i{constructor(e,t){var n;this.match=e,this.match=e,this.handler="string"==typeof t?(n=t,function(e,t,r,o){let i=n;if(t[1]){let e=t[0].lastIndexOf(t[1]);i+=t[0].slice(e+t[1].length);let n=(r+=e)-o;n>0&&(i=t[0].slice(e-n,e)+i,r=o)}return e.tr.insertText(i,r,o)}):t}}function s({rules:e}){let t=new r.Plugin({state:{init:()=>null,apply(e,t){let n=e.getMeta(this);return n||(e.selectionSet||e.docChanged?null:t)}},props:{handleTextInput:(n,r,o,i)=>l(n,r,o,i,e,t),handleDOMEvents:{compositionend:n=>{setTimeout(()=>{let{$cursor:r}=n.state.selection;r&&l(n,r.pos,r.pos,"",e,t)})}}},isInputRules:!0});return t}function l(e,t,n,r,o,i){if(e.composing)return!1;let s=e.state,l=s.doc.resolve(t);if(l.parent.type.spec.code)return!1;let a=l.parent.textBetween(Math.max(0,l.parentOffset-500),l.parentOffset,null,"")+r;for(let l=0;l<o.length;l++){let c=o[l].match.exec(a),d=c&&o[l].handler(s,c,t-(c[0].length-r.length),n);if(d)return e.dispatch(d.setMeta(i,{transform:d,from:t,to:n,text:r})),!0}return!1}const a=(e,t)=>{let n=e.plugins;for(let r=0;r<n.length;r++){let o,i=n[r];if(i.spec.isInputRules&&(o=i.getState(e))){if(t){let n=e.tr,r=o.transform;for(let e=r.steps.length-1;e>=0;e--)n.step(r.steps[e].invert(r.docs[e]));if(o.text){let t=n.doc.resolve(o.from).marks();n.replaceWith(o.from,o.to,e.schema.text(o.text,t))}else n.delete(o.from,o.to);t(n)}return!0}}return!1},c=new i(/--$/,"—"),d=new i(/\.\.\.$/,"…"),u=new i(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,"“"),h=new i(/"$/,"”"),p=new i(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,"‘"),f=new i(/'$/,"’"),m=[u,h,p,f];function g(e,t,n=null,r){return new i(e,(e,i,s,l)=>{let a=n instanceof Function?n(i):n,c=e.tr.delete(s,l),d=c.doc.resolve(s).blockRange(),u=d&&Object(o.findWrapping)(d,t,a);if(!u)return null;c.wrap(d,u);let h=c.doc.resolve(s-1).nodeBefore;return h&&h.type==t&&Object(o.canJoin)(c.doc,s-1)&&(!r||r(i,h))&&c.join(s-1),c})}function y(e,t,n=null){return new i(e,(e,r,o,i)=>{let s=e.doc.resolve(o),l=n instanceof Function?n(r):n;return s.node(-1).canReplaceWith(s.index(-1),s.indexAfter(-1),t)?e.tr.delete(o,i).setBlockType(o,o,t,l):null})}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.unlink=t.link=t.superscript=t.subscript=t.strikethrough=t.underline=t.italic=t.bold=void 0,t.bold={mark:"strong",altMarks:["b"],altStyle:{name:"font-weight",value:/^(bold(er)?|[5-9]\d{2,})$/}},t.italic={mark:"em",altMarks:["i"],altStyle:{name:"font-style",value:/^italic$/i}},t.underline={mark:"u",altStyle:{name:"text-decoration",value:/^underline$/i}},t.strikethrough={mark:"del",altStyle:{name:"text-decoration",value:/^line-through$/i}},t.subscript={mark:"sub"},t.superscript={mark:"sup"},t.link={mark:"link"},t.unlink={mark:"link"}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.convertMsLists=void 0;var r=n(8),o=/style=['"]?[^'"]*?mso-list:\s*[a-zA-Z]+(\d+)\s[a-zA-Z]+(\d+)\s(\w+)/gi,i=function(e){return/^MsoListParagraph/.test(e.className)},s=function(e){var t=e.innerHTML;return t=(t=t.replace(/<!--(.|\s)*?-->/gi,"")).replace(/<\/?[^>]+?\/?>/gm,"")},l=function(e,t){var n=document.createElement(e);return n.style.listStyleType=t,n},a=function(e){var t=null;return/^\d/.test(e)||(t=(/^[a-z]/.test(e)?"lower-":"upper-")+(/^[ivxlcdm]/i.test(e)?"roman":"alpha")),t},c=function(e,t){var n=[];Array.from(e).forEach((function(e){if(e.nodeType===Node.ELEMENT_NODE){var r=e;r.getAttribute("datalist")?(n.push(e),t.add(n)):i(r)&&n.length?n.push(e):(n=[],"DIV"===r.nodeName?c(r.children,t):"TABLE"===r.nodeName&&Array.from(r.querySelectorAll("td,th")).forEach((function(e){c(e.children,t)})))}}))},d=function(e){var t,n=e.innerHTML,r=function(e){return e.replace(/^(?:&nbsp;|[\u00a0\n\r\s])+/,"")};return n=n.replace(/<\/?\w+[^>]*>/g,"").replace(/&nbsp;/g," "),/^[\u2022\u00b7\u00a7\u00d8oØüvn][\u00a0 ]+/.test(n)?{tag:"ul",style:(t=r(s(e)),/^[\u2022\u00b7\u00FC\u00D8\u002dv-]/.test(t)?null:/^o/.test(t)?"circle":"square")}:/^\s*\w+[\.\)][\u00a0 ]{2,}/.test(n)?{tag:"ol",style:a(r(s(e)))}:void 0},u=function(e){var 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?s(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);var o=document.createElement("li");return o.appendChild(r.htmlToFragment(t)),o};t.convertMsLists=function(e){var t=r.htmlToFragment(function(e){return e=e.replace(o,(function(e,t,n){return'datalist="'+t+'" datalevel="'+n+'" '+e}))}(e)),n=new Set;return c(t.children,n),n.forEach((function(e){return function(e){var t,n,r,o,s,a,c,h,p,f,m,g,y,v=-1,b={};for(h=0;h<e.length;h++){var w=(y={datalist:(p=e[h]).getAttribute("datalist"),datalevel:p.getAttribute("datalevel")}).datalist,S=d(p);if(f=S&&S.tag){if(m=y.datalevel||parseFloat(p.style.marginLeft||0),y.datalevel||p.style.marginLeft){var k=f+w;b[m]||(b[m]={}),(!n||n<0)&&(n=m,r=w,o=(c=e.filter((function(e){return e.getAttribute("datalist")===String(r)})))[c.length-1],a=l(f,S&&S.style),p.parentNode.insertBefore(a,p),v=m,b[m][k]=a),s=o===p,g=b[m][k],(m>v||!g)&&(g=l(f,S&&S.style),b[m][k]=g,t.appendChild(g)),t=u(p),g.appendChild(t),s?n=v=-1:v=m}}else!t||s&&!i(p)||(p.style.marginLeft&&(p.style.marginLeft=""),p.style.marginLeft&&(p.style.margin=""),t.appendChild(p))}}(e)})),r.fragmentToHtml(t)}},function(e,t,n){"use strict";n.r(t),n.d(t,"closeHistory",(function(){return b})),n.d(t,"history",(function(){return k})),n.d(t,"redo",(function(){return C})),n.d(t,"redoDepth",(function(){return O})),n.d(t,"undo",(function(){return x})),n.d(t,"undoDepth",(function(){return M}));var r=function(){};r.prototype.append=function(e){return e.length?(e=r.from(e),!this.length&&e||e.length<200&&this.leafAppend(e)||this.length<200&&e.leafPrepend(this)||this.appendInner(e)):this},r.prototype.prepend=function(e){return e.length?r.from(e).append(this):this},r.prototype.appendInner=function(e){return new i(this,e)},r.prototype.slice=function(e,t){return void 0===e&&(e=0),void 0===t&&(t=this.length),e>=t?r.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},r.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},r.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)},r.prototype.map=function(e,t,n){void 0===t&&(t=0),void 0===n&&(n=this.length);var r=[];return this.forEach((function(t,n){return r.push(e(t,n))}),t,n),r},r.from=function(e){return e instanceof r?e:e&&e.length?new o(e):r.empty};var o=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,r){for(var o=t;o<n;o++)if(!1===e(this.values[o],r+o))return!1},t.prototype.forEachInvertedInner=function(e,t,n,r){for(var o=t-1;o>=n;o--)if(!1===e(this.values[o],r+o))return!1},t.prototype.leafAppend=function(e){if(this.length+e.length<=200)return new t(this.values.concat(e.flatten()))},t.prototype.leafPrepend=function(e){if(this.length+e.length<=200)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}(r);r.empty=new o([]);var i=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,r){var o=this.left.length;return!(t<o&&!1===this.left.forEachInner(e,t,Math.min(n,o),r))&&(!(n>o&&!1===this.right.forEachInner(e,Math.max(t-o,0),Math.min(this.length,n)-o,r+o))&&void 0)},t.prototype.forEachInvertedInner=function(e,t,n,r){var o=this.left.length;return!(t>o&&!1===this.right.forEachInvertedInner(e,t-o,Math.max(n,o)-o,r+o))&&(!(n<o&&!1===this.left.forEachInvertedInner(e,Math.min(t,o),n,r))&&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}(r),s=r,l=n(2),a=n(1);class c{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(0==this.eventCount)return null;let n,r,o=this.items.length;for(;;o--){if(this.items.get(o-1).selection){--o;break}}t&&(n=this.remapping(o,this.items.length),r=n.maps.length);let i,s,l=e.tr,a=[],u=[];return this.items.forEach((e,t)=>{if(!e.step)return n||(n=this.remapping(o,t+1),r=n.maps.length),r--,void u.push(e);if(n){u.push(new d(e.map));let t,o=e.step.map(n.slice(r));o&&l.maybeStep(o).doc&&(t=l.mapping.maps[l.mapping.maps.length-1],a.push(new d(t,void 0,void 0,a.length+u.length))),r--,t&&n.appendMap(t,r)}else l.maybeStep(e.step);return e.selection?(i=n?e.selection.map(n.slice(r)):e.selection,s=new c(this.items.slice(0,o).append(u.reverse().concat(a)),this.eventCount-1),!1):void 0},this.items.length,0),{remaining:s,transform:l,selection:i}}addTransform(e,t,n,r){let o=[],i=this.eventCount,s=this.items,l=!r&&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]),u=new d(e.mapping.maps[n],c,t);(a=l&&l.merge(u))&&(u=a,n?o.pop():s=s.slice(0,s.length-1)),o.push(u),t&&(i++,t=void 0),r||(l=u)}let a=i-n.depth;return a>h&&(s=function(e,t){let n;return e.forEach((e,r)=>{if(e.selection&&0==t--)return n=r,!1}),e.slice(n)}(s,a),i-=a),new c(s.append(o),i)}remapping(e,t){let n=new l.Mapping;return this.items.forEach((t,r)=>{let o=null!=t.mirrorOffset&&r-t.mirrorOffset>=e?n.maps.length-t.mirrorOffset:void 0;n.appendMap(t.map,o)},e,t),n}addMaps(e){return 0==this.eventCount?this:new c(this.items.append(e.map(e=>new d(e))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let n=[],r=Math.max(0,this.items.length-t),o=e.mapping,i=e.steps.length,s=this.eventCount;this.items.forEach(e=>{e.selection&&s--},r);let l=t;this.items.forEach(t=>{let r=o.getMirror(--l);if(null==r)return;i=Math.min(i,r);let a=o.maps[r];if(t.step){let i=e.steps[r].invert(e.docs[r]),c=t.selection&&t.selection.map(o.slice(l+1,r));c&&s++,n.push(new d(a,i,c))}else n.push(new d(a))},r);let a=[];for(let e=t;e<i;e++)a.push(new d(o.maps[e]));let u=this.items.slice(0,r).append(a).append(n),h=new c(u,s);return h.emptyItemCount()>500&&(h=h.compress(this.items.length-n.length)),h}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,r=[],o=0;return this.items.forEach((i,s)=>{if(s>=e)r.push(i),i.selection&&o++;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&&o++;let a,c=new d(s.invert(),e,l),u=r.length-1;(a=r.length&&r[u].merge(c))?r[u]=a:r.push(c)}}else i.map&&n--},this.items.length,0),new c(s.from(r.reverse()),o)}}c.empty=new c(s.empty,0);class d{constructor(e,t,n,r){this.map=e,this.step=t,this.selection=n,this.mirrorOffset=r}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new d(t.getMap().invert(),t,this.selection)}}}class u{constructor(e,t,n,r,o){this.done=e,this.undone=t,this.prevRanges=n,this.prevTime=r,this.prevComposition=o}}const h=20;function p(e){let t=[];return e.forEach((e,n,r,o)=>t.push(r,o)),t}function f(e,t){if(!e)return null;let n=[];for(let r=0;r<e.length;r+=2){let o=t.map(e[r],1),i=t.map(e[r+1],-1);o<=i&&n.push(o,i)}return n}function m(e,t,n,r){let o=v(t),i=w.get(t).spec.config,s=(r?e.undone:e.done).popEvent(t,o);if(!s)return;let l=s.selection.resolve(s.transform.doc),a=(r?e.done:e.undone).addTransform(s.transform,t.selection.getBookmark(),i,o),c=new u(r?a:s.remaining,r?s.remaining:a,null,0,-1);n(s.transform.setSelection(l).setMeta(w,{redo:r,historyState:c}).scrollIntoView())}let g=!1,y=null;function v(e){let t=e.plugins;if(y!=t){g=!1,y=t;for(let e=0;e<t.length;e++)if(t[e].spec.historyPreserveItems){g=!0;break}}return g}function b(e){return e.setMeta(S,!0)}const w=new a.PluginKey("history"),S=new a.PluginKey("closeHistory");function k(e={}){return e={depth:e.depth||100,newGroupDelay:e.newGroupDelay||500},new a.Plugin({key:w,state:{init:()=>new u(c.empty,c.empty,null,0,-1),apply:(t,n,r)=>function(e,t,n,r){let o,i=n.getMeta(w);if(i)return i.historyState;n.getMeta(S)&&(e=new u(e.done,e.undone,null,0,-1));let s=n.getMeta("appendedTransaction");if(0==n.steps.length)return e;if(s&&s.getMeta(w))return s.getMeta(w).redo?new u(e.done.addTransform(n,void 0,r,v(t)),e.undone,p(n.mapping.maps[n.steps.length-1]),e.prevTime,e.prevComposition):new u(e.done,e.undone.addTransform(n,void 0,r,v(t)),null,e.prevTime,e.prevComposition);if(!1===n.getMeta("addToHistory")||s&&!1===s.getMeta("addToHistory"))return(o=n.getMeta("rebased"))?new u(e.done.rebased(n,o),e.undone.rebased(n,o),f(e.prevRanges,n.mapping),e.prevTime,e.prevComposition):new u(e.done.addMaps(n.mapping.maps),e.undone.addMaps(n.mapping.maps),f(e.prevRanges,n.mapping),e.prevTime,e.prevComposition);{let o=n.getMeta("composition"),i=0==e.prevTime||!s&&e.prevComposition!=o&&(e.prevTime<(n.time||0)-r.newGroupDelay||!function(e,t){if(!t)return!1;if(!e.docChanged)return!0;let n=!1;return e.mapping.maps[0].forEach((e,r)=>{for(let o=0;o<t.length;o+=2)e<=t[o+1]&&r>=t[o]&&(n=!0)}),n}(n,e.prevRanges)),l=s?f(e.prevRanges,n.mapping):p(n.mapping.maps[n.steps.length-1]);return new u(e.done.addTransform(n,i?t.selection.getBookmark():void 0,r,v(t)),c.empty,l,n.time,null==o?e.prevComposition:o)}}(n,r,t,e)},config:e,props:{handleDOMEvents:{beforeinput(e,t){let n=t.inputType,r="historyUndo"==n?x:"historyRedo"==n?C:null;return!!r&&(t.preventDefault(),r(e.state,e.dispatch))}}}})}const x=(e,t)=>{let n=w.getState(e);return!(!n||0==n.done.eventCount)&&(t&&m(n,e,t,!1),!0)},C=(e,t)=>{let n=w.getState(e);return!(!n||0==n.undone.eventCount)&&(t&&m(n,e,t,!0),!0)};function M(e){let t=w.getState(e);return t?t.done.eventCount:0}function O(e){let t=w.getState(e);return t?t.undone.eventCount:0}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.expandSelection=t.selectedLineTextOnly=t.getNodeFromSelection=t.getSelectionText=t.hasSameMarkup=t.liftBlockquote=t.blockquote=t.listStyle=t.toggleList=t.toggleUnorderedList=t.toggleOrderedList=t.indentBlocks=t.canBeIndented=t.isIndented=t.canOutdentAsListItem=t.outdent=t.canIndentAsListItem=t.indent=t.selectionMarks=t.cleanMarks=t.removeAllMarks=t.getActiveMarks=t.getMark=t.hasMark=t.cleanTextBlockFormatting=t.blockNodes=t.changeTextBlock=t.parentBlockFormat=t.getBlockFormats=t.formatBlockElements=t.activeNode=t.hasNode=t.cleanFormatting=t.isAligned=t.alignBlocks=t.insertImage=t.insertText=t.removeLink=t.applyLink=t.toggleInlineFormat=t.getInlineStyles=t.applyInlineStyle=t.fragmentToHtml=t.pmDocToFragment=t.domToPmDoc=t.htmlToFragment=t.trimWhitespace=t.parseContent=t.setHtml=t.getHtml=void 0,t.tableEditing=t.TableMap=t.tableRowResizeKey=t.tableColumnResizeKey=t.tableResizeKey=t.tableResizing=t.caretColorKey=t.caretColor=t.imageResizeKey=t.imageResizing=t.textHighlightKey=t.textHighlight=t.spacesFix=t.placeholder=t.replaceAll=t.replace=t.findAll=t.findAt=t.find=t.convertMsLists=t.replaceImageSourcesFromRtf=t.removeAttribute=t.sanitizeStyleAttr=t.sanitizeClassAttr=t.pasteCleanup=t.removeTag=t.removeComments=t.sanitize=t.link=t.superscript=t.subscript=t.strikethrough=t.underline=t.italic=t.bold=t.buildListKeymap=t.buildKeymap=t.marks=t.nodes=t.outdentRules=t.indentRules=t.alignRemoveRules=t.alignJustifyRules=t.alignRightRules=t.alignCenterRules=t.alignLeftRules=t.indentHtml=t.insertNode=t.canInsert=t.expandToWordWrap=void 0,t.pmDeleteColumn=t.pmAddRowBefore=t.pmAddRowAfter=t.pmAddColumnAfter=t.pmAddColumnBefore=t.deleteColumn=t.addColumnAfter=t.addColumnBefore=t.addRowBefore=t.addRowAfter=t.createTable=t.nextCell=t.moveCellForward=t.removeColSpan=t.findCell=t.cellAround=t.updateColumnsOnResize=t.columnResizingPluginKey=t.columnResizing=t.columnIsHeader=t.colCount=t.addColumn=t.addColSpan=t.addRow=t.rowIsHeader=t.deleteRow=t.mergeCells=t.splitCellWithType=t.splitCell=t.toggleHeaderRow=t.toggleHeaderColumn=t.toggleHeaderCell=t.toggleHeader=t.goToNextCell=t.setCellAttr=t.selectionCell=t.selectedRect=t.CellSelection=t.inSameTable=t.deleteTable=t.isInTable=t.fixTablesKey=t.fixTables=t.tableNodes=t.tableNodeTypes=t.tableEditingKey=void 0;var r=n(4),o=n(8);Object.defineProperty(t,"getHtml",{enumerable:!0,get:function(){return o.getHtml}}),Object.defineProperty(t,"setHtml",{enumerable:!0,get:function(){return o.setHtml}}),Object.defineProperty(t,"parseContent",{enumerable:!0,get:function(){return o.parseContent}}),Object.defineProperty(t,"trimWhitespace",{enumerable:!0,get:function(){return o.trimWhitespace}}),Object.defineProperty(t,"htmlToFragment",{enumerable:!0,get:function(){return o.htmlToFragment}}),Object.defineProperty(t,"domToPmDoc",{enumerable:!0,get:function(){return o.domToPmDoc}}),Object.defineProperty(t,"pmDocToFragment",{enumerable:!0,get:function(){return o.pmDocToFragment}}),Object.defineProperty(t,"fragmentToHtml",{enumerable:!0,get:function(){return o.fragmentToHtml}});var i=n(14);Object.defineProperty(t,"applyInlineStyle",{enumerable:!0,get:function(){return i.applyInlineStyle}}),Object.defineProperty(t,"getInlineStyles",{enumerable:!0,get:function(){return i.getInlineStyles}}),Object.defineProperty(t,"toggleInlineFormat",{enumerable:!0,get:function(){return i.toggleInlineFormat}});var s=n(27);Object.defineProperty(t,"applyLink",{enumerable:!0,get:function(){return s.applyLink}}),Object.defineProperty(t,"removeLink",{enumerable:!0,get:function(){return s.removeLink}});var l=n(28);Object.defineProperty(t,"insertText",{enumerable:!0,get:function(){return l.insertText}});var a=n(29);Object.defineProperty(t,"insertImage",{enumerable:!0,get:function(){return a.insertImage}});var c=n(30);Object.defineProperty(t,"alignBlocks",{enumerable:!0,get:function(){return c.alignBlocks}}),Object.defineProperty(t,"isAligned",{enumerable:!0,get:function(){return c.isAligned}});var d=n(31);Object.defineProperty(t,"cleanFormatting",{enumerable:!0,get:function(){return d.cleanFormatting}});var u=n(12);Object.defineProperty(t,"hasNode",{enumerable:!0,get:function(){return u.hasNode}}),Object.defineProperty(t,"activeNode",{enumerable:!0,get:function(){return u.activeNode}}),Object.defineProperty(t,"formatBlockElements",{enumerable:!0,get:function(){return u.formatBlockElements}}),Object.defineProperty(t,"getBlockFormats",{enumerable:!0,get:function(){return u.getBlockFormats}}),Object.defineProperty(t,"parentBlockFormat",{enumerable:!0,get:function(){return u.parentBlockFormat}}),Object.defineProperty(t,"changeTextBlock",{enumerable:!0,get:function(){return u.changeTextBlock}}),Object.defineProperty(t,"blockNodes",{enumerable:!0,get:function(){return u.blockNodes}}),Object.defineProperty(t,"cleanTextBlockFormatting",{enumerable:!0,get:function(){return u.cleanTextBlockFormatting}});var h=n(9);Object.defineProperty(t,"hasMark",{enumerable:!0,get:function(){return h.hasMark}}),Object.defineProperty(t,"getMark",{enumerable:!0,get:function(){return h.getMark}}),Object.defineProperty(t,"getActiveMarks",{enumerable:!0,get:function(){return h.getActiveMarks}}),Object.defineProperty(t,"removeAllMarks",{enumerable:!0,get:function(){return h.removeAllMarks}}),Object.defineProperty(t,"cleanMarks",{enumerable:!0,get:function(){return h.cleanMarks}}),Object.defineProperty(t,"selectionMarks",{enumerable:!0,get:function(){return h.selectionMarks}});var p=n(32);Object.defineProperty(t,"indent",{enumerable:!0,get:function(){return p.indent}}),Object.defineProperty(t,"canIndentAsListItem",{enumerable:!0,get:function(){return p.canIndentAsListItem}}),Object.defineProperty(t,"outdent",{enumerable:!0,get:function(){return p.outdent}}),Object.defineProperty(t,"canOutdentAsListItem",{enumerable:!0,get:function(){return p.canOutdentAsListItem}}),Object.defineProperty(t,"isIndented",{enumerable:!0,get:function(){return p.isIndented}}),Object.defineProperty(t,"canBeIndented",{enumerable:!0,get:function(){return p.canBeIndented}}),Object.defineProperty(t,"indentBlocks",{enumerable:!0,get:function(){return p.indentBlocks}});var f=n(21);Object.defineProperty(t,"toggleOrderedList",{enumerable:!0,get:function(){return f.toggleOrderedList}}),Object.defineProperty(t,"toggleUnorderedList",{enumerable:!0,get:function(){return f.toggleUnorderedList}}),Object.defineProperty(t,"toggleList",{enumerable:!0,get:function(){return f.toggleList}}),Object.defineProperty(t,"listStyle",{enumerable:!0,get:function(){return f.listStyle}});var m=n(20);Object.defineProperty(t,"blockquote",{enumerable:!0,get:function(){return m.blockquote}}),Object.defineProperty(t,"liftBlockquote",{enumerable:!0,get:function(){return m.liftBlockquote}});var g=n(5);Object.defineProperty(t,"hasSameMarkup",{enumerable:!0,get:function(){return g.hasSameMarkup}}),Object.defineProperty(t,"getSelectionText",{enumerable:!0,get:function(){return g.getSelectionText}}),Object.defineProperty(t,"getNodeFromSelection",{enumerable:!0,get:function(){return g.getNodeFromSelection}}),Object.defineProperty(t,"selectedLineTextOnly",{enumerable:!0,get:function(){return g.selectedLineTextOnly}}),Object.defineProperty(t,"expandSelection",{enumerable:!0,get:function(){return g.expandSelection}}),Object.defineProperty(t,"expandToWordWrap",{enumerable:!0,get:function(){return g.expandToWordWrap}}),Object.defineProperty(t,"canInsert",{enumerable:!0,get:function(){return g.canInsert}}),Object.defineProperty(t,"insertNode",{enumerable:!0,get:function(){return g.insertNode}}),Object.defineProperty(t,"indentHtml",{enumerable:!0,get:function(){return g.indentHtml}});var y=n(33);Object.defineProperty(t,"alignLeftRules",{enumerable:!0,get:function(){return y.alignLeftRules}}),Object.defineProperty(t,"alignCenterRules",{enumerable:!0,get:function(){return y.alignCenterRules}}),Object.defineProperty(t,"alignRightRules",{enumerable:!0,get:function(){return y.alignRightRules}}),Object.defineProperty(t,"alignJustifyRules",{enumerable:!0,get:function(){return y.alignJustifyRules}}),Object.defineProperty(t,"alignRemoveRules",{enumerable:!0,get:function(){return y.alignRemoveRules}});var v=n(18);Object.defineProperty(t,"indentRules",{enumerable:!0,get:function(){return v.indentRules}}),Object.defineProperty(t,"outdentRules",{enumerable:!0,get:function(){return v.outdentRules}});var b=n(16);Object.defineProperty(t,"nodes",{enumerable:!0,get:function(){return b.nodes}}),Object.defineProperty(t,"marks",{enumerable:!0,get:function(){return b.marks}});var w=n(34);Object.defineProperty(t,"buildKeymap",{enumerable:!0,get:function(){return w.buildKeymap}}),Object.defineProperty(t,"buildListKeymap",{enumerable:!0,get:function(){return w.buildListKeymap}});var S=n(23);Object.defineProperty(t,"bold",{enumerable:!0,get:function(){return S.bold}}),Object.defineProperty(t,"italic",{enumerable:!0,get:function(){return S.italic}}),Object.defineProperty(t,"underline",{enumerable:!0,get:function(){return S.underline}}),Object.defineProperty(t,"strikethrough",{enumerable:!0,get:function(){return S.strikethrough}}),Object.defineProperty(t,"subscript",{enumerable:!0,get:function(){return S.subscript}}),Object.defineProperty(t,"superscript",{enumerable:!0,get:function(){return S.superscript}}),Object.defineProperty(t,"link",{enumerable:!0,get:function(){return S.link}});var k=n(35);Object.defineProperty(t,"sanitize",{enumerable:!0,get:function(){return k.sanitize}}),Object.defineProperty(t,"removeComments",{enumerable:!0,get:function(){return k.removeComments}}),Object.defineProperty(t,"removeTag",{enumerable:!0,get:function(){return k.removeTag}}),Object.defineProperty(t,"pasteCleanup",{enumerable:!0,get:function(){return k.pasteCleanup}}),Object.defineProperty(t,"sanitizeClassAttr",{enumerable:!0,get:function(){return k.sanitizeClassAttr}}),Object.defineProperty(t,"sanitizeStyleAttr",{enumerable:!0,get:function(){return k.sanitizeStyleAttr}}),Object.defineProperty(t,"removeAttribute",{enumerable:!0,get:function(){return k.removeAttribute}}),Object.defineProperty(t,"replaceImageSourcesFromRtf",{enumerable:!0,get:function(){return k.replaceImageSourcesFromRtf}});var x=n(24);Object.defineProperty(t,"convertMsLists",{enumerable:!0,get:function(){return x.convertMsLists}});var C=n(36);Object.defineProperty(t,"find",{enumerable:!0,get:function(){return C.find}}),Object.defineProperty(t,"findAt",{enumerable:!0,get:function(){return C.findAt}}),Object.defineProperty(t,"findAll",{enumerable:!0,get:function(){return C.findAll}}),Object.defineProperty(t,"replace",{enumerable:!0,get:function(){return C.replace}}),Object.defineProperty(t,"replaceAll",{enumerable:!0,get:function(){return C.replaceAll}});var M=n(37);Object.defineProperty(t,"placeholder",{enumerable:!0,get:function(){return M.placeholder}});var O=n(38);Object.defineProperty(t,"spacesFix",{enumerable:!0,get:function(){return O.spacesFix}});var A=n(39);Object.defineProperty(t,"textHighlight",{enumerable:!0,get:function(){return A.textHighlight}}),Object.defineProperty(t,"textHighlightKey",{enumerable:!0,get:function(){return A.textHighlightKey}});var T=n(40);Object.defineProperty(t,"imageResizing",{enumerable:!0,get:function(){return T.imageResizing}}),Object.defineProperty(t,"imageResizeKey",{enumerable:!0,get:function(){return T.imageResizeKey}});var N=n(41);Object.defineProperty(t,"caretColor",{enumerable:!0,get:function(){return N.caretColor}}),Object.defineProperty(t,"caretColorKey",{enumerable:!0,get:function(){return N.caretColorKey}});var R=n(42);Object.defineProperty(t,"tableResizing",{enumerable:!0,get:function(){return R.tableResizing}}),Object.defineProperty(t,"tableResizeKey",{enumerable:!0,get:function(){return R.tableResizeKey}}),Object.defineProperty(t,"tableColumnResizeKey",{enumerable:!0,get:function(){return R.tableColumnResizeKey}}),Object.defineProperty(t,"tableRowResizeKey",{enumerable:!0,get:function(){return R.tableRowResizeKey}}),r.__exportStar(n(13),t),r.__exportStar(n(47),t),r.__exportStar(n(48),t),r.__exportStar(n(25),t),r.__exportStar(n(22),t),r.__exportStar(n(11),t),r.__exportStar(n(0),t),r.__exportStar(n(15),t),r.__exportStar(n(1),t);var D=n(7);Object.defineProperty(t,"TableMap",{enumerable:!0,get:function(){return D.TableMap}}),Object.defineProperty(t,"tableEditing",{enumerable:!0,get:function(){return D.tableEditing}}),Object.defineProperty(t,"tableEditingKey",{enumerable:!0,get:function(){return D.tableEditingKey}}),Object.defineProperty(t,"tableNodeTypes",{enumerable:!0,get:function(){return D.tableNodeTypes}}),Object.defineProperty(t,"tableNodes",{enumerable:!0,get:function(){return D.tableNodes}}),Object.defineProperty(t,"fixTables",{enumerable:!0,get:function(){return D.fixTables}}),Object.defineProperty(t,"fixTablesKey",{enumerable:!0,get:function(){return D.fixTablesKey}}),Object.defineProperty(t,"isInTable",{enumerable:!0,get:function(){return D.isInTable}}),Object.defineProperty(t,"deleteTable",{enumerable:!0,get:function(){return D.deleteTable}}),Object.defineProperty(t,"inSameTable",{enumerable:!0,get:function(){return D.inSameTable}}),Object.defineProperty(t,"CellSelection",{enumerable:!0,get:function(){return D.CellSelection}}),Object.defineProperty(t,"selectedRect",{enumerable:!0,get:function(){return D.selectedRect}}),Object.defineProperty(t,"selectionCell",{enumerable:!0,get:function(){return D.selectionCell}}),Object.defineProperty(t,"setCellAttr",{enumerable:!0,get:function(){return D.setCellAttr}}),Object.defineProperty(t,"goToNextCell",{enumerable:!0,get:function(){return D.goToNextCell}}),Object.defineProperty(t,"toggleHeader",{enumerable:!0,get:function(){return D.toggleHeader}}),Object.defineProperty(t,"toggleHeaderCell",{enumerable:!0,get:function(){return D.toggleHeaderCell}}),Object.defineProperty(t,"toggleHeaderColumn",{enumerable:!0,get:function(){return D.toggleHeaderColumn}}),Object.defineProperty(t,"toggleHeaderRow",{enumerable:!0,get:function(){return D.toggleHeaderRow}}),Object.defineProperty(t,"splitCell",{enumerable:!0,get:function(){return D.splitCell}}),Object.defineProperty(t,"splitCellWithType",{enumerable:!0,get:function(){return D.splitCellWithType}}),Object.defineProperty(t,"mergeCells",{enumerable:!0,get:function(){return D.mergeCells}}),Object.defineProperty(t,"deleteRow",{enumerable:!0,get:function(){return D.deleteRow}}),Object.defineProperty(t,"rowIsHeader",{enumerable:!0,get:function(){return D.rowIsHeader}}),Object.defineProperty(t,"addRow",{enumerable:!0,get:function(){return D.addRow}}),Object.defineProperty(t,"addColSpan",{enumerable:!0,get:function(){return D.addColSpan}}),Object.defineProperty(t,"addColumn",{enumerable:!0,get:function(){return D.addColumn}}),Object.defineProperty(t,"colCount",{enumerable:!0,get:function(){return D.colCount}}),Object.defineProperty(t,"columnIsHeader",{enumerable:!0,get:function(){return D.columnIsHeader}}),Object.defineProperty(t,"columnResizing",{enumerable:!0,get:function(){return D.columnResizing}}),Object.defineProperty(t,"columnResizingPluginKey",{enumerable:!0,get:function(){return D.columnResizingPluginKey}}),Object.defineProperty(t,"updateColumnsOnResize",{enumerable:!0,get:function(){return D.updateColumnsOnResize}}),Object.defineProperty(t,"cellAround",{enumerable:!0,get:function(){return D.cellAround}}),Object.defineProperty(t,"findCell",{enumerable:!0,get:function(){return D.findCell}}),Object.defineProperty(t,"removeColSpan",{enumerable:!0,get:function(){return D.removeColSpan}}),Object.defineProperty(t,"moveCellForward",{enumerable:!0,get:function(){return D.moveCellForward}}),Object.defineProperty(t,"nextCell",{enumerable:!0,get:function(){return D.nextCell}}),r.__exportStar(n(2),t),r.__exportStar(n(3),t);var _=n(49);Object.defineProperty(t,"createTable",{enumerable:!0,get:function(){return _.createTable}}),Object.defineProperty(t,"addRowAfter",{enumerable:!0,get:function(){return _.addRowAfter}}),Object.defineProperty(t,"addRowBefore",{enumerable:!0,get:function(){return _.addRowBefore}}),Object.defineProperty(t,"addColumnBefore",{enumerable:!0,get:function(){return _.addColumnBefore}}),Object.defineProperty(t,"addColumnAfter",{enumerable:!0,get:function(){return _.addColumnAfter}}),Object.defineProperty(t,"deleteColumn",{enumerable:!0,get:function(){return _.deleteColumn}}),Object.defineProperty(t,"pmAddColumnBefore",{enumerable:!0,get:function(){return _.pmAddColumnBefore}}),Object.defineProperty(t,"pmAddColumnAfter",{enumerable:!0,get:function(){return _.pmAddColumnAfter}}),Object.defineProperty(t,"pmAddRowAfter",{enumerable:!0,get:function(){return _.pmAddRowAfter}}),Object.defineProperty(t,"pmAddRowBefore",{enumerable:!0,get:function(){return _.pmAddRowBefore}}),Object.defineProperty(t,"pmDeleteColumn",{enumerable:!0,get:function(){return _.pmDeleteColumn}})},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.applyLink=t.removeLink=void 0;var r=n(14),o=n(9),i=n(1);t.removeLink=function(e,t){return function(n,i){var s=n.selection.$cursor;if(s){var l=s.parent,a=s.index(),c=n.schema.marks[e.mark],d=l.child(a).marks.find((function(e){return e.type===c})),u=l.childCount,h=s.pos-s.textOffset,p=l.child(a).nodeSize,f=void 0,m=void 0;for(f=a-1;f>=0&&d.isInSet(l.child(f).marks);)p+=m=l.child(f).nodeSize,h-=m,f-=1;for(f=a+1;f<u&&d.isInSet(l.child(f).marks);)p+=l.child(f).nodeSize,f+=1;i(o.removeMark(t||n.tr,h,h+p,d))}else r.toggleInlineFormat(e,t)(n,i)}};t.applyLink=function(e,n){var s=e.mark,l=e.attrs;return void 0===n&&(n="link"),function(e,a){var c=e.schema.marks,d=e.tr;n&&(d.setMeta("commandName",n),d.setMeta("args",l));var u=!1,h=function(){return u=!0};if(function(e,t){var n=o.selectionMarks(e,t);return 1===n.length&&n[0]?n[0]:null}(e,c[s]))!function(e,t){return function(n,r){var o=n.selection,i=o.$cursor,s=o.from,l=o.to,a=n.schema.marks[e.mark];if(i){var c=i.parent,d=i.index(),u=c.child(d).marks.find((function(e){return e.type===a})),h=c.childCount,p=i.pos-i.textOffset,f=c.child(d).nodeSize,m=void 0,g=void 0;for(m=d-1;m>=0&&u.isInSet(c.child(m).marks);)f+=g=c.child(m).nodeSize,p-=g,m-=1;for(m=d+1;m<h&&u.isInSet(c.child(m).marks);)f+=c.child(m).nodeSize,m+=1;t.removeMark(p,p+f,a),t.addMark(p,p+f,a.create(e.attrs)),r(t)}else t.doc.nodesBetween(s,l,(function(n,o){n.isInline&&a.isInSet(n.marks)&&(t.removeMark(o,o+n.nodeSize,a),t.addMark(o,o+n.nodeSize,a.create(e.attrs)),r(t))}))}}({mark:s,attrs:l},d)(e,h);else{var p=e;o.hasMark(e,{mark:s})&&(t.removeLink({mark:s,attrs:l},d)(e,h),p=i.EditorState.create({doc:d.doc,selection:d.selection})),u?o.toggleMark(c[s],l,d)(p,h):r.toggleInlineFormat({mark:s},d,l)(p,h)}return u&&a(d),u}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.insertText=void 0;t.insertText=function(e){return function(t,n){n(t.tr.insertText(e.text,e.from,e.to))}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.insertImage=void 0;var r=n(5);t.insertImage=function(e){return function(t,n){var o=t.schema.nodes.image,i=o.createAndFill(e);r.insertNode(i)(t,(function(t){return n(t.setMeta("commandName","insertImage").setMeta("args",e))}))}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isAligned=t.alignBlocks=void 0;var r=n(12);t.alignBlocks=function(e,t){return function(n,o){var i=r.blockNodes(n),s=n.tr;s.setMeta("commandName",t),i.forEach((function(t){if(t.type.isTextblock){var n=e.find((function(e){return e.node===t.type.name}));if(n){var o=r.addStyles(t,n.style);r.changeTextBlock(s,t,t.type,o)}}}));var l=s.docChanged;return l&&o(s.scrollIntoView()),l}};t.isAligned=function(e,t){var n=r.blockNodes(e),o=!1;return n.forEach((function(e){if(!o&&e.type.isTextblock&&e.attrs.style){var n=t.find((function(t){return t.node===e.type.name}));n&&(o=n.style.every((function(t){return!!t.value&&new RegExp(t.name+":\\s?"+t.value,"i").test(e.attrs.style)})))}})),o}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.cleanFormatting=void 0;var r=n(12),o=n(9);t.cleanFormatting=function(e){return void 0===e&&(e={blocksInSelection:!0}),function(t,n){var i=t.tr,s=e.blocksInSelection,l=e.blockNodeType,a=(e.exceptMarks||[t.schema.marks.link]).filter(Boolean);o.cleanMarks(i,{except:a}),r.cleanTextBlockFormatting(i,{blocksInSelection:s,blockNodeType:l});var c=i.docChanged;return c&&n&&n(i),c}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.outdent=t.indent=t.canBeIndented=t.canOutdentAsListItem=t.canIndentAsListItem=t.isIndented=t.indentBlocks=void 0;var r=n(15),o=n(18),i=n(12),s=n(5),l=n(20);t.indentBlocks=function(e,t,n){return function(r,o){var s=i.blockNodes(r),l=r.tr;l.setMeta("commandName",t),s.forEach((function(t){if(t.type.isTextblock){var r=void 0,o=e.find((function(e){return e.node===t.type.name}));if(o){var s="rtl"===n?o.rtlStyle:o.style,a={name:s,value:o.step>0?""+o.step+o.unit:""};if(t.attrs.style){var c=new RegExp(s+":\\s?(\\d+)"+o.unit,"i"),d=t.attrs.style.match(c);if(d){var u=parseFloat(d[1])+o.step;u=u<=0?"":u,a.value=""+u+(u?o.unit:"")}}r=i.addStyles(t,[a])}r&&i.changeTextBlock(l,t,t.type,r)}}));var a=l.docChanged;return a&&o(l.scrollIntoView()),a}};t.isIndented=function(e,t,n){var r=i.blockNodes(e),o=!1;return r.forEach((function(e){if(!o&&e.type.isTextblock&&e.attrs.style){var r=t.find((function(t){return t.node===e.type.name}));if(r){var i="rtl"===n?r.rtlStyle:r.style,s=new RegExp(i+":\\s?\\d+"+r.unit,"i");o=s.test(e.attrs.style)}}})),o};t.canIndentAsListItem=function(e,t){return r.sinkListItem(t)(e)};t.canOutdentAsListItem=function(e,t){var n=e.schema.nodes[t.listsTypes.listItem],o=e.schema.nodes[t.listsTypes.orderedList],i=e.schema.nodes[t.listsTypes.bulletList],l=!!s.findNthParentNodeOfType(o,2)(e.selection),a=!!s.findNthParentNodeOfType(i,2)(e.selection);return(l||a)&&r.liftListItem(n)(e)};t.canBeIndented=function(e,n){var r=e.schema.nodes,s=r[o.indentRules.listsTypes.listItem];return(t.isIndented(e,n.nodes)||o.indentRules.nodes.some((function(t){return r[t.node]&&i.hasNode(e,r[t.node])})))&&!i.hasNode(e,s)};t.indent=function(e,n){var i=e.schema.nodes[o.indentRules.listsTypes.listItem],s=t.canBeIndented(e,o.indentRules);t.canIndentAsListItem(e,i)?r.sinkListItem(i)(e,n):s&&t.indentBlocks(o.indentRules.nodes)(e,n)};t.outdent=function(e,n){var s=e.schema.nodes,a=s[o.outdentRules.listsTypes.listItem],c=t.canBeIndented(e,o.outdentRules);i.hasNode(e,s.blockquote)?l.liftBlockquote(e,n):t.canOutdentAsListItem(e,o.outdentRules)?r.liftListItem(a)(e,n):c&&t.indentBlocks(o.outdentRules.nodes)(e,n)}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.alignRemoveRules=t.alignJustifyRules=t.alignCenterRules=t.alignRightRules=t.alignLeftRules=void 0;var r=function(e,t){return{name:e,value:t}};t.alignLeftRules=[{node:"paragraph",style:[r("text-align","left")]},{node:"heading",style:[r("text-align","left")]},{node:"table_caption_external",style:[r("text-align","left")]}],t.alignRightRules=[{node:"paragraph",style:[r("text-align","right")]},{node:"heading",style:[r("text-align","right")]},{node:"table_caption_external",style:[r("text-align","right")]}],t.alignCenterRules=[{node:"paragraph",style:[r("text-align","center")]},{node:"heading",style:[r("text-align","center")]},{node:"table_caption_external",style:[r("text-align","center")]}],t.alignJustifyRules=[{node:"paragraph",style:[r("text-align","justify")]},{node:"heading",style:[r("text-align","justify")]},{node:"table_caption_external",style:[r("text-align","justify")]}],t.alignRemoveRules=[{node:"paragraph",style:[r("text-align","")]},{node:"heading",style:[r("text-align","")]},{node:"table_caption_external",style:[r("text-align","")]}]},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.buildListKeymap=t.buildKeymap=void 0;var r=n(4),o=n(13),i=n(25),s=n(22),l=n(21),a=n(23),c=n(14),d=n(5),u="undefined"!=typeof navigator&&/Mac/.test(navigator.platform);t.buildKeymap=function(e,t){var n={},l=t&&t.applyToWord||!1;if(n["Mod-z"]=i.undo,n["Shift-Mod-z"]=i.redo,n.Backspace=o.chainCommands(s.undoInputRule,o.deleteSelection,o.joinBackward,o.selectNodeBackward),n.Enter=o.chainCommands(o.newlineInCode,o.createParagraphNear,o.liftEmptyBlock,o.splitBlockKeepMarks),u||(n["Mod-y"]=i.redo),e.marks.strong&&(n["Mod-b"]=d.expandToWordWrap(c.toggleInlineFormat,r.__assign(r.__assign({},a.bold),{applyToWord:l}))),e.marks.em&&(n["Mod-i"]=d.expandToWordWrap(c.toggleInlineFormat,r.__assign(r.__assign({},a.italic),{applyToWord:l}))),e.marks.u&&(n["Mod-u"]=d.expandToWordWrap(c.toggleInlineFormat,r.__assign(r.__assign({},a.underline),{applyToWord:l}))),e.nodes.hard_break){var h=e.nodes.hard_break,p=o.chainCommands(o.exitCode,(function(e,t){return t(e.tr.replaceSelectionWith(h.create()).scrollIntoView()),!0}));n["Shift-Enter"]=p}return n};t.buildListKeymap=function(e){var t={};return e.nodes.list_item&&(t.Enter=l.splitListItemKeepMarks(e.nodes.list_item)),t}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.replaceImageSourcesFromRtf=t.pasteCleanup=t.sanitizeStyleAttr=t.sanitizeClassAttr=t.removeAttribute=t.removeTag=t.removeComments=t.sanitize=void 0;var r=n(24),o=n(8);t.sanitize=function(e){return e=(e=(e=(e=(e=(e=(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,"")).replace(/<style[^>]*?>\s*<\/style>/gi,"")).replace(/<\/?st1:.*?>/gi,"")).replace(/<a name="[a-zA-Z0-9_]+">/gim,"")).replace(/v:shapes?="[^"]+"/gi,"")).replace(/<!\[if !supportLists\]>/gi,"")).replace(/<!\[endif\]>/gi,"")};t.removeComments=function(e){return e.replace(/<!--[\s\S]+?-->/g,"")};t.removeTag=function(e,t){return e.replace(new RegExp("<\\/?("+t+")(?:\\s[^>]*?)?>","gi"),"")};t.removeAttribute=function(e){e.ownerElement&&e.ownerElement.removeAttribute(e.name)};t.sanitizeClassAttr=function(e){/^Mso/.test(e.value)&&t.removeAttribute(e)};var i=/\s*;\s*/,s=/\s*:\s*/;t.sanitizeStyleAttr=function(e){var n,r,o=e.value.split(i).filter((function(e){return Boolean(e)})),l=e.ownerElement.style,a="";o.forEach((function(e){var t;t=e.split(s),n=t[0],r=t[1],void 0!==l[n]&&(a+=n+": "+r+"; ")})),(a=a.trim())?e.value=a:t.removeAttribute(e)};function l(e){for(var t=e.length,n=new Array(t/2),r=0;r<t;r+=2)n[r]=String.fromCharCode(parseInt(e.substring(r,r+2),16));return btoa(n.join(""))}t.pasteCleanup=function(e,n){var i=e;if(n.convertMsLists&&(i=r.convertMsLists(i)),n.stripTags&&(i=t.removeTag(i,n.stripTags)),n.attributes){var s=o.htmlToFragment(i);Array.from(s.querySelectorAll("*")).forEach((function(e){return function(e,t){if(e.nodeType===Node.ELEMENT_NODE){for(var n=e.attributes.length-1;n>=0;n--){var r=e.attributes[n];t[r.name]?t[r.name](r):t["*"]&&t["*"](r)}"SPAN"===e.nodeName&&0===e.attributes.length&&function(e){var t=e.parentNode;if(t){for(;e.firstChild;)t.insertBefore(e.firstChild,e);t.removeChild(e)}}(e)}}(e,n.attributes)})),i=o.fragmentToHtml(s)}return i};var a=/<img\s[^>]*?src=(?:'|")file:\/[^'"]+(?:'|")[^>]*>/gi,c=/{\\pict[\s\S]+?\\bliptag-?\d+(\\blipupi-?\d+)?({\\\*\\blipuid\s?[\da-fA-F]+)?[\s}]*?/,d=new RegExp("(?:("+c.source+"))([\\da-fA-F\\s]+)\\}","g"),u=/[^\da-fA-F]/g,h=/file:\/[^'"]+\.(jpg|png|gif)/i,p=/\\(png|jpeg)blip\\/;t.replaceImageSourcesFromRtf=function(e,t){var n=e.match(a);if(!n||-1===t.types.indexOf("text/rtf"))return e;var r=t.getData("text/rtf"),o=[],i=r.match(d);if(!r||!i)return e;for(var s=0,f=i;s<f.length;s++){var m=f[s],g=p.exec(m);if(g){var y=m.replace(c,"").replace(u,"");o.push("data:image/"+g[1]+";base64,"+l(y))}}return n.length!==o.length?e:e.replace(a,(function(e){var t=o.shift()||"";return e.replace(h,t)}))}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.replaceAll=t.replace=t.findAll=t.find=t.findAt=void 0;var r=n(4),o=n(1);t.findAt=function(e,t,n,r,i){var a,c,d,u,h,p,f=[],m=[],g=t.matchCase,y=t.matchWord,v=t.useRegExp,b=t.text;if(v&&(/^\\$/.test(b)||/[^\\]\\$/.test(b))&&(b=b.substring(0,b.length-1)),!b)return f;var w=g?"g":"gi",S=v?new RegExp(b,w):l(b,w);return e.nodesBetween(n,r,(function(t,l,g){if(i(f))return!1;t.inlineContent&&l+t.content.size>=n&&(m.length=0,t.nodesBetween(0,t.content.size,(function(t,g,v,b){if(i(f))return!1;var w=1+l+g;if(t.isText&&w+t.nodeSize>=n){if(h=t.text||"",p=v.childCount-1>=b+1&&v.child(b+1),m.push(n<=w?{text:h,start:w}:{text:h.slice(n-w),start:n}),p&&p.isText)return;for(c=m.map((function(e){return e.text})).join(""),a=S.exec(c);null!==a&&(d=m[0].start+a.index,u=d+a[0].length,n<=d&&r>=u&&s(a,y)&&f.push(o.TextSelection.create(e,d,u)),!i(f));)a=S.exec(c)}else m.length=0})))})),f};t.find=function(e,n){var o=n.backward,i=n.matchCyclic,s=r.__rest(n,["backward","matchCyclic"]),l=o?function(){return!1}:function(e){return e.length>0},a=e.doc,c=e.selection,d=[];return o?!(d=t.findAt(a,s,0,c.from,l)).length&&i&&(d=t.findAt(a,s,c.from,a.content.size,l)):!(d=t.findAt(a,s,c.to,a.content.size,l)).length&&i&&(d=t.findAt(a,s,0,c.to,l)),d.length?d[d.length-1]:null};t.findAll=function(e,n){return t.findAt(e,n,0,e.content.size,(function(){return!1}))};t.replace=function(e,t,n){var r=e.from,i=e.to;return n.insertText(t,r,i).setSelection(o.TextSelection.create(n.doc,r,r+t.length)),n};t.replaceAll=function(e,n,r){var o=t.findAll(e.doc,r);if(0===o.length)return null;for(var i=e.tr,s=o.length-1;s>=0;s--)i.insertText(n,o[s].from,o[s].to);return i};var i=/^[\s0-9~`!@#$%\^&*\(\)_\-=+\\|\[\]{};:'"\?/.,<>]?$/,s=function(e,t){if(t){if(!0===t){var n=e.input,r=n.charAt(e.index-1),o=n.charAt(e.index+e[0].length);return i.test(r)&&i.test(o)}return t(e)}return!0},l=function(e,t){var n=e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d").replace(/\s/g,"\\s");return new RegExp(n,t)}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.placeholder=void 0;var r=n(1),o=n(3);t.placeholder=function(e){var t={class:"k-placeholder","data-placeholder":e};return new r.Plugin({key:new r.PluginKey("placeholder"),props:{decorations:function(e){var n=e.doc,r=n.content.firstChild;if(!(0===n.childCount||1===n.childCount&&r.inlineContent&&0===r.childCount))return o.DecorationSet.empty;var i=[];return n.descendants((function(e,n){i.push(o.Decoration.node(n,n+e.nodeSize,t))})),o.DecorationSet.create(n,i)}}})}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.spacesFix=void 0;var r=n(1),o=n(3),i=/\s+/g,s=/text-align/;t.spacesFix=function(){return new r.Plugin({key:new r.PluginKey("spaces-fix"),props:{decorations:function(e){var t,n,r,l,a=[],c=e.doc;return c.nodesBetween(0,c.content.size,(function(e,c,d){if(e.type.isText&&function(e){return s.test(e&&e.attrs&&e.attrs.style||"")}(d))for(n=i.exec(e.text||"");null!==n;){if(t=c+n.index,r=n[0].length,n.index+r<n.input.length)for(l=0;l<=r-1;l+=2)a.push(o.Decoration.inline(t+l,t+l+1,{style:"white-space: normal"}));n=i.exec(e.text||"")}})),o.DecorationSet.create(c,a)}}})}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.textHighlight=t.textHighlightKey=void 0;var r=n(1),o=n(3);t.textHighlightKey=new r.PluginKey("highlight"),t.textHighlight=function(e){return void 0===e&&(e=t.textHighlightKey),new r.Plugin({key:e,state:{init:function(){return null},apply:function(e){return e.getMeta(this.spec.key)}},props:{decorations:function(e){var t=(this.spec.key.getState(e)||[]).map((function(e){return o.Decoration.inline(e.from,e.to,e.attrs)}));return o.DecorationSet.create(e.doc,t)}}})}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.imageResizing=t.imageResizeKey=void 0;var r=n(4),o=n(1),i=n(3),s=n(6),l=n(5),a=n(17);t.imageResizeKey=new o.PluginKey("image-resize");var c=function(e,t,n){e.style[t]=n+"px"},d=/[^\-]width:|[^\-]height:/,u=/^.+$/,h=function(){function e(e,t,n,r){this.activeHandle=e,this.dragging=t,this.rect=n,this.nodePosition=r}return e.prototype.apply=function(n){var r=n.getMeta(t.imageResizeKey);return r?new e(r.activeHandle,r.setDragging,r.rect,r.nodePosition):this},e}(),p=function(e,n,i){var h=n.target.getAttribute(s.dataResizeDirImage);if(!h)return!1;var p=t.imageResizeKey.getState(e.state);n.preventDefault();var f=e.state.tr;function m(n){!function(e,n,r){var o=t.imageResizeKey.getState(e.state),i=o.rect,s=o.dragging,l=o.nodePosition,d=o.activeHandle;if(s&&i){var u=e.nodeDOM(l),h=a.directions[d],p=(n.clientX-s.startX)*h.x,f=(n.clientY-s.startY)*h.y,m=h.x?p+u.width:i.width,g=h.y?f+u.height:i.height;if(r.lockRatio&&h.x&&h.y){var y=Math.min(m/u.width,g/u.height),v=u.width*y,b=u.height*y;s.startX=n.clientX-(m-v)*h.x,s.startY=n.clientY-(g-b)*h.y,m=v,g=b}else s.startX=h.x?n.clientX:s.startX,s.startY=h.y?n.clientY:s.startY;c(u,"width",m),c(u,"height",g),i.top=u.offsetTop,i.left=u.offsetLeft,i.width=u.offsetWidth,i.height=u.offsetHeight;var w=u.nextElementSibling;w.style.width=i.width+"px",w.style.height=i.height+"px",w.style.top=i.top+"px",w.style.left=i.left+"px"}}(e,n,i)}return f.setMeta(t.imageResizeKey,{setDragging:{startX:n.clientX,startY:n.clientY},activeHandle:h,rect:p.rect,nodePosition:p.nodePosition}),f.setMeta("addToHistory",!1),e.dispatch(f),n.view.addEventListener("mouseup",(function n(i){i.view.removeEventListener("mouseup",n),i.view.removeEventListener("mousemove",m),function(e){var n=t.imageResizeKey.getState(e.state),i=n.rect,s=n.dragging,a=n.nodePosition;if(s&&i){var c=e.state.selection;if(c instanceof o.NodeSelection){var h=c.node.attrs,p=i.width,f=i.height,m=void 0;if(d.test(h.style||"")){var g=l.changeStylesString(h.style,{style:"width",value:u,newValue:p+"px"}),y=l.changeStylesString(g.style||"",{style:"height",value:u,newValue:f+"px"}).style;m=r.__assign(r.__assign({},h),{style:y})}else m=r.__assign(r.__assign({},h),{width:p,height:f});var v=c.node.type.createAndFill(m);if(v){var b=e.state.tr;b.replaceWith(a,a+1,v),b.setSelection(o.NodeSelection.create(b.doc,a)),b.setMeta("commandName","image-resize"),b.setMeta("args",m),b.setMeta(t.imageResizeKey,{setDragging:null,activeHandle:null,rect:i,nodePosition:a}),e.dispatch(b)}}}}(e)})),n.view.addEventListener("mousemove",m),!0};t.imageResizing=function(e){return void 0===e&&(e={node:"image",lockRatio:!0}),new o.Plugin({key:t.imageResizeKey,view:function(n){return{resize:function(){t.imageResizeKey.getState(n.state).rect&&n.dispatch(n.state.tr.setMeta("resize",!0))},get window(){return n.dom.ownerDocument&&n.dom.ownerDocument.defaultView},attachResize:function(){var e=this.window;e&&(e.removeEventListener("resize",this.resize),e.addEventListener("resize",this.resize))},removeResize:function(){var e=this.window;e&&e.removeEventListener("resize",this.resize)},update:function(n,r){var i=n.state,s=i.selection,l=i.schema.nodes[e.node],a=t.imageResizeKey.getState(i),c=a.rect;if(s instanceof o.NodeSelection&&l===s.node.type){var d=n.nodeDOM(s.from),u={top:d.offsetTop,left:d.offsetLeft,width:d.offsetWidth,height:d.offsetHeight};if(!r.selection.eq(s)||c&&(c.width!==u.width||c.height!==u.height||c.top!==u.top||c.left!==u.left)){var h=i.tr;h.setMeta(t.imageResizeKey,{rect:u,nodePosition:s.from}),n.dispatch(h),this.attachResize()}}else c&&(a.rect=null,a.nodePosition=-1)},destroy:function(){this.removeResize()}}},state:{init:function(){return new h("",null,null,-1)},apply:function(e,t){return t.apply(e)}},props:{handleDOMEvents:{mousedown:function(t,n){return p(t,n,e)}},decorations:function(n){var r=n.selection,l=n.schema.nodes[e.node],c=t.imageResizeKey.getState(n).rect;if(c&&r instanceof o.NodeSelection&&l===r.node.type){var d=document.createElement("div");d.className="k-editor-resize-handles-wrapper",d.style.width=c.width+"px",d.style.height=c.height+"px",d.style.top=c.top+"px",d.style.left=c.left+"px";for(var u=0;u<a.handles.length;u++){var h=document.createElement("div");h.className=s.resizeHandle+" "+a.handles[u],h.setAttribute(s.dataResizeDirImage,a.handles[u]),d.appendChild(h)}return i.DecorationSet.create(n.doc,[i.Decoration.widget(n.selection.from+1,d)])}return i.DecorationSet.empty}}})}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.caretColor=t.caretColorKey=void 0;var r=n(1),o=n(3),i=n(9);t.caretColorKey=new r.PluginKey("caret-color"),t.caretColor=function(){return new r.Plugin({key:t.caretColorKey,props:{decorations:function(e){var t=e.doc,n=e.selection,r=e.storedMarks;if(!n.empty||!r)return o.DecorationSet.empty;var s=i.styleValue((r||[]).find((function(e){return"style"===e.type.name})),{name:"color",value:/^.+$/});if(!s)return o.DecorationSet.empty;var l=n.$anchor.parent,a=[];return t.descendants((function(e,t){e.eq(l)&&a.push(o.Decoration.node(t,t+e.nodeSize,{style:"caret-color: "+s}))})),o.DecorationSet.create(t,a)}}})}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.tableRowResizeKey=t.tableColumnResizeKey=t.tableResizeKey=t.tableResizing=void 0;var r=n(43),o=n(45),i=n(46);t.tableResizing=function(){return[o.tableResizing(),r.columnResizing(),i.rowResizing()]};var s=n(10);Object.defineProperty(t,"tableResizeKey",{enumerable:!0,get:function(){return s.tableResizeKey}}),Object.defineProperty(t,"tableColumnResizeKey",{enumerable:!0,get:function(){return s.tableColumnResizeKey}}),Object.defineProperty(t,"tableRowResizeKey",{enumerable:!0,get:function(){return s.tableRowResizeKey}})},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.columnResizing=void 0;var r=n(4),o=n(1),i=n(7),s=n(3),l=n(6),a=n(44),c=n(10);t.columnResizing=function(){return new o.Plugin({key:c.tableColumnResizeKey,state:{init:function(e,t){return new d(-1,null)},apply:function(e,t){return t.apply(e)}},props:{attributes:function(e){return c.otherResizeHandle(c.tableColumnResizeKey,e)?null:c.tableColumnResizeKey.getState(e).activeHandle>-1?{class:"resize-cursor"}:null},handleDOMEvents:{mousemove:function(e,t){return c.otherResizing(c.tableColumnResizeKey,e.state)||function(e,t,n){var r=c.tableColumnResizeKey.getState(e.state);if(!r.dragging){var o=c.domCellAround(t.target),i=-1;if(o){var s=c.cellIndexes(o),l=o.getBoundingClientRect(),a=l.left,d=l.right;Math.abs(t.clientX-a)<=n&&s.cellIndex>0?(s.cellIndex-=o.colSpan,i=c.edgeCell(e,t,s)):d-t.clientX>0&&d-t.clientX<=n&&(i=c.edgeCell(e,t,s))}i!==r.activeHandle&&h(e,i)}}(e,t,5),!1},mouseleave:function(e){return function(e){var t=c.tableColumnResizeKey.getState(e.state);t.activeHandle>-1&&!t.dragging&&h(e,-1)}(e),!1},mousedown:function(e,t){return function(e,t,n){var o,s=c.tableColumnResizeKey.getState(e.state);if(-1===s.activeHandle||s.dragging)return!1;for(var a=e.state.doc.resolve(s.activeHandle),d=a.parent,h=a.index(),p=0,f=0;f<=h;f++)p+=d.child(f).attrs.colspan;var m,g,y=a.node(a.depth-1),v=e.domAtPos(s.activeHandle),b=v.node.childNodes[v.offset].closest("table");if(y.attrs[l.colgroupAttr]){var w=b.firstChild;(m=w.children[p-1]).style.width||(m.style.width=m.offsetWidth+"px")}else{var S=0;for(f=0;f<d.childCount;f++)S+=d.child(f).attrs.colspan;w=document.createElement("colgroup");var k=new Array(S);for(f=0;f<S;f++)k[f]=document.createElement("col"),w.appendChild(k[f]);b.insertBefore(w,b.firstChild),(m=k[h]).style.width=m.offsetWidth+"px",g=r.__assign(r.__assign({},y.attrs),((o={})[l.colgroupAttr]="<colgroup>"+k.reduce((function(e,t){return e+t.outerHTML}),"")+"</colgroup>",o))}var x=parseFloat(m.style.width),C=e.state.tr.setMeta(c.tableColumnResizeKey,{setDragging:{startX:t.clientX,startWidth:x}});if(!b.style.width){var M=Array.from(m.parentNode.children).map((function(e){return e.style.width}));if(M.every(Boolean)){var O=M.reduce((function(e,t){return e+parseFloat(t)}),0);g=c.setNodeStyle(g||y.attrs,"width",O+"px")}}if(g){var A=a.posAtIndex(0,a.depth-1)-1;C.setNodeMarkup(A,null,g)}function T(t){t.view.removeEventListener("mouseup",T),t.view.removeEventListener("mousemove",N);var o=c.tableColumnResizeKey.getState(e.state);if(o.dragging){var i=e.state.tr;!function(e,t,n,o){var i,s=e.state.doc.resolve(n),a=s.node(-1),d=s.start(-1),u=s.posAtIndex(0,s.depth-1)-1,h=e.nodeDOM(d).closest("table"),p=a.attrs;if(a&&p[l.colgroupAttr]){var f=h.firstChild;p=r.__assign(r.__assign({},p),((i={})[l.colgroupAttr]=f.outerHTML,i))}var m=h.style.width;h&&m&&c.parseStyle(p.style).width!==m&&(p=c.setNodeStyle(p,"width",m));t.setNodeMarkup(u,null,p)}(e,i,o.activeHandle,u(o.dragging,t,n)),e.dispatch(i.setMeta(c.tableColumnResizeKey,{setDragging:null}))}}function N(t){if(!t.which)return T(t);var r=c.tableColumnResizeKey.getState(e.state),o=u(r.dragging,t,n);!function(e,t,n,r){var o=e.state.doc.resolve(t),s=o.node(-1),l=o.start(-1),a=i.TableMap.get(s).colCount(o.pos-l)+o.nodeAfter.attrs.colspan-1,c=e.domAtPos(o.start(-1)).node;"TABLE"!==c.nodeName&&(c=c.closest("table"));var d=c,u=d.firstChild,h=Array.from(u.children);if(h[a].style.width=n+"px",d.style.width){var p=h.map((function(e){return e.style.width}));if(p.every(Boolean)){var f=p.reduce((function(e,t){return e+parseFloat(t)}),0);d.style.width=f+"px"}}}(e,r.activeHandle,o)}return e.dispatch(C),t.view.addEventListener("mouseup",T),t.view.addEventListener("mousemove",N),t.preventDefault(),!0}(e,t,25)}},decorations:function(e){if(!c.otherResizing(c.tableColumnResizeKey,e)){var t=c.tableColumnResizeKey.getState(e);if(t.activeHandle>-1)return function(e,t){for(var n=[],r=e.doc.resolve(t),o=r.node(-1),l=i.TableMap.get(o),a=r.start(-1),c=[],d=t-a,u=-1,h=0;h<l.height;h++)c.push(l.map.slice(h*l.width,h*l.width+l.width)),-1===u&&(u=c[h].lastIndexOf(d));var p=[];return c.forEach((function(e){var t=e[u];e[u]!==e[u+1]&&p.push(t)})),p.forEach((function(e){var t=a+e+o.nodeAt(e).nodeSize-1,r=document.createElement("div");r.className="column-resize-handle",n.push(s.Decoration.widget(t,r))})),s.DecorationSet.create(e.doc,n)}(e,t.activeHandle)}return s.DecorationSet.empty},nodeViews:{table_wrapper:function(e,t){return new a.TableWrapperView(e,t)},table:function(e,t){return new a.TableView(e,t)}}}})};var d=function(){function e(e,t){this.activeHandle=e,this.dragging=t}return e.prototype.apply=function(t){var n,r=this,o=t.getMeta(c.tableColumnResizeKey);if(o&&null!=o.setHandle)return new e(o.setHandle,null);if(o&&void 0!==o.setDragging)return new e(r.activeHandle,o.setDragging);if(r.activeHandle>-1&&t.docChanged){var i=t.mapping.map(r.activeHandle,-1);n=t.doc.resolve(i),Boolean("row"===n.parent.type.spec.tableRole&&n.nodeAfter)||(i=-1),r=new e(i,r.dragging)}return r},e}();function u(e,t,n){var r=t.clientX-e.startX;return Math.max(n,e.startWidth+r)}function h(e,t){var n=e.state.tr;n.setMeta("addToHistory",!1),n.setMeta(c.tableColumnResizeKey,{setHandle:t}),e.dispatch(n)}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TableWrapperView=t.TableView=void 0;var r=n(6),o=n(16),i=n(17),s=n(10),l=function(){function e(e,t){this.node=e,this.view=t,this.dom=document.createElement("div"),this.dom.className=r.resizableWrap,this.table=this.dom.appendChild(document.createElement("table")),e.attrs[r.colgroupAttr]&&this.renderColgroup(e.attrs[r.colgroupAttr]);var n=this.table.appendChild(document.createElement("tbody"));this.setAttributes(this.table,e.attrs),this.resizeHandles=i.handles.map((function(e){var t=document.createElement("span");return t.className=r.resizeHandle+" "+e,t.setAttribute(r.dataResizeDirTable,e),t})),this.contentDOM=n}return e.prototype.update=function(e){var t=this;if(e.type!==this.node.type)return!1;var n=this.node;return this.node=e,e.attrs[r.resizableAttr]?this.resizeHandles.forEach((function(e){t.dom.appendChild(e)})):Array.from(this.dom.children).filter((function(e){return e.classList.contains(r.resizeHandle)})).forEach((function(e){return e.remove()})),this.setAttributes(this.table,e.attrs),n.attrs[r.colgroupAttr]!==e.attrs[r.colgroupAttr]&&this.renderColgroup(e.attrs[r.colgroupAttr]),!0},e.prototype.ignoreMutation=function(e){return"attributes"===e.type&&(e.target===this.table||e.target.firstChild===this.table||this.colgroup&&this.colgroup.contains(e.target))},e.prototype.destroy=function(){this.node=void 0,this.view=void 0,this.table=void 0,this.colgroup=void 0,this.resizeHandles=void 0},e.prototype.renderColgroup=function(e){this.table&&this.table.firstChild&&"COLGROUP"===this.table.firstChild.nodeName&&this.table.removeChild(this.table.firstChild),e&&(this.colgroup=o.parseStrColgroup(e),this.table.insertBefore(this.colgroup,this.table.firstChild))},e.prototype.setAttributes=function(e,t){var n=[r.colgroupAttr,r.resizableAttr];for(var o in t)if(o&&-1===n.indexOf(o)){var i=e.getAttribute(o),s=t[o];s&&s!==i?e.setAttribute(o,s):s||e.removeAttribute(o)}/%$/.test(e.style.width)?(this.dom.style.width=e.style.width,e.style.width=""):this.dom.style.width=""},e}();t.TableView=l;var a=function(){function e(e,t){this.node=e,this.view=t,this.dom=document.createElement("div"),this.setAttributes(this.dom,e.attrs),this.contentDOM=this.dom}return e.prototype.update=function(e){return e.type===this.node.type&&(this.node=e,this.setAttributes(this.dom,e.attrs),!0)},e.prototype.ignoreMutation=function(e){return"attributes"===e.type&&"style"===e.attributeName},e.prototype.destroy=function(){this.node=void 0,this.view=void 0},e.prototype.setAttributes=function(e,t){for(var n in t)if(n){var r=e.getAttribute(n),o=t[n];o&&o!==r?e.setAttribute(n,o):o||e.removeAttribute(n)}if(e.setAttribute("table",""),/%/.test(e.style.width)){var i=this.node&&this.node.lastChild,l=(i?s.parseStyle(i.attrs.style):{}).width||"";l&&!/%/.test(l)&&(e.style.width="")}},e}();t.TableWrapperView=a},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.tableResizing=void 0;var r=n(4),o=n(1),i=n(6),s=n(10),l=n(17),a={southeast:!0,southwest:!0,northwest:!0,northeast:!0},c=r.__assign({east:!0,west:!0},a),d=r.__assign({south:!0,north:!0},a),u=function(){function e(e,t,n){this.activeHandle=e,this.dragging=t,this.nodePosition=n}return e.prototype.apply=function(t){var n=t.getMeta(s.tableResizeKey);return n?new e(n.activeHandle,n.setDragging,n.nodePosition):this},e}(),h=function(e){var t=Array.from(e.firstChild.children).map((function(e){return e.offsetWidth})),n=Array.from(e.rows).map((function(e){return e.offsetHeight})),r=t.reduce((function(e,t){return e+t}),0),o=n.reduce((function(e,t){return e+t}),0),i=e.offsetHeight;return{width:r,height:o,colsWidth:t,rowsHeight:n,offsetWidth:e.offsetWidth,offsetHeight:i}},p=function(e){var t=s.tableResizeKey.getState(e.state),n=t.dragging,o=t.nodePosition,l=t.activeHandle;if(n){var a=e.state.doc.nodeAt(o),u=s.getTable(e.nodeDOM(o)),p=h(u);if(a){var f=p.offsetWidth+"px",m=p.offsetHeight+"px",g=e.state.tr,y=a.attrs,v=s.parseStyle(y.style);if(c[l]&&u.style.width&&v.width!==f&&(y=s.setNodeStyle(y,"width",f)),d[l]&&u.style.height&&v.height!==m&&(y=s.setNodeStyle(y,"height",m)),y=function(e,t,n,o){var l=e.state.doc.nodeAt(n),a=s.getTable(e.nodeDOM(n)),c=(a.ownerDocument&&a.ownerDocument.defaultView||window).getComputedStyle,d=Array.from(a.rows);l.forEach((function(e,r,o){var i=s.parseStyle(e.attrs.style).height;i&&!/px$/.test(i)&&t.setNodeMarkup(n+r+1,null,s.setNodeStyle(e.attrs,"height",c(d[o]).height))}));var u=a.firstChild,h=Array.from(u&&u.children||[]),p=!1;h.forEach((function(e,t){e.style.width&&!/px$/.test(e.style.width)&&(e.style.width=c(h[t]).width,p=!0)}));var f=r.__assign({},o);return p&&(f[i.colgroupAttr]=u.outerHTML),f}(e,g,o,y),g.setNodeMarkup(o,null,y),g.setMeta("commandName","node-resize"),g.setMeta("args",y),g.setMeta(s.tableResizeKey,{setDragging:null,activeHandle:null,nodePosition:o}),!/%/.test(s.parseStyle(y.style).width||"")){var b=g.doc.resolve(o),w=s.parentNode(b,(function(e){return"table_wrapper"===e.type.name}));if(w&&/%/.test(s.parseStyle(w.node.attrs.style).width||"")){var S=s.setNodeStyle(w.node.attrs,"width",""),k=b.start(w.depth)-1;g.setNodeMarkup(k,null,S)}}e.dispatch(g)}}},f=function(e,t){var n=t.target.getAttribute(i.dataResizeDirTable);if(!n)return!1;var r=s.tableResizeKey.getState(e.state);t.preventDefault();var o=e.state.tr;o.setMeta(s.tableResizeKey,{setDragging:{startX:t.clientX,startY:t.clientY},activeHandle:n,nodePosition:r.nodePosition}),o.setMeta("addToHistory",!1),function(e,t,n){var r=e.state.doc.nodeAt(n),o=s.getTable(e.nodeDOM(n)),l=h(o),a=l.width,c=l.height,d=l.colsWidth,u=l.rowsHeight,p=l.offsetWidth,f=l.offsetHeight,m=o.firstChild,g=Array.from(m&&m.children||[]),y=!1;g.forEach((function(e,t){e.style.width&&!/%$/.test(e.style.width)&&(e.style.width=100*d[t]/a+"%",y=!0)}));var v=!1;r.forEach((function(e,r,o){var i=s.parseStyle(e.attrs.style).height;i&&!/%$/.test(i)&&(t.setNodeMarkup(n+r+1,null,s.setNodeStyle(e.attrs,"height",100*u[o]/c+"%")),v=!0)}));var b=r.attrs;s.parseStyle(b.style).width!==p+"px"&&(b=s.setNodeStyle(b,"width",p+"px")),y&&(b[i.colgroupAttr]=m.outerHTML),v&&(b=s.setNodeStyle(b,"height",f+"px")),(y||v)&&t.setNodeMarkup(n,null,b)}(e,o,r.nodePosition),e.dispatch(o);var a=t.view||window;function u(t){!function(e,t){var n,r=s.tableResizeKey.getState(e.state),o=r.dragging,i=r.nodePosition,a=r.activeHandle;if(!(i<0)&&o){var u=s.getTable(e.nodeDOM(i)),h=u.getBoundingClientRect(),p=l.directions[a],f=(t.clientX-o.startX)*p.x,m=(t.clientY-o.startY)*p.y,g=(u.ownerDocument&&u.ownerDocument.defaultView||window).getComputedStyle(u),y=/px/.test(g.width)?parseFloat(g.width):u.offsetWidth,v=/px/.test(g.height)?parseFloat(g.height):u.offsetHeight,b=p.x?f+y:h.width,w=p.y?m+v:h.height;if(o.startX=p.x?t.clientX:o.startX,o.startY=p.y?t.clientY:o.startY,c[a]&&(u.style.width=b+"px"),d[a]&&(u.style.height=w+"px"),/px/.test(u.style.width)){var S=null===(n=u.parentNode)||void 0===n?void 0:n.parentNode;S instanceof HTMLDivElement&&S.matches("div[table]")&&/%/.test(S.style.width)&&(S.style.width="")}}}(e,t)}return a.addEventListener("mouseup",(function t(n){a.removeEventListener("mouseup",t),a.removeEventListener("mousemove",u),p(e)})),a.addEventListener("mousemove",u),!0};t.tableResizing=function(e){return void 0===e&&(e={node:"table"}),new o.Plugin({key:s.tableResizeKey,view:function(t){return{selectedNode:function(e,t){var n=e.selection;if(n instanceof o.NodeSelection&&t===n.node.type&&n instanceof o.NodeSelection)return{node:n.node,pos:n.from};var r=s.parentNode(n.$from,(function(e){return e.type===t})),i=r&&r.node;return i?{node:i,pos:n.$from.start(r.depth)-1}:null},update:function(t,n){var o,l,a,c,d,u=t.state,h=u.schema.nodes[e.node],p=this.selectedNode(u,h),f=this.selectedNode(n,h);if((p||!f||n.doc.eq(t.state.doc))&&(p||f)){var m=u.tr;if(m.setMeta("addToHistory",!1),p&&f&&p.pos!==f.pos){m.setMeta(s.tableResizeKey,{nodePosition:p.pos});var g=m.doc.nodeAt(f.pos);g&&g.type.name===h.name&&m.setNodeMarkup(f.pos,h,r.__assign(r.__assign({},f.node.attrs),((o={})[i.resizableAttr]=!1,o))),m.setNodeMarkup(p.pos,h,r.__assign(r.__assign({},p.node.attrs),((l={})[i.resizableAttr]=!0,l))),t.dispatch(m)}else p&&f&&p.pos===f.pos&&!p.node.attrs[i.resizableAttr]&&!u.selection.eq(n.selection)?(m.setMeta(s.tableResizeKey,{nodePosition:p.pos}),t.dispatch(m.setNodeMarkup(p.pos,h,r.__assign(r.__assign({},p.node.attrs),((a={})[i.resizableAttr]=!0,a))))):p&&!f?(m.setMeta(s.tableResizeKey,{nodePosition:p.pos}),t.dispatch(m.setNodeMarkup(p.pos,h,r.__assign(r.__assign({},p.node.attrs),((c={})[i.resizableAttr]=!0,c))))):!p&&f&&(m.setMeta(s.tableResizeKey,{nodePosition:-1}),t.dispatch(m.setNodeMarkup(f.pos,h,r.__assign(r.__assign({},f.node.attrs),((d={})[i.resizableAttr]=!1,d)))))}}}},state:{init:function(){return new u("",null,-1)},apply:function(e,t){return t.apply(e)}},props:{handleDOMEvents:{mousedown:function(e,t){return f(e,t)}}}})}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.rowResizing=void 0;var r=n(1),o=n(7),i=n(3),s=n(10),l=function(){function e(){}return e.prototype.ignoreMutation=function(e){return"attributes"===e.type&&"style"===e.attributeName&&"TR"===e.target.nodeName},e}();t.rowResizing=function(){return new r.Plugin({key:s.tableRowResizeKey,state:{init:function(e,t){return this.spec.props.nodeViews[o.tableNodeTypes(t.schema).row.name]=function(e,t){return new l},new a(-1,null)},apply:function(e,t){return t.apply(e)}},props:{attributes:function(e){return s.otherResizeHandle(s.tableRowResizeKey,e)?null:s.tableRowResizeKey.getState(e).activeHandle>-1?{class:"resize-cursor-vertical"}:null},handleDOMEvents:{mousemove:function(e,t){return s.otherResizing(s.tableRowResizeKey,e.state)||function(e,t,n){var r=s.tableRowResizeKey.getState(e.state);if(!r.dragging){var o=s.domCellAround(t.target),i=-1;if(o){var l=s.cellIndexes(o),a=o.getBoundingClientRect(),d=a.top,u=a.bottom;Math.abs(t.clientY-d)<=n&&l.rowIndex>0?(l.rowIndex-=o.rowSpan,i=s.edgeCell(e,t,l)):u-t.clientY>0&&u-t.clientY<=n&&(i=s.edgeCell(e,t,l))}i!==r.activeHandle&&c(e,i)}}(e,t,5),!1},mouseleave:function(e){return function(e){var t=s.tableRowResizeKey.getState(e.state);t.activeHandle>-1&&!t.dragging&&c(e,-1)}(e),!1},mousedown:function(e,t){return function(e,t){var n=s.tableRowResizeKey.getState(e.state);if(-1===n.activeHandle||n.dragging)return!1;var r=e.state.doc.resolve(n.activeHandle),o=r.parent,i=r.node(-1),l=s.parseStyle(o.attrs.style).height,a=s.parseStyle(i.attrs.style).height,c=l?parseFloat(l):0;if(!l){var d=e.nodeDOM(n.activeHandle);c=d.offsetHeight}function u(t){t.view.removeEventListener("mouseup",u),t.view.removeEventListener("mousemove",h);var n=s.tableRowResizeKey.getState(e.state);if(n.dragging){var r=e.state.tr.setMeta(s.tableRowResizeKey,{setDragging:null});!function(e,t,n){var r=e.state.doc,o=r.resolve(n),i=o.parent,l=o.posAtIndex(0)-1,a=e.nodeDOM(l),c=a.ownerDocument&&a.ownerDocument.defaultView||window;a.style.height=c.getComputedStyle(a).height,t.setNodeMarkup(l,null,s.setNodeStyle(i.attrs,"height",a.style.height));var d=a&&a.closest("table"),u=d&&d.style.height;if(u){var h=r.resolve(l),p=h.start(h.depth)-1;t.setNodeMarkup(p,null,s.setNodeStyle(h.parent.attrs,"height",u))}}(e,r,n.activeHandle),e.dispatch(r)}}function h(t){if(!t.which)return u(t);var n=s.tableRowResizeKey.getState(e.state),r=function(e,t){var n=t.clientY-e.startY;return e.startHeight.rowHeight+n}(n.dragging,t),o=t.clientY-n.dragging.startY;!function(e,t,n,r,o){var i=e.nodeDOM(t),s=i&&i.parentNode;if(s){s.style.height=n+"px";var l=s.ownerDocument&&s.ownerDocument.defaultView||window;s.style.height=l.getComputedStyle(s).height;var a=s.closest("table"),c=parseFloat(o)+r+"px",d=a&&a.style.height;d&&d!==c&&(a.style.height=parseFloat(o)+r+"px",a.style.height=l.getComputedStyle(a).height)}}(e,n.activeHandle,r,o,a)}return e.dispatch(e.state.tr.setMeta(s.tableRowResizeKey,{setDragging:{startY:t.clientY,startHeight:{rowHeight:c,tableHeight:a}}})),t.view.addEventListener("mouseup",u),t.view.addEventListener("mousemove",h),t.preventDefault(),!0}(e,t)}},decorations:function(e){if(s.otherResizing(s.tableRowResizeKey,e))return i.DecorationSet.empty;var t=s.tableRowResizeKey.getState(e);return t.activeHandle>-1?function(e,t){var n=[];if("number"!=typeof t)return i.DecorationSet.empty;for(var r=e.doc.resolve(t),s=r.node(-1),l=o.TableMap.get(s),a=r.start(-1),c=[],d=t-a,u=-1,h=0;h<l.height;h++)c.push(l.map.slice(h*l.width,h*l.width+l.width)),-1!==c[h].indexOf(d)&&(u=h);var p=[];return c[u].forEach((function(e,t){c[u+1]&&e===c[u+1][t]||p.push(e)})),p.forEach((function(e){var t=s.nodeAt(e),r=a+e+(t?t.nodeSize:0)-1,o=document.createElement("div");o.className="row-resize-handle",n.push(i.Decoration.widget(r,o))})),i.DecorationSet.create(e.doc,n)}(e,t.activeHandle):void 0},nodeViews:{}}})};var a=function(){function e(e,t){this.activeHandle=e,this.dragging=t}return e.prototype.apply=function(t){var n,r=this,o=t.getMeta(s.tableRowResizeKey);if(o&&null!=o.setHandle)return new e(o.setHandle,null);if(o&&void 0!==o.setDragging)return new e(r.activeHandle,o.setDragging);if(r.activeHandle>-1){var i=t.mapping.map(r.activeHandle,-1);"row"===(n=t.doc.resolve(i)).parent.type.spec.tableRole&&n.nodeAfter||(i=null),r=new e(i,r.dragging)}return r},e}();function c(e,t){var n=e.state.tr;n.setMeta("addToHistory",!1),n.setMeta(s.tableRowResizeKey,{setHandle:t}),e.dispatch(n)}},function(e,t,n){"use strict";n.r(t),n.d(t,"dropCursor",(function(){return i}));var r=n(1),o=n(2);function i(e={}){return new r.Plugin({view:t=>new s(t,e)})}class s{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,r=t.nodeAfter;if(n||r){let t=this.editorView.nodeDOM(this.cursorPos-(n?n.nodeSize:0));if(t){let o=t.getBoundingClientRect(),i=n?o.bottom:o.top;n&&r&&(i=(i+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2),e={left:o.left,right:o.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 r,o,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)r=-pageXOffset,o=-pageYOffset;else{let e=i.getBoundingClientRect();r=e.left-i.scrollLeft,o=e.top-i.scrollTop}this.element.style.left=e.left-r+"px",this.element.style.top=e.top-o+"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),r=n&&n.type.spec.disableDropCursor,i="function"==typeof r?r(this.editorView,t,e):r;if(t&&!i){let e=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let t=Object(o.dropPoint)(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)}}},function(e,t,n){"use strict";n.r(t),n.d(t,"GapCursor",(function(){return l})),n.d(t,"gapCursor",(function(){return c}));var r=n(11),o=n(1),i=n(0),s=n(3);class l extends o.Selection{constructor(e){super(e,e)}map(e,t){let n=e.resolve(t.map(this.head));return l.valid(n)?new l(n):o.Selection.near(n)}content(){return i.Slice.empty}eq(e){return e instanceof l&&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 l(e.resolve(t.pos))}getBookmark(){return new a(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),r=e.node(t);if(0!=n)for(let e=r.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(r.type.spec.isolating)return!0}return!0}(e)||!function(e){for(let t=e.depth;t>=0;t--){let n=e.indexAfter(t),r=e.node(t);if(n!=r.childCount)for(let e=r.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(r.type.spec.isolating)return!0}return!0}(e))return!1;let n=t.type.spec.allowGapCursor;if(null!=n)return n;let r=t.contentMatchAt(e.index()).defaultType;return r&&r.isTextblock}static findGapCursorFrom(e,t,n=!1){e:for(;;){if(!n&&l.valid(e))return e;let r=e.pos,i=null;for(let n=e.depth;;n--){let o=e.node(n);if(t>0?e.indexAfter(n)<o.childCount:e.index(n)>0){i=o.child(t>0?e.indexAfter(n):e.index(n)-1);break}if(0==n)return null;r+=t;let s=e.doc.resolve(r);if(l.valid(s))return s}for(;;){let s=t>0?i.firstChild:i.lastChild;if(!s){if(i.isAtom&&!i.isText&&!o.NodeSelection.isSelectable(i)){e=e.doc.resolve(r+i.nodeSize*t),n=!1;continue e}break}i=s,r+=t;let a=e.doc.resolve(r);if(l.valid(a))return a}return null}}}l.prototype.visible=!1,l.findFrom=l.findGapCursorFrom,o.Selection.jsonID("gapcursor",l);class a{constructor(e){this.pos=e}map(e){return new a(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return l.valid(t)?new l(t):o.Selection.near(t)}}function c(){return new o.Plugin({props:{decorations:f,createSelectionBetween:(e,t,n)=>t.pos==n.pos&&l.valid(n)?new l(n):null,handleClick:h,handleKeyDown:d,handleDOMEvents:{beforeinput:p}}})}const d=Object(r.keydownHandler)({ArrowLeft:u("horiz",-1),ArrowRight:u("horiz",1),ArrowUp:u("vert",-1),ArrowDown:u("vert",1)});function u(e,t){const n="vert"==e?t>0?"down":"up":t>0?"right":"left";return function(e,r,i){let s=e.selection,a=t>0?s.$to:s.$from,c=s.empty;if(s instanceof o.TextSelection){if(!i.endOfTextblock(n)||0==a.depth)return!1;c=!1,a=e.doc.resolve(t>0?a.after():a.before())}let d=l.findGapCursorFrom(a,t,c);return!!d&&(r&&r(e.tr.setSelection(new l(d))),!0)}}function h(e,t,n){if(!e||!e.editable)return!1;let r=e.state.doc.resolve(t);if(!l.valid(r))return!1;let i=e.posAtCoords({left:n.clientX,top:n.clientY});return!(i&&i.inside>-1&&o.NodeSelection.isSelectable(e.state.doc.nodeAt(i.inside)))&&(e.dispatch(e.state.tr.setSelection(new l(r))),!0)}function p(e,t){if("insertCompositionText"!=t.inputType||!(e.state.selection instanceof l))return!1;let{$from:n}=e.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(e.state.schema.nodes.text);if(!r)return!1;let s=i.Fragment.empty;for(let e=r.length-1;e>=0;e--)s=i.Fragment.from(r[e].createAndFill(null,s));let a=e.state.tr.replace(n.pos,n.pos,new i.Slice(s,0,0));return a.setSelection(o.TextSelection.near(a.doc.resolve(n.pos+1))),e.dispatch(a),!1}function f(e){if(!(e.selection instanceof l))return null;let t=document.createElement("div");return t.className="ProseMirror-gapcursor",s.DecorationSet.create(e.doc,[s.Decoration.widget(e.selection.head,t,{key:"gapcursor"})])}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pmDeleteColumn=t.pmAddColumnAfter=t.pmAddColumnBefore=t.pmAddRowAfter=t.pmAddRowBefore=t.deleteColumn=t.addColumnAfter=t.addColumnBefore=t.addRowAfter=t.addRowBefore=t.createTable=void 0;var r=n(4),o=n(7);Object.defineProperty(t,"pmAddRowAfter",{enumerable:!0,get:function(){return o.addRowAfter}}),Object.defineProperty(t,"pmAddRowBefore",{enumerable:!0,get:function(){return o.addRowBefore}}),Object.defineProperty(t,"pmAddColumnBefore",{enumerable:!0,get:function(){return o.addColumnBefore}}),Object.defineProperty(t,"pmAddColumnAfter",{enumerable:!0,get:function(){return o.addColumnAfter}}),Object.defineProperty(t,"pmDeleteColumn",{enumerable:!0,get:function(){return o.deleteColumn}});var i=n(6),s=n(16);t.createTable=function(e,t,n){for(var r,o=e.table,i=e.table_row,s=e.table_cell,l=[],a=0;a<t+1;a++){r=[];for(var c=0;c<n+1;c++)r.push(s.createAndFill());l.push(i.createAndFill(void 0,r))}return o.createAndFill(void 0,l)};var l=/^table$/,a=/^table_row$/,c=/^table_cell|table_header$/,d=function(e,t){for(var n=e.$head,r=n.depth;r>0;r--){var o=n.node(r);if(t.test(o.type.name))return{pos:n.before(r),node:o}}return null};t.addRowBefore=function(e,t){var n=t&&function(e){var n,r=d(e.selection,a),o=d(e.selection,l);if(r&&o&&r.node.attrs[i.rowTypeAttr]){for(var s=0,c=0;c<o.node.nodeSize;c++)if(o.node.child(c).eq(r.node)){s=c;break}var u=o.node.child(s-1),h=r.pos-u.nodeSize;e.setNodeMarkup(h,void 0,((n={})[i.rowTypeAttr]=r.node.attrs[i.rowTypeAttr],n))}return t(e)};return o.addRowBefore(e,n)};t.addRowAfter=function(e,t){var n=t&&function(e){var n,r=d(e.selection,a);if(r&&r.node.attrs[i.rowTypeAttr]){var o=r.pos+r.node.nodeSize;e.setNodeMarkup(o,void 0,((n={})[i.rowTypeAttr]=r.node.attrs[i.rowTypeAttr],n))}return t(e)};return o.addRowAfter(e,n)};var u=function(e,t){if(!e)return-1;var n=o.TableMap.get(e.node),r=d(t,c),i=n.map.indexOf(r.pos-e.pos-1),s=-1;return-1!==i&&(s=i%n.width),s},h=function(e,t,n){var o,l=u(t,e.selection),a=s.parseStrColgroup(t.node.attrs[i.colgroupAttr]);a.insertBefore(a.ownerDocument.createElement("col"),a.children[l+n]),e.setNodeMarkup(t.pos,null,r.__assign(r.__assign({},t.node.attrs),((o={})[i.colgroupAttr]=a.outerHTML,o)))};t.addColumnBefore=function(e,t){var n=t&&function(e){var n=d(e.selection,l);return n.node.attrs[i.colgroupAttr]?(h(e,n,-1),t(e)):t(e)};return o.addColumnBefore(e,n)};t.addColumnAfter=function(e,t){var n=t&&function(e){var n=d(e.selection,l);return n.node.attrs[i.colgroupAttr]?(h(e,n,1),t(e)):t(e)};return o.addColumnAfter(e,n)};t.deleteColumn=function(e,t){var n=d(e.selection,l),a=n&&n.node.attrs[i.colgroupAttr],c=u(n,e.selection),h=t&&function(e){if(!a)return t(e);var o=e.doc.nodeAt(n.pos);return function(e,t,n){var o,l=s.parseStrColgroup(t.node.attrs[i.colgroupAttr]);l.removeChild(l.children[n]),e.setNodeMarkup(t.pos,null,r.__assign(r.__assign({},t.node.attrs),((o={})[i.colgroupAttr]=l.outerHTML,o)))}(e,{node:o,pos:n.pos},c),t(e)};return o.deleteColumn(e,h)}}])}));
1
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.KendoEditorCommon=t():e.KendoEditorCommon=t()}(window,(function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=26)}([function(e,t,n){"use strict";function r(e){this.content=e}n.r(t),n.d(t,"ContentMatch",(function(){return A})),n.d(t,"DOMParser",(function(){return W})),n.d(t,"DOMSerializer",(function(){return te})),n.d(t,"Fragment",(function(){return i})),n.d(t,"Mark",(function(){return c})),n.d(t,"MarkType",(function(){return V})),n.d(t,"Node",(function(){return M})),n.d(t,"NodeRange",(function(){return x})),n.d(t,"NodeType",(function(){return $})),n.d(t,"ReplaceError",(function(){return d})),n.d(t,"ResolvedPos",(function(){return b})),n.d(t,"Schema",(function(){return K})),n.d(t,"Slice",(function(){return u})),r.prototype={constructor:r,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,t,n){var o=n&&n!=e?this.remove(n):this,i=o.find(e),s=o.content.slice();return-1==i?s.push(n||e,t):(s[i+1]=t,n&&(s[i]=n)),new r(s)},remove:function(e){var t=this.find(e);if(-1==t)return this;var n=this.content.slice();return n.splice(t,2),new r(n)},addToStart:function(e,t){return new r([e,t].concat(this.remove(e).content))},addToEnd:function(e,t){var n=this.remove(e).content.slice();return n.push(e,t),new r(n)},addBefore:function(e,t,n){var o=this.remove(t),i=o.content.slice(),s=o.find(e);return i.splice(-1==s?i.length:s,0,t,n),new r(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=r.from(e)).size?new r(e.content.concat(this.subtract(e).content)):this},append:function(e){return(e=r.from(e)).size?new r(this.subtract(e).content.concat(e.content)):this},subtract:function(e){var t=this;e=r.from(e);for(var n=0;n<e.content.length;n+=2)t=t.remove(e.content[n]);return t},toObject:function(){var e={};return this.forEach((function(t,n){e[t]=n})),e},get size(){return this.content.length>>1}},r.from=function(e){if(e instanceof r)return e;var t=[];if(e)for(var n in e)t.push(n,e[n]);return new r(t)};var o=r;class i{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,r=0,o){for(let i=0,s=0;s<t;i++){let l=this.content[i],a=s+l.nodeSize;if(a>e&&!1!==n(l,r+s,o||null,i)&&l.content.size){let o=s+1;l.nodesBetween(Math.max(0,e-o),Math.min(l.content.size,t-o),n,r+o)}s=a}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,n,r){let o="",i=!0;return this.nodesBetween(e,t,(s,l)=>{s.isText?(o+=s.text.slice(Math.max(e,l)-l,t-l),i=!n):s.isLeaf?(r?o+="function"==typeof r?r(s):r:s.type.spec.leafText&&(o+=s.type.spec.leafText(s)),i=!n):!i&&s.isBlock&&(o+=n,i=!0)},0),o}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,n=e.firstChild,r=this.content.slice(),o=0;for(t.isText&&t.sameMarkup(n)&&(r[r.length-1]=t.withText(t.text+n.text),o=1);o<e.content.length;o++)r.push(e.content[o]);return new i(r,this.size+e.size)}cut(e,t=this.size){if(0==e&&t==this.size)return this;let n=[],r=0;if(t>e)for(let o=0,i=0;i<t;o++){let s=this.content[o],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),r+=s.nodeSize),i=l}return new i(n,r)}cutByIndex(e,t){return e==t?i.empty:0==e&&t==this.content.length?this:new i(this.content.slice(e,t))}replaceChild(e,t){let n=this.content[e];if(n==t)return this;let r=this.content.slice(),o=this.size+t.nodeSize-n.nodeSize;return r[e]=t,new i(r,o)}addToStart(e){return new i([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new i(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 r=this.content[t];e(r,n,t),n+=r.nodeSize}}findDiffStart(e,t=0){return function e(t,n,r){for(let o=0;;o++){if(o==t.childCount||o==n.childCount)return t.childCount==n.childCount?null:r;let i=t.child(o),s=n.child(o);if(i!=s){if(!i.sameMarkup(s))return r;if(i.isText&&i.text!=s.text){for(let e=0;i.text[e]==s.text[e];e++)r++;return r}if(i.content.size||s.content.size){let t=e(i.content,s.content,r+1);if(null!=t)return t}r+=i.nodeSize}else r+=i.nodeSize}}(this,e,t)}findDiffEnd(e,t=this.size,n=e.size){return function e(t,n,r,o){for(let i=t.childCount,s=n.childCount;;){if(0==i||0==s)return i==s?null:{a:r,b:o};let l=t.child(--i),a=n.child(--s),c=l.nodeSize;if(l!=a){if(!l.sameMarkup(a))return{a:r,b:o};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++,r--,o--;return{a:r,b:o}}if(l.content.size||a.content.size){let t=e(l.content,a.content,r-1,o-1);if(t)return t}r-=c,o-=c}else r-=c,o-=c}}(this,e,t,n)}findIndex(e,t=-1){if(0==e)return l(0,e);if(e==this.size)return l(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let n=0,r=0;;n++){let o=r+this.child(n).nodeSize;if(o>=e)return o==e||t>0?l(n+1,o):l(n,r);r=o}}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 i.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new i(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return i.empty;let t,n=0;for(let r=0;r<e.length;r++){let o=e[r];n+=o.nodeSize,r&&o.isText&&e[r-1].sameMarkup(o)?(t||(t=e.slice(0,r)),t[t.length-1]=o.withText(t[t.length-1].text+o.text)):t&&t.push(o)}return new i(t||e,n)}static from(e){if(!e)return i.empty;if(e instanceof i)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new i([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}i.empty=new i([],0);const s={index:0,offset:0};function l(e,t){return s.index=e,s.offset=t,s}function a(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(!a(e[n],t[n]))return!1}else{for(let n in e)if(!(n in t)||!a(e[n],t[n]))return!1;for(let n in t)if(!(n in e))return!1}return!0}class c{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,n=!1;for(let r=0;r<e.length;r++){let o=e[r];if(this.eq(o))return e;if(this.type.excludes(o.type))t||(t=e.slice(0,r));else{if(o.type.excludes(this.type))return e;!n&&o.type.rank>this.type.rank&&(t||(t=e.slice(0,r)),t.push(this),n=!0),t&&t.push(o)}}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&&a(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`);return n.create(t.attrs)}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 c.none;if(e instanceof c)return[e];let t=e.slice();return t.sort((e,t)=>e.type.rank-t.type.rank),t}}c.none=[];class d extends Error{}class u{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=function e(t,n,r,o){let{index:i,offset:s}=t.findIndex(n),l=t.maybeChild(i);if(s==n||l.isText)return o&&!o.canReplace(i,i,r)?null:t.cut(0,n).append(r).append(t.cut(n));let a=e(l.content,n-s-1,r);return a&&t.replaceChild(i,l.copy(a))}(this.content,e+this.openStart,t);return n&&new u(n,this.openStart,this.openEnd)}removeBetween(e,t){return new u(function e(t,n,r){let{index:o,offset:i}=t.findIndex(n),s=t.maybeChild(o),{index:l,offset:a}=t.findIndex(r);if(i==n||s.isText){if(a!=r&&!t.child(l).isText)throw new RangeError("Removing non-flat range");return t.cut(0,n).append(t.cut(r))}if(o!=l)throw new RangeError("Removing non-flat range");return t.replaceChild(o,s.copy(e(s.content,n-i-1,r-i-1)))}(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 u.empty;let n=t.openStart||0,r=t.openEnd||0;if("number"!=typeof n||"number"!=typeof r)throw new RangeError("Invalid input for Slice.fromJSON");return new u(i.fromJSON(e,t.content),n,r)}static maxOpen(e,t=!0){let n=0,r=0;for(let r=e.firstChild;r&&!r.isLeaf&&(t||!r.type.spec.isolating);r=r.firstChild)n++;for(let n=e.lastChild;n&&!n.isLeaf&&(t||!n.type.spec.isolating);n=n.lastChild)r++;return new u(e,n,r)}}function h(e,t,n){if(n.openStart>e.depth)throw new d("Inserted content deeper than insertion position");if(e.depth-n.openStart!=t.depth-n.openEnd)throw new d("Inconsistent open depths");return function e(t,n,r,o){let s=t.index(o),l=t.node(o);if(s==n.index(o)&&o<t.depth-r.openStart){let i=e(t,n,r,o+1);return l.copy(l.content.replaceChild(s,i))}if(r.content.size){if(r.openStart||r.openEnd||t.depth!=o||n.depth!=o){let{start:e,end:s}=function(e,t){let n=t.depth-e.openStart,r=t.node(n).copy(e.content);for(let e=n-1;e>=0;e--)r=t.node(e).copy(i.from(r));return{start:r.resolveNoCache(e.openStart+n),end:r.resolveNoCache(r.content.size-e.openEnd-n)}}(r,t);return y(l,function e(t,n,r,o,s){let l=t.depth>s&&f(t,n,s+1),a=o.depth>s&&f(r,o,s+1),c=[];g(null,t,s,c),l&&a&&n.index(s)==r.index(s)?(p(l,a),m(y(l,e(t,n,r,o,s+1)),c)):(l&&m(y(l,v(t,n,s+1)),c),g(n,r,s,c),a&&m(y(a,v(r,o,s+1)),c));return g(o,null,s,c),new i(c)}(t,e,s,n,o))}{let e=t.parent,o=e.content;return y(e,o.cut(0,t.parentOffset).append(r.content).append(o.cut(n.parentOffset)))}}return y(l,v(t,n,o))}(e,t,n,0)}function p(e,t){if(!t.type.compatibleContent(e.type))throw new d("Cannot join "+t.type.name+" onto "+e.type.name)}function f(e,t,n){let r=e.node(n);return p(r,t.node(n)),r}function m(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 g(e,t,n,r){let o=(t||e).node(n),i=0,s=t?t.index(n):o.childCount;e&&(i=e.index(n),e.depth>n?i++:e.textOffset&&(m(e.nodeAfter,r),i++));for(let e=i;e<s;e++)m(o.child(e),r);t&&t.depth==n&&t.textOffset&&m(t.nodeBefore,r)}function y(e,t){return e.type.checkContent(t),e.copy(t)}function v(e,t,n){let r=[];if(g(null,e,n,r),e.depth>n){m(y(f(e,t,n+1),v(e,t,n+1)),r)}return g(t,null,n,r),new i(r)}u.empty=new u(i.empty,0,0);class b{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],r=e.child(t);return n?e.child(t).cut(n):r}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],r=0==t?0:this.path[3*t-1]+1;for(let t=0;t<e;t++)r+=n.child(t).nodeSize;return r}marks(){let e=this.parent,t=this.index();if(0==e.content.size)return c.none;if(this.textOffset)return e.child(t).marks;let n=e.maybeChild(t-1),r=e.maybeChild(t);if(!n){let e=n;n=r,r=e}let o=n.marks;for(var i=0;i<o.length;i++)!1!==o[i].type.spec.inclusive||r&&o[i].isInSet(r.marks)||(o=o[i--].removeFromSet(o));return o}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let n=t.marks,r=e.parent.maybeChild(e.index());for(var o=0;o<n.length;o++)!1!==n[o].type.spec.inclusive||r&&n[o].isInSet(r.marks)||(n=n[o--].removeFromSet(n));return n}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 x(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=[],r=0,o=t;for(let t=e;;){let{index:e,offset:i}=t.content.findIndex(o),s=o-i;if(n.push(t,e,r+i),!s)break;if(t=t.child(e),t.isText)break;o=s-1,r+=i+1}return new b(t,n,o)}static resolveCached(e,t){for(let n=0;n<w.length;n++){let r=w[n];if(r.pos==t&&r.doc==e)return r}let n=w[S]=b.resolve(e,t);return S=(S+1)%k,n}}let w=[],S=0,k=12;class x{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 C=Object.create(null);class M{constructor(e,t,n,r=c.none){this.type=e,this.attrs=t,this.marks=r,this.content=n||i.empty}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,r=0){this.content.nodesBetween(e,t,n,r,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,r){return this.content.textBetween(e,t,n,r)}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&&a(this.attrs,t||e.defaultAttrs||C)&&c.sameSet(this.marks,n||c.none)}copy(e=null){return e==this.content?this:new M(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new M(this.type,this.attrs,this.content,e)}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 u.empty;let r=this.resolve(e),o=this.resolve(t),i=n?0:r.sharedDepth(t),s=r.start(i),l=r.node(i).content.cut(r.pos-s,o.pos-s);return new u(l,r.depth-i,o.depth-i)}replace(e,t,n){return h(this.resolve(e),this.resolve(t),n)}nodeAt(e){for(let t=this;;){let{index:n,offset:r}=t.content.findIndex(e);if(t=t.maybeChild(n),!t)return null;if(r==e||t.isText)return t;e-=r+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 r=this.content.child(t-1);return{node:r,index:t-1,offset:n-r.nodeSize}}resolve(e){return b.resolveCached(this,e)}resolveNoCache(e){return b.resolve(this,e)}rangeHasMark(e,t,n){let r=!1;return t>e&&this.nodesBetween(e,t,e=>(n.isInSet(e.marks)&&(r=!0),!r)),r}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()+")"),T(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=i.empty,r=0,o=n.childCount){let s=this.contentMatchAt(e).matchFragment(n,r,o),l=s&&s.matchFragment(this.content,t);if(!l||!l.validEnd)return!1;for(let e=r;e<o;e++)if(!this.type.allowsMarks(n.child(e).marks))return!1;return!0}canReplaceWith(e,t,n,r){if(r&&!this.type.allowsMarks(r))return!1;let o=this.contentMatchAt(e).matchType(n),i=o&&o.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);let e=c.none;for(let t=0;t<this.marks.length;t++)e=this.marks[t].addToSet(e);if(!c.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=null;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 r=i.fromJSON(e,t.content);return e.nodeType(t.type).create(t.attrs,r,n)}}M.prototype.text=void 0;class O extends M{constructor(e,t,n,r){if(super(e,t,null,r),!n)throw new RangeError("Empty text nodes are not allowed");this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):T(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 O(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new O(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 T(e,t){for(let n=e.length-1;n>=0;n--)t=e[n].type.name+"("+t+")";return t}class A{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let n=new N(e,t);if(null==n.next)return A.empty;let r=R(n);n.next&&n.err("Unexpected trailing text");let o=function(e){let t=Object.create(null);return function n(r){let o=[];r.forEach(t=>{e[t].forEach(({term:t,to:n})=>{if(!t)return;let r;for(let e=0;e<o.length;e++)o[e][0]==t&&(r=o[e][1]);I(e,n).forEach(e=>{r||o.push([t,r=[]]),-1==r.indexOf(e)&&r.push(e)})})});let i=t[r.join(",")]=new A(r.indexOf(e.length-1)>-1);for(let e=0;e<o.length;e++){let r=o[e][1].sort(z);i.next.push({type:o[e][0],next:t[r.join(",")]||n(r)})}return i}(I(e,0))}(function(e){let t=[[]];return o(function e(t,i){if("choice"==t.type)return t.exprs.reduce((t,n)=>t.concat(e(n,i)),[]);if("seq"!=t.type){if("star"==t.type){let s=n();return r(i,s),o(e(t.expr,s),s),[r(s)]}if("plus"==t.type){let s=n();return o(e(t.expr,i),s),o(e(t.expr,s),s),[r(s)]}if("opt"==t.type)return[r(i)].concat(e(t.expr,i));if("range"==t.type){let s=i;for(let r=0;r<t.min;r++){let r=n();o(e(t.expr,s),r),s=r}if(-1==t.max)o(e(t.expr,s),s);else for(let i=t.min;i<t.max;i++){let i=n();r(s,i),o(e(t.expr,s),i),s=i}return[r(s)]}if("name"==t.type)return[r(i,void 0,t.value)];throw new Error("Unknown expr type")}for(let r=0;;r++){let s=e(t.exprs[r],i);if(r==t.exprs.length-1)return s;o(s,i=n())}}(e,0),n()),t;function n(){return t.push([])-1}function r(e,n,r){let o={term:r,to:n};return t[e].push(o),o}function o(e,t){e.forEach(e=>e.to=t)}}(r));return function(e,t){for(let n=0,r=[e];n<r.length;n++){let e=r[n],o=!e.validEnd,i=[];for(let t=0;t<e.next.length;t++){let{type:n,next:s}=e.next[t];i.push(n.name),!o||n.isText||n.hasRequiredAttrs()||(o=!1),-1==r.indexOf(s)&&r.push(s)}o&&t.err("Only non-generatable nodes ("+i.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}(o,n),o}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 r=this;for(let o=t;r&&o<n;o++)r=r.matchType(e.child(o).type);return r}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 r=[this];return function o(s,l){let a=s.matchFragment(e,n);if(a&&(!t||a.validEnd))return i.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==r.indexOf(n)){r.push(n);let e=o(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 r=n.shift(),o=r.match;if(o.matchType(e)){let e=[];for(let t=r;t.type;t=t.via)e.push(t.type);return e.reverse()}for(let e=0;e<o.next.length;e++){let{type:i,next:s}=o.next[e];i.isLeaf||i.hasRequiredAttrs()||i.name in t||r.type&&!s.validEnd||(n.push({match:i.contentMatch,type:i,via:r}),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 r=0;r<n.next.length;r++)-1==e.indexOf(n.next[r].next)&&t(n.next[r].next)}(this),e.map((t,n)=>{let r=n+(t.validEnd?"*":" ")+" ";for(let n=0;n<t.next.length;n++)r+=(n?", ":"")+t.next[n].type.name+"->"+e.indexOf(t.next[n].next);return r}).join("\n")}}A.empty=new A(!0);class N{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 R(e){let t=[];do{t.push(D(e))}while(e.eat("|"));return 1==t.length?t[0]:{type:"choice",exprs:t}}function D(e){let t=[];do{t.push(_(e))}while(e.next&&")"!=e.next&&"|"!=e.next);return 1==t.length?t[0]:{type:"seq",exprs:t}}function _(e){let t=function(e){if(e.eat("(")){let t=R(e);return e.eat(")")||e.err("Missing closing paren"),t}if(!/\W/.test(e.next)){let t=function(e,t){let n=e.nodeTypes,r=n[t];if(r)return[r];let o=[];for(let e in n){let r=n[e];r.groups.indexOf(t)>-1&&o.push(r)}0==o.length&&e.err("No node type or group '"+t+"' found");return o}(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 E(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=E(e),r=n;return e.eat(",")&&(r="}"!=e.next?E(e):-1),e.eat("}")||e.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:t}}function z(e,t){return t-e}function I(e,t){let n=[];return function t(r){let o=e[r];if(1==o.length&&!o[0].term)return t(o[0].to);n.push(r);for(let e=0;e<o.length;e++){let{term:r,to:i}=o[e];r||-1!=n.indexOf(i)||t(i)}}(t),n.sort(z)}function F(e){let t=Object.create(null);for(let n in e){let r=e[n];if(!r.hasDefault)return null;t[n]=r.default}return t}function B(e,t){let n=Object.create(null);for(let r in e){let o=t&&t[r];if(void 0===o){let t=e[r];if(!t.hasDefault)throw new RangeError("No value supplied for attribute "+r);o=t.default}n[r]=o}return n}function j(e){let t=Object.create(null);if(e)for(let n in e)t[n]=new L(e[n]);return t}class ${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=j(n.attrs),this.defaultAttrs=F(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==A.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}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:B(this.attrs,e)}create(e=null,t,n){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new M(this,this.computeAttrs(e),i.from(t),c.setFrom(n))}createChecked(e=null,t,n){return t=i.from(t),this.checkContent(t),new M(this,this.computeAttrs(e),t,c.setFrom(n))}createAndFill(e=null,t,n){if(e=this.computeAttrs(e),(t=i.from(t)).size){let e=this.contentMatch.fillBefore(t);if(!e)return null;t=e.append(t)}let r=this.contentMatch.matchFragment(t),o=r&&r.fillBefore(i.empty,!0);return o?new M(this,e,t.append(o),c.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)}`)}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:c.none:e}static compile(e,t){let n=Object.create(null);e.forEach((e,r)=>n[e]=new $(e,t,r));let r=t.spec.topNode||"doc";if(!n[r])throw new RangeError("Schema is missing its top node type ('"+r+"')");if(!n.text)throw new RangeError("Every schema needs a 'text' type");for(let e in n.text.attrs)throw new RangeError("The text node type should not have attributes");return n}}class L{constructor(e){this.hasDefault=Object.prototype.hasOwnProperty.call(e,"default"),this.default=e.default}get isRequired(){return!this.hasDefault}}class V{constructor(e,t,n,r){this.name=e,this.rank=t,this.schema=n,this.spec=r,this.attrs=j(r.attrs),this.excluded=null;let o=F(this.attrs);this.instance=o?new c(this,o):null}create(e=null){return!e&&this.instance?this.instance:new c(this,B(this.attrs,e))}static compile(e,t){let n=Object.create(null),r=0;return e.forEach((e,o)=>n[e]=new V(e,r++,t,o)),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]}excludes(e){return this.excluded.indexOf(e)>-1}}class K{constructor(e){this.cached=Object.create(null);let t=this.spec={};for(let n in e)t[n]=e[n];t.nodes=o.from(e.nodes),t.marks=o.from(e.marks||{}),this.nodes=$.compile(this.spec.nodes,this),this.marks=V.compile(this.spec.marks,this);let n=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],r=t.spec.content||"",o=t.spec.marks;t.contentMatch=n[r]||(n[r]=A.parse(r,this.nodes)),t.inlineContent=t.contentMatch.inlineContent,t.markSet="_"==o?null:o?H(this,o.split(" ")):""!=o&&t.inlineContent?null:[]}for(let e in this.marks){let t=this.marks[e],n=t.spec.excludes;t.excluded=null==n?[t]:""==n?[]:H(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,r){if("string"==typeof e)e=this.nodeType(e);else{if(!(e instanceof $))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,r)}text(e,t){let n=this.nodes.text;return new O(n,n.defaultAttrs,e,c.setFrom(t))}mark(e,t){return"string"==typeof e&&(e=this.marks[e]),e.create(t)}nodeFromJSON(e){return M.fromJSON(this,e)}markFromJSON(e){return c.fromJSON(this,e)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}}function H(e,t){let n=[];for(let r=0;r<t.length;r++){let o=t[r],i=e.marks[o],s=i;if(i)n.push(i);else for(let t in e.marks){let r=e.marks[t];("_"==o||r.spec.group&&r.spec.group.split(" ").indexOf(o)>-1)&&n.push(s=r)}if(!s)throw new SyntaxError("Unknown mark type: '"+t[r]+"'")}return n}class W{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[],t.forEach(e=>{e.tag?this.tags.push(e):e.style&&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 Y(this,t,!1);return n.addAll(e,t.from,t.to),n.finish()}parseSlice(e,t={}){let n=new Y(this,t,!0);return n.addAll(e,t.from,t.to),u.maxOpen(n.finish())}matchTag(e,t,n){for(let r=n?this.tags.indexOf(n)+1:0;r<this.tags.length;r++){let n=this.tags[r];if(Q(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,r){for(let o=r?this.styles.indexOf(r)+1:0;o<this.styles.length;o++){let r=this.styles[o],i=r.style;if(!(0!=i.indexOf(e)||r.context&&!n.matchesContext(r.context)||i.length>e.length&&(61!=i.charCodeAt(e.length)||i.slice(e.length+1)!=t))){if(r.getAttrs){let e=r.getAttrs(t);if(!1===e)continue;r.attrs=e||void 0}return r}}}static schemaRules(e){let t=[];function n(e){let n=null==e.priority?50:e.priority,r=0;for(;r<t.length;r++){let e=t[r];if((null==e.priority?50:e.priority)<n)break}t.splice(r,0,e)}for(let t in e.marks){let r=e.marks[t].spec.parseDOM;r&&r.forEach(e=>{n(e=Z(e)),e.mark||e.ignore||e.clearMark||(e.mark=t)})}for(let t in e.nodes){let r=e.nodes[t].spec.parseDOM;r&&r.forEach(e=>{n(e=Z(e)),e.node||e.ignore||e.mark||(e.node=t)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new W(e,W.schemaRules(e)))}}const q={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},J={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},U={ol:!0,ul:!0};function X(e,t,n){return null!=t?(t?1:0)|("full"===t?2:0):e&&"pre"==e.whitespace?3:-5&n}class G{constructor(e,t,n,r,o,i,s){this.type=e,this.attrs=t,this.marks=n,this.pendingMarks=r,this.solid=o,this.options=s,this.content=[],this.activeMarks=c.none,this.stashMarks=[],this.match=i||(4&s?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(i.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=i.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(i.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}popFromStashMark(e){for(let t=this.stashMarks.length-1;t>=0;t--)if(e.eq(this.stashMarks[t]))return this.stashMarks.splice(t,1)[0]}applyPending(e){for(let t=0,n=this.pendingMarks;t<n.length;t++){let r=n[t];(this.type?this.type.allowsMarkType(r.type):ee(r.type,e))&&!r.isInSet(this.activeMarks)&&(this.activeMarks=r.addToSet(this.activeMarks),this.pendingMarks=r.removeFromSet(this.pendingMarks))}}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!q.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class Y{constructor(e,t,n){this.parser=e,this.options=t,this.isOpen=n,this.open=0;let r,o=t.topNode,i=X(null,t.preserveWhitespace,0)|(n?4:0);r=o?new G(o.type,o.attrs,c.none,c.none,!0,t.topMatch||o.type.contentMatch,i):new G(n?null:e.schema.topNodeType,null,c.none,c.none,!0,null,i),this.nodes=[r],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e){3==e.nodeType?this.addTextNode(e):1==e.nodeType&&this.addElement(e)}withStyleRules(e,t){let n=e.getAttribute("style");if(!n)return t();let r=this.readStyles(function(e){let t,n=/\s*([\w-]+)\s*:\s*([^;]+)/g,r=[];for(;t=n.exec(e);)r.push(t[1],t[2].trim());return r}(n));if(!r)return;let[o,i]=r,s=this.top;for(let e=0;e<i.length;e++)this.removePendingMark(i[e],s);for(let e=0;e<o.length;e++)this.addPendingMark(o[e]);t();for(let e=0;e<o.length;e++)this.removePendingMark(o[e],s);for(let e=0;e<i.length;e++)this.addPendingMark(i[e])}addTextNode(e){let t=e.nodeValue,n=this.top;if(2&n.options||n.inlineContext(e)||/[^ \t\r\n\u000c]/.test(t)){if(1&n.options)t=2&n.options?t.replace(/\r\n?/g,"\n"):t.replace(/\r?\n|\r/g," ");else if(t=t.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(t)&&this.open==this.nodes.length-1){let r=n.content[n.content.length-1],o=e.previousSibling;(!r||o&&"BR"==o.nodeName||r.isText&&/[ \t\r\n\u000c]$/.test(r.text))&&(t=t.slice(1))}t&&this.insertNode(this.parser.schema.text(t)),this.findInText(e)}else this.findInside(e)}addElement(e,t){let n,r=e.nodeName.toLowerCase();U.hasOwnProperty(r)&&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&&U.hasOwnProperty(e)&&n?(n.appendChild(t),t=n):"li"==e?n=t:e&&(n=null)}}(e);let o=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(n=this.parser.matchTag(e,this,t));if(o?o.ignore:J.hasOwnProperty(r))this.findInside(e),this.ignoreFallback(e);else if(!o||o.skip||o.closeParent){o&&o.closeParent?this.open=Math.max(0,this.open-1):o&&o.skip.nodeType&&(e=o.skip);let t,n=this.top,i=this.needsBlock;if(q.hasOwnProperty(r))n.content.length&&n.content[0].isInline&&this.open&&(this.open--,n=this.top),t=!0,n.type||(this.needsBlock=!0);else if(!e.firstChild)return void this.leafFallback(e);o&&o.skip?this.addAll(e):this.withStyleRules(e,()=>this.addAll(e)),t&&this.sync(n),this.needsBlock=i}else this.withStyleRules(e,()=>{this.addElementByRule(e,o,!1===o.consuming?n:void 0)})}leafFallback(e){"BR"==e.nodeName&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode("\n"))}ignoreFallback(e){"BR"!=e.nodeName||this.top.type&&this.top.type.inlineContent||this.findPlace(this.parser.schema.text("-"))}readStyles(e){let t=c.none,n=c.none;for(let r=0;r<e.length;r+=2)for(let o=void 0;;){let i=this.parser.matchStyle(e[r],e[r+1],this,o);if(!i)break;if(i.ignore)return null;if(i.clearMark?this.top.pendingMarks.concat(this.top.activeMarks).forEach(e=>{i.clearMark(e)&&(n=e.addToSet(n))}):t=this.parser.schema.marks[i.mark].create(i.attrs).addToSet(t),!1!==i.consuming)break;o=i}return[t,n]}addElementByRule(e,t,n){let r,o,i;if(t.node)o=this.parser.schema.nodes[t.node],o.isLeaf?this.insertNode(o.create(t.attrs))||this.leafFallback(e):r=this.enter(o,t.attrs||null,t.preserveWhitespace);else{i=this.parser.schema.marks[t.mark].create(t.attrs),this.addPendingMark(i)}let s=this.top;if(o&&o.isLeaf)this.findInside(e);else if(n)this.addElement(e,n);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(e=>this.insertNode(e));else{let n=e;"string"==typeof t.contentElement?n=e.querySelector(t.contentElement):"function"==typeof t.contentElement?n=t.contentElement(e):t.contentElement&&(n=t.contentElement),this.findAround(e,n,!0),this.addAll(n)}r&&this.sync(s)&&this.open--,i&&this.removePendingMark(i,s)}addAll(e,t,n){let r=t||0;for(let o=t?e.childNodes[t]:e.firstChild,i=null==n?null:e.childNodes[n];o!=i;o=o.nextSibling,++r)this.findAtPoint(e,r),this.addDOM(o);this.findAtPoint(e,r)}findPlace(e){let t,n;for(let r=this.open;r>=0;r--){let o=this.nodes[r],i=o.findWrapping(e);if(i&&(!t||t.length>i.length)&&(t=i,n=o,!i.length))break;if(o.solid)break}if(!t)return!1;this.sync(n);for(let e=0;e<t.length;e++)this.enterInner(t[e],null,!1);return!0}insertNode(e){if(e.isInline&&this.needsBlock&&!this.top.type){let e=this.textblockFromContext();e&&this.enterInner(e)}if(this.findPlace(e)){this.closeExtra();let t=this.top;t.applyPending(e.type),t.match&&(t.match=t.match.matchType(e.type));let n=t.activeMarks;for(let r=0;r<e.marks.length;r++)t.type&&!t.type.allowsMarkType(e.marks[r].type)||(n=e.marks[r].addToSet(n));return t.content.push(e.mark(n)),!0}return!1}enter(e,t,n){let r=this.findPlace(e.create(t));return r&&this.enterInner(e,t,!0,n),r}enterInner(e,t=null,n=!1,r){this.closeExtra();let o=this.top;o.applyPending(e),o.match=o.match&&o.match.matchType(e);let i=X(e,r,o.options);4&o.options&&0==o.content.length&&(i|=4),this.nodes.push(new G(e,t,o.activeMarks,o.pendingMarks,n,null,i)),this.open++}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;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 r=0;r<this.find.length;r++)if(null==this.find[r].pos&&1==e.nodeType&&e.contains(this.find[r].node)){t.compareDocumentPosition(this.find[r].node)&(n?2:4)&&(this.find[r].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,r=!(this.isOpen||n&&n.parent.type!=this.nodes[0].type),o=-(n?n.depth+1:0)+(r?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>=o;s--)if(i(e-1,s))return!0;return!1}{let e=s>0||0==s&&r?this.nodes[s].type:n&&s>=o?n.node(s-o).type:null;if(!e||e.name!=l&&-1==e.groups.indexOf(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}}addPendingMark(e){let t=function(e,t){for(let n=0;n<t.length;n++)if(e.eq(t[n]))return t[n]}(e,this.top.pendingMarks);t&&this.top.stashMarks.push(t),this.top.pendingMarks=e.addToSet(this.top.pendingMarks)}removePendingMark(e,t){for(let n=this.open;n>=0;n--){let r=this.nodes[n];if(r.pendingMarks.lastIndexOf(e)>-1)r.pendingMarks=e.removeFromSet(r.pendingMarks);else{r.activeMarks=e.removeFromSet(r.activeMarks);let t=r.popFromStashMark(e);t&&r.type&&r.type.allowsMarkType(t.type)&&(r.activeMarks=t.addToSet(r.activeMarks))}if(r==t)break}}}function Q(e,t){return(e.matches||e.msMatchesSelector||e.webkitMatchesSelector||e.mozMatchesSelector).call(e,t)}function Z(e){let t={};for(let n in e)t[n]=e[n];return t}function ee(e,t){let n=t.schema.nodes;for(let r in n){let o=n[r];if(!o.allowsMarkType(e))continue;let i=[],s=e=>{i.push(e);for(let n=0;n<e.edgeCount;n++){let{type:r,next:o}=e.edge(n);if(r==t)return!0;if(i.indexOf(o)<0&&s(o))return!0}};if(s(o.contentMatch))return!0}}class te{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},n){n||(n=re(t).createDocumentFragment());let r=n,o=[];return e.forEach(e=>{if(o.length||e.marks.length){let n=0,i=0;for(;n<o.length&&i<e.marks.length;){let t=e.marks[i];if(this.marks[t.type.name]){if(!t.eq(o[n][0])||!1===t.type.spec.spanning)break;n++,i++}else i++}for(;n<o.length;)r=o.pop()[1];for(;i<e.marks.length;){let n=e.marks[i++],s=this.serializeMark(n,e.isInline,t);s&&(o.push([n,r]),r.appendChild(s.dom),r=s.contentDOM||s.dom)}}r.appendChild(this.serializeNodeInner(e,t))}),n}serializeNodeInner(e,t){let{dom:n,contentDOM:r}=te.renderSpec(re(t),this.nodes[e.type.name](e));if(r){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,r)}return n}serializeNode(e,t={}){let n=this.serializeNodeInner(e,t);for(let r=e.marks.length-1;r>=0;r--){let o=this.serializeMark(e.marks[r],e.isInline,t);o&&((o.contentDOM||o.dom).appendChild(n),n=o.dom)}return n}serializeMark(e,t,n={}){let r=this.marks[e.type.name];return r&&te.renderSpec(re(n),r(e,t))}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 r,o=t[0],i=o.indexOf(" ");i>0&&(n=o.slice(0,i),o=o.slice(i+1));let s=n?e.createElementNS(n,o):e.createElement(o),l=t[1],a=1;if(l&&"object"==typeof l&&null==l.nodeType&&!Array.isArray(l)){a=2;for(let e in l)if(null!=l[e]){let t=e.indexOf(" ");t>0?s.setAttributeNS(e.slice(0,t),e.slice(t+1),l[e]):s.setAttribute(e,l[e])}}for(let o=a;o<t.length;o++){let i=t[o];if(0===i){if(o<t.length-1||o>a)throw new RangeError("Content hole must be the only child of its parent node");return{dom:s,contentDOM:s}}{let{dom:t,contentDOM:o}=te.renderSpec(e,i,n);if(s.appendChild(t),o){if(r)throw new RangeError("Multiple content holes");r=o}}}return{dom:s,contentDOM:r}}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new te(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=ne(e.nodes);return t.text||(t.text=e=>e.text),t}static marksFromSchema(e){return ne(e.marks)}}function ne(e){let t={};for(let n in e){let r=e[n].spec.toDOM;r&&(t[n]=r)}return t}function re(e){return e.document||window.document}},function(e,t,n){"use strict";n.r(t),n.d(t,"AllSelection",(function(){return f})),n.d(t,"EditorState",(function(){return x})),n.d(t,"NodeSelection",(function(){return h})),n.d(t,"Plugin",(function(){return C})),n.d(t,"PluginKey",(function(){return T})),n.d(t,"Selection",(function(){return s})),n.d(t,"SelectionRange",(function(){return l})),n.d(t,"TextSelection",(function(){return d})),n.d(t,"Transaction",(function(){return v}));var r=n(0),o=n(2);const i=Object.create(null);class s{constructor(e,t,n){this.$anchor=e,this.$head=t,this.ranges=n||[new l(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=r.Slice.empty){let n=t.content.lastChild,o=null;for(let e=0;e<t.openEnd;e++)o=n,n=n.lastChild;let i=e.steps.length,s=this.ranges;for(let l=0;l<s.length;l++){let{$from:a,$to:c}=s[l],d=e.mapping.slice(i);e.replaceRange(d.map(a.pos),d.map(c.pos),l?r.Slice.empty:t),0==l&&y(e,i,(n?n.isInline:o&&o.isTextblock)?-1:1)}}replaceWith(e,t){let n=e.steps.length,r=this.ranges;for(let o=0;o<r.length;o++){let{$from:i,$to:s}=r[o],l=e.mapping.slice(n),a=l.map(i.pos),c=l.map(s.pos);o?e.deleteRange(a,c):(e.replaceRangeWith(a,c,t),y(e,n,t.isInline?-1:1))}}static findFrom(e,t,n=!1){let r=e.parent.inlineContent?new d(e):g(e.node(0),e.parent,e.pos,e.index(),t,n);if(r)return r;for(let r=e.depth-1;r>=0;r--){let o=t<0?g(e.node(0),e.node(r),e.before(r+1),e.index(r),t,n):g(e.node(0),e.node(r),e.after(r+1),e.index(r)+1,t,n);if(o)return o}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new f(e.node(0))}static atStart(e){return g(e,e,0,0,1)||new f(e)}static atEnd(e){return g(e,e,e.content.size,e.childCount,-1)||new f(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let n=i[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 i)throw new RangeError("Duplicate use of selection JSON ID "+e);return i[e]=t,t.prototype.jsonID=e,t}getBookmark(){return d.between(this.$anchor,this.$head).getBookmark()}}s.prototype.visible=!0;class l{constructor(e,t){this.$from=e,this.$to=t}}let a=!1;function c(e){a||e.parent.inlineContent||(a=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+e.parent.type.name+")"))}class d extends s{constructor(e,t=e){c(e),c(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 s.near(n);let r=e.resolve(t.map(this.anchor));return new d(r.parent.inlineContent?r:n,n)}replace(e,t=r.Slice.empty){if(super.replace(e,t),t==r.Slice.empty){let t=this.$from.marksAcross(this.$to);t&&e.ensureMarks(t)}}eq(e){return e instanceof d&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new u(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 d(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,n=t){let r=e.resolve(t);return new this(r,n==t?r:e.resolve(n))}static between(e,t,n){let r=e.pos-t.pos;if(n&&!r||(n=r>=0?1:-1),!t.parent.inlineContent){let e=s.findFrom(t,n,!0)||s.findFrom(t,-n,!0);if(!e)return s.near(t,n);t=e.$head}return e.parent.inlineContent||(0==r||(e=(s.findFrom(e,-n,!0)||s.findFrom(e,n,!0)).$anchor).pos<t.pos!=r<0)&&(e=t),new d(e,t)}}s.jsonID("text",d);class u{constructor(e,t){this.anchor=e,this.head=t}map(e){return new u(e.map(this.anchor),e.map(this.head))}resolve(e){return d.between(e.resolve(this.anchor),e.resolve(this.head))}}class h extends s{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:r}=t.mapResult(this.anchor),o=e.resolve(r);return n?s.near(o):new h(o)}content(){return new r.Slice(r.Fragment.from(this.node),0,0)}eq(e){return e instanceof h&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new p(this.anchor)}static fromJSON(e,t){if("number"!=typeof t.anchor)throw new RangeError("Invalid input for NodeSelection.fromJSON");return new h(e.resolve(t.anchor))}static create(e,t){return new h(e.resolve(t))}static isSelectable(e){return!e.isText&&!1!==e.type.spec.selectable}}h.prototype.visible=!1,s.jsonID("node",h);class p{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:n}=e.mapResult(this.anchor);return t?new u(n,n):new p(n)}resolve(e){let t=e.resolve(this.anchor),n=t.nodeAfter;return n&&h.isSelectable(n)?new h(t):s.near(t)}}class f extends s{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=r.Slice.empty){if(t==r.Slice.empty){e.delete(0,e.doc.content.size);let t=s.atStart(e.doc);t.eq(e.selection)||e.setSelection(t)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new f(e)}map(e){return new f(e)}eq(e){return e instanceof f}getBookmark(){return m}}s.jsonID("all",f);const m={map(){return this},resolve:e=>new f(e)};function g(e,t,n,r,o,i=!1){if(t.inlineContent)return d.create(e,n);for(let s=r-(o>0?0:1);o>0?s<t.childCount:s>=0;s+=o){let r=t.child(s);if(r.isAtom){if(!i&&h.isSelectable(r))return h.create(e,n-(o<0?r.nodeSize:0))}else{let t=g(e,r,n+o,o<0?r.childCount:0,o,i);if(t)return t}n+=r.nodeSize*o}return null}function y(e,t,n){let r=e.steps.length-1;if(r<t)return;let i,l=e.steps[r];(l instanceof o.ReplaceStep||l instanceof o.ReplaceAroundStep)&&(e.mapping.maps[r].forEach((e,t,n,r)=>{null==i&&(i=r)}),e.setSelection(s.near(e.doc.resolve(i),n)))}class v extends o.Transform{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&(1|this.updated),this.storedMarks=null,this}get selectionSet(){return(1&this.updated)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=2,this}ensureMarks(e){return r.Mark.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)||r.Mark.none))),n.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,n){let r=this.doc.type.schema;if(null==t)return e?this.replaceSelectionWith(r.text(e),!0):this.deleteSelection();{if(null==n&&(n=t),n=null==n?t:n,!e)return this.deleteRange(t,n);let o=this.storedMarks;if(!o){let e=this.doc.resolve(t);o=n==t?e.marks():e.marksAcross(this.doc.resolve(n))}return this.replaceRangeWith(t,n,r.text(e,o)),this.selection.empty||this.setSelection(s.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 b(e,t){return t&&e?e.bind(t):e}class w{constructor(e,t,n){this.name=e,this.init=b(t.init,n),this.apply=b(t.apply,n)}}const S=[new w("doc",{init:e=>e.doc||e.schema.topNodeType.createAndFill(),apply:e=>e.doc}),new w("selection",{init:(e,t)=>e.selection||s.atStart(t.doc),apply:e=>e.selection}),new w("storedMarks",{init:e=>e.storedMarks||null,apply:(e,t,n,r)=>r.selection.$cursor?e.storedMarks:null}),new w("scrollToSelection",{init:()=>0,apply:(e,t)=>e.scrolledIntoView?t+1:t})];class k{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=S.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 w(e.key,e.spec.state,e))})}}class x{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),r=null;for(;;){let o=!1;for(let i=0;i<this.config.plugins.length;i++){let s=this.config.plugins[i];if(s.spec.appendTransaction){let l=r?r[i].n:0,a=r?r[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),!r){r=[];for(let e=0;e<this.config.plugins.length;e++)r.push(e<i?{state:n,n:t.length}:{state:this,n:0})}t.push(c),n=n.applyInner(c),o=!0}r&&(r[i]={state:n,n:t.length})}}if(!o)return{state:n,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let t=new x(this.config),n=this.config.fields;for(let r=0;r<n.length;r++){let o=n[r];t[o.name]=o.apply(e,this[o.name],this,t)}return t}get tr(){return new v(this)}static create(e){let t=new k(e.doc?e.doc.type.schema:e.schema,e.plugins),n=new x(t);for(let r=0;r<t.fields.length;r++)n[t.fields[r].name]=t.fields[r].init(e,n);return n}reconfigure(e){let t=new k(this.schema,e.plugins),n=t.fields,r=new x(t);for(let t=0;t<n.length;t++){let o=n[t].name;r[o]=this.hasOwnProperty(o)?this[o]:n[t].init(e,r)}return r}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 r=e[n],o=r.spec.state;o&&o.toJSON&&(t[n]=o.toJSON.call(r,this[r.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 k(e.schema,e.plugins),i=new x(o);return o.fields.forEach(o=>{if("doc"==o.name)i.doc=r.Node.fromJSON(e.schema,t.doc);else if("selection"==o.name)i.selection=s.fromJSON(i.doc,t.selection);else if("storedMarks"==o.name)t.storedMarks&&(i.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(n)for(let r in n){let s=n[r],l=s.spec.state;if(s.key==o.name&&l&&l.fromJSON&&Object.prototype.hasOwnProperty.call(t,r))return void(i[o.name]=l.fromJSON.call(s,e,t[r],i))}i[o.name]=o.init(e,i)}}),i}}class C{constructor(e){this.spec=e,this.props={},e.props&&function e(t,n,r){for(let o in t){let i=t[o];i instanceof Function?i=i.bind(n):"handleDOMEvents"==o&&(i=e(i,n,{})),r[o]=i}return r}(e.props,this,this.props),this.key=e.key?e.key.key:O("plugin")}getState(e){return e[this.key]}}const M=Object.create(null);function O(e){return e in M?e+"$"+ ++M[e]:(M[e]=0,e+"$")}class T{constructor(e="key"){this.key=O(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}},function(e,t,n){"use strict";n.r(t),n.d(t,"AddMarkStep",(function(){return p})),n.d(t,"AddNodeMarkStep",(function(){return m})),n.d(t,"AttrStep",(function(){return L})),n.d(t,"MapResult",(function(){return s})),n.d(t,"Mapping",(function(){return a})),n.d(t,"RemoveMarkStep",(function(){return f})),n.d(t,"RemoveNodeMarkStep",(function(){return g})),n.d(t,"ReplaceAroundStep",(function(){return v})),n.d(t,"ReplaceStep",(function(){return y})),n.d(t,"Step",(function(){return d})),n.d(t,"StepMap",(function(){return l})),n.d(t,"StepResult",(function(){return u})),n.d(t,"Transform",(function(){return K})),n.d(t,"TransformError",(function(){return V})),n.d(t,"canJoin",(function(){return M})),n.d(t,"canSplit",(function(){return C})),n.d(t,"dropPoint",(function(){return N})),n.d(t,"findWrapping",(function(){return k})),n.d(t,"insertPoint",(function(){return A})),n.d(t,"joinPoint",(function(){return T})),n.d(t,"liftTarget",(function(){return S})),n.d(t,"replaceStep",(function(){return R}));var r=n(0);const o=Math.pow(2,16);function i(e){return 65535&e}class s{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 l{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&l.empty)return l.empty}recover(e){let t=0,n=i(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))/o}(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 r=0,i=this.inverted?2:1,l=this.inverted?1:2;for(let a=0;a<this.ranges.length;a+=3){let c=this.ranges[a]-(this.inverted?r:0);if(c>e)break;let d=this.ranges[a+i],u=this.ranges[a+l],h=c+d;if(e<=h){let i=c+r+((d?e==c?-1:e==h?1:t:t)<0?0:u);if(n)return i;let l=e==(t<0?c:h)?null:a/3+(e-c)*o,p=e==c?2:e==h?1:4;return(t<0?e!=c:e!=h)&&(p|=8),new s(i,p,l)}r+=u-d}return n?e+r:new s(e+r,0,null)}touches(e,t){let n=0,r=i(t),o=this.inverted?2:1,s=this.inverted?1:2;for(let t=0;t<this.ranges.length;t+=3){let i=this.ranges[t]-(this.inverted?n:0);if(i>e)break;let l=this.ranges[t+o];if(e<=i+l&&t==3*r)return!0;n+=this.ranges[t+s]-l}return!1}forEach(e){let t=this.inverted?2:1,n=this.inverted?1:2;for(let r=0,o=0;r<this.ranges.length;r+=3){let i=this.ranges[r],s=i-(this.inverted?o:0),l=i+(this.inverted?0:o),a=this.ranges[r+t],c=this.ranges[r+n];e(s,s+a,l,l+c),o+=c-a}}invert(){return new l(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return 0==e?l.empty:new l(e<0?[0,-e,0]:[0,0,e])}}l.empty=new l([]);class a{constructor(e=[],t,n=0,r=e.length){this.maps=e,this.mirror=t,this.from=n,this.to=r}slice(e=0,t=this.maps.length){return new a(this.maps,this.mirror,e,t)}copy(){return new a(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 r=e.getMirror(t);this.appendMap(e.maps[t],null!=r&&r<t?n+r: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 r=e.getMirror(t);this.appendMap(e.maps[t].invert(),null!=r&&r>t?n-r-1:void 0)}}invert(){let e=new a;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 r=0;for(let n=this.from;n<this.to;n++){let o=this.maps[n].mapResult(e,t);if(null!=o.recover){let t=this.getMirror(n);if(null!=t&&t>n&&t<this.to){n=t,e=this.maps[t].recover(o.recover);continue}}r|=o.delInfo,e=o.pos}return n?e:new s(e,r,null)}}const c=Object.create(null);class d{getMap(){return l.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let n=c[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 c)throw new RangeError("Duplicate use of step JSON ID "+e);return c[e]=t,t.prototype.jsonID=e,t}}class u{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new u(e,null)}static fail(e){return new u(null,e)}static fromReplace(e,t,n,o){try{return u.ok(e.replace(t,n,o))}catch(e){if(e instanceof r.ReplaceError)return u.fail(e.message);throw e}}}function h(e,t,n){let o=[];for(let r=0;r<e.childCount;r++){let i=e.child(r);i.content.size&&(i=i.copy(h(i.content,t,i))),i.isInline&&(i=t(i,n,r)),o.push(i)}return r.Fragment.fromArray(o)}class p extends d{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)),i=new r.Slice(h(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 u.fromReplace(e,this.from,this.to,i)}invert(){return new f(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 p(t.pos,n.pos,this.mark)}merge(e){return e instanceof p&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new p(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 p(t.from,t.to,e.markFromJSON(t.mark))}}d.jsonID("addMark",p);class f extends d{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 r.Slice(h(t.content,e=>e.mark(this.mark.removeFromSet(e.marks)),e),t.openStart,t.openEnd);return u.fromReplace(e,this.from,this.to,n)}invert(){return new p(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 f(t.pos,n.pos,this.mark)}merge(e){return e instanceof f&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new f(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 f(t.from,t.to,e.markFromJSON(t.mark))}}d.jsonID("removeMark",f);class m extends d{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return u.fail("No node at mark step's position");let n=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return u.fromReplace(e,this.pos,this.pos+1,new r.Slice(r.Fragment.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 m(this.pos,t.marks[n]);return new m(this.pos,this.mark)}}return new g(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new m(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 m(t.pos,e.markFromJSON(t.mark))}}d.jsonID("addNodeMark",m);class g extends d{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return u.fail("No node at mark step's position");let n=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return u.fromReplace(e,this.pos,this.pos+1,new r.Slice(r.Fragment.from(n),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return t&&this.mark.isInSet(t.marks)?new m(this.pos,this.mark):this}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new g(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 g(t.pos,e.markFromJSON(t.mark))}}d.jsonID("removeNodeMark",g);class y extends d{constructor(e,t,n,r=!1){super(),this.from=e,this.to=t,this.slice=n,this.structure=r}apply(e){return this.structure&&b(e,this.from,this.to)?u.fail("Structure replace would overwrite content"):u.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new l([this.from,this.to-this.from,this.slice.size])}invert(e){return new y(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 y(t.pos,Math.max(t.pos,n.pos),this.slice)}merge(e){if(!(e instanceof y)||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?r.Slice.empty:new r.Slice(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new y(e.from,this.to,t,this.structure)}}{let t=this.slice.size+e.slice.size==0?r.Slice.empty:new r.Slice(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new y(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 y(t.from,t.to,r.Slice.fromJSON(e,t.slice),!!t.structure)}}d.jsonID("replace",y);class v extends d{constructor(e,t,n,r,o,i,s=!1){super(),this.from=e,this.to=t,this.gapFrom=n,this.gapTo=r,this.slice=o,this.insert=i,this.structure=s}apply(e){if(this.structure&&(b(e,this.from,this.gapFrom)||b(e,this.gapTo,this.to)))return u.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return u.fail("Gap is not a flat range");let n=this.slice.insertAt(this.insert,t.content);return n?u.fromReplace(e,this.from,this.to,n):u.fail("Content does not fit in gap")}getMap(){return new l([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 v(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),r=e.map(this.gapFrom,-1),o=e.map(this.gapTo,1);return t.deletedAcross&&n.deletedAcross||r<t.pos||o>n.pos?null:new v(t.pos,n.pos,r,o,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 v(t.from,t.to,t.gapFrom,t.gapTo,r.Slice.fromJSON(e,t.slice),t.insert,!!t.structure)}}function b(e,t,n){let r=e.resolve(t),o=n-t,i=r.depth;for(;o>0&&i>0&&r.indexAfter(i)==r.node(i).childCount;)i--,o--;if(o>0){let e=r.node(i).maybeChild(r.indexAfter(i));for(;o>0;){if(!e||e.isLeaf)return!0;e=e.firstChild,o--}}return!1}function w(e,t,n){return(0==t||e.canReplace(t,e.childCount))&&(n==e.childCount||e.canReplace(0,n))}function S(e){let t=e.parent.content.cutByIndex(e.startIndex,e.endIndex);for(let n=e.depth;;--n){let r=e.$from.node(n),o=e.$from.index(n),i=e.$to.indexAfter(n);if(n<e.depth&&r.canReplace(o,i,t))return n;if(0==n||r.type.spec.isolating||!w(r,o,i))break}return null}function k(e,t,n=null,r=e){let o=function(e,t){let{parent:n,startIndex:r,endIndex:o}=e,i=n.contentMatchAt(r).findWrapping(t);if(!i)return null;let s=i.length?i[0]:t;return n.canReplaceWith(r,o,s)?i:null}(e,t),i=o&&function(e,t){let{parent:n,startIndex:r,endIndex:o}=e,i=n.child(r),s=t.contentMatch.findWrapping(i.type);if(!s)return null;let l=(s.length?s[s.length-1]:t).contentMatch;for(let e=r;l&&e<o;e++)l=l.matchType(n.child(e).type);return l&&l.validEnd?s:null}(r,t);return i?o.map(x).concat({type:t,attrs:n}).concat(i.map(x)):null}function x(e){return{type:e,attrs:null}}function C(e,t,n=1,r){let o=e.resolve(t),i=o.depth-n,s=r&&r[r.length-1]||o.parent;if(i<0||o.parent.type.spec.isolating||!o.parent.canReplace(o.index(),o.parent.childCount)||!s.type.validContent(o.parent.content.cutByIndex(o.index(),o.parent.childCount)))return!1;for(let e=o.depth-1,t=n-2;e>i;e--,t--){let n=o.node(e),i=o.index(e);if(n.type.spec.isolating)return!1;let s=n.content.cutByIndex(i,n.childCount),l=r&&r[t+1];l&&(s=s.replaceChild(0,l.type.create(l.attrs)));let a=r&&r[t]||n;if(!n.canReplace(i+1,n.childCount)||!a.type.validContent(s))return!1}let l=o.indexAfter(i),a=r&&r[0];return o.node(i).canReplaceWith(l,l,a?a.type:o.node(i+1).type)}function M(e,t){let n=e.resolve(t),r=n.index();return O(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function O(e,t){return!(!e||!t||e.isLeaf||!e.canAppend(t))}function T(e,t,n=-1){let r=e.resolve(t);for(let e=r.depth;;e--){let o,i,s=r.index(e);if(e==r.depth?(o=r.nodeBefore,i=r.nodeAfter):n>0?(o=r.node(e+1),s++,i=r.node(e).maybeChild(s)):(o=r.node(e).maybeChild(s-1),i=r.node(e+1)),o&&!o.isTextblock&&O(o,i)&&r.node(e).canReplace(s,s+1))return t;if(0==e)break;t=n<0?r.before(e):r.after(e)}}function A(e,t,n){let r=e.resolve(t);if(r.parent.canReplaceWith(r.index(),r.index(),n))return t;if(0==r.parentOffset)for(let e=r.depth-1;e>=0;e--){let t=r.index(e);if(r.node(e).canReplaceWith(t,t,n))return r.before(e+1);if(t>0)return null}if(r.parentOffset==r.parent.content.size)for(let e=r.depth-1;e>=0;e--){let t=r.indexAfter(e);if(r.node(e).canReplaceWith(t,t,n))return r.after(e+1);if(t<r.node(e).childCount)return null}return null}function N(e,t,n){let r=e.resolve(t);if(!n.content.size)return t;let o=n.content;for(let e=0;e<n.openStart;e++)o=o.firstChild.content;for(let e=1;e<=(0==n.openStart&&n.size?2:1);e++)for(let t=r.depth;t>=0;t--){let n=t==r.depth?0:r.pos<=(r.start(t+1)+r.end(t+1))/2?-1:1,i=r.index(t)+(n>0?1:0),s=r.node(t),l=!1;if(1==e)l=s.canReplace(i,i,o);else{let e=s.contentMatchAt(i).findWrapping(o.firstChild.type);l=e&&s.canReplaceWith(i,i,e[0])}if(l)return 0==n?r.pos:n<0?r.before(t+1):r.after(t+1)}return null}function R(e,t,n=t,o=r.Slice.empty){if(t==n&&!o.size)return null;let i=e.resolve(t),s=e.resolve(n);return D(i,s,o)?new y(t,n,o):new _(i,s,o).fit()}function D(e,t,n){return!n.openStart&&!n.openEnd&&e.start()==t.start()&&e.parent.canReplace(e.index(),t.index(),n.content)}d.jsonID("replaceAround",v);class _{constructor(e,t,n){this.$from=e,this.$to=t,this.unplaced=n,this.frontier=[],this.placed=r.Fragment.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.Fragment.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 i=this.placed,s=n.depth,l=o.depth;for(;s&&l&&1==i.childCount;)i=i.firstChild.content,s--,l--;let a=new r.Slice(i,s,l);return e>-1?new v(n.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||n.pos!=this.$to.pos?new y(n.pos,o.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,n=0,r=this.unplaced.openEnd;n<e;n++){let o=t.firstChild;if(t.childCount>1&&(r=0),o.type.spec.isolating&&r<=n){e=n;break}t=o.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=z(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.Fragment.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=z(e,t);return!(!o.childCount||o.firstChild.isLeaf)&&(this.unplaced=new r.Slice(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=z(e,t);if(o.childCount<=1&&t>0){let i=e.size-t<=t+o.size;this.unplaced=new r.Slice(E(e,t-1,1),t-1,i?t-1:n)}else this.unplaced=new r.Slice(E(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,d=[],{match:u,type:h}=this.frontier[t];if(o){for(let e=0;e<o.childCount;e++)d.push(o.child(e));u=u.matchFragment(o)}let p=l.size+e-(s.content.size-s.openEnd);for(;c<l.childCount;){let e=l.child(c),t=u.matchType(e.type);if(!t)break;c++,(c>1||0==a||e.content.size)&&(u=t,d.push(I(e.mark(h.allowedMarks(e.marks)),1==c?a:0,c==l.childCount?p:-1)))}let f=c==l.childCount;f||(p=-1),this.placed=P(this.placed,t,r.Fragment.from(d)),this.frontier[t].match=u,f&&p<0&&n&&n.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let e=0,t=l;e<p;e++){let e=t.lastChild;this.frontier.push({type:e.type,match:e.contentMatchAt(e.childCount)}),t=e.content}this.unplaced=f?0==e?r.Slice.empty:new r.Slice(E(s.content,e-1,1),e-1,p<0?s.openEnd:e-1):new r.Slice(E(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||!F(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,r=this.$to.after(n);for(;n>1&&r==this.$to.end(--n);)++r;return r}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:n,type:r}=this.frontier[t],o=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),i=F(e,t,r,n,o);if(i){for(let n=t-1;n>=0;n--){let{match:t,type:r}=this.frontier[n],o=F(e,n,r,t,!0);if(!o||o.childCount)continue e}return{depth:t,fit:i,move:o?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=P(this.placed,t.depth,t.fit)),e=t.move;for(let n=t.depth+1;n<=e.depth;n++){let t=e.node(n),r=t.type.contentMatch.fillBefore(t.content,!0,e.index(n));this.openFrontierNode(t.type,t.attrs,r)}return e}openFrontierNode(e,t=null,n){let o=this.frontier[this.depth];o.match=o.match.matchType(e),this.placed=P(this.placed,this.depth,r.Fragment.from(e.create(t,n))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let e=this.frontier.pop().match.fillBefore(r.Fragment.empty,!0);e.childCount&&(this.placed=P(this.placed,this.frontier.length,e))}}function E(e,t,n){return 0==t?e.cutByIndex(n,e.childCount):e.replaceChild(0,e.firstChild.copy(E(e.firstChild.content,t-1,n)))}function P(e,t,n){return 0==t?e.append(n):e.replaceChild(e.childCount-1,e.lastChild.copy(P(e.lastChild.content,t-1,n)))}function z(e,t){for(let n=0;n<t;n++)e=e.firstChild.content;return e}function I(e,t,n){if(t<=0)return e;let o=e.content;return t>1&&(o=o.replaceChild(0,I(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.Fragment.empty,!0)))),e.copy(o)}function F(e,t,n,r,o){let i=e.node(t),s=o?e.indexAfter(t):e.index(t);if(s==i.childCount&&!n.compatibleContent(i.type))return null;let l=r.fillBefore(i.content,!0,s);return l&&!function(e,t,n){for(let r=n;r<t.childCount;r++)if(!e.allowsMarks(t.child(r).marks))return!0;return!1}(n,i.content,s)?l:null}function B(e){return e.spec.defining||e.spec.definingForContent}function j(e,t,n,o,i){if(t<n){let r=e.firstChild;e=e.replaceChild(0,r.copy(j(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.Fragment.empty,!0))}return e}function $(e,t){let n=[];for(let r=Math.min(e.depth,t.depth);r>=0;r--){let o=e.start(r);if(o<e.pos-(e.depth-r)||t.end(r)>t.pos+(t.depth-r)||e.node(r).type.spec.isolating||t.node(r).type.spec.isolating)break;(o==t.start(r)||r==e.depth&&r==t.depth&&e.parent.inlineContent&&t.parent.inlineContent&&r&&t.start(r-1)==o-1)&&n.push(r)}return n}class L extends d{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 u.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 u.fromReplace(e,this.pos,this.pos+1,new r.Slice(r.Fragment.from(o),0,t.isLeaf?0:1))}getMap(){return l.empty}invert(e){return new L(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 L(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 L(t.pos,t.attr,t.value)}}d.jsonID("attr",L);let V=class extends Error{};V=function e(t){let n=Error.call(this,t);return n.__proto__=e.prototype,n},V.prototype=Object.create(Error.prototype),V.prototype.constructor=V,V.prototype.name="TransformError";class K{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new a}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new V(t.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=r.Slice.empty){let o=R(this.doc,e,t,n);return o&&this.step(o),this}replaceWith(e,t,n){return this.replace(e,t,new r.Slice(r.Fragment.from(n),0,0))}delete(e,t){return this.replace(e,t,r.Slice.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 i=e.doc.resolve(t),s=e.doc.resolve(n);if(D(i,s,o))return e.step(new y(t,n,o));let l=$(i,e.doc.resolve(n));0==l[l.length-1]&&l.pop();let a=-(i.depth+1);l.unshift(a);for(let e=i.depth,t=i.pos-1;e>0;e--,t--){let n=i.node(e).type.spec;if(n.defining||n.definingAsContext||n.isolating)break;l.indexOf(e)>-1?a=e:i.before(e)==t&&l.splice(1,0,-e)}let c=l.indexOf(a),d=[],u=o.openStart;for(let e=o.content,t=0;;t++){let n=e.firstChild;if(d.push(n),t==o.openStart)break;e=n.content}for(let e=u-1;e>=0;e--){let t=d[e].type,n=B(t);if(n&&i.node(c).type!=t)u=e;else if(n||!t.isTextblock)break}for(let t=o.openStart;t>=0;t--){let a=(t+u+1)%(o.openStart+1),h=d[a];if(h)for(let t=0;t<l.length;t++){let d=l[(t+c)%l.length],u=!0;d<0&&(u=!1,d=-d);let p=i.node(d-1),f=i.index(d-1);if(p.canReplaceWith(f,f,h.type,h.marks))return e.replace(i.before(d),u?s.after(d):n,new r.Slice(j(o.content,0,o.openStart,a),a,o.openEnd))}}let h=e.steps.length;for(let r=l.length-1;r>=0&&(e.replace(t,n,o),!(e.steps.length>h));r--){let e=l[r];e<0||(t=i.before(e),n=s.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=A(e.doc,t,o.type);null!=r&&(t=n=r)}e.replaceRange(t,n,new r.Slice(r.Fragment.from(o),0,0))}(this,e,t,n),this}deleteRange(e,t){return function(e,t,n){let r=e.doc.resolve(t),o=e.doc.resolve(n),i=$(r,o);for(let t=0;t<i.length;t++){let n=i[t],s=t==i.length-1;if(s&&0==n||r.node(n).type.contentMatch.validEnd)return e.delete(r.start(n),o.end(n));if(n>0&&(s||r.node(n-1).canReplace(r.index(n-1),o.indexAfter(n-1))))return e.delete(r.before(n),o.after(n))}for(let i=1;i<=r.depth&&i<=o.depth;i++)if(t-r.start(i)==r.depth-i&&n>r.end(i)&&o.end(i)-n!=o.depth-i)return e.delete(r.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,d=a,u=r.Fragment.empty,h=0;for(let e=s,t=!1;e>n;e--)t||o.index(e)>0?(t=!0,u=r.Fragment.from(o.node(e).copy(u)),h++):c--;let p=r.Fragment.empty,f=0;for(let e=s,t=!1;e>n;e--)t||i.after(e+1)<i.end(e)?(t=!0,p=r.Fragment.from(i.node(e).copy(p)),f++):d++;e.step(new v(c,d,l,a,new r.Slice(u.append(p),h,f),u.size-h,!0))}(this,e,t),this}join(e,t=1){return function(e,t,n){let o=new y(t-n,t+n,r.Slice.empty,!0);e.step(o)}(this,e,t),this}wrap(e,t){return function(e,t,n){let o=r.Fragment.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.Fragment.from(n[e].type.create(n[e].attrs,o))}let i=t.start,s=t.end;e.step(new v(i,s,i,s,new r.Slice(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)=>{if(t.isTextblock&&!t.hasMarkup(o,i)&&function(e,t,n){let r=e.resolve(t),o=r.index();return r.parent.canReplaceWith(o,o+1,n)}(e.doc,e.mapping.slice(s).map(n),o)){e.clearIncompatible(e.mapping.slice(s).map(n,1),o);let l=e.mapping.slice(s),a=l.map(n,1),c=l.map(n+t.nodeSize,1);return e.step(new v(a,c,a+1,c-1,new r.Slice(r.Fragment.from(o.create(i,null,t.marks)),0,0),1,!0)),!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 v(t,t+s.nodeSize,t+1,t+s.nodeSize-1,new r.Slice(r.Fragment.from(l),0,0),1,!0))}(this,e,t,n,o),this}setNodeAttribute(e,t,n){return this.step(new L(e,t,n)),this}addNodeMark(e,t){return this.step(new m(e,t)),this}removeNodeMark(e,t){if(!(t instanceof r.Mark)){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 g(e,t)),this}split(e,t=1,n){return function(e,t,n=1,o){let i=e.doc.resolve(t),s=r.Fragment.empty,l=r.Fragment.empty;for(let e=i.depth,t=i.depth-n,a=n-1;e>t;e--,a--){s=r.Fragment.from(i.node(e).copy(s));let t=o&&o[a];l=r.Fragment.from(t?t.type.create(t.attrs,l):i.node(e).copy(l))}e.step(new y(t,t,new r.Slice(s.append(l),n,n),!0))}(this,e,t,n),this}addMark(e,t,n){return function(e,t,n,r){let o,i,s=[],l=[];e.doc.nodesBetween(t,n,(e,a,c)=>{if(!e.isInline)return;let d=e.marks;if(!r.isInSet(d)&&c.type.allowsMarkType(r.type)){let c=Math.max(a,t),u=Math.min(a+e.nodeSize,n),h=r.addToSet(d);for(let e=0;e<d.length;e++)d[e].isInSet(h)||(o&&o.to==c&&o.mark.eq(d[e])?o.to=u:s.push(o=new f(c,u,d[e])));i&&i.to==c?i.to=u:l.push(i=new p(c,u,r))}}),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 i=[],s=0;e.doc.nodesBetween(t,n,(e,l)=>{if(!e.isInline)return;s++;let a=null;if(o instanceof r.MarkType){let t,n=e.marks;for(;t=o.isInSet(n);)(a||(a=[])).push(t),n=t.removeFromSet(n)}else o?o.isInSet(e.marks)&&(a=[o]):a=e.marks;if(a&&a.length){let r=Math.min(l+e.nodeSize,n);for(let e=0;e<a.length;e++){let n,o=a[e];for(let e=0;e<i.length;e++){let t=i[e];t.step==s-1&&o.eq(i[e].style)&&(n=t)}n?(n.to=r,n.step=s):i.push({style:o,from:Math.max(l,t),to:r,step:s})}}}),i.forEach(t=>e.step(new f(t.from,t.to,t.style)))}(this,e,t,n),this}clearIncompatible(e,t,n){return function(e,t,n,o=n.contentMatch){let i=e.doc.nodeAt(t),s=[],l=t+1;for(let t=0;t<i.childCount;t++){let a=i.child(t),c=l+a.nodeSize,d=o.matchType(a.type);if(d){o=d;for(let t=0;t<a.marks.length;t++)n.allowsMarkType(a.marks[t].type)||e.step(new f(l,c,a.marks[t]));if(a.isText&&!n.spec.code){let e,t,o=/\r?\n|\r/g;for(;e=o.exec(a.text);)t||(t=new r.Slice(r.Fragment.from(n.schema.text(" ",n.allowedMarks(a.marks))),0,0)),s.push(new y(l+e.index,l+e.index+e[0].length,t))}}else s.push(new y(l,c,r.Slice.empty));l=c}if(!o.validEnd){let t=o.fillBefore(r.Fragment.empty,!0);e.replace(l,l,new r.Slice(t,0,0))}for(let t=s.length-1;t>=0;t--)e.step(s[t])}(this,e,t,n),this}}},function(e,t,n){"use strict";n.r(t),n.d(t,"Decoration",(function(){return Ft})),n.d(t,"DecorationSet",(function(){return $t})),n.d(t,"EditorView",(function(){return hn})),n.d(t,"__endComposition",(function(){return un})),n.d(t,"__parseFromClipboard",(function(){return dn})),n.d(t,"__serializeForClipboard",(function(){return cn}));var r=n(1),o=n(0),i=n(2);const s=function(e){for(var t=0;;t++)if(!(e=e.previousSibling))return t},l=function(e){let t=e.assignedSlot||e.parentNode;return t&&11==t.nodeType?t.host:t};let a=null;const c=function(e,t,n){let r=a||(a=document.createRange());return r.setEnd(e,null==n?e.nodeValue.length:n),r.setStart(e,t||0),r},d=function(e,t,n,r){return n&&(h(e,t,n,r,-1)||h(e,t,n,r,1))},u=/^(img|br|input|textarea|hr)$/i;function h(e,t,n,r,o){for(;;){if(e==n&&t==r)return!0;if(t==(o<0?0:p(e))){let n=e.parentNode;if(!n||1!=n.nodeType||f(e)||u.test(e.nodeName)||"false"==e.contentEditable)return!1;t=s(e)+(o<0?0:1),e=n}else{if(1!=e.nodeType)return!1;if("false"==(e=e.childNodes[t+(o<0?-1:0)]).contentEditable)return!1;t=o<0?p(e):0}}}function p(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function f(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 m=function(e){return e.focusNode&&d(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)};function g(e,t){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=e,n.key=n.code=t,n}const y="undefined"!=typeof navigator?navigator:null,v="undefined"!=typeof document?document:null,b=y&&y.userAgent||"",w=/Edge\/(\d+)/.exec(b),S=/MSIE \d/.exec(b),k=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(b),x=!!(S||k||w),C=S?document.documentMode:k?+k[1]:w?+w[1]:0,M=!x&&/gecko\/(\d+)/i.test(b);M&&(/Firefox\/(\d+)/.exec(b)||[0,0])[1];const O=!x&&/Chrome\/(\d+)/.exec(b),T=!!O,A=O?+O[1]:0,N=!x&&!!y&&/Apple Computer/.test(y.vendor),R=N&&(/Mobile\/\w+/.test(b)||!!y&&y.maxTouchPoints>2),D=R||!!y&&/Mac/.test(y.platform),_=!!y&&/Win/.test(y.platform),E=/Android \d/.test(b),P=!!v&&"webkitFontSmoothing"in v.documentElement.style,z=P?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function I(e){return{left:0,right:e.documentElement.clientWidth,top:0,bottom:e.documentElement.clientHeight}}function F(e,t){return"number"==typeof e?e:e[t]}function B(e){let t=e.getBoundingClientRect(),n=t.width/e.offsetWidth||1,r=t.height/e.offsetHeight||1;return{left:t.left,right:t.left+e.clientWidth*n,top:t.top,bottom:t.top+e.clientHeight*r}}function j(e,t,n){let r=e.someProp("scrollThreshold")||0,o=e.someProp("scrollMargin")||5,i=e.dom.ownerDocument;for(let s=n||e.dom;s;s=l(s)){if(1!=s.nodeType)continue;let e=s,n=e==i.body,l=n?I(i):B(e),a=0,c=0;if(t.top<l.top+F(r,"top")?c=-(l.top-t.top+F(o,"top")):t.bottom>l.bottom-F(r,"bottom")&&(c=t.bottom-t.top>l.bottom-l.top?t.top+F(o,"top")-l.top:t.bottom-l.bottom+F(o,"bottom")),t.left<l.left+F(r,"left")?a=-(l.left-t.left+F(o,"left")):t.right>l.right-F(r,"right")&&(a=t.right-l.right+F(o,"right")),a||c)if(n)i.defaultView.scrollBy(a,c);else{let n=e.scrollLeft,r=e.scrollTop;c&&(e.scrollTop+=c),a&&(e.scrollLeft+=a);let o=e.scrollLeft-n,i=e.scrollTop-r;t={left:t.left-o,top:t.top-i,right:t.right-o,bottom:t.bottom-i}}if(n||/^(fixed|sticky)$/.test(getComputedStyle(s).position))break}}function $(e){let t=[],n=e.ownerDocument;for(let r=e;r&&(t.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),e!=n);r=l(r));return t}function L(e,t){for(let n=0;n<e.length;n++){let{dom:r,top:o,left:i}=e[n];r.scrollTop!=o+t&&(r.scrollTop=o+t),r.scrollLeft!=i&&(r.scrollLeft=i)}}let V=null;function K(e,t){let n,r,o,i,s=2e8,l=0,a=t.top,d=t.top;for(let u=e.firstChild,h=0;u;u=u.nextSibling,h++){let e;if(1==u.nodeType)e=u.getClientRects();else{if(3!=u.nodeType)continue;e=c(u).getClientRects()}for(let c=0;c<e.length;c++){let p=e[c];if(p.top<=a&&p.bottom>=d){a=Math.max(p.bottom,a),d=Math.min(p.top,d);let e=p.left>t.left?p.left-t.left:p.right<t.left?t.left-p.right:0;if(e<s){n=u,s=e,r=e&&3==n.nodeType?{left:p.right<t.left?p.right:p.left,top:t.top}:t,1==u.nodeType&&e&&(l=h+(t.left>=(p.left+p.right)/2?1:0));continue}}else p.top>t.top&&!o&&p.left<=t.left&&p.right>=t.left&&(o=u,i={left:Math.max(p.left,Math.min(p.right,t.left)),top:p.top});!n&&(t.left>=p.right&&t.top>=p.top||t.left>=p.left&&t.top>=p.bottom)&&(l=h+1)}}return!n&&o&&(n=o,r=i,s=0),n&&3==n.nodeType?function(e,t){let n=e.nodeValue.length,r=document.createRange();for(let o=0;o<n;o++){r.setEnd(e,o+1),r.setStart(e,o);let n=J(r,1);if(n.top!=n.bottom&&H(t,n))return{node:e,offset:o+(t.left>=(n.left+n.right)/2?1:0)}}return{node:e,offset:0}}(n,r):!n||s&&1==n.nodeType?{node:e,offset:l}:K(n,r)}function H(e,t){return e.left>=t.left-1&&e.left<=t.right+1&&e.top>=t.top-1&&e.top<=t.bottom+1}function W(e,t){let n,r=e.dom.ownerDocument,o=0,i=function(e,t,n){if(e.caretPositionFromPoint)try{let r=e.caretPositionFromPoint(t,n);if(r)return{node:r.offsetNode,offset:r.offset}}catch(e){}if(e.caretRangeFromPoint){let r=e.caretRangeFromPoint(t,n);if(r)return{node:r.startContainer,offset:r.startOffset}}}(r,t.left,t.top);i&&({node:n,offset:o}=i);let s,a=(e.root.elementFromPoint?e.root:r).elementFromPoint(t.left,t.top);if(!a||!e.dom.contains(1!=a.nodeType?a.parentNode:a)){let n=e.dom.getBoundingClientRect();if(!H(t,n))return null;if(a=function e(t,n,r){let o=t.childNodes.length;if(o&&r.top<r.bottom)for(let i=Math.max(0,Math.min(o-1,Math.floor(o*(n.top-r.top)/(r.bottom-r.top))-2)),s=i;;){let r=t.childNodes[s];if(1==r.nodeType){let t=r.getClientRects();for(let o=0;o<t.length;o++){let i=t[o];if(H(n,i))return e(r,n,i)}}if((s=(s+1)%o)==i)break}return t}(e.dom,t,n),!a)return null}if(N)for(let e=a;n&&e;e=l(e))e.draggable&&(n=void 0);if(a=function(e,t){let n=e.parentNode;return n&&/^li$/i.test(n.nodeName)&&t.left<e.getBoundingClientRect().left?n:e}(a,t),n){if(M&&1==n.nodeType&&(o=Math.min(o,n.childNodes.length),o<n.childNodes.length)){let e,r=n.childNodes[o];"IMG"==r.nodeName&&(e=r.getBoundingClientRect()).right<=t.left&&e.bottom>t.top&&o++}n==e.dom&&o==n.childNodes.length-1&&1==n.lastChild.nodeType&&t.top>n.lastChild.getBoundingClientRect().bottom?s=e.state.doc.content.size:0!=o&&1==n.nodeType&&"BR"==n.childNodes[o-1].nodeName||(s=function(e,t,n,r){let o=-1;for(let n=t,i=!1;n!=e.dom;){let t=e.docView.nearestDesc(n,!0);if(!t)return null;if(1==t.dom.nodeType&&(t.node.isBlock&&t.parent&&!i||!t.contentDOM)){let e=t.dom.getBoundingClientRect();if(t.node.isBlock&&t.parent&&!i&&(i=!0,e.left>r.left||e.top>r.top?o=t.posBefore:(e.right<r.left||e.bottom<r.top)&&(o=t.posAfter)),!t.contentDOM&&o<0&&!t.node.isText){return(t.node.isBlock?r.top<(e.top+e.bottom)/2:r.left<(e.left+e.right)/2)?t.posBefore:t.posAfter}}n=t.dom.parentNode}return o>-1?o:e.docView.posFromDOM(t,n,-1)}(e,n,o,t))}null==s&&(s=function(e,t,n){let{node:r,offset:o}=K(t,n),i=-1;if(1==r.nodeType&&!r.firstChild){let e=r.getBoundingClientRect();i=e.left!=e.right&&n.left>(e.left+e.right)/2?1:-1}return e.docView.posFromDOM(r,o,i)}(e,a,t));let c=e.docView.nearestDesc(a,!0);return{pos:s,inside:c?c.posAtStart-c.border:-1}}function q(e){return e.top<e.bottom||e.left<e.right}function J(e,t){let n=e.getClientRects();if(n.length){let e=n[t<0?0:n.length-1];if(q(e))return e}return Array.prototype.find.call(n,q)||e.getBoundingClientRect()}const U=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function X(e,t,n){let{node:r,offset:o,atom:i}=e.docView.domFromPos(t,n<0?-1:1),s=P||M;if(3==r.nodeType){if(!s||!U.test(r.nodeValue)&&(n<0?o:o!=r.nodeValue.length)){let e=o,t=o,i=n<0?1:-1;return n<0&&!o?(t++,i=-1):n>=0&&o==r.nodeValue.length?(e--,i=1):n<0?e--:t++,G(J(c(r,e,t),i),i<0)}{let e=J(c(r,o,o),n);if(M&&o&&/\s/.test(r.nodeValue[o-1])&&o<r.nodeValue.length){let t=J(c(r,o-1,o-1),-1);if(t.top==e.top){let n=J(c(r,o,o+1),-1);if(n.top!=e.top)return G(n,n.left<t.left)}}return e}}if(!e.state.doc.resolve(t-(i||0)).parent.inlineContent){if(null==i&&o&&(n<0||o==p(r))){let e=r.childNodes[o-1];if(1==e.nodeType)return Y(e.getBoundingClientRect(),!1)}if(null==i&&o<p(r)){let e=r.childNodes[o];if(1==e.nodeType)return Y(e.getBoundingClientRect(),!0)}return Y(r.getBoundingClientRect(),n>=0)}if(null==i&&o&&(n<0||o==p(r))){let e=r.childNodes[o-1],t=3==e.nodeType?c(e,p(e)-(s?0:1)):1!=e.nodeType||"BR"==e.nodeName&&e.nextSibling?null:e;if(t)return G(J(t,1),!1)}if(null==i&&o<p(r)){let e=r.childNodes[o];for(;e.pmViewDesc&&e.pmViewDesc.ignoreForCoords;)e=e.nextSibling;let t=e?3==e.nodeType?c(e,0,s?0:1):1==e.nodeType?e:null:null;if(t)return G(J(t,-1),!0)}return G(J(3==r.nodeType?c(r):r,-n),n>=0)}function G(e,t){if(0==e.width)return e;let n=t?e.left:e.right;return{top:e.top,bottom:e.bottom,left:n,right:n}}function Y(e,t){if(0==e.height)return e;let n=t?e.top:e.bottom;return{top:n,bottom:n,left:e.left,right:e.right}}function Q(e,t,n){let r=e.state,o=e.root.activeElement;r!=t&&e.updateState(t),o!=e.dom&&e.focus();try{return n()}finally{r!=t&&e.updateState(r),o!=e.dom&&o&&o.focus()}}const Z=/[\u0590-\u08ac]/;let ee=null,te=null,ne=!1;function re(e,t,n){return ee==t&&te==n?ne:(ee=t,te=n,ne="up"==n||"down"==n?function(e,t,n){let r=t.selection,o="up"==n?r.$from:r.$to;return Q(e,t,()=>{let{node:t}=e.docView.domFromPos(o.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 r=X(e,o.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=c(e,0,e.nodeValue.length).getClientRects()}for(let e=0;e<t.length;e++){let o=t[e];if(o.bottom>o.top+1&&("up"==n?r.top-o.top>2*(o.bottom-r.top):o.bottom-r.bottom>2*(r.bottom-o.top)))return!1}}return!0})}(e,t,n):function(e,t,n){let{$head:r}=t.selection;if(!r.parent.isTextblock)return!1;let o=r.parentOffset,i=!o,s=o==r.parent.content.size,l=e.domSelection();return Z.test(r.parent.textContent)&&l.modify?Q(e,t,()=>{let{focusNode:t,focusOffset:o,anchorNode:i,anchorOffset:s}=e.domSelectionRange(),a=l.caretBidiLevel;l.modify("move",n,"character");let c=r.depth?e.docView.domAfterPos(r.before()):e.dom,{focusNode:d,focusOffset:u}=e.domSelectionRange(),h=d&&!c.contains(1==d.nodeType?d:d.parentNode)||t==d&&o==u;try{l.collapse(i,s),t&&(t!=i||o!=s)&&l.extend&&l.extend(t,o)}catch(e){}return null!=a&&(l.caretBidiLevel=a),h}):"left"==n||"backward"==n?i:s}(e,t,n))}class oe{constructor(e,t,n,r){this.parent=e,this.children=t,this.dom=n,this.contentDOM=r,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 r=this.children[t];if(r==e)return n;n+=r.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,r;if(e==this.contentDOM)n=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;n=e.previousSibling}for(;n&&(!(r=n.pmViewDesc)||r.parent!=this);)n=n.previousSibling;return n?this.posBeforeChild(r)+r.size:this.posAtStart}{let n,r;if(e==this.contentDOM)n=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;n=e.nextSibling}for(;n&&(!(r=n.pmViewDesc)||r.parent!=this);)n=n.nextSibling;return n?this.posBeforeChild(r):this.posAtEnd}}let r;if(e==this.dom&&this.contentDOM)r=t>s(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))r=2&e.compareDocumentPosition(this.contentDOM);else if(this.dom.firstChild){if(0==t)for(let t=e;;t=t.parentNode){if(t==this.dom){r=!1;break}if(t.previousSibling)break}if(null==r&&t==e.childNodes.length)for(let t=e;;t=t.parentNode){if(t==this.dom){r=!0;break}if(t.nextSibling)break}}return(null==r?n>0:r)?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let n=!0,r=e;r;r=r.parentNode){let o,i=this.getDesc(r);if(i&&(!t||i.node)){if(!n||!(o=i.nodeDOM)||(1==o.nodeType?o.contains(1==e.nodeType?e:e.parentNode):o==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 r=e;r;r=r.parentNode){let o=this.getDesc(r);if(o)return o.localPosFromDOM(e,t,n)}return-1}descAt(e){for(let t=0,n=0;t<this.children.length;t++){let r=this.children[t],o=n+r.size;if(n==e&&o!=n){for(;!r.border&&r.children.length;)r=r.children[0];return r}if(e<o)return r.descAt(e-n-r.border);n=o}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let n,r=0,o=0;for(let t=0;r<this.children.length;r++){let n=this.children[r],i=t+n.size;if(i>e||n instanceof ue){o=e-t;break}t=i}if(o)return this.children[r].domFromPos(o-this.children[r].border,t);for(;r&&!(n=this.children[r-1]).size&&n instanceof ie&&n.side>=0;r--);if(t<=0){let e,n=!0;for(;e=r?this.children[r-1]:null,e&&e.dom.parentNode!=this.contentDOM;r--,n=!1);return e&&t&&n&&!e.border&&!e.domAtom?e.domFromPos(e.size,t):{node:this.contentDOM,offset:e?s(e.dom)+1:0}}{let e,n=!0;for(;e=r<this.children.length?this.children[r]:null,e&&e.dom.parentNode!=this.contentDOM;r++,n=!1);return e&&n&&!e.border&&!e.domAtom?e.domFromPos(0,t):{node:this.contentDOM,offset:e?s(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 r=-1,o=-1;for(let i=n,l=0;;l++){let n=this.children[l],a=i+n.size;if(-1==r&&e<=a){let o=i+n.border;if(e>=o&&t<=a-n.border&&n.node&&n.contentDOM&&this.contentDOM.contains(n.contentDOM))return n.parseRange(e,t,o);e=i;for(let t=l;t>0;t--){let n=this.children[t-1];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(1)){r=s(n.dom)+1;break}e-=n.size}-1==r&&(r=0)}if(r>-1&&(a>t||l==this.children.length-1)){t=a;for(let e=l+1;e<this.children.length;e++){let n=this.children[e];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(-1)){o=s(n.dom);break}t+=n.size}-1==o&&(o=this.contentDOM.childNodes.length);break}i=a}return{node:this.contentDOM,from:e,to:t,fromOffset:r,toOffset:o}}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,r=!1){let o=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(o>l&&i<c)return a.setSelection(e-l-a.border,t-l-a.border,n,r);l=c}let l=this.domFromPos(e,e?-1:1),a=t==e?l:this.domFromPos(t,t?-1:1),c=n.getSelection(),u=!1;if((M||N)&&e==t){let{node:e,offset:t}=l;if(3==e.nodeType){if(u=!(!t||"\n"!=e.nodeValue[t-1]),u&&t==e.nodeValue.length)for(let t,n=e;n;n=n.parentNode){if(t=n.nextSibling){"BR"==t.nodeName&&(l=a={node:t.parentNode,offset:s(t)+1});break}let e=n.pmViewDesc;if(e&&e.node&&e.node.isBlock)break}}else{let n=e.childNodes[t-1];u=n&&("BR"==n.nodeName||"false"==n.contentEditable)}}if(M&&c.focusNode&&c.focusNode!=a.node&&1==c.focusNode.nodeType){let e=c.focusNode.childNodes[c.focusOffset];e&&"false"==e.contentEditable&&(r=!0)}if(!(r||u&&N)&&d(l.node,l.offset,c.anchorNode,c.anchorOffset)&&d(a.node,a.offset,c.focusNode,c.focusOffset))return;let h=!1;if((c.extend||e==t)&&!u){c.collapse(l.node,l.offset);try{e!=t&&c.extend(a.node,a.offset),h=!0}catch(e){}}if(!h){if(e>t){let e=l;l=a,a=e}let n=document.createRange();n.setEnd(a.node,a.offset),n.setStart(l.node,l.offset),c.removeAllRanges(),c.addRange(n)}}ignoreMutation(e){return!this.contentDOM&&"selection"!=e.type}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let n=0,r=0;r<this.children.length;r++){let o=this.children[r],i=n+o.size;if(n==i?e<=i&&t>=n:e<i&&t>n){let r=n+o.border,s=i-o.border;if(e>=r&&t<=s)return this.dirty=e==n||t==i?2:1,void(e!=r||t!=s||!o.contentLost&&o.dom.parentNode==this.contentDOM?o.markDirty(e-r,t-r):o.dirty=3);o.dirty=o.dom!=o.contentDOM||o.dom.parentNode!=this.contentDOM||o.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}}class ie extends oe{constructor(e,t,n,r){let o,i=t.type.toDOM;if("function"==typeof i&&(i=i(n,()=>o?o.parent?o.parent.posBeforeChild(o):void 0:r)),!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,o=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 se extends oe{constructor(e,t,n,r){super(e,[],t,null),this.textDOM=n,this.text=r}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 le extends oe{constructor(e,t,n,r){super(e,[],n,r),this.mark=t}static create(e,t,n,r){let i=r.nodeViews[t.type.name],s=i&&i(t,r,n);return s&&s.dom||(s=o.DOMSerializer.renderSpec(document,t.type.spec.toDOM(t,n))),new le(e,t,s.dom,s.contentDOM||s.dom)}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 r=le.create(this.parent,this.mark,!0,n),o=this.children,i=this.size;t<i&&(o=xe(o,t,i,n)),e>0&&(o=xe(o,0,e,n));for(let e=0;e<o.length;e++)o[e].parent=r;return r.children=o,r}}class ae extends oe{constructor(e,t,n,r,o,i,s,l,a){super(e,[],o,i),this.node=t,this.outerDeco=n,this.innerDeco=r,this.nodeDOM=s}static create(e,t,n,r,i,s){let l,a=i.nodeViews[t.type.name],c=a&&a(t,i,()=>l?l.parent?l.parent.posBeforeChild(l):void 0:s,n,r),d=c&&c.dom,u=c&&c.contentDOM;if(t.isText)if(d){if(3!=d.nodeType)throw new RangeError("Text must be rendered as a DOM text node")}else d=document.createTextNode(t.text);else d||({dom:d,contentDOM:u}=o.DOMSerializer.renderSpec(document,t.type.spec.toDOM(t)));u||t.isText||"BR"==d.nodeName||(d.hasAttribute("contenteditable")||(d.contentEditable="false"),t.type.spec.draggable&&(d.draggable=!0));let h=d;return d=ve(d,n,t),c?l=new he(e,t,n,r,d,u||null,h,c,i,s+1):t.isText?new de(e,t,n,r,d,h,i):new ae(e,t,n,r,d,u||null,h,i,s+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if("pre"==this.node.type.whitespace&&(e.preserveWhitespace="full"),this.contentDOM)if(this.contentLost){for(let t=this.children.length-1;t>=0;t--){let n=this.children[t];if(this.dom.contains(n.dom.parentNode)){e.contentElement=n.dom.parentNode;break}}e.contentElement||(e.getContent=()=>o.Fragment.empty)}else e.contentElement=this.contentDOM;else e.getContent=()=>this.node.content;return e}matchesNode(e,t,n){return 0==this.dirty&&e.eq(this.node)&&be(t,this.outerDeco)&&n.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let n=this.node.inlineContent,r=t,i=e.composing?this.localCompositionInfo(e,t):null,s=i&&i.pos>-1?i:null,l=i&&i.pos<0,a=new Se(this,s&&s.node,e);!function(e,t,n,r){let o=t.locals(e),i=0;if(0==o.length){for(let n=0;n<e.childCount;n++){let s=e.child(n);r(s,o,t.forChild(i,s),n),i+=s.nodeSize}return}let s=0,l=[],a=null;for(let c=0;;){if(s<o.length&&o[s].to==i){let e,t=o[s++];for(;s<o.length&&o[s].to==i;)(e||(e=[t])).push(o[s++]);if(e){e.sort(ke);for(let t=0;t<e.length;t++)n(e[t],c,!!a)}else n(t,c,!!a)}let d,u;if(a)u=-1,d=a,a=null;else{if(!(c<e.childCount))break;u=c,d=e.child(c++)}for(let e=0;e<l.length;e++)l[e].to<=i&&l.splice(e--,1);for(;s<o.length&&o[s].from<=i&&o[s].to>i;)l.push(o[s++]);let h=i+d.nodeSize;if(d.isText){let e=h;s<o.length&&o[s].from<e&&(e=o[s].from);for(let t=0;t<l.length;t++)l[t].to<e&&(e=l[t].to);e<h&&(a=d.cut(e-i),d=d.cut(0,e-i),h=e,u=-1)}let p=d.isInline&&!d.isLeaf?l.filter(e=>!e.inline):l.slice();r(d,p,t.forChild(i,d),u),i=h}}(this.node,this.innerDeco,(t,i,s)=>{t.spec.marks?a.syncToMarks(t.spec.marks,n,e):t.type.side>=0&&!s&&a.syncToMarks(i==this.node.childCount?o.Mark.none:this.node.child(i).marks,n,e),a.placeWidget(t,e,r)},(t,o,s,c)=>{let d;a.syncToMarks(t.marks,n,e),a.findNodeMatch(t,o,s,c)||l&&e.state.selection.from>r&&e.state.selection.to<r+t.nodeSize&&(d=a.findIndexWithChild(i.node))>-1&&a.updateNodeAt(t,o,s,d,e)||a.updateNextNode(t,o,s,e,c,r)||a.addNode(t,o,s,e,r),r+=t.nodeSize}),a.syncToMarks([],n,e),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||2==this.dirty)&&(s&&this.protectLocalComposition(e,s),function e(t,n,r){let o=t.firstChild,i=!1;for(let s=0;s<n.length;s++){let l=n[s],a=l.dom;if(a.parentNode==t){for(;a!=o;)o=we(o),i=!0;o=o.nextSibling}else i=!0,t.insertBefore(a,o);if(l instanceof le){let n=o?o.previousSibling:t.lastChild;e(l.contentDOM,l.children,r),o=n?n.nextSibling:t.firstChild}}for(;o;)o=we(o),i=!0;i&&r.trackWrites==t&&(r.trackWrites=null)}(this.contentDOM,this.children,e),R&&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 r.TextSelection)||n<t||o>t+this.node.content.size)return null;let i=e.domSelectionRange(),s=function(e,t){for(;;){if(3==e.nodeType)return e;if(1==e.nodeType&&t>0){if(e.childNodes.length>t&&3==e.childNodes[t].nodeType)return e.childNodes[t];e=e.childNodes[t-1],t=p(e)}else{if(!(1==e.nodeType&&t<e.childNodes.length))return null;e=e.childNodes[t],t=0}}}(i.focusNode,i.focusOffset);if(!s||!this.dom.contains(s.parentNode))return null;if(this.node.inlineContent){let e=s.nodeValue,r=function(e,t,n,r){for(let o=0,i=0;o<e.childCount&&i<=r;){let s=e.child(o++),l=i;if(i+=s.nodeSize,!s.isText)continue;let a=s.text;for(;o<e.childCount;){let t=e.child(o++);if(i+=t.nodeSize,!t.isText)break;a+=t.text}if(i>=n){let e=l<r?a.lastIndexOf(t,r-l-1):-1;if(e>=0&&e+t.length+l>=n)return l+e;if(n==r&&a.length>=r+t.length-l&&a.slice(r-l,r-l+t.length)==t)return r}}return-1}(this.node.content,e,n-t,o-t);return r<0?null:{node:s,pos:r,text:e}}return{node:s,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:n,text:r}){if(this.getDesc(t))return;let o=t;for(;o.parentNode!=this.contentDOM;o=o.parentNode){for(;o.previousSibling;)o.parentNode.removeChild(o.previousSibling);for(;o.nextSibling;)o.parentNode.removeChild(o.nextSibling);o.pmViewDesc&&(o.pmViewDesc=void 0)}let i=new se(this,o,t,r);e.input.compositionNodes.push(i),this.children=xe(this.children,n,n+r.length,e,i)}update(e,t,n,r){return!(3==this.dirty||!e.sameMarkup(this.node))&&(this.updateInner(e,t,n,r),!0)}updateInner(e,t,n,r){this.updateOuterDeco(t),this.node=e,this.innerDeco=n,this.contentDOM&&this.updateChildren(r,this.posAtStart),this.dirty=0}updateOuterDeco(e){if(be(e,this.outerDeco))return;let t=1!=this.nodeDOM.nodeType,n=this.dom;this.dom=ge(this.dom,this.nodeDOM,me(this.outerDeco,this.node,t),me(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 ce(e,t,n,r,o){ve(r,t,e);let i=new ae(void 0,e,t,n,r,r,r,o,0);return i.contentDOM&&i.updateChildren(o,0),i}class de extends ae{constructor(e,t,n,r,o,i,s){super(e,t,n,r,o,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,r){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,r.trackWrites==this.nodeDOM&&(r.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 r=this.node.cut(e,t),o=document.createTextNode(r.text);return new de(this.parent,r,this.outerDeco,this.innerDeco,o,o,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}}class ue extends oe{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 he extends ae{constructor(e,t,n,r,o,i,s,l,a,c){super(e,t,n,r,o,i,s,a,c),this.spec=l}update(e,t,n,r){if(3==this.dirty)return!1;if(this.spec.update){let o=this.spec.update(e,t,n);return o&&this.updateInner(e,t,n,r),o}return!(!this.contentDOM&&!e.isLeaf)&&super.update(e,t,n,r)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,n,r){this.spec.setSelection?this.spec.setSelection(e,t,n):super.setSelection(e,t,n,r)}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)}}const pe=function(e){e&&(this.nodeName=e)};pe.prototype=Object.create(null);const fe=[new pe];function me(e,t,n){if(0==e.length)return fe;let r=n?fe[0]:new pe,o=[r];for(let i=0;i<e.length;i++){let s=e[i].type.attrs;if(s){s.nodeName&&o.push(r=new pe(s.nodeName));for(let e in s){let i=s[e];null!=i&&(n&&1==o.length&&o.push(r=new pe(t.isInline?"span":"div")),"class"==e?r.class=(r.class?r.class+" ":"")+i:"style"==e?r.style=(r.style?r.style+";":"")+i:"nodeName"!=e&&(r[e]=i))}}}return o}function ge(e,t,n,r){if(n==fe&&r==fe)return t;let o=t;for(let t=0;t<r.length;t++){let i=r[t],s=n[t];if(t){let t;s&&s.nodeName==i.nodeName&&o!=e&&(t=o.parentNode)&&t.nodeName.toLowerCase()==i.nodeName||(t=document.createElement(i.nodeName),t.pmIsDeco=!0,t.appendChild(o),s=fe[0]),o=t}ye(o,s||fe[0],i)}return o}function ye(e,t,n){for(let r in t)"class"==r||"style"==r||"nodeName"==r||r in n||e.removeAttribute(r);for(let r in n)"class"!=r&&"style"!=r&&"nodeName"!=r&&n[r]!=t[r]&&e.setAttribute(r,n[r]);if(t.class!=n.class){let r=t.class?t.class.split(" ").filter(Boolean):[],o=n.class?n.class.split(" ").filter(Boolean):[];for(let t=0;t<r.length;t++)-1==o.indexOf(r[t])&&e.classList.remove(r[t]);for(let t=0;t<o.length;t++)-1==r.indexOf(o[t])&&e.classList.add(o[t]);0==e.classList.length&&e.removeAttribute("class")}if(t.style!=n.style){if(t.style){let n,r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g;for(;n=r.exec(t.style);)e.style.removeProperty(n[1])}n.style&&(e.style.cssText+=n.style)}}function ve(e,t,n){return ge(e,e,fe,me(t,n,1!=e.nodeType))}function be(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].type.eq(t[n].type))return!1;return!0}function we(e){let t=e.nextSibling;return e.parentNode.removeChild(e),t}class Se{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,r=n.children.length,o=e.childCount,i=new Map,s=[];e:for(;o>0;){let l;for(;;)if(r){let e=n.children[r-1];if(!(e instanceof le)){l=e,r--;break}n=e,r=e.children.length}else{if(n==t)break e;r=n.parent.children.indexOf(n),n=n.parent}let a=l.node;if(a){if(a!=e.child(o-1))break;--o,i.set(l,o),s.push(l)}}return{index:o,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 r=0,o=this.stack.length>>1,i=Math.min(o,e.length);for(;r<i&&(r==o-1?this.top:this.stack[r+1<<1]).matchesMark(e[r])&&!1!==e[r].type.spec.spanning;)r++;for(;r<o;)this.destroyRest(),this.top.dirty=0,this.index=this.stack.pop(),this.top=this.stack.pop(),o--;for(;o<e.length;){this.stack.push(this.top,this.index+1);let r=-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[o])&&!this.isLocked(n.dom)){r=t;break}}if(r>-1)r>this.index&&(this.changed=!0,this.destroyBetween(this.index,r)),this.top=this.top.children[this.index];else{let r=le.create(this.top,e[o],t,n);this.top.children.splice(this.index,0,r),this.top=r,this.changed=!0}this.index=0,o++}}findNodeMatch(e,t,n,r){let o,i=-1;if(r>=this.preMatch.index&&(o=this.preMatch.matches[r-this.preMatch.index]).parent==this.top&&o.matchesNode(e,t,n))i=this.top.children.indexOf(o,this.index);else for(let r=this.index,o=Math.min(this.top.children.length,r+5);r<o;r++){let o=this.top.children[r];if(o.matchesNode(e,t,n)&&!this.preMatch.matched.has(o)){i=r;break}}return!(i<0)&&(this.destroyBetween(this.index,i),this.index++,!0)}updateNodeAt(e,t,n,r,o){let i=this.top.children[r];return 3==i.dirty&&i.dom==i.contentDOM&&(i.dirty=2),!!i.update(e,t,n,o)&&(this.destroyBetween(this.index,r),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,r,o,i){for(let s=this.index;s<this.top.children.length;s++){let l=this.top.children[s];if(l instanceof ae){let a=this.preMatch.matched.get(l);if(null!=a&&a!=o)return!1;let c,d=l.dom,u=this.isLocked(d)&&!(e.isText&&l.node&&l.node.isText&&l.nodeDOM.nodeValue==e.text&&3!=l.dirty&&be(t,l.outerDeco));if(!u&&l.update(e,t,n,r))return this.destroyBetween(this.index,s),l.dom!=d&&(this.changed=!0),this.index++,!0;if(!u&&(c=this.recreateWrapper(l,e,t,n,r,i)))return this.top.children[this.index]=c,c.dirty=2,c.updateChildren(r,i+1),c.dirty=0,this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,n,r,o,i){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content))return null;let s=ae.create(this.top,t,n,r,o,i);if(!s.contentDOM)return null;s.children=e.children,e.children=[],e.destroy();for(let e of s.children)e.parent=s;return s}addNode(e,t,n,r,o){let i=ae.create(this.top,e,t,n,r,o);i.contentDOM&&i.updateChildren(r,o+1),this.top.children.splice(this.index++,0,i),this.changed=!0}placeWidget(e,t,n){let r=this.index<this.top.children.length?this.top.children[this.index]:null;if(!r||!r.matchesWidget(e)||e!=r.widget&&r.widget.type.toDOM.parentNode){let r=new ie(this.top,e,t,n);this.top.children.splice(this.index++,0,r),this.changed=!0}else this.index++}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof le;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof de)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((N||T)&&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 r=new ue(this.top,[],n,null);t!=this.top?t.children.push(r):t.children.splice(this.index++,0,r),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||1==e.nodeType&&e.contains(this.lock.parentNode))}}function ke(e,t){return e.type.side-t.type.side}function xe(e,t,n,r,o){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,r)),o&&(i.push(o),o=void 0),d>n&&i.push(a.slice(n-c,a.size,r)))}return i}function Ce(e,t=null){let n=e.domSelectionRange(),o=e.state.doc;if(!n.focusNode)return null;let i=e.docView.nearestDesc(n.focusNode),l=i&&0==i.size,a=e.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(a<0)return null;let c,d,u=o.resolve(a);if(m(n)){for(c=u;i&&!i.node;)i=i.parent;let e=i.node;if(i&&e.isAtom&&r.NodeSelection.isSelectable(e)&&i.parent&&(!e.isInline||!function(e,t,n){for(let r=0==t,o=t==p(e);r||o;){if(e==n)return!0;let t=s(e);if(!(e=e.parentNode))return!1;r=r&&0==t,o=o&&t==p(e)}}(n.focusNode,n.focusOffset,i.dom))){let e=i.posBefore;d=new r.NodeSelection(a==e?u:o.resolve(e))}}else{let t=e.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(t<0)return null;c=o.resolve(t)}if(!d){d=Ee(e,c,u,"pointer"==t||e.state.selection.head<u.pos&&!l?1:-1)}return d}function Me(e){return e.editable?e.hasFocus():ze(e)&&document.activeElement&&document.activeElement.contains(e.dom)}function Oe(e,t=!1){let n=e.state.selection;if(De(e,n),Me(e)){if(!t&&e.input.mouseDown&&e.input.mouseDown.allowDefault&&T){let t=e.domSelectionRange(),n=e.domObserver.currentSelection;if(t.anchorNode&&n.anchorNode&&d(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(),r=e.cursorWrapper.dom,o="IMG"==r.nodeName;o?n.setEnd(r.parentNode,s(r)+1):n.setEnd(r,0);n.collapse(!1),t.removeAllRanges(),t.addRange(n),!o&&!e.state.selection.visible&&x&&C<=11&&(r.disabled=!0,r.disabled=!1)}(e);else{let o,i,{anchor:s,head:l}=n;!Te||n instanceof r.TextSelection||(n.$from.parent.inlineContent||(o=Ae(e,n.from)),n.empty||n.$from.parent.inlineContent||(i=Ae(e,n.to))),e.docView.setSelection(s,l,e.root,t),Te&&(o&&Re(o),i&&Re(i)),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(),r=n.anchorNode,o=n.anchorOffset;t.addEventListener("selectionchange",e.input.hideSelectionGuard=()=>{n.anchorNode==r&&n.anchorOffset==o||(t.removeEventListener("selectionchange",e.input.hideSelectionGuard),setTimeout(()=>{Me(e)&&!e.state.selection.visible||e.dom.classList.remove("ProseMirror-hideselection")},20))})}(e))}e.domObserver.setCurSelection(),e.domObserver.connectSelection()}}const Te=N||T&&A<63;function Ae(e,t){let{node:n,offset:r}=e.docView.domFromPos(t,0),o=r<n.childNodes.length?n.childNodes[r]:null,i=r?n.childNodes[r-1]:null;if(N&&o&&"false"==o.contentEditable)return Ne(o);if(!(o&&"false"!=o.contentEditable||i&&"false"!=i.contentEditable)){if(o)return Ne(o);if(i)return Ne(i)}}function Ne(e){return e.contentEditable="true",N&&e.draggable&&(e.draggable=!1,e.wasDraggable=!0),e}function Re(e){e.contentEditable="false",e.wasDraggable&&(e.draggable=!0,e.wasDraggable=null)}function De(e,t){if(t instanceof r.NodeSelection){let n=e.docView.descAt(t.from);n!=e.lastSelectedViewDesc&&(_e(e),n&&n.selectNode(),e.lastSelectedViewDesc=n)}else _e(e)}function _e(e){e.lastSelectedViewDesc&&(e.lastSelectedViewDesc.parent&&e.lastSelectedViewDesc.deselectNode(),e.lastSelectedViewDesc=void 0)}function Ee(e,t,n,o){return e.someProp("createSelectionBetween",r=>r(e,t,n))||r.TextSelection.between(t,n,o)}function Pe(e){return!(e.editable&&!e.hasFocus())&&ze(e)}function ze(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 Ie(e,t){let{$anchor:n,$head:o}=e.selection,i=t>0?n.max(o):n.min(o),s=i.parent.inlineContent?i.depth?e.doc.resolve(t>0?i.after():i.before()):null:i;return s&&r.Selection.findFrom(s,t)}function Fe(e,t){return e.dispatch(e.state.tr.setSelection(t).scrollIntoView()),!0}function Be(e,t,n){let o=e.state.selection;if(!(o instanceof r.TextSelection)){if(o instanceof r.NodeSelection&&o.node.isInline)return Fe(e,new r.TextSelection(t>0?o.$to:o.$from));{let n=Ie(e.state,t);return!!n&&Fe(e,n)}}if(!o.empty||n.indexOf("s")>-1)return!1;if(e.endOfTextblock(t>0?"forward":"backward")){let n=Ie(e.state,t);return!!(n&&n instanceof r.NodeSelection)&&Fe(e,n)}if(!(D&&n.indexOf("m")>-1)){let n,i=o.$head,s=i.textOffset?null:t<0?i.nodeBefore:i.nodeAfter;if(!s||s.isText)return!1;let l=t<0?i.pos-s.nodeSize:i.pos;return!!(s.isAtom||(n=e.docView.descAt(l))&&!n.contentDOM)&&(r.NodeSelection.isSelectable(s)?Fe(e,new r.NodeSelection(t<0?e.state.doc.resolve(i.pos-s.nodeSize):i)):!!P&&Fe(e,new r.TextSelection(e.state.doc.resolve(t<0?l:l+s.nodeSize))))}}function je(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function $e(e){if("false"==e.contentEditable)return!0;let t=e.pmViewDesc;return t&&0==t.size&&(e.nextSibling||"BR"!=e.nodeName)}function Le(e,t){return t<0?function(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let o,i,l=!1;M&&1==n.nodeType&&r<je(n)&&$e(n.childNodes[r])&&(l=!0);for(;;)if(r>0){if(1!=n.nodeType)break;{let e=n.childNodes[r-1];if($e(e))o=n,i=--r;else{if(3!=e.nodeType)break;n=e,r=n.nodeValue.length}}}else{if(Ke(n))break;{let t=n.previousSibling;for(;t&&$e(t);)o=n.parentNode,i=s(t),t=t.previousSibling;if(t)n=t,r=je(n);else{if(n=n.parentNode,n==e.dom)break;r=0}}}l?He(e,n,r):o&&He(e,o,i)}(e):Ve(e)}function Ve(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let o,i,l=je(n);for(;;)if(r<l){if(1!=n.nodeType)break;if(!$e(n.childNodes[r]))break;o=n,i=++r}else{if(Ke(n))break;{let t=n.nextSibling;for(;t&&$e(t);)o=t.parentNode,i=s(t)+1,t=t.nextSibling;if(t)n=t,r=0,l=je(n);else{if(n=n.parentNode,n==e.dom)break;r=l=0}}}o&&He(e,o,i)}function Ke(e){let t=e.pmViewDesc;return t&&t.node&&t.node.isBlock}function He(e,t,n){if(3!=t.nodeType){let e,r;(r=function(e,t){for(;e&&t==e.childNodes.length&&!f(e);)t=s(e)+1,e=e.parentNode;for(;e&&t<e.childNodes.length;){if(3==(e=e.childNodes[t]).nodeType)return e;t=0}}(t,n))?(t=r,n=0):(e=function(e,t){for(;e&&!t&&!f(e);)t=s(e),e=e.parentNode;for(;e&&t;){if(3==(e=e.childNodes[t-1]).nodeType)return e;t=e.childNodes.length}}(t,n))&&(t=e,n=e.nodeValue.length)}let r=e.domSelection();if(m(r)){let e=document.createRange();e.setEnd(t,n),e.setStart(t,n),r.removeAllRanges(),r.addRange(e)}else r.extend&&r.extend(t,n);e.domObserver.setCurSelection();let{state:o}=e;setTimeout(()=>{e.state==o&&Oe(e)},50)}function We(e,t){let n=e.state.doc.resolve(t);if(!T&&!_&&n.parent.inlineContent){let r=e.coordsAtPos(t);if(t>n.start()){let n=e.coordsAtPos(t-1),o=(n.top+n.bottom)/2;if(o>r.top&&o<r.bottom&&Math.abs(n.left-r.left)>1)return n.left<r.left?"ltr":"rtl"}if(t<n.end()){let n=e.coordsAtPos(t+1),o=(n.top+n.bottom)/2;if(o>r.top&&o<r.bottom&&Math.abs(n.left-r.left)>1)return n.left>r.left?"ltr":"rtl"}}return"rtl"==getComputedStyle(e.dom).direction?"rtl":"ltr"}function qe(e,t,n){let o=e.state.selection;if(o instanceof r.TextSelection&&!o.empty||n.indexOf("s")>-1)return!1;if(D&&n.indexOf("m")>-1)return!1;let{$from:i,$to:s}=o;if(!i.parent.inlineContent||e.endOfTextblock(t<0?"up":"down")){let n=Ie(e.state,t);if(n&&n instanceof r.NodeSelection)return Fe(e,n)}if(!i.parent.inlineContent){let n=t<0?i:s,l=o instanceof r.AllSelection?r.Selection.near(n,t):r.Selection.findFrom(n,t);return!!l&&Fe(e,l)}return!1}function Je(e,t){if(!(e.state.selection instanceof r.TextSelection))return!0;let{$head:n,$anchor:o,empty:i}=e.state.selection;if(!n.sameParent(o))return!0;if(!i)return!1;if(e.endOfTextblock(t>0?"forward":"backward"))return!0;let s=!n.textOffset&&(t<0?n.nodeBefore:n.nodeAfter);if(s&&!s.isText){let r=e.state.tr;return t<0?r.delete(n.pos-s.nodeSize,n.pos):r.delete(n.pos,n.pos+s.nodeSize),e.dispatch(r),!0}return!1}function Ue(e,t,n){e.domObserver.stop(),t.contentEditable=n,e.domObserver.start()}function Xe(e,t){let n=t.keyCode,r=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||D&&72==n&&"c"==r)return Je(e,-1)||Le(e,-1);if(46==n&&!t.shiftKey||D&&68==n&&"c"==r)return Je(e,1)||Le(e,1);if(13==n||27==n)return!0;if(37==n||D&&66==n&&"c"==r){let t=37==n?"ltr"==We(e,e.state.selection.from)?-1:1:-1;return Be(e,t,r)||Le(e,t)}if(39==n||D&&70==n&&"c"==r){let t=39==n?"ltr"==We(e,e.state.selection.from)?1:-1:1;return Be(e,t,r)||Le(e,t)}return 38==n||D&&80==n&&"c"==r?qe(e,-1,r)||Le(e,-1):40==n||D&&78==n&&"c"==r?function(e){if(!N||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;Ue(e,n,"true"),setTimeout(()=>Ue(e,n,"false"),20)}return!1}(e)||qe(e,1,r)||Ve(e):r==(D?"m":"c")&&(66==n||73==n||89==n||90==n)}function Ge(e,t){e.someProp("transformCopied",n=>{t=n(t,e)});let n=[],{content:r,openStart:i,openEnd:s}=t;for(;i>1&&s>1&&1==r.childCount&&1==r.firstChild.childCount;){i--,s--;let e=r.firstChild;n.push(e.type.name,e.attrs!=e.type.defaultAttrs?e.attrs:null),r=e.content}let l=e.someProp("clipboardSerializer")||o.DOMSerializer.fromSchema(e.state.schema),a=st(),c=a.createElement("div");c.appendChild(l.serializeFragment(r,{document:a}));let d,u=c.firstChild,h=0;for(;u&&1==u.nodeType&&(d=ot[u.nodeName.toLowerCase()]);){for(let e=d.length-1;e>=0;e--){let t=a.createElement(d[e]);for(;c.firstChild;)t.appendChild(c.firstChild);c.appendChild(t),h++}u=c.firstChild}return u&&1==u.nodeType&&u.setAttribute("data-pm-slice",`${i} ${s}${h?" -"+h:""} ${JSON.stringify(n)}`),{dom:c,text:e.someProp("clipboardTextSerializer",n=>n(t,e))||t.content.textBetween(0,t.content.size,"\n\n")}}function Ye(e,t,n,r,i){let s,l,a=i.parent.type.spec.code;if(!n&&!t)return null;let c=t&&(r||a||!n);if(c){if(e.someProp("transformPastedText",n=>{t=n(t,a||r,e)}),a)return t?new o.Slice(o.Fragment.from(e.state.schema.text(t.replace(/\r\n?/g,"\n"))),0,0):o.Slice.empty;let n=e.someProp("clipboardTextParser",n=>n(t,i,r,e));if(n)l=n;else{let n=i.marks(),{schema:r}=e.state,l=o.DOMSerializer.fromSchema(r);s=document.createElement("div"),t.split(/(?:\r\n?|\n)+/).forEach(e=>{let t=s.appendChild(document.createElement("p"));e&&t.appendChild(l.serializeNode(r.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,r=st().createElement("div"),o=/<([a-z][^>\s]+)/i.exec(e);(n=o&&ot[o[1].toLowerCase()])&&(e=n.map(e=>"<"+e+">").join("")+e+n.map(e=>"</"+e+">").reverse().join(""));if(r.innerHTML=e,n)for(let e=0;e<n.length;e++)r=r.querySelector(n[e])||r;return r}(n),P&&function(e){let t=e.querySelectorAll(T?"span:not([class]):not([style])":"span.Apple-converted-space");for(let n=0;n<t.length;n++){let r=t[n];1==r.childNodes.length&&" "==r.textContent&&r.parentNode&&r.parentNode.replaceChild(e.ownerDocument.createTextNode(" "),r)}}(s);let d=s&&s.querySelector("[data-pm-slice]"),u=d&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(d.getAttribute("data-pm-slice")||"");if(u&&u[3])for(let e=+u[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")||o.DOMParser.fromSchema(e.state.schema);l=t.parseSlice(s,{preserveWhitespace:!(!c&&!u),context:i,ruleFromNode:e=>"BR"!=e.nodeName||e.nextSibling||!e.parentNode||Qe.test(e.parentNode.nodeName)?null:{ignore:!0}})}if(u)l=function(e,t){if(!e.size)return e;let n,r=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=r.nodes[n[e]];if(!t||t.hasRequiredAttrs())break;i=o.Fragment.from(t.create(n[e+1],i)),s++,l++}return new o.Slice(i,s,l)}(rt(l,+u[1],+u[2]),u[4]);else if(l=o.Slice.maxOpen(function(e,t){if(e.childCount<2)return e;for(let n=t.depth;n>=0;n--){let r,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&&r.length&&et(n,r,e,s[s.length-1],0))s[s.length-1]=t;else{s.length&&(s[s.length-1]=tt(s[s.length-1],r.length));let t=Ze(e,n);s.push(t),i=i.matchType(t.type),r=n}}),s)return o.Fragment.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=rt(l,e,t)}return e.someProp("transformPasted",t=>{l=t(l,e)}),l}const Qe=/^(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 Ze(e,t,n=0){for(let r=t.length-1;r>=n;r--)e=t[r].create(null,o.Fragment.from(e));return e}function et(e,t,n,r,i){if(i<e.length&&i<t.length&&e[i]==t[i]){let s=et(e,t,n,r.lastChild,i+1);if(s)return r.copy(r.content.replaceChild(r.childCount-1,s));if(r.contentMatchAt(r.childCount).matchType(i==e.length-1?n.type:e[i+1]))return r.copy(r.content.append(o.Fragment.from(Ze(n,e,i+1))))}}function tt(e,t){if(0==t)return e;let n=e.content.replaceChild(e.childCount-1,tt(e.lastChild,t-1)),r=e.contentMatchAt(e.childCount).fillBefore(o.Fragment.empty,!0);return e.copy(n.append(r))}function nt(e,t,n,r,i,s){let l=t<0?e.firstChild:e.lastChild,a=l.content;return e.childCount>1&&(s=0),i<r-1&&(a=nt(a,t,n,r,i+1,s)),i>=n&&(a=t<0?l.contentMatchAt(0).fillBefore(a,s<=i).append(a):a.append(l.contentMatchAt(l.childCount).fillBefore(o.Fragment.empty,!0))),e.replaceChild(t<0?0:e.childCount-1,l.copy(a))}function rt(e,t,n){return t<e.openStart&&(e=new o.Slice(nt(e.content,-1,t,e.openStart,0,e.openEnd),t,e.openEnd)),n<e.openEnd&&(e=new o.Slice(nt(e.content,1,n,e.openEnd,0,0),e.openStart,n)),e}const ot={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 it=null;function st(){return it||(it=document.implementation.createHTMLDocument("title"))}const lt={},at={},ct={touchstart:!0,touchmove:!0};class dt{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.lastAndroidDelete=0,this.composing=!1,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 ut(e,t){e.input.lastSelectionOrigin=t,e.input.lastSelectionTime=Date.now()}function ht(e){e.someProp("handleDOMEvents",t=>{for(let n in t)e.input.eventHandlers[n]||e.dom.addEventListener(n,e.input.eventHandlers[n]=t=>pt(e,t))})}function pt(e,t){return e.someProp("handleDOMEvents",n=>{let r=n[t.type];return!!r&&(r(e,t)||t.defaultPrevented)})}function ft(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 mt(e){return{left:e.clientX,top:e.clientY}}function gt(e,t,n,r,o){if(-1==r)return!1;let i=e.state.doc.resolve(r);for(let r=i.depth+1;r>0;r--)if(e.someProp(t,t=>r>i.depth?t(e,n,i.nodeAfter,i.before(r),o,!0):t(e,n,i.node(r),i.before(r),o,!1)))return!0;return!1}function yt(e,t,n){e.focused||e.focus();let r=e.state.tr.setSelection(t);"pointer"==n&&r.setMeta("pointer",!0),e.dispatch(r)}function vt(e,t,n,o,i){return gt(e,"handleClickOn",t,n,o)||e.someProp("handleClick",n=>n(e,t,o))||(i?function(e,t){if(-1==t)return!1;let n,o,i=e.state.selection;i instanceof r.NodeSelection&&(n=i.node);let s=e.state.doc.resolve(t);for(let e=s.depth+1;e>0;e--){let t=e>s.depth?s.nodeAfter:s.node(e);if(r.NodeSelection.isSelectable(t)){o=n&&i.$from.depth>0&&e>=i.$from.depth&&s.before(i.$from.depth+1)==i.$from.pos?s.before(i.$from.depth):s.before(e);break}}return null!=o&&(yt(e,r.NodeSelection.create(e.state.doc,o),"pointer"),!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&&r.NodeSelection.isSelectable(o))&&(yt(e,new r.NodeSelection(n),"pointer"),!0)}(e,n))}function bt(e,t,n,r){return gt(e,"handleDoubleClickOn",t,n,r)||e.someProp("handleDoubleClick",n=>n(e,t,r))}function wt(e,t,n,o){return gt(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&&(yt(e,r.TextSelection.create(o,0,o.content.size),"pointer"),!0);let i=o.resolve(t);for(let t=i.depth+1;t>0;t--){let n=t>i.depth?i.nodeAfter:i.node(t),s=i.before(t);if(n.inlineContent)yt(e,r.TextSelection.create(o,s+1,s+1+n.content.size),"pointer");else{if(!r.NodeSelection.isSelectable(n))continue;yt(e,r.NodeSelection.create(o,s),"pointer")}return!0}}(e,n,o)}function St(e){return At(e)}at.keydown=(e,t)=>{let n=t;if(e.input.shiftKey=16==n.keyCode||n.shiftKey,!Ct(e,n)&&(e.input.lastKeyCode=n.keyCode,e.input.lastKeyCodeTime=Date.now(),!E||!T||13!=n.keyCode))if(229!=n.keyCode&&e.domObserver.forceFlush(),!R||13!=n.keyCode||n.ctrlKey||n.altKey||n.metaKey)e.someProp("handleKeyDown",t=>t(e,n))||Xe(e,n)?n.preventDefault():ut(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,g(13,"Enter"))),e.input.lastIOSEnter=0)},200)}},at.keyup=(e,t)=>{16==t.keyCode&&(e.input.shiftKey=!1)},at.keypress=(e,t)=>{let n=t;if(Ct(e,n)||!n.charCode||n.ctrlKey&&!n.altKey||D&&n.metaKey)return;if(e.someProp("handleKeyPress",t=>t(e,n)))return void n.preventDefault();let o=e.state.selection;if(!(o instanceof r.TextSelection&&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 kt=D?"metaKey":"ctrlKey";lt.mousedown=(e,t)=>{let n=t;e.input.shiftKey=n.shiftKey;let r=St(e),o=Date.now(),i="singleClick";o-e.input.lastClick.time<500&&function(e,t){let n=t.x-e.clientX,r=t.y-e.clientY;return n*n+r*r<100}(n,e.input.lastClick)&&!n[kt]&&("singleClick"==e.input.lastClick.type?i="doubleClick":"doubleClick"==e.input.lastClick.type&&(i="tripleClick")),e.input.lastClick={time:o,x:n.clientX,y:n.clientY,type:i};let s=e.posAtCoords(mt(n));s&&("singleClick"==i?(e.input.mouseDown&&e.input.mouseDown.done(),e.input.mouseDown=new xt(e,s,n,!!r)):("doubleClick"==i?bt:wt)(e,s.pos,s.inside,n)?n.preventDefault():ut(e,"pointer"))};class xt{constructor(e,t,n,o){let i,s;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[kt],this.allowDefault=n.shiftKey,t.inside>-1)i=e.state.doc.nodeAt(t.inside),s=t.inside;else{let n=e.state.doc.resolve(t.pos);i=n.parent,s=n.depth?n.before():0}const l=o?null:n.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a?a.dom:null;let{selection:c}=e.state;(0==n.button&&i.type.spec.draggable&&!1!==i.type.spec.selectable||c instanceof r.NodeSelection&&c.from<=s&&c.to>s)&&(this.mightDrag={node:i,pos:s,addAttr:!(!this.target||this.target.draggable),setUneditable:!(!this.target||!M||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)),ut(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(()=>Oe(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(mt(e))),this.updateAllowDefault(e),this.allowDefault||!t?ut(this.view,"pointer"):vt(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():0==e.button&&(this.flushed||N&&this.mightDrag&&!this.mightDrag.node.isAtom||T&&!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)?(yt(this.view,r.Selection.near(this.view.state.doc.resolve(t.pos)),"pointer"),e.preventDefault()):ut(this.view,"pointer")}move(e){this.updateAllowDefault(e),ut(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 Ct(e,t){return!!e.composing||!!(N&&Math.abs(t.timeStamp-e.input.compositionEndedAt)<500)&&(e.input.compositionEndedAt=-2e8,!0)}lt.touchstart=e=>{e.input.lastTouch=Date.now(),St(e),ut(e,"pointer")},lt.touchmove=e=>{e.input.lastTouch=Date.now(),ut(e,"pointer")},lt.contextmenu=e=>St(e);const Mt=E?5e3:-1;function Ot(e,t){clearTimeout(e.input.composingTimeout),t>-1&&(e.input.composingTimeout=setTimeout(()=>At(e),t))}function Tt(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 At(e,t=!1){if(!(E&&e.domObserver.flushingSoon>=0)){if(e.domObserver.forceFlush(),Tt(e),t||e.docView&&e.docView.dirty){let t=Ce(e);return t&&!t.eq(e.state.selection)?e.dispatch(e.state.tr.setSelection(t)):e.updateState(e.state),!0}return!1}}at.compositionstart=at.compositionupdate=e=>{if(!e.composing){e.domObserver.flush();let{state:t}=e,n=t.selection.$from;if(t.selection.empty&&(t.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(e=>!1===e.type.spec.inclusive)))e.markCursor=e.state.storedMarks||n.marks(),At(e,!0),e.markCursor=null;else if(At(e),M&&t.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let t=e.domSelectionRange();for(let n=t.focusNode,r=t.focusOffset;n&&1==n.nodeType&&0!=r;){let t=r<0?n.lastChild:n.childNodes[r-1];if(!t)break;if(3==t.nodeType){e.domSelection().collapse(t,t.nodeValue.length);break}n=t,r=-1}}e.input.composing=!0}Ot(e,Mt)},at.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.compositionPendingChanges&&Promise.resolve().then(()=>e.domObserver.flush()),e.input.compositionID++,Ot(e,20))};const Nt=x&&C<15||R&&z<604;function Rt(e,t,n,r,i){let s=Ye(e,t,n,r,e.state.selection.$from);if(e.someProp("handlePaste",t=>t(e,i,s||o.Slice.empty)))return!0;if(!s)return!1;let l=function(e){return 0==e.openStart&&0==e.openEnd&&1==e.content.childCount?e.content.firstChild:null}(s),a=l?e.state.tr.replaceSelectionWith(l,r):e.state.tr.replaceSelection(s);return e.dispatch(a.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}lt.copy=at.cut=(e,t)=>{let n=t,r=e.state.selection,o="cut"==n.type;if(r.empty)return;let i=Nt?null:n.clipboardData,s=r.content(),{dom:l,text:a}=Ge(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 r=getSelection(),o=document.createRange();o.selectNodeContents(t),e.dom.blur(),r.removeAllRanges(),r.addRange(o),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),e.focus()},50)}(e,l),o&&e.dispatch(e.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))},at.paste=(e,t)=>{let n=t;if(e.composing&&!E)return;let r=Nt?null:n.clipboardData,o=e.input.shiftKey&&45!=e.input.lastKeyCode;r&&Rt(e,r.getData("text/plain"),r.getData("text/html"),o,n)?n.preventDefault():function(e,t){if(!e.dom.parentNode)return;let n=e.input.shiftKey||e.state.selection.$from.parent.type.spec.code,r=e.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let o=e.input.shiftKey&&45!=e.input.lastKeyCode;setTimeout(()=>{e.focus(),r.parentNode&&r.parentNode.removeChild(r),n?Rt(e,r.value,null,o,t):Rt(e,r.textContent,r.innerHTML,o,t)},50)}(e,n)};class Dt{constructor(e,t){this.slice=e,this.move=t}}const _t=D?"altKey":"ctrlKey";lt.dragstart=(e,t)=>{let n=t,o=e.input.mouseDown;if(o&&o.done(),!n.dataTransfer)return;let i=e.state.selection,s=i.empty?null:e.posAtCoords(mt(n));if(s&&s.pos>=i.from&&s.pos<=(i instanceof r.NodeSelection?i.to-1:i.to));else if(o&&o.mightDrag)e.dispatch(e.state.tr.setSelection(r.NodeSelection.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&&e.dispatch(e.state.tr.setSelection(r.NodeSelection.create(e.state.doc,t.posBefore)))}let l=e.state.selection.content(),{dom:a,text:c}=Ge(e,l);n.dataTransfer.clearData(),n.dataTransfer.setData(Nt?"Text":"text/html",a.innerHTML),n.dataTransfer.effectAllowed="copyMove",Nt||n.dataTransfer.setData("text/plain",c),e.dragging=new Dt(l,!n[_t])},lt.dragend=e=>{let t=e.dragging;window.setTimeout(()=>{e.dragging==t&&(e.dragging=null)},50)},at.dragover=at.dragenter=(e,t)=>t.preventDefault(),at.drop=(e,t)=>{let n=t,s=e.dragging;if(e.dragging=null,!n.dataTransfer)return;let l=e.posAtCoords(mt(n));if(!l)return;let a=e.state.doc.resolve(l.pos),c=s&&s.slice;c?e.someProp("transformPasted",t=>{c=t(c,e)}):c=Ye(e,n.dataTransfer.getData(Nt?"Text":"text/plain"),Nt?null:n.dataTransfer.getData("text/html"),!1,a);let d=!(!s||n[_t]);if(e.someProp("handleDrop",t=>t(e,n,c||o.Slice.empty,d)))return void n.preventDefault();if(!c)return;n.preventDefault();let u=c?Object(i.dropPoint)(e.state.doc,a.pos,c):a.pos;null==u&&(u=a.pos);let h=e.state.tr;d&&h.deleteSelection();let p=h.mapping.map(u),f=0==c.openStart&&0==c.openEnd&&1==c.content.childCount,m=h.doc;if(f?h.replaceRangeWith(p,p,c.content.firstChild):h.replaceRange(p,p,c),h.doc.eq(m))return;let g=h.doc.resolve(p);if(f&&r.NodeSelection.isSelectable(c.content.firstChild)&&g.nodeAfter&&g.nodeAfter.sameMarkup(c.content.firstChild))h.setSelection(new r.NodeSelection(g));else{let t=h.mapping.map(u);h.mapping.maps[h.mapping.maps.length-1].forEach((e,n,r,o)=>t=o),h.setSelection(Ee(e,g,h.doc.resolve(t)))}e.focus(),e.dispatch(h.setMeta("uiEvent","drop"))},lt.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())&&Oe(e)},20))},lt.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)},lt.beforeinput=(e,t)=>{if(T&&E&&"deleteContentBackward"==t.inputType){e.domObserver.flushSoon();let{domChangeCount:t}=e.input;setTimeout(()=>{if(e.input.domChangeCount!=t)return;if(e.dom.blur(),e.focus(),e.someProp("handleKeyDown",t=>t(e,g(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 at)lt[e]=at[e];function Et(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 Pt{constructor(e,t){this.toDOM=e,this.spec=t||jt,this.side=this.spec.side||0}map(e,t,n,r){let{pos:o,deleted:i}=e.mapResult(t.from+r,this.side<0?-1:1);return i?null:new Ft(o-n,o-n,this)}valid(){return!0}eq(e){return this==e||e instanceof Pt&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Et(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class zt{constructor(e,t){this.attrs=e,this.spec=t||jt}map(e,t,n,r){let o=e.map(t.from+r,this.spec.inclusiveStart?-1:1)-n,i=e.map(t.to+r,this.spec.inclusiveEnd?1:-1)-n;return o>=i?null:new Ft(o,i,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof zt&&Et(this.attrs,e.attrs)&&Et(this.spec,e.spec)}static is(e){return e.type instanceof zt}destroy(){}}class It{constructor(e,t){this.attrs=e,this.spec=t||jt}map(e,t,n,r){let o=e.mapResult(t.from+r,1);if(o.deleted)return null;let i=e.mapResult(t.to+r,-1);return i.deleted||i.pos<=o.pos?null:new Ft(o.pos-n,i.pos-n,this)}valid(e,t){let n,{index:r,offset:o}=e.content.findIndex(t.from);return o==t.from&&!(n=e.child(r)).isText&&o+n.nodeSize==t.to}eq(e){return this==e||e instanceof It&&Et(this.attrs,e.attrs)&&Et(this.spec,e.spec)}destroy(){}}class Ft{constructor(e,t,n){this.from=e,this.to=t,this.type=n}copy(e,t){return new Ft(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 Ft(e,e,new Pt(t,n))}static inline(e,t,n,r){return new Ft(e,t,new zt(n,r))}static node(e,t,n,r){return new Ft(e,t,new It(n,r))}get spec(){return this.type.spec}get inline(){return this.type instanceof zt}}const Bt=[],jt={};class $t{constructor(e,t){this.local=e.length?e:Bt,this.children=t.length?t:Bt}static create(e,t){return t.length?qt(t,e,0,jt):Lt}find(e,t,n){let r=[];return this.findInner(null==e?0:e,null==t?1e9:t,r,0,n),r}findInner(e,t,n,r,o){for(let i=0;i<this.local.length;i++){let s=this.local[i];s.from<=t&&s.to>=e&&(!o||o(s.spec))&&n.push(s.copy(s.from+r,s.to+r))}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,r+s,o)}}map(e,t,n){return this==Lt||0==e.maps.length?this:this.mapInner(e,t,0,0,n||jt)}mapInner(e,t,n,r,o){let i;for(let s=0;s<this.local.length;s++){let l=this.local[s].map(e,n,r);l&&l.type.valid(t,l)?(i||(i=[])).push(l):o.onRemove&&o.onRemove(this.local[s].spec)}return this.children.length?function(e,t,n,r,o,i,s){let l=e.slice();for(let e=0,t=i;e<n.maps.length;e++){let r=0;n.maps[e].forEach((e,n,i,s)=>{let a=s-i-(n-e);for(let s=0;s<l.length;s+=3){let c=l[s+1];if(c<0||e>c+t-r)continue;let d=l[s]+t-r;n>=d?l[s+1]=e<=d?-2:-1:i>=o&&a&&(l[s]+=a,l[s+1]+=a)}r+=a}),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-o;if(d<0||d>=r.content.size){a=!0;continue}let u=n.map(e[t+1]+i,-1)-o,{index:h,offset:p}=r.content.findIndex(d),f=r.maybeChild(h);if(f&&p==d&&p+f.nodeSize==u){let r=l[t+2].mapInner(n,f,c+1,e[t]+i+1,s);r!=Lt?(l[t]=d,l[t+1]=u,l[t+2]=r):(l[t+1]=-2,a=!0)}else a=!0}if(a){let a=qt(function(e,t,n,r,o,i,s){function l(e,t){for(let i=0;i<e.local.length;i++){let l=e.local[i].map(r,o,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,o,i,s),r,0,s);t=a.local;for(let e=0;e<l.length;e+=3)l[e+1]<0&&(l.splice(e,3),e-=3);for(let e=0,t=0;e<a.children.length;e+=3){let n=a.children[e];for(;t<l.length&&l[t]<n;)t+=3;l.splice(t,0,a.children[e],a.children[e+1],a.children[e+2])}}return new $t(t.sort(Jt),l)}(this.children,i||[],e,t,n,r,o):i?new $t(i.sort(Jt),Bt):Lt}add(e,t){return t.length?this==Lt?$t.create(e,t):this.addInner(e,t,0):this}addInner(e,t,n){let r,o=0;e.forEach((e,i)=>{let s,l=i+n;if(s=Ht(t,e,l)){for(r||(r=this.children.slice());o<r.length&&r[o]<i;)o+=3;r[o]==i?r[o+2]=r[o+2].addInner(e,s,l+1):r.splice(o,0,i,i+e.nodeSize,qt(s,e,l+1,jt)),o+=3}});let i=Kt(o?Wt(t):t,-n);for(let t=0;t<i.length;t++)i[t].type.valid(e,i[t])||i.splice(t--,1);return new $t(i.length?this.local.concat(i).sort(Jt):this.local,r||this.children)}remove(e){return 0==e.length||this==Lt?this:this.removeInner(e,0)}removeInner(e,t){let n=this.children,r=this.local;for(let r=0;r<n.length;r+=3){let o,i=n[r]+t,s=n[r+1]+t;for(let t,n=0;n<e.length;n++)(t=e[n])&&t.from>i&&t.to<s&&(e[n]=null,(o||(o=[])).push(t));if(!o)continue;n==this.children&&(n=this.children.slice());let l=n[r+2].removeInner(o,i+1);l!=Lt?n[r+2]=l:(n.splice(r,3),r-=3)}if(r.length)for(let n,o=0;o<e.length;o++)if(n=e[o])for(let e=0;e<r.length;e++)r[e].eq(n,t)&&(r==this.local&&(r=this.local.slice()),r.splice(e--,1));return n==this.children&&r==this.local?this:r.length||n.length?new $t(r,n):Lt}forChild(e,t){if(this==Lt)return this;if(t.isLeaf)return $t.empty;let n,r;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 o=e+1,i=o+t.content.size;for(let e=0;e<this.local.length;e++){let t=this.local[e];if(t.from<i&&t.to>o&&t.type instanceof zt){let e=Math.max(o,t.from)-o,n=Math.min(i,t.to)-o;e<n&&(r||(r=[])).push(t.copy(e,n))}}if(r){let e=new $t(r.sort(Jt),Bt);return n?new Vt([e,n]):e}return n||Lt}eq(e){if(this==e)return!0;if(!(e instanceof $t)||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 Ut(this.localsInner(e))}localsInner(e){if(this==Lt)return Bt;if(e.inlineContent||!this.local.some(zt.is))return this.local;let t=[];for(let e=0;e<this.local.length;e++)this.local[e].type instanceof zt||t.push(this.local[e]);return t}}$t.empty=new $t([],[]),$t.removeOverlap=Ut;const Lt=$t.empty;class Vt{constructor(e){this.members=e}map(e,t){const n=this.members.map(n=>n.map(e,t,jt));return Vt.from(n)}forChild(e,t){if(t.isLeaf)return $t.empty;let n=[];for(let r=0;r<this.members.length;r++){let o=this.members[r].forChild(e,t);o!=Lt&&(o instanceof Vt?n=n.concat(o.members):n.push(o))}return Vt.from(n)}eq(e){if(!(e instanceof Vt)||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 r=0;r<this.members.length;r++){let o=this.members[r].localsInner(e);if(o.length)if(t){n&&(t=t.slice(),n=!1);for(let e=0;e<o.length;e++)t.push(o[e])}else t=o}return t?Ut(n?t:t.sort(Jt)):Bt}static from(e){switch(e.length){case 0:return Lt;case 1:return e[0];default:return new Vt(e.every(e=>e instanceof $t)?e:e.reduce((e,t)=>e.concat(t instanceof $t?t:t.members),[]))}}}function Kt(e,t){if(!t||!e.length)return e;let n=[];for(let r=0;r<e.length;r++){let o=e[r];n.push(new Ft(o.from+t,o.to+t,o.type))}return n}function Ht(e,t,n){if(t.isLeaf)return null;let r=n+t.nodeSize,o=null;for(let t,i=0;i<e.length;i++)(t=e[i])&&t.from>n&&t.to<r&&((o||(o=[])).push(t),e[i]=null);return o}function Wt(e){let t=[];for(let n=0;n<e.length;n++)null!=e[n]&&t.push(e[n]);return t}function qt(e,t,n,r){let o=[],i=!1;t.forEach((t,s)=>{let l=Ht(e,t,s+n);if(l){i=!0;let e=qt(l,t,n+s+1,r);e!=Lt&&o.push(s,s+t.nodeSize,e)}});let s=Kt(i?Wt(e):e,-n).sort(Jt);for(let e=0;e<s.length;e++)s[e].type.valid(t,s[e])||(r.onRemove&&r.onRemove(s[e].spec),s.splice(e--,1));return s.length||o.length?new $t(s,o):Lt}function Jt(e,t){return e.from-t.from||e.to-t.to}function Ut(e){let t=e;for(let n=0;n<t.length-1;n++){let r=t[n];if(r.from!=r.to)for(let o=n+1;o<t.length;o++){let i=t[o];if(i.from!=r.from){i.from<r.to&&(t==e&&(t=e.slice()),t[n]=r.copy(r.from,i.from),Xt(t,o,r.copy(i.from,r.to)));break}i.to!=r.to&&(t==e&&(t=e.slice()),t[o]=i.copy(i.from,r.to),Xt(t,o+1,i.copy(r.to,i.to)))}}return t}function Xt(e,t,n){for(;t<e.length&&Jt(n,e[t])>0;)t++;e.splice(t,0,n)}function Gt(e){let t=[];return e.someProp("decorations",n=>{let r=n(e.state);r&&r!=Lt&&t.push(r)}),e.cursorWrapper&&t.push($t.create(e.state.doc,[e.cursorWrapper.deco])),Vt.from(t)}const Yt={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},Qt=x&&C<=11;class Zt{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 en{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new Zt,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.observer=window.MutationObserver&&new window.MutationObserver(e=>{for(let t=0;t<e.length;t++)this.queue.push(e[t]);x&&C<=11&&e.some(e=>"childList"==e.type&&e.removedNodes.length||"characterData"==e.type&&e.oldValue.length>e.target.nodeValue.length)?this.flushSoon():this.flush()}),Qt&&(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,Yt)),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(Pe(this.view)){if(this.suppressingSelectionUpdates)return Oe(this.view);if(x&&C<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&d(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=l(t))n.add(t);for(let r=e.anchorNode;r;r=l(r))if(n.has(r)){t=r;break}let r=t&&this.view.docView.nearestDesc(t);return r&&r.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)&&Pe(e)&&!this.ignoreSelectionChange(n),i=-1,s=-1,l=!1,a=[];if(e.editable)for(let e=0;e<t.length;e++){let n=this.registerMutation(t[e],a);n&&(i=i<0?n.from:Math.min(n.from,i),s=s<0?n.to:Math.max(n.to,s),n.typeOver&&(l=!0))}if(M&&a.length>1){let e=a.filter(e=>"BR"==e.nodeName);if(2==e.length){let t=e[0],n=e[1];t.parentNode&&t.parentNode.parentNode==n.parentNode?n.remove():t.remove()}}let c=null;i<0&&o&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&m(n)&&(c=Ce(e))&&c.eq(r.Selection.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,Oe(e),this.currentSelection.set(n),e.scrollToSelection()):(i>-1||o)&&(i>-1&&(e.docView.markDirty(i,s),function(e){if(tn.has(e))return;if(tn.set(e,null),-1!==["normal","nowrap","pre-line"].indexOf(getComputedStyle(e.dom).whiteSpace)){if(e.requiresGeckoHackNode=M,nn)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."),nn=!0}}(e)),this.handleDOMChange(i,s,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(n)||Oe(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++)t.push(e.addedNodes[n]);if(n.contentDOM&&n.contentDOM!=n.dom&&!n.contentDOM.contains(e.target))return{from:n.posBefore,to:n.posAfter};let r=e.previousSibling,o=e.nextSibling;if(x&&C<=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)&&(r=n),(!i||Array.prototype.indexOf.call(e.addedNodes,i)<0)&&(o=i)}let i=r&&r.parentNode==e.target?s(r)+1:0,l=n.localPosFromDOM(e.target,i,-1),a=o&&o.parentNode==e.target?s(o):e.target.childNodes.length;return{from:l,to:n.localPosFromDOM(e.target,a,1)}}return"attributes"==e.type?{from:n.posAtStart-n.border,to:n.posAtEnd+n.border}:{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}}}let tn=new WeakMap,nn=!1;function rn(e){let t=e.pmViewDesc;if(t)return t.parseRule();if("BR"==e.nodeName&&e.parentNode){if(N&&/^(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||N&&/^(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 on=/^(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 sn(e,t,n,i,s){let l=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=Ce(e,t);if(n&&!e.state.selection.eq(n)){if(T&&E&&13===e.input.lastKeyCode&&Date.now()-100<e.input.lastKeyCodeTime&&e.someProp("handleKeyDown",t=>t(e,g(13,"Enter"))))return;let r=e.state.tr.setSelection(n);"pointer"==t?r.setMeta("pointer",!0):"key"==t&&r.scrollIntoView(),l&&r.setMeta("composition",l),e.dispatch(r)}return}let a=e.state.doc.resolve(t),c=a.sharedDepth(n);t=a.before(c+1),n=e.state.doc.resolve(n).after(c+1);let d,u,h=e.state.selection,p=function(e,t,n){let r,{node:i,fromOffset:s,toOffset:l,from:a,to:c}=e.docView.parseRange(t,n),d=e.domSelectionRange(),u=d.anchorNode;if(u&&e.dom.contains(1==u.nodeType?u:u.parentNode)&&(r=[{node:u,offset:d.anchorOffset}],m(d)||r.push({node:d.focusNode,offset:d.focusOffset})),T&&8===e.input.lastKeyCode)for(let e=l;e>s;e--){let t=i.childNodes[e-1],n=t.pmViewDesc;if("BR"==t.nodeName&&!n){l=e;break}if(!n||n.size)break}let h=e.state.doc,p=e.someProp("domParser")||o.DOMParser.fromSchema(e.state.schema),f=h.resolve(a),g=null,y=p.parse(i,{topNode:f.parent,topMatch:f.parent.contentMatchAt(f.index()),topOpen:!0,from:s,to:l,preserveWhitespace:"pre"!=f.parent.type.whitespace||"full",findPositions:r,ruleFromNode:rn,context:f});if(r&&null!=r[0].pos){let e=r[0].pos,t=r[1]&&r[1].pos;null==t&&(t=e),g={anchor:e+a,head:t+a}}return{doc:y,sel:g,from:a,to:c}}(e,t,n),f=e.state.doc,y=f.slice(p.from,p.to);8===e.input.lastKeyCode&&Date.now()-100<e.input.lastKeyCodeTime?(d=e.state.selection.to,u="end"):(d=e.state.selection.from,u="start"),e.input.lastKeyCode=null;let v=function(e,t,n,r,o){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"==o){let e=Math.max(0,i-Math.min(s,l));r-=s+e-i}if(s<i&&e.size<t.size){i-=r<=i&&r>=s?i-r:0,l=i+(l-s),s=i}else if(l<i){i-=r<=i&&r>=l?i-r:0,s=i+(s-l),l=i}return{start:i,endA:s,endB:l}}(y.content,p.doc.content,p.from,d,u);if((R&&e.input.lastIOSEnter>Date.now()-225||E)&&s.some(e=>1==e.nodeType&&!on.test(e.nodeName))&&(!v||v.endA>=v.endB)&&e.someProp("handleKeyDown",t=>t(e,g(13,"Enter"))))return void(e.input.lastIOSEnter=0);if(!v){if(!(i&&h instanceof r.TextSelection&&!h.empty&&h.$head.sameParent(h.$anchor))||e.composing||p.sel&&p.sel.anchor!=p.sel.head){if(p.sel){let t=ln(e,e.state.doc,p.sel);if(t&&!t.eq(e.state.selection)){let n=e.state.tr.setSelection(t);l&&n.setMeta("composition",l),e.dispatch(n)}}return}v={start:h.from,endA:h.to,endB:h.to}}if(T&&e.cursorWrapper&&p.sel&&p.sel.anchor==e.cursorWrapper.deco.from&&p.sel.head==p.sel.anchor){let e=v.endB-v.start;p.sel={anchor:p.sel.anchor+e,head:p.sel.anchor+e}}e.input.domChangeCount++,e.state.selection.from<e.state.selection.to&&v.start==v.endB&&e.state.selection instanceof r.TextSelection&&(v.start>e.state.selection.from&&v.start<=e.state.selection.from+2&&e.state.selection.from>=p.from?v.start=e.state.selection.from:v.endA<e.state.selection.to&&v.endA>=e.state.selection.to-2&&e.state.selection.to<=p.to&&(v.endB+=e.state.selection.to-v.endA,v.endA=e.state.selection.to)),x&&C<=11&&v.endB==v.start+1&&v.endA==v.start&&v.start>p.from&&"  "==p.doc.textBetween(v.start-p.from-1,v.start-p.from+1)&&(v.start--,v.endA--,v.endB--);let b,w=p.doc.resolveNoCache(v.start-p.from),S=p.doc.resolveNoCache(v.endB-p.from),k=f.resolve(v.start),M=w.sameParent(S)&&w.parent.inlineContent&&k.end()>=v.endA;if((R&&e.input.lastIOSEnter>Date.now()-225&&(!M||s.some(e=>"DIV"==e.nodeName||"P"==e.nodeName))||!M&&w.pos<p.doc.content.size&&!w.sameParent(S)&&(b=r.Selection.findFrom(p.doc.resolve(w.pos+1),1,!0))&&b.head==S.pos)&&e.someProp("handleKeyDown",t=>t(e,g(13,"Enter"))))return void(e.input.lastIOSEnter=0);if(e.state.selection.anchor>v.start&&function(e,t,n,r,o){if(!r.parent.isTextblock||n-t<=o.pos-r.pos||an(r,!0,!1)<o.pos)return!1;let i=e.resolve(t);if(i.parentOffset<i.parent.content.size||!i.parent.isTextblock)return!1;let s=e.resolve(an(i,!0,!0));return!(!s.parent.isTextblock||s.pos>n||an(s,!0,!1)<n)&&r.parent.content.cut(r.parentOffset).eq(s.parent.content)}(f,v.start,v.endA,w,S)&&e.someProp("handleKeyDown",t=>t(e,g(8,"Backspace"))))return void(E&&T&&e.domObserver.suppressSelectionUpdates());T&&E&&v.endB==v.start&&(e.input.lastAndroidDelete=Date.now()),E&&!M&&w.start()!=S.start()&&0==S.parentOffset&&w.depth==S.depth&&p.sel&&p.sel.anchor==p.sel.head&&p.sel.head==v.endA&&(v.endB-=2,S=p.doc.resolveNoCache(v.endB-p.from),setTimeout(()=>{e.someProp("handleKeyDown",(function(t){return t(e,g(13,"Enter"))}))},20));let O,A,N,D=v.start,_=v.endA;if(M)if(w.pos==S.pos)x&&C<=11&&0==w.parentOffset&&(e.domObserver.suppressSelectionUpdates(),setTimeout(()=>Oe(e),20)),O=e.state.tr.delete(D,_),A=f.resolve(v.start).marksAcross(f.resolve(v.endA));else if(v.endA==v.endB&&(N=function(e,t){let n,r,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)r=a[0],n="add",i=e=>e.mark(r.addToSet(e.marks));else{if(0!=a.length||1!=c.length)return null;r=c[0],n="remove",i=e=>e.mark(r.removeFromSet(e.marks))}let d=[];for(let e=0;e<t.childCount;e++)d.push(i(t.child(e)));if(o.Fragment.from(d).eq(e))return{mark:r,type:n}}(w.parent.content.cut(w.parentOffset,S.parentOffset),k.parent.content.cut(k.parentOffset,v.endA-k.start()))))O=e.state.tr,"add"==N.type?O.addMark(D,_,N.mark):O.removeMark(D,_,N.mark);else if(w.parent.child(w.index()).isText&&w.index()==S.index()-(S.textOffset?0:1)){let t=w.parent.textBetween(w.parentOffset,S.parentOffset);if(e.someProp("handleTextInput",n=>n(e,D,_,t)))return;O=e.state.tr.insertText(t,D,_)}if(O||(O=e.state.tr.replace(D,_,p.doc.slice(v.start-p.from,v.endB-p.from))),p.sel){let t=ln(e,O.doc,p.sel);t&&!(T&&E&&e.composing&&t.empty&&(v.start!=v.endB||e.input.lastAndroidDelete<Date.now()-100)&&(t.head==D||t.head==O.mapping.map(_)-1)||x&&t.empty&&t.head==D)&&O.setSelection(t)}A&&O.ensureMarks(A),l&&O.setMeta("composition",l),e.dispatch(O.scrollIntoView())}function ln(e,t,n){return Math.max(n.anchor,n.head)>t.content.size?null:Ee(e,t.resolve(n.anchor),t.resolve(n.head))}function an(e,t,n){let r=e.depth,o=t?e.end():e.pos;for(;r>0&&(t||e.indexAfter(r)==e.node(r).childCount);)r--,o++,t=!1;if(n){let t=e.node(r).maybeChild(e.indexAfter(r));for(;t&&!t.isLeaf;)t=t.firstChild,o++}return o}const cn=Ge,dn=Ye,un=At;class hn{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 dt,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(yn),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=mn(this),fn(this),this.nodeViews=gn(this),this.docView=ce(this.state.doc,pn(this),Gt(this),this.dom,this),this.domObserver=new en(this,(e,t,n,r)=>sn(this,e,t,n,r)),this.domObserver.start(),function(e){for(let t in lt){let n=lt[t];e.dom.addEventListener(t,e.input.eventHandlers[t]=t=>{!ft(e,t)||pt(e,t)||!e.editable&&t.type in at||n(e,t)},ct[t]?{passive:!0}:void 0)}N&&e.dom.addEventListener("input",()=>null),ht(e)}(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let t in e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&ht(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(yn),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){let n=this.state,r=!1,o=!1;e.storedMarks&&this.composing&&(Tt(this),o=!0),this.state=e;let i=n.plugins!=e.plugins||this._props.plugins!=t.plugins;if(i||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let e=gn(this);(function(e,t){let n=0,r=0;for(let r in e){if(e[r]!=t[r])return!0;n++}for(let e in t)r++;return n!=r})(e,this.nodeViews)&&(this.nodeViews=e,r=!0)}(i||t.handleDOMEvents!=this._props.handleDOMEvents)&&ht(this),this.editable=mn(this),fn(this);let s=Gt(this),l=pn(this),a=n.plugins==e.plugins||n.doc.eq(e.doc)?e.scrollToSelection>n.scrollToSelection?"to selection":"preserve":"reset",c=r||!this.docView.matchesNode(e.doc,l,s);!c&&e.selection.eq(n.selection)||(o=!0);let u="preserve"==a&&o&&null==this.dom.style.overflowAnchor&&function(e){let t,n,r=e.dom.getBoundingClientRect(),o=Math.max(0,r.top);for(let i=(r.left+r.right)/2,s=o+1;s<Math.min(innerHeight,r.bottom);s+=5){let r=e.root.elementFromPoint(i,s);if(!r||r==e.dom||!e.dom.contains(r))continue;let l=r.getBoundingClientRect();if(l.top>=o-20){t=r,n=l.top;break}}return{refDOM:t,refTop:n,stack:$(e.dom)}}(this);if(o){this.domObserver.stop();let t=c&&(x||T)&&!this.composing&&!n.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)}(n.selection,e.selection);if(c){let n=T?this.trackWrites=this.domSelectionRange().focusNode:null;!r&&this.docView.update(e.doc,l,s,this)||(this.docView.updateOuterDeco([]),this.docView.destroy(),this.docView=ce(e.doc,l,s,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 d(t.node,t.offset,n.anchorNode,n.anchorOffset)}(this))?Oe(this,t):(De(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(n),"reset"==a?this.dom.scrollTop=0:"to selection"==a?this.scrollToSelection():u&&function({refDOM:e,refTop:t,stack:n}){let r=e?e.getBoundingClientRect().top:0;L(n,0==r?0:r-t)}(u)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(this.someProp("handleScrollToSelection",e=>e(this)));else if(this.state.selection instanceof r.NodeSelection){let t=this.docView.domAfterPos(this.state.selection.from);1==t.nodeType&&j(this,t.getBoundingClientRect(),e)}else j(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))}}}someProp(e,t){let n,r=this._props&&this._props[e];if(null!=r&&(n=t?t(r):r))return n;for(let r=0;r<this.directPlugins.length;r++){let o=this.directPlugins[r].props[e];if(null!=o&&(n=t?t(o):o))return n}let o=this.state.plugins;if(o)for(let r=0;r<o.length;r++){let i=o[r].props[e];if(null!=i&&(n=t?t(i):i))return n}}hasFocus(){if(x){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(V)return e.focus(V);let t=$(e);e.focus(null==V?{get preventScroll(){return V={preventScroll:!0},!0}}:void 0),V||(V=!1,L(t,0))}(this.dom),Oe(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}posAtCoords(e){return W(this,e)}coordsAtPos(e,t=1){return X(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 r=this.docView.posFromDOM(e,t,n);if(null==r)throw new RangeError("DOM position not inside the editor");return r}endOfTextblock(e,t){return re(this,t||this.state,e)}pasteHTML(e,t){return Rt(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return Rt(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,[],Gt(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null)}get isDestroyed(){return null==this.docView}dispatchEvent(e){return function(e,t){pt(e,t)||!lt[t.type]||!e.editable&&t.type in at||lt[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(){return N&&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){let t;function n(e){e.preventDefault(),e.stopImmediatePropagation(),t=e.getTargetRanges()[0]}e.dom.addEventListener("beforeinput",n,!0),document.execCommand("indent"),e.dom.removeEventListener("beforeinput",n,!0);let r=t.startContainer,o=t.startOffset,i=t.endContainer,s=t.endOffset,l=e.domAtPos(e.state.selection.anchor);return d(l.node,l.offset,i,s)&&([r,o,i,s]=[i,s,r,o]),{anchorNode:r,anchorOffset:o,focusNode:i,focusOffset:s}}(this):this.domSelection()}domSelection(){return this.root.getSelection()}}function pn(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"),[Ft.node(0,e.state.doc.content.size,t)]}function fn(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:Ft.widget(e.state.selection.head,t,{raw:!0,marks:e.markCursor})}}else e.cursorWrapper=null}function mn(e){return!e.someProp("editable",t=>!1===t(e.state))}function gn(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 yn(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")}},function(e,t,n){"use strict";n.r(t),n.d(t,"__extends",(function(){return o})),n.d(t,"__assign",(function(){return i})),n.d(t,"__rest",(function(){return s})),n.d(t,"__decorate",(function(){return l})),n.d(t,"__param",(function(){return a})),n.d(t,"__esDecorate",(function(){return c})),n.d(t,"__runInitializers",(function(){return d})),n.d(t,"__propKey",(function(){return u})),n.d(t,"__setFunctionName",(function(){return h})),n.d(t,"__metadata",(function(){return p})),n.d(t,"__awaiter",(function(){return f})),n.d(t,"__generator",(function(){return m})),n.d(t,"__createBinding",(function(){return g})),n.d(t,"__exportStar",(function(){return y})),n.d(t,"__values",(function(){return v})),n.d(t,"__read",(function(){return b})),n.d(t,"__spread",(function(){return w})),n.d(t,"__spreadArrays",(function(){return S})),n.d(t,"__spreadArray",(function(){return k})),n.d(t,"__await",(function(){return x})),n.d(t,"__asyncGenerator",(function(){return C})),n.d(t,"__asyncDelegator",(function(){return M})),n.d(t,"__asyncValues",(function(){return O})),n.d(t,"__makeTemplateObject",(function(){return T})),n.d(t,"__importStar",(function(){return N})),n.d(t,"__importDefault",(function(){return R})),n.d(t,"__classPrivateFieldGet",(function(){return D})),n.d(t,"__classPrivateFieldSet",(function(){return _})),n.d(t,"__classPrivateFieldIn",(function(){return E})),n.d(t,"__addDisposableResource",(function(){return P})),n.d(t,"__disposeResources",(function(){return I}));var r=function(e,t){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,t)};function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var i=function(){return(i=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function s(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}function l(e,t,n,r){var o,i=arguments.length,s=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var l=e.length-1;l>=0;l--)(o=e[l])&&(s=(i<3?o(s):i>3?o(t,n,s):o(t,n))||s);return i>3&&s&&Object.defineProperty(t,n,s),s}function a(e,t){return function(n,r){t(n,r,e)}}function c(e,t,n,r,o,i){function s(e){if(void 0!==e&&"function"!=typeof e)throw new TypeError("Function expected");return e}for(var l,a=r.kind,c="getter"===a?"get":"setter"===a?"set":"value",d=!t&&e?r.static?e:e.prototype:null,u=t||(d?Object.getOwnPropertyDescriptor(d,r.name):{}),h=!1,p=n.length-1;p>=0;p--){var f={};for(var m in r)f[m]="access"===m?{}:r[m];for(var m in r.access)f.access[m]=r.access[m];f.addInitializer=function(e){if(h)throw new TypeError("Cannot add initializers after decoration has completed");i.push(s(e||null))};var g=(0,n[p])("accessor"===a?{get:u.get,set:u.set}:u[c],f);if("accessor"===a){if(void 0===g)continue;if(null===g||"object"!=typeof g)throw new TypeError("Object expected");(l=s(g.get))&&(u.get=l),(l=s(g.set))&&(u.set=l),(l=s(g.init))&&o.unshift(l)}else(l=s(g))&&("field"===a?o.unshift(l):u[c]=l)}d&&Object.defineProperty(d,r.name,u),h=!0}function d(e,t,n){for(var r=arguments.length>2,o=0;o<t.length;o++)n=r?t[o].call(e,n):t[o].call(e);return r?n:void 0}function u(e){return"symbol"==typeof e?e:"".concat(e)}function h(e,t,n){return"symbol"==typeof t&&(t=t.description?"[".concat(t.description,"]"):""),Object.defineProperty(e,"name",{configurable:!0,value:n?"".concat(n," ",t):t})}function p(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function f(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{a(r.next(e))}catch(e){i(e)}}function l(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,l)}a((r=r.apply(e,t||[])).next())}))}function m(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function l(l){return function(a){return function(l){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,l[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&l[0]?r.return:l[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,l[1])).done)return o;switch(r=0,o&&(l=[2&l[0],o.value]),l[0]){case 0:case 1:o=l;break;case 4:return s.label++,{value:l[1],done:!1};case 5:s.label++,r=l[1],l=[0];continue;case 7:l=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==l[0]&&2!==l[0])){s=0;continue}if(3===l[0]&&(!o||l[1]>o[0]&&l[1]<o[3])){s.label=l[1];break}if(6===l[0]&&s.label<o[1]){s.label=o[1],o=l;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(l);break}o[2]&&s.ops.pop(),s.trys.pop();continue}l=t.call(e,s)}catch(e){l=[6,e],r=0}finally{n=o=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}([l,a])}}}var g=Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]};function y(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||g(t,e,n)}function v(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function b(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,i=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return s}function w(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(b(arguments[t]));return e}function S(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;var r=Array(e),o=0;for(t=0;t<n;t++)for(var i=arguments[t],s=0,l=i.length;s<l;s++,o++)r[o]=i[s];return r}function k(e,t,n){if(n||2===arguments.length)for(var r,o=0,i=t.length;o<i;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))}function x(e){return this instanceof x?(this.v=e,this):new x(e)}function C(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r,o=n.apply(e,t||[]),i=[];return r={},s("next"),s("throw"),s("return"),r[Symbol.asyncIterator]=function(){return this},r;function s(e){o[e]&&(r[e]=function(t){return new Promise((function(n,r){i.push([e,t,n,r])>1||l(e,t)}))})}function l(e,t){try{(n=o[e](t)).value instanceof x?Promise.resolve(n.value.v).then(a,c):d(i[0][2],n)}catch(e){d(i[0][3],e)}var n}function a(e){l("next",e)}function c(e){l("throw",e)}function d(e,t){e(t),i.shift(),i.length&&l(i[0][0],i[0][1])}}function M(e){var t,n;return t={},r("next"),r("throw",(function(e){throw e})),r("return"),t[Symbol.iterator]=function(){return this},t;function r(r,o){t[r]=e[r]?function(t){return(n=!n)?{value:x(e[r](t)),done:!1}:o?o(t):t}:o}}function O(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,n=e[Symbol.asyncIterator];return n?n.call(e):(e=v(e),t={},r("next"),r("throw"),r("return"),t[Symbol.asyncIterator]=function(){return this},t);function r(n){t[n]=e[n]&&function(t){return new Promise((function(r,o){(function(e,t,n,r){Promise.resolve(r).then((function(t){e({value:t,done:n})}),t)})(r,o,(t=e[n](t)).done,t.value)}))}}}function T(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}var A=Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t};function N(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&g(t,e,n);return A(t,e),t}function R(e){return e&&e.__esModule?e:{default:e}}function D(e,t,n,r){if("a"===n&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?r:"a"===n?r.call(e):r?r.value:t.get(e)}function _(e,t,n,r,o){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?o.call(e,n):o?o.value=n:t.set(e,n),n}function E(e,t){if(null===t||"object"!=typeof t&&"function"!=typeof t)throw new TypeError("Cannot use 'in' operator on non-object");return"function"==typeof e?t===e:e.has(t)}function P(e,t,n){if(null!=t){if("object"!=typeof t&&"function"!=typeof t)throw new TypeError("Object expected.");var r;if(n){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");r=t[Symbol.asyncDispose]}if(void 0===r){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");r=t[Symbol.dispose]}if("function"!=typeof r)throw new TypeError("Object not disposable.");e.stack.push({value:t,dispose:r,async:n})}else n&&e.stack.push({async:!0});return t}var z="function"==typeof SuppressedError?SuppressedError:function(e,t,n){var r=new Error(n);return r.name="SuppressedError",r.error=e,r.suppressed=t,r};function I(e){function t(t){e.error=e.hasError?new z(t,e.error,"An error was suppressed during disposal."):t,e.hasError=!0}return function n(){for(;e.stack.length;){var r=e.stack.pop();try{var o=r.dispose&&r.dispose.call(r.value);if(r.async)return Promise.resolve(o).then(n,(function(e){return t(e),n()}))}catch(e){t(e)}}if(e.hasError)throw e.error}()}t.default={__extends:o,__assign:i,__rest:s,__decorate:l,__param:a,__metadata:p,__awaiter:f,__generator:m,__createBinding:g,__exportStar:y,__values:v,__read:b,__spread:w,__spreadArrays:S,__spreadArray:k,__await:x,__asyncGenerator:C,__asyncDelegator:M,__asyncValues:O,__makeTemplateObject:T,__importStar:N,__importDefault:R,__classPrivateFieldGet:D,__classPrivateFieldSet:_,__classPrivateFieldIn:E,__addDisposableResource:P,__disposeResources:I}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.expandToWordWrap=t.expandSelection=t.shallowEqual=t.indentHtml=t.selectedLineTextOnly=t.getNodeFromSelection=t.getSelectionText=t.hasSameMarkup=t.insertNode=t.findNthParentNodeOfType=t.canInsert=t.changeStylesString=void 0;var r=n(4),o=n(0),i=n(1),s=n(8);t.changeStylesString=function(e,t){var n=t.style,r=t.value,o=t.newValue;if(!e)return{changed:!1,style:null};var i=e.split(/\s*;\s*/).filter((function(e){return Boolean(e)})),s=i.filter((function(e){var t=e.split(/\s*:\s*/);return!(t[0].toLowerCase()===n&&r.test(t[1]))}));return o&&s.push(n+": "+o),{style:s.join("; ")+(s.length?";":""),changed:Boolean(o)||s.length!==i.length}};t.canInsert=function(e,t){for(var n=e.selection.$from,r=n.depth;r>=0;r--){var o=n.index(r);if(n.node(r).canReplaceWith(o,o,t))return!0}return!1};var l=function(e){return e instanceof o.Node?e.type.name:e.name};t.findNthParentNodeOfType=function(e,t){return void 0===t&&(t=1),function(n){return function(e,t){return void 0===t&&(t=1),function(n){for(var r=n.$from,o=r.depth;o>0;o--){var i=r.node(o);if(e(i)&&0===(t-=1))return{depth:o,node:i}}}}((function(t){return l(t)===l(e)}),t)(n)}};var a=function(e){var t={};for(var n in e)n&&(e[n]||0===e[n])&&(t[n]=e[n]);return t};t.insertNode=function(e,t){return function(n,o){var s=n.selection,l=n.tr;s instanceof i.NodeSelection&&s.node.type.name===e.type.name&&e.isLeaf&&!e.isText&&1===e.nodeSize?(l.setNodeMarkup(s.from,null,r.__assign(r.__assign({},a(s.node.attrs)),a(e.attrs))),l.setSelection(i.NodeSelection.create(l.doc,s.from))):l.replaceSelectionWith(e),t&&l.scrollIntoView(),o(l)}};t.hasSameMarkup=function(e,t,n,r){var i=o.Fragment.from(s.parseContent(e,n,r)),l=o.Fragment.from(s.parseContent(t,n,r));return i.eq(l)};t.getSelectionText=function(e){var t=e.selection;if(t instanceof i.TextSelection||t instanceof i.AllSelection){var n=t.content().content;return n.textBetween(0,n.size)}return""};t.getNodeFromSelection=function(e){if(e.selection instanceof i.NodeSelection)return e.selection.node};t.selectedLineTextOnly=function(e){var n="",r=!1,o=e.selection,i=e.doc,s=o.$from,l=o.$to,a=o.from,c=o.to;return s.sameParent(l)&&(i.nodesBetween(a,c,(function(e){r=r||e.isLeaf&&!e.isText})),r||(n=t.getSelectionText(e))),n};t.indentHtml=function(e){return 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$/,"")};t.shallowEqual=function(e,t){var n=Object.keys(e),r=Object.keys(t);return n.length===r.length&&n.every((function(n){return e[n]===t[n]}))};var c={before:/[^ !,?.\[\]{}()]+$/i,after:/^[^ !,?.\[\]{}()]+/i};t.expandSelection=function(e,t,n){if(!n.applyToWord||!e.selection.empty)return{state:e,dispatch:t};var r=!0===n.applyToWord?c:n.applyToWord,o=null,s=e.tr,l=e.selection,a=l.$head.nodeBefore,d=l.$head.nodeAfter;if(a&&"text"===a.type.name&&a.text&&d&&"text"===d.type.name&&d.text){var u=[];l.$head.parent.descendants((function(e,t){return u.push({node:e,pos:t}),!1}));for(var h=l.$head.parentOffset,p=u.findIndex((function(e){var t=e.node,n=e.pos;return n<=h&&n+t.nodeSize>=h})),f=u[p].node.text,m=!1,g=p-1;g>=0;g--){var y=u[g];!m&&y&&"text"===y.node.type.name?f=y.node.text+f:(m=!0,h-=y.node.nodeSize)}for(g=p+1;g<u.length;g++){if(!(y=u[g])||"text"!==y.node.type.name)break;f+=y.node.text}var v=f.substring(0,h),b=f.substring(h),w=r.before.exec(v),S=r.after.exec(b);if(w&&S){var k=w[0].length,x=S[0].length,C=o=l.from;s.setSelection(i.TextSelection.create(e.doc,C-k,C+x));return{state:{tr:s,selection:s.selection,doc:s.doc,storedMarks:null,schema:s.doc.type.schema},dispatch:function(e){e.setSelection(i.TextSelection.create(e.doc,o)),t(e)}}}}return{state:e,dispatch:t}};t.expandToWordWrap=function(e,n){return function(r,o,i){var s=t.expandSelection(r,o,n),l=s.state,a=s.dispatch;return e(n)(l,a)}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dataResizeDirImage=t.dataResizeDirTable=t.resizeHandle=t.resizableWrap=t.resizableAttr=t.colgroupAttr=t.rowTypeAttr=void 0,t.rowTypeAttr="k-parent-node",t.colgroupAttr="k-colgroup-data",t.resizableAttr="k-resizable-node",t.resizableWrap="k-editor-resize-wrap-element",t.resizeHandle="k-editor-resize-handle",t.dataResizeDirTable="data-dir-table-resize",t.dataResizeDirImage="data-dir-image-resize"},function(e,t,n){"use strict";n.r(t),n.d(t,"CellBookmark",(function(){return R})),n.d(t,"CellSelection",(function(){return N})),n.d(t,"ResizeState",(function(){return te})),n.d(t,"TableMap",(function(){return d})),n.d(t,"TableView",(function(){return Y})),n.d(t,"__clipCells",(function(){return I})),n.d(t,"__insertCells",(function(){return j})),n.d(t,"__pastedCells",(function(){return P})),n.d(t,"addColSpan",(function(){return T})),n.d(t,"addColumn",(function(){return se})),n.d(t,"addColumnAfter",(function(){return ae})),n.d(t,"addColumnBefore",(function(){return le})),n.d(t,"addRow",(function(){return he})),n.d(t,"addRowAfter",(function(){return fe})),n.d(t,"addRowBefore",(function(){return pe})),n.d(t,"cellAround",(function(){return y})),n.d(t,"colCount",(function(){return C})),n.d(t,"columnIsHeader",(function(){return A})),n.d(t,"columnResizing",(function(){return ee})),n.d(t,"columnResizingPluginKey",(function(){return Z})),n.d(t,"deleteColumn",(function(){return de})),n.d(t,"deleteRow",(function(){return ge})),n.d(t,"deleteTable",(function(){return Ae})),n.d(t,"findCell",(function(){return x})),n.d(t,"fixTables",(function(){return E})),n.d(t,"fixTablesKey",(function(){return _})),n.d(t,"goToNextCell",(function(){return Te})),n.d(t,"handlePaste",(function(){return q})),n.d(t,"inSameTable",(function(){return k})),n.d(t,"isInTable",(function(){return v})),n.d(t,"mergeCells",(function(){return ve})),n.d(t,"moveCellForward",(function(){return S})),n.d(t,"nextCell",(function(){return M})),n.d(t,"pointsAtCell",(function(){return w})),n.d(t,"removeColSpan",(function(){return O})),n.d(t,"removeColumn",(function(){return ce})),n.d(t,"removeRow",(function(){return me})),n.d(t,"rowIsHeader",(function(){return ue})),n.d(t,"selectedRect",(function(){return ie})),n.d(t,"selectionCell",(function(){return b})),n.d(t,"setCellAttr",(function(){return Se})),n.d(t,"splitCell",(function(){return be})),n.d(t,"splitCellWithType",(function(){return we})),n.d(t,"tableEditing",(function(){return Ne})),n.d(t,"tableEditingKey",(function(){return g})),n.d(t,"tableNodeTypes",(function(){return m})),n.d(t,"tableNodes",(function(){return f})),n.d(t,"toggleHeader",(function(){return xe})),n.d(t,"toggleHeaderCell",(function(){return Oe})),n.d(t,"toggleHeaderColumn",(function(){return Me})),n.d(t,"toggleHeaderRow",(function(){return Ce})),n.d(t,"updateColumnsOnResize",(function(){return Q}));var r,o,i=n(1),s=n(0),l=n(3),a=n(11),c=n(2);if("undefined"!=typeof WeakMap){let e=new WeakMap;r=t=>e.get(t),o=(t,n)=>(e.set(t,n),n)}else{const e=[],t=10;let n=0;r=t=>{for(let n=0;n<e.length;n+=2)if(e[n]==t)return e[n+1]},o=(r,o)=>(n==t&&(n=0),e[n++]=r,e[n++]=o)}var d=class{constructor(e,t,n,r){this.width=e,this.height=t,this.map=n,this.problems=r}findCell(e){for(let t=0;t<this.map.length;t++){const n=this.map[t];if(n!=e)continue;const r=t%this.width,o=t/this.width|0;let i=r+1,s=o+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:r,top:o,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:r,right:o,top:i,bottom:s}=this.findCell(e);return"horiz"==t?(n<0?0==r:o==this.width)?null:this.map[i*this.width+(n<0?r-1:o)]:(n<0?0==i:s==this.height)?null:this.map[r+this.width*(n<0?i-1:s)]}rectBetween(e,t){const{left:n,right:r,top:o,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(o,a),right:Math.max(r,l),bottom:Math.max(i,c)}}cellsInRect(e){const t=[],n={};for(let r=e.top;r<e.bottom;r++)for(let o=e.left;o<e.right;o++){const i=r*this.width+o,s=this.map[i];n[s]||(n[s]=!0,o==e.left&&o&&this.map[i-1]==s||r==e.top&&r&&this.map[i-this.width]==s||t.push(s))}return t}positionAt(e,t,n){for(let r=0,o=0;;r++){const i=o+n.child(r).nodeSize;if(r==e){let n=t+e*this.width;const r=(e+1)*this.width;for(;n<r&&this.map[n]<o;)n++;return n==r?i-1:this.map[n]}o=i}}static get(e){return r(e)||o(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 r=0;r<e.childCount;r++){const o=e.child(r);let i=0;if(n)for(let t=0;t<r;t++){const n=e.child(t);for(let e=0;e<n.childCount;e++){const o=n.child(e);t+o.attrs.rowspan>r&&(i+=o.attrs.colspan)}}for(let e=0;e<o.childCount;e++){const t=o.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,r=[];let o=0,i=null;const s=[];for(let e=0,o=t*n;e<o;e++)r[e]=0;for(let l=0,a=0;l<n;l++){const c=e.child(l);a++;for(let e=0;;e++){for(;o<r.length&&0!=r[o];)o++;if(e==c.childCount)break;const d=c.child(e),{colspan:u,rowspan:h,colwidth:p}=d.attrs;for(let e=0;e<h;e++){if(e+l>=n){(i||(i=[])).push({type:"overlong_rowspan",pos:a,n:h-e});break}const c=o+e*t;for(let e=0;e<u;e++){0==r[c+e]?r[c+e]=a:(i||(i=[])).push({type:"collision",row:l,pos:a,n:u-e});const n=p&&p[e];if(n){const r=(c+e)%t*2,o=s[r];null==o||o!=n&&1==s[r+1]?(s[r]=n,s[r+1]=1):o==n&&s[r+1]++}}}o+=u,a+=d.nodeSize}const d=(l+1)*t;let u=0;for(;o<d;)0==r[o++]&&u++;u&&(i||(i=[])).push({type:"missing",row:l,n:u}),a++}const l=new d(t,n,r,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 r={};for(let o=0;o<e.map.length;o++){const i=e.map[o];if(r[i])continue;r[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 r=(o+n)%e.width,i=t[2*r];null==i||a.colwidth&&a.colwidth[n]==i||((l||(l=u(a)))[n]=i)}l&&e.problems.unshift({type:"colwidth mismatch",pos:i,colwidth:l})}}(l,s,e);return l}(e))}};function u(e){if(e.colwidth)return e.colwidth.slice();const t=[];for(let n=0;n<e.colspan;n++)t.push(0);return t}function h(e,t){if("string"==typeof e)return{};const n=e.getAttribute("data-colwidth"),r=n&&/^\d+(,\d+)*$/.test(n)?n.split(",").map(e=>Number(e)):null,o=Number(e.getAttribute("colspan")||1),i={colspan:o,rowspan:Number(e.getAttribute("rowspan")||1),colwidth:r&&r.length==o?r:null};for(const n in t){const r=t[n].getFromDOM,o=r&&r(e);null!=o&&(i[n]=o)}return i}function p(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 r in t){const o=t[r].setDOMAttr;o&&o(e.attrs[r],n)}return n}function f(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=>h(e,t)}],toDOM:e=>["td",p(e,t),0]},table_header:{content:e.cellContent,attrs:n,tableRole:"header_cell",isolating:!0,parseDOM:[{tag:"th",getAttrs:e=>h(e,t)}],toDOM:e=>["th",p(e,t),0]}}}function m(e){let t=e.cached.tableNodeTypes;if(!t){t=e.cached.tableNodeTypes={};for(const n in e.nodes){const r=e.nodes[n],o=r.spec.tableRole;o&&(t[o]=r)}}return t}var g=new i.PluginKey("selectingCells");function y(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 v(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 b(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=y(t.$head)||function(e){for(let t=e.nodeAfter,n=e.pos;t;t=t.firstChild,n++){const r=t.type.spec.tableRole;if("cell"==r||"header_cell"==r)return e.doc.resolve(n)}for(let t=e.nodeBefore,n=e.pos;t;t=t.lastChild,n--){const r=t.type.spec.tableRole;if("cell"==r||"header_cell"==r)return e.doc.resolve(n-t.nodeSize)}}(t.$head);if(n)return n;throw new RangeError("No cell found around position "+t.head)}function w(e){return"row"==e.parent.type.spec.tableRole&&!!e.nodeAfter}function S(e){return e.node(0).resolve(e.pos+e.nodeAfter.nodeSize)}function k(e,t){return e.depth==t.depth&&e.pos>=t.start(-1)&&e.pos<=t.end(-1)}function x(e){return d.get(e.node(-1)).findCell(e.pos-e.start(-1))}function C(e){return d.get(e.node(-1)).colCount(e.pos-e.start(-1))}function M(e,t,n){const r=e.node(-1),o=d.get(r),i=e.start(-1),s=o.nextCell(e.pos-i,t,n);return null==s?null:e.node(0).resolve(i+s)}function O(e,t,n=1){const r={...e,colspan:e.colspan-n};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(t,n),r.colwidth.some(e=>e>0)||(r.colwidth=null)),r}function T(e,t,n=1){const r={...e,colspan:e.colspan+n};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let e=0;e<n;e++)r.colwidth.splice(t,0,0)}return r}function A(e,t,n){const r=m(t.type.schema).header_cell;for(let o=0;o<e.height;o++)if(t.nodeAt(e.map[n+o*e.width]).type!=r)return!1;return!0}var N=class extends i.Selection{constructor(e,t=e){const n=e.node(-1),r=d.get(n),o=e.start(-1),s=r.rectBetween(e.pos-o,t.pos-o),l=e.node(0),a=r.cellsInRect(s).filter(e=>e!=t.pos-o);a.unshift(t.pos-o);const c=a.map(e=>{const t=n.nodeAt(e);if(!t)throw RangeError(`No cell with offset ${e} found`);const r=o+e+1;return new i.SelectionRange(l.resolve(r),l.resolve(r+t.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=t}map(e,t){const n=e.resolve(t.map(this.$anchorCell.pos)),r=e.resolve(t.map(this.$headCell.pos));if(w(n)&&w(r)&&k(n,r)){const e=this.$anchorCell.node(-1)!=n.node(-1);return e&&this.isRowSelection()?N.rowSelection(n,r):e&&this.isColSelection()?N.colSelection(n,r):new N(n,r)}return i.TextSelection.between(n,r)}content(){const e=this.$anchorCell.node(-1),t=d.get(e),n=this.$anchorCell.start(-1),r=t.rectBetween(this.$anchorCell.pos-n,this.$headCell.pos-n),o={},i=[];for(let n=r.top;n<r.bottom;n++){const l=[];for(let i=n*t.width+r.left,s=r.left;s<r.right;s++,i++){const n=t.map[i];if(o[n])continue;o[n]=!0;const s=t.findCell(n);let a=e.nodeAt(n);if(!a)throw RangeError(`No cell with offset ${n} found`);const c=r.left-s.left,d=s.right-r.right;if(c>0||d>0){let e=a.attrs;if(c>0&&(e=O(e,0,c)),d>0&&(e=O(e,e.colspan-d,d)),s.left<r.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<r.top||s.bottom>r.bottom){const e={...a.attrs,rowspan:Math.min(s.bottom,r.bottom)-Math.max(s.top,r.top)};a=s.top<r.top?a.type.createAndFill(e):a.type.create(e,a.content)}l.push(a)}i.push(e.child(n).copy(s.Fragment.from(l)))}const l=this.isColSelection()&&this.isRowSelection()?e:i;return new s.Slice(s.Fragment.from(l),1,1)}replace(e,t=s.Slice.empty){const n=e.steps.length,r=this.ranges;for(let o=0;o<r.length;o++){const{$from:i,$to:l}=r[o],a=e.mapping.slice(n);e.replace(a.map(i.pos),a.map(l.pos),o?s.Slice.empty:t)}const o=i.Selection.findFrom(e.doc.resolve(e.mapping.slice(n).map(this.to)),-1);o&&e.setSelection(o)}replaceWith(e,t){this.replace(e,new s.Slice(s.Fragment.from(t),0,0))}forEachCell(e){const t=this.$anchorCell.node(-1),n=d.get(t),r=this.$anchorCell.start(-1),o=n.cellsInRect(n.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r));for(let n=0;n<o.length;n++)e(t.nodeAt(o[n]),r+o[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,r=t+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(n,r)==this.$headCell.node(-1).childCount}static colSelection(e,t=e){const n=e.node(-1),r=d.get(n),o=e.start(-1),i=r.findCell(e.pos-o),s=r.findCell(t.pos-o),l=e.node(0);return i.top<=s.top?(i.top>0&&(e=l.resolve(o+r.map[i.left])),s.bottom<r.height&&(t=l.resolve(o+r.map[r.width*(r.height-1)+s.right-1]))):(s.top>0&&(t=l.resolve(o+r.map[s.left])),i.bottom<r.height&&(e=l.resolve(o+r.map[r.width*(r.height-1)+i.right-1]))),new N(e,t)}isRowSelection(){const e=this.$anchorCell.node(-1),t=d.get(e),n=this.$anchorCell.start(-1),r=t.colCount(this.$anchorCell.pos-n),o=t.colCount(this.$headCell.pos-n);if(Math.min(r,o)>0)return!1;const i=r+this.$anchorCell.nodeAfter.attrs.colspan,s=o+this.$headCell.nodeAfter.attrs.colspan;return Math.max(i,s)==t.width}eq(e){return e instanceof N&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,t=e){const n=e.node(-1),r=d.get(n),o=e.start(-1),i=r.findCell(e.pos-o),s=r.findCell(t.pos-o),l=e.node(0);return i.left<=s.left?(i.left>0&&(e=l.resolve(o+r.map[i.top*r.width])),s.right<r.width&&(t=l.resolve(o+r.map[r.width*(s.top+1)-1]))):(s.left>0&&(t=l.resolve(o+r.map[s.top*r.width])),i.right<r.width&&(e=l.resolve(o+r.map[r.width*(i.top+1)-1]))),new N(e,t)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,t){return new N(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,n=t){return new N(e.resolve(t),e.resolve(n))}getBookmark(){return new R(this.$anchorCell.pos,this.$headCell.pos)}};N.prototype.visible=!1,i.Selection.jsonID("cell",N);var R=class{constructor(e,t){this.anchor=e,this.head=t}map(e){return new R(e.map(this.anchor),e.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&&k(t,n)?new N(t,n):i.Selection.near(n,1)}};function D(e){if(!(e.selection instanceof N))return null;const t=[];return e.selection.forEachCell((e,n)=>{t.push(l.Decoration.node(n,n+e.nodeSize,{class:"selectedCell"}))}),l.DecorationSet.create(e.doc,t)}var _=new i.PluginKey("fix-tables");function E(e,t){let n;const r=(t,r)=>{"table"==t.type.spec.tableRole&&(n=function(e,t,n,r){const o=d.get(t);if(!o.problems)return r;r||(r=e.tr);const i=[];for(let e=0;e<o.height;e++)i.push(0);for(let e=0;e<o.problems.length;e++){const s=o.problems[e];if("collision"==s.type){const e=t.nodeAt(s.pos);if(!e)continue;const o=e.attrs;for(let e=0;e<o.rowspan;e++)i[s.row+e]+=s.n;r.setNodeMarkup(r.mapping.map(n+1+s.pos),null,O(o,o.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;r.setNodeMarkup(r.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;r.setNodeMarkup(r.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<o.height;a++){const n=t.child(a),o=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=m(e.schema)[t].createAndFill();n&&i.push(n)}const u=0!=a&&s!=a-1||l!=a?o-1:c+1;r.insert(r.mapping.map(u),i)}c=o}return r.setMeta(_,{fixTables:!0})}(e,t,r,n))};return t?t.doc!=e.doc&&function e(t,n,r,o){const i=t.childCount,s=n.childCount;e:for(let l=0,a=0;l<s;l++){const s=n.child(l);for(let e=a,n=Math.min(i,l+3);e<n;e++)if(t.child(e)==s){a=e+1,r+=s.nodeSize;continue e}o(s,r),a<i&&t.child(a).sameMarkup(s)?e(t.child(a),s,r+1,o):s.nodesBetween(0,s.content.size,o,r+1),r+=s.nodeSize}}(t.doc,e.doc,0,r):e.doc.descendants(r),n}function P(e){if(!e.size)return null;let{content:t,openStart:n,openEnd:r}=e;for(;1==t.childCount&&(n>0&&r>0||"table"==t.child(0).type.spec.tableRole);)n--,r--,t=t.child(0).content;const o=t.child(0),i=o.type.spec.tableRole,l=o.type.schema,a=[];if("row"==i)for(let e=0;e<t.childCount;e++){let o=t.child(e).content;const i=e?0:Math.max(0,n-1),c=e<t.childCount-1?0:Math.max(0,r-1);(i||c)&&(o=z(m(l).row,new s.Slice(o,i,c)).content),a.push(o)}else{if("cell"!=i&&"header_cell"!=i)return null;a.push(n||r?z(m(l).row,new s.Slice(t,n,r)).content:t)}return function(e,t){const n=[];for(let e=0;e<t.length;e++){const r=t[e];for(let t=r.childCount-1;t>=0;t--){const{rowspan:o,colspan:i}=r.child(t).attrs;for(let t=e;t<e+o;t++)n[t]=(n[t]||0)+i}}let r=0;for(let e=0;e<n.length;e++)r=Math.max(r,n[e]);for(let o=0;o<n.length;o++)if(o>=t.length&&t.push(s.Fragment.empty),n[o]<r){const i=m(e).cell.createAndFill(),l=[];for(let e=n[o];e<r;e++)l.push(i);t[o]=t[o].append(s.Fragment.from(l))}return{height:t.length,width:r,rows:t}}(l,a)}function z(e,t){const n=e.createAndFill();return new c.Transform(n).replace(0,n.content.size,t).doc}function I({width:e,height:t,rows:n},r,o){if(e!=r){const t=[],o=[];for(let e=0;e<n.length;e++){const i=n[e],l=[];for(let n=t[e]||0,o=0;n<r;o++){let s=i.child(o%i.childCount);n+s.attrs.colspan>r&&(s=s.type.createChecked(O(s.attrs,s.attrs.colspan,n+s.attrs.colspan-r),s.content)),l.push(s),n+=s.attrs.colspan;for(let n=1;n<s.attrs.rowspan;n++)t[e+n]=(t[e+n]||0)+s.attrs.colspan}o.push(s.Fragment.from(l))}n=o,e=r}if(t!=o){const e=[];for(let r=0,i=0;r<o;r++,i++){const l=[],a=n[i%t];for(let e=0;e<a.childCount;e++){let t=a.child(e);r+t.attrs.rowspan>o&&(t=t.type.create({...t.attrs,rowspan:Math.max(1,o-t.attrs.rowspan)},t.content)),l.push(t)}e.push(s.Fragment.from(l))}n=e,t=o}return{width:e,height:t,rows:n}}function F(e,t,n,r,o,i,s,l){if(0==s||s==t.height)return!1;let a=!1;for(let c=o;c<i;c++){const o=s*t.width+c,i=t.map[o];if(t.map[o-t.width]==i){a=!0;const o=n.nodeAt(i),{top:d,left:u}=t.findCell(i);e.setNodeMarkup(e.mapping.slice(l).map(i+r),null,{...o.attrs,rowspan:s-d}),e.insert(e.mapping.slice(l).map(t.positionAt(s,u,n)),o.type.createAndFill({...o.attrs,rowspan:d+o.attrs.rowspan-s})),c+=o.attrs.colspan-1}}return a}function B(e,t,n,r,o,i,s,l){if(0==s||s==t.width)return!1;let a=!1;for(let c=o;c<i;c++){const o=c*t.width+s,i=t.map[o];if(t.map[o-1]==i){a=!0;const o=n.nodeAt(i),d=t.colCount(i),u=e.mapping.slice(l).map(i+r);e.setNodeMarkup(u,null,O(o.attrs,s-d,o.attrs.colspan-(s-d))),e.insert(u+o.nodeSize,o.type.createAndFill(O(o.attrs,0,s-d))),c+=o.attrs.rowspan-1}}return a}function j(e,t,n,r,o){let i=n?e.doc.nodeAt(n-1):e.doc;if(!i)throw new Error("No table found");let l=d.get(i);const{top:a,left:c}=r,u=c+o.width,h=a+o.height,p=e.tr;let f=0;function g(){if(i=n?p.doc.nodeAt(n-1):p.doc,!i)throw new Error("No table found");l=d.get(i),f=p.mapping.maps.length}(function(e,t,n,r,o,i,l){const a=m(e.doc.type.schema);let c,d;if(o>t.width)for(let i=0,s=0;i<t.height;i++){const u=n.child(i);s+=u.nodeSize;const h=[];let p;p=null==u.lastChild||u.lastChild.type==a.cell?c||(c=a.cell.createAndFill()):d||(d=a.header_cell.createAndFill());for(let e=t.width;e<o;e++)h.push(p);e.insert(e.mapping.slice(l).map(s-1+r),h)}if(i>t.height){const u=[];for(let e=0,r=(t.height-1)*t.width;e<Math.max(t.width,o);e++){const o=!(e>=t.width)&&n.nodeAt(t.map[r+e]).type==a.header_cell;u.push(o?d||(d=a.header_cell.createAndFill()):c||(c=a.cell.createAndFill()))}const h=a.row.create(null,s.Fragment.from(u)),p=[];for(let e=t.height;e<i;e++)p.push(h);e.insert(e.mapping.slice(l).map(r+n.nodeSize-2),p)}return!(!c&&!d)})(p,l,i,n,u,h,f)&&g(),F(p,l,i,n,c,u,a,f)&&g(),F(p,l,i,n,c,u,h,f)&&g(),B(p,l,i,n,a,h,c,f)&&g(),B(p,l,i,n,a,h,u,f)&&g();for(let e=a;e<h;e++){const t=l.positionAt(e,c,i),r=l.positionAt(e,u,i);p.replace(p.mapping.slice(f).map(t+n),p.mapping.slice(f).map(r+n),new s.Slice(o.rows[e-a],0,0))}g(),p.setSelection(new N(p.doc.resolve(n+l.positionAt(a,c,i)),p.doc.resolve(n+l.positionAt(h-1,u-1,i)))),t(p)}var $=Object(a.keydownHandler)({ArrowLeft:V("horiz",-1),ArrowRight:V("horiz",1),ArrowUp:V("vert",-1),ArrowDown:V("vert",1),"Shift-ArrowLeft":K("horiz",-1),"Shift-ArrowRight":K("horiz",1),"Shift-ArrowUp":K("vert",-1),"Shift-ArrowDown":K("vert",1),Backspace:H,"Mod-Backspace":H,Delete:H,"Mod-Delete":H});function L(e,t,n){return!n.eq(e.selection)&&(t&&t(e.tr.setSelection(n).scrollIntoView()),!0)}function V(e,t){return(n,r,o)=>{if(!o)return!1;const s=n.selection;if(s instanceof N)return L(n,r,i.Selection.near(s.$headCell,t));if("horiz"!=e&&!s.empty)return!1;const l=U(o,e,t);if(null==l)return!1;if("horiz"==e)return L(n,r,i.Selection.near(n.doc.resolve(s.head+t),t));{const o=n.doc.resolve(l),s=M(o,e,t);let a;return a=s?i.Selection.near(s,1):t<0?i.Selection.near(n.doc.resolve(o.before(-1)),-1):i.Selection.near(n.doc.resolve(o.after(-1)),1),L(n,r,a)}}}function K(e,t){return(n,r,o)=>{if(!o)return!1;const i=n.selection;let s;if(i instanceof N)s=i;else{const r=U(o,e,t);if(null==r)return!1;s=new N(n.doc.resolve(r))}const l=M(s.$headCell,e,t);return!!l&&L(n,r,new N(s.$anchorCell,l))}}function H(e,t){const n=e.selection;if(!(n instanceof N))return!1;if(t){const r=e.tr,o=m(e.schema).cell.createAndFill().content;n.forEachCell((e,t)=>{e.content.eq(o)||r.replace(r.mapping.map(t+1),r.mapping.map(t+e.nodeSize-1),new s.Slice(o,0,0))}),r.docChanged&&t(r)}return!0}function W(e,t){const n=y(e.state.doc.resolve(t));return!!n&&(e.dispatch(e.state.tr.setSelection(new N(n))),!0)}function q(e,t,n){if(!v(e.state))return!1;let r=P(n);const o=e.state.selection;if(o instanceof N){r||(r={width:1,height:1,rows:[s.Fragment.from(z(m(e.state.schema).cell,n))]});const t=o.$anchorCell.node(-1),i=o.$anchorCell.start(-1),l=d.get(t).rectBetween(o.$anchorCell.pos-i,o.$headCell.pos-i);return r=I(r,l.right-l.left,l.bottom-l.top),j(e.state,e.dispatch,i,l,r),!0}if(r){const t=b(e.state),n=t.start(-1);return j(e.state,e.dispatch,n,d.get(t.node(-1)).findCell(t.pos-n),r),!0}return!1}function J(e,t){var n;if(t.ctrlKey||t.metaKey)return;const r=X(e,t.target);let o;if(t.shiftKey&&e.state.selection instanceof N)i(e.state.selection.$anchorCell,t),t.preventDefault();else if(t.shiftKey&&r&&null!=(o=y(e.state.selection.$anchor))&&(null==(n=G(e,t))?void 0:n.pos)!=o.pos)i(o,t),t.preventDefault();else if(!r)return;function i(t,n){let r=G(e,n);const o=null==g.getState(e.state);if(!r||!k(t,r)){if(!o)return;r=t}const i=new N(t,r);if(o||!e.state.selection.eq(i)){const n=e.state.tr.setSelection(i);o&&n.setMeta(g,t.pos),e.dispatch(n)}}function s(){e.root.removeEventListener("mouseup",s),e.root.removeEventListener("dragstart",s),e.root.removeEventListener("mousemove",l),null!=g.getState(e.state)&&e.dispatch(e.state.tr.setMeta(g,-1))}function l(n){const o=n,l=g.getState(e.state);let a;if(null!=l)a=e.state.doc.resolve(l);else if(X(e,o.target)!=r&&(a=G(e,t),!a))return s();a&&i(a,o)}e.root.addEventListener("mouseup",s),e.root.addEventListener("dragstart",s),e.root.addEventListener("mousemove",l)}function U(e,t,n){if(!(e.state.selection instanceof i.TextSelection))return null;const{$head:r}=e.state.selection;for(let o=r.depth-1;o>=0;o--){const i=r.node(o);if((n<0?r.index(o):r.indexAfter(o))!=(n<0?0:i.childCount))return null;if("cell"==i.type.spec.tableRole||"header_cell"==i.type.spec.tableRole){const i=r.before(o),s="vert"==t?n>0?"down":"up":n>0?"right":"left";return e.endOfTextblock(s)?i:null}}return null}function X(e,t){for(;t&&t!=e.dom;t=t.parentNode)if("TD"==t.nodeName||"TH"==t.nodeName)return t;return null}function G(e,t){const n=e.posAtCoords({left:t.clientX,top:t.clientY});return n&&n?y(e.state.doc.resolve(n.pos)):null}var Y=class{constructor(e,t){this.node=e,this.cellMinWidth=t,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.colgroup=this.table.appendChild(document.createElement("colgroup")),Q(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,Q(e,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(e){return"attributes"==e.type&&(e.target==this.table||this.colgroup.contains(e.target))}};function Q(e,t,n,r,o,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:u}=d.child(e).attrs;for(let e=0;e<s;e++,n++){const s=o==n?i:u&&u[e],d=s?s+"px":"";l+=s||r,s||(a=!1),c?(c.style.width!=d&&(c.style.width=d),c=c.nextSibling):t.appendChild(document.createElement("col")).style.width=d}}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 Z=new i.PluginKey("tableColumnResizing");function ee({handleWidth:e=5,cellMinWidth:t=25,View:n=Y,lastColumnResizable:r=!0}={}){const o=new i.Plugin({key:Z,state:{init:(e,r)=>(o.spec.props.nodeViews[m(r.schema).table.name]=(e,r)=>new n(e,t,r),new te(-1,!1)),apply:(e,t)=>t.apply(e)},props:{attributes:e=>{const t=Z.getState(e);return t&&t.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(t,n)=>{!function(e,t,n,r,o){const i=Z.getState(e.state);if(!i)return;if(!i.dragging){const r=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(r){const{left:o,right:i}=r.getBoundingClientRect();t.clientX-o<=n?s=ne(e,t,"left",n):i-t.clientX<=n&&(s=ne(e,t,"right",n))}if(s!=i.activeHandle){if(!o&&-1!==s){const t=e.state.doc.resolve(s),n=t.node(-1),r=d.get(n),o=t.start(-1);if(r.colCount(t.pos-o)+t.nodeAfter.attrs.colspan-1==r.width-1)return}oe(e,s)}}}(t,n,e,0,r)},mouseleave:e=>{!function(e){const t=Z.getState(e.state);t&&t.activeHandle>-1&&!t.dragging&&oe(e,-1)}(e)},mousedown:(e,n)=>{!function(e,t,n){const r=Z.getState(e.state);if(!r||-1==r.activeHandle||r.dragging)return!1;const o=e.state.doc.nodeAt(r.activeHandle),i=function(e,t,{colspan:n,colwidth:r}){const o=r&&r[r.length-1];if(o)return o;const i=e.domAtPos(t);let s=i.node.childNodes[i.offset].offsetWidth,l=n;if(r)for(let e=0;e<n;e++)r[e]&&(s-=r[e],l--);return s/l}(e,r.activeHandle,o.attrs);function s(t){window.removeEventListener("mouseup",s),window.removeEventListener("mousemove",l);const r=Z.getState(e.state);(null==r?void 0:r.dragging)&&(!function(e,t,n){const r=e.state.doc.resolve(t),o=r.node(-1),i=d.get(o),s=r.start(-1),l=i.colCount(r.pos-s)+r.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 r=i.map[t],d=o.nodeAt(r).attrs,u=1==d.colspan?0:l-i.colCount(r);if(d.colwidth&&d.colwidth[u]==n)continue;const h=d.colwidth?d.colwidth.slice():(c=d.colspan,Array(c).fill(0));h[u]=n,a.setNodeMarkup(s+r,null,{...d,colwidth:h})}var c;a.docChanged&&e.dispatch(a)}(e,r.activeHandle,re(r.dragging,t,n)),e.dispatch(e.state.tr.setMeta(Z,{setDragging:null})))}function l(t){if(!t.which)return s(t);const r=Z.getState(e.state);if(r&&r.dragging){const o=re(r.dragging,t,n);!function(e,t,n,r){const o=e.state.doc.resolve(t),i=o.node(-1),s=o.start(-1),l=d.get(i).colCount(o.pos-s)+o.nodeAfter.attrs.colspan-1;let a=e.domAtPos(o.start(-1)).node;for(;a&&"TABLE"!=a.nodeName;)a=a.parentNode;if(!a)return;Q(i,a.firstChild,a,r,l,n)}(e,r.activeHandle,o,n)}}e.dispatch(e.state.tr.setMeta(Z,{setDragging:{startX:t.clientX,startWidth:i}})),window.addEventListener("mouseup",s),window.addEventListener("mousemove",l),t.preventDefault()}(e,n,t)}},decorations:e=>{const t=Z.getState(e);if(t&&t.activeHandle>-1)return function(e,t){const n=[],r=e.doc.resolve(t),o=r.node(-1);if(!o)return l.DecorationSet.empty;const i=d.get(o),s=r.start(-1),a=i.colCount(r.pos-s)+r.nodeAfter.attrs.colspan;for(let e=0;e<i.height;e++){const t=a+e*i.width-1;if(!(a!=i.width&&i.map[t]==i.map[t+1]||0!=e&&i.map[t]==i.map[t-i.width])){const e=i.map[t],r=s+e+o.nodeAt(e).nodeSize-1,a=document.createElement("div");a.className="column-resize-handle",n.push(l.Decoration.widget(r,a))}}return l.DecorationSet.create(e.doc,n)}(e,t.activeHandle)},nodeViews:{}}});return o}var te=class{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(e){const t=this,n=e.getMeta(Z);if(n&&null!=n.setHandle)return new te(n.setHandle,!1);if(n&&void 0!==n.setDragging)return new te(t.activeHandle,n.setDragging);if(t.activeHandle>-1&&e.docChanged){let n=e.mapping.map(t.activeHandle,-1);return w(e.doc.resolve(n))||(n=-1),new te(n,t.dragging)}return t}};function ne(e,t,n,r){const o="right"==n?-r:r,i=e.posAtCoords({left:t.clientX+o,top:t.clientY});if(!i)return-1;const{pos:s}=i,l=y(e.state.doc.resolve(s));if(!l)return-1;if("right"==n)return l.pos;const a=d.get(l.node(-1)),c=l.start(-1),u=a.map.indexOf(l.pos-c);return u%a.width==0?-1:c+a.map[u-1]}function re(e,t,n){const r=t.clientX-e.startX;return Math.max(n,e.startWidth+r)}function oe(e,t){e.dispatch(e.state.tr.setMeta(Z,{setHandle:t}))}function ie(e){const t=e.selection,n=b(e),r=n.node(-1),o=n.start(-1),i=d.get(r);return{...t instanceof N?i.rectBetween(t.$anchorCell.pos-o,t.$headCell.pos-o):i.findCell(n.pos-o),tableStart:o,map:i,table:r}}function se(e,{map:t,tableStart:n,table:r},o){let i=o>0?-1:0;A(t,r,o+i)&&(i=0==o||o==t.width?null:0);for(let s=0;s<t.height;s++){const l=s*t.width+o;if(o>0&&o<t.width&&t.map[l-1]==t.map[l]){const i=t.map[l],a=r.nodeAt(i);e.setNodeMarkup(e.mapping.map(n+i),null,T(a.attrs,o-t.colCount(i))),s+=a.attrs.rowspan-1}else{const a=null==i?m(r.type.schema).cell:r.nodeAt(t.map[l+i]).type,c=t.positionAt(s,o,r);e.insert(e.mapping.map(n+c),a.createAndFill())}}return e}function le(e,t){if(!v(e))return!1;if(t){const n=ie(e);t(se(e.tr,n,n.left))}return!0}function ae(e,t){if(!v(e))return!1;if(t){const n=ie(e);t(se(e.tr,n,n.right))}return!0}function ce(e,{map:t,table:n,tableStart:r},o){const i=e.mapping.maps.length;for(let s=0;s<t.height;){const l=s*t.width+o,a=t.map[l],c=n.nodeAt(a),d=c.attrs;if(o>0&&t.map[l-1]==a||o<t.width-1&&t.map[l+1]==a)e.setNodeMarkup(e.mapping.slice(i).map(r+a),null,O(d,o-t.colCount(a)));else{const t=e.mapping.slice(i).map(r+a);e.delete(t,t+c.nodeSize)}s+=d.rowspan}}function de(e,t){if(!v(e))return!1;if(t){const n=ie(e),r=e.tr;if(0==n.left&&n.right==n.map.width)return!1;for(let e=n.right-1;ce(r,n,e),e!=n.left;e--){const e=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!e)throw RangeError("No table found");n.table=e,n.map=d.get(e)}t(r)}return!0}function ue(e,t,n){var r;const o=m(t.type.schema).header_cell;for(let i=0;i<e.width;i++)if((null==(r=t.nodeAt(e.map[i+n*e.width]))?void 0:r.type)!=o)return!1;return!0}function he(e,{map:t,tableStart:n,table:r},o){var i;let s=n;for(let e=0;e<o;e++)s+=r.child(e).nodeSize;const l=[];let a=o>0?-1:0;ue(t,r,o+a)&&(a=0==o||o==t.height?null:0);for(let s=0,c=t.width*o;s<t.width;s++,c++)if(o>0&&o<t.height&&t.map[c]==t.map[c-t.width]){const o=t.map[c],i=r.nodeAt(o).attrs;e.setNodeMarkup(n+o,null,{...i,rowspan:i.rowspan+1}),s+=i.colspan-1}else{const e=null==a?m(r.type.schema).cell:null==(i=r.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,m(r.type.schema).row.create(null,l)),e}function pe(e,t){if(!v(e))return!1;if(t){const n=ie(e);t(he(e.tr,n,n.top))}return!0}function fe(e,t){if(!v(e))return!1;if(t){const n=ie(e);t(he(e.tr,n,n.bottom))}return!0}function me(e,{map:t,table:n,tableStart:r},o){let i=0;for(let e=0;e<o;e++)i+=n.child(e).nodeSize;const s=i+n.child(o).nodeSize,l=e.mapping.maps.length;e.delete(i+r,s+r);for(let i=0,s=o*t.width;i<t.width;i++,s++){const a=t.map[s];if(o>0&&a==t.map[s-t.width]){const t=n.nodeAt(a).attrs;e.setNodeMarkup(e.mapping.slice(l).map(a+r),null,{...t,rowspan:t.rowspan-1}),i+=t.colspan-1}else if(o<t.width&&a==t.map[s+t.width]){const s=n.nodeAt(a),c=s.attrs,d=s.type.create({...c,rowspan:s.attrs.rowspan-1},s.content),u=t.positionAt(o+1,i,n);e.insert(e.mapping.slice(l).map(r+u),d),i+=c.colspan-1}}}function ge(e,t){if(!v(e))return!1;if(t){const n=ie(e),r=e.tr;if(0==n.top&&n.bottom==n.map.height)return!1;for(let e=n.bottom-1;me(r,n,e),e!=n.top;e--){const e=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!e)throw RangeError("No table found");n.table=e,n.map=d.get(n.table)}t(r)}return!0}function ye(e){const t=e.content;return 1==t.childCount&&t.child(0).isTextblock&&0==t.child(0).childCount}function ve(e,t){const n=e.selection;if(!(n instanceof N)||n.$anchorCell.pos==n.$headCell.pos)return!1;const r=ie(e),{map:o}=r;if(function({width:e,height:t,map:n},r){let o=r.top*e+r.left,i=o,s=(r.bottom-1)*e+r.left,l=o+(r.right-r.left-1);for(let t=r.top;t<r.bottom;t++){if(r.left>0&&n[i]==n[i-1]||r.right<e&&n[l]==n[l+1])return!0;i+=e,l+=e}for(let i=r.left;i<r.right;i++){if(r.top>0&&n[o]==n[o-e]||r.bottom<t&&n[s]==n[s+e])return!0;o++,s++}return!1}(o,r))return!1;if(t){const n=e.tr,i={};let l,a,c=s.Fragment.empty;for(let e=r.top;e<r.bottom;e++)for(let t=r.left;t<r.right;t++){const s=o.map[e*o.width+t],d=r.table.nodeAt(s);if(!i[s]&&d)if(i[s]=!0,null==l)l=s,a=d;else{ye(d)||(c=c.append(d.content));const e=n.mapping.map(s+r.tableStart);n.delete(e,e+d.nodeSize)}}if(null==l||null==a)return!0;if(n.setNodeMarkup(l+r.tableStart,null,{...T(a.attrs,a.attrs.colspan,r.right-r.left-a.attrs.colspan),rowspan:r.bottom-r.top}),c.size){const e=l+1+a.content.size,t=ye(a)?l+1:e;n.replaceWith(t+r.tableStart,e+r.tableStart,c)}n.setSelection(new N(n.doc.resolve(l+r.tableStart))),t(n)}return!0}function be(e,t){const n=m(e.schema);return we(({node:e})=>n[e.type.spec.tableRole])(e,t)}function we(e){return(t,n)=>{var r;const o=t.selection;let i,s;if(o instanceof N){if(o.$anchorCell.pos!=o.$headCell.pos)return!1;i=o.$anchorCell.nodeAfter,s=o.$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}(o.$from),!i)return!1;s=null==(r=y(o.$from))?void 0:r.pos}if(null==i||null==s)return!1;if(1==i.attrs.colspan&&1==i.attrs.rowspan)return!1;if(n){let r=i.attrs;const l=[],a=r.colwidth;r.rowspan>1&&(r={...r,rowspan:1}),r.colspan>1&&(r={...r,colspan:1});const c=ie(t),d=t.tr;for(let e=0;e<c.right-c.left;e++)l.push(a?{...r,colwidth:a&&a[e]?[a[e]]:null}:r);let u;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 r=c.left,o=0;r<c.right;r++,o++)r==c.left&&t==c.top||d.insert(u=d.mapping.map(n+c.tableStart,1),e({node:i,row:t,col:r}).createAndFill(l[o]))}d.setNodeMarkup(s,e({node:i,row:c.top,col:c.left}),l[0]),o instanceof N&&d.setSelection(new N(d.doc.resolve(o.$anchorCell.pos),u?d.doc.resolve(u):void 0)),n(d)}return!0}}function Se(e,t){return function(n,r){if(!v(n))return!1;const o=b(n);if(o.nodeAfter.attrs[e]===t)return!1;if(r){const i=n.tr;n.selection instanceof N?n.selection.forEachCell((n,r)=>{n.attrs[e]!==t&&i.setNodeMarkup(r,null,{...n.attrs,[e]:t})}):i.setNodeMarkup(o.pos,null,{...o.nodeAfter.attrs,[e]:t}),r(i)}return!0}}function ke(e,t,n){const r=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<r.length;e++){const o=t.table.nodeAt(r[e]);if(o&&o.type!==n.header_cell)return!1}return!0}function xe(e,t){return(t=t||{useDeprecatedLogic:!1}).useDeprecatedLogic?function(e){return function(t,n){if(!v(t))return!1;if(n){const r=m(t.schema),o=ie(t),i=t.tr,s=o.map.cellsInRect("column"==e?{left:o.left,top:0,right:o.right,bottom:o.map.height}:"row"==e?{left:0,top:o.top,right:o.map.width,bottom:o.bottom}:o),l=s.map(e=>o.table.nodeAt(e));for(let e=0;e<s.length;e++)l[e].type==r.header_cell&&i.setNodeMarkup(o.tableStart+s[e],r.cell,l[e].attrs);if(0==i.steps.length)for(let e=0;e<s.length;e++)i.setNodeMarkup(o.tableStart+s[e],r.header_cell,l[e].attrs);n(i)}return!0}}(e):function(t,n){if(!v(t))return!1;if(n){const r=m(t.schema),o=ie(t),i=t.tr,s=ke("row",o,r),l=ke("column",o,r),a=("column"===e?s:"row"===e&&l)?1:0,c="column"==e?{left:0,top:a,right:1,bottom:o.map.height}:"row"==e?{left:a,top:0,right:o.map.width,bottom:1}:o,d="column"==e?l?r.cell:r.header_cell:"row"==e?s?r.cell:r.header_cell:r.cell;o.map.cellsInRect(c).forEach(e=>{const t=e+o.tableStart,n=i.doc.nodeAt(t);n&&i.setNodeMarkup(t,d,n.attrs)}),n(i)}return!0}}var Ce=xe("row",{useDeprecatedLogic:!0}),Me=xe("column",{useDeprecatedLogic:!0}),Oe=xe("cell",{useDeprecatedLogic:!0});function Te(e){return function(t,n){if(!v(t))return!1;const r=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 r=e.node(-1).child(t),o=r.lastChild;if(o)return n-1-o.nodeSize;n-=r.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),r=e.after();n<t.childCount;n++){const e=t.child(n);if(e.childCount)return r+1;r+=e.nodeSize}}return null}(b(t),e);if(null==r)return!1;if(n){const e=t.doc.resolve(r);n(t.tr.setSelection(i.TextSelection.between(e,S(e))).scrollIntoView())}return!0}}function Ae(e,t){const n=e.selection.$anchor;for(let r=n.depth;r>0;r--){if("table"==n.node(r).type.spec.tableRole)return t&&t(e.tr.delete(n.before(r),n.after(r)).scrollIntoView()),!0}return!1}function Ne({allowTableNodeSelection:e=!1}={}){return new i.Plugin({key:g,state:{init:()=>null,apply(e,t){const n=e.getMeta(g);if(null!=n)return-1==n?null:n;if(null==t||!e.docChanged)return t;const{deleted:r,pos:o}=e.mapping.mapResult(t);return r?null:o}},props:{decorations:D,handleDOMEvents:{mousedown:J},createSelectionBetween:e=>null!=g.getState(e.state)?e.state.selection:null,handleTripleClick:W,handleKeyDown:$,handlePaste:q},appendTransaction:(t,n,r)=>function(e,t,n){const r=(t||e).selection,o=(t||e).doc;let s,l;if(r instanceof i.NodeSelection&&(l=r.node.type.spec.tableRole)){if("cell"==l||"header_cell"==l)s=N.create(o,r.from);else if("row"==l){const e=o.resolve(r.from+1);s=N.rowSelection(e,e)}else if(!n){const e=d.get(r.node),t=r.from+1,n=t+e.map[e.width*e.height-1];s=N.create(o,t+1,n)}}else r instanceof i.TextSelection&&function({$from:e,$to:t}){if(e.pos==t.pos||e.pos<e.pos-6)return!1;let n=e.pos,r=t.pos,o=e.depth;for(;o>=0&&!(e.after(o+1)<e.end(o));o--,n++);for(let e=t.depth;e>=0&&!(t.before(e+1)>t.start(e));e--,r--);return n==r&&/row|table/.test(e.node(o).type.spec.tableRole)}(r)?s=i.TextSelection.create(o,r.from):r instanceof i.TextSelection&&function({$from:e,$to:t}){let n,r;for(let t=e.depth;t>0;t--){const r=e.node(t);if("cell"===r.type.spec.tableRole||"header_cell"===r.type.spec.tableRole){n=r;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){r=n;break}}return n!==r&&0===t.parentOffset}(r)&&(s=i.TextSelection.create(o,r.$from.start(),r.$from.end()));return s&&(t||(t=e.tr)).setSelection(s),t}(r,E(r,n),e)})}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setHtml=t.getHtml=t.parseContent=t.domToPmDoc=t.pmDocToFragment=t.fragmentToHtml=t.htmlToFragment=t.trimWhitespace=void 0;var r=n(0),o=n(1),i=n(6),s=["div","ol","ul","li","table","tbody","thead","tfoot","caption","td","th","p","tr","col","colgroup","article","main","nav","header","footer","aside","section"],l=function(e,t){var n=(e.ownerDocument||document).createElement(t);Array.from(e.rows).filter((function(e){return e.getAttribute(i.rowTypeAttr)===t})).forEach((function(e){e.removeAttribute(i.rowTypeAttr),n.appendChild(e)})),n.children.length&&e.appendChild(n)},a=function(e,t){var n=t.toUpperCase();e.filter((function(e){return e.nodeName===n})).forEach((function(e){Array.from(e.children).forEach((function(n){n.setAttribute(i.rowTypeAttr,t),e.parentNode&&e.parentNode.insertBefore(n,e)})),e.remove()}))};t.trimWhitespace=function(e,t){void 0===t&&(t=s);var n=t.join("|");return e.replace(new RegExp("\\s*(<(?:"+n+")(?:\\s[^>]*?)?>)","g"),"$1").replace(new RegExp("(<\\/(?:"+n+")(?:\\s[^>]*?)?>)\\s*","g"),"$1")};t.htmlToFragment=function(e){var t,n=document.createElement("template");if("content"in n)n.innerHTML=e,t=n.content;else{var r=(new DOMParser).parseFromString(e,"text/html");t=document.createDocumentFragment();for(var o=r.body;o&&o.firstChild;)t.appendChild(o.firstChild)}return t};t.fragmentToHtml=function(e){return Array.from(e.childNodes).reduce((function(e,t){return e+(t.outerHTML||t.textContent||"")}),"")};t.pmDocToFragment=function(e){var t=r.DOMSerializer.fromSchema(e.type.schema).serializeFragment(e.content);return function(e){Array.from(e.querySelectorAll("table")).forEach((function(e){l(e,"thead"),l(e,"tbody"),l(e,"tfoot");var t=Array.from(e.children).find((function(e){return 0===e.children.length}));t&&t.remove();var 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;var r=Array.from(n.children).find((function(e){return e.matches("div[caption]")}));if(r&&"<img>"!==r.innerHTML){var o=e.createCaption();for(r.id&&(o.id=r.id),r.className&&(o.className=r.className),Array.from(r.style).forEach((function(e){o.style[e]=r.style[e]}));r.firstChild;)o.appendChild(r.firstChild)}n.style.width&&!e.style.width&&(e.style.width=n.style.width),n.parentNode.insertBefore(e,n),n.parentNode.removeChild(n)}}))}(t),t};t.domToPmDoc=function(e,t,n){return r.DOMParser.fromSchema(t).parse(e,n)};t.parseContent=function(e,n,r){var o,s=t.htmlToFragment(e);return o=s,Array.from(o.querySelectorAll("table")).forEach((function(e){var t=Array.from(e.children);t.some((function(e){return"THEAD"===e.nodeName||"TFOOT"===e.nodeName}))&&(a(t,"thead"),a(t,"tbody"),a(t,"tfoot"));var n=t.find((function(e){return"COLGROUP"===e.nodeName}));if(n&&(e.setAttribute(i.colgroupAttr,n.outerHTML),n.remove()),e.caption||e.style.marginLeft||e.style.marginRight){var r=document.createElement("div");if(r.setAttribute("table",""),r.style.display="table",r.style.marginLeft=e.style.marginLeft,r.style.marginRight=e.style.marginRight,e.caption){var o=document.createElement("div");for(o.setAttribute("caption",""),e.caption.id&&(o.id=e.caption.id),e.caption.className&&(o.className=e.caption.className),Array.from(e.caption.style).forEach((function(t){o.style[t]=e.caption.style[t]}));e.caption.firstChild;)o.appendChild(e.caption.firstChild);e.removeChild(e.caption),r.appendChild(o)}e.parentNode.insertBefore(r,e),r.appendChild(e),/%/.test(e.style.width)&&(r.style.width=e.style.width,e.style.width="")}})),t.domToPmDoc(s,n,r)};t.getHtml=function(e){var n=t.pmDocToFragment(e.doc),r=document.createElement("div");return r.appendChild(n),r.innerHTML};t.setHtml=function(e,n,r){return void 0===n&&(n="setHTML"),void 0===r&&(r={preserveWhitespace:"full"}),function(i,s){return s(i.tr.setSelection(new o.AllSelection(i.doc)).replaceSelectionWith(t.parseContent(e,i.schema,r)).setMeta("commandName",n))}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getActiveMarks=t.getMark=t.selectionMarks=t.styleValue=t.hasMark=t.cleanMarks=t.removeAllMarks=t.removeMarks=t.removeMark=t.toggleMark=t.markApplies=void 0;var r=n(2),o=n(0);t.markApplies=function(e,t,n){for(var r=function(r){var o=t[r],i=o.$from,s=o.$to,l=0===i.depth&&e.type.allowsMarkType(n);if(e.nodesBetween(i.pos,s.pos,(function(e){if(l)return!1;l=e.inlineContent&&e.type.allowsMarkType(n)})),l)return{v:!0}},o=0;o<t.length;o++){var i=r(o);if(i)return i.v}return!1};t.toggleMark=function(e,n,r){return function(o,i){var s=o.selection,l=s.empty,a=s.$cursor,c=s.ranges;if(l&&!a||!t.markApplies(o.doc,c,e))return!1;if(i)if(a)e.isInSet(o.storedMarks||a.marks())?i(r.removeStoredMark(e)):i(r.addStoredMark(e.create(n)));else{for(var d=!1,u=0;!d&&u<c.length;u++){var h=c[u],p=h.$from,f=h.$to;d=o.doc.rangeHasMark(p.pos,f.pos,e)}for(u=0;u<c.length;u++){var m=c[u];p=m.$from,f=m.$to;d?r.removeMark(p.pos,f.pos,e):r.addMark(p.pos,f.pos,e.create(n))}i(r.scrollIntoView())}return!0}};t.removeMark=function(e,t,n,i){void 0===i&&(i=null);var s=[],l=0;return e.doc.nodesBetween(t,n,(function(e,r){if(e.isInline){l++;var a=null;if(i instanceof o.MarkType){var c=i.isInSet(e.marks);c&&(a=[c])}else i?i.isInSet(e.marks)&&(a=[i]):a=e.marks;if(a&&a.length)for(var d=Math.min(r+e.nodeSize,n),u=0;u<a.length;u++){for(var h=a[u],p=void 0,f=0;f<s.length;f++){var m=s[f];m.step===l-1&&h.eq(m.style)&&(p=m)}p?(p.to=d,p.step=l):s.push({style:h,from:Math.max(r,t),to:d,step:l})}}})),s.forEach((function(t){return e.step(new r.RemoveMarkStep(t.from,t.to,t.style))})),e};t.removeMarks=function(e,n,r,o){var i=n.selection,s=i.$cursor,l=i.ranges;if(o=o||n.tr,s)e.forEach((function(e){e.isInSet(n.storedMarks||s.marks())&&r(o.removeStoredMark(e))}));else{for(var a=function(n){var r=l[n],i=r.$from,s=r.$to;e.forEach((function(e){t.removeMark(o,i.pos,s.pos,e)}))},c=0;c<l.length;c++)a(c);r(o.scrollIntoView())}return!0};t.removeAllMarks=function(e){var n=(void 0===e?{}:e).except,r=void 0===n?[]:n;return function(e,n){var o,i=e.tr;t.cleanMarks(i,{except:(o=r,o instanceof Array?o:[o])}),i.docChanged&&n(i)}};t.cleanMarks=function(e,t){var n=t.except,r=e.doc,o=e.selection,i=r.type.schema,s=o.empty,l=o.ranges,a=(n||[]).map((function(e){return e.name}));if(!s){var c=Object.keys(i.marks).map((function(e){return i.marks[e]})).filter((function(e){return-1===a.indexOf(e.name)}));l.forEach((function(t){var n=t.$from,r=t.$to;c.forEach((function(t){return e.removeMark(n.pos,r.pos,t)}))}))}};t.hasMark=function(e,n){var r,o=e.schema.marks,i=(n.altMarks||[]).filter((function(e){return o[e]})),s=n.altStyle,l=e.selection,a=l.from,c=l.$from,d=l.to,u=l.empty,h=o[n.mark],p=e.doc,f=!1;return u?(r=e.storedMarks||c.marks(),f=h&&h.isInSet(r)||i.some((function(e){return o[e].isInSet(r)}))):f=h&&p.rangeHasMark(a,d,h)||i.some((function(e){return p.rangeHasMark(a,d,o[e])})),!f&&s&&o.style?t.selectionMarks(e,o.style).some((function(e){return null!==t.styleValue(e,s)})):Boolean(f)};t.styleValue=function(e,t){for(var n=(e&&e.attrs.style||"").split(/\s*;\s*/).filter((function(e){return Boolean(e)})),r=0;r<n.length;r++){var o=n[r].split(/\s*:\s*/);if(o[0].toLowerCase()===t.name&&t.value.test(o[1]))return o[1]}return null};t.selectionMarks=function(e,t){var n=e.selection,r=n.from,o=n.$from,i=n.to,s=n.empty,l=[];return s?l.push(t.isInSet(e.storedMarks||o.marks())):e.doc.nodesBetween(r,i,(function(e){e.isInline&&l.push(t.isInSet(e.marks))})),l};t.getMark=function(e,n){var r=t.selectionMarks(e,n),o=r.filter((function(e){return Boolean(e)}));return r.length===o.length?r[0]:void 0};t.getActiveMarks=function(e,n){var r=t.selectionMarks(e,n),o=r.filter((function(e){return Boolean(e)}));return{hasNodesWithoutMarks:r.length!==o.length,marks:o}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.edgeCell=t.parentNode=t.cellIndexes=t.domCellAround=t.getTable=t.otherResizeHandle=t.otherResizing=t.tableRowResizeKey=t.tableColumnResizeKey=t.tableResizeKey=t.setNodeStyle=t.parseStyle=t.reAnyValue=void 0;var r=n(4),o=n(1),i=n(7),s=n(5);t.reAnyValue=/^.+$/;function l(e,t){for(var n=e.depth;n>0;n--){var r=e.node(n);if(t(r))return{node:r,depth:n}}return null}t.parseStyle=function(e){return(e||"").split(/\s*;\s*/).filter(Boolean).map((function(e){var t,n=e.split(/\s*:\s*/);return(t={})[n[0]]=n[1],t})).reduce((function(e,t){return r.__assign(r.__assign({},e),t)}),{})},t.setNodeStyle=function(e,n,o){var i;if(new RegExp("[^-]?"+n+":").test(e.style||"")){var l=s.changeStylesString(e.style||"",{style:n,value:t.reAnyValue,newValue:o}).style;i=r.__assign(r.__assign({},e),{style:l})}else i=e.style?r.__assign(r.__assign({},e),{style:e.style.replace(/;$/,"")+"; "+n+": "+o+";"}):r.__assign(r.__assign({},e),{style:n+": "+o+";"});return i},t.tableResizeKey=new o.PluginKey("table-resize"),t.tableColumnResizeKey=new o.PluginKey("table-column-resizing"),t.tableRowResizeKey=new o.PluginKey("table-row-resizing"),t.otherResizing=function(e,n){var r=!1;return r=(r=(r=r||e!==t.tableResizeKey&&Boolean(t.tableResizeKey.get(n))&&t.tableResizeKey.getState(n).dragging)||e!==t.tableColumnResizeKey&&Boolean(t.tableColumnResizeKey.get(n))&&t.tableColumnResizeKey.getState(n).dragging)||e!==t.tableRowResizeKey&&Boolean(t.tableRowResizeKey.get(n))&&t.tableRowResizeKey.getState(n).dragging},t.otherResizeHandle=function(e,n){var r=!1;return r=(r=r||e!==t.tableColumnResizeKey&&Boolean(t.tableColumnResizeKey.get(n))&&t.tableColumnResizeKey.getState(n).activeHandle>-1)||e!==t.tableRowResizeKey&&Boolean(t.tableRowResizeKey.get(n))&&t.tableRowResizeKey.getState(n).activeHandle>-1},t.getTable=function(e){return e&&e.firstChild&&"TABLE"===e.firstChild.nodeName?e.firstChild:e},t.domCellAround=function(e){for(;e&&"TD"!==e.nodeName&&"TH"!==e.nodeName;)e=e.classList.contains("ProseMirror")?null:e.parentNode;return e},t.cellIndexes=function(e){for(var t=function(e){var t=Array.from(e&&e.rows||[]),n=Array.from(t&&t[0]&&t[0].cells||[]).map((function(e){return e.colSpan})).reduce((function(e,t){return e+t}),0),r=t.map((function(){return new Array(n)}));return t.forEach((function(e,t){var n=0;Array.from(e.cells).forEach((function(e){for(var o=0;o<e.colSpan;o++){for(var i=0;i<e.rowSpan;i++){var s=r[t+i].findIndex((function(e,t){return t>=n&&!e}));r[t+i][s]=e}n++}}))})),r}(e.closest("table")),n=null,r=function(r){if(t[r].forEach((function(t,o){e===t&&(n={rowIndex:r,cellIndex:o})})),n)return"break"},o=0;o<t.length;o++){if("break"===r(o))break}return n||{rowIndex:-1,cellIndex:-1}},t.parentNode=l,t.edgeCell=function(e,t,n){var r=e.posAtCoords({left:t.clientX,top:t.clientY});if(!r)return-1;var o=e.state.doc.resolve(r.pos),s=l(o,(function(e){return"table"===e.type.spec.tableRole}));if(null===s)return-1;var a=o.start(s.depth),c=s.node,d=i.TableMap.get(c);return a+d.map[d.width*n.rowIndex+n.cellIndex]}},function(e,t,n){"use strict";n.r(t),n.d(t,"keydownHandler",(function(){return f})),n.d(t,"keymap",(function(){return p}));for(var r={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:"'"},o={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},i="undefined"!=typeof navigator&&/Mac/.test(navigator.platform),s="undefined"!=typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),l=0;l<10;l++)r[48+l]=r[96+l]=String(l);for(l=1;l<=24;l++)r[l+111]="F"+l;for(l=65;l<=90;l++)r[l]=String.fromCharCode(l+32),o[l]=String.fromCharCode(l);for(var a in r)o.hasOwnProperty(a)||(o[a]=r[a]);var c=n(1);const d="undefined"!=typeof navigator&&/Mac|iP(hone|[oa]d)/.test(navigator.platform);function u(e){let t,n,r,o,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))o=!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))r=!0;else{if(!/^mod$/i.test(s))throw new Error("Unrecognized modifier name: "+s);d?o=!0:n=!0}}return t&&(s="Alt-"+s),n&&(s="Ctrl-"+s),o&&(s="Meta-"+s),r&&(s="Shift-"+s),s}function h(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 p(e){return new c.Plugin({props:{handleKeyDown:f(e)}})}function f(e){let t=function(e){let t=Object.create(null);for(let n in e)t[u(n)]=e[n];return t}(e);return function(e,n){let l,a=function(e){var t=!(i&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||s&&e.shiftKey&&e.key&&1==e.key.length||"Unidentified"==e.key)&&e.key||(e.shiftKey?o:r)[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),c=t[h(a,n)];if(c&&c(e.state,e.dispatch,e))return!0;if(1==a.length&&" "!=a){if(n.shiftKey){let r=t[h(a,n,!1)];if(r&&r(e.state,e.dispatch,e))return!0}if((n.shiftKey||n.altKey||n.metaKey||a.charCodeAt(0)>127)&&(l=r[n.keyCode])&&l!=a){let r=t[h(l,n)];if(r&&r(e.state,e.dispatch,e))return!0}}return!1}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.activeNode=t.parentBlockFormat=t.hasNode=t.addStyles=t.getBlockFormats=t.cleanTextBlockFormatting=t.formatBlockElements=t.blockNodes=t.changeTextBlock=void 0;var r=n(4),o=n(5),i=n(2),s=n(0),l=n(1);t.changeTextBlock=function(e,t,n,r){if(!n.isTextblock)return!1;e.selection.ranges.forEach((function(o){var l=e.steps.length,a=o.$from.pos,c=o.$to.pos;e.doc.nodesBetween(a,c,(function(o,a){if(o.eq(t)&&o.isTextblock&&!o.hasMarkup(n,r)&&function(e,t,n){var r=e.resolve(t),o=r.index();return r.parent.canReplaceWith(o,o+1,n)}(e.doc,e.mapping.slice(l).map(a),n)){e.clearIncompatible(e.mapping.slice(l).map(a,1),n);var c=e.mapping.slice(l),d=c.map(a,1),u=c.map(a+o.nodeSize,1),h=new s.Slice(s.Fragment.from(n.create(r,null,o.marks)),0,0);return e.step(new i.ReplaceAroundStep(d,u,d+1,u-1,h,1,!0)),!1}}))}))};t.blockNodes=function(e,t){void 0===t&&(t={blocksInSelection:!1});var n=e.doc,r=e.selection,o=r.$from,i=r.ranges,s=t.blocksInSelection,a=[],c=r instanceof l.NodeSelection?r.node:void 0;return c?c.isBlock?(a.push(c),c.nodesBetween(0,c.content.size,(function(e){e.isBlock&&a.push(e)}))):!s&&o.parent&&o.parent.isBlock&&a.push(o.parent):i.forEach((function(e){var t=e.$from.pos,r=e.$to.pos;n.nodesBetween(t,r,(function(e,n,o,i){e.isBlock&&(!s||n>=t&&n+e.content.size+2<=r)&&a.push(e)}))})),a};t.formatBlockElements=function(e,n){return function(o,i){var s=t.blockNodes(o),l=o.schema.nodes,a=o.tr;a.setMeta("commandName",n),a.setMeta("args",{value:e}),s.forEach((function(n){if(n.type.isTextblock)if("p"===e){var o=n.attrs,i=o.level,s=r.__rest(o,["level"]);t.changeTextBlock(a,n,l.paragraph,s)}else if(/^h[1-6]$/i.test(e)){i=parseInt(e.substr(1),10);t.changeTextBlock(a,n,l.heading,r.__assign(r.__assign({},n.attrs),{level:i}))}else if("blockquote"===e){var c=n.attrs;i=c.level,s=r.__rest(c,["level"]);t.changeTextBlock(a,n,l.blockquote,s)}}));var c=a.docChanged;return c&&i(a.scrollIntoView()),c}};t.cleanTextBlockFormatting=function(e,n){void 0===n&&(n={blocksInSelection:!0});var o=e.doc,i=e.selection,s=n.blocksInSelection,l=n.blockNodeType;t.blockNodes({doc:o,selection:i},{blocksInSelection:s}).filter((function(e){return e.isTextblock})).forEach((function(n){var o=n.attrs||{},i=o.style,s=void 0===i?"":i,a=o.class,c=void 0===a?"":a,d=r.__rest(o,["style","class"]),u=l||n.type;(s||c||u!==n.type)&&t.changeTextBlock(e,n,u,d)}))};t.getBlockFormats=function(e){var n=t.blockNodes(e),r=e.schema.nodes,o=[];return n.forEach((function(e){e.type===r.paragraph?o.push("p"):e.type===r.heading?o.push("h"+e.attrs.level):e.type===r.blockquote&&r.blockquote.isTextblock&&o.push("blockquote")})),o};t.addStyles=function(e,t){var n,r,i=e.attrs.style;i&&t.forEach((function(e){r={style:e.name,value:/^.+$/,newValue:e.value},n=o.changeStylesString(i,r),i=n.changed?n.style:i}));return i=i||t.reduce((function(e,t){return(e&&t.value?e+" ":"")+t.value?t.name+": "+t.value+";":""}),""),Object.assign({},e.attrs,{style:i||null})};t.hasNode=function(e,t){var n=e.selection,r=n.from,o=n.to,i=!1;return e.doc.nodesBetween(r,o,(function(e){return!(i=i||e.type===t)})),i};t.parentBlockFormat=function(e){var n=t.getBlockFormats(e);return 1===new Set(n).size?n[0]:null};t.activeNode=function(e){return{tag:t.parentBlockFormat(e)||""}}},function(e,t,n){"use strict";n.r(t),n.d(t,"autoJoin",(function(){return j})),n.d(t,"baseKeymap",(function(){return W})),n.d(t,"chainCommands",(function(){return $})),n.d(t,"createParagraphNear",(function(){return M})),n.d(t,"deleteSelection",(function(){return s})),n.d(t,"exitCode",(function(){return C})),n.d(t,"joinBackward",(function(){return a})),n.d(t,"joinDown",(function(){return w})),n.d(t,"joinForward",(function(){return g})),n.d(t,"joinTextblockBackward",(function(){return c})),n.d(t,"joinTextblockForward",(function(){return d})),n.d(t,"joinUp",(function(){return b})),n.d(t,"lift",(function(){return S})),n.d(t,"liftEmptyBlock",(function(){return O})),n.d(t,"macBaseKeymap",(function(){return H})),n.d(t,"newlineInCode",(function(){return k})),n.d(t,"pcBaseKeymap",(function(){return K})),n.d(t,"selectAll",(function(){return D})),n.d(t,"selectNodeBackward",(function(){return p})),n.d(t,"selectNodeForward",(function(){return y})),n.d(t,"selectParentNode",(function(){return R})),n.d(t,"selectTextblockEnd",(function(){return z})),n.d(t,"selectTextblockStart",(function(){return P})),n.d(t,"setBlockType",(function(){return F})),n.d(t,"splitBlock",(function(){return A})),n.d(t,"splitBlockAs",(function(){return T})),n.d(t,"splitBlockKeepMarks",(function(){return N})),n.d(t,"toggleMark",(function(){return B})),n.d(t,"wrapIn",(function(){return I}));var r=n(2),o=n(0),i=n(1);const s=(e,t)=>!e.selection.empty&&(t&&t(e.tr.deleteSelection().scrollIntoView()),!0);function l(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock("backward",e):n.parentOffset>0)?null:n}const a=(e,t,n)=>{let s=l(e,n);if(!s)return!1;let a=f(s);if(!a){let n=s.blockRange(),o=n&&Object(r.liftTarget)(n);return null!=o&&(t&&t(e.tr.lift(n,o).scrollIntoView()),!0)}let c=a.nodeBefore;if(!c.type.spec.isolating&&_(e,a,t))return!0;if(0==s.parent.content.size&&(h(c,"end")||i.NodeSelection.isSelectable(c))){let n=Object(r.replaceStep)(e.doc,s.before(),s.after(),o.Slice.empty);if(n&&n.slice.size<n.to-n.from){if(t){let r=e.tr.step(n);r.setSelection(h(c,"end")?i.Selection.findFrom(r.doc.resolve(r.mapping.map(a.pos,-1)),-1):i.NodeSelection.create(r.doc,a.pos-c.nodeSize)),t(r.scrollIntoView())}return!0}}return!(!c.isAtom||a.depth!=s.depth-1)&&(t&&t(e.tr.delete(a.pos-c.nodeSize,a.pos).scrollIntoView()),!0)},c=(e,t,n)=>{let r=l(e,n);if(!r)return!1;let o=f(r);return!!o&&u(e,o,t)},d=(e,t,n)=>{let r=m(e,n);if(!r)return!1;let o=v(r);return!!o&&u(e,o,t)};function u(e,t,n){let s=t.nodeBefore,l=t.pos-1;for(;!s.isTextblock;l--){if(s.type.spec.isolating)return!1;let e=s.lastChild;if(!e)return!1;s=e}let a=t.nodeAfter,c=t.pos+1;for(;!a.isTextblock;c++){if(a.type.spec.isolating)return!1;let e=a.firstChild;if(!e)return!1;a=e}let d=Object(r.replaceStep)(e.doc,l,c,o.Slice.empty);if(!d||d.from!=l||d instanceof r.ReplaceStep&&d.slice.size>=c-l)return!1;if(n){let t=e.tr.step(d);t.setSelection(i.TextSelection.create(t.doc,l)),n(t.scrollIntoView())}return!0}function h(e,t,n=!1){for(let r=e;r;r="start"==t?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&1!=r.childCount)return!1}return!1}const p=(e,t,n)=>{let{$head:r,empty:o}=e.selection,s=r;if(!o)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",e):r.parentOffset>0)return!1;s=f(r)}let l=s&&s.nodeBefore;return!(!l||!i.NodeSelection.isSelectable(l))&&(t&&t(e.tr.setSelection(i.NodeSelection.create(e.doc,s.pos-l.nodeSize)).scrollIntoView()),!0)};function f(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 m(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock("forward",e):n.parentOffset<n.parent.content.size)?null:n}const g=(e,t,n)=>{let s=m(e,n);if(!s)return!1;let l=v(s);if(!l)return!1;let a=l.nodeAfter;if(_(e,l,t))return!0;if(0==s.parent.content.size&&(h(a,"start")||i.NodeSelection.isSelectable(a))){let n=Object(r.replaceStep)(e.doc,s.before(),s.after(),o.Slice.empty);if(n&&n.slice.size<n.to-n.from){if(t){let r=e.tr.step(n);r.setSelection(h(a,"start")?i.Selection.findFrom(r.doc.resolve(r.mapping.map(l.pos)),1):i.NodeSelection.create(r.doc,r.mapping.map(l.pos))),t(r.scrollIntoView())}return!0}}return!(!a.isAtom||l.depth!=s.depth-1)&&(t&&t(e.tr.delete(l.pos,l.pos+a.nodeSize).scrollIntoView()),!0)},y=(e,t,n)=>{let{$head:r,empty:o}=e.selection,s=r;if(!o)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",e):r.parentOffset<r.parent.content.size)return!1;s=v(r)}let l=s&&s.nodeAfter;return!(!l||!i.NodeSelection.isSelectable(l))&&(t&&t(e.tr.setSelection(i.NodeSelection.create(e.doc,s.pos)).scrollIntoView()),!0)};function v(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 b=(e,t)=>{let n,o=e.selection,s=o instanceof i.NodeSelection;if(s){if(o.node.isTextblock||!Object(r.canJoin)(e.doc,o.from))return!1;n=o.from}else if(n=Object(r.joinPoint)(e.doc,o.from,-1),null==n)return!1;if(t){let r=e.tr.join(n);s&&r.setSelection(i.NodeSelection.create(r.doc,n-e.doc.resolve(n).nodeBefore.nodeSize)),t(r.scrollIntoView())}return!0},w=(e,t)=>{let n,o=e.selection;if(o instanceof i.NodeSelection){if(o.node.isTextblock||!Object(r.canJoin)(e.doc,o.to))return!1;n=o.to}else if(n=Object(r.joinPoint)(e.doc,o.to,1),null==n)return!1;return t&&t(e.tr.join(n).scrollIntoView()),!0},S=(e,t)=>{let{$from:n,$to:o}=e.selection,i=n.blockRange(o),s=i&&Object(r.liftTarget)(i);return null!=s&&(t&&t(e.tr.lift(i,s).scrollIntoView()),!0)},k=(e,t)=>{let{$head:n,$anchor:r}=e.selection;return!(!n.parent.type.spec.code||!n.sameParent(r))&&(t&&t(e.tr.insertText("\n").scrollIntoView()),!0)};function x(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 C=(e,t)=>{let{$head:n,$anchor:r}=e.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let o=n.node(-1),s=n.indexAfter(-1),l=x(o.contentMatchAt(s));if(!l||!o.canReplaceWith(s,s,l))return!1;if(t){let r=n.after(),o=e.tr.replaceWith(r,r,l.createAndFill());o.setSelection(i.Selection.near(o.doc.resolve(r),1)),t(o.scrollIntoView())}return!0},M=(e,t)=>{let n=e.selection,{$from:r,$to:o}=n;if(n instanceof i.AllSelection||r.parent.inlineContent||o.parent.inlineContent)return!1;let s=x(o.parent.contentMatchAt(o.indexAfter()));if(!s||!s.isTextblock)return!1;if(t){let n=(!r.parentOffset&&o.index()<o.parent.childCount?r:o).pos,l=e.tr.insert(n,s.createAndFill());l.setSelection(i.TextSelection.create(l.doc,n+1)),t(l.scrollIntoView())}return!0},O=(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(Object(r.canSplit)(e.doc,o))return t&&t(e.tr.split(o).scrollIntoView()),!0}let o=n.blockRange(),i=o&&Object(r.liftTarget)(o);return null!=i&&(t&&t(e.tr.lift(o,i).scrollIntoView()),!0)};function T(e){return(t,n)=>{let{$from:o,$to:s}=t.selection;if(t.selection instanceof i.NodeSelection&&t.selection.node.isBlock)return!(!o.parentOffset||!Object(r.canSplit)(t.doc,o.pos))&&(n&&n(t.tr.split(o.pos).scrollIntoView()),!0);if(!o.parent.isBlock)return!1;if(n){let l=s.parentOffset==s.parent.content.size,a=t.tr;(t.selection instanceof i.TextSelection||t.selection instanceof i.AllSelection)&&a.deleteSelection();let c=0==o.depth?null:x(o.node(-1).contentMatchAt(o.indexAfter(-1))),d=e&&e(s.parent,l),u=d?[d]:l&&c?[{type:c}]:void 0,h=Object(r.canSplit)(a.doc,a.mapping.map(o.pos),1,u);if(u||h||!Object(r.canSplit)(a.doc,a.mapping.map(o.pos),1,c?[{type:c}]:void 0)||(c&&(u=[{type:c}]),h=!0),h&&(a.split(a.mapping.map(o.pos),1,u),!l&&!o.parentOffset&&o.parent.type!=c)){let e=a.mapping.map(o.before()),t=a.doc.resolve(e);c&&o.node(-1).canReplaceWith(t.index(),t.index()+1,c)&&a.setNodeMarkup(a.mapping.map(o.before()),c)}n(a.scrollIntoView())}return!0}}const A=T(),N=(e,t)=>A(e,t&&(n=>{let r=e.storedMarks||e.selection.$to.parentOffset&&e.selection.$from.marks();r&&n.ensureMarks(r),t(n)})),R=(e,t)=>{let n,{$from:r,to:o}=e.selection,s=r.sharedDepth(o);return 0!=s&&(n=r.before(s),t&&t(e.tr.setSelection(i.NodeSelection.create(e.doc,n))),!0)},D=(e,t)=>(t&&t(e.tr.setSelection(new i.AllSelection(e.doc))),!0);function _(e,t,n){let s,l,a=t.nodeBefore,c=t.nodeAfter;if(a.type.spec.isolating||c.type.spec.isolating)return!1;if(function(e,t,n){let o=t.nodeBefore,i=t.nodeAfter,s=t.index();return!!(o&&i&&o.type.compatibleContent(i.type))&&(!o.content.size&&t.parent.canReplace(s-1,s)?(n&&n(e.tr.delete(t.pos-o.nodeSize,t.pos).scrollIntoView()),!0):!(!t.parent.canReplace(s,s+1)||!i.isTextblock&&!Object(r.canJoin)(e.doc,t.pos))&&(n&&n(e.tr.clearIncompatible(t.pos,o.type,o.contentMatchAt(o.childCount)).join(t.pos).scrollIntoView()),!0))}(e,t,n))return!0;let d=t.parent.canReplace(t.index(),t.index()+1);if(d&&(s=(l=a.contentMatchAt(a.childCount)).findWrapping(c.type))&&l.matchType(s[0]||c.type).validEnd){if(n){let i=t.pos+c.nodeSize,l=o.Fragment.empty;for(let e=s.length-1;e>=0;e--)l=o.Fragment.from(s[e].create(null,l));l=o.Fragment.from(a.copy(l));let d=e.tr.step(new r.ReplaceAroundStep(t.pos-1,i,t.pos,i,new o.Slice(l,1,0),s.length,!0)),u=i+2*s.length;Object(r.canJoin)(d.doc,u)&&d.join(u),n(d.scrollIntoView())}return!0}let u=i.Selection.findFrom(t,1),p=u&&u.$from.blockRange(u.$to),f=p&&Object(r.liftTarget)(p);if(null!=f&&f>=t.depth)return n&&n(e.tr.lift(p,f).scrollIntoView()),!0;if(d&&h(c,"start",!0)&&h(a,"end")){let i=a,s=[];for(;s.push(i),!i.isTextblock;)i=i.lastChild;let l=c,d=1;for(;!l.isTextblock;l=l.firstChild)d++;if(i.canReplace(i.childCount,i.childCount,l.content)){if(n){let i=o.Fragment.empty;for(let e=s.length-1;e>=0;e--)i=o.Fragment.from(s[e].copy(i));n(e.tr.step(new r.ReplaceAroundStep(t.pos-s.length,t.pos+c.nodeSize,t.pos+d,t.pos+c.nodeSize-d,new o.Slice(i,s.length,0),0,!0)).scrollIntoView())}return!0}}return!1}function E(e){return function(t,n){let r=t.selection,o=e<0?r.$from:r.$to,s=o.depth;for(;o.node(s).isInline;){if(!s)return!1;s--}return!!o.node(s).isTextblock&&(n&&n(t.tr.setSelection(i.TextSelection.create(t.doc,e<0?o.start(s):o.end(s)))),!0)}}const P=E(-1),z=E(1);function I(e,t=null){return function(n,o){let{$from:i,$to:s}=n.selection,l=i.blockRange(s),a=l&&Object(r.findWrapping)(l,e,t);return!!a&&(o&&o(n.tr.wrap(l,a).scrollIntoView()),!0)}}function F(e,t=null){return function(n,r){let o=!1;for(let r=0;r<n.selection.ranges.length&&!o;r++){let{$from:{pos:i},$to:{pos:s}}=n.selection.ranges[r];n.doc.nodesBetween(i,s,(r,i)=>{if(o)return!1;if(r.isTextblock&&!r.hasMarkup(e,t))if(r.type==e)o=!0;else{let t=n.doc.resolve(i),r=t.index();o=t.parent.canReplaceWith(r,r+1,e)}})}if(!o)return!1;if(r){let o=n.tr;for(let r=0;r<n.selection.ranges.length;r++){let{$from:{pos:i},$to:{pos:s}}=n.selection.ranges[r];o.setBlockType(i,s,e,t)}r(o.scrollIntoView())}return!0}}function B(e,t=null){return function(n,r){let{empty:o,$cursor:i,ranges:s}=n.selection;if(o&&!i||!function(e,t,n){for(let r=0;r<t.length;r++){let{$from:o,$to:i}=t[r],s=0==o.depth&&(e.inlineContent&&e.type.allowsMarkType(n));if(e.nodesBetween(o.pos,i.pos,e=>{if(s)return!1;s=e.inlineContent&&e.type.allowsMarkType(n)}),s)return!0}return!1}(n.doc,s,e))return!1;if(r)if(i)e.isInSet(n.storedMarks||i.marks())?r(n.tr.removeStoredMark(e)):r(n.tr.addStoredMark(e.create(t)));else{let o=!1,i=n.tr;for(let t=0;!o&&t<s.length;t++){let{$from:r,$to:i}=s[t];o=n.doc.rangeHasMark(r.pos,i.pos,e)}for(let n=0;n<s.length;n++){let{$from:r,$to:l}=s[n];if(o)i.removeMark(r.pos,l.pos,e);else{let n=r.pos,o=l.pos,s=r.nodeAfter,a=l.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<o&&(n+=c,o-=d),i.addMark(n,o,e.create(t))}}r(i.scrollIntoView())}return!0}}function j(e,t){let n=Array.isArray(t)?e=>t.indexOf(e.type.name)>-1:t;return(t,o,i)=>e(t,o&&function(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 i=[];for(let e=0;e<o.length;e+=2){let r=o[e],s=o[e+1],l=n.doc.resolve(r),a=l.sharedDepth(s),c=l.node(a);for(let e=l.indexAfter(a),n=l.after(a+1);n<=s;++e){let r=c.maybeChild(e);if(!r)break;if(e&&-1==i.indexOf(n)){let o=c.child(e-1);o.type==r.type&&t(o,r)&&i.push(n)}n+=r.nodeSize}}i.sort((e,t)=>e-t);for(let e=i.length-1;e>=0;e--)Object(r.canJoin)(n.doc,i[e])&&n.join(i[e]);e(n)}}(o,n),i)}function $(...e){return function(t,n,r){for(let o=0;o<e.length;o++)if(e[o](t,n,r))return!0;return!1}}let L=$(s,a,p),V=$(s,g,y);const K={Enter:$(k,M,O,A),"Mod-Enter":C,Backspace:L,"Mod-Backspace":L,"Shift-Backspace":L,Delete:V,"Mod-Delete":V,"Mod-a":D},H={"Ctrl-h":K.Backspace,"Alt-Backspace":K["Mod-Backspace"],"Ctrl-d":K.Delete,"Ctrl-Alt-Backspace":K["Mod-Delete"],"Alt-Delete":K["Mod-Delete"],"Alt-d":K["Mod-Delete"],"Ctrl-a":P,"Ctrl-e":z};for(let e in K)H[e]=K[e];const W=("undefined"!=typeof navigator?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!("undefined"==typeof os||!os.platform)&&"darwin"==os.platform())?H:K},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.applyInlineStyle=t.toggleInlineFormat=t.getInlineStyles=void 0;var r=n(4),o=n(2),i=n(5),s=n(9),l=function(e,t){var n=e.find((function(e){return"style"===e.type.name})),r=n&&n.attrs.style;return i.changeStylesString(r,t)},a=function(e,t,n,i,s){var a=s.create({style:i.style}),c=[],d=[],u=null,h=null;return e.doc.nodesBetween(t,n,(function(e,p,f){if(e.isInline){var m=e.marks;if(!a.isInSet(m)&&f.type.allowsMarkType(a.type)){var g=Math.max(p,t),y=Math.min(p+e.nodeSize,n),v=l(m,i);if(v.changed||i.newValue){for(var b=v.changed?{style:v.style||null}:{style:[i.style]+": "+i.newValue+";"},w=s.isInSet(m)?m.find((function(e){return"style"===e.type.name})):null,S=w?r.__assign(r.__assign({},w.attrs),b):b,k=s.create(S),x=k.addToSet(m),C=0;C<m.length;C++)m[C].isInSet(x)||(u&&u.to===g&&u.mark.eq(m[C])?u.to=y:(u=new o.RemoveMarkStep(g,y,m[C]),c.push(u)));var M=h&&h.to===g,O=M&&k.attrs.style===h.mark.attrs.style;M&&O?h.to=y:Object.keys(S).some((function(e){return null!==S[e]}))&&(h=new o.AddMarkStep(g,y,k),d.push(h))}}}})),c.forEach((function(t){return e.step(t)})),d.forEach((function(t){return e.step(t)})),c.length+d.length>0};t.getInlineStyles=function(e,t){var n=e.schema.marks.style;return(n?s.selectionMarks(e,n):[]).map((function(e){return s.styleValue(e,t)})).filter((function(e){return null!==e}))};var c=function(e,t){return function(n,o,c){var d=n.selection,u=d.empty,h=d.$cursor,p=d.ranges;if(u&&!h||!s.markApplies(n.doc,p,e))return!1;var f=!1;if(o){var m=c||n.tr;if(h){var g=n.storedMarks||h.marks();if(e.isInSet(g)){var y=l(g,t),v=g.find((function(e){return"style"===e.type.name})),b=r.__assign(r.__assign({},v?v.attrs:{}),{style:y.style||null});if(i.shallowEqual(v.attrs,b))return!1;o(m.removeStoredMark(e)),Object.keys(b).some((function(e){return null!==b[e]}))&&o(m.addStoredMark(e.create(b))),f=!0}}else{for(var w=0;w<p.length;w++){var S=p[w],k=S.$from,x=S.$to;f=a(m,k.pos,x.pos,t,e)}f&&(m.scrollIntoView(),o(m))}}return f}};t.toggleInlineFormat=function(e,t,n){return function(o,i){var l=o.schema.marks,a=e.altStyle,d=e.altMarks,u=void 0===d?[]:d,h=e.mark,p=t||o.tr,f=!1,m=!1,g=function(){return m=!0};a&&l.style&&(f=c(l.style,{style:a.name,value:a.value})(o,g,p));var y=r.__spreadArray([h],u).filter((function(e){return l[e]})).map((function(e){return s.hasMark(o,{mark:e})&&l[e]})).filter((function(e){return e}));return y.length?s.removeMarks(y,o,g,p):f||s.toggleMark(l[h],n,p)(o,g),m&&i(p),m}};t.applyInlineStyle=function(e,t){return function(n,o){var l=n.schema.marks.style,a={style:e.style,value:/^.+$/,newValue:e.value},d=n.tr;t&&d.setMeta("commandName",t),d.setMeta("args",e);var u=n.selection,h=u.empty,p=u.$cursor,f=u.ranges;if(h&&!p||!l||!s.markApplies(n.doc,f,l))return!1;if(p){var m=n.storedMarks||p.marks(),g=l.isInSet(m)?m.find((function(e){return"style"===e.type.name})):null,y={style:null};if(g&&g.attrs.style){var v=i.changeStylesString(g.attrs.style,a);v.changed&&v.style&&(y.style=v.style)}else a.newValue&&(y.style=[a.style]+": "+a.newValue+";");var b=g?r.__assign(r.__assign({},g.attrs),y):y;return Object.keys(b).some((function(e){return null!==b[e]}))?o(d.addStoredMark(l.create(b))):o(d.removeStoredMark(l)),!0}return c(l,a)(n,o,d)}}},function(e,t,n){"use strict";n.r(t),n.d(t,"addListNodes",(function(){return p})),n.d(t,"bulletList",(function(){return d})),n.d(t,"liftListItem",(function(){return g})),n.d(t,"listItem",(function(){return u})),n.d(t,"orderedList",(function(){return c})),n.d(t,"sinkListItem",(function(){return y})),n.d(t,"splitListItem",(function(){return m})),n.d(t,"wrapInList",(function(){return f}));var r=n(2),o=n(0),i=n(1);const s=["ol",0],l=["ul",0],a=["li",0],c={attrs:{order:{default:1}},parseDOM:[{tag:"ol",getAttrs:e=>({order:e.hasAttribute("start")?+e.getAttribute("start"):1})}],toDOM:e=>1==e.attrs.order?s:["ol",{start:e.attrs.order},0]},d={parseDOM:[{tag:"ul"}],toDOM:()=>l},u={parseDOM:[{tag:"li"}],toDOM:()=>a,defining:!0};function h(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 p(e,t,n){return e.append({ordered_list:h(c,{content:"list_item+",group:n}),bullet_list:h(d,{content:"list_item+",group:n}),list_item:h(u,{content:t})})}function f(e,t=null){return function(n,i){let{$from:s,$to:l}=n.selection,a=s.blockRange(l),c=!1,d=a;if(!a)return!1;if(a.depth>=2&&s.node(a.depth-1).type.compatibleContent(e)&&0==a.startIndex){if(0==s.index(a.depth-1))return!1;let e=n.doc.resolve(a.start-2);d=new o.NodeRange(e,e,a.depth),a.endIndex<a.parent.childCount&&(a=new o.NodeRange(s,n.doc.resolve(l.end(a.depth)),a.depth)),c=!0}let u=Object(r.findWrapping)(d,e,t,a);return!!u&&(i&&i(function(e,t,n,i,s){let l=o.Fragment.empty;for(let e=n.length-1;e>=0;e--)l=o.Fragment.from(n[e].type.create(n[e].attrs,l));e.step(new r.ReplaceAroundStep(t.start-(i?2:0),t.end,t.start,t.end,new o.Slice(l,0,0),n.length,!0));let a=0;for(let e=0;e<n.length;e++)n[e].type==s&&(a=e+1);let c=n.length-a,d=t.start+n.length-(i?2:0),u=t.parent;for(let n=t.startIndex,o=t.endIndex,i=!0;n<o;n++,i=!1)!i&&Object(r.canSplit)(e.doc,d,c)&&(e.split(d,c),d+=2*c),d+=u.child(n).nodeSize;return e}(n.tr,a,u,c,e).scrollIntoView()),!0)}}function m(e,t){return function(n,s){let{$from:l,$to:a,node:c}=n.selection;if(c&&c.isBlock||l.depth<2||!l.sameParent(a))return!1;let d=l.node(-1);if(d.type!=e)return!1;if(0==l.parent.content.size&&l.node(-1).childCount==l.indexAfter(-1)){if(3==l.depth||l.node(-3).type!=e||l.index(-2)!=l.node(-2).childCount-1)return!1;if(s){let t=o.Fragment.empty,r=l.index(-1)?1:l.index(-2)?2:3;for(let e=l.depth-r;e>=l.depth-3;e--)t=o.Fragment.from(l.node(e).copy(t));let a=l.indexAfter(-1)<l.node(-2).childCount?1:l.indexAfter(-2)<l.node(-3).childCount?2:3;t=t.append(o.Fragment.from(e.createAndFill()));let c=l.before(l.depth-(r-1)),d=n.tr.replace(c,l.after(-a),new o.Slice(t,4-r,0)),u=-1;d.doc.nodesBetween(c,d.doc.content.size,(e,t)=>{if(u>-1)return!1;e.isTextblock&&0==e.content.size&&(u=t+1)}),u>-1&&d.setSelection(i.Selection.near(d.doc.resolve(u))),s(d.scrollIntoView())}return!0}let u=a.pos==l.end()?d.contentMatchAt(0).defaultType:null,h=n.tr.delete(l.pos,a.pos),p=u?[t?{type:e,attrs:t}:null,{type:u}]:void 0;return!!Object(r.canSplit)(h.doc,l.pos,2,p)&&(s&&s(h.split(l.pos,2,p).scrollIntoView()),!0)}}function g(e){return function(t,n){let{$from:i,$to:s}=t.selection,l=i.blockRange(s,t=>t.childCount>0&&t.firstChild.type==e);return!!l&&(!n||(i.node(l.depth-1).type==e?function(e,t,n,i){let s=e.tr,l=i.end,a=i.$to.end(i.depth);l<a&&(s.step(new r.ReplaceAroundStep(l-1,a,l,a,new o.Slice(o.Fragment.from(n.create(null,i.parent.copy())),1,0),1,!0)),i=new o.NodeRange(s.doc.resolve(i.$from.pos),s.doc.resolve(a),i.depth));const c=Object(r.liftTarget)(i);if(null==c)return!1;s.lift(i,c);let d=s.mapping.map(l,-1)-1;Object(r.canJoin)(s.doc,d)&&s.join(d);return t(s.scrollIntoView()),!0}(t,n,e,l):function(e,t,n){let i=e.tr,s=n.parent;for(let e=n.end,t=n.endIndex-1,r=n.startIndex;t>r;t--)e-=s.child(t).nodeSize,i.delete(e-1,e+1);let l=i.doc.resolve(n.start),a=l.nodeAfter;if(i.mapping.map(n.end)!=n.start+l.nodeAfter.nodeSize)return!1;let c=0==n.startIndex,d=n.endIndex==s.childCount,u=l.node(-1),h=l.index(-1);if(!u.canReplace(h+(c?0:1),h+1,a.content.append(d?o.Fragment.empty:o.Fragment.from(s))))return!1;let p=l.pos,f=p+a.nodeSize;return i.step(new r.ReplaceAroundStep(p-(c?1:0),f+(d?1:0),p+1,f-1,new o.Slice((c?o.Fragment.empty:o.Fragment.from(s.copy(o.Fragment.empty))).append(d?o.Fragment.empty:o.Fragment.from(s.copy(o.Fragment.empty))),c?0:1,d?0:1),c?0:1)),t(i.scrollIntoView()),!0}(t,n,l)))}}function y(e){return function(t,n){let{$from:i,$to:s}=t.selection,l=i.blockRange(s,t=>t.childCount>0&&t.firstChild.type==e);if(!l)return!1;let a=l.startIndex;if(0==a)return!1;let c=l.parent,d=c.child(a-1);if(d.type!=e)return!1;if(n){let i=d.lastChild&&d.lastChild.type==c.type,s=o.Fragment.from(i?e.create():null),a=new o.Slice(o.Fragment.from(e.create(null,o.Fragment.from(c.type.create(null,s)))),i?3:1,0),u=l.start,h=l.end;n(t.tr.step(new r.ReplaceAroundStep(u-(i?3:1),h,u,h,a,1,!0)).scrollIntoView())}return!0}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.marks=t.nodes=t.parseStrColgroup=void 0;var r=n(4),o=n(0),i=n(7),s=n(8),l=n(6),a=["blockquote",0],c=["hr"],d=["pre",["code",0]],u=["ol",0],h=["ul",0],p=["li",0],f=function(e){for(var t,n={},r=e.attributes,o=0;o<r.length;o++)n[(t=r[o]).name]=t.value;return n},m=function(e){var t={};return e.forEach((function(e){t[e]={default:null}})),t},g=function(){return m(["style","class","id"])},y=function(e,t){for(var n in e)if(n&&null!==e[n]&&n!==t)return!0;return!1},v=function(e,t){void 0===t&&(t=[]);var n={},r=function(r){r&&null!==e[r]&&!t.find((function(e){return e===r}))&&(n[r]=e[r])};for(var o in e)r(o);return n},b=function(e){var t;return(t={})[e]={name:e,inclusive:!0,parseDOM:[{tag:e}],toDOM:function(){return[e,0]}},t},w=r.__assign(r.__assign(r.__assign(r.__assign(r.__assign(r.__assign(r.__assign(r.__assign(r.__assign(r.__assign({link:{attrs:r.__assign(r.__assign({},g()),{href:{default:null},target:{default:null},title:{default:null}}),inclusive:!1,parseDOM:[{tag:"a",getAttrs:f}],toDOM:function(e){return["a",v(e.attrs),0]}}},b("strong")),b("b")),b("em")),b("i")),b("del")),b("sub")),b("sup")),b("code")),{style:{attrs:r.__assign({},g()),parseDOM:[{tag:"span",getAttrs:f}],toDOM:function(e){return y(e.attrs)?["span",v(e.attrs),0]:["span",0]}}}),b("u"));t.marks=w;var S=function(e){var t;return(t={})[e]={default:null,getFromDOM:function(t){return t.getAttribute(e)},setDOMAttr:function(t,n){n[e]=t}},t},k=r.__assign(r.__assign(r.__assign(r.__assign(r.__assign({},S("style")),S("class")),S("id")),S("headers")),S("scope")),x={doc:{content:"colgroup*"},col:{attrs:m(["id","class","style","span"]),parseDOM:[{getAttrs:f,tag:"col"}],toDOM:function(e){return["col",e.attrs]}},colgroup:{attrs:m(["id","class","style","span"]),content:"col*",parseDOM:[{getAttrs:f,tag:"colgroup"}],toDOM:function(e){return["colgroup",e.attrs,0]}},text:{inline:!0,group:"inline"}},C=new o.Schema({nodes:x,marks:{}});t.parseStrColgroup=function(e){var t=s.domToPmDoc(s.htmlToFragment(e),C,{preserveWhitespace:!1});return s.pmDocToFragment(t).firstChild};var M=i.tableNodes({tableGroup:"block",cellContent:"block+",cellAttributes:k});M.table_row.attrs=r.__assign(r.__assign({},M.table_row.attrs),m([l.rowTypeAttr,"style","class","id"])),M.table_row.toDOM=function(e){return["tr",v(e.attrs),0]},M.table_row.parseDOM=[{tag:"tr",getAttrs:f}],M.table.attrs=r.__assign(r.__assign({},M.table.attrs),m(["style","class","id",l.colgroupAttr,l.resizableAttr])),M.table.toDOM=function(e){var n=y(e.attrs)?v(e.attrs,[l.colgroupAttr,l.resizableAttr]):{},r=null;if(e.attrs[l.colgroupAttr]&&!function(e){for(var t=!1,n=e.child(0),r=0;r<n.childCount;r++){if(n.child(r).attrs.colwidth){t=!0;break}}return t}(e)){var o=t.parseStrColgroup(e.attrs[l.colgroupAttr]);if(o){var i=Array.from(o.children).map((function(e){return["col",f(e)]}));r=["colgroup",f(o)].concat(i)}}return r?["table",n,r,["tbody",0]]:["table",n,["tbody",0]]},M.table.parseDOM=[{tag:"table",getAttrs:function(e){var t=f(e),n=Array.from(e.childNodes).find((function(e){return"COLGROUP"===e.nodeName}));return n&&(t[l.colgroupAttr]=n.outerHTML),t}}];var O=r.__assign({doc:{content:"block+"},paragraph:{content:"inline*",group:"block",attrs:r.__assign({},g()),parseDOM:[{tag:"p",getAttrs:f}],toDOM:function(e){return y(e.attrs)?["p",v(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:f}],toDOM:function(e){return y(e.attrs)?["div",v(e.attrs),0]:["div",0]}},table_caption_external:{content:"inline+",group:"block",attrs:r.__assign({caption:{default:null}},g()),parseDOM:[{tag:"div[caption]",getAttrs:f}],toDOM:function(e){return y(e.attrs)?["div",v(e.attrs),0]:["div",0]}},div:{content:"block*",group:"block",attrs:r.__assign({},g()),parseDOM:[{tag:"div",getAttrs:f}],toDOM:function(e){return y(e.attrs)?["div",v(e.attrs),0]:["div",0]}},blockquote:{attrs:r.__assign({},g()),content:"block+",group:"block",defining:!0,parseDOM:[{tag:"blockquote",getAttrs:f}],toDOM:function(e){return y(e.attrs)?["blockquote",v(e.attrs),0]:a}},horizontal_rule:{group:"block",parseDOM:[{tag:"hr"}],toDOM:function(){return c}},heading:{attrs:r.__assign(r.__assign({},g()),{level:{default:1}}),content:"inline*",group:"block",defining:!0,parseDOM:[{tag:"h1",getAttrs:function(e){return r.__assign(r.__assign({},f(e)),{level:1})}},{tag:"h2",getAttrs:function(e){return r.__assign(r.__assign({},f(e)),{level:2})}},{tag:"h3",getAttrs:function(e){return r.__assign(r.__assign({},f(e)),{level:3})}},{tag:"h4",getAttrs:function(e){return r.__assign(r.__assign({},f(e)),{level:4})}},{tag:"h5",getAttrs:function(e){return r.__assign(r.__assign({},f(e)),{level:5})}},{tag:"h6",getAttrs:function(e){return r.__assign(r.__assign({},f(e)),{level:6})}}],toDOM:function(e){return y(e.attrs,"level")?["h"+e.attrs.level,v(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:function(){return d}},text:{inline:!0,group:"inline"},image:{inline:!0,attrs:r.__assign({src:{default:null},alt:{default:null},title:{default:null},width:{default:null},height:{default:null}},g()),group:"inline",draggable:!0,parseDOM:[{tag:"img",getAttrs:f}],toDOM:function(e){return y(e.attrs)?["img",v(e.attrs)]:["img"]}},hard_break:{inline:!0,attrs:r.__assign({},g()),group:"inline",selectable:!1,parseDOM:[{tag:"br",getAttrs:f}],toDOM:function(e){return y(e.attrs)?["br",v(e.attrs)]:["br"]}},ordered_list:{content:"list_item+",group:"block",attrs:r.__assign(r.__assign({},g()),{type:{default:null},order:{default:1}}),parseDOM:[{tag:"ol",getAttrs:function(e){return r.__assign(r.__assign({},f(e)),{order:e.hasAttribute("start")?parseInt(e.getAttribute("start")||"1",10):1})}}],toDOM:function(e){return 1===e.attrs.order?y(e.attrs,"order")?["ol",v(e.attrs,["order"]),0]:u:["ol",r.__assign(r.__assign({},v(e.attrs,["order"])),{start:e.attrs.order}),0]}},bullet_list:{content:"list_item+",group:"block",attrs:r.__assign({},g()),parseDOM:[{tag:"ul",getAttrs:f}],toDOM:function(e){return y(e.attrs)?["ul",v(e.attrs),0]:h}},list_item:{content:"(paragraph | heading) block*",attrs:r.__assign({},g()),parseDOM:[{tag:"li",getAttrs:f}],toDOM:function(e){return y(e.attrs)?["li",v(e.attrs),0]:p},defining:!0}},M);t.nodes=O},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.handles=t.directions=void 0,t.directions={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}},t.handles=Object.keys(t.directions)},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.outdentRules=t.indentRules=void 0;var r=n(4),o=n(19);t.indentRules={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:r.__assign({},o.listsTypes)},t.outdentRules={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:r.__assign({},o.listsTypes)}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.bulletList=t.orderedList=t.listsTypes=void 0;var r=n(4);t.listsTypes={orderedList:"ordered_list",bulletList:"bullet_list",listItem:"list_item"},t.orderedList={listType:t.listsTypes.orderedList,types:r.__assign({},t.listsTypes)},t.bulletList={listType:t.listsTypes.bulletList,types:r.__assign({},t.listsTypes)}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.liftBlockquote=t.blockquote=void 0;var r=n(13);t.blockquote=function(e,t){return r.wrapIn(e.schema.nodes.blockquote)(e,t)};t.liftBlockquote=function(e,t){var n=e.selection,r=n.$from,o=n.$to,i=e.schema.nodes.blockquote,s=e.doc,l=-1,a=r.blockRange(o);a&&s.nodesBetween(a.start,a.end,(function(e,t,n,r){e.type===i&&(l=t)}));var c=-1!==l;return t&&c&&t(e.tr.lift(a,s.resolve(l).depth)),c}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.splitListItemKeepMarks=t.toggleOrderedList=t.toggleUnorderedList=t.toggleList=t.listStyle=void 0;var r=n(4),o=n(0),i=n(1),s=n(2),l=n(13),a=n(15),c=n(19),d=function(e,t,n){for(var r=t.depth,o=e.nodes[n.bulletList],i=e.nodes[n.orderedList],s=e.nodes[n.listItem],l=t.depth;l>0;l--){var a=t.node(l);if(a.type!==o&&a.type!==i||(r=l),a.type!==o&&a.type!==i&&a.type!==s)break}return r-1};function u(e){return function(t,n,r){if(!r)return!1;var o=(t=r.state).schema.nodes[e.listType],i=t.selection,s=i.$from,c=i.$to,d=s.node(-2),u=s.node(-3),h=function(e,t,n,r){return 0===function(e,t,n){var r=Array(),o=function(e,t){var n=["blockquote","bulletList","orderedList"];if(1===t.depth)return t;var r=t.node(t.depth),o=t;for(;t.depth>=1;)t=e.resolve(t.before(t.depth)),(r=t.node(t.depth))&&-1!==n.indexOf(r.type.name)&&(o=t);return o}(e,t).depth,i=e.resolve(t.start(o));for(;i.pos<=n.start(n.depth);){var s=Math.min(i.depth,o),l=i.node(s);if(l&&r.push(l),0===s)break;var a=e.resolve(i.after(s));if(a.start(s)>=e.nodeSize-2)break;a.depth!==i.depth&&(a=e.resolve(a.pos+2)),i=a.depth?e.resolve(a.start(a.depth)):e.resolve(a.end(a.depth))}return r}(e,t,n).filter((function(e){return e.type!==r})).length}(t.doc,s,c,o);return(d&&d.type===o||u&&u.type===o)&&h?p(e)(t,n):(h||(p(e)(t,n),t=r.state),function(e,t){void 0===t&&(t={});return l.autoJoin(a.wrapInList(e,t),(function(t,n){return t.type===n.type&&t.type===e}))}(o,e.listAttrs)(t,n))}}function h(e,t,n,r){var i=r||e.schema.nodes.listItem,l=t.$from,a=t.$to,c=l.blockRange(a,(function(e){return e.childCount&&e.firstChild.type===i}));if(!c||c.depth<2||l.node(c.depth-1).type!==i)return n;var d=c.end,u=a.end(c.depth);return d<u&&(n.step(new s.ReplaceAroundStep(d-1,u,d,u,new o.Slice(o.Fragment.from(i.create(void 0,c.parent.copy())),1,0),1,!0)),c=new o.NodeRange(n.doc.resolve(l.pos),n.doc.resolve(u),c.depth)),n.lift(c,s.liftTarget(c)).scrollIntoView()}function p(e){return function(t,n){var r=t.tr,o=t.selection,l=o.$from,a=o.$to;return r.doc.nodesBetween(l.pos,a.pos,(function(n,o){if(n.isTextblock||"blockquote"===n.type.name||"div"===n.type.name){var l=new i.NodeSelection(r.doc.resolve(r.mapping.map(o))),a=l.$from.blockRange(l.$to);if(!a||l.$from.parent.type!==t.schema.nodes[e.listItem])return!1;var c=a&&s.liftTarget(a);if(null==c)return!1;r.lift(a,c)}})),n&&n(r),!0}}var f=/list\-style\-type:\s?([\w-]+)/;t.listStyle=function(e){var t=e.style||"",n=f.exec(t);return n&&n[1]||""};t.toggleList=function(e,n,r,o,s){var l=o.listType,a=o.listAttrs,c=void 0===a?{style:null}:a,p=e.selection,f=p.$from.node(p.$from.depth-2),m=p.$to.node(p.$to.depth-2);if(f&&f.type.name===l&&t.listStyle(f.attrs)===t.listStyle(c)&&m&&m.type.name===l&&t.listStyle(m.attrs)===t.listStyle(c)){var g=r.state.schema.nodes,y={bulletList:g[o.bulletList],orderedList:g[o.orderedList],listItem:g[o.listItem]},v=function(e,t){for(var n,r=t.bulletList,o=t.orderedList,i=t.listItem,s=e.depth-1;s>0;s--){var l=e.node(s);if(l.type!==r&&l.type!==o||(n=s),l.type!==r&&l.type!==o&&l.type!==i)break}return n}(p.$to,y),b=function(e,t,n,r,o,s){s||(s=e.schema.nodes.listItem);var l=!1;return o.doc.nodesBetween(t,n,(function(n,a){if(!l&&n.type===s&&a>t){l=!0;for(var c=r+3;c>r+2;){var d=o.doc.resolve(o.mapping.map(a));c=d.depth;var u=o.doc.resolve(o.mapping.map(a+n.textContent.length)),p=new i.TextSelection(d,u);o=h(e,p,o,s)}}})),o}(e,p.$to.pos,p.$to.end(v),v,r.state.tr,y.listItem);return(b=function(e,t,n){var r=e.selection,o=r.from,i=r.to,s=e.schema.nodes,l=s.paragraph,a=s.heading,c=[];t.doc.nodesBetween(o,i,(function(e,t){e.type!==l&&e.type!==a||c.push({node:e,pos:t})}));for(var u=c.length-1;u>=0;u--){var h=c[u],p=t.doc.resolve(t.mapping.map(h.pos));if(p.depth>0){var f=void 0;f=h.node.textContent&&h.node.textContent.length>0?t.doc.resolve(t.mapping.map(h.pos+h.node.textContent.length)):t.doc.resolve(t.mapping.map(h.pos+1));var m=p.blockRange(f);m&&t.lift(m,d(e.schema,p,n))}}return t}(e,b,o)).setMeta("commandName",s),n(b),!0}return u(o)(e,n,r)},t.toggleUnorderedList=function(e,n,o){return t.toggleList(e,n,o,r.__assign({listType:c.bulletList.listType},c.bulletList.types))},t.toggleOrderedList=function(e,n,o){return t.toggleList(e,n,o,r.__assign({listType:c.orderedList.listType},c.orderedList.types))};t.splitListItemKeepMarks=function(e){return function(t,n){return a.splitListItem(e)(t,(function(e){var r=t.storedMarks||t.selection.$to.parentOffset&&t.selection.$from.marks();r&&e.ensureMarks(r),n(e)}))}}},function(e,t,n){"use strict";n.r(t),n.d(t,"InputRule",(function(){return i})),n.d(t,"closeDoubleQuote",(function(){return h})),n.d(t,"closeSingleQuote",(function(){return f})),n.d(t,"ellipsis",(function(){return d})),n.d(t,"emDash",(function(){return c})),n.d(t,"inputRules",(function(){return s})),n.d(t,"openDoubleQuote",(function(){return u})),n.d(t,"openSingleQuote",(function(){return p})),n.d(t,"smartQuotes",(function(){return m})),n.d(t,"textblockTypeInputRule",(function(){return y})),n.d(t,"undoInputRule",(function(){return a})),n.d(t,"wrappingInputRule",(function(){return g}));var r=n(1),o=n(2);class i{constructor(e,t){var n;this.match=e,this.match=e,this.handler="string"==typeof t?(n=t,function(e,t,r,o){let i=n;if(t[1]){let e=t[0].lastIndexOf(t[1]);i+=t[0].slice(e+t[1].length);let n=(r+=e)-o;n>0&&(i=t[0].slice(e-n,e)+i,r=o)}return e.tr.insertText(i,r,o)}):t}}function s({rules:e}){let t=new r.Plugin({state:{init:()=>null,apply(e,t){let n=e.getMeta(this);return n||(e.selectionSet||e.docChanged?null:t)}},props:{handleTextInput:(n,r,o,i)=>l(n,r,o,i,e,t),handleDOMEvents:{compositionend:n=>{setTimeout(()=>{let{$cursor:r}=n.state.selection;r&&l(n,r.pos,r.pos,"",e,t)})}}},isInputRules:!0});return t}function l(e,t,n,r,o,i){if(e.composing)return!1;let s=e.state,l=s.doc.resolve(t);if(l.parent.type.spec.code)return!1;let a=l.parent.textBetween(Math.max(0,l.parentOffset-500),l.parentOffset,null,"")+r;for(let l=0;l<o.length;l++){let c=o[l].match.exec(a),d=c&&o[l].handler(s,c,t-(c[0].length-r.length),n);if(d)return e.dispatch(d.setMeta(i,{transform:d,from:t,to:n,text:r})),!0}return!1}const a=(e,t)=>{let n=e.plugins;for(let r=0;r<n.length;r++){let o,i=n[r];if(i.spec.isInputRules&&(o=i.getState(e))){if(t){let n=e.tr,r=o.transform;for(let e=r.steps.length-1;e>=0;e--)n.step(r.steps[e].invert(r.docs[e]));if(o.text){let t=n.doc.resolve(o.from).marks();n.replaceWith(o.from,o.to,e.schema.text(o.text,t))}else n.delete(o.from,o.to);t(n)}return!0}}return!1},c=new i(/--$/,"—"),d=new i(/\.\.\.$/,"…"),u=new i(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,"“"),h=new i(/"$/,"”"),p=new i(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,"‘"),f=new i(/'$/,"’"),m=[u,h,p,f];function g(e,t,n=null,r){return new i(e,(e,i,s,l)=>{let a=n instanceof Function?n(i):n,c=e.tr.delete(s,l),d=c.doc.resolve(s).blockRange(),u=d&&Object(o.findWrapping)(d,t,a);if(!u)return null;c.wrap(d,u);let h=c.doc.resolve(s-1).nodeBefore;return h&&h.type==t&&Object(o.canJoin)(c.doc,s-1)&&(!r||r(i,h))&&c.join(s-1),c})}function y(e,t,n=null){return new i(e,(e,r,o,i)=>{let s=e.doc.resolve(o),l=n instanceof Function?n(r):n;return s.node(-1).canReplaceWith(s.index(-1),s.indexAfter(-1),t)?e.tr.delete(o,i).setBlockType(o,o,t,l):null})}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.unlink=t.link=t.superscript=t.subscript=t.strikethrough=t.underline=t.italic=t.bold=void 0,t.bold={mark:"strong",altMarks:["b"],altStyle:{name:"font-weight",value:/^(bold(er)?|[5-9]\d{2,})$/}},t.italic={mark:"em",altMarks:["i"],altStyle:{name:"font-style",value:/^italic$/i}},t.underline={mark:"u",altStyle:{name:"text-decoration",value:/^underline$/i}},t.strikethrough={mark:"del",altStyle:{name:"text-decoration",value:/^line-through$/i}},t.subscript={mark:"sub"},t.superscript={mark:"sup"},t.link={mark:"link"},t.unlink={mark:"link"}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.convertMsLists=void 0;var r=n(8),o=/style=['"]?[^'"]*?mso-list:\s*[a-zA-Z]+(\d+)\s[a-zA-Z]+(\d+)\s(\w+)/gi,i=function(e){return/^MsoListParagraph/.test(e.className)},s=function(e){var t=e.innerHTML;return t=(t=t.replace(/<!--(.|\s)*?-->/gi,"")).replace(/<\/?[^>]+?\/?>/gm,"")},l=function(e,t){var n=document.createElement(e);return n.style.listStyleType=t,n},a=function(e){var t=null;return/^\d/.test(e)||(t=(/^[a-z]/.test(e)?"lower-":"upper-")+(/^[ivxlcdm]/i.test(e)?"roman":"alpha")),t},c=function(e,t){var n=[];Array.from(e).forEach((function(e){if(e.nodeType===Node.ELEMENT_NODE){var r=e;r.getAttribute("datalist")?(n.push(e),t.add(n)):i(r)&&n.length?n.push(e):(n=[],"DIV"===r.nodeName?c(r.children,t):"TABLE"===r.nodeName&&Array.from(r.querySelectorAll("td,th")).forEach((function(e){c(e.children,t)})))}}))},d=function(e){var t,n=e.innerHTML,r=function(e){return e.replace(/^(?:&nbsp;|[\u00a0\n\r\s])+/,"")};return n=n.replace(/<\/?\w+[^>]*>/g,"").replace(/&nbsp;/g," "),/^[\u2022\u00b7\u00a7\u00d8oØüvn][\u00a0 ]+/.test(n)?{tag:"ul",style:(t=r(s(e)),/^[\u2022\u00b7\u00FC\u00D8\u002dv-]/.test(t)?null:/^o/.test(t)?"circle":"square")}:/^\s*\w+[\.\)][\u00a0 ]{2,}/.test(n)?{tag:"ol",style:a(r(s(e)))}:void 0},u=function(e){var 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?s(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);var o=document.createElement("li");return o.appendChild(r.htmlToFragment(t)),o};t.convertMsLists=function(e){var t=r.htmlToFragment(function(e){return e=e.replace(o,(function(e,t,n){return'datalist="'+t+'" datalevel="'+n+'" '+e}))}(e)),n=new Set;return c(t.children,n),n.forEach((function(e){return function(e){var t,n,r,o,s,a,c,h,p,f,m,g,y,v=-1,b={};for(h=0;h<e.length;h++){var w=(y={datalist:(p=e[h]).getAttribute("datalist"),datalevel:p.getAttribute("datalevel")}).datalist,S=d(p);if(f=S&&S.tag){if(m=y.datalevel||parseFloat(p.style.marginLeft||0),y.datalevel||p.style.marginLeft){var k=f+w;b[m]||(b[m]={}),(!n||n<0)&&(n=m,r=w,o=(c=e.filter((function(e){return e.getAttribute("datalist")===String(r)})))[c.length-1],a=l(f,S&&S.style),p.parentNode.insertBefore(a,p),v=m,b[m][k]=a),s=o===p,g=b[m][k],(m>v||!g)&&(g=l(f,S&&S.style),b[m][k]=g,t.appendChild(g)),t=u(p),g.appendChild(t),s?n=v=-1:v=m}}else!t||s&&!i(p)||(p.style.marginLeft&&(p.style.marginLeft=""),p.style.marginLeft&&(p.style.margin=""),t.appendChild(p))}}(e)})),r.fragmentToHtml(t)}},function(e,t,n){"use strict";n.r(t),n.d(t,"closeHistory",(function(){return b})),n.d(t,"history",(function(){return k})),n.d(t,"redo",(function(){return C})),n.d(t,"redoDepth",(function(){return O})),n.d(t,"undo",(function(){return x})),n.d(t,"undoDepth",(function(){return M}));var r=function(){};r.prototype.append=function(e){return e.length?(e=r.from(e),!this.length&&e||e.length<200&&this.leafAppend(e)||this.length<200&&e.leafPrepend(this)||this.appendInner(e)):this},r.prototype.prepend=function(e){return e.length?r.from(e).append(this):this},r.prototype.appendInner=function(e){return new i(this,e)},r.prototype.slice=function(e,t){return void 0===e&&(e=0),void 0===t&&(t=this.length),e>=t?r.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},r.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},r.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)},r.prototype.map=function(e,t,n){void 0===t&&(t=0),void 0===n&&(n=this.length);var r=[];return this.forEach((function(t,n){return r.push(e(t,n))}),t,n),r},r.from=function(e){return e instanceof r?e:e&&e.length?new o(e):r.empty};var o=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,r){for(var o=t;o<n;o++)if(!1===e(this.values[o],r+o))return!1},t.prototype.forEachInvertedInner=function(e,t,n,r){for(var o=t-1;o>=n;o--)if(!1===e(this.values[o],r+o))return!1},t.prototype.leafAppend=function(e){if(this.length+e.length<=200)return new t(this.values.concat(e.flatten()))},t.prototype.leafPrepend=function(e){if(this.length+e.length<=200)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}(r);r.empty=new o([]);var i=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,r){var o=this.left.length;return!(t<o&&!1===this.left.forEachInner(e,t,Math.min(n,o),r))&&(!(n>o&&!1===this.right.forEachInner(e,Math.max(t-o,0),Math.min(this.length,n)-o,r+o))&&void 0)},t.prototype.forEachInvertedInner=function(e,t,n,r){var o=this.left.length;return!(t>o&&!1===this.right.forEachInvertedInner(e,t-o,Math.max(n,o)-o,r+o))&&(!(n<o&&!1===this.left.forEachInvertedInner(e,Math.min(t,o),n,r))&&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}(r),s=r,l=n(2),a=n(1);class c{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(0==this.eventCount)return null;let n,r,o=this.items.length;for(;;o--){if(this.items.get(o-1).selection){--o;break}}t&&(n=this.remapping(o,this.items.length),r=n.maps.length);let i,s,l=e.tr,a=[],u=[];return this.items.forEach((e,t)=>{if(!e.step)return n||(n=this.remapping(o,t+1),r=n.maps.length),r--,void u.push(e);if(n){u.push(new d(e.map));let t,o=e.step.map(n.slice(r));o&&l.maybeStep(o).doc&&(t=l.mapping.maps[l.mapping.maps.length-1],a.push(new d(t,void 0,void 0,a.length+u.length))),r--,t&&n.appendMap(t,r)}else l.maybeStep(e.step);return e.selection?(i=n?e.selection.map(n.slice(r)):e.selection,s=new c(this.items.slice(0,o).append(u.reverse().concat(a)),this.eventCount-1),!1):void 0},this.items.length,0),{remaining:s,transform:l,selection:i}}addTransform(e,t,n,r){let o=[],i=this.eventCount,s=this.items,l=!r&&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]),u=new d(e.mapping.maps[n],c,t);(a=l&&l.merge(u))&&(u=a,n?o.pop():s=s.slice(0,s.length-1)),o.push(u),t&&(i++,t=void 0),r||(l=u)}let a=i-n.depth;return a>h&&(s=function(e,t){let n;return e.forEach((e,r)=>{if(e.selection&&0==t--)return n=r,!1}),e.slice(n)}(s,a),i-=a),new c(s.append(o),i)}remapping(e,t){let n=new l.Mapping;return this.items.forEach((t,r)=>{let o=null!=t.mirrorOffset&&r-t.mirrorOffset>=e?n.maps.length-t.mirrorOffset:void 0;n.appendMap(t.map,o)},e,t),n}addMaps(e){return 0==this.eventCount?this:new c(this.items.append(e.map(e=>new d(e))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let n=[],r=Math.max(0,this.items.length-t),o=e.mapping,i=e.steps.length,s=this.eventCount;this.items.forEach(e=>{e.selection&&s--},r);let l=t;this.items.forEach(t=>{let r=o.getMirror(--l);if(null==r)return;i=Math.min(i,r);let a=o.maps[r];if(t.step){let i=e.steps[r].invert(e.docs[r]),c=t.selection&&t.selection.map(o.slice(l+1,r));c&&s++,n.push(new d(a,i,c))}else n.push(new d(a))},r);let a=[];for(let e=t;e<i;e++)a.push(new d(o.maps[e]));let u=this.items.slice(0,r).append(a).append(n),h=new c(u,s);return h.emptyItemCount()>500&&(h=h.compress(this.items.length-n.length)),h}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,r=[],o=0;return this.items.forEach((i,s)=>{if(s>=e)r.push(i),i.selection&&o++;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&&o++;let a,c=new d(s.invert(),e,l),u=r.length-1;(a=r.length&&r[u].merge(c))?r[u]=a:r.push(c)}}else i.map&&n--},this.items.length,0),new c(s.from(r.reverse()),o)}}c.empty=new c(s.empty,0);class d{constructor(e,t,n,r){this.map=e,this.step=t,this.selection=n,this.mirrorOffset=r}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new d(t.getMap().invert(),t,this.selection)}}}class u{constructor(e,t,n,r,o){this.done=e,this.undone=t,this.prevRanges=n,this.prevTime=r,this.prevComposition=o}}const h=20;function p(e){let t=[];return e.forEach((e,n,r,o)=>t.push(r,o)),t}function f(e,t){if(!e)return null;let n=[];for(let r=0;r<e.length;r+=2){let o=t.map(e[r],1),i=t.map(e[r+1],-1);o<=i&&n.push(o,i)}return n}function m(e,t,n,r){let o=v(t),i=w.get(t).spec.config,s=(r?e.undone:e.done).popEvent(t,o);if(!s)return;let l=s.selection.resolve(s.transform.doc),a=(r?e.done:e.undone).addTransform(s.transform,t.selection.getBookmark(),i,o),c=new u(r?a:s.remaining,r?s.remaining:a,null,0,-1);n(s.transform.setSelection(l).setMeta(w,{redo:r,historyState:c}).scrollIntoView())}let g=!1,y=null;function v(e){let t=e.plugins;if(y!=t){g=!1,y=t;for(let e=0;e<t.length;e++)if(t[e].spec.historyPreserveItems){g=!0;break}}return g}function b(e){return e.setMeta(S,!0)}const w=new a.PluginKey("history"),S=new a.PluginKey("closeHistory");function k(e={}){return e={depth:e.depth||100,newGroupDelay:e.newGroupDelay||500},new a.Plugin({key:w,state:{init:()=>new u(c.empty,c.empty,null,0,-1),apply:(t,n,r)=>function(e,t,n,r){let o,i=n.getMeta(w);if(i)return i.historyState;n.getMeta(S)&&(e=new u(e.done,e.undone,null,0,-1));let s=n.getMeta("appendedTransaction");if(0==n.steps.length)return e;if(s&&s.getMeta(w))return s.getMeta(w).redo?new u(e.done.addTransform(n,void 0,r,v(t)),e.undone,p(n.mapping.maps[n.steps.length-1]),e.prevTime,e.prevComposition):new u(e.done,e.undone.addTransform(n,void 0,r,v(t)),null,e.prevTime,e.prevComposition);if(!1===n.getMeta("addToHistory")||s&&!1===s.getMeta("addToHistory"))return(o=n.getMeta("rebased"))?new u(e.done.rebased(n,o),e.undone.rebased(n,o),f(e.prevRanges,n.mapping),e.prevTime,e.prevComposition):new u(e.done.addMaps(n.mapping.maps),e.undone.addMaps(n.mapping.maps),f(e.prevRanges,n.mapping),e.prevTime,e.prevComposition);{let o=n.getMeta("composition"),i=0==e.prevTime||!s&&e.prevComposition!=o&&(e.prevTime<(n.time||0)-r.newGroupDelay||!function(e,t){if(!t)return!1;if(!e.docChanged)return!0;let n=!1;return e.mapping.maps[0].forEach((e,r)=>{for(let o=0;o<t.length;o+=2)e<=t[o+1]&&r>=t[o]&&(n=!0)}),n}(n,e.prevRanges)),l=s?f(e.prevRanges,n.mapping):p(n.mapping.maps[n.steps.length-1]);return new u(e.done.addTransform(n,i?t.selection.getBookmark():void 0,r,v(t)),c.empty,l,n.time,null==o?e.prevComposition:o)}}(n,r,t,e)},config:e,props:{handleDOMEvents:{beforeinput(e,t){let n=t.inputType,r="historyUndo"==n?x:"historyRedo"==n?C:null;return!!r&&(t.preventDefault(),r(e.state,e.dispatch))}}}})}const x=(e,t)=>{let n=w.getState(e);return!(!n||0==n.done.eventCount)&&(t&&m(n,e,t,!1),!0)},C=(e,t)=>{let n=w.getState(e);return!(!n||0==n.undone.eventCount)&&(t&&m(n,e,t,!0),!0)};function M(e){let t=w.getState(e);return t?t.done.eventCount:0}function O(e){let t=w.getState(e);return t?t.undone.eventCount:0}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.expandSelection=t.selectedLineTextOnly=t.getNodeFromSelection=t.getSelectionText=t.hasSameMarkup=t.liftBlockquote=t.blockquote=t.listStyle=t.toggleList=t.toggleUnorderedList=t.toggleOrderedList=t.indentBlocks=t.canBeIndented=t.isIndented=t.canOutdentAsListItem=t.outdent=t.canIndentAsListItem=t.indent=t.selectionMarks=t.cleanMarks=t.removeAllMarks=t.getActiveMarks=t.getMark=t.hasMark=t.cleanTextBlockFormatting=t.blockNodes=t.changeTextBlock=t.parentBlockFormat=t.getBlockFormats=t.formatBlockElements=t.activeNode=t.hasNode=t.cleanFormatting=t.isAligned=t.alignBlocks=t.insertImage=t.insertText=t.removeLink=t.applyLink=t.toggleInlineFormat=t.getInlineStyles=t.applyInlineStyle=t.fragmentToHtml=t.pmDocToFragment=t.domToPmDoc=t.htmlToFragment=t.trimWhitespace=t.parseContent=t.setHtml=t.getHtml=void 0,t.tableEditing=t.TableMap=t.tableRowResizeKey=t.tableColumnResizeKey=t.tableResizeKey=t.tableResizing=t.caretColorKey=t.caretColor=t.imageResizeKey=t.imageResizing=t.textHighlightKey=t.textHighlight=t.spacesFix=t.placeholder=t.replaceAll=t.replace=t.findAll=t.findAt=t.find=t.convertMsLists=t.replaceImageSourcesFromRtf=t.removeAttribute=t.sanitizeStyleAttr=t.sanitizeClassAttr=t.pasteCleanup=t.removeTag=t.removeComments=t.sanitize=t.link=t.superscript=t.subscript=t.strikethrough=t.underline=t.italic=t.bold=t.buildListKeymap=t.buildKeymap=t.marks=t.nodes=t.outdentRules=t.indentRules=t.alignRemoveRules=t.alignJustifyRules=t.alignRightRules=t.alignCenterRules=t.alignLeftRules=t.indentHtml=t.insertNode=t.canInsert=t.expandToWordWrap=void 0,t.pmDeleteColumn=t.pmAddRowBefore=t.pmAddRowAfter=t.pmAddColumnAfter=t.pmAddColumnBefore=t.deleteColumn=t.addColumnAfter=t.addColumnBefore=t.addRowBefore=t.addRowAfter=t.createTable=t.nextCell=t.moveCellForward=t.removeColSpan=t.findCell=t.cellAround=t.updateColumnsOnResize=t.columnResizingPluginKey=t.columnResizing=t.columnIsHeader=t.colCount=t.addColumn=t.addColSpan=t.addRow=t.rowIsHeader=t.deleteRow=t.mergeCells=t.splitCellWithType=t.splitCell=t.toggleHeaderRow=t.toggleHeaderColumn=t.toggleHeaderCell=t.toggleHeader=t.goToNextCell=t.setCellAttr=t.selectionCell=t.selectedRect=t.CellSelection=t.inSameTable=t.deleteTable=t.isInTable=t.fixTablesKey=t.fixTables=t.tableNodes=t.tableNodeTypes=t.tableEditingKey=void 0;var r=n(4),o=n(8);Object.defineProperty(t,"getHtml",{enumerable:!0,get:function(){return o.getHtml}}),Object.defineProperty(t,"setHtml",{enumerable:!0,get:function(){return o.setHtml}}),Object.defineProperty(t,"parseContent",{enumerable:!0,get:function(){return o.parseContent}}),Object.defineProperty(t,"trimWhitespace",{enumerable:!0,get:function(){return o.trimWhitespace}}),Object.defineProperty(t,"htmlToFragment",{enumerable:!0,get:function(){return o.htmlToFragment}}),Object.defineProperty(t,"domToPmDoc",{enumerable:!0,get:function(){return o.domToPmDoc}}),Object.defineProperty(t,"pmDocToFragment",{enumerable:!0,get:function(){return o.pmDocToFragment}}),Object.defineProperty(t,"fragmentToHtml",{enumerable:!0,get:function(){return o.fragmentToHtml}});var i=n(14);Object.defineProperty(t,"applyInlineStyle",{enumerable:!0,get:function(){return i.applyInlineStyle}}),Object.defineProperty(t,"getInlineStyles",{enumerable:!0,get:function(){return i.getInlineStyles}}),Object.defineProperty(t,"toggleInlineFormat",{enumerable:!0,get:function(){return i.toggleInlineFormat}});var s=n(27);Object.defineProperty(t,"applyLink",{enumerable:!0,get:function(){return s.applyLink}}),Object.defineProperty(t,"removeLink",{enumerable:!0,get:function(){return s.removeLink}});var l=n(28);Object.defineProperty(t,"insertText",{enumerable:!0,get:function(){return l.insertText}});var a=n(29);Object.defineProperty(t,"insertImage",{enumerable:!0,get:function(){return a.insertImage}});var c=n(30);Object.defineProperty(t,"alignBlocks",{enumerable:!0,get:function(){return c.alignBlocks}}),Object.defineProperty(t,"isAligned",{enumerable:!0,get:function(){return c.isAligned}});var d=n(31);Object.defineProperty(t,"cleanFormatting",{enumerable:!0,get:function(){return d.cleanFormatting}});var u=n(12);Object.defineProperty(t,"hasNode",{enumerable:!0,get:function(){return u.hasNode}}),Object.defineProperty(t,"activeNode",{enumerable:!0,get:function(){return u.activeNode}}),Object.defineProperty(t,"formatBlockElements",{enumerable:!0,get:function(){return u.formatBlockElements}}),Object.defineProperty(t,"getBlockFormats",{enumerable:!0,get:function(){return u.getBlockFormats}}),Object.defineProperty(t,"parentBlockFormat",{enumerable:!0,get:function(){return u.parentBlockFormat}}),Object.defineProperty(t,"changeTextBlock",{enumerable:!0,get:function(){return u.changeTextBlock}}),Object.defineProperty(t,"blockNodes",{enumerable:!0,get:function(){return u.blockNodes}}),Object.defineProperty(t,"cleanTextBlockFormatting",{enumerable:!0,get:function(){return u.cleanTextBlockFormatting}});var h=n(9);Object.defineProperty(t,"hasMark",{enumerable:!0,get:function(){return h.hasMark}}),Object.defineProperty(t,"getMark",{enumerable:!0,get:function(){return h.getMark}}),Object.defineProperty(t,"getActiveMarks",{enumerable:!0,get:function(){return h.getActiveMarks}}),Object.defineProperty(t,"removeAllMarks",{enumerable:!0,get:function(){return h.removeAllMarks}}),Object.defineProperty(t,"cleanMarks",{enumerable:!0,get:function(){return h.cleanMarks}}),Object.defineProperty(t,"selectionMarks",{enumerable:!0,get:function(){return h.selectionMarks}});var p=n(32);Object.defineProperty(t,"indent",{enumerable:!0,get:function(){return p.indent}}),Object.defineProperty(t,"canIndentAsListItem",{enumerable:!0,get:function(){return p.canIndentAsListItem}}),Object.defineProperty(t,"outdent",{enumerable:!0,get:function(){return p.outdent}}),Object.defineProperty(t,"canOutdentAsListItem",{enumerable:!0,get:function(){return p.canOutdentAsListItem}}),Object.defineProperty(t,"isIndented",{enumerable:!0,get:function(){return p.isIndented}}),Object.defineProperty(t,"canBeIndented",{enumerable:!0,get:function(){return p.canBeIndented}}),Object.defineProperty(t,"indentBlocks",{enumerable:!0,get:function(){return p.indentBlocks}});var f=n(21);Object.defineProperty(t,"toggleOrderedList",{enumerable:!0,get:function(){return f.toggleOrderedList}}),Object.defineProperty(t,"toggleUnorderedList",{enumerable:!0,get:function(){return f.toggleUnorderedList}}),Object.defineProperty(t,"toggleList",{enumerable:!0,get:function(){return f.toggleList}}),Object.defineProperty(t,"listStyle",{enumerable:!0,get:function(){return f.listStyle}});var m=n(20);Object.defineProperty(t,"blockquote",{enumerable:!0,get:function(){return m.blockquote}}),Object.defineProperty(t,"liftBlockquote",{enumerable:!0,get:function(){return m.liftBlockquote}});var g=n(5);Object.defineProperty(t,"hasSameMarkup",{enumerable:!0,get:function(){return g.hasSameMarkup}}),Object.defineProperty(t,"getSelectionText",{enumerable:!0,get:function(){return g.getSelectionText}}),Object.defineProperty(t,"getNodeFromSelection",{enumerable:!0,get:function(){return g.getNodeFromSelection}}),Object.defineProperty(t,"selectedLineTextOnly",{enumerable:!0,get:function(){return g.selectedLineTextOnly}}),Object.defineProperty(t,"expandSelection",{enumerable:!0,get:function(){return g.expandSelection}}),Object.defineProperty(t,"expandToWordWrap",{enumerable:!0,get:function(){return g.expandToWordWrap}}),Object.defineProperty(t,"canInsert",{enumerable:!0,get:function(){return g.canInsert}}),Object.defineProperty(t,"insertNode",{enumerable:!0,get:function(){return g.insertNode}}),Object.defineProperty(t,"indentHtml",{enumerable:!0,get:function(){return g.indentHtml}});var y=n(33);Object.defineProperty(t,"alignLeftRules",{enumerable:!0,get:function(){return y.alignLeftRules}}),Object.defineProperty(t,"alignCenterRules",{enumerable:!0,get:function(){return y.alignCenterRules}}),Object.defineProperty(t,"alignRightRules",{enumerable:!0,get:function(){return y.alignRightRules}}),Object.defineProperty(t,"alignJustifyRules",{enumerable:!0,get:function(){return y.alignJustifyRules}}),Object.defineProperty(t,"alignRemoveRules",{enumerable:!0,get:function(){return y.alignRemoveRules}});var v=n(18);Object.defineProperty(t,"indentRules",{enumerable:!0,get:function(){return v.indentRules}}),Object.defineProperty(t,"outdentRules",{enumerable:!0,get:function(){return v.outdentRules}});var b=n(16);Object.defineProperty(t,"nodes",{enumerable:!0,get:function(){return b.nodes}}),Object.defineProperty(t,"marks",{enumerable:!0,get:function(){return b.marks}});var w=n(34);Object.defineProperty(t,"buildKeymap",{enumerable:!0,get:function(){return w.buildKeymap}}),Object.defineProperty(t,"buildListKeymap",{enumerable:!0,get:function(){return w.buildListKeymap}});var S=n(23);Object.defineProperty(t,"bold",{enumerable:!0,get:function(){return S.bold}}),Object.defineProperty(t,"italic",{enumerable:!0,get:function(){return S.italic}}),Object.defineProperty(t,"underline",{enumerable:!0,get:function(){return S.underline}}),Object.defineProperty(t,"strikethrough",{enumerable:!0,get:function(){return S.strikethrough}}),Object.defineProperty(t,"subscript",{enumerable:!0,get:function(){return S.subscript}}),Object.defineProperty(t,"superscript",{enumerable:!0,get:function(){return S.superscript}}),Object.defineProperty(t,"link",{enumerable:!0,get:function(){return S.link}});var k=n(35);Object.defineProperty(t,"sanitize",{enumerable:!0,get:function(){return k.sanitize}}),Object.defineProperty(t,"removeComments",{enumerable:!0,get:function(){return k.removeComments}}),Object.defineProperty(t,"removeTag",{enumerable:!0,get:function(){return k.removeTag}}),Object.defineProperty(t,"pasteCleanup",{enumerable:!0,get:function(){return k.pasteCleanup}}),Object.defineProperty(t,"sanitizeClassAttr",{enumerable:!0,get:function(){return k.sanitizeClassAttr}}),Object.defineProperty(t,"sanitizeStyleAttr",{enumerable:!0,get:function(){return k.sanitizeStyleAttr}}),Object.defineProperty(t,"removeAttribute",{enumerable:!0,get:function(){return k.removeAttribute}}),Object.defineProperty(t,"replaceImageSourcesFromRtf",{enumerable:!0,get:function(){return k.replaceImageSourcesFromRtf}});var x=n(24);Object.defineProperty(t,"convertMsLists",{enumerable:!0,get:function(){return x.convertMsLists}});var C=n(36);Object.defineProperty(t,"find",{enumerable:!0,get:function(){return C.find}}),Object.defineProperty(t,"findAt",{enumerable:!0,get:function(){return C.findAt}}),Object.defineProperty(t,"findAll",{enumerable:!0,get:function(){return C.findAll}}),Object.defineProperty(t,"replace",{enumerable:!0,get:function(){return C.replace}}),Object.defineProperty(t,"replaceAll",{enumerable:!0,get:function(){return C.replaceAll}});var M=n(37);Object.defineProperty(t,"placeholder",{enumerable:!0,get:function(){return M.placeholder}});var O=n(38);Object.defineProperty(t,"spacesFix",{enumerable:!0,get:function(){return O.spacesFix}});var T=n(39);Object.defineProperty(t,"textHighlight",{enumerable:!0,get:function(){return T.textHighlight}}),Object.defineProperty(t,"textHighlightKey",{enumerable:!0,get:function(){return T.textHighlightKey}});var A=n(40);Object.defineProperty(t,"imageResizing",{enumerable:!0,get:function(){return A.imageResizing}}),Object.defineProperty(t,"imageResizeKey",{enumerable:!0,get:function(){return A.imageResizeKey}});var N=n(41);Object.defineProperty(t,"caretColor",{enumerable:!0,get:function(){return N.caretColor}}),Object.defineProperty(t,"caretColorKey",{enumerable:!0,get:function(){return N.caretColorKey}});var R=n(42);Object.defineProperty(t,"tableResizing",{enumerable:!0,get:function(){return R.tableResizing}}),Object.defineProperty(t,"tableResizeKey",{enumerable:!0,get:function(){return R.tableResizeKey}}),Object.defineProperty(t,"tableColumnResizeKey",{enumerable:!0,get:function(){return R.tableColumnResizeKey}}),Object.defineProperty(t,"tableRowResizeKey",{enumerable:!0,get:function(){return R.tableRowResizeKey}}),r.__exportStar(n(13),t),r.__exportStar(n(47),t),r.__exportStar(n(48),t),r.__exportStar(n(25),t),r.__exportStar(n(22),t),r.__exportStar(n(11),t),r.__exportStar(n(0),t),r.__exportStar(n(15),t),r.__exportStar(n(1),t);var D=n(7);Object.defineProperty(t,"TableMap",{enumerable:!0,get:function(){return D.TableMap}}),Object.defineProperty(t,"tableEditing",{enumerable:!0,get:function(){return D.tableEditing}}),Object.defineProperty(t,"tableEditingKey",{enumerable:!0,get:function(){return D.tableEditingKey}}),Object.defineProperty(t,"tableNodeTypes",{enumerable:!0,get:function(){return D.tableNodeTypes}}),Object.defineProperty(t,"tableNodes",{enumerable:!0,get:function(){return D.tableNodes}}),Object.defineProperty(t,"fixTables",{enumerable:!0,get:function(){return D.fixTables}}),Object.defineProperty(t,"fixTablesKey",{enumerable:!0,get:function(){return D.fixTablesKey}}),Object.defineProperty(t,"isInTable",{enumerable:!0,get:function(){return D.isInTable}}),Object.defineProperty(t,"deleteTable",{enumerable:!0,get:function(){return D.deleteTable}}),Object.defineProperty(t,"inSameTable",{enumerable:!0,get:function(){return D.inSameTable}}),Object.defineProperty(t,"CellSelection",{enumerable:!0,get:function(){return D.CellSelection}}),Object.defineProperty(t,"selectedRect",{enumerable:!0,get:function(){return D.selectedRect}}),Object.defineProperty(t,"selectionCell",{enumerable:!0,get:function(){return D.selectionCell}}),Object.defineProperty(t,"setCellAttr",{enumerable:!0,get:function(){return D.setCellAttr}}),Object.defineProperty(t,"goToNextCell",{enumerable:!0,get:function(){return D.goToNextCell}}),Object.defineProperty(t,"toggleHeader",{enumerable:!0,get:function(){return D.toggleHeader}}),Object.defineProperty(t,"toggleHeaderCell",{enumerable:!0,get:function(){return D.toggleHeaderCell}}),Object.defineProperty(t,"toggleHeaderColumn",{enumerable:!0,get:function(){return D.toggleHeaderColumn}}),Object.defineProperty(t,"toggleHeaderRow",{enumerable:!0,get:function(){return D.toggleHeaderRow}}),Object.defineProperty(t,"splitCell",{enumerable:!0,get:function(){return D.splitCell}}),Object.defineProperty(t,"splitCellWithType",{enumerable:!0,get:function(){return D.splitCellWithType}}),Object.defineProperty(t,"mergeCells",{enumerable:!0,get:function(){return D.mergeCells}}),Object.defineProperty(t,"deleteRow",{enumerable:!0,get:function(){return D.deleteRow}}),Object.defineProperty(t,"rowIsHeader",{enumerable:!0,get:function(){return D.rowIsHeader}}),Object.defineProperty(t,"addRow",{enumerable:!0,get:function(){return D.addRow}}),Object.defineProperty(t,"addColSpan",{enumerable:!0,get:function(){return D.addColSpan}}),Object.defineProperty(t,"addColumn",{enumerable:!0,get:function(){return D.addColumn}}),Object.defineProperty(t,"colCount",{enumerable:!0,get:function(){return D.colCount}}),Object.defineProperty(t,"columnIsHeader",{enumerable:!0,get:function(){return D.columnIsHeader}}),Object.defineProperty(t,"columnResizing",{enumerable:!0,get:function(){return D.columnResizing}}),Object.defineProperty(t,"columnResizingPluginKey",{enumerable:!0,get:function(){return D.columnResizingPluginKey}}),Object.defineProperty(t,"updateColumnsOnResize",{enumerable:!0,get:function(){return D.updateColumnsOnResize}}),Object.defineProperty(t,"cellAround",{enumerable:!0,get:function(){return D.cellAround}}),Object.defineProperty(t,"findCell",{enumerable:!0,get:function(){return D.findCell}}),Object.defineProperty(t,"removeColSpan",{enumerable:!0,get:function(){return D.removeColSpan}}),Object.defineProperty(t,"moveCellForward",{enumerable:!0,get:function(){return D.moveCellForward}}),Object.defineProperty(t,"nextCell",{enumerable:!0,get:function(){return D.nextCell}}),r.__exportStar(n(2),t),r.__exportStar(n(3),t);var _=n(49);Object.defineProperty(t,"createTable",{enumerable:!0,get:function(){return _.createTable}}),Object.defineProperty(t,"addRowAfter",{enumerable:!0,get:function(){return _.addRowAfter}}),Object.defineProperty(t,"addRowBefore",{enumerable:!0,get:function(){return _.addRowBefore}}),Object.defineProperty(t,"addColumnBefore",{enumerable:!0,get:function(){return _.addColumnBefore}}),Object.defineProperty(t,"addColumnAfter",{enumerable:!0,get:function(){return _.addColumnAfter}}),Object.defineProperty(t,"deleteColumn",{enumerable:!0,get:function(){return _.deleteColumn}}),Object.defineProperty(t,"pmAddColumnBefore",{enumerable:!0,get:function(){return _.pmAddColumnBefore}}),Object.defineProperty(t,"pmAddColumnAfter",{enumerable:!0,get:function(){return _.pmAddColumnAfter}}),Object.defineProperty(t,"pmAddRowAfter",{enumerable:!0,get:function(){return _.pmAddRowAfter}}),Object.defineProperty(t,"pmAddRowBefore",{enumerable:!0,get:function(){return _.pmAddRowBefore}}),Object.defineProperty(t,"pmDeleteColumn",{enumerable:!0,get:function(){return _.pmDeleteColumn}})},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.applyLink=t.removeLink=void 0;var r=n(14),o=n(9),i=n(1);t.removeLink=function(e,t){return function(n,i){var s=n.selection.$cursor;if(s){var l=s.parent,a=s.index(),c=n.schema.marks[e.mark],d=l.child(a).marks.find((function(e){return e.type===c})),u=l.childCount,h=s.pos-s.textOffset,p=l.child(a).nodeSize,f=void 0,m=void 0;for(f=a-1;f>=0&&d.isInSet(l.child(f).marks);)p+=m=l.child(f).nodeSize,h-=m,f-=1;for(f=a+1;f<u&&d.isInSet(l.child(f).marks);)p+=l.child(f).nodeSize,f+=1;i(o.removeMark(t||n.tr,h,h+p,d))}else r.toggleInlineFormat(e,t)(n,i)}};t.applyLink=function(e,n){var s=e.mark,l=e.attrs;return void 0===n&&(n="link"),function(e,a){var c=e.schema.marks,d=e.tr;n&&(d.setMeta("commandName",n),d.setMeta("args",l));var u=!1,h=function(){return u=!0};if(function(e,t){var n=o.selectionMarks(e,t);return 1===n.length&&n[0]?n[0]:null}(e,c[s]))!function(e,t){return function(n,r){var o=n.selection,i=o.$cursor,s=o.from,l=o.to,a=n.schema.marks[e.mark];if(i){var c=i.parent,d=i.index(),u=c.child(d).marks.find((function(e){return e.type===a})),h=c.childCount,p=i.pos-i.textOffset,f=c.child(d).nodeSize,m=void 0,g=void 0;for(m=d-1;m>=0&&u.isInSet(c.child(m).marks);)f+=g=c.child(m).nodeSize,p-=g,m-=1;for(m=d+1;m<h&&u.isInSet(c.child(m).marks);)f+=c.child(m).nodeSize,m+=1;t.removeMark(p,p+f,a),t.addMark(p,p+f,a.create(e.attrs)),r(t)}else t.doc.nodesBetween(s,l,(function(n,o){n.isInline&&a.isInSet(n.marks)&&(t.removeMark(o,o+n.nodeSize,a),t.addMark(o,o+n.nodeSize,a.create(e.attrs)),r(t))}))}}({mark:s,attrs:l},d)(e,h);else{var p=e;o.hasMark(e,{mark:s})&&(t.removeLink({mark:s,attrs:l},d)(e,h),p=i.EditorState.create({doc:d.doc,selection:d.selection})),u?o.toggleMark(c[s],l,d)(p,h):r.toggleInlineFormat({mark:s},d,l)(p,h)}return u&&a(d),u}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.insertText=void 0;t.insertText=function(e){return function(t,n){n(t.tr.insertText(e.text,e.from,e.to))}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.insertImage=void 0;var r=n(5);t.insertImage=function(e){return function(t,n){var o=t.schema.nodes.image,i=o.createAndFill(e);r.insertNode(i)(t,(function(t){return n(t.setMeta("commandName","insertImage").setMeta("args",e))}))}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isAligned=t.alignBlocks=void 0;var r=n(12);t.alignBlocks=function(e,t){return function(n,o){var i=r.blockNodes(n),s=n.tr;s.setMeta("commandName",t),i.forEach((function(t){if(t.type.isTextblock){var n=e.find((function(e){return e.node===t.type.name}));if(n){var o=r.addStyles(t,n.style);r.changeTextBlock(s,t,t.type,o)}}}));var l=s.docChanged;return l&&o(s.scrollIntoView()),l}};t.isAligned=function(e,t){var n=r.blockNodes(e),o=!1;return n.forEach((function(e){if(!o&&e.type.isTextblock&&e.attrs.style){var n=t.find((function(t){return t.node===e.type.name}));n&&(o=n.style.every((function(t){return!!t.value&&new RegExp(t.name+":\\s?"+t.value,"i").test(e.attrs.style)})))}})),o}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.cleanFormatting=void 0;var r=n(12),o=n(9);t.cleanFormatting=function(e){return void 0===e&&(e={blocksInSelection:!0}),function(t,n){var i=t.tr,s=e.blocksInSelection,l=e.blockNodeType,a=(e.exceptMarks||[t.schema.marks.link]).filter(Boolean);o.cleanMarks(i,{except:a}),r.cleanTextBlockFormatting(i,{blocksInSelection:s,blockNodeType:l});var c=i.docChanged;return c&&n&&n(i),c}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.outdent=t.indent=t.canBeIndented=t.canOutdentAsListItem=t.canIndentAsListItem=t.isIndented=t.indentBlocks=void 0;var r=n(15),o=n(18),i=n(12),s=n(5),l=n(20);t.indentBlocks=function(e,t,n){return function(r,o){var s=i.blockNodes(r),l=r.tr;l.setMeta("commandName",t),s.forEach((function(t){if(t.type.isTextblock){var r=void 0,o=e.find((function(e){return e.node===t.type.name}));if(o){var s="rtl"===n?o.rtlStyle:o.style,a={name:s,value:o.step>0?""+o.step+o.unit:""};if(t.attrs.style){var c=new RegExp(s+":\\s?(\\d+)"+o.unit,"i"),d=t.attrs.style.match(c);if(d){var u=parseFloat(d[1])+o.step;u=u<=0?"":u,a.value=""+u+(u?o.unit:"")}}r=i.addStyles(t,[a])}r&&i.changeTextBlock(l,t,t.type,r)}}));var a=l.docChanged;return a&&o(l.scrollIntoView()),a}};t.isIndented=function(e,t,n){var r=i.blockNodes(e),o=!1;return r.forEach((function(e){if(!o&&e.type.isTextblock&&e.attrs.style){var r=t.find((function(t){return t.node===e.type.name}));if(r){var i="rtl"===n?r.rtlStyle:r.style,s=new RegExp(i+":\\s?\\d+"+r.unit,"i");o=s.test(e.attrs.style)}}})),o};t.canIndentAsListItem=function(e,t){return r.sinkListItem(t)(e)};t.canOutdentAsListItem=function(e,t){var n=e.schema.nodes[t.listsTypes.listItem],o=e.schema.nodes[t.listsTypes.orderedList],i=e.schema.nodes[t.listsTypes.bulletList],l=!!s.findNthParentNodeOfType(o,2)(e.selection),a=!!s.findNthParentNodeOfType(i,2)(e.selection);return(l||a)&&r.liftListItem(n)(e)};t.canBeIndented=function(e,n){var r=e.schema.nodes,s=r[o.indentRules.listsTypes.listItem];return(t.isIndented(e,n.nodes)||o.indentRules.nodes.some((function(t){return r[t.node]&&i.hasNode(e,r[t.node])})))&&!i.hasNode(e,s)};t.indent=function(e,n){var i=e.schema.nodes[o.indentRules.listsTypes.listItem],s=t.canBeIndented(e,o.indentRules);t.canIndentAsListItem(e,i)?r.sinkListItem(i)(e,n):s&&t.indentBlocks(o.indentRules.nodes)(e,n)};t.outdent=function(e,n){var s=e.schema.nodes,a=s[o.outdentRules.listsTypes.listItem],c=t.canBeIndented(e,o.outdentRules);i.hasNode(e,s.blockquote)?l.liftBlockquote(e,n):t.canOutdentAsListItem(e,o.outdentRules)?r.liftListItem(a)(e,n):c&&t.indentBlocks(o.outdentRules.nodes)(e,n)}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.alignRemoveRules=t.alignJustifyRules=t.alignCenterRules=t.alignRightRules=t.alignLeftRules=void 0;var r=function(e,t){return{name:e,value:t}};t.alignLeftRules=[{node:"paragraph",style:[r("text-align","left")]},{node:"heading",style:[r("text-align","left")]},{node:"table_caption_external",style:[r("text-align","left")]}],t.alignRightRules=[{node:"paragraph",style:[r("text-align","right")]},{node:"heading",style:[r("text-align","right")]},{node:"table_caption_external",style:[r("text-align","right")]}],t.alignCenterRules=[{node:"paragraph",style:[r("text-align","center")]},{node:"heading",style:[r("text-align","center")]},{node:"table_caption_external",style:[r("text-align","center")]}],t.alignJustifyRules=[{node:"paragraph",style:[r("text-align","justify")]},{node:"heading",style:[r("text-align","justify")]},{node:"table_caption_external",style:[r("text-align","justify")]}],t.alignRemoveRules=[{node:"paragraph",style:[r("text-align","")]},{node:"heading",style:[r("text-align","")]},{node:"table_caption_external",style:[r("text-align","")]}]},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.buildListKeymap=t.buildKeymap=void 0;var r=n(4),o=n(13),i=n(25),s=n(22),l=n(21),a=n(23),c=n(14),d=n(5),u="undefined"!=typeof navigator&&/Mac/.test(navigator.platform);t.buildKeymap=function(e,t){var n={},l=t&&t.applyToWord||!1;if(n["Mod-z"]=i.undo,n["Shift-Mod-z"]=i.redo,n.Backspace=o.chainCommands(s.undoInputRule,o.deleteSelection,o.joinBackward,o.selectNodeBackward),n.Enter=o.chainCommands(o.newlineInCode,o.createParagraphNear,o.liftEmptyBlock,o.splitBlockKeepMarks),u||(n["Mod-y"]=i.redo),e.marks.strong&&(n["Mod-b"]=d.expandToWordWrap(c.toggleInlineFormat,r.__assign(r.__assign({},a.bold),{applyToWord:l}))),e.marks.em&&(n["Mod-i"]=d.expandToWordWrap(c.toggleInlineFormat,r.__assign(r.__assign({},a.italic),{applyToWord:l}))),e.marks.u&&(n["Mod-u"]=d.expandToWordWrap(c.toggleInlineFormat,r.__assign(r.__assign({},a.underline),{applyToWord:l}))),e.nodes.hard_break){var h=e.nodes.hard_break,p=o.chainCommands(o.exitCode,(function(e,t){return t(e.tr.replaceSelectionWith(h.create()).scrollIntoView()),!0}));n["Shift-Enter"]=p}return n};t.buildListKeymap=function(e){var t={};return e.nodes.list_item&&(t.Enter=l.splitListItemKeepMarks(e.nodes.list_item)),t}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.replaceImageSourcesFromRtf=t.pasteCleanup=t.sanitizeStyleAttr=t.sanitizeClassAttr=t.removeAttribute=t.removeTag=t.removeComments=t.sanitize=void 0;var r=n(24),o=n(8);t.sanitize=function(e){return e=(e=(e=(e=(e=(e=(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,"")).replace(/<style[^>]*?>\s*<\/style>/gi,"")).replace(/<\/?st1:.*?>/gi,"")).replace(/<a name="[a-zA-Z0-9_]+">/gim,"")).replace(/v:shapes?="[^"]+"/gi,"")).replace(/<!\[if !supportLists\]>/gi,"")).replace(/<!\[endif\]>/gi,"")};t.removeComments=function(e){return e.replace(/<!--[\s\S]+?-->/g,"")};t.removeTag=function(e,t){return e.replace(new RegExp("<\\/?("+t+")(?:\\s[^>]*?)?>","gi"),"")};t.removeAttribute=function(e){e.ownerElement&&e.ownerElement.removeAttribute(e.name)};t.sanitizeClassAttr=function(e){/^Mso/.test(e.value)&&t.removeAttribute(e)};var i=/\s*;\s*/,s=/\s*:\s*/;t.sanitizeStyleAttr=function(e){var n,r,o=e.value.split(i).filter((function(e){return Boolean(e)})),l=e.ownerElement.style,a="";o.forEach((function(e){var t;t=e.split(s),n=t[0],r=t[1],void 0!==l[n]&&(a+=n+": "+r+"; ")})),(a=a.trim())?e.value=a:t.removeAttribute(e)};function l(e){for(var t=e.length,n=new Array(t/2),r=0;r<t;r+=2)n[r]=String.fromCharCode(parseInt(e.substring(r,r+2),16));return btoa(n.join(""))}t.pasteCleanup=function(e,n){var i=e;if(n.convertMsLists&&(i=r.convertMsLists(i)),n.stripTags&&(i=t.removeTag(i,n.stripTags)),n.attributes){var s=o.htmlToFragment(i);Array.from(s.querySelectorAll("*")).forEach((function(e){return function(e,t){if(e.nodeType===Node.ELEMENT_NODE){for(var n=e.attributes.length-1;n>=0;n--){var r=e.attributes[n];t[r.name]?t[r.name](r):t["*"]&&t["*"](r)}"SPAN"===e.nodeName&&0===e.attributes.length&&function(e){var t=e.parentNode;if(t){for(;e.firstChild;)t.insertBefore(e.firstChild,e);t.removeChild(e)}}(e)}}(e,n.attributes)})),i=o.fragmentToHtml(s)}return i};var a=/<img\s[^>]*?src=(?:'|")file:\/[^'"]+(?:'|")[^>]*>/gi,c=/{\\pict[\s\S]+?\\bliptag-?\d+(\\blipupi-?\d+)?({\\\*\\blipuid\s?[\da-fA-F]+)?[\s}]*?/,d=new RegExp("(?:("+c.source+"))([\\da-fA-F\\s]+)\\}","g"),u=/[^\da-fA-F]/g,h=/file:\/[^'"]+\.(jpg|png|gif)/i,p=/\\(png|jpeg)blip\\/;t.replaceImageSourcesFromRtf=function(e,t){var n=e.match(a);if(!n||-1===t.types.indexOf("text/rtf"))return e;var r=t.getData("text/rtf"),o=[],i=r.match(d);if(!r||!i)return e;for(var s=0,f=i;s<f.length;s++){var m=f[s],g=p.exec(m);if(g){var y=m.replace(c,"").replace(u,"");o.push("data:image/"+g[1]+";base64,"+l(y))}}return n.length!==o.length?e:e.replace(a,(function(e){var t=o.shift()||"";return e.replace(h,t)}))}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.replaceAll=t.replace=t.findAll=t.find=t.findAt=void 0;var r=n(4),o=n(1);t.findAt=function(e,t,n,r,i){var a,c,d,u,h,p,f=[],m=[],g=t.matchCase,y=t.matchWord,v=t.useRegExp,b=t.text;if(v&&(/^\\$/.test(b)||/[^\\]\\$/.test(b))&&(b=b.substring(0,b.length-1)),!b)return f;var w=g?"g":"gi",S=v?new RegExp(b,w):l(b,w);return e.nodesBetween(n,r,(function(t,l,g){if(i(f))return!1;t.inlineContent&&l+t.content.size>=n&&(m.length=0,t.nodesBetween(0,t.content.size,(function(t,g,v,b){if(i(f))return!1;var w=1+l+g;if(t.isText&&w+t.nodeSize>=n){if(h=t.text||"",p=v.childCount-1>=b+1&&v.child(b+1),m.push(n<=w?{text:h,start:w}:{text:h.slice(n-w),start:n}),p&&p.isText)return;for(c=m.map((function(e){return e.text})).join(""),a=S.exec(c);null!==a&&(d=m[0].start+a.index,u=d+a[0].length,n<=d&&r>=u&&s(a,y)&&f.push(o.TextSelection.create(e,d,u)),!i(f));)a=S.exec(c)}else m.length=0})))})),f};t.find=function(e,n){var o=n.backward,i=n.matchCyclic,s=r.__rest(n,["backward","matchCyclic"]),l=o?function(){return!1}:function(e){return e.length>0},a=e.doc,c=e.selection,d=[];return o?!(d=t.findAt(a,s,0,c.from,l)).length&&i&&(d=t.findAt(a,s,c.from,a.content.size,l)):!(d=t.findAt(a,s,c.to,a.content.size,l)).length&&i&&(d=t.findAt(a,s,0,c.to,l)),d.length?d[d.length-1]:null};t.findAll=function(e,n){return t.findAt(e,n,0,e.content.size,(function(){return!1}))};t.replace=function(e,t,n){var r=e.from,i=e.to;return n.insertText(t,r,i).setSelection(o.TextSelection.create(n.doc,r,r+t.length)),n};t.replaceAll=function(e,n,r){var o=t.findAll(e.doc,r);if(0===o.length)return null;for(var i=e.tr,s=o.length-1;s>=0;s--)i.insertText(n,o[s].from,o[s].to);return i};var i=/^[\s0-9~`!@#$%\^&*\(\)_\-=+\\|\[\]{};:'"\?/.,<>]?$/,s=function(e,t){if(t){if(!0===t){var n=e.input,r=n.charAt(e.index-1),o=n.charAt(e.index+e[0].length);return i.test(r)&&i.test(o)}return t(e)}return!0},l=function(e,t){var n=e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d").replace(/\s/g,"\\s");return new RegExp(n,t)}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.placeholder=void 0;var r=n(1),o=n(3);t.placeholder=function(e){var t={class:"k-placeholder","data-placeholder":e};return new r.Plugin({key:new r.PluginKey("placeholder"),props:{decorations:function(e){var n=e.doc,r=n.content.firstChild;if(!(0===n.childCount||1===n.childCount&&r.inlineContent&&0===r.childCount))return o.DecorationSet.empty;var i=[];return n.descendants((function(e,n){i.push(o.Decoration.node(n,n+e.nodeSize,t))})),o.DecorationSet.create(n,i)}}})}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.spacesFix=void 0;var r=n(1),o=n(3),i=/\s+/g,s=/text-align/;t.spacesFix=function(){return new r.Plugin({key:new r.PluginKey("spaces-fix"),props:{decorations:function(e){var t,n,r,l,a=[],c=e.doc;return c.nodesBetween(0,c.content.size,(function(e,c,d){if(e.type.isText&&function(e){return s.test(e&&e.attrs&&e.attrs.style||"")}(d))for(n=i.exec(e.text||"");null!==n;){if(t=c+n.index,r=n[0].length,n.index+r<n.input.length)for(l=0;l<=r-1;l+=2)a.push(o.Decoration.inline(t+l,t+l+1,{style:"white-space: normal"}));n=i.exec(e.text||"")}})),o.DecorationSet.create(c,a)}}})}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.textHighlight=t.textHighlightKey=void 0;var r=n(1),o=n(3);t.textHighlightKey=new r.PluginKey("highlight"),t.textHighlight=function(e){return void 0===e&&(e=t.textHighlightKey),new r.Plugin({key:e,state:{init:function(){return null},apply:function(e){return e.getMeta(this.spec.key)}},props:{decorations:function(e){var t=(this.spec.key.getState(e)||[]).map((function(e){return o.Decoration.inline(e.from,e.to,e.attrs)}));return o.DecorationSet.create(e.doc,t)}}})}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.imageResizing=t.imageResizeKey=void 0;var r=n(4),o=n(1),i=n(3),s=n(6),l=n(5),a=n(17);t.imageResizeKey=new o.PluginKey("image-resize");var c=function(e,t,n){e.style[t]=n+"px"},d=/[^\-]width:|[^\-]height:/,u=/^.+$/,h=function(){function e(e,t,n,r){this.activeHandle=e,this.dragging=t,this.rect=n,this.nodePosition=r}return e.prototype.apply=function(n){var r=n.getMeta(t.imageResizeKey);return r?new e(r.activeHandle,r.setDragging,r.rect,r.nodePosition):this},e}(),p=function(e,n,i){var h=n.target.getAttribute(s.dataResizeDirImage);if(!h)return!1;var p=t.imageResizeKey.getState(e.state);n.preventDefault();var f=e.state.tr;function m(n){!function(e,n,r){var o=t.imageResizeKey.getState(e.state),i=o.rect,s=o.dragging,l=o.nodePosition,d=o.activeHandle;if(s&&i){var u=e.nodeDOM(l),h=a.directions[d],p=(n.clientX-s.startX)*h.x,f=(n.clientY-s.startY)*h.y,m=h.x?p+u.width:i.width,g=h.y?f+u.height:i.height;if(r.lockRatio&&h.x&&h.y){var y=Math.min(m/u.width,g/u.height),v=u.width*y,b=u.height*y;s.startX=n.clientX-(m-v)*h.x,s.startY=n.clientY-(g-b)*h.y,m=v,g=b}else s.startX=h.x?n.clientX:s.startX,s.startY=h.y?n.clientY:s.startY;c(u,"width",m),c(u,"height",g),i.top=u.offsetTop,i.left=u.offsetLeft,i.width=u.offsetWidth,i.height=u.offsetHeight;var w=u.nextElementSibling;w.style.width=i.width+"px",w.style.height=i.height+"px",w.style.top=i.top+"px",w.style.left=i.left+"px"}}(e,n,i)}return f.setMeta(t.imageResizeKey,{setDragging:{startX:n.clientX,startY:n.clientY},activeHandle:h,rect:p.rect,nodePosition:p.nodePosition}),f.setMeta("addToHistory",!1),e.dispatch(f),n.view.addEventListener("mouseup",(function n(i){i.view.removeEventListener("mouseup",n),i.view.removeEventListener("mousemove",m),function(e){var n=t.imageResizeKey.getState(e.state),i=n.rect,s=n.dragging,a=n.nodePosition;if(s&&i){var c=e.state.selection;if(c instanceof o.NodeSelection){var h=c.node.attrs,p=i.width,f=i.height,m=void 0;if(d.test(h.style||"")){var g=l.changeStylesString(h.style,{style:"width",value:u,newValue:p+"px"}),y=l.changeStylesString(g.style||"",{style:"height",value:u,newValue:f+"px"}).style;m=r.__assign(r.__assign({},h),{style:y})}else m=r.__assign(r.__assign({},h),{width:p,height:f});var v=c.node.type.createAndFill(m);if(v){var b=e.state.tr;b.replaceWith(a,a+1,v),b.setSelection(o.NodeSelection.create(b.doc,a)),b.setMeta("commandName","image-resize"),b.setMeta("args",m),b.setMeta(t.imageResizeKey,{setDragging:null,activeHandle:null,rect:i,nodePosition:a}),e.dispatch(b)}}}}(e)})),n.view.addEventListener("mousemove",m),!0};t.imageResizing=function(e){return void 0===e&&(e={node:"image",lockRatio:!0}),new o.Plugin({key:t.imageResizeKey,view:function(n){return{resize:function(){t.imageResizeKey.getState(n.state).rect&&n.dispatch(n.state.tr.setMeta("resize",!0))},get window(){return n.dom.ownerDocument&&n.dom.ownerDocument.defaultView},attachResize:function(){var e=this.window;e&&(e.removeEventListener("resize",this.resize),e.addEventListener("resize",this.resize))},removeResize:function(){var e=this.window;e&&e.removeEventListener("resize",this.resize)},update:function(n,r){var i=n.state,s=i.selection,l=i.schema.nodes[e.node],a=t.imageResizeKey.getState(i),c=a.rect;if(s instanceof o.NodeSelection&&l===s.node.type){var d=n.nodeDOM(s.from),u={top:d.offsetTop,left:d.offsetLeft,width:d.offsetWidth,height:d.offsetHeight};if(!r.selection.eq(s)||c&&(c.width!==u.width||c.height!==u.height||c.top!==u.top||c.left!==u.left)){var h=i.tr;h.setMeta(t.imageResizeKey,{rect:u,nodePosition:s.from}),n.dispatch(h),this.attachResize()}}else c&&(a.rect=null,a.nodePosition=-1)},destroy:function(){this.removeResize()}}},state:{init:function(){return new h("",null,null,-1)},apply:function(e,t){return t.apply(e)}},props:{handleDOMEvents:{mousedown:function(t,n){return p(t,n,e)}},decorations:function(n){var r=n.selection,l=n.schema.nodes[e.node],c=t.imageResizeKey.getState(n).rect;if(c&&r instanceof o.NodeSelection&&l===r.node.type){var d=document.createElement("div");d.className="k-editor-resize-handles-wrapper",d.style.width=c.width+"px",d.style.height=c.height+"px",d.style.top=c.top+"px",d.style.left=c.left+"px";for(var u=0;u<a.handles.length;u++){var h=document.createElement("div");h.className=s.resizeHandle+" "+a.handles[u],h.setAttribute(s.dataResizeDirImage,a.handles[u]),d.appendChild(h)}return i.DecorationSet.create(n.doc,[i.Decoration.widget(n.selection.from+1,d)])}return i.DecorationSet.empty}}})}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.caretColor=t.caretColorKey=void 0;var r=n(1),o=n(3),i=n(9);t.caretColorKey=new r.PluginKey("caret-color"),t.caretColor=function(){return new r.Plugin({key:t.caretColorKey,props:{decorations:function(e){var t=e.doc,n=e.selection,r=e.storedMarks;if(!n.empty||!r)return o.DecorationSet.empty;var s=i.styleValue((r||[]).find((function(e){return"style"===e.type.name})),{name:"color",value:/^.+$/});if(!s)return o.DecorationSet.empty;var l=n.$anchor.parent,a=[];return t.descendants((function(e,t){e.eq(l)&&a.push(o.Decoration.node(t,t+e.nodeSize,{style:"caret-color: "+s}))})),o.DecorationSet.create(t,a)}}})}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.tableRowResizeKey=t.tableColumnResizeKey=t.tableResizeKey=t.tableResizing=void 0;var r=n(43),o=n(45),i=n(46);t.tableResizing=function(){return[o.tableResizing(),r.columnResizing(),i.rowResizing()]};var s=n(10);Object.defineProperty(t,"tableResizeKey",{enumerable:!0,get:function(){return s.tableResizeKey}}),Object.defineProperty(t,"tableColumnResizeKey",{enumerable:!0,get:function(){return s.tableColumnResizeKey}}),Object.defineProperty(t,"tableRowResizeKey",{enumerable:!0,get:function(){return s.tableRowResizeKey}})},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.columnResizing=void 0;var r=n(4),o=n(1),i=n(7),s=n(3),l=n(6),a=n(44),c=n(10);t.columnResizing=function(){return new o.Plugin({key:c.tableColumnResizeKey,state:{init:function(e,t){return new d(-1,null)},apply:function(e,t){return t.apply(e)}},props:{attributes:function(e){return c.otherResizeHandle(c.tableColumnResizeKey,e)?null:c.tableColumnResizeKey.getState(e).activeHandle>-1?{class:"resize-cursor"}:null},handleDOMEvents:{mousemove:function(e,t){return c.otherResizing(c.tableColumnResizeKey,e.state)||function(e,t,n){var r=c.tableColumnResizeKey.getState(e.state);if(!r.dragging){var o=c.domCellAround(t.target),i=-1;if(o){var s=c.cellIndexes(o),l=o.getBoundingClientRect(),a=l.left,d=l.right;Math.abs(t.clientX-a)<=n&&s.cellIndex>0?(s.cellIndex-=o.colSpan,i=c.edgeCell(e,t,s)):d-t.clientX>0&&d-t.clientX<=n&&(i=c.edgeCell(e,t,s))}i!==r.activeHandle&&h(e,i)}}(e,t,5),!1},mouseleave:function(e){return function(e){var t=c.tableColumnResizeKey.getState(e.state);t.activeHandle>-1&&!t.dragging&&h(e,-1)}(e),!1},mousedown:function(e,t){return function(e,t,n){var o,s=c.tableColumnResizeKey.getState(e.state);if(-1===s.activeHandle||s.dragging)return!1;for(var a=e.state.doc.resolve(s.activeHandle),d=a.parent,h=a.index(),p=0,f=0;f<=h;f++)p+=d.child(f).attrs.colspan;var m,g,y=a.node(a.depth-1),v=e.domAtPos(s.activeHandle),b=v.node.childNodes[v.offset].closest("table");if(y.attrs[l.colgroupAttr]){var w=b.firstChild;(m=w.children[p-1]).style.width||(m.style.width=m.offsetWidth+"px")}else{var S=0;for(f=0;f<d.childCount;f++)S+=d.child(f).attrs.colspan;w=document.createElement("colgroup");var k=new Array(S);for(f=0;f<S;f++)k[f]=document.createElement("col"),w.appendChild(k[f]);b.insertBefore(w,b.firstChild),(m=k[h]).style.width=m.offsetWidth+"px",g=r.__assign(r.__assign({},y.attrs),((o={})[l.colgroupAttr]="<colgroup>"+k.reduce((function(e,t){return e+t.outerHTML}),"")+"</colgroup>",o))}var x=parseFloat(m.style.width),C=e.state.tr.setMeta(c.tableColumnResizeKey,{setDragging:{startX:t.clientX,startWidth:x}});if(!b.style.width){var M=Array.from(m.parentNode.children).map((function(e){return e.style.width}));if(M.every(Boolean)){var O=M.reduce((function(e,t){return e+parseFloat(t)}),0);g=c.setNodeStyle(g||y.attrs,"width",O+"px")}}if(g){var T=a.posAtIndex(0,a.depth-1)-1;C.setNodeMarkup(T,null,g)}function A(t){t.view.removeEventListener("mouseup",A),t.view.removeEventListener("mousemove",N);var o=c.tableColumnResizeKey.getState(e.state);if(o.dragging){var i=e.state.tr;!function(e,t,n,o){var i,s=e.state.doc.resolve(n),a=s.node(-1),d=s.start(-1),u=s.posAtIndex(0,s.depth-1)-1,h=e.nodeDOM(d).closest("table"),p=a.attrs;if(a&&p[l.colgroupAttr]){var f=h.firstChild;p=r.__assign(r.__assign({},p),((i={})[l.colgroupAttr]=f.outerHTML,i))}var m=h.style.width;h&&m&&c.parseStyle(p.style).width!==m&&(p=c.setNodeStyle(p,"width",m));t.setNodeMarkup(u,null,p)}(e,i,o.activeHandle,u(o.dragging,t,n)),e.dispatch(i.setMeta(c.tableColumnResizeKey,{setDragging:null}))}}function N(t){if(!t.which)return A(t);var r=c.tableColumnResizeKey.getState(e.state),o=u(r.dragging,t,n);!function(e,t,n,r){var o=e.state.doc.resolve(t),s=o.node(-1),l=o.start(-1),a=i.TableMap.get(s).colCount(o.pos-l)+o.nodeAfter.attrs.colspan-1,c=e.domAtPos(o.start(-1)).node;"TABLE"!==c.nodeName&&(c=c.closest("table"));var d=c,u=d.firstChild,h=Array.from(u.children);if(h[a].style.width=n+"px",d.style.width){var p=h.map((function(e){return e.style.width}));if(p.every(Boolean)){var f=p.reduce((function(e,t){return e+parseFloat(t)}),0);d.style.width=f+"px"}}}(e,r.activeHandle,o)}return e.dispatch(C),t.view.addEventListener("mouseup",A),t.view.addEventListener("mousemove",N),t.preventDefault(),!0}(e,t,25)}},decorations:function(e){if(!c.otherResizing(c.tableColumnResizeKey,e)){var t=c.tableColumnResizeKey.getState(e);if(t.activeHandle>-1)return function(e,t){for(var n=[],r=e.doc.resolve(t),o=r.node(-1),l=i.TableMap.get(o),a=r.start(-1),c=[],d=t-a,u=-1,h=0;h<l.height;h++)c.push(l.map.slice(h*l.width,h*l.width+l.width)),-1===u&&(u=c[h].lastIndexOf(d));var p=[];return c.forEach((function(e){var t=e[u];e[u]!==e[u+1]&&p.push(t)})),p.forEach((function(e){var t=a+e+o.nodeAt(e).nodeSize-1,r=document.createElement("div");r.className="column-resize-handle",n.push(s.Decoration.widget(t,r))})),s.DecorationSet.create(e.doc,n)}(e,t.activeHandle)}return s.DecorationSet.empty},nodeViews:{table_wrapper:function(e,t){return new a.TableWrapperView(e,t)},table:function(e,t){return new a.TableView(e,t)}}}})};var d=function(){function e(e,t){this.activeHandle=e,this.dragging=t}return e.prototype.apply=function(t){var n,r=this,o=t.getMeta(c.tableColumnResizeKey);if(o&&null!=o.setHandle)return new e(o.setHandle,null);if(o&&void 0!==o.setDragging)return new e(r.activeHandle,o.setDragging);if(r.activeHandle>-1&&t.docChanged){var i=t.mapping.map(r.activeHandle,-1);n=t.doc.resolve(i),Boolean("row"===n.parent.type.spec.tableRole&&n.nodeAfter)||(i=-1),r=new e(i,r.dragging)}return r},e}();function u(e,t,n){var r=t.clientX-e.startX;return Math.max(n,e.startWidth+r)}function h(e,t){var n=e.state.tr;n.setMeta("addToHistory",!1),n.setMeta(c.tableColumnResizeKey,{setHandle:t}),e.dispatch(n)}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TableWrapperView=t.TableView=void 0;var r=n(6),o=n(16),i=n(17),s=n(10),l=function(){function e(e,t){this.node=e,this.view=t,this.dom=document.createElement("div"),this.dom.className=r.resizableWrap,this.table=this.dom.appendChild(document.createElement("table")),e.attrs[r.colgroupAttr]&&this.renderColgroup(e.attrs[r.colgroupAttr]);var n=this.table.appendChild(document.createElement("tbody"));this.setAttributes(this.table,e.attrs),this.resizeHandles=i.handles.map((function(e){var t=document.createElement("span");return t.className=r.resizeHandle+" "+e,t.setAttribute(r.dataResizeDirTable,e),t})),this.contentDOM=n}return e.prototype.update=function(e){var t=this;if(e.type!==this.node.type)return!1;var n=this.node;return this.node=e,e.attrs[r.resizableAttr]?this.resizeHandles.forEach((function(e){t.dom.appendChild(e)})):Array.from(this.dom.children).filter((function(e){return e.classList.contains(r.resizeHandle)})).forEach((function(e){return e.remove()})),this.setAttributes(this.table,e.attrs),n.attrs[r.colgroupAttr]!==e.attrs[r.colgroupAttr]&&this.renderColgroup(e.attrs[r.colgroupAttr]),!0},e.prototype.ignoreMutation=function(e){return"attributes"===e.type&&(e.target===this.table||e.target.firstChild===this.table||this.colgroup&&this.colgroup.contains(e.target))},e.prototype.destroy=function(){this.node=void 0,this.view=void 0,this.table=void 0,this.colgroup=void 0,this.resizeHandles=void 0},e.prototype.renderColgroup=function(e){this.table&&this.table.firstChild&&"COLGROUP"===this.table.firstChild.nodeName&&this.table.removeChild(this.table.firstChild),e&&(this.colgroup=o.parseStrColgroup(e),this.table.insertBefore(this.colgroup,this.table.firstChild))},e.prototype.setAttributes=function(e,t){var n=[r.colgroupAttr,r.resizableAttr];for(var o in t)if(o&&-1===n.indexOf(o)){var i=e.getAttribute(o),s=t[o];s&&s!==i?e.setAttribute(o,s):s||e.removeAttribute(o)}/%$/.test(e.style.width)?(this.dom.style.width=e.style.width,e.style.width=""):this.dom.style.width=""},e}();t.TableView=l;var a=function(){function e(e,t){this.node=e,this.view=t,this.dom=document.createElement("div"),this.setAttributes(this.dom,e.attrs),this.contentDOM=this.dom}return e.prototype.update=function(e){return e.type===this.node.type&&(this.node=e,this.setAttributes(this.dom,e.attrs),!0)},e.prototype.ignoreMutation=function(e){return"attributes"===e.type&&"style"===e.attributeName},e.prototype.destroy=function(){this.node=void 0,this.view=void 0},e.prototype.setAttributes=function(e,t){for(var n in t)if(n){var r=e.getAttribute(n),o=t[n];o&&o!==r?e.setAttribute(n,o):o||e.removeAttribute(n)}if(e.setAttribute("table",""),/%/.test(e.style.width)){var i=this.node&&this.node.lastChild,l=(i?s.parseStyle(i.attrs.style):{}).width||"";l&&!/%/.test(l)&&(e.style.width="")}},e}();t.TableWrapperView=a},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.tableResizing=void 0;var r=n(4),o=n(1),i=n(6),s=n(10),l=n(17),a={southeast:!0,southwest:!0,northwest:!0,northeast:!0},c=r.__assign({east:!0,west:!0},a),d=r.__assign({south:!0,north:!0},a),u=function(){function e(e,t,n){this.activeHandle=e,this.dragging=t,this.nodePosition=n}return e.prototype.apply=function(t){var n=t.getMeta(s.tableResizeKey);return n?new e(n.activeHandle,n.setDragging,n.nodePosition):this},e}(),h=function(e){var t=Array.from(e.firstChild.children).map((function(e){return e.offsetWidth})),n=Array.from(e.rows).map((function(e){return e.offsetHeight})),r=t.reduce((function(e,t){return e+t}),0),o=n.reduce((function(e,t){return e+t}),0),i=e.offsetHeight;return{width:r,height:o,colsWidth:t,rowsHeight:n,offsetWidth:e.offsetWidth,offsetHeight:i}},p=function(e){var t=s.tableResizeKey.getState(e.state),n=t.dragging,o=t.nodePosition,l=t.activeHandle;if(n){var a=e.state.doc.nodeAt(o),u=s.getTable(e.nodeDOM(o)),p=h(u);if(a){var f=p.offsetWidth+"px",m=p.offsetHeight+"px",g=e.state.tr,y=a.attrs,v=s.parseStyle(y.style);if(c[l]&&u.style.width&&v.width!==f&&(y=s.setNodeStyle(y,"width",f)),d[l]&&u.style.height&&v.height!==m&&(y=s.setNodeStyle(y,"height",m)),y=function(e,t,n,o){var l=e.state.doc.nodeAt(n),a=s.getTable(e.nodeDOM(n)),c=(a.ownerDocument&&a.ownerDocument.defaultView||window).getComputedStyle,d=Array.from(a.rows);l.forEach((function(e,r,o){var i=s.parseStyle(e.attrs.style).height;i&&!/px$/.test(i)&&t.setNodeMarkup(n+r+1,null,s.setNodeStyle(e.attrs,"height",c(d[o]).height))}));var u=a.firstChild,h=Array.from(u&&u.children||[]),p=!1;h.forEach((function(e,t){e.style.width&&!/px$/.test(e.style.width)&&(e.style.width=c(h[t]).width,p=!0)}));var f=r.__assign({},o);return p&&(f[i.colgroupAttr]=u.outerHTML),f}(e,g,o,y),g.setNodeMarkup(o,null,y),g.setMeta("commandName","node-resize"),g.setMeta("args",y),g.setMeta(s.tableResizeKey,{setDragging:null,activeHandle:null,nodePosition:o}),!/%/.test(s.parseStyle(y.style).width||"")){var b=g.doc.resolve(o),w=s.parentNode(b,(function(e){return"table_wrapper"===e.type.name}));if(w&&/%/.test(s.parseStyle(w.node.attrs.style).width||"")){var S=s.setNodeStyle(w.node.attrs,"width",""),k=b.start(w.depth)-1;g.setNodeMarkup(k,null,S)}}e.dispatch(g)}}},f=function(e,t){var n=t.target.getAttribute(i.dataResizeDirTable);if(!n)return!1;var r=s.tableResizeKey.getState(e.state);t.preventDefault();var o=e.state.tr;o.setMeta(s.tableResizeKey,{setDragging:{startX:t.clientX,startY:t.clientY},activeHandle:n,nodePosition:r.nodePosition}),o.setMeta("addToHistory",!1),function(e,t,n){var r=e.state.doc.nodeAt(n),o=s.getTable(e.nodeDOM(n)),l=h(o),a=l.width,c=l.height,d=l.colsWidth,u=l.rowsHeight,p=l.offsetWidth,f=l.offsetHeight,m=o.firstChild,g=Array.from(m&&m.children||[]),y=!1;g.forEach((function(e,t){e.style.width&&!/%$/.test(e.style.width)&&(e.style.width=100*d[t]/a+"%",y=!0)}));var v=!1;r.forEach((function(e,r,o){var i=s.parseStyle(e.attrs.style).height;i&&!/%$/.test(i)&&(t.setNodeMarkup(n+r+1,null,s.setNodeStyle(e.attrs,"height",100*u[o]/c+"%")),v=!0)}));var b=r.attrs;s.parseStyle(b.style).width!==p+"px"&&(b=s.setNodeStyle(b,"width",p+"px")),y&&(b[i.colgroupAttr]=m.outerHTML),v&&(b=s.setNodeStyle(b,"height",f+"px")),(y||v)&&t.setNodeMarkup(n,null,b)}(e,o,r.nodePosition),e.dispatch(o);var a=t.view||window;function u(t){!function(e,t){var n,r=s.tableResizeKey.getState(e.state),o=r.dragging,i=r.nodePosition,a=r.activeHandle;if(!(i<0)&&o){var u=s.getTable(e.nodeDOM(i)),h=u.getBoundingClientRect(),p=l.directions[a],f=(t.clientX-o.startX)*p.x,m=(t.clientY-o.startY)*p.y,g=(u.ownerDocument&&u.ownerDocument.defaultView||window).getComputedStyle(u),y=/px/.test(g.width)?parseFloat(g.width):u.offsetWidth,v=/px/.test(g.height)?parseFloat(g.height):u.offsetHeight,b=p.x?f+y:h.width,w=p.y?m+v:h.height;if(o.startX=p.x?t.clientX:o.startX,o.startY=p.y?t.clientY:o.startY,c[a]&&(u.style.width=b+"px"),d[a]&&(u.style.height=w+"px"),/px/.test(u.style.width)){var S=null===(n=u.parentNode)||void 0===n?void 0:n.parentNode;S instanceof HTMLDivElement&&S.matches("div[table]")&&/%/.test(S.style.width)&&(S.style.width="")}}}(e,t)}return a.addEventListener("mouseup",(function t(n){a.removeEventListener("mouseup",t),a.removeEventListener("mousemove",u),p(e)})),a.addEventListener("mousemove",u),!0};t.tableResizing=function(e){return void 0===e&&(e={node:"table"}),new o.Plugin({key:s.tableResizeKey,view:function(t){return{selectedNode:function(e,t){var n=e.selection;if(n instanceof o.NodeSelection&&t===n.node.type&&n instanceof o.NodeSelection)return{node:n.node,pos:n.from};var r=s.parentNode(n.$from,(function(e){return e.type===t})),i=r&&r.node;return i?{node:i,pos:n.$from.start(r.depth)-1}:null},update:function(t,n){var o,l,a,c,d,u=t.state,h=u.schema.nodes[e.node],p=this.selectedNode(u,h),f=this.selectedNode(n,h);if((p||!f||n.doc.eq(t.state.doc))&&(p||f)){var m=u.tr;if(m.setMeta("addToHistory",!1),p&&f&&p.pos!==f.pos){m.setMeta(s.tableResizeKey,{nodePosition:p.pos});var g=m.doc.nodeAt(f.pos);g&&g.type.name===h.name&&m.setNodeMarkup(f.pos,h,r.__assign(r.__assign({},f.node.attrs),((o={})[i.resizableAttr]=!1,o))),m.setNodeMarkup(p.pos,h,r.__assign(r.__assign({},p.node.attrs),((l={})[i.resizableAttr]=!0,l))),t.dispatch(m)}else p&&f&&p.pos===f.pos&&!p.node.attrs[i.resizableAttr]&&!u.selection.eq(n.selection)?(m.setMeta(s.tableResizeKey,{nodePosition:p.pos}),t.dispatch(m.setNodeMarkup(p.pos,h,r.__assign(r.__assign({},p.node.attrs),((a={})[i.resizableAttr]=!0,a))))):p&&!f?(m.setMeta(s.tableResizeKey,{nodePosition:p.pos}),t.dispatch(m.setNodeMarkup(p.pos,h,r.__assign(r.__assign({},p.node.attrs),((c={})[i.resizableAttr]=!0,c))))):!p&&f&&(m.setMeta(s.tableResizeKey,{nodePosition:-1}),t.dispatch(m.setNodeMarkup(f.pos,h,r.__assign(r.__assign({},f.node.attrs),((d={})[i.resizableAttr]=!1,d)))))}}}},state:{init:function(){return new u("",null,-1)},apply:function(e,t){return t.apply(e)}},props:{handleDOMEvents:{mousedown:function(e,t){return f(e,t)}}}})}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.rowResizing=void 0;var r=n(1),o=n(7),i=n(3),s=n(10),l=function(){function e(){}return e.prototype.ignoreMutation=function(e){return"attributes"===e.type&&"style"===e.attributeName&&"TR"===e.target.nodeName},e}();t.rowResizing=function(){return new r.Plugin({key:s.tableRowResizeKey,state:{init:function(e,t){return this.spec.props.nodeViews[o.tableNodeTypes(t.schema).row.name]=function(e,t){return new l},new a(-1,null)},apply:function(e,t){return t.apply(e)}},props:{attributes:function(e){return s.otherResizeHandle(s.tableRowResizeKey,e)?null:s.tableRowResizeKey.getState(e).activeHandle>-1?{class:"resize-cursor-vertical"}:null},handleDOMEvents:{mousemove:function(e,t){return s.otherResizing(s.tableRowResizeKey,e.state)||function(e,t,n){var r=s.tableRowResizeKey.getState(e.state);if(!r.dragging){var o=s.domCellAround(t.target),i=-1;if(o){var l=s.cellIndexes(o),a=o.getBoundingClientRect(),d=a.top,u=a.bottom;Math.abs(t.clientY-d)<=n&&l.rowIndex>0?(l.rowIndex-=o.rowSpan,i=s.edgeCell(e,t,l)):u-t.clientY>0&&u-t.clientY<=n&&(i=s.edgeCell(e,t,l))}i!==r.activeHandle&&c(e,i)}}(e,t,5),!1},mouseleave:function(e){return function(e){var t=s.tableRowResizeKey.getState(e.state);t.activeHandle>-1&&!t.dragging&&c(e,-1)}(e),!1},mousedown:function(e,t){return function(e,t){var n=s.tableRowResizeKey.getState(e.state);if(-1===n.activeHandle||n.dragging)return!1;var r=e.state.doc.resolve(n.activeHandle),o=r.parent,i=r.node(-1),l=s.parseStyle(o.attrs.style).height,a=s.parseStyle(i.attrs.style).height,c=l?parseFloat(l):0;if(!l){var d=e.nodeDOM(n.activeHandle);c=d.offsetHeight}function u(t){t.view.removeEventListener("mouseup",u),t.view.removeEventListener("mousemove",h);var n=s.tableRowResizeKey.getState(e.state);if(n.dragging){var r=e.state.tr.setMeta(s.tableRowResizeKey,{setDragging:null});!function(e,t,n){var r=e.state.doc,o=r.resolve(n),i=o.parent,l=o.posAtIndex(0)-1,a=e.nodeDOM(l),c=a.ownerDocument&&a.ownerDocument.defaultView||window;a.style.height=c.getComputedStyle(a).height,t.setNodeMarkup(l,null,s.setNodeStyle(i.attrs,"height",a.style.height));var d=a&&a.closest("table"),u=d&&d.style.height;if(u){var h=r.resolve(l),p=h.start(h.depth)-1;t.setNodeMarkup(p,null,s.setNodeStyle(h.parent.attrs,"height",u))}}(e,r,n.activeHandle),e.dispatch(r)}}function h(t){if(!t.which)return u(t);var n=s.tableRowResizeKey.getState(e.state),r=function(e,t){var n=t.clientY-e.startY;return e.startHeight.rowHeight+n}(n.dragging,t),o=t.clientY-n.dragging.startY;!function(e,t,n,r,o){var i=e.nodeDOM(t),s=i&&i.parentNode;if(s){s.style.height=n+"px";var l=s.ownerDocument&&s.ownerDocument.defaultView||window;s.style.height=l.getComputedStyle(s).height;var a=s.closest("table"),c=parseFloat(o)+r+"px",d=a&&a.style.height;d&&d!==c&&(a.style.height=parseFloat(o)+r+"px",a.style.height=l.getComputedStyle(a).height)}}(e,n.activeHandle,r,o,a)}return e.dispatch(e.state.tr.setMeta(s.tableRowResizeKey,{setDragging:{startY:t.clientY,startHeight:{rowHeight:c,tableHeight:a}}})),t.view.addEventListener("mouseup",u),t.view.addEventListener("mousemove",h),t.preventDefault(),!0}(e,t)}},decorations:function(e){if(s.otherResizing(s.tableRowResizeKey,e))return i.DecorationSet.empty;var t=s.tableRowResizeKey.getState(e);return t.activeHandle>-1?function(e,t){var n=[];if("number"!=typeof t)return i.DecorationSet.empty;for(var r=e.doc.resolve(t),s=r.node(-1),l=o.TableMap.get(s),a=r.start(-1),c=[],d=t-a,u=-1,h=0;h<l.height;h++)c.push(l.map.slice(h*l.width,h*l.width+l.width)),-1!==c[h].indexOf(d)&&(u=h);var p=[];return c[u].forEach((function(e,t){c[u+1]&&e===c[u+1][t]||p.push(e)})),p.forEach((function(e){var t=s.nodeAt(e),r=a+e+(t?t.nodeSize:0)-1,o=document.createElement("div");o.className="row-resize-handle",n.push(i.Decoration.widget(r,o))})),i.DecorationSet.create(e.doc,n)}(e,t.activeHandle):void 0},nodeViews:{}}})};var a=function(){function e(e,t){this.activeHandle=e,this.dragging=t}return e.prototype.apply=function(t){var n,r=this,o=t.getMeta(s.tableRowResizeKey);if(o&&null!=o.setHandle)return new e(o.setHandle,null);if(o&&void 0!==o.setDragging)return new e(r.activeHandle,o.setDragging);if(r.activeHandle>-1){var i=t.mapping.map(r.activeHandle,-1);"row"===(n=t.doc.resolve(i)).parent.type.spec.tableRole&&n.nodeAfter||(i=null),r=new e(i,r.dragging)}return r},e}();function c(e,t){var n=e.state.tr;n.setMeta("addToHistory",!1),n.setMeta(s.tableRowResizeKey,{setHandle:t}),e.dispatch(n)}},function(e,t,n){"use strict";n.r(t),n.d(t,"dropCursor",(function(){return i}));var r=n(1),o=n(2);function i(e={}){return new r.Plugin({view:t=>new s(t,e)})}class s{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,r=t.nodeAfter;if(n||r){let t=this.editorView.nodeDOM(this.cursorPos-(n?n.nodeSize:0));if(t){let o=t.getBoundingClientRect(),i=n?o.bottom:o.top;n&&r&&(i=(i+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2),e={left:o.left,right:o.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 r,o,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)r=-pageXOffset,o=-pageYOffset;else{let e=i.getBoundingClientRect();r=e.left-i.scrollLeft,o=e.top-i.scrollTop}this.element.style.left=e.left-r+"px",this.element.style.top=e.top-o+"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),r=n&&n.type.spec.disableDropCursor,i="function"==typeof r?r(this.editorView,t,e):r;if(t&&!i){let e=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let t=Object(o.dropPoint)(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)}}},function(e,t,n){"use strict";n.r(t),n.d(t,"GapCursor",(function(){return l})),n.d(t,"gapCursor",(function(){return c}));var r=n(11),o=n(1),i=n(0),s=n(3);class l extends o.Selection{constructor(e){super(e,e)}map(e,t){let n=e.resolve(t.map(this.head));return l.valid(n)?new l(n):o.Selection.near(n)}content(){return i.Slice.empty}eq(e){return e instanceof l&&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 l(e.resolve(t.pos))}getBookmark(){return new a(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),r=e.node(t);if(0!=n)for(let e=r.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(r.type.spec.isolating)return!0}return!0}(e)||!function(e){for(let t=e.depth;t>=0;t--){let n=e.indexAfter(t),r=e.node(t);if(n!=r.childCount)for(let e=r.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(r.type.spec.isolating)return!0}return!0}(e))return!1;let n=t.type.spec.allowGapCursor;if(null!=n)return n;let r=t.contentMatchAt(e.index()).defaultType;return r&&r.isTextblock}static findGapCursorFrom(e,t,n=!1){e:for(;;){if(!n&&l.valid(e))return e;let r=e.pos,i=null;for(let n=e.depth;;n--){let o=e.node(n);if(t>0?e.indexAfter(n)<o.childCount:e.index(n)>0){i=o.child(t>0?e.indexAfter(n):e.index(n)-1);break}if(0==n)return null;r+=t;let s=e.doc.resolve(r);if(l.valid(s))return s}for(;;){let s=t>0?i.firstChild:i.lastChild;if(!s){if(i.isAtom&&!i.isText&&!o.NodeSelection.isSelectable(i)){e=e.doc.resolve(r+i.nodeSize*t),n=!1;continue e}break}i=s,r+=t;let a=e.doc.resolve(r);if(l.valid(a))return a}return null}}}l.prototype.visible=!1,l.findFrom=l.findGapCursorFrom,o.Selection.jsonID("gapcursor",l);class a{constructor(e){this.pos=e}map(e){return new a(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return l.valid(t)?new l(t):o.Selection.near(t)}}function c(){return new o.Plugin({props:{decorations:f,createSelectionBetween:(e,t,n)=>t.pos==n.pos&&l.valid(n)?new l(n):null,handleClick:h,handleKeyDown:d,handleDOMEvents:{beforeinput:p}}})}const d=Object(r.keydownHandler)({ArrowLeft:u("horiz",-1),ArrowRight:u("horiz",1),ArrowUp:u("vert",-1),ArrowDown:u("vert",1)});function u(e,t){const n="vert"==e?t>0?"down":"up":t>0?"right":"left";return function(e,r,i){let s=e.selection,a=t>0?s.$to:s.$from,c=s.empty;if(s instanceof o.TextSelection){if(!i.endOfTextblock(n)||0==a.depth)return!1;c=!1,a=e.doc.resolve(t>0?a.after():a.before())}let d=l.findGapCursorFrom(a,t,c);return!!d&&(r&&r(e.tr.setSelection(new l(d))),!0)}}function h(e,t,n){if(!e||!e.editable)return!1;let r=e.state.doc.resolve(t);if(!l.valid(r))return!1;let i=e.posAtCoords({left:n.clientX,top:n.clientY});return!(i&&i.inside>-1&&o.NodeSelection.isSelectable(e.state.doc.nodeAt(i.inside)))&&(e.dispatch(e.state.tr.setSelection(new l(r))),!0)}function p(e,t){if("insertCompositionText"!=t.inputType||!(e.state.selection instanceof l))return!1;let{$from:n}=e.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(e.state.schema.nodes.text);if(!r)return!1;let s=i.Fragment.empty;for(let e=r.length-1;e>=0;e--)s=i.Fragment.from(r[e].createAndFill(null,s));let a=e.state.tr.replace(n.pos,n.pos,new i.Slice(s,0,0));return a.setSelection(o.TextSelection.near(a.doc.resolve(n.pos+1))),e.dispatch(a),!1}function f(e){if(!(e.selection instanceof l))return null;let t=document.createElement("div");return t.className="ProseMirror-gapcursor",s.DecorationSet.create(e.doc,[s.Decoration.widget(e.selection.head,t,{key:"gapcursor"})])}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pmDeleteColumn=t.pmAddColumnAfter=t.pmAddColumnBefore=t.pmAddRowAfter=t.pmAddRowBefore=t.deleteColumn=t.addColumnAfter=t.addColumnBefore=t.addRowAfter=t.addRowBefore=t.createTable=void 0;var r=n(4),o=n(7);Object.defineProperty(t,"pmAddRowAfter",{enumerable:!0,get:function(){return o.addRowAfter}}),Object.defineProperty(t,"pmAddRowBefore",{enumerable:!0,get:function(){return o.addRowBefore}}),Object.defineProperty(t,"pmAddColumnBefore",{enumerable:!0,get:function(){return o.addColumnBefore}}),Object.defineProperty(t,"pmAddColumnAfter",{enumerable:!0,get:function(){return o.addColumnAfter}}),Object.defineProperty(t,"pmDeleteColumn",{enumerable:!0,get:function(){return o.deleteColumn}});var i=n(6),s=n(16);t.createTable=function(e,t,n){for(var r,o=e.table,i=e.table_row,s=e.table_cell,l=[],a=0;a<t+1;a++){r=[];for(var c=0;c<n+1;c++)r.push(s.createAndFill());l.push(i.createAndFill(void 0,r))}return o.createAndFill(void 0,l)};var l=/^table$/,a=/^table_row$/,c=/^table_cell|table_header$/,d=function(e,t){for(var n=e.$head,r=n.depth;r>0;r--){var o=n.node(r);if(t.test(o.type.name))return{pos:n.before(r),node:o}}return null};t.addRowBefore=function(e,t){var n=t&&function(e){var n,r=d(e.selection,a),o=d(e.selection,l);if(r&&o&&r.node.attrs[i.rowTypeAttr]){for(var s=0,c=0;c<o.node.nodeSize;c++)if(o.node.child(c).eq(r.node)){s=c;break}var u=o.node.child(s-1),h=r.pos-u.nodeSize;e.setNodeMarkup(h,void 0,((n={})[i.rowTypeAttr]=r.node.attrs[i.rowTypeAttr],n))}return t(e)};return o.addRowBefore(e,n)};t.addRowAfter=function(e,t){var n=t&&function(e){var n,r=d(e.selection,a);if(r&&r.node.attrs[i.rowTypeAttr]){var o=r.pos+r.node.nodeSize;e.setNodeMarkup(o,void 0,((n={})[i.rowTypeAttr]=r.node.attrs[i.rowTypeAttr],n))}return t(e)};return o.addRowAfter(e,n)};var u=function(e,t){if(!e)return-1;var n=o.TableMap.get(e.node),r=d(t,c),i=n.map.indexOf(r.pos-e.pos-1),s=-1;return-1!==i&&(s=i%n.width),s},h=function(e,t,n){var o,l=u(t,e.selection),a=s.parseStrColgroup(t.node.attrs[i.colgroupAttr]);a.insertBefore(a.ownerDocument.createElement("col"),a.children[l+n]),e.setNodeMarkup(t.pos,null,r.__assign(r.__assign({},t.node.attrs),((o={})[i.colgroupAttr]=a.outerHTML,o)))};t.addColumnBefore=function(e,t){var n=t&&function(e){var n=d(e.selection,l);return n.node.attrs[i.colgroupAttr]?(h(e,n,-1),t(e)):t(e)};return o.addColumnBefore(e,n)};t.addColumnAfter=function(e,t){var n=t&&function(e){var n=d(e.selection,l);return n.node.attrs[i.colgroupAttr]?(h(e,n,1),t(e)):t(e)};return o.addColumnAfter(e,n)};t.deleteColumn=function(e,t){var n=d(e.selection,l),a=n&&n.node.attrs[i.colgroupAttr],c=u(n,e.selection),h=t&&function(e){if(!a)return t(e);var o=e.doc.nodeAt(n.pos);return function(e,t,n){var o,l=s.parseStrColgroup(t.node.attrs[i.colgroupAttr]);l.removeChild(l.children[n]),e.setNodeMarkup(t.pos,null,r.__assign(r.__assign({},t.node.attrs),((o={})[i.colgroupAttr]=l.outerHTML,o)))}(e,{node:o,pos:n.pos},c),t(e)};return o.deleteColumn(e,h)}}])}));