@limetech/lime-elements 39.3.2 → 39.4.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.
Files changed (26) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/cjs/lime-elements.cjs.js +1 -1
  3. package/dist/cjs/limel-markdown.cjs.entry.js +206 -13
  4. package/dist/cjs/limel-prosemirror-adapter.cjs.entry.js +1 -1
  5. package/dist/cjs/loader.cjs.js +1 -1
  6. package/dist/cjs/{markdown-parser-B66l_Zvo.js → markdown-parser-VvYe9xWW.js} +18 -1
  7. package/dist/collection/components/markdown/default-whitelist.js +64 -0
  8. package/dist/collection/components/markdown/hydrate-custom-elements.js +50 -1
  9. package/dist/collection/components/markdown/markdown.js +76 -9
  10. package/dist/collection/components/markdown/remove-empty-paragraphs-plugin.js +18 -1
  11. package/dist/collection/components/markdown/safe-url-protocols.js +24 -0
  12. package/dist/esm/lime-elements.js +1 -1
  13. package/dist/esm/limel-markdown.entry.js +204 -11
  14. package/dist/esm/limel-prosemirror-adapter.entry.js +1 -1
  15. package/dist/esm/loader.js +1 -1
  16. package/dist/esm/{markdown-parser-DJi1w622.js → markdown-parser-CeVA0wsI.js} +18 -1
  17. package/dist/lime-elements/lime-elements.esm.js +1 -1
  18. package/dist/lime-elements/{p-1c6dd14c.entry.js → p-8e4ec999.entry.js} +1 -1
  19. package/dist/lime-elements/{p-BRCcjfVu.js → p-CfUOv15O.js} +1 -1
  20. package/dist/lime-elements/p-f4c9301d.entry.js +1 -0
  21. package/dist/types/components/markdown/default-whitelist.d.ts +16 -0
  22. package/dist/types/components/markdown/markdown.d.ts +29 -4
  23. package/dist/types/components/markdown/safe-url-protocols.d.ts +20 -0
  24. package/dist/types/components.d.ts +34 -2
  25. package/package.json +1 -1
  26. package/dist/lime-elements/p-49204db4.entry.js +0 -1
@@ -1 +1 @@
1
- import{r as t,c as e,h as r,H as i,a as n}from"./p-DBTJNfo7.js";import{E as s,L as o,M as l,e as u}from"./p-BWYo6dLf.js";import{g as h,m as a,s as f}from"./p-BRCcjfVu.js";import{U as c,f as d,g as p,r as m,t as g,i as b,j as w,u as v}from"./p-DTNvx8HZ.js";import{a as k}from"./p-ZcW3uvZL.js";import{i as D,S as y}from"./p-BJQylLSL.js";import{g as E}from"./p-gWSB8lIW.js";import{i as x}from"./p-B8VKuhvH.js";import{i as F}from"./p-oiMYqRQ0.js";import{c as M}from"./p-2kcqdtMr.js";import{t as A}from"./p-Cdx3I2X8.js";import{c as C}from"./p-JbKhhoXs.js";import{i as S}from"./p-CrvUOVvg.js";import{c as O}from"./p-CWuGCKo1.js";import{i as $}from"./p-DkL-aPMx.js";import{d as B}from"./p-BviYUVSD.js";import"./p-BFTU3MAI.js";import"./p-DtS35Df5.js";import"./p-efBXH4mj.js";import"./p-BgPHaiMH.js";import"./p-Cs5T63LB.js";import"./p-f_1nwOC8.js";import"./p-DlJXKdhK.js";import"./p-CgNJbSP4.js";import"./p-D6dCQvwl.js";import"./p-BOEi1C7r.js";var R=Object.create,N=function(){function t(){}return function(e){if(!D(e))return{};if(R)return R(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}();"object"==typeof exports&&exports&&!exports.nodeType&&exports&&"object"==typeof module&&module&&!module.nodeType&&module;var _=Object.prototype.hasOwnProperty;function T(t){var e=new t.constructor(t.byteLength);return new c(e).set(new c(t)),e}var z=/\w*$/,j=y?y.prototype:void 0,q=j?j.valueOf:void 0;var I=g&&g.isMap,P=I?m(I):function(t){return F(t)&&"[object Map]"==p(t)},L=g&&g.isSet,J=L?m(L):function(t){return F(t)&&"[object Set]"==p(t)},U="[object Arguments]",V="[object Function]",H="[object Object]",W={};function G(t,e,r,i,n,s){var o;if(void 0!==o)return o;if(!D(t))return t;var l=x(t);if(l)o=function(t){var e=t.length,r=new t.constructor(e);return e&&"string"==typeof t[0]&&_.call(t,"index")&&(r.index=t.index,r.input=t.input),r}(t);else{var u=p(t),h=u==V||"[object GeneratorFunction]"==u;if(b(t))return t.slice();if(u==H||u==U||h&&!n)o=h?{}:function(t){return"function"!=typeof t.constructor||d(t)?{}:N(E(t))}(t);else{if(!W[u])return n?t:{};o=function(t,e){var r,i,n,s,o=t.constructor;switch(e){case"[object ArrayBuffer]":return T(t);case"[object Boolean]":case"[object Date]":return new o(+t);case"[object DataView]":return s=T((n=t).buffer),new n.constructor(s,n.byteOffset,n.byteLength);case"[object Float32Array]":case"[object Float64Array]":case"[object Int8Array]":case"[object Int16Array]":case"[object Int32Array]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":case"[object Uint16Array]":case"[object Uint32Array]":return function(t){var e=T(t.buffer);return new t.constructor(e,t.byteOffset,t.length)}(t);case"[object Map]":case"[object Set]":return new o;case"[object Number]":case"[object String]":return new o(t);case"[object RegExp]":return(i=new(r=t).constructor(r.source,z.exec(r))).lastIndex=r.lastIndex,i;case"[object Symbol]":return q?Object(q.call(t)):{}}}(t,u)}}s||(s=new w);var a=s.get(t);if(a)return a;s.set(t,o),J(t)?t.forEach((function(i){o.add(G(i,e,r,0,t,s))})):P(t)&&t.forEach((function(i,n){o.set(n,G(i,e,r,0,t,s))}));var f=l?void 0:v(t);return function(t,e){for(var r=-1,i=null==t?0:t.length;++r<i&&!1!==e(t[r],r););}(f||t,(function(i,n){f&&(i=t[n=i]),k(o,n,G(i,e,r,0,t,s))})),o}function Z(t){return G(t,5)}function K(t){this.content=t}function Y(t,e,r){for(let i=0;;i++){if(i==t.childCount||i==e.childCount)return t.childCount==e.childCount?null:r;let n=t.child(i),s=e.child(i);if(n!=s){if(!n.sameMarkup(s))return r;if(n.isText&&n.text!=s.text){for(let t=0;n.text[t]==s.text[t];t++)r++;return r}if(n.content.size||s.content.size){let t=Y(n.content,s.content,r+1);if(null!=t)return t}r+=n.nodeSize}else r+=n.nodeSize}}function X(t,e,r,i){for(let n=t.childCount,s=e.childCount;;){if(0==n||0==s)return n==s?null:{a:r,b:i};let o=t.child(--n),l=e.child(--s),u=o.nodeSize;if(o!=l){if(!o.sameMarkup(l))return{a:r,b:i};if(o.isText&&o.text!=l.text){let t=0,e=Math.min(o.text.length,l.text.length);for(;t<e&&o.text[o.text.length-t-1]==l.text[l.text.length-t-1];)t++,r--,i--;return{a:r,b:i}}if(o.content.size||l.content.size){let t=X(o.content,l.content,r-1,i-1);if(t)return t}r-=u,i-=u}else r-=u,i-=u}}W[U]=W["[object Array]"]=W["[object ArrayBuffer]"]=W["[object DataView]"]=W["[object Boolean]"]=W["[object Date]"]=W["[object Float32Array]"]=W["[object Float64Array]"]=W["[object Int8Array]"]=W["[object Int16Array]"]=W["[object Int32Array]"]=W["[object Map]"]=W["[object Number]"]=W[H]=W["[object RegExp]"]=W["[object Set]"]=W["[object String]"]=W["[object Symbol]"]=W["[object Uint8Array]"]=W["[object Uint8ClampedArray]"]=W["[object Uint16Array]"]=W["[object Uint32Array]"]=!0,W["[object Error]"]=W[V]=W["[object WeakMap]"]=!1,K.prototype={constructor:K,find:function(t){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===t)return e;return-1},get:function(t){var e=this.find(t);return-1==e?void 0:this.content[e+1]},update:function(t,e,r){var i=r&&r!=t?this.remove(r):this,n=i.find(t),s=i.content.slice();return-1==n?s.push(r||t,e):(s[n+1]=e,r&&(s[n]=r)),new K(s)},remove:function(t){var e=this.find(t);if(-1==e)return this;var r=this.content.slice();return r.splice(e,2),new K(r)},addToStart:function(t,e){return new K([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var r=this.remove(t).content.slice();return r.push(t,e),new K(r)},addBefore:function(t,e,r){var i=this.remove(e),n=i.content.slice(),s=i.find(t);return n.splice(-1==s?n.length:s,0,e,r),new K(n)},forEach:function(t){for(var e=0;e<this.content.length;e+=2)t(this.content[e],this.content[e+1])},prepend:function(t){return(t=K.from(t)).size?new K(t.content.concat(this.subtract(t).content)):this},append:function(t){return(t=K.from(t)).size?new K(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=K.from(t);for(var r=0;r<t.content.length;r+=2)e=e.remove(t.content[r]);return e},toObject:function(){var t={};return this.forEach((function(e,r){t[e]=r})),t},get size(){return this.content.length>>1}},K.from=function(t){if(t instanceof K)return t;var e=[];if(t)for(var r in t)e.push(r,t[r]);return new K(e)};class Q{constructor(t,e){if(this.content=t,this.size=e||0,null==e)for(let e=0;e<t.length;e++)this.size+=t[e].nodeSize}nodesBetween(t,e,r,i=0,n){for(let s=0,o=0;o<e;s++){let l=this.content[s],u=o+l.nodeSize;if(u>t&&!1!==r(l,i+o,n||null,s)&&l.content.size){let n=o+1;l.nodesBetween(Math.max(0,t-n),Math.min(l.content.size,e-n),r,i+n)}o=u}}descendants(t){this.nodesBetween(0,this.size,t)}textBetween(t,e,r,i){let n="",s=!0;return this.nodesBetween(t,e,((o,l)=>{let u=o.isText?o.text.slice(Math.max(t,l)-l,e-l):o.isLeaf?i?"function"==typeof i?i(o):i:o.type.spec.leafText?o.type.spec.leafText(o):"":"";o.isBlock&&(o.isLeaf&&u||o.isTextblock)&&r&&(s?s=!1:n+=r),n+=u}),0),n}append(t){if(!t.size)return this;if(!this.size)return t;let e=this.lastChild,r=t.firstChild,i=this.content.slice(),n=0;for(e.isText&&e.sameMarkup(r)&&(i[i.length-1]=e.withText(e.text+r.text),n=1);n<t.content.length;n++)i.push(t.content[n]);return new Q(i,this.size+t.size)}cut(t,e=this.size){if(0==t&&e==this.size)return this;let r=[],i=0;if(e>t)for(let n=0,s=0;s<e;n++){let o=this.content[n],l=s+o.nodeSize;l>t&&((s<t||l>e)&&(o=o.isText?o.cut(Math.max(0,t-s),Math.min(o.text.length,e-s)):o.cut(Math.max(0,t-s-1),Math.min(o.content.size,e-s-1))),r.push(o),i+=o.nodeSize),s=l}return new Q(r,i)}cutByIndex(t,e){return t==e?Q.empty:0==t&&e==this.content.length?this:new Q(this.content.slice(t,e))}replaceChild(t,e){let r=this.content[t];if(r==e)return this;let i=this.content.slice(),n=this.size+e.nodeSize-r.nodeSize;return i[t]=e,new Q(i,n)}addToStart(t){return new Q([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new Q(this.content.concat(t),this.size+t.nodeSize)}eq(t){if(this.content.length!=t.content.length)return!1;for(let e=0;e<this.content.length;e++)if(!this.content[e].eq(t.content[e]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(t){let e=this.content[t];if(!e)throw new RangeError("Index "+t+" out of range for "+this);return e}maybeChild(t){return this.content[t]||null}forEach(t){for(let e=0,r=0;e<this.content.length;e++){let i=this.content[e];t(i,r,e),r+=i.nodeSize}}findDiffStart(t,e=0){return Y(this,t,e)}findDiffEnd(t,e=this.size,r=t.size){return X(this,t,e,r)}findIndex(t,e=-1){if(0==t)return et(0,t);if(t==this.size)return et(this.content.length,t);if(t>this.size||t<0)throw new RangeError(`Position ${t} outside of fragment (${this})`);for(let r=0,i=0;;r++){let n=i+this.child(r).nodeSize;if(n>=t)return n==t||e>0?et(r+1,n):et(r,i);i=n}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map((t=>t.toJSON())):null}static fromJSON(t,e){if(!e)return Q.empty;if(!Array.isArray(e))throw new RangeError("Invalid input for Fragment.fromJSON");return new Q(e.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return Q.empty;let e,r=0;for(let i=0;i<t.length;i++){let n=t[i];r+=n.nodeSize,i&&n.isText&&t[i-1].sameMarkup(n)?(e||(e=t.slice(0,i)),e[e.length-1]=n.withText(e[e.length-1].text+n.text)):e&&e.push(n)}return new Q(e||t,r)}static from(t){if(!t)return Q.empty;if(t instanceof Q)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new Q([t],t.nodeSize);throw new RangeError("Can not convert "+t+" to a Fragment"+(t.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}Q.empty=new Q([],0);const tt={index:0,offset:0};function et(t,e){return tt.index=t,tt.offset=e,tt}function rt(t,e){if(t===e)return!0;if(!t||"object"!=typeof t||!e||"object"!=typeof e)return!1;let r=Array.isArray(t);if(Array.isArray(e)!=r)return!1;if(r){if(t.length!=e.length)return!1;for(let r=0;r<t.length;r++)if(!rt(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!rt(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}class it{constructor(t,e){this.type=t,this.attrs=e}addToSet(t){let e,r=!1;for(let i=0;i<t.length;i++){let n=t[i];if(this.eq(n))return t;if(this.type.excludes(n.type))e||(e=t.slice(0,i));else{if(n.type.excludes(this.type))return t;!r&&n.type.rank>this.type.rank&&(e||(e=t.slice(0,i)),e.push(this),r=!0),e&&e.push(n)}}return e||(e=t.slice()),r||e.push(this),e}removeFromSet(t){for(let e=0;e<t.length;e++)if(this.eq(t[e]))return t.slice(0,e).concat(t.slice(e+1));return t}isInSet(t){for(let e=0;e<t.length;e++)if(this.eq(t[e]))return!0;return!1}eq(t){return this==t||this.type==t.type&&rt(this.attrs,t.attrs)}toJSON(){let t={type:this.type.name};for(let e in this.attrs){t.attrs=this.attrs;break}return t}static fromJSON(t,e){if(!e)throw new RangeError("Invalid input for Mark.fromJSON");let r=t.marks[e.type];if(!r)throw new RangeError(`There is no mark type ${e.type} in this schema`);let i=r.create(e.attrs);return r.checkAttrs(i.attrs),i}static sameSet(t,e){if(t==e)return!0;if(t.length!=e.length)return!1;for(let r=0;r<t.length;r++)if(!t[r].eq(e[r]))return!1;return!0}static setFrom(t){if(!t||Array.isArray(t)&&0==t.length)return it.none;if(t instanceof it)return[t];let e=t.slice();return e.sort(((t,e)=>t.type.rank-e.type.rank)),e}}it.none=[];class nt extends Error{}class st{constructor(t,e,r){this.content=t,this.openStart=e,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(t,e){let r=lt(this.content,t+this.openStart,e);return r&&new st(r,this.openStart,this.openEnd)}removeBetween(t,e){return new st(ot(this.content,t+this.openStart,e+this.openStart),this.openStart,this.openEnd)}eq(t){return this.content.eq(t.content)&&this.openStart==t.openStart&&this.openEnd==t.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let t={content:this.content.toJSON()};return this.openStart>0&&(t.openStart=this.openStart),this.openEnd>0&&(t.openEnd=this.openEnd),t}static fromJSON(t,e){if(!e)return st.empty;let r=e.openStart||0,i=e.openEnd||0;if("number"!=typeof r||"number"!=typeof i)throw new RangeError("Invalid input for Slice.fromJSON");return new st(Q.fromJSON(t,e.content),r,i)}static maxOpen(t,e=!0){let r=0,i=0;for(let i=t.firstChild;i&&!i.isLeaf&&(e||!i.type.spec.isolating);i=i.firstChild)r++;for(let r=t.lastChild;r&&!r.isLeaf&&(e||!r.type.spec.isolating);r=r.lastChild)i++;return new st(t,r,i)}}function ot(t,e,r){let{index:i,offset:n}=t.findIndex(e),s=t.maybeChild(i),{index:o,offset:l}=t.findIndex(r);if(n==e||s.isText){if(l!=r&&!t.child(o).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(r))}if(i!=o)throw new RangeError("Removing non-flat range");return t.replaceChild(i,s.copy(ot(s.content,e-n-1,r-n-1)))}function lt(t,e,r){let{index:i,offset:n}=t.findIndex(e),s=t.maybeChild(i);if(n==e||s.isText)return t.cut(0,e).append(r).append(t.cut(e));let o=lt(s.content,e-n-1,r);return o&&t.replaceChild(i,s.copy(o))}function ut(t,e,r){if(r.openStart>t.depth)throw new nt("Inserted content deeper than insertion position");if(t.depth-r.openStart!=e.depth-r.openEnd)throw new nt("Inconsistent open depths");return ht(t,e,r,0)}function ht(t,e,r,i){let n=t.index(i),s=t.node(i);if(n==e.index(i)&&i<t.depth-r.openStart){let o=ht(t,e,r,i+1);return s.copy(s.content.replaceChild(n,o))}if(r.content.size){if(r.openStart||r.openEnd||t.depth!=i||e.depth!=i){let{start:n,end:o}=function(t,e){let r=e.depth-t.openStart,i=e.node(r).copy(t.content);for(let t=r-1;t>=0;t--)i=e.node(t).copy(Q.from(i));return{start:i.resolveNoCache(t.openStart+r),end:i.resolveNoCache(i.content.size-t.openEnd-r)}}(r,t);return pt(s,mt(t,n,o,e,i))}{let i=t.parent,n=i.content;return pt(i,n.cut(0,t.parentOffset).append(r.content).append(n.cut(e.parentOffset)))}}return pt(s,gt(t,e,i))}function at(t,e){if(!e.type.compatibleContent(t.type))throw new nt("Cannot join "+e.type.name+" onto "+t.type.name)}function ft(t,e,r){let i=t.node(r);return at(i,e.node(r)),i}function ct(t,e){let r=e.length-1;r>=0&&t.isText&&t.sameMarkup(e[r])?e[r]=t.withText(e[r].text+t.text):e.push(t)}function dt(t,e,r,i){let n=(e||t).node(r),s=0,o=e?e.index(r):n.childCount;t&&(s=t.index(r),t.depth>r?s++:t.textOffset&&(ct(t.nodeAfter,i),s++));for(let t=s;t<o;t++)ct(n.child(t),i);e&&e.depth==r&&e.textOffset&&ct(e.nodeBefore,i)}function pt(t,e){return t.type.checkContent(e),t.copy(e)}function mt(t,e,r,i,n){let s=t.depth>n&&ft(t,e,n+1),o=i.depth>n&&ft(r,i,n+1),l=[];return dt(null,t,n,l),s&&o&&e.index(n)==r.index(n)?(at(s,o),ct(pt(s,mt(t,e,r,i,n+1)),l)):(s&&ct(pt(s,gt(t,e,n+1)),l),dt(e,r,n,l),o&&ct(pt(o,gt(r,i,n+1)),l)),dt(i,null,n,l),new Q(l)}function gt(t,e,r){let i=[];return dt(null,t,r,i),t.depth>r&&ct(pt(ft(t,e,r+1),gt(t,e,r+1)),i),dt(e,null,r,i),new Q(i)}st.empty=new st(Q.empty,0,0);class bt{constructor(t,e,r){this.pos=t,this.path=e,this.parentOffset=r,this.depth=e.length/3-1}resolveDepth(t){return null==t?this.depth:t<0?this.depth+t:t}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(t){return this.path[3*this.resolveDepth(t)]}index(t){return this.path[3*this.resolveDepth(t)+1]}indexAfter(t){return t=this.resolveDepth(t),this.index(t)+(t!=this.depth||this.textOffset?1:0)}start(t){return 0==(t=this.resolveDepth(t))?0:this.path[3*t-1]+1}end(t){return t=this.resolveDepth(t),this.start(t)+this.node(t).content.size}before(t){if(!(t=this.resolveDepth(t)))throw new RangeError("There is no position before the top-level node");return t==this.depth+1?this.pos:this.path[3*t-1]}after(t){if(!(t=this.resolveDepth(t)))throw new RangeError("There is no position after the top-level node");return t==this.depth+1?this.pos:this.path[3*t-1]+this.path[3*t].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let t=this.parent,e=this.index(this.depth);if(e==t.childCount)return null;let r=this.pos-this.path[this.path.length-1],i=t.child(e);return r?t.child(e).cut(r):i}get nodeBefore(){let t=this.index(this.depth),e=this.pos-this.path[this.path.length-1];return e?this.parent.child(t).cut(0,e):0==t?null:this.parent.child(t-1)}posAtIndex(t,e){e=this.resolveDepth(e);let r=this.path[3*e],i=0==e?0:this.path[3*e-1]+1;for(let e=0;e<t;e++)i+=r.child(e).nodeSize;return i}marks(){let t=this.parent,e=this.index();if(0==t.content.size)return it.none;if(this.textOffset)return t.child(e).marks;let r=t.maybeChild(e-1),i=t.maybeChild(e);if(!r){let t=r;r=i,i=t}let n=r.marks;for(var s=0;s<n.length;s++)!1!==n[s].type.spec.inclusive||i&&n[s].isInSet(i.marks)||(n=n[s--].removeFromSet(n));return n}marksAcross(t){let e=this.parent.maybeChild(this.index());if(!e||!e.isInline)return null;let r=e.marks,i=t.parent.maybeChild(t.index());for(var n=0;n<r.length;n++)!1!==r[n].type.spec.inclusive||i&&r[n].isInSet(i.marks)||(r=r[n--].removeFromSet(r));return r}sharedDepth(t){for(let e=this.depth;e>0;e--)if(this.start(e)<=t&&this.end(e)>=t)return e;return 0}blockRange(t=this,e){if(t.pos<this.pos)return t.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==t.pos?1:0);r>=0;r--)if(t.pos<=this.end(r)&&(!e||e(this.node(r))))return new Dt(this,t,r);return null}sameParent(t){return this.pos-this.parentOffset==t.pos-t.parentOffset}max(t){return t.pos>this.pos?t:this}min(t){return t.pos<this.pos?t:this}toString(){let t="";for(let e=1;e<=this.depth;e++)t+=(t?"/":"")+this.node(e).type.name+"_"+this.index(e-1);return t+":"+this.parentOffset}static resolve(t,e){if(!(e>=0&&e<=t.content.size))throw new RangeError("Position "+e+" out of range");let r=[],i=0,n=e;for(let e=t;;){let{index:t,offset:s}=e.content.findIndex(n),o=n-s;if(r.push(e,t,i+s),!o)break;if(e=e.child(t),e.isText)break;n=o-1,i+=s+1}return new bt(e,r,n)}static resolveCached(t,e){let r=kt.get(t);if(r)for(let t=0;t<r.elts.length;t++){let i=r.elts[t];if(i.pos==e)return i}else kt.set(t,r=new wt);let i=r.elts[r.i]=bt.resolve(t,e);return r.i=(r.i+1)%vt,i}}class wt{constructor(){this.elts=[],this.i=0}}const vt=12,kt=new WeakMap;class Dt{constructor(t,e,r){this.$from=t,this.$to=e,this.depth=r}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const yt=Object.create(null);class Et{constructor(t,e,r,i=it.none){this.type=t,this.attrs=e,this.marks=i,this.content=r||Q.empty}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(t){return this.content.child(t)}maybeChild(t){return this.content.maybeChild(t)}forEach(t){this.content.forEach(t)}nodesBetween(t,e,r,i=0){this.content.nodesBetween(t,e,r,i,this)}descendants(t){this.nodesBetween(0,this.content.size,t)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(t,e,r,i){return this.content.textBetween(t,e,r,i)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(t){return this==t||this.sameMarkup(t)&&this.content.eq(t.content)}sameMarkup(t){return this.hasMarkup(t.type,t.attrs,t.marks)}hasMarkup(t,e,r){return this.type==t&&rt(this.attrs,e||t.defaultAttrs||yt)&&it.sameSet(this.marks,r||it.none)}copy(t=null){return t==this.content?this:new Et(this.type,this.attrs,t,this.marks)}mark(t){return t==this.marks?this:new Et(this.type,this.attrs,this.content,t)}cut(t,e=this.content.size){return 0==t&&e==this.content.size?this:this.copy(this.content.cut(t,e))}slice(t,e=this.content.size,r=!1){if(t==e)return st.empty;let i=this.resolve(t),n=this.resolve(e),s=r?0:i.sharedDepth(e),o=i.start(s),l=i.node(s).content.cut(i.pos-o,n.pos-o);return new st(l,i.depth-s,n.depth-s)}replace(t,e,r){return ut(this.resolve(t),this.resolve(e),r)}nodeAt(t){for(let e=this;;){let{index:r,offset:i}=e.content.findIndex(t);if(e=e.maybeChild(r),!e)return null;if(i==t||e.isText)return e;t-=i+1}}childAfter(t){let{index:e,offset:r}=this.content.findIndex(t);return{node:this.content.maybeChild(e),index:e,offset:r}}childBefore(t){if(0==t)return{node:null,index:0,offset:0};let{index:e,offset:r}=this.content.findIndex(t);if(r<t)return{node:this.content.child(e),index:e,offset:r};let i=this.content.child(e-1);return{node:i,index:e-1,offset:r-i.nodeSize}}resolve(t){return bt.resolveCached(this,t)}resolveNoCache(t){return bt.resolve(this,t)}rangeHasMark(t,e,r){let i=!1;return e>t&&this.nodesBetween(t,e,(t=>(r.isInSet(t.marks)&&(i=!0),!i))),i}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let t=this.type.name;return this.content.size&&(t+="("+this.content.toStringInner()+")"),Ft(this.marks,t)}contentMatchAt(t){let e=this.type.contentMatch.matchFragment(this.content,0,t);if(!e)throw new Error("Called contentMatchAt on a node with invalid content");return e}canReplace(t,e,r=Q.empty,i=0,n=r.childCount){let s=this.contentMatchAt(t).matchFragment(r,i,n),o=s&&s.matchFragment(this.content,e);if(!o||!o.validEnd)return!1;for(let t=i;t<n;t++)if(!this.type.allowsMarks(r.child(t).marks))return!1;return!0}canReplaceWith(t,e,r,i){if(i&&!this.type.allowsMarks(i))return!1;let n=this.contentMatchAt(t).matchType(r),s=n&&n.matchFragment(this.content,e);return!!s&&s.validEnd}canAppend(t){return t.content.size?this.canReplace(this.childCount,this.childCount,t.content):this.type.compatibleContent(t.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let t=it.none;for(let e=0;e<this.marks.length;e++){let r=this.marks[e];r.type.checkAttrs(r.attrs),t=r.addToSet(t)}if(!it.sameSet(t,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map((t=>t.type.name))}`);this.content.forEach((t=>t.check()))}toJSON(){let t={type:this.type.name};for(let e in this.attrs){t.attrs=this.attrs;break}return this.content.size&&(t.content=this.content.toJSON()),this.marks.length&&(t.marks=this.marks.map((t=>t.toJSON()))),t}static fromJSON(t,e){if(!e)throw new RangeError("Invalid input for Node.fromJSON");let r;if(e.marks){if(!Array.isArray(e.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=e.marks.map(t.markFromJSON)}if("text"==e.type){if("string"!=typeof e.text)throw new RangeError("Invalid text node in JSON");return t.text(e.text,r)}let i=Q.fromJSON(t,e.content),n=t.nodeType(e.type).create(e.attrs,i,r);return n.type.checkAttrs(n.attrs),n}}Et.prototype.text=void 0;class xt extends Et{constructor(t,e,r,i){if(super(t,e,null,i),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Ft(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(t,e){return this.text.slice(t,e)}get nodeSize(){return this.text.length}mark(t){return t==this.marks?this:new xt(this.type,this.attrs,this.text,t)}withText(t){return t==this.text?this:new xt(this.type,this.attrs,t,this.marks)}cut(t=0,e=this.text.length){return 0==t&&e==this.text.length?this:this.withText(this.text.slice(t,e))}eq(t){return this.sameMarkup(t)&&this.text==t.text}toJSON(){let t=super.toJSON();return t.text=this.text,t}}function Ft(t,e){for(let r=t.length-1;r>=0;r--)e=t[r].type.name+"("+e+")";return e}class Mt{constructor(t){this.validEnd=t,this.next=[],this.wrapCache=[]}static parse(t,e){let r=new At(t,e);if(null==r.next)return Mt.empty;let i=Ct(r);r.next&&r.err("Unexpected trailing text");let n=function(t){let e=Object.create(null);return function r(i){let n=[];i.forEach((e=>{t[e].forEach((({term:e,to:r})=>{if(!e)return;let i;for(let t=0;t<n.length;t++)n[t][0]==e&&(i=n[t][1]);Nt(t,r).forEach((t=>{i||n.push([e,i=[]]),-1==i.indexOf(t)&&i.push(t)}))}))}));let s=e[i.join(",")]=new Mt(i.indexOf(t.length-1)>-1);for(let t=0;t<n.length;t++){let i=n[t][1].sort(Rt);s.next.push({type:n[t][0],next:e[i.join(",")]||r(i)})}return s}(Nt(t,0))}(function(t){let e=[[]];return n(function t(e,s){if("choice"==e.type)return e.exprs.reduce(((e,r)=>e.concat(t(r,s))),[]);if("seq"!=e.type){if("star"==e.type){let o=r();return i(s,o),n(t(e.expr,o),o),[i(o)]}if("plus"==e.type){let o=r();return n(t(e.expr,s),o),n(t(e.expr,o),o),[i(o)]}if("opt"==e.type)return[i(s)].concat(t(e.expr,s));if("range"==e.type){let o=s;for(let i=0;i<e.min;i++){let i=r();n(t(e.expr,o),i),o=i}if(-1==e.max)n(t(e.expr,o),o);else for(let s=e.min;s<e.max;s++){let s=r();i(o,s),n(t(e.expr,o),s),o=s}return[i(o)]}if("name"==e.type)return[i(s,void 0,e.value)];throw new Error("Unknown expr type")}for(let i=0;;i++){let o=t(e.exprs[i],s);if(i==e.exprs.length-1)return o;n(o,s=r())}}(t,0),r()),e;function r(){return e.push([])-1}function i(t,r,i){let n={term:i,to:r};return e[t].push(n),n}function n(t,e){t.forEach((t=>t.to=e))}}(i));return function(t,e){for(let r=0,i=[t];r<i.length;r++){let t=i[r],n=!t.validEnd,s=[];for(let e=0;e<t.next.length;e++){let{type:r,next:o}=t.next[e];s.push(r.name),!n||r.isText||r.hasRequiredAttrs()||(n=!1),-1==i.indexOf(o)&&i.push(o)}n&&e.err("Only non-generatable nodes ("+s.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}(n,r),n}matchType(t){for(let e=0;e<this.next.length;e++)if(this.next[e].type==t)return this.next[e].next;return null}matchFragment(t,e=0,r=t.childCount){let i=this;for(let n=e;i&&n<r;n++)i=i.matchType(t.child(n).type);return i}get inlineContent(){return 0!=this.next.length&&this.next[0].type.isInline}get defaultType(){for(let t=0;t<this.next.length;t++){let{type:e}=this.next[t];if(!e.isText&&!e.hasRequiredAttrs())return e}return null}compatible(t){for(let e=0;e<this.next.length;e++)for(let r=0;r<t.next.length;r++)if(this.next[e].type==t.next[r].type)return!0;return!1}fillBefore(t,e=!1,r=0){let i=[this];return function n(s,o){let l=s.matchFragment(t,r);if(l&&(!e||l.validEnd))return Q.from(o.map((t=>t.createAndFill())));for(let t=0;t<s.next.length;t++){let{type:e,next:r}=s.next[t];if(!e.isText&&!e.hasRequiredAttrs()&&-1==i.indexOf(r)){i.push(r);let t=n(r,o.concat(e));if(t)return t}}return null}(this,[])}findWrapping(t){for(let e=0;e<this.wrapCache.length;e+=2)if(this.wrapCache[e]==t)return this.wrapCache[e+1];let e=this.computeWrapping(t);return this.wrapCache.push(t,e),e}computeWrapping(t){let e=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let i=r.shift(),n=i.match;if(n.matchType(t)){let t=[];for(let e=i;e.type;e=e.via)t.push(e.type);return t.reverse()}for(let t=0;t<n.next.length;t++){let{type:s,next:o}=n.next[t];s.isLeaf||s.hasRequiredAttrs()||s.name in e||i.type&&!o.validEnd||(r.push({match:s.contentMatch,type:s,via:i}),e[s.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(t){if(t>=this.next.length)throw new RangeError(`There's no ${t}th edge in this content match`);return this.next[t]}toString(){let t=[];return function e(r){t.push(r);for(let i=0;i<r.next.length;i++)-1==t.indexOf(r.next[i].next)&&e(r.next[i].next)}(this),t.map(((e,r)=>{let i=r+(e.validEnd?"*":" ")+" ";for(let r=0;r<e.next.length;r++)i+=(r?", ":"")+e.next[r].type.name+"->"+t.indexOf(e.next[r].next);return i})).join("\n")}}Mt.empty=new Mt(!0);class At{constructor(t,e){this.string=t,this.nodeTypes=e,this.inline=null,this.pos=0,this.tokens=t.split(/\s*(?=\b|\W|$)/),""==this.tokens[this.tokens.length-1]&&this.tokens.pop(),""==this.tokens[0]&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(t){return this.next==t&&(this.pos++||!0)}err(t){throw new SyntaxError(t+" (in content expression '"+this.string+"')")}}function Ct(t){let e=[];do{e.push(St(t))}while(t.eat("|"));return 1==e.length?e[0]:{type:"choice",exprs:e}}function St(t){let e=[];do{e.push(Ot(t))}while(t.next&&")"!=t.next&&"|"!=t.next);return 1==e.length?e[0]:{type:"seq",exprs:e}}function Ot(t){let e=function(t){if(t.eat("(")){let e=Ct(t);return t.eat(")")||t.err("Missing closing paren"),e}if(!/\W/.test(t.next)){let e=function(t,e){let r=t.nodeTypes,i=r[e];if(i)return[i];let n=[];for(let t in r){let i=r[t];i.groups.indexOf(e)>-1&&n.push(i)}return 0==n.length&&t.err("No node type or group '"+e+"' found"),n}(t,t.next).map((e=>(null==t.inline?t.inline=e.isInline:t.inline!=e.isInline&&t.err("Mixing inline and block content"),{type:"name",value:e})));return t.pos++,1==e.length?e[0]:{type:"choice",exprs:e}}t.err("Unexpected token '"+t.next+"'")}(t);for(;;)if(t.eat("+"))e={type:"plus",expr:e};else if(t.eat("*"))e={type:"star",expr:e};else if(t.eat("?"))e={type:"opt",expr:e};else{if(!t.eat("{"))break;e=Bt(t,e)}return e}function $t(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function Bt(t,e){let r=$t(t),i=r;return t.eat(",")&&(i="}"!=t.next?$t(t):-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:r,max:i,expr:e}}function Rt(t,e){return e-t}function Nt(t,e){let r=[];return function e(i){let n=t[i];if(1==n.length&&!n[0].term)return e(n[0].to);r.push(i);for(let t=0;t<n.length;t++){let{term:i,to:s}=n[t];i||-1!=r.indexOf(s)||e(s)}}(e),r.sort(Rt)}function _t(t){let e=Object.create(null);for(let r in t){let i=t[r];if(!i.hasDefault)return null;e[r]=i.default}return e}function Tt(t,e){let r=Object.create(null);for(let i in t){let n=e&&e[i];if(void 0===n){let e=t[i];if(!e.hasDefault)throw new RangeError("No value supplied for attribute "+i);n=e.default}r[i]=n}return r}function zt(t,e,r){for(let i in e)if(!(i in t))throw new RangeError(`Unsupported attribute ${i} for ${r} of type ${i}`);for(let r in t){let i=t[r];i.validate&&i.validate(e[r])}}function jt(t,e){let r=Object.create(null);if(e)for(let i in e)r[i]=new It(t,i,e[i]);return r}let qt=class t{constructor(t,e,r){this.name=t,this.schema=e,this.spec=r,this.markSet=null,this.groups=r.group?r.group.split(" "):[],this.attrs=jt(t,r.attrs),this.defaultAttrs=_t(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(r.inline||"text"==t),this.isText="text"==t}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==Mt.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let t in this.attrs)if(this.attrs[t].isRequired)return!0;return!1}compatibleContent(t){return this==t||this.contentMatch.compatible(t.contentMatch)}computeAttrs(t){return!t&&this.defaultAttrs?this.defaultAttrs:Tt(this.attrs,t)}create(t=null,e,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Et(this,this.computeAttrs(t),Q.from(e),it.setFrom(r))}createChecked(t=null,e,r){return e=Q.from(e),this.checkContent(e),new Et(this,this.computeAttrs(t),e,it.setFrom(r))}createAndFill(t=null,e,r){if(t=this.computeAttrs(t),(e=Q.from(e)).size){let t=this.contentMatch.fillBefore(e);if(!t)return null;e=t.append(e)}let i=this.contentMatch.matchFragment(e),n=i&&i.fillBefore(Q.empty,!0);return n?new Et(this,t,e.append(n),it.setFrom(r)):null}validContent(t){let e=this.contentMatch.matchFragment(t);if(!e||!e.validEnd)return!1;for(let e=0;e<t.childCount;e++)if(!this.allowsMarks(t.child(e).marks))return!1;return!0}checkContent(t){if(!this.validContent(t))throw new RangeError(`Invalid content for node ${this.name}: ${t.toString().slice(0,50)}`)}checkAttrs(t){zt(this.attrs,t,"node")}allowsMarkType(t){return null==this.markSet||this.markSet.indexOf(t)>-1}allowsMarks(t){if(null==this.markSet)return!0;for(let e=0;e<t.length;e++)if(!this.allowsMarkType(t[e].type))return!1;return!0}allowedMarks(t){if(null==this.markSet)return t;let e;for(let r=0;r<t.length;r++)this.allowsMarkType(t[r].type)?e&&e.push(t[r]):e||(e=t.slice(0,r));return e?e.length?e:it.none:t}static compile(e,r){let i=Object.create(null);e.forEach(((e,n)=>i[e]=new t(e,r,n)));let n=r.spec.topNode||"doc";if(!i[n])throw new RangeError("Schema is missing its top node type ('"+n+"')");if(!i.text)throw new RangeError("Every schema needs a 'text' type");for(let t in i.text.attrs)throw new RangeError("The text node type should not have attributes");return i}};class It{constructor(t,e,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate="string"==typeof r.validate?function(t,e,r){let i=r.split("|");return r=>{let n=null===r?"null":typeof r;if(i.indexOf(n)<0)throw new RangeError(`Expected value of type ${i} for attribute ${e} on type ${t}, got ${n}`)}}(t,e,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class Pt{constructor(t,e,r,i){this.name=t,this.rank=e,this.schema=r,this.spec=i,this.attrs=jt(t,i.attrs),this.excluded=null;let n=_t(this.attrs);this.instance=n?new it(this,n):null}create(t=null){return!t&&this.instance?this.instance:new it(this,Tt(this.attrs,t))}static compile(t,e){let r=Object.create(null),i=0;return t.forEach(((t,n)=>r[t]=new Pt(t,i++,e,n))),r}removeFromSet(t){for(var e=0;e<t.length;e++)t[e].type==this&&(t=t.slice(0,e).concat(t.slice(e+1)),e--);return t}isInSet(t){for(let e=0;e<t.length;e++)if(t[e].type==this)return t[e]}checkAttrs(t){zt(this.attrs,t,"mark")}excludes(t){return this.excluded.indexOf(t)>-1}}class Lt{constructor(t){this.linebreakReplacement=null,this.cached=Object.create(null);let e=this.spec={};for(let r in t)e[r]=t[r];e.nodes=K.from(t.nodes),e.marks=K.from(t.marks||{}),this.nodes=qt.compile(this.spec.nodes,this),this.marks=Pt.compile(this.spec.marks,this);let r=Object.create(null);for(let t in this.nodes){if(t in this.marks)throw new RangeError(t+" can not be both a node and a mark");let e=this.nodes[t],i=e.spec.content||"",n=e.spec.marks;if(e.contentMatch=r[i]||(r[i]=Mt.parse(i,this.nodes)),e.inlineContent=e.contentMatch.inlineContent,e.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!e.isInline||!e.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=e}e.markSet="_"==n?null:n?Jt(this,n.split(" ")):""!=n&&e.inlineContent?null:[]}for(let t in this.marks){let e=this.marks[t],r=e.spec.excludes;e.excluded=null==r?[e]:""==r?[]:Jt(this,r.split(" "))}this.nodeFromJSON=this.nodeFromJSON.bind(this),this.markFromJSON=this.markFromJSON.bind(this),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(t,e=null,r,i){if("string"==typeof t)t=this.nodeType(t);else{if(!(t instanceof qt))throw new RangeError("Invalid node type: "+t);if(t.schema!=this)throw new RangeError("Node type from different schema used ("+t.name+")")}return t.createChecked(e,r,i)}text(t,e){let r=this.nodes.text;return new xt(r,r.defaultAttrs,t,it.setFrom(e))}mark(t,e){return"string"==typeof t&&(t=this.marks[t]),t.create(e)}nodeFromJSON(t){return Et.fromJSON(this,t)}markFromJSON(t){return it.fromJSON(this,t)}nodeType(t){let e=this.nodes[t];if(!e)throw new RangeError("Unknown node type: "+t);return e}}function Jt(t,e){let r=[];for(let i=0;i<e.length;i++){let n=e[i],s=t.marks[n],o=s;if(s)r.push(s);else for(let e in t.marks){let i=t.marks[e];("_"==n||i.spec.group&&i.spec.group.split(" ").indexOf(n)>-1)&&r.push(o=i)}if(!o)throw new SyntaxError("Unknown mark type: '"+e[i]+"'")}return r}class Ut{constructor(t,e){this.schema=t,this.rules=e,this.tags=[],this.styles=[];let r=this.matchedStyles=[];e.forEach((t=>{if(function(t){return null!=t.tag}(t))this.tags.push(t);else if(function(t){return null!=t.style}(t)){let e=/[^=]*/.exec(t.style)[0];r.indexOf(e)<0&&r.push(e),this.styles.push(t)}})),this.normalizeLists=!this.tags.some((e=>{if(!/^(ul|ol)\b/.test(e.tag)||!e.node)return!1;let r=t.nodes[e.node];return r.contentMatch.matchType(r)}))}parse(t,e={}){let r=new Kt(this,e,!1);return r.addAll(t,it.none,e.from,e.to),r.finish()}parseSlice(t,e={}){let r=new Kt(this,e,!0);return r.addAll(t,it.none,e.from,e.to),st.maxOpen(r.finish())}matchTag(t,e,r){for(let i=r?this.tags.indexOf(r)+1:0;i<this.tags.length;i++){let r=this.tags[i];if(Yt(t,r.tag)&&(void 0===r.namespace||t.namespaceURI==r.namespace)&&(!r.context||e.matchesContext(r.context))){if(r.getAttrs){let e=r.getAttrs(t);if(!1===e)continue;r.attrs=e||void 0}return r}}}matchStyle(t,e,r,i){for(let n=i?this.styles.indexOf(i)+1:0;n<this.styles.length;n++){let i=this.styles[n],s=i.style;if(!(0!=s.indexOf(t)||i.context&&!r.matchesContext(i.context)||s.length>t.length&&(61!=s.charCodeAt(t.length)||s.slice(t.length+1)!=e))){if(i.getAttrs){let t=i.getAttrs(e);if(!1===t)continue;i.attrs=t||void 0}return i}}}static schemaRules(t){let e=[];function r(t){let r=null==t.priority?50:t.priority,i=0;for(;i<e.length;i++){let t=e[i];if((null==t.priority?50:t.priority)<r)break}e.splice(i,0,t)}for(let e in t.marks){let i=t.marks[e].spec.parseDOM;i&&i.forEach((t=>{r(t=Xt(t)),t.mark||t.ignore||t.clearMark||(t.mark=e)}))}for(let e in t.nodes){let i=t.nodes[e].spec.parseDOM;i&&i.forEach((t=>{r(t=Xt(t)),t.node||t.ignore||t.mark||(t.node=e)}))}return e}static fromSchema(t){return t.cached.domParser||(t.cached.domParser=new Ut(t,Ut.schemaRules(t)))}}const Vt={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},Ht={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Wt={ol:!0,ul:!0};function Gt(t,e,r){return null!=e?(e?1:0)|("full"===e?2:0):t&&"pre"==t.whitespace?3:-5&r}class Zt{constructor(t,e,r,i,n,s){this.type=t,this.attrs=e,this.marks=r,this.solid=i,this.options=s,this.content=[],this.activeMarks=it.none,this.match=n||(4&s?null:t.contentMatch)}findWrapping(t){if(!this.match){if(!this.type)return[];let e=this.type.contentMatch.fillBefore(Q.from(t));if(!e){let e,r=this.type.contentMatch;return(e=r.findWrapping(t.type))?(this.match=r,e):null}this.match=this.type.contentMatch.matchFragment(e)}return this.match.findWrapping(t.type)}finish(t){if(!(1&this.options)){let t,e=this.content[this.content.length-1];if(e&&e.isText&&(t=/[ \t\r\n\u000c]+$/.exec(e.text))){let r=e;e.text.length==t[0].length?this.content.pop():this.content[this.content.length-1]=r.withText(r.text.slice(0,r.text.length-t[0].length))}}let e=Q.from(this.content);return!t&&this.match&&(e=e.append(this.match.fillBefore(Q.empty,!0))),this.type?this.type.create(this.attrs,e,this.marks):e}inlineContext(t){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:t.parentNode&&!Vt.hasOwnProperty(t.parentNode.nodeName.toLowerCase())}}class Kt{constructor(t,e,r){this.parser=t,this.options=e,this.isOpen=r,this.open=0;let i,n=e.topNode,s=Gt(null,e.preserveWhitespace,0)|(r?4:0);i=n?new Zt(n.type,n.attrs,it.none,!0,e.topMatch||n.type.contentMatch,s):new Zt(r?null:t.schema.topNodeType,null,it.none,!0,null,s),this.nodes=[i],this.find=e.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(t,e){3==t.nodeType?this.addTextNode(t,e):1==t.nodeType&&this.addElement(t,e)}addTextNode(t,e){let r=t.nodeValue,i=this.top;if(2&i.options||i.inlineContext(t)||/[^ \t\r\n\u000c]/.test(r)){if(1&i.options)r=2&i.options?r.replace(/\r\n?/g,"\n"):r.replace(/\r?\n|\r/g," ");else if(r=r.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let e=i.content[i.content.length-1],n=t.previousSibling;(!e||n&&"BR"==n.nodeName||e.isText&&/[ \t\r\n\u000c]$/.test(e.text))&&(r=r.slice(1))}r&&this.insertNode(this.parser.schema.text(r),e),this.findInText(t)}else this.findInside(t)}addElement(t,e,r){let i,n=t.nodeName.toLowerCase();Wt.hasOwnProperty(n)&&this.parser.normalizeLists&&function(t){for(let e=t.firstChild,r=null;e;e=e.nextSibling){let t=1==e.nodeType?e.nodeName.toLowerCase():null;t&&Wt.hasOwnProperty(t)&&r?(r.appendChild(e),e=r):"li"==t?r=e:t&&(r=null)}}(t);let s=this.options.ruleFromNode&&this.options.ruleFromNode(t)||(i=this.parser.matchTag(t,this,r));if(s?s.ignore:Ht.hasOwnProperty(n))this.findInside(t),this.ignoreFallback(t,e);else if(!s||s.skip||s.closeParent){s&&s.closeParent?this.open=Math.max(0,this.open-1):s&&s.skip.nodeType&&(t=s.skip);let r,i=this.top,o=this.needsBlock;if(Vt.hasOwnProperty(n))i.content.length&&i.content[0].isInline&&this.open&&(this.open--,i=this.top),r=!0,i.type||(this.needsBlock=!0);else if(!t.firstChild)return void this.leafFallback(t,e);let l=s&&s.skip?e:this.readStyles(t,e);l&&this.addAll(t,l),r&&this.sync(i),this.needsBlock=o}else{let r=this.readStyles(t,e);r&&this.addElementByRule(t,s,r,!1===s.consuming?i:void 0)}}leafFallback(t,e){"BR"==t.nodeName&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(t.ownerDocument.createTextNode("\n"),e)}ignoreFallback(t,e){"BR"!=t.nodeName||this.top.type&&this.top.type.inlineContent||this.findPlace(this.parser.schema.text("-"),e)}readStyles(t,e){let r=t.style;if(r&&r.length)for(let t=0;t<this.parser.matchedStyles.length;t++){let i=this.parser.matchedStyles[t],n=r.getPropertyValue(i);if(n)for(let t;;){let r=this.parser.matchStyle(i,n,this,t);if(!r)break;if(r.ignore)return null;if(e=r.clearMark?e.filter((t=>!r.clearMark(t))):e.concat(this.parser.schema.marks[r.mark].create(r.attrs)),!1!==r.consuming)break;t=r}}return e}addElementByRule(t,e,r,i){let n,s;if(e.node)if(s=this.parser.schema.nodes[e.node],s.isLeaf)this.insertNode(s.create(e.attrs),r)||this.leafFallback(t,r);else{let t=this.enter(s,e.attrs||null,r,e.preserveWhitespace);t&&(n=!0,r=t)}else r=r.concat(this.parser.schema.marks[e.mark].create(e.attrs));let o=this.top;if(s&&s.isLeaf)this.findInside(t);else if(i)this.addElement(t,r,i);else if(e.getContent)this.findInside(t),e.getContent(t,this.parser.schema).forEach((t=>this.insertNode(t,r)));else{let i=t;"string"==typeof e.contentElement?i=t.querySelector(e.contentElement):"function"==typeof e.contentElement?i=e.contentElement(t):e.contentElement&&(i=e.contentElement),this.findAround(t,i,!0),this.addAll(i,r)}n&&this.sync(o)&&this.open--}addAll(t,e,r,i){let n=r||0;for(let s=r?t.childNodes[r]:t.firstChild,o=null==i?null:t.childNodes[i];s!=o;s=s.nextSibling,++n)this.findAtPoint(t,n),this.addDOM(s,e);this.findAtPoint(t,n)}findPlace(t,e){let r,i;for(let e=this.open;e>=0;e--){let n=this.nodes[e],s=n.findWrapping(t);if(s&&(!r||r.length>s.length)&&(r=s,i=n,!s.length))break;if(n.solid)break}if(!r)return null;this.sync(i);for(let t=0;t<r.length;t++)e=this.enterInner(r[t],null,e,!1);return e}insertNode(t,e){if(t.isInline&&this.needsBlock&&!this.top.type){let t=this.textblockFromContext();t&&(e=this.enterInner(t,null,e))}let r=this.findPlace(t,e);if(r){this.closeExtra();let e=this.top;e.match&&(e.match=e.match.matchType(t.type));let i=it.none;for(let n of r.concat(t.marks))(e.type?e.type.allowsMarkType(n.type):Qt(n.type,t.type))&&(i=n.addToSet(i));return e.content.push(t.mark(i)),!0}return!1}enter(t,e,r,i){let n=this.findPlace(t.create(e),r);return n&&(n=this.enterInner(t,e,r,!0,i)),n}enterInner(t,e,r,i=!1,n){this.closeExtra();let s=this.top;s.match=s.match&&s.match.matchType(t);let o=Gt(t,n,s.options);4&s.options&&0==s.content.length&&(o|=4);let l=it.none;return r=r.filter((e=>!(s.type?s.type.allowsMarkType(e.type):Qt(e.type,t))||(l=e.addToSet(l),!1))),this.nodes.push(new Zt(t,e,l,i,null,o)),this.open++,r}closeExtra(t=!1){let e=this.nodes.length-1;if(e>this.open){for(;e>this.open;e--)this.nodes[e-1].content.push(this.nodes[e].finish(t));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(this.isOpen||this.options.topOpen)}sync(t){for(let e=this.open;e>=0;e--)if(this.nodes[e]==t)return this.open=e,!0;return!1}get currentPos(){this.closeExtra();let t=0;for(let e=this.open;e>=0;e--){let r=this.nodes[e].content;for(let e=r.length-1;e>=0;e--)t+=r[e].nodeSize;e&&t++}return t}findAtPoint(t,e){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==t&&this.find[r].offset==e&&(this.find[r].pos=this.currentPos)}findInside(t){if(this.find)for(let e=0;e<this.find.length;e++)null==this.find[e].pos&&1==t.nodeType&&t.contains(this.find[e].node)&&(this.find[e].pos=this.currentPos)}findAround(t,e,r){if(t!=e&&this.find)for(let i=0;i<this.find.length;i++)null==this.find[i].pos&&1==t.nodeType&&t.contains(this.find[i].node)&&e.compareDocumentPosition(this.find[i].node)&(r?2:4)&&(this.find[i].pos=this.currentPos)}findInText(t){if(this.find)for(let e=0;e<this.find.length;e++)this.find[e].node==t&&(this.find[e].pos=this.currentPos-(t.nodeValue.length-this.find[e].offset))}matchesContext(t){if(t.indexOf("|")>-1)return t.split(/\s*\|\s*/).some(this.matchesContext,this);let e=t.split("/"),r=this.options.context,i=!(this.isOpen||r&&r.parent.type!=this.nodes[0].type),n=(i?0:1)-(r?r.depth+1:0),s=(t,o)=>{for(;t>=0;t--){let l=e[t];if(""==l){if(t==e.length-1||0==t)continue;for(;o>=n;o--)if(s(t-1,o))return!0;return!1}{let t=o>0||0==o&&i?this.nodes[o].type:r&&o>=n?r.node(o-n).type:null;if(!t||t.name!=l&&-1==t.groups.indexOf(l))return!1;o--}}return!0};return s(e.length-1,this.open)}textblockFromContext(){let t=this.options.context;if(t)for(let e=t.depth;e>=0;e--){let r=t.node(e).contentMatchAt(t.indexAfter(e)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let t in this.parser.schema.nodes){let e=this.parser.schema.nodes[t];if(e.isTextblock&&e.defaultAttrs)return e}}}function Yt(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function Xt(t){let e={};for(let r in t)e[r]=t[r];return e}function Qt(t,e){let r=e.schema.nodes;for(let i in r){let n=r[i];if(!n.allowsMarkType(t))continue;let s=[],o=t=>{s.push(t);for(let r=0;r<t.edgeCount;r++){let{type:i,next:n}=t.edge(r);if(i==e)return!0;if(s.indexOf(n)<0&&o(n))return!0}};if(o(n.contentMatch))return!0}}class te{constructor(t,e){this.nodes=t,this.marks=e}serializeFragment(t,e={},r){r||(r=re(e).createDocumentFragment());let i=r,n=[];return t.forEach((t=>{if(n.length||t.marks.length){let r=0,s=0;for(;r<n.length&&s<t.marks.length;){let e=t.marks[s];if(this.marks[e.type.name]){if(!e.eq(n[r][0])||!1===e.type.spec.spanning)break;r++,s++}else s++}for(;r<n.length;)i=n.pop()[1];for(;s<t.marks.length;){let r=t.marks[s++],o=this.serializeMark(r,t.isInline,e);o&&(n.push([r,i]),i.appendChild(o.dom),i=o.contentDOM||o.dom)}}i.appendChild(this.serializeNodeInner(t,e))})),r}serializeNodeInner(t,e){let{dom:r,contentDOM:i}=ne(re(e),this.nodes[t.type.name](t),null,t.attrs);if(i){if(t.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(t.content,e,i)}return r}serializeNode(t,e={}){let r=this.serializeNodeInner(t,e);for(let i=t.marks.length-1;i>=0;i--){let n=this.serializeMark(t.marks[i],t.isInline,e);n&&((n.contentDOM||n.dom).appendChild(r),r=n.dom)}return r}serializeMark(t,e,r={}){let i=this.marks[t.type.name];return i&&ne(re(r),i(t,e),null,t.attrs)}static renderSpec(t,e,r=null,i){return ne(t,e,r,i)}static fromSchema(t){return t.cached.domSerializer||(t.cached.domSerializer=new te(this.nodesFromSchema(t),this.marksFromSchema(t)))}static nodesFromSchema(t){let e=ee(t.nodes);return e.text||(e.text=t=>t.text),e}static marksFromSchema(t){return ee(t.marks)}}function ee(t){let e={};for(let r in t){let i=t[r].spec.toDOM;i&&(e[r]=i)}return e}function re(t){return t.document||window.document}const ie=new WeakMap;function ne(t,e,r,i){if("string"==typeof e)return{dom:t.createTextNode(e)};if(null!=e.nodeType)return{dom:e};if(e.dom&&null!=e.dom.nodeType)return e;let n,s=e[0];if("string"!=typeof s)throw new RangeError("Invalid array passed to renderSpec");if(i&&(n=function(t){let e=ie.get(t);return void 0===e&&ie.set(t,e=function(t){let e=null;return function t(r){if(r&&"object"==typeof r)if(Array.isArray(r))if("string"==typeof r[0])e||(e=[]),e.push(r);else for(let e=0;e<r.length;e++)t(r[e]);else for(let e in r)t(r[e])}(t),e}(t)),e}(i))&&n.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let o,l=s.indexOf(" ");l>0&&(r=s.slice(0,l),s=s.slice(l+1));let u=r?t.createElementNS(r,s):t.createElement(s),h=e[1],a=1;if(h&&"object"==typeof h&&null==h.nodeType&&!Array.isArray(h)){a=2;for(let t in h)if(null!=h[t]){let e=t.indexOf(" ");e>0?u.setAttributeNS(t.slice(0,e),t.slice(e+1),h[t]):u.setAttribute(t,h[t])}}for(let n=a;n<e.length;n++){let s=e[n];if(0===s){if(n<e.length-1||n>a)throw new RangeError("Content hole must be the only child of its parent node");return{dom:u,contentDOM:u}}{let{dom:e,contentDOM:n}=ne(t,s,r,i);if(u.appendChild(e),n){if(o)throw new RangeError("Multiple content holes");o=n}}}return{dom:u,contentDOM:o}}const se=Math.pow(2,16);function oe(t){return 65535&t}class le{constructor(t,e,r){this.pos=t,this.delInfo=e,this.recover=r}get deleted(){return(8&this.delInfo)>0}get deletedBefore(){return(5&this.delInfo)>0}get deletedAfter(){return(6&this.delInfo)>0}get deletedAcross(){return(4&this.delInfo)>0}}class ue{constructor(t,e=!1){if(this.ranges=t,this.inverted=e,!t.length&&ue.empty)return ue.empty}recover(t){let e=0,r=oe(t);if(!this.inverted)for(let t=0;t<r;t++)e+=this.ranges[3*t+2]-this.ranges[3*t+1];return this.ranges[3*r]+e+function(t){return(t-(65535&t))/se}(t)}mapResult(t,e=1){return this._map(t,e,!1)}map(t,e=1){return this._map(t,e,!0)}_map(t,e,r){let i=0,n=this.inverted?2:1,s=this.inverted?1:2;for(let o=0;o<this.ranges.length;o+=3){let l=this.ranges[o]-(this.inverted?i:0);if(l>t)break;let u=this.ranges[o+n],h=this.ranges[o+s],a=l+u;if(t<=a){let n=l+i+((u?t==l?-1:t==a?1:e:e)<0?0:h);if(r)return n;let s=t==l?2:t==a?1:4;return(e<0?t!=l:t!=a)&&(s|=8),new le(n,s,t==(e<0?l:a)?null:o/3+(t-l)*se)}i+=h-u}return r?t+i:new le(t+i,0,null)}touches(t,e){let r=0,i=oe(e),n=this.inverted?2:1,s=this.inverted?1:2;for(let e=0;e<this.ranges.length;e+=3){let o=this.ranges[e]-(this.inverted?r:0);if(o>t)break;let l=this.ranges[e+n];if(t<=o+l&&e==3*i)return!0;r+=this.ranges[e+s]-l}return!1}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],o=s-(this.inverted?n:0),l=s+(this.inverted?0:n),u=this.ranges[i+e],h=this.ranges[i+r];t(o,o+u,l,l+h),n+=h-u}}invert(){return new ue(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(t){return 0==t?ue.empty:new ue(t<0?[0,-t,0]:[0,0,t])}}ue.empty=new ue([]);class he{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 he(this.maps,this.mirror,t,e)}copy(){return new he(this.maps.slice(),this.mirror&&this.mirror.slice(),this.from,this.to)}appendMap(t,e){this.to=this.maps.push(t),null!=e&&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],null!=i&&i<e?r+i:void 0)}}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){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(),null!=i&&i>e?r-i-1:void 0)}}invert(){let t=new he;return t.appendMappingInverted(this),t}map(t,e=1){if(this.mirror)return this._map(t,e,!0);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,!1)}_map(t,e,r){let i=0;for(let r=this.from;r<this.to;r++){let n=this.maps[r].mapResult(t,e);if(null!=n.recover){let e=this.getMirror(r);if(null!=e&&e>r&&e<this.to){r=e,t=this.maps[e].recover(n.recover);continue}}i|=n.delInfo,t=n.pos}return r?t:new le(t,i,null)}}const ae=Object.create(null);class fe{getMap(){return ue.empty}merge(t){return null}static fromJSON(t,e){if(!e||!e.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=ae[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 ae)throw new RangeError("Duplicate use of step JSON ID "+t);return ae[t]=e,e.prototype.jsonID=t,e}}class ce{constructor(t,e){this.doc=t,this.failed=e}static ok(t){return new ce(t,null)}static fail(t){return new ce(null,t)}static fromReplace(t,e,r,i){try{return ce.ok(t.replace(e,r,i))}catch(t){if(t instanceof nt)return ce.fail(t.message);throw t}}}function de(t,e,r){let i=[];for(let n=0;n<t.childCount;n++){let s=t.child(n);s.content.size&&(s=s.copy(de(s.content,e,s))),s.isInline&&(s=e(s,r,n)),i.push(s)}return Q.fromArray(i)}class pe extends fe{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),i=r.node(r.sharedDepth(this.to)),n=new st(de(e.content,((t,e)=>t.isAtom&&e.type.allowsMarkType(this.mark.type)?t.mark(this.mark.addToSet(t.marks)):t),i),e.openStart,e.openEnd);return ce.fromReplace(t,this.from,this.to,n)}invert(){return new me(this.from,this.to,this.mark)}map(t){let e=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return e.deleted&&r.deleted||e.pos>=r.pos?null:new pe(e.pos,r.pos,this.mark)}merge(t){return t instanceof pe&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new pe(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,e){if("number"!=typeof e.from||"number"!=typeof e.to)throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new pe(e.from,e.to,t.markFromJSON(e.mark))}}fe.jsonID("addMark",pe);class me extends fe{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=new st(de(e.content,(t=>t.mark(this.mark.removeFromSet(t.marks))),t),e.openStart,e.openEnd);return ce.fromReplace(t,this.from,this.to,r)}invert(){return new pe(this.from,this.to,this.mark)}map(t){let e=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return e.deleted&&r.deleted||e.pos>=r.pos?null:new me(e.pos,r.pos,this.mark)}merge(t){return t instanceof me&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new me(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,e){if("number"!=typeof e.from||"number"!=typeof e.to)throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new me(e.from,e.to,t.markFromJSON(e.mark))}}fe.jsonID("removeMark",me);class ge extends fe{constructor(t,e){super(),this.pos=t,this.mark=e}apply(t){let e=t.nodeAt(this.pos);if(!e)return ce.fail("No node at mark step's position");let r=e.type.create(e.attrs,null,this.mark.addToSet(e.marks));return ce.fromReplace(t,this.pos,this.pos+1,new st(Q.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 ge(this.pos,e.marks[r]);return new ge(this.pos,this.mark)}}return new be(this.pos,this.mark)}map(t){let e=t.mapResult(this.pos,1);return e.deletedAfter?null:new ge(e.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,e){if("number"!=typeof e.pos)throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new ge(e.pos,t.markFromJSON(e.mark))}}fe.jsonID("addNodeMark",ge);class be extends fe{constructor(t,e){super(),this.pos=t,this.mark=e}apply(t){let e=t.nodeAt(this.pos);if(!e)return ce.fail("No node at mark step's position");let r=e.type.create(e.attrs,null,this.mark.removeFromSet(e.marks));return ce.fromReplace(t,this.pos,this.pos+1,new st(Q.from(r),0,e.isLeaf?0:1))}invert(t){let e=t.nodeAt(this.pos);return e&&this.mark.isInSet(e.marks)?new ge(this.pos,this.mark):this}map(t){let e=t.mapResult(this.pos,1);return e.deletedAfter?null:new be(e.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,e){if("number"!=typeof e.pos)throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new be(e.pos,t.markFromJSON(e.mark))}}fe.jsonID("removeNodeMark",be);class we extends fe{constructor(t,e,r,i=!1){super(),this.from=t,this.to=e,this.slice=r,this.structure=i}apply(t){return this.structure&&ke(t,this.from,this.to)?ce.fail("Structure replace would overwrite content"):ce.fromReplace(t,this.from,this.to,this.slice)}getMap(){return new ue([this.from,this.to-this.from,this.slice.size])}invert(t){return new we(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);return e.deletedAcross&&r.deletedAcross?null:new we(e.pos,Math.max(e.pos,r.pos),this.slice)}merge(t){if(!(t instanceof we)||t.structure||this.structure)return null;if(this.from+this.slice.size!=t.from||this.slice.openEnd||t.slice.openStart){if(t.to!=this.from||this.slice.openStart||t.slice.openEnd)return null;{let e=this.slice.size+t.slice.size==0?st.empty:new st(t.slice.content.append(this.slice.content),t.slice.openStart,this.slice.openEnd);return new we(t.from,this.to,e,this.structure)}}{let e=this.slice.size+t.slice.size==0?st.empty:new st(this.slice.content.append(t.slice.content),this.slice.openStart,t.slice.openEnd);return new we(this.from,this.to+(t.to-t.from),e,this.structure)}}toJSON(){let t={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(t.slice=this.slice.toJSON()),this.structure&&(t.structure=!0),t}static fromJSON(t,e){if("number"!=typeof e.from||"number"!=typeof e.to)throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new we(e.from,e.to,st.fromJSON(t,e.slice),!!e.structure)}}fe.jsonID("replace",we);class ve extends fe{constructor(t,e,r,i,n,s,o=!1){super(),this.from=t,this.to=e,this.gapFrom=r,this.gapTo=i,this.slice=n,this.insert=s,this.structure=o}apply(t){if(this.structure&&(ke(t,this.from,this.gapFrom)||ke(t,this.gapTo,this.to)))return ce.fail("Structure gap-replace would overwrite content");let e=t.slice(this.gapFrom,this.gapTo);if(e.openStart||e.openEnd)return ce.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,e.content);return r?ce.fromReplace(t,this.from,this.to,r):ce.fail("Content does not fit in gap")}getMap(){return new ue([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 ve(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),i=this.from==this.gapFrom?e.pos:t.map(this.gapFrom,-1),n=this.to==this.gapTo?r.pos:t.map(this.gapTo,1);return e.deletedAcross&&r.deletedAcross||i<e.pos||n>r.pos?null:new ve(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};return this.slice.size&&(t.slice=this.slice.toJSON()),this.structure&&(t.structure=!0),t}static fromJSON(t,e){if("number"!=typeof e.from||"number"!=typeof e.to||"number"!=typeof e.gapFrom||"number"!=typeof e.gapTo||"number"!=typeof e.insert)throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new ve(e.from,e.to,e.gapFrom,e.gapTo,st.fromJSON(t,e.slice),e.insert,!!e.structure)}}function ke(t,e,r){let i=t.resolve(e),n=r-e,s=i.depth;for(;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));for(;n>0;){if(!t||t.isLeaf)return!0;t=t.firstChild,n--}}return!1}function De(t,e,r,i=r.contentMatch,n=!0){let s=t.doc.nodeAt(e),o=[],l=e+1;for(let e=0;e<s.childCount;e++){let u=s.child(e),h=l+u.nodeSize,a=i.matchType(u.type);if(a){i=a;for(let e=0;e<u.marks.length;e++)r.allowsMarkType(u.marks[e].type)||t.step(new me(l,h,u.marks[e]));if(n&&u.isText&&"pre"!=r.whitespace){let t,e,i=/\r?\n|\r/g;for(;t=i.exec(u.text);)e||(e=new st(Q.from(r.schema.text(" ",r.allowedMarks(u.marks))),0,0)),o.push(new we(l+t.index,l+t.index+t[0].length,e))}}else o.push(new we(l,h,st.empty));l=h}if(!i.validEnd){let e=i.fillBefore(Q.empty,!0);t.replace(l,l,new st(e,0,0))}for(let e=o.length-1;e>=0;e--)t.step(o[e])}function ye(t,e,r){return(0==e||t.canReplace(e,t.childCount))&&(r==t.childCount||t.canReplace(0,r))}function Ee(t){let e=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let r=t.depth;;--r){let i=t.$from.node(r),n=t.$from.index(r),s=t.$to.indexAfter(r);if(r<t.depth&&i.canReplace(n,s,e))return r;if(0==r||i.type.spec.isolating||!ye(i,n,s))break}return null}function xe(t,e,r=null,i=t){let n=function(t,e){let{parent:r,startIndex:i,endIndex:n}=t,s=r.contentMatchAt(i).findWrapping(e);return s&&r.canReplaceWith(i,n,s.length?s[0]:e)?s:null}(t,e),s=n&&function(t,e){let{parent:r,startIndex:i,endIndex:n}=t,s=r.child(i),o=e.contentMatch.findWrapping(s.type);if(!o)return null;let l=(o.length?o[o.length-1]:e).contentMatch;for(let t=i;l&&t<n;t++)l=l.matchType(r.child(t).type);return l&&l.validEnd?o:null}(i,e);return s?n.map(Fe).concat({type:e,attrs:r}).concat(s.map(Fe)):null}function Fe(t){return{type:t,attrs:null}}function Me(t,e,r,i){e.forEach(((n,s)=>{if(n.isText){let o,l=/\r?\n|\r/g;for(;o=l.exec(n.text);){let n=t.mapping.slice(i).map(r+1+s+o.index);t.replaceWith(n,n+1,e.type.schema.linebreakReplacement.create())}}}))}function Ae(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 Ce(t,e,r=1,i){let n=t.resolve(e),s=n.depth-r,o=i&&i[i.length-1]||n.parent;if(s<0||n.parent.type.spec.isolating||!n.parent.canReplace(n.index(),n.parent.childCount)||!o.type.validContent(n.parent.content.cutByIndex(n.index(),n.parent.childCount)))return!1;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!1;let o=r.content.cutByIndex(s,r.childCount),l=i&&i[e+1];l&&(o=o.replaceChild(0,l.type.create(l.attrs)));let u=i&&i[e]||r;if(!r.canReplace(s+1,r.childCount)||!u.type.validContent(o))return!1}let l=n.indexAfter(s),u=i&&i[0];return n.node(s).canReplaceWith(l,l,u?u.type:n.node(s+1).type)}function Se(t,e){let r=t.resolve(e),i=r.index();return Oe(r.nodeBefore,r.nodeAfter)&&r.parent.canReplace(i,i+1)}function Oe(t,e){return!(!t||!e||t.isLeaf||!function(t,e){e.content.size||t.type.compatibleContent(e.type);let r=t.contentMatchAt(t.childCount),{linebreakReplacement:i}=t.type.schema;for(let n=0;n<e.childCount;n++){let s=e.child(n);if(r=r.matchType(s.type==i?t.type.schema.nodes.text:s.type),!r)return!1;if(!t.type.allowsMarks(s.marks))return!1}return r.validEnd}(t,e))}function $e(t,e,r=-1){let i=t.resolve(e);for(let t=i.depth;;t--){let n,s,o=i.index(t);if(t==i.depth?(n=i.nodeBefore,s=i.nodeAfter):r>0?(n=i.node(t+1),o++,s=i.node(t).maybeChild(o)):(n=i.node(t).maybeChild(o-1),s=i.node(t+1)),n&&!n.isTextblock&&Oe(n,s)&&i.node(t).canReplace(o,o+1))return e;if(0==t)break;e=r<0?i.before(t):i.after(t)}}function Be(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<=(0==r.openStart&&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,s=i.index(e)+(r>0?1:0),o=i.node(e),l=!1;if(1==t)l=o.canReplace(s,s,n);else{let t=o.contentMatchAt(s).findWrapping(n.firstChild.type);l=t&&o.canReplaceWith(s,s,t[0])}if(l)return 0==r?i.pos:r<0?i.before(e+1):i.after(e+1)}return null}function Re(t,e,r=e,i=st.empty){if(e==r&&!i.size)return null;let n=t.resolve(e),s=t.resolve(r);return Ne(n,s,i)?new we(e,r,i):new _e(n,s,i).fit()}function Ne(t,e,r){return!r.openStart&&!r.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),r.content)}fe.jsonID("replaceAround",ve);class _e{constructor(t,e,r){this.$from=t,this.$to=e,this.unplaced=r,this.frontier=[],this.placed=Q.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=Q.from(t.node(e).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let t=this.findFittable();t?this.placeNodes(t):this.openMore()||this.dropNode()}let t=this.mustMoveInline(),e=this.placed.size-this.depth-this.$from.depth,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,o=i.depth;for(;s&&o&&1==n.childCount;)n=n.firstChild.content,s--,o--;let l=new st(n,s,o);return t>-1?new ve(r.pos,t,this.$to.pos,this.$to.end(),l,e):l.size||r.pos!=this.$to.pos?new we(r.pos,i.pos,l):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),n.type.spec.isolating&&i<=r){t=r;break}e=n.content}for(let e=1;e<=2;e++)for(let r=1==e?t:this.unplaced.openStart;r>=0;r--){let t,i=null;r?(i=je(this.unplaced.content,r-1).firstChild,t=i.content):t=this.unplaced.content;let n=t.firstChild;for(let t=this.depth;t>=0;t--){let s,{type:o,match:l}=this.frontier[t],u=null;if(1==e&&(n?l.matchType(n.type)||(u=l.fillBefore(Q.from(n),!1)):i&&o.compatibleContent(i.type)))return{sliceDepth:r,frontierDepth:t,parent:i,inject:u};if(2==e&&n&&(s=l.findWrapping(n.type)))return{sliceDepth:r,frontierDepth:t,parent:i,wrap:s};if(i&&l.matchType(i.type))break}}}openMore(){let{content:t,openStart:e,openEnd:r}=this.unplaced,i=je(t,e);return!(!i.childCount||i.firstChild.isLeaf||(this.unplaced=new st(t,e+1,Math.max(r,i.size+e>=t.size-r?e+1:0)),0))}dropNode(){let{content:t,openStart:e,openEnd:r}=this.unplaced,i=je(t,e);if(i.childCount<=1&&e>0){let n=t.size-e<=e+i.size;this.unplaced=new st(Te(t,e-1,1),e-1,n?e-1:r)}else this.unplaced=new st(Te(t,e,1),e,r)}placeNodes({sliceDepth:t,frontierDepth:e,parent:r,inject:i,wrap:n}){for(;this.depth>e;)this.closeFrontierNode();if(n)for(let t=0;t<n.length;t++)this.openFrontierNode(n[t]);let s=this.unplaced,o=r?r.content:s.content,l=s.openStart-t,u=0,h=[],{match:a,type:f}=this.frontier[e];if(i){for(let t=0;t<i.childCount;t++)h.push(i.child(t));a=a.matchFragment(i)}let c=o.size+t-(s.content.size-s.openEnd);for(;u<o.childCount;){let t=o.child(u),e=a.matchType(t.type);if(!e)break;u++,(u>1||0==l||t.content.size)&&(a=e,h.push(qe(t.mark(f.allowedMarks(t.marks)),1==u?l:0,u==o.childCount?c:-1)))}let d=u==o.childCount;d||(c=-1),this.placed=ze(this.placed,e,Q.from(h)),this.frontier[e].match=a,d&&c<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let t=0,e=o;t<c;t++){let t=e.lastChild;this.frontier.push({type:t.type,match:t.contentMatchAt(t.childCount)}),e=t.content}this.unplaced=d?0==t?st.empty:new st(Te(s.content,t-1,1),t-1,c<0?s.openEnd:t-1):new st(Te(s.content,t,u),s.openStart,s.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let t,e=this.frontier[this.depth];if(!e.type.isTextblock||!Ie(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(t=this.findCloseLevel(this.$to))&&t.depth==this.depth)return-1;let{depth:r}=this.$to,i=this.$to.after(r);for(;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],n=e<t.depth&&t.end(e+1)==t.pos+(t.depth-(e+1)),s=Ie(t,e,i,r,n);if(s){for(let r=e-1;r>=0;r--){let{match:e,type:i}=this.frontier[r],n=Ie(t,r,i,e,!0);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;for(;this.depth>e.depth;)this.closeFrontierNode();e.fit.childCount&&(this.placed=ze(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,!0,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=ze(this.placed,this.depth,Q.from(t.create(e,r))),this.frontier.push({type:t,match:t.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(Q.empty,!0);t.childCount&&(this.placed=ze(this.placed,this.frontier.length,t))}}function Te(t,e,r){return 0==e?t.cutByIndex(r,t.childCount):t.replaceChild(0,t.firstChild.copy(Te(t.firstChild.content,e-1,r)))}function ze(t,e,r){return 0==e?t.append(r):t.replaceChild(t.childCount-1,t.lastChild.copy(ze(t.lastChild.content,e-1,r)))}function je(t,e){for(let r=0;r<e;r++)t=t.firstChild.content;return t}function qe(t,e,r){if(e<=0)return t;let i=t.content;return e>1&&(i=i.replaceChild(0,qe(i.firstChild,e-1,1==i.childCount?r-1:0))),e>0&&(i=t.type.contentMatch.fillBefore(i).append(i),r<=0&&(i=i.append(t.type.contentMatch.matchFragment(i).fillBefore(Q.empty,!0)))),t.copy(i)}function Ie(t,e,r,i,n){let s=t.node(e),o=n?t.indexAfter(e):t.index(e);if(o==s.childCount&&!r.compatibleContent(s.type))return null;let l=i.fillBefore(s.content,!0,o);return l&&!function(t,e,r){for(let i=r;i<e.childCount;i++)if(!t.allowsMarks(e.child(i).marks))return!0;return!1}(r,s.content,o)?l:null}function Pe(t,e,r,i,n){if(e<r){let n=t.firstChild;t=t.replaceChild(0,n.copy(Pe(n.content,e+1,r,i,n)))}if(e>i){let e=n.contentMatchAt(0),r=e.fillBefore(t).append(t);t=r.append(e.matchFragment(r).fillBefore(Q.empty,!0))}return t}function Le(t,e){let r=[];for(let i=Math.min(t.depth,e.depth);i>=0;i--){let n=t.start(i);if(n<t.pos-(t.depth-i)||e.end(i)>e.pos+(e.depth-i)||t.node(i).type.spec.isolating||e.node(i).type.spec.isolating)break;(n==e.start(i)||i==t.depth&&i==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&i&&e.start(i-1)==n-1)&&r.push(i)}return r}class Je extends fe{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 ce.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 ce.fromReplace(t,this.pos,this.pos+1,new st(Q.from(i),0,e.isLeaf?0:1))}getMap(){return ue.empty}invert(t){return new Je(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 Je(e.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(t,e){if("number"!=typeof e.pos||"string"!=typeof e.attr)throw new RangeError("Invalid input for AttrStep.fromJSON");return new Je(e.pos,e.attr,e.value)}}fe.jsonID("attr",Je);class Ue extends fe{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 ce.ok(r)}getMap(){return ue.empty}invert(t){return new Ue(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("string"!=typeof e.attr)throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new Ue(e.attr,e.value)}}fe.jsonID("docAttr",Ue);let Ve=class extends Error{};Ve=function t(e){let r=Error.call(this,e);return r.__proto__=t.prototype,r},(Ve.prototype=Object.create(Error.prototype)).constructor=Ve,Ve.prototype.name="TransformError";class He{constructor(t){this.doc=t,this.steps=[],this.docs=[],this.mapping=new he}get before(){return this.docs.length?this.docs[0]:this.doc}step(t){let e=this.maybeStep(t);if(e.failed)throw new Ve(e.failed);return this}maybeStep(t){let e=t.apply(this.doc);return e.failed||this.addStep(t,e.doc),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=st.empty){let i=Re(this.doc,t,e,r);return i&&this.step(i),this}replaceWith(t,e,r){return this.replace(t,e,new st(Q.from(r),0,0))}delete(t,e){return this.replace(t,e,st.empty)}insert(t,e){return this.replaceWith(t,t,e)}replaceRange(t,e,r){return function(t,e,r,i){if(!i.size)return t.deleteRange(e,r);let n=t.doc.resolve(e),s=t.doc.resolve(r);if(Ne(n,s,i))return t.step(new we(e,r,i));let o=Le(n,t.doc.resolve(r));0==o[o.length-1]&&o.pop();let l=-(n.depth+1);o.unshift(l);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;o.indexOf(t)>-1?l=t:n.before(t)==e&&o.splice(1,0,-t)}let u=o.indexOf(l),h=[],a=i.openStart;for(let t=i.content,e=0;;e++){let r=t.firstChild;if(h.push(r),e==i.openStart)break;t=r.content}for(let t=a-1;t>=0;t--){let e=h[t],r=(f=e.type).spec.defining||f.spec.definingForContent;if(r&&!e.sameMarkup(n.node(Math.abs(l)-1)))a=t;else if(r||!e.type.isTextblock)break}var f;for(let e=i.openStart;e>=0;e--){let l=(e+a+1)%(i.openStart+1),f=h[l];if(f)for(let e=0;e<o.length;e++){let h=o[(e+u)%o.length],a=!0;h<0&&(a=!1,h=-h);let c=n.node(h-1),d=n.index(h-1);if(c.canReplaceWith(d,d,f.type,f.marks))return t.replace(n.before(h),a?s.after(h):r,new st(Pe(i.content,0,i.openStart,l),l,i.openEnd))}}let c=t.steps.length;for(let l=o.length-1;l>=0&&(t.replace(e,r,i),!(t.steps.length>c));l--){let t=o[l];t<0||(e=n.before(t),r=s.after(t))}}(this,t,e,r),this}replaceRangeWith(t,e,r){return function(t,e,r,i){if(!i.isInline&&e==r&&t.doc.resolve(e).parent.content.size){let n=function(t,e,r){let i=t.resolve(e);if(i.parent.canReplaceWith(i.index(),i.index(),r))return e;if(0==i.parentOffset)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}(t.doc,e,i.type);null!=n&&(e=r=n)}t.replaceRange(e,r,new st(Q.from(i),0,0))}(this,t,e,r),this}deleteRange(t,e){return function(t,e,r){let i=t.doc.resolve(e),n=t.doc.resolve(r),s=Le(i,n);for(let e=0;e<s.length;e++){let r=s[e],o=e==s.length-1;if(o&&0==r||i.node(r).type.contentMatch.validEnd)return t.delete(i.start(r),n.end(r));if(r>0&&(o||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)}(this,t,e),this}lift(t,e){return function(t,e,r){let{$from:i,$to:n,depth:s}=e,o=i.before(s+1),l=n.after(s+1),u=o,h=l,a=Q.empty,f=0;for(let t=s,e=!1;t>r;t--)e||i.index(t)>0?(e=!0,a=Q.from(i.node(t).copy(a)),f++):u--;let c=Q.empty,d=0;for(let t=s,e=!1;t>r;t--)e||n.after(t+1)<n.end(t)?(e=!0,c=Q.from(n.node(t).copy(c)),d++):h++;t.step(new ve(u,h,o,l,new st(a.append(c),f,d),a.size-f,!0))}(this,t,e),this}join(t,e=1){return function(t,e,r){let i=null,{linebreakReplacement:n}=t.doc.type.schema,s=t.doc.resolve(e-r),o=s.node().type;if(n&&o.inlineContent){let t="pre"==o.whitespace,e=!!o.contentMatch.matchType(n);t&&!e?i=!1:!t&&e&&(i=!0)}let l=t.steps.length;if(!1===i){let i=t.doc.resolve(e+r);Ae(t,i.node(),i.before(),l)}o.inlineContent&&De(t,e+r-1,o,s.node().contentMatchAt(s.index()),null==i);let u=t.mapping.slice(l),h=u.map(e-r);if(t.step(new we(h,u.map(e+r,-1),st.empty,!0)),!0===i){let e=t.doc.resolve(h);Me(t,e.node(),e.before(),t.steps.length)}}(this,t,e),this}wrap(t,e){return function(t,e,r){let i=Q.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=Q.from(r[t].type.create(r[t].attrs,i))}let n=e.start,s=e.end;t.step(new ve(n,s,n,s,new st(i,0,0),r.length,!0))}(this,t,e),this}setBlockType(t,e=t,r,i=null){return function(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 o="function"==typeof n?n(e):n;if(e.isTextblock&&!e.hasMarkup(i,o)&&function(t,e,r){let i=t.resolve(e),n=i.index();return i.parent.canReplaceWith(n,n+1,r)}(t.doc,t.mapping.slice(s).map(r),i)){let n=null;if(i.schema.linebreakReplacement){let t="pre"==i.whitespace,e=!!i.contentMatch.matchType(i.schema.linebreakReplacement);t&&!e?n=!1:!t&&e&&(n=!0)}!1===n&&Ae(t,e,r,s),De(t,t.mapping.slice(s).map(r,1),i,void 0,null===n);let l=t.mapping.slice(s),u=l.map(r,1),h=l.map(r+e.nodeSize,1);return t.step(new ve(u,h,u+1,h-1,new st(Q.from(i.create(o,null,e.marks)),0,0),1,!0)),!0===n&&Me(t,e,r,s),!1}}))}(this,t,e,r,i),this}setNodeMarkup(t,e,r=null,i){return function(t,e,r,i,n){let s=t.doc.nodeAt(e);if(!s)throw new RangeError("No node at given position");r||(r=s.type);let o=r.create(i,null,n||s.marks);if(s.isLeaf)return t.replaceWith(e,e+s.nodeSize,o);if(!r.validContent(s.content))throw new RangeError("Invalid content for node type "+r.name);t.step(new ve(e,e+s.nodeSize,e+1,e+s.nodeSize-1,new st(Q.from(o),0,0),1,!0))}(this,t,e,r,i),this}setNodeAttribute(t,e,r){return this.step(new Je(t,e,r)),this}setDocAttribute(t,e){return this.step(new Ue(t,e)),this}addNodeMark(t,e){return this.step(new ge(t,e)),this}removeNodeMark(t,e){if(!(e instanceof it)){let r=this.doc.nodeAt(t);if(!r)throw new RangeError("No node at position "+t);if(!(e=e.isInSet(r.marks)))return this}return this.step(new be(t,e)),this}split(t,e=1,r){return function(t,e,r=1,i){let n=t.doc.resolve(e),s=Q.empty,o=Q.empty;for(let t=n.depth,e=n.depth-r,l=r-1;t>e;t--,l--){s=Q.from(n.node(t).copy(s));let e=i&&i[l];o=Q.from(e?e.type.create(e.attrs,o):n.node(t).copy(o))}t.step(new we(e,e,new st(s.append(o),r,r),!0))}(this,t,e,r),this}addMark(t,e,r){return function(t,e,r,i){let n,s,o=[],l=[];t.doc.nodesBetween(e,r,((t,u,h)=>{if(!t.isInline)return;let a=t.marks;if(!i.isInSet(a)&&h.type.allowsMarkType(i.type)){let h=Math.max(u,e),f=Math.min(u+t.nodeSize,r),c=i.addToSet(a);for(let t=0;t<a.length;t++)a[t].isInSet(c)||(n&&n.to==h&&n.mark.eq(a[t])?n.to=f:o.push(n=new me(h,f,a[t])));s&&s.to==h?s.to=f:l.push(s=new pe(h,f,i))}})),o.forEach((e=>t.step(e))),l.forEach((e=>t.step(e)))}(this,t,e,r),this}removeMark(t,e,r){return function(t,e,r,i){let n=[],s=0;t.doc.nodesBetween(e,r,((t,o)=>{if(!t.isInline)return;s++;let l=null;if(i instanceof Pt){let e,r=t.marks;for(;e=i.isInSet(r);)(l||(l=[])).push(e),r=e.removeFromSet(r)}else i?i.isInSet(t.marks)&&(l=[i]):l=t.marks;if(l&&l.length){let i=Math.min(o+t.nodeSize,r);for(let t=0;t<l.length;t++){let r,u=l[t];for(let t=0;t<n.length;t++){let e=n[t];e.step==s-1&&u.eq(n[t].style)&&(r=e)}r?(r.to=i,r.step=s):n.push({style:u,from:Math.max(o,e),to:i,step:s})}}})),n.forEach((e=>t.step(new me(e.from,e.to,e.style))))}(this,t,e,r),this}clearIncompatible(t,e,r){return De(this,t,e,r),this}}const We=Object.create(null);class Ge{constructor(t,e,r){this.$anchor=t,this.$head=e,this.ranges=r||[new Ze(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!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(t,e=st.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 o=0;o<s.length;o++){let{$from:l,$to:u}=s[o],h=t.mapping.slice(n);t.replaceRange(h.map(l.pos),h.map(u.pos),o?st.empty:e),0==o&&sr(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:o}=i[n],l=t.mapping.slice(r),u=l.map(s.pos),h=l.map(o.pos);n?t.deleteRange(u,h):(t.replaceRangeWith(u,h,e),sr(t,r,e.isInline?-1:1))}}static findFrom(t,e,r=!1){let i=t.parent.inlineContent?new Xe(t):nr(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?nr(t.node(0),t.node(i),t.before(i+1),t.index(i),e,r):nr(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 rr(t.node(0))}static atStart(t){return nr(t,t,0,0,1)||new rr(t)}static atEnd(t){return nr(t,t,t.content.size,t.childCount,-1)||new rr(t)}static fromJSON(t,e){if(!e||!e.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=We[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 We)throw new RangeError("Duplicate use of selection JSON ID "+t);return We[t]=e,e.prototype.jsonID=t,e}getBookmark(){return Xe.between(this.$anchor,this.$head).getBookmark()}}Ge.prototype.visible=!0;class Ze{constructor(t,e){this.$from=t,this.$to=e}}let Ke=!1;function Ye(t){Ke||t.parent.inlineContent||(Ke=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class Xe extends Ge{constructor(t,e=t){Ye(t),Ye(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 Ge.near(r);let i=t.resolve(e.map(this.anchor));return new Xe(i.parent.inlineContent?i:r,r)}replace(t,e=st.empty){if(super.replace(t,e),e==st.empty){let e=this.$from.marksAcross(this.$to);e&&t.ensureMarks(e)}}eq(t){return t instanceof Xe&&t.anchor==this.anchor&&t.head==this.head}getBookmark(){return new Qe(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(t,e){if("number"!=typeof e.anchor||"number"!=typeof e.head)throw new RangeError("Invalid input for TextSelection.fromJSON");return new Xe(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),!e.parent.inlineContent){let t=Ge.findFrom(e,r,!0)||Ge.findFrom(e,-r,!0);if(!t)return Ge.near(e,r);e=t.$head}return t.parent.inlineContent||(0==i||(t=(Ge.findFrom(t,-r,!0)||Ge.findFrom(t,r,!0)).$anchor).pos<e.pos!=i<0)&&(t=e),new Xe(t,e)}}Ge.jsonID("text",Xe);class Qe{constructor(t,e){this.anchor=t,this.head=e}map(t){return new Qe(t.map(this.anchor),t.map(this.head))}resolve(t){return Xe.between(t.resolve(this.anchor),t.resolve(this.head))}}class tr extends Ge{constructor(t){let e=t.nodeAfter,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),n=t.resolve(i);return r?Ge.near(n):new tr(n)}content(){return new st(Q.from(this.node),0,0)}eq(t){return t instanceof tr&&t.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new er(this.anchor)}static fromJSON(t,e){if("number"!=typeof e.anchor)throw new RangeError("Invalid input for NodeSelection.fromJSON");return new tr(t.resolve(e.anchor))}static create(t,e){return new tr(t.resolve(e))}static isSelectable(t){return!t.isText&&!1!==t.type.spec.selectable}}tr.prototype.visible=!1,Ge.jsonID("node",tr);class er{constructor(t){this.anchor=t}map(t){let{deleted:e,pos:r}=t.mapResult(this.anchor);return e?new Qe(r,r):new er(r)}resolve(t){let e=t.resolve(this.anchor),r=e.nodeAfter;return r&&tr.isSelectable(r)?new tr(e):Ge.near(e)}}class rr extends Ge{constructor(t){super(t.resolve(0),t.resolve(t.content.size))}replace(t,e=st.empty){if(e==st.empty){t.delete(0,t.doc.content.size);let e=Ge.atStart(t.doc);e.eq(t.selection)||t.setSelection(e)}else super.replace(t,e)}toJSON(){return{type:"all"}}static fromJSON(t){return new rr(t)}map(t){return new rr(t)}eq(t){return t instanceof rr}getBookmark(){return ir}}Ge.jsonID("all",rr);const ir={map(){return this},resolve:t=>new rr(t)};function nr(t,e,r,i,n,s=!1){if(e.inlineContent)return Xe.create(t,r);for(let o=i-(n>0?0:1);n>0?o<e.childCount:o>=0;o+=n){let i=e.child(o);if(i.isAtom){if(!s&&tr.isSelectable(i))return tr.create(t,r-(n<0?i.nodeSize:0))}else{let e=nr(t,i,r+n,n<0?i.childCount:0,n,s);if(e)return e}r+=i.nodeSize*n}return null}function sr(t,e,r){let i=t.steps.length-1;if(i<e)return;let n,s=t.steps[i];(s instanceof we||s instanceof ve)&&(t.mapping.maps[i].forEach(((t,e,r,i)=>{null==n&&(n=i)})),t.setSelection(Ge.near(t.doc.resolve(n),r)))}class or extends He{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(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(t){if(t.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=t,this.curSelectionFor=this.steps.length,this.updated=-3&this.updated|1,this.storedMarks=null,this}get selectionSet(){return(1&this.updated)>0}setStoredMarks(t){return this.storedMarks=t,this.updated|=2,this}ensureMarks(t){return it.sameSet(this.storedMarks||this.selection.$from.marks(),t)||this.setStoredMarks(t),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(2&this.updated)>0}addStep(t,e){super.addStep(t,e),this.updated=-3&this.updated,this.storedMarks=null}setTime(t){return this.time=t,this}replaceSelection(t){return this.selection.replace(this,t),this}replaceSelectionWith(t,e=!0){let r=this.selection;return e&&(t=t.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||it.none))),r.replaceWith(this,t),this}deleteSelection(){return this.selection.replace(this),this}insertText(t,e,r){let i=this.doc.type.schema;if(null==e)return t?this.replaceSelectionWith(i.text(t),!0):this.deleteSelection();{if(null==r&&(r=e),r=null==r?e:r,!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))}return this.replaceRangeWith(e,r,i.text(t,n)),this.selection.empty||this.setSelection(Ge.near(this.selection.$to)),this}}setMeta(t,e){return this.meta["string"==typeof t?t:t.key]=e,this}getMeta(t){return this.meta["string"==typeof t?t:t.key]}get isGeneric(){for(let t in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=4,this}get scrolledIntoView(){return(4&this.updated)>0}}function lr(t,e){return e&&t?t.bind(e):t}class ur{constructor(t,e,r){this.name=t,this.init=lr(e.init,r),this.apply=lr(e.apply,r)}}const hr=[new ur("doc",{init:t=>t.doc||t.schema.topNodeType.createAndFill(),apply:t=>t.doc}),new ur("selection",{init:(t,e)=>t.selection||Ge.atStart(e.doc),apply:t=>t.selection}),new ur("storedMarks",{init:t=>t.storedMarks||null,apply:(t,e,r,i)=>i.selection.$cursor?t.storedMarks:null}),new ur("scrollToSelection",{init:()=>0,apply:(t,e)=>t.scrolledIntoView?e+1:e})];class ar{constructor(t,e){this.schema=t,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=hr.slice(),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,t.spec.state&&this.fields.push(new ur(t.key,t.spec.state,t))}))}}class fr{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!1}return!0}applyTransaction(t){if(!this.filterTransaction(t))return{state:this,transactions:[]};let e=[t],r=this.applyInner(t),i=null;for(;;){let n=!1;for(let s=0;s<this.config.plugins.length;s++){let o=this.config.plugins[s];if(o.spec.appendTransaction){let l=i?i[s].n:0,u=i?i[s].state:this,h=l<e.length&&o.spec.appendTransaction.call(o,l?e.slice(l):e,u,r);if(h&&r.filterTransaction(h,s)){if(h.setMeta("appendedTransaction",t),!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(h),r=r.applyInner(h),n=!0}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 fr(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 or(this)}static create(t){let e=new ar(t.doc?t.doc.type.schema:t.schema,t.plugins),r=new fr(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 ar(this.schema,t.plugins),r=e.fields,i=new fr(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()))),t&&"object"==typeof t)for(let r in t){if("doc"==r||"selection"==r)throw new RangeError("The JSON fields `doc` and `selection` are reserved");let i=t[r],n=i.spec.state;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 ar(t.schema,t.plugins),n=new fr(i);return i.fields.forEach((i=>{if("doc"==i.name)n.doc=Et.fromJSON(t.schema,e.doc);else if("selection"==i.name)n.selection=Ge.fromJSON(n.doc,e.selection);else if("storedMarks"==i.name)e.storedMarks&&(n.storedMarks=e.storedMarks.map(t.schema.markFromJSON));else{if(r)for(let s in r){let o=r[s],l=o.spec.state;if(o.key==i.name&&l&&l.fromJSON&&Object.prototype.hasOwnProperty.call(e,s))return void(n[i.name]=l.fromJSON.call(o,t,e[s],n))}n[i.name]=i.init(t,n)}})),n}}function cr(t,e,r){for(let i in t){let n=t[i];n instanceof Function?n=n.bind(e):"handleDOMEvents"==i&&(n=cr(n,e,{})),r[i]=n}return r}class dr{constructor(t){this.spec=t,this.props={},t.props&&cr(t.props,this,this.props),this.key=t.key?t.key.key:mr("plugin")}getState(t){return t[this.key]}}const pr=Object.create(null);function mr(t){return t in pr?t+"$"+ ++pr[t]:(pr[t]=0,t+"$")}class gr{constructor(t="key"){this.key=mr(t)}get(t){return t.config.pluginsByKey[this.key]}getState(t){return t[this.key]}}const br=function(t){for(var e=0;;e++)if(!(t=t.previousSibling))return e},wr=function(t){let e=t.assignedSlot||t.parentNode;return e&&11==e.nodeType?e.host:e};let vr=null;const kr=function(t,e,r){let i=vr||(vr=document.createRange());return i.setEnd(t,null==r?t.nodeValue.length:r),i.setStart(t,e||0),i},Dr=function(t,e,r,i){return r&&(Er(t,e,r,i,-1)||Er(t,e,r,i,1))},yr=/^(img|br|input|textarea|hr)$/i;function Er(t,e,r,i,n){for(;;){if(t==r&&e==i)return!0;if(e==(n<0?0:xr(t))){let r=t.parentNode;if(!r||1!=r.nodeType||Fr(t)||yr.test(t.nodeName)||"false"==t.contentEditable)return!1;e=br(t)+(n<0?0:1),t=r}else{if(1!=t.nodeType)return!1;if("false"==(t=t.childNodes[e+(n<0?-1:0)]).contentEditable)return!1;e=n<0?xr(t):0}}}function xr(t){return 3==t.nodeType?t.nodeValue.length:t.childNodes.length}function Fr(t){let e;for(let r=t;r&&!(e=r.pmViewDesc);r=r.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==t||e.contentDOM==t)}const Mr=function(t){return t.focusNode&&Dr(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function Ar(t,e){let r=document.createEvent("Event");return r.initEvent("keydown",!0,!0),r.keyCode=t,r.key=r.code=e,r}const Cr="undefined"!=typeof navigator?navigator:null,Sr="undefined"!=typeof document?document:null,Or=Cr&&Cr.userAgent||"",$r=/Edge\/(\d+)/.exec(Or),Br=/MSIE \d/.exec(Or),Rr=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Or),Nr=!!(Br||Rr||$r),_r=Br?document.documentMode:Rr?+Rr[1]:$r?+$r[1]:0,Tr=!Nr&&/gecko\/(\d+)/i.test(Or),zr=!Nr&&/Chrome\/(\d+)/.exec(Or),jr=!!zr,qr=zr?+zr[1]:0,Ir=!Nr&&!!Cr&&/Apple Computer/.test(Cr.vendor),Pr=Ir&&(/Mobile\/\w+/.test(Or)||!!Cr&&Cr.maxTouchPoints>2),Lr=Pr||!!Cr&&/Mac/.test(Cr.platform),Jr=!!Cr&&/Win/.test(Cr.platform),Ur=/Android \d/.test(Or),Vr=!!Sr&&"webkitFontSmoothing"in Sr.documentElement.style,Hr=Vr?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Wr(t){let e=t.defaultView&&t.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.documentElement.clientWidth,top:0,bottom:t.documentElement.clientHeight}}function Gr(t,e){return"number"==typeof t?t:t[e]}function Zr(t){let e=t.getBoundingClientRect();return{left:e.left,right:e.left+t.clientWidth*(e.width/t.offsetWidth||1),top:e.top,bottom:e.top+t.clientHeight*(e.height/t.offsetHeight||1)}}function Kr(t,e,r){let i=t.someProp("scrollThreshold")||0,n=t.someProp("scrollMargin")||5,s=t.dom.ownerDocument;for(let o=r||t.dom;o;o=wr(o)){if(1!=o.nodeType)continue;let t=o,r=t==s.body,l=r?Wr(s):Zr(t),u=0,h=0;if(e.top<l.top+Gr(i,"top")?h=-(l.top-e.top+Gr(n,"top")):e.bottom>l.bottom-Gr(i,"bottom")&&(h=e.bottom-e.top>l.bottom-l.top?e.top+Gr(n,"top")-l.top:e.bottom-l.bottom+Gr(n,"bottom")),e.left<l.left+Gr(i,"left")?u=-(l.left-e.left+Gr(n,"left")):e.right>l.right-Gr(i,"right")&&(u=e.right-l.right+Gr(n,"right")),u||h)if(r)s.defaultView.scrollBy(u,h);else{let r=t.scrollLeft,i=t.scrollTop;h&&(t.scrollTop+=h),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(o).position))break}}function Yr(t){let e=[],r=t.ownerDocument;for(let i=t;i&&(e.push({dom:i,top:i.scrollTop,left:i.scrollLeft}),t!=r);i=wr(i));return e}function Xr(t,e){for(let r=0;r<t.length;r++){let{dom:i,top:n,left:s}=t[r];i.scrollTop!=n+e&&(i.scrollTop=n+e),i.scrollLeft!=s&&(i.scrollLeft=s)}}let Qr=null;function ti(t,e){let r,i,n,s,o=2e8,l=0,u=e.top,h=e.top;for(let a=t.firstChild,f=0;a;a=a.nextSibling,f++){let t;if(1==a.nodeType)t=a.getClientRects();else{if(3!=a.nodeType)continue;t=kr(a).getClientRects()}for(let c=0;c<t.length;c++){let d=t[c];if(d.top<=u&&d.bottom>=h){u=Math.max(d.bottom,u),h=Math.min(d.top,h);let t=d.left>e.left?d.left-e.left:d.right<e.left?e.left-d.right:0;if(t<o){r=a,o=t,i=t&&3==r.nodeType?{left:d.right<e.left?d.right:d.left,top:e.top}:e,1==a.nodeType&&t&&(l=f+(e.left>=(d.left+d.right)/2?1:0));continue}}else d.top>e.top&&!n&&d.left<=e.left&&d.right>=e.left&&(n=a,s={left:Math.max(d.left,Math.min(d.right,e.left)),top:d.top});!r&&(e.left>=d.right&&e.top>=d.top||e.left>=d.left&&e.top>=d.bottom)&&(l=f+1)}}return!r&&n&&(r=n,i=s,o=0),r&&3==r.nodeType?function(t,e){let r=t.nodeValue.length,i=document.createRange();for(let n=0;n<r;n++){i.setEnd(t,n+1),i.setStart(t,n);let r=si(i,1);if(r.top!=r.bottom&&ei(e,r))return{node:t,offset:n+(e.left>=(r.left+r.right)/2?1:0)}}return{node:t,offset:0}}(r,i):!r||o&&1==r.nodeType?{node:t,offset:l}:ti(r,i)}function ei(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function ri(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(1==r.nodeType){let t=r.getClientRects();for(let i=0;i<t.length;i++){let n=t[i];if(ei(e,n))return ri(r,e,n)}}if((s=(s+1)%i)==n)break}return t}function ii(t,e){let r,i=t.dom.ownerDocument,n=0,s=function(t,e,r){if(t.caretPositionFromPoint)try{let i=t.caretPositionFromPoint(e,r);if(i)return{node:i.offsetNode,offset:Math.min(xr(i.offsetNode),i.offset)}}catch(t){}if(t.caretRangeFromPoint){let i=t.caretRangeFromPoint(e,r);if(i)return{node:i.startContainer,offset:Math.min(xr(i.startContainer),i.startOffset)}}}(i,e.left,e.top);s&&({node:r,offset:n}=s);let o,l=(t.root.elementFromPoint?t.root:i).elementFromPoint(e.left,e.top);if(!l||!t.dom.contains(1!=l.nodeType?l.parentNode:l)){let r=t.dom.getBoundingClientRect();if(!ei(e,r))return null;if(l=ri(t.dom,e,r),!l)return null}if(Ir)for(let t=l;r&&t;t=wr(t))t.draggable&&(r=void 0);if(l=function(t,e){let r=t.parentNode;return r&&/^li$/i.test(r.nodeName)&&e.left<t.getBoundingClientRect().left?r:t}(l,e),r){if(Tr&&1==r.nodeType&&(n=Math.min(n,r.childNodes.length),n<r.childNodes.length)){let t,i=r.childNodes[n];"IMG"==i.nodeName&&(t=i.getBoundingClientRect()).right<=e.left&&t.bottom>e.top&&n++}let i;Vr&&n&&1==r.nodeType&&1==(i=r.childNodes[n-1]).nodeType&&"false"==i.contentEditable&&i.getBoundingClientRect().top>=e.top&&n--,r==t.dom&&n==r.childNodes.length-1&&1==r.lastChild.nodeType&&e.top>r.lastChild.getBoundingClientRect().bottom?o=t.state.doc.content.size:0!=n&&1==r.nodeType&&"BR"==r.childNodes[n-1].nodeName||(o=function(t,e,r,i){let n=-1;for(let r=e,s=!1;r!=t.dom;){let e,o=t.docView.nearestDesc(r,!0);if(!o)return null;if(1==o.dom.nodeType&&(o.node.isBlock&&o.parent||!o.contentDOM)&&((e=o.dom.getBoundingClientRect()).width||e.height)&&(o.node.isBlock&&o.parent&&(!s&&e.left>i.left||e.top>i.top?n=o.posBefore:(!s&&e.right<i.left||e.bottom<i.top)&&(n=o.posAfter),s=!0),!o.contentDOM&&n<0&&!o.node.isText))return(o.node.isBlock?i.top<(e.top+e.bottom)/2:i.left<(e.left+e.right)/2)?o.posBefore:o.posAfter;r=o.dom.parentNode}return n>-1?n:t.docView.posFromDOM(e,r,-1)}(t,r,n,e))}null==o&&(o=function(t,e,r){let{node:i,offset:n}=ti(e,r),s=-1;if(1==i.nodeType&&!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)}(t,l,e));let u=t.docView.nearestDesc(l,!0);return{pos:o,inside:u?u.posAtStart-u.border:-1}}function ni(t){return t.top<t.bottom||t.left<t.right}function si(t,e){let r=t.getClientRects();if(r.length){let t=r[e<0?0:r.length-1];if(ni(t))return t}return Array.prototype.find.call(r,ni)||t.getBoundingClientRect()}const oi=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function li(t,e,r){let{node:i,offset:n,atom:s}=t.docView.domFromPos(e,r<0?-1:1),o=Vr||Tr;if(3==i.nodeType){if(!o||!oi.test(i.nodeValue)&&(r<0?n:n!=i.nodeValue.length)){let t=n,e=n,s=r<0?1:-1;return r<0&&!n?(e++,s=-1):r>=0&&n==i.nodeValue.length?(t--,s=1):r<0?t--:e++,ui(si(kr(i,t,e),s),s<0)}{let t=si(kr(i,n,n),r);if(Tr&&n&&/\s/.test(i.nodeValue[n-1])&&n<i.nodeValue.length){let e=si(kr(i,n-1,n-1),-1);if(e.top==t.top){let r=si(kr(i,n,n+1),-1);if(r.top!=t.top)return ui(r,r.left<e.left)}}return t}}if(!t.state.doc.resolve(e-(s||0)).parent.inlineContent){if(null==s&&n&&(r<0||n==xr(i))){let t=i.childNodes[n-1];if(1==t.nodeType)return hi(t.getBoundingClientRect(),!1)}if(null==s&&n<xr(i)){let t=i.childNodes[n];if(1==t.nodeType)return hi(t.getBoundingClientRect(),!0)}return hi(i.getBoundingClientRect(),r>=0)}if(null==s&&n&&(r<0||n==xr(i))){let t=i.childNodes[n-1],e=3==t.nodeType?kr(t,xr(t)-(o?0:1)):1!=t.nodeType||"BR"==t.nodeName&&t.nextSibling?null:t;if(e)return ui(si(e,1),!1)}if(null==s&&n<xr(i)){let t=i.childNodes[n];for(;t.pmViewDesc&&t.pmViewDesc.ignoreForCoords;)t=t.nextSibling;let e=t?3==t.nodeType?kr(t,0,o?0:1):1==t.nodeType?t:null:null;if(e)return ui(si(e,-1),!0)}return ui(si(3==i.nodeType?kr(i):i,-r),r>=0)}function ui(t,e){if(0==t.width)return t;let r=e?t.left:t.right;return{top:t.top,bottom:t.bottom,left:r,right:r}}function hi(t,e){if(0==t.height)return t;let r=e?t.top:t.bottom;return{top:r,bottom:r,left:t.left,right:t.right}}function ai(t,e,r){let i=t.state,n=t.root.activeElement;i!=e&&t.updateState(e),n!=t.dom&&t.focus();try{return r()}finally{i!=e&&t.updateState(i),n!=t.dom&&n&&n.focus()}}const fi=/[\u0590-\u08ac]/;let ci=null,di=null,pi=!1;class mi{constructor(t,e,r,i){this.parent=t,this.children=e,this.dom=r,this.contentDOM=i,this.dirty=0,r.pmViewDesc=this}matchesWidget(t){return!1}matchesMark(t){return!1}matchesNode(t,e,r){return!1}matchesHack(t){return!1}parseRule(){return null}stopEvent(t){return!1}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=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);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(1==t.nodeType?t:t.parentNode)){if(r<0){let r,i;if(t==this.contentDOM)r=t.childNodes[e-1];else{for(;t.parentNode!=this.contentDOM;)t=t.parentNode;r=t.previousSibling}for(;r&&(!(i=r.pmViewDesc)||i.parent!=this);)r=r.previousSibling;return r?this.posBeforeChild(i)+i.size:this.posAtStart}{let r,i;if(t==this.contentDOM)r=t.childNodes[e];else{for(;t.parentNode!=this.contentDOM;)t=t.parentNode;r=t.nextSibling}for(;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>br(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))i=2&t.compareDocumentPosition(this.contentDOM);else if(this.dom.firstChild){if(0==e)for(let e=t;;e=e.parentNode){if(e==this.dom){i=!1;break}if(e.previousSibling)break}if(null==i&&e==t.childNodes.length)for(let e=t;;e=e.parentNode){if(e==this.dom){i=!0;break}if(e.nextSibling)break}}return(null==i?r>0:i)?this.posAtEnd:this.posAtStart}nearestDesc(t,e=!1){for(let r=!0,i=t;i;i=i.parentNode){let n,s=this.getDesc(i);if(s&&(!e||s.node)){if(!r||!(n=s.nodeDOM)||(1==n.nodeType?n.contains(1==t.nodeType?t:t.parentNode):n==t))return s;r=!1}}}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){for(;!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 yi){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 gi&&t.side>=0;r--);if(e<=0){let t,i=!0;for(;t=r?this.children[r-1]:null,t&&t.dom.parentNode!=this.contentDOM;r--,i=!1);return t&&e&&i&&!t.border&&!t.domAtom?t.domFromPos(t.size,e):{node:this.contentDOM,offset:t?br(t.dom)+1:0}}{let t,i=!0;for(;t=r<this.children.length?this.children[r]:null,t&&t.dom.parentNode!=this.contentDOM;r++,i=!1);return t&&i&&!t.border&&!t.domAtom?t.domFromPos(0,e):{node:this.contentDOM,offset:t?br(t.dom):this.contentDOM.childNodes.length}}}parseRange(t,e,r=0){if(0==this.children.length)return{node:this.contentDOM,from:t,to:e,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let i=-1,n=-1;for(let s=r,o=0;;o++){let r=this.children[o],l=s+r.size;if(-1==i&&t<=l){let n=s+r.border;if(t>=n&&e<=l-r.border&&r.node&&r.contentDOM&&this.contentDOM.contains(r.contentDOM))return r.parseRange(t,e,n);t=s;for(let e=o;e>0;e--){let r=this.children[e-1];if(r.size&&r.dom.parentNode==this.contentDOM&&!r.emptyChildAt(1)){i=br(r.dom)+1;break}t-=r.size}-1==i&&(i=0)}if(i>-1&&(l>e||o==this.children.length-1)){e=l;for(let t=o+1;t<this.children.length;t++){let r=this.children[t];if(r.size&&r.dom.parentNode==this.contentDOM&&!r.emptyChildAt(-1)){n=br(r.dom);break}e+=r.size}-1==n&&(n=this.contentDOM.childNodes.length);break}s=l}return{node:this.contentDOM,from:t,to:e,fromOffset:i,toOffset:n}}emptyChildAt(t){if(this.border||!this.contentDOM||!this.children.length)return!1;let e=this.children[t<0?0:this.children.length-1];return 0==e.size||e.emptyChildAt(t)}domAfterPos(t){let{node:e,offset:r}=this.domFromPos(t,0);if(1!=e.nodeType||r==e.childNodes.length)throw new RangeError("No node after pos "+t);return e.childNodes[r]}setSelection(t,e,r,i=!1){let n=Math.min(t,e),s=Math.max(t,e);for(let o=0,l=0;o<this.children.length;o++){let u=this.children[o],h=l+u.size;if(n>l&&s<h)return u.setSelection(t-l-u.border,e-l-u.border,r,i);l=h}let o=this.domFromPos(t,t?-1:1),l=e==t?o:this.domFromPos(e,e?-1:1),u=r.root.getSelection(),h=r.domSelectionRange(),a=!1;if((Tr||Ir)&&t==e){let{node:t,offset:e}=o;if(3==t.nodeType){if(a=!(!e||"\n"!=t.nodeValue[e-1]),a&&e==t.nodeValue.length)for(let e,r=t;r;r=r.parentNode){if(e=r.nextSibling){"BR"==e.nodeName&&(o=l={node:e.parentNode,offset:br(e)+1});break}let t=r.pmViewDesc;if(t&&t.node&&t.node.isBlock)break}}else{let r=t.childNodes[e-1];a=r&&("BR"==r.nodeName||"false"==r.contentEditable)}}if(Tr&&h.focusNode&&h.focusNode!=l.node&&1==h.focusNode.nodeType){let t=h.focusNode.childNodes[h.focusOffset];t&&"false"==t.contentEditable&&(i=!0)}if(!(i||a&&Ir)&&Dr(o.node,o.offset,h.anchorNode,h.anchorOffset)&&Dr(l.node,l.offset,h.focusNode,h.focusOffset))return;let f=!1;if((u.extend||t==e)&&!a){u.collapse(o.node,o.offset);try{t!=e&&u.extend(l.node,l.offset),f=!0}catch(t){}}if(!f){if(t>e){let t=o;o=l,l=t}let r=document.createRange();r.setEnd(l.node,l.offset),r.setStart(o.node,o.offset),u.removeAllRanges(),u.addRange(r)}}ignoreMutation(t){return!this.contentDOM&&"selection"!=t.type}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,o=s-n.border;if(t>=i&&e<=o)return this.dirty=t==r||e==s?2:1,void(t!=i||e!=o||!n.contentLost&&n.dom.parentNode==this.contentDOM?n.markDirty(t-i,e-i):n.dirty=3);n.dirty=n.dom!=n.contentDOM||n.dom.parentNode!=this.contentDOM||n.children.length?3:2}r=s}this.dirty=2}markParentsDirty(){let t=1;for(let e=this.parent;e;e=e.parent,t++){let r=1==t?2:1;e.dirty<r&&(e.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}isText(t){return!1}}class gi extends mi{constructor(t,e,r,i){let n,s=e.type.toDOM;if("function"==typeof s&&(s=s(r,(()=>n?n.parent?n.parent.posBeforeChild(n):void 0:i))),!e.type.spec.raw){if(1!=s.nodeType){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 0==this.dirty&&t.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(t){let e=this.widget.spec.stopEvent;return!!e&&e(t)}ignoreMutation(t){return"selection"!=t.type||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get side(){return this.widget.type.side}}class bi extends mi{constructor(t,e,r,i){super(t,[],e,null),this.textDOM=r,this.text=i}get size(){return this.text.length}localPosFromDOM(t,e){return t!=this.textDOM?this.posAtStart+(e?this.size:0):this.posAtStart+e}domFromPos(t){return{node:this.textDOM,offset:t}}ignoreMutation(t){return"characterData"===t.type&&t.target.nodeValue==t.oldValue}}class wi extends mi{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],s=n&&n(e,i,r);return s&&s.dom||(s=te.renderSpec(document,e.type.spec.toDOM(e,r),null,e.attrs)),new wi(t,e,s.dom,s.contentDOM||s.dom,s)}parseRule(){return 3&this.dirty||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(t){return 3!=this.dirty&&this.mark.eq(t)}markDirty(t,e){if(super.markDirty(t,e),0!=this.dirty){let t=this.parent;for(;!t.node;)t=t.parent;t.dirty<this.dirty&&(t.dirty=this.dirty),this.dirty=0}}slice(t,e,r){let i=wi.create(this.parent,this.mark,!0,r),n=this.children,s=this.size;e<s&&(n=_i(n,e,s,r)),t>0&&(n=_i(n,0,t,r));for(let t=0;t<n.length;t++)n[t].parent=i;return i.children=n,i}ignoreMutation(t){return this.spec.ignoreMutation?this.spec.ignoreMutation(t):super.ignoreMutation(t)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class vi extends mi{constructor(t,e,r,i,n,s,o,l,u){super(t,[],n,s),this.node=e,this.outerDeco=r,this.innerDeco=i,this.nodeDOM=o}static create(t,e,r,i,n,s){let o,l=n.nodeViews[e.type.name],u=l&&l(e,n,(()=>o?o.parent?o.parent.posBeforeChild(o):void 0:s),r,i),h=u&&u.dom,a=u&&u.contentDOM;if(e.isText)if(h){if(3!=h.nodeType)throw new RangeError("Text must be rendered as a DOM text node")}else h=document.createTextNode(e.text);else if(!h){let t=te.renderSpec(document,e.type.spec.toDOM(e),null,e.attrs);({dom:h,contentDOM:a}=t)}a||e.isText||"BR"==h.nodeName||(h.hasAttribute("contenteditable")||(h.contentEditable="false"),e.type.spec.draggable&&(h.draggable=!0));let f=h;return h=Oi(h,r,e),u?o=new Ei(t,e,r,i,h,a||null,f,u,n,s+1):e.isText?new Di(t,e,r,i,h,f,n):new vi(t,e,r,i,h,a||null,f,n,s+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let t={node:this.node.type.name,attrs:this.node.attrs};if("pre"==this.node.type.whitespace&&(t.preserveWhitespace="full"),this.contentDOM)if(this.contentLost){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}}t.contentElement||(t.getContent=()=>Q.empty)}else t.contentElement=this.contentDOM;else t.getContent=()=>this.node.content;return t}matchesNode(t,e,r){return 0==this.dirty&&t.eq(this.node)&&$i(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,n=t.composing?this.localCompositionInfo(t,e):null,s=n&&n.pos>-1?n:null,o=n&&n.pos<0,l=new Ri(this,s&&s.node,t);!function(t,e,r,i){let n=e.locals(t),s=0;if(0==n.length){for(let r=0;r<t.childCount;r++){let o=t.child(r);i(o,n,e.forChild(s,o),r),s+=o.nodeSize}return}let o=0,l=[],u=null;for(let h=0;;){let a,f,c,d;for(;o<n.length&&n[o].to==s;){let t=n[o++];t.widget&&(a?(f||(f=[a])).push(t):a=t)}if(a)if(f){f.sort(Ni);for(let t=0;t<f.length;t++)r(f[t],h,!!u)}else r(a,h,!!u);if(u)d=-1,c=u,u=null;else{if(!(h<t.childCount))break;d=h,c=t.child(h++)}for(let t=0;t<l.length;t++)l[t].to<=s&&l.splice(t--,1);for(;o<n.length&&n[o].from<=s&&n[o].to>s;)l.push(n[o++]);let p=s+c.nodeSize;if(c.isText){let t=p;o<n.length&&n[o].from<t&&(t=n[o].from);for(let e=0;e<l.length;e++)l[e].to<t&&(t=l[e].to);t<p&&(u=c.cut(t-s),c=c.cut(0,t-s),p=t,d=-1)}else for(;o<n.length&&n[o].to<p;)o++;i(c,c.isInline&&!c.isLeaf?l.filter((t=>!t.inline)):l.slice(),e.forChild(s,c),d),s=p}}(this.node,this.innerDeco,((e,n,s)=>{e.spec.marks?l.syncToMarks(e.spec.marks,r,t):e.type.side>=0&&!s&&l.syncToMarks(n==this.node.childCount?it.none:this.node.child(n).marks,r,t),l.placeWidget(e,t,i)}),((e,s,u,h)=>{let a;l.syncToMarks(e.marks,r,t),l.findNodeMatch(e,s,u,h)||o&&t.state.selection.from>i&&t.state.selection.to<i+e.nodeSize&&(a=l.findIndexWithChild(n.node))>-1&&l.updateNodeAt(e,s,u,a,t)||l.updateNextNode(e,s,u,t,h,i)||l.addNode(e,s,u,t,i),i+=e.nodeSize})),l.syncToMarks([],r,t),this.node.isTextblock&&l.addTextblockHacks(),l.destroyRest(),(l.changed||2==this.dirty)&&(s&&this.protectLocalComposition(t,s),xi(this.contentDOM,this.children,t),Pr&&function(t){if("UL"==t.nodeName||"OL"==t.nodeName){let e=t.style.cssText;t.style.cssText=e+"; list-style: square !important",window.getComputedStyle(t),t.style.cssText=e}}(this.dom))}localCompositionInfo(t,e){let{from:r,to:i}=t.state.selection;if(!(t.state.selection instanceof Xe)||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,s=function(t,e,r,i){for(let n=0,s=0;n<t.childCount&&s<=i;){let o=t.child(n++),l=s;if(s+=o.nodeSize,!o.isText)continue;let u=o.text;for(;n<t.childCount;){let e=t.child(n++);if(s+=e.nodeSize,!e.isText)break;u+=e.text}if(s>=r){if(s>=i&&u.slice(i-e.length-l,i-l)==e)return i-e.length;let t=l<i?u.lastIndexOf(e,i-l-1):-1;if(t>=0&&t+e.length+l>=r)return l+t;if(r==i&&u.length>=i+e.length-l&&u.slice(i-l,i-l+e.length)==e)return i}}return-1}(this.node.content,t,r-e,i-e);return s<0?null:{node:n,pos:s,text:t}}return{node:n,pos:-1,text:""}}protectLocalComposition(t,{node:e,pos:r,text:i}){if(this.getDesc(e))return;let n=e;for(;n.parentNode!=this.contentDOM;n=n.parentNode){for(;n.previousSibling;)n.parentNode.removeChild(n.previousSibling);for(;n.nextSibling;)n.parentNode.removeChild(n.nextSibling);n.pmViewDesc&&(n.pmViewDesc=void 0)}let s=new bi(this,n,e,i);t.input.compositionNodes.push(s),this.children=_i(this.children,r,r+i.length,t,s)}update(t,e,r,i){return!(3==this.dirty||!t.sameMarkup(this.node)||(this.updateInner(t,e,r,i),0))}updateInner(t,e,r,i){this.updateOuterDeco(e),this.node=t,this.innerDeco=r,this.contentDOM&&this.updateChildren(i,this.posAtStart),this.dirty=0}updateOuterDeco(t){if($i(t,this.outerDeco))return;let e=1!=this.nodeDOM.nodeType,r=this.dom;this.dom=Ci(this.dom,this.nodeDOM,Ai(this.outerDeco,this.node,e),Ai(t,this.node,e)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=t}selectNode(){1==this.nodeDOM.nodeType&&this.nodeDOM.classList.add("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||(this.dom.draggable=!0)}deselectNode(){1==this.nodeDOM.nodeType&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||this.dom.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function ki(t,e,r,i,n){Oi(i,e,t);let s=new vi(void 0,t,e,r,i,i,i,n,0);return s.contentDOM&&s.updateChildren(n,0),s}class Di extends vi{constructor(t,e,r,i,n,s,o){super(t,e,r,i,n,null,s,o,0)}parseRule(){let t=this.nodeDOM.parentNode;for(;t&&t!=this.dom&&!t.pmIsDeco;)t=t.parentNode;return{skip:t||!0}}update(t,e,r,i){return!(3==this.dirty||0!=this.dirty&&!this.inParent()||!t.sameMarkup(this.node)||(this.updateOuterDeco(e),0==this.dirty&&t.text==this.node.text||t.text==this.nodeDOM.nodeValue||(this.nodeDOM.nodeValue=t.text,i.trackWrites==this.nodeDOM&&(i.trackWrites=null)),this.node=t,this.dirty=0,0))}inParent(){let t=this.parent.contentDOM;for(let e=this.nodeDOM;e;e=e.parentNode)if(e==t)return!0;return!1}domFromPos(t){return{node:this.nodeDOM,offset:t}}localPosFromDOM(t,e,r){return t==this.nodeDOM?this.posAtStart+Math.min(e,this.node.text.length):super.localPosFromDOM(t,e,r)}ignoreMutation(t){return"characterData"!=t.type&&"selection"!=t.type}slice(t,e,r){let i=this.node.cut(t,e),n=document.createTextNode(i.text);return new Di(this.parent,i,this.outerDeco,this.innerDeco,n,n,r)}markDirty(t,e){super.markDirty(t,e),this.dom==this.nodeDOM||0!=t&&e!=this.nodeDOM.nodeValue.length||(this.dirty=3)}get domAtom(){return!1}isText(t){return this.node.text==t}}class yi extends mi{parseRule(){return{ignore:!0}}matchesHack(t){return 0==this.dirty&&this.dom.nodeName==t}get domAtom(){return!0}get ignoreForCoords(){return"IMG"==this.dom.nodeName}}class Ei extends vi{constructor(t,e,r,i,n,s,o,l,u,h){super(t,e,r,i,n,s,o,u,h),this.spec=l}update(t,e,r,i){if(3==this.dirty)return!1;if(this.spec.update&&(this.node.type==t.type||this.spec.multiType)){let n=this.spec.update(t,e,r);return n&&this.updateInner(t,e,r,i),n}return!(!this.contentDOM&&!t.isLeaf)&&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(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(t){return!!this.spec.stopEvent&&this.spec.stopEvent(t)}ignoreMutation(t){return this.spec.ignoreMutation?this.spec.ignoreMutation(t):super.ignoreMutation(t)}}function xi(t,e,r){let i=t.firstChild,n=!1;for(let s=0;s<e.length;s++){let o=e[s],l=o.dom;if(l.parentNode==t){for(;l!=i;)i=Bi(i),n=!0;i=i.nextSibling}else n=!0,t.insertBefore(l,i);if(o instanceof wi){let e=i?i.previousSibling:t.lastChild;xi(o.contentDOM,o.children,r),i=e?e.nextSibling:t.firstChild}}for(;i;)i=Bi(i),n=!0;n&&r.trackWrites==t&&(r.trackWrites=null)}const Fi=function(t){t&&(this.nodeName=t)};Fi.prototype=Object.create(null);const Mi=[new Fi];function Ai(t,e,r){if(0==t.length)return Mi;let i=r?Mi[0]:new Fi,n=[i];for(let s=0;s<t.length;s++){let o=t[s].type.attrs;if(o){o.nodeName&&n.push(i=new Fi(o.nodeName));for(let t in o){let s=o[t];null!=s&&(r&&1==n.length&&n.push(i=new Fi(e.isInline?"span":"div")),"class"==t?i.class=(i.class?i.class+" ":"")+s:"style"==t?i.style=(i.style?i.style+";":"")+s:"nodeName"!=t&&(i[t]=s))}}}return n}function Ci(t,e,r,i){if(r==Mi&&i==Mi)return e;let n=e;for(let e=0;e<i.length;e++){let s=i[e],o=r[e];if(e){let e;o&&o.nodeName==s.nodeName&&n!=t&&(e=n.parentNode)&&e.nodeName.toLowerCase()==s.nodeName||(e=document.createElement(s.nodeName),e.pmIsDeco=!0,e.appendChild(n),o=Mi[0]),n=e}Si(n,o||Mi[0],s)}return n}function Si(t,e,r){for(let i in e)"class"==i||"style"==i||"nodeName"==i||i in r||t.removeAttribute(i);for(let i in r)"class"!=i&&"style"!=i&&"nodeName"!=i&&r[i]!=e[i]&&t.setAttribute(i,r[i]);if(e.class!=r.class){let i=e.class?e.class.split(" ").filter(Boolean):[],n=r.class?r.class.split(" ").filter(Boolean):[];for(let e=0;e<i.length;e++)-1==n.indexOf(i[e])&&t.classList.remove(i[e]);for(let e=0;e<n.length;e++)-1==i.indexOf(n[e])&&t.classList.add(n[e]);0==t.classList.length&&t.removeAttribute("class")}if(e.style!=r.style){if(e.style){let r,i=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g;for(;r=i.exec(e.style);)t.style.removeProperty(r[1])}r.style&&(t.style.cssText+=r.style)}}function Oi(t,e,r){return Ci(t,t,Mi,Ai(e,r,1!=t.nodeType))}function $i(t,e){if(t.length!=e.length)return!1;for(let r=0;r<t.length;r++)if(!t[r].type.eq(e[r].type))return!1;return!0}function Bi(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class Ri{constructor(t,e,r){this.lock=e,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=t,this.preMatch=function(t,e){let r=e,i=r.children.length,n=t.childCount,s=new Map,o=[];t:for(;n>0;){let l;for(;;)if(i){let t=r.children[i-1];if(!(t instanceof wi)){l=t,i--;break}r=t,i=t.children.length}else{if(r==e)break t;i=r.parent.children.indexOf(r),r=r.parent}let u=l.node;if(u){if(u!=t.child(n-1))break;--n,s.set(l,n),o.push(l)}}return{index:n,matched:s,matches:o.reverse()}}(t.node.content,t)}destroyBetween(t,e){if(t!=e){for(let r=t;r<e;r++)this.top.children[r].destroy();this.top.children.splice(t,e-t),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(t,e,r){let i=0,n=this.stack.length>>1,s=Math.min(n,t.length);for(;i<s&&(i==n-1?this.top:this.stack[i+1<<1]).matchesMark(t[i])&&!1!==t[i].type.spec.spanning;)i++;for(;i<n;)this.destroyRest(),this.top.dirty=0,this.index=this.stack.pop(),this.top=this.stack.pop(),n--;for(;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)i>this.index&&(this.changed=!0,this.destroyBetween(this.index,i)),this.top=this.top.children[this.index];else{let i=wi.create(this.top,t[n],e,r);this.top.children.splice(this.index,0,i),this.top=i,this.changed=!0}this.index=0,n++}}findNodeMatch(t,e,r,i){let n,s=-1;if(i>=this.preMatch.index&&(n=this.preMatch.matches[i-this.preMatch.index]).parent==this.top&&n.matchesNode(t,e,r))s=this.top.children.indexOf(n,this.index);else for(let i=this.index,n=Math.min(this.top.children.length,i+5);i<n;i++){let n=this.top.children[i];if(n.matchesNode(t,e,r)&&!this.preMatch.matched.has(n)){s=i;break}}return!(s<0||(this.destroyBetween(this.index,s),this.index++,0))}updateNodeAt(t,e,r,i,n){let s=this.top.children[i];return 3==s.dirty&&s.dom==s.contentDOM&&(s.dirty=2),!!s.update(t,e,r,n)&&(this.destroyBetween(this.index,i),this.index++,!0)}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 o=this.index;o<this.top.children.length;o++){let l=this.top.children[o];if(l instanceof vi){let u=this.preMatch.matched.get(l);if(null!=u&&u!=n)return!1;let h,a=l.dom,f=this.isLocked(a)&&!(t.isText&&l.node&&l.node.isText&&l.nodeDOM.nodeValue==t.text&&3!=l.dirty&&$i(e,l.outerDeco));if(!f&&l.update(t,e,r,i))return this.destroyBetween(this.index,o),l.dom!=a&&(this.changed=!0),this.index++,!0;if(!f&&(h=this.recreateWrapper(l,t,e,r,i,s)))return this.destroyBetween(this.index,o),this.top.children[this.index]=h,h.contentDOM&&(h.dirty=2,h.updateChildren(i,s+1),h.dirty=0),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(t,e,r,i,n,s){if(t.dirty||e.isAtom||!t.children.length||!t.node.content.eq(e.content)||!$i(r,t.outerDeco)||!i.eq(t.innerDeco))return null;let o=vi.create(this.top,e,r,i,n,s);if(o.contentDOM){o.children=t.children,t.children=[];for(let t of o.children)t.parent=o}return t.destroy(),o}addNode(t,e,r,i,n){let s=vi.create(this.top,t,e,r,i,n);s.contentDOM&&s.updateChildren(i,n+1),this.top.children.splice(this.index++,0,s),this.changed=!0}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){let i=new gi(this.top,t,e,r);this.top.children.splice(this.index++,0,i),this.changed=!0}else this.index++}addTextblockHacks(){let t=this.top.children[this.index-1],e=this.top;for(;t instanceof wi;)e=t,t=e.children[e.children.length-1];(!t||!(t instanceof Di)||/\n$/.test(t.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(t.node.text))&&((Ir||jr)&&t&&"false"==t.dom.contentEditable&&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);"IMG"==t&&(r.className="ProseMirror-separator",r.alt=""),"BR"==t&&(r.className="ProseMirror-trailingBreak");let i=new yi(this.top,[],r,null);e!=this.top?e.children.push(i):e.children.splice(this.index++,0,i),this.changed=!0}}isLocked(t){return this.lock&&(t==this.lock||1==t.nodeType&&t.contains(this.lock.parentNode))}}function Ni(t,e){return t.type.side-e.type.side}function _i(t,e,r,i,n){let s=[];for(let o=0,l=0;o<t.length;o++){let u=t[o],h=l,a=l+=u.size;h>=r||a<=e?s.push(u):(h<e&&s.push(u.slice(0,e-h,i)),n&&(s.push(n),n=void 0),a>r&&s.push(u.slice(r-h,u.size,i)))}return s}function Ti(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&&0==n.size,o=t.docView.posFromDOM(r.focusNode,r.focusOffset,1);if(o<0)return null;let l,u,h=i.resolve(o);if(Mr(r)){for(l=o;n&&!n.node;)n=n.parent;let t=n.node;if(n&&t.isAtom&&tr.isSelectable(t)&&n.parent&&(!t.isInline||!function(t,e,r){for(let i=0==e,n=e==xr(t);i||n;){if(t==r)return!0;let e=br(t);if(!(t=t.parentNode))return!1;i=i&&0==e,n=n&&e==xr(t)}}(r.focusNode,r.focusOffset,n.dom))){let t=n.posBefore;u=new tr(o==t?h:i.resolve(t))}}else{if(r instanceof t.dom.ownerDocument.defaultView.Selection&&r.rangeCount>1){let e=o,n=o;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;[l,o]=n==t.state.selection.anchor?[n,e]:[e,n],h=i.resolve(o)}else l=t.docView.posFromDOM(r.anchorNode,r.anchorOffset,1);if(l<0)return null}let a=i.resolve(l);return u||(u=Vi(t,a,h,"pointer"==e||t.state.selection.head<h.pos&&!s?1:-1)),u}function zi(t){return t.editable?t.hasFocus():Wi(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function ji(t,e=!1){let r=t.state.selection;if(Ji(t,r),zi(t)){if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&jr){let e=t.domSelectionRange(),r=t.domObserver.currentSelection;if(e.anchorNode&&r.anchorNode&&Dr(e.anchorNode,e.anchorOffset,r.anchorNode,r.anchorOffset))return t.input.mouseDown.delayedSelectionSync=!0,void t.domObserver.setCurSelection()}if(t.domObserver.disconnectSelection(),t.cursorWrapper)!function(t){let e=t.domSelection(),r=document.createRange();if(!e)return;let i=t.cursorWrapper.dom,n="IMG"==i.nodeName;n?r.setStart(i.parentNode,br(i)+1):r.setStart(i,0),r.collapse(!0),e.removeAllRanges(),e.addRange(r),!n&&!t.state.selection.visible&&Nr&&_r<=11&&(i.disabled=!0,i.disabled=!1)}(t);else{let i,n,{anchor:s,head:o}=r;!qi||r instanceof Xe||(r.$from.parent.inlineContent||(i=Ii(t,r.from)),r.empty||r.$from.parent.inlineContent||(n=Ii(t,r.to))),t.docView.setSelection(s,o,t,e),qi&&(i&&Li(i),n&&Li(n)),r.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&function(t){let e=t.dom.ownerDocument;e.removeEventListener("selectionchange",t.input.hideSelectionGuard);let r=t.domSelectionRange(),i=r.anchorNode,n=r.anchorOffset;e.addEventListener("selectionchange",t.input.hideSelectionGuard=()=>{r.anchorNode==i&&r.anchorOffset==n||(e.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout((()=>{zi(t)&&!t.state.selection.visible||t.dom.classList.remove("ProseMirror-hideselection")}),20))})}(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}const qi=Ir||jr&&qr<63;function Ii(t,e){let{node:r,offset:i}=t.docView.domFromPos(e,0),n=i<r.childNodes.length?r.childNodes[i]:null,s=i?r.childNodes[i-1]:null;if(Ir&&n&&"false"==n.contentEditable)return Pi(n);if(!(n&&"false"!=n.contentEditable||s&&"false"!=s.contentEditable)){if(n)return Pi(n);if(s)return Pi(s)}}function Pi(t){return t.contentEditable="true",Ir&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function Li(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function Ji(t,e){if(e instanceof tr){let r=t.docView.descAt(e.from);r!=t.lastSelectedViewDesc&&(Ui(t),r&&r.selectNode(),t.lastSelectedViewDesc=r)}else Ui(t)}function Ui(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function Vi(t,e,r,i){return t.someProp("createSelectionBetween",(i=>i(t,e,r)))||Xe.between(e,r,i)}function Hi(t){return!(t.editable&&!t.hasFocus())&&Wi(t)}function Wi(t){let e=t.domSelectionRange();if(!e.anchorNode)return!1;try{return t.dom.contains(3==e.anchorNode.nodeType?e.anchorNode.parentNode:e.anchorNode)&&(t.editable||t.dom.contains(3==e.focusNode.nodeType?e.focusNode.parentNode:e.focusNode))}catch(t){return!1}}function Gi(t,e){let{$anchor:r,$head:i}=t.selection,n=e>0?r.max(i):r.min(i),s=n.parent.inlineContent?n.depth?t.doc.resolve(e>0?n.after():n.before()):null:n;return s&&Ge.findFrom(s,e)}function Zi(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function Ki(t,e,r){let i=t.state.selection;if(!(i instanceof Xe)){if(i instanceof tr&&i.node.isInline)return Zi(t,new Xe(e>0?i.$to:i.$from));{let r=Gi(t.state,e);return!!r&&Zi(t,r)}}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!1;let s=t.state.doc.resolve(r.pos+n.nodeSize*(e<0?-1:1));return Zi(t,new Xe(i.$anchor,s))}if(!i.empty)return!1;if(t.endOfTextblock(e>0?"forward":"backward")){let r=Gi(t.state,e);return!!(r&&r instanceof tr)&&Zi(t,r)}if(!(Lr&&r.indexOf("m")>-1)){let r,n=i.$head,s=n.textOffset?null:e<0?n.nodeBefore:n.nodeAfter;if(!s||s.isText)return!1;let o=e<0?n.pos-s.nodeSize:n.pos;return!!(s.isAtom||(r=t.docView.descAt(o))&&!r.contentDOM)&&(tr.isSelectable(s)?Zi(t,new tr(e<0?t.state.doc.resolve(n.pos-s.nodeSize):n)):!!Vr&&Zi(t,new Xe(t.state.doc.resolve(e<0?o:o+s.nodeSize))))}}function Yi(t){return 3==t.nodeType?t.nodeValue.length:t.childNodes.length}function Xi(t,e){let r=t.pmViewDesc;return r&&0==r.size&&(e<0||t.nextSibling||"BR"!=t.nodeName)}function Qi(t,e){return e<0?function(t){let e=t.domSelectionRange(),r=e.focusNode,i=e.focusOffset;if(!r)return;let n,s,o=!1;for(Tr&&1==r.nodeType&&i<Yi(r)&&Xi(r.childNodes[i],-1)&&(o=!0);;)if(i>0){if(1!=r.nodeType)break;{let t=r.childNodes[i-1];if(Xi(t,-1))n=r,s=--i;else{if(3!=t.nodeType)break;r=t,i=r.nodeValue.length}}}else{if(tn(r))break;{let e=r.previousSibling;for(;e&&Xi(e,-1);)n=r.parentNode,s=br(e),e=e.previousSibling;if(e)r=e,i=Yi(r);else{if(r=r.parentNode,r==t.dom)break;i=0}}}o?en(t,r,i):n&&en(t,n,s)}(t):function(t){let e=t.domSelectionRange(),r=e.focusNode,i=e.focusOffset;if(!r)return;let n,s,o=Yi(r);for(;;)if(i<o){if(1!=r.nodeType)break;if(!Xi(r.childNodes[i],1))break;n=r,s=++i}else{if(tn(r))break;{let e=r.nextSibling;for(;e&&Xi(e,1);)n=e.parentNode,s=br(e)+1,e=e.nextSibling;if(e)r=e,i=0,o=Yi(r);else{if(r=r.parentNode,r==t.dom)break;i=o=0}}}n&&en(t,n,s)}(t)}function tn(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function en(t,e,r){if(3!=e.nodeType){let t,i;(i=function(t,e){for(;t&&e==t.childNodes.length&&!Fr(t);)e=br(t)+1,t=t.parentNode;for(;t&&e<t.childNodes.length;){let r=t.childNodes[e];if(3==r.nodeType)return r;if(1==r.nodeType&&"false"==r.contentEditable)break;t=r,e=0}}(e,r))?(e=i,r=0):(t=function(t,e){for(;t&&!e&&!Fr(t);)e=br(t),t=t.parentNode;for(;t&&e;){let r=t.childNodes[e-1];if(3==r.nodeType)return r;if(1==r.nodeType&&"false"==r.contentEditable)break;e=(t=r).childNodes.length}}(e,r))&&(e=t,r=t.nodeValue.length)}let i=t.domSelection();if(!i)return;if(Mr(i)){let t=document.createRange();t.setEnd(e,r),t.setStart(e,r),i.removeAllRanges(),i.addRange(t)}else i.extend&&i.extend(e,r);t.domObserver.setCurSelection();let{state:n}=t;setTimeout((()=>{t.state==n&&ji(t)}),50)}function rn(t,e){let r=t.state.doc.resolve(e);if(!jr&&!Jr&&r.parent.inlineContent){let i=t.coordsAtPos(e);if(e>r.start()){let r=t.coordsAtPos(e-1),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),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"}}return"rtl"==getComputedStyle(t.dom).direction?"rtl":"ltr"}function nn(t,e,r){let i=t.state.selection;if(i instanceof Xe&&!i.empty||r.indexOf("s")>-1)return!1;if(Lr&&r.indexOf("m")>-1)return!1;let{$from:n,$to:s}=i;if(!n.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let r=Gi(t.state,e);if(r&&r instanceof tr)return Zi(t,r)}if(!n.parent.inlineContent){let r=e<0?n:s,o=i instanceof rr?Ge.near(r,e):Ge.findFrom(r,e);return!!o&&Zi(t,o)}return!1}function sn(t,e){if(!(t.state.selection instanceof Xe))return!0;let{$head:r,$anchor:i,empty:n}=t.state.selection;if(!r.sameParent(i))return!0;if(!n)return!1;if(t.endOfTextblock(e>0?"forward":"backward"))return!0;let s=!r.textOffset&&(e<0?r.nodeBefore:r.nodeAfter);if(s&&!s.isText){let i=t.state.tr;return e<0?i.delete(r.pos-s.nodeSize,r.pos):i.delete(r.pos,r.pos+s.nodeSize),t.dispatch(i),!0}return!1}function on(t,e,r){t.domObserver.stop(),e.contentEditable=r,t.domObserver.start()}function ln(t,e){t.someProp("transformCopied",(r=>{e=r(e,t)}));let r=[],{content:i,openStart:n,openEnd:s}=e;for(;n>1&&s>1&&1==i.childCount&&1==i.firstChild.childCount;){n--,s--;let t=i.firstChild;r.push(t.type.name,t.attrs!=t.type.defaultAttrs?t.attrs:null),i=t.content}let o=t.someProp("clipboardSerializer")||te.fromSchema(t.state.schema),l=bn(),u=l.createElement("div");u.appendChild(o.serializeFragment(i,{document:l}));let h,a=u.firstChild,f=0;for(;a&&1==a.nodeType&&(h=mn[a.nodeName.toLowerCase()]);){for(let t=h.length-1;t>=0;t--){let e=l.createElement(h[t]);for(;u.firstChild;)e.appendChild(u.firstChild);u.appendChild(e),f++}a=u.firstChild}return a&&1==a.nodeType&&a.setAttribute("data-pm-slice",`${n} ${s}${f?` -${f}`:""} ${JSON.stringify(r)}`),{dom:u,text:t.someProp("clipboardTextSerializer",(r=>r(e,t)))||e.content.textBetween(0,e.content.size,"\n\n"),slice:e}}function un(t,e,r,i,n){let s,o,l=n.parent.type.spec.code;if(!r&&!e)return null;let u=e&&(i||l||!r);if(u){if(t.someProp("transformPastedText",(r=>{e=r(e,l||i,t)})),l)return e?new st(Q.from(t.state.schema.text(e.replace(/\r\n?/g,"\n"))),0,0):st.empty;let r=t.someProp("clipboardTextParser",(r=>r(e,n,i,t)));if(r)o=r;else{let r=n.marks(),{schema:i}=t.state,o=te.fromSchema(i);s=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach((t=>{let e=s.appendChild(document.createElement("p"));t&&e.appendChild(o.serializeNode(i.text(t,r)))}))}}else t.someProp("transformPastedHTML",(e=>{r=e(r,t)})),s=function(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let r,i=bn().createElement("div"),n=/<([a-z][^>\s]+)/i.exec(t);if((r=n&&mn[n[1].toLowerCase()])&&(t=r.map((t=>"<"+t+">")).join("")+t+r.map((t=>"</"+t+">")).reverse().join("")),i.innerHTML=function(t){let e=window.trustedTypes;return e?(wn||(wn=e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})),wn.createHTML(t)):t}(t),r)for(let t=0;t<r.length;t++)i=i.querySelector(r[t])||i;return i}(r),Vr&&function(t){let e=t.querySelectorAll(jr?"span:not([class]):not([style])":"span.Apple-converted-space");for(let r=0;r<e.length;r++){let i=e[r];1==i.childNodes.length&&" "==i.textContent&&i.parentNode&&i.parentNode.replaceChild(t.ownerDocument.createTextNode(" "),i)}}(s);let h=s&&s.querySelector("[data-pm-slice]"),a=h&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(h.getAttribute("data-pm-slice")||"");if(a&&a[3])for(let t=+a[3];t>0;t--){let t=s.firstChild;for(;t&&1!=t.nodeType;)t=t.nextSibling;if(!t)break;s=t}if(!o){let e=t.someProp("clipboardParser")||t.someProp("domParser")||Ut.fromSchema(t.state.schema);o=e.parseSlice(s,{preserveWhitespace:!(!u&&!a),context:n,ruleFromNode:t=>"BR"!=t.nodeName||t.nextSibling||!t.parentNode||hn.test(t.parentNode.nodeName)?null:{ignore:!0}})}if(a)o=function(t,e){if(!t.size)return t;let r,i=t.content.firstChild.type.schema;try{r=JSON.parse(e)}catch(e){return t}let{content:n,openStart:s,openEnd:o}=t;for(let t=r.length-2;t>=0;t-=2){let e=i.nodes[r[t]];if(!e||e.hasRequiredAttrs())break;n=Q.from(e.create(r[t+1],n)),s++,o++}return new st(n,s,o)}(pn(o,+a[1],+a[2]),a[4]);else if(o=st.maxOpen(function(t,e){if(t.childCount<2)return t;for(let r=e.depth;r>=0;r--){let i,n=e.node(r).contentMatchAt(e.index(r)),s=[];if(t.forEach((t=>{if(!s)return;let e,r=n.findWrapping(t.type);if(!r)return s=null;if(e=s.length&&i.length&&fn(r,i,t,s[s.length-1],0))s[s.length-1]=e;else{s.length&&(s[s.length-1]=cn(s[s.length-1],i.length));let e=an(t,r);s.push(e),n=n.matchType(e.type),i=r}})),s)return Q.from(s)}return t}(o.content,n),!0),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=pn(o,t,e)}return t.someProp("transformPasted",(e=>{o=e(o,t)})),o}const hn=/^(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 an(t,e,r=0){for(let i=e.length-1;i>=r;i--)t=e[i].create(null,Q.from(t));return t}function fn(t,e,r,i,n){if(n<t.length&&n<e.length&&t[n]==e[n]){let s=fn(t,e,r,i.lastChild,n+1);if(s)return i.copy(i.content.replaceChild(i.childCount-1,s));if(i.contentMatchAt(i.childCount).matchType(n==t.length-1?r.type:t[n+1]))return i.copy(i.content.append(Q.from(an(r,t,n+1))))}}function cn(t,e){if(0==e)return t;let r=t.content.replaceChild(t.childCount-1,cn(t.lastChild,e-1)),i=t.contentMatchAt(t.childCount).fillBefore(Q.empty,!0);return t.copy(r.append(i))}function dn(t,e,r,i,n,s){let o=e<0?t.firstChild:t.lastChild,l=o.content;return t.childCount>1&&(s=0),n<i-1&&(l=dn(l,e,r,i,n+1,s)),n>=r&&(l=e<0?o.contentMatchAt(0).fillBefore(l,s<=n).append(l):l.append(o.contentMatchAt(o.childCount).fillBefore(Q.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,o.copy(l))}function pn(t,e,r){return e<t.openStart&&(t=new st(dn(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),r<t.openEnd&&(t=new st(dn(t.content,1,r,t.openEnd,0,0),t.openStart,r)),t}const mn={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 gn=null;function bn(){return gn||(gn=document.implementation.createHTMLDocument("title"))}let wn=null;const vn={},kn={},Dn={touchstart:!0,touchmove:!0};class yn{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:""},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function En(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function xn(t){t.someProp("handleDOMEvents",(e=>{for(let r in e)t.input.eventHandlers[r]||t.dom.addEventListener(r,t.input.eventHandlers[r]=e=>Fn(t,e))}))}function Fn(t,e){return t.someProp("handleDOMEvents",(r=>{let i=r[e.type];return!!i&&(i(t,e)||e.defaultPrevented)}))}function Mn(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let r=e.target;r!=t.dom;r=r.parentNode)if(!r||11==r.nodeType||r.pmViewDesc&&r.pmViewDesc.stopEvent(e))return!1;return!0}function An(t){return{left:t.clientX,top:t.clientY}}function Cn(t,e,r,i,n){if(-1==i)return!1;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,!0):e(t,r,s.node(i),s.before(i),n,!1))))return!0;return!1}function Sn(t,e){if(t.focused||t.focus(),t.state.selection.eq(e))return;let r=t.state.tr.setSelection(e);r.setMeta("pointer",!0),t.dispatch(r)}function On(t,e,r,i){return Cn(t,"handleDoubleClickOn",e,r,i)||t.someProp("handleDoubleClick",(r=>r(t,e,i)))}function $n(t,e,r,i){return Cn(t,"handleTripleClickOn",e,r,i)||t.someProp("handleTripleClick",(r=>r(t,e,i)))||function(t,e,r){if(0!=r.button)return!1;let i=t.state.doc;if(-1==e)return!!i.inlineContent&&(Sn(t,Xe.create(i,0,i.content.size)),!0);let n=i.resolve(e);for(let e=n.depth+1;e>0;e--){let r=e>n.depth?n.nodeAfter:n.node(e),s=n.before(e);if(r.inlineContent)Sn(t,Xe.create(i,s+1,s+1+r.content.size));else{if(!tr.isSelectable(r))continue;Sn(t,tr.create(i,s))}return!0}}(t,r,i)}function Bn(t){return qn(t)}kn.keydown=(t,e)=>{let r=e;if(t.input.shiftKey=16==r.keyCode||r.shiftKey,!_n(t,r)&&(t.input.lastKeyCode=r.keyCode,t.input.lastKeyCodeTime=Date.now(),!Ur||!jr||13!=r.keyCode))if(229!=r.keyCode&&t.domObserver.forceFlush(),!Pr||13!=r.keyCode||r.ctrlKey||r.altKey||r.metaKey)t.someProp("handleKeyDown",(e=>e(t,r)))||function(t,e){let r=e.keyCode,i=function(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}(e);if(8==r||Lr&&72==r&&"c"==i)return sn(t,-1)||Qi(t,-1);if(46==r&&!e.shiftKey||Lr&&68==r&&"c"==i)return sn(t,1)||Qi(t,1);if(13==r||27==r)return!0;if(37==r||Lr&&66==r&&"c"==i){let e=37==r?"ltr"==rn(t,t.state.selection.from)?-1:1:-1;return Ki(t,e,i)||Qi(t,e)}if(39==r||Lr&&70==r&&"c"==i){let e=39==r?"ltr"==rn(t,t.state.selection.from)?1:-1:1;return Ki(t,e,i)||Qi(t,e)}return 38==r||Lr&&80==r&&"c"==i?nn(t,-1,i)||Qi(t,-1):40==r||Lr&&78==r&&"c"==i?function(t){if(!Ir||t.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:r}=t.domSelectionRange();if(e&&1==e.nodeType&&0==r&&e.firstChild&&"false"==e.firstChild.contentEditable){let r=e.firstChild;on(t,r,"true"),setTimeout((()=>on(t,r,"false")),20)}return!1}(t)||nn(t,1,i)||Qi(t,1):i==(Lr?"m":"c")&&(66==r||73==r||89==r||90==r)}(t,r)?r.preventDefault():En(t,"key");else{let e=Date.now();t.input.lastIOSEnter=e,t.input.lastIOSEnterFallbackTimeout=setTimeout((()=>{t.input.lastIOSEnter==e&&(t.someProp("handleKeyDown",(e=>e(t,Ar(13,"Enter")))),t.input.lastIOSEnter=0)}),200)}},kn.keyup=(t,e)=>{16==e.keyCode&&(t.input.shiftKey=!1)},kn.keypress=(t,e)=>{let r=e;if(_n(t,r)||!r.charCode||r.ctrlKey&&!r.altKey||Lr&&r.metaKey)return;if(t.someProp("handleKeyPress",(e=>e(t,r))))return void r.preventDefault();let i=t.state.selection;if(!(i instanceof Xe&&i.$from.sameParent(i.$to))){let e=String.fromCharCode(r.charCode);/[\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()}};const Rn=Lr?"metaKey":"ctrlKey";vn.mousedown=(t,e)=>{let r=e;t.input.shiftKey=r.shiftKey;let i=Bn(t),n=Date.now(),s="singleClick";n-t.input.lastClick.time<500&&function(t,e){let r=e.x-t.clientX,i=e.y-t.clientY;return r*r+i*i<100}(r,t.input.lastClick)&&!r[Rn]&&("singleClick"==t.input.lastClick.type?s="doubleClick":"doubleClick"==t.input.lastClick.type&&(s="tripleClick")),t.input.lastClick={time:n,x:r.clientX,y:r.clientY,type:s};let o=t.posAtCoords(An(r));o&&("singleClick"==s?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new Nn(t,o,r,!!i)):("doubleClick"==s?On:$n)(t,o.pos,o.inside,r)?r.preventDefault():En(t,"pointer"))};class Nn{constructor(t,e,r,i){let n,s;if(this.view=t,this.pos=e,this.event=r,this.flushed=i,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=t.state.doc,this.selectNode=!!r[Rn],this.allowDefault=r.shiftKey,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 o=i?null:r.target,l=o?t.docView.nearestDesc(o,!0):null;this.target=l&&1==l.dom.nodeType?l.dom:null;let{selection:u}=t.state;(0==r.button&&n.type.spec.draggable&&!1!==n.type.spec.selectable||u instanceof tr&&u.from<=s&&u.to>s)&&(this.mightDrag={node:n,pos:s,addAttr:!(!this.target||this.target.draggable),setUneditable:!(!this.target||!Tr||this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout((()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")}),20),this.view.domObserver.start()),t.root.addEventListener("mouseup",this.up=this.up.bind(this)),t.root.addEventListener("mousemove",this.move=this.move.bind(this)),En(t,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout((()=>ji(this.view))),this.view.input.mouseDown=null}up(t){if(this.done(),!this.view.dom.contains(t.target))return;let e=this.pos;this.view.state.doc!=this.startDoc&&(e=this.view.posAtCoords(An(t))),this.updateAllowDefault(t),this.allowDefault||!e?En(this.view,"pointer"):function(t,e,r,i,n){return Cn(t,"handleClickOn",e,r,i)||t.someProp("handleClick",(r=>r(t,e,i)))||(n?function(t,e){if(-1==e)return!1;let r,i,n=t.state.selection;n instanceof tr&&(r=n.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(tr.isSelectable(e)){i=r&&n.$from.depth>0&&t>=n.$from.depth&&s.before(n.$from.depth+1)==n.$from.pos?s.before(n.$from.depth):s.before(t);break}}return null!=i&&(Sn(t,tr.create(t.state.doc,i)),!0)}(t,r):function(t,e){if(-1==e)return!1;let r=t.state.doc.resolve(e),i=r.nodeAfter;return!!(i&&i.isAtom&&tr.isSelectable(i))&&(Sn(t,new tr(r)),!0)}(t,r))}(this.view,e.pos,e.inside,t,this.selectNode)?t.preventDefault():0==t.button&&(this.flushed||Ir&&this.mightDrag&&!this.mightDrag.node.isAtom||jr&&!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)?(Sn(this.view,Ge.near(this.view.state.doc.resolve(e.pos))),t.preventDefault()):En(this.view,"pointer")}move(t){this.updateAllowDefault(t),En(this.view,"pointer"),0==t.buttons&&this.done()}updateAllowDefault(t){!this.allowDefault&&(Math.abs(this.event.x-t.clientX)>4||Math.abs(this.event.y-t.clientY)>4)&&(this.allowDefault=!0)}}function _n(t,e){return!!t.composing||!!(Ir&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500)&&(t.input.compositionEndedAt=-2e8,!0)}vn.touchstart=t=>{t.input.lastTouch=Date.now(),Bn(t),En(t,"pointer")},vn.touchmove=t=>{t.input.lastTouch=Date.now(),En(t,"pointer")},vn.contextmenu=t=>Bn(t);const Tn=Ur?5e3:-1;function zn(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout((()=>qn(t)),e))}function jn(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=function(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function qn(t,e=!1){if(!(Ur&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),jn(t),e||t.docView&&t.docView.dirty){let r=Ti(t);return r&&!r.eq(t.state.selection)?t.dispatch(t.state.tr.setSelection(r)):!t.markCursor&&!e||t.state.selection.empty?t.updateState(t.state):t.dispatch(t.state.tr.deleteSelection()),!0}return!1}}kn.compositionstart=kn.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,r=e.selection.$to;if(e.selection instanceof Xe&&(e.storedMarks||!r.textOffset&&r.parentOffset&&r.nodeBefore.marks.some((t=>!1===t.type.spec.inclusive))))t.markCursor=t.state.storedMarks||r.marks(),qn(t,!0),t.markCursor=null;else if(qn(t,!e.selection.empty),Tr&&e.selection.empty&&r.parentOffset&&!r.textOffset&&r.nodeBefore.marks.length){let e=t.domSelectionRange();for(let r=e.focusNode,i=e.focusOffset;r&&1==r.nodeType&&0!=i;){let e=i<0?r.lastChild:r.childNodes[i-1];if(!e)break;if(3==e.nodeType){let r=t.domSelection();r&&r.collapse(e,e.nodeValue.length);break}r=e,i=-1}}t.input.composing=!0}zn(t,Tn)},kn.compositionend=(t,e)=>{t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=e.timeStamp,t.input.compositionPendingChanges=t.domObserver.pendingRecords().length?t.input.compositionID:0,t.input.compositionNode=null,t.input.compositionPendingChanges&&Promise.resolve().then((()=>t.domObserver.flush())),t.input.compositionID++,zn(t,20))};const In=Nr&&_r<15||Pr&&Hr<604;function Pn(t,e,r,i,n){let s=un(t,e,r,i,t.state.selection.$from);if(t.someProp("handlePaste",(e=>e(t,n,s||st.empty))))return!0;if(!s)return!1;let o=function(t){return 0==t.openStart&&0==t.openEnd&&1==t.content.childCount?t.content.firstChild:null}(s),l=o?t.state.tr.replaceSelectionWith(o,i):t.state.tr.replaceSelection(s);return t.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Ln(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," "):""}vn.copy=kn.cut=(t,e)=>{let r=e,i=t.state.selection,n="cut"==r.type;if(i.empty)return;let s=In?null:r.clipboardData,o=i.content(),{dom:l,text:u}=ln(t,o);s?(r.preventDefault(),s.clearData(),s.setData("text/html",l.innerHTML),s.setData("text/plain",u)):function(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((()=>{r.parentNode&&r.parentNode.removeChild(r),t.focus()}),50)}(t,l),n&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))},kn.paste=(t,e)=>{let r=e;if(t.composing&&!Ur)return;let i=In?null:r.clipboardData,n=t.input.shiftKey&&45!=t.input.lastKeyCode;i&&Pn(t,Ln(i),i.getData("text/html"),n,r)?r.preventDefault():function(t,e){if(!t.dom.parentNode)return;let r=t.input.shiftKey||t.state.selection.$from.parent.type.spec.code,i=t.dom.parentNode.appendChild(document.createElement(r?"textarea":"div"));r||(i.contentEditable="true"),i.style.cssText="position: fixed; left: -10000px; top: 10px",i.focus();let n=t.input.shiftKey&&45!=t.input.lastKeyCode;setTimeout((()=>{t.focus(),i.parentNode&&i.parentNode.removeChild(i),r?Pn(t,i.value,null,n,e):Pn(t,i.textContent,i.innerHTML,n,e)}),50)}(t,r)};class Jn{constructor(t,e,r){this.slice=t,this.move=e,this.node=r}}const Un=Lr?"altKey":"ctrlKey";vn.dragstart=(t,e)=>{let r=e,i=t.input.mouseDown;if(i&&i.done(),!r.dataTransfer)return;let n,s=t.state.selection,o=s.empty?null:t.posAtCoords(An(r));if(o&&o.pos>=s.from&&o.pos<=(s instanceof tr?s.to-1:s.to));else if(i&&i.mightDrag)n=tr.create(t.state.doc,i.mightDrag.pos);else if(r.target&&1==r.target.nodeType){let e=t.docView.nearestDesc(r.target,!0);e&&e.node.type.spec.draggable&&e!=t.docView&&(n=tr.create(t.state.doc,e.posBefore))}let l=(n||t.state.selection).content(),{dom:u,text:h,slice:a}=ln(t,l);(!r.dataTransfer.files.length||!jr||qr>120)&&r.dataTransfer.clearData(),r.dataTransfer.setData(In?"Text":"text/html",u.innerHTML),r.dataTransfer.effectAllowed="copyMove",In||r.dataTransfer.setData("text/plain",h),t.dragging=new Jn(a,!r[Un],n)},vn.dragend=t=>{let e=t.dragging;window.setTimeout((()=>{t.dragging==e&&(t.dragging=null)}),50)},kn.dragover=kn.dragenter=(t,e)=>e.preventDefault(),kn.drop=(t,e)=>{let r=e,i=t.dragging;if(t.dragging=null,!r.dataTransfer)return;let n=t.posAtCoords(An(r));if(!n)return;let s=t.state.doc.resolve(n.pos),o=i&&i.slice;o?t.someProp("transformPasted",(e=>{o=e(o,t)})):o=un(t,Ln(r.dataTransfer),In?null:r.dataTransfer.getData("text/html"),!1,s);let l=!(!i||r[Un]);if(t.someProp("handleDrop",(e=>e(t,r,o||st.empty,l))))return void r.preventDefault();if(!o)return;r.preventDefault();let u=o?Be(t.state.doc,s.pos,o):s.pos;null==u&&(u=s.pos);let h=t.state.tr;if(l){let{node:t}=i;t?t.replace(h):h.deleteSelection()}let a=h.mapping.map(u),f=0==o.openStart&&0==o.openEnd&&1==o.content.childCount,c=h.doc;if(f?h.replaceRangeWith(a,a,o.content.firstChild):h.replaceRange(a,a,o),h.doc.eq(c))return;let d=h.doc.resolve(a);if(f&&tr.isSelectable(o.content.firstChild)&&d.nodeAfter&&d.nodeAfter.sameMarkup(o.content.firstChild))h.setSelection(new tr(d));else{let e=h.mapping.map(u);h.mapping.maps[h.mapping.maps.length-1].forEach(((t,r,i,n)=>e=n)),h.setSelection(Vi(t,d,h.doc.resolve(e)))}t.focus(),t.dispatch(h.setMeta("uiEvent","drop"))},vn.focus=t=>{t.input.lastFocus=Date.now(),t.focused||(t.domObserver.stop(),t.dom.classList.add("ProseMirror-focused"),t.domObserver.start(),t.focused=!0,setTimeout((()=>{t.docView&&t.hasFocus()&&!t.domObserver.currentSelection.eq(t.domSelectionRange())&&ji(t)}),20))},vn.blur=(t,e)=>{let r=e;t.focused&&(t.domObserver.stop(),t.dom.classList.remove("ProseMirror-focused"),t.domObserver.start(),r.relatedTarget&&t.dom.contains(r.relatedTarget)&&t.domObserver.currentSelection.clear(),t.focused=!1)},vn.beforeinput=(t,e)=>{if(jr&&Ur&&"deleteContentBackward"==e.inputType){t.domObserver.flushSoon();let{domChangeCount:e}=t.input;setTimeout((()=>{if(t.input.domChangeCount!=e)return;if(t.dom.blur(),t.focus(),t.someProp("handleKeyDown",(e=>e(t,Ar(8,"Backspace")))))return;let{$cursor:r}=t.state.selection;r&&r.pos>0&&t.dispatch(t.state.tr.delete(r.pos-1,r.pos).scrollIntoView())}),50)}};for(let t in kn)vn[t]=kn[t];function Vn(t,e){if(t==e)return!0;for(let r in t)if(t[r]!==e[r])return!1;for(let r in e)if(!(r in t))return!1;return!0}class Hn{constructor(t,e){this.toDOM=t,this.spec=e||Yn,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 Zn(n-r,n-r,this)}valid(){return!0}eq(t){return this==t||t instanceof Hn&&(this.spec.key&&this.spec.key==t.spec.key||this.toDOM==t.toDOM&&Vn(this.spec,t.spec))}destroy(t){this.spec.destroy&&this.spec.destroy(t)}}class Wn{constructor(t,e){this.attrs=t,this.spec=e||Yn}map(t,e,r,i){let n=t.map(e.from+i,this.spec.inclusiveStart?-1:1)-r,s=t.map(e.to+i,this.spec.inclusiveEnd?1:-1)-r;return n>=s?null:new Zn(n,s,this)}valid(t,e){return e.from<e.to}eq(t){return this==t||t instanceof Wn&&Vn(this.attrs,t.attrs)&&Vn(this.spec,t.spec)}static is(t){return t.type instanceof Wn}destroy(){}}class Gn{constructor(t,e){this.attrs=t,this.spec=e||Yn}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);return s.deleted||s.pos<=n.pos?null:new Zn(n.pos-r,s.pos-r,this)}valid(t,e){let r,{index:i,offset:n}=t.content.findIndex(e.from);return n==e.from&&!(r=t.child(i)).isText&&n+r.nodeSize==e.to}eq(t){return this==t||t instanceof Gn&&Vn(this.attrs,t.attrs)&&Vn(this.spec,t.spec)}destroy(){}}class Zn{constructor(t,e,r){this.from=t,this.to=e,this.type=r}copy(t,e){return new Zn(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 Zn(t,t,new Hn(e,r))}static inline(t,e,r,i){return new Zn(t,e,new Wn(r,i))}static node(t,e,r,i){return new Zn(t,e,new Gn(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof Wn}get widget(){return this.type instanceof Hn}}const Kn=[],Yn={};class Xn{constructor(t,e){this.local=t.length?t:Kn,this.children=e.length?e:Kn}static create(t,e){return e.length?ns(e,t,0,Yn):Qn}find(t,e,r){let i=[];return this.findInner(null==t?0:t,null==e?1e9:e,i,0,r),i}findInner(t,e,r,i,n){for(let s=0;s<this.local.length;s++){let o=this.local[s];o.from<=e&&o.to>=t&&(!n||n(o.spec))&&r.push(o.copy(o.from+i,o.to+i))}for(let s=0;s<this.children.length;s+=3)if(this.children[s]<e&&this.children[s+1]>t){let o=this.children[s]+1;this.children[s+2].findInner(t-o,e-o,r,i+o,n)}}map(t,e,r){return this==Qn||0==t.maps.length?this:this.mapInner(t,e,0,0,r||Yn)}mapInner(t,e,r,i,n){let s;for(let o=0;o<this.local.length;o++){let l=this.local[o].map(t,r,i);l&&l.type.valid(e,l)?(s||(s=[])).push(l):n.onRemove&&n.onRemove(this.local[o].spec)}return this.children.length?function(t,e,r,i,n,s,o){let l=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 o=s-n-(r-t);for(let n=0;n<l.length;n+=3){let s=l[n+1];if(s<0||t>s+e-i)continue;let u=l[n]+e-i;r>=u?l[n+1]=t<=u?-2:-1:t>=e&&o&&(l[n]+=o,l[n+1]+=o)}i+=o})),e=r.maps[t].map(e,-1)}let u=!1;for(let e=0;e<l.length;e+=3)if(l[e+1]<0){if(-2==l[e+1]){u=!0,l[e+1]=-1;continue}let h=r.map(t[e]+s),a=h-n;if(a<0||a>=i.content.size){u=!0;continue}let f=r.map(t[e+1]+s,-1)-n,{index:c,offset:d}=i.content.findIndex(a),p=i.maybeChild(c);if(p&&d==a&&d+p.nodeSize==f){let i=l[e+2].mapInner(r,p,h+1,t[e]+s+1,o);i!=Qn?(l[e]=a,l[e+1]=f,l[e+2]=i):(l[e+1]=-2,u=!0)}else u=!0}if(u){let u=function(t,e,r,i,n,s,o){function l(t,e){for(let s=0;s<t.local.length;s++){let l=t.local[s].map(i,n,e);l?r.push(l):o.onRemove&&o.onRemove(t.local[s].spec)}for(let r=0;r<t.children.length;r+=3)l(t.children[r+2],t.children[r]+e+1)}for(let r=0;r<t.length;r+=3)-1==t[r+1]&&l(t[r+2],e[r]+s+1);return r}(l,t,e,r,n,s,o),h=ns(u,i,0,o);e=h.local;for(let t=0;t<l.length;t+=3)l[t+1]<0&&(l.splice(t,3),t-=3);for(let t=0,e=0;t<h.children.length;t+=3){let r=h.children[t];for(;e<l.length&&l[e]<r;)e+=3;l.splice(e,0,h.children[t],h.children[t+1],h.children[t+2])}}return new Xn(e.sort(ss),l)}(this.children,s||[],t,e,r,i,n):s?new Xn(s.sort(ss),Kn):Qn}add(t,e){return e.length?this==Qn?Xn.create(t,e):this.addInner(t,e,0):this}addInner(t,e,r){let i,n=0;t.forEach(((t,s)=>{let o,l=s+r;if(o=rs(e,t,l)){for(i||(i=this.children.slice());n<i.length&&i[n]<s;)n+=3;i[n]==s?i[n+2]=i[n+2].addInner(t,o,l+1):i.splice(n,0,s,s+t.nodeSize,ns(o,t,l+1,Yn)),n+=3}}));let s=es(n?is(e):e,-r);for(let e=0;e<s.length;e++)s[e].type.valid(t,s[e])||s.splice(e--,1);return new Xn(s.length?this.local.concat(s).sort(ss):this.local,i||this.children)}remove(t){return 0==t.length||this==Qn?this: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,s=r[i]+e,o=r[i+1]+e;for(let e,r=0;r<t.length;r++)(e=t[r])&&e.from>s&&e.to<o&&(t[r]=null,(n||(n=[])).push(e));if(!n)continue;r==this.children&&(r=this.children.slice());let l=r[i+2].removeInner(n,s+1);l!=Qn?r[i+2]=l:(r.splice(i,3),i-=3)}if(i.length)for(let r,n=0;n<t.length;n++)if(r=t[n])for(let t=0;t<i.length;t++)i[t].eq(r,e)&&(i==this.local&&(i=this.local.slice()),i.splice(t--,1));return r==this.children&&i==this.local?this:i.length||r.length?new Xn(i,r):Qn}forChild(t,e){if(this==Qn)return this;if(e.isLeaf)return Xn.empty;let r,i;for(let e=0;e<this.children.length;e+=3)if(this.children[e]>=t){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 Wn){let t=Math.max(n,e.from)-n,r=Math.min(s,e.to)-n;t<r&&(i||(i=[])).push(e.copy(t,r))}}if(i){let t=new Xn(i.sort(ss),Kn);return r?new ts([t,r]):t}return r||Qn}eq(t){if(this==t)return!0;if(!(t instanceof Xn)||this.local.length!=t.local.length||this.children.length!=t.children.length)return!1;for(let e=0;e<this.local.length;e++)if(!this.local[e].eq(t.local[e]))return!1;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!1;return!0}locals(t){return ls(this.localsInner(t))}localsInner(t){if(this==Qn)return Kn;if(t.inlineContent||!this.local.some(Wn.is))return this.local;let e=[];for(let t=0;t<this.local.length;t++)this.local[t].type instanceof Wn||e.push(this.local[t]);return e}forEachSet(t){t(this)}}Xn.empty=new Xn([],[]),Xn.removeOverlap=ls;const Qn=Xn.empty;class ts{constructor(t){this.members=t}map(t,e){const r=this.members.map((r=>r.map(t,e,Yn)));return ts.from(r)}forChild(t,e){if(e.isLeaf)return Xn.empty;let r=[];for(let i=0;i<this.members.length;i++){let n=this.members[i].forChild(t,e);n!=Qn&&(n instanceof ts?r=r.concat(n.members):r.push(n))}return ts.from(r)}eq(t){if(!(t instanceof ts)||t.members.length!=this.members.length)return!1;for(let e=0;e<this.members.length;e++)if(!this.members[e].eq(t.members[e]))return!1;return!0}locals(t){let e,r=!0;for(let i=0;i<this.members.length;i++){let n=this.members[i].localsInner(t);if(n.length)if(e){r&&(e=e.slice(),r=!1);for(let t=0;t<n.length;t++)e.push(n[t])}else e=n}return e?ls(r?e:e.sort(ss)):Kn}static from(t){switch(t.length){case 0:return Qn;case 1:return t[0];default:return new ts(t.every((t=>t instanceof Xn))?t:t.reduce(((t,e)=>t.concat(e instanceof Xn?e:e.members)),[]))}}forEachSet(t){for(let e=0;e<this.members.length;e++)this.members[e].forEachSet(t)}}function es(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 Zn(n.from+e,n.to+e,n.type))}return r}function rs(t,e,r){if(e.isLeaf)return null;let i=r+e.nodeSize,n=null;for(let e,s=0;s<t.length;s++)(e=t[s])&&e.from>r&&e.to<i&&((n||(n=[])).push(e),t[s]=null);return n}function is(t){let e=[];for(let r=0;r<t.length;r++)null!=t[r]&&e.push(t[r]);return e}function ns(t,e,r,i){let n=[],s=!1;e.forEach(((e,o)=>{let l=rs(t,e,o+r);if(l){s=!0;let t=ns(l,e,r+o+1,i);t!=Qn&&n.push(o,o+e.nodeSize,t)}}));let o=es(s?is(t):t,-r).sort(ss);for(let t=0;t<o.length;t++)o[t].type.valid(e,o[t])||(i.onRemove&&i.onRemove(o[t].spec),o.splice(t--,1));return o.length||n.length?new Xn(o,n):Qn}function ss(t,e){return t.from-e.from||t.to-e.to}function ls(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){s.from<i.to&&(e==t&&(e=t.slice()),e[r]=i.copy(i.from,s.from),us(e,n,i.copy(s.from,i.to)));break}s.to!=i.to&&(e==t&&(e=t.slice()),e[n]=s.copy(s.from,i.to),us(e,n+1,s.copy(i.to,s.to)))}}return e}function us(t,e,r){for(;e<t.length&&ss(r,t[e])>0;)e++;t.splice(e,0,r)}function hs(t){let e=[];return t.someProp("decorations",(r=>{let i=r(t.state);i&&i!=Qn&&e.push(i)})),t.cursorWrapper&&e.push(Xn.create(t.state.doc,[t.cursorWrapper.deco])),ts.from(e)}const as={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},fs=Nr&&_r<=11;class cs{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 ds{constructor(t,e){this.view=t,this.handleDOMChange=e,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new cs,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver((t=>{for(let e=0;e<t.length;e++)this.queue.push(t[e]);Nr&&_r<=11&&t.some((t=>"childList"==t.type&&t.removedNodes.length||"characterData"==t.type&&t.oldValue.length>t.target.nodeValue.length))?this.flushSoon():this.flush()})),fs&&(this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout((()=>{this.flushingSoon=-1,this.flush()}),20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,as)),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()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout((()=>this.suppressingSelectionUpdates=!1),50)}onSelectionChange(){if(Hi(this.view)){if(this.suppressingSelectionUpdates)return ji(this.view);if(Nr&&_r<=11&&!this.view.state.selection.empty){let t=this.view.domSelectionRange();if(t.focusNode&&Dr(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!0;let e,r=new Set;for(let e=t.focusNode;e;e=wr(e))r.add(e);for(let i=t.anchorNode;i;i=wr(i))if(r.has(i)){e=i;break}let i=e&&this.view.docView.nearestDesc(e);return i&&i.ignoreMutation({type:"selection",target:3==e.nodeType?e.parentNode:e})?(this.setCurSelection(),!0):void 0}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();e.length&&(this.queue=[]);let r=t.domSelectionRange(),i=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&Hi(t)&&!this.ignoreSelectionChange(r),n=-1,s=-1,o=!1,l=[];if(t.editable)for(let t=0;t<e.length;t++){let r=this.registerMutation(e[t],l);r&&(n=n<0?r.from:Math.min(r.from,n),s=s<0?r.to:Math.max(r.to,s),r.typeOver&&(o=!0))}if(Tr&&l.length){let e=l.filter((t=>"BR"==t.nodeName));if(2==e.length){let[t,r]=e;t.parentNode&&t.parentNode.parentNode==r.parentNode?r.remove():t.remove()}else{let{focusNode:r}=this.currentSelection;for(let i of e){let e=i.parentNode;!e||"LI"!=e.nodeName||r&&bs(t,r)==e||i.remove()}}}let u=null;n<0&&i&&t.input.lastFocus>Date.now()-200&&Math.max(t.input.lastTouch,t.input.lastClick.time)<Date.now()-300&&Mr(r)&&(u=Ti(t))&&u.eq(Ge.near(t.state.doc.resolve(0),1))?(t.input.lastFocus=0,ji(t),this.currentSelection.set(r),t.scrollToSelection()):(n>-1||i)&&(n>-1&&(t.docView.markDirty(n,s),function(t){if(!ps.has(t)&&(ps.set(t,null),-1!==["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace))){if(t.requiresGeckoHackNode=Tr,ms)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."),ms=!0}}(t)),this.handleDOMChange(n,s,o,l),t.docView&&t.docView.dirty?t.updateState(t.state):this.currentSelection.eq(r)||ji(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("attributes"==t.type&&(r==this.view.docView||"contenteditable"==t.attributeName||"style"==t.attributeName&&!t.oldValue&&!t.target.getAttribute("style")))return null;if(!r||r.ignoreMutation(t))return null;if("childList"==t.type){for(let r=0;r<t.addedNodes.length;r++){let i=t.addedNodes[r];e.push(i),3==i.nodeType&&(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(Nr&&_r<=11&&t.addedNodes.length)for(let e=0;e<t.addedNodes.length;e++){let{previousSibling:r,nextSibling:s}=t.addedNodes[e];(!r||Array.prototype.indexOf.call(t.addedNodes,r)<0)&&(i=r),(!s||Array.prototype.indexOf.call(t.addedNodes,s)<0)&&(n=s)}let s=i&&i.parentNode==t.target?br(i)+1:0,o=r.localPosFromDOM(t.target,s,-1),l=n&&n.parentNode==t.target?br(n):t.target.childNodes.length;return{from:o,to:r.localPosFromDOM(t.target,l,1)}}return"attributes"==t.type?{from:r.posAtStart-r.border,to:r.posAtEnd+r.border}:(this.lastChangedTextNode=t.target,{from:r.posAtStart,to:r.posAtEnd,typeOver:t.target.nodeValue==t.oldValue})}}let ps=new WeakMap,ms=!1;function gs(t,e){let r=e.startContainer,i=e.startOffset,n=e.endContainer,s=e.endOffset,o=t.domAtPos(t.state.selection.anchor);return Dr(o.node,o.offset,n,s)&&([r,i,n,s]=[n,s,r,i]),{anchorNode:r,anchorOffset:i,focusNode:n,focusOffset:s}}function bs(t,e){for(let r=e.parentNode;r&&r!=t.dom;r=r.parentNode){let e=t.docView.nearestDesc(r,!0);if(e&&e.node.isBlock)return r}return null}function ws(t){let e=t.pmViewDesc;if(e)return e.parseRule();if("BR"==t.nodeName&&t.parentNode){if(Ir&&/^(ul|ol)$/i.test(t.parentNode.nodeName)){let t=document.createElement("div");return t.appendChild(document.createElement("li")),{skip:t}}if(t.parentNode.lastChild==t||Ir&&/^(tr|table)$/i.test(t.parentNode.nodeName))return{ignore:!0}}else if("IMG"==t.nodeName&&t.getAttribute("mark-placeholder"))return{ignore:!0};return null}const vs=/^(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 ks(t,e,r){return Math.max(r.anchor,r.head)>e.content.size?null:Vi(t,e.resolve(r.anchor),e.resolve(r.head))}function Ds(t,e,r){let i=t.depth,n=e?t.end():t.pos;for(;i>0&&(e||t.indexAfter(i)==t.node(i).childCount);)i--,n++,e=!1;if(r){let e=t.node(i).maybeChild(t.indexAfter(i));for(;e&&!e.isLeaf;)e=e.firstChild,n++}return n}function ys(t){if(2!=t.length)return!1;let e=t.charCodeAt(0),r=t.charCodeAt(1);return e>=56320&&e<=57343&&r>=55296&&r<=56319}class Es{constructor(t,e){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new yn,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=e,this.state=e.state,this.directPlugins=e.plugins||[],this.directPlugins.forEach(Cs),this.dispatch=this.dispatch.bind(this),this.dom=t&&t.mount||document.createElement("div"),t&&(t.appendChild?t.appendChild(this.dom):"function"==typeof t?t(this.dom):t.mount&&(this.mounted=!0)),this.editable=Ms(this),Fs(this),this.nodeViews=As(this),this.docView=ki(this.state.doc,xs(this),hs(this),this.dom,this),this.domObserver=new ds(this,((t,e,r,i)=>function(t,e,r,i,n){let s=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let e=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,r=Ti(t,e);if(r&&!t.state.selection.eq(r)){if(jr&&Ur&&13===t.input.lastKeyCode&&Date.now()-100<t.input.lastKeyCodeTime&&t.someProp("handleKeyDown",(e=>e(t,Ar(13,"Enter")))))return;let i=t.state.tr.setSelection(r);"pointer"==e?i.setMeta("pointer",!0):"key"==e&&i.scrollIntoView(),s&&i.setMeta("composition",s),t.dispatch(i)}return}let o=t.state.doc.resolve(e),l=o.sharedDepth(r);e=o.before(l+1),r=t.state.doc.resolve(r).after(l+1);let u,h,a=t.state.selection,f=function(t,e,r){let i,{node:n,fromOffset:s,toOffset:o,from:l,to:u}=t.docView.parseRange(e,r),h=t.domSelectionRange(),a=h.anchorNode;if(a&&t.dom.contains(1==a.nodeType?a:a.parentNode)&&(i=[{node:a,offset:h.anchorOffset}],Mr(h)||i.push({node:h.focusNode,offset:h.focusOffset})),jr&&8===t.input.lastKeyCode)for(let t=o;t>s;t--){let e=n.childNodes[t-1],r=e.pmViewDesc;if("BR"==e.nodeName&&!r){o=t;break}if(!r||r.size)break}let f=t.state.doc,c=t.someProp("domParser")||Ut.fromSchema(t.state.schema),d=f.resolve(l),p=null,m=c.parse(n,{topNode:d.parent,topMatch:d.parent.contentMatchAt(d.index()),topOpen:!0,from:s,to:o,preserveWhitespace:"pre"!=d.parent.type.whitespace||"full",findPositions:i,ruleFromNode:ws,context:d});if(i&&null!=i[0].pos){let t=i[0].pos,e=i[1]&&i[1].pos;null==e&&(e=t),p={anchor:t+l,head:e+l}}return{doc:m,sel:p,from:l,to:u}}(t,e,r),c=t.state.doc,d=c.slice(f.from,f.to);8===t.input.lastKeyCode&&Date.now()-100<t.input.lastKeyCodeTime?(u=t.state.selection.to,h="end"):(u=t.state.selection.from,h="start"),t.input.lastKeyCode=null;let p=function(t,e,r,i,n){let s=t.findDiffStart(e,r);if(null==s)return null;let{a:o,b:l}=t.findDiffEnd(e,r+t.size,r+e.size);if("end"==n&&(i-=o+Math.max(0,s-Math.min(o,l))-s),o<s&&t.size<e.size){let t=i<=s&&i>=o?s-i:0;s-=t,s&&s<e.size&&ys(e.textBetween(s-1,s+1))&&(s+=t?1:-1),l=s+(l-o),o=s}else if(l<s){let e=i<=s&&i>=l?s-i:0;s-=e,s&&s<t.size&&ys(t.textBetween(s-1,s+1))&&(s+=e?1:-1),o=s+(o-l),l=s}return{start:s,endA:o,endB:l}}(d.content,f.doc.content,f.from,u,h);if(p&&t.input.domChangeCount++,(Pr&&t.input.lastIOSEnter>Date.now()-225||Ur)&&n.some((t=>1==t.nodeType&&!vs.test(t.nodeName)))&&(!p||p.endA>=p.endB)&&t.someProp("handleKeyDown",(e=>e(t,Ar(13,"Enter")))))return void(t.input.lastIOSEnter=0);if(!p){if(!(i&&a instanceof Xe&&!a.empty&&a.$head.sameParent(a.$anchor))||t.composing||f.sel&&f.sel.anchor!=f.sel.head){if(f.sel){let e=ks(t,t.state.doc,f.sel);if(e&&!e.eq(t.state.selection)){let r=t.state.tr.setSelection(e);s&&r.setMeta("composition",s),t.dispatch(r)}}return}p={start:a.from,endA:a.to,endB:a.to}}t.state.selection.from<t.state.selection.to&&p.start==p.endB&&t.state.selection instanceof Xe&&(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: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)),Nr&&_r<=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,g=f.doc.resolveNoCache(p.start-f.from),b=f.doc.resolveNoCache(p.endB-f.from),w=c.resolve(p.start),v=g.sameParent(b)&&g.parent.inlineContent&&w.end()>=p.endA;if((Pr&&t.input.lastIOSEnter>Date.now()-225&&(!v||n.some((t=>"DIV"==t.nodeName||"P"==t.nodeName)))||!v&&g.pos<f.doc.content.size&&!g.sameParent(b)&&(m=Ge.findFrom(f.doc.resolve(g.pos+1),1,!0))&&m.head==b.pos)&&t.someProp("handleKeyDown",(e=>e(t,Ar(13,"Enter")))))return void(t.input.lastIOSEnter=0);if(t.state.selection.anchor>p.start&&function(t,e,r,i,n){if(r-e<=n.pos-i.pos||Ds(i,!0,!1)<n.pos)return!1;let s=t.resolve(e);if(!i.parent.isTextblock){let t=s.nodeAfter;return null!=t&&r==e+t.nodeSize}if(s.parentOffset<s.parent.content.size||!s.parent.isTextblock)return!1;let o=t.resolve(Ds(s,!0,!0));return!(!o.parent.isTextblock||o.pos>r||Ds(o,!0,!1)<r)&&i.parent.content.cut(i.parentOffset).eq(o.parent.content)}(c,p.start,p.endA,g,b)&&t.someProp("handleKeyDown",(e=>e(t,Ar(8,"Backspace")))))return void(Ur&&jr&&t.domObserver.suppressSelectionUpdates());jr&&p.endB==p.start&&(t.input.lastChromeDelete=Date.now()),Ur&&!v&&g.start()!=b.start()&&0==b.parentOffset&&g.depth==b.depth&&f.sel&&f.sel.anchor==f.sel.head&&f.sel.head==p.endA&&(p.endB-=2,b=f.doc.resolveNoCache(p.endB-f.from),setTimeout((()=>{t.someProp("handleKeyDown",(function(e){return e(t,Ar(13,"Enter"))}))}),20));let k,D,y,E=p.start,x=p.endA;if(v)if(g.pos==b.pos)Nr&&_r<=11&&0==g.parentOffset&&(t.domObserver.suppressSelectionUpdates(),setTimeout((()=>ji(t)),20)),k=t.state.tr.delete(E,x),D=c.resolve(p.start).marksAcross(c.resolve(p.endA));else if(p.endA==p.endB&&(y=function(t,e){let r,i,n,s=t.firstChild.marks,o=e.firstChild.marks,l=s,u=o;for(let t=0;t<o.length;t++)l=o[t].removeFromSet(l);for(let t=0;t<s.length;t++)u=s[t].removeFromSet(u);if(1==l.length&&0==u.length)i=l[0],r="add",n=t=>t.mark(i.addToSet(t.marks));else{if(0!=l.length||1!=u.length)return null;i=u[0],r="remove",n=t=>t.mark(i.removeFromSet(t.marks))}let h=[];for(let t=0;t<e.childCount;t++)h.push(n(e.child(t)));if(Q.from(h).eq(t))return{mark:i,type:r}}(g.parent.content.cut(g.parentOffset,b.parentOffset),w.parent.content.cut(w.parentOffset,p.endA-w.start()))))k=t.state.tr,"add"==y.type?k.addMark(E,x,y.mark):k.removeMark(E,x,y.mark);else if(g.parent.child(g.index()).isText&&g.index()==b.index()-(b.textOffset?0:1)){let e=g.parent.textBetween(g.parentOffset,b.parentOffset);if(t.someProp("handleTextInput",(r=>r(t,E,x,e))))return;k=t.state.tr.insertText(e,E,x)}if(k||(k=t.state.tr.replace(E,x,f.doc.slice(p.start-f.from,p.endB-f.from))),f.sel){let e=ks(t,k.doc,f.sel);e&&!(jr&&t.composing&&e.empty&&(p.start!=p.endB||t.input.lastChromeDelete<Date.now()-100)&&(e.head==E||e.head==k.mapping.map(x)-1)||Nr&&e.empty&&e.head==E)&&k.setSelection(e)}D&&k.ensureMarks(D),s&&k.setMeta("composition",s),t.dispatch(k.scrollIntoView())}(this,t,e,r,i))),this.domObserver.start(),function(t){for(let e in vn){let r=vn[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=e=>{!Mn(t,e)||Fn(t,e)||!t.editable&&e.type in kn||r(t,e)},Dn[e]?{passive:!0}:void 0)}Ir&&t.dom.addEventListener("input",(()=>null)),xn(t)}(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){t.handleDOMEvents!=this._props.handleDOMEvents&&xn(this);let e=this._props;this._props=t,t.plugins&&(t.plugins.forEach(Cs),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=!1,s=!1;t.storedMarks&&this.composing&&(jn(this),s=!0),this.state=t;let o=i.plugins!=t.plugins||this._props.plugins!=e.plugins;if(o||this._props.plugins!=e.plugins||this._props.nodeViews!=e.nodeViews){let t=As(this);(function(t,e){let r=0,i=0;for(let i in t){if(t[i]!=e[i])return!0;r++}for(let t in e)i++;return r!=i})(t,this.nodeViews)&&(this.nodeViews=t,n=!0)}(o||e.handleDOMEvents!=this._props.handleDOMEvents)&&xn(this),this.editable=Ms(this),Fs(this);let l=hs(this),u=xs(this),h=i.plugins==t.plugins||i.doc.eq(t.doc)?t.scrollToSelection>i.scrollToSelection?"to selection":"preserve":"reset",a=n||!this.docView.matchesNode(t.doc,u,l);!a&&t.selection.eq(i.selection)||(s=!0);let f="preserve"==h&&s&&null==this.dom.style.overflowAnchor&&function(t){let e,r,i=t.dom.getBoundingClientRect(),n=Math.max(0,i.top);for(let s=(i.left+i.right)/2,o=n+1;o<Math.min(innerHeight,i.bottom);o+=5){let i=t.root.elementFromPoint(s,o);if(!i||i==t.dom||!t.dom.contains(i))continue;let l=i.getBoundingClientRect();if(l.top>=n-20){e=i,r=l.top;break}}return{refDOM:e,refTop:r,stack:Yr(t.dom)}}(this);if(s){this.domObserver.stop();let e=a&&(Nr||jr)&&!this.composing&&!i.selection.empty&&!t.selection.empty&&function(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)}(i.selection,t.selection);if(a){let r=jr?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=function(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let r=function(t,e){for(;;){if(3==t.nodeType&&e)return t;if(1==t.nodeType&&e>0){if("false"==t.contentEditable)return null;e=xr(t=t.childNodes[e-1])}else{if(!t.parentNode||Fr(t))return null;e=br(t),t=t.parentNode}}}(e.focusNode,e.focusOffset),i=function(t,e){for(;;){if(3==t.nodeType&&e<t.nodeValue.length)return t;if(1==t.nodeType&&e<t.childNodes.length){if("false"==t.contentEditable)return null;t=t.childNodes[e],e=0}else{if(!t.parentNode||Fr(t))return null;e=br(t)+1,t=t.parentNode}}}(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;if(t.input.compositionNode==i){let t=r.pmViewDesc;if(t&&t.isText(r.nodeValue))return i}}return r||i}(this)),!n&&this.docView.update(t.doc,u,l,this)||(this.docView.updateOuterDeco(u),this.docView.destroy(),this.docView=ki(t.doc,u,l,this.dom,this)),r&&!this.trackWrites&&(e=!0)}e||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&function(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),r=t.domSelectionRange();return Dr(e.node,e.offset,r.anchorNode,r.anchorOffset)}(this))?ji(this,e):(Ji(this,t.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(i),(null===(r=this.dragging)||void 0===r?void 0:r.node)&&!i.doc.eq(t.doc)&&this.updateDraggedNode(this.dragging,i),"reset"==h?this.dom.scrollTop=0:"to selection"==h?this.scrollToSelection():f&&function({refDOM:t,refTop:e,stack:r}){let i=t?t.getBoundingClientRect().top:0;Xr(r,0==i?0:i-e)}(f)}scrollToSelection(){let t=this.domSelectionRange().focusNode;if(t&&this.dom.contains(1==t.nodeType?t:t.parentNode))if(this.someProp("handleScrollToSelection",(t=>t(this))));else if(this.state.selection instanceof tr){let e=this.docView.domAfterPos(this.state.selection.from);1==e.nodeType&&Kr(this,e.getBoundingClientRect(),t)}else Kr(this,this.coordsAtPos(this.state.selection.head,1),t)}destroyPluginViews(){let t;for(;t=this.pluginViews.pop();)t.destroy&&t.destroy()}updatePluginViews(t){if(t&&t.plugins==this.state.plugins&&this.directPlugins==this.prevDirectPlugins)for(let e=0;e<this.pluginViews.length;e++){let r=this.pluginViews[e];r.update&&r.update(this,t)}else{this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let t=0;t<this.directPlugins.length;t++){let e=this.directPlugins[t];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];e.spec.view&&this.pluginViews.push(e.spec.view(this))}}}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);(t>0&&this.state.doc.nodeAt(t))==r.node&&(i=t)}this.dragging=new Jn(t.slice,t.move,i<0?void 0:tr.create(this.state.doc,i))}someProp(t,e){let r,i=this._props&&this._props[t];if(null!=i&&(r=e?e(i):i))return r;for(let i=0;i<this.directPlugins.length;i++){let n=this.directPlugins[i].props[t];if(null!=n&&(r=e?e(n):n))return r}let n=this.state.plugins;if(n)for(let i=0;i<n.length;i++){let s=n[i].props[t];if(null!=s&&(r=e?e(s):s))return r}}hasFocus(){if(Nr){let t=this.root.activeElement;if(t==this.dom)return!0;if(!t||!this.dom.contains(t))return!1;for(;t&&this.dom!=t&&this.dom.contains(t);){if("false"==t.contentEditable)return!1;t=t.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&function(t){if(t.setActive)return t.setActive();if(Qr)return t.focus(Qr);let e=Yr(t);t.focus(null==Qr?{get preventScroll(){return Qr={preventScroll:!0},!0}}:void 0),Qr||(Qr=!1,Xr(e,0))}(this.dom),ji(this),this.domObserver.start()}get root(){let t=this._root;if(null==t)for(let t=this.dom.parentNode;t;t=t.parentNode)if(9==t.nodeType||11==t.nodeType&&t.host)return t.getSelection||(Object.getPrototypeOf(t).getSelection=()=>t.ownerDocument.getSelection()),this._root=t;return t||document}updateRoot(){this._root=null}posAtCoords(t){return ii(this,t)}coordsAtPos(t,e=1){return li(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(null==i)throw new RangeError("DOM position not inside the editor");return i}endOfTextblock(t,e){return function(t,e,r){return ci==e&&di==r?pi:(ci=e,di=r,pi="up"==r||"down"==r?function(t,e,r){let i=e.selection,n="up"==r?i.$from:i.$to;return ai(t,e,(()=>{let{node:e}=t.docView.domFromPos(n.pos,"up"==r?-1:1);for(;;){let r=t.docView.nearestDesc(e,!0);if(!r)break;if(r.node.isBlock){e=r.contentDOM||r.dom;break}e=r.dom.parentNode}let i=li(t,n.pos,1);for(let t=e.firstChild;t;t=t.nextSibling){let e;if(1==t.nodeType)e=t.getClientRects();else{if(3!=t.nodeType)continue;e=kr(t,0,t.nodeValue.length).getClientRects()}for(let t=0;t<e.length;t++){let n=e[t];if(n.bottom>n.top+1&&("up"==r?i.top-n.top>2*(n.bottom-i.top):n.bottom-i.bottom>2*(i.bottom-n.top)))return!1}}return!0}))}(t,e,r):function(t,e,r){let{$head:i}=e.selection;if(!i.parent.isTextblock)return!1;let n=i.parentOffset,s=!n,o=n==i.parent.content.size,l=t.domSelection();return l?fi.test(i.parent.textContent)&&l.modify?ai(t,e,(()=>{let{focusNode:e,focusOffset:n,anchorNode:s,anchorOffset:o}=t.domSelectionRange(),u=l.caretBidiLevel;l.modify("move",r,"character");let h=i.depth?t.docView.domAfterPos(i.before()):t.dom,{focusNode:a,focusOffset:f}=t.domSelectionRange(),c=a&&!h.contains(1==a.nodeType?a:a.parentNode)||e==a&&n==f;try{l.collapse(s,o),e&&(e!=s||n!=o)&&l.extend&&l.extend(e,n)}catch(t){}return null!=u&&(l.caretBidiLevel=u),c})):"left"==r||"backward"==r?s:o:i.pos==i.start()||i.pos==i.end()}(t,e,r))}(this,e||this.state,t)}pasteHTML(t,e){return Pn(this,"",t,!1,e||new ClipboardEvent("paste"))}pasteText(t,e){return Pn(this,t,null,!0,e||new ClipboardEvent("paste"))}destroy(){this.docView&&(function(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)}(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],hs(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,vr=null)}get isDestroyed(){return null==this.docView}dispatchEvent(t){return function(t,e){Fn(t,e)||!vn[e.type]||!t.editable&&e.type in kn||vn[e.type](t,e)}(this,t)}dispatch(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))}domSelectionRange(){let t=this.domSelection();return t?Ir&&11===this.root.nodeType&&function(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}(this.dom.ownerDocument)==this.dom&&function(t,e){if(e.getComposedRanges){let r=e.getComposedRanges(t.root)[0];if(r)return gs(t,r)}let r;function i(t){t.preventDefault(),t.stopImmediatePropagation(),r=t.getTargetRanges()[0]}return t.dom.addEventListener("beforeinput",i,!0),document.execCommand("indent"),t.dom.removeEventListener("beforeinput",i,!0),r?gs(t,r):null}(this,t)||t:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}function xs(t){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(t.editable),t.someProp("attributes",(r=>{if("function"==typeof r&&(r=r(t.state)),r)for(let t in r)"class"==t?e.class+=" "+r[t]:"style"==t?e.style=(e.style?e.style+";":"")+r[t]:e[t]||"contenteditable"==t||"nodeName"==t||(e[t]=String(r[t]))})),e.translate||(e.translate="no"),[Zn.node(0,t.state.doc.content.size,e)]}function Fs(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:Zn.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function Ms(t){return!t.someProp("editable",(e=>!1===e(t.state)))}function As(t){let e=Object.create(null);function r(t){for(let r in t)Object.prototype.hasOwnProperty.call(e,r)||(e[r]=t[r])}return t.someProp("nodeViews",r),t.someProp("markViews",r),e}function Cs(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 Ss=["p",0],Os=["blockquote",0],$s=["hr"],Bs=["pre",["code",0]],Rs=["br"],Ns=["em",0],_s=["strong",0],Ts=["code",0],zs=new Lt({nodes:{doc:{content:"block+"},paragraph:{content:"inline*",group:"block",parseDOM:[{tag:"p"}],toDOM:()=>Ss},blockquote:{content:"block+",group:"block",defining:!0,parseDOM:[{tag:"blockquote"}],toDOM:()=>Os},horizontal_rule:{group:"block",parseDOM:[{tag:"hr"}],toDOM:()=>$s},heading:{attrs:{level:{default:1,validate:"number"}},content:"inline*",group:"block",defining:!0,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=>["h"+t.attrs.level,0]},code_block:{content:"text*",marks:"",group:"block",code:!0,defining:!0,parseDOM:[{tag:"pre",preserveWhitespace:"full"}],toDOM:()=>Bs},text:{group:"inline"},image:{inline:!0,attrs:{src:{validate:"string"},alt:{default:null,validate:"string|null"},title:{default:null,validate:"string|null"}},group:"inline",draggable:!0,parseDOM:[{tag:"img[src]",getAttrs:t=>({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:!0,group:"inline",selectable:!1,parseDOM:[{tag:"br"}],toDOM:()=>Rs}},marks:{link:{attrs:{href:{validate:"string"},title:{default:null,validate:"string|null"}},inclusive:!1,parseDOM:[{tag:"a[href]",getAttrs:t=>({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=>"em"==t.type.name}],toDOM:()=>Ns},strong:{parseDOM:[{tag:"strong"},{tag:"b",getAttrs:t=>"normal"!=t.style.fontWeight&&null},{style:"font-weight=400",clearMark:t=>"strong"==t.type.name},{style:"font-weight",getAttrs:t=>/^(bold(er)?|[5-9]\d{2,})$/.test(t)&&null}],toDOM:()=>_s},code:{code:!0,parseDOM:[{tag:"code"}],toDOM:()=>Ts}}}),js=["ol",0],qs=["ul",0],Is=["li",0],Ps={attrs:{order:{default:1}},parseDOM:[{tag:"ol",getAttrs:t=>({order:t.hasAttribute("start")?+t.getAttribute("start"):1})}],toDOM:t=>1==t.attrs.order?js:["ol",{start:t.attrs.order},0]},Ls={parseDOM:[{tag:"ul"}],toDOM:()=>qs},Js={parseDOM:[{tag:"li"}],toDOM:()=>Is,defining:!0};function Us(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 Vs(t,e=null){return function(r,i){let{$from:n,$to:s}=r.selection,o=n.blockRange(s),l=!1,u=o;if(!o)return!1;if(o.depth>=2&&n.node(o.depth-1).type.compatibleContent(t)&&0==o.startIndex){if(0==n.index(o.depth-1))return!1;let t=r.doc.resolve(o.start-2);u=new Dt(t,t,o.depth),o.endIndex<o.parent.childCount&&(o=new Dt(n,r.doc.resolve(s.end(o.depth)),o.depth)),l=!0}let h=xe(u,t,e,o);return!!h&&(i&&i(function(t,e,r,i,n){let s=Q.empty;for(let t=r.length-1;t>=0;t--)s=Q.from(r[t].type.create(r[t].attrs,s));t.step(new ve(e.start-(i?2:0),e.end,e.start,e.end,new st(s,0,0),r.length,!0));let o=0;for(let t=0;t<r.length;t++)r[t].type==n&&(o=t+1);let l=r.length-o,u=e.start+r.length-(i?2:0),h=e.parent;for(let r=e.startIndex,i=e.endIndex,n=!0;r<i;r++,n=!1)!n&&Ce(t.doc,u,l)&&(t.split(u,l),u+=2*l),u+=h.child(r).nodeSize;return t}(r.tr,o,h,l,t).scrollIntoView()),!0)}}for(var Hs={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:"'"},Ws={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Gs="undefined"!=typeof navigator&&/Mac/.test(navigator.platform),Zs="undefined"!=typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),Ks=0;Ks<10;Ks++)Hs[48+Ks]=Hs[96+Ks]=String(Ks);for(Ks=1;Ks<=24;Ks++)Hs[Ks+111]="F"+Ks;for(Ks=65;Ks<=90;Ks++)Hs[Ks]=String.fromCharCode(Ks+32),Ws[Ks]=String.fromCharCode(Ks);for(var Ys in Hs)Ws.hasOwnProperty(Ys)||(Ws[Ys]=Hs[Ys]);const Xs="undefined"!=typeof navigator&&/Mac|iP(hone|[oa]d)/.test(navigator.platform);function Qs(t){let e,r,i,n,s=t.split(/-(?!$)/),o=s[s.length-1];"Space"==o&&(o=" ");for(let t=0;t<s.length-1;t++){let o=s[t];if(/^(cmd|meta|m)$/i.test(o))n=!0;else if(/^a(lt)?$/i.test(o))e=!0;else if(/^(c|ctrl|control)$/i.test(o))r=!0;else if(/^s(hift)?$/i.test(o))i=!0;else{if(!/^mod$/i.test(o))throw new Error("Unrecognized modifier name: "+o);Xs?n=!0:r=!0}}return e&&(o="Alt-"+o),r&&(o="Ctrl-"+o),n&&(o="Meta-"+o),i&&(o="Shift-"+o),o}function to(t,e,r=!0){return e.altKey&&(t="Alt-"+t),e.ctrlKey&&(t="Ctrl-"+t),e.metaKey&&(t="Meta-"+t),r&&e.shiftKey&&(t="Shift-"+t),t}function eo(t){return new dr({props:{handleKeyDown:ro(t)}})}function ro(t){let e=function(t){let e=Object.create(null);for(let r in t)e[Qs(r)]=t[r];return e}(t);return function(t,r){let i,n=function(t){var e=!(Gs&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||Zs&&t.shiftKey&&t.key&&1==t.key.length||"Unidentified"==t.key)&&t.key||(t.shiftKey?Ws:Hs)[t.keyCode]||t.key||"Unidentified";return"Esc"==e&&(e="Escape"),"Del"==e&&(e="Delete"),"Left"==e&&(e="ArrowLeft"),"Up"==e&&(e="ArrowUp"),"Right"==e&&(e="ArrowRight"),"Down"==e&&(e="ArrowDown"),e}(r),s=e[to(n,r)];if(s&&s(t.state,t.dispatch,t))return!0;if(1==n.length&&" "!=n){if(r.shiftKey){let i=e[to(n,r,!1)];if(i&&i(t.state,t.dispatch,t))return!0}if((r.shiftKey||r.altKey||r.metaKey||n.charCodeAt(0)>127)&&(i=Hs[r.keyCode])&&i!=n){let n=e[to(i,r)];if(n&&n(t.state,t.dispatch,t))return!0}}return!1}}var io=200,no=function(){};no.prototype.append=function(t){return t.length?(t=no.from(t),!this.length&&t||t.length<io&&this.leafAppend(t)||this.length<io&&t.leafPrepend(this)||this.appendInner(t)):this},no.prototype.prepend=function(t){return t.length?no.from(t).append(this):this},no.prototype.appendInner=function(t){return new oo(this,t)},no.prototype.slice=function(t,e){return void 0===t&&(t=0),void 0===e&&(e=this.length),t>=e?no.empty:this.sliceInner(Math.max(0,t),Math.min(this.length,e))},no.prototype.get=function(t){if(!(t<0||t>=this.length))return this.getInner(t)},no.prototype.forEach=function(t,e,r){void 0===e&&(e=0),void 0===r&&(r=this.length),e<=r?this.forEachInner(t,e,r,0):this.forEachInvertedInner(t,e,r,0)},no.prototype.map=function(t,e,r){void 0===e&&(e=0),void 0===r&&(r=this.length);var i=[];return this.forEach((function(e,r){return i.push(t(e,r))}),e,r),i},no.from=function(t){return t instanceof no?t:t&&t.length?new so(t):no.empty};var so=function(t){function e(e){t.call(this),this.values=e}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var r={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(t,r){return 0==t&&r==this.length?this:new e(this.values.slice(t,r))},e.prototype.getInner=function(t){return this.values[t]},e.prototype.forEachInner=function(t,e,r,i){for(var n=e;n<r;n++)if(!1===t(this.values[n],i+n))return!1},e.prototype.forEachInvertedInner=function(t,e,r,i){for(var n=e-1;n>=r;n--)if(!1===t(this.values[n],i+n))return!1},e.prototype.leafAppend=function(t){if(this.length+t.length<=io)return new e(this.values.concat(t.flatten()))},e.prototype.leafPrepend=function(t){if(this.length+t.length<=io)return new e(t.flatten().concat(this.values))},r.length.get=function(){return this.values.length},r.depth.get=function(){return 0},Object.defineProperties(e.prototype,r),e}(no);no.empty=new so([]);var oo=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}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(t){return t<this.left.length?this.left.get(t):this.right.get(t-this.left.length)},e.prototype.forEachInner=function(t,e,r,i){var n=this.left.length;return!(e<n&&!1===this.left.forEachInner(t,e,Math.min(r,n),i))&&!(r>n&&!1===this.right.forEachInner(t,Math.max(e-n,0),Math.min(this.length,r)-n,i+n))&&void 0},e.prototype.forEachInvertedInner=function(t,e,r,i){var n=this.left.length;return!(e>n&&!1===this.right.forEachInvertedInner(t,e-n,Math.max(r,n)-n,i+n))&&!(r<n&&!1===this.left.forEachInvertedInner(t,Math.min(e,n),r,i))&&void 0},e.prototype.sliceInner=function(t,e){if(0==t&&e==this.length)return this;var r=this.left.length;return e<=r?this.left.slice(t,e):t>=r?this.right.slice(t-r,e-r):this.left.slice(t,r).append(this.right.slice(0,e-r))},e.prototype.leafAppend=function(t){var r=this.right.leafAppend(t);if(r)return new e(this.left,r)},e.prototype.leafPrepend=function(t){var r=this.left.leafPrepend(t);if(r)return new e(r,this.right)},e.prototype.appendInner=function(t){return this.left.depth>=Math.max(this.right.depth,t.depth)+1?new e(this.left,new e(this.right,t)):new e(this,t)},e}(no);class lo{constructor(t,e){this.items=t,this.eventCount=e}popEvent(t,e){if(0==this.eventCount)return null;let r,i,n=this.items.length;for(;;n--)if(this.items.get(n-1).selection){--n;break}e&&(r=this.remapping(n,this.items.length),i=r.maps.length);let s,o,l=t.tr,u=[],h=[];return this.items.forEach(((t,e)=>{if(!t.step)return r||(r=this.remapping(n,e+1),i=r.maps.length),i--,void h.push(t);if(r){h.push(new uo(t.map));let e,n=t.step.map(r.slice(i));n&&l.maybeStep(n).doc&&(e=l.mapping.maps[l.mapping.maps.length-1],u.push(new uo(e,void 0,void 0,u.length+h.length))),i--,e&&r.appendMap(e,i)}else l.maybeStep(t.step);return t.selection?(s=r?t.selection.map(r.slice(i)):t.selection,o=new lo(this.items.slice(0,n).append(h.reverse().concat(u)),this.eventCount-1),!1):void 0}),this.items.length,0),{remaining:o,transform:l,selection:s}}addTransform(t,e,r,i){let n=[],s=this.eventCount,o=this.items,l=!i&&o.length?o.get(o.length-1):null;for(let r=0;r<t.steps.length;r++){let u,h=t.steps[r].invert(t.docs[r]),a=new uo(t.mapping.maps[r],h,e);(u=l&&l.merge(a))&&(a=u,r?n.pop():o=o.slice(0,o.length-1)),n.push(a),e&&(s++,e=void 0),i||(l=a)}let u=s-r.depth;return u>ao&&(o=function(t,e){let r;return t.forEach(((t,i)=>{if(t.selection&&0==e--)return r=i,!1})),t.slice(r)}(o,u),s-=u),new lo(o.append(n),s)}remapping(t,e){let r=new he;return this.items.forEach(((e,i)=>{r.appendMap(e.map,null!=e.mirrorOffset&&i-e.mirrorOffset>=t?r.maps.length-e.mirrorOffset:void 0)}),t,e),r}addMaps(t){return 0==this.eventCount?this:new lo(this.items.append(t.map((t=>new uo(t)))),this.eventCount)}rebased(t,e){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-e),n=t.mapping,s=t.steps.length,o=this.eventCount;this.items.forEach((t=>{t.selection&&o--}),i);let l=e;this.items.forEach((e=>{let i=n.getMirror(--l);if(null==i)return;s=Math.min(s,i);let u=n.maps[i];if(e.step){let s=t.steps[i].invert(t.docs[i]),h=e.selection&&e.selection.map(n.slice(l+1,i));h&&o++,r.push(new uo(u,s,h))}else r.push(new uo(u))}),i);let u=[];for(let t=e;t<s;t++)u.push(new uo(n.maps[t]));let h=this.items.slice(0,i).append(u).append(r),a=new lo(h,o);return a.emptyItemCount()>500&&(a=a.compress(this.items.length-r.length)),a}emptyItemCount(){let t=0;return this.items.forEach((e=>{e.step||t++})),t}compress(t=this.items.length){let e=this.remapping(0,t),r=e.maps.length,i=[],n=0;return this.items.forEach(((s,o)=>{if(o>=t)i.push(s),s.selection&&n++;else if(s.step){let t=s.step.map(e.slice(r)),o=t&&t.getMap();if(r--,o&&e.appendMap(o,r),t){let l=s.selection&&s.selection.map(e.slice(r));l&&n++;let u,h=new uo(o.invert(),t,l),a=i.length-1;(u=i.length&&i[a].merge(h))?i[a]=u:i.push(h)}}else s.map&&r--}),this.items.length,0),new lo(no.from(i.reverse()),n)}}lo.empty=new lo(no.empty,0);class uo{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 uo(e.getMap().invert(),e,this.selection)}}}class ho{constructor(t,e,r,i,n){this.done=t,this.undone=e,this.prevRanges=r,this.prevTime=i,this.prevComposition=n}}const ao=20;function fo(t){let e=[];return t.forEach(((t,r,i,n)=>e.push(i,n))),e}function co(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);n<=s&&r.push(n,s)}return r}function po(t,e,r,i){let n=bo(e),s=wo.get(e).spec.config,o=(i?t.undone:t.done).popEvent(e,n);if(!o)return;let l=o.selection.resolve(o.transform.doc),u=(i?t.done:t.undone).addTransform(o.transform,e.selection.getBookmark(),s,n),h=new ho(i?u:o.remaining,i?o.remaining:u,null,0,-1);r(o.transform.setSelection(l).setMeta(wo,{redo:i,historyState:h}).scrollIntoView())}let mo=!1,go=null;function bo(t){let e=t.plugins;if(go!=e){mo=!1,go=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){mo=!0;break}}return mo}const wo=new gr("history"),vo=new gr("closeHistory");const ko=(t,e)=>{let r=wo.getState(t);return!(!r||0==r.done.eventCount||(e&&po(r,t,e,!1),0))},Do=(t,e)=>{let r=wo.getState(t);return!(!r||0==r.undone.eventCount||(e&&po(r,t,e,!0),0))},yo=(t,e)=>!t.selection.empty&&(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function Eo(t,e,r=!1){for(let i=t;i;i="start"==e?i.firstChild:i.lastChild){if(i.isTextblock)return!0;if(r&&1!=i.childCount)return!1}return!1}function xo(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 Fo(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 Mo=(t,e)=>{let r,i=t.selection,n=i instanceof tr;if(n){if(i.node.isTextblock||!Se(t.doc,i.from))return!1;r=i.from}else if(r=$e(t.doc,i.from,-1),null==r)return!1;if(e){let i=t.tr.join(r);n&&i.setSelection(tr.create(i.doc,r-t.doc.resolve(r).nodeBefore.nodeSize)),e(i.scrollIntoView())}return!0},Ao=(t,e)=>{let r,i=t.selection;if(i instanceof tr){if(i.node.isTextblock||!Se(t.doc,i.to))return!1;r=i.to}else if(r=$e(t.doc,i.to,1),null==r)return!1;return e&&e(t.tr.join(r).scrollIntoView()),!0},Co=(t,e)=>{let{$from:r,$to:i}=t.selection,n=r.blockRange(i),s=n&&Ee(n);return null!=s&&(e&&e(t.tr.lift(n,s).scrollIntoView()),!0)};function So(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 Oo=(t,e)=>{let{$head:r,$anchor:i}=t.selection;if(!r.parent.type.spec.code||!r.sameParent(i))return!1;let n=r.node(-1),s=r.indexAfter(-1),o=So(n.contentMatchAt(s));if(!o||!n.canReplaceWith(s,s,o))return!1;if(e){let i=r.after(),n=t.tr.replaceWith(i,i,o.createAndFill());n.setSelection(Ge.near(n.doc.resolve(i),1)),e(n.scrollIntoView())}return!0},$o=(t,e)=>{let r,{$from:i,to:n}=t.selection,s=i.sharedDepth(n);return 0!=s&&(r=i.before(s),e&&e(t.tr.setSelection(tr.create(t.doc,r))),!0)};function Bo(t,e,r){let i,n,s=e.nodeBefore,o=e.nodeAfter;if(s.type.spec.isolating||o.type.spec.isolating)return!1;if(function(t,e,r){let i=e.nodeBefore,n=e.nodeAfter,s=e.index();return!(!(i&&n&&i.type.compatibleContent(n.type))||(!i.content.size&&e.parent.canReplace(s-1,s)?(r&&r(t.tr.delete(e.pos-i.nodeSize,e.pos).scrollIntoView()),0):!e.parent.canReplace(s,s+1)||!n.isTextblock&&!Se(t.doc,e.pos)||(r&&r(t.tr.clearIncompatible(e.pos,i.type,i.contentMatchAt(i.childCount)).join(e.pos).scrollIntoView()),0)))}(t,e,r))return!0;let l=e.parent.canReplace(e.index(),e.index()+1);if(l&&(i=(n=s.contentMatchAt(s.childCount)).findWrapping(o.type))&&n.matchType(i[0]||o.type).validEnd){if(r){let n=e.pos+o.nodeSize,l=Q.empty;for(let t=i.length-1;t>=0;t--)l=Q.from(i[t].create(null,l));l=Q.from(s.copy(l));let u=t.tr.step(new ve(e.pos-1,n,e.pos,n,new st(l,1,0),i.length,!0)),h=n+2*i.length;Se(u.doc,h)&&u.join(h),r(u.scrollIntoView())}return!0}let u=Ge.findFrom(e,1),h=u&&u.$from.blockRange(u.$to),a=h&&Ee(h);if(null!=a&&a>=e.depth)return r&&r(t.tr.lift(h,a).scrollIntoView()),!0;if(l&&Eo(o,"start",!0)&&Eo(s,"end")){let i=s,n=[];for(;n.push(i),!i.isTextblock;)i=i.lastChild;let l=o,u=1;for(;!l.isTextblock;l=l.firstChild)u++;if(i.canReplace(i.childCount,i.childCount,l.content)){if(r){let i=Q.empty;for(let t=n.length-1;t>=0;t--)i=Q.from(n[t].copy(i));r(t.tr.step(new ve(e.pos-n.length,e.pos+o.nodeSize,e.pos+u,e.pos+o.nodeSize-u,new st(i,n.length,0),0,!0)).scrollIntoView())}return!0}}return!1}function Ro(t){return function(e,r){let i=e.selection,n=t<0?i.$from:i.$to,s=n.depth;for(;n.node(s).isInline;){if(!s)return!1;s--}return!!n.node(s).isTextblock&&(r&&r(e.tr.setSelection(Xe.create(e.doc,t<0?n.start(s):n.end(s)))),!0)}}const No=Ro(-1),_o=Ro(1);function To(t,e=null){return function(r,i){let{$from:n,$to:s}=r.selection,o=n.blockRange(s),l=o&&xe(o,t,e);return!!l&&(i&&i(r.tr.wrap(o,l).scrollIntoView()),!0)}}function zo(t,e=null){return function(r,i){let n=!1;for(let i=0;i<r.selection.ranges.length&&!n;i++){let{$from:{pos:s},$to:{pos:o}}=r.selection.ranges[i];r.doc.nodesBetween(s,o,((i,s)=>{if(n)return!1;if(i.isTextblock&&!i.hasMarkup(t,e))if(i.type==t)n=!0;else{let e=r.doc.resolve(s),i=e.index();n=e.parent.canReplaceWith(i,i+1,t)}}))}if(!n)return!1;if(i){let n=r.tr;for(let i=0;i<r.selection.ranges.length;i++){let{$from:{pos:s},$to:{pos:o}}=r.selection.ranges[i];n.setBlockType(s,o,t,e)}i(n.scrollIntoView())}return!0}}function jo(t,e=null){return function(r,i){let{empty:n,$cursor:s,ranges:o}=r.selection;if(n&&!s||!function(t,e,r){for(let i=0;i<e.length;i++){let{$from:n,$to:s}=e[i],o=0==n.depth&&t.inlineContent&&t.type.allowsMarkType(r);if(t.nodesBetween(n.pos,s.pos,(t=>{if(o)return!1;o=t.inlineContent&&t.type.allowsMarkType(r)})),o)return!0}return!1}(r.doc,o,t))return!1;if(i)if(s)t.isInSet(r.storedMarks||s.marks())?i(r.tr.removeStoredMark(t)):i(r.tr.addStoredMark(t.create(e)));else{let n=!1,s=r.tr;for(let e=0;!n&&e<o.length;e++){let{$from:i,$to:s}=o[e];n=r.doc.rangeHasMark(i.pos,s.pos,t)}for(let r=0;r<o.length;r++){let{$from:i,$to:l}=o[r];if(n)s.removeMark(i.pos,l.pos,t);else{let r=i.pos,n=l.pos,o=i.nodeAfter,u=l.nodeBefore,h=o&&o.isText?/^\s*/.exec(o.text)[0].length:0,a=u&&u.isText?/\s*$/.exec(u.text)[0].length:0;r+h<n&&(r+=h,n-=a),s.addMark(r,n,t.create(e))}}i(s.scrollIntoView())}return!0}}function qo(...t){return function(e,r,i){for(let n=0;n<t.length;n++)if(t[n](e,r,i))return!0;return!1}}let Io=qo(yo,((t,e,r)=>{let i=function(t,e){let{$cursor:r}=t.selection;return!r||(e?!e.endOfTextblock("backward",t):r.parentOffset>0)?null:r}(t,r);if(!i)return!1;let n=xo(i);if(!n){let r=i.blockRange(),n=r&&Ee(r);return null!=n&&(e&&e(t.tr.lift(r,n).scrollIntoView()),!0)}let s=n.nodeBefore;if(!s.type.spec.isolating&&Bo(t,n,e))return!0;if(0==i.parent.content.size&&(Eo(s,"end")||tr.isSelectable(s))){let r=Re(t.doc,i.before(),i.after(),st.empty);if(r&&r.slice.size<r.to-r.from){if(e){let i=t.tr.step(r);i.setSelection(Eo(s,"end")?Ge.findFrom(i.doc.resolve(i.mapping.map(n.pos,-1)),-1):tr.create(i.doc,n.pos-s.nodeSize)),e(i.scrollIntoView())}return!0}}return!(!s.isAtom||n.depth!=i.depth-1||(e&&e(t.tr.delete(n.pos-s.nodeSize,n.pos).scrollIntoView()),0))}),((t,e,r)=>{let{$head:i,empty:n}=t.selection,s=i;if(!n)return!1;if(i.parent.isTextblock){if(r?!r.endOfTextblock("backward",t):i.parentOffset>0)return!1;s=xo(i)}let o=s&&s.nodeBefore;return!(!o||!tr.isSelectable(o)||(e&&e(t.tr.setSelection(tr.create(t.doc,s.pos-o.nodeSize)).scrollIntoView()),0))})),Po=qo(yo,((t,e,r)=>{let i=function(t,e){let{$cursor:r}=t.selection;return!r||(e?!e.endOfTextblock("forward",t):r.parentOffset<r.parent.content.size)?null:r}(t,r);if(!i)return!1;let n=Fo(i);if(!n)return!1;let s=n.nodeAfter;if(Bo(t,n,e))return!0;if(0==i.parent.content.size&&(Eo(s,"start")||tr.isSelectable(s))){let r=Re(t.doc,i.before(),i.after(),st.empty);if(r&&r.slice.size<r.to-r.from){if(e){let i=t.tr.step(r);i.setSelection(Eo(s,"start")?Ge.findFrom(i.doc.resolve(i.mapping.map(n.pos)),1):tr.create(i.doc,i.mapping.map(n.pos))),e(i.scrollIntoView())}return!0}}return!(!s.isAtom||n.depth!=i.depth-1||(e&&e(t.tr.delete(n.pos,n.pos+s.nodeSize).scrollIntoView()),0))}),((t,e,r)=>{let{$head:i,empty:n}=t.selection,s=i;if(!n)return!1;if(i.parent.isTextblock){if(r?!r.endOfTextblock("forward",t):i.parentOffset<i.parent.content.size)return!1;s=Fo(i)}let o=s&&s.nodeAfter;return!(!o||!tr.isSelectable(o)||(e&&e(t.tr.setSelection(tr.create(t.doc,s.pos)).scrollIntoView()),0))}));const Lo={Enter:qo(((t,e)=>{let{$head:r,$anchor:i}=t.selection;return!(!r.parent.type.spec.code||!r.sameParent(i)||(e&&e(t.tr.insertText("\n").scrollIntoView()),0))}),((t,e)=>{let r=t.selection,{$from:i,$to:n}=r;if(r instanceof rr||i.parent.inlineContent||n.parent.inlineContent)return!1;let s=So(n.parent.contentMatchAt(n.indexAfter()));if(!s||!s.isTextblock)return!1;if(e){let r=(!i.parentOffset&&n.index()<n.parent.childCount?i:n).pos,o=t.tr.insert(r,s.createAndFill());o.setSelection(Xe.create(o.doc,r+1)),e(o.scrollIntoView())}return!0}),((t,e)=>{let{$cursor:r}=t.selection;if(!r||r.parent.content.size)return!1;if(r.depth>1&&r.after()!=r.end(-1)){let i=r.before();if(Ce(t.doc,i))return e&&e(t.tr.split(i).scrollIntoView()),!0}let i=r.blockRange(),n=i&&Ee(i);return null!=n&&(e&&e(t.tr.lift(i,n).scrollIntoView()),!0)}),((t,e)=>{let{$from:r,$to:i}=t.selection;if(t.selection instanceof tr&&t.selection.node.isBlock)return!(!r.parentOffset||!Ce(t.doc,r.pos)||(e&&e(t.tr.split(r.pos).scrollIntoView()),0));if(!r.parent.isBlock)return!1;if(e){let n=i.parentOffset==i.parent.content.size,s=t.tr;(t.selection instanceof Xe||t.selection instanceof rr)&&s.deleteSelection();let o=0==r.depth?null:So(r.node(-1).contentMatchAt(r.indexAfter(-1))),l=n&&o?[{type:o}]:void 0,u=Ce(s.doc,s.mapping.map(r.pos),1,l);if(l||u||!Ce(s.doc,s.mapping.map(r.pos),1,o?[{type:o}]:void 0)||(o&&(l=[{type:o}]),u=!0),u&&(s.split(s.mapping.map(r.pos),1,l),!n&&!r.parentOffset&&r.parent.type!=o)){let t=s.mapping.map(r.before()),e=s.doc.resolve(t);o&&r.node(-1).canReplaceWith(e.index(),e.index()+1,o)&&s.setNodeMarkup(s.mapping.map(r.before()),o)}e(s.scrollIntoView())}return!0})),"Mod-Enter":Oo,Backspace:Io,"Mod-Backspace":Io,"Shift-Backspace":Io,Delete:Po,"Mod-Delete":Po,"Mod-a":(t,e)=>(e&&e(t.tr.setSelection(new rr(t.doc))),!0)},Jo={"Ctrl-h":Lo.Backspace,"Alt-Backspace":Lo["Mod-Backspace"],"Ctrl-d":Lo.Delete,"Ctrl-Alt-Backspace":Lo["Mod-Delete"],"Alt-Delete":Lo["Mod-Delete"],"Alt-d":Lo["Mod-Delete"],"Ctrl-a":No,"Ctrl-e":_o};for(let t in Lo)Jo[t]=Lo[t];const Uo=("undefined"!=typeof navigator?/Mac|iP(hone|[oa]d)/.test(navigator.platform):"undefined"!=typeof os&&os.platform&&"darwin"==os.platform())?Jo:Lo;function Vo(t={}){return new dr({view:e=>new Ho(e,t)})}class Ho{constructor(t,e){var r;this.editorView=t,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=null!==(r=e.width)&&void 0!==r?r:1,this.color=!1===e.color?void 0:e.color||"black",this.class=e.class,this.handlers=["dragover","dragend","drop","dragleave"].map((e=>{let r=t=>{this[e](t)};return t.dom.addEventListener(e,r),{name:e,handler:r}}))}destroy(){this.handlers.forEach((({name:t,handler:e})=>this.editorView.dom.removeEventListener(t,e)))}update(t,e){null!=this.cursorPos&&e.doc!=t.state.doc&&(this.cursorPos>t.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(t){t!=this.cursorPos&&(this.cursorPos=t,null==t?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let t,e=this.editorView.state.doc.resolve(this.cursorPos),r=!e.parent.inlineContent;if(r){let r=e.nodeBefore,i=e.nodeAfter;if(r||i){let e=this.editorView.nodeDOM(this.cursorPos-(r?r.nodeSize:0));if(e){let n=e.getBoundingClientRect(),s=r?n.bottom:n.top;r&&i&&(s=(s+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2),t={left:n.left,right:n.right,top:s-this.width/2,bottom:s+this.width/2}}}}if(!t){let e=this.editorView.coordsAtPos(this.cursorPos);t={left:e.left-this.width/2,right:e.left+this.width/2,top:e.top,bottom:e.bottom}}let i,n,s=this.editorView.dom.offsetParent;if(this.element||(this.element=s.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",r),this.element.classList.toggle("prosemirror-dropcursor-inline",!r),!s||s==document.body&&"static"==getComputedStyle(s).position)i=-pageXOffset,n=-pageYOffset;else{let t=s.getBoundingClientRect();i=t.left-s.scrollLeft,n=t.top-s.scrollTop}this.element.style.left=t.left-i+"px",this.element.style.top=t.top-n+"px",this.element.style.width=t.right-t.left+"px",this.element.style.height=t.bottom-t.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}),r=e&&e.inside>=0&&this.editorView.state.doc.nodeAt(e.inside),i=r&&r.type.spec.disableDropCursor,n="function"==typeof i?i(this.editorView,e,t):i;if(e&&!n){let t=e.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let e=Be(this.editorView.state.doc,t,this.editorView.dragging.slice);null!=e&&(t=e)}this.setCursor(t),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(t){t.target!=this.editorView.dom&&this.editorView.dom.contains(t.relatedTarget)||this.setCursor(null)}}class Wo extends Ge{constructor(t){super(t,t)}map(t,e){let r=t.resolve(e.map(this.head));return Wo.valid(r)?new Wo(r):Ge.near(r)}content(){return st.empty}eq(t){return t instanceof Wo&&t.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(t,e){if("number"!=typeof e.pos)throw new RangeError("Invalid input for GapCursor.fromJSON");return new Wo(t.resolve(e.pos))}getBookmark(){return new Go(this.anchor)}static valid(t){let e=t.parent;if(e.isTextblock||!function(t){for(let e=t.depth;e>=0;e--){let r=t.index(e),i=t.node(e);if(0!=r)for(let t=i.child(r-1);;t=t.lastChild){if(0==t.childCount&&!t.inlineContent||t.isAtom||t.type.spec.isolating)return!0;if(t.inlineContent)return!1}else if(i.type.spec.isolating)return!0}return!0}(t)||!function(t){for(let e=t.depth;e>=0;e--){let r=t.indexAfter(e),i=t.node(e);if(r!=i.childCount)for(let t=i.child(r);;t=t.firstChild){if(0==t.childCount&&!t.inlineContent||t.isAtom||t.type.spec.isolating)return!0;if(t.inlineContent)return!1}else if(i.type.spec.isolating)return!0}return!0}(t))return!1;let r=e.type.spec.allowGapCursor;if(null!=r)return r;let i=e.contentMatchAt(t.index()).defaultType;return i&&i.isTextblock}static findGapCursorFrom(t,e,r=!1){t:for(;;){if(!r&&Wo.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}if(0==r)return null;i+=e;let o=t.doc.resolve(i);if(Wo.valid(o))return o}for(;;){let s=e>0?n.firstChild:n.lastChild;if(!s){if(n.isAtom&&!n.isText&&!tr.isSelectable(n)){t=t.doc.resolve(i+n.nodeSize*e),r=!1;continue t}break}n=s,i+=e;let o=t.doc.resolve(i);if(Wo.valid(o))return o}return null}}}Wo.prototype.visible=!1,Wo.findFrom=Wo.findGapCursorFrom,Ge.jsonID("gapcursor",Wo);class Go{constructor(t){this.pos=t}map(t){return new Go(t.map(this.pos))}resolve(t){let e=t.resolve(this.pos);return Wo.valid(e)?new Wo(e):Ge.near(e)}}const Zo=ro({ArrowLeft:Ko("horiz",-1),ArrowRight:Ko("horiz",1),ArrowUp:Ko("vert",-1),ArrowDown:Ko("vert",1)});function Ko(t,e){const r="vert"==t?e>0?"down":"up":e>0?"right":"left";return function(t,i,n){let s=t.selection,o=e>0?s.$to:s.$from,l=s.empty;if(s instanceof Xe){if(!n.endOfTextblock(r)||0==o.depth)return!1;l=!1,o=t.doc.resolve(e>0?o.after():o.before())}let u=Wo.findGapCursorFrom(o,e,l);return!!u&&(i&&i(t.tr.setSelection(new Wo(u))),!0)}}function Yo(t,e,r){if(!t||!t.editable)return!1;let i=t.state.doc.resolve(e);if(!Wo.valid(i))return!1;let n=t.posAtCoords({left:r.clientX,top:r.clientY});return!(n&&n.inside>-1&&tr.isSelectable(t.state.doc.nodeAt(n.inside))||(t.dispatch(t.state.tr.setSelection(new Wo(i))),0))}function Xo(t,e){if("insertCompositionText"!=e.inputType||!(t.state.selection instanceof Wo))return!1;let{$from:r}=t.state.selection,i=r.parent.contentMatchAt(r.index()).findWrapping(t.state.schema.nodes.text);if(!i)return!1;let n=Q.empty;for(let t=i.length-1;t>=0;t--)n=Q.from(i[t].createAndFill(null,n));let s=t.state.tr.replace(r.pos,r.pos,new st(n,0,0));return s.setSelection(Xe.near(s.doc.resolve(r.pos+1))),t.dispatch(s),!1}function Qo(t){if(!(t.selection instanceof Wo))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",Xn.create(t.doc,[Zn.widget(t.selection.head,e,{key:"gapcursor"})])}class tl{constructor(t,e,r={}){var i;this.match=t,this.match=t,this.handler="string"==typeof e?(i=e,function(t,e,r,n){let s=i;if(e[1]){let t=e[0].lastIndexOf(e[1]);s+=e[0].slice(t+e[1].length);let i=(r+=t)-n;i>0&&(s=e[0].slice(t-i,t)+s,r=n)}return t.tr.insertText(s,r,n)}):e,this.undoable=!1!==r.undoable,this.inCode=r.inCode||!1}}function el(t,e,r,i,n,s){if(t.composing)return!1;let o=t.state,l=o.doc.resolve(e),u=l.parent.textBetween(Math.max(0,l.parentOffset-500),l.parentOffset,null,"")+i;for(let h=0;h<n.length;h++){let a=n[h];if(l.parent.type.spec.code){if(!a.inCode)continue}else if("only"===a.inCode)continue;let f=a.match.exec(u),c=f&&a.handler(o,f,e-(f[0].length-i.length),r);if(c)return a.undoable&&c.setMeta(s,{transform:c,from:e,to:r,text:i}),t.dispatch(c),!0}return!1}const rl=(t,e)=>{let r=t.plugins;for(let i=0;i<r.length;i++){let n,s=r[i];if(s.spec.isInputRules&&(n=s.getState(t))){if(e){let r=t.tr,i=n.transform;for(let t=i.steps.length-1;t>=0;t--)r.step(i.steps[t].invert(i.docs[t]));if(n.text){let e=r.doc.resolve(n.from).marks();r.replaceWith(n.from,n.to,t.schema.text(n.text,e))}else r.delete(n.from,n.to);e(r)}return!0}}return!1},il=new tl(/--$/,"—"),nl=new tl(/\.\.\.$/,"…"),sl=[new tl(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,"“"),new tl(/"$/,"”"),new tl(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,"‘"),new tl(/'$/,"’")];function ol(t,e,r=null,i){return new tl(t,((t,n,s,o)=>{let l=r instanceof Function?r(n):r,u=t.tr.delete(s,o),h=u.doc.resolve(s).blockRange(),a=h&&xe(h,e,l);if(!a)return null;u.wrap(h,a);let f=u.doc.resolve(s-1).nodeBefore;return f&&f.type==e&&Se(u.doc,s-1)&&(!i||i(n,f))&&u.join(s-1),u}))}function ll(t,e,r=null){return new tl(t,((t,i,n,s)=>{let o=t.doc.resolve(n),l=r instanceof Function?r(i):r;return o.node(-1).canReplaceWith(o.index(-1),o.indexAfter(-1),e)?t.tr.delete(n,s).setBlockType(n,n,e,l):null}))}const ul="undefined"!=typeof navigator&&/Mac|iP(hone|[oa]d)/.test(navigator.platform);function hl(t,e){let r,i={};function n(t,r){if(e){let r=e[t];if(!1===r)return;r&&(t=r)}i[t]=r}if(n("Mod-z",ko),n("Shift-Mod-z",Do),n("Backspace",rl),ul||n("Mod-y",Do),n("Alt-ArrowUp",Mo),n("Alt-ArrowDown",Ao),n("Mod-BracketLeft",Co),n("Escape",$o),(r=t.marks.strong)&&(n("Mod-b",jo(r)),n("Mod-B",jo(r))),(r=t.marks.em)&&(n("Mod-i",jo(r)),n("Mod-I",jo(r))),(r=t.marks.code)&&n("Mod-`",jo(r)),(r=t.nodes.bullet_list)&&n("Shift-Ctrl-8",Vs(r)),(r=t.nodes.ordered_list)&&n("Shift-Ctrl-9",Vs(r)),(r=t.nodes.blockquote)&&n("Ctrl->",To(r)),r=t.nodes.hard_break){let t=r,e=qo(Oo,((e,r)=>(r&&r(e.tr.replaceSelectionWith(t.create()).scrollIntoView()),!0)));n("Mod-Enter",e),n("Shift-Enter",e),ul&&n("Ctrl-Enter",e)}var s;if((r=t.nodes.list_item)&&(n("Enter",(s=r,function(t,e){let{$from:r,$to:i,node:n}=t.selection;if(n&&n.isBlock||r.depth<2||!r.sameParent(i))return!1;let o=r.node(-1);if(o.type!=s)return!1;if(0==r.parent.content.size&&r.node(-1).childCount==r.indexAfter(-1)){if(3==r.depth||r.node(-3).type!=s||r.index(-2)!=r.node(-2).childCount-1)return!1;if(e){let i=Q.empty,n=r.index(-1)?1:r.index(-2)?2:3;for(let t=r.depth-n;t>=r.depth-3;t--)i=Q.from(r.node(t).copy(i));let o=r.indexAfter(-1)<r.node(-2).childCount?1:r.indexAfter(-2)<r.node(-3).childCount?2:3;i=i.append(Q.from(s.createAndFill()));let l=r.before(r.depth-(n-1)),u=t.tr.replace(l,r.after(-o),new st(i,4-n,0)),h=-1;u.doc.nodesBetween(l,u.doc.content.size,((t,e)=>{if(h>-1)return!1;t.isTextblock&&0==t.content.size&&(h=e+1)})),h>-1&&u.setSelection(Ge.near(u.doc.resolve(h))),e(u.scrollIntoView())}return!0}let l=i.pos==r.end()?o.contentMatchAt(0).defaultType:null,u=t.tr.delete(r.pos,i.pos),h=l?[null,{type:l}]:void 0;return!!Ce(u.doc,r.pos,2,h)&&(e&&e(u.split(r.pos,2,h).scrollIntoView()),!0)})),n("Mod-[",function(t){return function(e,r){let{$from:i,$to:n}=e.selection,s=i.blockRange(n,(e=>e.childCount>0&&e.firstChild.type==t));return!!s&&(!r||(i.node(s.depth-1).type==t?function(t,e,r,i){let n=t.tr,s=i.end,o=i.$to.end(i.depth);s<o&&(n.step(new ve(s-1,o,s,o,new st(Q.from(r.create(null,i.parent.copy())),1,0),1,!0)),i=new Dt(n.doc.resolve(i.$from.pos),n.doc.resolve(o),i.depth));const l=Ee(i);if(null==l)return!1;n.lift(i,l);let u=n.mapping.map(s,-1)-1;return Se(n.doc,u)&&n.join(u),e(n.scrollIntoView()),!0}(e,r,t,s):function(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),o=s.nodeAfter;if(i.mapping.map(r.end)!=r.start+s.nodeAfter.nodeSize)return!1;let l=0==r.startIndex,u=r.endIndex==n.childCount,h=s.node(-1),a=s.index(-1);if(!h.canReplace(a+(l?0:1),a+1,o.content.append(u?Q.empty:Q.from(n))))return!1;let f=s.pos,c=f+o.nodeSize;return i.step(new ve(f-(l?1:0),c+(u?1:0),f+1,c-1,new st((l?Q.empty:Q.from(n.copy(Q.empty))).append(u?Q.empty:Q.from(n.copy(Q.empty))),l?0:1,u?0:1),l?0:1)),e(i.scrollIntoView()),!0}(e,r,s)))}}(r)),n("Mod-]",function(t){return function(e,r){let{$from:i,$to:n}=e.selection,s=i.blockRange(n,(e=>e.childCount>0&&e.firstChild.type==t));if(!s)return!1;let o=s.startIndex;if(0==o)return!1;let l=s.parent,u=l.child(o-1);if(u.type!=t)return!1;if(r){let i=u.lastChild&&u.lastChild.type==l.type,n=Q.from(i?t.create():null),o=new st(Q.from(t.create(null,Q.from(l.type.create(null,n)))),i?3:1,0),h=s.start,a=s.end;r(e.tr.step(new ve(h-(i?3:1),a,h,a,o,1,!0)).scrollIntoView())}return!0}}(r))),(r=t.nodes.paragraph)&&n("Shift-Ctrl-0",zo(r)),(r=t.nodes.code_block)&&n("Shift-Ctrl-\\",zo(r)),r=t.nodes.heading)for(let t=1;t<=6;t++)n("Shift-Ctrl-"+t,zo(r,{level:t}));if(r=t.nodes.horizontal_rule){let t=r;n("Mod-_",((e,r)=>(r&&r(e.tr.replaceSelectionWith(t.create()).scrollIntoView()),!0)))}return i}function al(t){let e,r=sl.concat(nl,il);return(e=t.nodes.blockquote)&&r.push(ol(/^\s*>\s$/,e)),(e=t.nodes.ordered_list)&&r.push(ol(/^(\d+)\.\s$/,e,(t=>({order:+t[1]})),((t,e)=>e.childCount+e.attrs.order==+t[1]))),(e=t.nodes.bullet_list)&&r.push(function(t){return ol(/^\s*([-+*])\s$/,t)}(e)),(e=t.nodes.code_block)&&r.push(function(t){return ll(/^```$/,t)}(e)),(e=t.nodes.heading)&&r.push(function(t){return ll(new RegExp("^(#{1,6})\\s$"),t,(t=>({level:t[1].length})))}(e)),function({rules:t}){let e=new dr({state:{init:()=>null,apply(t,e){return t.getMeta(this)||(t.selectionSet||t.docChanged?null:e)}},props:{handleTextInput:(r,i,n,s)=>el(r,i,n,s,t,e),handleDOMEvents:{compositionend:r=>{setTimeout((()=>{let{$cursor:i}=r.state.selection;i&&el(r,i.pos,i.pos,"",t,e)}))}}},isInputRules:!0});return e}({rules:r})}function fl(t){let e=[al(t.schema),eo(hl(t.schema,t.mapKeys)),eo(Uo),Vo(),new dr({props:{decorations:Qo,createSelectionBetween:(t,e,r)=>e.pos==r.pos&&Wo.valid(r)?new Wo(r):null,handleClick:Yo,handleKeyDown:Zo,handleDOMEvents:{beforeinput:Xo}}})];return!1!==t.history&&e.push(function(t={}){return new dr({key:wo,state:{init:()=>new ho(lo.empty,lo.empty,null,0,-1),apply:(e,r,i)=>function(t,e,r,i){let n,s=r.getMeta(wo);if(s)return s.historyState;r.getMeta(vo)&&(t=new ho(t.done,t.undone,null,0,-1));let o=r.getMeta("appendedTransaction");if(0==r.steps.length)return t;if(o&&o.getMeta(wo))return o.getMeta(wo).redo?new ho(t.done.addTransform(r,void 0,i,bo(e)),t.undone,fo(r.mapping.maps[r.steps.length-1]),t.prevTime,t.prevComposition):new ho(t.done,t.undone.addTransform(r,void 0,i,bo(e)),null,t.prevTime,t.prevComposition);if(!1===r.getMeta("addToHistory")||o&&!1===o.getMeta("addToHistory"))return(n=r.getMeta("rebased"))?new ho(t.done.rebased(r,n),t.undone.rebased(r,n),co(t.prevRanges,r.mapping),t.prevTime,t.prevComposition):new ho(t.done.addMaps(r.mapping.maps),t.undone.addMaps(r.mapping.maps),co(t.prevRanges,r.mapping),t.prevTime,t.prevComposition);{let n=r.getMeta("composition"),s=0==t.prevTime||!o&&t.prevComposition!=n&&(t.prevTime<(r.time||0)-i.newGroupDelay||!function(t,e){if(!e)return!1;if(!t.docChanged)return!0;let r=!1;return t.mapping.maps[0].forEach(((t,i)=>{for(let n=0;n<e.length;n+=2)t<=e[n+1]&&i>=e[n]&&(r=!0)})),r}(r,t.prevRanges)),l=o?co(t.prevRanges,r.mapping):fo(r.mapping.maps[r.steps.length-1]);return new ho(t.done.addTransform(r,s?e.selection.getBookmark():void 0,i,bo(e)),lo.empty,l,r.time,null==n?t.prevComposition:n)}}(r,i,e,t)},config:t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},props:{handleDOMEvents:{beforeinput(t,e){let r=e.inputType,i="historyUndo"==r?ko:"historyRedo"==r?Do:null;return!!i&&(e.preventDefault(),i(t.state,t.dispatch))}}}})}()),e.concat(new dr({props:{attributes:{class:"ProseMirror-example-setup-style"}}}))}const cl=(t,e)=>{t.active=t=>{const{from:r,$from:i,to:n,empty:s}=t.selection;return s?!!e.isInSet(t.storedMarks||i.marks()):t.doc.rangeHasMark(r,n,e)}},dl=(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!0}}return!1}},pl=(t,e,r)=>{const i=t.marks[e];if(!i)throw new Error(`Mark "${e}" not found in schema`);const n=jo(i,ml(e,r));return cl(n,i),n},ml=(t,e)=>{if(t===s.Link&&e.href)return{href:e.href,target:gl(e.href)?"_blank":null}},gl=t=>!t.startsWith(window.location.origin),bl=(t,e,r={},i=!1)=>{const n=t.nodes[e],s=t.nodes.paragraph;return(t,e)=>{const{$from:o,$to:l}=t.selection,u=o.node(o.depth-1).type===n;return!!(t.selection instanceof Xe&&o.sameParent(o.doc.resolve(l.pos)))&&(o.parent.type===n?(e&&e(t.tr.setBlockType(o.pos,l.pos,s)),!0):u?Co(t,e):i?To(n,r)(t,e):zo(n,r)(t,e))}},wl=(t,e,r)=>{const i=t.nodes[e];if(!i)throw new Error(`Node type "${e}" not found in schema`);let n;return n=e===o.Heading&&r?bl(t,o.Heading,{level:r}):e===s.CodeBlock?bl(t,s.CodeBlock):zo(i),((t,e,r)=>{t.active=t=>{const{$from:i}=t.selection,n=i.node(i.depth);return!(!n||n.type.name!==e.name||e.name===o.Heading&&r&&n.attrs.level!==r)}})(n,i,r),n},vl=(t,e)=>{const r=t.nodes[e];if(!r)throw new Error(`List type "${e}" not found in schema`);const i=(t=>(e,r)=>{const{$from:i,$to:n}=e.selection,s=i.blockRange(n);if(!s)return!1;const o=s&&xe(s,t);if(o)return r&&r(e.tr.wrap(s,o).scrollIntoView()),!0;{const t=s&&Ee(s);return null!==t&&(r&&r(e.tr.lift(s,t).scrollIntoView()),!0)}})(r);return dl(i,r),i},kl={strong:pl,em:pl,underline:pl,strikethrough:pl,code:pl,link:(t,e,r)=>{const i=(e,i)=>{const{from:n,to:s}=e.selection,o=t.marks.link.create(h(r.href,r.href));if(n===s){const s=t.text(r.text||r.href,[o]);i(e.tr.insert(n,s))}else{const l=e.doc.textBetween(n,s," "),u=t.text(r.text||l,[o]);i(e.tr.replaceWith(n,s,u))}return!0};return cl(i,t.marks.link),i},headerlevel1:t=>wl(t,o.Heading,o.one),headerlevel2:t=>wl(t,o.Heading,o.two),headerlevel3:t=>wl(t,o.Heading,o.three),blockquote:t=>((t,e)=>{const r=t.nodes[e];if(!r)throw new Error(`Node type "${e}" not found in schema`);let i;return i=e===s.Blockquote?bl(t,s.Blockquote,{},!0):To(r),dl(i,r),i})(t,s.Blockquote),code_block:t=>wl(t,s.CodeBlock),ordered_list:t=>vl(t,s.OrderedList),bullet_list:t=>vl(t,s.BulletList)};class Dl{constructor(t){this.schema=t}getCommand(t,e){const r=kl[t];if(!r)throw new Error(`The Mark "${t}" is not supported`);return r(this.schema,t,e)}buildKeymap(){return{"Mod-B":this.getCommand(s.Bold),"Mod-I":this.getCommand(s.Italic),"Mod-Shift-1":this.getCommand(s.HeaderLevel1),"Mod-Shift-2":this.getCommand(s.HeaderLevel2),"Mod-Shift-3":this.getCommand(s.HeaderLevel3),"Mod-Shift-X":this.getCommand(s.Strikethrough),"Mod-`":this.getCommand(s.Code),"Mod-Shift-C":this.getCommand(s.CodeBlock)}}}const{mod:yl,shift:El}=/Macintosh|MacIntel|MacPPC|Mac68K/.test(navigator.userAgent)?{mod:"⌘",option:"⌥",shift:"⇧"}:{mod:"Ctrl",option:"Alt",shift:"Shift"},xl=[{value:s.Bold,text:"Bold",commandText:`${yl} B`,icon:"-lime-text-bold",iconOnly:!0,selected:!1},{value:s.Italic,text:"Italic",commandText:`${yl} I`,icon:"-lime-text-italic",iconOnly:!0,selected:!1},{value:s.Strikethrough,text:"Strikethrough",commandText:`${yl} ${El} X`,icon:"-lime-text-strikethrough",iconOnly:!0,selected:!1},{value:s.Link,text:"Link",icon:"-lime-text-link",iconOnly:!0},{separator:!0},{value:s.BulletList,text:"Bullet list",icon:"-lime-text-bulleted-list",iconOnly:!0,selected:!1},{value:s.OrderedList,text:"Numbered list",icon:"-lime-text-ordered-list",iconOnly:!0,selected:!1},{separator:!0},{value:s.HeaderLevel1,text:"Header 1",commandText:`${yl} ${El} 1`,icon:"-lime-text-h-heading-1",iconOnly:!0,selected:!1},{value:s.HeaderLevel2,text:"Header 2",commandText:`${yl} ${El} 2`,icon:"-lime-text-h-heading-2",iconOnly:!0,selected:!1},{value:s.HeaderLevel3,text:"Header 3",commandText:`${yl} ${El} 3`,icon:"-lime-text-h-heading-3",iconOnly:!0,selected:!1},{separator:!0},{value:s.Blockquote,text:"Blockquote",icon:"-lime-text-blockquote",iconOnly:!0,selected:!1},{separator:!0},{value:s.Code,text:"Code",commandText:`${yl} \``,icon:"-lime-text-code",iconOnly:!0,selected:!1},{value:s.CodeBlock,text:"Code Block",commandText:`${yl} ${El} C`,icon:"-lime-text-code-block",iconOnly:!0,selected:!1}],Fl=()=>Z(xl),Ml={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"},Al={};function Cl(t,e){"string"!=typeof e&&(e=Cl.defaultChars);const r=function(t){let e=Al[t];if(e)return e;e=Al[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}(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];else{if(192==(224&s)&&i+3<n){const r=parseInt(t.slice(i+4,i+6),16);if(128==(192&r)){const t=s<<6&1984|63&r;e+=t<128?"��":String.fromCharCode(t),i+=3;continue}}if(224==(240&s)&&i+6<n){const r=parseInt(t.slice(i+4,i+6),16),n=parseInt(t.slice(i+7,i+9),16);if(128==(192&r)&&128==(192&n)){const t=s<<12&61440|r<<6&4032|63&n;e+=t<2048||t>=55296&&t<=57343?"���":String.fromCharCode(t),i+=6;continue}}if(240==(248&s)&&i+9<n){const r=parseInt(t.slice(i+4,i+6),16),n=parseInt(t.slice(i+7,i+9),16),o=parseInt(t.slice(i+10,i+12),16);if(128==(192&r)&&128==(192&n)&&128==(192&o)){let t=s<<18&1835008|r<<12&258048|n<<6&4032|63&o;t<65536||t>1114111?e+="����":(t-=65536,e+=String.fromCharCode(55296+(t>>10),56320+(1023&t))),i+=9;continue}}e+="�"}}return e}))}Cl.defaultChars=";/?:@&=+$,#",Cl.componentChars="";const Sl={};function Ol(t,e,r){"string"!=typeof e&&(r=e,e=Ol.defaultChars),void 0===r&&(r=!0);const i=function(t){let e=Sl[t];if(e)return e;e=Sl[t]=[];for(let t=0;t<128;t++){const r=String.fromCharCode(t);/^[0-9a-z]$/i.test(r)?e.push(r):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}(e);let n="";for(let e=0,s=t.length;e<s;e++){const o=t.charCodeAt(e);if(r&&37===o&&e+2<s&&/^[0-9a-f]{2}$/i.test(t.slice(e+1,e+3)))n+=t.slice(e,e+3),e+=2;else if(o<128)n+=i[o];else if(o>=55296&&o<=57343){if(o>=55296&&o<=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"}else n+=encodeURIComponent(t[e])}return n}function $l(t){let e="";return e+=t.protocol||"",e+=t.slashes?"//":"",e+=t.auth?t.auth+"@":"",t.hostname&&-1!==t.hostname.indexOf(":")?e+="["+t.hostname+"]":e+=t.hostname||"",e+=t.port?":"+t.port:"",e+=t.pathname||"",e+=t.search||"",e+=t.hash||"",e}function Bl(){this.protocol=null,this.slashes=null,this.auth=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.pathname=null}Ol.defaultChars=";/?:@&=+$,-_.!~*'()#",Ol.componentChars="-_.!~*'()";const Rl=/^([a-z0-9.+-]+:)/i,Nl=/:[0-9]*$/,_l=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,Tl=["{","}","|","\\","^","`"].concat(["<",">",'"',"`"," ","\r","\n","\t"]),zl=["'"].concat(Tl),jl=["%","/","?",";","#"].concat(zl),ql=["/","?","#"],Il=/^[+a-z0-9A-Z_-]{0,63}$/,Pl=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,Ll={javascript:!0,"javascript:":!0},Jl={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0};function Ul(t,e){if(t&&t instanceof Bl)return t;const r=new Bl;return r.parse(t,e),r}Bl.prototype.parse=function(t,e){let r,i,n,s=t;if(s=s.trim(),!e&&1===t.split("#").length){const t=_l.exec(s);if(t)return this.pathname=t[1],t[2]&&(this.search=t[2]),this}let o=Rl.exec(s);if(o&&(o=o[0],r=o.toLowerCase(),this.protocol=o,s=s.substr(o.length)),(e||o||s.match(/^\/\/[^@\/]+@[^@\/]+/))&&(n="//"===s.substr(0,2),!n||o&&Ll[o]||(s=s.substr(2),this.slashes=!0)),!Ll[o]&&(n||o&&!Jl[o])){let t,e,r=-1;for(let t=0;t<ql.length;t++)i=s.indexOf(ql[t]),-1!==i&&(-1===r||i<r)&&(r=i);e=-1===r?s.lastIndexOf("@"):s.lastIndexOf("@",r),-1!==e&&(t=s.slice(0,e),s=s.slice(e+1),this.auth=t),r=-1;for(let t=0;t<jl.length;t++)i=s.indexOf(jl[t]),-1!==i&&(-1===r||i<r)&&(r=i);-1===r&&(r=s.length),":"===s[r-1]&&r--;const n=s.slice(0,r);s=s.slice(r),this.parseHost(n),this.hostname=this.hostname||"";const o="["===this.hostname[0]&&"]"===this.hostname[this.hostname.length-1];if(!o){const t=this.hostname.split(/\./);for(let e=0,r=t.length;e<r;e++){const r=t[e];if(r&&!r.match(Il)){let i="";for(let t=0,e=r.length;t<e;t++)r.charCodeAt(t)>127?i+="x":i+=r[t];if(!i.match(Il)){const i=t.slice(0,e),n=t.slice(e+1),o=r.match(Pl);o&&(i.push(o[1]),n.unshift(o[2])),n.length&&(s=n.join(".")+s),this.hostname=i.join(".");break}}}}this.hostname.length>255&&(this.hostname=""),o&&(this.hostname=this.hostname.substr(1,this.hostname.length-2))}const l=s.indexOf("#");-1!==l&&(this.hash=s.substr(l),s=s.slice(0,l));const u=s.indexOf("?");return-1!==u&&(this.search=s.substr(u),s=s.slice(0,u)),s&&(this.pathname=s),Jl[r]&&this.hostname&&!this.pathname&&(this.pathname=""),this},Bl.prototype.parseHost=function(t){let e=Nl.exec(t);e&&(e=e[0],":"!==e&&(this.port=e.substr(1)),t=t.substr(0,t.length-e.length)),t&&(this.hostname=t)};var Vl,Hl,Wl=Object.freeze({__proto__:null,decode:Cl,encode:Ol,format:$l,parse:Ul}),Gl=/[\0-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,Zl=/[\0-\x1F\x7F-\x9F]/,Kl=/[!-#%-\*,-\/:;\?@\[-\]_\{\}\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]/,Yl=/[\$\+<->\^`\|~\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]/,Xl=/[ \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000]/,Ql=Object.freeze({__proto__:null,Any:Gl,Cc:Zl,Cf:/[\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]/,P:Kl,S:Yl,Z:Xl});function tu(t){for(let e=1;e<t.length;e++)t[e][0]+=t[e-1][0]+1;return t}function eu(t){return"[object String]"===function(t){return Object.prototype.toString.call(t)}(t)}new Map(tu([[9,"&Tab;"],[0,"&NewLine;"],[22,"&excl;"],[0,"&quot;"],[0,"&num;"],[0,"&dollar;"],[0,"&percnt;"],[0,"&amp;"],[0,"&apos;"],[0,"&lpar;"],[0,"&rpar;"],[0,"&ast;"],[0,"&plus;"],[0,"&comma;"],[1,"&period;"],[0,"&sol;"],[10,"&colon;"],[0,"&semi;"],[0,{v:"&lt;",n:8402,o:"&nvlt;"}],[0,{v:"&equals;",n:8421,o:"&bne;"}],[0,{v:"&gt;",n:8402,o:"&nvgt;"}],[0,"&quest;"],[0,"&commat;"],[26,"&lbrack;"],[0,"&bsol;"],[0,"&rbrack;"],[0,"&Hat;"],[0,"&lowbar;"],[0,"&DiacriticalGrave;"],[5,{n:106,o:"&fjlig;"}],[20,"&lbrace;"],[0,"&verbar;"],[0,"&rbrace;"],[34,"&nbsp;"],[0,"&iexcl;"],[0,"&cent;"],[0,"&pound;"],[0,"&curren;"],[0,"&yen;"],[0,"&brvbar;"],[0,"&sect;"],[0,"&die;"],[0,"&copy;"],[0,"&ordf;"],[0,"&laquo;"],[0,"&not;"],[0,"&shy;"],[0,"&circledR;"],[0,"&macr;"],[0,"&deg;"],[0,"&PlusMinus;"],[0,"&sup2;"],[0,"&sup3;"],[0,"&acute;"],[0,"&micro;"],[0,"&para;"],[0,"&centerdot;"],[0,"&cedil;"],[0,"&sup1;"],[0,"&ordm;"],[0,"&raquo;"],[0,"&frac14;"],[0,"&frac12;"],[0,"&frac34;"],[0,"&iquest;"],[0,"&Agrave;"],[0,"&Aacute;"],[0,"&Acirc;"],[0,"&Atilde;"],[0,"&Auml;"],[0,"&angst;"],[0,"&AElig;"],[0,"&Ccedil;"],[0,"&Egrave;"],[0,"&Eacute;"],[0,"&Ecirc;"],[0,"&Euml;"],[0,"&Igrave;"],[0,"&Iacute;"],[0,"&Icirc;"],[0,"&Iuml;"],[0,"&ETH;"],[0,"&Ntilde;"],[0,"&Ograve;"],[0,"&Oacute;"],[0,"&Ocirc;"],[0,"&Otilde;"],[0,"&Ouml;"],[0,"&times;"],[0,"&Oslash;"],[0,"&Ugrave;"],[0,"&Uacute;"],[0,"&Ucirc;"],[0,"&Uuml;"],[0,"&Yacute;"],[0,"&THORN;"],[0,"&szlig;"],[0,"&agrave;"],[0,"&aacute;"],[0,"&acirc;"],[0,"&atilde;"],[0,"&auml;"],[0,"&aring;"],[0,"&aelig;"],[0,"&ccedil;"],[0,"&egrave;"],[0,"&eacute;"],[0,"&ecirc;"],[0,"&euml;"],[0,"&igrave;"],[0,"&iacute;"],[0,"&icirc;"],[0,"&iuml;"],[0,"&eth;"],[0,"&ntilde;"],[0,"&ograve;"],[0,"&oacute;"],[0,"&ocirc;"],[0,"&otilde;"],[0,"&ouml;"],[0,"&div;"],[0,"&oslash;"],[0,"&ugrave;"],[0,"&uacute;"],[0,"&ucirc;"],[0,"&uuml;"],[0,"&yacute;"],[0,"&thorn;"],[0,"&yuml;"],[0,"&Amacr;"],[0,"&amacr;"],[0,"&Abreve;"],[0,"&abreve;"],[0,"&Aogon;"],[0,"&aogon;"],[0,"&Cacute;"],[0,"&cacute;"],[0,"&Ccirc;"],[0,"&ccirc;"],[0,"&Cdot;"],[0,"&cdot;"],[0,"&Ccaron;"],[0,"&ccaron;"],[0,"&Dcaron;"],[0,"&dcaron;"],[0,"&Dstrok;"],[0,"&dstrok;"],[0,"&Emacr;"],[0,"&emacr;"],[2,"&Edot;"],[0,"&edot;"],[0,"&Eogon;"],[0,"&eogon;"],[0,"&Ecaron;"],[0,"&ecaron;"],[0,"&Gcirc;"],[0,"&gcirc;"],[0,"&Gbreve;"],[0,"&gbreve;"],[0,"&Gdot;"],[0,"&gdot;"],[0,"&Gcedil;"],[1,"&Hcirc;"],[0,"&hcirc;"],[0,"&Hstrok;"],[0,"&hstrok;"],[0,"&Itilde;"],[0,"&itilde;"],[0,"&Imacr;"],[0,"&imacr;"],[2,"&Iogon;"],[0,"&iogon;"],[0,"&Idot;"],[0,"&imath;"],[0,"&IJlig;"],[0,"&ijlig;"],[0,"&Jcirc;"],[0,"&jcirc;"],[0,"&Kcedil;"],[0,"&kcedil;"],[0,"&kgreen;"],[0,"&Lacute;"],[0,"&lacute;"],[0,"&Lcedil;"],[0,"&lcedil;"],[0,"&Lcaron;"],[0,"&lcaron;"],[0,"&Lmidot;"],[0,"&lmidot;"],[0,"&Lstrok;"],[0,"&lstrok;"],[0,"&Nacute;"],[0,"&nacute;"],[0,"&Ncedil;"],[0,"&ncedil;"],[0,"&Ncaron;"],[0,"&ncaron;"],[0,"&napos;"],[0,"&ENG;"],[0,"&eng;"],[0,"&Omacr;"],[0,"&omacr;"],[2,"&Odblac;"],[0,"&odblac;"],[0,"&OElig;"],[0,"&oelig;"],[0,"&Racute;"],[0,"&racute;"],[0,"&Rcedil;"],[0,"&rcedil;"],[0,"&Rcaron;"],[0,"&rcaron;"],[0,"&Sacute;"],[0,"&sacute;"],[0,"&Scirc;"],[0,"&scirc;"],[0,"&Scedil;"],[0,"&scedil;"],[0,"&Scaron;"],[0,"&scaron;"],[0,"&Tcedil;"],[0,"&tcedil;"],[0,"&Tcaron;"],[0,"&tcaron;"],[0,"&Tstrok;"],[0,"&tstrok;"],[0,"&Utilde;"],[0,"&utilde;"],[0,"&Umacr;"],[0,"&umacr;"],[0,"&Ubreve;"],[0,"&ubreve;"],[0,"&Uring;"],[0,"&uring;"],[0,"&Udblac;"],[0,"&udblac;"],[0,"&Uogon;"],[0,"&uogon;"],[0,"&Wcirc;"],[0,"&wcirc;"],[0,"&Ycirc;"],[0,"&ycirc;"],[0,"&Yuml;"],[0,"&Zacute;"],[0,"&zacute;"],[0,"&Zdot;"],[0,"&zdot;"],[0,"&Zcaron;"],[0,"&zcaron;"],[19,"&fnof;"],[34,"&imped;"],[63,"&gacute;"],[65,"&jmath;"],[142,"&circ;"],[0,"&caron;"],[16,"&breve;"],[0,"&DiacriticalDot;"],[0,"&ring;"],[0,"&ogon;"],[0,"&DiacriticalTilde;"],[0,"&dblac;"],[51,"&DownBreve;"],[127,"&Alpha;"],[0,"&Beta;"],[0,"&Gamma;"],[0,"&Delta;"],[0,"&Epsilon;"],[0,"&Zeta;"],[0,"&Eta;"],[0,"&Theta;"],[0,"&Iota;"],[0,"&Kappa;"],[0,"&Lambda;"],[0,"&Mu;"],[0,"&Nu;"],[0,"&Xi;"],[0,"&Omicron;"],[0,"&Pi;"],[0,"&Rho;"],[1,"&Sigma;"],[0,"&Tau;"],[0,"&Upsilon;"],[0,"&Phi;"],[0,"&Chi;"],[0,"&Psi;"],[0,"&ohm;"],[7,"&alpha;"],[0,"&beta;"],[0,"&gamma;"],[0,"&delta;"],[0,"&epsi;"],[0,"&zeta;"],[0,"&eta;"],[0,"&theta;"],[0,"&iota;"],[0,"&kappa;"],[0,"&lambda;"],[0,"&mu;"],[0,"&nu;"],[0,"&xi;"],[0,"&omicron;"],[0,"&pi;"],[0,"&rho;"],[0,"&sigmaf;"],[0,"&sigma;"],[0,"&tau;"],[0,"&upsi;"],[0,"&phi;"],[0,"&chi;"],[0,"&psi;"],[0,"&omega;"],[7,"&thetasym;"],[0,"&Upsi;"],[2,"&phiv;"],[0,"&piv;"],[5,"&Gammad;"],[0,"&digamma;"],[18,"&kappav;"],[0,"&rhov;"],[3,"&epsiv;"],[0,"&backepsilon;"],[10,"&IOcy;"],[0,"&DJcy;"],[0,"&GJcy;"],[0,"&Jukcy;"],[0,"&DScy;"],[0,"&Iukcy;"],[0,"&YIcy;"],[0,"&Jsercy;"],[0,"&LJcy;"],[0,"&NJcy;"],[0,"&TSHcy;"],[0,"&KJcy;"],[1,"&Ubrcy;"],[0,"&DZcy;"],[0,"&Acy;"],[0,"&Bcy;"],[0,"&Vcy;"],[0,"&Gcy;"],[0,"&Dcy;"],[0,"&IEcy;"],[0,"&ZHcy;"],[0,"&Zcy;"],[0,"&Icy;"],[0,"&Jcy;"],[0,"&Kcy;"],[0,"&Lcy;"],[0,"&Mcy;"],[0,"&Ncy;"],[0,"&Ocy;"],[0,"&Pcy;"],[0,"&Rcy;"],[0,"&Scy;"],[0,"&Tcy;"],[0,"&Ucy;"],[0,"&Fcy;"],[0,"&KHcy;"],[0,"&TScy;"],[0,"&CHcy;"],[0,"&SHcy;"],[0,"&SHCHcy;"],[0,"&HARDcy;"],[0,"&Ycy;"],[0,"&SOFTcy;"],[0,"&Ecy;"],[0,"&YUcy;"],[0,"&YAcy;"],[0,"&acy;"],[0,"&bcy;"],[0,"&vcy;"],[0,"&gcy;"],[0,"&dcy;"],[0,"&iecy;"],[0,"&zhcy;"],[0,"&zcy;"],[0,"&icy;"],[0,"&jcy;"],[0,"&kcy;"],[0,"&lcy;"],[0,"&mcy;"],[0,"&ncy;"],[0,"&ocy;"],[0,"&pcy;"],[0,"&rcy;"],[0,"&scy;"],[0,"&tcy;"],[0,"&ucy;"],[0,"&fcy;"],[0,"&khcy;"],[0,"&tscy;"],[0,"&chcy;"],[0,"&shcy;"],[0,"&shchcy;"],[0,"&hardcy;"],[0,"&ycy;"],[0,"&softcy;"],[0,"&ecy;"],[0,"&yucy;"],[0,"&yacy;"],[1,"&iocy;"],[0,"&djcy;"],[0,"&gjcy;"],[0,"&jukcy;"],[0,"&dscy;"],[0,"&iukcy;"],[0,"&yicy;"],[0,"&jsercy;"],[0,"&ljcy;"],[0,"&njcy;"],[0,"&tshcy;"],[0,"&kjcy;"],[1,"&ubrcy;"],[0,"&dzcy;"],[7074,"&ensp;"],[0,"&emsp;"],[0,"&emsp13;"],[0,"&emsp14;"],[1,"&numsp;"],[0,"&puncsp;"],[0,"&ThinSpace;"],[0,"&hairsp;"],[0,"&NegativeMediumSpace;"],[0,"&zwnj;"],[0,"&zwj;"],[0,"&lrm;"],[0,"&rlm;"],[0,"&dash;"],[2,"&ndash;"],[0,"&mdash;"],[0,"&horbar;"],[0,"&Verbar;"],[1,"&lsquo;"],[0,"&CloseCurlyQuote;"],[0,"&lsquor;"],[1,"&ldquo;"],[0,"&CloseCurlyDoubleQuote;"],[0,"&bdquo;"],[1,"&dagger;"],[0,"&Dagger;"],[0,"&bull;"],[2,"&nldr;"],[0,"&hellip;"],[9,"&permil;"],[0,"&pertenk;"],[0,"&prime;"],[0,"&Prime;"],[0,"&tprime;"],[0,"&backprime;"],[3,"&lsaquo;"],[0,"&rsaquo;"],[3,"&oline;"],[2,"&caret;"],[1,"&hybull;"],[0,"&frasl;"],[10,"&bsemi;"],[7,"&qprime;"],[7,{v:"&MediumSpace;",n:8202,o:"&ThickSpace;"}],[0,"&NoBreak;"],[0,"&af;"],[0,"&InvisibleTimes;"],[0,"&ic;"],[72,"&euro;"],[46,"&tdot;"],[0,"&DotDot;"],[37,"&complexes;"],[2,"&incare;"],[4,"&gscr;"],[0,"&hamilt;"],[0,"&Hfr;"],[0,"&Hopf;"],[0,"&planckh;"],[0,"&hbar;"],[0,"&imagline;"],[0,"&Ifr;"],[0,"&lagran;"],[0,"&ell;"],[1,"&naturals;"],[0,"&numero;"],[0,"&copysr;"],[0,"&weierp;"],[0,"&Popf;"],[0,"&Qopf;"],[0,"&realine;"],[0,"&real;"],[0,"&reals;"],[0,"&rx;"],[3,"&trade;"],[1,"&integers;"],[2,"&mho;"],[0,"&zeetrf;"],[0,"&iiota;"],[2,"&bernou;"],[0,"&Cayleys;"],[1,"&escr;"],[0,"&Escr;"],[0,"&Fouriertrf;"],[1,"&Mellintrf;"],[0,"&order;"],[0,"&alefsym;"],[0,"&beth;"],[0,"&gimel;"],[0,"&daleth;"],[12,"&CapitalDifferentialD;"],[0,"&dd;"],[0,"&ee;"],[0,"&ii;"],[10,"&frac13;"],[0,"&frac23;"],[0,"&frac15;"],[0,"&frac25;"],[0,"&frac35;"],[0,"&frac45;"],[0,"&frac16;"],[0,"&frac56;"],[0,"&frac18;"],[0,"&frac38;"],[0,"&frac58;"],[0,"&frac78;"],[49,"&larr;"],[0,"&ShortUpArrow;"],[0,"&rarr;"],[0,"&darr;"],[0,"&harr;"],[0,"&updownarrow;"],[0,"&nwarr;"],[0,"&nearr;"],[0,"&LowerRightArrow;"],[0,"&LowerLeftArrow;"],[0,"&nlarr;"],[0,"&nrarr;"],[1,{v:"&rarrw;",n:824,o:"&nrarrw;"}],[0,"&Larr;"],[0,"&Uarr;"],[0,"&Rarr;"],[0,"&Darr;"],[0,"&larrtl;"],[0,"&rarrtl;"],[0,"&LeftTeeArrow;"],[0,"&mapstoup;"],[0,"&map;"],[0,"&DownTeeArrow;"],[1,"&hookleftarrow;"],[0,"&hookrightarrow;"],[0,"&larrlp;"],[0,"&looparrowright;"],[0,"&harrw;"],[0,"&nharr;"],[1,"&lsh;"],[0,"&rsh;"],[0,"&ldsh;"],[0,"&rdsh;"],[1,"&crarr;"],[0,"&cularr;"],[0,"&curarr;"],[2,"&circlearrowleft;"],[0,"&circlearrowright;"],[0,"&leftharpoonup;"],[0,"&DownLeftVector;"],[0,"&RightUpVector;"],[0,"&LeftUpVector;"],[0,"&rharu;"],[0,"&DownRightVector;"],[0,"&dharr;"],[0,"&dharl;"],[0,"&RightArrowLeftArrow;"],[0,"&udarr;"],[0,"&LeftArrowRightArrow;"],[0,"&leftleftarrows;"],[0,"&upuparrows;"],[0,"&rightrightarrows;"],[0,"&ddarr;"],[0,"&leftrightharpoons;"],[0,"&Equilibrium;"],[0,"&nlArr;"],[0,"&nhArr;"],[0,"&nrArr;"],[0,"&DoubleLeftArrow;"],[0,"&DoubleUpArrow;"],[0,"&DoubleRightArrow;"],[0,"&dArr;"],[0,"&DoubleLeftRightArrow;"],[0,"&DoubleUpDownArrow;"],[0,"&nwArr;"],[0,"&neArr;"],[0,"&seArr;"],[0,"&swArr;"],[0,"&lAarr;"],[0,"&rAarr;"],[1,"&zigrarr;"],[6,"&larrb;"],[0,"&rarrb;"],[15,"&DownArrowUpArrow;"],[7,"&loarr;"],[0,"&roarr;"],[0,"&hoarr;"],[0,"&forall;"],[0,"&comp;"],[0,{v:"&part;",n:824,o:"&npart;"}],[0,"&exist;"],[0,"&nexist;"],[0,"&empty;"],[1,"&Del;"],[0,"&Element;"],[0,"&NotElement;"],[1,"&ni;"],[0,"&notni;"],[2,"&prod;"],[0,"&coprod;"],[0,"&sum;"],[0,"&minus;"],[0,"&MinusPlus;"],[0,"&dotplus;"],[1,"&Backslash;"],[0,"&lowast;"],[0,"&compfn;"],[1,"&radic;"],[2,"&prop;"],[0,"&infin;"],[0,"&angrt;"],[0,{v:"&ang;",n:8402,o:"&nang;"}],[0,"&angmsd;"],[0,"&angsph;"],[0,"&mid;"],[0,"&nmid;"],[0,"&DoubleVerticalBar;"],[0,"&NotDoubleVerticalBar;"],[0,"&and;"],[0,"&or;"],[0,{v:"&cap;",n:65024,o:"&caps;"}],[0,{v:"&cup;",n:65024,o:"&cups;"}],[0,"&int;"],[0,"&Int;"],[0,"&iiint;"],[0,"&conint;"],[0,"&Conint;"],[0,"&Cconint;"],[0,"&cwint;"],[0,"&ClockwiseContourIntegral;"],[0,"&awconint;"],[0,"&there4;"],[0,"&becaus;"],[0,"&ratio;"],[0,"&Colon;"],[0,"&dotminus;"],[1,"&mDDot;"],[0,"&homtht;"],[0,{v:"&sim;",n:8402,o:"&nvsim;"}],[0,{v:"&backsim;",n:817,o:"&race;"}],[0,{v:"&ac;",n:819,o:"&acE;"}],[0,"&acd;"],[0,"&VerticalTilde;"],[0,"&NotTilde;"],[0,{v:"&eqsim;",n:824,o:"&nesim;"}],[0,"&sime;"],[0,"&NotTildeEqual;"],[0,"&cong;"],[0,"&simne;"],[0,"&ncong;"],[0,"&ap;"],[0,"&nap;"],[0,"&ape;"],[0,{v:"&apid;",n:824,o:"&napid;"}],[0,"&backcong;"],[0,{v:"&asympeq;",n:8402,o:"&nvap;"}],[0,{v:"&bump;",n:824,o:"&nbump;"}],[0,{v:"&bumpe;",n:824,o:"&nbumpe;"}],[0,{v:"&doteq;",n:824,o:"&nedot;"}],[0,"&doteqdot;"],[0,"&efDot;"],[0,"&erDot;"],[0,"&Assign;"],[0,"&ecolon;"],[0,"&ecir;"],[0,"&circeq;"],[1,"&wedgeq;"],[0,"&veeeq;"],[1,"&triangleq;"],[2,"&equest;"],[0,"&ne;"],[0,{v:"&Congruent;",n:8421,o:"&bnequiv;"}],[0,"&nequiv;"],[1,{v:"&le;",n:8402,o:"&nvle;"}],[0,{v:"&ge;",n:8402,o:"&nvge;"}],[0,{v:"&lE;",n:824,o:"&nlE;"}],[0,{v:"&gE;",n:824,o:"&ngE;"}],[0,{v:"&lnE;",n:65024,o:"&lvertneqq;"}],[0,{v:"&gnE;",n:65024,o:"&gvertneqq;"}],[0,{v:"&ll;",n:new Map(tu([[824,"&nLtv;"],[7577,"&nLt;"]]))}],[0,{v:"&gg;",n:new Map(tu([[824,"&nGtv;"],[7577,"&nGt;"]]))}],[0,"&between;"],[0,"&NotCupCap;"],[0,"&nless;"],[0,"&ngt;"],[0,"&nle;"],[0,"&nge;"],[0,"&lesssim;"],[0,"&GreaterTilde;"],[0,"&nlsim;"],[0,"&ngsim;"],[0,"&LessGreater;"],[0,"&gl;"],[0,"&NotLessGreater;"],[0,"&NotGreaterLess;"],[0,"&pr;"],[0,"&sc;"],[0,"&prcue;"],[0,"&sccue;"],[0,"&PrecedesTilde;"],[0,{v:"&scsim;",n:824,o:"&NotSucceedsTilde;"}],[0,"&NotPrecedes;"],[0,"&NotSucceeds;"],[0,{v:"&sub;",n:8402,o:"&NotSubset;"}],[0,{v:"&sup;",n:8402,o:"&NotSuperset;"}],[0,"&nsub;"],[0,"&nsup;"],[0,"&sube;"],[0,"&supe;"],[0,"&NotSubsetEqual;"],[0,"&NotSupersetEqual;"],[0,{v:"&subne;",n:65024,o:"&varsubsetneq;"}],[0,{v:"&supne;",n:65024,o:"&varsupsetneq;"}],[1,"&cupdot;"],[0,"&UnionPlus;"],[0,{v:"&sqsub;",n:824,o:"&NotSquareSubset;"}],[0,{v:"&sqsup;",n:824,o:"&NotSquareSuperset;"}],[0,"&sqsube;"],[0,"&sqsupe;"],[0,{v:"&sqcap;",n:65024,o:"&sqcaps;"}],[0,{v:"&sqcup;",n:65024,o:"&sqcups;"}],[0,"&CirclePlus;"],[0,"&CircleMinus;"],[0,"&CircleTimes;"],[0,"&osol;"],[0,"&CircleDot;"],[0,"&circledcirc;"],[0,"&circledast;"],[1,"&circleddash;"],[0,"&boxplus;"],[0,"&boxminus;"],[0,"&boxtimes;"],[0,"&dotsquare;"],[0,"&RightTee;"],[0,"&dashv;"],[0,"&DownTee;"],[0,"&bot;"],[1,"&models;"],[0,"&DoubleRightTee;"],[0,"&Vdash;"],[0,"&Vvdash;"],[0,"&VDash;"],[0,"&nvdash;"],[0,"&nvDash;"],[0,"&nVdash;"],[0,"&nVDash;"],[0,"&prurel;"],[1,"&LeftTriangle;"],[0,"&RightTriangle;"],[0,{v:"&LeftTriangleEqual;",n:8402,o:"&nvltrie;"}],[0,{v:"&RightTriangleEqual;",n:8402,o:"&nvrtrie;"}],[0,"&origof;"],[0,"&imof;"],[0,"&multimap;"],[0,"&hercon;"],[0,"&intcal;"],[0,"&veebar;"],[1,"&barvee;"],[0,"&angrtvb;"],[0,"&lrtri;"],[0,"&bigwedge;"],[0,"&bigvee;"],[0,"&bigcap;"],[0,"&bigcup;"],[0,"&diam;"],[0,"&sdot;"],[0,"&sstarf;"],[0,"&divideontimes;"],[0,"&bowtie;"],[0,"&ltimes;"],[0,"&rtimes;"],[0,"&leftthreetimes;"],[0,"&rightthreetimes;"],[0,"&backsimeq;"],[0,"&curlyvee;"],[0,"&curlywedge;"],[0,"&Sub;"],[0,"&Sup;"],[0,"&Cap;"],[0,"&Cup;"],[0,"&fork;"],[0,"&epar;"],[0,"&lessdot;"],[0,"&gtdot;"],[0,{v:"&Ll;",n:824,o:"&nLl;"}],[0,{v:"&Gg;",n:824,o:"&nGg;"}],[0,{v:"&leg;",n:65024,o:"&lesg;"}],[0,{v:"&gel;",n:65024,o:"&gesl;"}],[2,"&cuepr;"],[0,"&cuesc;"],[0,"&NotPrecedesSlantEqual;"],[0,"&NotSucceedsSlantEqual;"],[0,"&NotSquareSubsetEqual;"],[0,"&NotSquareSupersetEqual;"],[2,"&lnsim;"],[0,"&gnsim;"],[0,"&precnsim;"],[0,"&scnsim;"],[0,"&nltri;"],[0,"&NotRightTriangle;"],[0,"&nltrie;"],[0,"&NotRightTriangleEqual;"],[0,"&vellip;"],[0,"&ctdot;"],[0,"&utdot;"],[0,"&dtdot;"],[0,"&disin;"],[0,"&isinsv;"],[0,"&isins;"],[0,{v:"&isindot;",n:824,o:"&notindot;"}],[0,"&notinvc;"],[0,"&notinvb;"],[1,{v:"&isinE;",n:824,o:"&notinE;"}],[0,"&nisd;"],[0,"&xnis;"],[0,"&nis;"],[0,"&notnivc;"],[0,"&notnivb;"],[6,"&barwed;"],[0,"&Barwed;"],[1,"&lceil;"],[0,"&rceil;"],[0,"&LeftFloor;"],[0,"&rfloor;"],[0,"&drcrop;"],[0,"&dlcrop;"],[0,"&urcrop;"],[0,"&ulcrop;"],[0,"&bnot;"],[1,"&profline;"],[0,"&profsurf;"],[1,"&telrec;"],[0,"&target;"],[5,"&ulcorn;"],[0,"&urcorn;"],[0,"&dlcorn;"],[0,"&drcorn;"],[2,"&frown;"],[0,"&smile;"],[9,"&cylcty;"],[0,"&profalar;"],[7,"&topbot;"],[6,"&ovbar;"],[1,"&solbar;"],[60,"&angzarr;"],[51,"&lmoustache;"],[0,"&rmoustache;"],[2,"&OverBracket;"],[0,"&bbrk;"],[0,"&bbrktbrk;"],[37,"&OverParenthesis;"],[0,"&UnderParenthesis;"],[0,"&OverBrace;"],[0,"&UnderBrace;"],[2,"&trpezium;"],[4,"&elinters;"],[59,"&blank;"],[164,"&circledS;"],[55,"&boxh;"],[1,"&boxv;"],[9,"&boxdr;"],[3,"&boxdl;"],[3,"&boxur;"],[3,"&boxul;"],[3,"&boxvr;"],[7,"&boxvl;"],[7,"&boxhd;"],[7,"&boxhu;"],[7,"&boxvh;"],[19,"&boxH;"],[0,"&boxV;"],[0,"&boxdR;"],[0,"&boxDr;"],[0,"&boxDR;"],[0,"&boxdL;"],[0,"&boxDl;"],[0,"&boxDL;"],[0,"&boxuR;"],[0,"&boxUr;"],[0,"&boxUR;"],[0,"&boxuL;"],[0,"&boxUl;"],[0,"&boxUL;"],[0,"&boxvR;"],[0,"&boxVr;"],[0,"&boxVR;"],[0,"&boxvL;"],[0,"&boxVl;"],[0,"&boxVL;"],[0,"&boxHd;"],[0,"&boxhD;"],[0,"&boxHD;"],[0,"&boxHu;"],[0,"&boxhU;"],[0,"&boxHU;"],[0,"&boxvH;"],[0,"&boxVh;"],[0,"&boxVH;"],[19,"&uhblk;"],[3,"&lhblk;"],[3,"&block;"],[8,"&blk14;"],[0,"&blk12;"],[0,"&blk34;"],[13,"&square;"],[8,"&blacksquare;"],[0,"&EmptyVerySmallSquare;"],[1,"&rect;"],[0,"&marker;"],[2,"&fltns;"],[1,"&bigtriangleup;"],[0,"&blacktriangle;"],[0,"&triangle;"],[2,"&blacktriangleright;"],[0,"&rtri;"],[3,"&bigtriangledown;"],[0,"&blacktriangledown;"],[0,"&dtri;"],[2,"&blacktriangleleft;"],[0,"&ltri;"],[6,"&loz;"],[0,"&cir;"],[32,"&tridot;"],[2,"&bigcirc;"],[8,"&ultri;"],[0,"&urtri;"],[0,"&lltri;"],[0,"&EmptySmallSquare;"],[0,"&FilledSmallSquare;"],[8,"&bigstar;"],[0,"&star;"],[7,"&phone;"],[49,"&female;"],[1,"&male;"],[29,"&spades;"],[2,"&clubs;"],[1,"&hearts;"],[0,"&diamondsuit;"],[3,"&sung;"],[2,"&flat;"],[0,"&natural;"],[0,"&sharp;"],[163,"&check;"],[3,"&cross;"],[8,"&malt;"],[21,"&sext;"],[33,"&VerticalSeparator;"],[25,"&lbbrk;"],[0,"&rbbrk;"],[84,"&bsolhsub;"],[0,"&suphsol;"],[28,"&LeftDoubleBracket;"],[0,"&RightDoubleBracket;"],[0,"&lang;"],[0,"&rang;"],[0,"&Lang;"],[0,"&Rang;"],[0,"&loang;"],[0,"&roang;"],[7,"&longleftarrow;"],[0,"&longrightarrow;"],[0,"&longleftrightarrow;"],[0,"&DoubleLongLeftArrow;"],[0,"&DoubleLongRightArrow;"],[0,"&DoubleLongLeftRightArrow;"],[1,"&longmapsto;"],[2,"&dzigrarr;"],[258,"&nvlArr;"],[0,"&nvrArr;"],[0,"&nvHarr;"],[0,"&Map;"],[6,"&lbarr;"],[0,"&bkarow;"],[0,"&lBarr;"],[0,"&dbkarow;"],[0,"&drbkarow;"],[0,"&DDotrahd;"],[0,"&UpArrowBar;"],[0,"&DownArrowBar;"],[2,"&Rarrtl;"],[2,"&latail;"],[0,"&ratail;"],[0,"&lAtail;"],[0,"&rAtail;"],[0,"&larrfs;"],[0,"&rarrfs;"],[0,"&larrbfs;"],[0,"&rarrbfs;"],[2,"&nwarhk;"],[0,"&nearhk;"],[0,"&hksearow;"],[0,"&hkswarow;"],[0,"&nwnear;"],[0,"&nesear;"],[0,"&seswar;"],[0,"&swnwar;"],[8,{v:"&rarrc;",n:824,o:"&nrarrc;"}],[1,"&cudarrr;"],[0,"&ldca;"],[0,"&rdca;"],[0,"&cudarrl;"],[0,"&larrpl;"],[2,"&curarrm;"],[0,"&cularrp;"],[7,"&rarrpl;"],[2,"&harrcir;"],[0,"&Uarrocir;"],[0,"&lurdshar;"],[0,"&ldrushar;"],[2,"&LeftRightVector;"],[0,"&RightUpDownVector;"],[0,"&DownLeftRightVector;"],[0,"&LeftUpDownVector;"],[0,"&LeftVectorBar;"],[0,"&RightVectorBar;"],[0,"&RightUpVectorBar;"],[0,"&RightDownVectorBar;"],[0,"&DownLeftVectorBar;"],[0,"&DownRightVectorBar;"],[0,"&LeftUpVectorBar;"],[0,"&LeftDownVectorBar;"],[0,"&LeftTeeVector;"],[0,"&RightTeeVector;"],[0,"&RightUpTeeVector;"],[0,"&RightDownTeeVector;"],[0,"&DownLeftTeeVector;"],[0,"&DownRightTeeVector;"],[0,"&LeftUpTeeVector;"],[0,"&LeftDownTeeVector;"],[0,"&lHar;"],[0,"&uHar;"],[0,"&rHar;"],[0,"&dHar;"],[0,"&luruhar;"],[0,"&ldrdhar;"],[0,"&ruluhar;"],[0,"&rdldhar;"],[0,"&lharul;"],[0,"&llhard;"],[0,"&rharul;"],[0,"&lrhard;"],[0,"&udhar;"],[0,"&duhar;"],[0,"&RoundImplies;"],[0,"&erarr;"],[0,"&simrarr;"],[0,"&larrsim;"],[0,"&rarrsim;"],[0,"&rarrap;"],[0,"&ltlarr;"],[1,"&gtrarr;"],[0,"&subrarr;"],[1,"&suplarr;"],[0,"&lfisht;"],[0,"&rfisht;"],[0,"&ufisht;"],[0,"&dfisht;"],[5,"&lopar;"],[0,"&ropar;"],[4,"&lbrke;"],[0,"&rbrke;"],[0,"&lbrkslu;"],[0,"&rbrksld;"],[0,"&lbrksld;"],[0,"&rbrkslu;"],[0,"&langd;"],[0,"&rangd;"],[0,"&lparlt;"],[0,"&rpargt;"],[0,"&gtlPar;"],[0,"&ltrPar;"],[3,"&vzigzag;"],[1,"&vangrt;"],[0,"&angrtvbd;"],[6,"&ange;"],[0,"&range;"],[0,"&dwangle;"],[0,"&uwangle;"],[0,"&angmsdaa;"],[0,"&angmsdab;"],[0,"&angmsdac;"],[0,"&angmsdad;"],[0,"&angmsdae;"],[0,"&angmsdaf;"],[0,"&angmsdag;"],[0,"&angmsdah;"],[0,"&bemptyv;"],[0,"&demptyv;"],[0,"&cemptyv;"],[0,"&raemptyv;"],[0,"&laemptyv;"],[0,"&ohbar;"],[0,"&omid;"],[0,"&opar;"],[1,"&operp;"],[1,"&olcross;"],[0,"&odsold;"],[1,"&olcir;"],[0,"&ofcir;"],[0,"&olt;"],[0,"&ogt;"],[0,"&cirscir;"],[0,"&cirE;"],[0,"&solb;"],[0,"&bsolb;"],[3,"&boxbox;"],[3,"&trisb;"],[0,"&rtriltri;"],[0,{v:"&LeftTriangleBar;",n:824,o:"&NotLeftTriangleBar;"}],[0,{v:"&RightTriangleBar;",n:824,o:"&NotRightTriangleBar;"}],[11,"&iinfin;"],[0,"&infintie;"],[0,"&nvinfin;"],[4,"&eparsl;"],[0,"&smeparsl;"],[0,"&eqvparsl;"],[5,"&blacklozenge;"],[8,"&RuleDelayed;"],[1,"&dsol;"],[9,"&bigodot;"],[0,"&bigoplus;"],[0,"&bigotimes;"],[1,"&biguplus;"],[1,"&bigsqcup;"],[5,"&iiiint;"],[0,"&fpartint;"],[2,"&cirfnint;"],[0,"&awint;"],[0,"&rppolint;"],[0,"&scpolint;"],[0,"&npolint;"],[0,"&pointint;"],[0,"&quatint;"],[0,"&intlarhk;"],[10,"&pluscir;"],[0,"&plusacir;"],[0,"&simplus;"],[0,"&plusdu;"],[0,"&plussim;"],[0,"&plustwo;"],[1,"&mcomma;"],[0,"&minusdu;"],[2,"&loplus;"],[0,"&roplus;"],[0,"&Cross;"],[0,"&timesd;"],[0,"&timesbar;"],[1,"&smashp;"],[0,"&lotimes;"],[0,"&rotimes;"],[0,"&otimesas;"],[0,"&Otimes;"],[0,"&odiv;"],[0,"&triplus;"],[0,"&triminus;"],[0,"&tritime;"],[0,"&intprod;"],[2,"&amalg;"],[0,"&capdot;"],[1,"&ncup;"],[0,"&ncap;"],[0,"&capand;"],[0,"&cupor;"],[0,"&cupcap;"],[0,"&capcup;"],[0,"&cupbrcap;"],[0,"&capbrcup;"],[0,"&cupcup;"],[0,"&capcap;"],[0,"&ccups;"],[0,"&ccaps;"],[2,"&ccupssm;"],[2,"&And;"],[0,"&Or;"],[0,"&andand;"],[0,"&oror;"],[0,"&orslope;"],[0,"&andslope;"],[1,"&andv;"],[0,"&orv;"],[0,"&andd;"],[0,"&ord;"],[1,"&wedbar;"],[6,"&sdote;"],[3,"&simdot;"],[2,{v:"&congdot;",n:824,o:"&ncongdot;"}],[0,"&easter;"],[0,"&apacir;"],[0,{v:"&apE;",n:824,o:"&napE;"}],[0,"&eplus;"],[0,"&pluse;"],[0,"&Esim;"],[0,"&Colone;"],[0,"&Equal;"],[1,"&ddotseq;"],[0,"&equivDD;"],[0,"&ltcir;"],[0,"&gtcir;"],[0,"&ltquest;"],[0,"&gtquest;"],[0,{v:"&leqslant;",n:824,o:"&nleqslant;"}],[0,{v:"&geqslant;",n:824,o:"&ngeqslant;"}],[0,"&lesdot;"],[0,"&gesdot;"],[0,"&lesdoto;"],[0,"&gesdoto;"],[0,"&lesdotor;"],[0,"&gesdotol;"],[0,"&lap;"],[0,"&gap;"],[0,"&lne;"],[0,"&gne;"],[0,"&lnap;"],[0,"&gnap;"],[0,"&lEg;"],[0,"&gEl;"],[0,"&lsime;"],[0,"&gsime;"],[0,"&lsimg;"],[0,"&gsiml;"],[0,"&lgE;"],[0,"&glE;"],[0,"&lesges;"],[0,"&gesles;"],[0,"&els;"],[0,"&egs;"],[0,"&elsdot;"],[0,"&egsdot;"],[0,"&el;"],[0,"&eg;"],[2,"&siml;"],[0,"&simg;"],[0,"&simlE;"],[0,"&simgE;"],[0,{v:"&LessLess;",n:824,o:"&NotNestedLessLess;"}],[0,{v:"&GreaterGreater;",n:824,o:"&NotNestedGreaterGreater;"}],[1,"&glj;"],[0,"&gla;"],[0,"&ltcc;"],[0,"&gtcc;"],[0,"&lescc;"],[0,"&gescc;"],[0,"&smt;"],[0,"&lat;"],[0,{v:"&smte;",n:65024,o:"&smtes;"}],[0,{v:"&late;",n:65024,o:"&lates;"}],[0,"&bumpE;"],[0,{v:"&PrecedesEqual;",n:824,o:"&NotPrecedesEqual;"}],[0,{v:"&sce;",n:824,o:"&NotSucceedsEqual;"}],[2,"&prE;"],[0,"&scE;"],[0,"&precneqq;"],[0,"&scnE;"],[0,"&prap;"],[0,"&scap;"],[0,"&precnapprox;"],[0,"&scnap;"],[0,"&Pr;"],[0,"&Sc;"],[0,"&subdot;"],[0,"&supdot;"],[0,"&subplus;"],[0,"&supplus;"],[0,"&submult;"],[0,"&supmult;"],[0,"&subedot;"],[0,"&supedot;"],[0,{v:"&subE;",n:824,o:"&nsubE;"}],[0,{v:"&supE;",n:824,o:"&nsupE;"}],[0,"&subsim;"],[0,"&supsim;"],[2,{v:"&subnE;",n:65024,o:"&varsubsetneqq;"}],[0,{v:"&supnE;",n:65024,o:"&varsupsetneqq;"}],[2,"&csub;"],[0,"&csup;"],[0,"&csube;"],[0,"&csupe;"],[0,"&subsup;"],[0,"&supsub;"],[0,"&subsub;"],[0,"&supsup;"],[0,"&suphsub;"],[0,"&supdsub;"],[0,"&forkv;"],[0,"&topfork;"],[0,"&mlcp;"],[8,"&Dashv;"],[1,"&Vdashl;"],[0,"&Barv;"],[0,"&vBar;"],[0,"&vBarv;"],[1,"&Vbar;"],[0,"&Not;"],[0,"&bNot;"],[0,"&rnmid;"],[0,"&cirmid;"],[0,"&midcir;"],[0,"&topcir;"],[0,"&nhpar;"],[0,"&parsim;"],[9,{v:"&parsl;",n:8421,o:"&nparsl;"}],[44343,{n:new Map(tu([[56476,"&Ascr;"],[1,"&Cscr;"],[0,"&Dscr;"],[2,"&Gscr;"],[2,"&Jscr;"],[0,"&Kscr;"],[2,"&Nscr;"],[0,"&Oscr;"],[0,"&Pscr;"],[0,"&Qscr;"],[1,"&Sscr;"],[0,"&Tscr;"],[0,"&Uscr;"],[0,"&Vscr;"],[0,"&Wscr;"],[0,"&Xscr;"],[0,"&Yscr;"],[0,"&Zscr;"],[0,"&ascr;"],[0,"&bscr;"],[0,"&cscr;"],[0,"&dscr;"],[1,"&fscr;"],[1,"&hscr;"],[0,"&iscr;"],[0,"&jscr;"],[0,"&kscr;"],[0,"&lscr;"],[0,"&mscr;"],[0,"&nscr;"],[1,"&pscr;"],[0,"&qscr;"],[0,"&rscr;"],[0,"&sscr;"],[0,"&tscr;"],[0,"&uscr;"],[0,"&vscr;"],[0,"&wscr;"],[0,"&xscr;"],[0,"&yscr;"],[0,"&zscr;"],[52,"&Afr;"],[0,"&Bfr;"],[1,"&Dfr;"],[0,"&Efr;"],[0,"&Ffr;"],[0,"&Gfr;"],[2,"&Jfr;"],[0,"&Kfr;"],[0,"&Lfr;"],[0,"&Mfr;"],[0,"&Nfr;"],[0,"&Ofr;"],[0,"&Pfr;"],[0,"&Qfr;"],[1,"&Sfr;"],[0,"&Tfr;"],[0,"&Ufr;"],[0,"&Vfr;"],[0,"&Wfr;"],[0,"&Xfr;"],[0,"&Yfr;"],[1,"&afr;"],[0,"&bfr;"],[0,"&cfr;"],[0,"&dfr;"],[0,"&efr;"],[0,"&ffr;"],[0,"&gfr;"],[0,"&hfr;"],[0,"&ifr;"],[0,"&jfr;"],[0,"&kfr;"],[0,"&lfr;"],[0,"&mfr;"],[0,"&nfr;"],[0,"&ofr;"],[0,"&pfr;"],[0,"&qfr;"],[0,"&rfr;"],[0,"&sfr;"],[0,"&tfr;"],[0,"&ufr;"],[0,"&vfr;"],[0,"&wfr;"],[0,"&xfr;"],[0,"&yfr;"],[0,"&zfr;"],[0,"&Aopf;"],[0,"&Bopf;"],[1,"&Dopf;"],[0,"&Eopf;"],[0,"&Fopf;"],[0,"&Gopf;"],[1,"&Iopf;"],[0,"&Jopf;"],[0,"&Kopf;"],[0,"&Lopf;"],[0,"&Mopf;"],[1,"&Oopf;"],[3,"&Sopf;"],[0,"&Topf;"],[0,"&Uopf;"],[0,"&Vopf;"],[0,"&Wopf;"],[0,"&Xopf;"],[0,"&Yopf;"],[1,"&aopf;"],[0,"&bopf;"],[0,"&copf;"],[0,"&dopf;"],[0,"&eopf;"],[0,"&fopf;"],[0,"&gopf;"],[0,"&hopf;"],[0,"&iopf;"],[0,"&jopf;"],[0,"&kopf;"],[0,"&lopf;"],[0,"&mopf;"],[0,"&nopf;"],[0,"&oopf;"],[0,"&popf;"],[0,"&qopf;"],[0,"&ropf;"],[0,"&sopf;"],[0,"&topf;"],[0,"&uopf;"],[0,"&vopf;"],[0,"&wopf;"],[0,"&xopf;"],[0,"&yopf;"],[0,"&zopf;"]]))}],[8906,"&fflig;"],[0,"&filig;"],[0,"&fllig;"],[0,"&ffilig;"],[0,"&ffllig;"]])),function(t){t[t.XML=0]="XML",t[t.HTML=1]="HTML"}(Vl||(Vl={})),function(t){t[t.UTF8=0]="UTF8",t[t.ASCII=1]="ASCII",t[t.Extensive=2]="Extensive",t[t.Attribute=3]="Attribute",t[t.Text=4]="Text"}(Hl||(Hl={}));const ru=Object.prototype.hasOwnProperty;function iu(t){return Array.prototype.slice.call(arguments,1).forEach((function(e){if(e){if("object"!=typeof e)throw new TypeError(e+"must be object");Object.keys(e).forEach((function(r){t[r]=e[r]}))}})),t}function nu(t,e,r){return[].concat(t.slice(0,e),r,t.slice(e+1))}function su(t){return!(t>=55296&&t<=57343||t>=64976&&t<=65007||!(65535&~t&&65534!=(65535&t))||t>=0&&t<=8||11===t||t>=14&&t<=31||t>=127&&t<=159||t>1114111)}function ou(t){return t>65535?(t-=65536,String.fromCharCode(55296+(t>>10),56320+(1023&t))):String.fromCharCode(t)}const lu=/\\([!"#$%&'()*+,\-./:;<=>?@[\\\]^_`{|}~])/g,uu=new RegExp(lu.source+"|"+/&([a-z#][a-z0-9]{1,31});/gi.source,"gi"),hu=/^#((?:x[a-f0-9]{1,8}|[0-9]{1,8}))$/i;function au(t){return t.indexOf("\\")<0&&t.indexOf("&")<0?t:t.replace(uu,(function(t,e,r){return e||function(t,e){if(35===e.charCodeAt(0)&&hu.test(e)){const r="x"===e[1].toLowerCase()?parseInt(e.slice(2),16):parseInt(e.slice(1),10);return su(r)?ou(r):t}const r=M(t);return r!==t?r:t}(t,r)}))}const fu=/[&<>"]/,cu=/[&<>"]/g,du={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;"};function pu(t){return du[t]}function mu(t){return fu.test(t)?t.replace(cu,pu):t}const gu=/[.?*+^$[\]\\(){}|-]/g;function bu(t){switch(t){case 9:case 32:return!0}return!1}function wu(t){if(t>=8192&&t<=8202)return!0;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!0}return!1}function vu(t){return Kl.test(t)||Yl.test(t)}function ku(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!0;default:return!1}}function Du(t){return t=t.trim().replace(/\s+/g," "),"Ṿ"==="ẞ".toLowerCase()&&(t=t.replace(/ẞ/g,"ß")),t.toLowerCase().toUpperCase()}var yu=Object.freeze({__proto__:null,arrayReplaceAt:nu,assign:iu,escapeHtml:mu,escapeRE:function(t){return t.replace(gu,"\\$&")},fromCodePoint:ou,has:function(t,e){return ru.call(t,e)},isMdAsciiPunct:ku,isPunctChar:vu,isSpace:bu,isString:eu,isValidEntityCode:su,isWhiteSpace:wu,lib:{mdurl:Wl,ucmicro:Ql},normalizeReference:Du,unescapeAll:au,unescapeMd:function(t){return t.indexOf("\\")<0?t:t.replace(lu,"$1")}}),Eu=Object.freeze({__proto__:null,parseLinkDestination:function(t,e,r){let i,n=e;const s={ok:!1,pos:0,str:""};if(60===t.charCodeAt(n)){for(n++;n<r;){if(i=t.charCodeAt(n),10===i)return s;if(60===i)return s;if(62===i)return s.pos=n+1,s.str=au(t.slice(e+1,n)),s.ok=!0,s;92===i&&n+1<r?n+=2:n++}return s}let o=0;for(;n<r&&(i=t.charCodeAt(n),32!==i)&&!(i<32||127===i);)if(92===i&&n+1<r){if(32===t.charCodeAt(n+1))break;n+=2}else{if(40===i&&(o++,o>32))return s;if(41===i){if(0===o)break;o--}n++}return e===n||0!==o||(s.str=au(t.slice(e,n)),s.pos=n,s.ok=!0),s},parseLinkLabel:function(t,e,r){let i,n,s,o;const l=t.posMax,u=t.pos;for(t.pos=e+1,i=1;t.pos<l;){if(s=t.src.charCodeAt(t.pos),93===s&&(i--,0===i)){n=!0;break}if(o=t.pos,t.md.inline.skipToken(t),91===s)if(o===t.pos-1)i++;else if(r)return t.pos=u,-1}let h=-1;return n&&(h=t.pos),t.pos=u,h},parseLinkTitle:function(t,e,r,i){let n,s=e;const o={ok:!1,can_continue:!1,pos:0,str:"",marker:0};if(i)o.str=i.str,o.marker=i.marker;else{if(s>=r)return o;let i=t.charCodeAt(s);if(34!==i&&39!==i&&40!==i)return o;e++,s++,40===i&&(i=41),o.marker=i}for(;s<r;){if(n=t.charCodeAt(s),n===o.marker)return o.pos=s+1,o.str+=au(t.slice(e,s)),o.ok=!0,o;if(40===n&&41===o.marker)return o;92===n&&s+1<r&&s++,s++}return o.can_continue=!0,o.str+=au(t.slice(e,s)),o}});const xu={};function Fu(){this.rules=iu({},xu)}function Mu(){this.__rules__=[],this.__cache__=null}function Au(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=!1,this.hidden=!1}function Cu(t,e,r){this.src=t,this.env=r,this.tokens=[],this.inlineMode=!1,this.md=e}xu.code_inline=function(t,e,r,i,n){const s=t[e];return"<code"+n.renderAttrs(s)+">"+mu(s.content)+"</code>"},xu.code_block=function(t,e,r,i,n){return"<pre"+n.renderAttrs(t[e])+"><code>"+mu(t[e].content)+"</code></pre>\n"},xu.fence=function(t,e,r,i,n){const s=t[e],o=s.info?au(s.info).trim():"";let l,u="",h="";if(o){const t=o.split(/(\s+)/g);u=t[0],h=t.slice(2).join("")}if(l=r.highlight&&r.highlight(s.content,u,h)||mu(s.content),0===l.indexOf("<pre"))return l+"\n";if(o){const t=s.attrIndex("class"),e=s.attrs?s.attrs.slice():[];return t<0?e.push(["class",r.langPrefix+u]):(e[t]=e[t].slice(),e[t][1]+=" "+r.langPrefix+u),`<pre><code${n.renderAttrs({attrs:e})}>${l}</code></pre>\n`}return`<pre><code${n.renderAttrs(s)}>${l}</code></pre>\n`},xu.image=function(t,e,r,i,n){const s=t[e];return s.attrs[s.attrIndex("alt")][1]=n.renderInlineAsText(s.children,r,i),n.renderToken(t,e,r)},xu.hardbreak=function(t,e,r){return r.xhtmlOut?"<br />\n":"<br>\n"},xu.softbreak=function(t,e,r){return r.breaks?r.xhtmlOut?"<br />\n":"<br>\n":"\n"},xu.text=function(t,e){return mu(t[e].content)},xu.html_block=function(t,e){return t[e].content},xu.html_inline=function(t,e){return t[e].content},Fu.prototype.renderAttrs=function(t){let e,r,i;if(!t.attrs)return"";for(i="",e=0,r=t.attrs.length;e<r;e++)i+=" "+mu(t.attrs[e][0])+'="'+mu(t.attrs[e][1])+'"';return i},Fu.prototype.renderToken=function(t,e,r){const i=t[e];let n="";if(i.hidden)return"";i.block&&-1!==i.nesting&&e&&t[e-1].hidden&&(n+="\n"),n+=(-1===i.nesting?"</":"<")+i.tag,n+=this.renderAttrs(i),0===i.nesting&&r.xhtmlOut&&(n+=" /");let s=!1;if(i.block&&(s=!0,1===i.nesting&&e+1<t.length)){const r=t[e+1];("inline"===r.type||r.hidden||-1===r.nesting&&r.tag===i.tag)&&(s=!1)}return n+=s?">\n":">",n},Fu.prototype.renderInline=function(t,e,r){let i="";const n=this.rules;for(let s=0,o=t.length;s<o;s++){const o=t[s].type;i+=void 0!==n[o]?n[o](t,s,e,r,this):this.renderToken(t,s,e)}return i},Fu.prototype.renderInlineAsText=function(t,e,r){let i="";for(let n=0,s=t.length;n<s;n++)switch(t[n].type){case"text":case"html_inline":case"html_block":i+=t[n].content;break;case"image":i+=this.renderInlineAsText(t[n].children,e,r);break;case"softbreak":case"hardbreak":i+="\n"}return i},Fu.prototype.render=function(t,e,r){let i="";const n=this.rules;for(let s=0,o=t.length;s<o;s++){const o=t[s].type;i+="inline"===o?this.renderInline(t[s].children,e,r):void 0!==n[o]?n[o](t,s,e,r,this):this.renderToken(t,s,e,r)}return i},Mu.prototype.__find__=function(t){for(let e=0;e<this.__rules__.length;e++)if(this.__rules__[e].name===t)return e;return-1},Mu.prototype.__compile__=function(){const t=this,e=[""];t.__rules__.forEach((function(t){t.enabled&&t.alt.forEach((function(t){e.indexOf(t)<0&&e.push(t)}))})),t.__cache__={},e.forEach((function(e){t.__cache__[e]=[],t.__rules__.forEach((function(r){r.enabled&&(e&&r.alt.indexOf(e)<0||t.__cache__[e].push(r.fn))}))}))},Mu.prototype.at=function(t,e,r){const i=this.__find__(t),n=r||{};if(-1===i)throw new Error("Parser rule not found: "+t);this.__rules__[i].fn=e,this.__rules__[i].alt=n.alt||[],this.__cache__=null},Mu.prototype.before=function(t,e,r,i){const n=this.__find__(t),s=i||{};if(-1===n)throw new Error("Parser rule not found: "+t);this.__rules__.splice(n,0,{name:e,enabled:!0,fn:r,alt:s.alt||[]}),this.__cache__=null},Mu.prototype.after=function(t,e,r,i){const n=this.__find__(t),s=i||{};if(-1===n)throw new Error("Parser rule not found: "+t);this.__rules__.splice(n+1,0,{name:e,enabled:!0,fn:r,alt:s.alt||[]}),this.__cache__=null},Mu.prototype.push=function(t,e,r){this.__rules__.push({name:t,enabled:!0,fn:e,alt:(r||{}).alt||[]}),this.__cache__=null},Mu.prototype.enable=function(t,e){Array.isArray(t)||(t=[t]);const r=[];return 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=!0,r.push(t)}),this),this.__cache__=null,r},Mu.prototype.enableOnly=function(t,e){Array.isArray(t)||(t=[t]),this.__rules__.forEach((function(t){t.enabled=!1})),this.enable(t,e)},Mu.prototype.disable=function(t,e){Array.isArray(t)||(t=[t]);const r=[];return 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=!1,r.push(t)}),this),this.__cache__=null,r},Mu.prototype.getRules=function(t){return null===this.__cache__&&this.__compile__(),this.__cache__[t]||[]},Au.prototype.attrIndex=function(t){if(!this.attrs)return-1;const e=this.attrs;for(let r=0,i=e.length;r<i;r++)if(e[r][0]===t)return r;return-1},Au.prototype.attrPush=function(t){this.attrs?this.attrs.push(t):this.attrs=[t]},Au.prototype.attrSet=function(t,e){const r=this.attrIndex(t),i=[t,e];r<0?this.attrPush(i):this.attrs[r]=i},Au.prototype.attrGet=function(t){const e=this.attrIndex(t);let r=null;return e>=0&&(r=this.attrs[e][1]),r},Au.prototype.attrJoin=function(t,e){const r=this.attrIndex(t);r<0?this.attrPush([t,e]):this.attrs[r][1]=this.attrs[r][1]+" "+e},Cu.prototype.Token=Au;const Su=/\r\n?|\n/g,Ou=/\0/g;const $u=/\+-|\.\.|\?\?\?\?|!!!!|,,|--/,Bu=/\((c|tm|r)\)/i,Ru=/\((c|tm|r)\)/gi,Nu={c:"©",r:"®",tm:"™"};function _u(t,e){return Nu[e.toLowerCase()]}function Tu(t){let e=0;for(let r=t.length-1;r>=0;r--){const i=t[r];"text"!==i.type||e||(i.content=i.content.replace(Ru,_u)),"link_open"===i.type&&"auto"===i.info&&e--,"link_close"===i.type&&"auto"===i.info&&e++}}function zu(t){let e=0;for(let r=t.length-1;r>=0;r--){const i=t[r];"text"!==i.type||e||$u.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–")),"link_open"===i.type&&"auto"===i.info&&e--,"link_close"===i.type&&"auto"===i.info&&e++}}const ju=/['"]/,qu=/['"]/g;function Iu(t,e,r){return t.slice(0,e)+r+t.slice(e+1)}function Pu(t,e){let r;const i=[];for(let n=0;n<t.length;n++){const s=t[n],o=t[n].level;for(r=i.length-1;r>=0&&!(i[r].level<=o);r--);if(i.length=r+1,"text"!==s.type)continue;let l=s.content,u=0,h=l.length;t:for(;u<h;){qu.lastIndex=u;const a=qu.exec(l);if(!a)break;let f=!0,c=!0;u=a.index+1;const d="'"===a[0];let p=32;if(a.index-1>=0)p=l.charCodeAt(a.index-1);else for(r=n-1;r>=0&&"softbreak"!==t[r].type&&"hardbreak"!==t[r].type;r--)if(t[r].content){p=t[r].content.charCodeAt(t[r].content.length-1);break}let m=32;if(u<h)m=l.charCodeAt(u);else for(r=n+1;r<t.length&&"softbreak"!==t[r].type&&"hardbreak"!==t[r].type;r++)if(t[r].content){m=t[r].content.charCodeAt(0);break}const g=ku(p)||vu(String.fromCharCode(p)),b=ku(m)||vu(String.fromCharCode(m)),w=wu(p),v=wu(m);if(v?f=!1:b&&(w||g||(f=!1)),w?c=!1:g&&(v||b||(c=!1)),34===m&&'"'===a[0]&&p>=48&&p<=57&&(c=f=!1),f&&c&&(f=g,c=b),f||c){if(c)for(r=i.length-1;r>=0;r--){let f=i[r];if(i[r].level<o)break;if(f.single===d&&i[r].level===o){let o,c;f=i[r],d?(o=e.md.options.quotes[2],c=e.md.options.quotes[3]):(o=e.md.options.quotes[0],c=e.md.options.quotes[1]),s.content=Iu(s.content,a.index,c),t[f.token].content=Iu(t[f.token].content,f.pos,o),u+=c.length-1,f.token===n&&(u+=o.length-1),l=s.content,h=l.length,i.length=r;continue t}}f?i.push({token:n,pos:a.index,single:d,level:o}):c&&d&&(s.content=Iu(s.content,a.index,"’"))}else d&&(s.content=Iu(s.content,a.index,"’"))}}}const Lu=[["normalize",function(t){let e;e=t.src.replace(Su,"\n"),e=e.replace(Ou,"�"),t.src=e}],["block",function(t){let e;t.inlineMode?(e=new t.Token("inline","",0),e.content=t.src,e.map=[0,1],e.children=[],t.tokens.push(e)):t.md.block.parse(t.src,t.md,t.env,t.tokens)}],["inline",function(t){const e=t.tokens;for(let r=0,i=e.length;r<i;r++){const i=e[r];"inline"===i.type&&t.md.inline.parse(i.content,t.md,t.env,i.children)}}],["linkify",function(t){const e=t.tokens;if(t.md.options.linkify)for(let r=0,i=e.length;r<i;r++){if("inline"!==e[r].type||!t.md.linkify.pretest(e[r].content))continue;let i=e[r].children,n=0;for(let s=i.length-1;s>=0;s--){const o=i[s];if("link_close"!==o.type){if("html_inline"===o.type&&(/^<a[>\s]/i.test(o.content)&&n>0&&n--,/^<\/a\s*>/i.test(o.content)&&n++),!(n>0)&&"text"===o.type&&t.md.linkify.test(o.content)){const n=o.content;let l=t.md.linkify.match(n);const u=[];let h=o.level,a=0;l.length>0&&0===l[0].index&&s>0&&"text_special"===i[s-1].type&&(l=l.slice(1));for(let e=0;e<l.length;e++){const r=t.md.normalizeLink(l[e].url);if(!t.md.validateLink(r))continue;let i=l[e].text;i=l[e].schema?"mailto:"!==l[e].schema||/^mailto:/i.test(i)?t.md.normalizeLinkText(i):t.md.normalizeLinkText("mailto:"+i).replace(/^mailto:/,""):t.md.normalizeLinkText("http://"+i).replace(/^http:\/\//,"");const s=l[e].index;if(s>a){const e=new t.Token("text","",0);e.content=n.slice(a,s),e.level=h,u.push(e)}const o=new t.Token("link_open","a",1);o.attrs=[["href",r]],o.level=h++,o.markup="linkify",o.info="auto",u.push(o);const f=new t.Token("text","",0);f.content=i,f.level=h,u.push(f);const c=new t.Token("link_close","a",-1);c.level=--h,c.markup="linkify",c.info="auto",u.push(c),a=l[e].lastIndex}if(a<n.length){const e=new t.Token("text","",0);e.content=n.slice(a),e.level=h,u.push(e)}e[r].children=i=nu(i,s,u)}}else for(s--;i[s].level!==o.level&&"link_open"!==i[s].type;)s--}}}],["replacements",function(t){let e;if(t.md.options.typographer)for(e=t.tokens.length-1;e>=0;e--)"inline"===t.tokens[e].type&&(Bu.test(t.tokens[e].content)&&Tu(t.tokens[e].children),$u.test(t.tokens[e].content)&&zu(t.tokens[e].children))}],["smartquotes",function(t){if(t.md.options.typographer)for(let e=t.tokens.length-1;e>=0;e--)"inline"===t.tokens[e].type&&ju.test(t.tokens[e].content)&&Pu(t.tokens[e].children,t)}],["text_join",function(t){let e,r;const i=t.tokens,n=i.length;for(let t=0;t<n;t++){if("inline"!==i[t].type)continue;const n=i[t].children,s=n.length;for(e=0;e<s;e++)"text_special"===n[e].type&&(n[e].type="text");for(e=r=0;e<s;e++)"text"===n[e].type&&e+1<s&&"text"===n[e+1].type?n[e+1].content=n[e].content+n[e+1].content:(e!==r&&(n[r]=n[e]),r++);e!==r&&(n.length=r)}}]];function Ju(){this.ruler=new Mu;for(let t=0;t<Lu.length;t++)this.ruler.push(Lu[t][0],Lu[t][1])}function Uu(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=!1,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,o=!1;e<s;e++){const l=n.charCodeAt(e);if(!o){if(bu(l)){r++,9===l?i+=4-i%4:i++;continue}o=!0}10!==l&&e!==s-1||(10!==l&&e++,this.bMarks.push(t),this.eMarks.push(e),this.tShift.push(r),this.sCount.push(i),this.bsCount.push(0),o=!1,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}function Vu(t,e){return t.src.slice(t.bMarks[e]+t.tShift[e],t.eMarks[e])}function Hu(t){const e=[],r=t.length;let i=0,n=t.charCodeAt(i),s=!1,o=0,l="";for(;i<r;)124===n&&(s?(l+=t.substring(o,i-1),o=i):(e.push(l+t.substring(o,i)),l="",o=i+1)),s=92===n,i++,n=t.charCodeAt(i);return e.push(l+t.substring(o)),e}function Wu(t,e){const r=t.eMarks[e];let i=t.bMarks[e]+t.tShift[e];const n=t.src.charCodeAt(i++);return 42!==n&&45!==n&&43!==n||i<r&&!bu(t.src.charCodeAt(i))?-1:i}function Gu(t,e){const r=t.bMarks[e]+t.tShift[e],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;if(s=t.src.charCodeAt(n++),!(s>=48&&s<=57)){if(41===s||46===s)break;return-1}if(n-r>=10)return-1}return n<i&&(s=t.src.charCodeAt(n),!bu(s))?-1:n}Ju.prototype.process=function(t){const e=this.ruler.getRules("");for(let r=0,i=e.length;r<i;r++)e[r](t)},Ju.prototype.State=Cu,Uu.prototype.push=function(t,e,r){const i=new Au(t,e,r);return i.block=!0,r<0&&this.level--,i.level=this.level,r>0&&this.level++,this.tokens.push(i),i},Uu.prototype.isEmpty=function(t){return this.bMarks[t]+this.tShift[t]>=this.eMarks[t]},Uu.prototype.skipEmptyLines=function(t){for(let e=this.lineMax;t<e&&!(this.bMarks[t]+this.tShift[t]<this.eMarks[t]);t++);return t},Uu.prototype.skipSpaces=function(t){for(let e=this.src.length;t<e&&bu(this.src.charCodeAt(t));t++);return t},Uu.prototype.skipSpacesBack=function(t,e){if(t<=e)return t;for(;t>e;)if(!bu(this.src.charCodeAt(--t)))return t+1;return t},Uu.prototype.skipChars=function(t,e){for(let r=this.src.length;t<r&&this.src.charCodeAt(t)===e;t++);return t},Uu.prototype.skipCharsBack=function(t,e,r){if(t<=r)return t;for(;t>r;)if(e!==this.src.charCodeAt(--t))return t+1;return t},Uu.prototype.getLines=function(t,e,r,i){if(t>=e)return"";const n=new Array(e-t);for(let s=0,o=t;o<e;o++,s++){let t=0;const l=this.bMarks[o];let u,h=l;for(u=o+1<e||i?this.eMarks[o]+1:this.eMarks[o];h<u&&t<r;){const e=this.src.charCodeAt(h);if(bu(e))9===e?t+=4-(t+this.bsCount[o])%4:t++;else{if(!(h-l<this.tShift[o]))break;t++}h++}n[s]=t>r?new Array(t-r+1).join(" ")+this.src.slice(h,u):this.src.slice(h,u)}return n.join("")},Uu.prototype.Token=Au;const Zu="<[A-Za-z][A-Za-z0-9\\-]*(?:\\s+[a-zA-Z_:][a-zA-Z0-9:._-]*(?:\\s*=\\s*(?:[^\"'=<>`\\x00-\\x20]+|'[^']*'|\"[^\"]*\"))?)*\\s*\\/?>",Ku="<\\/[A-Za-z][A-Za-z0-9\\-]*\\s*>",Yu=new RegExp("^(?:"+Zu+"|"+Ku+"|\x3c!---?>|\x3c!--(?:[^-]|-[^-]|--[^>])*--\x3e|<[?][\\s\\S]*?[?]>|<![A-Za-z][^>]*>|<!\\[CDATA\\[[\\s\\S]*?\\]\\]>)"),Xu=new RegExp("^(?:"+Zu+"|"+Ku+")"),Qu=[[/^<(script|pre|style|textarea)(?=(\s|>|$))/i,/<\/(script|pre|style|textarea)>/i,!0],[/^<!--/,/-->/,!0],[/^<\?/,/\?>/,!0],[/^<![A-Z]/,/>/,!0],[/^<!\[CDATA\[/,/\]\]>/,!0],[new RegExp("^</?("+["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"].join("|")+")(?=(\\s|/?>|$))","i"),/^$/,!0],[new RegExp(Xu.source+"\\s*$"),/^$/,!1]],th=[["table",function(t,e,r,i){if(e+2>r)return!1;let n=e+1;if(t.sCount[n]<t.blkIndent)return!1;if(t.sCount[n]-t.blkIndent>=4)return!1;let s=t.bMarks[n]+t.tShift[n];if(s>=t.eMarks[n])return!1;const o=t.src.charCodeAt(s++);if(124!==o&&45!==o&&58!==o)return!1;if(s>=t.eMarks[n])return!1;const l=t.src.charCodeAt(s++);if(124!==l&&45!==l&&58!==l&&!bu(l))return!1;if(45===o&&bu(l))return!1;for(;s<t.eMarks[n];){const e=t.src.charCodeAt(s);if(124!==e&&45!==e&&58!==e&&!bu(e))return!1;s++}let u=Vu(t,e+1),h=u.split("|");const a=[];for(let t=0;t<h.length;t++){const e=h[t].trim();if(!e){if(0===t||t===h.length-1)continue;return!1}if(!/^:?-+:?$/.test(e))return!1;58===e.charCodeAt(e.length-1)?a.push(58===e.charCodeAt(0)?"center":"right"):58===e.charCodeAt(0)?a.push("left"):a.push("")}if(u=Vu(t,e).trim(),-1===u.indexOf("|"))return!1;if(t.sCount[e]-t.blkIndent>=4)return!1;h=Hu(u),h.length&&""===h[0]&&h.shift(),h.length&&""===h[h.length-1]&&h.pop();const f=h.length;if(0===f||f!==a.length)return!1;if(i)return!0;const c=t.parentType;t.parentType="table";const d=t.md.block.ruler.getRules("blockquote"),p=[e,0];t.push("table_open","table",1).map=p,t.push("thead_open","thead",1).map=[e,e+1],t.push("tr_open","tr",1).map=[e,e+1];for(let e=0;e<h.length;e++){const r=t.push("th_open","th",1);a[e]&&(r.attrs=[["style","text-align:"+a[e]]]);const i=t.push("inline","",0);i.content=h[e].trim(),i.children=[],t.push("th_close","th",-1)}let m;t.push("tr_close","tr",-1),t.push("thead_close","thead",-1);let g=0;for(n=e+2;n<r&&!(t.sCount[n]<t.blkIndent);n++){let i=!1;for(let e=0,s=d.length;e<s;e++)if(d[e](t,n,r,!0)){i=!0;break}if(i)break;if(u=Vu(t,n).trim(),!u)break;if(t.sCount[n]-t.blkIndent>=4)break;if(h=Hu(u),h.length&&""===h[0]&&h.shift(),h.length&&""===h[h.length-1]&&h.pop(),g+=f-h.length,g>65536)break;n===e+2&&(t.push("tbody_open","tbody",1).map=m=[e+2,0]),t.push("tr_open","tr",1).map=[n,n+1];for(let e=0;e<f;e++){const r=t.push("td_open","td",1);a[e]&&(r.attrs=[["style","text-align:"+a[e]]]);const i=t.push("inline","",0);i.content=h[e]?h[e].trim():"",i.children=[],t.push("td_close","td",-1)}t.push("tr_close","tr",-1)}return m&&(t.push("tbody_close","tbody",-1),m[1]=n),t.push("table_close","table",-1),p[1]=n,t.parentType=c,t.line=n,!0},["paragraph","reference"]],["code",function(t,e,r){if(t.sCount[e]-t.blkIndent<4)return!1;let i=e+1,n=i;for(;i<r;)if(t.isEmpty(i))i++;else{if(!(t.sCount[i]-t.blkIndent>=4))break;i++,n=i}t.line=n;const s=t.push("code_block","code",0);return s.content=t.getLines(e,n,4+t.blkIndent,!1)+"\n",s.map=[e,t.line],!0}],["fence",function(t,e,r,i){let n=t.bMarks[e]+t.tShift[e],s=t.eMarks[e];if(t.sCount[e]-t.blkIndent>=4)return!1;if(n+3>s)return!1;const o=t.src.charCodeAt(n);if(126!==o&&96!==o)return!1;let l=n;n=t.skipChars(n,o);let u=n-l;if(u<3)return!1;const h=t.src.slice(l,n),a=t.src.slice(n,s);if(96===o&&a.indexOf(String.fromCharCode(o))>=0)return!1;if(i)return!0;let f=e,c=!1;for(;!(f++,f>=r||(n=l=t.bMarks[f]+t.tShift[f],s=t.eMarks[f],n<s&&t.sCount[f]<t.blkIndent));)if(t.src.charCodeAt(n)===o&&!(t.sCount[f]-t.blkIndent>=4||(n=t.skipChars(n,o),n-l<u||(n=t.skipSpaces(n),n<s)))){c=!0;break}u=t.sCount[e],t.line=f+(c?1:0);const d=t.push("fence","code",0);return d.info=a,d.content=t.getLines(e+1,f,u,!0),d.markup=h,d.map=[e,t.line],!0},["paragraph","reference","blockquote","list"]],["blockquote",function(t,e,r,i){let n=t.bMarks[e]+t.tShift[e],s=t.eMarks[e];const o=t.lineMax;if(t.sCount[e]-t.blkIndent>=4)return!1;if(62!==t.src.charCodeAt(n))return!1;if(i)return!0;const l=[],u=[],h=[],a=[],f=t.md.block.ruler.getRules("blockquote"),c=t.parentType;t.parentType="blockquote";let d,p=!1;for(d=e;d<r;d++){const e=t.sCount[d]<t.blkIndent;if(n=t.bMarks[d]+t.tShift[d],s=t.eMarks[d],n>=s)break;if(62===t.src.charCodeAt(n++)&&!e){let e,r,i=t.sCount[d]+1;32===t.src.charCodeAt(n)?(n++,i++,r=!1,e=!0):9===t.src.charCodeAt(n)?(e=!0,(t.bsCount[d]+i)%4==3?(n++,i++,r=!1):r=!0):e=!1;let o=i;for(l.push(t.bMarks[d]),t.bMarks[d]=n;n<s;){const e=t.src.charCodeAt(n);if(!bu(e))break;9===e?o+=4-(o+t.bsCount[d]+(r?1:0))%4:o++,n++}p=n>=s,u.push(t.bsCount[d]),t.bsCount[d]=t.sCount[d]+1+(e?1:0),h.push(t.sCount[d]),t.sCount[d]=o-i,a.push(t.tShift[d]),t.tShift[d]=n-t.bMarks[d];continue}if(p)break;let i=!1;for(let e=0,n=f.length;e<n;e++)if(f[e](t,d,r,!0)){i=!0;break}if(i){t.lineMax=d,0!==t.blkIndent&&(l.push(t.bMarks[d]),u.push(t.bsCount[d]),a.push(t.tShift[d]),h.push(t.sCount[d]),t.sCount[d]-=t.blkIndent);break}l.push(t.bMarks[d]),u.push(t.bsCount[d]),a.push(t.tShift[d]),h.push(t.sCount[d]),t.sCount[d]=-1}const m=t.blkIndent;t.blkIndent=0;const g=t.push("blockquote_open","blockquote",1);g.markup=">";const b=[e,0];g.map=b,t.md.block.tokenize(t,e,d),t.push("blockquote_close","blockquote",-1).markup=">",t.lineMax=o,t.parentType=c,b[1]=t.line;for(let r=0;r<a.length;r++)t.bMarks[r+e]=l[r],t.tShift[r+e]=a[r],t.sCount[r+e]=h[r],t.bsCount[r+e]=u[r];return t.blkIndent=m,!0},["paragraph","reference","blockquote","list"]],["hr",function(t,e,r,i){const n=t.eMarks[e];if(t.sCount[e]-t.blkIndent>=4)return!1;let s=t.bMarks[e]+t.tShift[e];const o=t.src.charCodeAt(s++);if(42!==o&&45!==o&&95!==o)return!1;let l=1;for(;s<n;){const e=t.src.charCodeAt(s++);if(e!==o&&!bu(e))return!1;e===o&&l++}if(l<3)return!1;if(i)return!0;t.line=e+1;const u=t.push("hr","hr",0);return u.map=[e,t.line],u.markup=Array(l+1).join(String.fromCharCode(o)),!0},["paragraph","reference","blockquote","list"]],["list",function(t,e,r,i){let n,s,o,l,u=e,h=!0;if(t.sCount[u]-t.blkIndent>=4)return!1;if(t.listIndent>=0&&t.sCount[u]-t.listIndent>=4&&t.sCount[u]<t.blkIndent)return!1;let a,f,c,d=!1;if(i&&"paragraph"===t.parentType&&t.sCount[u]>=t.blkIndent&&(d=!0),(c=Gu(t,u))>=0){if(a=!0,o=t.bMarks[u]+t.tShift[u],f=Number(t.src.slice(o,c-1)),d&&1!==f)return!1}else{if(!((c=Wu(t,u))>=0))return!1;a=!1}if(d&&t.skipSpaces(c)>=t.eMarks[u])return!1;if(i)return!0;const p=t.src.charCodeAt(c-1),m=t.tokens.length;a?(l=t.push("ordered_list_open","ol",1),1!==f&&(l.attrs=[["start",f]])):l=t.push("bullet_list_open","ul",1);const g=[u,0];l.map=g,l.markup=String.fromCharCode(p);let b=!1;const w=t.md.block.ruler.getRules("list"),v=t.parentType;for(t.parentType="list";u<r;){s=c,n=t.eMarks[u];const e=t.sCount[u]+c-(t.bMarks[u]+t.tShift[u]);let i=e;for(;s<n;){const e=t.src.charCodeAt(s);if(9===e)i+=4-(i+t.bsCount[u])%4;else{if(32!==e)break;i++}s++}const f=s;let d;d=f>=n?1:i-e,d>4&&(d=1);const m=e+d;l=t.push("list_item_open","li",1),l.markup=String.fromCharCode(p);const g=[u,0];l.map=g,a&&(l.info=t.src.slice(o,c-1));const v=t.tight,k=t.tShift[u],D=t.sCount[u],y=t.listIndent;if(t.listIndent=t.blkIndent,t.blkIndent=m,t.tight=!0,t.tShift[u]=f-t.bMarks[u],t.sCount[u]=i,f>=n&&t.isEmpty(u+1)?t.line=Math.min(t.line+2,r):t.md.block.tokenize(t,u,r,!0),t.tight&&!b||(h=!1),b=t.line-u>1&&t.isEmpty(t.line-1),t.blkIndent=t.listIndent,t.listIndent=y,t.tShift[u]=k,t.sCount[u]=D,t.tight=v,l=t.push("list_item_close","li",-1),l.markup=String.fromCharCode(p),u=t.line,g[1]=u,u>=r)break;if(t.sCount[u]<t.blkIndent)break;if(t.sCount[u]-t.blkIndent>=4)break;let E=!1;for(let e=0,i=w.length;e<i;e++)if(w[e](t,u,r,!0)){E=!0;break}if(E)break;if(a){if(c=Gu(t,u),c<0)break;o=t.bMarks[u]+t.tShift[u]}else if(c=Wu(t,u),c<0)break;if(p!==t.src.charCodeAt(c-1))break}return l=a?t.push("ordered_list_close","ol",-1):t.push("bullet_list_close","ul",-1),l.markup=String.fromCharCode(p),g[1]=u,t.line=u,t.parentType=v,h&&function(t,e){const r=t.level+2;for(let i=e+2,n=t.tokens.length-2;i<n;i++)t.tokens[i].level===r&&"paragraph_open"===t.tokens[i].type&&(t.tokens[i+2].hidden=!0,t.tokens[i].hidden=!0,i+=2)}(t,m),!0},["paragraph","reference","blockquote"]],["reference",function(t,e,r,i){let n=t.bMarks[e]+t.tShift[e],s=t.eMarks[e],o=e+1;if(t.sCount[e]-t.blkIndent>=4)return!1;if(91!==t.src.charCodeAt(n))return!1;function l(e){const r=t.lineMax;if(e>=r||t.isEmpty(e))return null;let i=!1;if(t.sCount[e]-t.blkIndent>3&&(i=!0),t.sCount[e]<0&&(i=!0),!i){const i=t.md.block.ruler.getRules("reference"),n=t.parentType;t.parentType="reference";let s=!1;for(let n=0,o=i.length;n<o;n++)if(i[n](t,e,r,!0)){s=!0;break}if(t.parentType=n,s)return null}return t.src.slice(t.bMarks[e]+t.tShift[e],t.eMarks[e]+1)}let u=t.src.slice(n,s+1);s=u.length;let h=-1;for(n=1;n<s;n++){const t=u.charCodeAt(n);if(91===t)return!1;if(93===t){h=n;break}if(10===t){const t=l(o);null!==t&&(u+=t,s=u.length,o++)}else if(92===t&&(n++,n<s&&10===u.charCodeAt(n))){const t=l(o);null!==t&&(u+=t,s=u.length,o++)}}if(h<0||58!==u.charCodeAt(h+1))return!1;for(n=h+2;n<s;n++){const t=u.charCodeAt(n);if(10===t){const t=l(o);null!==t&&(u+=t,s=u.length,o++)}else if(!bu(t))break}const a=t.md.helpers.parseLinkDestination(u,n,s);if(!a.ok)return!1;const f=t.md.normalizeLink(a.str);if(!t.md.validateLink(f))return!1;n=a.pos;const c=n,d=o,p=n;for(;n<s;n++){const t=u.charCodeAt(n);if(10===t){const t=l(o);null!==t&&(u+=t,s=u.length,o++)}else if(!bu(t))break}let m,g=t.md.helpers.parseLinkTitle(u,n,s);for(;g.can_continue;){const e=l(o);if(null===e)break;u+=e,n=s,s=u.length,o++,g=t.md.helpers.parseLinkTitle(u,n,s,g)}for(n<s&&p!==n&&g.ok?(m=g.str,n=g.pos):(m="",n=c,o=d);n<s&&bu(u.charCodeAt(n));)n++;if(n<s&&10!==u.charCodeAt(n)&&m)for(m="",n=c,o=d;n<s&&bu(u.charCodeAt(n));)n++;if(n<s&&10!==u.charCodeAt(n))return!1;const b=Du(u.slice(1,h));return!!b&&(i||(void 0===t.env.references&&(t.env.references={}),void 0===t.env.references[b]&&(t.env.references[b]={title:m,href:f}),t.line=o),!0)}],["html_block",function(t,e,r,i){let n=t.bMarks[e]+t.tShift[e],s=t.eMarks[e];if(t.sCount[e]-t.blkIndent>=4)return!1;if(!t.md.options.html)return!1;if(60!==t.src.charCodeAt(n))return!1;let o=t.src.slice(n,s),l=0;for(;l<Qu.length&&!Qu[l][0].test(o);l++);if(l===Qu.length)return!1;if(i)return Qu[l][2];let u=e+1;if(!Qu[l][1].test(o))for(;u<r&&!(t.sCount[u]<t.blkIndent);u++)if(n=t.bMarks[u]+t.tShift[u],s=t.eMarks[u],o=t.src.slice(n,s),Qu[l][1].test(o)){0!==o.length&&u++;break}t.line=u;const h=t.push("html_block","",0);return h.map=[e,u],h.content=t.getLines(e,u,t.blkIndent,!0),!0},["paragraph","reference","blockquote"]],["heading",function(t,e,r,i){let n=t.bMarks[e]+t.tShift[e],s=t.eMarks[e];if(t.sCount[e]-t.blkIndent>=4)return!1;let o=t.src.charCodeAt(n);if(35!==o||n>=s)return!1;let l=1;for(o=t.src.charCodeAt(++n);35===o&&n<s&&l<=6;)l++,o=t.src.charCodeAt(++n);if(l>6||n<s&&!bu(o))return!1;if(i)return!0;s=t.skipSpacesBack(s,n);const u=t.skipCharsBack(s,35,n);u>n&&bu(t.src.charCodeAt(u-1))&&(s=u),t.line=e+1;const h=t.push("heading_open","h"+String(l),1);h.markup="########".slice(0,l),h.map=[e,t.line];const a=t.push("inline","",0);return a.content=t.src.slice(n,s).trim(),a.map=[e,t.line],a.children=[],t.push("heading_close","h"+String(l),-1).markup="########".slice(0,l),!0},["paragraph","reference","blockquote"]],["lheading",function(t,e,r){const i=t.md.block.ruler.getRules("paragraph");if(t.sCount[e]-t.blkIndent>=4)return!1;const n=t.parentType;t.parentType="paragraph";let s,o=0,l=e+1;for(;l<r&&!t.isEmpty(l);l++){if(t.sCount[l]-t.blkIndent>3)continue;if(t.sCount[l]>=t.blkIndent){let e=t.bMarks[l]+t.tShift[l];const r=t.eMarks[l];if(e<r&&(s=t.src.charCodeAt(e),(45===s||61===s)&&(e=t.skipChars(e,s),e=t.skipSpaces(e),e>=r))){o=61===s?1:2;break}}if(t.sCount[l]<0)continue;let e=!1;for(let n=0,s=i.length;n<s;n++)if(i[n](t,l,r,!0)){e=!0;break}if(e)break}if(!o)return!1;const u=t.getLines(e,l,t.blkIndent,!1).trim();t.line=l+1;const h=t.push("heading_open","h"+String(o),1);h.markup=String.fromCharCode(s),h.map=[e,t.line];const a=t.push("inline","",0);return a.content=u,a.map=[e,t.line-1],a.children=[],t.push("heading_close","h"+String(o),-1).markup=String.fromCharCode(s),t.parentType=n,!0}],["paragraph",function(t,e,r){const i=t.md.block.ruler.getRules("paragraph"),n=t.parentType;let s=e+1;for(t.parentType="paragraph";s<r&&!t.isEmpty(s);s++){if(t.sCount[s]-t.blkIndent>3)continue;if(t.sCount[s]<0)continue;let e=!1;for(let n=0,o=i.length;n<o;n++)if(i[n](t,s,r,!0)){e=!0;break}if(e)break}const o=t.getLines(e,s,t.blkIndent,!1).trim();t.line=s,t.push("paragraph_open","p",1).map=[e,t.line];const l=t.push("inline","",0);return l.content=o,l.map=[e,t.line],l.children=[],t.push("paragraph_close","p",-1),t.parentType=n,!0}]];function eh(){this.ruler=new Mu;for(let t=0;t<th.length;t++)this.ruler.push(th[t][0],th[t][1],{alt:(th[t][2]||[]).slice()})}function rh(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=!1,this.linkLevel=0}function ih(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!0;default:return!1}}eh.prototype.tokenize=function(t,e,r){const i=this.ruler.getRules(""),n=i.length,s=t.md.options.maxNesting;let o=e,l=!1;for(;o<r&&(t.line=o=t.skipEmptyLines(o),!(o>=r))&&!(t.sCount[o]<t.blkIndent);){if(t.level>=s){t.line=r;break}const e=t.line;let u=!1;for(let s=0;s<n;s++)if(u=i[s](t,o,r,!1),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=!l,t.isEmpty(t.line-1)&&(l=!0),o=t.line,o<r&&t.isEmpty(o)&&(l=!0,o++,t.line=o)}},eh.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)},eh.prototype.State=Uu,rh.prototype.pushPending=function(){const t=new Au("text","",0);return t.content=this.pending,t.level=this.pendingLevel,this.tokens.push(t),this.pending="",t},rh.prototype.push=function(t,e,r){this.pending&&this.pushPending();const i=new Au(t,e,r);let n=null;return r<0&&(this.level--,this.delimiters=this._prev_delimiters.pop()),i.level=this.level,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),i},rh.prototype.scanDelims=function(t,e){const r=this.posMax,i=this.src.charCodeAt(t),n=t>0?this.src.charCodeAt(t-1):32;let s=t;for(;s<r&&this.src.charCodeAt(s)===i;)s++;const o=s-t,l=s<r?this.src.charCodeAt(s):32,u=ku(n)||vu(String.fromCharCode(n)),h=ku(l)||vu(String.fromCharCode(l)),a=wu(n),f=wu(l),c=!f&&(!h||a||u),d=!a&&(!u||f||h);return{can_open:c&&(e||!d||u),can_close:d&&(e||!c||h),length:o}},rh.prototype.Token=Au;const nh=/(?:^|[^a-z0-9.+-])([a-z][a-z0-9.+-]*)$/i,sh=[];for(let t=0;t<256;t++)sh.push(0);function oh(t,e){let r;const i=[],n=e.length;for(let s=0;s<n;s++){const n=e[s];if(126!==n.marker)continue;if(-1===n.end)continue;const o=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[o.token],r.type="s_close",r.tag="s",r.nesting=-1,r.markup="~~",r.content="","text"===t.tokens[o.token-1].type&&"~"===t.tokens[o.token-1].content&&i.push(o.token-1)}for(;i.length;){const e=i.pop();let n=e+1;for(;n<t.tokens.length&&"s_close"===t.tokens[n].type;)n++;n--,e!==n&&(r=t.tokens[n],t.tokens[n]=t.tokens[e],t.tokens[e]=r)}}"\\!\"#$%&'()*+,./:;<=>?@[]^_`{|}~-".split("").forEach((function(t){sh[t.charCodeAt(0)]=1}));var lh={tokenize:function(t,e){const r=t.src.charCodeAt(t.pos);if(e)return!1;if(126!==r)return!1;const i=t.scanDelims(t.pos,!0);let n=i.length;const s=String.fromCharCode(r);if(n<2)return!1;let o;n%2&&(o=t.push("text","",0),o.content=s,n--);for(let e=0;e<n;e+=2)o=t.push("text","",0),o.content=s+s,t.delimiters.push({marker:r,length:0,token:t.tokens.length-1,end:-1,open:i.can_open,close:i.can_close});return t.pos+=i.length,!0},postProcess:function(t){const e=t.tokens_meta,r=t.tokens_meta.length;oh(t,t.delimiters);for(let i=0;i<r;i++)e[i]&&e[i].delimiters&&oh(t,e[i].delimiters)}};function uh(t,e){for(let r=e.length-1;r>=0;r--){const i=e[r];if(95!==i.marker&&42!==i.marker)continue;if(-1===i.end)continue;const n=e[i.end],s=r>0&&e[r-1].end===i.end+1&&e[r-1].marker===i.marker&&e[r-1].token===i.token-1&&e[i.end+1].token===n.token+1,o=String.fromCharCode(i.marker),l=t.tokens[i.token];l.type=s?"strong_open":"em_open",l.tag=s?"strong":"em",l.nesting=1,l.markup=s?o+o:o,l.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?o+o:o,u.content="",s&&(t.tokens[e[r-1].token].content="",t.tokens[e[i.end+1].token].content="",r--)}}var hh={tokenize:function(t,e){const r=t.src.charCodeAt(t.pos);if(e)return!1;if(95!==r&&42!==r)return!1;const i=t.scanDelims(t.pos,42===r);for(let e=0;e<i.length;e++)t.push("text","",0).content=String.fromCharCode(r),t.delimiters.push({marker:r,length:i.length,token:t.tokens.length-1,end:-1,open:i.can_open,close:i.can_close});return t.pos+=i.length,!0},postProcess:function(t){const e=t.tokens_meta,r=t.tokens_meta.length;uh(t,t.delimiters);for(let i=0;i<r;i++)e[i]&&e[i].delimiters&&uh(t,e[i].delimiters)}};const ah=/^([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])?)*)$/,fh=/^([a-zA-Z][a-zA-Z0-9+.-]{1,31}):([^<>\x00-\x20]*)$/,ch=/^&#((?:x[a-f0-9]{1,6}|[0-9]{1,7}));/i,dh=/^&([a-z][a-z0-9]{1,31});/i;function ph(t){const e={},r=t.length;if(!r)return;let i=0,n=-2;const s=[];for(let o=0;o<r;o++){const r=t[o];if(s.push(0),t[i].marker===r.marker&&n===r.token-1||(i=o),n=r.token,r.length=r.length||0,!r.close)continue;e.hasOwnProperty(r.marker)||(e[r.marker]=[-1,-1,-1,-1,-1,-1]);const l=e[r.marker][(r.open?3:0)+r.length%3];let u=i-s[i]-1,h=u;for(;u>l;u-=s[u]+1){const e=t[u];if(e.marker===r.marker&&e.open&&e.end<0){let i=!1;if((e.close||r.open)&&(e.length+r.length)%3==0&&(e.length%3==0&&r.length%3==0||(i=!0)),!i){const i=u>0&&!t[u-1].open?s[u-1]+1:0;s[o]=o-u+i,s[u]=i,r.open=!1,e.end=o,e.close=!1,h=-1,n=-2;break}}}-1!==h&&(e[r.marker][(r.open?3:0)+(r.length||0)%3]=h)}}const mh=[["text",function(t,e){let r=t.pos;for(;r<t.posMax&&!ih(t.src.charCodeAt(r));)r++;return r!==t.pos&&(e||(t.pending+=t.src.slice(t.pos,r)),t.pos=r,!0)}],["linkify",function(t,e){if(!t.md.options.linkify)return!1;if(t.linkLevel>0)return!1;const r=t.pos;if(r+3>t.posMax)return!1;if(58!==t.src.charCodeAt(r))return!1;if(47!==t.src.charCodeAt(r+1))return!1;if(47!==t.src.charCodeAt(r+2))return!1;const i=t.pending.match(nh);if(!i)return!1;const n=i[1],s=t.md.linkify.matchAtStart(t.src.slice(r-n.length));if(!s)return!1;let o=s.url;if(o.length<=n.length)return!1;o=o.replace(/\*+$/,"");const l=t.md.normalizeLink(o);if(!t.md.validateLink(l))return!1;if(!e){t.pending=t.pending.slice(0,-n.length);const e=t.push("link_open","a",1);e.attrs=[["href",l]],e.markup="linkify",e.info="auto",t.push("text","",0).content=t.md.normalizeLinkText(o);const r=t.push("link_close","a",-1);r.markup="linkify",r.info="auto"}return t.pos+=o.length-n.length,!0}],["newline",function(t,e){let r=t.pos;if(10!==t.src.charCodeAt(r))return!1;const i=t.pending.length-1,n=t.posMax;if(!e)if(i>=0&&32===t.pending.charCodeAt(i))if(i>=1&&32===t.pending.charCodeAt(i-1)){let e=i-1;for(;e>=1&&32===t.pending.charCodeAt(e-1);)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);for(r++;r<n&&bu(t.src.charCodeAt(r));)r++;return t.pos=r,!0}],["escape",function(t,e){let r=t.pos;const i=t.posMax;if(92!==t.src.charCodeAt(r))return!1;if(r++,r>=i)return!1;let n=t.src.charCodeAt(r);if(10===n){for(e||t.push("hardbreak","br",0),r++;r<i&&(n=t.src.charCodeAt(r),bu(n));)r++;return t.pos=r,!0}let s=t.src[r];if(n>=55296&&n<=56319&&r+1<i){const e=t.src.charCodeAt(r+1);e>=56320&&e<=57343&&(s+=t.src[r+1],r++)}const o="\\"+s;if(!e){const e=t.push("text_special","",0);e.content=n<256&&0!==sh[n]?s:o,e.markup=o,e.info="escape"}return t.pos=r+1,!0}],["backticks",function(t,e){let r=t.pos;if(96!==t.src.charCodeAt(r))return!1;const i=r;r++;const n=t.posMax;for(;r<n&&96===t.src.charCodeAt(r);)r++;const s=t.src.slice(i,r),o=s.length;if(t.backticksScanned&&(t.backticks[o]||0)<=i)return e||(t.pending+=s),t.pos+=o,!0;let l,u=r;for(;-1!==(l=t.src.indexOf("`",u));){for(u=l+1;u<n&&96===t.src.charCodeAt(u);)u++;const i=u-l;if(i===o){if(!e){const e=t.push("code_inline","code",0);e.markup=s,e.content=t.src.slice(r,l).replace(/\n/g," ").replace(/^ (.+) $/,"$1")}return t.pos=u,!0}t.backticks[i]=l}return t.backticksScanned=!0,e||(t.pending+=s),t.pos+=o,!0}],["strikethrough",lh.tokenize],["emphasis",hh.tokenize],["link",function(t,e){let r,i,n,s,o="",l="",u=t.pos,h=!0;if(91!==t.src.charCodeAt(t.pos))return!1;const a=t.pos,f=t.posMax,c=t.pos+1,d=t.md.helpers.parseLinkLabel(t,t.pos,!0);if(d<0)return!1;let p=d+1;if(p<f&&40===t.src.charCodeAt(p)){for(h=!1,p++;p<f&&(r=t.src.charCodeAt(p),bu(r)||10===r);p++);if(p>=f)return!1;if(u=p,n=t.md.helpers.parseLinkDestination(t.src,p,t.posMax),n.ok){for(o=t.md.normalizeLink(n.str),t.md.validateLink(o)?p=n.pos:o="",u=p;p<f&&(r=t.src.charCodeAt(p),bu(r)||10===r);p++);if(n=t.md.helpers.parseLinkTitle(t.src,p,t.posMax),p<f&&u!==p&&n.ok)for(l=n.str,p=n.pos;p<f&&(r=t.src.charCodeAt(p),bu(r)||10===r);p++);}(p>=f||41!==t.src.charCodeAt(p))&&(h=!0),p++}if(h){if(void 0===t.env.references)return!1;if(p<f&&91===t.src.charCodeAt(p)?(u=p+1,p=t.md.helpers.parseLinkLabel(t,p),p>=0?i=t.src.slice(u,p++):p=d+1):p=d+1,i||(i=t.src.slice(c,d)),s=t.env.references[Du(i)],!s)return t.pos=a,!1;o=s.href,l=s.title}if(!e){t.pos=c,t.posMax=d;const e=[["href",o]];t.push("link_open","a",1).attrs=e,l&&e.push(["title",l]),t.linkLevel++,t.md.inline.tokenize(t),t.linkLevel--,t.push("link_close","a",-1)}return t.pos=p,t.posMax=f,!0}],["image",function(t,e){let r,i,n,s,o,l,u,h,a="";const f=t.pos,c=t.posMax;if(33!==t.src.charCodeAt(t.pos))return!1;if(91!==t.src.charCodeAt(t.pos+1))return!1;const d=t.pos+2,p=t.md.helpers.parseLinkLabel(t,t.pos+1,!1);if(p<0)return!1;if(s=p+1,s<c&&40===t.src.charCodeAt(s)){for(s++;s<c&&(r=t.src.charCodeAt(s),bu(r)||10===r);s++);if(s>=c)return!1;for(h=s,l=t.md.helpers.parseLinkDestination(t.src,s,t.posMax),l.ok&&(a=t.md.normalizeLink(l.str),t.md.validateLink(a)?s=l.pos:a=""),h=s;s<c&&(r=t.src.charCodeAt(s),bu(r)||10===r);s++);if(l=t.md.helpers.parseLinkTitle(t.src,s,t.posMax),s<c&&h!==s&&l.ok)for(u=l.str,s=l.pos;s<c&&(r=t.src.charCodeAt(s),bu(r)||10===r);s++);else u="";if(s>=c||41!==t.src.charCodeAt(s))return t.pos=f,!1;s++}else{if(void 0===t.env.references)return!1;if(s<c&&91===t.src.charCodeAt(s)?(h=s+1,s=t.md.helpers.parseLinkLabel(t,s),s>=0?n=t.src.slice(h,s++):s=p+1):s=p+1,n||(n=t.src.slice(d,p)),o=t.env.references[Du(n)],!o)return t.pos=f,!1;a=o.href,u=o.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),n=[["src",a],["alt",""]];r.attrs=n,r.children=e,r.content=i,u&&n.push(["title",u])}return t.pos=s,t.posMax=c,!0}],["autolink",function(t,e){let r=t.pos;if(60!==t.src.charCodeAt(r))return!1;const i=t.pos,n=t.posMax;for(;;){if(++r>=n)return!1;const e=t.src.charCodeAt(r);if(60===e)return!1;if(62===e)break}const s=t.src.slice(i+1,r);if(fh.test(s)){const r=t.md.normalizeLink(s);if(!t.md.validateLink(r))return!1;if(!e){const e=t.push("link_open","a",1);e.attrs=[["href",r]],e.markup="autolink",e.info="auto",t.push("text","",0).content=t.md.normalizeLinkText(s);const i=t.push("link_close","a",-1);i.markup="autolink",i.info="auto"}return t.pos+=s.length+2,!0}if(ah.test(s)){const r=t.md.normalizeLink("mailto:"+s);if(!t.md.validateLink(r))return!1;if(!e){const e=t.push("link_open","a",1);e.attrs=[["href",r]],e.markup="autolink",e.info="auto",t.push("text","",0).content=t.md.normalizeLinkText(s);const i=t.push("link_close","a",-1);i.markup="autolink",i.info="auto"}return t.pos+=s.length+2,!0}return!1}],["html_inline",function(t,e){if(!t.md.options.html)return!1;const r=t.posMax,i=t.pos;if(60!==t.src.charCodeAt(i)||i+2>=r)return!1;const n=t.src.charCodeAt(i+1);if(33!==n&&63!==n&&47!==n&&!function(t){const e=32|t;return e>=97&&e<=122}(n))return!1;const s=t.src.slice(i).match(Yu);if(!s)return!1;if(!e){const e=t.push("html_inline","",0);e.content=s[0],/^<a[>\s]/i.test(e.content)&&t.linkLevel++,/^<\/a\s*>/i.test(e.content)&&t.linkLevel--}return t.pos+=s[0].length,!0}],["entity",function(t,e){const r=t.pos,i=t.posMax;if(38!==t.src.charCodeAt(r))return!1;if(r+1>=i)return!1;if(35===t.src.charCodeAt(r+1)){const i=t.src.slice(r).match(ch);if(i){if(!e){const e="x"===i[1][0].toLowerCase()?parseInt(i[1].slice(1),16):parseInt(i[1],10),r=t.push("text_special","",0);r.content=su(e)?ou(e):ou(65533),r.markup=i[0],r.info="entity"}return t.pos+=i[0].length,!0}}else{const i=t.src.slice(r).match(dh);if(i){const r=M(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"}return t.pos+=i[0].length,!0}}}return!1}]],gh=[["balance_pairs",function(t){const e=t.tokens_meta,r=t.tokens_meta.length;ph(t.delimiters);for(let t=0;t<r;t++)e[t]&&e[t].delimiters&&ph(e[t].delimiters)}],["strikethrough",lh.postProcess],["emphasis",hh.postProcess],["fragments_join",function(t){let e,r,i=0;const n=t.tokens,s=t.tokens.length;for(e=r=0;e<s;e++)n[e].nesting<0&&i--,n[e].level=i,n[e].nesting>0&&i++,"text"===n[e].type&&e+1<s&&"text"===n[e+1].type?n[e+1].content=n[e].content+n[e+1].content:(e!==r&&(n[r]=n[e]),r++);e!==r&&(n.length=r)}]];function bh(){this.ruler=new Mu;for(let t=0;t<mh.length;t++)this.ruler.push(mh[t][0],mh[t][1]);this.ruler2=new Mu;for(let t=0;t<gh.length;t++)this.ruler2.push(gh[t][0],gh[t][1])}function wh(t){return Array.prototype.slice.call(arguments,1).forEach((function(e){e&&Object.keys(e).forEach((function(r){t[r]=e[r]}))})),t}function vh(t){return Object.prototype.toString.call(t)}function kh(t){return"[object Function]"===vh(t)}function Dh(t){return t.replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}bh.prototype.skipToken=function(t){const e=t.pos,r=this.ruler.getRules(""),i=r.length,n=t.md.options.maxNesting,s=t.cache;if(void 0!==s[e])return void(t.pos=s[e]);let o=!1;if(t.level<n){for(let n=0;n<i;n++)if(t.level++,o=r[n](t,!0),t.level--,o){if(e>=t.pos)throw new Error("inline rule didn't increment state.pos");break}}else t.pos=t.posMax;o||t.pos++,s[e]=t.pos},bh.prototype.tokenize=function(t){const e=this.ruler.getRules(""),r=e.length,i=t.posMax,n=t.md.options.maxNesting;for(;t.pos<i;){const s=t.pos;let o=!1;if(t.level<n)for(let i=0;i<r;i++)if(o=e[i](t,!1),o){if(s>=t.pos)throw new Error("inline rule didn't increment state.pos");break}if(o){if(t.pos>=i)break}else t.pending+=t.src[t.pos++]}t.pending&&t.pushPending()},bh.prototype.parse=function(t,e,r,i){const n=new this.State(t,e,r,i);this.tokenize(n);const s=this.ruler2.getRules(""),o=s.length;for(let t=0;t<o;t++)s[t](n)},bh.prototype.State=rh;const yh={fuzzyLink:!0,fuzzyEmail:!0,fuzzyIP:!1},Eh={"http:":{validate:function(t,e,r){const i=t.slice(e);return r.re.http||(r.re.http=new RegExp("^\\/\\/"+r.re.src_auth+r.re.src_host_port_strict+r.re.src_path,"i")),r.re.http.test(i)?i.match(r.re.http)[0].length:0}},"https:":"http:","ftp:":"http:","//":{validate:function(t,e,r){const i=t.slice(e);return 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")),r.re.no_http.test(i)?e>=3&&":"===t[e-3]||e>=3&&"/"===t[e-3]?0:i.match(r.re.no_http)[0].length:0}},"mailto:":{validate:function(t,e,r){const i=t.slice(e);return r.re.mailto||(r.re.mailto=new RegExp("^"+r.re.src_email_name+"@"+r.re.src_host_strict,"i")),r.re.mailto.test(i)?i.match(r.re.mailto)[0].length:0}}},xh="biz|com|edu|gov|net|org|pro|web|xxx|aero|asia|coop|info|museum|name|shop|рф".split("|");function Fh(t){const e=t.re=function(t){const e={};t=t||{},e.src_Any=Gl.source,e.src_Cc=Zl.source,e.src_Z=Xl.source,e.src_P=Kl.source,e.src_ZPCc=[e.src_Z,e.src_P,e.src_Cc].join("|"),e.src_ZCc=[e.src_Z,e.src_Cc].join("|");return e.src_pseudo_letter="(?:(?![><|]|"+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="(?=$|[><|]|"+e.src_ZPCc+")(?!"+(t["---"]?"-(?!--)|":"-|")+"_|:\\d|\\.-|\\.(?!$|"+e.src_ZPCc+"))",e.src_path="(?:[/?#](?:(?!"+e.src_ZCc+"|[><|]|[()[\\]{}.,\"'?!\\-;]).|\\[(?:(?!"+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='(^|[><|]|"|\\(|'+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+")",e}(t.__opts__),r=t.__tlds__.slice();function i(t){return t.replace("%TLDS%",e.src_tlds)}t.onCompile(),t.__tlds_replaced__||r.push("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]"),r.push(e.src_xn),e.src_tlds=r.join("|"),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=[];function s(t,e){throw new Error('(LinkifyIt) Invalid schema "'+t+'": '+e)}t.__compiled__={},Object.keys(t.__schemas__).forEach((function(e){const r=t.__schemas__[e];if(null===r)return;const i={validate:null,link:null};if(t.__compiled__[e]=i,"[object Object]"===vh(r))return"[object RegExp]"!==vh(r.validate)?kh(r.validate)?i.validate=r.validate:s(e,r):i.validate=function(t){return function(e,r){const i=e.slice(r);return t.test(i)?i.match(t)[0].length:0}}(r.validate),void(kh(r.normalize)?i.normalize=r.normalize:r.normalize?s(e,r):i.normalize=function(t,e){e.normalize(t)});!function(t){return"[object String]"===vh(t)}(r)?s(e,r):n.push(e)})),n.forEach((function(e){t.__compiled__[t.__schemas__[e]]&&(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:function(t,e){e.normalize(t)}};const o=Object.keys(t.__compiled__).filter((function(e){return e.length>0&&t.__compiled__[e]})).map(Dh).join("|");t.re.schema_test=RegExp("(^|(?!_)(?:[><|]|"+e.src_ZPCc+"))("+o+")","i"),t.re.schema_search=RegExp("(^|(?!_)(?:[><|]|"+e.src_ZPCc+"))("+o+")","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"),function(t){t.__index__=-1,t.__text_cache__=""}(t)}function Mh(t,e){const r=t.__index__,i=t.__last_index__,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 Ah(t,e){const r=new Mh(t,e);return t.__compiled__[r.schema].normalize(r,t),r}function Ch(t,e){if(!(this instanceof Ch))return new Ch(t,e);e||Object.keys(t||{}).reduce((function(t,e){return t||yh.hasOwnProperty(e)}),!1)&&(e=t,t={}),this.__opts__=wh({},yh,e),this.__index__=-1,this.__last_index__=-1,this.__schema__="",this.__text_cache__="",this.__schemas__=wh({},Eh,t),this.__compiled__={},this.__tlds__=xh,this.__tlds_replaced__=!1,this.re={},Fh(this)}Ch.prototype.add=function(t,e){return this.__schemas__[t]=e,Fh(this),this},Ch.prototype.set=function(t){return this.__opts__=wh(this.__opts__,t),this},Ch.prototype.test=function(t){if(this.__text_cache__=t,this.__index__=-1,!t.length)return!1;let e,r,i,n,s,o,l,u,h;if(this.re.schema_test.test(t))for(l=this.re.schema_search,l.lastIndex=0;null!==(e=l.exec(t));)if(n=this.testSchemaAt(t,e[2],l.lastIndex),n){this.__schema__=e[2],this.__index__=e.index+e[1].length,this.__last_index__=e.index+e[0].length+n;break}return this.__opts__.fuzzyLink&&this.__compiled__["http:"]&&(u=t.search(this.re.host_fuzzy_test),u>=0&&(this.__index__<0||u<this.__index__)&&null!==(r=t.match(this.__opts__.fuzzyIP?this.re.link_fuzzy:this.re.link_no_ip_fuzzy))&&(s=r.index+r[1].length,(this.__index__<0||s<this.__index__)&&(this.__schema__="",this.__index__=s,this.__last_index__=r.index+r[0].length))),this.__opts__.fuzzyEmail&&this.__compiled__["mailto:"]&&(h=t.indexOf("@"),h>=0&&null!==(i=t.match(this.re.email_fuzzy))&&(s=i.index+i[1].length,o=i.index+i[0].length,(this.__index__<0||s<this.__index__||s===this.__index__&&o>this.__last_index__)&&(this.__schema__="mailto:",this.__index__=s,this.__last_index__=o))),this.__index__>=0},Ch.prototype.pretest=function(t){return this.re.pretest.test(t)},Ch.prototype.testSchemaAt=function(t,e,r){return this.__compiled__[e.toLowerCase()]?this.__compiled__[e.toLowerCase()].validate(t,r,this):0},Ch.prototype.match=function(t){const e=[];let r=0;this.__index__>=0&&this.__text_cache__===t&&(e.push(Ah(this,r)),r=this.__last_index__);let i=r?t.slice(r):t;for(;this.test(i);)e.push(Ah(this,r)),i=i.slice(this.__last_index__),r+=this.__last_index__;return e.length?e:null},Ch.prototype.matchAtStart=function(t){if(this.__text_cache__=t,this.__index__=-1,!t.length)return null;const e=this.re.schema_at_start.exec(t);if(!e)return null;const r=this.testSchemaAt(t,e[2],e[0].length);return r?(this.__schema__=e[2],this.__index__=e.index+e[1].length,this.__last_index__=e.index+e[0].length+r,Ah(this,0)):null},Ch.prototype.tlds=function(t,e){return t=Array.isArray(t)?t:[t],e?(this.__tlds__=this.__tlds__.concat(t).sort().filter((function(t,e,r){return t!==r[e-1]})).reverse(),Fh(this),this):(this.__tlds__=t.slice(),this.__tlds_replaced__=!0,Fh(this),this)},Ch.prototype.normalize=function(t){t.schema||(t.url="http://"+t.url),"mailto:"!==t.schema||/^mailto:/i.test(t.url)||(t.url="mailto:"+t.url)},Ch.prototype.onCompile=function(){};const Sh=2147483647,Oh=36,$h=/^xn--/,Bh=/[^\0-\x7F]/,Rh=/[\x2E\u3002\uFF0E\uFF61]/g,Nh={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},_h=Math.floor,Th=String.fromCharCode;function zh(t){throw new RangeError(Nh[t])}function jh(t,e){const r=t.split("@");let i="";r.length>1&&(i=r[0]+"@",t=r[1]);const n=function(t,e){const r=[];let i=t.length;for(;i--;)r[i]=e(t[i]);return r}((t=t.replace(Rh,".")).split("."),e).join(".");return i+n}const qh=function(t,e){return t+22+75*(t<26)-((0!=e)<<5)},Ih=function(t,e,r){let i=0;for(t=r?_h(t/700):t>>1,t+=_h(t/e);t>455;i+=Oh)t=_h(t/35);return _h(i+36*t/(t+38))},Ph=function(t){return jh(t,(function(t){return Bh.test(t)?"xn--"+function(t){const e=[],r=(t=function(t){const e=[];let r=0;const i=t.length;for(;r<i;){const n=t.charCodeAt(r++);if(n>=55296&&n<=56319&&r<i){const i=t.charCodeAt(r++);56320==(64512&i)?e.push(((1023&n)<<10)+(1023&i)+65536):(e.push(n),r--)}else e.push(n)}return e}(t)).length;let i=128,n=0,s=72;for(const r of t)r<128&&e.push(Th(r));const o=e.length;let l=o;for(o&&e.push("-");l<r;){let r=Sh;for(const e of t)e>=i&&e<r&&(r=e);const u=l+1;r-i>_h((Sh-n)/u)&&zh("overflow"),n+=(r-i)*u,i=r;for(const r of t)if(r<i&&++n>Sh&&zh("overflow"),r===i){let t=n;for(let r=Oh;;r+=Oh){const i=r<=s?1:r>=s+26?26:r-s;if(t<i)break;const n=t-i,o=Oh-i;e.push(Th(qh(i+n%o,0))),t=_h(n/o)}e.push(Th(qh(t,0))),s=Ih(n,u,l===o),n=0,++l}++n,++i}return e.join("")}(t):t}))},Lh=function(t){return jh(t,(function(t){return $h.test(t)?function(t){const e=[],r=t.length;let i=0,n=128,s=72,o=t.lastIndexOf("-");o<0&&(o=0);for(let r=0;r<o;++r)t.charCodeAt(r)>=128&&zh("not-basic"),e.push(t.charCodeAt(r));for(let u=o>0?o+1:0;u<r;){const o=i;for(let e=1,n=Oh;;n+=Oh){u>=r&&zh("invalid-input");const o=(l=t.charCodeAt(u++))>=48&&l<58?l-48+26:l>=65&&l<91?l-65:l>=97&&l<123?l-97:Oh;o>=Oh&&zh("invalid-input"),o>_h((Sh-i)/e)&&zh("overflow"),i+=o*e;const h=n<=s?1:n>=s+26?26:n-s;if(o<h)break;const a=Oh-h;e>_h(Sh/a)&&zh("overflow"),e*=a}const h=e.length+1;s=Ih(i-o,h,0==o),_h(i/h)>Sh-n&&zh("overflow"),n+=_h(i/h),i%=h,e.splice(i++,0,n)}var l;return String.fromCodePoint(...e)}(t.slice(4).toLowerCase()):t}))},Jh={default:{options:{html:!1,xhtmlOut:!1,breaks:!1,langPrefix:"language-",linkify:!1,typographer:!1,quotes:"“”‘’",highlight:null,maxNesting:100},components:{core:{},block:{},inline:{}}},zero:{options:{html:!1,xhtmlOut:!1,breaks:!1,langPrefix:"language-",linkify:!1,typographer:!1,quotes:"“”‘’",highlight:null,maxNesting:20},components:{core:{rules:["normalize","block","inline","text_join"]},block:{rules:["paragraph"]},inline:{rules:["text"],rules2:["balance_pairs","fragments_join"]}}},commonmark:{options:{html:!0,xhtmlOut:!0,breaks:!1,langPrefix:"language-",linkify:!1,typographer:!1,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"]}}}},Uh=/^(vbscript|javascript|file|data):/,Vh=/^data:image\/(gif|png|jpeg|webp);/;function Hh(t){const e=t.trim().toLowerCase();return!Uh.test(e)||Vh.test(e)}const Wh=["http:","https:","mailto:"];function Gh(t){const e=Ul(t,!0);if(e.hostname&&(!e.protocol||Wh.indexOf(e.protocol)>=0))try{e.hostname=Ph(e.hostname)}catch(t){}return Ol($l(e))}function Zh(t){const e=Ul(t,!0);if(e.hostname&&(!e.protocol||Wh.indexOf(e.protocol)>=0))try{e.hostname=Lh(e.hostname)}catch(t){}return Cl($l(e),Cl.defaultChars+"%")}function Kh(t,e){if(!(this instanceof Kh))return new Kh(t,e);e||eu(t)||(e=t||{},t="default"),this.inline=new bh,this.block=new eh,this.core=new Ju,this.renderer=new Fu,this.linkify=new Ch,this.validateLink=Hh,this.normalizeLink=Gh,this.normalizeLinkText=Zh,this.utils=yu,this.helpers=iu({},Eu),this.options={},this.configure(t),e&&this.set(e)}Kh.prototype.set=function(t){return iu(this.options,t),this},Kh.prototype.configure=function(t){const e=this;if(eu(t)){const e=t;if(!(t=Jh[e]))throw new Error('Wrong `markdown-it` preset "'+e+'", check name')}if(!t)throw new Error("Wrong `markdown-it` preset, can't be empty");return t.options&&e.set(t.options),t.components&&Object.keys(t.components).forEach((function(r){t.components[r].rules&&e[r].ruler.enableOnly(t.components[r].rules),t.components[r].rules2&&e[r].ruler2.enableOnly(t.components[r].rules2)})),this},Kh.prototype.enable=function(t,e){let r=[];Array.isArray(t)||(t=[t]),["core","block","inline"].forEach((function(e){r=r.concat(this[e].ruler.enable(t,!0))}),this),r=r.concat(this.inline.ruler2.enable(t,!0));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},Kh.prototype.disable=function(t,e){let r=[];Array.isArray(t)||(t=[t]),["core","block","inline"].forEach((function(e){r=r.concat(this[e].ruler.disable(t,!0))}),this),r=r.concat(this.inline.ruler2.disable(t,!0));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},Kh.prototype.use=function(t){const e=[this].concat(Array.prototype.slice.call(arguments,1));return t.apply(t,e),this},Kh.prototype.parse=function(t,e){if("string"!=typeof t)throw new Error("Input data should be a String");const r=new this.core.State(t,this,e);return this.core.process(r),r.tokens},Kh.prototype.render=function(t,e){return this.renderer.render(this.parse(t,e=e||{}),this.options,e)},Kh.prototype.parseInline=function(t,e){const r=new this.core.State(t,this,e);return r.inlineMode=!0,this.core.process(r),r.tokens},Kh.prototype.renderInline=function(t,e){return this.renderer.render(this.parseInline(t,e=e||{}),this.options,e)};const Yh=new Lt({nodes:{doc:{content:"block+"},paragraph:{content:"inline*",group:"block",parseDOM:[{tag:"p"}],toDOM:()=>["p",0]},blockquote:{content:"block+",group:"block",parseDOM:[{tag:"blockquote"}],toDOM:()=>["blockquote",0]},horizontal_rule:{group:"block",parseDOM:[{tag:"hr"}],toDOM:()=>["div",["hr"]]},heading:{attrs:{level:{default:1}},content:"(text | image)*",group:"block",defining:!0,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=>["h"+t.attrs.level,0]},code_block:{content:"text*",group:"block",code:!0,defining:!0,marks:"",attrs:{params:{default:""}},parseDOM:[{tag:"pre",preserveWhitespace:"full",getAttrs:t=>({params:t.getAttribute("data-params")||""})}],toDOM:t=>["pre",t.attrs.params?{"data-params":t.attrs.params}:{},["code",0]]},ordered_list:{content:"list_item+",group:"block",attrs:{order:{default:1},tight:{default:!1}},parseDOM:[{tag:"ol",getAttrs:t=>({order:t.hasAttribute("start")?+t.getAttribute("start"):1,tight:t.hasAttribute("data-tight")})}],toDOM:t=>["ol",{start:1==t.attrs.order?null:t.attrs.order,"data-tight":t.attrs.tight?"true":null},0]},bullet_list:{content:"list_item+",group:"block",attrs:{tight:{default:!1}},parseDOM:[{tag:"ul",getAttrs:t=>({tight:t.hasAttribute("data-tight")})}],toDOM:t=>["ul",{"data-tight":t.attrs.tight?"true":null},0]},list_item:{content:"block+",defining:!0,parseDOM:[{tag:"li"}],toDOM:()=>["li",0]},text:{group:"inline"},image:{inline:!0,attrs:{src:{},alt:{default:null},title:{default:null}},group:"inline",draggable:!0,parseDOM:[{tag:"img[src]",getAttrs:t=>({src:t.getAttribute("src"),title:t.getAttribute("title"),alt:t.getAttribute("alt")})}],toDOM:t=>["img",t.attrs]},hard_break:{inline:!0,group:"inline",selectable:!1,parseDOM:[{tag:"br"}],toDOM:()=>["br"]}},marks:{em:{parseDOM:[{tag:"i"},{tag:"em"},{style:"font-style=italic"},{style:"font-style=normal",clearMark:t=>"em"==t.type.name}],toDOM:()=>["em"]},strong:{parseDOM:[{tag:"strong"},{tag:"b",getAttrs:t=>"normal"!=t.style.fontWeight&&null},{style:"font-weight=400",clearMark:t=>"strong"==t.type.name},{style:"font-weight",getAttrs:t=>/^(bold(er)?|[5-9]\d{2,})$/.test(t)&&null}],toDOM:()=>["strong"]},link:{attrs:{href:{},title:{default:null}},inclusive:!1,parseDOM:[{tag:"a[href]",getAttrs:t=>({href:t.getAttribute("href"),title:t.getAttribute("title")})}],toDOM:t=>["a",t.attrs]},code:{code:!0,parseDOM:[{tag:"code"}],toDOM:()=>["code"]}}});class Xh{constructor(t,e){this.schema=t,this.tokenHandlers=e,this.stack=[{type:t.topNodeType,attrs:null,content:[],marks:it.none}]}top(){return this.stack[this.stack.length-1]}push(t){this.stack.length&&this.top().content.push(t)}addText(t){if(!t)return;let e,r=this.top(),i=r.content,n=i[i.length-1],s=this.schema.text(t,r.marks);n&&(e=function(t,e){if(t.isText&&e.isText&&it.sameSet(t.marks,e.marks))return t.withText(t.text+e.text)}(n,s))?i[i.length-1]=e:i.push(s)}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],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(),n=t.createAndFill(e,r,i?i.marks:[]);return n?(this.push(n),n):null}openNode(t,e){this.stack.push({type:t,attrs:e,content:[],marks:it.none})}closeNode(){let t=this.stack.pop();return this.addNode(t.type,t.attrs,t.content)}}function Qh(t,e,r,i){return t.getAttrs?t.getAttrs(e,r,i):t.attrs instanceof Function?t.attrs(e):t.attrs}function ta(t,e){return t.noCloseToken||"code_inline"==e||"code_block"==e||"fence"==e}function ea(t){return"\n"==t[t.length-1]?t.slice(0,t.length-1):t}function ra(){}function ia(t,e){for(;++e<t.length;)if("list_item_open"!=t[e].type)return t[e].hidden;return!1}new class{constructor(t,e,r){this.schema=t,this.tokenizer=e,this.tokens=r,this.tokenHandlers=function(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);ta(n,i)?r[i]=(t,r,i,s)=>{t.openNode(e,Qh(n,r,i,s)),t.addText(ea(r.content)),t.closeNode()}:(r[i+"_open"]=(t,r,i,s)=>t.openNode(e,Qh(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,Qh(n,r,i,s))}else if(n.mark){let e=t.marks[n.mark];ta(n,i)?r[i]=(t,r,i,s)=>{t.openMark(e.create(Qh(n,r,i,s))),t.addText(ea(r.content)),t.closeMark(e)}:(r[i+"_open"]=(t,r,i,s)=>t.openMark(e.create(Qh(n,r,i,s))),r[i+"_close"]=t=>t.closeMark(e))}else{if(!n.ignore)throw new RangeError("Unrecognized parsing spec "+JSON.stringify(n));ta(n,i)?r[i]=ra:(r[i+"_open"]=ra,r[i+"_close"]=ra)}}return r.text=(t,e)=>t.addText(e.content),r.inline=(t,e)=>t.parseTokens(e.children),r.softbreak=r.softbreak||(t=>t.addText(" ")),r}(t,r)}parse(t,e={}){let r,i=new Xh(this.schema,this.tokenHandlers);i.parseTokens(this.tokenizer.parse(t,e));do{r=i.closeNode()}while(i.stack.length);return r||this.schema.topNodeType.createAndFill()}}(Yh,Kh("commonmark",{html:!1}),{blockquote:{block:"blockquote"},paragraph:{block:"paragraph"},list_item:{block:"list_item"},bullet_list:{block:"bullet_list",getAttrs:(t,e,r)=>({tight:ia(e,r)})},ordered_list:{block:"ordered_list",getAttrs:(t,e,r)=>({order:+t.attrGet("start")||1,tight:ia(e,r)})},heading:{block:"heading",getAttrs:t=>({level:+t.tag.slice(1)})},code_block:{block:"code_block",noCloseToken:!0},fence:{block:"code_block",getAttrs:t=>({params:t.info||""}),noCloseToken:!0},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:!0}});const na={open:"",close:"",mixable:!0};class sa{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 ua(this.nodes,this.marks,e);return r.renderContent(t),r.out}}const oa=new sa({blockquote(t,e){t.wrapBlock("> ",null,e,(()=>t.renderContent(e)))},code_block(t,e){const r=e.textContent.match(/`{3,}/gm),i=r?r.sort().slice(-1)[0]+"`":"```";t.write(i+(e.attrs.params||"")+"\n"),t.text(e.textContent,!1),t.write("\n"),t.write(i),t.closeBlock(e)},heading(t,e){t.write(t.repeat("#",e.attrs.level)+" "),t.renderInline(e,!1),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,i=String(r+e.childCount-1).length,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("!["+t.esc(e.attrs.alt||"")+"]("+e.attrs.src.replace(/[\(\)]/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)return void t.write("\\\n")},text(t,e){t.text(e.text,!t.inAutolink)}},{em:{open:"*",close:"*",mixable:!0,expelEnclosingWhitespace:!0},strong:{open:"**",close:"**",mixable:!0,expelEnclosingWhitespace:!0},link:{open:(t,e,r,i)=>(t.inAutolink=function(t,e,r){if(t.attrs.title||!/^\w+:/.test(t.attrs.href))return!1;let i=e.child(r);return!(!i.isText||i.text!=t.attrs.href||i.marks[i.marks.length-1]!=t||r!=e.childCount-1&&t.isInSet(e.child(r+1).marks))}(e,r,i),t.inAutolink?"<":"["),close(t,e,r,i){let{inAutolink:n}=t;return t.inAutolink=void 0,n?">":"]("+e.attrs.href.replace(/[\(\)"]/g,"\\$&")+(e.attrs.title?` "${e.attrs.title.replace(/"/g,'\\"')}"`:"")+")"},mixable:!0},code:{open:(t,e,r,i)=>la(r.child(i),-1),close:(t,e,r,i)=>la(r.child(i-1),1),escape:!1}});function la(t,e){let r,i=/`+/g,n=0;if(t.isText)for(;r=i.exec(t.text);)n=Math.max(n,r[0].length);let s=n>0&&e>0?" `":"`";for(let t=0;t<n;t++)s+="`";return n>0&&e<0&&(s+=" "),s}class ua{constructor(t,e,r){this.nodes=t,this.marks=e,this.options=r,this.delim="",this.out="",this.closed=null,this.inAutolink=void 0,this.atBlockStart=!1,this.inTightList=!1,void 0===this.options.tightLists&&(this.options.tightLists=!1),void 0===this.options.hardBreakNodeName&&(this.options.hardBreakNodeName="hard_break")}flushClose(t=2){if(this.closed){if(this.atBlank()||(this.out+="\n"),t>1){let e=this.delim,r=/\s+$/.exec(e);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(!1!==this.options.strict)throw new Error(`Mark type \`${t}\` not supported by Markdown renderer`);e=na}return e}wrapBlock(t,e,r,i){let n=this.delim;this.write(null!=e?e:t),this.delim+=t,i(),this.delim=n,this.closeBlock(r)}atBlank(){return/(^|\n)$/.test(this.out)}ensureNewLine(){this.atBlank()||(this.out+="\n")}write(t){this.flushClose(),this.delim&&this.atBlank()&&(this.out+=this.delim),t&&(this.out+=t)}closeBlock(t){this.closed=t}text(t,e=!0){let r=t.split("\n");for(let t=0;t<r.length;t++)this.write(),!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],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(!1!==this.options.strict)throw new Error("Token type `"+t.type.name+"` not supported by Markdown renderer");t.type.isLeaf||(t.type.inlineContent?this.renderInline(t):this.renderContent(t),t.isBlock&&this.closeBlock(t))}}renderContent(t){t.forEach(((e,r,i)=>this.render(e,t,i)))}renderInline(t,e=!0){this.atBlockStart=e;let r=[],i="",n=(e,n,s)=>{let o=e?e.marks:[];e&&e.type.name===this.options.hardBreakNodeName&&(o=o.filter((e=>{if(s+1==t.childCount)return!1;let r=t.child(s+1);return e.isInSet(r.marks)&&(!r.isText||/\S/.test(r.text))})));let l=i;if(i="",e&&e.isText&&o.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);i&&(l+=i,(e=n?e.withText(n):null)||(o=r))}if(e&&e.isText&&o.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);s&&(i=s,(e=n?e.withText(n):null)||(o=r))}let u=o.length?o[o.length-1]:null,h=u&&!1===this.getMark(u.type.name).escape,a=o.length-(h?1:0);t:for(let t=0;t<a;t++){let e=o[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)){t>i?o=o.slice(0,i).concat(e).concat(o.slice(i,t)).concat(o.slice(t+1,a)):i>t&&(o=o.slice(0,t).concat(o.slice(t+1,i)).concat(e).concat(o.slice(i,a)));continue t}}}let f=0;for(;f<Math.min(r.length,a)&&o[f].eq(r[f]);)++f;for(;f<r.length;)this.text(this.markString(r.pop(),!1,t,s),!1);if(l&&this.text(l),e){for(;r.length<a;){let e=o[r.length];r.push(e),this.text(this.markString(e,!0,t,s),!1),this.atBlockStart=!1}h&&e.isText?this.text(this.markString(u,!0,t,s)+e.text+this.markString(u,!1,t,s+1),!1):this.render(e,t,s),this.atBlockStart=!1}(null==e?void 0:e.isText)&&e.nodeSize>0&&(this.atBlockStart=!1)};t.forEach(n),n(null,0,t.childCount),this.atBlockStart=!1}renderList(t,e,r){this.closed&&this.closed.type==t.type?this.flushClose(3):this.inTightList&&this.flushClose(1);let i=void 0!==t.attrs.tight?t.attrs.tight:this.options.tightLists,n=this.inTightList;this.inTightList=i,t.forEach(((n,s,o)=>{o&&i&&this.flushClose(1),this.wrapBlock(e,r(o),t,(()=>this.render(n,t,o)))})),this.inTightList=n}esc(t,e=!1){return 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)),e&&(t=t.replace(/^(\+[ ]|[\-*>])/,"\\$&").replace(/^(\s*)(#{1,6})(\s|$)/,"$1\\$2$3").replace(/^(\s*\d+)\.\s/,"$1\\. ")),this.options.escapeExtraCharacters&&(t=t.replace(this.options.escapeExtraCharacters,"\\$&")),t}quote(t){let e=-1==t.indexOf('"')?'""':-1==t.indexOf("'")?"''":"()";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),s=e?n.open:n.close;return"string"==typeof s?s:s(this,t,r,i)}getEnclosingWhitespace(t){return{leading:(t.match(/^(\s+)/)||[void 0])[0],trailing:(t.match(/(\s+)$/)||[void 0])[0]}}}const ha=new Map;function aa(t,e){t.style.height=e.attrs.height,t.style.width=e.attrs.width,t.style.minHeight=e.attrs.minHeight,t.style.minWidth=e.attrs.minWidth,t.style.maxWidth=e.attrs.maxWidth}function fa(t){if("image"===t.type.name)return!0;for(let e=0;e<t.childCount;e++)if(fa(t.child(e)))return!0;return!1}function ca(t){return(e,r)=>{const i=r.attrs.state;if(!da(i))return;if("success"===i){const t=function(t){const e=[];t.height&&e.push(`height: ${t.height};`),t.width&&e.push(`width: ${t.width};`),t.minHeight&&e.push(`min-height: ${t.minHeight};`),t.minWidth&&e.push(`min-width: ${t.minWidth};`),t.maxWidth&&e.push(`max-width: ${t.maxWidth};`);const r=e.length>0?` style="${e.join("")}"`:"";return`<img src="${t.src}" alt="${t.alt}"${r} />`}(r.attrs);return void e.write(t)}const n=function(t,e,r){return`<span>${A.get(`editor-image-view.${"failed"===t?"failed":"loading"}`,r,{filename:e||"file"})}</span>`}(i,r.attrs.alt,t);e.write(n)}}function da(t){return"loading"===t||"failed"===t||"success"===t}const pa=t=>(e,r)=>{const i=`<${t.tagName}`+t.attributes.map((t=>` ${t}="${r.attrs[t]}"`)).join("")+">",n=`</${t.tagName}>`;e.write(i),e.renderContent(r),e.write(n)};class ma{constructor(t,e){this.parseAsHTML=t=>a(t,{whitelist:this.customNodes}),this.serialize=t=>""!==t.dom.textContent.trim()||fa(t.state.doc)?this.markdownSerializer.serialize(t.state.doc):"",this.markdownSerializer=((t,e)=>{const r={};for(const e of t)r[e.tagName]=pa(e);const i=Object.assign(Object.assign(Object.assign({},oa.nodes),function(t){return{image:ca(t)}}(e)),r),n=Object.assign(Object.assign({},oa.marks),{strikethrough:{open:"~~",close:"~~",mixable:!0,expelEnclosingWhitespace:!0}});return new sa(i,n)})(t,e),this.customNodes=t}}class ga{constructor(t){this.parseAsHTML=t=>f(t,this.customNodes),this.serialize=t=>{if(""===t.dom.textContent.trim()&&!fa(t.state.doc))return"";const e=document.createElement("div");return e.append(te.fromSchema(t.state.schema).serializeFragment(t.state.doc.content)),e.innerHTML},this.customNodes=t}}const ba={parseDOM:[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration=line-through"}],toDOM:()=>["s",0]},wa=new gr("linkPlugin"),va=(t,e)=>{const r=t.posAtCoords({left:e.clientX,top:e.clientY}),i=t.state.doc.nodeAt(null==r?void 0:r.pos);if(!i)return null;const n=i.marks.find((t=>t.type.name===s.Link));if(!n)return null;const o=n.attrs.href,l=((t,e,r)=>{for(;e>0;){const i=t.nodeAt(e-1);if(!(null==i?void 0:i.isText)||!i.marks.some((t=>t.type.name===s.Link&&t.attrs.href===r)))break;e--}return e})(t.state.doc,r.pos,o),u=((t,e,r)=>{for(;e<t.content.size;){const i=t.nodeAt(e);if(!(null==i?void 0:i.isText)||!i.marks.some((t=>t.type.name===s.Link&&t.attrs.href===r)))break;e++}return e})(t.state.doc,r.pos,o);return{href:o,text:t.state.doc.textBetween(l,u," "),from:l,to:u}},ka=/(https?:\/\/[^\s<>"']+|mailto:[^\s<>"']+|tel:[^\s<>"']+|www\.[^\s<>"']+)/g,Da=(t,e)=>t.text(e),ya=(t,e)=>{const r=(t=>{let e=t.trim();for(;e.endsWith("\\");)e=e.slice(0,-1);return e.toLowerCase().startsWith("www.")&&(e=`https://${e}`),e})(e),i=t.marks.link.create(h(r,r));return t.text(r,[i])},Ea=(t,e)=>{const r=[],i=(t=>{const e=[];let r;for(ka.lastIndex=0;null!==(r=ka.exec(t));)e.push({url:r[0],start:r.index,end:r.index+r[0].length});return e})(t);if(0===i.length)return[Da(e,t)];let n=0;for(const s of i)s.start>n&&r.push(Da(e,t.slice(n,s.start))),r.push(ya(e,s.url)),n=s.end;return n<t.length&&r.push(Da(e,t.slice(n))),r},xa=(t,e)=>{var r;const i=null===(r=e.clipboardData)||void 0===r?void 0:r.getData("text/plain");if(!i||!(t=>(ka.lastIndex=0,ka.test(t)))(i))return!1;const n=((t,e)=>{const r=t.split(/\r\n|\r|\n/),i=[];for(const[t,n]of r.entries())if(n.length>0&&i.push(...Ea(n,e)),t<r.length-1){const t=e.nodes.hard_break;t?i.push(t.create()):console.warn("hard_break node not found in schema")}return i})(i,t.state.schema);return e.preventDefault(),((t,e)=>{0!==e.length&&((t=>{if(1!==t.length)return!1;const e=t[0];return!(!e.isText||!e.text||""===e.text.trim())&&e.marks.some((t=>"link"===t.type.name))})(e)?((t,e)=>{const{state:r,dispatch:i}=t,{from:n,to:s}=r.selection,o=e.marks.find((t=>"link"===t.type.name)),l=r.doc.textBetween(n,s," ")||o.attrs.href;i(r.tr.insertText(l,n,s).addMark(n,n+l.length,o))})(t,e[0]):((t,e)=>{const{state:r,dispatch:i}=t,{from:n,to:s}=r.selection,o=Q.fromArray(e);i(r.tr.replaceWith(n,s,o))})(t,e))})(t,n),!0},Fa=t=>new dr({key:wa,props:{handlePaste:(t,e)=>xa(t,e),handleDOMEvents:{mousedown:(t,e)=>{if((e.metaKey||e.ctrlKey)&&0===e.button)return((t,e)=>{const r=va(t,e);if(!r.href)return!1;e.preventDefault();const{href:i}=r;return!!i&&(window.open(i,"_blank","noopener,noreferrer"),!0)})(t,e)},dblclick:(t,e)=>{if(e.button!==l.Right)return((t,e)=>{const r=va(t,e);if(!r)return!1;const{href:i,text:n,from:s,to:o}=r,l=t.state.tr.setSelection(Xe.create(t.state.doc,s,o));return t.dispatch(l),((t,e,r)=>{const i=new CustomEvent("open-editor-link-menu",{detail:{href:e,text:r},bubbles:!0,composed:!0});t.dom.dispatchEvent(i)})(t,i,n),!0})(t,e)},click:(t,e)=>{e.target instanceof HTMLElement&&e.target.closest("a")&&(e.preventDefault(),e.stopPropagation())}}},view:()=>({update:e=>{((t,e)=>{const{from:r,to:i}=t.state.selection;let n="",s="";t.state.doc.nodesBetween(r,i,((t,e)=>{if("text"!==t.type.name)return;const o=Math.max(0,r-e),l=Math.min(t.text.length,i-e);n+=t.text.slice(o,l),t.marks.forEach((t=>{"link"===t.type.name&&(s=t.attrs.href)}))})),e&&e(n,s)})(e,t)}})}),Ma={attrs:{href:{default:""},title:{default:null},target:{default:null},rel:{default:null},referrerpolicy:{default:null}},inclusive:!1,parseDOM:[{tag:"a[href]",getAttrs:t=>({href:t.getAttribute("href")||"",title:t.getAttribute("title"),target:t.getAttribute("target"),rel:t.getAttribute("rel"),referrerpolicy:t.getAttribute("referrerpolicy")})}],toDOM:t=>{const e=t.attrs.target||null,r={rel:"_blank"===e?"noopener noreferrer":null,referrerpolicy:"_blank"===e?"noreferrer":null};return["a",Object.assign(Object.assign({},t.attrs),r),0]}},Aa=new gr("imageInserterPlugin"),Ca=(t,e,r)=>({fileInfo:r,insertThumbnail:Sa(t,e,r),insertImage:Oa(t,r),insertFailedThumbnail:$a(t,r)}),Sa=(t,e,r)=>()=>{const{state:i,dispatch:n}=t,{schema:s}=i,o=Ba(e,r,"loading"),l=s.nodes.image.create(o);n(i.tr.replaceSelectionWith(l))},Oa=(t,e)=>r=>{const{state:i,dispatch:n}=t,{schema:s}=i,o=i.tr;i.doc.descendants(((t,i)=>{if(t.attrs.fileInfoId===e.id){const n=Ba(null!=r?r:t.attrs.src,e,"success"),l=s.nodes.image.create(n);return o.replaceWith(i,i+t.nodeSize,l),!1}})),n(o)},$a=(t,e)=>()=>{const{state:r,dispatch:i}=t,{schema:n}=r,s=r.tr;r.doc.descendants(((t,r)=>{if(t.attrs.fileInfoId===e.id){const i=Ba(t.attrs.src,e,"failed"),o=n.nodes.image.create(i);return s.replaceWith(r,r+t.nodeSize,o),!1}})),i(s)};function Ba(t,e,r){return{src:t,alt:e.filename,fileInfoId:e.id,state:r}}const Ra=t=>{if(t instanceof Et){if("image"===t.type.name)return!0;let e=!1;return t.content.forEach((t=>{Ra(t)&&(e=!0)})),e}if(t instanceof Q){let e=!1;return t.forEach((t=>{Ra(t)&&(e=!0)})),e}return!1},Na=t=>{const e=[];return t.forEach((t=>{if(!Ra(t))if(t.content.size>0){const r=Na(t.content),i=t.copy(r);e.push(i)}else e.push(t)})),Q.fromArray(e)};function _a(t,e){var r,i;if(!function(t){return!!(null==t?void 0:t.type)&&t.type.startsWith("image/")}(t))return!1;const n=null!==(i=null===(r=null==e?void 0:e.getData("text/html"))||void 0===r?void 0:r.toLowerCase())&&void 0!==i?i:"";return!function(t){return!!t&&(t.includes('name=generator content="microsoft excel"')||t.includes('xmlns:x="urn:schemas-microsoft-com:office:excel"'))}(n)&&!function(t){return!!t&&t.includes("<table")}(n)}class Ta{constructor(t,e,r,i){this.createResizeHandle=t=>{const e=document.createElement("div");return e.className=`resize-handle ${t}`,e.setAttribute("role","slider"),e.setAttribute("aria-label",A.get("editor-image-view.resize-handle",this.language)),e.setAttribute("tabindex","0"),e.setAttribute("aria-valuemin",10..toString()),e.setAttribute("aria-valuenow",this.img.offsetWidth.toString()),e.setAttribute("aria-valuetext",`${this.img.offsetWidth} pixels`),e.setAttribute("aria-grabbed","false"),e.addEventListener("pointerdown",(r=>{e.setAttribute("aria-grabbed","true"),this.onResizeStart(r,t)})),e},this.onResizeStart=(t,e)=>{t.preventDefault();const r=t.target,i=t.clientX,n=this.img.offsetWidth,s=t=>{const r=t.clientX-i,s=Math.max(10,n+("top-left"===e?-r:r));this.img.style.width=`${s}px`;const o=this.dom.querySelectorAll(".resize-handle");for(const t of o)t.setAttribute("aria-valuenow",s.toString()),t.setAttribute("aria-valuetext",`${s} pixels`)},o=()=>{window.removeEventListener("pointermove",s),window.removeEventListener("pointerup",o),r.setAttribute("aria-grabbed","false"),this.persistDimensions()};window.addEventListener("pointermove",s),window.addEventListener("pointerup",o)},this.createLoadingState=()=>{this.dom.setAttribute("aria-live","polite"),this.dom.setAttribute("aria-busy","true"),this.dom.setAttribute("aria-label",A.get("editor-image-view.loading",this.language,{filename:this.node.attrs.alt||"file"}));const t=document.createElement("limel-linear-progress");t.setAttribute("indeterminate","true"),this.dom.append(t)},this.createSuccessState=()=>{this.dom.setAttribute("aria-live","polite"),this.dom.setAttribute("aria-busy","false"),this.dom.setAttribute("aria-label",A.get("editor-image-view.success",this.language,{filename:this.node.attrs.alt||"file"}));const t=this.createResizeHandle("bottom-right"),e=this.createResizeHandle("top-left");this.dom.append(t),this.dom.append(e)},this.createFailedState=()=>{this.dom.setAttribute("aria-live","assertive"),this.dom.setAttribute("aria-busy","false"),this.dom.setAttribute("aria-label",A.get("editor-image-view.failed",this.language,{filename:this.node.attrs.alt||"file"}))},this.cleanUpPreviousState=()=>{for(const t of this.dom.childNodes)t instanceof HTMLImageElement||t.remove()},this.transitionBetweenStates=()=>{var t;this.cleanUpPreviousState(),this.dom.className=`image-wrapper state-${this.node.attrs.state}`;const e={loading:this.createLoadingState,success:this.createSuccessState,failed:this.createFailedState};null===(t=e[this.node.attrs.state])||void 0===t||t.call(e)},this.transitioningBetweenSuccessStates=t=>"success"===this.node.attrs.state&&"success"===t.attrs.state,this.node=t,this.view=e,this.getPos=r,this.language=i,this.dom=document.createElement("div"),this.dom.className=`image-wrapper state-${t.attrs.state}`,this.img=document.createElement("img"),this.img.src=t.attrs.src,this.img.alt=t.attrs.alt,aa(this.img,t),this.img.addEventListener("load",(()=>{this.persistDimensions()})),this.dom.append(this.img),this.transitionBetweenStates()}persistDimensions(){this.view.dispatch(this.view.state.tr.setNodeMarkup(this.getPos(),void 0,Object.assign(Object.assign({},this.node.attrs),{height:`${this.img.offsetHeight}px`,width:`${this.img.offsetWidth}px`,minHeight:`${this.img.offsetHeight}px`,minWidth:`${this.img.offsetWidth}px`})))}update(t){return this.transitioningBetweenSuccessStates(t)||(this.img.src=t.attrs.src,this.img.alt=t.attrs.alt,aa(this.img,t)),this.node=t,this.transitionBetweenStates(),!0}}const za=new gr("actionBarPlugin"),ja=new gr("actionBarInteractionPlugin"),qa=(t,e)=>{const{state:r}=e,i=r.selection;let n=r.tr;i.empty||n.setSelection(i),t(r,(t=>{n=t})),e.dispatch(n),e.focus()},Ia=t=>new dr({key:ja,props:{handleDOMEvents:{actionBarItemClick:(e,r)=>{r.preventDefault(),r.stopPropagation();const{value:i}=r.detail;try{const r=t.getCommand(i);qa(r,e)}catch(t){console.error(`Error executing command: ${t}`)}return!0},saveLinkMenu:(e,r)=>{r.preventDefault(),r.stopPropagation();const{type:i,link:n}=r.detail;if(i===s.Link)try{const r=t.getCommand(i,n);qa(r,e)}catch(t){console.error(`Error executing command: ${t}`)}return!0}}}}),Pa=t=>{const e={};for(const r of t.attributes)e[r]={};return{group:"inline",content:"(text* | inline*)",inline:!0,atom:!0,selectable:!0,attrs:e,toDOM:e=>[t.tagName,e.attrs],parseDOM:[{tag:`${t.tagName}[${t.attributes.map((t=>t)).join("][")}]`,getAttrs:e=>{const r={};return t.attributes.forEach((t=>r[t]=e.getAttribute(t))),r}}]}},La=(t,e,r,i)=>{const n=t.state.schema;return async s=>{const o=document.createElement("span");o.innerHTML=await e.parseAsHTML(s,n);const l=Ut.fromSchema(n).parse(o).content;i(t,r,l)}},Ja=(t,e,r)=>({insert:Ua(t,r),insertHtml:La(t,e,r.position,Ha),stopTrigger:()=>Va(t)}),Ua=(t,e)=>r=>{const i=t.state.schema;let n;try{n=Wa(r,i)}catch(t){return void console.error(t.message)}const s=i.text(" "),o=i.nodes.doc.create(null,[n,s]);Ha(t,e.position,o)},Va=t=>{const{state:e,dispatch:r}=t,i=e.tr;i.setMeta("stopTrigger",!0),r(i)},Ha=(t,e,r)=>{const i=t.state,n=t.dispatch,s=i.tr.replaceWith(e,i.selection.$from.pos,r);s.setMeta("stopTrigger",!0),n(s)},Wa=(t,e)=>{var r;if("string"==typeof t)return e.text(t);const i=t.node;if("string"==typeof i)return e.text(i);const n=Ga(i.tagName,e),s=(null!==(r=t.children)&&void 0!==r?r:[]).map((t=>Wa(t,e))).filter(Boolean);return n.create(i.attributes,s)},Ga=(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},Za=(t,e,r,i)=>({trigger:r.character,textEditor:Ja(t,e,r),value:i}),Ka=(t,e,r,i,n)=>{const s=new CustomEvent(t,{detail:Za(e,r,i,n),bubbles:!0,composed:!0});e.dom.dispatchEvent(s)},Ya=(t,e)=>{let r=null,i=null;const n=()=>{i=null},s=((t,e)=>(r,n,s,o)=>{if(!e.includes(o))return!1;const l=r.state.doc.textBetween(n-1,n,"");if(/\s/.test(l)||""===l){const e={character:o,position:n};(t=>{i=t})(e),Ka("triggerStart",r,t,e,o)}return!1})(e,t),o=((t,e,r,i)=>(n,s,o)=>{const l=e();if(!l)return;const u=((t,e,r,i,n)=>{if(!e||e.position<1)return!1;for(const s of t.steps)if(s instanceof we){const{from:t,to:o,slice:l}=s;if(t<=e.position&&o>=e.position&&!l.content.textBetween(0,l.content.size,"").includes(e.character))return r(),Ka("triggerStop",n,i,e,""),!0}return!1})(n[0],l,r,i,t());u?r():((t,e,r,i,n)=>{let s="";r>e.position&&(s=t.textBetween(e.position+1,r,"")),Ka("triggerChange",n,i,e,s)})(o.doc,l,o.selection.from,i,t())})((()=>r),(()=>i),n,e);return new dr({key:new gr("triggerPlugin"),view:t=>(r=t,{}),state:{init:()=>({}),apply:t=>(t.getMeta("stopTrigger")&&(Ka("triggerStop",r,e,i,""),n()),{})},props:{handleTextInput:s},appendTransaction:o})};var Xa,Qa;if("undefined"!=typeof WeakMap){let t=new WeakMap;Xa=e=>t.get(e),Qa=(e,r)=>(t.set(e,r),r)}else{const t=[],e=10;let r=0;Xa=e=>{for(let r=0;r<t.length;r+=2)if(t[r]==e)return t[r+1]},Qa=(i,n)=>(r==e&&(r=0),t[r++]=i,t[r++]=n)}var tf=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,n=e/this.width|0;let s=i+1,o=n+1;for(let t=1;s<this.width&&this.map[e+t]==r;t++)s++;for(let t=1;o<this.height&&this.map[e+this.width*t]==r;t++)o++;return{left:i,top:n,right:s,bottom:o}}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:o}=this.findCell(t);return"horiz"==e?(r<0?0==i:n==this.width)?null:this.map[s*this.width+(r<0?i-1:n)]:(r<0?0==s:o==this.height)?null:this.map[i+this.width*(r<0?s-1:o)]}rectBetween(t,e){const{left:r,right:i,top:n,bottom:s}=this.findCell(t),{left:o,right:l,top:u,bottom:h}=this.findCell(e);return{left:Math.min(r,o),top:Math.min(n,u),right:Math.max(i,l),bottom:Math.max(s,h)}}cellsInRect(t){const e=[],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,o=this.map[s];r[o]||(r[o]=!0,n==t.left&&n&&this.map[s-1]==o||i==t.top&&i&&this.map[s-this.width]==o||e.push(o))}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;for(;r<i&&this.map[r]<n;)r++;return r==i?s-1:this.map[r]}n=s}}static get(t){return Xa(t)||Qa(t,function(t){if("table"!=t.type.spec.tableRole)throw new RangeError("Not a table node: "+t.type.name);const e=function(t){let e=-1,r=!1;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);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,e.attrs.rowspan>1&&(r=!0)}-1==e?e=s:e!=s&&(e=Math.max(e,s))}return e}(t),r=t.childCount,i=[];let n=0,s=null;const o=[];for(let t=0,n=e*r;t<n;t++)i[t]=0;for(let l=0,u=0;l<r;l++){const h=t.child(l);u++;for(let t=0;;t++){for(;n<i.length&&0!=i[n];)n++;if(t==h.childCount)break;const a=h.child(t),{colspan:f,rowspan:c,colwidth:d}=a.attrs;for(let t=0;t<c;t++){if(t+l>=r){(s||(s=[])).push({type:"overlong_rowspan",pos:u,n:c-t});break}const h=n+t*e;for(let t=0;t<f;t++){0==i[h+t]?i[h+t]=u:(s||(s=[])).push({type:"collision",row:l,pos:u,n:f-t});const r=d&&d[t];if(r){const i=(h+t)%e*2,n=o[i];null==n||n!=r&&1==o[i+1]?(o[i]=r,o[i+1]=1):n==r&&o[i+1]++}}}n+=f,u+=a.nodeSize}const a=(l+1)*e;let f=0;for(;n<a;)0==i[n++]&&f++;f&&(s||(s=[])).push({type:"missing",row:l,n:f}),u++}0!==e&&0!==r||(s||(s=[])).push({type:"zero_sized"});const l=new tf(e,r,i,s);let u=!1;for(let t=0;!u&&t<o.length;t+=2)null!=o[t]&&o[t+1]<r&&(u=!0);return u&&function(t,e,r){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]=!0;const o=r.nodeAt(s);if(!o)throw new RangeError(`No cell with offset ${s} found`);let l=null;const u=o.attrs;for(let r=0;r<u.colspan;r++){const i=e[(n+r)%t.width*2];null==i||u.colwidth&&u.colwidth[r]==i||((l||(l=ef(u)))[r]=i)}l&&t.problems.unshift({type:"colwidth mismatch",pos:s,colwidth:l})}}(l,o,t),l}(t))}};function ef(t){if(t.colwidth)return t.colwidth.slice();const e=[];for(let r=0;r<t.colspan;r++)e.push(0);return e}function rf(t,e){if("string"==typeof t)return{};const r=t.getAttribute("data-colwidth"),i=r&&/^\d+(,\d+)*$/.test(r)?r.split(",").map((t=>Number(t))):null,n=Number(t.getAttribute("colspan")||1),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,n=i&&i(t);null!=n&&(s[r]=n)}return s}function nf(t,e){const r={};1!=t.attrs.colspan&&(r.colspan=t.attrs.colspan),1!=t.attrs.rowspan&&(r.rowspan=t.attrs.rowspan),t.attrs.colwidth&&(r["data-colwidth"]=t.attrs.colwidth.join(","));for(const i in e){const n=e[i].setDOMAttr;n&&n(t.attrs[i],r)}return r}function sf(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;n&&(e[n]=i)}}return e}var of=new gr("selectingCells");function lf(t){for(let e=t.depth-1;e>0;e--)if("row"==t.node(e).type.spec.tableRole)return t.node(0).resolve(t.before(e+1));return null}function uf(t){return"row"==t.parent.type.spec.tableRole&&!!t.nodeAfter}function hf(t,e){return t.depth==e.depth&&t.pos>=e.start(-1)&&t.pos<=e.end(-1)}function af(t,e,r){const i=t.node(-1),n=tf.get(i),s=t.start(-1),o=n.nextCell(t.pos-s,e,r);return null==o?null:t.node(0).resolve(s+o)}function ff(t,e,r=1){const i={...t,colspan:t.colspan-r};return i.colwidth&&(i.colwidth=i.colwidth.slice(),i.colwidth.splice(e,r),i.colwidth.some((t=>t>0))||(i.colwidth=null)),i}var cf=class t extends Ge{constructor(t,e=t){const r=t.node(-1),i=tf.get(r),n=t.start(-1),s=i.rectBetween(t.pos-n,e.pos-n),o=t.node(0),l=i.cellsInRect(s).filter((t=>t!=e.pos-n));l.unshift(e.pos-n);const u=l.map((t=>{const e=r.nodeAt(t);if(!e)throw RangeError(`No cell with offset ${t} found`);const i=n+t+1;return new Ze(o.resolve(i),o.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)),n=e.resolve(r.map(this.$headCell.pos));if(uf(i)&&uf(n)&&hf(i,n)){const e=this.$anchorCell.node(-1)!=i.node(-1);return e&&this.isRowSelection()?t.rowSelection(i,n):e&&this.isColSelection()?t.colSelection(i,n):new t(i,n)}return Xe.between(i,n)}content(){const t=this.$anchorCell.node(-1),e=tf.get(t),r=this.$anchorCell.start(-1),i=e.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),n={},s=[];for(let r=i.top;r<i.bottom;r++){const o=[];for(let s=r*e.width+i.left,l=i.left;l<i.right;l++,s++){const r=e.map[s];if(n[r])continue;n[r]=!0;const l=e.findCell(r);let u=t.nodeAt(r);if(!u)throw RangeError(`No cell with offset ${r} found`);const h=i.left-l.left,a=l.right-i.right;if(h>0||a>0){let t=u.attrs;if(h>0&&(t=ff(t,0,h)),a>0&&(t=ff(t,t.colspan-a,a)),l.left<i.left){if(u=u.type.createAndFill(t),!u)throw RangeError(`Could not create cell with attrs ${JSON.stringify(t)}`)}else u=u.type.create(t,u.content)}if(l.top<i.top||l.bottom>i.bottom){const t={...u.attrs,rowspan:Math.min(l.bottom,i.bottom)-Math.max(l.top,i.top)};u=l.top<i.top?u.type.createAndFill(t):u.type.create(t,u.content)}o.push(u)}s.push(t.child(r).copy(Q.from(o)))}const o=this.isColSelection()&&this.isRowSelection()?t:s;return new st(Q.from(o),1,1)}replace(t,e=st.empty){const r=t.steps.length,i=this.ranges;for(let n=0;n<i.length;n++){const{$from:s,$to:o}=i[n],l=t.mapping.slice(r);t.replace(l.map(s.pos),l.map(o.pos),n?st.empty:e)}const n=Ge.findFrom(t.doc.resolve(t.mapping.slice(r).map(this.to)),-1);n&&t.setSelection(n)}replaceWith(t,e){this.replace(t,new st(Q.from(e),0,0))}forEachCell(t){const e=this.$anchorCell.node(-1),r=tf.get(e),i=this.$anchorCell.start(-1),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),e=this.$headCell.index(-1);return!(Math.min(t,e)>0)&&Math.max(t+this.$anchorCell.nodeAfter.attrs.rowspan,e+this.$headCell.nodeAfter.attrs.rowspan)==this.$headCell.node(-1).childCount}static colSelection(e,r=e){const i=e.node(-1),n=tf.get(i),s=e.start(-1),o=n.findCell(e.pos-s),l=n.findCell(r.pos-s),u=e.node(0);return o.top<=l.top?(o.top>0&&(e=u.resolve(s+n.map[o.left])),l.bottom<n.height&&(r=u.resolve(s+n.map[n.width*(n.height-1)+l.right-1]))):(l.top>0&&(r=u.resolve(s+n.map[l.left])),o.bottom<n.height&&(e=u.resolve(s+n.map[n.width*(n.height-1)+o.right-1]))),new t(e,r)}isRowSelection(){const t=this.$anchorCell.node(-1),e=tf.get(t),r=this.$anchorCell.start(-1),i=e.colCount(this.$anchorCell.pos-r),n=e.colCount(this.$headCell.pos-r);return!(Math.min(i,n)>0)&&Math.max(i+this.$anchorCell.nodeAfter.attrs.colspan,n+this.$headCell.nodeAfter.attrs.colspan)==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),n=tf.get(i),s=e.start(-1),o=n.findCell(e.pos-s),l=n.findCell(r.pos-s),u=e.node(0);return o.left<=l.left?(o.left>0&&(e=u.resolve(s+n.map[o.top*n.width])),l.right<n.width&&(r=u.resolve(s+n.map[n.width*(l.top+1)-1]))):(l.left>0&&(r=u.resolve(s+n.map[l.top*n.width])),o.right<n.width&&(e=u.resolve(s+n.map[n.width*(o.top+1)-1]))),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 df(this.$anchorCell.pos,this.$headCell.pos)}};cf.prototype.visible=!1,Ge.jsonID("cell",cf);var df=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);return"row"==e.parent.type.spec.tableRole&&"row"==r.parent.type.spec.tableRole&&e.index()<e.parent.childCount&&r.index()<r.parent.childCount&&hf(e,r)?new cf(e,r):Ge.near(r,1)}};function pf(t){if(!(t.selection instanceof cf))return null;const e=[];return t.selection.forEachCell(((t,r)=>{e.push(Zn.node(r,r+t.nodeSize,{class:"selectedCell"}))})),Xn.create(t.doc,e)}var mf=new gr("fix-tables");function gf(t,e,r,i){const n=t.childCount,s=e.childCount;t:for(let o=0,l=0;o<s;o++){const s=e.child(o);for(let e=l,i=Math.min(n,o+3);e<i;e++)if(t.child(e)==s){l=e+1,r+=s.nodeSize;continue t}i(s,r),l<n&&t.child(l).sameMarkup(s)?gf(t.child(l),s,r+1,i):s.nodesBetween(0,s.content.size,i,r+1),r+=s.nodeSize}}function bf(t,e){let r;const i=(e,i)=>{"table"==e.type.spec.tableRole&&(r=function(t,e,r,i){const n=tf.get(e);if(!n.problems)return i;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 o=n.problems[t];if("collision"==o.type){const t=e.nodeAt(o.pos);if(!t)continue;const n=t.attrs;for(let t=0;t<n.rowspan;t++)s[o.row+t]+=o.n;i.setNodeMarkup(i.mapping.map(r+1+o.pos),null,ff(n,n.colspan-o.n,o.n))}else if("missing"==o.type)s[o.row]+=o.n;else if("overlong_rowspan"==o.type){const t=e.nodeAt(o.pos);if(!t)continue;i.setNodeMarkup(i.mapping.map(r+1+o.pos),null,{...t.attrs,rowspan:t.attrs.rowspan-o.n})}else if("colwidth mismatch"==o.type){const t=e.nodeAt(o.pos);if(!t)continue;i.setNodeMarkup(i.mapping.map(r+1+o.pos),null,{...t.attrs,colwidth:o.colwidth})}else if("zero_sized"==o.type){const t=i.mapping.map(r);i.delete(t,t+e.nodeSize)}}let o,l;for(let t=0;t<s.length;t++)s[t]&&(null==o&&(o=t),l=t);for(let u=0,h=r+1;u<n.height;u++){const r=e.child(u),n=h+r.nodeSize,a=s[u];if(a>0){let e="cell";r.firstChild&&(e=r.firstChild.type.spec.tableRole);const s=[];for(let r=0;r<a;r++){const r=sf(t.schema)[e].createAndFill();r&&s.push(r)}i.insert(i.mapping.map(0!=u&&o!=u-1||l!=u?n-1:h+1),s)}h=n}return i.setMeta(mf,{fixTables:!0})}(t,e,i,r))};return e?e.doc!=t.doc&&gf(e.doc,t.doc,0,i):t.doc.descendants(i),r}function wf(t,e){const r=t.selection;if(!(r instanceof cf))return!1;if(e){const i=t.tr,n=sf(t.schema).cell.createAndFill().content;r.forEachCell(((t,e)=>{t.content.eq(n)||i.replace(i.mapping.map(e+1),i.mapping.map(e+t.nodeSize-1),new st(n,0,0))})),i.docChanged&&e(i)}return!0}function vf(t,e){const r=t.createAndFill();return new He(r).replace(0,r.content.size,e).doc}function kf(t,e,r,i,n,s,o,l){if(0==o||o==e.height)return!1;let u=!1;for(let h=n;h<s;h++){const n=o*e.width+h,s=e.map[n];if(e.map[n-e.width]==s){u=!0;const n=r.nodeAt(s),{top:a,left:f}=e.findCell(s);t.setNodeMarkup(t.mapping.slice(l).map(s+i),null,{...n.attrs,rowspan:o-a}),t.insert(t.mapping.slice(l).map(e.positionAt(o,f,r)),n.type.createAndFill({...n.attrs,rowspan:a+n.attrs.rowspan-o})),h+=n.attrs.colspan-1}}return u}function Df(t,e,r,i,n,s,o,l){if(0==o||o==e.width)return!1;let u=!1;for(let h=n;h<s;h++){const n=h*e.width+o,s=e.map[n];if(e.map[n-1]==s){u=!0;const n=r.nodeAt(s),a=e.colCount(s),f=t.mapping.slice(l).map(s+i);t.setNodeMarkup(f,null,ff(n.attrs,o-a,n.attrs.colspan-(o-a))),t.insert(f+n.nodeSize,n.type.createAndFill(ff(n.attrs,0,o-a))),h+=n.attrs.rowspan-1}}return u}function yf(t,e,r,i,n){let s=r?t.doc.nodeAt(r-1):t.doc;if(!s)throw new Error("No table found");let o=tf.get(s);const{top:l,left:u}=i,h=u+n.width,a=l+n.height,f=t.tr;let c=0;function d(){if(s=r?f.doc.nodeAt(r-1):f.doc,!s)throw new Error("No table found");o=tf.get(s),c=f.mapping.maps.length}(function(t,e,r,i,n,s,o){const l=sf(t.doc.type.schema);let u,h;if(n>e.width)for(let s=0,a=0;s<e.height;s++){const f=r.child(s);a+=f.nodeSize;const c=[];let d;d=null==f.lastChild||f.lastChild.type==l.cell?u||(u=l.cell.createAndFill()):h||(h=l.header_cell.createAndFill());for(let t=e.width;t<n;t++)c.push(d);t.insert(t.mapping.slice(o).map(a-1+i),c)}if(s>e.height){const a=[];for(let t=0,i=(e.height-1)*e.width;t<Math.max(e.width,n);t++){const n=!(t>=e.width)&&r.nodeAt(e.map[i+t]).type==l.header_cell;a.push(n?h||(h=l.header_cell.createAndFill()):u||(u=l.cell.createAndFill()))}const f=l.row.create(null,Q.from(a)),c=[];for(let t=e.height;t<s;t++)c.push(f);t.insert(t.mapping.slice(o).map(i+r.nodeSize-2),c)}return!(!u&&!h)})(f,o,s,r,h,a,c)&&d(),kf(f,o,s,r,u,h,l,c)&&d(),kf(f,o,s,r,u,h,a,c)&&d(),Df(f,o,s,r,l,a,u,c)&&d(),Df(f,o,s,r,l,a,h,c)&&d();for(let t=l;t<a;t++){const e=o.positionAt(t,u,s),i=o.positionAt(t,h,s);f.replace(f.mapping.slice(c).map(e+r),f.mapping.slice(c).map(i+r),new st(n.rows[t-l],0,0))}d(),f.setSelection(new cf(f.doc.resolve(r+o.positionAt(l,u,s)),f.doc.resolve(r+o.positionAt(a-1,h-1,s)))),e(f)}var Ef=ro({ArrowLeft:Ff("horiz",-1),ArrowRight:Ff("horiz",1),ArrowUp:Ff("vert",-1),ArrowDown:Ff("vert",1),"Shift-ArrowLeft":Mf("horiz",-1),"Shift-ArrowRight":Mf("horiz",1),"Shift-ArrowUp":Mf("vert",-1),"Shift-ArrowDown":Mf("vert",1),Backspace:wf,"Mod-Backspace":wf,Delete:wf,"Mod-Delete":wf});function xf(t,e,r){return!r.eq(t.selection)&&(e&&e(t.tr.setSelection(r).scrollIntoView()),!0)}function Ff(t,e){return(r,i,n)=>{if(!n)return!1;const s=r.selection;if(s instanceof cf)return xf(r,i,Ge.near(s.$headCell,e));if("horiz"!=t&&!s.empty)return!1;const o=Of(n,t,e);if(null==o)return!1;if("horiz"==t)return xf(r,i,Ge.near(r.doc.resolve(s.head+e),e));{const n=r.doc.resolve(o),s=af(n,t,e);let l;return l=s?Ge.near(s,1):e<0?Ge.near(r.doc.resolve(n.before(-1)),-1):Ge.near(r.doc.resolve(n.after(-1)),1),xf(r,i,l)}}}function Mf(t,e){return(r,i,n)=>{if(!n)return!1;const s=r.selection;let o;if(s instanceof cf)o=s;else{const i=Of(n,t,e);if(null==i)return!1;o=new cf(r.doc.resolve(i))}const l=af(o.$headCell,t,e);return!!l&&xf(r,i,new cf(o.$anchorCell,l))}}function Af(t,e){const r=lf(t.state.doc.resolve(e));return!!r&&(t.dispatch(t.state.tr.setSelection(new cf(r))),!0)}function Cf(t,e,r){if(!function(t){const e=t.selection.$head;for(let t=e.depth;t>0;t--)if("row"==e.node(t).type.spec.tableRole)return!0;return!1}(t.state))return!1;let i=function(t){if(!t.size)return null;let{content:e,openStart:r,openEnd:i}=t;for(;1==e.childCount&&(r>0&&i>0||"table"==e.child(0).type.spec.tableRole);)r--,i--,e=e.child(0).content;const n=e.child(0),s=n.type.spec.tableRole,o=n.type.schema,l=[];if("row"==s)for(let t=0;t<e.childCount;t++){let n=e.child(t).content;const s=t?0:Math.max(0,r-1),u=t<e.childCount-1?0:Math.max(0,i-1);(s||u)&&(n=vf(sf(o).row,new st(n,s,u)).content),l.push(n)}else{if("cell"!=s&&"header_cell"!=s)return null;l.push(r||i?vf(sf(o).row,new st(e,r,i)).content:e)}return function(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(Q.empty),r[n]<i){const s=sf(t).cell.createAndFill(),o=[];for(let t=r[n];t<i;t++)o.push(s);e[n]=e[n].append(Q.from(o))}return{height:e.length,width:i,rows:e}}(o,l)}(r);const n=t.state.selection;if(n instanceof cf){i||(i={width:1,height:1,rows:[Q.from(vf(sf(t.state.schema).cell,r))]});const e=n.$anchorCell.node(-1),s=n.$anchorCell.start(-1),o=tf.get(e).rectBetween(n.$anchorCell.pos-s,n.$headCell.pos-s);return i=function({width:t,height:e,rows:r},i,n){if(t!=i){const e=[],n=[];for(let t=0;t<r.length;t++){const s=r[t],o=[];for(let r=e[t]||0,n=0;r<i;n++){let l=s.child(n%s.childCount);r+l.attrs.colspan>i&&(l=l.type.createChecked(ff(l.attrs,l.attrs.colspan,r+l.attrs.colspan-i),l.content)),o.push(l),r+=l.attrs.colspan;for(let r=1;r<l.attrs.rowspan;r++)e[t+r]=(e[t+r]||0)+l.attrs.colspan}n.push(Q.from(o))}r=n,t=i}if(e!=n){const t=[];for(let i=0,s=0;i<n;i++,s++){const o=[],l=r[s%e];for(let t=0;t<l.childCount;t++){let e=l.child(t);i+e.attrs.rowspan>n&&(e=e.type.create({...e.attrs,rowspan:Math.max(1,n-e.attrs.rowspan)},e.content)),o.push(e)}t.push(Q.from(o))}r=t,e=n}return{width:t,height:e,rows:r}}(i,o.right-o.left,o.bottom-o.top),yf(t.state,t.dispatch,s,o,i),!0}if(i){const e=function(t){const e=t.selection;if("$anchorCell"in e&&e.$anchorCell)return e.$anchorCell.pos>e.$headCell.pos?e.$anchorCell:e.$headCell;if("node"in e&&e.node&&"cell"==e.node.type.spec.tableRole)return e.$anchor;const r=lf(e.$head)||function(t){for(let e=t.nodeAfter,r=t.pos;e;e=e.firstChild,r++){const i=e.type.spec.tableRole;if("cell"==i||"header_cell"==i)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("cell"==i||"header_cell"==i)return t.doc.resolve(r-e.nodeSize)}}(e.$head);if(r)return r;throw new RangeError(`No cell found around position ${e.head}`)}(t.state),r=e.start(-1);return yf(t.state,t.dispatch,r,tf.get(e.node(-1)).findCell(e.pos-r),i),!0}return!1}function Sf(t,e){var r;if(e.ctrlKey||e.metaKey)return;const i=$f(t,e.target);let n;if(e.shiftKey&&t.state.selection instanceof cf)s(t.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&i&&null!=(n=lf(t.state.selection.$anchor))&&(null==(r=Bf(t,e))?void 0:r.pos)!=n.pos)s(n,e),e.preventDefault();else if(!i)return;function s(e,r){let i=Bf(t,r);const n=null==of.getState(t.state);if(!i||!hf(e,i)){if(!n)return;i=e}const s=new cf(e,i);if(n||!t.state.selection.eq(s)){const r=t.state.tr.setSelection(s);n&&r.setMeta(of,e.pos),t.dispatch(r)}}function o(){t.root.removeEventListener("mouseup",o),t.root.removeEventListener("dragstart",o),t.root.removeEventListener("mousemove",l),null!=of.getState(t.state)&&t.dispatch(t.state.tr.setMeta(of,-1))}function l(r){const n=r,l=of.getState(t.state);let u;if(null!=l)u=t.state.doc.resolve(l);else if($f(t,n.target)!=i&&(u=Bf(t,e),!u))return o();u&&s(u,n)}t.root.addEventListener("mouseup",o),t.root.addEventListener("dragstart",o),t.root.addEventListener("mousemove",l)}function Of(t,e,r){if(!(t.state.selection instanceof Xe))return null;const{$head:i}=t.state.selection;for(let n=i.depth-1;n>=0;n--){const s=i.node(n);if((r<0?i.index(n):i.indexAfter(n))!=(r<0?0:s.childCount))return null;if("cell"==s.type.spec.tableRole||"header_cell"==s.type.spec.tableRole){const s=i.before(n);return t.endOfTextblock("vert"==e?r>0?"down":"up":r>0?"right":"left")?s:null}}return null}function $f(t,e){for(;e&&e!=t.dom;e=e.parentNode)if("TD"==e.nodeName||"TH"==e.nodeName)return e;return null}function Bf(t,e){const r=t.posAtCoords({left:e.clientX,top:e.clientY});return r&&r?lf(t.state.doc.resolve(r.pos)):null}function Rf({allowTableNodeSelection:t=!1}={}){return new dr({key:of,state:{init:()=>null,apply(t,e){const r=t.getMeta(of);if(null!=r)return-1==r?null:r;if(null==e||!t.docChanged)return e;const{deleted:i,pos:n}=t.mapping.mapResult(e);return i?null:n}},props:{decorations:pf,handleDOMEvents:{mousedown:Sf},createSelectionBetween:t=>null!=of.getState(t.state)?t.state.selection:null,handleTripleClick:Af,handleKeyDown:Ef,handlePaste:Cf},appendTransaction:(e,r,i)=>function(t,e,r){const i=(e||t).selection,n=(e||t).doc;let s,o;if(i instanceof tr&&(o=i.node.type.spec.tableRole)){if("cell"==o||"header_cell"==o)s=cf.create(n,i.from);else if("row"==o){const t=n.resolve(i.from+1);s=cf.rowSelection(t,t)}else if(!r){const t=tf.get(i.node),e=i.from+1;s=cf.create(n,e+1,e+t.map[t.width*t.height-1])}}else i instanceof Xe&&function({$from:t,$to:e}){if(t.pos==e.pos||t.pos<e.pos-6)return!1;let r=t.pos,i=e.pos,n=t.depth;for(;n>=0&&!(t.after(n+1)<t.end(n));n--,r++);for(let t=e.depth;t>=0&&!(e.before(t+1)>e.start(t));t--,i--);return r==i&&/row|table/.test(t.node(n).type.spec.tableRole)}(i)?s=Xe.create(n,i.from):i instanceof Xe&&function({$from:t,$to:e}){let r,i;for(let e=t.depth;e>0;e--){const i=t.node(e);if("cell"===i.type.spec.tableRole||"header_cell"===i.type.spec.tableRole){r=i;break}}for(let t=e.depth;t>0;t--){const r=e.node(t);if("cell"===r.type.spec.tableRole||"header_cell"===r.type.spec.tableRole){i=r;break}}return r!==i&&0===e.parentOffset}(i)&&(s=Xe.create(n,i.$from.start(),i.$from.end()));return s&&(e||(e=t.tr)).setSelection(s),e}(i,bf(i,r),t)})}new gr("tableColumnResizing");const Nf=t=>({default:null,getFromDOM:e=>e.style[t]||null,setDOMAttr:(e,r)=>{e&&(r.style=(r.style||"")+`${t}: ${e};`)}});function _f(t){const e={images:[],links:[]};return t.descendants((t=>{if(function(t){return"image"===t.type.name&&!!t.attrs}(t))e.images.push(function(t){return{src:t.attrs.src,state:t.attrs.state,fileInfoId:t.attrs.fileInfoId}}(t));else if(function(t){var e;return t.isText&&(null===(e=t.marks)||void 0===e?void 0:e.length)>0}(t))for(const r of function(t){return t.marks.filter((t=>"link"===t.type.name&&t.attrs)).map((e=>({href:e.attrs.href,text:t.text})))}(t))e.links.push(r);return!0})),e}function Tf(t){const e=new Map;for(const r of t){const t=`${r.fileInfoId}|${r.state}|${r.src}`;e.set(t,(e.get(t)||0)+1)}return e}function zf(t){const e=new Map;for(const r of t){const t=`${r.href}|${r.text}`;e.set(t,(e.get(t)||0)+1)}return e}function jf(t,e){if(t.size!==e.size)return!1;for(const[r,i]of t.entries())if(e.get(r)!==i)return!1;return!0}const qf=class{constructor(r){t(this,r),this.change=e(this,"change"),this.imagePasted=e(this,"imagePasted"),this.imageRemoved=e(this,"imageRemoved"),this.metadataChange=e(this,"metadataChange"),this.contentType="markdown",this.disabled=!1,this.customElements=[],this.triggerCharacters=[],this.ui="standard",this.actionBarItems=[],this.link={href:"https://"},this.isLinkMenuOpen=!1,this.changeWaiting=!1,this.transactionFired=!1,this.lastClickedPos=null,this.metadata={images:[],links:[]},this.suppressChangeEvent=!1,this.getActionBarItems=()=>{this.actionBarItems=Fl().map(this.getTranslatedItem)},this.getTranslatedItem=t=>{const e=Z(t);if(S(t)){const r=Ml[t.value];r&&(e.text=A.get(r,this.language))}return e},this.updateActiveActionBarItems=(t,e)=>{const r=Fl().map((r=>S(r)?Object.assign(Object.assign({},r),{selected:t[r.value],allowed:e[r.value]}):r));this.actionBarItems=r.filter((t=>!S(t)||t.allowed))},this.handleTransaction=t=>{this.transactionFired=!0;const e=this.view.state.apply(t);if(this.view.updateState(e),this.suppressChangeEvent||t.getMeta("pointer"))return;const r=this.contentConverter.serialize(this.view,this.schema);if(r===this.lastEmittedValue)return;const i=_f(e.doc);this.metadataEmitter(i),this.lastEmittedValue=r,this.changeWaiting=!0,this.changeEmitter(r)},this.handleActionBarItem=t=>{t.preventDefault(),t.stopImmediatePropagation();const{value:e}=t.detail;if(e===s.Link)return void(this.isLinkMenuOpen=!0);const r=new CustomEvent("actionBarItemClick",{detail:t.detail});this.view.dom.dispatchEvent(r)},this.handleCancelLinkMenu=t=>{t.preventDefault(),t.stopPropagation(),this.isLinkMenuOpen=!1,this.link={text:"",href:"https://"}},this.handleSaveLinkMenu=()=>{this.isLinkMenuOpen=!1;const t=new CustomEvent("saveLinkMenu",{detail:{type:s.Link,link:this.link}});this.view.dom.dispatchEvent(t),this.link={href:"https://"}},this.handleLinkChange=t=>{this.link=t.detail},this.handleFocus=()=>{var t;this.disabled||(null===(t=this.view)||void 0===t||t.focus(),this.transactionFired=!1,setTimeout((()=>{if(!this.transactionFired&&this.lastClickedPos){const{doc:t,tr:e}=this.view.state,r=t.resolve(this.lastClickedPos),i=Ge.near(r);e.setMeta("pointer",!0),this.view.dispatch(e.setSelection(i))}}),0))},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=!0},this.handleMouseDown=t=>{var e;const r=this.view.posAtCoords({left:t.clientX,top:t.clientY});this.lastClickedPos=null!==(e=null==r?void 0:r.pos)&&void 0!==e?e:null},this.changeEmitter=B((t=>{this.change.emit(t),this.changeWaiting=!1}),300),this.handleBlur=()=>{this.changeEmitter.flush()},this.portalId=C()}watchValue(t){this.view&&(this.changeWaiting||t!==this.contentConverter.serialize(this.view,this.schema)&&this.updateView(t))}componentWillLoad(){this.getActionBarItems(),this.setupContentConverter()}componentDidLoad(){setTimeout((()=>{this.initializeTextEditor()}),0)}connectedCallback(){this.view&&this.initializeTextEditor(),this.host.addEventListener("open-editor-link-menu",this.handleOpenLinkMenu)}disconnectedCallback(){var t,e,r,i,n;ha.clear(),this.host.removeEventListener("open-editor-link-menu",this.handleOpenLinkMenu),null===(e=null===(t=this.view)||void 0===t?void 0:t.dom)||void 0===e||e.removeEventListener("blur",this.handleBlur),null===(i=null===(r=this.view)||void 0===r?void 0:r.dom)||void 0===i||i.removeEventListener("mousedown",this.handleMouseDown),null===(n=this.view)||void 0===n||n.destroy()}render(){return r(i,{key:"1d27dcbd164b5ad8bfb0f84a515b0898b82f8065",onFocus:this.handleFocus},r("div",{key:"622f4a64560e1bb1f6f7b99aaf8473b7234ea026",id:"editor"}),this.renderToolbar(),this.renderLinkMenu())}renderToolbar(){if(0!==this.actionBarItems.length&&"no-toolbar"!==this.ui)return r("div",{class:"toolbar"},r("limel-action-bar",{ref:t=>this.actionBarElement=t,accessibleLabel:"Toolbar",actions:this.actionBarItems,onItemSelected:this.handleActionBarItem}))}renderLinkMenu(){if(this.isLinkMenuOpen)return r("limel-portal",{containerId:this.portalId,visible:this.isLinkMenuOpen,openDirection:"top",inheritParentWidth:!0,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("markdown"===this.contentType)this.contentConverter=new ma(this.customElements,this.language);else{if("html"!==this.contentType)throw new Error(`Unsupported content type: ${this.contentType}. Only 'markdown' and 'html' are supported.`);this.contentConverter=new ga(this.customElements)}}async initializeTextEditor(){this.schema=this.initializeSchema();const t=await this.parseInitialContent();this.menuCommandFactory=new Dl(this.schema),this.view=new Es(this.host.shadowRoot.querySelector("#editor"),{state:this.createEditorState(t),dispatchTransaction:this.handleTransaction}),this.view.dom.addEventListener("blur",this.handleBlur),this.view.dom.addEventListener("mousedown",this.handleMouseDown),this.value&&this.updateView(this.value),this.lastEmittedValue=this.contentConverter.serialize(this.view,this.schema)}initializeSchema(){let t=zs.spec.nodes;for(const e of this.customElements){const r=Pa(e),i=e.tagName;t=t.append({[i]:r})}return t=function(t,e,r){return t.append({ordered_list:Us(Ps,{content:"list_item+",group:r}),bullet_list:Us(Ls,{content:"list_item+",group:r}),list_item:Us(Js,{content:"paragraph block*"})})}(t,0,"block"),"html"===this.contentType&&(t=t.append(function(t){const e=t.cellAttributes||{},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:!0,group:t.tableGroup,parseDOM:[{tag:"table"}],toDOM:()=>["table",["tbody",0]]},table_row:{content:"(table_cell | table_header)*",tableRole:"row",parseDOM:[{tag:"tr"}],toDOM:()=>["tr",0]},table_cell:{content:t.cellContent,attrs:r,tableRole:"cell",isolating:!0,parseDOM:[{tag:"td",getAttrs:t=>rf(t,e)}],toDOM:t=>["td",nf(t,e),0]},table_header:{content:t.cellContent,attrs:r,tableRole:"header_cell",isolating:!0,parseDOM:[{tag:"th",getAttrs:t=>rf(t,e)}],toDOM:t=>["th",nf(t,e),0]}}}({tableGroup:"block",cellContent:"block+",cellAttributes:{background:Nf("background-color"),color:Nf("color")}}))),t=t.append({image:(e=this.language,{group:"inline",inline:!0,attrs:{src:{default:""},alt:{default:""},fileInfoId:{default:""},height:{default:""},width:{default:""},minHeight:{default:""},minWidth:{default:""},maxWidth:{default:"100%"},state:{default:"success"}},toDOM:t=>{if(da(t.attrs.state))return"success"===t.attrs.state?function(t,e){let r=ha.get(t);return r?function(t,e){t.alt=e.attrs.alt,aa(t,e)}(r,e):(r=function(t){const e=document.createElement("img");return e.src=t.attrs.src,e.alt=t.attrs.alt,aa(e,t),e}(e),ha.set(t,r)),r}(t.attrs.fileInfoId,t):function(t,e,r){return function(t,e,r){const i=A.get(`editor-image-view.${t}`,r,{filename:e.attrs.alt||"file"}),n=document.createElement("span");return n.textContent=i,n}("failed"===t?"failed":"loading",e,r)}(t.attrs.state,t,e)},parseDOM:[{tag:"img",getAttrs:t=>({src:t.getAttribute("src")||"",alt:t.getAttribute("alt")||"file",width:t.style.width||"",maxWidth:"100%",state:"success",fileInfoId:crypto.randomUUID()})}]})}),new Lt({nodes:t,marks:zs.spec.marks.append({strikethrough:ba,link:Ma})});var e}async parseInitialContent(){const t=document.createElement("div");return t.innerHTML=this.value?await this.contentConverter.parseAsHTML(this.value,this.schema):"<p></p>",Ut.fromSchema(this.schema).parse(t)}createEditorState(t){return fr.create({doc:t,plugins:[...fl({schema:this.schema}),eo(this.menuCommandFactory.buildKeymap()),Ya(this.triggerCharacters,this.contentConverter),Fa(this.handleNewLinkSelection),(o=this.imagePasted.emit,new dr({key:Aa,props:{handlePaste:(t,e,r)=>((t,e,r)=>{const i=e.clipboardData;if(!i)return!1;const n=function(t,e){let r=!1;const i=[...e.files||[]];for(const n of i)if(_a(n,e)){r=!0;const e=new FileReader;e.onloadend=()=>{t.dom.dispatchEvent(new CustomEvent("imagePasted",{detail:Ca(t,e.result,O(n))}))},e.readAsDataURL(n)}return r}(t,i),s=new st(Na(r.content),r.openStart,r.openEnd);if(s.content.childCount<r.content.childCount){const{state:e,dispatch:r}=t;return r(e.tr.replaceSelection(s)),!0}return n})(t,e,r),handleDOMEvents:{imagePasted:(t,e)=>{o(e.detail)}}}})),(s=this.language,new dr({props:{nodeViews:{image:(t,e,r)=>new Ta(t,e,r,s)}}})),(r=u,i=this.menuCommandFactory,n=this.updateActiveActionBarItems,new dr({key:za,state:{init:()=>({active:{},allowed:{}}),apply:(t,e)=>{const r=t.getMeta(za);return null!=r?r:e}},view:()=>({update:t=>{const e=za.getState(t.state),s=((t,e,r)=>{var i,n,s;const o={},l={};for(const u of t){const t=e.getCommand(u);o[u]=!!(null===(i=null==t?void 0:t.active)||void 0===i?void 0:i.call(t,r.state))||!1,l[u]=!(null!==(s=null===(n=null==t?void 0:t.allowed)||void 0===n?void 0:n.call(t,r.state))&&void 0!==s&&!s)}return{active:o,allowed:l}})(r,i,t);if(!$(e,s)){const e=t.state.tr.setMeta(za,s);t.dispatch(e),n(s.active,s.allowed)}}})})),Ia(this.menuCommandFactory),...(e="html"===this.contentType,e?[Rf()]:[])]});var e,r,i,n,s,o}async updateView(t){this.suppressChangeEvent=!0;const e=await this.contentConverter.parseAsHTML(t,this.schema),r=Ut.fromSchema(this.view.state.schema),i=(new window.DOMParser).parseFromString(e,"text/html"),n=r.parse(i.body),s=this.view.state.tr;s.replaceWith(0,s.doc.content.size,n.content),this.view.dispatch(s);const o=_f(this.view.state.doc);this.metadataEmitter(o),this.suppressChangeEvent=!1}metadataEmitter(t){var e,r,i,n;(function(t,e){return t.images.length!==e.images.length||t.links.length!==e.links.length}(e=this.metadata,r=t)||(n=r.links,!jf(zf(e.links),zf(n)))||(i=r.images,!jf(Tf(e.images),Tf(i))))&&(this.removeImagesFromCache(this.metadata,t),this.metadata=t,this.metadataChange.emit(t))}removeImagesFromCache(t,e){const r=t.images.filter((t=>!e.images.some((e=>e.fileInfoId===t.fileInfoId))));for(const t of r)ha.delete(t.fileInfoId),this.imageRemoved.emit(t)}static get delegatesFocus(){return!0}get host(){return n(this)}static get watchers(){return{value:[{watchValue:0}]}}};qf.style='@charset "UTF-8";blockquote{position:relative;max-width:100%;margin:0.75rem 0;padding:0.5rem;border-left:0.25rem solid rgb(var(--contrast-500));background-color:rgb(var(--contrast-200))}blockquote:before,blockquote:after{position:absolute;line-height:0;font-size:2rem;opacity:0.4}blockquote:before{content:"“";left:-0.5rem;top:0.5rem}blockquote:after{content:"”";right:-0.25rem;bottom:-0.25rem}blockquote blockquote{padding-top:0;padding-right:0;padding-bottom:0;padding-left:0.25rem;border-color:rgb(var(--contrast-700));border-left-width:1px}blockquote blockquote:before,blockquote blockquote:after{display:none}blockquote:has(>blockquote){padding-left:0.25rem;padding-bottom:0}:host(limel-markdown.truncate-paragraphs) p{overflow:hidden;white-space:nowrap;text-overflow:ellipsis}p,li{font-size:var(--limel-theme-default-font-size);word-break:break-word}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:var(--limel-theme-default-font-size);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:var(--limel-theme-default-font-size)}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:var(--limel-theme-default-small-font-size);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:var(--limel-theme-default-font-size)}: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}.image-wrapper{display:inline-flex;position:relative}.image-wrapper limel-linear-progress{position:absolute;inset:0.25rem auto auto 0.25rem;width:calc(100% - 0.5rem)}.image-wrapper img{transition:opacity 0.2s ease, scale 0.6s ease}.image-wrapper.state-failed,.image-wrapper.state-loading{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns=\'http://www.w3.org/2000/svg\'%20viewBox=\'0%200%208%208\'%20style=\'fill-rule:evenodd;\'%3E%3Cpath%20fill=\'rgba(186,186,192,0.16)\'%20d=\'M0%200h4v4H0zM4%204h4v4H4z\'/%3E%3C/svg%3E");background-size:0.5rem}.image-wrapper.state-failed img,.image-wrapper.state-loading img{opacity:0.3;scale:0.98}.image-wrapper::before{pointer-events:none;content:"";display:block;position:absolute;inset:0;border-radius:0.25rem;transition:border-color 0.4s ease, opacity 0.2s ease, box-shadow 0.6s ease;border:1px dashed transparent;opacity:0.2}.image-wrapper.state-failed img{filter:grayscale(0.8)}.image-wrapper.state-failed:before{opacity:0.8;box-shadow:var(--shadow-error-state)}.image-wrapper:hover::before{opacity:0.8;box-shadow:var(--shadow-depth-8)}.image-wrapper:has(.resize-handle[aria-grabbed=true])::before{border-color:var(--lime-primary-color, var(--limel-theme-primary-color));opacity:0.8;box-shadow:var(--shadow-depth-16), var(--shadow-depth-8)}.resize-handle{transition:color var(--limel-clickable-transition-speed, 0.4s) ease, background-color var(--limel-clickable-transition-speed, 0.4s) ease, box-shadow var(--limel-clickable-transform-speed, 0.4s) ease, transform var(--limel-clickable-transform-speed, 0.4s) var(--limel-clickable-transform-timing-function, ease);cursor:pointer;color:var(--limel-theme-on-surface-color);background-color:rgb(var(--contrast-900));box-shadow:var(--button-shadow-normal)}.resize-handle:hover,.resize-handle:focus,.resize-handle:focus-visible{will-change:color, background-color, box-shadow, transform}.resize-handle:hover,.resize-handle:focus-visible{transform:translate3d(0, -0.04rem, 0);color:var(--limel-theme-on-surface-color);background-color:var(--lime-elevated-surface-background-color);box-shadow:var(--button-shadow-hovered)}.resize-handle:active{--limel-clickable-transform-timing-function:cubic-bezier( 0.83, -0.15, 0.49, 1.16 );transform:translate3d(0, 0.05rem, 0);box-shadow:var(--button-shadow-pressed)}.resize-handle:hover,.resize-handle:active{--limel-clickable-transition-speed:0.2s;--limel-clickable-transform-speed:0.16s}.resize-handle:focus{outline:none}.resize-handle:focus-visible{outline:none;box-shadow:var(--shadow-depth-8-focused)}.resize-handle{cursor:nwse-resize;position:absolute;display:flex;align-items:center;justify-content:center;width:0.5rem;height:0.5rem;border-radius:50%}.resize-handle.top-left{left:-0.25rem;top:-0.25rem;translate:-50%, -50%}.resize-handle.bottom-right{right:-0.25rem;bottom:-0.25rem;translate:50%, 50%}.resize-handle{opacity:0.6}.resize-wrapper:has(.resize-handle[aria-grabbed=true]) .resize-handle,.resize-wrapper:hover .resize-handle,.resize-handle:hover,.resize-handle:focus-visible{opacity:1}.resize-handle[aria-grabbed=true],.resize-handle:hover,.resize-handle:focus-visible{opacity:1;background-color:var(--lime-primary-color, var(--limel-theme-primary-color))}.resize-handle:hover,.resize-handle[aria-grabbed=true]{scale:1.4}.resize-handle:hover:before,.resize-handle[aria-grabbed=true]:before{background-color:rgb(var(--color-white))}.resize-handle:before{content:"";display:block;position:absolute;inset:0;margin:auto;border-radius:50%;width:0.25rem;height:0.25rem;background-color:rgb(var(--contrast-100))}: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 *::selection{background:transparent}.ProseMirror-hideselection *::-moz-selection{background:transparent}.ProseMirror-hideselection{caret-color: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}';export{qf as limel_prosemirror_adapter}
1
+ import{r as t,c as e,h as r,H as i,a as n}from"./p-DBTJNfo7.js";import{E as s,L as o,M as l,e as u}from"./p-BWYo6dLf.js";import{g as h,m as a,s as f}from"./p-CfUOv15O.js";import{U as c,f as d,g as p,r as m,t as g,i as b,j as w,u as v}from"./p-DTNvx8HZ.js";import{a as k}from"./p-ZcW3uvZL.js";import{i as D,S as y}from"./p-BJQylLSL.js";import{g as E}from"./p-gWSB8lIW.js";import{i as x}from"./p-B8VKuhvH.js";import{i as F}from"./p-oiMYqRQ0.js";import{c as M}from"./p-2kcqdtMr.js";import{t as A}from"./p-Cdx3I2X8.js";import{c as C}from"./p-JbKhhoXs.js";import{i as S}from"./p-CrvUOVvg.js";import{c as O}from"./p-CWuGCKo1.js";import{i as $}from"./p-DkL-aPMx.js";import{d as B}from"./p-BviYUVSD.js";import"./p-BFTU3MAI.js";import"./p-DtS35Df5.js";import"./p-efBXH4mj.js";import"./p-BgPHaiMH.js";import"./p-Cs5T63LB.js";import"./p-f_1nwOC8.js";import"./p-DlJXKdhK.js";import"./p-CgNJbSP4.js";import"./p-D6dCQvwl.js";import"./p-BOEi1C7r.js";var R=Object.create,N=function(){function t(){}return function(e){if(!D(e))return{};if(R)return R(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}();"object"==typeof exports&&exports&&!exports.nodeType&&exports&&"object"==typeof module&&module&&!module.nodeType&&module;var _=Object.prototype.hasOwnProperty;function T(t){var e=new t.constructor(t.byteLength);return new c(e).set(new c(t)),e}var z=/\w*$/,j=y?y.prototype:void 0,q=j?j.valueOf:void 0;var I=g&&g.isMap,P=I?m(I):function(t){return F(t)&&"[object Map]"==p(t)},L=g&&g.isSet,J=L?m(L):function(t){return F(t)&&"[object Set]"==p(t)},U="[object Arguments]",V="[object Function]",H="[object Object]",W={};function G(t,e,r,i,n,s){var o;if(void 0!==o)return o;if(!D(t))return t;var l=x(t);if(l)o=function(t){var e=t.length,r=new t.constructor(e);return e&&"string"==typeof t[0]&&_.call(t,"index")&&(r.index=t.index,r.input=t.input),r}(t);else{var u=p(t),h=u==V||"[object GeneratorFunction]"==u;if(b(t))return t.slice();if(u==H||u==U||h&&!n)o=h?{}:function(t){return"function"!=typeof t.constructor||d(t)?{}:N(E(t))}(t);else{if(!W[u])return n?t:{};o=function(t,e){var r,i,n,s,o=t.constructor;switch(e){case"[object ArrayBuffer]":return T(t);case"[object Boolean]":case"[object Date]":return new o(+t);case"[object DataView]":return s=T((n=t).buffer),new n.constructor(s,n.byteOffset,n.byteLength);case"[object Float32Array]":case"[object Float64Array]":case"[object Int8Array]":case"[object Int16Array]":case"[object Int32Array]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":case"[object Uint16Array]":case"[object Uint32Array]":return function(t){var e=T(t.buffer);return new t.constructor(e,t.byteOffset,t.length)}(t);case"[object Map]":case"[object Set]":return new o;case"[object Number]":case"[object String]":return new o(t);case"[object RegExp]":return(i=new(r=t).constructor(r.source,z.exec(r))).lastIndex=r.lastIndex,i;case"[object Symbol]":return q?Object(q.call(t)):{}}}(t,u)}}s||(s=new w);var a=s.get(t);if(a)return a;s.set(t,o),J(t)?t.forEach((function(i){o.add(G(i,e,r,0,t,s))})):P(t)&&t.forEach((function(i,n){o.set(n,G(i,e,r,0,t,s))}));var f=l?void 0:v(t);return function(t,e){for(var r=-1,i=null==t?0:t.length;++r<i&&!1!==e(t[r],r););}(f||t,(function(i,n){f&&(i=t[n=i]),k(o,n,G(i,e,r,0,t,s))})),o}function Z(t){return G(t,5)}function K(t){this.content=t}function Y(t,e,r){for(let i=0;;i++){if(i==t.childCount||i==e.childCount)return t.childCount==e.childCount?null:r;let n=t.child(i),s=e.child(i);if(n!=s){if(!n.sameMarkup(s))return r;if(n.isText&&n.text!=s.text){for(let t=0;n.text[t]==s.text[t];t++)r++;return r}if(n.content.size||s.content.size){let t=Y(n.content,s.content,r+1);if(null!=t)return t}r+=n.nodeSize}else r+=n.nodeSize}}function X(t,e,r,i){for(let n=t.childCount,s=e.childCount;;){if(0==n||0==s)return n==s?null:{a:r,b:i};let o=t.child(--n),l=e.child(--s),u=o.nodeSize;if(o!=l){if(!o.sameMarkup(l))return{a:r,b:i};if(o.isText&&o.text!=l.text){let t=0,e=Math.min(o.text.length,l.text.length);for(;t<e&&o.text[o.text.length-t-1]==l.text[l.text.length-t-1];)t++,r--,i--;return{a:r,b:i}}if(o.content.size||l.content.size){let t=X(o.content,l.content,r-1,i-1);if(t)return t}r-=u,i-=u}else r-=u,i-=u}}W[U]=W["[object Array]"]=W["[object ArrayBuffer]"]=W["[object DataView]"]=W["[object Boolean]"]=W["[object Date]"]=W["[object Float32Array]"]=W["[object Float64Array]"]=W["[object Int8Array]"]=W["[object Int16Array]"]=W["[object Int32Array]"]=W["[object Map]"]=W["[object Number]"]=W[H]=W["[object RegExp]"]=W["[object Set]"]=W["[object String]"]=W["[object Symbol]"]=W["[object Uint8Array]"]=W["[object Uint8ClampedArray]"]=W["[object Uint16Array]"]=W["[object Uint32Array]"]=!0,W["[object Error]"]=W[V]=W["[object WeakMap]"]=!1,K.prototype={constructor:K,find:function(t){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===t)return e;return-1},get:function(t){var e=this.find(t);return-1==e?void 0:this.content[e+1]},update:function(t,e,r){var i=r&&r!=t?this.remove(r):this,n=i.find(t),s=i.content.slice();return-1==n?s.push(r||t,e):(s[n+1]=e,r&&(s[n]=r)),new K(s)},remove:function(t){var e=this.find(t);if(-1==e)return this;var r=this.content.slice();return r.splice(e,2),new K(r)},addToStart:function(t,e){return new K([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var r=this.remove(t).content.slice();return r.push(t,e),new K(r)},addBefore:function(t,e,r){var i=this.remove(e),n=i.content.slice(),s=i.find(t);return n.splice(-1==s?n.length:s,0,e,r),new K(n)},forEach:function(t){for(var e=0;e<this.content.length;e+=2)t(this.content[e],this.content[e+1])},prepend:function(t){return(t=K.from(t)).size?new K(t.content.concat(this.subtract(t).content)):this},append:function(t){return(t=K.from(t)).size?new K(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=K.from(t);for(var r=0;r<t.content.length;r+=2)e=e.remove(t.content[r]);return e},toObject:function(){var t={};return this.forEach((function(e,r){t[e]=r})),t},get size(){return this.content.length>>1}},K.from=function(t){if(t instanceof K)return t;var e=[];if(t)for(var r in t)e.push(r,t[r]);return new K(e)};class Q{constructor(t,e){if(this.content=t,this.size=e||0,null==e)for(let e=0;e<t.length;e++)this.size+=t[e].nodeSize}nodesBetween(t,e,r,i=0,n){for(let s=0,o=0;o<e;s++){let l=this.content[s],u=o+l.nodeSize;if(u>t&&!1!==r(l,i+o,n||null,s)&&l.content.size){let n=o+1;l.nodesBetween(Math.max(0,t-n),Math.min(l.content.size,e-n),r,i+n)}o=u}}descendants(t){this.nodesBetween(0,this.size,t)}textBetween(t,e,r,i){let n="",s=!0;return this.nodesBetween(t,e,((o,l)=>{let u=o.isText?o.text.slice(Math.max(t,l)-l,e-l):o.isLeaf?i?"function"==typeof i?i(o):i:o.type.spec.leafText?o.type.spec.leafText(o):"":"";o.isBlock&&(o.isLeaf&&u||o.isTextblock)&&r&&(s?s=!1:n+=r),n+=u}),0),n}append(t){if(!t.size)return this;if(!this.size)return t;let e=this.lastChild,r=t.firstChild,i=this.content.slice(),n=0;for(e.isText&&e.sameMarkup(r)&&(i[i.length-1]=e.withText(e.text+r.text),n=1);n<t.content.length;n++)i.push(t.content[n]);return new Q(i,this.size+t.size)}cut(t,e=this.size){if(0==t&&e==this.size)return this;let r=[],i=0;if(e>t)for(let n=0,s=0;s<e;n++){let o=this.content[n],l=s+o.nodeSize;l>t&&((s<t||l>e)&&(o=o.isText?o.cut(Math.max(0,t-s),Math.min(o.text.length,e-s)):o.cut(Math.max(0,t-s-1),Math.min(o.content.size,e-s-1))),r.push(o),i+=o.nodeSize),s=l}return new Q(r,i)}cutByIndex(t,e){return t==e?Q.empty:0==t&&e==this.content.length?this:new Q(this.content.slice(t,e))}replaceChild(t,e){let r=this.content[t];if(r==e)return this;let i=this.content.slice(),n=this.size+e.nodeSize-r.nodeSize;return i[t]=e,new Q(i,n)}addToStart(t){return new Q([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new Q(this.content.concat(t),this.size+t.nodeSize)}eq(t){if(this.content.length!=t.content.length)return!1;for(let e=0;e<this.content.length;e++)if(!this.content[e].eq(t.content[e]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(t){let e=this.content[t];if(!e)throw new RangeError("Index "+t+" out of range for "+this);return e}maybeChild(t){return this.content[t]||null}forEach(t){for(let e=0,r=0;e<this.content.length;e++){let i=this.content[e];t(i,r,e),r+=i.nodeSize}}findDiffStart(t,e=0){return Y(this,t,e)}findDiffEnd(t,e=this.size,r=t.size){return X(this,t,e,r)}findIndex(t,e=-1){if(0==t)return et(0,t);if(t==this.size)return et(this.content.length,t);if(t>this.size||t<0)throw new RangeError(`Position ${t} outside of fragment (${this})`);for(let r=0,i=0;;r++){let n=i+this.child(r).nodeSize;if(n>=t)return n==t||e>0?et(r+1,n):et(r,i);i=n}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map((t=>t.toJSON())):null}static fromJSON(t,e){if(!e)return Q.empty;if(!Array.isArray(e))throw new RangeError("Invalid input for Fragment.fromJSON");return new Q(e.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return Q.empty;let e,r=0;for(let i=0;i<t.length;i++){let n=t[i];r+=n.nodeSize,i&&n.isText&&t[i-1].sameMarkup(n)?(e||(e=t.slice(0,i)),e[e.length-1]=n.withText(e[e.length-1].text+n.text)):e&&e.push(n)}return new Q(e||t,r)}static from(t){if(!t)return Q.empty;if(t instanceof Q)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new Q([t],t.nodeSize);throw new RangeError("Can not convert "+t+" to a Fragment"+(t.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}Q.empty=new Q([],0);const tt={index:0,offset:0};function et(t,e){return tt.index=t,tt.offset=e,tt}function rt(t,e){if(t===e)return!0;if(!t||"object"!=typeof t||!e||"object"!=typeof e)return!1;let r=Array.isArray(t);if(Array.isArray(e)!=r)return!1;if(r){if(t.length!=e.length)return!1;for(let r=0;r<t.length;r++)if(!rt(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!rt(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}class it{constructor(t,e){this.type=t,this.attrs=e}addToSet(t){let e,r=!1;for(let i=0;i<t.length;i++){let n=t[i];if(this.eq(n))return t;if(this.type.excludes(n.type))e||(e=t.slice(0,i));else{if(n.type.excludes(this.type))return t;!r&&n.type.rank>this.type.rank&&(e||(e=t.slice(0,i)),e.push(this),r=!0),e&&e.push(n)}}return e||(e=t.slice()),r||e.push(this),e}removeFromSet(t){for(let e=0;e<t.length;e++)if(this.eq(t[e]))return t.slice(0,e).concat(t.slice(e+1));return t}isInSet(t){for(let e=0;e<t.length;e++)if(this.eq(t[e]))return!0;return!1}eq(t){return this==t||this.type==t.type&&rt(this.attrs,t.attrs)}toJSON(){let t={type:this.type.name};for(let e in this.attrs){t.attrs=this.attrs;break}return t}static fromJSON(t,e){if(!e)throw new RangeError("Invalid input for Mark.fromJSON");let r=t.marks[e.type];if(!r)throw new RangeError(`There is no mark type ${e.type} in this schema`);let i=r.create(e.attrs);return r.checkAttrs(i.attrs),i}static sameSet(t,e){if(t==e)return!0;if(t.length!=e.length)return!1;for(let r=0;r<t.length;r++)if(!t[r].eq(e[r]))return!1;return!0}static setFrom(t){if(!t||Array.isArray(t)&&0==t.length)return it.none;if(t instanceof it)return[t];let e=t.slice();return e.sort(((t,e)=>t.type.rank-e.type.rank)),e}}it.none=[];class nt extends Error{}class st{constructor(t,e,r){this.content=t,this.openStart=e,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(t,e){let r=lt(this.content,t+this.openStart,e);return r&&new st(r,this.openStart,this.openEnd)}removeBetween(t,e){return new st(ot(this.content,t+this.openStart,e+this.openStart),this.openStart,this.openEnd)}eq(t){return this.content.eq(t.content)&&this.openStart==t.openStart&&this.openEnd==t.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let t={content:this.content.toJSON()};return this.openStart>0&&(t.openStart=this.openStart),this.openEnd>0&&(t.openEnd=this.openEnd),t}static fromJSON(t,e){if(!e)return st.empty;let r=e.openStart||0,i=e.openEnd||0;if("number"!=typeof r||"number"!=typeof i)throw new RangeError("Invalid input for Slice.fromJSON");return new st(Q.fromJSON(t,e.content),r,i)}static maxOpen(t,e=!0){let r=0,i=0;for(let i=t.firstChild;i&&!i.isLeaf&&(e||!i.type.spec.isolating);i=i.firstChild)r++;for(let r=t.lastChild;r&&!r.isLeaf&&(e||!r.type.spec.isolating);r=r.lastChild)i++;return new st(t,r,i)}}function ot(t,e,r){let{index:i,offset:n}=t.findIndex(e),s=t.maybeChild(i),{index:o,offset:l}=t.findIndex(r);if(n==e||s.isText){if(l!=r&&!t.child(o).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(r))}if(i!=o)throw new RangeError("Removing non-flat range");return t.replaceChild(i,s.copy(ot(s.content,e-n-1,r-n-1)))}function lt(t,e,r){let{index:i,offset:n}=t.findIndex(e),s=t.maybeChild(i);if(n==e||s.isText)return t.cut(0,e).append(r).append(t.cut(e));let o=lt(s.content,e-n-1,r);return o&&t.replaceChild(i,s.copy(o))}function ut(t,e,r){if(r.openStart>t.depth)throw new nt("Inserted content deeper than insertion position");if(t.depth-r.openStart!=e.depth-r.openEnd)throw new nt("Inconsistent open depths");return ht(t,e,r,0)}function ht(t,e,r,i){let n=t.index(i),s=t.node(i);if(n==e.index(i)&&i<t.depth-r.openStart){let o=ht(t,e,r,i+1);return s.copy(s.content.replaceChild(n,o))}if(r.content.size){if(r.openStart||r.openEnd||t.depth!=i||e.depth!=i){let{start:n,end:o}=function(t,e){let r=e.depth-t.openStart,i=e.node(r).copy(t.content);for(let t=r-1;t>=0;t--)i=e.node(t).copy(Q.from(i));return{start:i.resolveNoCache(t.openStart+r),end:i.resolveNoCache(i.content.size-t.openEnd-r)}}(r,t);return pt(s,mt(t,n,o,e,i))}{let i=t.parent,n=i.content;return pt(i,n.cut(0,t.parentOffset).append(r.content).append(n.cut(e.parentOffset)))}}return pt(s,gt(t,e,i))}function at(t,e){if(!e.type.compatibleContent(t.type))throw new nt("Cannot join "+e.type.name+" onto "+t.type.name)}function ft(t,e,r){let i=t.node(r);return at(i,e.node(r)),i}function ct(t,e){let r=e.length-1;r>=0&&t.isText&&t.sameMarkup(e[r])?e[r]=t.withText(e[r].text+t.text):e.push(t)}function dt(t,e,r,i){let n=(e||t).node(r),s=0,o=e?e.index(r):n.childCount;t&&(s=t.index(r),t.depth>r?s++:t.textOffset&&(ct(t.nodeAfter,i),s++));for(let t=s;t<o;t++)ct(n.child(t),i);e&&e.depth==r&&e.textOffset&&ct(e.nodeBefore,i)}function pt(t,e){return t.type.checkContent(e),t.copy(e)}function mt(t,e,r,i,n){let s=t.depth>n&&ft(t,e,n+1),o=i.depth>n&&ft(r,i,n+1),l=[];return dt(null,t,n,l),s&&o&&e.index(n)==r.index(n)?(at(s,o),ct(pt(s,mt(t,e,r,i,n+1)),l)):(s&&ct(pt(s,gt(t,e,n+1)),l),dt(e,r,n,l),o&&ct(pt(o,gt(r,i,n+1)),l)),dt(i,null,n,l),new Q(l)}function gt(t,e,r){let i=[];return dt(null,t,r,i),t.depth>r&&ct(pt(ft(t,e,r+1),gt(t,e,r+1)),i),dt(e,null,r,i),new Q(i)}st.empty=new st(Q.empty,0,0);class bt{constructor(t,e,r){this.pos=t,this.path=e,this.parentOffset=r,this.depth=e.length/3-1}resolveDepth(t){return null==t?this.depth:t<0?this.depth+t:t}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(t){return this.path[3*this.resolveDepth(t)]}index(t){return this.path[3*this.resolveDepth(t)+1]}indexAfter(t){return t=this.resolveDepth(t),this.index(t)+(t!=this.depth||this.textOffset?1:0)}start(t){return 0==(t=this.resolveDepth(t))?0:this.path[3*t-1]+1}end(t){return t=this.resolveDepth(t),this.start(t)+this.node(t).content.size}before(t){if(!(t=this.resolveDepth(t)))throw new RangeError("There is no position before the top-level node");return t==this.depth+1?this.pos:this.path[3*t-1]}after(t){if(!(t=this.resolveDepth(t)))throw new RangeError("There is no position after the top-level node");return t==this.depth+1?this.pos:this.path[3*t-1]+this.path[3*t].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let t=this.parent,e=this.index(this.depth);if(e==t.childCount)return null;let r=this.pos-this.path[this.path.length-1],i=t.child(e);return r?t.child(e).cut(r):i}get nodeBefore(){let t=this.index(this.depth),e=this.pos-this.path[this.path.length-1];return e?this.parent.child(t).cut(0,e):0==t?null:this.parent.child(t-1)}posAtIndex(t,e){e=this.resolveDepth(e);let r=this.path[3*e],i=0==e?0:this.path[3*e-1]+1;for(let e=0;e<t;e++)i+=r.child(e).nodeSize;return i}marks(){let t=this.parent,e=this.index();if(0==t.content.size)return it.none;if(this.textOffset)return t.child(e).marks;let r=t.maybeChild(e-1),i=t.maybeChild(e);if(!r){let t=r;r=i,i=t}let n=r.marks;for(var s=0;s<n.length;s++)!1!==n[s].type.spec.inclusive||i&&n[s].isInSet(i.marks)||(n=n[s--].removeFromSet(n));return n}marksAcross(t){let e=this.parent.maybeChild(this.index());if(!e||!e.isInline)return null;let r=e.marks,i=t.parent.maybeChild(t.index());for(var n=0;n<r.length;n++)!1!==r[n].type.spec.inclusive||i&&r[n].isInSet(i.marks)||(r=r[n--].removeFromSet(r));return r}sharedDepth(t){for(let e=this.depth;e>0;e--)if(this.start(e)<=t&&this.end(e)>=t)return e;return 0}blockRange(t=this,e){if(t.pos<this.pos)return t.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==t.pos?1:0);r>=0;r--)if(t.pos<=this.end(r)&&(!e||e(this.node(r))))return new Dt(this,t,r);return null}sameParent(t){return this.pos-this.parentOffset==t.pos-t.parentOffset}max(t){return t.pos>this.pos?t:this}min(t){return t.pos<this.pos?t:this}toString(){let t="";for(let e=1;e<=this.depth;e++)t+=(t?"/":"")+this.node(e).type.name+"_"+this.index(e-1);return t+":"+this.parentOffset}static resolve(t,e){if(!(e>=0&&e<=t.content.size))throw new RangeError("Position "+e+" out of range");let r=[],i=0,n=e;for(let e=t;;){let{index:t,offset:s}=e.content.findIndex(n),o=n-s;if(r.push(e,t,i+s),!o)break;if(e=e.child(t),e.isText)break;n=o-1,i+=s+1}return new bt(e,r,n)}static resolveCached(t,e){let r=kt.get(t);if(r)for(let t=0;t<r.elts.length;t++){let i=r.elts[t];if(i.pos==e)return i}else kt.set(t,r=new wt);let i=r.elts[r.i]=bt.resolve(t,e);return r.i=(r.i+1)%vt,i}}class wt{constructor(){this.elts=[],this.i=0}}const vt=12,kt=new WeakMap;class Dt{constructor(t,e,r){this.$from=t,this.$to=e,this.depth=r}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const yt=Object.create(null);class Et{constructor(t,e,r,i=it.none){this.type=t,this.attrs=e,this.marks=i,this.content=r||Q.empty}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(t){return this.content.child(t)}maybeChild(t){return this.content.maybeChild(t)}forEach(t){this.content.forEach(t)}nodesBetween(t,e,r,i=0){this.content.nodesBetween(t,e,r,i,this)}descendants(t){this.nodesBetween(0,this.content.size,t)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(t,e,r,i){return this.content.textBetween(t,e,r,i)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(t){return this==t||this.sameMarkup(t)&&this.content.eq(t.content)}sameMarkup(t){return this.hasMarkup(t.type,t.attrs,t.marks)}hasMarkup(t,e,r){return this.type==t&&rt(this.attrs,e||t.defaultAttrs||yt)&&it.sameSet(this.marks,r||it.none)}copy(t=null){return t==this.content?this:new Et(this.type,this.attrs,t,this.marks)}mark(t){return t==this.marks?this:new Et(this.type,this.attrs,this.content,t)}cut(t,e=this.content.size){return 0==t&&e==this.content.size?this:this.copy(this.content.cut(t,e))}slice(t,e=this.content.size,r=!1){if(t==e)return st.empty;let i=this.resolve(t),n=this.resolve(e),s=r?0:i.sharedDepth(e),o=i.start(s),l=i.node(s).content.cut(i.pos-o,n.pos-o);return new st(l,i.depth-s,n.depth-s)}replace(t,e,r){return ut(this.resolve(t),this.resolve(e),r)}nodeAt(t){for(let e=this;;){let{index:r,offset:i}=e.content.findIndex(t);if(e=e.maybeChild(r),!e)return null;if(i==t||e.isText)return e;t-=i+1}}childAfter(t){let{index:e,offset:r}=this.content.findIndex(t);return{node:this.content.maybeChild(e),index:e,offset:r}}childBefore(t){if(0==t)return{node:null,index:0,offset:0};let{index:e,offset:r}=this.content.findIndex(t);if(r<t)return{node:this.content.child(e),index:e,offset:r};let i=this.content.child(e-1);return{node:i,index:e-1,offset:r-i.nodeSize}}resolve(t){return bt.resolveCached(this,t)}resolveNoCache(t){return bt.resolve(this,t)}rangeHasMark(t,e,r){let i=!1;return e>t&&this.nodesBetween(t,e,(t=>(r.isInSet(t.marks)&&(i=!0),!i))),i}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let t=this.type.name;return this.content.size&&(t+="("+this.content.toStringInner()+")"),Ft(this.marks,t)}contentMatchAt(t){let e=this.type.contentMatch.matchFragment(this.content,0,t);if(!e)throw new Error("Called contentMatchAt on a node with invalid content");return e}canReplace(t,e,r=Q.empty,i=0,n=r.childCount){let s=this.contentMatchAt(t).matchFragment(r,i,n),o=s&&s.matchFragment(this.content,e);if(!o||!o.validEnd)return!1;for(let t=i;t<n;t++)if(!this.type.allowsMarks(r.child(t).marks))return!1;return!0}canReplaceWith(t,e,r,i){if(i&&!this.type.allowsMarks(i))return!1;let n=this.contentMatchAt(t).matchType(r),s=n&&n.matchFragment(this.content,e);return!!s&&s.validEnd}canAppend(t){return t.content.size?this.canReplace(this.childCount,this.childCount,t.content):this.type.compatibleContent(t.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let t=it.none;for(let e=0;e<this.marks.length;e++){let r=this.marks[e];r.type.checkAttrs(r.attrs),t=r.addToSet(t)}if(!it.sameSet(t,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map((t=>t.type.name))}`);this.content.forEach((t=>t.check()))}toJSON(){let t={type:this.type.name};for(let e in this.attrs){t.attrs=this.attrs;break}return this.content.size&&(t.content=this.content.toJSON()),this.marks.length&&(t.marks=this.marks.map((t=>t.toJSON()))),t}static fromJSON(t,e){if(!e)throw new RangeError("Invalid input for Node.fromJSON");let r;if(e.marks){if(!Array.isArray(e.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=e.marks.map(t.markFromJSON)}if("text"==e.type){if("string"!=typeof e.text)throw new RangeError("Invalid text node in JSON");return t.text(e.text,r)}let i=Q.fromJSON(t,e.content),n=t.nodeType(e.type).create(e.attrs,i,r);return n.type.checkAttrs(n.attrs),n}}Et.prototype.text=void 0;class xt extends Et{constructor(t,e,r,i){if(super(t,e,null,i),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Ft(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(t,e){return this.text.slice(t,e)}get nodeSize(){return this.text.length}mark(t){return t==this.marks?this:new xt(this.type,this.attrs,this.text,t)}withText(t){return t==this.text?this:new xt(this.type,this.attrs,t,this.marks)}cut(t=0,e=this.text.length){return 0==t&&e==this.text.length?this:this.withText(this.text.slice(t,e))}eq(t){return this.sameMarkup(t)&&this.text==t.text}toJSON(){let t=super.toJSON();return t.text=this.text,t}}function Ft(t,e){for(let r=t.length-1;r>=0;r--)e=t[r].type.name+"("+e+")";return e}class Mt{constructor(t){this.validEnd=t,this.next=[],this.wrapCache=[]}static parse(t,e){let r=new At(t,e);if(null==r.next)return Mt.empty;let i=Ct(r);r.next&&r.err("Unexpected trailing text");let n=function(t){let e=Object.create(null);return function r(i){let n=[];i.forEach((e=>{t[e].forEach((({term:e,to:r})=>{if(!e)return;let i;for(let t=0;t<n.length;t++)n[t][0]==e&&(i=n[t][1]);Nt(t,r).forEach((t=>{i||n.push([e,i=[]]),-1==i.indexOf(t)&&i.push(t)}))}))}));let s=e[i.join(",")]=new Mt(i.indexOf(t.length-1)>-1);for(let t=0;t<n.length;t++){let i=n[t][1].sort(Rt);s.next.push({type:n[t][0],next:e[i.join(",")]||r(i)})}return s}(Nt(t,0))}(function(t){let e=[[]];return n(function t(e,s){if("choice"==e.type)return e.exprs.reduce(((e,r)=>e.concat(t(r,s))),[]);if("seq"!=e.type){if("star"==e.type){let o=r();return i(s,o),n(t(e.expr,o),o),[i(o)]}if("plus"==e.type){let o=r();return n(t(e.expr,s),o),n(t(e.expr,o),o),[i(o)]}if("opt"==e.type)return[i(s)].concat(t(e.expr,s));if("range"==e.type){let o=s;for(let i=0;i<e.min;i++){let i=r();n(t(e.expr,o),i),o=i}if(-1==e.max)n(t(e.expr,o),o);else for(let s=e.min;s<e.max;s++){let s=r();i(o,s),n(t(e.expr,o),s),o=s}return[i(o)]}if("name"==e.type)return[i(s,void 0,e.value)];throw new Error("Unknown expr type")}for(let i=0;;i++){let o=t(e.exprs[i],s);if(i==e.exprs.length-1)return o;n(o,s=r())}}(t,0),r()),e;function r(){return e.push([])-1}function i(t,r,i){let n={term:i,to:r};return e[t].push(n),n}function n(t,e){t.forEach((t=>t.to=e))}}(i));return function(t,e){for(let r=0,i=[t];r<i.length;r++){let t=i[r],n=!t.validEnd,s=[];for(let e=0;e<t.next.length;e++){let{type:r,next:o}=t.next[e];s.push(r.name),!n||r.isText||r.hasRequiredAttrs()||(n=!1),-1==i.indexOf(o)&&i.push(o)}n&&e.err("Only non-generatable nodes ("+s.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}(n,r),n}matchType(t){for(let e=0;e<this.next.length;e++)if(this.next[e].type==t)return this.next[e].next;return null}matchFragment(t,e=0,r=t.childCount){let i=this;for(let n=e;i&&n<r;n++)i=i.matchType(t.child(n).type);return i}get inlineContent(){return 0!=this.next.length&&this.next[0].type.isInline}get defaultType(){for(let t=0;t<this.next.length;t++){let{type:e}=this.next[t];if(!e.isText&&!e.hasRequiredAttrs())return e}return null}compatible(t){for(let e=0;e<this.next.length;e++)for(let r=0;r<t.next.length;r++)if(this.next[e].type==t.next[r].type)return!0;return!1}fillBefore(t,e=!1,r=0){let i=[this];return function n(s,o){let l=s.matchFragment(t,r);if(l&&(!e||l.validEnd))return Q.from(o.map((t=>t.createAndFill())));for(let t=0;t<s.next.length;t++){let{type:e,next:r}=s.next[t];if(!e.isText&&!e.hasRequiredAttrs()&&-1==i.indexOf(r)){i.push(r);let t=n(r,o.concat(e));if(t)return t}}return null}(this,[])}findWrapping(t){for(let e=0;e<this.wrapCache.length;e+=2)if(this.wrapCache[e]==t)return this.wrapCache[e+1];let e=this.computeWrapping(t);return this.wrapCache.push(t,e),e}computeWrapping(t){let e=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let i=r.shift(),n=i.match;if(n.matchType(t)){let t=[];for(let e=i;e.type;e=e.via)t.push(e.type);return t.reverse()}for(let t=0;t<n.next.length;t++){let{type:s,next:o}=n.next[t];s.isLeaf||s.hasRequiredAttrs()||s.name in e||i.type&&!o.validEnd||(r.push({match:s.contentMatch,type:s,via:i}),e[s.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(t){if(t>=this.next.length)throw new RangeError(`There's no ${t}th edge in this content match`);return this.next[t]}toString(){let t=[];return function e(r){t.push(r);for(let i=0;i<r.next.length;i++)-1==t.indexOf(r.next[i].next)&&e(r.next[i].next)}(this),t.map(((e,r)=>{let i=r+(e.validEnd?"*":" ")+" ";for(let r=0;r<e.next.length;r++)i+=(r?", ":"")+e.next[r].type.name+"->"+t.indexOf(e.next[r].next);return i})).join("\n")}}Mt.empty=new Mt(!0);class At{constructor(t,e){this.string=t,this.nodeTypes=e,this.inline=null,this.pos=0,this.tokens=t.split(/\s*(?=\b|\W|$)/),""==this.tokens[this.tokens.length-1]&&this.tokens.pop(),""==this.tokens[0]&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(t){return this.next==t&&(this.pos++||!0)}err(t){throw new SyntaxError(t+" (in content expression '"+this.string+"')")}}function Ct(t){let e=[];do{e.push(St(t))}while(t.eat("|"));return 1==e.length?e[0]:{type:"choice",exprs:e}}function St(t){let e=[];do{e.push(Ot(t))}while(t.next&&")"!=t.next&&"|"!=t.next);return 1==e.length?e[0]:{type:"seq",exprs:e}}function Ot(t){let e=function(t){if(t.eat("(")){let e=Ct(t);return t.eat(")")||t.err("Missing closing paren"),e}if(!/\W/.test(t.next)){let e=function(t,e){let r=t.nodeTypes,i=r[e];if(i)return[i];let n=[];for(let t in r){let i=r[t];i.groups.indexOf(e)>-1&&n.push(i)}return 0==n.length&&t.err("No node type or group '"+e+"' found"),n}(t,t.next).map((e=>(null==t.inline?t.inline=e.isInline:t.inline!=e.isInline&&t.err("Mixing inline and block content"),{type:"name",value:e})));return t.pos++,1==e.length?e[0]:{type:"choice",exprs:e}}t.err("Unexpected token '"+t.next+"'")}(t);for(;;)if(t.eat("+"))e={type:"plus",expr:e};else if(t.eat("*"))e={type:"star",expr:e};else if(t.eat("?"))e={type:"opt",expr:e};else{if(!t.eat("{"))break;e=Bt(t,e)}return e}function $t(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function Bt(t,e){let r=$t(t),i=r;return t.eat(",")&&(i="}"!=t.next?$t(t):-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:r,max:i,expr:e}}function Rt(t,e){return e-t}function Nt(t,e){let r=[];return function e(i){let n=t[i];if(1==n.length&&!n[0].term)return e(n[0].to);r.push(i);for(let t=0;t<n.length;t++){let{term:i,to:s}=n[t];i||-1!=r.indexOf(s)||e(s)}}(e),r.sort(Rt)}function _t(t){let e=Object.create(null);for(let r in t){let i=t[r];if(!i.hasDefault)return null;e[r]=i.default}return e}function Tt(t,e){let r=Object.create(null);for(let i in t){let n=e&&e[i];if(void 0===n){let e=t[i];if(!e.hasDefault)throw new RangeError("No value supplied for attribute "+i);n=e.default}r[i]=n}return r}function zt(t,e,r){for(let i in e)if(!(i in t))throw new RangeError(`Unsupported attribute ${i} for ${r} of type ${i}`);for(let r in t){let i=t[r];i.validate&&i.validate(e[r])}}function jt(t,e){let r=Object.create(null);if(e)for(let i in e)r[i]=new It(t,i,e[i]);return r}let qt=class t{constructor(t,e,r){this.name=t,this.schema=e,this.spec=r,this.markSet=null,this.groups=r.group?r.group.split(" "):[],this.attrs=jt(t,r.attrs),this.defaultAttrs=_t(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(r.inline||"text"==t),this.isText="text"==t}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==Mt.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let t in this.attrs)if(this.attrs[t].isRequired)return!0;return!1}compatibleContent(t){return this==t||this.contentMatch.compatible(t.contentMatch)}computeAttrs(t){return!t&&this.defaultAttrs?this.defaultAttrs:Tt(this.attrs,t)}create(t=null,e,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Et(this,this.computeAttrs(t),Q.from(e),it.setFrom(r))}createChecked(t=null,e,r){return e=Q.from(e),this.checkContent(e),new Et(this,this.computeAttrs(t),e,it.setFrom(r))}createAndFill(t=null,e,r){if(t=this.computeAttrs(t),(e=Q.from(e)).size){let t=this.contentMatch.fillBefore(e);if(!t)return null;e=t.append(e)}let i=this.contentMatch.matchFragment(e),n=i&&i.fillBefore(Q.empty,!0);return n?new Et(this,t,e.append(n),it.setFrom(r)):null}validContent(t){let e=this.contentMatch.matchFragment(t);if(!e||!e.validEnd)return!1;for(let e=0;e<t.childCount;e++)if(!this.allowsMarks(t.child(e).marks))return!1;return!0}checkContent(t){if(!this.validContent(t))throw new RangeError(`Invalid content for node ${this.name}: ${t.toString().slice(0,50)}`)}checkAttrs(t){zt(this.attrs,t,"node")}allowsMarkType(t){return null==this.markSet||this.markSet.indexOf(t)>-1}allowsMarks(t){if(null==this.markSet)return!0;for(let e=0;e<t.length;e++)if(!this.allowsMarkType(t[e].type))return!1;return!0}allowedMarks(t){if(null==this.markSet)return t;let e;for(let r=0;r<t.length;r++)this.allowsMarkType(t[r].type)?e&&e.push(t[r]):e||(e=t.slice(0,r));return e?e.length?e:it.none:t}static compile(e,r){let i=Object.create(null);e.forEach(((e,n)=>i[e]=new t(e,r,n)));let n=r.spec.topNode||"doc";if(!i[n])throw new RangeError("Schema is missing its top node type ('"+n+"')");if(!i.text)throw new RangeError("Every schema needs a 'text' type");for(let t in i.text.attrs)throw new RangeError("The text node type should not have attributes");return i}};class It{constructor(t,e,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate="string"==typeof r.validate?function(t,e,r){let i=r.split("|");return r=>{let n=null===r?"null":typeof r;if(i.indexOf(n)<0)throw new RangeError(`Expected value of type ${i} for attribute ${e} on type ${t}, got ${n}`)}}(t,e,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class Pt{constructor(t,e,r,i){this.name=t,this.rank=e,this.schema=r,this.spec=i,this.attrs=jt(t,i.attrs),this.excluded=null;let n=_t(this.attrs);this.instance=n?new it(this,n):null}create(t=null){return!t&&this.instance?this.instance:new it(this,Tt(this.attrs,t))}static compile(t,e){let r=Object.create(null),i=0;return t.forEach(((t,n)=>r[t]=new Pt(t,i++,e,n))),r}removeFromSet(t){for(var e=0;e<t.length;e++)t[e].type==this&&(t=t.slice(0,e).concat(t.slice(e+1)),e--);return t}isInSet(t){for(let e=0;e<t.length;e++)if(t[e].type==this)return t[e]}checkAttrs(t){zt(this.attrs,t,"mark")}excludes(t){return this.excluded.indexOf(t)>-1}}class Lt{constructor(t){this.linebreakReplacement=null,this.cached=Object.create(null);let e=this.spec={};for(let r in t)e[r]=t[r];e.nodes=K.from(t.nodes),e.marks=K.from(t.marks||{}),this.nodes=qt.compile(this.spec.nodes,this),this.marks=Pt.compile(this.spec.marks,this);let r=Object.create(null);for(let t in this.nodes){if(t in this.marks)throw new RangeError(t+" can not be both a node and a mark");let e=this.nodes[t],i=e.spec.content||"",n=e.spec.marks;if(e.contentMatch=r[i]||(r[i]=Mt.parse(i,this.nodes)),e.inlineContent=e.contentMatch.inlineContent,e.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!e.isInline||!e.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=e}e.markSet="_"==n?null:n?Jt(this,n.split(" ")):""!=n&&e.inlineContent?null:[]}for(let t in this.marks){let e=this.marks[t],r=e.spec.excludes;e.excluded=null==r?[e]:""==r?[]:Jt(this,r.split(" "))}this.nodeFromJSON=this.nodeFromJSON.bind(this),this.markFromJSON=this.markFromJSON.bind(this),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(t,e=null,r,i){if("string"==typeof t)t=this.nodeType(t);else{if(!(t instanceof qt))throw new RangeError("Invalid node type: "+t);if(t.schema!=this)throw new RangeError("Node type from different schema used ("+t.name+")")}return t.createChecked(e,r,i)}text(t,e){let r=this.nodes.text;return new xt(r,r.defaultAttrs,t,it.setFrom(e))}mark(t,e){return"string"==typeof t&&(t=this.marks[t]),t.create(e)}nodeFromJSON(t){return Et.fromJSON(this,t)}markFromJSON(t){return it.fromJSON(this,t)}nodeType(t){let e=this.nodes[t];if(!e)throw new RangeError("Unknown node type: "+t);return e}}function Jt(t,e){let r=[];for(let i=0;i<e.length;i++){let n=e[i],s=t.marks[n],o=s;if(s)r.push(s);else for(let e in t.marks){let i=t.marks[e];("_"==n||i.spec.group&&i.spec.group.split(" ").indexOf(n)>-1)&&r.push(o=i)}if(!o)throw new SyntaxError("Unknown mark type: '"+e[i]+"'")}return r}class Ut{constructor(t,e){this.schema=t,this.rules=e,this.tags=[],this.styles=[];let r=this.matchedStyles=[];e.forEach((t=>{if(function(t){return null!=t.tag}(t))this.tags.push(t);else if(function(t){return null!=t.style}(t)){let e=/[^=]*/.exec(t.style)[0];r.indexOf(e)<0&&r.push(e),this.styles.push(t)}})),this.normalizeLists=!this.tags.some((e=>{if(!/^(ul|ol)\b/.test(e.tag)||!e.node)return!1;let r=t.nodes[e.node];return r.contentMatch.matchType(r)}))}parse(t,e={}){let r=new Kt(this,e,!1);return r.addAll(t,it.none,e.from,e.to),r.finish()}parseSlice(t,e={}){let r=new Kt(this,e,!0);return r.addAll(t,it.none,e.from,e.to),st.maxOpen(r.finish())}matchTag(t,e,r){for(let i=r?this.tags.indexOf(r)+1:0;i<this.tags.length;i++){let r=this.tags[i];if(Yt(t,r.tag)&&(void 0===r.namespace||t.namespaceURI==r.namespace)&&(!r.context||e.matchesContext(r.context))){if(r.getAttrs){let e=r.getAttrs(t);if(!1===e)continue;r.attrs=e||void 0}return r}}}matchStyle(t,e,r,i){for(let n=i?this.styles.indexOf(i)+1:0;n<this.styles.length;n++){let i=this.styles[n],s=i.style;if(!(0!=s.indexOf(t)||i.context&&!r.matchesContext(i.context)||s.length>t.length&&(61!=s.charCodeAt(t.length)||s.slice(t.length+1)!=e))){if(i.getAttrs){let t=i.getAttrs(e);if(!1===t)continue;i.attrs=t||void 0}return i}}}static schemaRules(t){let e=[];function r(t){let r=null==t.priority?50:t.priority,i=0;for(;i<e.length;i++){let t=e[i];if((null==t.priority?50:t.priority)<r)break}e.splice(i,0,t)}for(let e in t.marks){let i=t.marks[e].spec.parseDOM;i&&i.forEach((t=>{r(t=Xt(t)),t.mark||t.ignore||t.clearMark||(t.mark=e)}))}for(let e in t.nodes){let i=t.nodes[e].spec.parseDOM;i&&i.forEach((t=>{r(t=Xt(t)),t.node||t.ignore||t.mark||(t.node=e)}))}return e}static fromSchema(t){return t.cached.domParser||(t.cached.domParser=new Ut(t,Ut.schemaRules(t)))}}const Vt={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},Ht={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Wt={ol:!0,ul:!0};function Gt(t,e,r){return null!=e?(e?1:0)|("full"===e?2:0):t&&"pre"==t.whitespace?3:-5&r}class Zt{constructor(t,e,r,i,n,s){this.type=t,this.attrs=e,this.marks=r,this.solid=i,this.options=s,this.content=[],this.activeMarks=it.none,this.match=n||(4&s?null:t.contentMatch)}findWrapping(t){if(!this.match){if(!this.type)return[];let e=this.type.contentMatch.fillBefore(Q.from(t));if(!e){let e,r=this.type.contentMatch;return(e=r.findWrapping(t.type))?(this.match=r,e):null}this.match=this.type.contentMatch.matchFragment(e)}return this.match.findWrapping(t.type)}finish(t){if(!(1&this.options)){let t,e=this.content[this.content.length-1];if(e&&e.isText&&(t=/[ \t\r\n\u000c]+$/.exec(e.text))){let r=e;e.text.length==t[0].length?this.content.pop():this.content[this.content.length-1]=r.withText(r.text.slice(0,r.text.length-t[0].length))}}let e=Q.from(this.content);return!t&&this.match&&(e=e.append(this.match.fillBefore(Q.empty,!0))),this.type?this.type.create(this.attrs,e,this.marks):e}inlineContext(t){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:t.parentNode&&!Vt.hasOwnProperty(t.parentNode.nodeName.toLowerCase())}}class Kt{constructor(t,e,r){this.parser=t,this.options=e,this.isOpen=r,this.open=0;let i,n=e.topNode,s=Gt(null,e.preserveWhitespace,0)|(r?4:0);i=n?new Zt(n.type,n.attrs,it.none,!0,e.topMatch||n.type.contentMatch,s):new Zt(r?null:t.schema.topNodeType,null,it.none,!0,null,s),this.nodes=[i],this.find=e.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(t,e){3==t.nodeType?this.addTextNode(t,e):1==t.nodeType&&this.addElement(t,e)}addTextNode(t,e){let r=t.nodeValue,i=this.top;if(2&i.options||i.inlineContext(t)||/[^ \t\r\n\u000c]/.test(r)){if(1&i.options)r=2&i.options?r.replace(/\r\n?/g,"\n"):r.replace(/\r?\n|\r/g," ");else if(r=r.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let e=i.content[i.content.length-1],n=t.previousSibling;(!e||n&&"BR"==n.nodeName||e.isText&&/[ \t\r\n\u000c]$/.test(e.text))&&(r=r.slice(1))}r&&this.insertNode(this.parser.schema.text(r),e),this.findInText(t)}else this.findInside(t)}addElement(t,e,r){let i,n=t.nodeName.toLowerCase();Wt.hasOwnProperty(n)&&this.parser.normalizeLists&&function(t){for(let e=t.firstChild,r=null;e;e=e.nextSibling){let t=1==e.nodeType?e.nodeName.toLowerCase():null;t&&Wt.hasOwnProperty(t)&&r?(r.appendChild(e),e=r):"li"==t?r=e:t&&(r=null)}}(t);let s=this.options.ruleFromNode&&this.options.ruleFromNode(t)||(i=this.parser.matchTag(t,this,r));if(s?s.ignore:Ht.hasOwnProperty(n))this.findInside(t),this.ignoreFallback(t,e);else if(!s||s.skip||s.closeParent){s&&s.closeParent?this.open=Math.max(0,this.open-1):s&&s.skip.nodeType&&(t=s.skip);let r,i=this.top,o=this.needsBlock;if(Vt.hasOwnProperty(n))i.content.length&&i.content[0].isInline&&this.open&&(this.open--,i=this.top),r=!0,i.type||(this.needsBlock=!0);else if(!t.firstChild)return void this.leafFallback(t,e);let l=s&&s.skip?e:this.readStyles(t,e);l&&this.addAll(t,l),r&&this.sync(i),this.needsBlock=o}else{let r=this.readStyles(t,e);r&&this.addElementByRule(t,s,r,!1===s.consuming?i:void 0)}}leafFallback(t,e){"BR"==t.nodeName&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(t.ownerDocument.createTextNode("\n"),e)}ignoreFallback(t,e){"BR"!=t.nodeName||this.top.type&&this.top.type.inlineContent||this.findPlace(this.parser.schema.text("-"),e)}readStyles(t,e){let r=t.style;if(r&&r.length)for(let t=0;t<this.parser.matchedStyles.length;t++){let i=this.parser.matchedStyles[t],n=r.getPropertyValue(i);if(n)for(let t;;){let r=this.parser.matchStyle(i,n,this,t);if(!r)break;if(r.ignore)return null;if(e=r.clearMark?e.filter((t=>!r.clearMark(t))):e.concat(this.parser.schema.marks[r.mark].create(r.attrs)),!1!==r.consuming)break;t=r}}return e}addElementByRule(t,e,r,i){let n,s;if(e.node)if(s=this.parser.schema.nodes[e.node],s.isLeaf)this.insertNode(s.create(e.attrs),r)||this.leafFallback(t,r);else{let t=this.enter(s,e.attrs||null,r,e.preserveWhitespace);t&&(n=!0,r=t)}else r=r.concat(this.parser.schema.marks[e.mark].create(e.attrs));let o=this.top;if(s&&s.isLeaf)this.findInside(t);else if(i)this.addElement(t,r,i);else if(e.getContent)this.findInside(t),e.getContent(t,this.parser.schema).forEach((t=>this.insertNode(t,r)));else{let i=t;"string"==typeof e.contentElement?i=t.querySelector(e.contentElement):"function"==typeof e.contentElement?i=e.contentElement(t):e.contentElement&&(i=e.contentElement),this.findAround(t,i,!0),this.addAll(i,r)}n&&this.sync(o)&&this.open--}addAll(t,e,r,i){let n=r||0;for(let s=r?t.childNodes[r]:t.firstChild,o=null==i?null:t.childNodes[i];s!=o;s=s.nextSibling,++n)this.findAtPoint(t,n),this.addDOM(s,e);this.findAtPoint(t,n)}findPlace(t,e){let r,i;for(let e=this.open;e>=0;e--){let n=this.nodes[e],s=n.findWrapping(t);if(s&&(!r||r.length>s.length)&&(r=s,i=n,!s.length))break;if(n.solid)break}if(!r)return null;this.sync(i);for(let t=0;t<r.length;t++)e=this.enterInner(r[t],null,e,!1);return e}insertNode(t,e){if(t.isInline&&this.needsBlock&&!this.top.type){let t=this.textblockFromContext();t&&(e=this.enterInner(t,null,e))}let r=this.findPlace(t,e);if(r){this.closeExtra();let e=this.top;e.match&&(e.match=e.match.matchType(t.type));let i=it.none;for(let n of r.concat(t.marks))(e.type?e.type.allowsMarkType(n.type):Qt(n.type,t.type))&&(i=n.addToSet(i));return e.content.push(t.mark(i)),!0}return!1}enter(t,e,r,i){let n=this.findPlace(t.create(e),r);return n&&(n=this.enterInner(t,e,r,!0,i)),n}enterInner(t,e,r,i=!1,n){this.closeExtra();let s=this.top;s.match=s.match&&s.match.matchType(t);let o=Gt(t,n,s.options);4&s.options&&0==s.content.length&&(o|=4);let l=it.none;return r=r.filter((e=>!(s.type?s.type.allowsMarkType(e.type):Qt(e.type,t))||(l=e.addToSet(l),!1))),this.nodes.push(new Zt(t,e,l,i,null,o)),this.open++,r}closeExtra(t=!1){let e=this.nodes.length-1;if(e>this.open){for(;e>this.open;e--)this.nodes[e-1].content.push(this.nodes[e].finish(t));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(this.isOpen||this.options.topOpen)}sync(t){for(let e=this.open;e>=0;e--)if(this.nodes[e]==t)return this.open=e,!0;return!1}get currentPos(){this.closeExtra();let t=0;for(let e=this.open;e>=0;e--){let r=this.nodes[e].content;for(let e=r.length-1;e>=0;e--)t+=r[e].nodeSize;e&&t++}return t}findAtPoint(t,e){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==t&&this.find[r].offset==e&&(this.find[r].pos=this.currentPos)}findInside(t){if(this.find)for(let e=0;e<this.find.length;e++)null==this.find[e].pos&&1==t.nodeType&&t.contains(this.find[e].node)&&(this.find[e].pos=this.currentPos)}findAround(t,e,r){if(t!=e&&this.find)for(let i=0;i<this.find.length;i++)null==this.find[i].pos&&1==t.nodeType&&t.contains(this.find[i].node)&&e.compareDocumentPosition(this.find[i].node)&(r?2:4)&&(this.find[i].pos=this.currentPos)}findInText(t){if(this.find)for(let e=0;e<this.find.length;e++)this.find[e].node==t&&(this.find[e].pos=this.currentPos-(t.nodeValue.length-this.find[e].offset))}matchesContext(t){if(t.indexOf("|")>-1)return t.split(/\s*\|\s*/).some(this.matchesContext,this);let e=t.split("/"),r=this.options.context,i=!(this.isOpen||r&&r.parent.type!=this.nodes[0].type),n=(i?0:1)-(r?r.depth+1:0),s=(t,o)=>{for(;t>=0;t--){let l=e[t];if(""==l){if(t==e.length-1||0==t)continue;for(;o>=n;o--)if(s(t-1,o))return!0;return!1}{let t=o>0||0==o&&i?this.nodes[o].type:r&&o>=n?r.node(o-n).type:null;if(!t||t.name!=l&&-1==t.groups.indexOf(l))return!1;o--}}return!0};return s(e.length-1,this.open)}textblockFromContext(){let t=this.options.context;if(t)for(let e=t.depth;e>=0;e--){let r=t.node(e).contentMatchAt(t.indexAfter(e)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let t in this.parser.schema.nodes){let e=this.parser.schema.nodes[t];if(e.isTextblock&&e.defaultAttrs)return e}}}function Yt(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function Xt(t){let e={};for(let r in t)e[r]=t[r];return e}function Qt(t,e){let r=e.schema.nodes;for(let i in r){let n=r[i];if(!n.allowsMarkType(t))continue;let s=[],o=t=>{s.push(t);for(let r=0;r<t.edgeCount;r++){let{type:i,next:n}=t.edge(r);if(i==e)return!0;if(s.indexOf(n)<0&&o(n))return!0}};if(o(n.contentMatch))return!0}}class te{constructor(t,e){this.nodes=t,this.marks=e}serializeFragment(t,e={},r){r||(r=re(e).createDocumentFragment());let i=r,n=[];return t.forEach((t=>{if(n.length||t.marks.length){let r=0,s=0;for(;r<n.length&&s<t.marks.length;){let e=t.marks[s];if(this.marks[e.type.name]){if(!e.eq(n[r][0])||!1===e.type.spec.spanning)break;r++,s++}else s++}for(;r<n.length;)i=n.pop()[1];for(;s<t.marks.length;){let r=t.marks[s++],o=this.serializeMark(r,t.isInline,e);o&&(n.push([r,i]),i.appendChild(o.dom),i=o.contentDOM||o.dom)}}i.appendChild(this.serializeNodeInner(t,e))})),r}serializeNodeInner(t,e){let{dom:r,contentDOM:i}=ne(re(e),this.nodes[t.type.name](t),null,t.attrs);if(i){if(t.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(t.content,e,i)}return r}serializeNode(t,e={}){let r=this.serializeNodeInner(t,e);for(let i=t.marks.length-1;i>=0;i--){let n=this.serializeMark(t.marks[i],t.isInline,e);n&&((n.contentDOM||n.dom).appendChild(r),r=n.dom)}return r}serializeMark(t,e,r={}){let i=this.marks[t.type.name];return i&&ne(re(r),i(t,e),null,t.attrs)}static renderSpec(t,e,r=null,i){return ne(t,e,r,i)}static fromSchema(t){return t.cached.domSerializer||(t.cached.domSerializer=new te(this.nodesFromSchema(t),this.marksFromSchema(t)))}static nodesFromSchema(t){let e=ee(t.nodes);return e.text||(e.text=t=>t.text),e}static marksFromSchema(t){return ee(t.marks)}}function ee(t){let e={};for(let r in t){let i=t[r].spec.toDOM;i&&(e[r]=i)}return e}function re(t){return t.document||window.document}const ie=new WeakMap;function ne(t,e,r,i){if("string"==typeof e)return{dom:t.createTextNode(e)};if(null!=e.nodeType)return{dom:e};if(e.dom&&null!=e.dom.nodeType)return e;let n,s=e[0];if("string"!=typeof s)throw new RangeError("Invalid array passed to renderSpec");if(i&&(n=function(t){let e=ie.get(t);return void 0===e&&ie.set(t,e=function(t){let e=null;return function t(r){if(r&&"object"==typeof r)if(Array.isArray(r))if("string"==typeof r[0])e||(e=[]),e.push(r);else for(let e=0;e<r.length;e++)t(r[e]);else for(let e in r)t(r[e])}(t),e}(t)),e}(i))&&n.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let o,l=s.indexOf(" ");l>0&&(r=s.slice(0,l),s=s.slice(l+1));let u=r?t.createElementNS(r,s):t.createElement(s),h=e[1],a=1;if(h&&"object"==typeof h&&null==h.nodeType&&!Array.isArray(h)){a=2;for(let t in h)if(null!=h[t]){let e=t.indexOf(" ");e>0?u.setAttributeNS(t.slice(0,e),t.slice(e+1),h[t]):u.setAttribute(t,h[t])}}for(let n=a;n<e.length;n++){let s=e[n];if(0===s){if(n<e.length-1||n>a)throw new RangeError("Content hole must be the only child of its parent node");return{dom:u,contentDOM:u}}{let{dom:e,contentDOM:n}=ne(t,s,r,i);if(u.appendChild(e),n){if(o)throw new RangeError("Multiple content holes");o=n}}}return{dom:u,contentDOM:o}}const se=Math.pow(2,16);function oe(t){return 65535&t}class le{constructor(t,e,r){this.pos=t,this.delInfo=e,this.recover=r}get deleted(){return(8&this.delInfo)>0}get deletedBefore(){return(5&this.delInfo)>0}get deletedAfter(){return(6&this.delInfo)>0}get deletedAcross(){return(4&this.delInfo)>0}}class ue{constructor(t,e=!1){if(this.ranges=t,this.inverted=e,!t.length&&ue.empty)return ue.empty}recover(t){let e=0,r=oe(t);if(!this.inverted)for(let t=0;t<r;t++)e+=this.ranges[3*t+2]-this.ranges[3*t+1];return this.ranges[3*r]+e+function(t){return(t-(65535&t))/se}(t)}mapResult(t,e=1){return this._map(t,e,!1)}map(t,e=1){return this._map(t,e,!0)}_map(t,e,r){let i=0,n=this.inverted?2:1,s=this.inverted?1:2;for(let o=0;o<this.ranges.length;o+=3){let l=this.ranges[o]-(this.inverted?i:0);if(l>t)break;let u=this.ranges[o+n],h=this.ranges[o+s],a=l+u;if(t<=a){let n=l+i+((u?t==l?-1:t==a?1:e:e)<0?0:h);if(r)return n;let s=t==l?2:t==a?1:4;return(e<0?t!=l:t!=a)&&(s|=8),new le(n,s,t==(e<0?l:a)?null:o/3+(t-l)*se)}i+=h-u}return r?t+i:new le(t+i,0,null)}touches(t,e){let r=0,i=oe(e),n=this.inverted?2:1,s=this.inverted?1:2;for(let e=0;e<this.ranges.length;e+=3){let o=this.ranges[e]-(this.inverted?r:0);if(o>t)break;let l=this.ranges[e+n];if(t<=o+l&&e==3*i)return!0;r+=this.ranges[e+s]-l}return!1}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],o=s-(this.inverted?n:0),l=s+(this.inverted?0:n),u=this.ranges[i+e],h=this.ranges[i+r];t(o,o+u,l,l+h),n+=h-u}}invert(){return new ue(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(t){return 0==t?ue.empty:new ue(t<0?[0,-t,0]:[0,0,t])}}ue.empty=new ue([]);class he{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 he(this.maps,this.mirror,t,e)}copy(){return new he(this.maps.slice(),this.mirror&&this.mirror.slice(),this.from,this.to)}appendMap(t,e){this.to=this.maps.push(t),null!=e&&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],null!=i&&i<e?r+i:void 0)}}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){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(),null!=i&&i>e?r-i-1:void 0)}}invert(){let t=new he;return t.appendMappingInverted(this),t}map(t,e=1){if(this.mirror)return this._map(t,e,!0);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,!1)}_map(t,e,r){let i=0;for(let r=this.from;r<this.to;r++){let n=this.maps[r].mapResult(t,e);if(null!=n.recover){let e=this.getMirror(r);if(null!=e&&e>r&&e<this.to){r=e,t=this.maps[e].recover(n.recover);continue}}i|=n.delInfo,t=n.pos}return r?t:new le(t,i,null)}}const ae=Object.create(null);class fe{getMap(){return ue.empty}merge(t){return null}static fromJSON(t,e){if(!e||!e.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=ae[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 ae)throw new RangeError("Duplicate use of step JSON ID "+t);return ae[t]=e,e.prototype.jsonID=t,e}}class ce{constructor(t,e){this.doc=t,this.failed=e}static ok(t){return new ce(t,null)}static fail(t){return new ce(null,t)}static fromReplace(t,e,r,i){try{return ce.ok(t.replace(e,r,i))}catch(t){if(t instanceof nt)return ce.fail(t.message);throw t}}}function de(t,e,r){let i=[];for(let n=0;n<t.childCount;n++){let s=t.child(n);s.content.size&&(s=s.copy(de(s.content,e,s))),s.isInline&&(s=e(s,r,n)),i.push(s)}return Q.fromArray(i)}class pe extends fe{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),i=r.node(r.sharedDepth(this.to)),n=new st(de(e.content,((t,e)=>t.isAtom&&e.type.allowsMarkType(this.mark.type)?t.mark(this.mark.addToSet(t.marks)):t),i),e.openStart,e.openEnd);return ce.fromReplace(t,this.from,this.to,n)}invert(){return new me(this.from,this.to,this.mark)}map(t){let e=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return e.deleted&&r.deleted||e.pos>=r.pos?null:new pe(e.pos,r.pos,this.mark)}merge(t){return t instanceof pe&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new pe(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,e){if("number"!=typeof e.from||"number"!=typeof e.to)throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new pe(e.from,e.to,t.markFromJSON(e.mark))}}fe.jsonID("addMark",pe);class me extends fe{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=new st(de(e.content,(t=>t.mark(this.mark.removeFromSet(t.marks))),t),e.openStart,e.openEnd);return ce.fromReplace(t,this.from,this.to,r)}invert(){return new pe(this.from,this.to,this.mark)}map(t){let e=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return e.deleted&&r.deleted||e.pos>=r.pos?null:new me(e.pos,r.pos,this.mark)}merge(t){return t instanceof me&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new me(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,e){if("number"!=typeof e.from||"number"!=typeof e.to)throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new me(e.from,e.to,t.markFromJSON(e.mark))}}fe.jsonID("removeMark",me);class ge extends fe{constructor(t,e){super(),this.pos=t,this.mark=e}apply(t){let e=t.nodeAt(this.pos);if(!e)return ce.fail("No node at mark step's position");let r=e.type.create(e.attrs,null,this.mark.addToSet(e.marks));return ce.fromReplace(t,this.pos,this.pos+1,new st(Q.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 ge(this.pos,e.marks[r]);return new ge(this.pos,this.mark)}}return new be(this.pos,this.mark)}map(t){let e=t.mapResult(this.pos,1);return e.deletedAfter?null:new ge(e.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,e){if("number"!=typeof e.pos)throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new ge(e.pos,t.markFromJSON(e.mark))}}fe.jsonID("addNodeMark",ge);class be extends fe{constructor(t,e){super(),this.pos=t,this.mark=e}apply(t){let e=t.nodeAt(this.pos);if(!e)return ce.fail("No node at mark step's position");let r=e.type.create(e.attrs,null,this.mark.removeFromSet(e.marks));return ce.fromReplace(t,this.pos,this.pos+1,new st(Q.from(r),0,e.isLeaf?0:1))}invert(t){let e=t.nodeAt(this.pos);return e&&this.mark.isInSet(e.marks)?new ge(this.pos,this.mark):this}map(t){let e=t.mapResult(this.pos,1);return e.deletedAfter?null:new be(e.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,e){if("number"!=typeof e.pos)throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new be(e.pos,t.markFromJSON(e.mark))}}fe.jsonID("removeNodeMark",be);class we extends fe{constructor(t,e,r,i=!1){super(),this.from=t,this.to=e,this.slice=r,this.structure=i}apply(t){return this.structure&&ke(t,this.from,this.to)?ce.fail("Structure replace would overwrite content"):ce.fromReplace(t,this.from,this.to,this.slice)}getMap(){return new ue([this.from,this.to-this.from,this.slice.size])}invert(t){return new we(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);return e.deletedAcross&&r.deletedAcross?null:new we(e.pos,Math.max(e.pos,r.pos),this.slice)}merge(t){if(!(t instanceof we)||t.structure||this.structure)return null;if(this.from+this.slice.size!=t.from||this.slice.openEnd||t.slice.openStart){if(t.to!=this.from||this.slice.openStart||t.slice.openEnd)return null;{let e=this.slice.size+t.slice.size==0?st.empty:new st(t.slice.content.append(this.slice.content),t.slice.openStart,this.slice.openEnd);return new we(t.from,this.to,e,this.structure)}}{let e=this.slice.size+t.slice.size==0?st.empty:new st(this.slice.content.append(t.slice.content),this.slice.openStart,t.slice.openEnd);return new we(this.from,this.to+(t.to-t.from),e,this.structure)}}toJSON(){let t={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(t.slice=this.slice.toJSON()),this.structure&&(t.structure=!0),t}static fromJSON(t,e){if("number"!=typeof e.from||"number"!=typeof e.to)throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new we(e.from,e.to,st.fromJSON(t,e.slice),!!e.structure)}}fe.jsonID("replace",we);class ve extends fe{constructor(t,e,r,i,n,s,o=!1){super(),this.from=t,this.to=e,this.gapFrom=r,this.gapTo=i,this.slice=n,this.insert=s,this.structure=o}apply(t){if(this.structure&&(ke(t,this.from,this.gapFrom)||ke(t,this.gapTo,this.to)))return ce.fail("Structure gap-replace would overwrite content");let e=t.slice(this.gapFrom,this.gapTo);if(e.openStart||e.openEnd)return ce.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,e.content);return r?ce.fromReplace(t,this.from,this.to,r):ce.fail("Content does not fit in gap")}getMap(){return new ue([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 ve(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),i=this.from==this.gapFrom?e.pos:t.map(this.gapFrom,-1),n=this.to==this.gapTo?r.pos:t.map(this.gapTo,1);return e.deletedAcross&&r.deletedAcross||i<e.pos||n>r.pos?null:new ve(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};return this.slice.size&&(t.slice=this.slice.toJSON()),this.structure&&(t.structure=!0),t}static fromJSON(t,e){if("number"!=typeof e.from||"number"!=typeof e.to||"number"!=typeof e.gapFrom||"number"!=typeof e.gapTo||"number"!=typeof e.insert)throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new ve(e.from,e.to,e.gapFrom,e.gapTo,st.fromJSON(t,e.slice),e.insert,!!e.structure)}}function ke(t,e,r){let i=t.resolve(e),n=r-e,s=i.depth;for(;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));for(;n>0;){if(!t||t.isLeaf)return!0;t=t.firstChild,n--}}return!1}function De(t,e,r,i=r.contentMatch,n=!0){let s=t.doc.nodeAt(e),o=[],l=e+1;for(let e=0;e<s.childCount;e++){let u=s.child(e),h=l+u.nodeSize,a=i.matchType(u.type);if(a){i=a;for(let e=0;e<u.marks.length;e++)r.allowsMarkType(u.marks[e].type)||t.step(new me(l,h,u.marks[e]));if(n&&u.isText&&"pre"!=r.whitespace){let t,e,i=/\r?\n|\r/g;for(;t=i.exec(u.text);)e||(e=new st(Q.from(r.schema.text(" ",r.allowedMarks(u.marks))),0,0)),o.push(new we(l+t.index,l+t.index+t[0].length,e))}}else o.push(new we(l,h,st.empty));l=h}if(!i.validEnd){let e=i.fillBefore(Q.empty,!0);t.replace(l,l,new st(e,0,0))}for(let e=o.length-1;e>=0;e--)t.step(o[e])}function ye(t,e,r){return(0==e||t.canReplace(e,t.childCount))&&(r==t.childCount||t.canReplace(0,r))}function Ee(t){let e=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let r=t.depth;;--r){let i=t.$from.node(r),n=t.$from.index(r),s=t.$to.indexAfter(r);if(r<t.depth&&i.canReplace(n,s,e))return r;if(0==r||i.type.spec.isolating||!ye(i,n,s))break}return null}function xe(t,e,r=null,i=t){let n=function(t,e){let{parent:r,startIndex:i,endIndex:n}=t,s=r.contentMatchAt(i).findWrapping(e);return s&&r.canReplaceWith(i,n,s.length?s[0]:e)?s:null}(t,e),s=n&&function(t,e){let{parent:r,startIndex:i,endIndex:n}=t,s=r.child(i),o=e.contentMatch.findWrapping(s.type);if(!o)return null;let l=(o.length?o[o.length-1]:e).contentMatch;for(let t=i;l&&t<n;t++)l=l.matchType(r.child(t).type);return l&&l.validEnd?o:null}(i,e);return s?n.map(Fe).concat({type:e,attrs:r}).concat(s.map(Fe)):null}function Fe(t){return{type:t,attrs:null}}function Me(t,e,r,i){e.forEach(((n,s)=>{if(n.isText){let o,l=/\r?\n|\r/g;for(;o=l.exec(n.text);){let n=t.mapping.slice(i).map(r+1+s+o.index);t.replaceWith(n,n+1,e.type.schema.linebreakReplacement.create())}}}))}function Ae(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 Ce(t,e,r=1,i){let n=t.resolve(e),s=n.depth-r,o=i&&i[i.length-1]||n.parent;if(s<0||n.parent.type.spec.isolating||!n.parent.canReplace(n.index(),n.parent.childCount)||!o.type.validContent(n.parent.content.cutByIndex(n.index(),n.parent.childCount)))return!1;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!1;let o=r.content.cutByIndex(s,r.childCount),l=i&&i[e+1];l&&(o=o.replaceChild(0,l.type.create(l.attrs)));let u=i&&i[e]||r;if(!r.canReplace(s+1,r.childCount)||!u.type.validContent(o))return!1}let l=n.indexAfter(s),u=i&&i[0];return n.node(s).canReplaceWith(l,l,u?u.type:n.node(s+1).type)}function Se(t,e){let r=t.resolve(e),i=r.index();return Oe(r.nodeBefore,r.nodeAfter)&&r.parent.canReplace(i,i+1)}function Oe(t,e){return!(!t||!e||t.isLeaf||!function(t,e){e.content.size||t.type.compatibleContent(e.type);let r=t.contentMatchAt(t.childCount),{linebreakReplacement:i}=t.type.schema;for(let n=0;n<e.childCount;n++){let s=e.child(n);if(r=r.matchType(s.type==i?t.type.schema.nodes.text:s.type),!r)return!1;if(!t.type.allowsMarks(s.marks))return!1}return r.validEnd}(t,e))}function $e(t,e,r=-1){let i=t.resolve(e);for(let t=i.depth;;t--){let n,s,o=i.index(t);if(t==i.depth?(n=i.nodeBefore,s=i.nodeAfter):r>0?(n=i.node(t+1),o++,s=i.node(t).maybeChild(o)):(n=i.node(t).maybeChild(o-1),s=i.node(t+1)),n&&!n.isTextblock&&Oe(n,s)&&i.node(t).canReplace(o,o+1))return e;if(0==t)break;e=r<0?i.before(t):i.after(t)}}function Be(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<=(0==r.openStart&&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,s=i.index(e)+(r>0?1:0),o=i.node(e),l=!1;if(1==t)l=o.canReplace(s,s,n);else{let t=o.contentMatchAt(s).findWrapping(n.firstChild.type);l=t&&o.canReplaceWith(s,s,t[0])}if(l)return 0==r?i.pos:r<0?i.before(e+1):i.after(e+1)}return null}function Re(t,e,r=e,i=st.empty){if(e==r&&!i.size)return null;let n=t.resolve(e),s=t.resolve(r);return Ne(n,s,i)?new we(e,r,i):new _e(n,s,i).fit()}function Ne(t,e,r){return!r.openStart&&!r.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),r.content)}fe.jsonID("replaceAround",ve);class _e{constructor(t,e,r){this.$from=t,this.$to=e,this.unplaced=r,this.frontier=[],this.placed=Q.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=Q.from(t.node(e).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let t=this.findFittable();t?this.placeNodes(t):this.openMore()||this.dropNode()}let t=this.mustMoveInline(),e=this.placed.size-this.depth-this.$from.depth,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,o=i.depth;for(;s&&o&&1==n.childCount;)n=n.firstChild.content,s--,o--;let l=new st(n,s,o);return t>-1?new ve(r.pos,t,this.$to.pos,this.$to.end(),l,e):l.size||r.pos!=this.$to.pos?new we(r.pos,i.pos,l):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),n.type.spec.isolating&&i<=r){t=r;break}e=n.content}for(let e=1;e<=2;e++)for(let r=1==e?t:this.unplaced.openStart;r>=0;r--){let t,i=null;r?(i=je(this.unplaced.content,r-1).firstChild,t=i.content):t=this.unplaced.content;let n=t.firstChild;for(let t=this.depth;t>=0;t--){let s,{type:o,match:l}=this.frontier[t],u=null;if(1==e&&(n?l.matchType(n.type)||(u=l.fillBefore(Q.from(n),!1)):i&&o.compatibleContent(i.type)))return{sliceDepth:r,frontierDepth:t,parent:i,inject:u};if(2==e&&n&&(s=l.findWrapping(n.type)))return{sliceDepth:r,frontierDepth:t,parent:i,wrap:s};if(i&&l.matchType(i.type))break}}}openMore(){let{content:t,openStart:e,openEnd:r}=this.unplaced,i=je(t,e);return!(!i.childCount||i.firstChild.isLeaf||(this.unplaced=new st(t,e+1,Math.max(r,i.size+e>=t.size-r?e+1:0)),0))}dropNode(){let{content:t,openStart:e,openEnd:r}=this.unplaced,i=je(t,e);if(i.childCount<=1&&e>0){let n=t.size-e<=e+i.size;this.unplaced=new st(Te(t,e-1,1),e-1,n?e-1:r)}else this.unplaced=new st(Te(t,e,1),e,r)}placeNodes({sliceDepth:t,frontierDepth:e,parent:r,inject:i,wrap:n}){for(;this.depth>e;)this.closeFrontierNode();if(n)for(let t=0;t<n.length;t++)this.openFrontierNode(n[t]);let s=this.unplaced,o=r?r.content:s.content,l=s.openStart-t,u=0,h=[],{match:a,type:f}=this.frontier[e];if(i){for(let t=0;t<i.childCount;t++)h.push(i.child(t));a=a.matchFragment(i)}let c=o.size+t-(s.content.size-s.openEnd);for(;u<o.childCount;){let t=o.child(u),e=a.matchType(t.type);if(!e)break;u++,(u>1||0==l||t.content.size)&&(a=e,h.push(qe(t.mark(f.allowedMarks(t.marks)),1==u?l:0,u==o.childCount?c:-1)))}let d=u==o.childCount;d||(c=-1),this.placed=ze(this.placed,e,Q.from(h)),this.frontier[e].match=a,d&&c<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let t=0,e=o;t<c;t++){let t=e.lastChild;this.frontier.push({type:t.type,match:t.contentMatchAt(t.childCount)}),e=t.content}this.unplaced=d?0==t?st.empty:new st(Te(s.content,t-1,1),t-1,c<0?s.openEnd:t-1):new st(Te(s.content,t,u),s.openStart,s.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let t,e=this.frontier[this.depth];if(!e.type.isTextblock||!Ie(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(t=this.findCloseLevel(this.$to))&&t.depth==this.depth)return-1;let{depth:r}=this.$to,i=this.$to.after(r);for(;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],n=e<t.depth&&t.end(e+1)==t.pos+(t.depth-(e+1)),s=Ie(t,e,i,r,n);if(s){for(let r=e-1;r>=0;r--){let{match:e,type:i}=this.frontier[r],n=Ie(t,r,i,e,!0);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;for(;this.depth>e.depth;)this.closeFrontierNode();e.fit.childCount&&(this.placed=ze(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,!0,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=ze(this.placed,this.depth,Q.from(t.create(e,r))),this.frontier.push({type:t,match:t.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(Q.empty,!0);t.childCount&&(this.placed=ze(this.placed,this.frontier.length,t))}}function Te(t,e,r){return 0==e?t.cutByIndex(r,t.childCount):t.replaceChild(0,t.firstChild.copy(Te(t.firstChild.content,e-1,r)))}function ze(t,e,r){return 0==e?t.append(r):t.replaceChild(t.childCount-1,t.lastChild.copy(ze(t.lastChild.content,e-1,r)))}function je(t,e){for(let r=0;r<e;r++)t=t.firstChild.content;return t}function qe(t,e,r){if(e<=0)return t;let i=t.content;return e>1&&(i=i.replaceChild(0,qe(i.firstChild,e-1,1==i.childCount?r-1:0))),e>0&&(i=t.type.contentMatch.fillBefore(i).append(i),r<=0&&(i=i.append(t.type.contentMatch.matchFragment(i).fillBefore(Q.empty,!0)))),t.copy(i)}function Ie(t,e,r,i,n){let s=t.node(e),o=n?t.indexAfter(e):t.index(e);if(o==s.childCount&&!r.compatibleContent(s.type))return null;let l=i.fillBefore(s.content,!0,o);return l&&!function(t,e,r){for(let i=r;i<e.childCount;i++)if(!t.allowsMarks(e.child(i).marks))return!0;return!1}(r,s.content,o)?l:null}function Pe(t,e,r,i,n){if(e<r){let n=t.firstChild;t=t.replaceChild(0,n.copy(Pe(n.content,e+1,r,i,n)))}if(e>i){let e=n.contentMatchAt(0),r=e.fillBefore(t).append(t);t=r.append(e.matchFragment(r).fillBefore(Q.empty,!0))}return t}function Le(t,e){let r=[];for(let i=Math.min(t.depth,e.depth);i>=0;i--){let n=t.start(i);if(n<t.pos-(t.depth-i)||e.end(i)>e.pos+(e.depth-i)||t.node(i).type.spec.isolating||e.node(i).type.spec.isolating)break;(n==e.start(i)||i==t.depth&&i==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&i&&e.start(i-1)==n-1)&&r.push(i)}return r}class Je extends fe{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 ce.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 ce.fromReplace(t,this.pos,this.pos+1,new st(Q.from(i),0,e.isLeaf?0:1))}getMap(){return ue.empty}invert(t){return new Je(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 Je(e.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(t,e){if("number"!=typeof e.pos||"string"!=typeof e.attr)throw new RangeError("Invalid input for AttrStep.fromJSON");return new Je(e.pos,e.attr,e.value)}}fe.jsonID("attr",Je);class Ue extends fe{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 ce.ok(r)}getMap(){return ue.empty}invert(t){return new Ue(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("string"!=typeof e.attr)throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new Ue(e.attr,e.value)}}fe.jsonID("docAttr",Ue);let Ve=class extends Error{};Ve=function t(e){let r=Error.call(this,e);return r.__proto__=t.prototype,r},(Ve.prototype=Object.create(Error.prototype)).constructor=Ve,Ve.prototype.name="TransformError";class He{constructor(t){this.doc=t,this.steps=[],this.docs=[],this.mapping=new he}get before(){return this.docs.length?this.docs[0]:this.doc}step(t){let e=this.maybeStep(t);if(e.failed)throw new Ve(e.failed);return this}maybeStep(t){let e=t.apply(this.doc);return e.failed||this.addStep(t,e.doc),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=st.empty){let i=Re(this.doc,t,e,r);return i&&this.step(i),this}replaceWith(t,e,r){return this.replace(t,e,new st(Q.from(r),0,0))}delete(t,e){return this.replace(t,e,st.empty)}insert(t,e){return this.replaceWith(t,t,e)}replaceRange(t,e,r){return function(t,e,r,i){if(!i.size)return t.deleteRange(e,r);let n=t.doc.resolve(e),s=t.doc.resolve(r);if(Ne(n,s,i))return t.step(new we(e,r,i));let o=Le(n,t.doc.resolve(r));0==o[o.length-1]&&o.pop();let l=-(n.depth+1);o.unshift(l);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;o.indexOf(t)>-1?l=t:n.before(t)==e&&o.splice(1,0,-t)}let u=o.indexOf(l),h=[],a=i.openStart;for(let t=i.content,e=0;;e++){let r=t.firstChild;if(h.push(r),e==i.openStart)break;t=r.content}for(let t=a-1;t>=0;t--){let e=h[t],r=(f=e.type).spec.defining||f.spec.definingForContent;if(r&&!e.sameMarkup(n.node(Math.abs(l)-1)))a=t;else if(r||!e.type.isTextblock)break}var f;for(let e=i.openStart;e>=0;e--){let l=(e+a+1)%(i.openStart+1),f=h[l];if(f)for(let e=0;e<o.length;e++){let h=o[(e+u)%o.length],a=!0;h<0&&(a=!1,h=-h);let c=n.node(h-1),d=n.index(h-1);if(c.canReplaceWith(d,d,f.type,f.marks))return t.replace(n.before(h),a?s.after(h):r,new st(Pe(i.content,0,i.openStart,l),l,i.openEnd))}}let c=t.steps.length;for(let l=o.length-1;l>=0&&(t.replace(e,r,i),!(t.steps.length>c));l--){let t=o[l];t<0||(e=n.before(t),r=s.after(t))}}(this,t,e,r),this}replaceRangeWith(t,e,r){return function(t,e,r,i){if(!i.isInline&&e==r&&t.doc.resolve(e).parent.content.size){let n=function(t,e,r){let i=t.resolve(e);if(i.parent.canReplaceWith(i.index(),i.index(),r))return e;if(0==i.parentOffset)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}(t.doc,e,i.type);null!=n&&(e=r=n)}t.replaceRange(e,r,new st(Q.from(i),0,0))}(this,t,e,r),this}deleteRange(t,e){return function(t,e,r){let i=t.doc.resolve(e),n=t.doc.resolve(r),s=Le(i,n);for(let e=0;e<s.length;e++){let r=s[e],o=e==s.length-1;if(o&&0==r||i.node(r).type.contentMatch.validEnd)return t.delete(i.start(r),n.end(r));if(r>0&&(o||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)}(this,t,e),this}lift(t,e){return function(t,e,r){let{$from:i,$to:n,depth:s}=e,o=i.before(s+1),l=n.after(s+1),u=o,h=l,a=Q.empty,f=0;for(let t=s,e=!1;t>r;t--)e||i.index(t)>0?(e=!0,a=Q.from(i.node(t).copy(a)),f++):u--;let c=Q.empty,d=0;for(let t=s,e=!1;t>r;t--)e||n.after(t+1)<n.end(t)?(e=!0,c=Q.from(n.node(t).copy(c)),d++):h++;t.step(new ve(u,h,o,l,new st(a.append(c),f,d),a.size-f,!0))}(this,t,e),this}join(t,e=1){return function(t,e,r){let i=null,{linebreakReplacement:n}=t.doc.type.schema,s=t.doc.resolve(e-r),o=s.node().type;if(n&&o.inlineContent){let t="pre"==o.whitespace,e=!!o.contentMatch.matchType(n);t&&!e?i=!1:!t&&e&&(i=!0)}let l=t.steps.length;if(!1===i){let i=t.doc.resolve(e+r);Ae(t,i.node(),i.before(),l)}o.inlineContent&&De(t,e+r-1,o,s.node().contentMatchAt(s.index()),null==i);let u=t.mapping.slice(l),h=u.map(e-r);if(t.step(new we(h,u.map(e+r,-1),st.empty,!0)),!0===i){let e=t.doc.resolve(h);Me(t,e.node(),e.before(),t.steps.length)}}(this,t,e),this}wrap(t,e){return function(t,e,r){let i=Q.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=Q.from(r[t].type.create(r[t].attrs,i))}let n=e.start,s=e.end;t.step(new ve(n,s,n,s,new st(i,0,0),r.length,!0))}(this,t,e),this}setBlockType(t,e=t,r,i=null){return function(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 o="function"==typeof n?n(e):n;if(e.isTextblock&&!e.hasMarkup(i,o)&&function(t,e,r){let i=t.resolve(e),n=i.index();return i.parent.canReplaceWith(n,n+1,r)}(t.doc,t.mapping.slice(s).map(r),i)){let n=null;if(i.schema.linebreakReplacement){let t="pre"==i.whitespace,e=!!i.contentMatch.matchType(i.schema.linebreakReplacement);t&&!e?n=!1:!t&&e&&(n=!0)}!1===n&&Ae(t,e,r,s),De(t,t.mapping.slice(s).map(r,1),i,void 0,null===n);let l=t.mapping.slice(s),u=l.map(r,1),h=l.map(r+e.nodeSize,1);return t.step(new ve(u,h,u+1,h-1,new st(Q.from(i.create(o,null,e.marks)),0,0),1,!0)),!0===n&&Me(t,e,r,s),!1}}))}(this,t,e,r,i),this}setNodeMarkup(t,e,r=null,i){return function(t,e,r,i,n){let s=t.doc.nodeAt(e);if(!s)throw new RangeError("No node at given position");r||(r=s.type);let o=r.create(i,null,n||s.marks);if(s.isLeaf)return t.replaceWith(e,e+s.nodeSize,o);if(!r.validContent(s.content))throw new RangeError("Invalid content for node type "+r.name);t.step(new ve(e,e+s.nodeSize,e+1,e+s.nodeSize-1,new st(Q.from(o),0,0),1,!0))}(this,t,e,r,i),this}setNodeAttribute(t,e,r){return this.step(new Je(t,e,r)),this}setDocAttribute(t,e){return this.step(new Ue(t,e)),this}addNodeMark(t,e){return this.step(new ge(t,e)),this}removeNodeMark(t,e){if(!(e instanceof it)){let r=this.doc.nodeAt(t);if(!r)throw new RangeError("No node at position "+t);if(!(e=e.isInSet(r.marks)))return this}return this.step(new be(t,e)),this}split(t,e=1,r){return function(t,e,r=1,i){let n=t.doc.resolve(e),s=Q.empty,o=Q.empty;for(let t=n.depth,e=n.depth-r,l=r-1;t>e;t--,l--){s=Q.from(n.node(t).copy(s));let e=i&&i[l];o=Q.from(e?e.type.create(e.attrs,o):n.node(t).copy(o))}t.step(new we(e,e,new st(s.append(o),r,r),!0))}(this,t,e,r),this}addMark(t,e,r){return function(t,e,r,i){let n,s,o=[],l=[];t.doc.nodesBetween(e,r,((t,u,h)=>{if(!t.isInline)return;let a=t.marks;if(!i.isInSet(a)&&h.type.allowsMarkType(i.type)){let h=Math.max(u,e),f=Math.min(u+t.nodeSize,r),c=i.addToSet(a);for(let t=0;t<a.length;t++)a[t].isInSet(c)||(n&&n.to==h&&n.mark.eq(a[t])?n.to=f:o.push(n=new me(h,f,a[t])));s&&s.to==h?s.to=f:l.push(s=new pe(h,f,i))}})),o.forEach((e=>t.step(e))),l.forEach((e=>t.step(e)))}(this,t,e,r),this}removeMark(t,e,r){return function(t,e,r,i){let n=[],s=0;t.doc.nodesBetween(e,r,((t,o)=>{if(!t.isInline)return;s++;let l=null;if(i instanceof Pt){let e,r=t.marks;for(;e=i.isInSet(r);)(l||(l=[])).push(e),r=e.removeFromSet(r)}else i?i.isInSet(t.marks)&&(l=[i]):l=t.marks;if(l&&l.length){let i=Math.min(o+t.nodeSize,r);for(let t=0;t<l.length;t++){let r,u=l[t];for(let t=0;t<n.length;t++){let e=n[t];e.step==s-1&&u.eq(n[t].style)&&(r=e)}r?(r.to=i,r.step=s):n.push({style:u,from:Math.max(o,e),to:i,step:s})}}})),n.forEach((e=>t.step(new me(e.from,e.to,e.style))))}(this,t,e,r),this}clearIncompatible(t,e,r){return De(this,t,e,r),this}}const We=Object.create(null);class Ge{constructor(t,e,r){this.$anchor=t,this.$head=e,this.ranges=r||[new Ze(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!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(t,e=st.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 o=0;o<s.length;o++){let{$from:l,$to:u}=s[o],h=t.mapping.slice(n);t.replaceRange(h.map(l.pos),h.map(u.pos),o?st.empty:e),0==o&&sr(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:o}=i[n],l=t.mapping.slice(r),u=l.map(s.pos),h=l.map(o.pos);n?t.deleteRange(u,h):(t.replaceRangeWith(u,h,e),sr(t,r,e.isInline?-1:1))}}static findFrom(t,e,r=!1){let i=t.parent.inlineContent?new Xe(t):nr(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?nr(t.node(0),t.node(i),t.before(i+1),t.index(i),e,r):nr(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 rr(t.node(0))}static atStart(t){return nr(t,t,0,0,1)||new rr(t)}static atEnd(t){return nr(t,t,t.content.size,t.childCount,-1)||new rr(t)}static fromJSON(t,e){if(!e||!e.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=We[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 We)throw new RangeError("Duplicate use of selection JSON ID "+t);return We[t]=e,e.prototype.jsonID=t,e}getBookmark(){return Xe.between(this.$anchor,this.$head).getBookmark()}}Ge.prototype.visible=!0;class Ze{constructor(t,e){this.$from=t,this.$to=e}}let Ke=!1;function Ye(t){Ke||t.parent.inlineContent||(Ke=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class Xe extends Ge{constructor(t,e=t){Ye(t),Ye(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 Ge.near(r);let i=t.resolve(e.map(this.anchor));return new Xe(i.parent.inlineContent?i:r,r)}replace(t,e=st.empty){if(super.replace(t,e),e==st.empty){let e=this.$from.marksAcross(this.$to);e&&t.ensureMarks(e)}}eq(t){return t instanceof Xe&&t.anchor==this.anchor&&t.head==this.head}getBookmark(){return new Qe(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(t,e){if("number"!=typeof e.anchor||"number"!=typeof e.head)throw new RangeError("Invalid input for TextSelection.fromJSON");return new Xe(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),!e.parent.inlineContent){let t=Ge.findFrom(e,r,!0)||Ge.findFrom(e,-r,!0);if(!t)return Ge.near(e,r);e=t.$head}return t.parent.inlineContent||(0==i||(t=(Ge.findFrom(t,-r,!0)||Ge.findFrom(t,r,!0)).$anchor).pos<e.pos!=i<0)&&(t=e),new Xe(t,e)}}Ge.jsonID("text",Xe);class Qe{constructor(t,e){this.anchor=t,this.head=e}map(t){return new Qe(t.map(this.anchor),t.map(this.head))}resolve(t){return Xe.between(t.resolve(this.anchor),t.resolve(this.head))}}class tr extends Ge{constructor(t){let e=t.nodeAfter,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),n=t.resolve(i);return r?Ge.near(n):new tr(n)}content(){return new st(Q.from(this.node),0,0)}eq(t){return t instanceof tr&&t.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new er(this.anchor)}static fromJSON(t,e){if("number"!=typeof e.anchor)throw new RangeError("Invalid input for NodeSelection.fromJSON");return new tr(t.resolve(e.anchor))}static create(t,e){return new tr(t.resolve(e))}static isSelectable(t){return!t.isText&&!1!==t.type.spec.selectable}}tr.prototype.visible=!1,Ge.jsonID("node",tr);class er{constructor(t){this.anchor=t}map(t){let{deleted:e,pos:r}=t.mapResult(this.anchor);return e?new Qe(r,r):new er(r)}resolve(t){let e=t.resolve(this.anchor),r=e.nodeAfter;return r&&tr.isSelectable(r)?new tr(e):Ge.near(e)}}class rr extends Ge{constructor(t){super(t.resolve(0),t.resolve(t.content.size))}replace(t,e=st.empty){if(e==st.empty){t.delete(0,t.doc.content.size);let e=Ge.atStart(t.doc);e.eq(t.selection)||t.setSelection(e)}else super.replace(t,e)}toJSON(){return{type:"all"}}static fromJSON(t){return new rr(t)}map(t){return new rr(t)}eq(t){return t instanceof rr}getBookmark(){return ir}}Ge.jsonID("all",rr);const ir={map(){return this},resolve:t=>new rr(t)};function nr(t,e,r,i,n,s=!1){if(e.inlineContent)return Xe.create(t,r);for(let o=i-(n>0?0:1);n>0?o<e.childCount:o>=0;o+=n){let i=e.child(o);if(i.isAtom){if(!s&&tr.isSelectable(i))return tr.create(t,r-(n<0?i.nodeSize:0))}else{let e=nr(t,i,r+n,n<0?i.childCount:0,n,s);if(e)return e}r+=i.nodeSize*n}return null}function sr(t,e,r){let i=t.steps.length-1;if(i<e)return;let n,s=t.steps[i];(s instanceof we||s instanceof ve)&&(t.mapping.maps[i].forEach(((t,e,r,i)=>{null==n&&(n=i)})),t.setSelection(Ge.near(t.doc.resolve(n),r)))}class or extends He{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(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(t){if(t.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=t,this.curSelectionFor=this.steps.length,this.updated=-3&this.updated|1,this.storedMarks=null,this}get selectionSet(){return(1&this.updated)>0}setStoredMarks(t){return this.storedMarks=t,this.updated|=2,this}ensureMarks(t){return it.sameSet(this.storedMarks||this.selection.$from.marks(),t)||this.setStoredMarks(t),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(2&this.updated)>0}addStep(t,e){super.addStep(t,e),this.updated=-3&this.updated,this.storedMarks=null}setTime(t){return this.time=t,this}replaceSelection(t){return this.selection.replace(this,t),this}replaceSelectionWith(t,e=!0){let r=this.selection;return e&&(t=t.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||it.none))),r.replaceWith(this,t),this}deleteSelection(){return this.selection.replace(this),this}insertText(t,e,r){let i=this.doc.type.schema;if(null==e)return t?this.replaceSelectionWith(i.text(t),!0):this.deleteSelection();{if(null==r&&(r=e),r=null==r?e:r,!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))}return this.replaceRangeWith(e,r,i.text(t,n)),this.selection.empty||this.setSelection(Ge.near(this.selection.$to)),this}}setMeta(t,e){return this.meta["string"==typeof t?t:t.key]=e,this}getMeta(t){return this.meta["string"==typeof t?t:t.key]}get isGeneric(){for(let t in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=4,this}get scrolledIntoView(){return(4&this.updated)>0}}function lr(t,e){return e&&t?t.bind(e):t}class ur{constructor(t,e,r){this.name=t,this.init=lr(e.init,r),this.apply=lr(e.apply,r)}}const hr=[new ur("doc",{init:t=>t.doc||t.schema.topNodeType.createAndFill(),apply:t=>t.doc}),new ur("selection",{init:(t,e)=>t.selection||Ge.atStart(e.doc),apply:t=>t.selection}),new ur("storedMarks",{init:t=>t.storedMarks||null,apply:(t,e,r,i)=>i.selection.$cursor?t.storedMarks:null}),new ur("scrollToSelection",{init:()=>0,apply:(t,e)=>t.scrolledIntoView?e+1:e})];class ar{constructor(t,e){this.schema=t,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=hr.slice(),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,t.spec.state&&this.fields.push(new ur(t.key,t.spec.state,t))}))}}class fr{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!1}return!0}applyTransaction(t){if(!this.filterTransaction(t))return{state:this,transactions:[]};let e=[t],r=this.applyInner(t),i=null;for(;;){let n=!1;for(let s=0;s<this.config.plugins.length;s++){let o=this.config.plugins[s];if(o.spec.appendTransaction){let l=i?i[s].n:0,u=i?i[s].state:this,h=l<e.length&&o.spec.appendTransaction.call(o,l?e.slice(l):e,u,r);if(h&&r.filterTransaction(h,s)){if(h.setMeta("appendedTransaction",t),!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(h),r=r.applyInner(h),n=!0}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 fr(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 or(this)}static create(t){let e=new ar(t.doc?t.doc.type.schema:t.schema,t.plugins),r=new fr(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 ar(this.schema,t.plugins),r=e.fields,i=new fr(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()))),t&&"object"==typeof t)for(let r in t){if("doc"==r||"selection"==r)throw new RangeError("The JSON fields `doc` and `selection` are reserved");let i=t[r],n=i.spec.state;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 ar(t.schema,t.plugins),n=new fr(i);return i.fields.forEach((i=>{if("doc"==i.name)n.doc=Et.fromJSON(t.schema,e.doc);else if("selection"==i.name)n.selection=Ge.fromJSON(n.doc,e.selection);else if("storedMarks"==i.name)e.storedMarks&&(n.storedMarks=e.storedMarks.map(t.schema.markFromJSON));else{if(r)for(let s in r){let o=r[s],l=o.spec.state;if(o.key==i.name&&l&&l.fromJSON&&Object.prototype.hasOwnProperty.call(e,s))return void(n[i.name]=l.fromJSON.call(o,t,e[s],n))}n[i.name]=i.init(t,n)}})),n}}function cr(t,e,r){for(let i in t){let n=t[i];n instanceof Function?n=n.bind(e):"handleDOMEvents"==i&&(n=cr(n,e,{})),r[i]=n}return r}class dr{constructor(t){this.spec=t,this.props={},t.props&&cr(t.props,this,this.props),this.key=t.key?t.key.key:mr("plugin")}getState(t){return t[this.key]}}const pr=Object.create(null);function mr(t){return t in pr?t+"$"+ ++pr[t]:(pr[t]=0,t+"$")}class gr{constructor(t="key"){this.key=mr(t)}get(t){return t.config.pluginsByKey[this.key]}getState(t){return t[this.key]}}const br=function(t){for(var e=0;;e++)if(!(t=t.previousSibling))return e},wr=function(t){let e=t.assignedSlot||t.parentNode;return e&&11==e.nodeType?e.host:e};let vr=null;const kr=function(t,e,r){let i=vr||(vr=document.createRange());return i.setEnd(t,null==r?t.nodeValue.length:r),i.setStart(t,e||0),i},Dr=function(t,e,r,i){return r&&(Er(t,e,r,i,-1)||Er(t,e,r,i,1))},yr=/^(img|br|input|textarea|hr)$/i;function Er(t,e,r,i,n){for(;;){if(t==r&&e==i)return!0;if(e==(n<0?0:xr(t))){let r=t.parentNode;if(!r||1!=r.nodeType||Fr(t)||yr.test(t.nodeName)||"false"==t.contentEditable)return!1;e=br(t)+(n<0?0:1),t=r}else{if(1!=t.nodeType)return!1;if("false"==(t=t.childNodes[e+(n<0?-1:0)]).contentEditable)return!1;e=n<0?xr(t):0}}}function xr(t){return 3==t.nodeType?t.nodeValue.length:t.childNodes.length}function Fr(t){let e;for(let r=t;r&&!(e=r.pmViewDesc);r=r.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==t||e.contentDOM==t)}const Mr=function(t){return t.focusNode&&Dr(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function Ar(t,e){let r=document.createEvent("Event");return r.initEvent("keydown",!0,!0),r.keyCode=t,r.key=r.code=e,r}const Cr="undefined"!=typeof navigator?navigator:null,Sr="undefined"!=typeof document?document:null,Or=Cr&&Cr.userAgent||"",$r=/Edge\/(\d+)/.exec(Or),Br=/MSIE \d/.exec(Or),Rr=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Or),Nr=!!(Br||Rr||$r),_r=Br?document.documentMode:Rr?+Rr[1]:$r?+$r[1]:0,Tr=!Nr&&/gecko\/(\d+)/i.test(Or),zr=!Nr&&/Chrome\/(\d+)/.exec(Or),jr=!!zr,qr=zr?+zr[1]:0,Ir=!Nr&&!!Cr&&/Apple Computer/.test(Cr.vendor),Pr=Ir&&(/Mobile\/\w+/.test(Or)||!!Cr&&Cr.maxTouchPoints>2),Lr=Pr||!!Cr&&/Mac/.test(Cr.platform),Jr=!!Cr&&/Win/.test(Cr.platform),Ur=/Android \d/.test(Or),Vr=!!Sr&&"webkitFontSmoothing"in Sr.documentElement.style,Hr=Vr?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Wr(t){let e=t.defaultView&&t.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.documentElement.clientWidth,top:0,bottom:t.documentElement.clientHeight}}function Gr(t,e){return"number"==typeof t?t:t[e]}function Zr(t){let e=t.getBoundingClientRect();return{left:e.left,right:e.left+t.clientWidth*(e.width/t.offsetWidth||1),top:e.top,bottom:e.top+t.clientHeight*(e.height/t.offsetHeight||1)}}function Kr(t,e,r){let i=t.someProp("scrollThreshold")||0,n=t.someProp("scrollMargin")||5,s=t.dom.ownerDocument;for(let o=r||t.dom;o;o=wr(o)){if(1!=o.nodeType)continue;let t=o,r=t==s.body,l=r?Wr(s):Zr(t),u=0,h=0;if(e.top<l.top+Gr(i,"top")?h=-(l.top-e.top+Gr(n,"top")):e.bottom>l.bottom-Gr(i,"bottom")&&(h=e.bottom-e.top>l.bottom-l.top?e.top+Gr(n,"top")-l.top:e.bottom-l.bottom+Gr(n,"bottom")),e.left<l.left+Gr(i,"left")?u=-(l.left-e.left+Gr(n,"left")):e.right>l.right-Gr(i,"right")&&(u=e.right-l.right+Gr(n,"right")),u||h)if(r)s.defaultView.scrollBy(u,h);else{let r=t.scrollLeft,i=t.scrollTop;h&&(t.scrollTop+=h),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(o).position))break}}function Yr(t){let e=[],r=t.ownerDocument;for(let i=t;i&&(e.push({dom:i,top:i.scrollTop,left:i.scrollLeft}),t!=r);i=wr(i));return e}function Xr(t,e){for(let r=0;r<t.length;r++){let{dom:i,top:n,left:s}=t[r];i.scrollTop!=n+e&&(i.scrollTop=n+e),i.scrollLeft!=s&&(i.scrollLeft=s)}}let Qr=null;function ti(t,e){let r,i,n,s,o=2e8,l=0,u=e.top,h=e.top;for(let a=t.firstChild,f=0;a;a=a.nextSibling,f++){let t;if(1==a.nodeType)t=a.getClientRects();else{if(3!=a.nodeType)continue;t=kr(a).getClientRects()}for(let c=0;c<t.length;c++){let d=t[c];if(d.top<=u&&d.bottom>=h){u=Math.max(d.bottom,u),h=Math.min(d.top,h);let t=d.left>e.left?d.left-e.left:d.right<e.left?e.left-d.right:0;if(t<o){r=a,o=t,i=t&&3==r.nodeType?{left:d.right<e.left?d.right:d.left,top:e.top}:e,1==a.nodeType&&t&&(l=f+(e.left>=(d.left+d.right)/2?1:0));continue}}else d.top>e.top&&!n&&d.left<=e.left&&d.right>=e.left&&(n=a,s={left:Math.max(d.left,Math.min(d.right,e.left)),top:d.top});!r&&(e.left>=d.right&&e.top>=d.top||e.left>=d.left&&e.top>=d.bottom)&&(l=f+1)}}return!r&&n&&(r=n,i=s,o=0),r&&3==r.nodeType?function(t,e){let r=t.nodeValue.length,i=document.createRange();for(let n=0;n<r;n++){i.setEnd(t,n+1),i.setStart(t,n);let r=si(i,1);if(r.top!=r.bottom&&ei(e,r))return{node:t,offset:n+(e.left>=(r.left+r.right)/2?1:0)}}return{node:t,offset:0}}(r,i):!r||o&&1==r.nodeType?{node:t,offset:l}:ti(r,i)}function ei(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function ri(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(1==r.nodeType){let t=r.getClientRects();for(let i=0;i<t.length;i++){let n=t[i];if(ei(e,n))return ri(r,e,n)}}if((s=(s+1)%i)==n)break}return t}function ii(t,e){let r,i=t.dom.ownerDocument,n=0,s=function(t,e,r){if(t.caretPositionFromPoint)try{let i=t.caretPositionFromPoint(e,r);if(i)return{node:i.offsetNode,offset:Math.min(xr(i.offsetNode),i.offset)}}catch(t){}if(t.caretRangeFromPoint){let i=t.caretRangeFromPoint(e,r);if(i)return{node:i.startContainer,offset:Math.min(xr(i.startContainer),i.startOffset)}}}(i,e.left,e.top);s&&({node:r,offset:n}=s);let o,l=(t.root.elementFromPoint?t.root:i).elementFromPoint(e.left,e.top);if(!l||!t.dom.contains(1!=l.nodeType?l.parentNode:l)){let r=t.dom.getBoundingClientRect();if(!ei(e,r))return null;if(l=ri(t.dom,e,r),!l)return null}if(Ir)for(let t=l;r&&t;t=wr(t))t.draggable&&(r=void 0);if(l=function(t,e){let r=t.parentNode;return r&&/^li$/i.test(r.nodeName)&&e.left<t.getBoundingClientRect().left?r:t}(l,e),r){if(Tr&&1==r.nodeType&&(n=Math.min(n,r.childNodes.length),n<r.childNodes.length)){let t,i=r.childNodes[n];"IMG"==i.nodeName&&(t=i.getBoundingClientRect()).right<=e.left&&t.bottom>e.top&&n++}let i;Vr&&n&&1==r.nodeType&&1==(i=r.childNodes[n-1]).nodeType&&"false"==i.contentEditable&&i.getBoundingClientRect().top>=e.top&&n--,r==t.dom&&n==r.childNodes.length-1&&1==r.lastChild.nodeType&&e.top>r.lastChild.getBoundingClientRect().bottom?o=t.state.doc.content.size:0!=n&&1==r.nodeType&&"BR"==r.childNodes[n-1].nodeName||(o=function(t,e,r,i){let n=-1;for(let r=e,s=!1;r!=t.dom;){let e,o=t.docView.nearestDesc(r,!0);if(!o)return null;if(1==o.dom.nodeType&&(o.node.isBlock&&o.parent||!o.contentDOM)&&((e=o.dom.getBoundingClientRect()).width||e.height)&&(o.node.isBlock&&o.parent&&(!s&&e.left>i.left||e.top>i.top?n=o.posBefore:(!s&&e.right<i.left||e.bottom<i.top)&&(n=o.posAfter),s=!0),!o.contentDOM&&n<0&&!o.node.isText))return(o.node.isBlock?i.top<(e.top+e.bottom)/2:i.left<(e.left+e.right)/2)?o.posBefore:o.posAfter;r=o.dom.parentNode}return n>-1?n:t.docView.posFromDOM(e,r,-1)}(t,r,n,e))}null==o&&(o=function(t,e,r){let{node:i,offset:n}=ti(e,r),s=-1;if(1==i.nodeType&&!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)}(t,l,e));let u=t.docView.nearestDesc(l,!0);return{pos:o,inside:u?u.posAtStart-u.border:-1}}function ni(t){return t.top<t.bottom||t.left<t.right}function si(t,e){let r=t.getClientRects();if(r.length){let t=r[e<0?0:r.length-1];if(ni(t))return t}return Array.prototype.find.call(r,ni)||t.getBoundingClientRect()}const oi=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function li(t,e,r){let{node:i,offset:n,atom:s}=t.docView.domFromPos(e,r<0?-1:1),o=Vr||Tr;if(3==i.nodeType){if(!o||!oi.test(i.nodeValue)&&(r<0?n:n!=i.nodeValue.length)){let t=n,e=n,s=r<0?1:-1;return r<0&&!n?(e++,s=-1):r>=0&&n==i.nodeValue.length?(t--,s=1):r<0?t--:e++,ui(si(kr(i,t,e),s),s<0)}{let t=si(kr(i,n,n),r);if(Tr&&n&&/\s/.test(i.nodeValue[n-1])&&n<i.nodeValue.length){let e=si(kr(i,n-1,n-1),-1);if(e.top==t.top){let r=si(kr(i,n,n+1),-1);if(r.top!=t.top)return ui(r,r.left<e.left)}}return t}}if(!t.state.doc.resolve(e-(s||0)).parent.inlineContent){if(null==s&&n&&(r<0||n==xr(i))){let t=i.childNodes[n-1];if(1==t.nodeType)return hi(t.getBoundingClientRect(),!1)}if(null==s&&n<xr(i)){let t=i.childNodes[n];if(1==t.nodeType)return hi(t.getBoundingClientRect(),!0)}return hi(i.getBoundingClientRect(),r>=0)}if(null==s&&n&&(r<0||n==xr(i))){let t=i.childNodes[n-1],e=3==t.nodeType?kr(t,xr(t)-(o?0:1)):1!=t.nodeType||"BR"==t.nodeName&&t.nextSibling?null:t;if(e)return ui(si(e,1),!1)}if(null==s&&n<xr(i)){let t=i.childNodes[n];for(;t.pmViewDesc&&t.pmViewDesc.ignoreForCoords;)t=t.nextSibling;let e=t?3==t.nodeType?kr(t,0,o?0:1):1==t.nodeType?t:null:null;if(e)return ui(si(e,-1),!0)}return ui(si(3==i.nodeType?kr(i):i,-r),r>=0)}function ui(t,e){if(0==t.width)return t;let r=e?t.left:t.right;return{top:t.top,bottom:t.bottom,left:r,right:r}}function hi(t,e){if(0==t.height)return t;let r=e?t.top:t.bottom;return{top:r,bottom:r,left:t.left,right:t.right}}function ai(t,e,r){let i=t.state,n=t.root.activeElement;i!=e&&t.updateState(e),n!=t.dom&&t.focus();try{return r()}finally{i!=e&&t.updateState(i),n!=t.dom&&n&&n.focus()}}const fi=/[\u0590-\u08ac]/;let ci=null,di=null,pi=!1;class mi{constructor(t,e,r,i){this.parent=t,this.children=e,this.dom=r,this.contentDOM=i,this.dirty=0,r.pmViewDesc=this}matchesWidget(t){return!1}matchesMark(t){return!1}matchesNode(t,e,r){return!1}matchesHack(t){return!1}parseRule(){return null}stopEvent(t){return!1}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=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);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(1==t.nodeType?t:t.parentNode)){if(r<0){let r,i;if(t==this.contentDOM)r=t.childNodes[e-1];else{for(;t.parentNode!=this.contentDOM;)t=t.parentNode;r=t.previousSibling}for(;r&&(!(i=r.pmViewDesc)||i.parent!=this);)r=r.previousSibling;return r?this.posBeforeChild(i)+i.size:this.posAtStart}{let r,i;if(t==this.contentDOM)r=t.childNodes[e];else{for(;t.parentNode!=this.contentDOM;)t=t.parentNode;r=t.nextSibling}for(;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>br(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))i=2&t.compareDocumentPosition(this.contentDOM);else if(this.dom.firstChild){if(0==e)for(let e=t;;e=e.parentNode){if(e==this.dom){i=!1;break}if(e.previousSibling)break}if(null==i&&e==t.childNodes.length)for(let e=t;;e=e.parentNode){if(e==this.dom){i=!0;break}if(e.nextSibling)break}}return(null==i?r>0:i)?this.posAtEnd:this.posAtStart}nearestDesc(t,e=!1){for(let r=!0,i=t;i;i=i.parentNode){let n,s=this.getDesc(i);if(s&&(!e||s.node)){if(!r||!(n=s.nodeDOM)||(1==n.nodeType?n.contains(1==t.nodeType?t:t.parentNode):n==t))return s;r=!1}}}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){for(;!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 yi){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 gi&&t.side>=0;r--);if(e<=0){let t,i=!0;for(;t=r?this.children[r-1]:null,t&&t.dom.parentNode!=this.contentDOM;r--,i=!1);return t&&e&&i&&!t.border&&!t.domAtom?t.domFromPos(t.size,e):{node:this.contentDOM,offset:t?br(t.dom)+1:0}}{let t,i=!0;for(;t=r<this.children.length?this.children[r]:null,t&&t.dom.parentNode!=this.contentDOM;r++,i=!1);return t&&i&&!t.border&&!t.domAtom?t.domFromPos(0,e):{node:this.contentDOM,offset:t?br(t.dom):this.contentDOM.childNodes.length}}}parseRange(t,e,r=0){if(0==this.children.length)return{node:this.contentDOM,from:t,to:e,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let i=-1,n=-1;for(let s=r,o=0;;o++){let r=this.children[o],l=s+r.size;if(-1==i&&t<=l){let n=s+r.border;if(t>=n&&e<=l-r.border&&r.node&&r.contentDOM&&this.contentDOM.contains(r.contentDOM))return r.parseRange(t,e,n);t=s;for(let e=o;e>0;e--){let r=this.children[e-1];if(r.size&&r.dom.parentNode==this.contentDOM&&!r.emptyChildAt(1)){i=br(r.dom)+1;break}t-=r.size}-1==i&&(i=0)}if(i>-1&&(l>e||o==this.children.length-1)){e=l;for(let t=o+1;t<this.children.length;t++){let r=this.children[t];if(r.size&&r.dom.parentNode==this.contentDOM&&!r.emptyChildAt(-1)){n=br(r.dom);break}e+=r.size}-1==n&&(n=this.contentDOM.childNodes.length);break}s=l}return{node:this.contentDOM,from:t,to:e,fromOffset:i,toOffset:n}}emptyChildAt(t){if(this.border||!this.contentDOM||!this.children.length)return!1;let e=this.children[t<0?0:this.children.length-1];return 0==e.size||e.emptyChildAt(t)}domAfterPos(t){let{node:e,offset:r}=this.domFromPos(t,0);if(1!=e.nodeType||r==e.childNodes.length)throw new RangeError("No node after pos "+t);return e.childNodes[r]}setSelection(t,e,r,i=!1){let n=Math.min(t,e),s=Math.max(t,e);for(let o=0,l=0;o<this.children.length;o++){let u=this.children[o],h=l+u.size;if(n>l&&s<h)return u.setSelection(t-l-u.border,e-l-u.border,r,i);l=h}let o=this.domFromPos(t,t?-1:1),l=e==t?o:this.domFromPos(e,e?-1:1),u=r.root.getSelection(),h=r.domSelectionRange(),a=!1;if((Tr||Ir)&&t==e){let{node:t,offset:e}=o;if(3==t.nodeType){if(a=!(!e||"\n"!=t.nodeValue[e-1]),a&&e==t.nodeValue.length)for(let e,r=t;r;r=r.parentNode){if(e=r.nextSibling){"BR"==e.nodeName&&(o=l={node:e.parentNode,offset:br(e)+1});break}let t=r.pmViewDesc;if(t&&t.node&&t.node.isBlock)break}}else{let r=t.childNodes[e-1];a=r&&("BR"==r.nodeName||"false"==r.contentEditable)}}if(Tr&&h.focusNode&&h.focusNode!=l.node&&1==h.focusNode.nodeType){let t=h.focusNode.childNodes[h.focusOffset];t&&"false"==t.contentEditable&&(i=!0)}if(!(i||a&&Ir)&&Dr(o.node,o.offset,h.anchorNode,h.anchorOffset)&&Dr(l.node,l.offset,h.focusNode,h.focusOffset))return;let f=!1;if((u.extend||t==e)&&!a){u.collapse(o.node,o.offset);try{t!=e&&u.extend(l.node,l.offset),f=!0}catch(t){}}if(!f){if(t>e){let t=o;o=l,l=t}let r=document.createRange();r.setEnd(l.node,l.offset),r.setStart(o.node,o.offset),u.removeAllRanges(),u.addRange(r)}}ignoreMutation(t){return!this.contentDOM&&"selection"!=t.type}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,o=s-n.border;if(t>=i&&e<=o)return this.dirty=t==r||e==s?2:1,void(t!=i||e!=o||!n.contentLost&&n.dom.parentNode==this.contentDOM?n.markDirty(t-i,e-i):n.dirty=3);n.dirty=n.dom!=n.contentDOM||n.dom.parentNode!=this.contentDOM||n.children.length?3:2}r=s}this.dirty=2}markParentsDirty(){let t=1;for(let e=this.parent;e;e=e.parent,t++){let r=1==t?2:1;e.dirty<r&&(e.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}isText(t){return!1}}class gi extends mi{constructor(t,e,r,i){let n,s=e.type.toDOM;if("function"==typeof s&&(s=s(r,(()=>n?n.parent?n.parent.posBeforeChild(n):void 0:i))),!e.type.spec.raw){if(1!=s.nodeType){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 0==this.dirty&&t.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(t){let e=this.widget.spec.stopEvent;return!!e&&e(t)}ignoreMutation(t){return"selection"!=t.type||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get side(){return this.widget.type.side}}class bi extends mi{constructor(t,e,r,i){super(t,[],e,null),this.textDOM=r,this.text=i}get size(){return this.text.length}localPosFromDOM(t,e){return t!=this.textDOM?this.posAtStart+(e?this.size:0):this.posAtStart+e}domFromPos(t){return{node:this.textDOM,offset:t}}ignoreMutation(t){return"characterData"===t.type&&t.target.nodeValue==t.oldValue}}class wi extends mi{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],s=n&&n(e,i,r);return s&&s.dom||(s=te.renderSpec(document,e.type.spec.toDOM(e,r),null,e.attrs)),new wi(t,e,s.dom,s.contentDOM||s.dom,s)}parseRule(){return 3&this.dirty||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(t){return 3!=this.dirty&&this.mark.eq(t)}markDirty(t,e){if(super.markDirty(t,e),0!=this.dirty){let t=this.parent;for(;!t.node;)t=t.parent;t.dirty<this.dirty&&(t.dirty=this.dirty),this.dirty=0}}slice(t,e,r){let i=wi.create(this.parent,this.mark,!0,r),n=this.children,s=this.size;e<s&&(n=_i(n,e,s,r)),t>0&&(n=_i(n,0,t,r));for(let t=0;t<n.length;t++)n[t].parent=i;return i.children=n,i}ignoreMutation(t){return this.spec.ignoreMutation?this.spec.ignoreMutation(t):super.ignoreMutation(t)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class vi extends mi{constructor(t,e,r,i,n,s,o,l,u){super(t,[],n,s),this.node=e,this.outerDeco=r,this.innerDeco=i,this.nodeDOM=o}static create(t,e,r,i,n,s){let o,l=n.nodeViews[e.type.name],u=l&&l(e,n,(()=>o?o.parent?o.parent.posBeforeChild(o):void 0:s),r,i),h=u&&u.dom,a=u&&u.contentDOM;if(e.isText)if(h){if(3!=h.nodeType)throw new RangeError("Text must be rendered as a DOM text node")}else h=document.createTextNode(e.text);else if(!h){let t=te.renderSpec(document,e.type.spec.toDOM(e),null,e.attrs);({dom:h,contentDOM:a}=t)}a||e.isText||"BR"==h.nodeName||(h.hasAttribute("contenteditable")||(h.contentEditable="false"),e.type.spec.draggable&&(h.draggable=!0));let f=h;return h=Oi(h,r,e),u?o=new Ei(t,e,r,i,h,a||null,f,u,n,s+1):e.isText?new Di(t,e,r,i,h,f,n):new vi(t,e,r,i,h,a||null,f,n,s+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let t={node:this.node.type.name,attrs:this.node.attrs};if("pre"==this.node.type.whitespace&&(t.preserveWhitespace="full"),this.contentDOM)if(this.contentLost){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}}t.contentElement||(t.getContent=()=>Q.empty)}else t.contentElement=this.contentDOM;else t.getContent=()=>this.node.content;return t}matchesNode(t,e,r){return 0==this.dirty&&t.eq(this.node)&&$i(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,n=t.composing?this.localCompositionInfo(t,e):null,s=n&&n.pos>-1?n:null,o=n&&n.pos<0,l=new Ri(this,s&&s.node,t);!function(t,e,r,i){let n=e.locals(t),s=0;if(0==n.length){for(let r=0;r<t.childCount;r++){let o=t.child(r);i(o,n,e.forChild(s,o),r),s+=o.nodeSize}return}let o=0,l=[],u=null;for(let h=0;;){let a,f,c,d;for(;o<n.length&&n[o].to==s;){let t=n[o++];t.widget&&(a?(f||(f=[a])).push(t):a=t)}if(a)if(f){f.sort(Ni);for(let t=0;t<f.length;t++)r(f[t],h,!!u)}else r(a,h,!!u);if(u)d=-1,c=u,u=null;else{if(!(h<t.childCount))break;d=h,c=t.child(h++)}for(let t=0;t<l.length;t++)l[t].to<=s&&l.splice(t--,1);for(;o<n.length&&n[o].from<=s&&n[o].to>s;)l.push(n[o++]);let p=s+c.nodeSize;if(c.isText){let t=p;o<n.length&&n[o].from<t&&(t=n[o].from);for(let e=0;e<l.length;e++)l[e].to<t&&(t=l[e].to);t<p&&(u=c.cut(t-s),c=c.cut(0,t-s),p=t,d=-1)}else for(;o<n.length&&n[o].to<p;)o++;i(c,c.isInline&&!c.isLeaf?l.filter((t=>!t.inline)):l.slice(),e.forChild(s,c),d),s=p}}(this.node,this.innerDeco,((e,n,s)=>{e.spec.marks?l.syncToMarks(e.spec.marks,r,t):e.type.side>=0&&!s&&l.syncToMarks(n==this.node.childCount?it.none:this.node.child(n).marks,r,t),l.placeWidget(e,t,i)}),((e,s,u,h)=>{let a;l.syncToMarks(e.marks,r,t),l.findNodeMatch(e,s,u,h)||o&&t.state.selection.from>i&&t.state.selection.to<i+e.nodeSize&&(a=l.findIndexWithChild(n.node))>-1&&l.updateNodeAt(e,s,u,a,t)||l.updateNextNode(e,s,u,t,h,i)||l.addNode(e,s,u,t,i),i+=e.nodeSize})),l.syncToMarks([],r,t),this.node.isTextblock&&l.addTextblockHacks(),l.destroyRest(),(l.changed||2==this.dirty)&&(s&&this.protectLocalComposition(t,s),xi(this.contentDOM,this.children,t),Pr&&function(t){if("UL"==t.nodeName||"OL"==t.nodeName){let e=t.style.cssText;t.style.cssText=e+"; list-style: square !important",window.getComputedStyle(t),t.style.cssText=e}}(this.dom))}localCompositionInfo(t,e){let{from:r,to:i}=t.state.selection;if(!(t.state.selection instanceof Xe)||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,s=function(t,e,r,i){for(let n=0,s=0;n<t.childCount&&s<=i;){let o=t.child(n++),l=s;if(s+=o.nodeSize,!o.isText)continue;let u=o.text;for(;n<t.childCount;){let e=t.child(n++);if(s+=e.nodeSize,!e.isText)break;u+=e.text}if(s>=r){if(s>=i&&u.slice(i-e.length-l,i-l)==e)return i-e.length;let t=l<i?u.lastIndexOf(e,i-l-1):-1;if(t>=0&&t+e.length+l>=r)return l+t;if(r==i&&u.length>=i+e.length-l&&u.slice(i-l,i-l+e.length)==e)return i}}return-1}(this.node.content,t,r-e,i-e);return s<0?null:{node:n,pos:s,text:t}}return{node:n,pos:-1,text:""}}protectLocalComposition(t,{node:e,pos:r,text:i}){if(this.getDesc(e))return;let n=e;for(;n.parentNode!=this.contentDOM;n=n.parentNode){for(;n.previousSibling;)n.parentNode.removeChild(n.previousSibling);for(;n.nextSibling;)n.parentNode.removeChild(n.nextSibling);n.pmViewDesc&&(n.pmViewDesc=void 0)}let s=new bi(this,n,e,i);t.input.compositionNodes.push(s),this.children=_i(this.children,r,r+i.length,t,s)}update(t,e,r,i){return!(3==this.dirty||!t.sameMarkup(this.node)||(this.updateInner(t,e,r,i),0))}updateInner(t,e,r,i){this.updateOuterDeco(e),this.node=t,this.innerDeco=r,this.contentDOM&&this.updateChildren(i,this.posAtStart),this.dirty=0}updateOuterDeco(t){if($i(t,this.outerDeco))return;let e=1!=this.nodeDOM.nodeType,r=this.dom;this.dom=Ci(this.dom,this.nodeDOM,Ai(this.outerDeco,this.node,e),Ai(t,this.node,e)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=t}selectNode(){1==this.nodeDOM.nodeType&&this.nodeDOM.classList.add("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||(this.dom.draggable=!0)}deselectNode(){1==this.nodeDOM.nodeType&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||this.dom.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function ki(t,e,r,i,n){Oi(i,e,t);let s=new vi(void 0,t,e,r,i,i,i,n,0);return s.contentDOM&&s.updateChildren(n,0),s}class Di extends vi{constructor(t,e,r,i,n,s,o){super(t,e,r,i,n,null,s,o,0)}parseRule(){let t=this.nodeDOM.parentNode;for(;t&&t!=this.dom&&!t.pmIsDeco;)t=t.parentNode;return{skip:t||!0}}update(t,e,r,i){return!(3==this.dirty||0!=this.dirty&&!this.inParent()||!t.sameMarkup(this.node)||(this.updateOuterDeco(e),0==this.dirty&&t.text==this.node.text||t.text==this.nodeDOM.nodeValue||(this.nodeDOM.nodeValue=t.text,i.trackWrites==this.nodeDOM&&(i.trackWrites=null)),this.node=t,this.dirty=0,0))}inParent(){let t=this.parent.contentDOM;for(let e=this.nodeDOM;e;e=e.parentNode)if(e==t)return!0;return!1}domFromPos(t){return{node:this.nodeDOM,offset:t}}localPosFromDOM(t,e,r){return t==this.nodeDOM?this.posAtStart+Math.min(e,this.node.text.length):super.localPosFromDOM(t,e,r)}ignoreMutation(t){return"characterData"!=t.type&&"selection"!=t.type}slice(t,e,r){let i=this.node.cut(t,e),n=document.createTextNode(i.text);return new Di(this.parent,i,this.outerDeco,this.innerDeco,n,n,r)}markDirty(t,e){super.markDirty(t,e),this.dom==this.nodeDOM||0!=t&&e!=this.nodeDOM.nodeValue.length||(this.dirty=3)}get domAtom(){return!1}isText(t){return this.node.text==t}}class yi extends mi{parseRule(){return{ignore:!0}}matchesHack(t){return 0==this.dirty&&this.dom.nodeName==t}get domAtom(){return!0}get ignoreForCoords(){return"IMG"==this.dom.nodeName}}class Ei extends vi{constructor(t,e,r,i,n,s,o,l,u,h){super(t,e,r,i,n,s,o,u,h),this.spec=l}update(t,e,r,i){if(3==this.dirty)return!1;if(this.spec.update&&(this.node.type==t.type||this.spec.multiType)){let n=this.spec.update(t,e,r);return n&&this.updateInner(t,e,r,i),n}return!(!this.contentDOM&&!t.isLeaf)&&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(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(t){return!!this.spec.stopEvent&&this.spec.stopEvent(t)}ignoreMutation(t){return this.spec.ignoreMutation?this.spec.ignoreMutation(t):super.ignoreMutation(t)}}function xi(t,e,r){let i=t.firstChild,n=!1;for(let s=0;s<e.length;s++){let o=e[s],l=o.dom;if(l.parentNode==t){for(;l!=i;)i=Bi(i),n=!0;i=i.nextSibling}else n=!0,t.insertBefore(l,i);if(o instanceof wi){let e=i?i.previousSibling:t.lastChild;xi(o.contentDOM,o.children,r),i=e?e.nextSibling:t.firstChild}}for(;i;)i=Bi(i),n=!0;n&&r.trackWrites==t&&(r.trackWrites=null)}const Fi=function(t){t&&(this.nodeName=t)};Fi.prototype=Object.create(null);const Mi=[new Fi];function Ai(t,e,r){if(0==t.length)return Mi;let i=r?Mi[0]:new Fi,n=[i];for(let s=0;s<t.length;s++){let o=t[s].type.attrs;if(o){o.nodeName&&n.push(i=new Fi(o.nodeName));for(let t in o){let s=o[t];null!=s&&(r&&1==n.length&&n.push(i=new Fi(e.isInline?"span":"div")),"class"==t?i.class=(i.class?i.class+" ":"")+s:"style"==t?i.style=(i.style?i.style+";":"")+s:"nodeName"!=t&&(i[t]=s))}}}return n}function Ci(t,e,r,i){if(r==Mi&&i==Mi)return e;let n=e;for(let e=0;e<i.length;e++){let s=i[e],o=r[e];if(e){let e;o&&o.nodeName==s.nodeName&&n!=t&&(e=n.parentNode)&&e.nodeName.toLowerCase()==s.nodeName||(e=document.createElement(s.nodeName),e.pmIsDeco=!0,e.appendChild(n),o=Mi[0]),n=e}Si(n,o||Mi[0],s)}return n}function Si(t,e,r){for(let i in e)"class"==i||"style"==i||"nodeName"==i||i in r||t.removeAttribute(i);for(let i in r)"class"!=i&&"style"!=i&&"nodeName"!=i&&r[i]!=e[i]&&t.setAttribute(i,r[i]);if(e.class!=r.class){let i=e.class?e.class.split(" ").filter(Boolean):[],n=r.class?r.class.split(" ").filter(Boolean):[];for(let e=0;e<i.length;e++)-1==n.indexOf(i[e])&&t.classList.remove(i[e]);for(let e=0;e<n.length;e++)-1==i.indexOf(n[e])&&t.classList.add(n[e]);0==t.classList.length&&t.removeAttribute("class")}if(e.style!=r.style){if(e.style){let r,i=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g;for(;r=i.exec(e.style);)t.style.removeProperty(r[1])}r.style&&(t.style.cssText+=r.style)}}function Oi(t,e,r){return Ci(t,t,Mi,Ai(e,r,1!=t.nodeType))}function $i(t,e){if(t.length!=e.length)return!1;for(let r=0;r<t.length;r++)if(!t[r].type.eq(e[r].type))return!1;return!0}function Bi(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class Ri{constructor(t,e,r){this.lock=e,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=t,this.preMatch=function(t,e){let r=e,i=r.children.length,n=t.childCount,s=new Map,o=[];t:for(;n>0;){let l;for(;;)if(i){let t=r.children[i-1];if(!(t instanceof wi)){l=t,i--;break}r=t,i=t.children.length}else{if(r==e)break t;i=r.parent.children.indexOf(r),r=r.parent}let u=l.node;if(u){if(u!=t.child(n-1))break;--n,s.set(l,n),o.push(l)}}return{index:n,matched:s,matches:o.reverse()}}(t.node.content,t)}destroyBetween(t,e){if(t!=e){for(let r=t;r<e;r++)this.top.children[r].destroy();this.top.children.splice(t,e-t),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(t,e,r){let i=0,n=this.stack.length>>1,s=Math.min(n,t.length);for(;i<s&&(i==n-1?this.top:this.stack[i+1<<1]).matchesMark(t[i])&&!1!==t[i].type.spec.spanning;)i++;for(;i<n;)this.destroyRest(),this.top.dirty=0,this.index=this.stack.pop(),this.top=this.stack.pop(),n--;for(;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)i>this.index&&(this.changed=!0,this.destroyBetween(this.index,i)),this.top=this.top.children[this.index];else{let i=wi.create(this.top,t[n],e,r);this.top.children.splice(this.index,0,i),this.top=i,this.changed=!0}this.index=0,n++}}findNodeMatch(t,e,r,i){let n,s=-1;if(i>=this.preMatch.index&&(n=this.preMatch.matches[i-this.preMatch.index]).parent==this.top&&n.matchesNode(t,e,r))s=this.top.children.indexOf(n,this.index);else for(let i=this.index,n=Math.min(this.top.children.length,i+5);i<n;i++){let n=this.top.children[i];if(n.matchesNode(t,e,r)&&!this.preMatch.matched.has(n)){s=i;break}}return!(s<0||(this.destroyBetween(this.index,s),this.index++,0))}updateNodeAt(t,e,r,i,n){let s=this.top.children[i];return 3==s.dirty&&s.dom==s.contentDOM&&(s.dirty=2),!!s.update(t,e,r,n)&&(this.destroyBetween(this.index,i),this.index++,!0)}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 o=this.index;o<this.top.children.length;o++){let l=this.top.children[o];if(l instanceof vi){let u=this.preMatch.matched.get(l);if(null!=u&&u!=n)return!1;let h,a=l.dom,f=this.isLocked(a)&&!(t.isText&&l.node&&l.node.isText&&l.nodeDOM.nodeValue==t.text&&3!=l.dirty&&$i(e,l.outerDeco));if(!f&&l.update(t,e,r,i))return this.destroyBetween(this.index,o),l.dom!=a&&(this.changed=!0),this.index++,!0;if(!f&&(h=this.recreateWrapper(l,t,e,r,i,s)))return this.destroyBetween(this.index,o),this.top.children[this.index]=h,h.contentDOM&&(h.dirty=2,h.updateChildren(i,s+1),h.dirty=0),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(t,e,r,i,n,s){if(t.dirty||e.isAtom||!t.children.length||!t.node.content.eq(e.content)||!$i(r,t.outerDeco)||!i.eq(t.innerDeco))return null;let o=vi.create(this.top,e,r,i,n,s);if(o.contentDOM){o.children=t.children,t.children=[];for(let t of o.children)t.parent=o}return t.destroy(),o}addNode(t,e,r,i,n){let s=vi.create(this.top,t,e,r,i,n);s.contentDOM&&s.updateChildren(i,n+1),this.top.children.splice(this.index++,0,s),this.changed=!0}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){let i=new gi(this.top,t,e,r);this.top.children.splice(this.index++,0,i),this.changed=!0}else this.index++}addTextblockHacks(){let t=this.top.children[this.index-1],e=this.top;for(;t instanceof wi;)e=t,t=e.children[e.children.length-1];(!t||!(t instanceof Di)||/\n$/.test(t.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(t.node.text))&&((Ir||jr)&&t&&"false"==t.dom.contentEditable&&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);"IMG"==t&&(r.className="ProseMirror-separator",r.alt=""),"BR"==t&&(r.className="ProseMirror-trailingBreak");let i=new yi(this.top,[],r,null);e!=this.top?e.children.push(i):e.children.splice(this.index++,0,i),this.changed=!0}}isLocked(t){return this.lock&&(t==this.lock||1==t.nodeType&&t.contains(this.lock.parentNode))}}function Ni(t,e){return t.type.side-e.type.side}function _i(t,e,r,i,n){let s=[];for(let o=0,l=0;o<t.length;o++){let u=t[o],h=l,a=l+=u.size;h>=r||a<=e?s.push(u):(h<e&&s.push(u.slice(0,e-h,i)),n&&(s.push(n),n=void 0),a>r&&s.push(u.slice(r-h,u.size,i)))}return s}function Ti(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&&0==n.size,o=t.docView.posFromDOM(r.focusNode,r.focusOffset,1);if(o<0)return null;let l,u,h=i.resolve(o);if(Mr(r)){for(l=o;n&&!n.node;)n=n.parent;let t=n.node;if(n&&t.isAtom&&tr.isSelectable(t)&&n.parent&&(!t.isInline||!function(t,e,r){for(let i=0==e,n=e==xr(t);i||n;){if(t==r)return!0;let e=br(t);if(!(t=t.parentNode))return!1;i=i&&0==e,n=n&&e==xr(t)}}(r.focusNode,r.focusOffset,n.dom))){let t=n.posBefore;u=new tr(o==t?h:i.resolve(t))}}else{if(r instanceof t.dom.ownerDocument.defaultView.Selection&&r.rangeCount>1){let e=o,n=o;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;[l,o]=n==t.state.selection.anchor?[n,e]:[e,n],h=i.resolve(o)}else l=t.docView.posFromDOM(r.anchorNode,r.anchorOffset,1);if(l<0)return null}let a=i.resolve(l);return u||(u=Vi(t,a,h,"pointer"==e||t.state.selection.head<h.pos&&!s?1:-1)),u}function zi(t){return t.editable?t.hasFocus():Wi(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function ji(t,e=!1){let r=t.state.selection;if(Ji(t,r),zi(t)){if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&jr){let e=t.domSelectionRange(),r=t.domObserver.currentSelection;if(e.anchorNode&&r.anchorNode&&Dr(e.anchorNode,e.anchorOffset,r.anchorNode,r.anchorOffset))return t.input.mouseDown.delayedSelectionSync=!0,void t.domObserver.setCurSelection()}if(t.domObserver.disconnectSelection(),t.cursorWrapper)!function(t){let e=t.domSelection(),r=document.createRange();if(!e)return;let i=t.cursorWrapper.dom,n="IMG"==i.nodeName;n?r.setStart(i.parentNode,br(i)+1):r.setStart(i,0),r.collapse(!0),e.removeAllRanges(),e.addRange(r),!n&&!t.state.selection.visible&&Nr&&_r<=11&&(i.disabled=!0,i.disabled=!1)}(t);else{let i,n,{anchor:s,head:o}=r;!qi||r instanceof Xe||(r.$from.parent.inlineContent||(i=Ii(t,r.from)),r.empty||r.$from.parent.inlineContent||(n=Ii(t,r.to))),t.docView.setSelection(s,o,t,e),qi&&(i&&Li(i),n&&Li(n)),r.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&function(t){let e=t.dom.ownerDocument;e.removeEventListener("selectionchange",t.input.hideSelectionGuard);let r=t.domSelectionRange(),i=r.anchorNode,n=r.anchorOffset;e.addEventListener("selectionchange",t.input.hideSelectionGuard=()=>{r.anchorNode==i&&r.anchorOffset==n||(e.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout((()=>{zi(t)&&!t.state.selection.visible||t.dom.classList.remove("ProseMirror-hideselection")}),20))})}(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}const qi=Ir||jr&&qr<63;function Ii(t,e){let{node:r,offset:i}=t.docView.domFromPos(e,0),n=i<r.childNodes.length?r.childNodes[i]:null,s=i?r.childNodes[i-1]:null;if(Ir&&n&&"false"==n.contentEditable)return Pi(n);if(!(n&&"false"!=n.contentEditable||s&&"false"!=s.contentEditable)){if(n)return Pi(n);if(s)return Pi(s)}}function Pi(t){return t.contentEditable="true",Ir&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function Li(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function Ji(t,e){if(e instanceof tr){let r=t.docView.descAt(e.from);r!=t.lastSelectedViewDesc&&(Ui(t),r&&r.selectNode(),t.lastSelectedViewDesc=r)}else Ui(t)}function Ui(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function Vi(t,e,r,i){return t.someProp("createSelectionBetween",(i=>i(t,e,r)))||Xe.between(e,r,i)}function Hi(t){return!(t.editable&&!t.hasFocus())&&Wi(t)}function Wi(t){let e=t.domSelectionRange();if(!e.anchorNode)return!1;try{return t.dom.contains(3==e.anchorNode.nodeType?e.anchorNode.parentNode:e.anchorNode)&&(t.editable||t.dom.contains(3==e.focusNode.nodeType?e.focusNode.parentNode:e.focusNode))}catch(t){return!1}}function Gi(t,e){let{$anchor:r,$head:i}=t.selection,n=e>0?r.max(i):r.min(i),s=n.parent.inlineContent?n.depth?t.doc.resolve(e>0?n.after():n.before()):null:n;return s&&Ge.findFrom(s,e)}function Zi(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function Ki(t,e,r){let i=t.state.selection;if(!(i instanceof Xe)){if(i instanceof tr&&i.node.isInline)return Zi(t,new Xe(e>0?i.$to:i.$from));{let r=Gi(t.state,e);return!!r&&Zi(t,r)}}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!1;let s=t.state.doc.resolve(r.pos+n.nodeSize*(e<0?-1:1));return Zi(t,new Xe(i.$anchor,s))}if(!i.empty)return!1;if(t.endOfTextblock(e>0?"forward":"backward")){let r=Gi(t.state,e);return!!(r&&r instanceof tr)&&Zi(t,r)}if(!(Lr&&r.indexOf("m")>-1)){let r,n=i.$head,s=n.textOffset?null:e<0?n.nodeBefore:n.nodeAfter;if(!s||s.isText)return!1;let o=e<0?n.pos-s.nodeSize:n.pos;return!!(s.isAtom||(r=t.docView.descAt(o))&&!r.contentDOM)&&(tr.isSelectable(s)?Zi(t,new tr(e<0?t.state.doc.resolve(n.pos-s.nodeSize):n)):!!Vr&&Zi(t,new Xe(t.state.doc.resolve(e<0?o:o+s.nodeSize))))}}function Yi(t){return 3==t.nodeType?t.nodeValue.length:t.childNodes.length}function Xi(t,e){let r=t.pmViewDesc;return r&&0==r.size&&(e<0||t.nextSibling||"BR"!=t.nodeName)}function Qi(t,e){return e<0?function(t){let e=t.domSelectionRange(),r=e.focusNode,i=e.focusOffset;if(!r)return;let n,s,o=!1;for(Tr&&1==r.nodeType&&i<Yi(r)&&Xi(r.childNodes[i],-1)&&(o=!0);;)if(i>0){if(1!=r.nodeType)break;{let t=r.childNodes[i-1];if(Xi(t,-1))n=r,s=--i;else{if(3!=t.nodeType)break;r=t,i=r.nodeValue.length}}}else{if(tn(r))break;{let e=r.previousSibling;for(;e&&Xi(e,-1);)n=r.parentNode,s=br(e),e=e.previousSibling;if(e)r=e,i=Yi(r);else{if(r=r.parentNode,r==t.dom)break;i=0}}}o?en(t,r,i):n&&en(t,n,s)}(t):function(t){let e=t.domSelectionRange(),r=e.focusNode,i=e.focusOffset;if(!r)return;let n,s,o=Yi(r);for(;;)if(i<o){if(1!=r.nodeType)break;if(!Xi(r.childNodes[i],1))break;n=r,s=++i}else{if(tn(r))break;{let e=r.nextSibling;for(;e&&Xi(e,1);)n=e.parentNode,s=br(e)+1,e=e.nextSibling;if(e)r=e,i=0,o=Yi(r);else{if(r=r.parentNode,r==t.dom)break;i=o=0}}}n&&en(t,n,s)}(t)}function tn(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function en(t,e,r){if(3!=e.nodeType){let t,i;(i=function(t,e){for(;t&&e==t.childNodes.length&&!Fr(t);)e=br(t)+1,t=t.parentNode;for(;t&&e<t.childNodes.length;){let r=t.childNodes[e];if(3==r.nodeType)return r;if(1==r.nodeType&&"false"==r.contentEditable)break;t=r,e=0}}(e,r))?(e=i,r=0):(t=function(t,e){for(;t&&!e&&!Fr(t);)e=br(t),t=t.parentNode;for(;t&&e;){let r=t.childNodes[e-1];if(3==r.nodeType)return r;if(1==r.nodeType&&"false"==r.contentEditable)break;e=(t=r).childNodes.length}}(e,r))&&(e=t,r=t.nodeValue.length)}let i=t.domSelection();if(!i)return;if(Mr(i)){let t=document.createRange();t.setEnd(e,r),t.setStart(e,r),i.removeAllRanges(),i.addRange(t)}else i.extend&&i.extend(e,r);t.domObserver.setCurSelection();let{state:n}=t;setTimeout((()=>{t.state==n&&ji(t)}),50)}function rn(t,e){let r=t.state.doc.resolve(e);if(!jr&&!Jr&&r.parent.inlineContent){let i=t.coordsAtPos(e);if(e>r.start()){let r=t.coordsAtPos(e-1),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),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"}}return"rtl"==getComputedStyle(t.dom).direction?"rtl":"ltr"}function nn(t,e,r){let i=t.state.selection;if(i instanceof Xe&&!i.empty||r.indexOf("s")>-1)return!1;if(Lr&&r.indexOf("m")>-1)return!1;let{$from:n,$to:s}=i;if(!n.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let r=Gi(t.state,e);if(r&&r instanceof tr)return Zi(t,r)}if(!n.parent.inlineContent){let r=e<0?n:s,o=i instanceof rr?Ge.near(r,e):Ge.findFrom(r,e);return!!o&&Zi(t,o)}return!1}function sn(t,e){if(!(t.state.selection instanceof Xe))return!0;let{$head:r,$anchor:i,empty:n}=t.state.selection;if(!r.sameParent(i))return!0;if(!n)return!1;if(t.endOfTextblock(e>0?"forward":"backward"))return!0;let s=!r.textOffset&&(e<0?r.nodeBefore:r.nodeAfter);if(s&&!s.isText){let i=t.state.tr;return e<0?i.delete(r.pos-s.nodeSize,r.pos):i.delete(r.pos,r.pos+s.nodeSize),t.dispatch(i),!0}return!1}function on(t,e,r){t.domObserver.stop(),e.contentEditable=r,t.domObserver.start()}function ln(t,e){t.someProp("transformCopied",(r=>{e=r(e,t)}));let r=[],{content:i,openStart:n,openEnd:s}=e;for(;n>1&&s>1&&1==i.childCount&&1==i.firstChild.childCount;){n--,s--;let t=i.firstChild;r.push(t.type.name,t.attrs!=t.type.defaultAttrs?t.attrs:null),i=t.content}let o=t.someProp("clipboardSerializer")||te.fromSchema(t.state.schema),l=bn(),u=l.createElement("div");u.appendChild(o.serializeFragment(i,{document:l}));let h,a=u.firstChild,f=0;for(;a&&1==a.nodeType&&(h=mn[a.nodeName.toLowerCase()]);){for(let t=h.length-1;t>=0;t--){let e=l.createElement(h[t]);for(;u.firstChild;)e.appendChild(u.firstChild);u.appendChild(e),f++}a=u.firstChild}return a&&1==a.nodeType&&a.setAttribute("data-pm-slice",`${n} ${s}${f?` -${f}`:""} ${JSON.stringify(r)}`),{dom:u,text:t.someProp("clipboardTextSerializer",(r=>r(e,t)))||e.content.textBetween(0,e.content.size,"\n\n"),slice:e}}function un(t,e,r,i,n){let s,o,l=n.parent.type.spec.code;if(!r&&!e)return null;let u=e&&(i||l||!r);if(u){if(t.someProp("transformPastedText",(r=>{e=r(e,l||i,t)})),l)return e?new st(Q.from(t.state.schema.text(e.replace(/\r\n?/g,"\n"))),0,0):st.empty;let r=t.someProp("clipboardTextParser",(r=>r(e,n,i,t)));if(r)o=r;else{let r=n.marks(),{schema:i}=t.state,o=te.fromSchema(i);s=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach((t=>{let e=s.appendChild(document.createElement("p"));t&&e.appendChild(o.serializeNode(i.text(t,r)))}))}}else t.someProp("transformPastedHTML",(e=>{r=e(r,t)})),s=function(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let r,i=bn().createElement("div"),n=/<([a-z][^>\s]+)/i.exec(t);if((r=n&&mn[n[1].toLowerCase()])&&(t=r.map((t=>"<"+t+">")).join("")+t+r.map((t=>"</"+t+">")).reverse().join("")),i.innerHTML=function(t){let e=window.trustedTypes;return e?(wn||(wn=e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})),wn.createHTML(t)):t}(t),r)for(let t=0;t<r.length;t++)i=i.querySelector(r[t])||i;return i}(r),Vr&&function(t){let e=t.querySelectorAll(jr?"span:not([class]):not([style])":"span.Apple-converted-space");for(let r=0;r<e.length;r++){let i=e[r];1==i.childNodes.length&&" "==i.textContent&&i.parentNode&&i.parentNode.replaceChild(t.ownerDocument.createTextNode(" "),i)}}(s);let h=s&&s.querySelector("[data-pm-slice]"),a=h&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(h.getAttribute("data-pm-slice")||"");if(a&&a[3])for(let t=+a[3];t>0;t--){let t=s.firstChild;for(;t&&1!=t.nodeType;)t=t.nextSibling;if(!t)break;s=t}if(!o){let e=t.someProp("clipboardParser")||t.someProp("domParser")||Ut.fromSchema(t.state.schema);o=e.parseSlice(s,{preserveWhitespace:!(!u&&!a),context:n,ruleFromNode:t=>"BR"!=t.nodeName||t.nextSibling||!t.parentNode||hn.test(t.parentNode.nodeName)?null:{ignore:!0}})}if(a)o=function(t,e){if(!t.size)return t;let r,i=t.content.firstChild.type.schema;try{r=JSON.parse(e)}catch(e){return t}let{content:n,openStart:s,openEnd:o}=t;for(let t=r.length-2;t>=0;t-=2){let e=i.nodes[r[t]];if(!e||e.hasRequiredAttrs())break;n=Q.from(e.create(r[t+1],n)),s++,o++}return new st(n,s,o)}(pn(o,+a[1],+a[2]),a[4]);else if(o=st.maxOpen(function(t,e){if(t.childCount<2)return t;for(let r=e.depth;r>=0;r--){let i,n=e.node(r).contentMatchAt(e.index(r)),s=[];if(t.forEach((t=>{if(!s)return;let e,r=n.findWrapping(t.type);if(!r)return s=null;if(e=s.length&&i.length&&fn(r,i,t,s[s.length-1],0))s[s.length-1]=e;else{s.length&&(s[s.length-1]=cn(s[s.length-1],i.length));let e=an(t,r);s.push(e),n=n.matchType(e.type),i=r}})),s)return Q.from(s)}return t}(o.content,n),!0),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=pn(o,t,e)}return t.someProp("transformPasted",(e=>{o=e(o,t)})),o}const hn=/^(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 an(t,e,r=0){for(let i=e.length-1;i>=r;i--)t=e[i].create(null,Q.from(t));return t}function fn(t,e,r,i,n){if(n<t.length&&n<e.length&&t[n]==e[n]){let s=fn(t,e,r,i.lastChild,n+1);if(s)return i.copy(i.content.replaceChild(i.childCount-1,s));if(i.contentMatchAt(i.childCount).matchType(n==t.length-1?r.type:t[n+1]))return i.copy(i.content.append(Q.from(an(r,t,n+1))))}}function cn(t,e){if(0==e)return t;let r=t.content.replaceChild(t.childCount-1,cn(t.lastChild,e-1)),i=t.contentMatchAt(t.childCount).fillBefore(Q.empty,!0);return t.copy(r.append(i))}function dn(t,e,r,i,n,s){let o=e<0?t.firstChild:t.lastChild,l=o.content;return t.childCount>1&&(s=0),n<i-1&&(l=dn(l,e,r,i,n+1,s)),n>=r&&(l=e<0?o.contentMatchAt(0).fillBefore(l,s<=n).append(l):l.append(o.contentMatchAt(o.childCount).fillBefore(Q.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,o.copy(l))}function pn(t,e,r){return e<t.openStart&&(t=new st(dn(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),r<t.openEnd&&(t=new st(dn(t.content,1,r,t.openEnd,0,0),t.openStart,r)),t}const mn={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 gn=null;function bn(){return gn||(gn=document.implementation.createHTMLDocument("title"))}let wn=null;const vn={},kn={},Dn={touchstart:!0,touchmove:!0};class yn{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:""},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function En(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function xn(t){t.someProp("handleDOMEvents",(e=>{for(let r in e)t.input.eventHandlers[r]||t.dom.addEventListener(r,t.input.eventHandlers[r]=e=>Fn(t,e))}))}function Fn(t,e){return t.someProp("handleDOMEvents",(r=>{let i=r[e.type];return!!i&&(i(t,e)||e.defaultPrevented)}))}function Mn(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let r=e.target;r!=t.dom;r=r.parentNode)if(!r||11==r.nodeType||r.pmViewDesc&&r.pmViewDesc.stopEvent(e))return!1;return!0}function An(t){return{left:t.clientX,top:t.clientY}}function Cn(t,e,r,i,n){if(-1==i)return!1;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,!0):e(t,r,s.node(i),s.before(i),n,!1))))return!0;return!1}function Sn(t,e){if(t.focused||t.focus(),t.state.selection.eq(e))return;let r=t.state.tr.setSelection(e);r.setMeta("pointer",!0),t.dispatch(r)}function On(t,e,r,i){return Cn(t,"handleDoubleClickOn",e,r,i)||t.someProp("handleDoubleClick",(r=>r(t,e,i)))}function $n(t,e,r,i){return Cn(t,"handleTripleClickOn",e,r,i)||t.someProp("handleTripleClick",(r=>r(t,e,i)))||function(t,e,r){if(0!=r.button)return!1;let i=t.state.doc;if(-1==e)return!!i.inlineContent&&(Sn(t,Xe.create(i,0,i.content.size)),!0);let n=i.resolve(e);for(let e=n.depth+1;e>0;e--){let r=e>n.depth?n.nodeAfter:n.node(e),s=n.before(e);if(r.inlineContent)Sn(t,Xe.create(i,s+1,s+1+r.content.size));else{if(!tr.isSelectable(r))continue;Sn(t,tr.create(i,s))}return!0}}(t,r,i)}function Bn(t){return qn(t)}kn.keydown=(t,e)=>{let r=e;if(t.input.shiftKey=16==r.keyCode||r.shiftKey,!_n(t,r)&&(t.input.lastKeyCode=r.keyCode,t.input.lastKeyCodeTime=Date.now(),!Ur||!jr||13!=r.keyCode))if(229!=r.keyCode&&t.domObserver.forceFlush(),!Pr||13!=r.keyCode||r.ctrlKey||r.altKey||r.metaKey)t.someProp("handleKeyDown",(e=>e(t,r)))||function(t,e){let r=e.keyCode,i=function(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}(e);if(8==r||Lr&&72==r&&"c"==i)return sn(t,-1)||Qi(t,-1);if(46==r&&!e.shiftKey||Lr&&68==r&&"c"==i)return sn(t,1)||Qi(t,1);if(13==r||27==r)return!0;if(37==r||Lr&&66==r&&"c"==i){let e=37==r?"ltr"==rn(t,t.state.selection.from)?-1:1:-1;return Ki(t,e,i)||Qi(t,e)}if(39==r||Lr&&70==r&&"c"==i){let e=39==r?"ltr"==rn(t,t.state.selection.from)?1:-1:1;return Ki(t,e,i)||Qi(t,e)}return 38==r||Lr&&80==r&&"c"==i?nn(t,-1,i)||Qi(t,-1):40==r||Lr&&78==r&&"c"==i?function(t){if(!Ir||t.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:r}=t.domSelectionRange();if(e&&1==e.nodeType&&0==r&&e.firstChild&&"false"==e.firstChild.contentEditable){let r=e.firstChild;on(t,r,"true"),setTimeout((()=>on(t,r,"false")),20)}return!1}(t)||nn(t,1,i)||Qi(t,1):i==(Lr?"m":"c")&&(66==r||73==r||89==r||90==r)}(t,r)?r.preventDefault():En(t,"key");else{let e=Date.now();t.input.lastIOSEnter=e,t.input.lastIOSEnterFallbackTimeout=setTimeout((()=>{t.input.lastIOSEnter==e&&(t.someProp("handleKeyDown",(e=>e(t,Ar(13,"Enter")))),t.input.lastIOSEnter=0)}),200)}},kn.keyup=(t,e)=>{16==e.keyCode&&(t.input.shiftKey=!1)},kn.keypress=(t,e)=>{let r=e;if(_n(t,r)||!r.charCode||r.ctrlKey&&!r.altKey||Lr&&r.metaKey)return;if(t.someProp("handleKeyPress",(e=>e(t,r))))return void r.preventDefault();let i=t.state.selection;if(!(i instanceof Xe&&i.$from.sameParent(i.$to))){let e=String.fromCharCode(r.charCode);/[\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()}};const Rn=Lr?"metaKey":"ctrlKey";vn.mousedown=(t,e)=>{let r=e;t.input.shiftKey=r.shiftKey;let i=Bn(t),n=Date.now(),s="singleClick";n-t.input.lastClick.time<500&&function(t,e){let r=e.x-t.clientX,i=e.y-t.clientY;return r*r+i*i<100}(r,t.input.lastClick)&&!r[Rn]&&("singleClick"==t.input.lastClick.type?s="doubleClick":"doubleClick"==t.input.lastClick.type&&(s="tripleClick")),t.input.lastClick={time:n,x:r.clientX,y:r.clientY,type:s};let o=t.posAtCoords(An(r));o&&("singleClick"==s?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new Nn(t,o,r,!!i)):("doubleClick"==s?On:$n)(t,o.pos,o.inside,r)?r.preventDefault():En(t,"pointer"))};class Nn{constructor(t,e,r,i){let n,s;if(this.view=t,this.pos=e,this.event=r,this.flushed=i,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=t.state.doc,this.selectNode=!!r[Rn],this.allowDefault=r.shiftKey,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 o=i?null:r.target,l=o?t.docView.nearestDesc(o,!0):null;this.target=l&&1==l.dom.nodeType?l.dom:null;let{selection:u}=t.state;(0==r.button&&n.type.spec.draggable&&!1!==n.type.spec.selectable||u instanceof tr&&u.from<=s&&u.to>s)&&(this.mightDrag={node:n,pos:s,addAttr:!(!this.target||this.target.draggable),setUneditable:!(!this.target||!Tr||this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout((()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")}),20),this.view.domObserver.start()),t.root.addEventListener("mouseup",this.up=this.up.bind(this)),t.root.addEventListener("mousemove",this.move=this.move.bind(this)),En(t,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout((()=>ji(this.view))),this.view.input.mouseDown=null}up(t){if(this.done(),!this.view.dom.contains(t.target))return;let e=this.pos;this.view.state.doc!=this.startDoc&&(e=this.view.posAtCoords(An(t))),this.updateAllowDefault(t),this.allowDefault||!e?En(this.view,"pointer"):function(t,e,r,i,n){return Cn(t,"handleClickOn",e,r,i)||t.someProp("handleClick",(r=>r(t,e,i)))||(n?function(t,e){if(-1==e)return!1;let r,i,n=t.state.selection;n instanceof tr&&(r=n.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(tr.isSelectable(e)){i=r&&n.$from.depth>0&&t>=n.$from.depth&&s.before(n.$from.depth+1)==n.$from.pos?s.before(n.$from.depth):s.before(t);break}}return null!=i&&(Sn(t,tr.create(t.state.doc,i)),!0)}(t,r):function(t,e){if(-1==e)return!1;let r=t.state.doc.resolve(e),i=r.nodeAfter;return!!(i&&i.isAtom&&tr.isSelectable(i))&&(Sn(t,new tr(r)),!0)}(t,r))}(this.view,e.pos,e.inside,t,this.selectNode)?t.preventDefault():0==t.button&&(this.flushed||Ir&&this.mightDrag&&!this.mightDrag.node.isAtom||jr&&!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)?(Sn(this.view,Ge.near(this.view.state.doc.resolve(e.pos))),t.preventDefault()):En(this.view,"pointer")}move(t){this.updateAllowDefault(t),En(this.view,"pointer"),0==t.buttons&&this.done()}updateAllowDefault(t){!this.allowDefault&&(Math.abs(this.event.x-t.clientX)>4||Math.abs(this.event.y-t.clientY)>4)&&(this.allowDefault=!0)}}function _n(t,e){return!!t.composing||!!(Ir&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500)&&(t.input.compositionEndedAt=-2e8,!0)}vn.touchstart=t=>{t.input.lastTouch=Date.now(),Bn(t),En(t,"pointer")},vn.touchmove=t=>{t.input.lastTouch=Date.now(),En(t,"pointer")},vn.contextmenu=t=>Bn(t);const Tn=Ur?5e3:-1;function zn(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout((()=>qn(t)),e))}function jn(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=function(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function qn(t,e=!1){if(!(Ur&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),jn(t),e||t.docView&&t.docView.dirty){let r=Ti(t);return r&&!r.eq(t.state.selection)?t.dispatch(t.state.tr.setSelection(r)):!t.markCursor&&!e||t.state.selection.empty?t.updateState(t.state):t.dispatch(t.state.tr.deleteSelection()),!0}return!1}}kn.compositionstart=kn.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,r=e.selection.$to;if(e.selection instanceof Xe&&(e.storedMarks||!r.textOffset&&r.parentOffset&&r.nodeBefore.marks.some((t=>!1===t.type.spec.inclusive))))t.markCursor=t.state.storedMarks||r.marks(),qn(t,!0),t.markCursor=null;else if(qn(t,!e.selection.empty),Tr&&e.selection.empty&&r.parentOffset&&!r.textOffset&&r.nodeBefore.marks.length){let e=t.domSelectionRange();for(let r=e.focusNode,i=e.focusOffset;r&&1==r.nodeType&&0!=i;){let e=i<0?r.lastChild:r.childNodes[i-1];if(!e)break;if(3==e.nodeType){let r=t.domSelection();r&&r.collapse(e,e.nodeValue.length);break}r=e,i=-1}}t.input.composing=!0}zn(t,Tn)},kn.compositionend=(t,e)=>{t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=e.timeStamp,t.input.compositionPendingChanges=t.domObserver.pendingRecords().length?t.input.compositionID:0,t.input.compositionNode=null,t.input.compositionPendingChanges&&Promise.resolve().then((()=>t.domObserver.flush())),t.input.compositionID++,zn(t,20))};const In=Nr&&_r<15||Pr&&Hr<604;function Pn(t,e,r,i,n){let s=un(t,e,r,i,t.state.selection.$from);if(t.someProp("handlePaste",(e=>e(t,n,s||st.empty))))return!0;if(!s)return!1;let o=function(t){return 0==t.openStart&&0==t.openEnd&&1==t.content.childCount?t.content.firstChild:null}(s),l=o?t.state.tr.replaceSelectionWith(o,i):t.state.tr.replaceSelection(s);return t.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Ln(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," "):""}vn.copy=kn.cut=(t,e)=>{let r=e,i=t.state.selection,n="cut"==r.type;if(i.empty)return;let s=In?null:r.clipboardData,o=i.content(),{dom:l,text:u}=ln(t,o);s?(r.preventDefault(),s.clearData(),s.setData("text/html",l.innerHTML),s.setData("text/plain",u)):function(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((()=>{r.parentNode&&r.parentNode.removeChild(r),t.focus()}),50)}(t,l),n&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))},kn.paste=(t,e)=>{let r=e;if(t.composing&&!Ur)return;let i=In?null:r.clipboardData,n=t.input.shiftKey&&45!=t.input.lastKeyCode;i&&Pn(t,Ln(i),i.getData("text/html"),n,r)?r.preventDefault():function(t,e){if(!t.dom.parentNode)return;let r=t.input.shiftKey||t.state.selection.$from.parent.type.spec.code,i=t.dom.parentNode.appendChild(document.createElement(r?"textarea":"div"));r||(i.contentEditable="true"),i.style.cssText="position: fixed; left: -10000px; top: 10px",i.focus();let n=t.input.shiftKey&&45!=t.input.lastKeyCode;setTimeout((()=>{t.focus(),i.parentNode&&i.parentNode.removeChild(i),r?Pn(t,i.value,null,n,e):Pn(t,i.textContent,i.innerHTML,n,e)}),50)}(t,r)};class Jn{constructor(t,e,r){this.slice=t,this.move=e,this.node=r}}const Un=Lr?"altKey":"ctrlKey";vn.dragstart=(t,e)=>{let r=e,i=t.input.mouseDown;if(i&&i.done(),!r.dataTransfer)return;let n,s=t.state.selection,o=s.empty?null:t.posAtCoords(An(r));if(o&&o.pos>=s.from&&o.pos<=(s instanceof tr?s.to-1:s.to));else if(i&&i.mightDrag)n=tr.create(t.state.doc,i.mightDrag.pos);else if(r.target&&1==r.target.nodeType){let e=t.docView.nearestDesc(r.target,!0);e&&e.node.type.spec.draggable&&e!=t.docView&&(n=tr.create(t.state.doc,e.posBefore))}let l=(n||t.state.selection).content(),{dom:u,text:h,slice:a}=ln(t,l);(!r.dataTransfer.files.length||!jr||qr>120)&&r.dataTransfer.clearData(),r.dataTransfer.setData(In?"Text":"text/html",u.innerHTML),r.dataTransfer.effectAllowed="copyMove",In||r.dataTransfer.setData("text/plain",h),t.dragging=new Jn(a,!r[Un],n)},vn.dragend=t=>{let e=t.dragging;window.setTimeout((()=>{t.dragging==e&&(t.dragging=null)}),50)},kn.dragover=kn.dragenter=(t,e)=>e.preventDefault(),kn.drop=(t,e)=>{let r=e,i=t.dragging;if(t.dragging=null,!r.dataTransfer)return;let n=t.posAtCoords(An(r));if(!n)return;let s=t.state.doc.resolve(n.pos),o=i&&i.slice;o?t.someProp("transformPasted",(e=>{o=e(o,t)})):o=un(t,Ln(r.dataTransfer),In?null:r.dataTransfer.getData("text/html"),!1,s);let l=!(!i||r[Un]);if(t.someProp("handleDrop",(e=>e(t,r,o||st.empty,l))))return void r.preventDefault();if(!o)return;r.preventDefault();let u=o?Be(t.state.doc,s.pos,o):s.pos;null==u&&(u=s.pos);let h=t.state.tr;if(l){let{node:t}=i;t?t.replace(h):h.deleteSelection()}let a=h.mapping.map(u),f=0==o.openStart&&0==o.openEnd&&1==o.content.childCount,c=h.doc;if(f?h.replaceRangeWith(a,a,o.content.firstChild):h.replaceRange(a,a,o),h.doc.eq(c))return;let d=h.doc.resolve(a);if(f&&tr.isSelectable(o.content.firstChild)&&d.nodeAfter&&d.nodeAfter.sameMarkup(o.content.firstChild))h.setSelection(new tr(d));else{let e=h.mapping.map(u);h.mapping.maps[h.mapping.maps.length-1].forEach(((t,r,i,n)=>e=n)),h.setSelection(Vi(t,d,h.doc.resolve(e)))}t.focus(),t.dispatch(h.setMeta("uiEvent","drop"))},vn.focus=t=>{t.input.lastFocus=Date.now(),t.focused||(t.domObserver.stop(),t.dom.classList.add("ProseMirror-focused"),t.domObserver.start(),t.focused=!0,setTimeout((()=>{t.docView&&t.hasFocus()&&!t.domObserver.currentSelection.eq(t.domSelectionRange())&&ji(t)}),20))},vn.blur=(t,e)=>{let r=e;t.focused&&(t.domObserver.stop(),t.dom.classList.remove("ProseMirror-focused"),t.domObserver.start(),r.relatedTarget&&t.dom.contains(r.relatedTarget)&&t.domObserver.currentSelection.clear(),t.focused=!1)},vn.beforeinput=(t,e)=>{if(jr&&Ur&&"deleteContentBackward"==e.inputType){t.domObserver.flushSoon();let{domChangeCount:e}=t.input;setTimeout((()=>{if(t.input.domChangeCount!=e)return;if(t.dom.blur(),t.focus(),t.someProp("handleKeyDown",(e=>e(t,Ar(8,"Backspace")))))return;let{$cursor:r}=t.state.selection;r&&r.pos>0&&t.dispatch(t.state.tr.delete(r.pos-1,r.pos).scrollIntoView())}),50)}};for(let t in kn)vn[t]=kn[t];function Vn(t,e){if(t==e)return!0;for(let r in t)if(t[r]!==e[r])return!1;for(let r in e)if(!(r in t))return!1;return!0}class Hn{constructor(t,e){this.toDOM=t,this.spec=e||Yn,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 Zn(n-r,n-r,this)}valid(){return!0}eq(t){return this==t||t instanceof Hn&&(this.spec.key&&this.spec.key==t.spec.key||this.toDOM==t.toDOM&&Vn(this.spec,t.spec))}destroy(t){this.spec.destroy&&this.spec.destroy(t)}}class Wn{constructor(t,e){this.attrs=t,this.spec=e||Yn}map(t,e,r,i){let n=t.map(e.from+i,this.spec.inclusiveStart?-1:1)-r,s=t.map(e.to+i,this.spec.inclusiveEnd?1:-1)-r;return n>=s?null:new Zn(n,s,this)}valid(t,e){return e.from<e.to}eq(t){return this==t||t instanceof Wn&&Vn(this.attrs,t.attrs)&&Vn(this.spec,t.spec)}static is(t){return t.type instanceof Wn}destroy(){}}class Gn{constructor(t,e){this.attrs=t,this.spec=e||Yn}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);return s.deleted||s.pos<=n.pos?null:new Zn(n.pos-r,s.pos-r,this)}valid(t,e){let r,{index:i,offset:n}=t.content.findIndex(e.from);return n==e.from&&!(r=t.child(i)).isText&&n+r.nodeSize==e.to}eq(t){return this==t||t instanceof Gn&&Vn(this.attrs,t.attrs)&&Vn(this.spec,t.spec)}destroy(){}}class Zn{constructor(t,e,r){this.from=t,this.to=e,this.type=r}copy(t,e){return new Zn(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 Zn(t,t,new Hn(e,r))}static inline(t,e,r,i){return new Zn(t,e,new Wn(r,i))}static node(t,e,r,i){return new Zn(t,e,new Gn(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof Wn}get widget(){return this.type instanceof Hn}}const Kn=[],Yn={};class Xn{constructor(t,e){this.local=t.length?t:Kn,this.children=e.length?e:Kn}static create(t,e){return e.length?ns(e,t,0,Yn):Qn}find(t,e,r){let i=[];return this.findInner(null==t?0:t,null==e?1e9:e,i,0,r),i}findInner(t,e,r,i,n){for(let s=0;s<this.local.length;s++){let o=this.local[s];o.from<=e&&o.to>=t&&(!n||n(o.spec))&&r.push(o.copy(o.from+i,o.to+i))}for(let s=0;s<this.children.length;s+=3)if(this.children[s]<e&&this.children[s+1]>t){let o=this.children[s]+1;this.children[s+2].findInner(t-o,e-o,r,i+o,n)}}map(t,e,r){return this==Qn||0==t.maps.length?this:this.mapInner(t,e,0,0,r||Yn)}mapInner(t,e,r,i,n){let s;for(let o=0;o<this.local.length;o++){let l=this.local[o].map(t,r,i);l&&l.type.valid(e,l)?(s||(s=[])).push(l):n.onRemove&&n.onRemove(this.local[o].spec)}return this.children.length?function(t,e,r,i,n,s,o){let l=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 o=s-n-(r-t);for(let n=0;n<l.length;n+=3){let s=l[n+1];if(s<0||t>s+e-i)continue;let u=l[n]+e-i;r>=u?l[n+1]=t<=u?-2:-1:t>=e&&o&&(l[n]+=o,l[n+1]+=o)}i+=o})),e=r.maps[t].map(e,-1)}let u=!1;for(let e=0;e<l.length;e+=3)if(l[e+1]<0){if(-2==l[e+1]){u=!0,l[e+1]=-1;continue}let h=r.map(t[e]+s),a=h-n;if(a<0||a>=i.content.size){u=!0;continue}let f=r.map(t[e+1]+s,-1)-n,{index:c,offset:d}=i.content.findIndex(a),p=i.maybeChild(c);if(p&&d==a&&d+p.nodeSize==f){let i=l[e+2].mapInner(r,p,h+1,t[e]+s+1,o);i!=Qn?(l[e]=a,l[e+1]=f,l[e+2]=i):(l[e+1]=-2,u=!0)}else u=!0}if(u){let u=function(t,e,r,i,n,s,o){function l(t,e){for(let s=0;s<t.local.length;s++){let l=t.local[s].map(i,n,e);l?r.push(l):o.onRemove&&o.onRemove(t.local[s].spec)}for(let r=0;r<t.children.length;r+=3)l(t.children[r+2],t.children[r]+e+1)}for(let r=0;r<t.length;r+=3)-1==t[r+1]&&l(t[r+2],e[r]+s+1);return r}(l,t,e,r,n,s,o),h=ns(u,i,0,o);e=h.local;for(let t=0;t<l.length;t+=3)l[t+1]<0&&(l.splice(t,3),t-=3);for(let t=0,e=0;t<h.children.length;t+=3){let r=h.children[t];for(;e<l.length&&l[e]<r;)e+=3;l.splice(e,0,h.children[t],h.children[t+1],h.children[t+2])}}return new Xn(e.sort(ss),l)}(this.children,s||[],t,e,r,i,n):s?new Xn(s.sort(ss),Kn):Qn}add(t,e){return e.length?this==Qn?Xn.create(t,e):this.addInner(t,e,0):this}addInner(t,e,r){let i,n=0;t.forEach(((t,s)=>{let o,l=s+r;if(o=rs(e,t,l)){for(i||(i=this.children.slice());n<i.length&&i[n]<s;)n+=3;i[n]==s?i[n+2]=i[n+2].addInner(t,o,l+1):i.splice(n,0,s,s+t.nodeSize,ns(o,t,l+1,Yn)),n+=3}}));let s=es(n?is(e):e,-r);for(let e=0;e<s.length;e++)s[e].type.valid(t,s[e])||s.splice(e--,1);return new Xn(s.length?this.local.concat(s).sort(ss):this.local,i||this.children)}remove(t){return 0==t.length||this==Qn?this: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,s=r[i]+e,o=r[i+1]+e;for(let e,r=0;r<t.length;r++)(e=t[r])&&e.from>s&&e.to<o&&(t[r]=null,(n||(n=[])).push(e));if(!n)continue;r==this.children&&(r=this.children.slice());let l=r[i+2].removeInner(n,s+1);l!=Qn?r[i+2]=l:(r.splice(i,3),i-=3)}if(i.length)for(let r,n=0;n<t.length;n++)if(r=t[n])for(let t=0;t<i.length;t++)i[t].eq(r,e)&&(i==this.local&&(i=this.local.slice()),i.splice(t--,1));return r==this.children&&i==this.local?this:i.length||r.length?new Xn(i,r):Qn}forChild(t,e){if(this==Qn)return this;if(e.isLeaf)return Xn.empty;let r,i;for(let e=0;e<this.children.length;e+=3)if(this.children[e]>=t){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 Wn){let t=Math.max(n,e.from)-n,r=Math.min(s,e.to)-n;t<r&&(i||(i=[])).push(e.copy(t,r))}}if(i){let t=new Xn(i.sort(ss),Kn);return r?new ts([t,r]):t}return r||Qn}eq(t){if(this==t)return!0;if(!(t instanceof Xn)||this.local.length!=t.local.length||this.children.length!=t.children.length)return!1;for(let e=0;e<this.local.length;e++)if(!this.local[e].eq(t.local[e]))return!1;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!1;return!0}locals(t){return ls(this.localsInner(t))}localsInner(t){if(this==Qn)return Kn;if(t.inlineContent||!this.local.some(Wn.is))return this.local;let e=[];for(let t=0;t<this.local.length;t++)this.local[t].type instanceof Wn||e.push(this.local[t]);return e}forEachSet(t){t(this)}}Xn.empty=new Xn([],[]),Xn.removeOverlap=ls;const Qn=Xn.empty;class ts{constructor(t){this.members=t}map(t,e){const r=this.members.map((r=>r.map(t,e,Yn)));return ts.from(r)}forChild(t,e){if(e.isLeaf)return Xn.empty;let r=[];for(let i=0;i<this.members.length;i++){let n=this.members[i].forChild(t,e);n!=Qn&&(n instanceof ts?r=r.concat(n.members):r.push(n))}return ts.from(r)}eq(t){if(!(t instanceof ts)||t.members.length!=this.members.length)return!1;for(let e=0;e<this.members.length;e++)if(!this.members[e].eq(t.members[e]))return!1;return!0}locals(t){let e,r=!0;for(let i=0;i<this.members.length;i++){let n=this.members[i].localsInner(t);if(n.length)if(e){r&&(e=e.slice(),r=!1);for(let t=0;t<n.length;t++)e.push(n[t])}else e=n}return e?ls(r?e:e.sort(ss)):Kn}static from(t){switch(t.length){case 0:return Qn;case 1:return t[0];default:return new ts(t.every((t=>t instanceof Xn))?t:t.reduce(((t,e)=>t.concat(e instanceof Xn?e:e.members)),[]))}}forEachSet(t){for(let e=0;e<this.members.length;e++)this.members[e].forEachSet(t)}}function es(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 Zn(n.from+e,n.to+e,n.type))}return r}function rs(t,e,r){if(e.isLeaf)return null;let i=r+e.nodeSize,n=null;for(let e,s=0;s<t.length;s++)(e=t[s])&&e.from>r&&e.to<i&&((n||(n=[])).push(e),t[s]=null);return n}function is(t){let e=[];for(let r=0;r<t.length;r++)null!=t[r]&&e.push(t[r]);return e}function ns(t,e,r,i){let n=[],s=!1;e.forEach(((e,o)=>{let l=rs(t,e,o+r);if(l){s=!0;let t=ns(l,e,r+o+1,i);t!=Qn&&n.push(o,o+e.nodeSize,t)}}));let o=es(s?is(t):t,-r).sort(ss);for(let t=0;t<o.length;t++)o[t].type.valid(e,o[t])||(i.onRemove&&i.onRemove(o[t].spec),o.splice(t--,1));return o.length||n.length?new Xn(o,n):Qn}function ss(t,e){return t.from-e.from||t.to-e.to}function ls(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){s.from<i.to&&(e==t&&(e=t.slice()),e[r]=i.copy(i.from,s.from),us(e,n,i.copy(s.from,i.to)));break}s.to!=i.to&&(e==t&&(e=t.slice()),e[n]=s.copy(s.from,i.to),us(e,n+1,s.copy(i.to,s.to)))}}return e}function us(t,e,r){for(;e<t.length&&ss(r,t[e])>0;)e++;t.splice(e,0,r)}function hs(t){let e=[];return t.someProp("decorations",(r=>{let i=r(t.state);i&&i!=Qn&&e.push(i)})),t.cursorWrapper&&e.push(Xn.create(t.state.doc,[t.cursorWrapper.deco])),ts.from(e)}const as={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},fs=Nr&&_r<=11;class cs{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 ds{constructor(t,e){this.view=t,this.handleDOMChange=e,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new cs,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver((t=>{for(let e=0;e<t.length;e++)this.queue.push(t[e]);Nr&&_r<=11&&t.some((t=>"childList"==t.type&&t.removedNodes.length||"characterData"==t.type&&t.oldValue.length>t.target.nodeValue.length))?this.flushSoon():this.flush()})),fs&&(this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout((()=>{this.flushingSoon=-1,this.flush()}),20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,as)),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()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout((()=>this.suppressingSelectionUpdates=!1),50)}onSelectionChange(){if(Hi(this.view)){if(this.suppressingSelectionUpdates)return ji(this.view);if(Nr&&_r<=11&&!this.view.state.selection.empty){let t=this.view.domSelectionRange();if(t.focusNode&&Dr(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!0;let e,r=new Set;for(let e=t.focusNode;e;e=wr(e))r.add(e);for(let i=t.anchorNode;i;i=wr(i))if(r.has(i)){e=i;break}let i=e&&this.view.docView.nearestDesc(e);return i&&i.ignoreMutation({type:"selection",target:3==e.nodeType?e.parentNode:e})?(this.setCurSelection(),!0):void 0}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();e.length&&(this.queue=[]);let r=t.domSelectionRange(),i=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&Hi(t)&&!this.ignoreSelectionChange(r),n=-1,s=-1,o=!1,l=[];if(t.editable)for(let t=0;t<e.length;t++){let r=this.registerMutation(e[t],l);r&&(n=n<0?r.from:Math.min(r.from,n),s=s<0?r.to:Math.max(r.to,s),r.typeOver&&(o=!0))}if(Tr&&l.length){let e=l.filter((t=>"BR"==t.nodeName));if(2==e.length){let[t,r]=e;t.parentNode&&t.parentNode.parentNode==r.parentNode?r.remove():t.remove()}else{let{focusNode:r}=this.currentSelection;for(let i of e){let e=i.parentNode;!e||"LI"!=e.nodeName||r&&bs(t,r)==e||i.remove()}}}let u=null;n<0&&i&&t.input.lastFocus>Date.now()-200&&Math.max(t.input.lastTouch,t.input.lastClick.time)<Date.now()-300&&Mr(r)&&(u=Ti(t))&&u.eq(Ge.near(t.state.doc.resolve(0),1))?(t.input.lastFocus=0,ji(t),this.currentSelection.set(r),t.scrollToSelection()):(n>-1||i)&&(n>-1&&(t.docView.markDirty(n,s),function(t){if(!ps.has(t)&&(ps.set(t,null),-1!==["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace))){if(t.requiresGeckoHackNode=Tr,ms)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."),ms=!0}}(t)),this.handleDOMChange(n,s,o,l),t.docView&&t.docView.dirty?t.updateState(t.state):this.currentSelection.eq(r)||ji(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("attributes"==t.type&&(r==this.view.docView||"contenteditable"==t.attributeName||"style"==t.attributeName&&!t.oldValue&&!t.target.getAttribute("style")))return null;if(!r||r.ignoreMutation(t))return null;if("childList"==t.type){for(let r=0;r<t.addedNodes.length;r++){let i=t.addedNodes[r];e.push(i),3==i.nodeType&&(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(Nr&&_r<=11&&t.addedNodes.length)for(let e=0;e<t.addedNodes.length;e++){let{previousSibling:r,nextSibling:s}=t.addedNodes[e];(!r||Array.prototype.indexOf.call(t.addedNodes,r)<0)&&(i=r),(!s||Array.prototype.indexOf.call(t.addedNodes,s)<0)&&(n=s)}let s=i&&i.parentNode==t.target?br(i)+1:0,o=r.localPosFromDOM(t.target,s,-1),l=n&&n.parentNode==t.target?br(n):t.target.childNodes.length;return{from:o,to:r.localPosFromDOM(t.target,l,1)}}return"attributes"==t.type?{from:r.posAtStart-r.border,to:r.posAtEnd+r.border}:(this.lastChangedTextNode=t.target,{from:r.posAtStart,to:r.posAtEnd,typeOver:t.target.nodeValue==t.oldValue})}}let ps=new WeakMap,ms=!1;function gs(t,e){let r=e.startContainer,i=e.startOffset,n=e.endContainer,s=e.endOffset,o=t.domAtPos(t.state.selection.anchor);return Dr(o.node,o.offset,n,s)&&([r,i,n,s]=[n,s,r,i]),{anchorNode:r,anchorOffset:i,focusNode:n,focusOffset:s}}function bs(t,e){for(let r=e.parentNode;r&&r!=t.dom;r=r.parentNode){let e=t.docView.nearestDesc(r,!0);if(e&&e.node.isBlock)return r}return null}function ws(t){let e=t.pmViewDesc;if(e)return e.parseRule();if("BR"==t.nodeName&&t.parentNode){if(Ir&&/^(ul|ol)$/i.test(t.parentNode.nodeName)){let t=document.createElement("div");return t.appendChild(document.createElement("li")),{skip:t}}if(t.parentNode.lastChild==t||Ir&&/^(tr|table)$/i.test(t.parentNode.nodeName))return{ignore:!0}}else if("IMG"==t.nodeName&&t.getAttribute("mark-placeholder"))return{ignore:!0};return null}const vs=/^(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 ks(t,e,r){return Math.max(r.anchor,r.head)>e.content.size?null:Vi(t,e.resolve(r.anchor),e.resolve(r.head))}function Ds(t,e,r){let i=t.depth,n=e?t.end():t.pos;for(;i>0&&(e||t.indexAfter(i)==t.node(i).childCount);)i--,n++,e=!1;if(r){let e=t.node(i).maybeChild(t.indexAfter(i));for(;e&&!e.isLeaf;)e=e.firstChild,n++}return n}function ys(t){if(2!=t.length)return!1;let e=t.charCodeAt(0),r=t.charCodeAt(1);return e>=56320&&e<=57343&&r>=55296&&r<=56319}class Es{constructor(t,e){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new yn,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=e,this.state=e.state,this.directPlugins=e.plugins||[],this.directPlugins.forEach(Cs),this.dispatch=this.dispatch.bind(this),this.dom=t&&t.mount||document.createElement("div"),t&&(t.appendChild?t.appendChild(this.dom):"function"==typeof t?t(this.dom):t.mount&&(this.mounted=!0)),this.editable=Ms(this),Fs(this),this.nodeViews=As(this),this.docView=ki(this.state.doc,xs(this),hs(this),this.dom,this),this.domObserver=new ds(this,((t,e,r,i)=>function(t,e,r,i,n){let s=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let e=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,r=Ti(t,e);if(r&&!t.state.selection.eq(r)){if(jr&&Ur&&13===t.input.lastKeyCode&&Date.now()-100<t.input.lastKeyCodeTime&&t.someProp("handleKeyDown",(e=>e(t,Ar(13,"Enter")))))return;let i=t.state.tr.setSelection(r);"pointer"==e?i.setMeta("pointer",!0):"key"==e&&i.scrollIntoView(),s&&i.setMeta("composition",s),t.dispatch(i)}return}let o=t.state.doc.resolve(e),l=o.sharedDepth(r);e=o.before(l+1),r=t.state.doc.resolve(r).after(l+1);let u,h,a=t.state.selection,f=function(t,e,r){let i,{node:n,fromOffset:s,toOffset:o,from:l,to:u}=t.docView.parseRange(e,r),h=t.domSelectionRange(),a=h.anchorNode;if(a&&t.dom.contains(1==a.nodeType?a:a.parentNode)&&(i=[{node:a,offset:h.anchorOffset}],Mr(h)||i.push({node:h.focusNode,offset:h.focusOffset})),jr&&8===t.input.lastKeyCode)for(let t=o;t>s;t--){let e=n.childNodes[t-1],r=e.pmViewDesc;if("BR"==e.nodeName&&!r){o=t;break}if(!r||r.size)break}let f=t.state.doc,c=t.someProp("domParser")||Ut.fromSchema(t.state.schema),d=f.resolve(l),p=null,m=c.parse(n,{topNode:d.parent,topMatch:d.parent.contentMatchAt(d.index()),topOpen:!0,from:s,to:o,preserveWhitespace:"pre"!=d.parent.type.whitespace||"full",findPositions:i,ruleFromNode:ws,context:d});if(i&&null!=i[0].pos){let t=i[0].pos,e=i[1]&&i[1].pos;null==e&&(e=t),p={anchor:t+l,head:e+l}}return{doc:m,sel:p,from:l,to:u}}(t,e,r),c=t.state.doc,d=c.slice(f.from,f.to);8===t.input.lastKeyCode&&Date.now()-100<t.input.lastKeyCodeTime?(u=t.state.selection.to,h="end"):(u=t.state.selection.from,h="start"),t.input.lastKeyCode=null;let p=function(t,e,r,i,n){let s=t.findDiffStart(e,r);if(null==s)return null;let{a:o,b:l}=t.findDiffEnd(e,r+t.size,r+e.size);if("end"==n&&(i-=o+Math.max(0,s-Math.min(o,l))-s),o<s&&t.size<e.size){let t=i<=s&&i>=o?s-i:0;s-=t,s&&s<e.size&&ys(e.textBetween(s-1,s+1))&&(s+=t?1:-1),l=s+(l-o),o=s}else if(l<s){let e=i<=s&&i>=l?s-i:0;s-=e,s&&s<t.size&&ys(t.textBetween(s-1,s+1))&&(s+=e?1:-1),o=s+(o-l),l=s}return{start:s,endA:o,endB:l}}(d.content,f.doc.content,f.from,u,h);if(p&&t.input.domChangeCount++,(Pr&&t.input.lastIOSEnter>Date.now()-225||Ur)&&n.some((t=>1==t.nodeType&&!vs.test(t.nodeName)))&&(!p||p.endA>=p.endB)&&t.someProp("handleKeyDown",(e=>e(t,Ar(13,"Enter")))))return void(t.input.lastIOSEnter=0);if(!p){if(!(i&&a instanceof Xe&&!a.empty&&a.$head.sameParent(a.$anchor))||t.composing||f.sel&&f.sel.anchor!=f.sel.head){if(f.sel){let e=ks(t,t.state.doc,f.sel);if(e&&!e.eq(t.state.selection)){let r=t.state.tr.setSelection(e);s&&r.setMeta("composition",s),t.dispatch(r)}}return}p={start:a.from,endA:a.to,endB:a.to}}t.state.selection.from<t.state.selection.to&&p.start==p.endB&&t.state.selection instanceof Xe&&(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: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)),Nr&&_r<=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,g=f.doc.resolveNoCache(p.start-f.from),b=f.doc.resolveNoCache(p.endB-f.from),w=c.resolve(p.start),v=g.sameParent(b)&&g.parent.inlineContent&&w.end()>=p.endA;if((Pr&&t.input.lastIOSEnter>Date.now()-225&&(!v||n.some((t=>"DIV"==t.nodeName||"P"==t.nodeName)))||!v&&g.pos<f.doc.content.size&&!g.sameParent(b)&&(m=Ge.findFrom(f.doc.resolve(g.pos+1),1,!0))&&m.head==b.pos)&&t.someProp("handleKeyDown",(e=>e(t,Ar(13,"Enter")))))return void(t.input.lastIOSEnter=0);if(t.state.selection.anchor>p.start&&function(t,e,r,i,n){if(r-e<=n.pos-i.pos||Ds(i,!0,!1)<n.pos)return!1;let s=t.resolve(e);if(!i.parent.isTextblock){let t=s.nodeAfter;return null!=t&&r==e+t.nodeSize}if(s.parentOffset<s.parent.content.size||!s.parent.isTextblock)return!1;let o=t.resolve(Ds(s,!0,!0));return!(!o.parent.isTextblock||o.pos>r||Ds(o,!0,!1)<r)&&i.parent.content.cut(i.parentOffset).eq(o.parent.content)}(c,p.start,p.endA,g,b)&&t.someProp("handleKeyDown",(e=>e(t,Ar(8,"Backspace")))))return void(Ur&&jr&&t.domObserver.suppressSelectionUpdates());jr&&p.endB==p.start&&(t.input.lastChromeDelete=Date.now()),Ur&&!v&&g.start()!=b.start()&&0==b.parentOffset&&g.depth==b.depth&&f.sel&&f.sel.anchor==f.sel.head&&f.sel.head==p.endA&&(p.endB-=2,b=f.doc.resolveNoCache(p.endB-f.from),setTimeout((()=>{t.someProp("handleKeyDown",(function(e){return e(t,Ar(13,"Enter"))}))}),20));let k,D,y,E=p.start,x=p.endA;if(v)if(g.pos==b.pos)Nr&&_r<=11&&0==g.parentOffset&&(t.domObserver.suppressSelectionUpdates(),setTimeout((()=>ji(t)),20)),k=t.state.tr.delete(E,x),D=c.resolve(p.start).marksAcross(c.resolve(p.endA));else if(p.endA==p.endB&&(y=function(t,e){let r,i,n,s=t.firstChild.marks,o=e.firstChild.marks,l=s,u=o;for(let t=0;t<o.length;t++)l=o[t].removeFromSet(l);for(let t=0;t<s.length;t++)u=s[t].removeFromSet(u);if(1==l.length&&0==u.length)i=l[0],r="add",n=t=>t.mark(i.addToSet(t.marks));else{if(0!=l.length||1!=u.length)return null;i=u[0],r="remove",n=t=>t.mark(i.removeFromSet(t.marks))}let h=[];for(let t=0;t<e.childCount;t++)h.push(n(e.child(t)));if(Q.from(h).eq(t))return{mark:i,type:r}}(g.parent.content.cut(g.parentOffset,b.parentOffset),w.parent.content.cut(w.parentOffset,p.endA-w.start()))))k=t.state.tr,"add"==y.type?k.addMark(E,x,y.mark):k.removeMark(E,x,y.mark);else if(g.parent.child(g.index()).isText&&g.index()==b.index()-(b.textOffset?0:1)){let e=g.parent.textBetween(g.parentOffset,b.parentOffset);if(t.someProp("handleTextInput",(r=>r(t,E,x,e))))return;k=t.state.tr.insertText(e,E,x)}if(k||(k=t.state.tr.replace(E,x,f.doc.slice(p.start-f.from,p.endB-f.from))),f.sel){let e=ks(t,k.doc,f.sel);e&&!(jr&&t.composing&&e.empty&&(p.start!=p.endB||t.input.lastChromeDelete<Date.now()-100)&&(e.head==E||e.head==k.mapping.map(x)-1)||Nr&&e.empty&&e.head==E)&&k.setSelection(e)}D&&k.ensureMarks(D),s&&k.setMeta("composition",s),t.dispatch(k.scrollIntoView())}(this,t,e,r,i))),this.domObserver.start(),function(t){for(let e in vn){let r=vn[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=e=>{!Mn(t,e)||Fn(t,e)||!t.editable&&e.type in kn||r(t,e)},Dn[e]?{passive:!0}:void 0)}Ir&&t.dom.addEventListener("input",(()=>null)),xn(t)}(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){t.handleDOMEvents!=this._props.handleDOMEvents&&xn(this);let e=this._props;this._props=t,t.plugins&&(t.plugins.forEach(Cs),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=!1,s=!1;t.storedMarks&&this.composing&&(jn(this),s=!0),this.state=t;let o=i.plugins!=t.plugins||this._props.plugins!=e.plugins;if(o||this._props.plugins!=e.plugins||this._props.nodeViews!=e.nodeViews){let t=As(this);(function(t,e){let r=0,i=0;for(let i in t){if(t[i]!=e[i])return!0;r++}for(let t in e)i++;return r!=i})(t,this.nodeViews)&&(this.nodeViews=t,n=!0)}(o||e.handleDOMEvents!=this._props.handleDOMEvents)&&xn(this),this.editable=Ms(this),Fs(this);let l=hs(this),u=xs(this),h=i.plugins==t.plugins||i.doc.eq(t.doc)?t.scrollToSelection>i.scrollToSelection?"to selection":"preserve":"reset",a=n||!this.docView.matchesNode(t.doc,u,l);!a&&t.selection.eq(i.selection)||(s=!0);let f="preserve"==h&&s&&null==this.dom.style.overflowAnchor&&function(t){let e,r,i=t.dom.getBoundingClientRect(),n=Math.max(0,i.top);for(let s=(i.left+i.right)/2,o=n+1;o<Math.min(innerHeight,i.bottom);o+=5){let i=t.root.elementFromPoint(s,o);if(!i||i==t.dom||!t.dom.contains(i))continue;let l=i.getBoundingClientRect();if(l.top>=n-20){e=i,r=l.top;break}}return{refDOM:e,refTop:r,stack:Yr(t.dom)}}(this);if(s){this.domObserver.stop();let e=a&&(Nr||jr)&&!this.composing&&!i.selection.empty&&!t.selection.empty&&function(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)}(i.selection,t.selection);if(a){let r=jr?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=function(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let r=function(t,e){for(;;){if(3==t.nodeType&&e)return t;if(1==t.nodeType&&e>0){if("false"==t.contentEditable)return null;e=xr(t=t.childNodes[e-1])}else{if(!t.parentNode||Fr(t))return null;e=br(t),t=t.parentNode}}}(e.focusNode,e.focusOffset),i=function(t,e){for(;;){if(3==t.nodeType&&e<t.nodeValue.length)return t;if(1==t.nodeType&&e<t.childNodes.length){if("false"==t.contentEditable)return null;t=t.childNodes[e],e=0}else{if(!t.parentNode||Fr(t))return null;e=br(t)+1,t=t.parentNode}}}(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;if(t.input.compositionNode==i){let t=r.pmViewDesc;if(t&&t.isText(r.nodeValue))return i}}return r||i}(this)),!n&&this.docView.update(t.doc,u,l,this)||(this.docView.updateOuterDeco(u),this.docView.destroy(),this.docView=ki(t.doc,u,l,this.dom,this)),r&&!this.trackWrites&&(e=!0)}e||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&function(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),r=t.domSelectionRange();return Dr(e.node,e.offset,r.anchorNode,r.anchorOffset)}(this))?ji(this,e):(Ji(this,t.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(i),(null===(r=this.dragging)||void 0===r?void 0:r.node)&&!i.doc.eq(t.doc)&&this.updateDraggedNode(this.dragging,i),"reset"==h?this.dom.scrollTop=0:"to selection"==h?this.scrollToSelection():f&&function({refDOM:t,refTop:e,stack:r}){let i=t?t.getBoundingClientRect().top:0;Xr(r,0==i?0:i-e)}(f)}scrollToSelection(){let t=this.domSelectionRange().focusNode;if(t&&this.dom.contains(1==t.nodeType?t:t.parentNode))if(this.someProp("handleScrollToSelection",(t=>t(this))));else if(this.state.selection instanceof tr){let e=this.docView.domAfterPos(this.state.selection.from);1==e.nodeType&&Kr(this,e.getBoundingClientRect(),t)}else Kr(this,this.coordsAtPos(this.state.selection.head,1),t)}destroyPluginViews(){let t;for(;t=this.pluginViews.pop();)t.destroy&&t.destroy()}updatePluginViews(t){if(t&&t.plugins==this.state.plugins&&this.directPlugins==this.prevDirectPlugins)for(let e=0;e<this.pluginViews.length;e++){let r=this.pluginViews[e];r.update&&r.update(this,t)}else{this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let t=0;t<this.directPlugins.length;t++){let e=this.directPlugins[t];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];e.spec.view&&this.pluginViews.push(e.spec.view(this))}}}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);(t>0&&this.state.doc.nodeAt(t))==r.node&&(i=t)}this.dragging=new Jn(t.slice,t.move,i<0?void 0:tr.create(this.state.doc,i))}someProp(t,e){let r,i=this._props&&this._props[t];if(null!=i&&(r=e?e(i):i))return r;for(let i=0;i<this.directPlugins.length;i++){let n=this.directPlugins[i].props[t];if(null!=n&&(r=e?e(n):n))return r}let n=this.state.plugins;if(n)for(let i=0;i<n.length;i++){let s=n[i].props[t];if(null!=s&&(r=e?e(s):s))return r}}hasFocus(){if(Nr){let t=this.root.activeElement;if(t==this.dom)return!0;if(!t||!this.dom.contains(t))return!1;for(;t&&this.dom!=t&&this.dom.contains(t);){if("false"==t.contentEditable)return!1;t=t.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&function(t){if(t.setActive)return t.setActive();if(Qr)return t.focus(Qr);let e=Yr(t);t.focus(null==Qr?{get preventScroll(){return Qr={preventScroll:!0},!0}}:void 0),Qr||(Qr=!1,Xr(e,0))}(this.dom),ji(this),this.domObserver.start()}get root(){let t=this._root;if(null==t)for(let t=this.dom.parentNode;t;t=t.parentNode)if(9==t.nodeType||11==t.nodeType&&t.host)return t.getSelection||(Object.getPrototypeOf(t).getSelection=()=>t.ownerDocument.getSelection()),this._root=t;return t||document}updateRoot(){this._root=null}posAtCoords(t){return ii(this,t)}coordsAtPos(t,e=1){return li(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(null==i)throw new RangeError("DOM position not inside the editor");return i}endOfTextblock(t,e){return function(t,e,r){return ci==e&&di==r?pi:(ci=e,di=r,pi="up"==r||"down"==r?function(t,e,r){let i=e.selection,n="up"==r?i.$from:i.$to;return ai(t,e,(()=>{let{node:e}=t.docView.domFromPos(n.pos,"up"==r?-1:1);for(;;){let r=t.docView.nearestDesc(e,!0);if(!r)break;if(r.node.isBlock){e=r.contentDOM||r.dom;break}e=r.dom.parentNode}let i=li(t,n.pos,1);for(let t=e.firstChild;t;t=t.nextSibling){let e;if(1==t.nodeType)e=t.getClientRects();else{if(3!=t.nodeType)continue;e=kr(t,0,t.nodeValue.length).getClientRects()}for(let t=0;t<e.length;t++){let n=e[t];if(n.bottom>n.top+1&&("up"==r?i.top-n.top>2*(n.bottom-i.top):n.bottom-i.bottom>2*(i.bottom-n.top)))return!1}}return!0}))}(t,e,r):function(t,e,r){let{$head:i}=e.selection;if(!i.parent.isTextblock)return!1;let n=i.parentOffset,s=!n,o=n==i.parent.content.size,l=t.domSelection();return l?fi.test(i.parent.textContent)&&l.modify?ai(t,e,(()=>{let{focusNode:e,focusOffset:n,anchorNode:s,anchorOffset:o}=t.domSelectionRange(),u=l.caretBidiLevel;l.modify("move",r,"character");let h=i.depth?t.docView.domAfterPos(i.before()):t.dom,{focusNode:a,focusOffset:f}=t.domSelectionRange(),c=a&&!h.contains(1==a.nodeType?a:a.parentNode)||e==a&&n==f;try{l.collapse(s,o),e&&(e!=s||n!=o)&&l.extend&&l.extend(e,n)}catch(t){}return null!=u&&(l.caretBidiLevel=u),c})):"left"==r||"backward"==r?s:o:i.pos==i.start()||i.pos==i.end()}(t,e,r))}(this,e||this.state,t)}pasteHTML(t,e){return Pn(this,"",t,!1,e||new ClipboardEvent("paste"))}pasteText(t,e){return Pn(this,t,null,!0,e||new ClipboardEvent("paste"))}destroy(){this.docView&&(function(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)}(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],hs(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,vr=null)}get isDestroyed(){return null==this.docView}dispatchEvent(t){return function(t,e){Fn(t,e)||!vn[e.type]||!t.editable&&e.type in kn||vn[e.type](t,e)}(this,t)}dispatch(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))}domSelectionRange(){let t=this.domSelection();return t?Ir&&11===this.root.nodeType&&function(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}(this.dom.ownerDocument)==this.dom&&function(t,e){if(e.getComposedRanges){let r=e.getComposedRanges(t.root)[0];if(r)return gs(t,r)}let r;function i(t){t.preventDefault(),t.stopImmediatePropagation(),r=t.getTargetRanges()[0]}return t.dom.addEventListener("beforeinput",i,!0),document.execCommand("indent"),t.dom.removeEventListener("beforeinput",i,!0),r?gs(t,r):null}(this,t)||t:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}function xs(t){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(t.editable),t.someProp("attributes",(r=>{if("function"==typeof r&&(r=r(t.state)),r)for(let t in r)"class"==t?e.class+=" "+r[t]:"style"==t?e.style=(e.style?e.style+";":"")+r[t]:e[t]||"contenteditable"==t||"nodeName"==t||(e[t]=String(r[t]))})),e.translate||(e.translate="no"),[Zn.node(0,t.state.doc.content.size,e)]}function Fs(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:Zn.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function Ms(t){return!t.someProp("editable",(e=>!1===e(t.state)))}function As(t){let e=Object.create(null);function r(t){for(let r in t)Object.prototype.hasOwnProperty.call(e,r)||(e[r]=t[r])}return t.someProp("nodeViews",r),t.someProp("markViews",r),e}function Cs(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 Ss=["p",0],Os=["blockquote",0],$s=["hr"],Bs=["pre",["code",0]],Rs=["br"],Ns=["em",0],_s=["strong",0],Ts=["code",0],zs=new Lt({nodes:{doc:{content:"block+"},paragraph:{content:"inline*",group:"block",parseDOM:[{tag:"p"}],toDOM:()=>Ss},blockquote:{content:"block+",group:"block",defining:!0,parseDOM:[{tag:"blockquote"}],toDOM:()=>Os},horizontal_rule:{group:"block",parseDOM:[{tag:"hr"}],toDOM:()=>$s},heading:{attrs:{level:{default:1,validate:"number"}},content:"inline*",group:"block",defining:!0,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=>["h"+t.attrs.level,0]},code_block:{content:"text*",marks:"",group:"block",code:!0,defining:!0,parseDOM:[{tag:"pre",preserveWhitespace:"full"}],toDOM:()=>Bs},text:{group:"inline"},image:{inline:!0,attrs:{src:{validate:"string"},alt:{default:null,validate:"string|null"},title:{default:null,validate:"string|null"}},group:"inline",draggable:!0,parseDOM:[{tag:"img[src]",getAttrs:t=>({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:!0,group:"inline",selectable:!1,parseDOM:[{tag:"br"}],toDOM:()=>Rs}},marks:{link:{attrs:{href:{validate:"string"},title:{default:null,validate:"string|null"}},inclusive:!1,parseDOM:[{tag:"a[href]",getAttrs:t=>({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=>"em"==t.type.name}],toDOM:()=>Ns},strong:{parseDOM:[{tag:"strong"},{tag:"b",getAttrs:t=>"normal"!=t.style.fontWeight&&null},{style:"font-weight=400",clearMark:t=>"strong"==t.type.name},{style:"font-weight",getAttrs:t=>/^(bold(er)?|[5-9]\d{2,})$/.test(t)&&null}],toDOM:()=>_s},code:{code:!0,parseDOM:[{tag:"code"}],toDOM:()=>Ts}}}),js=["ol",0],qs=["ul",0],Is=["li",0],Ps={attrs:{order:{default:1}},parseDOM:[{tag:"ol",getAttrs:t=>({order:t.hasAttribute("start")?+t.getAttribute("start"):1})}],toDOM:t=>1==t.attrs.order?js:["ol",{start:t.attrs.order},0]},Ls={parseDOM:[{tag:"ul"}],toDOM:()=>qs},Js={parseDOM:[{tag:"li"}],toDOM:()=>Is,defining:!0};function Us(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 Vs(t,e=null){return function(r,i){let{$from:n,$to:s}=r.selection,o=n.blockRange(s),l=!1,u=o;if(!o)return!1;if(o.depth>=2&&n.node(o.depth-1).type.compatibleContent(t)&&0==o.startIndex){if(0==n.index(o.depth-1))return!1;let t=r.doc.resolve(o.start-2);u=new Dt(t,t,o.depth),o.endIndex<o.parent.childCount&&(o=new Dt(n,r.doc.resolve(s.end(o.depth)),o.depth)),l=!0}let h=xe(u,t,e,o);return!!h&&(i&&i(function(t,e,r,i,n){let s=Q.empty;for(let t=r.length-1;t>=0;t--)s=Q.from(r[t].type.create(r[t].attrs,s));t.step(new ve(e.start-(i?2:0),e.end,e.start,e.end,new st(s,0,0),r.length,!0));let o=0;for(let t=0;t<r.length;t++)r[t].type==n&&(o=t+1);let l=r.length-o,u=e.start+r.length-(i?2:0),h=e.parent;for(let r=e.startIndex,i=e.endIndex,n=!0;r<i;r++,n=!1)!n&&Ce(t.doc,u,l)&&(t.split(u,l),u+=2*l),u+=h.child(r).nodeSize;return t}(r.tr,o,h,l,t).scrollIntoView()),!0)}}for(var Hs={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:"'"},Ws={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Gs="undefined"!=typeof navigator&&/Mac/.test(navigator.platform),Zs="undefined"!=typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),Ks=0;Ks<10;Ks++)Hs[48+Ks]=Hs[96+Ks]=String(Ks);for(Ks=1;Ks<=24;Ks++)Hs[Ks+111]="F"+Ks;for(Ks=65;Ks<=90;Ks++)Hs[Ks]=String.fromCharCode(Ks+32),Ws[Ks]=String.fromCharCode(Ks);for(var Ys in Hs)Ws.hasOwnProperty(Ys)||(Ws[Ys]=Hs[Ys]);const Xs="undefined"!=typeof navigator&&/Mac|iP(hone|[oa]d)/.test(navigator.platform);function Qs(t){let e,r,i,n,s=t.split(/-(?!$)/),o=s[s.length-1];"Space"==o&&(o=" ");for(let t=0;t<s.length-1;t++){let o=s[t];if(/^(cmd|meta|m)$/i.test(o))n=!0;else if(/^a(lt)?$/i.test(o))e=!0;else if(/^(c|ctrl|control)$/i.test(o))r=!0;else if(/^s(hift)?$/i.test(o))i=!0;else{if(!/^mod$/i.test(o))throw new Error("Unrecognized modifier name: "+o);Xs?n=!0:r=!0}}return e&&(o="Alt-"+o),r&&(o="Ctrl-"+o),n&&(o="Meta-"+o),i&&(o="Shift-"+o),o}function to(t,e,r=!0){return e.altKey&&(t="Alt-"+t),e.ctrlKey&&(t="Ctrl-"+t),e.metaKey&&(t="Meta-"+t),r&&e.shiftKey&&(t="Shift-"+t),t}function eo(t){return new dr({props:{handleKeyDown:ro(t)}})}function ro(t){let e=function(t){let e=Object.create(null);for(let r in t)e[Qs(r)]=t[r];return e}(t);return function(t,r){let i,n=function(t){var e=!(Gs&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||Zs&&t.shiftKey&&t.key&&1==t.key.length||"Unidentified"==t.key)&&t.key||(t.shiftKey?Ws:Hs)[t.keyCode]||t.key||"Unidentified";return"Esc"==e&&(e="Escape"),"Del"==e&&(e="Delete"),"Left"==e&&(e="ArrowLeft"),"Up"==e&&(e="ArrowUp"),"Right"==e&&(e="ArrowRight"),"Down"==e&&(e="ArrowDown"),e}(r),s=e[to(n,r)];if(s&&s(t.state,t.dispatch,t))return!0;if(1==n.length&&" "!=n){if(r.shiftKey){let i=e[to(n,r,!1)];if(i&&i(t.state,t.dispatch,t))return!0}if((r.shiftKey||r.altKey||r.metaKey||n.charCodeAt(0)>127)&&(i=Hs[r.keyCode])&&i!=n){let n=e[to(i,r)];if(n&&n(t.state,t.dispatch,t))return!0}}return!1}}var io=200,no=function(){};no.prototype.append=function(t){return t.length?(t=no.from(t),!this.length&&t||t.length<io&&this.leafAppend(t)||this.length<io&&t.leafPrepend(this)||this.appendInner(t)):this},no.prototype.prepend=function(t){return t.length?no.from(t).append(this):this},no.prototype.appendInner=function(t){return new oo(this,t)},no.prototype.slice=function(t,e){return void 0===t&&(t=0),void 0===e&&(e=this.length),t>=e?no.empty:this.sliceInner(Math.max(0,t),Math.min(this.length,e))},no.prototype.get=function(t){if(!(t<0||t>=this.length))return this.getInner(t)},no.prototype.forEach=function(t,e,r){void 0===e&&(e=0),void 0===r&&(r=this.length),e<=r?this.forEachInner(t,e,r,0):this.forEachInvertedInner(t,e,r,0)},no.prototype.map=function(t,e,r){void 0===e&&(e=0),void 0===r&&(r=this.length);var i=[];return this.forEach((function(e,r){return i.push(t(e,r))}),e,r),i},no.from=function(t){return t instanceof no?t:t&&t.length?new so(t):no.empty};var so=function(t){function e(e){t.call(this),this.values=e}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var r={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(t,r){return 0==t&&r==this.length?this:new e(this.values.slice(t,r))},e.prototype.getInner=function(t){return this.values[t]},e.prototype.forEachInner=function(t,e,r,i){for(var n=e;n<r;n++)if(!1===t(this.values[n],i+n))return!1},e.prototype.forEachInvertedInner=function(t,e,r,i){for(var n=e-1;n>=r;n--)if(!1===t(this.values[n],i+n))return!1},e.prototype.leafAppend=function(t){if(this.length+t.length<=io)return new e(this.values.concat(t.flatten()))},e.prototype.leafPrepend=function(t){if(this.length+t.length<=io)return new e(t.flatten().concat(this.values))},r.length.get=function(){return this.values.length},r.depth.get=function(){return 0},Object.defineProperties(e.prototype,r),e}(no);no.empty=new so([]);var oo=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}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(t){return t<this.left.length?this.left.get(t):this.right.get(t-this.left.length)},e.prototype.forEachInner=function(t,e,r,i){var n=this.left.length;return!(e<n&&!1===this.left.forEachInner(t,e,Math.min(r,n),i))&&!(r>n&&!1===this.right.forEachInner(t,Math.max(e-n,0),Math.min(this.length,r)-n,i+n))&&void 0},e.prototype.forEachInvertedInner=function(t,e,r,i){var n=this.left.length;return!(e>n&&!1===this.right.forEachInvertedInner(t,e-n,Math.max(r,n)-n,i+n))&&!(r<n&&!1===this.left.forEachInvertedInner(t,Math.min(e,n),r,i))&&void 0},e.prototype.sliceInner=function(t,e){if(0==t&&e==this.length)return this;var r=this.left.length;return e<=r?this.left.slice(t,e):t>=r?this.right.slice(t-r,e-r):this.left.slice(t,r).append(this.right.slice(0,e-r))},e.prototype.leafAppend=function(t){var r=this.right.leafAppend(t);if(r)return new e(this.left,r)},e.prototype.leafPrepend=function(t){var r=this.left.leafPrepend(t);if(r)return new e(r,this.right)},e.prototype.appendInner=function(t){return this.left.depth>=Math.max(this.right.depth,t.depth)+1?new e(this.left,new e(this.right,t)):new e(this,t)},e}(no);class lo{constructor(t,e){this.items=t,this.eventCount=e}popEvent(t,e){if(0==this.eventCount)return null;let r,i,n=this.items.length;for(;;n--)if(this.items.get(n-1).selection){--n;break}e&&(r=this.remapping(n,this.items.length),i=r.maps.length);let s,o,l=t.tr,u=[],h=[];return this.items.forEach(((t,e)=>{if(!t.step)return r||(r=this.remapping(n,e+1),i=r.maps.length),i--,void h.push(t);if(r){h.push(new uo(t.map));let e,n=t.step.map(r.slice(i));n&&l.maybeStep(n).doc&&(e=l.mapping.maps[l.mapping.maps.length-1],u.push(new uo(e,void 0,void 0,u.length+h.length))),i--,e&&r.appendMap(e,i)}else l.maybeStep(t.step);return t.selection?(s=r?t.selection.map(r.slice(i)):t.selection,o=new lo(this.items.slice(0,n).append(h.reverse().concat(u)),this.eventCount-1),!1):void 0}),this.items.length,0),{remaining:o,transform:l,selection:s}}addTransform(t,e,r,i){let n=[],s=this.eventCount,o=this.items,l=!i&&o.length?o.get(o.length-1):null;for(let r=0;r<t.steps.length;r++){let u,h=t.steps[r].invert(t.docs[r]),a=new uo(t.mapping.maps[r],h,e);(u=l&&l.merge(a))&&(a=u,r?n.pop():o=o.slice(0,o.length-1)),n.push(a),e&&(s++,e=void 0),i||(l=a)}let u=s-r.depth;return u>ao&&(o=function(t,e){let r;return t.forEach(((t,i)=>{if(t.selection&&0==e--)return r=i,!1})),t.slice(r)}(o,u),s-=u),new lo(o.append(n),s)}remapping(t,e){let r=new he;return this.items.forEach(((e,i)=>{r.appendMap(e.map,null!=e.mirrorOffset&&i-e.mirrorOffset>=t?r.maps.length-e.mirrorOffset:void 0)}),t,e),r}addMaps(t){return 0==this.eventCount?this:new lo(this.items.append(t.map((t=>new uo(t)))),this.eventCount)}rebased(t,e){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-e),n=t.mapping,s=t.steps.length,o=this.eventCount;this.items.forEach((t=>{t.selection&&o--}),i);let l=e;this.items.forEach((e=>{let i=n.getMirror(--l);if(null==i)return;s=Math.min(s,i);let u=n.maps[i];if(e.step){let s=t.steps[i].invert(t.docs[i]),h=e.selection&&e.selection.map(n.slice(l+1,i));h&&o++,r.push(new uo(u,s,h))}else r.push(new uo(u))}),i);let u=[];for(let t=e;t<s;t++)u.push(new uo(n.maps[t]));let h=this.items.slice(0,i).append(u).append(r),a=new lo(h,o);return a.emptyItemCount()>500&&(a=a.compress(this.items.length-r.length)),a}emptyItemCount(){let t=0;return this.items.forEach((e=>{e.step||t++})),t}compress(t=this.items.length){let e=this.remapping(0,t),r=e.maps.length,i=[],n=0;return this.items.forEach(((s,o)=>{if(o>=t)i.push(s),s.selection&&n++;else if(s.step){let t=s.step.map(e.slice(r)),o=t&&t.getMap();if(r--,o&&e.appendMap(o,r),t){let l=s.selection&&s.selection.map(e.slice(r));l&&n++;let u,h=new uo(o.invert(),t,l),a=i.length-1;(u=i.length&&i[a].merge(h))?i[a]=u:i.push(h)}}else s.map&&r--}),this.items.length,0),new lo(no.from(i.reverse()),n)}}lo.empty=new lo(no.empty,0);class uo{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 uo(e.getMap().invert(),e,this.selection)}}}class ho{constructor(t,e,r,i,n){this.done=t,this.undone=e,this.prevRanges=r,this.prevTime=i,this.prevComposition=n}}const ao=20;function fo(t){let e=[];return t.forEach(((t,r,i,n)=>e.push(i,n))),e}function co(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);n<=s&&r.push(n,s)}return r}function po(t,e,r,i){let n=bo(e),s=wo.get(e).spec.config,o=(i?t.undone:t.done).popEvent(e,n);if(!o)return;let l=o.selection.resolve(o.transform.doc),u=(i?t.done:t.undone).addTransform(o.transform,e.selection.getBookmark(),s,n),h=new ho(i?u:o.remaining,i?o.remaining:u,null,0,-1);r(o.transform.setSelection(l).setMeta(wo,{redo:i,historyState:h}).scrollIntoView())}let mo=!1,go=null;function bo(t){let e=t.plugins;if(go!=e){mo=!1,go=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){mo=!0;break}}return mo}const wo=new gr("history"),vo=new gr("closeHistory");const ko=(t,e)=>{let r=wo.getState(t);return!(!r||0==r.done.eventCount||(e&&po(r,t,e,!1),0))},Do=(t,e)=>{let r=wo.getState(t);return!(!r||0==r.undone.eventCount||(e&&po(r,t,e,!0),0))},yo=(t,e)=>!t.selection.empty&&(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function Eo(t,e,r=!1){for(let i=t;i;i="start"==e?i.firstChild:i.lastChild){if(i.isTextblock)return!0;if(r&&1!=i.childCount)return!1}return!1}function xo(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 Fo(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 Mo=(t,e)=>{let r,i=t.selection,n=i instanceof tr;if(n){if(i.node.isTextblock||!Se(t.doc,i.from))return!1;r=i.from}else if(r=$e(t.doc,i.from,-1),null==r)return!1;if(e){let i=t.tr.join(r);n&&i.setSelection(tr.create(i.doc,r-t.doc.resolve(r).nodeBefore.nodeSize)),e(i.scrollIntoView())}return!0},Ao=(t,e)=>{let r,i=t.selection;if(i instanceof tr){if(i.node.isTextblock||!Se(t.doc,i.to))return!1;r=i.to}else if(r=$e(t.doc,i.to,1),null==r)return!1;return e&&e(t.tr.join(r).scrollIntoView()),!0},Co=(t,e)=>{let{$from:r,$to:i}=t.selection,n=r.blockRange(i),s=n&&Ee(n);return null!=s&&(e&&e(t.tr.lift(n,s).scrollIntoView()),!0)};function So(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 Oo=(t,e)=>{let{$head:r,$anchor:i}=t.selection;if(!r.parent.type.spec.code||!r.sameParent(i))return!1;let n=r.node(-1),s=r.indexAfter(-1),o=So(n.contentMatchAt(s));if(!o||!n.canReplaceWith(s,s,o))return!1;if(e){let i=r.after(),n=t.tr.replaceWith(i,i,o.createAndFill());n.setSelection(Ge.near(n.doc.resolve(i),1)),e(n.scrollIntoView())}return!0},$o=(t,e)=>{let r,{$from:i,to:n}=t.selection,s=i.sharedDepth(n);return 0!=s&&(r=i.before(s),e&&e(t.tr.setSelection(tr.create(t.doc,r))),!0)};function Bo(t,e,r){let i,n,s=e.nodeBefore,o=e.nodeAfter;if(s.type.spec.isolating||o.type.spec.isolating)return!1;if(function(t,e,r){let i=e.nodeBefore,n=e.nodeAfter,s=e.index();return!(!(i&&n&&i.type.compatibleContent(n.type))||(!i.content.size&&e.parent.canReplace(s-1,s)?(r&&r(t.tr.delete(e.pos-i.nodeSize,e.pos).scrollIntoView()),0):!e.parent.canReplace(s,s+1)||!n.isTextblock&&!Se(t.doc,e.pos)||(r&&r(t.tr.clearIncompatible(e.pos,i.type,i.contentMatchAt(i.childCount)).join(e.pos).scrollIntoView()),0)))}(t,e,r))return!0;let l=e.parent.canReplace(e.index(),e.index()+1);if(l&&(i=(n=s.contentMatchAt(s.childCount)).findWrapping(o.type))&&n.matchType(i[0]||o.type).validEnd){if(r){let n=e.pos+o.nodeSize,l=Q.empty;for(let t=i.length-1;t>=0;t--)l=Q.from(i[t].create(null,l));l=Q.from(s.copy(l));let u=t.tr.step(new ve(e.pos-1,n,e.pos,n,new st(l,1,0),i.length,!0)),h=n+2*i.length;Se(u.doc,h)&&u.join(h),r(u.scrollIntoView())}return!0}let u=Ge.findFrom(e,1),h=u&&u.$from.blockRange(u.$to),a=h&&Ee(h);if(null!=a&&a>=e.depth)return r&&r(t.tr.lift(h,a).scrollIntoView()),!0;if(l&&Eo(o,"start",!0)&&Eo(s,"end")){let i=s,n=[];for(;n.push(i),!i.isTextblock;)i=i.lastChild;let l=o,u=1;for(;!l.isTextblock;l=l.firstChild)u++;if(i.canReplace(i.childCount,i.childCount,l.content)){if(r){let i=Q.empty;for(let t=n.length-1;t>=0;t--)i=Q.from(n[t].copy(i));r(t.tr.step(new ve(e.pos-n.length,e.pos+o.nodeSize,e.pos+u,e.pos+o.nodeSize-u,new st(i,n.length,0),0,!0)).scrollIntoView())}return!0}}return!1}function Ro(t){return function(e,r){let i=e.selection,n=t<0?i.$from:i.$to,s=n.depth;for(;n.node(s).isInline;){if(!s)return!1;s--}return!!n.node(s).isTextblock&&(r&&r(e.tr.setSelection(Xe.create(e.doc,t<0?n.start(s):n.end(s)))),!0)}}const No=Ro(-1),_o=Ro(1);function To(t,e=null){return function(r,i){let{$from:n,$to:s}=r.selection,o=n.blockRange(s),l=o&&xe(o,t,e);return!!l&&(i&&i(r.tr.wrap(o,l).scrollIntoView()),!0)}}function zo(t,e=null){return function(r,i){let n=!1;for(let i=0;i<r.selection.ranges.length&&!n;i++){let{$from:{pos:s},$to:{pos:o}}=r.selection.ranges[i];r.doc.nodesBetween(s,o,((i,s)=>{if(n)return!1;if(i.isTextblock&&!i.hasMarkup(t,e))if(i.type==t)n=!0;else{let e=r.doc.resolve(s),i=e.index();n=e.parent.canReplaceWith(i,i+1,t)}}))}if(!n)return!1;if(i){let n=r.tr;for(let i=0;i<r.selection.ranges.length;i++){let{$from:{pos:s},$to:{pos:o}}=r.selection.ranges[i];n.setBlockType(s,o,t,e)}i(n.scrollIntoView())}return!0}}function jo(t,e=null){return function(r,i){let{empty:n,$cursor:s,ranges:o}=r.selection;if(n&&!s||!function(t,e,r){for(let i=0;i<e.length;i++){let{$from:n,$to:s}=e[i],o=0==n.depth&&t.inlineContent&&t.type.allowsMarkType(r);if(t.nodesBetween(n.pos,s.pos,(t=>{if(o)return!1;o=t.inlineContent&&t.type.allowsMarkType(r)})),o)return!0}return!1}(r.doc,o,t))return!1;if(i)if(s)t.isInSet(r.storedMarks||s.marks())?i(r.tr.removeStoredMark(t)):i(r.tr.addStoredMark(t.create(e)));else{let n=!1,s=r.tr;for(let e=0;!n&&e<o.length;e++){let{$from:i,$to:s}=o[e];n=r.doc.rangeHasMark(i.pos,s.pos,t)}for(let r=0;r<o.length;r++){let{$from:i,$to:l}=o[r];if(n)s.removeMark(i.pos,l.pos,t);else{let r=i.pos,n=l.pos,o=i.nodeAfter,u=l.nodeBefore,h=o&&o.isText?/^\s*/.exec(o.text)[0].length:0,a=u&&u.isText?/\s*$/.exec(u.text)[0].length:0;r+h<n&&(r+=h,n-=a),s.addMark(r,n,t.create(e))}}i(s.scrollIntoView())}return!0}}function qo(...t){return function(e,r,i){for(let n=0;n<t.length;n++)if(t[n](e,r,i))return!0;return!1}}let Io=qo(yo,((t,e,r)=>{let i=function(t,e){let{$cursor:r}=t.selection;return!r||(e?!e.endOfTextblock("backward",t):r.parentOffset>0)?null:r}(t,r);if(!i)return!1;let n=xo(i);if(!n){let r=i.blockRange(),n=r&&Ee(r);return null!=n&&(e&&e(t.tr.lift(r,n).scrollIntoView()),!0)}let s=n.nodeBefore;if(!s.type.spec.isolating&&Bo(t,n,e))return!0;if(0==i.parent.content.size&&(Eo(s,"end")||tr.isSelectable(s))){let r=Re(t.doc,i.before(),i.after(),st.empty);if(r&&r.slice.size<r.to-r.from){if(e){let i=t.tr.step(r);i.setSelection(Eo(s,"end")?Ge.findFrom(i.doc.resolve(i.mapping.map(n.pos,-1)),-1):tr.create(i.doc,n.pos-s.nodeSize)),e(i.scrollIntoView())}return!0}}return!(!s.isAtom||n.depth!=i.depth-1||(e&&e(t.tr.delete(n.pos-s.nodeSize,n.pos).scrollIntoView()),0))}),((t,e,r)=>{let{$head:i,empty:n}=t.selection,s=i;if(!n)return!1;if(i.parent.isTextblock){if(r?!r.endOfTextblock("backward",t):i.parentOffset>0)return!1;s=xo(i)}let o=s&&s.nodeBefore;return!(!o||!tr.isSelectable(o)||(e&&e(t.tr.setSelection(tr.create(t.doc,s.pos-o.nodeSize)).scrollIntoView()),0))})),Po=qo(yo,((t,e,r)=>{let i=function(t,e){let{$cursor:r}=t.selection;return!r||(e?!e.endOfTextblock("forward",t):r.parentOffset<r.parent.content.size)?null:r}(t,r);if(!i)return!1;let n=Fo(i);if(!n)return!1;let s=n.nodeAfter;if(Bo(t,n,e))return!0;if(0==i.parent.content.size&&(Eo(s,"start")||tr.isSelectable(s))){let r=Re(t.doc,i.before(),i.after(),st.empty);if(r&&r.slice.size<r.to-r.from){if(e){let i=t.tr.step(r);i.setSelection(Eo(s,"start")?Ge.findFrom(i.doc.resolve(i.mapping.map(n.pos)),1):tr.create(i.doc,i.mapping.map(n.pos))),e(i.scrollIntoView())}return!0}}return!(!s.isAtom||n.depth!=i.depth-1||(e&&e(t.tr.delete(n.pos,n.pos+s.nodeSize).scrollIntoView()),0))}),((t,e,r)=>{let{$head:i,empty:n}=t.selection,s=i;if(!n)return!1;if(i.parent.isTextblock){if(r?!r.endOfTextblock("forward",t):i.parentOffset<i.parent.content.size)return!1;s=Fo(i)}let o=s&&s.nodeAfter;return!(!o||!tr.isSelectable(o)||(e&&e(t.tr.setSelection(tr.create(t.doc,s.pos)).scrollIntoView()),0))}));const Lo={Enter:qo(((t,e)=>{let{$head:r,$anchor:i}=t.selection;return!(!r.parent.type.spec.code||!r.sameParent(i)||(e&&e(t.tr.insertText("\n").scrollIntoView()),0))}),((t,e)=>{let r=t.selection,{$from:i,$to:n}=r;if(r instanceof rr||i.parent.inlineContent||n.parent.inlineContent)return!1;let s=So(n.parent.contentMatchAt(n.indexAfter()));if(!s||!s.isTextblock)return!1;if(e){let r=(!i.parentOffset&&n.index()<n.parent.childCount?i:n).pos,o=t.tr.insert(r,s.createAndFill());o.setSelection(Xe.create(o.doc,r+1)),e(o.scrollIntoView())}return!0}),((t,e)=>{let{$cursor:r}=t.selection;if(!r||r.parent.content.size)return!1;if(r.depth>1&&r.after()!=r.end(-1)){let i=r.before();if(Ce(t.doc,i))return e&&e(t.tr.split(i).scrollIntoView()),!0}let i=r.blockRange(),n=i&&Ee(i);return null!=n&&(e&&e(t.tr.lift(i,n).scrollIntoView()),!0)}),((t,e)=>{let{$from:r,$to:i}=t.selection;if(t.selection instanceof tr&&t.selection.node.isBlock)return!(!r.parentOffset||!Ce(t.doc,r.pos)||(e&&e(t.tr.split(r.pos).scrollIntoView()),0));if(!r.parent.isBlock)return!1;if(e){let n=i.parentOffset==i.parent.content.size,s=t.tr;(t.selection instanceof Xe||t.selection instanceof rr)&&s.deleteSelection();let o=0==r.depth?null:So(r.node(-1).contentMatchAt(r.indexAfter(-1))),l=n&&o?[{type:o}]:void 0,u=Ce(s.doc,s.mapping.map(r.pos),1,l);if(l||u||!Ce(s.doc,s.mapping.map(r.pos),1,o?[{type:o}]:void 0)||(o&&(l=[{type:o}]),u=!0),u&&(s.split(s.mapping.map(r.pos),1,l),!n&&!r.parentOffset&&r.parent.type!=o)){let t=s.mapping.map(r.before()),e=s.doc.resolve(t);o&&r.node(-1).canReplaceWith(e.index(),e.index()+1,o)&&s.setNodeMarkup(s.mapping.map(r.before()),o)}e(s.scrollIntoView())}return!0})),"Mod-Enter":Oo,Backspace:Io,"Mod-Backspace":Io,"Shift-Backspace":Io,Delete:Po,"Mod-Delete":Po,"Mod-a":(t,e)=>(e&&e(t.tr.setSelection(new rr(t.doc))),!0)},Jo={"Ctrl-h":Lo.Backspace,"Alt-Backspace":Lo["Mod-Backspace"],"Ctrl-d":Lo.Delete,"Ctrl-Alt-Backspace":Lo["Mod-Delete"],"Alt-Delete":Lo["Mod-Delete"],"Alt-d":Lo["Mod-Delete"],"Ctrl-a":No,"Ctrl-e":_o};for(let t in Lo)Jo[t]=Lo[t];const Uo=("undefined"!=typeof navigator?/Mac|iP(hone|[oa]d)/.test(navigator.platform):"undefined"!=typeof os&&os.platform&&"darwin"==os.platform())?Jo:Lo;function Vo(t={}){return new dr({view:e=>new Ho(e,t)})}class Ho{constructor(t,e){var r;this.editorView=t,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=null!==(r=e.width)&&void 0!==r?r:1,this.color=!1===e.color?void 0:e.color||"black",this.class=e.class,this.handlers=["dragover","dragend","drop","dragleave"].map((e=>{let r=t=>{this[e](t)};return t.dom.addEventListener(e,r),{name:e,handler:r}}))}destroy(){this.handlers.forEach((({name:t,handler:e})=>this.editorView.dom.removeEventListener(t,e)))}update(t,e){null!=this.cursorPos&&e.doc!=t.state.doc&&(this.cursorPos>t.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(t){t!=this.cursorPos&&(this.cursorPos=t,null==t?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let t,e=this.editorView.state.doc.resolve(this.cursorPos),r=!e.parent.inlineContent;if(r){let r=e.nodeBefore,i=e.nodeAfter;if(r||i){let e=this.editorView.nodeDOM(this.cursorPos-(r?r.nodeSize:0));if(e){let n=e.getBoundingClientRect(),s=r?n.bottom:n.top;r&&i&&(s=(s+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2),t={left:n.left,right:n.right,top:s-this.width/2,bottom:s+this.width/2}}}}if(!t){let e=this.editorView.coordsAtPos(this.cursorPos);t={left:e.left-this.width/2,right:e.left+this.width/2,top:e.top,bottom:e.bottom}}let i,n,s=this.editorView.dom.offsetParent;if(this.element||(this.element=s.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",r),this.element.classList.toggle("prosemirror-dropcursor-inline",!r),!s||s==document.body&&"static"==getComputedStyle(s).position)i=-pageXOffset,n=-pageYOffset;else{let t=s.getBoundingClientRect();i=t.left-s.scrollLeft,n=t.top-s.scrollTop}this.element.style.left=t.left-i+"px",this.element.style.top=t.top-n+"px",this.element.style.width=t.right-t.left+"px",this.element.style.height=t.bottom-t.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}),r=e&&e.inside>=0&&this.editorView.state.doc.nodeAt(e.inside),i=r&&r.type.spec.disableDropCursor,n="function"==typeof i?i(this.editorView,e,t):i;if(e&&!n){let t=e.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let e=Be(this.editorView.state.doc,t,this.editorView.dragging.slice);null!=e&&(t=e)}this.setCursor(t),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(t){t.target!=this.editorView.dom&&this.editorView.dom.contains(t.relatedTarget)||this.setCursor(null)}}class Wo extends Ge{constructor(t){super(t,t)}map(t,e){let r=t.resolve(e.map(this.head));return Wo.valid(r)?new Wo(r):Ge.near(r)}content(){return st.empty}eq(t){return t instanceof Wo&&t.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(t,e){if("number"!=typeof e.pos)throw new RangeError("Invalid input for GapCursor.fromJSON");return new Wo(t.resolve(e.pos))}getBookmark(){return new Go(this.anchor)}static valid(t){let e=t.parent;if(e.isTextblock||!function(t){for(let e=t.depth;e>=0;e--){let r=t.index(e),i=t.node(e);if(0!=r)for(let t=i.child(r-1);;t=t.lastChild){if(0==t.childCount&&!t.inlineContent||t.isAtom||t.type.spec.isolating)return!0;if(t.inlineContent)return!1}else if(i.type.spec.isolating)return!0}return!0}(t)||!function(t){for(let e=t.depth;e>=0;e--){let r=t.indexAfter(e),i=t.node(e);if(r!=i.childCount)for(let t=i.child(r);;t=t.firstChild){if(0==t.childCount&&!t.inlineContent||t.isAtom||t.type.spec.isolating)return!0;if(t.inlineContent)return!1}else if(i.type.spec.isolating)return!0}return!0}(t))return!1;let r=e.type.spec.allowGapCursor;if(null!=r)return r;let i=e.contentMatchAt(t.index()).defaultType;return i&&i.isTextblock}static findGapCursorFrom(t,e,r=!1){t:for(;;){if(!r&&Wo.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}if(0==r)return null;i+=e;let o=t.doc.resolve(i);if(Wo.valid(o))return o}for(;;){let s=e>0?n.firstChild:n.lastChild;if(!s){if(n.isAtom&&!n.isText&&!tr.isSelectable(n)){t=t.doc.resolve(i+n.nodeSize*e),r=!1;continue t}break}n=s,i+=e;let o=t.doc.resolve(i);if(Wo.valid(o))return o}return null}}}Wo.prototype.visible=!1,Wo.findFrom=Wo.findGapCursorFrom,Ge.jsonID("gapcursor",Wo);class Go{constructor(t){this.pos=t}map(t){return new Go(t.map(this.pos))}resolve(t){let e=t.resolve(this.pos);return Wo.valid(e)?new Wo(e):Ge.near(e)}}const Zo=ro({ArrowLeft:Ko("horiz",-1),ArrowRight:Ko("horiz",1),ArrowUp:Ko("vert",-1),ArrowDown:Ko("vert",1)});function Ko(t,e){const r="vert"==t?e>0?"down":"up":e>0?"right":"left";return function(t,i,n){let s=t.selection,o=e>0?s.$to:s.$from,l=s.empty;if(s instanceof Xe){if(!n.endOfTextblock(r)||0==o.depth)return!1;l=!1,o=t.doc.resolve(e>0?o.after():o.before())}let u=Wo.findGapCursorFrom(o,e,l);return!!u&&(i&&i(t.tr.setSelection(new Wo(u))),!0)}}function Yo(t,e,r){if(!t||!t.editable)return!1;let i=t.state.doc.resolve(e);if(!Wo.valid(i))return!1;let n=t.posAtCoords({left:r.clientX,top:r.clientY});return!(n&&n.inside>-1&&tr.isSelectable(t.state.doc.nodeAt(n.inside))||(t.dispatch(t.state.tr.setSelection(new Wo(i))),0))}function Xo(t,e){if("insertCompositionText"!=e.inputType||!(t.state.selection instanceof Wo))return!1;let{$from:r}=t.state.selection,i=r.parent.contentMatchAt(r.index()).findWrapping(t.state.schema.nodes.text);if(!i)return!1;let n=Q.empty;for(let t=i.length-1;t>=0;t--)n=Q.from(i[t].createAndFill(null,n));let s=t.state.tr.replace(r.pos,r.pos,new st(n,0,0));return s.setSelection(Xe.near(s.doc.resolve(r.pos+1))),t.dispatch(s),!1}function Qo(t){if(!(t.selection instanceof Wo))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",Xn.create(t.doc,[Zn.widget(t.selection.head,e,{key:"gapcursor"})])}class tl{constructor(t,e,r={}){var i;this.match=t,this.match=t,this.handler="string"==typeof e?(i=e,function(t,e,r,n){let s=i;if(e[1]){let t=e[0].lastIndexOf(e[1]);s+=e[0].slice(t+e[1].length);let i=(r+=t)-n;i>0&&(s=e[0].slice(t-i,t)+s,r=n)}return t.tr.insertText(s,r,n)}):e,this.undoable=!1!==r.undoable,this.inCode=r.inCode||!1}}function el(t,e,r,i,n,s){if(t.composing)return!1;let o=t.state,l=o.doc.resolve(e),u=l.parent.textBetween(Math.max(0,l.parentOffset-500),l.parentOffset,null,"")+i;for(let h=0;h<n.length;h++){let a=n[h];if(l.parent.type.spec.code){if(!a.inCode)continue}else if("only"===a.inCode)continue;let f=a.match.exec(u),c=f&&a.handler(o,f,e-(f[0].length-i.length),r);if(c)return a.undoable&&c.setMeta(s,{transform:c,from:e,to:r,text:i}),t.dispatch(c),!0}return!1}const rl=(t,e)=>{let r=t.plugins;for(let i=0;i<r.length;i++){let n,s=r[i];if(s.spec.isInputRules&&(n=s.getState(t))){if(e){let r=t.tr,i=n.transform;for(let t=i.steps.length-1;t>=0;t--)r.step(i.steps[t].invert(i.docs[t]));if(n.text){let e=r.doc.resolve(n.from).marks();r.replaceWith(n.from,n.to,t.schema.text(n.text,e))}else r.delete(n.from,n.to);e(r)}return!0}}return!1},il=new tl(/--$/,"—"),nl=new tl(/\.\.\.$/,"…"),sl=[new tl(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,"“"),new tl(/"$/,"”"),new tl(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,"‘"),new tl(/'$/,"’")];function ol(t,e,r=null,i){return new tl(t,((t,n,s,o)=>{let l=r instanceof Function?r(n):r,u=t.tr.delete(s,o),h=u.doc.resolve(s).blockRange(),a=h&&xe(h,e,l);if(!a)return null;u.wrap(h,a);let f=u.doc.resolve(s-1).nodeBefore;return f&&f.type==e&&Se(u.doc,s-1)&&(!i||i(n,f))&&u.join(s-1),u}))}function ll(t,e,r=null){return new tl(t,((t,i,n,s)=>{let o=t.doc.resolve(n),l=r instanceof Function?r(i):r;return o.node(-1).canReplaceWith(o.index(-1),o.indexAfter(-1),e)?t.tr.delete(n,s).setBlockType(n,n,e,l):null}))}const ul="undefined"!=typeof navigator&&/Mac|iP(hone|[oa]d)/.test(navigator.platform);function hl(t,e){let r,i={};function n(t,r){if(e){let r=e[t];if(!1===r)return;r&&(t=r)}i[t]=r}if(n("Mod-z",ko),n("Shift-Mod-z",Do),n("Backspace",rl),ul||n("Mod-y",Do),n("Alt-ArrowUp",Mo),n("Alt-ArrowDown",Ao),n("Mod-BracketLeft",Co),n("Escape",$o),(r=t.marks.strong)&&(n("Mod-b",jo(r)),n("Mod-B",jo(r))),(r=t.marks.em)&&(n("Mod-i",jo(r)),n("Mod-I",jo(r))),(r=t.marks.code)&&n("Mod-`",jo(r)),(r=t.nodes.bullet_list)&&n("Shift-Ctrl-8",Vs(r)),(r=t.nodes.ordered_list)&&n("Shift-Ctrl-9",Vs(r)),(r=t.nodes.blockquote)&&n("Ctrl->",To(r)),r=t.nodes.hard_break){let t=r,e=qo(Oo,((e,r)=>(r&&r(e.tr.replaceSelectionWith(t.create()).scrollIntoView()),!0)));n("Mod-Enter",e),n("Shift-Enter",e),ul&&n("Ctrl-Enter",e)}var s;if((r=t.nodes.list_item)&&(n("Enter",(s=r,function(t,e){let{$from:r,$to:i,node:n}=t.selection;if(n&&n.isBlock||r.depth<2||!r.sameParent(i))return!1;let o=r.node(-1);if(o.type!=s)return!1;if(0==r.parent.content.size&&r.node(-1).childCount==r.indexAfter(-1)){if(3==r.depth||r.node(-3).type!=s||r.index(-2)!=r.node(-2).childCount-1)return!1;if(e){let i=Q.empty,n=r.index(-1)?1:r.index(-2)?2:3;for(let t=r.depth-n;t>=r.depth-3;t--)i=Q.from(r.node(t).copy(i));let o=r.indexAfter(-1)<r.node(-2).childCount?1:r.indexAfter(-2)<r.node(-3).childCount?2:3;i=i.append(Q.from(s.createAndFill()));let l=r.before(r.depth-(n-1)),u=t.tr.replace(l,r.after(-o),new st(i,4-n,0)),h=-1;u.doc.nodesBetween(l,u.doc.content.size,((t,e)=>{if(h>-1)return!1;t.isTextblock&&0==t.content.size&&(h=e+1)})),h>-1&&u.setSelection(Ge.near(u.doc.resolve(h))),e(u.scrollIntoView())}return!0}let l=i.pos==r.end()?o.contentMatchAt(0).defaultType:null,u=t.tr.delete(r.pos,i.pos),h=l?[null,{type:l}]:void 0;return!!Ce(u.doc,r.pos,2,h)&&(e&&e(u.split(r.pos,2,h).scrollIntoView()),!0)})),n("Mod-[",function(t){return function(e,r){let{$from:i,$to:n}=e.selection,s=i.blockRange(n,(e=>e.childCount>0&&e.firstChild.type==t));return!!s&&(!r||(i.node(s.depth-1).type==t?function(t,e,r,i){let n=t.tr,s=i.end,o=i.$to.end(i.depth);s<o&&(n.step(new ve(s-1,o,s,o,new st(Q.from(r.create(null,i.parent.copy())),1,0),1,!0)),i=new Dt(n.doc.resolve(i.$from.pos),n.doc.resolve(o),i.depth));const l=Ee(i);if(null==l)return!1;n.lift(i,l);let u=n.mapping.map(s,-1)-1;return Se(n.doc,u)&&n.join(u),e(n.scrollIntoView()),!0}(e,r,t,s):function(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),o=s.nodeAfter;if(i.mapping.map(r.end)!=r.start+s.nodeAfter.nodeSize)return!1;let l=0==r.startIndex,u=r.endIndex==n.childCount,h=s.node(-1),a=s.index(-1);if(!h.canReplace(a+(l?0:1),a+1,o.content.append(u?Q.empty:Q.from(n))))return!1;let f=s.pos,c=f+o.nodeSize;return i.step(new ve(f-(l?1:0),c+(u?1:0),f+1,c-1,new st((l?Q.empty:Q.from(n.copy(Q.empty))).append(u?Q.empty:Q.from(n.copy(Q.empty))),l?0:1,u?0:1),l?0:1)),e(i.scrollIntoView()),!0}(e,r,s)))}}(r)),n("Mod-]",function(t){return function(e,r){let{$from:i,$to:n}=e.selection,s=i.blockRange(n,(e=>e.childCount>0&&e.firstChild.type==t));if(!s)return!1;let o=s.startIndex;if(0==o)return!1;let l=s.parent,u=l.child(o-1);if(u.type!=t)return!1;if(r){let i=u.lastChild&&u.lastChild.type==l.type,n=Q.from(i?t.create():null),o=new st(Q.from(t.create(null,Q.from(l.type.create(null,n)))),i?3:1,0),h=s.start,a=s.end;r(e.tr.step(new ve(h-(i?3:1),a,h,a,o,1,!0)).scrollIntoView())}return!0}}(r))),(r=t.nodes.paragraph)&&n("Shift-Ctrl-0",zo(r)),(r=t.nodes.code_block)&&n("Shift-Ctrl-\\",zo(r)),r=t.nodes.heading)for(let t=1;t<=6;t++)n("Shift-Ctrl-"+t,zo(r,{level:t}));if(r=t.nodes.horizontal_rule){let t=r;n("Mod-_",((e,r)=>(r&&r(e.tr.replaceSelectionWith(t.create()).scrollIntoView()),!0)))}return i}function al(t){let e,r=sl.concat(nl,il);return(e=t.nodes.blockquote)&&r.push(ol(/^\s*>\s$/,e)),(e=t.nodes.ordered_list)&&r.push(ol(/^(\d+)\.\s$/,e,(t=>({order:+t[1]})),((t,e)=>e.childCount+e.attrs.order==+t[1]))),(e=t.nodes.bullet_list)&&r.push(function(t){return ol(/^\s*([-+*])\s$/,t)}(e)),(e=t.nodes.code_block)&&r.push(function(t){return ll(/^```$/,t)}(e)),(e=t.nodes.heading)&&r.push(function(t){return ll(new RegExp("^(#{1,6})\\s$"),t,(t=>({level:t[1].length})))}(e)),function({rules:t}){let e=new dr({state:{init:()=>null,apply(t,e){return t.getMeta(this)||(t.selectionSet||t.docChanged?null:e)}},props:{handleTextInput:(r,i,n,s)=>el(r,i,n,s,t,e),handleDOMEvents:{compositionend:r=>{setTimeout((()=>{let{$cursor:i}=r.state.selection;i&&el(r,i.pos,i.pos,"",t,e)}))}}},isInputRules:!0});return e}({rules:r})}function fl(t){let e=[al(t.schema),eo(hl(t.schema,t.mapKeys)),eo(Uo),Vo(),new dr({props:{decorations:Qo,createSelectionBetween:(t,e,r)=>e.pos==r.pos&&Wo.valid(r)?new Wo(r):null,handleClick:Yo,handleKeyDown:Zo,handleDOMEvents:{beforeinput:Xo}}})];return!1!==t.history&&e.push(function(t={}){return new dr({key:wo,state:{init:()=>new ho(lo.empty,lo.empty,null,0,-1),apply:(e,r,i)=>function(t,e,r,i){let n,s=r.getMeta(wo);if(s)return s.historyState;r.getMeta(vo)&&(t=new ho(t.done,t.undone,null,0,-1));let o=r.getMeta("appendedTransaction");if(0==r.steps.length)return t;if(o&&o.getMeta(wo))return o.getMeta(wo).redo?new ho(t.done.addTransform(r,void 0,i,bo(e)),t.undone,fo(r.mapping.maps[r.steps.length-1]),t.prevTime,t.prevComposition):new ho(t.done,t.undone.addTransform(r,void 0,i,bo(e)),null,t.prevTime,t.prevComposition);if(!1===r.getMeta("addToHistory")||o&&!1===o.getMeta("addToHistory"))return(n=r.getMeta("rebased"))?new ho(t.done.rebased(r,n),t.undone.rebased(r,n),co(t.prevRanges,r.mapping),t.prevTime,t.prevComposition):new ho(t.done.addMaps(r.mapping.maps),t.undone.addMaps(r.mapping.maps),co(t.prevRanges,r.mapping),t.prevTime,t.prevComposition);{let n=r.getMeta("composition"),s=0==t.prevTime||!o&&t.prevComposition!=n&&(t.prevTime<(r.time||0)-i.newGroupDelay||!function(t,e){if(!e)return!1;if(!t.docChanged)return!0;let r=!1;return t.mapping.maps[0].forEach(((t,i)=>{for(let n=0;n<e.length;n+=2)t<=e[n+1]&&i>=e[n]&&(r=!0)})),r}(r,t.prevRanges)),l=o?co(t.prevRanges,r.mapping):fo(r.mapping.maps[r.steps.length-1]);return new ho(t.done.addTransform(r,s?e.selection.getBookmark():void 0,i,bo(e)),lo.empty,l,r.time,null==n?t.prevComposition:n)}}(r,i,e,t)},config:t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},props:{handleDOMEvents:{beforeinput(t,e){let r=e.inputType,i="historyUndo"==r?ko:"historyRedo"==r?Do:null;return!!i&&(e.preventDefault(),i(t.state,t.dispatch))}}}})}()),e.concat(new dr({props:{attributes:{class:"ProseMirror-example-setup-style"}}}))}const cl=(t,e)=>{t.active=t=>{const{from:r,$from:i,to:n,empty:s}=t.selection;return s?!!e.isInSet(t.storedMarks||i.marks()):t.doc.rangeHasMark(r,n,e)}},dl=(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!0}}return!1}},pl=(t,e,r)=>{const i=t.marks[e];if(!i)throw new Error(`Mark "${e}" not found in schema`);const n=jo(i,ml(e,r));return cl(n,i),n},ml=(t,e)=>{if(t===s.Link&&e.href)return{href:e.href,target:gl(e.href)?"_blank":null}},gl=t=>!t.startsWith(window.location.origin),bl=(t,e,r={},i=!1)=>{const n=t.nodes[e],s=t.nodes.paragraph;return(t,e)=>{const{$from:o,$to:l}=t.selection,u=o.node(o.depth-1).type===n;return!!(t.selection instanceof Xe&&o.sameParent(o.doc.resolve(l.pos)))&&(o.parent.type===n?(e&&e(t.tr.setBlockType(o.pos,l.pos,s)),!0):u?Co(t,e):i?To(n,r)(t,e):zo(n,r)(t,e))}},wl=(t,e,r)=>{const i=t.nodes[e];if(!i)throw new Error(`Node type "${e}" not found in schema`);let n;return n=e===o.Heading&&r?bl(t,o.Heading,{level:r}):e===s.CodeBlock?bl(t,s.CodeBlock):zo(i),((t,e,r)=>{t.active=t=>{const{$from:i}=t.selection,n=i.node(i.depth);return!(!n||n.type.name!==e.name||e.name===o.Heading&&r&&n.attrs.level!==r)}})(n,i,r),n},vl=(t,e)=>{const r=t.nodes[e];if(!r)throw new Error(`List type "${e}" not found in schema`);const i=(t=>(e,r)=>{const{$from:i,$to:n}=e.selection,s=i.blockRange(n);if(!s)return!1;const o=s&&xe(s,t);if(o)return r&&r(e.tr.wrap(s,o).scrollIntoView()),!0;{const t=s&&Ee(s);return null!==t&&(r&&r(e.tr.lift(s,t).scrollIntoView()),!0)}})(r);return dl(i,r),i},kl={strong:pl,em:pl,underline:pl,strikethrough:pl,code:pl,link:(t,e,r)=>{const i=(e,i)=>{const{from:n,to:s}=e.selection,o=t.marks.link.create(h(r.href,r.href));if(n===s){const s=t.text(r.text||r.href,[o]);i(e.tr.insert(n,s))}else{const l=e.doc.textBetween(n,s," "),u=t.text(r.text||l,[o]);i(e.tr.replaceWith(n,s,u))}return!0};return cl(i,t.marks.link),i},headerlevel1:t=>wl(t,o.Heading,o.one),headerlevel2:t=>wl(t,o.Heading,o.two),headerlevel3:t=>wl(t,o.Heading,o.three),blockquote:t=>((t,e)=>{const r=t.nodes[e];if(!r)throw new Error(`Node type "${e}" not found in schema`);let i;return i=e===s.Blockquote?bl(t,s.Blockquote,{},!0):To(r),dl(i,r),i})(t,s.Blockquote),code_block:t=>wl(t,s.CodeBlock),ordered_list:t=>vl(t,s.OrderedList),bullet_list:t=>vl(t,s.BulletList)};class Dl{constructor(t){this.schema=t}getCommand(t,e){const r=kl[t];if(!r)throw new Error(`The Mark "${t}" is not supported`);return r(this.schema,t,e)}buildKeymap(){return{"Mod-B":this.getCommand(s.Bold),"Mod-I":this.getCommand(s.Italic),"Mod-Shift-1":this.getCommand(s.HeaderLevel1),"Mod-Shift-2":this.getCommand(s.HeaderLevel2),"Mod-Shift-3":this.getCommand(s.HeaderLevel3),"Mod-Shift-X":this.getCommand(s.Strikethrough),"Mod-`":this.getCommand(s.Code),"Mod-Shift-C":this.getCommand(s.CodeBlock)}}}const{mod:yl,shift:El}=/Macintosh|MacIntel|MacPPC|Mac68K/.test(navigator.userAgent)?{mod:"⌘",option:"⌥",shift:"⇧"}:{mod:"Ctrl",option:"Alt",shift:"Shift"},xl=[{value:s.Bold,text:"Bold",commandText:`${yl} B`,icon:"-lime-text-bold",iconOnly:!0,selected:!1},{value:s.Italic,text:"Italic",commandText:`${yl} I`,icon:"-lime-text-italic",iconOnly:!0,selected:!1},{value:s.Strikethrough,text:"Strikethrough",commandText:`${yl} ${El} X`,icon:"-lime-text-strikethrough",iconOnly:!0,selected:!1},{value:s.Link,text:"Link",icon:"-lime-text-link",iconOnly:!0},{separator:!0},{value:s.BulletList,text:"Bullet list",icon:"-lime-text-bulleted-list",iconOnly:!0,selected:!1},{value:s.OrderedList,text:"Numbered list",icon:"-lime-text-ordered-list",iconOnly:!0,selected:!1},{separator:!0},{value:s.HeaderLevel1,text:"Header 1",commandText:`${yl} ${El} 1`,icon:"-lime-text-h-heading-1",iconOnly:!0,selected:!1},{value:s.HeaderLevel2,text:"Header 2",commandText:`${yl} ${El} 2`,icon:"-lime-text-h-heading-2",iconOnly:!0,selected:!1},{value:s.HeaderLevel3,text:"Header 3",commandText:`${yl} ${El} 3`,icon:"-lime-text-h-heading-3",iconOnly:!0,selected:!1},{separator:!0},{value:s.Blockquote,text:"Blockquote",icon:"-lime-text-blockquote",iconOnly:!0,selected:!1},{separator:!0},{value:s.Code,text:"Code",commandText:`${yl} \``,icon:"-lime-text-code",iconOnly:!0,selected:!1},{value:s.CodeBlock,text:"Code Block",commandText:`${yl} ${El} C`,icon:"-lime-text-code-block",iconOnly:!0,selected:!1}],Fl=()=>Z(xl),Ml={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"},Al={};function Cl(t,e){"string"!=typeof e&&(e=Cl.defaultChars);const r=function(t){let e=Al[t];if(e)return e;e=Al[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}(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];else{if(192==(224&s)&&i+3<n){const r=parseInt(t.slice(i+4,i+6),16);if(128==(192&r)){const t=s<<6&1984|63&r;e+=t<128?"��":String.fromCharCode(t),i+=3;continue}}if(224==(240&s)&&i+6<n){const r=parseInt(t.slice(i+4,i+6),16),n=parseInt(t.slice(i+7,i+9),16);if(128==(192&r)&&128==(192&n)){const t=s<<12&61440|r<<6&4032|63&n;e+=t<2048||t>=55296&&t<=57343?"���":String.fromCharCode(t),i+=6;continue}}if(240==(248&s)&&i+9<n){const r=parseInt(t.slice(i+4,i+6),16),n=parseInt(t.slice(i+7,i+9),16),o=parseInt(t.slice(i+10,i+12),16);if(128==(192&r)&&128==(192&n)&&128==(192&o)){let t=s<<18&1835008|r<<12&258048|n<<6&4032|63&o;t<65536||t>1114111?e+="����":(t-=65536,e+=String.fromCharCode(55296+(t>>10),56320+(1023&t))),i+=9;continue}}e+="�"}}return e}))}Cl.defaultChars=";/?:@&=+$,#",Cl.componentChars="";const Sl={};function Ol(t,e,r){"string"!=typeof e&&(r=e,e=Ol.defaultChars),void 0===r&&(r=!0);const i=function(t){let e=Sl[t];if(e)return e;e=Sl[t]=[];for(let t=0;t<128;t++){const r=String.fromCharCode(t);/^[0-9a-z]$/i.test(r)?e.push(r):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}(e);let n="";for(let e=0,s=t.length;e<s;e++){const o=t.charCodeAt(e);if(r&&37===o&&e+2<s&&/^[0-9a-f]{2}$/i.test(t.slice(e+1,e+3)))n+=t.slice(e,e+3),e+=2;else if(o<128)n+=i[o];else if(o>=55296&&o<=57343){if(o>=55296&&o<=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"}else n+=encodeURIComponent(t[e])}return n}function $l(t){let e="";return e+=t.protocol||"",e+=t.slashes?"//":"",e+=t.auth?t.auth+"@":"",t.hostname&&-1!==t.hostname.indexOf(":")?e+="["+t.hostname+"]":e+=t.hostname||"",e+=t.port?":"+t.port:"",e+=t.pathname||"",e+=t.search||"",e+=t.hash||"",e}function Bl(){this.protocol=null,this.slashes=null,this.auth=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.pathname=null}Ol.defaultChars=";/?:@&=+$,-_.!~*'()#",Ol.componentChars="-_.!~*'()";const Rl=/^([a-z0-9.+-]+:)/i,Nl=/:[0-9]*$/,_l=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,Tl=["{","}","|","\\","^","`"].concat(["<",">",'"',"`"," ","\r","\n","\t"]),zl=["'"].concat(Tl),jl=["%","/","?",";","#"].concat(zl),ql=["/","?","#"],Il=/^[+a-z0-9A-Z_-]{0,63}$/,Pl=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,Ll={javascript:!0,"javascript:":!0},Jl={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0};function Ul(t,e){if(t&&t instanceof Bl)return t;const r=new Bl;return r.parse(t,e),r}Bl.prototype.parse=function(t,e){let r,i,n,s=t;if(s=s.trim(),!e&&1===t.split("#").length){const t=_l.exec(s);if(t)return this.pathname=t[1],t[2]&&(this.search=t[2]),this}let o=Rl.exec(s);if(o&&(o=o[0],r=o.toLowerCase(),this.protocol=o,s=s.substr(o.length)),(e||o||s.match(/^\/\/[^@\/]+@[^@\/]+/))&&(n="//"===s.substr(0,2),!n||o&&Ll[o]||(s=s.substr(2),this.slashes=!0)),!Ll[o]&&(n||o&&!Jl[o])){let t,e,r=-1;for(let t=0;t<ql.length;t++)i=s.indexOf(ql[t]),-1!==i&&(-1===r||i<r)&&(r=i);e=-1===r?s.lastIndexOf("@"):s.lastIndexOf("@",r),-1!==e&&(t=s.slice(0,e),s=s.slice(e+1),this.auth=t),r=-1;for(let t=0;t<jl.length;t++)i=s.indexOf(jl[t]),-1!==i&&(-1===r||i<r)&&(r=i);-1===r&&(r=s.length),":"===s[r-1]&&r--;const n=s.slice(0,r);s=s.slice(r),this.parseHost(n),this.hostname=this.hostname||"";const o="["===this.hostname[0]&&"]"===this.hostname[this.hostname.length-1];if(!o){const t=this.hostname.split(/\./);for(let e=0,r=t.length;e<r;e++){const r=t[e];if(r&&!r.match(Il)){let i="";for(let t=0,e=r.length;t<e;t++)r.charCodeAt(t)>127?i+="x":i+=r[t];if(!i.match(Il)){const i=t.slice(0,e),n=t.slice(e+1),o=r.match(Pl);o&&(i.push(o[1]),n.unshift(o[2])),n.length&&(s=n.join(".")+s),this.hostname=i.join(".");break}}}}this.hostname.length>255&&(this.hostname=""),o&&(this.hostname=this.hostname.substr(1,this.hostname.length-2))}const l=s.indexOf("#");-1!==l&&(this.hash=s.substr(l),s=s.slice(0,l));const u=s.indexOf("?");return-1!==u&&(this.search=s.substr(u),s=s.slice(0,u)),s&&(this.pathname=s),Jl[r]&&this.hostname&&!this.pathname&&(this.pathname=""),this},Bl.prototype.parseHost=function(t){let e=Nl.exec(t);e&&(e=e[0],":"!==e&&(this.port=e.substr(1)),t=t.substr(0,t.length-e.length)),t&&(this.hostname=t)};var Vl,Hl,Wl=Object.freeze({__proto__:null,decode:Cl,encode:Ol,format:$l,parse:Ul}),Gl=/[\0-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,Zl=/[\0-\x1F\x7F-\x9F]/,Kl=/[!-#%-\*,-\/:;\?@\[-\]_\{\}\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]/,Yl=/[\$\+<->\^`\|~\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]/,Xl=/[ \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000]/,Ql=Object.freeze({__proto__:null,Any:Gl,Cc:Zl,Cf:/[\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]/,P:Kl,S:Yl,Z:Xl});function tu(t){for(let e=1;e<t.length;e++)t[e][0]+=t[e-1][0]+1;return t}function eu(t){return"[object String]"===function(t){return Object.prototype.toString.call(t)}(t)}new Map(tu([[9,"&Tab;"],[0,"&NewLine;"],[22,"&excl;"],[0,"&quot;"],[0,"&num;"],[0,"&dollar;"],[0,"&percnt;"],[0,"&amp;"],[0,"&apos;"],[0,"&lpar;"],[0,"&rpar;"],[0,"&ast;"],[0,"&plus;"],[0,"&comma;"],[1,"&period;"],[0,"&sol;"],[10,"&colon;"],[0,"&semi;"],[0,{v:"&lt;",n:8402,o:"&nvlt;"}],[0,{v:"&equals;",n:8421,o:"&bne;"}],[0,{v:"&gt;",n:8402,o:"&nvgt;"}],[0,"&quest;"],[0,"&commat;"],[26,"&lbrack;"],[0,"&bsol;"],[0,"&rbrack;"],[0,"&Hat;"],[0,"&lowbar;"],[0,"&DiacriticalGrave;"],[5,{n:106,o:"&fjlig;"}],[20,"&lbrace;"],[0,"&verbar;"],[0,"&rbrace;"],[34,"&nbsp;"],[0,"&iexcl;"],[0,"&cent;"],[0,"&pound;"],[0,"&curren;"],[0,"&yen;"],[0,"&brvbar;"],[0,"&sect;"],[0,"&die;"],[0,"&copy;"],[0,"&ordf;"],[0,"&laquo;"],[0,"&not;"],[0,"&shy;"],[0,"&circledR;"],[0,"&macr;"],[0,"&deg;"],[0,"&PlusMinus;"],[0,"&sup2;"],[0,"&sup3;"],[0,"&acute;"],[0,"&micro;"],[0,"&para;"],[0,"&centerdot;"],[0,"&cedil;"],[0,"&sup1;"],[0,"&ordm;"],[0,"&raquo;"],[0,"&frac14;"],[0,"&frac12;"],[0,"&frac34;"],[0,"&iquest;"],[0,"&Agrave;"],[0,"&Aacute;"],[0,"&Acirc;"],[0,"&Atilde;"],[0,"&Auml;"],[0,"&angst;"],[0,"&AElig;"],[0,"&Ccedil;"],[0,"&Egrave;"],[0,"&Eacute;"],[0,"&Ecirc;"],[0,"&Euml;"],[0,"&Igrave;"],[0,"&Iacute;"],[0,"&Icirc;"],[0,"&Iuml;"],[0,"&ETH;"],[0,"&Ntilde;"],[0,"&Ograve;"],[0,"&Oacute;"],[0,"&Ocirc;"],[0,"&Otilde;"],[0,"&Ouml;"],[0,"&times;"],[0,"&Oslash;"],[0,"&Ugrave;"],[0,"&Uacute;"],[0,"&Ucirc;"],[0,"&Uuml;"],[0,"&Yacute;"],[0,"&THORN;"],[0,"&szlig;"],[0,"&agrave;"],[0,"&aacute;"],[0,"&acirc;"],[0,"&atilde;"],[0,"&auml;"],[0,"&aring;"],[0,"&aelig;"],[0,"&ccedil;"],[0,"&egrave;"],[0,"&eacute;"],[0,"&ecirc;"],[0,"&euml;"],[0,"&igrave;"],[0,"&iacute;"],[0,"&icirc;"],[0,"&iuml;"],[0,"&eth;"],[0,"&ntilde;"],[0,"&ograve;"],[0,"&oacute;"],[0,"&ocirc;"],[0,"&otilde;"],[0,"&ouml;"],[0,"&div;"],[0,"&oslash;"],[0,"&ugrave;"],[0,"&uacute;"],[0,"&ucirc;"],[0,"&uuml;"],[0,"&yacute;"],[0,"&thorn;"],[0,"&yuml;"],[0,"&Amacr;"],[0,"&amacr;"],[0,"&Abreve;"],[0,"&abreve;"],[0,"&Aogon;"],[0,"&aogon;"],[0,"&Cacute;"],[0,"&cacute;"],[0,"&Ccirc;"],[0,"&ccirc;"],[0,"&Cdot;"],[0,"&cdot;"],[0,"&Ccaron;"],[0,"&ccaron;"],[0,"&Dcaron;"],[0,"&dcaron;"],[0,"&Dstrok;"],[0,"&dstrok;"],[0,"&Emacr;"],[0,"&emacr;"],[2,"&Edot;"],[0,"&edot;"],[0,"&Eogon;"],[0,"&eogon;"],[0,"&Ecaron;"],[0,"&ecaron;"],[0,"&Gcirc;"],[0,"&gcirc;"],[0,"&Gbreve;"],[0,"&gbreve;"],[0,"&Gdot;"],[0,"&gdot;"],[0,"&Gcedil;"],[1,"&Hcirc;"],[0,"&hcirc;"],[0,"&Hstrok;"],[0,"&hstrok;"],[0,"&Itilde;"],[0,"&itilde;"],[0,"&Imacr;"],[0,"&imacr;"],[2,"&Iogon;"],[0,"&iogon;"],[0,"&Idot;"],[0,"&imath;"],[0,"&IJlig;"],[0,"&ijlig;"],[0,"&Jcirc;"],[0,"&jcirc;"],[0,"&Kcedil;"],[0,"&kcedil;"],[0,"&kgreen;"],[0,"&Lacute;"],[0,"&lacute;"],[0,"&Lcedil;"],[0,"&lcedil;"],[0,"&Lcaron;"],[0,"&lcaron;"],[0,"&Lmidot;"],[0,"&lmidot;"],[0,"&Lstrok;"],[0,"&lstrok;"],[0,"&Nacute;"],[0,"&nacute;"],[0,"&Ncedil;"],[0,"&ncedil;"],[0,"&Ncaron;"],[0,"&ncaron;"],[0,"&napos;"],[0,"&ENG;"],[0,"&eng;"],[0,"&Omacr;"],[0,"&omacr;"],[2,"&Odblac;"],[0,"&odblac;"],[0,"&OElig;"],[0,"&oelig;"],[0,"&Racute;"],[0,"&racute;"],[0,"&Rcedil;"],[0,"&rcedil;"],[0,"&Rcaron;"],[0,"&rcaron;"],[0,"&Sacute;"],[0,"&sacute;"],[0,"&Scirc;"],[0,"&scirc;"],[0,"&Scedil;"],[0,"&scedil;"],[0,"&Scaron;"],[0,"&scaron;"],[0,"&Tcedil;"],[0,"&tcedil;"],[0,"&Tcaron;"],[0,"&tcaron;"],[0,"&Tstrok;"],[0,"&tstrok;"],[0,"&Utilde;"],[0,"&utilde;"],[0,"&Umacr;"],[0,"&umacr;"],[0,"&Ubreve;"],[0,"&ubreve;"],[0,"&Uring;"],[0,"&uring;"],[0,"&Udblac;"],[0,"&udblac;"],[0,"&Uogon;"],[0,"&uogon;"],[0,"&Wcirc;"],[0,"&wcirc;"],[0,"&Ycirc;"],[0,"&ycirc;"],[0,"&Yuml;"],[0,"&Zacute;"],[0,"&zacute;"],[0,"&Zdot;"],[0,"&zdot;"],[0,"&Zcaron;"],[0,"&zcaron;"],[19,"&fnof;"],[34,"&imped;"],[63,"&gacute;"],[65,"&jmath;"],[142,"&circ;"],[0,"&caron;"],[16,"&breve;"],[0,"&DiacriticalDot;"],[0,"&ring;"],[0,"&ogon;"],[0,"&DiacriticalTilde;"],[0,"&dblac;"],[51,"&DownBreve;"],[127,"&Alpha;"],[0,"&Beta;"],[0,"&Gamma;"],[0,"&Delta;"],[0,"&Epsilon;"],[0,"&Zeta;"],[0,"&Eta;"],[0,"&Theta;"],[0,"&Iota;"],[0,"&Kappa;"],[0,"&Lambda;"],[0,"&Mu;"],[0,"&Nu;"],[0,"&Xi;"],[0,"&Omicron;"],[0,"&Pi;"],[0,"&Rho;"],[1,"&Sigma;"],[0,"&Tau;"],[0,"&Upsilon;"],[0,"&Phi;"],[0,"&Chi;"],[0,"&Psi;"],[0,"&ohm;"],[7,"&alpha;"],[0,"&beta;"],[0,"&gamma;"],[0,"&delta;"],[0,"&epsi;"],[0,"&zeta;"],[0,"&eta;"],[0,"&theta;"],[0,"&iota;"],[0,"&kappa;"],[0,"&lambda;"],[0,"&mu;"],[0,"&nu;"],[0,"&xi;"],[0,"&omicron;"],[0,"&pi;"],[0,"&rho;"],[0,"&sigmaf;"],[0,"&sigma;"],[0,"&tau;"],[0,"&upsi;"],[0,"&phi;"],[0,"&chi;"],[0,"&psi;"],[0,"&omega;"],[7,"&thetasym;"],[0,"&Upsi;"],[2,"&phiv;"],[0,"&piv;"],[5,"&Gammad;"],[0,"&digamma;"],[18,"&kappav;"],[0,"&rhov;"],[3,"&epsiv;"],[0,"&backepsilon;"],[10,"&IOcy;"],[0,"&DJcy;"],[0,"&GJcy;"],[0,"&Jukcy;"],[0,"&DScy;"],[0,"&Iukcy;"],[0,"&YIcy;"],[0,"&Jsercy;"],[0,"&LJcy;"],[0,"&NJcy;"],[0,"&TSHcy;"],[0,"&KJcy;"],[1,"&Ubrcy;"],[0,"&DZcy;"],[0,"&Acy;"],[0,"&Bcy;"],[0,"&Vcy;"],[0,"&Gcy;"],[0,"&Dcy;"],[0,"&IEcy;"],[0,"&ZHcy;"],[0,"&Zcy;"],[0,"&Icy;"],[0,"&Jcy;"],[0,"&Kcy;"],[0,"&Lcy;"],[0,"&Mcy;"],[0,"&Ncy;"],[0,"&Ocy;"],[0,"&Pcy;"],[0,"&Rcy;"],[0,"&Scy;"],[0,"&Tcy;"],[0,"&Ucy;"],[0,"&Fcy;"],[0,"&KHcy;"],[0,"&TScy;"],[0,"&CHcy;"],[0,"&SHcy;"],[0,"&SHCHcy;"],[0,"&HARDcy;"],[0,"&Ycy;"],[0,"&SOFTcy;"],[0,"&Ecy;"],[0,"&YUcy;"],[0,"&YAcy;"],[0,"&acy;"],[0,"&bcy;"],[0,"&vcy;"],[0,"&gcy;"],[0,"&dcy;"],[0,"&iecy;"],[0,"&zhcy;"],[0,"&zcy;"],[0,"&icy;"],[0,"&jcy;"],[0,"&kcy;"],[0,"&lcy;"],[0,"&mcy;"],[0,"&ncy;"],[0,"&ocy;"],[0,"&pcy;"],[0,"&rcy;"],[0,"&scy;"],[0,"&tcy;"],[0,"&ucy;"],[0,"&fcy;"],[0,"&khcy;"],[0,"&tscy;"],[0,"&chcy;"],[0,"&shcy;"],[0,"&shchcy;"],[0,"&hardcy;"],[0,"&ycy;"],[0,"&softcy;"],[0,"&ecy;"],[0,"&yucy;"],[0,"&yacy;"],[1,"&iocy;"],[0,"&djcy;"],[0,"&gjcy;"],[0,"&jukcy;"],[0,"&dscy;"],[0,"&iukcy;"],[0,"&yicy;"],[0,"&jsercy;"],[0,"&ljcy;"],[0,"&njcy;"],[0,"&tshcy;"],[0,"&kjcy;"],[1,"&ubrcy;"],[0,"&dzcy;"],[7074,"&ensp;"],[0,"&emsp;"],[0,"&emsp13;"],[0,"&emsp14;"],[1,"&numsp;"],[0,"&puncsp;"],[0,"&ThinSpace;"],[0,"&hairsp;"],[0,"&NegativeMediumSpace;"],[0,"&zwnj;"],[0,"&zwj;"],[0,"&lrm;"],[0,"&rlm;"],[0,"&dash;"],[2,"&ndash;"],[0,"&mdash;"],[0,"&horbar;"],[0,"&Verbar;"],[1,"&lsquo;"],[0,"&CloseCurlyQuote;"],[0,"&lsquor;"],[1,"&ldquo;"],[0,"&CloseCurlyDoubleQuote;"],[0,"&bdquo;"],[1,"&dagger;"],[0,"&Dagger;"],[0,"&bull;"],[2,"&nldr;"],[0,"&hellip;"],[9,"&permil;"],[0,"&pertenk;"],[0,"&prime;"],[0,"&Prime;"],[0,"&tprime;"],[0,"&backprime;"],[3,"&lsaquo;"],[0,"&rsaquo;"],[3,"&oline;"],[2,"&caret;"],[1,"&hybull;"],[0,"&frasl;"],[10,"&bsemi;"],[7,"&qprime;"],[7,{v:"&MediumSpace;",n:8202,o:"&ThickSpace;"}],[0,"&NoBreak;"],[0,"&af;"],[0,"&InvisibleTimes;"],[0,"&ic;"],[72,"&euro;"],[46,"&tdot;"],[0,"&DotDot;"],[37,"&complexes;"],[2,"&incare;"],[4,"&gscr;"],[0,"&hamilt;"],[0,"&Hfr;"],[0,"&Hopf;"],[0,"&planckh;"],[0,"&hbar;"],[0,"&imagline;"],[0,"&Ifr;"],[0,"&lagran;"],[0,"&ell;"],[1,"&naturals;"],[0,"&numero;"],[0,"&copysr;"],[0,"&weierp;"],[0,"&Popf;"],[0,"&Qopf;"],[0,"&realine;"],[0,"&real;"],[0,"&reals;"],[0,"&rx;"],[3,"&trade;"],[1,"&integers;"],[2,"&mho;"],[0,"&zeetrf;"],[0,"&iiota;"],[2,"&bernou;"],[0,"&Cayleys;"],[1,"&escr;"],[0,"&Escr;"],[0,"&Fouriertrf;"],[1,"&Mellintrf;"],[0,"&order;"],[0,"&alefsym;"],[0,"&beth;"],[0,"&gimel;"],[0,"&daleth;"],[12,"&CapitalDifferentialD;"],[0,"&dd;"],[0,"&ee;"],[0,"&ii;"],[10,"&frac13;"],[0,"&frac23;"],[0,"&frac15;"],[0,"&frac25;"],[0,"&frac35;"],[0,"&frac45;"],[0,"&frac16;"],[0,"&frac56;"],[0,"&frac18;"],[0,"&frac38;"],[0,"&frac58;"],[0,"&frac78;"],[49,"&larr;"],[0,"&ShortUpArrow;"],[0,"&rarr;"],[0,"&darr;"],[0,"&harr;"],[0,"&updownarrow;"],[0,"&nwarr;"],[0,"&nearr;"],[0,"&LowerRightArrow;"],[0,"&LowerLeftArrow;"],[0,"&nlarr;"],[0,"&nrarr;"],[1,{v:"&rarrw;",n:824,o:"&nrarrw;"}],[0,"&Larr;"],[0,"&Uarr;"],[0,"&Rarr;"],[0,"&Darr;"],[0,"&larrtl;"],[0,"&rarrtl;"],[0,"&LeftTeeArrow;"],[0,"&mapstoup;"],[0,"&map;"],[0,"&DownTeeArrow;"],[1,"&hookleftarrow;"],[0,"&hookrightarrow;"],[0,"&larrlp;"],[0,"&looparrowright;"],[0,"&harrw;"],[0,"&nharr;"],[1,"&lsh;"],[0,"&rsh;"],[0,"&ldsh;"],[0,"&rdsh;"],[1,"&crarr;"],[0,"&cularr;"],[0,"&curarr;"],[2,"&circlearrowleft;"],[0,"&circlearrowright;"],[0,"&leftharpoonup;"],[0,"&DownLeftVector;"],[0,"&RightUpVector;"],[0,"&LeftUpVector;"],[0,"&rharu;"],[0,"&DownRightVector;"],[0,"&dharr;"],[0,"&dharl;"],[0,"&RightArrowLeftArrow;"],[0,"&udarr;"],[0,"&LeftArrowRightArrow;"],[0,"&leftleftarrows;"],[0,"&upuparrows;"],[0,"&rightrightarrows;"],[0,"&ddarr;"],[0,"&leftrightharpoons;"],[0,"&Equilibrium;"],[0,"&nlArr;"],[0,"&nhArr;"],[0,"&nrArr;"],[0,"&DoubleLeftArrow;"],[0,"&DoubleUpArrow;"],[0,"&DoubleRightArrow;"],[0,"&dArr;"],[0,"&DoubleLeftRightArrow;"],[0,"&DoubleUpDownArrow;"],[0,"&nwArr;"],[0,"&neArr;"],[0,"&seArr;"],[0,"&swArr;"],[0,"&lAarr;"],[0,"&rAarr;"],[1,"&zigrarr;"],[6,"&larrb;"],[0,"&rarrb;"],[15,"&DownArrowUpArrow;"],[7,"&loarr;"],[0,"&roarr;"],[0,"&hoarr;"],[0,"&forall;"],[0,"&comp;"],[0,{v:"&part;",n:824,o:"&npart;"}],[0,"&exist;"],[0,"&nexist;"],[0,"&empty;"],[1,"&Del;"],[0,"&Element;"],[0,"&NotElement;"],[1,"&ni;"],[0,"&notni;"],[2,"&prod;"],[0,"&coprod;"],[0,"&sum;"],[0,"&minus;"],[0,"&MinusPlus;"],[0,"&dotplus;"],[1,"&Backslash;"],[0,"&lowast;"],[0,"&compfn;"],[1,"&radic;"],[2,"&prop;"],[0,"&infin;"],[0,"&angrt;"],[0,{v:"&ang;",n:8402,o:"&nang;"}],[0,"&angmsd;"],[0,"&angsph;"],[0,"&mid;"],[0,"&nmid;"],[0,"&DoubleVerticalBar;"],[0,"&NotDoubleVerticalBar;"],[0,"&and;"],[0,"&or;"],[0,{v:"&cap;",n:65024,o:"&caps;"}],[0,{v:"&cup;",n:65024,o:"&cups;"}],[0,"&int;"],[0,"&Int;"],[0,"&iiint;"],[0,"&conint;"],[0,"&Conint;"],[0,"&Cconint;"],[0,"&cwint;"],[0,"&ClockwiseContourIntegral;"],[0,"&awconint;"],[0,"&there4;"],[0,"&becaus;"],[0,"&ratio;"],[0,"&Colon;"],[0,"&dotminus;"],[1,"&mDDot;"],[0,"&homtht;"],[0,{v:"&sim;",n:8402,o:"&nvsim;"}],[0,{v:"&backsim;",n:817,o:"&race;"}],[0,{v:"&ac;",n:819,o:"&acE;"}],[0,"&acd;"],[0,"&VerticalTilde;"],[0,"&NotTilde;"],[0,{v:"&eqsim;",n:824,o:"&nesim;"}],[0,"&sime;"],[0,"&NotTildeEqual;"],[0,"&cong;"],[0,"&simne;"],[0,"&ncong;"],[0,"&ap;"],[0,"&nap;"],[0,"&ape;"],[0,{v:"&apid;",n:824,o:"&napid;"}],[0,"&backcong;"],[0,{v:"&asympeq;",n:8402,o:"&nvap;"}],[0,{v:"&bump;",n:824,o:"&nbump;"}],[0,{v:"&bumpe;",n:824,o:"&nbumpe;"}],[0,{v:"&doteq;",n:824,o:"&nedot;"}],[0,"&doteqdot;"],[0,"&efDot;"],[0,"&erDot;"],[0,"&Assign;"],[0,"&ecolon;"],[0,"&ecir;"],[0,"&circeq;"],[1,"&wedgeq;"],[0,"&veeeq;"],[1,"&triangleq;"],[2,"&equest;"],[0,"&ne;"],[0,{v:"&Congruent;",n:8421,o:"&bnequiv;"}],[0,"&nequiv;"],[1,{v:"&le;",n:8402,o:"&nvle;"}],[0,{v:"&ge;",n:8402,o:"&nvge;"}],[0,{v:"&lE;",n:824,o:"&nlE;"}],[0,{v:"&gE;",n:824,o:"&ngE;"}],[0,{v:"&lnE;",n:65024,o:"&lvertneqq;"}],[0,{v:"&gnE;",n:65024,o:"&gvertneqq;"}],[0,{v:"&ll;",n:new Map(tu([[824,"&nLtv;"],[7577,"&nLt;"]]))}],[0,{v:"&gg;",n:new Map(tu([[824,"&nGtv;"],[7577,"&nGt;"]]))}],[0,"&between;"],[0,"&NotCupCap;"],[0,"&nless;"],[0,"&ngt;"],[0,"&nle;"],[0,"&nge;"],[0,"&lesssim;"],[0,"&GreaterTilde;"],[0,"&nlsim;"],[0,"&ngsim;"],[0,"&LessGreater;"],[0,"&gl;"],[0,"&NotLessGreater;"],[0,"&NotGreaterLess;"],[0,"&pr;"],[0,"&sc;"],[0,"&prcue;"],[0,"&sccue;"],[0,"&PrecedesTilde;"],[0,{v:"&scsim;",n:824,o:"&NotSucceedsTilde;"}],[0,"&NotPrecedes;"],[0,"&NotSucceeds;"],[0,{v:"&sub;",n:8402,o:"&NotSubset;"}],[0,{v:"&sup;",n:8402,o:"&NotSuperset;"}],[0,"&nsub;"],[0,"&nsup;"],[0,"&sube;"],[0,"&supe;"],[0,"&NotSubsetEqual;"],[0,"&NotSupersetEqual;"],[0,{v:"&subne;",n:65024,o:"&varsubsetneq;"}],[0,{v:"&supne;",n:65024,o:"&varsupsetneq;"}],[1,"&cupdot;"],[0,"&UnionPlus;"],[0,{v:"&sqsub;",n:824,o:"&NotSquareSubset;"}],[0,{v:"&sqsup;",n:824,o:"&NotSquareSuperset;"}],[0,"&sqsube;"],[0,"&sqsupe;"],[0,{v:"&sqcap;",n:65024,o:"&sqcaps;"}],[0,{v:"&sqcup;",n:65024,o:"&sqcups;"}],[0,"&CirclePlus;"],[0,"&CircleMinus;"],[0,"&CircleTimes;"],[0,"&osol;"],[0,"&CircleDot;"],[0,"&circledcirc;"],[0,"&circledast;"],[1,"&circleddash;"],[0,"&boxplus;"],[0,"&boxminus;"],[0,"&boxtimes;"],[0,"&dotsquare;"],[0,"&RightTee;"],[0,"&dashv;"],[0,"&DownTee;"],[0,"&bot;"],[1,"&models;"],[0,"&DoubleRightTee;"],[0,"&Vdash;"],[0,"&Vvdash;"],[0,"&VDash;"],[0,"&nvdash;"],[0,"&nvDash;"],[0,"&nVdash;"],[0,"&nVDash;"],[0,"&prurel;"],[1,"&LeftTriangle;"],[0,"&RightTriangle;"],[0,{v:"&LeftTriangleEqual;",n:8402,o:"&nvltrie;"}],[0,{v:"&RightTriangleEqual;",n:8402,o:"&nvrtrie;"}],[0,"&origof;"],[0,"&imof;"],[0,"&multimap;"],[0,"&hercon;"],[0,"&intcal;"],[0,"&veebar;"],[1,"&barvee;"],[0,"&angrtvb;"],[0,"&lrtri;"],[0,"&bigwedge;"],[0,"&bigvee;"],[0,"&bigcap;"],[0,"&bigcup;"],[0,"&diam;"],[0,"&sdot;"],[0,"&sstarf;"],[0,"&divideontimes;"],[0,"&bowtie;"],[0,"&ltimes;"],[0,"&rtimes;"],[0,"&leftthreetimes;"],[0,"&rightthreetimes;"],[0,"&backsimeq;"],[0,"&curlyvee;"],[0,"&curlywedge;"],[0,"&Sub;"],[0,"&Sup;"],[0,"&Cap;"],[0,"&Cup;"],[0,"&fork;"],[0,"&epar;"],[0,"&lessdot;"],[0,"&gtdot;"],[0,{v:"&Ll;",n:824,o:"&nLl;"}],[0,{v:"&Gg;",n:824,o:"&nGg;"}],[0,{v:"&leg;",n:65024,o:"&lesg;"}],[0,{v:"&gel;",n:65024,o:"&gesl;"}],[2,"&cuepr;"],[0,"&cuesc;"],[0,"&NotPrecedesSlantEqual;"],[0,"&NotSucceedsSlantEqual;"],[0,"&NotSquareSubsetEqual;"],[0,"&NotSquareSupersetEqual;"],[2,"&lnsim;"],[0,"&gnsim;"],[0,"&precnsim;"],[0,"&scnsim;"],[0,"&nltri;"],[0,"&NotRightTriangle;"],[0,"&nltrie;"],[0,"&NotRightTriangleEqual;"],[0,"&vellip;"],[0,"&ctdot;"],[0,"&utdot;"],[0,"&dtdot;"],[0,"&disin;"],[0,"&isinsv;"],[0,"&isins;"],[0,{v:"&isindot;",n:824,o:"&notindot;"}],[0,"&notinvc;"],[0,"&notinvb;"],[1,{v:"&isinE;",n:824,o:"&notinE;"}],[0,"&nisd;"],[0,"&xnis;"],[0,"&nis;"],[0,"&notnivc;"],[0,"&notnivb;"],[6,"&barwed;"],[0,"&Barwed;"],[1,"&lceil;"],[0,"&rceil;"],[0,"&LeftFloor;"],[0,"&rfloor;"],[0,"&drcrop;"],[0,"&dlcrop;"],[0,"&urcrop;"],[0,"&ulcrop;"],[0,"&bnot;"],[1,"&profline;"],[0,"&profsurf;"],[1,"&telrec;"],[0,"&target;"],[5,"&ulcorn;"],[0,"&urcorn;"],[0,"&dlcorn;"],[0,"&drcorn;"],[2,"&frown;"],[0,"&smile;"],[9,"&cylcty;"],[0,"&profalar;"],[7,"&topbot;"],[6,"&ovbar;"],[1,"&solbar;"],[60,"&angzarr;"],[51,"&lmoustache;"],[0,"&rmoustache;"],[2,"&OverBracket;"],[0,"&bbrk;"],[0,"&bbrktbrk;"],[37,"&OverParenthesis;"],[0,"&UnderParenthesis;"],[0,"&OverBrace;"],[0,"&UnderBrace;"],[2,"&trpezium;"],[4,"&elinters;"],[59,"&blank;"],[164,"&circledS;"],[55,"&boxh;"],[1,"&boxv;"],[9,"&boxdr;"],[3,"&boxdl;"],[3,"&boxur;"],[3,"&boxul;"],[3,"&boxvr;"],[7,"&boxvl;"],[7,"&boxhd;"],[7,"&boxhu;"],[7,"&boxvh;"],[19,"&boxH;"],[0,"&boxV;"],[0,"&boxdR;"],[0,"&boxDr;"],[0,"&boxDR;"],[0,"&boxdL;"],[0,"&boxDl;"],[0,"&boxDL;"],[0,"&boxuR;"],[0,"&boxUr;"],[0,"&boxUR;"],[0,"&boxuL;"],[0,"&boxUl;"],[0,"&boxUL;"],[0,"&boxvR;"],[0,"&boxVr;"],[0,"&boxVR;"],[0,"&boxvL;"],[0,"&boxVl;"],[0,"&boxVL;"],[0,"&boxHd;"],[0,"&boxhD;"],[0,"&boxHD;"],[0,"&boxHu;"],[0,"&boxhU;"],[0,"&boxHU;"],[0,"&boxvH;"],[0,"&boxVh;"],[0,"&boxVH;"],[19,"&uhblk;"],[3,"&lhblk;"],[3,"&block;"],[8,"&blk14;"],[0,"&blk12;"],[0,"&blk34;"],[13,"&square;"],[8,"&blacksquare;"],[0,"&EmptyVerySmallSquare;"],[1,"&rect;"],[0,"&marker;"],[2,"&fltns;"],[1,"&bigtriangleup;"],[0,"&blacktriangle;"],[0,"&triangle;"],[2,"&blacktriangleright;"],[0,"&rtri;"],[3,"&bigtriangledown;"],[0,"&blacktriangledown;"],[0,"&dtri;"],[2,"&blacktriangleleft;"],[0,"&ltri;"],[6,"&loz;"],[0,"&cir;"],[32,"&tridot;"],[2,"&bigcirc;"],[8,"&ultri;"],[0,"&urtri;"],[0,"&lltri;"],[0,"&EmptySmallSquare;"],[0,"&FilledSmallSquare;"],[8,"&bigstar;"],[0,"&star;"],[7,"&phone;"],[49,"&female;"],[1,"&male;"],[29,"&spades;"],[2,"&clubs;"],[1,"&hearts;"],[0,"&diamondsuit;"],[3,"&sung;"],[2,"&flat;"],[0,"&natural;"],[0,"&sharp;"],[163,"&check;"],[3,"&cross;"],[8,"&malt;"],[21,"&sext;"],[33,"&VerticalSeparator;"],[25,"&lbbrk;"],[0,"&rbbrk;"],[84,"&bsolhsub;"],[0,"&suphsol;"],[28,"&LeftDoubleBracket;"],[0,"&RightDoubleBracket;"],[0,"&lang;"],[0,"&rang;"],[0,"&Lang;"],[0,"&Rang;"],[0,"&loang;"],[0,"&roang;"],[7,"&longleftarrow;"],[0,"&longrightarrow;"],[0,"&longleftrightarrow;"],[0,"&DoubleLongLeftArrow;"],[0,"&DoubleLongRightArrow;"],[0,"&DoubleLongLeftRightArrow;"],[1,"&longmapsto;"],[2,"&dzigrarr;"],[258,"&nvlArr;"],[0,"&nvrArr;"],[0,"&nvHarr;"],[0,"&Map;"],[6,"&lbarr;"],[0,"&bkarow;"],[0,"&lBarr;"],[0,"&dbkarow;"],[0,"&drbkarow;"],[0,"&DDotrahd;"],[0,"&UpArrowBar;"],[0,"&DownArrowBar;"],[2,"&Rarrtl;"],[2,"&latail;"],[0,"&ratail;"],[0,"&lAtail;"],[0,"&rAtail;"],[0,"&larrfs;"],[0,"&rarrfs;"],[0,"&larrbfs;"],[0,"&rarrbfs;"],[2,"&nwarhk;"],[0,"&nearhk;"],[0,"&hksearow;"],[0,"&hkswarow;"],[0,"&nwnear;"],[0,"&nesear;"],[0,"&seswar;"],[0,"&swnwar;"],[8,{v:"&rarrc;",n:824,o:"&nrarrc;"}],[1,"&cudarrr;"],[0,"&ldca;"],[0,"&rdca;"],[0,"&cudarrl;"],[0,"&larrpl;"],[2,"&curarrm;"],[0,"&cularrp;"],[7,"&rarrpl;"],[2,"&harrcir;"],[0,"&Uarrocir;"],[0,"&lurdshar;"],[0,"&ldrushar;"],[2,"&LeftRightVector;"],[0,"&RightUpDownVector;"],[0,"&DownLeftRightVector;"],[0,"&LeftUpDownVector;"],[0,"&LeftVectorBar;"],[0,"&RightVectorBar;"],[0,"&RightUpVectorBar;"],[0,"&RightDownVectorBar;"],[0,"&DownLeftVectorBar;"],[0,"&DownRightVectorBar;"],[0,"&LeftUpVectorBar;"],[0,"&LeftDownVectorBar;"],[0,"&LeftTeeVector;"],[0,"&RightTeeVector;"],[0,"&RightUpTeeVector;"],[0,"&RightDownTeeVector;"],[0,"&DownLeftTeeVector;"],[0,"&DownRightTeeVector;"],[0,"&LeftUpTeeVector;"],[0,"&LeftDownTeeVector;"],[0,"&lHar;"],[0,"&uHar;"],[0,"&rHar;"],[0,"&dHar;"],[0,"&luruhar;"],[0,"&ldrdhar;"],[0,"&ruluhar;"],[0,"&rdldhar;"],[0,"&lharul;"],[0,"&llhard;"],[0,"&rharul;"],[0,"&lrhard;"],[0,"&udhar;"],[0,"&duhar;"],[0,"&RoundImplies;"],[0,"&erarr;"],[0,"&simrarr;"],[0,"&larrsim;"],[0,"&rarrsim;"],[0,"&rarrap;"],[0,"&ltlarr;"],[1,"&gtrarr;"],[0,"&subrarr;"],[1,"&suplarr;"],[0,"&lfisht;"],[0,"&rfisht;"],[0,"&ufisht;"],[0,"&dfisht;"],[5,"&lopar;"],[0,"&ropar;"],[4,"&lbrke;"],[0,"&rbrke;"],[0,"&lbrkslu;"],[0,"&rbrksld;"],[0,"&lbrksld;"],[0,"&rbrkslu;"],[0,"&langd;"],[0,"&rangd;"],[0,"&lparlt;"],[0,"&rpargt;"],[0,"&gtlPar;"],[0,"&ltrPar;"],[3,"&vzigzag;"],[1,"&vangrt;"],[0,"&angrtvbd;"],[6,"&ange;"],[0,"&range;"],[0,"&dwangle;"],[0,"&uwangle;"],[0,"&angmsdaa;"],[0,"&angmsdab;"],[0,"&angmsdac;"],[0,"&angmsdad;"],[0,"&angmsdae;"],[0,"&angmsdaf;"],[0,"&angmsdag;"],[0,"&angmsdah;"],[0,"&bemptyv;"],[0,"&demptyv;"],[0,"&cemptyv;"],[0,"&raemptyv;"],[0,"&laemptyv;"],[0,"&ohbar;"],[0,"&omid;"],[0,"&opar;"],[1,"&operp;"],[1,"&olcross;"],[0,"&odsold;"],[1,"&olcir;"],[0,"&ofcir;"],[0,"&olt;"],[0,"&ogt;"],[0,"&cirscir;"],[0,"&cirE;"],[0,"&solb;"],[0,"&bsolb;"],[3,"&boxbox;"],[3,"&trisb;"],[0,"&rtriltri;"],[0,{v:"&LeftTriangleBar;",n:824,o:"&NotLeftTriangleBar;"}],[0,{v:"&RightTriangleBar;",n:824,o:"&NotRightTriangleBar;"}],[11,"&iinfin;"],[0,"&infintie;"],[0,"&nvinfin;"],[4,"&eparsl;"],[0,"&smeparsl;"],[0,"&eqvparsl;"],[5,"&blacklozenge;"],[8,"&RuleDelayed;"],[1,"&dsol;"],[9,"&bigodot;"],[0,"&bigoplus;"],[0,"&bigotimes;"],[1,"&biguplus;"],[1,"&bigsqcup;"],[5,"&iiiint;"],[0,"&fpartint;"],[2,"&cirfnint;"],[0,"&awint;"],[0,"&rppolint;"],[0,"&scpolint;"],[0,"&npolint;"],[0,"&pointint;"],[0,"&quatint;"],[0,"&intlarhk;"],[10,"&pluscir;"],[0,"&plusacir;"],[0,"&simplus;"],[0,"&plusdu;"],[0,"&plussim;"],[0,"&plustwo;"],[1,"&mcomma;"],[0,"&minusdu;"],[2,"&loplus;"],[0,"&roplus;"],[0,"&Cross;"],[0,"&timesd;"],[0,"&timesbar;"],[1,"&smashp;"],[0,"&lotimes;"],[0,"&rotimes;"],[0,"&otimesas;"],[0,"&Otimes;"],[0,"&odiv;"],[0,"&triplus;"],[0,"&triminus;"],[0,"&tritime;"],[0,"&intprod;"],[2,"&amalg;"],[0,"&capdot;"],[1,"&ncup;"],[0,"&ncap;"],[0,"&capand;"],[0,"&cupor;"],[0,"&cupcap;"],[0,"&capcup;"],[0,"&cupbrcap;"],[0,"&capbrcup;"],[0,"&cupcup;"],[0,"&capcap;"],[0,"&ccups;"],[0,"&ccaps;"],[2,"&ccupssm;"],[2,"&And;"],[0,"&Or;"],[0,"&andand;"],[0,"&oror;"],[0,"&orslope;"],[0,"&andslope;"],[1,"&andv;"],[0,"&orv;"],[0,"&andd;"],[0,"&ord;"],[1,"&wedbar;"],[6,"&sdote;"],[3,"&simdot;"],[2,{v:"&congdot;",n:824,o:"&ncongdot;"}],[0,"&easter;"],[0,"&apacir;"],[0,{v:"&apE;",n:824,o:"&napE;"}],[0,"&eplus;"],[0,"&pluse;"],[0,"&Esim;"],[0,"&Colone;"],[0,"&Equal;"],[1,"&ddotseq;"],[0,"&equivDD;"],[0,"&ltcir;"],[0,"&gtcir;"],[0,"&ltquest;"],[0,"&gtquest;"],[0,{v:"&leqslant;",n:824,o:"&nleqslant;"}],[0,{v:"&geqslant;",n:824,o:"&ngeqslant;"}],[0,"&lesdot;"],[0,"&gesdot;"],[0,"&lesdoto;"],[0,"&gesdoto;"],[0,"&lesdotor;"],[0,"&gesdotol;"],[0,"&lap;"],[0,"&gap;"],[0,"&lne;"],[0,"&gne;"],[0,"&lnap;"],[0,"&gnap;"],[0,"&lEg;"],[0,"&gEl;"],[0,"&lsime;"],[0,"&gsime;"],[0,"&lsimg;"],[0,"&gsiml;"],[0,"&lgE;"],[0,"&glE;"],[0,"&lesges;"],[0,"&gesles;"],[0,"&els;"],[0,"&egs;"],[0,"&elsdot;"],[0,"&egsdot;"],[0,"&el;"],[0,"&eg;"],[2,"&siml;"],[0,"&simg;"],[0,"&simlE;"],[0,"&simgE;"],[0,{v:"&LessLess;",n:824,o:"&NotNestedLessLess;"}],[0,{v:"&GreaterGreater;",n:824,o:"&NotNestedGreaterGreater;"}],[1,"&glj;"],[0,"&gla;"],[0,"&ltcc;"],[0,"&gtcc;"],[0,"&lescc;"],[0,"&gescc;"],[0,"&smt;"],[0,"&lat;"],[0,{v:"&smte;",n:65024,o:"&smtes;"}],[0,{v:"&late;",n:65024,o:"&lates;"}],[0,"&bumpE;"],[0,{v:"&PrecedesEqual;",n:824,o:"&NotPrecedesEqual;"}],[0,{v:"&sce;",n:824,o:"&NotSucceedsEqual;"}],[2,"&prE;"],[0,"&scE;"],[0,"&precneqq;"],[0,"&scnE;"],[0,"&prap;"],[0,"&scap;"],[0,"&precnapprox;"],[0,"&scnap;"],[0,"&Pr;"],[0,"&Sc;"],[0,"&subdot;"],[0,"&supdot;"],[0,"&subplus;"],[0,"&supplus;"],[0,"&submult;"],[0,"&supmult;"],[0,"&subedot;"],[0,"&supedot;"],[0,{v:"&subE;",n:824,o:"&nsubE;"}],[0,{v:"&supE;",n:824,o:"&nsupE;"}],[0,"&subsim;"],[0,"&supsim;"],[2,{v:"&subnE;",n:65024,o:"&varsubsetneqq;"}],[0,{v:"&supnE;",n:65024,o:"&varsupsetneqq;"}],[2,"&csub;"],[0,"&csup;"],[0,"&csube;"],[0,"&csupe;"],[0,"&subsup;"],[0,"&supsub;"],[0,"&subsub;"],[0,"&supsup;"],[0,"&suphsub;"],[0,"&supdsub;"],[0,"&forkv;"],[0,"&topfork;"],[0,"&mlcp;"],[8,"&Dashv;"],[1,"&Vdashl;"],[0,"&Barv;"],[0,"&vBar;"],[0,"&vBarv;"],[1,"&Vbar;"],[0,"&Not;"],[0,"&bNot;"],[0,"&rnmid;"],[0,"&cirmid;"],[0,"&midcir;"],[0,"&topcir;"],[0,"&nhpar;"],[0,"&parsim;"],[9,{v:"&parsl;",n:8421,o:"&nparsl;"}],[44343,{n:new Map(tu([[56476,"&Ascr;"],[1,"&Cscr;"],[0,"&Dscr;"],[2,"&Gscr;"],[2,"&Jscr;"],[0,"&Kscr;"],[2,"&Nscr;"],[0,"&Oscr;"],[0,"&Pscr;"],[0,"&Qscr;"],[1,"&Sscr;"],[0,"&Tscr;"],[0,"&Uscr;"],[0,"&Vscr;"],[0,"&Wscr;"],[0,"&Xscr;"],[0,"&Yscr;"],[0,"&Zscr;"],[0,"&ascr;"],[0,"&bscr;"],[0,"&cscr;"],[0,"&dscr;"],[1,"&fscr;"],[1,"&hscr;"],[0,"&iscr;"],[0,"&jscr;"],[0,"&kscr;"],[0,"&lscr;"],[0,"&mscr;"],[0,"&nscr;"],[1,"&pscr;"],[0,"&qscr;"],[0,"&rscr;"],[0,"&sscr;"],[0,"&tscr;"],[0,"&uscr;"],[0,"&vscr;"],[0,"&wscr;"],[0,"&xscr;"],[0,"&yscr;"],[0,"&zscr;"],[52,"&Afr;"],[0,"&Bfr;"],[1,"&Dfr;"],[0,"&Efr;"],[0,"&Ffr;"],[0,"&Gfr;"],[2,"&Jfr;"],[0,"&Kfr;"],[0,"&Lfr;"],[0,"&Mfr;"],[0,"&Nfr;"],[0,"&Ofr;"],[0,"&Pfr;"],[0,"&Qfr;"],[1,"&Sfr;"],[0,"&Tfr;"],[0,"&Ufr;"],[0,"&Vfr;"],[0,"&Wfr;"],[0,"&Xfr;"],[0,"&Yfr;"],[1,"&afr;"],[0,"&bfr;"],[0,"&cfr;"],[0,"&dfr;"],[0,"&efr;"],[0,"&ffr;"],[0,"&gfr;"],[0,"&hfr;"],[0,"&ifr;"],[0,"&jfr;"],[0,"&kfr;"],[0,"&lfr;"],[0,"&mfr;"],[0,"&nfr;"],[0,"&ofr;"],[0,"&pfr;"],[0,"&qfr;"],[0,"&rfr;"],[0,"&sfr;"],[0,"&tfr;"],[0,"&ufr;"],[0,"&vfr;"],[0,"&wfr;"],[0,"&xfr;"],[0,"&yfr;"],[0,"&zfr;"],[0,"&Aopf;"],[0,"&Bopf;"],[1,"&Dopf;"],[0,"&Eopf;"],[0,"&Fopf;"],[0,"&Gopf;"],[1,"&Iopf;"],[0,"&Jopf;"],[0,"&Kopf;"],[0,"&Lopf;"],[0,"&Mopf;"],[1,"&Oopf;"],[3,"&Sopf;"],[0,"&Topf;"],[0,"&Uopf;"],[0,"&Vopf;"],[0,"&Wopf;"],[0,"&Xopf;"],[0,"&Yopf;"],[1,"&aopf;"],[0,"&bopf;"],[0,"&copf;"],[0,"&dopf;"],[0,"&eopf;"],[0,"&fopf;"],[0,"&gopf;"],[0,"&hopf;"],[0,"&iopf;"],[0,"&jopf;"],[0,"&kopf;"],[0,"&lopf;"],[0,"&mopf;"],[0,"&nopf;"],[0,"&oopf;"],[0,"&popf;"],[0,"&qopf;"],[0,"&ropf;"],[0,"&sopf;"],[0,"&topf;"],[0,"&uopf;"],[0,"&vopf;"],[0,"&wopf;"],[0,"&xopf;"],[0,"&yopf;"],[0,"&zopf;"]]))}],[8906,"&fflig;"],[0,"&filig;"],[0,"&fllig;"],[0,"&ffilig;"],[0,"&ffllig;"]])),function(t){t[t.XML=0]="XML",t[t.HTML=1]="HTML"}(Vl||(Vl={})),function(t){t[t.UTF8=0]="UTF8",t[t.ASCII=1]="ASCII",t[t.Extensive=2]="Extensive",t[t.Attribute=3]="Attribute",t[t.Text=4]="Text"}(Hl||(Hl={}));const ru=Object.prototype.hasOwnProperty;function iu(t){return Array.prototype.slice.call(arguments,1).forEach((function(e){if(e){if("object"!=typeof e)throw new TypeError(e+"must be object");Object.keys(e).forEach((function(r){t[r]=e[r]}))}})),t}function nu(t,e,r){return[].concat(t.slice(0,e),r,t.slice(e+1))}function su(t){return!(t>=55296&&t<=57343||t>=64976&&t<=65007||!(65535&~t&&65534!=(65535&t))||t>=0&&t<=8||11===t||t>=14&&t<=31||t>=127&&t<=159||t>1114111)}function ou(t){return t>65535?(t-=65536,String.fromCharCode(55296+(t>>10),56320+(1023&t))):String.fromCharCode(t)}const lu=/\\([!"#$%&'()*+,\-./:;<=>?@[\\\]^_`{|}~])/g,uu=new RegExp(lu.source+"|"+/&([a-z#][a-z0-9]{1,31});/gi.source,"gi"),hu=/^#((?:x[a-f0-9]{1,8}|[0-9]{1,8}))$/i;function au(t){return t.indexOf("\\")<0&&t.indexOf("&")<0?t:t.replace(uu,(function(t,e,r){return e||function(t,e){if(35===e.charCodeAt(0)&&hu.test(e)){const r="x"===e[1].toLowerCase()?parseInt(e.slice(2),16):parseInt(e.slice(1),10);return su(r)?ou(r):t}const r=M(t);return r!==t?r:t}(t,r)}))}const fu=/[&<>"]/,cu=/[&<>"]/g,du={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;"};function pu(t){return du[t]}function mu(t){return fu.test(t)?t.replace(cu,pu):t}const gu=/[.?*+^$[\]\\(){}|-]/g;function bu(t){switch(t){case 9:case 32:return!0}return!1}function wu(t){if(t>=8192&&t<=8202)return!0;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!0}return!1}function vu(t){return Kl.test(t)||Yl.test(t)}function ku(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!0;default:return!1}}function Du(t){return t=t.trim().replace(/\s+/g," "),"Ṿ"==="ẞ".toLowerCase()&&(t=t.replace(/ẞ/g,"ß")),t.toLowerCase().toUpperCase()}var yu=Object.freeze({__proto__:null,arrayReplaceAt:nu,assign:iu,escapeHtml:mu,escapeRE:function(t){return t.replace(gu,"\\$&")},fromCodePoint:ou,has:function(t,e){return ru.call(t,e)},isMdAsciiPunct:ku,isPunctChar:vu,isSpace:bu,isString:eu,isValidEntityCode:su,isWhiteSpace:wu,lib:{mdurl:Wl,ucmicro:Ql},normalizeReference:Du,unescapeAll:au,unescapeMd:function(t){return t.indexOf("\\")<0?t:t.replace(lu,"$1")}}),Eu=Object.freeze({__proto__:null,parseLinkDestination:function(t,e,r){let i,n=e;const s={ok:!1,pos:0,str:""};if(60===t.charCodeAt(n)){for(n++;n<r;){if(i=t.charCodeAt(n),10===i)return s;if(60===i)return s;if(62===i)return s.pos=n+1,s.str=au(t.slice(e+1,n)),s.ok=!0,s;92===i&&n+1<r?n+=2:n++}return s}let o=0;for(;n<r&&(i=t.charCodeAt(n),32!==i)&&!(i<32||127===i);)if(92===i&&n+1<r){if(32===t.charCodeAt(n+1))break;n+=2}else{if(40===i&&(o++,o>32))return s;if(41===i){if(0===o)break;o--}n++}return e===n||0!==o||(s.str=au(t.slice(e,n)),s.pos=n,s.ok=!0),s},parseLinkLabel:function(t,e,r){let i,n,s,o;const l=t.posMax,u=t.pos;for(t.pos=e+1,i=1;t.pos<l;){if(s=t.src.charCodeAt(t.pos),93===s&&(i--,0===i)){n=!0;break}if(o=t.pos,t.md.inline.skipToken(t),91===s)if(o===t.pos-1)i++;else if(r)return t.pos=u,-1}let h=-1;return n&&(h=t.pos),t.pos=u,h},parseLinkTitle:function(t,e,r,i){let n,s=e;const o={ok:!1,can_continue:!1,pos:0,str:"",marker:0};if(i)o.str=i.str,o.marker=i.marker;else{if(s>=r)return o;let i=t.charCodeAt(s);if(34!==i&&39!==i&&40!==i)return o;e++,s++,40===i&&(i=41),o.marker=i}for(;s<r;){if(n=t.charCodeAt(s),n===o.marker)return o.pos=s+1,o.str+=au(t.slice(e,s)),o.ok=!0,o;if(40===n&&41===o.marker)return o;92===n&&s+1<r&&s++,s++}return o.can_continue=!0,o.str+=au(t.slice(e,s)),o}});const xu={};function Fu(){this.rules=iu({},xu)}function Mu(){this.__rules__=[],this.__cache__=null}function Au(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=!1,this.hidden=!1}function Cu(t,e,r){this.src=t,this.env=r,this.tokens=[],this.inlineMode=!1,this.md=e}xu.code_inline=function(t,e,r,i,n){const s=t[e];return"<code"+n.renderAttrs(s)+">"+mu(s.content)+"</code>"},xu.code_block=function(t,e,r,i,n){return"<pre"+n.renderAttrs(t[e])+"><code>"+mu(t[e].content)+"</code></pre>\n"},xu.fence=function(t,e,r,i,n){const s=t[e],o=s.info?au(s.info).trim():"";let l,u="",h="";if(o){const t=o.split(/(\s+)/g);u=t[0],h=t.slice(2).join("")}if(l=r.highlight&&r.highlight(s.content,u,h)||mu(s.content),0===l.indexOf("<pre"))return l+"\n";if(o){const t=s.attrIndex("class"),e=s.attrs?s.attrs.slice():[];return t<0?e.push(["class",r.langPrefix+u]):(e[t]=e[t].slice(),e[t][1]+=" "+r.langPrefix+u),`<pre><code${n.renderAttrs({attrs:e})}>${l}</code></pre>\n`}return`<pre><code${n.renderAttrs(s)}>${l}</code></pre>\n`},xu.image=function(t,e,r,i,n){const s=t[e];return s.attrs[s.attrIndex("alt")][1]=n.renderInlineAsText(s.children,r,i),n.renderToken(t,e,r)},xu.hardbreak=function(t,e,r){return r.xhtmlOut?"<br />\n":"<br>\n"},xu.softbreak=function(t,e,r){return r.breaks?r.xhtmlOut?"<br />\n":"<br>\n":"\n"},xu.text=function(t,e){return mu(t[e].content)},xu.html_block=function(t,e){return t[e].content},xu.html_inline=function(t,e){return t[e].content},Fu.prototype.renderAttrs=function(t){let e,r,i;if(!t.attrs)return"";for(i="",e=0,r=t.attrs.length;e<r;e++)i+=" "+mu(t.attrs[e][0])+'="'+mu(t.attrs[e][1])+'"';return i},Fu.prototype.renderToken=function(t,e,r){const i=t[e];let n="";if(i.hidden)return"";i.block&&-1!==i.nesting&&e&&t[e-1].hidden&&(n+="\n"),n+=(-1===i.nesting?"</":"<")+i.tag,n+=this.renderAttrs(i),0===i.nesting&&r.xhtmlOut&&(n+=" /");let s=!1;if(i.block&&(s=!0,1===i.nesting&&e+1<t.length)){const r=t[e+1];("inline"===r.type||r.hidden||-1===r.nesting&&r.tag===i.tag)&&(s=!1)}return n+=s?">\n":">",n},Fu.prototype.renderInline=function(t,e,r){let i="";const n=this.rules;for(let s=0,o=t.length;s<o;s++){const o=t[s].type;i+=void 0!==n[o]?n[o](t,s,e,r,this):this.renderToken(t,s,e)}return i},Fu.prototype.renderInlineAsText=function(t,e,r){let i="";for(let n=0,s=t.length;n<s;n++)switch(t[n].type){case"text":case"html_inline":case"html_block":i+=t[n].content;break;case"image":i+=this.renderInlineAsText(t[n].children,e,r);break;case"softbreak":case"hardbreak":i+="\n"}return i},Fu.prototype.render=function(t,e,r){let i="";const n=this.rules;for(let s=0,o=t.length;s<o;s++){const o=t[s].type;i+="inline"===o?this.renderInline(t[s].children,e,r):void 0!==n[o]?n[o](t,s,e,r,this):this.renderToken(t,s,e,r)}return i},Mu.prototype.__find__=function(t){for(let e=0;e<this.__rules__.length;e++)if(this.__rules__[e].name===t)return e;return-1},Mu.prototype.__compile__=function(){const t=this,e=[""];t.__rules__.forEach((function(t){t.enabled&&t.alt.forEach((function(t){e.indexOf(t)<0&&e.push(t)}))})),t.__cache__={},e.forEach((function(e){t.__cache__[e]=[],t.__rules__.forEach((function(r){r.enabled&&(e&&r.alt.indexOf(e)<0||t.__cache__[e].push(r.fn))}))}))},Mu.prototype.at=function(t,e,r){const i=this.__find__(t),n=r||{};if(-1===i)throw new Error("Parser rule not found: "+t);this.__rules__[i].fn=e,this.__rules__[i].alt=n.alt||[],this.__cache__=null},Mu.prototype.before=function(t,e,r,i){const n=this.__find__(t),s=i||{};if(-1===n)throw new Error("Parser rule not found: "+t);this.__rules__.splice(n,0,{name:e,enabled:!0,fn:r,alt:s.alt||[]}),this.__cache__=null},Mu.prototype.after=function(t,e,r,i){const n=this.__find__(t),s=i||{};if(-1===n)throw new Error("Parser rule not found: "+t);this.__rules__.splice(n+1,0,{name:e,enabled:!0,fn:r,alt:s.alt||[]}),this.__cache__=null},Mu.prototype.push=function(t,e,r){this.__rules__.push({name:t,enabled:!0,fn:e,alt:(r||{}).alt||[]}),this.__cache__=null},Mu.prototype.enable=function(t,e){Array.isArray(t)||(t=[t]);const r=[];return 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=!0,r.push(t)}),this),this.__cache__=null,r},Mu.prototype.enableOnly=function(t,e){Array.isArray(t)||(t=[t]),this.__rules__.forEach((function(t){t.enabled=!1})),this.enable(t,e)},Mu.prototype.disable=function(t,e){Array.isArray(t)||(t=[t]);const r=[];return 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=!1,r.push(t)}),this),this.__cache__=null,r},Mu.prototype.getRules=function(t){return null===this.__cache__&&this.__compile__(),this.__cache__[t]||[]},Au.prototype.attrIndex=function(t){if(!this.attrs)return-1;const e=this.attrs;for(let r=0,i=e.length;r<i;r++)if(e[r][0]===t)return r;return-1},Au.prototype.attrPush=function(t){this.attrs?this.attrs.push(t):this.attrs=[t]},Au.prototype.attrSet=function(t,e){const r=this.attrIndex(t),i=[t,e];r<0?this.attrPush(i):this.attrs[r]=i},Au.prototype.attrGet=function(t){const e=this.attrIndex(t);let r=null;return e>=0&&(r=this.attrs[e][1]),r},Au.prototype.attrJoin=function(t,e){const r=this.attrIndex(t);r<0?this.attrPush([t,e]):this.attrs[r][1]=this.attrs[r][1]+" "+e},Cu.prototype.Token=Au;const Su=/\r\n?|\n/g,Ou=/\0/g;const $u=/\+-|\.\.|\?\?\?\?|!!!!|,,|--/,Bu=/\((c|tm|r)\)/i,Ru=/\((c|tm|r)\)/gi,Nu={c:"©",r:"®",tm:"™"};function _u(t,e){return Nu[e.toLowerCase()]}function Tu(t){let e=0;for(let r=t.length-1;r>=0;r--){const i=t[r];"text"!==i.type||e||(i.content=i.content.replace(Ru,_u)),"link_open"===i.type&&"auto"===i.info&&e--,"link_close"===i.type&&"auto"===i.info&&e++}}function zu(t){let e=0;for(let r=t.length-1;r>=0;r--){const i=t[r];"text"!==i.type||e||$u.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–")),"link_open"===i.type&&"auto"===i.info&&e--,"link_close"===i.type&&"auto"===i.info&&e++}}const ju=/['"]/,qu=/['"]/g;function Iu(t,e,r){return t.slice(0,e)+r+t.slice(e+1)}function Pu(t,e){let r;const i=[];for(let n=0;n<t.length;n++){const s=t[n],o=t[n].level;for(r=i.length-1;r>=0&&!(i[r].level<=o);r--);if(i.length=r+1,"text"!==s.type)continue;let l=s.content,u=0,h=l.length;t:for(;u<h;){qu.lastIndex=u;const a=qu.exec(l);if(!a)break;let f=!0,c=!0;u=a.index+1;const d="'"===a[0];let p=32;if(a.index-1>=0)p=l.charCodeAt(a.index-1);else for(r=n-1;r>=0&&"softbreak"!==t[r].type&&"hardbreak"!==t[r].type;r--)if(t[r].content){p=t[r].content.charCodeAt(t[r].content.length-1);break}let m=32;if(u<h)m=l.charCodeAt(u);else for(r=n+1;r<t.length&&"softbreak"!==t[r].type&&"hardbreak"!==t[r].type;r++)if(t[r].content){m=t[r].content.charCodeAt(0);break}const g=ku(p)||vu(String.fromCharCode(p)),b=ku(m)||vu(String.fromCharCode(m)),w=wu(p),v=wu(m);if(v?f=!1:b&&(w||g||(f=!1)),w?c=!1:g&&(v||b||(c=!1)),34===m&&'"'===a[0]&&p>=48&&p<=57&&(c=f=!1),f&&c&&(f=g,c=b),f||c){if(c)for(r=i.length-1;r>=0;r--){let f=i[r];if(i[r].level<o)break;if(f.single===d&&i[r].level===o){let o,c;f=i[r],d?(o=e.md.options.quotes[2],c=e.md.options.quotes[3]):(o=e.md.options.quotes[0],c=e.md.options.quotes[1]),s.content=Iu(s.content,a.index,c),t[f.token].content=Iu(t[f.token].content,f.pos,o),u+=c.length-1,f.token===n&&(u+=o.length-1),l=s.content,h=l.length,i.length=r;continue t}}f?i.push({token:n,pos:a.index,single:d,level:o}):c&&d&&(s.content=Iu(s.content,a.index,"’"))}else d&&(s.content=Iu(s.content,a.index,"’"))}}}const Lu=[["normalize",function(t){let e;e=t.src.replace(Su,"\n"),e=e.replace(Ou,"�"),t.src=e}],["block",function(t){let e;t.inlineMode?(e=new t.Token("inline","",0),e.content=t.src,e.map=[0,1],e.children=[],t.tokens.push(e)):t.md.block.parse(t.src,t.md,t.env,t.tokens)}],["inline",function(t){const e=t.tokens;for(let r=0,i=e.length;r<i;r++){const i=e[r];"inline"===i.type&&t.md.inline.parse(i.content,t.md,t.env,i.children)}}],["linkify",function(t){const e=t.tokens;if(t.md.options.linkify)for(let r=0,i=e.length;r<i;r++){if("inline"!==e[r].type||!t.md.linkify.pretest(e[r].content))continue;let i=e[r].children,n=0;for(let s=i.length-1;s>=0;s--){const o=i[s];if("link_close"!==o.type){if("html_inline"===o.type&&(/^<a[>\s]/i.test(o.content)&&n>0&&n--,/^<\/a\s*>/i.test(o.content)&&n++),!(n>0)&&"text"===o.type&&t.md.linkify.test(o.content)){const n=o.content;let l=t.md.linkify.match(n);const u=[];let h=o.level,a=0;l.length>0&&0===l[0].index&&s>0&&"text_special"===i[s-1].type&&(l=l.slice(1));for(let e=0;e<l.length;e++){const r=t.md.normalizeLink(l[e].url);if(!t.md.validateLink(r))continue;let i=l[e].text;i=l[e].schema?"mailto:"!==l[e].schema||/^mailto:/i.test(i)?t.md.normalizeLinkText(i):t.md.normalizeLinkText("mailto:"+i).replace(/^mailto:/,""):t.md.normalizeLinkText("http://"+i).replace(/^http:\/\//,"");const s=l[e].index;if(s>a){const e=new t.Token("text","",0);e.content=n.slice(a,s),e.level=h,u.push(e)}const o=new t.Token("link_open","a",1);o.attrs=[["href",r]],o.level=h++,o.markup="linkify",o.info="auto",u.push(o);const f=new t.Token("text","",0);f.content=i,f.level=h,u.push(f);const c=new t.Token("link_close","a",-1);c.level=--h,c.markup="linkify",c.info="auto",u.push(c),a=l[e].lastIndex}if(a<n.length){const e=new t.Token("text","",0);e.content=n.slice(a),e.level=h,u.push(e)}e[r].children=i=nu(i,s,u)}}else for(s--;i[s].level!==o.level&&"link_open"!==i[s].type;)s--}}}],["replacements",function(t){let e;if(t.md.options.typographer)for(e=t.tokens.length-1;e>=0;e--)"inline"===t.tokens[e].type&&(Bu.test(t.tokens[e].content)&&Tu(t.tokens[e].children),$u.test(t.tokens[e].content)&&zu(t.tokens[e].children))}],["smartquotes",function(t){if(t.md.options.typographer)for(let e=t.tokens.length-1;e>=0;e--)"inline"===t.tokens[e].type&&ju.test(t.tokens[e].content)&&Pu(t.tokens[e].children,t)}],["text_join",function(t){let e,r;const i=t.tokens,n=i.length;for(let t=0;t<n;t++){if("inline"!==i[t].type)continue;const n=i[t].children,s=n.length;for(e=0;e<s;e++)"text_special"===n[e].type&&(n[e].type="text");for(e=r=0;e<s;e++)"text"===n[e].type&&e+1<s&&"text"===n[e+1].type?n[e+1].content=n[e].content+n[e+1].content:(e!==r&&(n[r]=n[e]),r++);e!==r&&(n.length=r)}}]];function Ju(){this.ruler=new Mu;for(let t=0;t<Lu.length;t++)this.ruler.push(Lu[t][0],Lu[t][1])}function Uu(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=!1,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,o=!1;e<s;e++){const l=n.charCodeAt(e);if(!o){if(bu(l)){r++,9===l?i+=4-i%4:i++;continue}o=!0}10!==l&&e!==s-1||(10!==l&&e++,this.bMarks.push(t),this.eMarks.push(e),this.tShift.push(r),this.sCount.push(i),this.bsCount.push(0),o=!1,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}function Vu(t,e){return t.src.slice(t.bMarks[e]+t.tShift[e],t.eMarks[e])}function Hu(t){const e=[],r=t.length;let i=0,n=t.charCodeAt(i),s=!1,o=0,l="";for(;i<r;)124===n&&(s?(l+=t.substring(o,i-1),o=i):(e.push(l+t.substring(o,i)),l="",o=i+1)),s=92===n,i++,n=t.charCodeAt(i);return e.push(l+t.substring(o)),e}function Wu(t,e){const r=t.eMarks[e];let i=t.bMarks[e]+t.tShift[e];const n=t.src.charCodeAt(i++);return 42!==n&&45!==n&&43!==n||i<r&&!bu(t.src.charCodeAt(i))?-1:i}function Gu(t,e){const r=t.bMarks[e]+t.tShift[e],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;if(s=t.src.charCodeAt(n++),!(s>=48&&s<=57)){if(41===s||46===s)break;return-1}if(n-r>=10)return-1}return n<i&&(s=t.src.charCodeAt(n),!bu(s))?-1:n}Ju.prototype.process=function(t){const e=this.ruler.getRules("");for(let r=0,i=e.length;r<i;r++)e[r](t)},Ju.prototype.State=Cu,Uu.prototype.push=function(t,e,r){const i=new Au(t,e,r);return i.block=!0,r<0&&this.level--,i.level=this.level,r>0&&this.level++,this.tokens.push(i),i},Uu.prototype.isEmpty=function(t){return this.bMarks[t]+this.tShift[t]>=this.eMarks[t]},Uu.prototype.skipEmptyLines=function(t){for(let e=this.lineMax;t<e&&!(this.bMarks[t]+this.tShift[t]<this.eMarks[t]);t++);return t},Uu.prototype.skipSpaces=function(t){for(let e=this.src.length;t<e&&bu(this.src.charCodeAt(t));t++);return t},Uu.prototype.skipSpacesBack=function(t,e){if(t<=e)return t;for(;t>e;)if(!bu(this.src.charCodeAt(--t)))return t+1;return t},Uu.prototype.skipChars=function(t,e){for(let r=this.src.length;t<r&&this.src.charCodeAt(t)===e;t++);return t},Uu.prototype.skipCharsBack=function(t,e,r){if(t<=r)return t;for(;t>r;)if(e!==this.src.charCodeAt(--t))return t+1;return t},Uu.prototype.getLines=function(t,e,r,i){if(t>=e)return"";const n=new Array(e-t);for(let s=0,o=t;o<e;o++,s++){let t=0;const l=this.bMarks[o];let u,h=l;for(u=o+1<e||i?this.eMarks[o]+1:this.eMarks[o];h<u&&t<r;){const e=this.src.charCodeAt(h);if(bu(e))9===e?t+=4-(t+this.bsCount[o])%4:t++;else{if(!(h-l<this.tShift[o]))break;t++}h++}n[s]=t>r?new Array(t-r+1).join(" ")+this.src.slice(h,u):this.src.slice(h,u)}return n.join("")},Uu.prototype.Token=Au;const Zu="<[A-Za-z][A-Za-z0-9\\-]*(?:\\s+[a-zA-Z_:][a-zA-Z0-9:._-]*(?:\\s*=\\s*(?:[^\"'=<>`\\x00-\\x20]+|'[^']*'|\"[^\"]*\"))?)*\\s*\\/?>",Ku="<\\/[A-Za-z][A-Za-z0-9\\-]*\\s*>",Yu=new RegExp("^(?:"+Zu+"|"+Ku+"|\x3c!---?>|\x3c!--(?:[^-]|-[^-]|--[^>])*--\x3e|<[?][\\s\\S]*?[?]>|<![A-Za-z][^>]*>|<!\\[CDATA\\[[\\s\\S]*?\\]\\]>)"),Xu=new RegExp("^(?:"+Zu+"|"+Ku+")"),Qu=[[/^<(script|pre|style|textarea)(?=(\s|>|$))/i,/<\/(script|pre|style|textarea)>/i,!0],[/^<!--/,/-->/,!0],[/^<\?/,/\?>/,!0],[/^<![A-Z]/,/>/,!0],[/^<!\[CDATA\[/,/\]\]>/,!0],[new RegExp("^</?("+["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"].join("|")+")(?=(\\s|/?>|$))","i"),/^$/,!0],[new RegExp(Xu.source+"\\s*$"),/^$/,!1]],th=[["table",function(t,e,r,i){if(e+2>r)return!1;let n=e+1;if(t.sCount[n]<t.blkIndent)return!1;if(t.sCount[n]-t.blkIndent>=4)return!1;let s=t.bMarks[n]+t.tShift[n];if(s>=t.eMarks[n])return!1;const o=t.src.charCodeAt(s++);if(124!==o&&45!==o&&58!==o)return!1;if(s>=t.eMarks[n])return!1;const l=t.src.charCodeAt(s++);if(124!==l&&45!==l&&58!==l&&!bu(l))return!1;if(45===o&&bu(l))return!1;for(;s<t.eMarks[n];){const e=t.src.charCodeAt(s);if(124!==e&&45!==e&&58!==e&&!bu(e))return!1;s++}let u=Vu(t,e+1),h=u.split("|");const a=[];for(let t=0;t<h.length;t++){const e=h[t].trim();if(!e){if(0===t||t===h.length-1)continue;return!1}if(!/^:?-+:?$/.test(e))return!1;58===e.charCodeAt(e.length-1)?a.push(58===e.charCodeAt(0)?"center":"right"):58===e.charCodeAt(0)?a.push("left"):a.push("")}if(u=Vu(t,e).trim(),-1===u.indexOf("|"))return!1;if(t.sCount[e]-t.blkIndent>=4)return!1;h=Hu(u),h.length&&""===h[0]&&h.shift(),h.length&&""===h[h.length-1]&&h.pop();const f=h.length;if(0===f||f!==a.length)return!1;if(i)return!0;const c=t.parentType;t.parentType="table";const d=t.md.block.ruler.getRules("blockquote"),p=[e,0];t.push("table_open","table",1).map=p,t.push("thead_open","thead",1).map=[e,e+1],t.push("tr_open","tr",1).map=[e,e+1];for(let e=0;e<h.length;e++){const r=t.push("th_open","th",1);a[e]&&(r.attrs=[["style","text-align:"+a[e]]]);const i=t.push("inline","",0);i.content=h[e].trim(),i.children=[],t.push("th_close","th",-1)}let m;t.push("tr_close","tr",-1),t.push("thead_close","thead",-1);let g=0;for(n=e+2;n<r&&!(t.sCount[n]<t.blkIndent);n++){let i=!1;for(let e=0,s=d.length;e<s;e++)if(d[e](t,n,r,!0)){i=!0;break}if(i)break;if(u=Vu(t,n).trim(),!u)break;if(t.sCount[n]-t.blkIndent>=4)break;if(h=Hu(u),h.length&&""===h[0]&&h.shift(),h.length&&""===h[h.length-1]&&h.pop(),g+=f-h.length,g>65536)break;n===e+2&&(t.push("tbody_open","tbody",1).map=m=[e+2,0]),t.push("tr_open","tr",1).map=[n,n+1];for(let e=0;e<f;e++){const r=t.push("td_open","td",1);a[e]&&(r.attrs=[["style","text-align:"+a[e]]]);const i=t.push("inline","",0);i.content=h[e]?h[e].trim():"",i.children=[],t.push("td_close","td",-1)}t.push("tr_close","tr",-1)}return m&&(t.push("tbody_close","tbody",-1),m[1]=n),t.push("table_close","table",-1),p[1]=n,t.parentType=c,t.line=n,!0},["paragraph","reference"]],["code",function(t,e,r){if(t.sCount[e]-t.blkIndent<4)return!1;let i=e+1,n=i;for(;i<r;)if(t.isEmpty(i))i++;else{if(!(t.sCount[i]-t.blkIndent>=4))break;i++,n=i}t.line=n;const s=t.push("code_block","code",0);return s.content=t.getLines(e,n,4+t.blkIndent,!1)+"\n",s.map=[e,t.line],!0}],["fence",function(t,e,r,i){let n=t.bMarks[e]+t.tShift[e],s=t.eMarks[e];if(t.sCount[e]-t.blkIndent>=4)return!1;if(n+3>s)return!1;const o=t.src.charCodeAt(n);if(126!==o&&96!==o)return!1;let l=n;n=t.skipChars(n,o);let u=n-l;if(u<3)return!1;const h=t.src.slice(l,n),a=t.src.slice(n,s);if(96===o&&a.indexOf(String.fromCharCode(o))>=0)return!1;if(i)return!0;let f=e,c=!1;for(;!(f++,f>=r||(n=l=t.bMarks[f]+t.tShift[f],s=t.eMarks[f],n<s&&t.sCount[f]<t.blkIndent));)if(t.src.charCodeAt(n)===o&&!(t.sCount[f]-t.blkIndent>=4||(n=t.skipChars(n,o),n-l<u||(n=t.skipSpaces(n),n<s)))){c=!0;break}u=t.sCount[e],t.line=f+(c?1:0);const d=t.push("fence","code",0);return d.info=a,d.content=t.getLines(e+1,f,u,!0),d.markup=h,d.map=[e,t.line],!0},["paragraph","reference","blockquote","list"]],["blockquote",function(t,e,r,i){let n=t.bMarks[e]+t.tShift[e],s=t.eMarks[e];const o=t.lineMax;if(t.sCount[e]-t.blkIndent>=4)return!1;if(62!==t.src.charCodeAt(n))return!1;if(i)return!0;const l=[],u=[],h=[],a=[],f=t.md.block.ruler.getRules("blockquote"),c=t.parentType;t.parentType="blockquote";let d,p=!1;for(d=e;d<r;d++){const e=t.sCount[d]<t.blkIndent;if(n=t.bMarks[d]+t.tShift[d],s=t.eMarks[d],n>=s)break;if(62===t.src.charCodeAt(n++)&&!e){let e,r,i=t.sCount[d]+1;32===t.src.charCodeAt(n)?(n++,i++,r=!1,e=!0):9===t.src.charCodeAt(n)?(e=!0,(t.bsCount[d]+i)%4==3?(n++,i++,r=!1):r=!0):e=!1;let o=i;for(l.push(t.bMarks[d]),t.bMarks[d]=n;n<s;){const e=t.src.charCodeAt(n);if(!bu(e))break;9===e?o+=4-(o+t.bsCount[d]+(r?1:0))%4:o++,n++}p=n>=s,u.push(t.bsCount[d]),t.bsCount[d]=t.sCount[d]+1+(e?1:0),h.push(t.sCount[d]),t.sCount[d]=o-i,a.push(t.tShift[d]),t.tShift[d]=n-t.bMarks[d];continue}if(p)break;let i=!1;for(let e=0,n=f.length;e<n;e++)if(f[e](t,d,r,!0)){i=!0;break}if(i){t.lineMax=d,0!==t.blkIndent&&(l.push(t.bMarks[d]),u.push(t.bsCount[d]),a.push(t.tShift[d]),h.push(t.sCount[d]),t.sCount[d]-=t.blkIndent);break}l.push(t.bMarks[d]),u.push(t.bsCount[d]),a.push(t.tShift[d]),h.push(t.sCount[d]),t.sCount[d]=-1}const m=t.blkIndent;t.blkIndent=0;const g=t.push("blockquote_open","blockquote",1);g.markup=">";const b=[e,0];g.map=b,t.md.block.tokenize(t,e,d),t.push("blockquote_close","blockquote",-1).markup=">",t.lineMax=o,t.parentType=c,b[1]=t.line;for(let r=0;r<a.length;r++)t.bMarks[r+e]=l[r],t.tShift[r+e]=a[r],t.sCount[r+e]=h[r],t.bsCount[r+e]=u[r];return t.blkIndent=m,!0},["paragraph","reference","blockquote","list"]],["hr",function(t,e,r,i){const n=t.eMarks[e];if(t.sCount[e]-t.blkIndent>=4)return!1;let s=t.bMarks[e]+t.tShift[e];const o=t.src.charCodeAt(s++);if(42!==o&&45!==o&&95!==o)return!1;let l=1;for(;s<n;){const e=t.src.charCodeAt(s++);if(e!==o&&!bu(e))return!1;e===o&&l++}if(l<3)return!1;if(i)return!0;t.line=e+1;const u=t.push("hr","hr",0);return u.map=[e,t.line],u.markup=Array(l+1).join(String.fromCharCode(o)),!0},["paragraph","reference","blockquote","list"]],["list",function(t,e,r,i){let n,s,o,l,u=e,h=!0;if(t.sCount[u]-t.blkIndent>=4)return!1;if(t.listIndent>=0&&t.sCount[u]-t.listIndent>=4&&t.sCount[u]<t.blkIndent)return!1;let a,f,c,d=!1;if(i&&"paragraph"===t.parentType&&t.sCount[u]>=t.blkIndent&&(d=!0),(c=Gu(t,u))>=0){if(a=!0,o=t.bMarks[u]+t.tShift[u],f=Number(t.src.slice(o,c-1)),d&&1!==f)return!1}else{if(!((c=Wu(t,u))>=0))return!1;a=!1}if(d&&t.skipSpaces(c)>=t.eMarks[u])return!1;if(i)return!0;const p=t.src.charCodeAt(c-1),m=t.tokens.length;a?(l=t.push("ordered_list_open","ol",1),1!==f&&(l.attrs=[["start",f]])):l=t.push("bullet_list_open","ul",1);const g=[u,0];l.map=g,l.markup=String.fromCharCode(p);let b=!1;const w=t.md.block.ruler.getRules("list"),v=t.parentType;for(t.parentType="list";u<r;){s=c,n=t.eMarks[u];const e=t.sCount[u]+c-(t.bMarks[u]+t.tShift[u]);let i=e;for(;s<n;){const e=t.src.charCodeAt(s);if(9===e)i+=4-(i+t.bsCount[u])%4;else{if(32!==e)break;i++}s++}const f=s;let d;d=f>=n?1:i-e,d>4&&(d=1);const m=e+d;l=t.push("list_item_open","li",1),l.markup=String.fromCharCode(p);const g=[u,0];l.map=g,a&&(l.info=t.src.slice(o,c-1));const v=t.tight,k=t.tShift[u],D=t.sCount[u],y=t.listIndent;if(t.listIndent=t.blkIndent,t.blkIndent=m,t.tight=!0,t.tShift[u]=f-t.bMarks[u],t.sCount[u]=i,f>=n&&t.isEmpty(u+1)?t.line=Math.min(t.line+2,r):t.md.block.tokenize(t,u,r,!0),t.tight&&!b||(h=!1),b=t.line-u>1&&t.isEmpty(t.line-1),t.blkIndent=t.listIndent,t.listIndent=y,t.tShift[u]=k,t.sCount[u]=D,t.tight=v,l=t.push("list_item_close","li",-1),l.markup=String.fromCharCode(p),u=t.line,g[1]=u,u>=r)break;if(t.sCount[u]<t.blkIndent)break;if(t.sCount[u]-t.blkIndent>=4)break;let E=!1;for(let e=0,i=w.length;e<i;e++)if(w[e](t,u,r,!0)){E=!0;break}if(E)break;if(a){if(c=Gu(t,u),c<0)break;o=t.bMarks[u]+t.tShift[u]}else if(c=Wu(t,u),c<0)break;if(p!==t.src.charCodeAt(c-1))break}return l=a?t.push("ordered_list_close","ol",-1):t.push("bullet_list_close","ul",-1),l.markup=String.fromCharCode(p),g[1]=u,t.line=u,t.parentType=v,h&&function(t,e){const r=t.level+2;for(let i=e+2,n=t.tokens.length-2;i<n;i++)t.tokens[i].level===r&&"paragraph_open"===t.tokens[i].type&&(t.tokens[i+2].hidden=!0,t.tokens[i].hidden=!0,i+=2)}(t,m),!0},["paragraph","reference","blockquote"]],["reference",function(t,e,r,i){let n=t.bMarks[e]+t.tShift[e],s=t.eMarks[e],o=e+1;if(t.sCount[e]-t.blkIndent>=4)return!1;if(91!==t.src.charCodeAt(n))return!1;function l(e){const r=t.lineMax;if(e>=r||t.isEmpty(e))return null;let i=!1;if(t.sCount[e]-t.blkIndent>3&&(i=!0),t.sCount[e]<0&&(i=!0),!i){const i=t.md.block.ruler.getRules("reference"),n=t.parentType;t.parentType="reference";let s=!1;for(let n=0,o=i.length;n<o;n++)if(i[n](t,e,r,!0)){s=!0;break}if(t.parentType=n,s)return null}return t.src.slice(t.bMarks[e]+t.tShift[e],t.eMarks[e]+1)}let u=t.src.slice(n,s+1);s=u.length;let h=-1;for(n=1;n<s;n++){const t=u.charCodeAt(n);if(91===t)return!1;if(93===t){h=n;break}if(10===t){const t=l(o);null!==t&&(u+=t,s=u.length,o++)}else if(92===t&&(n++,n<s&&10===u.charCodeAt(n))){const t=l(o);null!==t&&(u+=t,s=u.length,o++)}}if(h<0||58!==u.charCodeAt(h+1))return!1;for(n=h+2;n<s;n++){const t=u.charCodeAt(n);if(10===t){const t=l(o);null!==t&&(u+=t,s=u.length,o++)}else if(!bu(t))break}const a=t.md.helpers.parseLinkDestination(u,n,s);if(!a.ok)return!1;const f=t.md.normalizeLink(a.str);if(!t.md.validateLink(f))return!1;n=a.pos;const c=n,d=o,p=n;for(;n<s;n++){const t=u.charCodeAt(n);if(10===t){const t=l(o);null!==t&&(u+=t,s=u.length,o++)}else if(!bu(t))break}let m,g=t.md.helpers.parseLinkTitle(u,n,s);for(;g.can_continue;){const e=l(o);if(null===e)break;u+=e,n=s,s=u.length,o++,g=t.md.helpers.parseLinkTitle(u,n,s,g)}for(n<s&&p!==n&&g.ok?(m=g.str,n=g.pos):(m="",n=c,o=d);n<s&&bu(u.charCodeAt(n));)n++;if(n<s&&10!==u.charCodeAt(n)&&m)for(m="",n=c,o=d;n<s&&bu(u.charCodeAt(n));)n++;if(n<s&&10!==u.charCodeAt(n))return!1;const b=Du(u.slice(1,h));return!!b&&(i||(void 0===t.env.references&&(t.env.references={}),void 0===t.env.references[b]&&(t.env.references[b]={title:m,href:f}),t.line=o),!0)}],["html_block",function(t,e,r,i){let n=t.bMarks[e]+t.tShift[e],s=t.eMarks[e];if(t.sCount[e]-t.blkIndent>=4)return!1;if(!t.md.options.html)return!1;if(60!==t.src.charCodeAt(n))return!1;let o=t.src.slice(n,s),l=0;for(;l<Qu.length&&!Qu[l][0].test(o);l++);if(l===Qu.length)return!1;if(i)return Qu[l][2];let u=e+1;if(!Qu[l][1].test(o))for(;u<r&&!(t.sCount[u]<t.blkIndent);u++)if(n=t.bMarks[u]+t.tShift[u],s=t.eMarks[u],o=t.src.slice(n,s),Qu[l][1].test(o)){0!==o.length&&u++;break}t.line=u;const h=t.push("html_block","",0);return h.map=[e,u],h.content=t.getLines(e,u,t.blkIndent,!0),!0},["paragraph","reference","blockquote"]],["heading",function(t,e,r,i){let n=t.bMarks[e]+t.tShift[e],s=t.eMarks[e];if(t.sCount[e]-t.blkIndent>=4)return!1;let o=t.src.charCodeAt(n);if(35!==o||n>=s)return!1;let l=1;for(o=t.src.charCodeAt(++n);35===o&&n<s&&l<=6;)l++,o=t.src.charCodeAt(++n);if(l>6||n<s&&!bu(o))return!1;if(i)return!0;s=t.skipSpacesBack(s,n);const u=t.skipCharsBack(s,35,n);u>n&&bu(t.src.charCodeAt(u-1))&&(s=u),t.line=e+1;const h=t.push("heading_open","h"+String(l),1);h.markup="########".slice(0,l),h.map=[e,t.line];const a=t.push("inline","",0);return a.content=t.src.slice(n,s).trim(),a.map=[e,t.line],a.children=[],t.push("heading_close","h"+String(l),-1).markup="########".slice(0,l),!0},["paragraph","reference","blockquote"]],["lheading",function(t,e,r){const i=t.md.block.ruler.getRules("paragraph");if(t.sCount[e]-t.blkIndent>=4)return!1;const n=t.parentType;t.parentType="paragraph";let s,o=0,l=e+1;for(;l<r&&!t.isEmpty(l);l++){if(t.sCount[l]-t.blkIndent>3)continue;if(t.sCount[l]>=t.blkIndent){let e=t.bMarks[l]+t.tShift[l];const r=t.eMarks[l];if(e<r&&(s=t.src.charCodeAt(e),(45===s||61===s)&&(e=t.skipChars(e,s),e=t.skipSpaces(e),e>=r))){o=61===s?1:2;break}}if(t.sCount[l]<0)continue;let e=!1;for(let n=0,s=i.length;n<s;n++)if(i[n](t,l,r,!0)){e=!0;break}if(e)break}if(!o)return!1;const u=t.getLines(e,l,t.blkIndent,!1).trim();t.line=l+1;const h=t.push("heading_open","h"+String(o),1);h.markup=String.fromCharCode(s),h.map=[e,t.line];const a=t.push("inline","",0);return a.content=u,a.map=[e,t.line-1],a.children=[],t.push("heading_close","h"+String(o),-1).markup=String.fromCharCode(s),t.parentType=n,!0}],["paragraph",function(t,e,r){const i=t.md.block.ruler.getRules("paragraph"),n=t.parentType;let s=e+1;for(t.parentType="paragraph";s<r&&!t.isEmpty(s);s++){if(t.sCount[s]-t.blkIndent>3)continue;if(t.sCount[s]<0)continue;let e=!1;for(let n=0,o=i.length;n<o;n++)if(i[n](t,s,r,!0)){e=!0;break}if(e)break}const o=t.getLines(e,s,t.blkIndent,!1).trim();t.line=s,t.push("paragraph_open","p",1).map=[e,t.line];const l=t.push("inline","",0);return l.content=o,l.map=[e,t.line],l.children=[],t.push("paragraph_close","p",-1),t.parentType=n,!0}]];function eh(){this.ruler=new Mu;for(let t=0;t<th.length;t++)this.ruler.push(th[t][0],th[t][1],{alt:(th[t][2]||[]).slice()})}function rh(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=!1,this.linkLevel=0}function ih(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!0;default:return!1}}eh.prototype.tokenize=function(t,e,r){const i=this.ruler.getRules(""),n=i.length,s=t.md.options.maxNesting;let o=e,l=!1;for(;o<r&&(t.line=o=t.skipEmptyLines(o),!(o>=r))&&!(t.sCount[o]<t.blkIndent);){if(t.level>=s){t.line=r;break}const e=t.line;let u=!1;for(let s=0;s<n;s++)if(u=i[s](t,o,r,!1),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=!l,t.isEmpty(t.line-1)&&(l=!0),o=t.line,o<r&&t.isEmpty(o)&&(l=!0,o++,t.line=o)}},eh.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)},eh.prototype.State=Uu,rh.prototype.pushPending=function(){const t=new Au("text","",0);return t.content=this.pending,t.level=this.pendingLevel,this.tokens.push(t),this.pending="",t},rh.prototype.push=function(t,e,r){this.pending&&this.pushPending();const i=new Au(t,e,r);let n=null;return r<0&&(this.level--,this.delimiters=this._prev_delimiters.pop()),i.level=this.level,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),i},rh.prototype.scanDelims=function(t,e){const r=this.posMax,i=this.src.charCodeAt(t),n=t>0?this.src.charCodeAt(t-1):32;let s=t;for(;s<r&&this.src.charCodeAt(s)===i;)s++;const o=s-t,l=s<r?this.src.charCodeAt(s):32,u=ku(n)||vu(String.fromCharCode(n)),h=ku(l)||vu(String.fromCharCode(l)),a=wu(n),f=wu(l),c=!f&&(!h||a||u),d=!a&&(!u||f||h);return{can_open:c&&(e||!d||u),can_close:d&&(e||!c||h),length:o}},rh.prototype.Token=Au;const nh=/(?:^|[^a-z0-9.+-])([a-z][a-z0-9.+-]*)$/i,sh=[];for(let t=0;t<256;t++)sh.push(0);function oh(t,e){let r;const i=[],n=e.length;for(let s=0;s<n;s++){const n=e[s];if(126!==n.marker)continue;if(-1===n.end)continue;const o=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[o.token],r.type="s_close",r.tag="s",r.nesting=-1,r.markup="~~",r.content="","text"===t.tokens[o.token-1].type&&"~"===t.tokens[o.token-1].content&&i.push(o.token-1)}for(;i.length;){const e=i.pop();let n=e+1;for(;n<t.tokens.length&&"s_close"===t.tokens[n].type;)n++;n--,e!==n&&(r=t.tokens[n],t.tokens[n]=t.tokens[e],t.tokens[e]=r)}}"\\!\"#$%&'()*+,./:;<=>?@[]^_`{|}~-".split("").forEach((function(t){sh[t.charCodeAt(0)]=1}));var lh={tokenize:function(t,e){const r=t.src.charCodeAt(t.pos);if(e)return!1;if(126!==r)return!1;const i=t.scanDelims(t.pos,!0);let n=i.length;const s=String.fromCharCode(r);if(n<2)return!1;let o;n%2&&(o=t.push("text","",0),o.content=s,n--);for(let e=0;e<n;e+=2)o=t.push("text","",0),o.content=s+s,t.delimiters.push({marker:r,length:0,token:t.tokens.length-1,end:-1,open:i.can_open,close:i.can_close});return t.pos+=i.length,!0},postProcess:function(t){const e=t.tokens_meta,r=t.tokens_meta.length;oh(t,t.delimiters);for(let i=0;i<r;i++)e[i]&&e[i].delimiters&&oh(t,e[i].delimiters)}};function uh(t,e){for(let r=e.length-1;r>=0;r--){const i=e[r];if(95!==i.marker&&42!==i.marker)continue;if(-1===i.end)continue;const n=e[i.end],s=r>0&&e[r-1].end===i.end+1&&e[r-1].marker===i.marker&&e[r-1].token===i.token-1&&e[i.end+1].token===n.token+1,o=String.fromCharCode(i.marker),l=t.tokens[i.token];l.type=s?"strong_open":"em_open",l.tag=s?"strong":"em",l.nesting=1,l.markup=s?o+o:o,l.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?o+o:o,u.content="",s&&(t.tokens[e[r-1].token].content="",t.tokens[e[i.end+1].token].content="",r--)}}var hh={tokenize:function(t,e){const r=t.src.charCodeAt(t.pos);if(e)return!1;if(95!==r&&42!==r)return!1;const i=t.scanDelims(t.pos,42===r);for(let e=0;e<i.length;e++)t.push("text","",0).content=String.fromCharCode(r),t.delimiters.push({marker:r,length:i.length,token:t.tokens.length-1,end:-1,open:i.can_open,close:i.can_close});return t.pos+=i.length,!0},postProcess:function(t){const e=t.tokens_meta,r=t.tokens_meta.length;uh(t,t.delimiters);for(let i=0;i<r;i++)e[i]&&e[i].delimiters&&uh(t,e[i].delimiters)}};const ah=/^([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])?)*)$/,fh=/^([a-zA-Z][a-zA-Z0-9+.-]{1,31}):([^<>\x00-\x20]*)$/,ch=/^&#((?:x[a-f0-9]{1,6}|[0-9]{1,7}));/i,dh=/^&([a-z][a-z0-9]{1,31});/i;function ph(t){const e={},r=t.length;if(!r)return;let i=0,n=-2;const s=[];for(let o=0;o<r;o++){const r=t[o];if(s.push(0),t[i].marker===r.marker&&n===r.token-1||(i=o),n=r.token,r.length=r.length||0,!r.close)continue;e.hasOwnProperty(r.marker)||(e[r.marker]=[-1,-1,-1,-1,-1,-1]);const l=e[r.marker][(r.open?3:0)+r.length%3];let u=i-s[i]-1,h=u;for(;u>l;u-=s[u]+1){const e=t[u];if(e.marker===r.marker&&e.open&&e.end<0){let i=!1;if((e.close||r.open)&&(e.length+r.length)%3==0&&(e.length%3==0&&r.length%3==0||(i=!0)),!i){const i=u>0&&!t[u-1].open?s[u-1]+1:0;s[o]=o-u+i,s[u]=i,r.open=!1,e.end=o,e.close=!1,h=-1,n=-2;break}}}-1!==h&&(e[r.marker][(r.open?3:0)+(r.length||0)%3]=h)}}const mh=[["text",function(t,e){let r=t.pos;for(;r<t.posMax&&!ih(t.src.charCodeAt(r));)r++;return r!==t.pos&&(e||(t.pending+=t.src.slice(t.pos,r)),t.pos=r,!0)}],["linkify",function(t,e){if(!t.md.options.linkify)return!1;if(t.linkLevel>0)return!1;const r=t.pos;if(r+3>t.posMax)return!1;if(58!==t.src.charCodeAt(r))return!1;if(47!==t.src.charCodeAt(r+1))return!1;if(47!==t.src.charCodeAt(r+2))return!1;const i=t.pending.match(nh);if(!i)return!1;const n=i[1],s=t.md.linkify.matchAtStart(t.src.slice(r-n.length));if(!s)return!1;let o=s.url;if(o.length<=n.length)return!1;o=o.replace(/\*+$/,"");const l=t.md.normalizeLink(o);if(!t.md.validateLink(l))return!1;if(!e){t.pending=t.pending.slice(0,-n.length);const e=t.push("link_open","a",1);e.attrs=[["href",l]],e.markup="linkify",e.info="auto",t.push("text","",0).content=t.md.normalizeLinkText(o);const r=t.push("link_close","a",-1);r.markup="linkify",r.info="auto"}return t.pos+=o.length-n.length,!0}],["newline",function(t,e){let r=t.pos;if(10!==t.src.charCodeAt(r))return!1;const i=t.pending.length-1,n=t.posMax;if(!e)if(i>=0&&32===t.pending.charCodeAt(i))if(i>=1&&32===t.pending.charCodeAt(i-1)){let e=i-1;for(;e>=1&&32===t.pending.charCodeAt(e-1);)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);for(r++;r<n&&bu(t.src.charCodeAt(r));)r++;return t.pos=r,!0}],["escape",function(t,e){let r=t.pos;const i=t.posMax;if(92!==t.src.charCodeAt(r))return!1;if(r++,r>=i)return!1;let n=t.src.charCodeAt(r);if(10===n){for(e||t.push("hardbreak","br",0),r++;r<i&&(n=t.src.charCodeAt(r),bu(n));)r++;return t.pos=r,!0}let s=t.src[r];if(n>=55296&&n<=56319&&r+1<i){const e=t.src.charCodeAt(r+1);e>=56320&&e<=57343&&(s+=t.src[r+1],r++)}const o="\\"+s;if(!e){const e=t.push("text_special","",0);e.content=n<256&&0!==sh[n]?s:o,e.markup=o,e.info="escape"}return t.pos=r+1,!0}],["backticks",function(t,e){let r=t.pos;if(96!==t.src.charCodeAt(r))return!1;const i=r;r++;const n=t.posMax;for(;r<n&&96===t.src.charCodeAt(r);)r++;const s=t.src.slice(i,r),o=s.length;if(t.backticksScanned&&(t.backticks[o]||0)<=i)return e||(t.pending+=s),t.pos+=o,!0;let l,u=r;for(;-1!==(l=t.src.indexOf("`",u));){for(u=l+1;u<n&&96===t.src.charCodeAt(u);)u++;const i=u-l;if(i===o){if(!e){const e=t.push("code_inline","code",0);e.markup=s,e.content=t.src.slice(r,l).replace(/\n/g," ").replace(/^ (.+) $/,"$1")}return t.pos=u,!0}t.backticks[i]=l}return t.backticksScanned=!0,e||(t.pending+=s),t.pos+=o,!0}],["strikethrough",lh.tokenize],["emphasis",hh.tokenize],["link",function(t,e){let r,i,n,s,o="",l="",u=t.pos,h=!0;if(91!==t.src.charCodeAt(t.pos))return!1;const a=t.pos,f=t.posMax,c=t.pos+1,d=t.md.helpers.parseLinkLabel(t,t.pos,!0);if(d<0)return!1;let p=d+1;if(p<f&&40===t.src.charCodeAt(p)){for(h=!1,p++;p<f&&(r=t.src.charCodeAt(p),bu(r)||10===r);p++);if(p>=f)return!1;if(u=p,n=t.md.helpers.parseLinkDestination(t.src,p,t.posMax),n.ok){for(o=t.md.normalizeLink(n.str),t.md.validateLink(o)?p=n.pos:o="",u=p;p<f&&(r=t.src.charCodeAt(p),bu(r)||10===r);p++);if(n=t.md.helpers.parseLinkTitle(t.src,p,t.posMax),p<f&&u!==p&&n.ok)for(l=n.str,p=n.pos;p<f&&(r=t.src.charCodeAt(p),bu(r)||10===r);p++);}(p>=f||41!==t.src.charCodeAt(p))&&(h=!0),p++}if(h){if(void 0===t.env.references)return!1;if(p<f&&91===t.src.charCodeAt(p)?(u=p+1,p=t.md.helpers.parseLinkLabel(t,p),p>=0?i=t.src.slice(u,p++):p=d+1):p=d+1,i||(i=t.src.slice(c,d)),s=t.env.references[Du(i)],!s)return t.pos=a,!1;o=s.href,l=s.title}if(!e){t.pos=c,t.posMax=d;const e=[["href",o]];t.push("link_open","a",1).attrs=e,l&&e.push(["title",l]),t.linkLevel++,t.md.inline.tokenize(t),t.linkLevel--,t.push("link_close","a",-1)}return t.pos=p,t.posMax=f,!0}],["image",function(t,e){let r,i,n,s,o,l,u,h,a="";const f=t.pos,c=t.posMax;if(33!==t.src.charCodeAt(t.pos))return!1;if(91!==t.src.charCodeAt(t.pos+1))return!1;const d=t.pos+2,p=t.md.helpers.parseLinkLabel(t,t.pos+1,!1);if(p<0)return!1;if(s=p+1,s<c&&40===t.src.charCodeAt(s)){for(s++;s<c&&(r=t.src.charCodeAt(s),bu(r)||10===r);s++);if(s>=c)return!1;for(h=s,l=t.md.helpers.parseLinkDestination(t.src,s,t.posMax),l.ok&&(a=t.md.normalizeLink(l.str),t.md.validateLink(a)?s=l.pos:a=""),h=s;s<c&&(r=t.src.charCodeAt(s),bu(r)||10===r);s++);if(l=t.md.helpers.parseLinkTitle(t.src,s,t.posMax),s<c&&h!==s&&l.ok)for(u=l.str,s=l.pos;s<c&&(r=t.src.charCodeAt(s),bu(r)||10===r);s++);else u="";if(s>=c||41!==t.src.charCodeAt(s))return t.pos=f,!1;s++}else{if(void 0===t.env.references)return!1;if(s<c&&91===t.src.charCodeAt(s)?(h=s+1,s=t.md.helpers.parseLinkLabel(t,s),s>=0?n=t.src.slice(h,s++):s=p+1):s=p+1,n||(n=t.src.slice(d,p)),o=t.env.references[Du(n)],!o)return t.pos=f,!1;a=o.href,u=o.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),n=[["src",a],["alt",""]];r.attrs=n,r.children=e,r.content=i,u&&n.push(["title",u])}return t.pos=s,t.posMax=c,!0}],["autolink",function(t,e){let r=t.pos;if(60!==t.src.charCodeAt(r))return!1;const i=t.pos,n=t.posMax;for(;;){if(++r>=n)return!1;const e=t.src.charCodeAt(r);if(60===e)return!1;if(62===e)break}const s=t.src.slice(i+1,r);if(fh.test(s)){const r=t.md.normalizeLink(s);if(!t.md.validateLink(r))return!1;if(!e){const e=t.push("link_open","a",1);e.attrs=[["href",r]],e.markup="autolink",e.info="auto",t.push("text","",0).content=t.md.normalizeLinkText(s);const i=t.push("link_close","a",-1);i.markup="autolink",i.info="auto"}return t.pos+=s.length+2,!0}if(ah.test(s)){const r=t.md.normalizeLink("mailto:"+s);if(!t.md.validateLink(r))return!1;if(!e){const e=t.push("link_open","a",1);e.attrs=[["href",r]],e.markup="autolink",e.info="auto",t.push("text","",0).content=t.md.normalizeLinkText(s);const i=t.push("link_close","a",-1);i.markup="autolink",i.info="auto"}return t.pos+=s.length+2,!0}return!1}],["html_inline",function(t,e){if(!t.md.options.html)return!1;const r=t.posMax,i=t.pos;if(60!==t.src.charCodeAt(i)||i+2>=r)return!1;const n=t.src.charCodeAt(i+1);if(33!==n&&63!==n&&47!==n&&!function(t){const e=32|t;return e>=97&&e<=122}(n))return!1;const s=t.src.slice(i).match(Yu);if(!s)return!1;if(!e){const e=t.push("html_inline","",0);e.content=s[0],/^<a[>\s]/i.test(e.content)&&t.linkLevel++,/^<\/a\s*>/i.test(e.content)&&t.linkLevel--}return t.pos+=s[0].length,!0}],["entity",function(t,e){const r=t.pos,i=t.posMax;if(38!==t.src.charCodeAt(r))return!1;if(r+1>=i)return!1;if(35===t.src.charCodeAt(r+1)){const i=t.src.slice(r).match(ch);if(i){if(!e){const e="x"===i[1][0].toLowerCase()?parseInt(i[1].slice(1),16):parseInt(i[1],10),r=t.push("text_special","",0);r.content=su(e)?ou(e):ou(65533),r.markup=i[0],r.info="entity"}return t.pos+=i[0].length,!0}}else{const i=t.src.slice(r).match(dh);if(i){const r=M(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"}return t.pos+=i[0].length,!0}}}return!1}]],gh=[["balance_pairs",function(t){const e=t.tokens_meta,r=t.tokens_meta.length;ph(t.delimiters);for(let t=0;t<r;t++)e[t]&&e[t].delimiters&&ph(e[t].delimiters)}],["strikethrough",lh.postProcess],["emphasis",hh.postProcess],["fragments_join",function(t){let e,r,i=0;const n=t.tokens,s=t.tokens.length;for(e=r=0;e<s;e++)n[e].nesting<0&&i--,n[e].level=i,n[e].nesting>0&&i++,"text"===n[e].type&&e+1<s&&"text"===n[e+1].type?n[e+1].content=n[e].content+n[e+1].content:(e!==r&&(n[r]=n[e]),r++);e!==r&&(n.length=r)}]];function bh(){this.ruler=new Mu;for(let t=0;t<mh.length;t++)this.ruler.push(mh[t][0],mh[t][1]);this.ruler2=new Mu;for(let t=0;t<gh.length;t++)this.ruler2.push(gh[t][0],gh[t][1])}function wh(t){return Array.prototype.slice.call(arguments,1).forEach((function(e){e&&Object.keys(e).forEach((function(r){t[r]=e[r]}))})),t}function vh(t){return Object.prototype.toString.call(t)}function kh(t){return"[object Function]"===vh(t)}function Dh(t){return t.replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}bh.prototype.skipToken=function(t){const e=t.pos,r=this.ruler.getRules(""),i=r.length,n=t.md.options.maxNesting,s=t.cache;if(void 0!==s[e])return void(t.pos=s[e]);let o=!1;if(t.level<n){for(let n=0;n<i;n++)if(t.level++,o=r[n](t,!0),t.level--,o){if(e>=t.pos)throw new Error("inline rule didn't increment state.pos");break}}else t.pos=t.posMax;o||t.pos++,s[e]=t.pos},bh.prototype.tokenize=function(t){const e=this.ruler.getRules(""),r=e.length,i=t.posMax,n=t.md.options.maxNesting;for(;t.pos<i;){const s=t.pos;let o=!1;if(t.level<n)for(let i=0;i<r;i++)if(o=e[i](t,!1),o){if(s>=t.pos)throw new Error("inline rule didn't increment state.pos");break}if(o){if(t.pos>=i)break}else t.pending+=t.src[t.pos++]}t.pending&&t.pushPending()},bh.prototype.parse=function(t,e,r,i){const n=new this.State(t,e,r,i);this.tokenize(n);const s=this.ruler2.getRules(""),o=s.length;for(let t=0;t<o;t++)s[t](n)},bh.prototype.State=rh;const yh={fuzzyLink:!0,fuzzyEmail:!0,fuzzyIP:!1},Eh={"http:":{validate:function(t,e,r){const i=t.slice(e);return r.re.http||(r.re.http=new RegExp("^\\/\\/"+r.re.src_auth+r.re.src_host_port_strict+r.re.src_path,"i")),r.re.http.test(i)?i.match(r.re.http)[0].length:0}},"https:":"http:","ftp:":"http:","//":{validate:function(t,e,r){const i=t.slice(e);return 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")),r.re.no_http.test(i)?e>=3&&":"===t[e-3]||e>=3&&"/"===t[e-3]?0:i.match(r.re.no_http)[0].length:0}},"mailto:":{validate:function(t,e,r){const i=t.slice(e);return r.re.mailto||(r.re.mailto=new RegExp("^"+r.re.src_email_name+"@"+r.re.src_host_strict,"i")),r.re.mailto.test(i)?i.match(r.re.mailto)[0].length:0}}},xh="biz|com|edu|gov|net|org|pro|web|xxx|aero|asia|coop|info|museum|name|shop|рф".split("|");function Fh(t){const e=t.re=function(t){const e={};t=t||{},e.src_Any=Gl.source,e.src_Cc=Zl.source,e.src_Z=Xl.source,e.src_P=Kl.source,e.src_ZPCc=[e.src_Z,e.src_P,e.src_Cc].join("|"),e.src_ZCc=[e.src_Z,e.src_Cc].join("|");return e.src_pseudo_letter="(?:(?![><|]|"+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="(?=$|[><|]|"+e.src_ZPCc+")(?!"+(t["---"]?"-(?!--)|":"-|")+"_|:\\d|\\.-|\\.(?!$|"+e.src_ZPCc+"))",e.src_path="(?:[/?#](?:(?!"+e.src_ZCc+"|[><|]|[()[\\]{}.,\"'?!\\-;]).|\\[(?:(?!"+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='(^|[><|]|"|\\(|'+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+")",e}(t.__opts__),r=t.__tlds__.slice();function i(t){return t.replace("%TLDS%",e.src_tlds)}t.onCompile(),t.__tlds_replaced__||r.push("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]"),r.push(e.src_xn),e.src_tlds=r.join("|"),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=[];function s(t,e){throw new Error('(LinkifyIt) Invalid schema "'+t+'": '+e)}t.__compiled__={},Object.keys(t.__schemas__).forEach((function(e){const r=t.__schemas__[e];if(null===r)return;const i={validate:null,link:null};if(t.__compiled__[e]=i,"[object Object]"===vh(r))return"[object RegExp]"!==vh(r.validate)?kh(r.validate)?i.validate=r.validate:s(e,r):i.validate=function(t){return function(e,r){const i=e.slice(r);return t.test(i)?i.match(t)[0].length:0}}(r.validate),void(kh(r.normalize)?i.normalize=r.normalize:r.normalize?s(e,r):i.normalize=function(t,e){e.normalize(t)});!function(t){return"[object String]"===vh(t)}(r)?s(e,r):n.push(e)})),n.forEach((function(e){t.__compiled__[t.__schemas__[e]]&&(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:function(t,e){e.normalize(t)}};const o=Object.keys(t.__compiled__).filter((function(e){return e.length>0&&t.__compiled__[e]})).map(Dh).join("|");t.re.schema_test=RegExp("(^|(?!_)(?:[><|]|"+e.src_ZPCc+"))("+o+")","i"),t.re.schema_search=RegExp("(^|(?!_)(?:[><|]|"+e.src_ZPCc+"))("+o+")","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"),function(t){t.__index__=-1,t.__text_cache__=""}(t)}function Mh(t,e){const r=t.__index__,i=t.__last_index__,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 Ah(t,e){const r=new Mh(t,e);return t.__compiled__[r.schema].normalize(r,t),r}function Ch(t,e){if(!(this instanceof Ch))return new Ch(t,e);e||Object.keys(t||{}).reduce((function(t,e){return t||yh.hasOwnProperty(e)}),!1)&&(e=t,t={}),this.__opts__=wh({},yh,e),this.__index__=-1,this.__last_index__=-1,this.__schema__="",this.__text_cache__="",this.__schemas__=wh({},Eh,t),this.__compiled__={},this.__tlds__=xh,this.__tlds_replaced__=!1,this.re={},Fh(this)}Ch.prototype.add=function(t,e){return this.__schemas__[t]=e,Fh(this),this},Ch.prototype.set=function(t){return this.__opts__=wh(this.__opts__,t),this},Ch.prototype.test=function(t){if(this.__text_cache__=t,this.__index__=-1,!t.length)return!1;let e,r,i,n,s,o,l,u,h;if(this.re.schema_test.test(t))for(l=this.re.schema_search,l.lastIndex=0;null!==(e=l.exec(t));)if(n=this.testSchemaAt(t,e[2],l.lastIndex),n){this.__schema__=e[2],this.__index__=e.index+e[1].length,this.__last_index__=e.index+e[0].length+n;break}return this.__opts__.fuzzyLink&&this.__compiled__["http:"]&&(u=t.search(this.re.host_fuzzy_test),u>=0&&(this.__index__<0||u<this.__index__)&&null!==(r=t.match(this.__opts__.fuzzyIP?this.re.link_fuzzy:this.re.link_no_ip_fuzzy))&&(s=r.index+r[1].length,(this.__index__<0||s<this.__index__)&&(this.__schema__="",this.__index__=s,this.__last_index__=r.index+r[0].length))),this.__opts__.fuzzyEmail&&this.__compiled__["mailto:"]&&(h=t.indexOf("@"),h>=0&&null!==(i=t.match(this.re.email_fuzzy))&&(s=i.index+i[1].length,o=i.index+i[0].length,(this.__index__<0||s<this.__index__||s===this.__index__&&o>this.__last_index__)&&(this.__schema__="mailto:",this.__index__=s,this.__last_index__=o))),this.__index__>=0},Ch.prototype.pretest=function(t){return this.re.pretest.test(t)},Ch.prototype.testSchemaAt=function(t,e,r){return this.__compiled__[e.toLowerCase()]?this.__compiled__[e.toLowerCase()].validate(t,r,this):0},Ch.prototype.match=function(t){const e=[];let r=0;this.__index__>=0&&this.__text_cache__===t&&(e.push(Ah(this,r)),r=this.__last_index__);let i=r?t.slice(r):t;for(;this.test(i);)e.push(Ah(this,r)),i=i.slice(this.__last_index__),r+=this.__last_index__;return e.length?e:null},Ch.prototype.matchAtStart=function(t){if(this.__text_cache__=t,this.__index__=-1,!t.length)return null;const e=this.re.schema_at_start.exec(t);if(!e)return null;const r=this.testSchemaAt(t,e[2],e[0].length);return r?(this.__schema__=e[2],this.__index__=e.index+e[1].length,this.__last_index__=e.index+e[0].length+r,Ah(this,0)):null},Ch.prototype.tlds=function(t,e){return t=Array.isArray(t)?t:[t],e?(this.__tlds__=this.__tlds__.concat(t).sort().filter((function(t,e,r){return t!==r[e-1]})).reverse(),Fh(this),this):(this.__tlds__=t.slice(),this.__tlds_replaced__=!0,Fh(this),this)},Ch.prototype.normalize=function(t){t.schema||(t.url="http://"+t.url),"mailto:"!==t.schema||/^mailto:/i.test(t.url)||(t.url="mailto:"+t.url)},Ch.prototype.onCompile=function(){};const Sh=2147483647,Oh=36,$h=/^xn--/,Bh=/[^\0-\x7F]/,Rh=/[\x2E\u3002\uFF0E\uFF61]/g,Nh={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},_h=Math.floor,Th=String.fromCharCode;function zh(t){throw new RangeError(Nh[t])}function jh(t,e){const r=t.split("@");let i="";r.length>1&&(i=r[0]+"@",t=r[1]);const n=function(t,e){const r=[];let i=t.length;for(;i--;)r[i]=e(t[i]);return r}((t=t.replace(Rh,".")).split("."),e).join(".");return i+n}const qh=function(t,e){return t+22+75*(t<26)-((0!=e)<<5)},Ih=function(t,e,r){let i=0;for(t=r?_h(t/700):t>>1,t+=_h(t/e);t>455;i+=Oh)t=_h(t/35);return _h(i+36*t/(t+38))},Ph=function(t){return jh(t,(function(t){return Bh.test(t)?"xn--"+function(t){const e=[],r=(t=function(t){const e=[];let r=0;const i=t.length;for(;r<i;){const n=t.charCodeAt(r++);if(n>=55296&&n<=56319&&r<i){const i=t.charCodeAt(r++);56320==(64512&i)?e.push(((1023&n)<<10)+(1023&i)+65536):(e.push(n),r--)}else e.push(n)}return e}(t)).length;let i=128,n=0,s=72;for(const r of t)r<128&&e.push(Th(r));const o=e.length;let l=o;for(o&&e.push("-");l<r;){let r=Sh;for(const e of t)e>=i&&e<r&&(r=e);const u=l+1;r-i>_h((Sh-n)/u)&&zh("overflow"),n+=(r-i)*u,i=r;for(const r of t)if(r<i&&++n>Sh&&zh("overflow"),r===i){let t=n;for(let r=Oh;;r+=Oh){const i=r<=s?1:r>=s+26?26:r-s;if(t<i)break;const n=t-i,o=Oh-i;e.push(Th(qh(i+n%o,0))),t=_h(n/o)}e.push(Th(qh(t,0))),s=Ih(n,u,l===o),n=0,++l}++n,++i}return e.join("")}(t):t}))},Lh=function(t){return jh(t,(function(t){return $h.test(t)?function(t){const e=[],r=t.length;let i=0,n=128,s=72,o=t.lastIndexOf("-");o<0&&(o=0);for(let r=0;r<o;++r)t.charCodeAt(r)>=128&&zh("not-basic"),e.push(t.charCodeAt(r));for(let u=o>0?o+1:0;u<r;){const o=i;for(let e=1,n=Oh;;n+=Oh){u>=r&&zh("invalid-input");const o=(l=t.charCodeAt(u++))>=48&&l<58?l-48+26:l>=65&&l<91?l-65:l>=97&&l<123?l-97:Oh;o>=Oh&&zh("invalid-input"),o>_h((Sh-i)/e)&&zh("overflow"),i+=o*e;const h=n<=s?1:n>=s+26?26:n-s;if(o<h)break;const a=Oh-h;e>_h(Sh/a)&&zh("overflow"),e*=a}const h=e.length+1;s=Ih(i-o,h,0==o),_h(i/h)>Sh-n&&zh("overflow"),n+=_h(i/h),i%=h,e.splice(i++,0,n)}var l;return String.fromCodePoint(...e)}(t.slice(4).toLowerCase()):t}))},Jh={default:{options:{html:!1,xhtmlOut:!1,breaks:!1,langPrefix:"language-",linkify:!1,typographer:!1,quotes:"“”‘’",highlight:null,maxNesting:100},components:{core:{},block:{},inline:{}}},zero:{options:{html:!1,xhtmlOut:!1,breaks:!1,langPrefix:"language-",linkify:!1,typographer:!1,quotes:"“”‘’",highlight:null,maxNesting:20},components:{core:{rules:["normalize","block","inline","text_join"]},block:{rules:["paragraph"]},inline:{rules:["text"],rules2:["balance_pairs","fragments_join"]}}},commonmark:{options:{html:!0,xhtmlOut:!0,breaks:!1,langPrefix:"language-",linkify:!1,typographer:!1,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"]}}}},Uh=/^(vbscript|javascript|file|data):/,Vh=/^data:image\/(gif|png|jpeg|webp);/;function Hh(t){const e=t.trim().toLowerCase();return!Uh.test(e)||Vh.test(e)}const Wh=["http:","https:","mailto:"];function Gh(t){const e=Ul(t,!0);if(e.hostname&&(!e.protocol||Wh.indexOf(e.protocol)>=0))try{e.hostname=Ph(e.hostname)}catch(t){}return Ol($l(e))}function Zh(t){const e=Ul(t,!0);if(e.hostname&&(!e.protocol||Wh.indexOf(e.protocol)>=0))try{e.hostname=Lh(e.hostname)}catch(t){}return Cl($l(e),Cl.defaultChars+"%")}function Kh(t,e){if(!(this instanceof Kh))return new Kh(t,e);e||eu(t)||(e=t||{},t="default"),this.inline=new bh,this.block=new eh,this.core=new Ju,this.renderer=new Fu,this.linkify=new Ch,this.validateLink=Hh,this.normalizeLink=Gh,this.normalizeLinkText=Zh,this.utils=yu,this.helpers=iu({},Eu),this.options={},this.configure(t),e&&this.set(e)}Kh.prototype.set=function(t){return iu(this.options,t),this},Kh.prototype.configure=function(t){const e=this;if(eu(t)){const e=t;if(!(t=Jh[e]))throw new Error('Wrong `markdown-it` preset "'+e+'", check name')}if(!t)throw new Error("Wrong `markdown-it` preset, can't be empty");return t.options&&e.set(t.options),t.components&&Object.keys(t.components).forEach((function(r){t.components[r].rules&&e[r].ruler.enableOnly(t.components[r].rules),t.components[r].rules2&&e[r].ruler2.enableOnly(t.components[r].rules2)})),this},Kh.prototype.enable=function(t,e){let r=[];Array.isArray(t)||(t=[t]),["core","block","inline"].forEach((function(e){r=r.concat(this[e].ruler.enable(t,!0))}),this),r=r.concat(this.inline.ruler2.enable(t,!0));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},Kh.prototype.disable=function(t,e){let r=[];Array.isArray(t)||(t=[t]),["core","block","inline"].forEach((function(e){r=r.concat(this[e].ruler.disable(t,!0))}),this),r=r.concat(this.inline.ruler2.disable(t,!0));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},Kh.prototype.use=function(t){const e=[this].concat(Array.prototype.slice.call(arguments,1));return t.apply(t,e),this},Kh.prototype.parse=function(t,e){if("string"!=typeof t)throw new Error("Input data should be a String");const r=new this.core.State(t,this,e);return this.core.process(r),r.tokens},Kh.prototype.render=function(t,e){return this.renderer.render(this.parse(t,e=e||{}),this.options,e)},Kh.prototype.parseInline=function(t,e){const r=new this.core.State(t,this,e);return r.inlineMode=!0,this.core.process(r),r.tokens},Kh.prototype.renderInline=function(t,e){return this.renderer.render(this.parseInline(t,e=e||{}),this.options,e)};const Yh=new Lt({nodes:{doc:{content:"block+"},paragraph:{content:"inline*",group:"block",parseDOM:[{tag:"p"}],toDOM:()=>["p",0]},blockquote:{content:"block+",group:"block",parseDOM:[{tag:"blockquote"}],toDOM:()=>["blockquote",0]},horizontal_rule:{group:"block",parseDOM:[{tag:"hr"}],toDOM:()=>["div",["hr"]]},heading:{attrs:{level:{default:1}},content:"(text | image)*",group:"block",defining:!0,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=>["h"+t.attrs.level,0]},code_block:{content:"text*",group:"block",code:!0,defining:!0,marks:"",attrs:{params:{default:""}},parseDOM:[{tag:"pre",preserveWhitespace:"full",getAttrs:t=>({params:t.getAttribute("data-params")||""})}],toDOM:t=>["pre",t.attrs.params?{"data-params":t.attrs.params}:{},["code",0]]},ordered_list:{content:"list_item+",group:"block",attrs:{order:{default:1},tight:{default:!1}},parseDOM:[{tag:"ol",getAttrs:t=>({order:t.hasAttribute("start")?+t.getAttribute("start"):1,tight:t.hasAttribute("data-tight")})}],toDOM:t=>["ol",{start:1==t.attrs.order?null:t.attrs.order,"data-tight":t.attrs.tight?"true":null},0]},bullet_list:{content:"list_item+",group:"block",attrs:{tight:{default:!1}},parseDOM:[{tag:"ul",getAttrs:t=>({tight:t.hasAttribute("data-tight")})}],toDOM:t=>["ul",{"data-tight":t.attrs.tight?"true":null},0]},list_item:{content:"block+",defining:!0,parseDOM:[{tag:"li"}],toDOM:()=>["li",0]},text:{group:"inline"},image:{inline:!0,attrs:{src:{},alt:{default:null},title:{default:null}},group:"inline",draggable:!0,parseDOM:[{tag:"img[src]",getAttrs:t=>({src:t.getAttribute("src"),title:t.getAttribute("title"),alt:t.getAttribute("alt")})}],toDOM:t=>["img",t.attrs]},hard_break:{inline:!0,group:"inline",selectable:!1,parseDOM:[{tag:"br"}],toDOM:()=>["br"]}},marks:{em:{parseDOM:[{tag:"i"},{tag:"em"},{style:"font-style=italic"},{style:"font-style=normal",clearMark:t=>"em"==t.type.name}],toDOM:()=>["em"]},strong:{parseDOM:[{tag:"strong"},{tag:"b",getAttrs:t=>"normal"!=t.style.fontWeight&&null},{style:"font-weight=400",clearMark:t=>"strong"==t.type.name},{style:"font-weight",getAttrs:t=>/^(bold(er)?|[5-9]\d{2,})$/.test(t)&&null}],toDOM:()=>["strong"]},link:{attrs:{href:{},title:{default:null}},inclusive:!1,parseDOM:[{tag:"a[href]",getAttrs:t=>({href:t.getAttribute("href"),title:t.getAttribute("title")})}],toDOM:t=>["a",t.attrs]},code:{code:!0,parseDOM:[{tag:"code"}],toDOM:()=>["code"]}}});class Xh{constructor(t,e){this.schema=t,this.tokenHandlers=e,this.stack=[{type:t.topNodeType,attrs:null,content:[],marks:it.none}]}top(){return this.stack[this.stack.length-1]}push(t){this.stack.length&&this.top().content.push(t)}addText(t){if(!t)return;let e,r=this.top(),i=r.content,n=i[i.length-1],s=this.schema.text(t,r.marks);n&&(e=function(t,e){if(t.isText&&e.isText&&it.sameSet(t.marks,e.marks))return t.withText(t.text+e.text)}(n,s))?i[i.length-1]=e:i.push(s)}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],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(),n=t.createAndFill(e,r,i?i.marks:[]);return n?(this.push(n),n):null}openNode(t,e){this.stack.push({type:t,attrs:e,content:[],marks:it.none})}closeNode(){let t=this.stack.pop();return this.addNode(t.type,t.attrs,t.content)}}function Qh(t,e,r,i){return t.getAttrs?t.getAttrs(e,r,i):t.attrs instanceof Function?t.attrs(e):t.attrs}function ta(t,e){return t.noCloseToken||"code_inline"==e||"code_block"==e||"fence"==e}function ea(t){return"\n"==t[t.length-1]?t.slice(0,t.length-1):t}function ra(){}function ia(t,e){for(;++e<t.length;)if("list_item_open"!=t[e].type)return t[e].hidden;return!1}new class{constructor(t,e,r){this.schema=t,this.tokenizer=e,this.tokens=r,this.tokenHandlers=function(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);ta(n,i)?r[i]=(t,r,i,s)=>{t.openNode(e,Qh(n,r,i,s)),t.addText(ea(r.content)),t.closeNode()}:(r[i+"_open"]=(t,r,i,s)=>t.openNode(e,Qh(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,Qh(n,r,i,s))}else if(n.mark){let e=t.marks[n.mark];ta(n,i)?r[i]=(t,r,i,s)=>{t.openMark(e.create(Qh(n,r,i,s))),t.addText(ea(r.content)),t.closeMark(e)}:(r[i+"_open"]=(t,r,i,s)=>t.openMark(e.create(Qh(n,r,i,s))),r[i+"_close"]=t=>t.closeMark(e))}else{if(!n.ignore)throw new RangeError("Unrecognized parsing spec "+JSON.stringify(n));ta(n,i)?r[i]=ra:(r[i+"_open"]=ra,r[i+"_close"]=ra)}}return r.text=(t,e)=>t.addText(e.content),r.inline=(t,e)=>t.parseTokens(e.children),r.softbreak=r.softbreak||(t=>t.addText(" ")),r}(t,r)}parse(t,e={}){let r,i=new Xh(this.schema,this.tokenHandlers);i.parseTokens(this.tokenizer.parse(t,e));do{r=i.closeNode()}while(i.stack.length);return r||this.schema.topNodeType.createAndFill()}}(Yh,Kh("commonmark",{html:!1}),{blockquote:{block:"blockquote"},paragraph:{block:"paragraph"},list_item:{block:"list_item"},bullet_list:{block:"bullet_list",getAttrs:(t,e,r)=>({tight:ia(e,r)})},ordered_list:{block:"ordered_list",getAttrs:(t,e,r)=>({order:+t.attrGet("start")||1,tight:ia(e,r)})},heading:{block:"heading",getAttrs:t=>({level:+t.tag.slice(1)})},code_block:{block:"code_block",noCloseToken:!0},fence:{block:"code_block",getAttrs:t=>({params:t.info||""}),noCloseToken:!0},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:!0}});const na={open:"",close:"",mixable:!0};class sa{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 ua(this.nodes,this.marks,e);return r.renderContent(t),r.out}}const oa=new sa({blockquote(t,e){t.wrapBlock("> ",null,e,(()=>t.renderContent(e)))},code_block(t,e){const r=e.textContent.match(/`{3,}/gm),i=r?r.sort().slice(-1)[0]+"`":"```";t.write(i+(e.attrs.params||"")+"\n"),t.text(e.textContent,!1),t.write("\n"),t.write(i),t.closeBlock(e)},heading(t,e){t.write(t.repeat("#",e.attrs.level)+" "),t.renderInline(e,!1),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,i=String(r+e.childCount-1).length,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("!["+t.esc(e.attrs.alt||"")+"]("+e.attrs.src.replace(/[\(\)]/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)return void t.write("\\\n")},text(t,e){t.text(e.text,!t.inAutolink)}},{em:{open:"*",close:"*",mixable:!0,expelEnclosingWhitespace:!0},strong:{open:"**",close:"**",mixable:!0,expelEnclosingWhitespace:!0},link:{open:(t,e,r,i)=>(t.inAutolink=function(t,e,r){if(t.attrs.title||!/^\w+:/.test(t.attrs.href))return!1;let i=e.child(r);return!(!i.isText||i.text!=t.attrs.href||i.marks[i.marks.length-1]!=t||r!=e.childCount-1&&t.isInSet(e.child(r+1).marks))}(e,r,i),t.inAutolink?"<":"["),close(t,e,r,i){let{inAutolink:n}=t;return t.inAutolink=void 0,n?">":"]("+e.attrs.href.replace(/[\(\)"]/g,"\\$&")+(e.attrs.title?` "${e.attrs.title.replace(/"/g,'\\"')}"`:"")+")"},mixable:!0},code:{open:(t,e,r,i)=>la(r.child(i),-1),close:(t,e,r,i)=>la(r.child(i-1),1),escape:!1}});function la(t,e){let r,i=/`+/g,n=0;if(t.isText)for(;r=i.exec(t.text);)n=Math.max(n,r[0].length);let s=n>0&&e>0?" `":"`";for(let t=0;t<n;t++)s+="`";return n>0&&e<0&&(s+=" "),s}class ua{constructor(t,e,r){this.nodes=t,this.marks=e,this.options=r,this.delim="",this.out="",this.closed=null,this.inAutolink=void 0,this.atBlockStart=!1,this.inTightList=!1,void 0===this.options.tightLists&&(this.options.tightLists=!1),void 0===this.options.hardBreakNodeName&&(this.options.hardBreakNodeName="hard_break")}flushClose(t=2){if(this.closed){if(this.atBlank()||(this.out+="\n"),t>1){let e=this.delim,r=/\s+$/.exec(e);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(!1!==this.options.strict)throw new Error(`Mark type \`${t}\` not supported by Markdown renderer`);e=na}return e}wrapBlock(t,e,r,i){let n=this.delim;this.write(null!=e?e:t),this.delim+=t,i(),this.delim=n,this.closeBlock(r)}atBlank(){return/(^|\n)$/.test(this.out)}ensureNewLine(){this.atBlank()||(this.out+="\n")}write(t){this.flushClose(),this.delim&&this.atBlank()&&(this.out+=this.delim),t&&(this.out+=t)}closeBlock(t){this.closed=t}text(t,e=!0){let r=t.split("\n");for(let t=0;t<r.length;t++)this.write(),!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],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(!1!==this.options.strict)throw new Error("Token type `"+t.type.name+"` not supported by Markdown renderer");t.type.isLeaf||(t.type.inlineContent?this.renderInline(t):this.renderContent(t),t.isBlock&&this.closeBlock(t))}}renderContent(t){t.forEach(((e,r,i)=>this.render(e,t,i)))}renderInline(t,e=!0){this.atBlockStart=e;let r=[],i="",n=(e,n,s)=>{let o=e?e.marks:[];e&&e.type.name===this.options.hardBreakNodeName&&(o=o.filter((e=>{if(s+1==t.childCount)return!1;let r=t.child(s+1);return e.isInSet(r.marks)&&(!r.isText||/\S/.test(r.text))})));let l=i;if(i="",e&&e.isText&&o.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);i&&(l+=i,(e=n?e.withText(n):null)||(o=r))}if(e&&e.isText&&o.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);s&&(i=s,(e=n?e.withText(n):null)||(o=r))}let u=o.length?o[o.length-1]:null,h=u&&!1===this.getMark(u.type.name).escape,a=o.length-(h?1:0);t:for(let t=0;t<a;t++){let e=o[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)){t>i?o=o.slice(0,i).concat(e).concat(o.slice(i,t)).concat(o.slice(t+1,a)):i>t&&(o=o.slice(0,t).concat(o.slice(t+1,i)).concat(e).concat(o.slice(i,a)));continue t}}}let f=0;for(;f<Math.min(r.length,a)&&o[f].eq(r[f]);)++f;for(;f<r.length;)this.text(this.markString(r.pop(),!1,t,s),!1);if(l&&this.text(l),e){for(;r.length<a;){let e=o[r.length];r.push(e),this.text(this.markString(e,!0,t,s),!1),this.atBlockStart=!1}h&&e.isText?this.text(this.markString(u,!0,t,s)+e.text+this.markString(u,!1,t,s+1),!1):this.render(e,t,s),this.atBlockStart=!1}(null==e?void 0:e.isText)&&e.nodeSize>0&&(this.atBlockStart=!1)};t.forEach(n),n(null,0,t.childCount),this.atBlockStart=!1}renderList(t,e,r){this.closed&&this.closed.type==t.type?this.flushClose(3):this.inTightList&&this.flushClose(1);let i=void 0!==t.attrs.tight?t.attrs.tight:this.options.tightLists,n=this.inTightList;this.inTightList=i,t.forEach(((n,s,o)=>{o&&i&&this.flushClose(1),this.wrapBlock(e,r(o),t,(()=>this.render(n,t,o)))})),this.inTightList=n}esc(t,e=!1){return 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)),e&&(t=t.replace(/^(\+[ ]|[\-*>])/,"\\$&").replace(/^(\s*)(#{1,6})(\s|$)/,"$1\\$2$3").replace(/^(\s*\d+)\.\s/,"$1\\. ")),this.options.escapeExtraCharacters&&(t=t.replace(this.options.escapeExtraCharacters,"\\$&")),t}quote(t){let e=-1==t.indexOf('"')?'""':-1==t.indexOf("'")?"''":"()";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),s=e?n.open:n.close;return"string"==typeof s?s:s(this,t,r,i)}getEnclosingWhitespace(t){return{leading:(t.match(/^(\s+)/)||[void 0])[0],trailing:(t.match(/(\s+)$/)||[void 0])[0]}}}const ha=new Map;function aa(t,e){t.style.height=e.attrs.height,t.style.width=e.attrs.width,t.style.minHeight=e.attrs.minHeight,t.style.minWidth=e.attrs.minWidth,t.style.maxWidth=e.attrs.maxWidth}function fa(t){if("image"===t.type.name)return!0;for(let e=0;e<t.childCount;e++)if(fa(t.child(e)))return!0;return!1}function ca(t){return(e,r)=>{const i=r.attrs.state;if(!da(i))return;if("success"===i){const t=function(t){const e=[];t.height&&e.push(`height: ${t.height};`),t.width&&e.push(`width: ${t.width};`),t.minHeight&&e.push(`min-height: ${t.minHeight};`),t.minWidth&&e.push(`min-width: ${t.minWidth};`),t.maxWidth&&e.push(`max-width: ${t.maxWidth};`);const r=e.length>0?` style="${e.join("")}"`:"";return`<img src="${t.src}" alt="${t.alt}"${r} />`}(r.attrs);return void e.write(t)}const n=function(t,e,r){return`<span>${A.get(`editor-image-view.${"failed"===t?"failed":"loading"}`,r,{filename:e||"file"})}</span>`}(i,r.attrs.alt,t);e.write(n)}}function da(t){return"loading"===t||"failed"===t||"success"===t}const pa=t=>(e,r)=>{const i=`<${t.tagName}`+t.attributes.map((t=>` ${t}="${r.attrs[t]}"`)).join("")+">",n=`</${t.tagName}>`;e.write(i),e.renderContent(r),e.write(n)};class ma{constructor(t,e){this.parseAsHTML=t=>a(t,{whitelist:this.customNodes}),this.serialize=t=>""!==t.dom.textContent.trim()||fa(t.state.doc)?this.markdownSerializer.serialize(t.state.doc):"",this.markdownSerializer=((t,e)=>{const r={};for(const e of t)r[e.tagName]=pa(e);const i=Object.assign(Object.assign(Object.assign({},oa.nodes),function(t){return{image:ca(t)}}(e)),r),n=Object.assign(Object.assign({},oa.marks),{strikethrough:{open:"~~",close:"~~",mixable:!0,expelEnclosingWhitespace:!0}});return new sa(i,n)})(t,e),this.customNodes=t}}class ga{constructor(t){this.parseAsHTML=t=>f(t,this.customNodes),this.serialize=t=>{if(""===t.dom.textContent.trim()&&!fa(t.state.doc))return"";const e=document.createElement("div");return e.append(te.fromSchema(t.state.schema).serializeFragment(t.state.doc.content)),e.innerHTML},this.customNodes=t}}const ba={parseDOM:[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration=line-through"}],toDOM:()=>["s",0]},wa=new gr("linkPlugin"),va=(t,e)=>{const r=t.posAtCoords({left:e.clientX,top:e.clientY}),i=t.state.doc.nodeAt(null==r?void 0:r.pos);if(!i)return null;const n=i.marks.find((t=>t.type.name===s.Link));if(!n)return null;const o=n.attrs.href,l=((t,e,r)=>{for(;e>0;){const i=t.nodeAt(e-1);if(!(null==i?void 0:i.isText)||!i.marks.some((t=>t.type.name===s.Link&&t.attrs.href===r)))break;e--}return e})(t.state.doc,r.pos,o),u=((t,e,r)=>{for(;e<t.content.size;){const i=t.nodeAt(e);if(!(null==i?void 0:i.isText)||!i.marks.some((t=>t.type.name===s.Link&&t.attrs.href===r)))break;e++}return e})(t.state.doc,r.pos,o);return{href:o,text:t.state.doc.textBetween(l,u," "),from:l,to:u}},ka=/(https?:\/\/[^\s<>"']+|mailto:[^\s<>"']+|tel:[^\s<>"']+|www\.[^\s<>"']+)/g,Da=(t,e)=>t.text(e),ya=(t,e)=>{const r=(t=>{let e=t.trim();for(;e.endsWith("\\");)e=e.slice(0,-1);return e.toLowerCase().startsWith("www.")&&(e=`https://${e}`),e})(e),i=t.marks.link.create(h(r,r));return t.text(r,[i])},Ea=(t,e)=>{const r=[],i=(t=>{const e=[];let r;for(ka.lastIndex=0;null!==(r=ka.exec(t));)e.push({url:r[0],start:r.index,end:r.index+r[0].length});return e})(t);if(0===i.length)return[Da(e,t)];let n=0;for(const s of i)s.start>n&&r.push(Da(e,t.slice(n,s.start))),r.push(ya(e,s.url)),n=s.end;return n<t.length&&r.push(Da(e,t.slice(n))),r},xa=(t,e)=>{var r;const i=null===(r=e.clipboardData)||void 0===r?void 0:r.getData("text/plain");if(!i||!(t=>(ka.lastIndex=0,ka.test(t)))(i))return!1;const n=((t,e)=>{const r=t.split(/\r\n|\r|\n/),i=[];for(const[t,n]of r.entries())if(n.length>0&&i.push(...Ea(n,e)),t<r.length-1){const t=e.nodes.hard_break;t?i.push(t.create()):console.warn("hard_break node not found in schema")}return i})(i,t.state.schema);return e.preventDefault(),((t,e)=>{0!==e.length&&((t=>{if(1!==t.length)return!1;const e=t[0];return!(!e.isText||!e.text||""===e.text.trim())&&e.marks.some((t=>"link"===t.type.name))})(e)?((t,e)=>{const{state:r,dispatch:i}=t,{from:n,to:s}=r.selection,o=e.marks.find((t=>"link"===t.type.name)),l=r.doc.textBetween(n,s," ")||o.attrs.href;i(r.tr.insertText(l,n,s).addMark(n,n+l.length,o))})(t,e[0]):((t,e)=>{const{state:r,dispatch:i}=t,{from:n,to:s}=r.selection,o=Q.fromArray(e);i(r.tr.replaceWith(n,s,o))})(t,e))})(t,n),!0},Fa=t=>new dr({key:wa,props:{handlePaste:(t,e)=>xa(t,e),handleDOMEvents:{mousedown:(t,e)=>{if((e.metaKey||e.ctrlKey)&&0===e.button)return((t,e)=>{const r=va(t,e);if(!r.href)return!1;e.preventDefault();const{href:i}=r;return!!i&&(window.open(i,"_blank","noopener,noreferrer"),!0)})(t,e)},dblclick:(t,e)=>{if(e.button!==l.Right)return((t,e)=>{const r=va(t,e);if(!r)return!1;const{href:i,text:n,from:s,to:o}=r,l=t.state.tr.setSelection(Xe.create(t.state.doc,s,o));return t.dispatch(l),((t,e,r)=>{const i=new CustomEvent("open-editor-link-menu",{detail:{href:e,text:r},bubbles:!0,composed:!0});t.dom.dispatchEvent(i)})(t,i,n),!0})(t,e)},click:(t,e)=>{e.target instanceof HTMLElement&&e.target.closest("a")&&(e.preventDefault(),e.stopPropagation())}}},view:()=>({update:e=>{((t,e)=>{const{from:r,to:i}=t.state.selection;let n="",s="";t.state.doc.nodesBetween(r,i,((t,e)=>{if("text"!==t.type.name)return;const o=Math.max(0,r-e),l=Math.min(t.text.length,i-e);n+=t.text.slice(o,l),t.marks.forEach((t=>{"link"===t.type.name&&(s=t.attrs.href)}))})),e&&e(n,s)})(e,t)}})}),Ma={attrs:{href:{default:""},title:{default:null},target:{default:null},rel:{default:null},referrerpolicy:{default:null}},inclusive:!1,parseDOM:[{tag:"a[href]",getAttrs:t=>({href:t.getAttribute("href")||"",title:t.getAttribute("title"),target:t.getAttribute("target"),rel:t.getAttribute("rel"),referrerpolicy:t.getAttribute("referrerpolicy")})}],toDOM:t=>{const e=t.attrs.target||null,r={rel:"_blank"===e?"noopener noreferrer":null,referrerpolicy:"_blank"===e?"noreferrer":null};return["a",Object.assign(Object.assign({},t.attrs),r),0]}},Aa=new gr("imageInserterPlugin"),Ca=(t,e,r)=>({fileInfo:r,insertThumbnail:Sa(t,e,r),insertImage:Oa(t,r),insertFailedThumbnail:$a(t,r)}),Sa=(t,e,r)=>()=>{const{state:i,dispatch:n}=t,{schema:s}=i,o=Ba(e,r,"loading"),l=s.nodes.image.create(o);n(i.tr.replaceSelectionWith(l))},Oa=(t,e)=>r=>{const{state:i,dispatch:n}=t,{schema:s}=i,o=i.tr;i.doc.descendants(((t,i)=>{if(t.attrs.fileInfoId===e.id){const n=Ba(null!=r?r:t.attrs.src,e,"success"),l=s.nodes.image.create(n);return o.replaceWith(i,i+t.nodeSize,l),!1}})),n(o)},$a=(t,e)=>()=>{const{state:r,dispatch:i}=t,{schema:n}=r,s=r.tr;r.doc.descendants(((t,r)=>{if(t.attrs.fileInfoId===e.id){const i=Ba(t.attrs.src,e,"failed"),o=n.nodes.image.create(i);return s.replaceWith(r,r+t.nodeSize,o),!1}})),i(s)};function Ba(t,e,r){return{src:t,alt:e.filename,fileInfoId:e.id,state:r}}const Ra=t=>{if(t instanceof Et){if("image"===t.type.name)return!0;let e=!1;return t.content.forEach((t=>{Ra(t)&&(e=!0)})),e}if(t instanceof Q){let e=!1;return t.forEach((t=>{Ra(t)&&(e=!0)})),e}return!1},Na=t=>{const e=[];return t.forEach((t=>{if(!Ra(t))if(t.content.size>0){const r=Na(t.content),i=t.copy(r);e.push(i)}else e.push(t)})),Q.fromArray(e)};function _a(t,e){var r,i;if(!function(t){return!!(null==t?void 0:t.type)&&t.type.startsWith("image/")}(t))return!1;const n=null!==(i=null===(r=null==e?void 0:e.getData("text/html"))||void 0===r?void 0:r.toLowerCase())&&void 0!==i?i:"";return!function(t){return!!t&&(t.includes('name=generator content="microsoft excel"')||t.includes('xmlns:x="urn:schemas-microsoft-com:office:excel"'))}(n)&&!function(t){return!!t&&t.includes("<table")}(n)}class Ta{constructor(t,e,r,i){this.createResizeHandle=t=>{const e=document.createElement("div");return e.className=`resize-handle ${t}`,e.setAttribute("role","slider"),e.setAttribute("aria-label",A.get("editor-image-view.resize-handle",this.language)),e.setAttribute("tabindex","0"),e.setAttribute("aria-valuemin",10..toString()),e.setAttribute("aria-valuenow",this.img.offsetWidth.toString()),e.setAttribute("aria-valuetext",`${this.img.offsetWidth} pixels`),e.setAttribute("aria-grabbed","false"),e.addEventListener("pointerdown",(r=>{e.setAttribute("aria-grabbed","true"),this.onResizeStart(r,t)})),e},this.onResizeStart=(t,e)=>{t.preventDefault();const r=t.target,i=t.clientX,n=this.img.offsetWidth,s=t=>{const r=t.clientX-i,s=Math.max(10,n+("top-left"===e?-r:r));this.img.style.width=`${s}px`;const o=this.dom.querySelectorAll(".resize-handle");for(const t of o)t.setAttribute("aria-valuenow",s.toString()),t.setAttribute("aria-valuetext",`${s} pixels`)},o=()=>{window.removeEventListener("pointermove",s),window.removeEventListener("pointerup",o),r.setAttribute("aria-grabbed","false"),this.persistDimensions()};window.addEventListener("pointermove",s),window.addEventListener("pointerup",o)},this.createLoadingState=()=>{this.dom.setAttribute("aria-live","polite"),this.dom.setAttribute("aria-busy","true"),this.dom.setAttribute("aria-label",A.get("editor-image-view.loading",this.language,{filename:this.node.attrs.alt||"file"}));const t=document.createElement("limel-linear-progress");t.setAttribute("indeterminate","true"),this.dom.append(t)},this.createSuccessState=()=>{this.dom.setAttribute("aria-live","polite"),this.dom.setAttribute("aria-busy","false"),this.dom.setAttribute("aria-label",A.get("editor-image-view.success",this.language,{filename:this.node.attrs.alt||"file"}));const t=this.createResizeHandle("bottom-right"),e=this.createResizeHandle("top-left");this.dom.append(t),this.dom.append(e)},this.createFailedState=()=>{this.dom.setAttribute("aria-live","assertive"),this.dom.setAttribute("aria-busy","false"),this.dom.setAttribute("aria-label",A.get("editor-image-view.failed",this.language,{filename:this.node.attrs.alt||"file"}))},this.cleanUpPreviousState=()=>{for(const t of this.dom.childNodes)t instanceof HTMLImageElement||t.remove()},this.transitionBetweenStates=()=>{var t;this.cleanUpPreviousState(),this.dom.className=`image-wrapper state-${this.node.attrs.state}`;const e={loading:this.createLoadingState,success:this.createSuccessState,failed:this.createFailedState};null===(t=e[this.node.attrs.state])||void 0===t||t.call(e)},this.transitioningBetweenSuccessStates=t=>"success"===this.node.attrs.state&&"success"===t.attrs.state,this.node=t,this.view=e,this.getPos=r,this.language=i,this.dom=document.createElement("div"),this.dom.className=`image-wrapper state-${t.attrs.state}`,this.img=document.createElement("img"),this.img.src=t.attrs.src,this.img.alt=t.attrs.alt,aa(this.img,t),this.img.addEventListener("load",(()=>{this.persistDimensions()})),this.dom.append(this.img),this.transitionBetweenStates()}persistDimensions(){this.view.dispatch(this.view.state.tr.setNodeMarkup(this.getPos(),void 0,Object.assign(Object.assign({},this.node.attrs),{height:`${this.img.offsetHeight}px`,width:`${this.img.offsetWidth}px`,minHeight:`${this.img.offsetHeight}px`,minWidth:`${this.img.offsetWidth}px`})))}update(t){return this.transitioningBetweenSuccessStates(t)||(this.img.src=t.attrs.src,this.img.alt=t.attrs.alt,aa(this.img,t)),this.node=t,this.transitionBetweenStates(),!0}}const za=new gr("actionBarPlugin"),ja=new gr("actionBarInteractionPlugin"),qa=(t,e)=>{const{state:r}=e,i=r.selection;let n=r.tr;i.empty||n.setSelection(i),t(r,(t=>{n=t})),e.dispatch(n),e.focus()},Ia=t=>new dr({key:ja,props:{handleDOMEvents:{actionBarItemClick:(e,r)=>{r.preventDefault(),r.stopPropagation();const{value:i}=r.detail;try{const r=t.getCommand(i);qa(r,e)}catch(t){console.error(`Error executing command: ${t}`)}return!0},saveLinkMenu:(e,r)=>{r.preventDefault(),r.stopPropagation();const{type:i,link:n}=r.detail;if(i===s.Link)try{const r=t.getCommand(i,n);qa(r,e)}catch(t){console.error(`Error executing command: ${t}`)}return!0}}}}),Pa=t=>{const e={};for(const r of t.attributes)e[r]={};return{group:"inline",content:"(text* | inline*)",inline:!0,atom:!0,selectable:!0,attrs:e,toDOM:e=>[t.tagName,e.attrs],parseDOM:[{tag:`${t.tagName}[${t.attributes.map((t=>t)).join("][")}]`,getAttrs:e=>{const r={};return t.attributes.forEach((t=>r[t]=e.getAttribute(t))),r}}]}},La=(t,e,r,i)=>{const n=t.state.schema;return async s=>{const o=document.createElement("span");o.innerHTML=await e.parseAsHTML(s,n);const l=Ut.fromSchema(n).parse(o).content;i(t,r,l)}},Ja=(t,e,r)=>({insert:Ua(t,r),insertHtml:La(t,e,r.position,Ha),stopTrigger:()=>Va(t)}),Ua=(t,e)=>r=>{const i=t.state.schema;let n;try{n=Wa(r,i)}catch(t){return void console.error(t.message)}const s=i.text(" "),o=i.nodes.doc.create(null,[n,s]);Ha(t,e.position,o)},Va=t=>{const{state:e,dispatch:r}=t,i=e.tr;i.setMeta("stopTrigger",!0),r(i)},Ha=(t,e,r)=>{const i=t.state,n=t.dispatch,s=i.tr.replaceWith(e,i.selection.$from.pos,r);s.setMeta("stopTrigger",!0),n(s)},Wa=(t,e)=>{var r;if("string"==typeof t)return e.text(t);const i=t.node;if("string"==typeof i)return e.text(i);const n=Ga(i.tagName,e),s=(null!==(r=t.children)&&void 0!==r?r:[]).map((t=>Wa(t,e))).filter(Boolean);return n.create(i.attributes,s)},Ga=(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},Za=(t,e,r,i)=>({trigger:r.character,textEditor:Ja(t,e,r),value:i}),Ka=(t,e,r,i,n)=>{const s=new CustomEvent(t,{detail:Za(e,r,i,n),bubbles:!0,composed:!0});e.dom.dispatchEvent(s)},Ya=(t,e)=>{let r=null,i=null;const n=()=>{i=null},s=((t,e)=>(r,n,s,o)=>{if(!e.includes(o))return!1;const l=r.state.doc.textBetween(n-1,n,"");if(/\s/.test(l)||""===l){const e={character:o,position:n};(t=>{i=t})(e),Ka("triggerStart",r,t,e,o)}return!1})(e,t),o=((t,e,r,i)=>(n,s,o)=>{const l=e();if(!l)return;const u=((t,e,r,i,n)=>{if(!e||e.position<1)return!1;for(const s of t.steps)if(s instanceof we){const{from:t,to:o,slice:l}=s;if(t<=e.position&&o>=e.position&&!l.content.textBetween(0,l.content.size,"").includes(e.character))return r(),Ka("triggerStop",n,i,e,""),!0}return!1})(n[0],l,r,i,t());u?r():((t,e,r,i,n)=>{let s="";r>e.position&&(s=t.textBetween(e.position+1,r,"")),Ka("triggerChange",n,i,e,s)})(o.doc,l,o.selection.from,i,t())})((()=>r),(()=>i),n,e);return new dr({key:new gr("triggerPlugin"),view:t=>(r=t,{}),state:{init:()=>({}),apply:t=>(t.getMeta("stopTrigger")&&(Ka("triggerStop",r,e,i,""),n()),{})},props:{handleTextInput:s},appendTransaction:o})};var Xa,Qa;if("undefined"!=typeof WeakMap){let t=new WeakMap;Xa=e=>t.get(e),Qa=(e,r)=>(t.set(e,r),r)}else{const t=[],e=10;let r=0;Xa=e=>{for(let r=0;r<t.length;r+=2)if(t[r]==e)return t[r+1]},Qa=(i,n)=>(r==e&&(r=0),t[r++]=i,t[r++]=n)}var tf=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,n=e/this.width|0;let s=i+1,o=n+1;for(let t=1;s<this.width&&this.map[e+t]==r;t++)s++;for(let t=1;o<this.height&&this.map[e+this.width*t]==r;t++)o++;return{left:i,top:n,right:s,bottom:o}}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:o}=this.findCell(t);return"horiz"==e?(r<0?0==i:n==this.width)?null:this.map[s*this.width+(r<0?i-1:n)]:(r<0?0==s:o==this.height)?null:this.map[i+this.width*(r<0?s-1:o)]}rectBetween(t,e){const{left:r,right:i,top:n,bottom:s}=this.findCell(t),{left:o,right:l,top:u,bottom:h}=this.findCell(e);return{left:Math.min(r,o),top:Math.min(n,u),right:Math.max(i,l),bottom:Math.max(s,h)}}cellsInRect(t){const e=[],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,o=this.map[s];r[o]||(r[o]=!0,n==t.left&&n&&this.map[s-1]==o||i==t.top&&i&&this.map[s-this.width]==o||e.push(o))}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;for(;r<i&&this.map[r]<n;)r++;return r==i?s-1:this.map[r]}n=s}}static get(t){return Xa(t)||Qa(t,function(t){if("table"!=t.type.spec.tableRole)throw new RangeError("Not a table node: "+t.type.name);const e=function(t){let e=-1,r=!1;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);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,e.attrs.rowspan>1&&(r=!0)}-1==e?e=s:e!=s&&(e=Math.max(e,s))}return e}(t),r=t.childCount,i=[];let n=0,s=null;const o=[];for(let t=0,n=e*r;t<n;t++)i[t]=0;for(let l=0,u=0;l<r;l++){const h=t.child(l);u++;for(let t=0;;t++){for(;n<i.length&&0!=i[n];)n++;if(t==h.childCount)break;const a=h.child(t),{colspan:f,rowspan:c,colwidth:d}=a.attrs;for(let t=0;t<c;t++){if(t+l>=r){(s||(s=[])).push({type:"overlong_rowspan",pos:u,n:c-t});break}const h=n+t*e;for(let t=0;t<f;t++){0==i[h+t]?i[h+t]=u:(s||(s=[])).push({type:"collision",row:l,pos:u,n:f-t});const r=d&&d[t];if(r){const i=(h+t)%e*2,n=o[i];null==n||n!=r&&1==o[i+1]?(o[i]=r,o[i+1]=1):n==r&&o[i+1]++}}}n+=f,u+=a.nodeSize}const a=(l+1)*e;let f=0;for(;n<a;)0==i[n++]&&f++;f&&(s||(s=[])).push({type:"missing",row:l,n:f}),u++}0!==e&&0!==r||(s||(s=[])).push({type:"zero_sized"});const l=new tf(e,r,i,s);let u=!1;for(let t=0;!u&&t<o.length;t+=2)null!=o[t]&&o[t+1]<r&&(u=!0);return u&&function(t,e,r){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]=!0;const o=r.nodeAt(s);if(!o)throw new RangeError(`No cell with offset ${s} found`);let l=null;const u=o.attrs;for(let r=0;r<u.colspan;r++){const i=e[(n+r)%t.width*2];null==i||u.colwidth&&u.colwidth[r]==i||((l||(l=ef(u)))[r]=i)}l&&t.problems.unshift({type:"colwidth mismatch",pos:s,colwidth:l})}}(l,o,t),l}(t))}};function ef(t){if(t.colwidth)return t.colwidth.slice();const e=[];for(let r=0;r<t.colspan;r++)e.push(0);return e}function rf(t,e){if("string"==typeof t)return{};const r=t.getAttribute("data-colwidth"),i=r&&/^\d+(,\d+)*$/.test(r)?r.split(",").map((t=>Number(t))):null,n=Number(t.getAttribute("colspan")||1),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,n=i&&i(t);null!=n&&(s[r]=n)}return s}function nf(t,e){const r={};1!=t.attrs.colspan&&(r.colspan=t.attrs.colspan),1!=t.attrs.rowspan&&(r.rowspan=t.attrs.rowspan),t.attrs.colwidth&&(r["data-colwidth"]=t.attrs.colwidth.join(","));for(const i in e){const n=e[i].setDOMAttr;n&&n(t.attrs[i],r)}return r}function sf(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;n&&(e[n]=i)}}return e}var of=new gr("selectingCells");function lf(t){for(let e=t.depth-1;e>0;e--)if("row"==t.node(e).type.spec.tableRole)return t.node(0).resolve(t.before(e+1));return null}function uf(t){return"row"==t.parent.type.spec.tableRole&&!!t.nodeAfter}function hf(t,e){return t.depth==e.depth&&t.pos>=e.start(-1)&&t.pos<=e.end(-1)}function af(t,e,r){const i=t.node(-1),n=tf.get(i),s=t.start(-1),o=n.nextCell(t.pos-s,e,r);return null==o?null:t.node(0).resolve(s+o)}function ff(t,e,r=1){const i={...t,colspan:t.colspan-r};return i.colwidth&&(i.colwidth=i.colwidth.slice(),i.colwidth.splice(e,r),i.colwidth.some((t=>t>0))||(i.colwidth=null)),i}var cf=class t extends Ge{constructor(t,e=t){const r=t.node(-1),i=tf.get(r),n=t.start(-1),s=i.rectBetween(t.pos-n,e.pos-n),o=t.node(0),l=i.cellsInRect(s).filter((t=>t!=e.pos-n));l.unshift(e.pos-n);const u=l.map((t=>{const e=r.nodeAt(t);if(!e)throw RangeError(`No cell with offset ${t} found`);const i=n+t+1;return new Ze(o.resolve(i),o.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)),n=e.resolve(r.map(this.$headCell.pos));if(uf(i)&&uf(n)&&hf(i,n)){const e=this.$anchorCell.node(-1)!=i.node(-1);return e&&this.isRowSelection()?t.rowSelection(i,n):e&&this.isColSelection()?t.colSelection(i,n):new t(i,n)}return Xe.between(i,n)}content(){const t=this.$anchorCell.node(-1),e=tf.get(t),r=this.$anchorCell.start(-1),i=e.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),n={},s=[];for(let r=i.top;r<i.bottom;r++){const o=[];for(let s=r*e.width+i.left,l=i.left;l<i.right;l++,s++){const r=e.map[s];if(n[r])continue;n[r]=!0;const l=e.findCell(r);let u=t.nodeAt(r);if(!u)throw RangeError(`No cell with offset ${r} found`);const h=i.left-l.left,a=l.right-i.right;if(h>0||a>0){let t=u.attrs;if(h>0&&(t=ff(t,0,h)),a>0&&(t=ff(t,t.colspan-a,a)),l.left<i.left){if(u=u.type.createAndFill(t),!u)throw RangeError(`Could not create cell with attrs ${JSON.stringify(t)}`)}else u=u.type.create(t,u.content)}if(l.top<i.top||l.bottom>i.bottom){const t={...u.attrs,rowspan:Math.min(l.bottom,i.bottom)-Math.max(l.top,i.top)};u=l.top<i.top?u.type.createAndFill(t):u.type.create(t,u.content)}o.push(u)}s.push(t.child(r).copy(Q.from(o)))}const o=this.isColSelection()&&this.isRowSelection()?t:s;return new st(Q.from(o),1,1)}replace(t,e=st.empty){const r=t.steps.length,i=this.ranges;for(let n=0;n<i.length;n++){const{$from:s,$to:o}=i[n],l=t.mapping.slice(r);t.replace(l.map(s.pos),l.map(o.pos),n?st.empty:e)}const n=Ge.findFrom(t.doc.resolve(t.mapping.slice(r).map(this.to)),-1);n&&t.setSelection(n)}replaceWith(t,e){this.replace(t,new st(Q.from(e),0,0))}forEachCell(t){const e=this.$anchorCell.node(-1),r=tf.get(e),i=this.$anchorCell.start(-1),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),e=this.$headCell.index(-1);return!(Math.min(t,e)>0)&&Math.max(t+this.$anchorCell.nodeAfter.attrs.rowspan,e+this.$headCell.nodeAfter.attrs.rowspan)==this.$headCell.node(-1).childCount}static colSelection(e,r=e){const i=e.node(-1),n=tf.get(i),s=e.start(-1),o=n.findCell(e.pos-s),l=n.findCell(r.pos-s),u=e.node(0);return o.top<=l.top?(o.top>0&&(e=u.resolve(s+n.map[o.left])),l.bottom<n.height&&(r=u.resolve(s+n.map[n.width*(n.height-1)+l.right-1]))):(l.top>0&&(r=u.resolve(s+n.map[l.left])),o.bottom<n.height&&(e=u.resolve(s+n.map[n.width*(n.height-1)+o.right-1]))),new t(e,r)}isRowSelection(){const t=this.$anchorCell.node(-1),e=tf.get(t),r=this.$anchorCell.start(-1),i=e.colCount(this.$anchorCell.pos-r),n=e.colCount(this.$headCell.pos-r);return!(Math.min(i,n)>0)&&Math.max(i+this.$anchorCell.nodeAfter.attrs.colspan,n+this.$headCell.nodeAfter.attrs.colspan)==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),n=tf.get(i),s=e.start(-1),o=n.findCell(e.pos-s),l=n.findCell(r.pos-s),u=e.node(0);return o.left<=l.left?(o.left>0&&(e=u.resolve(s+n.map[o.top*n.width])),l.right<n.width&&(r=u.resolve(s+n.map[n.width*(l.top+1)-1]))):(l.left>0&&(r=u.resolve(s+n.map[l.top*n.width])),o.right<n.width&&(e=u.resolve(s+n.map[n.width*(o.top+1)-1]))),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 df(this.$anchorCell.pos,this.$headCell.pos)}};cf.prototype.visible=!1,Ge.jsonID("cell",cf);var df=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);return"row"==e.parent.type.spec.tableRole&&"row"==r.parent.type.spec.tableRole&&e.index()<e.parent.childCount&&r.index()<r.parent.childCount&&hf(e,r)?new cf(e,r):Ge.near(r,1)}};function pf(t){if(!(t.selection instanceof cf))return null;const e=[];return t.selection.forEachCell(((t,r)=>{e.push(Zn.node(r,r+t.nodeSize,{class:"selectedCell"}))})),Xn.create(t.doc,e)}var mf=new gr("fix-tables");function gf(t,e,r,i){const n=t.childCount,s=e.childCount;t:for(let o=0,l=0;o<s;o++){const s=e.child(o);for(let e=l,i=Math.min(n,o+3);e<i;e++)if(t.child(e)==s){l=e+1,r+=s.nodeSize;continue t}i(s,r),l<n&&t.child(l).sameMarkup(s)?gf(t.child(l),s,r+1,i):s.nodesBetween(0,s.content.size,i,r+1),r+=s.nodeSize}}function bf(t,e){let r;const i=(e,i)=>{"table"==e.type.spec.tableRole&&(r=function(t,e,r,i){const n=tf.get(e);if(!n.problems)return i;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 o=n.problems[t];if("collision"==o.type){const t=e.nodeAt(o.pos);if(!t)continue;const n=t.attrs;for(let t=0;t<n.rowspan;t++)s[o.row+t]+=o.n;i.setNodeMarkup(i.mapping.map(r+1+o.pos),null,ff(n,n.colspan-o.n,o.n))}else if("missing"==o.type)s[o.row]+=o.n;else if("overlong_rowspan"==o.type){const t=e.nodeAt(o.pos);if(!t)continue;i.setNodeMarkup(i.mapping.map(r+1+o.pos),null,{...t.attrs,rowspan:t.attrs.rowspan-o.n})}else if("colwidth mismatch"==o.type){const t=e.nodeAt(o.pos);if(!t)continue;i.setNodeMarkup(i.mapping.map(r+1+o.pos),null,{...t.attrs,colwidth:o.colwidth})}else if("zero_sized"==o.type){const t=i.mapping.map(r);i.delete(t,t+e.nodeSize)}}let o,l;for(let t=0;t<s.length;t++)s[t]&&(null==o&&(o=t),l=t);for(let u=0,h=r+1;u<n.height;u++){const r=e.child(u),n=h+r.nodeSize,a=s[u];if(a>0){let e="cell";r.firstChild&&(e=r.firstChild.type.spec.tableRole);const s=[];for(let r=0;r<a;r++){const r=sf(t.schema)[e].createAndFill();r&&s.push(r)}i.insert(i.mapping.map(0!=u&&o!=u-1||l!=u?n-1:h+1),s)}h=n}return i.setMeta(mf,{fixTables:!0})}(t,e,i,r))};return e?e.doc!=t.doc&&gf(e.doc,t.doc,0,i):t.doc.descendants(i),r}function wf(t,e){const r=t.selection;if(!(r instanceof cf))return!1;if(e){const i=t.tr,n=sf(t.schema).cell.createAndFill().content;r.forEachCell(((t,e)=>{t.content.eq(n)||i.replace(i.mapping.map(e+1),i.mapping.map(e+t.nodeSize-1),new st(n,0,0))})),i.docChanged&&e(i)}return!0}function vf(t,e){const r=t.createAndFill();return new He(r).replace(0,r.content.size,e).doc}function kf(t,e,r,i,n,s,o,l){if(0==o||o==e.height)return!1;let u=!1;for(let h=n;h<s;h++){const n=o*e.width+h,s=e.map[n];if(e.map[n-e.width]==s){u=!0;const n=r.nodeAt(s),{top:a,left:f}=e.findCell(s);t.setNodeMarkup(t.mapping.slice(l).map(s+i),null,{...n.attrs,rowspan:o-a}),t.insert(t.mapping.slice(l).map(e.positionAt(o,f,r)),n.type.createAndFill({...n.attrs,rowspan:a+n.attrs.rowspan-o})),h+=n.attrs.colspan-1}}return u}function Df(t,e,r,i,n,s,o,l){if(0==o||o==e.width)return!1;let u=!1;for(let h=n;h<s;h++){const n=h*e.width+o,s=e.map[n];if(e.map[n-1]==s){u=!0;const n=r.nodeAt(s),a=e.colCount(s),f=t.mapping.slice(l).map(s+i);t.setNodeMarkup(f,null,ff(n.attrs,o-a,n.attrs.colspan-(o-a))),t.insert(f+n.nodeSize,n.type.createAndFill(ff(n.attrs,0,o-a))),h+=n.attrs.rowspan-1}}return u}function yf(t,e,r,i,n){let s=r?t.doc.nodeAt(r-1):t.doc;if(!s)throw new Error("No table found");let o=tf.get(s);const{top:l,left:u}=i,h=u+n.width,a=l+n.height,f=t.tr;let c=0;function d(){if(s=r?f.doc.nodeAt(r-1):f.doc,!s)throw new Error("No table found");o=tf.get(s),c=f.mapping.maps.length}(function(t,e,r,i,n,s,o){const l=sf(t.doc.type.schema);let u,h;if(n>e.width)for(let s=0,a=0;s<e.height;s++){const f=r.child(s);a+=f.nodeSize;const c=[];let d;d=null==f.lastChild||f.lastChild.type==l.cell?u||(u=l.cell.createAndFill()):h||(h=l.header_cell.createAndFill());for(let t=e.width;t<n;t++)c.push(d);t.insert(t.mapping.slice(o).map(a-1+i),c)}if(s>e.height){const a=[];for(let t=0,i=(e.height-1)*e.width;t<Math.max(e.width,n);t++){const n=!(t>=e.width)&&r.nodeAt(e.map[i+t]).type==l.header_cell;a.push(n?h||(h=l.header_cell.createAndFill()):u||(u=l.cell.createAndFill()))}const f=l.row.create(null,Q.from(a)),c=[];for(let t=e.height;t<s;t++)c.push(f);t.insert(t.mapping.slice(o).map(i+r.nodeSize-2),c)}return!(!u&&!h)})(f,o,s,r,h,a,c)&&d(),kf(f,o,s,r,u,h,l,c)&&d(),kf(f,o,s,r,u,h,a,c)&&d(),Df(f,o,s,r,l,a,u,c)&&d(),Df(f,o,s,r,l,a,h,c)&&d();for(let t=l;t<a;t++){const e=o.positionAt(t,u,s),i=o.positionAt(t,h,s);f.replace(f.mapping.slice(c).map(e+r),f.mapping.slice(c).map(i+r),new st(n.rows[t-l],0,0))}d(),f.setSelection(new cf(f.doc.resolve(r+o.positionAt(l,u,s)),f.doc.resolve(r+o.positionAt(a-1,h-1,s)))),e(f)}var Ef=ro({ArrowLeft:Ff("horiz",-1),ArrowRight:Ff("horiz",1),ArrowUp:Ff("vert",-1),ArrowDown:Ff("vert",1),"Shift-ArrowLeft":Mf("horiz",-1),"Shift-ArrowRight":Mf("horiz",1),"Shift-ArrowUp":Mf("vert",-1),"Shift-ArrowDown":Mf("vert",1),Backspace:wf,"Mod-Backspace":wf,Delete:wf,"Mod-Delete":wf});function xf(t,e,r){return!r.eq(t.selection)&&(e&&e(t.tr.setSelection(r).scrollIntoView()),!0)}function Ff(t,e){return(r,i,n)=>{if(!n)return!1;const s=r.selection;if(s instanceof cf)return xf(r,i,Ge.near(s.$headCell,e));if("horiz"!=t&&!s.empty)return!1;const o=Of(n,t,e);if(null==o)return!1;if("horiz"==t)return xf(r,i,Ge.near(r.doc.resolve(s.head+e),e));{const n=r.doc.resolve(o),s=af(n,t,e);let l;return l=s?Ge.near(s,1):e<0?Ge.near(r.doc.resolve(n.before(-1)),-1):Ge.near(r.doc.resolve(n.after(-1)),1),xf(r,i,l)}}}function Mf(t,e){return(r,i,n)=>{if(!n)return!1;const s=r.selection;let o;if(s instanceof cf)o=s;else{const i=Of(n,t,e);if(null==i)return!1;o=new cf(r.doc.resolve(i))}const l=af(o.$headCell,t,e);return!!l&&xf(r,i,new cf(o.$anchorCell,l))}}function Af(t,e){const r=lf(t.state.doc.resolve(e));return!!r&&(t.dispatch(t.state.tr.setSelection(new cf(r))),!0)}function Cf(t,e,r){if(!function(t){const e=t.selection.$head;for(let t=e.depth;t>0;t--)if("row"==e.node(t).type.spec.tableRole)return!0;return!1}(t.state))return!1;let i=function(t){if(!t.size)return null;let{content:e,openStart:r,openEnd:i}=t;for(;1==e.childCount&&(r>0&&i>0||"table"==e.child(0).type.spec.tableRole);)r--,i--,e=e.child(0).content;const n=e.child(0),s=n.type.spec.tableRole,o=n.type.schema,l=[];if("row"==s)for(let t=0;t<e.childCount;t++){let n=e.child(t).content;const s=t?0:Math.max(0,r-1),u=t<e.childCount-1?0:Math.max(0,i-1);(s||u)&&(n=vf(sf(o).row,new st(n,s,u)).content),l.push(n)}else{if("cell"!=s&&"header_cell"!=s)return null;l.push(r||i?vf(sf(o).row,new st(e,r,i)).content:e)}return function(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(Q.empty),r[n]<i){const s=sf(t).cell.createAndFill(),o=[];for(let t=r[n];t<i;t++)o.push(s);e[n]=e[n].append(Q.from(o))}return{height:e.length,width:i,rows:e}}(o,l)}(r);const n=t.state.selection;if(n instanceof cf){i||(i={width:1,height:1,rows:[Q.from(vf(sf(t.state.schema).cell,r))]});const e=n.$anchorCell.node(-1),s=n.$anchorCell.start(-1),o=tf.get(e).rectBetween(n.$anchorCell.pos-s,n.$headCell.pos-s);return i=function({width:t,height:e,rows:r},i,n){if(t!=i){const e=[],n=[];for(let t=0;t<r.length;t++){const s=r[t],o=[];for(let r=e[t]||0,n=0;r<i;n++){let l=s.child(n%s.childCount);r+l.attrs.colspan>i&&(l=l.type.createChecked(ff(l.attrs,l.attrs.colspan,r+l.attrs.colspan-i),l.content)),o.push(l),r+=l.attrs.colspan;for(let r=1;r<l.attrs.rowspan;r++)e[t+r]=(e[t+r]||0)+l.attrs.colspan}n.push(Q.from(o))}r=n,t=i}if(e!=n){const t=[];for(let i=0,s=0;i<n;i++,s++){const o=[],l=r[s%e];for(let t=0;t<l.childCount;t++){let e=l.child(t);i+e.attrs.rowspan>n&&(e=e.type.create({...e.attrs,rowspan:Math.max(1,n-e.attrs.rowspan)},e.content)),o.push(e)}t.push(Q.from(o))}r=t,e=n}return{width:t,height:e,rows:r}}(i,o.right-o.left,o.bottom-o.top),yf(t.state,t.dispatch,s,o,i),!0}if(i){const e=function(t){const e=t.selection;if("$anchorCell"in e&&e.$anchorCell)return e.$anchorCell.pos>e.$headCell.pos?e.$anchorCell:e.$headCell;if("node"in e&&e.node&&"cell"==e.node.type.spec.tableRole)return e.$anchor;const r=lf(e.$head)||function(t){for(let e=t.nodeAfter,r=t.pos;e;e=e.firstChild,r++){const i=e.type.spec.tableRole;if("cell"==i||"header_cell"==i)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("cell"==i||"header_cell"==i)return t.doc.resolve(r-e.nodeSize)}}(e.$head);if(r)return r;throw new RangeError(`No cell found around position ${e.head}`)}(t.state),r=e.start(-1);return yf(t.state,t.dispatch,r,tf.get(e.node(-1)).findCell(e.pos-r),i),!0}return!1}function Sf(t,e){var r;if(e.ctrlKey||e.metaKey)return;const i=$f(t,e.target);let n;if(e.shiftKey&&t.state.selection instanceof cf)s(t.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&i&&null!=(n=lf(t.state.selection.$anchor))&&(null==(r=Bf(t,e))?void 0:r.pos)!=n.pos)s(n,e),e.preventDefault();else if(!i)return;function s(e,r){let i=Bf(t,r);const n=null==of.getState(t.state);if(!i||!hf(e,i)){if(!n)return;i=e}const s=new cf(e,i);if(n||!t.state.selection.eq(s)){const r=t.state.tr.setSelection(s);n&&r.setMeta(of,e.pos),t.dispatch(r)}}function o(){t.root.removeEventListener("mouseup",o),t.root.removeEventListener("dragstart",o),t.root.removeEventListener("mousemove",l),null!=of.getState(t.state)&&t.dispatch(t.state.tr.setMeta(of,-1))}function l(r){const n=r,l=of.getState(t.state);let u;if(null!=l)u=t.state.doc.resolve(l);else if($f(t,n.target)!=i&&(u=Bf(t,e),!u))return o();u&&s(u,n)}t.root.addEventListener("mouseup",o),t.root.addEventListener("dragstart",o),t.root.addEventListener("mousemove",l)}function Of(t,e,r){if(!(t.state.selection instanceof Xe))return null;const{$head:i}=t.state.selection;for(let n=i.depth-1;n>=0;n--){const s=i.node(n);if((r<0?i.index(n):i.indexAfter(n))!=(r<0?0:s.childCount))return null;if("cell"==s.type.spec.tableRole||"header_cell"==s.type.spec.tableRole){const s=i.before(n);return t.endOfTextblock("vert"==e?r>0?"down":"up":r>0?"right":"left")?s:null}}return null}function $f(t,e){for(;e&&e!=t.dom;e=e.parentNode)if("TD"==e.nodeName||"TH"==e.nodeName)return e;return null}function Bf(t,e){const r=t.posAtCoords({left:e.clientX,top:e.clientY});return r&&r?lf(t.state.doc.resolve(r.pos)):null}function Rf({allowTableNodeSelection:t=!1}={}){return new dr({key:of,state:{init:()=>null,apply(t,e){const r=t.getMeta(of);if(null!=r)return-1==r?null:r;if(null==e||!t.docChanged)return e;const{deleted:i,pos:n}=t.mapping.mapResult(e);return i?null:n}},props:{decorations:pf,handleDOMEvents:{mousedown:Sf},createSelectionBetween:t=>null!=of.getState(t.state)?t.state.selection:null,handleTripleClick:Af,handleKeyDown:Ef,handlePaste:Cf},appendTransaction:(e,r,i)=>function(t,e,r){const i=(e||t).selection,n=(e||t).doc;let s,o;if(i instanceof tr&&(o=i.node.type.spec.tableRole)){if("cell"==o||"header_cell"==o)s=cf.create(n,i.from);else if("row"==o){const t=n.resolve(i.from+1);s=cf.rowSelection(t,t)}else if(!r){const t=tf.get(i.node),e=i.from+1;s=cf.create(n,e+1,e+t.map[t.width*t.height-1])}}else i instanceof Xe&&function({$from:t,$to:e}){if(t.pos==e.pos||t.pos<e.pos-6)return!1;let r=t.pos,i=e.pos,n=t.depth;for(;n>=0&&!(t.after(n+1)<t.end(n));n--,r++);for(let t=e.depth;t>=0&&!(e.before(t+1)>e.start(t));t--,i--);return r==i&&/row|table/.test(t.node(n).type.spec.tableRole)}(i)?s=Xe.create(n,i.from):i instanceof Xe&&function({$from:t,$to:e}){let r,i;for(let e=t.depth;e>0;e--){const i=t.node(e);if("cell"===i.type.spec.tableRole||"header_cell"===i.type.spec.tableRole){r=i;break}}for(let t=e.depth;t>0;t--){const r=e.node(t);if("cell"===r.type.spec.tableRole||"header_cell"===r.type.spec.tableRole){i=r;break}}return r!==i&&0===e.parentOffset}(i)&&(s=Xe.create(n,i.$from.start(),i.$from.end()));return s&&(e||(e=t.tr)).setSelection(s),e}(i,bf(i,r),t)})}new gr("tableColumnResizing");const Nf=t=>({default:null,getFromDOM:e=>e.style[t]||null,setDOMAttr:(e,r)=>{e&&(r.style=(r.style||"")+`${t}: ${e};`)}});function _f(t){const e={images:[],links:[]};return t.descendants((t=>{if(function(t){return"image"===t.type.name&&!!t.attrs}(t))e.images.push(function(t){return{src:t.attrs.src,state:t.attrs.state,fileInfoId:t.attrs.fileInfoId}}(t));else if(function(t){var e;return t.isText&&(null===(e=t.marks)||void 0===e?void 0:e.length)>0}(t))for(const r of function(t){return t.marks.filter((t=>"link"===t.type.name&&t.attrs)).map((e=>({href:e.attrs.href,text:t.text})))}(t))e.links.push(r);return!0})),e}function Tf(t){const e=new Map;for(const r of t){const t=`${r.fileInfoId}|${r.state}|${r.src}`;e.set(t,(e.get(t)||0)+1)}return e}function zf(t){const e=new Map;for(const r of t){const t=`${r.href}|${r.text}`;e.set(t,(e.get(t)||0)+1)}return e}function jf(t,e){if(t.size!==e.size)return!1;for(const[r,i]of t.entries())if(e.get(r)!==i)return!1;return!0}const qf=class{constructor(r){t(this,r),this.change=e(this,"change"),this.imagePasted=e(this,"imagePasted"),this.imageRemoved=e(this,"imageRemoved"),this.metadataChange=e(this,"metadataChange"),this.contentType="markdown",this.disabled=!1,this.customElements=[],this.triggerCharacters=[],this.ui="standard",this.actionBarItems=[],this.link={href:"https://"},this.isLinkMenuOpen=!1,this.changeWaiting=!1,this.transactionFired=!1,this.lastClickedPos=null,this.metadata={images:[],links:[]},this.suppressChangeEvent=!1,this.getActionBarItems=()=>{this.actionBarItems=Fl().map(this.getTranslatedItem)},this.getTranslatedItem=t=>{const e=Z(t);if(S(t)){const r=Ml[t.value];r&&(e.text=A.get(r,this.language))}return e},this.updateActiveActionBarItems=(t,e)=>{const r=Fl().map((r=>S(r)?Object.assign(Object.assign({},r),{selected:t[r.value],allowed:e[r.value]}):r));this.actionBarItems=r.filter((t=>!S(t)||t.allowed))},this.handleTransaction=t=>{this.transactionFired=!0;const e=this.view.state.apply(t);if(this.view.updateState(e),this.suppressChangeEvent||t.getMeta("pointer"))return;const r=this.contentConverter.serialize(this.view,this.schema);if(r===this.lastEmittedValue)return;const i=_f(e.doc);this.metadataEmitter(i),this.lastEmittedValue=r,this.changeWaiting=!0,this.changeEmitter(r)},this.handleActionBarItem=t=>{t.preventDefault(),t.stopImmediatePropagation();const{value:e}=t.detail;if(e===s.Link)return void(this.isLinkMenuOpen=!0);const r=new CustomEvent("actionBarItemClick",{detail:t.detail});this.view.dom.dispatchEvent(r)},this.handleCancelLinkMenu=t=>{t.preventDefault(),t.stopPropagation(),this.isLinkMenuOpen=!1,this.link={text:"",href:"https://"}},this.handleSaveLinkMenu=()=>{this.isLinkMenuOpen=!1;const t=new CustomEvent("saveLinkMenu",{detail:{type:s.Link,link:this.link}});this.view.dom.dispatchEvent(t),this.link={href:"https://"}},this.handleLinkChange=t=>{this.link=t.detail},this.handleFocus=()=>{var t;this.disabled||(null===(t=this.view)||void 0===t||t.focus(),this.transactionFired=!1,setTimeout((()=>{if(!this.transactionFired&&this.lastClickedPos){const{doc:t,tr:e}=this.view.state,r=t.resolve(this.lastClickedPos),i=Ge.near(r);e.setMeta("pointer",!0),this.view.dispatch(e.setSelection(i))}}),0))},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=!0},this.handleMouseDown=t=>{var e;const r=this.view.posAtCoords({left:t.clientX,top:t.clientY});this.lastClickedPos=null!==(e=null==r?void 0:r.pos)&&void 0!==e?e:null},this.changeEmitter=B((t=>{this.change.emit(t),this.changeWaiting=!1}),300),this.handleBlur=()=>{this.changeEmitter.flush()},this.portalId=C()}watchValue(t){this.view&&(this.changeWaiting||t!==this.contentConverter.serialize(this.view,this.schema)&&this.updateView(t))}componentWillLoad(){this.getActionBarItems(),this.setupContentConverter()}componentDidLoad(){setTimeout((()=>{this.initializeTextEditor()}),0)}connectedCallback(){this.view&&this.initializeTextEditor(),this.host.addEventListener("open-editor-link-menu",this.handleOpenLinkMenu)}disconnectedCallback(){var t,e,r,i,n;ha.clear(),this.host.removeEventListener("open-editor-link-menu",this.handleOpenLinkMenu),null===(e=null===(t=this.view)||void 0===t?void 0:t.dom)||void 0===e||e.removeEventListener("blur",this.handleBlur),null===(i=null===(r=this.view)||void 0===r?void 0:r.dom)||void 0===i||i.removeEventListener("mousedown",this.handleMouseDown),null===(n=this.view)||void 0===n||n.destroy()}render(){return r(i,{key:"1d27dcbd164b5ad8bfb0f84a515b0898b82f8065",onFocus:this.handleFocus},r("div",{key:"622f4a64560e1bb1f6f7b99aaf8473b7234ea026",id:"editor"}),this.renderToolbar(),this.renderLinkMenu())}renderToolbar(){if(0!==this.actionBarItems.length&&"no-toolbar"!==this.ui)return r("div",{class:"toolbar"},r("limel-action-bar",{ref:t=>this.actionBarElement=t,accessibleLabel:"Toolbar",actions:this.actionBarItems,onItemSelected:this.handleActionBarItem}))}renderLinkMenu(){if(this.isLinkMenuOpen)return r("limel-portal",{containerId:this.portalId,visible:this.isLinkMenuOpen,openDirection:"top",inheritParentWidth:!0,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("markdown"===this.contentType)this.contentConverter=new ma(this.customElements,this.language);else{if("html"!==this.contentType)throw new Error(`Unsupported content type: ${this.contentType}. Only 'markdown' and 'html' are supported.`);this.contentConverter=new ga(this.customElements)}}async initializeTextEditor(){this.schema=this.initializeSchema();const t=await this.parseInitialContent();this.menuCommandFactory=new Dl(this.schema),this.view=new Es(this.host.shadowRoot.querySelector("#editor"),{state:this.createEditorState(t),dispatchTransaction:this.handleTransaction}),this.view.dom.addEventListener("blur",this.handleBlur),this.view.dom.addEventListener("mousedown",this.handleMouseDown),this.value&&this.updateView(this.value),this.lastEmittedValue=this.contentConverter.serialize(this.view,this.schema)}initializeSchema(){let t=zs.spec.nodes;for(const e of this.customElements){const r=Pa(e),i=e.tagName;t=t.append({[i]:r})}return t=function(t,e,r){return t.append({ordered_list:Us(Ps,{content:"list_item+",group:r}),bullet_list:Us(Ls,{content:"list_item+",group:r}),list_item:Us(Js,{content:"paragraph block*"})})}(t,0,"block"),"html"===this.contentType&&(t=t.append(function(t){const e=t.cellAttributes||{},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:!0,group:t.tableGroup,parseDOM:[{tag:"table"}],toDOM:()=>["table",["tbody",0]]},table_row:{content:"(table_cell | table_header)*",tableRole:"row",parseDOM:[{tag:"tr"}],toDOM:()=>["tr",0]},table_cell:{content:t.cellContent,attrs:r,tableRole:"cell",isolating:!0,parseDOM:[{tag:"td",getAttrs:t=>rf(t,e)}],toDOM:t=>["td",nf(t,e),0]},table_header:{content:t.cellContent,attrs:r,tableRole:"header_cell",isolating:!0,parseDOM:[{tag:"th",getAttrs:t=>rf(t,e)}],toDOM:t=>["th",nf(t,e),0]}}}({tableGroup:"block",cellContent:"block+",cellAttributes:{background:Nf("background-color"),color:Nf("color")}}))),t=t.append({image:(e=this.language,{group:"inline",inline:!0,attrs:{src:{default:""},alt:{default:""},fileInfoId:{default:""},height:{default:""},width:{default:""},minHeight:{default:""},minWidth:{default:""},maxWidth:{default:"100%"},state:{default:"success"}},toDOM:t=>{if(da(t.attrs.state))return"success"===t.attrs.state?function(t,e){let r=ha.get(t);return r?function(t,e){t.alt=e.attrs.alt,aa(t,e)}(r,e):(r=function(t){const e=document.createElement("img");return e.src=t.attrs.src,e.alt=t.attrs.alt,aa(e,t),e}(e),ha.set(t,r)),r}(t.attrs.fileInfoId,t):function(t,e,r){return function(t,e,r){const i=A.get(`editor-image-view.${t}`,r,{filename:e.attrs.alt||"file"}),n=document.createElement("span");return n.textContent=i,n}("failed"===t?"failed":"loading",e,r)}(t.attrs.state,t,e)},parseDOM:[{tag:"img",getAttrs:t=>({src:t.getAttribute("src")||"",alt:t.getAttribute("alt")||"file",width:t.style.width||"",maxWidth:"100%",state:"success",fileInfoId:crypto.randomUUID()})}]})}),new Lt({nodes:t,marks:zs.spec.marks.append({strikethrough:ba,link:Ma})});var e}async parseInitialContent(){const t=document.createElement("div");return t.innerHTML=this.value?await this.contentConverter.parseAsHTML(this.value,this.schema):"<p></p>",Ut.fromSchema(this.schema).parse(t)}createEditorState(t){return fr.create({doc:t,plugins:[...fl({schema:this.schema}),eo(this.menuCommandFactory.buildKeymap()),Ya(this.triggerCharacters,this.contentConverter),Fa(this.handleNewLinkSelection),(o=this.imagePasted.emit,new dr({key:Aa,props:{handlePaste:(t,e,r)=>((t,e,r)=>{const i=e.clipboardData;if(!i)return!1;const n=function(t,e){let r=!1;const i=[...e.files||[]];for(const n of i)if(_a(n,e)){r=!0;const e=new FileReader;e.onloadend=()=>{t.dom.dispatchEvent(new CustomEvent("imagePasted",{detail:Ca(t,e.result,O(n))}))},e.readAsDataURL(n)}return r}(t,i),s=new st(Na(r.content),r.openStart,r.openEnd);if(s.content.childCount<r.content.childCount){const{state:e,dispatch:r}=t;return r(e.tr.replaceSelection(s)),!0}return n})(t,e,r),handleDOMEvents:{imagePasted:(t,e)=>{o(e.detail)}}}})),(s=this.language,new dr({props:{nodeViews:{image:(t,e,r)=>new Ta(t,e,r,s)}}})),(r=u,i=this.menuCommandFactory,n=this.updateActiveActionBarItems,new dr({key:za,state:{init:()=>({active:{},allowed:{}}),apply:(t,e)=>{const r=t.getMeta(za);return null!=r?r:e}},view:()=>({update:t=>{const e=za.getState(t.state),s=((t,e,r)=>{var i,n,s;const o={},l={};for(const u of t){const t=e.getCommand(u);o[u]=!!(null===(i=null==t?void 0:t.active)||void 0===i?void 0:i.call(t,r.state))||!1,l[u]=!(null!==(s=null===(n=null==t?void 0:t.allowed)||void 0===n?void 0:n.call(t,r.state))&&void 0!==s&&!s)}return{active:o,allowed:l}})(r,i,t);if(!$(e,s)){const e=t.state.tr.setMeta(za,s);t.dispatch(e),n(s.active,s.allowed)}}})})),Ia(this.menuCommandFactory),...(e="html"===this.contentType,e?[Rf()]:[])]});var e,r,i,n,s,o}async updateView(t){this.suppressChangeEvent=!0;const e=await this.contentConverter.parseAsHTML(t,this.schema),r=Ut.fromSchema(this.view.state.schema),i=(new window.DOMParser).parseFromString(e,"text/html"),n=r.parse(i.body),s=this.view.state.tr;s.replaceWith(0,s.doc.content.size,n.content),this.view.dispatch(s);const o=_f(this.view.state.doc);this.metadataEmitter(o),this.suppressChangeEvent=!1}metadataEmitter(t){var e,r,i,n;(function(t,e){return t.images.length!==e.images.length||t.links.length!==e.links.length}(e=this.metadata,r=t)||(n=r.links,!jf(zf(e.links),zf(n)))||(i=r.images,!jf(Tf(e.images),Tf(i))))&&(this.removeImagesFromCache(this.metadata,t),this.metadata=t,this.metadataChange.emit(t))}removeImagesFromCache(t,e){const r=t.images.filter((t=>!e.images.some((e=>e.fileInfoId===t.fileInfoId))));for(const t of r)ha.delete(t.fileInfoId),this.imageRemoved.emit(t)}static get delegatesFocus(){return!0}get host(){return n(this)}static get watchers(){return{value:[{watchValue:0}]}}};qf.style='@charset "UTF-8";blockquote{position:relative;max-width:100%;margin:0.75rem 0;padding:0.5rem;border-left:0.25rem solid rgb(var(--contrast-500));background-color:rgb(var(--contrast-200))}blockquote:before,blockquote:after{position:absolute;line-height:0;font-size:2rem;opacity:0.4}blockquote:before{content:"“";left:-0.5rem;top:0.5rem}blockquote:after{content:"”";right:-0.25rem;bottom:-0.25rem}blockquote blockquote{padding-top:0;padding-right:0;padding-bottom:0;padding-left:0.25rem;border-color:rgb(var(--contrast-700));border-left-width:1px}blockquote blockquote:before,blockquote blockquote:after{display:none}blockquote:has(>blockquote){padding-left:0.25rem;padding-bottom:0}:host(limel-markdown.truncate-paragraphs) p{overflow:hidden;white-space:nowrap;text-overflow:ellipsis}p,li{font-size:var(--limel-theme-default-font-size);word-break:break-word}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:var(--limel-theme-default-font-size);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:var(--limel-theme-default-font-size)}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:var(--limel-theme-default-small-font-size);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:var(--limel-theme-default-font-size)}: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}.image-wrapper{display:inline-flex;position:relative}.image-wrapper limel-linear-progress{position:absolute;inset:0.25rem auto auto 0.25rem;width:calc(100% - 0.5rem)}.image-wrapper img{transition:opacity 0.2s ease, scale 0.6s ease}.image-wrapper.state-failed,.image-wrapper.state-loading{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns=\'http://www.w3.org/2000/svg\'%20viewBox=\'0%200%208%208\'%20style=\'fill-rule:evenodd;\'%3E%3Cpath%20fill=\'rgba(186,186,192,0.16)\'%20d=\'M0%200h4v4H0zM4%204h4v4H4z\'/%3E%3C/svg%3E");background-size:0.5rem}.image-wrapper.state-failed img,.image-wrapper.state-loading img{opacity:0.3;scale:0.98}.image-wrapper::before{pointer-events:none;content:"";display:block;position:absolute;inset:0;border-radius:0.25rem;transition:border-color 0.4s ease, opacity 0.2s ease, box-shadow 0.6s ease;border:1px dashed transparent;opacity:0.2}.image-wrapper.state-failed img{filter:grayscale(0.8)}.image-wrapper.state-failed:before{opacity:0.8;box-shadow:var(--shadow-error-state)}.image-wrapper:hover::before{opacity:0.8;box-shadow:var(--shadow-depth-8)}.image-wrapper:has(.resize-handle[aria-grabbed=true])::before{border-color:var(--lime-primary-color, var(--limel-theme-primary-color));opacity:0.8;box-shadow:var(--shadow-depth-16), var(--shadow-depth-8)}.resize-handle{transition:color var(--limel-clickable-transition-speed, 0.4s) ease, background-color var(--limel-clickable-transition-speed, 0.4s) ease, box-shadow var(--limel-clickable-transform-speed, 0.4s) ease, transform var(--limel-clickable-transform-speed, 0.4s) var(--limel-clickable-transform-timing-function, ease);cursor:pointer;color:var(--limel-theme-on-surface-color);background-color:rgb(var(--contrast-900));box-shadow:var(--button-shadow-normal)}.resize-handle:hover,.resize-handle:focus,.resize-handle:focus-visible{will-change:color, background-color, box-shadow, transform}.resize-handle:hover,.resize-handle:focus-visible{transform:translate3d(0, -0.04rem, 0);color:var(--limel-theme-on-surface-color);background-color:var(--lime-elevated-surface-background-color);box-shadow:var(--button-shadow-hovered)}.resize-handle:active{--limel-clickable-transform-timing-function:cubic-bezier( 0.83, -0.15, 0.49, 1.16 );transform:translate3d(0, 0.05rem, 0);box-shadow:var(--button-shadow-pressed)}.resize-handle:hover,.resize-handle:active{--limel-clickable-transition-speed:0.2s;--limel-clickable-transform-speed:0.16s}.resize-handle:focus{outline:none}.resize-handle:focus-visible{outline:none;box-shadow:var(--shadow-depth-8-focused)}.resize-handle{cursor:nwse-resize;position:absolute;display:flex;align-items:center;justify-content:center;width:0.5rem;height:0.5rem;border-radius:50%}.resize-handle.top-left{left:-0.25rem;top:-0.25rem;translate:-50%, -50%}.resize-handle.bottom-right{right:-0.25rem;bottom:-0.25rem;translate:50%, 50%}.resize-handle{opacity:0.6}.resize-wrapper:has(.resize-handle[aria-grabbed=true]) .resize-handle,.resize-wrapper:hover .resize-handle,.resize-handle:hover,.resize-handle:focus-visible{opacity:1}.resize-handle[aria-grabbed=true],.resize-handle:hover,.resize-handle:focus-visible{opacity:1;background-color:var(--lime-primary-color, var(--limel-theme-primary-color))}.resize-handle:hover,.resize-handle[aria-grabbed=true]{scale:1.4}.resize-handle:hover:before,.resize-handle[aria-grabbed=true]:before{background-color:rgb(var(--color-white))}.resize-handle:before{content:"";display:block;position:absolute;inset:0;margin:auto;border-radius:50%;width:0.25rem;height:0.25rem;background-color:rgb(var(--contrast-100))}: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 *::selection{background:transparent}.ProseMirror-hideselection *::-moz-selection{background:transparent}.ProseMirror-hideselection{caret-color: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}';export{qf as limel_prosemirror_adapter}