UNPKG

@limetech/lime-elements

Version:
1 lines • 391 kB
import{r as t,c as e,h as r,H as i,a as n}from"./p-DBTJNfo7.js";import{E as s,L as o,M as l,e as u}from"./p-BWYo6dLf.js";import{g as h,m as a,s as f}from"./p-CfUOv15O.js";import{U as c,f as d,g as p,r as m,t as g,i as w,j as b,u as v}from"./p-DTNvx8HZ.js";import{a as k}from"./p-ZcW3uvZL.js";import{i as D,S as y}from"./p-BJQylLSL.js";import{g as E}from"./p-gWSB8lIW.js";import{i as x}from"./p-B8VKuhvH.js";import{i as F}from"./p-oiMYqRQ0.js";import{c as M}from"./p-2kcqdtMr.js";import{t as A}from"./p-DVRaJQvC.js";import{c as C}from"./p-JbKhhoXs.js";import{i as S}from"./p-CrvUOVvg.js";import{c as O}from"./p-CWuGCKo1.js";import{i as $}from"./p-DkL-aPMx.js";import{d as B}from"./p-BviYUVSD.js";import"./p-BFTU3MAI.js";import"./p-DtS35Df5.js";import"./p-efBXH4mj.js";import"./p-BgPHaiMH.js";import"./p-Cs5T63LB.js";import"./p-f_1nwOC8.js";import"./p-DlJXKdhK.js";import"./p-CgNJbSP4.js";import"./p-D6dCQvwl.js";import"./p-BOEi1C7r.js";var R=Object.create,N=function(){function t(){}return function(e){if(!D(e))return{};if(R)return R(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}();"object"==typeof exports&&exports&&!exports.nodeType&&exports&&"object"==typeof module&&module&&!module.nodeType&&module;var _=Object.prototype.hasOwnProperty;function T(t){var e=new t.constructor(t.byteLength);return new c(e).set(new c(t)),e}var z=/\w*$/,j=y?y.prototype:void 0,q=j?j.valueOf:void 0;var I=g&&g.isMap,P=I?m(I):function(t){return F(t)&&"[object Map]"==p(t)},L=g&&g.isSet,J=L?m(L):function(t){return F(t)&&"[object Set]"==p(t)},U="[object Arguments]",V="[object Function]",H="[object Object]",W={};function G(t,e,r,i,n,s){var o;if(void 0!==o)return o;if(!D(t))return t;var l=x(t);if(l)o=function(t){var e=t.length,r=new t.constructor(e);return e&&"string"==typeof t[0]&&_.call(t,"index")&&(r.index=t.index,r.input=t.input),r}(t);else{var u=p(t),h=u==V||"[object GeneratorFunction]"==u;if(w(t))return t.slice();if(u==H||u==U||h&&!n)o=h?{}:function(t){return"function"!=typeof t.constructor||d(t)?{}:N(E(t))}(t);else{if(!W[u])return n?t:{};o=function(t,e){var r,i,n,s,o=t.constructor;switch(e){case"[object ArrayBuffer]":return T(t);case"[object Boolean]":case"[object Date]":return new o(+t);case"[object DataView]":return s=T((n=t).buffer),new n.constructor(s,n.byteOffset,n.byteLength);case"[object Float32Array]":case"[object Float64Array]":case"[object Int8Array]":case"[object Int16Array]":case"[object Int32Array]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":case"[object Uint16Array]":case"[object Uint32Array]":return function(t){var e=T(t.buffer);return new t.constructor(e,t.byteOffset,t.length)}(t);case"[object Map]":case"[object Set]":return new o;case"[object Number]":case"[object String]":return new o(t);case"[object RegExp]":return(i=new(r=t).constructor(r.source,z.exec(r))).lastIndex=r.lastIndex,i;case"[object Symbol]":return q?Object(q.call(t)):{}}}(t,u)}}s||(s=new b);var a=s.get(t);if(a)return a;s.set(t,o),J(t)?t.forEach((function(i){o.add(G(i,e,r,0,t,s))})):P(t)&&t.forEach((function(i,n){o.set(n,G(i,e,r,0,t,s))}));var f=l?void 0:v(t);return function(t,e){for(var r=-1,i=null==t?0:t.length;++r<i&&!1!==e(t[r],r););}(f||t,(function(i,n){f&&(i=t[n=i]),k(o,n,G(i,e,r,0,t,s))})),o}function Z(t){return G(t,5)}function K(t){this.content=t}function Y(t,e,r){for(let i=0;;i++){if(i==t.childCount||i==e.childCount)return t.childCount==e.childCount?null:r;let n=t.child(i),s=e.child(i);if(n!=s){if(!n.sameMarkup(s))return r;if(n.isText&&n.text!=s.text){for(let t=0;n.text[t]==s.text[t];t++)r++;return r}if(n.content.size||s.content.size){let t=Y(n.content,s.content,r+1);if(null!=t)return t}r+=n.nodeSize}else r+=n.nodeSize}}function X(t,e,r,i){for(let n=t.childCount,s=e.childCount;;){if(0==n||0==s)return n==s?null:{a:r,b:i};let o=t.child(--n),l=e.child(--s),u=o.nodeSize;if(o!=l){if(!o.sameMarkup(l))return{a:r,b:i};if(o.isText&&o.text!=l.text){let t=0,e=Math.min(o.text.length,l.text.length);for(;t<e&&o.text[o.text.length-t-1]==l.text[l.text.length-t-1];)t++,r--,i--;return{a:r,b:i}}if(o.content.size||l.content.size){let t=X(o.content,l.content,r-1,i-1);if(t)return t}r-=u,i-=u}else r-=u,i-=u}}W[U]=W["[object Array]"]=W["[object ArrayBuffer]"]=W["[object DataView]"]=W["[object Boolean]"]=W["[object Date]"]=W["[object Float32Array]"]=W["[object Float64Array]"]=W["[object Int8Array]"]=W["[object Int16Array]"]=W["[object Int32Array]"]=W["[object Map]"]=W["[object Number]"]=W[H]=W["[object RegExp]"]=W["[object Set]"]=W["[object String]"]=W["[object Symbol]"]=W["[object Uint8Array]"]=W["[object Uint8ClampedArray]"]=W["[object Uint16Array]"]=W["[object Uint32Array]"]=!0,W["[object Error]"]=W[V]=W["[object WeakMap]"]=!1,K.prototype={constructor:K,find:function(t){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===t)return e;return-1},get:function(t){var e=this.find(t);return-1==e?void 0:this.content[e+1]},update:function(t,e,r){var i=r&&r!=t?this.remove(r):this,n=i.find(t),s=i.content.slice();return-1==n?s.push(r||t,e):(s[n+1]=e,r&&(s[n]=r)),new K(s)},remove:function(t){var e=this.find(t);if(-1==e)return this;var r=this.content.slice();return r.splice(e,2),new K(r)},addToStart:function(t,e){return new K([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var r=this.remove(t).content.slice();return r.push(t,e),new K(r)},addBefore:function(t,e,r){var i=this.remove(e),n=i.content.slice(),s=i.find(t);return n.splice(-1==s?n.length:s,0,e,r),new K(n)},forEach:function(t){for(var e=0;e<this.content.length;e+=2)t(this.content[e],this.content[e+1])},prepend:function(t){return(t=K.from(t)).size?new K(t.content.concat(this.subtract(t).content)):this},append:function(t){return(t=K.from(t)).size?new K(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=K.from(t);for(var r=0;r<t.content.length;r+=2)e=e.remove(t.content[r]);return e},toObject:function(){var t={};return this.forEach((function(e,r){t[e]=r})),t},get size(){return this.content.length>>1}},K.from=function(t){if(t instanceof K)return t;var e=[];if(t)for(var r in t)e.push(r,t[r]);return new K(e)};class Q{constructor(t,e){if(this.content=t,this.size=e||0,null==e)for(let e=0;e<t.length;e++)this.size+=t[e].nodeSize}nodesBetween(t,e,r,i=0,n){for(let s=0,o=0;o<e;s++){let l=this.content[s],u=o+l.nodeSize;if(u>t&&!1!==r(l,i+o,n||null,s)&&l.content.size){let n=o+1;l.nodesBetween(Math.max(0,t-n),Math.min(l.content.size,e-n),r,i+n)}o=u}}descendants(t){this.nodesBetween(0,this.size,t)}textBetween(t,e,r,i){let n="",s=!0;return this.nodesBetween(t,e,((o,l)=>{let u=o.isText?o.text.slice(Math.max(t,l)-l,e-l):o.isLeaf?i?"function"==typeof i?i(o):i:o.type.spec.leafText?o.type.spec.leafText(o):"":"";o.isBlock&&(o.isLeaf&&u||o.isTextblock)&&r&&(s?s=!1:n+=r),n+=u}),0),n}append(t){if(!t.size)return this;if(!this.size)return t;let e=this.lastChild,r=t.firstChild,i=this.content.slice(),n=0;for(e.isText&&e.sameMarkup(r)&&(i[i.length-1]=e.withText(e.text+r.text),n=1);n<t.content.length;n++)i.push(t.content[n]);return new Q(i,this.size+t.size)}cut(t,e=this.size){if(0==t&&e==this.size)return this;let r=[],i=0;if(e>t)for(let n=0,s=0;s<e;n++){let o=this.content[n],l=s+o.nodeSize;l>t&&((s<t||l>e)&&(o=o.isText?o.cut(Math.max(0,t-s),Math.min(o.text.length,e-s)):o.cut(Math.max(0,t-s-1),Math.min(o.content.size,e-s-1))),r.push(o),i+=o.nodeSize),s=l}return new Q(r,i)}cutByIndex(t,e){return t==e?Q.empty:0==t&&e==this.content.length?this:new Q(this.content.slice(t,e))}replaceChild(t,e){let r=this.content[t];if(r==e)return this;let i=this.content.slice(),n=this.size+e.nodeSize-r.nodeSize;return i[t]=e,new Q(i,n)}addToStart(t){return new Q([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new Q(this.content.concat(t),this.size+t.nodeSize)}eq(t){if(this.content.length!=t.content.length)return!1;for(let e=0;e<this.content.length;e++)if(!this.content[e].eq(t.content[e]))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(t){let e=this.content[t];if(!e)throw new RangeError("Index "+t+" out of range for "+this);return e}maybeChild(t){return this.content[t]||null}forEach(t){for(let e=0,r=0;e<this.content.length;e++){let i=this.content[e];t(i,r,e),r+=i.nodeSize}}findDiffStart(t,e=0){return Y(this,t,e)}findDiffEnd(t,e=this.size,r=t.size){return X(this,t,e,r)}findIndex(t,e=-1){if(0==t)return et(0,t);if(t==this.size)return et(this.content.length,t);if(t>this.size||t<0)throw new RangeError(`Position ${t} outside of fragment (${this})`);for(let r=0,i=0;;r++){let n=i+this.child(r).nodeSize;if(n>=t)return n==t||e>0?et(r+1,n):et(r,i);i=n}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map((t=>t.toJSON())):null}static fromJSON(t,e){if(!e)return Q.empty;if(!Array.isArray(e))throw new RangeError("Invalid input for Fragment.fromJSON");return new Q(e.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return Q.empty;let e,r=0;for(let i=0;i<t.length;i++){let n=t[i];r+=n.nodeSize,i&&n.isText&&t[i-1].sameMarkup(n)?(e||(e=t.slice(0,i)),e[e.length-1]=n.withText(e[e.length-1].text+n.text)):e&&e.push(n)}return new Q(e||t,r)}static from(t){if(!t)return Q.empty;if(t instanceof Q)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new Q([t],t.nodeSize);throw new RangeError("Can not convert "+t+" to a Fragment"+(t.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}Q.empty=new Q([],0);const tt={index:0,offset:0};function et(t,e){return tt.index=t,tt.offset=e,tt}function rt(t,e){if(t===e)return!0;if(!t||"object"!=typeof t||!e||"object"!=typeof e)return!1;let r=Array.isArray(t);if(Array.isArray(e)!=r)return!1;if(r){if(t.length!=e.length)return!1;for(let r=0;r<t.length;r++)if(!rt(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!rt(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}class it{constructor(t,e){this.type=t,this.attrs=e}addToSet(t){let e,r=!1;for(let i=0;i<t.length;i++){let n=t[i];if(this.eq(n))return t;if(this.type.excludes(n.type))e||(e=t.slice(0,i));else{if(n.type.excludes(this.type))return t;!r&&n.type.rank>this.type.rank&&(e||(e=t.slice(0,i)),e.push(this),r=!0),e&&e.push(n)}}return e||(e=t.slice()),r||e.push(this),e}removeFromSet(t){for(let e=0;e<t.length;e++)if(this.eq(t[e]))return t.slice(0,e).concat(t.slice(e+1));return t}isInSet(t){for(let e=0;e<t.length;e++)if(this.eq(t[e]))return!0;return!1}eq(t){return this==t||this.type==t.type&&rt(this.attrs,t.attrs)}toJSON(){let t={type:this.type.name};for(let e in this.attrs){t.attrs=this.attrs;break}return t}static fromJSON(t,e){if(!e)throw new RangeError("Invalid input for Mark.fromJSON");let r=t.marks[e.type];if(!r)throw new RangeError(`There is no mark type ${e.type} in this schema`);let i=r.create(e.attrs);return r.checkAttrs(i.attrs),i}static sameSet(t,e){if(t==e)return!0;if(t.length!=e.length)return!1;for(let r=0;r<t.length;r++)if(!t[r].eq(e[r]))return!1;return!0}static setFrom(t){if(!t||Array.isArray(t)&&0==t.length)return it.none;if(t instanceof it)return[t];let e=t.slice();return e.sort(((t,e)=>t.type.rank-e.type.rank)),e}}it.none=[];class nt extends Error{}class st{constructor(t,e,r){this.content=t,this.openStart=e,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(t,e){let r=lt(this.content,t+this.openStart,e);return r&&new st(r,this.openStart,this.openEnd)}removeBetween(t,e){return new st(ot(this.content,t+this.openStart,e+this.openStart),this.openStart,this.openEnd)}eq(t){return this.content.eq(t.content)&&this.openStart==t.openStart&&this.openEnd==t.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let t={content:this.content.toJSON()};return this.openStart>0&&(t.openStart=this.openStart),this.openEnd>0&&(t.openEnd=this.openEnd),t}static fromJSON(t,e){if(!e)return st.empty;let r=e.openStart||0,i=e.openEnd||0;if("number"!=typeof r||"number"!=typeof i)throw new RangeError("Invalid input for Slice.fromJSON");return new st(Q.fromJSON(t,e.content),r,i)}static maxOpen(t,e=!0){let r=0,i=0;for(let i=t.firstChild;i&&!i.isLeaf&&(e||!i.type.spec.isolating);i=i.firstChild)r++;for(let r=t.lastChild;r&&!r.isLeaf&&(e||!r.type.spec.isolating);r=r.lastChild)i++;return new st(t,r,i)}}function ot(t,e,r){let{index:i,offset:n}=t.findIndex(e),s=t.maybeChild(i),{index:o,offset:l}=t.findIndex(r);if(n==e||s.isText){if(l!=r&&!t.child(o).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(r))}if(i!=o)throw new RangeError("Removing non-flat range");return t.replaceChild(i,s.copy(ot(s.content,e-n-1,r-n-1)))}function lt(t,e,r){let{index:i,offset:n}=t.findIndex(e),s=t.maybeChild(i);if(n==e||s.isText)return t.cut(0,e).append(r).append(t.cut(e));let o=lt(s.content,e-n-1,r);return o&&t.replaceChild(i,s.copy(o))}function ut(t,e,r){if(r.openStart>t.depth)throw new nt("Inserted content deeper than insertion position");if(t.depth-r.openStart!=e.depth-r.openEnd)throw new nt("Inconsistent open depths");return ht(t,e,r,0)}function ht(t,e,r,i){let n=t.index(i),s=t.node(i);if(n==e.index(i)&&i<t.depth-r.openStart){let o=ht(t,e,r,i+1);return s.copy(s.content.replaceChild(n,o))}if(r.content.size){if(r.openStart||r.openEnd||t.depth!=i||e.depth!=i){let{start:n,end:o}=function(t,e){let r=e.depth-t.openStart,i=e.node(r).copy(t.content);for(let t=r-1;t>=0;t--)i=e.node(t).copy(Q.from(i));return{start:i.resolveNoCache(t.openStart+r),end:i.resolveNoCache(i.content.size-t.openEnd-r)}}(r,t);return pt(s,mt(t,n,o,e,i))}{let i=t.parent,n=i.content;return pt(i,n.cut(0,t.parentOffset).append(r.content).append(n.cut(e.parentOffset)))}}return pt(s,gt(t,e,i))}function at(t,e){if(!e.type.compatibleContent(t.type))throw new nt("Cannot join "+e.type.name+" onto "+t.type.name)}function ft(t,e,r){let i=t.node(r);return at(i,e.node(r)),i}function ct(t,e){let r=e.length-1;r>=0&&t.isText&&t.sameMarkup(e[r])?e[r]=t.withText(e[r].text+t.text):e.push(t)}function dt(t,e,r,i){let n=(e||t).node(r),s=0,o=e?e.index(r):n.childCount;t&&(s=t.index(r),t.depth>r?s++:t.textOffset&&(ct(t.nodeAfter,i),s++));for(let t=s;t<o;t++)ct(n.child(t),i);e&&e.depth==r&&e.textOffset&&ct(e.nodeBefore,i)}function pt(t,e){return t.type.checkContent(e),t.copy(e)}function mt(t,e,r,i,n){let s=t.depth>n&&ft(t,e,n+1),o=i.depth>n&&ft(r,i,n+1),l=[];return dt(null,t,n,l),s&&o&&e.index(n)==r.index(n)?(at(s,o),ct(pt(s,mt(t,e,r,i,n+1)),l)):(s&&ct(pt(s,gt(t,e,n+1)),l),dt(e,r,n,l),o&&ct(pt(o,gt(r,i,n+1)),l)),dt(i,null,n,l),new Q(l)}function gt(t,e,r){let i=[];return dt(null,t,r,i),t.depth>r&&ct(pt(ft(t,e,r+1),gt(t,e,r+1)),i),dt(e,null,r,i),new Q(i)}st.empty=new st(Q.empty,0,0);class wt{constructor(t,e,r){this.pos=t,this.path=e,this.parentOffset=r,this.depth=e.length/3-1}resolveDepth(t){return null==t?this.depth:t<0?this.depth+t:t}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(t){return this.path[3*this.resolveDepth(t)]}index(t){return this.path[3*this.resolveDepth(t)+1]}indexAfter(t){return t=this.resolveDepth(t),this.index(t)+(t!=this.depth||this.textOffset?1:0)}start(t){return 0==(t=this.resolveDepth(t))?0:this.path[3*t-1]+1}end(t){return t=this.resolveDepth(t),this.start(t)+this.node(t).content.size}before(t){if(!(t=this.resolveDepth(t)))throw new RangeError("There is no position before the top-level node");return t==this.depth+1?this.pos:this.path[3*t-1]}after(t){if(!(t=this.resolveDepth(t)))throw new RangeError("There is no position after the top-level node");return t==this.depth+1?this.pos:this.path[3*t-1]+this.path[3*t].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let t=this.parent,e=this.index(this.depth);if(e==t.childCount)return null;let r=this.pos-this.path[this.path.length-1],i=t.child(e);return r?t.child(e).cut(r):i}get nodeBefore(){let t=this.index(this.depth),e=this.pos-this.path[this.path.length-1];return e?this.parent.child(t).cut(0,e):0==t?null:this.parent.child(t-1)}posAtIndex(t,e){e=this.resolveDepth(e);let r=this.path[3*e],i=0==e?0:this.path[3*e-1]+1;for(let e=0;e<t;e++)i+=r.child(e).nodeSize;return i}marks(){let t=this.parent,e=this.index();if(0==t.content.size)return it.none;if(this.textOffset)return t.child(e).marks;let r=t.maybeChild(e-1),i=t.maybeChild(e);if(!r){let t=r;r=i,i=t}let n=r.marks;for(var s=0;s<n.length;s++)!1!==n[s].type.spec.inclusive||i&&n[s].isInSet(i.marks)||(n=n[s--].removeFromSet(n));return n}marksAcross(t){let e=this.parent.maybeChild(this.index());if(!e||!e.isInline)return null;let r=e.marks,i=t.parent.maybeChild(t.index());for(var n=0;n<r.length;n++)!1!==r[n].type.spec.inclusive||i&&r[n].isInSet(i.marks)||(r=r[n--].removeFromSet(r));return r}sharedDepth(t){for(let e=this.depth;e>0;e--)if(this.start(e)<=t&&this.end(e)>=t)return e;return 0}blockRange(t=this,e){if(t.pos<this.pos)return t.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==t.pos?1:0);r>=0;r--)if(t.pos<=this.end(r)&&(!e||e(this.node(r))))return new Dt(this,t,r);return null}sameParent(t){return this.pos-this.parentOffset==t.pos-t.parentOffset}max(t){return t.pos>this.pos?t:this}min(t){return t.pos<this.pos?t:this}toString(){let t="";for(let e=1;e<=this.depth;e++)t+=(t?"/":"")+this.node(e).type.name+"_"+this.index(e-1);return t+":"+this.parentOffset}static resolve(t,e){if(!(e>=0&&e<=t.content.size))throw new RangeError("Position "+e+" out of range");let r=[],i=0,n=e;for(let e=t;;){let{index:t,offset:s}=e.content.findIndex(n),o=n-s;if(r.push(e,t,i+s),!o)break;if(e=e.child(t),e.isText)break;n=o-1,i+=s+1}return new wt(e,r,n)}static resolveCached(t,e){let r=kt.get(t);if(r)for(let t=0;t<r.elts.length;t++){let i=r.elts[t];if(i.pos==e)return i}else kt.set(t,r=new bt);let i=r.elts[r.i]=wt.resolve(t,e);return r.i=(r.i+1)%vt,i}}class bt{constructor(){this.elts=[],this.i=0}}const vt=12,kt=new WeakMap;class Dt{constructor(t,e,r){this.$from=t,this.$to=e,this.depth=r}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 yt=Object.create(null);class Et{constructor(t,e,r,i=it.none){this.type=t,this.attrs=e,this.marks=i,this.content=r||Q.empty}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(t){return this.content.child(t)}maybeChild(t){return this.content.maybeChild(t)}forEach(t){this.content.forEach(t)}nodesBetween(t,e,r,i=0){this.content.nodesBetween(t,e,r,i,this)}descendants(t){this.nodesBetween(0,this.content.size,t)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(t,e,r,i){return this.content.textBetween(t,e,r,i)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(t){return this==t||this.sameMarkup(t)&&this.content.eq(t.content)}sameMarkup(t){return this.hasMarkup(t.type,t.attrs,t.marks)}hasMarkup(t,e,r){return this.type==t&&rt(this.attrs,e||t.defaultAttrs||yt)&&it.sameSet(this.marks,r||it.none)}copy(t=null){return t==this.content?this:new Et(this.type,this.attrs,t,this.marks)}mark(t){return t==this.marks?this:new Et(this.type,this.attrs,this.content,t)}cut(t,e=this.content.size){return 0==t&&e==this.content.size?this:this.copy(this.content.cut(t,e))}slice(t,e=this.content.size,r=!1){if(t==e)return st.empty;let i=this.resolve(t),n=this.resolve(e),s=r?0:i.sharedDepth(e),o=i.start(s),l=i.node(s).content.cut(i.pos-o,n.pos-o);return new st(l,i.depth-s,n.depth-s)}replace(t,e,r){return ut(this.resolve(t),this.resolve(e),r)}nodeAt(t){for(let e=this;;){let{index:r,offset:i}=e.content.findIndex(t);if(e=e.maybeChild(r),!e)return null;if(i==t||e.isText)return e;t-=i+1}}childAfter(t){let{index:e,offset:r}=this.content.findIndex(t);return{node:this.content.maybeChild(e),index:e,offset:r}}childBefore(t){if(0==t)return{node:null,index:0,offset:0};let{index:e,offset:r}=this.content.findIndex(t);if(r<t)return{node:this.content.child(e),index:e,offset:r};let i=this.content.child(e-1);return{node:i,index:e-1,offset:r-i.nodeSize}}resolve(t){return wt.resolveCached(this,t)}resolveNoCache(t){return wt.resolve(this,t)}rangeHasMark(t,e,r){let i=!1;return e>t&&this.nodesBetween(t,e,(t=>(r.isInSet(t.marks)&&(i=!0),!i))),i}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 t=this.type.name;return this.content.size&&(t+="("+this.content.toStringInner()+")"),Ft(this.marks,t)}contentMatchAt(t){let e=this.type.contentMatch.matchFragment(this.content,0,t);if(!e)throw new Error("Called contentMatchAt on a node with invalid content");return e}canReplace(t,e,r=Q.empty,i=0,n=r.childCount){let s=this.contentMatchAt(t).matchFragment(r,i,n),o=s&&s.matchFragment(this.content,e);if(!o||!o.validEnd)return!1;for(let t=i;t<n;t++)if(!this.type.allowsMarks(r.child(t).marks))return!1;return!0}canReplaceWith(t,e,r,i){if(i&&!this.type.allowsMarks(i))return!1;let n=this.contentMatchAt(t).matchType(r),s=n&&n.matchFragment(this.content,e);return!!s&&s.validEnd}canAppend(t){return t.content.size?this.canReplace(this.childCount,this.childCount,t.content):this.type.compatibleContent(t.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let t=it.none;for(let e=0;e<this.marks.length;e++){let r=this.marks[e];r.type.checkAttrs(r.attrs),t=r.addToSet(t)}if(!it.sameSet(t,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map((t=>t.type.name))}`);this.content.forEach((t=>t.check()))}toJSON(){let t={type:this.type.name};for(let e in this.attrs){t.attrs=this.attrs;break}return this.content.size&&(t.content=this.content.toJSON()),this.marks.length&&(t.marks=this.marks.map((t=>t.toJSON()))),t}static fromJSON(t,e){if(!e)throw new RangeError("Invalid input for Node.fromJSON");let r;if(e.marks){if(!Array.isArray(e.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=e.marks.map(t.markFromJSON)}if("text"==e.type){if("string"!=typeof e.text)throw new RangeError("Invalid text node in JSON");return t.text(e.text,r)}let i=Q.fromJSON(t,e.content),n=t.nodeType(e.type).create(e.attrs,i,r);return n.type.checkAttrs(n.attrs),n}}Et.prototype.text=void 0;class xt extends Et{constructor(t,e,r,i){if(super(t,e,null,i),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Ft(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(t,e){return this.text.slice(t,e)}get nodeSize(){return this.text.length}mark(t){return t==this.marks?this:new xt(this.type,this.attrs,this.text,t)}withText(t){return t==this.text?this:new xt(this.type,this.attrs,t,this.marks)}cut(t=0,e=this.text.length){return 0==t&&e==this.text.length?this:this.withText(this.text.slice(t,e))}eq(t){return this.sameMarkup(t)&&this.text==t.text}toJSON(){let t=super.toJSON();return t.text=this.text,t}}function Ft(t,e){for(let r=t.length-1;r>=0;r--)e=t[r].type.name+"("+e+")";return e}class Mt{constructor(t){this.validEnd=t,this.next=[],this.wrapCache=[]}static parse(t,e){let r=new At(t,e);if(null==r.next)return Mt.empty;let i=Ct(r);r.next&&r.err("Unexpected trailing text");let n=function(t){let e=Object.create(null);return function r(i){let n=[];i.forEach((e=>{t[e].forEach((({term:e,to:r})=>{if(!e)return;let i;for(let t=0;t<n.length;t++)n[t][0]==e&&(i=n[t][1]);Nt(t,r).forEach((t=>{i||n.push([e,i=[]]),-1==i.indexOf(t)&&i.push(t)}))}))}));let s=e[i.join(",")]=new Mt(i.indexOf(t.length-1)>-1);for(let t=0;t<n.length;t++){let i=n[t][1].sort(Rt);s.next.push({type:n[t][0],next:e[i.join(",")]||r(i)})}return s}(Nt(t,0))}(function(t){let e=[[]];return n(function t(e,s){if("choice"==e.type)return e.exprs.reduce(((e,r)=>e.concat(t(r,s))),[]);if("seq"!=e.type){if("star"==e.type){let o=r();return i(s,o),n(t(e.expr,o),o),[i(o)]}if("plus"==e.type){let o=r();return n(t(e.expr,s),o),n(t(e.expr,o),o),[i(o)]}if("opt"==e.type)return[i(s)].concat(t(e.expr,s));if("range"==e.type){let o=s;for(let i=0;i<e.min;i++){let i=r();n(t(e.expr,o),i),o=i}if(-1==e.max)n(t(e.expr,o),o);else for(let s=e.min;s<e.max;s++){let s=r();i(o,s),n(t(e.expr,o),s),o=s}return[i(o)]}if("name"==e.type)return[i(s,void 0,e.value)];throw new Error("Unknown expr type")}for(let i=0;;i++){let o=t(e.exprs[i],s);if(i==e.exprs.length-1)return o;n(o,s=r())}}(t,0),r()),e;function r(){return e.push([])-1}function i(t,r,i){let n={term:i,to:r};return e[t].push(n),n}function n(t,e){t.forEach((t=>t.to=e))}}(i));return function(t,e){for(let r=0,i=[t];r<i.length;r++){let t=i[r],n=!t.validEnd,s=[];for(let e=0;e<t.next.length;e++){let{type:r,next:o}=t.next[e];s.push(r.name),!n||r.isText||r.hasRequiredAttrs()||(n=!1),-1==i.indexOf(o)&&i.push(o)}n&&e.err("Only non-generatable nodes ("+s.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}(n,r),n}matchType(t){for(let e=0;e<this.next.length;e++)if(this.next[e].type==t)return this.next[e].next;return null}matchFragment(t,e=0,r=t.childCount){let i=this;for(let n=e;i&&n<r;n++)i=i.matchType(t.child(n).type);return i}get inlineContent(){return 0!=this.next.length&&this.next[0].type.isInline}get defaultType(){for(let t=0;t<this.next.length;t++){let{type:e}=this.next[t];if(!e.isText&&!e.hasRequiredAttrs())return e}return null}compatible(t){for(let e=0;e<this.next.length;e++)for(let r=0;r<t.next.length;r++)if(this.next[e].type==t.next[r].type)return!0;return!1}fillBefore(t,e=!1,r=0){let i=[this];return function n(s,o){let l=s.matchFragment(t,r);if(l&&(!e||l.validEnd))return Q.from(o.map((t=>t.createAndFill())));for(let t=0;t<s.next.length;t++){let{type:e,next:r}=s.next[t];if(!e.isText&&!e.hasRequiredAttrs()&&-1==i.indexOf(r)){i.push(r);let t=n(r,o.concat(e));if(t)return t}}return null}(this,[])}findWrapping(t){for(let e=0;e<this.wrapCache.length;e+=2)if(this.wrapCache[e]==t)return this.wrapCache[e+1];let e=this.computeWrapping(t);return this.wrapCache.push(t,e),e}computeWrapping(t){let e=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let i=r.shift(),n=i.match;if(n.matchType(t)){let t=[];for(let e=i;e.type;e=e.via)t.push(e.type);return t.reverse()}for(let t=0;t<n.next.length;t++){let{type:s,next:o}=n.next[t];s.isLeaf||s.hasRequiredAttrs()||s.name in e||i.type&&!o.validEnd||(r.push({match:s.contentMatch,type:s,via:i}),e[s.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(t){if(t>=this.next.length)throw new RangeError(`There's no ${t}th edge in this content match`);return this.next[t]}toString(){let t=[];return function e(r){t.push(r);for(let i=0;i<r.next.length;i++)-1==t.indexOf(r.next[i].next)&&e(r.next[i].next)}(this),t.map(((e,r)=>{let i=r+(e.validEnd?"*":" ")+" ";for(let r=0;r<e.next.length;r++)i+=(r?", ":"")+e.next[r].type.name+"->"+t.indexOf(e.next[r].next);return i})).join("\n")}}Mt.empty=new Mt(!0);class At{constructor(t,e){this.string=t,this.nodeTypes=e,this.inline=null,this.pos=0,this.tokens=t.split(/\s*(?=\b|\W|$)/),""==this.tokens[this.tokens.length-1]&&this.tokens.pop(),""==this.tokens[0]&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(t){return this.next==t&&(this.pos++||!0)}err(t){throw new SyntaxError(t+" (in content expression '"+this.string+"')")}}function Ct(t){let e=[];do{e.push(St(t))}while(t.eat("|"));return 1==e.length?e[0]:{type:"choice",exprs:e}}function St(t){let e=[];do{e.push(Ot(t))}while(t.next&&")"!=t.next&&"|"!=t.next);return 1==e.length?e[0]:{type:"seq",exprs:e}}function Ot(t){let e=function(t){if(t.eat("(")){let e=Ct(t);return t.eat(")")||t.err("Missing closing paren"),e}if(!/\W/.test(t.next)){let e=function(t,e){let r=t.nodeTypes,i=r[e];if(i)return[i];let n=[];for(let t in r){let i=r[t];i.groups.indexOf(e)>-1&&n.push(i)}return 0==n.length&&t.err("No node type or group '"+e+"' found"),n}(t,t.next).map((e=>(null==t.inline?t.inline=e.isInline:t.inline!=e.isInline&&t.err("Mixing inline and block content"),{type:"name",value:e})));return t.pos++,1==e.length?e[0]:{type:"choice",exprs:e}}t.err("Unexpected token '"+t.next+"'")}(t);for(;;)if(t.eat("+"))e={type:"plus",expr:e};else if(t.eat("*"))e={type:"star",expr:e};else if(t.eat("?"))e={type:"opt",expr:e};else{if(!t.eat("{"))break;e=Bt(t,e)}return e}function $t(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function Bt(t,e){let r=$t(t),i=r;return t.eat(",")&&(i="}"!=t.next?$t(t):-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:r,max:i,expr:e}}function Rt(t,e){return e-t}function Nt(t,e){let r=[];return function e(i){let n=t[i];if(1==n.length&&!n[0].term)return e(n[0].to);r.push(i);for(let t=0;t<n.length;t++){let{term:i,to:s}=n[t];i||-1!=r.indexOf(s)||e(s)}}(e),r.sort(Rt)}function _t(t){let e=Object.create(null);for(let r in t){let i=t[r];if(!i.hasDefault)return null;e[r]=i.default}return e}function Tt(t,e){let r=Object.create(null);for(let i in t){let n=e&&e[i];if(void 0===n){let e=t[i];if(!e.hasDefault)throw new RangeError("No value supplied for attribute "+i);n=e.default}r[i]=n}return r}function zt(t,e,r){for(let i in e)if(!(i in t))throw new RangeError(`Unsupported attribute ${i} for ${r} of type ${i}`);for(let r in t){let i=t[r];i.validate&&i.validate(e[r])}}function jt(t,e){let r=Object.create(null);if(e)for(let i in e)r[i]=new It(t,i,e[i]);return r}let qt=class t{constructor(t,e,r){this.name=t,this.schema=e,this.spec=r,this.markSet=null,this.groups=r.group?r.group.split(" "):[],this.attrs=jt(t,r.attrs),this.defaultAttrs=_t(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(r.inline||"text"==t),this.isText="text"==t}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==Mt.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let t in this.attrs)if(this.attrs[t].isRequired)return!0;return!1}compatibleContent(t){return this==t||this.contentMatch.compatible(t.contentMatch)}computeAttrs(t){return!t&&this.defaultAttrs?this.defaultAttrs:Tt(this.attrs,t)}create(t=null,e,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Et(this,this.computeAttrs(t),Q.from(e),it.setFrom(r))}createChecked(t=null,e,r){return e=Q.from(e),this.checkContent(e),new Et(this,this.computeAttrs(t),e,it.setFrom(r))}createAndFill(t=null,e,r){if(t=this.computeAttrs(t),(e=Q.from(e)).size){let t=this.contentMatch.fillBefore(e);if(!t)return null;e=t.append(e)}let i=this.contentMatch.matchFragment(e),n=i&&i.fillBefore(Q.empty,!0);return n?new Et(this,t,e.append(n),it.setFrom(r)):null}validContent(t){let e=this.contentMatch.matchFragment(t);if(!e||!e.validEnd)return!1;for(let e=0;e<t.childCount;e++)if(!this.allowsMarks(t.child(e).marks))return!1;return!0}checkContent(t){if(!this.validContent(t))throw new RangeError(`Invalid content for node ${this.name}: ${t.toString().slice(0,50)}`)}checkAttrs(t){zt(this.attrs,t,"node")}allowsMarkType(t){return null==this.markSet||this.markSet.indexOf(t)>-1}allowsMarks(t){if(null==this.markSet)return!0;for(let e=0;e<t.length;e++)if(!this.allowsMarkType(t[e].type))return!1;return!0}allowedMarks(t){if(null==this.markSet)return t;let e;for(let r=0;r<t.length;r++)this.allowsMarkType(t[r].type)?e&&e.push(t[r]):e||(e=t.slice(0,r));return e?e.length?e:it.none:t}static compile(e,r){let i=Object.create(null);e.forEach(((e,n)=>i[e]=new t(e,r,n)));let n=r.spec.topNode||"doc";if(!i[n])throw new RangeError("Schema is missing its top node type ('"+n+"')");if(!i.text)throw new RangeError("Every schema needs a 'text' type");for(let t in i.text.attrs)throw new RangeError("The text node type should not have attributes");return i}};class It{constructor(t,e,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate="string"==typeof r.validate?function(t,e,r){let i=r.split("|");return r=>{let n=null===r?"null":typeof r;if(i.indexOf(n)<0)throw new RangeError(`Expected value of type ${i} for attribute ${e} on type ${t}, got ${n}`)}}(t,e,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class Pt{constructor(t,e,r,i){this.name=t,this.rank=e,this.schema=r,this.spec=i,this.attrs=jt(t,i.attrs),this.excluded=null;let n=_t(this.attrs);this.instance=n?new it(this,n):null}create(t=null){return!t&&this.instance?this.instance:new it(this,Tt(this.attrs,t))}static compile(t,e){let r=Object.create(null),i=0;return t.forEach(((t,n)=>r[t]=new Pt(t,i++,e,n))),r}removeFromSet(t){for(var e=0;e<t.length;e++)t[e].type==this&&(t=t.slice(0,e).concat(t.slice(e+1)),e--);return t}isInSet(t){for(let e=0;e<t.length;e++)if(t[e].type==this)return t[e]}checkAttrs(t){zt(this.attrs,t,"mark")}excludes(t){return this.excluded.indexOf(t)>-1}}class Lt{constructor(t){this.linebreakReplacement=null,this.cached=Object.create(null);let e=this.spec={};for(let r in t)e[r]=t[r];e.nodes=K.from(t.nodes),e.marks=K.from(t.marks||{}),this.nodes=qt.compile(this.spec.nodes,this),this.marks=Pt.compile(this.spec.marks,this);let r=Object.create(null);for(let t in this.nodes){if(t in this.marks)throw new RangeError(t+" can not be both a node and a mark");let e=this.nodes[t],i=e.spec.content||"",n=e.spec.marks;if(e.contentMatch=r[i]||(r[i]=Mt.parse(i,this.nodes)),e.inlineContent=e.contentMatch.inlineContent,e.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!e.isInline||!e.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=e}e.markSet="_"==n?null:n?Jt(this,n.split(" ")):""!=n&&e.inlineContent?null:[]}for(let t in this.marks){let e=this.marks[t],r=e.spec.excludes;e.excluded=null==r?[e]:""==r?[]:Jt(this,r.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(t,e=null,r,i){if("string"==typeof t)t=this.nodeType(t);else{if(!(t instanceof qt))throw new RangeError("Invalid node type: "+t);if(t.schema!=this)throw new RangeError("Node type from different schema used ("+t.name+")")}return t.createChecked(e,r,i)}text(t,e){let r=this.nodes.text;return new xt(r,r.defaultAttrs,t,it.setFrom(e))}mark(t,e){return"string"==typeof t&&(t=this.marks[t]),t.create(e)}nodeFromJSON(t){return Et.fromJSON(this,t)}markFromJSON(t){return it.fromJSON(this,t)}nodeType(t){let e=this.nodes[t];if(!e)throw new RangeError("Unknown node type: "+t);return e}}function Jt(t,e){let r=[];for(let i=0;i<e.length;i++){let n=e[i],s=t.marks[n],o=s;if(s)r.push(s);else for(let e in t.marks){let i=t.marks[e];("_"==n||i.spec.group&&i.spec.group.split(" ").indexOf(n)>-1)&&r.push(o=i)}if(!o)throw new SyntaxError("Unknown mark type: '"+e[i]+"'")}return r}class Ut{constructor(t,e){this.schema=t,this.rules=e,this.tags=[],this.styles=[];let r=this.matchedStyles=[];e.forEach((t=>{if(function(t){return null!=t.tag}(t))this.tags.push(t);else if(function(t){return null!=t.style}(t)){let e=/[^=]*/.exec(t.style)[0];r.indexOf(e)<0&&r.push(e),this.styles.push(t)}})),this.normalizeLists=!this.tags.some((e=>{if(!/^(ul|ol)\b/.test(e.tag)||!e.node)return!1;let r=t.nodes[e.node];return r.contentMatch.matchType(r)}))}parse(t,e={}){let r=new Kt(this,e,!1);return r.addAll(t,it.none,e.from,e.to),r.finish()}parseSlice(t,e={}){let r=new Kt(this,e,!0);return r.addAll(t,it.none,e.from,e.to),st.maxOpen(r.finish())}matchTag(t,e,r){for(let i=r?this.tags.indexOf(r)+1:0;i<this.tags.length;i++){let r=this.tags[i];if(Yt(t,r.tag)&&(void 0===r.namespace||t.namespaceURI==r.namespace)&&(!r.context||e.matchesContext(r.context))){if(r.getAttrs){let e=r.getAttrs(t);if(!1===e)continue;r.attrs=e||void 0}return r}}}matchStyle(t,e,r,i){for(let n=i?this.styles.indexOf(i)+1:0;n<this.styles.length;n++){let i=this.styles[n],s=i.style;if(!(0!=s.indexOf(t)||i.context&&!r.matchesContext(i.context)||s.length>t.length&&(61!=s.charCodeAt(t.length)||s.slice(t.length+1)!=e))){if(i.getAttrs){let t=i.getAttrs(e);if(!1===t)continue;i.attrs=t||void 0}return i}}}static schemaRules(t){let e=[];function r(t){let r=null==t.priority?50:t.priority,i=0;for(;i<e.length;i++){let t=e[i];if((null==t.priority?50:t.priority)<r)break}e.splice(i,0,t)}for(let e in t.marks){let i=t.marks[e].spec.parseDOM;i&&i.forEach((t=>{r(t=Xt(t)),t.mark||t.ignore||t.clearMark||(t.mark=e)}))}for(let e in t.nodes){let i=t.nodes[e].spec.parseDOM;i&&i.forEach((t=>{r(t=Xt(t)),t.node||t.ignore||t.mark||(t.node=e)}))}return e}static fromSchema(t){return t.cached.domParser||(t.cached.domParser=new Ut(t,Ut.schemaRules(t)))}}const Vt={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},Ht={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Wt={ol:!0,ul:!0};function Gt(t,e,r){return null!=e?(e?1:0)|("full"===e?2:0):t&&"pre"==t.whitespace?3:-5&r}class Zt{constructor(t,e,r,i,n,s){this.type=t,this.attrs=e,this.marks=r,this.solid=i,this.options=s,this.content=[],this.activeMarks=it.none,this.match=n||(4&s?null:t.contentMatch)}findWrapping(t){if(!this.match){if(!this.type)return[];let e=this.type.contentMatch.fillBefore(Q.from(t));if(!e){let e,r=this.type.contentMatch;return(e=r.findWrapping(t.type))?(this.match=r,e):null}this.match=this.type.contentMatch.matchFragment(e)}return this.match.findWrapping(t.type)}finish(t){if(!(1&this.options)){let t,e=this.content[this.content.length-1];if(e&&e.isText&&(t=/[ \t\r\n\u000c]+$/.exec(e.text))){let r=e;e.text.length==t[0].length?this.content.pop():this.content[this.content.length-1]=r.withText(r.text.slice(0,r.text.length-t[0].length))}}let e=Q.from(this.content);return!t&&this.match&&(e=e.append(this.match.fillBefore(Q.empty,!0))),this.type?this.type.create(this.attrs,e,this.marks):e}inlineContext(t){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:t.parentNode&&!Vt.hasOwnProperty(t.parentNode.nodeName.toLowerCase())}}class Kt{constructor(t,e,r){this.parser=t,this.options=e,this.isOpen=r,this.open=0;let i,n=e.topNode,s=Gt(null,e.preserveWhitespace,0)|(r?4:0);i=n?new Zt(n.type,n.attrs,it.none,!0,e.topMatch||n.type.contentMatch,s):new Zt(r?null:t.schema.topNodeType,null,it.none,!0,null,s),this.nodes=[i],this.find=e.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(t,e){3==t.nodeType?this.addTextNode(t,e):1==t.nodeType&&this.addElement(t,e)}addTextNode(t,e){let r=t.nodeValue,i=this.top;if(2&i.options||i.inlineContext(t)||/[^ \t\r\n\u000c]/.test(r)){if(1&i.options)r=2&i.options?r.replace(/\r\n?/g,"\n"):r.replace(/\r?\n|\r/g," ");else if(r=r.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let e=i.content[i.content.length-1],n=t.previousSibling;(!e||n&&"BR"==n.nodeName||e.isText&&/[ \t\r\n\u000c]$/.test(e.text))&&(r=r.slice(1))}r&&this.insertNode(this.parser.schema.text(r),e),this.findInText(t)}else this.findInside(t)}addElement(t,e,r){let i,n=t.nodeName.toLowerCase();Wt.hasOwnProperty(n)&&this.parser.normalizeLists&&function(t){for(let e=t.firstChild,r=null;e;e=e.nextSibling){let t=1==e.nodeType?e.nodeName.toLowerCase():null;t&&Wt.hasOwnProperty(t)&&r?(r.appendChild(e),e=r):"li"==t?r=e:t&&(r=null)}}(t);let s=this.options.ruleFromNode&&this.options.ruleFromNode(t)||(i=this.parser.matchTag(t,this,r));if(s?s.ignore:Ht.hasOwnProperty(n))this.findInside(t),this.ignoreFallback(t,e);else if(!s||s.skip||s.closeParent){s&&s.closeParent?this.open=Math.max(0,this.open-1):s&&s.skip.nodeType&&(t=s.skip);let r,i=this.top,o=this.needsBlock;if(Vt.hasOwnProperty(n))i.content.length&&i.content[0].isInline&&this.open&&(this.open--,i=this.top),r=!0,i.type||(this.needsBlock=!0);else if(!t.firstChild)return void this.leafFallback(t,e);let l=s&&s.skip?e:this.readStyles(t,e);l&&this.addAll(t,l),r&&this.sync(i),this.needsBlock=o}else{let r=this.readStyles(t,e);r&&this.addElementByRule(t,s,r,!1===s.consuming?i:void 0)}}leafFallback(t,e){"BR"==t.nodeName&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(t.ownerDocument.createTextNode("\n"),e)}ignoreFallback(t,e){"BR"!=t.nodeName||this.top.type&&this.top.type.inlineContent||this.findPlace(this.parser.schema.text("-"),e)}readStyles(t,e){let r=t.style;if(r&&r.length)for(let t=0;t<this.parser.matchedStyles.length;t++){let i=this.parser.matchedStyles[t],n=r.getPropertyValue(i);if(n)for(let t;;){let r=this.parser.matchStyle(i,n,this,t);if(!r)break;if(r.ignore)return null;if(e=r.clearMark?e.filter((t=>!r.clearMark(t))):e.concat(this.parser.schema.marks[r.mark].create(r.attrs)),!1!==r.consuming)break;t=r}}return e}addElementByRule(t,e,r,i){let n,s;if(e.node)if(s=this.parser.schema.nodes[e.node],s.isLeaf)this.insertNode(s.create(e.attrs),r)||this.leafFallback(t,r);else{let t=this.enter(s,e.attrs||null,r,e.preserveWhitespace);t&&(n=!0,r=t)}else r=r.concat(this.parser.schema.marks[e.mark].create(e.attrs));let o=this.top;if(s&&s.isLeaf)this.findInside(t);else if(i)this.addElement(t,r,i);else if(e.getContent)this.findInside(t),e.getContent(t,this.parser.schema).forEach((t=>this.insertNode(t,r)));else{let i=t;"string"==typeof e.contentElement?i=t.querySelector(e.contentElement):"function"==typeof e.contentElement?i=e.contentElement(t):e.contentElement&&(i=e.contentElement),this.findAround(t,i,!0),this.addAll(i,r)}n&&this.sync(o)&&this.open--}addAll(t,e,r,i){let n=r||0;for(let s=r?t.childNodes[r]:t.firstChild,o=null==i?null:t.childNodes[i];s!=o;s=s.nextSibling,++n)this.findAtPoint(t,n),this.addDOM(s,e);this.findAtPoint(t,n)}findPlace(t,e){let r,i;for(let e=this.open;e>=0;e--){let n=this.nodes[e],s=n.findWrapping(t);if(s&&(!r||r.length>s.length)&&(r=s,i=n,!s.length))break;if(n.solid)break}if(!r)return null;this.sync(i);for(let t=0;t<r.length;t++)e=this.enterInner(r[t],null,e,!1);return e}insertNode(t,e){if(t.isInline&&this.needsBlock&&!this.top.type){let t=this.textblockFromContext();t&&(e=this.enterInner(t,null,e))}let r=this.findPlace(t,e);if(r){this.closeExtra();let e=this.top;e.match&&(e.match=e.match.matchType(t.type));let i=it.none;for(let n of r.concat(t.marks))(e.type?e.type.allowsMarkType(n.type):Qt(n.type,t.type))&&(i=n.addToSet(i));return e.content.push(t.mark(i)),!0}return!1}enter(t,e,r,i){let n=this.findPlace(t.create(e),r);return n&&(n=this.enterInner(t,e,r,!0,i)),n}enterInner(t,e,r,i=!1,n){this.closeExtra();let s=this.top;s.match=s.match&&s.match.matchType(t);let o=Gt(t,n,s.options);4&s.options&&0==s.content.length&&(o|=4);let l=it.none;return r=r.filter((e=>!(s.type?s.type.allowsMarkType(e.type):Qt(e.type,t))||(l=e.addToSet(l),!1))),this.nodes.push(new Zt(t,e,l,i,null,o)),this.open++,r}closeExtra(t=!1){let e=this.nodes.length-1;if(e>this.open){for(;e>this.open;e--)this.nodes[e-1].content.push(this.nodes[e].finish(t));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(this.isOpen||this.options.topOpen)}sync(t){for(let e=this.open;e>=0;e--)if(this.nodes[e]==t)return this.open=e,!0;return!1}get currentPos(){this.closeExtra();let t=0;for(let e=this.open;e>=0;e--){let r=this.nodes[e].content;for(let e=r.length-1;e>=0;e--)t+=r[e].nodeSize;e&&t++}return t}findAtPoint(t,e){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==t&&this.find[r].offset==e&&(this.find[r].pos=this.currentPos)}findInside(t){if(this.find)for(let e=0;e<this.find.length;e++)null==this.find[e].pos&&1==t.nodeType&&t.contains(this.find[e].node)&&(this.find[e].pos=this.currentPos)}findAround(t,e,r){if(t!=e&&this.find)for(let i=0;i<this.find.length;i++)null==this.find[i].pos&&1==t.nodeType&&t.contains(this.find[i].node)&&e.compareDocumentPosition(this.find[i].node)&(r?2:4)&&(this.find[i].pos=this.currentPos)}findInText(t){if(this.find)for(let e=0;e<this.find.length;e++)this.find[e].node==t&&(this.find[e].pos=this.currentPos-(t.nodeValue.length-this.find[e].offset))}matchesContext(t){if(t.indexOf("|")>-1)return t.split(/\s*\|\s*/).some(this.matchesContext,this);let e=t.split("/"),r=this.options.context,i=!(this.isOpen||r&&r.parent.type!=this.nodes[0].type),n=(i?0:1)-(r?r.depth+1:0),s=(t,o)=>{for(;t>=0;t--){let l=e[t];if(""==l){if(t==e.length-1||0==t)continue;for(;o>=n;o--)if(s(t-1,o))return!0;return!1}{let t=o>0||0==o&&i?this.nodes[o].type:r&&o>=n?r.node(o-n).type:null;if(!t||t.name!=l&&-1==t.groups.indexOf(l))return!1;o--}}return!0};return s(e.length-1,this.open)}textblockFromContext(){let t=this.options.context;if(t)for(let e=t.depth;e>=0;e--){let r=t.node(e).contentMatchAt(t.indexAfter(e)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let t in this.parser.schema.nodes){let e=this.parser.schema.nodes[t];if(e.isTextblock&&e.defaultAttrs)return e}}}function Yt(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function Xt(t){let e={};for(let r in t)e[r]=t[r];return e}function Qt(t,e){let r=e.schema.nodes;for(let i in r){let n=r[i];if(!n.allowsMarkType(t))continue;let s=[],o=t=>{s.push(t);for(let r=0;r<t.edgeCount;r++){let{type:i,next:n}=t.edge(r);if(i==e)return!0;if(s.indexOf(n)<0&&o(n))return!0}};if(o(n.contentMatch))return!0}}class te{constructor(t,e){this.nodes=t,this.marks=e}serializeFragment(t,e={},r){r||(r=re(e).createDocumentFragment());let i=r,n=[];return t.forEach((t=>{if(n.length||t.marks.length){let r=0,s=0;for(;r<n.length&&s<t.marks.length;){let e=t.marks[s];if(this.marks[e.type.name]){if(!e.eq(n[r][0])||!1===e.type.spec.spanning)break;r++,s++}else s++}for(;r<n.length;)i=n.pop()[1];for(;s<t.marks.length;){let r=t.marks[s++],o=this.serializeMark(r,t.isInline,e);o&&(n.push([r,i]),i.appendChild(o.dom),i=o.contentDOM||o.dom)}}i.appendChild(this.serializeNodeInner(t,e))})),r}serializeNodeInner(t,e){let{dom:r,contentDOM:i}=ne(re(e),this.nodes[t.type.name](t),null,t.attrs);if(i){if(t.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(t.content,e,i)}return r}serializeNode(t,e={}){let r=this.serializeNodeInner(t,e);for(let i=t.marks.length-1;i>=0;i--){let n=this.serializeMark(t.marks[i],t.isInline,e);n&&((n.contentDOM||n.dom).appendChild(r),r=n.dom)}return r}serializeMark(t,e,r={}){let i=this.marks[t.type.name];return i&&ne(re(r),i(t,e),null,t.attrs)}static renderSpec(t,e,r=null,i){return ne(t,e,r,i)}static fromSchema(t){return t.cached.domSerializer||(t.cached.domSerializer=new te(this.nodesFromSchema(t),this.marksFromSchema(t)))}static nodesFromSchema(t){let e=ee(t.nodes);return e.text||(e.text=t=>t.text),e}static marksFromSchema(t){return ee(t.marks)}}function ee(t){let e={};for(let r in t){let i=t[r].spec.toDOM;i&&(e[r]=i)}return e}function re(t){return t.document||window.document}const ie=new WeakMap;function ne(t,e,r,i){if("string"==typeof e)return{dom:t.createTextNode(e)};if(null!=e.nodeType)return{dom:e};if(e.dom&&null!=e.dom.nodeType)return e;let n,s=e[0];if("string"!=typeof s)throw new RangeError("Invalid array passed to renderSpec");if(i&&(n=function(t){let e=ie.get(t);return void 0===e&&ie.set(t,e=function(t){let e=null;return function t(r){if(r&&"object"==typeof r)if(Array.isArray(r))if("string"==typeof r[0])e||(e=[]),e.push(r);else for(let e=0;e<r.length;e++)t(r[e]);else for(let e in r)t(r[e])}(t),e}(t)),e}(i))&&n.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let o,l=s.indexOf(" ");l>0&&(r=s.slice(0,l),s=s.slice(l+1));let u=r?t.createElementNS(r,s):t.createElement(s),h=e[1],a=1;if(h&&"object"==typeof h&&null==h.nodeType&&!Array.isArray(h)){a=2;for(let t in h)if(null!=h[t]){let e=t.indexOf(" ");e>0?u.setAttributeNS(t.slice(0,e),t.slice(e+1),h[t]):u.setAttribute(t,h[t])}}for(let n=a;n<e.length;n++){let s=e[n];if(0===s){if(n<e.length-1||n>a)throw new RangeError("Content hole must be the only child of its parent node");return{dom:u,contentDOM:u}}{let{dom:e,contentDOM:n}=ne(t,s,r,i);if(u.appendChild(e),n){if(o)throw new RangeError("Multiple content holes");o=n}}}return{dom:u,contentDOM:o}}const se=Math.pow(2,16);function oe(t){return 65535&t}class le{constructor(t,e,r){this.pos=t,this.delInfo=e,this.recover=r}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 ue{constructor(t,e=!1){if(this.ranges=t,this.inverted=e,!t.length&&ue.empty)return ue.empty}recover(t){let e=0,r=oe(t);if(!this.inverted)for(let t=0;t<r;t++)e+=this.ranges[3*t+2]-this.ranges[3*t+1];return this.ranges[3*r]+e+function(t){return(t-(65535&t))/se}(t)}mapResult(t,e=1){return this._map(t,e,!1)}map(t,e=1){return this._map(t,e,!0)}_map(t,e,r){let i=0,n=this.inverted?2:1,s=this.inverted?1:2;for(let o=0;o<this.ranges.length;o+=3){let l=this.ranges[o]-(this.inverted?i:0);if(l>t)break;let u=this.ranges[o+n],h=this.ranges[o+s],a=l+u;if(t<=a){let n=l+i+((u?t==l?-1:t==a?1:e:e)<0?0:h);if(r)return n;let s=t==l?2:t==a?1:4;return(e<0?t!=l:t!=a)&&(s|=8),new le(n,s,t==(e<0?l:a)?null:o/3+(t-l)*se)}i+=h-u}return r?t+i:new le(t+i,0,null)}touches(t,e){let r=0,i=oe(e),n=this.inverted?2:1,s=this.inverted?1:2;for(let e=0;e<this.ranges.length;e+=3){let o=this.ranges[e]-(this.inverted?r:0);if(o>t)break;let l=this.