@limetech/lime-elements 38.2.0 → 38.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/dist/cjs/limel-markdown.cjs.entry.js +1 -1
- package/dist/cjs/limel-markdown.cjs.entry.js.map +1 -1
- package/dist/cjs/limel-prosemirror-adapter.cjs.entry.js +1 -1
- package/dist/cjs/limel-prosemirror-adapter.cjs.entry.js.map +1 -1
- package/dist/collection/components/markdown/markdown.css +11 -0
- package/dist/collection/components/text-editor/prosemirror-adapter/prosemirror-adapter.css +11 -0
- package/dist/esm/limel-markdown.entry.js +1 -1
- package/dist/esm/limel-markdown.entry.js.map +1 -1
- package/dist/esm/limel-prosemirror-adapter.entry.js +1 -1
- package/dist/esm/limel-prosemirror-adapter.entry.js.map +1 -1
- package/dist/lime-elements/lime-elements.esm.js +1 -1
- package/dist/lime-elements/p-3ab8ab51.entry.js +2 -0
- package/dist/lime-elements/{p-261cc6f1.entry.js.map → p-3ab8ab51.entry.js.map} +1 -1
- package/dist/lime-elements/{p-fdfd3e5a.entry.js → p-e5545944.entry.js} +2 -2
- package/dist/lime-elements/{p-fdfd3e5a.entry.js.map → p-e5545944.entry.js.map} +1 -1
- package/package.json +1 -1
- package/dist/lime-elements/p-261cc6f1.entry.js +0 -2
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{r as t,c as e,h as r,H as i,g as n}from"./p-443111b3.js";import{k as s,g as l,U as o,a as u,i as f}from"./p-ea0310b8.js";import{a as h}from"./p-50bd0336.js";import{b as a}from"./p-5467ea06.js";import{k as c,a as d,g as p}from"./p-40df077c.js";import{i as m,r as w,S as g}from"./p-c93050d6.js";import{d as b,g as k,e as D,n as v,a as y}from"./p-28a23eac.js";import{g as F}from"./p-d4378e4c.js";import{i as E}from"./p-0b1af919.js";import{i as M}from"./p-858c6b82.js";import{d as x,m as A,s as C}from"./p-639f9320.js";import{t as S}from"./p-efd753ba.js";import{c as O}from"./p-96460db3.js";import{i as $}from"./p-91741e79.js";import{i as _}from"./p-cf019264.js";import{d as B}from"./p-18c97232.js";import"./p-eda23c05.js";import"./p-4c3358cb.js";import"./p-87a34aa6.js";import"./p-33375610.js";import"./p-5fdb83c9.js";import"./p-eab67c09.js";import"./p-365098fe.js";import"./p-d529bb7d.js";var R=Object.create;var j=function(){function t(){}return function(e){if(!m(e)){return{}}if(R){return R(e)}t.prototype=e;var r=new t;t.prototype=undefined;return r}}();function N(t,e){var r=-1,i=t.length;e||(e=Array(i));while(++r<i){e[r]=t[r]}return e}function q(t,e){var r=-1,i=t==null?0:t.length;while(++r<i){if(e(t[r],r,t)===false){break}}return t}function T(t,e,r,i){var n=!r;r||(r={});var s=-1,l=e.length;while(++s<l){var o=e[s];var u=i?i(r[o],t[o],o,r,t):undefined;if(u===undefined){u=t[o]}if(n){a(r,o,u)}else{h(r,o,u)}}return r}function z(t,e){return t&&T(e,s(e),t)}function I(t,e){return t&&T(e,c(e),t)}var P=typeof exports=="object"&&exports&&!exports.nodeType&&exports;var J=P&&typeof module=="object"&&module&&!module.nodeType&&module;var L=J&&J.exports===P;var W=L?w.Buffer:undefined,U=W?W.allocUnsafe:undefined;function H(t,e){if(e){return t.slice()}var r=t.length,i=U?U(r):new t.constructor(r);t.copy(i);return i}function Z(t,e){return T(t,l(t),e)}function K(t,e){return T(t,d(t),e)}var V=Object.prototype;var G=V.hasOwnProperty;function X(t){var e=t.length,r=new t.constructor(e);if(e&&typeof t[0]=="string"&&G.call(t,"index")){r.index=t.index;r.input=t.input}return r}function Y(t){var e=new t.constructor(t.byteLength);new o(e).set(new o(t));return e}function Q(t,e){var r=e?Y(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}var tt=/\w*$/;function et(t){var e=new t.constructor(t.source,tt.exec(t));e.lastIndex=t.lastIndex;return e}var rt=g?g.prototype:undefined,it=rt?rt.valueOf:undefined;function nt(t){return it?Object(it.call(t)):{}}function st(t,e){var r=e?Y(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}var lt="[object Boolean]",ot="[object Date]",ut="[object Map]",ft="[object Number]",ht="[object RegExp]",at="[object Set]",ct="[object String]",dt="[object Symbol]";var pt="[object ArrayBuffer]",mt="[object DataView]",wt="[object Float32Array]",gt="[object Float64Array]",bt="[object Int8Array]",kt="[object Int16Array]",Dt="[object Int32Array]",vt="[object Uint8Array]",yt="[object Uint8ClampedArray]",Ft="[object Uint16Array]",Et="[object Uint32Array]";function Mt(t,e,r){var i=t.constructor;switch(e){case pt:return Y(t);case lt:case ot:return new i(+t);case mt:return Q(t,r);case wt:case gt:case bt:case kt:case Dt:case vt:case yt:case Ft:case Et:return st(t,r);case ut:return new i;case ft:case ct:return new i(t);case ht:return et(t);case at:return new i;case dt:return nt(t)}}function xt(t){return typeof t.constructor=="function"&&!b(t)?j(F(t)):{}}var At="[object Map]";function Ct(t){return M(t)&&k(t)==At}var St=v&&v.isMap;var Ot=St?D(St):Ct;var $t="[object Set]";function _t(t){return M(t)&&k(t)==$t}var Bt=v&&v.isSet;var Rt=Bt?D(Bt):_t;var jt=1,Nt=2,qt=4;var Tt="[object Arguments]",zt="[object Array]",It="[object Boolean]",Pt="[object Date]",Jt="[object Error]",Lt="[object Function]",Wt="[object GeneratorFunction]",Ut="[object Map]",Ht="[object Number]",Zt="[object Object]",Kt="[object RegExp]",Vt="[object Set]",Gt="[object String]",Xt="[object Symbol]",Yt="[object WeakMap]";var Qt="[object ArrayBuffer]",te="[object DataView]",ee="[object Float32Array]",re="[object Float64Array]",ie="[object Int8Array]",ne="[object Int16Array]",se="[object Int32Array]",le="[object Uint8Array]",oe="[object Uint8ClampedArray]",ue="[object Uint16Array]",fe="[object Uint32Array]";var he={};he[Tt]=he[zt]=he[Qt]=he[te]=he[It]=he[Pt]=he[ee]=he[re]=he[ie]=he[ne]=he[se]=he[Ut]=he[Ht]=he[Zt]=he[Kt]=he[Vt]=he[Gt]=he[Xt]=he[le]=he[oe]=he[ue]=he[fe]=true;he[Jt]=he[Lt]=he[Yt]=false;function ae(t,e,r,i,n,l){var o,a=e&jt,d=e&Nt,w=e&qt;if(r){o=n?r(t,i,n,l):r(t)}if(o!==undefined){return o}if(!m(t)){return t}var g=E(t);if(g){o=X(t);if(!a){return N(t,o)}}else{var b=k(t),D=b==Lt||b==Wt;if(y(t)){return H(t,a)}if(b==Zt||b==Tt||D&&!n){o=d||D?{}:xt(t);if(!a){return d?K(t,I(o,t)):Z(t,z(o,t))}}else{if(!he[b]){return n?t:{}}o=Mt(t,b,a)}}l||(l=new u);var v=l.get(t);if(v){return v}l.set(t,o);if(Rt(t)){t.forEach((function(i){o.add(ae(i,e,r,i,t,l))}))}else if(Ot(t)){t.forEach((function(i,n){o.set(n,ae(i,e,r,n,t,l))}))}var F=w?d?p:f:d?c:s;var M=g?undefined:F(t);q(M||t,(function(i,n){if(M){n=i;i=t[n]}h(o,n,ae(i,e,r,n,t,l))}));return o}var ce=1,de=4;function pe(t){return ae(t,ce|de)}function me(t){this.content=t}me.prototype={constructor:me,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,r){var i=r&&r!=t?this.remove(r):this;var n=i.find(t),s=i.content.slice();if(n==-1){s.push(r||t,e)}else{s[n+1]=e;if(r)s[n]=r}return new me(s)},remove:function(t){var e=this.find(t);if(e==-1)return this;var r=this.content.slice();r.splice(e,2);return new me(r)},addToStart:function(t,e){return new me([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var r=this.remove(t).content.slice();r.push(t,e);return new me(r)},addBefore:function(t,e,r){var i=this.remove(e),n=i.content.slice();var s=i.find(t);n.splice(s==-1?n.length:s,0,e,r);return new me(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=me.from(t);if(!t.size)return this;return new me(t.content.concat(this.subtract(t).content))},append:function(t){t=me.from(t);if(!t.size)return this;return new me(this.subtract(t).content.concat(t.content))},subtract:function(t){var e=this;t=me.from(t);for(var r=0;r<t.content.length;r+=2)e=e.remove(t.content[r]);return e},toObject:function(){var t={};this.forEach((function(e,r){t[e]=r}));return t},get size(){return this.content.length>>1}};me.from=function(t){if(t instanceof me)return t;var e=[];if(t)for(var r in t)e.push(r,t[r]);return new me(e)};function we(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){r+=n.nodeSize;continue}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=we(n.content,s.content,r+1);if(t!=null)return t}r+=n.nodeSize}}function ge(t,e,r,i){for(let n=t.childCount,s=e.childCount;;){if(n==0||s==0)return n==s?null:{a:r,b:i};let l=t.child(--n),o=e.child(--s),u=l.nodeSize;if(l==o){r-=u;i-=u;continue}if(!l.sameMarkup(o))return{a:r,b:i};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++;r--;i--}return{a:r,b:i}}if(l.content.size||o.content.size){let t=ge(l.content,o.content,r-1,i-1);if(t)return t}r-=u;i-=u}}class be{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,r,i=0,n){for(let s=0,l=0;l<e;s++){let o=this.content[s],u=l+o.nodeSize;if(u>t&&r(o,i+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),r,i+n)}l=u}}descendants(t){this.nodesBetween(0,this.size,t)}textBetween(t,e,r,i){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?"":i?typeof i==="function"?i(l):i:l.type.spec.leafText?l.type.spec.leafText(l):"";if(l.isBlock&&(l.isLeaf&&u||l.isTextblock)&&r){if(s)s=false;else n+=r}n+=u}),0);return 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;if(e.isText&&e.sameMarkup(r)){i[i.length-1]=e.withText(e.text+r.text);n=1}for(;n<t.content.length;n++)i.push(t.content[n]);return new be(i,this.size+t.size)}cut(t,e=this.size){if(t==0&&e==this.size)return this;let r=[],i=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))}r.push(l);i+=l.nodeSize}s=o}return new be(r,i)}cutByIndex(t,e){if(t==e)return be.empty;if(t==0&&e==this.content.length)return this;return new be(this.content.slice(t,e))}replaceChild(t,e){let r=this.content[t];if(r==e)return this;let i=this.content.slice();let n=this.size+e.nodeSize-r.nodeSize;i[t]=e;return new be(i,n)}addToStart(t){return new be([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new be(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,r=0;e<this.content.length;e++){let i=this.content[e];t(i,r,e);r+=i.nodeSize}}findDiffStart(t,e=0){return we(this,t,e)}findDiffEnd(t,e=this.size,r=t.size){return ge(this,t,e,r)}findIndex(t,e=-1){if(t==0)return De(0,t);if(t==this.size)return De(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=this.child(r),s=i+n.nodeSize;if(s>=t){if(s==t||e>0)return De(r+1,s);return De(r,i)}i=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 be.empty;if(!Array.isArray(e))throw new RangeError("Invalid input for Fragment.fromJSON");return new be(e.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return be.empty;let e,r=0;for(let i=0;i<t.length;i++){let n=t[i];r+=n.nodeSize;if(i&&n.isText&&t[i-1].sameMarkup(n)){if(!e)e=t.slice(0,i);e[e.length-1]=n.withText(e[e.length-1].text+n.text)}else if(e){e.push(n)}}return new be(e||t,r)}static from(t){if(!t)return be.empty;if(t instanceof be)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new be([t],t.nodeSize);throw new RangeError("Can not convert "+t+" to a Fragment"+(t.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}be.empty=new be([],0);const ke={index:0,offset:0};function De(t,e){ke.index=t;ke.offset=e;return ke}function ve(t,e){if(t===e)return true;if(!(t&&typeof t=="object")||!(e&&typeof e=="object"))return false;let r=Array.isArray(t);if(Array.isArray(e)!=r)return false;if(r){if(t.length!=e.length)return false;for(let r=0;r<t.length;r++)if(!ve(t[r],e[r]))return false}else{for(let r in t)if(!(r in e)||!ve(t[r],e[r]))return false;for(let r in e)if(!(r in t))return false}return true}class ye{constructor(t,e){this.type=t;this.attrs=e}addToSet(t){let e,r=false;for(let i=0;i<t.length;i++){let n=t[i];if(this.eq(n))return t;if(this.type.excludes(n.type)){if(!e)e=t.slice(0,i)}else if(n.type.excludes(this.type)){return t}else{if(!r&&n.type.rank>this.type.rank){if(!e)e=t.slice(0,i);e.push(this);r=true}if(e)e.push(n)}}if(!e)e=t.slice();if(!r)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&&ve(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);r.checkAttrs(i.attrs);return i}static sameSet(t,e){if(t==e)return true;if(t.length!=e.length)return false;for(let r=0;r<t.length;r++)if(!t[r].eq(e[r]))return false;return true}static setFrom(t){if(!t||Array.isArray(t)&&t.length==0)return ye.none;if(t instanceof ye)return[t];let e=t.slice();e.sort(((t,e)=>t.type.rank-e.type.rank));return e}}ye.none=[];class Fe extends Error{}class Ee{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=xe(this.content,t+this.openStart,e);return r&&new Ee(r,this.openStart,this.openEnd)}removeBetween(t,e){return new Ee(Me(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 Ee.empty;let r=e.openStart||0,i=e.openEnd||0;if(typeof r!="number"||typeof i!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new Ee(be.fromJSON(t,e.content),r,i)}static maxOpen(t,e=true){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 Ee(t,r,i)}}Ee.empty=new Ee(be.empty,0,0);function Me(t,e,r){let{index:i,offset:n}=t.findIndex(e),s=t.maybeChild(i);let{index:l,offset:o}=t.findIndex(r);if(n==e||s.isText){if(o!=r&&!t.child(l).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(r))}if(i!=l)throw new RangeError("Removing non-flat range");return t.replaceChild(i,s.copy(Me(s.content,e-n-1,r-n-1)))}function xe(t,e,r,i){let{index:n,offset:s}=t.findIndex(e),l=t.maybeChild(n);if(s==e||l.isText){if(i&&!i.canReplace(n,n,r))return null;return t.cut(0,e).append(r).append(t.cut(e))}let o=xe(l.content,e-s-1,r);return o&&t.replaceChild(n,l.copy(o))}function Ae(t,e,r){if(r.openStart>t.depth)throw new Fe("Inserted content deeper than insertion position");if(t.depth-r.openStart!=e.depth-r.openEnd)throw new Fe("Inconsistent open depths");return Ce(t,e,r,0)}function Ce(t,e,r,i){let n=t.index(i),s=t.node(i);if(n==e.index(i)&&i<t.depth-r.openStart){let l=Ce(t,e,r,i+1);return s.copy(s.content.replaceChild(n,l))}else if(!r.content.size){return Be(s,je(t,e,i))}else if(!r.openStart&&!r.openEnd&&t.depth==i&&e.depth==i){let i=t.parent,n=i.content;return Be(i,n.cut(0,t.parentOffset).append(r.content).append(n.cut(e.parentOffset)))}else{let{start:n,end:l}=Ne(r,t);return Be(s,Re(t,n,l,e,i))}}function Se(t,e){if(!e.type.compatibleContent(t.type))throw new Fe("Cannot join "+e.type.name+" onto "+t.type.name)}function Oe(t,e,r){let i=t.node(r);Se(i,e.node(r));return i}function $e(t,e){let r=e.length-1;if(r>=0&&t.isText&&t.sameMarkup(e[r]))e[r]=t.withText(e[r].text+t.text);else e.push(t)}function _e(t,e,r,i){let n=(e||t).node(r);let s=0,l=e?e.index(r):n.childCount;if(t){s=t.index(r);if(t.depth>r){s++}else if(t.textOffset){$e(t.nodeAfter,i);s++}}for(let t=s;t<l;t++)$e(n.child(t),i);if(e&&e.depth==r&&e.textOffset)$e(e.nodeBefore,i)}function Be(t,e){t.type.checkContent(e);return t.copy(e)}function Re(t,e,r,i,n){let s=t.depth>n&&Oe(t,e,n+1);let l=i.depth>n&&Oe(r,i,n+1);let o=[];_e(null,t,n,o);if(s&&l&&e.index(n)==r.index(n)){Se(s,l);$e(Be(s,Re(t,e,r,i,n+1)),o)}else{if(s)$e(Be(s,je(t,e,n+1)),o);_e(e,r,n,o);if(l)$e(Be(l,je(r,i,n+1)),o)}_e(i,null,n,o);return new be(o)}function je(t,e,r){let i=[];_e(null,t,r,i);if(t.depth>r){let n=Oe(t,e,r+1);$e(Be(n,je(t,e,r+1)),i)}_e(e,null,r,i);return new be(i)}function Ne(t,e){let r=e.depth-t.openStart,i=e.node(r);let n=i.copy(t.content);for(let t=r-1;t>=0;t--)n=e.node(t).copy(be.from(n));return{start:n.resolveNoCache(t.openStart+r),end:n.resolveNoCache(n.content.size-t.openEnd-r)}}class qe{constructor(t,e,r){this.pos=t;this.path=e;this.parentOffset=r;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 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);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 r=this.path[e*3],i=e==0?0:this.path[e*3-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(t.content.size==0)return ye.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++)if(n[s].type.spec.inclusive===false&&(!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++)if(r[n].type.spec.inclusive===false&&(!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 Pe(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=[];let i=0,n=e;for(let e=t;;){let{index:t,offset:s}=e.content.findIndex(n);let l=n-s;r.push(e,t,i+s);if(!l)break;e=e.child(t);if(e.isText)break;n=l-1;i+=s+1}return new qe(e,r,n)}static resolveCached(t,e){let r=Ie.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{Ie.set(t,r=new Te)}let i=r.elts[r.i]=qe.resolve(t,e);r.i=(r.i+1)%ze;return i}}class Te{constructor(){this.elts=[];this.i=0}}const ze=12,Ie=new WeakMap;class Pe{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 Je=Object.create(null);class Le{constructor(t,e,r,i=ye.none){this.type=t;this.attrs=e;this.marks=i;this.content=r||be.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&&ve(this.attrs,e||t.defaultAttrs||Je)&&ye.sameSet(this.marks,r||ye.none)}copy(t=null){if(t==this.content)return this;return new Le(this.type,this.attrs,t,this.marks)}mark(t){return t==this.marks?this:new Le(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,r=false){if(t==e)return Ee.empty;let i=this.resolve(t),n=this.resolve(e);let s=r?0:i.sharedDepth(e);let l=i.start(s),o=i.node(s);let u=o.content.cut(i.pos-l,n.pos-l);return new Ee(u,i.depth-s,n.depth-s)}replace(t,e,r){return Ae(this.resolve(t),this.resolve(e),r)}nodeAt(t){for(let e=this;;){let{index:r,offset:i}=e.content.findIndex(t);e=e.maybeChild(r);if(!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(t==0)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 qe.resolveCached(this,t)}resolveNoCache(t){return qe.resolve(this,t)}rangeHasMark(t,e,r){let i=false;if(e>t)this.nodesBetween(t,e,(t=>{if(r.isInSet(t.marks))i=true;return!i}));return 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;if(this.content.size)t+="("+this.content.toStringInner()+")";return Ue(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=be.empty,i=0,n=r.childCount){let s=this.contentMatchAt(t).matchFragment(r,i,n);let l=s&&s.matchFragment(this.content,e);if(!l||!l.validEnd)return false;for(let t=i;t<n;t++)if(!this.type.allowsMarks(r.child(t).marks))return false;return true}canReplaceWith(t,e,r,i){if(i&&!this.type.allowsMarks(i))return false;let n=this.contentMatchAt(t).matchType(r);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=ye.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(!ye.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 r=undefined;if(e.marks){if(!Array.isArray(e.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=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,r)}let i=be.fromJSON(t,e.content);let n=t.nodeType(e.type).create(e.attrs,i,r);n.type.checkAttrs(n.attrs);return n}}Le.prototype.text=undefined;class We extends Le{constructor(t,e,r,i){super(t,e,null,i);if(!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);return Ue(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 We(this.type,this.attrs,this.text,t)}withText(t){if(t==this.text)return this;return new We(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 Ue(t,e){for(let r=t.length-1;r>=0;r--)e=t[r].type.name+"("+e+")";return e}class He{constructor(t){this.validEnd=t;this.next=[];this.wrapCache=[]}static parse(t,e){let r=new Ze(t,e);if(r.next==null)return He.empty;let i=Ke(r);if(r.next)r.err("Unexpected trailing text");let n=nr(er(i));sr(n,r);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,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 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 r=0;r<t.next.length;r++)if(this.next[e].type==t.next[r].type)return true;return false}fillBefore(t,e=false,r=0){let i=[this];function n(s,l){let o=s.matchFragment(t,r);if(o&&(!e||o.validEnd))return be.from(l.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())&&i.indexOf(r)==-1){i.push(r);let t=n(r,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),r=[{match:this,type:null,via:null}];while(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:l}=n.next[t];if(!s.isLeaf&&!s.hasRequiredAttrs()&&!(s.name in e)&&(!i.type||l.validEnd)){r.push({match:s.contentMatch,type:s,via:i});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(r){t.push(r);for(let i=0;i<r.next.length;i++)if(t.indexOf(r.next[i].next)==-1)e(r.next[i].next)}e(this);return 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")}}He.empty=new He(true);class Ze{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 Ke(t){let e=[];do{e.push(Ve(t))}while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function Ve(t){let e=[];do{e.push(Ge(t))}while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function Ge(t){let e=tr(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=Ye(t,e);else break}return e}function Xe(t){if(/\D/.test(t.next))t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);t.pos++;return e}function Ye(t,e){let r=Xe(t),i=r;if(t.eat(",")){if(t.next!="}")i=Xe(t);else i=-1}if(!t.eat("}"))t.err("Unclosed braced range");return{type:"range",min:r,max:i,expr:e}}function Qe(t,e){let r=t.nodeTypes,i=r[e];if(i)return[i];let n=[];for(let t in r){let i=r[t];if(i.groups.indexOf(e)>-1)n.push(i)}if(n.length==0)t.err("No node type or group '"+e+"' found");return n}function tr(t){if(t.eat("(")){let e=Ke(t);if(!t.eat(")"))t.err("Missing closing paren");return e}else if(!/\W/.test(t.next)){let e=Qe(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 er(t){let e=[[]];n(s(t,0),r());return e;function r(){return e.push([])-1}function i(t,r,i){let n={term:i,to:r};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,r)=>t.concat(s(r,e))),[])}else if(t.type=="seq"){for(let i=0;;i++){let l=s(t.exprs[i],e);if(i==t.exprs.length-1)return l;n(l,e=r())}}else if(t.type=="star"){let l=r();i(e,l);n(s(t.expr,l),l);return[i(l)]}else if(t.type=="plus"){let l=r();n(s(t.expr,e),l);n(s(t.expr,l),l);return[i(l)]}else if(t.type=="opt"){return[i(e)].concat(s(t.expr,e))}else if(t.type=="range"){let l=e;for(let e=0;e<t.min;e++){let e=r();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=r();i(l,e);n(s(t.expr,l),e);l=e}}return[i(l)]}else if(t.type=="name"){return[i(e,undefined,t.value)]}else{throw new Error("Unknown expr type")}}}function rr(t,e){return e-t}function ir(t,e){let r=[];i(e);return r.sort(rr);function i(e){let n=t[e];if(n.length==1&&!n[0].term)return i(n[0].to);r.push(e);for(let t=0;t<n.length;t++){let{term:e,to:s}=n[t];if(!e&&r.indexOf(s)==-1)i(s)}}}function nr(t){let e=Object.create(null);return r(ir(t,0));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++)if(n[t][0]==e)i=n[t][1];ir(t,r).forEach((t=>{if(!i)n.push([e,i=[]]);if(i.indexOf(t)==-1)i.push(t)}))}))}));let s=e[i.join(",")]=new He(i.indexOf(t.length-1)>-1);for(let t=0;t<n.length;t++){let i=n[t][1].sort(rr);s.next.push({type:n[t][0],next:e[i.join(",")]||r(i)})}return s}}function sr(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:l}=t.next[e];s.push(r.name);if(n&&!(r.isText||r.hasRequiredAttrs()))n=false;if(i.indexOf(l)==-1)i.push(l)}if(n)e.err("Only non-generatable nodes ("+s.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function lr(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 or(t,e){let r=Object.create(null);for(let i in t){let n=e&&e[i];if(n===undefined){let e=t[i];if(e.hasDefault)n=e.default;else throw new RangeError("No value supplied for attribute "+i)}r[i]=n}return r}function ur(t,e,r,i){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];if(i.validate)i.validate(e[r])}}function fr(t,e){let r=Object.create(null);if(e)for(let i in e)r[i]=new cr(t,i,e[i]);return r}class hr{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=fr(t,r.attrs);this.defaultAttrs=lr(this.attrs);this.contentMatch=null;this.inlineContent=null;this.isBlock=!(r.inline||t=="text");this.isText=t=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==He.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 or(this.attrs,t)}create(t=null,e,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Le(this,this.computeAttrs(t),be.from(e),ye.setFrom(r))}createChecked(t=null,e,r){e=be.from(e);this.checkContent(e);return new Le(this,this.computeAttrs(t),e,ye.setFrom(r))}createAndFill(t=null,e,r){t=this.computeAttrs(t);e=be.from(e);if(e.size){let t=this.contentMatch.fillBefore(e);if(!t)return null;e=t.append(e)}let i=this.contentMatch.matchFragment(e);let n=i&&i.fillBefore(be.empty,true);if(!n)return null;return new Le(this,t,e.append(n),ye.setFrom(r))}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){ur(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 r=0;r<t.length;r++){if(!this.allowsMarkType(t[r].type)){if(!e)e=t.slice(0,r)}else if(e){e.push(t[r])}}return!e?t:e.length?e:ye.none}static compile(t,e){let r=Object.create(null);t.forEach(((t,i)=>r[t]=new hr(t,e,i)));let i=e.spec.topNode||"doc";if(!r[i])throw new RangeError("Schema is missing its top node type ('"+i+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let t in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}}function ar(t,e,r){let i=r.split("|");return r=>{let n=r===null?"null":typeof r;if(i.indexOf(n)<0)throw new RangeError(`Expected value of type ${i} for attribute ${e} on type ${t}, got ${n}`)}}class cr{constructor(t,e,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default");this.default=r.default;this.validate=typeof r.validate=="string"?ar(t,e,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class dr{constructor(t,e,r,i){this.name=t;this.rank=e;this.schema=r;this.spec=i;this.attrs=fr(t,i.attrs);this.excluded=null;let n=lr(this.attrs);this.instance=n?new ye(this,n):null}create(t=null){if(!t&&this.instance)return this.instance;return new ye(this,or(this.attrs,t))}static compile(t,e){let r=Object.create(null),i=0;t.forEach(((t,n)=>r[t]=new dr(t,i++,e,n)));return r}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){ur(this.attrs,t,"mark")}excludes(t){return this.excluded.indexOf(t)>-1}}class pr{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=me.from(t.nodes),e.marks=me.from(t.marks||{}),this.nodes=hr.compile(this.spec.nodes,this);this.marks=dr.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;e.contentMatch=r[i]||(r[i]=He.parse(i,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?mr(this,n.split(" ")):n==""||!e.inlineContent?[]:null}for(let t in this.marks){let e=this.marks[t],r=e.spec.excludes;e.excluded=r==null?[e]:r==""?[]:mr(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(typeof t=="string")t=this.nodeType(t);else if(!(t instanceof hr))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,r,i)}text(t,e){let r=this.nodes.text;return new We(r,r.defaultAttrs,t,ye.setFrom(e))}mark(t,e){if(typeof t=="string")t=this.marks[t];return t.create(e)}nodeFromJSON(t){return Le.fromJSON(this,t)}markFromJSON(t){return ye.fromJSON(this,t)}nodeType(t){let e=this.nodes[t];if(!e)throw new RangeError("Unknown node type: "+t);return e}}function mr(t,e){let r=[];for(let i=0;i<e.length;i++){let n=e[i],s=t.marks[n],l=s;if(s){r.push(s)}else{for(let e in t.marks){let i=t.marks[e];if(n=="_"||i.spec.group&&i.spec.group.split(" ").indexOf(n)>-1)r.push(l=i)}}if(!l)throw new SyntaxError("Unknown mark type: '"+e[i]+"'")}return r}function wr(t){return t.tag!=null}function gr(t){return t.style!=null}class br{constructor(t,e){this.schema=t;this.rules=e;this.tags=[];this.styles=[];let r=this.matchedStyles=[];e.forEach((t=>{if(wr(t)){this.tags.push(t)}else if(gr(t)){let e=/[^=]*/.exec(t.style)[0];if(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 false;let r=t.nodes[e.node];return r.contentMatch.matchType(r)}))}parse(t,e={}){let r=new Ar(this,e,false);r.addAll(t,ye.none,e.from,e.to);return r.finish()}parseSlice(t,e={}){let r=new Ar(this,e,true);r.addAll(t,ye.none,e.from,e.to);return Ee.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(Sr(t,r.tag)&&(r.namespace===undefined||t.namespaceURI==r.namespace)&&(!r.context||e.matchesContext(r.context))){if(r.getAttrs){let e=r.getAttrs(t);if(e===false)continue;r.attrs=e||undefined}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(s.indexOf(t)!=0||i.context&&!r.matchesContext(i.context)||s.length>t.length&&(s.charCodeAt(t.length)!=61||s.slice(t.length+1)!=e))continue;if(i.getAttrs){let t=i.getAttrs(e);if(t===false)continue;i.attrs=t||undefined}return i}}static schemaRules(t){let e=[];function r(t){let r=t.priority==null?50:t.priority,i=0;for(;i<e.length;i++){let t=e[i],n=t.priority==null?50:t.priority;if(n<r)break}e.splice(i,0,t)}for(let e in t.marks){let i=t.marks[e].spec.parseDOM;if(i)i.forEach((t=>{r(t=Or(t));if(!(t.mark||t.ignore||t.clearMark))t.mark=e}))}for(let e in t.nodes){let i=t.nodes[e].spec.parseDOM;if(i)i.forEach((t=>{r(t=Or(t));if(!(t.node||t.ignore||t.mark))t.node=e}))}return e}static fromSchema(t){return t.cached.domParser||(t.cached.domParser=new br(t,br.schemaRules(t)))}}const kr={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 Dr={head:true,noscript:true,object:true,script:true,style:true,title:true};const vr={ol:true,ul:true};const yr=1,Fr=2,Er=4;function Mr(t,e,r){if(e!=null)return(e?yr:0)|(e==="full"?Fr:0);return t&&t.whitespace=="pre"?yr|Fr:r&~Er}class xr{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=ye.none;this.match=n||(s&Er?null:t.contentMatch)}findWrapping(t){if(!this.match){if(!this.type)return[];let e=this.type.contentMatch.fillBefore(be.from(t));if(e){this.match=this.type.contentMatch.matchFragment(e)}else{let e=this.type.contentMatch,r;if(r=e.findWrapping(t.type)){this.match=e;return r}else{return null}}}return this.match.findWrapping(t.type)}finish(t){if(!(this.options&yr)){let t=this.content[this.content.length-1],e;if(t&&t.isText&&(e=/[ \t\r\n\u000c]+$/.exec(t.text))){let r=t;if(t.text.length==e[0].length)this.content.pop();else this.content[this.content.length-1]=r.withText(r.text.slice(0,r.text.length-e[0].length))}}let e=be.from(this.content);if(!t&&this.match)e=e.append(this.match.fillBefore(be.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&&!kr.hasOwnProperty(t.parentNode.nodeName.toLowerCase())}}class Ar{constructor(t,e,r){this.parser=t;this.options=e;this.isOpen=r;this.open=0;let i=e.topNode,n;let s=Mr(null,e.preserveWhitespace,0)|(r?Er:0);if(i)n=new xr(i.type,i.attrs,ye.none,true,e.topMatch||i.type.contentMatch,s);else if(r)n=new xr(null,null,ye.none,true,null,s);else n=new xr(t.schema.topNodeType,null,ye.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 r=t.nodeValue;let i=this.top;if(i.options&Fr||i.inlineContext(t)||/[^ \t\r\n\u000c]/.test(r)){if(!(i.options&yr)){r=r.replace(/[ \t\r\n\u000c]+/g," ");if(/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let e=i.content[i.content.length-1];let n=t.previousSibling;if(!e||n&&n.nodeName=="BR"||e.isText&&/[ \t\r\n\u000c]$/.test(e.text))r=r.slice(1)}}else if(!(i.options&Fr)){r=r.replace(/\r?\n|\r/g," ")}else{r=r.replace(/\r\n?/g,"\n")}if(r)this.insertNode(this.parser.schema.text(r),e);this.findInText(t)}else{this.findInside(t)}}addElement(t,e,r){let i=t.nodeName.toLowerCase(),n;if(vr.hasOwnProperty(i)&&this.parser.normalizeLists)Cr(t);let s=this.options.ruleFromNode&&this.options.ruleFromNode(t)||(n=this.parser.matchTag(t,this,r));if(s?s.ignore:Dr.hasOwnProperty(i)){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 r,n=this.top,l=this.needsBlock;if(kr.hasOwnProperty(i)){if(n.content.length&&n.content[0].isInline&&this.open){this.open--;n=this.top}r=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(r)this.sync(n);this.needsBlock=l}else{let r=this.readStyles(t,e);if(r)this.addElementByRule(t,s,r,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 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=undefined;;){let r=this.parser.matchStyle(i,n,this,t);if(!r)break;if(r.ignore)return null;if(r.clearMark)e=e.filter((t=>!r.clearMark(t)));else e=e.concat(this.parser.schema.marks[r.mark].create(r.attrs));if(r.consuming===false)t=r;else break}}return e}addElementByRule(t,e,r,i){let n,s;if(e.node){s=this.parser.schema.nodes[e.node];if(!s.isLeaf){let t=this.enter(s,e.attrs||null,r,e.preserveWhitespace);if(t){n=true;r=t}}else if(!this.insertNode(s.create(e.attrs),r)){this.leafFallback(t,r)}}else{let t=this.parser.schema.marks[e.mark];r=r.concat(t.create(e.attrs))}let l=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;if(typeof e.contentElement=="string")i=t.querySelector(e.contentElement);else if(typeof e.contentElement=="function")i=e.contentElement(t);else if(e.contentElement)i=e.contentElement;this.findAround(t,i,true);this.addAll(i,r)}if(n&&this.sync(l))this.open--}addAll(t,e,r,i){let n=r||0;for(let s=r?t.childNodes[r]:t.firstChild,l=i==null?null:t.childNodes[i];s!=l;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];let s=n.findWrapping(t);if(s&&(!r||r.length>s.length)){r=s;i=n;if(!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,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 r=this.findPlace(t,e);if(r){this.closeExtra();let e=this.top;if(e.match)e.match=e.match.matchType(t.type);let i=ye.none;for(let n of r.concat(t.marks))if(e.type?e.type.allowsMarkType(n.type):$r(n.type,t.type))i=n.addToSet(i);e.content.push(t.mark(i));return true}return false}enter(t,e,r,i){let n=this.findPlace(t.create(e),r);if(n)n=this.enterInner(t,e,r,true,i);return n}enterInner(t,e,r,i=false,n){this.closeExtra();let s=this.top;s.match=s.match&&s.match.matchType(t);let l=Mr(t,n,s.options);if(s.options&Er&&s.content.length==0)l|=Er;let o=ye.none;r=r.filter((e=>{if(s.type?s.type.allowsMarkType(e.type):$r(e.type,t)){o=e.addToSet(o);return false}return true}));this.nodes.push(new xr(t,e,o,i,null,l));this.open++;return r}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 r=this.nodes[e].content;for(let e=r.length-1;e>=0;e--)t+=r[e].nodeSize;if(e)t++}return t}findAtPoint(t,e){if(this.find)for(let r=0;r<this.find.length;r++){if(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++){if(this.find[e].pos==null&&t.nodeType==1&&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++){if(this.find[i].pos==null&&t.nodeType==1&&t.contains(this.find[i].node)){let t=e.compareDocumentPosition(this.find[i].node);if(t&(r?2:4))this.find[i].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 r=this.options.context;let i=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type);let n=-(r?r.depth+1:0)+(i?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&&i?this.nodes[l].type:r&&l>=n?r.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 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 Cr(t){for(let e=t.firstChild,r=null;e;e=e.nextSibling){let t=e.nodeType==1?e.nodeName.toLowerCase():null;if(t&&vr.hasOwnProperty(t)&&r){r.appendChild(e);e=r}else if(t=="li"){r=e}else if(t){r=null}}}function Sr(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function Or(t){let e={};for(let r in t)e[r]=t[r];return e}function $r(t,e){let r=e.schema.nodes;for(let i in r){let n=r[i];if(!n.allowsMarkType(t))continue;let s=[],l=t=>{s.push(t);for(let r=0;r<t.edgeCount;r++){let{type:i,next:n}=t.edge(r);if(i==e)return true;if(s.indexOf(n)<0&&l(n))return true}};if(l(n.contentMatch))return true}}class _r{constructor(t,e){this.nodes=t;this.marks=e}serializeFragment(t,e={},r){if(!r)r=Rr(e).createDocumentFragment();let i=r,n=[];t.forEach((t=>{if(n.length||t.marks.length){let r=0,s=0;while(r<n.length&&s<t.marks.length){let e=t.marks[s];if(!this.marks[e.type.name]){s++;continue}if(!e.eq(n[r][0])||e.type.spec.spanning===false)break;r++;s++}while(r<n.length)i=n.pop()[1];while(s<t.marks.length){let r=t.marks[s++];let l=this.serializeMark(r,t.isInline,e);if(l){n.push([r,i]);i.appendChild(l.dom);i=l.contentDOM||l.dom}}}i.appendChild(this.serializeNodeInner(t,e))}));return r}serializeNodeInner(t,e){let{dom:r,contentDOM:i}=Tr(Rr(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);if(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&&Tr(Rr(r),i(t,e),null,t.attrs)}static renderSpec(t,e,r=null,i){return Tr(t,e,r,i)}static fromSchema(t){return t.cached.domSerializer||(t.cached.domSerializer=new _r(this.nodesFromSchema(t),this.marksFromSchema(t)))}static nodesFromSchema(t){let e=Br(t.nodes);if(!e.text)e.text=t=>t.text;return e}static marksFromSchema(t){return Br(t.marks)}}function Br(t){let e={};for(let r in t){let i=t[r].spec.toDOM;if(i)e[r]=i}return e}function Rr(t){return t.document||window.document}const jr=new WeakMap;function Nr(t){let e=jr.get(t);if(e===undefined)jr.set(t,e=qr(t));return e}function qr(t){let e=null;function r(t){if(t&&typeof t=="object"){if(Array.isArray(t)){if(typeof t[0]=="string"){if(!e)e=[];e.push(t)}else{for(let e=0;e<t.length;e++)r(t[e])}}else{for(let e in t)r(t[e])}}}r(t);return e}function Tr(t,e,r,i){if(typeof e=="string")return{dom:t.createTextNode(e)};if(e.nodeType!=null)return{dom:e};if(e.dom&&e.dom.nodeType!=null)return e;let n=e[0],s;if(typeof n!="string")throw new RangeError("Invalid array passed to renderSpec");if(i&&(s=Nr(i))&&s.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 l=n.indexOf(" ");if(l>0){r=n.slice(0,l);n=n.slice(l+1)}let o;let u=r?t.createElementNS(r,n):t.createElement(n);let f=e[1],h=1;if(f&&typeof f=="object"&&f.nodeType==null&&!Array.isArray(f)){h=2;for(let t in f)if(f[t]!=null){let e=t.indexOf(" ");if(e>0)u.setAttributeNS(t.slice(0,e),t.slice(e+1),f[t]);else u.setAttribute(t,f[t])}}for(let n=h;n<e.length;n++){let s=e[n];if(s===0){if(n<e.length-1||n>h)throw new RangeError("Content hole must be the only child of its parent node");return{dom:u,contentDOM:u}}else{let{dom:e,contentDOM:n}=Tr(t,s,r,i);u.appendChild(e);if(n){if(o)throw new RangeError("Multiple content holes");o=n}}}return{dom:u,contentDOM:o}}const zr=65535;const Ir=Math.pow(2,16);function Pr(t,e){return t+e*Ir}function Jr(t){return t&zr}function Lr(t){return(t-(t&zr))/Ir}const Wr=1,Ur=2,Hr=4,Zr=8;class Kr{constructor(t,e,r){this.pos=t;this.delInfo=e;this.recover=r}get deleted(){return(this.delInfo&Zr)>0}get deletedBefore(){return(this.delInfo&(Wr|Hr))>0}get deletedAfter(){return(this.delInfo&(Ur|Hr))>0}get deletedAcross(){return(this.delInfo&Hr)>0}}class Vr{constructor(t,e=false){this.ranges=t;this.inverted=e;if(!t.length&&Vr.empty)return Vr.empty}recover(t){let e=0,r=Jr(t);if(!this.inverted)for(let t=0;t<r;t++)e+=this.ranges[t*3+2]-this.ranges[t*3+1];return this.ranges[r*3]+e+Lr(t)}mapResult(t,e=1){return this._map(t,e,false)}map(t,e=1){return this._map(t,e,true)}_map(t,e,r){let i=0,n=this.inverted?2:1,s=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let o=this.ranges[l]-(this.inverted?i:0);if(o>t)break;let u=this.ranges[l+n],f=this.ranges[l+s],h=o+u;if(t<=h){let n=!u?e:t==o?-1:t==h?1:e;let s=o+i+(n<0?0:f);if(r)return s;let a=t==(e<0?o:h)?null:Pr(l/3,t-o);let c=t==o?Ur:t==h?Wr:Hr;if(e<0?t!=o:t!=h)c|=Zr;return new Kr(s,c,a)}i+=f-u}return r?t+i:new Kr(t+i,0,null)}touches(t,e){let r=0,i=Jr(e);let n=this.inverted?2:1,s=this.inverted?1:2;for(let e=0;e<this.ranges.length;e+=3){let l=this.ranges[e]-(this.inverted?r:0);if(l>t)break;let o=this.ranges[e+n],u=l+o;if(t<=u&&e==i*3)return true;r+=this.ranges[e+s]-o}return false}forEach(t){let e=this.inverted?2:1,r=this.inverted?1:2;for(let i=0,n=0;i<this.ranges.length;i+=3){let s=this.ranges[i],l=s-(this.inverted?n:0),o=s+(this.inverted?0:n);let u=this.ranges[i+e],f=this.ranges[i+r];t(l,l+u,o,o+f);n+=f-u}}invert(){return new Vr(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(t){return t==0?Vr.empty:new Vr(t<0?[0,-t,0]:[0,0,t])}}Vr.empty=new Vr([]);class Gr{constructor(t=[],e,r=0,i=t.length){this.maps=t;this.mirror=e;this.from=r;this.to=i}slice(t=0,e=this.maps.length){return new Gr(this.maps,this.mirror,t,e)}copy(){return new Gr(this.maps.slice(),this.mirror&&this.mirror.slice(),this.from,this.to)}appendMap(t,e){this.to=this.maps.push(t);if(e!=null)this.setMirror(this.maps.length-1,e)}appendMapping(t){for(let e=0,r=this.maps.length;e<t.maps.length;e++){let i=t.getMirror(e);this.appendMap(t.maps[e],i!=null&&i<e?r+i:undefined)}}getMirror(t){if(this.mirror)for(let e=0;e<this.mirror.length;e++)if(this.mirror[e]==t)return this.mirror[e+(e%2?-1:1)]}setMirror(t,e){if(!this.mirror)this.mirror=[];this.mirror.push(t,e)}appendMappingInverted(t){for(let e=t.maps.length-1,r=this.maps.length+t.maps.length;e>=0;e--){let i=t.getMirror(e);this.appendMap(t.maps[e].invert(),i!=null&&i>e?r-i-1:undefined)}}invert(){let t=new Gr;t.appendMappingInverted(this);return t}map(t,e=1){if(this.mirror)return this._map(t,e,true);for(let r=this.from;r<this.to;r++)t=this.maps[r].map(t,e);return t}mapResult(t,e=1){return this._map(t,e,false)}_map(t,e,r){let i=0;for(let r=this.from;r<this.to;r++){let n=this.maps[r],s=n.mapResult(t,e);if(s.recover!=null){let e=this.getMirror(r);if(e!=null&&e>r&&e<this.to){r=e;t=this.maps[e].recover(s.recover);continue}}i|=s.delInfo;t=s.pos}return r?t:new Kr(t,i,null)}}const Xr=Object.create(null);class Yr{getMap(){return Vr.empty}merge(t){return null}static fromJSON(t,e){if(!e||!e.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=Xr[e.stepType];if(!r)throw new RangeError(`No step type ${e.stepType} defined`);return r.fromJSON(t,e)}static jsonID(t,e){if(t in Xr)throw new RangeError("Duplicate use of step JSON ID "+t);Xr[t]=e;e.prototype.jsonID=t;return e}}class Qr{constructor(t,e){this.doc=t;this.failed=e}static ok(t){return new Qr(t,null)}static fail(t){return new Qr(null,t)}static fromReplace(t,e,r,i){try{return Qr.ok(t.replace(e,r,i))}catch(t){if(t instanceof Fe)return Qr.fail(t.message);throw t}}}function ti(t,e,r){let i=[];for(let n=0;n<t.childCount;n++){let s=t.child(n);if(s.content.size)s=s.copy(ti(s.content,e,s));if(s.isInline)s=e(s,r,n);i.push(s)}return be.fromArray(i)}class ei extends Yr{constructor(t,e,r){super();this.from=t;this.to=e;this.mark=r}apply(t){let e=t.slice(this.from,this.to),r=t.resolve(this.from);let i=r.node(r.sharedDepth(this.to));let n=new Ee(ti(e.content,((t,e)=>{if(!t.isAtom||!e.type.allowsMarkType(this.mark.type))return t;return t.mark(this.mark.addToSet(t.marks))}),i),e.openStart,e.openEnd);return Qr.fromReplace(t,this.from,this.to,n)}invert(){return new ri(this.from,this.to,this.mark)}map(t){let e=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);if(e.deleted&&r.deleted||e.pos>=r.pos)return null;return new ei(e.pos,r.pos,this.mark)}merge(t){if(t instanceof ei&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from)return new ei(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark);return null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,e){if(typeof e.from!="number"||typeof e.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new ei(e.from,e.to,t.markFromJSON(e.mark))}}Yr.jsonID("addMark",ei);class ri extends Yr{constructor(t,e,r){super();this.from=t;this.to=e;this.mark=r}apply(t){let e=t.slice(this.from,this.to);let r=new Ee(ti(e.content,(t=>t.mark(this.mark.removeFromSet(t.marks))),t),e.openStart,e.openEnd);return Qr.fromReplace(t,this.from,this.to,r)}invert(){return new ei(this.from,this.to,this.mark)}map(t){let e=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);if(e.deleted&&r.deleted||e.pos>=r.pos)return null;return new ri(e.pos,r.pos,this.mark)}merge(t){if(t instanceof ri&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from)return new ri(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark);return null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,e){if(typeof e.from!="number"||typeof e.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new ri(e.from,e.to,t.markFromJSON(e.mark))}}Yr.jsonID("removeMark",ri);class ii extends Yr{constructor(t,e){super();this.pos=t;this.mark=e}apply(t){let e=t.nodeAt(this.pos);if(!e)return Qr.fail("No node at mark step's position");let r=e.type.create(e.attrs,null,this.mark.addToSet(e.marks));return Qr.fromReplace(t,this.pos,this.pos+1,new Ee(be.from(r),0,e.isLeaf?0:1))}invert(t){let e=t.nodeAt(this.pos);if(e){let t=this.mark.addToSet(e.marks);if(t.length==e.marks.length){for(let r=0;r<e.marks.length;r++)if(!e.marks[r].isInSet(t))return new ii(this.pos,e.marks[r]);return new ii(this.pos,this.mark)}}return new ni(this.pos,this.mark)}map(t){let e=t.mapResult(this.pos,1);return e.deletedAfter?null:new ii(e.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,e){if(typeof e.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new ii(e.pos,t.markFromJSON(e.mark))}}Yr.jsonID("addNodeMark",ii);class ni extends Yr{constructor(t,e){super();this.pos=t;this.mark=e}apply(t){let e=t.nodeAt(this.pos);if(!e)return Qr.fail("No node at mark step's position");let r=e.type.create(e.attrs,null,this.mark.removeFromSet(e.marks));return Qr.fromReplace(t,this.pos,this.pos+1,new Ee(be.from(r),0,e.isLeaf?0:1))}invert(t){let e=t.nodeAt(this.pos);if(!e||!this.mark.isInSet(e.marks))return this;return new ii(this.pos,this.mark)}map(t){let e=t.mapResult(this.pos,1);return e.deletedAfter?null:new ni(e.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,e){if(typeof e.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new ni(e.pos,t.markFromJSON(e.mark))}}Yr.jsonID("removeNodeMark",ni);class si extends Yr{constructor(t,e,r,i=false){super();this.from=t;this.to=e;this.slice=r;this.structure=i}apply(t){if(this.structure&&oi(t,this.from,this.to))return Qr.fail("Structure replace would overwrite content");return Qr.fromReplace(t,this.from,this.to,this.slice)}getMap(){return new Vr([this.from,this.to-this.from,this.slice.size])}invert(t){return new si(this.from,this.from+this.slice.size,t.slice(this.from,this.to))}map(t){let e=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);if(e.deletedAcross&&r.deletedAcross)return null;return new si(e.pos,Math.max(e.pos,r.pos),this.slice)}merge(t){if(!(t instanceof si)||t.structure||this.structure)return null;if(this.from+this.slice.size==t.from&&!this.slice.openEnd&&!t.slice.openStart){let e=this.slice.size+t.slice.size==0?Ee.empty:new Ee(this.slice.content.append(t.slice.content),this.slice.openStart,t.slice.openEnd);return new si(this.from,this.to+(t.to-t.from),e,this.structure)}else if(t.to==this.from&&!this.slice.openStart&&!t.slice.openEnd){let e=this.slice.size+t.slice.size==0?Ee.empty:new Ee(t.slice.content.append(this.slice.content),t.slice.openStart,this.slice.openEnd);return new si(t.from,this.to,e,this.structure)}else{return null}}toJSON(){let t={stepType:"replace",from:this.from,to:this.to};if(this.slice.size)t.slice=this.slice.toJSON();if(this.structure)t.structure=true;return t}static fromJSON(t,e){if(typeof e.from!="number"||typeof e.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new si(e.from,e.to,Ee.fromJSON(t,e.slice),!!e.structure)}}Yr.jsonID("replace",si);class li extends Yr{constructor(t,e,r,i,n,s,l=false){super();this.from=t;this.to=e;this.gapFrom=r;this.gapTo=i;this.slice=n;this.insert=s;this.structure=l}apply(t){if(this.structure&&(oi(t,this.from,this.gapFrom)||oi(t,this.gapTo,this.to)))return Qr.fail("Structure gap-replace would overwrite content");let e=t.slice(this.gapFrom,this.gapTo);if(e.openStart||e.openEnd)return Qr.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,e.content);if(!r)return Qr.fail("Content does not fit in gap");return Qr.fromReplace(t,this.from,this.to,r)}getMap(){return new Vr([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(t){let e=this.gapTo-this.gapFrom;return new li(this.from,this.from+this.slice.size+e,this.from+this.insert,this.from+this.insert+e,t.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(t){let e=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);let i=this.from==this.gapFrom?e.pos:t.map(this.gapFrom,-1);let n=this.to==this.gapTo?r.pos:t.map(this.gapTo,1);if(e.deletedAcross&&r.deletedAcross||i<e.pos||n>r.pos)return null;return new li(e.pos,r.pos,i,n,this.slice,this.insert,this.structure)}toJSON(){let t={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};if(this.slice.size)t.slice=this.slice.toJSON();if(this.structure)t.structure=true;return t}static fromJSON(t,e){if(typeof e.from!="number"||typeof e.to!="number"||typeof e.gapFrom!="number"||typeof e.gapTo!="number"||typeof e.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new li(e.from,e.to,e.gapFrom,e.gapTo,Ee.fromJSON(t,e.slice),e.insert,!!e.structure)}}Yr.jsonID("replaceAround",li);function oi(t,e,r){let i=t.resolve(e),n=r-e,s=i.depth;while(n>0&&s>0&&i.indexAfter(s)==i.node(s).childCount){s--;n--}if(n>0){let t=i.node(s).maybeChild(i.indexAfter(s));while(n>0){if(!t||t.isLeaf)return true;t=t.firstChild;n--}}return false}function ui(t,e,r,i){let n=[],s=[];let l,o;t.doc.nodesBetween(e,r,((t,u,f)=>{if(!t.isInline)return;let h=t.marks;if(!i.isInSet(h)&&f.type.allowsMarkType(i.type)){let f=Math.max(u,e),a=Math.min(u+t.nodeSize,r);let c=i.addToSet(h);for(let t=0;t<h.length;t++){if(!h[t].isInSet(c)){if(l&&l.to==f&&l.mark.eq(h[t]))l.to=a;else n.push(l=new ri(f,a,h[t]))}}if(o&&o.to==f)o.to=a;else s.push(o=new ei(f,a,i))}}));n.forEach((e=>t.step(e)));s.forEach((e=>t.step(e)))}function fi(t,e,r,i){let n=[],s=0;t.doc.nodesBetween(e,r,((t,l)=>{if(!t.isInline)return;s++;let o=null;if(i instanceof dr){let e=t.marks,r;while(r=i.isInSet(e)){(o||(o=[])).push(r);e=r.removeFromSet(e)}}else if(i){if(i.isInSet(t.marks))o=[i]}else{o=t.marks}if(o&&o.length){let i=Math.min(l+t.nodeSize,r);for(let t=0;t<o.length;t++){let r=o[t],u;for(let t=0;t<n.length;t++){let e=n[t];if(e.step==s-1&&r.eq(n[t].style))u=e}if(u){u.to=i;u.step=s}else{n.push({style:r,from:Math.max(l,e),to:i,step:s})}}}}));n.forEach((e=>t.step(new ri(e.from,e.to,e.style))))}function hi(t,e,r,i=r.contentMatch,n=true){let s=t.doc.nodeAt(e);let l=[],o=e+1;for(let e=0;e<s.childCount;e++){let u=s.child(e),f=o+u.nodeSize;let h=i.matchType(u.type);if(!h){l.push(new si(o,f,Ee.empty))}else{i=h;for(let e=0;e<u.marks.length;e++)if(!r.allowsMarkType(u.marks[e].type))t.step(new ri(o,f,u.marks[e]));if(n&&u.isText&&r.whitespace!="pre"){let t,e=/\r?\n|\r/g,i;while(t=e.exec(u.text)){if(!i)i=new Ee(be.from(r.schema.text(" ",r.allowedMarks(u.marks))),0,0);l.push(new si(o+t.index,o+t.index+t[0].length,i))}}}o=f}if(!i.validEnd){let e=i.fillBefore(be.empty,true);t.replace(o,o,new Ee(e,0,0))}for(let e=l.length-1;e>=0;e--)t.step(l[e])}function ai(t,e,r){return(e==0||t.canReplace(e,t.childCount))&&(r==t.childCount||t.canReplace(0,r))}function ci(t){let e=t.parent;let r=e.content.cutByIndex(t.startIndex,t.endIndex);for(let e=t.depth;;--e){let i=t.$from.node(e);let n=t.$from.index(e),s=t.$to.indexAfter(e);if(e<t.depth&&i.canReplace(n,s,r))return e;if(e==0||i.type.spec.isolating||!ai(i,n,s))break}return null}function di(t,e,r){let{$from:i,$to:n,depth:s}=e;let l=i.before(s+1),o=n.after(s+1);let u=l,f=o;let h=be.empty,a=0;for(let t=s,e=false;t>r;t--)if(e||i.index(t)>0){e=true;h=be.from(i.node(t).copy(h));a++}else{u--}let c=be.empty,d=0;for(let t=s,e=false;t>r;t--)if(e||n.after(t+1)<n.end(t)){e=true;c=be.from(n.node(t).copy(c));d++}else{f++}t.step(new li(u,f,l,o,new Ee(h.append(c),a,d),h.size-a,true))}function pi(t,e,r=null,i=t){let n=wi(t,e);let s=n&&gi(i,e);if(!s)return null;return n.map(mi).concat({type:e,attrs:r}).concat(s.map(mi))}function mi(t){return{type:t,attrs:null}}function wi(t,e){let{parent:r,startIndex:i,endIndex:n}=t;let s=r.contentMatchAt(i).findWrapping(e);if(!s)return null;let l=s.length?s[0]:e;return r.canReplaceWith(i,n,l)?s:null}function gi(t,e){let{parent:r,startIndex:i,endIndex:n}=t;let s=r.child(i);let l=e.contentMatch.findWrapping(s.type);if(!l)return null;let o=l.length?l[l.length-1]:e;let u=o.contentMatch;for(let t=i;u&&t<n;t++)u=u.matchType(r.child(t).type);if(!u||!u.validEnd)return null;return l}function bi(t,e,r){let i=be.empty;for(let t=r.length-1;t>=0;t--){if(i.size){let e=r[t].type.contentMatch.matchFragment(i);if(!e||!e.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}i=be.from(r[t].type.create(r[t].attrs,i))}let n=e.start,s=e.end;t.step(new li(n,s,n,s,new Ee(i,0,0),r.length,true))}function ki(t,e,r,i,n){if(!i.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let s=t.steps.length;t.doc.nodesBetween(e,r,((e,r)=>{let l=typeof n=="function"?n(e):n;if(e.isTextblock&&!e.hasMarkup(i,l)&&yi(t.doc,t.mapping.slice(s).map(r),i)){let n=null;if(i.schema.linebreakReplacement){let t=i.whitespace=="pre",e=!!i.contentMatch.matchType(i.schema.linebreakReplacement);if(t&&!e)n=false;else if(!t&&e)n=true}if(n===false)vi(t,e,r,s);hi(t,t.mapping.slice(s).map(r,1),i,undefined,n===null);let o=t.mapping.slice(s);let u=o.map(r,1),f=o.map(r+e.nodeSize,1);t.step(new li(u,f,u+1,f-1,new Ee(be.from(i.create(l,null,e.marks)),0,0),1,true));if(n===true)Di(t,e,r,s);return false}}))}function Di(t,e,r,i){e.forEach(((n,s)=>{if(n.isText){let l,o=/\r?\n|\r/g;while(l=o.exec(n.text)){let n=t.mapping.slice(i).map(r+1+s+l.index);t.replaceWith(n,n+1,e.type.schema.linebreakReplacement.create())}}}))}function vi(t,e,r,i){e.forEach(((n,s)=>{if(n.type==n.type.schema.linebreakReplacement){let n=t.mapping.slice(i).map(r+1+s);t.replaceWith(n,n+1,e.type.schema.text("\n"))}}))}function yi(t,e,r){let i=t.resolve(e),n=i.index();return i.parent.canReplaceWith(n,n+1,r)}function Fi(t,e,r,i,n){let s=t.doc.nodeAt(e);if(!s)throw new RangeError("No node at given position");if(!r)r=s.type;let l=r.create(i,null,n||s.marks);if(s.isLeaf)return t.replaceWith(e,e+s.nodeSize,l);if(!r.validContent(s.content))throw new RangeError("Invalid content for node type "+r.name);t.step(new li(e,e+s.nodeSize,e+1,e+s.nodeSize-1,new Ee(be.from(l),0,0),1,true))}function Ei(t,e,r=1,i){let n=t.resolve(e),s=n.depth-r;let l=i&&i[i.length-1]||n.parent;if(s<0||n.parent.type.spec.isolating||!n.parent.canReplace(n.index(),n.parent.childCount)||!l.type.validContent(n.parent.content.cutByIndex(n.index(),n.parent.childCount)))return false;for(let t=n.depth-1,e=r-2;t>s;t--,e--){let r=n.node(t),s=n.index(t);if(r.type.spec.isolating)return false;let l=r.content.cutByIndex(s,r.childCount);let o=i&&i[e+1];if(o)l=l.replaceChild(0,o.type.create(o.attrs));let u=i&&i[e]||r;if(!r.canReplace(s+1,r.childCount)||!u.type.validContent(l))return false}let o=n.indexAfter(s);let u=i&&i[0];return n.node(s).canReplaceWith(o,o,u?u.type:n.node(s+1).type)}function Mi(t,e,r=1,i){let n=t.doc.resolve(e),s=be.empty,l=be.empty;for(let t=n.depth,e=n.depth-r,o=r-1;t>e;t--,o--){s=be.from(n.node(t).copy(s));let e=i&&i[o];l=be.from(e?e.type.create(e.attrs,l):n.node(t).copy(l))}t.step(new si(e,e,new Ee(s.append(l),r,r),true))}function xi(t,e){let r=t.resolve(e),i=r.index();return Ci(r.nodeBefore,r.nodeAfter)&&r.parent.canReplace(i,i+1)}function Ai(t,e){if(!e.content.size)t.type.compatibleContent(e.type);let r=t.contentMatchAt(t.childCount);let{linebreakReplacement:i}=t.type.schema;for(let n=0;n<e.childCount;n++){let s=e.child(n);let l=s.type==i?t.type.schema.nodes.text:s.type;r=r.matchType(l);if(!r)return false;if(!t.type.allowsMarks(s.marks))return false}return r.validEnd}function Ci(t,e){return!!(t&&e&&!t.isLeaf&&Ai(t,e))}function Si(t,e,r=-1){let i=t.resolve(e);for(let t=i.depth;;t--){let n,s,l=i.index(t);if(t==i.depth){n=i.nodeBefore;s=i.nodeAfter}else if(r>0){n=i.node(t+1);l++;s=i.node(t).maybeChild(l)}else{n=i.node(t).maybeChild(l-1);s=i.node(t+1)}if(n&&!n.isTextblock&&Ci(n,s)&&i.node(t).canReplace(l,l+1))return e;if(t==0)break;e=r<0?i.before(t):i.after(t)}}function Oi(t,e,r){let i=null;let{linebreakReplacement:n}=t.doc.type.schema;let s=t.doc.resolve(e-r),l=s.node().type;if(n&&l.inlineContent){let t=l.whitespace=="pre";let e=!!l.contentMatch.matchType(n);if(t&&!e)i=false;else if(!t&&e)i=true}let o=t.steps.length;if(i===false){let i=t.doc.resolve(e+r);vi(t,i.node(),i.before(),o)}if(l.inlineContent)hi(t,e+r-1,l,s.node().contentMatchAt(s.index()),i==null);let u=t.mapping.slice(o),f=u.map(e-r);t.step(new si(f,u.map(e+r,-1),Ee.empty,true));if(i===true){let e=t.doc.resolve(f);Di(t,e.node(),e.before(),t.steps.length)}return t}function $i(t,e,r){let i=t.resolve(e);if(i.parent.canReplaceWith(i.index(),i.index(),r))return e;if(i.parentOffset==0)for(let t=i.depth-1;t>=0;t--){let e=i.index(t);if(i.node(t).canReplaceWith(e,e,r))return i.before(t+1);if(e>0)return null}if(i.parentOffset==i.parent.content.size)for(let t=i.depth-1;t>=0;t--){let e=i.indexAfter(t);if(i.node(t).canReplaceWith(e,e,r))return i.after(t+1);if(e<i.node(t).childCount)return null}return null}function _i(t,e,r){let i=t.resolve(e);if(!r.content.size)return e;let n=r.content;for(let t=0;t<r.openStart;t++)n=n.firstChild.content;for(let t=1;t<=(r.openStart==0&&r.size?2:1);t++){for(let e=i.depth;e>=0;e--){let r=e==i.depth?0:i.pos<=(i.start(e+1)+i.end(e+1))/2?-1:1;let s=i.index(e)+(r>0?1:0);let l=i.node(e),o=false;if(t==1){o=l.canReplace(s,s,n)}else{let t=l.contentMatchAt(s).findWrapping(n.firstChild.type);o=t&&l.canReplaceWith(s,s,t[0])}if(o)return r==0?i.pos:r<0?i.before(e+1):i.after(e+1)}}return null}function Bi(t,e,r=e,i=Ee.empty){if(e==r&&!i.size)return null;let n=t.resolve(e),s=t.resolve(r);if(Ri(n,s,i))return new si(e,r,i);return new ji(n,s,i).fit()}function Ri(t,e,r){return!r.openStart&&!r.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),r.content)}class ji{constructor(t,e,r){this.$from=t;this.$to=e;this.unplaced=r;this.frontier=[];this.placed=be.empty;for(let e=0;e<=t.depth;e++){let r=t.node(e);this.frontier.push({type:r.type,match:r.contentMatchAt(t.indexAfter(e))})}for(let e=t.depth;e>0;e--)this.placed=be.from(t.node(e).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){while(this.unplaced.size){let t=this.findFittable();if(t)this.placeNodes(t);else this.openMore()||this.dropNode()}let t=this.mustMoveInline(),e=this.placed.size-this.depth-this.$from.depth;let r=this.$from,i=this.close(t<0?this.$to:r.doc.resolve(t));if(!i)return null;let n=this.placed,s=r.depth,l=i.depth;while(s&&l&&n.childCount==1){n=n.firstChild.content;s--;l--}let o=new Ee(n,s,l);if(t>-1)return new li(r.pos,t,this.$to.pos,this.$to.end(),o,e);if(o.size||r.pos!=this.$to.pos)return new si(r.pos,i.pos,o);return null}findFittable(){let t=this.unplaced.openStart;for(let e=this.unplaced.content,r=0,i=this.unplaced.openEnd;r<t;r++){let n=e.firstChild;if(e.childCount>1)i=0;if(n.type.spec.isolating&&i<=r){t=r;break}e=n.content}for(let e=1;e<=2;e++){for(let r=e==1?t:this.unplaced.openStart;r>=0;r--){let t,i=null;if(r){i=Ti(this.unplaced.content,r-1).firstChild;t=i.content}else{t=this.unplaced.content}let n=t.firstChild;for(let t=this.depth;t>=0;t--){let{type:s,match:l}=this.frontier[t],o,u=null;if(e==1&&(n?l.matchType(n.type)||(u=l.fillBefore(be.from(n),false)):i&&s.compatibleContent(i.type)))return{sliceDepth:r,frontierDepth:t,parent:i,inject:u};else if(e==2&&n&&(o=l.findWrapping(n.type)))return{sliceDepth:r,frontierDepth:t,parent:i,wrap:o};if(i&&l.matchType(i.type))break}}}}openMore(){let{content:t,openStart:e,openEnd:r}=this.unplaced;let i=Ti(t,e);if(!i.childCount||i.firstChild.isLeaf)return false;this.unplaced=new Ee(t,e+1,Math.max(r,i.size+e>=t.size-r?e+1:0));return true}dropNode(){let{content:t,openStart:e,openEnd:r}=this.unplaced;let i=Ti(t,e);if(i.childCount<=1&&e>0){let n=t.size-e<=e+i.size;this.unplaced=new Ee(Ni(t,e-1,1),e-1,n?e-1:r)}else{this.unplaced=new Ee(Ni(t,e,1),e,r)}}placeNodes({sliceDepth:t,frontierDepth:e,parent:r,inject:i,wrap:n}){while(this.depth>e)this.closeFrontierNode();if(n)for(let t=0;t<n.length;t++)this.openFrontierNode(n[t]);let s=this.unplaced,l=r?r.content:s.content;let o=s.openStart-t;let u=0,f=[];let{match:h,type:a}=this.frontier[e];if(i){for(let t=0;t<i.childCount;t++)f.push(i.child(t));h=h.matchFragment(i)}let c=l.size+t-(s.content.size-s.openEnd);while(u<l.childCount){let t=l.child(u),e=h.matchType(t.type);if(!e)break;u++;if(u>1||o==0||t.content.size){h=e;f.push(zi(t.mark(a.allowedMarks(t.marks)),u==1?o:0,u==l.childCount?c:-1))}}let d=u==l.childCount;if(!d)c=-1;this.placed=qi(this.placed,e,be.from(f));this.frontier[e].match=h;if(d&&c<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1)this.closeFrontierNode();for(let t=0,e=l;t<c;t++){let t=e.lastChild;this.frontier.push({type:t.type,match:t.contentMatchAt(t.childCount)});e=t.content}this.unplaced=!d?new Ee(Ni(s.content,t,u),s.openStart,s.openEnd):t==0?Ee.empty:new Ee(Ni(s.content,t-1,1),t-1,c<0?s.openEnd:t-1)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let t=this.frontier[this.depth],e;if(!t.type.isTextblock||!Ii(this.$to,this.$to.depth,t.type,t.match,false)||this.$to.depth==this.depth&&(e=this.findCloseLevel(this.$to))&&e.depth==this.depth)return-1;let{depth:r}=this.$to,i=this.$to.after(r);while(r>1&&i==this.$to.end(--r))++i;return i}findCloseLevel(t){t:for(let e=Math.min(this.depth,t.depth);e>=0;e--){let{match:r,type:i}=this.frontier[e];let n=e<t.depth&&t.end(e+1)==t.pos+(t.depth-(e+1));let s=Ii(t,e,i,r,n);if(!s)continue;for(let r=e-1;r>=0;r--){let{match:e,type:i}=this.frontier[r];let n=Ii(t,r,i,e,true);if(!n||n.childCount)continue t}return{depth:e,fit:s,move:n?t.doc.resolve(t.after(e+1)):t}}}close(t){let e=this.findCloseLevel(t);if(!e)return null;while(this.depth>e.depth)this.closeFrontierNode();if(e.fit.childCount)this.placed=qi(this.placed,e.depth,e.fit);t=e.move;for(let r=e.depth+1;r<=t.depth;r++){let e=t.node(r),i=e.type.contentMatch.fillBefore(e.content,true,t.index(r));this.openFrontierNode(e.type,e.attrs,i)}return t}openFrontierNode(t,e=null,r){let i=this.frontier[this.depth];i.match=i.match.matchType(t);this.placed=qi(this.placed,this.depth,be.from(t.create(e,r)));this.frontier.push({type:t,match:t.contentMatch})}closeFrontierNode(){let t=this.frontier.pop();let e=t.match.fillBefore(be.empty,true);if(e.childCount)this.placed=qi(this.placed,this.frontier.length,e)}}function Ni(t,e,r){if(e==0)return t.cutByIndex(r,t.childCount);return t.replaceChild(0,t.firstChild.copy(Ni(t.firstChild.content,e-1,r)))}function qi(t,e,r){if(e==0)return t.append(r);return t.replaceChild(t.childCount-1,t.lastChild.copy(qi(t.lastChild.content,e-1,r)))}function Ti(t,e){for(let r=0;r<e;r++)t=t.firstChild.content;return t}function zi(t,e,r){if(e<=0)return t;let i=t.content;if(e>1)i=i.replaceChild(0,zi(i.firstChild,e-1,i.childCount==1?r-1:0));if(e>0){i=t.type.contentMatch.fillBefore(i).append(i);if(r<=0)i=i.append(t.type.contentMatch.matchFragment(i).fillBefore(be.empty,true))}return t.copy(i)}function Ii(t,e,r,i,n){let s=t.node(e),l=n?t.indexAfter(e):t.index(e);if(l==s.childCount&&!r.compatibleContent(s.type))return null;let o=i.fillBefore(s.content,true,l);return o&&!Pi(r,s.content,l)?o:null}function Pi(t,e,r){for(let i=r;i<e.childCount;i++)if(!t.allowsMarks(e.child(i).marks))return true;return false}function Ji(t){return t.spec.defining||t.spec.definingForContent}function Li(t,e,r,i){if(!i.size)return t.deleteRange(e,r);let n=t.doc.resolve(e),s=t.doc.resolve(r);if(Ri(n,s,i))return t.step(new si(e,r,i));let l=Zi(n,t.doc.resolve(r));if(l[l.length-1]==0)l.pop();let o=-(n.depth+1);l.unshift(o);for(let t=n.depth,e=n.pos-1;t>0;t--,e--){let r=n.node(t).type.spec;if(r.defining||r.definingAsContext||r.isolating)break;if(l.indexOf(t)>-1)o=t;else if(n.before(t)==e)l.splice(1,0,-t)}let u=l.indexOf(o);let f=[],h=i.openStart;for(let t=i.content,e=0;;e++){let r=t.firstChild;f.push(r);if(e==i.openStart)break;t=r.content}for(let t=h-1;t>=0;t--){let e=f[t],r=Ji(e.type);if(r&&!e.sameMarkup(n.node(Math.abs(o)-1)))h=t;else if(r||!e.type.isTextblock)break}for(let e=i.openStart;e>=0;e--){let o=(e+h+1)%(i.openStart+1);let a=f[o];if(!a)continue;for(let e=0;e<l.length;e++){let f=l[(e+u)%l.length],h=true;if(f<0){h=false;f=-f}let c=n.node(f-1),d=n.index(f-1);if(c.canReplaceWith(d,d,a.type,a.marks))return t.replace(n.before(f),h?s.after(f):r,new Ee(Wi(i.content,0,i.openStart,o),o,i.openEnd))}}let a=t.steps.length;for(let o=l.length-1;o>=0;o--){t.replace(e,r,i);if(t.steps.length>a)break;let u=l[o];if(u<0)continue;e=n.before(u);r=s.after(u)}}function Wi(t,e,r,i,n){if(e<r){let n=t.firstChild;t=t.replaceChild(0,n.copy(Wi(n.content,e+1,r,i,n)))}if(e>i){let e=n.contentMatchAt(0);let r=e.fillBefore(t).append(t);t=r.append(e.matchFragment(r).fillBefore(be.empty,true))}return t}function Ui(t,e,r,i){if(!i.isInline&&e==r&&t.doc.resolve(e).parent.content.size){let n=$i(t.doc,e,i.type);if(n!=null)e=r=n}t.replaceRange(e,r,new Ee(be.from(i),0,0))}function Hi(t,e,r){let i=t.doc.resolve(e),n=t.doc.resolve(r);let s=Zi(i,n);for(let e=0;e<s.length;e++){let r=s[e],l=e==s.length-1;if(l&&r==0||i.node(r).type.contentMatch.validEnd)return t.delete(i.start(r),n.end(r));if(r>0&&(l||i.node(r-1).canReplace(i.index(r-1),n.indexAfter(r-1))))return t.delete(i.before(r),n.after(r))}for(let s=1;s<=i.depth&&s<=n.depth;s++){if(e-i.start(s)==i.depth-s&&r>i.end(s)&&n.end(s)-r!=n.depth-s&&i.start(s-1)==n.start(s-1)&&i.node(s-1).canReplace(i.index(s-1),n.index(s-1)))return t.delete(i.before(s),r)}t.delete(e,r)}function Zi(t,e){let r=[],i=Math.min(t.depth,e.depth);for(let n=i;n>=0;n--){let i=t.start(n);if(i<t.pos-(t.depth-n)||e.end(n)>e.pos+(e.depth-n)||t.node(n).type.spec.isolating||e.node(n).type.spec.isolating)break;if(i==e.start(n)||n==t.depth&&n==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&n&&e.start(n-1)==i-1)r.push(n)}return r}class Ki extends Yr{constructor(t,e,r){super();this.pos=t;this.attr=e;this.value=r}apply(t){let e=t.nodeAt(this.pos);if(!e)return Qr.fail("No node at attribute step's position");let r=Object.create(null);for(let t in e.attrs)r[t]=e.attrs[t];r[this.attr]=this.value;let i=e.type.create(r,null,e.marks);return Qr.fromReplace(t,this.pos,this.pos+1,new Ee(be.from(i),0,e.isLeaf?0:1))}getMap(){return Vr.empty}invert(t){return new Ki(this.pos,this.attr,t.nodeAt(this.pos).attrs[this.attr])}map(t){let e=t.mapResult(this.pos,1);return e.deletedAfter?null:new Ki(e.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(t,e){if(typeof e.pos!="number"||typeof e.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new Ki(e.pos,e.attr,e.value)}}Yr.jsonID("attr",Ki);class Vi extends Yr{constructor(t,e){super();this.attr=t;this.value=e}apply(t){let e=Object.create(null);for(let r in t.attrs)e[r]=t.attrs[r];e[this.attr]=this.value;let r=t.type.create(e,t.content,t.marks);return Qr.ok(r)}getMap(){return Vr.empty}invert(t){return new Vi(this.attr,t.attrs[this.attr])}map(t){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(t,e){if(typeof e.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new Vi(e.attr,e.value)}}Yr.jsonID("docAttr",Vi);let Gi=class extends Error{};Gi=function t(e){let r=Error.call(this,e);r.__proto__=t.prototype;return r};Gi.prototype=Object.create(Error.prototype);Gi.prototype.constructor=Gi;Gi.prototype.name="TransformError";class Xi{constructor(t){this.doc=t;this.steps=[];this.docs=[];this.mapping=new Gr}get before(){return this.docs.length?this.docs[0]:this.doc}step(t){let e=this.maybeStep(t);if(e.failed)throw new Gi(e.failed);return this}maybeStep(t){let e=t.apply(this.doc);if(!e.failed)this.addStep(t,e.doc);return e}get docChanged(){return this.steps.length>0}addStep(t,e){this.docs.push(this.doc);this.steps.push(t);this.mapping.appendMap(t.getMap());this.doc=e}replace(t,e=t,r=Ee.empty){let i=Bi(this.doc,t,e,r);if(i)this.step(i);return this}replaceWith(t,e,r){return this.replace(t,e,new Ee(be.from(r),0,0))}delete(t,e){return this.replace(t,e,Ee.empty)}insert(t,e){return this.replaceWith(t,t,e)}replaceRange(t,e,r){Li(this,t,e,r);return this}replaceRangeWith(t,e,r){Ui(this,t,e,r);return this}deleteRange(t,e){Hi(this,t,e);return this}lift(t,e){di(this,t,e);return this}join(t,e=1){Oi(this,t,e);return this}wrap(t,e){bi(this,t,e);return this}setBlockType(t,e=t,r,i=null){ki(this,t,e,r,i);return this}setNodeMarkup(t,e,r=null,i){Fi(this,t,e,r,i);return this}setNodeAttribute(t,e,r){this.step(new Ki(t,e,r));return this}setDocAttribute(t,e){this.step(new Vi(t,e));return this}addNodeMark(t,e){this.step(new ii(t,e));return this}removeNodeMark(t,e){if(!(e instanceof ye)){let r=this.doc.nodeAt(t);if(!r)throw new RangeError("No node at position "+t);e=e.isInSet(r.marks);if(!e)return this}this.step(new ni(t,e));return this}split(t,e=1,r){Mi(this,t,e,r);return this}addMark(t,e,r){ui(this,t,e,r);return this}removeMark(t,e,r){fi(this,t,e,r);return this}clearIncompatible(t,e,r){hi(this,t,e,r);return this}}const Yi=Object.create(null);class Qi{constructor(t,e,r){this.$anchor=t;this.$head=e;this.ranges=r||[new tn(t.min(e),t.max(e))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let t=this.ranges;for(let e=0;e<t.length;e++)if(t[e].$from.pos!=t[e].$to.pos)return false;return true}content(){return this.$from.doc.slice(this.from,this.to,true)}replace(t,e=Ee.empty){let r=e.content.lastChild,i=null;for(let t=0;t<e.openEnd;t++){i=r;r=r.lastChild}let n=t.steps.length,s=this.ranges;for(let l=0;l<s.length;l++){let{$from:o,$to:u}=s[l],f=t.mapping.slice(n);t.replaceRange(f.map(o.pos),f.map(u.pos),l?Ee.empty:e);if(l==0)an(t,n,(r?r.isInline:i&&i.isTextblock)?-1:1)}}replaceWith(t,e){let r=t.steps.length,i=this.ranges;for(let n=0;n<i.length;n++){let{$from:s,$to:l}=i[n],o=t.mapping.slice(r);let u=o.map(s.pos),f=o.map(l.pos);if(n){t.deleteRange(u,f)}else{t.replaceRangeWith(u,f,e);an(t,r,e.isInline?-1:1)}}}static findFrom(t,e,r=false){let i=t.parent.inlineContent?new nn(t):hn(t.node(0),t.parent,t.pos,t.index(),e,r);if(i)return i;for(let i=t.depth-1;i>=0;i--){let n=e<0?hn(t.node(0),t.node(i),t.before(i+1),t.index(i),e,r):hn(t.node(0),t.node(i),t.after(i+1),t.index(i)+1,e,r);if(n)return n}return null}static near(t,e=1){return this.findFrom(t,e)||this.findFrom(t,-e)||new un(t.node(0))}static atStart(t){return hn(t,t,0,0,1)||new un(t)}static atEnd(t){return hn(t,t,t.content.size,t.childCount,-1)||new un(t)}static fromJSON(t,e){if(!e||!e.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Yi[e.type];if(!r)throw new RangeError(`No selection type ${e.type} defined`);return r.fromJSON(t,e)}static jsonID(t,e){if(t in Yi)throw new RangeError("Duplicate use of selection JSON ID "+t);Yi[t]=e;e.prototype.jsonID=t;return e}getBookmark(){return nn.between(this.$anchor,this.$head).getBookmark()}}Qi.prototype.visible=true;class tn{constructor(t,e){this.$from=t;this.$to=e}}let en=false;function rn(t){if(!en&&!t.parent.inlineContent){en=true;console["warn"]("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")")}}class nn extends Qi{constructor(t,e=t){rn(t);rn(e);super(t,e)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(t,e){let r=t.resolve(e.map(this.head));if(!r.parent.inlineContent)return Qi.near(r);let i=t.resolve(e.map(this.anchor));return new nn(i.parent.inlineContent?i:r,r)}replace(t,e=Ee.empty){super.replace(t,e);if(e==Ee.empty){let e=this.$from.marksAcross(this.$to);if(e)t.ensureMarks(e)}}eq(t){return t instanceof nn&&t.anchor==this.anchor&&t.head==this.head}getBookmark(){return new sn(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(t,e){if(typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new nn(t.resolve(e.anchor),t.resolve(e.head))}static create(t,e,r=e){let i=t.resolve(e);return new this(i,r==e?i:t.resolve(r))}static between(t,e,r){let i=t.pos-e.pos;if(!r||i)r=i>=0?1:-1;if(!e.parent.inlineContent){let t=Qi.findFrom(e,r,true)||Qi.findFrom(e,-r,true);if(t)e=t.$head;else return Qi.near(e,r)}if(!t.parent.inlineContent){if(i==0){t=e}else{t=(Qi.findFrom(t,-r,true)||Qi.findFrom(t,r,true)).$anchor;if(t.pos<e.pos!=i<0)t=e}}return new nn(t,e)}}Qi.jsonID("text",nn);class sn{constructor(t,e){this.anchor=t;this.head=e}map(t){return new sn(t.map(this.anchor),t.map(this.head))}resolve(t){return nn.between(t.resolve(this.anchor),t.resolve(this.head))}}class ln extends Qi{constructor(t){let e=t.nodeAfter;let r=t.node(0).resolve(t.pos+e.nodeSize);super(t,r);this.node=e}map(t,e){let{deleted:r,pos:i}=e.mapResult(this.anchor);let n=t.resolve(i);if(r)return Qi.near(n);return new ln(n)}content(){return new Ee(be.from(this.node),0,0)}eq(t){return t instanceof ln&&t.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new on(this.anchor)}static fromJSON(t,e){if(typeof e.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new ln(t.resolve(e.anchor))}static create(t,e){return new ln(t.resolve(e))}static isSelectable(t){return!t.isText&&t.type.spec.selectable!==false}}ln.prototype.visible=false;Qi.jsonID("node",ln);class on{constructor(t){this.anchor=t}map(t){let{deleted:e,pos:r}=t.mapResult(this.anchor);return e?new sn(r,r):new on(r)}resolve(t){let e=t.resolve(this.anchor),r=e.nodeAfter;if(r&&ln.isSelectable(r))return new ln(e);return Qi.near(e)}}class un extends Qi{constructor(t){super(t.resolve(0),t.resolve(t.content.size))}replace(t,e=Ee.empty){if(e==Ee.empty){t.delete(0,t.doc.content.size);let e=Qi.atStart(t.doc);if(!e.eq(t.selection))t.setSelection(e)}else{super.replace(t,e)}}toJSON(){return{type:"all"}}static fromJSON(t){return new un(t)}map(t){return new un(t)}eq(t){return t instanceof un}getBookmark(){return fn}}Qi.jsonID("all",un);const fn={map(){return this},resolve(t){return new un(t)}};function hn(t,e,r,i,n,s=false){if(e.inlineContent)return nn.create(t,r);for(let l=i-(n>0?0:1);n>0?l<e.childCount:l>=0;l+=n){let i=e.child(l);if(!i.isAtom){let e=hn(t,i,r+n,n<0?i.childCount:0,n,s);if(e)return e}else if(!s&&ln.isSelectable(i)){return ln.create(t,r-(n<0?i.nodeSize:0))}r+=i.nodeSize*n}return null}function an(t,e,r){let i=t.steps.length-1;if(i<e)return;let n=t.steps[i];if(!(n instanceof si||n instanceof li))return;let s=t.mapping.maps[i],l;s.forEach(((t,e,r,i)=>{if(l==null)l=i}));t.setSelection(Qi.near(t.doc.resolve(l),r))}const cn=1,dn=2,pn=4;class mn extends Xi{constructor(t){super(t.doc);this.curSelectionFor=0;this.updated=0;this.meta=Object.create(null);this.time=Date.now();this.curSelection=t.selection;this.storedMarks=t.storedMarks}get selection(){if(this.curSelectionFor<this.steps.length){this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor));this.curSelectionFor=this.steps.length}return this.curSelection}setSelection(t){if(t.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");this.curSelection=t;this.curSelectionFor=this.steps.length;this.updated=(this.updated|cn)&~dn;this.storedMarks=null;return this}get selectionSet(){return(this.updated&cn)>0}setStoredMarks(t){this.storedMarks=t;this.updated|=dn;return this}ensureMarks(t){if(!ye.sameSet(this.storedMarks||this.selection.$from.marks(),t))this.setStoredMarks(t);return this}addStoredMark(t){return this.ensureMarks(t.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(t){return this.ensureMarks(t.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&dn)>0}addStep(t,e){super.addStep(t,e);this.updated=this.updated&~dn;this.storedMarks=null}setTime(t){this.time=t;return this}replaceSelection(t){this.selection.replace(this,t);return this}replaceSelectionWith(t,e=true){let r=this.selection;if(e)t=t.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||ye.none));r.replaceWith(this,t);return this}deleteSelection(){this.selection.replace(this);return this}insertText(t,e,r){let i=this.doc.type.schema;if(e==null){if(!t)return this.deleteSelection();return this.replaceSelectionWith(i.text(t),true)}else{if(r==null)r=e;r=r==null?e:r;if(!t)return this.deleteRange(e,r);let n=this.storedMarks;if(!n){let t=this.doc.resolve(e);n=r==e?t.marks():t.marksAcross(this.doc.resolve(r))}this.replaceRangeWith(e,r,i.text(t,n));if(!this.selection.empty)this.setSelection(Qi.near(this.selection.$to));return this}}setMeta(t,e){this.meta[typeof t=="string"?t:t.key]=e;return this}getMeta(t){return this.meta[typeof t=="string"?t:t.key]}get isGeneric(){for(let t in this.meta)return false;return true}scrollIntoView(){this.updated|=pn;return this}get scrolledIntoView(){return(this.updated&pn)>0}}function wn(t,e){return!e||!t?t:t.bind(e)}class gn{constructor(t,e,r){this.name=t;this.init=wn(e.init,r);this.apply=wn(e.apply,r)}}const bn=[new gn("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new gn("selection",{init(t,e){return t.selection||Qi.atStart(e.doc)},apply(t){return t.selection}}),new gn("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,r,i){return i.selection.$cursor?t.storedMarks:null}}),new gn("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class kn{constructor(t,e){this.schema=t;this.plugins=[];this.pluginsByKey=Object.create(null);this.fields=bn.slice();if(e)e.forEach((t=>{if(this.pluginsByKey[t.key])throw new RangeError("Adding different instances of a keyed plugin ("+t.key+")");this.plugins.push(t);this.pluginsByKey[t.key]=t;if(t.spec.state)this.fields.push(new gn(t.key,t.spec.state,t))}))}}class Dn{constructor(t){this.config=t}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(t){return this.applyTransaction(t).state}filterTransaction(t,e=-1){for(let r=0;r<this.config.plugins.length;r++)if(r!=e){let e=this.config.plugins[r];if(e.spec.filterTransaction&&!e.spec.filterTransaction.call(e,t,this))return false}return true}applyTransaction(t){if(!this.filterTransaction(t))return{state:this,transactions:[]};let e=[t],r=this.applyInner(t),i=null;for(;;){let n=false;for(let s=0;s<this.config.plugins.length;s++){let l=this.config.plugins[s];if(l.spec.appendTransaction){let o=i?i[s].n:0,u=i?i[s].state:this;let f=o<e.length&&l.spec.appendTransaction.call(l,o?e.slice(o):e,u,r);if(f&&r.filterTransaction(f,s)){f.setMeta("appendedTransaction",t);if(!i){i=[];for(let t=0;t<this.config.plugins.length;t++)i.push(t<s?{state:r,n:e.length}:{state:this,n:0})}e.push(f);r=r.applyInner(f);n=true}if(i)i[s]={state:r,n:e.length}}}if(!n)return{state:r,transactions:e}}}applyInner(t){if(!t.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let e=new Dn(this.config),r=this.config.fields;for(let i=0;i<r.length;i++){let n=r[i];e[n.name]=n.apply(t,this[n.name],this,e)}return e}get tr(){return new mn(this)}static create(t){let e=new kn(t.doc?t.doc.type.schema:t.schema,t.plugins);let r=new Dn(e);for(let i=0;i<e.fields.length;i++)r[e.fields[i].name]=e.fields[i].init(t,r);return r}reconfigure(t){let e=new kn(this.schema,t.plugins);let r=e.fields,i=new Dn(e);for(let e=0;e<r.length;e++){let n=r[e].name;i[n]=this.hasOwnProperty(n)?this[n]:r[e].init(t,i)}return i}toJSON(t){let e={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks)e.storedMarks=this.storedMarks.map((t=>t.toJSON()));if(t&&typeof t=="object")for(let r in t){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let i=t[r],n=i.spec.state;if(n&&n.toJSON)e[r]=n.toJSON.call(i,this[i.key])}return e}static fromJSON(t,e,r){if(!e)throw new RangeError("Invalid input for EditorState.fromJSON");if(!t.schema)throw new RangeError("Required config field 'schema' missing");let i=new kn(t.schema,t.plugins);let n=new Dn(i);i.fields.forEach((i=>{if(i.name=="doc"){n.doc=Le.fromJSON(t.schema,e.doc)}else if(i.name=="selection"){n.selection=Qi.fromJSON(n.doc,e.selection)}else if(i.name=="storedMarks"){if(e.storedMarks)n.storedMarks=e.storedMarks.map(t.schema.markFromJSON)}else{if(r)for(let s in r){let l=r[s],o=l.spec.state;if(l.key==i.name&&o&&o.fromJSON&&Object.prototype.hasOwnProperty.call(e,s)){n[i.name]=o.fromJSON.call(l,t,e[s],n);return}}n[i.name]=i.init(t,n)}}));return n}}function vn(t,e,r){for(let i in t){let n=t[i];if(n instanceof Function)n=n.bind(e);else if(i=="handleDOMEvents")n=vn(n,e,{});r[i]=n}return r}class yn{constructor(t){this.spec=t;this.props={};if(t.props)vn(t.props,this,this.props);this.key=t.key?t.key.key:En("plugin")}getState(t){return t[this.key]}}const Fn=Object.create(null);function En(t){if(t in Fn)return t+"$"+ ++Fn[t];Fn[t]=0;return t+"$"}class Mn{constructor(t="key"){this.key=En(t)}get(t){return t.config.pluginsByKey[this.key]}getState(t){return t[this.key]}}const xn=function(t){for(var e=0;;e++){t=t.previousSibling;if(!t)return e}};const An=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let Cn=null;const Sn=function(t,e,r){let i=Cn||(Cn=document.createRange());i.setEnd(t,r==null?t.nodeValue.length:r);i.setStart(t,e||0);return i};const On=function(){Cn=null};const $n=function(t,e,r,i){return r&&(Bn(t,e,r,i,-1)||Bn(t,e,r,i,1))};const _n=/^(img|br|input|textarea|hr)$/i;function Bn(t,e,r,i,n){for(;;){if(t==r&&e==i)return true;if(e==(n<0?0:Rn(t))){let r=t.parentNode;if(!r||r.nodeType!=1||Tn(t)||_n.test(t.nodeName)||t.contentEditable=="false")return false;e=xn(t)+(n<0?0:1);t=r}else if(t.nodeType==1){t=t.childNodes[e+(n<0?-1:0)];if(t.contentEditable=="false")return false;e=n<0?Rn(t):0}else{return false}}}function Rn(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function jn(t,e){for(;;){if(t.nodeType==3&&e)return t;if(t.nodeType==1&&e>0){if(t.contentEditable=="false")return null;t=t.childNodes[e-1];e=Rn(t)}else if(t.parentNode&&!Tn(t)){e=xn(t);t=t.parentNode}else{return null}}}function Nn(t,e){for(;;){if(t.nodeType==3&&e<t.nodeValue.length)return t;if(t.nodeType==1&&e<t.childNodes.length){if(t.contentEditable=="false")return null;t=t.childNodes[e];e=0}else if(t.parentNode&&!Tn(t)){e=xn(t)+1;t=t.parentNode}else{return null}}}function qn(t,e,r){for(let i=e==0,n=e==Rn(t);i||n;){if(t==r)return true;let e=xn(t);t=t.parentNode;if(!t)return false;i=i&&e==0;n=n&&e==Rn(t)}}function Tn(t){let e;for(let r=t;r;r=r.parentNode)if(e=r.pmViewDesc)break;return e&&e.node&&e.node.isBlock&&(e.dom==t||e.contentDOM==t)}const zn=function(t){return t.focusNode&&$n(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function In(t,e){let r=document.createEvent("Event");r.initEvent("keydown",true,true);r.keyCode=t;r.key=r.code=e;return r}function Pn(t){let e=t.activeElement;while(e&&e.shadowRoot)e=e.shadowRoot.activeElement;return e}function Jn(t,e,r){if(t.caretPositionFromPoint){try{let i=t.caretPositionFromPoint(e,r);if(i)return{node:i.offsetNode,offset:Math.min(Rn(i.offsetNode),i.offset)}}catch(t){}}if(t.caretRangeFromPoint){let i=t.caretRangeFromPoint(e,r);if(i)return{node:i.startContainer,offset:Math.min(Rn(i.startContainer),i.startOffset)}}}const Ln=typeof navigator!="undefined"?navigator:null;const Wn=typeof document!="undefined"?document:null;const Un=Ln&&Ln.userAgent||"";const Hn=/Edge\/(\d+)/.exec(Un);const Zn=/MSIE \d/.exec(Un);const Kn=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Un);const Vn=!!(Zn||Kn||Hn);const Gn=Zn?document.documentMode:Kn?+Kn[1]:Hn?+Hn[1]:0;const Xn=!Vn&&/gecko\/(\d+)/i.test(Un);Xn&&+(/Firefox\/(\d+)/.exec(Un)||[0,0])[1];const Yn=!Vn&&/Chrome\/(\d+)/.exec(Un);const Qn=!!Yn;const ts=Yn?+Yn[1]:0;const es=!Vn&&!!Ln&&/Apple Computer/.test(Ln.vendor);const rs=es&&(/Mobile\/\w+/.test(Un)||!!Ln&&Ln.maxTouchPoints>2);const is=rs||(Ln?/Mac/.test(Ln.platform):false);const ns=Ln?/Win/.test(Ln.platform):false;const ss=/Android \d/.test(Un);const ls=!!Wn&&"webkitFontSmoothing"in Wn.documentElement.style;const us=ls?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function fs(t){let e=t.defaultView&&t.defaultView.visualViewport;if(e)return{left:0,right:e.width,top:0,bottom:e.height};return{left:0,right:t.documentElement.clientWidth,top:0,bottom:t.documentElement.clientHeight}}function hs(t,e){return typeof t=="number"?t:t[e]}function as(t){let e=t.getBoundingClientRect();let r=e.width/t.offsetWidth||1;let i=e.height/t.offsetHeight||1;return{left:e.left,right:e.left+t.clientWidth*r,top:e.top,bottom:e.top+t.clientHeight*i}}function cs(t,e,r){let i=t.someProp("scrollThreshold")||0,n=t.someProp("scrollMargin")||5;let s=t.dom.ownerDocument;for(let l=r||t.dom;;l=An(l)){if(!l)break;if(l.nodeType!=1)continue;let t=l;let r=t==s.body;let o=r?fs(s):as(t);let u=0,f=0;if(e.top<o.top+hs(i,"top"))f=-(o.top-e.top+hs(n,"top"));else if(e.bottom>o.bottom-hs(i,"bottom"))f=e.bottom-e.top>o.bottom-o.top?e.top+hs(n,"top")-o.top:e.bottom-o.bottom+hs(n,"bottom");if(e.left<o.left+hs(i,"left"))u=-(o.left-e.left+hs(n,"left"));else if(e.right>o.right-hs(i,"right"))u=e.right-o.right+hs(n,"right");if(u||f){if(r){s.defaultView.scrollBy(u,f)}else{let r=t.scrollLeft,i=t.scrollTop;if(f)t.scrollTop+=f;if(u)t.scrollLeft+=u;let n=t.scrollLeft-r,s=t.scrollTop-i;e={left:e.left-n,top:e.top-s,right:e.right-n,bottom:e.bottom-s}}}if(r||/^(fixed|sticky)$/.test(getComputedStyle(l).position))break}}function ds(t){let e=t.dom.getBoundingClientRect(),r=Math.max(0,e.top);let i,n;for(let s=(e.left+e.right)/2,l=r+1;l<Math.min(innerHeight,e.bottom);l+=5){let e=t.root.elementFromPoint(s,l);if(!e||e==t.dom||!t.dom.contains(e))continue;let o=e.getBoundingClientRect();if(o.top>=r-20){i=e;n=o.top;break}}return{refDOM:i,refTop:n,stack:ps(t.dom)}}function ps(t){let e=[],r=t.ownerDocument;for(let i=t;i;i=An(i)){e.push({dom:i,top:i.scrollTop,left:i.scrollLeft});if(t==r)break}return e}function ms({refDOM:t,refTop:e,stack:r}){let i=t?t.getBoundingClientRect().top:0;ws(r,i==0?0:i-e)}function ws(t,e){for(let r=0;r<t.length;r++){let{dom:i,top:n,left:s}=t[r];if(i.scrollTop!=n+e)i.scrollTop=n+e;if(i.scrollLeft!=s)i.scrollLeft=s}}let gs=null;function bs(t){if(t.setActive)return t.setActive();if(gs)return t.focus(gs);let e=ps(t);t.focus(gs==null?{get preventScroll(){gs={preventScroll:true};return true}}:undefined);if(!gs){gs=false;ws(e,0)}}function ks(t,e){let r,i=2e8,n,s=0;let l=e.top,o=e.top;let u,f;for(let h=t.firstChild,a=0;h;h=h.nextSibling,a++){let t;if(h.nodeType==1)t=h.getClientRects();else if(h.nodeType==3)t=Sn(h).getClientRects();else continue;for(let c=0;c<t.length;c++){let d=t[c];if(d.top<=l&&d.bottom>=o){l=Math.max(d.bottom,l);o=Math.min(d.top,o);let t=d.left>e.left?d.left-e.left:d.right<e.left?e.left-d.right:0;if(t<i){r=h;i=t;n=t&&r.nodeType==3?{left:d.right<e.left?d.right:d.left,top:e.top}:e;if(h.nodeType==1&&t)s=a+(e.left>=(d.left+d.right)/2?1:0);continue}}else if(d.top>e.top&&!u&&d.left<=e.left&&d.right>=e.left){u=h;f={left:Math.max(d.left,Math.min(d.right,e.left)),top:d.top}}if(!r&&(e.left>=d.right&&e.top>=d.top||e.left>=d.left&&e.top>=d.bottom))s=a+1}}if(!r&&u){r=u;n=f;i=0}if(r&&r.nodeType==3)return Ds(r,n);if(!r||i&&r.nodeType==1)return{node:t,offset:s};return ks(r,n)}function Ds(t,e){let r=t.nodeValue.length;let i=document.createRange();for(let n=0;n<r;n++){i.setEnd(t,n+1);i.setStart(t,n);let r=Cs(i,1);if(r.top==r.bottom)continue;if(vs(e,r))return{node:t,offset:n+(e.left>=(r.left+r.right)/2?1:0)}}return{node:t,offset:0}}function vs(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function ys(t,e){let r=t.parentNode;if(r&&/^li$/i.test(r.nodeName)&&e.left<t.getBoundingClientRect().left)return r;return t}function Fs(t,e,r){let{node:i,offset:n}=ks(e,r),s=-1;if(i.nodeType==1&&!i.firstChild){let t=i.getBoundingClientRect();s=t.left!=t.right&&r.left>(t.left+t.right)/2?1:-1}return t.docView.posFromDOM(i,n,s)}function Es(t,e,r,i){let n=-1;for(let r=e,s=false;;){if(r==t.dom)break;let e=t.docView.nearestDesc(r,true),l;if(!e)return null;if(e.dom.nodeType==1&&(e.node.isBlock&&e.parent||!e.contentDOM)&&((l=e.dom.getBoundingClientRect()).width||l.height)){if(e.node.isBlock&&e.parent){if(!s&&l.left>i.left||l.top>i.top)n=e.posBefore;else if(!s&&l.right<i.left||l.bottom<i.top)n=e.posAfter;s=true}if(!e.contentDOM&&n<0&&!e.node.isText){let t=e.node.isBlock?i.top<(l.top+l.bottom)/2:i.left<(l.left+l.right)/2;return t?e.posBefore:e.posAfter}}r=e.dom.parentNode}return n>-1?n:t.docView.posFromDOM(e,r,-1)}function Ms(t,e,r){let i=t.childNodes.length;if(i&&r.top<r.bottom){for(let n=Math.max(0,Math.min(i-1,Math.floor(i*(e.top-r.top)/(r.bottom-r.top))-2)),s=n;;){let r=t.childNodes[s];if(r.nodeType==1){let t=r.getClientRects();for(let i=0;i<t.length;i++){let n=t[i];if(vs(e,n))return Ms(r,e,n)}}if((s=(s+1)%i)==n)break}}return t}function xs(t,e){let r=t.dom.ownerDocument,i,n=0;let s=Jn(r,e.left,e.top);if(s)({node:i,offset:n}=s);let l=(t.root.elementFromPoint?t.root:r).elementFromPoint(e.left,e.top);let o;if(!l||!t.dom.contains(l.nodeType!=1?l.parentNode:l)){let r=t.dom.getBoundingClientRect();if(!vs(e,r))return null;l=Ms(t.dom,e,r);if(!l)return null}if(es){for(let t=l;i&&t;t=An(t))if(t.draggable)i=undefined}l=ys(l,e);if(i){if(Xn&&i.nodeType==1){n=Math.min(n,i.childNodes.length);if(n<i.childNodes.length){let t=i.childNodes[n],r;if(t.nodeName=="IMG"&&(r=t.getBoundingClientRect()).right<=e.left&&r.bottom>e.top)n++}}let r;if(ls&&n&&i.nodeType==1&&(r=i.childNodes[n-1]).nodeType==1&&r.contentEditable=="false"&&r.getBoundingClientRect().top>=e.top)n--;if(i==t.dom&&n==i.childNodes.length-1&&i.lastChild.nodeType==1&&e.top>i.lastChild.getBoundingClientRect().bottom)o=t.state.doc.content.size;else if(n==0||i.nodeType!=1||i.childNodes[n-1].nodeName!="BR")o=Es(t,i,n,e)}if(o==null)o=Fs(t,l,e);let u=t.docView.nearestDesc(l,true);return{pos:o,inside:u?u.posAtStart-u.border:-1}}function As(t){return t.top<t.bottom||t.left<t.right}function Cs(t,e){let r=t.getClientRects();if(r.length){let t=r[e<0?0:r.length-1];if(As(t))return t}return Array.prototype.find.call(r,As)||t.getBoundingClientRect()}const Ss=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Os(t,e,r){let{node:i,offset:n,atom:s}=t.docView.domFromPos(e,r<0?-1:1);let l=ls||Xn;if(i.nodeType==3){if(l&&(Ss.test(i.nodeValue)||(r<0?!n:n==i.nodeValue.length))){let t=Cs(Sn(i,n,n),r);if(Xn&&n&&/\s/.test(i.nodeValue[n-1])&&n<i.nodeValue.length){let e=Cs(Sn(i,n-1,n-1),-1);if(e.top==t.top){let r=Cs(Sn(i,n,n+1),-1);if(r.top!=t.top)return $s(r,r.left<e.left)}}return t}else{let t=n,e=n,s=r<0?1:-1;if(r<0&&!n){e++;s=-1}else if(r>=0&&n==i.nodeValue.length){t--;s=1}else if(r<0){t--}else{e++}return $s(Cs(Sn(i,t,e),s),s<0)}}let o=t.state.doc.resolve(e-(s||0));if(!o.parent.inlineContent){if(s==null&&n&&(r<0||n==Rn(i))){let t=i.childNodes[n-1];if(t.nodeType==1)return _s(t.getBoundingClientRect(),false)}if(s==null&&n<Rn(i)){let t=i.childNodes[n];if(t.nodeType==1)return _s(t.getBoundingClientRect(),true)}return _s(i.getBoundingClientRect(),r>=0)}if(s==null&&n&&(r<0||n==Rn(i))){let t=i.childNodes[n-1];let e=t.nodeType==3?Sn(t,Rn(t)-(l?0:1)):t.nodeType==1&&(t.nodeName!="BR"||!t.nextSibling)?t:null;if(e)return $s(Cs(e,1),false)}if(s==null&&n<Rn(i)){let t=i.childNodes[n];while(t.pmViewDesc&&t.pmViewDesc.ignoreForCoords)t=t.nextSibling;let e=!t?null:t.nodeType==3?Sn(t,0,l?0:1):t.nodeType==1?t:null;if(e)return $s(Cs(e,-1),true)}return $s(Cs(i.nodeType==3?Sn(i):i,-r),r>=0)}function $s(t,e){if(t.width==0)return t;let r=e?t.left:t.right;return{top:t.top,bottom:t.bottom,left:r,right:r}}function _s(t,e){if(t.height==0)return t;let r=e?t.top:t.bottom;return{top:r,bottom:r,left:t.left,right:t.right}}function Bs(t,e,r){let i=t.state,n=t.root.activeElement;if(i!=e)t.updateState(e);if(n!=t.dom)t.focus();try{return r()}finally{if(i!=e)t.updateState(i);if(n!=t.dom&&n)n.focus()}}function Rs(t,e,r){let i=e.selection;let n=r=="up"?i.$from:i.$to;return Bs(t,e,(()=>{let{node:e}=t.docView.domFromPos(n.pos,r=="up"?-1:1);for(;;){let r=t.docView.nearestDesc(e,true);if(!r)break;if(r.node.isBlock){e=r.contentDOM||r.dom;break}e=r.dom.parentNode}let i=Os(t,n.pos,1);for(let t=e.firstChild;t;t=t.nextSibling){let e;if(t.nodeType==1)e=t.getClientRects();else if(t.nodeType==3)e=Sn(t,0,t.nodeValue.length).getClientRects();else continue;for(let t=0;t<e.length;t++){let n=e[t];if(n.bottom>n.top+1&&(r=="up"?i.top-n.top>(n.bottom-i.top)*2:n.bottom-i.bottom>(i.bottom-n.top)*2))return false}}return true}))}const js=/[\u0590-\u08ac]/;function Ns(t,e,r){let{$head:i}=e.selection;if(!i.parent.isTextblock)return false;let n=i.parentOffset,s=!n,l=n==i.parent.content.size;let o=t.domSelection();if(!o)return i.pos==i.start()||i.pos==i.end();if(!js.test(i.parent.textContent)||!o.modify)return r=="left"||r=="backward"?s:l;return Bs(t,e,(()=>{let{focusNode:e,focusOffset:n,anchorNode:s,anchorOffset:l}=t.domSelectionRange();let u=o.caretBidiLevel;o.modify("move",r,"character");let f=i.depth?t.docView.domAfterPos(i.before()):t.dom;let{focusNode:h,focusOffset:a}=t.domSelectionRange();let c=h&&!f.contains(h.nodeType==1?h:h.parentNode)||e==h&&n==a;try{o.collapse(s,l);if(e&&(e!=s||n!=l)&&o.extend)o.extend(e,n)}catch(t){}if(u!=null)o.caretBidiLevel=u;return c}))}let qs=null;let Ts=null;let zs=false;function Is(t,e,r){if(qs==e&&Ts==r)return zs;qs=e;Ts=r;return zs=r=="up"||r=="down"?Rs(t,e,r):Ns(t,e,r)}const Ps=0,Js=1,Ls=2,Ws=3;class Us{constructor(t,e,r,i){this.parent=t;this.children=e;this.dom=r;this.contentDOM=i;this.dirty=Ps;r.pmViewDesc=this}matchesWidget(t){return false}matchesMark(t){return false}matchesNode(t,e,r){return false}matchesHack(t){return false}parseRule(){return null}stopEvent(t){return false}get size(){let t=0;for(let e=0;e<this.children.length;e++)t+=this.children[e].size;return t}get border(){return 0}destroy(){this.parent=undefined;if(this.dom.pmViewDesc==this)this.dom.pmViewDesc=undefined;for(let t=0;t<this.children.length;t++)this.children[t].destroy()}posBeforeChild(t){for(let e=0,r=this.posAtStart;;e++){let i=this.children[e];if(i==t)return r;r+=i.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(t,e,r){if(this.contentDOM&&this.contentDOM.contains(t.nodeType==1?t:t.parentNode)){if(r<0){let r,i;if(t==this.contentDOM){r=t.childNodes[e-1]}else{while(t.parentNode!=this.contentDOM)t=t.parentNode;r=t.previousSibling}while(r&&!((i=r.pmViewDesc)&&i.parent==this))r=r.previousSibling;return r?this.posBeforeChild(i)+i.size:this.posAtStart}else{let r,i;if(t==this.contentDOM){r=t.childNodes[e]}else{while(t.parentNode!=this.contentDOM)t=t.parentNode;r=t.nextSibling}while(r&&!((i=r.pmViewDesc)&&i.parent==this))r=r.nextSibling;return r?this.posBeforeChild(i):this.posAtEnd}}let i;if(t==this.dom&&this.contentDOM){i=e>xn(this.contentDOM)}else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM)){i=t.compareDocumentPosition(this.contentDOM)&2}else if(this.dom.firstChild){if(e==0)for(let e=t;;e=e.parentNode){if(e==this.dom){i=false;break}if(e.previousSibling)break}if(i==null&&e==t.childNodes.length)for(let e=t;;e=e.parentNode){if(e==this.dom){i=true;break}if(e.nextSibling)break}}return(i==null?r>0:i)?this.posAtEnd:this.posAtStart}nearestDesc(t,e=false){for(let r=true,i=t;i;i=i.parentNode){let n=this.getDesc(i),s;if(n&&(!e||n.node)){if(r&&(s=n.nodeDOM)&&!(s.nodeType==1?s.contains(t.nodeType==1?t:t.parentNode):s==t))r=false;else return n}}}getDesc(t){let e=t.pmViewDesc;for(let t=e;t;t=t.parent)if(t==this)return e}posFromDOM(t,e,r){for(let i=t;i;i=i.parentNode){let n=this.getDesc(i);if(n)return n.localPosFromDOM(t,e,r)}return-1}descAt(t){for(let e=0,r=0;e<this.children.length;e++){let i=this.children[e],n=r+i.size;if(r==t&&n!=r){while(!i.border&&i.children.length){for(let t=0;t<i.children.length;t++){let e=i.children[t];if(e.size){i=e;break}}}return i}if(t<n)return i.descAt(t-r-i.border);r=n}}domFromPos(t,e){if(!this.contentDOM)return{node:this.dom,offset:0,atom:t+1};let r=0,i=0;for(let e=0;r<this.children.length;r++){let n=this.children[r],s=e+n.size;if(s>t||n instanceof Ys){i=t-e;break}e=s}if(i)return this.children[r].domFromPos(i-this.children[r].border,e);for(let t;r&&!(t=this.children[r-1]).size&&t instanceof Hs&&t.side>=0;r--){}if(e<=0){let t,i=true;for(;;r--,i=false){t=r?this.children[r-1]:null;if(!t||t.dom.parentNode==this.contentDOM)break}if(t&&e&&i&&!t.border&&!t.domAtom)return t.domFromPos(t.size,e);return{node:this.contentDOM,offset:t?xn(t.dom)+1:0}}else{let t,i=true;for(;;r++,i=false){t=r<this.children.length?this.children[r]:null;if(!t||t.dom.parentNode==this.contentDOM)break}if(t&&i&&!t.border&&!t.domAtom)return t.domFromPos(0,e);return{node:this.contentDOM,offset:t?xn(t.dom):this.contentDOM.childNodes.length}}}parseRange(t,e,r=0){if(this.children.length==0)return{node:this.contentDOM,from:t,to:e,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let i=-1,n=-1;for(let s=r,l=0;;l++){let r=this.children[l],o=s+r.size;if(i==-1&&t<=o){let n=s+r.border;if(t>=n&&e<=o-r.border&&r.node&&r.contentDOM&&this.contentDOM.contains(r.contentDOM))return r.parseRange(t,e,n);t=s;for(let e=l;e>0;e--){let r=this.children[e-1];if(r.size&&r.dom.parentNode==this.contentDOM&&!r.emptyChildAt(1)){i=xn(r.dom)+1;break}t-=r.size}if(i==-1)i=0}if(i>-1&&(o>e||l==this.children.length-1)){e=o;for(let t=l+1;t<this.children.length;t++){let r=this.children[t];if(r.size&&r.dom.parentNode==this.contentDOM&&!r.emptyChildAt(-1)){n=xn(r.dom);break}e+=r.size}if(n==-1)n=this.contentDOM.childNodes.length;break}s=o}return{node:this.contentDOM,from:t,to:e,fromOffset:i,toOffset:n}}emptyChildAt(t){if(this.border||!this.contentDOM||!this.children.length)return false;let e=this.children[t<0?0:this.children.length-1];return e.size==0||e.emptyChildAt(t)}domAfterPos(t){let{node:e,offset:r}=this.domFromPos(t,0);if(e.nodeType!=1||r==e.childNodes.length)throw new RangeError("No node after pos "+t);return e.childNodes[r]}setSelection(t,e,r,i=false){let n=Math.min(t,e),s=Math.max(t,e);for(let l=0,o=0;l<this.children.length;l++){let u=this.children[l],f=o+u.size;if(n>o&&s<f)return u.setSelection(t-o-u.border,e-o-u.border,r,i);o=f}let l=this.domFromPos(t,t?-1:1);let o=e==t?l:this.domFromPos(e,e?-1:1);let u=r.root.getSelection();let f=r.domSelectionRange();let h=false;if((Xn||es)&&t==e){let{node:t,offset:e}=l;if(t.nodeType==3){h=!!(e&&t.nodeValue[e-1]=="\n");if(h&&e==t.nodeValue.length){for(let e=t,r;e;e=e.parentNode){if(r=e.nextSibling){if(r.nodeName=="BR")l=o={node:r.parentNode,offset:xn(r)+1};break}let t=e.pmViewDesc;if(t&&t.node&&t.node.isBlock)break}}}else{let r=t.childNodes[e-1];h=r&&(r.nodeName=="BR"||r.contentEditable=="false")}}if(Xn&&f.focusNode&&f.focusNode!=o.node&&f.focusNode.nodeType==1){let t=f.focusNode.childNodes[f.focusOffset];if(t&&t.contentEditable=="false")i=true}if(!(i||h&&es)&&$n(l.node,l.offset,f.anchorNode,f.anchorOffset)&&$n(o.node,o.offset,f.focusNode,f.focusOffset))return;let a=false;if((u.extend||t==e)&&!h){u.collapse(l.node,l.offset);try{if(t!=e)u.extend(o.node,o.offset);a=true}catch(t){}}if(!a){if(t>e){let t=l;l=o;o=t}let r=document.createRange();r.setEnd(o.node,o.offset);r.setStart(l.node,l.offset);u.removeAllRanges();u.addRange(r)}}ignoreMutation(t){return!this.contentDOM&&t.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(t,e){for(let r=0,i=0;i<this.children.length;i++){let n=this.children[i],s=r+n.size;if(r==s?t<=s&&e>=r:t<s&&e>r){let i=r+n.border,l=s-n.border;if(t>=i&&e<=l){this.dirty=t==r||e==s?Ls:Js;if(t==i&&e==l&&(n.contentLost||n.dom.parentNode!=this.contentDOM))n.dirty=Ws;else n.markDirty(t-i,e-i);return}else{n.dirty=n.dom==n.contentDOM&&n.dom.parentNode==this.contentDOM&&!n.children.length?Ls:Ws}}r=s}this.dirty=Ls}markParentsDirty(){let t=1;for(let e=this.parent;e;e=e.parent,t++){let r=t==1?Ls:Js;if(e.dirty<r)e.dirty=r}}get domAtom(){return false}get ignoreForCoords(){return false}isText(t){return false}}class Hs extends Us{constructor(t,e,r,i){let n,s=e.type.toDOM;if(typeof s=="function")s=s(r,(()=>{if(!n)return i;if(n.parent)return n.parent.posBeforeChild(n)}));if(!e.type.spec.raw){if(s.nodeType!=1){let t=document.createElement("span");t.appendChild(s);s=t}s.contentEditable="false";s.classList.add("ProseMirror-widget")}super(t,[],s,null);this.widget=e;this.widget=e;n=this}matchesWidget(t){return this.dirty==Ps&&t.type.eq(this.widget.type)}parseRule(){return{ignore:true}}stopEvent(t){let e=this.widget.spec.stopEvent;return e?e(t):false}ignoreMutation(t){return t.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom);super.destroy()}get domAtom(){return true}get side(){return this.widget.type.side}}class Zs extends Us{constructor(t,e,r,i){super(t,[],e,null);this.textDOM=r;this.text=i}get size(){return this.text.length}localPosFromDOM(t,e){if(t!=this.textDOM)return this.posAtStart+(e?this.size:0);return this.posAtStart+e}domFromPos(t){return{node:this.textDOM,offset:t}}ignoreMutation(t){return t.type==="characterData"&&t.target.nodeValue==t.oldValue}}class Ks extends Us{constructor(t,e,r,i,n){super(t,[],r,i);this.mark=e;this.spec=n}static create(t,e,r,i){let n=i.nodeViews[e.type.name];let s=n&&n(e,i,r);if(!s||!s.dom)s=_r.renderSpec(document,e.type.spec.toDOM(e,r),null,e.attrs);return new Ks(t,e,s.dom,s.contentDOM||s.dom,s)}parseRule(){if(this.dirty&Ws||this.mark.type.spec.reparseInView)return null;return{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(t){return this.dirty!=Ws&&this.mark.eq(t)}markDirty(t,e){super.markDirty(t,e);if(this.dirty!=Ps){let t=this.parent;while(!t.node)t=t.parent;if(t.dirty<this.dirty)t.dirty=this.dirty;this.dirty=Ps}}slice(t,e,r){let i=Ks.create(this.parent,this.mark,true,r);let n=this.children,s=this.size;if(e<s)n=ml(n,e,s,r);if(t>0)n=ml(n,0,t,r);for(let t=0;t<n.length;t++)n[t].parent=i;i.children=n;return i}ignoreMutation(t){return this.spec.ignoreMutation?this.spec.ignoreMutation(t):super.ignoreMutation(t)}destroy(){if(this.spec.destroy)this.spec.destroy();super.destroy()}}class Vs extends Us{constructor(t,e,r,i,n,s,l,o,u){super(t,[],n,s);this.node=e;this.outerDeco=r;this.innerDeco=i;this.nodeDOM=l}static create(t,e,r,i,n,s){let l=n.nodeViews[e.type.name],o;let u=l&&l(e,n,(()=>{if(!o)return s;if(o.parent)return o.parent.posBeforeChild(o)}),r,i);let f=u&&u.dom,h=u&&u.contentDOM;if(e.isText){if(!f)f=document.createTextNode(e.text);else if(f.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else if(!f){let t=_r.renderSpec(document,e.type.spec.toDOM(e),null,e.attrs);({dom:f,contentDOM:h}=t)}if(!h&&!e.isText&&f.nodeName!="BR"){if(!f.hasAttribute("contenteditable"))f.contentEditable="false";if(e.type.spec.draggable)f.draggable=true}let a=f;f=ll(f,r,e);if(u)return o=new Qs(t,e,r,i,f,h||null,a,u,n,s+1);else if(e.isText)return new Xs(t,e,r,i,f,a,n);else return new Vs(t,e,r,i,f,h||null,a,n,s+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let t={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre")t.preserveWhitespace="full";if(!this.contentDOM){t.getContent=()=>this.node.content}else if(!this.contentLost){t.contentElement=this.contentDOM}else{for(let e=this.children.length-1;e>=0;e--){let r=this.children[e];if(this.dom.contains(r.dom.parentNode)){t.contentElement=r.dom.parentNode;break}}if(!t.contentElement)t.getContent=()=>be.empty}return t}matchesNode(t,e,r){return this.dirty==Ps&&t.eq(this.node)&&ol(e,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(t,e){let r=this.node.inlineContent,i=e;let n=t.composing?this.localCompositionInfo(t,e):null;let s=n&&n.pos>-1?n:null;let l=n&&n.pos<0;let o=new fl(this,s&&s.node,t);cl(this.node,this.innerDeco,((e,n,s)=>{if(e.spec.marks)o.syncToMarks(e.spec.marks,r,t);else if(e.type.side>=0&&!s)o.syncToMarks(n==this.node.childCount?ye.none:this.node.child(n).marks,r,t);o.placeWidget(e,t,i)}),((e,s,u,f)=>{o.syncToMarks(e.marks,r,t);let h;if(o.findNodeMatch(e,s,u,f));else if(l&&t.state.selection.from>i&&t.state.selection.to<i+e.nodeSize&&(h=o.findIndexWithChild(n.node))>-1&&o.updateNodeAt(e,s,u,h,t));else if(o.updateNextNode(e,s,u,t,f,i));else{o.addNode(e,s,u,t,i)}i+=e.nodeSize}));o.syncToMarks([],r,t);if(this.node.isTextblock)o.addTextblockHacks();o.destroyRest();if(o.changed||this.dirty==Ls){if(s)this.protectLocalComposition(t,s);tl(this.contentDOM,this.children,t);if(rs)dl(this.dom)}}localCompositionInfo(t,e){let{from:r,to:i}=t.state.selection;if(!(t.state.selection instanceof nn)||r<e||i>e+this.node.content.size)return null;let n=t.input.compositionNode;if(!n||!this.dom.contains(n.parentNode))return null;if(this.node.inlineContent){let t=n.nodeValue;let s=pl(this.node.content,t,r-e,i-e);return s<0?null:{node:n,pos:s,text:t}}else{return{node:n,pos:-1,text:""}}}protectLocalComposition(t,{node:e,pos:r,text:i}){if(this.getDesc(e))return;let n=e;for(;;n=n.parentNode){if(n.parentNode==this.contentDOM)break;while(n.previousSibling)n.parentNode.removeChild(n.previousSibling);while(n.nextSibling)n.parentNode.removeChild(n.nextSibling);if(n.pmViewDesc)n.pmViewDesc=undefined}let s=new Zs(this,n,e,i);t.input.compositionNodes.push(s);this.children=ml(this.children,r,r+i.length,t,s)}update(t,e,r,i){if(this.dirty==Ws||!t.sameMarkup(this.node))return false;this.updateInner(t,e,r,i);return true}updateInner(t,e,r,i){this.updateOuterDeco(e);this.node=t;this.innerDeco=r;if(this.contentDOM)this.updateChildren(i,this.posAtStart);this.dirty=Ps}updateOuterDeco(t){if(ol(t,this.outerDeco))return;let e=this.nodeDOM.nodeType!=1;let r=this.dom;this.dom=nl(this.dom,this.nodeDOM,il(this.outerDeco,this.node,e),il(t,this.node,e));if(this.dom!=r){r.pmViewDesc=undefined;this.dom.pmViewDesc=this}this.outerDeco=t}selectNode(){if(this.nodeDOM.nodeType==1)this.nodeDOM.classList.add("ProseMirror-selectednode");if(this.contentDOM||!this.node.type.spec.draggable)this.dom.draggable=true}deselectNode(){if(this.nodeDOM.nodeType==1){this.nodeDOM.classList.remove("ProseMirror-selectednode");if(this.contentDOM||!this.node.type.spec.draggable)this.dom.removeAttribute("draggable")}}get domAtom(){return this.node.isAtom}}function Gs(t,e,r,i,n){ll(i,e,t);let s=new Vs(undefined,t,e,r,i,i,i,n,0);if(s.contentDOM)s.updateChildren(n,0);return s}class Xs extends Vs{constructor(t,e,r,i,n,s,l){super(t,e,r,i,n,null,s,l,0)}parseRule(){let t=this.nodeDOM.parentNode;while(t&&t!=this.dom&&!t.pmIsDeco)t=t.parentNode;return{skip:t||true}}update(t,e,r,i){if(this.dirty==Ws||this.dirty!=Ps&&!this.inParent()||!t.sameMarkup(this.node))return false;this.updateOuterDeco(e);if((this.dirty!=Ps||t.text!=this.node.text)&&t.text!=this.nodeDOM.nodeValue){this.nodeDOM.nodeValue=t.text;if(i.trackWrites==this.nodeDOM)i.trackWrites=null}this.node=t;this.dirty=Ps;return true}inParent(){let t=this.parent.contentDOM;for(let e=this.nodeDOM;e;e=e.parentNode)if(e==t)return true;return false}domFromPos(t){return{node:this.nodeDOM,offset:t}}localPosFromDOM(t,e,r){if(t==this.nodeDOM)return this.posAtStart+Math.min(e,this.node.text.length);return super.localPosFromDOM(t,e,r)}ignoreMutation(t){return t.type!="characterData"&&t.type!="selection"}slice(t,e,r){let i=this.node.cut(t,e),n=document.createTextNode(i.text);return new Xs(this.parent,i,this.outerDeco,this.innerDeco,n,n,r)}markDirty(t,e){super.markDirty(t,e);if(this.dom!=this.nodeDOM&&(t==0||e==this.nodeDOM.nodeValue.length))this.dirty=Ws}get domAtom(){return false}isText(t){return this.node.text==t}}class Ys extends Us{parseRule(){return{ignore:true}}matchesHack(t){return this.dirty==Ps&&this.dom.nodeName==t}get domAtom(){return true}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class Qs extends Vs{constructor(t,e,r,i,n,s,l,o,u,f){super(t,e,r,i,n,s,l,u,f);this.spec=o}update(t,e,r,i){if(this.dirty==Ws)return false;if(this.spec.update&&(this.node.type==t.type||this.spec.multiType)){let n=this.spec.update(t,e,r);if(n)this.updateInner(t,e,r,i);return n}else if(!this.contentDOM&&!t.isLeaf){return false}else{return super.update(t,e,r,i)}}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(t,e,r,i){this.spec.setSelection?this.spec.setSelection(t,e,r.root):super.setSelection(t,e,r,i)}destroy(){if(this.spec.destroy)this.spec.destroy();super.destroy()}stopEvent(t){return this.spec.stopEvent?this.spec.stopEvent(t):false}ignoreMutation(t){return this.spec.ignoreMutation?this.spec.ignoreMutation(t):super.ignoreMutation(t)}}function tl(t,e,r){let i=t.firstChild,n=false;for(let s=0;s<e.length;s++){let l=e[s],o=l.dom;if(o.parentNode==t){while(o!=i){i=ul(i);n=true}i=i.nextSibling}else{n=true;t.insertBefore(o,i)}if(l instanceof Ks){let e=i?i.previousSibling:t.lastChild;tl(l.contentDOM,l.children,r);i=e?e.nextSibling:t.firstChild}}while(i){i=ul(i);n=true}if(n&&r.trackWrites==t)r.trackWrites=null}const el=function(t){if(t)this.nodeName=t};el.prototype=Object.create(null);const rl=[new el];function il(t,e,r){if(t.length==0)return rl;let i=r?rl[0]:new el,n=[i];for(let s=0;s<t.length;s++){let l=t[s].type.attrs;if(!l)continue;if(l.nodeName)n.push(i=new el(l.nodeName));for(let t in l){let s=l[t];if(s==null)continue;if(r&&n.length==1)n.push(i=new el(e.isInline?"span":"div"));if(t=="class")i.class=(i.class?i.class+" ":"")+s;else if(t=="style")i.style=(i.style?i.style+";":"")+s;else if(t!="nodeName")i[t]=s}}return n}function nl(t,e,r,i){if(r==rl&&i==rl)return e;let n=e;for(let e=0;e<i.length;e++){let s=i[e],l=r[e];if(e){let e;if(l&&l.nodeName==s.nodeName&&n!=t&&(e=n.parentNode)&&e.nodeName.toLowerCase()==s.nodeName){n=e}else{e=document.createElement(s.nodeName);e.pmIsDeco=true;e.appendChild(n);l=rl[0];n=e}}sl(n,l||rl[0],s)}return n}function sl(t,e,r){for(let i in e)if(i!="class"&&i!="style"&&i!="nodeName"&&!(i in r))t.removeAttribute(i);for(let i in r)if(i!="class"&&i!="style"&&i!="nodeName"&&r[i]!=e[i])t.setAttribute(i,r[i]);if(e.class!=r.class){let i=e.class?e.class.split(" ").filter(Boolean):[];let n=r.class?r.class.split(" ").filter(Boolean):[];for(let e=0;e<i.length;e++)if(n.indexOf(i[e])==-1)t.classList.remove(i[e]);for(let e=0;e<n.length;e++)if(i.indexOf(n[e])==-1)t.classList.add(n[e]);if(t.classList.length==0)t.removeAttribute("class")}if(e.style!=r.style){if(e.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,i;while(i=r.exec(e.style))t.style.removeProperty(i[1])}if(r.style)t.style.cssText+=r.style}}function ll(t,e,r){return nl(t,t,rl,il(e,r,t.nodeType!=1))}function ol(t,e){if(t.length!=e.length)return false;for(let r=0;r<t.length;r++)if(!t[r].type.eq(e[r].type))return false;return true}function ul(t){let e=t.nextSibling;t.parentNode.removeChild(t);return e}class fl{constructor(t,e,r){this.lock=e;this.view=r;this.index=0;this.stack=[];this.changed=false;this.top=t;this.preMatch=hl(t.node.content,t)}destroyBetween(t,e){if(t==e)return;for(let r=t;r<e;r++)this.top.children[r].destroy();this.top.children.splice(t,e-t);this.changed=true}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(t,e,r){let i=0,n=this.stack.length>>1;let s=Math.min(n,t.length);while(i<s&&(i==n-1?this.top:this.stack[i+1<<1]).matchesMark(t[i])&&t[i].type.spec.spanning!==false)i++;while(i<n){this.destroyRest();this.top.dirty=Ps;this.index=this.stack.pop();this.top=this.stack.pop();n--}while(n<t.length){this.stack.push(this.top,this.index+1);let i=-1;for(let e=this.index;e<Math.min(this.index+3,this.top.children.length);e++){let r=this.top.children[e];if(r.matchesMark(t[n])&&!this.isLocked(r.dom)){i=e;break}}if(i>-1){if(i>this.index){this.changed=true;this.destroyBetween(this.index,i)}this.top=this.top.children[this.index]}else{let i=Ks.create(this.top,t[n],e,r);this.top.children.splice(this.index,0,i);this.top=i;this.changed=true}this.index=0;n++}}findNodeMatch(t,e,r,i){let n=-1,s;if(i>=this.preMatch.index&&(s=this.preMatch.matches[i-this.preMatch.index]).parent==this.top&&s.matchesNode(t,e,r)){n=this.top.children.indexOf(s,this.index)}else{for(let i=this.index,s=Math.min(this.top.children.length,i+5);i<s;i++){let s=this.top.children[i];if(s.matchesNode(t,e,r)&&!this.preMatch.matched.has(s)){n=i;break}}}if(n<0)return false;this.destroyBetween(this.index,n);this.index++;return true}updateNodeAt(t,e,r,i,n){let s=this.top.children[i];if(s.dirty==Ws&&s.dom==s.contentDOM)s.dirty=Ls;if(!s.update(t,e,r,n))return false;this.destroyBetween(this.index,i);this.index++;return true}findIndexWithChild(t){for(;;){let e=t.parentNode;if(!e)return-1;if(e==this.top.contentDOM){let e=t.pmViewDesc;if(e)for(let t=this.index;t<this.top.children.length;t++){if(this.top.children[t]==e)return t}return-1}t=e}}updateNextNode(t,e,r,i,n,s){for(let l=this.index;l<this.top.children.length;l++){let o=this.top.children[l];if(o instanceof Vs){let u=this.preMatch.matched.get(o);if(u!=null&&u!=n)return false;let f=o.dom,h;let a=this.isLocked(f)&&!(t.isText&&o.node&&o.node.isText&&o.nodeDOM.nodeValue==t.text&&o.dirty!=Ws&&ol(e,o.outerDeco));if(!a&&o.update(t,e,r,i)){this.destroyBetween(this.index,l);if(o.dom!=f)this.changed=true;this.index++;return true}else if(!a&&(h=this.recreateWrapper(o,t,e,r,i,s))){this.destroyBetween(this.index,l);this.top.children[this.index]=h;if(h.contentDOM){h.dirty=Ls;h.updateChildren(i,s+1);h.dirty=Ps}this.changed=true;this.index++;return true}break}}return false}recreateWrapper(t,e,r,i,n,s){if(t.dirty||e.isAtom||!t.children.length||!t.node.content.eq(e.content)||!ol(r,t.outerDeco)||!i.eq(t.innerDeco))return null;let l=Vs.create(this.top,e,r,i,n,s);if(l.contentDOM){l.children=t.children;t.children=[];for(let t of l.children)t.parent=l}t.destroy();return l}addNode(t,e,r,i,n){let s=Vs.create(this.top,t,e,r,i,n);if(s.contentDOM)s.updateChildren(i,n+1);this.top.children.splice(this.index++,0,s);this.changed=true}placeWidget(t,e,r){let i=this.index<this.top.children.length?this.top.children[this.index]:null;if(i&&i.matchesWidget(t)&&(t==i.widget||!i.widget.type.toDOM.parentNode)){this.index++}else{let i=new Hs(this.top,t,e,r);this.top.children.splice(this.index++,0,i);this.changed=true}}addTextblockHacks(){let t=this.top.children[this.index-1],e=this.top;while(t instanceof Ks){e=t;t=e.children[e.children.length-1]}if(!t||!(t instanceof Xs)||/\n$/.test(t.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(t.node.text)){if((es||Qn)&&t&&t.dom.contentEditable=="false")this.addHackNode("IMG",e);this.addHackNode("BR",this.top)}}addHackNode(t,e){if(e==this.top&&this.index<e.children.length&&e.children[this.index].matchesHack(t)){this.index++}else{let r=document.createElement(t);if(t=="IMG"){r.className="ProseMirror-separator";r.alt=""}if(t=="BR")r.className="ProseMirror-trailingBreak";let i=new Ys(this.top,[],r,null);if(e!=this.top)e.children.push(i);else e.children.splice(this.index++,0,i);this.changed=true}}isLocked(t){return this.lock&&(t==this.lock||t.nodeType==1&&t.contains(this.lock.parentNode))}}function hl(t,e){let r=e,i=r.children.length;let n=t.childCount,s=new Map,l=[];t:while(n>0){let o;for(;;){if(i){let t=r.children[i-1];if(t instanceof Ks){r=t;i=t.children.length}else{o=t;i--;break}}else if(r==e){break t}else{i=r.parent.children.indexOf(r);r=r.parent}}let u=o.node;if(!u)continue;if(u!=t.child(n-1))break;--n;s.set(o,n);l.push(o)}return{index:n,matched:s,matches:l.reverse()}}function al(t,e){return t.type.side-e.type.side}function cl(t,e,r,i){let n=e.locals(t),s=0;if(n.length==0){for(let r=0;r<t.childCount;r++){let l=t.child(r);i(l,n,e.forChild(s,l),r);s+=l.nodeSize}return}let l=0,o=[],u=null;for(let f=0;;){let h,a;while(l<n.length&&n[l].to==s){let t=n[l++];if(t.widget){if(!h)h=t;else(a||(a=[h])).push(t)}}if(h){if(a){a.sort(al);for(let t=0;t<a.length;t++)r(a[t],f,!!u)}else{r(h,f,!!u)}}let c,d;if(u){d=-1;c=u;u=null}else if(f<t.childCount){d=f;c=t.child(f++)}else{break}for(let t=0;t<o.length;t++)if(o[t].to<=s)o.splice(t--,1);while(l<n.length&&n[l].from<=s&&n[l].to>s)o.push(n[l++]);let p=s+c.nodeSize;if(c.isText){let t=p;if(l<n.length&&n[l].from<t)t=n[l].from;for(let e=0;e<o.length;e++)if(o[e].to<t)t=o[e].to;if(t<p){u=c.cut(t-s);c=c.cut(0,t-s);p=t;d=-1}}else{while(l<n.length&&n[l].to<p)l++}let m=c.isInline&&!c.isLeaf?o.filter((t=>!t.inline)):o.slice();i(c,m,e.forChild(s,c),d);s=p}}function dl(t){if(t.nodeName=="UL"||t.nodeName=="OL"){let e=t.style.cssText;t.style.cssText=e+"; list-style: square !important";window.getComputedStyle(t).listStyle;t.style.cssText=e}}function pl(t,e,r,i){for(let n=0,s=0;n<t.childCount&&s<=i;){let l=t.child(n++),o=s;s+=l.nodeSize;if(!l.isText)continue;let u=l.text;while(n<t.childCount){let e=t.child(n++);s+=e.nodeSize;if(!e.isText)break;u+=e.text}if(s>=r){if(s>=i&&u.slice(i-e.length-o,i-o)==e)return i-e.length;let t=o<i?u.lastIndexOf(e,i-o-1):-1;if(t>=0&&t+e.length+o>=r)return o+t;if(r==i&&u.length>=i+e.length-o&&u.slice(i-o,i-o+e.length)==e)return i}}return-1}function ml(t,e,r,i,n){let s=[];for(let l=0,o=0;l<t.length;l++){let u=t[l],f=o,h=o+=u.size;if(f>=r||h<=e){s.push(u)}else{if(f<e)s.push(u.slice(0,e-f,i));if(n){s.push(n);n=undefined}if(h>r)s.push(u.slice(r-f,u.size,i))}}return s}function wl(t,e=null){let r=t.domSelectionRange(),i=t.state.doc;if(!r.focusNode)return null;let n=t.docView.nearestDesc(r.focusNode),s=n&&n.size==0;let l=t.docView.posFromDOM(r.focusNode,r.focusOffset,1);if(l<0)return null;let o=i.resolve(l),u,f;if(zn(r)){u=l;while(n&&!n.node)n=n.parent;let t=n.node;if(n&&t.isAtom&&ln.isSelectable(t)&&n.parent&&!(t.isInline&&qn(r.focusNode,r.focusOffset,n.dom))){let t=n.posBefore;f=new ln(l==t?o:i.resolve(t))}}else{if(r instanceof t.dom.ownerDocument.defaultView.Selection&&r.rangeCount>1){let e=l,n=l;for(let i=0;i<r.rangeCount;i++){let s=r.getRangeAt(i);e=Math.min(e,t.docView.posFromDOM(s.startContainer,s.startOffset,1));n=Math.max(n,t.docView.posFromDOM(s.endContainer,s.endOffset,-1))}if(e<0)return null;[u,l]=n==t.state.selection.anchor?[n,e]:[e,n];o=i.resolve(l)}else{u=t.docView.posFromDOM(r.anchorNode,r.anchorOffset,1)}if(u<0)return null}let h=i.resolve(u);if(!f){let r=e=="pointer"||t.state.selection.head<o.pos&&!s?1:-1;f=Al(t,h,o,r)}return f}function gl(t){return t.editable?t.hasFocus():Sl(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function bl(t,e=false){let r=t.state.selection;Ml(t,r);if(!gl(t))return;if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&Qn){let e=t.domSelectionRange(),r=t.domObserver.currentSelection;if(e.anchorNode&&r.anchorNode&&$n(e.anchorNode,e.anchorOffset,r.anchorNode,r.anchorOffset)){t.input.mouseDown.delayedSelectionSync=true;t.domObserver.setCurSelection();return}}t.domObserver.disconnectSelection();if(t.cursorWrapper){El(t)}else{let{anchor:i,head:n}=r,s,l;if(kl&&!(r instanceof nn)){if(!r.$from.parent.inlineContent)s=Dl(t,r.from);if(!r.empty&&!r.$from.parent.inlineContent)l=Dl(t,r.to)}t.docView.setSelection(i,n,t,e);if(kl){if(s)yl(s);if(l)yl(l)}if(r.visible){t.dom.classList.remove("ProseMirror-hideselection")}else{t.dom.classList.add("ProseMirror-hideselection");if("onselectionchange"in document)Fl(t)}}t.domObserver.setCurSelection();t.domObserver.connectSelection()}const kl=es||Qn&&ts<63;function Dl(t,e){let{node:r,offset:i}=t.docView.domFromPos(e,0);let n=i<r.childNodes.length?r.childNodes[i]:null;let s=i?r.childNodes[i-1]:null;if(es&&n&&n.contentEditable=="false")return vl(n);if((!n||n.contentEditable=="false")&&(!s||s.contentEditable=="false")){if(n)return vl(n);else if(s)return vl(s)}}function vl(t){t.contentEditable="true";if(es&&t.draggable){t.draggable=false;t.wasDraggable=true}return t}function yl(t){t.contentEditable="false";if(t.wasDraggable){t.draggable=true;t.wasDraggable=null}}function Fl(t){let e=t.dom.ownerDocument;e.removeEventListener("selectionchange",t.input.hideSelectionGuard);let r=t.domSelectionRange();let i=r.anchorNode,n=r.anchorOffset;e.addEventListener("selectionchange",t.input.hideSelectionGuard=()=>{if(r.anchorNode!=i||r.anchorOffset!=n){e.removeEventListener("selectionchange",t.input.hideSelectionGuard);setTimeout((()=>{if(!gl(t)||t.state.selection.visible)t.dom.classList.remove("ProseMirror-hideselection")}),20)}})}function El(t){let e=t.domSelection(),r=document.createRange();if(!e)return;let i=t.cursorWrapper.dom,n=i.nodeName=="IMG";if(n)r.setStart(i.parentNode,xn(i)+1);else r.setStart(i,0);r.collapse(true);e.removeAllRanges();e.addRange(r);if(!n&&!t.state.selection.visible&&Vn&&Gn<=11){i.disabled=true;i.disabled=false}}function Ml(t,e){if(e instanceof ln){let r=t.docView.descAt(e.from);if(r!=t.lastSelectedViewDesc){xl(t);if(r)r.selectNode();t.lastSelectedViewDesc=r}}else{xl(t)}}function xl(t){if(t.lastSelectedViewDesc){if(t.lastSelectedViewDesc.parent)t.lastSelectedViewDesc.deselectNode();t.lastSelectedViewDesc=undefined}}function Al(t,e,r,i){return t.someProp("createSelectionBetween",(i=>i(t,e,r)))||nn.between(e,r,i)}function Cl(t){if(t.editable&&!t.hasFocus())return false;return Sl(t)}function Sl(t){let e=t.domSelectionRange();if(!e.anchorNode)return false;try{return t.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(t.editable||t.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch(t){return false}}function Ol(t){let e=t.docView.domFromPos(t.state.selection.anchor,0);let r=t.domSelectionRange();return $n(e.node,e.offset,r.anchorNode,r.anchorOffset)}function $l(t,e){let{$anchor:r,$head:i}=t.selection;let n=e>0?r.max(i):r.min(i);let s=!n.parent.inlineContent?n:n.depth?t.doc.resolve(e>0?n.after():n.before()):null;return s&&Qi.findFrom(s,e)}function _l(t,e){t.dispatch(t.state.tr.setSelection(e).scrollIntoView());return true}function Bl(t,e,r){let i=t.state.selection;if(i instanceof nn){if(r.indexOf("s")>-1){let{$head:r}=i,n=r.textOffset?null:e<0?r.nodeBefore:r.nodeAfter;if(!n||n.isText||!n.isLeaf)return false;let s=t.state.doc.resolve(r.pos+n.nodeSize*(e<0?-1:1));return _l(t,new nn(i.$anchor,s))}else if(!i.empty){return false}else if(t.endOfTextblock(e>0?"forward":"backward")){let r=$l(t.state,e);if(r&&r instanceof ln)return _l(t,r);return false}else if(!(is&&r.indexOf("m")>-1)){let r=i.$head,n=r.textOffset?null:e<0?r.nodeBefore:r.nodeAfter,s;if(!n||n.isText)return false;let l=e<0?r.pos-n.nodeSize:r.pos;if(!(n.isAtom||(s=t.docView.descAt(l))&&!s.contentDOM))return false;if(ln.isSelectable(n)){return _l(t,new ln(e<0?t.state.doc.resolve(r.pos-n.nodeSize):r))}else if(ls){return _l(t,new nn(t.state.doc.resolve(e<0?l:l+n.nodeSize)))}else{return false}}}else if(i instanceof ln&&i.node.isInline){return _l(t,new nn(e>0?i.$to:i.$from))}else{let r=$l(t.state,e);if(r)return _l(t,r);return false}}function Rl(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function jl(t,e){let r=t.pmViewDesc;return r&&r.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function Nl(t,e){return e<0?ql(t):Tl(t)}function ql(t){let e=t.domSelectionRange();let r=e.focusNode,i=e.focusOffset;if(!r)return;let n,s,l=false;if(Xn&&r.nodeType==1&&i<Rl(r)&&jl(r.childNodes[i],-1))l=true;for(;;){if(i>0){if(r.nodeType!=1){break}else{let t=r.childNodes[i-1];if(jl(t,-1)){n=r;s=--i}else if(t.nodeType==3){r=t;i=r.nodeValue.length}else break}}else if(zl(r)){break}else{let e=r.previousSibling;while(e&&jl(e,-1)){n=r.parentNode;s=xn(e);e=e.previousSibling}if(!e){r=r.parentNode;if(r==t.dom)break;i=0}else{r=e;i=Rl(r)}}}if(l)Jl(t,r,i);else if(n)Jl(t,n,s)}function Tl(t){let e=t.domSelectionRange();let r=e.focusNode,i=e.focusOffset;if(!r)return;let n=Rl(r);let s,l;for(;;){if(i<n){if(r.nodeType!=1)break;let t=r.childNodes[i];if(jl(t,1)){s=r;l=++i}else break}else if(zl(r)){break}else{let e=r.nextSibling;while(e&&jl(e,1)){s=e.parentNode;l=xn(e)+1;e=e.nextSibling}if(!e){r=r.parentNode;if(r==t.dom)break;i=n=0}else{r=e;i=0;n=Rl(r)}}}if(s)Jl(t,s,l)}function zl(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function Il(t,e){while(t&&e==t.childNodes.length&&!Tn(t)){e=xn(t)+1;t=t.parentNode}while(t&&e<t.childNodes.length){let r=t.childNodes[e];if(r.nodeType==3)return r;if(r.nodeType==1&&r.contentEditable=="false")break;t=r;e=0}}function Pl(t,e){while(t&&!e&&!Tn(t)){e=xn(t);t=t.parentNode}while(t&&e){let r=t.childNodes[e-1];if(r.nodeType==3)return r;if(r.nodeType==1&&r.contentEditable=="false")break;t=r;e=t.childNodes.length}}function Jl(t,e,r){if(e.nodeType!=3){let t,i;if(i=Il(e,r)){e=i;r=0}else if(t=Pl(e,r)){e=t;r=t.nodeValue.length}}let i=t.domSelection();if(!i)return;if(zn(i)){let t=document.createRange();t.setEnd(e,r);t.setStart(e,r);i.removeAllRanges();i.addRange(t)}else if(i.extend){i.extend(e,r)}t.domObserver.setCurSelection();let{state:n}=t;setTimeout((()=>{if(t.state==n)bl(t)}),50)}function Ll(t,e){let r=t.state.doc.resolve(e);if(!(Qn||ns)&&r.parent.inlineContent){let i=t.coordsAtPos(e);if(e>r.start()){let r=t.coordsAtPos(e-1);let n=(r.top+r.bottom)/2;if(n>i.top&&n<i.bottom&&Math.abs(r.left-i.left)>1)return r.left<i.left?"ltr":"rtl"}if(e<r.end()){let r=t.coordsAtPos(e+1);let n=(r.top+r.bottom)/2;if(n>i.top&&n<i.bottom&&Math.abs(r.left-i.left)>1)return r.left>i.left?"ltr":"rtl"}}let i=getComputedStyle(t.dom).direction;return i=="rtl"?"rtl":"ltr"}function Wl(t,e,r){let i=t.state.selection;if(i instanceof nn&&!i.empty||r.indexOf("s")>-1)return false;if(is&&r.indexOf("m")>-1)return false;let{$from:n,$to:s}=i;if(!n.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let r=$l(t.state,e);if(r&&r instanceof ln)return _l(t,r)}if(!n.parent.inlineContent){let r=e<0?n:s;let l=i instanceof un?Qi.near(r,e):Qi.findFrom(r,e);return l?_l(t,l):false}return false}function Ul(t,e){if(!(t.state.selection instanceof nn))return true;let{$head:r,$anchor:i,empty:n}=t.state.selection;if(!r.sameParent(i))return true;if(!n)return false;if(t.endOfTextblock(e>0?"forward":"backward"))return true;let s=!r.textOffset&&(e<0?r.nodeBefore:r.nodeAfter);if(s&&!s.isText){let i=t.state.tr;if(e<0)i.delete(r.pos-s.nodeSize,r.pos);else i.delete(r.pos,r.pos+s.nodeSize);t.dispatch(i);return true}return false}function Hl(t,e,r){t.domObserver.stop();e.contentEditable=r;t.domObserver.start()}function Zl(t){if(!es||t.state.selection.$head.parentOffset>0)return false;let{focusNode:e,focusOffset:r}=t.domSelectionRange();if(e&&e.nodeType==1&&r==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;Hl(t,r,"true");setTimeout((()=>Hl(t,r,"false")),20)}return false}function Kl(t){let e="";if(t.ctrlKey)e+="c";if(t.metaKey)e+="m";if(t.altKey)e+="a";if(t.shiftKey)e+="s";return e}function Vl(t,e){let r=e.keyCode,i=Kl(e);if(r==8||is&&r==72&&i=="c"){return Ul(t,-1)||Nl(t,-1)}else if(r==46&&!e.shiftKey||is&&r==68&&i=="c"){return Ul(t,1)||Nl(t,1)}else if(r==13||r==27){return true}else if(r==37||is&&r==66&&i=="c"){let e=r==37?Ll(t,t.state.selection.from)=="ltr"?-1:1:-1;return Bl(t,e,i)||Nl(t,e)}else if(r==39||is&&r==70&&i=="c"){let e=r==39?Ll(t,t.state.selection.from)=="ltr"?1:-1:1;return Bl(t,e,i)||Nl(t,e)}else if(r==38||is&&r==80&&i=="c"){return Wl(t,-1,i)||Nl(t,-1)}else if(r==40||is&&r==78&&i=="c"){return Zl(t)||Wl(t,1,i)||Nl(t,1)}else if(i==(is?"m":"c")&&(r==66||r==73||r==89||r==90)){return true}return false}function Gl(t,e){t.someProp("transformCopied",(r=>{e=r(e,t)}));let r=[],{content:i,openStart:n,openEnd:s}=e;while(n>1&&s>1&&i.childCount==1&&i.firstChild.childCount==1){n--;s--;let t=i.firstChild;r.push(t.type.name,t.attrs!=t.type.defaultAttrs?t.attrs:null);i=t.content}let l=t.someProp("clipboardSerializer")||_r.fromSchema(t.state.schema);let o=oo(),u=o.createElement("div");u.appendChild(l.serializeFragment(i,{document:o}));let f=u.firstChild,h,a=0;while(f&&f.nodeType==1&&(h=so[f.nodeName.toLowerCase()])){for(let t=h.length-1;t>=0;t--){let e=o.createElement(h[t]);while(u.firstChild)e.appendChild(u.firstChild);u.appendChild(e);a++}f=u.firstChild}if(f&&f.nodeType==1)f.setAttribute("data-pm-slice",`${n} ${s}${a?` -${a}`:""} ${JSON.stringify(r)}`);let c=t.someProp("clipboardTextSerializer",(r=>r(e,t)))||e.content.textBetween(0,e.content.size,"\n\n");return{dom:u,text:c,slice:e}}function Xl(t,e,r,i,n){let s=n.parent.type.spec.code;let l,o;if(!r&&!e)return null;let u=e&&(i||s||!r);if(u){t.someProp("transformPastedText",(r=>{e=r(e,s||i,t)}));if(s)return e?new Ee(be.from(t.state.schema.text(e.replace(/\r\n?/g,"\n"))),0,0):Ee.empty;let r=t.someProp("clipboardTextParser",(r=>r(e,n,i,t)));if(r){o=r}else{let r=n.marks();let{schema:i}=t.state,s=_r.fromSchema(i);l=document.createElement("div");e.split(/(?:\r\n?|\n)+/).forEach((t=>{let e=l.appendChild(document.createElement("p"));if(t)e.appendChild(s.serializeNode(i.text(t,r)))}))}}else{t.someProp("transformPastedHTML",(e=>{r=e(r,t)}));l=ho(r);if(ls)ao(l)}let f=l&&l.querySelector("[data-pm-slice]");let h=f&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(f.getAttribute("data-pm-slice")||"");if(h&&h[3])for(let t=+h[3];t>0;t--){let t=l.firstChild;while(t&&t.nodeType!=1)t=t.nextSibling;if(!t)break;l=t}if(!o){let e=t.someProp("clipboardParser")||t.someProp("domParser")||br.fromSchema(t.state.schema);o=e.parseSlice(l,{preserveWhitespace:!!(u||h),context:n,ruleFromNode(t){if(t.nodeName=="BR"&&!t.nextSibling&&t.parentNode&&!Yl.test(t.parentNode.nodeName))return{ignore:true};return null}})}if(h){o=co(no(o,+h[1],+h[2]),h[4])}else{o=Ee.maxOpen(Ql(o.content,n),true);if(o.openStart||o.openEnd){let t=0,e=0;for(let e=o.content.firstChild;t<o.openStart&&!e.type.spec.isolating;t++,e=e.firstChild){}for(let t=o.content.lastChild;e<o.openEnd&&!t.type.spec.isolating;e++,t=t.lastChild){}o=no(o,t,e)}}t.someProp("transformPasted",(e=>{o=e(o,t)}));return o}const Yl=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function Ql(t,e){if(t.childCount<2)return t;for(let r=e.depth;r>=0;r--){let i=e.node(r);let n=i.contentMatchAt(e.index(r));let s,l=[];t.forEach((t=>{if(!l)return;let e=n.findWrapping(t.type),r;if(!e)return l=null;if(r=l.length&&s.length&&eo(e,s,t,l[l.length-1],0)){l[l.length-1]=r}else{if(l.length)l[l.length-1]=ro(l[l.length-1],s.length);let r=to(t,e);l.push(r);n=n.matchType(r.type);s=e}}));if(l)return be.from(l)}return t}function to(t,e,r=0){for(let i=e.length-1;i>=r;i--)t=e[i].create(null,be.from(t));return t}function eo(t,e,r,i,n){if(n<t.length&&n<e.length&&t[n]==e[n]){let s=eo(t,e,r,i.lastChild,n+1);if(s)return i.copy(i.content.replaceChild(i.childCount-1,s));let l=i.contentMatchAt(i.childCount);if(l.matchType(n==t.length-1?r.type:t[n+1]))return i.copy(i.content.append(be.from(to(r,t,n+1))))}}function ro(t,e){if(e==0)return t;let r=t.content.replaceChild(t.childCount-1,ro(t.lastChild,e-1));let i=t.contentMatchAt(t.childCount).fillBefore(be.empty,true);return t.copy(r.append(i))}function io(t,e,r,i,n,s){let l=e<0?t.firstChild:t.lastChild,o=l.content;if(t.childCount>1)s=0;if(n<i-1)o=io(o,e,r,i,n+1,s);if(n>=r)o=e<0?l.contentMatchAt(0).fillBefore(o,s<=n).append(o):o.append(l.contentMatchAt(l.childCount).fillBefore(be.empty,true));return t.replaceChild(e<0?0:t.childCount-1,l.copy(o))}function no(t,e,r){if(e<t.openStart)t=new Ee(io(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd);if(r<t.openEnd)t=new Ee(io(t.content,1,r,t.openEnd,0,0),t.openStart,r);return t}const so={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};let lo=null;function oo(){return lo||(lo=document.implementation.createHTMLDocument("title"))}let uo=null;function fo(t){let e=window.trustedTypes;if(!e)return t;if(!uo)uo=e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t});return uo.createHTML(t)}function ho(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);if(e)t=t.slice(e[0].length);let r=oo().createElement("div");let i=/<([a-z][^>\s]+)/i.exec(t),n;if(n=i&&so[i[1].toLowerCase()])t=n.map((t=>"<"+t+">")).join("")+t+n.map((t=>"</"+t+">")).reverse().join("");r.innerHTML=fo(t);if(n)for(let t=0;t<n.length;t++)r=r.querySelector(n[t])||r;return r}function ao(t){let e=t.querySelectorAll(Qn?"span:not([class]):not([style])":"span.Apple-converted-space");for(let r=0;r<e.length;r++){let i=e[r];if(i.childNodes.length==1&&i.textContent==" "&&i.parentNode)i.parentNode.replaceChild(t.ownerDocument.createTextNode(" "),i)}}function co(t,e){if(!t.size)return t;let r=t.content.firstChild.type.schema,i;try{i=JSON.parse(e)}catch(e){return t}let{content:n,openStart:s,openEnd:l}=t;for(let t=i.length-2;t>=0;t-=2){let e=r.nodes[i[t]];if(!e||e.hasRequiredAttrs())break;n=be.from(e.create(i[t+1],n));s++;l++}return new Ee(n,s,l)}const po={};const mo={};const wo={touchstart:true,touchmove:true};class go{constructor(){this.shiftKey=false;this.mouseDown=null;this.lastKeyCode=null;this.lastKeyCodeTime=0;this.lastClick={time:0,x:0,y:0,type:""};this.lastSelectionOrigin=null;this.lastSelectionTime=0;this.lastIOSEnter=0;this.lastIOSEnterFallbackTimeout=-1;this.lastFocus=0;this.lastTouch=0;this.lastChromeDelete=0;this.composing=false;this.compositionNode=null;this.composingTimeout=-1;this.compositionNodes=[];this.compositionEndedAt=-2e8;this.compositionID=1;this.compositionPendingChanges=0;this.domChangeCount=0;this.eventHandlers=Object.create(null);this.hideSelectionGuard=null}}function bo(t){for(let e in po){let r=po[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=e=>{if(Fo(t,e)&&!yo(t,e)&&(t.editable||!(e.type in mo)))r(t,e)},wo[e]?{passive:true}:undefined)}if(es)t.dom.addEventListener("input",(()=>null));vo(t)}function ko(t,e){t.input.lastSelectionOrigin=e;t.input.lastSelectionTime=Date.now()}function Do(t){t.domObserver.stop();for(let e in t.input.eventHandlers)t.dom.removeEventListener(e,t.input.eventHandlers[e]);clearTimeout(t.input.composingTimeout);clearTimeout(t.input.lastIOSEnterFallbackTimeout)}function vo(t){t.someProp("handleDOMEvents",(e=>{for(let r in e)if(!t.input.eventHandlers[r])t.dom.addEventListener(r,t.input.eventHandlers[r]=e=>yo(t,e))}))}function yo(t,e){return t.someProp("handleDOMEvents",(r=>{let i=r[e.type];return i?i(t,e)||e.defaultPrevented:false}))}function Fo(t,e){if(!e.bubbles)return true;if(e.defaultPrevented)return false;for(let r=e.target;r!=t.dom;r=r.parentNode)if(!r||r.nodeType==11||r.pmViewDesc&&r.pmViewDesc.stopEvent(e))return false;return true}function Eo(t,e){if(!yo(t,e)&&po[e.type]&&(t.editable||!(e.type in mo)))po[e.type](t,e)}mo.keydown=(t,e)=>{let r=e;t.input.shiftKey=r.keyCode==16||r.shiftKey;if(To(t,r))return;t.input.lastKeyCode=r.keyCode;t.input.lastKeyCodeTime=Date.now();if(ss&&Qn&&r.keyCode==13)return;if(r.keyCode!=229)t.domObserver.forceFlush();if(rs&&r.keyCode==13&&!r.ctrlKey&&!r.altKey&&!r.metaKey){let e=Date.now();t.input.lastIOSEnter=e;t.input.lastIOSEnterFallbackTimeout=setTimeout((()=>{if(t.input.lastIOSEnter==e){t.someProp("handleKeyDown",(e=>e(t,In(13,"Enter"))));t.input.lastIOSEnter=0}}),200)}else if(t.someProp("handleKeyDown",(e=>e(t,r)))||Vl(t,r)){r.preventDefault()}else{ko(t,"key")}};mo.keyup=(t,e)=>{if(e.keyCode==16)t.input.shiftKey=false};mo.keypress=(t,e)=>{let r=e;if(To(t,r)||!r.charCode||r.ctrlKey&&!r.altKey||is&&r.metaKey)return;if(t.someProp("handleKeyPress",(e=>e(t,r)))){r.preventDefault();return}let i=t.state.selection;if(!(i instanceof nn)||!i.$from.sameParent(i.$to)){let e=String.fromCharCode(r.charCode);if(!/[\r\n]/.test(e)&&!t.someProp("handleTextInput",(r=>r(t,i.$from.pos,i.$to.pos,e))))t.dispatch(t.state.tr.insertText(e).scrollIntoView());r.preventDefault()}};function Mo(t){return{left:t.clientX,top:t.clientY}}function xo(t,e){let r=e.x-t.clientX,i=e.y-t.clientY;return r*r+i*i<100}function Ao(t,e,r,i,n){if(i==-1)return false;let s=t.state.doc.resolve(i);for(let i=s.depth+1;i>0;i--){if(t.someProp(e,(e=>i>s.depth?e(t,r,s.nodeAfter,s.before(i),n,true):e(t,r,s.node(i),s.before(i),n,false))))return true}return false}function Co(t,e,r){if(!t.focused)t.focus();if(t.state.selection.eq(e))return;let i=t.state.tr.setSelection(e);if(r=="pointer")i.setMeta("pointer",true);t.dispatch(i)}function So(t,e){if(e==-1)return false;let r=t.state.doc.resolve(e),i=r.nodeAfter;if(i&&i.isAtom&&ln.isSelectable(i)){Co(t,new ln(r),"pointer");return true}return false}function Oo(t,e){if(e==-1)return false;let r=t.state.selection,i,n;if(r instanceof ln)i=r.node;let s=t.state.doc.resolve(e);for(let t=s.depth+1;t>0;t--){let e=t>s.depth?s.nodeAfter:s.node(t);if(ln.isSelectable(e)){if(i&&r.$from.depth>0&&t>=r.$from.depth&&s.before(r.$from.depth+1)==r.$from.pos)n=s.before(r.$from.depth);else n=s.before(t);break}}if(n!=null){Co(t,ln.create(t.state.doc,n),"pointer");return true}else{return false}}function $o(t,e,r,i,n){return Ao(t,"handleClickOn",e,r,i)||t.someProp("handleClick",(r=>r(t,e,i)))||(n?Oo(t,r):So(t,r))}function _o(t,e,r,i){return Ao(t,"handleDoubleClickOn",e,r,i)||t.someProp("handleDoubleClick",(r=>r(t,e,i)))}function Bo(t,e,r,i){return Ao(t,"handleTripleClickOn",e,r,i)||t.someProp("handleTripleClick",(r=>r(t,e,i)))||Ro(t,r,i)}function Ro(t,e,r){if(r.button!=0)return false;let i=t.state.doc;if(e==-1){if(i.inlineContent){Co(t,nn.create(i,0,i.content.size),"pointer");return true}return false}let n=i.resolve(e);for(let e=n.depth+1;e>0;e--){let r=e>n.depth?n.nodeAfter:n.node(e);let s=n.before(e);if(r.inlineContent)Co(t,nn.create(i,s+1,s+1+r.content.size),"pointer");else if(ln.isSelectable(r))Co(t,ln.create(i,s),"pointer");else continue;return true}}function jo(t){return Wo(t)}const No=is?"metaKey":"ctrlKey";po.mousedown=(t,e)=>{let r=e;t.input.shiftKey=r.shiftKey;let i=jo(t);let n=Date.now(),s="singleClick";if(n-t.input.lastClick.time<500&&xo(r,t.input.lastClick)&&!r[No]){if(t.input.lastClick.type=="singleClick")s="doubleClick";else if(t.input.lastClick.type=="doubleClick")s="tripleClick"}t.input.lastClick={time:n,x:r.clientX,y:r.clientY,type:s};let l=t.posAtCoords(Mo(r));if(!l)return;if(s=="singleClick"){if(t.input.mouseDown)t.input.mouseDown.done();t.input.mouseDown=new qo(t,l,r,!!i)}else if((s=="doubleClick"?_o:Bo)(t,l.pos,l.inside,r)){r.preventDefault()}else{ko(t,"pointer")}};class qo{constructor(t,e,r,i){this.view=t;this.pos=e;this.event=r;this.flushed=i;this.delayedSelectionSync=false;this.mightDrag=null;this.startDoc=t.state.doc;this.selectNode=!!r[No];this.allowDefault=r.shiftKey;let n,s;if(e.inside>-1){n=t.state.doc.nodeAt(e.inside);s=e.inside}else{let r=t.state.doc.resolve(e.pos);n=r.parent;s=r.depth?r.before():0}const l=i?null:r.target;const o=l?t.docView.nearestDesc(l,true):null;this.target=o&&o.dom.nodeType==1?o.dom:null;let{selection:u}=t.state;if(r.button==0&&n.type.spec.draggable&&n.type.spec.selectable!==false||u instanceof ln&&u.from<=s&&u.to>s)this.mightDrag={node:n,pos:s,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Xn&&!this.target.hasAttribute("contentEditable"))};if(this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)){this.view.domObserver.stop();if(this.mightDrag.addAttr)this.target.draggable=true;if(this.mightDrag.setUneditable)setTimeout((()=>{if(this.view.input.mouseDown==this)this.target.setAttribute("contentEditable","false")}),20);this.view.domObserver.start()}t.root.addEventListener("mouseup",this.up=this.up.bind(this));t.root.addEventListener("mousemove",this.move=this.move.bind(this));ko(t,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up);this.view.root.removeEventListener("mousemove",this.move);if(this.mightDrag&&this.target){this.view.domObserver.stop();if(this.mightDrag.addAttr)this.target.removeAttribute("draggable");if(this.mightDrag.setUneditable)this.target.removeAttribute("contentEditable");this.view.domObserver.start()}if(this.delayedSelectionSync)setTimeout((()=>bl(this.view)));this.view.input.mouseDown=null}up(t){this.done();if(!this.view.dom.contains(t.target))return;let e=this.pos;if(this.view.state.doc!=this.startDoc)e=this.view.posAtCoords(Mo(t));this.updateAllowDefault(t);if(this.allowDefault||!e){ko(this.view,"pointer")}else if($o(this.view,e.pos,e.inside,t,this.selectNode)){t.preventDefault()}else if(t.button==0&&(this.flushed||es&&this.mightDrag&&!this.mightDrag.node.isAtom||Qn&&!this.view.state.selection.visible&&Math.min(Math.abs(e.pos-this.view.state.selection.from),Math.abs(e.pos-this.view.state.selection.to))<=2)){Co(this.view,Qi.near(this.view.state.doc.resolve(e.pos)),"pointer");t.preventDefault()}else{ko(this.view,"pointer")}}move(t){this.updateAllowDefault(t);ko(this.view,"pointer");if(t.buttons==0)this.done()}updateAllowDefault(t){if(!this.allowDefault&&(Math.abs(this.event.x-t.clientX)>4||Math.abs(this.event.y-t.clientY)>4))this.allowDefault=true}}po.touchstart=t=>{t.input.lastTouch=Date.now();jo(t);ko(t,"pointer")};po.touchmove=t=>{t.input.lastTouch=Date.now();ko(t,"pointer")};po.contextmenu=t=>jo(t);function To(t,e){if(t.composing)return true;if(es&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500){t.input.compositionEndedAt=-2e8;return true}return false}const zo=ss?5e3:-1;mo.compositionstart=mo.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,r=e.selection.$to;if(e.selection instanceof nn&&(e.storedMarks||!r.textOffset&&r.parentOffset&&r.nodeBefore.marks.some((t=>t.type.spec.inclusive===false)))){t.markCursor=t.state.storedMarks||r.marks();Wo(t,true);t.markCursor=null}else{Wo(t,!e.selection.empty);if(Xn&&e.selection.empty&&r.parentOffset&&!r.textOffset&&r.nodeBefore.marks.length){let e=t.domSelectionRange();for(let r=e.focusNode,i=e.focusOffset;r&&r.nodeType==1&&i!=0;){let e=i<0?r.lastChild:r.childNodes[i-1];if(!e)break;if(e.nodeType==3){let r=t.domSelection();if(r)r.collapse(e,e.nodeValue.length);break}else{r=e;i=-1}}}}t.input.composing=true}Io(t,zo)};mo.compositionend=(t,e)=>{if(t.composing){t.input.composing=false;t.input.compositionEndedAt=e.timeStamp;t.input.compositionPendingChanges=t.domObserver.pendingRecords().length?t.input.compositionID:0;t.input.compositionNode=null;if(t.input.compositionPendingChanges)Promise.resolve().then((()=>t.domObserver.flush()));t.input.compositionID++;Io(t,20)}};function Io(t,e){clearTimeout(t.input.composingTimeout);if(e>-1)t.input.composingTimeout=setTimeout((()=>Wo(t)),e)}function Po(t){if(t.composing){t.input.composing=false;t.input.compositionEndedAt=Lo()}while(t.input.compositionNodes.length>0)t.input.compositionNodes.pop().markParentsDirty()}function Jo(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let r=jn(e.focusNode,e.focusOffset);let i=Nn(e.focusNode,e.focusOffset);if(r&&i&&r!=i){let e=i.pmViewDesc,n=t.domObserver.lastChangedTextNode;if(r==n||i==n)return n;if(!e||!e.isText(i.nodeValue)){return i}else if(t.input.compositionNode==i){let t=r.pmViewDesc;if(!(!t||!t.isText(r.nodeValue)))return i}}return r||i}function Lo(){let t=document.createEvent("Event");t.initEvent("event",true,true);return t.timeStamp}function Wo(t,e=false){if(ss&&t.domObserver.flushingSoon>=0)return;t.domObserver.forceFlush();Po(t);if(e||t.docView&&t.docView.dirty){let r=wl(t);if(r&&!r.eq(t.state.selection))t.dispatch(t.state.tr.setSelection(r));else if((t.markCursor||e)&&!t.state.selection.empty)t.dispatch(t.state.tr.deleteSelection());else t.updateState(t.state);return true}return false}function Uo(t,e){if(!t.dom.parentNode)return;let r=t.dom.parentNode.appendChild(document.createElement("div"));r.appendChild(e);r.style.cssText="position: fixed; left: -10000px; top: 10px";let i=getSelection(),n=document.createRange();n.selectNodeContents(e);t.dom.blur();i.removeAllRanges();i.addRange(n);setTimeout((()=>{if(r.parentNode)r.parentNode.removeChild(r);t.focus()}),50)}const Ho=Vn&&Gn<15||rs&&us<604;po.copy=mo.cut=(t,e)=>{let r=e;let i=t.state.selection,n=r.type=="cut";if(i.empty)return;let s=Ho?null:r.clipboardData;let l=i.content(),{dom:o,text:u}=Gl(t,l);if(s){r.preventDefault();s.clearData();s.setData("text/html",o.innerHTML);s.setData("text/plain",u)}else{Uo(t,o)}if(n)t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function Zo(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function Ko(t,e){if(!t.dom.parentNode)return;let r=t.input.shiftKey||t.state.selection.$from.parent.type.spec.code;let i=t.dom.parentNode.appendChild(document.createElement(r?"textarea":"div"));if(!r)i.contentEditable="true";i.style.cssText="position: fixed; left: -10000px; top: 10px";i.focus();let n=t.input.shiftKey&&t.input.lastKeyCode!=45;setTimeout((()=>{t.focus();if(i.parentNode)i.parentNode.removeChild(i);if(r)Vo(t,i.value,null,n,e);else Vo(t,i.textContent,i.innerHTML,n,e)}),50)}function Vo(t,e,r,i,n){let s=Xl(t,e,r,i,t.state.selection.$from);if(t.someProp("handlePaste",(e=>e(t,n,s||Ee.empty))))return true;if(!s)return false;let l=Zo(s);let o=l?t.state.tr.replaceSelectionWith(l,i):t.state.tr.replaceSelection(s);t.dispatch(o.scrollIntoView().setMeta("paste",true).setMeta("uiEvent","paste"));return true}function Go(t){let e=t.getData("text/plain")||t.getData("Text");if(e)return e;let r=t.getData("text/uri-list");return r?r.replace(/\r?\n/g," "):""}mo.paste=(t,e)=>{let r=e;if(t.composing&&!ss)return;let i=Ho?null:r.clipboardData;let n=t.input.shiftKey&&t.input.lastKeyCode!=45;if(i&&Vo(t,Go(i),i.getData("text/html"),n,r))r.preventDefault();else Ko(t,r)};class Xo{constructor(t,e,r){this.slice=t;this.move=e;this.node=r}}const Yo=is?"altKey":"ctrlKey";po.dragstart=(t,e)=>{let r=e;let i=t.input.mouseDown;if(i)i.done();if(!r.dataTransfer)return;let n=t.state.selection;let s=n.empty?null:t.posAtCoords(Mo(r));let l;if(s&&s.pos>=n.from&&s.pos<=(n instanceof ln?n.to-1:n.to));else if(i&&i.mightDrag){l=ln.create(t.state.doc,i.mightDrag.pos)}else if(r.target&&r.target.nodeType==1){let e=t.docView.nearestDesc(r.target,true);if(e&&e.node.type.spec.draggable&&e!=t.docView)l=ln.create(t.state.doc,e.posBefore)}let o=(l||t.state.selection).content();let{dom:u,text:f,slice:h}=Gl(t,o);if(!r.dataTransfer.files.length||!Qn||ts>120)r.dataTransfer.clearData();r.dataTransfer.setData(Ho?"Text":"text/html",u.innerHTML);r.dataTransfer.effectAllowed="copyMove";if(!Ho)r.dataTransfer.setData("text/plain",f);t.dragging=new Xo(h,!r[Yo],l)};po.dragend=t=>{let e=t.dragging;window.setTimeout((()=>{if(t.dragging==e)t.dragging=null}),50)};mo.dragover=mo.dragenter=(t,e)=>e.preventDefault();mo.drop=(t,e)=>{let r=e;let i=t.dragging;t.dragging=null;if(!r.dataTransfer)return;let n=t.posAtCoords(Mo(r));if(!n)return;let s=t.state.doc.resolve(n.pos);let l=i&&i.slice;if(l){t.someProp("transformPasted",(e=>{l=e(l,t)}))}else{l=Xl(t,Go(r.dataTransfer),Ho?null:r.dataTransfer.getData("text/html"),false,s)}let o=!!(i&&!r[Yo]);if(t.someProp("handleDrop",(e=>e(t,r,l||Ee.empty,o)))){r.preventDefault();return}if(!l)return;r.preventDefault();let u=l?_i(t.state.doc,s.pos,l):s.pos;if(u==null)u=s.pos;let f=t.state.tr;if(o){let{node:t}=i;if(t)t.replace(f);else f.deleteSelection()}let h=f.mapping.map(u);let a=l.openStart==0&&l.openEnd==0&&l.content.childCount==1;let c=f.doc;if(a)f.replaceRangeWith(h,h,l.content.firstChild);else f.replaceRange(h,h,l);if(f.doc.eq(c))return;let d=f.doc.resolve(h);if(a&&ln.isSelectable(l.content.firstChild)&&d.nodeAfter&&d.nodeAfter.sameMarkup(l.content.firstChild)){f.setSelection(new ln(d))}else{let e=f.mapping.map(u);f.mapping.maps[f.mapping.maps.length-1].forEach(((t,r,i,n)=>e=n));f.setSelection(Al(t,d,f.doc.resolve(e)))}t.focus();t.dispatch(f.setMeta("uiEvent","drop"))};po.focus=t=>{t.input.lastFocus=Date.now();if(!t.focused){t.domObserver.stop();t.dom.classList.add("ProseMirror-focused");t.domObserver.start();t.focused=true;setTimeout((()=>{if(t.docView&&t.hasFocus()&&!t.domObserver.currentSelection.eq(t.domSelectionRange()))bl(t)}),20)}};po.blur=(t,e)=>{let r=e;if(t.focused){t.domObserver.stop();t.dom.classList.remove("ProseMirror-focused");t.domObserver.start();if(r.relatedTarget&&t.dom.contains(r.relatedTarget))t.domObserver.currentSelection.clear();t.focused=false}};po.beforeinput=(t,e)=>{let r=e;if(Qn&&ss&&r.inputType=="deleteContentBackward"){t.domObserver.flushSoon();let{domChangeCount:e}=t.input;setTimeout((()=>{if(t.input.domChangeCount!=e)return;t.dom.blur();t.focus();if(t.someProp("handleKeyDown",(e=>e(t,In(8,"Backspace")))))return;let{$cursor:r}=t.state.selection;if(r&&r.pos>0)t.dispatch(t.state.tr.delete(r.pos-1,r.pos).scrollIntoView())}),50)}};for(let t in mo)po[t]=mo[t];function Qo(t,e){if(t==e)return true;for(let r in t)if(t[r]!==e[r])return false;for(let r in e)if(!(r in t))return false;return true}class tu{constructor(t,e){this.toDOM=t;this.spec=e||su;this.side=this.spec.side||0}map(t,e,r,i){let{pos:n,deleted:s}=t.mapResult(e.from+i,this.side<0?-1:1);return s?null:new iu(n-r,n-r,this)}valid(){return true}eq(t){return this==t||t instanceof tu&&(this.spec.key&&this.spec.key==t.spec.key||this.toDOM==t.toDOM&&Qo(this.spec,t.spec))}destroy(t){if(this.spec.destroy)this.spec.destroy(t)}}class eu{constructor(t,e){this.attrs=t;this.spec=e||su}map(t,e,r,i){let n=t.map(e.from+i,this.spec.inclusiveStart?-1:1)-r;let s=t.map(e.to+i,this.spec.inclusiveEnd?1:-1)-r;return n>=s?null:new iu(n,s,this)}valid(t,e){return e.from<e.to}eq(t){return this==t||t instanceof eu&&Qo(this.attrs,t.attrs)&&Qo(this.spec,t.spec)}static is(t){return t.type instanceof eu}destroy(){}}class ru{constructor(t,e){this.attrs=t;this.spec=e||su}map(t,e,r,i){let n=t.mapResult(e.from+i,1);if(n.deleted)return null;let s=t.mapResult(e.to+i,-1);if(s.deleted||s.pos<=n.pos)return null;return new iu(n.pos-r,s.pos-r,this)}valid(t,e){let{index:r,offset:i}=t.content.findIndex(e.from),n;return i==e.from&&!(n=t.child(r)).isText&&i+n.nodeSize==e.to}eq(t){return this==t||t instanceof ru&&Qo(this.attrs,t.attrs)&&Qo(this.spec,t.spec)}destroy(){}}class iu{constructor(t,e,r){this.from=t;this.to=e;this.type=r}copy(t,e){return new iu(t,e,this.type)}eq(t,e=0){return this.type.eq(t.type)&&this.from+e==t.from&&this.to+e==t.to}map(t,e,r){return this.type.map(t,this,e,r)}static widget(t,e,r){return new iu(t,t,new tu(e,r))}static inline(t,e,r,i){return new iu(t,e,new eu(r,i))}static node(t,e,r,i){return new iu(t,e,new ru(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof eu}get widget(){return this.type instanceof tu}}const nu=[],su={};class lu{constructor(t,e){this.local=t.length?t:nu;this.children=e.length?e:nu}static create(t,e){return e.length?pu(e,t,0,su):ou}find(t,e,r){let i=[];this.findInner(t==null?0:t,e==null?1e9:e,i,0,r);return i}findInner(t,e,r,i,n){for(let s=0;s<this.local.length;s++){let l=this.local[s];if(l.from<=e&&l.to>=t&&(!n||n(l.spec)))r.push(l.copy(l.from+i,l.to+i))}for(let s=0;s<this.children.length;s+=3){if(this.children[s]<e&&this.children[s+1]>t){let l=this.children[s]+1;this.children[s+2].findInner(t-l,e-l,r,i+l,n)}}}map(t,e,r){if(this==ou||t.maps.length==0)return this;return this.mapInner(t,e,0,0,r||su)}mapInner(t,e,r,i,n){let s;for(let l=0;l<this.local.length;l++){let o=this.local[l].map(t,r,i);if(o&&o.type.valid(e,o))(s||(s=[])).push(o);else if(n.onRemove)n.onRemove(this.local[l].spec)}if(this.children.length)return fu(this.children,s||[],t,e,r,i,n);else return s?new lu(s.sort(mu),nu):ou}add(t,e){if(!e.length)return this;if(this==ou)return lu.create(t,e);return this.addInner(t,e,0)}addInner(t,e,r){let i,n=0;t.forEach(((t,s)=>{let l=s+r,o;if(!(o=cu(e,t,l)))return;if(!i)i=this.children.slice();while(n<i.length&&i[n]<s)n+=3;if(i[n]==s)i[n+2]=i[n+2].addInner(t,o,l+1);else i.splice(n,0,s,s+t.nodeSize,pu(o,t,l+1,su));n+=3}));let s=hu(n?du(e):e,-r);for(let e=0;e<s.length;e++)if(!s[e].type.valid(t,s[e]))s.splice(e--,1);return new lu(s.length?this.local.concat(s).sort(mu):this.local,i||this.children)}remove(t){if(t.length==0||this==ou)return this;return this.removeInner(t,0)}removeInner(t,e){let r=this.children,i=this.local;for(let i=0;i<r.length;i+=3){let n;let s=r[i]+e,l=r[i+1]+e;for(let e=0,r;e<t.length;e++)if(r=t[e]){if(r.from>s&&r.to<l){t[e]=null;(n||(n=[])).push(r)}}if(!n)continue;if(r==this.children)r=this.children.slice();let o=r[i+2].removeInner(n,s+1);if(o!=ou){r[i+2]=o}else{r.splice(i,3);i-=3}}if(i.length)for(let r=0,n;r<t.length;r++)if(n=t[r]){for(let t=0;t<i.length;t++)if(i[t].eq(n,e)){if(i==this.local)i=this.local.slice();i.splice(t--,1)}}if(r==this.children&&i==this.local)return this;return i.length||r.length?new lu(i,r):ou}forChild(t,e){if(this==ou)return this;if(e.isLeaf)return lu.empty;let r,i;for(let e=0;e<this.children.length;e+=3)if(this.children[e]>=t){if(this.children[e]==t)r=this.children[e+2];break}let n=t+1,s=n+e.content.size;for(let t=0;t<this.local.length;t++){let e=this.local[t];if(e.from<s&&e.to>n&&e.type instanceof eu){let t=Math.max(n,e.from)-n,r=Math.min(s,e.to)-n;if(t<r)(i||(i=[])).push(e.copy(t,r))}}if(i){let t=new lu(i.sort(mu),nu);return r?new uu([t,r]):t}return r||ou}eq(t){if(this==t)return true;if(!(t instanceof lu)||this.local.length!=t.local.length||this.children.length!=t.children.length)return false;for(let e=0;e<this.local.length;e++)if(!this.local[e].eq(t.local[e]))return false;for(let e=0;e<this.children.length;e+=3)if(this.children[e]!=t.children[e]||this.children[e+1]!=t.children[e+1]||!this.children[e+2].eq(t.children[e+2]))return false;return true}locals(t){return wu(this.localsInner(t))}localsInner(t){if(this==ou)return nu;if(t.inlineContent||!this.local.some(eu.is))return this.local;let e=[];for(let t=0;t<this.local.length;t++){if(!(this.local[t].type instanceof eu))e.push(this.local[t])}return e}forEachSet(t){t(this)}}lu.empty=new lu([],[]);lu.removeOverlap=wu;const ou=lu.empty;class uu{constructor(t){this.members=t}map(t,e){const r=this.members.map((r=>r.map(t,e,su)));return uu.from(r)}forChild(t,e){if(e.isLeaf)return lu.empty;let r=[];for(let i=0;i<this.members.length;i++){let n=this.members[i].forChild(t,e);if(n==ou)continue;if(n instanceof uu)r=r.concat(n.members);else r.push(n)}return uu.from(r)}eq(t){if(!(t instanceof uu)||t.members.length!=this.members.length)return false;for(let e=0;e<this.members.length;e++)if(!this.members[e].eq(t.members[e]))return false;return true}locals(t){let e,r=true;for(let i=0;i<this.members.length;i++){let n=this.members[i].localsInner(t);if(!n.length)continue;if(!e){e=n}else{if(r){e=e.slice();r=false}for(let t=0;t<n.length;t++)e.push(n[t])}}return e?wu(r?e:e.sort(mu)):nu}static from(t){switch(t.length){case 0:return ou;case 1:return t[0];default:return new uu(t.every((t=>t instanceof lu))?t:t.reduce(((t,e)=>t.concat(e instanceof lu?e:e.members)),[]))}}forEachSet(t){for(let e=0;e<this.members.length;e++)this.members[e].forEachSet(t)}}function fu(t,e,r,i,n,s,l){let o=t.slice();for(let t=0,e=s;t<r.maps.length;t++){let i=0;r.maps[t].forEach(((t,r,n,s)=>{let l=s-n-(r-t);for(let n=0;n<o.length;n+=3){let s=o[n+1];if(s<0||t>s+e-i)continue;let u=o[n]+e-i;if(r>=u){o[n+1]=t<=u?-2:-1}else if(t>=e&&l){o[n]+=l;o[n+1]+=l}}i+=l}));e=r.maps[t].map(e,-1)}let u=false;for(let e=0;e<o.length;e+=3)if(o[e+1]<0){if(o[e+1]==-2){u=true;o[e+1]=-1;continue}let f=r.map(t[e]+s),h=f-n;if(h<0||h>=i.content.size){u=true;continue}let a=r.map(t[e+1]+s,-1),c=a-n;let{index:d,offset:p}=i.content.findIndex(h);let m=i.maybeChild(d);if(m&&p==h&&p+m.nodeSize==c){let i=o[e+2].mapInner(r,m,f+1,t[e]+s+1,l);if(i!=ou){o[e]=h;o[e+1]=c;o[e+2]=i}else{o[e+1]=-2;u=true}}else{u=true}}if(u){let u=au(o,t,e,r,n,s,l);let f=pu(u,i,0,l);e=f.local;for(let t=0;t<o.length;t+=3)if(o[t+1]<0){o.splice(t,3);t-=3}for(let t=0,e=0;t<f.children.length;t+=3){let r=f.children[t];while(e<o.length&&o[e]<r)e+=3;o.splice(e,0,f.children[t],f.children[t+1],f.children[t+2])}}return new lu(e.sort(mu),o)}function hu(t,e){if(!e||!t.length)return t;let r=[];for(let i=0;i<t.length;i++){let n=t[i];r.push(new iu(n.from+e,n.to+e,n.type))}return r}function au(t,e,r,i,n,s,l){function o(t,e){for(let s=0;s<t.local.length;s++){let o=t.local[s].map(i,n,e);if(o)r.push(o);else if(l.onRemove)l.onRemove(t.local[s].spec)}for(let r=0;r<t.children.length;r+=3)o(t.children[r+2],t.children[r]+e+1)}for(let r=0;r<t.length;r+=3)if(t[r+1]==-1)o(t[r+2],e[r]+s+1);return r}function cu(t,e,r){if(e.isLeaf)return null;let i=r+e.nodeSize,n=null;for(let e=0,s;e<t.length;e++){if((s=t[e])&&s.from>r&&s.to<i){(n||(n=[])).push(s);t[e]=null}}return n}function du(t){let e=[];for(let r=0;r<t.length;r++)if(t[r]!=null)e.push(t[r]);return e}function pu(t,e,r,i){let n=[],s=false;e.forEach(((e,l)=>{let o=cu(t,e,l+r);if(o){s=true;let t=pu(o,e,r+l+1,i);if(t!=ou)n.push(l,l+e.nodeSize,t)}}));let l=hu(s?du(t):t,-r).sort(mu);for(let t=0;t<l.length;t++)if(!l[t].type.valid(e,l[t])){if(i.onRemove)i.onRemove(l[t].spec);l.splice(t--,1)}return l.length||n.length?new lu(l,n):ou}function mu(t,e){return t.from-e.from||t.to-e.to}function wu(t){let e=t;for(let r=0;r<e.length-1;r++){let i=e[r];if(i.from!=i.to)for(let n=r+1;n<e.length;n++){let s=e[n];if(s.from==i.from){if(s.to!=i.to){if(e==t)e=t.slice();e[n]=s.copy(s.from,i.to);gu(e,n+1,s.copy(i.to,s.to))}continue}else{if(s.from<i.to){if(e==t)e=t.slice();e[r]=i.copy(i.from,s.from);gu(e,n,i.copy(s.from,i.to))}break}}}return e}function gu(t,e,r){while(e<t.length&&mu(r,t[e])>0)e++;t.splice(e,0,r)}function bu(t){let e=[];t.someProp("decorations",(r=>{let i=r(t.state);if(i&&i!=ou)e.push(i)}));if(t.cursorWrapper)e.push(lu.create(t.state.doc,[t.cursorWrapper.deco]));return uu.from(e)}const ku={childList:true,characterData:true,characterDataOldValue:true,attributes:true,attributeOldValue:true,subtree:true};const Du=Vn&&Gn<=11;class vu{constructor(){this.anchorNode=null;this.anchorOffset=0;this.focusNode=null;this.focusOffset=0}set(t){this.anchorNode=t.anchorNode;this.anchorOffset=t.anchorOffset;this.focusNode=t.focusNode;this.focusOffset=t.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(t){return t.anchorNode==this.anchorNode&&t.anchorOffset==this.anchorOffset&&t.focusNode==this.focusNode&&t.focusOffset==this.focusOffset}}class yu{constructor(t,e){this.view=t;this.handleDOMChange=e;this.queue=[];this.flushingSoon=-1;this.observer=null;this.currentSelection=new vu;this.onCharData=null;this.suppressingSelectionUpdates=false;this.lastChangedTextNode=null;this.observer=window.MutationObserver&&new window.MutationObserver((t=>{for(let e=0;e<t.length;e++)this.queue.push(t[e]);if(Vn&&Gn<=11&&t.some((t=>t.type=="childList"&&t.removedNodes.length||t.type=="characterData"&&t.oldValue.length>t.target.nodeValue.length)))this.flushSoon();else this.flush()}));if(Du){this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue});this.flushSoon()}}this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){if(this.flushingSoon<0)this.flushingSoon=window.setTimeout((()=>{this.flushingSoon=-1;this.flush()}),20)}forceFlush(){if(this.flushingSoon>-1){window.clearTimeout(this.flushingSoon);this.flushingSoon=-1;this.flush()}}start(){if(this.observer){this.observer.takeRecords();this.observer.observe(this.view.dom,ku)}if(this.onCharData)this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData);this.connectSelection()}stop(){if(this.observer){let t=this.observer.takeRecords();if(t.length){for(let e=0;e<t.length;e++)this.queue.push(t[e]);window.setTimeout((()=>this.flush()),20)}this.observer.disconnect()}if(this.onCharData)this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData);this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=true;setTimeout((()=>this.suppressingSelectionUpdates=false),50)}onSelectionChange(){if(!Cl(this.view))return;if(this.suppressingSelectionUpdates)return bl(this.view);if(Vn&&Gn<=11&&!this.view.state.selection.empty){let t=this.view.domSelectionRange();if(t.focusNode&&$n(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset))return this.flushSoon()}this.flush()}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(t){if(!t.focusNode)return true;let e=new Set,r;for(let r=t.focusNode;r;r=An(r))e.add(r);for(let i=t.anchorNode;i;i=An(i))if(e.has(i)){r=i;break}let i=r&&this.view.docView.nearestDesc(r);if(i&&i.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r})){this.setCurSelection();return true}}pendingRecords(){if(this.observer)for(let t of this.observer.takeRecords())this.queue.push(t);return this.queue}flush(){let{view:t}=this;if(!t.docView||this.flushingSoon>-1)return;let e=this.pendingRecords();if(e.length)this.queue=[];let r=t.domSelectionRange();let i=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&Cl(t)&&!this.ignoreSelectionChange(r);let n=-1,s=-1,l=false,o=[];if(t.editable){for(let t=0;t<e.length;t++){let r=this.registerMutation(e[t],o);if(r){n=n<0?r.from:Math.min(r.from,n);s=s<0?r.to:Math.max(r.to,s);if(r.typeOver)l=true}}}if(Xn&&o.length){let e=o.filter((t=>t.nodeName=="BR"));if(e.length==2){let[t,r]=e;if(t.parentNode&&t.parentNode.parentNode==r.parentNode)r.remove();else t.remove()}else{let{focusNode:r}=this.currentSelection;for(let i of e){let e=i.parentNode;if(e&&e.nodeName=="LI"&&(!r||Cu(t,r)!=e))i.remove()}}}let u=null;if(n<0&&i&&t.input.lastFocus>Date.now()-200&&Math.max(t.input.lastTouch,t.input.lastClick.time)<Date.now()-300&&zn(r)&&(u=wl(t))&&u.eq(Qi.near(t.state.doc.resolve(0),1))){t.input.lastFocus=0;bl(t);this.currentSelection.set(r);t.scrollToSelection()}else if(n>-1||i){if(n>-1){t.docView.markDirty(n,s);Mu(t)}this.handleDOMChange(n,s,l,o);if(t.docView&&t.docView.dirty)t.updateState(t.state);else if(!this.currentSelection.eq(r))bl(t);this.currentSelection.set(r)}}registerMutation(t,e){if(e.indexOf(t.target)>-1)return null;let r=this.view.docView.nearestDesc(t.target);if(t.type=="attributes"&&(r==this.view.docView||t.attributeName=="contenteditable"||t.attributeName=="style"&&!t.oldValue&&!t.target.getAttribute("style")))return null;if(!r||r.ignoreMutation(t))return null;if(t.type=="childList"){for(let r=0;r<t.addedNodes.length;r++){let i=t.addedNodes[r];e.push(i);if(i.nodeType==3)this.lastChangedTextNode=i}if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(t.target))return{from:r.posBefore,to:r.posAfter};let i=t.previousSibling,n=t.nextSibling;if(Vn&&Gn<=11&&t.addedNodes.length){for(let e=0;e<t.addedNodes.length;e++){let{previousSibling:r,nextSibling:s}=t.addedNodes[e];if(!r||Array.prototype.indexOf.call(t.addedNodes,r)<0)i=r;if(!s||Array.prototype.indexOf.call(t.addedNodes,s)<0)n=s}}let s=i&&i.parentNode==t.target?xn(i)+1:0;let l=r.localPosFromDOM(t.target,s,-1);let o=n&&n.parentNode==t.target?xn(n):t.target.childNodes.length;let u=r.localPosFromDOM(t.target,o,1);return{from:l,to:u}}else if(t.type=="attributes"){return{from:r.posAtStart-r.border,to:r.posAtEnd+r.border}}else{this.lastChangedTextNode=t.target;return{from:r.posAtStart,to:r.posAtEnd,typeOver:t.target.nodeValue==t.oldValue}}}}let Fu=new WeakMap;let Eu=false;function Mu(t){if(Fu.has(t))return;Fu.set(t,null);if(["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace)!==-1){t.requiresGeckoHackNode=Xn;if(Eu)return;console["warn"]("ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package.");Eu=true}}function xu(t,e){let r=e.startContainer,i=e.startOffset;let n=e.endContainer,s=e.endOffset;let l=t.domAtPos(t.state.selection.anchor);if($n(l.node,l.offset,n,s))[r,i,n,s]=[n,s,r,i];return{anchorNode:r,anchorOffset:i,focusNode:n,focusOffset:s}}function Au(t,e){if(e.getComposedRanges){let r=e.getComposedRanges(t.root)[0];if(r)return xu(t,r)}let r;function i(t){t.preventDefault();t.stopImmediatePropagation();r=t.getTargetRanges()[0]}t.dom.addEventListener("beforeinput",i,true);document.execCommand("indent");t.dom.removeEventListener("beforeinput",i,true);return r?xu(t,r):null}function Cu(t,e){for(let r=e.parentNode;r&&r!=t.dom;r=r.parentNode){let e=t.docView.nearestDesc(r,true);if(e&&e.node.isBlock)return r}return null}function Su(t,e,r){let{node:i,fromOffset:n,toOffset:s,from:l,to:o}=t.docView.parseRange(e,r);let u=t.domSelectionRange();let f;let h=u.anchorNode;if(h&&t.dom.contains(h.nodeType==1?h:h.parentNode)){f=[{node:h,offset:u.anchorOffset}];if(!zn(u))f.push({node:u.focusNode,offset:u.focusOffset})}if(Qn&&t.input.lastKeyCode===8){for(let t=s;t>n;t--){let e=i.childNodes[t-1],r=e.pmViewDesc;if(e.nodeName=="BR"&&!r){s=t;break}if(!r||r.size)break}}let a=t.state.doc;let c=t.someProp("domParser")||br.fromSchema(t.state.schema);let d=a.resolve(l);let p=null,m=c.parse(i,{topNode:d.parent,topMatch:d.parent.contentMatchAt(d.index()),topOpen:true,from:n,to:s,preserveWhitespace:d.parent.type.whitespace=="pre"?"full":true,findPositions:f,ruleFromNode:Ou,context:d});if(f&&f[0].pos!=null){let t=f[0].pos,e=f[1]&&f[1].pos;if(e==null)e=t;p={anchor:t+l,head:e+l}}return{doc:m,sel:p,from:l,to:o}}function Ou(t){let e=t.pmViewDesc;if(e){return e.parseRule()}else if(t.nodeName=="BR"&&t.parentNode){if(es&&/^(ul|ol)$/i.test(t.parentNode.nodeName)){let t=document.createElement("div");t.appendChild(document.createElement("li"));return{skip:t}}else if(t.parentNode.lastChild==t||es&&/^(tr|table)$/i.test(t.parentNode.nodeName)){return{ignore:true}}}else if(t.nodeName=="IMG"&&t.getAttribute("mark-placeholder")){return{ignore:true}}return null}const $u=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function _u(t,e,r,i,n){let s=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);t.input.compositionPendingChanges=0;if(e<0){let e=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null;let r=wl(t,e);if(r&&!t.state.selection.eq(r)){if(Qn&&ss&&t.input.lastKeyCode===13&&Date.now()-100<t.input.lastKeyCodeTime&&t.someProp("handleKeyDown",(e=>e(t,In(13,"Enter")))))return;let i=t.state.tr.setSelection(r);if(e=="pointer")i.setMeta("pointer",true);else if(e=="key")i.scrollIntoView();if(s)i.setMeta("composition",s);t.dispatch(i)}return}let l=t.state.doc.resolve(e);let o=l.sharedDepth(r);e=l.before(o+1);r=t.state.doc.resolve(r).after(o+1);let u=t.state.selection;let f=Su(t,e,r);let h=t.state.doc,a=h.slice(f.from,f.to);let c,d;if(t.input.lastKeyCode===8&&Date.now()-100<t.input.lastKeyCodeTime){c=t.state.selection.to;d="end"}else{c=t.state.selection.from;d="start"}t.input.lastKeyCode=null;let p=qu(a.content,f.doc.content,f.from,c,d);if(p)t.input.domChangeCount++;if((rs&&t.input.lastIOSEnter>Date.now()-225||ss)&&n.some((t=>t.nodeType==1&&!$u.test(t.nodeName)))&&(!p||p.endA>=p.endB)&&t.someProp("handleKeyDown",(e=>e(t,In(13,"Enter"))))){t.input.lastIOSEnter=0;return}if(!p){if(i&&u instanceof nn&&!u.empty&&u.$head.sameParent(u.$anchor)&&!t.composing&&!(f.sel&&f.sel.anchor!=f.sel.head)){p={start:u.from,endA:u.to,endB:u.to}}else{if(f.sel){let e=Bu(t,t.state.doc,f.sel);if(e&&!e.eq(t.state.selection)){let r=t.state.tr.setSelection(e);if(s)r.setMeta("composition",s);t.dispatch(r)}}return}}if(t.state.selection.from<t.state.selection.to&&p.start==p.endB&&t.state.selection instanceof nn){if(p.start>t.state.selection.from&&p.start<=t.state.selection.from+2&&t.state.selection.from>=f.from){p.start=t.state.selection.from}else if(p.endA<t.state.selection.to&&p.endA>=t.state.selection.to-2&&t.state.selection.to<=f.to){p.endB+=t.state.selection.to-p.endA;p.endA=t.state.selection.to}}if(Vn&&Gn<=11&&p.endB==p.start+1&&p.endA==p.start&&p.start>f.from&&f.doc.textBetween(p.start-f.from-1,p.start-f.from+1)==" "){p.start--;p.endA--;p.endB--}let m=f.doc.resolveNoCache(p.start-f.from);let w=f.doc.resolveNoCache(p.endB-f.from);let g=h.resolve(p.start);let b=m.sameParent(w)&&m.parent.inlineContent&&g.end()>=p.endA;let k;if((rs&&t.input.lastIOSEnter>Date.now()-225&&(!b||n.some((t=>t.nodeName=="DIV"||t.nodeName=="P")))||!b&&m.pos<f.doc.content.size&&!m.sameParent(w)&&(k=Qi.findFrom(f.doc.resolve(m.pos+1),1,true))&&k.head==w.pos)&&t.someProp("handleKeyDown",(e=>e(t,In(13,"Enter"))))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>p.start&&ju(h,p.start,p.endA,m,w)&&t.someProp("handleKeyDown",(e=>e(t,In(8,"Backspace"))))){if(ss&&Qn)t.domObserver.suppressSelectionUpdates();return}if(Qn&&p.endB==p.start)t.input.lastChromeDelete=Date.now();if(ss&&!b&&m.start()!=w.start()&&w.parentOffset==0&&m.depth==w.depth&&f.sel&&f.sel.anchor==f.sel.head&&f.sel.head==p.endA){p.endB-=2;w=f.doc.resolveNoCache(p.endB-f.from);setTimeout((()=>{t.someProp("handleKeyDown",(function(e){return e(t,In(13,"Enter"))}))}),20)}let D=p.start,v=p.endA;let y,F,E;if(b){if(m.pos==w.pos){if(Vn&&Gn<=11&&m.parentOffset==0){t.domObserver.suppressSelectionUpdates();setTimeout((()=>bl(t)),20)}y=t.state.tr.delete(D,v);F=h.resolve(p.start).marksAcross(h.resolve(p.endA))}else if(p.endA==p.endB&&(E=Ru(m.parent.content.cut(m.parentOffset,w.parentOffset),g.parent.content.cut(g.parentOffset,p.endA-g.start())))){y=t.state.tr;if(E.type=="add")y.addMark(D,v,E.mark);else y.removeMark(D,v,E.mark)}else if(m.parent.child(m.index()).isText&&m.index()==w.index()-(w.textOffset?0:1)){let e=m.parent.textBetween(m.parentOffset,w.parentOffset);if(t.someProp("handleTextInput",(r=>r(t,D,v,e))))return;y=t.state.tr.insertText(e,D,v)}}if(!y)y=t.state.tr.replace(D,v,f.doc.slice(p.start-f.from,p.endB-f.from));if(f.sel){let e=Bu(t,y.doc,f.sel);if(e&&!(Qn&&t.composing&&e.empty&&(p.start!=p.endB||t.input.lastChromeDelete<Date.now()-100)&&(e.head==D||e.head==y.mapping.map(v)-1)||Vn&&e.empty&&e.head==D))y.setSelection(e)}if(F)y.ensureMarks(F);if(s)y.setMeta("composition",s);t.dispatch(y.scrollIntoView())}function Bu(t,e,r){if(Math.max(r.anchor,r.head)>e.content.size)return null;return Al(t,e.resolve(r.anchor),e.resolve(r.head))}function Ru(t,e){let r=t.firstChild.marks,i=e.firstChild.marks;let n=r,s=i,l,o,u;for(let t=0;t<i.length;t++)n=i[t].removeFromSet(n);for(let t=0;t<r.length;t++)s=r[t].removeFromSet(s);if(n.length==1&&s.length==0){o=n[0];l="add";u=t=>t.mark(o.addToSet(t.marks))}else if(n.length==0&&s.length==1){o=s[0];l="remove";u=t=>t.mark(o.removeFromSet(t.marks))}else{return null}let f=[];for(let t=0;t<e.childCount;t++)f.push(u(e.child(t)));if(be.from(f).eq(t))return{mark:o,type:l}}function ju(t,e,r,i,n){if(r-e<=n.pos-i.pos||Nu(i,true,false)<n.pos)return false;let s=t.resolve(e);if(!i.parent.isTextblock){let t=s.nodeAfter;return t!=null&&r==e+t.nodeSize}if(s.parentOffset<s.parent.content.size||!s.parent.isTextblock)return false;let l=t.resolve(Nu(s,true,true));if(!l.parent.isTextblock||l.pos>r||Nu(l,true,false)<r)return false;return i.parent.content.cut(i.parentOffset).eq(l.parent.content)}function Nu(t,e,r){let i=t.depth,n=e?t.end():t.pos;while(i>0&&(e||t.indexAfter(i)==t.node(i).childCount)){i--;n++;e=false}if(r){let e=t.node(i).maybeChild(t.indexAfter(i));while(e&&!e.isLeaf){e=e.firstChild;n++}}return n}function qu(t,e,r,i,n){let s=t.findDiffStart(e,r);if(s==null)return null;let{a:l,b:o}=t.findDiffEnd(e,r+t.size,r+e.size);if(n=="end"){let t=Math.max(0,s-Math.min(l,o));i-=l+t-s}if(l<s&&t.size<e.size){let t=i<=s&&i>=l?s-i:0;s-=t;if(s&&s<e.size&&Tu(e.textBetween(s-1,s+1)))s+=t?1:-1;o=s+(o-l);l=s}else if(o<s){let e=i<=s&&i>=o?s-i:0;s-=e;if(s&&s<t.size&&Tu(t.textBetween(s-1,s+1)))s+=e?1:-1;l=s+(l-o);o=s}return{start:s,endA:l,endB:o}}function Tu(t){if(t.length!=2)return false;let e=t.charCodeAt(0),r=t.charCodeAt(1);return e>=56320&&e<=57343&&r>=55296&&r<=56319}class zu{constructor(t,e){this._root=null;this.focused=false;this.trackWrites=null;this.mounted=false;this.markCursor=null;this.cursorWrapper=null;this.lastSelectedViewDesc=undefined;this.input=new go;this.prevDirectPlugins=[];this.pluginViews=[];this.requiresGeckoHackNode=false;this.dragging=null;this._props=e;this.state=e.state;this.directPlugins=e.plugins||[];this.directPlugins.forEach(Hu);this.dispatch=this.dispatch.bind(this);this.dom=t&&t.mount||document.createElement("div");if(t){if(t.appendChild)t.appendChild(this.dom);else if(typeof t=="function")t(this.dom);else if(t.mount)this.mounted=true}this.editable=Ju(this);Pu(this);this.nodeViews=Wu(this);this.docView=Gs(this.state.doc,Iu(this),bu(this),this.dom,this);this.domObserver=new yu(this,((t,e,r,i)=>_u(this,t,e,r,i)));this.domObserver.start();bo(this);this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let t=this._props;this._props={};for(let e in t)this._props[e]=t[e];this._props.state=this.state}return this._props}update(t){if(t.handleDOMEvents!=this._props.handleDOMEvents)vo(this);let e=this._props;this._props=t;if(t.plugins){t.plugins.forEach(Hu);this.directPlugins=t.plugins}this.updateStateInner(t.state,e)}setProps(t){let e={};for(let t in this._props)e[t]=this._props[t];e.state=this.state;for(let r in t)e[r]=t[r];this.update(e)}updateState(t){this.updateStateInner(t,this._props)}updateStateInner(t,e){var r;let i=this.state,n=false,s=false;if(t.storedMarks&&this.composing){Po(this);s=true}this.state=t;let l=i.plugins!=t.plugins||this._props.plugins!=e.plugins;if(l||this._props.plugins!=e.plugins||this._props.nodeViews!=e.nodeViews){let t=Wu(this);if(Uu(t,this.nodeViews)){this.nodeViews=t;n=true}}if(l||e.handleDOMEvents!=this._props.handleDOMEvents){vo(this)}this.editable=Ju(this);Pu(this);let o=bu(this),u=Iu(this);let f=i.plugins!=t.plugins&&!i.doc.eq(t.doc)?"reset":t.scrollToSelection>i.scrollToSelection?"to selection":"preserve";let h=n||!this.docView.matchesNode(t.doc,u,o);if(h||!t.selection.eq(i.selection))s=true;let a=f=="preserve"&&s&&this.dom.style.overflowAnchor==null&&ds(this);if(s){this.domObserver.stop();let e=h&&(Vn||Qn)&&!this.composing&&!i.selection.empty&&!t.selection.empty&&Lu(i.selection,t.selection);if(h){let r=Qn?this.trackWrites=this.domSelectionRange().focusNode:null;if(this.composing)this.input.compositionNode=Jo(this);if(n||!this.docView.update(t.doc,u,o,this)){this.docView.updateOuterDeco(u);this.docView.destroy();this.docView=Gs(t.doc,u,o,this.dom,this)}if(r&&!this.trackWrites)e=true}if(e||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&Ol(this))){bl(this,e)}else{Ml(this,t.selection);this.domObserver.setCurSelection()}this.domObserver.start()}this.updatePluginViews(i);if(((r=this.dragging)===null||r===void 0?void 0:r.node)&&!i.doc.eq(t.doc))this.updateDraggedNode(this.dragging,i);if(f=="reset"){this.dom.scrollTop=0}else if(f=="to selection"){this.scrollToSelection()}else if(a){ms(a)}}scrollToSelection(){let t=this.domSelectionRange().focusNode;if(!t||!this.dom.contains(t.nodeType==1?t:t.parentNode));else if(this.someProp("handleScrollToSelection",(t=>t(this))));else if(this.state.selection instanceof ln){let e=this.docView.domAfterPos(this.state.selection.from);if(e.nodeType==1)cs(this,e.getBoundingClientRect(),t)}else{cs(this,this.coordsAtPos(this.state.selection.head,1),t)}}destroyPluginViews(){let t;while(t=this.pluginViews.pop())if(t.destroy)t.destroy()}updatePluginViews(t){if(!t||t.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins;this.destroyPluginViews();for(let t=0;t<this.directPlugins.length;t++){let e=this.directPlugins[t];if(e.spec.view)this.pluginViews.push(e.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let e=this.state.plugins[t];if(e.spec.view)this.pluginViews.push(e.spec.view(this))}}else{for(let e=0;e<this.pluginViews.length;e++){let r=this.pluginViews[e];if(r.update)r.update(this,t)}}}updateDraggedNode(t,e){let r=t.node,i=-1;if(this.state.doc.nodeAt(r.from)==r.node){i=r.from}else{let t=r.from+(this.state.doc.content.size-e.doc.content.size);let n=t>0&&this.state.doc.nodeAt(t);if(n==r.node)i=t}this.dragging=new Xo(t.slice,t.move,i<0?undefined:ln.create(this.state.doc,i))}someProp(t,e){let r=this._props&&this._props[t],i;if(r!=null&&(i=e?e(r):r))return i;for(let r=0;r<this.directPlugins.length;r++){let n=this.directPlugins[r].props[t];if(n!=null&&(i=e?e(n):n))return i}let n=this.state.plugins;if(n)for(let r=0;r<n.length;r++){let s=n[r].props[t];if(s!=null&&(i=e?e(s):s))return i}}hasFocus(){if(Vn){let t=this.root.activeElement;if(t==this.dom)return true;if(!t||!this.dom.contains(t))return false;while(t&&this.dom!=t&&this.dom.contains(t)){if(t.contentEditable=="false")return false;t=t.parentElement}return true}return this.root.activeElement==this.dom}focus(){this.domObserver.stop();if(this.editable)bs(this.dom);bl(this);this.domObserver.start()}get root(){let t=this._root;if(t==null)for(let t=this.dom.parentNode;t;t=t.parentNode){if(t.nodeType==9||t.nodeType==11&&t.host){if(!t.getSelection)Object.getPrototypeOf(t).getSelection=()=>t.ownerDocument.getSelection();return this._root=t}}return t||document}updateRoot(){this._root=null}posAtCoords(t){return xs(this,t)}coordsAtPos(t,e=1){return Os(this,t,e)}domAtPos(t,e=0){return this.docView.domFromPos(t,e)}nodeDOM(t){let e=this.docView.descAt(t);return e?e.nodeDOM:null}posAtDOM(t,e,r=-1){let i=this.docView.posFromDOM(t,e,r);if(i==null)throw new RangeError("DOM position not inside the editor");return i}endOfTextblock(t,e){return Is(this,e||this.state,t)}pasteHTML(t,e){return Vo(this,"",t,false,e||new ClipboardEvent("paste"))}pasteText(t,e){return Vo(this,t,null,true,e||new ClipboardEvent("paste"))}destroy(){if(!this.docView)return;Do(this);this.destroyPluginViews();if(this.mounted){this.docView.update(this.state.doc,[],bu(this),this);this.dom.textContent=""}else if(this.dom.parentNode){this.dom.parentNode.removeChild(this.dom)}this.docView.destroy();this.docView=null;On()}get isDestroyed(){return this.docView==null}dispatchEvent(t){return Eo(this,t)}dispatch(t){let e=this._props.dispatchTransaction;if(e)e.call(this,t);else this.updateState(this.state.apply(t))}domSelectionRange(){let t=this.domSelection();if(!t)return{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0};return es&&this.root.nodeType===11&&Pn(this.dom.ownerDocument)==this.dom&&Au(this,t)||t}domSelection(){return this.root.getSelection()}}function Iu(t){let e=Object.create(null);e.class="ProseMirror";e.contenteditable=String(t.editable);t.someProp("attributes",(r=>{if(typeof r=="function")r=r(t.state);if(r)for(let t in r){if(t=="class")e.class+=" "+r[t];else if(t=="style")e.style=(e.style?e.style+";":"")+r[t];else if(!e[t]&&t!="contenteditable"&&t!="nodeName")e[t]=String(r[t])}}));if(!e.translate)e.translate="no";return[iu.node(0,t.state.doc.content.size,e)]}function Pu(t){if(t.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator";e.setAttribute("mark-placeholder","true");e.setAttribute("alt","");t.cursorWrapper={dom:e,deco:iu.widget(t.state.selection.from,e,{raw:true,marks:t.markCursor})}}else{t.cursorWrapper=null}}function Ju(t){return!t.someProp("editable",(e=>e(t.state)===false))}function Lu(t,e){let r=Math.min(t.$anchor.sharedDepth(t.head),e.$anchor.sharedDepth(e.head));return t.$anchor.start(r)!=e.$anchor.start(r)}function Wu(t){let e=Object.create(null);function r(t){for(let r in t)if(!Object.prototype.hasOwnProperty.call(e,r))e[r]=t[r]}t.someProp("nodeViews",r);t.someProp("markViews",r);return e}function Uu(t,e){let r=0,i=0;for(let i in t){if(t[i]!=e[i])return true;r++}for(let t in e)i++;return r!=i}function Hu(t){if(t.spec.state||t.spec.filterTransaction||t.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}const Zu=["p",0],Ku=["blockquote",0],Vu=["hr"],Gu=["pre",["code",0]],Xu=["br"];const Yu={doc:{content:"block+"},paragraph:{content:"inline*",group:"block",parseDOM:[{tag:"p"}],toDOM(){return Zu}},blockquote:{content:"block+",group:"block",defining:true,parseDOM:[{tag:"blockquote"}],toDOM(){return Ku}},horizontal_rule:{group:"block",parseDOM:[{tag:"hr"}],toDOM(){return Vu}},heading:{attrs:{level:{default:1,validate:"number"}},content:"inline*",group:"block",defining:true,parseDOM:[{tag:"h1",attrs:{level:1}},{tag:"h2",attrs:{level:2}},{tag:"h3",attrs:{level:3}},{tag:"h4",attrs:{level:4}},{tag:"h5",attrs:{level:5}},{tag:"h6",attrs:{level:6}}],toDOM(t){return["h"+t.attrs.level,0]}},code_block:{content:"text*",marks:"",group:"block",code:true,defining:true,parseDOM:[{tag:"pre",preserveWhitespace:"full"}],toDOM(){return Gu}},text:{group:"inline"},image:{inline:true,attrs:{src:{validate:"string"},alt:{default:null,validate:"string|null"},title:{default:null,validate:"string|null"}},group:"inline",draggable:true,parseDOM:[{tag:"img[src]",getAttrs(t){return{src:t.getAttribute("src"),title:t.getAttribute("title"),alt:t.getAttribute("alt")}}}],toDOM(t){let{src:e,alt:r,title:i}=t.attrs;return["img",{src:e,alt:r,title:i}]}},hard_break:{inline:true,group:"inline",selectable:false,parseDOM:[{tag:"br"}],toDOM(){return Xu}}};const Qu=["em",0],tf=["strong",0],ef=["code",0];const rf={link:{attrs:{href:{validate:"string"},title:{default:null,validate:"string|null"}},inclusive:false,parseDOM:[{tag:"a[href]",getAttrs(t){return{href:t.getAttribute("href"),title:t.getAttribute("title")}}}],toDOM(t){let{href:e,title:r}=t.attrs;return["a",{href:e,title:r},0]}},em:{parseDOM:[{tag:"i"},{tag:"em"},{style:"font-style=italic"},{style:"font-style=normal",clearMark:t=>t.type.name=="em"}],toDOM(){return Qu}},strong:{parseDOM:[{tag:"strong"},{tag:"b",getAttrs:t=>t.style.fontWeight!="normal"&&null},{style:"font-weight=400",clearMark:t=>t.type.name=="strong"},{style:"font-weight",getAttrs:t=>/^(bold(er)?|[5-9]\d{2,})$/.test(t)&&null}],toDOM(){return tf}},code:{parseDOM:[{tag:"code"}],toDOM(){return ef}}};const nf=new pr({nodes:Yu,marks:rf});const sf=["ol",0],lf=["ul",0],of=["li",0];const uf={attrs:{order:{default:1}},parseDOM:[{tag:"ol",getAttrs(t){return{order:t.hasAttribute("start")?+t.getAttribute("start"):1}}}],toDOM(t){return t.attrs.order==1?sf:["ol",{start:t.attrs.order},0]}};const ff={parseDOM:[{tag:"ul"}],toDOM(){return lf}};const hf={parseDOM:[{tag:"li"}],toDOM(){return of},defining:true};function af(t,e){let r={};for(let e in t)r[e]=t[e];for(let t in e)r[t]=e[t];return r}function cf(t,e,r){return t.append({ordered_list:af(uf,{content:"list_item+",group:r}),bullet_list:af(ff,{content:"list_item+",group:r}),list_item:af(hf,{content:e})})}function df(t,e=null){return function(r,i){let{$from:n,$to:s}=r.selection;let l=n.blockRange(s),o=false,u=l;if(!l)return false;if(l.depth>=2&&n.node(l.depth-1).type.compatibleContent(t)&&l.startIndex==0){if(n.index(l.depth-1)==0)return false;let t=r.doc.resolve(l.start-2);u=new Pe(t,t,l.depth);if(l.endIndex<l.parent.childCount)l=new Pe(n,r.doc.resolve(s.end(l.depth)),l.depth);o=true}let f=pi(u,t,e,l);if(!f)return false;if(i)i(pf(r.tr,l,f,o,t).scrollIntoView());return true}}function pf(t,e,r,i,n){let s=be.empty;for(let t=r.length-1;t>=0;t--)s=be.from(r[t].type.create(r[t].attrs,s));t.step(new li(e.start-(i?2:0),e.end,e.start,e.end,new Ee(s,0,0),r.length,true));let l=0;for(let t=0;t<r.length;t++)if(r[t].type==n)l=t+1;let o=r.length-l;let u=e.start+r.length-(i?2:0),f=e.parent;for(let r=e.startIndex,i=e.endIndex,n=true;r<i;r++,n=false){if(!n&&Ei(t.doc,u,o)){t.split(u,o);u+=2*o}u+=f.child(r).nodeSize}return t}function mf(t,e){return function(r,i){let{$from:n,$to:s,node:l}=r.selection;if(l&&l.isBlock||n.depth<2||!n.sameParent(s))return false;let o=n.node(-1);if(o.type!=t)return false;if(n.parent.content.size==0&&n.node(-1).childCount==n.indexAfter(-1)){if(n.depth==3||n.node(-3).type!=t||n.index(-2)!=n.node(-2).childCount-1)return false;if(i){let e=be.empty;let s=n.index(-1)?1:n.index(-2)?2:3;for(let t=n.depth-s;t>=n.depth-3;t--)e=be.from(n.node(t).copy(e));let l=n.indexAfter(-1)<n.node(-2).childCount?1:n.indexAfter(-2)<n.node(-3).childCount?2:3;e=e.append(be.from(t.createAndFill()));let o=n.before(n.depth-(s-1));let u=r.tr.replace(o,n.after(-l),new Ee(e,4-s,0));let f=-1;u.doc.nodesBetween(o,u.doc.content.size,((t,e)=>{if(f>-1)return false;if(t.isTextblock&&t.content.size==0)f=e+1}));if(f>-1)u.setSelection(Qi.near(u.doc.resolve(f)));i(u.scrollIntoView())}return true}let u=s.pos==n.end()?o.contentMatchAt(0).defaultType:null;let f=r.tr.delete(n.pos,s.pos);let h=u?[e?{type:t,attrs:e}:null,{type:u}]:undefined;if(!Ei(f.doc,n.pos,2,h))return false;if(i)i(f.split(n.pos,2,h).scrollIntoView());return true}}function wf(t){return function(e,r){let{$from:i,$to:n}=e.selection;let s=i.blockRange(n,(e=>e.childCount>0&&e.firstChild.type==t));if(!s)return false;if(!r)return true;if(i.node(s.depth-1).type==t)return gf(e,r,t,s);else return bf(e,r,s)}}function gf(t,e,r,i){let n=t.tr,s=i.end,l=i.$to.end(i.depth);if(s<l){n.step(new li(s-1,l,s,l,new Ee(be.from(r.create(null,i.parent.copy())),1,0),1,true));i=new Pe(n.doc.resolve(i.$from.pos),n.doc.resolve(l),i.depth)}const o=ci(i);if(o==null)return false;n.lift(i,o);let u=n.mapping.map(s,-1)-1;if(xi(n.doc,u))n.join(u);e(n.scrollIntoView());return true}function bf(t,e,r){let i=t.tr,n=r.parent;for(let t=r.end,e=r.endIndex-1,s=r.startIndex;e>s;e--){t-=n.child(e).nodeSize;i.delete(t-1,t+1)}let s=i.doc.resolve(r.start),l=s.nodeAfter;if(i.mapping.map(r.end)!=r.start+s.nodeAfter.nodeSize)return false;let o=r.startIndex==0,u=r.endIndex==n.childCount;let f=s.node(-1),h=s.index(-1);if(!f.canReplace(h+(o?0:1),h+1,l.content.append(u?be.empty:be.from(n))))return false;let a=s.pos,c=a+l.nodeSize;i.step(new li(a-(o?1:0),c+(u?1:0),a+1,c-1,new Ee((o?be.empty:be.from(n.copy(be.empty))).append(u?be.empty:be.from(n.copy(be.empty))),o?0:1,u?0:1),o?0:1));e(i.scrollIntoView());return true}function kf(t){return function(e,r){let{$from:i,$to:n}=e.selection;let s=i.blockRange(n,(e=>e.childCount>0&&e.firstChild.type==t));if(!s)return false;let l=s.startIndex;if(l==0)return false;let o=s.parent,u=o.child(l-1);if(u.type!=t)return false;if(r){let i=u.lastChild&&u.lastChild.type==o.type;let n=be.from(i?t.create():null);let l=new Ee(be.from(t.create(null,be.from(o.type.create(null,n)))),i?3:1,0);let f=s.start,h=s.end;r(e.tr.step(new li(f-(i?3:1),h,f,h,l,1,true)).scrollIntoView())}return true}}var Df={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"};var vf={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'};var yf=typeof navigator!="undefined"&&/Mac/.test(navigator.platform);var Ff=typeof navigator!="undefined"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var Ef=0;Ef<10;Ef++)Df[48+Ef]=Df[96+Ef]=String(Ef);for(var Ef=1;Ef<=24;Ef++)Df[Ef+111]="F"+Ef;for(var Ef=65;Ef<=90;Ef++){Df[Ef]=String.fromCharCode(Ef+32);vf[Ef]=String.fromCharCode(Ef)}for(var Mf in Df)if(!vf.hasOwnProperty(Mf))vf[Mf]=Df[Mf];function xf(t){var e=yf&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||Ff&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified";var r=!e&&t.key||(t.shiftKey?vf:Df)[t.keyCode]||t.key||"Unidentified";if(r=="Esc")r="Escape";if(r=="Del")r="Delete";if(r=="Left")r="ArrowLeft";if(r=="Up")r="ArrowUp";if(r=="Right")r="ArrowRight";if(r=="Down")r="ArrowDown";return r}const Af=typeof navigator!="undefined"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):false;function Cf(t){let e=t.split(/-(?!$)/),r=e[e.length-1];if(r=="Space")r=" ";let i,n,s,l;for(let t=0;t<e.length-1;t++){let r=e[t];if(/^(cmd|meta|m)$/i.test(r))l=true;else if(/^a(lt)?$/i.test(r))i=true;else if(/^(c|ctrl|control)$/i.test(r))n=true;else if(/^s(hift)?$/i.test(r))s=true;else if(/^mod$/i.test(r)){if(Af)l=true;else n=true}else throw new Error("Unrecognized modifier name: "+r)}if(i)r="Alt-"+r;if(n)r="Ctrl-"+r;if(l)r="Meta-"+r;if(s)r="Shift-"+r;return r}function Sf(t){let e=Object.create(null);for(let r in t)e[Cf(r)]=t[r];return e}function Of(t,e,r=true){if(e.altKey)t="Alt-"+t;if(e.ctrlKey)t="Ctrl-"+t;if(e.metaKey)t="Meta-"+t;if(r&&e.shiftKey)t="Shift-"+t;return t}function $f(t){return new yn({props:{handleKeyDown:_f(t)}})}function _f(t){let e=Sf(t);return function(t,r){let i=xf(r),n,s=e[Of(i,r)];if(s&&s(t.state,t.dispatch,t))return true;if(i.length==1&&i!=" "){if(r.shiftKey){let n=e[Of(i,r,false)];if(n&&n(t.state,t.dispatch,t))return true}if((r.shiftKey||r.altKey||r.metaKey||i.charCodeAt(0)>127)&&(n=Df[r.keyCode])&&n!=i){let i=e[Of(n,r)];if(i&&i(t.state,t.dispatch,t))return true}}return false}}var Bf=200;var Rf=function t(){};Rf.prototype.append=function t(e){if(!e.length){return this}e=Rf.from(e);return!this.length&&e||e.length<Bf&&this.leafAppend(e)||this.length<Bf&&e.leafPrepend(this)||this.appendInner(e)};Rf.prototype.prepend=function t(e){if(!e.length){return this}return Rf.from(e).append(this)};Rf.prototype.appendInner=function t(e){return new Nf(this,e)};Rf.prototype.slice=function t(e,r){if(e===void 0)e=0;if(r===void 0)r=this.length;if(e>=r){return Rf.empty}return this.sliceInner(Math.max(0,e),Math.min(this.length,r))};Rf.prototype.get=function t(e){if(e<0||e>=this.length){return undefined}return this.getInner(e)};Rf.prototype.forEach=function t(e,r,i){if(r===void 0)r=0;if(i===void 0)i=this.length;if(r<=i){this.forEachInner(e,r,i,0)}else{this.forEachInvertedInner(e,r,i,0)}};Rf.prototype.map=function t(e,r,i){if(r===void 0)r=0;if(i===void 0)i=this.length;var n=[];this.forEach((function(t,r){return n.push(e(t,r))}),r,i);return n};Rf.from=function t(e){if(e instanceof Rf){return e}return e&&e.length?new jf(e):Rf.empty};var jf=function(t){function e(e){t.call(this);this.values=e}if(t)e.__proto__=t;e.prototype=Object.create(t&&t.prototype);e.prototype.constructor=e;var r={length:{configurable:true},depth:{configurable:true}};e.prototype.flatten=function t(){return this.values};e.prototype.sliceInner=function t(r,i){if(r==0&&i==this.length){return this}return new e(this.values.slice(r,i))};e.prototype.getInner=function t(e){return this.values[e]};e.prototype.forEachInner=function t(e,r,i,n){for(var s=r;s<i;s++){if(e(this.values[s],n+s)===false){return false}}};e.prototype.forEachInvertedInner=function t(e,r,i,n){for(var s=r-1;s>=i;s--){if(e(this.values[s],n+s)===false){return false}}};e.prototype.leafAppend=function t(r){if(this.length+r.length<=Bf){return new e(this.values.concat(r.flatten()))}};e.prototype.leafPrepend=function t(r){if(this.length+r.length<=Bf){return new e(r.flatten().concat(this.values))}};r.length.get=function(){return this.values.length};r.depth.get=function(){return 0};Object.defineProperties(e.prototype,r);return e}(Rf);Rf.empty=new jf([]);var Nf=function(t){function e(e,r){t.call(this);this.left=e;this.right=r;this.length=e.length+r.length;this.depth=Math.max(e.depth,r.depth)+1}if(t)e.__proto__=t;e.prototype=Object.create(t&&t.prototype);e.prototype.constructor=e;e.prototype.flatten=function t(){return this.left.flatten().concat(this.right.flatten())};e.prototype.getInner=function t(e){return e<this.left.length?this.left.get(e):this.right.get(e-this.left.length)};e.prototype.forEachInner=function t(e,r,i,n){var s=this.left.length;if(r<s&&this.left.forEachInner(e,r,Math.min(i,s),n)===false){return false}if(i>s&&this.right.forEachInner(e,Math.max(r-s,0),Math.min(this.length,i)-s,n+s)===false){return false}};e.prototype.forEachInvertedInner=function t(e,r,i,n){var s=this.left.length;if(r>s&&this.right.forEachInvertedInner(e,r-s,Math.max(i,s)-s,n+s)===false){return false}if(i<s&&this.left.forEachInvertedInner(e,Math.min(r,s),i,n)===false){return false}};e.prototype.sliceInner=function t(e,r){if(e==0&&r==this.length){return this}var i=this.left.length;if(r<=i){return this.left.slice(e,r)}if(e>=i){return this.right.slice(e-i,r-i)}return this.left.slice(e,i).append(this.right.slice(0,r-i))};e.prototype.leafAppend=function t(r){var i=this.right.leafAppend(r);if(i){return new e(this.left,i)}};e.prototype.leafPrepend=function t(r){var i=this.left.leafPrepend(r);if(i){return new e(i,this.right)}};e.prototype.appendInner=function t(r){if(this.left.depth>=Math.max(this.right.depth,r.depth)+1){return new e(this.left,new e(this.right,r))}return new e(this,r)};return e}(Rf);const qf=500;class Tf{constructor(t,e){this.items=t;this.eventCount=e}popEvent(t,e){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--){let t=this.items.get(r-1);if(t.selection){--r;break}}let i,n;if(e){i=this.remapping(r,this.items.length);n=i.maps.length}let s=t.tr;let l,o;let u=[],f=[];this.items.forEach(((t,e)=>{if(!t.step){if(!i){i=this.remapping(r,e+1);n=i.maps.length}n--;f.push(t);return}if(i){f.push(new If(t.map));let e=t.step.map(i.slice(n)),r;if(e&&s.maybeStep(e).doc){r=s.mapping.maps[s.mapping.maps.length-1];u.push(new If(r,undefined,undefined,u.length+f.length))}n--;if(r)i.appendMap(r,n)}else{s.maybeStep(t.step)}if(t.selection){l=i?t.selection.map(i.slice(n)):t.selection;o=new Tf(this.items.slice(0,r).append(f.reverse().concat(u)),this.eventCount-1);return false}}),this.items.length,0);return{remaining:o,transform:s,selection:l}}addTransform(t,e,r,i){let n=[],s=this.eventCount;let l=this.items,o=!i&&l.length?l.get(l.length-1):null;for(let r=0;r<t.steps.length;r++){let u=t.steps[r].invert(t.docs[r]);let f=new If(t.mapping.maps[r],u,e),h;if(h=o&&o.merge(f)){f=h;if(r)n.pop();else l=l.slice(0,l.length-1)}n.push(f);if(e){s++;e=undefined}if(!i)o=f}let u=s-r.depth;if(u>Jf){l=zf(l,u);s-=u}return new Tf(l.append(n),s)}remapping(t,e){let r=new Gr;this.items.forEach(((e,i)=>{let n=e.mirrorOffset!=null&&i-e.mirrorOffset>=t?r.maps.length-e.mirrorOffset:undefined;r.appendMap(e.map,n)}),t,e);return r}addMaps(t){if(this.eventCount==0)return this;return new Tf(this.items.append(t.map((t=>new If(t)))),this.eventCount)}rebased(t,e){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-e);let n=t.mapping;let s=t.steps.length;let l=this.eventCount;this.items.forEach((t=>{if(t.selection)l--}),i);let o=e;this.items.forEach((e=>{let i=n.getMirror(--o);if(i==null)return;s=Math.min(s,i);let u=n.maps[i];if(e.step){let s=t.steps[i].invert(t.docs[i]);let f=e.selection&&e.selection.map(n.slice(o+1,i));if(f)l++;r.push(new If(u,s,f))}else{r.push(new If(u))}}),i);let u=[];for(let t=e;t<s;t++)u.push(new If(n.maps[t]));let f=this.items.slice(0,i).append(u).append(r);let h=new Tf(f,l);if(h.emptyItemCount()>qf)h=h.compress(this.items.length-r.length);return h}emptyItemCount(){let t=0;this.items.forEach((e=>{if(!e.step)t++}));return t}compress(t=this.items.length){let e=this.remapping(0,t),r=e.maps.length;let i=[],n=0;this.items.forEach(((s,l)=>{if(l>=t){i.push(s);if(s.selection)n++}else if(s.step){let t=s.step.map(e.slice(r)),l=t&&t.getMap();r--;if(l)e.appendMap(l,r);if(t){let o=s.selection&&s.selection.map(e.slice(r));if(o)n++;let u=new If(l.invert(),t,o),f,h=i.length-1;if(f=i.length&&i[h].merge(u))i[h]=f;else i.push(u)}}else if(s.map){r--}}),this.items.length,0);return new Tf(Rf.from(i.reverse()),n)}}Tf.empty=new Tf(Rf.empty,0);function zf(t,e){let r;t.forEach(((t,i)=>{if(t.selection&&e--==0){r=i;return false}}));return t.slice(r)}class If{constructor(t,e,r,i){this.map=t;this.step=e;this.selection=r;this.mirrorOffset=i}merge(t){if(this.step&&t.step&&!t.selection){let e=t.step.merge(this.step);if(e)return new If(e.getMap().invert(),e,this.selection)}}}class Pf{constructor(t,e,r,i,n){this.done=t;this.undone=e;this.prevRanges=r;this.prevTime=i;this.prevComposition=n}}const Jf=20;function Lf(t,e,r,i){let n=r.getMeta(Xf),s;if(n)return n.historyState;if(r.getMeta(Yf))t=new Pf(t.done,t.undone,null,0,-1);let l=r.getMeta("appendedTransaction");if(r.steps.length==0){return t}else if(l&&l.getMeta(Xf)){if(l.getMeta(Xf).redo)return new Pf(t.done.addTransform(r,undefined,i,Gf(e)),t.undone,Uf(r.mapping.maps[r.steps.length-1]),t.prevTime,t.prevComposition);else return new Pf(t.done,t.undone.addTransform(r,undefined,i,Gf(e)),null,t.prevTime,t.prevComposition)}else if(r.getMeta("addToHistory")!==false&&!(l&&l.getMeta("addToHistory")===false)){let n=r.getMeta("composition");let s=t.prevTime==0||!l&&t.prevComposition!=n&&(t.prevTime<(r.time||0)-i.newGroupDelay||!Wf(r,t.prevRanges));let o=l?Hf(t.prevRanges,r.mapping):Uf(r.mapping.maps[r.steps.length-1]);return new Pf(t.done.addTransform(r,s?e.selection.getBookmark():undefined,i,Gf(e)),Tf.empty,o,r.time,n==null?t.prevComposition:n)}else if(s=r.getMeta("rebased")){return new Pf(t.done.rebased(r,s),t.undone.rebased(r,s),Hf(t.prevRanges,r.mapping),t.prevTime,t.prevComposition)}else{return new Pf(t.done.addMaps(r.mapping.maps),t.undone.addMaps(r.mapping.maps),Hf(t.prevRanges,r.mapping),t.prevTime,t.prevComposition)}}function Wf(t,e){if(!e)return false;if(!t.docChanged)return true;let r=false;t.mapping.maps[0].forEach(((t,i)=>{for(let n=0;n<e.length;n+=2)if(t<=e[n+1]&&i>=e[n])r=true}));return r}function Uf(t){let e=[];t.forEach(((t,r,i,n)=>e.push(i,n)));return e}function Hf(t,e){if(!t)return null;let r=[];for(let i=0;i<t.length;i+=2){let n=e.map(t[i],1),s=e.map(t[i+1],-1);if(n<=s)r.push(n,s)}return r}function Zf(t,e,r,i){let n=Gf(e);let s=Xf.get(e).spec.config;let l=(i?t.undone:t.done).popEvent(e,n);if(!l)return;let o=l.selection.resolve(l.transform.doc);let u=(i?t.done:t.undone).addTransform(l.transform,e.selection.getBookmark(),s,n);let f=new Pf(i?u:l.remaining,i?l.remaining:u,null,0,-1);r(l.transform.setSelection(o).setMeta(Xf,{redo:i,historyState:f}).scrollIntoView())}let Kf=false,Vf=null;function Gf(t){let e=t.plugins;if(Vf!=e){Kf=false;Vf=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){Kf=true;break}}return Kf}const Xf=new Mn("history");const Yf=new Mn("closeHistory");function Qf(t={}){t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500};return new yn({key:Xf,state:{init(){return new Pf(Tf.empty,Tf.empty,null,0,-1)},apply(e,r,i){return Lf(r,i,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(t,e){let r=e.inputType;let i=r=="historyUndo"?th:r=="historyRedo"?eh:null;if(!i)return false;e.preventDefault();return i(t.state,t.dispatch)}}}})}const th=(t,e)=>{let r=Xf.getState(t);if(!r||r.done.eventCount==0)return false;if(e)Zf(r,t,e,false);return true};const eh=(t,e)=>{let r=Xf.getState(t);if(!r||r.undone.eventCount==0)return false;if(e)Zf(r,t,e,true);return true};const rh=(t,e)=>{if(t.selection.empty)return false;if(e)e(t.tr.deleteSelection().scrollIntoView());return true};function ih(t,e){let{$cursor:r}=t.selection;if(!r||(e?!e.endOfTextblock("backward",t):r.parentOffset>0))return null;return r}const nh=(t,e,r)=>{let i=ih(t,r);if(!i)return false;let n=oh(i);if(!n){let r=i.blockRange(),n=r&&ci(r);if(n==null)return false;if(e)e(t.tr.lift(r,n).scrollIntoView());return true}let s=n.nodeBefore;if(!s.type.spec.isolating&&Mh(t,n,e))return true;if(i.parent.content.size==0&&(sh(s,"end")||ln.isSelectable(s))){let r=Bi(t.doc,i.before(),i.after(),Ee.empty);if(r&&r.slice.size<r.to-r.from){if(e){let i=t.tr.step(r);i.setSelection(sh(s,"end")?Qi.findFrom(i.doc.resolve(i.mapping.map(n.pos,-1)),-1):ln.create(i.doc,n.pos-s.nodeSize));e(i.scrollIntoView())}return true}}if(s.isAtom&&n.depth==i.depth-1){if(e)e(t.tr.delete(n.pos-s.nodeSize,n.pos).scrollIntoView());return true}return false};function sh(t,e,r=false){for(let i=t;i;i=e=="start"?i.firstChild:i.lastChild){if(i.isTextblock)return true;if(r&&i.childCount!=1)return false}return false}const lh=(t,e,r)=>{let{$head:i,empty:n}=t.selection,s=i;if(!n)return false;if(i.parent.isTextblock){if(r?!r.endOfTextblock("backward",t):i.parentOffset>0)return false;s=oh(i)}let l=s&&s.nodeBefore;if(!l||!ln.isSelectable(l))return false;if(e)e(t.tr.setSelection(ln.create(t.doc,s.pos-l.nodeSize)).scrollIntoView());return true};function oh(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){if(t.index(e)>0)return t.doc.resolve(t.before(e+1));if(t.node(e).type.spec.isolating)break}return null}function uh(t,e){let{$cursor:r}=t.selection;if(!r||(e?!e.endOfTextblock("forward",t):r.parentOffset<r.parent.content.size))return null;return r}const fh=(t,e,r)=>{let i=uh(t,r);if(!i)return false;let n=ah(i);if(!n)return false;let s=n.nodeAfter;if(Mh(t,n,e))return true;if(i.parent.content.size==0&&(sh(s,"start")||ln.isSelectable(s))){let r=Bi(t.doc,i.before(),i.after(),Ee.empty);if(r&&r.slice.size<r.to-r.from){if(e){let i=t.tr.step(r);i.setSelection(sh(s,"start")?Qi.findFrom(i.doc.resolve(i.mapping.map(n.pos)),1):ln.create(i.doc,i.mapping.map(n.pos)));e(i.scrollIntoView())}return true}}if(s.isAtom&&n.depth==i.depth-1){if(e)e(t.tr.delete(n.pos,n.pos+s.nodeSize).scrollIntoView());return true}return false};const hh=(t,e,r)=>{let{$head:i,empty:n}=t.selection,s=i;if(!n)return false;if(i.parent.isTextblock){if(r?!r.endOfTextblock("forward",t):i.parentOffset<i.parent.content.size)return false;s=ah(i)}let l=s&&s.nodeAfter;if(!l||!ln.isSelectable(l))return false;if(e)e(t.tr.setSelection(ln.create(t.doc,s.pos)).scrollIntoView());return true};function ah(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){let r=t.node(e);if(t.index(e)+1<r.childCount)return t.doc.resolve(t.after(e+1));if(r.type.spec.isolating)break}return null}const ch=(t,e)=>{let r=t.selection,i=r instanceof ln,n;if(i){if(r.node.isTextblock||!xi(t.doc,r.from))return false;n=r.from}else{n=Si(t.doc,r.from,-1);if(n==null)return false}if(e){let r=t.tr.join(n);if(i)r.setSelection(ln.create(r.doc,n-t.doc.resolve(n).nodeBefore.nodeSize));e(r.scrollIntoView())}return true};const dh=(t,e)=>{let r=t.selection,i;if(r instanceof ln){if(r.node.isTextblock||!xi(t.doc,r.to))return false;i=r.to}else{i=Si(t.doc,r.to,1);if(i==null)return false}if(e)e(t.tr.join(i).scrollIntoView());return true};const ph=(t,e)=>{let{$from:r,$to:i}=t.selection;let n=r.blockRange(i),s=n&&ci(n);if(s==null)return false;if(e)e(t.tr.lift(n,s).scrollIntoView());return true};const mh=(t,e)=>{let{$head:r,$anchor:i}=t.selection;if(!r.parent.type.spec.code||!r.sameParent(i))return false;if(e)e(t.tr.insertText("\n").scrollIntoView());return true};function wh(t){for(let e=0;e<t.edgeCount;e++){let{type:r}=t.edge(e);if(r.isTextblock&&!r.hasRequiredAttrs())return r}return null}const gh=(t,e)=>{let{$head:r,$anchor:i}=t.selection;if(!r.parent.type.spec.code||!r.sameParent(i))return false;let n=r.node(-1),s=r.indexAfter(-1),l=wh(n.contentMatchAt(s));if(!l||!n.canReplaceWith(s,s,l))return false;if(e){let i=r.after(),n=t.tr.replaceWith(i,i,l.createAndFill());n.setSelection(Qi.near(n.doc.resolve(i),1));e(n.scrollIntoView())}return true};const bh=(t,e)=>{let r=t.selection,{$from:i,$to:n}=r;if(r instanceof un||i.parent.inlineContent||n.parent.inlineContent)return false;let s=wh(n.parent.contentMatchAt(n.indexAfter()));if(!s||!s.isTextblock)return false;if(e){let r=(!i.parentOffset&&n.index()<n.parent.childCount?i:n).pos;let l=t.tr.insert(r,s.createAndFill());l.setSelection(nn.create(l.doc,r+1));e(l.scrollIntoView())}return true};const kh=(t,e)=>{let{$cursor:r}=t.selection;if(!r||r.parent.content.size)return false;if(r.depth>1&&r.after()!=r.end(-1)){let i=r.before();if(Ei(t.doc,i)){if(e)e(t.tr.split(i).scrollIntoView());return true}}let i=r.blockRange(),n=i&&ci(i);if(n==null)return false;if(e)e(t.tr.lift(i,n).scrollIntoView());return true};function Dh(t){return(e,r)=>{let{$from:i,$to:n}=e.selection;if(e.selection instanceof ln&&e.selection.node.isBlock){if(!i.parentOffset||!Ei(e.doc,i.pos))return false;if(r)r(e.tr.split(i.pos).scrollIntoView());return true}if(!i.parent.isBlock)return false;if(r){let s=n.parentOffset==n.parent.content.size;let l=e.tr;if(e.selection instanceof nn||e.selection instanceof un)l.deleteSelection();let o=i.depth==0?null:wh(i.node(-1).contentMatchAt(i.indexAfter(-1)));let u=t&&t(n.parent,s);let f=u?[u]:s&&o?[{type:o}]:undefined;let h=Ei(l.doc,l.mapping.map(i.pos),1,f);if(!f&&!h&&Ei(l.doc,l.mapping.map(i.pos),1,o?[{type:o}]:undefined)){if(o)f=[{type:o}];h=true}if(h){l.split(l.mapping.map(i.pos),1,f);if(!s&&!i.parentOffset&&i.parent.type!=o){let t=l.mapping.map(i.before()),e=l.doc.resolve(t);if(o&&i.node(-1).canReplaceWith(e.index(),e.index()+1,o))l.setNodeMarkup(l.mapping.map(i.before()),o)}}r(l.scrollIntoView())}return true}}const vh=Dh();const yh=(t,e)=>{let{$from:r,to:i}=t.selection,n;let s=r.sharedDepth(i);if(s==0)return false;n=r.before(s);if(e)e(t.tr.setSelection(ln.create(t.doc,n)));return true};const Fh=(t,e)=>{if(e)e(t.tr.setSelection(new un(t.doc)));return true};function Eh(t,e,r){let i=e.nodeBefore,n=e.nodeAfter,s=e.index();if(!i||!n||!i.type.compatibleContent(n.type))return false;if(!i.content.size&&e.parent.canReplace(s-1,s)){if(r)r(t.tr.delete(e.pos-i.nodeSize,e.pos).scrollIntoView());return true}if(!e.parent.canReplace(s,s+1)||!(n.isTextblock||xi(t.doc,e.pos)))return false;if(r)r(t.tr.clearIncompatible(e.pos,i.type,i.contentMatchAt(i.childCount)).join(e.pos).scrollIntoView());return true}function Mh(t,e,r){let i=e.nodeBefore,n=e.nodeAfter,s,l;if(i.type.spec.isolating||n.type.spec.isolating)return false;if(Eh(t,e,r))return true;let o=e.parent.canReplace(e.index(),e.index()+1);if(o&&(s=(l=i.contentMatchAt(i.childCount)).findWrapping(n.type))&&l.matchType(s[0]||n.type).validEnd){if(r){let l=e.pos+n.nodeSize,o=be.empty;for(let t=s.length-1;t>=0;t--)o=be.from(s[t].create(null,o));o=be.from(i.copy(o));let u=t.tr.step(new li(e.pos-1,l,e.pos,l,new Ee(o,1,0),s.length,true));let f=l+2*s.length;if(xi(u.doc,f))u.join(f);r(u.scrollIntoView())}return true}let u=Qi.findFrom(e,1);let f=u&&u.$from.blockRange(u.$to),h=f&&ci(f);if(h!=null&&h>=e.depth){if(r)r(t.tr.lift(f,h).scrollIntoView());return true}if(o&&sh(n,"start",true)&&sh(i,"end")){let s=i,l=[];for(;;){l.push(s);if(s.isTextblock)break;s=s.lastChild}let o=n,u=1;for(;!o.isTextblock;o=o.firstChild)u++;if(s.canReplace(s.childCount,s.childCount,o.content)){if(r){let i=be.empty;for(let t=l.length-1;t>=0;t--)i=be.from(l[t].copy(i));let s=t.tr.step(new li(e.pos-l.length,e.pos+n.nodeSize,e.pos+u,e.pos+n.nodeSize-u,new Ee(i,l.length,0),0,true));r(s.scrollIntoView())}return true}}return false}function xh(t){return function(e,r){let i=e.selection,n=t<0?i.$from:i.$to;let s=n.depth;while(n.node(s).isInline){if(!s)return false;s--}if(!n.node(s).isTextblock)return false;if(r)r(e.tr.setSelection(nn.create(e.doc,t<0?n.start(s):n.end(s))));return true}}const Ah=xh(-1);const Ch=xh(1);function Sh(t,e=null){return function(r,i){let{$from:n,$to:s}=r.selection;let l=n.blockRange(s),o=l&&pi(l,t,e);if(!o)return false;if(i)i(r.tr.wrap(l,o).scrollIntoView());return true}}function Oh(t,e=null){return function(r,i){let n=false;for(let i=0;i<r.selection.ranges.length&&!n;i++){let{$from:{pos:s},$to:{pos:l}}=r.selection.ranges[i];r.doc.nodesBetween(s,l,((i,s)=>{if(n)return false;if(!i.isTextblock||i.hasMarkup(t,e))return;if(i.type==t){n=true}else{let e=r.doc.resolve(s),i=e.index();n=e.parent.canReplaceWith(i,i+1,t)}}))}if(!n)return false;if(i){let n=r.tr;for(let i=0;i<r.selection.ranges.length;i++){let{$from:{pos:s},$to:{pos:l}}=r.selection.ranges[i];n.setBlockType(s,l,t,e)}i(n.scrollIntoView())}return true}}function $h(t,e,r){for(let i=0;i<e.length;i++){let{$from:n,$to:s}=e[i];let l=n.depth==0?t.inlineContent&&t.type.allowsMarkType(r):false;t.nodesBetween(n.pos,s.pos,(t=>{if(l)return false;l=t.inlineContent&&t.type.allowsMarkType(r)}));if(l)return true}return false}function _h(t,e=null){return function(r,i){let{empty:n,$cursor:s,ranges:l}=r.selection;if(n&&!s||!$h(r.doc,l,t))return false;if(i){if(s){if(t.isInSet(r.storedMarks||s.marks()))i(r.tr.removeStoredMark(t));else i(r.tr.addStoredMark(t.create(e)))}else{let n=false,s=r.tr;for(let e=0;!n&&e<l.length;e++){let{$from:i,$to:s}=l[e];n=r.doc.rangeHasMark(i.pos,s.pos,t)}for(let r=0;r<l.length;r++){let{$from:i,$to:o}=l[r];if(n){s.removeMark(i.pos,o.pos,t)}else{let r=i.pos,n=o.pos,l=i.nodeAfter,u=o.nodeBefore;let f=l&&l.isText?/^\s*/.exec(l.text)[0].length:0;let h=u&&u.isText?/\s*$/.exec(u.text)[0].length:0;if(r+f<n){r+=f;n-=h}s.addMark(r,n,t.create(e))}}i(s.scrollIntoView())}}return true}}function Bh(...t){return function(e,r,i){for(let n=0;n<t.length;n++)if(t[n](e,r,i))return true;return false}}let Rh=Bh(rh,nh,lh);let jh=Bh(rh,fh,hh);const Nh={Enter:Bh(mh,bh,kh,vh),"Mod-Enter":gh,Backspace:Rh,"Mod-Backspace":Rh,"Shift-Backspace":Rh,Delete:jh,"Mod-Delete":jh,"Mod-a":Fh};const qh={"Ctrl-h":Nh["Backspace"],"Alt-Backspace":Nh["Mod-Backspace"],"Ctrl-d":Nh["Delete"],"Ctrl-Alt-Backspace":Nh["Mod-Delete"],"Alt-Delete":Nh["Mod-Delete"],"Alt-d":Nh["Mod-Delete"],"Ctrl-a":Ah,"Ctrl-e":Ch};for(let t in Nh)qh[t]=Nh[t];const Th=typeof navigator!="undefined"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os!="undefined"&&os.platform?os.platform()=="darwin":false;const zh=Th?qh:Nh;function Ih(t={}){return new yn({view(e){return new Ph(e,t)}})}class Ph{constructor(t,e){var r;this.editorView=t;this.cursorPos=null;this.element=null;this.timeout=-1;this.width=(r=e.width)!==null&&r!==void 0?r:1;this.color=e.color===false?undefined:e.color||"black";this.class=e.class;this.handlers=["dragover","dragend","drop","dragleave"].map((e=>{let r=t=>{this[e](t)};t.dom.addEventListener(e,r);return{name:e,handler:r}}))}destroy(){this.handlers.forEach((({name:t,handler:e})=>this.editorView.dom.removeEventListener(t,e)))}update(t,e){if(this.cursorPos!=null&&e.doc!=t.state.doc){if(this.cursorPos>t.state.doc.content.size)this.setCursor(null);else this.updateOverlay()}}setCursor(t){if(t==this.cursorPos)return;this.cursorPos=t;if(t==null){this.element.parentNode.removeChild(this.element);this.element=null}else{this.updateOverlay()}}updateOverlay(){let t=this.editorView.state.doc.resolve(this.cursorPos);let e=!t.parent.inlineContent,r;if(e){let e=t.nodeBefore,i=t.nodeAfter;if(e||i){let t=this.editorView.nodeDOM(this.cursorPos-(e?e.nodeSize:0));if(t){let n=t.getBoundingClientRect();let s=e?n.bottom:n.top;if(e&&i)s=(s+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2;r={left:n.left,right:n.right,top:s-this.width/2,bottom:s+this.width/2}}}}if(!r){let t=this.editorView.coordsAtPos(this.cursorPos);r={left:t.left-this.width/2,right:t.left+this.width/2,top:t.top,bottom:t.bottom}}let i=this.editorView.dom.offsetParent;if(!this.element){this.element=i.appendChild(document.createElement("div"));if(this.class)this.element.className=this.class;this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;";if(this.color){this.element.style.backgroundColor=this.color}}this.element.classList.toggle("prosemirror-dropcursor-block",e);this.element.classList.toggle("prosemirror-dropcursor-inline",!e);let n,s;if(!i||i==document.body&&getComputedStyle(i).position=="static"){n=-pageXOffset;s=-pageYOffset}else{let t=i.getBoundingClientRect();n=t.left-i.scrollLeft;s=t.top-i.scrollTop}this.element.style.left=r.left-n+"px";this.element.style.top=r.top-s+"px";this.element.style.width=r.right-r.left+"px";this.element.style.height=r.bottom-r.top+"px"}scheduleRemoval(t){clearTimeout(this.timeout);this.timeout=setTimeout((()=>this.setCursor(null)),t)}dragover(t){if(!this.editorView.editable)return;let e=this.editorView.posAtCoords({left:t.clientX,top:t.clientY});let r=e&&e.inside>=0&&this.editorView.state.doc.nodeAt(e.inside);let i=r&&r.type.spec.disableDropCursor;let n=typeof i=="function"?i(this.editorView,e,t):i;if(e&&!n){let t=e.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let e=_i(this.editorView.state.doc,t,this.editorView.dragging.slice);if(e!=null)t=e}this.setCursor(t);this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(t){if(t.target==this.editorView.dom||!this.editorView.dom.contains(t.relatedTarget))this.setCursor(null)}}class Jh extends Qi{constructor(t){super(t,t)}map(t,e){let r=t.resolve(e.map(this.head));return Jh.valid(r)?new Jh(r):Qi.near(r)}content(){return Ee.empty}eq(t){return t instanceof Jh&&t.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(t,e){if(typeof e.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new Jh(t.resolve(e.pos))}getBookmark(){return new Lh(this.anchor)}static valid(t){let e=t.parent;if(e.isTextblock||!Wh(t)||!Uh(t))return false;let r=e.type.spec.allowGapCursor;if(r!=null)return r;let i=e.contentMatchAt(t.index()).defaultType;return i&&i.isTextblock}static findGapCursorFrom(t,e,r=false){t:for(;;){if(!r&&Jh.valid(t))return t;let i=t.pos,n=null;for(let r=t.depth;;r--){let s=t.node(r);if(e>0?t.indexAfter(r)<s.childCount:t.index(r)>0){n=s.child(e>0?t.indexAfter(r):t.index(r)-1);break}else if(r==0){return null}i+=e;let l=t.doc.resolve(i);if(Jh.valid(l))return l}for(;;){let s=e>0?n.firstChild:n.lastChild;if(!s){if(n.isAtom&&!n.isText&&!ln.isSelectable(n)){t=t.doc.resolve(i+n.nodeSize*e);r=false;continue t}break}n=s;i+=e;let l=t.doc.resolve(i);if(Jh.valid(l))return l}return null}}}Jh.prototype.visible=false;Jh.findFrom=Jh.findGapCursorFrom;Qi.jsonID("gapcursor",Jh);class Lh{constructor(t){this.pos=t}map(t){return new Lh(t.map(this.pos))}resolve(t){let e=t.resolve(this.pos);return Jh.valid(e)?new Jh(e):Qi.near(e)}}function Wh(t){for(let e=t.depth;e>=0;e--){let r=t.index(e),i=t.node(e);if(r==0){if(i.type.spec.isolating)return true;continue}for(let t=i.child(r-1);;t=t.lastChild){if(t.childCount==0&&!t.inlineContent||t.isAtom||t.type.spec.isolating)return true;if(t.inlineContent)return false}}return true}function Uh(t){for(let e=t.depth;e>=0;e--){let r=t.indexAfter(e),i=t.node(e);if(r==i.childCount){if(i.type.spec.isolating)return true;continue}for(let t=i.child(r);;t=t.firstChild){if(t.childCount==0&&!t.inlineContent||t.isAtom||t.type.spec.isolating)return true;if(t.inlineContent)return false}}return true}function Hh(){return new yn({props:{decorations:Xh,createSelectionBetween(t,e,r){return e.pos==r.pos&&Jh.valid(r)?new Jh(r):null},handleClick:Vh,handleKeyDown:Zh,handleDOMEvents:{beforeinput:Gh}}})}const Zh=_f({ArrowLeft:Kh("horiz",-1),ArrowRight:Kh("horiz",1),ArrowUp:Kh("vert",-1),ArrowDown:Kh("vert",1)});function Kh(t,e){const r=t=="vert"?e>0?"down":"up":e>0?"right":"left";return function(t,i,n){let s=t.selection;let l=e>0?s.$to:s.$from,o=s.empty;if(s instanceof nn){if(!n.endOfTextblock(r)||l.depth==0)return false;o=false;l=t.doc.resolve(e>0?l.after():l.before())}let u=Jh.findGapCursorFrom(l,e,o);if(!u)return false;if(i)i(t.tr.setSelection(new Jh(u)));return true}}function Vh(t,e,r){if(!t||!t.editable)return false;let i=t.state.doc.resolve(e);if(!Jh.valid(i))return false;let n=t.posAtCoords({left:r.clientX,top:r.clientY});if(n&&n.inside>-1&&ln.isSelectable(t.state.doc.nodeAt(n.inside)))return false;t.dispatch(t.state.tr.setSelection(new Jh(i)));return true}function Gh(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof Jh))return false;let{$from:r}=t.state.selection;let i=r.parent.contentMatchAt(r.index()).findWrapping(t.state.schema.nodes.text);if(!i)return false;let n=be.empty;for(let t=i.length-1;t>=0;t--)n=be.from(i[t].createAndFill(null,n));let s=t.state.tr.replace(r.pos,r.pos,new Ee(n,0,0));s.setSelection(nn.near(s.doc.resolve(r.pos+1)));t.dispatch(s);return false}function Xh(t){if(!(t.selection instanceof Jh))return null;let e=document.createElement("div");e.className="ProseMirror-gapcursor";return lu.create(t.doc,[iu.widget(t.selection.head,e,{key:"gapcursor"})])}function Yh(){var t=arguments[0];if(typeof t=="string")t=document.createElement(t);var e=1,r=arguments[1];if(r&&typeof r=="object"&&r.nodeType==null&&!Array.isArray(r)){for(var i in r)if(Object.prototype.hasOwnProperty.call(r,i)){var n=r[i];if(typeof n=="string")t.setAttribute(i,n);else if(n!=null)t[i]=n}e++}for(;e<arguments.length;e++)Qh(t,arguments[e]);return t}function Qh(t,e){if(typeof e=="string"){t.appendChild(document.createTextNode(e))}else if(e==null);else if(e.nodeType!=null){t.appendChild(e)}else if(Array.isArray(e)){for(var r=0;r<e.length;r++)Qh(t,e[r])}else{throw new RangeError("Unsupported child node: "+e)}}const ta="http://www.w3.org/2000/svg";const ea="http://www.w3.org/1999/xlink";const ra="ProseMirror-icon";function ia(t){let e=0;for(let r=0;r<t.length;r++)e=(e<<5)-e+t.charCodeAt(r)|0;return e}function na(t,e){let r=(t.nodeType==9?t:t.ownerDocument)||document;let i=r.createElement("div");i.className=ra;if(e.path){let{path:n,width:s,height:l}=e;let o="pm-icon-"+ia(n).toString(16);if(!r.getElementById(o))sa(t,o,e);let u=i.appendChild(r.createElementNS(ta,"svg"));u.style.width=s/l+"em";let f=u.appendChild(r.createElementNS(ta,"use"));f.setAttributeNS(ea,"href",/([^#]*)/.exec(r.location.toString())[1]+"#"+o)}else if(e.dom){i.appendChild(e.dom.cloneNode(true))}else{let{text:t,css:n}=e;i.appendChild(r.createElement("span")).textContent=t||"";if(n)i.firstChild.style.cssText=n}return i}function sa(t,e,r){let[i,n]=t.nodeType==9?[t,t.body]:[t.ownerDocument||document,t];let s=i.getElementById(ra+"-collection");if(!s){s=i.createElementNS(ta,"svg");s.id=ra+"-collection";s.style.display="none";n.insertBefore(s,n.firstChild)}let l=i.createElementNS(ta,"symbol");l.id=e;l.setAttribute("viewBox","0 0 "+r.width+" "+r.height);let o=l.appendChild(i.createElementNS(ta,"path"));o.setAttribute("d",r.path);s.appendChild(l)}const la="ProseMirror-menu";class oa{constructor(t){this.spec=t}render(t){let e=this.spec;let r=e.render?e.render(t):e.icon?na(t.root,e.icon):e.label?Yh("div",null,ua(t,e.label)):null;if(!r)throw new RangeError("MenuItem without icon or label property");if(e.title){const i=typeof e.title==="function"?e.title(t.state):e.title;r.setAttribute("title",ua(t,i))}if(e.class)r.classList.add(e.class);if(e.css)r.style.cssText+=e.css;r.addEventListener("mousedown",(i=>{i.preventDefault();if(!r.classList.contains(la+"-disabled"))e.run(t.state,t.dispatch,t,i)}));function i(t){if(e.select){let i=e.select(t);r.style.display=i?"":"none";if(!i)return false}let i=true;if(e.enable){i=e.enable(t)||false;xa(r,la+"-disabled",!i)}if(e.active){let n=i&&e.active(t)||false;xa(r,la+"-active",n)}return true}return{dom:r,update:i}}}function ua(t,e){return t._props.translate?t._props.translate(e):e}let fa={time:0,node:null};function ha(t){fa.time=Date.now();fa.node=t.target}function aa(t){return Date.now()-100<fa.time&&fa.node&&t.contains(fa.node)}class ca{constructor(t,e={}){this.options=e;this.options=e||{};this.content=Array.isArray(t)?t:[t]}render(t){let e=da(this.content,t);let r=t.dom.ownerDocument.defaultView||window;let i=Yh("div",{class:la+"-dropdown "+(this.options.class||""),style:this.options.css},ua(t,this.options.label||""));if(this.options.title)i.setAttribute("title",ua(t,this.options.title));let n=Yh("div",{class:la+"-dropdown-wrap"},i);let s=null;let l=null;let o=()=>{if(s&&s.close()){s=null;r.removeEventListener("mousedown",l)}};i.addEventListener("mousedown",(t=>{t.preventDefault();ha(t);if(s){o()}else{s=this.expand(n,e.dom);r.addEventListener("mousedown",l=()=>{if(!aa(n))o()})}}));function u(t){let r=e.update(t);n.style.display=r?"":"none";return r}return{dom:n,update:u}}expand(t,e){let r=Yh("div",{class:la+"-dropdown-menu "+(this.options.class||"")},e);let i=false;function n(){if(i)return false;i=true;t.removeChild(r);return true}t.appendChild(r);return{close:n,node:r}}}function da(t,e){let r=[],i=[];for(let n=0;n<t.length;n++){let{dom:s,update:l}=t[n].render(e);r.push(Yh("div",{class:la+"-dropdown-item"},s));i.push(l)}return{dom:r,update:pa(i,r)}}function pa(t,e){return r=>{let i=false;for(let n=0;n<t.length;n++){let s=t[n](r);e[n].style.display=s?"":"none";if(s)i=true}return i}}class ma{constructor(t,e={}){this.options=e;this.content=Array.isArray(t)?t:[t]}render(t){let e=da(this.content,t);let r=t.dom.ownerDocument.defaultView||window;let i=Yh("div",{class:la+"-submenu-label"},ua(t,this.options.label||""));let n=Yh("div",{class:la+"-submenu-wrap"},i,Yh("div",{class:la+"-submenu"},e.dom));let s=null;i.addEventListener("mousedown",(t=>{t.preventDefault();ha(t);xa(n,la+"-submenu-wrap-active",false);if(!s)r.addEventListener("mousedown",s=()=>{if(!aa(n)){n.classList.remove(la+"-submenu-wrap-active");r.removeEventListener("mousedown",s);s=null}})}));function l(t){let r=e.update(t);n.style.display=r?"":"none";return r}return{dom:n,update:l}}}function wa(t,e){let r=document.createDocumentFragment();let i=[],n=[];for(let s=0;s<e.length;s++){let l=e[s],o=[],u=[];for(let e=0;e<l.length;e++){let{dom:i,update:n}=l[e].render(t);let s=Yh("span",{class:la+"item"},i);r.appendChild(s);u.push(s);o.push(n)}if(o.length){i.push(pa(o,u));if(s<e.length-1)n.push(r.appendChild(ga()))}}function s(t){let e=false,r=false;for(let s=0;s<i.length;s++){let l=i[s](t);if(s)n[s-1].style.display=r&&l?"":"none";r=l;if(l)e=true}return e}return{dom:r,update:s}}function ga(){return Yh("span",{class:la+"separator"})}const ba={join:{width:800,height:900,path:"M0 75h800v125h-800z M0 825h800v-125h-800z M250 400h100v-100h100v100h100v100h-100v100h-100v-100h-100z"},lift:{width:1024,height:1024,path:"M219 310v329q0 7-5 12t-12 5q-8 0-13-5l-164-164q-5-5-5-13t5-13l164-164q5-5 13-5 7 0 12 5t5 12zM1024 749v109q0 7-5 12t-12 5h-987q-7 0-12-5t-5-12v-109q0-7 5-12t12-5h987q7 0 12 5t5 12zM1024 530v109q0 7-5 12t-12 5h-621q-7 0-12-5t-5-12v-109q0-7 5-12t12-5h621q7 0 12 5t5 12zM1024 310v109q0 7-5 12t-12 5h-621q-7 0-12-5t-5-12v-109q0-7 5-12t12-5h621q7 0 12 5t5 12zM1024 91v109q0 7-5 12t-12 5h-987q-7 0-12-5t-5-12v-109q0-7 5-12t12-5h987q7 0 12 5t5 12z"},selectParentNode:{text:"⬚",css:"font-weight: bold"},undo:{width:1024,height:1024,path:"M761 1024c113-206 132-520-313-509v253l-384-384 384-384v248c534-13 594 472 313 775z"},redo:{width:1024,height:1024,path:"M576 248v-248l384 384-384 384v-253c-446-10-427 303-313 509-280-303-221-789 313-775z"},strong:{width:805,height:1024,path:"M317 869q42 18 80 18 214 0 214-191 0-65-23-102-15-25-35-42t-38-26-46-14-48-6-54-1q-41 0-57 5 0 30-0 90t-0 90q0 4-0 38t-0 55 2 47 6 38zM309 442q24 4 62 4 46 0 81-7t62-25 42-51 14-81q0-40-16-70t-45-46-61-24-70-8q-28 0-74 7 0 28 2 86t2 86q0 15-0 45t-0 45q0 26 0 39zM0 950l1-53q8-2 48-9t60-15q4-6 7-15t4-19 3-18 1-21 0-19v-37q0-561-12-585-2-4-12-8t-25-6-28-4-27-2-17-1l-2-47q56-1 194-6t213-5q13 0 39 0t38 0q40 0 78 7t73 24 61 40 42 59 16 78q0 29-9 54t-22 41-36 32-41 25-48 22q88 20 146 76t58 141q0 57-20 102t-53 74-78 48-93 27-100 8q-25 0-75-1t-75-1q-60 0-175 6t-132 6z"},em:{width:585,height:1024,path:"M0 949l9-48q3-1 46-12t63-21q16-20 23-57 0-4 35-165t65-310 29-169v-14q-13-7-31-10t-39-4-33-3l10-58q18 1 68 3t85 4 68 1q27 0 56-1t69-4 56-3q-2 22-10 50-17 5-58 16t-62 19q-4 10-8 24t-5 22-4 26-3 24q-15 84-50 239t-44 203q-1 5-7 33t-11 51-9 47-3 32l0 10q9 2 105 17-1 25-9 56-6 0-18 0t-18 0q-16 0-49-5t-49-5q-78-1-117-1-29 0-81 5t-69 6z"},code:{width:896,height:1024,path:"M608 192l-96 96 224 224-224 224 96 96 288-320-288-320zM288 192l-288 320 288 320 96-96-224-224 224-224-96-96z"},link:{width:951,height:1024,path:"M832 694q0-22-16-38l-118-118q-16-16-38-16-24 0-41 18 1 1 10 10t12 12 8 10 7 14 2 15q0 22-16 38t-38 16q-8 0-15-2t-14-7-10-8-12-12-10-10q-18 17-18 41 0 22 16 38l117 118q15 15 38 15 22 0 38-14l84-83q16-16 16-38zM430 292q0-22-16-38l-117-118q-16-16-38-16-22 0-38 15l-84 83q-16 16-16 38 0 22 16 38l118 118q15 15 38 15 24 0 41-17-1-1-10-10t-12-12-8-10-7-14-2-15q0-22 16-38t38-16q8 0 15 2t14 7 10 8 12 12 10 10q18-17 18-41zM941 694q0 68-48 116l-84 83q-47 47-116 47-69 0-116-48l-117-118q-47-47-47-116 0-70 50-119l-50-50q-49 50-118 50-68 0-116-48l-118-118q-48-48-48-116t48-116l84-83q47-47 116-47 69 0 116 48l117 118q47 47 47 116 0 70-50 119l50 50q49-50 118-50 68 0 116 48l118 118q48 48 48 116z"},bulletList:{width:768,height:896,path:"M0 512h128v-128h-128v128zM0 256h128v-128h-128v128zM0 768h128v-128h-128v128zM256 512h512v-128h-512v128zM256 256h512v-128h-512v128zM256 768h512v-128h-512v128z"},orderedList:{width:768,height:896,path:"M320 512h448v-128h-448v128zM320 768h448v-128h-448v128zM320 128v128h448v-128h-448zM79 384h78v-256h-36l-85 23v50l43-2v185zM189 590c0-36-12-78-96-78-33 0-64 6-83 16l1 66c21-10 42-15 67-15s32 11 32 28c0 26-30 58-110 112v50h192v-67l-91 2c49-30 87-66 87-113l1-1z"},blockquote:{width:640,height:896,path:"M0 448v256h256v-256h-128c0 0 0-128 128-128v-128c0 0-256 0-256 256zM640 320v-128c0 0-256 0-256 256v256h256v-256h-128c0 0 0-128 128-128z"}};const ka=new oa({title:"Join with above block",run:ch,select:t=>ch(t),icon:ba.join});const Da=new oa({title:"Lift out of enclosing block",run:ph,select:t=>ph(t),icon:ba.lift});const va=new oa({title:"Select parent node",run:yh,select:t=>yh(t),icon:ba.selectParentNode});let ya=new oa({title:"Undo last change",run:th,enable:t=>th(t),icon:ba.undo});let Fa=new oa({title:"Redo last undone change",run:eh,enable:t=>eh(t),icon:ba.redo});function Ea(t,e){let r={run(r,i){return Sh(t,e.attrs)(r,i)},select(r){return Sh(t,e.attrs)(r)}};for(let t in e)r[t]=e[t];return new oa(r)}function Ma(t,e){let r=Oh(t,e.attrs);let i={run:r,enable(t){return r(t)},active(r){let{$from:i,to:n,node:s}=r.selection;if(s)return s.hasMarkup(t,e.attrs);return n<=i.end()&&i.parent.hasMarkup(t,e.attrs)}};for(let t in e)i[t]=e[t];return new oa(i)}function xa(t,e,r){if(r)t.classList.add(e);else t.classList.remove(e)}const Aa="ProseMirror-menubar";function Ca(){if(typeof navigator=="undefined")return false;let t=navigator.userAgent;return!/Edge\/\d/.test(t)&&/AppleWebKit/.test(t)&&/Mobile\/\w+/.test(t)}function Sa(t){return new yn({view(e){return new Oa(e,t)}})}class Oa{constructor(t,e){this.editorView=t;this.options=e;this.spacer=null;this.maxHeight=0;this.widthForMaxHeight=0;this.floating=false;this.scrollHandler=null;this.wrapper=Yh("div",{class:Aa+"-wrapper"});this.menu=this.wrapper.appendChild(Yh("div",{class:Aa}));this.menu.className=Aa;if(t.dom.parentNode)t.dom.parentNode.replaceChild(this.wrapper,t.dom);this.wrapper.appendChild(t.dom);let{dom:r,update:i}=wa(this.editorView,this.options.content);this.contentUpdate=i;this.menu.appendChild(r);this.update();if(e.floating&&!Ca()){this.updateFloat();let t=Ba(this.wrapper);this.scrollHandler=e=>{let r=this.editorView.root;if(!(r.body||r).contains(this.wrapper))t.forEach((t=>t.removeEventListener("scroll",this.scrollHandler)));else this.updateFloat(e.target.getBoundingClientRect?e.target:undefined)};t.forEach((t=>t.addEventListener("scroll",this.scrollHandler)))}}update(){this.contentUpdate(this.editorView.state);if(this.floating){this.updateScrollCursor()}else{if(this.menu.offsetWidth!=this.widthForMaxHeight){this.widthForMaxHeight=this.menu.offsetWidth;this.maxHeight=0}if(this.menu.offsetHeight>this.maxHeight){this.maxHeight=this.menu.offsetHeight;this.menu.style.minHeight=this.maxHeight+"px"}}}updateScrollCursor(){let t=this.editorView.root.getSelection();if(!t.focusNode)return;let e=t.getRangeAt(0).getClientRects();let r=e[$a(t)?0:e.length-1];if(!r)return;let i=this.menu.getBoundingClientRect();if(r.top<i.bottom&&r.bottom>i.top){let t=_a(this.wrapper);if(t)t.scrollTop-=i.bottom-r.top}}updateFloat(t){let e=this.wrapper,r=e.getBoundingClientRect(),i=t?Math.max(0,t.getBoundingClientRect().top):0;if(this.floating){if(r.top>=i||r.bottom<this.menu.offsetHeight+10){this.floating=false;this.menu.style.position=this.menu.style.left=this.menu.style.top=this.menu.style.width="";this.menu.style.display="";this.spacer.parentNode.removeChild(this.spacer);this.spacer=null}else{let n=(e.offsetWidth-e.clientWidth)/2;this.menu.style.left=r.left+n+"px";this.menu.style.display=r.top>(this.editorView.dom.ownerDocument.defaultView||window).innerHeight?"none":"";if(t)this.menu.style.top=i+"px"}}else{if(r.top<i&&r.bottom>=this.menu.offsetHeight+10){this.floating=true;let r=this.menu.getBoundingClientRect();this.menu.style.left=r.left+"px";this.menu.style.width=r.width+"px";if(t)this.menu.style.top=i+"px";this.menu.style.position="fixed";this.spacer=Yh("div",{class:Aa+"-spacer",style:`height: ${r.height}px`});e.insertBefore(this.spacer,this.menu)}}}destroy(){if(this.wrapper.parentNode)this.wrapper.parentNode.replaceChild(this.editorView.dom,this.wrapper)}}function $a(t){if(t.anchorNode==t.focusNode)return t.anchorOffset>t.focusOffset;return t.anchorNode.compareDocumentPosition(t.focusNode)==Node.DOCUMENT_POSITION_FOLLOWING}function _a(t){for(let e=t.parentNode;e;e=e.parentNode)if(e.scrollHeight>e.clientHeight)return e}function Ba(t){let e=[t.ownerDocument.defaultView||window];for(let r=t.parentNode;r;r=r.parentNode)e.push(r);return e}class Ra{constructor(t,e,r={}){this.match=t;this.match=t;this.handler=typeof e=="string"?ja(e):e;this.undoable=r.undoable!==false;this.inCode=r.inCode||false}}function ja(t){return function(e,r,i,n){let s=t;if(r[1]){let t=r[0].lastIndexOf(r[1]);s+=r[0].slice(t+r[1].length);i+=t;let e=i-n;if(e>0){s=r[0].slice(t-e,t)+s;i=n}}return e.tr.insertText(s,i,n)}}const Na=500;function qa({rules:t}){let e=new yn({state:{init(){return null},apply(t,e){let r=t.getMeta(this);if(r)return r;return t.selectionSet||t.docChanged?null:e}},props:{handleTextInput(r,i,n,s){return Ta(r,i,n,s,t,e)},handleDOMEvents:{compositionend:r=>{setTimeout((()=>{let{$cursor:i}=r.state.selection;if(i)Ta(r,i.pos,i.pos,"",t,e)}))}}},isInputRules:true});return e}function Ta(t,e,r,i,n,s){if(t.composing)return false;let l=t.state,o=l.doc.resolve(e);let u=o.parent.textBetween(Math.max(0,o.parentOffset-Na),o.parentOffset,null,"")+i;for(let f=0;f<n.length;f++){let h=n[f];if(o.parent.type.spec.code){if(!h.inCode)continue}else if(h.inCode==="only"){continue}let a=h.match.exec(u);let c=a&&h.handler(l,a,e-(a[0].length-i.length),r);if(!c)continue;if(h.undoable)c.setMeta(s,{transform:c,from:e,to:r,text:i});t.dispatch(c);return true}return false}const za=(t,e)=>{let r=t.plugins;for(let i=0;i<r.length;i++){let n=r[i],s;if(n.spec.isInputRules&&(s=n.getState(t))){if(e){let r=t.tr,i=s.transform;for(let t=i.steps.length-1;t>=0;t--)r.step(i.steps[t].invert(i.docs[t]));if(s.text){let e=r.doc.resolve(s.from).marks();r.replaceWith(s.from,s.to,t.schema.text(s.text,e))}else{r.delete(s.from,s.to)}e(r)}return true}}return false};const Ia=new Ra(/--$/,"—");const Pa=new Ra(/\.\.\.$/,"…");const Ja=new Ra(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,"“");const La=new Ra(/"$/,"”");const Wa=new Ra(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,"‘");const Ua=new Ra(/'$/,"’");const Ha=[Ja,La,Wa,Ua];function Za(t,e,r=null,i){return new Ra(t,((t,n,s,l)=>{let o=r instanceof Function?r(n):r;let u=t.tr.delete(s,l);let f=u.doc.resolve(s),h=f.blockRange(),a=h&&pi(h,e,o);if(!a)return null;u.wrap(h,a);let c=u.doc.resolve(s-1).nodeBefore;if(c&&c.type==e&&xi(u.doc,s-1)&&(!i||i(n,c)))u.join(s-1);return u}))}function Ka(t,e,r=null){return new Ra(t,((t,i,n,s)=>{let l=t.doc.resolve(n);let o=r instanceof Function?r(i):r;if(!l.node(-1).canReplaceWith(l.index(-1),l.indexAfter(-1),e))return null;return t.tr.delete(n,s).setBlockType(n,n,e,o)}))}const Va="ProseMirror-prompt";function Ga(t){let e=document.body.appendChild(document.createElement("div"));e.className=Va;let r=t=>{if(!e.contains(t.target))i()};setTimeout((()=>window.addEventListener("mousedown",r)),50);let i=()=>{window.removeEventListener("mousedown",r);if(e.parentNode)e.parentNode.removeChild(e)};let n=[];for(let e in t.fields)n.push(t.fields[e].render());let s=document.createElement("button");s.type="submit";s.className=Va+"-submit";s.textContent="OK";let l=document.createElement("button");l.type="button";l.className=Va+"-cancel";l.textContent="Cancel";l.addEventListener("click",i);let o=e.appendChild(document.createElement("form"));if(t.title)o.appendChild(document.createElement("h5")).textContent=t.title;n.forEach((t=>{o.appendChild(document.createElement("div")).appendChild(t)}));let u=o.appendChild(document.createElement("div"));u.className=Va+"-buttons";u.appendChild(s);u.appendChild(document.createTextNode(" "));u.appendChild(l);let f=e.getBoundingClientRect();e.style.top=(window.innerHeight-f.height)/2+"px";e.style.left=(window.innerWidth-f.width)/2+"px";let h=()=>{let e=Xa(t.fields,n);if(e){i();t.callback(e)}};o.addEventListener("submit",(t=>{t.preventDefault();h()}));o.addEventListener("keydown",(t=>{if(t.keyCode==27){t.preventDefault();i()}else if(t.keyCode==13&&!(t.ctrlKey||t.metaKey||t.shiftKey)){t.preventDefault();h()}else if(t.keyCode==9){window.setTimeout((()=>{if(!e.contains(document.activeElement))i()}),500)}}));let a=o.elements[0];if(a)a.focus()}function Xa(t,e){let r=Object.create(null),i=0;for(let n in t){let s=t[n],l=e[i++];let o=s.read(l),u=s.validate(o);if(u){Ya(l,u);return null}r[n]=s.clean(o)}return r}function Ya(t,e){let r=t.parentNode;let i=r.appendChild(document.createElement("div"));i.style.left=t.offsetLeft+t.offsetWidth+2+"px";i.style.top=t.offsetTop-5+"px";i.className="ProseMirror-invalid";i.textContent=e;setTimeout((()=>r.removeChild(i)),1500)}class Qa{constructor(t){this.options=t}read(t){return t.value}validateType(t){return null}validate(t){if(!t&&this.options.required)return"Required field";return this.validateType(t)||(this.options.validate?this.options.validate(t):null)}clean(t){return this.options.clean?this.options.clean(t):t}}class tc extends Qa{render(){let t=document.createElement("input");t.type="text";t.placeholder=this.options.label;t.value=this.options.value||"";t.autocomplete="off";return t}}function ec(t,e){let r=t.selection.$from;for(let t=r.depth;t>=0;t--){let i=r.index(t);if(r.node(t).canReplaceWith(i,i,e))return true}return false}function rc(t){return new oa({title:"Insert image",label:"Image",enable(e){return ec(e,t)},run(e,r,i){let{from:n,to:s}=e.selection,l=null;if(e.selection instanceof ln&&e.selection.node.type==t)l=e.selection.node.attrs;Ga({title:"Insert image",fields:{src:new tc({label:"Location",required:true,value:l&&l.src}),title:new tc({label:"Title",value:l&&l.title}),alt:new tc({label:"Description",value:l?l.alt:e.doc.textBetween(n,s," ")})},callback(e){i.dispatch(i.state.tr.replaceSelectionWith(t.createAndFill(e)));i.focus()}})}})}function ic(t,e){let r={label:e.title,run:t};for(let t in e)r[t]=e[t];if(!e.enable&&!e.select)r[e.enable?"enable":"select"]=e=>t(e);return new oa(r)}function nc(t,e){let{from:r,$from:i,to:n,empty:s}=t.selection;if(s)return!!e.isInSet(t.storedMarks||i.marks());else return t.doc.rangeHasMark(r,n,e)}function sc(t,e){let r={active(e){return nc(e,t)}};for(let t in e)r[t]=e[t];return ic(_h(t),r)}function lc(t){return new oa({title:"Add or remove link",icon:ba.link,active(e){return nc(e,t)},enable(t){return!t.selection.empty},run(e,r,i){if(nc(e,t)){_h(t)(e,r);return true}Ga({title:"Create a link",fields:{href:new tc({label:"Link target",required:true}),title:new tc({label:"Title"})},callback(e){_h(t,e)(i.state,i.dispatch);i.focus()}})}})}function oc(t,e){return ic(df(t,e.attrs),e)}function uc(t){let e={};let r;if(r=t.marks.strong)e.toggleStrong=sc(r,{title:"Toggle strong style",icon:ba.strong});if(r=t.marks.em)e.toggleEm=sc(r,{title:"Toggle emphasis",icon:ba.em});if(r=t.marks.code)e.toggleCode=sc(r,{title:"Toggle code font",icon:ba.code});if(r=t.marks.link)e.toggleLink=lc(r);let i;if(i=t.nodes.image)e.insertImage=rc(i);if(i=t.nodes.bullet_list)e.wrapBulletList=oc(i,{title:"Wrap in bullet list",icon:ba.bulletList});if(i=t.nodes.ordered_list)e.wrapOrderedList=oc(i,{title:"Wrap in ordered list",icon:ba.orderedList});if(i=t.nodes.blockquote)e.wrapBlockQuote=Ea(i,{title:"Wrap in block quote",icon:ba.blockquote});if(i=t.nodes.paragraph)e.makeParagraph=Ma(i,{title:"Change to paragraph",label:"Plain"});if(i=t.nodes.code_block)e.makeCodeBlock=Ma(i,{title:"Change to code block",label:"Code"});if(i=t.nodes.heading)for(let t=1;t<=10;t++)e["makeHead"+t]=Ma(i,{title:"Change to heading "+t,label:"Level "+t,attrs:{level:t}});if(i=t.nodes.horizontal_rule){let t=i;e.insertHorizontalRule=new oa({title:"Insert horizontal rule",label:"Horizontal rule",enable(e){return ec(e,t)},run(e,r){r(e.tr.replaceSelectionWith(t.create()))}})}let n=t=>t.filter((t=>t));e.insertMenu=new ca(n([e.insertImage,e.insertHorizontalRule]),{label:"Insert"});e.typeMenu=new ca(n([e.makeParagraph,e.makeCodeBlock,e.makeHead1&&new ma(n([e.makeHead1,e.makeHead2,e.makeHead3,e.makeHead4,e.makeHead5,e.makeHead6]),{label:"Heading"})]),{label:"Type..."});e.inlineMenu=[n([e.toggleStrong,e.toggleEm,e.toggleCode,e.toggleLink])];e.blockMenu=[n([e.wrapBulletList,e.wrapOrderedList,e.wrapBlockQuote,ka,Da,va])];e.fullMenu=e.inlineMenu.concat([[e.insertMenu,e.typeMenu]],[[ya,Fa]],e.blockMenu);return e}const fc=typeof navigator!="undefined"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):false;function hc(t,e){let r={},i;function n(t,i){if(e){let r=e[t];if(r===false)return;if(r)t=r}r[t]=i}n("Mod-z",th);n("Shift-Mod-z",eh);n("Backspace",za);if(!fc)n("Mod-y",eh);n("Alt-ArrowUp",ch);n("Alt-ArrowDown",dh);n("Mod-BracketLeft",ph);n("Escape",yh);if(i=t.marks.strong){n("Mod-b",_h(i));n("Mod-B",_h(i))}if(i=t.marks.em){n("Mod-i",_h(i));n("Mod-I",_h(i))}if(i=t.marks.code)n("Mod-`",_h(i));if(i=t.nodes.bullet_list)n("Shift-Ctrl-8",df(i));if(i=t.nodes.ordered_list)n("Shift-Ctrl-9",df(i));if(i=t.nodes.blockquote)n("Ctrl->",Sh(i));if(i=t.nodes.hard_break){let t=i,e=Bh(gh,((e,r)=>{if(r)r(e.tr.replaceSelectionWith(t.create()).scrollIntoView());return true}));n("Mod-Enter",e);n("Shift-Enter",e);if(fc)n("Ctrl-Enter",e)}if(i=t.nodes.list_item){n("Enter",mf(i));n("Mod-[",wf(i));n("Mod-]",kf(i))}if(i=t.nodes.paragraph)n("Shift-Ctrl-0",Oh(i));if(i=t.nodes.code_block)n("Shift-Ctrl-\\",Oh(i));if(i=t.nodes.heading)for(let t=1;t<=6;t++)n("Shift-Ctrl-"+t,Oh(i,{level:t}));if(i=t.nodes.horizontal_rule){let t=i;n("Mod-_",((e,r)=>{if(r)r(e.tr.replaceSelectionWith(t.create()).scrollIntoView());return true}))}return r}function ac(t){return Za(/^\s*>\s$/,t)}function cc(t){return Za(/^(\d+)\.\s$/,t,(t=>({order:+t[1]})),((t,e)=>e.childCount+e.attrs.order==+t[1]))}function dc(t){return Za(/^\s*([-+*])\s$/,t)}function pc(t){return Ka(/^```$/,t)}function mc(t,e){return Ka(new RegExp("^(#{1,"+e+"})\\s$"),t,(t=>({level:t[1].length})))}function wc(t){let e=Ha.concat(Pa,Ia),r;if(r=t.nodes.blockquote)e.push(ac(r));if(r=t.nodes.ordered_list)e.push(cc(r));if(r=t.nodes.bullet_list)e.push(dc(r));if(r=t.nodes.code_block)e.push(pc(r));if(r=t.nodes.heading)e.push(mc(r,6));return qa({rules:e})}function gc(t){let e=[wc(t.schema),$f(hc(t.schema,t.mapKeys)),$f(zh),Ih(),Hh()];if(t.menuBar!==false)e.push(Sa({floating:t.floatingMenu!==false,content:t.menuContent||uc(t.schema).fullMenu}));if(t.history!==false)e.push(Qf());return e.concat(new yn({props:{attributes:{class:"ProseMirror-example-setup-style"}}}))}const bc={Bold:"strong",Italic:"em",Blockquote:"blockquote",HeaderLevel1:"headerlevel1",HeaderLevel2:"headerlevel2",HeaderLevel3:"headerlevel3",Link:"link",OrderedList:"ordered_list",BulletList:"bullet_list",Strikethrough:"strikethrough",Code:"code",CodeBlock:"code_block"};const kc=Object.values(bc);const Dc={Heading:"heading",one:1,two:2,three:3};const vc={Left:0,Middle:1,Right:2};const yc=(t,e)=>{t.active=t=>{const{from:r,$from:i,to:n,empty:s}=t.selection;if(s){return!!e.isInSet(t.storedMarks||i.marks())}else{return t.doc.rangeHasMark(r,n,e)}}};const Fc=(t,e,r)=>{t.active=t=>{const{$from:i}=t.selection;const n=i.node(i.depth);if(n&&n.type.name===e.name){if(e.name===Dc.Heading&&r){return n.attrs.level===r}return true}return false}};const Ec=(t,e)=>{t.active=t=>{const{from:r,to:i}=t.selection;for(let n=r;n<=i;n++){const r=t.doc.resolve(n);for(let t=r.depth;t>0;t--){const i=r.node(t);if(i&&i.type.name===e.name){return true}}}return false}};const Mc=(t,e,r)=>{const i=(e,i)=>{const{from:n,to:s}=e.selection;if(n===s){const s=t.marks.link.create({href:r.href,title:r.href,target:Cc(r.href)?"_blank":null});const l=r.text||r.href;const o=t.text(l,[s]);i(e.tr.insert(n,o))}else{const l=t.marks.link.create({href:r.href,title:r.href,target:Cc(r.href)?"_blank":null});const o=e.doc.textBetween(n,s," ");const u=t.text(r.text||o,[l]);i(e.tr.replaceWith(n,s,u))}return true};yc(i,t.marks.link);return i};const xc=(t,e,r)=>{const i=t.marks[e];if(!i){throw new Error(`Mark "${e}" not found in schema`)}const n=Ac(e,r);const s=_h(i,n);yc(s,i);return s};const Ac=(t,e)=>{if(t===bc.Link&&e.href){return{href:e.href,target:Cc(e.href)?"_blank":null}}return undefined};const Cc=t=>!t.startsWith(window.location.origin);const Sc=(t,e,r={},i=false)=>{const n=t.nodes[e];const s=t.nodes.paragraph;return(t,e)=>{const{$from:l,$to:o}=t.selection;const u=l.node(l.depth-1).type===n;if(t.selection instanceof nn&&l.sameParent(l.doc.resolve(o.pos))){if(l.parent.type===n){if(e){e(t.tr.setBlockType(l.pos,o.pos,s))}return true}else{if(u){return ph(t,e)}if(i){return Sh(n,r)(t,e)}else{return Oh(n,r)(t,e)}}}return false}};const Oc=t=>{try{new URL(t)}catch(t){return false}return true};const $c=(t,e,r)=>{const i=t.nodes[e];if(!i){throw new Error(`Node type "${e}" not found in schema`)}let n;if(e===Dc.Heading&&r){n=Sc(t,Dc.Heading,{level:r})}else if(e===bc.CodeBlock){n=Sc(t,bc.CodeBlock)}else{n=Oh(i)}Fc(n,i,r);return n};const _c=(t,e)=>{const r=t.nodes[e];if(!r){throw new Error(`Node type "${e}" not found in schema`)}let i;if(e===bc.Blockquote){i=Sc(t,bc.Blockquote,{},true)}else{i=Sh(r)}Ec(i,r);return i};const Bc=t=>(e,r)=>{const{$from:i,$to:n}=e.selection;const s=i.blockRange(n);if(!s){return false}const l=s&&pi(s,t);if(l){if(r){r(e.tr.wrap(s,l).scrollIntoView())}return true}else{const t=s&&ci(s);if(t!==null){if(r){r(e.tr.lift(s,t).scrollIntoView())}return true}return false}};const Rc=(t,e)=>{const r=t.nodes[e];if(!r){throw new Error(`List type "${e}" not found in schema`)}const i=Bc(r);Ec(i,r);return i};const jc=(t,e)=>{const{from:r,to:i}=t.selection;if(r===i){return false}const n=window.clipboardData;if(!n){return false}const s=n.getData("text");if(!Oc(s)){return false}const l=t.schema.marks.link.create({href:s,target:Cc(s)?"_blank":null});const o=t.doc.textBetween(r,i," ");const u=t.schema.text(o,[l]);e(t.tr.replaceWith(r,i,u))};const Nc={strong:xc,em:xc,underline:xc,strikethrough:xc,code:xc,link:Mc,headerlevel1:t=>$c(t,Dc.Heading,Dc.one),headerlevel2:t=>$c(t,Dc.Heading,Dc.two),headerlevel3:t=>$c(t,Dc.Heading,Dc.three),blockquote:t=>_c(t,bc.Blockquote),code_block:t=>$c(t,bc.CodeBlock),ordered_list:t=>Rc(t,bc.OrderedList),bullet_list:t=>Rc(t,bc.BulletList)};class qc{constructor(t){this.schema=t}getCommand(t,e){const r=Nc[t];if(!r){throw new Error(`The Mark "${t}" is not supported`)}return r(this.schema,t,e)}buildKeymap(){return{"Mod-B":this.getCommand(bc.Bold),"Mod-I":this.getCommand(bc.Italic),"Mod-Shift-1":this.getCommand(bc.HeaderLevel1),"Mod-Shift-2":this.getCommand(bc.HeaderLevel2),"Mod-Shift-3":this.getCommand(bc.HeaderLevel3),"Mod-Shift-X":this.getCommand(bc.Strikethrough),"Mod-`":this.getCommand(bc.Code),"Mod-Shift-C":this.getCommand(bc.CodeBlock),"Mod-v":jc}}}const Tc=()=>{const t=/Macintosh|MacIntel|MacPPC|Mac68K/;if(t.exec(navigator.userAgent)){return{mod:"⌘",option:"⌥",shift:"⇧"}}return{mod:"Ctrl",option:"Alt",shift:"Shift"}};const{mod:zc,shift:Ic}=Tc();const Pc=[{value:bc.Bold,text:"Bold",commandText:`${zc} B`,icon:"-lime-text-bold",iconOnly:true,selected:false},{value:bc.Italic,text:"Italic",commandText:`${zc} I`,icon:"-lime-text-italic",iconOnly:true,selected:false},{value:bc.Strikethrough,text:"Strikethrough",commandText:`${zc} ${Ic} X`,icon:"-lime-text-strikethrough",iconOnly:true,selected:false},{value:bc.Link,text:"Link",icon:"-lime-text-link",iconOnly:true},{separator:true},{value:bc.BulletList,text:"Bullet list",icon:"-lime-text-bulleted-list",iconOnly:true,selected:false},{value:bc.OrderedList,text:"Numbered list",icon:"-lime-text-ordered-list",iconOnly:true,selected:false},{separator:true},{value:bc.HeaderLevel1,text:"Header 1",commandText:`${zc} ${Ic} 1`,icon:"-lime-text-h-heading-1",iconOnly:true,selected:false},{value:bc.HeaderLevel2,text:"Header 2",commandText:`${zc} ${Ic} 2`,icon:"-lime-text-h-heading-2",iconOnly:true,selected:false},{value:bc.HeaderLevel3,text:"Header 3",commandText:`${zc} ${Ic} 3`,icon:"-lime-text-h-heading-3",iconOnly:true,selected:false},{separator:true},{value:bc.Blockquote,text:"Blockquote",icon:"-lime-text-blockquote",iconOnly:true,selected:false},{separator:true},{value:bc.Code,text:"Code",commandText:`${zc} \``,icon:"-lime-text-code",iconOnly:true,selected:false},{value:bc.CodeBlock,text:"Code Block",commandText:`${zc} ${Ic} C`,icon:"-lime-text-code-block",iconOnly:true,selected:false}];const Jc=()=>pe(Pc);const Lc={strong:"editor-menu.bold",em:"editor-menu.italic",headerlevel1:"editor-menu.h1",headerlevel2:"editor-menu.h2",headerlevel3:"editor-menu.h3",bullet_list:"editor-menu.bulleted-list",ordered_list:"editor-menu.numbered-list",code_block:"editor-menu.code-block",blockquote:"editor-menu.blockquote",link:"editor-menu.link",strikethrough:"editor-menu.strikethrough",code:"editor-menu.code"};const Wc={};function Uc(t){let e=Wc[t];if(e){return e}e=Wc[t]=[];for(let t=0;t<128;t++){const r=String.fromCharCode(t);e.push(r)}for(let r=0;r<t.length;r++){const i=t.charCodeAt(r);e[i]="%"+("0"+i.toString(16).toUpperCase()).slice(-2)}return e}function Hc(t,e){if(typeof e!=="string"){e=Hc.defaultChars}const r=Uc(e);return t.replace(/(%[a-f0-9]{2})+/gi,(function(t){let e="";for(let i=0,n=t.length;i<n;i+=3){const s=parseInt(t.slice(i+1,i+3),16);if(s<128){e+=r[s];continue}if((s&224)===192&&i+3<n){const r=parseInt(t.slice(i+4,i+6),16);if((r&192)===128){const t=s<<6&1984|r&63;if(t<128){e+="��"}else{e+=String.fromCharCode(t)}i+=3;continue}}if((s&240)===224&&i+6<n){const r=parseInt(t.slice(i+4,i+6),16);const n=parseInt(t.slice(i+7,i+9),16);if((r&192)===128&&(n&192)===128){const t=s<<12&61440|r<<6&4032|n&63;if(t<2048||t>=55296&&t<=57343){e+="���"}else{e+=String.fromCharCode(t)}i+=6;continue}}if((s&248)===240&&i+9<n){const r=parseInt(t.slice(i+4,i+6),16);const n=parseInt(t.slice(i+7,i+9),16);const l=parseInt(t.slice(i+10,i+12),16);if((r&192)===128&&(n&192)===128&&(l&192)===128){let t=s<<18&1835008|r<<12&258048|n<<6&4032|l&63;if(t<65536||t>1114111){e+="����"}else{t-=65536;e+=String.fromCharCode(55296+(t>>10),56320+(t&1023))}i+=9;continue}}e+="�"}return e}))}Hc.defaultChars=";/?:@&=+$,#";Hc.componentChars="";const Zc={};function Kc(t){let e=Zc[t];if(e){return e}e=Zc[t]=[];for(let t=0;t<128;t++){const r=String.fromCharCode(t);if(/^[0-9a-z]$/i.test(r)){e.push(r)}else{e.push("%"+("0"+t.toString(16).toUpperCase()).slice(-2))}}for(let r=0;r<t.length;r++){e[t.charCodeAt(r)]=t[r]}return e}function Vc(t,e,r){if(typeof e!=="string"){r=e;e=Vc.defaultChars}if(typeof r==="undefined"){r=true}const i=Kc(e);let n="";for(let e=0,s=t.length;e<s;e++){const l=t.charCodeAt(e);if(r&&l===37&&e+2<s){if(/^[0-9a-f]{2}$/i.test(t.slice(e+1,e+3))){n+=t.slice(e,e+3);e+=2;continue}}if(l<128){n+=i[l];continue}if(l>=55296&&l<=57343){if(l>=55296&&l<=56319&&e+1<s){const r=t.charCodeAt(e+1);if(r>=56320&&r<=57343){n+=encodeURIComponent(t[e]+t[e+1]);e++;continue}}n+="%EF%BF%BD";continue}n+=encodeURIComponent(t[e])}return n}Vc.defaultChars=";/?:@&=+$,-_.!~*'()#";Vc.componentChars="-_.!~*'()";function Gc(t){let e="";e+=t.protocol||"";e+=t.slashes?"//":"";e+=t.auth?t.auth+"@":"";if(t.hostname&&t.hostname.indexOf(":")!==-1){e+="["+t.hostname+"]"}else{e+=t.hostname||""}e+=t.port?":"+t.port:"";e+=t.pathname||"";e+=t.search||"";e+=t.hash||"";return e}function Xc(){this.protocol=null;this.slashes=null;this.auth=null;this.port=null;this.hostname=null;this.hash=null;this.search=null;this.pathname=null}const Yc=/^([a-z0-9.+-]+:)/i;const Qc=/:[0-9]*$/;const td=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/;const ed=["<",">",'"',"`"," ","\r","\n","\t"];const rd=["{","}","|","\\","^","`"].concat(ed);const id=["'"].concat(rd);const nd=["%","/","?",";","#"].concat(id);const sd=["/","?","#"];const ld=255;const od=/^[+a-z0-9A-Z_-]{0,63}$/;const ud=/^([+a-z0-9A-Z_-]{0,63})(.*)$/;const fd={javascript:true,"javascript:":true};const hd={http:true,https:true,ftp:true,gopher:true,file:true,"http:":true,"https:":true,"ftp:":true,"gopher:":true,"file:":true};function ad(t,e){if(t&&t instanceof Xc)return t;const r=new Xc;r.parse(t,e);return r}Xc.prototype.parse=function(t,e){let r,i,n;let s=t;s=s.trim();if(!e&&t.split("#").length===1){const t=td.exec(s);if(t){this.pathname=t[1];if(t[2]){this.search=t[2]}return this}}let l=Yc.exec(s);if(l){l=l[0];r=l.toLowerCase();this.protocol=l;s=s.substr(l.length)}if(e||l||s.match(/^\/\/[^@\/]+@[^@\/]+/)){n=s.substr(0,2)==="//";if(n&&!(l&&fd[l])){s=s.substr(2);this.slashes=true}}if(!fd[l]&&(n||l&&!hd[l])){let t=-1;for(let e=0;e<sd.length;e++){i=s.indexOf(sd[e]);if(i!==-1&&(t===-1||i<t)){t=i}}let e,r;if(t===-1){r=s.lastIndexOf("@")}else{r=s.lastIndexOf("@",t)}if(r!==-1){e=s.slice(0,r);s=s.slice(r+1);this.auth=e}t=-1;for(let e=0;e<nd.length;e++){i=s.indexOf(nd[e]);if(i!==-1&&(t===-1||i<t)){t=i}}if(t===-1){t=s.length}if(s[t-1]===":"){t--}const n=s.slice(0,t);s=s.slice(t);this.parseHost(n);this.hostname=this.hostname||"";const l=this.hostname[0]==="["&&this.hostname[this.hostname.length-1]==="]";if(!l){const t=this.hostname.split(/\./);for(let e=0,r=t.length;e<r;e++){const r=t[e];if(!r){continue}if(!r.match(od)){let i="";for(let t=0,e=r.length;t<e;t++){if(r.charCodeAt(t)>127){i+="x"}else{i+=r[t]}}if(!i.match(od)){const i=t.slice(0,e);const n=t.slice(e+1);const l=r.match(ud);if(l){i.push(l[1]);n.unshift(l[2])}if(n.length){s=n.join(".")+s}this.hostname=i.join(".");break}}}}if(this.hostname.length>ld){this.hostname=""}if(l){this.hostname=this.hostname.substr(1,this.hostname.length-2)}}const o=s.indexOf("#");if(o!==-1){this.hash=s.substr(o);s=s.slice(0,o)}const u=s.indexOf("?");if(u!==-1){this.search=s.substr(u);s=s.slice(0,u)}if(s){this.pathname=s}if(hd[r]&&this.hostname&&!this.pathname){this.pathname=""}return this};Xc.prototype.parseHost=function(t){let e=Qc.exec(t);if(e){e=e[0];if(e!==":"){this.port=e.substr(1)}t=t.substr(0,t.length-e.length)}if(t){this.hostname=t}};const cd=Object.freeze({__proto__:null,decode:Hc,encode:Vc,format:Gc,parse:ad});const dd=/[\0-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/;const pd=/[\0-\x1F\x7F-\x9F]/;const md=/[\xAD\u0600-\u0605\u061C\u06DD\u070F\u0890\u0891\u08E2\u180E\u200B-\u200F\u202A-\u202E\u2060-\u2064\u2066-\u206F\uFEFF\uFFF9-\uFFFB]|\uD804[\uDCBD\uDCCD]|\uD80D[\uDC30-\uDC3F]|\uD82F[\uDCA0-\uDCA3]|\uD834[\uDD73-\uDD7A]|\uDB40[\uDC01\uDC20-\uDC7F]/;const wd=/[!-#%-\*,-\/:;\?@\[-\]_\{\}\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061D-\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u09FD\u0A76\u0AF0\u0C77\u0C84\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1B7D\u1B7E\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E4F\u2E52-\u2E5D\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]|\uD800[\uDD00-\uDD02\uDF9F\uDFD0]|\uD801\uDD6F|\uD802[\uDC57\uDD1F\uDD3F\uDE50-\uDE58\uDE7F\uDEF0-\uDEF6\uDF39-\uDF3F\uDF99-\uDF9C]|\uD803[\uDEAD\uDF55-\uDF59\uDF86-\uDF89]|\uD804[\uDC47-\uDC4D\uDCBB\uDCBC\uDCBE-\uDCC1\uDD40-\uDD43\uDD74\uDD75\uDDC5-\uDDC8\uDDCD\uDDDB\uDDDD-\uDDDF\uDE38-\uDE3D\uDEA9]|\uD805[\uDC4B-\uDC4F\uDC5A\uDC5B\uDC5D\uDCC6\uDDC1-\uDDD7\uDE41-\uDE43\uDE60-\uDE6C\uDEB9\uDF3C-\uDF3E]|\uD806[\uDC3B\uDD44-\uDD46\uDDE2\uDE3F-\uDE46\uDE9A-\uDE9C\uDE9E-\uDEA2\uDF00-\uDF09]|\uD807[\uDC41-\uDC45\uDC70\uDC71\uDEF7\uDEF8\uDF43-\uDF4F\uDFFF]|\uD809[\uDC70-\uDC74]|\uD80B[\uDFF1\uDFF2]|\uD81A[\uDE6E\uDE6F\uDEF5\uDF37-\uDF3B\uDF44]|\uD81B[\uDE97-\uDE9A\uDFE2]|\uD82F\uDC9F|\uD836[\uDE87-\uDE8B]|\uD83A[\uDD5E\uDD5F]/;const gd=/[\$\+<->\^`\|~\xA2-\xA6\xA8\xA9\xAC\xAE-\xB1\xB4\xB8\xD7\xF7\u02C2-\u02C5\u02D2-\u02DF\u02E5-\u02EB\u02ED\u02EF-\u02FF\u0375\u0384\u0385\u03F6\u0482\u058D-\u058F\u0606-\u0608\u060B\u060E\u060F\u06DE\u06E9\u06FD\u06FE\u07F6\u07FE\u07FF\u0888\u09F2\u09F3\u09FA\u09FB\u0AF1\u0B70\u0BF3-\u0BFA\u0C7F\u0D4F\u0D79\u0E3F\u0F01-\u0F03\u0F13\u0F15-\u0F17\u0F1A-\u0F1F\u0F34\u0F36\u0F38\u0FBE-\u0FC5\u0FC7-\u0FCC\u0FCE\u0FCF\u0FD5-\u0FD8\u109E\u109F\u1390-\u1399\u166D\u17DB\u1940\u19DE-\u19FF\u1B61-\u1B6A\u1B74-\u1B7C\u1FBD\u1FBF-\u1FC1\u1FCD-\u1FCF\u1FDD-\u1FDF\u1FED-\u1FEF\u1FFD\u1FFE\u2044\u2052\u207A-\u207C\u208A-\u208C\u20A0-\u20C0\u2100\u2101\u2103-\u2106\u2108\u2109\u2114\u2116-\u2118\u211E-\u2123\u2125\u2127\u2129\u212E\u213A\u213B\u2140-\u2144\u214A-\u214D\u214F\u218A\u218B\u2190-\u2307\u230C-\u2328\u232B-\u2426\u2440-\u244A\u249C-\u24E9\u2500-\u2767\u2794-\u27C4\u27C7-\u27E5\u27F0-\u2982\u2999-\u29D7\u29DC-\u29FB\u29FE-\u2B73\u2B76-\u2B95\u2B97-\u2BFF\u2CE5-\u2CEA\u2E50\u2E51\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u2FFF\u3004\u3012\u3013\u3020\u3036\u3037\u303E\u303F\u309B\u309C\u3190\u3191\u3196-\u319F\u31C0-\u31E3\u31EF\u3200-\u321E\u322A-\u3247\u3250\u3260-\u327F\u328A-\u32B0\u32C0-\u33FF\u4DC0-\u4DFF\uA490-\uA4C6\uA700-\uA716\uA720\uA721\uA789\uA78A\uA828-\uA82B\uA836-\uA839\uAA77-\uAA79\uAB5B\uAB6A\uAB6B\uFB29\uFBB2-\uFBC2\uFD40-\uFD4F\uFDCF\uFDFC-\uFDFF\uFE62\uFE64-\uFE66\uFE69\uFF04\uFF0B\uFF1C-\uFF1E\uFF3E\uFF40\uFF5C\uFF5E\uFFE0-\uFFE6\uFFE8-\uFFEE\uFFFC\uFFFD]|\uD800[\uDD37-\uDD3F\uDD79-\uDD89\uDD8C-\uDD8E\uDD90-\uDD9C\uDDA0\uDDD0-\uDDFC]|\uD802[\uDC77\uDC78\uDEC8]|\uD805\uDF3F|\uD807[\uDFD5-\uDFF1]|\uD81A[\uDF3C-\uDF3F\uDF45]|\uD82F\uDC9C|\uD833[\uDF50-\uDFC3]|\uD834[\uDC00-\uDCF5\uDD00-\uDD26\uDD29-\uDD64\uDD6A-\uDD6C\uDD83\uDD84\uDD8C-\uDDA9\uDDAE-\uDDEA\uDE00-\uDE41\uDE45\uDF00-\uDF56]|\uD835[\uDEC1\uDEDB\uDEFB\uDF15\uDF35\uDF4F\uDF6F\uDF89\uDFA9\uDFC3]|\uD836[\uDC00-\uDDFF\uDE37-\uDE3A\uDE6D-\uDE74\uDE76-\uDE83\uDE85\uDE86]|\uD838[\uDD4F\uDEFF]|\uD83B[\uDCAC\uDCB0\uDD2E\uDEF0\uDEF1]|\uD83C[\uDC00-\uDC2B\uDC30-\uDC93\uDCA0-\uDCAE\uDCB1-\uDCBF\uDCC1-\uDCCF\uDCD1-\uDCF5\uDD0D-\uDDAD\uDDE6-\uDE02\uDE10-\uDE3B\uDE40-\uDE48\uDE50\uDE51\uDE60-\uDE65\uDF00-\uDFFF]|\uD83D[\uDC00-\uDED7\uDEDC-\uDEEC\uDEF0-\uDEFC\uDF00-\uDF76\uDF7B-\uDFD9\uDFE0-\uDFEB\uDFF0]|\uD83E[\uDC00-\uDC0B\uDC10-\uDC47\uDC50-\uDC59\uDC60-\uDC87\uDC90-\uDCAD\uDCB0\uDCB1\uDD00-\uDE53\uDE60-\uDE6D\uDE70-\uDE7C\uDE80-\uDE88\uDE90-\uDEBD\uDEBF-\uDEC5\uDECE-\uDEDB\uDEE0-\uDEE8\uDEF0-\uDEF8\uDF00-\uDF92\uDF94-\uDFCA]/;const bd=/[ \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000]/;const kd=Object.freeze({__proto__:null,Any:dd,Cc:pd,Cf:md,P:wd,S:gd,Z:bd});function Dd(t){return Object.prototype.toString.call(t)}function vd(t){return Dd(t)==="[object String]"}const yd=Object.prototype.hasOwnProperty;function Fd(t,e){return yd.call(t,e)}function Ed(t){const e=Array.prototype.slice.call(arguments,1);e.forEach((function(e){if(!e){return}if(typeof e!=="object"){throw new TypeError(e+"must be object")}Object.keys(e).forEach((function(r){t[r]=e[r]}))}));return t}function Md(t,e,r){return[].concat(t.slice(0,e),r,t.slice(e+1))}function xd(t){if(t>=55296&&t<=57343){return false}if(t>=64976&&t<=65007){return false}if((t&65535)===65535||(t&65535)===65534){return false}if(t>=0&&t<=8){return false}if(t===11){return false}if(t>=14&&t<=31){return false}if(t>=127&&t<=159){return false}if(t>1114111){return false}return true}function Ad(t){if(t>65535){t-=65536;const e=55296+(t>>10);const r=56320+(t&1023);return String.fromCharCode(e,r)}return String.fromCharCode(t)}const Cd=/\\([!"#$%&'()*+,\-./:;<=>?@[\\\]^_`{|}~])/g;const Sd=/&([a-z#][a-z0-9]{1,31});/gi;const Od=new RegExp(Cd.source+"|"+Sd.source,"gi");const $d=/^#((?:x[a-f0-9]{1,8}|[0-9]{1,8}))$/i;function _d(t,e){if(e.charCodeAt(0)===35&&$d.test(e)){const r=e[1].toLowerCase()==="x"?parseInt(e.slice(2),16):parseInt(e.slice(1),10);if(xd(r)){return Ad(r)}return t}const r=x(t);if(r!==t){return r}return t}function Bd(t){if(t.indexOf("\\")<0){return t}return t.replace(Cd,"$1")}function Rd(t){if(t.indexOf("\\")<0&&t.indexOf("&")<0){return t}return t.replace(Od,(function(t,e,r){if(e){return e}return _d(t,r)}))}const jd=/[&<>"]/;const Nd=/[&<>"]/g;const qd={"&":"&","<":"<",">":">",'"':"""};function Td(t){return qd[t]}function zd(t){if(jd.test(t)){return t.replace(Nd,Td)}return t}const Id=/[.?*+^$[\]\\(){}|-]/g;function Pd(t){return t.replace(Id,"\\$&")}function Jd(t){switch(t){case 9:case 32:return true}return false}function Ld(t){if(t>=8192&&t<=8202){return true}switch(t){case 9:case 10:case 11:case 12:case 13:case 32:case 160:case 5760:case 8239:case 8287:case 12288:return true}return false}function Wd(t){return wd.test(t)||gd.test(t)}function Ud(t){switch(t){case 33:case 34:case 35:case 36:case 37:case 38:case 39:case 40:case 41:case 42:case 43:case 44:case 45:case 46:case 47:case 58:case 59:case 60:case 61:case 62:case 63:case 64:case 91:case 92:case 93:case 94:case 95:case 96:case 123:case 124:case 125:case 126:return true;default:return false}}function Hd(t){t=t.trim().replace(/\s+/g," ");if("ẞ".toLowerCase()==="Ṿ"){t=t.replace(/ẞ/g,"ß")}return t.toLowerCase().toUpperCase()}const Zd={mdurl:cd,ucmicro:kd};const Kd=Object.freeze({__proto__:null,lib:Zd,assign:Ed,isString:vd,has:Fd,unescapeMd:Bd,unescapeAll:Rd,isValidEntityCode:xd,fromCodePoint:Ad,escapeHtml:zd,arrayReplaceAt:Md,isSpace:Jd,isWhiteSpace:Ld,isMdAsciiPunct:Ud,isPunctChar:Wd,escapeRE:Pd,normalizeReference:Hd});function Vd(t,e,r){let i,n,s,l;const o=t.posMax;const u=t.pos;t.pos=e+1;i=1;while(t.pos<o){s=t.src.charCodeAt(t.pos);if(s===93){i--;if(i===0){n=true;break}}l=t.pos;t.md.inline.skipToken(t);if(s===91){if(l===t.pos-1){i++}else if(r){t.pos=u;return-1}}}let f=-1;if(n){f=t.pos}t.pos=u;return f}function Gd(t,e,r){let i;let n=e;const s={ok:false,pos:0,str:""};if(t.charCodeAt(n)===60){n++;while(n<r){i=t.charCodeAt(n);if(i===10){return s}if(i===60){return s}if(i===62){s.pos=n+1;s.str=Rd(t.slice(e+1,n));s.ok=true;return s}if(i===92&&n+1<r){n+=2;continue}n++}return s}let l=0;while(n<r){i=t.charCodeAt(n);if(i===32){break}if(i<32||i===127){break}if(i===92&&n+1<r){if(t.charCodeAt(n+1)===32){break}n+=2;continue}if(i===40){l++;if(l>32){return s}}if(i===41){if(l===0){break}l--}n++}if(e===n){return s}if(l!==0){return s}s.str=Rd(t.slice(e,n));s.pos=n;s.ok=true;return s}function Xd(t,e,r,i){let n;let s=e;const l={ok:false,can_continue:false,pos:0,str:"",marker:0};if(i){l.str=i.str;l.marker=i.marker}else{if(s>=r){return l}let i=t.charCodeAt(s);if(i!==34&&i!==39&&i!==40){return l}e++;s++;if(i===40){i=41}l.marker=i}while(s<r){n=t.charCodeAt(s);if(n===l.marker){l.pos=s+1;l.str+=Rd(t.slice(e,s));l.ok=true;return l}else if(n===40&&l.marker===41){return l}else if(n===92&&s+1<r){s++}s++}l.can_continue=true;l.str+=Rd(t.slice(e,s));return l}const Yd=Object.freeze({__proto__:null,parseLinkLabel:Vd,parseLinkDestination:Gd,parseLinkTitle:Xd});const Qd={};Qd.code_inline=function(t,e,r,i,n){const s=t[e];return"<code"+n.renderAttrs(s)+">"+zd(s.content)+"</code>"};Qd.code_block=function(t,e,r,i,n){const s=t[e];return"<pre"+n.renderAttrs(s)+"><code>"+zd(t[e].content)+"</code></pre>\n"};Qd.fence=function(t,e,r,i,n){const s=t[e];const l=s.info?Rd(s.info).trim():"";let o="";let u="";if(l){const t=l.split(/(\s+)/g);o=t[0];u=t.slice(2).join("")}let f;if(r.highlight){f=r.highlight(s.content,o,u)||zd(s.content)}else{f=zd(s.content)}if(f.indexOf("<pre")===0){return f+"\n"}if(l){const t=s.attrIndex("class");const e=s.attrs?s.attrs.slice():[];if(t<0){e.push(["class",r.langPrefix+o])}else{e[t]=e[t].slice();e[t][1]+=" "+r.langPrefix+o}const i={attrs:e};return`<pre><code${n.renderAttrs(i)}>${f}</code></pre>\n`}return`<pre><code${n.renderAttrs(s)}>${f}</code></pre>\n`};Qd.image=function(t,e,r,i,n){const s=t[e];s.attrs[s.attrIndex("alt")][1]=n.renderInlineAsText(s.children,r,i);return n.renderToken(t,e,r)};Qd.hardbreak=function(t,e,r){return r.xhtmlOut?"<br />\n":"<br>\n"};Qd.softbreak=function(t,e,r){return r.breaks?r.xhtmlOut?"<br />\n":"<br>\n":"\n"};Qd.text=function(t,e){return zd(t[e].content)};Qd.html_block=function(t,e){return t[e].content};Qd.html_inline=function(t,e){return t[e].content};function tp(){this.rules=Ed({},Qd)}tp.prototype.renderAttrs=function t(e){let r,i,n;if(!e.attrs){return""}n="";for(r=0,i=e.attrs.length;r<i;r++){n+=" "+zd(e.attrs[r][0])+'="'+zd(e.attrs[r][1])+'"'}return n};tp.prototype.renderToken=function t(e,r,i){const n=e[r];let s="";if(n.hidden){return""}if(n.block&&n.nesting!==-1&&r&&e[r-1].hidden){s+="\n"}s+=(n.nesting===-1?"</":"<")+n.tag;s+=this.renderAttrs(n);if(n.nesting===0&&i.xhtmlOut){s+=" /"}let l=false;if(n.block){l=true;if(n.nesting===1){if(r+1<e.length){const t=e[r+1];if(t.type==="inline"||t.hidden){l=false}else if(t.nesting===-1&&t.tag===n.tag){l=false}}}}s+=l?">\n":">";return s};tp.prototype.renderInline=function(t,e,r){let i="";const n=this.rules;for(let s=0,l=t.length;s<l;s++){const l=t[s].type;if(typeof n[l]!=="undefined"){i+=n[l](t,s,e,r,this)}else{i+=this.renderToken(t,s,e)}}return i};tp.prototype.renderInlineAsText=function(t,e,r){let i="";for(let n=0,s=t.length;n<s;n++){switch(t[n].type){case"text":i+=t[n].content;break;case"image":i+=this.renderInlineAsText(t[n].children,e,r);break;case"html_inline":case"html_block":i+=t[n].content;break;case"softbreak":case"hardbreak":i+="\n";break}}return i};tp.prototype.render=function(t,e,r){let i="";const n=this.rules;for(let s=0,l=t.length;s<l;s++){const l=t[s].type;if(l==="inline"){i+=this.renderInline(t[s].children,e,r)}else if(typeof n[l]!=="undefined"){i+=n[l](t,s,e,r,this)}else{i+=this.renderToken(t,s,e,r)}}return i};function ep(){this.__rules__=[];this.__cache__=null}ep.prototype.__find__=function(t){for(let e=0;e<this.__rules__.length;e++){if(this.__rules__[e].name===t){return e}}return-1};ep.prototype.__compile__=function(){const t=this;const e=[""];t.__rules__.forEach((function(t){if(!t.enabled){return}t.alt.forEach((function(t){if(e.indexOf(t)<0){e.push(t)}}))}));t.__cache__={};e.forEach((function(e){t.__cache__[e]=[];t.__rules__.forEach((function(r){if(!r.enabled){return}if(e&&r.alt.indexOf(e)<0){return}t.__cache__[e].push(r.fn)}))}))};ep.prototype.at=function(t,e,r){const i=this.__find__(t);const n=r||{};if(i===-1){throw new Error("Parser rule not found: "+t)}this.__rules__[i].fn=e;this.__rules__[i].alt=n.alt||[];this.__cache__=null};ep.prototype.before=function(t,e,r,i){const n=this.__find__(t);const s=i||{};if(n===-1){throw new Error("Parser rule not found: "+t)}this.__rules__.splice(n,0,{name:e,enabled:true,fn:r,alt:s.alt||[]});this.__cache__=null};ep.prototype.after=function(t,e,r,i){const n=this.__find__(t);const s=i||{};if(n===-1){throw new Error("Parser rule not found: "+t)}this.__rules__.splice(n+1,0,{name:e,enabled:true,fn:r,alt:s.alt||[]});this.__cache__=null};ep.prototype.push=function(t,e,r){const i=r||{};this.__rules__.push({name:t,enabled:true,fn:e,alt:i.alt||[]});this.__cache__=null};ep.prototype.enable=function(t,e){if(!Array.isArray(t)){t=[t]}const r=[];t.forEach((function(t){const i=this.__find__(t);if(i<0){if(e){return}throw new Error("Rules manager: invalid rule name "+t)}this.__rules__[i].enabled=true;r.push(t)}),this);this.__cache__=null;return r};ep.prototype.enableOnly=function(t,e){if(!Array.isArray(t)){t=[t]}this.__rules__.forEach((function(t){t.enabled=false}));this.enable(t,e)};ep.prototype.disable=function(t,e){if(!Array.isArray(t)){t=[t]}const r=[];t.forEach((function(t){const i=this.__find__(t);if(i<0){if(e){return}throw new Error("Rules manager: invalid rule name "+t)}this.__rules__[i].enabled=false;r.push(t)}),this);this.__cache__=null;return r};ep.prototype.getRules=function(t){if(this.__cache__===null){this.__compile__()}return this.__cache__[t]||[]};function rp(t,e,r){this.type=t;this.tag=e;this.attrs=null;this.map=null;this.nesting=r;this.level=0;this.children=null;this.content="";this.markup="";this.info="";this.meta=null;this.block=false;this.hidden=false}rp.prototype.attrIndex=function t(e){if(!this.attrs){return-1}const r=this.attrs;for(let t=0,i=r.length;t<i;t++){if(r[t][0]===e){return t}}return-1};rp.prototype.attrPush=function t(e){if(this.attrs){this.attrs.push(e)}else{this.attrs=[e]}};rp.prototype.attrSet=function t(e,r){const i=this.attrIndex(e);const n=[e,r];if(i<0){this.attrPush(n)}else{this.attrs[i]=n}};rp.prototype.attrGet=function t(e){const r=this.attrIndex(e);let i=null;if(r>=0){i=this.attrs[r][1]}return i};rp.prototype.attrJoin=function t(e,r){const i=this.attrIndex(e);if(i<0){this.attrPush([e,r])}else{this.attrs[i][1]=this.attrs[i][1]+" "+r}};function ip(t,e,r){this.src=t;this.env=r;this.tokens=[];this.inlineMode=false;this.md=e}ip.prototype.Token=rp;const np=/\r\n?|\n/g;const sp=/\0/g;function lp(t){let e;e=t.src.replace(np,"\n");e=e.replace(sp,"�");t.src=e}function op(t){let e;if(t.inlineMode){e=new t.Token("inline","",0);e.content=t.src;e.map=[0,1];e.children=[];t.tokens.push(e)}else{t.md.block.parse(t.src,t.md,t.env,t.tokens)}}function up(t){const e=t.tokens;for(let r=0,i=e.length;r<i;r++){const i=e[r];if(i.type==="inline"){t.md.inline.parse(i.content,t.md,t.env,i.children)}}}function fp(t){return/^<a[>\s]/i.test(t)}function hp(t){return/^<\/a\s*>/i.test(t)}function ap(t){const e=t.tokens;if(!t.md.options.linkify){return}for(let r=0,i=e.length;r<i;r++){if(e[r].type!=="inline"||!t.md.linkify.pretest(e[r].content)){continue}let i=e[r].children;let n=0;for(let s=i.length-1;s>=0;s--){const l=i[s];if(l.type==="link_close"){s--;while(i[s].level!==l.level&&i[s].type!=="link_open"){s--}continue}if(l.type==="html_inline"){if(fp(l.content)&&n>0){n--}if(hp(l.content)){n++}}if(n>0){continue}if(l.type==="text"&&t.md.linkify.test(l.content)){const n=l.content;let o=t.md.linkify.match(n);const u=[];let f=l.level;let h=0;if(o.length>0&&o[0].index===0&&s>0&&i[s-1].type==="text_special"){o=o.slice(1)}for(let e=0;e<o.length;e++){const r=o[e].url;const i=t.md.normalizeLink(r);if(!t.md.validateLink(i)){continue}let s=o[e].text;if(!o[e].schema){s=t.md.normalizeLinkText("http://"+s).replace(/^http:\/\//,"")}else if(o[e].schema==="mailto:"&&!/^mailto:/i.test(s)){s=t.md.normalizeLinkText("mailto:"+s).replace(/^mailto:/,"")}else{s=t.md.normalizeLinkText(s)}const l=o[e].index;if(l>h){const e=new t.Token("text","",0);e.content=n.slice(h,l);e.level=f;u.push(e)}const a=new t.Token("link_open","a",1);a.attrs=[["href",i]];a.level=f++;a.markup="linkify";a.info="auto";u.push(a);const c=new t.Token("text","",0);c.content=s;c.level=f;u.push(c);const d=new t.Token("link_close","a",-1);d.level=--f;d.markup="linkify";d.info="auto";u.push(d);h=o[e].lastIndex}if(h<n.length){const e=new t.Token("text","",0);e.content=n.slice(h);e.level=f;u.push(e)}e[r].children=i=Md(i,s,u)}}}}const cp=/\+-|\.\.|\?\?\?\?|!!!!|,,|--/;const dp=/\((c|tm|r)\)/i;const pp=/\((c|tm|r)\)/gi;const mp={c:"©",r:"®",tm:"™"};function wp(t,e){return mp[e.toLowerCase()]}function gp(t){let e=0;for(let r=t.length-1;r>=0;r--){const i=t[r];if(i.type==="text"&&!e){i.content=i.content.replace(pp,wp)}if(i.type==="link_open"&&i.info==="auto"){e--}if(i.type==="link_close"&&i.info==="auto"){e++}}}function bp(t){let e=0;for(let r=t.length-1;r>=0;r--){const i=t[r];if(i.type==="text"&&!e){if(cp.test(i.content)){i.content=i.content.replace(/\+-/g,"±").replace(/\.{2,}/g,"…").replace(/([?!])…/g,"$1..").replace(/([?!]){4,}/g,"$1$1$1").replace(/,{2,}/g,",").replace(/(^|[^-])---(?=[^-]|$)/gm,"$1—").replace(/(^|\s)--(?=\s|$)/gm,"$1–").replace(/(^|[^-\s])--(?=[^-\s]|$)/gm,"$1–")}}if(i.type==="link_open"&&i.info==="auto"){e--}if(i.type==="link_close"&&i.info==="auto"){e++}}}function kp(t){let e;if(!t.md.options.typographer){return}for(e=t.tokens.length-1;e>=0;e--){if(t.tokens[e].type!=="inline"){continue}if(dp.test(t.tokens[e].content)){gp(t.tokens[e].children)}if(cp.test(t.tokens[e].content)){bp(t.tokens[e].children)}}}const Dp=/['"]/;const vp=/['"]/g;const yp="’";function Fp(t,e,r){return t.slice(0,e)+r+t.slice(e+1)}function Ep(t,e){let r;const i=[];for(let n=0;n<t.length;n++){const s=t[n];const l=t[n].level;for(r=i.length-1;r>=0;r--){if(i[r].level<=l){break}}i.length=r+1;if(s.type!=="text"){continue}let o=s.content;let u=0;let f=o.length;t:while(u<f){vp.lastIndex=u;const h=vp.exec(o);if(!h){break}let a=true;let c=true;u=h.index+1;const d=h[0]==="'";let p=32;if(h.index-1>=0){p=o.charCodeAt(h.index-1)}else{for(r=n-1;r>=0;r--){if(t[r].type==="softbreak"||t[r].type==="hardbreak")break;if(!t[r].content)continue;p=t[r].content.charCodeAt(t[r].content.length-1);break}}let m=32;if(u<f){m=o.charCodeAt(u)}else{for(r=n+1;r<t.length;r++){if(t[r].type==="softbreak"||t[r].type==="hardbreak")break;if(!t[r].content)continue;m=t[r].content.charCodeAt(0);break}}const w=Ud(p)||Wd(String.fromCharCode(p));const g=Ud(m)||Wd(String.fromCharCode(m));const b=Ld(p);const k=Ld(m);if(k){a=false}else if(g){if(!(b||w)){a=false}}if(b){c=false}else if(w){if(!(k||g)){c=false}}if(m===34&&h[0]==='"'){if(p>=48&&p<=57){c=a=false}}if(a&&c){a=w;c=g}if(!a&&!c){if(d){s.content=Fp(s.content,h.index,yp)}continue}if(c){for(r=i.length-1;r>=0;r--){let a=i[r];if(i[r].level<l){break}if(a.single===d&&i[r].level===l){a=i[r];let l;let c;if(d){l=e.md.options.quotes[2];c=e.md.options.quotes[3]}else{l=e.md.options.quotes[0];c=e.md.options.quotes[1]}s.content=Fp(s.content,h.index,c);t[a.token].content=Fp(t[a.token].content,a.pos,l);u+=c.length-1;if(a.token===n){u+=l.length-1}o=s.content;f=o.length;i.length=r;continue t}}}if(a){i.push({token:n,pos:h.index,single:d,level:l})}else if(c&&d){s.content=Fp(s.content,h.index,yp)}}}}function Mp(t){if(!t.md.options.typographer){return}for(let e=t.tokens.length-1;e>=0;e--){if(t.tokens[e].type!=="inline"||!Dp.test(t.tokens[e].content)){continue}Ep(t.tokens[e].children,t)}}function xp(t){let e,r;const i=t.tokens;const n=i.length;for(let t=0;t<n;t++){if(i[t].type!=="inline")continue;const n=i[t].children;const s=n.length;for(e=0;e<s;e++){if(n[e].type==="text_special"){n[e].type="text"}}for(e=r=0;e<s;e++){if(n[e].type==="text"&&e+1<s&&n[e+1].type==="text"){n[e+1].content=n[e].content+n[e+1].content}else{if(e!==r){n[r]=n[e]}r++}}if(e!==r){n.length=r}}}const Ap=[["normalize",lp],["block",op],["inline",up],["linkify",ap],["replacements",kp],["smartquotes",Mp],["text_join",xp]];function Cp(){this.ruler=new ep;for(let t=0;t<Ap.length;t++){this.ruler.push(Ap[t][0],Ap[t][1])}}Cp.prototype.process=function(t){const e=this.ruler.getRules("");for(let r=0,i=e.length;r<i;r++){e[r](t)}};Cp.prototype.State=ip;function Sp(t,e,r,i){this.src=t;this.md=e;this.env=r;this.tokens=i;this.bMarks=[];this.eMarks=[];this.tShift=[];this.sCount=[];this.bsCount=[];this.blkIndent=0;this.line=0;this.lineMax=0;this.tight=false;this.ddIndent=-1;this.listIndent=-1;this.parentType="root";this.level=0;const n=this.src;for(let t=0,e=0,r=0,i=0,s=n.length,l=false;e<s;e++){const o=n.charCodeAt(e);if(!l){if(Jd(o)){r++;if(o===9){i+=4-i%4}else{i++}continue}else{l=true}}if(o===10||e===s-1){if(o!==10){e++}this.bMarks.push(t);this.eMarks.push(e);this.tShift.push(r);this.sCount.push(i);this.bsCount.push(0);l=false;r=0;i=0;t=e+1}}this.bMarks.push(n.length);this.eMarks.push(n.length);this.tShift.push(0);this.sCount.push(0);this.bsCount.push(0);this.lineMax=this.bMarks.length-1}Sp.prototype.push=function(t,e,r){const i=new rp(t,e,r);i.block=true;if(r<0)this.level--;i.level=this.level;if(r>0)this.level++;this.tokens.push(i);return i};Sp.prototype.isEmpty=function t(e){return this.bMarks[e]+this.tShift[e]>=this.eMarks[e]};Sp.prototype.skipEmptyLines=function t(e){for(let t=this.lineMax;e<t;e++){if(this.bMarks[e]+this.tShift[e]<this.eMarks[e]){break}}return e};Sp.prototype.skipSpaces=function t(e){for(let t=this.src.length;e<t;e++){const t=this.src.charCodeAt(e);if(!Jd(t)){break}}return e};Sp.prototype.skipSpacesBack=function t(e,r){if(e<=r){return e}while(e>r){if(!Jd(this.src.charCodeAt(--e))){return e+1}}return e};Sp.prototype.skipChars=function t(e,r){for(let t=this.src.length;e<t;e++){if(this.src.charCodeAt(e)!==r){break}}return e};Sp.prototype.skipCharsBack=function t(e,r,i){if(e<=i){return e}while(e>i){if(r!==this.src.charCodeAt(--e)){return e+1}}return e};Sp.prototype.getLines=function t(e,r,i,n){if(e>=r){return""}const s=new Array(r-e);for(let t=0,l=e;l<r;l++,t++){let e=0;const o=this.bMarks[l];let u=o;let f;if(l+1<r||n){f=this.eMarks[l]+1}else{f=this.eMarks[l]}while(u<f&&e<i){const t=this.src.charCodeAt(u);if(Jd(t)){if(t===9){e+=4-(e+this.bsCount[l])%4}else{e++}}else if(u-o<this.tShift[l]){e++}else{break}u++}if(e>i){s[t]=new Array(e-i+1).join(" ")+this.src.slice(u,f)}else{s[t]=this.src.slice(u,f)}}return s.join("")};Sp.prototype.Token=rp;const Op=65536;function $p(t,e){const r=t.bMarks[e]+t.tShift[e];const i=t.eMarks[e];return t.src.slice(r,i)}function _p(t){const e=[];const r=t.length;let i=0;let n=t.charCodeAt(i);let s=false;let l=0;let o="";while(i<r){if(n===124){if(!s){e.push(o+t.substring(l,i));o="";l=i+1}else{o+=t.substring(l,i-1);l=i}}s=n===92;i++;n=t.charCodeAt(i)}e.push(o+t.substring(l));return e}function Bp(t,e,r,i){if(e+2>r){return false}let n=e+1;if(t.sCount[n]<t.blkIndent){return false}if(t.sCount[n]-t.blkIndent>=4){return false}let s=t.bMarks[n]+t.tShift[n];if(s>=t.eMarks[n]){return false}const l=t.src.charCodeAt(s++);if(l!==124&&l!==45&&l!==58){return false}if(s>=t.eMarks[n]){return false}const o=t.src.charCodeAt(s++);if(o!==124&&o!==45&&o!==58&&!Jd(o)){return false}if(l===45&&Jd(o)){return false}while(s<t.eMarks[n]){const e=t.src.charCodeAt(s);if(e!==124&&e!==45&&e!==58&&!Jd(e)){return false}s++}let u=$p(t,e+1);let f=u.split("|");const h=[];for(let t=0;t<f.length;t++){const e=f[t].trim();if(!e){if(t===0||t===f.length-1){continue}else{return false}}if(!/^:?-+:?$/.test(e)){return false}if(e.charCodeAt(e.length-1)===58){h.push(e.charCodeAt(0)===58?"center":"right")}else if(e.charCodeAt(0)===58){h.push("left")}else{h.push("")}}u=$p(t,e).trim();if(u.indexOf("|")===-1){return false}if(t.sCount[e]-t.blkIndent>=4){return false}f=_p(u);if(f.length&&f[0]==="")f.shift();if(f.length&&f[f.length-1]==="")f.pop();const a=f.length;if(a===0||a!==h.length){return false}if(i){return true}const c=t.parentType;t.parentType="table";const d=t.md.block.ruler.getRules("blockquote");const p=t.push("table_open","table",1);const m=[e,0];p.map=m;const w=t.push("thead_open","thead",1);w.map=[e,e+1];const g=t.push("tr_open","tr",1);g.map=[e,e+1];for(let e=0;e<f.length;e++){const r=t.push("th_open","th",1);if(h[e]){r.attrs=[["style","text-align:"+h[e]]]}const i=t.push("inline","",0);i.content=f[e].trim();i.children=[];t.push("th_close","th",-1)}t.push("tr_close","tr",-1);t.push("thead_close","thead",-1);let b;let k=0;for(n=e+2;n<r;n++){if(t.sCount[n]<t.blkIndent){break}let i=false;for(let e=0,s=d.length;e<s;e++){if(d[e](t,n,r,true)){i=true;break}}if(i){break}u=$p(t,n).trim();if(!u){break}if(t.sCount[n]-t.blkIndent>=4){break}f=_p(u);if(f.length&&f[0]==="")f.shift();if(f.length&&f[f.length-1]==="")f.pop();k+=a-f.length;if(k>Op){break}if(n===e+2){const r=t.push("tbody_open","tbody",1);r.map=b=[e+2,0]}const s=t.push("tr_open","tr",1);s.map=[n,n+1];for(let e=0;e<a;e++){const r=t.push("td_open","td",1);if(h[e]){r.attrs=[["style","text-align:"+h[e]]]}const i=t.push("inline","",0);i.content=f[e]?f[e].trim():"";i.children=[];t.push("td_close","td",-1)}t.push("tr_close","tr",-1)}if(b){t.push("tbody_close","tbody",-1);b[1]=n}t.push("table_close","table",-1);m[1]=n;t.parentType=c;t.line=n;return true}function Rp(t,e,r){if(t.sCount[e]-t.blkIndent<4){return false}let i=e+1;let n=i;while(i<r){if(t.isEmpty(i)){i++;continue}if(t.sCount[i]-t.blkIndent>=4){i++;n=i;continue}break}t.line=n;const s=t.push("code_block","code",0);s.content=t.getLines(e,n,4+t.blkIndent,false)+"\n";s.map=[e,t.line];return true}function jp(t,e,r,i){let n=t.bMarks[e]+t.tShift[e];let s=t.eMarks[e];if(t.sCount[e]-t.blkIndent>=4){return false}if(n+3>s){return false}const l=t.src.charCodeAt(n);if(l!==126&&l!==96){return false}let o=n;n=t.skipChars(n,l);let u=n-o;if(u<3){return false}const f=t.src.slice(o,n);const h=t.src.slice(n,s);if(l===96){if(h.indexOf(String.fromCharCode(l))>=0){return false}}if(i){return true}let a=e;let c=false;for(;;){a++;if(a>=r){break}n=o=t.bMarks[a]+t.tShift[a];s=t.eMarks[a];if(n<s&&t.sCount[a]<t.blkIndent){break}if(t.src.charCodeAt(n)!==l){continue}if(t.sCount[a]-t.blkIndent>=4){continue}n=t.skipChars(n,l);if(n-o<u){continue}n=t.skipSpaces(n);if(n<s){continue}c=true;break}u=t.sCount[e];t.line=a+(c?1:0);const d=t.push("fence","code",0);d.info=h;d.content=t.getLines(e+1,a,u,true);d.markup=f;d.map=[e,t.line];return true}function Np(t,e,r,i){let n=t.bMarks[e]+t.tShift[e];let s=t.eMarks[e];const l=t.lineMax;if(t.sCount[e]-t.blkIndent>=4){return false}if(t.src.charCodeAt(n)!==62){return false}if(i){return true}const o=[];const u=[];const f=[];const h=[];const a=t.md.block.ruler.getRules("blockquote");const c=t.parentType;t.parentType="blockquote";let d=false;let p;for(p=e;p<r;p++){const e=t.sCount[p]<t.blkIndent;n=t.bMarks[p]+t.tShift[p];s=t.eMarks[p];if(n>=s){break}if(t.src.charCodeAt(n++)===62&&!e){let e=t.sCount[p]+1;let r;let i;if(t.src.charCodeAt(n)===32){n++;e++;i=false;r=true}else if(t.src.charCodeAt(n)===9){r=true;if((t.bsCount[p]+e)%4===3){n++;e++;i=false}else{i=true}}else{r=false}let l=e;o.push(t.bMarks[p]);t.bMarks[p]=n;while(n<s){const e=t.src.charCodeAt(n);if(Jd(e)){if(e===9){l+=4-(l+t.bsCount[p]+(i?1:0))%4}else{l++}}else{break}n++}d=n>=s;u.push(t.bsCount[p]);t.bsCount[p]=t.sCount[p]+1+(r?1:0);f.push(t.sCount[p]);t.sCount[p]=l-e;h.push(t.tShift[p]);t.tShift[p]=n-t.bMarks[p];continue}if(d){break}let i=false;for(let e=0,n=a.length;e<n;e++){if(a[e](t,p,r,true)){i=true;break}}if(i){t.lineMax=p;if(t.blkIndent!==0){o.push(t.bMarks[p]);u.push(t.bsCount[p]);h.push(t.tShift[p]);f.push(t.sCount[p]);t.sCount[p]-=t.blkIndent}break}o.push(t.bMarks[p]);u.push(t.bsCount[p]);h.push(t.tShift[p]);f.push(t.sCount[p]);t.sCount[p]=-1}const m=t.blkIndent;t.blkIndent=0;const w=t.push("blockquote_open","blockquote",1);w.markup=">";const g=[e,0];w.map=g;t.md.block.tokenize(t,e,p);const b=t.push("blockquote_close","blockquote",-1);b.markup=">";t.lineMax=l;t.parentType=c;g[1]=t.line;for(let r=0;r<h.length;r++){t.bMarks[r+e]=o[r];t.tShift[r+e]=h[r];t.sCount[r+e]=f[r];t.bsCount[r+e]=u[r]}t.blkIndent=m;return true}function qp(t,e,r,i){const n=t.eMarks[e];if(t.sCount[e]-t.blkIndent>=4){return false}let s=t.bMarks[e]+t.tShift[e];const l=t.src.charCodeAt(s++);if(l!==42&&l!==45&&l!==95){return false}let o=1;while(s<n){const e=t.src.charCodeAt(s++);if(e!==l&&!Jd(e)){return false}if(e===l){o++}}if(o<3){return false}if(i){return true}t.line=e+1;const u=t.push("hr","hr",0);u.map=[e,t.line];u.markup=Array(o+1).join(String.fromCharCode(l));return true}function Tp(t,e){const r=t.eMarks[e];let i=t.bMarks[e]+t.tShift[e];const n=t.src.charCodeAt(i++);if(n!==42&&n!==45&&n!==43){return-1}if(i<r){const e=t.src.charCodeAt(i);if(!Jd(e)){return-1}}return i}function zp(t,e){const r=t.bMarks[e]+t.tShift[e];const i=t.eMarks[e];let n=r;if(n+1>=i){return-1}let s=t.src.charCodeAt(n++);if(s<48||s>57){return-1}for(;;){if(n>=i){return-1}s=t.src.charCodeAt(n++);if(s>=48&&s<=57){if(n-r>=10){return-1}continue}if(s===41||s===46){break}return-1}if(n<i){s=t.src.charCodeAt(n);if(!Jd(s)){return-1}}return n}function Ip(t,e){const r=t.level+2;for(let i=e+2,n=t.tokens.length-2;i<n;i++){if(t.tokens[i].level===r&&t.tokens[i].type==="paragraph_open"){t.tokens[i+2].hidden=true;t.tokens[i].hidden=true;i+=2}}}function Pp(t,e,r,i){let n,s,l,o;let u=e;let f=true;if(t.sCount[u]-t.blkIndent>=4){return false}if(t.listIndent>=0&&t.sCount[u]-t.listIndent>=4&&t.sCount[u]<t.blkIndent){return false}let h=false;if(i&&t.parentType==="paragraph"){if(t.sCount[u]>=t.blkIndent){h=true}}let a;let c;let d;if((d=zp(t,u))>=0){a=true;l=t.bMarks[u]+t.tShift[u];c=Number(t.src.slice(l,d-1));if(h&&c!==1)return false}else if((d=Tp(t,u))>=0){a=false}else{return false}if(h){if(t.skipSpaces(d)>=t.eMarks[u])return false}if(i){return true}const p=t.src.charCodeAt(d-1);const m=t.tokens.length;if(a){o=t.push("ordered_list_open","ol",1);if(c!==1){o.attrs=[["start",c]]}}else{o=t.push("bullet_list_open","ul",1)}const w=[u,0];o.map=w;o.markup=String.fromCharCode(p);let g=false;const b=t.md.block.ruler.getRules("list");const k=t.parentType;t.parentType="list";while(u<r){s=d;n=t.eMarks[u];const e=t.sCount[u]+d-(t.bMarks[u]+t.tShift[u]);let i=e;while(s<n){const e=t.src.charCodeAt(s);if(e===9){i+=4-(i+t.bsCount[u])%4}else if(e===32){i++}else{break}s++}const h=s;let c;if(h>=n){c=1}else{c=i-e}if(c>4){c=1}const m=e+c;o=t.push("list_item_open","li",1);o.markup=String.fromCharCode(p);const w=[u,0];o.map=w;if(a){o.info=t.src.slice(l,d-1)}const k=t.tight;const D=t.tShift[u];const v=t.sCount[u];const y=t.listIndent;t.listIndent=t.blkIndent;t.blkIndent=m;t.tight=true;t.tShift[u]=h-t.bMarks[u];t.sCount[u]=i;if(h>=n&&t.isEmpty(u+1)){t.line=Math.min(t.line+2,r)}else{t.md.block.tokenize(t,u,r,true)}if(!t.tight||g){f=false}g=t.line-u>1&&t.isEmpty(t.line-1);t.blkIndent=t.listIndent;t.listIndent=y;t.tShift[u]=D;t.sCount[u]=v;t.tight=k;o=t.push("list_item_close","li",-1);o.markup=String.fromCharCode(p);u=t.line;w[1]=u;if(u>=r){break}if(t.sCount[u]<t.blkIndent){break}if(t.sCount[u]-t.blkIndent>=4){break}let F=false;for(let e=0,i=b.length;e<i;e++){if(b[e](t,u,r,true)){F=true;break}}if(F){break}if(a){d=zp(t,u);if(d<0){break}l=t.bMarks[u]+t.tShift[u]}else{d=Tp(t,u);if(d<0){break}}if(p!==t.src.charCodeAt(d-1)){break}}if(a){o=t.push("ordered_list_close","ol",-1)}else{o=t.push("bullet_list_close","ul",-1)}o.markup=String.fromCharCode(p);w[1]=u;t.line=u;t.parentType=k;if(f){Ip(t,m)}return true}function Jp(t,e,r,i){let n=t.bMarks[e]+t.tShift[e];let s=t.eMarks[e];let l=e+1;if(t.sCount[e]-t.blkIndent>=4){return false}if(t.src.charCodeAt(n)!==91){return false}function o(e){const r=t.lineMax;if(e>=r||t.isEmpty(e)){return null}let i=false;if(t.sCount[e]-t.blkIndent>3){i=true}if(t.sCount[e]<0){i=true}if(!i){const i=t.md.block.ruler.getRules("reference");const n=t.parentType;t.parentType="reference";let s=false;for(let n=0,l=i.length;n<l;n++){if(i[n](t,e,r,true)){s=true;break}}t.parentType=n;if(s){return null}}const n=t.bMarks[e]+t.tShift[e];const s=t.eMarks[e];return t.src.slice(n,s+1)}let u=t.src.slice(n,s+1);s=u.length;let f=-1;for(n=1;n<s;n++){const t=u.charCodeAt(n);if(t===91){return false}else if(t===93){f=n;break}else if(t===10){const t=o(l);if(t!==null){u+=t;s=u.length;l++}}else if(t===92){n++;if(n<s&&u.charCodeAt(n)===10){const t=o(l);if(t!==null){u+=t;s=u.length;l++}}}}if(f<0||u.charCodeAt(f+1)!==58){return false}for(n=f+2;n<s;n++){const t=u.charCodeAt(n);if(t===10){const t=o(l);if(t!==null){u+=t;s=u.length;l++}}else if(Jd(t));else{break}}const h=t.md.helpers.parseLinkDestination(u,n,s);if(!h.ok){return false}const a=t.md.normalizeLink(h.str);if(!t.md.validateLink(a)){return false}n=h.pos;const c=n;const d=l;const p=n;for(;n<s;n++){const t=u.charCodeAt(n);if(t===10){const t=o(l);if(t!==null){u+=t;s=u.length;l++}}else if(Jd(t));else{break}}let m=t.md.helpers.parseLinkTitle(u,n,s);while(m.can_continue){const e=o(l);if(e===null)break;u+=e;n=s;s=u.length;l++;m=t.md.helpers.parseLinkTitle(u,n,s,m)}let w;if(n<s&&p!==n&&m.ok){w=m.str;n=m.pos}else{w="";n=c;l=d}while(n<s){const t=u.charCodeAt(n);if(!Jd(t)){break}n++}if(n<s&&u.charCodeAt(n)!==10){if(w){w="";n=c;l=d;while(n<s){const t=u.charCodeAt(n);if(!Jd(t)){break}n++}}}if(n<s&&u.charCodeAt(n)!==10){return false}const g=Hd(u.slice(1,f));if(!g){return false}if(i){return true}if(typeof t.env.references==="undefined"){t.env.references={}}if(typeof t.env.references[g]==="undefined"){t.env.references[g]={title:w,href:a}}t.line=l;return true}const Lp=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"];const Wp="[a-zA-Z_:][a-zA-Z0-9:._-]*";const Up="[^\"'=<>`\\x00-\\x20]+";const Hp="'[^']*'";const Zp='"[^"]*"';const Kp="(?:"+Up+"|"+Hp+"|"+Zp+")";const Vp="(?:\\s+"+Wp+"(?:\\s*=\\s*"+Kp+")?)";const Gp="<[A-Za-z][A-Za-z0-9\\-]*"+Vp+"*\\s*\\/?>";const Xp="<\\/[A-Za-z][A-Za-z0-9\\-]*\\s*>";const Yp="\x3c!---?>|\x3c!--(?:[^-]|-[^-]|--[^>])*--\x3e";const Qp="<[?][\\s\\S]*?[?]>";const tm="<![A-Za-z][^>]*>";const em="<!\\[CDATA\\[[\\s\\S]*?\\]\\]>";const rm=new RegExp("^(?:"+Gp+"|"+Xp+"|"+Yp+"|"+Qp+"|"+tm+"|"+em+")");const im=new RegExp("^(?:"+Gp+"|"+Xp+")");const nm=[[/^<(script|pre|style|textarea)(?=(\s|>|$))/i,/<\/(script|pre|style|textarea)>/i,true],[/^<!--/,/-->/,true],[/^<\?/,/\?>/,true],[/^<![A-Z]/,/>/,true],[/^<!\[CDATA\[/,/\]\]>/,true],[new RegExp("^</?("+Lp.join("|")+")(?=(\\s|/?>|$))","i"),/^$/,true],[new RegExp(im.source+"\\s*$"),/^$/,false]];function sm(t,e,r,i){let n=t.bMarks[e]+t.tShift[e];let s=t.eMarks[e];if(t.sCount[e]-t.blkIndent>=4){return false}if(!t.md.options.html){return false}if(t.src.charCodeAt(n)!==60){return false}let l=t.src.slice(n,s);let o=0;for(;o<nm.length;o++){if(nm[o][0].test(l)){break}}if(o===nm.length){return false}if(i){return nm[o][2]}let u=e+1;if(!nm[o][1].test(l)){for(;u<r;u++){if(t.sCount[u]<t.blkIndent){break}n=t.bMarks[u]+t.tShift[u];s=t.eMarks[u];l=t.src.slice(n,s);if(nm[o][1].test(l)){if(l.length!==0){u++}break}}}t.line=u;const f=t.push("html_block","",0);f.map=[e,u];f.content=t.getLines(e,u,t.blkIndent,true);return true}function lm(t,e,r,i){let n=t.bMarks[e]+t.tShift[e];let s=t.eMarks[e];if(t.sCount[e]-t.blkIndent>=4){return false}let l=t.src.charCodeAt(n);if(l!==35||n>=s){return false}let o=1;l=t.src.charCodeAt(++n);while(l===35&&n<s&&o<=6){o++;l=t.src.charCodeAt(++n)}if(o>6||n<s&&!Jd(l)){return false}if(i){return true}s=t.skipSpacesBack(s,n);const u=t.skipCharsBack(s,35,n);if(u>n&&Jd(t.src.charCodeAt(u-1))){s=u}t.line=e+1;const f=t.push("heading_open","h"+String(o),1);f.markup="########".slice(0,o);f.map=[e,t.line];const h=t.push("inline","",0);h.content=t.src.slice(n,s).trim();h.map=[e,t.line];h.children=[];const a=t.push("heading_close","h"+String(o),-1);a.markup="########".slice(0,o);return true}function om(t,e,r){const i=t.md.block.ruler.getRules("paragraph");if(t.sCount[e]-t.blkIndent>=4){return false}const n=t.parentType;t.parentType="paragraph";let s=0;let l;let o=e+1;for(;o<r&&!t.isEmpty(o);o++){if(t.sCount[o]-t.blkIndent>3){continue}if(t.sCount[o]>=t.blkIndent){let e=t.bMarks[o]+t.tShift[o];const r=t.eMarks[o];if(e<r){l=t.src.charCodeAt(e);if(l===45||l===61){e=t.skipChars(e,l);e=t.skipSpaces(e);if(e>=r){s=l===61?1:2;break}}}}if(t.sCount[o]<0){continue}let e=false;for(let n=0,s=i.length;n<s;n++){if(i[n](t,o,r,true)){e=true;break}}if(e){break}}if(!s){return false}const u=t.getLines(e,o,t.blkIndent,false).trim();t.line=o+1;const f=t.push("heading_open","h"+String(s),1);f.markup=String.fromCharCode(l);f.map=[e,t.line];const h=t.push("inline","",0);h.content=u;h.map=[e,t.line-1];h.children=[];const a=t.push("heading_close","h"+String(s),-1);a.markup=String.fromCharCode(l);t.parentType=n;return true}function um(t,e,r){const i=t.md.block.ruler.getRules("paragraph");const n=t.parentType;let s=e+1;t.parentType="paragraph";for(;s<r&&!t.isEmpty(s);s++){if(t.sCount[s]-t.blkIndent>3){continue}if(t.sCount[s]<0){continue}let e=false;for(let n=0,l=i.length;n<l;n++){if(i[n](t,s,r,true)){e=true;break}}if(e){break}}const l=t.getLines(e,s,t.blkIndent,false).trim();t.line=s;const o=t.push("paragraph_open","p",1);o.map=[e,t.line];const u=t.push("inline","",0);u.content=l;u.map=[e,t.line];u.children=[];t.push("paragraph_close","p",-1);t.parentType=n;return true}const fm=[["table",Bp,["paragraph","reference"]],["code",Rp],["fence",jp,["paragraph","reference","blockquote","list"]],["blockquote",Np,["paragraph","reference","blockquote","list"]],["hr",qp,["paragraph","reference","blockquote","list"]],["list",Pp,["paragraph","reference","blockquote"]],["reference",Jp],["html_block",sm,["paragraph","reference","blockquote"]],["heading",lm,["paragraph","reference","blockquote"]],["lheading",om],["paragraph",um]];function hm(){this.ruler=new ep;for(let t=0;t<fm.length;t++){this.ruler.push(fm[t][0],fm[t][1],{alt:(fm[t][2]||[]).slice()})}}hm.prototype.tokenize=function(t,e,r){const i=this.ruler.getRules("");const n=i.length;const s=t.md.options.maxNesting;let l=e;let o=false;while(l<r){t.line=l=t.skipEmptyLines(l);if(l>=r){break}if(t.sCount[l]<t.blkIndent){break}if(t.level>=s){t.line=r;break}const e=t.line;let u=false;for(let s=0;s<n;s++){u=i[s](t,l,r,false);if(u){if(e>=t.line){throw new Error("block rule didn't increment state.line")}break}}if(!u)throw new Error("none of the block rules matched");t.tight=!o;if(t.isEmpty(t.line-1)){o=true}l=t.line;if(l<r&&t.isEmpty(l)){o=true;l++;t.line=l}}};hm.prototype.parse=function(t,e,r,i){if(!t){return}const n=new this.State(t,e,r,i);this.tokenize(n,n.line,n.lineMax)};hm.prototype.State=Sp;function am(t,e,r,i){this.src=t;this.env=r;this.md=e;this.tokens=i;this.tokens_meta=Array(i.length);this.pos=0;this.posMax=this.src.length;this.level=0;this.pending="";this.pendingLevel=0;this.cache={};this.delimiters=[];this._prev_delimiters=[];this.backticks={};this.backticksScanned=false;this.linkLevel=0}am.prototype.pushPending=function(){const t=new rp("text","",0);t.content=this.pending;t.level=this.pendingLevel;this.tokens.push(t);this.pending="";return t};am.prototype.push=function(t,e,r){if(this.pending){this.pushPending()}const i=new rp(t,e,r);let n=null;if(r<0){this.level--;this.delimiters=this._prev_delimiters.pop()}i.level=this.level;if(r>0){this.level++;this._prev_delimiters.push(this.delimiters);this.delimiters=[];n={delimiters:this.delimiters}}this.pendingLevel=this.level;this.tokens.push(i);this.tokens_meta.push(n);return i};am.prototype.scanDelims=function(t,e){const r=this.posMax;const i=this.src.charCodeAt(t);const n=t>0?this.src.charCodeAt(t-1):32;let s=t;while(s<r&&this.src.charCodeAt(s)===i){s++}const l=s-t;const o=s<r?this.src.charCodeAt(s):32;const u=Ud(n)||Wd(String.fromCharCode(n));const f=Ud(o)||Wd(String.fromCharCode(o));const h=Ld(n);const a=Ld(o);const c=!a&&(!f||h||u);const d=!h&&(!u||a||f);const p=c&&(e||!d||u);const m=d&&(e||!c||f);return{can_open:p,can_close:m,length:l}};am.prototype.Token=rp;function cm(t){switch(t){case 10:case 33:case 35:case 36:case 37:case 38:case 42:case 43:case 45:case 58:case 60:case 61:case 62:case 64:case 91:case 92:case 93:case 94:case 95:case 96:case 123:case 125:case 126:return true;default:return false}}function dm(t,e){let r=t.pos;while(r<t.posMax&&!cm(t.src.charCodeAt(r))){r++}if(r===t.pos){return false}if(!e){t.pending+=t.src.slice(t.pos,r)}t.pos=r;return true}const pm=/(?:^|[^a-z0-9.+-])([a-z][a-z0-9.+-]*)$/i;function mm(t,e){if(!t.md.options.linkify)return false;if(t.linkLevel>0)return false;const r=t.pos;const i=t.posMax;if(r+3>i)return false;if(t.src.charCodeAt(r)!==58)return false;if(t.src.charCodeAt(r+1)!==47)return false;if(t.src.charCodeAt(r+2)!==47)return false;const n=t.pending.match(pm);if(!n)return false;const s=n[1];const l=t.md.linkify.matchAtStart(t.src.slice(r-s.length));if(!l)return false;let o=l.url;if(o.length<=s.length)return false;o=o.replace(/\*+$/,"");const u=t.md.normalizeLink(o);if(!t.md.validateLink(u))return false;if(!e){t.pending=t.pending.slice(0,-s.length);const e=t.push("link_open","a",1);e.attrs=[["href",u]];e.markup="linkify";e.info="auto";const r=t.push("text","",0);r.content=t.md.normalizeLinkText(o);const i=t.push("link_close","a",-1);i.markup="linkify";i.info="auto"}t.pos+=o.length-s.length;return true}function wm(t,e){let r=t.pos;if(t.src.charCodeAt(r)!==10){return false}const i=t.pending.length-1;const n=t.posMax;if(!e){if(i>=0&&t.pending.charCodeAt(i)===32){if(i>=1&&t.pending.charCodeAt(i-1)===32){let e=i-1;while(e>=1&&t.pending.charCodeAt(e-1)===32)e--;t.pending=t.pending.slice(0,e);t.push("hardbreak","br",0)}else{t.pending=t.pending.slice(0,-1);t.push("softbreak","br",0)}}else{t.push("softbreak","br",0)}}r++;while(r<n&&Jd(t.src.charCodeAt(r))){r++}t.pos=r;return true}const gm=[];for(let t=0;t<256;t++){gm.push(0)}"\\!\"#$%&'()*+,./:;<=>?@[]^_`{|}~-".split("").forEach((function(t){gm[t.charCodeAt(0)]=1}));function bm(t,e){let r=t.pos;const i=t.posMax;if(t.src.charCodeAt(r)!==92)return false;r++;if(r>=i)return false;let n=t.src.charCodeAt(r);if(n===10){if(!e){t.push("hardbreak","br",0)}r++;while(r<i){n=t.src.charCodeAt(r);if(!Jd(n))break;r++}t.pos=r;return true}let s=t.src[r];if(n>=55296&&n<=56319&&r+1<i){const e=t.src.charCodeAt(r+1);if(e>=56320&&e<=57343){s+=t.src[r+1];r++}}const l="\\"+s;if(!e){const e=t.push("text_special","",0);if(n<256&&gm[n]!==0){e.content=s}else{e.content=l}e.markup=l;e.info="escape"}t.pos=r+1;return true}function km(t,e){let r=t.pos;const i=t.src.charCodeAt(r);if(i!==96){return false}const n=r;r++;const s=t.posMax;while(r<s&&t.src.charCodeAt(r)===96){r++}const l=t.src.slice(n,r);const o=l.length;if(t.backticksScanned&&(t.backticks[o]||0)<=n){if(!e)t.pending+=l;t.pos+=o;return true}let u=r;let f;while((f=t.src.indexOf("`",u))!==-1){u=f+1;while(u<s&&t.src.charCodeAt(u)===96){u++}const i=u-f;if(i===o){if(!e){const e=t.push("code_inline","code",0);e.markup=l;e.content=t.src.slice(r,f).replace(/\n/g," ").replace(/^ (.+) $/,"$1")}t.pos=u;return true}t.backticks[i]=f}t.backticksScanned=true;if(!e)t.pending+=l;t.pos+=o;return true}function Dm(t,e){const r=t.pos;const i=t.src.charCodeAt(r);if(e){return false}if(i!==126){return false}const n=t.scanDelims(t.pos,true);let s=n.length;const l=String.fromCharCode(i);if(s<2){return false}let o;if(s%2){o=t.push("text","",0);o.content=l;s--}for(let e=0;e<s;e+=2){o=t.push("text","",0);o.content=l+l;t.delimiters.push({marker:i,length:0,token:t.tokens.length-1,end:-1,open:n.can_open,close:n.can_close})}t.pos+=n.length;return true}function vm(t,e){let r;const i=[];const n=e.length;for(let s=0;s<n;s++){const n=e[s];if(n.marker!==126){continue}if(n.end===-1){continue}const l=e[n.end];r=t.tokens[n.token];r.type="s_open";r.tag="s";r.nesting=1;r.markup="~~";r.content="";r=t.tokens[l.token];r.type="s_close";r.tag="s";r.nesting=-1;r.markup="~~";r.content="";if(t.tokens[l.token-1].type==="text"&&t.tokens[l.token-1].content==="~"){i.push(l.token-1)}}while(i.length){const e=i.pop();let n=e+1;while(n<t.tokens.length&&t.tokens[n].type==="s_close"){n++}n--;if(e!==n){r=t.tokens[n];t.tokens[n]=t.tokens[e];t.tokens[e]=r}}}function ym(t){const e=t.tokens_meta;const r=t.tokens_meta.length;vm(t,t.delimiters);for(let i=0;i<r;i++){if(e[i]&&e[i].delimiters){vm(t,e[i].delimiters)}}}const Fm={tokenize:Dm,postProcess:ym};function Em(t,e){const r=t.pos;const i=t.src.charCodeAt(r);if(e){return false}if(i!==95&&i!==42){return false}const n=t.scanDelims(t.pos,i===42);for(let e=0;e<n.length;e++){const e=t.push("text","",0);e.content=String.fromCharCode(i);t.delimiters.push({marker:i,length:n.length,token:t.tokens.length-1,end:-1,open:n.can_open,close:n.can_close})}t.pos+=n.length;return true}function Mm(t,e){const r=e.length;for(let i=r-1;i>=0;i--){const r=e[i];if(r.marker!==95&&r.marker!==42){continue}if(r.end===-1){continue}const n=e[r.end];const s=i>0&&e[i-1].end===r.end+1&&e[i-1].marker===r.marker&&e[i-1].token===r.token-1&&e[r.end+1].token===n.token+1;const l=String.fromCharCode(r.marker);const o=t.tokens[r.token];o.type=s?"strong_open":"em_open";o.tag=s?"strong":"em";o.nesting=1;o.markup=s?l+l:l;o.content="";const u=t.tokens[n.token];u.type=s?"strong_close":"em_close";u.tag=s?"strong":"em";u.nesting=-1;u.markup=s?l+l:l;u.content="";if(s){t.tokens[e[i-1].token].content="";t.tokens[e[r.end+1].token].content="";i--}}}function xm(t){const e=t.tokens_meta;const r=t.tokens_meta.length;Mm(t,t.delimiters);for(let i=0;i<r;i++){if(e[i]&&e[i].delimiters){Mm(t,e[i].delimiters)}}}const Am={tokenize:Em,postProcess:xm};function Cm(t,e){let r,i,n,s;let l="";let o="";let u=t.pos;let f=true;if(t.src.charCodeAt(t.pos)!==91){return false}const h=t.pos;const a=t.posMax;const c=t.pos+1;const d=t.md.helpers.parseLinkLabel(t,t.pos,true);if(d<0){return false}let p=d+1;if(p<a&&t.src.charCodeAt(p)===40){f=false;p++;for(;p<a;p++){r=t.src.charCodeAt(p);if(!Jd(r)&&r!==10){break}}if(p>=a){return false}u=p;n=t.md.helpers.parseLinkDestination(t.src,p,t.posMax);if(n.ok){l=t.md.normalizeLink(n.str);if(t.md.validateLink(l)){p=n.pos}else{l=""}u=p;for(;p<a;p++){r=t.src.charCodeAt(p);if(!Jd(r)&&r!==10){break}}n=t.md.helpers.parseLinkTitle(t.src,p,t.posMax);if(p<a&&u!==p&&n.ok){o=n.str;p=n.pos;for(;p<a;p++){r=t.src.charCodeAt(p);if(!Jd(r)&&r!==10){break}}}}if(p>=a||t.src.charCodeAt(p)!==41){f=true}p++}if(f){if(typeof t.env.references==="undefined"){return false}if(p<a&&t.src.charCodeAt(p)===91){u=p+1;p=t.md.helpers.parseLinkLabel(t,p);if(p>=0){i=t.src.slice(u,p++)}else{p=d+1}}else{p=d+1}if(!i){i=t.src.slice(c,d)}s=t.env.references[Hd(i)];if(!s){t.pos=h;return false}l=s.href;o=s.title}if(!e){t.pos=c;t.posMax=d;const e=t.push("link_open","a",1);const r=[["href",l]];e.attrs=r;if(o){r.push(["title",o])}t.linkLevel++;t.md.inline.tokenize(t);t.linkLevel--;t.push("link_close","a",-1)}t.pos=p;t.posMax=a;return true}function Sm(t,e){let r,i,n,s,l,o,u,f;let h="";const a=t.pos;const c=t.posMax;if(t.src.charCodeAt(t.pos)!==33){return false}if(t.src.charCodeAt(t.pos+1)!==91){return false}const d=t.pos+2;const p=t.md.helpers.parseLinkLabel(t,t.pos+1,false);if(p<0){return false}s=p+1;if(s<c&&t.src.charCodeAt(s)===40){s++;for(;s<c;s++){r=t.src.charCodeAt(s);if(!Jd(r)&&r!==10){break}}if(s>=c){return false}f=s;o=t.md.helpers.parseLinkDestination(t.src,s,t.posMax);if(o.ok){h=t.md.normalizeLink(o.str);if(t.md.validateLink(h)){s=o.pos}else{h=""}}f=s;for(;s<c;s++){r=t.src.charCodeAt(s);if(!Jd(r)&&r!==10){break}}o=t.md.helpers.parseLinkTitle(t.src,s,t.posMax);if(s<c&&f!==s&&o.ok){u=o.str;s=o.pos;for(;s<c;s++){r=t.src.charCodeAt(s);if(!Jd(r)&&r!==10){break}}}else{u=""}if(s>=c||t.src.charCodeAt(s)!==41){t.pos=a;return false}s++}else{if(typeof t.env.references==="undefined"){return false}if(s<c&&t.src.charCodeAt(s)===91){f=s+1;s=t.md.helpers.parseLinkLabel(t,s);if(s>=0){n=t.src.slice(f,s++)}else{s=p+1}}else{s=p+1}if(!n){n=t.src.slice(d,p)}l=t.env.references[Hd(n)];if(!l){t.pos=a;return false}h=l.href;u=l.title}if(!e){i=t.src.slice(d,p);const e=[];t.md.inline.parse(i,t.md,t.env,e);const r=t.push("image","img",0);const n=[["src",h],["alt",""]];r.attrs=n;r.children=e;r.content=i;if(u){n.push(["title",u])}}t.pos=s;t.posMax=c;return true}const Om=/^([a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*)$/;const $m=/^([a-zA-Z][a-zA-Z0-9+.-]{1,31}):([^<>\x00-\x20]*)$/;function _m(t,e){let r=t.pos;if(t.src.charCodeAt(r)!==60){return false}const i=t.pos;const n=t.posMax;for(;;){if(++r>=n)return false;const e=t.src.charCodeAt(r);if(e===60)return false;if(e===62)break}const s=t.src.slice(i+1,r);if($m.test(s)){const r=t.md.normalizeLink(s);if(!t.md.validateLink(r)){return false}if(!e){const e=t.push("link_open","a",1);e.attrs=[["href",r]];e.markup="autolink";e.info="auto";const i=t.push("text","",0);i.content=t.md.normalizeLinkText(s);const n=t.push("link_close","a",-1);n.markup="autolink";n.info="auto"}t.pos+=s.length+2;return true}if(Om.test(s)){const r=t.md.normalizeLink("mailto:"+s);if(!t.md.validateLink(r)){return false}if(!e){const e=t.push("link_open","a",1);e.attrs=[["href",r]];e.markup="autolink";e.info="auto";const i=t.push("text","",0);i.content=t.md.normalizeLinkText(s);const n=t.push("link_close","a",-1);n.markup="autolink";n.info="auto"}t.pos+=s.length+2;return true}return false}function Bm(t){return/^<a[>\s]/i.test(t)}function Rm(t){return/^<\/a\s*>/i.test(t)}function jm(t){const e=t|32;return e>=97&&e<=122}function Nm(t,e){if(!t.md.options.html){return false}const r=t.posMax;const i=t.pos;if(t.src.charCodeAt(i)!==60||i+2>=r){return false}const n=t.src.charCodeAt(i+1);if(n!==33&&n!==63&&n!==47&&!jm(n)){return false}const s=t.src.slice(i).match(rm);if(!s){return false}if(!e){const e=t.push("html_inline","",0);e.content=s[0];if(Bm(e.content))t.linkLevel++;if(Rm(e.content))t.linkLevel--}t.pos+=s[0].length;return true}const qm=/^&#((?:x[a-f0-9]{1,6}|[0-9]{1,7}));/i;const Tm=/^&([a-z][a-z0-9]{1,31});/i;function zm(t,e){const r=t.pos;const i=t.posMax;if(t.src.charCodeAt(r)!==38)return false;if(r+1>=i)return false;const n=t.src.charCodeAt(r+1);if(n===35){const i=t.src.slice(r).match(qm);if(i){if(!e){const e=i[1][0].toLowerCase()==="x"?parseInt(i[1].slice(1),16):parseInt(i[1],10);const r=t.push("text_special","",0);r.content=xd(e)?Ad(e):Ad(65533);r.markup=i[0];r.info="entity"}t.pos+=i[0].length;return true}}else{const i=t.src.slice(r).match(Tm);if(i){const r=x(i[0]);if(r!==i[0]){if(!e){const e=t.push("text_special","",0);e.content=r;e.markup=i[0];e.info="entity"}t.pos+=i[0].length;return true}}}return false}function Im(t){const e={};const r=t.length;if(!r)return;let i=0;let n=-2;const s=[];for(let l=0;l<r;l++){const r=t[l];s.push(0);if(t[i].marker!==r.marker||n!==r.token-1){i=l}n=r.token;r.length=r.length||0;if(!r.close)continue;if(!e.hasOwnProperty(r.marker)){e[r.marker]=[-1,-1,-1,-1,-1,-1]}const o=e[r.marker][(r.open?3:0)+r.length%3];let u=i-s[i]-1;let f=u;for(;u>o;u-=s[u]+1){const e=t[u];if(e.marker!==r.marker)continue;if(e.open&&e.end<0){let i=false;if(e.close||r.open){if((e.length+r.length)%3===0){if(e.length%3!==0||r.length%3!==0){i=true}}}if(!i){const i=u>0&&!t[u-1].open?s[u-1]+1:0;s[l]=l-u+i;s[u]=i;r.open=false;e.end=l;e.close=false;f=-1;n=-2;break}}}if(f!==-1){e[r.marker][(r.open?3:0)+(r.length||0)%3]=f}}}function Pm(t){const e=t.tokens_meta;const r=t.tokens_meta.length;Im(t.delimiters);for(let t=0;t<r;t++){if(e[t]&&e[t].delimiters){Im(e[t].delimiters)}}}function Jm(t){let e,r;let i=0;const n=t.tokens;const s=t.tokens.length;for(e=r=0;e<s;e++){if(n[e].nesting<0)i--;n[e].level=i;if(n[e].nesting>0)i++;if(n[e].type==="text"&&e+1<s&&n[e+1].type==="text"){n[e+1].content=n[e].content+n[e+1].content}else{if(e!==r){n[r]=n[e]}r++}}if(e!==r){n.length=r}}const Lm=[["text",dm],["linkify",mm],["newline",wm],["escape",bm],["backticks",km],["strikethrough",Fm.tokenize],["emphasis",Am.tokenize],["link",Cm],["image",Sm],["autolink",_m],["html_inline",Nm],["entity",zm]];const Wm=[["balance_pairs",Pm],["strikethrough",Fm.postProcess],["emphasis",Am.postProcess],["fragments_join",Jm]];function Um(){this.ruler=new ep;for(let t=0;t<Lm.length;t++){this.ruler.push(Lm[t][0],Lm[t][1])}this.ruler2=new ep;for(let t=0;t<Wm.length;t++){this.ruler2.push(Wm[t][0],Wm[t][1])}}Um.prototype.skipToken=function(t){const e=t.pos;const r=this.ruler.getRules("");const i=r.length;const n=t.md.options.maxNesting;const s=t.cache;if(typeof s[e]!=="undefined"){t.pos=s[e];return}let l=false;if(t.level<n){for(let n=0;n<i;n++){t.level++;l=r[n](t,true);t.level--;if(l){if(e>=t.pos){throw new Error("inline rule didn't increment state.pos")}break}}}else{t.pos=t.posMax}if(!l){t.pos++}s[e]=t.pos};Um.prototype.tokenize=function(t){const e=this.ruler.getRules("");const r=e.length;const i=t.posMax;const n=t.md.options.maxNesting;while(t.pos<i){const s=t.pos;let l=false;if(t.level<n){for(let i=0;i<r;i++){l=e[i](t,false);if(l){if(s>=t.pos){throw new Error("inline rule didn't increment state.pos")}break}}}if(l){if(t.pos>=i){break}continue}t.pending+=t.src[t.pos++]}if(t.pending){t.pushPending()}};Um.prototype.parse=function(t,e,r,i){const n=new this.State(t,e,r,i);this.tokenize(n);const s=this.ruler2.getRules("");const l=s.length;for(let t=0;t<l;t++){s[t](n)}};Um.prototype.State=am;function Hm(t){const e={};t=t||{};e.src_Any=dd.source;e.src_Cc=pd.source;e.src_Z=bd.source;e.src_P=wd.source;e.src_ZPCc=[e.src_Z,e.src_P,e.src_Cc].join("|");e.src_ZCc=[e.src_Z,e.src_Cc].join("|");const r="[><|]";e.src_pseudo_letter="(?:(?!"+r+"|"+e.src_ZPCc+")"+e.src_Any+")";e.src_ip4="(?:(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)";e.src_auth="(?:(?:(?!"+e.src_ZCc+"|[@/\\[\\]()]).)+@)?";e.src_port="(?::(?:6(?:[0-4]\\d{3}|5(?:[0-4]\\d{2}|5(?:[0-2]\\d|3[0-5])))|[1-5]?\\d{1,4}))?";e.src_host_terminator="(?=$|"+r+"|"+e.src_ZPCc+")"+"(?!"+(t["---"]?"-(?!--)|":"-|")+"_|:\\d|\\.-|\\.(?!$|"+e.src_ZPCc+"))";e.src_path="(?:"+"[/?#]"+"(?:"+"(?!"+e.src_ZCc+"|"+r+"|[()[\\]{}.,\"'?!\\-;]).|"+"\\[(?:(?!"+e.src_ZCc+"|\\]).)*\\]|"+"\\((?:(?!"+e.src_ZCc+"|[)]).)*\\)|"+"\\{(?:(?!"+e.src_ZCc+"|[}]).)*\\}|"+'\\"(?:(?!'+e.src_ZCc+'|["]).)+\\"|'+"\\'(?:(?!"+e.src_ZCc+"|[']).)+\\'|"+"\\'(?="+e.src_pseudo_letter+"|[-])|"+"\\.{2,}[a-zA-Z0-9%/&]|"+"\\.(?!"+e.src_ZCc+"|[.]|$)|"+(t["---"]?"\\-(?!--(?:[^-]|$))(?:-*)|":"\\-+|")+",(?!"+e.src_ZCc+"|$)|"+";(?!"+e.src_ZCc+"|$)|"+"\\!+(?!"+e.src_ZCc+"|[!]|$)|"+"\\?(?!"+e.src_ZCc+"|[?]|$)"+")+"+"|\\/"+")?";e.src_email_name='[\\-;:&=\\+\\$,\\.a-zA-Z0-9_][\\-;:&=\\+\\$,\\"\\.a-zA-Z0-9_]*';e.src_xn="xn--[a-z0-9\\-]{1,59}";e.src_domain_root="(?:"+e.src_xn+"|"+e.src_pseudo_letter+"{1,63}"+")";e.src_domain="(?:"+e.src_xn+"|"+"(?:"+e.src_pseudo_letter+")"+"|"+"(?:"+e.src_pseudo_letter+"(?:-|"+e.src_pseudo_letter+"){0,61}"+e.src_pseudo_letter+")"+")";e.src_host="(?:"+"(?:(?:(?:"+e.src_domain+")\\.)*"+e.src_domain+")"+")";e.tpl_host_fuzzy="(?:"+e.src_ip4+"|"+"(?:(?:(?:"+e.src_domain+")\\.)+(?:%TLDS%))"+")";e.tpl_host_no_ip_fuzzy="(?:(?:(?:"+e.src_domain+")\\.)+(?:%TLDS%))";e.src_host_strict=e.src_host+e.src_host_terminator;e.tpl_host_fuzzy_strict=e.tpl_host_fuzzy+e.src_host_terminator;e.src_host_port_strict=e.src_host+e.src_port+e.src_host_terminator;e.tpl_host_port_fuzzy_strict=e.tpl_host_fuzzy+e.src_port+e.src_host_terminator;e.tpl_host_port_no_ip_fuzzy_strict=e.tpl_host_no_ip_fuzzy+e.src_port+e.src_host_terminator;e.tpl_host_fuzzy_test="localhost|www\\.|\\.\\d{1,3}\\.|(?:\\.(?:%TLDS%)(?:"+e.src_ZPCc+"|>|$))";e.tpl_email_fuzzy="(^|"+r+'|"|\\(|'+e.src_ZCc+")"+"("+e.src_email_name+"@"+e.tpl_host_fuzzy_strict+")";e.tpl_link_fuzzy="(^|(?![.:/\\-_@])(?:[$+<=>^`||]|"+e.src_ZPCc+"))"+"((?![$+<=>^`||])"+e.tpl_host_port_fuzzy_strict+e.src_path+")";e.tpl_link_no_ip_fuzzy="(^|(?![.:/\\-_@])(?:[$+<=>^`||]|"+e.src_ZPCc+"))"+"((?![$+<=>^`||])"+e.tpl_host_port_no_ip_fuzzy_strict+e.src_path+")";return e}function Zm(t){const e=Array.prototype.slice.call(arguments,1);e.forEach((function(e){if(!e){return}Object.keys(e).forEach((function(r){t[r]=e[r]}))}));return t}function Km(t){return Object.prototype.toString.call(t)}function Vm(t){return Km(t)==="[object String]"}function Gm(t){return Km(t)==="[object Object]"}function Xm(t){return Km(t)==="[object RegExp]"}function Ym(t){return Km(t)==="[object Function]"}function Qm(t){return t.replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}const tw={fuzzyLink:true,fuzzyEmail:true,fuzzyIP:false};function ew(t){return Object.keys(t||{}).reduce((function(t,e){return t||tw.hasOwnProperty(e)}),false)}const rw={"http:":{validate:function(t,e,r){const i=t.slice(e);if(!r.re.http){r.re.http=new RegExp("^\\/\\/"+r.re.src_auth+r.re.src_host_port_strict+r.re.src_path,"i")}if(r.re.http.test(i)){return i.match(r.re.http)[0].length}return 0}},"https:":"http:","ftp:":"http:","//":{validate:function(t,e,r){const i=t.slice(e);if(!r.re.no_http){r.re.no_http=new RegExp("^"+r.re.src_auth+"(?:localhost|(?:(?:"+r.re.src_domain+")\\.)+"+r.re.src_domain_root+")"+r.re.src_port+r.re.src_host_terminator+r.re.src_path,"i")}if(r.re.no_http.test(i)){if(e>=3&&t[e-3]===":"){return 0}if(e>=3&&t[e-3]==="/"){return 0}return i.match(r.re.no_http)[0].length}return 0}},"mailto:":{validate:function(t,e,r){const i=t.slice(e);if(!r.re.mailto){r.re.mailto=new RegExp("^"+r.re.src_email_name+"@"+r.re.src_host_strict,"i")}if(r.re.mailto.test(i)){return i.match(r.re.mailto)[0].length}return 0}}};const iw="a[cdefgilmnoqrstuwxz]|b[abdefghijmnorstvwyz]|c[acdfghiklmnoruvwxyz]|d[ejkmoz]|e[cegrstu]|f[ijkmor]|g[abdefghilmnpqrstuwy]|h[kmnrtu]|i[delmnoqrst]|j[emop]|k[eghimnprwyz]|l[abcikrstuvy]|m[acdeghklmnopqrstuvwxyz]|n[acefgilopruz]|om|p[aefghklmnrstwy]|qa|r[eosuw]|s[abcdeghijklmnortuvxyz]|t[cdfghjklmnortvwz]|u[agksyz]|v[aceginu]|w[fs]|y[et]|z[amw]";const nw="biz|com|edu|gov|net|org|pro|web|xxx|aero|asia|coop|info|museum|name|shop|рф".split("|");function sw(t){t.__index__=-1;t.__text_cache__=""}function lw(t){return function(e,r){const i=e.slice(r);if(t.test(i)){return i.match(t)[0].length}return 0}}function ow(){return function(t,e){e.normalize(t)}}function uw(t){const e=t.re=Hm(t.__opts__);const r=t.__tlds__.slice();t.onCompile();if(!t.__tlds_replaced__){r.push(iw)}r.push(e.src_xn);e.src_tlds=r.join("|");function i(t){return t.replace("%TLDS%",e.src_tlds)}e.email_fuzzy=RegExp(i(e.tpl_email_fuzzy),"i");e.link_fuzzy=RegExp(i(e.tpl_link_fuzzy),"i");e.link_no_ip_fuzzy=RegExp(i(e.tpl_link_no_ip_fuzzy),"i");e.host_fuzzy_test=RegExp(i(e.tpl_host_fuzzy_test),"i");const n=[];t.__compiled__={};function s(t,e){throw new Error('(LinkifyIt) Invalid schema "'+t+'": '+e)}Object.keys(t.__schemas__).forEach((function(e){const r=t.__schemas__[e];if(r===null){return}const i={validate:null,link:null};t.__compiled__[e]=i;if(Gm(r)){if(Xm(r.validate)){i.validate=lw(r.validate)}else if(Ym(r.validate)){i.validate=r.validate}else{s(e,r)}if(Ym(r.normalize)){i.normalize=r.normalize}else if(!r.normalize){i.normalize=ow()}else{s(e,r)}return}if(Vm(r)){n.push(e);return}s(e,r)}));n.forEach((function(e){if(!t.__compiled__[t.__schemas__[e]]){return}t.__compiled__[e].validate=t.__compiled__[t.__schemas__[e]].validate;t.__compiled__[e].normalize=t.__compiled__[t.__schemas__[e]].normalize}));t.__compiled__[""]={validate:null,normalize:ow()};const l=Object.keys(t.__compiled__).filter((function(e){return e.length>0&&t.__compiled__[e]})).map(Qm).join("|");t.re.schema_test=RegExp("(^|(?!_)(?:[><|]|"+e.src_ZPCc+"))("+l+")","i");t.re.schema_search=RegExp("(^|(?!_)(?:[><|]|"+e.src_ZPCc+"))("+l+")","ig");t.re.schema_at_start=RegExp("^"+t.re.schema_search.source,"i");t.re.pretest=RegExp("("+t.re.schema_test.source+")|("+t.re.host_fuzzy_test.source+")|@","i");sw(t)}function fw(t,e){const r=t.__index__;const i=t.__last_index__;const n=t.__text_cache__.slice(r,i);this.schema=t.__schema__.toLowerCase();this.index=r+e;this.lastIndex=i+e;this.raw=n;this.text=n;this.url=n}function hw(t,e){const r=new fw(t,e);t.__compiled__[r.schema].normalize(r,t);return r}function aw(t,e){if(!(this instanceof aw)){return new aw(t,e)}if(!e){if(ew(t)){e=t;t={}}}this.__opts__=Zm({},tw,e);this.__index__=-1;this.__last_index__=-1;this.__schema__="";this.__text_cache__="";this.__schemas__=Zm({},rw,t);this.__compiled__={};this.__tlds__=nw;this.__tlds_replaced__=false;this.re={};uw(this)}aw.prototype.add=function t(e,r){this.__schemas__[e]=r;uw(this);return this};aw.prototype.set=function t(e){this.__opts__=Zm(this.__opts__,e);return this};aw.prototype.test=function t(e){this.__text_cache__=e;this.__index__=-1;if(!e.length){return false}let r,i,n,s,l,o,u,f,h;if(this.re.schema_test.test(e)){u=this.re.schema_search;u.lastIndex=0;while((r=u.exec(e))!==null){s=this.testSchemaAt(e,r[2],u.lastIndex);if(s){this.__schema__=r[2];this.__index__=r.index+r[1].length;this.__last_index__=r.index+r[0].length+s;break}}}if(this.__opts__.fuzzyLink&&this.__compiled__["http:"]){f=e.search(this.re.host_fuzzy_test);if(f>=0){if(this.__index__<0||f<this.__index__){if((i=e.match(this.__opts__.fuzzyIP?this.re.link_fuzzy:this.re.link_no_ip_fuzzy))!==null){l=i.index+i[1].length;if(this.__index__<0||l<this.__index__){this.__schema__="";this.__index__=l;this.__last_index__=i.index+i[0].length}}}}}if(this.__opts__.fuzzyEmail&&this.__compiled__["mailto:"]){h=e.indexOf("@");if(h>=0){if((n=e.match(this.re.email_fuzzy))!==null){l=n.index+n[1].length;o=n.index+n[0].length;if(this.__index__<0||l<this.__index__||l===this.__index__&&o>this.__last_index__){this.__schema__="mailto:";this.__index__=l;this.__last_index__=o}}}}return this.__index__>=0};aw.prototype.pretest=function t(e){return this.re.pretest.test(e)};aw.prototype.testSchemaAt=function t(e,r,i){if(!this.__compiled__[r.toLowerCase()]){return 0}return this.__compiled__[r.toLowerCase()].validate(e,i,this)};aw.prototype.match=function t(e){const r=[];let i=0;if(this.__index__>=0&&this.__text_cache__===e){r.push(hw(this,i));i=this.__last_index__}let n=i?e.slice(i):e;while(this.test(n)){r.push(hw(this,i));n=n.slice(this.__last_index__);i+=this.__last_index__}if(r.length){return r}return null};aw.prototype.matchAtStart=function t(e){this.__text_cache__=e;this.__index__=-1;if(!e.length)return null;const r=this.re.schema_at_start.exec(e);if(!r)return null;const i=this.testSchemaAt(e,r[2],r[0].length);if(!i)return null;this.__schema__=r[2];this.__index__=r.index+r[1].length;this.__last_index__=r.index+r[0].length+i;return hw(this,0)};aw.prototype.tlds=function t(e,r){e=Array.isArray(e)?e:[e];if(!r){this.__tlds__=e.slice();this.__tlds_replaced__=true;uw(this);return this}this.__tlds__=this.__tlds__.concat(e).sort().filter((function(t,e,r){return t!==r[e-1]})).reverse();uw(this);return this};aw.prototype.normalize=function t(e){if(!e.schema){e.url="http://"+e.url}if(e.schema==="mailto:"&&!/^mailto:/i.test(e.url)){e.url="mailto:"+e.url}};aw.prototype.onCompile=function t(){};const cw=2147483647;const dw=36;const pw=1;const mw=26;const ww=38;const gw=700;const bw=72;const kw=128;const Dw="-";const vw=/^xn--/;const yw=/[^\0-\x7F]/;const Fw=/[\x2E\u3002\uFF0E\uFF61]/g;const Ew={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"};const Mw=dw-pw;const xw=Math.floor;const Aw=String.fromCharCode;function Cw(t){throw new RangeError(Ew[t])}function Sw(t,e){const r=[];let i=t.length;while(i--){r[i]=e(t[i])}return r}function Ow(t,e){const r=t.split("@");let i="";if(r.length>1){i=r[0]+"@";t=r[1]}t=t.replace(Fw,".");const n=t.split(".");const s=Sw(n,e).join(".");return i+s}function $w(t){const e=[];let r=0;const i=t.length;while(r<i){const n=t.charCodeAt(r++);if(n>=55296&&n<=56319&&r<i){const i=t.charCodeAt(r++);if((i&64512)==56320){e.push(((n&1023)<<10)+(i&1023)+65536)}else{e.push(n);r--}}else{e.push(n)}}return e}const _w=t=>String.fromCodePoint(...t);const Bw=function(t){if(t>=48&&t<58){return 26+(t-48)}if(t>=65&&t<91){return t-65}if(t>=97&&t<123){return t-97}return dw};const Rw=function(t,e){return t+22+75*(t<26)-((e!=0)<<5)};const jw=function(t,e,r){let i=0;t=r?xw(t/gw):t>>1;t+=xw(t/e);for(;t>Mw*mw>>1;i+=dw){t=xw(t/Mw)}return xw(i+(Mw+1)*t/(t+ww))};const Nw=function(t){const e=[];const r=t.length;let i=0;let n=kw;let s=bw;let l=t.lastIndexOf(Dw);if(l<0){l=0}for(let r=0;r<l;++r){if(t.charCodeAt(r)>=128){Cw("not-basic")}e.push(t.charCodeAt(r))}for(let o=l>0?l+1:0;o<r;){const l=i;for(let e=1,n=dw;;n+=dw){if(o>=r){Cw("invalid-input")}const l=Bw(t.charCodeAt(o++));if(l>=dw){Cw("invalid-input")}if(l>xw((cw-i)/e)){Cw("overflow")}i+=l*e;const u=n<=s?pw:n>=s+mw?mw:n-s;if(l<u){break}const f=dw-u;if(e>xw(cw/f)){Cw("overflow")}e*=f}const u=e.length+1;s=jw(i-l,u,l==0);if(xw(i/u)>cw-n){Cw("overflow")}n+=xw(i/u);i%=u;e.splice(i++,0,n)}return String.fromCodePoint(...e)};const qw=function(t){const e=[];t=$w(t);const r=t.length;let i=kw;let n=0;let s=bw;for(const r of t){if(r<128){e.push(Aw(r))}}const l=e.length;let o=l;if(l){e.push(Dw)}while(o<r){let r=cw;for(const e of t){if(e>=i&&e<r){r=e}}const u=o+1;if(r-i>xw((cw-n)/u)){Cw("overflow")}n+=(r-i)*u;i=r;for(const r of t){if(r<i&&++n>cw){Cw("overflow")}if(r===i){let t=n;for(let r=dw;;r+=dw){const i=r<=s?pw:r>=s+mw?mw:r-s;if(t<i){break}const n=t-i;const l=dw-i;e.push(Aw(Rw(i+n%l,0)));t=xw(n/l)}e.push(Aw(Rw(t,0)));s=jw(n,u,o===l);n=0;++o}}++n;++i}return e.join("")};const Tw=function(t){return Ow(t,(function(t){return vw.test(t)?Nw(t.slice(4).toLowerCase()):t}))};const zw=function(t){return Ow(t,(function(t){return yw.test(t)?"xn--"+qw(t):t}))};const Iw={version:"2.3.1",ucs2:{decode:$w,encode:_w},decode:Nw,encode:qw,toASCII:zw,toUnicode:Tw};const Pw={options:{html:false,xhtmlOut:false,breaks:false,langPrefix:"language-",linkify:false,typographer:false,quotes:"“”‘’",highlight:null,maxNesting:100},components:{core:{},block:{},inline:{}}};const Jw={options:{html:false,xhtmlOut:false,breaks:false,langPrefix:"language-",linkify:false,typographer:false,quotes:"“”‘’",highlight:null,maxNesting:20},components:{core:{rules:["normalize","block","inline","text_join"]},block:{rules:["paragraph"]},inline:{rules:["text"],rules2:["balance_pairs","fragments_join"]}}};const Lw={options:{html:true,xhtmlOut:true,breaks:false,langPrefix:"language-",linkify:false,typographer:false,quotes:"“”‘’",highlight:null,maxNesting:20},components:{core:{rules:["normalize","block","inline","text_join"]},block:{rules:["blockquote","code","fence","heading","hr","html_block","lheading","list","reference","paragraph"]},inline:{rules:["autolink","backticks","emphasis","entity","escape","html_inline","image","link","newline","text"],rules2:["balance_pairs","emphasis","fragments_join"]}}};const Ww={default:Pw,zero:Jw,commonmark:Lw};const Uw=/^(vbscript|javascript|file|data):/;const Hw=/^data:image\/(gif|png|jpeg|webp);/;function Zw(t){const e=t.trim().toLowerCase();return Uw.test(e)?Hw.test(e):true}const Kw=["http:","https:","mailto:"];function Vw(t){const e=ad(t,true);if(e.hostname){if(!e.protocol||Kw.indexOf(e.protocol)>=0){try{e.hostname=Iw.toASCII(e.hostname)}catch(t){}}}return Vc(Gc(e))}function Gw(t){const e=ad(t,true);if(e.hostname){if(!e.protocol||Kw.indexOf(e.protocol)>=0){try{e.hostname=Iw.toUnicode(e.hostname)}catch(t){}}}return Hc(Gc(e),Hc.defaultChars+"%")}function Xw(t,e){if(!(this instanceof Xw)){return new Xw(t,e)}if(!e){if(!vd(t)){e=t||{};t="default"}}this.inline=new Um;this.block=new hm;this.core=new Cp;this.renderer=new tp;this.linkify=new aw;this.validateLink=Zw;this.normalizeLink=Vw;this.normalizeLinkText=Gw;this.utils=Kd;this.helpers=Ed({},Yd);this.options={};this.configure(t);if(e){this.set(e)}}Xw.prototype.set=function(t){Ed(this.options,t);return this};Xw.prototype.configure=function(t){const e=this;if(vd(t)){const e=t;t=Ww[e];if(!t){throw new Error('Wrong `markdown-it` preset "'+e+'", check name')}}if(!t){throw new Error("Wrong `markdown-it` preset, can't be empty")}if(t.options){e.set(t.options)}if(t.components){Object.keys(t.components).forEach((function(r){if(t.components[r].rules){e[r].ruler.enableOnly(t.components[r].rules)}if(t.components[r].rules2){e[r].ruler2.enableOnly(t.components[r].rules2)}}))}return this};Xw.prototype.enable=function(t,e){let r=[];if(!Array.isArray(t)){t=[t]}["core","block","inline"].forEach((function(e){r=r.concat(this[e].ruler.enable(t,true))}),this);r=r.concat(this.inline.ruler2.enable(t,true));const i=t.filter((function(t){return r.indexOf(t)<0}));if(i.length&&!e){throw new Error("MarkdownIt. Failed to enable unknown rule(s): "+i)}return this};Xw.prototype.disable=function(t,e){let r=[];if(!Array.isArray(t)){t=[t]}["core","block","inline"].forEach((function(e){r=r.concat(this[e].ruler.disable(t,true))}),this);r=r.concat(this.inline.ruler2.disable(t,true));const i=t.filter((function(t){return r.indexOf(t)<0}));if(i.length&&!e){throw new Error("MarkdownIt. Failed to disable unknown rule(s): "+i)}return this};Xw.prototype.use=function(t){const e=[this].concat(Array.prototype.slice.call(arguments,1));t.apply(t,e);return this};Xw.prototype.parse=function(t,e){if(typeof t!=="string"){throw new Error("Input data should be a String")}const r=new this.core.State(t,this,e);this.core.process(r);return r.tokens};Xw.prototype.render=function(t,e){e=e||{};return this.renderer.render(this.parse(t,e),this.options,e)};Xw.prototype.parseInline=function(t,e){const r=new this.core.State(t,this,e);r.inlineMode=true;this.core.process(r);return r.tokens};Xw.prototype.renderInline=function(t,e){e=e||{};return this.renderer.render(this.parseInline(t,e),this.options,e)};const Yw=new pr({nodes:{doc:{content:"block+"},paragraph:{content:"inline*",group:"block",parseDOM:[{tag:"p"}],toDOM(){return["p",0]}},blockquote:{content:"block+",group:"block",parseDOM:[{tag:"blockquote"}],toDOM(){return["blockquote",0]}},horizontal_rule:{group:"block",parseDOM:[{tag:"hr"}],toDOM(){return["div",["hr"]]}},heading:{attrs:{level:{default:1}},content:"(text | image)*",group:"block",defining:true,parseDOM:[{tag:"h1",attrs:{level:1}},{tag:"h2",attrs:{level:2}},{tag:"h3",attrs:{level:3}},{tag:"h4",attrs:{level:4}},{tag:"h5",attrs:{level:5}},{tag:"h6",attrs:{level:6}}],toDOM(t){return["h"+t.attrs.level,0]}},code_block:{content:"text*",group:"block",code:true,defining:true,marks:"",attrs:{params:{default:""}},parseDOM:[{tag:"pre",preserveWhitespace:"full",getAttrs:t=>({params:t.getAttribute("data-params")||""})}],toDOM(t){return["pre",t.attrs.params?{"data-params":t.attrs.params}:{},["code",0]]}},ordered_list:{content:"list_item+",group:"block",attrs:{order:{default:1},tight:{default:false}},parseDOM:[{tag:"ol",getAttrs(t){return{order:t.hasAttribute("start")?+t.getAttribute("start"):1,tight:t.hasAttribute("data-tight")}}}],toDOM(t){return["ol",{start:t.attrs.order==1?null:t.attrs.order,"data-tight":t.attrs.tight?"true":null},0]}},bullet_list:{content:"list_item+",group:"block",attrs:{tight:{default:false}},parseDOM:[{tag:"ul",getAttrs:t=>({tight:t.hasAttribute("data-tight")})}],toDOM(t){return["ul",{"data-tight":t.attrs.tight?"true":null},0]}},list_item:{content:"block+",defining:true,parseDOM:[{tag:"li"}],toDOM(){return["li",0]}},text:{group:"inline"},image:{inline:true,attrs:{src:{},alt:{default:null},title:{default:null}},group:"inline",draggable:true,parseDOM:[{tag:"img[src]",getAttrs(t){return{src:t.getAttribute("src"),title:t.getAttribute("title"),alt:t.getAttribute("alt")}}}],toDOM(t){return["img",t.attrs]}},hard_break:{inline:true,group:"inline",selectable:false,parseDOM:[{tag:"br"}],toDOM(){return["br"]}}},marks:{em:{parseDOM:[{tag:"i"},{tag:"em"},{style:"font-style=italic"},{style:"font-style=normal",clearMark:t=>t.type.name=="em"}],toDOM(){return["em"]}},strong:{parseDOM:[{tag:"strong"},{tag:"b",getAttrs:t=>t.style.fontWeight!="normal"&&null},{style:"font-weight=400",clearMark:t=>t.type.name=="strong"},{style:"font-weight",getAttrs:t=>/^(bold(er)?|[5-9]\d{2,})$/.test(t)&&null}],toDOM(){return["strong"]}},link:{attrs:{href:{},title:{default:null}},inclusive:false,parseDOM:[{tag:"a[href]",getAttrs(t){return{href:t.getAttribute("href"),title:t.getAttribute("title")}}}],toDOM(t){return["a",t.attrs]}},code:{parseDOM:[{tag:"code"}],toDOM(){return["code"]}}}});function Qw(t,e){if(t.isText&&e.isText&&ye.sameSet(t.marks,e.marks))return t.withText(t.text+e.text)}class tg{constructor(t,e){this.schema=t;this.tokenHandlers=e;this.stack=[{type:t.topNodeType,attrs:null,content:[],marks:ye.none}]}top(){return this.stack[this.stack.length-1]}push(t){if(this.stack.length)this.top().content.push(t)}addText(t){if(!t)return;let e=this.top(),r=e.content,i=r[r.length-1];let n=this.schema.text(t,e.marks),s;if(i&&(s=Qw(i,n)))r[r.length-1]=s;else r.push(n)}openMark(t){let e=this.top();e.marks=t.addToSet(e.marks)}closeMark(t){let e=this.top();e.marks=t.removeFromSet(e.marks)}parseTokens(t){for(let e=0;e<t.length;e++){let r=t[e];let i=this.tokenHandlers[r.type];if(!i)throw new Error("Token type `"+r.type+"` not supported by Markdown parser");i(this,r,t,e)}}addNode(t,e,r){let i=this.top();let n=t.createAndFill(e,r,i?i.marks:[]);if(!n)return null;this.push(n);return n}openNode(t,e){this.stack.push({type:t,attrs:e,content:[],marks:ye.none})}closeNode(){let t=this.stack.pop();return this.addNode(t.type,t.attrs,t.content)}}function eg(t,e,r,i){if(t.getAttrs)return t.getAttrs(e,r,i);else if(t.attrs instanceof Function)return t.attrs(e);else return t.attrs}function rg(t,e){return t.noCloseToken||e=="code_inline"||e=="code_block"||e=="fence"}function ig(t){return t[t.length-1]=="\n"?t.slice(0,t.length-1):t}function ng(){}function sg(t,e){let r=Object.create(null);for(let i in e){let n=e[i];if(n.block){let e=t.nodeType(n.block);if(rg(n,i)){r[i]=(t,r,i,s)=>{t.openNode(e,eg(n,r,i,s));t.addText(ig(r.content));t.closeNode()}}else{r[i+"_open"]=(t,r,i,s)=>t.openNode(e,eg(n,r,i,s));r[i+"_close"]=t=>t.closeNode()}}else if(n.node){let e=t.nodeType(n.node);r[i]=(t,r,i,s)=>t.addNode(e,eg(n,r,i,s))}else if(n.mark){let e=t.marks[n.mark];if(rg(n,i)){r[i]=(t,r,i,s)=>{t.openMark(e.create(eg(n,r,i,s)));t.addText(ig(r.content));t.closeMark(e)}}else{r[i+"_open"]=(t,r,i,s)=>t.openMark(e.create(eg(n,r,i,s)));r[i+"_close"]=t=>t.closeMark(e)}}else if(n.ignore){if(rg(n,i)){r[i]=ng}else{r[i+"_open"]=ng;r[i+"_close"]=ng}}else{throw new RangeError("Unrecognized parsing spec "+JSON.stringify(n))}}r.text=(t,e)=>t.addText(e.content);r.inline=(t,e)=>t.parseTokens(e.children);r.softbreak=r.softbreak||(t=>t.addText(" "));return r}class lg{constructor(t,e,r){this.schema=t;this.tokenizer=e;this.tokens=r;this.tokenHandlers=sg(t,r)}parse(t,e={}){let r=new tg(this.schema,this.tokenHandlers),i;r.parseTokens(this.tokenizer.parse(t,e));do{i=r.closeNode()}while(r.stack.length);return i||this.schema.topNodeType.createAndFill()}}function og(t,e){while(++e<t.length)if(t[e].type!="list_item_open")return t[e].hidden;return false}new lg(Yw,Xw("commonmark",{html:false}),{blockquote:{block:"blockquote"},paragraph:{block:"paragraph"},list_item:{block:"list_item"},bullet_list:{block:"bullet_list",getAttrs:(t,e,r)=>({tight:og(e,r)})},ordered_list:{block:"ordered_list",getAttrs:(t,e,r)=>({order:+t.attrGet("start")||1,tight:og(e,r)})},heading:{block:"heading",getAttrs:t=>({level:+t.tag.slice(1)})},code_block:{block:"code_block",noCloseToken:true},fence:{block:"code_block",getAttrs:t=>({params:t.info||""}),noCloseToken:true},hr:{node:"horizontal_rule"},image:{node:"image",getAttrs:t=>({src:t.attrGet("src"),title:t.attrGet("title")||null,alt:t.children[0]&&t.children[0].content||null})},hardbreak:{node:"hard_break"},em:{mark:"em"},strong:{mark:"strong"},link:{mark:"link",getAttrs:t=>({href:t.attrGet("href"),title:t.attrGet("title")||null})},code_inline:{mark:"code",noCloseToken:true}});const ug={open:"",close:"",mixable:true};class fg{constructor(t,e,r={}){this.nodes=t;this.marks=e;this.options=r}serialize(t,e={}){e=Object.assign({},this.options,e);let r=new dg(this.nodes,this.marks,e);r.renderContent(t);return r.out}}const hg=new fg({blockquote(t,e){t.wrapBlock("> ",null,e,(()=>t.renderContent(e)))},code_block(t,e){const r=e.textContent.match(/`{3,}/gm);const i=r?r.sort().slice(-1)[0]+"`":"```";t.write(i+(e.attrs.params||"")+"\n");t.text(e.textContent,false);t.write("\n");t.write(i);t.closeBlock(e)},heading(t,e){t.write(t.repeat("#",e.attrs.level)+" ");t.renderInline(e,false);t.closeBlock(e)},horizontal_rule(t,e){t.write(e.attrs.markup||"---");t.closeBlock(e)},bullet_list(t,e){t.renderList(e," ",(()=>(e.attrs.bullet||"*")+" "))},ordered_list(t,e){let r=e.attrs.order||1;let i=String(r+e.childCount-1).length;let n=t.repeat(" ",i+2);t.renderList(e,n,(e=>{let n=String(r+e);return t.repeat(" ",i-n.length)+n+". "}))},list_item(t,e){t.renderContent(e)},paragraph(t,e){t.renderInline(e);t.closeBlock(e)},image(t,e){t.write("]/g,"\\$&")+(e.attrs.title?' "'+e.attrs.title.replace(/"/g,'\\"')+'"':"")+")")},hard_break(t,e,r,i){for(let n=i+1;n<r.childCount;n++)if(r.child(n).type!=e.type){t.write("\\\n");return}},text(t,e){t.text(e.text,!t.inAutolink)}},{em:{open:"*",close:"*",mixable:true,expelEnclosingWhitespace:true},strong:{open:"**",close:"**",mixable:true,expelEnclosingWhitespace:true},link:{open(t,e,r,i){t.inAutolink=cg(e,r,i);return t.inAutolink?"<":"["},close(t,e,r,i){let{inAutolink:n}=t;t.inAutolink=undefined;return n?">":"]("+e.attrs.href.replace(/[\(\)"]/g,"\\$&")+(e.attrs.title?` "${e.attrs.title.replace(/"/g,'\\"')}"`:"")+")"},mixable:true},code:{open(t,e,r,i){return ag(r.child(i),-1)},close(t,e,r,i){return ag(r.child(i-1),1)},escape:false}});function ag(t,e){let r=/`+/g,i,n=0;if(t.isText)while(i=r.exec(t.text))n=Math.max(n,i[0].length);let s=n>0&&e>0?" `":"`";for(let t=0;t<n;t++)s+="`";if(n>0&&e<0)s+=" ";return s}function cg(t,e,r){if(t.attrs.title||!/^\w+:/.test(t.attrs.href))return false;let i=e.child(r);if(!i.isText||i.text!=t.attrs.href||i.marks[i.marks.length-1]!=t)return false;return r==e.childCount-1||!t.isInSet(e.child(r+1).marks)}class dg{constructor(t,e,r){this.nodes=t;this.marks=e;this.options=r;this.delim="";this.out="";this.closed=null;this.inAutolink=undefined;this.atBlockStart=false;this.inTightList=false;if(typeof this.options.tightLists=="undefined")this.options.tightLists=false;if(typeof this.options.hardBreakNodeName=="undefined")this.options.hardBreakNodeName="hard_break"}flushClose(t=2){if(this.closed){if(!this.atBlank())this.out+="\n";if(t>1){let e=this.delim;let r=/\s+$/.exec(e);if(r)e=e.slice(0,e.length-r[0].length);for(let r=1;r<t;r++)this.out+=e+"\n"}this.closed=null}}getMark(t){let e=this.marks[t];if(!e){if(this.options.strict!==false)throw new Error(`Mark type \`${t}\` not supported by Markdown renderer`);e=ug}return e}wrapBlock(t,e,r,i){let n=this.delim;this.write(e!=null?e:t);this.delim+=t;i();this.delim=n;this.closeBlock(r)}atBlank(){return/(^|\n)$/.test(this.out)}ensureNewLine(){if(!this.atBlank())this.out+="\n"}write(t){this.flushClose();if(this.delim&&this.atBlank())this.out+=this.delim;if(t)this.out+=t}closeBlock(t){this.closed=t}text(t,e=true){let r=t.split("\n");for(let t=0;t<r.length;t++){this.write();if(!e&&r[t][0]=="["&&/(^|[^\\])\!$/.test(this.out))this.out=this.out.slice(0,this.out.length-1)+"\\!";this.out+=e?this.esc(r[t],this.atBlockStart):r[t];if(t!=r.length-1)this.out+="\n"}}render(t,e,r){if(this.nodes[t.type.name]){this.nodes[t.type.name](this,t,e,r)}else{if(this.options.strict!==false){throw new Error("Token type `"+t.type.name+"` not supported by Markdown renderer")}else if(!t.type.isLeaf){if(t.type.inlineContent)this.renderInline(t);else this.renderContent(t);if(t.isBlock)this.closeBlock(t)}}}renderContent(t){t.forEach(((e,r,i)=>this.render(e,t,i)))}renderInline(t,e=true){this.atBlockStart=e;let r=[],i="";let n=(e,n,s)=>{let l=e?e.marks:[];if(e&&e.type.name===this.options.hardBreakNodeName)l=l.filter((e=>{if(s+1==t.childCount)return false;let r=t.child(s+1);return e.isInSet(r.marks)&&(!r.isText||/\S/.test(r.text))}));let o=i;i="";if(e&&e.isText&&l.some((t=>{let e=this.getMark(t.type.name);return e&&e.expelEnclosingWhitespace&&!t.isInSet(r)}))){let[t,i,n]=/^(\s*)(.*)$/m.exec(e.text);if(i){o+=i;e=n?e.withText(n):null;if(!e)l=r}}if(e&&e.isText&&l.some((e=>{let r=this.getMark(e.type.name);return r&&r.expelEnclosingWhitespace&&(s==t.childCount-1||!e.isInSet(t.child(s+1).marks))}))){let[t,n,s]=/^(.*?)(\s*)$/m.exec(e.text);if(s){i=s;e=n?e.withText(n):null;if(!e)l=r}}let u=l.length?l[l.length-1]:null;let f=u&&this.getMark(u.type.name).escape===false;let h=l.length-(f?1:0);t:for(let t=0;t<h;t++){let e=l[t];if(!this.getMark(e.type.name).mixable)break;for(let i=0;i<r.length;i++){let n=r[i];if(!this.getMark(n.type.name).mixable)break;if(e.eq(n)){if(t>i)l=l.slice(0,i).concat(e).concat(l.slice(i,t)).concat(l.slice(t+1,h));else if(i>t)l=l.slice(0,t).concat(l.slice(t+1,i)).concat(e).concat(l.slice(i,h));continue t}}}let a=0;while(a<Math.min(r.length,h)&&l[a].eq(r[a]))++a;while(a<r.length)this.text(this.markString(r.pop(),false,t,s),false);if(o)this.text(o);if(e){while(r.length<h){let e=l[r.length];r.push(e);this.text(this.markString(e,true,t,s),false);this.atBlockStart=false}if(f&&e.isText)this.text(this.markString(u,true,t,s)+e.text+this.markString(u,false,t,s+1),false);else this.render(e,t,s);this.atBlockStart=false}if((e===null||e===void 0?void 0:e.isText)&&e.nodeSize>0){this.atBlockStart=false}};t.forEach(n);n(null,0,t.childCount);this.atBlockStart=false}renderList(t,e,r){if(this.closed&&this.closed.type==t.type)this.flushClose(3);else if(this.inTightList)this.flushClose(1);let i=typeof t.attrs.tight!="undefined"?t.attrs.tight:this.options.tightLists;let n=this.inTightList;this.inTightList=i;t.forEach(((n,s,l)=>{if(l&&i)this.flushClose(1);this.wrapBlock(e,r(l),t,(()=>this.render(n,t,l)))}));this.inTightList=n}esc(t,e=false){t=t.replace(/[`*\\~\[\]_]/g,((e,r)=>e=="_"&&r>0&&r+1<t.length&&t[r-1].match(/\w/)&&t[r+1].match(/\w/)?e:"\\"+e));if(e)t=t.replace(/^(\+[ ]|[\-*>])/,"\\$&").replace(/^(\s*)(#{1,6})(\s|$)/,"$1\\$2$3").replace(/^(\s*\d+)\.\s/,"$1\\. ");if(this.options.escapeExtraCharacters)t=t.replace(this.options.escapeExtraCharacters,"\\$&");return t}quote(t){let e=t.indexOf('"')==-1?'""':t.indexOf("'")==-1?"''":"()";return e[0]+t+e[1]}repeat(t,e){let r="";for(let i=0;i<e;i++)r+=t;return r}markString(t,e,r,i){let n=this.getMark(t.type.name);let s=e?n.open:n.close;return typeof s=="string"?s:s(this,t,r,i)}getEnclosingWhitespace(t){return{leading:(t.match(/^(\s+)/)||[undefined])[0],trailing:(t.match(/(\s+)$/)||[undefined])[0]}}}const pg=t=>(e,r)=>{const i=`<${t.tagName}`+t.attributes.map((t=>` ${t}="${r.attrs[t]}"`)).join("")+">";const n=`</${t.tagName}>`;e.write(i);e.renderContent(r);e.write(n)};const mg=t=>{const e={};t.forEach((t=>{e[t.tagName]=pg(t)}));const r=Object.assign(Object.assign({},hg.nodes),e);const i=Object.assign(Object.assign({},hg.marks),{strikethrough:{open:"~~",close:"~~",mixable:true,expelEnclosingWhitespace:true}});return new fg(r,i)};class wg{constructor(t){this.parseAsHTML=t=>A(t,{whitelist:this.customNodes});this.serialize=t=>{if(t.dom.textContent===""){return""}else{return this.markdownSerializer.serialize(t.state.doc)}};this.markdownSerializer=mg(t);this.customNodes=t}}class gg{constructor(t){this.parseAsHTML=t=>C(t,this.customNodes);this.serialize=t=>{if(t.dom.textContent===""){return""}else{return t.dom.innerHTML}};this.customNodes=t}}const bg={parseDOM:[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration=line-through"}],toDOM:()=>["s",0]};const kg=new Mn("linkPlugin");const Dg=(t,e)=>{const{from:r,to:i}=t.state.selection;let n="";let s="";t.state.doc.nodesBetween(r,i,((t,e)=>{if(t.type.name!=="text"){return}const l=Math.max(0,r-e);const o=Math.min(t.text.length,i-e);n+=t.text.slice(l,o);t.marks.forEach((t=>{if(t.type.name==="link"){s=t.attrs.href}}))}));if(e){e(n,s)}};const vg=(t,e,r)=>{while(e>0){const i=t.nodeAt(e-1);if(!(i===null||i===void 0?void 0:i.isText)||!i.marks.some((t=>t.type.name===bc.Link&&t.attrs.href===r))){break}e--}return e};const yg=(t,e,r)=>{while(e<t.content.size){const i=t.nodeAt(e);if(!(i===null||i===void 0?void 0:i.isText)||!i.marks.some((t=>t.type.name===bc.Link&&t.attrs.href===r))){break}e++}return e};const Fg=(t,e)=>{const r=t.posAtCoords({left:e.clientX,top:e.clientY});const i=t.state.doc.nodeAt(r===null||r===void 0?void 0:r.pos);if(!i){return null}const n=i.marks.find((t=>t.type.name===bc.Link));if(!n){return null}const s=n.attrs.href;const l=vg(t.state.doc,r.pos,s);const o=yg(t.state.doc,r.pos,s);const u=t.state.doc.textBetween(l,o," ");return{href:s,text:u,from:l,to:o}};const Eg=(t,e)=>{const{href:r}=Fg(t,e);if(r){window.open(r,"_blank");return true}return false};const Mg=(t,e,r)=>{const i=new CustomEvent("open-editor-link-menu",{detail:{href:e,text:r},bubbles:true,composed:true});t.dom.dispatchEvent(i)};let xg=0;const Ag=200;let Cg;const Sg=(t,e)=>{const r=Date.now();if(r-xg<Ag){clearTimeout(Cg);xg=r;return false}xg=r;Cg=setTimeout((()=>{const r=Fg(t,e);if(r){const{href:e,text:i,from:n,to:s}=r;const l=t.state.tr.setSelection(nn.create(t.state.doc,n,s));t.dispatch(l);Mg(t,e,i)}}),Ag);return true};const Og=(t,e)=>{const r=e.clipboardData;if(!r){return false}const i=r.getData("text/plain");if(Oc(i)){$g(t,i);return true}return false};const $g=(t,e)=>{const{state:r,dispatch:i}=t;const{from:n,to:s}=r.selection;const l=nf.marks.link.create({href:e,title:e,target:Cc(e)?"_blank":null});const o=r.doc.textBetween(n,s," ")||e;const u=r.tr.insertText(o,n,s).addMark(n,n+o.length,l);i(u)};const _g=t=>new yn({key:kg,props:{handlePaste:(t,e)=>Og(t,e),handleDOMEvents:{mousedown:(t,e)=>{if((e.metaKey||e.ctrlKey)&&e.button===0){return Eg(t,e)}if(e.button!==vc.Right){return Sg(t,e)}return true},click:(t,e)=>{if(!(e.target instanceof HTMLElement)){return}const r=e.target.closest("a");if(r){e.preventDefault();e.stopPropagation()}}}},view:()=>({update:e=>{Dg(e,t)}})});const Bg=new Mn("imageRemoverPlugin");const Rg=()=>new yn({key:Bg,props:{handlePaste:(t,e,r)=>qg(t,e,r)}});const jg=t=>{if(t instanceof Le){if(t.type.name==="image"){return true}let e=false;t.content.forEach((t=>{if(jg(t)){e=true}}));return e}else if(t instanceof be){let e=false;t.forEach((t=>{if(jg(t)){e=true}}));return e}return false};const Ng=t=>{const e=[];t.forEach((t=>{if(!jg(t)){if(t.content.size>0){const r=Ng(t.content);const i=t.copy(r);e.push(i)}else{e.push(t)}}}));return be.fromArray(e)};const qg=(t,e,r)=>{const i=e.clipboardData;if(!i){return false}const n=new Ee(Ng(r.content),r.openStart,r.openEnd);if(n.content.childCount<r.content.childCount){const{state:e,dispatch:r}=t;const i=e.tr.replaceSelection(n);r(i);return true}return false};const Tg=new Mn("actionBarPlugin");const zg=(t,e,r)=>{const i={};t.forEach((t=>{const n=e.getCommand(t);i[t]=n&&n.active&&n.active(r.state)}));return i};const Ig=(t,e,r)=>new yn({key:Tg,state:{init:()=>({}),apply:(t,e)=>{const r=t.getMeta(Tg);return r?r:e}},view:()=>({update:i=>{const n=Tg.getState(i.state);const s=zg(t,e,i);if(!_(n,s)){const t=i.state.tr.setMeta(Tg,s);i.dispatch(t);r(s)}}})});const Pg=new Mn("actionBarInteractionPlugin");const Jg=(t,e)=>{const{state:r}=e;const i=r.selection;let n=r.tr;if(!i.empty){n.setSelection(i)}t(r,(t=>{n=t}));e.dispatch(n);e.focus()};const Lg=t=>new yn({key:Pg,props:{handleDOMEvents:{actionBarItemClick:(e,r)=>{r.preventDefault();r.stopPropagation();const{value:i}=r.detail;try{const r=t.getCommand(i);Jg(r,e)}catch(t){console.error(`Error executing command: ${t}`)}return true},saveLinkMenu:(e,r)=>{r.preventDefault();r.stopPropagation();const{type:i,link:n}=r.detail;if(i===bc.Link){try{const r=t.getCommand(i,n);Jg(r,e)}catch(t){console.error(`Error executing command: ${t}`)}}return true}}}});const Wg=t=>{const e={};t.attributes.forEach((t=>e[t]={}));const r=`${t.tagName}[${t.attributes.map((t=>t)).join("][")}]`;return{group:"inline",content:"(text* | inline*)",inline:true,atom:true,selectable:true,attrs:e,toDOM:e=>[t.tagName,e.attrs],parseDOM:[{tag:r,getAttrs:e=>{const r={};t.attributes.forEach((t=>r[t]=e.getAttribute(t)));return r}}]}};const Ug=(t,e,r,i)=>{const n=t.state.schema;return async s=>{const l=document.createElement("span");l.innerHTML=await e.parseAsHTML(s,n);const o=br.fromSchema(n).parse(l).content;i(t,r,o)}};const Hg=(t,e,r)=>({insert:Zg(t,r),insertHtml:Ug(t,e,r.position,Vg),stopTrigger:()=>Kg(t)});const Zg=(t,e)=>r=>{const i=t.state.schema;let n;try{n=Gg(r,i)}catch(t){console.error(t.message);return}const s=i.text(" ");const l=i.nodes.doc.create(null,[n,s]);Vg(t,e.position,l)};const Kg=t=>{const{state:e,dispatch:r}=t;const i=e.tr;i.setMeta("stopTrigger",true);r(i)};const Vg=(t,e,r)=>{const i=t.state;const n=i.selection.$from.pos;const s=t.dispatch;const l=i.tr.replaceWith(e,n,r);l.setMeta("stopTrigger",true);s(l)};const Gg=(t,e)=>{var r;if(typeof t==="string"){return e.text(t)}const i=t.node;if(typeof i==="string"){return e.text(i)}const n=Xg(i.tagName,e);const s=((r=t.children)!==null&&r!==void 0?r:[]).map((t=>Gg(t,e))).filter(Boolean);return n.create(i.attributes,s)};const Xg=(t,e)=>{const r=Object.values(e.nodes).find((e=>e.name===t));if(!r){throw new Error(`No custom element has been registered for node ${t}`)}return r};const Yg=(t,e,r,i)=>{const n={trigger:r.character,textEditor:Hg(t,e,r),value:i};return n};const Qg=(t,e,r,i,n)=>{const s=new CustomEvent(t,{detail:Yg(e,r,i,n),bubbles:true,composed:true});e.dom.dispatchEvent(s)};const tb=(t,e,r)=>(i,n,s,l)=>{if(!e.includes(l)){return false}const o=i.state.doc;const u=o.textBetween(n-1,n,"");if(/\s/.test(u)||u===""){const e={character:l,position:n};r(e);Qg("triggerStart",i,t,e,l)}return false};const eb=(t,e,r,i,n)=>{if(!e||e.position<1){return false}for(const s of t.steps){if(s instanceof si){const{from:t,to:l,slice:o}=s;if(t<=e.position&&l>=e.position){const t=o.content.textBetween(0,o.content.size,"");if(!t.includes(e.character)){r();Qg("triggerStop",n,i,e,"");return true}}}}return false};const rb=(t,e,r,i,n)=>{let s="";if(r>e.position){s=t.textBetween(e.position+1,r,"")}Qg("triggerChange",n,i,e,s);return s};const ib=(t,e,r,i)=>(n,s,l)=>{const o=e();if(!o){return}const u=eb(n[0],o,r,i,t());if(u){r();return}rb(l.doc,o,l.selection.from,i,t())};const nb=(t,e)=>{let r=null;let i=null;const n=()=>r;const s=()=>i;const l=()=>{i=null};const o=t=>{i=t};const u=tb(e,t,o);const f=ib(n,s,l,e);return new yn({key:new Mn("triggerPlugin"),view:t=>{r=t;return{}},state:{init:()=>({}),apply:t=>{if(t.getMeta("stopTrigger")){Qg("triggerStop",r,e,i,"");l()}return{}}},props:{handleTextInput:u},appendTransaction:f})};var sb;var lb;if(typeof WeakMap!="undefined"){let t=new WeakMap;sb=e=>t.get(e);lb=(e,r)=>{t.set(e,r);return r}}else{const t=[];const e=10;let r=0;sb=e=>{for(let r=0;r<t.length;r+=2)if(t[r]==e)return t[r+1]};lb=(i,n)=>{if(r==e)r=0;t[r++]=i;return t[r++]=n}}var ob=class{constructor(t,e,r,i){this.width=t;this.height=e;this.map=r;this.problems=i}findCell(t){for(let e=0;e<this.map.length;e++){const r=this.map[e];if(r!=t)continue;const i=e%this.width;const n=e/this.width|0;let s=i+1;let l=n+1;for(let t=1;s<this.width&&this.map[e+t]==r;t++){s++}for(let t=1;l<this.height&&this.map[e+this.width*t]==r;t++){l++}return{left:i,top:n,right:s,bottom:l}}throw new RangeError(`No cell with offset ${t} found`)}colCount(t){for(let e=0;e<this.map.length;e++){if(this.map[e]==t){return e%this.width}}throw new RangeError(`No cell with offset ${t} found`)}nextCell(t,e,r){const{left:i,right:n,top:s,bottom:l}=this.findCell(t);if(e=="horiz"){if(r<0?i==0:n==this.width)return null;return this.map[s*this.width+(r<0?i-1:n)]}else{if(r<0?s==0:l==this.height)return null;return this.map[i+this.width*(r<0?s-1:l)]}}rectBetween(t,e){const{left:r,right:i,top:n,bottom:s}=this.findCell(t);const{left:l,right:o,top:u,bottom:f}=this.findCell(e);return{left:Math.min(r,l),top:Math.min(n,u),right:Math.max(i,o),bottom:Math.max(s,f)}}cellsInRect(t){const e=[];const r={};for(let i=t.top;i<t.bottom;i++){for(let n=t.left;n<t.right;n++){const s=i*this.width+n;const l=this.map[s];if(r[l])continue;r[l]=true;if(n==t.left&&n&&this.map[s-1]==l||i==t.top&&i&&this.map[s-this.width]==l){continue}e.push(l)}}return e}positionAt(t,e,r){for(let i=0,n=0;;i++){const s=n+r.child(i).nodeSize;if(i==t){let r=e+t*this.width;const i=(t+1)*this.width;while(r<i&&this.map[r]<n)r++;return r==i?s-1:this.map[r]}n=s}}static get(t){return sb(t)||lb(t,ub(t))}};function ub(t){if(t.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+t.type.name);const e=fb(t),r=t.childCount;const i=[];let n=0;let s=null;const l=[];for(let t=0,n=e*r;t<n;t++)i[t]=0;for(let o=0,u=0;o<r;o++){const f=t.child(o);u++;for(let t=0;;t++){while(n<i.length&&i[n]!=0)n++;if(t==f.childCount)break;const h=f.child(t);const{colspan:a,rowspan:c,colwidth:d}=h.attrs;for(let t=0;t<c;t++){if(t+o>=r){(s||(s=[])).push({type:"overlong_rowspan",pos:u,n:c-t});break}const f=n+t*e;for(let t=0;t<a;t++){if(i[f+t]==0)i[f+t]=u;else(s||(s=[])).push({type:"collision",row:o,pos:u,n:a-t});const r=d&&d[t];if(r){const i=(f+t)%e*2,n=l[i];if(n==null||n!=r&&l[i+1]==1){l[i]=r;l[i+1]=1}else if(n==r){l[i+1]++}}}}n+=a;u+=h.nodeSize}const h=(o+1)*e;let a=0;while(n<h)if(i[n++]==0)a++;if(a)(s||(s=[])).push({type:"missing",row:o,n:a});u++}if(e===0||r===0)(s||(s=[])).push({type:"zero_sized"});const o=new ob(e,r,i,s);let u=false;for(let t=0;!u&&t<l.length;t+=2)if(l[t]!=null&&l[t+1]<r)u=true;if(u)hb(o,l,t);return o}function fb(t){let e=-1;let r=false;for(let i=0;i<t.childCount;i++){const n=t.child(i);let s=0;if(r)for(let e=0;e<i;e++){const r=t.child(e);for(let t=0;t<r.childCount;t++){const n=r.child(t);if(e+n.attrs.rowspan>i)s+=n.attrs.colspan}}for(let t=0;t<n.childCount;t++){const e=n.child(t);s+=e.attrs.colspan;if(e.attrs.rowspan>1)r=true}if(e==-1)e=s;else if(e!=s)e=Math.max(e,s)}return e}function hb(t,e,r){if(!t.problems)t.problems=[];const i={};for(let n=0;n<t.map.length;n++){const s=t.map[n];if(i[s])continue;i[s]=true;const l=r.nodeAt(s);if(!l){throw new RangeError(`No cell with offset ${s} found`)}let o=null;const u=l.attrs;for(let r=0;r<u.colspan;r++){const i=(n+r)%t.width;const s=e[i*2];if(s!=null&&(!u.colwidth||u.colwidth[r]!=s))(o||(o=ab(u)))[r]=s}if(o)t.problems.unshift({type:"colwidth mismatch",pos:s,colwidth:o})}}function ab(t){if(t.colwidth)return t.colwidth.slice();const e=[];for(let r=0;r<t.colspan;r++)e.push(0);return e}function cb(t,e){if(typeof t==="string"){return{}}const r=t.getAttribute("data-colwidth");const i=r&&/^\d+(,\d+)*$/.test(r)?r.split(",").map((t=>Number(t))):null;const n=Number(t.getAttribute("colspan")||1);const s={colspan:n,rowspan:Number(t.getAttribute("rowspan")||1),colwidth:i&&i.length==n?i:null};for(const r in e){const i=e[r].getFromDOM;const n=i&&i(t);if(n!=null){s[r]=n}}return s}function db(t,e){const r={};if(t.attrs.colspan!=1)r.colspan=t.attrs.colspan;if(t.attrs.rowspan!=1)r.rowspan=t.attrs.rowspan;if(t.attrs.colwidth)r["data-colwidth"]=t.attrs.colwidth.join(",");for(const i in e){const n=e[i].setDOMAttr;if(n)n(t.attrs[i],r)}return r}function pb(t){const e=t.cellAttributes||{};const r={colspan:{default:1},rowspan:{default:1},colwidth:{default:null}};for(const t in e)r[t]={default:e[t].default};return{table:{content:"table_row+",tableRole:"table",isolating:true,group:t.tableGroup,parseDOM:[{tag:"table"}],toDOM(){return["table",["tbody",0]]}},table_row:{content:"(table_cell | table_header)*",tableRole:"row",parseDOM:[{tag:"tr"}],toDOM(){return["tr",0]}},table_cell:{content:t.cellContent,attrs:r,tableRole:"cell",isolating:true,parseDOM:[{tag:"td",getAttrs:t=>cb(t,e)}],toDOM(t){return["td",db(t,e),0]}},table_header:{content:t.cellContent,attrs:r,tableRole:"header_cell",isolating:true,parseDOM:[{tag:"th",getAttrs:t=>cb(t,e)}],toDOM(t){return["th",db(t,e),0]}}}}function mb(t){let e=t.cached.tableNodeTypes;if(!e){e=t.cached.tableNodeTypes={};for(const r in t.nodes){const i=t.nodes[r],n=i.spec.tableRole;if(n)e[n]=i}}return e}var wb=new Mn("selectingCells");function gb(t){for(let e=t.depth-1;e>0;e--)if(t.node(e).type.spec.tableRole=="row")return t.node(0).resolve(t.before(e+1));return null}function bb(t){const e=t.selection.$head;for(let t=e.depth;t>0;t--)if(e.node(t).type.spec.tableRole=="row")return true;return false}function kb(t){const e=t.selection;if("$anchorCell"in e&&e.$anchorCell){return e.$anchorCell.pos>e.$headCell.pos?e.$anchorCell:e.$headCell}else if("node"in e&&e.node&&e.node.type.spec.tableRole=="cell"){return e.$anchor}const r=gb(e.$head)||Db(e.$head);if(r){return r}throw new RangeError(`No cell found around position ${e.head}`)}function Db(t){for(let e=t.nodeAfter,r=t.pos;e;e=e.firstChild,r++){const i=e.type.spec.tableRole;if(i=="cell"||i=="header_cell")return t.doc.resolve(r)}for(let e=t.nodeBefore,r=t.pos;e;e=e.lastChild,r--){const i=e.type.spec.tableRole;if(i=="cell"||i=="header_cell")return t.doc.resolve(r-e.nodeSize)}}function vb(t){return t.parent.type.spec.tableRole=="row"&&!!t.nodeAfter}function yb(t,e){return t.depth==e.depth&&t.pos>=e.start(-1)&&t.pos<=e.end(-1)}function Fb(t,e,r){const i=t.node(-1);const n=ob.get(i);const s=t.start(-1);const l=n.nextCell(t.pos-s,e,r);return l==null?null:t.node(0).resolve(s+l)}function Eb(t,e,r=1){const i={...t,colspan:t.colspan-r};if(i.colwidth){i.colwidth=i.colwidth.slice();i.colwidth.splice(e,r);if(!i.colwidth.some((t=>t>0)))i.colwidth=null}return i}var Mb=class t extends Qi{constructor(t,e=t){const r=t.node(-1);const i=ob.get(r);const n=t.start(-1);const s=i.rectBetween(t.pos-n,e.pos-n);const l=t.node(0);const o=i.cellsInRect(s).filter((t=>t!=e.pos-n));o.unshift(e.pos-n);const u=o.map((t=>{const e=r.nodeAt(t);if(!e){throw RangeError(`No cell with offset ${t} found`)}const i=n+t+1;return new tn(l.resolve(i),l.resolve(i+e.content.size))}));super(u[0].$from,u[0].$to,u);this.$anchorCell=t;this.$headCell=e}map(e,r){const i=e.resolve(r.map(this.$anchorCell.pos));const n=e.resolve(r.map(this.$headCell.pos));if(vb(i)&&vb(n)&&yb(i,n)){const e=this.$anchorCell.node(-1)!=i.node(-1);if(e&&this.isRowSelection())return t.rowSelection(i,n);else if(e&&this.isColSelection())return t.colSelection(i,n);else return new t(i,n)}return nn.between(i,n)}content(){const t=this.$anchorCell.node(-1);const e=ob.get(t);const r=this.$anchorCell.start(-1);const i=e.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r);const n={};const s=[];for(let r=i.top;r<i.bottom;r++){const l=[];for(let s=r*e.width+i.left,o=i.left;o<i.right;o++,s++){const r=e.map[s];if(n[r])continue;n[r]=true;const o=e.findCell(r);let u=t.nodeAt(r);if(!u){throw RangeError(`No cell with offset ${r} found`)}const f=i.left-o.left;const h=o.right-i.right;if(f>0||h>0){let t=u.attrs;if(f>0){t=Eb(t,0,f)}if(h>0){t=Eb(t,t.colspan-h,h)}if(o.left<i.left){u=u.type.createAndFill(t);if(!u){throw RangeError(`Could not create cell with attrs ${JSON.stringify(t)}`)}}else{u=u.type.create(t,u.content)}}if(o.top<i.top||o.bottom>i.bottom){const t={...u.attrs,rowspan:Math.min(o.bottom,i.bottom)-Math.max(o.top,i.top)};if(o.top<i.top){u=u.type.createAndFill(t)}else{u=u.type.create(t,u.content)}}l.push(u)}s.push(t.child(r).copy(be.from(l)))}const l=this.isColSelection()&&this.isRowSelection()?t:s;return new Ee(be.from(l),1,1)}replace(t,e=Ee.empty){const r=t.steps.length,i=this.ranges;for(let n=0;n<i.length;n++){const{$from:s,$to:l}=i[n],o=t.mapping.slice(r);t.replace(o.map(s.pos),o.map(l.pos),n?Ee.empty:e)}const n=Qi.findFrom(t.doc.resolve(t.mapping.slice(r).map(this.to)),-1);if(n)t.setSelection(n)}replaceWith(t,e){this.replace(t,new Ee(be.from(e),0,0))}forEachCell(t){const e=this.$anchorCell.node(-1);const r=ob.get(e);const i=this.$anchorCell.start(-1);const n=r.cellsInRect(r.rectBetween(this.$anchorCell.pos-i,this.$headCell.pos-i));for(let r=0;r<n.length;r++){t(e.nodeAt(n[r]),i+n[r])}}isColSelection(){const t=this.$anchorCell.index(-1);const e=this.$headCell.index(-1);if(Math.min(t,e)>0)return false;const r=t+this.$anchorCell.nodeAfter.attrs.rowspan;const i=e+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,i)==this.$headCell.node(-1).childCount}static colSelection(e,r=e){const i=e.node(-1);const n=ob.get(i);const s=e.start(-1);const l=n.findCell(e.pos-s);const o=n.findCell(r.pos-s);const u=e.node(0);if(l.top<=o.top){if(l.top>0)e=u.resolve(s+n.map[l.left]);if(o.bottom<n.height)r=u.resolve(s+n.map[n.width*(n.height-1)+o.right-1])}else{if(o.top>0)r=u.resolve(s+n.map[o.left]);if(l.bottom<n.height)e=u.resolve(s+n.map[n.width*(n.height-1)+l.right-1])}return new t(e,r)}isRowSelection(){const t=this.$anchorCell.node(-1);const e=ob.get(t);const r=this.$anchorCell.start(-1);const i=e.colCount(this.$anchorCell.pos-r);const n=e.colCount(this.$headCell.pos-r);if(Math.min(i,n)>0)return false;const s=i+this.$anchorCell.nodeAfter.attrs.colspan;const l=n+this.$headCell.nodeAfter.attrs.colspan;return Math.max(s,l)==e.width}eq(e){return e instanceof t&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,r=e){const i=e.node(-1);const n=ob.get(i);const s=e.start(-1);const l=n.findCell(e.pos-s);const o=n.findCell(r.pos-s);const u=e.node(0);if(l.left<=o.left){if(l.left>0)e=u.resolve(s+n.map[l.top*n.width]);if(o.right<n.width)r=u.resolve(s+n.map[n.width*(o.top+1)-1])}else{if(o.left>0)r=u.resolve(s+n.map[o.top*n.width]);if(l.right<n.width)e=u.resolve(s+n.map[n.width*(l.top+1)-1])}return new t(e,r)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,r){return new t(e.resolve(r.anchor),e.resolve(r.head))}static create(e,r,i=r){return new t(e.resolve(r),e.resolve(i))}getBookmark(){return new xb(this.$anchorCell.pos,this.$headCell.pos)}};Mb.prototype.visible=false;Qi.jsonID("cell",Mb);var xb=class t{constructor(t,e){this.anchor=t;this.head=e}map(e){return new t(e.map(this.anchor),e.map(this.head))}resolve(t){const e=t.resolve(this.anchor),r=t.resolve(this.head);if(e.parent.type.spec.tableRole=="row"&&r.parent.type.spec.tableRole=="row"&&e.index()<e.parent.childCount&&r.index()<r.parent.childCount&&yb(e,r))return new Mb(e,r);else return Qi.near(r,1)}};function Ab(t){if(!(t.selection instanceof Mb))return null;const e=[];t.selection.forEachCell(((t,r)=>{e.push(iu.node(r,r+t.nodeSize,{class:"selectedCell"}))}));return lu.create(t.doc,e)}function Cb({$from:t,$to:e}){if(t.pos==e.pos||t.pos<e.pos-6)return false;let r=t.pos;let i=e.pos;let n=t.depth;for(;n>=0;n--,r++)if(t.after(n+1)<t.end(n))break;for(let t=e.depth;t>=0;t--,i--)if(e.before(t+1)>e.start(t))break;return r==i&&/row|table/.test(t.node(n).type.spec.tableRole)}function Sb({$from:t,$to:e}){let r;let i;for(let e=t.depth;e>0;e--){const i=t.node(e);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){r=i;break}}for(let t=e.depth;t>0;t--){const r=e.node(t);if(r.type.spec.tableRole==="cell"||r.type.spec.tableRole==="header_cell"){i=r;break}}return r!==i&&e.parentOffset===0}function Ob(t,e,r){const i=(e||t).selection;const n=(e||t).doc;let s;let l;if(i instanceof ln&&(l=i.node.type.spec.tableRole)){if(l=="cell"||l=="header_cell"){s=Mb.create(n,i.from)}else if(l=="row"){const t=n.resolve(i.from+1);s=Mb.rowSelection(t,t)}else if(!r){const t=ob.get(i.node);const e=i.from+1;const r=e+t.map[t.width*t.height-1];s=Mb.create(n,e+1,r)}}else if(i instanceof nn&&Cb(i)){s=nn.create(n,i.from)}else if(i instanceof nn&&Sb(i)){s=nn.create(n,i.$from.start(),i.$from.end())}if(s)(e||(e=t.tr)).setSelection(s);return e}var $b=new Mn("fix-tables");function _b(t,e,r,i){const n=t.childCount,s=e.childCount;t:for(let l=0,o=0;l<s;l++){const s=e.child(l);for(let e=o,i=Math.min(n,l+3);e<i;e++){if(t.child(e)==s){o=e+1;r+=s.nodeSize;continue t}}i(s,r);if(o<n&&t.child(o).sameMarkup(s))_b(t.child(o),s,r+1,i);else s.nodesBetween(0,s.content.size,i,r+1);r+=s.nodeSize}}function Bb(t,e){let r;const i=(e,i)=>{if(e.type.spec.tableRole=="table")r=Rb(t,e,i,r)};if(!e)t.doc.descendants(i);else if(e.doc!=t.doc)_b(e.doc,t.doc,0,i);return r}function Rb(t,e,r,i){const n=ob.get(e);if(!n.problems)return i;if(!i)i=t.tr;const s=[];for(let t=0;t<n.height;t++)s.push(0);for(let t=0;t<n.problems.length;t++){const l=n.problems[t];if(l.type=="collision"){const t=e.nodeAt(l.pos);if(!t)continue;const n=t.attrs;for(let t=0;t<n.rowspan;t++)s[l.row+t]+=l.n;i.setNodeMarkup(i.mapping.map(r+1+l.pos),null,Eb(n,n.colspan-l.n,l.n))}else if(l.type=="missing"){s[l.row]+=l.n}else if(l.type=="overlong_rowspan"){const t=e.nodeAt(l.pos);if(!t)continue;i.setNodeMarkup(i.mapping.map(r+1+l.pos),null,{...t.attrs,rowspan:t.attrs.rowspan-l.n})}else if(l.type=="colwidth mismatch"){const t=e.nodeAt(l.pos);if(!t)continue;i.setNodeMarkup(i.mapping.map(r+1+l.pos),null,{...t.attrs,colwidth:l.colwidth})}else if(l.type=="zero_sized"){const t=i.mapping.map(r);i.delete(t,t+e.nodeSize)}}let l,o;for(let t=0;t<s.length;t++)if(s[t]){if(l==null)l=t;o=t}for(let u=0,f=r+1;u<n.height;u++){const r=e.child(u);const n=f+r.nodeSize;const h=s[u];if(h>0){let e="cell";if(r.firstChild){e=r.firstChild.type.spec.tableRole}const s=[];for(let r=0;r<h;r++){const r=mb(t.schema)[e].createAndFill();if(r)s.push(r)}const a=(u==0||l==u-1)&&o==u?f+1:n-1;i.insert(i.mapping.map(a),s)}f=n}return i.setMeta($b,{fixTables:true})}function jb(t,e){const r=t.selection;if(!(r instanceof Mb))return false;if(e){const i=t.tr;const n=mb(t.schema).cell.createAndFill().content;r.forEachCell(((t,e)=>{if(!t.content.eq(n))i.replace(i.mapping.map(e+1),i.mapping.map(e+t.nodeSize-1),new Ee(n,0,0))}));if(i.docChanged)e(i)}return true}function Nb(t){if(!t.size)return null;let{content:e,openStart:r,openEnd:i}=t;while(e.childCount==1&&(r>0&&i>0||e.child(0).type.spec.tableRole=="table")){r--;i--;e=e.child(0).content}const n=e.child(0);const s=n.type.spec.tableRole;const l=n.type.schema,o=[];if(s=="row"){for(let t=0;t<e.childCount;t++){let n=e.child(t).content;const s=t?0:Math.max(0,r-1);const u=t<e.childCount-1?0:Math.max(0,i-1);if(s||u)n=Tb(mb(l).row,new Ee(n,s,u)).content;o.push(n)}}else if(s=="cell"||s=="header_cell"){o.push(r||i?Tb(mb(l).row,new Ee(e,r,i)).content:e)}else{return null}return qb(l,o)}function qb(t,e){const r=[];for(let t=0;t<e.length;t++){const i=e[t];for(let e=i.childCount-1;e>=0;e--){const{rowspan:n,colspan:s}=i.child(e).attrs;for(let e=t;e<t+n;e++)r[e]=(r[e]||0)+s}}let i=0;for(let t=0;t<r.length;t++)i=Math.max(i,r[t]);for(let n=0;n<r.length;n++){if(n>=e.length)e.push(be.empty);if(r[n]<i){const s=mb(t).cell.createAndFill();const l=[];for(let t=r[n];t<i;t++){l.push(s)}e[n]=e[n].append(be.from(l))}}return{height:e.length,width:i,rows:e}}function Tb(t,e){const r=t.createAndFill();const i=new Xi(r).replace(0,r.content.size,e);return i.doc}function zb({width:t,height:e,rows:r},i,n){if(t!=i){const e=[];const n=[];for(let t=0;t<r.length;t++){const s=r[t],l=[];for(let r=e[t]||0,n=0;r<i;n++){let o=s.child(n%s.childCount);if(r+o.attrs.colspan>i)o=o.type.createChecked(Eb(o.attrs,o.attrs.colspan,r+o.attrs.colspan-i),o.content);l.push(o);r+=o.attrs.colspan;for(let r=1;r<o.attrs.rowspan;r++)e[t+r]=(e[t+r]||0)+o.attrs.colspan}n.push(be.from(l))}r=n;t=i}if(e!=n){const t=[];for(let i=0,s=0;i<n;i++,s++){const l=[],o=r[s%e];for(let t=0;t<o.childCount;t++){let e=o.child(t);if(i+e.attrs.rowspan>n)e=e.type.create({...e.attrs,rowspan:Math.max(1,n-e.attrs.rowspan)},e.content);l.push(e)}t.push(be.from(l))}r=t;e=n}return{width:t,height:e,rows:r}}function Ib(t,e,r,i,n,s,l){const o=t.doc.type.schema;const u=mb(o);let f;let h;if(n>e.width){for(let s=0,o=0;s<e.height;s++){const a=r.child(s);o+=a.nodeSize;const c=[];let d;if(a.lastChild==null||a.lastChild.type==u.cell)d=f||(f=u.cell.createAndFill());else d=h||(h=u.header_cell.createAndFill());for(let t=e.width;t<n;t++)c.push(d);t.insert(t.mapping.slice(l).map(o-1+i),c)}}if(s>e.height){const o=[];for(let t=0,i=(e.height-1)*e.width;t<Math.max(e.width,n);t++){const n=t>=e.width?false:r.nodeAt(e.map[i+t]).type==u.header_cell;o.push(n?h||(h=u.header_cell.createAndFill()):f||(f=u.cell.createAndFill()))}const a=u.row.create(null,be.from(o)),c=[];for(let t=e.height;t<s;t++)c.push(a);t.insert(t.mapping.slice(l).map(i+r.nodeSize-2),c)}return!!(f||h)}function Pb(t,e,r,i,n,s,l,o){if(l==0||l==e.height)return false;let u=false;for(let f=n;f<s;f++){const n=l*e.width+f,s=e.map[n];if(e.map[n-e.width]==s){u=true;const n=r.nodeAt(s);const{top:h,left:a}=e.findCell(s);t.setNodeMarkup(t.mapping.slice(o).map(s+i),null,{...n.attrs,rowspan:l-h});t.insert(t.mapping.slice(o).map(e.positionAt(l,a,r)),n.type.createAndFill({...n.attrs,rowspan:h+n.attrs.rowspan-l}));f+=n.attrs.colspan-1}}return u}function Jb(t,e,r,i,n,s,l,o){if(l==0||l==e.width)return false;let u=false;for(let f=n;f<s;f++){const n=f*e.width+l,s=e.map[n];if(e.map[n-1]==s){u=true;const n=r.nodeAt(s);const h=e.colCount(s);const a=t.mapping.slice(o).map(s+i);t.setNodeMarkup(a,null,Eb(n.attrs,l-h,n.attrs.colspan-(l-h)));t.insert(a+n.nodeSize,n.type.createAndFill(Eb(n.attrs,0,l-h)));f+=n.attrs.rowspan-1}}return u}function Lb(t,e,r,i,n){let s=r?t.doc.nodeAt(r-1):t.doc;if(!s){throw new Error("No table found")}let l=ob.get(s);const{top:o,left:u}=i;const f=u+n.width,h=o+n.height;const a=t.tr;let c=0;function d(){s=r?a.doc.nodeAt(r-1):a.doc;if(!s){throw new Error("No table found")}l=ob.get(s);c=a.mapping.maps.length}if(Ib(a,l,s,r,f,h,c))d();if(Pb(a,l,s,r,u,f,o,c))d();if(Pb(a,l,s,r,u,f,h,c))d();if(Jb(a,l,s,r,o,h,u,c))d();if(Jb(a,l,s,r,o,h,f,c))d();for(let t=o;t<h;t++){const e=l.positionAt(t,u,s),i=l.positionAt(t,f,s);a.replace(a.mapping.slice(c).map(e+r),a.mapping.slice(c).map(i+r),new Ee(n.rows[t-o],0,0))}d();a.setSelection(new Mb(a.doc.resolve(r+l.positionAt(o,u,s)),a.doc.resolve(r+l.positionAt(h-1,f-1,s))));e(a)}var Wb=_f({ArrowLeft:Hb("horiz",-1),ArrowRight:Hb("horiz",1),ArrowUp:Hb("vert",-1),ArrowDown:Hb("vert",1),"Shift-ArrowLeft":Zb("horiz",-1),"Shift-ArrowRight":Zb("horiz",1),"Shift-ArrowUp":Zb("vert",-1),"Shift-ArrowDown":Zb("vert",1),Backspace:jb,"Mod-Backspace":jb,Delete:jb,"Mod-Delete":jb});function Ub(t,e,r){if(r.eq(t.selection))return false;if(e)e(t.tr.setSelection(r).scrollIntoView());return true}function Hb(t,e){return(r,i,n)=>{if(!n)return false;const s=r.selection;if(s instanceof Mb){return Ub(r,i,Qi.near(s.$headCell,e))}if(t!="horiz"&&!s.empty)return false;const l=Xb(n,t,e);if(l==null)return false;if(t=="horiz"){return Ub(r,i,Qi.near(r.doc.resolve(s.head+e),e))}else{const n=r.doc.resolve(l);const s=Fb(n,t,e);let o;if(s)o=Qi.near(s,1);else if(e<0)o=Qi.near(r.doc.resolve(n.before(-1)),-1);else o=Qi.near(r.doc.resolve(n.after(-1)),1);return Ub(r,i,o)}}}function Zb(t,e){return(r,i,n)=>{if(!n)return false;const s=r.selection;let l;if(s instanceof Mb){l=s}else{const i=Xb(n,t,e);if(i==null)return false;l=new Mb(r.doc.resolve(i))}const o=Fb(l.$headCell,t,e);if(!o)return false;return Ub(r,i,new Mb(l.$anchorCell,o))}}function Kb(t,e){const r=t.state.doc,i=gb(r.resolve(e));if(!i)return false;t.dispatch(t.state.tr.setSelection(new Mb(i)));return true}function Vb(t,e,r){if(!bb(t.state))return false;let i=Nb(r);const n=t.state.selection;if(n instanceof Mb){if(!i)i={width:1,height:1,rows:[be.from(Tb(mb(t.state.schema).cell,r))]};const e=n.$anchorCell.node(-1);const s=n.$anchorCell.start(-1);const l=ob.get(e).rectBetween(n.$anchorCell.pos-s,n.$headCell.pos-s);i=zb(i,l.right-l.left,l.bottom-l.top);Lb(t.state,t.dispatch,s,l,i);return true}else if(i){const e=kb(t.state);const r=e.start(-1);Lb(t.state,t.dispatch,r,ob.get(e.node(-1)).findCell(e.pos-r),i);return true}else{return false}}function Gb(t,e){var r;if(e.ctrlKey||e.metaKey)return;const i=Yb(t,e.target);let n;if(e.shiftKey&&t.state.selection instanceof Mb){s(t.state.selection.$anchorCell,e);e.preventDefault()}else if(e.shiftKey&&i&&(n=gb(t.state.selection.$anchor))!=null&&((r=Qb(t,e))==null?void 0:r.pos)!=n.pos){s(n,e);e.preventDefault()}else if(!i){return}function s(e,r){let i=Qb(t,r);const n=wb.getState(t.state)==null;if(!i||!yb(e,i)){if(n)i=e;else return}const s=new Mb(e,i);if(n||!t.state.selection.eq(s)){const r=t.state.tr.setSelection(s);if(n)r.setMeta(wb,e.pos);t.dispatch(r)}}function l(){t.root.removeEventListener("mouseup",l);t.root.removeEventListener("dragstart",l);t.root.removeEventListener("mousemove",o);if(wb.getState(t.state)!=null)t.dispatch(t.state.tr.setMeta(wb,-1))}function o(r){const n=r;const o=wb.getState(t.state);let u;if(o!=null){u=t.state.doc.resolve(o)}else if(Yb(t,n.target)!=i){u=Qb(t,e);if(!u)return l()}if(u)s(u,n)}t.root.addEventListener("mouseup",l);t.root.addEventListener("dragstart",l);t.root.addEventListener("mousemove",o)}function Xb(t,e,r){if(!(t.state.selection instanceof nn))return null;const{$head:i}=t.state.selection;for(let n=i.depth-1;n>=0;n--){const s=i.node(n),l=r<0?i.index(n):i.indexAfter(n);if(l!=(r<0?0:s.childCount))return null;if(s.type.spec.tableRole=="cell"||s.type.spec.tableRole=="header_cell"){const s=i.before(n);const l=e=="vert"?r>0?"down":"up":r>0?"right":"left";return t.endOfTextblock(l)?s:null}}return null}function Yb(t,e){for(;e&&e!=t.dom;e=e.parentNode){if(e.nodeName=="TD"||e.nodeName=="TH"){return e}}return null}function Qb(t,e){const r=t.posAtCoords({left:e.clientX,top:e.clientY});if(!r)return null;return r?gb(t.state.doc.resolve(r.pos)):null}new Mn("tableColumnResizing");function tk({allowTableNodeSelection:t=false}={}){return new yn({key:wb,state:{init(){return null},apply(t,e){const r=t.getMeta(wb);if(r!=null)return r==-1?null:r;if(e==null||!t.docChanged)return e;const{deleted:i,pos:n}=t.mapping.mapResult(e);return i?null:n}},props:{decorations:Ab,handleDOMEvents:{mousedown:Gb},createSelectionBetween(t){return wb.getState(t.state)!=null?t.state.selection:null},handleTripleClick:Kb,handleKeyDown:Wb,handlePaste:Vb},appendTransaction(e,r,i){return Ob(i,Bb(i,r),t)}})}const ek=t=>{if(t){return[tk()]}return[]};const rk=t=>({default:null,getFromDOM:e=>e.style[t]||null,setDOMAttr:(e,r)=>{if(e){r.style=(r.style||"")+`${t}: ${e};`}}});const ik=()=>pb({tableGroup:"block",cellContent:"block+",cellAttributes:{background:rk("background-color"),color:rk("color")}});const nk='@charset "UTF-8";:host{--mdc-theme-primary:var(\n --lime-primary-color,\n rgb(var(--color-teal-default))\n );--mdc-theme-secondary:var(\n --lime-secondary-color,\n rgb(var(--contrast-1100))\n );--mdc-theme-on-primary:var(\n --lime-on-primary-color,\n rgb(var(--contrast-100))\n );--mdc-theme-on-secondary:var(\n --lime-on-secondary-color,\n rgb(var(--contrast-100))\n );--mdc-theme-text-disabled-on-background:var(\n --lime-text-disabled-on-background-color,\n rgba(var(--contrast-1700), 0.38)\n );--mdc-theme-text-primary-on-background:var(\n --lime-text-primary-on-background-color,\n rgba(var(--contrast-1700), 0.87)\n );--mdc-theme-text-secondary-on-background:var(\n --lime-text-secondary-on-background-color,\n rgba(var(--contrast-1700), 0.54)\n );--mdc-theme-error:var(\n --lime-error-background-color,\n rgb(var(--color-red-dark))\n );--lime-error-text-color:rgb(var(--color-red-darker));--mdc-theme-surface:var(\n --lime-surface-background-color,\n rgb(var(--contrast-100))\n );--mdc-theme-on-surface:var(\n --lime-on-surface-color,\n rgb(var(--contrast-1500))\n )}:host(limel-prosemirror-adapter){display:flex;flex-direction:column}:host(limel-prosemirror-adapter) .toolbar{order:1}:host(limel-prosemirror-adapter) div#editor{order:2;height:100%;flex-grow:1}:host(limel-prosemirror-adapter) div[contenteditable=true]{height:100%}*{box-sizing:border-box}:host(limel-prosemirror-adapter:hover) .toolbar,:host(limel-prosemirror-adapter:focus-within) .toolbar{will-change:grid-template-rows}:host(limel-prosemirror-adapter:hover) limel-action-bar,:host(limel-prosemirror-adapter:focus-within) limel-action-bar{will-change:opacity, padding}.ProseMirror-menubar-wrapper{display:grid;grid-template-rows:auto 1fr}.ProseMirror-textblock-dropdown{min-width:3em}.ProseMirror-tooltip .ProseMirror-menu{width:-webkit-fit-content;width:fit-content;white-space:pre}.toolbar{--action-bar-border-radius:0.25rem;border-radius:var(--action-bar-border-radius);flex-shrink:0;position:sticky;z-index:1;top:0;width:100%;display:grid;grid-template-rows:var(--limel-prosemirror-adapter-toolbar-grid-template-rows);transition-property:grid-template-rows;transition-duration:var(--limel-prosemirror-adapter-toolbar-grid-template-rows-transition-duration);transition-timing-function:var(--limel-prosemirror-adapter-toolbar-transition-timing-function);background-color:rgba(var(--contrast-200), 0.5);backdrop-filter:blur(0.5rem);-webkit-backdrop-filter:blur(0.5rem)}limel-action-bar{min-width:0;transition-property:padding, opacity;transition-duration:var(--limel-prosemirror-adapter-toolbar-grid-template-rows-transition-duration);transition-timing-function:var(--limel-prosemirror-adapter-toolbar-transition-timing-function);opacity:var(--limel-prosemirror-adapter-toolbar-opacity);padding:var(--limel-prosemirror-adapter-action-bar-padding-top-bottom, 0.125rem) 0.25rem;background-color:transparent;overflow:hidden}.ProseMirror{position:relative;word-wrap:break-word;white-space:pre-wrap;white-space:break-spaces;-webkit-font-variant-ligatures:none;font-variant-ligatures:none;font-feature-settings:"liga" 0;padding:var(--limel-text-editor-padding)}.ProseMirror [draggable][contenteditable=false]{user-select:text}.ProseMirror:focus-visible{outline:none}.ProseMirror-hideselection{caret-color:transparent}.ProseMirror-hideselection *::selection{background:transparent}.ProseMirror-hideselection *::-moz-selection{background:transparent}.ProseMirror-selectednode{outline:0.125rem solid rgb(var(--color-sky-light))}li.ProseMirror-selectednode{outline:none}li.ProseMirror-selectednode:after{content:"";position:absolute;left:-2rem;right:-0.125rem;top:-0.125rem;bottom:-0.125rem;border:0.125rem solid rgb(var(--color-sky-light));pointer-events:none}img.ProseMirror-separator{display:inline !important;border:none !important;margin:0 !important}limel-portal{width:25rem}blockquote{position:relative;font-weight:100;font-size:0.875rem;max-width:100%;line-height:1.4;margin:0;padding:0.5rem 1.25rem;border-radius:0.05rem 0.75rem;background-color:rgb(var(--contrast-300))}blockquote:before,blockquote:after{position:absolute;font-size:2.75rem;opacity:0.4}blockquote:before{content:"“";left:0;top:-0.75rem}blockquote:after{content:"”";right:0;bottom:-2rem}:host(limel-markdown.truncate-paragraphs) p{overflow:hidden;white-space:nowrap;text-overflow:ellipsis}p,li{font-size:0.875rem;word-break:break-word;hyphens:auto;-webkit-hyphens:auto}a{word-break:break-all}p{margin-top:0;margin-bottom:0.5rem}p:only-child{margin-bottom:0}a{transition:color 0.2s ease;color:var(--markdown-hyperlink-color, rgb(var(--color-blue-dark)));text-decoration:none}a:hover{color:var(--markdown-hyperlink-color--hovered, rgb(var(--color-blue-default)))}hr{margin:1.75rem 0 2rem 0;border-width:0;border-top:1px solid rgb(var(--contrast-500))}dl{display:grid;grid-template-columns:1fr 2fr;grid-template-rows:1fr;margin-bottom:2rem;border:1px solid rgb(var(--contrast-400));border-radius:0.375rem;background-color:rgb(var(--contrast-200))}dl dt,dl dd{padding:0.375rem 0.5rem;font-size:0.875rem;margin:0}dl dt:nth-of-type(even),dl dd:nth-of-type(even){background-color:rgb(var(--contrast-300))}dl dt:first-child{border-top-left-radius:0.375rem}dl dt:last-child{border-bottom-left-radius:0.375rem}dl dd:first-child{border-top-right-radius:0.375rem}dl dd:last-child{border-bottom-right-radius:0.375rem}h1{font-size:1.5rem}h2{font-size:1.25rem}h3{font-size:1.125rem}h4{font-size:1rem}h5{font-size:0.875rem}h6{font-size:0.75rem}h1,h2{margin-top:0.5rem;margin-bottom:0.5rem;letter-spacing:-0.03125rem;font-weight:500}h3,h4{margin-top:0.75rem;margin-bottom:0.25rem;font-weight:600}h5,h6{margin-top:0.5rem;margin-bottom:0.125rem;font-weight:600}h1,h2,h3,h4,h5,h6{word-break:break-word;hyphens:auto;-webkit-hyphens:auto}:not([contenteditable=true]) h1,:not([contenteditable=true]) h2,:not([contenteditable=true]) h3,:not([contenteditable=true]) h4,:not([contenteditable=true]) h5,:not([contenteditable=true]) h6{text-wrap:balance}[contenteditable=true] h1,[contenteditable=true] h2,[contenteditable=true] h3,[contenteditable=true] h4,[contenteditable=true] h5,[contenteditable=true] h6{text-wrap:initial}ul{list-style:none}ul li{position:relative;margin-left:0.75rem}ul li:before{content:"";position:absolute;left:-0.5rem;top:0.5rem;width:0.25rem;height:0.25rem;border-radius:50%;background-color:rgb(var(--contrast-700));display:block}ol{margin-top:0.25rem;padding-left:1rem}ul{margin-top:0.25rem;padding-left:0}ul ul,ul ol,ol ol,ol ul{margin-left:0}li{margin-bottom:0.25rem}code{font-family:ui-monospace, "Cascadia Code", "Source Code Pro", Menlo, Consolas, "DejaVu Sans Mono", monospace;font-size:0.8125rem;letter-spacing:-0.0125rem;color:rgb(var(--contrast-1300));-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none;display:inline-block;border-radius:0.25rem;padding:0.03125rem 0.25rem;background-color:rgb(var(--contrast-600))}pre>code{display:block;margin:0.5rem 0;padding:0.5rem 0.75rem;overflow:auto;white-space:pre-wrap}:host(limel-markdown:not(.no-table-styles)) table{table-layout:auto;min-width:100%;border-collapse:collapse;border-spacing:0;background:transparent;margin:0.75rem 0;border:1px solid rgb(var(--contrast-400))}:host(limel-markdown:not(.no-table-styles)) th,:host(limel-markdown:not(.no-table-styles)) td{text-align:left;vertical-align:top;transition:background-color 0.2s ease;font-size:0.875rem}:host(limel-markdown:not(.no-table-styles)) td{padding:0.5rem 0.375rem 0.75rem 0.375rem}:host(limel-markdown:not(.no-table-styles)) tr th{background-color:rgb(var(--contrast-400));padding:0.25rem 0.375rem;font-weight:normal}:host(limel-markdown:not(.no-table-styles)) tr th:only-child{text-align:center}:host(limel-markdown:not(.no-table-styles)) tbody tr:nth-child(odd) td{background-color:rgb(var(--contrast-200))}:host(limel-markdown:not(.no-table-styles)) tbody tr:hover td{background-color:rgb(var(--contrast-300))}kbd{font-family:ui-monospace, "Cascadia Code", "Source Code Pro", Menlo, Consolas, "DejaVu Sans Mono", monospace;font-weight:600;color:rgb(var(--contrast-1100));background-color:rgb(var(--contrast-200));white-space:pre;word-spacing:normal;word-break:normal;word-wrap:normal;line-height:normal;padding:0.125rem 0.5rem;margin:0 0.25rem;box-shadow:var(--button-shadow-normal), 0 0.03125rem 0.21875rem 0 rgba(var(--contrast-100), 0.5) inset;border-radius:0.125rem;border-style:solid;border-color:rgba(var(--contrast-600), 0.8);border-width:0 1px 0.125rem 1px}img{max-width:100%;border-radius:0.25rem}';const sk=300;const lk=class{constructor(r){t(this,r);this.change=e(this,"change",7);this.changeWaiting=false;this.suppressChangeEvent=false;this.getActionBarItems=()=>{this.actionBarItems=Jc().map(this.getTranslatedItem)};this.getTranslatedItem=t=>{const e=pe(t);if($(t)){const r=Lc[t.value];if(r){e.text=S.get(r,this.language)}}return e};this.updateActiveActionBarItems=t=>{const e=Jc().map((e=>{if($(e)){return Object.assign(Object.assign({},e),{selected:t[e.value]})}return e}));this.actionBarItems=e};this.handleTransaction=t=>{const e=this.view.state.apply(t);this.view.updateState(e);if(this.suppressChangeEvent||t.getMeta("pointer")){return}const r=this.contentConverter.serialize(this.view,this.schema);if(r===this.lastEmittedValue){return}this.lastEmittedValue=r;this.changeWaiting=true;this.changeEmitter(r)};this.handleActionBarItem=t=>{t.preventDefault();t.stopImmediatePropagation();const{value:e}=t.detail;if(e===bc.Link){this.isLinkMenuOpen=true;return}const r=new CustomEvent("actionBarItemClick",{detail:t.detail});this.view.dom.dispatchEvent(r)};this.handleCancelLinkMenu=t=>{t.preventDefault();t.stopPropagation();this.isLinkMenuOpen=false;this.link={text:"",href:"https://"}};this.handleSaveLinkMenu=()=>{this.isLinkMenuOpen=false;const t=new CustomEvent("saveLinkMenu",{detail:{type:bc.Link,link:this.link}});this.view.dom.dispatchEvent(t);this.link={href:"https://"}};this.handleLinkChange=t=>{this.link=t.detail};this.handleFocus=()=>{var t;if(!this.disabled){(t=this.view)===null||t===void 0?void 0:t.focus()}};this.handleNewLinkSelection=(t,e)=>{this.link.text=t;this.link.href=e||"https://"};this.handleOpenLinkMenu=t=>{t.stopImmediatePropagation();const{href:e,text:r}=t.detail;this.link={href:e,text:r};this.isLinkMenuOpen=true};this.changeEmitter=B((t=>{this.change.emit(t);this.changeWaiting=false}),sk);this.handleBlur=()=>{this.changeEmitter.flush()};this.contentType="markdown";this.value=undefined;this.language=undefined;this.disabled=false;this.customElements=[];this.triggerCharacters=[];this.view=undefined;this.actionBarItems=[];this.link={href:"https://"};this.isLinkMenuOpen=false;this.portalId=O()}watchValue(t){if(!this.view){return}if(this.changeWaiting){return}const e=this.contentConverter.serialize(this.view,this.schema);if(t===e){return}this.updateView(t)}componentWillLoad(){this.getActionBarItems();this.setupContentConverter()}componentDidLoad(){setTimeout((()=>{this.initializeTextEditor()}),0)}connectedCallback(){if(this.view){this.initializeTextEditor()}this.host.addEventListener("open-editor-link-menu",this.handleOpenLinkMenu)}disconnectedCallback(){var t,e,r;this.host.removeEventListener("open-editor-link-menu",this.handleOpenLinkMenu);(e=(t=this.view)===null||t===void 0?void 0:t.dom)===null||e===void 0?void 0:e.removeEventListener("blur",this.handleBlur);(r=this.view)===null||r===void 0?void 0:r.destroy()}render(){return r(i,{onFocus:this.handleFocus},r("div",{id:"editor"}),r("div",{class:"toolbar"},r("limel-action-bar",{ref:t=>this.actionBarElement=t,accessibleLabel:"Toolbar",actions:this.actionBarItems,onItemSelected:this.handleActionBarItem})),this.renderLinkMenu())}renderLinkMenu(){if(!this.isLinkMenuOpen){return}return r("limel-portal",{containerId:this.portalId,visible:this.isLinkMenuOpen,openDirection:"top",inheritParentWidth:true,anchor:this.actionBarElement},r("limel-text-editor-link-menu",{link:this.link,isOpen:this.isLinkMenuOpen,onLinkChange:this.handleLinkChange,onCancel:this.handleCancelLinkMenu,onSave:this.handleSaveLinkMenu}))}setupContentConverter(){if(this.contentType==="markdown"){this.contentConverter=new wg(this.customElements)}else if(this.contentType==="html"){this.contentConverter=new gg(this.customElements)}else{throw new Error(`Unsupported content type: ${this.contentType}. Only 'markdown' and 'html' are supported.`)}}async initializeTextEditor(){this.schema=this.initializeSchema();const t=await this.parseInitialContent();this.menuCommandFactory=new qc(this.schema);this.view=new zu(this.host.shadowRoot.querySelector("#editor"),{state:this.createEditorState(t),dispatchTransaction:this.handleTransaction});this.view.dom.addEventListener("blur",this.handleBlur);if(this.value){this.updateView(this.value)}}initializeSchema(){let t=nf.spec.nodes;this.customElements.forEach((e=>{const r=Wg(e);const i=e.tagName;t=t.append({[i]:r})}));t=cf(t,"paragraph block*","block");if(this.contentType==="html"){t=t.append(ik())}return new pr({nodes:t,marks:nf.spec.marks.append({strikethrough:bg})})}async parseInitialContent(){const t=document.createElement("div");if(this.value){t.innerHTML=await this.contentConverter.parseAsHTML(this.value,this.schema)}else{t.innerHTML="<p></p>"}return br.fromSchema(this.schema).parse(t)}createEditorState(t){return Dn.create({doc:t,plugins:[...gc({schema:this.schema,menuBar:false}),$f(this.menuCommandFactory.buildKeymap()),nb(this.triggerCharacters,this.contentConverter),_g(this.handleNewLinkSelection),Rg(),Ig(kc,this.menuCommandFactory,this.updateActiveActionBarItems),Lg(this.menuCommandFactory),...ek(this.contentType==="html")]})}async updateView(t){this.suppressChangeEvent=true;const e=await this.contentConverter.parseAsHTML(t,this.schema);const r=br.fromSchema(this.view.state.schema);const i=new window.DOMParser;const n=i.parseFromString(e,"text/html");const s=r.parse(n.body);const l=this.view.state.tr;l.replaceWith(0,l.doc.content.size,s.content);this.view.dispatch(l);this.suppressChangeEvent=false}static get delegatesFocus(){return true}get host(){return n(this)}static get watchers(){return{value:["watchValue"]}}};lk.style=nk;export{lk as limel_prosemirror_adapter};
|
|
2
|
-
//# sourceMappingURL=p-
|
|
1
|
+
import{r as t,c as e,h as r,H as i,g as n}from"./p-443111b3.js";import{k as s,g as l,U as o,a as u,i as f}from"./p-ea0310b8.js";import{a as h}from"./p-50bd0336.js";import{b as a}from"./p-5467ea06.js";import{k as c,a as d,g as p}from"./p-40df077c.js";import{i as m,r as w,S as g}from"./p-c93050d6.js";import{d as b,g as k,e as D,n as v,a as y}from"./p-28a23eac.js";import{g as F}from"./p-d4378e4c.js";import{i as E}from"./p-0b1af919.js";import{i as M}from"./p-858c6b82.js";import{d as x,m as A,s as C}from"./p-639f9320.js";import{t as S}from"./p-efd753ba.js";import{c as O}from"./p-96460db3.js";import{i as $}from"./p-91741e79.js";import{i as _}from"./p-cf019264.js";import{d as B}from"./p-18c97232.js";import"./p-eda23c05.js";import"./p-4c3358cb.js";import"./p-87a34aa6.js";import"./p-33375610.js";import"./p-5fdb83c9.js";import"./p-eab67c09.js";import"./p-365098fe.js";import"./p-d529bb7d.js";var R=Object.create;var j=function(){function t(){}return function(e){if(!m(e)){return{}}if(R){return R(e)}t.prototype=e;var r=new t;t.prototype=undefined;return r}}();function N(t,e){var r=-1,i=t.length;e||(e=Array(i));while(++r<i){e[r]=t[r]}return e}function q(t,e){var r=-1,i=t==null?0:t.length;while(++r<i){if(e(t[r],r,t)===false){break}}return t}function z(t,e,r,i){var n=!r;r||(r={});var s=-1,l=e.length;while(++s<l){var o=e[s];var u=i?i(r[o],t[o],o,r,t):undefined;if(u===undefined){u=t[o]}if(n){a(r,o,u)}else{h(r,o,u)}}return r}function T(t,e){return t&&z(e,s(e),t)}function I(t,e){return t&&z(e,c(e),t)}var P=typeof exports=="object"&&exports&&!exports.nodeType&&exports;var J=P&&typeof module=="object"&&module&&!module.nodeType&&module;var L=J&&J.exports===P;var W=L?w.Buffer:undefined,U=W?W.allocUnsafe:undefined;function H(t,e){if(e){return t.slice()}var r=t.length,i=U?U(r):new t.constructor(r);t.copy(i);return i}function Z(t,e){return z(t,l(t),e)}function K(t,e){return z(t,d(t),e)}var V=Object.prototype;var G=V.hasOwnProperty;function X(t){var e=t.length,r=new t.constructor(e);if(e&&typeof t[0]=="string"&&G.call(t,"index")){r.index=t.index;r.input=t.input}return r}function Y(t){var e=new t.constructor(t.byteLength);new o(e).set(new o(t));return e}function Q(t,e){var r=e?Y(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}var tt=/\w*$/;function et(t){var e=new t.constructor(t.source,tt.exec(t));e.lastIndex=t.lastIndex;return e}var rt=g?g.prototype:undefined,it=rt?rt.valueOf:undefined;function nt(t){return it?Object(it.call(t)):{}}function st(t,e){var r=e?Y(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}var lt="[object Boolean]",ot="[object Date]",ut="[object Map]",ft="[object Number]",ht="[object RegExp]",at="[object Set]",ct="[object String]",dt="[object Symbol]";var pt="[object ArrayBuffer]",mt="[object DataView]",wt="[object Float32Array]",gt="[object Float64Array]",bt="[object Int8Array]",kt="[object Int16Array]",Dt="[object Int32Array]",vt="[object Uint8Array]",yt="[object Uint8ClampedArray]",Ft="[object Uint16Array]",Et="[object Uint32Array]";function Mt(t,e,r){var i=t.constructor;switch(e){case pt:return Y(t);case lt:case ot:return new i(+t);case mt:return Q(t,r);case wt:case gt:case bt:case kt:case Dt:case vt:case yt:case Ft:case Et:return st(t,r);case ut:return new i;case ft:case ct:return new i(t);case ht:return et(t);case at:return new i;case dt:return nt(t)}}function xt(t){return typeof t.constructor=="function"&&!b(t)?j(F(t)):{}}var At="[object Map]";function Ct(t){return M(t)&&k(t)==At}var St=v&&v.isMap;var Ot=St?D(St):Ct;var $t="[object Set]";function _t(t){return M(t)&&k(t)==$t}var Bt=v&&v.isSet;var Rt=Bt?D(Bt):_t;var jt=1,Nt=2,qt=4;var zt="[object Arguments]",Tt="[object Array]",It="[object Boolean]",Pt="[object Date]",Jt="[object Error]",Lt="[object Function]",Wt="[object GeneratorFunction]",Ut="[object Map]",Ht="[object Number]",Zt="[object Object]",Kt="[object RegExp]",Vt="[object Set]",Gt="[object String]",Xt="[object Symbol]",Yt="[object WeakMap]";var Qt="[object ArrayBuffer]",te="[object DataView]",ee="[object Float32Array]",re="[object Float64Array]",ie="[object Int8Array]",ne="[object Int16Array]",se="[object Int32Array]",le="[object Uint8Array]",oe="[object Uint8ClampedArray]",ue="[object Uint16Array]",fe="[object Uint32Array]";var he={};he[zt]=he[Tt]=he[Qt]=he[te]=he[It]=he[Pt]=he[ee]=he[re]=he[ie]=he[ne]=he[se]=he[Ut]=he[Ht]=he[Zt]=he[Kt]=he[Vt]=he[Gt]=he[Xt]=he[le]=he[oe]=he[ue]=he[fe]=true;he[Jt]=he[Lt]=he[Yt]=false;function ae(t,e,r,i,n,l){var o,a=e&jt,d=e&Nt,w=e&qt;if(r){o=n?r(t,i,n,l):r(t)}if(o!==undefined){return o}if(!m(t)){return t}var g=E(t);if(g){o=X(t);if(!a){return N(t,o)}}else{var b=k(t),D=b==Lt||b==Wt;if(y(t)){return H(t,a)}if(b==Zt||b==zt||D&&!n){o=d||D?{}:xt(t);if(!a){return d?K(t,I(o,t)):Z(t,T(o,t))}}else{if(!he[b]){return n?t:{}}o=Mt(t,b,a)}}l||(l=new u);var v=l.get(t);if(v){return v}l.set(t,o);if(Rt(t)){t.forEach((function(i){o.add(ae(i,e,r,i,t,l))}))}else if(Ot(t)){t.forEach((function(i,n){o.set(n,ae(i,e,r,n,t,l))}))}var F=w?d?p:f:d?c:s;var M=g?undefined:F(t);q(M||t,(function(i,n){if(M){n=i;i=t[n]}h(o,n,ae(i,e,r,n,t,l))}));return o}var ce=1,de=4;function pe(t){return ae(t,ce|de)}function me(t){this.content=t}me.prototype={constructor:me,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,r){var i=r&&r!=t?this.remove(r):this;var n=i.find(t),s=i.content.slice();if(n==-1){s.push(r||t,e)}else{s[n+1]=e;if(r)s[n]=r}return new me(s)},remove:function(t){var e=this.find(t);if(e==-1)return this;var r=this.content.slice();r.splice(e,2);return new me(r)},addToStart:function(t,e){return new me([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var r=this.remove(t).content.slice();r.push(t,e);return new me(r)},addBefore:function(t,e,r){var i=this.remove(e),n=i.content.slice();var s=i.find(t);n.splice(s==-1?n.length:s,0,e,r);return new me(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=me.from(t);if(!t.size)return this;return new me(t.content.concat(this.subtract(t).content))},append:function(t){t=me.from(t);if(!t.size)return this;return new me(this.subtract(t).content.concat(t.content))},subtract:function(t){var e=this;t=me.from(t);for(var r=0;r<t.content.length;r+=2)e=e.remove(t.content[r]);return e},toObject:function(){var t={};this.forEach((function(e,r){t[e]=r}));return t},get size(){return this.content.length>>1}};me.from=function(t){if(t instanceof me)return t;var e=[];if(t)for(var r in t)e.push(r,t[r]);return new me(e)};function we(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){r+=n.nodeSize;continue}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=we(n.content,s.content,r+1);if(t!=null)return t}r+=n.nodeSize}}function ge(t,e,r,i){for(let n=t.childCount,s=e.childCount;;){if(n==0||s==0)return n==s?null:{a:r,b:i};let l=t.child(--n),o=e.child(--s),u=l.nodeSize;if(l==o){r-=u;i-=u;continue}if(!l.sameMarkup(o))return{a:r,b:i};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++;r--;i--}return{a:r,b:i}}if(l.content.size||o.content.size){let t=ge(l.content,o.content,r-1,i-1);if(t)return t}r-=u;i-=u}}class be{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,r,i=0,n){for(let s=0,l=0;l<e;s++){let o=this.content[s],u=l+o.nodeSize;if(u>t&&r(o,i+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),r,i+n)}l=u}}descendants(t){this.nodesBetween(0,this.size,t)}textBetween(t,e,r,i){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?"":i?typeof i==="function"?i(l):i:l.type.spec.leafText?l.type.spec.leafText(l):"";if(l.isBlock&&(l.isLeaf&&u||l.isTextblock)&&r){if(s)s=false;else n+=r}n+=u}),0);return 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;if(e.isText&&e.sameMarkup(r)){i[i.length-1]=e.withText(e.text+r.text);n=1}for(;n<t.content.length;n++)i.push(t.content[n]);return new be(i,this.size+t.size)}cut(t,e=this.size){if(t==0&&e==this.size)return this;let r=[],i=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))}r.push(l);i+=l.nodeSize}s=o}return new be(r,i)}cutByIndex(t,e){if(t==e)return be.empty;if(t==0&&e==this.content.length)return this;return new be(this.content.slice(t,e))}replaceChild(t,e){let r=this.content[t];if(r==e)return this;let i=this.content.slice();let n=this.size+e.nodeSize-r.nodeSize;i[t]=e;return new be(i,n)}addToStart(t){return new be([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new be(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,r=0;e<this.content.length;e++){let i=this.content[e];t(i,r,e);r+=i.nodeSize}}findDiffStart(t,e=0){return we(this,t,e)}findDiffEnd(t,e=this.size,r=t.size){return ge(this,t,e,r)}findIndex(t,e=-1){if(t==0)return De(0,t);if(t==this.size)return De(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=this.child(r),s=i+n.nodeSize;if(s>=t){if(s==t||e>0)return De(r+1,s);return De(r,i)}i=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 be.empty;if(!Array.isArray(e))throw new RangeError("Invalid input for Fragment.fromJSON");return new be(e.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return be.empty;let e,r=0;for(let i=0;i<t.length;i++){let n=t[i];r+=n.nodeSize;if(i&&n.isText&&t[i-1].sameMarkup(n)){if(!e)e=t.slice(0,i);e[e.length-1]=n.withText(e[e.length-1].text+n.text)}else if(e){e.push(n)}}return new be(e||t,r)}static from(t){if(!t)return be.empty;if(t instanceof be)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new be([t],t.nodeSize);throw new RangeError("Can not convert "+t+" to a Fragment"+(t.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}be.empty=new be([],0);const ke={index:0,offset:0};function De(t,e){ke.index=t;ke.offset=e;return ke}function ve(t,e){if(t===e)return true;if(!(t&&typeof t=="object")||!(e&&typeof e=="object"))return false;let r=Array.isArray(t);if(Array.isArray(e)!=r)return false;if(r){if(t.length!=e.length)return false;for(let r=0;r<t.length;r++)if(!ve(t[r],e[r]))return false}else{for(let r in t)if(!(r in e)||!ve(t[r],e[r]))return false;for(let r in e)if(!(r in t))return false}return true}class ye{constructor(t,e){this.type=t;this.attrs=e}addToSet(t){let e,r=false;for(let i=0;i<t.length;i++){let n=t[i];if(this.eq(n))return t;if(this.type.excludes(n.type)){if(!e)e=t.slice(0,i)}else if(n.type.excludes(this.type)){return t}else{if(!r&&n.type.rank>this.type.rank){if(!e)e=t.slice(0,i);e.push(this);r=true}if(e)e.push(n)}}if(!e)e=t.slice();if(!r)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&&ve(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);r.checkAttrs(i.attrs);return i}static sameSet(t,e){if(t==e)return true;if(t.length!=e.length)return false;for(let r=0;r<t.length;r++)if(!t[r].eq(e[r]))return false;return true}static setFrom(t){if(!t||Array.isArray(t)&&t.length==0)return ye.none;if(t instanceof ye)return[t];let e=t.slice();e.sort(((t,e)=>t.type.rank-e.type.rank));return e}}ye.none=[];class Fe extends Error{}class Ee{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=xe(this.content,t+this.openStart,e);return r&&new Ee(r,this.openStart,this.openEnd)}removeBetween(t,e){return new Ee(Me(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 Ee.empty;let r=e.openStart||0,i=e.openEnd||0;if(typeof r!="number"||typeof i!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new Ee(be.fromJSON(t,e.content),r,i)}static maxOpen(t,e=true){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 Ee(t,r,i)}}Ee.empty=new Ee(be.empty,0,0);function Me(t,e,r){let{index:i,offset:n}=t.findIndex(e),s=t.maybeChild(i);let{index:l,offset:o}=t.findIndex(r);if(n==e||s.isText){if(o!=r&&!t.child(l).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(r))}if(i!=l)throw new RangeError("Removing non-flat range");return t.replaceChild(i,s.copy(Me(s.content,e-n-1,r-n-1)))}function xe(t,e,r,i){let{index:n,offset:s}=t.findIndex(e),l=t.maybeChild(n);if(s==e||l.isText){if(i&&!i.canReplace(n,n,r))return null;return t.cut(0,e).append(r).append(t.cut(e))}let o=xe(l.content,e-s-1,r);return o&&t.replaceChild(n,l.copy(o))}function Ae(t,e,r){if(r.openStart>t.depth)throw new Fe("Inserted content deeper than insertion position");if(t.depth-r.openStart!=e.depth-r.openEnd)throw new Fe("Inconsistent open depths");return Ce(t,e,r,0)}function Ce(t,e,r,i){let n=t.index(i),s=t.node(i);if(n==e.index(i)&&i<t.depth-r.openStart){let l=Ce(t,e,r,i+1);return s.copy(s.content.replaceChild(n,l))}else if(!r.content.size){return Be(s,je(t,e,i))}else if(!r.openStart&&!r.openEnd&&t.depth==i&&e.depth==i){let i=t.parent,n=i.content;return Be(i,n.cut(0,t.parentOffset).append(r.content).append(n.cut(e.parentOffset)))}else{let{start:n,end:l}=Ne(r,t);return Be(s,Re(t,n,l,e,i))}}function Se(t,e){if(!e.type.compatibleContent(t.type))throw new Fe("Cannot join "+e.type.name+" onto "+t.type.name)}function Oe(t,e,r){let i=t.node(r);Se(i,e.node(r));return i}function $e(t,e){let r=e.length-1;if(r>=0&&t.isText&&t.sameMarkup(e[r]))e[r]=t.withText(e[r].text+t.text);else e.push(t)}function _e(t,e,r,i){let n=(e||t).node(r);let s=0,l=e?e.index(r):n.childCount;if(t){s=t.index(r);if(t.depth>r){s++}else if(t.textOffset){$e(t.nodeAfter,i);s++}}for(let t=s;t<l;t++)$e(n.child(t),i);if(e&&e.depth==r&&e.textOffset)$e(e.nodeBefore,i)}function Be(t,e){t.type.checkContent(e);return t.copy(e)}function Re(t,e,r,i,n){let s=t.depth>n&&Oe(t,e,n+1);let l=i.depth>n&&Oe(r,i,n+1);let o=[];_e(null,t,n,o);if(s&&l&&e.index(n)==r.index(n)){Se(s,l);$e(Be(s,Re(t,e,r,i,n+1)),o)}else{if(s)$e(Be(s,je(t,e,n+1)),o);_e(e,r,n,o);if(l)$e(Be(l,je(r,i,n+1)),o)}_e(i,null,n,o);return new be(o)}function je(t,e,r){let i=[];_e(null,t,r,i);if(t.depth>r){let n=Oe(t,e,r+1);$e(Be(n,je(t,e,r+1)),i)}_e(e,null,r,i);return new be(i)}function Ne(t,e){let r=e.depth-t.openStart,i=e.node(r);let n=i.copy(t.content);for(let t=r-1;t>=0;t--)n=e.node(t).copy(be.from(n));return{start:n.resolveNoCache(t.openStart+r),end:n.resolveNoCache(n.content.size-t.openEnd-r)}}class qe{constructor(t,e,r){this.pos=t;this.path=e;this.parentOffset=r;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 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);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 r=this.path[e*3],i=e==0?0:this.path[e*3-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(t.content.size==0)return ye.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++)if(n[s].type.spec.inclusive===false&&(!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++)if(r[n].type.spec.inclusive===false&&(!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 Pe(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=[];let i=0,n=e;for(let e=t;;){let{index:t,offset:s}=e.content.findIndex(n);let l=n-s;r.push(e,t,i+s);if(!l)break;e=e.child(t);if(e.isText)break;n=l-1;i+=s+1}return new qe(e,r,n)}static resolveCached(t,e){let r=Ie.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{Ie.set(t,r=new ze)}let i=r.elts[r.i]=qe.resolve(t,e);r.i=(r.i+1)%Te;return i}}class ze{constructor(){this.elts=[];this.i=0}}const Te=12,Ie=new WeakMap;class Pe{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 Je=Object.create(null);class Le{constructor(t,e,r,i=ye.none){this.type=t;this.attrs=e;this.marks=i;this.content=r||be.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&&ve(this.attrs,e||t.defaultAttrs||Je)&&ye.sameSet(this.marks,r||ye.none)}copy(t=null){if(t==this.content)return this;return new Le(this.type,this.attrs,t,this.marks)}mark(t){return t==this.marks?this:new Le(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,r=false){if(t==e)return Ee.empty;let i=this.resolve(t),n=this.resolve(e);let s=r?0:i.sharedDepth(e);let l=i.start(s),o=i.node(s);let u=o.content.cut(i.pos-l,n.pos-l);return new Ee(u,i.depth-s,n.depth-s)}replace(t,e,r){return Ae(this.resolve(t),this.resolve(e),r)}nodeAt(t){for(let e=this;;){let{index:r,offset:i}=e.content.findIndex(t);e=e.maybeChild(r);if(!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(t==0)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 qe.resolveCached(this,t)}resolveNoCache(t){return qe.resolve(this,t)}rangeHasMark(t,e,r){let i=false;if(e>t)this.nodesBetween(t,e,(t=>{if(r.isInSet(t.marks))i=true;return!i}));return 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;if(this.content.size)t+="("+this.content.toStringInner()+")";return Ue(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=be.empty,i=0,n=r.childCount){let s=this.contentMatchAt(t).matchFragment(r,i,n);let l=s&&s.matchFragment(this.content,e);if(!l||!l.validEnd)return false;for(let t=i;t<n;t++)if(!this.type.allowsMarks(r.child(t).marks))return false;return true}canReplaceWith(t,e,r,i){if(i&&!this.type.allowsMarks(i))return false;let n=this.contentMatchAt(t).matchType(r);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=ye.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(!ye.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 r=undefined;if(e.marks){if(!Array.isArray(e.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=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,r)}let i=be.fromJSON(t,e.content);let n=t.nodeType(e.type).create(e.attrs,i,r);n.type.checkAttrs(n.attrs);return n}}Le.prototype.text=undefined;class We extends Le{constructor(t,e,r,i){super(t,e,null,i);if(!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);return Ue(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 We(this.type,this.attrs,this.text,t)}withText(t){if(t==this.text)return this;return new We(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 Ue(t,e){for(let r=t.length-1;r>=0;r--)e=t[r].type.name+"("+e+")";return e}class He{constructor(t){this.validEnd=t;this.next=[];this.wrapCache=[]}static parse(t,e){let r=new Ze(t,e);if(r.next==null)return He.empty;let i=Ke(r);if(r.next)r.err("Unexpected trailing text");let n=nr(er(i));sr(n,r);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,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 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 r=0;r<t.next.length;r++)if(this.next[e].type==t.next[r].type)return true;return false}fillBefore(t,e=false,r=0){let i=[this];function n(s,l){let o=s.matchFragment(t,r);if(o&&(!e||o.validEnd))return be.from(l.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())&&i.indexOf(r)==-1){i.push(r);let t=n(r,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),r=[{match:this,type:null,via:null}];while(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:l}=n.next[t];if(!s.isLeaf&&!s.hasRequiredAttrs()&&!(s.name in e)&&(!i.type||l.validEnd)){r.push({match:s.contentMatch,type:s,via:i});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(r){t.push(r);for(let i=0;i<r.next.length;i++)if(t.indexOf(r.next[i].next)==-1)e(r.next[i].next)}e(this);return 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")}}He.empty=new He(true);class Ze{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 Ke(t){let e=[];do{e.push(Ve(t))}while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function Ve(t){let e=[];do{e.push(Ge(t))}while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function Ge(t){let e=tr(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=Ye(t,e);else break}return e}function Xe(t){if(/\D/.test(t.next))t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);t.pos++;return e}function Ye(t,e){let r=Xe(t),i=r;if(t.eat(",")){if(t.next!="}")i=Xe(t);else i=-1}if(!t.eat("}"))t.err("Unclosed braced range");return{type:"range",min:r,max:i,expr:e}}function Qe(t,e){let r=t.nodeTypes,i=r[e];if(i)return[i];let n=[];for(let t in r){let i=r[t];if(i.groups.indexOf(e)>-1)n.push(i)}if(n.length==0)t.err("No node type or group '"+e+"' found");return n}function tr(t){if(t.eat("(")){let e=Ke(t);if(!t.eat(")"))t.err("Missing closing paren");return e}else if(!/\W/.test(t.next)){let e=Qe(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 er(t){let e=[[]];n(s(t,0),r());return e;function r(){return e.push([])-1}function i(t,r,i){let n={term:i,to:r};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,r)=>t.concat(s(r,e))),[])}else if(t.type=="seq"){for(let i=0;;i++){let l=s(t.exprs[i],e);if(i==t.exprs.length-1)return l;n(l,e=r())}}else if(t.type=="star"){let l=r();i(e,l);n(s(t.expr,l),l);return[i(l)]}else if(t.type=="plus"){let l=r();n(s(t.expr,e),l);n(s(t.expr,l),l);return[i(l)]}else if(t.type=="opt"){return[i(e)].concat(s(t.expr,e))}else if(t.type=="range"){let l=e;for(let e=0;e<t.min;e++){let e=r();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=r();i(l,e);n(s(t.expr,l),e);l=e}}return[i(l)]}else if(t.type=="name"){return[i(e,undefined,t.value)]}else{throw new Error("Unknown expr type")}}}function rr(t,e){return e-t}function ir(t,e){let r=[];i(e);return r.sort(rr);function i(e){let n=t[e];if(n.length==1&&!n[0].term)return i(n[0].to);r.push(e);for(let t=0;t<n.length;t++){let{term:e,to:s}=n[t];if(!e&&r.indexOf(s)==-1)i(s)}}}function nr(t){let e=Object.create(null);return r(ir(t,0));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++)if(n[t][0]==e)i=n[t][1];ir(t,r).forEach((t=>{if(!i)n.push([e,i=[]]);if(i.indexOf(t)==-1)i.push(t)}))}))}));let s=e[i.join(",")]=new He(i.indexOf(t.length-1)>-1);for(let t=0;t<n.length;t++){let i=n[t][1].sort(rr);s.next.push({type:n[t][0],next:e[i.join(",")]||r(i)})}return s}}function sr(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:l}=t.next[e];s.push(r.name);if(n&&!(r.isText||r.hasRequiredAttrs()))n=false;if(i.indexOf(l)==-1)i.push(l)}if(n)e.err("Only non-generatable nodes ("+s.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function lr(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 or(t,e){let r=Object.create(null);for(let i in t){let n=e&&e[i];if(n===undefined){let e=t[i];if(e.hasDefault)n=e.default;else throw new RangeError("No value supplied for attribute "+i)}r[i]=n}return r}function ur(t,e,r,i){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];if(i.validate)i.validate(e[r])}}function fr(t,e){let r=Object.create(null);if(e)for(let i in e)r[i]=new cr(t,i,e[i]);return r}class hr{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=fr(t,r.attrs);this.defaultAttrs=lr(this.attrs);this.contentMatch=null;this.inlineContent=null;this.isBlock=!(r.inline||t=="text");this.isText=t=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==He.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 or(this.attrs,t)}create(t=null,e,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Le(this,this.computeAttrs(t),be.from(e),ye.setFrom(r))}createChecked(t=null,e,r){e=be.from(e);this.checkContent(e);return new Le(this,this.computeAttrs(t),e,ye.setFrom(r))}createAndFill(t=null,e,r){t=this.computeAttrs(t);e=be.from(e);if(e.size){let t=this.contentMatch.fillBefore(e);if(!t)return null;e=t.append(e)}let i=this.contentMatch.matchFragment(e);let n=i&&i.fillBefore(be.empty,true);if(!n)return null;return new Le(this,t,e.append(n),ye.setFrom(r))}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){ur(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 r=0;r<t.length;r++){if(!this.allowsMarkType(t[r].type)){if(!e)e=t.slice(0,r)}else if(e){e.push(t[r])}}return!e?t:e.length?e:ye.none}static compile(t,e){let r=Object.create(null);t.forEach(((t,i)=>r[t]=new hr(t,e,i)));let i=e.spec.topNode||"doc";if(!r[i])throw new RangeError("Schema is missing its top node type ('"+i+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let t in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}}function ar(t,e,r){let i=r.split("|");return r=>{let n=r===null?"null":typeof r;if(i.indexOf(n)<0)throw new RangeError(`Expected value of type ${i} for attribute ${e} on type ${t}, got ${n}`)}}class cr{constructor(t,e,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default");this.default=r.default;this.validate=typeof r.validate=="string"?ar(t,e,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class dr{constructor(t,e,r,i){this.name=t;this.rank=e;this.schema=r;this.spec=i;this.attrs=fr(t,i.attrs);this.excluded=null;let n=lr(this.attrs);this.instance=n?new ye(this,n):null}create(t=null){if(!t&&this.instance)return this.instance;return new ye(this,or(this.attrs,t))}static compile(t,e){let r=Object.create(null),i=0;t.forEach(((t,n)=>r[t]=new dr(t,i++,e,n)));return r}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){ur(this.attrs,t,"mark")}excludes(t){return this.excluded.indexOf(t)>-1}}class pr{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=me.from(t.nodes),e.marks=me.from(t.marks||{}),this.nodes=hr.compile(this.spec.nodes,this);this.marks=dr.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;e.contentMatch=r[i]||(r[i]=He.parse(i,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?mr(this,n.split(" ")):n==""||!e.inlineContent?[]:null}for(let t in this.marks){let e=this.marks[t],r=e.spec.excludes;e.excluded=r==null?[e]:r==""?[]:mr(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(typeof t=="string")t=this.nodeType(t);else if(!(t instanceof hr))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,r,i)}text(t,e){let r=this.nodes.text;return new We(r,r.defaultAttrs,t,ye.setFrom(e))}mark(t,e){if(typeof t=="string")t=this.marks[t];return t.create(e)}nodeFromJSON(t){return Le.fromJSON(this,t)}markFromJSON(t){return ye.fromJSON(this,t)}nodeType(t){let e=this.nodes[t];if(!e)throw new RangeError("Unknown node type: "+t);return e}}function mr(t,e){let r=[];for(let i=0;i<e.length;i++){let n=e[i],s=t.marks[n],l=s;if(s){r.push(s)}else{for(let e in t.marks){let i=t.marks[e];if(n=="_"||i.spec.group&&i.spec.group.split(" ").indexOf(n)>-1)r.push(l=i)}}if(!l)throw new SyntaxError("Unknown mark type: '"+e[i]+"'")}return r}function wr(t){return t.tag!=null}function gr(t){return t.style!=null}class br{constructor(t,e){this.schema=t;this.rules=e;this.tags=[];this.styles=[];let r=this.matchedStyles=[];e.forEach((t=>{if(wr(t)){this.tags.push(t)}else if(gr(t)){let e=/[^=]*/.exec(t.style)[0];if(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 false;let r=t.nodes[e.node];return r.contentMatch.matchType(r)}))}parse(t,e={}){let r=new Ar(this,e,false);r.addAll(t,ye.none,e.from,e.to);return r.finish()}parseSlice(t,e={}){let r=new Ar(this,e,true);r.addAll(t,ye.none,e.from,e.to);return Ee.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(Sr(t,r.tag)&&(r.namespace===undefined||t.namespaceURI==r.namespace)&&(!r.context||e.matchesContext(r.context))){if(r.getAttrs){let e=r.getAttrs(t);if(e===false)continue;r.attrs=e||undefined}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(s.indexOf(t)!=0||i.context&&!r.matchesContext(i.context)||s.length>t.length&&(s.charCodeAt(t.length)!=61||s.slice(t.length+1)!=e))continue;if(i.getAttrs){let t=i.getAttrs(e);if(t===false)continue;i.attrs=t||undefined}return i}}static schemaRules(t){let e=[];function r(t){let r=t.priority==null?50:t.priority,i=0;for(;i<e.length;i++){let t=e[i],n=t.priority==null?50:t.priority;if(n<r)break}e.splice(i,0,t)}for(let e in t.marks){let i=t.marks[e].spec.parseDOM;if(i)i.forEach((t=>{r(t=Or(t));if(!(t.mark||t.ignore||t.clearMark))t.mark=e}))}for(let e in t.nodes){let i=t.nodes[e].spec.parseDOM;if(i)i.forEach((t=>{r(t=Or(t));if(!(t.node||t.ignore||t.mark))t.node=e}))}return e}static fromSchema(t){return t.cached.domParser||(t.cached.domParser=new br(t,br.schemaRules(t)))}}const kr={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 Dr={head:true,noscript:true,object:true,script:true,style:true,title:true};const vr={ol:true,ul:true};const yr=1,Fr=2,Er=4;function Mr(t,e,r){if(e!=null)return(e?yr:0)|(e==="full"?Fr:0);return t&&t.whitespace=="pre"?yr|Fr:r&~Er}class xr{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=ye.none;this.match=n||(s&Er?null:t.contentMatch)}findWrapping(t){if(!this.match){if(!this.type)return[];let e=this.type.contentMatch.fillBefore(be.from(t));if(e){this.match=this.type.contentMatch.matchFragment(e)}else{let e=this.type.contentMatch,r;if(r=e.findWrapping(t.type)){this.match=e;return r}else{return null}}}return this.match.findWrapping(t.type)}finish(t){if(!(this.options&yr)){let t=this.content[this.content.length-1],e;if(t&&t.isText&&(e=/[ \t\r\n\u000c]+$/.exec(t.text))){let r=t;if(t.text.length==e[0].length)this.content.pop();else this.content[this.content.length-1]=r.withText(r.text.slice(0,r.text.length-e[0].length))}}let e=be.from(this.content);if(!t&&this.match)e=e.append(this.match.fillBefore(be.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&&!kr.hasOwnProperty(t.parentNode.nodeName.toLowerCase())}}class Ar{constructor(t,e,r){this.parser=t;this.options=e;this.isOpen=r;this.open=0;let i=e.topNode,n;let s=Mr(null,e.preserveWhitespace,0)|(r?Er:0);if(i)n=new xr(i.type,i.attrs,ye.none,true,e.topMatch||i.type.contentMatch,s);else if(r)n=new xr(null,null,ye.none,true,null,s);else n=new xr(t.schema.topNodeType,null,ye.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 r=t.nodeValue;let i=this.top;if(i.options&Fr||i.inlineContext(t)||/[^ \t\r\n\u000c]/.test(r)){if(!(i.options&yr)){r=r.replace(/[ \t\r\n\u000c]+/g," ");if(/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let e=i.content[i.content.length-1];let n=t.previousSibling;if(!e||n&&n.nodeName=="BR"||e.isText&&/[ \t\r\n\u000c]$/.test(e.text))r=r.slice(1)}}else if(!(i.options&Fr)){r=r.replace(/\r?\n|\r/g," ")}else{r=r.replace(/\r\n?/g,"\n")}if(r)this.insertNode(this.parser.schema.text(r),e);this.findInText(t)}else{this.findInside(t)}}addElement(t,e,r){let i=t.nodeName.toLowerCase(),n;if(vr.hasOwnProperty(i)&&this.parser.normalizeLists)Cr(t);let s=this.options.ruleFromNode&&this.options.ruleFromNode(t)||(n=this.parser.matchTag(t,this,r));if(s?s.ignore:Dr.hasOwnProperty(i)){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 r,n=this.top,l=this.needsBlock;if(kr.hasOwnProperty(i)){if(n.content.length&&n.content[0].isInline&&this.open){this.open--;n=this.top}r=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(r)this.sync(n);this.needsBlock=l}else{let r=this.readStyles(t,e);if(r)this.addElementByRule(t,s,r,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 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=undefined;;){let r=this.parser.matchStyle(i,n,this,t);if(!r)break;if(r.ignore)return null;if(r.clearMark)e=e.filter((t=>!r.clearMark(t)));else e=e.concat(this.parser.schema.marks[r.mark].create(r.attrs));if(r.consuming===false)t=r;else break}}return e}addElementByRule(t,e,r,i){let n,s;if(e.node){s=this.parser.schema.nodes[e.node];if(!s.isLeaf){let t=this.enter(s,e.attrs||null,r,e.preserveWhitespace);if(t){n=true;r=t}}else if(!this.insertNode(s.create(e.attrs),r)){this.leafFallback(t,r)}}else{let t=this.parser.schema.marks[e.mark];r=r.concat(t.create(e.attrs))}let l=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;if(typeof e.contentElement=="string")i=t.querySelector(e.contentElement);else if(typeof e.contentElement=="function")i=e.contentElement(t);else if(e.contentElement)i=e.contentElement;this.findAround(t,i,true);this.addAll(i,r)}if(n&&this.sync(l))this.open--}addAll(t,e,r,i){let n=r||0;for(let s=r?t.childNodes[r]:t.firstChild,l=i==null?null:t.childNodes[i];s!=l;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];let s=n.findWrapping(t);if(s&&(!r||r.length>s.length)){r=s;i=n;if(!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,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 r=this.findPlace(t,e);if(r){this.closeExtra();let e=this.top;if(e.match)e.match=e.match.matchType(t.type);let i=ye.none;for(let n of r.concat(t.marks))if(e.type?e.type.allowsMarkType(n.type):$r(n.type,t.type))i=n.addToSet(i);e.content.push(t.mark(i));return true}return false}enter(t,e,r,i){let n=this.findPlace(t.create(e),r);if(n)n=this.enterInner(t,e,r,true,i);return n}enterInner(t,e,r,i=false,n){this.closeExtra();let s=this.top;s.match=s.match&&s.match.matchType(t);let l=Mr(t,n,s.options);if(s.options&Er&&s.content.length==0)l|=Er;let o=ye.none;r=r.filter((e=>{if(s.type?s.type.allowsMarkType(e.type):$r(e.type,t)){o=e.addToSet(o);return false}return true}));this.nodes.push(new xr(t,e,o,i,null,l));this.open++;return r}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 r=this.nodes[e].content;for(let e=r.length-1;e>=0;e--)t+=r[e].nodeSize;if(e)t++}return t}findAtPoint(t,e){if(this.find)for(let r=0;r<this.find.length;r++){if(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++){if(this.find[e].pos==null&&t.nodeType==1&&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++){if(this.find[i].pos==null&&t.nodeType==1&&t.contains(this.find[i].node)){let t=e.compareDocumentPosition(this.find[i].node);if(t&(r?2:4))this.find[i].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 r=this.options.context;let i=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type);let n=-(r?r.depth+1:0)+(i?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&&i?this.nodes[l].type:r&&l>=n?r.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 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 Cr(t){for(let e=t.firstChild,r=null;e;e=e.nextSibling){let t=e.nodeType==1?e.nodeName.toLowerCase():null;if(t&&vr.hasOwnProperty(t)&&r){r.appendChild(e);e=r}else if(t=="li"){r=e}else if(t){r=null}}}function Sr(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function Or(t){let e={};for(let r in t)e[r]=t[r];return e}function $r(t,e){let r=e.schema.nodes;for(let i in r){let n=r[i];if(!n.allowsMarkType(t))continue;let s=[],l=t=>{s.push(t);for(let r=0;r<t.edgeCount;r++){let{type:i,next:n}=t.edge(r);if(i==e)return true;if(s.indexOf(n)<0&&l(n))return true}};if(l(n.contentMatch))return true}}class _r{constructor(t,e){this.nodes=t;this.marks=e}serializeFragment(t,e={},r){if(!r)r=Rr(e).createDocumentFragment();let i=r,n=[];t.forEach((t=>{if(n.length||t.marks.length){let r=0,s=0;while(r<n.length&&s<t.marks.length){let e=t.marks[s];if(!this.marks[e.type.name]){s++;continue}if(!e.eq(n[r][0])||e.type.spec.spanning===false)break;r++;s++}while(r<n.length)i=n.pop()[1];while(s<t.marks.length){let r=t.marks[s++];let l=this.serializeMark(r,t.isInline,e);if(l){n.push([r,i]);i.appendChild(l.dom);i=l.contentDOM||l.dom}}}i.appendChild(this.serializeNodeInner(t,e))}));return r}serializeNodeInner(t,e){let{dom:r,contentDOM:i}=zr(Rr(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);if(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&&zr(Rr(r),i(t,e),null,t.attrs)}static renderSpec(t,e,r=null,i){return zr(t,e,r,i)}static fromSchema(t){return t.cached.domSerializer||(t.cached.domSerializer=new _r(this.nodesFromSchema(t),this.marksFromSchema(t)))}static nodesFromSchema(t){let e=Br(t.nodes);if(!e.text)e.text=t=>t.text;return e}static marksFromSchema(t){return Br(t.marks)}}function Br(t){let e={};for(let r in t){let i=t[r].spec.toDOM;if(i)e[r]=i}return e}function Rr(t){return t.document||window.document}const jr=new WeakMap;function Nr(t){let e=jr.get(t);if(e===undefined)jr.set(t,e=qr(t));return e}function qr(t){let e=null;function r(t){if(t&&typeof t=="object"){if(Array.isArray(t)){if(typeof t[0]=="string"){if(!e)e=[];e.push(t)}else{for(let e=0;e<t.length;e++)r(t[e])}}else{for(let e in t)r(t[e])}}}r(t);return e}function zr(t,e,r,i){if(typeof e=="string")return{dom:t.createTextNode(e)};if(e.nodeType!=null)return{dom:e};if(e.dom&&e.dom.nodeType!=null)return e;let n=e[0],s;if(typeof n!="string")throw new RangeError("Invalid array passed to renderSpec");if(i&&(s=Nr(i))&&s.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 l=n.indexOf(" ");if(l>0){r=n.slice(0,l);n=n.slice(l+1)}let o;let u=r?t.createElementNS(r,n):t.createElement(n);let f=e[1],h=1;if(f&&typeof f=="object"&&f.nodeType==null&&!Array.isArray(f)){h=2;for(let t in f)if(f[t]!=null){let e=t.indexOf(" ");if(e>0)u.setAttributeNS(t.slice(0,e),t.slice(e+1),f[t]);else u.setAttribute(t,f[t])}}for(let n=h;n<e.length;n++){let s=e[n];if(s===0){if(n<e.length-1||n>h)throw new RangeError("Content hole must be the only child of its parent node");return{dom:u,contentDOM:u}}else{let{dom:e,contentDOM:n}=zr(t,s,r,i);u.appendChild(e);if(n){if(o)throw new RangeError("Multiple content holes");o=n}}}return{dom:u,contentDOM:o}}const Tr=65535;const Ir=Math.pow(2,16);function Pr(t,e){return t+e*Ir}function Jr(t){return t&Tr}function Lr(t){return(t-(t&Tr))/Ir}const Wr=1,Ur=2,Hr=4,Zr=8;class Kr{constructor(t,e,r){this.pos=t;this.delInfo=e;this.recover=r}get deleted(){return(this.delInfo&Zr)>0}get deletedBefore(){return(this.delInfo&(Wr|Hr))>0}get deletedAfter(){return(this.delInfo&(Ur|Hr))>0}get deletedAcross(){return(this.delInfo&Hr)>0}}class Vr{constructor(t,e=false){this.ranges=t;this.inverted=e;if(!t.length&&Vr.empty)return Vr.empty}recover(t){let e=0,r=Jr(t);if(!this.inverted)for(let t=0;t<r;t++)e+=this.ranges[t*3+2]-this.ranges[t*3+1];return this.ranges[r*3]+e+Lr(t)}mapResult(t,e=1){return this._map(t,e,false)}map(t,e=1){return this._map(t,e,true)}_map(t,e,r){let i=0,n=this.inverted?2:1,s=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let o=this.ranges[l]-(this.inverted?i:0);if(o>t)break;let u=this.ranges[l+n],f=this.ranges[l+s],h=o+u;if(t<=h){let n=!u?e:t==o?-1:t==h?1:e;let s=o+i+(n<0?0:f);if(r)return s;let a=t==(e<0?o:h)?null:Pr(l/3,t-o);let c=t==o?Ur:t==h?Wr:Hr;if(e<0?t!=o:t!=h)c|=Zr;return new Kr(s,c,a)}i+=f-u}return r?t+i:new Kr(t+i,0,null)}touches(t,e){let r=0,i=Jr(e);let n=this.inverted?2:1,s=this.inverted?1:2;for(let e=0;e<this.ranges.length;e+=3){let l=this.ranges[e]-(this.inverted?r:0);if(l>t)break;let o=this.ranges[e+n],u=l+o;if(t<=u&&e==i*3)return true;r+=this.ranges[e+s]-o}return false}forEach(t){let e=this.inverted?2:1,r=this.inverted?1:2;for(let i=0,n=0;i<this.ranges.length;i+=3){let s=this.ranges[i],l=s-(this.inverted?n:0),o=s+(this.inverted?0:n);let u=this.ranges[i+e],f=this.ranges[i+r];t(l,l+u,o,o+f);n+=f-u}}invert(){return new Vr(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(t){return t==0?Vr.empty:new Vr(t<0?[0,-t,0]:[0,0,t])}}Vr.empty=new Vr([]);class Gr{constructor(t=[],e,r=0,i=t.length){this.maps=t;this.mirror=e;this.from=r;this.to=i}slice(t=0,e=this.maps.length){return new Gr(this.maps,this.mirror,t,e)}copy(){return new Gr(this.maps.slice(),this.mirror&&this.mirror.slice(),this.from,this.to)}appendMap(t,e){this.to=this.maps.push(t);if(e!=null)this.setMirror(this.maps.length-1,e)}appendMapping(t){for(let e=0,r=this.maps.length;e<t.maps.length;e++){let i=t.getMirror(e);this.appendMap(t.maps[e],i!=null&&i<e?r+i:undefined)}}getMirror(t){if(this.mirror)for(let e=0;e<this.mirror.length;e++)if(this.mirror[e]==t)return this.mirror[e+(e%2?-1:1)]}setMirror(t,e){if(!this.mirror)this.mirror=[];this.mirror.push(t,e)}appendMappingInverted(t){for(let e=t.maps.length-1,r=this.maps.length+t.maps.length;e>=0;e--){let i=t.getMirror(e);this.appendMap(t.maps[e].invert(),i!=null&&i>e?r-i-1:undefined)}}invert(){let t=new Gr;t.appendMappingInverted(this);return t}map(t,e=1){if(this.mirror)return this._map(t,e,true);for(let r=this.from;r<this.to;r++)t=this.maps[r].map(t,e);return t}mapResult(t,e=1){return this._map(t,e,false)}_map(t,e,r){let i=0;for(let r=this.from;r<this.to;r++){let n=this.maps[r],s=n.mapResult(t,e);if(s.recover!=null){let e=this.getMirror(r);if(e!=null&&e>r&&e<this.to){r=e;t=this.maps[e].recover(s.recover);continue}}i|=s.delInfo;t=s.pos}return r?t:new Kr(t,i,null)}}const Xr=Object.create(null);class Yr{getMap(){return Vr.empty}merge(t){return null}static fromJSON(t,e){if(!e||!e.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=Xr[e.stepType];if(!r)throw new RangeError(`No step type ${e.stepType} defined`);return r.fromJSON(t,e)}static jsonID(t,e){if(t in Xr)throw new RangeError("Duplicate use of step JSON ID "+t);Xr[t]=e;e.prototype.jsonID=t;return e}}class Qr{constructor(t,e){this.doc=t;this.failed=e}static ok(t){return new Qr(t,null)}static fail(t){return new Qr(null,t)}static fromReplace(t,e,r,i){try{return Qr.ok(t.replace(e,r,i))}catch(t){if(t instanceof Fe)return Qr.fail(t.message);throw t}}}function ti(t,e,r){let i=[];for(let n=0;n<t.childCount;n++){let s=t.child(n);if(s.content.size)s=s.copy(ti(s.content,e,s));if(s.isInline)s=e(s,r,n);i.push(s)}return be.fromArray(i)}class ei extends Yr{constructor(t,e,r){super();this.from=t;this.to=e;this.mark=r}apply(t){let e=t.slice(this.from,this.to),r=t.resolve(this.from);let i=r.node(r.sharedDepth(this.to));let n=new Ee(ti(e.content,((t,e)=>{if(!t.isAtom||!e.type.allowsMarkType(this.mark.type))return t;return t.mark(this.mark.addToSet(t.marks))}),i),e.openStart,e.openEnd);return Qr.fromReplace(t,this.from,this.to,n)}invert(){return new ri(this.from,this.to,this.mark)}map(t){let e=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);if(e.deleted&&r.deleted||e.pos>=r.pos)return null;return new ei(e.pos,r.pos,this.mark)}merge(t){if(t instanceof ei&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from)return new ei(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark);return null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,e){if(typeof e.from!="number"||typeof e.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new ei(e.from,e.to,t.markFromJSON(e.mark))}}Yr.jsonID("addMark",ei);class ri extends Yr{constructor(t,e,r){super();this.from=t;this.to=e;this.mark=r}apply(t){let e=t.slice(this.from,this.to);let r=new Ee(ti(e.content,(t=>t.mark(this.mark.removeFromSet(t.marks))),t),e.openStart,e.openEnd);return Qr.fromReplace(t,this.from,this.to,r)}invert(){return new ei(this.from,this.to,this.mark)}map(t){let e=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);if(e.deleted&&r.deleted||e.pos>=r.pos)return null;return new ri(e.pos,r.pos,this.mark)}merge(t){if(t instanceof ri&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from)return new ri(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark);return null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,e){if(typeof e.from!="number"||typeof e.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new ri(e.from,e.to,t.markFromJSON(e.mark))}}Yr.jsonID("removeMark",ri);class ii extends Yr{constructor(t,e){super();this.pos=t;this.mark=e}apply(t){let e=t.nodeAt(this.pos);if(!e)return Qr.fail("No node at mark step's position");let r=e.type.create(e.attrs,null,this.mark.addToSet(e.marks));return Qr.fromReplace(t,this.pos,this.pos+1,new Ee(be.from(r),0,e.isLeaf?0:1))}invert(t){let e=t.nodeAt(this.pos);if(e){let t=this.mark.addToSet(e.marks);if(t.length==e.marks.length){for(let r=0;r<e.marks.length;r++)if(!e.marks[r].isInSet(t))return new ii(this.pos,e.marks[r]);return new ii(this.pos,this.mark)}}return new ni(this.pos,this.mark)}map(t){let e=t.mapResult(this.pos,1);return e.deletedAfter?null:new ii(e.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,e){if(typeof e.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new ii(e.pos,t.markFromJSON(e.mark))}}Yr.jsonID("addNodeMark",ii);class ni extends Yr{constructor(t,e){super();this.pos=t;this.mark=e}apply(t){let e=t.nodeAt(this.pos);if(!e)return Qr.fail("No node at mark step's position");let r=e.type.create(e.attrs,null,this.mark.removeFromSet(e.marks));return Qr.fromReplace(t,this.pos,this.pos+1,new Ee(be.from(r),0,e.isLeaf?0:1))}invert(t){let e=t.nodeAt(this.pos);if(!e||!this.mark.isInSet(e.marks))return this;return new ii(this.pos,this.mark)}map(t){let e=t.mapResult(this.pos,1);return e.deletedAfter?null:new ni(e.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,e){if(typeof e.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new ni(e.pos,t.markFromJSON(e.mark))}}Yr.jsonID("removeNodeMark",ni);class si extends Yr{constructor(t,e,r,i=false){super();this.from=t;this.to=e;this.slice=r;this.structure=i}apply(t){if(this.structure&&oi(t,this.from,this.to))return Qr.fail("Structure replace would overwrite content");return Qr.fromReplace(t,this.from,this.to,this.slice)}getMap(){return new Vr([this.from,this.to-this.from,this.slice.size])}invert(t){return new si(this.from,this.from+this.slice.size,t.slice(this.from,this.to))}map(t){let e=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);if(e.deletedAcross&&r.deletedAcross)return null;return new si(e.pos,Math.max(e.pos,r.pos),this.slice)}merge(t){if(!(t instanceof si)||t.structure||this.structure)return null;if(this.from+this.slice.size==t.from&&!this.slice.openEnd&&!t.slice.openStart){let e=this.slice.size+t.slice.size==0?Ee.empty:new Ee(this.slice.content.append(t.slice.content),this.slice.openStart,t.slice.openEnd);return new si(this.from,this.to+(t.to-t.from),e,this.structure)}else if(t.to==this.from&&!this.slice.openStart&&!t.slice.openEnd){let e=this.slice.size+t.slice.size==0?Ee.empty:new Ee(t.slice.content.append(this.slice.content),t.slice.openStart,this.slice.openEnd);return new si(t.from,this.to,e,this.structure)}else{return null}}toJSON(){let t={stepType:"replace",from:this.from,to:this.to};if(this.slice.size)t.slice=this.slice.toJSON();if(this.structure)t.structure=true;return t}static fromJSON(t,e){if(typeof e.from!="number"||typeof e.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new si(e.from,e.to,Ee.fromJSON(t,e.slice),!!e.structure)}}Yr.jsonID("replace",si);class li extends Yr{constructor(t,e,r,i,n,s,l=false){super();this.from=t;this.to=e;this.gapFrom=r;this.gapTo=i;this.slice=n;this.insert=s;this.structure=l}apply(t){if(this.structure&&(oi(t,this.from,this.gapFrom)||oi(t,this.gapTo,this.to)))return Qr.fail("Structure gap-replace would overwrite content");let e=t.slice(this.gapFrom,this.gapTo);if(e.openStart||e.openEnd)return Qr.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,e.content);if(!r)return Qr.fail("Content does not fit in gap");return Qr.fromReplace(t,this.from,this.to,r)}getMap(){return new Vr([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(t){let e=this.gapTo-this.gapFrom;return new li(this.from,this.from+this.slice.size+e,this.from+this.insert,this.from+this.insert+e,t.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(t){let e=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);let i=this.from==this.gapFrom?e.pos:t.map(this.gapFrom,-1);let n=this.to==this.gapTo?r.pos:t.map(this.gapTo,1);if(e.deletedAcross&&r.deletedAcross||i<e.pos||n>r.pos)return null;return new li(e.pos,r.pos,i,n,this.slice,this.insert,this.structure)}toJSON(){let t={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};if(this.slice.size)t.slice=this.slice.toJSON();if(this.structure)t.structure=true;return t}static fromJSON(t,e){if(typeof e.from!="number"||typeof e.to!="number"||typeof e.gapFrom!="number"||typeof e.gapTo!="number"||typeof e.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new li(e.from,e.to,e.gapFrom,e.gapTo,Ee.fromJSON(t,e.slice),e.insert,!!e.structure)}}Yr.jsonID("replaceAround",li);function oi(t,e,r){let i=t.resolve(e),n=r-e,s=i.depth;while(n>0&&s>0&&i.indexAfter(s)==i.node(s).childCount){s--;n--}if(n>0){let t=i.node(s).maybeChild(i.indexAfter(s));while(n>0){if(!t||t.isLeaf)return true;t=t.firstChild;n--}}return false}function ui(t,e,r,i){let n=[],s=[];let l,o;t.doc.nodesBetween(e,r,((t,u,f)=>{if(!t.isInline)return;let h=t.marks;if(!i.isInSet(h)&&f.type.allowsMarkType(i.type)){let f=Math.max(u,e),a=Math.min(u+t.nodeSize,r);let c=i.addToSet(h);for(let t=0;t<h.length;t++){if(!h[t].isInSet(c)){if(l&&l.to==f&&l.mark.eq(h[t]))l.to=a;else n.push(l=new ri(f,a,h[t]))}}if(o&&o.to==f)o.to=a;else s.push(o=new ei(f,a,i))}}));n.forEach((e=>t.step(e)));s.forEach((e=>t.step(e)))}function fi(t,e,r,i){let n=[],s=0;t.doc.nodesBetween(e,r,((t,l)=>{if(!t.isInline)return;s++;let o=null;if(i instanceof dr){let e=t.marks,r;while(r=i.isInSet(e)){(o||(o=[])).push(r);e=r.removeFromSet(e)}}else if(i){if(i.isInSet(t.marks))o=[i]}else{o=t.marks}if(o&&o.length){let i=Math.min(l+t.nodeSize,r);for(let t=0;t<o.length;t++){let r=o[t],u;for(let t=0;t<n.length;t++){let e=n[t];if(e.step==s-1&&r.eq(n[t].style))u=e}if(u){u.to=i;u.step=s}else{n.push({style:r,from:Math.max(l,e),to:i,step:s})}}}}));n.forEach((e=>t.step(new ri(e.from,e.to,e.style))))}function hi(t,e,r,i=r.contentMatch,n=true){let s=t.doc.nodeAt(e);let l=[],o=e+1;for(let e=0;e<s.childCount;e++){let u=s.child(e),f=o+u.nodeSize;let h=i.matchType(u.type);if(!h){l.push(new si(o,f,Ee.empty))}else{i=h;for(let e=0;e<u.marks.length;e++)if(!r.allowsMarkType(u.marks[e].type))t.step(new ri(o,f,u.marks[e]));if(n&&u.isText&&r.whitespace!="pre"){let t,e=/\r?\n|\r/g,i;while(t=e.exec(u.text)){if(!i)i=new Ee(be.from(r.schema.text(" ",r.allowedMarks(u.marks))),0,0);l.push(new si(o+t.index,o+t.index+t[0].length,i))}}}o=f}if(!i.validEnd){let e=i.fillBefore(be.empty,true);t.replace(o,o,new Ee(e,0,0))}for(let e=l.length-1;e>=0;e--)t.step(l[e])}function ai(t,e,r){return(e==0||t.canReplace(e,t.childCount))&&(r==t.childCount||t.canReplace(0,r))}function ci(t){let e=t.parent;let r=e.content.cutByIndex(t.startIndex,t.endIndex);for(let e=t.depth;;--e){let i=t.$from.node(e);let n=t.$from.index(e),s=t.$to.indexAfter(e);if(e<t.depth&&i.canReplace(n,s,r))return e;if(e==0||i.type.spec.isolating||!ai(i,n,s))break}return null}function di(t,e,r){let{$from:i,$to:n,depth:s}=e;let l=i.before(s+1),o=n.after(s+1);let u=l,f=o;let h=be.empty,a=0;for(let t=s,e=false;t>r;t--)if(e||i.index(t)>0){e=true;h=be.from(i.node(t).copy(h));a++}else{u--}let c=be.empty,d=0;for(let t=s,e=false;t>r;t--)if(e||n.after(t+1)<n.end(t)){e=true;c=be.from(n.node(t).copy(c));d++}else{f++}t.step(new li(u,f,l,o,new Ee(h.append(c),a,d),h.size-a,true))}function pi(t,e,r=null,i=t){let n=wi(t,e);let s=n&&gi(i,e);if(!s)return null;return n.map(mi).concat({type:e,attrs:r}).concat(s.map(mi))}function mi(t){return{type:t,attrs:null}}function wi(t,e){let{parent:r,startIndex:i,endIndex:n}=t;let s=r.contentMatchAt(i).findWrapping(e);if(!s)return null;let l=s.length?s[0]:e;return r.canReplaceWith(i,n,l)?s:null}function gi(t,e){let{parent:r,startIndex:i,endIndex:n}=t;let s=r.child(i);let l=e.contentMatch.findWrapping(s.type);if(!l)return null;let o=l.length?l[l.length-1]:e;let u=o.contentMatch;for(let t=i;u&&t<n;t++)u=u.matchType(r.child(t).type);if(!u||!u.validEnd)return null;return l}function bi(t,e,r){let i=be.empty;for(let t=r.length-1;t>=0;t--){if(i.size){let e=r[t].type.contentMatch.matchFragment(i);if(!e||!e.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}i=be.from(r[t].type.create(r[t].attrs,i))}let n=e.start,s=e.end;t.step(new li(n,s,n,s,new Ee(i,0,0),r.length,true))}function ki(t,e,r,i,n){if(!i.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let s=t.steps.length;t.doc.nodesBetween(e,r,((e,r)=>{let l=typeof n=="function"?n(e):n;if(e.isTextblock&&!e.hasMarkup(i,l)&&yi(t.doc,t.mapping.slice(s).map(r),i)){let n=null;if(i.schema.linebreakReplacement){let t=i.whitespace=="pre",e=!!i.contentMatch.matchType(i.schema.linebreakReplacement);if(t&&!e)n=false;else if(!t&&e)n=true}if(n===false)vi(t,e,r,s);hi(t,t.mapping.slice(s).map(r,1),i,undefined,n===null);let o=t.mapping.slice(s);let u=o.map(r,1),f=o.map(r+e.nodeSize,1);t.step(new li(u,f,u+1,f-1,new Ee(be.from(i.create(l,null,e.marks)),0,0),1,true));if(n===true)Di(t,e,r,s);return false}}))}function Di(t,e,r,i){e.forEach(((n,s)=>{if(n.isText){let l,o=/\r?\n|\r/g;while(l=o.exec(n.text)){let n=t.mapping.slice(i).map(r+1+s+l.index);t.replaceWith(n,n+1,e.type.schema.linebreakReplacement.create())}}}))}function vi(t,e,r,i){e.forEach(((n,s)=>{if(n.type==n.type.schema.linebreakReplacement){let n=t.mapping.slice(i).map(r+1+s);t.replaceWith(n,n+1,e.type.schema.text("\n"))}}))}function yi(t,e,r){let i=t.resolve(e),n=i.index();return i.parent.canReplaceWith(n,n+1,r)}function Fi(t,e,r,i,n){let s=t.doc.nodeAt(e);if(!s)throw new RangeError("No node at given position");if(!r)r=s.type;let l=r.create(i,null,n||s.marks);if(s.isLeaf)return t.replaceWith(e,e+s.nodeSize,l);if(!r.validContent(s.content))throw new RangeError("Invalid content for node type "+r.name);t.step(new li(e,e+s.nodeSize,e+1,e+s.nodeSize-1,new Ee(be.from(l),0,0),1,true))}function Ei(t,e,r=1,i){let n=t.resolve(e),s=n.depth-r;let l=i&&i[i.length-1]||n.parent;if(s<0||n.parent.type.spec.isolating||!n.parent.canReplace(n.index(),n.parent.childCount)||!l.type.validContent(n.parent.content.cutByIndex(n.index(),n.parent.childCount)))return false;for(let t=n.depth-1,e=r-2;t>s;t--,e--){let r=n.node(t),s=n.index(t);if(r.type.spec.isolating)return false;let l=r.content.cutByIndex(s,r.childCount);let o=i&&i[e+1];if(o)l=l.replaceChild(0,o.type.create(o.attrs));let u=i&&i[e]||r;if(!r.canReplace(s+1,r.childCount)||!u.type.validContent(l))return false}let o=n.indexAfter(s);let u=i&&i[0];return n.node(s).canReplaceWith(o,o,u?u.type:n.node(s+1).type)}function Mi(t,e,r=1,i){let n=t.doc.resolve(e),s=be.empty,l=be.empty;for(let t=n.depth,e=n.depth-r,o=r-1;t>e;t--,o--){s=be.from(n.node(t).copy(s));let e=i&&i[o];l=be.from(e?e.type.create(e.attrs,l):n.node(t).copy(l))}t.step(new si(e,e,new Ee(s.append(l),r,r),true))}function xi(t,e){let r=t.resolve(e),i=r.index();return Ci(r.nodeBefore,r.nodeAfter)&&r.parent.canReplace(i,i+1)}function Ai(t,e){if(!e.content.size)t.type.compatibleContent(e.type);let r=t.contentMatchAt(t.childCount);let{linebreakReplacement:i}=t.type.schema;for(let n=0;n<e.childCount;n++){let s=e.child(n);let l=s.type==i?t.type.schema.nodes.text:s.type;r=r.matchType(l);if(!r)return false;if(!t.type.allowsMarks(s.marks))return false}return r.validEnd}function Ci(t,e){return!!(t&&e&&!t.isLeaf&&Ai(t,e))}function Si(t,e,r=-1){let i=t.resolve(e);for(let t=i.depth;;t--){let n,s,l=i.index(t);if(t==i.depth){n=i.nodeBefore;s=i.nodeAfter}else if(r>0){n=i.node(t+1);l++;s=i.node(t).maybeChild(l)}else{n=i.node(t).maybeChild(l-1);s=i.node(t+1)}if(n&&!n.isTextblock&&Ci(n,s)&&i.node(t).canReplace(l,l+1))return e;if(t==0)break;e=r<0?i.before(t):i.after(t)}}function Oi(t,e,r){let i=null;let{linebreakReplacement:n}=t.doc.type.schema;let s=t.doc.resolve(e-r),l=s.node().type;if(n&&l.inlineContent){let t=l.whitespace=="pre";let e=!!l.contentMatch.matchType(n);if(t&&!e)i=false;else if(!t&&e)i=true}let o=t.steps.length;if(i===false){let i=t.doc.resolve(e+r);vi(t,i.node(),i.before(),o)}if(l.inlineContent)hi(t,e+r-1,l,s.node().contentMatchAt(s.index()),i==null);let u=t.mapping.slice(o),f=u.map(e-r);t.step(new si(f,u.map(e+r,-1),Ee.empty,true));if(i===true){let e=t.doc.resolve(f);Di(t,e.node(),e.before(),t.steps.length)}return t}function $i(t,e,r){let i=t.resolve(e);if(i.parent.canReplaceWith(i.index(),i.index(),r))return e;if(i.parentOffset==0)for(let t=i.depth-1;t>=0;t--){let e=i.index(t);if(i.node(t).canReplaceWith(e,e,r))return i.before(t+1);if(e>0)return null}if(i.parentOffset==i.parent.content.size)for(let t=i.depth-1;t>=0;t--){let e=i.indexAfter(t);if(i.node(t).canReplaceWith(e,e,r))return i.after(t+1);if(e<i.node(t).childCount)return null}return null}function _i(t,e,r){let i=t.resolve(e);if(!r.content.size)return e;let n=r.content;for(let t=0;t<r.openStart;t++)n=n.firstChild.content;for(let t=1;t<=(r.openStart==0&&r.size?2:1);t++){for(let e=i.depth;e>=0;e--){let r=e==i.depth?0:i.pos<=(i.start(e+1)+i.end(e+1))/2?-1:1;let s=i.index(e)+(r>0?1:0);let l=i.node(e),o=false;if(t==1){o=l.canReplace(s,s,n)}else{let t=l.contentMatchAt(s).findWrapping(n.firstChild.type);o=t&&l.canReplaceWith(s,s,t[0])}if(o)return r==0?i.pos:r<0?i.before(e+1):i.after(e+1)}}return null}function Bi(t,e,r=e,i=Ee.empty){if(e==r&&!i.size)return null;let n=t.resolve(e),s=t.resolve(r);if(Ri(n,s,i))return new si(e,r,i);return new ji(n,s,i).fit()}function Ri(t,e,r){return!r.openStart&&!r.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),r.content)}class ji{constructor(t,e,r){this.$from=t;this.$to=e;this.unplaced=r;this.frontier=[];this.placed=be.empty;for(let e=0;e<=t.depth;e++){let r=t.node(e);this.frontier.push({type:r.type,match:r.contentMatchAt(t.indexAfter(e))})}for(let e=t.depth;e>0;e--)this.placed=be.from(t.node(e).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){while(this.unplaced.size){let t=this.findFittable();if(t)this.placeNodes(t);else this.openMore()||this.dropNode()}let t=this.mustMoveInline(),e=this.placed.size-this.depth-this.$from.depth;let r=this.$from,i=this.close(t<0?this.$to:r.doc.resolve(t));if(!i)return null;let n=this.placed,s=r.depth,l=i.depth;while(s&&l&&n.childCount==1){n=n.firstChild.content;s--;l--}let o=new Ee(n,s,l);if(t>-1)return new li(r.pos,t,this.$to.pos,this.$to.end(),o,e);if(o.size||r.pos!=this.$to.pos)return new si(r.pos,i.pos,o);return null}findFittable(){let t=this.unplaced.openStart;for(let e=this.unplaced.content,r=0,i=this.unplaced.openEnd;r<t;r++){let n=e.firstChild;if(e.childCount>1)i=0;if(n.type.spec.isolating&&i<=r){t=r;break}e=n.content}for(let e=1;e<=2;e++){for(let r=e==1?t:this.unplaced.openStart;r>=0;r--){let t,i=null;if(r){i=zi(this.unplaced.content,r-1).firstChild;t=i.content}else{t=this.unplaced.content}let n=t.firstChild;for(let t=this.depth;t>=0;t--){let{type:s,match:l}=this.frontier[t],o,u=null;if(e==1&&(n?l.matchType(n.type)||(u=l.fillBefore(be.from(n),false)):i&&s.compatibleContent(i.type)))return{sliceDepth:r,frontierDepth:t,parent:i,inject:u};else if(e==2&&n&&(o=l.findWrapping(n.type)))return{sliceDepth:r,frontierDepth:t,parent:i,wrap:o};if(i&&l.matchType(i.type))break}}}}openMore(){let{content:t,openStart:e,openEnd:r}=this.unplaced;let i=zi(t,e);if(!i.childCount||i.firstChild.isLeaf)return false;this.unplaced=new Ee(t,e+1,Math.max(r,i.size+e>=t.size-r?e+1:0));return true}dropNode(){let{content:t,openStart:e,openEnd:r}=this.unplaced;let i=zi(t,e);if(i.childCount<=1&&e>0){let n=t.size-e<=e+i.size;this.unplaced=new Ee(Ni(t,e-1,1),e-1,n?e-1:r)}else{this.unplaced=new Ee(Ni(t,e,1),e,r)}}placeNodes({sliceDepth:t,frontierDepth:e,parent:r,inject:i,wrap:n}){while(this.depth>e)this.closeFrontierNode();if(n)for(let t=0;t<n.length;t++)this.openFrontierNode(n[t]);let s=this.unplaced,l=r?r.content:s.content;let o=s.openStart-t;let u=0,f=[];let{match:h,type:a}=this.frontier[e];if(i){for(let t=0;t<i.childCount;t++)f.push(i.child(t));h=h.matchFragment(i)}let c=l.size+t-(s.content.size-s.openEnd);while(u<l.childCount){let t=l.child(u),e=h.matchType(t.type);if(!e)break;u++;if(u>1||o==0||t.content.size){h=e;f.push(Ti(t.mark(a.allowedMarks(t.marks)),u==1?o:0,u==l.childCount?c:-1))}}let d=u==l.childCount;if(!d)c=-1;this.placed=qi(this.placed,e,be.from(f));this.frontier[e].match=h;if(d&&c<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1)this.closeFrontierNode();for(let t=0,e=l;t<c;t++){let t=e.lastChild;this.frontier.push({type:t.type,match:t.contentMatchAt(t.childCount)});e=t.content}this.unplaced=!d?new Ee(Ni(s.content,t,u),s.openStart,s.openEnd):t==0?Ee.empty:new Ee(Ni(s.content,t-1,1),t-1,c<0?s.openEnd:t-1)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let t=this.frontier[this.depth],e;if(!t.type.isTextblock||!Ii(this.$to,this.$to.depth,t.type,t.match,false)||this.$to.depth==this.depth&&(e=this.findCloseLevel(this.$to))&&e.depth==this.depth)return-1;let{depth:r}=this.$to,i=this.$to.after(r);while(r>1&&i==this.$to.end(--r))++i;return i}findCloseLevel(t){t:for(let e=Math.min(this.depth,t.depth);e>=0;e--){let{match:r,type:i}=this.frontier[e];let n=e<t.depth&&t.end(e+1)==t.pos+(t.depth-(e+1));let s=Ii(t,e,i,r,n);if(!s)continue;for(let r=e-1;r>=0;r--){let{match:e,type:i}=this.frontier[r];let n=Ii(t,r,i,e,true);if(!n||n.childCount)continue t}return{depth:e,fit:s,move:n?t.doc.resolve(t.after(e+1)):t}}}close(t){let e=this.findCloseLevel(t);if(!e)return null;while(this.depth>e.depth)this.closeFrontierNode();if(e.fit.childCount)this.placed=qi(this.placed,e.depth,e.fit);t=e.move;for(let r=e.depth+1;r<=t.depth;r++){let e=t.node(r),i=e.type.contentMatch.fillBefore(e.content,true,t.index(r));this.openFrontierNode(e.type,e.attrs,i)}return t}openFrontierNode(t,e=null,r){let i=this.frontier[this.depth];i.match=i.match.matchType(t);this.placed=qi(this.placed,this.depth,be.from(t.create(e,r)));this.frontier.push({type:t,match:t.contentMatch})}closeFrontierNode(){let t=this.frontier.pop();let e=t.match.fillBefore(be.empty,true);if(e.childCount)this.placed=qi(this.placed,this.frontier.length,e)}}function Ni(t,e,r){if(e==0)return t.cutByIndex(r,t.childCount);return t.replaceChild(0,t.firstChild.copy(Ni(t.firstChild.content,e-1,r)))}function qi(t,e,r){if(e==0)return t.append(r);return t.replaceChild(t.childCount-1,t.lastChild.copy(qi(t.lastChild.content,e-1,r)))}function zi(t,e){for(let r=0;r<e;r++)t=t.firstChild.content;return t}function Ti(t,e,r){if(e<=0)return t;let i=t.content;if(e>1)i=i.replaceChild(0,Ti(i.firstChild,e-1,i.childCount==1?r-1:0));if(e>0){i=t.type.contentMatch.fillBefore(i).append(i);if(r<=0)i=i.append(t.type.contentMatch.matchFragment(i).fillBefore(be.empty,true))}return t.copy(i)}function Ii(t,e,r,i,n){let s=t.node(e),l=n?t.indexAfter(e):t.index(e);if(l==s.childCount&&!r.compatibleContent(s.type))return null;let o=i.fillBefore(s.content,true,l);return o&&!Pi(r,s.content,l)?o:null}function Pi(t,e,r){for(let i=r;i<e.childCount;i++)if(!t.allowsMarks(e.child(i).marks))return true;return false}function Ji(t){return t.spec.defining||t.spec.definingForContent}function Li(t,e,r,i){if(!i.size)return t.deleteRange(e,r);let n=t.doc.resolve(e),s=t.doc.resolve(r);if(Ri(n,s,i))return t.step(new si(e,r,i));let l=Zi(n,t.doc.resolve(r));if(l[l.length-1]==0)l.pop();let o=-(n.depth+1);l.unshift(o);for(let t=n.depth,e=n.pos-1;t>0;t--,e--){let r=n.node(t).type.spec;if(r.defining||r.definingAsContext||r.isolating)break;if(l.indexOf(t)>-1)o=t;else if(n.before(t)==e)l.splice(1,0,-t)}let u=l.indexOf(o);let f=[],h=i.openStart;for(let t=i.content,e=0;;e++){let r=t.firstChild;f.push(r);if(e==i.openStart)break;t=r.content}for(let t=h-1;t>=0;t--){let e=f[t],r=Ji(e.type);if(r&&!e.sameMarkup(n.node(Math.abs(o)-1)))h=t;else if(r||!e.type.isTextblock)break}for(let e=i.openStart;e>=0;e--){let o=(e+h+1)%(i.openStart+1);let a=f[o];if(!a)continue;for(let e=0;e<l.length;e++){let f=l[(e+u)%l.length],h=true;if(f<0){h=false;f=-f}let c=n.node(f-1),d=n.index(f-1);if(c.canReplaceWith(d,d,a.type,a.marks))return t.replace(n.before(f),h?s.after(f):r,new Ee(Wi(i.content,0,i.openStart,o),o,i.openEnd))}}let a=t.steps.length;for(let o=l.length-1;o>=0;o--){t.replace(e,r,i);if(t.steps.length>a)break;let u=l[o];if(u<0)continue;e=n.before(u);r=s.after(u)}}function Wi(t,e,r,i,n){if(e<r){let n=t.firstChild;t=t.replaceChild(0,n.copy(Wi(n.content,e+1,r,i,n)))}if(e>i){let e=n.contentMatchAt(0);let r=e.fillBefore(t).append(t);t=r.append(e.matchFragment(r).fillBefore(be.empty,true))}return t}function Ui(t,e,r,i){if(!i.isInline&&e==r&&t.doc.resolve(e).parent.content.size){let n=$i(t.doc,e,i.type);if(n!=null)e=r=n}t.replaceRange(e,r,new Ee(be.from(i),0,0))}function Hi(t,e,r){let i=t.doc.resolve(e),n=t.doc.resolve(r);let s=Zi(i,n);for(let e=0;e<s.length;e++){let r=s[e],l=e==s.length-1;if(l&&r==0||i.node(r).type.contentMatch.validEnd)return t.delete(i.start(r),n.end(r));if(r>0&&(l||i.node(r-1).canReplace(i.index(r-1),n.indexAfter(r-1))))return t.delete(i.before(r),n.after(r))}for(let s=1;s<=i.depth&&s<=n.depth;s++){if(e-i.start(s)==i.depth-s&&r>i.end(s)&&n.end(s)-r!=n.depth-s&&i.start(s-1)==n.start(s-1)&&i.node(s-1).canReplace(i.index(s-1),n.index(s-1)))return t.delete(i.before(s),r)}t.delete(e,r)}function Zi(t,e){let r=[],i=Math.min(t.depth,e.depth);for(let n=i;n>=0;n--){let i=t.start(n);if(i<t.pos-(t.depth-n)||e.end(n)>e.pos+(e.depth-n)||t.node(n).type.spec.isolating||e.node(n).type.spec.isolating)break;if(i==e.start(n)||n==t.depth&&n==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&n&&e.start(n-1)==i-1)r.push(n)}return r}class Ki extends Yr{constructor(t,e,r){super();this.pos=t;this.attr=e;this.value=r}apply(t){let e=t.nodeAt(this.pos);if(!e)return Qr.fail("No node at attribute step's position");let r=Object.create(null);for(let t in e.attrs)r[t]=e.attrs[t];r[this.attr]=this.value;let i=e.type.create(r,null,e.marks);return Qr.fromReplace(t,this.pos,this.pos+1,new Ee(be.from(i),0,e.isLeaf?0:1))}getMap(){return Vr.empty}invert(t){return new Ki(this.pos,this.attr,t.nodeAt(this.pos).attrs[this.attr])}map(t){let e=t.mapResult(this.pos,1);return e.deletedAfter?null:new Ki(e.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(t,e){if(typeof e.pos!="number"||typeof e.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new Ki(e.pos,e.attr,e.value)}}Yr.jsonID("attr",Ki);class Vi extends Yr{constructor(t,e){super();this.attr=t;this.value=e}apply(t){let e=Object.create(null);for(let r in t.attrs)e[r]=t.attrs[r];e[this.attr]=this.value;let r=t.type.create(e,t.content,t.marks);return Qr.ok(r)}getMap(){return Vr.empty}invert(t){return new Vi(this.attr,t.attrs[this.attr])}map(t){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(t,e){if(typeof e.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new Vi(e.attr,e.value)}}Yr.jsonID("docAttr",Vi);let Gi=class extends Error{};Gi=function t(e){let r=Error.call(this,e);r.__proto__=t.prototype;return r};Gi.prototype=Object.create(Error.prototype);Gi.prototype.constructor=Gi;Gi.prototype.name="TransformError";class Xi{constructor(t){this.doc=t;this.steps=[];this.docs=[];this.mapping=new Gr}get before(){return this.docs.length?this.docs[0]:this.doc}step(t){let e=this.maybeStep(t);if(e.failed)throw new Gi(e.failed);return this}maybeStep(t){let e=t.apply(this.doc);if(!e.failed)this.addStep(t,e.doc);return e}get docChanged(){return this.steps.length>0}addStep(t,e){this.docs.push(this.doc);this.steps.push(t);this.mapping.appendMap(t.getMap());this.doc=e}replace(t,e=t,r=Ee.empty){let i=Bi(this.doc,t,e,r);if(i)this.step(i);return this}replaceWith(t,e,r){return this.replace(t,e,new Ee(be.from(r),0,0))}delete(t,e){return this.replace(t,e,Ee.empty)}insert(t,e){return this.replaceWith(t,t,e)}replaceRange(t,e,r){Li(this,t,e,r);return this}replaceRangeWith(t,e,r){Ui(this,t,e,r);return this}deleteRange(t,e){Hi(this,t,e);return this}lift(t,e){di(this,t,e);return this}join(t,e=1){Oi(this,t,e);return this}wrap(t,e){bi(this,t,e);return this}setBlockType(t,e=t,r,i=null){ki(this,t,e,r,i);return this}setNodeMarkup(t,e,r=null,i){Fi(this,t,e,r,i);return this}setNodeAttribute(t,e,r){this.step(new Ki(t,e,r));return this}setDocAttribute(t,e){this.step(new Vi(t,e));return this}addNodeMark(t,e){this.step(new ii(t,e));return this}removeNodeMark(t,e){if(!(e instanceof ye)){let r=this.doc.nodeAt(t);if(!r)throw new RangeError("No node at position "+t);e=e.isInSet(r.marks);if(!e)return this}this.step(new ni(t,e));return this}split(t,e=1,r){Mi(this,t,e,r);return this}addMark(t,e,r){ui(this,t,e,r);return this}removeMark(t,e,r){fi(this,t,e,r);return this}clearIncompatible(t,e,r){hi(this,t,e,r);return this}}const Yi=Object.create(null);class Qi{constructor(t,e,r){this.$anchor=t;this.$head=e;this.ranges=r||[new tn(t.min(e),t.max(e))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let t=this.ranges;for(let e=0;e<t.length;e++)if(t[e].$from.pos!=t[e].$to.pos)return false;return true}content(){return this.$from.doc.slice(this.from,this.to,true)}replace(t,e=Ee.empty){let r=e.content.lastChild,i=null;for(let t=0;t<e.openEnd;t++){i=r;r=r.lastChild}let n=t.steps.length,s=this.ranges;for(let l=0;l<s.length;l++){let{$from:o,$to:u}=s[l],f=t.mapping.slice(n);t.replaceRange(f.map(o.pos),f.map(u.pos),l?Ee.empty:e);if(l==0)an(t,n,(r?r.isInline:i&&i.isTextblock)?-1:1)}}replaceWith(t,e){let r=t.steps.length,i=this.ranges;for(let n=0;n<i.length;n++){let{$from:s,$to:l}=i[n],o=t.mapping.slice(r);let u=o.map(s.pos),f=o.map(l.pos);if(n){t.deleteRange(u,f)}else{t.replaceRangeWith(u,f,e);an(t,r,e.isInline?-1:1)}}}static findFrom(t,e,r=false){let i=t.parent.inlineContent?new nn(t):hn(t.node(0),t.parent,t.pos,t.index(),e,r);if(i)return i;for(let i=t.depth-1;i>=0;i--){let n=e<0?hn(t.node(0),t.node(i),t.before(i+1),t.index(i),e,r):hn(t.node(0),t.node(i),t.after(i+1),t.index(i)+1,e,r);if(n)return n}return null}static near(t,e=1){return this.findFrom(t,e)||this.findFrom(t,-e)||new un(t.node(0))}static atStart(t){return hn(t,t,0,0,1)||new un(t)}static atEnd(t){return hn(t,t,t.content.size,t.childCount,-1)||new un(t)}static fromJSON(t,e){if(!e||!e.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Yi[e.type];if(!r)throw new RangeError(`No selection type ${e.type} defined`);return r.fromJSON(t,e)}static jsonID(t,e){if(t in Yi)throw new RangeError("Duplicate use of selection JSON ID "+t);Yi[t]=e;e.prototype.jsonID=t;return e}getBookmark(){return nn.between(this.$anchor,this.$head).getBookmark()}}Qi.prototype.visible=true;class tn{constructor(t,e){this.$from=t;this.$to=e}}let en=false;function rn(t){if(!en&&!t.parent.inlineContent){en=true;console["warn"]("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")")}}class nn extends Qi{constructor(t,e=t){rn(t);rn(e);super(t,e)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(t,e){let r=t.resolve(e.map(this.head));if(!r.parent.inlineContent)return Qi.near(r);let i=t.resolve(e.map(this.anchor));return new nn(i.parent.inlineContent?i:r,r)}replace(t,e=Ee.empty){super.replace(t,e);if(e==Ee.empty){let e=this.$from.marksAcross(this.$to);if(e)t.ensureMarks(e)}}eq(t){return t instanceof nn&&t.anchor==this.anchor&&t.head==this.head}getBookmark(){return new sn(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(t,e){if(typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new nn(t.resolve(e.anchor),t.resolve(e.head))}static create(t,e,r=e){let i=t.resolve(e);return new this(i,r==e?i:t.resolve(r))}static between(t,e,r){let i=t.pos-e.pos;if(!r||i)r=i>=0?1:-1;if(!e.parent.inlineContent){let t=Qi.findFrom(e,r,true)||Qi.findFrom(e,-r,true);if(t)e=t.$head;else return Qi.near(e,r)}if(!t.parent.inlineContent){if(i==0){t=e}else{t=(Qi.findFrom(t,-r,true)||Qi.findFrom(t,r,true)).$anchor;if(t.pos<e.pos!=i<0)t=e}}return new nn(t,e)}}Qi.jsonID("text",nn);class sn{constructor(t,e){this.anchor=t;this.head=e}map(t){return new sn(t.map(this.anchor),t.map(this.head))}resolve(t){return nn.between(t.resolve(this.anchor),t.resolve(this.head))}}class ln extends Qi{constructor(t){let e=t.nodeAfter;let r=t.node(0).resolve(t.pos+e.nodeSize);super(t,r);this.node=e}map(t,e){let{deleted:r,pos:i}=e.mapResult(this.anchor);let n=t.resolve(i);if(r)return Qi.near(n);return new ln(n)}content(){return new Ee(be.from(this.node),0,0)}eq(t){return t instanceof ln&&t.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new on(this.anchor)}static fromJSON(t,e){if(typeof e.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new ln(t.resolve(e.anchor))}static create(t,e){return new ln(t.resolve(e))}static isSelectable(t){return!t.isText&&t.type.spec.selectable!==false}}ln.prototype.visible=false;Qi.jsonID("node",ln);class on{constructor(t){this.anchor=t}map(t){let{deleted:e,pos:r}=t.mapResult(this.anchor);return e?new sn(r,r):new on(r)}resolve(t){let e=t.resolve(this.anchor),r=e.nodeAfter;if(r&&ln.isSelectable(r))return new ln(e);return Qi.near(e)}}class un extends Qi{constructor(t){super(t.resolve(0),t.resolve(t.content.size))}replace(t,e=Ee.empty){if(e==Ee.empty){t.delete(0,t.doc.content.size);let e=Qi.atStart(t.doc);if(!e.eq(t.selection))t.setSelection(e)}else{super.replace(t,e)}}toJSON(){return{type:"all"}}static fromJSON(t){return new un(t)}map(t){return new un(t)}eq(t){return t instanceof un}getBookmark(){return fn}}Qi.jsonID("all",un);const fn={map(){return this},resolve(t){return new un(t)}};function hn(t,e,r,i,n,s=false){if(e.inlineContent)return nn.create(t,r);for(let l=i-(n>0?0:1);n>0?l<e.childCount:l>=0;l+=n){let i=e.child(l);if(!i.isAtom){let e=hn(t,i,r+n,n<0?i.childCount:0,n,s);if(e)return e}else if(!s&&ln.isSelectable(i)){return ln.create(t,r-(n<0?i.nodeSize:0))}r+=i.nodeSize*n}return null}function an(t,e,r){let i=t.steps.length-1;if(i<e)return;let n=t.steps[i];if(!(n instanceof si||n instanceof li))return;let s=t.mapping.maps[i],l;s.forEach(((t,e,r,i)=>{if(l==null)l=i}));t.setSelection(Qi.near(t.doc.resolve(l),r))}const cn=1,dn=2,pn=4;class mn extends Xi{constructor(t){super(t.doc);this.curSelectionFor=0;this.updated=0;this.meta=Object.create(null);this.time=Date.now();this.curSelection=t.selection;this.storedMarks=t.storedMarks}get selection(){if(this.curSelectionFor<this.steps.length){this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor));this.curSelectionFor=this.steps.length}return this.curSelection}setSelection(t){if(t.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");this.curSelection=t;this.curSelectionFor=this.steps.length;this.updated=(this.updated|cn)&~dn;this.storedMarks=null;return this}get selectionSet(){return(this.updated&cn)>0}setStoredMarks(t){this.storedMarks=t;this.updated|=dn;return this}ensureMarks(t){if(!ye.sameSet(this.storedMarks||this.selection.$from.marks(),t))this.setStoredMarks(t);return this}addStoredMark(t){return this.ensureMarks(t.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(t){return this.ensureMarks(t.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&dn)>0}addStep(t,e){super.addStep(t,e);this.updated=this.updated&~dn;this.storedMarks=null}setTime(t){this.time=t;return this}replaceSelection(t){this.selection.replace(this,t);return this}replaceSelectionWith(t,e=true){let r=this.selection;if(e)t=t.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||ye.none));r.replaceWith(this,t);return this}deleteSelection(){this.selection.replace(this);return this}insertText(t,e,r){let i=this.doc.type.schema;if(e==null){if(!t)return this.deleteSelection();return this.replaceSelectionWith(i.text(t),true)}else{if(r==null)r=e;r=r==null?e:r;if(!t)return this.deleteRange(e,r);let n=this.storedMarks;if(!n){let t=this.doc.resolve(e);n=r==e?t.marks():t.marksAcross(this.doc.resolve(r))}this.replaceRangeWith(e,r,i.text(t,n));if(!this.selection.empty)this.setSelection(Qi.near(this.selection.$to));return this}}setMeta(t,e){this.meta[typeof t=="string"?t:t.key]=e;return this}getMeta(t){return this.meta[typeof t=="string"?t:t.key]}get isGeneric(){for(let t in this.meta)return false;return true}scrollIntoView(){this.updated|=pn;return this}get scrolledIntoView(){return(this.updated&pn)>0}}function wn(t,e){return!e||!t?t:t.bind(e)}class gn{constructor(t,e,r){this.name=t;this.init=wn(e.init,r);this.apply=wn(e.apply,r)}}const bn=[new gn("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new gn("selection",{init(t,e){return t.selection||Qi.atStart(e.doc)},apply(t){return t.selection}}),new gn("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,r,i){return i.selection.$cursor?t.storedMarks:null}}),new gn("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class kn{constructor(t,e){this.schema=t;this.plugins=[];this.pluginsByKey=Object.create(null);this.fields=bn.slice();if(e)e.forEach((t=>{if(this.pluginsByKey[t.key])throw new RangeError("Adding different instances of a keyed plugin ("+t.key+")");this.plugins.push(t);this.pluginsByKey[t.key]=t;if(t.spec.state)this.fields.push(new gn(t.key,t.spec.state,t))}))}}class Dn{constructor(t){this.config=t}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(t){return this.applyTransaction(t).state}filterTransaction(t,e=-1){for(let r=0;r<this.config.plugins.length;r++)if(r!=e){let e=this.config.plugins[r];if(e.spec.filterTransaction&&!e.spec.filterTransaction.call(e,t,this))return false}return true}applyTransaction(t){if(!this.filterTransaction(t))return{state:this,transactions:[]};let e=[t],r=this.applyInner(t),i=null;for(;;){let n=false;for(let s=0;s<this.config.plugins.length;s++){let l=this.config.plugins[s];if(l.spec.appendTransaction){let o=i?i[s].n:0,u=i?i[s].state:this;let f=o<e.length&&l.spec.appendTransaction.call(l,o?e.slice(o):e,u,r);if(f&&r.filterTransaction(f,s)){f.setMeta("appendedTransaction",t);if(!i){i=[];for(let t=0;t<this.config.plugins.length;t++)i.push(t<s?{state:r,n:e.length}:{state:this,n:0})}e.push(f);r=r.applyInner(f);n=true}if(i)i[s]={state:r,n:e.length}}}if(!n)return{state:r,transactions:e}}}applyInner(t){if(!t.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let e=new Dn(this.config),r=this.config.fields;for(let i=0;i<r.length;i++){let n=r[i];e[n.name]=n.apply(t,this[n.name],this,e)}return e}get tr(){return new mn(this)}static create(t){let e=new kn(t.doc?t.doc.type.schema:t.schema,t.plugins);let r=new Dn(e);for(let i=0;i<e.fields.length;i++)r[e.fields[i].name]=e.fields[i].init(t,r);return r}reconfigure(t){let e=new kn(this.schema,t.plugins);let r=e.fields,i=new Dn(e);for(let e=0;e<r.length;e++){let n=r[e].name;i[n]=this.hasOwnProperty(n)?this[n]:r[e].init(t,i)}return i}toJSON(t){let e={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks)e.storedMarks=this.storedMarks.map((t=>t.toJSON()));if(t&&typeof t=="object")for(let r in t){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let i=t[r],n=i.spec.state;if(n&&n.toJSON)e[r]=n.toJSON.call(i,this[i.key])}return e}static fromJSON(t,e,r){if(!e)throw new RangeError("Invalid input for EditorState.fromJSON");if(!t.schema)throw new RangeError("Required config field 'schema' missing");let i=new kn(t.schema,t.plugins);let n=new Dn(i);i.fields.forEach((i=>{if(i.name=="doc"){n.doc=Le.fromJSON(t.schema,e.doc)}else if(i.name=="selection"){n.selection=Qi.fromJSON(n.doc,e.selection)}else if(i.name=="storedMarks"){if(e.storedMarks)n.storedMarks=e.storedMarks.map(t.schema.markFromJSON)}else{if(r)for(let s in r){let l=r[s],o=l.spec.state;if(l.key==i.name&&o&&o.fromJSON&&Object.prototype.hasOwnProperty.call(e,s)){n[i.name]=o.fromJSON.call(l,t,e[s],n);return}}n[i.name]=i.init(t,n)}}));return n}}function vn(t,e,r){for(let i in t){let n=t[i];if(n instanceof Function)n=n.bind(e);else if(i=="handleDOMEvents")n=vn(n,e,{});r[i]=n}return r}class yn{constructor(t){this.spec=t;this.props={};if(t.props)vn(t.props,this,this.props);this.key=t.key?t.key.key:En("plugin")}getState(t){return t[this.key]}}const Fn=Object.create(null);function En(t){if(t in Fn)return t+"$"+ ++Fn[t];Fn[t]=0;return t+"$"}class Mn{constructor(t="key"){this.key=En(t)}get(t){return t.config.pluginsByKey[this.key]}getState(t){return t[this.key]}}const xn=function(t){for(var e=0;;e++){t=t.previousSibling;if(!t)return e}};const An=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let Cn=null;const Sn=function(t,e,r){let i=Cn||(Cn=document.createRange());i.setEnd(t,r==null?t.nodeValue.length:r);i.setStart(t,e||0);return i};const On=function(){Cn=null};const $n=function(t,e,r,i){return r&&(Bn(t,e,r,i,-1)||Bn(t,e,r,i,1))};const _n=/^(img|br|input|textarea|hr)$/i;function Bn(t,e,r,i,n){for(;;){if(t==r&&e==i)return true;if(e==(n<0?0:Rn(t))){let r=t.parentNode;if(!r||r.nodeType!=1||zn(t)||_n.test(t.nodeName)||t.contentEditable=="false")return false;e=xn(t)+(n<0?0:1);t=r}else if(t.nodeType==1){t=t.childNodes[e+(n<0?-1:0)];if(t.contentEditable=="false")return false;e=n<0?Rn(t):0}else{return false}}}function Rn(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function jn(t,e){for(;;){if(t.nodeType==3&&e)return t;if(t.nodeType==1&&e>0){if(t.contentEditable=="false")return null;t=t.childNodes[e-1];e=Rn(t)}else if(t.parentNode&&!zn(t)){e=xn(t);t=t.parentNode}else{return null}}}function Nn(t,e){for(;;){if(t.nodeType==3&&e<t.nodeValue.length)return t;if(t.nodeType==1&&e<t.childNodes.length){if(t.contentEditable=="false")return null;t=t.childNodes[e];e=0}else if(t.parentNode&&!zn(t)){e=xn(t)+1;t=t.parentNode}else{return null}}}function qn(t,e,r){for(let i=e==0,n=e==Rn(t);i||n;){if(t==r)return true;let e=xn(t);t=t.parentNode;if(!t)return false;i=i&&e==0;n=n&&e==Rn(t)}}function zn(t){let e;for(let r=t;r;r=r.parentNode)if(e=r.pmViewDesc)break;return e&&e.node&&e.node.isBlock&&(e.dom==t||e.contentDOM==t)}const Tn=function(t){return t.focusNode&&$n(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function In(t,e){let r=document.createEvent("Event");r.initEvent("keydown",true,true);r.keyCode=t;r.key=r.code=e;return r}function Pn(t){let e=t.activeElement;while(e&&e.shadowRoot)e=e.shadowRoot.activeElement;return e}function Jn(t,e,r){if(t.caretPositionFromPoint){try{let i=t.caretPositionFromPoint(e,r);if(i)return{node:i.offsetNode,offset:Math.min(Rn(i.offsetNode),i.offset)}}catch(t){}}if(t.caretRangeFromPoint){let i=t.caretRangeFromPoint(e,r);if(i)return{node:i.startContainer,offset:Math.min(Rn(i.startContainer),i.startOffset)}}}const Ln=typeof navigator!="undefined"?navigator:null;const Wn=typeof document!="undefined"?document:null;const Un=Ln&&Ln.userAgent||"";const Hn=/Edge\/(\d+)/.exec(Un);const Zn=/MSIE \d/.exec(Un);const Kn=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Un);const Vn=!!(Zn||Kn||Hn);const Gn=Zn?document.documentMode:Kn?+Kn[1]:Hn?+Hn[1]:0;const Xn=!Vn&&/gecko\/(\d+)/i.test(Un);Xn&&+(/Firefox\/(\d+)/.exec(Un)||[0,0])[1];const Yn=!Vn&&/Chrome\/(\d+)/.exec(Un);const Qn=!!Yn;const ts=Yn?+Yn[1]:0;const es=!Vn&&!!Ln&&/Apple Computer/.test(Ln.vendor);const rs=es&&(/Mobile\/\w+/.test(Un)||!!Ln&&Ln.maxTouchPoints>2);const is=rs||(Ln?/Mac/.test(Ln.platform):false);const ns=Ln?/Win/.test(Ln.platform):false;const ss=/Android \d/.test(Un);const ls=!!Wn&&"webkitFontSmoothing"in Wn.documentElement.style;const us=ls?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function fs(t){let e=t.defaultView&&t.defaultView.visualViewport;if(e)return{left:0,right:e.width,top:0,bottom:e.height};return{left:0,right:t.documentElement.clientWidth,top:0,bottom:t.documentElement.clientHeight}}function hs(t,e){return typeof t=="number"?t:t[e]}function as(t){let e=t.getBoundingClientRect();let r=e.width/t.offsetWidth||1;let i=e.height/t.offsetHeight||1;return{left:e.left,right:e.left+t.clientWidth*r,top:e.top,bottom:e.top+t.clientHeight*i}}function cs(t,e,r){let i=t.someProp("scrollThreshold")||0,n=t.someProp("scrollMargin")||5;let s=t.dom.ownerDocument;for(let l=r||t.dom;;l=An(l)){if(!l)break;if(l.nodeType!=1)continue;let t=l;let r=t==s.body;let o=r?fs(s):as(t);let u=0,f=0;if(e.top<o.top+hs(i,"top"))f=-(o.top-e.top+hs(n,"top"));else if(e.bottom>o.bottom-hs(i,"bottom"))f=e.bottom-e.top>o.bottom-o.top?e.top+hs(n,"top")-o.top:e.bottom-o.bottom+hs(n,"bottom");if(e.left<o.left+hs(i,"left"))u=-(o.left-e.left+hs(n,"left"));else if(e.right>o.right-hs(i,"right"))u=e.right-o.right+hs(n,"right");if(u||f){if(r){s.defaultView.scrollBy(u,f)}else{let r=t.scrollLeft,i=t.scrollTop;if(f)t.scrollTop+=f;if(u)t.scrollLeft+=u;let n=t.scrollLeft-r,s=t.scrollTop-i;e={left:e.left-n,top:e.top-s,right:e.right-n,bottom:e.bottom-s}}}if(r||/^(fixed|sticky)$/.test(getComputedStyle(l).position))break}}function ds(t){let e=t.dom.getBoundingClientRect(),r=Math.max(0,e.top);let i,n;for(let s=(e.left+e.right)/2,l=r+1;l<Math.min(innerHeight,e.bottom);l+=5){let e=t.root.elementFromPoint(s,l);if(!e||e==t.dom||!t.dom.contains(e))continue;let o=e.getBoundingClientRect();if(o.top>=r-20){i=e;n=o.top;break}}return{refDOM:i,refTop:n,stack:ps(t.dom)}}function ps(t){let e=[],r=t.ownerDocument;for(let i=t;i;i=An(i)){e.push({dom:i,top:i.scrollTop,left:i.scrollLeft});if(t==r)break}return e}function ms({refDOM:t,refTop:e,stack:r}){let i=t?t.getBoundingClientRect().top:0;ws(r,i==0?0:i-e)}function ws(t,e){for(let r=0;r<t.length;r++){let{dom:i,top:n,left:s}=t[r];if(i.scrollTop!=n+e)i.scrollTop=n+e;if(i.scrollLeft!=s)i.scrollLeft=s}}let gs=null;function bs(t){if(t.setActive)return t.setActive();if(gs)return t.focus(gs);let e=ps(t);t.focus(gs==null?{get preventScroll(){gs={preventScroll:true};return true}}:undefined);if(!gs){gs=false;ws(e,0)}}function ks(t,e){let r,i=2e8,n,s=0;let l=e.top,o=e.top;let u,f;for(let h=t.firstChild,a=0;h;h=h.nextSibling,a++){let t;if(h.nodeType==1)t=h.getClientRects();else if(h.nodeType==3)t=Sn(h).getClientRects();else continue;for(let c=0;c<t.length;c++){let d=t[c];if(d.top<=l&&d.bottom>=o){l=Math.max(d.bottom,l);o=Math.min(d.top,o);let t=d.left>e.left?d.left-e.left:d.right<e.left?e.left-d.right:0;if(t<i){r=h;i=t;n=t&&r.nodeType==3?{left:d.right<e.left?d.right:d.left,top:e.top}:e;if(h.nodeType==1&&t)s=a+(e.left>=(d.left+d.right)/2?1:0);continue}}else if(d.top>e.top&&!u&&d.left<=e.left&&d.right>=e.left){u=h;f={left:Math.max(d.left,Math.min(d.right,e.left)),top:d.top}}if(!r&&(e.left>=d.right&&e.top>=d.top||e.left>=d.left&&e.top>=d.bottom))s=a+1}}if(!r&&u){r=u;n=f;i=0}if(r&&r.nodeType==3)return Ds(r,n);if(!r||i&&r.nodeType==1)return{node:t,offset:s};return ks(r,n)}function Ds(t,e){let r=t.nodeValue.length;let i=document.createRange();for(let n=0;n<r;n++){i.setEnd(t,n+1);i.setStart(t,n);let r=Cs(i,1);if(r.top==r.bottom)continue;if(vs(e,r))return{node:t,offset:n+(e.left>=(r.left+r.right)/2?1:0)}}return{node:t,offset:0}}function vs(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function ys(t,e){let r=t.parentNode;if(r&&/^li$/i.test(r.nodeName)&&e.left<t.getBoundingClientRect().left)return r;return t}function Fs(t,e,r){let{node:i,offset:n}=ks(e,r),s=-1;if(i.nodeType==1&&!i.firstChild){let t=i.getBoundingClientRect();s=t.left!=t.right&&r.left>(t.left+t.right)/2?1:-1}return t.docView.posFromDOM(i,n,s)}function Es(t,e,r,i){let n=-1;for(let r=e,s=false;;){if(r==t.dom)break;let e=t.docView.nearestDesc(r,true),l;if(!e)return null;if(e.dom.nodeType==1&&(e.node.isBlock&&e.parent||!e.contentDOM)&&((l=e.dom.getBoundingClientRect()).width||l.height)){if(e.node.isBlock&&e.parent){if(!s&&l.left>i.left||l.top>i.top)n=e.posBefore;else if(!s&&l.right<i.left||l.bottom<i.top)n=e.posAfter;s=true}if(!e.contentDOM&&n<0&&!e.node.isText){let t=e.node.isBlock?i.top<(l.top+l.bottom)/2:i.left<(l.left+l.right)/2;return t?e.posBefore:e.posAfter}}r=e.dom.parentNode}return n>-1?n:t.docView.posFromDOM(e,r,-1)}function Ms(t,e,r){let i=t.childNodes.length;if(i&&r.top<r.bottom){for(let n=Math.max(0,Math.min(i-1,Math.floor(i*(e.top-r.top)/(r.bottom-r.top))-2)),s=n;;){let r=t.childNodes[s];if(r.nodeType==1){let t=r.getClientRects();for(let i=0;i<t.length;i++){let n=t[i];if(vs(e,n))return Ms(r,e,n)}}if((s=(s+1)%i)==n)break}}return t}function xs(t,e){let r=t.dom.ownerDocument,i,n=0;let s=Jn(r,e.left,e.top);if(s)({node:i,offset:n}=s);let l=(t.root.elementFromPoint?t.root:r).elementFromPoint(e.left,e.top);let o;if(!l||!t.dom.contains(l.nodeType!=1?l.parentNode:l)){let r=t.dom.getBoundingClientRect();if(!vs(e,r))return null;l=Ms(t.dom,e,r);if(!l)return null}if(es){for(let t=l;i&&t;t=An(t))if(t.draggable)i=undefined}l=ys(l,e);if(i){if(Xn&&i.nodeType==1){n=Math.min(n,i.childNodes.length);if(n<i.childNodes.length){let t=i.childNodes[n],r;if(t.nodeName=="IMG"&&(r=t.getBoundingClientRect()).right<=e.left&&r.bottom>e.top)n++}}let r;if(ls&&n&&i.nodeType==1&&(r=i.childNodes[n-1]).nodeType==1&&r.contentEditable=="false"&&r.getBoundingClientRect().top>=e.top)n--;if(i==t.dom&&n==i.childNodes.length-1&&i.lastChild.nodeType==1&&e.top>i.lastChild.getBoundingClientRect().bottom)o=t.state.doc.content.size;else if(n==0||i.nodeType!=1||i.childNodes[n-1].nodeName!="BR")o=Es(t,i,n,e)}if(o==null)o=Fs(t,l,e);let u=t.docView.nearestDesc(l,true);return{pos:o,inside:u?u.posAtStart-u.border:-1}}function As(t){return t.top<t.bottom||t.left<t.right}function Cs(t,e){let r=t.getClientRects();if(r.length){let t=r[e<0?0:r.length-1];if(As(t))return t}return Array.prototype.find.call(r,As)||t.getBoundingClientRect()}const Ss=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Os(t,e,r){let{node:i,offset:n,atom:s}=t.docView.domFromPos(e,r<0?-1:1);let l=ls||Xn;if(i.nodeType==3){if(l&&(Ss.test(i.nodeValue)||(r<0?!n:n==i.nodeValue.length))){let t=Cs(Sn(i,n,n),r);if(Xn&&n&&/\s/.test(i.nodeValue[n-1])&&n<i.nodeValue.length){let e=Cs(Sn(i,n-1,n-1),-1);if(e.top==t.top){let r=Cs(Sn(i,n,n+1),-1);if(r.top!=t.top)return $s(r,r.left<e.left)}}return t}else{let t=n,e=n,s=r<0?1:-1;if(r<0&&!n){e++;s=-1}else if(r>=0&&n==i.nodeValue.length){t--;s=1}else if(r<0){t--}else{e++}return $s(Cs(Sn(i,t,e),s),s<0)}}let o=t.state.doc.resolve(e-(s||0));if(!o.parent.inlineContent){if(s==null&&n&&(r<0||n==Rn(i))){let t=i.childNodes[n-1];if(t.nodeType==1)return _s(t.getBoundingClientRect(),false)}if(s==null&&n<Rn(i)){let t=i.childNodes[n];if(t.nodeType==1)return _s(t.getBoundingClientRect(),true)}return _s(i.getBoundingClientRect(),r>=0)}if(s==null&&n&&(r<0||n==Rn(i))){let t=i.childNodes[n-1];let e=t.nodeType==3?Sn(t,Rn(t)-(l?0:1)):t.nodeType==1&&(t.nodeName!="BR"||!t.nextSibling)?t:null;if(e)return $s(Cs(e,1),false)}if(s==null&&n<Rn(i)){let t=i.childNodes[n];while(t.pmViewDesc&&t.pmViewDesc.ignoreForCoords)t=t.nextSibling;let e=!t?null:t.nodeType==3?Sn(t,0,l?0:1):t.nodeType==1?t:null;if(e)return $s(Cs(e,-1),true)}return $s(Cs(i.nodeType==3?Sn(i):i,-r),r>=0)}function $s(t,e){if(t.width==0)return t;let r=e?t.left:t.right;return{top:t.top,bottom:t.bottom,left:r,right:r}}function _s(t,e){if(t.height==0)return t;let r=e?t.top:t.bottom;return{top:r,bottom:r,left:t.left,right:t.right}}function Bs(t,e,r){let i=t.state,n=t.root.activeElement;if(i!=e)t.updateState(e);if(n!=t.dom)t.focus();try{return r()}finally{if(i!=e)t.updateState(i);if(n!=t.dom&&n)n.focus()}}function Rs(t,e,r){let i=e.selection;let n=r=="up"?i.$from:i.$to;return Bs(t,e,(()=>{let{node:e}=t.docView.domFromPos(n.pos,r=="up"?-1:1);for(;;){let r=t.docView.nearestDesc(e,true);if(!r)break;if(r.node.isBlock){e=r.contentDOM||r.dom;break}e=r.dom.parentNode}let i=Os(t,n.pos,1);for(let t=e.firstChild;t;t=t.nextSibling){let e;if(t.nodeType==1)e=t.getClientRects();else if(t.nodeType==3)e=Sn(t,0,t.nodeValue.length).getClientRects();else continue;for(let t=0;t<e.length;t++){let n=e[t];if(n.bottom>n.top+1&&(r=="up"?i.top-n.top>(n.bottom-i.top)*2:n.bottom-i.bottom>(i.bottom-n.top)*2))return false}}return true}))}const js=/[\u0590-\u08ac]/;function Ns(t,e,r){let{$head:i}=e.selection;if(!i.parent.isTextblock)return false;let n=i.parentOffset,s=!n,l=n==i.parent.content.size;let o=t.domSelection();if(!o)return i.pos==i.start()||i.pos==i.end();if(!js.test(i.parent.textContent)||!o.modify)return r=="left"||r=="backward"?s:l;return Bs(t,e,(()=>{let{focusNode:e,focusOffset:n,anchorNode:s,anchorOffset:l}=t.domSelectionRange();let u=o.caretBidiLevel;o.modify("move",r,"character");let f=i.depth?t.docView.domAfterPos(i.before()):t.dom;let{focusNode:h,focusOffset:a}=t.domSelectionRange();let c=h&&!f.contains(h.nodeType==1?h:h.parentNode)||e==h&&n==a;try{o.collapse(s,l);if(e&&(e!=s||n!=l)&&o.extend)o.extend(e,n)}catch(t){}if(u!=null)o.caretBidiLevel=u;return c}))}let qs=null;let zs=null;let Ts=false;function Is(t,e,r){if(qs==e&&zs==r)return Ts;qs=e;zs=r;return Ts=r=="up"||r=="down"?Rs(t,e,r):Ns(t,e,r)}const Ps=0,Js=1,Ls=2,Ws=3;class Us{constructor(t,e,r,i){this.parent=t;this.children=e;this.dom=r;this.contentDOM=i;this.dirty=Ps;r.pmViewDesc=this}matchesWidget(t){return false}matchesMark(t){return false}matchesNode(t,e,r){return false}matchesHack(t){return false}parseRule(){return null}stopEvent(t){return false}get size(){let t=0;for(let e=0;e<this.children.length;e++)t+=this.children[e].size;return t}get border(){return 0}destroy(){this.parent=undefined;if(this.dom.pmViewDesc==this)this.dom.pmViewDesc=undefined;for(let t=0;t<this.children.length;t++)this.children[t].destroy()}posBeforeChild(t){for(let e=0,r=this.posAtStart;;e++){let i=this.children[e];if(i==t)return r;r+=i.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(t,e,r){if(this.contentDOM&&this.contentDOM.contains(t.nodeType==1?t:t.parentNode)){if(r<0){let r,i;if(t==this.contentDOM){r=t.childNodes[e-1]}else{while(t.parentNode!=this.contentDOM)t=t.parentNode;r=t.previousSibling}while(r&&!((i=r.pmViewDesc)&&i.parent==this))r=r.previousSibling;return r?this.posBeforeChild(i)+i.size:this.posAtStart}else{let r,i;if(t==this.contentDOM){r=t.childNodes[e]}else{while(t.parentNode!=this.contentDOM)t=t.parentNode;r=t.nextSibling}while(r&&!((i=r.pmViewDesc)&&i.parent==this))r=r.nextSibling;return r?this.posBeforeChild(i):this.posAtEnd}}let i;if(t==this.dom&&this.contentDOM){i=e>xn(this.contentDOM)}else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM)){i=t.compareDocumentPosition(this.contentDOM)&2}else if(this.dom.firstChild){if(e==0)for(let e=t;;e=e.parentNode){if(e==this.dom){i=false;break}if(e.previousSibling)break}if(i==null&&e==t.childNodes.length)for(let e=t;;e=e.parentNode){if(e==this.dom){i=true;break}if(e.nextSibling)break}}return(i==null?r>0:i)?this.posAtEnd:this.posAtStart}nearestDesc(t,e=false){for(let r=true,i=t;i;i=i.parentNode){let n=this.getDesc(i),s;if(n&&(!e||n.node)){if(r&&(s=n.nodeDOM)&&!(s.nodeType==1?s.contains(t.nodeType==1?t:t.parentNode):s==t))r=false;else return n}}}getDesc(t){let e=t.pmViewDesc;for(let t=e;t;t=t.parent)if(t==this)return e}posFromDOM(t,e,r){for(let i=t;i;i=i.parentNode){let n=this.getDesc(i);if(n)return n.localPosFromDOM(t,e,r)}return-1}descAt(t){for(let e=0,r=0;e<this.children.length;e++){let i=this.children[e],n=r+i.size;if(r==t&&n!=r){while(!i.border&&i.children.length){for(let t=0;t<i.children.length;t++){let e=i.children[t];if(e.size){i=e;break}}}return i}if(t<n)return i.descAt(t-r-i.border);r=n}}domFromPos(t,e){if(!this.contentDOM)return{node:this.dom,offset:0,atom:t+1};let r=0,i=0;for(let e=0;r<this.children.length;r++){let n=this.children[r],s=e+n.size;if(s>t||n instanceof Ys){i=t-e;break}e=s}if(i)return this.children[r].domFromPos(i-this.children[r].border,e);for(let t;r&&!(t=this.children[r-1]).size&&t instanceof Hs&&t.side>=0;r--){}if(e<=0){let t,i=true;for(;;r--,i=false){t=r?this.children[r-1]:null;if(!t||t.dom.parentNode==this.contentDOM)break}if(t&&e&&i&&!t.border&&!t.domAtom)return t.domFromPos(t.size,e);return{node:this.contentDOM,offset:t?xn(t.dom)+1:0}}else{let t,i=true;for(;;r++,i=false){t=r<this.children.length?this.children[r]:null;if(!t||t.dom.parentNode==this.contentDOM)break}if(t&&i&&!t.border&&!t.domAtom)return t.domFromPos(0,e);return{node:this.contentDOM,offset:t?xn(t.dom):this.contentDOM.childNodes.length}}}parseRange(t,e,r=0){if(this.children.length==0)return{node:this.contentDOM,from:t,to:e,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let i=-1,n=-1;for(let s=r,l=0;;l++){let r=this.children[l],o=s+r.size;if(i==-1&&t<=o){let n=s+r.border;if(t>=n&&e<=o-r.border&&r.node&&r.contentDOM&&this.contentDOM.contains(r.contentDOM))return r.parseRange(t,e,n);t=s;for(let e=l;e>0;e--){let r=this.children[e-1];if(r.size&&r.dom.parentNode==this.contentDOM&&!r.emptyChildAt(1)){i=xn(r.dom)+1;break}t-=r.size}if(i==-1)i=0}if(i>-1&&(o>e||l==this.children.length-1)){e=o;for(let t=l+1;t<this.children.length;t++){let r=this.children[t];if(r.size&&r.dom.parentNode==this.contentDOM&&!r.emptyChildAt(-1)){n=xn(r.dom);break}e+=r.size}if(n==-1)n=this.contentDOM.childNodes.length;break}s=o}return{node:this.contentDOM,from:t,to:e,fromOffset:i,toOffset:n}}emptyChildAt(t){if(this.border||!this.contentDOM||!this.children.length)return false;let e=this.children[t<0?0:this.children.length-1];return e.size==0||e.emptyChildAt(t)}domAfterPos(t){let{node:e,offset:r}=this.domFromPos(t,0);if(e.nodeType!=1||r==e.childNodes.length)throw new RangeError("No node after pos "+t);return e.childNodes[r]}setSelection(t,e,r,i=false){let n=Math.min(t,e),s=Math.max(t,e);for(let l=0,o=0;l<this.children.length;l++){let u=this.children[l],f=o+u.size;if(n>o&&s<f)return u.setSelection(t-o-u.border,e-o-u.border,r,i);o=f}let l=this.domFromPos(t,t?-1:1);let o=e==t?l:this.domFromPos(e,e?-1:1);let u=r.root.getSelection();let f=r.domSelectionRange();let h=false;if((Xn||es)&&t==e){let{node:t,offset:e}=l;if(t.nodeType==3){h=!!(e&&t.nodeValue[e-1]=="\n");if(h&&e==t.nodeValue.length){for(let e=t,r;e;e=e.parentNode){if(r=e.nextSibling){if(r.nodeName=="BR")l=o={node:r.parentNode,offset:xn(r)+1};break}let t=e.pmViewDesc;if(t&&t.node&&t.node.isBlock)break}}}else{let r=t.childNodes[e-1];h=r&&(r.nodeName=="BR"||r.contentEditable=="false")}}if(Xn&&f.focusNode&&f.focusNode!=o.node&&f.focusNode.nodeType==1){let t=f.focusNode.childNodes[f.focusOffset];if(t&&t.contentEditable=="false")i=true}if(!(i||h&&es)&&$n(l.node,l.offset,f.anchorNode,f.anchorOffset)&&$n(o.node,o.offset,f.focusNode,f.focusOffset))return;let a=false;if((u.extend||t==e)&&!h){u.collapse(l.node,l.offset);try{if(t!=e)u.extend(o.node,o.offset);a=true}catch(t){}}if(!a){if(t>e){let t=l;l=o;o=t}let r=document.createRange();r.setEnd(o.node,o.offset);r.setStart(l.node,l.offset);u.removeAllRanges();u.addRange(r)}}ignoreMutation(t){return!this.contentDOM&&t.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(t,e){for(let r=0,i=0;i<this.children.length;i++){let n=this.children[i],s=r+n.size;if(r==s?t<=s&&e>=r:t<s&&e>r){let i=r+n.border,l=s-n.border;if(t>=i&&e<=l){this.dirty=t==r||e==s?Ls:Js;if(t==i&&e==l&&(n.contentLost||n.dom.parentNode!=this.contentDOM))n.dirty=Ws;else n.markDirty(t-i,e-i);return}else{n.dirty=n.dom==n.contentDOM&&n.dom.parentNode==this.contentDOM&&!n.children.length?Ls:Ws}}r=s}this.dirty=Ls}markParentsDirty(){let t=1;for(let e=this.parent;e;e=e.parent,t++){let r=t==1?Ls:Js;if(e.dirty<r)e.dirty=r}}get domAtom(){return false}get ignoreForCoords(){return false}isText(t){return false}}class Hs extends Us{constructor(t,e,r,i){let n,s=e.type.toDOM;if(typeof s=="function")s=s(r,(()=>{if(!n)return i;if(n.parent)return n.parent.posBeforeChild(n)}));if(!e.type.spec.raw){if(s.nodeType!=1){let t=document.createElement("span");t.appendChild(s);s=t}s.contentEditable="false";s.classList.add("ProseMirror-widget")}super(t,[],s,null);this.widget=e;this.widget=e;n=this}matchesWidget(t){return this.dirty==Ps&&t.type.eq(this.widget.type)}parseRule(){return{ignore:true}}stopEvent(t){let e=this.widget.spec.stopEvent;return e?e(t):false}ignoreMutation(t){return t.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom);super.destroy()}get domAtom(){return true}get side(){return this.widget.type.side}}class Zs extends Us{constructor(t,e,r,i){super(t,[],e,null);this.textDOM=r;this.text=i}get size(){return this.text.length}localPosFromDOM(t,e){if(t!=this.textDOM)return this.posAtStart+(e?this.size:0);return this.posAtStart+e}domFromPos(t){return{node:this.textDOM,offset:t}}ignoreMutation(t){return t.type==="characterData"&&t.target.nodeValue==t.oldValue}}class Ks extends Us{constructor(t,e,r,i,n){super(t,[],r,i);this.mark=e;this.spec=n}static create(t,e,r,i){let n=i.nodeViews[e.type.name];let s=n&&n(e,i,r);if(!s||!s.dom)s=_r.renderSpec(document,e.type.spec.toDOM(e,r),null,e.attrs);return new Ks(t,e,s.dom,s.contentDOM||s.dom,s)}parseRule(){if(this.dirty&Ws||this.mark.type.spec.reparseInView)return null;return{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(t){return this.dirty!=Ws&&this.mark.eq(t)}markDirty(t,e){super.markDirty(t,e);if(this.dirty!=Ps){let t=this.parent;while(!t.node)t=t.parent;if(t.dirty<this.dirty)t.dirty=this.dirty;this.dirty=Ps}}slice(t,e,r){let i=Ks.create(this.parent,this.mark,true,r);let n=this.children,s=this.size;if(e<s)n=ml(n,e,s,r);if(t>0)n=ml(n,0,t,r);for(let t=0;t<n.length;t++)n[t].parent=i;i.children=n;return i}ignoreMutation(t){return this.spec.ignoreMutation?this.spec.ignoreMutation(t):super.ignoreMutation(t)}destroy(){if(this.spec.destroy)this.spec.destroy();super.destroy()}}class Vs extends Us{constructor(t,e,r,i,n,s,l,o,u){super(t,[],n,s);this.node=e;this.outerDeco=r;this.innerDeco=i;this.nodeDOM=l}static create(t,e,r,i,n,s){let l=n.nodeViews[e.type.name],o;let u=l&&l(e,n,(()=>{if(!o)return s;if(o.parent)return o.parent.posBeforeChild(o)}),r,i);let f=u&&u.dom,h=u&&u.contentDOM;if(e.isText){if(!f)f=document.createTextNode(e.text);else if(f.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else if(!f){let t=_r.renderSpec(document,e.type.spec.toDOM(e),null,e.attrs);({dom:f,contentDOM:h}=t)}if(!h&&!e.isText&&f.nodeName!="BR"){if(!f.hasAttribute("contenteditable"))f.contentEditable="false";if(e.type.spec.draggable)f.draggable=true}let a=f;f=ll(f,r,e);if(u)return o=new Qs(t,e,r,i,f,h||null,a,u,n,s+1);else if(e.isText)return new Xs(t,e,r,i,f,a,n);else return new Vs(t,e,r,i,f,h||null,a,n,s+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let t={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre")t.preserveWhitespace="full";if(!this.contentDOM){t.getContent=()=>this.node.content}else if(!this.contentLost){t.contentElement=this.contentDOM}else{for(let e=this.children.length-1;e>=0;e--){let r=this.children[e];if(this.dom.contains(r.dom.parentNode)){t.contentElement=r.dom.parentNode;break}}if(!t.contentElement)t.getContent=()=>be.empty}return t}matchesNode(t,e,r){return this.dirty==Ps&&t.eq(this.node)&&ol(e,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(t,e){let r=this.node.inlineContent,i=e;let n=t.composing?this.localCompositionInfo(t,e):null;let s=n&&n.pos>-1?n:null;let l=n&&n.pos<0;let o=new fl(this,s&&s.node,t);cl(this.node,this.innerDeco,((e,n,s)=>{if(e.spec.marks)o.syncToMarks(e.spec.marks,r,t);else if(e.type.side>=0&&!s)o.syncToMarks(n==this.node.childCount?ye.none:this.node.child(n).marks,r,t);o.placeWidget(e,t,i)}),((e,s,u,f)=>{o.syncToMarks(e.marks,r,t);let h;if(o.findNodeMatch(e,s,u,f));else if(l&&t.state.selection.from>i&&t.state.selection.to<i+e.nodeSize&&(h=o.findIndexWithChild(n.node))>-1&&o.updateNodeAt(e,s,u,h,t));else if(o.updateNextNode(e,s,u,t,f,i));else{o.addNode(e,s,u,t,i)}i+=e.nodeSize}));o.syncToMarks([],r,t);if(this.node.isTextblock)o.addTextblockHacks();o.destroyRest();if(o.changed||this.dirty==Ls){if(s)this.protectLocalComposition(t,s);tl(this.contentDOM,this.children,t);if(rs)dl(this.dom)}}localCompositionInfo(t,e){let{from:r,to:i}=t.state.selection;if(!(t.state.selection instanceof nn)||r<e||i>e+this.node.content.size)return null;let n=t.input.compositionNode;if(!n||!this.dom.contains(n.parentNode))return null;if(this.node.inlineContent){let t=n.nodeValue;let s=pl(this.node.content,t,r-e,i-e);return s<0?null:{node:n,pos:s,text:t}}else{return{node:n,pos:-1,text:""}}}protectLocalComposition(t,{node:e,pos:r,text:i}){if(this.getDesc(e))return;let n=e;for(;;n=n.parentNode){if(n.parentNode==this.contentDOM)break;while(n.previousSibling)n.parentNode.removeChild(n.previousSibling);while(n.nextSibling)n.parentNode.removeChild(n.nextSibling);if(n.pmViewDesc)n.pmViewDesc=undefined}let s=new Zs(this,n,e,i);t.input.compositionNodes.push(s);this.children=ml(this.children,r,r+i.length,t,s)}update(t,e,r,i){if(this.dirty==Ws||!t.sameMarkup(this.node))return false;this.updateInner(t,e,r,i);return true}updateInner(t,e,r,i){this.updateOuterDeco(e);this.node=t;this.innerDeco=r;if(this.contentDOM)this.updateChildren(i,this.posAtStart);this.dirty=Ps}updateOuterDeco(t){if(ol(t,this.outerDeco))return;let e=this.nodeDOM.nodeType!=1;let r=this.dom;this.dom=nl(this.dom,this.nodeDOM,il(this.outerDeco,this.node,e),il(t,this.node,e));if(this.dom!=r){r.pmViewDesc=undefined;this.dom.pmViewDesc=this}this.outerDeco=t}selectNode(){if(this.nodeDOM.nodeType==1)this.nodeDOM.classList.add("ProseMirror-selectednode");if(this.contentDOM||!this.node.type.spec.draggable)this.dom.draggable=true}deselectNode(){if(this.nodeDOM.nodeType==1){this.nodeDOM.classList.remove("ProseMirror-selectednode");if(this.contentDOM||!this.node.type.spec.draggable)this.dom.removeAttribute("draggable")}}get domAtom(){return this.node.isAtom}}function Gs(t,e,r,i,n){ll(i,e,t);let s=new Vs(undefined,t,e,r,i,i,i,n,0);if(s.contentDOM)s.updateChildren(n,0);return s}class Xs extends Vs{constructor(t,e,r,i,n,s,l){super(t,e,r,i,n,null,s,l,0)}parseRule(){let t=this.nodeDOM.parentNode;while(t&&t!=this.dom&&!t.pmIsDeco)t=t.parentNode;return{skip:t||true}}update(t,e,r,i){if(this.dirty==Ws||this.dirty!=Ps&&!this.inParent()||!t.sameMarkup(this.node))return false;this.updateOuterDeco(e);if((this.dirty!=Ps||t.text!=this.node.text)&&t.text!=this.nodeDOM.nodeValue){this.nodeDOM.nodeValue=t.text;if(i.trackWrites==this.nodeDOM)i.trackWrites=null}this.node=t;this.dirty=Ps;return true}inParent(){let t=this.parent.contentDOM;for(let e=this.nodeDOM;e;e=e.parentNode)if(e==t)return true;return false}domFromPos(t){return{node:this.nodeDOM,offset:t}}localPosFromDOM(t,e,r){if(t==this.nodeDOM)return this.posAtStart+Math.min(e,this.node.text.length);return super.localPosFromDOM(t,e,r)}ignoreMutation(t){return t.type!="characterData"&&t.type!="selection"}slice(t,e,r){let i=this.node.cut(t,e),n=document.createTextNode(i.text);return new Xs(this.parent,i,this.outerDeco,this.innerDeco,n,n,r)}markDirty(t,e){super.markDirty(t,e);if(this.dom!=this.nodeDOM&&(t==0||e==this.nodeDOM.nodeValue.length))this.dirty=Ws}get domAtom(){return false}isText(t){return this.node.text==t}}class Ys extends Us{parseRule(){return{ignore:true}}matchesHack(t){return this.dirty==Ps&&this.dom.nodeName==t}get domAtom(){return true}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class Qs extends Vs{constructor(t,e,r,i,n,s,l,o,u,f){super(t,e,r,i,n,s,l,u,f);this.spec=o}update(t,e,r,i){if(this.dirty==Ws)return false;if(this.spec.update&&(this.node.type==t.type||this.spec.multiType)){let n=this.spec.update(t,e,r);if(n)this.updateInner(t,e,r,i);return n}else if(!this.contentDOM&&!t.isLeaf){return false}else{return super.update(t,e,r,i)}}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(t,e,r,i){this.spec.setSelection?this.spec.setSelection(t,e,r.root):super.setSelection(t,e,r,i)}destroy(){if(this.spec.destroy)this.spec.destroy();super.destroy()}stopEvent(t){return this.spec.stopEvent?this.spec.stopEvent(t):false}ignoreMutation(t){return this.spec.ignoreMutation?this.spec.ignoreMutation(t):super.ignoreMutation(t)}}function tl(t,e,r){let i=t.firstChild,n=false;for(let s=0;s<e.length;s++){let l=e[s],o=l.dom;if(o.parentNode==t){while(o!=i){i=ul(i);n=true}i=i.nextSibling}else{n=true;t.insertBefore(o,i)}if(l instanceof Ks){let e=i?i.previousSibling:t.lastChild;tl(l.contentDOM,l.children,r);i=e?e.nextSibling:t.firstChild}}while(i){i=ul(i);n=true}if(n&&r.trackWrites==t)r.trackWrites=null}const el=function(t){if(t)this.nodeName=t};el.prototype=Object.create(null);const rl=[new el];function il(t,e,r){if(t.length==0)return rl;let i=r?rl[0]:new el,n=[i];for(let s=0;s<t.length;s++){let l=t[s].type.attrs;if(!l)continue;if(l.nodeName)n.push(i=new el(l.nodeName));for(let t in l){let s=l[t];if(s==null)continue;if(r&&n.length==1)n.push(i=new el(e.isInline?"span":"div"));if(t=="class")i.class=(i.class?i.class+" ":"")+s;else if(t=="style")i.style=(i.style?i.style+";":"")+s;else if(t!="nodeName")i[t]=s}}return n}function nl(t,e,r,i){if(r==rl&&i==rl)return e;let n=e;for(let e=0;e<i.length;e++){let s=i[e],l=r[e];if(e){let e;if(l&&l.nodeName==s.nodeName&&n!=t&&(e=n.parentNode)&&e.nodeName.toLowerCase()==s.nodeName){n=e}else{e=document.createElement(s.nodeName);e.pmIsDeco=true;e.appendChild(n);l=rl[0];n=e}}sl(n,l||rl[0],s)}return n}function sl(t,e,r){for(let i in e)if(i!="class"&&i!="style"&&i!="nodeName"&&!(i in r))t.removeAttribute(i);for(let i in r)if(i!="class"&&i!="style"&&i!="nodeName"&&r[i]!=e[i])t.setAttribute(i,r[i]);if(e.class!=r.class){let i=e.class?e.class.split(" ").filter(Boolean):[];let n=r.class?r.class.split(" ").filter(Boolean):[];for(let e=0;e<i.length;e++)if(n.indexOf(i[e])==-1)t.classList.remove(i[e]);for(let e=0;e<n.length;e++)if(i.indexOf(n[e])==-1)t.classList.add(n[e]);if(t.classList.length==0)t.removeAttribute("class")}if(e.style!=r.style){if(e.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,i;while(i=r.exec(e.style))t.style.removeProperty(i[1])}if(r.style)t.style.cssText+=r.style}}function ll(t,e,r){return nl(t,t,rl,il(e,r,t.nodeType!=1))}function ol(t,e){if(t.length!=e.length)return false;for(let r=0;r<t.length;r++)if(!t[r].type.eq(e[r].type))return false;return true}function ul(t){let e=t.nextSibling;t.parentNode.removeChild(t);return e}class fl{constructor(t,e,r){this.lock=e;this.view=r;this.index=0;this.stack=[];this.changed=false;this.top=t;this.preMatch=hl(t.node.content,t)}destroyBetween(t,e){if(t==e)return;for(let r=t;r<e;r++)this.top.children[r].destroy();this.top.children.splice(t,e-t);this.changed=true}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(t,e,r){let i=0,n=this.stack.length>>1;let s=Math.min(n,t.length);while(i<s&&(i==n-1?this.top:this.stack[i+1<<1]).matchesMark(t[i])&&t[i].type.spec.spanning!==false)i++;while(i<n){this.destroyRest();this.top.dirty=Ps;this.index=this.stack.pop();this.top=this.stack.pop();n--}while(n<t.length){this.stack.push(this.top,this.index+1);let i=-1;for(let e=this.index;e<Math.min(this.index+3,this.top.children.length);e++){let r=this.top.children[e];if(r.matchesMark(t[n])&&!this.isLocked(r.dom)){i=e;break}}if(i>-1){if(i>this.index){this.changed=true;this.destroyBetween(this.index,i)}this.top=this.top.children[this.index]}else{let i=Ks.create(this.top,t[n],e,r);this.top.children.splice(this.index,0,i);this.top=i;this.changed=true}this.index=0;n++}}findNodeMatch(t,e,r,i){let n=-1,s;if(i>=this.preMatch.index&&(s=this.preMatch.matches[i-this.preMatch.index]).parent==this.top&&s.matchesNode(t,e,r)){n=this.top.children.indexOf(s,this.index)}else{for(let i=this.index,s=Math.min(this.top.children.length,i+5);i<s;i++){let s=this.top.children[i];if(s.matchesNode(t,e,r)&&!this.preMatch.matched.has(s)){n=i;break}}}if(n<0)return false;this.destroyBetween(this.index,n);this.index++;return true}updateNodeAt(t,e,r,i,n){let s=this.top.children[i];if(s.dirty==Ws&&s.dom==s.contentDOM)s.dirty=Ls;if(!s.update(t,e,r,n))return false;this.destroyBetween(this.index,i);this.index++;return true}findIndexWithChild(t){for(;;){let e=t.parentNode;if(!e)return-1;if(e==this.top.contentDOM){let e=t.pmViewDesc;if(e)for(let t=this.index;t<this.top.children.length;t++){if(this.top.children[t]==e)return t}return-1}t=e}}updateNextNode(t,e,r,i,n,s){for(let l=this.index;l<this.top.children.length;l++){let o=this.top.children[l];if(o instanceof Vs){let u=this.preMatch.matched.get(o);if(u!=null&&u!=n)return false;let f=o.dom,h;let a=this.isLocked(f)&&!(t.isText&&o.node&&o.node.isText&&o.nodeDOM.nodeValue==t.text&&o.dirty!=Ws&&ol(e,o.outerDeco));if(!a&&o.update(t,e,r,i)){this.destroyBetween(this.index,l);if(o.dom!=f)this.changed=true;this.index++;return true}else if(!a&&(h=this.recreateWrapper(o,t,e,r,i,s))){this.destroyBetween(this.index,l);this.top.children[this.index]=h;if(h.contentDOM){h.dirty=Ls;h.updateChildren(i,s+1);h.dirty=Ps}this.changed=true;this.index++;return true}break}}return false}recreateWrapper(t,e,r,i,n,s){if(t.dirty||e.isAtom||!t.children.length||!t.node.content.eq(e.content)||!ol(r,t.outerDeco)||!i.eq(t.innerDeco))return null;let l=Vs.create(this.top,e,r,i,n,s);if(l.contentDOM){l.children=t.children;t.children=[];for(let t of l.children)t.parent=l}t.destroy();return l}addNode(t,e,r,i,n){let s=Vs.create(this.top,t,e,r,i,n);if(s.contentDOM)s.updateChildren(i,n+1);this.top.children.splice(this.index++,0,s);this.changed=true}placeWidget(t,e,r){let i=this.index<this.top.children.length?this.top.children[this.index]:null;if(i&&i.matchesWidget(t)&&(t==i.widget||!i.widget.type.toDOM.parentNode)){this.index++}else{let i=new Hs(this.top,t,e,r);this.top.children.splice(this.index++,0,i);this.changed=true}}addTextblockHacks(){let t=this.top.children[this.index-1],e=this.top;while(t instanceof Ks){e=t;t=e.children[e.children.length-1]}if(!t||!(t instanceof Xs)||/\n$/.test(t.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(t.node.text)){if((es||Qn)&&t&&t.dom.contentEditable=="false")this.addHackNode("IMG",e);this.addHackNode("BR",this.top)}}addHackNode(t,e){if(e==this.top&&this.index<e.children.length&&e.children[this.index].matchesHack(t)){this.index++}else{let r=document.createElement(t);if(t=="IMG"){r.className="ProseMirror-separator";r.alt=""}if(t=="BR")r.className="ProseMirror-trailingBreak";let i=new Ys(this.top,[],r,null);if(e!=this.top)e.children.push(i);else e.children.splice(this.index++,0,i);this.changed=true}}isLocked(t){return this.lock&&(t==this.lock||t.nodeType==1&&t.contains(this.lock.parentNode))}}function hl(t,e){let r=e,i=r.children.length;let n=t.childCount,s=new Map,l=[];t:while(n>0){let o;for(;;){if(i){let t=r.children[i-1];if(t instanceof Ks){r=t;i=t.children.length}else{o=t;i--;break}}else if(r==e){break t}else{i=r.parent.children.indexOf(r);r=r.parent}}let u=o.node;if(!u)continue;if(u!=t.child(n-1))break;--n;s.set(o,n);l.push(o)}return{index:n,matched:s,matches:l.reverse()}}function al(t,e){return t.type.side-e.type.side}function cl(t,e,r,i){let n=e.locals(t),s=0;if(n.length==0){for(let r=0;r<t.childCount;r++){let l=t.child(r);i(l,n,e.forChild(s,l),r);s+=l.nodeSize}return}let l=0,o=[],u=null;for(let f=0;;){let h,a;while(l<n.length&&n[l].to==s){let t=n[l++];if(t.widget){if(!h)h=t;else(a||(a=[h])).push(t)}}if(h){if(a){a.sort(al);for(let t=0;t<a.length;t++)r(a[t],f,!!u)}else{r(h,f,!!u)}}let c,d;if(u){d=-1;c=u;u=null}else if(f<t.childCount){d=f;c=t.child(f++)}else{break}for(let t=0;t<o.length;t++)if(o[t].to<=s)o.splice(t--,1);while(l<n.length&&n[l].from<=s&&n[l].to>s)o.push(n[l++]);let p=s+c.nodeSize;if(c.isText){let t=p;if(l<n.length&&n[l].from<t)t=n[l].from;for(let e=0;e<o.length;e++)if(o[e].to<t)t=o[e].to;if(t<p){u=c.cut(t-s);c=c.cut(0,t-s);p=t;d=-1}}else{while(l<n.length&&n[l].to<p)l++}let m=c.isInline&&!c.isLeaf?o.filter((t=>!t.inline)):o.slice();i(c,m,e.forChild(s,c),d);s=p}}function dl(t){if(t.nodeName=="UL"||t.nodeName=="OL"){let e=t.style.cssText;t.style.cssText=e+"; list-style: square !important";window.getComputedStyle(t).listStyle;t.style.cssText=e}}function pl(t,e,r,i){for(let n=0,s=0;n<t.childCount&&s<=i;){let l=t.child(n++),o=s;s+=l.nodeSize;if(!l.isText)continue;let u=l.text;while(n<t.childCount){let e=t.child(n++);s+=e.nodeSize;if(!e.isText)break;u+=e.text}if(s>=r){if(s>=i&&u.slice(i-e.length-o,i-o)==e)return i-e.length;let t=o<i?u.lastIndexOf(e,i-o-1):-1;if(t>=0&&t+e.length+o>=r)return o+t;if(r==i&&u.length>=i+e.length-o&&u.slice(i-o,i-o+e.length)==e)return i}}return-1}function ml(t,e,r,i,n){let s=[];for(let l=0,o=0;l<t.length;l++){let u=t[l],f=o,h=o+=u.size;if(f>=r||h<=e){s.push(u)}else{if(f<e)s.push(u.slice(0,e-f,i));if(n){s.push(n);n=undefined}if(h>r)s.push(u.slice(r-f,u.size,i))}}return s}function wl(t,e=null){let r=t.domSelectionRange(),i=t.state.doc;if(!r.focusNode)return null;let n=t.docView.nearestDesc(r.focusNode),s=n&&n.size==0;let l=t.docView.posFromDOM(r.focusNode,r.focusOffset,1);if(l<0)return null;let o=i.resolve(l),u,f;if(Tn(r)){u=l;while(n&&!n.node)n=n.parent;let t=n.node;if(n&&t.isAtom&&ln.isSelectable(t)&&n.parent&&!(t.isInline&&qn(r.focusNode,r.focusOffset,n.dom))){let t=n.posBefore;f=new ln(l==t?o:i.resolve(t))}}else{if(r instanceof t.dom.ownerDocument.defaultView.Selection&&r.rangeCount>1){let e=l,n=l;for(let i=0;i<r.rangeCount;i++){let s=r.getRangeAt(i);e=Math.min(e,t.docView.posFromDOM(s.startContainer,s.startOffset,1));n=Math.max(n,t.docView.posFromDOM(s.endContainer,s.endOffset,-1))}if(e<0)return null;[u,l]=n==t.state.selection.anchor?[n,e]:[e,n];o=i.resolve(l)}else{u=t.docView.posFromDOM(r.anchorNode,r.anchorOffset,1)}if(u<0)return null}let h=i.resolve(u);if(!f){let r=e=="pointer"||t.state.selection.head<o.pos&&!s?1:-1;f=Al(t,h,o,r)}return f}function gl(t){return t.editable?t.hasFocus():Sl(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function bl(t,e=false){let r=t.state.selection;Ml(t,r);if(!gl(t))return;if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&Qn){let e=t.domSelectionRange(),r=t.domObserver.currentSelection;if(e.anchorNode&&r.anchorNode&&$n(e.anchorNode,e.anchorOffset,r.anchorNode,r.anchorOffset)){t.input.mouseDown.delayedSelectionSync=true;t.domObserver.setCurSelection();return}}t.domObserver.disconnectSelection();if(t.cursorWrapper){El(t)}else{let{anchor:i,head:n}=r,s,l;if(kl&&!(r instanceof nn)){if(!r.$from.parent.inlineContent)s=Dl(t,r.from);if(!r.empty&&!r.$from.parent.inlineContent)l=Dl(t,r.to)}t.docView.setSelection(i,n,t,e);if(kl){if(s)yl(s);if(l)yl(l)}if(r.visible){t.dom.classList.remove("ProseMirror-hideselection")}else{t.dom.classList.add("ProseMirror-hideselection");if("onselectionchange"in document)Fl(t)}}t.domObserver.setCurSelection();t.domObserver.connectSelection()}const kl=es||Qn&&ts<63;function Dl(t,e){let{node:r,offset:i}=t.docView.domFromPos(e,0);let n=i<r.childNodes.length?r.childNodes[i]:null;let s=i?r.childNodes[i-1]:null;if(es&&n&&n.contentEditable=="false")return vl(n);if((!n||n.contentEditable=="false")&&(!s||s.contentEditable=="false")){if(n)return vl(n);else if(s)return vl(s)}}function vl(t){t.contentEditable="true";if(es&&t.draggable){t.draggable=false;t.wasDraggable=true}return t}function yl(t){t.contentEditable="false";if(t.wasDraggable){t.draggable=true;t.wasDraggable=null}}function Fl(t){let e=t.dom.ownerDocument;e.removeEventListener("selectionchange",t.input.hideSelectionGuard);let r=t.domSelectionRange();let i=r.anchorNode,n=r.anchorOffset;e.addEventListener("selectionchange",t.input.hideSelectionGuard=()=>{if(r.anchorNode!=i||r.anchorOffset!=n){e.removeEventListener("selectionchange",t.input.hideSelectionGuard);setTimeout((()=>{if(!gl(t)||t.state.selection.visible)t.dom.classList.remove("ProseMirror-hideselection")}),20)}})}function El(t){let e=t.domSelection(),r=document.createRange();if(!e)return;let i=t.cursorWrapper.dom,n=i.nodeName=="IMG";if(n)r.setStart(i.parentNode,xn(i)+1);else r.setStart(i,0);r.collapse(true);e.removeAllRanges();e.addRange(r);if(!n&&!t.state.selection.visible&&Vn&&Gn<=11){i.disabled=true;i.disabled=false}}function Ml(t,e){if(e instanceof ln){let r=t.docView.descAt(e.from);if(r!=t.lastSelectedViewDesc){xl(t);if(r)r.selectNode();t.lastSelectedViewDesc=r}}else{xl(t)}}function xl(t){if(t.lastSelectedViewDesc){if(t.lastSelectedViewDesc.parent)t.lastSelectedViewDesc.deselectNode();t.lastSelectedViewDesc=undefined}}function Al(t,e,r,i){return t.someProp("createSelectionBetween",(i=>i(t,e,r)))||nn.between(e,r,i)}function Cl(t){if(t.editable&&!t.hasFocus())return false;return Sl(t)}function Sl(t){let e=t.domSelectionRange();if(!e.anchorNode)return false;try{return t.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(t.editable||t.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch(t){return false}}function Ol(t){let e=t.docView.domFromPos(t.state.selection.anchor,0);let r=t.domSelectionRange();return $n(e.node,e.offset,r.anchorNode,r.anchorOffset)}function $l(t,e){let{$anchor:r,$head:i}=t.selection;let n=e>0?r.max(i):r.min(i);let s=!n.parent.inlineContent?n:n.depth?t.doc.resolve(e>0?n.after():n.before()):null;return s&&Qi.findFrom(s,e)}function _l(t,e){t.dispatch(t.state.tr.setSelection(e).scrollIntoView());return true}function Bl(t,e,r){let i=t.state.selection;if(i instanceof nn){if(r.indexOf("s")>-1){let{$head:r}=i,n=r.textOffset?null:e<0?r.nodeBefore:r.nodeAfter;if(!n||n.isText||!n.isLeaf)return false;let s=t.state.doc.resolve(r.pos+n.nodeSize*(e<0?-1:1));return _l(t,new nn(i.$anchor,s))}else if(!i.empty){return false}else if(t.endOfTextblock(e>0?"forward":"backward")){let r=$l(t.state,e);if(r&&r instanceof ln)return _l(t,r);return false}else if(!(is&&r.indexOf("m")>-1)){let r=i.$head,n=r.textOffset?null:e<0?r.nodeBefore:r.nodeAfter,s;if(!n||n.isText)return false;let l=e<0?r.pos-n.nodeSize:r.pos;if(!(n.isAtom||(s=t.docView.descAt(l))&&!s.contentDOM))return false;if(ln.isSelectable(n)){return _l(t,new ln(e<0?t.state.doc.resolve(r.pos-n.nodeSize):r))}else if(ls){return _l(t,new nn(t.state.doc.resolve(e<0?l:l+n.nodeSize)))}else{return false}}}else if(i instanceof ln&&i.node.isInline){return _l(t,new nn(e>0?i.$to:i.$from))}else{let r=$l(t.state,e);if(r)return _l(t,r);return false}}function Rl(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function jl(t,e){let r=t.pmViewDesc;return r&&r.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function Nl(t,e){return e<0?ql(t):zl(t)}function ql(t){let e=t.domSelectionRange();let r=e.focusNode,i=e.focusOffset;if(!r)return;let n,s,l=false;if(Xn&&r.nodeType==1&&i<Rl(r)&&jl(r.childNodes[i],-1))l=true;for(;;){if(i>0){if(r.nodeType!=1){break}else{let t=r.childNodes[i-1];if(jl(t,-1)){n=r;s=--i}else if(t.nodeType==3){r=t;i=r.nodeValue.length}else break}}else if(Tl(r)){break}else{let e=r.previousSibling;while(e&&jl(e,-1)){n=r.parentNode;s=xn(e);e=e.previousSibling}if(!e){r=r.parentNode;if(r==t.dom)break;i=0}else{r=e;i=Rl(r)}}}if(l)Jl(t,r,i);else if(n)Jl(t,n,s)}function zl(t){let e=t.domSelectionRange();let r=e.focusNode,i=e.focusOffset;if(!r)return;let n=Rl(r);let s,l;for(;;){if(i<n){if(r.nodeType!=1)break;let t=r.childNodes[i];if(jl(t,1)){s=r;l=++i}else break}else if(Tl(r)){break}else{let e=r.nextSibling;while(e&&jl(e,1)){s=e.parentNode;l=xn(e)+1;e=e.nextSibling}if(!e){r=r.parentNode;if(r==t.dom)break;i=n=0}else{r=e;i=0;n=Rl(r)}}}if(s)Jl(t,s,l)}function Tl(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function Il(t,e){while(t&&e==t.childNodes.length&&!zn(t)){e=xn(t)+1;t=t.parentNode}while(t&&e<t.childNodes.length){let r=t.childNodes[e];if(r.nodeType==3)return r;if(r.nodeType==1&&r.contentEditable=="false")break;t=r;e=0}}function Pl(t,e){while(t&&!e&&!zn(t)){e=xn(t);t=t.parentNode}while(t&&e){let r=t.childNodes[e-1];if(r.nodeType==3)return r;if(r.nodeType==1&&r.contentEditable=="false")break;t=r;e=t.childNodes.length}}function Jl(t,e,r){if(e.nodeType!=3){let t,i;if(i=Il(e,r)){e=i;r=0}else if(t=Pl(e,r)){e=t;r=t.nodeValue.length}}let i=t.domSelection();if(!i)return;if(Tn(i)){let t=document.createRange();t.setEnd(e,r);t.setStart(e,r);i.removeAllRanges();i.addRange(t)}else if(i.extend){i.extend(e,r)}t.domObserver.setCurSelection();let{state:n}=t;setTimeout((()=>{if(t.state==n)bl(t)}),50)}function Ll(t,e){let r=t.state.doc.resolve(e);if(!(Qn||ns)&&r.parent.inlineContent){let i=t.coordsAtPos(e);if(e>r.start()){let r=t.coordsAtPos(e-1);let n=(r.top+r.bottom)/2;if(n>i.top&&n<i.bottom&&Math.abs(r.left-i.left)>1)return r.left<i.left?"ltr":"rtl"}if(e<r.end()){let r=t.coordsAtPos(e+1);let n=(r.top+r.bottom)/2;if(n>i.top&&n<i.bottom&&Math.abs(r.left-i.left)>1)return r.left>i.left?"ltr":"rtl"}}let i=getComputedStyle(t.dom).direction;return i=="rtl"?"rtl":"ltr"}function Wl(t,e,r){let i=t.state.selection;if(i instanceof nn&&!i.empty||r.indexOf("s")>-1)return false;if(is&&r.indexOf("m")>-1)return false;let{$from:n,$to:s}=i;if(!n.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let r=$l(t.state,e);if(r&&r instanceof ln)return _l(t,r)}if(!n.parent.inlineContent){let r=e<0?n:s;let l=i instanceof un?Qi.near(r,e):Qi.findFrom(r,e);return l?_l(t,l):false}return false}function Ul(t,e){if(!(t.state.selection instanceof nn))return true;let{$head:r,$anchor:i,empty:n}=t.state.selection;if(!r.sameParent(i))return true;if(!n)return false;if(t.endOfTextblock(e>0?"forward":"backward"))return true;let s=!r.textOffset&&(e<0?r.nodeBefore:r.nodeAfter);if(s&&!s.isText){let i=t.state.tr;if(e<0)i.delete(r.pos-s.nodeSize,r.pos);else i.delete(r.pos,r.pos+s.nodeSize);t.dispatch(i);return true}return false}function Hl(t,e,r){t.domObserver.stop();e.contentEditable=r;t.domObserver.start()}function Zl(t){if(!es||t.state.selection.$head.parentOffset>0)return false;let{focusNode:e,focusOffset:r}=t.domSelectionRange();if(e&&e.nodeType==1&&r==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;Hl(t,r,"true");setTimeout((()=>Hl(t,r,"false")),20)}return false}function Kl(t){let e="";if(t.ctrlKey)e+="c";if(t.metaKey)e+="m";if(t.altKey)e+="a";if(t.shiftKey)e+="s";return e}function Vl(t,e){let r=e.keyCode,i=Kl(e);if(r==8||is&&r==72&&i=="c"){return Ul(t,-1)||Nl(t,-1)}else if(r==46&&!e.shiftKey||is&&r==68&&i=="c"){return Ul(t,1)||Nl(t,1)}else if(r==13||r==27){return true}else if(r==37||is&&r==66&&i=="c"){let e=r==37?Ll(t,t.state.selection.from)=="ltr"?-1:1:-1;return Bl(t,e,i)||Nl(t,e)}else if(r==39||is&&r==70&&i=="c"){let e=r==39?Ll(t,t.state.selection.from)=="ltr"?1:-1:1;return Bl(t,e,i)||Nl(t,e)}else if(r==38||is&&r==80&&i=="c"){return Wl(t,-1,i)||Nl(t,-1)}else if(r==40||is&&r==78&&i=="c"){return Zl(t)||Wl(t,1,i)||Nl(t,1)}else if(i==(is?"m":"c")&&(r==66||r==73||r==89||r==90)){return true}return false}function Gl(t,e){t.someProp("transformCopied",(r=>{e=r(e,t)}));let r=[],{content:i,openStart:n,openEnd:s}=e;while(n>1&&s>1&&i.childCount==1&&i.firstChild.childCount==1){n--;s--;let t=i.firstChild;r.push(t.type.name,t.attrs!=t.type.defaultAttrs?t.attrs:null);i=t.content}let l=t.someProp("clipboardSerializer")||_r.fromSchema(t.state.schema);let o=oo(),u=o.createElement("div");u.appendChild(l.serializeFragment(i,{document:o}));let f=u.firstChild,h,a=0;while(f&&f.nodeType==1&&(h=so[f.nodeName.toLowerCase()])){for(let t=h.length-1;t>=0;t--){let e=o.createElement(h[t]);while(u.firstChild)e.appendChild(u.firstChild);u.appendChild(e);a++}f=u.firstChild}if(f&&f.nodeType==1)f.setAttribute("data-pm-slice",`${n} ${s}${a?` -${a}`:""} ${JSON.stringify(r)}`);let c=t.someProp("clipboardTextSerializer",(r=>r(e,t)))||e.content.textBetween(0,e.content.size,"\n\n");return{dom:u,text:c,slice:e}}function Xl(t,e,r,i,n){let s=n.parent.type.spec.code;let l,o;if(!r&&!e)return null;let u=e&&(i||s||!r);if(u){t.someProp("transformPastedText",(r=>{e=r(e,s||i,t)}));if(s)return e?new Ee(be.from(t.state.schema.text(e.replace(/\r\n?/g,"\n"))),0,0):Ee.empty;let r=t.someProp("clipboardTextParser",(r=>r(e,n,i,t)));if(r){o=r}else{let r=n.marks();let{schema:i}=t.state,s=_r.fromSchema(i);l=document.createElement("div");e.split(/(?:\r\n?|\n)+/).forEach((t=>{let e=l.appendChild(document.createElement("p"));if(t)e.appendChild(s.serializeNode(i.text(t,r)))}))}}else{t.someProp("transformPastedHTML",(e=>{r=e(r,t)}));l=ho(r);if(ls)ao(l)}let f=l&&l.querySelector("[data-pm-slice]");let h=f&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(f.getAttribute("data-pm-slice")||"");if(h&&h[3])for(let t=+h[3];t>0;t--){let t=l.firstChild;while(t&&t.nodeType!=1)t=t.nextSibling;if(!t)break;l=t}if(!o){let e=t.someProp("clipboardParser")||t.someProp("domParser")||br.fromSchema(t.state.schema);o=e.parseSlice(l,{preserveWhitespace:!!(u||h),context:n,ruleFromNode(t){if(t.nodeName=="BR"&&!t.nextSibling&&t.parentNode&&!Yl.test(t.parentNode.nodeName))return{ignore:true};return null}})}if(h){o=co(no(o,+h[1],+h[2]),h[4])}else{o=Ee.maxOpen(Ql(o.content,n),true);if(o.openStart||o.openEnd){let t=0,e=0;for(let e=o.content.firstChild;t<o.openStart&&!e.type.spec.isolating;t++,e=e.firstChild){}for(let t=o.content.lastChild;e<o.openEnd&&!t.type.spec.isolating;e++,t=t.lastChild){}o=no(o,t,e)}}t.someProp("transformPasted",(e=>{o=e(o,t)}));return o}const Yl=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function Ql(t,e){if(t.childCount<2)return t;for(let r=e.depth;r>=0;r--){let i=e.node(r);let n=i.contentMatchAt(e.index(r));let s,l=[];t.forEach((t=>{if(!l)return;let e=n.findWrapping(t.type),r;if(!e)return l=null;if(r=l.length&&s.length&&eo(e,s,t,l[l.length-1],0)){l[l.length-1]=r}else{if(l.length)l[l.length-1]=ro(l[l.length-1],s.length);let r=to(t,e);l.push(r);n=n.matchType(r.type);s=e}}));if(l)return be.from(l)}return t}function to(t,e,r=0){for(let i=e.length-1;i>=r;i--)t=e[i].create(null,be.from(t));return t}function eo(t,e,r,i,n){if(n<t.length&&n<e.length&&t[n]==e[n]){let s=eo(t,e,r,i.lastChild,n+1);if(s)return i.copy(i.content.replaceChild(i.childCount-1,s));let l=i.contentMatchAt(i.childCount);if(l.matchType(n==t.length-1?r.type:t[n+1]))return i.copy(i.content.append(be.from(to(r,t,n+1))))}}function ro(t,e){if(e==0)return t;let r=t.content.replaceChild(t.childCount-1,ro(t.lastChild,e-1));let i=t.contentMatchAt(t.childCount).fillBefore(be.empty,true);return t.copy(r.append(i))}function io(t,e,r,i,n,s){let l=e<0?t.firstChild:t.lastChild,o=l.content;if(t.childCount>1)s=0;if(n<i-1)o=io(o,e,r,i,n+1,s);if(n>=r)o=e<0?l.contentMatchAt(0).fillBefore(o,s<=n).append(o):o.append(l.contentMatchAt(l.childCount).fillBefore(be.empty,true));return t.replaceChild(e<0?0:t.childCount-1,l.copy(o))}function no(t,e,r){if(e<t.openStart)t=new Ee(io(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd);if(r<t.openEnd)t=new Ee(io(t.content,1,r,t.openEnd,0,0),t.openStart,r);return t}const so={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};let lo=null;function oo(){return lo||(lo=document.implementation.createHTMLDocument("title"))}let uo=null;function fo(t){let e=window.trustedTypes;if(!e)return t;if(!uo)uo=e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t});return uo.createHTML(t)}function ho(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);if(e)t=t.slice(e[0].length);let r=oo().createElement("div");let i=/<([a-z][^>\s]+)/i.exec(t),n;if(n=i&&so[i[1].toLowerCase()])t=n.map((t=>"<"+t+">")).join("")+t+n.map((t=>"</"+t+">")).reverse().join("");r.innerHTML=fo(t);if(n)for(let t=0;t<n.length;t++)r=r.querySelector(n[t])||r;return r}function ao(t){let e=t.querySelectorAll(Qn?"span:not([class]):not([style])":"span.Apple-converted-space");for(let r=0;r<e.length;r++){let i=e[r];if(i.childNodes.length==1&&i.textContent==" "&&i.parentNode)i.parentNode.replaceChild(t.ownerDocument.createTextNode(" "),i)}}function co(t,e){if(!t.size)return t;let r=t.content.firstChild.type.schema,i;try{i=JSON.parse(e)}catch(e){return t}let{content:n,openStart:s,openEnd:l}=t;for(let t=i.length-2;t>=0;t-=2){let e=r.nodes[i[t]];if(!e||e.hasRequiredAttrs())break;n=be.from(e.create(i[t+1],n));s++;l++}return new Ee(n,s,l)}const po={};const mo={};const wo={touchstart:true,touchmove:true};class go{constructor(){this.shiftKey=false;this.mouseDown=null;this.lastKeyCode=null;this.lastKeyCodeTime=0;this.lastClick={time:0,x:0,y:0,type:""};this.lastSelectionOrigin=null;this.lastSelectionTime=0;this.lastIOSEnter=0;this.lastIOSEnterFallbackTimeout=-1;this.lastFocus=0;this.lastTouch=0;this.lastChromeDelete=0;this.composing=false;this.compositionNode=null;this.composingTimeout=-1;this.compositionNodes=[];this.compositionEndedAt=-2e8;this.compositionID=1;this.compositionPendingChanges=0;this.domChangeCount=0;this.eventHandlers=Object.create(null);this.hideSelectionGuard=null}}function bo(t){for(let e in po){let r=po[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=e=>{if(Fo(t,e)&&!yo(t,e)&&(t.editable||!(e.type in mo)))r(t,e)},wo[e]?{passive:true}:undefined)}if(es)t.dom.addEventListener("input",(()=>null));vo(t)}function ko(t,e){t.input.lastSelectionOrigin=e;t.input.lastSelectionTime=Date.now()}function Do(t){t.domObserver.stop();for(let e in t.input.eventHandlers)t.dom.removeEventListener(e,t.input.eventHandlers[e]);clearTimeout(t.input.composingTimeout);clearTimeout(t.input.lastIOSEnterFallbackTimeout)}function vo(t){t.someProp("handleDOMEvents",(e=>{for(let r in e)if(!t.input.eventHandlers[r])t.dom.addEventListener(r,t.input.eventHandlers[r]=e=>yo(t,e))}))}function yo(t,e){return t.someProp("handleDOMEvents",(r=>{let i=r[e.type];return i?i(t,e)||e.defaultPrevented:false}))}function Fo(t,e){if(!e.bubbles)return true;if(e.defaultPrevented)return false;for(let r=e.target;r!=t.dom;r=r.parentNode)if(!r||r.nodeType==11||r.pmViewDesc&&r.pmViewDesc.stopEvent(e))return false;return true}function Eo(t,e){if(!yo(t,e)&&po[e.type]&&(t.editable||!(e.type in mo)))po[e.type](t,e)}mo.keydown=(t,e)=>{let r=e;t.input.shiftKey=r.keyCode==16||r.shiftKey;if(zo(t,r))return;t.input.lastKeyCode=r.keyCode;t.input.lastKeyCodeTime=Date.now();if(ss&&Qn&&r.keyCode==13)return;if(r.keyCode!=229)t.domObserver.forceFlush();if(rs&&r.keyCode==13&&!r.ctrlKey&&!r.altKey&&!r.metaKey){let e=Date.now();t.input.lastIOSEnter=e;t.input.lastIOSEnterFallbackTimeout=setTimeout((()=>{if(t.input.lastIOSEnter==e){t.someProp("handleKeyDown",(e=>e(t,In(13,"Enter"))));t.input.lastIOSEnter=0}}),200)}else if(t.someProp("handleKeyDown",(e=>e(t,r)))||Vl(t,r)){r.preventDefault()}else{ko(t,"key")}};mo.keyup=(t,e)=>{if(e.keyCode==16)t.input.shiftKey=false};mo.keypress=(t,e)=>{let r=e;if(zo(t,r)||!r.charCode||r.ctrlKey&&!r.altKey||is&&r.metaKey)return;if(t.someProp("handleKeyPress",(e=>e(t,r)))){r.preventDefault();return}let i=t.state.selection;if(!(i instanceof nn)||!i.$from.sameParent(i.$to)){let e=String.fromCharCode(r.charCode);if(!/[\r\n]/.test(e)&&!t.someProp("handleTextInput",(r=>r(t,i.$from.pos,i.$to.pos,e))))t.dispatch(t.state.tr.insertText(e).scrollIntoView());r.preventDefault()}};function Mo(t){return{left:t.clientX,top:t.clientY}}function xo(t,e){let r=e.x-t.clientX,i=e.y-t.clientY;return r*r+i*i<100}function Ao(t,e,r,i,n){if(i==-1)return false;let s=t.state.doc.resolve(i);for(let i=s.depth+1;i>0;i--){if(t.someProp(e,(e=>i>s.depth?e(t,r,s.nodeAfter,s.before(i),n,true):e(t,r,s.node(i),s.before(i),n,false))))return true}return false}function Co(t,e,r){if(!t.focused)t.focus();if(t.state.selection.eq(e))return;let i=t.state.tr.setSelection(e);if(r=="pointer")i.setMeta("pointer",true);t.dispatch(i)}function So(t,e){if(e==-1)return false;let r=t.state.doc.resolve(e),i=r.nodeAfter;if(i&&i.isAtom&&ln.isSelectable(i)){Co(t,new ln(r),"pointer");return true}return false}function Oo(t,e){if(e==-1)return false;let r=t.state.selection,i,n;if(r instanceof ln)i=r.node;let s=t.state.doc.resolve(e);for(let t=s.depth+1;t>0;t--){let e=t>s.depth?s.nodeAfter:s.node(t);if(ln.isSelectable(e)){if(i&&r.$from.depth>0&&t>=r.$from.depth&&s.before(r.$from.depth+1)==r.$from.pos)n=s.before(r.$from.depth);else n=s.before(t);break}}if(n!=null){Co(t,ln.create(t.state.doc,n),"pointer");return true}else{return false}}function $o(t,e,r,i,n){return Ao(t,"handleClickOn",e,r,i)||t.someProp("handleClick",(r=>r(t,e,i)))||(n?Oo(t,r):So(t,r))}function _o(t,e,r,i){return Ao(t,"handleDoubleClickOn",e,r,i)||t.someProp("handleDoubleClick",(r=>r(t,e,i)))}function Bo(t,e,r,i){return Ao(t,"handleTripleClickOn",e,r,i)||t.someProp("handleTripleClick",(r=>r(t,e,i)))||Ro(t,r,i)}function Ro(t,e,r){if(r.button!=0)return false;let i=t.state.doc;if(e==-1){if(i.inlineContent){Co(t,nn.create(i,0,i.content.size),"pointer");return true}return false}let n=i.resolve(e);for(let e=n.depth+1;e>0;e--){let r=e>n.depth?n.nodeAfter:n.node(e);let s=n.before(e);if(r.inlineContent)Co(t,nn.create(i,s+1,s+1+r.content.size),"pointer");else if(ln.isSelectable(r))Co(t,ln.create(i,s),"pointer");else continue;return true}}function jo(t){return Wo(t)}const No=is?"metaKey":"ctrlKey";po.mousedown=(t,e)=>{let r=e;t.input.shiftKey=r.shiftKey;let i=jo(t);let n=Date.now(),s="singleClick";if(n-t.input.lastClick.time<500&&xo(r,t.input.lastClick)&&!r[No]){if(t.input.lastClick.type=="singleClick")s="doubleClick";else if(t.input.lastClick.type=="doubleClick")s="tripleClick"}t.input.lastClick={time:n,x:r.clientX,y:r.clientY,type:s};let l=t.posAtCoords(Mo(r));if(!l)return;if(s=="singleClick"){if(t.input.mouseDown)t.input.mouseDown.done();t.input.mouseDown=new qo(t,l,r,!!i)}else if((s=="doubleClick"?_o:Bo)(t,l.pos,l.inside,r)){r.preventDefault()}else{ko(t,"pointer")}};class qo{constructor(t,e,r,i){this.view=t;this.pos=e;this.event=r;this.flushed=i;this.delayedSelectionSync=false;this.mightDrag=null;this.startDoc=t.state.doc;this.selectNode=!!r[No];this.allowDefault=r.shiftKey;let n,s;if(e.inside>-1){n=t.state.doc.nodeAt(e.inside);s=e.inside}else{let r=t.state.doc.resolve(e.pos);n=r.parent;s=r.depth?r.before():0}const l=i?null:r.target;const o=l?t.docView.nearestDesc(l,true):null;this.target=o&&o.dom.nodeType==1?o.dom:null;let{selection:u}=t.state;if(r.button==0&&n.type.spec.draggable&&n.type.spec.selectable!==false||u instanceof ln&&u.from<=s&&u.to>s)this.mightDrag={node:n,pos:s,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Xn&&!this.target.hasAttribute("contentEditable"))};if(this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)){this.view.domObserver.stop();if(this.mightDrag.addAttr)this.target.draggable=true;if(this.mightDrag.setUneditable)setTimeout((()=>{if(this.view.input.mouseDown==this)this.target.setAttribute("contentEditable","false")}),20);this.view.domObserver.start()}t.root.addEventListener("mouseup",this.up=this.up.bind(this));t.root.addEventListener("mousemove",this.move=this.move.bind(this));ko(t,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up);this.view.root.removeEventListener("mousemove",this.move);if(this.mightDrag&&this.target){this.view.domObserver.stop();if(this.mightDrag.addAttr)this.target.removeAttribute("draggable");if(this.mightDrag.setUneditable)this.target.removeAttribute("contentEditable");this.view.domObserver.start()}if(this.delayedSelectionSync)setTimeout((()=>bl(this.view)));this.view.input.mouseDown=null}up(t){this.done();if(!this.view.dom.contains(t.target))return;let e=this.pos;if(this.view.state.doc!=this.startDoc)e=this.view.posAtCoords(Mo(t));this.updateAllowDefault(t);if(this.allowDefault||!e){ko(this.view,"pointer")}else if($o(this.view,e.pos,e.inside,t,this.selectNode)){t.preventDefault()}else if(t.button==0&&(this.flushed||es&&this.mightDrag&&!this.mightDrag.node.isAtom||Qn&&!this.view.state.selection.visible&&Math.min(Math.abs(e.pos-this.view.state.selection.from),Math.abs(e.pos-this.view.state.selection.to))<=2)){Co(this.view,Qi.near(this.view.state.doc.resolve(e.pos)),"pointer");t.preventDefault()}else{ko(this.view,"pointer")}}move(t){this.updateAllowDefault(t);ko(this.view,"pointer");if(t.buttons==0)this.done()}updateAllowDefault(t){if(!this.allowDefault&&(Math.abs(this.event.x-t.clientX)>4||Math.abs(this.event.y-t.clientY)>4))this.allowDefault=true}}po.touchstart=t=>{t.input.lastTouch=Date.now();jo(t);ko(t,"pointer")};po.touchmove=t=>{t.input.lastTouch=Date.now();ko(t,"pointer")};po.contextmenu=t=>jo(t);function zo(t,e){if(t.composing)return true;if(es&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500){t.input.compositionEndedAt=-2e8;return true}return false}const To=ss?5e3:-1;mo.compositionstart=mo.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,r=e.selection.$to;if(e.selection instanceof nn&&(e.storedMarks||!r.textOffset&&r.parentOffset&&r.nodeBefore.marks.some((t=>t.type.spec.inclusive===false)))){t.markCursor=t.state.storedMarks||r.marks();Wo(t,true);t.markCursor=null}else{Wo(t,!e.selection.empty);if(Xn&&e.selection.empty&&r.parentOffset&&!r.textOffset&&r.nodeBefore.marks.length){let e=t.domSelectionRange();for(let r=e.focusNode,i=e.focusOffset;r&&r.nodeType==1&&i!=0;){let e=i<0?r.lastChild:r.childNodes[i-1];if(!e)break;if(e.nodeType==3){let r=t.domSelection();if(r)r.collapse(e,e.nodeValue.length);break}else{r=e;i=-1}}}}t.input.composing=true}Io(t,To)};mo.compositionend=(t,e)=>{if(t.composing){t.input.composing=false;t.input.compositionEndedAt=e.timeStamp;t.input.compositionPendingChanges=t.domObserver.pendingRecords().length?t.input.compositionID:0;t.input.compositionNode=null;if(t.input.compositionPendingChanges)Promise.resolve().then((()=>t.domObserver.flush()));t.input.compositionID++;Io(t,20)}};function Io(t,e){clearTimeout(t.input.composingTimeout);if(e>-1)t.input.composingTimeout=setTimeout((()=>Wo(t)),e)}function Po(t){if(t.composing){t.input.composing=false;t.input.compositionEndedAt=Lo()}while(t.input.compositionNodes.length>0)t.input.compositionNodes.pop().markParentsDirty()}function Jo(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let r=jn(e.focusNode,e.focusOffset);let i=Nn(e.focusNode,e.focusOffset);if(r&&i&&r!=i){let e=i.pmViewDesc,n=t.domObserver.lastChangedTextNode;if(r==n||i==n)return n;if(!e||!e.isText(i.nodeValue)){return i}else if(t.input.compositionNode==i){let t=r.pmViewDesc;if(!(!t||!t.isText(r.nodeValue)))return i}}return r||i}function Lo(){let t=document.createEvent("Event");t.initEvent("event",true,true);return t.timeStamp}function Wo(t,e=false){if(ss&&t.domObserver.flushingSoon>=0)return;t.domObserver.forceFlush();Po(t);if(e||t.docView&&t.docView.dirty){let r=wl(t);if(r&&!r.eq(t.state.selection))t.dispatch(t.state.tr.setSelection(r));else if((t.markCursor||e)&&!t.state.selection.empty)t.dispatch(t.state.tr.deleteSelection());else t.updateState(t.state);return true}return false}function Uo(t,e){if(!t.dom.parentNode)return;let r=t.dom.parentNode.appendChild(document.createElement("div"));r.appendChild(e);r.style.cssText="position: fixed; left: -10000px; top: 10px";let i=getSelection(),n=document.createRange();n.selectNodeContents(e);t.dom.blur();i.removeAllRanges();i.addRange(n);setTimeout((()=>{if(r.parentNode)r.parentNode.removeChild(r);t.focus()}),50)}const Ho=Vn&&Gn<15||rs&&us<604;po.copy=mo.cut=(t,e)=>{let r=e;let i=t.state.selection,n=r.type=="cut";if(i.empty)return;let s=Ho?null:r.clipboardData;let l=i.content(),{dom:o,text:u}=Gl(t,l);if(s){r.preventDefault();s.clearData();s.setData("text/html",o.innerHTML);s.setData("text/plain",u)}else{Uo(t,o)}if(n)t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function Zo(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function Ko(t,e){if(!t.dom.parentNode)return;let r=t.input.shiftKey||t.state.selection.$from.parent.type.spec.code;let i=t.dom.parentNode.appendChild(document.createElement(r?"textarea":"div"));if(!r)i.contentEditable="true";i.style.cssText="position: fixed; left: -10000px; top: 10px";i.focus();let n=t.input.shiftKey&&t.input.lastKeyCode!=45;setTimeout((()=>{t.focus();if(i.parentNode)i.parentNode.removeChild(i);if(r)Vo(t,i.value,null,n,e);else Vo(t,i.textContent,i.innerHTML,n,e)}),50)}function Vo(t,e,r,i,n){let s=Xl(t,e,r,i,t.state.selection.$from);if(t.someProp("handlePaste",(e=>e(t,n,s||Ee.empty))))return true;if(!s)return false;let l=Zo(s);let o=l?t.state.tr.replaceSelectionWith(l,i):t.state.tr.replaceSelection(s);t.dispatch(o.scrollIntoView().setMeta("paste",true).setMeta("uiEvent","paste"));return true}function Go(t){let e=t.getData("text/plain")||t.getData("Text");if(e)return e;let r=t.getData("text/uri-list");return r?r.replace(/\r?\n/g," "):""}mo.paste=(t,e)=>{let r=e;if(t.composing&&!ss)return;let i=Ho?null:r.clipboardData;let n=t.input.shiftKey&&t.input.lastKeyCode!=45;if(i&&Vo(t,Go(i),i.getData("text/html"),n,r))r.preventDefault();else Ko(t,r)};class Xo{constructor(t,e,r){this.slice=t;this.move=e;this.node=r}}const Yo=is?"altKey":"ctrlKey";po.dragstart=(t,e)=>{let r=e;let i=t.input.mouseDown;if(i)i.done();if(!r.dataTransfer)return;let n=t.state.selection;let s=n.empty?null:t.posAtCoords(Mo(r));let l;if(s&&s.pos>=n.from&&s.pos<=(n instanceof ln?n.to-1:n.to));else if(i&&i.mightDrag){l=ln.create(t.state.doc,i.mightDrag.pos)}else if(r.target&&r.target.nodeType==1){let e=t.docView.nearestDesc(r.target,true);if(e&&e.node.type.spec.draggable&&e!=t.docView)l=ln.create(t.state.doc,e.posBefore)}let o=(l||t.state.selection).content();let{dom:u,text:f,slice:h}=Gl(t,o);if(!r.dataTransfer.files.length||!Qn||ts>120)r.dataTransfer.clearData();r.dataTransfer.setData(Ho?"Text":"text/html",u.innerHTML);r.dataTransfer.effectAllowed="copyMove";if(!Ho)r.dataTransfer.setData("text/plain",f);t.dragging=new Xo(h,!r[Yo],l)};po.dragend=t=>{let e=t.dragging;window.setTimeout((()=>{if(t.dragging==e)t.dragging=null}),50)};mo.dragover=mo.dragenter=(t,e)=>e.preventDefault();mo.drop=(t,e)=>{let r=e;let i=t.dragging;t.dragging=null;if(!r.dataTransfer)return;let n=t.posAtCoords(Mo(r));if(!n)return;let s=t.state.doc.resolve(n.pos);let l=i&&i.slice;if(l){t.someProp("transformPasted",(e=>{l=e(l,t)}))}else{l=Xl(t,Go(r.dataTransfer),Ho?null:r.dataTransfer.getData("text/html"),false,s)}let o=!!(i&&!r[Yo]);if(t.someProp("handleDrop",(e=>e(t,r,l||Ee.empty,o)))){r.preventDefault();return}if(!l)return;r.preventDefault();let u=l?_i(t.state.doc,s.pos,l):s.pos;if(u==null)u=s.pos;let f=t.state.tr;if(o){let{node:t}=i;if(t)t.replace(f);else f.deleteSelection()}let h=f.mapping.map(u);let a=l.openStart==0&&l.openEnd==0&&l.content.childCount==1;let c=f.doc;if(a)f.replaceRangeWith(h,h,l.content.firstChild);else f.replaceRange(h,h,l);if(f.doc.eq(c))return;let d=f.doc.resolve(h);if(a&&ln.isSelectable(l.content.firstChild)&&d.nodeAfter&&d.nodeAfter.sameMarkup(l.content.firstChild)){f.setSelection(new ln(d))}else{let e=f.mapping.map(u);f.mapping.maps[f.mapping.maps.length-1].forEach(((t,r,i,n)=>e=n));f.setSelection(Al(t,d,f.doc.resolve(e)))}t.focus();t.dispatch(f.setMeta("uiEvent","drop"))};po.focus=t=>{t.input.lastFocus=Date.now();if(!t.focused){t.domObserver.stop();t.dom.classList.add("ProseMirror-focused");t.domObserver.start();t.focused=true;setTimeout((()=>{if(t.docView&&t.hasFocus()&&!t.domObserver.currentSelection.eq(t.domSelectionRange()))bl(t)}),20)}};po.blur=(t,e)=>{let r=e;if(t.focused){t.domObserver.stop();t.dom.classList.remove("ProseMirror-focused");t.domObserver.start();if(r.relatedTarget&&t.dom.contains(r.relatedTarget))t.domObserver.currentSelection.clear();t.focused=false}};po.beforeinput=(t,e)=>{let r=e;if(Qn&&ss&&r.inputType=="deleteContentBackward"){t.domObserver.flushSoon();let{domChangeCount:e}=t.input;setTimeout((()=>{if(t.input.domChangeCount!=e)return;t.dom.blur();t.focus();if(t.someProp("handleKeyDown",(e=>e(t,In(8,"Backspace")))))return;let{$cursor:r}=t.state.selection;if(r&&r.pos>0)t.dispatch(t.state.tr.delete(r.pos-1,r.pos).scrollIntoView())}),50)}};for(let t in mo)po[t]=mo[t];function Qo(t,e){if(t==e)return true;for(let r in t)if(t[r]!==e[r])return false;for(let r in e)if(!(r in t))return false;return true}class tu{constructor(t,e){this.toDOM=t;this.spec=e||su;this.side=this.spec.side||0}map(t,e,r,i){let{pos:n,deleted:s}=t.mapResult(e.from+i,this.side<0?-1:1);return s?null:new iu(n-r,n-r,this)}valid(){return true}eq(t){return this==t||t instanceof tu&&(this.spec.key&&this.spec.key==t.spec.key||this.toDOM==t.toDOM&&Qo(this.spec,t.spec))}destroy(t){if(this.spec.destroy)this.spec.destroy(t)}}class eu{constructor(t,e){this.attrs=t;this.spec=e||su}map(t,e,r,i){let n=t.map(e.from+i,this.spec.inclusiveStart?-1:1)-r;let s=t.map(e.to+i,this.spec.inclusiveEnd?1:-1)-r;return n>=s?null:new iu(n,s,this)}valid(t,e){return e.from<e.to}eq(t){return this==t||t instanceof eu&&Qo(this.attrs,t.attrs)&&Qo(this.spec,t.spec)}static is(t){return t.type instanceof eu}destroy(){}}class ru{constructor(t,e){this.attrs=t;this.spec=e||su}map(t,e,r,i){let n=t.mapResult(e.from+i,1);if(n.deleted)return null;let s=t.mapResult(e.to+i,-1);if(s.deleted||s.pos<=n.pos)return null;return new iu(n.pos-r,s.pos-r,this)}valid(t,e){let{index:r,offset:i}=t.content.findIndex(e.from),n;return i==e.from&&!(n=t.child(r)).isText&&i+n.nodeSize==e.to}eq(t){return this==t||t instanceof ru&&Qo(this.attrs,t.attrs)&&Qo(this.spec,t.spec)}destroy(){}}class iu{constructor(t,e,r){this.from=t;this.to=e;this.type=r}copy(t,e){return new iu(t,e,this.type)}eq(t,e=0){return this.type.eq(t.type)&&this.from+e==t.from&&this.to+e==t.to}map(t,e,r){return this.type.map(t,this,e,r)}static widget(t,e,r){return new iu(t,t,new tu(e,r))}static inline(t,e,r,i){return new iu(t,e,new eu(r,i))}static node(t,e,r,i){return new iu(t,e,new ru(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof eu}get widget(){return this.type instanceof tu}}const nu=[],su={};class lu{constructor(t,e){this.local=t.length?t:nu;this.children=e.length?e:nu}static create(t,e){return e.length?pu(e,t,0,su):ou}find(t,e,r){let i=[];this.findInner(t==null?0:t,e==null?1e9:e,i,0,r);return i}findInner(t,e,r,i,n){for(let s=0;s<this.local.length;s++){let l=this.local[s];if(l.from<=e&&l.to>=t&&(!n||n(l.spec)))r.push(l.copy(l.from+i,l.to+i))}for(let s=0;s<this.children.length;s+=3){if(this.children[s]<e&&this.children[s+1]>t){let l=this.children[s]+1;this.children[s+2].findInner(t-l,e-l,r,i+l,n)}}}map(t,e,r){if(this==ou||t.maps.length==0)return this;return this.mapInner(t,e,0,0,r||su)}mapInner(t,e,r,i,n){let s;for(let l=0;l<this.local.length;l++){let o=this.local[l].map(t,r,i);if(o&&o.type.valid(e,o))(s||(s=[])).push(o);else if(n.onRemove)n.onRemove(this.local[l].spec)}if(this.children.length)return fu(this.children,s||[],t,e,r,i,n);else return s?new lu(s.sort(mu),nu):ou}add(t,e){if(!e.length)return this;if(this==ou)return lu.create(t,e);return this.addInner(t,e,0)}addInner(t,e,r){let i,n=0;t.forEach(((t,s)=>{let l=s+r,o;if(!(o=cu(e,t,l)))return;if(!i)i=this.children.slice();while(n<i.length&&i[n]<s)n+=3;if(i[n]==s)i[n+2]=i[n+2].addInner(t,o,l+1);else i.splice(n,0,s,s+t.nodeSize,pu(o,t,l+1,su));n+=3}));let s=hu(n?du(e):e,-r);for(let e=0;e<s.length;e++)if(!s[e].type.valid(t,s[e]))s.splice(e--,1);return new lu(s.length?this.local.concat(s).sort(mu):this.local,i||this.children)}remove(t){if(t.length==0||this==ou)return this;return this.removeInner(t,0)}removeInner(t,e){let r=this.children,i=this.local;for(let i=0;i<r.length;i+=3){let n;let s=r[i]+e,l=r[i+1]+e;for(let e=0,r;e<t.length;e++)if(r=t[e]){if(r.from>s&&r.to<l){t[e]=null;(n||(n=[])).push(r)}}if(!n)continue;if(r==this.children)r=this.children.slice();let o=r[i+2].removeInner(n,s+1);if(o!=ou){r[i+2]=o}else{r.splice(i,3);i-=3}}if(i.length)for(let r=0,n;r<t.length;r++)if(n=t[r]){for(let t=0;t<i.length;t++)if(i[t].eq(n,e)){if(i==this.local)i=this.local.slice();i.splice(t--,1)}}if(r==this.children&&i==this.local)return this;return i.length||r.length?new lu(i,r):ou}forChild(t,e){if(this==ou)return this;if(e.isLeaf)return lu.empty;let r,i;for(let e=0;e<this.children.length;e+=3)if(this.children[e]>=t){if(this.children[e]==t)r=this.children[e+2];break}let n=t+1,s=n+e.content.size;for(let t=0;t<this.local.length;t++){let e=this.local[t];if(e.from<s&&e.to>n&&e.type instanceof eu){let t=Math.max(n,e.from)-n,r=Math.min(s,e.to)-n;if(t<r)(i||(i=[])).push(e.copy(t,r))}}if(i){let t=new lu(i.sort(mu),nu);return r?new uu([t,r]):t}return r||ou}eq(t){if(this==t)return true;if(!(t instanceof lu)||this.local.length!=t.local.length||this.children.length!=t.children.length)return false;for(let e=0;e<this.local.length;e++)if(!this.local[e].eq(t.local[e]))return false;for(let e=0;e<this.children.length;e+=3)if(this.children[e]!=t.children[e]||this.children[e+1]!=t.children[e+1]||!this.children[e+2].eq(t.children[e+2]))return false;return true}locals(t){return wu(this.localsInner(t))}localsInner(t){if(this==ou)return nu;if(t.inlineContent||!this.local.some(eu.is))return this.local;let e=[];for(let t=0;t<this.local.length;t++){if(!(this.local[t].type instanceof eu))e.push(this.local[t])}return e}forEachSet(t){t(this)}}lu.empty=new lu([],[]);lu.removeOverlap=wu;const ou=lu.empty;class uu{constructor(t){this.members=t}map(t,e){const r=this.members.map((r=>r.map(t,e,su)));return uu.from(r)}forChild(t,e){if(e.isLeaf)return lu.empty;let r=[];for(let i=0;i<this.members.length;i++){let n=this.members[i].forChild(t,e);if(n==ou)continue;if(n instanceof uu)r=r.concat(n.members);else r.push(n)}return uu.from(r)}eq(t){if(!(t instanceof uu)||t.members.length!=this.members.length)return false;for(let e=0;e<this.members.length;e++)if(!this.members[e].eq(t.members[e]))return false;return true}locals(t){let e,r=true;for(let i=0;i<this.members.length;i++){let n=this.members[i].localsInner(t);if(!n.length)continue;if(!e){e=n}else{if(r){e=e.slice();r=false}for(let t=0;t<n.length;t++)e.push(n[t])}}return e?wu(r?e:e.sort(mu)):nu}static from(t){switch(t.length){case 0:return ou;case 1:return t[0];default:return new uu(t.every((t=>t instanceof lu))?t:t.reduce(((t,e)=>t.concat(e instanceof lu?e:e.members)),[]))}}forEachSet(t){for(let e=0;e<this.members.length;e++)this.members[e].forEachSet(t)}}function fu(t,e,r,i,n,s,l){let o=t.slice();for(let t=0,e=s;t<r.maps.length;t++){let i=0;r.maps[t].forEach(((t,r,n,s)=>{let l=s-n-(r-t);for(let n=0;n<o.length;n+=3){let s=o[n+1];if(s<0||t>s+e-i)continue;let u=o[n]+e-i;if(r>=u){o[n+1]=t<=u?-2:-1}else if(t>=e&&l){o[n]+=l;o[n+1]+=l}}i+=l}));e=r.maps[t].map(e,-1)}let u=false;for(let e=0;e<o.length;e+=3)if(o[e+1]<0){if(o[e+1]==-2){u=true;o[e+1]=-1;continue}let f=r.map(t[e]+s),h=f-n;if(h<0||h>=i.content.size){u=true;continue}let a=r.map(t[e+1]+s,-1),c=a-n;let{index:d,offset:p}=i.content.findIndex(h);let m=i.maybeChild(d);if(m&&p==h&&p+m.nodeSize==c){let i=o[e+2].mapInner(r,m,f+1,t[e]+s+1,l);if(i!=ou){o[e]=h;o[e+1]=c;o[e+2]=i}else{o[e+1]=-2;u=true}}else{u=true}}if(u){let u=au(o,t,e,r,n,s,l);let f=pu(u,i,0,l);e=f.local;for(let t=0;t<o.length;t+=3)if(o[t+1]<0){o.splice(t,3);t-=3}for(let t=0,e=0;t<f.children.length;t+=3){let r=f.children[t];while(e<o.length&&o[e]<r)e+=3;o.splice(e,0,f.children[t],f.children[t+1],f.children[t+2])}}return new lu(e.sort(mu),o)}function hu(t,e){if(!e||!t.length)return t;let r=[];for(let i=0;i<t.length;i++){let n=t[i];r.push(new iu(n.from+e,n.to+e,n.type))}return r}function au(t,e,r,i,n,s,l){function o(t,e){for(let s=0;s<t.local.length;s++){let o=t.local[s].map(i,n,e);if(o)r.push(o);else if(l.onRemove)l.onRemove(t.local[s].spec)}for(let r=0;r<t.children.length;r+=3)o(t.children[r+2],t.children[r]+e+1)}for(let r=0;r<t.length;r+=3)if(t[r+1]==-1)o(t[r+2],e[r]+s+1);return r}function cu(t,e,r){if(e.isLeaf)return null;let i=r+e.nodeSize,n=null;for(let e=0,s;e<t.length;e++){if((s=t[e])&&s.from>r&&s.to<i){(n||(n=[])).push(s);t[e]=null}}return n}function du(t){let e=[];for(let r=0;r<t.length;r++)if(t[r]!=null)e.push(t[r]);return e}function pu(t,e,r,i){let n=[],s=false;e.forEach(((e,l)=>{let o=cu(t,e,l+r);if(o){s=true;let t=pu(o,e,r+l+1,i);if(t!=ou)n.push(l,l+e.nodeSize,t)}}));let l=hu(s?du(t):t,-r).sort(mu);for(let t=0;t<l.length;t++)if(!l[t].type.valid(e,l[t])){if(i.onRemove)i.onRemove(l[t].spec);l.splice(t--,1)}return l.length||n.length?new lu(l,n):ou}function mu(t,e){return t.from-e.from||t.to-e.to}function wu(t){let e=t;for(let r=0;r<e.length-1;r++){let i=e[r];if(i.from!=i.to)for(let n=r+1;n<e.length;n++){let s=e[n];if(s.from==i.from){if(s.to!=i.to){if(e==t)e=t.slice();e[n]=s.copy(s.from,i.to);gu(e,n+1,s.copy(i.to,s.to))}continue}else{if(s.from<i.to){if(e==t)e=t.slice();e[r]=i.copy(i.from,s.from);gu(e,n,i.copy(s.from,i.to))}break}}}return e}function gu(t,e,r){while(e<t.length&&mu(r,t[e])>0)e++;t.splice(e,0,r)}function bu(t){let e=[];t.someProp("decorations",(r=>{let i=r(t.state);if(i&&i!=ou)e.push(i)}));if(t.cursorWrapper)e.push(lu.create(t.state.doc,[t.cursorWrapper.deco]));return uu.from(e)}const ku={childList:true,characterData:true,characterDataOldValue:true,attributes:true,attributeOldValue:true,subtree:true};const Du=Vn&&Gn<=11;class vu{constructor(){this.anchorNode=null;this.anchorOffset=0;this.focusNode=null;this.focusOffset=0}set(t){this.anchorNode=t.anchorNode;this.anchorOffset=t.anchorOffset;this.focusNode=t.focusNode;this.focusOffset=t.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(t){return t.anchorNode==this.anchorNode&&t.anchorOffset==this.anchorOffset&&t.focusNode==this.focusNode&&t.focusOffset==this.focusOffset}}class yu{constructor(t,e){this.view=t;this.handleDOMChange=e;this.queue=[];this.flushingSoon=-1;this.observer=null;this.currentSelection=new vu;this.onCharData=null;this.suppressingSelectionUpdates=false;this.lastChangedTextNode=null;this.observer=window.MutationObserver&&new window.MutationObserver((t=>{for(let e=0;e<t.length;e++)this.queue.push(t[e]);if(Vn&&Gn<=11&&t.some((t=>t.type=="childList"&&t.removedNodes.length||t.type=="characterData"&&t.oldValue.length>t.target.nodeValue.length)))this.flushSoon();else this.flush()}));if(Du){this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue});this.flushSoon()}}this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){if(this.flushingSoon<0)this.flushingSoon=window.setTimeout((()=>{this.flushingSoon=-1;this.flush()}),20)}forceFlush(){if(this.flushingSoon>-1){window.clearTimeout(this.flushingSoon);this.flushingSoon=-1;this.flush()}}start(){if(this.observer){this.observer.takeRecords();this.observer.observe(this.view.dom,ku)}if(this.onCharData)this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData);this.connectSelection()}stop(){if(this.observer){let t=this.observer.takeRecords();if(t.length){for(let e=0;e<t.length;e++)this.queue.push(t[e]);window.setTimeout((()=>this.flush()),20)}this.observer.disconnect()}if(this.onCharData)this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData);this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=true;setTimeout((()=>this.suppressingSelectionUpdates=false),50)}onSelectionChange(){if(!Cl(this.view))return;if(this.suppressingSelectionUpdates)return bl(this.view);if(Vn&&Gn<=11&&!this.view.state.selection.empty){let t=this.view.domSelectionRange();if(t.focusNode&&$n(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset))return this.flushSoon()}this.flush()}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(t){if(!t.focusNode)return true;let e=new Set,r;for(let r=t.focusNode;r;r=An(r))e.add(r);for(let i=t.anchorNode;i;i=An(i))if(e.has(i)){r=i;break}let i=r&&this.view.docView.nearestDesc(r);if(i&&i.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r})){this.setCurSelection();return true}}pendingRecords(){if(this.observer)for(let t of this.observer.takeRecords())this.queue.push(t);return this.queue}flush(){let{view:t}=this;if(!t.docView||this.flushingSoon>-1)return;let e=this.pendingRecords();if(e.length)this.queue=[];let r=t.domSelectionRange();let i=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&Cl(t)&&!this.ignoreSelectionChange(r);let n=-1,s=-1,l=false,o=[];if(t.editable){for(let t=0;t<e.length;t++){let r=this.registerMutation(e[t],o);if(r){n=n<0?r.from:Math.min(r.from,n);s=s<0?r.to:Math.max(r.to,s);if(r.typeOver)l=true}}}if(Xn&&o.length){let e=o.filter((t=>t.nodeName=="BR"));if(e.length==2){let[t,r]=e;if(t.parentNode&&t.parentNode.parentNode==r.parentNode)r.remove();else t.remove()}else{let{focusNode:r}=this.currentSelection;for(let i of e){let e=i.parentNode;if(e&&e.nodeName=="LI"&&(!r||Cu(t,r)!=e))i.remove()}}}let u=null;if(n<0&&i&&t.input.lastFocus>Date.now()-200&&Math.max(t.input.lastTouch,t.input.lastClick.time)<Date.now()-300&&Tn(r)&&(u=wl(t))&&u.eq(Qi.near(t.state.doc.resolve(0),1))){t.input.lastFocus=0;bl(t);this.currentSelection.set(r);t.scrollToSelection()}else if(n>-1||i){if(n>-1){t.docView.markDirty(n,s);Mu(t)}this.handleDOMChange(n,s,l,o);if(t.docView&&t.docView.dirty)t.updateState(t.state);else if(!this.currentSelection.eq(r))bl(t);this.currentSelection.set(r)}}registerMutation(t,e){if(e.indexOf(t.target)>-1)return null;let r=this.view.docView.nearestDesc(t.target);if(t.type=="attributes"&&(r==this.view.docView||t.attributeName=="contenteditable"||t.attributeName=="style"&&!t.oldValue&&!t.target.getAttribute("style")))return null;if(!r||r.ignoreMutation(t))return null;if(t.type=="childList"){for(let r=0;r<t.addedNodes.length;r++){let i=t.addedNodes[r];e.push(i);if(i.nodeType==3)this.lastChangedTextNode=i}if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(t.target))return{from:r.posBefore,to:r.posAfter};let i=t.previousSibling,n=t.nextSibling;if(Vn&&Gn<=11&&t.addedNodes.length){for(let e=0;e<t.addedNodes.length;e++){let{previousSibling:r,nextSibling:s}=t.addedNodes[e];if(!r||Array.prototype.indexOf.call(t.addedNodes,r)<0)i=r;if(!s||Array.prototype.indexOf.call(t.addedNodes,s)<0)n=s}}let s=i&&i.parentNode==t.target?xn(i)+1:0;let l=r.localPosFromDOM(t.target,s,-1);let o=n&&n.parentNode==t.target?xn(n):t.target.childNodes.length;let u=r.localPosFromDOM(t.target,o,1);return{from:l,to:u}}else if(t.type=="attributes"){return{from:r.posAtStart-r.border,to:r.posAtEnd+r.border}}else{this.lastChangedTextNode=t.target;return{from:r.posAtStart,to:r.posAtEnd,typeOver:t.target.nodeValue==t.oldValue}}}}let Fu=new WeakMap;let Eu=false;function Mu(t){if(Fu.has(t))return;Fu.set(t,null);if(["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace)!==-1){t.requiresGeckoHackNode=Xn;if(Eu)return;console["warn"]("ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package.");Eu=true}}function xu(t,e){let r=e.startContainer,i=e.startOffset;let n=e.endContainer,s=e.endOffset;let l=t.domAtPos(t.state.selection.anchor);if($n(l.node,l.offset,n,s))[r,i,n,s]=[n,s,r,i];return{anchorNode:r,anchorOffset:i,focusNode:n,focusOffset:s}}function Au(t,e){if(e.getComposedRanges){let r=e.getComposedRanges(t.root)[0];if(r)return xu(t,r)}let r;function i(t){t.preventDefault();t.stopImmediatePropagation();r=t.getTargetRanges()[0]}t.dom.addEventListener("beforeinput",i,true);document.execCommand("indent");t.dom.removeEventListener("beforeinput",i,true);return r?xu(t,r):null}function Cu(t,e){for(let r=e.parentNode;r&&r!=t.dom;r=r.parentNode){let e=t.docView.nearestDesc(r,true);if(e&&e.node.isBlock)return r}return null}function Su(t,e,r){let{node:i,fromOffset:n,toOffset:s,from:l,to:o}=t.docView.parseRange(e,r);let u=t.domSelectionRange();let f;let h=u.anchorNode;if(h&&t.dom.contains(h.nodeType==1?h:h.parentNode)){f=[{node:h,offset:u.anchorOffset}];if(!Tn(u))f.push({node:u.focusNode,offset:u.focusOffset})}if(Qn&&t.input.lastKeyCode===8){for(let t=s;t>n;t--){let e=i.childNodes[t-1],r=e.pmViewDesc;if(e.nodeName=="BR"&&!r){s=t;break}if(!r||r.size)break}}let a=t.state.doc;let c=t.someProp("domParser")||br.fromSchema(t.state.schema);let d=a.resolve(l);let p=null,m=c.parse(i,{topNode:d.parent,topMatch:d.parent.contentMatchAt(d.index()),topOpen:true,from:n,to:s,preserveWhitespace:d.parent.type.whitespace=="pre"?"full":true,findPositions:f,ruleFromNode:Ou,context:d});if(f&&f[0].pos!=null){let t=f[0].pos,e=f[1]&&f[1].pos;if(e==null)e=t;p={anchor:t+l,head:e+l}}return{doc:m,sel:p,from:l,to:o}}function Ou(t){let e=t.pmViewDesc;if(e){return e.parseRule()}else if(t.nodeName=="BR"&&t.parentNode){if(es&&/^(ul|ol)$/i.test(t.parentNode.nodeName)){let t=document.createElement("div");t.appendChild(document.createElement("li"));return{skip:t}}else if(t.parentNode.lastChild==t||es&&/^(tr|table)$/i.test(t.parentNode.nodeName)){return{ignore:true}}}else if(t.nodeName=="IMG"&&t.getAttribute("mark-placeholder")){return{ignore:true}}return null}const $u=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function _u(t,e,r,i,n){let s=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);t.input.compositionPendingChanges=0;if(e<0){let e=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null;let r=wl(t,e);if(r&&!t.state.selection.eq(r)){if(Qn&&ss&&t.input.lastKeyCode===13&&Date.now()-100<t.input.lastKeyCodeTime&&t.someProp("handleKeyDown",(e=>e(t,In(13,"Enter")))))return;let i=t.state.tr.setSelection(r);if(e=="pointer")i.setMeta("pointer",true);else if(e=="key")i.scrollIntoView();if(s)i.setMeta("composition",s);t.dispatch(i)}return}let l=t.state.doc.resolve(e);let o=l.sharedDepth(r);e=l.before(o+1);r=t.state.doc.resolve(r).after(o+1);let u=t.state.selection;let f=Su(t,e,r);let h=t.state.doc,a=h.slice(f.from,f.to);let c,d;if(t.input.lastKeyCode===8&&Date.now()-100<t.input.lastKeyCodeTime){c=t.state.selection.to;d="end"}else{c=t.state.selection.from;d="start"}t.input.lastKeyCode=null;let p=qu(a.content,f.doc.content,f.from,c,d);if(p)t.input.domChangeCount++;if((rs&&t.input.lastIOSEnter>Date.now()-225||ss)&&n.some((t=>t.nodeType==1&&!$u.test(t.nodeName)))&&(!p||p.endA>=p.endB)&&t.someProp("handleKeyDown",(e=>e(t,In(13,"Enter"))))){t.input.lastIOSEnter=0;return}if(!p){if(i&&u instanceof nn&&!u.empty&&u.$head.sameParent(u.$anchor)&&!t.composing&&!(f.sel&&f.sel.anchor!=f.sel.head)){p={start:u.from,endA:u.to,endB:u.to}}else{if(f.sel){let e=Bu(t,t.state.doc,f.sel);if(e&&!e.eq(t.state.selection)){let r=t.state.tr.setSelection(e);if(s)r.setMeta("composition",s);t.dispatch(r)}}return}}if(t.state.selection.from<t.state.selection.to&&p.start==p.endB&&t.state.selection instanceof nn){if(p.start>t.state.selection.from&&p.start<=t.state.selection.from+2&&t.state.selection.from>=f.from){p.start=t.state.selection.from}else if(p.endA<t.state.selection.to&&p.endA>=t.state.selection.to-2&&t.state.selection.to<=f.to){p.endB+=t.state.selection.to-p.endA;p.endA=t.state.selection.to}}if(Vn&&Gn<=11&&p.endB==p.start+1&&p.endA==p.start&&p.start>f.from&&f.doc.textBetween(p.start-f.from-1,p.start-f.from+1)==" "){p.start--;p.endA--;p.endB--}let m=f.doc.resolveNoCache(p.start-f.from);let w=f.doc.resolveNoCache(p.endB-f.from);let g=h.resolve(p.start);let b=m.sameParent(w)&&m.parent.inlineContent&&g.end()>=p.endA;let k;if((rs&&t.input.lastIOSEnter>Date.now()-225&&(!b||n.some((t=>t.nodeName=="DIV"||t.nodeName=="P")))||!b&&m.pos<f.doc.content.size&&!m.sameParent(w)&&(k=Qi.findFrom(f.doc.resolve(m.pos+1),1,true))&&k.head==w.pos)&&t.someProp("handleKeyDown",(e=>e(t,In(13,"Enter"))))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>p.start&&ju(h,p.start,p.endA,m,w)&&t.someProp("handleKeyDown",(e=>e(t,In(8,"Backspace"))))){if(ss&&Qn)t.domObserver.suppressSelectionUpdates();return}if(Qn&&p.endB==p.start)t.input.lastChromeDelete=Date.now();if(ss&&!b&&m.start()!=w.start()&&w.parentOffset==0&&m.depth==w.depth&&f.sel&&f.sel.anchor==f.sel.head&&f.sel.head==p.endA){p.endB-=2;w=f.doc.resolveNoCache(p.endB-f.from);setTimeout((()=>{t.someProp("handleKeyDown",(function(e){return e(t,In(13,"Enter"))}))}),20)}let D=p.start,v=p.endA;let y,F,E;if(b){if(m.pos==w.pos){if(Vn&&Gn<=11&&m.parentOffset==0){t.domObserver.suppressSelectionUpdates();setTimeout((()=>bl(t)),20)}y=t.state.tr.delete(D,v);F=h.resolve(p.start).marksAcross(h.resolve(p.endA))}else if(p.endA==p.endB&&(E=Ru(m.parent.content.cut(m.parentOffset,w.parentOffset),g.parent.content.cut(g.parentOffset,p.endA-g.start())))){y=t.state.tr;if(E.type=="add")y.addMark(D,v,E.mark);else y.removeMark(D,v,E.mark)}else if(m.parent.child(m.index()).isText&&m.index()==w.index()-(w.textOffset?0:1)){let e=m.parent.textBetween(m.parentOffset,w.parentOffset);if(t.someProp("handleTextInput",(r=>r(t,D,v,e))))return;y=t.state.tr.insertText(e,D,v)}}if(!y)y=t.state.tr.replace(D,v,f.doc.slice(p.start-f.from,p.endB-f.from));if(f.sel){let e=Bu(t,y.doc,f.sel);if(e&&!(Qn&&t.composing&&e.empty&&(p.start!=p.endB||t.input.lastChromeDelete<Date.now()-100)&&(e.head==D||e.head==y.mapping.map(v)-1)||Vn&&e.empty&&e.head==D))y.setSelection(e)}if(F)y.ensureMarks(F);if(s)y.setMeta("composition",s);t.dispatch(y.scrollIntoView())}function Bu(t,e,r){if(Math.max(r.anchor,r.head)>e.content.size)return null;return Al(t,e.resolve(r.anchor),e.resolve(r.head))}function Ru(t,e){let r=t.firstChild.marks,i=e.firstChild.marks;let n=r,s=i,l,o,u;for(let t=0;t<i.length;t++)n=i[t].removeFromSet(n);for(let t=0;t<r.length;t++)s=r[t].removeFromSet(s);if(n.length==1&&s.length==0){o=n[0];l="add";u=t=>t.mark(o.addToSet(t.marks))}else if(n.length==0&&s.length==1){o=s[0];l="remove";u=t=>t.mark(o.removeFromSet(t.marks))}else{return null}let f=[];for(let t=0;t<e.childCount;t++)f.push(u(e.child(t)));if(be.from(f).eq(t))return{mark:o,type:l}}function ju(t,e,r,i,n){if(r-e<=n.pos-i.pos||Nu(i,true,false)<n.pos)return false;let s=t.resolve(e);if(!i.parent.isTextblock){let t=s.nodeAfter;return t!=null&&r==e+t.nodeSize}if(s.parentOffset<s.parent.content.size||!s.parent.isTextblock)return false;let l=t.resolve(Nu(s,true,true));if(!l.parent.isTextblock||l.pos>r||Nu(l,true,false)<r)return false;return i.parent.content.cut(i.parentOffset).eq(l.parent.content)}function Nu(t,e,r){let i=t.depth,n=e?t.end():t.pos;while(i>0&&(e||t.indexAfter(i)==t.node(i).childCount)){i--;n++;e=false}if(r){let e=t.node(i).maybeChild(t.indexAfter(i));while(e&&!e.isLeaf){e=e.firstChild;n++}}return n}function qu(t,e,r,i,n){let s=t.findDiffStart(e,r);if(s==null)return null;let{a:l,b:o}=t.findDiffEnd(e,r+t.size,r+e.size);if(n=="end"){let t=Math.max(0,s-Math.min(l,o));i-=l+t-s}if(l<s&&t.size<e.size){let t=i<=s&&i>=l?s-i:0;s-=t;if(s&&s<e.size&&zu(e.textBetween(s-1,s+1)))s+=t?1:-1;o=s+(o-l);l=s}else if(o<s){let e=i<=s&&i>=o?s-i:0;s-=e;if(s&&s<t.size&&zu(t.textBetween(s-1,s+1)))s+=e?1:-1;l=s+(l-o);o=s}return{start:s,endA:l,endB:o}}function zu(t){if(t.length!=2)return false;let e=t.charCodeAt(0),r=t.charCodeAt(1);return e>=56320&&e<=57343&&r>=55296&&r<=56319}class Tu{constructor(t,e){this._root=null;this.focused=false;this.trackWrites=null;this.mounted=false;this.markCursor=null;this.cursorWrapper=null;this.lastSelectedViewDesc=undefined;this.input=new go;this.prevDirectPlugins=[];this.pluginViews=[];this.requiresGeckoHackNode=false;this.dragging=null;this._props=e;this.state=e.state;this.directPlugins=e.plugins||[];this.directPlugins.forEach(Hu);this.dispatch=this.dispatch.bind(this);this.dom=t&&t.mount||document.createElement("div");if(t){if(t.appendChild)t.appendChild(this.dom);else if(typeof t=="function")t(this.dom);else if(t.mount)this.mounted=true}this.editable=Ju(this);Pu(this);this.nodeViews=Wu(this);this.docView=Gs(this.state.doc,Iu(this),bu(this),this.dom,this);this.domObserver=new yu(this,((t,e,r,i)=>_u(this,t,e,r,i)));this.domObserver.start();bo(this);this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let t=this._props;this._props={};for(let e in t)this._props[e]=t[e];this._props.state=this.state}return this._props}update(t){if(t.handleDOMEvents!=this._props.handleDOMEvents)vo(this);let e=this._props;this._props=t;if(t.plugins){t.plugins.forEach(Hu);this.directPlugins=t.plugins}this.updateStateInner(t.state,e)}setProps(t){let e={};for(let t in this._props)e[t]=this._props[t];e.state=this.state;for(let r in t)e[r]=t[r];this.update(e)}updateState(t){this.updateStateInner(t,this._props)}updateStateInner(t,e){var r;let i=this.state,n=false,s=false;if(t.storedMarks&&this.composing){Po(this);s=true}this.state=t;let l=i.plugins!=t.plugins||this._props.plugins!=e.plugins;if(l||this._props.plugins!=e.plugins||this._props.nodeViews!=e.nodeViews){let t=Wu(this);if(Uu(t,this.nodeViews)){this.nodeViews=t;n=true}}if(l||e.handleDOMEvents!=this._props.handleDOMEvents){vo(this)}this.editable=Ju(this);Pu(this);let o=bu(this),u=Iu(this);let f=i.plugins!=t.plugins&&!i.doc.eq(t.doc)?"reset":t.scrollToSelection>i.scrollToSelection?"to selection":"preserve";let h=n||!this.docView.matchesNode(t.doc,u,o);if(h||!t.selection.eq(i.selection))s=true;let a=f=="preserve"&&s&&this.dom.style.overflowAnchor==null&&ds(this);if(s){this.domObserver.stop();let e=h&&(Vn||Qn)&&!this.composing&&!i.selection.empty&&!t.selection.empty&&Lu(i.selection,t.selection);if(h){let r=Qn?this.trackWrites=this.domSelectionRange().focusNode:null;if(this.composing)this.input.compositionNode=Jo(this);if(n||!this.docView.update(t.doc,u,o,this)){this.docView.updateOuterDeco(u);this.docView.destroy();this.docView=Gs(t.doc,u,o,this.dom,this)}if(r&&!this.trackWrites)e=true}if(e||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&Ol(this))){bl(this,e)}else{Ml(this,t.selection);this.domObserver.setCurSelection()}this.domObserver.start()}this.updatePluginViews(i);if(((r=this.dragging)===null||r===void 0?void 0:r.node)&&!i.doc.eq(t.doc))this.updateDraggedNode(this.dragging,i);if(f=="reset"){this.dom.scrollTop=0}else if(f=="to selection"){this.scrollToSelection()}else if(a){ms(a)}}scrollToSelection(){let t=this.domSelectionRange().focusNode;if(!t||!this.dom.contains(t.nodeType==1?t:t.parentNode));else if(this.someProp("handleScrollToSelection",(t=>t(this))));else if(this.state.selection instanceof ln){let e=this.docView.domAfterPos(this.state.selection.from);if(e.nodeType==1)cs(this,e.getBoundingClientRect(),t)}else{cs(this,this.coordsAtPos(this.state.selection.head,1),t)}}destroyPluginViews(){let t;while(t=this.pluginViews.pop())if(t.destroy)t.destroy()}updatePluginViews(t){if(!t||t.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins;this.destroyPluginViews();for(let t=0;t<this.directPlugins.length;t++){let e=this.directPlugins[t];if(e.spec.view)this.pluginViews.push(e.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let e=this.state.plugins[t];if(e.spec.view)this.pluginViews.push(e.spec.view(this))}}else{for(let e=0;e<this.pluginViews.length;e++){let r=this.pluginViews[e];if(r.update)r.update(this,t)}}}updateDraggedNode(t,e){let r=t.node,i=-1;if(this.state.doc.nodeAt(r.from)==r.node){i=r.from}else{let t=r.from+(this.state.doc.content.size-e.doc.content.size);let n=t>0&&this.state.doc.nodeAt(t);if(n==r.node)i=t}this.dragging=new Xo(t.slice,t.move,i<0?undefined:ln.create(this.state.doc,i))}someProp(t,e){let r=this._props&&this._props[t],i;if(r!=null&&(i=e?e(r):r))return i;for(let r=0;r<this.directPlugins.length;r++){let n=this.directPlugins[r].props[t];if(n!=null&&(i=e?e(n):n))return i}let n=this.state.plugins;if(n)for(let r=0;r<n.length;r++){let s=n[r].props[t];if(s!=null&&(i=e?e(s):s))return i}}hasFocus(){if(Vn){let t=this.root.activeElement;if(t==this.dom)return true;if(!t||!this.dom.contains(t))return false;while(t&&this.dom!=t&&this.dom.contains(t)){if(t.contentEditable=="false")return false;t=t.parentElement}return true}return this.root.activeElement==this.dom}focus(){this.domObserver.stop();if(this.editable)bs(this.dom);bl(this);this.domObserver.start()}get root(){let t=this._root;if(t==null)for(let t=this.dom.parentNode;t;t=t.parentNode){if(t.nodeType==9||t.nodeType==11&&t.host){if(!t.getSelection)Object.getPrototypeOf(t).getSelection=()=>t.ownerDocument.getSelection();return this._root=t}}return t||document}updateRoot(){this._root=null}posAtCoords(t){return xs(this,t)}coordsAtPos(t,e=1){return Os(this,t,e)}domAtPos(t,e=0){return this.docView.domFromPos(t,e)}nodeDOM(t){let e=this.docView.descAt(t);return e?e.nodeDOM:null}posAtDOM(t,e,r=-1){let i=this.docView.posFromDOM(t,e,r);if(i==null)throw new RangeError("DOM position not inside the editor");return i}endOfTextblock(t,e){return Is(this,e||this.state,t)}pasteHTML(t,e){return Vo(this,"",t,false,e||new ClipboardEvent("paste"))}pasteText(t,e){return Vo(this,t,null,true,e||new ClipboardEvent("paste"))}destroy(){if(!this.docView)return;Do(this);this.destroyPluginViews();if(this.mounted){this.docView.update(this.state.doc,[],bu(this),this);this.dom.textContent=""}else if(this.dom.parentNode){this.dom.parentNode.removeChild(this.dom)}this.docView.destroy();this.docView=null;On()}get isDestroyed(){return this.docView==null}dispatchEvent(t){return Eo(this,t)}dispatch(t){let e=this._props.dispatchTransaction;if(e)e.call(this,t);else this.updateState(this.state.apply(t))}domSelectionRange(){let t=this.domSelection();if(!t)return{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0};return es&&this.root.nodeType===11&&Pn(this.dom.ownerDocument)==this.dom&&Au(this,t)||t}domSelection(){return this.root.getSelection()}}function Iu(t){let e=Object.create(null);e.class="ProseMirror";e.contenteditable=String(t.editable);t.someProp("attributes",(r=>{if(typeof r=="function")r=r(t.state);if(r)for(let t in r){if(t=="class")e.class+=" "+r[t];else if(t=="style")e.style=(e.style?e.style+";":"")+r[t];else if(!e[t]&&t!="contenteditable"&&t!="nodeName")e[t]=String(r[t])}}));if(!e.translate)e.translate="no";return[iu.node(0,t.state.doc.content.size,e)]}function Pu(t){if(t.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator";e.setAttribute("mark-placeholder","true");e.setAttribute("alt","");t.cursorWrapper={dom:e,deco:iu.widget(t.state.selection.from,e,{raw:true,marks:t.markCursor})}}else{t.cursorWrapper=null}}function Ju(t){return!t.someProp("editable",(e=>e(t.state)===false))}function Lu(t,e){let r=Math.min(t.$anchor.sharedDepth(t.head),e.$anchor.sharedDepth(e.head));return t.$anchor.start(r)!=e.$anchor.start(r)}function Wu(t){let e=Object.create(null);function r(t){for(let r in t)if(!Object.prototype.hasOwnProperty.call(e,r))e[r]=t[r]}t.someProp("nodeViews",r);t.someProp("markViews",r);return e}function Uu(t,e){let r=0,i=0;for(let i in t){if(t[i]!=e[i])return true;r++}for(let t in e)i++;return r!=i}function Hu(t){if(t.spec.state||t.spec.filterTransaction||t.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}const Zu=["p",0],Ku=["blockquote",0],Vu=["hr"],Gu=["pre",["code",0]],Xu=["br"];const Yu={doc:{content:"block+"},paragraph:{content:"inline*",group:"block",parseDOM:[{tag:"p"}],toDOM(){return Zu}},blockquote:{content:"block+",group:"block",defining:true,parseDOM:[{tag:"blockquote"}],toDOM(){return Ku}},horizontal_rule:{group:"block",parseDOM:[{tag:"hr"}],toDOM(){return Vu}},heading:{attrs:{level:{default:1,validate:"number"}},content:"inline*",group:"block",defining:true,parseDOM:[{tag:"h1",attrs:{level:1}},{tag:"h2",attrs:{level:2}},{tag:"h3",attrs:{level:3}},{tag:"h4",attrs:{level:4}},{tag:"h5",attrs:{level:5}},{tag:"h6",attrs:{level:6}}],toDOM(t){return["h"+t.attrs.level,0]}},code_block:{content:"text*",marks:"",group:"block",code:true,defining:true,parseDOM:[{tag:"pre",preserveWhitespace:"full"}],toDOM(){return Gu}},text:{group:"inline"},image:{inline:true,attrs:{src:{validate:"string"},alt:{default:null,validate:"string|null"},title:{default:null,validate:"string|null"}},group:"inline",draggable:true,parseDOM:[{tag:"img[src]",getAttrs(t){return{src:t.getAttribute("src"),title:t.getAttribute("title"),alt:t.getAttribute("alt")}}}],toDOM(t){let{src:e,alt:r,title:i}=t.attrs;return["img",{src:e,alt:r,title:i}]}},hard_break:{inline:true,group:"inline",selectable:false,parseDOM:[{tag:"br"}],toDOM(){return Xu}}};const Qu=["em",0],tf=["strong",0],ef=["code",0];const rf={link:{attrs:{href:{validate:"string"},title:{default:null,validate:"string|null"}},inclusive:false,parseDOM:[{tag:"a[href]",getAttrs(t){return{href:t.getAttribute("href"),title:t.getAttribute("title")}}}],toDOM(t){let{href:e,title:r}=t.attrs;return["a",{href:e,title:r},0]}},em:{parseDOM:[{tag:"i"},{tag:"em"},{style:"font-style=italic"},{style:"font-style=normal",clearMark:t=>t.type.name=="em"}],toDOM(){return Qu}},strong:{parseDOM:[{tag:"strong"},{tag:"b",getAttrs:t=>t.style.fontWeight!="normal"&&null},{style:"font-weight=400",clearMark:t=>t.type.name=="strong"},{style:"font-weight",getAttrs:t=>/^(bold(er)?|[5-9]\d{2,})$/.test(t)&&null}],toDOM(){return tf}},code:{parseDOM:[{tag:"code"}],toDOM(){return ef}}};const nf=new pr({nodes:Yu,marks:rf});const sf=["ol",0],lf=["ul",0],of=["li",0];const uf={attrs:{order:{default:1}},parseDOM:[{tag:"ol",getAttrs(t){return{order:t.hasAttribute("start")?+t.getAttribute("start"):1}}}],toDOM(t){return t.attrs.order==1?sf:["ol",{start:t.attrs.order},0]}};const ff={parseDOM:[{tag:"ul"}],toDOM(){return lf}};const hf={parseDOM:[{tag:"li"}],toDOM(){return of},defining:true};function af(t,e){let r={};for(let e in t)r[e]=t[e];for(let t in e)r[t]=e[t];return r}function cf(t,e,r){return t.append({ordered_list:af(uf,{content:"list_item+",group:r}),bullet_list:af(ff,{content:"list_item+",group:r}),list_item:af(hf,{content:e})})}function df(t,e=null){return function(r,i){let{$from:n,$to:s}=r.selection;let l=n.blockRange(s),o=false,u=l;if(!l)return false;if(l.depth>=2&&n.node(l.depth-1).type.compatibleContent(t)&&l.startIndex==0){if(n.index(l.depth-1)==0)return false;let t=r.doc.resolve(l.start-2);u=new Pe(t,t,l.depth);if(l.endIndex<l.parent.childCount)l=new Pe(n,r.doc.resolve(s.end(l.depth)),l.depth);o=true}let f=pi(u,t,e,l);if(!f)return false;if(i)i(pf(r.tr,l,f,o,t).scrollIntoView());return true}}function pf(t,e,r,i,n){let s=be.empty;for(let t=r.length-1;t>=0;t--)s=be.from(r[t].type.create(r[t].attrs,s));t.step(new li(e.start-(i?2:0),e.end,e.start,e.end,new Ee(s,0,0),r.length,true));let l=0;for(let t=0;t<r.length;t++)if(r[t].type==n)l=t+1;let o=r.length-l;let u=e.start+r.length-(i?2:0),f=e.parent;for(let r=e.startIndex,i=e.endIndex,n=true;r<i;r++,n=false){if(!n&&Ei(t.doc,u,o)){t.split(u,o);u+=2*o}u+=f.child(r).nodeSize}return t}function mf(t,e){return function(r,i){let{$from:n,$to:s,node:l}=r.selection;if(l&&l.isBlock||n.depth<2||!n.sameParent(s))return false;let o=n.node(-1);if(o.type!=t)return false;if(n.parent.content.size==0&&n.node(-1).childCount==n.indexAfter(-1)){if(n.depth==3||n.node(-3).type!=t||n.index(-2)!=n.node(-2).childCount-1)return false;if(i){let e=be.empty;let s=n.index(-1)?1:n.index(-2)?2:3;for(let t=n.depth-s;t>=n.depth-3;t--)e=be.from(n.node(t).copy(e));let l=n.indexAfter(-1)<n.node(-2).childCount?1:n.indexAfter(-2)<n.node(-3).childCount?2:3;e=e.append(be.from(t.createAndFill()));let o=n.before(n.depth-(s-1));let u=r.tr.replace(o,n.after(-l),new Ee(e,4-s,0));let f=-1;u.doc.nodesBetween(o,u.doc.content.size,((t,e)=>{if(f>-1)return false;if(t.isTextblock&&t.content.size==0)f=e+1}));if(f>-1)u.setSelection(Qi.near(u.doc.resolve(f)));i(u.scrollIntoView())}return true}let u=s.pos==n.end()?o.contentMatchAt(0).defaultType:null;let f=r.tr.delete(n.pos,s.pos);let h=u?[e?{type:t,attrs:e}:null,{type:u}]:undefined;if(!Ei(f.doc,n.pos,2,h))return false;if(i)i(f.split(n.pos,2,h).scrollIntoView());return true}}function wf(t){return function(e,r){let{$from:i,$to:n}=e.selection;let s=i.blockRange(n,(e=>e.childCount>0&&e.firstChild.type==t));if(!s)return false;if(!r)return true;if(i.node(s.depth-1).type==t)return gf(e,r,t,s);else return bf(e,r,s)}}function gf(t,e,r,i){let n=t.tr,s=i.end,l=i.$to.end(i.depth);if(s<l){n.step(new li(s-1,l,s,l,new Ee(be.from(r.create(null,i.parent.copy())),1,0),1,true));i=new Pe(n.doc.resolve(i.$from.pos),n.doc.resolve(l),i.depth)}const o=ci(i);if(o==null)return false;n.lift(i,o);let u=n.mapping.map(s,-1)-1;if(xi(n.doc,u))n.join(u);e(n.scrollIntoView());return true}function bf(t,e,r){let i=t.tr,n=r.parent;for(let t=r.end,e=r.endIndex-1,s=r.startIndex;e>s;e--){t-=n.child(e).nodeSize;i.delete(t-1,t+1)}let s=i.doc.resolve(r.start),l=s.nodeAfter;if(i.mapping.map(r.end)!=r.start+s.nodeAfter.nodeSize)return false;let o=r.startIndex==0,u=r.endIndex==n.childCount;let f=s.node(-1),h=s.index(-1);if(!f.canReplace(h+(o?0:1),h+1,l.content.append(u?be.empty:be.from(n))))return false;let a=s.pos,c=a+l.nodeSize;i.step(new li(a-(o?1:0),c+(u?1:0),a+1,c-1,new Ee((o?be.empty:be.from(n.copy(be.empty))).append(u?be.empty:be.from(n.copy(be.empty))),o?0:1,u?0:1),o?0:1));e(i.scrollIntoView());return true}function kf(t){return function(e,r){let{$from:i,$to:n}=e.selection;let s=i.blockRange(n,(e=>e.childCount>0&&e.firstChild.type==t));if(!s)return false;let l=s.startIndex;if(l==0)return false;let o=s.parent,u=o.child(l-1);if(u.type!=t)return false;if(r){let i=u.lastChild&&u.lastChild.type==o.type;let n=be.from(i?t.create():null);let l=new Ee(be.from(t.create(null,be.from(o.type.create(null,n)))),i?3:1,0);let f=s.start,h=s.end;r(e.tr.step(new li(f-(i?3:1),h,f,h,l,1,true)).scrollIntoView())}return true}}var Df={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"};var vf={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'};var yf=typeof navigator!="undefined"&&/Mac/.test(navigator.platform);var Ff=typeof navigator!="undefined"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var Ef=0;Ef<10;Ef++)Df[48+Ef]=Df[96+Ef]=String(Ef);for(var Ef=1;Ef<=24;Ef++)Df[Ef+111]="F"+Ef;for(var Ef=65;Ef<=90;Ef++){Df[Ef]=String.fromCharCode(Ef+32);vf[Ef]=String.fromCharCode(Ef)}for(var Mf in Df)if(!vf.hasOwnProperty(Mf))vf[Mf]=Df[Mf];function xf(t){var e=yf&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||Ff&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified";var r=!e&&t.key||(t.shiftKey?vf:Df)[t.keyCode]||t.key||"Unidentified";if(r=="Esc")r="Escape";if(r=="Del")r="Delete";if(r=="Left")r="ArrowLeft";if(r=="Up")r="ArrowUp";if(r=="Right")r="ArrowRight";if(r=="Down")r="ArrowDown";return r}const Af=typeof navigator!="undefined"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):false;function Cf(t){let e=t.split(/-(?!$)/),r=e[e.length-1];if(r=="Space")r=" ";let i,n,s,l;for(let t=0;t<e.length-1;t++){let r=e[t];if(/^(cmd|meta|m)$/i.test(r))l=true;else if(/^a(lt)?$/i.test(r))i=true;else if(/^(c|ctrl|control)$/i.test(r))n=true;else if(/^s(hift)?$/i.test(r))s=true;else if(/^mod$/i.test(r)){if(Af)l=true;else n=true}else throw new Error("Unrecognized modifier name: "+r)}if(i)r="Alt-"+r;if(n)r="Ctrl-"+r;if(l)r="Meta-"+r;if(s)r="Shift-"+r;return r}function Sf(t){let e=Object.create(null);for(let r in t)e[Cf(r)]=t[r];return e}function Of(t,e,r=true){if(e.altKey)t="Alt-"+t;if(e.ctrlKey)t="Ctrl-"+t;if(e.metaKey)t="Meta-"+t;if(r&&e.shiftKey)t="Shift-"+t;return t}function $f(t){return new yn({props:{handleKeyDown:_f(t)}})}function _f(t){let e=Sf(t);return function(t,r){let i=xf(r),n,s=e[Of(i,r)];if(s&&s(t.state,t.dispatch,t))return true;if(i.length==1&&i!=" "){if(r.shiftKey){let n=e[Of(i,r,false)];if(n&&n(t.state,t.dispatch,t))return true}if((r.shiftKey||r.altKey||r.metaKey||i.charCodeAt(0)>127)&&(n=Df[r.keyCode])&&n!=i){let i=e[Of(n,r)];if(i&&i(t.state,t.dispatch,t))return true}}return false}}var Bf=200;var Rf=function t(){};Rf.prototype.append=function t(e){if(!e.length){return this}e=Rf.from(e);return!this.length&&e||e.length<Bf&&this.leafAppend(e)||this.length<Bf&&e.leafPrepend(this)||this.appendInner(e)};Rf.prototype.prepend=function t(e){if(!e.length){return this}return Rf.from(e).append(this)};Rf.prototype.appendInner=function t(e){return new Nf(this,e)};Rf.prototype.slice=function t(e,r){if(e===void 0)e=0;if(r===void 0)r=this.length;if(e>=r){return Rf.empty}return this.sliceInner(Math.max(0,e),Math.min(this.length,r))};Rf.prototype.get=function t(e){if(e<0||e>=this.length){return undefined}return this.getInner(e)};Rf.prototype.forEach=function t(e,r,i){if(r===void 0)r=0;if(i===void 0)i=this.length;if(r<=i){this.forEachInner(e,r,i,0)}else{this.forEachInvertedInner(e,r,i,0)}};Rf.prototype.map=function t(e,r,i){if(r===void 0)r=0;if(i===void 0)i=this.length;var n=[];this.forEach((function(t,r){return n.push(e(t,r))}),r,i);return n};Rf.from=function t(e){if(e instanceof Rf){return e}return e&&e.length?new jf(e):Rf.empty};var jf=function(t){function e(e){t.call(this);this.values=e}if(t)e.__proto__=t;e.prototype=Object.create(t&&t.prototype);e.prototype.constructor=e;var r={length:{configurable:true},depth:{configurable:true}};e.prototype.flatten=function t(){return this.values};e.prototype.sliceInner=function t(r,i){if(r==0&&i==this.length){return this}return new e(this.values.slice(r,i))};e.prototype.getInner=function t(e){return this.values[e]};e.prototype.forEachInner=function t(e,r,i,n){for(var s=r;s<i;s++){if(e(this.values[s],n+s)===false){return false}}};e.prototype.forEachInvertedInner=function t(e,r,i,n){for(var s=r-1;s>=i;s--){if(e(this.values[s],n+s)===false){return false}}};e.prototype.leafAppend=function t(r){if(this.length+r.length<=Bf){return new e(this.values.concat(r.flatten()))}};e.prototype.leafPrepend=function t(r){if(this.length+r.length<=Bf){return new e(r.flatten().concat(this.values))}};r.length.get=function(){return this.values.length};r.depth.get=function(){return 0};Object.defineProperties(e.prototype,r);return e}(Rf);Rf.empty=new jf([]);var Nf=function(t){function e(e,r){t.call(this);this.left=e;this.right=r;this.length=e.length+r.length;this.depth=Math.max(e.depth,r.depth)+1}if(t)e.__proto__=t;e.prototype=Object.create(t&&t.prototype);e.prototype.constructor=e;e.prototype.flatten=function t(){return this.left.flatten().concat(this.right.flatten())};e.prototype.getInner=function t(e){return e<this.left.length?this.left.get(e):this.right.get(e-this.left.length)};e.prototype.forEachInner=function t(e,r,i,n){var s=this.left.length;if(r<s&&this.left.forEachInner(e,r,Math.min(i,s),n)===false){return false}if(i>s&&this.right.forEachInner(e,Math.max(r-s,0),Math.min(this.length,i)-s,n+s)===false){return false}};e.prototype.forEachInvertedInner=function t(e,r,i,n){var s=this.left.length;if(r>s&&this.right.forEachInvertedInner(e,r-s,Math.max(i,s)-s,n+s)===false){return false}if(i<s&&this.left.forEachInvertedInner(e,Math.min(r,s),i,n)===false){return false}};e.prototype.sliceInner=function t(e,r){if(e==0&&r==this.length){return this}var i=this.left.length;if(r<=i){return this.left.slice(e,r)}if(e>=i){return this.right.slice(e-i,r-i)}return this.left.slice(e,i).append(this.right.slice(0,r-i))};e.prototype.leafAppend=function t(r){var i=this.right.leafAppend(r);if(i){return new e(this.left,i)}};e.prototype.leafPrepend=function t(r){var i=this.left.leafPrepend(r);if(i){return new e(i,this.right)}};e.prototype.appendInner=function t(r){if(this.left.depth>=Math.max(this.right.depth,r.depth)+1){return new e(this.left,new e(this.right,r))}return new e(this,r)};return e}(Rf);const qf=500;class zf{constructor(t,e){this.items=t;this.eventCount=e}popEvent(t,e){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--){let t=this.items.get(r-1);if(t.selection){--r;break}}let i,n;if(e){i=this.remapping(r,this.items.length);n=i.maps.length}let s=t.tr;let l,o;let u=[],f=[];this.items.forEach(((t,e)=>{if(!t.step){if(!i){i=this.remapping(r,e+1);n=i.maps.length}n--;f.push(t);return}if(i){f.push(new If(t.map));let e=t.step.map(i.slice(n)),r;if(e&&s.maybeStep(e).doc){r=s.mapping.maps[s.mapping.maps.length-1];u.push(new If(r,undefined,undefined,u.length+f.length))}n--;if(r)i.appendMap(r,n)}else{s.maybeStep(t.step)}if(t.selection){l=i?t.selection.map(i.slice(n)):t.selection;o=new zf(this.items.slice(0,r).append(f.reverse().concat(u)),this.eventCount-1);return false}}),this.items.length,0);return{remaining:o,transform:s,selection:l}}addTransform(t,e,r,i){let n=[],s=this.eventCount;let l=this.items,o=!i&&l.length?l.get(l.length-1):null;for(let r=0;r<t.steps.length;r++){let u=t.steps[r].invert(t.docs[r]);let f=new If(t.mapping.maps[r],u,e),h;if(h=o&&o.merge(f)){f=h;if(r)n.pop();else l=l.slice(0,l.length-1)}n.push(f);if(e){s++;e=undefined}if(!i)o=f}let u=s-r.depth;if(u>Jf){l=Tf(l,u);s-=u}return new zf(l.append(n),s)}remapping(t,e){let r=new Gr;this.items.forEach(((e,i)=>{let n=e.mirrorOffset!=null&&i-e.mirrorOffset>=t?r.maps.length-e.mirrorOffset:undefined;r.appendMap(e.map,n)}),t,e);return r}addMaps(t){if(this.eventCount==0)return this;return new zf(this.items.append(t.map((t=>new If(t)))),this.eventCount)}rebased(t,e){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-e);let n=t.mapping;let s=t.steps.length;let l=this.eventCount;this.items.forEach((t=>{if(t.selection)l--}),i);let o=e;this.items.forEach((e=>{let i=n.getMirror(--o);if(i==null)return;s=Math.min(s,i);let u=n.maps[i];if(e.step){let s=t.steps[i].invert(t.docs[i]);let f=e.selection&&e.selection.map(n.slice(o+1,i));if(f)l++;r.push(new If(u,s,f))}else{r.push(new If(u))}}),i);let u=[];for(let t=e;t<s;t++)u.push(new If(n.maps[t]));let f=this.items.slice(0,i).append(u).append(r);let h=new zf(f,l);if(h.emptyItemCount()>qf)h=h.compress(this.items.length-r.length);return h}emptyItemCount(){let t=0;this.items.forEach((e=>{if(!e.step)t++}));return t}compress(t=this.items.length){let e=this.remapping(0,t),r=e.maps.length;let i=[],n=0;this.items.forEach(((s,l)=>{if(l>=t){i.push(s);if(s.selection)n++}else if(s.step){let t=s.step.map(e.slice(r)),l=t&&t.getMap();r--;if(l)e.appendMap(l,r);if(t){let o=s.selection&&s.selection.map(e.slice(r));if(o)n++;let u=new If(l.invert(),t,o),f,h=i.length-1;if(f=i.length&&i[h].merge(u))i[h]=f;else i.push(u)}}else if(s.map){r--}}),this.items.length,0);return new zf(Rf.from(i.reverse()),n)}}zf.empty=new zf(Rf.empty,0);function Tf(t,e){let r;t.forEach(((t,i)=>{if(t.selection&&e--==0){r=i;return false}}));return t.slice(r)}class If{constructor(t,e,r,i){this.map=t;this.step=e;this.selection=r;this.mirrorOffset=i}merge(t){if(this.step&&t.step&&!t.selection){let e=t.step.merge(this.step);if(e)return new If(e.getMap().invert(),e,this.selection)}}}class Pf{constructor(t,e,r,i,n){this.done=t;this.undone=e;this.prevRanges=r;this.prevTime=i;this.prevComposition=n}}const Jf=20;function Lf(t,e,r,i){let n=r.getMeta(Xf),s;if(n)return n.historyState;if(r.getMeta(Yf))t=new Pf(t.done,t.undone,null,0,-1);let l=r.getMeta("appendedTransaction");if(r.steps.length==0){return t}else if(l&&l.getMeta(Xf)){if(l.getMeta(Xf).redo)return new Pf(t.done.addTransform(r,undefined,i,Gf(e)),t.undone,Uf(r.mapping.maps[r.steps.length-1]),t.prevTime,t.prevComposition);else return new Pf(t.done,t.undone.addTransform(r,undefined,i,Gf(e)),null,t.prevTime,t.prevComposition)}else if(r.getMeta("addToHistory")!==false&&!(l&&l.getMeta("addToHistory")===false)){let n=r.getMeta("composition");let s=t.prevTime==0||!l&&t.prevComposition!=n&&(t.prevTime<(r.time||0)-i.newGroupDelay||!Wf(r,t.prevRanges));let o=l?Hf(t.prevRanges,r.mapping):Uf(r.mapping.maps[r.steps.length-1]);return new Pf(t.done.addTransform(r,s?e.selection.getBookmark():undefined,i,Gf(e)),zf.empty,o,r.time,n==null?t.prevComposition:n)}else if(s=r.getMeta("rebased")){return new Pf(t.done.rebased(r,s),t.undone.rebased(r,s),Hf(t.prevRanges,r.mapping),t.prevTime,t.prevComposition)}else{return new Pf(t.done.addMaps(r.mapping.maps),t.undone.addMaps(r.mapping.maps),Hf(t.prevRanges,r.mapping),t.prevTime,t.prevComposition)}}function Wf(t,e){if(!e)return false;if(!t.docChanged)return true;let r=false;t.mapping.maps[0].forEach(((t,i)=>{for(let n=0;n<e.length;n+=2)if(t<=e[n+1]&&i>=e[n])r=true}));return r}function Uf(t){let e=[];t.forEach(((t,r,i,n)=>e.push(i,n)));return e}function Hf(t,e){if(!t)return null;let r=[];for(let i=0;i<t.length;i+=2){let n=e.map(t[i],1),s=e.map(t[i+1],-1);if(n<=s)r.push(n,s)}return r}function Zf(t,e,r,i){let n=Gf(e);let s=Xf.get(e).spec.config;let l=(i?t.undone:t.done).popEvent(e,n);if(!l)return;let o=l.selection.resolve(l.transform.doc);let u=(i?t.done:t.undone).addTransform(l.transform,e.selection.getBookmark(),s,n);let f=new Pf(i?u:l.remaining,i?l.remaining:u,null,0,-1);r(l.transform.setSelection(o).setMeta(Xf,{redo:i,historyState:f}).scrollIntoView())}let Kf=false,Vf=null;function Gf(t){let e=t.plugins;if(Vf!=e){Kf=false;Vf=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){Kf=true;break}}return Kf}const Xf=new Mn("history");const Yf=new Mn("closeHistory");function Qf(t={}){t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500};return new yn({key:Xf,state:{init(){return new Pf(zf.empty,zf.empty,null,0,-1)},apply(e,r,i){return Lf(r,i,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(t,e){let r=e.inputType;let i=r=="historyUndo"?th:r=="historyRedo"?eh:null;if(!i)return false;e.preventDefault();return i(t.state,t.dispatch)}}}})}const th=(t,e)=>{let r=Xf.getState(t);if(!r||r.done.eventCount==0)return false;if(e)Zf(r,t,e,false);return true};const eh=(t,e)=>{let r=Xf.getState(t);if(!r||r.undone.eventCount==0)return false;if(e)Zf(r,t,e,true);return true};const rh=(t,e)=>{if(t.selection.empty)return false;if(e)e(t.tr.deleteSelection().scrollIntoView());return true};function ih(t,e){let{$cursor:r}=t.selection;if(!r||(e?!e.endOfTextblock("backward",t):r.parentOffset>0))return null;return r}const nh=(t,e,r)=>{let i=ih(t,r);if(!i)return false;let n=oh(i);if(!n){let r=i.blockRange(),n=r&&ci(r);if(n==null)return false;if(e)e(t.tr.lift(r,n).scrollIntoView());return true}let s=n.nodeBefore;if(!s.type.spec.isolating&&Mh(t,n,e))return true;if(i.parent.content.size==0&&(sh(s,"end")||ln.isSelectable(s))){let r=Bi(t.doc,i.before(),i.after(),Ee.empty);if(r&&r.slice.size<r.to-r.from){if(e){let i=t.tr.step(r);i.setSelection(sh(s,"end")?Qi.findFrom(i.doc.resolve(i.mapping.map(n.pos,-1)),-1):ln.create(i.doc,n.pos-s.nodeSize));e(i.scrollIntoView())}return true}}if(s.isAtom&&n.depth==i.depth-1){if(e)e(t.tr.delete(n.pos-s.nodeSize,n.pos).scrollIntoView());return true}return false};function sh(t,e,r=false){for(let i=t;i;i=e=="start"?i.firstChild:i.lastChild){if(i.isTextblock)return true;if(r&&i.childCount!=1)return false}return false}const lh=(t,e,r)=>{let{$head:i,empty:n}=t.selection,s=i;if(!n)return false;if(i.parent.isTextblock){if(r?!r.endOfTextblock("backward",t):i.parentOffset>0)return false;s=oh(i)}let l=s&&s.nodeBefore;if(!l||!ln.isSelectable(l))return false;if(e)e(t.tr.setSelection(ln.create(t.doc,s.pos-l.nodeSize)).scrollIntoView());return true};function oh(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){if(t.index(e)>0)return t.doc.resolve(t.before(e+1));if(t.node(e).type.spec.isolating)break}return null}function uh(t,e){let{$cursor:r}=t.selection;if(!r||(e?!e.endOfTextblock("forward",t):r.parentOffset<r.parent.content.size))return null;return r}const fh=(t,e,r)=>{let i=uh(t,r);if(!i)return false;let n=ah(i);if(!n)return false;let s=n.nodeAfter;if(Mh(t,n,e))return true;if(i.parent.content.size==0&&(sh(s,"start")||ln.isSelectable(s))){let r=Bi(t.doc,i.before(),i.after(),Ee.empty);if(r&&r.slice.size<r.to-r.from){if(e){let i=t.tr.step(r);i.setSelection(sh(s,"start")?Qi.findFrom(i.doc.resolve(i.mapping.map(n.pos)),1):ln.create(i.doc,i.mapping.map(n.pos)));e(i.scrollIntoView())}return true}}if(s.isAtom&&n.depth==i.depth-1){if(e)e(t.tr.delete(n.pos,n.pos+s.nodeSize).scrollIntoView());return true}return false};const hh=(t,e,r)=>{let{$head:i,empty:n}=t.selection,s=i;if(!n)return false;if(i.parent.isTextblock){if(r?!r.endOfTextblock("forward",t):i.parentOffset<i.parent.content.size)return false;s=ah(i)}let l=s&&s.nodeAfter;if(!l||!ln.isSelectable(l))return false;if(e)e(t.tr.setSelection(ln.create(t.doc,s.pos)).scrollIntoView());return true};function ah(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){let r=t.node(e);if(t.index(e)+1<r.childCount)return t.doc.resolve(t.after(e+1));if(r.type.spec.isolating)break}return null}const ch=(t,e)=>{let r=t.selection,i=r instanceof ln,n;if(i){if(r.node.isTextblock||!xi(t.doc,r.from))return false;n=r.from}else{n=Si(t.doc,r.from,-1);if(n==null)return false}if(e){let r=t.tr.join(n);if(i)r.setSelection(ln.create(r.doc,n-t.doc.resolve(n).nodeBefore.nodeSize));e(r.scrollIntoView())}return true};const dh=(t,e)=>{let r=t.selection,i;if(r instanceof ln){if(r.node.isTextblock||!xi(t.doc,r.to))return false;i=r.to}else{i=Si(t.doc,r.to,1);if(i==null)return false}if(e)e(t.tr.join(i).scrollIntoView());return true};const ph=(t,e)=>{let{$from:r,$to:i}=t.selection;let n=r.blockRange(i),s=n&&ci(n);if(s==null)return false;if(e)e(t.tr.lift(n,s).scrollIntoView());return true};const mh=(t,e)=>{let{$head:r,$anchor:i}=t.selection;if(!r.parent.type.spec.code||!r.sameParent(i))return false;if(e)e(t.tr.insertText("\n").scrollIntoView());return true};function wh(t){for(let e=0;e<t.edgeCount;e++){let{type:r}=t.edge(e);if(r.isTextblock&&!r.hasRequiredAttrs())return r}return null}const gh=(t,e)=>{let{$head:r,$anchor:i}=t.selection;if(!r.parent.type.spec.code||!r.sameParent(i))return false;let n=r.node(-1),s=r.indexAfter(-1),l=wh(n.contentMatchAt(s));if(!l||!n.canReplaceWith(s,s,l))return false;if(e){let i=r.after(),n=t.tr.replaceWith(i,i,l.createAndFill());n.setSelection(Qi.near(n.doc.resolve(i),1));e(n.scrollIntoView())}return true};const bh=(t,e)=>{let r=t.selection,{$from:i,$to:n}=r;if(r instanceof un||i.parent.inlineContent||n.parent.inlineContent)return false;let s=wh(n.parent.contentMatchAt(n.indexAfter()));if(!s||!s.isTextblock)return false;if(e){let r=(!i.parentOffset&&n.index()<n.parent.childCount?i:n).pos;let l=t.tr.insert(r,s.createAndFill());l.setSelection(nn.create(l.doc,r+1));e(l.scrollIntoView())}return true};const kh=(t,e)=>{let{$cursor:r}=t.selection;if(!r||r.parent.content.size)return false;if(r.depth>1&&r.after()!=r.end(-1)){let i=r.before();if(Ei(t.doc,i)){if(e)e(t.tr.split(i).scrollIntoView());return true}}let i=r.blockRange(),n=i&&ci(i);if(n==null)return false;if(e)e(t.tr.lift(i,n).scrollIntoView());return true};function Dh(t){return(e,r)=>{let{$from:i,$to:n}=e.selection;if(e.selection instanceof ln&&e.selection.node.isBlock){if(!i.parentOffset||!Ei(e.doc,i.pos))return false;if(r)r(e.tr.split(i.pos).scrollIntoView());return true}if(!i.parent.isBlock)return false;if(r){let s=n.parentOffset==n.parent.content.size;let l=e.tr;if(e.selection instanceof nn||e.selection instanceof un)l.deleteSelection();let o=i.depth==0?null:wh(i.node(-1).contentMatchAt(i.indexAfter(-1)));let u=t&&t(n.parent,s);let f=u?[u]:s&&o?[{type:o}]:undefined;let h=Ei(l.doc,l.mapping.map(i.pos),1,f);if(!f&&!h&&Ei(l.doc,l.mapping.map(i.pos),1,o?[{type:o}]:undefined)){if(o)f=[{type:o}];h=true}if(h){l.split(l.mapping.map(i.pos),1,f);if(!s&&!i.parentOffset&&i.parent.type!=o){let t=l.mapping.map(i.before()),e=l.doc.resolve(t);if(o&&i.node(-1).canReplaceWith(e.index(),e.index()+1,o))l.setNodeMarkup(l.mapping.map(i.before()),o)}}r(l.scrollIntoView())}return true}}const vh=Dh();const yh=(t,e)=>{let{$from:r,to:i}=t.selection,n;let s=r.sharedDepth(i);if(s==0)return false;n=r.before(s);if(e)e(t.tr.setSelection(ln.create(t.doc,n)));return true};const Fh=(t,e)=>{if(e)e(t.tr.setSelection(new un(t.doc)));return true};function Eh(t,e,r){let i=e.nodeBefore,n=e.nodeAfter,s=e.index();if(!i||!n||!i.type.compatibleContent(n.type))return false;if(!i.content.size&&e.parent.canReplace(s-1,s)){if(r)r(t.tr.delete(e.pos-i.nodeSize,e.pos).scrollIntoView());return true}if(!e.parent.canReplace(s,s+1)||!(n.isTextblock||xi(t.doc,e.pos)))return false;if(r)r(t.tr.clearIncompatible(e.pos,i.type,i.contentMatchAt(i.childCount)).join(e.pos).scrollIntoView());return true}function Mh(t,e,r){let i=e.nodeBefore,n=e.nodeAfter,s,l;if(i.type.spec.isolating||n.type.spec.isolating)return false;if(Eh(t,e,r))return true;let o=e.parent.canReplace(e.index(),e.index()+1);if(o&&(s=(l=i.contentMatchAt(i.childCount)).findWrapping(n.type))&&l.matchType(s[0]||n.type).validEnd){if(r){let l=e.pos+n.nodeSize,o=be.empty;for(let t=s.length-1;t>=0;t--)o=be.from(s[t].create(null,o));o=be.from(i.copy(o));let u=t.tr.step(new li(e.pos-1,l,e.pos,l,new Ee(o,1,0),s.length,true));let f=l+2*s.length;if(xi(u.doc,f))u.join(f);r(u.scrollIntoView())}return true}let u=Qi.findFrom(e,1);let f=u&&u.$from.blockRange(u.$to),h=f&&ci(f);if(h!=null&&h>=e.depth){if(r)r(t.tr.lift(f,h).scrollIntoView());return true}if(o&&sh(n,"start",true)&&sh(i,"end")){let s=i,l=[];for(;;){l.push(s);if(s.isTextblock)break;s=s.lastChild}let o=n,u=1;for(;!o.isTextblock;o=o.firstChild)u++;if(s.canReplace(s.childCount,s.childCount,o.content)){if(r){let i=be.empty;for(let t=l.length-1;t>=0;t--)i=be.from(l[t].copy(i));let s=t.tr.step(new li(e.pos-l.length,e.pos+n.nodeSize,e.pos+u,e.pos+n.nodeSize-u,new Ee(i,l.length,0),0,true));r(s.scrollIntoView())}return true}}return false}function xh(t){return function(e,r){let i=e.selection,n=t<0?i.$from:i.$to;let s=n.depth;while(n.node(s).isInline){if(!s)return false;s--}if(!n.node(s).isTextblock)return false;if(r)r(e.tr.setSelection(nn.create(e.doc,t<0?n.start(s):n.end(s))));return true}}const Ah=xh(-1);const Ch=xh(1);function Sh(t,e=null){return function(r,i){let{$from:n,$to:s}=r.selection;let l=n.blockRange(s),o=l&&pi(l,t,e);if(!o)return false;if(i)i(r.tr.wrap(l,o).scrollIntoView());return true}}function Oh(t,e=null){return function(r,i){let n=false;for(let i=0;i<r.selection.ranges.length&&!n;i++){let{$from:{pos:s},$to:{pos:l}}=r.selection.ranges[i];r.doc.nodesBetween(s,l,((i,s)=>{if(n)return false;if(!i.isTextblock||i.hasMarkup(t,e))return;if(i.type==t){n=true}else{let e=r.doc.resolve(s),i=e.index();n=e.parent.canReplaceWith(i,i+1,t)}}))}if(!n)return false;if(i){let n=r.tr;for(let i=0;i<r.selection.ranges.length;i++){let{$from:{pos:s},$to:{pos:l}}=r.selection.ranges[i];n.setBlockType(s,l,t,e)}i(n.scrollIntoView())}return true}}function $h(t,e,r){for(let i=0;i<e.length;i++){let{$from:n,$to:s}=e[i];let l=n.depth==0?t.inlineContent&&t.type.allowsMarkType(r):false;t.nodesBetween(n.pos,s.pos,(t=>{if(l)return false;l=t.inlineContent&&t.type.allowsMarkType(r)}));if(l)return true}return false}function _h(t,e=null){return function(r,i){let{empty:n,$cursor:s,ranges:l}=r.selection;if(n&&!s||!$h(r.doc,l,t))return false;if(i){if(s){if(t.isInSet(r.storedMarks||s.marks()))i(r.tr.removeStoredMark(t));else i(r.tr.addStoredMark(t.create(e)))}else{let n=false,s=r.tr;for(let e=0;!n&&e<l.length;e++){let{$from:i,$to:s}=l[e];n=r.doc.rangeHasMark(i.pos,s.pos,t)}for(let r=0;r<l.length;r++){let{$from:i,$to:o}=l[r];if(n){s.removeMark(i.pos,o.pos,t)}else{let r=i.pos,n=o.pos,l=i.nodeAfter,u=o.nodeBefore;let f=l&&l.isText?/^\s*/.exec(l.text)[0].length:0;let h=u&&u.isText?/\s*$/.exec(u.text)[0].length:0;if(r+f<n){r+=f;n-=h}s.addMark(r,n,t.create(e))}}i(s.scrollIntoView())}}return true}}function Bh(...t){return function(e,r,i){for(let n=0;n<t.length;n++)if(t[n](e,r,i))return true;return false}}let Rh=Bh(rh,nh,lh);let jh=Bh(rh,fh,hh);const Nh={Enter:Bh(mh,bh,kh,vh),"Mod-Enter":gh,Backspace:Rh,"Mod-Backspace":Rh,"Shift-Backspace":Rh,Delete:jh,"Mod-Delete":jh,"Mod-a":Fh};const qh={"Ctrl-h":Nh["Backspace"],"Alt-Backspace":Nh["Mod-Backspace"],"Ctrl-d":Nh["Delete"],"Ctrl-Alt-Backspace":Nh["Mod-Delete"],"Alt-Delete":Nh["Mod-Delete"],"Alt-d":Nh["Mod-Delete"],"Ctrl-a":Ah,"Ctrl-e":Ch};for(let t in Nh)qh[t]=Nh[t];const zh=typeof navigator!="undefined"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os!="undefined"&&os.platform?os.platform()=="darwin":false;const Th=zh?qh:Nh;function Ih(t={}){return new yn({view(e){return new Ph(e,t)}})}class Ph{constructor(t,e){var r;this.editorView=t;this.cursorPos=null;this.element=null;this.timeout=-1;this.width=(r=e.width)!==null&&r!==void 0?r:1;this.color=e.color===false?undefined:e.color||"black";this.class=e.class;this.handlers=["dragover","dragend","drop","dragleave"].map((e=>{let r=t=>{this[e](t)};t.dom.addEventListener(e,r);return{name:e,handler:r}}))}destroy(){this.handlers.forEach((({name:t,handler:e})=>this.editorView.dom.removeEventListener(t,e)))}update(t,e){if(this.cursorPos!=null&&e.doc!=t.state.doc){if(this.cursorPos>t.state.doc.content.size)this.setCursor(null);else this.updateOverlay()}}setCursor(t){if(t==this.cursorPos)return;this.cursorPos=t;if(t==null){this.element.parentNode.removeChild(this.element);this.element=null}else{this.updateOverlay()}}updateOverlay(){let t=this.editorView.state.doc.resolve(this.cursorPos);let e=!t.parent.inlineContent,r;if(e){let e=t.nodeBefore,i=t.nodeAfter;if(e||i){let t=this.editorView.nodeDOM(this.cursorPos-(e?e.nodeSize:0));if(t){let n=t.getBoundingClientRect();let s=e?n.bottom:n.top;if(e&&i)s=(s+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2;r={left:n.left,right:n.right,top:s-this.width/2,bottom:s+this.width/2}}}}if(!r){let t=this.editorView.coordsAtPos(this.cursorPos);r={left:t.left-this.width/2,right:t.left+this.width/2,top:t.top,bottom:t.bottom}}let i=this.editorView.dom.offsetParent;if(!this.element){this.element=i.appendChild(document.createElement("div"));if(this.class)this.element.className=this.class;this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;";if(this.color){this.element.style.backgroundColor=this.color}}this.element.classList.toggle("prosemirror-dropcursor-block",e);this.element.classList.toggle("prosemirror-dropcursor-inline",!e);let n,s;if(!i||i==document.body&&getComputedStyle(i).position=="static"){n=-pageXOffset;s=-pageYOffset}else{let t=i.getBoundingClientRect();n=t.left-i.scrollLeft;s=t.top-i.scrollTop}this.element.style.left=r.left-n+"px";this.element.style.top=r.top-s+"px";this.element.style.width=r.right-r.left+"px";this.element.style.height=r.bottom-r.top+"px"}scheduleRemoval(t){clearTimeout(this.timeout);this.timeout=setTimeout((()=>this.setCursor(null)),t)}dragover(t){if(!this.editorView.editable)return;let e=this.editorView.posAtCoords({left:t.clientX,top:t.clientY});let r=e&&e.inside>=0&&this.editorView.state.doc.nodeAt(e.inside);let i=r&&r.type.spec.disableDropCursor;let n=typeof i=="function"?i(this.editorView,e,t):i;if(e&&!n){let t=e.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let e=_i(this.editorView.state.doc,t,this.editorView.dragging.slice);if(e!=null)t=e}this.setCursor(t);this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(t){if(t.target==this.editorView.dom||!this.editorView.dom.contains(t.relatedTarget))this.setCursor(null)}}class Jh extends Qi{constructor(t){super(t,t)}map(t,e){let r=t.resolve(e.map(this.head));return Jh.valid(r)?new Jh(r):Qi.near(r)}content(){return Ee.empty}eq(t){return t instanceof Jh&&t.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(t,e){if(typeof e.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new Jh(t.resolve(e.pos))}getBookmark(){return new Lh(this.anchor)}static valid(t){let e=t.parent;if(e.isTextblock||!Wh(t)||!Uh(t))return false;let r=e.type.spec.allowGapCursor;if(r!=null)return r;let i=e.contentMatchAt(t.index()).defaultType;return i&&i.isTextblock}static findGapCursorFrom(t,e,r=false){t:for(;;){if(!r&&Jh.valid(t))return t;let i=t.pos,n=null;for(let r=t.depth;;r--){let s=t.node(r);if(e>0?t.indexAfter(r)<s.childCount:t.index(r)>0){n=s.child(e>0?t.indexAfter(r):t.index(r)-1);break}else if(r==0){return null}i+=e;let l=t.doc.resolve(i);if(Jh.valid(l))return l}for(;;){let s=e>0?n.firstChild:n.lastChild;if(!s){if(n.isAtom&&!n.isText&&!ln.isSelectable(n)){t=t.doc.resolve(i+n.nodeSize*e);r=false;continue t}break}n=s;i+=e;let l=t.doc.resolve(i);if(Jh.valid(l))return l}return null}}}Jh.prototype.visible=false;Jh.findFrom=Jh.findGapCursorFrom;Qi.jsonID("gapcursor",Jh);class Lh{constructor(t){this.pos=t}map(t){return new Lh(t.map(this.pos))}resolve(t){let e=t.resolve(this.pos);return Jh.valid(e)?new Jh(e):Qi.near(e)}}function Wh(t){for(let e=t.depth;e>=0;e--){let r=t.index(e),i=t.node(e);if(r==0){if(i.type.spec.isolating)return true;continue}for(let t=i.child(r-1);;t=t.lastChild){if(t.childCount==0&&!t.inlineContent||t.isAtom||t.type.spec.isolating)return true;if(t.inlineContent)return false}}return true}function Uh(t){for(let e=t.depth;e>=0;e--){let r=t.indexAfter(e),i=t.node(e);if(r==i.childCount){if(i.type.spec.isolating)return true;continue}for(let t=i.child(r);;t=t.firstChild){if(t.childCount==0&&!t.inlineContent||t.isAtom||t.type.spec.isolating)return true;if(t.inlineContent)return false}}return true}function Hh(){return new yn({props:{decorations:Xh,createSelectionBetween(t,e,r){return e.pos==r.pos&&Jh.valid(r)?new Jh(r):null},handleClick:Vh,handleKeyDown:Zh,handleDOMEvents:{beforeinput:Gh}}})}const Zh=_f({ArrowLeft:Kh("horiz",-1),ArrowRight:Kh("horiz",1),ArrowUp:Kh("vert",-1),ArrowDown:Kh("vert",1)});function Kh(t,e){const r=t=="vert"?e>0?"down":"up":e>0?"right":"left";return function(t,i,n){let s=t.selection;let l=e>0?s.$to:s.$from,o=s.empty;if(s instanceof nn){if(!n.endOfTextblock(r)||l.depth==0)return false;o=false;l=t.doc.resolve(e>0?l.after():l.before())}let u=Jh.findGapCursorFrom(l,e,o);if(!u)return false;if(i)i(t.tr.setSelection(new Jh(u)));return true}}function Vh(t,e,r){if(!t||!t.editable)return false;let i=t.state.doc.resolve(e);if(!Jh.valid(i))return false;let n=t.posAtCoords({left:r.clientX,top:r.clientY});if(n&&n.inside>-1&&ln.isSelectable(t.state.doc.nodeAt(n.inside)))return false;t.dispatch(t.state.tr.setSelection(new Jh(i)));return true}function Gh(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof Jh))return false;let{$from:r}=t.state.selection;let i=r.parent.contentMatchAt(r.index()).findWrapping(t.state.schema.nodes.text);if(!i)return false;let n=be.empty;for(let t=i.length-1;t>=0;t--)n=be.from(i[t].createAndFill(null,n));let s=t.state.tr.replace(r.pos,r.pos,new Ee(n,0,0));s.setSelection(nn.near(s.doc.resolve(r.pos+1)));t.dispatch(s);return false}function Xh(t){if(!(t.selection instanceof Jh))return null;let e=document.createElement("div");e.className="ProseMirror-gapcursor";return lu.create(t.doc,[iu.widget(t.selection.head,e,{key:"gapcursor"})])}function Yh(){var t=arguments[0];if(typeof t=="string")t=document.createElement(t);var e=1,r=arguments[1];if(r&&typeof r=="object"&&r.nodeType==null&&!Array.isArray(r)){for(var i in r)if(Object.prototype.hasOwnProperty.call(r,i)){var n=r[i];if(typeof n=="string")t.setAttribute(i,n);else if(n!=null)t[i]=n}e++}for(;e<arguments.length;e++)Qh(t,arguments[e]);return t}function Qh(t,e){if(typeof e=="string"){t.appendChild(document.createTextNode(e))}else if(e==null);else if(e.nodeType!=null){t.appendChild(e)}else if(Array.isArray(e)){for(var r=0;r<e.length;r++)Qh(t,e[r])}else{throw new RangeError("Unsupported child node: "+e)}}const ta="http://www.w3.org/2000/svg";const ea="http://www.w3.org/1999/xlink";const ra="ProseMirror-icon";function ia(t){let e=0;for(let r=0;r<t.length;r++)e=(e<<5)-e+t.charCodeAt(r)|0;return e}function na(t,e){let r=(t.nodeType==9?t:t.ownerDocument)||document;let i=r.createElement("div");i.className=ra;if(e.path){let{path:n,width:s,height:l}=e;let o="pm-icon-"+ia(n).toString(16);if(!r.getElementById(o))sa(t,o,e);let u=i.appendChild(r.createElementNS(ta,"svg"));u.style.width=s/l+"em";let f=u.appendChild(r.createElementNS(ta,"use"));f.setAttributeNS(ea,"href",/([^#]*)/.exec(r.location.toString())[1]+"#"+o)}else if(e.dom){i.appendChild(e.dom.cloneNode(true))}else{let{text:t,css:n}=e;i.appendChild(r.createElement("span")).textContent=t||"";if(n)i.firstChild.style.cssText=n}return i}function sa(t,e,r){let[i,n]=t.nodeType==9?[t,t.body]:[t.ownerDocument||document,t];let s=i.getElementById(ra+"-collection");if(!s){s=i.createElementNS(ta,"svg");s.id=ra+"-collection";s.style.display="none";n.insertBefore(s,n.firstChild)}let l=i.createElementNS(ta,"symbol");l.id=e;l.setAttribute("viewBox","0 0 "+r.width+" "+r.height);let o=l.appendChild(i.createElementNS(ta,"path"));o.setAttribute("d",r.path);s.appendChild(l)}const la="ProseMirror-menu";class oa{constructor(t){this.spec=t}render(t){let e=this.spec;let r=e.render?e.render(t):e.icon?na(t.root,e.icon):e.label?Yh("div",null,ua(t,e.label)):null;if(!r)throw new RangeError("MenuItem without icon or label property");if(e.title){const i=typeof e.title==="function"?e.title(t.state):e.title;r.setAttribute("title",ua(t,i))}if(e.class)r.classList.add(e.class);if(e.css)r.style.cssText+=e.css;r.addEventListener("mousedown",(i=>{i.preventDefault();if(!r.classList.contains(la+"-disabled"))e.run(t.state,t.dispatch,t,i)}));function i(t){if(e.select){let i=e.select(t);r.style.display=i?"":"none";if(!i)return false}let i=true;if(e.enable){i=e.enable(t)||false;xa(r,la+"-disabled",!i)}if(e.active){let n=i&&e.active(t)||false;xa(r,la+"-active",n)}return true}return{dom:r,update:i}}}function ua(t,e){return t._props.translate?t._props.translate(e):e}let fa={time:0,node:null};function ha(t){fa.time=Date.now();fa.node=t.target}function aa(t){return Date.now()-100<fa.time&&fa.node&&t.contains(fa.node)}class ca{constructor(t,e={}){this.options=e;this.options=e||{};this.content=Array.isArray(t)?t:[t]}render(t){let e=da(this.content,t);let r=t.dom.ownerDocument.defaultView||window;let i=Yh("div",{class:la+"-dropdown "+(this.options.class||""),style:this.options.css},ua(t,this.options.label||""));if(this.options.title)i.setAttribute("title",ua(t,this.options.title));let n=Yh("div",{class:la+"-dropdown-wrap"},i);let s=null;let l=null;let o=()=>{if(s&&s.close()){s=null;r.removeEventListener("mousedown",l)}};i.addEventListener("mousedown",(t=>{t.preventDefault();ha(t);if(s){o()}else{s=this.expand(n,e.dom);r.addEventListener("mousedown",l=()=>{if(!aa(n))o()})}}));function u(t){let r=e.update(t);n.style.display=r?"":"none";return r}return{dom:n,update:u}}expand(t,e){let r=Yh("div",{class:la+"-dropdown-menu "+(this.options.class||"")},e);let i=false;function n(){if(i)return false;i=true;t.removeChild(r);return true}t.appendChild(r);return{close:n,node:r}}}function da(t,e){let r=[],i=[];for(let n=0;n<t.length;n++){let{dom:s,update:l}=t[n].render(e);r.push(Yh("div",{class:la+"-dropdown-item"},s));i.push(l)}return{dom:r,update:pa(i,r)}}function pa(t,e){return r=>{let i=false;for(let n=0;n<t.length;n++){let s=t[n](r);e[n].style.display=s?"":"none";if(s)i=true}return i}}class ma{constructor(t,e={}){this.options=e;this.content=Array.isArray(t)?t:[t]}render(t){let e=da(this.content,t);let r=t.dom.ownerDocument.defaultView||window;let i=Yh("div",{class:la+"-submenu-label"},ua(t,this.options.label||""));let n=Yh("div",{class:la+"-submenu-wrap"},i,Yh("div",{class:la+"-submenu"},e.dom));let s=null;i.addEventListener("mousedown",(t=>{t.preventDefault();ha(t);xa(n,la+"-submenu-wrap-active",false);if(!s)r.addEventListener("mousedown",s=()=>{if(!aa(n)){n.classList.remove(la+"-submenu-wrap-active");r.removeEventListener("mousedown",s);s=null}})}));function l(t){let r=e.update(t);n.style.display=r?"":"none";return r}return{dom:n,update:l}}}function wa(t,e){let r=document.createDocumentFragment();let i=[],n=[];for(let s=0;s<e.length;s++){let l=e[s],o=[],u=[];for(let e=0;e<l.length;e++){let{dom:i,update:n}=l[e].render(t);let s=Yh("span",{class:la+"item"},i);r.appendChild(s);u.push(s);o.push(n)}if(o.length){i.push(pa(o,u));if(s<e.length-1)n.push(r.appendChild(ga()))}}function s(t){let e=false,r=false;for(let s=0;s<i.length;s++){let l=i[s](t);if(s)n[s-1].style.display=r&&l?"":"none";r=l;if(l)e=true}return e}return{dom:r,update:s}}function ga(){return Yh("span",{class:la+"separator"})}const ba={join:{width:800,height:900,path:"M0 75h800v125h-800z M0 825h800v-125h-800z M250 400h100v-100h100v100h100v100h-100v100h-100v-100h-100z"},lift:{width:1024,height:1024,path:"M219 310v329q0 7-5 12t-12 5q-8 0-13-5l-164-164q-5-5-5-13t5-13l164-164q5-5 13-5 7 0 12 5t5 12zM1024 749v109q0 7-5 12t-12 5h-987q-7 0-12-5t-5-12v-109q0-7 5-12t12-5h987q7 0 12 5t5 12zM1024 530v109q0 7-5 12t-12 5h-621q-7 0-12-5t-5-12v-109q0-7 5-12t12-5h621q7 0 12 5t5 12zM1024 310v109q0 7-5 12t-12 5h-621q-7 0-12-5t-5-12v-109q0-7 5-12t12-5h621q7 0 12 5t5 12zM1024 91v109q0 7-5 12t-12 5h-987q-7 0-12-5t-5-12v-109q0-7 5-12t12-5h987q7 0 12 5t5 12z"},selectParentNode:{text:"⬚",css:"font-weight: bold"},undo:{width:1024,height:1024,path:"M761 1024c113-206 132-520-313-509v253l-384-384 384-384v248c534-13 594 472 313 775z"},redo:{width:1024,height:1024,path:"M576 248v-248l384 384-384 384v-253c-446-10-427 303-313 509-280-303-221-789 313-775z"},strong:{width:805,height:1024,path:"M317 869q42 18 80 18 214 0 214-191 0-65-23-102-15-25-35-42t-38-26-46-14-48-6-54-1q-41 0-57 5 0 30-0 90t-0 90q0 4-0 38t-0 55 2 47 6 38zM309 442q24 4 62 4 46 0 81-7t62-25 42-51 14-81q0-40-16-70t-45-46-61-24-70-8q-28 0-74 7 0 28 2 86t2 86q0 15-0 45t-0 45q0 26 0 39zM0 950l1-53q8-2 48-9t60-15q4-6 7-15t4-19 3-18 1-21 0-19v-37q0-561-12-585-2-4-12-8t-25-6-28-4-27-2-17-1l-2-47q56-1 194-6t213-5q13 0 39 0t38 0q40 0 78 7t73 24 61 40 42 59 16 78q0 29-9 54t-22 41-36 32-41 25-48 22q88 20 146 76t58 141q0 57-20 102t-53 74-78 48-93 27-100 8q-25 0-75-1t-75-1q-60 0-175 6t-132 6z"},em:{width:585,height:1024,path:"M0 949l9-48q3-1 46-12t63-21q16-20 23-57 0-4 35-165t65-310 29-169v-14q-13-7-31-10t-39-4-33-3l10-58q18 1 68 3t85 4 68 1q27 0 56-1t69-4 56-3q-2 22-10 50-17 5-58 16t-62 19q-4 10-8 24t-5 22-4 26-3 24q-15 84-50 239t-44 203q-1 5-7 33t-11 51-9 47-3 32l0 10q9 2 105 17-1 25-9 56-6 0-18 0t-18 0q-16 0-49-5t-49-5q-78-1-117-1-29 0-81 5t-69 6z"},code:{width:896,height:1024,path:"M608 192l-96 96 224 224-224 224 96 96 288-320-288-320zM288 192l-288 320 288 320 96-96-224-224 224-224-96-96z"},link:{width:951,height:1024,path:"M832 694q0-22-16-38l-118-118q-16-16-38-16-24 0-41 18 1 1 10 10t12 12 8 10 7 14 2 15q0 22-16 38t-38 16q-8 0-15-2t-14-7-10-8-12-12-10-10q-18 17-18 41 0 22 16 38l117 118q15 15 38 15 22 0 38-14l84-83q16-16 16-38zM430 292q0-22-16-38l-117-118q-16-16-38-16-22 0-38 15l-84 83q-16 16-16 38 0 22 16 38l118 118q15 15 38 15 24 0 41-17-1-1-10-10t-12-12-8-10-7-14-2-15q0-22 16-38t38-16q8 0 15 2t14 7 10 8 12 12 10 10q18-17 18-41zM941 694q0 68-48 116l-84 83q-47 47-116 47-69 0-116-48l-117-118q-47-47-47-116 0-70 50-119l-50-50q-49 50-118 50-68 0-116-48l-118-118q-48-48-48-116t48-116l84-83q47-47 116-47 69 0 116 48l117 118q47 47 47 116 0 70-50 119l50 50q49-50 118-50 68 0 116 48l118 118q48 48 48 116z"},bulletList:{width:768,height:896,path:"M0 512h128v-128h-128v128zM0 256h128v-128h-128v128zM0 768h128v-128h-128v128zM256 512h512v-128h-512v128zM256 256h512v-128h-512v128zM256 768h512v-128h-512v128z"},orderedList:{width:768,height:896,path:"M320 512h448v-128h-448v128zM320 768h448v-128h-448v128zM320 128v128h448v-128h-448zM79 384h78v-256h-36l-85 23v50l43-2v185zM189 590c0-36-12-78-96-78-33 0-64 6-83 16l1 66c21-10 42-15 67-15s32 11 32 28c0 26-30 58-110 112v50h192v-67l-91 2c49-30 87-66 87-113l1-1z"},blockquote:{width:640,height:896,path:"M0 448v256h256v-256h-128c0 0 0-128 128-128v-128c0 0-256 0-256 256zM640 320v-128c0 0-256 0-256 256v256h256v-256h-128c0 0 0-128 128-128z"}};const ka=new oa({title:"Join with above block",run:ch,select:t=>ch(t),icon:ba.join});const Da=new oa({title:"Lift out of enclosing block",run:ph,select:t=>ph(t),icon:ba.lift});const va=new oa({title:"Select parent node",run:yh,select:t=>yh(t),icon:ba.selectParentNode});let ya=new oa({title:"Undo last change",run:th,enable:t=>th(t),icon:ba.undo});let Fa=new oa({title:"Redo last undone change",run:eh,enable:t=>eh(t),icon:ba.redo});function Ea(t,e){let r={run(r,i){return Sh(t,e.attrs)(r,i)},select(r){return Sh(t,e.attrs)(r)}};for(let t in e)r[t]=e[t];return new oa(r)}function Ma(t,e){let r=Oh(t,e.attrs);let i={run:r,enable(t){return r(t)},active(r){let{$from:i,to:n,node:s}=r.selection;if(s)return s.hasMarkup(t,e.attrs);return n<=i.end()&&i.parent.hasMarkup(t,e.attrs)}};for(let t in e)i[t]=e[t];return new oa(i)}function xa(t,e,r){if(r)t.classList.add(e);else t.classList.remove(e)}const Aa="ProseMirror-menubar";function Ca(){if(typeof navigator=="undefined")return false;let t=navigator.userAgent;return!/Edge\/\d/.test(t)&&/AppleWebKit/.test(t)&&/Mobile\/\w+/.test(t)}function Sa(t){return new yn({view(e){return new Oa(e,t)}})}class Oa{constructor(t,e){this.editorView=t;this.options=e;this.spacer=null;this.maxHeight=0;this.widthForMaxHeight=0;this.floating=false;this.scrollHandler=null;this.wrapper=Yh("div",{class:Aa+"-wrapper"});this.menu=this.wrapper.appendChild(Yh("div",{class:Aa}));this.menu.className=Aa;if(t.dom.parentNode)t.dom.parentNode.replaceChild(this.wrapper,t.dom);this.wrapper.appendChild(t.dom);let{dom:r,update:i}=wa(this.editorView,this.options.content);this.contentUpdate=i;this.menu.appendChild(r);this.update();if(e.floating&&!Ca()){this.updateFloat();let t=Ba(this.wrapper);this.scrollHandler=e=>{let r=this.editorView.root;if(!(r.body||r).contains(this.wrapper))t.forEach((t=>t.removeEventListener("scroll",this.scrollHandler)));else this.updateFloat(e.target.getBoundingClientRect?e.target:undefined)};t.forEach((t=>t.addEventListener("scroll",this.scrollHandler)))}}update(){this.contentUpdate(this.editorView.state);if(this.floating){this.updateScrollCursor()}else{if(this.menu.offsetWidth!=this.widthForMaxHeight){this.widthForMaxHeight=this.menu.offsetWidth;this.maxHeight=0}if(this.menu.offsetHeight>this.maxHeight){this.maxHeight=this.menu.offsetHeight;this.menu.style.minHeight=this.maxHeight+"px"}}}updateScrollCursor(){let t=this.editorView.root.getSelection();if(!t.focusNode)return;let e=t.getRangeAt(0).getClientRects();let r=e[$a(t)?0:e.length-1];if(!r)return;let i=this.menu.getBoundingClientRect();if(r.top<i.bottom&&r.bottom>i.top){let t=_a(this.wrapper);if(t)t.scrollTop-=i.bottom-r.top}}updateFloat(t){let e=this.wrapper,r=e.getBoundingClientRect(),i=t?Math.max(0,t.getBoundingClientRect().top):0;if(this.floating){if(r.top>=i||r.bottom<this.menu.offsetHeight+10){this.floating=false;this.menu.style.position=this.menu.style.left=this.menu.style.top=this.menu.style.width="";this.menu.style.display="";this.spacer.parentNode.removeChild(this.spacer);this.spacer=null}else{let n=(e.offsetWidth-e.clientWidth)/2;this.menu.style.left=r.left+n+"px";this.menu.style.display=r.top>(this.editorView.dom.ownerDocument.defaultView||window).innerHeight?"none":"";if(t)this.menu.style.top=i+"px"}}else{if(r.top<i&&r.bottom>=this.menu.offsetHeight+10){this.floating=true;let r=this.menu.getBoundingClientRect();this.menu.style.left=r.left+"px";this.menu.style.width=r.width+"px";if(t)this.menu.style.top=i+"px";this.menu.style.position="fixed";this.spacer=Yh("div",{class:Aa+"-spacer",style:`height: ${r.height}px`});e.insertBefore(this.spacer,this.menu)}}}destroy(){if(this.wrapper.parentNode)this.wrapper.parentNode.replaceChild(this.editorView.dom,this.wrapper)}}function $a(t){if(t.anchorNode==t.focusNode)return t.anchorOffset>t.focusOffset;return t.anchorNode.compareDocumentPosition(t.focusNode)==Node.DOCUMENT_POSITION_FOLLOWING}function _a(t){for(let e=t.parentNode;e;e=e.parentNode)if(e.scrollHeight>e.clientHeight)return e}function Ba(t){let e=[t.ownerDocument.defaultView||window];for(let r=t.parentNode;r;r=r.parentNode)e.push(r);return e}class Ra{constructor(t,e,r={}){this.match=t;this.match=t;this.handler=typeof e=="string"?ja(e):e;this.undoable=r.undoable!==false;this.inCode=r.inCode||false}}function ja(t){return function(e,r,i,n){let s=t;if(r[1]){let t=r[0].lastIndexOf(r[1]);s+=r[0].slice(t+r[1].length);i+=t;let e=i-n;if(e>0){s=r[0].slice(t-e,t)+s;i=n}}return e.tr.insertText(s,i,n)}}const Na=500;function qa({rules:t}){let e=new yn({state:{init(){return null},apply(t,e){let r=t.getMeta(this);if(r)return r;return t.selectionSet||t.docChanged?null:e}},props:{handleTextInput(r,i,n,s){return za(r,i,n,s,t,e)},handleDOMEvents:{compositionend:r=>{setTimeout((()=>{let{$cursor:i}=r.state.selection;if(i)za(r,i.pos,i.pos,"",t,e)}))}}},isInputRules:true});return e}function za(t,e,r,i,n,s){if(t.composing)return false;let l=t.state,o=l.doc.resolve(e);let u=o.parent.textBetween(Math.max(0,o.parentOffset-Na),o.parentOffset,null,"")+i;for(let f=0;f<n.length;f++){let h=n[f];if(o.parent.type.spec.code){if(!h.inCode)continue}else if(h.inCode==="only"){continue}let a=h.match.exec(u);let c=a&&h.handler(l,a,e-(a[0].length-i.length),r);if(!c)continue;if(h.undoable)c.setMeta(s,{transform:c,from:e,to:r,text:i});t.dispatch(c);return true}return false}const Ta=(t,e)=>{let r=t.plugins;for(let i=0;i<r.length;i++){let n=r[i],s;if(n.spec.isInputRules&&(s=n.getState(t))){if(e){let r=t.tr,i=s.transform;for(let t=i.steps.length-1;t>=0;t--)r.step(i.steps[t].invert(i.docs[t]));if(s.text){let e=r.doc.resolve(s.from).marks();r.replaceWith(s.from,s.to,t.schema.text(s.text,e))}else{r.delete(s.from,s.to)}e(r)}return true}}return false};const Ia=new Ra(/--$/,"—");const Pa=new Ra(/\.\.\.$/,"…");const Ja=new Ra(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,"“");const La=new Ra(/"$/,"”");const Wa=new Ra(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,"‘");const Ua=new Ra(/'$/,"’");const Ha=[Ja,La,Wa,Ua];function Za(t,e,r=null,i){return new Ra(t,((t,n,s,l)=>{let o=r instanceof Function?r(n):r;let u=t.tr.delete(s,l);let f=u.doc.resolve(s),h=f.blockRange(),a=h&&pi(h,e,o);if(!a)return null;u.wrap(h,a);let c=u.doc.resolve(s-1).nodeBefore;if(c&&c.type==e&&xi(u.doc,s-1)&&(!i||i(n,c)))u.join(s-1);return u}))}function Ka(t,e,r=null){return new Ra(t,((t,i,n,s)=>{let l=t.doc.resolve(n);let o=r instanceof Function?r(i):r;if(!l.node(-1).canReplaceWith(l.index(-1),l.indexAfter(-1),e))return null;return t.tr.delete(n,s).setBlockType(n,n,e,o)}))}const Va="ProseMirror-prompt";function Ga(t){let e=document.body.appendChild(document.createElement("div"));e.className=Va;let r=t=>{if(!e.contains(t.target))i()};setTimeout((()=>window.addEventListener("mousedown",r)),50);let i=()=>{window.removeEventListener("mousedown",r);if(e.parentNode)e.parentNode.removeChild(e)};let n=[];for(let e in t.fields)n.push(t.fields[e].render());let s=document.createElement("button");s.type="submit";s.className=Va+"-submit";s.textContent="OK";let l=document.createElement("button");l.type="button";l.className=Va+"-cancel";l.textContent="Cancel";l.addEventListener("click",i);let o=e.appendChild(document.createElement("form"));if(t.title)o.appendChild(document.createElement("h5")).textContent=t.title;n.forEach((t=>{o.appendChild(document.createElement("div")).appendChild(t)}));let u=o.appendChild(document.createElement("div"));u.className=Va+"-buttons";u.appendChild(s);u.appendChild(document.createTextNode(" "));u.appendChild(l);let f=e.getBoundingClientRect();e.style.top=(window.innerHeight-f.height)/2+"px";e.style.left=(window.innerWidth-f.width)/2+"px";let h=()=>{let e=Xa(t.fields,n);if(e){i();t.callback(e)}};o.addEventListener("submit",(t=>{t.preventDefault();h()}));o.addEventListener("keydown",(t=>{if(t.keyCode==27){t.preventDefault();i()}else if(t.keyCode==13&&!(t.ctrlKey||t.metaKey||t.shiftKey)){t.preventDefault();h()}else if(t.keyCode==9){window.setTimeout((()=>{if(!e.contains(document.activeElement))i()}),500)}}));let a=o.elements[0];if(a)a.focus()}function Xa(t,e){let r=Object.create(null),i=0;for(let n in t){let s=t[n],l=e[i++];let o=s.read(l),u=s.validate(o);if(u){Ya(l,u);return null}r[n]=s.clean(o)}return r}function Ya(t,e){let r=t.parentNode;let i=r.appendChild(document.createElement("div"));i.style.left=t.offsetLeft+t.offsetWidth+2+"px";i.style.top=t.offsetTop-5+"px";i.className="ProseMirror-invalid";i.textContent=e;setTimeout((()=>r.removeChild(i)),1500)}class Qa{constructor(t){this.options=t}read(t){return t.value}validateType(t){return null}validate(t){if(!t&&this.options.required)return"Required field";return this.validateType(t)||(this.options.validate?this.options.validate(t):null)}clean(t){return this.options.clean?this.options.clean(t):t}}class tc extends Qa{render(){let t=document.createElement("input");t.type="text";t.placeholder=this.options.label;t.value=this.options.value||"";t.autocomplete="off";return t}}function ec(t,e){let r=t.selection.$from;for(let t=r.depth;t>=0;t--){let i=r.index(t);if(r.node(t).canReplaceWith(i,i,e))return true}return false}function rc(t){return new oa({title:"Insert image",label:"Image",enable(e){return ec(e,t)},run(e,r,i){let{from:n,to:s}=e.selection,l=null;if(e.selection instanceof ln&&e.selection.node.type==t)l=e.selection.node.attrs;Ga({title:"Insert image",fields:{src:new tc({label:"Location",required:true,value:l&&l.src}),title:new tc({label:"Title",value:l&&l.title}),alt:new tc({label:"Description",value:l?l.alt:e.doc.textBetween(n,s," ")})},callback(e){i.dispatch(i.state.tr.replaceSelectionWith(t.createAndFill(e)));i.focus()}})}})}function ic(t,e){let r={label:e.title,run:t};for(let t in e)r[t]=e[t];if(!e.enable&&!e.select)r[e.enable?"enable":"select"]=e=>t(e);return new oa(r)}function nc(t,e){let{from:r,$from:i,to:n,empty:s}=t.selection;if(s)return!!e.isInSet(t.storedMarks||i.marks());else return t.doc.rangeHasMark(r,n,e)}function sc(t,e){let r={active(e){return nc(e,t)}};for(let t in e)r[t]=e[t];return ic(_h(t),r)}function lc(t){return new oa({title:"Add or remove link",icon:ba.link,active(e){return nc(e,t)},enable(t){return!t.selection.empty},run(e,r,i){if(nc(e,t)){_h(t)(e,r);return true}Ga({title:"Create a link",fields:{href:new tc({label:"Link target",required:true}),title:new tc({label:"Title"})},callback(e){_h(t,e)(i.state,i.dispatch);i.focus()}})}})}function oc(t,e){return ic(df(t,e.attrs),e)}function uc(t){let e={};let r;if(r=t.marks.strong)e.toggleStrong=sc(r,{title:"Toggle strong style",icon:ba.strong});if(r=t.marks.em)e.toggleEm=sc(r,{title:"Toggle emphasis",icon:ba.em});if(r=t.marks.code)e.toggleCode=sc(r,{title:"Toggle code font",icon:ba.code});if(r=t.marks.link)e.toggleLink=lc(r);let i;if(i=t.nodes.image)e.insertImage=rc(i);if(i=t.nodes.bullet_list)e.wrapBulletList=oc(i,{title:"Wrap in bullet list",icon:ba.bulletList});if(i=t.nodes.ordered_list)e.wrapOrderedList=oc(i,{title:"Wrap in ordered list",icon:ba.orderedList});if(i=t.nodes.blockquote)e.wrapBlockQuote=Ea(i,{title:"Wrap in block quote",icon:ba.blockquote});if(i=t.nodes.paragraph)e.makeParagraph=Ma(i,{title:"Change to paragraph",label:"Plain"});if(i=t.nodes.code_block)e.makeCodeBlock=Ma(i,{title:"Change to code block",label:"Code"});if(i=t.nodes.heading)for(let t=1;t<=10;t++)e["makeHead"+t]=Ma(i,{title:"Change to heading "+t,label:"Level "+t,attrs:{level:t}});if(i=t.nodes.horizontal_rule){let t=i;e.insertHorizontalRule=new oa({title:"Insert horizontal rule",label:"Horizontal rule",enable(e){return ec(e,t)},run(e,r){r(e.tr.replaceSelectionWith(t.create()))}})}let n=t=>t.filter((t=>t));e.insertMenu=new ca(n([e.insertImage,e.insertHorizontalRule]),{label:"Insert"});e.typeMenu=new ca(n([e.makeParagraph,e.makeCodeBlock,e.makeHead1&&new ma(n([e.makeHead1,e.makeHead2,e.makeHead3,e.makeHead4,e.makeHead5,e.makeHead6]),{label:"Heading"})]),{label:"Type..."});e.inlineMenu=[n([e.toggleStrong,e.toggleEm,e.toggleCode,e.toggleLink])];e.blockMenu=[n([e.wrapBulletList,e.wrapOrderedList,e.wrapBlockQuote,ka,Da,va])];e.fullMenu=e.inlineMenu.concat([[e.insertMenu,e.typeMenu]],[[ya,Fa]],e.blockMenu);return e}const fc=typeof navigator!="undefined"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):false;function hc(t,e){let r={},i;function n(t,i){if(e){let r=e[t];if(r===false)return;if(r)t=r}r[t]=i}n("Mod-z",th);n("Shift-Mod-z",eh);n("Backspace",Ta);if(!fc)n("Mod-y",eh);n("Alt-ArrowUp",ch);n("Alt-ArrowDown",dh);n("Mod-BracketLeft",ph);n("Escape",yh);if(i=t.marks.strong){n("Mod-b",_h(i));n("Mod-B",_h(i))}if(i=t.marks.em){n("Mod-i",_h(i));n("Mod-I",_h(i))}if(i=t.marks.code)n("Mod-`",_h(i));if(i=t.nodes.bullet_list)n("Shift-Ctrl-8",df(i));if(i=t.nodes.ordered_list)n("Shift-Ctrl-9",df(i));if(i=t.nodes.blockquote)n("Ctrl->",Sh(i));if(i=t.nodes.hard_break){let t=i,e=Bh(gh,((e,r)=>{if(r)r(e.tr.replaceSelectionWith(t.create()).scrollIntoView());return true}));n("Mod-Enter",e);n("Shift-Enter",e);if(fc)n("Ctrl-Enter",e)}if(i=t.nodes.list_item){n("Enter",mf(i));n("Mod-[",wf(i));n("Mod-]",kf(i))}if(i=t.nodes.paragraph)n("Shift-Ctrl-0",Oh(i));if(i=t.nodes.code_block)n("Shift-Ctrl-\\",Oh(i));if(i=t.nodes.heading)for(let t=1;t<=6;t++)n("Shift-Ctrl-"+t,Oh(i,{level:t}));if(i=t.nodes.horizontal_rule){let t=i;n("Mod-_",((e,r)=>{if(r)r(e.tr.replaceSelectionWith(t.create()).scrollIntoView());return true}))}return r}function ac(t){return Za(/^\s*>\s$/,t)}function cc(t){return Za(/^(\d+)\.\s$/,t,(t=>({order:+t[1]})),((t,e)=>e.childCount+e.attrs.order==+t[1]))}function dc(t){return Za(/^\s*([-+*])\s$/,t)}function pc(t){return Ka(/^```$/,t)}function mc(t,e){return Ka(new RegExp("^(#{1,"+e+"})\\s$"),t,(t=>({level:t[1].length})))}function wc(t){let e=Ha.concat(Pa,Ia),r;if(r=t.nodes.blockquote)e.push(ac(r));if(r=t.nodes.ordered_list)e.push(cc(r));if(r=t.nodes.bullet_list)e.push(dc(r));if(r=t.nodes.code_block)e.push(pc(r));if(r=t.nodes.heading)e.push(mc(r,6));return qa({rules:e})}function gc(t){let e=[wc(t.schema),$f(hc(t.schema,t.mapKeys)),$f(Th),Ih(),Hh()];if(t.menuBar!==false)e.push(Sa({floating:t.floatingMenu!==false,content:t.menuContent||uc(t.schema).fullMenu}));if(t.history!==false)e.push(Qf());return e.concat(new yn({props:{attributes:{class:"ProseMirror-example-setup-style"}}}))}const bc={Bold:"strong",Italic:"em",Blockquote:"blockquote",HeaderLevel1:"headerlevel1",HeaderLevel2:"headerlevel2",HeaderLevel3:"headerlevel3",Link:"link",OrderedList:"ordered_list",BulletList:"bullet_list",Strikethrough:"strikethrough",Code:"code",CodeBlock:"code_block"};const kc=Object.values(bc);const Dc={Heading:"heading",one:1,two:2,three:3};const vc={Left:0,Middle:1,Right:2};const yc=(t,e)=>{t.active=t=>{const{from:r,$from:i,to:n,empty:s}=t.selection;if(s){return!!e.isInSet(t.storedMarks||i.marks())}else{return t.doc.rangeHasMark(r,n,e)}}};const Fc=(t,e,r)=>{t.active=t=>{const{$from:i}=t.selection;const n=i.node(i.depth);if(n&&n.type.name===e.name){if(e.name===Dc.Heading&&r){return n.attrs.level===r}return true}return false}};const Ec=(t,e)=>{t.active=t=>{const{from:r,to:i}=t.selection;for(let n=r;n<=i;n++){const r=t.doc.resolve(n);for(let t=r.depth;t>0;t--){const i=r.node(t);if(i&&i.type.name===e.name){return true}}}return false}};const Mc=(t,e,r)=>{const i=(e,i)=>{const{from:n,to:s}=e.selection;if(n===s){const s=t.marks.link.create({href:r.href,title:r.href,target:Cc(r.href)?"_blank":null});const l=r.text||r.href;const o=t.text(l,[s]);i(e.tr.insert(n,o))}else{const l=t.marks.link.create({href:r.href,title:r.href,target:Cc(r.href)?"_blank":null});const o=e.doc.textBetween(n,s," ");const u=t.text(r.text||o,[l]);i(e.tr.replaceWith(n,s,u))}return true};yc(i,t.marks.link);return i};const xc=(t,e,r)=>{const i=t.marks[e];if(!i){throw new Error(`Mark "${e}" not found in schema`)}const n=Ac(e,r);const s=_h(i,n);yc(s,i);return s};const Ac=(t,e)=>{if(t===bc.Link&&e.href){return{href:e.href,target:Cc(e.href)?"_blank":null}}return undefined};const Cc=t=>!t.startsWith(window.location.origin);const Sc=(t,e,r={},i=false)=>{const n=t.nodes[e];const s=t.nodes.paragraph;return(t,e)=>{const{$from:l,$to:o}=t.selection;const u=l.node(l.depth-1).type===n;if(t.selection instanceof nn&&l.sameParent(l.doc.resolve(o.pos))){if(l.parent.type===n){if(e){e(t.tr.setBlockType(l.pos,o.pos,s))}return true}else{if(u){return ph(t,e)}if(i){return Sh(n,r)(t,e)}else{return Oh(n,r)(t,e)}}}return false}};const Oc=t=>{try{new URL(t)}catch(t){return false}return true};const $c=(t,e,r)=>{const i=t.nodes[e];if(!i){throw new Error(`Node type "${e}" not found in schema`)}let n;if(e===Dc.Heading&&r){n=Sc(t,Dc.Heading,{level:r})}else if(e===bc.CodeBlock){n=Sc(t,bc.CodeBlock)}else{n=Oh(i)}Fc(n,i,r);return n};const _c=(t,e)=>{const r=t.nodes[e];if(!r){throw new Error(`Node type "${e}" not found in schema`)}let i;if(e===bc.Blockquote){i=Sc(t,bc.Blockquote,{},true)}else{i=Sh(r)}Ec(i,r);return i};const Bc=t=>(e,r)=>{const{$from:i,$to:n}=e.selection;const s=i.blockRange(n);if(!s){return false}const l=s&&pi(s,t);if(l){if(r){r(e.tr.wrap(s,l).scrollIntoView())}return true}else{const t=s&&ci(s);if(t!==null){if(r){r(e.tr.lift(s,t).scrollIntoView())}return true}return false}};const Rc=(t,e)=>{const r=t.nodes[e];if(!r){throw new Error(`List type "${e}" not found in schema`)}const i=Bc(r);Ec(i,r);return i};const jc=(t,e)=>{const{from:r,to:i}=t.selection;if(r===i){return false}const n=window.clipboardData;if(!n){return false}const s=n.getData("text");if(!Oc(s)){return false}const l=t.schema.marks.link.create({href:s,target:Cc(s)?"_blank":null});const o=t.doc.textBetween(r,i," ");const u=t.schema.text(o,[l]);e(t.tr.replaceWith(r,i,u))};const Nc={strong:xc,em:xc,underline:xc,strikethrough:xc,code:xc,link:Mc,headerlevel1:t=>$c(t,Dc.Heading,Dc.one),headerlevel2:t=>$c(t,Dc.Heading,Dc.two),headerlevel3:t=>$c(t,Dc.Heading,Dc.three),blockquote:t=>_c(t,bc.Blockquote),code_block:t=>$c(t,bc.CodeBlock),ordered_list:t=>Rc(t,bc.OrderedList),bullet_list:t=>Rc(t,bc.BulletList)};class qc{constructor(t){this.schema=t}getCommand(t,e){const r=Nc[t];if(!r){throw new Error(`The Mark "${t}" is not supported`)}return r(this.schema,t,e)}buildKeymap(){return{"Mod-B":this.getCommand(bc.Bold),"Mod-I":this.getCommand(bc.Italic),"Mod-Shift-1":this.getCommand(bc.HeaderLevel1),"Mod-Shift-2":this.getCommand(bc.HeaderLevel2),"Mod-Shift-3":this.getCommand(bc.HeaderLevel3),"Mod-Shift-X":this.getCommand(bc.Strikethrough),"Mod-`":this.getCommand(bc.Code),"Mod-Shift-C":this.getCommand(bc.CodeBlock),"Mod-v":jc}}}const zc=()=>{const t=/Macintosh|MacIntel|MacPPC|Mac68K/;if(t.exec(navigator.userAgent)){return{mod:"⌘",option:"⌥",shift:"⇧"}}return{mod:"Ctrl",option:"Alt",shift:"Shift"}};const{mod:Tc,shift:Ic}=zc();const Pc=[{value:bc.Bold,text:"Bold",commandText:`${Tc} B`,icon:"-lime-text-bold",iconOnly:true,selected:false},{value:bc.Italic,text:"Italic",commandText:`${Tc} I`,icon:"-lime-text-italic",iconOnly:true,selected:false},{value:bc.Strikethrough,text:"Strikethrough",commandText:`${Tc} ${Ic} X`,icon:"-lime-text-strikethrough",iconOnly:true,selected:false},{value:bc.Link,text:"Link",icon:"-lime-text-link",iconOnly:true},{separator:true},{value:bc.BulletList,text:"Bullet list",icon:"-lime-text-bulleted-list",iconOnly:true,selected:false},{value:bc.OrderedList,text:"Numbered list",icon:"-lime-text-ordered-list",iconOnly:true,selected:false},{separator:true},{value:bc.HeaderLevel1,text:"Header 1",commandText:`${Tc} ${Ic} 1`,icon:"-lime-text-h-heading-1",iconOnly:true,selected:false},{value:bc.HeaderLevel2,text:"Header 2",commandText:`${Tc} ${Ic} 2`,icon:"-lime-text-h-heading-2",iconOnly:true,selected:false},{value:bc.HeaderLevel3,text:"Header 3",commandText:`${Tc} ${Ic} 3`,icon:"-lime-text-h-heading-3",iconOnly:true,selected:false},{separator:true},{value:bc.Blockquote,text:"Blockquote",icon:"-lime-text-blockquote",iconOnly:true,selected:false},{separator:true},{value:bc.Code,text:"Code",commandText:`${Tc} \``,icon:"-lime-text-code",iconOnly:true,selected:false},{value:bc.CodeBlock,text:"Code Block",commandText:`${Tc} ${Ic} C`,icon:"-lime-text-code-block",iconOnly:true,selected:false}];const Jc=()=>pe(Pc);const Lc={strong:"editor-menu.bold",em:"editor-menu.italic",headerlevel1:"editor-menu.h1",headerlevel2:"editor-menu.h2",headerlevel3:"editor-menu.h3",bullet_list:"editor-menu.bulleted-list",ordered_list:"editor-menu.numbered-list",code_block:"editor-menu.code-block",blockquote:"editor-menu.blockquote",link:"editor-menu.link",strikethrough:"editor-menu.strikethrough",code:"editor-menu.code"};const Wc={};function Uc(t){let e=Wc[t];if(e){return e}e=Wc[t]=[];for(let t=0;t<128;t++){const r=String.fromCharCode(t);e.push(r)}for(let r=0;r<t.length;r++){const i=t.charCodeAt(r);e[i]="%"+("0"+i.toString(16).toUpperCase()).slice(-2)}return e}function Hc(t,e){if(typeof e!=="string"){e=Hc.defaultChars}const r=Uc(e);return t.replace(/(%[a-f0-9]{2})+/gi,(function(t){let e="";for(let i=0,n=t.length;i<n;i+=3){const s=parseInt(t.slice(i+1,i+3),16);if(s<128){e+=r[s];continue}if((s&224)===192&&i+3<n){const r=parseInt(t.slice(i+4,i+6),16);if((r&192)===128){const t=s<<6&1984|r&63;if(t<128){e+="��"}else{e+=String.fromCharCode(t)}i+=3;continue}}if((s&240)===224&&i+6<n){const r=parseInt(t.slice(i+4,i+6),16);const n=parseInt(t.slice(i+7,i+9),16);if((r&192)===128&&(n&192)===128){const t=s<<12&61440|r<<6&4032|n&63;if(t<2048||t>=55296&&t<=57343){e+="���"}else{e+=String.fromCharCode(t)}i+=6;continue}}if((s&248)===240&&i+9<n){const r=parseInt(t.slice(i+4,i+6),16);const n=parseInt(t.slice(i+7,i+9),16);const l=parseInt(t.slice(i+10,i+12),16);if((r&192)===128&&(n&192)===128&&(l&192)===128){let t=s<<18&1835008|r<<12&258048|n<<6&4032|l&63;if(t<65536||t>1114111){e+="����"}else{t-=65536;e+=String.fromCharCode(55296+(t>>10),56320+(t&1023))}i+=9;continue}}e+="�"}return e}))}Hc.defaultChars=";/?:@&=+$,#";Hc.componentChars="";const Zc={};function Kc(t){let e=Zc[t];if(e){return e}e=Zc[t]=[];for(let t=0;t<128;t++){const r=String.fromCharCode(t);if(/^[0-9a-z]$/i.test(r)){e.push(r)}else{e.push("%"+("0"+t.toString(16).toUpperCase()).slice(-2))}}for(let r=0;r<t.length;r++){e[t.charCodeAt(r)]=t[r]}return e}function Vc(t,e,r){if(typeof e!=="string"){r=e;e=Vc.defaultChars}if(typeof r==="undefined"){r=true}const i=Kc(e);let n="";for(let e=0,s=t.length;e<s;e++){const l=t.charCodeAt(e);if(r&&l===37&&e+2<s){if(/^[0-9a-f]{2}$/i.test(t.slice(e+1,e+3))){n+=t.slice(e,e+3);e+=2;continue}}if(l<128){n+=i[l];continue}if(l>=55296&&l<=57343){if(l>=55296&&l<=56319&&e+1<s){const r=t.charCodeAt(e+1);if(r>=56320&&r<=57343){n+=encodeURIComponent(t[e]+t[e+1]);e++;continue}}n+="%EF%BF%BD";continue}n+=encodeURIComponent(t[e])}return n}Vc.defaultChars=";/?:@&=+$,-_.!~*'()#";Vc.componentChars="-_.!~*'()";function Gc(t){let e="";e+=t.protocol||"";e+=t.slashes?"//":"";e+=t.auth?t.auth+"@":"";if(t.hostname&&t.hostname.indexOf(":")!==-1){e+="["+t.hostname+"]"}else{e+=t.hostname||""}e+=t.port?":"+t.port:"";e+=t.pathname||"";e+=t.search||"";e+=t.hash||"";return e}function Xc(){this.protocol=null;this.slashes=null;this.auth=null;this.port=null;this.hostname=null;this.hash=null;this.search=null;this.pathname=null}const Yc=/^([a-z0-9.+-]+:)/i;const Qc=/:[0-9]*$/;const td=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/;const ed=["<",">",'"',"`"," ","\r","\n","\t"];const rd=["{","}","|","\\","^","`"].concat(ed);const id=["'"].concat(rd);const nd=["%","/","?",";","#"].concat(id);const sd=["/","?","#"];const ld=255;const od=/^[+a-z0-9A-Z_-]{0,63}$/;const ud=/^([+a-z0-9A-Z_-]{0,63})(.*)$/;const fd={javascript:true,"javascript:":true};const hd={http:true,https:true,ftp:true,gopher:true,file:true,"http:":true,"https:":true,"ftp:":true,"gopher:":true,"file:":true};function ad(t,e){if(t&&t instanceof Xc)return t;const r=new Xc;r.parse(t,e);return r}Xc.prototype.parse=function(t,e){let r,i,n;let s=t;s=s.trim();if(!e&&t.split("#").length===1){const t=td.exec(s);if(t){this.pathname=t[1];if(t[2]){this.search=t[2]}return this}}let l=Yc.exec(s);if(l){l=l[0];r=l.toLowerCase();this.protocol=l;s=s.substr(l.length)}if(e||l||s.match(/^\/\/[^@\/]+@[^@\/]+/)){n=s.substr(0,2)==="//";if(n&&!(l&&fd[l])){s=s.substr(2);this.slashes=true}}if(!fd[l]&&(n||l&&!hd[l])){let t=-1;for(let e=0;e<sd.length;e++){i=s.indexOf(sd[e]);if(i!==-1&&(t===-1||i<t)){t=i}}let e,r;if(t===-1){r=s.lastIndexOf("@")}else{r=s.lastIndexOf("@",t)}if(r!==-1){e=s.slice(0,r);s=s.slice(r+1);this.auth=e}t=-1;for(let e=0;e<nd.length;e++){i=s.indexOf(nd[e]);if(i!==-1&&(t===-1||i<t)){t=i}}if(t===-1){t=s.length}if(s[t-1]===":"){t--}const n=s.slice(0,t);s=s.slice(t);this.parseHost(n);this.hostname=this.hostname||"";const l=this.hostname[0]==="["&&this.hostname[this.hostname.length-1]==="]";if(!l){const t=this.hostname.split(/\./);for(let e=0,r=t.length;e<r;e++){const r=t[e];if(!r){continue}if(!r.match(od)){let i="";for(let t=0,e=r.length;t<e;t++){if(r.charCodeAt(t)>127){i+="x"}else{i+=r[t]}}if(!i.match(od)){const i=t.slice(0,e);const n=t.slice(e+1);const l=r.match(ud);if(l){i.push(l[1]);n.unshift(l[2])}if(n.length){s=n.join(".")+s}this.hostname=i.join(".");break}}}}if(this.hostname.length>ld){this.hostname=""}if(l){this.hostname=this.hostname.substr(1,this.hostname.length-2)}}const o=s.indexOf("#");if(o!==-1){this.hash=s.substr(o);s=s.slice(0,o)}const u=s.indexOf("?");if(u!==-1){this.search=s.substr(u);s=s.slice(0,u)}if(s){this.pathname=s}if(hd[r]&&this.hostname&&!this.pathname){this.pathname=""}return this};Xc.prototype.parseHost=function(t){let e=Qc.exec(t);if(e){e=e[0];if(e!==":"){this.port=e.substr(1)}t=t.substr(0,t.length-e.length)}if(t){this.hostname=t}};const cd=Object.freeze({__proto__:null,decode:Hc,encode:Vc,format:Gc,parse:ad});const dd=/[\0-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/;const pd=/[\0-\x1F\x7F-\x9F]/;const md=/[\xAD\u0600-\u0605\u061C\u06DD\u070F\u0890\u0891\u08E2\u180E\u200B-\u200F\u202A-\u202E\u2060-\u2064\u2066-\u206F\uFEFF\uFFF9-\uFFFB]|\uD804[\uDCBD\uDCCD]|\uD80D[\uDC30-\uDC3F]|\uD82F[\uDCA0-\uDCA3]|\uD834[\uDD73-\uDD7A]|\uDB40[\uDC01\uDC20-\uDC7F]/;const wd=/[!-#%-\*,-\/:;\?@\[-\]_\{\}\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061D-\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u09FD\u0A76\u0AF0\u0C77\u0C84\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1B7D\u1B7E\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E4F\u2E52-\u2E5D\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]|\uD800[\uDD00-\uDD02\uDF9F\uDFD0]|\uD801\uDD6F|\uD802[\uDC57\uDD1F\uDD3F\uDE50-\uDE58\uDE7F\uDEF0-\uDEF6\uDF39-\uDF3F\uDF99-\uDF9C]|\uD803[\uDEAD\uDF55-\uDF59\uDF86-\uDF89]|\uD804[\uDC47-\uDC4D\uDCBB\uDCBC\uDCBE-\uDCC1\uDD40-\uDD43\uDD74\uDD75\uDDC5-\uDDC8\uDDCD\uDDDB\uDDDD-\uDDDF\uDE38-\uDE3D\uDEA9]|\uD805[\uDC4B-\uDC4F\uDC5A\uDC5B\uDC5D\uDCC6\uDDC1-\uDDD7\uDE41-\uDE43\uDE60-\uDE6C\uDEB9\uDF3C-\uDF3E]|\uD806[\uDC3B\uDD44-\uDD46\uDDE2\uDE3F-\uDE46\uDE9A-\uDE9C\uDE9E-\uDEA2\uDF00-\uDF09]|\uD807[\uDC41-\uDC45\uDC70\uDC71\uDEF7\uDEF8\uDF43-\uDF4F\uDFFF]|\uD809[\uDC70-\uDC74]|\uD80B[\uDFF1\uDFF2]|\uD81A[\uDE6E\uDE6F\uDEF5\uDF37-\uDF3B\uDF44]|\uD81B[\uDE97-\uDE9A\uDFE2]|\uD82F\uDC9F|\uD836[\uDE87-\uDE8B]|\uD83A[\uDD5E\uDD5F]/;const gd=/[\$\+<->\^`\|~\xA2-\xA6\xA8\xA9\xAC\xAE-\xB1\xB4\xB8\xD7\xF7\u02C2-\u02C5\u02D2-\u02DF\u02E5-\u02EB\u02ED\u02EF-\u02FF\u0375\u0384\u0385\u03F6\u0482\u058D-\u058F\u0606-\u0608\u060B\u060E\u060F\u06DE\u06E9\u06FD\u06FE\u07F6\u07FE\u07FF\u0888\u09F2\u09F3\u09FA\u09FB\u0AF1\u0B70\u0BF3-\u0BFA\u0C7F\u0D4F\u0D79\u0E3F\u0F01-\u0F03\u0F13\u0F15-\u0F17\u0F1A-\u0F1F\u0F34\u0F36\u0F38\u0FBE-\u0FC5\u0FC7-\u0FCC\u0FCE\u0FCF\u0FD5-\u0FD8\u109E\u109F\u1390-\u1399\u166D\u17DB\u1940\u19DE-\u19FF\u1B61-\u1B6A\u1B74-\u1B7C\u1FBD\u1FBF-\u1FC1\u1FCD-\u1FCF\u1FDD-\u1FDF\u1FED-\u1FEF\u1FFD\u1FFE\u2044\u2052\u207A-\u207C\u208A-\u208C\u20A0-\u20C0\u2100\u2101\u2103-\u2106\u2108\u2109\u2114\u2116-\u2118\u211E-\u2123\u2125\u2127\u2129\u212E\u213A\u213B\u2140-\u2144\u214A-\u214D\u214F\u218A\u218B\u2190-\u2307\u230C-\u2328\u232B-\u2426\u2440-\u244A\u249C-\u24E9\u2500-\u2767\u2794-\u27C4\u27C7-\u27E5\u27F0-\u2982\u2999-\u29D7\u29DC-\u29FB\u29FE-\u2B73\u2B76-\u2B95\u2B97-\u2BFF\u2CE5-\u2CEA\u2E50\u2E51\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u2FFF\u3004\u3012\u3013\u3020\u3036\u3037\u303E\u303F\u309B\u309C\u3190\u3191\u3196-\u319F\u31C0-\u31E3\u31EF\u3200-\u321E\u322A-\u3247\u3250\u3260-\u327F\u328A-\u32B0\u32C0-\u33FF\u4DC0-\u4DFF\uA490-\uA4C6\uA700-\uA716\uA720\uA721\uA789\uA78A\uA828-\uA82B\uA836-\uA839\uAA77-\uAA79\uAB5B\uAB6A\uAB6B\uFB29\uFBB2-\uFBC2\uFD40-\uFD4F\uFDCF\uFDFC-\uFDFF\uFE62\uFE64-\uFE66\uFE69\uFF04\uFF0B\uFF1C-\uFF1E\uFF3E\uFF40\uFF5C\uFF5E\uFFE0-\uFFE6\uFFE8-\uFFEE\uFFFC\uFFFD]|\uD800[\uDD37-\uDD3F\uDD79-\uDD89\uDD8C-\uDD8E\uDD90-\uDD9C\uDDA0\uDDD0-\uDDFC]|\uD802[\uDC77\uDC78\uDEC8]|\uD805\uDF3F|\uD807[\uDFD5-\uDFF1]|\uD81A[\uDF3C-\uDF3F\uDF45]|\uD82F\uDC9C|\uD833[\uDF50-\uDFC3]|\uD834[\uDC00-\uDCF5\uDD00-\uDD26\uDD29-\uDD64\uDD6A-\uDD6C\uDD83\uDD84\uDD8C-\uDDA9\uDDAE-\uDDEA\uDE00-\uDE41\uDE45\uDF00-\uDF56]|\uD835[\uDEC1\uDEDB\uDEFB\uDF15\uDF35\uDF4F\uDF6F\uDF89\uDFA9\uDFC3]|\uD836[\uDC00-\uDDFF\uDE37-\uDE3A\uDE6D-\uDE74\uDE76-\uDE83\uDE85\uDE86]|\uD838[\uDD4F\uDEFF]|\uD83B[\uDCAC\uDCB0\uDD2E\uDEF0\uDEF1]|\uD83C[\uDC00-\uDC2B\uDC30-\uDC93\uDCA0-\uDCAE\uDCB1-\uDCBF\uDCC1-\uDCCF\uDCD1-\uDCF5\uDD0D-\uDDAD\uDDE6-\uDE02\uDE10-\uDE3B\uDE40-\uDE48\uDE50\uDE51\uDE60-\uDE65\uDF00-\uDFFF]|\uD83D[\uDC00-\uDED7\uDEDC-\uDEEC\uDEF0-\uDEFC\uDF00-\uDF76\uDF7B-\uDFD9\uDFE0-\uDFEB\uDFF0]|\uD83E[\uDC00-\uDC0B\uDC10-\uDC47\uDC50-\uDC59\uDC60-\uDC87\uDC90-\uDCAD\uDCB0\uDCB1\uDD00-\uDE53\uDE60-\uDE6D\uDE70-\uDE7C\uDE80-\uDE88\uDE90-\uDEBD\uDEBF-\uDEC5\uDECE-\uDEDB\uDEE0-\uDEE8\uDEF0-\uDEF8\uDF00-\uDF92\uDF94-\uDFCA]/;const bd=/[ \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000]/;const kd=Object.freeze({__proto__:null,Any:dd,Cc:pd,Cf:md,P:wd,S:gd,Z:bd});function Dd(t){return Object.prototype.toString.call(t)}function vd(t){return Dd(t)==="[object String]"}const yd=Object.prototype.hasOwnProperty;function Fd(t,e){return yd.call(t,e)}function Ed(t){const e=Array.prototype.slice.call(arguments,1);e.forEach((function(e){if(!e){return}if(typeof e!=="object"){throw new TypeError(e+"must be object")}Object.keys(e).forEach((function(r){t[r]=e[r]}))}));return t}function Md(t,e,r){return[].concat(t.slice(0,e),r,t.slice(e+1))}function xd(t){if(t>=55296&&t<=57343){return false}if(t>=64976&&t<=65007){return false}if((t&65535)===65535||(t&65535)===65534){return false}if(t>=0&&t<=8){return false}if(t===11){return false}if(t>=14&&t<=31){return false}if(t>=127&&t<=159){return false}if(t>1114111){return false}return true}function Ad(t){if(t>65535){t-=65536;const e=55296+(t>>10);const r=56320+(t&1023);return String.fromCharCode(e,r)}return String.fromCharCode(t)}const Cd=/\\([!"#$%&'()*+,\-./:;<=>?@[\\\]^_`{|}~])/g;const Sd=/&([a-z#][a-z0-9]{1,31});/gi;const Od=new RegExp(Cd.source+"|"+Sd.source,"gi");const $d=/^#((?:x[a-f0-9]{1,8}|[0-9]{1,8}))$/i;function _d(t,e){if(e.charCodeAt(0)===35&&$d.test(e)){const r=e[1].toLowerCase()==="x"?parseInt(e.slice(2),16):parseInt(e.slice(1),10);if(xd(r)){return Ad(r)}return t}const r=x(t);if(r!==t){return r}return t}function Bd(t){if(t.indexOf("\\")<0){return t}return t.replace(Cd,"$1")}function Rd(t){if(t.indexOf("\\")<0&&t.indexOf("&")<0){return t}return t.replace(Od,(function(t,e,r){if(e){return e}return _d(t,r)}))}const jd=/[&<>"]/;const Nd=/[&<>"]/g;const qd={"&":"&","<":"<",">":">",'"':"""};function zd(t){return qd[t]}function Td(t){if(jd.test(t)){return t.replace(Nd,zd)}return t}const Id=/[.?*+^$[\]\\(){}|-]/g;function Pd(t){return t.replace(Id,"\\$&")}function Jd(t){switch(t){case 9:case 32:return true}return false}function Ld(t){if(t>=8192&&t<=8202){return true}switch(t){case 9:case 10:case 11:case 12:case 13:case 32:case 160:case 5760:case 8239:case 8287:case 12288:return true}return false}function Wd(t){return wd.test(t)||gd.test(t)}function Ud(t){switch(t){case 33:case 34:case 35:case 36:case 37:case 38:case 39:case 40:case 41:case 42:case 43:case 44:case 45:case 46:case 47:case 58:case 59:case 60:case 61:case 62:case 63:case 64:case 91:case 92:case 93:case 94:case 95:case 96:case 123:case 124:case 125:case 126:return true;default:return false}}function Hd(t){t=t.trim().replace(/\s+/g," ");if("ẞ".toLowerCase()==="Ṿ"){t=t.replace(/ẞ/g,"ß")}return t.toLowerCase().toUpperCase()}const Zd={mdurl:cd,ucmicro:kd};const Kd=Object.freeze({__proto__:null,lib:Zd,assign:Ed,isString:vd,has:Fd,unescapeMd:Bd,unescapeAll:Rd,isValidEntityCode:xd,fromCodePoint:Ad,escapeHtml:Td,arrayReplaceAt:Md,isSpace:Jd,isWhiteSpace:Ld,isMdAsciiPunct:Ud,isPunctChar:Wd,escapeRE:Pd,normalizeReference:Hd});function Vd(t,e,r){let i,n,s,l;const o=t.posMax;const u=t.pos;t.pos=e+1;i=1;while(t.pos<o){s=t.src.charCodeAt(t.pos);if(s===93){i--;if(i===0){n=true;break}}l=t.pos;t.md.inline.skipToken(t);if(s===91){if(l===t.pos-1){i++}else if(r){t.pos=u;return-1}}}let f=-1;if(n){f=t.pos}t.pos=u;return f}function Gd(t,e,r){let i;let n=e;const s={ok:false,pos:0,str:""};if(t.charCodeAt(n)===60){n++;while(n<r){i=t.charCodeAt(n);if(i===10){return s}if(i===60){return s}if(i===62){s.pos=n+1;s.str=Rd(t.slice(e+1,n));s.ok=true;return s}if(i===92&&n+1<r){n+=2;continue}n++}return s}let l=0;while(n<r){i=t.charCodeAt(n);if(i===32){break}if(i<32||i===127){break}if(i===92&&n+1<r){if(t.charCodeAt(n+1)===32){break}n+=2;continue}if(i===40){l++;if(l>32){return s}}if(i===41){if(l===0){break}l--}n++}if(e===n){return s}if(l!==0){return s}s.str=Rd(t.slice(e,n));s.pos=n;s.ok=true;return s}function Xd(t,e,r,i){let n;let s=e;const l={ok:false,can_continue:false,pos:0,str:"",marker:0};if(i){l.str=i.str;l.marker=i.marker}else{if(s>=r){return l}let i=t.charCodeAt(s);if(i!==34&&i!==39&&i!==40){return l}e++;s++;if(i===40){i=41}l.marker=i}while(s<r){n=t.charCodeAt(s);if(n===l.marker){l.pos=s+1;l.str+=Rd(t.slice(e,s));l.ok=true;return l}else if(n===40&&l.marker===41){return l}else if(n===92&&s+1<r){s++}s++}l.can_continue=true;l.str+=Rd(t.slice(e,s));return l}const Yd=Object.freeze({__proto__:null,parseLinkLabel:Vd,parseLinkDestination:Gd,parseLinkTitle:Xd});const Qd={};Qd.code_inline=function(t,e,r,i,n){const s=t[e];return"<code"+n.renderAttrs(s)+">"+Td(s.content)+"</code>"};Qd.code_block=function(t,e,r,i,n){const s=t[e];return"<pre"+n.renderAttrs(s)+"><code>"+Td(t[e].content)+"</code></pre>\n"};Qd.fence=function(t,e,r,i,n){const s=t[e];const l=s.info?Rd(s.info).trim():"";let o="";let u="";if(l){const t=l.split(/(\s+)/g);o=t[0];u=t.slice(2).join("")}let f;if(r.highlight){f=r.highlight(s.content,o,u)||Td(s.content)}else{f=Td(s.content)}if(f.indexOf("<pre")===0){return f+"\n"}if(l){const t=s.attrIndex("class");const e=s.attrs?s.attrs.slice():[];if(t<0){e.push(["class",r.langPrefix+o])}else{e[t]=e[t].slice();e[t][1]+=" "+r.langPrefix+o}const i={attrs:e};return`<pre><code${n.renderAttrs(i)}>${f}</code></pre>\n`}return`<pre><code${n.renderAttrs(s)}>${f}</code></pre>\n`};Qd.image=function(t,e,r,i,n){const s=t[e];s.attrs[s.attrIndex("alt")][1]=n.renderInlineAsText(s.children,r,i);return n.renderToken(t,e,r)};Qd.hardbreak=function(t,e,r){return r.xhtmlOut?"<br />\n":"<br>\n"};Qd.softbreak=function(t,e,r){return r.breaks?r.xhtmlOut?"<br />\n":"<br>\n":"\n"};Qd.text=function(t,e){return Td(t[e].content)};Qd.html_block=function(t,e){return t[e].content};Qd.html_inline=function(t,e){return t[e].content};function tp(){this.rules=Ed({},Qd)}tp.prototype.renderAttrs=function t(e){let r,i,n;if(!e.attrs){return""}n="";for(r=0,i=e.attrs.length;r<i;r++){n+=" "+Td(e.attrs[r][0])+'="'+Td(e.attrs[r][1])+'"'}return n};tp.prototype.renderToken=function t(e,r,i){const n=e[r];let s="";if(n.hidden){return""}if(n.block&&n.nesting!==-1&&r&&e[r-1].hidden){s+="\n"}s+=(n.nesting===-1?"</":"<")+n.tag;s+=this.renderAttrs(n);if(n.nesting===0&&i.xhtmlOut){s+=" /"}let l=false;if(n.block){l=true;if(n.nesting===1){if(r+1<e.length){const t=e[r+1];if(t.type==="inline"||t.hidden){l=false}else if(t.nesting===-1&&t.tag===n.tag){l=false}}}}s+=l?">\n":">";return s};tp.prototype.renderInline=function(t,e,r){let i="";const n=this.rules;for(let s=0,l=t.length;s<l;s++){const l=t[s].type;if(typeof n[l]!=="undefined"){i+=n[l](t,s,e,r,this)}else{i+=this.renderToken(t,s,e)}}return i};tp.prototype.renderInlineAsText=function(t,e,r){let i="";for(let n=0,s=t.length;n<s;n++){switch(t[n].type){case"text":i+=t[n].content;break;case"image":i+=this.renderInlineAsText(t[n].children,e,r);break;case"html_inline":case"html_block":i+=t[n].content;break;case"softbreak":case"hardbreak":i+="\n";break}}return i};tp.prototype.render=function(t,e,r){let i="";const n=this.rules;for(let s=0,l=t.length;s<l;s++){const l=t[s].type;if(l==="inline"){i+=this.renderInline(t[s].children,e,r)}else if(typeof n[l]!=="undefined"){i+=n[l](t,s,e,r,this)}else{i+=this.renderToken(t,s,e,r)}}return i};function ep(){this.__rules__=[];this.__cache__=null}ep.prototype.__find__=function(t){for(let e=0;e<this.__rules__.length;e++){if(this.__rules__[e].name===t){return e}}return-1};ep.prototype.__compile__=function(){const t=this;const e=[""];t.__rules__.forEach((function(t){if(!t.enabled){return}t.alt.forEach((function(t){if(e.indexOf(t)<0){e.push(t)}}))}));t.__cache__={};e.forEach((function(e){t.__cache__[e]=[];t.__rules__.forEach((function(r){if(!r.enabled){return}if(e&&r.alt.indexOf(e)<0){return}t.__cache__[e].push(r.fn)}))}))};ep.prototype.at=function(t,e,r){const i=this.__find__(t);const n=r||{};if(i===-1){throw new Error("Parser rule not found: "+t)}this.__rules__[i].fn=e;this.__rules__[i].alt=n.alt||[];this.__cache__=null};ep.prototype.before=function(t,e,r,i){const n=this.__find__(t);const s=i||{};if(n===-1){throw new Error("Parser rule not found: "+t)}this.__rules__.splice(n,0,{name:e,enabled:true,fn:r,alt:s.alt||[]});this.__cache__=null};ep.prototype.after=function(t,e,r,i){const n=this.__find__(t);const s=i||{};if(n===-1){throw new Error("Parser rule not found: "+t)}this.__rules__.splice(n+1,0,{name:e,enabled:true,fn:r,alt:s.alt||[]});this.__cache__=null};ep.prototype.push=function(t,e,r){const i=r||{};this.__rules__.push({name:t,enabled:true,fn:e,alt:i.alt||[]});this.__cache__=null};ep.prototype.enable=function(t,e){if(!Array.isArray(t)){t=[t]}const r=[];t.forEach((function(t){const i=this.__find__(t);if(i<0){if(e){return}throw new Error("Rules manager: invalid rule name "+t)}this.__rules__[i].enabled=true;r.push(t)}),this);this.__cache__=null;return r};ep.prototype.enableOnly=function(t,e){if(!Array.isArray(t)){t=[t]}this.__rules__.forEach((function(t){t.enabled=false}));this.enable(t,e)};ep.prototype.disable=function(t,e){if(!Array.isArray(t)){t=[t]}const r=[];t.forEach((function(t){const i=this.__find__(t);if(i<0){if(e){return}throw new Error("Rules manager: invalid rule name "+t)}this.__rules__[i].enabled=false;r.push(t)}),this);this.__cache__=null;return r};ep.prototype.getRules=function(t){if(this.__cache__===null){this.__compile__()}return this.__cache__[t]||[]};function rp(t,e,r){this.type=t;this.tag=e;this.attrs=null;this.map=null;this.nesting=r;this.level=0;this.children=null;this.content="";this.markup="";this.info="";this.meta=null;this.block=false;this.hidden=false}rp.prototype.attrIndex=function t(e){if(!this.attrs){return-1}const r=this.attrs;for(let t=0,i=r.length;t<i;t++){if(r[t][0]===e){return t}}return-1};rp.prototype.attrPush=function t(e){if(this.attrs){this.attrs.push(e)}else{this.attrs=[e]}};rp.prototype.attrSet=function t(e,r){const i=this.attrIndex(e);const n=[e,r];if(i<0){this.attrPush(n)}else{this.attrs[i]=n}};rp.prototype.attrGet=function t(e){const r=this.attrIndex(e);let i=null;if(r>=0){i=this.attrs[r][1]}return i};rp.prototype.attrJoin=function t(e,r){const i=this.attrIndex(e);if(i<0){this.attrPush([e,r])}else{this.attrs[i][1]=this.attrs[i][1]+" "+r}};function ip(t,e,r){this.src=t;this.env=r;this.tokens=[];this.inlineMode=false;this.md=e}ip.prototype.Token=rp;const np=/\r\n?|\n/g;const sp=/\0/g;function lp(t){let e;e=t.src.replace(np,"\n");e=e.replace(sp,"�");t.src=e}function op(t){let e;if(t.inlineMode){e=new t.Token("inline","",0);e.content=t.src;e.map=[0,1];e.children=[];t.tokens.push(e)}else{t.md.block.parse(t.src,t.md,t.env,t.tokens)}}function up(t){const e=t.tokens;for(let r=0,i=e.length;r<i;r++){const i=e[r];if(i.type==="inline"){t.md.inline.parse(i.content,t.md,t.env,i.children)}}}function fp(t){return/^<a[>\s]/i.test(t)}function hp(t){return/^<\/a\s*>/i.test(t)}function ap(t){const e=t.tokens;if(!t.md.options.linkify){return}for(let r=0,i=e.length;r<i;r++){if(e[r].type!=="inline"||!t.md.linkify.pretest(e[r].content)){continue}let i=e[r].children;let n=0;for(let s=i.length-1;s>=0;s--){const l=i[s];if(l.type==="link_close"){s--;while(i[s].level!==l.level&&i[s].type!=="link_open"){s--}continue}if(l.type==="html_inline"){if(fp(l.content)&&n>0){n--}if(hp(l.content)){n++}}if(n>0){continue}if(l.type==="text"&&t.md.linkify.test(l.content)){const n=l.content;let o=t.md.linkify.match(n);const u=[];let f=l.level;let h=0;if(o.length>0&&o[0].index===0&&s>0&&i[s-1].type==="text_special"){o=o.slice(1)}for(let e=0;e<o.length;e++){const r=o[e].url;const i=t.md.normalizeLink(r);if(!t.md.validateLink(i)){continue}let s=o[e].text;if(!o[e].schema){s=t.md.normalizeLinkText("http://"+s).replace(/^http:\/\//,"")}else if(o[e].schema==="mailto:"&&!/^mailto:/i.test(s)){s=t.md.normalizeLinkText("mailto:"+s).replace(/^mailto:/,"")}else{s=t.md.normalizeLinkText(s)}const l=o[e].index;if(l>h){const e=new t.Token("text","",0);e.content=n.slice(h,l);e.level=f;u.push(e)}const a=new t.Token("link_open","a",1);a.attrs=[["href",i]];a.level=f++;a.markup="linkify";a.info="auto";u.push(a);const c=new t.Token("text","",0);c.content=s;c.level=f;u.push(c);const d=new t.Token("link_close","a",-1);d.level=--f;d.markup="linkify";d.info="auto";u.push(d);h=o[e].lastIndex}if(h<n.length){const e=new t.Token("text","",0);e.content=n.slice(h);e.level=f;u.push(e)}e[r].children=i=Md(i,s,u)}}}}const cp=/\+-|\.\.|\?\?\?\?|!!!!|,,|--/;const dp=/\((c|tm|r)\)/i;const pp=/\((c|tm|r)\)/gi;const mp={c:"©",r:"®",tm:"™"};function wp(t,e){return mp[e.toLowerCase()]}function gp(t){let e=0;for(let r=t.length-1;r>=0;r--){const i=t[r];if(i.type==="text"&&!e){i.content=i.content.replace(pp,wp)}if(i.type==="link_open"&&i.info==="auto"){e--}if(i.type==="link_close"&&i.info==="auto"){e++}}}function bp(t){let e=0;for(let r=t.length-1;r>=0;r--){const i=t[r];if(i.type==="text"&&!e){if(cp.test(i.content)){i.content=i.content.replace(/\+-/g,"±").replace(/\.{2,}/g,"…").replace(/([?!])…/g,"$1..").replace(/([?!]){4,}/g,"$1$1$1").replace(/,{2,}/g,",").replace(/(^|[^-])---(?=[^-]|$)/gm,"$1—").replace(/(^|\s)--(?=\s|$)/gm,"$1–").replace(/(^|[^-\s])--(?=[^-\s]|$)/gm,"$1–")}}if(i.type==="link_open"&&i.info==="auto"){e--}if(i.type==="link_close"&&i.info==="auto"){e++}}}function kp(t){let e;if(!t.md.options.typographer){return}for(e=t.tokens.length-1;e>=0;e--){if(t.tokens[e].type!=="inline"){continue}if(dp.test(t.tokens[e].content)){gp(t.tokens[e].children)}if(cp.test(t.tokens[e].content)){bp(t.tokens[e].children)}}}const Dp=/['"]/;const vp=/['"]/g;const yp="’";function Fp(t,e,r){return t.slice(0,e)+r+t.slice(e+1)}function Ep(t,e){let r;const i=[];for(let n=0;n<t.length;n++){const s=t[n];const l=t[n].level;for(r=i.length-1;r>=0;r--){if(i[r].level<=l){break}}i.length=r+1;if(s.type!=="text"){continue}let o=s.content;let u=0;let f=o.length;t:while(u<f){vp.lastIndex=u;const h=vp.exec(o);if(!h){break}let a=true;let c=true;u=h.index+1;const d=h[0]==="'";let p=32;if(h.index-1>=0){p=o.charCodeAt(h.index-1)}else{for(r=n-1;r>=0;r--){if(t[r].type==="softbreak"||t[r].type==="hardbreak")break;if(!t[r].content)continue;p=t[r].content.charCodeAt(t[r].content.length-1);break}}let m=32;if(u<f){m=o.charCodeAt(u)}else{for(r=n+1;r<t.length;r++){if(t[r].type==="softbreak"||t[r].type==="hardbreak")break;if(!t[r].content)continue;m=t[r].content.charCodeAt(0);break}}const w=Ud(p)||Wd(String.fromCharCode(p));const g=Ud(m)||Wd(String.fromCharCode(m));const b=Ld(p);const k=Ld(m);if(k){a=false}else if(g){if(!(b||w)){a=false}}if(b){c=false}else if(w){if(!(k||g)){c=false}}if(m===34&&h[0]==='"'){if(p>=48&&p<=57){c=a=false}}if(a&&c){a=w;c=g}if(!a&&!c){if(d){s.content=Fp(s.content,h.index,yp)}continue}if(c){for(r=i.length-1;r>=0;r--){let a=i[r];if(i[r].level<l){break}if(a.single===d&&i[r].level===l){a=i[r];let l;let c;if(d){l=e.md.options.quotes[2];c=e.md.options.quotes[3]}else{l=e.md.options.quotes[0];c=e.md.options.quotes[1]}s.content=Fp(s.content,h.index,c);t[a.token].content=Fp(t[a.token].content,a.pos,l);u+=c.length-1;if(a.token===n){u+=l.length-1}o=s.content;f=o.length;i.length=r;continue t}}}if(a){i.push({token:n,pos:h.index,single:d,level:l})}else if(c&&d){s.content=Fp(s.content,h.index,yp)}}}}function Mp(t){if(!t.md.options.typographer){return}for(let e=t.tokens.length-1;e>=0;e--){if(t.tokens[e].type!=="inline"||!Dp.test(t.tokens[e].content)){continue}Ep(t.tokens[e].children,t)}}function xp(t){let e,r;const i=t.tokens;const n=i.length;for(let t=0;t<n;t++){if(i[t].type!=="inline")continue;const n=i[t].children;const s=n.length;for(e=0;e<s;e++){if(n[e].type==="text_special"){n[e].type="text"}}for(e=r=0;e<s;e++){if(n[e].type==="text"&&e+1<s&&n[e+1].type==="text"){n[e+1].content=n[e].content+n[e+1].content}else{if(e!==r){n[r]=n[e]}r++}}if(e!==r){n.length=r}}}const Ap=[["normalize",lp],["block",op],["inline",up],["linkify",ap],["replacements",kp],["smartquotes",Mp],["text_join",xp]];function Cp(){this.ruler=new ep;for(let t=0;t<Ap.length;t++){this.ruler.push(Ap[t][0],Ap[t][1])}}Cp.prototype.process=function(t){const e=this.ruler.getRules("");for(let r=0,i=e.length;r<i;r++){e[r](t)}};Cp.prototype.State=ip;function Sp(t,e,r,i){this.src=t;this.md=e;this.env=r;this.tokens=i;this.bMarks=[];this.eMarks=[];this.tShift=[];this.sCount=[];this.bsCount=[];this.blkIndent=0;this.line=0;this.lineMax=0;this.tight=false;this.ddIndent=-1;this.listIndent=-1;this.parentType="root";this.level=0;const n=this.src;for(let t=0,e=0,r=0,i=0,s=n.length,l=false;e<s;e++){const o=n.charCodeAt(e);if(!l){if(Jd(o)){r++;if(o===9){i+=4-i%4}else{i++}continue}else{l=true}}if(o===10||e===s-1){if(o!==10){e++}this.bMarks.push(t);this.eMarks.push(e);this.tShift.push(r);this.sCount.push(i);this.bsCount.push(0);l=false;r=0;i=0;t=e+1}}this.bMarks.push(n.length);this.eMarks.push(n.length);this.tShift.push(0);this.sCount.push(0);this.bsCount.push(0);this.lineMax=this.bMarks.length-1}Sp.prototype.push=function(t,e,r){const i=new rp(t,e,r);i.block=true;if(r<0)this.level--;i.level=this.level;if(r>0)this.level++;this.tokens.push(i);return i};Sp.prototype.isEmpty=function t(e){return this.bMarks[e]+this.tShift[e]>=this.eMarks[e]};Sp.prototype.skipEmptyLines=function t(e){for(let t=this.lineMax;e<t;e++){if(this.bMarks[e]+this.tShift[e]<this.eMarks[e]){break}}return e};Sp.prototype.skipSpaces=function t(e){for(let t=this.src.length;e<t;e++){const t=this.src.charCodeAt(e);if(!Jd(t)){break}}return e};Sp.prototype.skipSpacesBack=function t(e,r){if(e<=r){return e}while(e>r){if(!Jd(this.src.charCodeAt(--e))){return e+1}}return e};Sp.prototype.skipChars=function t(e,r){for(let t=this.src.length;e<t;e++){if(this.src.charCodeAt(e)!==r){break}}return e};Sp.prototype.skipCharsBack=function t(e,r,i){if(e<=i){return e}while(e>i){if(r!==this.src.charCodeAt(--e)){return e+1}}return e};Sp.prototype.getLines=function t(e,r,i,n){if(e>=r){return""}const s=new Array(r-e);for(let t=0,l=e;l<r;l++,t++){let e=0;const o=this.bMarks[l];let u=o;let f;if(l+1<r||n){f=this.eMarks[l]+1}else{f=this.eMarks[l]}while(u<f&&e<i){const t=this.src.charCodeAt(u);if(Jd(t)){if(t===9){e+=4-(e+this.bsCount[l])%4}else{e++}}else if(u-o<this.tShift[l]){e++}else{break}u++}if(e>i){s[t]=new Array(e-i+1).join(" ")+this.src.slice(u,f)}else{s[t]=this.src.slice(u,f)}}return s.join("")};Sp.prototype.Token=rp;const Op=65536;function $p(t,e){const r=t.bMarks[e]+t.tShift[e];const i=t.eMarks[e];return t.src.slice(r,i)}function _p(t){const e=[];const r=t.length;let i=0;let n=t.charCodeAt(i);let s=false;let l=0;let o="";while(i<r){if(n===124){if(!s){e.push(o+t.substring(l,i));o="";l=i+1}else{o+=t.substring(l,i-1);l=i}}s=n===92;i++;n=t.charCodeAt(i)}e.push(o+t.substring(l));return e}function Bp(t,e,r,i){if(e+2>r){return false}let n=e+1;if(t.sCount[n]<t.blkIndent){return false}if(t.sCount[n]-t.blkIndent>=4){return false}let s=t.bMarks[n]+t.tShift[n];if(s>=t.eMarks[n]){return false}const l=t.src.charCodeAt(s++);if(l!==124&&l!==45&&l!==58){return false}if(s>=t.eMarks[n]){return false}const o=t.src.charCodeAt(s++);if(o!==124&&o!==45&&o!==58&&!Jd(o)){return false}if(l===45&&Jd(o)){return false}while(s<t.eMarks[n]){const e=t.src.charCodeAt(s);if(e!==124&&e!==45&&e!==58&&!Jd(e)){return false}s++}let u=$p(t,e+1);let f=u.split("|");const h=[];for(let t=0;t<f.length;t++){const e=f[t].trim();if(!e){if(t===0||t===f.length-1){continue}else{return false}}if(!/^:?-+:?$/.test(e)){return false}if(e.charCodeAt(e.length-1)===58){h.push(e.charCodeAt(0)===58?"center":"right")}else if(e.charCodeAt(0)===58){h.push("left")}else{h.push("")}}u=$p(t,e).trim();if(u.indexOf("|")===-1){return false}if(t.sCount[e]-t.blkIndent>=4){return false}f=_p(u);if(f.length&&f[0]==="")f.shift();if(f.length&&f[f.length-1]==="")f.pop();const a=f.length;if(a===0||a!==h.length){return false}if(i){return true}const c=t.parentType;t.parentType="table";const d=t.md.block.ruler.getRules("blockquote");const p=t.push("table_open","table",1);const m=[e,0];p.map=m;const w=t.push("thead_open","thead",1);w.map=[e,e+1];const g=t.push("tr_open","tr",1);g.map=[e,e+1];for(let e=0;e<f.length;e++){const r=t.push("th_open","th",1);if(h[e]){r.attrs=[["style","text-align:"+h[e]]]}const i=t.push("inline","",0);i.content=f[e].trim();i.children=[];t.push("th_close","th",-1)}t.push("tr_close","tr",-1);t.push("thead_close","thead",-1);let b;let k=0;for(n=e+2;n<r;n++){if(t.sCount[n]<t.blkIndent){break}let i=false;for(let e=0,s=d.length;e<s;e++){if(d[e](t,n,r,true)){i=true;break}}if(i){break}u=$p(t,n).trim();if(!u){break}if(t.sCount[n]-t.blkIndent>=4){break}f=_p(u);if(f.length&&f[0]==="")f.shift();if(f.length&&f[f.length-1]==="")f.pop();k+=a-f.length;if(k>Op){break}if(n===e+2){const r=t.push("tbody_open","tbody",1);r.map=b=[e+2,0]}const s=t.push("tr_open","tr",1);s.map=[n,n+1];for(let e=0;e<a;e++){const r=t.push("td_open","td",1);if(h[e]){r.attrs=[["style","text-align:"+h[e]]]}const i=t.push("inline","",0);i.content=f[e]?f[e].trim():"";i.children=[];t.push("td_close","td",-1)}t.push("tr_close","tr",-1)}if(b){t.push("tbody_close","tbody",-1);b[1]=n}t.push("table_close","table",-1);m[1]=n;t.parentType=c;t.line=n;return true}function Rp(t,e,r){if(t.sCount[e]-t.blkIndent<4){return false}let i=e+1;let n=i;while(i<r){if(t.isEmpty(i)){i++;continue}if(t.sCount[i]-t.blkIndent>=4){i++;n=i;continue}break}t.line=n;const s=t.push("code_block","code",0);s.content=t.getLines(e,n,4+t.blkIndent,false)+"\n";s.map=[e,t.line];return true}function jp(t,e,r,i){let n=t.bMarks[e]+t.tShift[e];let s=t.eMarks[e];if(t.sCount[e]-t.blkIndent>=4){return false}if(n+3>s){return false}const l=t.src.charCodeAt(n);if(l!==126&&l!==96){return false}let o=n;n=t.skipChars(n,l);let u=n-o;if(u<3){return false}const f=t.src.slice(o,n);const h=t.src.slice(n,s);if(l===96){if(h.indexOf(String.fromCharCode(l))>=0){return false}}if(i){return true}let a=e;let c=false;for(;;){a++;if(a>=r){break}n=o=t.bMarks[a]+t.tShift[a];s=t.eMarks[a];if(n<s&&t.sCount[a]<t.blkIndent){break}if(t.src.charCodeAt(n)!==l){continue}if(t.sCount[a]-t.blkIndent>=4){continue}n=t.skipChars(n,l);if(n-o<u){continue}n=t.skipSpaces(n);if(n<s){continue}c=true;break}u=t.sCount[e];t.line=a+(c?1:0);const d=t.push("fence","code",0);d.info=h;d.content=t.getLines(e+1,a,u,true);d.markup=f;d.map=[e,t.line];return true}function Np(t,e,r,i){let n=t.bMarks[e]+t.tShift[e];let s=t.eMarks[e];const l=t.lineMax;if(t.sCount[e]-t.blkIndent>=4){return false}if(t.src.charCodeAt(n)!==62){return false}if(i){return true}const o=[];const u=[];const f=[];const h=[];const a=t.md.block.ruler.getRules("blockquote");const c=t.parentType;t.parentType="blockquote";let d=false;let p;for(p=e;p<r;p++){const e=t.sCount[p]<t.blkIndent;n=t.bMarks[p]+t.tShift[p];s=t.eMarks[p];if(n>=s){break}if(t.src.charCodeAt(n++)===62&&!e){let e=t.sCount[p]+1;let r;let i;if(t.src.charCodeAt(n)===32){n++;e++;i=false;r=true}else if(t.src.charCodeAt(n)===9){r=true;if((t.bsCount[p]+e)%4===3){n++;e++;i=false}else{i=true}}else{r=false}let l=e;o.push(t.bMarks[p]);t.bMarks[p]=n;while(n<s){const e=t.src.charCodeAt(n);if(Jd(e)){if(e===9){l+=4-(l+t.bsCount[p]+(i?1:0))%4}else{l++}}else{break}n++}d=n>=s;u.push(t.bsCount[p]);t.bsCount[p]=t.sCount[p]+1+(r?1:0);f.push(t.sCount[p]);t.sCount[p]=l-e;h.push(t.tShift[p]);t.tShift[p]=n-t.bMarks[p];continue}if(d){break}let i=false;for(let e=0,n=a.length;e<n;e++){if(a[e](t,p,r,true)){i=true;break}}if(i){t.lineMax=p;if(t.blkIndent!==0){o.push(t.bMarks[p]);u.push(t.bsCount[p]);h.push(t.tShift[p]);f.push(t.sCount[p]);t.sCount[p]-=t.blkIndent}break}o.push(t.bMarks[p]);u.push(t.bsCount[p]);h.push(t.tShift[p]);f.push(t.sCount[p]);t.sCount[p]=-1}const m=t.blkIndent;t.blkIndent=0;const w=t.push("blockquote_open","blockquote",1);w.markup=">";const g=[e,0];w.map=g;t.md.block.tokenize(t,e,p);const b=t.push("blockquote_close","blockquote",-1);b.markup=">";t.lineMax=l;t.parentType=c;g[1]=t.line;for(let r=0;r<h.length;r++){t.bMarks[r+e]=o[r];t.tShift[r+e]=h[r];t.sCount[r+e]=f[r];t.bsCount[r+e]=u[r]}t.blkIndent=m;return true}function qp(t,e,r,i){const n=t.eMarks[e];if(t.sCount[e]-t.blkIndent>=4){return false}let s=t.bMarks[e]+t.tShift[e];const l=t.src.charCodeAt(s++);if(l!==42&&l!==45&&l!==95){return false}let o=1;while(s<n){const e=t.src.charCodeAt(s++);if(e!==l&&!Jd(e)){return false}if(e===l){o++}}if(o<3){return false}if(i){return true}t.line=e+1;const u=t.push("hr","hr",0);u.map=[e,t.line];u.markup=Array(o+1).join(String.fromCharCode(l));return true}function zp(t,e){const r=t.eMarks[e];let i=t.bMarks[e]+t.tShift[e];const n=t.src.charCodeAt(i++);if(n!==42&&n!==45&&n!==43){return-1}if(i<r){const e=t.src.charCodeAt(i);if(!Jd(e)){return-1}}return i}function Tp(t,e){const r=t.bMarks[e]+t.tShift[e];const i=t.eMarks[e];let n=r;if(n+1>=i){return-1}let s=t.src.charCodeAt(n++);if(s<48||s>57){return-1}for(;;){if(n>=i){return-1}s=t.src.charCodeAt(n++);if(s>=48&&s<=57){if(n-r>=10){return-1}continue}if(s===41||s===46){break}return-1}if(n<i){s=t.src.charCodeAt(n);if(!Jd(s)){return-1}}return n}function Ip(t,e){const r=t.level+2;for(let i=e+2,n=t.tokens.length-2;i<n;i++){if(t.tokens[i].level===r&&t.tokens[i].type==="paragraph_open"){t.tokens[i+2].hidden=true;t.tokens[i].hidden=true;i+=2}}}function Pp(t,e,r,i){let n,s,l,o;let u=e;let f=true;if(t.sCount[u]-t.blkIndent>=4){return false}if(t.listIndent>=0&&t.sCount[u]-t.listIndent>=4&&t.sCount[u]<t.blkIndent){return false}let h=false;if(i&&t.parentType==="paragraph"){if(t.sCount[u]>=t.blkIndent){h=true}}let a;let c;let d;if((d=Tp(t,u))>=0){a=true;l=t.bMarks[u]+t.tShift[u];c=Number(t.src.slice(l,d-1));if(h&&c!==1)return false}else if((d=zp(t,u))>=0){a=false}else{return false}if(h){if(t.skipSpaces(d)>=t.eMarks[u])return false}if(i){return true}const p=t.src.charCodeAt(d-1);const m=t.tokens.length;if(a){o=t.push("ordered_list_open","ol",1);if(c!==1){o.attrs=[["start",c]]}}else{o=t.push("bullet_list_open","ul",1)}const w=[u,0];o.map=w;o.markup=String.fromCharCode(p);let g=false;const b=t.md.block.ruler.getRules("list");const k=t.parentType;t.parentType="list";while(u<r){s=d;n=t.eMarks[u];const e=t.sCount[u]+d-(t.bMarks[u]+t.tShift[u]);let i=e;while(s<n){const e=t.src.charCodeAt(s);if(e===9){i+=4-(i+t.bsCount[u])%4}else if(e===32){i++}else{break}s++}const h=s;let c;if(h>=n){c=1}else{c=i-e}if(c>4){c=1}const m=e+c;o=t.push("list_item_open","li",1);o.markup=String.fromCharCode(p);const w=[u,0];o.map=w;if(a){o.info=t.src.slice(l,d-1)}const k=t.tight;const D=t.tShift[u];const v=t.sCount[u];const y=t.listIndent;t.listIndent=t.blkIndent;t.blkIndent=m;t.tight=true;t.tShift[u]=h-t.bMarks[u];t.sCount[u]=i;if(h>=n&&t.isEmpty(u+1)){t.line=Math.min(t.line+2,r)}else{t.md.block.tokenize(t,u,r,true)}if(!t.tight||g){f=false}g=t.line-u>1&&t.isEmpty(t.line-1);t.blkIndent=t.listIndent;t.listIndent=y;t.tShift[u]=D;t.sCount[u]=v;t.tight=k;o=t.push("list_item_close","li",-1);o.markup=String.fromCharCode(p);u=t.line;w[1]=u;if(u>=r){break}if(t.sCount[u]<t.blkIndent){break}if(t.sCount[u]-t.blkIndent>=4){break}let F=false;for(let e=0,i=b.length;e<i;e++){if(b[e](t,u,r,true)){F=true;break}}if(F){break}if(a){d=Tp(t,u);if(d<0){break}l=t.bMarks[u]+t.tShift[u]}else{d=zp(t,u);if(d<0){break}}if(p!==t.src.charCodeAt(d-1)){break}}if(a){o=t.push("ordered_list_close","ol",-1)}else{o=t.push("bullet_list_close","ul",-1)}o.markup=String.fromCharCode(p);w[1]=u;t.line=u;t.parentType=k;if(f){Ip(t,m)}return true}function Jp(t,e,r,i){let n=t.bMarks[e]+t.tShift[e];let s=t.eMarks[e];let l=e+1;if(t.sCount[e]-t.blkIndent>=4){return false}if(t.src.charCodeAt(n)!==91){return false}function o(e){const r=t.lineMax;if(e>=r||t.isEmpty(e)){return null}let i=false;if(t.sCount[e]-t.blkIndent>3){i=true}if(t.sCount[e]<0){i=true}if(!i){const i=t.md.block.ruler.getRules("reference");const n=t.parentType;t.parentType="reference";let s=false;for(let n=0,l=i.length;n<l;n++){if(i[n](t,e,r,true)){s=true;break}}t.parentType=n;if(s){return null}}const n=t.bMarks[e]+t.tShift[e];const s=t.eMarks[e];return t.src.slice(n,s+1)}let u=t.src.slice(n,s+1);s=u.length;let f=-1;for(n=1;n<s;n++){const t=u.charCodeAt(n);if(t===91){return false}else if(t===93){f=n;break}else if(t===10){const t=o(l);if(t!==null){u+=t;s=u.length;l++}}else if(t===92){n++;if(n<s&&u.charCodeAt(n)===10){const t=o(l);if(t!==null){u+=t;s=u.length;l++}}}}if(f<0||u.charCodeAt(f+1)!==58){return false}for(n=f+2;n<s;n++){const t=u.charCodeAt(n);if(t===10){const t=o(l);if(t!==null){u+=t;s=u.length;l++}}else if(Jd(t));else{break}}const h=t.md.helpers.parseLinkDestination(u,n,s);if(!h.ok){return false}const a=t.md.normalizeLink(h.str);if(!t.md.validateLink(a)){return false}n=h.pos;const c=n;const d=l;const p=n;for(;n<s;n++){const t=u.charCodeAt(n);if(t===10){const t=o(l);if(t!==null){u+=t;s=u.length;l++}}else if(Jd(t));else{break}}let m=t.md.helpers.parseLinkTitle(u,n,s);while(m.can_continue){const e=o(l);if(e===null)break;u+=e;n=s;s=u.length;l++;m=t.md.helpers.parseLinkTitle(u,n,s,m)}let w;if(n<s&&p!==n&&m.ok){w=m.str;n=m.pos}else{w="";n=c;l=d}while(n<s){const t=u.charCodeAt(n);if(!Jd(t)){break}n++}if(n<s&&u.charCodeAt(n)!==10){if(w){w="";n=c;l=d;while(n<s){const t=u.charCodeAt(n);if(!Jd(t)){break}n++}}}if(n<s&&u.charCodeAt(n)!==10){return false}const g=Hd(u.slice(1,f));if(!g){return false}if(i){return true}if(typeof t.env.references==="undefined"){t.env.references={}}if(typeof t.env.references[g]==="undefined"){t.env.references[g]={title:w,href:a}}t.line=l;return true}const Lp=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"];const Wp="[a-zA-Z_:][a-zA-Z0-9:._-]*";const Up="[^\"'=<>`\\x00-\\x20]+";const Hp="'[^']*'";const Zp='"[^"]*"';const Kp="(?:"+Up+"|"+Hp+"|"+Zp+")";const Vp="(?:\\s+"+Wp+"(?:\\s*=\\s*"+Kp+")?)";const Gp="<[A-Za-z][A-Za-z0-9\\-]*"+Vp+"*\\s*\\/?>";const Xp="<\\/[A-Za-z][A-Za-z0-9\\-]*\\s*>";const Yp="\x3c!---?>|\x3c!--(?:[^-]|-[^-]|--[^>])*--\x3e";const Qp="<[?][\\s\\S]*?[?]>";const tm="<![A-Za-z][^>]*>";const em="<!\\[CDATA\\[[\\s\\S]*?\\]\\]>";const rm=new RegExp("^(?:"+Gp+"|"+Xp+"|"+Yp+"|"+Qp+"|"+tm+"|"+em+")");const im=new RegExp("^(?:"+Gp+"|"+Xp+")");const nm=[[/^<(script|pre|style|textarea)(?=(\s|>|$))/i,/<\/(script|pre|style|textarea)>/i,true],[/^<!--/,/-->/,true],[/^<\?/,/\?>/,true],[/^<![A-Z]/,/>/,true],[/^<!\[CDATA\[/,/\]\]>/,true],[new RegExp("^</?("+Lp.join("|")+")(?=(\\s|/?>|$))","i"),/^$/,true],[new RegExp(im.source+"\\s*$"),/^$/,false]];function sm(t,e,r,i){let n=t.bMarks[e]+t.tShift[e];let s=t.eMarks[e];if(t.sCount[e]-t.blkIndent>=4){return false}if(!t.md.options.html){return false}if(t.src.charCodeAt(n)!==60){return false}let l=t.src.slice(n,s);let o=0;for(;o<nm.length;o++){if(nm[o][0].test(l)){break}}if(o===nm.length){return false}if(i){return nm[o][2]}let u=e+1;if(!nm[o][1].test(l)){for(;u<r;u++){if(t.sCount[u]<t.blkIndent){break}n=t.bMarks[u]+t.tShift[u];s=t.eMarks[u];l=t.src.slice(n,s);if(nm[o][1].test(l)){if(l.length!==0){u++}break}}}t.line=u;const f=t.push("html_block","",0);f.map=[e,u];f.content=t.getLines(e,u,t.blkIndent,true);return true}function lm(t,e,r,i){let n=t.bMarks[e]+t.tShift[e];let s=t.eMarks[e];if(t.sCount[e]-t.blkIndent>=4){return false}let l=t.src.charCodeAt(n);if(l!==35||n>=s){return false}let o=1;l=t.src.charCodeAt(++n);while(l===35&&n<s&&o<=6){o++;l=t.src.charCodeAt(++n)}if(o>6||n<s&&!Jd(l)){return false}if(i){return true}s=t.skipSpacesBack(s,n);const u=t.skipCharsBack(s,35,n);if(u>n&&Jd(t.src.charCodeAt(u-1))){s=u}t.line=e+1;const f=t.push("heading_open","h"+String(o),1);f.markup="########".slice(0,o);f.map=[e,t.line];const h=t.push("inline","",0);h.content=t.src.slice(n,s).trim();h.map=[e,t.line];h.children=[];const a=t.push("heading_close","h"+String(o),-1);a.markup="########".slice(0,o);return true}function om(t,e,r){const i=t.md.block.ruler.getRules("paragraph");if(t.sCount[e]-t.blkIndent>=4){return false}const n=t.parentType;t.parentType="paragraph";let s=0;let l;let o=e+1;for(;o<r&&!t.isEmpty(o);o++){if(t.sCount[o]-t.blkIndent>3){continue}if(t.sCount[o]>=t.blkIndent){let e=t.bMarks[o]+t.tShift[o];const r=t.eMarks[o];if(e<r){l=t.src.charCodeAt(e);if(l===45||l===61){e=t.skipChars(e,l);e=t.skipSpaces(e);if(e>=r){s=l===61?1:2;break}}}}if(t.sCount[o]<0){continue}let e=false;for(let n=0,s=i.length;n<s;n++){if(i[n](t,o,r,true)){e=true;break}}if(e){break}}if(!s){return false}const u=t.getLines(e,o,t.blkIndent,false).trim();t.line=o+1;const f=t.push("heading_open","h"+String(s),1);f.markup=String.fromCharCode(l);f.map=[e,t.line];const h=t.push("inline","",0);h.content=u;h.map=[e,t.line-1];h.children=[];const a=t.push("heading_close","h"+String(s),-1);a.markup=String.fromCharCode(l);t.parentType=n;return true}function um(t,e,r){const i=t.md.block.ruler.getRules("paragraph");const n=t.parentType;let s=e+1;t.parentType="paragraph";for(;s<r&&!t.isEmpty(s);s++){if(t.sCount[s]-t.blkIndent>3){continue}if(t.sCount[s]<0){continue}let e=false;for(let n=0,l=i.length;n<l;n++){if(i[n](t,s,r,true)){e=true;break}}if(e){break}}const l=t.getLines(e,s,t.blkIndent,false).trim();t.line=s;const o=t.push("paragraph_open","p",1);o.map=[e,t.line];const u=t.push("inline","",0);u.content=l;u.map=[e,t.line];u.children=[];t.push("paragraph_close","p",-1);t.parentType=n;return true}const fm=[["table",Bp,["paragraph","reference"]],["code",Rp],["fence",jp,["paragraph","reference","blockquote","list"]],["blockquote",Np,["paragraph","reference","blockquote","list"]],["hr",qp,["paragraph","reference","blockquote","list"]],["list",Pp,["paragraph","reference","blockquote"]],["reference",Jp],["html_block",sm,["paragraph","reference","blockquote"]],["heading",lm,["paragraph","reference","blockquote"]],["lheading",om],["paragraph",um]];function hm(){this.ruler=new ep;for(let t=0;t<fm.length;t++){this.ruler.push(fm[t][0],fm[t][1],{alt:(fm[t][2]||[]).slice()})}}hm.prototype.tokenize=function(t,e,r){const i=this.ruler.getRules("");const n=i.length;const s=t.md.options.maxNesting;let l=e;let o=false;while(l<r){t.line=l=t.skipEmptyLines(l);if(l>=r){break}if(t.sCount[l]<t.blkIndent){break}if(t.level>=s){t.line=r;break}const e=t.line;let u=false;for(let s=0;s<n;s++){u=i[s](t,l,r,false);if(u){if(e>=t.line){throw new Error("block rule didn't increment state.line")}break}}if(!u)throw new Error("none of the block rules matched");t.tight=!o;if(t.isEmpty(t.line-1)){o=true}l=t.line;if(l<r&&t.isEmpty(l)){o=true;l++;t.line=l}}};hm.prototype.parse=function(t,e,r,i){if(!t){return}const n=new this.State(t,e,r,i);this.tokenize(n,n.line,n.lineMax)};hm.prototype.State=Sp;function am(t,e,r,i){this.src=t;this.env=r;this.md=e;this.tokens=i;this.tokens_meta=Array(i.length);this.pos=0;this.posMax=this.src.length;this.level=0;this.pending="";this.pendingLevel=0;this.cache={};this.delimiters=[];this._prev_delimiters=[];this.backticks={};this.backticksScanned=false;this.linkLevel=0}am.prototype.pushPending=function(){const t=new rp("text","",0);t.content=this.pending;t.level=this.pendingLevel;this.tokens.push(t);this.pending="";return t};am.prototype.push=function(t,e,r){if(this.pending){this.pushPending()}const i=new rp(t,e,r);let n=null;if(r<0){this.level--;this.delimiters=this._prev_delimiters.pop()}i.level=this.level;if(r>0){this.level++;this._prev_delimiters.push(this.delimiters);this.delimiters=[];n={delimiters:this.delimiters}}this.pendingLevel=this.level;this.tokens.push(i);this.tokens_meta.push(n);return i};am.prototype.scanDelims=function(t,e){const r=this.posMax;const i=this.src.charCodeAt(t);const n=t>0?this.src.charCodeAt(t-1):32;let s=t;while(s<r&&this.src.charCodeAt(s)===i){s++}const l=s-t;const o=s<r?this.src.charCodeAt(s):32;const u=Ud(n)||Wd(String.fromCharCode(n));const f=Ud(o)||Wd(String.fromCharCode(o));const h=Ld(n);const a=Ld(o);const c=!a&&(!f||h||u);const d=!h&&(!u||a||f);const p=c&&(e||!d||u);const m=d&&(e||!c||f);return{can_open:p,can_close:m,length:l}};am.prototype.Token=rp;function cm(t){switch(t){case 10:case 33:case 35:case 36:case 37:case 38:case 42:case 43:case 45:case 58:case 60:case 61:case 62:case 64:case 91:case 92:case 93:case 94:case 95:case 96:case 123:case 125:case 126:return true;default:return false}}function dm(t,e){let r=t.pos;while(r<t.posMax&&!cm(t.src.charCodeAt(r))){r++}if(r===t.pos){return false}if(!e){t.pending+=t.src.slice(t.pos,r)}t.pos=r;return true}const pm=/(?:^|[^a-z0-9.+-])([a-z][a-z0-9.+-]*)$/i;function mm(t,e){if(!t.md.options.linkify)return false;if(t.linkLevel>0)return false;const r=t.pos;const i=t.posMax;if(r+3>i)return false;if(t.src.charCodeAt(r)!==58)return false;if(t.src.charCodeAt(r+1)!==47)return false;if(t.src.charCodeAt(r+2)!==47)return false;const n=t.pending.match(pm);if(!n)return false;const s=n[1];const l=t.md.linkify.matchAtStart(t.src.slice(r-s.length));if(!l)return false;let o=l.url;if(o.length<=s.length)return false;o=o.replace(/\*+$/,"");const u=t.md.normalizeLink(o);if(!t.md.validateLink(u))return false;if(!e){t.pending=t.pending.slice(0,-s.length);const e=t.push("link_open","a",1);e.attrs=[["href",u]];e.markup="linkify";e.info="auto";const r=t.push("text","",0);r.content=t.md.normalizeLinkText(o);const i=t.push("link_close","a",-1);i.markup="linkify";i.info="auto"}t.pos+=o.length-s.length;return true}function wm(t,e){let r=t.pos;if(t.src.charCodeAt(r)!==10){return false}const i=t.pending.length-1;const n=t.posMax;if(!e){if(i>=0&&t.pending.charCodeAt(i)===32){if(i>=1&&t.pending.charCodeAt(i-1)===32){let e=i-1;while(e>=1&&t.pending.charCodeAt(e-1)===32)e--;t.pending=t.pending.slice(0,e);t.push("hardbreak","br",0)}else{t.pending=t.pending.slice(0,-1);t.push("softbreak","br",0)}}else{t.push("softbreak","br",0)}}r++;while(r<n&&Jd(t.src.charCodeAt(r))){r++}t.pos=r;return true}const gm=[];for(let t=0;t<256;t++){gm.push(0)}"\\!\"#$%&'()*+,./:;<=>?@[]^_`{|}~-".split("").forEach((function(t){gm[t.charCodeAt(0)]=1}));function bm(t,e){let r=t.pos;const i=t.posMax;if(t.src.charCodeAt(r)!==92)return false;r++;if(r>=i)return false;let n=t.src.charCodeAt(r);if(n===10){if(!e){t.push("hardbreak","br",0)}r++;while(r<i){n=t.src.charCodeAt(r);if(!Jd(n))break;r++}t.pos=r;return true}let s=t.src[r];if(n>=55296&&n<=56319&&r+1<i){const e=t.src.charCodeAt(r+1);if(e>=56320&&e<=57343){s+=t.src[r+1];r++}}const l="\\"+s;if(!e){const e=t.push("text_special","",0);if(n<256&&gm[n]!==0){e.content=s}else{e.content=l}e.markup=l;e.info="escape"}t.pos=r+1;return true}function km(t,e){let r=t.pos;const i=t.src.charCodeAt(r);if(i!==96){return false}const n=r;r++;const s=t.posMax;while(r<s&&t.src.charCodeAt(r)===96){r++}const l=t.src.slice(n,r);const o=l.length;if(t.backticksScanned&&(t.backticks[o]||0)<=n){if(!e)t.pending+=l;t.pos+=o;return true}let u=r;let f;while((f=t.src.indexOf("`",u))!==-1){u=f+1;while(u<s&&t.src.charCodeAt(u)===96){u++}const i=u-f;if(i===o){if(!e){const e=t.push("code_inline","code",0);e.markup=l;e.content=t.src.slice(r,f).replace(/\n/g," ").replace(/^ (.+) $/,"$1")}t.pos=u;return true}t.backticks[i]=f}t.backticksScanned=true;if(!e)t.pending+=l;t.pos+=o;return true}function Dm(t,e){const r=t.pos;const i=t.src.charCodeAt(r);if(e){return false}if(i!==126){return false}const n=t.scanDelims(t.pos,true);let s=n.length;const l=String.fromCharCode(i);if(s<2){return false}let o;if(s%2){o=t.push("text","",0);o.content=l;s--}for(let e=0;e<s;e+=2){o=t.push("text","",0);o.content=l+l;t.delimiters.push({marker:i,length:0,token:t.tokens.length-1,end:-1,open:n.can_open,close:n.can_close})}t.pos+=n.length;return true}function vm(t,e){let r;const i=[];const n=e.length;for(let s=0;s<n;s++){const n=e[s];if(n.marker!==126){continue}if(n.end===-1){continue}const l=e[n.end];r=t.tokens[n.token];r.type="s_open";r.tag="s";r.nesting=1;r.markup="~~";r.content="";r=t.tokens[l.token];r.type="s_close";r.tag="s";r.nesting=-1;r.markup="~~";r.content="";if(t.tokens[l.token-1].type==="text"&&t.tokens[l.token-1].content==="~"){i.push(l.token-1)}}while(i.length){const e=i.pop();let n=e+1;while(n<t.tokens.length&&t.tokens[n].type==="s_close"){n++}n--;if(e!==n){r=t.tokens[n];t.tokens[n]=t.tokens[e];t.tokens[e]=r}}}function ym(t){const e=t.tokens_meta;const r=t.tokens_meta.length;vm(t,t.delimiters);for(let i=0;i<r;i++){if(e[i]&&e[i].delimiters){vm(t,e[i].delimiters)}}}const Fm={tokenize:Dm,postProcess:ym};function Em(t,e){const r=t.pos;const i=t.src.charCodeAt(r);if(e){return false}if(i!==95&&i!==42){return false}const n=t.scanDelims(t.pos,i===42);for(let e=0;e<n.length;e++){const e=t.push("text","",0);e.content=String.fromCharCode(i);t.delimiters.push({marker:i,length:n.length,token:t.tokens.length-1,end:-1,open:n.can_open,close:n.can_close})}t.pos+=n.length;return true}function Mm(t,e){const r=e.length;for(let i=r-1;i>=0;i--){const r=e[i];if(r.marker!==95&&r.marker!==42){continue}if(r.end===-1){continue}const n=e[r.end];const s=i>0&&e[i-1].end===r.end+1&&e[i-1].marker===r.marker&&e[i-1].token===r.token-1&&e[r.end+1].token===n.token+1;const l=String.fromCharCode(r.marker);const o=t.tokens[r.token];o.type=s?"strong_open":"em_open";o.tag=s?"strong":"em";o.nesting=1;o.markup=s?l+l:l;o.content="";const u=t.tokens[n.token];u.type=s?"strong_close":"em_close";u.tag=s?"strong":"em";u.nesting=-1;u.markup=s?l+l:l;u.content="";if(s){t.tokens[e[i-1].token].content="";t.tokens[e[r.end+1].token].content="";i--}}}function xm(t){const e=t.tokens_meta;const r=t.tokens_meta.length;Mm(t,t.delimiters);for(let i=0;i<r;i++){if(e[i]&&e[i].delimiters){Mm(t,e[i].delimiters)}}}const Am={tokenize:Em,postProcess:xm};function Cm(t,e){let r,i,n,s;let l="";let o="";let u=t.pos;let f=true;if(t.src.charCodeAt(t.pos)!==91){return false}const h=t.pos;const a=t.posMax;const c=t.pos+1;const d=t.md.helpers.parseLinkLabel(t,t.pos,true);if(d<0){return false}let p=d+1;if(p<a&&t.src.charCodeAt(p)===40){f=false;p++;for(;p<a;p++){r=t.src.charCodeAt(p);if(!Jd(r)&&r!==10){break}}if(p>=a){return false}u=p;n=t.md.helpers.parseLinkDestination(t.src,p,t.posMax);if(n.ok){l=t.md.normalizeLink(n.str);if(t.md.validateLink(l)){p=n.pos}else{l=""}u=p;for(;p<a;p++){r=t.src.charCodeAt(p);if(!Jd(r)&&r!==10){break}}n=t.md.helpers.parseLinkTitle(t.src,p,t.posMax);if(p<a&&u!==p&&n.ok){o=n.str;p=n.pos;for(;p<a;p++){r=t.src.charCodeAt(p);if(!Jd(r)&&r!==10){break}}}}if(p>=a||t.src.charCodeAt(p)!==41){f=true}p++}if(f){if(typeof t.env.references==="undefined"){return false}if(p<a&&t.src.charCodeAt(p)===91){u=p+1;p=t.md.helpers.parseLinkLabel(t,p);if(p>=0){i=t.src.slice(u,p++)}else{p=d+1}}else{p=d+1}if(!i){i=t.src.slice(c,d)}s=t.env.references[Hd(i)];if(!s){t.pos=h;return false}l=s.href;o=s.title}if(!e){t.pos=c;t.posMax=d;const e=t.push("link_open","a",1);const r=[["href",l]];e.attrs=r;if(o){r.push(["title",o])}t.linkLevel++;t.md.inline.tokenize(t);t.linkLevel--;t.push("link_close","a",-1)}t.pos=p;t.posMax=a;return true}function Sm(t,e){let r,i,n,s,l,o,u,f;let h="";const a=t.pos;const c=t.posMax;if(t.src.charCodeAt(t.pos)!==33){return false}if(t.src.charCodeAt(t.pos+1)!==91){return false}const d=t.pos+2;const p=t.md.helpers.parseLinkLabel(t,t.pos+1,false);if(p<0){return false}s=p+1;if(s<c&&t.src.charCodeAt(s)===40){s++;for(;s<c;s++){r=t.src.charCodeAt(s);if(!Jd(r)&&r!==10){break}}if(s>=c){return false}f=s;o=t.md.helpers.parseLinkDestination(t.src,s,t.posMax);if(o.ok){h=t.md.normalizeLink(o.str);if(t.md.validateLink(h)){s=o.pos}else{h=""}}f=s;for(;s<c;s++){r=t.src.charCodeAt(s);if(!Jd(r)&&r!==10){break}}o=t.md.helpers.parseLinkTitle(t.src,s,t.posMax);if(s<c&&f!==s&&o.ok){u=o.str;s=o.pos;for(;s<c;s++){r=t.src.charCodeAt(s);if(!Jd(r)&&r!==10){break}}}else{u=""}if(s>=c||t.src.charCodeAt(s)!==41){t.pos=a;return false}s++}else{if(typeof t.env.references==="undefined"){return false}if(s<c&&t.src.charCodeAt(s)===91){f=s+1;s=t.md.helpers.parseLinkLabel(t,s);if(s>=0){n=t.src.slice(f,s++)}else{s=p+1}}else{s=p+1}if(!n){n=t.src.slice(d,p)}l=t.env.references[Hd(n)];if(!l){t.pos=a;return false}h=l.href;u=l.title}if(!e){i=t.src.slice(d,p);const e=[];t.md.inline.parse(i,t.md,t.env,e);const r=t.push("image","img",0);const n=[["src",h],["alt",""]];r.attrs=n;r.children=e;r.content=i;if(u){n.push(["title",u])}}t.pos=s;t.posMax=c;return true}const Om=/^([a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*)$/;const $m=/^([a-zA-Z][a-zA-Z0-9+.-]{1,31}):([^<>\x00-\x20]*)$/;function _m(t,e){let r=t.pos;if(t.src.charCodeAt(r)!==60){return false}const i=t.pos;const n=t.posMax;for(;;){if(++r>=n)return false;const e=t.src.charCodeAt(r);if(e===60)return false;if(e===62)break}const s=t.src.slice(i+1,r);if($m.test(s)){const r=t.md.normalizeLink(s);if(!t.md.validateLink(r)){return false}if(!e){const e=t.push("link_open","a",1);e.attrs=[["href",r]];e.markup="autolink";e.info="auto";const i=t.push("text","",0);i.content=t.md.normalizeLinkText(s);const n=t.push("link_close","a",-1);n.markup="autolink";n.info="auto"}t.pos+=s.length+2;return true}if(Om.test(s)){const r=t.md.normalizeLink("mailto:"+s);if(!t.md.validateLink(r)){return false}if(!e){const e=t.push("link_open","a",1);e.attrs=[["href",r]];e.markup="autolink";e.info="auto";const i=t.push("text","",0);i.content=t.md.normalizeLinkText(s);const n=t.push("link_close","a",-1);n.markup="autolink";n.info="auto"}t.pos+=s.length+2;return true}return false}function Bm(t){return/^<a[>\s]/i.test(t)}function Rm(t){return/^<\/a\s*>/i.test(t)}function jm(t){const e=t|32;return e>=97&&e<=122}function Nm(t,e){if(!t.md.options.html){return false}const r=t.posMax;const i=t.pos;if(t.src.charCodeAt(i)!==60||i+2>=r){return false}const n=t.src.charCodeAt(i+1);if(n!==33&&n!==63&&n!==47&&!jm(n)){return false}const s=t.src.slice(i).match(rm);if(!s){return false}if(!e){const e=t.push("html_inline","",0);e.content=s[0];if(Bm(e.content))t.linkLevel++;if(Rm(e.content))t.linkLevel--}t.pos+=s[0].length;return true}const qm=/^&#((?:x[a-f0-9]{1,6}|[0-9]{1,7}));/i;const zm=/^&([a-z][a-z0-9]{1,31});/i;function Tm(t,e){const r=t.pos;const i=t.posMax;if(t.src.charCodeAt(r)!==38)return false;if(r+1>=i)return false;const n=t.src.charCodeAt(r+1);if(n===35){const i=t.src.slice(r).match(qm);if(i){if(!e){const e=i[1][0].toLowerCase()==="x"?parseInt(i[1].slice(1),16):parseInt(i[1],10);const r=t.push("text_special","",0);r.content=xd(e)?Ad(e):Ad(65533);r.markup=i[0];r.info="entity"}t.pos+=i[0].length;return true}}else{const i=t.src.slice(r).match(zm);if(i){const r=x(i[0]);if(r!==i[0]){if(!e){const e=t.push("text_special","",0);e.content=r;e.markup=i[0];e.info="entity"}t.pos+=i[0].length;return true}}}return false}function Im(t){const e={};const r=t.length;if(!r)return;let i=0;let n=-2;const s=[];for(let l=0;l<r;l++){const r=t[l];s.push(0);if(t[i].marker!==r.marker||n!==r.token-1){i=l}n=r.token;r.length=r.length||0;if(!r.close)continue;if(!e.hasOwnProperty(r.marker)){e[r.marker]=[-1,-1,-1,-1,-1,-1]}const o=e[r.marker][(r.open?3:0)+r.length%3];let u=i-s[i]-1;let f=u;for(;u>o;u-=s[u]+1){const e=t[u];if(e.marker!==r.marker)continue;if(e.open&&e.end<0){let i=false;if(e.close||r.open){if((e.length+r.length)%3===0){if(e.length%3!==0||r.length%3!==0){i=true}}}if(!i){const i=u>0&&!t[u-1].open?s[u-1]+1:0;s[l]=l-u+i;s[u]=i;r.open=false;e.end=l;e.close=false;f=-1;n=-2;break}}}if(f!==-1){e[r.marker][(r.open?3:0)+(r.length||0)%3]=f}}}function Pm(t){const e=t.tokens_meta;const r=t.tokens_meta.length;Im(t.delimiters);for(let t=0;t<r;t++){if(e[t]&&e[t].delimiters){Im(e[t].delimiters)}}}function Jm(t){let e,r;let i=0;const n=t.tokens;const s=t.tokens.length;for(e=r=0;e<s;e++){if(n[e].nesting<0)i--;n[e].level=i;if(n[e].nesting>0)i++;if(n[e].type==="text"&&e+1<s&&n[e+1].type==="text"){n[e+1].content=n[e].content+n[e+1].content}else{if(e!==r){n[r]=n[e]}r++}}if(e!==r){n.length=r}}const Lm=[["text",dm],["linkify",mm],["newline",wm],["escape",bm],["backticks",km],["strikethrough",Fm.tokenize],["emphasis",Am.tokenize],["link",Cm],["image",Sm],["autolink",_m],["html_inline",Nm],["entity",Tm]];const Wm=[["balance_pairs",Pm],["strikethrough",Fm.postProcess],["emphasis",Am.postProcess],["fragments_join",Jm]];function Um(){this.ruler=new ep;for(let t=0;t<Lm.length;t++){this.ruler.push(Lm[t][0],Lm[t][1])}this.ruler2=new ep;for(let t=0;t<Wm.length;t++){this.ruler2.push(Wm[t][0],Wm[t][1])}}Um.prototype.skipToken=function(t){const e=t.pos;const r=this.ruler.getRules("");const i=r.length;const n=t.md.options.maxNesting;const s=t.cache;if(typeof s[e]!=="undefined"){t.pos=s[e];return}let l=false;if(t.level<n){for(let n=0;n<i;n++){t.level++;l=r[n](t,true);t.level--;if(l){if(e>=t.pos){throw new Error("inline rule didn't increment state.pos")}break}}}else{t.pos=t.posMax}if(!l){t.pos++}s[e]=t.pos};Um.prototype.tokenize=function(t){const e=this.ruler.getRules("");const r=e.length;const i=t.posMax;const n=t.md.options.maxNesting;while(t.pos<i){const s=t.pos;let l=false;if(t.level<n){for(let i=0;i<r;i++){l=e[i](t,false);if(l){if(s>=t.pos){throw new Error("inline rule didn't increment state.pos")}break}}}if(l){if(t.pos>=i){break}continue}t.pending+=t.src[t.pos++]}if(t.pending){t.pushPending()}};Um.prototype.parse=function(t,e,r,i){const n=new this.State(t,e,r,i);this.tokenize(n);const s=this.ruler2.getRules("");const l=s.length;for(let t=0;t<l;t++){s[t](n)}};Um.prototype.State=am;function Hm(t){const e={};t=t||{};e.src_Any=dd.source;e.src_Cc=pd.source;e.src_Z=bd.source;e.src_P=wd.source;e.src_ZPCc=[e.src_Z,e.src_P,e.src_Cc].join("|");e.src_ZCc=[e.src_Z,e.src_Cc].join("|");const r="[><|]";e.src_pseudo_letter="(?:(?!"+r+"|"+e.src_ZPCc+")"+e.src_Any+")";e.src_ip4="(?:(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)";e.src_auth="(?:(?:(?!"+e.src_ZCc+"|[@/\\[\\]()]).)+@)?";e.src_port="(?::(?:6(?:[0-4]\\d{3}|5(?:[0-4]\\d{2}|5(?:[0-2]\\d|3[0-5])))|[1-5]?\\d{1,4}))?";e.src_host_terminator="(?=$|"+r+"|"+e.src_ZPCc+")"+"(?!"+(t["---"]?"-(?!--)|":"-|")+"_|:\\d|\\.-|\\.(?!$|"+e.src_ZPCc+"))";e.src_path="(?:"+"[/?#]"+"(?:"+"(?!"+e.src_ZCc+"|"+r+"|[()[\\]{}.,\"'?!\\-;]).|"+"\\[(?:(?!"+e.src_ZCc+"|\\]).)*\\]|"+"\\((?:(?!"+e.src_ZCc+"|[)]).)*\\)|"+"\\{(?:(?!"+e.src_ZCc+"|[}]).)*\\}|"+'\\"(?:(?!'+e.src_ZCc+'|["]).)+\\"|'+"\\'(?:(?!"+e.src_ZCc+"|[']).)+\\'|"+"\\'(?="+e.src_pseudo_letter+"|[-])|"+"\\.{2,}[a-zA-Z0-9%/&]|"+"\\.(?!"+e.src_ZCc+"|[.]|$)|"+(t["---"]?"\\-(?!--(?:[^-]|$))(?:-*)|":"\\-+|")+",(?!"+e.src_ZCc+"|$)|"+";(?!"+e.src_ZCc+"|$)|"+"\\!+(?!"+e.src_ZCc+"|[!]|$)|"+"\\?(?!"+e.src_ZCc+"|[?]|$)"+")+"+"|\\/"+")?";e.src_email_name='[\\-;:&=\\+\\$,\\.a-zA-Z0-9_][\\-;:&=\\+\\$,\\"\\.a-zA-Z0-9_]*';e.src_xn="xn--[a-z0-9\\-]{1,59}";e.src_domain_root="(?:"+e.src_xn+"|"+e.src_pseudo_letter+"{1,63}"+")";e.src_domain="(?:"+e.src_xn+"|"+"(?:"+e.src_pseudo_letter+")"+"|"+"(?:"+e.src_pseudo_letter+"(?:-|"+e.src_pseudo_letter+"){0,61}"+e.src_pseudo_letter+")"+")";e.src_host="(?:"+"(?:(?:(?:"+e.src_domain+")\\.)*"+e.src_domain+")"+")";e.tpl_host_fuzzy="(?:"+e.src_ip4+"|"+"(?:(?:(?:"+e.src_domain+")\\.)+(?:%TLDS%))"+")";e.tpl_host_no_ip_fuzzy="(?:(?:(?:"+e.src_domain+")\\.)+(?:%TLDS%))";e.src_host_strict=e.src_host+e.src_host_terminator;e.tpl_host_fuzzy_strict=e.tpl_host_fuzzy+e.src_host_terminator;e.src_host_port_strict=e.src_host+e.src_port+e.src_host_terminator;e.tpl_host_port_fuzzy_strict=e.tpl_host_fuzzy+e.src_port+e.src_host_terminator;e.tpl_host_port_no_ip_fuzzy_strict=e.tpl_host_no_ip_fuzzy+e.src_port+e.src_host_terminator;e.tpl_host_fuzzy_test="localhost|www\\.|\\.\\d{1,3}\\.|(?:\\.(?:%TLDS%)(?:"+e.src_ZPCc+"|>|$))";e.tpl_email_fuzzy="(^|"+r+'|"|\\(|'+e.src_ZCc+")"+"("+e.src_email_name+"@"+e.tpl_host_fuzzy_strict+")";e.tpl_link_fuzzy="(^|(?![.:/\\-_@])(?:[$+<=>^`||]|"+e.src_ZPCc+"))"+"((?![$+<=>^`||])"+e.tpl_host_port_fuzzy_strict+e.src_path+")";e.tpl_link_no_ip_fuzzy="(^|(?![.:/\\-_@])(?:[$+<=>^`||]|"+e.src_ZPCc+"))"+"((?![$+<=>^`||])"+e.tpl_host_port_no_ip_fuzzy_strict+e.src_path+")";return e}function Zm(t){const e=Array.prototype.slice.call(arguments,1);e.forEach((function(e){if(!e){return}Object.keys(e).forEach((function(r){t[r]=e[r]}))}));return t}function Km(t){return Object.prototype.toString.call(t)}function Vm(t){return Km(t)==="[object String]"}function Gm(t){return Km(t)==="[object Object]"}function Xm(t){return Km(t)==="[object RegExp]"}function Ym(t){return Km(t)==="[object Function]"}function Qm(t){return t.replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}const tw={fuzzyLink:true,fuzzyEmail:true,fuzzyIP:false};function ew(t){return Object.keys(t||{}).reduce((function(t,e){return t||tw.hasOwnProperty(e)}),false)}const rw={"http:":{validate:function(t,e,r){const i=t.slice(e);if(!r.re.http){r.re.http=new RegExp("^\\/\\/"+r.re.src_auth+r.re.src_host_port_strict+r.re.src_path,"i")}if(r.re.http.test(i)){return i.match(r.re.http)[0].length}return 0}},"https:":"http:","ftp:":"http:","//":{validate:function(t,e,r){const i=t.slice(e);if(!r.re.no_http){r.re.no_http=new RegExp("^"+r.re.src_auth+"(?:localhost|(?:(?:"+r.re.src_domain+")\\.)+"+r.re.src_domain_root+")"+r.re.src_port+r.re.src_host_terminator+r.re.src_path,"i")}if(r.re.no_http.test(i)){if(e>=3&&t[e-3]===":"){return 0}if(e>=3&&t[e-3]==="/"){return 0}return i.match(r.re.no_http)[0].length}return 0}},"mailto:":{validate:function(t,e,r){const i=t.slice(e);if(!r.re.mailto){r.re.mailto=new RegExp("^"+r.re.src_email_name+"@"+r.re.src_host_strict,"i")}if(r.re.mailto.test(i)){return i.match(r.re.mailto)[0].length}return 0}}};const iw="a[cdefgilmnoqrstuwxz]|b[abdefghijmnorstvwyz]|c[acdfghiklmnoruvwxyz]|d[ejkmoz]|e[cegrstu]|f[ijkmor]|g[abdefghilmnpqrstuwy]|h[kmnrtu]|i[delmnoqrst]|j[emop]|k[eghimnprwyz]|l[abcikrstuvy]|m[acdeghklmnopqrstuvwxyz]|n[acefgilopruz]|om|p[aefghklmnrstwy]|qa|r[eosuw]|s[abcdeghijklmnortuvxyz]|t[cdfghjklmnortvwz]|u[agksyz]|v[aceginu]|w[fs]|y[et]|z[amw]";const nw="biz|com|edu|gov|net|org|pro|web|xxx|aero|asia|coop|info|museum|name|shop|рф".split("|");function sw(t){t.__index__=-1;t.__text_cache__=""}function lw(t){return function(e,r){const i=e.slice(r);if(t.test(i)){return i.match(t)[0].length}return 0}}function ow(){return function(t,e){e.normalize(t)}}function uw(t){const e=t.re=Hm(t.__opts__);const r=t.__tlds__.slice();t.onCompile();if(!t.__tlds_replaced__){r.push(iw)}r.push(e.src_xn);e.src_tlds=r.join("|");function i(t){return t.replace("%TLDS%",e.src_tlds)}e.email_fuzzy=RegExp(i(e.tpl_email_fuzzy),"i");e.link_fuzzy=RegExp(i(e.tpl_link_fuzzy),"i");e.link_no_ip_fuzzy=RegExp(i(e.tpl_link_no_ip_fuzzy),"i");e.host_fuzzy_test=RegExp(i(e.tpl_host_fuzzy_test),"i");const n=[];t.__compiled__={};function s(t,e){throw new Error('(LinkifyIt) Invalid schema "'+t+'": '+e)}Object.keys(t.__schemas__).forEach((function(e){const r=t.__schemas__[e];if(r===null){return}const i={validate:null,link:null};t.__compiled__[e]=i;if(Gm(r)){if(Xm(r.validate)){i.validate=lw(r.validate)}else if(Ym(r.validate)){i.validate=r.validate}else{s(e,r)}if(Ym(r.normalize)){i.normalize=r.normalize}else if(!r.normalize){i.normalize=ow()}else{s(e,r)}return}if(Vm(r)){n.push(e);return}s(e,r)}));n.forEach((function(e){if(!t.__compiled__[t.__schemas__[e]]){return}t.__compiled__[e].validate=t.__compiled__[t.__schemas__[e]].validate;t.__compiled__[e].normalize=t.__compiled__[t.__schemas__[e]].normalize}));t.__compiled__[""]={validate:null,normalize:ow()};const l=Object.keys(t.__compiled__).filter((function(e){return e.length>0&&t.__compiled__[e]})).map(Qm).join("|");t.re.schema_test=RegExp("(^|(?!_)(?:[><|]|"+e.src_ZPCc+"))("+l+")","i");t.re.schema_search=RegExp("(^|(?!_)(?:[><|]|"+e.src_ZPCc+"))("+l+")","ig");t.re.schema_at_start=RegExp("^"+t.re.schema_search.source,"i");t.re.pretest=RegExp("("+t.re.schema_test.source+")|("+t.re.host_fuzzy_test.source+")|@","i");sw(t)}function fw(t,e){const r=t.__index__;const i=t.__last_index__;const n=t.__text_cache__.slice(r,i);this.schema=t.__schema__.toLowerCase();this.index=r+e;this.lastIndex=i+e;this.raw=n;this.text=n;this.url=n}function hw(t,e){const r=new fw(t,e);t.__compiled__[r.schema].normalize(r,t);return r}function aw(t,e){if(!(this instanceof aw)){return new aw(t,e)}if(!e){if(ew(t)){e=t;t={}}}this.__opts__=Zm({},tw,e);this.__index__=-1;this.__last_index__=-1;this.__schema__="";this.__text_cache__="";this.__schemas__=Zm({},rw,t);this.__compiled__={};this.__tlds__=nw;this.__tlds_replaced__=false;this.re={};uw(this)}aw.prototype.add=function t(e,r){this.__schemas__[e]=r;uw(this);return this};aw.prototype.set=function t(e){this.__opts__=Zm(this.__opts__,e);return this};aw.prototype.test=function t(e){this.__text_cache__=e;this.__index__=-1;if(!e.length){return false}let r,i,n,s,l,o,u,f,h;if(this.re.schema_test.test(e)){u=this.re.schema_search;u.lastIndex=0;while((r=u.exec(e))!==null){s=this.testSchemaAt(e,r[2],u.lastIndex);if(s){this.__schema__=r[2];this.__index__=r.index+r[1].length;this.__last_index__=r.index+r[0].length+s;break}}}if(this.__opts__.fuzzyLink&&this.__compiled__["http:"]){f=e.search(this.re.host_fuzzy_test);if(f>=0){if(this.__index__<0||f<this.__index__){if((i=e.match(this.__opts__.fuzzyIP?this.re.link_fuzzy:this.re.link_no_ip_fuzzy))!==null){l=i.index+i[1].length;if(this.__index__<0||l<this.__index__){this.__schema__="";this.__index__=l;this.__last_index__=i.index+i[0].length}}}}}if(this.__opts__.fuzzyEmail&&this.__compiled__["mailto:"]){h=e.indexOf("@");if(h>=0){if((n=e.match(this.re.email_fuzzy))!==null){l=n.index+n[1].length;o=n.index+n[0].length;if(this.__index__<0||l<this.__index__||l===this.__index__&&o>this.__last_index__){this.__schema__="mailto:";this.__index__=l;this.__last_index__=o}}}}return this.__index__>=0};aw.prototype.pretest=function t(e){return this.re.pretest.test(e)};aw.prototype.testSchemaAt=function t(e,r,i){if(!this.__compiled__[r.toLowerCase()]){return 0}return this.__compiled__[r.toLowerCase()].validate(e,i,this)};aw.prototype.match=function t(e){const r=[];let i=0;if(this.__index__>=0&&this.__text_cache__===e){r.push(hw(this,i));i=this.__last_index__}let n=i?e.slice(i):e;while(this.test(n)){r.push(hw(this,i));n=n.slice(this.__last_index__);i+=this.__last_index__}if(r.length){return r}return null};aw.prototype.matchAtStart=function t(e){this.__text_cache__=e;this.__index__=-1;if(!e.length)return null;const r=this.re.schema_at_start.exec(e);if(!r)return null;const i=this.testSchemaAt(e,r[2],r[0].length);if(!i)return null;this.__schema__=r[2];this.__index__=r.index+r[1].length;this.__last_index__=r.index+r[0].length+i;return hw(this,0)};aw.prototype.tlds=function t(e,r){e=Array.isArray(e)?e:[e];if(!r){this.__tlds__=e.slice();this.__tlds_replaced__=true;uw(this);return this}this.__tlds__=this.__tlds__.concat(e).sort().filter((function(t,e,r){return t!==r[e-1]})).reverse();uw(this);return this};aw.prototype.normalize=function t(e){if(!e.schema){e.url="http://"+e.url}if(e.schema==="mailto:"&&!/^mailto:/i.test(e.url)){e.url="mailto:"+e.url}};aw.prototype.onCompile=function t(){};const cw=2147483647;const dw=36;const pw=1;const mw=26;const ww=38;const gw=700;const bw=72;const kw=128;const Dw="-";const vw=/^xn--/;const yw=/[^\0-\x7F]/;const Fw=/[\x2E\u3002\uFF0E\uFF61]/g;const Ew={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"};const Mw=dw-pw;const xw=Math.floor;const Aw=String.fromCharCode;function Cw(t){throw new RangeError(Ew[t])}function Sw(t,e){const r=[];let i=t.length;while(i--){r[i]=e(t[i])}return r}function Ow(t,e){const r=t.split("@");let i="";if(r.length>1){i=r[0]+"@";t=r[1]}t=t.replace(Fw,".");const n=t.split(".");const s=Sw(n,e).join(".");return i+s}function $w(t){const e=[];let r=0;const i=t.length;while(r<i){const n=t.charCodeAt(r++);if(n>=55296&&n<=56319&&r<i){const i=t.charCodeAt(r++);if((i&64512)==56320){e.push(((n&1023)<<10)+(i&1023)+65536)}else{e.push(n);r--}}else{e.push(n)}}return e}const _w=t=>String.fromCodePoint(...t);const Bw=function(t){if(t>=48&&t<58){return 26+(t-48)}if(t>=65&&t<91){return t-65}if(t>=97&&t<123){return t-97}return dw};const Rw=function(t,e){return t+22+75*(t<26)-((e!=0)<<5)};const jw=function(t,e,r){let i=0;t=r?xw(t/gw):t>>1;t+=xw(t/e);for(;t>Mw*mw>>1;i+=dw){t=xw(t/Mw)}return xw(i+(Mw+1)*t/(t+ww))};const Nw=function(t){const e=[];const r=t.length;let i=0;let n=kw;let s=bw;let l=t.lastIndexOf(Dw);if(l<0){l=0}for(let r=0;r<l;++r){if(t.charCodeAt(r)>=128){Cw("not-basic")}e.push(t.charCodeAt(r))}for(let o=l>0?l+1:0;o<r;){const l=i;for(let e=1,n=dw;;n+=dw){if(o>=r){Cw("invalid-input")}const l=Bw(t.charCodeAt(o++));if(l>=dw){Cw("invalid-input")}if(l>xw((cw-i)/e)){Cw("overflow")}i+=l*e;const u=n<=s?pw:n>=s+mw?mw:n-s;if(l<u){break}const f=dw-u;if(e>xw(cw/f)){Cw("overflow")}e*=f}const u=e.length+1;s=jw(i-l,u,l==0);if(xw(i/u)>cw-n){Cw("overflow")}n+=xw(i/u);i%=u;e.splice(i++,0,n)}return String.fromCodePoint(...e)};const qw=function(t){const e=[];t=$w(t);const r=t.length;let i=kw;let n=0;let s=bw;for(const r of t){if(r<128){e.push(Aw(r))}}const l=e.length;let o=l;if(l){e.push(Dw)}while(o<r){let r=cw;for(const e of t){if(e>=i&&e<r){r=e}}const u=o+1;if(r-i>xw((cw-n)/u)){Cw("overflow")}n+=(r-i)*u;i=r;for(const r of t){if(r<i&&++n>cw){Cw("overflow")}if(r===i){let t=n;for(let r=dw;;r+=dw){const i=r<=s?pw:r>=s+mw?mw:r-s;if(t<i){break}const n=t-i;const l=dw-i;e.push(Aw(Rw(i+n%l,0)));t=xw(n/l)}e.push(Aw(Rw(t,0)));s=jw(n,u,o===l);n=0;++o}}++n;++i}return e.join("")};const zw=function(t){return Ow(t,(function(t){return vw.test(t)?Nw(t.slice(4).toLowerCase()):t}))};const Tw=function(t){return Ow(t,(function(t){return yw.test(t)?"xn--"+qw(t):t}))};const Iw={version:"2.3.1",ucs2:{decode:$w,encode:_w},decode:Nw,encode:qw,toASCII:Tw,toUnicode:zw};const Pw={options:{html:false,xhtmlOut:false,breaks:false,langPrefix:"language-",linkify:false,typographer:false,quotes:"“”‘’",highlight:null,maxNesting:100},components:{core:{},block:{},inline:{}}};const Jw={options:{html:false,xhtmlOut:false,breaks:false,langPrefix:"language-",linkify:false,typographer:false,quotes:"“”‘’",highlight:null,maxNesting:20},components:{core:{rules:["normalize","block","inline","text_join"]},block:{rules:["paragraph"]},inline:{rules:["text"],rules2:["balance_pairs","fragments_join"]}}};const Lw={options:{html:true,xhtmlOut:true,breaks:false,langPrefix:"language-",linkify:false,typographer:false,quotes:"“”‘’",highlight:null,maxNesting:20},components:{core:{rules:["normalize","block","inline","text_join"]},block:{rules:["blockquote","code","fence","heading","hr","html_block","lheading","list","reference","paragraph"]},inline:{rules:["autolink","backticks","emphasis","entity","escape","html_inline","image","link","newline","text"],rules2:["balance_pairs","emphasis","fragments_join"]}}};const Ww={default:Pw,zero:Jw,commonmark:Lw};const Uw=/^(vbscript|javascript|file|data):/;const Hw=/^data:image\/(gif|png|jpeg|webp);/;function Zw(t){const e=t.trim().toLowerCase();return Uw.test(e)?Hw.test(e):true}const Kw=["http:","https:","mailto:"];function Vw(t){const e=ad(t,true);if(e.hostname){if(!e.protocol||Kw.indexOf(e.protocol)>=0){try{e.hostname=Iw.toASCII(e.hostname)}catch(t){}}}return Vc(Gc(e))}function Gw(t){const e=ad(t,true);if(e.hostname){if(!e.protocol||Kw.indexOf(e.protocol)>=0){try{e.hostname=Iw.toUnicode(e.hostname)}catch(t){}}}return Hc(Gc(e),Hc.defaultChars+"%")}function Xw(t,e){if(!(this instanceof Xw)){return new Xw(t,e)}if(!e){if(!vd(t)){e=t||{};t="default"}}this.inline=new Um;this.block=new hm;this.core=new Cp;this.renderer=new tp;this.linkify=new aw;this.validateLink=Zw;this.normalizeLink=Vw;this.normalizeLinkText=Gw;this.utils=Kd;this.helpers=Ed({},Yd);this.options={};this.configure(t);if(e){this.set(e)}}Xw.prototype.set=function(t){Ed(this.options,t);return this};Xw.prototype.configure=function(t){const e=this;if(vd(t)){const e=t;t=Ww[e];if(!t){throw new Error('Wrong `markdown-it` preset "'+e+'", check name')}}if(!t){throw new Error("Wrong `markdown-it` preset, can't be empty")}if(t.options){e.set(t.options)}if(t.components){Object.keys(t.components).forEach((function(r){if(t.components[r].rules){e[r].ruler.enableOnly(t.components[r].rules)}if(t.components[r].rules2){e[r].ruler2.enableOnly(t.components[r].rules2)}}))}return this};Xw.prototype.enable=function(t,e){let r=[];if(!Array.isArray(t)){t=[t]}["core","block","inline"].forEach((function(e){r=r.concat(this[e].ruler.enable(t,true))}),this);r=r.concat(this.inline.ruler2.enable(t,true));const i=t.filter((function(t){return r.indexOf(t)<0}));if(i.length&&!e){throw new Error("MarkdownIt. Failed to enable unknown rule(s): "+i)}return this};Xw.prototype.disable=function(t,e){let r=[];if(!Array.isArray(t)){t=[t]}["core","block","inline"].forEach((function(e){r=r.concat(this[e].ruler.disable(t,true))}),this);r=r.concat(this.inline.ruler2.disable(t,true));const i=t.filter((function(t){return r.indexOf(t)<0}));if(i.length&&!e){throw new Error("MarkdownIt. Failed to disable unknown rule(s): "+i)}return this};Xw.prototype.use=function(t){const e=[this].concat(Array.prototype.slice.call(arguments,1));t.apply(t,e);return this};Xw.prototype.parse=function(t,e){if(typeof t!=="string"){throw new Error("Input data should be a String")}const r=new this.core.State(t,this,e);this.core.process(r);return r.tokens};Xw.prototype.render=function(t,e){e=e||{};return this.renderer.render(this.parse(t,e),this.options,e)};Xw.prototype.parseInline=function(t,e){const r=new this.core.State(t,this,e);r.inlineMode=true;this.core.process(r);return r.tokens};Xw.prototype.renderInline=function(t,e){e=e||{};return this.renderer.render(this.parseInline(t,e),this.options,e)};const Yw=new pr({nodes:{doc:{content:"block+"},paragraph:{content:"inline*",group:"block",parseDOM:[{tag:"p"}],toDOM(){return["p",0]}},blockquote:{content:"block+",group:"block",parseDOM:[{tag:"blockquote"}],toDOM(){return["blockquote",0]}},horizontal_rule:{group:"block",parseDOM:[{tag:"hr"}],toDOM(){return["div",["hr"]]}},heading:{attrs:{level:{default:1}},content:"(text | image)*",group:"block",defining:true,parseDOM:[{tag:"h1",attrs:{level:1}},{tag:"h2",attrs:{level:2}},{tag:"h3",attrs:{level:3}},{tag:"h4",attrs:{level:4}},{tag:"h5",attrs:{level:5}},{tag:"h6",attrs:{level:6}}],toDOM(t){return["h"+t.attrs.level,0]}},code_block:{content:"text*",group:"block",code:true,defining:true,marks:"",attrs:{params:{default:""}},parseDOM:[{tag:"pre",preserveWhitespace:"full",getAttrs:t=>({params:t.getAttribute("data-params")||""})}],toDOM(t){return["pre",t.attrs.params?{"data-params":t.attrs.params}:{},["code",0]]}},ordered_list:{content:"list_item+",group:"block",attrs:{order:{default:1},tight:{default:false}},parseDOM:[{tag:"ol",getAttrs(t){return{order:t.hasAttribute("start")?+t.getAttribute("start"):1,tight:t.hasAttribute("data-tight")}}}],toDOM(t){return["ol",{start:t.attrs.order==1?null:t.attrs.order,"data-tight":t.attrs.tight?"true":null},0]}},bullet_list:{content:"list_item+",group:"block",attrs:{tight:{default:false}},parseDOM:[{tag:"ul",getAttrs:t=>({tight:t.hasAttribute("data-tight")})}],toDOM(t){return["ul",{"data-tight":t.attrs.tight?"true":null},0]}},list_item:{content:"block+",defining:true,parseDOM:[{tag:"li"}],toDOM(){return["li",0]}},text:{group:"inline"},image:{inline:true,attrs:{src:{},alt:{default:null},title:{default:null}},group:"inline",draggable:true,parseDOM:[{tag:"img[src]",getAttrs(t){return{src:t.getAttribute("src"),title:t.getAttribute("title"),alt:t.getAttribute("alt")}}}],toDOM(t){return["img",t.attrs]}},hard_break:{inline:true,group:"inline",selectable:false,parseDOM:[{tag:"br"}],toDOM(){return["br"]}}},marks:{em:{parseDOM:[{tag:"i"},{tag:"em"},{style:"font-style=italic"},{style:"font-style=normal",clearMark:t=>t.type.name=="em"}],toDOM(){return["em"]}},strong:{parseDOM:[{tag:"strong"},{tag:"b",getAttrs:t=>t.style.fontWeight!="normal"&&null},{style:"font-weight=400",clearMark:t=>t.type.name=="strong"},{style:"font-weight",getAttrs:t=>/^(bold(er)?|[5-9]\d{2,})$/.test(t)&&null}],toDOM(){return["strong"]}},link:{attrs:{href:{},title:{default:null}},inclusive:false,parseDOM:[{tag:"a[href]",getAttrs(t){return{href:t.getAttribute("href"),title:t.getAttribute("title")}}}],toDOM(t){return["a",t.attrs]}},code:{parseDOM:[{tag:"code"}],toDOM(){return["code"]}}}});function Qw(t,e){if(t.isText&&e.isText&&ye.sameSet(t.marks,e.marks))return t.withText(t.text+e.text)}class tg{constructor(t,e){this.schema=t;this.tokenHandlers=e;this.stack=[{type:t.topNodeType,attrs:null,content:[],marks:ye.none}]}top(){return this.stack[this.stack.length-1]}push(t){if(this.stack.length)this.top().content.push(t)}addText(t){if(!t)return;let e=this.top(),r=e.content,i=r[r.length-1];let n=this.schema.text(t,e.marks),s;if(i&&(s=Qw(i,n)))r[r.length-1]=s;else r.push(n)}openMark(t){let e=this.top();e.marks=t.addToSet(e.marks)}closeMark(t){let e=this.top();e.marks=t.removeFromSet(e.marks)}parseTokens(t){for(let e=0;e<t.length;e++){let r=t[e];let i=this.tokenHandlers[r.type];if(!i)throw new Error("Token type `"+r.type+"` not supported by Markdown parser");i(this,r,t,e)}}addNode(t,e,r){let i=this.top();let n=t.createAndFill(e,r,i?i.marks:[]);if(!n)return null;this.push(n);return n}openNode(t,e){this.stack.push({type:t,attrs:e,content:[],marks:ye.none})}closeNode(){let t=this.stack.pop();return this.addNode(t.type,t.attrs,t.content)}}function eg(t,e,r,i){if(t.getAttrs)return t.getAttrs(e,r,i);else if(t.attrs instanceof Function)return t.attrs(e);else return t.attrs}function rg(t,e){return t.noCloseToken||e=="code_inline"||e=="code_block"||e=="fence"}function ig(t){return t[t.length-1]=="\n"?t.slice(0,t.length-1):t}function ng(){}function sg(t,e){let r=Object.create(null);for(let i in e){let n=e[i];if(n.block){let e=t.nodeType(n.block);if(rg(n,i)){r[i]=(t,r,i,s)=>{t.openNode(e,eg(n,r,i,s));t.addText(ig(r.content));t.closeNode()}}else{r[i+"_open"]=(t,r,i,s)=>t.openNode(e,eg(n,r,i,s));r[i+"_close"]=t=>t.closeNode()}}else if(n.node){let e=t.nodeType(n.node);r[i]=(t,r,i,s)=>t.addNode(e,eg(n,r,i,s))}else if(n.mark){let e=t.marks[n.mark];if(rg(n,i)){r[i]=(t,r,i,s)=>{t.openMark(e.create(eg(n,r,i,s)));t.addText(ig(r.content));t.closeMark(e)}}else{r[i+"_open"]=(t,r,i,s)=>t.openMark(e.create(eg(n,r,i,s)));r[i+"_close"]=t=>t.closeMark(e)}}else if(n.ignore){if(rg(n,i)){r[i]=ng}else{r[i+"_open"]=ng;r[i+"_close"]=ng}}else{throw new RangeError("Unrecognized parsing spec "+JSON.stringify(n))}}r.text=(t,e)=>t.addText(e.content);r.inline=(t,e)=>t.parseTokens(e.children);r.softbreak=r.softbreak||(t=>t.addText(" "));return r}class lg{constructor(t,e,r){this.schema=t;this.tokenizer=e;this.tokens=r;this.tokenHandlers=sg(t,r)}parse(t,e={}){let r=new tg(this.schema,this.tokenHandlers),i;r.parseTokens(this.tokenizer.parse(t,e));do{i=r.closeNode()}while(r.stack.length);return i||this.schema.topNodeType.createAndFill()}}function og(t,e){while(++e<t.length)if(t[e].type!="list_item_open")return t[e].hidden;return false}new lg(Yw,Xw("commonmark",{html:false}),{blockquote:{block:"blockquote"},paragraph:{block:"paragraph"},list_item:{block:"list_item"},bullet_list:{block:"bullet_list",getAttrs:(t,e,r)=>({tight:og(e,r)})},ordered_list:{block:"ordered_list",getAttrs:(t,e,r)=>({order:+t.attrGet("start")||1,tight:og(e,r)})},heading:{block:"heading",getAttrs:t=>({level:+t.tag.slice(1)})},code_block:{block:"code_block",noCloseToken:true},fence:{block:"code_block",getAttrs:t=>({params:t.info||""}),noCloseToken:true},hr:{node:"horizontal_rule"},image:{node:"image",getAttrs:t=>({src:t.attrGet("src"),title:t.attrGet("title")||null,alt:t.children[0]&&t.children[0].content||null})},hardbreak:{node:"hard_break"},em:{mark:"em"},strong:{mark:"strong"},link:{mark:"link",getAttrs:t=>({href:t.attrGet("href"),title:t.attrGet("title")||null})},code_inline:{mark:"code",noCloseToken:true}});const ug={open:"",close:"",mixable:true};class fg{constructor(t,e,r={}){this.nodes=t;this.marks=e;this.options=r}serialize(t,e={}){e=Object.assign({},this.options,e);let r=new dg(this.nodes,this.marks,e);r.renderContent(t);return r.out}}const hg=new fg({blockquote(t,e){t.wrapBlock("> ",null,e,(()=>t.renderContent(e)))},code_block(t,e){const r=e.textContent.match(/`{3,}/gm);const i=r?r.sort().slice(-1)[0]+"`":"```";t.write(i+(e.attrs.params||"")+"\n");t.text(e.textContent,false);t.write("\n");t.write(i);t.closeBlock(e)},heading(t,e){t.write(t.repeat("#",e.attrs.level)+" ");t.renderInline(e,false);t.closeBlock(e)},horizontal_rule(t,e){t.write(e.attrs.markup||"---");t.closeBlock(e)},bullet_list(t,e){t.renderList(e," ",(()=>(e.attrs.bullet||"*")+" "))},ordered_list(t,e){let r=e.attrs.order||1;let i=String(r+e.childCount-1).length;let n=t.repeat(" ",i+2);t.renderList(e,n,(e=>{let n=String(r+e);return t.repeat(" ",i-n.length)+n+". "}))},list_item(t,e){t.renderContent(e)},paragraph(t,e){t.renderInline(e);t.closeBlock(e)},image(t,e){t.write("]/g,"\\$&")+(e.attrs.title?' "'+e.attrs.title.replace(/"/g,'\\"')+'"':"")+")")},hard_break(t,e,r,i){for(let n=i+1;n<r.childCount;n++)if(r.child(n).type!=e.type){t.write("\\\n");return}},text(t,e){t.text(e.text,!t.inAutolink)}},{em:{open:"*",close:"*",mixable:true,expelEnclosingWhitespace:true},strong:{open:"**",close:"**",mixable:true,expelEnclosingWhitespace:true},link:{open(t,e,r,i){t.inAutolink=cg(e,r,i);return t.inAutolink?"<":"["},close(t,e,r,i){let{inAutolink:n}=t;t.inAutolink=undefined;return n?">":"]("+e.attrs.href.replace(/[\(\)"]/g,"\\$&")+(e.attrs.title?` "${e.attrs.title.replace(/"/g,'\\"')}"`:"")+")"},mixable:true},code:{open(t,e,r,i){return ag(r.child(i),-1)},close(t,e,r,i){return ag(r.child(i-1),1)},escape:false}});function ag(t,e){let r=/`+/g,i,n=0;if(t.isText)while(i=r.exec(t.text))n=Math.max(n,i[0].length);let s=n>0&&e>0?" `":"`";for(let t=0;t<n;t++)s+="`";if(n>0&&e<0)s+=" ";return s}function cg(t,e,r){if(t.attrs.title||!/^\w+:/.test(t.attrs.href))return false;let i=e.child(r);if(!i.isText||i.text!=t.attrs.href||i.marks[i.marks.length-1]!=t)return false;return r==e.childCount-1||!t.isInSet(e.child(r+1).marks)}class dg{constructor(t,e,r){this.nodes=t;this.marks=e;this.options=r;this.delim="";this.out="";this.closed=null;this.inAutolink=undefined;this.atBlockStart=false;this.inTightList=false;if(typeof this.options.tightLists=="undefined")this.options.tightLists=false;if(typeof this.options.hardBreakNodeName=="undefined")this.options.hardBreakNodeName="hard_break"}flushClose(t=2){if(this.closed){if(!this.atBlank())this.out+="\n";if(t>1){let e=this.delim;let r=/\s+$/.exec(e);if(r)e=e.slice(0,e.length-r[0].length);for(let r=1;r<t;r++)this.out+=e+"\n"}this.closed=null}}getMark(t){let e=this.marks[t];if(!e){if(this.options.strict!==false)throw new Error(`Mark type \`${t}\` not supported by Markdown renderer`);e=ug}return e}wrapBlock(t,e,r,i){let n=this.delim;this.write(e!=null?e:t);this.delim+=t;i();this.delim=n;this.closeBlock(r)}atBlank(){return/(^|\n)$/.test(this.out)}ensureNewLine(){if(!this.atBlank())this.out+="\n"}write(t){this.flushClose();if(this.delim&&this.atBlank())this.out+=this.delim;if(t)this.out+=t}closeBlock(t){this.closed=t}text(t,e=true){let r=t.split("\n");for(let t=0;t<r.length;t++){this.write();if(!e&&r[t][0]=="["&&/(^|[^\\])\!$/.test(this.out))this.out=this.out.slice(0,this.out.length-1)+"\\!";this.out+=e?this.esc(r[t],this.atBlockStart):r[t];if(t!=r.length-1)this.out+="\n"}}render(t,e,r){if(this.nodes[t.type.name]){this.nodes[t.type.name](this,t,e,r)}else{if(this.options.strict!==false){throw new Error("Token type `"+t.type.name+"` not supported by Markdown renderer")}else if(!t.type.isLeaf){if(t.type.inlineContent)this.renderInline(t);else this.renderContent(t);if(t.isBlock)this.closeBlock(t)}}}renderContent(t){t.forEach(((e,r,i)=>this.render(e,t,i)))}renderInline(t,e=true){this.atBlockStart=e;let r=[],i="";let n=(e,n,s)=>{let l=e?e.marks:[];if(e&&e.type.name===this.options.hardBreakNodeName)l=l.filter((e=>{if(s+1==t.childCount)return false;let r=t.child(s+1);return e.isInSet(r.marks)&&(!r.isText||/\S/.test(r.text))}));let o=i;i="";if(e&&e.isText&&l.some((t=>{let e=this.getMark(t.type.name);return e&&e.expelEnclosingWhitespace&&!t.isInSet(r)}))){let[t,i,n]=/^(\s*)(.*)$/m.exec(e.text);if(i){o+=i;e=n?e.withText(n):null;if(!e)l=r}}if(e&&e.isText&&l.some((e=>{let r=this.getMark(e.type.name);return r&&r.expelEnclosingWhitespace&&(s==t.childCount-1||!e.isInSet(t.child(s+1).marks))}))){let[t,n,s]=/^(.*?)(\s*)$/m.exec(e.text);if(s){i=s;e=n?e.withText(n):null;if(!e)l=r}}let u=l.length?l[l.length-1]:null;let f=u&&this.getMark(u.type.name).escape===false;let h=l.length-(f?1:0);t:for(let t=0;t<h;t++){let e=l[t];if(!this.getMark(e.type.name).mixable)break;for(let i=0;i<r.length;i++){let n=r[i];if(!this.getMark(n.type.name).mixable)break;if(e.eq(n)){if(t>i)l=l.slice(0,i).concat(e).concat(l.slice(i,t)).concat(l.slice(t+1,h));else if(i>t)l=l.slice(0,t).concat(l.slice(t+1,i)).concat(e).concat(l.slice(i,h));continue t}}}let a=0;while(a<Math.min(r.length,h)&&l[a].eq(r[a]))++a;while(a<r.length)this.text(this.markString(r.pop(),false,t,s),false);if(o)this.text(o);if(e){while(r.length<h){let e=l[r.length];r.push(e);this.text(this.markString(e,true,t,s),false);this.atBlockStart=false}if(f&&e.isText)this.text(this.markString(u,true,t,s)+e.text+this.markString(u,false,t,s+1),false);else this.render(e,t,s);this.atBlockStart=false}if((e===null||e===void 0?void 0:e.isText)&&e.nodeSize>0){this.atBlockStart=false}};t.forEach(n);n(null,0,t.childCount);this.atBlockStart=false}renderList(t,e,r){if(this.closed&&this.closed.type==t.type)this.flushClose(3);else if(this.inTightList)this.flushClose(1);let i=typeof t.attrs.tight!="undefined"?t.attrs.tight:this.options.tightLists;let n=this.inTightList;this.inTightList=i;t.forEach(((n,s,l)=>{if(l&&i)this.flushClose(1);this.wrapBlock(e,r(l),t,(()=>this.render(n,t,l)))}));this.inTightList=n}esc(t,e=false){t=t.replace(/[`*\\~\[\]_]/g,((e,r)=>e=="_"&&r>0&&r+1<t.length&&t[r-1].match(/\w/)&&t[r+1].match(/\w/)?e:"\\"+e));if(e)t=t.replace(/^(\+[ ]|[\-*>])/,"\\$&").replace(/^(\s*)(#{1,6})(\s|$)/,"$1\\$2$3").replace(/^(\s*\d+)\.\s/,"$1\\. ");if(this.options.escapeExtraCharacters)t=t.replace(this.options.escapeExtraCharacters,"\\$&");return t}quote(t){let e=t.indexOf('"')==-1?'""':t.indexOf("'")==-1?"''":"()";return e[0]+t+e[1]}repeat(t,e){let r="";for(let i=0;i<e;i++)r+=t;return r}markString(t,e,r,i){let n=this.getMark(t.type.name);let s=e?n.open:n.close;return typeof s=="string"?s:s(this,t,r,i)}getEnclosingWhitespace(t){return{leading:(t.match(/^(\s+)/)||[undefined])[0],trailing:(t.match(/(\s+)$/)||[undefined])[0]}}}const pg=t=>(e,r)=>{const i=`<${t.tagName}`+t.attributes.map((t=>` ${t}="${r.attrs[t]}"`)).join("")+">";const n=`</${t.tagName}>`;e.write(i);e.renderContent(r);e.write(n)};const mg=t=>{const e={};t.forEach((t=>{e[t.tagName]=pg(t)}));const r=Object.assign(Object.assign({},hg.nodes),e);const i=Object.assign(Object.assign({},hg.marks),{strikethrough:{open:"~~",close:"~~",mixable:true,expelEnclosingWhitespace:true}});return new fg(r,i)};class wg{constructor(t){this.parseAsHTML=t=>A(t,{whitelist:this.customNodes});this.serialize=t=>{if(t.dom.textContent===""){return""}else{return this.markdownSerializer.serialize(t.state.doc)}};this.markdownSerializer=mg(t);this.customNodes=t}}class gg{constructor(t){this.parseAsHTML=t=>C(t,this.customNodes);this.serialize=t=>{if(t.dom.textContent===""){return""}else{return t.dom.innerHTML}};this.customNodes=t}}const bg={parseDOM:[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration=line-through"}],toDOM:()=>["s",0]};const kg=new Mn("linkPlugin");const Dg=(t,e)=>{const{from:r,to:i}=t.state.selection;let n="";let s="";t.state.doc.nodesBetween(r,i,((t,e)=>{if(t.type.name!=="text"){return}const l=Math.max(0,r-e);const o=Math.min(t.text.length,i-e);n+=t.text.slice(l,o);t.marks.forEach((t=>{if(t.type.name==="link"){s=t.attrs.href}}))}));if(e){e(n,s)}};const vg=(t,e,r)=>{while(e>0){const i=t.nodeAt(e-1);if(!(i===null||i===void 0?void 0:i.isText)||!i.marks.some((t=>t.type.name===bc.Link&&t.attrs.href===r))){break}e--}return e};const yg=(t,e,r)=>{while(e<t.content.size){const i=t.nodeAt(e);if(!(i===null||i===void 0?void 0:i.isText)||!i.marks.some((t=>t.type.name===bc.Link&&t.attrs.href===r))){break}e++}return e};const Fg=(t,e)=>{const r=t.posAtCoords({left:e.clientX,top:e.clientY});const i=t.state.doc.nodeAt(r===null||r===void 0?void 0:r.pos);if(!i){return null}const n=i.marks.find((t=>t.type.name===bc.Link));if(!n){return null}const s=n.attrs.href;const l=vg(t.state.doc,r.pos,s);const o=yg(t.state.doc,r.pos,s);const u=t.state.doc.textBetween(l,o," ");return{href:s,text:u,from:l,to:o}};const Eg=(t,e)=>{const{href:r}=Fg(t,e);if(r){window.open(r,"_blank");return true}return false};const Mg=(t,e,r)=>{const i=new CustomEvent("open-editor-link-menu",{detail:{href:e,text:r},bubbles:true,composed:true});t.dom.dispatchEvent(i)};let xg=0;const Ag=200;let Cg;const Sg=(t,e)=>{const r=Date.now();if(r-xg<Ag){clearTimeout(Cg);xg=r;return false}xg=r;Cg=setTimeout((()=>{const r=Fg(t,e);if(r){const{href:e,text:i,from:n,to:s}=r;const l=t.state.tr.setSelection(nn.create(t.state.doc,n,s));t.dispatch(l);Mg(t,e,i)}}),Ag);return true};const Og=(t,e)=>{const r=e.clipboardData;if(!r){return false}const i=r.getData("text/plain");if(Oc(i)){$g(t,i);return true}return false};const $g=(t,e)=>{const{state:r,dispatch:i}=t;const{from:n,to:s}=r.selection;const l=nf.marks.link.create({href:e,title:e,target:Cc(e)?"_blank":null});const o=r.doc.textBetween(n,s," ")||e;const u=r.tr.insertText(o,n,s).addMark(n,n+o.length,l);i(u)};const _g=t=>new yn({key:kg,props:{handlePaste:(t,e)=>Og(t,e),handleDOMEvents:{mousedown:(t,e)=>{if((e.metaKey||e.ctrlKey)&&e.button===0){return Eg(t,e)}if(e.button!==vc.Right){return Sg(t,e)}return true},click:(t,e)=>{if(!(e.target instanceof HTMLElement)){return}const r=e.target.closest("a");if(r){e.preventDefault();e.stopPropagation()}}}},view:()=>({update:e=>{Dg(e,t)}})});const Bg=new Mn("imageRemoverPlugin");const Rg=()=>new yn({key:Bg,props:{handlePaste:(t,e,r)=>qg(t,e,r)}});const jg=t=>{if(t instanceof Le){if(t.type.name==="image"){return true}let e=false;t.content.forEach((t=>{if(jg(t)){e=true}}));return e}else if(t instanceof be){let e=false;t.forEach((t=>{if(jg(t)){e=true}}));return e}return false};const Ng=t=>{const e=[];t.forEach((t=>{if(!jg(t)){if(t.content.size>0){const r=Ng(t.content);const i=t.copy(r);e.push(i)}else{e.push(t)}}}));return be.fromArray(e)};const qg=(t,e,r)=>{const i=e.clipboardData;if(!i){return false}const n=new Ee(Ng(r.content),r.openStart,r.openEnd);if(n.content.childCount<r.content.childCount){const{state:e,dispatch:r}=t;const i=e.tr.replaceSelection(n);r(i);return true}return false};const zg=new Mn("actionBarPlugin");const Tg=(t,e,r)=>{const i={};t.forEach((t=>{const n=e.getCommand(t);i[t]=n&&n.active&&n.active(r.state)}));return i};const Ig=(t,e,r)=>new yn({key:zg,state:{init:()=>({}),apply:(t,e)=>{const r=t.getMeta(zg);return r?r:e}},view:()=>({update:i=>{const n=zg.getState(i.state);const s=Tg(t,e,i);if(!_(n,s)){const t=i.state.tr.setMeta(zg,s);i.dispatch(t);r(s)}}})});const Pg=new Mn("actionBarInteractionPlugin");const Jg=(t,e)=>{const{state:r}=e;const i=r.selection;let n=r.tr;if(!i.empty){n.setSelection(i)}t(r,(t=>{n=t}));e.dispatch(n);e.focus()};const Lg=t=>new yn({key:Pg,props:{handleDOMEvents:{actionBarItemClick:(e,r)=>{r.preventDefault();r.stopPropagation();const{value:i}=r.detail;try{const r=t.getCommand(i);Jg(r,e)}catch(t){console.error(`Error executing command: ${t}`)}return true},saveLinkMenu:(e,r)=>{r.preventDefault();r.stopPropagation();const{type:i,link:n}=r.detail;if(i===bc.Link){try{const r=t.getCommand(i,n);Jg(r,e)}catch(t){console.error(`Error executing command: ${t}`)}}return true}}}});const Wg=t=>{const e={};t.attributes.forEach((t=>e[t]={}));const r=`${t.tagName}[${t.attributes.map((t=>t)).join("][")}]`;return{group:"inline",content:"(text* | inline*)",inline:true,atom:true,selectable:true,attrs:e,toDOM:e=>[t.tagName,e.attrs],parseDOM:[{tag:r,getAttrs:e=>{const r={};t.attributes.forEach((t=>r[t]=e.getAttribute(t)));return r}}]}};const Ug=(t,e,r,i)=>{const n=t.state.schema;return async s=>{const l=document.createElement("span");l.innerHTML=await e.parseAsHTML(s,n);const o=br.fromSchema(n).parse(l).content;i(t,r,o)}};const Hg=(t,e,r)=>({insert:Zg(t,r),insertHtml:Ug(t,e,r.position,Vg),stopTrigger:()=>Kg(t)});const Zg=(t,e)=>r=>{const i=t.state.schema;let n;try{n=Gg(r,i)}catch(t){console.error(t.message);return}const s=i.text(" ");const l=i.nodes.doc.create(null,[n,s]);Vg(t,e.position,l)};const Kg=t=>{const{state:e,dispatch:r}=t;const i=e.tr;i.setMeta("stopTrigger",true);r(i)};const Vg=(t,e,r)=>{const i=t.state;const n=i.selection.$from.pos;const s=t.dispatch;const l=i.tr.replaceWith(e,n,r);l.setMeta("stopTrigger",true);s(l)};const Gg=(t,e)=>{var r;if(typeof t==="string"){return e.text(t)}const i=t.node;if(typeof i==="string"){return e.text(i)}const n=Xg(i.tagName,e);const s=((r=t.children)!==null&&r!==void 0?r:[]).map((t=>Gg(t,e))).filter(Boolean);return n.create(i.attributes,s)};const Xg=(t,e)=>{const r=Object.values(e.nodes).find((e=>e.name===t));if(!r){throw new Error(`No custom element has been registered for node ${t}`)}return r};const Yg=(t,e,r,i)=>{const n={trigger:r.character,textEditor:Hg(t,e,r),value:i};return n};const Qg=(t,e,r,i,n)=>{const s=new CustomEvent(t,{detail:Yg(e,r,i,n),bubbles:true,composed:true});e.dom.dispatchEvent(s)};const tb=(t,e,r)=>(i,n,s,l)=>{if(!e.includes(l)){return false}const o=i.state.doc;const u=o.textBetween(n-1,n,"");if(/\s/.test(u)||u===""){const e={character:l,position:n};r(e);Qg("triggerStart",i,t,e,l)}return false};const eb=(t,e,r,i,n)=>{if(!e||e.position<1){return false}for(const s of t.steps){if(s instanceof si){const{from:t,to:l,slice:o}=s;if(t<=e.position&&l>=e.position){const t=o.content.textBetween(0,o.content.size,"");if(!t.includes(e.character)){r();Qg("triggerStop",n,i,e,"");return true}}}}return false};const rb=(t,e,r,i,n)=>{let s="";if(r>e.position){s=t.textBetween(e.position+1,r,"")}Qg("triggerChange",n,i,e,s);return s};const ib=(t,e,r,i)=>(n,s,l)=>{const o=e();if(!o){return}const u=eb(n[0],o,r,i,t());if(u){r();return}rb(l.doc,o,l.selection.from,i,t())};const nb=(t,e)=>{let r=null;let i=null;const n=()=>r;const s=()=>i;const l=()=>{i=null};const o=t=>{i=t};const u=tb(e,t,o);const f=ib(n,s,l,e);return new yn({key:new Mn("triggerPlugin"),view:t=>{r=t;return{}},state:{init:()=>({}),apply:t=>{if(t.getMeta("stopTrigger")){Qg("triggerStop",r,e,i,"");l()}return{}}},props:{handleTextInput:u},appendTransaction:f})};var sb;var lb;if(typeof WeakMap!="undefined"){let t=new WeakMap;sb=e=>t.get(e);lb=(e,r)=>{t.set(e,r);return r}}else{const t=[];const e=10;let r=0;sb=e=>{for(let r=0;r<t.length;r+=2)if(t[r]==e)return t[r+1]};lb=(i,n)=>{if(r==e)r=0;t[r++]=i;return t[r++]=n}}var ob=class{constructor(t,e,r,i){this.width=t;this.height=e;this.map=r;this.problems=i}findCell(t){for(let e=0;e<this.map.length;e++){const r=this.map[e];if(r!=t)continue;const i=e%this.width;const n=e/this.width|0;let s=i+1;let l=n+1;for(let t=1;s<this.width&&this.map[e+t]==r;t++){s++}for(let t=1;l<this.height&&this.map[e+this.width*t]==r;t++){l++}return{left:i,top:n,right:s,bottom:l}}throw new RangeError(`No cell with offset ${t} found`)}colCount(t){for(let e=0;e<this.map.length;e++){if(this.map[e]==t){return e%this.width}}throw new RangeError(`No cell with offset ${t} found`)}nextCell(t,e,r){const{left:i,right:n,top:s,bottom:l}=this.findCell(t);if(e=="horiz"){if(r<0?i==0:n==this.width)return null;return this.map[s*this.width+(r<0?i-1:n)]}else{if(r<0?s==0:l==this.height)return null;return this.map[i+this.width*(r<0?s-1:l)]}}rectBetween(t,e){const{left:r,right:i,top:n,bottom:s}=this.findCell(t);const{left:l,right:o,top:u,bottom:f}=this.findCell(e);return{left:Math.min(r,l),top:Math.min(n,u),right:Math.max(i,o),bottom:Math.max(s,f)}}cellsInRect(t){const e=[];const r={};for(let i=t.top;i<t.bottom;i++){for(let n=t.left;n<t.right;n++){const s=i*this.width+n;const l=this.map[s];if(r[l])continue;r[l]=true;if(n==t.left&&n&&this.map[s-1]==l||i==t.top&&i&&this.map[s-this.width]==l){continue}e.push(l)}}return e}positionAt(t,e,r){for(let i=0,n=0;;i++){const s=n+r.child(i).nodeSize;if(i==t){let r=e+t*this.width;const i=(t+1)*this.width;while(r<i&&this.map[r]<n)r++;return r==i?s-1:this.map[r]}n=s}}static get(t){return sb(t)||lb(t,ub(t))}};function ub(t){if(t.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+t.type.name);const e=fb(t),r=t.childCount;const i=[];let n=0;let s=null;const l=[];for(let t=0,n=e*r;t<n;t++)i[t]=0;for(let o=0,u=0;o<r;o++){const f=t.child(o);u++;for(let t=0;;t++){while(n<i.length&&i[n]!=0)n++;if(t==f.childCount)break;const h=f.child(t);const{colspan:a,rowspan:c,colwidth:d}=h.attrs;for(let t=0;t<c;t++){if(t+o>=r){(s||(s=[])).push({type:"overlong_rowspan",pos:u,n:c-t});break}const f=n+t*e;for(let t=0;t<a;t++){if(i[f+t]==0)i[f+t]=u;else(s||(s=[])).push({type:"collision",row:o,pos:u,n:a-t});const r=d&&d[t];if(r){const i=(f+t)%e*2,n=l[i];if(n==null||n!=r&&l[i+1]==1){l[i]=r;l[i+1]=1}else if(n==r){l[i+1]++}}}}n+=a;u+=h.nodeSize}const h=(o+1)*e;let a=0;while(n<h)if(i[n++]==0)a++;if(a)(s||(s=[])).push({type:"missing",row:o,n:a});u++}if(e===0||r===0)(s||(s=[])).push({type:"zero_sized"});const o=new ob(e,r,i,s);let u=false;for(let t=0;!u&&t<l.length;t+=2)if(l[t]!=null&&l[t+1]<r)u=true;if(u)hb(o,l,t);return o}function fb(t){let e=-1;let r=false;for(let i=0;i<t.childCount;i++){const n=t.child(i);let s=0;if(r)for(let e=0;e<i;e++){const r=t.child(e);for(let t=0;t<r.childCount;t++){const n=r.child(t);if(e+n.attrs.rowspan>i)s+=n.attrs.colspan}}for(let t=0;t<n.childCount;t++){const e=n.child(t);s+=e.attrs.colspan;if(e.attrs.rowspan>1)r=true}if(e==-1)e=s;else if(e!=s)e=Math.max(e,s)}return e}function hb(t,e,r){if(!t.problems)t.problems=[];const i={};for(let n=0;n<t.map.length;n++){const s=t.map[n];if(i[s])continue;i[s]=true;const l=r.nodeAt(s);if(!l){throw new RangeError(`No cell with offset ${s} found`)}let o=null;const u=l.attrs;for(let r=0;r<u.colspan;r++){const i=(n+r)%t.width;const s=e[i*2];if(s!=null&&(!u.colwidth||u.colwidth[r]!=s))(o||(o=ab(u)))[r]=s}if(o)t.problems.unshift({type:"colwidth mismatch",pos:s,colwidth:o})}}function ab(t){if(t.colwidth)return t.colwidth.slice();const e=[];for(let r=0;r<t.colspan;r++)e.push(0);return e}function cb(t,e){if(typeof t==="string"){return{}}const r=t.getAttribute("data-colwidth");const i=r&&/^\d+(,\d+)*$/.test(r)?r.split(",").map((t=>Number(t))):null;const n=Number(t.getAttribute("colspan")||1);const s={colspan:n,rowspan:Number(t.getAttribute("rowspan")||1),colwidth:i&&i.length==n?i:null};for(const r in e){const i=e[r].getFromDOM;const n=i&&i(t);if(n!=null){s[r]=n}}return s}function db(t,e){const r={};if(t.attrs.colspan!=1)r.colspan=t.attrs.colspan;if(t.attrs.rowspan!=1)r.rowspan=t.attrs.rowspan;if(t.attrs.colwidth)r["data-colwidth"]=t.attrs.colwidth.join(",");for(const i in e){const n=e[i].setDOMAttr;if(n)n(t.attrs[i],r)}return r}function pb(t){const e=t.cellAttributes||{};const r={colspan:{default:1},rowspan:{default:1},colwidth:{default:null}};for(const t in e)r[t]={default:e[t].default};return{table:{content:"table_row+",tableRole:"table",isolating:true,group:t.tableGroup,parseDOM:[{tag:"table"}],toDOM(){return["table",["tbody",0]]}},table_row:{content:"(table_cell | table_header)*",tableRole:"row",parseDOM:[{tag:"tr"}],toDOM(){return["tr",0]}},table_cell:{content:t.cellContent,attrs:r,tableRole:"cell",isolating:true,parseDOM:[{tag:"td",getAttrs:t=>cb(t,e)}],toDOM(t){return["td",db(t,e),0]}},table_header:{content:t.cellContent,attrs:r,tableRole:"header_cell",isolating:true,parseDOM:[{tag:"th",getAttrs:t=>cb(t,e)}],toDOM(t){return["th",db(t,e),0]}}}}function mb(t){let e=t.cached.tableNodeTypes;if(!e){e=t.cached.tableNodeTypes={};for(const r in t.nodes){const i=t.nodes[r],n=i.spec.tableRole;if(n)e[n]=i}}return e}var wb=new Mn("selectingCells");function gb(t){for(let e=t.depth-1;e>0;e--)if(t.node(e).type.spec.tableRole=="row")return t.node(0).resolve(t.before(e+1));return null}function bb(t){const e=t.selection.$head;for(let t=e.depth;t>0;t--)if(e.node(t).type.spec.tableRole=="row")return true;return false}function kb(t){const e=t.selection;if("$anchorCell"in e&&e.$anchorCell){return e.$anchorCell.pos>e.$headCell.pos?e.$anchorCell:e.$headCell}else if("node"in e&&e.node&&e.node.type.spec.tableRole=="cell"){return e.$anchor}const r=gb(e.$head)||Db(e.$head);if(r){return r}throw new RangeError(`No cell found around position ${e.head}`)}function Db(t){for(let e=t.nodeAfter,r=t.pos;e;e=e.firstChild,r++){const i=e.type.spec.tableRole;if(i=="cell"||i=="header_cell")return t.doc.resolve(r)}for(let e=t.nodeBefore,r=t.pos;e;e=e.lastChild,r--){const i=e.type.spec.tableRole;if(i=="cell"||i=="header_cell")return t.doc.resolve(r-e.nodeSize)}}function vb(t){return t.parent.type.spec.tableRole=="row"&&!!t.nodeAfter}function yb(t,e){return t.depth==e.depth&&t.pos>=e.start(-1)&&t.pos<=e.end(-1)}function Fb(t,e,r){const i=t.node(-1);const n=ob.get(i);const s=t.start(-1);const l=n.nextCell(t.pos-s,e,r);return l==null?null:t.node(0).resolve(s+l)}function Eb(t,e,r=1){const i={...t,colspan:t.colspan-r};if(i.colwidth){i.colwidth=i.colwidth.slice();i.colwidth.splice(e,r);if(!i.colwidth.some((t=>t>0)))i.colwidth=null}return i}var Mb=class t extends Qi{constructor(t,e=t){const r=t.node(-1);const i=ob.get(r);const n=t.start(-1);const s=i.rectBetween(t.pos-n,e.pos-n);const l=t.node(0);const o=i.cellsInRect(s).filter((t=>t!=e.pos-n));o.unshift(e.pos-n);const u=o.map((t=>{const e=r.nodeAt(t);if(!e){throw RangeError(`No cell with offset ${t} found`)}const i=n+t+1;return new tn(l.resolve(i),l.resolve(i+e.content.size))}));super(u[0].$from,u[0].$to,u);this.$anchorCell=t;this.$headCell=e}map(e,r){const i=e.resolve(r.map(this.$anchorCell.pos));const n=e.resolve(r.map(this.$headCell.pos));if(vb(i)&&vb(n)&&yb(i,n)){const e=this.$anchorCell.node(-1)!=i.node(-1);if(e&&this.isRowSelection())return t.rowSelection(i,n);else if(e&&this.isColSelection())return t.colSelection(i,n);else return new t(i,n)}return nn.between(i,n)}content(){const t=this.$anchorCell.node(-1);const e=ob.get(t);const r=this.$anchorCell.start(-1);const i=e.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r);const n={};const s=[];for(let r=i.top;r<i.bottom;r++){const l=[];for(let s=r*e.width+i.left,o=i.left;o<i.right;o++,s++){const r=e.map[s];if(n[r])continue;n[r]=true;const o=e.findCell(r);let u=t.nodeAt(r);if(!u){throw RangeError(`No cell with offset ${r} found`)}const f=i.left-o.left;const h=o.right-i.right;if(f>0||h>0){let t=u.attrs;if(f>0){t=Eb(t,0,f)}if(h>0){t=Eb(t,t.colspan-h,h)}if(o.left<i.left){u=u.type.createAndFill(t);if(!u){throw RangeError(`Could not create cell with attrs ${JSON.stringify(t)}`)}}else{u=u.type.create(t,u.content)}}if(o.top<i.top||o.bottom>i.bottom){const t={...u.attrs,rowspan:Math.min(o.bottom,i.bottom)-Math.max(o.top,i.top)};if(o.top<i.top){u=u.type.createAndFill(t)}else{u=u.type.create(t,u.content)}}l.push(u)}s.push(t.child(r).copy(be.from(l)))}const l=this.isColSelection()&&this.isRowSelection()?t:s;return new Ee(be.from(l),1,1)}replace(t,e=Ee.empty){const r=t.steps.length,i=this.ranges;for(let n=0;n<i.length;n++){const{$from:s,$to:l}=i[n],o=t.mapping.slice(r);t.replace(o.map(s.pos),o.map(l.pos),n?Ee.empty:e)}const n=Qi.findFrom(t.doc.resolve(t.mapping.slice(r).map(this.to)),-1);if(n)t.setSelection(n)}replaceWith(t,e){this.replace(t,new Ee(be.from(e),0,0))}forEachCell(t){const e=this.$anchorCell.node(-1);const r=ob.get(e);const i=this.$anchorCell.start(-1);const n=r.cellsInRect(r.rectBetween(this.$anchorCell.pos-i,this.$headCell.pos-i));for(let r=0;r<n.length;r++){t(e.nodeAt(n[r]),i+n[r])}}isColSelection(){const t=this.$anchorCell.index(-1);const e=this.$headCell.index(-1);if(Math.min(t,e)>0)return false;const r=t+this.$anchorCell.nodeAfter.attrs.rowspan;const i=e+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,i)==this.$headCell.node(-1).childCount}static colSelection(e,r=e){const i=e.node(-1);const n=ob.get(i);const s=e.start(-1);const l=n.findCell(e.pos-s);const o=n.findCell(r.pos-s);const u=e.node(0);if(l.top<=o.top){if(l.top>0)e=u.resolve(s+n.map[l.left]);if(o.bottom<n.height)r=u.resolve(s+n.map[n.width*(n.height-1)+o.right-1])}else{if(o.top>0)r=u.resolve(s+n.map[o.left]);if(l.bottom<n.height)e=u.resolve(s+n.map[n.width*(n.height-1)+l.right-1])}return new t(e,r)}isRowSelection(){const t=this.$anchorCell.node(-1);const e=ob.get(t);const r=this.$anchorCell.start(-1);const i=e.colCount(this.$anchorCell.pos-r);const n=e.colCount(this.$headCell.pos-r);if(Math.min(i,n)>0)return false;const s=i+this.$anchorCell.nodeAfter.attrs.colspan;const l=n+this.$headCell.nodeAfter.attrs.colspan;return Math.max(s,l)==e.width}eq(e){return e instanceof t&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,r=e){const i=e.node(-1);const n=ob.get(i);const s=e.start(-1);const l=n.findCell(e.pos-s);const o=n.findCell(r.pos-s);const u=e.node(0);if(l.left<=o.left){if(l.left>0)e=u.resolve(s+n.map[l.top*n.width]);if(o.right<n.width)r=u.resolve(s+n.map[n.width*(o.top+1)-1])}else{if(o.left>0)r=u.resolve(s+n.map[o.top*n.width]);if(l.right<n.width)e=u.resolve(s+n.map[n.width*(l.top+1)-1])}return new t(e,r)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,r){return new t(e.resolve(r.anchor),e.resolve(r.head))}static create(e,r,i=r){return new t(e.resolve(r),e.resolve(i))}getBookmark(){return new xb(this.$anchorCell.pos,this.$headCell.pos)}};Mb.prototype.visible=false;Qi.jsonID("cell",Mb);var xb=class t{constructor(t,e){this.anchor=t;this.head=e}map(e){return new t(e.map(this.anchor),e.map(this.head))}resolve(t){const e=t.resolve(this.anchor),r=t.resolve(this.head);if(e.parent.type.spec.tableRole=="row"&&r.parent.type.spec.tableRole=="row"&&e.index()<e.parent.childCount&&r.index()<r.parent.childCount&&yb(e,r))return new Mb(e,r);else return Qi.near(r,1)}};function Ab(t){if(!(t.selection instanceof Mb))return null;const e=[];t.selection.forEachCell(((t,r)=>{e.push(iu.node(r,r+t.nodeSize,{class:"selectedCell"}))}));return lu.create(t.doc,e)}function Cb({$from:t,$to:e}){if(t.pos==e.pos||t.pos<e.pos-6)return false;let r=t.pos;let i=e.pos;let n=t.depth;for(;n>=0;n--,r++)if(t.after(n+1)<t.end(n))break;for(let t=e.depth;t>=0;t--,i--)if(e.before(t+1)>e.start(t))break;return r==i&&/row|table/.test(t.node(n).type.spec.tableRole)}function Sb({$from:t,$to:e}){let r;let i;for(let e=t.depth;e>0;e--){const i=t.node(e);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){r=i;break}}for(let t=e.depth;t>0;t--){const r=e.node(t);if(r.type.spec.tableRole==="cell"||r.type.spec.tableRole==="header_cell"){i=r;break}}return r!==i&&e.parentOffset===0}function Ob(t,e,r){const i=(e||t).selection;const n=(e||t).doc;let s;let l;if(i instanceof ln&&(l=i.node.type.spec.tableRole)){if(l=="cell"||l=="header_cell"){s=Mb.create(n,i.from)}else if(l=="row"){const t=n.resolve(i.from+1);s=Mb.rowSelection(t,t)}else if(!r){const t=ob.get(i.node);const e=i.from+1;const r=e+t.map[t.width*t.height-1];s=Mb.create(n,e+1,r)}}else if(i instanceof nn&&Cb(i)){s=nn.create(n,i.from)}else if(i instanceof nn&&Sb(i)){s=nn.create(n,i.$from.start(),i.$from.end())}if(s)(e||(e=t.tr)).setSelection(s);return e}var $b=new Mn("fix-tables");function _b(t,e,r,i){const n=t.childCount,s=e.childCount;t:for(let l=0,o=0;l<s;l++){const s=e.child(l);for(let e=o,i=Math.min(n,l+3);e<i;e++){if(t.child(e)==s){o=e+1;r+=s.nodeSize;continue t}}i(s,r);if(o<n&&t.child(o).sameMarkup(s))_b(t.child(o),s,r+1,i);else s.nodesBetween(0,s.content.size,i,r+1);r+=s.nodeSize}}function Bb(t,e){let r;const i=(e,i)=>{if(e.type.spec.tableRole=="table")r=Rb(t,e,i,r)};if(!e)t.doc.descendants(i);else if(e.doc!=t.doc)_b(e.doc,t.doc,0,i);return r}function Rb(t,e,r,i){const n=ob.get(e);if(!n.problems)return i;if(!i)i=t.tr;const s=[];for(let t=0;t<n.height;t++)s.push(0);for(let t=0;t<n.problems.length;t++){const l=n.problems[t];if(l.type=="collision"){const t=e.nodeAt(l.pos);if(!t)continue;const n=t.attrs;for(let t=0;t<n.rowspan;t++)s[l.row+t]+=l.n;i.setNodeMarkup(i.mapping.map(r+1+l.pos),null,Eb(n,n.colspan-l.n,l.n))}else if(l.type=="missing"){s[l.row]+=l.n}else if(l.type=="overlong_rowspan"){const t=e.nodeAt(l.pos);if(!t)continue;i.setNodeMarkup(i.mapping.map(r+1+l.pos),null,{...t.attrs,rowspan:t.attrs.rowspan-l.n})}else if(l.type=="colwidth mismatch"){const t=e.nodeAt(l.pos);if(!t)continue;i.setNodeMarkup(i.mapping.map(r+1+l.pos),null,{...t.attrs,colwidth:l.colwidth})}else if(l.type=="zero_sized"){const t=i.mapping.map(r);i.delete(t,t+e.nodeSize)}}let l,o;for(let t=0;t<s.length;t++)if(s[t]){if(l==null)l=t;o=t}for(let u=0,f=r+1;u<n.height;u++){const r=e.child(u);const n=f+r.nodeSize;const h=s[u];if(h>0){let e="cell";if(r.firstChild){e=r.firstChild.type.spec.tableRole}const s=[];for(let r=0;r<h;r++){const r=mb(t.schema)[e].createAndFill();if(r)s.push(r)}const a=(u==0||l==u-1)&&o==u?f+1:n-1;i.insert(i.mapping.map(a),s)}f=n}return i.setMeta($b,{fixTables:true})}function jb(t,e){const r=t.selection;if(!(r instanceof Mb))return false;if(e){const i=t.tr;const n=mb(t.schema).cell.createAndFill().content;r.forEachCell(((t,e)=>{if(!t.content.eq(n))i.replace(i.mapping.map(e+1),i.mapping.map(e+t.nodeSize-1),new Ee(n,0,0))}));if(i.docChanged)e(i)}return true}function Nb(t){if(!t.size)return null;let{content:e,openStart:r,openEnd:i}=t;while(e.childCount==1&&(r>0&&i>0||e.child(0).type.spec.tableRole=="table")){r--;i--;e=e.child(0).content}const n=e.child(0);const s=n.type.spec.tableRole;const l=n.type.schema,o=[];if(s=="row"){for(let t=0;t<e.childCount;t++){let n=e.child(t).content;const s=t?0:Math.max(0,r-1);const u=t<e.childCount-1?0:Math.max(0,i-1);if(s||u)n=zb(mb(l).row,new Ee(n,s,u)).content;o.push(n)}}else if(s=="cell"||s=="header_cell"){o.push(r||i?zb(mb(l).row,new Ee(e,r,i)).content:e)}else{return null}return qb(l,o)}function qb(t,e){const r=[];for(let t=0;t<e.length;t++){const i=e[t];for(let e=i.childCount-1;e>=0;e--){const{rowspan:n,colspan:s}=i.child(e).attrs;for(let e=t;e<t+n;e++)r[e]=(r[e]||0)+s}}let i=0;for(let t=0;t<r.length;t++)i=Math.max(i,r[t]);for(let n=0;n<r.length;n++){if(n>=e.length)e.push(be.empty);if(r[n]<i){const s=mb(t).cell.createAndFill();const l=[];for(let t=r[n];t<i;t++){l.push(s)}e[n]=e[n].append(be.from(l))}}return{height:e.length,width:i,rows:e}}function zb(t,e){const r=t.createAndFill();const i=new Xi(r).replace(0,r.content.size,e);return i.doc}function Tb({width:t,height:e,rows:r},i,n){if(t!=i){const e=[];const n=[];for(let t=0;t<r.length;t++){const s=r[t],l=[];for(let r=e[t]||0,n=0;r<i;n++){let o=s.child(n%s.childCount);if(r+o.attrs.colspan>i)o=o.type.createChecked(Eb(o.attrs,o.attrs.colspan,r+o.attrs.colspan-i),o.content);l.push(o);r+=o.attrs.colspan;for(let r=1;r<o.attrs.rowspan;r++)e[t+r]=(e[t+r]||0)+o.attrs.colspan}n.push(be.from(l))}r=n;t=i}if(e!=n){const t=[];for(let i=0,s=0;i<n;i++,s++){const l=[],o=r[s%e];for(let t=0;t<o.childCount;t++){let e=o.child(t);if(i+e.attrs.rowspan>n)e=e.type.create({...e.attrs,rowspan:Math.max(1,n-e.attrs.rowspan)},e.content);l.push(e)}t.push(be.from(l))}r=t;e=n}return{width:t,height:e,rows:r}}function Ib(t,e,r,i,n,s,l){const o=t.doc.type.schema;const u=mb(o);let f;let h;if(n>e.width){for(let s=0,o=0;s<e.height;s++){const a=r.child(s);o+=a.nodeSize;const c=[];let d;if(a.lastChild==null||a.lastChild.type==u.cell)d=f||(f=u.cell.createAndFill());else d=h||(h=u.header_cell.createAndFill());for(let t=e.width;t<n;t++)c.push(d);t.insert(t.mapping.slice(l).map(o-1+i),c)}}if(s>e.height){const o=[];for(let t=0,i=(e.height-1)*e.width;t<Math.max(e.width,n);t++){const n=t>=e.width?false:r.nodeAt(e.map[i+t]).type==u.header_cell;o.push(n?h||(h=u.header_cell.createAndFill()):f||(f=u.cell.createAndFill()))}const a=u.row.create(null,be.from(o)),c=[];for(let t=e.height;t<s;t++)c.push(a);t.insert(t.mapping.slice(l).map(i+r.nodeSize-2),c)}return!!(f||h)}function Pb(t,e,r,i,n,s,l,o){if(l==0||l==e.height)return false;let u=false;for(let f=n;f<s;f++){const n=l*e.width+f,s=e.map[n];if(e.map[n-e.width]==s){u=true;const n=r.nodeAt(s);const{top:h,left:a}=e.findCell(s);t.setNodeMarkup(t.mapping.slice(o).map(s+i),null,{...n.attrs,rowspan:l-h});t.insert(t.mapping.slice(o).map(e.positionAt(l,a,r)),n.type.createAndFill({...n.attrs,rowspan:h+n.attrs.rowspan-l}));f+=n.attrs.colspan-1}}return u}function Jb(t,e,r,i,n,s,l,o){if(l==0||l==e.width)return false;let u=false;for(let f=n;f<s;f++){const n=f*e.width+l,s=e.map[n];if(e.map[n-1]==s){u=true;const n=r.nodeAt(s);const h=e.colCount(s);const a=t.mapping.slice(o).map(s+i);t.setNodeMarkup(a,null,Eb(n.attrs,l-h,n.attrs.colspan-(l-h)));t.insert(a+n.nodeSize,n.type.createAndFill(Eb(n.attrs,0,l-h)));f+=n.attrs.rowspan-1}}return u}function Lb(t,e,r,i,n){let s=r?t.doc.nodeAt(r-1):t.doc;if(!s){throw new Error("No table found")}let l=ob.get(s);const{top:o,left:u}=i;const f=u+n.width,h=o+n.height;const a=t.tr;let c=0;function d(){s=r?a.doc.nodeAt(r-1):a.doc;if(!s){throw new Error("No table found")}l=ob.get(s);c=a.mapping.maps.length}if(Ib(a,l,s,r,f,h,c))d();if(Pb(a,l,s,r,u,f,o,c))d();if(Pb(a,l,s,r,u,f,h,c))d();if(Jb(a,l,s,r,o,h,u,c))d();if(Jb(a,l,s,r,o,h,f,c))d();for(let t=o;t<h;t++){const e=l.positionAt(t,u,s),i=l.positionAt(t,f,s);a.replace(a.mapping.slice(c).map(e+r),a.mapping.slice(c).map(i+r),new Ee(n.rows[t-o],0,0))}d();a.setSelection(new Mb(a.doc.resolve(r+l.positionAt(o,u,s)),a.doc.resolve(r+l.positionAt(h-1,f-1,s))));e(a)}var Wb=_f({ArrowLeft:Hb("horiz",-1),ArrowRight:Hb("horiz",1),ArrowUp:Hb("vert",-1),ArrowDown:Hb("vert",1),"Shift-ArrowLeft":Zb("horiz",-1),"Shift-ArrowRight":Zb("horiz",1),"Shift-ArrowUp":Zb("vert",-1),"Shift-ArrowDown":Zb("vert",1),Backspace:jb,"Mod-Backspace":jb,Delete:jb,"Mod-Delete":jb});function Ub(t,e,r){if(r.eq(t.selection))return false;if(e)e(t.tr.setSelection(r).scrollIntoView());return true}function Hb(t,e){return(r,i,n)=>{if(!n)return false;const s=r.selection;if(s instanceof Mb){return Ub(r,i,Qi.near(s.$headCell,e))}if(t!="horiz"&&!s.empty)return false;const l=Xb(n,t,e);if(l==null)return false;if(t=="horiz"){return Ub(r,i,Qi.near(r.doc.resolve(s.head+e),e))}else{const n=r.doc.resolve(l);const s=Fb(n,t,e);let o;if(s)o=Qi.near(s,1);else if(e<0)o=Qi.near(r.doc.resolve(n.before(-1)),-1);else o=Qi.near(r.doc.resolve(n.after(-1)),1);return Ub(r,i,o)}}}function Zb(t,e){return(r,i,n)=>{if(!n)return false;const s=r.selection;let l;if(s instanceof Mb){l=s}else{const i=Xb(n,t,e);if(i==null)return false;l=new Mb(r.doc.resolve(i))}const o=Fb(l.$headCell,t,e);if(!o)return false;return Ub(r,i,new Mb(l.$anchorCell,o))}}function Kb(t,e){const r=t.state.doc,i=gb(r.resolve(e));if(!i)return false;t.dispatch(t.state.tr.setSelection(new Mb(i)));return true}function Vb(t,e,r){if(!bb(t.state))return false;let i=Nb(r);const n=t.state.selection;if(n instanceof Mb){if(!i)i={width:1,height:1,rows:[be.from(zb(mb(t.state.schema).cell,r))]};const e=n.$anchorCell.node(-1);const s=n.$anchorCell.start(-1);const l=ob.get(e).rectBetween(n.$anchorCell.pos-s,n.$headCell.pos-s);i=Tb(i,l.right-l.left,l.bottom-l.top);Lb(t.state,t.dispatch,s,l,i);return true}else if(i){const e=kb(t.state);const r=e.start(-1);Lb(t.state,t.dispatch,r,ob.get(e.node(-1)).findCell(e.pos-r),i);return true}else{return false}}function Gb(t,e){var r;if(e.ctrlKey||e.metaKey)return;const i=Yb(t,e.target);let n;if(e.shiftKey&&t.state.selection instanceof Mb){s(t.state.selection.$anchorCell,e);e.preventDefault()}else if(e.shiftKey&&i&&(n=gb(t.state.selection.$anchor))!=null&&((r=Qb(t,e))==null?void 0:r.pos)!=n.pos){s(n,e);e.preventDefault()}else if(!i){return}function s(e,r){let i=Qb(t,r);const n=wb.getState(t.state)==null;if(!i||!yb(e,i)){if(n)i=e;else return}const s=new Mb(e,i);if(n||!t.state.selection.eq(s)){const r=t.state.tr.setSelection(s);if(n)r.setMeta(wb,e.pos);t.dispatch(r)}}function l(){t.root.removeEventListener("mouseup",l);t.root.removeEventListener("dragstart",l);t.root.removeEventListener("mousemove",o);if(wb.getState(t.state)!=null)t.dispatch(t.state.tr.setMeta(wb,-1))}function o(r){const n=r;const o=wb.getState(t.state);let u;if(o!=null){u=t.state.doc.resolve(o)}else if(Yb(t,n.target)!=i){u=Qb(t,e);if(!u)return l()}if(u)s(u,n)}t.root.addEventListener("mouseup",l);t.root.addEventListener("dragstart",l);t.root.addEventListener("mousemove",o)}function Xb(t,e,r){if(!(t.state.selection instanceof nn))return null;const{$head:i}=t.state.selection;for(let n=i.depth-1;n>=0;n--){const s=i.node(n),l=r<0?i.index(n):i.indexAfter(n);if(l!=(r<0?0:s.childCount))return null;if(s.type.spec.tableRole=="cell"||s.type.spec.tableRole=="header_cell"){const s=i.before(n);const l=e=="vert"?r>0?"down":"up":r>0?"right":"left";return t.endOfTextblock(l)?s:null}}return null}function Yb(t,e){for(;e&&e!=t.dom;e=e.parentNode){if(e.nodeName=="TD"||e.nodeName=="TH"){return e}}return null}function Qb(t,e){const r=t.posAtCoords({left:e.clientX,top:e.clientY});if(!r)return null;return r?gb(t.state.doc.resolve(r.pos)):null}new Mn("tableColumnResizing");function tk({allowTableNodeSelection:t=false}={}){return new yn({key:wb,state:{init(){return null},apply(t,e){const r=t.getMeta(wb);if(r!=null)return r==-1?null:r;if(e==null||!t.docChanged)return e;const{deleted:i,pos:n}=t.mapping.mapResult(e);return i?null:n}},props:{decorations:Ab,handleDOMEvents:{mousedown:Gb},createSelectionBetween(t){return wb.getState(t.state)!=null?t.state.selection:null},handleTripleClick:Kb,handleKeyDown:Wb,handlePaste:Vb},appendTransaction(e,r,i){return Ob(i,Bb(i,r),t)}})}const ek=t=>{if(t){return[tk()]}return[]};const rk=t=>({default:null,getFromDOM:e=>e.style[t]||null,setDOMAttr:(e,r)=>{if(e){r.style=(r.style||"")+`${t}: ${e};`}}});const ik=()=>pb({tableGroup:"block",cellContent:"block+",cellAttributes:{background:rk("background-color"),color:rk("color")}});const nk='@charset "UTF-8";:host{--mdc-theme-primary:var(\n --lime-primary-color,\n rgb(var(--color-teal-default))\n );--mdc-theme-secondary:var(\n --lime-secondary-color,\n rgb(var(--contrast-1100))\n );--mdc-theme-on-primary:var(\n --lime-on-primary-color,\n rgb(var(--contrast-100))\n );--mdc-theme-on-secondary:var(\n --lime-on-secondary-color,\n rgb(var(--contrast-100))\n );--mdc-theme-text-disabled-on-background:var(\n --lime-text-disabled-on-background-color,\n rgba(var(--contrast-1700), 0.38)\n );--mdc-theme-text-primary-on-background:var(\n --lime-text-primary-on-background-color,\n rgba(var(--contrast-1700), 0.87)\n );--mdc-theme-text-secondary-on-background:var(\n --lime-text-secondary-on-background-color,\n rgba(var(--contrast-1700), 0.54)\n );--mdc-theme-error:var(\n --lime-error-background-color,\n rgb(var(--color-red-dark))\n );--lime-error-text-color:rgb(var(--color-red-darker));--mdc-theme-surface:var(\n --lime-surface-background-color,\n rgb(var(--contrast-100))\n );--mdc-theme-on-surface:var(\n --lime-on-surface-color,\n rgb(var(--contrast-1500))\n )}:host(limel-prosemirror-adapter){display:flex;flex-direction:column}:host(limel-prosemirror-adapter) .toolbar{order:1}:host(limel-prosemirror-adapter) div#editor{order:2;height:100%;flex-grow:1}:host(limel-prosemirror-adapter) div[contenteditable=true]{height:100%}*{box-sizing:border-box}:host(limel-prosemirror-adapter:hover) .toolbar,:host(limel-prosemirror-adapter:focus-within) .toolbar{will-change:grid-template-rows}:host(limel-prosemirror-adapter:hover) limel-action-bar,:host(limel-prosemirror-adapter:focus-within) limel-action-bar{will-change:opacity, padding}.ProseMirror-menubar-wrapper{display:grid;grid-template-rows:auto 1fr}.ProseMirror-textblock-dropdown{min-width:3em}.ProseMirror-tooltip .ProseMirror-menu{width:-webkit-fit-content;width:fit-content;white-space:pre}.toolbar{--action-bar-border-radius:0.25rem;border-radius:var(--action-bar-border-radius);flex-shrink:0;position:sticky;z-index:1;top:0;width:100%;display:grid;grid-template-rows:var(--limel-prosemirror-adapter-toolbar-grid-template-rows);transition-property:grid-template-rows;transition-duration:var(--limel-prosemirror-adapter-toolbar-grid-template-rows-transition-duration);transition-timing-function:var(--limel-prosemirror-adapter-toolbar-transition-timing-function);background-color:rgba(var(--contrast-200), 0.5);backdrop-filter:blur(0.5rem);-webkit-backdrop-filter:blur(0.5rem)}limel-action-bar{min-width:0;transition-property:padding, opacity;transition-duration:var(--limel-prosemirror-adapter-toolbar-grid-template-rows-transition-duration);transition-timing-function:var(--limel-prosemirror-adapter-toolbar-transition-timing-function);opacity:var(--limel-prosemirror-adapter-toolbar-opacity);padding:var(--limel-prosemirror-adapter-action-bar-padding-top-bottom, 0.125rem) 0.25rem;background-color:transparent;overflow:hidden}.ProseMirror{position:relative;word-wrap:break-word;white-space:pre-wrap;white-space:break-spaces;-webkit-font-variant-ligatures:none;font-variant-ligatures:none;font-feature-settings:"liga" 0;padding:var(--limel-text-editor-padding)}.ProseMirror [draggable][contenteditable=false]{user-select:text}.ProseMirror:focus-visible{outline:none}.ProseMirror-hideselection{caret-color:transparent}.ProseMirror-hideselection *::selection{background:transparent}.ProseMirror-hideselection *::-moz-selection{background:transparent}.ProseMirror-selectednode{outline:0.125rem solid rgb(var(--color-sky-light))}li.ProseMirror-selectednode{outline:none}li.ProseMirror-selectednode:after{content:"";position:absolute;left:-2rem;right:-0.125rem;top:-0.125rem;bottom:-0.125rem;border:0.125rem solid rgb(var(--color-sky-light));pointer-events:none}img.ProseMirror-separator{display:inline !important;border:none !important;margin:0 !important}limel-portal{width:25rem}blockquote{position:relative;font-weight:100;font-size:0.875rem;max-width:100%;line-height:1.4;margin:0;padding:0.5rem 1.25rem;border-radius:0.05rem 0.75rem;background-color:rgb(var(--contrast-300))}blockquote:before,blockquote:after{position:absolute;font-size:2.75rem;opacity:0.4}blockquote:before{content:"“";left:0;top:-0.75rem}blockquote:after{content:"”";right:0;bottom:-2rem}:host(limel-markdown.truncate-paragraphs) p{overflow:hidden;white-space:nowrap;text-overflow:ellipsis}p,li{font-size:0.875rem;word-break:break-word;hyphens:auto;-webkit-hyphens:auto}a{word-break:break-all}p{margin-top:0;margin-bottom:0.5rem}p:only-child{margin-bottom:0}a{transition:color 0.2s ease;color:var(--markdown-hyperlink-color, rgb(var(--color-blue-dark)));text-decoration:none}a:hover{color:var(--markdown-hyperlink-color--hovered, rgb(var(--color-blue-default)))}hr{margin:1.75rem 0 2rem 0;border-width:0;border-top:1px solid rgb(var(--contrast-500))}dl{display:grid;grid-template-columns:1fr 2fr;grid-template-rows:1fr;margin-bottom:2rem;border:1px solid rgb(var(--contrast-400));border-radius:0.375rem;background-color:rgb(var(--contrast-200))}dl dt,dl dd{padding:0.375rem 0.5rem;font-size:0.875rem;margin:0}dl dt:nth-of-type(even),dl dd:nth-of-type(even){background-color:rgb(var(--contrast-300))}dl dt:first-child{border-top-left-radius:0.375rem}dl dt:last-child{border-bottom-left-radius:0.375rem}dl dd:first-child{border-top-right-radius:0.375rem}dl dd:last-child{border-bottom-right-radius:0.375rem}h1{font-size:1.5rem}h2{font-size:1.25rem}h3{font-size:1.125rem}h4{font-size:1rem}h5{font-size:0.875rem}h6{font-size:0.75rem}h1,h2{margin-top:0.5rem;margin-bottom:0.5rem;letter-spacing:-0.03125rem;font-weight:500}h3,h4{margin-top:0.75rem;margin-bottom:0.25rem;font-weight:600}h5,h6{margin-top:0.5rem;margin-bottom:0.125rem;font-weight:600}h1,h2,h3,h4,h5,h6{word-break:break-word;hyphens:auto;-webkit-hyphens:auto}:not([contenteditable=true]) h1,:not([contenteditable=true]) h2,:not([contenteditable=true]) h3,:not([contenteditable=true]) h4,:not([contenteditable=true]) h5,:not([contenteditable=true]) h6{text-wrap:balance}[contenteditable=true] h1,[contenteditable=true] h2,[contenteditable=true] h3,[contenteditable=true] h4,[contenteditable=true] h5,[contenteditable=true] h6{text-wrap:initial}ul{list-style:none}ul li{position:relative;margin-left:0.75rem}ul li:before{content:"";position:absolute;left:-0.5rem;top:0.5rem;width:0.25rem;height:0.25rem;border-radius:50%;background-color:rgb(var(--contrast-700));display:block}ol{margin-top:0.25rem;padding-left:1rem}ul{margin-top:0.25rem;padding-left:0}ul ul,ul ol,ol ol,ol ul{margin-left:0}li{margin-bottom:0.25rem}code{font-family:ui-monospace, "Cascadia Code", "Source Code Pro", Menlo, Consolas, "DejaVu Sans Mono", monospace;font-size:0.8125rem;letter-spacing:-0.0125rem;color:rgb(var(--contrast-1300));-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none;display:inline-block;border-radius:0.25rem;padding:0.03125rem 0.25rem;background-color:rgb(var(--contrast-600))}pre>code{display:block;margin:0.5rem 0;padding:0.5rem 0.75rem;overflow:auto;white-space:pre-wrap}:host(limel-markdown:not(.no-table-styles)) table{table-layout:auto;min-width:100%;border-collapse:collapse;border-spacing:0;background:transparent;margin:0.75rem 0}:host(limel-markdown:not(.no-table-styles)) tbody{border:1px solid rgb(var(--contrast-400));border-radius:0.25rem}:host(limel-markdown:not(.no-table-styles)) th,:host(limel-markdown:not(.no-table-styles)) td{text-align:left;vertical-align:top;transition:background-color 0.2s ease;font-size:0.875rem}:host(limel-markdown:not(.no-table-styles)) td{padding:0.5rem 0.375rem 0.75rem 0.375rem}:host(limel-markdown:not(.no-table-styles)) tr th{background-color:rgb(var(--contrast-400));padding:0.25rem 0.375rem;font-weight:normal}:host(limel-markdown:not(.no-table-styles)) tr th:only-child{text-align:center}:host(limel-markdown:not(.no-table-styles)) tbody tr:nth-child(odd) td{background-color:rgb(var(--contrast-200))}:host(limel-markdown:not(.no-table-styles)) tbody tr:hover td{background-color:rgb(var(--contrast-300))}table{display:block;box-sizing:border-box;overflow-x:auto;-webkit-overflow-scrolling:touch;max-width:100%}kbd{font-family:ui-monospace, "Cascadia Code", "Source Code Pro", Menlo, Consolas, "DejaVu Sans Mono", monospace;font-weight:600;color:rgb(var(--contrast-1100));background-color:rgb(var(--contrast-200));white-space:pre;word-spacing:normal;word-break:normal;word-wrap:normal;line-height:normal;padding:0.125rem 0.5rem;margin:0 0.25rem;box-shadow:var(--button-shadow-normal), 0 0.03125rem 0.21875rem 0 rgba(var(--contrast-100), 0.5) inset;border-radius:0.125rem;border-style:solid;border-color:rgba(var(--contrast-600), 0.8);border-width:0 1px 0.125rem 1px}img{max-width:100%;border-radius:0.25rem}';const sk=300;const lk=class{constructor(r){t(this,r);this.change=e(this,"change",7);this.changeWaiting=false;this.suppressChangeEvent=false;this.getActionBarItems=()=>{this.actionBarItems=Jc().map(this.getTranslatedItem)};this.getTranslatedItem=t=>{const e=pe(t);if($(t)){const r=Lc[t.value];if(r){e.text=S.get(r,this.language)}}return e};this.updateActiveActionBarItems=t=>{const e=Jc().map((e=>{if($(e)){return Object.assign(Object.assign({},e),{selected:t[e.value]})}return e}));this.actionBarItems=e};this.handleTransaction=t=>{const e=this.view.state.apply(t);this.view.updateState(e);if(this.suppressChangeEvent||t.getMeta("pointer")){return}const r=this.contentConverter.serialize(this.view,this.schema);if(r===this.lastEmittedValue){return}this.lastEmittedValue=r;this.changeWaiting=true;this.changeEmitter(r)};this.handleActionBarItem=t=>{t.preventDefault();t.stopImmediatePropagation();const{value:e}=t.detail;if(e===bc.Link){this.isLinkMenuOpen=true;return}const r=new CustomEvent("actionBarItemClick",{detail:t.detail});this.view.dom.dispatchEvent(r)};this.handleCancelLinkMenu=t=>{t.preventDefault();t.stopPropagation();this.isLinkMenuOpen=false;this.link={text:"",href:"https://"}};this.handleSaveLinkMenu=()=>{this.isLinkMenuOpen=false;const t=new CustomEvent("saveLinkMenu",{detail:{type:bc.Link,link:this.link}});this.view.dom.dispatchEvent(t);this.link={href:"https://"}};this.handleLinkChange=t=>{this.link=t.detail};this.handleFocus=()=>{var t;if(!this.disabled){(t=this.view)===null||t===void 0?void 0:t.focus()}};this.handleNewLinkSelection=(t,e)=>{this.link.text=t;this.link.href=e||"https://"};this.handleOpenLinkMenu=t=>{t.stopImmediatePropagation();const{href:e,text:r}=t.detail;this.link={href:e,text:r};this.isLinkMenuOpen=true};this.changeEmitter=B((t=>{this.change.emit(t);this.changeWaiting=false}),sk);this.handleBlur=()=>{this.changeEmitter.flush()};this.contentType="markdown";this.value=undefined;this.language=undefined;this.disabled=false;this.customElements=[];this.triggerCharacters=[];this.view=undefined;this.actionBarItems=[];this.link={href:"https://"};this.isLinkMenuOpen=false;this.portalId=O()}watchValue(t){if(!this.view){return}if(this.changeWaiting){return}const e=this.contentConverter.serialize(this.view,this.schema);if(t===e){return}this.updateView(t)}componentWillLoad(){this.getActionBarItems();this.setupContentConverter()}componentDidLoad(){setTimeout((()=>{this.initializeTextEditor()}),0)}connectedCallback(){if(this.view){this.initializeTextEditor()}this.host.addEventListener("open-editor-link-menu",this.handleOpenLinkMenu)}disconnectedCallback(){var t,e,r;this.host.removeEventListener("open-editor-link-menu",this.handleOpenLinkMenu);(e=(t=this.view)===null||t===void 0?void 0:t.dom)===null||e===void 0?void 0:e.removeEventListener("blur",this.handleBlur);(r=this.view)===null||r===void 0?void 0:r.destroy()}render(){return r(i,{onFocus:this.handleFocus},r("div",{id:"editor"}),r("div",{class:"toolbar"},r("limel-action-bar",{ref:t=>this.actionBarElement=t,accessibleLabel:"Toolbar",actions:this.actionBarItems,onItemSelected:this.handleActionBarItem})),this.renderLinkMenu())}renderLinkMenu(){if(!this.isLinkMenuOpen){return}return r("limel-portal",{containerId:this.portalId,visible:this.isLinkMenuOpen,openDirection:"top",inheritParentWidth:true,anchor:this.actionBarElement},r("limel-text-editor-link-menu",{link:this.link,isOpen:this.isLinkMenuOpen,onLinkChange:this.handleLinkChange,onCancel:this.handleCancelLinkMenu,onSave:this.handleSaveLinkMenu}))}setupContentConverter(){if(this.contentType==="markdown"){this.contentConverter=new wg(this.customElements)}else if(this.contentType==="html"){this.contentConverter=new gg(this.customElements)}else{throw new Error(`Unsupported content type: ${this.contentType}. Only 'markdown' and 'html' are supported.`)}}async initializeTextEditor(){this.schema=this.initializeSchema();const t=await this.parseInitialContent();this.menuCommandFactory=new qc(this.schema);this.view=new Tu(this.host.shadowRoot.querySelector("#editor"),{state:this.createEditorState(t),dispatchTransaction:this.handleTransaction});this.view.dom.addEventListener("blur",this.handleBlur);if(this.value){this.updateView(this.value)}}initializeSchema(){let t=nf.spec.nodes;this.customElements.forEach((e=>{const r=Wg(e);const i=e.tagName;t=t.append({[i]:r})}));t=cf(t,"paragraph block*","block");if(this.contentType==="html"){t=t.append(ik())}return new pr({nodes:t,marks:nf.spec.marks.append({strikethrough:bg})})}async parseInitialContent(){const t=document.createElement("div");if(this.value){t.innerHTML=await this.contentConverter.parseAsHTML(this.value,this.schema)}else{t.innerHTML="<p></p>"}return br.fromSchema(this.schema).parse(t)}createEditorState(t){return Dn.create({doc:t,plugins:[...gc({schema:this.schema,menuBar:false}),$f(this.menuCommandFactory.buildKeymap()),nb(this.triggerCharacters,this.contentConverter),_g(this.handleNewLinkSelection),Rg(),Ig(kc,this.menuCommandFactory,this.updateActiveActionBarItems),Lg(this.menuCommandFactory),...ek(this.contentType==="html")]})}async updateView(t){this.suppressChangeEvent=true;const e=await this.contentConverter.parseAsHTML(t,this.schema);const r=br.fromSchema(this.view.state.schema);const i=new window.DOMParser;const n=i.parseFromString(e,"text/html");const s=r.parse(n.body);const l=this.view.state.tr;l.replaceWith(0,l.doc.content.size,s.content);this.view.dispatch(l);this.suppressChangeEvent=false}static get delegatesFocus(){return true}get host(){return n(this)}static get watchers(){return{value:["watchValue"]}}};lk.style=nk;export{lk as limel_prosemirror_adapter};
|
|
2
|
+
//# sourceMappingURL=p-e5545944.entry.js.map
|