UNPKG

@limetech/lime-elements

Version:
1 lines • 407 kB
import{r as t,c as e,h as i,H as r,g as n}from"./p-288f0842.js";import{g as s,d as l,m as o,s as u}from"./p-f2206d1b.js";import{k as f,g as h,U as a,a as c,i as d}from"./p-394c3702.js";import{a as p}from"./p-0c9cb62b.js";import{b as m}from"./p-8008edb7.js";import{k as w,a as g,g as b}from"./p-9c246850.js";import{i as k,r as v,S as D}from"./p-c93050d6.js";import{d as y,g as F,e as x,n as E,a as M}from"./p-6f46165b.js";import{g as A}from"./p-6deb5fef.js";import{i as C}from"./p-0b1af919.js";import{i as O}from"./p-858c6b82.js";import{t as S}from"./p-4c88e5d3.js";import{c as $}from"./p-ad52787a.js";import{i as _}from"./p-fc998171.js";import{c as B}from"./p-b8c91b22.js";import{i as z}from"./p-0cc45207.js";import{d as j}from"./p-18c97232.js";import"./p-4e9b4087.js";import"./p-4f8562ee.js";import"./p-9bdd72e2.js";import"./p-23071d2f.js";import"./p-87a34aa6.js";import"./p-504ee819.js";import"./p-88b3ee98.js";import"./p-89524e09.js";import"./p-d251f404.js";import"./p-365098fe.js";import"./p-d529bb7d.js";var R=Object.create;var N=function(){function t(){}return function(e){if(!k(e)){return{}}if(R){return R(e)}t.prototype=e;var i=new t;t.prototype=undefined;return i}}();function q(t,e){var i=-1,r=t.length;e||(e=Array(r));while(++i<r){e[i]=t[i]}return e}function T(t,e){var i=-1,r=t==null?0:t.length;while(++i<r){if(e(t[i],i,t)===false){break}}return t}function I(t,e,i,r){var n=!i;i||(i={});var s=-1,l=e.length;while(++s<l){var o=e[s];var u=r?r(i[o],t[o],o,i,t):undefined;if(u===undefined){u=t[o]}if(n){m(i,o,u)}else{p(i,o,u)}}return i}function P(t,e){return t&&I(e,f(e),t)}function J(t,e){return t&&I(e,w(e),t)}var L=typeof exports=="object"&&exports&&!exports.nodeType&&exports;var W=L&&typeof module=="object"&&module&&!module.nodeType&&module;var U=W&&W.exports===L;var H=U?v.Buffer:undefined,Z=H?H.allocUnsafe:undefined;function K(t,e){if(e){return t.slice()}var i=t.length,r=Z?Z(i):new t.constructor(i);t.copy(r);return r}function V(t,e){return I(t,h(t),e)}function G(t,e){return I(t,g(t),e)}var X=Object.prototype;var Y=X.hasOwnProperty;function Q(t){var e=t.length,i=new t.constructor(e);if(e&&typeof t[0]=="string"&&Y.call(t,"index")){i.index=t.index;i.input=t.input}return i}function tt(t){var e=new t.constructor(t.byteLength);new a(e).set(new a(t));return e}function et(t,e){var i=e?tt(t.buffer):t.buffer;return new t.constructor(i,t.byteOffset,t.byteLength)}var it=/\w*$/;function rt(t){var e=new t.constructor(t.source,it.exec(t));e.lastIndex=t.lastIndex;return e}var nt=D?D.prototype:undefined,st=nt?nt.valueOf:undefined;function lt(t){return st?Object(st.call(t)):{}}function ot(t,e){var i=e?tt(t.buffer):t.buffer;return new t.constructor(i,t.byteOffset,t.length)}var ut="[object Boolean]",ft="[object Date]",ht="[object Map]",at="[object Number]",ct="[object RegExp]",dt="[object Set]",pt="[object String]",mt="[object Symbol]";var wt="[object ArrayBuffer]",gt="[object DataView]",bt="[object Float32Array]",kt="[object Float64Array]",vt="[object Int8Array]",Dt="[object Int16Array]",yt="[object Int32Array]",Ft="[object Uint8Array]",xt="[object Uint8ClampedArray]",Et="[object Uint16Array]",Mt="[object Uint32Array]";function At(t,e,i){var r=t.constructor;switch(e){case wt:return tt(t);case ut:case ft:return new r(+t);case gt:return et(t,i);case bt:case kt:case vt:case Dt:case yt:case Ft:case xt:case Et:case Mt:return ot(t,i);case ht:return new r;case at:case pt:return new r(t);case ct:return rt(t);case dt:return new r;case mt:return lt(t)}}function Ct(t){return typeof t.constructor=="function"&&!y(t)?N(A(t)):{}}var Ot="[object Map]";function St(t){return O(t)&&F(t)==Ot}var $t=E&&E.isMap;var _t=$t?x($t):St;var Bt="[object Set]";function zt(t){return O(t)&&F(t)==Bt}var jt=E&&E.isSet;var Rt=jt?x(jt):zt;var Nt=1,qt=2,Tt=4;var It="[object Arguments]",Pt="[object Array]",Jt="[object Boolean]",Lt="[object Date]",Wt="[object Error]",Ut="[object Function]",Ht="[object GeneratorFunction]",Zt="[object Map]",Kt="[object Number]",Vt="[object Object]",Gt="[object RegExp]",Xt="[object Set]",Yt="[object String]",Qt="[object Symbol]",te="[object WeakMap]";var ee="[object ArrayBuffer]",ie="[object DataView]",re="[object Float32Array]",ne="[object Float64Array]",se="[object Int8Array]",le="[object Int16Array]",oe="[object Int32Array]",ue="[object Uint8Array]",fe="[object Uint8ClampedArray]",he="[object Uint16Array]",ae="[object Uint32Array]";var ce={};ce[It]=ce[Pt]=ce[ee]=ce[ie]=ce[Jt]=ce[Lt]=ce[re]=ce[ne]=ce[se]=ce[le]=ce[oe]=ce[Zt]=ce[Kt]=ce[Vt]=ce[Gt]=ce[Xt]=ce[Yt]=ce[Qt]=ce[ue]=ce[fe]=ce[he]=ce[ae]=true;ce[Wt]=ce[Ut]=ce[te]=false;function de(t,e,i,r,n,s){var l,o=e&Nt,u=e&qt,h=e&Tt;if(i){l=n?i(t,r,n,s):i(t)}if(l!==undefined){return l}if(!k(t)){return t}var a=C(t);if(a){l=Q(t);if(!o){return q(t,l)}}else{var m=F(t),g=m==Ut||m==Ht;if(M(t)){return K(t,o)}if(m==Vt||m==It||g&&!n){l=u||g?{}:Ct(t);if(!o){return u?G(t,J(l,t)):V(t,P(l,t))}}else{if(!ce[m]){return n?t:{}}l=At(t,m,o)}}s||(s=new c);var v=s.get(t);if(v){return v}s.set(t,l);if(Rt(t)){t.forEach((function(r){l.add(de(r,e,i,r,t,s))}))}else if(_t(t)){t.forEach((function(r,n){l.set(n,de(r,e,i,n,t,s))}))}var D=h?u?b:d:u?w:f;var y=a?undefined:D(t);T(y||t,(function(r,n){if(y){n=r;r=t[n]}p(l,n,de(r,e,i,n,t,s))}));return l}var pe=1,me=4;function we(t){return de(t,pe|me)}function ge(t){this.content=t}ge.prototype={constructor:ge,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 e==-1?undefined:this.content[e+1]},update:function(t,e,i){var r=i&&i!=t?this.remove(i):this;var n=r.find(t),s=r.content.slice();if(n==-1){s.push(i||t,e)}else{s[n+1]=e;if(i)s[n]=i}return new ge(s)},remove:function(t){var e=this.find(t);if(e==-1)return this;var i=this.content.slice();i.splice(e,2);return new ge(i)},addToStart:function(t,e){return new ge([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var i=this.remove(t).content.slice();i.push(t,e);return new ge(i)},addBefore:function(t,e,i){var r=this.remove(e),n=r.content.slice();var s=r.find(t);n.splice(s==-1?n.length:s,0,e,i);return new ge(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){t=ge.from(t);if(!t.size)return this;return new ge(t.content.concat(this.subtract(t).content))},append:function(t){t=ge.from(t);if(!t.size)return this;return new ge(this.subtract(t).content.concat(t.content))},subtract:function(t){var e=this;t=ge.from(t);for(var i=0;i<t.content.length;i+=2)e=e.remove(t.content[i]);return e},toObject:function(){var t={};this.forEach((function(e,i){t[e]=i}));return t},get size(){return this.content.length>>1}};ge.from=function(t){if(t instanceof ge)return t;var e=[];if(t)for(var i in t)e.push(i,t[i]);return new ge(e)};function be(t,e,i){for(let r=0;;r++){if(r==t.childCount||r==e.childCount)return t.childCount==e.childCount?null:i;let n=t.child(r),s=e.child(r);if(n==s){i+=n.nodeSize;continue}if(!n.sameMarkup(s))return i;if(n.isText&&n.text!=s.text){for(let t=0;n.text[t]==s.text[t];t++)i++;return i}if(n.content.size||s.content.size){let t=be(n.content,s.content,i+1);if(t!=null)return t}i+=n.nodeSize}}function ke(t,e,i,r){for(let n=t.childCount,s=e.childCount;;){if(n==0||s==0)return n==s?null:{a:i,b:r};let l=t.child(--n),o=e.child(--s),u=l.nodeSize;if(l==o){i-=u;r-=u;continue}if(!l.sameMarkup(o))return{a:i,b:r};if(l.isText&&l.text!=o.text){let t=0,e=Math.min(l.text.length,o.text.length);while(t<e&&l.text[l.text.length-t-1]==o.text[o.text.length-t-1]){t++;i--;r--}return{a:i,b:r}}if(l.content.size||o.content.size){let t=ke(l.content,o.content,i-1,r-1);if(t)return t}i-=u;r-=u}}class ve{constructor(t,e){this.content=t;this.size=e||0;if(e==null)for(let e=0;e<t.length;e++)this.size+=t[e].nodeSize}nodesBetween(t,e,i,r=0,n){for(let s=0,l=0;l<e;s++){let o=this.content[s],u=l+o.nodeSize;if(u>t&&i(o,r+l,n||null,s)!==false&&o.content.size){let n=l+1;o.nodesBetween(Math.max(0,t-n),Math.min(o.content.size,e-n),i,r+n)}l=u}}descendants(t){this.nodesBetween(0,this.size,t)}textBetween(t,e,i,r){let n="",s=true;this.nodesBetween(t,e,((l,o)=>{let u=l.isText?l.text.slice(Math.max(t,o)-o,e-o):!l.isLeaf?"":r?typeof r==="function"?r(l):r:l.type.spec.leafText?l.type.spec.leafText(l):"";if(l.isBlock&&(l.isLeaf&&u||l.isTextblock)&&i){if(s)s=false;else n+=i}n+=u}),0);return n}append(t){if(!t.size)return this;if(!this.size)return t;let e=this.lastChild,i=t.firstChild,r=this.content.slice(),n=0;if(e.isText&&e.sameMarkup(i)){r[r.length-1]=e.withText(e.text+i.text);n=1}for(;n<t.content.length;n++)r.push(t.content[n]);return new ve(r,this.size+t.size)}cut(t,e=this.size){if(t==0&&e==this.size)return this;let i=[],r=0;if(e>t)for(let n=0,s=0;s<e;n++){let l=this.content[n],o=s+l.nodeSize;if(o>t){if(s<t||o>e){if(l.isText)l=l.cut(Math.max(0,t-s),Math.min(l.text.length,e-s));else l=l.cut(Math.max(0,t-s-1),Math.min(l.content.size,e-s-1))}i.push(l);r+=l.nodeSize}s=o}return new ve(i,r)}cutByIndex(t,e){if(t==e)return ve.empty;if(t==0&&e==this.content.length)return this;return new ve(this.content.slice(t,e))}replaceChild(t,e){let i=this.content[t];if(i==e)return this;let r=this.content.slice();let n=this.size+e.nodeSize-i.nodeSize;r[t]=e;return new ve(r,n)}addToStart(t){return new ve([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new ve(this.content.concat(t),this.size+t.nodeSize)}eq(t){if(this.content.length!=t.content.length)return false;for(let e=0;e<this.content.length;e++)if(!this.content[e].eq(t.content[e]))return false;return true}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,i=0;e<this.content.length;e++){let r=this.content[e];t(r,i,e);i+=r.nodeSize}}findDiffStart(t,e=0){return be(this,t,e)}findDiffEnd(t,e=this.size,i=t.size){return ke(this,t,e,i)}findIndex(t,e=-1){if(t==0)return ye(0,t);if(t==this.size)return ye(this.content.length,t);if(t>this.size||t<0)throw new RangeError(`Position ${t} outside of fragment (${this})`);for(let i=0,r=0;;i++){let n=this.child(i),s=r+n.nodeSize;if(s>=t){if(s==t||e>0)return ye(i+1,s);return ye(i,r)}r=s}}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 ve.empty;if(!Array.isArray(e))throw new RangeError("Invalid input for Fragment.fromJSON");return new ve(e.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return ve.empty;let e,i=0;for(let r=0;r<t.length;r++){let n=t[r];i+=n.nodeSize;if(r&&n.isText&&t[r-1].sameMarkup(n)){if(!e)e=t.slice(0,r);e[e.length-1]=n.withText(e[e.length-1].text+n.text)}else if(e){e.push(n)}}return new ve(e||t,i)}static from(t){if(!t)return ve.empty;if(t instanceof ve)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new ve([t],t.nodeSize);throw new RangeError("Can not convert "+t+" to a Fragment"+(t.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}ve.empty=new ve([],0);const De={index:0,offset:0};function ye(t,e){De.index=t;De.offset=e;return De}function Fe(t,e){if(t===e)return true;if(!(t&&typeof t=="object")||!(e&&typeof e=="object"))return false;let i=Array.isArray(t);if(Array.isArray(e)!=i)return false;if(i){if(t.length!=e.length)return false;for(let i=0;i<t.length;i++)if(!Fe(t[i],e[i]))return false}else{for(let i in t)if(!(i in e)||!Fe(t[i],e[i]))return false;for(let i in e)if(!(i in t))return false}return true}class xe{constructor(t,e){this.type=t;this.attrs=e}addToSet(t){let e,i=false;for(let r=0;r<t.length;r++){let n=t[r];if(this.eq(n))return t;if(this.type.excludes(n.type)){if(!e)e=t.slice(0,r)}else if(n.type.excludes(this.type)){return t}else{if(!i&&n.type.rank>this.type.rank){if(!e)e=t.slice(0,r);e.push(this);i=true}if(e)e.push(n)}}if(!e)e=t.slice();if(!i)e.push(this);return 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 true;return false}eq(t){return this==t||this.type==t.type&&Fe(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 i=t.marks[e.type];if(!i)throw new RangeError(`There is no mark type ${e.type} in this schema`);let r=i.create(e.attrs);i.checkAttrs(r.attrs);return r}static sameSet(t,e){if(t==e)return true;if(t.length!=e.length)return false;for(let i=0;i<t.length;i++)if(!t[i].eq(e[i]))return false;return true}static setFrom(t){if(!t||Array.isArray(t)&&t.length==0)return xe.none;if(t instanceof xe)return[t];let e=t.slice();e.sort(((t,e)=>t.type.rank-e.type.rank));return e}}xe.none=[];class Ee extends Error{}class Me{constructor(t,e,i){this.content=t;this.openStart=e;this.openEnd=i}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(t,e){let i=Ce(this.content,t+this.openStart,e);return i&&new Me(i,this.openStart,this.openEnd)}removeBetween(t,e){return new Me(Ae(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()};if(this.openStart>0)t.openStart=this.openStart;if(this.openEnd>0)t.openEnd=this.openEnd;return t}static fromJSON(t,e){if(!e)return Me.empty;let i=e.openStart||0,r=e.openEnd||0;if(typeof i!="number"||typeof r!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new Me(ve.fromJSON(t,e.content),i,r)}static maxOpen(t,e=true){let i=0,r=0;for(let r=t.firstChild;r&&!r.isLeaf&&(e||!r.type.spec.isolating);r=r.firstChild)i++;for(let i=t.lastChild;i&&!i.isLeaf&&(e||!i.type.spec.isolating);i=i.lastChild)r++;return new Me(t,i,r)}}Me.empty=new Me(ve.empty,0,0);function Ae(t,e,i){let{index:r,offset:n}=t.findIndex(e),s=t.maybeChild(r);let{index:l,offset:o}=t.findIndex(i);if(n==e||s.isText){if(o!=i&&!t.child(l).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(i))}if(r!=l)throw new RangeError("Removing non-flat range");return t.replaceChild(r,s.copy(Ae(s.content,e-n-1,i-n-1)))}function Ce(t,e,i,r){let{index:n,offset:s}=t.findIndex(e),l=t.maybeChild(n);if(s==e||l.isText){if(r&&!r.canReplace(n,n,i))return null;return t.cut(0,e).append(i).append(t.cut(e))}let o=Ce(l.content,e-s-1,i);return o&&t.replaceChild(n,l.copy(o))}function Oe(t,e,i){if(i.openStart>t.depth)throw new Ee("Inserted content deeper than insertion position");if(t.depth-i.openStart!=e.depth-i.openEnd)throw new Ee("Inconsistent open depths");return Se(t,e,i,0)}function Se(t,e,i,r){let n=t.index(r),s=t.node(r);if(n==e.index(r)&&r<t.depth-i.openStart){let l=Se(t,e,i,r+1);return s.copy(s.content.replaceChild(n,l))}else if(!i.content.size){return je(s,Ne(t,e,r))}else if(!i.openStart&&!i.openEnd&&t.depth==r&&e.depth==r){let r=t.parent,n=r.content;return je(r,n.cut(0,t.parentOffset).append(i.content).append(n.cut(e.parentOffset)))}else{let{start:n,end:l}=qe(i,t);return je(s,Re(t,n,l,e,r))}}function $e(t,e){if(!e.type.compatibleContent(t.type))throw new Ee("Cannot join "+e.type.name+" onto "+t.type.name)}function _e(t,e,i){let r=t.node(i);$e(r,e.node(i));return r}function Be(t,e){let i=e.length-1;if(i>=0&&t.isText&&t.sameMarkup(e[i]))e[i]=t.withText(e[i].text+t.text);else e.push(t)}function ze(t,e,i,r){let n=(e||t).node(i);let s=0,l=e?e.index(i):n.childCount;if(t){s=t.index(i);if(t.depth>i){s++}else if(t.textOffset){Be(t.nodeAfter,r);s++}}for(let t=s;t<l;t++)Be(n.child(t),r);if(e&&e.depth==i&&e.textOffset)Be(e.nodeBefore,r)}function je(t,e){t.type.checkContent(e);return t.copy(e)}function Re(t,e,i,r,n){let s=t.depth>n&&_e(t,e,n+1);let l=r.depth>n&&_e(i,r,n+1);let o=[];ze(null,t,n,o);if(s&&l&&e.index(n)==i.index(n)){$e(s,l);Be(je(s,Re(t,e,i,r,n+1)),o)}else{if(s)Be(je(s,Ne(t,e,n+1)),o);ze(e,i,n,o);if(l)Be(je(l,Ne(i,r,n+1)),o)}ze(r,null,n,o);return new ve(o)}function Ne(t,e,i){let r=[];ze(null,t,i,r);if(t.depth>i){let n=_e(t,e,i+1);Be(je(n,Ne(t,e,i+1)),r)}ze(e,null,i,r);return new ve(r)}function qe(t,e){let i=e.depth-t.openStart,r=e.node(i);let n=r.copy(t.content);for(let t=i-1;t>=0;t--)n=e.node(t).copy(ve.from(n));return{start:n.resolveNoCache(t.openStart+i),end:n.resolveNoCache(n.content.size-t.openEnd-i)}}class Te{constructor(t,e,i){this.pos=t;this.path=e;this.parentOffset=i;this.depth=e.length/3-1}resolveDepth(t){if(t==null)return this.depth;if(t<0)return this.depth+t;return t}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(t){return this.path[this.resolveDepth(t)*3]}index(t){return this.path[this.resolveDepth(t)*3+1]}indexAfter(t){t=this.resolveDepth(t);return this.index(t)+(t==this.depth&&!this.textOffset?0:1)}start(t){t=this.resolveDepth(t);return t==0?0:this.path[t*3-1]+1}end(t){t=this.resolveDepth(t);return this.start(t)+this.node(t).content.size}before(t){t=this.resolveDepth(t);if(!t)throw new RangeError("There is no position before the top-level node");return t==this.depth+1?this.pos:this.path[t*3-1]}after(t){t=this.resolveDepth(t);if(!t)throw new RangeError("There is no position after the top-level node");return t==this.depth+1?this.pos:this.path[t*3-1]+this.path[t*3].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 i=this.pos-this.path[this.path.length-1],r=t.child(e);return i?t.child(e).cut(i):r}get nodeBefore(){let t=this.index(this.depth);let e=this.pos-this.path[this.path.length-1];if(e)return this.parent.child(t).cut(0,e);return t==0?null:this.parent.child(t-1)}posAtIndex(t,e){e=this.resolveDepth(e);let i=this.path[e*3],r=e==0?0:this.path[e*3-1]+1;for(let e=0;e<t;e++)r+=i.child(e).nodeSize;return r}marks(){let t=this.parent,e=this.index();if(t.content.size==0)return xe.none;if(this.textOffset)return t.child(e).marks;let i=t.maybeChild(e-1),r=t.maybeChild(e);if(!i){let t=i;i=r;r=t}let n=i.marks;for(var s=0;s<n.length;s++)if(n[s].type.spec.inclusive===false&&(!r||!n[s].isInSet(r.marks)))n=n[s--].removeFromSet(n);return n}marksAcross(t){let e=this.parent.maybeChild(this.index());if(!e||!e.isInline)return null;let i=e.marks,r=t.parent.maybeChild(t.index());for(var n=0;n<i.length;n++)if(i[n].type.spec.inclusive===false&&(!r||!i[n].isInSet(r.marks)))i=i[n--].removeFromSet(i);return i}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 i=this.depth-(this.parent.inlineContent||this.pos==t.pos?1:0);i>=0;i--)if(t.pos<=this.end(i)&&(!e||e(this.node(i))))return new Le(this,t,i);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 i=[];let r=0,n=e;for(let e=t;;){let{index:t,offset:s}=e.content.findIndex(n);let l=n-s;i.push(e,t,r+s);if(!l)break;e=e.child(t);if(e.isText)break;n=l-1;r+=s+1}return new Te(e,i,n)}static resolveCached(t,e){let i=Je.get(t);if(i){for(let t=0;t<i.elts.length;t++){let r=i.elts[t];if(r.pos==e)return r}}else{Je.set(t,i=new Ie)}let r=i.elts[i.i]=Te.resolve(t,e);i.i=(i.i+1)%Pe;return r}}class Ie{constructor(){this.elts=[];this.i=0}}const Pe=12,Je=new WeakMap;class Le{constructor(t,e,i){this.$from=t;this.$to=e;this.depth=i}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 We=Object.create(null);class Ue{constructor(t,e,i,r=xe.none){this.type=t;this.attrs=e;this.marks=r;this.content=i||ve.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,i,r=0){this.content.nodesBetween(t,e,i,r,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,i,r){return this.content.textBetween(t,e,i,r)}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,i){return this.type==t&&Fe(this.attrs,e||t.defaultAttrs||We)&&xe.sameSet(this.marks,i||xe.none)}copy(t=null){if(t==this.content)return this;return new Ue(this.type,this.attrs,t,this.marks)}mark(t){return t==this.marks?this:new Ue(this.type,this.attrs,this.content,t)}cut(t,e=this.content.size){if(t==0&&e==this.content.size)return this;return this.copy(this.content.cut(t,e))}slice(t,e=this.content.size,i=false){if(t==e)return Me.empty;let r=this.resolve(t),n=this.resolve(e);let s=i?0:r.sharedDepth(e);let l=r.start(s),o=r.node(s);let u=o.content.cut(r.pos-l,n.pos-l);return new Me(u,r.depth-s,n.depth-s)}replace(t,e,i){return Oe(this.resolve(t),this.resolve(e),i)}nodeAt(t){for(let e=this;;){let{index:i,offset:r}=e.content.findIndex(t);e=e.maybeChild(i);if(!e)return null;if(r==t||e.isText)return e;t-=r+1}}childAfter(t){let{index:e,offset:i}=this.content.findIndex(t);return{node:this.content.maybeChild(e),index:e,offset:i}}childBefore(t){if(t==0)return{node:null,index:0,offset:0};let{index:e,offset:i}=this.content.findIndex(t);if(i<t)return{node:this.content.child(e),index:e,offset:i};let r=this.content.child(e-1);return{node:r,index:e-1,offset:i-r.nodeSize}}resolve(t){return Te.resolveCached(this,t)}resolveNoCache(t){return Te.resolve(this,t)}rangeHasMark(t,e,i){let r=false;if(e>t)this.nodesBetween(t,e,(t=>{if(i.isInSet(t.marks))r=true;return!r}));return 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 t=this.type.name;if(this.content.size)t+="("+this.content.toStringInner()+")";return Ze(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,i=ve.empty,r=0,n=i.childCount){let s=this.contentMatchAt(t).matchFragment(i,r,n);let l=s&&s.matchFragment(this.content,e);if(!l||!l.validEnd)return false;for(let t=r;t<n;t++)if(!this.type.allowsMarks(i.child(t).marks))return false;return true}canReplaceWith(t,e,i,r){if(r&&!this.type.allowsMarks(r))return false;let n=this.contentMatchAt(t).matchType(i);let s=n&&n.matchFragment(this.content,e);return s?s.validEnd:false}canAppend(t){if(t.content.size)return this.canReplace(this.childCount,this.childCount,t.content);else return this.type.compatibleContent(t.type)}check(){this.type.checkContent(this.content);this.type.checkAttrs(this.attrs);let t=xe.none;for(let e=0;e<this.marks.length;e++){let i=this.marks[e];i.type.checkAttrs(i.attrs);t=i.addToSet(t)}if(!xe.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}if(this.content.size)t.content=this.content.toJSON();if(this.marks.length)t.marks=this.marks.map((t=>t.toJSON()));return t}static fromJSON(t,e){if(!e)throw new RangeError("Invalid input for Node.fromJSON");let i=undefined;if(e.marks){if(!Array.isArray(e.marks))throw new RangeError("Invalid mark data for Node.fromJSON");i=e.marks.map(t.markFromJSON)}if(e.type=="text"){if(typeof e.text!="string")throw new RangeError("Invalid text node in JSON");return t.text(e.text,i)}let r=ve.fromJSON(t,e.content);let n=t.nodeType(e.type).create(e.attrs,r,i);n.type.checkAttrs(n.attrs);return n}}Ue.prototype.text=undefined;class He extends Ue{constructor(t,e,i,r){super(t,e,null,r);if(!i)throw new RangeError("Empty text nodes are not allowed");this.text=i}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);return Ze(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 He(this.type,this.attrs,this.text,t)}withText(t){if(t==this.text)return this;return new He(this.type,this.attrs,t,this.marks)}cut(t=0,e=this.text.length){if(t==0&&e==this.text.length)return this;return this.withText(this.text.slice(t,e))}eq(t){return this.sameMarkup(t)&&this.text==t.text}toJSON(){let t=super.toJSON();t.text=this.text;return t}}function Ze(t,e){for(let i=t.length-1;i>=0;i--)e=t[i].type.name+"("+e+")";return e}class Ke{constructor(t){this.validEnd=t;this.next=[];this.wrapCache=[]}static parse(t,e){let i=new Ve(t,e);if(i.next==null)return Ke.empty;let r=Ge(i);if(i.next)i.err("Unexpected trailing text");let n=li(ri(r));oi(n,i);return 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,i=t.childCount){let r=this;for(let n=e;r&&n<i;n++)r=r.matchType(t.child(n).type);return r}get inlineContent(){return this.next.length!=0&&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 i=0;i<t.next.length;i++)if(this.next[e].type==t.next[i].type)return true;return false}fillBefore(t,e=false,i=0){let r=[this];function n(s,l){let o=s.matchFragment(t,i);if(o&&(!e||o.validEnd))return ve.from(l.map((t=>t.createAndFill())));for(let t=0;t<s.next.length;t++){let{type:e,next:i}=s.next[t];if(!(e.isText||e.hasRequiredAttrs())&&r.indexOf(i)==-1){r.push(i);let t=n(i,l.concat(e));if(t)return t}}return null}return n(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);this.wrapCache.push(t,e);return e}computeWrapping(t){let e=Object.create(null),i=[{match:this,type:null,via:null}];while(i.length){let r=i.shift(),n=r.match;if(n.matchType(t)){let t=[];for(let e=r;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:l}=n.next[t];if(!s.isLeaf&&!s.hasRequiredAttrs()&&!(s.name in e)&&(!r.type||l.validEnd)){i.push({match:s.contentMatch,type:s,via:r});e[s.name]=true}}}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=[];function e(i){t.push(i);for(let r=0;r<i.next.length;r++)if(t.indexOf(i.next[r].next)==-1)e(i.next[r].next)}e(this);return t.map(((e,i)=>{let r=i+(e.validEnd?"*":" ")+" ";for(let i=0;i<e.next.length;i++)r+=(i?", ":"")+e.next[i].type.name+"->"+t.indexOf(e.next[i].next);return r})).join("\n")}}Ke.empty=new Ke(true);class Ve{constructor(t,e){this.string=t;this.nodeTypes=e;this.inline=null;this.pos=0;this.tokens=t.split(/\s*(?=\b|\W|$)/);if(this.tokens[this.tokens.length-1]=="")this.tokens.pop();if(this.tokens[0]=="")this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(t){return this.next==t&&(this.pos++||true)}err(t){throw new SyntaxError(t+" (in content expression '"+this.string+"')")}}function Ge(t){let e=[];do{e.push(Xe(t))}while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function Xe(t){let e=[];do{e.push(Ye(t))}while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function Ye(t){let e=ii(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("{"))e=ti(t,e);else break}return e}function Qe(t){if(/\D/.test(t.next))t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);t.pos++;return e}function ti(t,e){let i=Qe(t),r=i;if(t.eat(",")){if(t.next!="}")r=Qe(t);else r=-1}if(!t.eat("}"))t.err("Unclosed braced range");return{type:"range",min:i,max:r,expr:e}}function ei(t,e){let i=t.nodeTypes,r=i[e];if(r)return[r];let n=[];for(let t in i){let r=i[t];if(r.groups.indexOf(e)>-1)n.push(r)}if(n.length==0)t.err("No node type or group '"+e+"' found");return n}function ii(t){if(t.eat("(")){let e=Ge(t);if(!t.eat(")"))t.err("Missing closing paren");return e}else if(!/\W/.test(t.next)){let e=ei(t,t.next).map((e=>{if(t.inline==null)t.inline=e.isInline;else if(t.inline!=e.isInline)t.err("Mixing inline and block content");return{type:"name",value:e}}));t.pos++;return e.length==1?e[0]:{type:"choice",exprs:e}}else{t.err("Unexpected token '"+t.next+"'")}}function ri(t){let e=[[]];n(s(t,0),i());return e;function i(){return e.push([])-1}function r(t,i,r){let n={term:r,to:i};e[t].push(n);return n}function n(t,e){t.forEach((t=>t.to=e))}function s(t,e){if(t.type=="choice"){return t.exprs.reduce(((t,i)=>t.concat(s(i,e))),[])}else if(t.type=="seq"){for(let r=0;;r++){let l=s(t.exprs[r],e);if(r==t.exprs.length-1)return l;n(l,e=i())}}else if(t.type=="star"){let l=i();r(e,l);n(s(t.expr,l),l);return[r(l)]}else if(t.type=="plus"){let l=i();n(s(t.expr,e),l);n(s(t.expr,l),l);return[r(l)]}else if(t.type=="opt"){return[r(e)].concat(s(t.expr,e))}else if(t.type=="range"){let l=e;for(let e=0;e<t.min;e++){let e=i();n(s(t.expr,l),e);l=e}if(t.max==-1){n(s(t.expr,l),l)}else{for(let e=t.min;e<t.max;e++){let e=i();r(l,e);n(s(t.expr,l),e);l=e}}return[r(l)]}else if(t.type=="name"){return[r(e,undefined,t.value)]}else{throw new Error("Unknown expr type")}}}function ni(t,e){return e-t}function si(t,e){let i=[];r(e);return i.sort(ni);function r(e){let n=t[e];if(n.length==1&&!n[0].term)return r(n[0].to);i.push(e);for(let t=0;t<n.length;t++){let{term:e,to:s}=n[t];if(!e&&i.indexOf(s)==-1)r(s)}}}function li(t){let e=Object.create(null);return i(si(t,0));function i(r){let n=[];r.forEach((e=>{t[e].forEach((({term:e,to:i})=>{if(!e)return;let r;for(let t=0;t<n.length;t++)if(n[t][0]==e)r=n[t][1];si(t,i).forEach((t=>{if(!r)n.push([e,r=[]]);if(r.indexOf(t)==-1)r.push(t)}))}))}));let s=e[r.join(",")]=new Ke(r.indexOf(t.length-1)>-1);for(let t=0;t<n.length;t++){let r=n[t][1].sort(ni);s.next.push({type:n[t][0],next:e[r.join(",")]||i(r)})}return s}}function oi(t,e){for(let i=0,r=[t];i<r.length;i++){let t=r[i],n=!t.validEnd,s=[];for(let e=0;e<t.next.length;e++){let{type:i,next:l}=t.next[e];s.push(i.name);if(n&&!(i.isText||i.hasRequiredAttrs()))n=false;if(r.indexOf(l)==-1)r.push(l)}if(n)e.err("Only non-generatable nodes ("+s.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function ui(t){let e=Object.create(null);for(let i in t){let r=t[i];if(!r.hasDefault)return null;e[i]=r.default}return e}function fi(t,e){let i=Object.create(null);for(let r in t){let n=e&&e[r];if(n===undefined){let e=t[r];if(e.hasDefault)n=e.default;else throw new RangeError("No value supplied for attribute "+r)}i[r]=n}return i}function hi(t,e,i,r){for(let r in e)if(!(r in t))throw new RangeError(`Unsupported attribute ${r} for ${i} of type ${r}`);for(let i in t){let r=t[i];if(r.validate)r.validate(e[i])}}function ai(t,e){let i=Object.create(null);if(e)for(let r in e)i[r]=new pi(t,r,e[r]);return i}class ci{constructor(t,e,i){this.name=t;this.schema=e;this.spec=i;this.markSet=null;this.groups=i.group?i.group.split(" "):[];this.attrs=ai(t,i.attrs);this.defaultAttrs=ui(this.attrs);this.contentMatch=null;this.inlineContent=null;this.isBlock=!(i.inline||t=="text");this.isText=t=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==Ke.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 true;return false}compatibleContent(t){return this==t||this.contentMatch.compatible(t.contentMatch)}computeAttrs(t){if(!t&&this.defaultAttrs)return this.defaultAttrs;else return fi(this.attrs,t)}create(t=null,e,i){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Ue(this,this.computeAttrs(t),ve.from(e),xe.setFrom(i))}createChecked(t=null,e,i){e=ve.from(e);this.checkContent(e);return new Ue(this,this.computeAttrs(t),e,xe.setFrom(i))}createAndFill(t=null,e,i){t=this.computeAttrs(t);e=ve.from(e);if(e.size){let t=this.contentMatch.fillBefore(e);if(!t)return null;e=t.append(e)}let r=this.contentMatch.matchFragment(e);let n=r&&r.fillBefore(ve.empty,true);if(!n)return null;return new Ue(this,t,e.append(n),xe.setFrom(i))}validContent(t){let e=this.contentMatch.matchFragment(t);if(!e||!e.validEnd)return false;for(let e=0;e<t.childCount;e++)if(!this.allowsMarks(t.child(e).marks))return false;return true}checkContent(t){if(!this.validContent(t))throw new RangeError(`Invalid content for node ${this.name}: ${t.toString().slice(0,50)}`)}checkAttrs(t){hi(this.attrs,t,"node")}allowsMarkType(t){return this.markSet==null||this.markSet.indexOf(t)>-1}allowsMarks(t){if(this.markSet==null)return true;for(let e=0;e<t.length;e++)if(!this.allowsMarkType(t[e].type))return false;return true}allowedMarks(t){if(this.markSet==null)return t;let e;for(let i=0;i<t.length;i++){if(!this.allowsMarkType(t[i].type)){if(!e)e=t.slice(0,i)}else if(e){e.push(t[i])}}return!e?t:e.length?e:xe.none}static compile(t,e){let i=Object.create(null);t.forEach(((t,r)=>i[t]=new ci(t,e,r)));let r=e.spec.topNode||"doc";if(!i[r])throw new RangeError("Schema is missing its top node type ('"+r+"')");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}}function di(t,e,i){let r=i.split("|");return i=>{let n=i===null?"null":typeof i;if(r.indexOf(n)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${t}, got ${n}`)}}class pi{constructor(t,e,i){this.hasDefault=Object.prototype.hasOwnProperty.call(i,"default");this.default=i.default;this.validate=typeof i.validate=="string"?di(t,e,i.validate):i.validate}get isRequired(){return!this.hasDefault}}class mi{constructor(t,e,i,r){this.name=t;this.rank=e;this.schema=i;this.spec=r;this.attrs=ai(t,r.attrs);this.excluded=null;let n=ui(this.attrs);this.instance=n?new xe(this,n):null}create(t=null){if(!t&&this.instance)return this.instance;return new xe(this,fi(this.attrs,t))}static compile(t,e){let i=Object.create(null),r=0;t.forEach(((t,n)=>i[t]=new mi(t,r++,e,n)));return i}removeFromSet(t){for(var e=0;e<t.length;e++)if(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){hi(this.attrs,t,"mark")}excludes(t){return this.excluded.indexOf(t)>-1}}class wi{constructor(t){this.linebreakReplacement=null;this.cached=Object.create(null);let e=this.spec={};for(let i in t)e[i]=t[i];e.nodes=ge.from(t.nodes),e.marks=ge.from(t.marks||{}),this.nodes=ci.compile(this.spec.nodes,this);this.marks=mi.compile(this.spec.marks,this);let i=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],r=e.spec.content||"",n=e.spec.marks;e.contentMatch=i[r]||(i[r]=Ke.parse(r,this.nodes));e.inlineContent=e.contentMatch.inlineContent;if(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?gi(this,n.split(" ")):n==""||!e.inlineContent?[]:null}for(let t in this.marks){let e=this.marks[t],i=e.spec.excludes;e.excluded=i==null?[e]:i==""?[]:gi(this,i.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,i,r){if(typeof t=="string")t=this.nodeType(t);else if(!(t instanceof ci))throw new RangeError("Invalid node type: "+t);else if(t.schema!=this)throw new RangeError("Node type from different schema used ("+t.name+")");return t.createChecked(e,i,r)}text(t,e){let i=this.nodes.text;return new He(i,i.defaultAttrs,t,xe.setFrom(e))}mark(t,e){if(typeof t=="string")t=this.marks[t];return t.create(e)}nodeFromJSON(t){return Ue.fromJSON(this,t)}markFromJSON(t){return xe.fromJSON(this,t)}nodeType(t){let e=this.nodes[t];if(!e)throw new RangeError("Unknown node type: "+t);return e}}function gi(t,e){let i=[];for(let r=0;r<e.length;r++){let n=e[r],s=t.marks[n],l=s;if(s){i.push(s)}else{for(let e in t.marks){let r=t.marks[e];if(n=="_"||r.spec.group&&r.spec.group.split(" ").indexOf(n)>-1)i.push(l=r)}}if(!l)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return i}function bi(t){return t.tag!=null}function ki(t){return t.style!=null}class vi{constructor(t,e){this.schema=t;this.rules=e;this.tags=[];this.styles=[];let i=this.matchedStyles=[];e.forEach((t=>{if(bi(t)){this.tags.push(t)}else if(ki(t)){let e=/[^=]*/.exec(t.style)[0];if(i.indexOf(e)<0)i.push(e);this.styles.push(t)}}));this.normalizeLists=!this.tags.some((e=>{if(!/^(ul|ol)\b/.test(e.tag)||!e.node)return false;let i=t.nodes[e.node];return i.contentMatch.matchType(i)}))}parse(t,e={}){let i=new Oi(this,e,false);i.addAll(t,xe.none,e.from,e.to);return i.finish()}parseSlice(t,e={}){let i=new Oi(this,e,true);i.addAll(t,xe.none,e.from,e.to);return Me.maxOpen(i.finish())}matchTag(t,e,i){for(let r=i?this.tags.indexOf(i)+1:0;r<this.tags.length;r++){let i=this.tags[r];if($i(t,i.tag)&&(i.namespace===undefined||t.namespaceURI==i.namespace)&&(!i.context||e.matchesContext(i.context))){if(i.getAttrs){let e=i.getAttrs(t);if(e===false)continue;i.attrs=e||undefined}return i}}}matchStyle(t,e,i,r){for(let n=r?this.styles.indexOf(r)+1:0;n<this.styles.length;n++){let r=this.styles[n],s=r.style;if(s.indexOf(t)!=0||r.context&&!i.matchesContext(r.context)||s.length>t.length&&(s.charCodeAt(t.length)!=61||s.slice(t.length+1)!=e))continue;if(r.getAttrs){let t=r.getAttrs(e);if(t===false)continue;r.attrs=t||undefined}return r}}static schemaRules(t){let e=[];function i(t){let i=t.priority==null?50:t.priority,r=0;for(;r<e.length;r++){let t=e[r],n=t.priority==null?50:t.priority;if(n<i)break}e.splice(r,0,t)}for(let e in t.marks){let r=t.marks[e].spec.parseDOM;if(r)r.forEach((t=>{i(t=_i(t));if(!(t.mark||t.ignore||t.clearMark))t.mark=e}))}for(let e in t.nodes){let r=t.nodes[e].spec.parseDOM;if(r)r.forEach((t=>{i(t=_i(t));if(!(t.node||t.ignore||t.mark))t.node=e}))}return e}static fromSchema(t){return t.cached.domParser||(t.cached.domParser=new vi(t,vi.schemaRules(t)))}}const Di={address:true,article:true,aside:true,blockquote:true,canvas:true,dd:true,div:true,dl:true,fieldset:true,figcaption:true,figure:true,footer:true,form:true,h1:true,h2:true,h3:true,h4:true,h5:true,h6:true,header:true,hgroup:true,hr:true,li:true,noscript:true,ol:true,output:true,p:true,pre:true,section:true,table:true,tfoot:true,ul:true};const yi={head:true,noscript:true,object:true,script:true,style:true,title:true};const Fi={ol:true,ul:true};const xi=1,Ei=2,Mi=4;function Ai(t,e,i){if(e!=null)return(e?xi:0)|(e==="full"?Ei:0);return t&&t.whitespace=="pre"?xi|Ei:i&~Mi}class Ci{constructor(t,e,i,r,n,s){this.type=t;this.attrs=e;this.marks=i;this.solid=r;this.options=s;this.content=[];this.activeMarks=xe.none;this.match=n||(s&Mi?null:t.contentMatch)}findWrapping(t){if(!this.match){if(!this.type)return[];let e=this.type.contentMatch.fillBefore(ve.from(t));if(e){this.match=this.type.contentMatch.matchFragment(e)}else{let e=this.type.contentMatch,i;if(i=e.findWrapping(t.type)){this.match=e;return i}else{return null}}}return this.match.findWrapping(t.type)}finish(t){if(!(this.options&xi)){let t=this.content[this.content.length-1],e;if(t&&t.isText&&(e=/[ \t\r\n\u000c]+$/.exec(t.text))){let i=t;if(t.text.length==e[0].length)this.content.pop();else this.content[this.content.length-1]=i.withText(i.text.slice(0,i.text.length-e[0].length))}}let e=ve.from(this.content);if(!t&&this.match)e=e.append(this.match.fillBefore(ve.empty,true));return this.type?this.type.create(this.attrs,e,this.marks):e}inlineContext(t){if(this.type)return this.type.inlineContent;if(this.content.length)return this.content[0].isInline;return t.parentNode&&!Di.hasOwnProperty(t.parentNode.nodeName.toLowerCase())}}class Oi{constructor(t,e,i){this.parser=t;this.options=e;this.isOpen=i;this.open=0;let r=e.topNode,n;let s=Ai(null,e.preserveWhitespace,0)|(i?Mi:0);if(r)n=new Ci(r.type,r.attrs,xe.none,true,e.topMatch||r.type.contentMatch,s);else if(i)n=new Ci(null,null,xe.none,true,null,s);else n=new Ci(t.schema.topNodeType,null,xe.none,true,null,s);this.nodes=[n];this.find=e.findPositions;this.needsBlock=false}get top(){return this.nodes[this.open]}addDOM(t,e){if(t.nodeType==3)this.addTextNode(t,e);else if(t.nodeType==1)this.addElement(t,e)}addTextNode(t,e){let i=t.nodeValue;let r=this.top;if(r.options&Ei||r.inlineContext(t)||/[^ \t\r\n\u000c]/.test(i)){if(!(r.options&xi)){i=i.replace(/[ \t\r\n\u000c]+/g," ");if(/^[ \t\r\n\u000c]/.test(i)&&this.open==this.nodes.length-1){let e=r.content[r.content.length-1];let n=t.previousSibling;if(!e||n&&n.nodeName=="BR"||e.isText&&/[ \t\r\n\u000c]$/.test(e.text))i=i.slice(1)}}else if(!(r.options&Ei)){i=i.replace(/\r?\n|\r/g," ")}else{i=i.replace(/\r\n?/g,"\n")}if(i)this.insertNode(this.parser.schema.text(i),e);this.findInText(t)}else{this.findInside(t)}}addElement(t,e,i){let r=t.nodeName.toLowerCase(),n;if(Fi.hasOwnProperty(r)&&this.parser.normalizeLists)Si(t);let s=this.options.ruleFromNode&&this.options.ruleFromNode(t)||(n=this.parser.matchTag(t,this,i));if(s?s.ignore:yi.hasOwnProperty(r)){this.findInside(t);this.ignoreFallback(t,e)}else if(!s||s.skip||s.closeParent){if(s&&s.closeParent)this.open=Math.max(0,this.open-1);else if(s&&s.skip.nodeType)t=s.skip;let i,n=this.top,l=this.needsBlock;if(Di.hasOwnProperty(r)){if(n.content.length&&n.content[0].isInline&&this.open){this.open--;n=this.top}i=true;if(!n.type)this.needsBlock=true}else if(!t.firstChild){this.leafFallback(t,e);return}let o=s&&s.skip?e:this.readStyles(t,e);if(o)this.addAll(t,o);if(i)this.sync(n);this.needsBlock=l}else{let i=this.readStyles(t,e);if(i)this.addElementByRule(t,s,i,s.consuming===false?n:undefined)}}leafFallback(t,e){if(t.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent)this.addTextNode(t.ownerDocument.createTextNode("\n"),e)}ignoreFallback(t,e){if(t.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent))this.findPlace(this.parser.schema.text("-"),e)}readStyles(t,e){let i=t.style;if(i&&i.length)for(let t=0;t<this.parser.matchedStyles.length;t++){let r=this.parser.matchedStyles[t],n=i.getPropertyValue(r);if(n)for(let t=undefined;;){let i=this.parser.matchStyle(r,n,this,t);if(!i)break;if(i.ignore)return null;if(i.clearMark)e=e.filter((t=>!i.clearMark(t)));else e=e.concat(this.parser.schema.marks[i.mark].create(i.attrs));if(i.consuming===false)t=i;else break}}return e}addElementByRule(t,e,i,r){let n,s;if(e.node){s=this.parser.schema.nodes[e.node];if(!s.isLeaf){let t=this.enter(s,e.attrs||null,i,e.preserveWhitespace);if(t){n=true;i=t}}else if(!this.insertNode(s.create(e.attrs),i)){this.leafFallback(t,i)}}else{let t=this.parser.schema.marks[e.mark];i=i.concat(t.create(e.attrs))}let l=this.top;if(s&&s.isLeaf){this.findInside(t)}else if(r){this.addElement(t,i,r)}else if(e.getContent){this.findInside(t);e.getContent(t,this.parser.schema).forEach((t=>this.insertNode(t,i)))}else{let r=t;if(typeof e.contentElement=="string")r=t.querySelector(e.contentElement);else if(typeof e.contentElement=="function")r=e.contentElement(t);else if(e.contentElement)r=e.contentElement;this.findAround(t,r,true);this.addAll(r,i)}if(n&&this.sync(l))this.open--}addAll(t,e,i,r){let n=i||0;for(let s=i?t.childNodes[i]:t.firstChild,l=r==null?null:t.childNodes[r];s!=l;s=s.nextSibling,++n){this.findAtPoint(t,n);this.addDOM(s,e)}this.findAtPoint(t,n)}findPlace(t,e){let i,r;for(let e=this.open;e>=0;e--){let n=this.nodes[e];let s=n.findWrapping(t);if(s&&(!i||i.length>s.length)){i=s;r=n;if(!s.length)break}if(n.solid)break}if(!i)return null;this.sync(r);for(let t=0;t<i.length;t++)e=this.enterInner(i[t],null,e,false);return e}insertNode(t,e){if(t.isInline&&this.needsBlock&&!this.top.type){let t=this.textblockFromContext();if(t)e=this.enterInner(t,null,e)}let i=this.findPlace(t,e);if(i){this.closeExtra();let e=this.top;if(e.match)e.match=e.match.matchType(t.type);let r=xe.none;for(let n of i.concat(t.marks))if(e.type?e.type.allowsMarkType(n.type):Bi(n.type,t.type))r=n.addToSet(r);e.content.push(t.mark(r));return true}return false}enter(t,e,i,r){let n=this.findPlace(t.create(e),i);if(n)n=this.enterInner(t,e,i,true,r);return n}enterInner(t,e,i,r=false,n){this.closeExtra();let s=this.top;s.match=s.match&&s.match.matchType(t);let l=Ai(t,n,s.options);if(s.options&Mi&&s.content.length==0)l|=Mi;let o=xe.none;i=i.filter((e=>{if(s.type?s.type.allowsMarkType(e.type):Bi(e.type,t)){o=e.addToSet(o);return false}return true}));this.nodes.push(new Ci(t,e,o,r,null,l));this.open++;return i}closeExtra(t=false){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(){this.open=0;this.closeExtra(this.isOpen);return this.nodes[0].finish(this.isOpen||this.options.topOpen)}sync(t){for(let e=this.open;e>=0;e--)if(this.nodes[e]==t){this.open=e;return true}return false}get currentPos(){this.closeExtra();let t=0;for(let e=this.open;e>=0;e--){let i=this.nodes[e].content;for(let e=i.length-1;e>=0;e--)t+=i[e].nodeSize;if(e)t++}return t}findAtPoint(t,e){if(this.find)for(let i=0;i<this.find.length;i++){if(this.find[i].node==t&&this.find[i].offset==e)this.find[i].pos=this.currentPos}}findInside(t){if(this.find)for(let e=0;e<this.find.length;e++){if(this.find[e].pos==null&&t.nodeType==1&&t.contains(this.find[e].node))this.find[e].pos=this.currentPos}}findAround(t,e,i){if(t!=e&&this.find)for(let r=0;r<this.find.length;r++){if(this.find[r].pos==null&&t.nodeType==1&&t.contains(this.find[r].node)){let t=e.compareDocumentPosition(this.find[r].node);if(t&(i?2:4))this.find[r].pos=this.currentPos}}}findInText(t){if(this.find)for(let e=0;e<this.find.length;e++){if(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("/");let i=this.options.context;let r=!this.isOpen&&(!i||i.parent.type==this.nodes[0].type);let n=-(i?i.depth+1:0)+(r?0:1);let s=(t,l)=>{for(;t>=0;t--){let o=e[t];if(o==""){if(t==e.length-1||t==0)continue;for(;l>=n;l--)if(s(t-1,l))return true;return false}else{let t=l>0||l==0&&r?this.nodes[l].type:i&&l>=n?i.node(l-n).type:null;if(!t||t.name!=o&&t.groups.indexOf(o)==-1)return false;l--}}return true};return s(e.length-1,this.open)}textblockFromContext(){let t=this.options.context;if(t)for(let e=t.depth;e>=0;e--){let i=t.node(e).contentMatchAt(t.indexAfter(e)).defaultType;if(i&&i.isTextblock&&i.defaultAttrs)return i}for(let t in this.parser.schema.nodes){let e=this.parser.schema.nodes[t];if(e.isTextblock&&e.defaultAttrs)return e}}}function Si(t){for(let e=t.firstChild,i=null;e;e=e.nextSibling){let t=e.nodeType==1?e.nodeName.toLowerCase():null;if(t&&Fi.hasOwnProperty(t)&&i){i.appendChild(e);e=i}else if(t=="li"){i=e}else if(t){i=null}}}function $i(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function _i(t){let e={};for(let i in t)e[i]=t[i];return e}function Bi(t,e){let i=e.schema.nodes;for(let r in i){let n=i[r];if(!n.allowsMarkType(t))continue;let s=[],l=t=>{s.push(t);for(let i=0;i<t.edgeCount;i++){let{type:r,next:n}=t.edge(i);if(r==e)return true;if(s.indexOf(n)<0&&l(n))return true}};if(l(n.contentMatch))return true}}class zi{constructor(t,e){this.nodes=t;this.marks=e}serializeFragment(t,e={},i){if(!i)i=Ri(e).createDocumentFragment();let r=i,n=[];t.forEach((t=>{if(n.length||t.marks.length){let i=0,s=0;while(i<n.length&&s<t.marks.length){let e=t.marks[s];if(!this.marks[e.type.name]){s++;continue}if(!e.eq(n[i][0])||e.type.spec.spanning===false)break;i++;s++}while(i<n.length)r=n.pop()[1];while(s<t.marks.length){let i=t.marks[s++];let l=this.serializeMark(i,t.isInline,e);if(l){n.push([i,r]);r.appendChild(l.dom);r=l.contentDOM||l.dom}}}r.appendChild(this.serializeNodeInner(t,e))}));return i}serializeNodeInner(t,e){let{dom:i,contentDOM:r}=Ii(Ri(e),this.nodes[t.type.name](t),null,t.attrs);if(r){if(t.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(t.content,e,r)}return i}serializeNode(t,e={}){let i=this.serializeNodeInner(t,e);for(let r=t.marks.length-1;r>=0;r--){let n=this.serializeMark(t.marks[r],t.isInline,e);if(n){(n.contentDOM||n.dom).appendChild(i);i=n.dom}}return i}serializeMark(t,e,i={}){let r=this.marks[t.type.name];return r&&Ii(Ri(i),r(t,e),null,t.attrs)}static renderSp