@pod-os/elements 0.30.2-rc.a4eda69.0 → 0.30.2-rc.d44969f.0

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 (53) hide show
  1. package/dist/cjs/elements.cjs.js +1 -1
  2. package/dist/cjs/loader.cjs.js +1 -1
  3. package/dist/cjs/pos-document.cjs.entry.js +9 -6
  4. package/dist/cjs/pos-document.cjs.entry.js.map +1 -1
  5. package/dist/cjs/pos-markdown-document.cjs.entry.js +2046 -3685
  6. package/dist/cjs/pos-markdown-document.cjs.entry.js.map +1 -1
  7. package/dist/collection/components/pos-document/pos-document.js +10 -7
  8. package/dist/collection/components/pos-document/pos-document.js.map +1 -1
  9. package/dist/collection/components/pos-markdown-document/pos-markdown-document.css +17 -0
  10. package/dist/collection/components/pos-markdown-document/pos-markdown-document.js +19 -21
  11. package/dist/collection/components/pos-markdown-document/pos-markdown-document.js.map +1 -1
  12. package/dist/collection/components/pos-markdown-document/rich-editor/PosImageNode.js +25 -21
  13. package/dist/collection/components/pos-markdown-document/rich-editor/PosImageNode.js.map +1 -1
  14. package/dist/collection/components/pos-markdown-document/rich-editor/PosRichLinkMark.js +20 -16
  15. package/dist/collection/components/pos-markdown-document/rich-editor/PosRichLinkMark.js.map +1 -1
  16. package/dist/collection/components/pos-markdown-document/rich-editor/RichEditor.js +10 -24
  17. package/dist/collection/components/pos-markdown-document/rich-editor/RichEditor.js.map +1 -1
  18. package/dist/components/pos-document2.js +10 -7
  19. package/dist/components/pos-document2.js.map +1 -1
  20. package/dist/components/pos-markdown-document2.js +2048 -3687
  21. package/dist/components/pos-markdown-document2.js.map +1 -1
  22. package/dist/elements/elements.esm.js +1 -1
  23. package/dist/elements/elements.esm.js.map +1 -1
  24. package/dist/elements/p-08f92489.entry.js +2 -0
  25. package/dist/elements/p-08f92489.entry.js.map +1 -0
  26. package/dist/elements/p-4f8297e8.entry.js +2 -0
  27. package/dist/elements/p-4f8297e8.entry.js.map +1 -0
  28. package/dist/esm/elements.js +1 -1
  29. package/dist/esm/loader.js +1 -1
  30. package/dist/esm/pos-document.entry.js +9 -6
  31. package/dist/esm/pos-document.entry.js.map +1 -1
  32. package/dist/esm/pos-markdown-document.entry.js +2046 -3685
  33. package/dist/esm/pos-markdown-document.entry.js.map +1 -1
  34. package/dist/types/components/pos-document/pos-document.d.ts +1 -1
  35. package/dist/types/components/pos-markdown-document/pos-markdown-document.d.ts +3 -3
  36. package/dist/types/components/pos-markdown-document/rich-editor/PosImageNode.d.ts +2 -0
  37. package/dist/types/components/pos-markdown-document/rich-editor/PosRichLinkMark.d.ts +2 -0
  38. package/dist/types/components/pos-markdown-document/rich-editor/RichEditor.d.ts +1 -9
  39. package/dist/types/components.d.ts +4 -4
  40. package/package.json +3 -5
  41. package/dist/collection/components/pos-markdown-document/html2markdown.js +0 -10
  42. package/dist/collection/components/pos-markdown-document/html2markdown.js.map +0 -1
  43. package/dist/collection/components/pos-markdown-document/markdown2html.js +0 -5
  44. package/dist/collection/components/pos-markdown-document/markdown2html.js.map +0 -1
  45. package/dist/collection/components/pos-markdown-document/sanitize.js +0 -10
  46. package/dist/collection/components/pos-markdown-document/sanitize.js.map +0 -1
  47. package/dist/elements/p-b479ffbe.entry.js +0 -3
  48. package/dist/elements/p-b479ffbe.entry.js.map +0 -1
  49. package/dist/elements/p-ff3f95dc.entry.js +0 -2
  50. package/dist/elements/p-ff3f95dc.entry.js.map +0 -1
  51. package/dist/types/components/pos-markdown-document/html2markdown.d.ts +0 -1
  52. package/dist/types/components/pos-markdown-document/markdown2html.d.ts +0 -1
  53. package/dist/types/components/pos-markdown-document/sanitize.d.ts +0 -4
@@ -0,0 +1,2 @@
1
+ import{r as t,i as e,h as r}from"./p-97889672.js";import{o as n,j as i,k as s,l as o,S as l,h as u,t as a}from"./p-5a025614.js";import"./p-c066fd50.js";function f(t,e){return n(((r,n)=>{let s=0;r.subscribe(i(n,(r=>{n.next(t.call(e,r,s++))})))}))}function h(t,e,r){const l=o(t)||e||r?{next:t,error:e,complete:r}:t;return l?n(((t,e)=>{var r;(r=l.subscribe)===null||r===void 0?void 0:r.call(l);let n=true;t.subscribe(i(e,(t=>{var r;(r=l.next)===null||r===void 0?void 0:r.call(l,t);e.next(t)}),(()=>{var t;n=false;(t=l.complete)===null||t===void 0?void 0:t.call(l);e.complete()}),(t=>{var r;n=false;(r=l.error)===null||r===void 0?void 0:r.call(l,t);e.error(t)}),(()=>{var t,e;if(n){(t=l.unsubscribe)===null||t===void 0?void 0:t.call(l)}(e=l.finalize)===null||e===void 0?void 0:e.call(l)})))})):s}function c(t){this.content=t}c.prototype={constructor:c,find:function(t){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===t)return e;return-1},get:function(t){var e=this.find(t);return e==-1?undefined:this.content[e+1]},update:function(t,e,r){var n=r&&r!=t?this.remove(r):this;var i=n.find(t),s=n.content.slice();if(i==-1){s.push(r||t,e)}else{s[i+1]=e;if(r)s[i]=r}return new c(s)},remove:function(t){var e=this.find(t);if(e==-1)return this;var r=this.content.slice();r.splice(e,2);return new c(r)},addToStart:function(t,e){return new c([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var r=this.remove(t).content.slice();r.push(t,e);return new c(r)},addBefore:function(t,e,r){var n=this.remove(e),i=n.content.slice();var s=n.find(t);i.splice(s==-1?i.length:s,0,e,r);return new c(i)},forEach:function(t){for(var e=0;e<this.content.length;e+=2)t(this.content[e],this.content[e+1])},prepend:function(t){t=c.from(t);if(!t.size)return this;return new c(t.content.concat(this.subtract(t).content))},append:function(t){t=c.from(t);if(!t.size)return this;return new c(this.subtract(t).content.concat(t.content))},subtract:function(t){var e=this;t=c.from(t);for(var r=0;r<t.content.length;r+=2)e=e.remove(t.content[r]);return e},toObject:function(){var t={};this.forEach((function(e,r){t[e]=r}));return t},get size(){return this.content.length>>1}};c.from=function(t){if(t instanceof c)return t;var e=[];if(t)for(var r in t)e.push(r,t[r]);return new c(e)};function d(t,e,r){for(let n=0;;n++){if(n==t.childCount||n==e.childCount)return t.childCount==e.childCount?null:r;let i=t.child(n),s=e.child(n);if(i==s){r+=i.nodeSize;continue}if(!i.sameMarkup(s))return r;if(i.isText&&i.text!=s.text){for(let t=0;i.text[t]==s.text[t];t++)r++;return r}if(i.content.size||s.content.size){let t=d(i.content,s.content,r+1);if(t!=null)return t}r+=i.nodeSize}}function p(t,e,r,n){for(let i=t.childCount,s=e.childCount;;){if(i==0||s==0)return i==s?null:{a:r,b:n};let o=t.child(--i),l=e.child(--s),u=o.nodeSize;if(o==l){r-=u;n-=u;continue}if(!o.sameMarkup(l))return{a:r,b:n};if(o.isText&&o.text!=l.text){let t=0,e=Math.min(o.text.length,l.text.length);while(t<e&&o.text[o.text.length-t-1]==l.text[l.text.length-t-1]){t++;r--;n--}return{a:r,b:n}}if(o.content.size||l.content.size){let t=p(o.content,l.content,r-1,n-1);if(t)return t}r-=u;n-=u}}class m{constructor(t,e){this.content=t;this.size=e||0;if(e==null)for(let e=0;e<t.length;e++)this.size+=t[e].nodeSize}nodesBetween(t,e,r,n=0,i){for(let s=0,o=0;o<e;s++){let l=this.content[s],u=o+l.nodeSize;if(u>t&&r(l,n+o,i||null,s)!==false&&l.content.size){let i=o+1;l.nodesBetween(Math.max(0,t-i),Math.min(l.content.size,e-i),r,n+i)}o=u}}descendants(t){this.nodesBetween(0,this.size,t)}textBetween(t,e,r,n){let i="",s=true;this.nodesBetween(t,e,((o,l)=>{let u=o.isText?o.text.slice(Math.max(t,l)-l,e-l):!o.isLeaf?"":n?typeof n==="function"?n(o):n:o.type.spec.leafText?o.type.spec.leafText(o):"";if(o.isBlock&&(o.isLeaf&&u||o.isTextblock)&&r){if(s)s=false;else i+=r}i+=u}),0);return i}append(t){if(!t.size)return this;if(!this.size)return t;let e=this.lastChild,r=t.firstChild,n=this.content.slice(),i=0;if(e.isText&&e.sameMarkup(r)){n[n.length-1]=e.withText(e.text+r.text);i=1}for(;i<t.content.length;i++)n.push(t.content[i]);return new m(n,this.size+t.size)}cut(t,e=this.size){if(t==0&&e==this.size)return this;let r=[],n=0;if(e>t)for(let i=0,s=0;s<e;i++){let o=this.content[i],l=s+o.nodeSize;if(l>t){if(s<t||l>e){if(o.isText)o=o.cut(Math.max(0,t-s),Math.min(o.text.length,e-s));else o=o.cut(Math.max(0,t-s-1),Math.min(o.content.size,e-s-1))}r.push(o);n+=o.nodeSize}s=l}return new m(r,n)}cutByIndex(t,e){if(t==e)return m.empty;if(t==0&&e==this.content.length)return this;return new m(this.content.slice(t,e))}replaceChild(t,e){let r=this.content[t];if(r==e)return this;let n=this.content.slice();let i=this.size+e.nodeSize-r.nodeSize;n[t]=e;return new m(n,i)}addToStart(t){return new m([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new m(this.content.concat(t),this.size+t.nodeSize)}eq(t){if(this.content.length!=t.content.length)return false;for(let e=0;e<this.content.length;e++)if(!this.content[e].eq(t.content[e]))return false;return true}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(t){let e=this.content[t];if(!e)throw new RangeError("Index "+t+" out of range for "+this);return e}maybeChild(t){return this.content[t]||null}forEach(t){for(let e=0,r=0;e<this.content.length;e++){let n=this.content[e];t(n,r,e);r+=n.nodeSize}}findDiffStart(t,e=0){return d(this,t,e)}findDiffEnd(t,e=this.size,r=t.size){return p(this,t,e,r)}findIndex(t){if(t==0)return w(0,t);if(t==this.size)return w(this.content.length,t);if(t>this.size||t<0)throw new RangeError(`Position ${t} outside of fragment (${this})`);for(let e=0,r=0;;e++){let n=this.child(e),i=r+n.nodeSize;if(i>=t){if(i==t)return w(e+1,i);return w(e,r)}r=i}}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 m.empty;if(!Array.isArray(e))throw new RangeError("Invalid input for Fragment.fromJSON");return new m(e.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return m.empty;let e,r=0;for(let n=0;n<t.length;n++){let i=t[n];r+=i.nodeSize;if(n&&i.isText&&t[n-1].sameMarkup(i)){if(!e)e=t.slice(0,n);e[e.length-1]=i.withText(e[e.length-1].text+i.text)}else if(e){e.push(i)}}return new m(e||t,r)}static from(t){if(!t)return m.empty;if(t instanceof m)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new m([t],t.nodeSize);throw new RangeError("Can not convert "+t+" to a Fragment"+(t.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}m.empty=new m([],0);const g={index:0,offset:0};function w(t,e){g.index=t;g.offset=e;return g}function b(t,e){if(t===e)return true;if(!(t&&typeof t=="object")||!(e&&typeof e=="object"))return false;let r=Array.isArray(t);if(Array.isArray(e)!=r)return false;if(r){if(t.length!=e.length)return false;for(let r=0;r<t.length;r++)if(!b(t[r],e[r]))return false}else{for(let r in t)if(!(r in e)||!b(t[r],e[r]))return false;for(let r in e)if(!(r in t))return false}return true}class k{constructor(t,e){this.type=t;this.attrs=e}addToSet(t){let e,r=false;for(let n=0;n<t.length;n++){let i=t[n];if(this.eq(i))return t;if(this.type.excludes(i.type)){if(!e)e=t.slice(0,n)}else if(i.type.excludes(this.type)){return t}else{if(!r&&i.type.rank>this.type.rank){if(!e)e=t.slice(0,n);e.push(this);r=true}if(e)e.push(i)}}if(!e)e=t.slice();if(!r)e.push(this);return e}removeFromSet(t){for(let e=0;e<t.length;e++)if(this.eq(t[e]))return t.slice(0,e).concat(t.slice(e+1));return t}isInSet(t){for(let e=0;e<t.length;e++)if(this.eq(t[e]))return true;return false}eq(t){return this==t||this.type==t.type&&b(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 n=r.create(e.attrs);r.checkAttrs(n.attrs);return n}static sameSet(t,e){if(t==e)return true;if(t.length!=e.length)return false;for(let r=0;r<t.length;r++)if(!t[r].eq(e[r]))return false;return true}static setFrom(t){if(!t||Array.isArray(t)&&t.length==0)return k.none;if(t instanceof k)return[t];let e=t.slice();e.sort(((t,e)=>t.type.rank-e.type.rank));return e}}k.none=[];class v extends Error{}class y{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=x(this.content,t+this.openStart,e);return r&&new y(r,this.openStart,this.openEnd)}removeBetween(t,e){return new y(M(this.content,t+this.openStart,e+this.openStart),this.openStart,this.openEnd)}eq(t){return this.content.eq(t.content)&&this.openStart==t.openStart&&this.openEnd==t.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let t={content:this.content.toJSON()};if(this.openStart>0)t.openStart=this.openStart;if(this.openEnd>0)t.openEnd=this.openEnd;return t}static fromJSON(t,e){if(!e)return y.empty;let r=e.openStart||0,n=e.openEnd||0;if(typeof r!="number"||typeof n!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new y(m.fromJSON(t,e.content),r,n)}static maxOpen(t,e=true){let r=0,n=0;for(let n=t.firstChild;n&&!n.isLeaf&&(e||!n.type.spec.isolating);n=n.firstChild)r++;for(let r=t.lastChild;r&&!r.isLeaf&&(e||!r.type.spec.isolating);r=r.lastChild)n++;return new y(t,r,n)}}y.empty=new y(m.empty,0,0);function M(t,e,r){let{index:n,offset:i}=t.findIndex(e),s=t.maybeChild(n);let{index:o,offset:l}=t.findIndex(r);if(i==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(n!=o)throw new RangeError("Removing non-flat range");return t.replaceChild(n,s.copy(M(s.content,e-i-1,r-i-1)))}function x(t,e,r,n){let{index:i,offset:s}=t.findIndex(e),o=t.maybeChild(i);if(s==e||o.isText){if(n&&!n.canReplace(i,i,r))return null;return t.cut(0,e).append(r).append(t.cut(e))}let l=x(o.content,e-s-1,r,o);return l&&t.replaceChild(i,o.copy(l))}function S(t,e,r){if(r.openStart>t.depth)throw new v("Inserted content deeper than insertion position");if(t.depth-r.openStart!=e.depth-r.openEnd)throw new v("Inconsistent open depths");return T(t,e,r,0)}function T(t,e,r,n){let i=t.index(n),s=t.node(n);if(i==e.index(n)&&n<t.depth-r.openStart){let o=T(t,e,r,n+1);return s.copy(s.content.replaceChild(i,o))}else if(!r.content.size){return R(s,L(t,e,n))}else if(!r.openStart&&!r.openEnd&&t.depth==n&&e.depth==n){let n=t.parent,i=n.content;return R(n,i.cut(0,t.parentOffset).append(r.content).append(i.cut(e.parentOffset)))}else{let{start:i,end:o}=N(r,t);return R(s,C(t,i,o,e,n))}}function E(t,e){if(!e.type.compatibleContent(t.type))throw new v("Cannot join "+e.type.name+" onto "+t.type.name)}function $(t,e,r){let n=t.node(r);E(n,e.node(r));return n}function A(t,e){let r=e.length-1;if(r>=0&&t.isText&&t.sameMarkup(e[r]))e[r]=t.withText(e[r].text+t.text);else e.push(t)}function O(t,e,r,n){let i=(e||t).node(r);let s=0,o=e?e.index(r):i.childCount;if(t){s=t.index(r);if(t.depth>r){s++}else if(t.textOffset){A(t.nodeAfter,n);s++}}for(let t=s;t<o;t++)A(i.child(t),n);if(e&&e.depth==r&&e.textOffset)A(e.nodeBefore,n)}function R(t,e){t.type.checkContent(e);return t.copy(e)}function C(t,e,r,n,i){let s=t.depth>i&&$(t,e,i+1);let o=n.depth>i&&$(r,n,i+1);let l=[];O(null,t,i,l);if(s&&o&&e.index(i)==r.index(i)){E(s,o);A(R(s,C(t,e,r,n,i+1)),l)}else{if(s)A(R(s,L(t,e,i+1)),l);O(e,r,i,l);if(o)A(R(o,L(r,n,i+1)),l)}O(n,null,i,l);return new m(l)}function L(t,e,r){let n=[];O(null,t,r,n);if(t.depth>r){let i=$(t,e,r+1);A(R(i,L(t,e,r+1)),n)}O(e,null,r,n);return new m(n)}function N(t,e){let r=e.depth-t.openStart,n=e.node(r);let i=n.copy(t.content);for(let t=r-1;t>=0;t--)i=e.node(t).copy(m.from(i));return{start:i.resolveNoCache(t.openStart+r),end:i.resolveNoCache(i.content.size-t.openEnd-r)}}class P{constructor(t,e,r){this.pos=t;this.path=e;this.parentOffset=r;this.depth=e.length/3-1}resolveDepth(t){if(t==null)return this.depth;if(t<0)return this.depth+t;return t}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(t){return this.path[this.resolveDepth(t)*3]}index(t){return this.path[this.resolveDepth(t)*3+1]}indexAfter(t){t=this.resolveDepth(t);return this.index(t)+(t==this.depth&&!this.textOffset?0:1)}start(t){t=this.resolveDepth(t);return t==0?0:this.path[t*3-1]+1}end(t){t=this.resolveDepth(t);return this.start(t)+this.node(t).content.size}before(t){t=this.resolveDepth(t);if(!t)throw new RangeError("There is no position before the top-level node");return t==this.depth+1?this.pos:this.path[t*3-1]}after(t){t=this.resolveDepth(t);if(!t)throw new RangeError("There is no position after the top-level node");return t==this.depth+1?this.pos:this.path[t*3-1]+this.path[t*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let t=this.parent,e=this.index(this.depth);if(e==t.childCount)return null;let r=this.pos-this.path[this.path.length-1],n=t.child(e);return r?t.child(e).cut(r):n}get nodeBefore(){let t=this.index(this.depth);let e=this.pos-this.path[this.path.length-1];if(e)return this.parent.child(t).cut(0,e);return t==0?null:this.parent.child(t-1)}posAtIndex(t,e){e=this.resolveDepth(e);let r=this.path[e*3],n=e==0?0:this.path[e*3-1]+1;for(let e=0;e<t;e++)n+=r.child(e).nodeSize;return n}marks(){let t=this.parent,e=this.index();if(t.content.size==0)return k.none;if(this.textOffset)return t.child(e).marks;let r=t.maybeChild(e-1),n=t.maybeChild(e);if(!r){let t=r;r=n;n=t}let i=r.marks;for(var s=0;s<i.length;s++)if(i[s].type.spec.inclusive===false&&(!n||!i[s].isInSet(n.marks)))i=i[s--].removeFromSet(i);return i}marksAcross(t){let e=this.parent.maybeChild(this.index());if(!e||!e.isInline)return null;let r=e.marks,n=t.parent.maybeChild(t.index());for(var i=0;i<r.length;i++)if(r[i].type.spec.inclusive===false&&(!n||!r[i].isInSet(n.marks)))r=r[i--].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 j(this,t,r);return null}sameParent(t){return this.pos-this.parentOffset==t.pos-t.parentOffset}max(t){return t.pos>this.pos?t:this}min(t){return t.pos<this.pos?t:this}toString(){let t="";for(let e=1;e<=this.depth;e++)t+=(t?"/":"")+this.node(e).type.name+"_"+this.index(e-1);return t+":"+this.parentOffset}static resolve(t,e){if(!(e>=0&&e<=t.content.size))throw new RangeError("Position "+e+" out of range");let r=[];let n=0,i=e;for(let e=t;;){let{index:t,offset:s}=e.content.findIndex(i);let o=i-s;r.push(e,t,n+s);if(!o)break;e=e.child(t);if(e.isText)break;i=o-1;n+=s+1}return new P(e,r,i)}static resolveCached(t,e){let r=H.get(t);if(r){for(let t=0;t<r.elts.length;t++){let n=r.elts[t];if(n.pos==e)return n}}else{H.set(t,r=new I)}let n=r.elts[r.i]=P.resolve(t,e);r.i=(r.i+1)%D;return n}}class I{constructor(){this.elts=[];this.i=0}}const D=12,H=new WeakMap;class j{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 _=Object.create(null);class z{constructor(t,e,r,n=k.none){this.type=t;this.attrs=e;this.marks=n;this.content=r||m.empty}get children(){return this.content.content}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,n=0){this.content.nodesBetween(t,e,r,n,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,n){return this.content.textBetween(t,e,r,n)}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&&b(this.attrs,e||t.defaultAttrs||_)&&k.sameSet(this.marks,r||k.none)}copy(t=null){if(t==this.content)return this;return new z(this.type,this.attrs,t,this.marks)}mark(t){return t==this.marks?this:new z(this.type,this.attrs,this.content,t)}cut(t,e=this.content.size){if(t==0&&e==this.content.size)return this;return this.copy(this.content.cut(t,e))}slice(t,e=this.content.size,r=false){if(t==e)return y.empty;let n=this.resolve(t),i=this.resolve(e);let s=r?0:n.sharedDepth(e);let o=n.start(s),l=n.node(s);let u=l.content.cut(n.pos-o,i.pos-o);return new y(u,n.depth-s,i.depth-s)}replace(t,e,r){return S(this.resolve(t),this.resolve(e),r)}nodeAt(t){for(let e=this;;){let{index:r,offset:n}=e.content.findIndex(t);e=e.maybeChild(r);if(!e)return null;if(n==t||e.isText)return e;t-=n+1}}childAfter(t){let{index:e,offset:r}=this.content.findIndex(t);return{node:this.content.maybeChild(e),index:e,offset:r}}childBefore(t){if(t==0)return{node:null,index:0,offset:0};let{index:e,offset:r}=this.content.findIndex(t);if(r<t)return{node:this.content.child(e),index:e,offset:r};let n=this.content.child(e-1);return{node:n,index:e-1,offset:r-n.nodeSize}}resolve(t){return P.resolveCached(this,t)}resolveNoCache(t){return P.resolve(this,t)}rangeHasMark(t,e,r){let n=false;if(e>t)this.nodesBetween(t,e,(t=>{if(r.isInSet(t.marks))n=true;return!n}));return n}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let t=this.type.name;if(this.content.size)t+="("+this.content.toStringInner()+")";return F(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=m.empty,n=0,i=r.childCount){let s=this.contentMatchAt(t).matchFragment(r,n,i);let o=s&&s.matchFragment(this.content,e);if(!o||!o.validEnd)return false;for(let t=n;t<i;t++)if(!this.type.allowsMarks(r.child(t).marks))return false;return true}canReplaceWith(t,e,r,n){if(n&&!this.type.allowsMarks(n))return false;let i=this.contentMatchAt(t).matchType(r);let s=i&&i.matchFragment(this.content,e);return s?s.validEnd:false}canAppend(t){if(t.content.size)return this.canReplace(this.childCount,this.childCount,t.content);else return this.type.compatibleContent(t.type)}check(){this.type.checkContent(this.content);this.type.checkAttrs(this.attrs);let t=k.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(!k.sameSet(t,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map((t=>t.type.name))}`);this.content.forEach((t=>t.check()))}toJSON(){let t={type:this.type.name};for(let e in this.attrs){t.attrs=this.attrs;break}if(this.content.size)t.content=this.content.toJSON();if(this.marks.length)t.marks=this.marks.map((t=>t.toJSON()));return t}static fromJSON(t,e){if(!e)throw new RangeError("Invalid input for Node.fromJSON");let r=undefined;if(e.marks){if(!Array.isArray(e.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=e.marks.map(t.markFromJSON)}if(e.type=="text"){if(typeof e.text!="string")throw new RangeError("Invalid text node in JSON");return t.text(e.text,r)}let n=m.fromJSON(t,e.content);let i=t.nodeType(e.type).create(e.attrs,n,r);i.type.checkAttrs(i.attrs);return i}}z.prototype.text=undefined;class B extends z{constructor(t,e,r,n){super(t,e,null,n);if(!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);return F(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 B(this.type,this.attrs,this.text,t)}withText(t){if(t==this.text)return this;return new B(this.type,this.attrs,t,this.marks)}cut(t=0,e=this.text.length){if(t==0&&e==this.text.length)return this;return this.withText(this.text.slice(t,e))}eq(t){return this.sameMarkup(t)&&this.text==t.text}toJSON(){let t=super.toJSON();t.text=this.text;return t}}function F(t,e){for(let r=t.length-1;r>=0;r--)e=t[r].type.name+"("+e+")";return e}class U{constructor(t){this.validEnd=t;this.next=[];this.wrapCache=[]}static parse(t,e){let r=new q(t,e);if(r.next==null)return U.empty;let n=J(r);if(r.next)r.err("Unexpected trailing text");let i=et(X(n));rt(i,r);return i}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 n=this;for(let i=e;n&&i<r;i++)n=n.matchType(t.child(i).type);return n}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let t=0;t<this.next.length;t++){let{type:e}=this.next[t];if(!(e.isText||e.hasRequiredAttrs()))return e}return null}compatible(t){for(let e=0;e<this.next.length;e++)for(let r=0;r<t.next.length;r++)if(this.next[e].type==t.next[r].type)return true;return false}fillBefore(t,e=false,r=0){let n=[this];function i(s,o){let l=s.matchFragment(t,r);if(l&&(!e||l.validEnd))return m.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())&&n.indexOf(r)==-1){n.push(r);let t=i(r,o.concat(e));if(t)return t}}return null}return i(this,[])}findWrapping(t){for(let e=0;e<this.wrapCache.length;e+=2)if(this.wrapCache[e]==t)return this.wrapCache[e+1];let e=this.computeWrapping(t);this.wrapCache.push(t,e);return e}computeWrapping(t){let e=Object.create(null),r=[{match:this,type:null,via:null}];while(r.length){let n=r.shift(),i=n.match;if(i.matchType(t)){let t=[];for(let e=n;e.type;e=e.via)t.push(e.type);return t.reverse()}for(let t=0;t<i.next.length;t++){let{type:s,next:o}=i.next[t];if(!s.isLeaf&&!s.hasRequiredAttrs()&&!(s.name in e)&&(!n.type||o.validEnd)){r.push({match:s.contentMatch,type:s,via:n});e[s.name]=true}}}return null}get edgeCount(){return this.next.length}edge(t){if(t>=this.next.length)throw new RangeError(`There's no ${t}th edge in this content match`);return this.next[t]}toString(){let t=[];function e(r){t.push(r);for(let n=0;n<r.next.length;n++)if(t.indexOf(r.next[n].next)==-1)e(r.next[n].next)}e(this);return t.map(((e,r)=>{let n=r+(e.validEnd?"*":" ")+" ";for(let r=0;r<e.next.length;r++)n+=(r?", ":"")+e.next[r].type.name+"->"+t.indexOf(e.next[r].next);return n})).join("\n")}}U.empty=new U(true);class q{constructor(t,e){this.string=t;this.nodeTypes=e;this.inline=null;this.pos=0;this.tokens=t.split(/\s*(?=\b|\W|$)/);if(this.tokens[this.tokens.length-1]=="")this.tokens.pop();if(this.tokens[0]=="")this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(t){return this.next==t&&(this.pos++||true)}err(t){throw new SyntaxError(t+" (in content expression '"+this.string+"')")}}function J(t){let e=[];do{e.push(K(t))}while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function K(t){let e=[];do{e.push(W(t))}while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function W(t){let e=Q(t);for(;;){if(t.eat("+"))e={type:"plus",expr:e};else if(t.eat("*"))e={type:"star",expr:e};else if(t.eat("?"))e={type:"opt",expr:e};else if(t.eat("{"))e=G(t,e);else break}return e}function V(t){if(/\D/.test(t.next))t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);t.pos++;return e}function G(t,e){let r=V(t),n=r;if(t.eat(",")){if(t.next!="}")n=V(t);else n=-1}if(!t.eat("}"))t.err("Unclosed braced range");return{type:"range",min:r,max:n,expr:e}}function Z(t,e){let r=t.nodeTypes,n=r[e];if(n)return[n];let i=[];for(let t in r){let n=r[t];if(n.isInGroup(e))i.push(n)}if(i.length==0)t.err("No node type or group '"+e+"' found");return i}function Q(t){if(t.eat("(")){let e=J(t);if(!t.eat(")"))t.err("Missing closing paren");return e}else if(!/\W/.test(t.next)){let e=Z(t,t.next).map((e=>{if(t.inline==null)t.inline=e.isInline;else if(t.inline!=e.isInline)t.err("Mixing inline and block content");return{type:"name",value:e}}));t.pos++;return e.length==1?e[0]:{type:"choice",exprs:e}}else{t.err("Unexpected token '"+t.next+"'")}}function X(t){let e=[[]];i(s(t,0),r());return e;function r(){return e.push([])-1}function n(t,r,n){let i={term:n,to:r};e[t].push(i);return i}function i(t,e){t.forEach((t=>t.to=e))}function s(t,e){if(t.type=="choice"){return t.exprs.reduce(((t,r)=>t.concat(s(r,e))),[])}else if(t.type=="seq"){for(let n=0;;n++){let o=s(t.exprs[n],e);if(n==t.exprs.length-1)return o;i(o,e=r())}}else if(t.type=="star"){let o=r();n(e,o);i(s(t.expr,o),o);return[n(o)]}else if(t.type=="plus"){let o=r();i(s(t.expr,e),o);i(s(t.expr,o),o);return[n(o)]}else if(t.type=="opt"){return[n(e)].concat(s(t.expr,e))}else if(t.type=="range"){let o=e;for(let e=0;e<t.min;e++){let e=r();i(s(t.expr,o),e);o=e}if(t.max==-1){i(s(t.expr,o),o)}else{for(let e=t.min;e<t.max;e++){let e=r();n(o,e);i(s(t.expr,o),e);o=e}}return[n(o)]}else if(t.type=="name"){return[n(e,undefined,t.value)]}else{throw new Error("Unknown expr type")}}}function Y(t,e){return e-t}function tt(t,e){let r=[];n(e);return r.sort(Y);function n(e){let i=t[e];if(i.length==1&&!i[0].term)return n(i[0].to);r.push(e);for(let t=0;t<i.length;t++){let{term:e,to:s}=i[t];if(!e&&r.indexOf(s)==-1)n(s)}}}function et(t){let e=Object.create(null);return r(tt(t,0));function r(n){let i=[];n.forEach((e=>{t[e].forEach((({term:e,to:r})=>{if(!e)return;let n;for(let t=0;t<i.length;t++)if(i[t][0]==e)n=i[t][1];tt(t,r).forEach((t=>{if(!n)i.push([e,n=[]]);if(n.indexOf(t)==-1)n.push(t)}))}))}));let s=e[n.join(",")]=new U(n.indexOf(t.length-1)>-1);for(let t=0;t<i.length;t++){let n=i[t][1].sort(Y);s.next.push({type:i[t][0],next:e[n.join(",")]||r(n)})}return s}}function rt(t,e){for(let r=0,n=[t];r<n.length;r++){let t=n[r],i=!t.validEnd,s=[];for(let e=0;e<t.next.length;e++){let{type:r,next:o}=t.next[e];s.push(r.name);if(i&&!(r.isText||r.hasRequiredAttrs()))i=false;if(n.indexOf(o)==-1)n.push(o)}if(i)e.err("Only non-generatable nodes ("+s.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function nt(t){let e=Object.create(null);for(let r in t){let n=t[r];if(!n.hasDefault)return null;e[r]=n.default}return e}function it(t,e){let r=Object.create(null);for(let n in t){let i=e&&e[n];if(i===undefined){let e=t[n];if(e.hasDefault)i=e.default;else throw new RangeError("No value supplied for attribute "+n)}r[n]=i}return r}function st(t,e,r,n){for(let n in e)if(!(n in t))throw new RangeError(`Unsupported attribute ${n} for ${r} of type ${n}`);for(let r in t){let n=t[r];if(n.validate)n.validate(e[r])}}function ot(t,e){let r=Object.create(null);if(e)for(let n in e)r[n]=new at(t,n,e[n]);return r}class lt{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=ot(t,r.attrs);this.defaultAttrs=nt(this.attrs);this.contentMatch=null;this.inlineContent=null;this.isBlock=!(r.inline||t=="text");this.isText=t=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==U.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(t){return this.groups.indexOf(t)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let t in this.attrs)if(this.attrs[t].isRequired)return true;return false}compatibleContent(t){return this==t||this.contentMatch.compatible(t.contentMatch)}computeAttrs(t){if(!t&&this.defaultAttrs)return this.defaultAttrs;else return it(this.attrs,t)}create(t=null,e,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new z(this,this.computeAttrs(t),m.from(e),k.setFrom(r))}createChecked(t=null,e,r){e=m.from(e);this.checkContent(e);return new z(this,this.computeAttrs(t),e,k.setFrom(r))}createAndFill(t=null,e,r){t=this.computeAttrs(t);e=m.from(e);if(e.size){let t=this.contentMatch.fillBefore(e);if(!t)return null;e=t.append(e)}let n=this.contentMatch.matchFragment(e);let i=n&&n.fillBefore(m.empty,true);if(!i)return null;return new z(this,t,e.append(i),k.setFrom(r))}validContent(t){let e=this.contentMatch.matchFragment(t);if(!e||!e.validEnd)return false;for(let e=0;e<t.childCount;e++)if(!this.allowsMarks(t.child(e).marks))return false;return true}checkContent(t){if(!this.validContent(t))throw new RangeError(`Invalid content for node ${this.name}: ${t.toString().slice(0,50)}`)}checkAttrs(t){st(this.attrs,t,"node")}allowsMarkType(t){return this.markSet==null||this.markSet.indexOf(t)>-1}allowsMarks(t){if(this.markSet==null)return true;for(let e=0;e<t.length;e++)if(!this.allowsMarkType(t[e].type))return false;return true}allowedMarks(t){if(this.markSet==null)return t;let e;for(let r=0;r<t.length;r++){if(!this.allowsMarkType(t[r].type)){if(!e)e=t.slice(0,r)}else if(e){e.push(t[r])}}return!e?t:e.length?e:k.none}static compile(t,e){let r=Object.create(null);t.forEach(((t,n)=>r[t]=new lt(t,e,n)));let n=e.spec.topNode||"doc";if(!r[n])throw new RangeError("Schema is missing its top node type ('"+n+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let t in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}}function ut(t,e,r){let n=r.split("|");return r=>{let i=r===null?"null":typeof r;if(n.indexOf(i)<0)throw new RangeError(`Expected value of type ${n} for attribute ${e} on type ${t}, got ${i}`)}}class at{constructor(t,e,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default");this.default=r.default;this.validate=typeof r.validate=="string"?ut(t,e,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class ft{constructor(t,e,r,n){this.name=t;this.rank=e;this.schema=r;this.spec=n;this.attrs=ot(t,n.attrs);this.excluded=null;let i=nt(this.attrs);this.instance=i?new k(this,i):null}create(t=null){if(!t&&this.instance)return this.instance;return new k(this,it(this.attrs,t))}static compile(t,e){let r=Object.create(null),n=0;t.forEach(((t,i)=>r[t]=new ft(t,n++,e,i)));return r}removeFromSet(t){for(var e=0;e<t.length;e++)if(t[e].type==this){t=t.slice(0,e).concat(t.slice(e+1));e--}return t}isInSet(t){for(let e=0;e<t.length;e++)if(t[e].type==this)return t[e]}checkAttrs(t){st(this.attrs,t,"mark")}excludes(t){return this.excluded.indexOf(t)>-1}}class ht{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=c.from(t.nodes),e.marks=c.from(t.marks||{}),this.nodes=lt.compile(this.spec.nodes,this);this.marks=ft.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],n=e.spec.content||"",i=e.spec.marks;e.contentMatch=r[n]||(r[n]=U.parse(n,this.nodes));e.inlineContent=e.contentMatch.inlineContent;if(e.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!e.isInline||!e.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=e}e.markSet=i=="_"?null:i?ct(this,i.split(" ")):i==""||!e.inlineContent?[]:null}for(let t in this.marks){let e=this.marks[t],r=e.spec.excludes;e.excluded=r==null?[e]:r==""?[]:ct(this,r.split(" "))}this.nodeFromJSON=t=>z.fromJSON(this,t);this.markFromJSON=t=>k.fromJSON(this,t);this.topNodeType=this.nodes[this.spec.topNode||"doc"];this.cached.wrappings=Object.create(null)}node(t,e=null,r,n){if(typeof t=="string")t=this.nodeType(t);else if(!(t instanceof lt))throw new RangeError("Invalid node type: "+t);else if(t.schema!=this)throw new RangeError("Node type from different schema used ("+t.name+")");return t.createChecked(e,r,n)}text(t,e){let r=this.nodes.text;return new B(r,r.defaultAttrs,t,k.setFrom(e))}mark(t,e){if(typeof t=="string")t=this.marks[t];return t.create(e)}nodeType(t){let e=this.nodes[t];if(!e)throw new RangeError("Unknown node type: "+t);return e}}function ct(t,e){let r=[];for(let n=0;n<e.length;n++){let i=e[n],s=t.marks[i],o=s;if(s){r.push(s)}else{for(let e in t.marks){let n=t.marks[e];if(i=="_"||n.spec.group&&n.spec.group.split(" ").indexOf(i)>-1)r.push(o=n)}}if(!o)throw new SyntaxError("Unknown mark type: '"+e[n]+"'")}return r}function dt(t){return t.tag!=null}function pt(t){return t.style!=null}class mt{constructor(t,e){this.schema=t;this.rules=e;this.tags=[];this.styles=[];let r=this.matchedStyles=[];e.forEach((t=>{if(dt(t)){this.tags.push(t)}else if(pt(t)){let e=/[^=]*/.exec(t.style)[0];if(r.indexOf(e)<0)r.push(e);this.styles.push(t)}}));this.normalizeLists=!this.tags.some((e=>{if(!/^(ul|ol)\b/.test(e.tag)||!e.node)return false;let r=t.nodes[e.node];return r.contentMatch.matchType(r)}))}parse(t,e={}){let r=new St(this,e,false);r.addAll(t,k.none,e.from,e.to);return r.finish()}parseSlice(t,e={}){let r=new St(this,e,true);r.addAll(t,k.none,e.from,e.to);return y.maxOpen(r.finish())}matchTag(t,e,r){for(let n=r?this.tags.indexOf(r)+1:0;n<this.tags.length;n++){let r=this.tags[n];if(Et(t,r.tag)&&(r.namespace===undefined||t.namespaceURI==r.namespace)&&(!r.context||e.matchesContext(r.context))){if(r.getAttrs){let e=r.getAttrs(t);if(e===false)continue;r.attrs=e||undefined}return r}}}matchStyle(t,e,r,n){for(let i=n?this.styles.indexOf(n)+1:0;i<this.styles.length;i++){let n=this.styles[i],s=n.style;if(s.indexOf(t)!=0||n.context&&!r.matchesContext(n.context)||s.length>t.length&&(s.charCodeAt(t.length)!=61||s.slice(t.length+1)!=e))continue;if(n.getAttrs){let t=n.getAttrs(e);if(t===false)continue;n.attrs=t||undefined}return n}}static schemaRules(t){let e=[];function r(t){let r=t.priority==null?50:t.priority,n=0;for(;n<e.length;n++){let t=e[n],i=t.priority==null?50:t.priority;if(i<r)break}e.splice(n,0,t)}for(let e in t.marks){let n=t.marks[e].spec.parseDOM;if(n)n.forEach((t=>{r(t=$t(t));if(!(t.mark||t.ignore||t.clearMark))t.mark=e}))}for(let e in t.nodes){let n=t.nodes[e].spec.parseDOM;if(n)n.forEach((t=>{r(t=$t(t));if(!(t.node||t.ignore||t.mark))t.node=e}))}return e}static fromSchema(t){return t.cached.domParser||(t.cached.domParser=new mt(t,mt.schemaRules(t)))}}const gt={address:true,article:true,aside:true,blockquote:true,canvas:true,dd:true,div:true,dl:true,fieldset:true,figcaption:true,figure:true,footer:true,form:true,h1:true,h2:true,h3:true,h4:true,h5:true,h6:true,header:true,hgroup:true,hr:true,li:true,noscript:true,ol:true,output:true,p:true,pre:true,section:true,table:true,tfoot:true,ul:true};const wt={head:true,noscript:true,object:true,script:true,style:true,title:true};const bt={ol:true,ul:true};const kt=1,vt=2,yt=4;function Mt(t,e,r){if(e!=null)return(e?kt:0)|(e==="full"?vt:0);return t&&t.whitespace=="pre"?kt|vt:r&~yt}class xt{constructor(t,e,r,n,i,s){this.type=t;this.attrs=e;this.marks=r;this.solid=n;this.options=s;this.content=[];this.activeMarks=k.none;this.match=i||(s&yt?null:t.contentMatch)}findWrapping(t){if(!this.match){if(!this.type)return[];let e=this.type.contentMatch.fillBefore(m.from(t));if(e){this.match=this.type.contentMatch.matchFragment(e)}else{let e=this.type.contentMatch,r;if(r=e.findWrapping(t.type)){this.match=e;return r}else{return null}}}return this.match.findWrapping(t.type)}finish(t){if(!(this.options&kt)){let t=this.content[this.content.length-1],e;if(t&&t.isText&&(e=/[ \t\r\n\u000c]+$/.exec(t.text))){let r=t;if(t.text.length==e[0].length)this.content.pop();else this.content[this.content.length-1]=r.withText(r.text.slice(0,r.text.length-e[0].length))}}let e=m.from(this.content);if(!t&&this.match)e=e.append(this.match.fillBefore(m.empty,true));return this.type?this.type.create(this.attrs,e,this.marks):e}inlineContext(t){if(this.type)return this.type.inlineContent;if(this.content.length)return this.content[0].isInline;return t.parentNode&&!gt.hasOwnProperty(t.parentNode.nodeName.toLowerCase())}}class St{constructor(t,e,r){this.parser=t;this.options=e;this.isOpen=r;this.open=0;this.localPreserveWS=false;let n=e.topNode,i;let s=Mt(null,e.preserveWhitespace,0)|(r?yt:0);if(n)i=new xt(n.type,n.attrs,k.none,true,e.topMatch||n.type.contentMatch,s);else if(r)i=new xt(null,null,k.none,true,null,s);else i=new xt(t.schema.topNodeType,null,k.none,true,null,s);this.nodes=[i];this.find=e.findPositions;this.needsBlock=false}get top(){return this.nodes[this.open]}addDOM(t,e){if(t.nodeType==3)this.addTextNode(t,e);else if(t.nodeType==1)this.addElement(t,e)}addTextNode(t,e){let r=t.nodeValue;let n=this.top,i=n.options&vt?"full":this.localPreserveWS||(n.options&kt)>0;if(i==="full"||n.inlineContext(t)||/[^ \t\r\n\u000c]/.test(r)){if(!i){r=r.replace(/[ \t\r\n\u000c]+/g," ");if(/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let e=n.content[n.content.length-1];let i=t.previousSibling;if(!e||i&&i.nodeName=="BR"||e.isText&&/[ \t\r\n\u000c]$/.test(e.text))r=r.slice(1)}}else if(i!=="full"){r=r.replace(/\r?\n|\r/g," ")}else{r=r.replace(/\r\n?/g,"\n")}if(r)this.insertNode(this.parser.schema.text(r),e,!/\S/.test(r));this.findInText(t)}else{this.findInside(t)}}addElement(t,e,r){let n=this.localPreserveWS,i=this.top;if(t.tagName=="PRE"||/pre/.test(t.style&&t.style.whiteSpace))this.localPreserveWS=true;let s=t.nodeName.toLowerCase(),o;if(bt.hasOwnProperty(s)&&this.parser.normalizeLists)Tt(t);let l=this.options.ruleFromNode&&this.options.ruleFromNode(t)||(o=this.parser.matchTag(t,this,r));t:if(l?l.ignore:wt.hasOwnProperty(s)){this.findInside(t);this.ignoreFallback(t,e)}else if(!l||l.skip||l.closeParent){if(l&&l.closeParent)this.open=Math.max(0,this.open-1);else if(l&&l.skip.nodeType)t=l.skip;let r,n=this.needsBlock;if(gt.hasOwnProperty(s)){if(i.content.length&&i.content[0].isInline&&this.open){this.open--;i=this.top}r=true;if(!i.type)this.needsBlock=true}else if(!t.firstChild){this.leafFallback(t,e);break t}let o=l&&l.skip?e:this.readStyles(t,e);if(o)this.addAll(t,o);if(r)this.sync(i);this.needsBlock=n}else{let r=this.readStyles(t,e);if(r)this.addElementByRule(t,l,r,l.consuming===false?o:undefined)}this.localPreserveWS=n}leafFallback(t,e){if(t.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent)this.addTextNode(t.ownerDocument.createTextNode("\n"),e)}ignoreFallback(t,e){if(t.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent))this.findPlace(this.parser.schema.text("-"),e,true)}readStyles(t,e){let r=t.style;if(r&&r.length)for(let t=0;t<this.parser.matchedStyles.length;t++){let n=this.parser.matchedStyles[t],i=r.getPropertyValue(n);if(i)for(let t=undefined;;){let r=this.parser.matchStyle(n,i,this,t);if(!r)break;if(r.ignore)return null;if(r.clearMark)e=e.filter((t=>!r.clearMark(t)));else e=e.concat(this.parser.schema.marks[r.mark].create(r.attrs));if(r.consuming===false)t=r;else break}}return e}addElementByRule(t,e,r,n){let i,s;if(e.node){s=this.parser.schema.nodes[e.node];if(!s.isLeaf){let t=this.enter(s,e.attrs||null,r,e.preserveWhitespace);if(t){i=true;r=t}}else if(!this.insertNode(s.create(e.attrs),r,t.nodeName=="BR")){this.leafFallback(t,r)}}else{let t=this.parser.schema.marks[e.mark];r=r.concat(t.create(e.attrs))}let o=this.top;if(s&&s.isLeaf){this.findInside(t)}else if(n){this.addElement(t,r,n)}else if(e.getContent){this.findInside(t);e.getContent(t,this.parser.schema).forEach((t=>this.insertNode(t,r,false)))}else{let n=t;if(typeof e.contentElement=="string")n=t.querySelector(e.contentElement);else if(typeof e.contentElement=="function")n=e.contentElement(t);else if(e.contentElement)n=e.contentElement;this.findAround(t,n,true);this.addAll(n,r);this.findAround(t,n,false)}if(i&&this.sync(o))this.open--}addAll(t,e,r,n){let i=r||0;for(let s=r?t.childNodes[r]:t.firstChild,o=n==null?null:t.childNodes[n];s!=o;s=s.nextSibling,++i){this.findAtPoint(t,i);this.addDOM(s,e)}this.findAtPoint(t,i)}findPlace(t,e,r){let n,i;for(let e=this.open,s=0;e>=0;e--){let o=this.nodes[e];let l=o.findWrapping(t);if(l&&(!n||n.length>l.length+s)){n=l;i=o;if(!l.length)break}if(o.solid){if(r)break;s+=2}}if(!n)return null;this.sync(i);for(let t=0;t<n.length;t++)e=this.enterInner(n[t],null,e,false);return e}insertNode(t,e,r){if(t.isInline&&this.needsBlock&&!this.top.type){let t=this.textblockFromContext();if(t)e=this.enterInner(t,null,e)}let n=this.findPlace(t,e,r);if(n){this.closeExtra();let e=this.top;if(e.match)e.match=e.match.matchType(t.type);let r=k.none;for(let i of n.concat(t.marks))if(e.type?e.type.allowsMarkType(i.type):At(i.type,t.type))r=i.addToSet(r);e.content.push(t.mark(r));return true}return false}enter(t,e,r,n){let i=this.findPlace(t.create(e),r,false);if(i)i=this.enterInner(t,e,r,true,n);return i}enterInner(t,e,r,n=false,i){this.closeExtra();let s=this.top;s.match=s.match&&s.match.matchType(t);let o=Mt(t,i,s.options);if(s.options&yt&&s.content.length==0)o|=yt;let l=k.none;r=r.filter((e=>{if(s.type?s.type.allowsMarkType(e.type):At(e.type,t)){l=e.addToSet(l);return false}return true}));this.nodes.push(new xt(t,e,l,n,null,o));this.open++;return r}closeExtra(t=false){let e=this.nodes.length-1;if(e>this.open){for(;e>this.open;e--)this.nodes[e-1].content.push(this.nodes[e].finish(t));this.nodes.length=this.open+1}}finish(){this.open=0;this.closeExtra(this.isOpen);return this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(t){for(let e=this.open;e>=0;e--){if(this.nodes[e]==t){this.open=e;return true}else if(this.localPreserveWS){this.nodes[e].options|=kt}}return false}get currentPos(){this.closeExtra();let t=0;for(let e=this.open;e>=0;e--){let r=this.nodes[e].content;for(let e=r.length-1;e>=0;e--)t+=r[e].nodeSize;if(e)t++}return t}findAtPoint(t,e){if(this.find)for(let r=0;r<this.find.length;r++){if(this.find[r].node==t&&this.find[r].offset==e)this.find[r].pos=this.currentPos}}findInside(t){if(this.find)for(let e=0;e<this.find.length;e++){if(this.find[e].pos==null&&t.nodeType==1&&t.contains(this.find[e].node))this.find[e].pos=this.currentPos}}findAround(t,e,r){if(t!=e&&this.find)for(let n=0;n<this.find.length;n++){if(this.find[n].pos==null&&t.nodeType==1&&t.contains(this.find[n].node)){let t=e.compareDocumentPosition(this.find[n].node);if(t&(r?2:4))this.find[n].pos=this.currentPos}}}findInText(t){if(this.find)for(let e=0;e<this.find.length;e++){if(this.find[e].node==t)this.find[e].pos=this.currentPos-(t.nodeValue.length-this.find[e].offset)}}matchesContext(t){if(t.indexOf("|")>-1)return t.split(/\s*\|\s*/).some(this.matchesContext,this);let e=t.split("/");let r=this.options.context;let n=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type);let i=-(r?r.depth+1:0)+(n?0:1);let s=(t,o)=>{for(;t>=0;t--){let l=e[t];if(l==""){if(t==e.length-1||t==0)continue;for(;o>=i;o--)if(s(t-1,o))return true;return false}else{let t=o>0||o==0&&n?this.nodes[o].type:r&&o>=i?r.node(o-i).type:null;if(!t||t.name!=l&&!t.isInGroup(l))return false;o--}}return true};return s(e.length-1,this.open)}textblockFromContext(){let t=this.options.context;if(t)for(let e=t.depth;e>=0;e--){let r=t.node(e).contentMatchAt(t.indexAfter(e)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let t in this.parser.schema.nodes){let e=this.parser.schema.nodes[t];if(e.isTextblock&&e.defaultAttrs)return e}}}function Tt(t){for(let e=t.firstChild,r=null;e;e=e.nextSibling){let t=e.nodeType==1?e.nodeName.toLowerCase():null;if(t&&bt.hasOwnProperty(t)&&r){r.appendChild(e);e=r}else if(t=="li"){r=e}else if(t){r=null}}}function Et(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function $t(t){let e={};for(let r in t)e[r]=t[r];return e}function At(t,e){let r=e.schema.nodes;for(let n in r){let i=r[n];if(!i.allowsMarkType(t))continue;let s=[],o=t=>{s.push(t);for(let r=0;r<t.edgeCount;r++){let{type:n,next:i}=t.edge(r);if(n==e)return true;if(s.indexOf(i)<0&&o(i))return true}};if(o(i.contentMatch))return true}}class Ot{constructor(t,e){this.nodes=t;this.marks=e}serializeFragment(t,e={},r){if(!r)r=Ct(e).createDocumentFragment();let n=r,i=[];t.forEach((t=>{if(i.length||t.marks.length){let r=0,s=0;while(r<i.length&&s<t.marks.length){let e=t.marks[s];if(!this.marks[e.type.name]){s++;continue}if(!e.eq(i[r][0])||e.type.spec.spanning===false)break;r++;s++}while(r<i.length)n=i.pop()[1];while(s<t.marks.length){let r=t.marks[s++];let o=this.serializeMark(r,t.isInline,e);if(o){i.push([r,n]);n.appendChild(o.dom);n=o.contentDOM||o.dom}}}n.appendChild(this.serializeNodeInner(t,e))}));return r}serializeNodeInner(t,e){let{dom:r,contentDOM:n}=It(Ct(e),this.nodes[t.type.name](t),null,t.attrs);if(n){if(t.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(t.content,e,n)}return r}serializeNode(t,e={}){let r=this.serializeNodeInner(t,e);for(let n=t.marks.length-1;n>=0;n--){let i=this.serializeMark(t.marks[n],t.isInline,e);if(i){(i.contentDOM||i.dom).appendChild(r);r=i.dom}}return r}serializeMark(t,e,r={}){let n=this.marks[t.type.name];return n&&It(Ct(r),n(t,e),null,t.attrs)}static renderSpec(t,e,r=null,n){return It(t,e,r,n)}static fromSchema(t){return t.cached.domSerializer||(t.cached.domSerializer=new Ot(this.nodesFromSchema(t),this.marksFromSchema(t)))}static nodesFromSchema(t){let e=Rt(t.nodes);if(!e.text)e.text=t=>t.text;return e}static marksFromSchema(t){return Rt(t.marks)}}function Rt(t){let e={};for(let r in t){let n=t[r].spec.toDOM;if(n)e[r]=n}return e}function Ct(t){return t.document||window.document}const Lt=new WeakMap;function Nt(t){let e=Lt.get(t);if(e===undefined)Lt.set(t,e=Pt(t));return e}function Pt(t){let e=null;function r(t){if(t&&typeof t=="object"){if(Array.isArray(t)){if(typeof t[0]=="string"){if(!e)e=[];e.push(t)}else{for(let e=0;e<t.length;e++)r(t[e])}}else{for(let e in t)r(t[e])}}}r(t);return e}function It(t,e,r,n){if(typeof e=="string")return{dom:t.createTextNode(e)};if(e.nodeType!=null)return{dom:e};if(e.dom&&e.dom.nodeType!=null)return e;let i=e[0],s;if(typeof i!="string")throw new RangeError("Invalid array passed to renderSpec");if(n&&(s=Nt(n))&&s.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let o=i.indexOf(" ");if(o>0){r=i.slice(0,o);i=i.slice(o+1)}let l;let u=r?t.createElementNS(r,i):t.createElement(i);let a=e[1],f=1;if(a&&typeof a=="object"&&a.nodeType==null&&!Array.isArray(a)){f=2;for(let t in a)if(a[t]!=null){let e=t.indexOf(" ");if(e>0)u.setAttributeNS(t.slice(0,e),t.slice(e+1),a[t]);else if(t=="style"&&u.style)u.style.cssText=a[t];else u.setAttribute(t,a[t])}}for(let i=f;i<e.length;i++){let s=e[i];if(s===0){if(i<e.length-1||i>f)throw new RangeError("Content hole must be the only child of its parent node");return{dom:u,contentDOM:u}}else{let{dom:e,contentDOM:i}=It(t,s,r,n);u.appendChild(e);if(i){if(l)throw new RangeError("Multiple content holes");l=i}}}return{dom:u,contentDOM:l}}const Dt=65535;const Ht=Math.pow(2,16);function jt(t,e){return t+e*Ht}function _t(t){return t&Dt}function zt(t){return(t-(t&Dt))/Ht}const Bt=1,Ft=2,Ut=4,qt=8;class Jt{constructor(t,e,r){this.pos=t;this.delInfo=e;this.recover=r}get deleted(){return(this.delInfo&qt)>0}get deletedBefore(){return(this.delInfo&(Bt|Ut))>0}get deletedAfter(){return(this.delInfo&(Ft|Ut))>0}get deletedAcross(){return(this.delInfo&Ut)>0}}class Kt{constructor(t,e=false){this.ranges=t;this.inverted=e;if(!t.length&&Kt.empty)return Kt.empty}recover(t){let e=0,r=_t(t);if(!this.inverted)for(let t=0;t<r;t++)e+=this.ranges[t*3+2]-this.ranges[t*3+1];return this.ranges[r*3]+e+zt(t)}mapResult(t,e=1){return this._map(t,e,false)}map(t,e=1){return this._map(t,e,true)}_map(t,e,r){let n=0,i=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?n:0);if(l>t)break;let u=this.ranges[o+i],a=this.ranges[o+s],f=l+u;if(t<=f){let i=!u?e:t==l?-1:t==f?1:e;let s=l+n+(i<0?0:a);if(r)return s;let h=t==(e<0?l:f)?null:jt(o/3,t-l);let c=t==l?Ft:t==f?Bt:Ut;if(e<0?t!=l:t!=f)c|=qt;return new Jt(s,c,h)}n+=a-u}return r?t+n:new Jt(t+n,0,null)}touches(t,e){let r=0,n=_t(e);let i=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+i],u=o+l;if(t<=u&&e==n*3)return true;r+=this.ranges[e+s]-l}return false}forEach(t){let e=this.inverted?2:1,r=this.inverted?1:2;for(let n=0,i=0;n<this.ranges.length;n+=3){let s=this.ranges[n],o=s-(this.inverted?i:0),l=s+(this.inverted?0:i);let u=this.ranges[n+e],a=this.ranges[n+r];t(o,o+u,l,l+a);i+=a-u}}invert(){return new Kt(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(t){return t==0?Kt.empty:new Kt(t<0?[0,-t,0]:[0,0,t])}}Kt.empty=new Kt([]);class Wt{constructor(t,e,r=0,n=(t?t.length:0)){this.mirror=e;this.from=r;this.to=n;this._maps=t||[];this.ownData=!(t||e)}get maps(){return this._maps}slice(t=0,e=this.maps.length){return new Wt(this._maps,this.mirror,t,e)}appendMap(t,e){if(!this.ownData){this._maps=this._maps.slice();this.mirror=this.mirror&&this.mirror.slice();this.ownData=true}this.to=this._maps.push(t);if(e!=null)this.setMirror(this._maps.length-1,e)}appendMapping(t){for(let e=0,r=this._maps.length;e<t._maps.length;e++){let n=t.getMirror(e);this.appendMap(t._maps[e],n!=null&&n<e?r+n:undefined)}}getMirror(t){if(this.mirror)for(let e=0;e<this.mirror.length;e++)if(this.mirror[e]==t)return this.mirror[e+(e%2?-1:1)]}setMirror(t,e){if(!this.mirror)this.mirror=[];this.mirror.push(t,e)}appendMappingInverted(t){for(let e=t.maps.length-1,r=this._maps.length+t._maps.length;e>=0;e--){let n=t.getMirror(e);this.appendMap(t._maps[e].invert(),n!=null&&n>e?r-n-1:undefined)}}invert(){let t=new Wt;t.appendMappingInverted(this);return t}map(t,e=1){if(this.mirror)return this._map(t,e,true);for(let r=this.from;r<this.to;r++)t=this._maps[r].map(t,e);return t}mapResult(t,e=1){return this._map(t,e,false)}_map(t,e,r){let n=0;for(let r=this.from;r<this.to;r++){let i=this._maps[r],s=i.mapResult(t,e);if(s.recover!=null){let e=this.getMirror(r);if(e!=null&&e>r&&e<this.to){r=e;t=this._maps[e].recover(s.recover);continue}}n|=s.delInfo;t=s.pos}return r?t:new Jt(t,n,null)}}const Vt=Object.create(null);class Gt{getMap(){return Kt.empty}merge(t){return null}static fromJSON(t,e){if(!e||!e.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=Vt[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 Vt)throw new RangeError("Duplicate use of step JSON ID "+t);Vt[t]=e;e.prototype.jsonID=t;return e}}class Zt{constructor(t,e){this.doc=t;this.failed=e}static ok(t){return new Zt(t,null)}static fail(t){return new Zt(null,t)}static fromReplace(t,e,r,n){try{return Zt.ok(t.replace(e,r,n))}catch(t){if(t instanceof v)return Zt.fail(t.message);throw t}}}function Qt(t,e,r){let n=[];for(let i=0;i<t.childCount;i++){let s=t.child(i);if(s.content.size)s=s.copy(Qt(s.content,e,s));if(s.isInline)s=e(s,r,i);n.push(s)}return m.fromArray(n)}class Xt extends Gt{constructor(t,e,r){super();this.from=t;this.to=e;this.mark=r}apply(t){let e=t.slice(this.from,this.to),r=t.resolve(this.from);let n=r.node(r.sharedDepth(this.to));let i=new y(Qt(e.content,((t,e)=>{if(!t.isAtom||!e.type.allowsMarkType(this.mark.type))return t;return t.mark(this.mark.addToSet(t.marks))}),n),e.openStart,e.openEnd);return Zt.fromReplace(t,this.from,this.to,i)}invert(){return new Yt(this.from,this.to,this.mark)}map(t){let e=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);if(e.deleted&&r.deleted||e.pos>=r.pos)return null;return new Xt(e.pos,r.pos,this.mark)}merge(t){if(t instanceof Xt&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from)return new Xt(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark);return null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,e){if(typeof e.from!="number"||typeof e.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new Xt(e.from,e.to,t.markFromJSON(e.mark))}}Gt.jsonID("addMark",Xt);class Yt extends Gt{constructor(t,e,r){super();this.from=t;this.to=e;this.mark=r}apply(t){let e=t.slice(this.from,this.to);let r=new y(Qt(e.content,(t=>t.mark(this.mark.removeFromSet(t.marks))),t),e.openStart,e.openEnd);return Zt.fromReplace(t,this.from,this.to,r)}invert(){return new Xt(this.from,this.to,this.mark)}map(t){let e=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);if(e.deleted&&r.deleted||e.pos>=r.pos)return null;return new Yt(e.pos,r.pos,this.mark)}merge(t){if(t instanceof Yt&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from)return new Yt(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark);return null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,e){if(typeof e.from!="number"||typeof e.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new Yt(e.from,e.to,t.markFromJSON(e.mark))}}Gt.jsonID("removeMark",Yt);class te extends Gt{constructor(t,e){super();this.pos=t;this.mark=e}apply(t){let e=t.nodeAt(this.pos);if(!e)return Zt.fail("No node at mark step's position");let r=e.type.create(e.attrs,null,this.mark.addToSet(e.marks));return Zt.fromReplace(t,this.pos,this.pos+1,new y(m.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 te(this.pos,e.marks[r]);return new te(this.pos,this.mark)}}return new ee(this.pos,this.mark)}map(t){let e=t.mapResult(this.pos,1);return e.deletedAfter?null:new te(e.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,e){if(typeof e.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new te(e.pos,t.markFromJSON(e.mark))}}Gt.jsonID("addNodeMark",te);class ee extends Gt{constructor(t,e){super();this.pos=t;this.mark=e}apply(t){let e=t.nodeAt(this.pos);if(!e)return Zt.fail("No node at mark step's position");let r=e.type.create(e.attrs,null,this.mark.removeFromSet(e.marks));return Zt.fromReplace(t,this.pos,this.pos+1,new y(m.from(r),0,e.isLeaf?0:1))}invert(t){let e=t.nodeAt(this.pos);if(!e||!this.mark.isInSet(e.marks))return this;return new te(this.pos,this.mark)}map(t){let e=t.mapResult(this.pos,1);return e.deletedAfter?null:new ee(e.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,e){if(typeof e.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new ee(e.pos,t.markFromJSON(e.mark))}}Gt.jsonID("removeNodeMark",ee);class re extends Gt{constructor(t,e,r,n=false){super();this.from=t;this.to=e;this.slice=r;this.structure=n}apply(t){if(this.structure&&ie(t,this.from,this.to))return Zt.fail("Structure replace would overwrite content");return Zt.fromReplace(t,this.from,this.to,this.slice)}getMap(){return new Kt([this.from,this.to-this.from,this.slice.size])}invert(t){return new re(this.from,this.from+this.slice.size,t.slice(this.from,this.to))}map(t){let e=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);if(e.deletedAcross&&r.deletedAcross)return null;return new re(e.pos,Math.max(e.pos,r.pos),this.slice,this.structure)}merge(t){if(!(t instanceof re)||t.structure||this.structure)return null;if(this.from+this.slice.size==t.from&&!this.slice.openEnd&&!t.slice.openStart){let e=this.slice.size+t.slice.size==0?y.empty:new y(this.slice.content.append(t.slice.content),this.slice.openStart,t.slice.openEnd);return new re(this.from,this.to+(t.to-t.from),e,this.structure)}else if(t.to==this.from&&!this.slice.openStart&&!t.slice.openEnd){let e=this.slice.size+t.slice.size==0?y.empty:new y(t.slice.content.append(this.slice.content),t.slice.openStart,this.slice.openEnd);return new re(t.from,this.to,e,this.structure)}else{return null}}toJSON(){let t={stepType:"replace",from:this.from,to:this.to};if(this.slice.size)t.slice=this.slice.toJSON();if(this.structure)t.structure=true;return t}static fromJSON(t,e){if(typeof e.from!="number"||typeof e.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new re(e.from,e.to,y.fromJSON(t,e.slice),!!e.structure)}}Gt.jsonID("replace",re);class ne extends Gt{constructor(t,e,r,n,i,s,o=false){super();this.from=t;this.to=e;this.gapFrom=r;this.gapTo=n;this.slice=i;this.insert=s;this.structure=o}apply(t){if(this.structure&&(ie(t,this.from,this.gapFrom)||ie(t,this.gapTo,this.to)))return Zt.fail("Structure gap-replace would overwrite content");let e=t.slice(this.gapFrom,this.gapTo);if(e.openStart||e.openEnd)return Zt.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,e.content);if(!r)return Zt.fail("Content does not fit in gap");return Zt.fromReplace(t,this.from,this.to,r)}getMap(){return new Kt([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 ne(this.from,this.from+this.slice.size+e,this.from+this.insert,this.from+this.insert+e,t.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(t){let e=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);let n=this.from==this.gapFrom?e.pos:t.map(this.gapFrom,-1);let i=this.to==this.gapTo?r.pos:t.map(this.gapTo,1);if(e.deletedAcross&&r.deletedAcross||n<e.pos||i>r.pos)return null;return new ne(e.pos,r.pos,n,i,this.slice,this.insert,this.structure)}toJSON(){let t={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};if(this.slice.size)t.slice=this.slice.toJSON();if(this.structure)t.structure=true;return t}static fromJSON(t,e){if(typeof e.from!="number"||typeof e.to!="number"||typeof e.gapFrom!="number"||typeof e.gapTo!="number"||typeof e.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new ne(e.from,e.to,e.gapFrom,e.gapTo,y.fromJSON(t,e.slice),e.insert,!!e.structure)}}Gt.jsonID("replaceAround",ne);function ie(t,e,r){let n=t.resolve(e),i=r-e,s=n.depth;while(i>0&&s>0&&n.indexAfter(s)==n.node(s).childCount){s--;i--}if(i>0){let t=n.node(s).maybeChild(n.indexAfter(s));while(i>0){if(!t||t.isLeaf)return true;t=t.firstChild;i--}}return false}function se(t,e,r,n){let i=[],s=[];let o,l;t.doc.nodesBetween(e,r,((t,u,a)=>{if(!t.isInline)return;let f=t.marks;if(!n.isInSet(f)&&a.type.allowsMarkType(n.type)){let a=Math.max(u,e),h=Math.min(u+t.nodeSize,r);let c=n.addToSet(f);for(let t=0;t<f.length;t++){if(!f[t].isInSet(c)){if(o&&o.to==a&&o.mark.eq(f[t]))o.to=h;else i.push(o=new Yt(a,h,f[t]))}}if(l&&l.to==a)l.to=h;else s.push(l=new Xt(a,h,n))}}));i.forEach((e=>t.step(e)));s.forEach((e=>t.step(e)))}function oe(t,e,r,n){let i=[],s=0;t.doc.nodesBetween(e,r,((t,o)=>{if(!t.isInline)return;s++;let l=null;if(n instanceof ft){let e=t.marks,r;while(r=n.isInSet(e)){(l||(l=[])).push(r);e=r.removeFromSet(e)}}else if(n){if(n.isInSet(t.marks))l=[n]}else{l=t.marks}if(l&&l.length){let n=Math.min(o+t.nodeSize,r);for(let t=0;t<l.length;t++){let r=l[t],u;for(let t=0;t<i.length;t++){let e=i[t];if(e.step==s-1&&r.eq(i[t].style))u=e}if(u){u.to=n;u.step=s}else{i.push({style:r,from:Math.max(o,e),to:n,step:s})}}}}));i.forEach((e=>t.step(new Yt(e.from,e.to,e.style))))}function le(t,e,r,n=r.contentMatch,i=true){let s=t.doc.nodeAt(e);let o=[],l=e+1;for(let e=0;e<s.childCount;e++){let u=s.child(e),a=l+u.nodeSize;let f=n.matchType(u.type);if(!f){o.push(new re(l,a,y.empty))}else{n=f;for(let e=0;e<u.marks.length;e++)if(!r.allowsMarkType(u.marks[e].type))t.step(new Yt(l,a,u.marks[e]));if(i&&u.isText&&r.whitespace!="pre"){let t,e=/\r?\n|\r/g,n;while(t=e.exec(u.text)){if(!n)n=new y(m.from(r.schema.text(" ",r.allowedMarks(u.marks))),0,0);o.push(new re(l+t.index,l+t.index+t[0].length,n))}}}l=a}if(!n.validEnd){let e=n.fillBefore(m.empty,true);t.replace(l,l,new y(e,0,0))}for(let e=o.length-1;e>=0;e--)t.step(o[e])}function ue(t,e,r){return(e==0||t.canReplace(e,t.childCount))&&(r==t.childCount||t.canReplace(0,r))}function ae(t){let e=t.parent;let r=e.content.cutByIndex(t.startIndex,t.endIndex);for(let e=t.depth;;--e){let n=t.$from.node(e);let i=t.$from.index(e),s=t.$to.indexAfter(e);if(e<t.depth&&n.canReplace(i,s,r))return e;if(e==0||n.type.spec.isolating||!ue(n,i,s))break}return null}function fe(t,e,r){let{$from:n,$to:i,depth:s}=e;let o=n.before(s+1),l=i.after(s+1);let u=o,a=l;let f=m.empty,h=0;for(let t=s,e=false;t>r;t--)if(e||n.index(t)>0){e=true;f=m.from(n.node(t).copy(f));h++}else{u--}let c=m.empty,d=0;for(let t=s,e=false;t>r;t--)if(e||i.after(t+1)<i.end(t)){e=true;c=m.from(i.node(t).copy(c));d++}else{a++}t.step(new ne(u,a,o,l,new y(f.append(c),h,d),f.size-h,true))}function he(t,e,r=null,n=t){let i=de(t,e);let s=i&&pe(n,e);if(!s)return null;return i.map(ce).concat({type:e,attrs:r}).concat(s.map(ce))}function ce(t){return{type:t,attrs:null}}function de(t,e){let{parent:r,startIndex:n,endIndex:i}=t;let s=r.contentMatchAt(n).findWrapping(e);if(!s)return null;let o=s.length?s[0]:e;return r.canReplaceWith(n,i,o)?s:null}function pe(t,e){let{parent:r,startIndex:n,endIndex:i}=t;let s=r.child(n);let o=e.contentMatch.findWrapping(s.type);if(!o)return null;let l=o.length?o[o.length-1]:e;let u=l.contentMatch;for(let t=n;u&&t<i;t++)u=u.matchType(r.child(t).type);if(!u||!u.validEnd)return null;return o}function me(t,e,r){let n=m.empty;for(let t=r.length-1;t>=0;t--){if(n.size){let e=r[t].type.contentMatch.matchFragment(n);if(!e||!e.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}n=m.from(r[t].type.create(r[t].attrs,n))}let i=e.start,s=e.end;t.step(new ne(i,s,i,s,new y(n,0,0),r.length,true))}function ge(t,e,r,n,i){if(!n.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=typeof i=="function"?i(e):i;if(e.isTextblock&&!e.hasMarkup(n,o)&&ke(t.doc,t.mapping.slice(s).map(r),n)){let i=null;if(n.schema.linebreakReplacement){let t=n.whitespace=="pre",e=!!n.contentMatch.matchType(n.schema.linebreakReplacement);if(t&&!e)i=false;else if(!t&&e)i=true}if(i===false)be(t,e,r,s);le(t,t.mapping.slice(s).map(r,1),n,undefined,i===null);let l=t.mapping.slice(s);let u=l.map(r,1),a=l.map(r+e.nodeSize,1);t.step(new ne(u,a,u+1,a-1,new y(m.from(n.create(o,null,e.marks)),0,0),1,true));if(i===true)we(t,e,r,s);return false}}))}function we(t,e,r,n){e.forEach(((i,s)=>{if(i.isText){let o,l=/\r?\n|\r/g;while(o=l.exec(i.text)){let i=t.mapping.slice(n).map(r+1+s+o.index);t.replaceWith(i,i+1,e.type.schema.linebreakReplacement.create())}}}))}function be(t,e,r,n){e.forEach(((i,s)=>{if(i.type==i.type.schema.linebreakReplacement){let i=t.mapping.slice(n).map(r+1+s);t.replaceWith(i,i+1,e.type.schema.text("\n"))}}))}function ke(t,e,r){let n=t.resolve(e),i=n.index();return n.parent.canReplaceWith(i,i+1,r)}function ve(t,e,r,n,i){let s=t.doc.nodeAt(e);if(!s)throw new RangeError("No node at given position");if(!r)r=s.type;let o=r.create(n,null,i||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 ne(e,e+s.nodeSize,e+1,e+s.nodeSize-1,new y(m.from(o),0,0),1,true))}function ye(t,e,r=1,n){let i=t.resolve(e),s=i.depth-r;let o=n&&n[n.length-1]||i.parent;if(s<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!o.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return false;for(let t=i.depth-1,e=r-2;t>s;t--,e--){let r=i.node(t),s=i.index(t);if(r.type.spec.isolating)return false;let o=r.content.cutByIndex(s,r.childCount);let l=n&&n[e+1];if(l)o=o.replaceChild(0,l.type.create(l.attrs));let u=n&&n[e]||r;if(!r.canReplace(s+1,r.childCount)||!u.type.validContent(o))return false}let l=i.indexAfter(s);let u=n&&n[0];return i.node(s).canReplaceWith(l,l,u?u.type:i.node(s+1).type)}function Me(t,e,r=1,n){let i=t.doc.resolve(e),s=m.empty,o=m.empty;for(let t=i.depth,e=i.depth-r,l=r-1;t>e;t--,l--){s=m.from(i.node(t).copy(s));let e=n&&n[l];o=m.from(e?e.type.create(e.attrs,o):i.node(t).copy(o))}t.step(new re(e,e,new y(s.append(o),r,r),true))}function xe(t,e){let r=t.resolve(e),n=r.index();return Te(r.nodeBefore,r.nodeAfter)&&r.parent.canReplace(n,n+1)}function Se(t,e){if(!e.content.size)t.type.compatibleContent(e.type);let r=t.contentMatchAt(t.childCount);let{linebreakReplacement:n}=t.type.schema;for(let i=0;i<e.childCount;i++){let s=e.child(i);let o=s.type==n?t.type.schema.nodes.text:s.type;r=r.matchType(o);if(!r)return false;if(!t.type.allowsMarks(s.marks))return false}return r.validEnd}function Te(t,e){return!!(t&&e&&!t.isLeaf&&Se(t,e))}function Ee(t,e,r=-1){let n=t.resolve(e);for(let t=n.depth;;t--){let i,s,o=n.index(t);if(t==n.depth){i=n.nodeBefore;s=n.nodeAfter}else if(r>0){i=n.node(t+1);o++;s=n.node(t).maybeChild(o)}else{i=n.node(t).maybeChild(o-1);s=n.node(t+1)}if(i&&!i.isTextblock&&Te(i,s)&&n.node(t).canReplace(o,o+1))return e;if(t==0)break;e=r<0?n.before(t):n.after(t)}}function $e(t,e,r){let n=null;let{linebreakReplacement:i}=t.doc.type.schema;let s=t.doc.resolve(e-r),o=s.node().type;if(i&&o.inlineContent){let t=o.whitespace=="pre";let e=!!o.contentMatch.matchType(i);if(t&&!e)n=false;else if(!t&&e)n=true}let l=t.steps.length;if(n===false){let n=t.doc.resolve(e+r);be(t,n.node(),n.before(),l)}if(o.inlineContent)le(t,e+r-1,o,s.node().contentMatchAt(s.index()),n==null);let u=t.mapping.slice(l),a=u.map(e-r);t.step(new re(a,u.map(e+r,-1),y.empty,true));if(n===true){let e=t.doc.resolve(a);we(t,e.node(),e.before(),t.steps.length)}return t}function Ae(t,e,r){let n=t.resolve(e);if(n.parent.canReplaceWith(n.index(),n.index(),r))return e;if(n.parentOffset==0)for(let t=n.depth-1;t>=0;t--){let e=n.index(t);if(n.node(t).canReplaceWith(e,e,r))return n.before(t+1);if(e>0)return null}if(n.parentOffset==n.parent.content.size)for(let t=n.depth-1;t>=0;t--){let e=n.indexAfter(t);if(n.node(t).canReplaceWith(e,e,r))return n.after(t+1);if(e<n.node(t).childCount)return null}return null}function Oe(t,e,r){let n=t.resolve(e);if(!r.content.size)return e;let i=r.content;for(let t=0;t<r.openStart;t++)i=i.firstChild.content;for(let t=1;t<=(r.openStart==0&&r.size?2:1);t++){for(let e=n.depth;e>=0;e--){let r=e==n.depth?0:n.pos<=(n.start(e+1)+n.end(e+1))/2?-1:1;let s=n.index(e)+(r>0?1:0);let o=n.node(e),l=false;if(t==1){l=o.canReplace(s,s,i)}else{let t=o.contentMatchAt(s).findWrapping(i.firstChild.type);l=t&&o.canReplaceWith(s,s,t[0])}if(l)return r==0?n.pos:r<0?n.before(e+1):n.after(e+1)}}return null}function Re(t,e,r=e,n=y.empty){if(e==r&&!n.size)return null;let i=t.resolve(e),s=t.resolve(r);if(Ce(i,s,n))return new re(e,r,n);return new Le(i,s,n).fit()}function Ce(t,e,r){return!r.openStart&&!r.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),r.content)}class Le{constructor(t,e,r){this.$from=t;this.$to=e;this.unplaced=r;this.frontier=[];this.placed=m.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=m.from(t.node(e).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){while(this.unplaced.size){let t=this.findFittable();if(t)this.placeNodes(t);else this.openMore()||this.dropNode()}let t=this.mustMoveInline(),e=this.placed.size-this.depth-this.$from.depth;let r=this.$from,n=this.close(t<0?this.$to:r.doc.resolve(t));if(!n)return null;let i=this.placed,s=r.depth,o=n.depth;while(s&&o&&i.childCount==1){i=i.firstChild.content;s--;o--}let l=new y(i,s,o);if(t>-1)return new ne(r.pos,t,this.$to.pos,this.$to.end(),l,e);if(l.size||r.pos!=this.$to.pos)return new re(r.pos,n.pos,l);return null}findFittable(){let t=this.unplaced.openStart;for(let e=this.unplaced.content,r=0,n=this.unplaced.openEnd;r<t;r++){let i=e.firstChild;if(e.childCount>1)n=0;if(i.type.spec.isolating&&n<=r){t=r;break}e=i.content}for(let e=1;e<=2;e++){for(let r=e==1?t:this.unplaced.openStart;r>=0;r--){let t,n=null;if(r){n=Ie(this.unplaced.content,r-1).firstChild;t=n.content}else{t=this.unplaced.content}let i=t.firstChild;for(let t=this.depth;t>=0;t--){let{type:s,match:o}=this.frontier[t],l,u=null;if(e==1&&(i?o.matchType(i.type)||(u=o.fillBefore(m.from(i),false)):n&&s.compatibleContent(n.type)))return{sliceDepth:r,frontierDepth:t,parent:n,inject:u};else if(e==2&&i&&(l=o.findWrapping(i.type)))return{sliceDepth:r,frontierDepth:t,parent:n,wrap:l};if(n&&o.matchType(n.type))break}}}}openMore(){let{content:t,openStart:e,openEnd:r}=this.unplaced;let n=Ie(t,e);if(!n.childCount||n.firstChild.isLeaf)return false;this.unplaced=new y(t,e+1,Math.max(r,n.size+e>=t.size-r?e+1:0));return true}dropNode(){let{content:t,openStart:e,openEnd:r}=this.unplaced;let n=Ie(t,e);if(n.childCount<=1&&e>0){let i=t.size-e<=e+n.size;this.unplaced=new y(Ne(t,e-1,1),e-1,i?e-1:r)}else{this.unplaced=new y(Ne(t,e,1),e,r)}}placeNodes({sliceDepth:t,frontierDepth:e,parent:r,inject:n,wrap:i}){while(this.depth>e)this.closeFrontierNode();if(i)for(let t=0;t<i.length;t++)this.openFrontierNode(i[t]);let s=this.unplaced,o=r?r.content:s.content;let l=s.openStart-t;let u=0,a=[];let{match:f,type:h}=this.frontier[e];if(n){for(let t=0;t<n.childCount;t++)a.push(n.child(t));f=f.matchFragment(n)}let c=o.size+t-(s.content.size-s.openEnd);while(u<o.childCount){let t=o.child(u),e=f.matchType(t.type);if(!e)break;u++;if(u>1||l==0||t.content.size){f=e;a.push(De(t.mark(h.allowedMarks(t.marks)),u==1?l:0,u==o.childCount?c:-1))}}let d=u==o.childCount;if(!d)c=-1;this.placed=Pe(this.placed,e,m.from(a));this.frontier[e].match=f;if(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?new y(Ne(s.content,t,u),s.openStart,s.openEnd):t==0?y.empty:new y(Ne(s.content,t-1,1),t-1,c<0?s.openEnd:t-1)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let t=this.frontier[this.depth],e;if(!t.type.isTextblock||!He(this.$to,this.$to.depth,t.type,t.match,false)||this.$to.depth==this.depth&&(e=this.findCloseLevel(this.$to))&&e.depth==this.depth)return-1;let{depth:r}=this.$to,n=this.$to.after(r);while(r>1&&n==this.$to.end(--r))++n;return n}findCloseLevel(t){t:for(let e=Math.min(this.depth,t.depth);e>=0;e--){let{match:r,type:n}=this.frontier[e];let i=e<t.depth&&t.end(e+1)==t.pos+(t.depth-(e+1));let s=He(t,e,n,r,i);if(!s)continue;for(let r=e-1;r>=0;r--){let{match:e,type:n}=this.frontier[r];let i=He(t,r,n,e,true);if(!i||i.childCount)continue t}return{depth:e,fit:s,move:i?t.doc.resolve(t.after(e+1)):t}}}close(t){let e=this.findCloseLevel(t);if(!e)return null;while(this.depth>e.depth)this.closeFrontierNode();if(e.fit.childCount)this.placed=Pe(this.placed,e.depth,e.fit);t=e.move;for(let r=e.depth+1;r<=t.depth;r++){let e=t.node(r),n=e.type.contentMatch.fillBefore(e.content,true,t.index(r));this.openFrontierNode(e.type,e.attrs,n)}return t}openFrontierNode(t,e=null,r){let n=this.frontier[this.depth];n.match=n.match.matchType(t);this.placed=Pe(this.placed,this.depth,m.from(t.create(e,r)));this.frontier.push({type:t,match:t.contentMatch})}closeFrontierNode(){let t=this.frontier.pop();let e=t.match.fillBefore(m.empty,true);if(e.childCount)this.placed=Pe(this.placed,this.frontier.length,e)}}function Ne(t,e,r){if(e==0)return t.cutByIndex(r,t.childCount);return t.replaceChild(0,t.firstChild.copy(Ne(t.firstChild.content,e-1,r)))}function Pe(t,e,r){if(e==0)return t.append(r);return t.replaceChild(t.childCount-1,t.lastChild.copy(Pe(t.lastChild.content,e-1,r)))}function Ie(t,e){for(let r=0;r<e;r++)t=t.firstChild.content;return t}function De(t,e,r){if(e<=0)return t;let n=t.content;if(e>1)n=n.replaceChild(0,De(n.firstChild,e-1,n.childCount==1?r-1:0));if(e>0){n=t.type.contentMatch.fillBefore(n).append(n);if(r<=0)n=n.append(t.type.contentMatch.matchFragment(n).fillBefore(m.empty,true))}return t.copy(n)}function He(t,e,r,n,i){let s=t.node(e),o=i?t.indexAfter(e):t.index(e);if(o==s.childCount&&!r.compatibleContent(s.type))return null;let l=n.fillBefore(s.content,true,o);return l&&!je(r,s.content,o)?l:null}function je(t,e,r){for(let n=r;n<e.childCount;n++)if(!t.allowsMarks(e.child(n).marks))return true;return false}function _e(t){return t.spec.defining||t.spec.definingForContent}function ze(t,e,r,n){if(!n.size)return t.deleteRange(e,r);let i=t.doc.resolve(e),s=t.doc.resolve(r);if(Ce(i,s,n))return t.step(new re(e,r,n));let o=qe(i,t.doc.resolve(r));if(o[o.length-1]==0)o.pop();let l=-(i.depth+1);o.unshift(l);for(let t=i.depth,e=i.pos-1;t>0;t--,e--){let r=i.node(t).type.spec;if(r.defining||r.definingAsContext||r.isolating)break;if(o.indexOf(t)>-1)l=t;else if(i.before(t)==e)o.splice(1,0,-t)}let u=o.indexOf(l);let a=[],f=n.openStart;for(let t=n.content,e=0;;e++){let r=t.firstChild;a.push(r);if(e==n.openStart)break;t=r.content}for(let t=f-1;t>=0;t--){let e=a[t],r=_e(e.type);if(r&&!e.sameMarkup(i.node(Math.abs(l)-1)))f=t;else if(r||!e.type.isTextblock)break}for(let e=n.openStart;e>=0;e--){let l=(e+f+1)%(n.openStart+1);let h=a[l];if(!h)continue;for(let e=0;e<o.length;e++){let a=o[(e+u)%o.length],f=true;if(a<0){f=false;a=-a}let c=i.node(a-1),d=i.index(a-1);if(c.canReplaceWith(d,d,h.type,h.marks))return t.replace(i.before(a),f?s.after(a):r,new y(Be(n.content,0,n.openStart,l),l,n.openEnd))}}let h=t.steps.length;for(let l=o.length-1;l>=0;l--){t.replace(e,r,n);if(t.steps.length>h)break;let u=o[l];if(u<0)continue;e=i.before(u);r=s.after(u)}}function Be(t,e,r,n,i){if(e<r){let i=t.firstChild;t=t.replaceChild(0,i.copy(Be(i.content,e+1,r,n,i)))}if(e>n){let e=i.contentMatchAt(0);let r=e.fillBefore(t).append(t);t=r.append(e.matchFragment(r).fillBefore(m.empty,true))}return t}function Fe(t,e,r,n){if(!n.isInline&&e==r&&t.doc.resolve(e).parent.content.size){let i=Ae(t.doc,e,n.type);if(i!=null)e=r=i}t.replaceRange(e,r,new y(m.from(n),0,0))}function Ue(t,e,r){let n=t.doc.resolve(e),i=t.doc.resolve(r);let s=qe(n,i);for(let e=0;e<s.length;e++){let r=s[e],o=e==s.length-1;if(o&&r==0||n.node(r).type.contentMatch.validEnd)return t.delete(n.start(r),i.end(r));if(r>0&&(o||n.node(r-1).canReplace(n.index(r-1),i.indexAfter(r-1))))return t.delete(n.before(r),i.after(r))}for(let s=1;s<=n.depth&&s<=i.depth;s++){if(e-n.start(s)==n.depth-s&&r>n.end(s)&&i.end(s)-r!=i.depth-s&&n.start(s-1)==i.start(s-1)&&n.node(s-1).canReplace(n.index(s-1),i.index(s-1)))return t.delete(n.before(s),r)}t.delete(e,r)}function qe(t,e){let r=[],n=Math.min(t.depth,e.depth);for(let i=n;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;if(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 Gt{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 Zt.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 n=e.type.create(r,null,e.marks);return Zt.fromReplace(t,this.pos,this.pos+1,new y(m.from(n),0,e.isLeaf?0:1))}getMap(){return Kt.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(typeof e.pos!="number"||typeof e.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new Je(e.pos,e.attr,e.value)}}Gt.jsonID("attr",Je);class Ke extends Gt{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 Zt.ok(r)}getMap(){return Kt.empty}invert(t){return new Ke(this.attr,t.attrs[this.attr])}map(t){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(t,e){if(typeof e.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new Ke(e.attr,e.value)}}Gt.jsonID("docAttr",Ke);let We=class extends Error{};We=function t(e){let r=Error.call(this,e);r.__proto__=t.prototype;return r};We.prototype=Object.create(Error.prototype);We.prototype.constructor=We;We.prototype.name="TransformError";class Ve{constructor(t){this.doc=t;this.steps=[];this.docs=[];this.mapping=new Wt}get before(){return this.docs.length?this.docs[0]:this.doc}step(t){let e=this.maybeStep(t);if(e.failed)throw new We(e.failed);return this}maybeStep(t){let e=t.apply(this.doc);if(!e.failed)this.addStep(t,e.doc);return e}get docChanged(){return this.steps.length>0}addStep(t,e){this.docs.push(this.doc);this.steps.push(t);this.mapping.appendMap(t.getMap());this.doc=e}replace(t,e=t,r=y.empty){let n=Re(this.doc,t,e,r);if(n)this.step(n);return this}replaceWith(t,e,r){return this.replace(t,e,new y(m.from(r),0,0))}delete(t,e){return this.replace(t,e,y.empty)}insert(t,e){return this.replaceWith(t,t,e)}replaceRange(t,e,r){ze(this,t,e,r);return this}replaceRangeWith(t,e,r){Fe(this,t,e,r);return this}deleteRange(t,e){Ue(this,t,e);return this}lift(t,e){fe(this,t,e);return this}join(t,e=1){$e(this,t,e);return this}wrap(t,e){me(this,t,e);return this}setBlockType(t,e=t,r,n=null){ge(this,t,e,r,n);return this}setNodeMarkup(t,e,r=null,n){ve(this,t,e,r,n);return this}setNodeAttribute(t,e,r){this.step(new Je(t,e,r));return this}setDocAttribute(t,e){this.step(new Ke(t,e));return this}addNodeMark(t,e){this.step(new te(t,e));return this}removeNodeMark(t,e){let r=this.doc.nodeAt(t);if(!r)throw new RangeError("No node at position "+t);if(e instanceof k){if(e.isInSet(r.marks))this.step(new ee(t,e))}else{let n=r.marks,i,s=[];while(i=e.isInSet(n)){s.push(new ee(t,i));n=i.removeFromSet(n)}for(let t=s.length-1;t>=0;t--)this.step(s[t])}return this}split(t,e=1,r){Me(this,t,e,r);return this}addMark(t,e,r){se(this,t,e,r);return this}removeMark(t,e,r){oe(this,t,e,r);return this}clearIncompatible(t,e,r){le(this,t,e,r);return this}}const Ge=Object.create(null);class Ze{constructor(t,e,r){this.$anchor=t;this.$head=e;this.ranges=r||[new Qe(t.min(e),t.max(e))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let t=this.ranges;for(let e=0;e<t.length;e++)if(t[e].$from.pos!=t[e].$to.pos)return false;return true}content(){return this.$from.doc.slice(this.from,this.to,true)}replace(t,e=y.empty){let r=e.content.lastChild,n=null;for(let t=0;t<e.openEnd;t++){n=r;r=r.lastChild}let i=t.steps.length,s=this.ranges;for(let o=0;o<s.length;o++){let{$from:l,$to:u}=s[o],a=t.mapping.slice(i);t.replaceRange(a.map(l.pos),a.map(u.pos),o?y.empty:e);if(o==0)lr(t,i,(r?r.isInline:n&&n.isTextblock)?-1:1)}}replaceWith(t,e){let r=t.steps.length,n=this.ranges;for(let i=0;i<n.length;i++){let{$from:s,$to:o}=n[i],l=t.mapping.slice(r);let u=l.map(s.pos),a=l.map(o.pos);if(i){t.deleteRange(u,a)}else{t.replaceRangeWith(u,a,e);lr(t,r,e.isInline?-1:1)}}}static findFrom(t,e,r=false){let n=t.parent.inlineContent?new tr(t):or(t.node(0),t.parent,t.pos,t.index(),e,r);if(n)return n;for(let n=t.depth-1;n>=0;n--){let i=e<0?or(t.node(0),t.node(n),t.before(n+1),t.index(n),e,r):or(t.node(0),t.node(n),t.after(n+1),t.index(n)+1,e,r);if(i)return i}return null}static near(t,e=1){return this.findFrom(t,e)||this.findFrom(t,-e)||new ir(t.node(0))}static atStart(t){return or(t,t,0,0,1)||new ir(t)}static atEnd(t){return or(t,t,t.content.size,t.childCount,-1)||new ir(t)}static fromJSON(t,e){if(!e||!e.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Ge[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 Ge)throw new RangeError("Duplicate use of selection JSON ID "+t);Ge[t]=e;e.prototype.jsonID=t;return e}getBookmark(){return tr.between(this.$anchor,this.$head).getBookmark()}}Ze.prototype.visible=true;class Qe{constructor(t,e){this.$from=t;this.$to=e}}let Xe=false;function Ye(t){if(!Xe&&!t.parent.inlineContent){Xe=true;console["warn"]("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")")}}class tr extends Ze{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 Ze.near(r);let n=t.resolve(e.map(this.anchor));return new tr(n.parent.inlineContent?n:r,r)}replace(t,e=y.empty){super.replace(t,e);if(e==y.empty){let e=this.$from.marksAcross(this.$to);if(e)t.ensureMarks(e)}}eq(t){return t instanceof tr&&t.anchor==this.anchor&&t.head==this.head}getBookmark(){return new er(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(t,e){if(typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new tr(t.resolve(e.anchor),t.resolve(e.head))}static create(t,e,r=e){let n=t.resolve(e);return new this(n,r==e?n:t.resolve(r))}static between(t,e,r){let n=t.pos-e.pos;if(!r||n)r=n>=0?1:-1;if(!e.parent.inlineContent){let t=Ze.findFrom(e,r,true)||Ze.findFrom(e,-r,true);if(t)e=t.$head;else return Ze.near(e,r)}if(!t.parent.inlineContent){if(n==0){t=e}else{t=(Ze.findFrom(t,-r,true)||Ze.findFrom(t,r,true)).$anchor;if(t.pos<e.pos!=n<0)t=e}}return new tr(t,e)}}Ze.jsonID("text",tr);class er{constructor(t,e){this.anchor=t;this.head=e}map(t){return new er(t.map(this.anchor),t.map(this.head))}resolve(t){return tr.between(t.resolve(this.anchor),t.resolve(this.head))}}class rr extends Ze{constructor(t){let e=t.nodeAfter;let r=t.node(0).resolve(t.pos+e.nodeSize);super(t,r);this.node=e}map(t,e){let{deleted:r,pos:n}=e.mapResult(this.anchor);let i=t.resolve(n);if(r)return Ze.near(i);return new rr(i)}content(){return new y(m.from(this.node),0,0)}eq(t){return t instanceof rr&&t.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new nr(this.anchor)}static fromJSON(t,e){if(typeof e.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new rr(t.resolve(e.anchor))}static create(t,e){return new rr(t.resolve(e))}static isSelectable(t){return!t.isText&&t.type.spec.selectable!==false}}rr.prototype.visible=false;Ze.jsonID("node",rr);class nr{constructor(t){this.anchor=t}map(t){let{deleted:e,pos:r}=t.mapResult(this.anchor);return e?new er(r,r):new nr(r)}resolve(t){let e=t.resolve(this.anchor),r=e.nodeAfter;if(r&&rr.isSelectable(r))return new rr(e);return Ze.near(e)}}class ir extends Ze{constructor(t){super(t.resolve(0),t.resolve(t.content.size))}replace(t,e=y.empty){if(e==y.empty){t.delete(0,t.doc.content.size);let e=Ze.atStart(t.doc);if(!e.eq(t.selection))t.setSelection(e)}else{super.replace(t,e)}}toJSON(){return{type:"all"}}static fromJSON(t){return new ir(t)}map(t){return new ir(t)}eq(t){return t instanceof ir}getBookmark(){return sr}}Ze.jsonID("all",ir);const sr={map(){return this},resolve(t){return new ir(t)}};function or(t,e,r,n,i,s=false){if(e.inlineContent)return tr.create(t,r);for(let o=n-(i>0?0:1);i>0?o<e.childCount:o>=0;o+=i){let n=e.child(o);if(!n.isAtom){let e=or(t,n,r+i,i<0?n.childCount:0,i,s);if(e)return e}else if(!s&&rr.isSelectable(n)){return rr.create(t,r-(i<0?n.nodeSize:0))}r+=n.nodeSize*i}return null}function lr(t,e,r){let n=t.steps.length-1;if(n<e)return;let i=t.steps[n];if(!(i instanceof re||i instanceof ne))return;let s=t.mapping.maps[n],o;s.forEach(((t,e,r,n)=>{if(o==null)o=n}));t.setSelection(Ze.near(t.doc.resolve(o),r))}const ur=1,ar=2,fr=4;class hr extends Ve{constructor(t){super(t.doc);this.curSelectionFor=0;this.updated=0;this.meta=Object.create(null);this.time=Date.now();this.curSelection=t.selection;this.storedMarks=t.storedMarks}get selection(){if(this.curSelectionFor<this.steps.length){this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor));this.curSelectionFor=this.steps.length}return this.curSelection}setSelection(t){if(t.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");this.curSelection=t;this.curSelectionFor=this.steps.length;this.updated=(this.updated|ur)&~ar;this.storedMarks=null;return this}get selectionSet(){return(this.updated&ur)>0}setStoredMarks(t){this.storedMarks=t;this.updated|=ar;return this}ensureMarks(t){if(!k.sameSet(this.storedMarks||this.selection.$from.marks(),t))this.setStoredMarks(t);return this}addStoredMark(t){return this.ensureMarks(t.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(t){return this.ensureMarks(t.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&ar)>0}addStep(t,e){super.addStep(t,e);this.updated=this.updated&~ar;this.storedMarks=null}setTime(t){this.time=t;return this}replaceSelection(t){this.selection.replace(this,t);return this}replaceSelectionWith(t,e=true){let r=this.selection;if(e)t=t.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||k.none));r.replaceWith(this,t);return this}deleteSelection(){this.selection.replace(this);return this}insertText(t,e,r){let n=this.doc.type.schema;if(e==null){if(!t)return this.deleteSelection();return this.replaceSelectionWith(n.text(t),true)}else{if(r==null)r=e;r=r==null?e:r;if(!t)return this.deleteRange(e,r);let i=this.storedMarks;if(!i){let t=this.doc.resolve(e);i=r==e?t.marks():t.marksAcross(this.doc.resolve(r))}this.replaceRangeWith(e,r,n.text(t,i));if(!this.selection.empty)this.setSelection(Ze.near(this.selection.$to));return this}}setMeta(t,e){this.meta[typeof t=="string"?t:t.key]=e;return this}getMeta(t){return this.meta[typeof t=="string"?t:t.key]}get isGeneric(){for(let t in this.meta)return false;return true}scrollIntoView(){this.updated|=fr;return this}get scrolledIntoView(){return(this.updated&fr)>0}}function cr(t,e){return!e||!t?t:t.bind(e)}class dr{constructor(t,e,r){this.name=t;this.init=cr(e.init,r);this.apply=cr(e.apply,r)}}const pr=[new dr("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new dr("selection",{init(t,e){return t.selection||Ze.atStart(e.doc)},apply(t){return t.selection}}),new dr("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,r,n){return n.selection.$cursor?t.storedMarks:null}}),new dr("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class mr{constructor(t,e){this.schema=t;this.plugins=[];this.pluginsByKey=Object.create(null);this.fields=pr.slice();if(e)e.forEach((t=>{if(this.pluginsByKey[t.key])throw new RangeError("Adding different instances of a keyed plugin ("+t.key+")");this.plugins.push(t);this.pluginsByKey[t.key]=t;if(t.spec.state)this.fields.push(new dr(t.key,t.spec.state,t))}))}}class gr{constructor(t){this.config=t}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(t){return this.applyTransaction(t).state}filterTransaction(t,e=-1){for(let r=0;r<this.config.plugins.length;r++)if(r!=e){let e=this.config.plugins[r];if(e.spec.filterTransaction&&!e.spec.filterTransaction.call(e,t,this))return false}return true}applyTransaction(t){if(!this.filterTransaction(t))return{state:this,transactions:[]};let e=[t],r=this.applyInner(t),n=null;for(;;){let i=false;for(let s=0;s<this.config.plugins.length;s++){let o=this.config.plugins[s];if(o.spec.appendTransaction){let l=n?n[s].n:0,u=n?n[s].state:this;let a=l<e.length&&o.spec.appendTransaction.call(o,l?e.slice(l):e,u,r);if(a&&r.filterTransaction(a,s)){a.setMeta("appendedTransaction",t);if(!n){n=[];for(let t=0;t<this.config.plugins.length;t++)n.push(t<s?{state:r,n:e.length}:{state:this,n:0})}e.push(a);r=r.applyInner(a);i=true}if(n)n[s]={state:r,n:e.length}}}if(!i)return{state:r,transactions:e}}}applyInner(t){if(!t.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let e=new gr(this.config),r=this.config.fields;for(let n=0;n<r.length;n++){let i=r[n];e[i.name]=i.apply(t,this[i.name],this,e)}return e}get tr(){return new hr(this)}static create(t){let e=new mr(t.doc?t.doc.type.schema:t.schema,t.plugins);let r=new gr(e);for(let n=0;n<e.fields.length;n++)r[e.fields[n].name]=e.fields[n].init(t,r);return r}reconfigure(t){let e=new mr(this.schema,t.plugins);let r=e.fields,n=new gr(e);for(let e=0;e<r.length;e++){let i=r[e].name;n[i]=this.hasOwnProperty(i)?this[i]:r[e].init(t,n)}return n}toJSON(t){let e={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks)e.storedMarks=this.storedMarks.map((t=>t.toJSON()));if(t&&typeof t=="object")for(let r in t){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let n=t[r],i=n.spec.state;if(i&&i.toJSON)e[r]=i.toJSON.call(n,this[n.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 n=new mr(t.schema,t.plugins);let i=new gr(n);n.fields.forEach((n=>{if(n.name=="doc"){i.doc=z.fromJSON(t.schema,e.doc)}else if(n.name=="selection"){i.selection=Ze.fromJSON(i.doc,e.selection)}else if(n.name=="storedMarks"){if(e.storedMarks)i.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==n.name&&l&&l.fromJSON&&Object.prototype.hasOwnProperty.call(e,s)){i[n.name]=l.fromJSON.call(o,t,e[s],i);return}}i[n.name]=n.init(t,i)}}));return i}}function wr(t,e,r){for(let n in t){let i=t[n];if(i instanceof Function)i=i.bind(e);else if(n=="handleDOMEvents")i=wr(i,e,{});r[n]=i}return r}class br{constructor(t){this.spec=t;this.props={};if(t.props)wr(t.props,this,this.props);this.key=t.key?t.key.key:vr("plugin")}getState(t){return t[this.key]}}const kr=Object.create(null);function vr(t){if(t in kr)return t+"$"+ ++kr[t];kr[t]=0;return t+"$"}class yr{constructor(t="key"){this.key=vr(t)}get(t){return t.config.pluginsByKey[this.key]}getState(t){return t[this.key]}}const Mr=(t,e)=>{if(t.selection.empty)return false;if(e)e(t.tr.deleteSelection().scrollIntoView());return true};function xr(t,e){let{$cursor:r}=t.selection;if(!r||(e?!e.endOfTextblock("backward",t):r.parentOffset>0))return null;return r}const Sr=(t,e,r)=>{let n=xr(t,r);if(!n)return false;let i=Rr(n);if(!i){let r=n.blockRange(),i=r&&ae(r);if(i==null)return false;if(e)e(t.tr.lift(r,i).scrollIntoView());return true}let s=i.nodeBefore;if(Vr(t,i,e,-1))return true;if(n.parent.content.size==0&&(Ar(s,"end")||rr.isSelectable(s))){for(let r=n.depth;;r--){let o=Re(t.doc,n.before(r),n.after(r),y.empty);if(o&&o.slice.size<o.to-o.from){if(e){let r=t.tr.step(o);r.setSelection(Ar(s,"end")?Ze.findFrom(r.doc.resolve(r.mapping.map(i.pos,-1)),-1):rr.create(r.doc,i.pos-s.nodeSize));e(r.scrollIntoView())}return true}if(r==1||n.node(r-1).childCount>1)break}}if(s.isAtom&&i.depth==n.depth-1){if(e)e(t.tr.delete(i.pos-s.nodeSize,i.pos).scrollIntoView());return true}return false};const Tr=(t,e,r)=>{let n=xr(t,r);if(!n)return false;let i=Rr(n);return i?$r(t,i,e):false};const Er=(t,e,r)=>{let n=Cr(t,r);if(!n)return false;let i=Pr(n);return i?$r(t,i,e):false};function $r(t,e,r){let n=e.nodeBefore,i=n,s=e.pos-1;for(;!i.isTextblock;s--){if(i.type.spec.isolating)return false;let t=i.lastChild;if(!t)return false;i=t}let o=e.nodeAfter,l=o,u=e.pos+1;for(;!l.isTextblock;u++){if(l.type.spec.isolating)return false;let t=l.firstChild;if(!t)return false;l=t}let a=Re(t.doc,s,u,y.empty);if(!a||a.from!=s||a instanceof re&&a.slice.size>=u-s)return false;if(r){let e=t.tr.step(a);e.setSelection(tr.create(e.doc,s));r(e.scrollIntoView())}return true}function Ar(t,e,r=false){for(let n=t;n;n=e=="start"?n.firstChild:n.lastChild){if(n.isTextblock)return true;if(r&&n.childCount!=1)return false}return false}const Or=(t,e,r)=>{let{$head:n,empty:i}=t.selection,s=n;if(!i)return false;if(n.parent.isTextblock){if(r?!r.endOfTextblock("backward",t):n.parentOffset>0)return false;s=Rr(n)}let o=s&&s.nodeBefore;if(!o||!rr.isSelectable(o))return false;if(e)e(t.tr.setSelection(rr.create(t.doc,s.pos-o.nodeSize)).scrollIntoView());return true};function Rr(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 Cr(t,e){let{$cursor:r}=t.selection;if(!r||(e?!e.endOfTextblock("forward",t):r.parentOffset<r.parent.content.size))return null;return r}const Lr=(t,e,r)=>{let n=Cr(t,r);if(!n)return false;let i=Pr(n);if(!i)return false;let s=i.nodeAfter;if(Vr(t,i,e,1))return true;if(n.parent.content.size==0&&(Ar(s,"start")||rr.isSelectable(s))){let r=Re(t.doc,n.before(),n.after(),y.empty);if(r&&r.slice.size<r.to-r.from){if(e){let n=t.tr.step(r);n.setSelection(Ar(s,"start")?Ze.findFrom(n.doc.resolve(n.mapping.map(i.pos)),1):rr.create(n.doc,n.mapping.map(i.pos)));e(n.scrollIntoView())}return true}}if(s.isAtom&&i.depth==n.depth-1){if(e)e(t.tr.delete(i.pos,i.pos+s.nodeSize).scrollIntoView());return true}return false};const Nr=(t,e,r)=>{let{$head:n,empty:i}=t.selection,s=n;if(!i)return false;if(n.parent.isTextblock){if(r?!r.endOfTextblock("forward",t):n.parentOffset<n.parent.content.size)return false;s=Pr(n)}let o=s&&s.nodeAfter;if(!o||!rr.isSelectable(o))return false;if(e)e(t.tr.setSelection(rr.create(t.doc,s.pos)).scrollIntoView());return true};function Pr(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 Ir=(t,e)=>{let r=t.selection,n=r instanceof rr,i;if(n){if(r.node.isTextblock||!xe(t.doc,r.from))return false;i=r.from}else{i=Ee(t.doc,r.from,-1);if(i==null)return false}if(e){let r=t.tr.join(i);if(n)r.setSelection(rr.create(r.doc,i-t.doc.resolve(i).nodeBefore.nodeSize));e(r.scrollIntoView())}return true};const Dr=(t,e)=>{let r=t.selection,n;if(r instanceof rr){if(r.node.isTextblock||!xe(t.doc,r.to))return false;n=r.to}else{n=Ee(t.doc,r.to,1);if(n==null)return false}if(e)e(t.tr.join(n).scrollIntoView());return true};const Hr=(t,e)=>{let{$from:r,$to:n}=t.selection;let i=r.blockRange(n),s=i&&ae(i);if(s==null)return false;if(e)e(t.tr.lift(i,s).scrollIntoView());return true};const jr=(t,e)=>{let{$head:r,$anchor:n}=t.selection;if(!r.parent.type.spec.code||!r.sameParent(n))return false;if(e)e(t.tr.insertText("\n").scrollIntoView());return true};function _r(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 zr=(t,e)=>{let{$head:r,$anchor:n}=t.selection;if(!r.parent.type.spec.code||!r.sameParent(n))return false;let i=r.node(-1),s=r.indexAfter(-1),o=_r(i.contentMatchAt(s));if(!o||!i.canReplaceWith(s,s,o))return false;if(e){let n=r.after(),i=t.tr.replaceWith(n,n,o.createAndFill());i.setSelection(Ze.near(i.doc.resolve(n),1));e(i.scrollIntoView())}return true};const Br=(t,e)=>{let r=t.selection,{$from:n,$to:i}=r;if(r instanceof ir||n.parent.inlineContent||i.parent.inlineContent)return false;let s=_r(i.parent.contentMatchAt(i.indexAfter()));if(!s||!s.isTextblock)return false;if(e){let r=(!n.parentOffset&&i.index()<i.parent.childCount?n:i).pos;let o=t.tr.insert(r,s.createAndFill());o.setSelection(tr.create(o.doc,r+1));e(o.scrollIntoView())}return true};const Fr=(t,e)=>{let{$cursor:r}=t.selection;if(!r||r.parent.content.size)return false;if(r.depth>1&&r.after()!=r.end(-1)){let n=r.before();if(ye(t.doc,n)){if(e)e(t.tr.split(n).scrollIntoView());return true}}let n=r.blockRange(),i=n&&ae(n);if(i==null)return false;if(e)e(t.tr.lift(n,i).scrollIntoView());return true};function Ur(t){return(e,r)=>{let{$from:n,$to:i}=e.selection;if(e.selection instanceof rr&&e.selection.node.isBlock){if(!n.parentOffset||!ye(e.doc,n.pos))return false;if(r)r(e.tr.split(n.pos).scrollIntoView());return true}if(!n.depth)return false;let s=[];let o,l,u=false,a=false;for(let e=n.depth;;e--){let r=n.node(e);if(r.isBlock){u=n.end(e)==n.pos+(n.depth-e);a=n.start(e)==n.pos-(n.depth-e);l=_r(n.node(e-1).contentMatchAt(n.indexAfter(e-1)));let r=t&&t(i.parent,u,n);s.unshift(r||(u&&l?{type:l}:null));o=e;break}else{if(e==1)return false;s.unshift(null)}}let f=e.tr;if(e.selection instanceof tr||e.selection instanceof ir)f.deleteSelection();let h=f.mapping.map(n.pos);let c=ye(f.doc,h,s.length,s);if(!c){s[0]=l?{type:l}:null;c=ye(f.doc,h,s.length,s)}if(!c)return false;f.split(h,s.length,s);if(!u&&a&&n.node(o).type!=l){let t=f.mapping.map(n.before(o)),e=f.doc.resolve(t);if(l&&n.node(o-1).canReplaceWith(e.index(),e.index()+1,l))f.setNodeMarkup(f.mapping.map(n.before(o)),l)}if(r)r(f.scrollIntoView());return true}}const qr=Ur();const Jr=(t,e)=>{let{$from:r,to:n}=t.selection,i;let s=r.sharedDepth(n);if(s==0)return false;i=r.before(s);if(e)e(t.tr.setSelection(rr.create(t.doc,i)));return true};const Kr=(t,e)=>{if(e)e(t.tr.setSelection(new ir(t.doc)));return true};function Wr(t,e,r){let n=e.nodeBefore,i=e.nodeAfter,s=e.index();if(!n||!i||!n.type.compatibleContent(i.type))return false;if(!n.content.size&&e.parent.canReplace(s-1,s)){if(r)r(t.tr.delete(e.pos-n.nodeSize,e.pos).scrollIntoView());return true}if(!e.parent.canReplace(s,s+1)||!(i.isTextblock||xe(t.doc,e.pos)))return false;if(r)r(t.tr.join(e.pos).scrollIntoView());return true}function Vr(t,e,r,n){let i=e.nodeBefore,s=e.nodeAfter,o,l;let u=i.type.spec.isolating||s.type.spec.isolating;if(!u&&Wr(t,e,r))return true;let a=!u&&e.parent.canReplace(e.index(),e.index()+1);if(a&&(o=(l=i.contentMatchAt(i.childCount)).findWrapping(s.type))&&l.matchType(o[0]||s.type).validEnd){if(r){let n=e.pos+s.nodeSize,l=m.empty;for(let t=o.length-1;t>=0;t--)l=m.from(o[t].create(null,l));l=m.from(i.copy(l));let u=t.tr.step(new ne(e.pos-1,n,e.pos,n,new y(l,1,0),o.length,true));let a=u.doc.resolve(n+2*o.length);if(a.nodeAfter&&a.nodeAfter.type==i.type&&xe(u.doc,a.pos))u.join(a.pos);r(u.scrollIntoView())}return true}let f=s.type.spec.isolating||n>0&&u?null:Ze.findFrom(e,1);let h=f&&f.$from.blockRange(f.$to),c=h&&ae(h);if(c!=null&&c>=e.depth){if(r)r(t.tr.lift(h,c).scrollIntoView());return true}if(a&&Ar(s,"start",true)&&Ar(i,"end")){let n=i,o=[];for(;;){o.push(n);if(n.isTextblock)break;n=n.lastChild}let l=s,u=1;for(;!l.isTextblock;l=l.firstChild)u++;if(n.canReplace(n.childCount,n.childCount,l.content)){if(r){let n=m.empty;for(let t=o.length-1;t>=0;t--)n=m.from(o[t].copy(n));let i=t.tr.step(new ne(e.pos-o.length,e.pos+s.nodeSize,e.pos+u,e.pos+s.nodeSize-u,new y(n,o.length,0),0,true));r(i.scrollIntoView())}return true}}return false}function Gr(t){return function(e,r){let n=e.selection,i=t<0?n.$from:n.$to;let s=i.depth;while(i.node(s).isInline){if(!s)return false;s--}if(!i.node(s).isTextblock)return false;if(r)r(e.tr.setSelection(tr.create(e.doc,t<0?i.start(s):i.end(s))));return true}}const Zr=Gr(-1);const Qr=Gr(1);function Xr(t,e=null){return function(r,n){let{$from:i,$to:s}=r.selection;let o=i.blockRange(s),l=o&&he(o,t,e);if(!l)return false;if(n)n(r.tr.wrap(o,l).scrollIntoView());return true}}function Yr(t,e=null){return function(r,n){let i=false;for(let n=0;n<r.selection.ranges.length&&!i;n++){let{$from:{pos:s},$to:{pos:o}}=r.selection.ranges[n];r.doc.nodesBetween(s,o,((n,s)=>{if(i)return false;if(!n.isTextblock||n.hasMarkup(t,e))return;if(n.type==t){i=true}else{let e=r.doc.resolve(s),n=e.index();i=e.parent.canReplaceWith(n,n+1,t)}}))}if(!i)return false;if(n){let i=r.tr;for(let n=0;n<r.selection.ranges.length;n++){let{$from:{pos:s},$to:{pos:o}}=r.selection.ranges[n];i.setBlockType(s,o,t,e)}n(i.scrollIntoView())}return true}}function tn(...t){return function(e,r,n){for(let i=0;i<t.length;i++)if(t[i](e,r,n))return true;return false}}let en=tn(Mr,Sr,Or);let rn=tn(Mr,Lr,Nr);const nn={Enter:tn(jr,Br,Fr,qr),"Mod-Enter":zr,Backspace:en,"Mod-Backspace":en,"Shift-Backspace":en,Delete:rn,"Mod-Delete":rn,"Mod-a":Kr};const sn={"Ctrl-h":nn["Backspace"],"Alt-Backspace":nn["Mod-Backspace"],"Ctrl-d":nn["Delete"],"Ctrl-Alt-Backspace":nn["Mod-Delete"],"Alt-Delete":nn["Mod-Delete"],"Alt-d":nn["Mod-Delete"],"Ctrl-a":Zr,"Ctrl-e":Qr};for(let t in nn)sn[t]=nn[t];typeof navigator!="undefined"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os!="undefined"&&os.platform?os.platform()=="darwin":false;function on(t,e=null){return function(r,n){let{$from:i,$to:s}=r.selection;let o=i.blockRange(s);if(!o)return false;let l=n?r.tr:null;if(!ln(l,o,t,e))return false;if(n)n(l.scrollIntoView());return true}}function ln(t,e,r,n=null){let i=false,s=e,o=e.$from.doc;if(e.depth>=2&&e.$from.node(e.depth-1).type.compatibleContent(r)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return false;let t=o.resolve(e.start-2);s=new j(t,t,e.depth);if(e.endIndex<e.parent.childCount)e=new j(e.$from,o.resolve(e.$to.end(e.depth)),e.depth);i=true}let l=he(s,r,n,e);if(!l)return false;if(t)un(t,e,l,i,r);return true}function un(t,e,r,n,i){let s=m.empty;for(let t=r.length-1;t>=0;t--)s=m.from(r[t].type.create(r[t].attrs,s));t.step(new ne(e.start-(n?2:0),e.end,e.start,e.end,new y(s,0,0),r.length,true));let o=0;for(let t=0;t<r.length;t++)if(r[t].type==i)o=t+1;let l=r.length-o;let u=e.start+r.length-(n?2:0),a=e.parent;for(let r=e.startIndex,n=e.endIndex,i=true;r<n;r++,i=false){if(!i&&ye(t.doc,u,l)){t.split(u,l);u+=2*l}u+=a.child(r).nodeSize}return t}function an(t){return function(e,r){let{$from:n,$to:i}=e.selection;let s=n.blockRange(i,(e=>e.childCount>0&&e.firstChild.type==t));if(!s)return false;if(!r)return true;if(n.node(s.depth-1).type==t)return fn(e,r,t,s);else return hn(e,r,s)}}function fn(t,e,r,n){let i=t.tr,s=n.end,o=n.$to.end(n.depth);if(s<o){i.step(new ne(s-1,o,s,o,new y(m.from(r.create(null,n.parent.copy())),1,0),1,true));n=new j(i.doc.resolve(n.$from.pos),i.doc.resolve(o),n.depth)}const l=ae(n);if(l==null)return false;i.lift(n,l);let u=i.doc.resolve(i.mapping.map(s,-1)-1);if(xe(i.doc,u.pos)&&u.nodeBefore.type==u.nodeAfter.type)i.join(u.pos);e(i.scrollIntoView());return true}function hn(t,e,r){let n=t.tr,i=r.parent;for(let t=r.end,e=r.endIndex-1,s=r.startIndex;e>s;e--){t-=i.child(e).nodeSize;n.delete(t-1,t+1)}let s=n.doc.resolve(r.start),o=s.nodeAfter;if(n.mapping.map(r.end)!=r.start+s.nodeAfter.nodeSize)return false;let l=r.startIndex==0,u=r.endIndex==i.childCount;let a=s.node(-1),f=s.index(-1);if(!a.canReplace(f+(l?0:1),f+1,o.content.append(u?m.empty:m.from(i))))return false;let h=s.pos,c=h+o.nodeSize;n.step(new ne(h-(l?1:0),c+(u?1:0),h+1,c-1,new y((l?m.empty:m.from(i.copy(m.empty))).append(u?m.empty:m.from(i.copy(m.empty))),l?0:1,u?0:1),l?0:1));e(n.scrollIntoView());return true}function cn(t){return function(e,r){let{$from:n,$to:i}=e.selection;let s=n.blockRange(i,(e=>e.childCount>0&&e.firstChild.type==t));if(!s)return false;let o=s.startIndex;if(o==0)return false;let l=s.parent,u=l.child(o-1);if(u.type!=t)return false;if(r){let n=u.lastChild&&u.lastChild.type==l.type;let i=m.from(n?t.create():null);let o=new y(m.from(t.create(null,m.from(l.type.create(null,i)))),n?3:1,0);let a=s.start,f=s.end;r(e.tr.step(new ne(a-(n?3:1),f,a,f,o,1,true)).scrollIntoView())}return true}}const dn=function(t){for(var e=0;;e++){t=t.previousSibling;if(!t)return e}};const pn=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let mn=null;const gn=function(t,e,r){let n=mn||(mn=document.createRange());n.setEnd(t,r==null?t.nodeValue.length:r);n.setStart(t,e||0);return n};const wn=function(){mn=null};const bn=function(t,e,r,n){return r&&(vn(t,e,r,n,-1)||vn(t,e,r,n,1))};const kn=/^(img|br|input|textarea|hr)$/i;function vn(t,e,r,n,i){var s;for(;;){if(t==r&&e==n)return true;if(e==(i<0?0:yn(t))){let r=t.parentNode;if(!r||r.nodeType!=1||Tn(t)||kn.test(t.nodeName)||t.contentEditable=="false")return false;e=dn(t)+(i<0?0:1);t=r}else if(t.nodeType==1){let r=t.childNodes[e+(i<0?-1:0)];if(r.nodeType==1&&r.contentEditable=="false"){if((s=r.pmViewDesc)===null||s===void 0?void 0:s.ignoreForSelection)e+=i;else return false}else{t=r;e=i<0?yn(t):0}}else{return false}}}function yn(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function Mn(t,e){for(;;){if(t.nodeType==3&&e)return t;if(t.nodeType==1&&e>0){if(t.contentEditable=="false")return null;t=t.childNodes[e-1];e=yn(t)}else if(t.parentNode&&!Tn(t)){e=dn(t);t=t.parentNode}else{return null}}}function xn(t,e){for(;;){if(t.nodeType==3&&e<t.nodeValue.length)return t;if(t.nodeType==1&&e<t.childNodes.length){if(t.contentEditable=="false")return null;t=t.childNodes[e];e=0}else if(t.parentNode&&!Tn(t)){e=dn(t)+1;t=t.parentNode}else{return null}}}function Sn(t,e,r){for(let n=e==0,i=e==yn(t);n||i;){if(t==r)return true;let e=dn(t);t=t.parentNode;if(!t)return false;n=n&&e==0;i=i&&e==yn(t)}}function Tn(t){let e;for(let r=t;r;r=r.parentNode)if(e=r.pmViewDesc)break;return e&&e.node&&e.node.isBlock&&(e.dom==t||e.contentDOM==t)}const En=function(t){return t.focusNode&&bn(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function $n(t,e){let r=document.createEvent("Event");r.initEvent("keydown",true,true);r.keyCode=t;r.key=r.code=e;return r}function An(t){let e=t.activeElement;while(e&&e.shadowRoot)e=e.shadowRoot.activeElement;return e}function On(t,e,r){if(t.caretPositionFromPoint){try{let n=t.caretPositionFromPoint(e,r);if(n)return{node:n.offsetNode,offset:Math.min(yn(n.offsetNode),n.offset)}}catch(t){}}if(t.caretRangeFromPoint){let n=t.caretRangeFromPoint(e,r);if(n)return{node:n.startContainer,offset:Math.min(yn(n.startContainer),n.startOffset)}}}const Rn=typeof navigator!="undefined"?navigator:null;const Cn=typeof document!="undefined"?document:null;const Ln=Rn&&Rn.userAgent||"";const Nn=/Edge\/(\d+)/.exec(Ln);const Pn=/MSIE \d/.exec(Ln);const In=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Ln);const Dn=!!(Pn||In||Nn);const Hn=Pn?document.documentMode:In?+In[1]:Nn?+Nn[1]:0;const jn=!Dn&&/gecko\/(\d+)/i.test(Ln);jn&&+(/Firefox\/(\d+)/.exec(Ln)||[0,0])[1];const _n=!Dn&&/Chrome\/(\d+)/.exec(Ln);const zn=!!_n;const Bn=_n?+_n[1]:0;const Fn=!Dn&&!!Rn&&/Apple Computer/.test(Rn.vendor);const Un=Fn&&(/Mobile\/\w+/.test(Ln)||!!Rn&&Rn.maxTouchPoints>2);const qn=Un||(Rn?/Mac/.test(Rn.platform):false);const Jn=Rn?/Win/.test(Rn.platform):false;const Kn=/Android \d/.test(Ln);const Wn=!!Cn&&"webkitFontSmoothing"in Cn.documentElement.style;const Vn=Wn?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Gn(t){let e=t.defaultView&&t.defaultView.visualViewport;if(e)return{left:0,right:e.width,top:0,bottom:e.height};return{left:0,right:t.documentElement.clientWidth,top:0,bottom:t.documentElement.clientHeight}}function Zn(t,e){return typeof t=="number"?t:t[e]}function Qn(t){let e=t.getBoundingClientRect();let r=e.width/t.offsetWidth||1;let n=e.height/t.offsetHeight||1;return{left:e.left,right:e.left+t.clientWidth*r,top:e.top,bottom:e.top+t.clientHeight*n}}function Xn(t,e,r){let n=t.someProp("scrollThreshold")||0,i=t.someProp("scrollMargin")||5;let s=t.dom.ownerDocument;for(let o=r||t.dom;;){if(!o)break;if(o.nodeType!=1){o=pn(o);continue}let t=o;let r=t==s.body;let l=r?Gn(s):Qn(t);let u=0,a=0;if(e.top<l.top+Zn(n,"top"))a=-(l.top-e.top+Zn(i,"top"));else if(e.bottom>l.bottom-Zn(n,"bottom"))a=e.bottom-e.top>l.bottom-l.top?e.top+Zn(i,"top")-l.top:e.bottom-l.bottom+Zn(i,"bottom");if(e.left<l.left+Zn(n,"left"))u=-(l.left-e.left+Zn(i,"left"));else if(e.right>l.right-Zn(n,"right"))u=e.right-l.right+Zn(i,"right");if(u||a){if(r){s.defaultView.scrollBy(u,a)}else{let r=t.scrollLeft,n=t.scrollTop;if(a)t.scrollTop+=a;if(u)t.scrollLeft+=u;let i=t.scrollLeft-r,s=t.scrollTop-n;e={left:e.left-i,top:e.top-s,right:e.right-i,bottom:e.bottom-s}}}let f=r?"fixed":getComputedStyle(o).position;if(/^(fixed|sticky)$/.test(f))break;o=f=="absolute"?o.offsetParent:pn(o)}}function Yn(t){let e=t.dom.getBoundingClientRect(),r=Math.max(0,e.top);let n,i;for(let s=(e.left+e.right)/2,o=r+1;o<Math.min(innerHeight,e.bottom);o+=5){let e=t.root.elementFromPoint(s,o);if(!e||e==t.dom||!t.dom.contains(e))continue;let l=e.getBoundingClientRect();if(l.top>=r-20){n=e;i=l.top;break}}return{refDOM:n,refTop:i,stack:ti(t.dom)}}function ti(t){let e=[],r=t.ownerDocument;for(let n=t;n;n=pn(n)){e.push({dom:n,top:n.scrollTop,left:n.scrollLeft});if(t==r)break}return e}function ei({refDOM:t,refTop:e,stack:r}){let n=t?t.getBoundingClientRect().top:0;ri(r,n==0?0:n-e)}function ri(t,e){for(let r=0;r<t.length;r++){let{dom:n,top:i,left:s}=t[r];if(n.scrollTop!=i+e)n.scrollTop=i+e;if(n.scrollLeft!=s)n.scrollLeft=s}}let ni=null;function ii(t){if(t.setActive)return t.setActive();if(ni)return t.focus(ni);let e=ti(t);t.focus(ni==null?{get preventScroll(){ni={preventScroll:true};return true}}:undefined);if(!ni){ni=false;ri(e,0)}}function si(t,e){let r,n=2e8,i,s=0;let o=e.top,l=e.top;let u,a;for(let f=t.firstChild,h=0;f;f=f.nextSibling,h++){let t;if(f.nodeType==1)t=f.getClientRects();else if(f.nodeType==3)t=gn(f).getClientRects();else continue;for(let c=0;c<t.length;c++){let d=t[c];if(d.top<=o&&d.bottom>=l){o=Math.max(d.bottom,o);l=Math.min(d.top,l);let t=d.left>e.left?d.left-e.left:d.right<e.left?e.left-d.right:0;if(t<n){r=f;n=t;i=t&&r.nodeType==3?{left:d.right<e.left?d.right:d.left,top:e.top}:e;if(f.nodeType==1&&t)s=h+(e.left>=(d.left+d.right)/2?1:0);continue}}else if(d.top>e.top&&!u&&d.left<=e.left&&d.right>=e.left){u=f;a={left:Math.max(d.left,Math.min(d.right,e.left)),top:d.top}}if(!r&&(e.left>=d.right&&e.top>=d.top||e.left>=d.left&&e.top>=d.bottom))s=h+1}}if(!r&&u){r=u;i=a;n=0}if(r&&r.nodeType==3)return oi(r,i);if(!r||n&&r.nodeType==1)return{node:t,offset:s};return si(r,i)}function oi(t,e){let r=t.nodeValue.length;let n=document.createRange();for(let i=0;i<r;i++){n.setEnd(t,i+1);n.setStart(t,i);let r=pi(n,1);if(r.top==r.bottom)continue;if(li(e,r))return{node:t,offset:i+(e.left>=(r.left+r.right)/2?1:0)}}return{node:t,offset:0}}function li(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function ui(t,e){let r=t.parentNode;if(r&&/^li$/i.test(r.nodeName)&&e.left<t.getBoundingClientRect().left)return r;return t}function ai(t,e,r){let{node:n,offset:i}=si(e,r),s=-1;if(n.nodeType==1&&!n.firstChild){let t=n.getBoundingClientRect();s=t.left!=t.right&&r.left>(t.left+t.right)/2?1:-1}return t.docView.posFromDOM(n,i,s)}function fi(t,e,r,n){let i=-1;for(let r=e,s=false;;){if(r==t.dom)break;let e=t.docView.nearestDesc(r,true),o;if(!e)return null;if(e.dom.nodeType==1&&(e.node.isBlock&&e.parent||!e.contentDOM)&&((o=e.dom.getBoundingClientRect()).width||o.height)){if(e.node.isBlock&&e.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(e.dom.nodeName)){if(!s&&o.left>n.left||o.top>n.top)i=e.posBefore;else if(!s&&o.right<n.left||o.bottom<n.top)i=e.posAfter;s=true}if(!e.contentDOM&&i<0&&!e.node.isText){let t=e.node.isBlock?n.top<(o.top+o.bottom)/2:n.left<(o.left+o.right)/2;return t?e.posBefore:e.posAfter}}r=e.dom.parentNode}return i>-1?i:t.docView.posFromDOM(e,r,-1)}function hi(t,e,r){let n=t.childNodes.length;if(n&&r.top<r.bottom){for(let i=Math.max(0,Math.min(n-1,Math.floor(n*(e.top-r.top)/(r.bottom-r.top))-2)),s=i;;){let r=t.childNodes[s];if(r.nodeType==1){let t=r.getClientRects();for(let n=0;n<t.length;n++){let i=t[n];if(li(e,i))return hi(r,e,i)}}if((s=(s+1)%n)==i)break}}return t}function ci(t,e){let r=t.dom.ownerDocument,n,i=0;let s=On(r,e.left,e.top);if(s)({node:n,offset:i}=s);let o=(t.root.elementFromPoint?t.root:r).elementFromPoint(e.left,e.top);let l;if(!o||!t.dom.contains(o.nodeType!=1?o.parentNode:o)){let r=t.dom.getBoundingClientRect();if(!li(e,r))return null;o=hi(t.dom,e,r);if(!o)return null}if(Fn){for(let t=o;n&&t;t=pn(t))if(t.draggable)n=undefined}o=ui(o,e);if(n){if(jn&&n.nodeType==1){i=Math.min(i,n.childNodes.length);if(i<n.childNodes.length){let t=n.childNodes[i],r;if(t.nodeName=="IMG"&&(r=t.getBoundingClientRect()).right<=e.left&&r.bottom>e.top)i++}}let r;if(Wn&&i&&n.nodeType==1&&(r=n.childNodes[i-1]).nodeType==1&&r.contentEditable=="false"&&r.getBoundingClientRect().top>=e.top)i--;if(n==t.dom&&i==n.childNodes.length-1&&n.lastChild.nodeType==1&&e.top>n.lastChild.getBoundingClientRect().bottom)l=t.state.doc.content.size;else if(i==0||n.nodeType!=1||n.childNodes[i-1].nodeName!="BR")l=fi(t,n,i,e)}if(l==null)l=ai(t,o,e);let u=t.docView.nearestDesc(o,true);return{pos:l,inside:u?u.posAtStart-u.border:-1}}function di(t){return t.top<t.bottom||t.left<t.right}function pi(t,e){let r=t.getClientRects();if(r.length){let t=r[e<0?0:r.length-1];if(di(t))return t}return Array.prototype.find.call(r,di)||t.getBoundingClientRect()}const mi=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function gi(t,e,r){let{node:n,offset:i,atom:s}=t.docView.domFromPos(e,r<0?-1:1);let o=Wn||jn;if(n.nodeType==3){if(o&&(mi.test(n.nodeValue)||(r<0?!i:i==n.nodeValue.length))){let t=pi(gn(n,i,i),r);if(jn&&i&&/\s/.test(n.nodeValue[i-1])&&i<n.nodeValue.length){let e=pi(gn(n,i-1,i-1),-1);if(e.top==t.top){let r=pi(gn(n,i,i+1),-1);if(r.top!=t.top)return wi(r,r.left<e.left)}}return t}else{let t=i,e=i,s=r<0?1:-1;if(r<0&&!i){e++;s=-1}else if(r>=0&&i==n.nodeValue.length){t--;s=1}else if(r<0){t--}else{e++}return wi(pi(gn(n,t,e),s),s<0)}}let l=t.state.doc.resolve(e-(s||0));if(!l.parent.inlineContent){if(s==null&&i&&(r<0||i==yn(n))){let t=n.childNodes[i-1];if(t.nodeType==1)return bi(t.getBoundingClientRect(),false)}if(s==null&&i<yn(n)){let t=n.childNodes[i];if(t.nodeType==1)return bi(t.getBoundingClientRect(),true)}return bi(n.getBoundingClientRect(),r>=0)}if(s==null&&i&&(r<0||i==yn(n))){let t=n.childNodes[i-1];let e=t.nodeType==3?gn(t,yn(t)-(o?0:1)):t.nodeType==1&&(t.nodeName!="BR"||!t.nextSibling)?t:null;if(e)return wi(pi(e,1),false)}if(s==null&&i<yn(n)){let t=n.childNodes[i];while(t.pmViewDesc&&t.pmViewDesc.ignoreForCoords)t=t.nextSibling;let e=!t?null:t.nodeType==3?gn(t,0,o?0:1):t.nodeType==1?t:null;if(e)return wi(pi(e,-1),true)}return wi(pi(n.nodeType==3?gn(n):n,-r),r>=0)}function wi(t,e){if(t.width==0)return t;let r=e?t.left:t.right;return{top:t.top,bottom:t.bottom,left:r,right:r}}function bi(t,e){if(t.height==0)return t;let r=e?t.top:t.bottom;return{top:r,bottom:r,left:t.left,right:t.right}}function ki(t,e,r){let n=t.state,i=t.root.activeElement;if(n!=e)t.updateState(e);if(i!=t.dom)t.focus();try{return r()}finally{if(n!=e)t.updateState(n);if(i!=t.dom&&i)i.focus()}}function vi(t,e,r){let n=e.selection;let i=r=="up"?n.$from:n.$to;return ki(t,e,(()=>{let{node:e}=t.docView.domFromPos(i.pos,r=="up"?-1:1);for(;;){let r=t.docView.nearestDesc(e,true);if(!r)break;if(r.node.isBlock){e=r.contentDOM||r.dom;break}e=r.dom.parentNode}let n=gi(t,i.pos,1);for(let t=e.firstChild;t;t=t.nextSibling){let e;if(t.nodeType==1)e=t.getClientRects();else if(t.nodeType==3)e=gn(t,0,t.nodeValue.length).getClientRects();else continue;for(let t=0;t<e.length;t++){let i=e[t];if(i.bottom>i.top+1&&(r=="up"?n.top-i.top>(i.bottom-n.top)*2:i.bottom-n.bottom>(n.bottom-i.top)*2))return false}}return true}))}const yi=/[\u0590-\u08ac]/;function Mi(t,e,r){let{$head:n}=e.selection;if(!n.parent.isTextblock)return false;let i=n.parentOffset,s=!i,o=i==n.parent.content.size;let l=t.domSelection();if(!l)return n.pos==n.start()||n.pos==n.end();if(!yi.test(n.parent.textContent)||!l.modify)return r=="left"||r=="backward"?s:o;return ki(t,e,(()=>{let{focusNode:e,focusOffset:i,anchorNode:s,anchorOffset:o}=t.domSelectionRange();let u=l.caretBidiLevel;l.modify("move",r,"character");let a=n.depth?t.docView.domAfterPos(n.before()):t.dom;let{focusNode:f,focusOffset:h}=t.domSelectionRange();let c=f&&!a.contains(f.nodeType==1?f:f.parentNode)||e==f&&i==h;try{l.collapse(s,o);if(e&&(e!=s||i!=o)&&l.extend)l.extend(e,i)}catch(t){}if(u!=null)l.caretBidiLevel=u;return c}))}let xi=null;let Si=null;let Ti=false;function Ei(t,e,r){if(xi==e&&Si==r)return Ti;xi=e;Si=r;return Ti=r=="up"||r=="down"?vi(t,e,r):Mi(t,e,r)}const $i=0,Ai=1,Oi=2,Ri=3;class Ci{constructor(t,e,r,n){this.parent=t;this.children=e;this.dom=r;this.contentDOM=n;this.dirty=$i;r.pmViewDesc=this}matchesWidget(t){return false}matchesMark(t){return false}matchesNode(t,e,r){return false}matchesHack(t){return false}parseRule(){return null}stopEvent(t){return false}get size(){let t=0;for(let e=0;e<this.children.length;e++)t+=this.children[e].size;return t}get border(){return 0}destroy(){this.parent=undefined;if(this.dom.pmViewDesc==this)this.dom.pmViewDesc=undefined;for(let t=0;t<this.children.length;t++)this.children[t].destroy()}posBeforeChild(t){for(let e=0,r=this.posAtStart;;e++){let n=this.children[e];if(n==t)return r;r+=n.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(t,e,r){if(this.contentDOM&&this.contentDOM.contains(t.nodeType==1?t:t.parentNode)){if(r<0){let r,n;if(t==this.contentDOM){r=t.childNodes[e-1]}else{while(t.parentNode!=this.contentDOM)t=t.parentNode;r=t.previousSibling}while(r&&!((n=r.pmViewDesc)&&n.parent==this))r=r.previousSibling;return r?this.posBeforeChild(n)+n.size:this.posAtStart}else{let r,n;if(t==this.contentDOM){r=t.childNodes[e]}else{while(t.parentNode!=this.contentDOM)t=t.parentNode;r=t.nextSibling}while(r&&!((n=r.pmViewDesc)&&n.parent==this))r=r.nextSibling;return r?this.posBeforeChild(n):this.posAtEnd}}let n;if(t==this.dom&&this.contentDOM){n=e>dn(this.contentDOM)}else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM)){n=t.compareDocumentPosition(this.contentDOM)&2}else if(this.dom.firstChild){if(e==0)for(let e=t;;e=e.parentNode){if(e==this.dom){n=false;break}if(e.previousSibling)break}if(n==null&&e==t.childNodes.length)for(let e=t;;e=e.parentNode){if(e==this.dom){n=true;break}if(e.nextSibling)break}}return(n==null?r>0:n)?this.posAtEnd:this.posAtStart}nearestDesc(t,e=false){for(let r=true,n=t;n;n=n.parentNode){let i=this.getDesc(n),s;if(i&&(!e||i.node)){if(r&&(s=i.nodeDOM)&&!(s.nodeType==1?s.contains(t.nodeType==1?t:t.parentNode):s==t))r=false;else return i}}}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 n=t;n;n=n.parentNode){let i=this.getDesc(n);if(i)return i.localPosFromDOM(t,e,r)}return-1}descAt(t){for(let e=0,r=0;e<this.children.length;e++){let n=this.children[e],i=r+n.size;if(r==t&&i!=r){while(!n.border&&n.children.length){for(let t=0;t<n.children.length;t++){let e=n.children[t];if(e.size){n=e;break}}}return n}if(t<i)return n.descAt(t-r-n.border);r=i}}domFromPos(t,e){if(!this.contentDOM)return{node:this.dom,offset:0,atom:t+1};let r=0,n=0;for(let e=0;r<this.children.length;r++){let i=this.children[r],s=e+i.size;if(s>t||i instanceof ji){n=t-e;break}e=s}if(n)return this.children[r].domFromPos(n-this.children[r].border,e);for(let t;r&&!(t=this.children[r-1]).size&&t instanceof Li&&t.side>=0;r--){}if(e<=0){let t,n=true;for(;;r--,n=false){t=r?this.children[r-1]:null;if(!t||t.dom.parentNode==this.contentDOM)break}if(t&&e&&n&&!t.border&&!t.domAtom)return t.domFromPos(t.size,e);return{node:this.contentDOM,offset:t?dn(t.dom)+1:0}}else{let t,n=true;for(;;r++,n=false){t=r<this.children.length?this.children[r]:null;if(!t||t.dom.parentNode==this.contentDOM)break}if(t&&n&&!t.border&&!t.domAtom)return t.domFromPos(0,e);return{node:this.contentDOM,offset:t?dn(t.dom):this.contentDOM.childNodes.length}}}parseRange(t,e,r=0){if(this.children.length==0)return{node:this.contentDOM,from:t,to:e,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let n=-1,i=-1;for(let s=r,o=0;;o++){let r=this.children[o],l=s+r.size;if(n==-1&&t<=l){let i=s+r.border;if(t>=i&&e<=l-r.border&&r.node&&r.contentDOM&&this.contentDOM.contains(r.contentDOM))return r.parseRange(t,e,i);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)){n=dn(r.dom)+1;break}t-=r.size}if(n==-1)n=0}if(n>-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)){i=dn(r.dom);break}e+=r.size}if(i==-1)i=this.contentDOM.childNodes.length;break}s=l}return{node:this.contentDOM,from:t,to:e,fromOffset:n,toOffset:i}}emptyChildAt(t){if(this.border||!this.contentDOM||!this.children.length)return false;let e=this.children[t<0?0:this.children.length-1];return e.size==0||e.emptyChildAt(t)}domAfterPos(t){let{node:e,offset:r}=this.domFromPos(t,0);if(e.nodeType!=1||r==e.childNodes.length)throw new RangeError("No node after pos "+t);return e.childNodes[r]}setSelection(t,e,r,n=false){let i=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],a=l+u.size;if(i>l&&s<a)return u.setSelection(t-l-u.border,e-l-u.border,r,n);l=a}let o=this.domFromPos(t,t?-1:1);let l=e==t?o:this.domFromPos(e,e?-1:1);let u=r.root.getSelection();let a=r.domSelectionRange();let f=false;if((jn||Fn)&&t==e){let{node:t,offset:e}=o;if(t.nodeType==3){f=!!(e&&t.nodeValue[e-1]=="\n");if(f&&e==t.nodeValue.length){for(let e=t,r;e;e=e.parentNode){if(r=e.nextSibling){if(r.nodeName=="BR")o=l={node:r.parentNode,offset:dn(r)+1};break}let t=e.pmViewDesc;if(t&&t.node&&t.node.isBlock)break}}}else{let r=t.childNodes[e-1];f=r&&(r.nodeName=="BR"||r.contentEditable=="false")}}if(jn&&a.focusNode&&a.focusNode!=l.node&&a.focusNode.nodeType==1){let t=a.focusNode.childNodes[a.focusOffset];if(t&&t.contentEditable=="false")n=true}if(!(n||f&&Fn)&&bn(o.node,o.offset,a.anchorNode,a.anchorOffset)&&bn(l.node,l.offset,a.focusNode,a.focusOffset))return;let h=false;if((u.extend||t==e)&&!(f&&jn)){u.collapse(o.node,o.offset);try{if(t!=e)u.extend(l.node,l.offset);h=true}catch(t){}}if(!h){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&&t.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(t,e){for(let r=0,n=0;n<this.children.length;n++){let i=this.children[n],s=r+i.size;if(r==s?t<=s&&e>=r:t<s&&e>r){let n=r+i.border,o=s-i.border;if(t>=n&&e<=o){this.dirty=t==r||e==s?Oi:Ai;if(t==n&&e==o&&(i.contentLost||i.dom.parentNode!=this.contentDOM))i.dirty=Ri;else i.markDirty(t-n,e-n);return}else{i.dirty=i.dom==i.contentDOM&&i.dom.parentNode==this.contentDOM&&!i.children.length?Oi:Ri}}r=s}this.dirty=Oi}markParentsDirty(){let t=1;for(let e=this.parent;e;e=e.parent,t++){let r=t==1?Oi:Ai;if(e.dirty<r)e.dirty=r}}get domAtom(){return false}get ignoreForCoords(){return false}get ignoreForSelection(){return false}isText(t){return false}}class Li extends Ci{constructor(t,e,r,n){let i,s=e.type.toDOM;if(typeof s=="function")s=s(r,(()=>{if(!i)return n;if(i.parent)return i.parent.posBeforeChild(i)}));if(!e.type.spec.raw){if(s.nodeType!=1){let t=document.createElement("span");t.appendChild(s);s=t}s.contentEditable="false";s.classList.add("ProseMirror-widget")}super(t,[],s,null);this.widget=e;this.widget=e;i=this}matchesWidget(t){return this.dirty==$i&&t.type.eq(this.widget.type)}parseRule(){return{ignore:true}}stopEvent(t){let e=this.widget.spec.stopEvent;return e?e(t):false}ignoreMutation(t){return t.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom);super.destroy()}get domAtom(){return true}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}}class Ni extends Ci{constructor(t,e,r,n){super(t,[],e,null);this.textDOM=r;this.text=n}get size(){return this.text.length}localPosFromDOM(t,e){if(t!=this.textDOM)return this.posAtStart+(e?this.size:0);return this.posAtStart+e}domFromPos(t){return{node:this.textDOM,offset:t}}ignoreMutation(t){return t.type==="characterData"&&t.target.nodeValue==t.oldValue}}class Pi extends Ci{constructor(t,e,r,n,i){super(t,[],r,n);this.mark=e;this.spec=i}static create(t,e,r,n){let i=n.nodeViews[e.type.name];let s=i&&i(e,n,r);if(!s||!s.dom)s=Ot.renderSpec(document,e.type.spec.toDOM(e,r),null,e.attrs);return new Pi(t,e,s.dom,s.contentDOM||s.dom,s)}parseRule(){if(this.dirty&Ri||this.mark.type.spec.reparseInView)return null;return{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(t){return this.dirty!=Ri&&this.mark.eq(t)}markDirty(t,e){super.markDirty(t,e);if(this.dirty!=$i){let t=this.parent;while(!t.node)t=t.parent;if(t.dirty<this.dirty)t.dirty=this.dirty;this.dirty=$i}}slice(t,e,r){let n=Pi.create(this.parent,this.mark,true,r);let i=this.children,s=this.size;if(e<s)i=es(i,e,s,r);if(t>0)i=es(i,0,t,r);for(let t=0;t<i.length;t++)i[t].parent=n;n.children=i;return n}ignoreMutation(t){return this.spec.ignoreMutation?this.spec.ignoreMutation(t):super.ignoreMutation(t)}destroy(){if(this.spec.destroy)this.spec.destroy();super.destroy()}}class Ii extends Ci{constructor(t,e,r,n,i,s,o,l,u){super(t,[],i,s);this.node=e;this.outerDeco=r;this.innerDeco=n;this.nodeDOM=o}static create(t,e,r,n,i,s){let o=i.nodeViews[e.type.name],l;let u=o&&o(e,i,(()=>{if(!l)return s;if(l.parent)return l.parent.posBeforeChild(l)}),r,n);let a=u&&u.dom,f=u&&u.contentDOM;if(e.isText){if(!a)a=document.createTextNode(e.text);else if(a.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else if(!a){let t=Ot.renderSpec(document,e.type.spec.toDOM(e),null,e.attrs);({dom:a,contentDOM:f}=t)}if(!f&&!e.isText&&a.nodeName!="BR"){if(!a.hasAttribute("contenteditable"))a.contentEditable="false";if(e.type.spec.draggable)a.draggable=true}let h=a;a=Ki(a,r,e);if(u)return l=new _i(t,e,r,n,a,f||null,h,u,i,s+1);else if(e.isText)return new Hi(t,e,r,n,a,h,i);else return new Ii(t,e,r,n,a,f||null,h,i,s+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let t={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre")t.preserveWhitespace="full";if(!this.contentDOM){t.getContent=()=>this.node.content}else if(!this.contentLost){t.contentElement=this.contentDOM}else{for(let e=this.children.length-1;e>=0;e--){let r=this.children[e];if(this.dom.contains(r.dom.parentNode)){t.contentElement=r.dom.parentNode;break}}if(!t.contentElement)t.getContent=()=>m.empty}return t}matchesNode(t,e,r){return this.dirty==$i&&t.eq(this.node)&&Wi(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,n=e;let i=t.composing?this.localCompositionInfo(t,e):null;let s=i&&i.pos>-1?i:null;let o=i&&i.pos<0;let l=new Gi(this,s&&s.node,t);Xi(this.node,this.innerDeco,((e,i,s)=>{if(e.spec.marks)l.syncToMarks(e.spec.marks,r,t);else if(e.type.side>=0&&!s)l.syncToMarks(i==this.node.childCount?k.none:this.node.child(i).marks,r,t);l.placeWidget(e,t,n)}),((e,s,u,a)=>{l.syncToMarks(e.marks,r,t);let f;if(l.findNodeMatch(e,s,u,a));else if(o&&t.state.selection.from>n&&t.state.selection.to<n+e.nodeSize&&(f=l.findIndexWithChild(i.node))>-1&&l.updateNodeAt(e,s,u,f,t));else if(l.updateNextNode(e,s,u,t,a,n));else{l.addNode(e,s,u,t,n)}n+=e.nodeSize}));l.syncToMarks([],r,t);if(this.node.isTextblock)l.addTextblockHacks();l.destroyRest();if(l.changed||this.dirty==Oi){if(s)this.protectLocalComposition(t,s);zi(this.contentDOM,this.children,t);if(Un)Yi(this.dom)}}localCompositionInfo(t,e){let{from:r,to:n}=t.state.selection;if(!(t.state.selection instanceof tr)||r<e||n>e+this.node.content.size)return null;let i=t.input.compositionNode;if(!i||!this.dom.contains(i.parentNode))return null;if(this.node.inlineContent){let t=i.nodeValue;let s=ts(this.node.content,t,r-e,n-e);return s<0?null:{node:i,pos:s,text:t}}else{return{node:i,pos:-1,text:""}}}protectLocalComposition(t,{node:e,pos:r,text:n}){if(this.getDesc(e))return;let i=e;for(;;i=i.parentNode){if(i.parentNode==this.contentDOM)break;while(i.previousSibling)i.parentNode.removeChild(i.previousSibling);while(i.nextSibling)i.parentNode.removeChild(i.nextSibling);if(i.pmViewDesc)i.pmViewDesc=undefined}let s=new Ni(this,i,e,n);t.input.compositionNodes.push(s);this.children=es(this.children,r,r+n.length,t,s)}update(t,e,r,n){if(this.dirty==Ri||!t.sameMarkup(this.node))return false;this.updateInner(t,e,r,n);return true}updateInner(t,e,r,n){this.updateOuterDeco(e);this.node=t;this.innerDeco=r;if(this.contentDOM)this.updateChildren(n,this.posAtStart);this.dirty=$i}updateOuterDeco(t){if(Wi(t,this.outerDeco))return;let e=this.nodeDOM.nodeType!=1;let r=this.dom;this.dom=qi(this.dom,this.nodeDOM,Ui(this.outerDeco,this.node,e),Ui(t,this.node,e));if(this.dom!=r){r.pmViewDesc=undefined;this.dom.pmViewDesc=this}this.outerDeco=t}selectNode(){if(this.nodeDOM.nodeType==1){this.nodeDOM.classList.add("ProseMirror-selectednode");if(this.contentDOM||!this.node.type.spec.draggable)this.nodeDOM.draggable=true}}deselectNode(){if(this.nodeDOM.nodeType==1){this.nodeDOM.classList.remove("ProseMirror-selectednode");if(this.contentDOM||!this.node.type.spec.draggable)this.nodeDOM.removeAttribute("draggable")}}get domAtom(){return this.node.isAtom}}function Di(t,e,r,n,i){Ki(n,e,t);let s=new Ii(undefined,t,e,r,n,n,n,i,0);if(s.contentDOM)s.updateChildren(i,0);return s}class Hi extends Ii{constructor(t,e,r,n,i,s,o){super(t,e,r,n,i,null,s,o,0)}parseRule(){let t=this.nodeDOM.parentNode;while(t&&t!=this.dom&&!t.pmIsDeco)t=t.parentNode;return{skip:t||true}}update(t,e,r,n){if(this.dirty==Ri||this.dirty!=$i&&!this.inParent()||!t.sameMarkup(this.node))return false;this.updateOuterDeco(e);if((this.dirty!=$i||t.text!=this.node.text)&&t.text!=this.nodeDOM.nodeValue){this.nodeDOM.nodeValue=t.text;if(n.trackWrites==this.nodeDOM)n.trackWrites=null}this.node=t;this.dirty=$i;return true}inParent(){let t=this.parent.contentDOM;for(let e=this.nodeDOM;e;e=e.parentNode)if(e==t)return true;return false}domFromPos(t){return{node:this.nodeDOM,offset:t}}localPosFromDOM(t,e,r){if(t==this.nodeDOM)return this.posAtStart+Math.min(e,this.node.text.length);return super.localPosFromDOM(t,e,r)}ignoreMutation(t){return t.type!="characterData"&&t.type!="selection"}slice(t,e,r){let n=this.node.cut(t,e),i=document.createTextNode(n.text);return new Hi(this.parent,n,this.outerDeco,this.innerDeco,i,i,r)}markDirty(t,e){super.markDirty(t,e);if(this.dom!=this.nodeDOM&&(t==0||e==this.nodeDOM.nodeValue.length))this.dirty=Ri}get domAtom(){return false}isText(t){return this.node.text==t}}class ji extends Ci{parseRule(){return{ignore:true}}matchesHack(t){return this.dirty==$i&&this.dom.nodeName==t}get domAtom(){return true}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class _i extends Ii{constructor(t,e,r,n,i,s,o,l,u,a){super(t,e,r,n,i,s,o,u,a);this.spec=l}update(t,e,r,n){if(this.dirty==Ri)return false;if(this.spec.update&&(this.node.type==t.type||this.spec.multiType)){let i=this.spec.update(t,e,r);if(i)this.updateInner(t,e,r,n);return i}else if(!this.contentDOM&&!t.isLeaf){return false}else{return super.update(t,e,r,n)}}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(t,e,r,n){this.spec.setSelection?this.spec.setSelection(t,e,r.root):super.setSelection(t,e,r,n)}destroy(){if(this.spec.destroy)this.spec.destroy();super.destroy()}stopEvent(t){return this.spec.stopEvent?this.spec.stopEvent(t):false}ignoreMutation(t){return this.spec.ignoreMutation?this.spec.ignoreMutation(t):super.ignoreMutation(t)}}function zi(t,e,r){let n=t.firstChild,i=false;for(let s=0;s<e.length;s++){let o=e[s],l=o.dom;if(l.parentNode==t){while(l!=n){n=Vi(n);i=true}n=n.nextSibling}else{i=true;t.insertBefore(l,n)}if(o instanceof Pi){let e=n?n.previousSibling:t.lastChild;zi(o.contentDOM,o.children,r);n=e?e.nextSibling:t.firstChild}}while(n){n=Vi(n);i=true}if(i&&r.trackWrites==t)r.trackWrites=null}const Bi=function(t){if(t)this.nodeName=t};Bi.prototype=Object.create(null);const Fi=[new Bi];function Ui(t,e,r){if(t.length==0)return Fi;let n=r?Fi[0]:new Bi,i=[n];for(let s=0;s<t.length;s++){let o=t[s].type.attrs;if(!o)continue;if(o.nodeName)i.push(n=new Bi(o.nodeName));for(let t in o){let s=o[t];if(s==null)continue;if(r&&i.length==1)i.push(n=new Bi(e.isInline?"span":"div"));if(t=="class")n.class=(n.class?n.class+" ":"")+s;else if(t=="style")n.style=(n.style?n.style+";":"")+s;else if(t!="nodeName")n[t]=s}}return i}function qi(t,e,r,n){if(r==Fi&&n==Fi)return e;let i=e;for(let e=0;e<n.length;e++){let s=n[e],o=r[e];if(e){let e;if(o&&o.nodeName==s.nodeName&&i!=t&&(e=i.parentNode)&&e.nodeName.toLowerCase()==s.nodeName){i=e}else{e=document.createElement(s.nodeName);e.pmIsDeco=true;e.appendChild(i);o=Fi[0];i=e}}Ji(i,o||Fi[0],s)}return i}function Ji(t,e,r){for(let n in e)if(n!="class"&&n!="style"&&n!="nodeName"&&!(n in r))t.removeAttribute(n);for(let n in r)if(n!="class"&&n!="style"&&n!="nodeName"&&r[n]!=e[n])t.setAttribute(n,r[n]);if(e.class!=r.class){let n=e.class?e.class.split(" ").filter(Boolean):[];let i=r.class?r.class.split(" ").filter(Boolean):[];for(let e=0;e<n.length;e++)if(i.indexOf(n[e])==-1)t.classList.remove(n[e]);for(let e=0;e<i.length;e++)if(n.indexOf(i[e])==-1)t.classList.add(i[e]);if(t.classList.length==0)t.removeAttribute("class")}if(e.style!=r.style){if(e.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,n;while(n=r.exec(e.style))t.style.removeProperty(n[1])}if(r.style)t.style.cssText+=r.style}}function Ki(t,e,r){return qi(t,t,Fi,Ui(e,r,t.nodeType!=1))}function Wi(t,e){if(t.length!=e.length)return false;for(let r=0;r<t.length;r++)if(!t[r].type.eq(e[r].type))return false;return true}function Vi(t){let e=t.nextSibling;t.parentNode.removeChild(t);return e}class Gi{constructor(t,e,r){this.lock=e;this.view=r;this.index=0;this.stack=[];this.changed=false;this.top=t;this.preMatch=Zi(t.node.content,t)}destroyBetween(t,e){if(t==e)return;for(let r=t;r<e;r++)this.top.children[r].destroy();this.top.children.splice(t,e-t);this.changed=true}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(t,e,r){let n=0,i=this.stack.length>>1;let s=Math.min(i,t.length);while(n<s&&(n==i-1?this.top:this.stack[n+1<<1]).matchesMark(t[n])&&t[n].type.spec.spanning!==false)n++;while(n<i){this.destroyRest();this.top.dirty=$i;this.index=this.stack.pop();this.top=this.stack.pop();i--}while(i<t.length){this.stack.push(this.top,this.index+1);let n=-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[i])&&!this.isLocked(r.dom)){n=e;break}}if(n>-1){if(n>this.index){this.changed=true;this.destroyBetween(this.index,n)}this.top=this.top.children[this.index]}else{let n=Pi.create(this.top,t[i],e,r);this.top.children.splice(this.index,0,n);this.top=n;this.changed=true}this.index=0;i++}}findNodeMatch(t,e,r,n){let i=-1,s;if(n>=this.preMatch.index&&(s=this.preMatch.matches[n-this.preMatch.index]).parent==this.top&&s.matchesNode(t,e,r)){i=this.top.children.indexOf(s,this.index)}else{for(let n=this.index,s=Math.min(this.top.children.length,n+5);n<s;n++){let s=this.top.children[n];if(s.matchesNode(t,e,r)&&!this.preMatch.matched.has(s)){i=n;break}}}if(i<0)return false;this.destroyBetween(this.index,i);this.index++;return true}updateNodeAt(t,e,r,n,i){let s=this.top.children[n];if(s.dirty==Ri&&s.dom==s.contentDOM)s.dirty=Oi;if(!s.update(t,e,r,i))return false;this.destroyBetween(this.index,n);this.index++;return true}findIndexWithChild(t){for(;;){let e=t.parentNode;if(!e)return-1;if(e==this.top.contentDOM){let e=t.pmViewDesc;if(e)for(let t=this.index;t<this.top.children.length;t++){if(this.top.children[t]==e)return t}return-1}t=e}}updateNextNode(t,e,r,n,i,s){for(let o=this.index;o<this.top.children.length;o++){let l=this.top.children[o];if(l instanceof Ii){let u=this.preMatch.matched.get(l);if(u!=null&&u!=i)return false;let a=l.dom,f;let h=this.isLocked(a)&&!(t.isText&&l.node&&l.node.isText&&l.nodeDOM.nodeValue==t.text&&l.dirty!=Ri&&Wi(e,l.outerDeco));if(!h&&l.update(t,e,r,n)){this.destroyBetween(this.index,o);if(l.dom!=a)this.changed=true;this.index++;return true}else if(!h&&(f=this.recreateWrapper(l,t,e,r,n,s))){this.destroyBetween(this.index,o);this.top.children[this.index]=f;if(f.contentDOM){f.dirty=Oi;f.updateChildren(n,s+1);f.dirty=$i}this.changed=true;this.index++;return true}break}}return false}recreateWrapper(t,e,r,n,i,s){if(t.dirty||e.isAtom||!t.children.length||!t.node.content.eq(e.content)||!Wi(r,t.outerDeco)||!n.eq(t.innerDeco))return null;let o=Ii.create(this.top,e,r,n,i,s);if(o.contentDOM){o.children=t.children;t.children=[];for(let t of o.children)t.parent=o}t.destroy();return o}addNode(t,e,r,n,i){let s=Ii.create(this.top,t,e,r,n,i);if(s.contentDOM)s.updateChildren(n,i+1);this.top.children.splice(this.index++,0,s);this.changed=true}placeWidget(t,e,r){let n=this.index<this.top.children.length?this.top.children[this.index]:null;if(n&&n.matchesWidget(t)&&(t==n.widget||!n.widget.type.toDOM.parentNode)){this.index++}else{let n=new Li(this.top,t,e,r);this.top.children.splice(this.index++,0,n);this.changed=true}}addTextblockHacks(){let t=this.top.children[this.index-1],e=this.top;while(t instanceof Pi){e=t;t=e.children[e.children.length-1]}if(!t||!(t instanceof Hi)||/\n$/.test(t.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(t.node.text)){if((Fn||zn)&&t&&t.dom.contentEditable=="false")this.addHackNode("IMG",e);this.addHackNode("BR",this.top)}}addHackNode(t,e){if(e==this.top&&this.index<e.children.length&&e.children[this.index].matchesHack(t)){this.index++}else{let r=document.createElement(t);if(t=="IMG"){r.className="ProseMirror-separator";r.alt=""}if(t=="BR")r.className="ProseMirror-trailingBreak";let n=new ji(this.top,[],r,null);if(e!=this.top)e.children.push(n);else e.children.splice(this.index++,0,n);this.changed=true}}isLocked(t){return this.lock&&(t==this.lock||t.nodeType==1&&t.contains(this.lock.parentNode))}}function Zi(t,e){let r=e,n=r.children.length;let i=t.childCount,s=new Map,o=[];t:while(i>0){let l;for(;;){if(n){let t=r.children[n-1];if(t instanceof Pi){r=t;n=t.children.length}else{l=t;n--;break}}else if(r==e){break t}else{n=r.parent.children.indexOf(r);r=r.parent}}let u=l.node;if(!u)continue;if(u!=t.child(i-1))break;--i;s.set(l,i);o.push(l)}return{index:i,matched:s,matches:o.reverse()}}function Qi(t,e){return t.type.side-e.type.side}function Xi(t,e,r,n){let i=e.locals(t),s=0;if(i.length==0){for(let r=0;r<t.childCount;r++){let o=t.child(r);n(o,i,e.forChild(s,o),r);s+=o.nodeSize}return}let o=0,l=[],u=null;for(let a=0;;){let f,h;while(o<i.length&&i[o].to==s){let t=i[o++];if(t.widget){if(!f)f=t;else(h||(h=[f])).push(t)}}if(f){if(h){h.sort(Qi);for(let t=0;t<h.length;t++)r(h[t],a,!!u)}else{r(f,a,!!u)}}let c,d;if(u){d=-1;c=u;u=null}else if(a<t.childCount){d=a;c=t.child(a++)}else{break}for(let t=0;t<l.length;t++)if(l[t].to<=s)l.splice(t--,1);while(o<i.length&&i[o].from<=s&&i[o].to>s)l.push(i[o++]);let p=s+c.nodeSize;if(c.isText){let t=p;if(o<i.length&&i[o].from<t)t=i[o].from;for(let e=0;e<l.length;e++)if(l[e].to<t)t=l[e].to;if(t<p){u=c.cut(t-s);c=c.cut(0,t-s);p=t;d=-1}}else{while(o<i.length&&i[o].to<p)o++}let m=c.isInline&&!c.isLeaf?l.filter((t=>!t.inline)):l.slice();n(c,m,e.forChild(s,c),d);s=p}}function Yi(t){if(t.nodeName=="UL"||t.nodeName=="OL"){let e=t.style.cssText;t.style.cssText=e+"; list-style: square !important";window.getComputedStyle(t).listStyle;t.style.cssText=e}}function ts(t,e,r,n){for(let i=0,s=0;i<t.childCount&&s<=n;){let o=t.child(i++),l=s;s+=o.nodeSize;if(!o.isText)continue;let u=o.text;while(i<t.childCount){let e=t.child(i++);s+=e.nodeSize;if(!e.isText)break;u+=e.text}if(s>=r){if(s>=n&&u.slice(n-e.length-l,n-l)==e)return n-e.length;let t=l<n?u.lastIndexOf(e,n-l-1):-1;if(t>=0&&t+e.length+l>=r)return l+t;if(r==n&&u.length>=n+e.length-l&&u.slice(n-l,n-l+e.length)==e)return n}}return-1}function es(t,e,r,n,i){let s=[];for(let o=0,l=0;o<t.length;o++){let u=t[o],a=l,f=l+=u.size;if(a>=r||f<=e){s.push(u)}else{if(a<e)s.push(u.slice(0,e-a,n));if(i){s.push(i);i=undefined}if(f>r)s.push(u.slice(r-a,u.size,n))}}return s}function rs(t,e=null){let r=t.domSelectionRange(),n=t.state.doc;if(!r.focusNode)return null;let i=t.docView.nearestDesc(r.focusNode),s=i&&i.size==0;let o=t.docView.posFromDOM(r.focusNode,r.focusOffset,1);if(o<0)return null;let l=n.resolve(o),u,a;if(En(r)){u=o;while(i&&!i.node)i=i.parent;let t=i.node;if(i&&t.isAtom&&rr.isSelectable(t)&&i.parent&&!(t.isInline&&Sn(r.focusNode,r.focusOffset,i.dom))){let t=i.posBefore;a=new rr(o==t?l:n.resolve(t))}}else{if(r instanceof t.dom.ownerDocument.defaultView.Selection&&r.rangeCount>1){let e=o,i=o;for(let n=0;n<r.rangeCount;n++){let s=r.getRangeAt(n);e=Math.min(e,t.docView.posFromDOM(s.startContainer,s.startOffset,1));i=Math.max(i,t.docView.posFromDOM(s.endContainer,s.endOffset,-1))}if(e<0)return null;[u,o]=i==t.state.selection.anchor?[i,e]:[e,i];l=n.resolve(o)}else{u=t.docView.posFromDOM(r.anchorNode,r.anchorOffset,1)}if(u<0)return null}let f=n.resolve(u);if(!a){let r=e=="pointer"||t.state.selection.head<l.pos&&!s?1:-1;a=ps(t,f,l,r)}return a}function ns(t){return t.editable?t.hasFocus():gs(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function is(t,e=false){let r=t.state.selection;cs(t,r);if(!ns(t))return;if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&zn){let e=t.domSelectionRange(),r=t.domObserver.currentSelection;if(e.anchorNode&&r.anchorNode&&bn(e.anchorNode,e.anchorOffset,r.anchorNode,r.anchorOffset)){t.input.mouseDown.delayedSelectionSync=true;t.domObserver.setCurSelection();return}}t.domObserver.disconnectSelection();if(t.cursorWrapper){hs(t)}else{let{anchor:n,head:i}=r,s,o;if(ss&&!(r instanceof tr)){if(!r.$from.parent.inlineContent)s=ls(t,r.from);if(!r.empty&&!r.$from.parent.inlineContent)o=ls(t,r.to)}t.docView.setSelection(n,i,t,e);if(ss){if(s)as(s);if(o)as(o)}if(r.visible){t.dom.classList.remove("ProseMirror-hideselection")}else{t.dom.classList.add("ProseMirror-hideselection");if("onselectionchange"in document)fs(t)}}t.domObserver.setCurSelection();t.domObserver.connectSelection()}const ss=Fn||zn&&Bn<63;function ls(t,e){let{node:r,offset:n}=t.docView.domFromPos(e,0);let i=n<r.childNodes.length?r.childNodes[n]:null;let s=n?r.childNodes[n-1]:null;if(Fn&&i&&i.contentEditable=="false")return us(i);if((!i||i.contentEditable=="false")&&(!s||s.contentEditable=="false")){if(i)return us(i);else if(s)return us(s)}}function us(t){t.contentEditable="true";if(Fn&&t.draggable){t.draggable=false;t.wasDraggable=true}return t}function as(t){t.contentEditable="false";if(t.wasDraggable){t.draggable=true;t.wasDraggable=null}}function fs(t){let e=t.dom.ownerDocument;e.removeEventListener("selectionchange",t.input.hideSelectionGuard);let r=t.domSelectionRange();let n=r.anchorNode,i=r.anchorOffset;e.addEventListener("selectionchange",t.input.hideSelectionGuard=()=>{if(r.anchorNode!=n||r.anchorOffset!=i){e.removeEventListener("selectionchange",t.input.hideSelectionGuard);setTimeout((()=>{if(!ns(t)||t.state.selection.visible)t.dom.classList.remove("ProseMirror-hideselection")}),20)}})}function hs(t){let e=t.domSelection();if(!e)return;let r=t.cursorWrapper.dom,n=r.nodeName=="IMG";if(n)e.collapse(r.parentNode,dn(r)+1);else e.collapse(r,0);if(!n&&!t.state.selection.visible&&Dn&&Hn<=11){r.disabled=true;r.disabled=false}}function cs(t,e){if(e instanceof rr){let r=t.docView.descAt(e.from);if(r!=t.lastSelectedViewDesc){ds(t);if(r)r.selectNode();t.lastSelectedViewDesc=r}}else{ds(t)}}function ds(t){if(t.lastSelectedViewDesc){if(t.lastSelectedViewDesc.parent)t.lastSelectedViewDesc.deselectNode();t.lastSelectedViewDesc=undefined}}function ps(t,e,r,n){return t.someProp("createSelectionBetween",(n=>n(t,e,r)))||tr.between(e,r,n)}function ms(t){if(t.editable&&!t.hasFocus())return false;return gs(t)}function gs(t){let e=t.domSelectionRange();if(!e.anchorNode)return false;try{return t.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(t.editable||t.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch(t){return false}}function ws(t){let e=t.docView.domFromPos(t.state.selection.anchor,0);let r=t.domSelectionRange();return bn(e.node,e.offset,r.anchorNode,r.anchorOffset)}function bs(t,e){let{$anchor:r,$head:n}=t.selection;let i=e>0?r.max(n):r.min(n);let s=!i.parent.inlineContent?i:i.depth?t.doc.resolve(e>0?i.after():i.before()):null;return s&&Ze.findFrom(s,e)}function ks(t,e){t.dispatch(t.state.tr.setSelection(e).scrollIntoView());return true}function vs(t,e,r){let n=t.state.selection;if(n instanceof tr){if(r.indexOf("s")>-1){let{$head:r}=n,i=r.textOffset?null:e<0?r.nodeBefore:r.nodeAfter;if(!i||i.isText||!i.isLeaf)return false;let s=t.state.doc.resolve(r.pos+i.nodeSize*(e<0?-1:1));return ks(t,new tr(n.$anchor,s))}else if(!n.empty){return false}else if(t.endOfTextblock(e>0?"forward":"backward")){let r=bs(t.state,e);if(r&&r instanceof rr)return ks(t,r);return false}else if(!(qn&&r.indexOf("m")>-1)){let r=n.$head,i=r.textOffset?null:e<0?r.nodeBefore:r.nodeAfter,s;if(!i||i.isText)return false;let o=e<0?r.pos-i.nodeSize:r.pos;if(!(i.isAtom||(s=t.docView.descAt(o))&&!s.contentDOM))return false;if(rr.isSelectable(i)){return ks(t,new rr(e<0?t.state.doc.resolve(r.pos-i.nodeSize):r))}else if(Wn){return ks(t,new tr(t.state.doc.resolve(e<0?o:o+i.nodeSize)))}else{return false}}}else if(n instanceof rr&&n.node.isInline){return ks(t,new tr(e>0?n.$to:n.$from))}else{let r=bs(t.state,e);if(r)return ks(t,r);return false}}function ys(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function Ms(t,e){let r=t.pmViewDesc;return r&&r.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function xs(t,e){return e<0?Ss(t):Ts(t)}function Ss(t){let e=t.domSelectionRange();let r=e.focusNode,n=e.focusOffset;if(!r)return;let i,s,o=false;if(jn&&r.nodeType==1&&n<ys(r)&&Ms(r.childNodes[n],-1))o=true;for(;;){if(n>0){if(r.nodeType!=1){break}else{let t=r.childNodes[n-1];if(Ms(t,-1)){i=r;s=--n}else if(t.nodeType==3){r=t;n=r.nodeValue.length}else break}}else if(Es(r)){break}else{let e=r.previousSibling;while(e&&Ms(e,-1)){i=r.parentNode;s=dn(e);e=e.previousSibling}if(!e){r=r.parentNode;if(r==t.dom)break;n=0}else{r=e;n=ys(r)}}}if(o)Os(t,r,n);else if(i)Os(t,i,s)}function Ts(t){let e=t.domSelectionRange();let r=e.focusNode,n=e.focusOffset;if(!r)return;let i=ys(r);let s,o;for(;;){if(n<i){if(r.nodeType!=1)break;let t=r.childNodes[n];if(Ms(t,1)){s=r;o=++n}else break}else if(Es(r)){break}else{let e=r.nextSibling;while(e&&Ms(e,1)){s=e.parentNode;o=dn(e)+1;e=e.nextSibling}if(!e){r=r.parentNode;if(r==t.dom)break;n=i=0}else{r=e;n=0;i=ys(r)}}}if(s)Os(t,s,o)}function Es(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function $s(t,e){while(t&&e==t.childNodes.length&&!Tn(t)){e=dn(t)+1;t=t.parentNode}while(t&&e<t.childNodes.length){let r=t.childNodes[e];if(r.nodeType==3)return r;if(r.nodeType==1&&r.contentEditable=="false")break;t=r;e=0}}function As(t,e){while(t&&!e&&!Tn(t)){e=dn(t);t=t.parentNode}while(t&&e){let r=t.childNodes[e-1];if(r.nodeType==3)return r;if(r.nodeType==1&&r.contentEditable=="false")break;t=r;e=t.childNodes.length}}function Os(t,e,r){if(e.nodeType!=3){let t,n;if(n=$s(e,r)){e=n;r=0}else if(t=As(e,r)){e=t;r=t.nodeValue.length}}let n=t.domSelection();if(!n)return;if(En(n)){let t=document.createRange();t.setEnd(e,r);t.setStart(e,r);n.removeAllRanges();n.addRange(t)}else if(n.extend){n.extend(e,r)}t.domObserver.setCurSelection();let{state:i}=t;setTimeout((()=>{if(t.state==i)is(t)}),50)}function Rs(t,e){let r=t.state.doc.resolve(e);if(!(zn||Jn)&&r.parent.inlineContent){let n=t.coordsAtPos(e);if(e>r.start()){let r=t.coordsAtPos(e-1);let i=(r.top+r.bottom)/2;if(i>n.top&&i<n.bottom&&Math.abs(r.left-n.left)>1)return r.left<n.left?"ltr":"rtl"}if(e<r.end()){let r=t.coordsAtPos(e+1);let i=(r.top+r.bottom)/2;if(i>n.top&&i<n.bottom&&Math.abs(r.left-n.left)>1)return r.left>n.left?"ltr":"rtl"}}let n=getComputedStyle(t.dom).direction;return n=="rtl"?"rtl":"ltr"}function Cs(t,e,r){let n=t.state.selection;if(n instanceof tr&&!n.empty||r.indexOf("s")>-1)return false;if(qn&&r.indexOf("m")>-1)return false;let{$from:i,$to:s}=n;if(!i.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let r=bs(t.state,e);if(r&&r instanceof rr)return ks(t,r)}if(!i.parent.inlineContent){let r=e<0?i:s;let o=n instanceof ir?Ze.near(r,e):Ze.findFrom(r,e);return o?ks(t,o):false}return false}function Ls(t,e){if(!(t.state.selection instanceof tr))return true;let{$head:r,$anchor:n,empty:i}=t.state.selection;if(!r.sameParent(n))return true;if(!i)return false;if(t.endOfTextblock(e>0?"forward":"backward"))return true;let s=!r.textOffset&&(e<0?r.nodeBefore:r.nodeAfter);if(s&&!s.isText){let n=t.state.tr;if(e<0)n.delete(r.pos-s.nodeSize,r.pos);else n.delete(r.pos,r.pos+s.nodeSize);t.dispatch(n);return true}return false}function Ns(t,e,r){t.domObserver.stop();e.contentEditable=r;t.domObserver.start()}function Ps(t){if(!Fn||t.state.selection.$head.parentOffset>0)return false;let{focusNode:e,focusOffset:r}=t.domSelectionRange();if(e&&e.nodeType==1&&r==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;Ns(t,r,"true");setTimeout((()=>Ns(t,r,"false")),20)}return false}function Is(t){let e="";if(t.ctrlKey)e+="c";if(t.metaKey)e+="m";if(t.altKey)e+="a";if(t.shiftKey)e+="s";return e}function Ds(t,e){let r=e.keyCode,n=Is(e);if(r==8||qn&&r==72&&n=="c"){return Ls(t,-1)||xs(t,-1)}else if(r==46&&!e.shiftKey||qn&&r==68&&n=="c"){return Ls(t,1)||xs(t,1)}else if(r==13||r==27){return true}else if(r==37||qn&&r==66&&n=="c"){let e=r==37?Rs(t,t.state.selection.from)=="ltr"?-1:1:-1;return vs(t,e,n)||xs(t,e)}else if(r==39||qn&&r==70&&n=="c"){let e=r==39?Rs(t,t.state.selection.from)=="ltr"?1:-1:1;return vs(t,e,n)||xs(t,e)}else if(r==38||qn&&r==80&&n=="c"){return Cs(t,-1,n)||xs(t,-1)}else if(r==40||qn&&r==78&&n=="c"){return Ps(t)||Cs(t,1,n)||xs(t,1)}else if(n==(qn?"m":"c")&&(r==66||r==73||r==89||r==90)){return true}return false}function Hs(t,e){t.someProp("transformCopied",(r=>{e=r(e,t)}));let r=[],{content:n,openStart:i,openEnd:s}=e;while(i>1&&s>1&&n.childCount==1&&n.firstChild.childCount==1){i--;s--;let t=n.firstChild;r.push(t.type.name,t.attrs!=t.type.defaultAttrs?t.attrs:null);n=t.content}let o=t.someProp("clipboardSerializer")||Ot.fromSchema(t.state.schema);let l=Vs(),u=l.createElement("div");u.appendChild(o.serializeFragment(n,{document:l}));let a=u.firstChild,f,h=0;while(a&&a.nodeType==1&&(f=Ks[a.nodeName.toLowerCase()])){for(let t=f.length-1;t>=0;t--){let e=l.createElement(f[t]);while(u.firstChild)e.appendChild(u.firstChild);u.appendChild(e);h++}a=u.firstChild}if(a&&a.nodeType==1)a.setAttribute("data-pm-slice",`${i} ${s}${h?` -${h}`:""} ${JSON.stringify(r)}`);let c=t.someProp("clipboardTextSerializer",(r=>r(e,t)))||e.content.textBetween(0,e.content.size,"\n\n");return{dom:u,text:c,slice:e}}function js(t,e,r,n,i){let s=i.parent.type.spec.code;let o,l;if(!r&&!e)return null;let u=!!e&&(n||s||!r);if(u){t.someProp("transformPastedText",(r=>{e=r(e,s||n,t)}));if(s){l=new y(m.from(t.state.schema.text(e.replace(/\r\n?/g,"\n"))),0,0);t.someProp("transformPasted",(e=>{l=e(l,t,true)}));return l}let r=t.someProp("clipboardTextParser",(r=>r(e,i,n,t)));if(r){l=r}else{let r=i.marks();let{schema:n}=t.state,s=Ot.fromSchema(n);o=document.createElement("div");e.split(/(?:\r\n?|\n)+/).forEach((t=>{let e=o.appendChild(document.createElement("p"));if(t)e.appendChild(s.serializeNode(n.text(t,r)))}))}}else{t.someProp("transformPastedHTML",(e=>{r=e(r,t)}));o=Qs(r);if(Wn)Xs(o)}let a=o&&o.querySelector("[data-pm-slice]");let f=a&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(a.getAttribute("data-pm-slice")||"");if(f&&f[3])for(let t=+f[3];t>0;t--){let t=o.firstChild;while(t&&t.nodeType!=1)t=t.nextSibling;if(!t)break;o=t}if(!l){let e=t.someProp("clipboardParser")||t.someProp("domParser")||mt.fromSchema(t.state.schema);l=e.parseSlice(o,{preserveWhitespace:!!(u||f),context:i,ruleFromNode(t){if(t.nodeName=="BR"&&!t.nextSibling&&t.parentNode&&!_s.test(t.parentNode.nodeName))return{ignore:true};return null}})}if(f){l=Ys(Js(l,+f[1],+f[2]),f[4])}else{l=y.maxOpen(zs(l.content,i),true);if(l.openStart||l.openEnd){let t=0,e=0;for(let e=l.content.firstChild;t<l.openStart&&!e.type.spec.isolating;t++,e=e.firstChild){}for(let t=l.content.lastChild;e<l.openEnd&&!t.type.spec.isolating;e++,t=t.lastChild){}l=Js(l,t,e)}}t.someProp("transformPasted",(e=>{l=e(l,t,u)}));return l}const _s=/^(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 zs(t,e){if(t.childCount<2)return t;for(let r=e.depth;r>=0;r--){let n=e.node(r);let i=n.contentMatchAt(e.index(r));let s,o=[];t.forEach((t=>{if(!o)return;let e=i.findWrapping(t.type),r;if(!e)return o=null;if(r=o.length&&s.length&&Fs(e,s,t,o[o.length-1],0)){o[o.length-1]=r}else{if(o.length)o[o.length-1]=Us(o[o.length-1],s.length);let r=Bs(t,e);o.push(r);i=i.matchType(r.type);s=e}}));if(o)return m.from(o)}return t}function Bs(t,e,r=0){for(let n=e.length-1;n>=r;n--)t=e[n].create(null,m.from(t));return t}function Fs(t,e,r,n,i){if(i<t.length&&i<e.length&&t[i]==e[i]){let s=Fs(t,e,r,n.lastChild,i+1);if(s)return n.copy(n.content.replaceChild(n.childCount-1,s));let o=n.contentMatchAt(n.childCount);if(o.matchType(i==t.length-1?r.type:t[i+1]))return n.copy(n.content.append(m.from(Bs(r,t,i+1))))}}function Us(t,e){if(e==0)return t;let r=t.content.replaceChild(t.childCount-1,Us(t.lastChild,e-1));let n=t.contentMatchAt(t.childCount).fillBefore(m.empty,true);return t.copy(r.append(n))}function qs(t,e,r,n,i,s){let o=e<0?t.firstChild:t.lastChild,l=o.content;if(t.childCount>1)s=0;if(i<n-1)l=qs(l,e,r,n,i+1,s);if(i>=r)l=e<0?o.contentMatchAt(0).fillBefore(l,s<=i).append(l):l.append(o.contentMatchAt(o.childCount).fillBefore(m.empty,true));return t.replaceChild(e<0?0:t.childCount-1,o.copy(l))}function Js(t,e,r){if(e<t.openStart)t=new y(qs(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd);if(r<t.openEnd)t=new y(qs(t.content,1,r,t.openEnd,0,0),t.openStart,r);return t}const Ks={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 Ws=null;function Vs(){return Ws||(Ws=document.implementation.createHTMLDocument("title"))}let Gs=null;function Zs(t){let e=window.trustedTypes;if(!e)return t;if(!Gs)Gs=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t});return Gs.createHTML(t)}function Qs(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);if(e)t=t.slice(e[0].length);let r=Vs().createElement("div");let n=/<([a-z][^>\s]+)/i.exec(t),i;if(i=n&&Ks[n[1].toLowerCase()])t=i.map((t=>"<"+t+">")).join("")+t+i.map((t=>"</"+t+">")).reverse().join("");r.innerHTML=Zs(t);if(i)for(let t=0;t<i.length;t++)r=r.querySelector(i[t])||r;return r}function Xs(t){let e=t.querySelectorAll(zn?"span:not([class]):not([style])":"span.Apple-converted-space");for(let r=0;r<e.length;r++){let n=e[r];if(n.childNodes.length==1&&n.textContent==" "&&n.parentNode)n.parentNode.replaceChild(t.ownerDocument.createTextNode(" "),n)}}function Ys(t,e){if(!t.size)return t;let r=t.content.firstChild.type.schema,n;try{n=JSON.parse(e)}catch(e){return t}let{content:i,openStart:s,openEnd:o}=t;for(let t=n.length-2;t>=0;t-=2){let e=r.nodes[n[t]];if(!e||e.hasRequiredAttrs())break;i=m.from(e.create(n[t+1],i));s++;o++}return new y(i,s,o)}const to={};const eo={};const ro={touchstart:true,touchmove:true};class no{constructor(){this.shiftKey=false;this.mouseDown=null;this.lastKeyCode=null;this.lastKeyCodeTime=0;this.lastClick={time:0,x:0,y:0,type:"",button:0};this.lastSelectionOrigin=null;this.lastSelectionTime=0;this.lastIOSEnter=0;this.lastIOSEnterFallbackTimeout=-1;this.lastFocus=0;this.lastTouch=0;this.lastChromeDelete=0;this.composing=false;this.compositionNode=null;this.composingTimeout=-1;this.compositionNodes=[];this.compositionEndedAt=-2e8;this.compositionID=1;this.compositionPendingChanges=0;this.domChangeCount=0;this.eventHandlers=Object.create(null);this.hideSelectionGuard=null}}function io(t){for(let e in to){let r=to[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=e=>{if(ao(t,e)&&!uo(t,e)&&(t.editable||!(e.type in eo)))r(t,e)},ro[e]?{passive:true}:undefined)}if(Fn)t.dom.addEventListener("input",(()=>null));lo(t)}function so(t,e){t.input.lastSelectionOrigin=e;t.input.lastSelectionTime=Date.now()}function oo(t){t.domObserver.stop();for(let e in t.input.eventHandlers)t.dom.removeEventListener(e,t.input.eventHandlers[e]);clearTimeout(t.input.composingTimeout);clearTimeout(t.input.lastIOSEnterFallbackTimeout)}function lo(t){t.someProp("handleDOMEvents",(e=>{for(let r in e)if(!t.input.eventHandlers[r])t.dom.addEventListener(r,t.input.eventHandlers[r]=e=>uo(t,e))}))}function uo(t,e){return t.someProp("handleDOMEvents",(r=>{let n=r[e.type];return n?n(t,e)||e.defaultPrevented:false}))}function ao(t,e){if(!e.bubbles)return true;if(e.defaultPrevented)return false;for(let r=e.target;r!=t.dom;r=r.parentNode)if(!r||r.nodeType==11||r.pmViewDesc&&r.pmViewDesc.stopEvent(e))return false;return true}function fo(t,e){if(!uo(t,e)&&to[e.type]&&(t.editable||!(e.type in eo)))to[e.type](t,e)}eo.keydown=(t,e)=>{let r=e;t.input.shiftKey=r.keyCode==16||r.shiftKey;if(To(t,r))return;t.input.lastKeyCode=r.keyCode;t.input.lastKeyCodeTime=Date.now();if(Kn&&zn&&r.keyCode==13)return;if(r.keyCode!=229)t.domObserver.forceFlush();if(Un&&r.keyCode==13&&!r.ctrlKey&&!r.altKey&&!r.metaKey){let e=Date.now();t.input.lastIOSEnter=e;t.input.lastIOSEnterFallbackTimeout=setTimeout((()=>{if(t.input.lastIOSEnter==e){t.someProp("handleKeyDown",(e=>e(t,$n(13,"Enter"))));t.input.lastIOSEnter=0}}),200)}else if(t.someProp("handleKeyDown",(e=>e(t,r)))||Ds(t,r)){r.preventDefault()}else{so(t,"key")}};eo.keyup=(t,e)=>{if(e.keyCode==16)t.input.shiftKey=false};eo.keypress=(t,e)=>{let r=e;if(To(t,r)||!r.charCode||r.ctrlKey&&!r.altKey||qn&&r.metaKey)return;if(t.someProp("handleKeyPress",(e=>e(t,r)))){r.preventDefault();return}let n=t.state.selection;if(!(n instanceof tr)||!n.$from.sameParent(n.$to)){let e=String.fromCharCode(r.charCode);let i=()=>t.state.tr.insertText(e).scrollIntoView();if(!/[\r\n]/.test(e)&&!t.someProp("handleTextInput",(r=>r(t,n.$from.pos,n.$to.pos,e,i))))t.dispatch(i());r.preventDefault()}};function ho(t){return{left:t.clientX,top:t.clientY}}function co(t,e){let r=e.x-t.clientX,n=e.y-t.clientY;return r*r+n*n<100}function po(t,e,r,n,i){if(n==-1)return false;let s=t.state.doc.resolve(n);for(let n=s.depth+1;n>0;n--){if(t.someProp(e,(e=>n>s.depth?e(t,r,s.nodeAfter,s.before(n),i,true):e(t,r,s.node(n),s.before(n),i,false))))return true}return false}function mo(t,e,r){if(!t.focused)t.focus();if(t.state.selection.eq(e))return;let n=t.state.tr.setSelection(e);if(r=="pointer")n.setMeta("pointer",true);t.dispatch(n)}function go(t,e){if(e==-1)return false;let r=t.state.doc.resolve(e),n=r.nodeAfter;if(n&&n.isAtom&&rr.isSelectable(n)){mo(t,new rr(r),"pointer");return true}return false}function wo(t,e){if(e==-1)return false;let r=t.state.selection,n,i;if(r instanceof rr)n=r.node;let s=t.state.doc.resolve(e);for(let t=s.depth+1;t>0;t--){let e=t>s.depth?s.nodeAfter:s.node(t);if(rr.isSelectable(e)){if(n&&r.$from.depth>0&&t>=r.$from.depth&&s.before(r.$from.depth+1)==r.$from.pos)i=s.before(r.$from.depth);else i=s.before(t);break}}if(i!=null){mo(t,rr.create(t.state.doc,i),"pointer");return true}else{return false}}function bo(t,e,r,n,i){return po(t,"handleClickOn",e,r,n)||t.someProp("handleClick",(r=>r(t,e,n)))||(i?wo(t,r):go(t,r))}function ko(t,e,r,n){return po(t,"handleDoubleClickOn",e,r,n)||t.someProp("handleDoubleClick",(r=>r(t,e,n)))}function vo(t,e,r,n){return po(t,"handleTripleClickOn",e,r,n)||t.someProp("handleTripleClick",(r=>r(t,e,n)))||yo(t,r,n)}function yo(t,e,r){if(r.button!=0)return false;let n=t.state.doc;if(e==-1){if(n.inlineContent){mo(t,tr.create(n,0,n.content.size),"pointer");return true}return false}let i=n.resolve(e);for(let e=i.depth+1;e>0;e--){let r=e>i.depth?i.nodeAfter:i.node(e);let s=i.before(e);if(r.inlineContent)mo(t,tr.create(n,s+1,s+1+r.content.size),"pointer");else if(rr.isSelectable(r))mo(t,rr.create(n,s),"pointer");else continue;return true}}function Mo(t){return Co(t)}const xo=qn?"metaKey":"ctrlKey";to.mousedown=(t,e)=>{let r=e;t.input.shiftKey=r.shiftKey;let n=Mo(t);let i=Date.now(),s="singleClick";if(i-t.input.lastClick.time<500&&co(r,t.input.lastClick)&&!r[xo]&&t.input.lastClick.button==r.button){if(t.input.lastClick.type=="singleClick")s="doubleClick";else if(t.input.lastClick.type=="doubleClick")s="tripleClick"}t.input.lastClick={time:i,x:r.clientX,y:r.clientY,type:s,button:r.button};let o=t.posAtCoords(ho(r));if(!o)return;if(s=="singleClick"){if(t.input.mouseDown)t.input.mouseDown.done();t.input.mouseDown=new So(t,o,r,!!n)}else if((s=="doubleClick"?ko:vo)(t,o.pos,o.inside,r)){r.preventDefault()}else{so(t,"pointer")}};class So{constructor(t,e,r,n){this.view=t;this.pos=e;this.event=r;this.flushed=n;this.delayedSelectionSync=false;this.mightDrag=null;this.startDoc=t.state.doc;this.selectNode=!!r[xo];this.allowDefault=r.shiftKey;let i,s;if(e.inside>-1){i=t.state.doc.nodeAt(e.inside);s=e.inside}else{let r=t.state.doc.resolve(e.pos);i=r.parent;s=r.depth?r.before():0}const o=n?null:r.target;const l=o?t.docView.nearestDesc(o,true):null;this.target=l&&l.nodeDOM.nodeType==1?l.nodeDOM:null;let{selection:u}=t.state;if(r.button==0&&i.type.spec.draggable&&i.type.spec.selectable!==false||u instanceof rr&&u.from<=s&&u.to>s)this.mightDrag={node:i,pos:s,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&jn&&!this.target.hasAttribute("contentEditable"))};if(this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)){this.view.domObserver.stop();if(this.mightDrag.addAttr)this.target.draggable=true;if(this.mightDrag.setUneditable)setTimeout((()=>{if(this.view.input.mouseDown==this)this.target.setAttribute("contentEditable","false")}),20);this.view.domObserver.start()}t.root.addEventListener("mouseup",this.up=this.up.bind(this));t.root.addEventListener("mousemove",this.move=this.move.bind(this));so(t,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up);this.view.root.removeEventListener("mousemove",this.move);if(this.mightDrag&&this.target){this.view.domObserver.stop();if(this.mightDrag.addAttr)this.target.removeAttribute("draggable");if(this.mightDrag.setUneditable)this.target.removeAttribute("contentEditable");this.view.domObserver.start()}if(this.delayedSelectionSync)setTimeout((()=>is(this.view)));this.view.input.mouseDown=null}up(t){this.done();if(!this.view.dom.contains(t.target))return;let e=this.pos;if(this.view.state.doc!=this.startDoc)e=this.view.posAtCoords(ho(t));this.updateAllowDefault(t);if(this.allowDefault||!e){so(this.view,"pointer")}else if(bo(this.view,e.pos,e.inside,t,this.selectNode)){t.preventDefault()}else if(t.button==0&&(this.flushed||Fn&&this.mightDrag&&!this.mightDrag.node.isAtom||zn&&!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)){mo(this.view,Ze.near(this.view.state.doc.resolve(e.pos)),"pointer");t.preventDefault()}else{so(this.view,"pointer")}}move(t){this.updateAllowDefault(t);so(this.view,"pointer");if(t.buttons==0)this.done()}updateAllowDefault(t){if(!this.allowDefault&&(Math.abs(this.event.x-t.clientX)>4||Math.abs(this.event.y-t.clientY)>4))this.allowDefault=true}}to.touchstart=t=>{t.input.lastTouch=Date.now();Mo(t);so(t,"pointer")};to.touchmove=t=>{t.input.lastTouch=Date.now();so(t,"pointer")};to.contextmenu=t=>Mo(t);function To(t,e){if(t.composing)return true;if(Fn&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500){t.input.compositionEndedAt=-2e8;return true}return false}const Eo=Kn?5e3:-1;eo.compositionstart=eo.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,r=e.selection.$to;if(e.selection instanceof tr&&(e.storedMarks||!r.textOffset&&r.parentOffset&&r.nodeBefore.marks.some((t=>t.type.spec.inclusive===false)))){t.markCursor=t.state.storedMarks||r.marks();Co(t,true);t.markCursor=null}else{Co(t,!e.selection.empty);if(jn&&e.selection.empty&&r.parentOffset&&!r.textOffset&&r.nodeBefore.marks.length){let e=t.domSelectionRange();for(let r=e.focusNode,n=e.focusOffset;r&&r.nodeType==1&&n!=0;){let e=n<0?r.lastChild:r.childNodes[n-1];if(!e)break;if(e.nodeType==3){let r=t.domSelection();if(r)r.collapse(e,e.nodeValue.length);break}else{r=e;n=-1}}}}t.input.composing=true}$o(t,Eo)};eo.compositionend=(t,e)=>{if(t.composing){t.input.composing=false;t.input.compositionEndedAt=e.timeStamp;t.input.compositionPendingChanges=t.domObserver.pendingRecords().length?t.input.compositionID:0;t.input.compositionNode=null;if(t.input.compositionPendingChanges)Promise.resolve().then((()=>t.domObserver.flush()));t.input.compositionID++;$o(t,20)}};function $o(t,e){clearTimeout(t.input.composingTimeout);if(e>-1)t.input.composingTimeout=setTimeout((()=>Co(t)),e)}function Ao(t){if(t.composing){t.input.composing=false;t.input.compositionEndedAt=Ro()}while(t.input.compositionNodes.length>0)t.input.compositionNodes.pop().markParentsDirty()}function Oo(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let r=Mn(e.focusNode,e.focusOffset);let n=xn(e.focusNode,e.focusOffset);if(r&&n&&r!=n){let e=n.pmViewDesc,i=t.domObserver.lastChangedTextNode;if(r==i||n==i)return i;if(!e||!e.isText(n.nodeValue)){return n}else if(t.input.compositionNode==n){let t=r.pmViewDesc;if(!(!t||!t.isText(r.nodeValue)))return n}}return r||n}function Ro(){let t=document.createEvent("Event");t.initEvent("event",true,true);return t.timeStamp}function Co(t,e=false){if(Kn&&t.domObserver.flushingSoon>=0)return;t.domObserver.forceFlush();Ao(t);if(e||t.docView&&t.docView.dirty){let r=rs(t),n=t.state.selection;if(r&&!r.eq(n))t.dispatch(t.state.tr.setSelection(r));else if((t.markCursor||e)&&!n.$from.node(n.$from.sharedDepth(n.to)).inlineContent)t.dispatch(t.state.tr.deleteSelection());else t.updateState(t.state);return true}return false}function Lo(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 n=getSelection(),i=document.createRange();i.selectNodeContents(e);t.dom.blur();n.removeAllRanges();n.addRange(i);setTimeout((()=>{if(r.parentNode)r.parentNode.removeChild(r);t.focus()}),50)}const No=Dn&&Hn<15||Un&&Vn<604;to.copy=eo.cut=(t,e)=>{let r=e;let n=t.state.selection,i=r.type=="cut";if(n.empty)return;let s=No?null:r.clipboardData;let o=n.content(),{dom:l,text:u}=Hs(t,o);if(s){r.preventDefault();s.clearData();s.setData("text/html",l.innerHTML);s.setData("text/plain",u)}else{Lo(t,l)}if(i)t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function Po(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function Io(t,e){if(!t.dom.parentNode)return;let r=t.input.shiftKey||t.state.selection.$from.parent.type.spec.code;let n=t.dom.parentNode.appendChild(document.createElement(r?"textarea":"div"));if(!r)n.contentEditable="true";n.style.cssText="position: fixed; left: -10000px; top: 10px";n.focus();let i=t.input.shiftKey&&t.input.lastKeyCode!=45;setTimeout((()=>{t.focus();if(n.parentNode)n.parentNode.removeChild(n);if(r)Do(t,n.value,null,i,e);else Do(t,n.textContent,n.innerHTML,i,e)}),50)}function Do(t,e,r,n,i){let s=js(t,e,r,n,t.state.selection.$from);if(t.someProp("handlePaste",(e=>e(t,i,s||y.empty))))return true;if(!s)return false;let o=Po(s);let l=o?t.state.tr.replaceSelectionWith(o,n):t.state.tr.replaceSelection(s);t.dispatch(l.scrollIntoView().setMeta("paste",true).setMeta("uiEvent","paste"));return true}function Ho(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," "):""}eo.paste=(t,e)=>{let r=e;if(t.composing&&!Kn)return;let n=No?null:r.clipboardData;let i=t.input.shiftKey&&t.input.lastKeyCode!=45;if(n&&Do(t,Ho(n),n.getData("text/html"),i,r))r.preventDefault();else Io(t,r)};class jo{constructor(t,e,r){this.slice=t;this.move=e;this.node=r}}const _o=qn?"altKey":"ctrlKey";function zo(t,e){let r=t.someProp("dragCopies",(t=>!t(e)));return r!=null?r:!e[_o]}to.dragstart=(t,e)=>{let r=e;let n=t.input.mouseDown;if(n)n.done();if(!r.dataTransfer)return;let i=t.state.selection;let s=i.empty?null:t.posAtCoords(ho(r));let o;if(s&&s.pos>=i.from&&s.pos<=(i instanceof rr?i.to-1:i.to));else if(n&&n.mightDrag){o=rr.create(t.state.doc,n.mightDrag.pos)}else if(r.target&&r.target.nodeType==1){let e=t.docView.nearestDesc(r.target,true);if(e&&e.node.type.spec.draggable&&e!=t.docView)o=rr.create(t.state.doc,e.posBefore)}let l=(o||t.state.selection).content();let{dom:u,text:a,slice:f}=Hs(t,l);if(!r.dataTransfer.files.length||!zn||Bn>120)r.dataTransfer.clearData();r.dataTransfer.setData(No?"Text":"text/html",u.innerHTML);r.dataTransfer.effectAllowed="copyMove";if(!No)r.dataTransfer.setData("text/plain",a);t.dragging=new jo(f,zo(t,r),o)};to.dragend=t=>{let e=t.dragging;window.setTimeout((()=>{if(t.dragging==e)t.dragging=null}),50)};eo.dragover=eo.dragenter=(t,e)=>e.preventDefault();eo.drop=(t,e)=>{let r=e;let n=t.dragging;t.dragging=null;if(!r.dataTransfer)return;let i=t.posAtCoords(ho(r));if(!i)return;let s=t.state.doc.resolve(i.pos);let o=n&&n.slice;if(o){t.someProp("transformPasted",(e=>{o=e(o,t,false)}))}else{o=js(t,Ho(r.dataTransfer),No?null:r.dataTransfer.getData("text/html"),false,s)}let l=!!(n&&zo(t,r));if(t.someProp("handleDrop",(e=>e(t,r,o||y.empty,l)))){r.preventDefault();return}if(!o)return;r.preventDefault();let u=o?Oe(t.state.doc,s.pos,o):s.pos;if(u==null)u=s.pos;let a=t.state.tr;if(l){let{node:t}=n;if(t)t.replace(a);else a.deleteSelection()}let f=a.mapping.map(u);let h=o.openStart==0&&o.openEnd==0&&o.content.childCount==1;let c=a.doc;if(h)a.replaceRangeWith(f,f,o.content.firstChild);else a.replaceRange(f,f,o);if(a.doc.eq(c))return;let d=a.doc.resolve(f);if(h&&rr.isSelectable(o.content.firstChild)&&d.nodeAfter&&d.nodeAfter.sameMarkup(o.content.firstChild)){a.setSelection(new rr(d))}else{let e=a.mapping.map(u);a.mapping.maps[a.mapping.maps.length-1].forEach(((t,r,n,i)=>e=i));a.setSelection(ps(t,d,a.doc.resolve(e)))}t.focus();t.dispatch(a.setMeta("uiEvent","drop"))};to.focus=t=>{t.input.lastFocus=Date.now();if(!t.focused){t.domObserver.stop();t.dom.classList.add("ProseMirror-focused");t.domObserver.start();t.focused=true;setTimeout((()=>{if(t.docView&&t.hasFocus()&&!t.domObserver.currentSelection.eq(t.domSelectionRange()))is(t)}),20)}};to.blur=(t,e)=>{let r=e;if(t.focused){t.domObserver.stop();t.dom.classList.remove("ProseMirror-focused");t.domObserver.start();if(r.relatedTarget&&t.dom.contains(r.relatedTarget))t.domObserver.currentSelection.clear();t.focused=false}};to.beforeinput=(t,e)=>{let r=e;if(zn&&Kn&&r.inputType=="deleteContentBackward"){t.domObserver.flushSoon();let{domChangeCount:e}=t.input;setTimeout((()=>{if(t.input.domChangeCount!=e)return;t.dom.blur();t.focus();if(t.someProp("handleKeyDown",(e=>e(t,$n(8,"Backspace")))))return;let{$cursor:r}=t.state.selection;if(r&&r.pos>0)t.dispatch(t.state.tr.delete(r.pos-1,r.pos).scrollIntoView())}),50)}};for(let t in eo)to[t]=eo[t];function Bo(t,e){if(t==e)return true;for(let r in t)if(t[r]!==e[r])return false;for(let r in e)if(!(r in t))return false;return true}class Fo{constructor(t,e){this.toDOM=t;this.spec=e||Wo;this.side=this.spec.side||0}map(t,e,r,n){let{pos:i,deleted:s}=t.mapResult(e.from+n,this.side<0?-1:1);return s?null:new Jo(i-r,i-r,this)}valid(){return true}eq(t){return this==t||t instanceof Fo&&(this.spec.key&&this.spec.key==t.spec.key||this.toDOM==t.toDOM&&Bo(this.spec,t.spec))}destroy(t){if(this.spec.destroy)this.spec.destroy(t)}}class Uo{constructor(t,e){this.attrs=t;this.spec=e||Wo}map(t,e,r,n){let i=t.map(e.from+n,this.spec.inclusiveStart?-1:1)-r;let s=t.map(e.to+n,this.spec.inclusiveEnd?1:-1)-r;return i>=s?null:new Jo(i,s,this)}valid(t,e){return e.from<e.to}eq(t){return this==t||t instanceof Uo&&Bo(this.attrs,t.attrs)&&Bo(this.spec,t.spec)}static is(t){return t.type instanceof Uo}destroy(){}}class qo{constructor(t,e){this.attrs=t;this.spec=e||Wo}map(t,e,r,n){let i=t.mapResult(e.from+n,1);if(i.deleted)return null;let s=t.mapResult(e.to+n,-1);if(s.deleted||s.pos<=i.pos)return null;return new Jo(i.pos-r,s.pos-r,this)}valid(t,e){let{index:r,offset:n}=t.content.findIndex(e.from),i;return n==e.from&&!(i=t.child(r)).isText&&n+i.nodeSize==e.to}eq(t){return this==t||t instanceof qo&&Bo(this.attrs,t.attrs)&&Bo(this.spec,t.spec)}destroy(){}}class Jo{constructor(t,e,r){this.from=t;this.to=e;this.type=r}copy(t,e){return new Jo(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 Jo(t,t,new Fo(e,r))}static inline(t,e,r,n){return new Jo(t,e,new Uo(r,n))}static node(t,e,r,n){return new Jo(t,e,new qo(r,n))}get spec(){return this.type.spec}get inline(){return this.type instanceof Uo}get widget(){return this.type instanceof Fo}}const Ko=[],Wo={};class Vo{constructor(t,e){this.local=t.length?t:Ko;this.children=e.length?e:Ko}static create(t,e){return e.length?rl(e,t,0,Wo):Go}find(t,e,r){let n=[];this.findInner(t==null?0:t,e==null?1e9:e,n,0,r);return n}findInner(t,e,r,n,i){for(let s=0;s<this.local.length;s++){let o=this.local[s];if(o.from<=e&&o.to>=t&&(!i||i(o.spec)))r.push(o.copy(o.from+n,o.to+n))}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,n+o,i)}}}map(t,e,r){if(this==Go||t.maps.length==0)return this;return this.mapInner(t,e,0,0,r||Wo)}mapInner(t,e,r,n,i){let s;for(let o=0;o<this.local.length;o++){let l=this.local[o].map(t,r,n);if(l&&l.type.valid(e,l))(s||(s=[])).push(l);else if(i.onRemove)i.onRemove(this.local[o].spec)}if(this.children.length)return Qo(this.children,s||[],t,e,r,n,i);else return s?new Vo(s.sort(nl),Ko):Go}add(t,e){if(!e.length)return this;if(this==Go)return Vo.create(t,e);return this.addInner(t,e,0)}addInner(t,e,r){let n,i=0;t.forEach(((t,s)=>{let o=s+r,l;if(!(l=tl(e,t,o)))return;if(!n)n=this.children.slice();while(i<n.length&&n[i]<s)i+=3;if(n[i]==s)n[i+2]=n[i+2].addInner(t,l,o+1);else n.splice(i,0,s,s+t.nodeSize,rl(l,t,o+1,Wo));i+=3}));let s=Xo(i?el(e):e,-r);for(let e=0;e<s.length;e++)if(!s[e].type.valid(t,s[e]))s.splice(e--,1);return new Vo(s.length?this.local.concat(s).sort(nl):this.local,n||this.children)}remove(t){if(t.length==0||this==Go)return this;return this.removeInner(t,0)}removeInner(t,e){let r=this.children,n=this.local;for(let n=0;n<r.length;n+=3){let i;let s=r[n]+e,o=r[n+1]+e;for(let e=0,r;e<t.length;e++)if(r=t[e]){if(r.from>s&&r.to<o){t[e]=null;(i||(i=[])).push(r)}}if(!i)continue;if(r==this.children)r=this.children.slice();let l=r[n+2].removeInner(i,s+1);if(l!=Go){r[n+2]=l}else{r.splice(n,3);n-=3}}if(n.length)for(let r=0,i;r<t.length;r++)if(i=t[r]){for(let t=0;t<n.length;t++)if(n[t].eq(i,e)){if(n==this.local)n=this.local.slice();n.splice(t--,1)}}if(r==this.children&&n==this.local)return this;return n.length||r.length?new Vo(n,r):Go}forChild(t,e){if(this==Go)return this;if(e.isLeaf)return Vo.empty;let r,n;for(let e=0;e<this.children.length;e+=3)if(this.children[e]>=t){if(this.children[e]==t)r=this.children[e+2];break}let i=t+1,s=i+e.content.size;for(let t=0;t<this.local.length;t++){let e=this.local[t];if(e.from<s&&e.to>i&&e.type instanceof Uo){let t=Math.max(i,e.from)-i,r=Math.min(s,e.to)-i;if(t<r)(n||(n=[])).push(e.copy(t,r))}}if(n){let t=new Vo(n.sort(nl),Ko);return r?new Zo([t,r]):t}return r||Go}eq(t){if(this==t)return true;if(!(t instanceof Vo)||this.local.length!=t.local.length||this.children.length!=t.children.length)return false;for(let e=0;e<this.local.length;e++)if(!this.local[e].eq(t.local[e]))return false;for(let e=0;e<this.children.length;e+=3)if(this.children[e]!=t.children[e]||this.children[e+1]!=t.children[e+1]||!this.children[e+2].eq(t.children[e+2]))return false;return true}locals(t){return il(this.localsInner(t))}localsInner(t){if(this==Go)return Ko;if(t.inlineContent||!this.local.some(Uo.is))return this.local;let e=[];for(let t=0;t<this.local.length;t++){if(!(this.local[t].type instanceof Uo))e.push(this.local[t])}return e}forEachSet(t){t(this)}}Vo.empty=new Vo([],[]);Vo.removeOverlap=il;const Go=Vo.empty;class Zo{constructor(t){this.members=t}map(t,e){const r=this.members.map((r=>r.map(t,e,Wo)));return Zo.from(r)}forChild(t,e){if(e.isLeaf)return Vo.empty;let r=[];for(let n=0;n<this.members.length;n++){let i=this.members[n].forChild(t,e);if(i==Go)continue;if(i instanceof Zo)r=r.concat(i.members);else r.push(i)}return Zo.from(r)}eq(t){if(!(t instanceof Zo)||t.members.length!=this.members.length)return false;for(let e=0;e<this.members.length;e++)if(!this.members[e].eq(t.members[e]))return false;return true}locals(t){let e,r=true;for(let n=0;n<this.members.length;n++){let i=this.members[n].localsInner(t);if(!i.length)continue;if(!e){e=i}else{if(r){e=e.slice();r=false}for(let t=0;t<i.length;t++)e.push(i[t])}}return e?il(r?e:e.sort(nl)):Ko}static from(t){switch(t.length){case 0:return Go;case 1:return t[0];default:return new Zo(t.every((t=>t instanceof Vo))?t:t.reduce(((t,e)=>t.concat(e instanceof Vo?e:e.members)),[]))}}forEachSet(t){for(let e=0;e<this.members.length;e++)this.members[e].forEachSet(t)}}function Qo(t,e,r,n,i,s,o){let l=t.slice();for(let t=0,e=s;t<r.maps.length;t++){let n=0;r.maps[t].forEach(((t,r,i,s)=>{let o=s-i-(r-t);for(let i=0;i<l.length;i+=3){let s=l[i+1];if(s<0||t>s+e-n)continue;let u=l[i]+e-n;if(r>=u){l[i+1]=t<=u?-2:-1}else if(t>=e&&o){l[i]+=o;l[i+1]+=o}}n+=o}));e=r.maps[t].map(e,-1)}let u=false;for(let e=0;e<l.length;e+=3)if(l[e+1]<0){if(l[e+1]==-2){u=true;l[e+1]=-1;continue}let a=r.map(t[e]+s),f=a-i;if(f<0||f>=n.content.size){u=true;continue}let h=r.map(t[e+1]+s,-1),c=h-i;let{index:d,offset:p}=n.content.findIndex(f);let m=n.maybeChild(d);if(m&&p==f&&p+m.nodeSize==c){let n=l[e+2].mapInner(r,m,a+1,t[e]+s+1,o);if(n!=Go){l[e]=f;l[e+1]=c;l[e+2]=n}else{l[e+1]=-2;u=true}}else{u=true}}if(u){let u=Yo(l,t,e,r,i,s,o);let a=rl(u,n,0,o);e=a.local;for(let t=0;t<l.length;t+=3)if(l[t+1]<0){l.splice(t,3);t-=3}for(let t=0,e=0;t<a.children.length;t+=3){let r=a.children[t];while(e<l.length&&l[e]<r)e+=3;l.splice(e,0,a.children[t],a.children[t+1],a.children[t+2])}}return new Vo(e.sort(nl),l)}function Xo(t,e){if(!e||!t.length)return t;let r=[];for(let n=0;n<t.length;n++){let i=t[n];r.push(new Jo(i.from+e,i.to+e,i.type))}return r}function Yo(t,e,r,n,i,s,o){function l(t,e){for(let s=0;s<t.local.length;s++){let l=t.local[s].map(n,i,e);if(l)r.push(l);else if(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)if(t[r+1]==-1)l(t[r+2],e[r]+s+1);return r}function tl(t,e,r){if(e.isLeaf)return null;let n=r+e.nodeSize,i=null;for(let e=0,s;e<t.length;e++){if((s=t[e])&&s.from>r&&s.to<n){(i||(i=[])).push(s);t[e]=null}}return i}function el(t){let e=[];for(let r=0;r<t.length;r++)if(t[r]!=null)e.push(t[r]);return e}function rl(t,e,r,n){let i=[],s=false;e.forEach(((e,o)=>{let l=tl(t,e,o+r);if(l){s=true;let t=rl(l,e,r+o+1,n);if(t!=Go)i.push(o,o+e.nodeSize,t)}}));let o=Xo(s?el(t):t,-r).sort(nl);for(let t=0;t<o.length;t++)if(!o[t].type.valid(e,o[t])){if(n.onRemove)n.onRemove(o[t].spec);o.splice(t--,1)}return o.length||i.length?new Vo(o,i):Go}function nl(t,e){return t.from-e.from||t.to-e.to}function il(t){let e=t;for(let r=0;r<e.length-1;r++){let n=e[r];if(n.from!=n.to)for(let i=r+1;i<e.length;i++){let s=e[i];if(s.from==n.from){if(s.to!=n.to){if(e==t)e=t.slice();e[i]=s.copy(s.from,n.to);sl(e,i+1,s.copy(n.to,s.to))}continue}else{if(s.from<n.to){if(e==t)e=t.slice();e[r]=n.copy(n.from,s.from);sl(e,i,n.copy(s.from,n.to))}break}}}return e}function sl(t,e,r){while(e<t.length&&nl(r,t[e])>0)e++;t.splice(e,0,r)}function ol(t){let e=[];t.someProp("decorations",(r=>{let n=r(t.state);if(n&&n!=Go)e.push(n)}));if(t.cursorWrapper)e.push(Vo.create(t.state.doc,[t.cursorWrapper.deco]));return Zo.from(e)}const ll={childList:true,characterData:true,characterDataOldValue:true,attributes:true,attributeOldValue:true,subtree:true};const ul=Dn&&Hn<=11;class al{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 fl{constructor(t,e){this.view=t;this.handleDOMChange=e;this.queue=[];this.flushingSoon=-1;this.observer=null;this.currentSelection=new al;this.onCharData=null;this.suppressingSelectionUpdates=false;this.lastChangedTextNode=null;this.observer=window.MutationObserver&&new window.MutationObserver((t=>{for(let e=0;e<t.length;e++)this.queue.push(t[e]);if(Dn&&Hn<=11&&t.some((t=>t.type=="childList"&&t.removedNodes.length||t.type=="characterData"&&t.oldValue.length>t.target.nodeValue.length)))this.flushSoon();else this.flush()}));if(ul){this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue});this.flushSoon()}}this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){if(this.flushingSoon<0)this.flushingSoon=window.setTimeout((()=>{this.flushingSoon=-1;this.flush()}),20)}forceFlush(){if(this.flushingSoon>-1){window.clearTimeout(this.flushingSoon);this.flushingSoon=-1;this.flush()}}start(){if(this.observer){this.observer.takeRecords();this.observer.observe(this.view.dom,ll)}if(this.onCharData)this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData);this.connectSelection()}stop(){if(this.observer){let t=this.observer.takeRecords();if(t.length){for(let e=0;e<t.length;e++)this.queue.push(t[e]);window.setTimeout((()=>this.flush()),20)}this.observer.disconnect()}if(this.onCharData)this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData);this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=true;setTimeout((()=>this.suppressingSelectionUpdates=false),50)}onSelectionChange(){if(!ms(this.view))return;if(this.suppressingSelectionUpdates)return is(this.view);if(Dn&&Hn<=11&&!this.view.state.selection.empty){let t=this.view.domSelectionRange();if(t.focusNode&&bn(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset))return this.flushSoon()}this.flush()}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(t){if(!t.focusNode)return true;let e=new Set,r;for(let r=t.focusNode;r;r=pn(r))e.add(r);for(let n=t.anchorNode;n;n=pn(n))if(e.has(n)){r=n;break}let n=r&&this.view.docView.nearestDesc(r);if(n&&n.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r})){this.setCurSelection();return true}}pendingRecords(){if(this.observer)for(let t of this.observer.takeRecords())this.queue.push(t);return this.queue}flush(){let{view:t}=this;if(!t.docView||this.flushingSoon>-1)return;let e=this.pendingRecords();if(e.length)this.queue=[];let r=t.domSelectionRange();let n=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&ms(t)&&!this.ignoreSelectionChange(r);let i=-1,s=-1,o=false,l=[];if(t.editable){for(let t=0;t<e.length;t++){let r=this.registerMutation(e[t],l);if(r){i=i<0?r.from:Math.min(r.from,i);s=s<0?r.to:Math.max(r.to,s);if(r.typeOver)o=true}}}if(jn&&l.length){let e=l.filter((t=>t.nodeName=="BR"));if(e.length==2){let[t,r]=e;if(t.parentNode&&t.parentNode.parentNode==r.parentNode)r.remove();else t.remove()}else{let{focusNode:r}=this.currentSelection;for(let n of e){let e=n.parentNode;if(e&&e.nodeName=="LI"&&(!r||gl(t,r)!=e))n.remove()}}}let u=null;if(i<0&&n&&t.input.lastFocus>Date.now()-200&&Math.max(t.input.lastTouch,t.input.lastClick.time)<Date.now()-300&&En(r)&&(u=rs(t))&&u.eq(Ze.near(t.state.doc.resolve(0),1))){t.input.lastFocus=0;is(t);this.currentSelection.set(r);t.scrollToSelection()}else if(i>-1||n){if(i>-1){t.docView.markDirty(i,s);dl(t)}this.handleDOMChange(i,s,o,l);if(t.docView&&t.docView.dirty)t.updateState(t.state);else if(!this.currentSelection.eq(r))is(t);this.currentSelection.set(r)}}registerMutation(t,e){if(e.indexOf(t.target)>-1)return null;let r=this.view.docView.nearestDesc(t.target);if(t.type=="attributes"&&(r==this.view.docView||t.attributeName=="contenteditable"||t.attributeName=="style"&&!t.oldValue&&!t.target.getAttribute("style")))return null;if(!r||r.ignoreMutation(t))return null;if(t.type=="childList"){for(let r=0;r<t.addedNodes.length;r++){let n=t.addedNodes[r];e.push(n);if(n.nodeType==3)this.lastChangedTextNode=n}if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(t.target))return{from:r.posBefore,to:r.posAfter};let n=t.previousSibling,i=t.nextSibling;if(Dn&&Hn<=11&&t.addedNodes.length){for(let e=0;e<t.addedNodes.length;e++){let{previousSibling:r,nextSibling:s}=t.addedNodes[e];if(!r||Array.prototype.indexOf.call(t.addedNodes,r)<0)n=r;if(!s||Array.prototype.indexOf.call(t.addedNodes,s)<0)i=s}}let s=n&&n.parentNode==t.target?dn(n)+1:0;let o=r.localPosFromDOM(t.target,s,-1);let l=i&&i.parentNode==t.target?dn(i):t.target.childNodes.length;let u=r.localPosFromDOM(t.target,l,1);return{from:o,to:u}}else if(t.type=="attributes"){return{from:r.posAtStart-r.border,to:r.posAtEnd+r.border}}else{this.lastChangedTextNode=t.target;return{from:r.posAtStart,to:r.posAtEnd,typeOver:t.target.nodeValue==t.oldValue}}}}let hl=new WeakMap;let cl=false;function dl(t){if(hl.has(t))return;hl.set(t,null);if(["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace)!==-1){t.requiresGeckoHackNode=jn;if(cl)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.");cl=true}}function pl(t,e){let r=e.startContainer,n=e.startOffset;let i=e.endContainer,s=e.endOffset;let o=t.domAtPos(t.state.selection.anchor);if(bn(o.node,o.offset,i,s))[r,n,i,s]=[i,s,r,n];return{anchorNode:r,anchorOffset:n,focusNode:i,focusOffset:s}}function ml(t,e){if(e.getComposedRanges){let r=e.getComposedRanges(t.root)[0];if(r)return pl(t,r)}let r;function n(t){t.preventDefault();t.stopImmediatePropagation();r=t.getTargetRanges()[0]}t.dom.addEventListener("beforeinput",n,true);document.execCommand("indent");t.dom.removeEventListener("beforeinput",n,true);return r?pl(t,r):null}function gl(t,e){for(let r=e.parentNode;r&&r!=t.dom;r=r.parentNode){let e=t.docView.nearestDesc(r,true);if(e&&e.node.isBlock)return r}return null}function wl(t,e,r){let{node:n,fromOffset:i,toOffset:s,from:o,to:l}=t.docView.parseRange(e,r);let u=t.domSelectionRange();let a;let f=u.anchorNode;if(f&&t.dom.contains(f.nodeType==1?f:f.parentNode)){a=[{node:f,offset:u.anchorOffset}];if(!En(u))a.push({node:u.focusNode,offset:u.focusOffset})}if(zn&&t.input.lastKeyCode===8){for(let t=s;t>i;t--){let e=n.childNodes[t-1],r=e.pmViewDesc;if(e.nodeName=="BR"&&!r){s=t;break}if(!r||r.size)break}}let h=t.state.doc;let c=t.someProp("domParser")||mt.fromSchema(t.state.schema);let d=h.resolve(o);let p=null,m=c.parse(n,{topNode:d.parent,topMatch:d.parent.contentMatchAt(d.index()),topOpen:true,from:i,to:s,preserveWhitespace:d.parent.type.whitespace=="pre"?"full":true,findPositions:a,ruleFromNode:bl,context:d});if(a&&a[0].pos!=null){let t=a[0].pos,e=a[1]&&a[1].pos;if(e==null)e=t;p={anchor:t+o,head:e+o}}return{doc:m,sel:p,from:o,to:l}}function bl(t){let e=t.pmViewDesc;if(e){return e.parseRule()}else if(t.nodeName=="BR"&&t.parentNode){if(Fn&&/^(ul|ol)$/i.test(t.parentNode.nodeName)){let t=document.createElement("div");t.appendChild(document.createElement("li"));return{skip:t}}else if(t.parentNode.lastChild==t||Fn&&/^(tr|table)$/i.test(t.parentNode.nodeName)){return{ignore:true}}}else if(t.nodeName=="IMG"&&t.getAttribute("mark-placeholder")){return{ignore:true}}return null}const kl=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function vl(t,e,r,n,i){let s=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);t.input.compositionPendingChanges=0;if(e<0){let e=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null;let r=rs(t,e);if(r&&!t.state.selection.eq(r)){if(zn&&Kn&&t.input.lastKeyCode===13&&Date.now()-100<t.input.lastKeyCodeTime&&t.someProp("handleKeyDown",(e=>e(t,$n(13,"Enter")))))return;let n=t.state.tr.setSelection(r);if(e=="pointer")n.setMeta("pointer",true);else if(e=="key")n.scrollIntoView();if(s)n.setMeta("composition",s);t.dispatch(n)}return}let o=t.state.doc.resolve(e);let l=o.sharedDepth(r);e=o.before(l+1);r=t.state.doc.resolve(r).after(l+1);let u=t.state.selection;let a=wl(t,e,r);let f=t.state.doc,h=f.slice(a.from,a.to);let c,d;if(t.input.lastKeyCode===8&&Date.now()-100<t.input.lastKeyCodeTime){c=t.state.selection.to;d="end"}else{c=t.state.selection.from;d="start"}t.input.lastKeyCode=null;let p=Tl(h.content,a.doc.content,a.from,c,d);if(p)t.input.domChangeCount++;if((Un&&t.input.lastIOSEnter>Date.now()-225||Kn)&&i.some((t=>t.nodeType==1&&!kl.test(t.nodeName)))&&(!p||p.endA>=p.endB)&&t.someProp("handleKeyDown",(e=>e(t,$n(13,"Enter"))))){t.input.lastIOSEnter=0;return}if(!p){if(n&&u instanceof tr&&!u.empty&&u.$head.sameParent(u.$anchor)&&!t.composing&&!(a.sel&&a.sel.anchor!=a.sel.head)){p={start:u.from,endA:u.to,endB:u.to}}else{if(a.sel){let e=yl(t,t.state.doc,a.sel);if(e&&!e.eq(t.state.selection)){let r=t.state.tr.setSelection(e);if(s)r.setMeta("composition",s);t.dispatch(r)}}return}}if(t.state.selection.from<t.state.selection.to&&p.start==p.endB&&t.state.selection instanceof tr){if(p.start>t.state.selection.from&&p.start<=t.state.selection.from+2&&t.state.selection.from>=a.from){p.start=t.state.selection.from}else if(p.endA<t.state.selection.to&&p.endA>=t.state.selection.to-2&&t.state.selection.to<=a.to){p.endB+=t.state.selection.to-p.endA;p.endA=t.state.selection.to}}if(Dn&&Hn<=11&&p.endB==p.start+1&&p.endA==p.start&&p.start>a.from&&a.doc.textBetween(p.start-a.from-1,p.start-a.from+1)=="  "){p.start--;p.endA--;p.endB--}let m=a.doc.resolveNoCache(p.start-a.from);let g=a.doc.resolveNoCache(p.endB-a.from);let w=f.resolve(p.start);let b=m.sameParent(g)&&m.parent.inlineContent&&w.end()>=p.endA;if((Un&&t.input.lastIOSEnter>Date.now()-225&&(!b||i.some((t=>t.nodeName=="DIV"||t.nodeName=="P")))||!b&&m.pos<a.doc.content.size&&(!m.sameParent(g)||!m.parent.inlineContent)&&m.pos<g.pos&&!/\S/.test(a.doc.textBetween(m.pos,g.pos,"","")))&&t.someProp("handleKeyDown",(e=>e(t,$n(13,"Enter"))))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>p.start&&xl(f,p.start,p.endA,m,g)&&t.someProp("handleKeyDown",(e=>e(t,$n(8,"Backspace"))))){if(Kn&&zn)t.domObserver.suppressSelectionUpdates();return}if(zn&&p.endB==p.start)t.input.lastChromeDelete=Date.now();if(Kn&&!b&&m.start()!=g.start()&&g.parentOffset==0&&m.depth==g.depth&&a.sel&&a.sel.anchor==a.sel.head&&a.sel.head==p.endA){p.endB-=2;g=a.doc.resolveNoCache(p.endB-a.from);setTimeout((()=>{t.someProp("handleKeyDown",(function(e){return e(t,$n(13,"Enter"))}))}),20)}let k=p.start,v=p.endA;let y=e=>{let r=e||t.state.tr.replace(k,v,a.doc.slice(p.start-a.from,p.endB-a.from));if(a.sel){let e=yl(t,r.doc,a.sel);if(e&&!(zn&&t.composing&&e.empty&&(p.start!=p.endB||t.input.lastChromeDelete<Date.now()-100)&&(e.head==k||e.head==r.mapping.map(v)-1)||Dn&&e.empty&&e.head==k))r.setSelection(e)}if(s)r.setMeta("composition",s);return r.scrollIntoView()};let M;if(b){if(m.pos==g.pos){if(Dn&&Hn<=11&&m.parentOffset==0){t.domObserver.suppressSelectionUpdates();setTimeout((()=>is(t)),20)}let e=y(t.state.tr.delete(k,v));let r=f.resolve(p.start).marksAcross(f.resolve(p.endA));if(r)e.ensureMarks(r);t.dispatch(e)}else if(p.endA==p.endB&&(M=Ml(m.parent.content.cut(m.parentOffset,g.parentOffset),w.parent.content.cut(w.parentOffset,p.endA-w.start())))){let e=y(t.state.tr);if(M.type=="add")e.addMark(k,v,M.mark);else e.removeMark(k,v,M.mark);t.dispatch(e)}else if(m.parent.child(m.index()).isText&&m.index()==g.index()-(g.textOffset?0:1)){let e=m.parent.textBetween(m.parentOffset,g.parentOffset);let r=()=>y(t.state.tr.insertText(e,k,v));if(!t.someProp("handleTextInput",(n=>n(t,k,v,e,r))))t.dispatch(r())}}else{t.dispatch(y())}}function yl(t,e,r){if(Math.max(r.anchor,r.head)>e.content.size)return null;return ps(t,e.resolve(r.anchor),e.resolve(r.head))}function Ml(t,e){let r=t.firstChild.marks,n=e.firstChild.marks;let i=r,s=n,o,l,u;for(let t=0;t<n.length;t++)i=n[t].removeFromSet(i);for(let t=0;t<r.length;t++)s=r[t].removeFromSet(s);if(i.length==1&&s.length==0){l=i[0];o="add";u=t=>t.mark(l.addToSet(t.marks))}else if(i.length==0&&s.length==1){l=s[0];o="remove";u=t=>t.mark(l.removeFromSet(t.marks))}else{return null}let a=[];for(let t=0;t<e.childCount;t++)a.push(u(e.child(t)));if(m.from(a).eq(t))return{mark:l,type:o}}function xl(t,e,r,n,i){if(r-e<=i.pos-n.pos||Sl(n,true,false)<i.pos)return false;let s=t.resolve(e);if(!n.parent.isTextblock){let t=s.nodeAfter;return t!=null&&r==e+t.nodeSize}if(s.parentOffset<s.parent.content.size||!s.parent.isTextblock)return false;let o=t.resolve(Sl(s,true,true));if(!o.parent.isTextblock||o.pos>r||Sl(o,true,false)<r)return false;return n.parent.content.cut(n.parentOffset).eq(o.parent.content)}function Sl(t,e,r){let n=t.depth,i=e?t.end():t.pos;while(n>0&&(e||t.indexAfter(n)==t.node(n).childCount)){n--;i++;e=false}if(r){let e=t.node(n).maybeChild(t.indexAfter(n));while(e&&!e.isLeaf){e=e.firstChild;i++}}return i}function Tl(t,e,r,n,i){let s=t.findDiffStart(e,r);if(s==null)return null;let{a:o,b:l}=t.findDiffEnd(e,r+t.size,r+e.size);if(i=="end"){let t=Math.max(0,s-Math.min(o,l));n-=o+t-s}if(o<s&&t.size<e.size){let t=n<=s&&n>=o?s-n:0;s-=t;if(s&&s<e.size&&El(e.textBetween(s-1,s+1)))s+=t?1:-1;l=s+(l-o);o=s}else if(l<s){let e=n<=s&&n>=l?s-n:0;s-=e;if(s&&s<t.size&&El(t.textBetween(s-1,s+1)))s+=e?1:-1;o=s+(o-l);l=s}return{start:s,endA:o,endB:l}}function El(t){if(t.length!=2)return false;let e=t.charCodeAt(0),r=t.charCodeAt(1);return e>=56320&&e<=57343&&r>=55296&&r<=56319}class $l{constructor(t,e){this._root=null;this.focused=false;this.trackWrites=null;this.mounted=false;this.markCursor=null;this.cursorWrapper=null;this.lastSelectedViewDesc=undefined;this.input=new no;this.prevDirectPlugins=[];this.pluginViews=[];this.requiresGeckoHackNode=false;this.dragging=null;this._props=e;this.state=e.state;this.directPlugins=e.plugins||[];this.directPlugins.forEach(Pl);this.dispatch=this.dispatch.bind(this);this.dom=t&&t.mount||document.createElement("div");if(t){if(t.appendChild)t.appendChild(this.dom);else if(typeof t=="function")t(this.dom);else if(t.mount)this.mounted=true}this.editable=Rl(this);Ol(this);this.nodeViews=Ll(this);this.docView=Di(this.state.doc,Al(this),ol(this),this.dom,this);this.domObserver=new fl(this,((t,e,r,n)=>vl(this,t,e,r,n)));this.domObserver.start();io(this);this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let t=this._props;this._props={};for(let e in t)this._props[e]=t[e];this._props.state=this.state}return this._props}update(t){if(t.handleDOMEvents!=this._props.handleDOMEvents)lo(this);let e=this._props;this._props=t;if(t.plugins){t.plugins.forEach(Pl);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 n=this.state,i=false,s=false;if(t.storedMarks&&this.composing){Ao(this);s=true}this.state=t;let o=n.plugins!=t.plugins||this._props.plugins!=e.plugins;if(o||this._props.plugins!=e.plugins||this._props.nodeViews!=e.nodeViews){let t=Ll(this);if(Nl(t,this.nodeViews)){this.nodeViews=t;i=true}}if(o||e.handleDOMEvents!=this._props.handleDOMEvents){lo(this)}this.editable=Rl(this);Ol(this);let l=ol(this),u=Al(this);let a=n.plugins!=t.plugins&&!n.doc.eq(t.doc)?"reset":t.scrollToSelection>n.scrollToSelection?"to selection":"preserve";let f=i||!this.docView.matchesNode(t.doc,u,l);if(f||!t.selection.eq(n.selection))s=true;let h=a=="preserve"&&s&&this.dom.style.overflowAnchor==null&&Yn(this);if(s){this.domObserver.stop();let e=f&&(Dn||zn)&&!this.composing&&!n.selection.empty&&!t.selection.empty&&Cl(n.selection,t.selection);if(f){let r=zn?this.trackWrites=this.domSelectionRange().focusNode:null;if(this.composing)this.input.compositionNode=Oo(this);if(i||!this.docView.update(t.doc,u,l,this)){this.docView.updateOuterDeco(u);this.docView.destroy();this.docView=Di(t.doc,u,l,this.dom,this)}if(r&&!this.trackWrites)e=true}if(e||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&ws(this))){is(this,e)}else{cs(this,t.selection);this.domObserver.setCurSelection()}this.domObserver.start()}this.updatePluginViews(n);if(((r=this.dragging)===null||r===void 0?void 0:r.node)&&!n.doc.eq(t.doc))this.updateDraggedNode(this.dragging,n);if(a=="reset"){this.dom.scrollTop=0}else if(a=="to selection"){this.scrollToSelection()}else if(h){ei(h)}}scrollToSelection(){let t=this.domSelectionRange().focusNode;if(!t||!this.dom.contains(t.nodeType==1?t:t.parentNode));else if(this.someProp("handleScrollToSelection",(t=>t(this))));else if(this.state.selection instanceof rr){let e=this.docView.domAfterPos(this.state.selection.from);if(e.nodeType==1)Xn(this,e.getBoundingClientRect(),t)}else{Xn(this,this.coordsAtPos(this.state.selection.head,1),t)}}destroyPluginViews(){let t;while(t=this.pluginViews.pop())if(t.destroy)t.destroy()}updatePluginViews(t){if(!t||t.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins;this.destroyPluginViews();for(let t=0;t<this.directPlugins.length;t++){let e=this.directPlugins[t];if(e.spec.view)this.pluginViews.push(e.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let e=this.state.plugins[t];if(e.spec.view)this.pluginViews.push(e.spec.view(this))}}else{for(let e=0;e<this.pluginViews.length;e++){let r=this.pluginViews[e];if(r.update)r.update(this,t)}}}updateDraggedNode(t,e){let r=t.node,n=-1;if(this.state.doc.nodeAt(r.from)==r.node){n=r.from}else{let t=r.from+(this.state.doc.content.size-e.doc.content.size);let i=t>0&&this.state.doc.nodeAt(t);if(i==r.node)n=t}this.dragging=new jo(t.slice,t.move,n<0?undefined:rr.create(this.state.doc,n))}someProp(t,e){let r=this._props&&this._props[t],n;if(r!=null&&(n=e?e(r):r))return n;for(let r=0;r<this.directPlugins.length;r++){let i=this.directPlugins[r].props[t];if(i!=null&&(n=e?e(i):i))return n}let i=this.state.plugins;if(i)for(let r=0;r<i.length;r++){let s=i[r].props[t];if(s!=null&&(n=e?e(s):s))return n}}hasFocus(){if(Dn){let t=this.root.activeElement;if(t==this.dom)return true;if(!t||!this.dom.contains(t))return false;while(t&&this.dom!=t&&this.dom.contains(t)){if(t.contentEditable=="false")return false;t=t.parentElement}return true}return this.root.activeElement==this.dom}focus(){this.domObserver.stop();if(this.editable)ii(this.dom);is(this);this.domObserver.start()}get root(){let t=this._root;if(t==null)for(let t=this.dom.parentNode;t;t=t.parentNode){if(t.nodeType==9||t.nodeType==11&&t.host){if(!t.getSelection)Object.getPrototypeOf(t).getSelection=()=>t.ownerDocument.getSelection();return this._root=t}}return t||document}updateRoot(){this._root=null}posAtCoords(t){return ci(this,t)}coordsAtPos(t,e=1){return gi(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 n=this.docView.posFromDOM(t,e,r);if(n==null)throw new RangeError("DOM position not inside the editor");return n}endOfTextblock(t,e){return Ei(this,e||this.state,t)}pasteHTML(t,e){return Do(this,"",t,false,e||new ClipboardEvent("paste"))}pasteText(t,e){return Do(this,t,null,true,e||new ClipboardEvent("paste"))}serializeForClipboard(t){return Hs(this,t)}destroy(){if(!this.docView)return;oo(this);this.destroyPluginViews();if(this.mounted){this.docView.update(this.state.doc,[],ol(this),this);this.dom.textContent=""}else if(this.dom.parentNode){this.dom.parentNode.removeChild(this.dom)}this.docView.destroy();this.docView=null;wn()}get isDestroyed(){return this.docView==null}dispatchEvent(t){return fo(this,t)}domSelectionRange(){let t=this.domSelection();if(!t)return{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0};return Fn&&this.root.nodeType===11&&An(this.dom.ownerDocument)==this.dom&&ml(this,t)||t}domSelection(){return this.root.getSelection()}}$l.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;if(e)e.call(this,t);else this.updateState(this.state.apply(t))};function Al(t){let e=Object.create(null);e.class="ProseMirror";e.contenteditable=String(t.editable);t.someProp("attributes",(r=>{if(typeof r=="function")r=r(t.state);if(r)for(let t in r){if(t=="class")e.class+=" "+r[t];else if(t=="style")e.style=(e.style?e.style+";":"")+r[t];else if(!e[t]&&t!="contenteditable"&&t!="nodeName")e[t]=String(r[t])}}));if(!e.translate)e.translate="no";return[Jo.node(0,t.state.doc.content.size,e)]}function Ol(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:Jo.widget(t.state.selection.from,e,{raw:true,marks:t.markCursor})}}else{t.cursorWrapper=null}}function Rl(t){return!t.someProp("editable",(e=>e(t.state)===false))}function Cl(t,e){let r=Math.min(t.$anchor.sharedDepth(t.head),e.$anchor.sharedDepth(e.head));return t.$anchor.start(r)!=e.$anchor.start(r)}function Ll(t){let e=Object.create(null);function r(t){for(let r in t)if(!Object.prototype.hasOwnProperty.call(e,r))e[r]=t[r]}t.someProp("nodeViews",r);t.someProp("markViews",r);return e}function Nl(t,e){let r=0,n=0;for(let n in t){if(t[n]!=e[n])return true;r++}for(let t in e)n++;return r!=n}function Pl(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")}var Il={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"};var Dl={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'};var Hl=typeof navigator!="undefined"&&/Mac/.test(navigator.platform);var jl=typeof navigator!="undefined"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var _l=0;_l<10;_l++)Il[48+_l]=Il[96+_l]=String(_l);for(var _l=1;_l<=24;_l++)Il[_l+111]="F"+_l;for(var _l=65;_l<=90;_l++){Il[_l]=String.fromCharCode(_l+32);Dl[_l]=String.fromCharCode(_l)}for(var zl in Il)if(!Dl.hasOwnProperty(zl))Dl[zl]=Il[zl];function Bl(t){var e=Hl&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||jl&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified";var r=!e&&t.key||(t.shiftKey?Dl:Il)[t.keyCode]||t.key||"Unidentified";if(r=="Esc")r="Escape";if(r=="Del")r="Delete";if(r=="Left")r="ArrowLeft";if(r=="Up")r="ArrowUp";if(r=="Right")r="ArrowRight";if(r=="Down")r="ArrowDown";return r}const Fl=typeof navigator!="undefined"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform);const Ul=typeof navigator!="undefined"&&/Win/.test(navigator.platform);function ql(t){let e=t.split(/-(?!$)/),r=e[e.length-1];if(r=="Space")r=" ";let n,i,s,o;for(let t=0;t<e.length-1;t++){let r=e[t];if(/^(cmd|meta|m)$/i.test(r))o=true;else if(/^a(lt)?$/i.test(r))n=true;else if(/^(c|ctrl|control)$/i.test(r))i=true;else if(/^s(hift)?$/i.test(r))s=true;else if(/^mod$/i.test(r)){if(Fl)o=true;else i=true}else throw new Error("Unrecognized modifier name: "+r)}if(n)r="Alt-"+r;if(i)r="Ctrl-"+r;if(o)r="Meta-"+r;if(s)r="Shift-"+r;return r}function Jl(t){let e=Object.create(null);for(let r in t)e[ql(r)]=t[r];return e}function Kl(t,e,r=true){if(e.altKey)t="Alt-"+t;if(e.ctrlKey)t="Ctrl-"+t;if(e.metaKey)t="Meta-"+t;if(r&&e.shiftKey)t="Shift-"+t;return t}function Wl(t){return new br({props:{handleKeyDown:Vl(t)}})}function Vl(t){let e=Jl(t);return function(t,r){let n=Bl(r),i,s=e[Kl(n,r)];if(s&&s(t.state,t.dispatch,t))return true;if(n.length==1&&n!=" "){if(r.shiftKey){let i=e[Kl(n,r,false)];if(i&&i(t.state,t.dispatch,t))return true}if((r.altKey||r.metaKey||r.ctrlKey)&&!(Ul&&r.ctrlKey&&r.altKey)&&(i=Il[r.keyCode])&&i!=n){let n=e[Kl(i,r)];if(n&&n(t.state,t.dispatch,t))return true}}return false}}var Gl=Object.defineProperty;var Zl=(t,e)=>{for(var r in e)Gl(t,r,{get:e[r],enumerable:true})};function Ql(t){const{state:e,transaction:r}=t;let{selection:n}=r;let{doc:i}=r;let{storedMarks:s}=r;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return s},get selection(){return n},get doc(){return i},get tr(){n=r.selection;i=r.doc;s=r.storedMarks;return r}}}var Xl=class{constructor(t){this.editor=t.editor;this.rawCommands=this.editor.extensionManager.commands;this.customState=t.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:t,editor:e,state:r}=this;const{view:n}=e;const{tr:i}=r;const s=this.buildProps(i);return Object.fromEntries(Object.entries(t).map((([t,e])=>{const r=(...t)=>{const r=e(...t)(s);if(!i.getMeta("preventDispatch")&&!this.hasCustomState){n.dispatch(i)}return r};return[t,r]})))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(t,e=true){const{rawCommands:r,editor:n,state:i}=this;const{view:s}=n;const o=[];const l=!!t;const u=t||i.tr;const a=()=>{if(!l&&e&&!u.getMeta("preventDispatch")&&!this.hasCustomState){s.dispatch(u)}return o.every((t=>t===true))};const f={...Object.fromEntries(Object.entries(r).map((([t,r])=>{const n=(...t)=>{const n=this.buildProps(u,e);const i=r(...t)(n);o.push(i);return f};return[t,n]}))),run:a};return f}createCan(t){const{rawCommands:e,state:r}=this;const n=false;const i=t||r.tr;const s=this.buildProps(i,n);const o=Object.fromEntries(Object.entries(e).map((([t,e])=>[t,(...t)=>e(...t)({...s,dispatch:void 0})])));return{...o,chain:()=>this.createChain(i,n)}}buildProps(t,e=true){const{rawCommands:r,editor:n,state:i}=this;const{view:s}=n;const o={tr:t,editor:n,view:s,state:Ql({state:i,transaction:t}),dispatch:e?()=>void 0:void 0,chain:()=>this.createChain(t,e),can:()=>this.createCan(t),get commands(){return Object.fromEntries(Object.entries(r).map((([t,e])=>[t,(...t)=>e(...t)(o)])))}};return o}};var Yl={};Zl(Yl,{blur:()=>tu,clearContent:()=>eu,clearNodes:()=>ru,command:()=>nu,createParagraphNear:()=>iu,cut:()=>su,deleteCurrentNode:()=>ou,deleteNode:()=>uu,deleteRange:()=>au,deleteSelection:()=>fu,enter:()=>hu,exitCode:()=>cu,extendMarkRange:()=>ku,first:()=>vu,focus:()=>Eu,forEach:()=>$u,insertContent:()=>Au,insertContentAt:()=>Pu,joinBackward:()=>Hu,joinDown:()=>Du,joinForward:()=>ju,joinItemBackward:()=>_u,joinItemForward:()=>zu,joinTextblockBackward:()=>Bu,joinTextblockForward:()=>Fu,joinUp:()=>Iu,keyboardShortcut:()=>Ju,lift:()=>Wu,liftEmptyBlock:()=>Vu,liftListItem:()=>Gu,newlineInCode:()=>Zu,resetAttributes:()=>Yu,scrollIntoView:()=>ta,selectAll:()=>ea,selectNodeBackward:()=>ra,selectNodeForward:()=>na,selectParentNode:()=>ia,selectTextblockEnd:()=>sa,selectTextblockStart:()=>oa,setContent:()=>ua,setMark:()=>rf,setMeta:()=>nf,setNode:()=>sf,setNodeSelection:()=>of,setTextSelection:()=>lf,sinkListItem:()=>uf,splitBlock:()=>ff,splitListItem:()=>hf,toggleList:()=>pf,toggleMark:()=>mf,toggleNode:()=>gf,toggleWrap:()=>wf,undoInputRule:()=>bf,unsetAllMarks:()=>kf,unsetMark:()=>vf,updateAttributes:()=>yf,wrapIn:()=>Mf,wrapInList:()=>xf});var tu=()=>({editor:t,view:e})=>{requestAnimationFrame((()=>{var r;if(!t.isDestroyed){e.dom.blur();(r=window==null?void 0:window.getSelection())==null?void 0:r.removeAllRanges()}}));return true};var eu=(t=true)=>({commands:e})=>e.setContent("",{emitUpdate:t});var ru=()=>({state:t,tr:e,dispatch:r})=>{const{selection:n}=e;const{ranges:i}=n;if(!r){return true}i.forEach((({$from:r,$to:n})=>{t.doc.nodesBetween(r.pos,n.pos,((t,r)=>{if(t.type.isText){return}const{doc:n,mapping:i}=e;const s=n.resolve(i.map(r));const o=n.resolve(i.map(r+t.nodeSize));const l=s.blockRange(o);if(!l){return}const u=ae(l);if(t.type.isTextblock){const{defaultType:t}=s.parent.contentMatchAt(s.index());e.setNodeMarkup(l.start,t)}if(u||u===0){e.lift(l,u)}}))}));return true};var nu=t=>e=>t(e);var iu=()=>({state:t,dispatch:e})=>Br(t,e);var su=(t,e)=>({editor:r,tr:n})=>{const{state:i}=r;const s=i.doc.slice(t.from,t.to);n.deleteRange(t.from,t.to);const o=n.mapping.map(e);n.insert(o,s.content);n.setSelection(new tr(n.doc.resolve(Math.max(o-1,0))));return true};var ou=()=>({tr:t,dispatch:e})=>{const{selection:r}=t;const n=r.$anchor.node();if(n.content.size>0){return false}const i=t.selection.$anchor;for(let r=i.depth;r>0;r-=1){const s=i.node(r);if(s.type===n.type){if(e){const e=i.before(r);const n=i.after(r);t.delete(e,n).scrollIntoView()}return true}}return false};function lu(t,e){if(typeof t==="string"){if(!e.nodes[t]){throw Error(`There is no node type named '${t}'. Maybe you forgot to add the extension?`)}return e.nodes[t]}return t}var uu=t=>({tr:e,state:r,dispatch:n})=>{const i=lu(t,r.schema);const s=e.selection.$anchor;for(let t=s.depth;t>0;t-=1){const r=s.node(t);if(r.type===i){if(n){const r=s.before(t);const n=s.after(t);e.delete(r,n).scrollIntoView()}return true}}return false};var au=t=>({tr:e,dispatch:r})=>{const{from:n,to:i}=t;if(r){e.delete(n,i)}return true};var fu=()=>({state:t,dispatch:e})=>Mr(t,e);var hu=()=>({commands:t})=>t.keyboardShortcut("Enter");var cu=()=>({state:t,dispatch:e})=>zr(t,e);function du(t){return Object.prototype.toString.call(t)==="[object RegExp]"}function pu(t,e,r={strict:true}){const n=Object.keys(e);if(!n.length){return true}return n.every((n=>{if(r.strict){return e[n]===t[n]}if(du(e[n])){return e[n].test(t[n])}return e[n]===t[n]}))}function mu(t,e,r={}){return t.find((t=>t.type===e&&pu(Object.fromEntries(Object.keys(r).map((e=>[e,t.attrs[e]]))),r)))}function gu(t,e,r={}){return!!mu(t,e,r)}function wu(t,e,r){var n;if(!t||!e){return}let i=t.parent.childAfter(t.parentOffset);if(!i.node||!i.node.marks.some((t=>t.type===e))){i=t.parent.childBefore(t.parentOffset)}if(!i.node||!i.node.marks.some((t=>t.type===e))){return}r=r||((n=i.node.marks[0])==null?void 0:n.attrs);const s=mu([...i.node.marks],e,r);if(!s){return}let o=i.index;let l=t.start()+i.offset;let u=o+1;let a=l+i.node.nodeSize;while(o>0&&gu([...t.parent.child(o-1).marks],e,r)){o-=1;l-=t.parent.child(o).nodeSize}while(u<t.parent.childCount&&gu([...t.parent.child(u).marks],e,r)){a+=t.parent.child(u).nodeSize;u+=1}return{from:l,to:a}}function bu(t,e){if(typeof t==="string"){if(!e.marks[t]){throw Error(`There is no mark type named '${t}'. Maybe you forgot to add the extension?`)}return e.marks[t]}return t}var ku=(t,e={})=>({tr:r,state:n,dispatch:i})=>{const s=bu(t,n.schema);const{doc:o,selection:l}=r;const{$from:u,from:a,to:f}=l;if(i){const t=wu(u,s,e);if(t&&t.from<=a&&t.to>=f){const e=tr.create(o,t.from,t.to);r.setSelection(e)}}return true};var vu=t=>e=>{const r=typeof t==="function"?t(e):t;for(let t=0;t<r.length;t+=1){if(r[t](e)){return true}}return false};function yu(t){return t instanceof tr}function Mu(t=0,e=0,r=0){return Math.min(Math.max(t,e),r)}function xu(t,e=null){if(!e){return null}const r=Ze.atStart(t);const n=Ze.atEnd(t);if(e==="start"||e===true){return r}if(e==="end"){return n}const i=r.from;const s=n.to;if(e==="all"){return tr.create(t,Mu(0,i,s),Mu(t.content.size,i,s))}return tr.create(t,Mu(e,i,s),Mu(e,i,s))}function Su(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function Tu(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}var Eu=(t=null,e={})=>({editor:r,view:n,tr:i,dispatch:s})=>{e={scrollIntoView:true,...e};const o=()=>{if(Tu()||Su()){n.dom.focus()}requestAnimationFrame((()=>{if(!r.isDestroyed){n.focus();if(e==null?void 0:e.scrollIntoView){r.commands.scrollIntoView()}}}))};if(n.hasFocus()&&t===null||t===false){return true}if(s&&t===null&&!yu(r.state.selection)){o();return true}const l=xu(i.doc,t)||r.state.selection;const u=r.state.selection.eq(l);if(s){if(!u){i.setSelection(l)}if(u&&i.storedMarks){i.setStoredMarks(i.storedMarks)}o()}return true};var $u=(t,e)=>r=>t.every(((t,n)=>e(t,{...r,index:n})));var Au=(t,e)=>({tr:r,commands:n})=>n.insertContentAt({from:r.selection.from,to:r.selection.to},t,e);var Ou=t=>{const e=t.childNodes;for(let r=e.length-1;r>=0;r-=1){const n=e[r];if(n.nodeType===3&&n.nodeValue&&/^(\n\s\s|\n)$/.test(n.nodeValue)){t.removeChild(n)}else if(n.nodeType===1){Ou(n)}}return t};function Ru(t){if(typeof window==="undefined"){throw new Error("[tiptap error]: there is no window object available, so this function cannot be used")}const e=`<body>${t}</body>`;const r=(new window.DOMParser).parseFromString(e,"text/html").body;return Ou(r)}function Cu(t,e,r){if(t instanceof z||t instanceof m){return t}r={slice:true,parseOptions:{},...r};const n=typeof t==="object"&&t!==null;const i=typeof t==="string";if(n){try{const n=Array.isArray(t)&&t.length>0;if(n){return m.fromArray(t.map((t=>e.nodeFromJSON(t))))}const i=e.nodeFromJSON(t);if(r.errorOnInvalidContent){i.check()}return i}catch(n){if(r.errorOnInvalidContent){throw new Error("[tiptap error]: Invalid JSON content",{cause:n})}console.warn("[tiptap warn]: Invalid content.","Passed value:",t,"Error:",n);return Cu("",e,r)}}if(i){if(r.errorOnInvalidContent){let n=false;let i="";const s=new ht({topNode:e.spec.topNode,marks:e.spec.marks,nodes:e.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:t=>{n=true;i=typeof t==="string"?t:t.outerHTML;return null}}]}})});if(r.slice){mt.fromSchema(s).parseSlice(Ru(t),r.parseOptions)}else{mt.fromSchema(s).parse(Ru(t),r.parseOptions)}if(r.errorOnInvalidContent&&n){throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${i}`)})}}const n=mt.fromSchema(e);if(r.slice){return n.parseSlice(Ru(t),r.parseOptions).content}return n.parse(Ru(t),r.parseOptions)}return Cu("",e,r)}function Lu(t,e,r){const n=t.steps.length-1;if(n<e){return}const i=t.steps[n];if(!(i instanceof re||i instanceof ne)){return}const s=t.mapping.maps[n];let o=0;s.forEach(((t,e,r,n)=>{if(o===0){o=n}}));t.setSelection(Ze.near(t.doc.resolve(o),r))}var Nu=t=>!("type"in t);var Pu=(t,e,r)=>({tr:n,dispatch:i,editor:s})=>{var o;if(i){r={parseOptions:s.options.parseOptions,updateSelection:true,applyInputRules:false,applyPasteRules:false,...r};let i;const l=t=>{s.emit("contentError",{editor:s,error:t,disableCollaboration:()=>{if("collaboration"in s.storage&&typeof s.storage.collaboration==="object"&&s.storage.collaboration){s.storage.collaboration.isDisabled=true}}})};const u={preserveWhitespace:"full",...r.parseOptions};if(!r.errorOnInvalidContent&&!s.options.enableContentCheck&&s.options.emitContentError){try{Cu(e,s.schema,{parseOptions:u,errorOnInvalidContent:true})}catch(t){l(t)}}try{i=Cu(e,s.schema,{parseOptions:u,errorOnInvalidContent:(o=r.errorOnInvalidContent)!=null?o:s.options.enableContentCheck})}catch(t){l(t);return false}let{from:a,to:f}=typeof t==="number"?{from:t,to:t}:{from:t.from,to:t.to};let h=true;let c=true;const d=Nu(i)?i:[i];d.forEach((t=>{t.check();h=h?t.isText&&t.marks.length===0:false;c=c?t.isBlock:false}));if(a===f&&c){const{parent:t}=n.doc.resolve(a);const e=t.isTextblock&&!t.type.spec.code&&!t.childCount;if(e){a-=1;f+=1}}let p;if(h){if(Array.isArray(e)){p=e.map((t=>t.text||"")).join("")}else if(e instanceof m){let t="";e.forEach((e=>{if(e.text){t+=e.text}}));p=t}else if(typeof e==="object"&&!!e&&!!e.text){p=e.text}else{p=e}n.insertText(p,a,f)}else{p=i;const t=n.doc.resolve(a);const e=t.node();const r=t.parentOffset===0;const s=e.isText||e.isTextblock;const o=e.content.size>0;if(r&&s&&o){a=Math.max(0,a-1)}n.replaceWith(a,f,p)}if(r.updateSelection){Lu(n,n.steps.length-1,-1)}if(r.applyInputRules){n.setMeta("applyInputRules",{from:a,text:p})}if(r.applyPasteRules){n.setMeta("applyPasteRules",{from:a,text:p})}}return true};var Iu=()=>({state:t,dispatch:e})=>Ir(t,e);var Du=()=>({state:t,dispatch:e})=>Dr(t,e);var Hu=()=>({state:t,dispatch:e})=>Sr(t,e);var ju=()=>({state:t,dispatch:e})=>Lr(t,e);var _u=()=>({state:t,dispatch:e,tr:r})=>{try{const n=Ee(t.doc,t.selection.$from.pos,-1);if(n===null||n===void 0){return false}r.join(n,2);if(e){e(r)}return true}catch{return false}};var zu=()=>({state:t,dispatch:e,tr:r})=>{try{const n=Ee(t.doc,t.selection.$from.pos,1);if(n===null||n===void 0){return false}r.join(n,2);if(e){e(r)}return true}catch{return false}};var Bu=()=>({state:t,dispatch:e})=>Tr(t,e);var Fu=()=>({state:t,dispatch:e})=>Er(t,e);function Uu(){return typeof navigator!=="undefined"?/Mac/.test(navigator.platform):false}function qu(t){const e=t.split(/-(?!$)/);let r=e[e.length-1];if(r==="Space"){r=" "}let n;let i;let s;let o;for(let t=0;t<e.length-1;t+=1){const r=e[t];if(/^(cmd|meta|m)$/i.test(r)){o=true}else if(/^a(lt)?$/i.test(r)){n=true}else if(/^(c|ctrl|control)$/i.test(r)){i=true}else if(/^s(hift)?$/i.test(r)){s=true}else if(/^mod$/i.test(r)){if(Tu()||Uu()){o=true}else{i=true}}else{throw new Error(`Unrecognized modifier name: ${r}`)}}if(n){r=`Alt-${r}`}if(i){r=`Ctrl-${r}`}if(o){r=`Meta-${r}`}if(s){r=`Shift-${r}`}return r}var Ju=t=>({editor:e,view:r,tr:n,dispatch:i})=>{const s=qu(t).split(/-(?!$)/);const o=s.find((t=>!["Alt","Ctrl","Meta","Shift"].includes(t)));const l=new KeyboardEvent("keydown",{key:o==="Space"?" ":o,altKey:s.includes("Alt"),ctrlKey:s.includes("Ctrl"),metaKey:s.includes("Meta"),shiftKey:s.includes("Shift"),bubbles:true,cancelable:true});const u=e.captureTransaction((()=>{r.someProp("handleKeyDown",(t=>t(r,l)))}));u==null?void 0:u.steps.forEach((t=>{const e=t.map(n.mapping);if(e&&i){n.maybeStep(e)}}));return true};function Ku(t,e,r={}){const{from:n,to:i,empty:s}=t.selection;const o=e?lu(e,t.schema):null;const l=[];t.doc.nodesBetween(n,i,((t,e)=>{if(t.isText){return}const r=Math.max(n,e);const s=Math.min(i,e+t.nodeSize);l.push({node:t,from:r,to:s})}));const u=i-n;const a=l.filter((t=>{if(!o){return true}return o.name===t.node.type.name})).filter((t=>pu(t.node.attrs,r,{strict:false})));if(s){return!!a.length}const f=a.reduce(((t,e)=>t+e.to-e.from),0);return f>=u}var Wu=(t,e={})=>({state:r,dispatch:n})=>{const i=lu(t,r.schema);const s=Ku(r,i,e);if(!s){return false}return Hr(r,n)};var Vu=()=>({state:t,dispatch:e})=>Fr(t,e);var Gu=t=>({state:e,dispatch:r})=>{const n=lu(t,e.schema);return an(n)(e,r)};var Zu=()=>({state:t,dispatch:e})=>jr(t,e);function Qu(t,e){if(e.nodes[t]){return"node"}if(e.marks[t]){return"mark"}return null}function Xu(t,e){const r=typeof e==="string"?[e]:e;return Object.keys(t).reduce(((e,n)=>{if(!r.includes(n)){e[n]=t[n]}return e}),{})}var Yu=(t,e)=>({tr:r,state:n,dispatch:i})=>{let s=null;let o=null;const l=Qu(typeof t==="string"?t:t.name,n.schema);if(!l){return false}if(l==="node"){s=lu(t,n.schema)}if(l==="mark"){o=bu(t,n.schema)}if(i){r.selection.ranges.forEach((t=>{n.doc.nodesBetween(t.$from.pos,t.$to.pos,((t,n)=>{if(s&&s===t.type){r.setNodeMarkup(n,void 0,Xu(t.attrs,e))}if(o&&t.marks.length){t.marks.forEach((i=>{if(o===i.type){r.addMark(n,n+t.nodeSize,o.create(Xu(i.attrs,e)))}}))}}))}))}return true};var ta=()=>({tr:t,dispatch:e})=>{if(e){t.scrollIntoView()}return true};var ea=()=>({tr:t,dispatch:e})=>{if(e){const e=new ir(t.doc);t.setSelection(e)}return true};var ra=()=>({state:t,dispatch:e})=>Or(t,e);var na=()=>({state:t,dispatch:e})=>Nr(t,e);var ia=()=>({state:t,dispatch:e})=>Jr(t,e);var sa=()=>({state:t,dispatch:e})=>Qr(t,e);var oa=()=>({state:t,dispatch:e})=>Zr(t,e);function la(t,e,r={},n={}){return Cu(t,e,{slice:false,parseOptions:r,errorOnInvalidContent:n.errorOnInvalidContent})}var ua=(t,{errorOnInvalidContent:e,emitUpdate:r=true,parseOptions:n={}}={})=>({editor:i,tr:s,dispatch:o,commands:l})=>{const{doc:u}=s;if(n.preserveWhitespace!=="full"){const l=la(t,i.schema,n,{errorOnInvalidContent:e!=null?e:i.options.enableContentCheck});if(o){s.replaceWith(0,u.content.size,l).setMeta("preventUpdate",!r)}return true}if(o){s.setMeta("preventUpdate",!r)}return l.insertContentAt({from:0,to:u.content.size},t,{parseOptions:n,errorOnInvalidContent:e!=null?e:i.options.enableContentCheck})};function aa(t,e){const r=bu(e,t.schema);const{from:n,to:i,empty:s}=t.selection;const o=[];if(s){if(t.storedMarks){o.push(...t.storedMarks)}o.push(...t.selection.$head.marks())}else{t.doc.nodesBetween(n,i,(t=>{o.push(...t.marks)}))}const l=o.find((t=>t.type.name===r.name));if(!l){return{}}return{...l.attrs}}function fa(t,e){const r=new Ve(t);e.forEach((t=>{t.steps.forEach((t=>{r.step(t)}))}));return r}function ha(t){for(let e=0;e<t.edgeCount;e+=1){const{type:r}=t.edge(e);if(r.isTextblock&&!r.hasRequiredAttrs()){return r}}return null}function ca(t,e,r){const n=[];t.nodesBetween(e.from,e.to,((t,e)=>{if(r(t)){n.push({node:t,pos:e})}}));return n}function da(t,e){for(let r=t.depth;r>0;r-=1){const n=t.node(r);if(e(n)){return{pos:r>0?t.before(r):0,start:t.start(r),depth:r,node:n}}}}function pa(t){return e=>da(e.$from,t)}function ma(t,e,r){if(t.config[e]===void 0&&t.parent){return ma(t.parent,e,r)}if(typeof t.config[e]==="function"){const n=t.config[e].bind({...r,parent:t.parent?ma(t.parent,e,r):null});return n}return t.config[e]}function ga(t){return t.map((t=>{const e={name:t.name,options:t.options,storage:t.storage};const r=ma(t,"addExtensions",e);if(r){return[t,...ga(r())]}return t})).flat(10)}function wa(t,e){const r=Ot.fromSchema(e).serializeFragment(t);const n=document.implementation.createHTMLDocument();const i=n.createElement("div");i.appendChild(r);return i.innerHTML}function ba(t){return typeof t==="function"}function ka(t,e=void 0,...r){if(ba(t)){if(e){return t.bind(e)(...r)}return t(...r)}return t}function va(t={}){return Object.keys(t).length===0&&t.constructor===Object}function ya(t){const e=t.filter((t=>t.type==="extension"));const r=t.filter((t=>t.type==="node"));const n=t.filter((t=>t.type==="mark"));return{baseExtensions:e,nodeExtensions:r,markExtensions:n}}function Ma(t){const e=[];const{nodeExtensions:r,markExtensions:n}=ya(t);const i=[...r,...n];const s={default:null,validate:void 0,rendered:true,renderHTML:null,parseHTML:null,keepOnSplit:true,isRequired:false};t.forEach((t=>{const r={name:t.name,options:t.options,storage:t.storage,extensions:i};const n=ma(t,"addGlobalAttributes",r);if(!n){return}const o=n();o.forEach((t=>{t.types.forEach((r=>{Object.entries(t.attributes).forEach((([t,n])=>{e.push({type:r,name:t,attribute:{...s,...n}})}))}))}))}));i.forEach((t=>{const r={name:t.name,options:t.options,storage:t.storage};const n=ma(t,"addAttributes",r);if(!n){return}const i=n();Object.entries(i).forEach((([r,n])=>{const i={...s,...n};if(typeof(i==null?void 0:i.default)==="function"){i.default=i.default()}if((i==null?void 0:i.isRequired)&&(i==null?void 0:i.default)===void 0){delete i.default}e.push({type:t.name,name:r,attribute:i})}))}));return e}function xa(...t){return t.filter((t=>!!t)).reduce(((t,e)=>{const r={...t};Object.entries(e).forEach((([t,e])=>{const n=r[t];if(!n){r[t]=e;return}if(t==="class"){const n=e?String(e).split(" "):[];const i=r[t]?r[t].split(" "):[];const s=n.filter((t=>!i.includes(t)));r[t]=[...i,...s].join(" ")}else if(t==="style"){const n=e?e.split(";").map((t=>t.trim())).filter(Boolean):[];const i=r[t]?r[t].split(";").map((t=>t.trim())).filter(Boolean):[];const s=new Map;i.forEach((t=>{const[e,r]=t.split(":").map((t=>t.trim()));s.set(e,r)}));n.forEach((t=>{const[e,r]=t.split(":").map((t=>t.trim()));s.set(e,r)}));r[t]=Array.from(s.entries()).map((([t,e])=>`${t}: ${e}`)).join("; ")}else{r[t]=e}}));return r}),{})}function Sa(t,e){return e.filter((e=>e.type===t.type.name)).filter((t=>t.attribute.rendered)).map((e=>{if(!e.attribute.renderHTML){return{[e.name]:t.attrs[e.name]}}return e.attribute.renderHTML(t.attrs)||{}})).reduce(((t,e)=>xa(t,e)),{})}function Ta(t){if(typeof t!=="string"){return t}if(t.match(/^[+-]?(?:\d*\.)?\d+$/)){return Number(t)}if(t==="true"){return true}if(t==="false"){return false}return t}function Ea(t,e){if("style"in t){return t}return{...t,getAttrs:r=>{const n=t.getAttrs?t.getAttrs(r):t.attrs;if(n===false){return false}const i=e.reduce(((t,e)=>{const n=e.attribute.parseHTML?e.attribute.parseHTML(r):Ta(r.getAttribute(e.name));if(n===null||n===void 0){return t}return{...t,[e.name]:n}}),{});return{...n,...i}}}}function $a(t){return Object.fromEntries(Object.entries(t).filter((([t,e])=>{if(t==="attrs"&&va(e)){return false}return e!==null&&e!==void 0})))}function Aa(t,e){var r;const n=Ma(t);const{nodeExtensions:i,markExtensions:s}=ya(t);const o=(r=i.find((t=>ma(t,"topNode"))))==null?void 0:r.name;const l=Object.fromEntries(i.map((r=>{const i=n.filter((t=>t.type===r.name));const s={name:r.name,options:r.options,storage:r.storage,editor:e};const o=t.reduce(((t,e)=>{const n=ma(e,"extendNodeSchema",s);return{...t,...n?n(r):{}}}),{});const l=$a({...o,content:ka(ma(r,"content",s)),marks:ka(ma(r,"marks",s)),group:ka(ma(r,"group",s)),inline:ka(ma(r,"inline",s)),atom:ka(ma(r,"atom",s)),selectable:ka(ma(r,"selectable",s)),draggable:ka(ma(r,"draggable",s)),code:ka(ma(r,"code",s)),whitespace:ka(ma(r,"whitespace",s)),linebreakReplacement:ka(ma(r,"linebreakReplacement",s)),defining:ka(ma(r,"defining",s)),isolating:ka(ma(r,"isolating",s)),attrs:Object.fromEntries(i.map((t=>{var e,r;return[t.name,{default:(e=t==null?void 0:t.attribute)==null?void 0:e.default,validate:(r=t==null?void 0:t.attribute)==null?void 0:r.validate}]})))});const u=ka(ma(r,"parseHTML",s));if(u){l.parseDOM=u.map((t=>Ea(t,i)))}const a=ma(r,"renderHTML",s);if(a){l.toDOM=t=>a({node:t,HTMLAttributes:Sa(t,i)})}const f=ma(r,"renderText",s);if(f){l.toText=f}return[r.name,l]})));const u=Object.fromEntries(s.map((r=>{const i=n.filter((t=>t.type===r.name));const s={name:r.name,options:r.options,storage:r.storage,editor:e};const o=t.reduce(((t,e)=>{const n=ma(e,"extendMarkSchema",s);return{...t,...n?n(r):{}}}),{});const l=$a({...o,inclusive:ka(ma(r,"inclusive",s)),excludes:ka(ma(r,"excludes",s)),group:ka(ma(r,"group",s)),spanning:ka(ma(r,"spanning",s)),code:ka(ma(r,"code",s)),attrs:Object.fromEntries(i.map((t=>{var e,r;return[t.name,{default:(e=t==null?void 0:t.attribute)==null?void 0:e.default,validate:(r=t==null?void 0:t.attribute)==null?void 0:r.validate}]})))});const u=ka(ma(r,"parseHTML",s));if(u){l.parseDOM=u.map((t=>Ea(t,i)))}const a=ma(r,"renderHTML",s);if(a){l.toDOM=t=>a({mark:t,HTMLAttributes:Sa(t,i)})}return[r.name,l]})));return new ht({topNode:o,nodes:l,marks:u})}function Oa(t){const e=t.filter(((e,r)=>t.indexOf(e)!==r));return Array.from(new Set(e))}function Ra(t){const e=100;return t.sort(((t,r)=>{const n=ma(t,"priority")||e;const i=ma(r,"priority")||e;if(n>i){return-1}if(n<i){return 1}return 0}))}function Ca(t){const e=Ra(ga(t));const r=Oa(e.map((t=>t.name)));if(r.length){console.warn(`[tiptap warn]: Duplicate extension names found: [${r.map((t=>`'${t}'`)).join(", ")}]. This can lead to issues.`)}return e}function La(t,e){const r=Ca(t);return Aa(r,e)}function Na(t,e){const r=La(e);const n=Ru(t);return mt.fromSchema(r).parse(n).toJSON()}function Pa(t,e,r){const{from:n,to:i}=e;const{blockSeparator:s="\n\n",textSerializers:o={}}=r||{};let l="";t.nodesBetween(n,i,((t,r,u,a)=>{var f;if(t.isBlock&&r>n){l+=s}const h=o==null?void 0:o[t.type.name];if(h){if(u){l+=h({node:t,pos:r,parent:u,index:a,range:e})}return false}if(t.isText){l+=(f=t==null?void 0:t.text)==null?void 0:f.slice(Math.max(n,r)-r,i-r)}}));return l}function Ia(t,e){const r={from:0,to:t.content.size};return Pa(t,r,e)}function Da(t){return Object.fromEntries(Object.entries(t.nodes).filter((([,t])=>t.spec.toText)).map((([t,e])=>[t,e.spec.toText])))}function Ha(t,e){const r=lu(e,t.schema);const{from:n,to:i}=t.selection;const s=[];t.doc.nodesBetween(n,i,(t=>{s.push(t)}));const o=s.reverse().find((t=>t.type.name===r.name));if(!o){return{}}return{...o.attrs}}function ja(t,e){const r=Qu(typeof e==="string"?e:e.name,t.schema);if(r==="node"){return Ha(t,e)}if(r==="mark"){return aa(t,e)}return{}}function _a(t,e=JSON.stringify){const r={};return t.filter((t=>{const n=e(t);return Object.prototype.hasOwnProperty.call(r,n)?false:r[n]=true}))}function za(t){const e=_a(t);return e.length===1?e:e.filter(((t,r)=>{const n=e.filter(((t,e)=>e!==r));return!n.some((e=>t.oldRange.from>=e.oldRange.from&&t.oldRange.to<=e.oldRange.to&&t.newRange.from>=e.newRange.from&&t.newRange.to<=e.newRange.to))}))}function Ba(t){const{mapping:e,steps:r}=t;const n=[];e.maps.forEach(((t,i)=>{const s=[];if(!t.ranges.length){const{from:t,to:e}=r[i];if(t===void 0||e===void 0){return}s.push({from:t,to:e})}else{t.forEach(((t,e)=>{s.push({from:t,to:e})}))}s.forEach((({from:t,to:r})=>{const s=e.slice(i).map(t,-1);const o=e.slice(i).map(r);const l=e.invert().map(s,-1);const u=e.invert().map(o);n.push({oldRange:{from:l,to:u},newRange:{from:s,to:o}})}))}));return za(n)}function Fa(t,e,r){const n=[];if(t===e){r.resolve(t).marks().forEach((e=>{const i=r.resolve(t);const s=wu(i,e.type);if(!s){return}n.push({mark:e,...s})}))}else{r.nodesBetween(t,e,((t,e)=>{if(!t||(t==null?void 0:t.nodeSize)===void 0){return}n.push(...t.marks.map((r=>({from:e,to:e+t.nodeSize,mark:r}))))}))}return n}var Ua=(t,e,r,n=20)=>{const i=t.doc.resolve(r);let s=n;let o=null;while(s>0&&o===null){const t=i.node(s);if((t==null?void 0:t.type.name)===e){o=t}else{s-=1}}return[o,s]};function qa(t,e){return e.nodes[t]||e.marks[t]||null}function Ja(t,e,r){return Object.fromEntries(Object.entries(r).filter((([r])=>{const n=t.find((t=>t.type===e&&t.name===r));if(!n){return false}return n.attribute.keepOnSplit})))}var Ka=(t,e=500)=>{let r="";const n=t.parentOffset;t.parent.nodesBetween(Math.max(0,n-e),n,((t,e,i,s)=>{var o,l;const u=((l=(o=t.type.spec).toText)==null?void 0:l.call(o,{node:t,pos:e,parent:i,index:s}))||t.textContent||"%leaf%";r+=t.isAtom&&!t.isText?u:u.slice(0,Math.max(0,n-e))}));return r};function Wa(t,e,r={}){const{empty:n,ranges:i}=t.selection;const s=e?bu(e,t.schema):null;if(n){return!!(t.storedMarks||t.selection.$from.marks()).filter((t=>{if(!s){return true}return s.name===t.type.name})).find((t=>pu(t.attrs,r,{strict:false})))}let o=0;const l=[];i.forEach((({$from:e,$to:r})=>{const n=e.pos;const i=r.pos;t.doc.nodesBetween(n,i,((t,e)=>{if(!t.isText&&!t.marks.length){return}const r=Math.max(n,e);const s=Math.min(i,e+t.nodeSize);const u=s-r;o+=u;l.push(...t.marks.map((t=>({mark:t,from:r,to:s}))))}))}));if(o===0){return false}const u=l.filter((t=>{if(!s){return true}return s.name===t.mark.type.name})).filter((t=>pu(t.mark.attrs,r,{strict:false}))).reduce(((t,e)=>t+e.to-e.from),0);const a=l.filter((t=>{if(!s){return true}return t.mark.type!==s&&t.mark.type.excludes(s)})).reduce(((t,e)=>t+e.to-e.from),0);const f=u>0?u+a:u;return f>=o}function Va(t,e,r={}){if(!e){return Ku(t,null,r)||Wa(t,null,r)}const n=Qu(e,t.schema);if(n==="node"){return Ku(t,e,r)}if(n==="mark"){return Wa(t,e,r)}return false}var Ga=(t,e)=>{const{$from:r,$to:n,$anchor:i}=t.selection;if(e){const r=pa((t=>t.type.name===e))(t.selection);if(!r){return false}const n=t.doc.resolve(r.pos+1);if(i.pos+1===n.end()){return true}return false}if(n.parentOffset<n.parent.nodeSize-2||r.pos!==n.pos){return false}return true};var Za=t=>{const{$from:e,$to:r}=t.selection;if(e.parentOffset>0||e.pos!==r.pos){return false}return true};function Qa(t,e){if(Array.isArray(e)){return e.some((e=>{const r=typeof e==="string"?e:e.name;return r===t.name}))}return e}function Xa(t,e){const{nodeExtensions:r}=ya(e);const n=r.find((e=>e.name===t));if(!n){return false}const i={name:n.name,options:n.options,storage:n.storage};const s=ka(ma(n,"group",i));if(typeof s!=="string"){return false}return s.split(" ").includes("list")}function Ya(t,{checkChildren:e=true,ignoreWhitespace:r=false}={}){var n;if(r){if(t.type.name==="hardBreak"){return true}if(t.isText){return/^\s*$/m.test((n=t.text)!=null?n:"")}}if(t.isText){return!t.text}if(t.isAtom||t.isLeaf){return false}if(t.content.childCount===0){return true}if(e){let n=true;t.content.forEach((t=>{if(n===false){return}if(!Ya(t,{ignoreWhitespace:r,checkChildren:e})){n=false}}));return n}return false}function tf(t){return t instanceof rr}function ef(t,e,r){var n;const{selection:i}=e;let s=null;if(yu(i)){s=i.$cursor}if(s){const e=(n=t.storedMarks)!=null?n:s.marks();const i=s.parent.type.allowsMarkType(r);return i&&(!!r.isInSet(e)||!e.some((t=>t.type.excludes(r))))}const{ranges:o}=i;return o.some((({$from:e,$to:n})=>{let i=e.depth===0?t.doc.inlineContent&&t.doc.type.allowsMarkType(r):false;t.doc.nodesBetween(e.pos,n.pos,((t,e,n)=>{if(i){return false}if(t.isInline){const e=!n||n.type.allowsMarkType(r);const s=!!r.isInSet(t.marks)||!t.marks.some((t=>t.type.excludes(r)));i=e&&s}return!i}));return i}))}var rf=(t,e={})=>({tr:r,state:n,dispatch:i})=>{const{selection:s}=r;const{empty:o,ranges:l}=s;const u=bu(t,n.schema);if(i){if(o){const t=aa(n,u);r.addStoredMark(u.create({...t,...e}))}else{l.forEach((t=>{const i=t.$from.pos;const s=t.$to.pos;n.doc.nodesBetween(i,s,((t,n)=>{const o=Math.max(n,i);const l=Math.min(n+t.nodeSize,s);const a=t.marks.find((t=>t.type===u));if(a){t.marks.forEach((t=>{if(u===t.type){r.addMark(o,l,u.create({...t.attrs,...e}))}}))}else{r.addMark(o,l,u.create(e))}}))}))}}return ef(n,r,u)};var nf=(t,e)=>({tr:r})=>{r.setMeta(t,e);return true};var sf=(t,e={})=>({state:r,dispatch:n,chain:i})=>{const s=lu(t,r.schema);let o;if(r.selection.$anchor.sameParent(r.selection.$head)){o=r.selection.$anchor.parent.attrs}if(!s.isTextblock){console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.');return false}return i().command((({commands:t})=>{const n=Yr(s,{...o,...e})(r);if(n){return true}return t.clearNodes()})).command((({state:t})=>Yr(s,{...o,...e})(t,n))).run()};var of=t=>({tr:e,dispatch:r})=>{if(r){const{doc:r}=e;const n=Mu(t,0,r.content.size);const i=rr.create(r,n);e.setSelection(i)}return true};var lf=t=>({tr:e,dispatch:r})=>{if(r){const{doc:r}=e;const{from:n,to:i}=typeof t==="number"?{from:t,to:t}:t;const s=tr.atStart(r).from;const o=tr.atEnd(r).to;const l=Mu(n,s,o);const u=Mu(i,s,o);const a=tr.create(r,l,u);e.setSelection(a)}return true};var uf=t=>({state:e,dispatch:r})=>{const n=lu(t,e.schema);return cn(n)(e,r)};function af(t,e){const r=t.storedMarks||t.selection.$to.parentOffset&&t.selection.$from.marks();if(r){const n=r.filter((t=>e==null?void 0:e.includes(t.type.name)));t.tr.ensureMarks(n)}}var ff=({keepMarks:t=true}={})=>({tr:e,state:r,dispatch:n,editor:i})=>{const{selection:s,doc:o}=e;const{$from:l,$to:u}=s;const a=i.extensionManager.attributes;const f=Ja(a,l.node().type.name,l.node().attrs);if(s instanceof rr&&s.node.isBlock){if(!l.parentOffset||!ye(o,l.pos)){return false}if(n){if(t){af(r,i.extensionManager.splittableMarks)}e.split(l.pos).scrollIntoView()}return true}if(!l.parent.isBlock){return false}const h=u.parentOffset===u.parent.content.size;const c=l.depth===0?void 0:ha(l.node(-1).contentMatchAt(l.indexAfter(-1)));let d=h&&c?[{type:c,attrs:f}]:void 0;let p=ye(e.doc,e.mapping.map(l.pos),1,d);if(!d&&!p&&ye(e.doc,e.mapping.map(l.pos),1,c?[{type:c}]:void 0)){p=true;d=c?[{type:c,attrs:f}]:void 0}if(n){if(p){if(s instanceof tr){e.deleteSelection()}e.split(e.mapping.map(l.pos),1,d);if(c&&!h&&!l.parentOffset&&l.parent.type!==c){const t=e.mapping.map(l.before());const r=e.doc.resolve(t);if(l.node(-1).canReplaceWith(r.index(),r.index()+1,c)){e.setNodeMarkup(e.mapping.map(l.before()),c)}}}if(t){af(r,i.extensionManager.splittableMarks)}e.scrollIntoView()}return p};var hf=(t,e={})=>({tr:r,state:n,dispatch:i,editor:s})=>{var o;const l=lu(t,n.schema);const{$from:u,$to:a}=n.selection;const f=n.selection.node;if(f&&f.isBlock||u.depth<2||!u.sameParent(a)){return false}const h=u.node(-1);if(h.type!==l){return false}const c=s.extensionManager.attributes;if(u.parent.content.size===0&&u.node(-1).childCount===u.indexAfter(-1)){if(u.depth===2||u.node(-3).type!==l||u.index(-2)!==u.node(-2).childCount-1){return false}if(i){let t=m.empty;const n=u.index(-1)?1:u.index(-2)?2:3;for(let e=u.depth-n;e>=u.depth-3;e-=1){t=m.from(u.node(e).copy(t))}const i=u.indexAfter(-1)<u.node(-2).childCount?1:u.indexAfter(-2)<u.node(-3).childCount?2:3;const s={...Ja(c,u.node().type.name,u.node().attrs),...e};const a=((o=l.contentMatch.defaultType)==null?void 0:o.createAndFill(s))||void 0;t=t.append(m.from(l.createAndFill(null,a)||void 0));const f=u.before(u.depth-(n-1));r.replace(f,u.after(-i),new y(t,4-n,0));let h=-1;r.doc.nodesBetween(f,r.doc.content.size,((t,e)=>{if(h>-1){return false}if(t.isTextblock&&t.content.size===0){h=e+1}}));if(h>-1){r.setSelection(tr.near(r.doc.resolve(h)))}r.scrollIntoView()}return true}const d=a.pos===u.end()?h.contentMatchAt(0).defaultType:null;const p={...Ja(c,h.type.name,h.attrs),...e};const g={...Ja(c,u.node().type.name,u.node().attrs),...e};r.delete(u.pos,a.pos);const w=d?[{type:l,attrs:p},{type:d,attrs:g}]:[{type:l,attrs:p}];if(!ye(r.doc,u.pos,2)){return false}if(i){const{selection:t,storedMarks:e}=n;const{splittableMarks:o}=s.extensionManager;const l=e||t.$to.parentOffset&&t.$from.marks();r.split(u.pos,2,w).scrollIntoView();if(!l||!i){return true}const a=l.filter((t=>o.includes(t.type.name)));r.ensureMarks(a)}return true};var cf=(t,e)=>{const r=pa((t=>t.type===e))(t.selection);if(!r){return true}const n=t.doc.resolve(Math.max(0,r.pos-1)).before(r.depth);if(n===void 0){return true}const i=t.doc.nodeAt(n);const s=r.node.type===(i==null?void 0:i.type)&&xe(t.doc,r.pos);if(!s){return true}t.join(r.pos);return true};var df=(t,e)=>{const r=pa((t=>t.type===e))(t.selection);if(!r){return true}const n=t.doc.resolve(r.start).after(r.depth);if(n===void 0){return true}const i=t.doc.nodeAt(n);const s=r.node.type===(i==null?void 0:i.type)&&xe(t.doc,n);if(!s){return true}t.join(n);return true};var pf=(t,e,r,n={})=>({editor:i,tr:s,state:o,dispatch:l,chain:u,commands:a,can:f})=>{const{extensions:h,splittableMarks:c}=i.extensionManager;const d=lu(t,o.schema);const p=lu(e,o.schema);const{selection:m,storedMarks:g}=o;const{$from:w,$to:b}=m;const k=w.blockRange(b);const v=g||m.$to.parentOffset&&m.$from.marks();if(!k){return false}const y=pa((t=>Xa(t.type.name,h)))(m);if(k.depth>=1&&y&&k.depth-y.depth<=1){if(y.node.type===d){return a.liftListItem(p)}if(Xa(y.node.type.name,h)&&d.validContent(y.node.content)&&l){return u().command((()=>{s.setNodeMarkup(y.pos,d);return true})).command((()=>cf(s,d))).command((()=>df(s,d))).run()}}if(!r||!v||!l){return u().command((()=>{const t=f().wrapInList(d,n);if(t){return true}return a.clearNodes()})).wrapInList(d,n).command((()=>cf(s,d))).command((()=>df(s,d))).run()}return u().command((()=>{const t=f().wrapInList(d,n);const e=v.filter((t=>c.includes(t.type.name)));s.ensureMarks(e);if(t){return true}return a.clearNodes()})).wrapInList(d,n).command((()=>cf(s,d))).command((()=>df(s,d))).run()};var mf=(t,e={},r={})=>({state:n,commands:i})=>{const{extendEmptyMarkRange:s=false}=r;const o=bu(t,n.schema);const l=Wa(n,o,e);if(l){return i.unsetMark(o,{extendEmptyMarkRange:s})}return i.setMark(o,e)};var gf=(t,e,r={})=>({state:n,commands:i})=>{const s=lu(t,n.schema);const o=lu(e,n.schema);const l=Ku(n,s,r);let u;if(n.selection.$anchor.sameParent(n.selection.$head)){u=n.selection.$anchor.parent.attrs}if(l){return i.setNode(o,u)}return i.setNode(s,{...u,...r})};var wf=(t,e={})=>({state:r,commands:n})=>{const i=lu(t,r.schema);const s=Ku(r,i,e);if(s){return n.lift(i)}return n.wrapIn(i,e)};var bf=()=>({state:t,dispatch:e})=>{const r=t.plugins;for(let n=0;n<r.length;n+=1){const i=r[n];let s;if(i.spec.isInputRules&&(s=i.getState(t))){if(e){const e=t.tr;const r=s.transform;for(let t=r.steps.length-1;t>=0;t-=1){e.step(r.steps[t].invert(r.docs[t]))}if(s.text){const r=e.doc.resolve(s.from).marks();e.replaceWith(s.from,s.to,t.schema.text(s.text,r))}else{e.delete(s.from,s.to)}}return true}}return false};var kf=()=>({tr:t,dispatch:e})=>{const{selection:r}=t;const{empty:n,ranges:i}=r;if(n){return true}if(e){i.forEach((e=>{t.removeMark(e.$from.pos,e.$to.pos)}))}return true};var vf=(t,e={})=>({tr:r,state:n,dispatch:i})=>{var s;const{extendEmptyMarkRange:o=false}=e;const{selection:l}=r;const u=bu(t,n.schema);const{$from:a,empty:f,ranges:h}=l;if(!i){return true}if(f&&o){let{from:t,to:e}=l;const n=(s=a.marks().find((t=>t.type===u)))==null?void 0:s.attrs;const i=wu(a,u,n);if(i){t=i.from;e=i.to}r.removeMark(t,e,u)}else{h.forEach((t=>{r.removeMark(t.$from.pos,t.$to.pos,u)}))}r.removeStoredMark(u);return true};var yf=(t,e={})=>({tr:r,state:n,dispatch:i})=>{let s=null;let o=null;const l=Qu(typeof t==="string"?t:t.name,n.schema);if(!l){return false}if(l==="node"){s=lu(t,n.schema)}if(l==="mark"){o=bu(t,n.schema)}if(i){r.selection.ranges.forEach((t=>{const i=t.$from.pos;const l=t.$to.pos;let u;let a;let f;let h;if(r.selection.empty){n.doc.nodesBetween(i,l,((t,e)=>{if(s&&s===t.type){f=Math.max(e,i);h=Math.min(e+t.nodeSize,l);u=e;a=t}}))}else{n.doc.nodesBetween(i,l,((t,n)=>{if(n<i&&s&&s===t.type){f=Math.max(n,i);h=Math.min(n+t.nodeSize,l);u=n;a=t}if(n>=i&&n<=l){if(s&&s===t.type){r.setNodeMarkup(n,void 0,{...t.attrs,...e})}if(o&&t.marks.length){t.marks.forEach((s=>{if(o===s.type){const u=Math.max(n,i);const a=Math.min(n+t.nodeSize,l);r.addMark(u,a,o.create({...s.attrs,...e}))}}))}}}))}if(a){if(u!==void 0){r.setNodeMarkup(u,void 0,{...a.attrs,...e})}if(o&&a.marks.length){a.marks.forEach((t=>{if(o===t.type){r.addMark(f,h,o.create({...t.attrs,...e}))}}))}}}))}return true};var Mf=(t,e={})=>({state:r,dispatch:n})=>{const i=lu(t,r.schema);return Xr(i,e)(r,n)};var xf=(t,e={})=>({state:r,dispatch:n})=>{const i=lu(t,r.schema);return on(i,e)(r,n)};var Sf=class{constructor(){this.callbacks={}}on(t,e){if(!this.callbacks[t]){this.callbacks[t]=[]}this.callbacks[t].push(e);return this}emit(t,...e){const r=this.callbacks[t];if(r){r.forEach((t=>t.apply(this,e)))}return this}off(t,e){const r=this.callbacks[t];if(r){if(e){this.callbacks[t]=r.filter((t=>t!==e))}else{delete this.callbacks[t]}}return this}once(t,e){const r=(...n)=>{this.off(t,r);e.apply(this,n)};return this.on(t,r)}removeAllListeners(){this.callbacks={}}};var Tf=class{constructor(t){var e;this.find=t.find;this.handler=t.handler;this.undoable=(e=t.undoable)!=null?e:true}};var Ef=(t,e)=>{if(du(e)){return e.exec(t)}const r=e(t);if(!r){return null}const n=[r.text];n.index=r.index;n.input=t;n.data=r.data;if(r.replaceWith){if(!r.text.includes(r.replaceWith)){console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".')}n.push(r.replaceWith)}return n};function $f(t){var e;const{editor:r,from:n,to:i,text:s,rules:o,plugin:l}=t;const{view:u}=r;if(u.composing){return false}const a=u.state.doc.resolve(n);if(a.parent.type.spec.code||!!((e=a.nodeBefore||a.nodeAfter)==null?void 0:e.marks.find((t=>t.type.spec.code)))){return false}let f=false;const h=Ka(a)+s;o.forEach((t=>{if(f){return}const e=Ef(h,t.find);if(!e){return}const o=u.state.tr;const a=Ql({state:u.state,transaction:o});const c={from:n-(e[0].length-s.length),to:i};const{commands:d,chain:p,can:m}=new Xl({editor:r,state:a});const g=t.handler({state:a,range:c,match:e,commands:d,chain:p,can:m});if(g===null||!o.steps.length){return}if(t.undoable){o.setMeta(l,{transform:o,from:n,to:i,text:s})}u.dispatch(o);f=true}));return f}function Af(t){const{editor:e,rules:r}=t;const n=new br({state:{init(){return null},apply(t,i,s){const o=t.getMeta(n);if(o){return o}const l=t.getMeta("applyInputRules");const u=!!l;if(u){setTimeout((()=>{let{text:t}=l;if(typeof t==="string"){t=t}else{t=wa(m.from(t),s.schema)}const{from:i}=l;const o=i+t.length;$f({editor:e,from:i,to:o,text:t,rules:r,plugin:n})}))}return t.selectionSet||t.docChanged?null:i}},props:{handleTextInput(t,i,s,o){return $f({editor:e,from:i,to:s,text:o,rules:r,plugin:n})},handleDOMEvents:{compositionend:t=>{setTimeout((()=>{const{$cursor:i}=t.state.selection;if(i){$f({editor:e,from:i.pos,to:i.pos,text:"",rules:r,plugin:n})}}));return false}},handleKeyDown(t,i){if(i.key!=="Enter"){return false}const{$cursor:s}=t.state.selection;if(s){return $f({editor:e,from:s.pos,to:s.pos,text:"\n",rules:r,plugin:n})}return false}},isInputRules:true});return n}function Of(t){return Object.prototype.toString.call(t).slice(8,-1)}function Rf(t){if(Of(t)!=="Object"){return false}return t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function Cf(t,e){const r={...t};if(Rf(t)&&Rf(e)){Object.keys(e).forEach((n=>{if(Rf(e[n])&&Rf(t[n])){r[n]=Cf(t[n],e[n])}else{r[n]=e[n]}}))}return r}var Lf=class{constructor(t={}){this.type="extendable";this.parent=null;this.child=null;this.name="";this.config={name:this.name};this.config={...this.config,...t};this.name=this.config.name}get options(){return{...ka(ma(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...ka(ma(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(t={}){const e=this.extend({...this.config,addOptions:()=>Cf(this.options,t)});e.name=this.name;e.parent=this.parent;return e}extend(t={}){const e=new this.constructor({...this.config,...t});e.parent=this;this.child=e;e.name="name"in t?t.name:e.parent.name;return e}};var Nf=class t extends Lf{constructor(){super(...arguments);this.type="mark"}static create(e={}){const r=typeof e==="function"?e():e;return new t(r)}static handleExit({editor:t,mark:e}){const{tr:r}=t.state;const n=t.state.selection.$from;const i=n.pos===n.end();if(i){const i=n.marks();const s=!!i.find((t=>(t==null?void 0:t.type.name)===e.name));if(!s){return false}const o=i.find((t=>(t==null?void 0:t.type.name)===e.name));if(o){r.removeStoredMark(o)}r.insertText(" ",n.pos);t.view.dispatch(r);return true}return false}configure(t){return super.configure(t)}extend(t){const e=typeof t==="function"?t():t;return super.extend(e)}};function Pf(t){return typeof t==="number"}var If=class{constructor(t){this.find=t.find;this.handler=t.handler}};var Df=(t,e,r)=>{if(du(e)){return[...t.matchAll(e)]}const n=e(t,r);if(!n){return[]}return n.map((e=>{const r=[e.text];r.index=e.index;r.input=t;r.data=e.data;if(e.replaceWith){if(!e.text.includes(e.replaceWith)){console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".')}r.push(e.replaceWith)}return r}))};function Hf(t){const{editor:e,state:r,from:n,to:i,rule:s,pasteEvent:o,dropEvent:l}=t;const{commands:u,chain:a,can:f}=new Xl({editor:e,state:r});const h=[];r.doc.nodesBetween(n,i,((t,e)=>{var c,d,p,m,g;if(((d=(c=t.type)==null?void 0:c.spec)==null?void 0:d.code)||!(t.isText||t.isTextblock||t.isInline)){return}const w=(g=(m=(p=t.content)==null?void 0:p.size)!=null?m:t.nodeSize)!=null?g:0;const b=Math.max(n,e);const k=Math.min(i,e+w);if(b>=k){return}const v=t.isText?t.text||"":t.textBetween(b-e,k-e,void 0,"");const y=Df(v,s.find,o);y.forEach((t=>{if(t.index===void 0){return}const e=b+t.index+1;const n=e+t[0].length;const i={from:r.tr.mapping.map(e),to:r.tr.mapping.map(n)};const c=s.handler({state:r,range:i,match:t,commands:u,chain:a,can:f,pasteEvent:o,dropEvent:l});h.push(c)}))}));const c=h.every((t=>t!==null));return c}var jf=null;var _f=t=>{var e;const r=new ClipboardEvent("paste",{clipboardData:new DataTransfer});(e=r.clipboardData)==null?void 0:e.setData("text/html",t);return r};function zf(t){const{editor:e,rules:r}=t;let n=null;let i=false;let s=false;let o=typeof ClipboardEvent!=="undefined"?new ClipboardEvent("paste"):null;let l;try{l=typeof DragEvent!=="undefined"?new DragEvent("drop"):null}catch{l=null}const u=({state:t,from:r,to:n,rule:i,pasteEvt:s})=>{const u=t.tr;const a=Ql({state:t,transaction:u});const f=Hf({editor:e,state:a,from:Math.max(r-1,0),to:n.b-1,rule:i,pasteEvent:s,dropEvent:l});if(!f||!u.steps.length){return}try{l=typeof DragEvent!=="undefined"?new DragEvent("drop"):null}catch{l=null}o=typeof ClipboardEvent!=="undefined"?new ClipboardEvent("paste"):null;return u};const a=r.map((t=>new br({view(t){const r=r=>{var i;n=((i=t.dom.parentElement)==null?void 0:i.contains(r.target))?t.dom.parentElement:null;if(n){jf=e}};const i=()=>{if(jf){jf=null}};window.addEventListener("dragstart",r);window.addEventListener("dragend",i);return{destroy(){window.removeEventListener("dragstart",r);window.removeEventListener("dragend",i)}}},props:{handleDOMEvents:{drop:(t,e)=>{s=n===t.dom.parentElement;l=e;if(!s){const t=jf;if(t==null?void 0:t.isEditable){setTimeout((()=>{const e=t.state.selection;if(e){t.commands.deleteRange({from:e.from,to:e.to})}}),10)}}return false},paste:(t,e)=>{var r;const n=(r=e.clipboardData)==null?void 0:r.getData("text/html");o=e;i=!!(n==null?void 0:n.includes("data-pm-slice"));return false}}},appendTransaction:(e,r,n)=>{const l=e[0];const a=l.getMeta("uiEvent")==="paste"&&!i;const f=l.getMeta("uiEvent")==="drop"&&!s;const h=l.getMeta("applyPasteRules");const c=!!h;if(!a&&!f&&!c){return}if(c){let{text:e}=h;if(typeof e==="string"){e=e}else{e=wa(m.from(e),n.schema)}const{from:r}=h;const i=r+e.length;const s=_f(e);return u({rule:t,state:n,from:r,to:{b:i},pasteEvt:s})}const d=r.doc.content.findDiffStart(n.doc.content);const p=r.doc.content.findDiffEnd(n.doc.content);if(!Pf(d)||!p||d===p.b){return}return u({rule:t,state:n,from:d,to:p,pasteEvt:o})}})));return a}var Bf=class{constructor(t,e){this.splittableMarks=[];this.editor=e;this.baseExtensions=t;this.extensions=Ca(t);this.schema=Aa(this.extensions,e);this.setupExtensions()}get commands(){return this.extensions.reduce(((t,e)=>{const r={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:qa(e.name,this.schema)};const n=ma(e,"addCommands",r);if(!n){return t}return{...t,...n()}}),{})}get plugins(){const{editor:t}=this;const e=Ra([...this.extensions].reverse());const r=e.flatMap((e=>{const r={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:t,type:qa(e.name,this.schema)};const n=[];const i=ma(e,"addKeyboardShortcuts",r);let s={};if(e.type==="mark"&&ma(e,"exitable",r)){s.ArrowRight=()=>Nf.handleExit({editor:t,mark:e})}if(i){const e=Object.fromEntries(Object.entries(i()).map((([e,r])=>[e,()=>r({editor:t})])));s={...s,...e}}const o=Wl(s);n.push(o);const l=ma(e,"addInputRules",r);if(Qa(e,t.options.enableInputRules)&&l){const e=l();if(e&&e.length){const r=Af({editor:t,rules:e});const i=Array.isArray(r)?r:[r];n.push(...i)}}const u=ma(e,"addPasteRules",r);if(Qa(e,t.options.enablePasteRules)&&u){const e=u();if(e&&e.length){const r=zf({editor:t,rules:e});n.push(...r)}}const a=ma(e,"addProseMirrorPlugins",r);if(a){const t=a();n.push(...t)}return n}));return r}get attributes(){return Ma(this.extensions)}get nodeViews(){const{editor:t}=this;const{nodeExtensions:e}=ya(this.extensions);return Object.fromEntries(e.filter((t=>!!ma(t,"addNodeView"))).map((e=>{const r=this.attributes.filter((t=>t.type===e.name));const n={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:t,type:lu(e.name,this.schema)};const i=ma(e,"addNodeView",n);if(!i){return[]}const s=(n,s,o,l,u)=>{const a=Sa(n,r);return i()({node:n,view:s,getPos:o,decorations:l,innerDecorations:u,editor:t,extension:e,HTMLAttributes:a})};return[e.name,s]})))}get markViews(){const{editor:t}=this;const{markExtensions:e}=ya(this.extensions);return Object.fromEntries(e.filter((t=>!!ma(t,"addMarkView"))).map((e=>{const r=this.attributes.filter((t=>t.type===e.name));const n={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:t,type:bu(e.name,this.schema)};const i=ma(e,"addMarkView",n);if(!i){return[]}const s=(n,s,o)=>{const l=Sa(n,r);return i()({mark:n,view:s,inline:o,editor:t,extension:e,HTMLAttributes:l,updateAttributes:e=>{kh(n,t,e)}})};return[e.name,s]})))}setupExtensions(){const t=this.extensions;this.editor.extensionStorage=Object.fromEntries(t.map((t=>[t.name,t.storage])));t.forEach((t=>{var e;const r={name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:this.editor,type:qa(t.name,this.schema)};if(t.type==="mark"){const n=(e=ka(ma(t,"keepOnSplit",r)))!=null?e:true;if(n){this.splittableMarks.push(t.name)}}const n=ma(t,"onBeforeCreate",r);const i=ma(t,"onCreate",r);const s=ma(t,"onUpdate",r);const o=ma(t,"onSelectionUpdate",r);const l=ma(t,"onTransaction",r);const u=ma(t,"onFocus",r);const a=ma(t,"onBlur",r);const f=ma(t,"onDestroy",r);if(n){this.editor.on("beforeCreate",n)}if(i){this.editor.on("create",i)}if(s){this.editor.on("update",s)}if(o){this.editor.on("selectionUpdate",o)}if(l){this.editor.on("transaction",l)}if(u){this.editor.on("focus",u)}if(a){this.editor.on("blur",a)}if(f){this.editor.on("destroy",f)}}))}};Bf.resolve=Ca;Bf.sort=Ra;Bf.flatten=ga;var Ff={};Zl(Ff,{ClipboardTextSerializer:()=>qf,Commands:()=>Jf,Delete:()=>Kf,Drop:()=>Wf,Editable:()=>Vf,FocusEvents:()=>Zf,Keymap:()=>Qf,Paste:()=>Xf,Tabindex:()=>Yf,focusEventsPluginKey:()=>Gf});var Uf=class t extends Lf{constructor(){super(...arguments);this.type="extension"}static create(e={}){const r=typeof e==="function"?e():e;return new t(r)}configure(t){return super.configure(t)}extend(t){const e=typeof t==="function"?t():t;return super.extend(e)}};var qf=Uf.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new br({key:new yr("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:t}=this;const{state:e,schema:r}=t;const{doc:n,selection:i}=e;const{ranges:s}=i;const o=Math.min(...s.map((t=>t.$from.pos)));const l=Math.max(...s.map((t=>t.$to.pos)));const u=Da(r);const a={from:o,to:l};return Pa(n,a,{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:u})}}})]}});var Jf=Uf.create({name:"commands",addCommands(){return{...Yl}}});var Kf=Uf.create({name:"delete",onUpdate({transaction:t,appendedTransactions:e}){var r,n,i;const s=()=>{var r,n,i,s;if((s=(i=(n=(r=this.editor.options.coreExtensionOptions)==null?void 0:r.delete)==null?void 0:n.filterTransaction)==null?void 0:i.call(n,t))!=null?s:t.getMeta("y-sync$")){return}const o=fa(t.before,[t,...e]);const l=Ba(o);l.forEach((e=>{if(o.mapping.mapResult(e.oldRange.from).deletedAfter&&o.mapping.mapResult(e.oldRange.to).deletedBefore){o.before.nodesBetween(e.oldRange.from,e.oldRange.to,((r,n)=>{const i=n+r.nodeSize-2;const s=e.oldRange.from<=n&&i<=e.oldRange.to;this.editor.emit("delete",{type:"node",node:r,from:n,to:i,newFrom:o.mapping.map(n),newTo:o.mapping.map(i),deletedRange:e.oldRange,newRange:e.newRange,partial:!s,editor:this.editor,transaction:t,combinedTransform:o})}))}}));const u=o.mapping;o.steps.forEach(((e,r)=>{var n,i;if(e instanceof Yt){const s=u.slice(r).map(e.from,-1);const l=u.slice(r).map(e.to);const a=u.invert().map(s,-1);const f=u.invert().map(l);const h=(n=o.doc.nodeAt(s-1))==null?void 0:n.marks.some((t=>t.eq(e.mark)));const c=(i=o.doc.nodeAt(l))==null?void 0:i.marks.some((t=>t.eq(e.mark)));this.editor.emit("delete",{type:"mark",mark:e.mark,from:e.from,to:e.to,deletedRange:{from:a,to:f},newRange:{from:s,to:l},partial:Boolean(c||h),editor:this.editor,transaction:t,combinedTransform:o})}}))};if((i=(n=(r=this.editor.options.coreExtensionOptions)==null?void 0:r.delete)==null?void 0:n.async)!=null?i:true){setTimeout(s,0)}else{s()}}});var Wf=Uf.create({name:"drop",addProseMirrorPlugins(){return[new br({key:new yr("tiptapDrop"),props:{handleDrop:(t,e,r,n)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:r,moved:n})}}})]}});var Vf=Uf.create({name:"editable",addProseMirrorPlugins(){return[new br({key:new yr("editable"),props:{editable:()=>this.editor.options.editable}})]}});var Gf=new yr("focusEvents");var Zf=Uf.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new br({key:Gf,props:{handleDOMEvents:{focus:(e,r)=>{t.isFocused=true;const n=t.state.tr.setMeta("focus",{event:r}).setMeta("addToHistory",false);e.dispatch(n);return false},blur:(e,r)=>{t.isFocused=false;const n=t.state.tr.setMeta("blur",{event:r}).setMeta("addToHistory",false);e.dispatch(n);return false}}}})]}});var Qf=Uf.create({name:"keymap",addKeyboardShortcuts(){const t=()=>this.editor.commands.first((({commands:t})=>[()=>t.undoInputRule(),()=>t.command((({tr:e})=>{const{selection:r,doc:n}=e;const{empty:i,$anchor:s}=r;const{pos:o,parent:l}=s;const u=s.parent.isTextblock&&o>0?e.doc.resolve(o-1):s;const a=u.parent.type.spec.isolating;const f=s.pos-s.parentOffset;const h=a&&u.parent.childCount===1?f===s.pos:Ze.atStart(n).from===o;if(!i||!l.type.isTextblock||l.textContent.length||!h||h&&s.parent.type.name==="paragraph"){return false}return t.clearNodes()})),()=>t.deleteSelection(),()=>t.joinBackward(),()=>t.selectNodeBackward()]));const e=()=>this.editor.commands.first((({commands:t})=>[()=>t.deleteSelection(),()=>t.deleteCurrentNode(),()=>t.joinForward(),()=>t.selectNodeForward()]));const r=()=>this.editor.commands.first((({commands:t})=>[()=>t.newlineInCode(),()=>t.createParagraphNear(),()=>t.liftEmptyBlock(),()=>t.splitBlock()]));const n={Enter:r,"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:t,"Mod-Backspace":t,"Shift-Backspace":t,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()};const i={...n};const s={...n,"Ctrl-h":t,"Alt-Backspace":t,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};if(Tu()||Uu()){return s}return i},addProseMirrorPlugins(){return[new br({key:new yr("clearDocument"),appendTransaction:(t,e,r)=>{if(t.some((t=>t.getMeta("composition")))){return}const n=t.some((t=>t.docChanged))&&!e.doc.eq(r.doc);const i=t.some((t=>t.getMeta("preventClearDocument")));if(!n||i){return}const{empty:s,from:o,to:l}=e.selection;const u=Ze.atStart(e.doc).from;const a=Ze.atEnd(e.doc).to;const f=o===u&&l===a;if(s||!f){return}const h=Ya(r.doc);if(!h){return}const c=r.tr;const d=Ql({state:r,transaction:c});const{commands:p}=new Xl({editor:this.editor,state:d});p.clearNodes();if(!c.steps.length){return}return c}})]}});var Xf=Uf.create({name:"paste",addProseMirrorPlugins(){return[new br({key:new yr("tiptapPaste"),props:{handlePaste:(t,e,r)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:r})}}})]}});var Yf=Uf.create({name:"tabindex",addProseMirrorPlugins(){return[new br({key:new yr("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}});var th=class t{constructor(t,e,r=false,n=null){this.currentNode=null;this.actualDepth=null;this.isBlock=r;this.resolvedPos=t;this.editor=e;this.currentNode=n}get name(){return this.node.type.name}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var t;return(t=this.actualDepth)!=null?t:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(t){let e=this.from;let r=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can’t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}e=this.from+1;r=this.to-1}this.editor.commands.insertContentAt({from:e,to:r},t)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){if(this.isBlock){return this.pos}return this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){if(this.isBlock){return this.pos+this.size}return this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(this.depth===0){return null}const e=this.resolvedPos.start(this.resolvedPos.depth-1);const r=this.resolvedPos.doc.resolve(e);return new t(r,this.editor)}get before(){let e=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));if(e.depth!==this.depth){e=this.resolvedPos.doc.resolve(this.from-3)}return new t(e,this.editor)}get after(){let e=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));if(e.depth!==this.depth){e=this.resolvedPos.doc.resolve(this.to+3)}return new t(e,this.editor)}get children(){const e=[];this.node.content.forEach(((r,n)=>{const i=r.isBlock&&!r.isTextblock;const s=r.isAtom&&!r.isText;const o=this.pos+n+(s?0:1);if(o<0||o>this.resolvedPos.doc.nodeSize-2){return}const l=this.resolvedPos.doc.resolve(o);if(!i&&l.depth<=this.depth){return}const u=new t(l,this.editor,i,i?r:null);if(i){u.actualDepth=this.depth+1}e.push(new t(l,this.editor,i,i?r:null))}));return e}get firstChild(){return this.children[0]||null}get lastChild(){const t=this.children;return t[t.length-1]||null}closest(t,e={}){let r=null;let n=this.parent;while(n&&!r){if(n.node.type.name===t){if(Object.keys(e).length>0);else{r=n}}n=n.parent}return r}querySelector(t,e={}){return this.querySelectorAll(t,e,true)[0]||null}querySelectorAll(t,e={},r=false){let n=[];if(!this.children||this.children.length===0){return n}const i=Object.keys(e);this.children.forEach((s=>{if(r&&n.length>0){return}if(s.node.type.name===t){const t=i.every((t=>e[t]===s.node.attrs[t]));if(t){n.push(s)}}if(r&&n.length>0){return}n=n.concat(s.querySelectorAll(t,e,r))}));return n}setAttribute(t){const{tr:e}=this.editor.state;e.setNodeMarkup(this.from,void 0,{...this.node.attrs,...t});this.editor.view.dispatch(e)}};var eh=`.ProseMirror {\n position: relative;\n}\n\n.ProseMirror {\n word-wrap: break-word;\n white-space: pre-wrap;\n white-space: break-spaces;\n -webkit-font-variant-ligatures: none;\n font-variant-ligatures: none;\n font-feature-settings: "liga" 0; /* the above doesn't seem to work in Edge */\n}\n\n.ProseMirror [contenteditable="false"] {\n white-space: normal;\n}\n\n.ProseMirror [contenteditable="false"] [contenteditable="true"] {\n white-space: pre-wrap;\n}\n\n.ProseMirror pre {\n white-space: pre-wrap;\n}\n\nimg.ProseMirror-separator {\n display: inline !important;\n border: none !important;\n margin: 0 !important;\n width: 0 !important;\n height: 0 !important;\n}\n\n.ProseMirror-gapcursor {\n display: none;\n pointer-events: none;\n position: absolute;\n margin: 0;\n}\n\n.ProseMirror-gapcursor:after {\n content: "";\n display: block;\n position: absolute;\n top: -2px;\n width: 20px;\n border-top: 1px solid black;\n animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;\n}\n\n@keyframes ProseMirror-cursor-blink {\n to {\n visibility: hidden;\n }\n}\n\n.ProseMirror-hideselection *::selection {\n background: transparent;\n}\n\n.ProseMirror-hideselection *::-moz-selection {\n background: transparent;\n}\n\n.ProseMirror-hideselection * {\n caret-color: transparent;\n}\n\n.ProseMirror-focused .ProseMirror-gapcursor {\n display: block;\n}`;function rh(t,e,r){const n=document.querySelector(`style[data-tiptap-style${r?`-${r}`:""}]`);if(n!==null){return n}const i=document.createElement("style");if(e){i.setAttribute("nonce",e)}i.setAttribute(`data-tiptap-style${r?`-${r}`:""}`,"");i.innerHTML=t;document.getElementsByTagName("head")[0].appendChild(i);return i}var nh=class extends Sf{constructor(t={}){super();this.css=null;this.editorView=null;this.isFocused=false;this.isInitialized=false;this.extensionStorage={};this.instanceId=Math.random().toString(36).slice(2,9);this.options={element:typeof document!=="undefined"?document.createElement("div"):null,content:"",injectCSS:true,injectNonce:void 0,extensions:[],autofocus:false,editable:true,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:true,enablePasteRules:true,enableCoreExtensions:true,enableContentCheck:false,emitContentError:false,onBeforeCreate:()=>null,onCreate:()=>null,onMount:()=>null,onUnmount:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:t})=>{throw t},onPaste:()=>null,onDrop:()=>null,onDelete:()=>null};this.isCapturingTransaction=false;this.capturedTransaction=null;this.setOptions(t);this.createExtensionManager();this.createCommandManager();this.createSchema();this.on("beforeCreate",this.options.onBeforeCreate);this.emit("beforeCreate",{editor:this});this.on("mount",this.options.onMount);this.on("unmount",this.options.onUnmount);this.on("contentError",this.options.onContentError);this.on("create",this.options.onCreate);this.on("update",this.options.onUpdate);this.on("selectionUpdate",this.options.onSelectionUpdate);this.on("transaction",this.options.onTransaction);this.on("focus",this.options.onFocus);this.on("blur",this.options.onBlur);this.on("destroy",this.options.onDestroy);this.on("drop",(({event:t,slice:e,moved:r})=>this.options.onDrop(t,e,r)));this.on("paste",(({event:t,slice:e})=>this.options.onPaste(t,e)));this.on("delete",this.options.onDelete);const e=this.createDoc();const r=xu(e,this.options.autofocus);this.editorState=gr.create({doc:e,schema:this.schema,selection:r||void 0});if(this.options.element){this.mount(this.options.element)}}mount(t){if(typeof document==="undefined"){throw new Error(`[tiptap error]: The editor cannot be mounted because there is no 'document' defined in this environment.`)}this.createView(t);this.emit("mount",{editor:this});if(this.css&&!document.head.contains(this.css)){document.head.appendChild(this.css)}window.setTimeout((()=>{if(this.isDestroyed){return}this.commands.focus(this.options.autofocus);this.emit("create",{editor:this});this.isInitialized=true}),0)}unmount(){if(this.editorView){const t=this.editorView.dom;if(t==null?void 0:t.editor){delete t.editor}this.editorView.destroy()}this.editorView=null;this.isInitialized=false;if(this.css){try{if(typeof this.css.remove==="function"){this.css.remove()}else if(this.css.parentNode){this.css.parentNode.removeChild(this.css)}}catch(t){console.warn("Failed to remove CSS element:",t)}}this.css=null;this.emit("unmount",{editor:this})}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager.chain()}can(){return this.commandManager.can()}injectCSS(){if(this.options.injectCSS&&typeof document!=="undefined"){this.css=rh(eh,this.options.injectNonce)}}setOptions(t={}){this.options={...this.options,...t};if(!this.editorView||!this.state||this.isDestroyed){return}if(this.options.editorProps){this.view.setProps(this.options.editorProps)}this.view.updateState(this.state)}setEditable(t,e=true){this.setOptions({editable:t});if(e){this.emit("update",{editor:this,transaction:this.state.tr,appendedTransactions:[]})}}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get view(){if(this.editorView){return this.editorView}return new Proxy({state:this.editorState,updateState:t=>{this.editorState=t},dispatch:t=>{this.dispatchTransaction(t)},composing:false,dragging:null,editable:true,isDestroyed:false},{get:(t,e)=>{if(this.editorView){return this.editorView[e]}if(e==="state"){return this.editorState}if(e in t){return Reflect.get(t,e)}throw new Error(`[tiptap error]: The editor view is not available. Cannot access view['${e}']. The editor may not be mounted yet.`)}})}get state(){if(this.editorView){this.editorState=this.view.state}return this.editorState}registerPlugin(t,e){const r=ba(e)?e(t,[...this.state.plugins]):[...this.state.plugins,t];const n=this.state.reconfigure({plugins:r});this.view.updateState(n);return n}unregisterPlugin(t){if(this.isDestroyed){return void 0}const e=this.state.plugins;let r=e;[].concat(t).forEach((t=>{const e=typeof t==="string"?`${t}$`:t.key;r=r.filter((t=>!t.key.startsWith(e)))}));if(e.length===r.length){return void 0}const n=this.state.reconfigure({plugins:r});this.view.updateState(n);return n}createExtensionManager(){var t,e;const r=this.options.enableCoreExtensions?[Vf,qf.configure({blockSeparator:(e=(t=this.options.coreExtensionOptions)==null?void 0:t.clipboardTextSerializer)==null?void 0:e.blockSeparator}),Jf,Zf,Qf,Yf,Wf,Xf,Kf].filter((t=>{if(typeof this.options.enableCoreExtensions==="object"){return this.options.enableCoreExtensions[t.name]!==false}return true})):[];const n=[...r,...this.options.extensions].filter((t=>["extension","node","mark"].includes(t==null?void 0:t.type)));this.extensionManager=new Bf(n,this)}createCommandManager(){this.commandManager=new Xl({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let t;try{t=la(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(e){if(!(e instanceof Error)||!["[tiptap error]: Invalid JSON content","[tiptap error]: Invalid HTML content"].includes(e.message)){throw e}this.emit("contentError",{editor:this,error:e,disableCollaboration:()=>{if("collaboration"in this.storage&&typeof this.storage.collaboration==="object"&&this.storage.collaboration){this.storage.collaboration.isDisabled=true}this.options.extensions=this.options.extensions.filter((t=>t.name!=="collaboration"));this.createExtensionManager()}});t=la(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:false})}return t}createView(t){var e;this.editorView=new $l(t,{...this.options.editorProps,attributes:{role:"textbox",...(e=this.options.editorProps)==null?void 0:e.attributes},dispatchTransaction:this.dispatchTransaction.bind(this),state:this.editorState,markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews});const r=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(r);this.prependClass();this.injectCSS();const n=this.view.dom;n.editor=this}createNodeViews(){if(this.view.isDestroyed){return}this.view.setProps({markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`tiptap ${this.view.dom.className}`}captureTransaction(t){this.isCapturingTransaction=true;t();this.isCapturingTransaction=false;const e=this.capturedTransaction;this.capturedTransaction=null;return e}dispatchTransaction(t){if(this.view.isDestroyed){return}if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=t;return}t.steps.forEach((t=>{var e;return(e=this.capturedTransaction)==null?void 0:e.step(t)}));return}const{state:e,transactions:r}=this.state.applyTransaction(t);const n=!this.state.selection.eq(e.selection);const i=r.includes(t);const s=this.state;this.emit("beforeTransaction",{editor:this,transaction:t,nextState:e});if(!i){return}this.view.updateState(e);this.emit("transaction",{editor:this,transaction:t,appendedTransactions:r.slice(1)});if(n){this.emit("selectionUpdate",{editor:this,transaction:t})}const o=r.findLast((t=>t.getMeta("focus")||t.getMeta("blur")));const l=o==null?void 0:o.getMeta("focus");const u=o==null?void 0:o.getMeta("blur");if(l){this.emit("focus",{editor:this,event:l.event,transaction:o})}if(u){this.emit("blur",{editor:this,event:u.event,transaction:o})}if(t.getMeta("preventUpdate")||!r.some((t=>t.docChanged))||s.doc.eq(e.doc)){return}this.emit("update",{editor:this,transaction:t,appendedTransactions:r.slice(1)})}getAttributes(t){return ja(this.state,t)}isActive(t,e){const r=typeof t==="string"?t:null;const n=typeof t==="string"?e:t;return Va(this.state,r,n)}getJSON(){return this.state.doc.toJSON()}getHTML(){return wa(this.state.doc.content,this.schema)}getText(t){const{blockSeparator:e="\n\n",textSerializers:r={}}=t||{};return Ia(this.state.doc,{blockSeparator:e,textSerializers:{...Da(this.schema),...r}})}get isEmpty(){return Ya(this.state.doc)}destroy(){this.emit("destroy");this.unmount();this.removeAllListeners()}get isDestroyed(){var t,e;return(e=(t=this.editorView)==null?void 0:t.isDestroyed)!=null?e:true}$node(t,e){var r;return((r=this.$doc)==null?void 0:r.querySelector(t,e))||null}$nodes(t,e){var r;return((r=this.$doc)==null?void 0:r.querySelectorAll(t,e))||null}$pos(t){const e=this.state.doc.resolve(t);return new th(e,this)}get $doc(){return this.$pos(0)}};function ih(t){return new Tf({find:t.find,handler:({state:e,range:r,match:n})=>{const i=ka(t.getAttributes,void 0,n);if(i===false||i===null){return null}const{tr:s}=e;const o=n[n.length-1];const l=n[0];if(o){const n=l.search(/\S/);const u=r.from+l.indexOf(o);const a=u+o.length;const f=Fa(r.from,r.to,e.doc).filter((e=>{const r=e.mark.type.excluded;return r.find((r=>r===t.type&&r!==e.mark.type))})).filter((t=>t.to>u));if(f.length){return null}if(a<r.to){s.delete(a,r.to)}if(u>r.from){s.delete(r.from+n,u)}const h=r.from+n+o.length;s.addMark(r.from+n,h,t.type.create(i||{}));s.removeStoredMark(t.type)}},undoable:t.undoable})}function sh(t){return new Tf({find:t.find,handler:({state:e,range:r,match:n})=>{const i=ka(t.getAttributes,void 0,n)||{};const{tr:s}=e;const o=r.from;let l=r.to;const u=t.type.create(i);if(n[1]){const t=n[0].lastIndexOf(n[1]);let e=o+t;if(e>l){e=l}else{l=e+n[1].length}const r=n[0][n[0].length-1];s.insertText(r,o+n[0].length-1);s.replaceWith(e,l,u)}else if(n[0]){const e=t.type.isInline?o:o-1;s.insert(e,t.type.create(i)).delete(s.mapping.map(o),s.mapping.map(l))}s.scrollIntoView()},undoable:t.undoable})}function oh(t){return new Tf({find:t.find,handler:({state:e,range:r,match:n})=>{const i=e.doc.resolve(r.from);const s=ka(t.getAttributes,void 0,n)||{};if(!i.node(-1).canReplaceWith(i.index(-1),i.indexAfter(-1),t.type)){return null}e.tr.delete(r.from,r.to).setBlockType(r.from,r.from,t.type,s)},undoable:t.undoable})}function lh(t){return new Tf({find:t.find,handler:({state:e,range:r,match:n,chain:i})=>{const s=ka(t.getAttributes,void 0,n)||{};const o=e.tr.delete(r.from,r.to);const l=o.doc.resolve(r.from);const u=l.blockRange();const a=u&&he(u,t.type,s);if(!a){return null}o.wrap(u,a);if(t.keepMarks&&t.editor){const{selection:r,storedMarks:n}=e;const{splittableMarks:i}=t.editor.extensionManager;const s=n||r.$to.parentOffset&&r.$from.marks();if(s){const t=s.filter((t=>i.includes(t.type.name)));o.ensureMarks(t)}}if(t.keepAttributes){const e=t.type.name==="bulletList"||t.type.name==="orderedList"?"listItem":"taskList";i().updateAttributes(e,s).run()}const f=o.doc.resolve(r.from-1).nodeBefore;if(f&&f.type===t.type&&xe(o.doc,r.from-1)&&(!t.joinPredicate||t.joinPredicate(n,f))){o.join(r.from-1)}},undoable:t.undoable})}function uh(t,e){const{selection:r}=t;const{$from:n}=r;if(r instanceof rr){const t=n.index();const r=n.parent;return r.canReplaceWith(t,t+1,e)}let i=n.depth;while(i>=0){const t=n.index(i);const r=n.node(i);const s=r.contentMatchAt(t);if(s.matchType(e)){return true}i-=1}return false}var ah={};Zl(ah,{createAtomBlockMarkdownSpec:()=>ch,createBlockMarkdownSpec:()=>dh,createInlineMarkdownSpec:()=>gh,parseAttributes:()=>fh,parseIndentedBlocks:()=>wh,renderNestedMarkdownContent:()=>bh,serializeAttributes:()=>hh});function fh(t){if(!(t==null?void 0:t.trim())){return{}}const e={};const r=[];const n=t.replace(/["']([^"']*)["']/g,(t=>{r.push(t);return`__QUOTED_${r.length-1}__`}));const i=n.match(/(?:^|\s)\.([a-zA-Z][\w-]*)/g);if(i){const t=i.map((t=>t.trim().slice(1)));e.class=t.join(" ")}const s=n.match(/(?:^|\s)#([a-zA-Z][\w-]*)/);if(s){e.id=s[1]}const o=/([a-zA-Z][\w-]*)\s*=\s*(__QUOTED_\d+__)/g;const l=Array.from(n.matchAll(o));l.forEach((([,t,n])=>{var i;const s=parseInt(((i=n.match(/__QUOTED_(\d+)__/))==null?void 0:i[1])||"0",10);const o=r[s];if(o){e[t]=o.slice(1,-1)}}));const u=n.replace(/(?:^|\s)\.([a-zA-Z][\w-]*)/g,"").replace(/(?:^|\s)#([a-zA-Z][\w-]*)/g,"").replace(/([a-zA-Z][\w-]*)\s*=\s*__QUOTED_\d+__/g,"").trim();if(u){const t=u.split(/\s+/).filter(Boolean);t.forEach((t=>{if(t.match(/^[a-zA-Z][\w-]*$/)){e[t]=true}}))}return e}function hh(t){if(!t||Object.keys(t).length===0){return""}const e=[];if(t.class){const r=String(t.class).split(/\s+/).filter(Boolean);r.forEach((t=>e.push(`.${t}`)))}if(t.id){e.push(`#${t.id}`)}Object.entries(t).forEach((([t,r])=>{if(t==="class"||t==="id"){return}if(r===true){e.push(t)}else if(r!==false&&r!=null){e.push(`${t}="${String(r)}"`)}}));return e.join(" ")}function ch(t){const{nodeName:e,name:r,parseAttributes:n=fh,serializeAttributes:i=hh,defaultAttributes:s={},requiredAttributes:o=[],allowedAttributes:l}=t;const u=r||e;const a=t=>{if(!l){return t}const e={};l.forEach((r=>{if(r in t){e[r]=t[r]}}));return e};return{parseMarkdown:(t,r)=>{const n={...s,...t.attributes};return r.createNode(e,n,[])},markdownTokenizer:{name:e,level:"block",start(t){var e;const r=new RegExp(`^:::${u}(?:\\s|$)`,"m");const n=(e=t.match(r))==null?void 0:e.index;return n!==void 0?n:-1},tokenize(t,r,i){const s=new RegExp(`^:::${u}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`);const l=t.match(s);if(!l){return void 0}const a=l[1]||"";const f=n(a);const h=o.find((t=>!(t in f)));if(h){return void 0}return{type:e,raw:l[0],attributes:f}}},renderMarkdown:t=>{const e=a(t.attrs||{});const r=i(e);const n=r?` {${r}}`:"";return`:::${u}${n} :::`}}}function dh(t){const{nodeName:e,name:r,getContent:n,parseAttributes:i=fh,serializeAttributes:s=hh,defaultAttributes:o={},content:l="block",allowedAttributes:u}=t;const a=r||e;const f=t=>{if(!u){return t}const e={};u.forEach((r=>{if(r in t){e[r]=t[r]}}));return e};return{parseMarkdown:(t,r)=>{let i;if(n){const e=n(t);i=typeof e==="string"?[{type:"text",text:e}]:e}else if(l==="block"){i=r.parseChildren(t.tokens||[])}else{i=r.parseInline(t.tokens||[])}const s={...o,...t.attributes};return r.createNode(e,s,i)},markdownTokenizer:{name:e,level:"block",start(t){var e;const r=new RegExp(`^:::${a}`,"m");const n=(e=t.match(r))==null?void 0:e.index;return n!==void 0?n:-1},tokenize(t,r,n){var s;const o=new RegExp(`^:::${a}(?:\\s+\\{([^}]*)\\})?\\s*\\n`);const u=t.match(o);if(!u){return void 0}const[f,h=""]=u;const c=i(h);let d=1;const p=f.length;let m="";const g=/^:::([\w-]*)(\s.*)?/gm;const w=t.slice(p);g.lastIndex=0;for(;;){const r=g.exec(w);if(r===null){break}const i=r.index;const o=r[1];if((s=r[2])==null?void 0:s.endsWith(":::")){continue}if(o){d+=1}else{d-=1;if(d===0){const s=w.slice(0,i);m=s.trim();const o=t.slice(0,p+i+r[0].length);let u=[];if(m){if(l==="block"){u=n.blockTokens(s);u.forEach((t=>{if(t.text&&(!t.tokens||t.tokens.length===0)){t.tokens=n.inlineTokens(t.text)}}));while(u.length>0){const t=u[u.length-1];if(t.type==="paragraph"&&(!t.text||t.text.trim()==="")){u.pop()}else{break}}}else{u=n.inlineTokens(m)}}return{type:e,raw:o,attributes:c,content:m,tokens:u}}}}return void 0}},renderMarkdown:(t,e)=>{const r=f(t.attrs||{});const n=s(r);const i=n?` {${n}}`:"";const o=e.renderChildren(t.content||[],"\n\n");return`:::${a}${i}\n\n${o}\n\n:::`}}}function ph(t){if(!t.trim()){return{}}const e={};const r=/(\w+)=(?:"([^"]*)"|'([^']*)')/g;let n=r.exec(t);while(n!==null){const[,i,s,o]=n;e[i]=s||o;n=r.exec(t)}return e}function mh(t){return Object.entries(t).filter((([,t])=>t!==void 0&&t!==null)).map((([t,e])=>`${t}="${e}"`)).join(" ")}function gh(t){const{nodeName:e,name:r,getContent:n,parseAttributes:i=ph,serializeAttributes:s=mh,defaultAttributes:o={},selfClosing:l=false,allowedAttributes:u}=t;const a=r||e;const f=t=>{if(!u){return t}const e={};u.forEach((r=>{if(r in t){e[r]=t[r]}}));return e};const h=a.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return{parseMarkdown:(t,r)=>{const i={...o,...t.attributes};if(l){return r.createNode(e,i)}const s=n?n(t):t.content||"";if(s){return r.createNode(e,i,[r.createTextNode(s)])}return r.createNode(e,i,[])},markdownTokenizer:{name:e,level:"inline",start(t){const e=l?new RegExp(`\\[${h}\\s*[^\\]]*\\]`):new RegExp(`\\[${h}\\s*[^\\]]*\\][\\s\\S]*?\\[\\/${h}\\]`);const r=t.match(e);const n=r==null?void 0:r.index;return n!==void 0?n:-1},tokenize(t,r,n){const s=l?new RegExp(`^\\[${h}\\s*([^\\]]*)\\]`):new RegExp(`^\\[${h}\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/${h}\\]`);const o=t.match(s);if(!o){return void 0}let u="";let a="";if(l){const[,t]=o;a=t}else{const[,t,e]=o;a=t;u=e||""}const f=i(a.trim());return{type:e,raw:o[0],content:u.trim(),attributes:f}}},renderMarkdown:t=>{let e="";if(n){e=n(t)}else if(t.content&&t.content.length>0){e=t.content.filter((t=>t.type==="text")).map((t=>t.text)).join("")}const r=f(t.attrs||{});const i=s(r);const o=i?` ${i}`:"";if(l){return`[${a}${o}]`}return`[${a}${o}]${e}[/${a}]`}}}function wh(t,e,r){var n,i,s,o;const l=t.split("\n");const u=[];let a="";let f=0;const h=e.baseIndentSize||2;while(f<l.length){const t=l[f];const c=t.match(e.itemPattern);if(!c){if(u.length>0){break}else if(t.trim()===""){f+=1;continue}else{return void 0}}const d=e.extractItemData(c);const{indentLevel:p,mainContent:m}=d;a=`${a}${t}\n`;const g=[m];f+=1;while(f<l.length){const t=l[f];if(t.trim()===""){const e=l.slice(f+1).findIndex((t=>t.trim()!==""));if(e===-1){break}const r=l[f+1+e];const s=((i=(n=r.match(/^(\s*)/))==null?void 0:n[1])==null?void 0:i.length)||0;if(s>p){g.push(t);a=`${a}${t}\n`;f+=1;continue}else{break}}const e=((o=(s=t.match(/^(\s*)/))==null?void 0:s[1])==null?void 0:o.length)||0;if(e>p){g.push(t);a=`${a}${t}\n`;f+=1}else{break}}let w;const b=g.slice(1);if(b.length>0){const t=b.map((t=>t.slice(p+h))).join("\n");if(t.trim()){if(e.customNestedParser){w=e.customNestedParser(t)}else{w=r.blockTokens(t)}}}const k=e.createToken(d,w);u.push(k)}if(u.length===0){return void 0}return{items:u,raw:a.trim()}}function bh(t,e,r,n){if(!t||!Array.isArray(t.content)){return""}const i=typeof r==="function"?r(n):r;const[s,...o]=t.content;const l=e.renderChildren([s]);const u=[`${i}${l}`];if(o&&o.length>0){o.forEach((t=>{const r=e.renderChildren([t]);if(r){const t=r.split("\n").map((t=>t?e.indent(t):"")).join("\n");u.push(t)}}))}return u.join("\n")}function kh(t,e,r={}){const{state:n}=e;const{doc:i,tr:s}=n;const o=t;i.descendants(((e,n)=>{const i=s.mapping.map(n);const l=s.mapping.map(n)+e.nodeSize;let u=null;e.marks.forEach((t=>{if(t!==o){return false}u=t}));if(!u){return}let a=false;Object.keys(r).forEach((t=>{if(r[t]!==u.attrs[t]){a=true}}));if(a){const e=t.type.create({...t.attrs,...r});s.removeMark(i,l,t.type);s.addMark(i,l,e)}}));if(s.docChanged){e.view.dispatch(s)}}var vh=class t extends Lf{constructor(){super(...arguments);this.type="node"}static create(e={}){const r=typeof e==="function"?e():e;return new t(r)}configure(t){return super.configure(t)}extend(t){const e=typeof t==="function"?t():t;return super.extend(e)}};function yh(t){return new If({find:t.find,handler:({state:e,range:r,match:n,pasteEvent:i})=>{const s=ka(t.getAttributes,void 0,n,i);if(s===false||s===null){return null}const{tr:o}=e;const l=n[n.length-1];const u=n[0];let a=r.to;if(l){const n=u.search(/\S/);const i=r.from+u.indexOf(l);const f=i+l.length;const h=Fa(r.from,r.to,e.doc).filter((e=>{const r=e.mark.type.excluded;return r.find((r=>r===t.type&&r!==e.mark.type))})).filter((t=>t.to>i));if(h.length){return null}if(f<r.to){o.delete(f,r.to)}if(i>r.from){o.delete(r.from+n,i)}a=r.from+n+l.length;o.addMark(r.from+n,a,t.type.create(s||{}));o.removeStoredMark(t.type)}}})}var Mh=typeof globalThis!=="undefined"?globalThis:typeof window!=="undefined"?window:typeof global!=="undefined"?global:typeof self!=="undefined"?self:{};var xh={exports:{}};(function(t,e){(function(e,r){{t.exports=r()}})(typeof globalThis<"u"?globalThis:typeof self<"u"?self:Mh,(function(){var t={};var e=t;var r={exports:t};var n=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var s=Object.getOwnPropertyNames;var o=Object.prototype.hasOwnProperty;var l=(t,e)=>{for(var r in e)n(t,r,{get:e[r],enumerable:!0})},u=(t,e,r,l)=>{if(e&&typeof e=="object"||typeof e=="function")for(let u of s(e))!o.call(t,u)&&u!==r&&n(t,u,{get:()=>e[u],enumerable:!(l=i(e,u))||l.enumerable});return t};var a=t=>u(n({},"__esModule",{value:!0}),t);var f={};l(f,{Hooks:()=>It,Lexer:()=>Ct,Marked:()=>Dt,Parser:()=>Pt,Renderer:()=>Lt,TextRenderer:()=>Nt,Tokenizer:()=>Rt,defaults:()=>c,getDefaults:()=>h,lexer:()=>Kt,marked:()=>jt,options:()=>_t,parse:()=>qt,parseInline:()=>Ut,parser:()=>Jt,setOptions:()=>zt,use:()=>Bt,walkTokens:()=>Ft});r.exports=a(f);function h(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var c=h();function d(t){c=t}var p={exec:()=>null};function m(t,e=""){let r=typeof t=="string"?t:t.source,n={replace:(t,e)=>{let i=typeof e=="string"?e:e.source;return i=i.replace(g.caret,"$1"),r=r.replace(t,i),n},getRegex:()=>new RegExp(r,e)};return n}var g={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceTabs:/^\t+/,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] /,listReplaceTask:/^\[[ xX]\] +/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/gi,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:t=>new RegExp(`^( {0,3}${t})((?:[\t ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ \t][^\\n]*)?(?:\\n|$))`),hrRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}#`),htmlBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}<(?:[a-z].*>|!--)`,"i")},w=/^(?:[ \t]*(?:\n|$))+/,b=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,k=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,v=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,y=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,M=/(?:[*+-]|\d{1,9}[.)])/,x=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,S=m(x).replace(/bull/g,M).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),T=m(x).replace(/bull/g,M).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),E=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,$=/^[^\n]+/,A=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,O=m(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",A).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),R=m(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,M).getRegex(),C="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|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",L=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,N=m("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$))","i").replace("comment",L).replace("tag",C).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),P=m(E).replace("hr",v).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",C).getRegex(),I=m(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",P).getRegex(),D={blockquote:I,code:b,def:O,fences:k,heading:y,hr:v,html:N,lheading:S,list:R,newline:w,paragraph:P,table:p,text:$},H=m("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",v).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3}\t)[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",C).getRegex(),j={...D,lheading:T,table:H,paragraph:m(E).replace("hr",v).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",H).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",C).getRegex()},_={...D,html:m(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",L).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:p,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:m(E).replace("hr",v).replace("heading",` *#{1,6} *[^\n]`).replace("lheading",S).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},z=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,B=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,F=/^( {2,}|\\)\n(?!\s*$)/,U=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,q=/[\p{P}\p{S}]/u,J=/[\s\p{P}\p{S}]/u,K=/[^\s\p{P}\p{S}]/u,W=m(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,J).getRegex(),V=/(?!~)[\p{P}\p{S}]/u,G=/(?!~)[\s\p{P}\p{S}]/u,Z=/(?:[^\s\p{P}\p{S}]|~)/u,Q=/\[(?:[^\[\]`]|`[^`]*?`)*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)|`[^`]*?`|<(?! )[^<>]*?>/g,X=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,Y=m(X,"u").replace(/punct/g,q).getRegex(),tt=m(X,"u").replace(/punct/g,V).getRegex(),et="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",rt=m(et,"gu").replace(/notPunctSpace/g,K).replace(/punctSpace/g,J).replace(/punct/g,q).getRegex(),nt=m(et,"gu").replace(/notPunctSpace/g,Z).replace(/punctSpace/g,G).replace(/punct/g,V).getRegex(),it=m("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,K).replace(/punctSpace/g,J).replace(/punct/g,q).getRegex(),st=m(/\\(punct)/,"gu").replace(/punct/g,q).getRegex(),ot=m(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[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])?)+(?![-_])/).getRegex(),lt=m(L).replace("(?:--\x3e|$)","--\x3e").getRegex(),ut=m("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",lt).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),at=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,ft=m(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",at).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),ht=m(/^!?\[(label)\]\[(ref)\]/).replace("label",at).replace("ref",A).getRegex(),ct=m(/^!?\[(ref)\](?:\[\])?/).replace("ref",A).getRegex(),dt=m("reflink|nolink(?!\\()","g").replace("reflink",ht).replace("nolink",ct).getRegex(),pt=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,mt={_backpedal:p,anyPunctuation:st,autolink:ot,blockSkip:Q,br:F,code:B,del:p,emStrongLDelim:Y,emStrongRDelimAst:rt,emStrongRDelimUnd:it,escape:z,link:ft,nolink:ct,punctuation:W,reflink:ht,reflinkSearch:dt,tag:ut,text:U,url:p},gt={...mt,link:m(/^!?\[(label)\]\((.*?)\)/).replace("label",at).getRegex(),reflink:m(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",at).getRegex()},wt={...mt,emStrongRDelimAst:nt,emStrongLDelim:tt,url:m(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",pt).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:m(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",pt).getRegex()},bt={...wt,br:m(F).replace("{2,}","*").getRegex(),text:m(wt.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},kt={normal:D,gfm:j,pedantic:_},vt={normal:mt,gfm:wt,breaks:bt,pedantic:gt};var yt={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},Mt=t=>yt[t];function xt(t,e){if(e){if(g.escapeTest.test(t))return t.replace(g.escapeReplace,Mt)}else if(g.escapeTestNoEncode.test(t))return t.replace(g.escapeReplaceNoEncode,Mt);return t}function St(t){try{t=encodeURI(t).replace(g.percentDecode,"%")}catch{return null}return t}function Tt(t,e){let r=t.replace(g.findPipe,((t,e,r)=>{let n=!1,i=e;for(;--i>=0&&r[i]==="\\";)n=!n;return n?"|":" |"})),n=r.split(g.splitPipe),i=0;if(n[0].trim()||n.shift(),n.length>0&&!n.at(-1)?.trim()&&n.pop(),e)if(n.length>e)n.splice(e);else for(;n.length<e;)n.push("");for(;i<n.length;i++)n[i]=n[i].trim().replace(g.slashPipe,"|");return n}function Et(t,e,r){let n=t.length;if(n===0)return"";let i=0;for(;i<n;){let s=t.charAt(n-i-1);if(s===e&&!r)i++;else if(s!==e&&r)i++;else break}return t.slice(0,n-i)}function $t(t,e){if(t.indexOf(e[1])===-1)return-1;let r=0;for(let n=0;n<t.length;n++)if(t[n]==="\\")n++;else if(t[n]===e[0])r++;else if(t[n]===e[1]&&(r--,r<0))return n;return r>0?-2:-1}function At(t,e,r,n,i){let s=e.href,o=e.title||null,l=t[1].replace(i.other.outputLinkReplace,"$1");n.state.inLink=!0;let u={type:t[0].charAt(0)==="!"?"image":"link",raw:r,href:s,title:o,text:l,tokens:n.inlineTokens(l)};return n.state.inLink=!1,u}function Ot(t,e,r){let n=t.match(r.other.indentCodeCompensation);if(n===null)return e;let i=n[1];return e.split(`\n`).map((t=>{let e=t.match(r.other.beginningSpace);if(e===null)return t;let[n]=e;return n.length>=i.length?t.slice(i.length):t})).join(`\n`)}var Rt=class{options;rules;lexer;constructor(t){this.options=t||c}space(t){let e=this.rules.block.newline.exec(t);if(e&&e[0].length>0)return{type:"space",raw:e[0]}}code(t){let e=this.rules.block.code.exec(t);if(e){let t=e[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:e[0],codeBlockStyle:"indented",text:this.options.pedantic?t:Et(t,`\n`)}}}fences(t){let e=this.rules.block.fences.exec(t);if(e){let t=e[0],r=Ot(t,e[3]||"",this.rules);return{type:"code",raw:t,lang:e[2]?e[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):e[2],text:r}}}heading(t){let e=this.rules.block.heading.exec(t);if(e){let t=e[2].trim();if(this.rules.other.endingHash.test(t)){let e=Et(t,"#");(this.options.pedantic||!e||this.rules.other.endingSpaceChar.test(e))&&(t=e.trim())}return{type:"heading",raw:e[0],depth:e[1].length,text:t,tokens:this.lexer.inline(t)}}}hr(t){let e=this.rules.block.hr.exec(t);if(e)return{type:"hr",raw:Et(e[0],`\n`)}}blockquote(t){let e=this.rules.block.blockquote.exec(t);if(e){let t=Et(e[0],`\n`).split(`\n`),r="",n="",i=[];for(;t.length>0;){let e=!1,s=[],o;for(o=0;o<t.length;o++)if(this.rules.other.blockquoteStart.test(t[o]))s.push(t[o]),e=!0;else if(!e)s.push(t[o]);else break;t=t.slice(o);let l=s.join(`\n`),u=l.replace(this.rules.other.blockquoteSetextReplace,`\n $1`).replace(this.rules.other.blockquoteSetextReplace2,"");r=r?`${r}\n${l}`:l,n=n?`${n}\n${u}`:u;let a=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(u,i,!0),this.lexer.state.top=a,t.length===0)break;let f=i.at(-1);if(f?.type==="code")break;if(f?.type==="blockquote"){let e=f,s=e.raw+`\n`+t.join(`\n`),o=this.blockquote(s);i[i.length-1]=o,r=r.substring(0,r.length-e.raw.length)+o.raw,n=n.substring(0,n.length-e.text.length)+o.text;break}else if(f?.type==="list"){let e=f,s=e.raw+`\n`+t.join(`\n`),o=this.list(s);i[i.length-1]=o,r=r.substring(0,r.length-f.raw.length)+o.raw,n=n.substring(0,n.length-e.raw.length)+o.raw,t=s.substring(i.at(-1).raw.length).split(`\n`);continue}}return{type:"blockquote",raw:r,tokens:i,text:n}}}list(t){let e=this.rules.block.list.exec(t);if(e){let r=e[1].trim(),n=r.length>1,i={type:"list",raw:"",ordered:n,start:n?+r.slice(0,-1):"",loose:!1,items:[]};r=n?`\\d{1,9}\\${r.slice(-1)}`:`\\${r}`,this.options.pedantic&&(r=n?r:"[*+-]");let s=this.rules.other.listItemRegex(r),o=!1;for(;t;){let r=!1,n="",l="";if(!(e=s.exec(t))||this.rules.block.hr.test(t))break;n=e[0],t=t.substring(n.length);let u=e[2].split(`\n`,1)[0].replace(this.rules.other.listReplaceTabs,(t=>" ".repeat(3*t.length))),a=t.split(`\n`,1)[0],f=!u.trim(),h=0;if(this.options.pedantic?(h=2,l=u.trimStart()):f?h=e[1].length+1:(h=e[2].search(this.rules.other.nonSpaceChar),h=h>4?1:h,l=u.slice(h),h+=e[1].length),f&&this.rules.other.blankLine.test(a)&&(n+=a+`\n`,t=t.substring(a.length+1),r=!0),!r){let e=this.rules.other.nextBulletRegex(h),r=this.rules.other.hrRegex(h),i=this.rules.other.fencesBeginRegex(h),s=this.rules.other.headingBeginRegex(h),o=this.rules.other.htmlBeginRegex(h);for(;t;){let c=t.split(`\n`,1)[0],d;if(a=c,this.options.pedantic?(a=a.replace(this.rules.other.listReplaceNesting," "),d=a):d=a.replace(this.rules.other.tabCharGlobal," "),i.test(a)||s.test(a)||o.test(a)||e.test(a)||r.test(a))break;if(d.search(this.rules.other.nonSpaceChar)>=h||!a.trim())l+=`\n`+d.slice(h);else{if(f||u.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||i.test(u)||s.test(u)||r.test(u))break;l+=`\n`+a}!f&&!a.trim()&&(f=!0),n+=c+`\n`,t=t.substring(c.length+1),u=d.slice(h)}}i.loose||(o?i.loose=!0:this.rules.other.doubleBlankLine.test(n)&&(o=!0));let c=null,d;this.options.gfm&&(c=this.rules.other.listIsTask.exec(l),c&&(d=c[0]!=="[ ] ",l=l.replace(this.rules.other.listReplaceTask,""))),i.items.push({type:"list_item",raw:n,task:!!c,checked:d,loose:!1,text:l,tokens:[]}),i.raw+=n}let l=i.items.at(-1);if(l)l.raw=l.raw.trimEnd(),l.text=l.text.trimEnd();else return;i.raw=i.raw.trimEnd();for(let t=0;t<i.items.length;t++)if(this.lexer.state.top=!1,i.items[t].tokens=this.lexer.blockTokens(i.items[t].text,[]),!i.loose){let e=i.items[t].tokens.filter((t=>t.type==="space")),r=e.length>0&&e.some((t=>this.rules.other.anyLine.test(t.raw)));i.loose=r}if(i.loose)for(let t=0;t<i.items.length;t++)i.items[t].loose=!0;return i}}html(t){let e=this.rules.block.html.exec(t);if(e)return{type:"html",block:!0,raw:e[0],pre:e[1]==="pre"||e[1]==="script"||e[1]==="style",text:e[0]}}def(t){let e=this.rules.block.def.exec(t);if(e){let t=e[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),r=e[2]?e[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",n=e[3]?e[3].substring(1,e[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):e[3];return{type:"def",tag:t,raw:e[0],href:r,title:n}}}table(t){let e=this.rules.block.table.exec(t);if(!e||!this.rules.other.tableDelimiter.test(e[2]))return;let r=Tt(e[1]),n=e[2].replace(this.rules.other.tableAlignChars,"").split("|"),i=e[3]?.trim()?e[3].replace(this.rules.other.tableRowBlankLine,"").split(`\n`):[],s={type:"table",raw:e[0],header:[],align:[],rows:[]};if(r.length===n.length){for(let t of n)this.rules.other.tableAlignRight.test(t)?s.align.push("right"):this.rules.other.tableAlignCenter.test(t)?s.align.push("center"):this.rules.other.tableAlignLeft.test(t)?s.align.push("left"):s.align.push(null);for(let t=0;t<r.length;t++)s.header.push({text:r[t],tokens:this.lexer.inline(r[t]),header:!0,align:s.align[t]});for(let t of i)s.rows.push(Tt(t,s.header.length).map(((t,e)=>({text:t,tokens:this.lexer.inline(t),header:!1,align:s.align[e]}))));return s}}lheading(t){let e=this.rules.block.lheading.exec(t);if(e)return{type:"heading",raw:e[0],depth:e[2].charAt(0)==="="?1:2,text:e[1],tokens:this.lexer.inline(e[1])}}paragraph(t){let e=this.rules.block.paragraph.exec(t);if(e){let t=e[1].charAt(e[1].length-1)===`\n`?e[1].slice(0,-1):e[1];return{type:"paragraph",raw:e[0],text:t,tokens:this.lexer.inline(t)}}}text(t){let e=this.rules.block.text.exec(t);if(e)return{type:"text",raw:e[0],text:e[0],tokens:this.lexer.inline(e[0])}}escape(t){let e=this.rules.inline.escape.exec(t);if(e)return{type:"escape",raw:e[0],text:e[1]}}tag(t){let e=this.rules.inline.tag.exec(t);if(e)return!this.lexer.state.inLink&&this.rules.other.startATag.test(e[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(e[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(e[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(e[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:e[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:e[0]}}link(t){let e=this.rules.inline.link.exec(t);if(e){let t=e[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(t)){if(!this.rules.other.endAngleBracket.test(t))return;let e=Et(t.slice(0,-1),"\\");if((t.length-e.length)%2===0)return}else{let t=$t(e[2],"()");if(t===-2)return;if(t>-1){let r=(e[0].indexOf("!")===0?5:4)+e[1].length+t;e[2]=e[2].substring(0,t),e[0]=e[0].substring(0,r).trim(),e[3]=""}}let r=e[2],n="";if(this.options.pedantic){let t=this.rules.other.pedanticHrefTitle.exec(r);t&&(r=t[1],n=t[3])}else n=e[3]?e[3].slice(1,-1):"";return r=r.trim(),this.rules.other.startAngleBracket.test(r)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(t)?r=r.slice(1):r=r.slice(1,-1)),At(e,{href:r&&r.replace(this.rules.inline.anyPunctuation,"$1"),title:n&&n.replace(this.rules.inline.anyPunctuation,"$1")},e[0],this.lexer,this.rules)}}reflink(t,e){let r;if((r=this.rules.inline.reflink.exec(t))||(r=this.rules.inline.nolink.exec(t))){let t=(r[2]||r[1]).replace(this.rules.other.multipleSpaceGlobal," "),n=e[t.toLowerCase()];if(!n){let t=r[0].charAt(0);return{type:"text",raw:t,text:t}}return At(r,n,r[0],this.lexer,this.rules)}}emStrong(t,e,r=""){let n=this.rules.inline.emStrongLDelim.exec(t);if(!n||n[3]&&r.match(this.rules.other.unicodeAlphaNumeric))return;if(!(n[1]||n[2]||"")||!r||this.rules.inline.punctuation.exec(r)){let r=[...n[0]].length-1,i,s,o=r,l=0,u=n[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(u.lastIndex=0,e=e.slice(-1*t.length+r);(n=u.exec(e))!=null;){if(i=n[1]||n[2]||n[3]||n[4]||n[5]||n[6],!i)continue;if(s=[...i].length,n[3]||n[4]){o+=s;continue}else if((n[5]||n[6])&&r%3&&!((r+s)%3)){l+=s;continue}if(o-=s,o>0)continue;s=Math.min(s,s+o+l);let e=[...n[0]][0].length,u=t.slice(0,r+n.index+e+s);if(Math.min(r,s)%2){let t=u.slice(1,-1);return{type:"em",raw:u,text:t,tokens:this.lexer.inlineTokens(t)}}let a=u.slice(2,-2);return{type:"strong",raw:u,text:a,tokens:this.lexer.inlineTokens(a)}}}}codespan(t){let e=this.rules.inline.code.exec(t);if(e){let t=e[2].replace(this.rules.other.newLineCharGlobal," "),r=this.rules.other.nonSpaceChar.test(t),n=this.rules.other.startingSpaceChar.test(t)&&this.rules.other.endingSpaceChar.test(t);return r&&n&&(t=t.substring(1,t.length-1)),{type:"codespan",raw:e[0],text:t}}}br(t){let e=this.rules.inline.br.exec(t);if(e)return{type:"br",raw:e[0]}}del(t){let e=this.rules.inline.del.exec(t);if(e)return{type:"del",raw:e[0],text:e[2],tokens:this.lexer.inlineTokens(e[2])}}autolink(t){let e=this.rules.inline.autolink.exec(t);if(e){let t,r;return e[2]==="@"?(t=e[1],r="mailto:"+t):(t=e[1],r=t),{type:"link",raw:e[0],text:t,href:r,tokens:[{type:"text",raw:t,text:t}]}}}url(t){let e;if(e=this.rules.inline.url.exec(t)){let t,r;if(e[2]==="@")t=e[0],r="mailto:"+t;else{let n;do{n=e[0],e[0]=this.rules.inline._backpedal.exec(e[0])?.[0]??""}while(n!==e[0]);t=e[0],e[1]==="www."?r="http://"+e[0]:r=e[0]}return{type:"link",raw:e[0],text:t,href:r,tokens:[{type:"text",raw:t,text:t}]}}}inlineText(t){let e=this.rules.inline.text.exec(t);if(e){let t=this.lexer.state.inRawBlock;return{type:"text",raw:e[0],text:e[0],escaped:t}}}};var Ct=class t{tokens;options;state;tokenizer;inlineQueue;constructor(t){this.tokens=[],this.tokens.links=Object.create(null),this.options=t||c,this.options.tokenizer=this.options.tokenizer||new Rt,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let e={other:g,block:kt.normal,inline:vt.normal};this.options.pedantic?(e.block=kt.pedantic,e.inline=vt.pedantic):this.options.gfm&&(e.block=kt.gfm,this.options.breaks?e.inline=vt.breaks:e.inline=vt.gfm),this.tokenizer.rules=e}static get rules(){return{block:kt,inline:vt}}static lex(e,r){return new t(r).lex(e)}static lexInline(e,r){return new t(r).inlineTokens(e)}lex(t){t=t.replace(g.carriageReturn,`\n`),this.blockTokens(t,this.tokens);for(let t=0;t<this.inlineQueue.length;t++){let e=this.inlineQueue[t];this.inlineTokens(e.src,e.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(t,e=[],r=!1){for(this.options.pedantic&&(t=t.replace(g.tabCharGlobal," ").replace(g.spaceLine,""));t;){let n;if(this.options.extensions?.block?.some((r=>(n=r.call({lexer:this},t,e))?(t=t.substring(n.raw.length),e.push(n),!0):!1)))continue;if(n=this.tokenizer.space(t)){t=t.substring(n.raw.length);let r=e.at(-1);n.raw.length===1&&r!==void 0?r.raw+=`\n`:e.push(n);continue}if(n=this.tokenizer.code(t)){t=t.substring(n.raw.length);let r=e.at(-1);r?.type==="paragraph"||r?.type==="text"?(r.raw+=(r.raw.endsWith(`\n`)?"":`\n`)+n.raw,r.text+=`\n`+n.text,this.inlineQueue.at(-1).src=r.text):e.push(n);continue}if(n=this.tokenizer.fences(t)){t=t.substring(n.raw.length),e.push(n);continue}if(n=this.tokenizer.heading(t)){t=t.substring(n.raw.length),e.push(n);continue}if(n=this.tokenizer.hr(t)){t=t.substring(n.raw.length),e.push(n);continue}if(n=this.tokenizer.blockquote(t)){t=t.substring(n.raw.length),e.push(n);continue}if(n=this.tokenizer.list(t)){t=t.substring(n.raw.length),e.push(n);continue}if(n=this.tokenizer.html(t)){t=t.substring(n.raw.length),e.push(n);continue}if(n=this.tokenizer.def(t)){t=t.substring(n.raw.length);let r=e.at(-1);r?.type==="paragraph"||r?.type==="text"?(r.raw+=(r.raw.endsWith(`\n`)?"":`\n`)+n.raw,r.text+=`\n`+n.raw,this.inlineQueue.at(-1).src=r.text):this.tokens.links[n.tag]||(this.tokens.links[n.tag]={href:n.href,title:n.title},e.push(n));continue}if(n=this.tokenizer.table(t)){t=t.substring(n.raw.length),e.push(n);continue}if(n=this.tokenizer.lheading(t)){t=t.substring(n.raw.length),e.push(n);continue}let i=t;if(this.options.extensions?.startBlock){let e=1/0,r=t.slice(1),n;this.options.extensions.startBlock.forEach((t=>{n=t.call({lexer:this},r),typeof n=="number"&&n>=0&&(e=Math.min(e,n))})),e<1/0&&e>=0&&(i=t.substring(0,e+1))}if(this.state.top&&(n=this.tokenizer.paragraph(i))){let s=e.at(-1);r&&s?.type==="paragraph"?(s.raw+=(s.raw.endsWith(`\n`)?"":`\n`)+n.raw,s.text+=`\n`+n.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=s.text):e.push(n),r=i.length!==t.length,t=t.substring(n.raw.length);continue}if(n=this.tokenizer.text(t)){t=t.substring(n.raw.length);let r=e.at(-1);r?.type==="text"?(r.raw+=(r.raw.endsWith(`\n`)?"":`\n`)+n.raw,r.text+=`\n`+n.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=r.text):e.push(n);continue}if(t){let e="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(e);break}else throw new Error(e)}}return this.state.top=!0,e}inline(t,e=[]){return this.inlineQueue.push({src:t,tokens:e}),e}inlineTokens(t,e=[]){let r=t,n=null;if(this.tokens.links){let t=Object.keys(this.tokens.links);if(t.length>0)for(;(n=this.tokenizer.rules.inline.reflinkSearch.exec(r))!=null;)t.includes(n[0].slice(n[0].lastIndexOf("[")+1,-1))&&(r=r.slice(0,n.index)+"["+"a".repeat(n[0].length-2)+"]"+r.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(n=this.tokenizer.rules.inline.anyPunctuation.exec(r))!=null;)r=r.slice(0,n.index)+"++"+r.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);for(;(n=this.tokenizer.rules.inline.blockSkip.exec(r))!=null;)r=r.slice(0,n.index)+"["+"a".repeat(n[0].length-2)+"]"+r.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);r=this.options.hooks?.emStrongMask?.call({lexer:this},r)??r;let i=!1,s="";for(;t;){i||(s=""),i=!1;let n;if(this.options.extensions?.inline?.some((r=>(n=r.call({lexer:this},t,e))?(t=t.substring(n.raw.length),e.push(n),!0):!1)))continue;if(n=this.tokenizer.escape(t)){t=t.substring(n.raw.length),e.push(n);continue}if(n=this.tokenizer.tag(t)){t=t.substring(n.raw.length),e.push(n);continue}if(n=this.tokenizer.link(t)){t=t.substring(n.raw.length),e.push(n);continue}if(n=this.tokenizer.reflink(t,this.tokens.links)){t=t.substring(n.raw.length);let r=e.at(-1);n.type==="text"&&r?.type==="text"?(r.raw+=n.raw,r.text+=n.text):e.push(n);continue}if(n=this.tokenizer.emStrong(t,r,s)){t=t.substring(n.raw.length),e.push(n);continue}if(n=this.tokenizer.codespan(t)){t=t.substring(n.raw.length),e.push(n);continue}if(n=this.tokenizer.br(t)){t=t.substring(n.raw.length),e.push(n);continue}if(n=this.tokenizer.del(t)){t=t.substring(n.raw.length),e.push(n);continue}if(n=this.tokenizer.autolink(t)){t=t.substring(n.raw.length),e.push(n);continue}if(!this.state.inLink&&(n=this.tokenizer.url(t))){t=t.substring(n.raw.length),e.push(n);continue}let o=t;if(this.options.extensions?.startInline){let e=1/0,r=t.slice(1),n;this.options.extensions.startInline.forEach((t=>{n=t.call({lexer:this},r),typeof n=="number"&&n>=0&&(e=Math.min(e,n))})),e<1/0&&e>=0&&(o=t.substring(0,e+1))}if(n=this.tokenizer.inlineText(o)){t=t.substring(n.raw.length),n.raw.slice(-1)!=="_"&&(s=n.raw.slice(-1)),i=!0;let r=e.at(-1);r?.type==="text"?(r.raw+=n.raw,r.text+=n.text):e.push(n);continue}if(t){let e="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(e);break}else throw new Error(e)}}return e}};var Lt=class{options;parser;constructor(t){this.options=t||c}space(t){return""}code({text:t,lang:e,escaped:r}){let n=(e||"").match(g.notSpaceStart)?.[0],i=t.replace(g.endingNewline,"")+`\n`;return n?'<pre><code class="language-'+xt(n)+'">'+(r?i:xt(i,!0))+`</code></pre>\n`:"<pre><code>"+(r?i:xt(i,!0))+`</code></pre>\n`}blockquote({tokens:t}){return`<blockquote>\n${this.parser.parse(t)}</blockquote>\n`}html({text:t}){return t}def(t){return""}heading({tokens:t,depth:e}){return`<h${e}>${this.parser.parseInline(t)}</h${e}>\n`}hr(t){return`<hr>\n`}list(t){let e=t.ordered,r=t.start,n="";for(let e=0;e<t.items.length;e++){let r=t.items[e];n+=this.listitem(r)}let i=e?"ol":"ul",s=e&&r!==1?' start="'+r+'"':"";return"<"+i+s+`>\n`+n+"</"+i+`>\n`}listitem(t){let e="";if(t.task){let r=this.checkbox({checked:!!t.checked});t.loose?t.tokens[0]?.type==="paragraph"?(t.tokens[0].text=r+" "+t.tokens[0].text,t.tokens[0].tokens&&t.tokens[0].tokens.length>0&&t.tokens[0].tokens[0].type==="text"&&(t.tokens[0].tokens[0].text=r+" "+xt(t.tokens[0].tokens[0].text),t.tokens[0].tokens[0].escaped=!0)):t.tokens.unshift({type:"text",raw:r+" ",text:r+" ",escaped:!0}):e+=r+" "}return e+=this.parser.parse(t.tokens,!!t.loose),`<li>${e}</li>\n`}checkbox({checked:t}){return"<input "+(t?'checked="" ':"")+'disabled="" type="checkbox">'}paragraph({tokens:t}){return`<p>${this.parser.parseInline(t)}</p>\n`}table(t){let e="",r="";for(let e=0;e<t.header.length;e++)r+=this.tablecell(t.header[e]);e+=this.tablerow({text:r});let n="";for(let e=0;e<t.rows.length;e++){let i=t.rows[e];r="";for(let t=0;t<i.length;t++)r+=this.tablecell(i[t]);n+=this.tablerow({text:r})}return n&&(n=`<tbody>${n}</tbody>`),`<table>\n<thead>\n`+e+`</thead>\n`+n+`</table>\n`}tablerow({text:t}){return`<tr>\n${t}</tr>\n`}tablecell(t){let e=this.parser.parseInline(t.tokens),r=t.header?"th":"td";return(t.align?`<${r} align="${t.align}">`:`<${r}>`)+e+`</${r}>\n`}strong({tokens:t}){return`<strong>${this.parser.parseInline(t)}</strong>`}em({tokens:t}){return`<em>${this.parser.parseInline(t)}</em>`}codespan({text:t}){return`<code>${xt(t,!0)}</code>`}br(t){return"<br>"}del({tokens:t}){return`<del>${this.parser.parseInline(t)}</del>`}link({href:t,title:e,tokens:r}){let n=this.parser.parseInline(r),i=St(t);if(i===null)return n;t=i;let s='<a href="'+t+'"';return e&&(s+=' title="'+xt(e)+'"'),s+=">"+n+"</a>",s}image({href:t,title:e,text:r,tokens:n}){n&&(r=this.parser.parseInline(n,this.parser.textRenderer));let i=St(t);if(i===null)return xt(r);t=i;let s=`<img src="${t}" alt="${r}"`;return e&&(s+=` title="${xt(e)}"`),s+=">",s}text(t){return"tokens"in t&&t.tokens?this.parser.parseInline(t.tokens):"escaped"in t&&t.escaped?t.text:xt(t.text)}};var Nt=class{strong({text:t}){return t}em({text:t}){return t}codespan({text:t}){return t}del({text:t}){return t}html({text:t}){return t}text({text:t}){return t}link({text:t}){return""+t}image({text:t}){return""+t}br(){return""}};var Pt=class t{options;renderer;textRenderer;constructor(t){this.options=t||c,this.options.renderer=this.options.renderer||new Lt,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Nt}static parse(e,r){return new t(r).parse(e)}static parseInline(e,r){return new t(r).parseInline(e)}parse(t,e=!0){let r="";for(let n=0;n<t.length;n++){let i=t[n];if(this.options.extensions?.renderers?.[i.type]){let t=i,e=this.options.extensions.renderers[t.type].call({parser:this},t);if(e!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(t.type)){r+=e||"";continue}}let s=i;switch(s.type){case"space":{r+=this.renderer.space(s);continue}case"hr":{r+=this.renderer.hr(s);continue}case"heading":{r+=this.renderer.heading(s);continue}case"code":{r+=this.renderer.code(s);continue}case"table":{r+=this.renderer.table(s);continue}case"blockquote":{r+=this.renderer.blockquote(s);continue}case"list":{r+=this.renderer.list(s);continue}case"html":{r+=this.renderer.html(s);continue}case"def":{r+=this.renderer.def(s);continue}case"paragraph":{r+=this.renderer.paragraph(s);continue}case"text":{let i=s,o=this.renderer.text(i);for(;n+1<t.length&&t[n+1].type==="text";)i=t[++n],o+=`\n`+this.renderer.text(i);e?r+=this.renderer.paragraph({type:"paragraph",raw:o,text:o,tokens:[{type:"text",raw:o,text:o,escaped:!0}]}):r+=o;continue}default:{let t='Token with "'+s.type+'" type was not found.';if(this.options.silent)return console.error(t),"";throw new Error(t)}}}return r}parseInline(t,e=this.renderer){let r="";for(let n=0;n<t.length;n++){let i=t[n];if(this.options.extensions?.renderers?.[i.type]){let t=this.options.extensions.renderers[i.type].call({parser:this},i);if(t!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(i.type)){r+=t||"";continue}}let s=i;switch(s.type){case"escape":{r+=e.text(s);break}case"html":{r+=e.html(s);break}case"link":{r+=e.link(s);break}case"image":{r+=e.image(s);break}case"strong":{r+=e.strong(s);break}case"em":{r+=e.em(s);break}case"codespan":{r+=e.codespan(s);break}case"br":{r+=e.br(s);break}case"del":{r+=e.del(s);break}case"text":{r+=e.text(s);break}default:{let t='Token with "'+s.type+'" type was not found.';if(this.options.silent)return console.error(t),"";throw new Error(t)}}}return r}};var It=class{options;block;constructor(t){this.options=t||c}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(t){return t}postprocess(t){return t}processAllTokens(t){return t}emStrongMask(t){return t}provideLexer(){return this.block?Ct.lex:Ct.lexInline}provideParser(){return this.block?Pt.parse:Pt.parseInline}};var Dt=class{defaults=h();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=Pt;Renderer=Lt;TextRenderer=Nt;Lexer=Ct;Tokenizer=Rt;Hooks=It;constructor(...t){this.use(...t)}walkTokens(t,e){let r=[];for(let n of t)switch(r=r.concat(e.call(this,n)),n.type){case"table":{let t=n;for(let n of t.header)r=r.concat(this.walkTokens(n.tokens,e));for(let n of t.rows)for(let t of n)r=r.concat(this.walkTokens(t.tokens,e));break}case"list":{let t=n;r=r.concat(this.walkTokens(t.items,e));break}default:{let t=n;this.defaults.extensions?.childTokens?.[t.type]?this.defaults.extensions.childTokens[t.type].forEach((n=>{let i=t[n].flat(1/0);r=r.concat(this.walkTokens(i,e))})):t.tokens&&(r=r.concat(this.walkTokens(t.tokens,e)))}}return r}use(...t){let e=this.defaults.extensions||{renderers:{},childTokens:{}};return t.forEach((t=>{let r={...t};if(r.async=this.defaults.async||r.async||!1,t.extensions&&(t.extensions.forEach((t=>{if(!t.name)throw new Error("extension name required");if("renderer"in t){let r=e.renderers[t.name];r?e.renderers[t.name]=function(...e){let n=t.renderer.apply(this,e);return n===!1&&(n=r.apply(this,e)),n}:e.renderers[t.name]=t.renderer}if("tokenizer"in t){if(!t.level||t.level!=="block"&&t.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let r=e[t.level];r?r.unshift(t.tokenizer):e[t.level]=[t.tokenizer],t.start&&(t.level==="block"?e.startBlock?e.startBlock.push(t.start):e.startBlock=[t.start]:t.level==="inline"&&(e.startInline?e.startInline.push(t.start):e.startInline=[t.start]))}"childTokens"in t&&t.childTokens&&(e.childTokens[t.name]=t.childTokens)})),r.extensions=e),t.renderer){let e=this.defaults.renderer||new Lt(this.defaults);for(let r in t.renderer){if(!(r in e))throw new Error(`renderer '${r}' does not exist`);if(["options","parser"].includes(r))continue;let n=r,i=t.renderer[n],s=e[n];e[n]=(...t)=>{let r=i.apply(e,t);return r===!1&&(r=s.apply(e,t)),r||""}}r.renderer=e}if(t.tokenizer){let e=this.defaults.tokenizer||new Rt(this.defaults);for(let r in t.tokenizer){if(!(r in e))throw new Error(`tokenizer '${r}' does not exist`);if(["options","rules","lexer"].includes(r))continue;let n=r,i=t.tokenizer[n],s=e[n];e[n]=(...t)=>{let r=i.apply(e,t);return r===!1&&(r=s.apply(e,t)),r}}r.tokenizer=e}if(t.hooks){let e=this.defaults.hooks||new It;for(let r in t.hooks){if(!(r in e))throw new Error(`hook '${r}' does not exist`);if(["options","block"].includes(r))continue;let n=r,i=t.hooks[n],s=e[n];It.passThroughHooks.has(r)?e[n]=t=>{if(this.defaults.async&&It.passThroughHooksRespectAsync.has(r))return(async()=>{let r=await i.call(e,t);return s.call(e,r)})();let n=i.call(e,t);return s.call(e,n)}:e[n]=(...t)=>{if(this.defaults.async)return(async()=>{let r=await i.apply(e,t);return r===!1&&(r=await s.apply(e,t)),r})();let r=i.apply(e,t);return r===!1&&(r=s.apply(e,t)),r}}r.hooks=e}if(t.walkTokens){let e=this.defaults.walkTokens,n=t.walkTokens;r.walkTokens=function(t){let r=[];return r.push(n.call(this,t)),e&&(r=r.concat(e.call(this,t))),r}}this.defaults={...this.defaults,...r}})),this}setOptions(t){return this.defaults={...this.defaults,...t},this}lexer(t,e){return Ct.lex(t,e??this.defaults)}parser(t,e){return Pt.parse(t,e??this.defaults)}parseMarkdown(t){return(e,r)=>{let n={...r},i={...this.defaults,...n},s=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&n.async===!1)return s(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof e>"u"||e===null)return s(new Error("marked(): input parameter is undefined or null"));if(typeof e!="string")return s(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(e)+", string expected"));if(i.hooks&&(i.hooks.options=i,i.hooks.block=t),i.async)return(async()=>{let r=i.hooks?await i.hooks.preprocess(e):e,n=await(i.hooks?await i.hooks.provideLexer():t?Ct.lex:Ct.lexInline)(r,i),s=i.hooks?await i.hooks.processAllTokens(n):n;i.walkTokens&&await Promise.all(this.walkTokens(s,i.walkTokens));let o=await(i.hooks?await i.hooks.provideParser():t?Pt.parse:Pt.parseInline)(s,i);return i.hooks?await i.hooks.postprocess(o):o})().catch(s);try{i.hooks&&(e=i.hooks.preprocess(e));let r=(i.hooks?i.hooks.provideLexer():t?Ct.lex:Ct.lexInline)(e,i);i.hooks&&(r=i.hooks.processAllTokens(r)),i.walkTokens&&this.walkTokens(r,i.walkTokens);let n=(i.hooks?i.hooks.provideParser():t?Pt.parse:Pt.parseInline)(r,i);return i.hooks&&(n=i.hooks.postprocess(n)),n}catch(t){return s(t)}}}onError(t,e){return r=>{if(r.message+=`\nPlease report this to https://github.com/markedjs/marked.`,t){let t="<p>An error occurred:</p><pre>"+xt(r.message+"",!0)+"</pre>";return e?Promise.resolve(t):t}if(e)return Promise.reject(r);throw r}}};var Ht=new Dt;function jt(t,e){return Ht.parse(t,e)}jt.options=jt.setOptions=function(t){return Ht.setOptions(t),jt.defaults=Ht.defaults,d(jt.defaults),jt};jt.getDefaults=h;jt.defaults=c;jt.use=function(...t){return Ht.use(...t),jt.defaults=Ht.defaults,d(jt.defaults),jt};jt.walkTokens=function(t,e){return Ht.walkTokens(t,e)};jt.parseInline=Ht.parseInline;jt.Parser=Pt;jt.parser=Pt.parse;jt.Renderer=Lt;jt.TextRenderer=Nt;jt.Lexer=Ct;jt.lexer=Ct.lex;jt.Tokenizer=Rt;jt.Hooks=It;jt.parse=jt;var _t=jt.options,zt=jt.setOptions,Bt=jt.use,Ft=jt.walkTokens,Ut=jt.parseInline,qt=jt,Jt=Pt.parse,Kt=Ct.lex;if(e!=t)r.exports=t;return r.exports}))})(xh);function Sh(t,e){const r=e.split("\n");const n=r.flatMap((t=>[t,""])).map((e=>`${t}${e}`)).join("\n");return n.slice(0,n.length-1)}function Th(t,e){const r=[];Array.from(t.keys()).forEach((t=>{if(!e.has(t)){r.push(t)}}));return r.reverse()}function Eh(t,e){const r=[];Array.from(e.entries()).forEach((([e,n])=>{if(!t.has(e)){r.push({type:e,mark:n})}}));return r}function $h(t,e,r,n){const i=!r;const s=r&&r.type==="text"&&(!r.marks||r.marks.length===0);const o=r&&r.type==="text"&&r.marks&&!n(e,new Map(r.marks.map((t=>[t.type,t]))));const l=[];if(i||s||o){if(r&&r.type==="text"&&r.marks){const e=new Map(r.marks.map((t=>[t.type,t])));Array.from(t.keys()).forEach((t=>{if(!e.has(t)){l.push(t)}}))}else if(i||s){l.push(...Array.from(t.keys()))}}return l.reverse()}function Ah(t,e){let r="";Array.from(t.keys()).reverse().forEach((n=>{const i=t.get(n);const s=e(n,i);if(s){r=s+r}}));t.clear();return r}function Oh(t,e,r){let n="";Array.from(t.entries()).forEach((([t,i])=>{const s=r(t,i);if(s){n+=s}e.set(t,i)}));return n}function Rh(t,e){if(typeof t!=="string"){return"json"}return e}var Ch=class{constructor(t){this.baseExtensions=[];this.extensions=[];this.lastParseResult=null;var e,r,n,i,s;this.markedInstance=(e=t==null?void 0:t.marked)!=null?e:xh.exports.marked;this.lexer=new this.markedInstance.Lexer;this.indentStyle=(n=(r=t==null?void 0:t.indentation)==null?void 0:r.style)!=null?n:"space";this.indentSize=(s=(i=t==null?void 0:t.indentation)==null?void 0:i.size)!=null?s:2;this.baseExtensions=(t==null?void 0:t.extensions)||[];if((t==null?void 0:t.markedOptions)&&typeof this.markedInstance.setOptions==="function"){this.markedInstance.setOptions(t.markedOptions)}this.registry=new Map;this.nodeTypeRegistry=new Map;if(t==null?void 0:t.extensions){this.baseExtensions=t.extensions;const e=ga(t.extensions);e.forEach((t=>this.registerExtension(t,false)))}this.lexer=new this.markedInstance.Lexer}get instance(){return this.markedInstance}get indentCharacter(){return this.indentStyle==="space"?" ":"\t"}get indentString(){return this.indentCharacter.repeat(this.indentSize)}hasMarked(){return!!this.markedInstance}registerExtension(t,e=true){var r,n;this.extensions.push(t);const i=t.name;const s=ma(t,"markdownTokenName")||i;const o=ma(t,"parseMarkdown");const l=ma(t,"renderMarkdown");const u=ma(t,"markdownTokenizer");const a=(r=ma(t,"markdownOptions"))!=null?r:null;const f=(n=a==null?void 0:a.indentsContent)!=null?n:false;const h={tokenName:s,nodeName:i,parseMarkdown:o,renderMarkdown:l,isIndenting:f,tokenizer:u};if(s&&o){const t=this.registry.get(s)||[];t.push(h);this.registry.set(s,t)}if(l){const t=this.nodeTypeRegistry.get(i)||[];t.push(h);this.nodeTypeRegistry.set(i,t)}if(u&&this.hasMarked()){this.registerTokenizer(u);if(e){this.lexer=new this.markedInstance.Lexer}}}registerTokenizer(t){if(!this.hasMarked()){return}const{name:e,start:r,level:n="inline",tokenize:i}=t;const s=t=>this.lexer.inlineTokens(t);const o=t=>this.lexer.blockTokens(t);const l={inlineTokens:s,blockTokens:o};let u;if(!r){u=t=>{const e=i(t,[],l);if(e&&e.raw){const r=t.indexOf(e.raw);return r}return-1}}else{u=typeof r==="function"?r:t=>t.indexOf(r)}const a={name:e,level:n,start:u,tokenizer:(t,r)=>{const n=i(t,r,l);if(n&&n.type){return{...n,type:n.type||e,raw:n.raw||"",tokens:n.tokens||[]}}return void 0},childTokens:[]};this.markedInstance.use({extensions:[a]})}getHandlersForToken(t){try{return this.registry.get(t)||[]}catch{return[]}}getHandlerForToken(t){const e=this.getHandlersForToken(t);if(e.length>0){return e[0]}const r=this.getHandlersForNodeType(t);return r.length>0?r[0]:void 0}getHandlersForNodeType(t){try{return this.nodeTypeRegistry.get(t)||[]}catch{return[]}}serialize(t){if(!t){return""}if(Array.isArray(t)){return this.renderNodes(t,t)}return this.renderNodes(t,t)}parse(t){if(!this.hasMarked()){throw new Error("No marked instance available for parsing")}const e=this.markedInstance.lexer(t);const r=this.parseTokens(e);return{type:"doc",content:r}}parseTokens(t){return t.map((t=>this.parseToken(t))).filter((t=>t!==null)).flatMap((t=>Array.isArray(t)?t:[t]))}parseToken(t){if(!t.type){return null}const e=this.getHandlersForToken(t.type);const r=this.createParseHelpers();const n=e.find((e=>{if(!e.parseMarkdown){return false}const n=e.parseMarkdown(t,r);const i=this.normalizeParseResult(n);if(i&&(!Array.isArray(i)||i.length>0)){this.lastParseResult=i;return true}return false}));if(n&&this.lastParseResult){const t=this.lastParseResult;this.lastParseResult=null;return t}return this.parseFallbackToken(t)}createParseHelpers(){return{parseInline:t=>this.parseInlineTokens(t),parseChildren:t=>this.parseTokens(t),createTextNode:(t,e)=>{const r={type:"text",text:t,marks:e||void 0};return r},createNode:(t,e,r)=>{const n={type:t,attrs:e||void 0,content:r||void 0};if(!e||Object.keys(e).length===0){delete n.attrs}return n},applyMark:(t,e,r)=>({mark:t,content:e,attrs:r&&Object.keys(r).length>0?r:void 0})}}parseInlineTokens(t){const e=[];t.forEach((t=>{if(t.type==="text"){e.push({type:"text",text:t.text||""})}else if(t.type){const r=this.getHandlerForToken(t.type);if(r&&r.parseMarkdown){const n=this.createParseHelpers();const i=r.parseMarkdown(t,n);if(this.isMarkResult(i)){const t=this.applyMarkToContent(i.mark,i.content,i.attrs);e.push(...t)}else{const t=this.normalizeParseResult(i);if(Array.isArray(t)){e.push(...t)}else if(t){e.push(t)}}}else if(t.tokens){e.push(...this.parseInlineTokens(t.tokens))}}}));return e}applyMarkToContent(t,e,r){return e.map((e=>{if(e.type==="text"){const n=e.marks||[];const i=r?{type:t,attrs:r}:{type:t};return{...e,marks:[...n,i]}}return{...e,content:e.content?this.applyMarkToContent(t,e.content,r):void 0}}))}isMarkResult(t){return t&&typeof t==="object"&&"mark"in t}normalizeParseResult(t){if(!t){return null}if(this.isMarkResult(t)){return t.content}return t}parseFallbackToken(t){switch(t.type){case"paragraph":return{type:"paragraph",content:t.tokens?this.parseInlineTokens(t.tokens):[]};case"heading":return{type:"heading",attrs:{level:t.depth||1},content:t.tokens?this.parseInlineTokens(t.tokens):[]};case"text":return{type:"text",text:t.text||""};case"html":return this.parseHTMLToken(t);case"space":return null;default:if(t.tokens){return this.parseTokens(t.tokens)}return null}}parseHTMLToken(t){const e=t.text||t.raw||"";if(!e.trim()){return null}try{const r=Na(e,this.baseExtensions);if(r.type==="doc"&&r.content){if(t.block){return r.content}if(r.content.length===1&&r.content[0].type==="paragraph"&&r.content[0].content){return r.content[0].content}return r.content}return r}catch(t){throw new Error(`Failed to parse HTML in markdown: ${t}`)}}renderNodeToMarkdown(t,e,r=0,n=0){var i;if(t.type==="text"){return t.text||""}if(!t.type){return""}const s=this.getHandlerForToken(t.type);if(!s){return""}const o={renderChildren:(e,i)=>{const o=s.isIndenting?n+1:n;if(!Array.isArray(e)&&e.content){return this.renderNodes(e.content,t,i||"",r,o)}return this.renderNodes(e,t,i||"",r,o)},indent:t=>this.indentString+t,wrapInBlock:Sh};const l={index:r,level:n,parentType:e==null?void 0:e.type,meta:{}};const u=((i=s.renderMarkdown)==null?void 0:i.call(s,t,o,l))||"";return u}renderNodes(t,e,r="",n=0,i=0){if(!Array.isArray(t)){if(!t.type){return""}return this.renderNodeToMarkdown(t,e,n,i)}return this.renderNodesWithMarkBoundaries(t,e,r,i)}renderNodesWithMarkBoundaries(t,e,r="",n=0){const i=[];const s=new Map;t.forEach(((r,o)=>{const l=o<t.length-1?t[o+1]:null;if(!r.type){return}if(r.type==="text"){let t=r.text||"";const e=new Map((r.marks||[]).map((t=>[t.type,t])));const n=Th(s,e);const o=Eh(s,e);n.forEach((e=>{const r=s.get(e);const n=this.getMarkClosing(e,r);if(n){t+=n}s.delete(e)}));o.forEach((({type:e,mark:r})=>{const n=this.getMarkOpening(e,r);if(n){t=n+t}s.set(e,r)}));const u=$h(s,e,l,this.markSetsEqual.bind(this));u.forEach((e=>{const r=s.get(e);const n=this.getMarkClosing(e,r);if(n){t+=n}s.delete(e)}));i.push(t)}else{const t=new Map(s);const l=Ah(s,this.getMarkClosing.bind(this));const u=this.renderNodeToMarkdown(r,e,o,n);const a=Oh(t,s,this.getMarkOpening.bind(this));i.push(l+u+a)}}));return i.join(r)}getMarkOpening(t,e){const r=this.getHandlersForNodeType(t);const n=r.length>0?r[0]:void 0;if(!n||!n.renderMarkdown){return""}const i="__TIPTAP_MARKDOWN_PLACEHOLDER__";const s={type:t,attrs:e.attrs||{},content:[{type:"text",text:i}]};try{const t=n.renderMarkdown(s,{renderChildren:()=>i,indent:t=>t,wrapInBlock:(t,e)=>t+e},{index:0,level:0,parentType:"text",meta:{}});const e=t.indexOf(i);return e>=0?t.substring(0,e):""}catch(e){throw new Error(`Failed to get mark opening for ${t}: ${e}`)}}getMarkClosing(t,e){const r=this.getHandlersForNodeType(t);const n=r.length>0?r[0]:void 0;if(!n||!n.renderMarkdown){return""}const i="__TIPTAP_MARKDOWN_PLACEHOLDER__";const s={type:t,attrs:e.attrs||{},content:[{type:"text",text:i}]};try{const t=n.renderMarkdown(s,{renderChildren:()=>i,indent:t=>t,wrapInBlock:(t,e)=>t+e},{index:0,level:0,parentType:"text",meta:{}});const e=t.indexOf(i);const r=e+i.length;return e>=0?t.substring(r):""}catch(e){throw new Error(`Failed to get mark closing for ${t}: ${e}`)}}markSetsEqual(t,e){if(t.size!==e.size){return false}return Array.from(t.keys()).every((t=>e.has(t)))}};var Lh=Ch;var Nh=Uf.create({name:"markdown",addOptions(){return{indentation:{style:"space",size:2},marked:void 0,markedOptions:{}}},addCommands(){return{setContent:(t,e)=>{if(!(e==null?void 0:e.contentType)){return Yl.setContent(t,e)}const r=Rh(t,e==null?void 0:e.contentType);if(r!=="markdown"||!this.editor.markdown){return Yl.setContent(t,e)}const n=this.editor.markdown.parse(t);return Yl.setContent(n,e)},insertContent:(t,e)=>{if(!(e==null?void 0:e.contentType)){return Yl.insertContent(t,e)}const r=Rh(t,e==null?void 0:e.contentType);if(r!=="markdown"||!this.editor.markdown){return Yl.insertContent(t,e)}const n=this.editor.markdown.parse(t);return Yl.insertContent(n,e)},insertContentAt:(t,e,r)=>{if(!(r==null?void 0:r.contentType)){return Yl.insertContentAt(t,e,r)}const n=Rh(e,r==null?void 0:r.contentType);if(n!=="markdown"||!this.editor.markdown){return Yl.insertContentAt(t,e,r)}const i=this.editor.markdown.parse(e);return Yl.insertContentAt(t,i,r)}}},addStorage(){return{manager:new Lh({indentation:this.options.indentation,marked:this.options.marked,markedOptions:this.options.markedOptions,extensions:[]})}},onBeforeCreate(){if(this.editor.markdown){console.error("[tiptap][markdown]: There is already a `markdown` property on the editor instance. This might lead to unexpected behavior.");return}this.storage.manager=new Lh({indentation:this.options.indentation,marked:this.options.marked,markedOptions:this.options.markedOptions,extensions:this.editor.extensionManager.baseExtensions});this.editor.markdown=this.storage.manager;this.editor.getMarkdown=()=>this.storage.manager.serialize(this.editor.getJSON());if(!this.editor.options.contentType){return}const t=Rh(this.editor.options.content,this.editor.options.contentType);if(t!=="markdown"){return}if(!this.editor.markdown){throw new Error('[tiptap][markdown]: The `contentType` option is set to "markdown", but the Markdown extension is not added to the editor. Please add the Markdown extension to use this feature.')}if(this.editor.options.content===void 0||typeof this.editor.options.content!=="string"){throw new Error('[tiptap][markdown]: The `contentType` option is set to "markdown", but the initial content is not a string. Please provide the initial content as a markdown string.')}const e=this.editor.markdown.parse(this.editor.options.content);this.editor.options.content=e}});var Ph=(t,e)=>{if(t==="slot"){return 0}if(t instanceof Function){return t(e)}const{children:r,...n}=e!=null?e:{};if(t==="svg"){throw new Error("SVG elements are not supported in the JSX syntax, use the array syntax instead")}return[t,n,r]};var Ih=/^\s*>\s$/;var Dh=vh.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:true,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return Ph("blockquote",{...xa(this.options.HTMLAttributes,t),children:Ph("slot",{})})},parseMarkdown:(t,e)=>e.createNode("blockquote",void 0,e.parseChildren(t.tokens||[])),renderMarkdown:(t,e)=>{if(!t.content){return""}const r=[];t.content.forEach((t=>{const n=e.renderChildren(t);const i=n.split("\n").map((t=>`> ${t}`)).join("\n");r.push(i)}));const n=r.flatMap((t=>[t,"> "]));return n.slice(0,-1).join("\n")},addCommands(){return{setBlockquote:()=>({commands:t})=>t.wrapIn(this.name),toggleBlockquote:()=>({commands:t})=>t.toggleWrap(this.name),unsetBlockquote:()=>({commands:t})=>t.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[lh({find:Ih,type:this.type})]}});var Hh=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/;var jh=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g;var _h=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/;var zh=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g;var Bh=Nf.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:t=>t.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:t=>t.type.name===this.name},{style:"font-weight",getAttrs:t=>/^(bold(er)?|[5-9]\d{2,})$/.test(t)&&null}]},renderHTML({HTMLAttributes:t}){return Ph("strong",{...xa(this.options.HTMLAttributes,t),children:Ph("slot",{})})},markdownTokenName:"strong",parseMarkdown:(t,e)=>e.applyMark("bold",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`**${e.renderChildren(t)}**`,addCommands(){return{setBold:()=>({commands:t})=>t.setMark(this.name),toggleBold:()=>({commands:t})=>t.toggleMark(this.name),unsetBold:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[ih({find:Hh,type:this.type}),ih({find:_h,type:this.type})]},addPasteRules(){return[yh({find:jh,type:this.type}),yh({find:zh,type:this.type})]}});var Fh=/(^|[^`])`([^`]+)`(?!`)$/;var Uh=/(^|[^`])`([^`]+)`(?!`)/g;var qh=Nf.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:true,exitable:true,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",xa(this.options.HTMLAttributes,t),0]},markdownTokenName:"codespan",parseMarkdown:(t,e)=>e.applyMark("code",[{type:"text",text:t.text||""}]),renderMarkdown:(t,e)=>{if(!t.content){return""}return`\`${e.renderChildren(t.content)}\``},addCommands(){return{setCode:()=>({commands:t})=>t.setMark(this.name),toggleCode:()=>({commands:t})=>t.toggleMark(this.name),unsetCode:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[ih({find:Fh,type:this.type})]},addPasteRules(){return[yh({find:Uh,type:this.type})]}});var Jh=4;var Kh=/^```([a-z]+)?[\s\n]$/;var Wh=/^~~~([a-z]+)?[\s\n]$/;var Vh=vh.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:true,exitOnArrowDown:true,defaultLanguage:null,enableTabIndentation:false,tabSize:Jh,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:true,defining:true,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:t=>{var e;const{languageClassPrefix:r}=this.options;if(!r){return null}const n=[...((e=t.firstElementChild)==null?void 0:e.classList)||[]];const i=n.filter((t=>t.startsWith(r))).map((t=>t.replace(r,"")));const s=i[0];if(!s){return null}return s},rendered:false}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:t,HTMLAttributes:e}){return["pre",xa(this.options.HTMLAttributes,e),["code",{class:t.attrs.language?this.options.languageClassPrefix+t.attrs.language:null},0]]},markdownTokenName:"code",parseMarkdown:(t,e)=>{var r;if(((r=t.raw)==null?void 0:r.startsWith("```"))===false&&t.codeBlockStyle!=="indented"){return[]}return e.createNode("codeBlock",{language:t.lang||null},t.text?[e.createTextNode(t.text)]:[])},renderMarkdown:(t,e)=>{var r;let n="";const i=((r=t.attrs)==null?void 0:r.language)||"";if(!t.content){n=`\`\`\`${i}\n\n\`\`\``}else{const r=[`\`\`\`${i}`,e.renderChildren(t.content),"```"];n=r.join("\n")}return n},addCommands(){return{setCodeBlock:t=>({commands:e})=>e.setNode(this.name,t),toggleCodeBlock:t=>({commands:e})=>e.toggleNode(this.name,"paragraph",t)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:t,$anchor:e}=this.editor.state.selection;const r=e.pos===1;if(!t||e.parent.type.name!==this.name){return false}if(r||!e.parent.textContent.length){return this.editor.commands.clearNodes()}return false},Tab:({editor:t})=>{var e;if(!this.options.enableTabIndentation){return false}const r=(e=this.options.tabSize)!=null?e:Jh;const{state:n}=t;const{selection:i}=n;const{$from:s,empty:o}=i;if(s.parent.type!==this.type){return false}const l=" ".repeat(r);if(o){return t.commands.insertContent(l)}return t.commands.command((({tr:t})=>{const{from:e,to:r}=i;const s=n.doc.textBetween(e,r,"\n","\n");const o=s.split("\n");const u=o.map((t=>l+t)).join("\n");t.replaceWith(e,r,n.schema.text(u));return true}))},"Shift-Tab":({editor:t})=>{var e;if(!this.options.enableTabIndentation){return false}const r=(e=this.options.tabSize)!=null?e:Jh;const{state:n}=t;const{selection:i}=n;const{$from:s,empty:o}=i;if(s.parent.type!==this.type){return false}if(o){return t.commands.command((({tr:t})=>{var e;const{pos:i}=s;const o=s.start();const l=s.end();const u=n.doc.textBetween(o,l,"\n","\n");const a=u.split("\n");let f=0;let h=0;const c=i-o;for(let t=0;t<a.length;t+=1){if(h+a[t].length>=c){f=t;break}h+=a[t].length+1}const d=a[f];const p=((e=d.match(/^ */))==null?void 0:e[0])||"";const m=Math.min(p.length,r);if(m===0){return true}let g=o;for(let t=0;t<f;t+=1){g+=a[t].length+1}t.delete(g,g+m);const w=i-g;if(w<=m){t.setSelection(tr.create(t.doc,g))}return true}))}return t.commands.command((({tr:t})=>{const{from:e,to:s}=i;const o=n.doc.textBetween(e,s,"\n","\n");const l=o.split("\n");const u=l.map((t=>{var e;const n=((e=t.match(/^ */))==null?void 0:e[0])||"";const i=Math.min(n.length,r);return t.slice(i)})).join("\n");t.replaceWith(e,s,n.schema.text(u));return true}))},Enter:({editor:t})=>{if(!this.options.exitOnTripleEnter){return false}const{state:e}=t;const{selection:r}=e;const{$from:n,empty:i}=r;if(!i||n.parent.type!==this.type){return false}const s=n.parentOffset===n.parent.nodeSize-2;const o=n.parent.textContent.endsWith("\n\n");if(!s||!o){return false}return t.chain().command((({tr:t})=>{t.delete(n.pos-2,n.pos);return true})).exitCode().run()},ArrowDown:({editor:t})=>{if(!this.options.exitOnArrowDown){return false}const{state:e}=t;const{selection:r,doc:n}=e;const{$from:i,empty:s}=r;if(!s||i.parent.type!==this.type){return false}const o=i.parentOffset===i.parent.nodeSize-2;if(!o){return false}const l=i.after();if(l===void 0){return false}const u=n.nodeAt(l);if(u){return t.commands.command((({tr:t})=>{t.setSelection(Ze.near(n.resolve(l)));return true}))}return t.commands.exitCode()}}},addInputRules(){return[oh({find:Kh,type:this.type,getAttributes:t=>({language:t[1]})}),oh({find:Wh,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new br({key:new yr("codeBlockVSCodeHandler"),props:{handlePaste:(t,e)=>{if(!e.clipboardData){return false}if(this.editor.isActive(this.type.name)){return false}const r=e.clipboardData.getData("text/plain");const n=e.clipboardData.getData("vscode-editor-data");const i=n?JSON.parse(n):void 0;const s=i==null?void 0:i.mode;if(!r||!s){return false}const{tr:o,schema:l}=t.state;const u=l.text(r.replace(/\r\n?/g,"\n"));o.replaceSelectionWith(this.type.create({language:s},u));if(o.selection.$from.parent.type!==this.type){o.setSelection(tr.near(o.doc.resolve(Math.max(0,o.selection.from-2))))}o.setMeta("paste",true);t.dispatch(o);return true}}})]}});var Gh=vh.create({name:"doc",topNode:true,content:"block+",renderMarkdown:(t,e)=>{if(!t.content){return""}return e.renderChildren(t.content,"\n\n")}});var Zh=vh.create({name:"hardBreak",addOptions(){return{keepMarks:true,HTMLAttributes:{}}},inline:true,group:"inline",selectable:false,linebreakReplacement:true,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:t}){return["br",xa(this.options.HTMLAttributes,t)]},renderText(){return"\n"},renderMarkdown:(t,e)=>e.indent(`\n`),addCommands(){return{setHardBreak:()=>({commands:t,chain:e,state:r,editor:n})=>t.first([()=>t.exitCode(),()=>t.command((()=>{const{selection:t,storedMarks:i}=r;if(t.$from.parent.type.spec.isolating){return false}const{keepMarks:s}=this.options;const{splittableMarks:o}=n.extensionManager;const l=i||t.$to.parentOffset&&t.$from.marks();return e().insertContent({type:this.name}).command((({tr:t,dispatch:e})=>{if(e&&l&&s){const e=l.filter((t=>o.includes(t.type.name)));t.ensureMarks(e)}return true})).run()}))])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}});var Qh=vh.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:true,addAttributes(){return{level:{default:1,rendered:false}}},parseHTML(){return this.options.levels.map((t=>({tag:`h${t}`,attrs:{level:t}})))},renderHTML({node:t,HTMLAttributes:e}){const r=this.options.levels.includes(t.attrs.level);const n=r?t.attrs.level:this.options.levels[0];return[`h${n}`,xa(this.options.HTMLAttributes,e),0]},parseMarkdown:(t,e)=>e.createNode("heading",{level:t.depth||1},e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>{var r;const n=((r=t.attrs)==null?void 0:r.level)?parseInt(t.attrs.level,10):1;const i="#".repeat(n);if(!t.content){return""}return`${i} ${e.renderChildren(t.content)}`},addCommands(){return{setHeading:t=>({commands:e})=>{if(!this.options.levels.includes(t.level)){return false}return e.setNode(this.name,t)},toggleHeading:t=>({commands:e})=>{if(!this.options.levels.includes(t.level)){return false}return e.toggleNode(this.name,"paragraph",t)}}},addKeyboardShortcuts(){return this.options.levels.reduce(((t,e)=>({...t,...{[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}})),{})},addInputRules(){return this.options.levels.map((t=>oh({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}})))}});var Xh=vh.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",xa(this.options.HTMLAttributes,t)]},markdownTokenName:"hr",parseMarkdown:(t,e)=>e.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{if(!uh(e,e.schema.nodes[this.name])){return false}const{selection:r}=e;const{$to:n}=r;const i=t();if(tf(r)){i.insertContentAt(n.pos,{type:this.name})}else{i.insertContent({type:this.name})}return i.command((({state:t,tr:e,dispatch:r})=>{if(r){const{$to:r}=e.selection;const n=r.end();if(r.nodeAfter){if(r.nodeAfter.isTextblock){e.setSelection(tr.create(e.doc,r.pos+1))}else if(r.nodeAfter.isBlock){e.setSelection(rr.create(e.doc,r.pos))}else{e.setSelection(tr.create(e.doc,r.pos))}}else{const i=t.schema.nodes[this.options.nextNodeType]||r.parent.type.contentMatch.defaultType;const s=i==null?void 0:i.create();if(s){e.insert(n,s);e.setSelection(tr.create(e.doc,n+1))}}e.scrollIntoView()}return true})).run()}}},addInputRules(){return[sh({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}});var Yh=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/;var tc=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g;var ec=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/;var rc=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g;var nc=Nf.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:t=>t.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:t=>t.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:t}){return["em",xa(this.options.HTMLAttributes,t),0]},addCommands(){return{setItalic:()=>({commands:t})=>t.setMark(this.name),toggleItalic:()=>({commands:t})=>t.toggleMark(this.name),unsetItalic:()=>({commands:t})=>t.unsetMark(this.name)}},markdownTokenName:"em",parseMarkdown:(t,e)=>e.applyMark("italic",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`*${e.renderChildren(t)}*`,addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[ih({find:Yh,type:this.type}),ih({find:ec,type:this.type})]},addPasteRules(){return[yh({find:tc,type:this.type}),yh({find:rc,type:this.type})]}});const ic="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2";const sc="ελ1υ2бг1ел3дети4ею2католик6ом3мкд2он1сква6онлайн5рг3рус2ф2сайт3рб3укр3қаз3հայ3ישראל5קום3ابوظبي5رامكو5لاردن4بحرين5جزائر5سعودية6عليان5مغرب5مارات5یران5بارت2زار4يتك3ھارت5تونس4سودان3رية5شبكة4عراق2ب2مان4فلسطين6قطر3كاثوليك6وم3مصر2ليسيا5وريتانيا7قع4همراه5پاکستان7ڀارت4कॉम3नेट3भारत0म्3ोत5संगठन5বাংলা5ভারত2ৰত4ਭਾਰਤ4ભારત4ଭାରତ4இந்தியா6லங்கை6சிங்கப்பூர்11భారత్5ಭಾರತ4ഭാരതം5ලංකා4คอม3ไทย3ລາວ3გე2みんな3アマゾン4クラウド4グーグル4コム2ストア3セール3ファッション6ポイント4世界2中信1国1國1文网3亚马逊3企业2佛山2信息2健康2八卦2公司1益2台湾1灣2商城1店1标2嘉里0大酒店5在线2大拿2天主教3娱乐2家電2广东2微博2慈善2我爱你3手机2招聘2政务1府2新加坡2闻2时尚2書籍2机构2淡马锡3游戏2澳門2点看2移动2组织机构4网址1店1站1络2联通2谷歌2购物2通販2集团2電訊盈科4飞利浦3食品2餐厅2香格里拉3港2닷넷1컴2삼성2한국2";const oc="numeric";const lc="ascii";const uc="alpha";const ac="asciinumeric";const fc="alphanumeric";const hc="domain";const cc="emoji";const dc="scheme";const pc="slashscheme";const mc="whitespace";function gc(t,e){if(!(t in e)){e[t]=[]}return e[t]}function wc(t,e,r){if(e[oc]){e[ac]=true;e[fc]=true}if(e[lc]){e[ac]=true;e[uc]=true}if(e[ac]){e[fc]=true}if(e[uc]){e[fc]=true}if(e[fc]){e[hc]=true}if(e[cc]){e[hc]=true}for(const n in e){const e=gc(n,r);if(e.indexOf(t)<0){e.push(t)}}}function bc(t,e){const r={};for(const n in e){if(e[n].indexOf(t)>=0){r[n]=true}}return r}function kc(t=null){this.j={};this.jr=[];this.jd=null;this.t=t}kc.groups={};kc.prototype={accepts(){return!!this.t},go(t){const e=this;const r=e.j[t];if(r){return r}for(let r=0;r<e.jr.length;r++){const n=e.jr[r][0];const i=e.jr[r][1];if(i&&n.test(t)){return i}}return e.jd},has(t,e=false){return e?t in this.j:!!this.go(t)},ta(t,e,r,n){for(let i=0;i<t.length;i++){this.tt(t[i],e,r,n)}},tr(t,e,r,n){n=n||kc.groups;let i;if(e&&e.j){i=e}else{i=new kc(e);if(r&&n){wc(e,r,n)}}this.jr.push([t,i]);return i},ts(t,e,r,n){let i=this;const s=t.length;if(!s){return i}for(let e=0;e<s-1;e++){i=i.tt(t[e])}return i.tt(t[s-1],e,r,n)},tt(t,e,r,n){n=n||kc.groups;const i=this;if(e&&e.j){i.j[t]=e;return e}const s=e;let o,l=i.go(t);if(l){o=new kc;Object.assign(o.j,l.j);o.jr.push.apply(o.jr,l.jr);o.jd=l.jd;o.t=l.t}else{o=new kc}if(s){if(n){if(o.t&&typeof o.t==="string"){const t=Object.assign(bc(o.t,n),r);wc(s,t,n)}else if(r){wc(s,r,n)}}o.t=s}i.j[t]=o;return o}};const vc=(t,e,r,n,i)=>t.ta(e,r,n,i);const yc=(t,e,r,n,i)=>t.tr(e,r,n,i);const Mc=(t,e,r,n,i)=>t.ts(e,r,n,i);const xc=(t,e,r,n,i)=>t.tt(e,r,n,i);const Sc="WORD";const Tc="UWORD";const Ec="ASCIINUMERICAL";const $c="ALPHANUMERICAL";const Ac="LOCALHOST";const Oc="TLD";const Rc="UTLD";const Cc="SCHEME";const Lc="SLASH_SCHEME";const Nc="NUM";const Pc="WS";const Ic="NL";const Dc="OPENBRACE";const Hc="CLOSEBRACE";const jc="OPENBRACKET";const _c="CLOSEBRACKET";const zc="OPENPAREN";const Bc="CLOSEPAREN";const Fc="OPENANGLEBRACKET";const Uc="CLOSEANGLEBRACKET";const qc="FULLWIDTHLEFTPAREN";const Jc="FULLWIDTHRIGHTPAREN";const Kc="LEFTCORNERBRACKET";const Wc="RIGHTCORNERBRACKET";const Vc="LEFTWHITECORNERBRACKET";const Gc="RIGHTWHITECORNERBRACKET";const Zc="FULLWIDTHLESSTHAN";const Qc="FULLWIDTHGREATERTHAN";const Xc="AMPERSAND";const Yc="APOSTROPHE";const td="ASTERISK";const ed="AT";const rd="BACKSLASH";const nd="BACKTICK";const id="CARET";const sd="COLON";const od="COMMA";const ld="DOLLAR";const ud="DOT";const ad="EQUALS";const fd="EXCLAMATION";const hd="HYPHEN";const cd="PERCENT";const dd="PIPE";const pd="PLUS";const md="POUND";const gd="QUERY";const wd="QUOTE";const bd="FULLWIDTHMIDDLEDOT";const kd="SEMI";const vd="SLASH";const yd="TILDE";const Md="UNDERSCORE";const xd="EMOJI";const Sd="SYM";var Td=Object.freeze({__proto__:null,ALPHANUMERICAL:$c,AMPERSAND:Xc,APOSTROPHE:Yc,ASCIINUMERICAL:Ec,ASTERISK:td,AT:ed,BACKSLASH:rd,BACKTICK:nd,CARET:id,CLOSEANGLEBRACKET:Uc,CLOSEBRACE:Hc,CLOSEBRACKET:_c,CLOSEPAREN:Bc,COLON:sd,COMMA:od,DOLLAR:ld,DOT:ud,EMOJI:xd,EQUALS:ad,EXCLAMATION:fd,FULLWIDTHGREATERTHAN:Qc,FULLWIDTHLEFTPAREN:qc,FULLWIDTHLESSTHAN:Zc,FULLWIDTHMIDDLEDOT:bd,FULLWIDTHRIGHTPAREN:Jc,HYPHEN:hd,LEFTCORNERBRACKET:Kc,LEFTWHITECORNERBRACKET:Vc,LOCALHOST:Ac,NL:Ic,NUM:Nc,OPENANGLEBRACKET:Fc,OPENBRACE:Dc,OPENBRACKET:jc,OPENPAREN:zc,PERCENT:cd,PIPE:dd,PLUS:pd,POUND:md,QUERY:gd,QUOTE:wd,RIGHTCORNERBRACKET:Wc,RIGHTWHITECORNERBRACKET:Gc,SCHEME:Cc,SEMI:kd,SLASH:vd,SLASH_SCHEME:Lc,SYM:Sd,TILDE:yd,TLD:Oc,UNDERSCORE:Md,UTLD:Rc,UWORD:Tc,WORD:Sc,WS:Pc});const Ed=/[a-z]/;const $d=/\p{L}/u;const Ad=/\p{Emoji}/u;const Od=/\d/;const Rd=/\s/;const Cd="\r";const Ld="\n";const Nd="️";const Pd="‍";const Id="";let Dd=null,Hd=null;function jd(t=[]){const e={};kc.groups=e;const r=new kc;if(Dd==null){Dd=Fd(ic)}if(Hd==null){Hd=Fd(sc)}xc(r,"'",Yc);xc(r,"{",Dc);xc(r,"}",Hc);xc(r,"[",jc);xc(r,"]",_c);xc(r,"(",zc);xc(r,")",Bc);xc(r,"<",Fc);xc(r,">",Uc);xc(r,"(",qc);xc(r,")",Jc);xc(r,"「",Kc);xc(r,"」",Wc);xc(r,"『",Vc);xc(r,"』",Gc);xc(r,"<",Zc);xc(r,">",Qc);xc(r,"&",Xc);xc(r,"*",td);xc(r,"@",ed);xc(r,"`",nd);xc(r,"^",id);xc(r,":",sd);xc(r,",",od);xc(r,"$",ld);xc(r,".",ud);xc(r,"=",ad);xc(r,"!",fd);xc(r,"-",hd);xc(r,"%",cd);xc(r,"|",dd);xc(r,"+",pd);xc(r,"#",md);xc(r,"?",gd);xc(r,'"',wd);xc(r,"/",vd);xc(r,";",kd);xc(r,"~",yd);xc(r,"_",Md);xc(r,"\\",rd);xc(r,"・",bd);const n=yc(r,Od,Nc,{[oc]:true});yc(n,Od,n);const i=yc(n,Ed,Ec,{[ac]:true});const s=yc(n,$d,$c,{[fc]:true});const o=yc(r,Ed,Sc,{[lc]:true});yc(o,Od,i);yc(o,Ed,o);yc(i,Od,i);yc(i,Ed,i);const l=yc(r,$d,Tc,{[uc]:true});yc(l,Ed);yc(l,Od,s);yc(l,$d,l);yc(s,Od,s);yc(s,Ed);yc(s,$d,s);const u=xc(r,Ld,Ic,{[mc]:true});const a=xc(r,Cd,Pc,{[mc]:true});const f=yc(r,Rd,Pc,{[mc]:true});xc(r,Id,f);xc(a,Ld,u);xc(a,Id,f);yc(a,Rd,f);xc(f,Cd);xc(f,Ld);yc(f,Rd,f);xc(f,Id,f);const h=yc(r,Ad,xd,{[cc]:true});xc(h,"#");yc(h,Ad,h);xc(h,Nd,h);const c=xc(h,Pd);xc(c,"#");yc(c,Ad,h);const d=[[Ed,o],[Od,i]];const p=[[Ed,null],[$d,l],[Od,s]];for(let t=0;t<Dd.length;t++){Bd(r,Dd[t],Oc,Sc,d)}for(let t=0;t<Hd.length;t++){Bd(r,Hd[t],Rc,Tc,p)}wc(Oc,{tld:true,ascii:true},e);wc(Rc,{utld:true,alpha:true},e);Bd(r,"file",Cc,Sc,d);Bd(r,"mailto",Cc,Sc,d);Bd(r,"http",Lc,Sc,d);Bd(r,"https",Lc,Sc,d);Bd(r,"ftp",Lc,Sc,d);Bd(r,"ftps",Lc,Sc,d);wc(Cc,{scheme:true,ascii:true},e);wc(Lc,{slashscheme:true,ascii:true},e);t=t.sort(((t,e)=>t[0]>e[0]?1:-1));for(let e=0;e<t.length;e++){const n=t[e][0];const i=t[e][1];const s=i?{[dc]:true}:{[pc]:true};if(n.indexOf("-")>=0){s[hc]=true}else if(!Ed.test(n)){s[oc]=true}else if(Od.test(n)){s[ac]=true}else{s[lc]=true}Mc(r,n,n,s)}Mc(r,"localhost",Ac,{ascii:true});r.jd=new kc(Sd);return{start:r,tokens:Object.assign({groups:e},Td)}}function _d(t,e){const r=zd(e.replace(/[A-Z]/g,(t=>t.toLowerCase())));const n=r.length;const i=[];let s=0;let o=0;while(o<n){let l=t;let u=null;let a=0;let f=null;let h=-1;let c=-1;while(o<n&&(u=l.go(r[o]))){l=u;if(l.accepts()){h=0;c=0;f=l}else if(h>=0){h+=r[o].length;c++}a+=r[o].length;s+=r[o].length;o++}s-=h;o-=c;a-=h;i.push({t:f.t,v:e.slice(s-a,s),s:s-a,e:s})}return i}function zd(t){const e=[];const r=t.length;let n=0;while(n<r){let i=t.charCodeAt(n);let s;let o=i<55296||i>56319||n+1===r||(s=t.charCodeAt(n+1))<56320||s>57343?t[n]:t.slice(n,n+2);e.push(o);n+=o.length}return e}function Bd(t,e,r,n,i){let s;const o=e.length;for(let r=0;r<o-1;r++){const o=e[r];if(t.j[o]){s=t.j[o]}else{s=new kc(n);s.jr=i.slice();t.j[o]=s}t=s}s=new kc(r);s.jr=i.slice();t.j[e[o-1]]=s;return s}function Fd(t){const e=[];const r=[];let n=0;let i="0123456789";while(n<t.length){let s=0;while(i.indexOf(t[n+s])>=0){s++}if(s>0){e.push(r.join(""));for(let e=parseInt(t.substring(n,n+s),10);e>0;e--){r.pop()}n+=s}else{r.push(t[n]);n++}}return e}const Ud={defaultProtocol:"http",events:null,format:Jd,formatHref:Jd,nl2br:false,tagName:"a",target:null,rel:null,validate:true,truncate:Infinity,className:null,attributes:null,ignoreTags:[],render:null};function qd(t,e=null){let r=Object.assign({},Ud);if(t){r=Object.assign(r,t instanceof qd?t.o:t)}const n=r.ignoreTags;const i=[];for(let t=0;t<n.length;t++){i.push(n[t].toUpperCase())}this.o=r;if(e){this.defaultRender=e}this.ignoreTags=i}qd.prototype={o:Ud,ignoreTags:[],defaultRender(t){return t},check(t){return this.get("validate",t.toString(),t)},get(t,e,r){const n=e!=null;let i=this.o[t];if(!i){return i}if(typeof i==="object"){i=r.t in i?i[r.t]:Ud[t];if(typeof i==="function"&&n){i=i(e,r)}}else if(typeof i==="function"&&n){i=i(e,r.t,r)}return i},getObj(t,e,r){let n=this.o[t];if(typeof n==="function"&&e!=null){n=n(e,r.t,r)}return n},render(t){const e=t.render(this);const r=this.get("render",null,t)||this.defaultRender;return r(e,t.t,t)}};function Jd(t){return t}function Kd(t,e){this.t="token";this.v=t;this.tk=e}Kd.prototype={isLink:false,toString(){return this.v},toHref(t){return this.toString()},toFormattedString(t){const e=this.toString();const r=t.get("truncate",e,this);const n=t.get("format",e,this);return r&&n.length>r?n.substring(0,r)+"…":n},toFormattedHref(t){return t.get("formatHref",this.toHref(t.get("defaultProtocol")),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(t=Ud.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(t),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(t){return{type:this.t,value:this.toFormattedString(t),isLink:this.isLink,href:this.toFormattedHref(t),start:this.startIndex(),end:this.endIndex()}},validate(t){return t.get("validate",this.toString(),this)},render(t){const e=this;const r=this.toHref(t.get("defaultProtocol"));const n=t.get("formatHref",r,this);const i=t.get("tagName",r,e);const s=this.toFormattedString(t);const o={};const l=t.get("className",r,e);const u=t.get("target",r,e);const a=t.get("rel",r,e);const f=t.getObj("attributes",r,e);const h=t.getObj("events",r,e);o.href=n;if(l){o.class=l}if(u){o.target=u}if(a){o.rel=a}if(f){Object.assign(o,f)}return{tagName:i,attributes:o,content:s,eventListeners:h}}};function Wd(t,e){class r extends Kd{constructor(e,r){super(e,r);this.t=t}}for(const t in e){r.prototype[t]=e[t]}r.t=t;return r}const Vd=Wd("email",{isLink:true,toHref(){return"mailto:"+this.toString()}});const Gd=Wd("text");const Zd=Wd("nl");const Qd=Wd("url",{isLink:true,toHref(t=Ud.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==Ac&&t[1].t===sd}});const Xd=t=>new kc(t);function Yd({groups:t}){const e=t.domain.concat([Xc,td,ed,rd,nd,id,ld,ad,hd,Nc,cd,dd,pd,md,vd,Sd,yd,Md]);const r=[Yc,sd,od,ud,fd,cd,gd,wd,kd,Fc,Uc,Dc,Hc,_c,jc,zc,Bc,qc,Jc,Kc,Wc,Vc,Gc,Zc,Qc];const n=[Xc,Yc,td,rd,nd,id,ld,ad,hd,Dc,Hc,cd,dd,pd,md,gd,vd,Sd,yd,Md];const i=Xd();const s=xc(i,yd);vc(s,n,s);vc(s,t.domain,s);const o=Xd(),l=Xd(),u=Xd();vc(i,t.domain,o);vc(i,t.scheme,l);vc(i,t.slashscheme,u);vc(o,n,s);vc(o,t.domain,o);const a=xc(o,ed);xc(s,ed,a);xc(l,ed,a);xc(u,ed,a);const f=xc(s,ud);vc(f,n,s);vc(f,t.domain,s);const h=Xd();vc(a,t.domain,h);vc(h,t.domain,h);const c=xc(h,ud);vc(c,t.domain,h);const d=Xd(Vd);vc(c,t.tld,d);vc(c,t.utld,d);xc(a,Ac,d);const p=xc(h,hd);xc(p,hd,p);vc(p,t.domain,h);vc(d,t.domain,h);xc(d,ud,c);xc(d,hd,p);const m=xc(d,sd);vc(m,t.numeric,Vd);const g=xc(o,hd);const w=xc(o,ud);xc(g,hd,g);vc(g,t.domain,o);vc(w,n,s);vc(w,t.domain,o);const b=Xd(Qd);vc(w,t.tld,b);vc(w,t.utld,b);vc(b,t.domain,o);vc(b,n,s);xc(b,ud,w);xc(b,hd,g);xc(b,ed,a);const k=xc(b,sd);const v=Xd(Qd);vc(k,t.numeric,v);const y=Xd(Qd);const M=Xd();vc(y,e,y);vc(y,r,M);vc(M,e,y);vc(M,r,M);xc(b,vd,y);xc(v,vd,y);const x=xc(l,sd);const S=xc(u,sd);const T=xc(S,vd);const E=xc(T,vd);vc(l,t.domain,o);xc(l,ud,w);xc(l,hd,g);vc(u,t.domain,o);xc(u,ud,w);xc(u,hd,g);vc(x,t.domain,y);xc(x,vd,y);xc(x,gd,y);vc(E,t.domain,y);vc(E,e,y);xc(E,vd,y);const $=[[Dc,Hc],[jc,_c],[zc,Bc],[Fc,Uc],[qc,Jc],[Kc,Wc],[Vc,Gc],[Zc,Qc]];for(let t=0;t<$.length;t++){const[n,i]=$[t];const s=xc(y,n);xc(M,n,s);xc(s,i,y);const o=Xd(Qd);vc(s,e,o);const l=Xd();vc(s,r);vc(o,e,o);vc(o,r,l);vc(l,e,o);vc(l,r,l);xc(o,i,y);xc(l,i,y)}xc(i,Ac,b);xc(i,Ic,Zd);return{start:i,tokens:Td}}function tp(t,e,r){let n=r.length;let i=0;let s=[];let o=[];while(i<n){let l=t;let u=null;let a=null;let f=0;let h=null;let c=-1;while(i<n&&!(u=l.go(r[i].t))){o.push(r[i++])}while(i<n&&(a=u||l.go(r[i].t))){u=null;l=a;if(l.accepts()){c=0;h=l}else if(c>=0){c++}i++;f++}if(c<0){i-=f;if(i<n){o.push(r[i]);i++}}else{if(o.length>0){s.push(ep(Gd,e,o));o=[]}i-=c;f-=c;const t=h.t;const n=r.slice(i-f,i);s.push(ep(t,e,n))}}if(o.length>0){s.push(ep(Gd,e,o))}return s}function ep(t,e,r){const n=r[0].s;const i=r[r.length-1].e;const s=e.slice(n,i);return new t(s,r)}const rp=typeof console!=="undefined"&&console&&console.warn||(()=>{});const np="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.";const ip={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:false};function sp(){kc.groups={};ip.scanner=null;ip.parser=null;ip.tokenQueue=[];ip.pluginQueue=[];ip.customSchemes=[];ip.initialized=false;return ip}function op(t,e=false){if(ip.initialized){rp(`linkifyjs: already initialized - will not register custom scheme "${t}" ${np}`)}if(!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(t)){throw new Error(`linkifyjs: incorrect scheme format.\n1. Must only contain digits, lowercase ASCII letters or "-"\n2. Cannot start or end with "-"\n3. "-" cannot repeat`)}ip.customSchemes.push([t,e])}function lp(){ip.scanner=jd(ip.customSchemes);for(let t=0;t<ip.tokenQueue.length;t++){ip.tokenQueue[t][1]({scanner:ip.scanner})}ip.parser=Yd(ip.scanner.tokens);for(let t=0;t<ip.pluginQueue.length;t++){ip.pluginQueue[t][1]({scanner:ip.scanner,parser:ip.parser})}ip.initialized=true;return ip}function up(t){if(!ip.initialized){lp()}return tp(ip.parser.start,t,_d(ip.scanner.start,t))}up.scan=_d;function ap(t,e=null,r=null){if(e&&typeof e==="object"){if(r){throw Error(`linkifyjs: Invalid link type ${e}; must be a string`)}r=e;e=null}const n=new qd(r);const i=up(t);const s=[];for(let t=0;t<i.length;t++){const r=i[t];if(r.isLink&&(!e||r.t===e)&&n.check(r)){s.push(r.toFormattedObject(n))}}return s}var fp="[\0-   ᠎ -\u2029  ]";var hp=new RegExp(fp);var cp=new RegExp(`${fp}$`);var dp=new RegExp(fp,"g");function pp(t){if(t.length===1){return t[0].isLink}if(t.length===3&&t[1].isLink){return["()","[]"].includes(t[0].value+t[2].value)}return false}function mp(t){return new br({key:new yr("autolink"),appendTransaction:(e,r,n)=>{const i=e.some((t=>t.docChanged))&&!r.doc.eq(n.doc);const s=e.some((t=>t.getMeta("preventAutolink")));if(!i||s){return}const{tr:o}=n;const l=fa(r.doc,[...e]);const u=Ba(l);u.forEach((({newRange:e})=>{const r=ca(n.doc,e,(t=>t.isTextblock));let i;let s;if(r.length>1){i=r[0];s=n.doc.textBetween(i.pos,i.pos+i.node.nodeSize,void 0," ")}else if(r.length){const t=n.doc.textBetween(e.from,e.to," "," ");if(!cp.test(t)){return}i=r[0];s=n.doc.textBetween(i.pos,e.to,void 0," ")}if(i&&s){const e=s.split(hp).filter(Boolean);if(e.length<=0){return false}const r=e[e.length-1];const l=i.pos+s.lastIndexOf(r);if(!r){return false}const u=up(r).map((e=>e.toObject(t.defaultProtocol)));if(!pp(u)){return false}u.filter((t=>t.isLink)).map((t=>({...t,from:l+t.start+1,to:l+t.end+1}))).filter((t=>{if(!n.schema.marks.code){return true}return!n.doc.rangeHasMark(t.from,t.to,n.schema.marks.code)})).filter((e=>t.validate(e.value))).filter((e=>t.shouldAutoLink(e.value))).forEach((e=>{if(Fa(e.from,e.to,n.doc).some((e=>e.mark.type===t.type))){return}o.addMark(e.from,e.to,t.type.create({href:e.href}))}))}}));if(!o.steps.length){return}return o}})}function gp(t){return new br({key:new yr("handleClickLink"),props:{handleClick:(e,r,n)=>{var i,s;if(n.button!==0){return false}if(!e.editable){return false}let o=null;if(n.target instanceof HTMLAnchorElement){o=n.target}else{let t=n.target;const e=[];while(t.nodeName!=="DIV"){e.push(t);t=t.parentNode}o=e.find((t=>t.nodeName==="A"))}if(!o){return false}const l=ja(e.state,t.type.name);const u=(i=o==null?void 0:o.href)!=null?i:l.href;const a=(s=o==null?void 0:o.target)!=null?s:l.target;if(t.enableClickSelection){t.editor.commands.extendMarkRange(t.type.name)}if(o&&u){window.open(u,a);return true}return false}}})}function wp(t){return new br({key:new yr("handlePasteLink"),props:{handlePaste:(e,r,n)=>{const{shouldAutoLink:i}=t;const{state:s}=e;const{selection:o}=s;const{empty:l}=o;if(l){return false}let u="";n.content.forEach((t=>{u+=t.textContent}));const a=ap(u,{defaultProtocol:t.defaultProtocol}).find((t=>t.isLink&&t.value===u));if(!u||!a||i!==void 0&&!i(a.href)){return false}return t.editor.commands.setMark(t.type,{href:a.href})}}})}function bp(t,e){const r=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];if(e){e.forEach((t=>{const e=typeof t==="string"?t:t.scheme;if(e){r.push(e)}}))}return!t||t.replace(dp,"").match(new RegExp(`^(?:(?:${r.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var kp=Nf.create({name:"link",priority:1e3,keepOnSplit:false,exitable:true,onCreate(){if(this.options.validate&&!this.options.shouldAutoLink){this.options.shouldAutoLink=this.options.validate;console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")}this.options.protocols.forEach((t=>{if(typeof t==="string"){op(t);return}op(t.scheme,t.optionalSlashes)}))},onDestroy(){sp()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:true,enableClickSelection:false,linkOnPaste:true,autolink:true,protocols:[],defaultProtocol:"http",HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},isAllowedUri:(t,e)=>!!bp(t,e.protocols),validate:t=>!!t,shouldAutoLink:t=>!!t}},addAttributes(){return{href:{default:null,parseHTML(t){return t.getAttribute("href")}},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class}}},parseHTML(){return[{tag:"a[href]",getAttrs:t=>{const e=t.getAttribute("href");if(!e||!this.options.isAllowedUri(e,{defaultValidate:t=>!!bp(t,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})){return false}return null}}]},renderHTML({HTMLAttributes:t}){if(!this.options.isAllowedUri(t.href,{defaultValidate:t=>!!bp(t,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})){return["a",xa(this.options.HTMLAttributes,{...t,href:""}),0]}return["a",xa(this.options.HTMLAttributes,t),0]},markdownTokenName:"link",parseMarkdown:(t,e)=>e.applyMark("link",e.parseInline(t.tokens||[]),{href:t.href,title:t.title||null}),renderMarkdown:(t,e)=>{var r;const n=((r=t.attrs)==null?void 0:r.href)||"";const i=e.renderChildren(t);return`[${i}](${n})`},addCommands(){return{setLink:t=>({chain:e})=>{const{href:r}=t;if(!this.options.isAllowedUri(r,{defaultValidate:t=>!!bp(t,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})){return false}return e().setMark(this.name,t).setMeta("preventAutolink",true).run()},toggleLink:t=>({chain:e})=>{const{href:r}=t||{};if(r&&!this.options.isAllowedUri(r,{defaultValidate:t=>!!bp(t,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})){return false}return e().toggleMark(this.name,t,{extendEmptyMarkRange:true}).setMeta("preventAutolink",true).run()},unsetLink:()=>({chain:t})=>t().unsetMark(this.name,{extendEmptyMarkRange:true}).setMeta("preventAutolink",true).run()}},addPasteRules(){return[yh({find:t=>{const e=[];if(t){const{protocols:r,defaultProtocol:n}=this.options;const i=ap(t).filter((t=>t.isLink&&this.options.isAllowedUri(t.value,{defaultValidate:t=>!!bp(t,r),protocols:r,defaultProtocol:n})));if(i.length){i.forEach((t=>{if(!this.options.shouldAutoLink(t.value)){return}e.push({text:t.value,data:{href:t.href},index:t.start})}))}}return e},type:this.type,getAttributes:t=>{var e;return{href:(e=t.data)==null?void 0:e.href}}})]},addProseMirrorPlugins(){const t=[];const{protocols:e,defaultProtocol:r}=this.options;if(this.options.autolink){t.push(mp({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:t=>this.options.isAllowedUri(t,{defaultValidate:t=>!!bp(t,e),protocols:e,defaultProtocol:r}),shouldAutoLink:this.options.shouldAutoLink}))}if(this.options.openOnClick===true){t.push(gp({type:this.type,editor:this.editor,enableClickSelection:this.options.enableClickSelection}))}if(this.options.linkOnPaste){t.push(wp({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink}))}return t}});var vp=kp;var yp=Object.defineProperty;var Mp=(t,e)=>{for(var r in e)yp(t,r,{get:e[r],enumerable:true})};var xp="listItem";var Sp="textStyle";var Tp=/^\s*([-+*])\s$/;var Ep=vh.create({name:"bulletList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:false,keepAttributes:false}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:"ul"}]},renderHTML({HTMLAttributes:t}){return["ul",xa(this.options.HTMLAttributes,t),0]},markdownTokenName:"list",parseMarkdown:(t,e)=>{if(t.type!=="list"||t.ordered){return[]}return{type:"bulletList",content:t.items?e.parseChildren(t.items):[]}},renderMarkdown:(t,e)=>{if(!t.content){return""}return e.renderChildren(t.content,"\n")},markdownOptions:{indentsContent:true},addCommands(){return{toggleBulletList:()=>({commands:t,chain:e})=>{if(this.options.keepAttributes){return e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(xp,this.editor.getAttributes(Sp)).run()}return t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=lh({find:Tp,type:this.type});if(this.options.keepMarks||this.options.keepAttributes){t=lh({find:Tp,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(Sp),editor:this.editor})}return[t]}});var $p=vh.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:true,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",xa(this.options.HTMLAttributes,t),0]},markdownTokenName:"list_item",parseMarkdown:(t,e)=>{if(t.type!=="list_item"){return[]}let r=[];if(t.tokens&&t.tokens.length>0){const n=t.tokens.some((t=>t.type==="paragraph"));if(n){r=e.parseChildren(t.tokens)}else{const n=t.tokens[0];if(n&&n.type==="text"&&n.tokens&&n.tokens.length>0){const i=e.parseInline(n.tokens);r=[{type:"paragraph",content:i}];if(t.tokens.length>1){const n=t.tokens.slice(1);const i=e.parseChildren(n);r.push(...i)}}else{r=e.parseChildren(t.tokens)}}}if(r.length===0){r=[{type:"paragraph",content:[]}]}return{type:"listItem",content:r}},renderMarkdown:(t,e,r)=>bh(t,e,(t=>{if(t.parentType==="bulletList"){return"- "}if(t.parentType==="orderedList"){return`${t.index+1}. `}return"- "}),r),addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}});var Ap={};Mp(Ap,{findListItemPos:()=>Op,getNextListDepth:()=>Rp,handleBackspace:()=>Pp,handleDelete:()=>Hp,hasListBefore:()=>Cp,hasListItemAfter:()=>jp,hasListItemBefore:()=>Lp,listItemHasSubList:()=>Np,nextListIsDeeper:()=>Ip,nextListIsHigher:()=>Dp});var Op=(t,e)=>{const{$from:r}=e.selection;const n=lu(t,e.schema);let i=null;let s=r.depth;let o=r.pos;let l=null;while(s>0&&l===null){i=r.node(s);if(i.type===n){l=s}else{s-=1;o-=1}}if(l===null){return null}return{$pos:e.doc.resolve(o),depth:l}};var Rp=(t,e)=>{const r=Op(t,e);if(!r){return false}const[,n]=Ua(e,t,r.$pos.pos+4);return n};var Cp=(t,e,r)=>{const{$anchor:n}=t.selection;const i=Math.max(0,n.pos-2);const s=t.doc.resolve(i).node();if(!s||!r.includes(s.type.name)){return false}return true};var Lp=(t,e)=>{var r;const{$anchor:n}=e.selection;const i=e.doc.resolve(n.pos-2);if(i.index()===0){return false}if(((r=i.nodeBefore)==null?void 0:r.type.name)!==t){return false}return true};var Np=(t,e,r)=>{if(!r){return false}const n=lu(t,e.schema);let i=false;r.descendants((t=>{if(t.type===n){i=true}}));return i};var Pp=(t,e,r)=>{if(t.commands.undoInputRule()){return true}if(t.state.selection.from!==t.state.selection.to){return false}if(!Ku(t.state,e)&&Cp(t.state,e,r)){const{$anchor:r}=t.state.selection;const n=t.state.doc.resolve(r.before()-1);const i=[];n.node().descendants(((t,r)=>{if(t.type.name===e){i.push({node:t,pos:r})}}));const s=i.at(-1);if(!s){return false}const o=t.state.doc.resolve(n.start()+s.pos+1);return t.chain().cut({from:r.start()-1,to:r.end()+1},o.end()).joinForward().run()}if(!Ku(t.state,e)){return false}if(!Za(t.state)){return false}const n=Op(e,t.state);if(!n){return false}const i=t.state.doc.resolve(n.$pos.pos-2);const s=i.node(n.depth);const o=Np(e,t.state,s);if(Lp(e,t.state)&&!o){return t.commands.joinItemBackward()}return t.chain().liftListItem(e).run()};var Ip=(t,e)=>{const r=Rp(t,e);const n=Op(t,e);if(!n||!r){return false}if(r>n.depth){return true}return false};var Dp=(t,e)=>{const r=Rp(t,e);const n=Op(t,e);if(!n||!r){return false}if(r<n.depth){return true}return false};var Hp=(t,e)=>{if(!Ku(t.state,e)){return false}if(!Ga(t.state,e)){return false}const{selection:r}=t.state;const{$from:n,$to:i}=r;if(!r.empty&&n.sameParent(i)){return false}if(Ip(e,t.state)){return t.chain().focus(t.state.selection.from+4).lift(e).joinBackward().run()}if(Dp(e,t.state)){return t.chain().joinForward().joinBackward().run()}return t.commands.joinItemForward()};var jp=(t,e)=>{var r;const{$anchor:n}=e.selection;const i=e.doc.resolve(n.pos-n.parentOffset-2);if(i.index()===i.parent.childCount-1){return false}if(((r=i.nodeAfter)==null?void 0:r.type.name)!==t){return false}return true};var _p=Uf.create({name:"listKeymap",addOptions(){return{listTypes:[{itemName:"listItem",wrapperNames:["bulletList","orderedList"]},{itemName:"taskItem",wrapperNames:["taskList"]}]}},addKeyboardShortcuts(){return{Delete:({editor:t})=>{let e=false;this.options.listTypes.forEach((({itemName:r})=>{if(t.state.schema.nodes[r]===void 0){return}if(Hp(t,r)){e=true}}));return e},"Mod-Delete":({editor:t})=>{let e=false;this.options.listTypes.forEach((({itemName:r})=>{if(t.state.schema.nodes[r]===void 0){return}if(Hp(t,r)){e=true}}));return e},Backspace:({editor:t})=>{let e=false;this.options.listTypes.forEach((({itemName:r,wrapperNames:n})=>{if(t.state.schema.nodes[r]===void 0){return}if(Pp(t,r,n)){e=true}}));return e},"Mod-Backspace":({editor:t})=>{let e=false;this.options.listTypes.forEach((({itemName:r,wrapperNames:n})=>{if(t.state.schema.nodes[r]===void 0){return}if(Pp(t,r,n)){e=true}}));return e}}}});var zp=/^(\s*)(\d+)\.\s+(.*)$/;var Bp=/^\s/;function Fp(t){const e=[];let r=0;let n=0;while(r<t.length){const i=t[r];const s=i.match(zp);if(!s){break}const[,o,l,u]=s;const a=o.length;let f=u;let h=r+1;const c=[i];while(h<t.length){const e=t[h];const r=e.match(zp);if(r){break}if(e.trim()===""){c.push(e);f+="\n";h+=1}else if(e.match(Bp)){c.push(e);f+=`\n${e.slice(a+2)}`;h+=1}else{break}}e.push({indent:a,number:parseInt(l,10),content:f.trim(),raw:c.join("\n")});n=h;r=h}return[e,n]}function Up(t,e,r){var n;const i=[];let s=0;while(s<t.length){const o=t[s];if(o.indent===e){const l=o.content.split("\n");const u=((n=l[0])==null?void 0:n.trim())||"";const a=[];if(u){a.push({type:"paragraph",raw:u,tokens:r.inlineTokens(u)})}const f=l.slice(1).join("\n").trim();if(f){const t=r.blockTokens(f);a.push(...t)}let h=s+1;const c=[];while(h<t.length&&t[h].indent>e){c.push(t[h]);h+=1}if(c.length>0){const t=Math.min(...c.map((t=>t.indent)));const e=Up(c,t,r);a.push({type:"list",ordered:true,start:c[0].number,items:e,raw:c.map((t=>t.raw)).join("\n")})}i.push({type:"list_item",raw:o.raw,tokens:a});s=h}else{s+=1}}return i}function qp(t,e){return t.map((t=>{if(t.type!=="list_item"){return e.parseChildren([t])[0]}const r=[];if(t.tokens&&t.tokens.length>0){t.tokens.forEach((t=>{if(t.type==="paragraph"||t.type==="list"||t.type==="blockquote"||t.type==="code"){r.push(...e.parseChildren([t]))}else if(t.type==="text"&&t.tokens){const n=e.parseChildren([t]);r.push({type:"paragraph",content:n})}else{const n=e.parseChildren([t]);if(n.length>0){r.push(...n)}}}))}return{type:"listItem",content:r}}))}var Jp="listItem";var Kp="textStyle";var Wp=/^(\d+)\.\s$/;var Vp=vh.create({name:"orderedList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:false,keepAttributes:false}},group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:t=>t.hasAttribute("start")?parseInt(t.getAttribute("start")||"",10):1},type:{default:null,parseHTML:t=>t.getAttribute("type")}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:t}){const{start:e,...r}=t;return e===1?["ol",xa(this.options.HTMLAttributes,r),0]:["ol",xa(this.options.HTMLAttributes,t),0]},markdownTokenName:"list",parseMarkdown:(t,e)=>{if(t.type!=="list"||!t.ordered){return[]}const r=t.start||1;const n=t.items?qp(t.items,e):[];if(r!==1){return{type:"orderedList",attrs:{start:r},content:n}}return{type:"orderedList",content:n}},renderMarkdown:(t,e)=>{if(!t.content){return""}return e.renderChildren(t.content,"\n")},markdownTokenizer:{name:"orderedList",level:"block",start:t=>{const e=t.match(/^(\s*)(\d+)\.\s+/);const r=e==null?void 0:e.index;return r!==void 0?r:-1},tokenize:(t,e,r)=>{var n;const i=t.split("\n");const[s,o]=Fp(i);if(s.length===0){return void 0}const l=Up(s,0,r);if(l.length===0){return void 0}const u=((n=s[0])==null?void 0:n.number)||1;return{type:"list",ordered:true,start:u,items:l,raw:i.slice(0,o).join("\n")}}},markdownOptions:{indentsContent:true},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:e})=>{if(this.options.keepAttributes){return e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(Jp,this.editor.getAttributes(Kp)).run()}return t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=lh({find:Wp,type:this.type,getAttributes:t=>({start:+t[1]}),joinPredicate:(t,e)=>e.childCount+e.attrs.start===+t[1]});if(this.options.keepMarks||this.options.keepAttributes){t=lh({find:Wp,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:t=>({start:+t[1],...this.editor.getAttributes(Kp)}),joinPredicate:(t,e)=>e.childCount+e.attrs.start===+t[1],editor:this.editor})}return[t]}});var Gp=/^\s*(\[([( |x])?\])\s$/;var Zp=vh.create({name:"taskItem",addOptions(){return{nested:false,HTMLAttributes:{},taskListTypeName:"taskList",a11y:void 0}},content(){return this.options.nested?"paragraph block*":"paragraph+"},defining:true,addAttributes(){return{checked:{default:false,keepOnSplit:false,parseHTML:t=>{const e=t.getAttribute("data-checked");return e===""||e==="true"},renderHTML:t=>({"data-checked":t.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51}]},renderHTML({node:t,HTMLAttributes:e}){return["li",xa(this.options.HTMLAttributes,e,{"data-type":this.name}),["label",["input",{type:"checkbox",checked:t.attrs.checked?"checked":null}],["span"]],["div",0]]},parseMarkdown:(t,e)=>{const r=[];if(t.tokens&&t.tokens.length>0){r.push(e.createNode("paragraph",{},e.parseInline(t.tokens)))}else if(t.text){r.push(e.createNode("paragraph",{},[e.createNode("text",{text:t.text})]))}else{r.push(e.createNode("paragraph",{},[]))}if(t.nestedTokens&&t.nestedTokens.length>0){const n=e.parseChildren(t.nestedTokens);r.push(...n)}return e.createNode("taskItem",{checked:t.checked||false},r)},renderMarkdown:(t,e)=>{var r;const n=((r=t.attrs)==null?void 0:r.checked)?"x":" ";const i=`- [${n}] `;return bh(t,e,i)},addKeyboardShortcuts(){const t={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};if(!this.options.nested){return t}return{...t,Tab:()=>this.editor.commands.sinkListItem(this.name)}},addNodeView(){return({node:t,HTMLAttributes:e,getPos:r,editor:n})=>{const i=document.createElement("li");const s=document.createElement("label");const o=document.createElement("span");const l=document.createElement("input");const u=document.createElement("div");const a=t=>{var e,r;l.ariaLabel=((r=(e=this.options.a11y)==null?void 0:e.checkboxLabel)==null?void 0:r.call(e,t,l.checked))||`Task item checkbox for ${t.textContent||"empty task item"}`};a(t);s.contentEditable="false";l.type="checkbox";l.addEventListener("mousedown",(t=>t.preventDefault()));l.addEventListener("change",(e=>{if(!n.isEditable&&!this.options.onReadOnlyChecked){l.checked=!l.checked;return}const{checked:i}=e.target;if(n.isEditable&&typeof r==="function"){n.chain().focus(void 0,{scrollIntoView:false}).command((({tr:t})=>{const e=r();if(typeof e!=="number"){return false}const n=t.doc.nodeAt(e);t.setNodeMarkup(e,void 0,{...n==null?void 0:n.attrs,checked:i});return true})).run()}if(!n.isEditable&&this.options.onReadOnlyChecked){if(!this.options.onReadOnlyChecked(t,i)){l.checked=!l.checked}}}));Object.entries(this.options.HTMLAttributes).forEach((([t,e])=>{i.setAttribute(t,e)}));i.dataset.checked=t.attrs.checked;l.checked=t.attrs.checked;s.append(l,o);i.append(s,u);Object.entries(e).forEach((([t,e])=>{i.setAttribute(t,e)}));return{dom:i,contentDOM:u,update:t=>{if(t.type!==this.type){return false}i.dataset.checked=t.attrs.checked;l.checked=t.attrs.checked;a(t);return true}}}},addInputRules(){return[lh({find:Gp,type:this.type,getAttributes:t=>({checked:t[t.length-1]==="x"})})]}});var Qp=vh.create({name:"taskList",addOptions(){return{itemTypeName:"taskItem",HTMLAttributes:{}}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:t}){return["ul",xa(this.options.HTMLAttributes,t,{"data-type":this.name}),0]},parseMarkdown:(t,e)=>e.createNode("taskList",{},e.parseChildren(t.items||[])),renderMarkdown:(t,e)=>{if(!t.content){return""}return e.renderChildren(t.content,"\n")},markdownTokenizer:{name:"taskList",level:"block",start(t){var e;const r=(e=t.match(/^\s*[-+*]\s+\[([ xX])\]\s+/))==null?void 0:e.index;return r!==void 0?r:-1},tokenize(t,e,r){const n=t=>{const e=wh(t,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:t=>({indentLevel:t[1].length,mainContent:t[4],checked:t[3].toLowerCase()==="x"}),createToken:(t,e)=>({type:"taskItem",raw:"",mainContent:t.mainContent,indentLevel:t.indentLevel,checked:t.checked,text:t.mainContent,tokens:r.inlineTokens(t.mainContent),nestedTokens:e}),customNestedParser:n},r);if(e){return[{type:"taskList",raw:e.raw,items:e.items}]}return r.blockTokens(t)};const i=wh(t,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:t=>({indentLevel:t[1].length,mainContent:t[4],checked:t[3].toLowerCase()==="x"}),createToken:(t,e)=>({type:"taskItem",raw:"",mainContent:t.mainContent,indentLevel:t.indentLevel,checked:t.checked,text:t.mainContent,tokens:r.inlineTokens(t.mainContent),nestedTokens:e}),customNestedParser:n},r);if(!i){return void 0}return{type:"taskList",raw:i.raw,items:i.items}}},markdownOptions:{indentsContent:true},addCommands(){return{toggleTaskList:()=>({commands:t})=>t.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});Uf.create({name:"listKit",addExtensions(){const t=[];if(this.options.bulletList!==false){t.push(Ep.configure(this.options.bulletList))}if(this.options.listItem!==false){t.push($p.configure(this.options.listItem))}if(this.options.listKeymap!==false){t.push(_p.configure(this.options.listKeymap))}if(this.options.orderedList!==false){t.push(Vp.configure(this.options.orderedList))}if(this.options.taskItem!==false){t.push(Zp.configure(this.options.taskItem))}if(this.options.taskList!==false){t.push(Qp.configure(this.options.taskList))}return t}});var Xp=vh.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",xa(this.options.HTMLAttributes,t),0]},parseMarkdown:(t,e)=>{const r=t.tokens||[];if(r.length===1&&r[0].type==="image"){return e.parseChildren([r[0]])}return e.createNode("paragraph",void 0,e.parseInline(r))},renderMarkdown:(t,e)=>{if(!t||!Array.isArray(t.content)){return""}return e.renderChildren(t.content)},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}});var Yp=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/;var tm=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g;var em=Nf.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:false,getAttrs:t=>t.includes("line-through")?{}:false}]},renderHTML({HTMLAttributes:t}){return["s",xa(this.options.HTMLAttributes,t),0]},markdownTokenName:"del",parseMarkdown:(t,e)=>e.applyMark("strike",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`~~${e.renderChildren(t)}~~`,addCommands(){return{setStrike:()=>({commands:t})=>t.setMark(this.name),toggleStrike:()=>({commands:t})=>t.toggleMark(this.name),unsetStrike:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[ih({find:Yp,type:this.type})]},addPasteRules(){return[yh({find:tm,type:this.type})]}});var rm=vh.create({name:"text",group:"inline",parseMarkdown:t=>({type:"text",text:t.text||""}),renderMarkdown:t=>t.text||""});var nm=Nf.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:false,getAttrs:t=>t.includes("underline")?{}:false}]},renderHTML({HTMLAttributes:t}){return["u",xa(this.options.HTMLAttributes,t),0]},parseMarkdown(t,e){return e.applyMark(this.name||"underline",e.parseInline(t.tokens||[]))},renderMarkdown(t,e){return`++${e.renderChildren(t)}++`},markdownTokenizer:{name:"underline",level:"inline",start(t){return t.indexOf("++")},tokenize(t,e,r){const n=/^(\+\+)([\s\S]+?)(\+\+)/;const i=n.exec(t);if(!i){return void 0}const s=i[2].trim();return{type:"underline",raw:i[0],text:s,tokens:r.inlineTokens(s)}}},addCommands(){return{setUnderline:()=>({commands:t})=>t.setMark(this.name),toggleUnderline:()=>({commands:t})=>t.toggleMark(this.name),unsetUnderline:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}});function im(t={}){return new br({view(e){return new sm(e,t)}})}class sm{constructor(t,e){var r;this.editorView=t;this.cursorPos=null;this.element=null;this.timeout=-1;this.width=(r=e.width)!==null&&r!==void 0?r:1;this.color=e.color===false?undefined:e.color||"black";this.class=e.class;this.handlers=["dragover","dragend","drop","dragleave"].map((e=>{let r=t=>{this[e](t)};t.dom.addEventListener(e,r);return{name:e,handler:r}}))}destroy(){this.handlers.forEach((({name:t,handler:e})=>this.editorView.dom.removeEventListener(t,e)))}update(t,e){if(this.cursorPos!=null&&e.doc!=t.state.doc){if(this.cursorPos>t.state.doc.content.size)this.setCursor(null);else this.updateOverlay()}}setCursor(t){if(t==this.cursorPos)return;this.cursorPos=t;if(t==null){this.element.parentNode.removeChild(this.element);this.element=null}else{this.updateOverlay()}}updateOverlay(){let t=this.editorView.state.doc.resolve(this.cursorPos);let e=!t.parent.inlineContent,r;let n=this.editorView.dom,i=n.getBoundingClientRect();let s=i.width/n.offsetWidth,o=i.height/n.offsetHeight;if(e){let e=t.nodeBefore,n=t.nodeAfter;if(e||n){let t=this.editorView.nodeDOM(this.cursorPos-(e?e.nodeSize:0));if(t){let i=t.getBoundingClientRect();let s=e?i.bottom:i.top;if(e&&n)s=(s+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2;let l=this.width/2*o;r={left:i.left,right:i.right,top:s-l,bottom:s+l}}}}if(!r){let t=this.editorView.coordsAtPos(this.cursorPos);let e=this.width/2*s;r={left:t.left-e,right:t.left+e,top:t.top,bottom:t.bottom}}let l=this.editorView.dom.offsetParent;if(!this.element){this.element=l.appendChild(document.createElement("div"));if(this.class)this.element.className=this.class;this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;";if(this.color){this.element.style.backgroundColor=this.color}}this.element.classList.toggle("prosemirror-dropcursor-block",e);this.element.classList.toggle("prosemirror-dropcursor-inline",!e);let u,a;if(!l||l==document.body&&getComputedStyle(l).position=="static"){u=-pageXOffset;a=-pageYOffset}else{let t=l.getBoundingClientRect();let e=t.width/l.offsetWidth,r=t.height/l.offsetHeight;u=t.left-l.scrollLeft*e;a=t.top-l.scrollTop*r}this.element.style.left=(r.left-u)/s+"px";this.element.style.top=(r.top-a)/o+"px";this.element.style.width=(r.right-r.left)/s+"px";this.element.style.height=(r.bottom-r.top)/o+"px"}scheduleRemoval(t){clearTimeout(this.timeout);this.timeout=setTimeout((()=>this.setCursor(null)),t)}dragover(t){if(!this.editorView.editable)return;let e=this.editorView.posAtCoords({left:t.clientX,top:t.clientY});let r=e&&e.inside>=0&&this.editorView.state.doc.nodeAt(e.inside);let n=r&&r.type.spec.disableDropCursor;let i=typeof n=="function"?n(this.editorView,e,t):n;if(e&&!i){let t=e.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let e=Oe(this.editorView.state.doc,t,this.editorView.dragging.slice);if(e!=null)t=e}this.setCursor(t);this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(t){if(!this.editorView.dom.contains(t.relatedTarget))this.setCursor(null)}}class om extends Ze{constructor(t){super(t,t)}map(t,e){let r=t.resolve(e.map(this.head));return om.valid(r)?new om(r):Ze.near(r)}content(){return y.empty}eq(t){return t instanceof om&&t.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(t,e){if(typeof e.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new om(t.resolve(e.pos))}getBookmark(){return new lm(this.anchor)}static valid(t){let e=t.parent;if(e.isTextblock||!um(t)||!am(t))return false;let r=e.type.spec.allowGapCursor;if(r!=null)return r;let n=e.contentMatchAt(t.index()).defaultType;return n&&n.isTextblock}static findGapCursorFrom(t,e,r=false){t:for(;;){if(!r&&om.valid(t))return t;let n=t.pos,i=null;for(let r=t.depth;;r--){let s=t.node(r);if(e>0?t.indexAfter(r)<s.childCount:t.index(r)>0){i=s.child(e>0?t.indexAfter(r):t.index(r)-1);break}else if(r==0){return null}n+=e;let o=t.doc.resolve(n);if(om.valid(o))return o}for(;;){let s=e>0?i.firstChild:i.lastChild;if(!s){if(i.isAtom&&!i.isText&&!rr.isSelectable(i)){t=t.doc.resolve(n+i.nodeSize*e);r=false;continue t}break}i=s;n+=e;let o=t.doc.resolve(n);if(om.valid(o))return o}return null}}}om.prototype.visible=false;om.findFrom=om.findGapCursorFrom;Ze.jsonID("gapcursor",om);class lm{constructor(t){this.pos=t}map(t){return new lm(t.map(this.pos))}resolve(t){let e=t.resolve(this.pos);return om.valid(e)?new om(e):Ze.near(e)}}function um(t){for(let e=t.depth;e>=0;e--){let r=t.index(e),n=t.node(e);if(r==0){if(n.type.spec.isolating)return true;continue}for(let t=n.child(r-1);;t=t.lastChild){if(t.childCount==0&&!t.inlineContent||t.isAtom||t.type.spec.isolating)return true;if(t.inlineContent)return false}}return true}function am(t){for(let e=t.depth;e>=0;e--){let r=t.indexAfter(e),n=t.node(e);if(r==n.childCount){if(n.type.spec.isolating)return true;continue}for(let t=n.child(r);;t=t.firstChild){if(t.childCount==0&&!t.inlineContent||t.isAtom||t.type.spec.isolating)return true;if(t.inlineContent)return false}}return true}function fm(){return new br({props:{decorations:mm,createSelectionBetween(t,e,r){return e.pos==r.pos&&om.valid(r)?new om(r):null},handleClick:dm,handleKeyDown:hm,handleDOMEvents:{beforeinput:pm}}})}const hm=Vl({ArrowLeft:cm("horiz",-1),ArrowRight:cm("horiz",1),ArrowUp:cm("vert",-1),ArrowDown:cm("vert",1)});function cm(t,e){const r=t=="vert"?e>0?"down":"up":e>0?"right":"left";return function(t,n,i){let s=t.selection;let o=e>0?s.$to:s.$from,l=s.empty;if(s instanceof tr){if(!i.endOfTextblock(r)||o.depth==0)return false;l=false;o=t.doc.resolve(e>0?o.after():o.before())}let u=om.findGapCursorFrom(o,e,l);if(!u)return false;if(n)n(t.tr.setSelection(new om(u)));return true}}function dm(t,e,r){if(!t||!t.editable)return false;let n=t.state.doc.resolve(e);if(!om.valid(n))return false;let i=t.posAtCoords({left:r.clientX,top:r.clientY});if(i&&i.inside>-1&&rr.isSelectable(t.state.doc.nodeAt(i.inside)))return false;t.dispatch(t.state.tr.setSelection(new om(n)));return true}function pm(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof om))return false;let{$from:r}=t.state.selection;let n=r.parent.contentMatchAt(r.index()).findWrapping(t.state.schema.nodes.text);if(!n)return false;let i=m.empty;for(let t=n.length-1;t>=0;t--)i=m.from(n[t].createAndFill(null,i));let s=t.state.tr.replace(r.pos,r.pos,new y(i,0,0));s.setSelection(tr.near(s.doc.resolve(r.pos+1)));t.dispatch(s);return false}function mm(t){if(!(t.selection instanceof om))return null;let e=document.createElement("div");e.className="ProseMirror-gapcursor";return Vo.create(t.doc,[Jo.widget(t.selection.head,e,{key:"gapcursor"})])}var gm=200;var wm=function t(){};wm.prototype.append=function t(e){if(!e.length){return this}e=wm.from(e);return!this.length&&e||e.length<gm&&this.leafAppend(e)||this.length<gm&&e.leafPrepend(this)||this.appendInner(e)};wm.prototype.prepend=function t(e){if(!e.length){return this}return wm.from(e).append(this)};wm.prototype.appendInner=function t(e){return new km(this,e)};wm.prototype.slice=function t(e,r){if(e===void 0)e=0;if(r===void 0)r=this.length;if(e>=r){return wm.empty}return this.sliceInner(Math.max(0,e),Math.min(this.length,r))};wm.prototype.get=function t(e){if(e<0||e>=this.length){return undefined}return this.getInner(e)};wm.prototype.forEach=function t(e,r,n){if(r===void 0)r=0;if(n===void 0)n=this.length;if(r<=n){this.forEachInner(e,r,n,0)}else{this.forEachInvertedInner(e,r,n,0)}};wm.prototype.map=function t(e,r,n){if(r===void 0)r=0;if(n===void 0)n=this.length;var i=[];this.forEach((function(t,r){return i.push(e(t,r))}),r,n);return i};wm.from=function t(e){if(e instanceof wm){return e}return e&&e.length?new bm(e):wm.empty};var bm=function(t){function e(e){t.call(this);this.values=e}if(t)e.__proto__=t;e.prototype=Object.create(t&&t.prototype);e.prototype.constructor=e;var r={length:{configurable:true},depth:{configurable:true}};e.prototype.flatten=function t(){return this.values};e.prototype.sliceInner=function t(r,n){if(r==0&&n==this.length){return this}return new e(this.values.slice(r,n))};e.prototype.getInner=function t(e){return this.values[e]};e.prototype.forEachInner=function t(e,r,n,i){for(var s=r;s<n;s++){if(e(this.values[s],i+s)===false){return false}}};e.prototype.forEachInvertedInner=function t(e,r,n,i){for(var s=r-1;s>=n;s--){if(e(this.values[s],i+s)===false){return false}}};e.prototype.leafAppend=function t(r){if(this.length+r.length<=gm){return new e(this.values.concat(r.flatten()))}};e.prototype.leafPrepend=function t(r){if(this.length+r.length<=gm){return new e(r.flatten().concat(this.values))}};r.length.get=function(){return this.values.length};r.depth.get=function(){return 0};Object.defineProperties(e.prototype,r);return e}(wm);wm.empty=new bm([]);var km=function(t){function e(e,r){t.call(this);this.left=e;this.right=r;this.length=e.length+r.length;this.depth=Math.max(e.depth,r.depth)+1}if(t)e.__proto__=t;e.prototype=Object.create(t&&t.prototype);e.prototype.constructor=e;e.prototype.flatten=function t(){return this.left.flatten().concat(this.right.flatten())};e.prototype.getInner=function t(e){return e<this.left.length?this.left.get(e):this.right.get(e-this.left.length)};e.prototype.forEachInner=function t(e,r,n,i){var s=this.left.length;if(r<s&&this.left.forEachInner(e,r,Math.min(n,s),i)===false){return false}if(n>s&&this.right.forEachInner(e,Math.max(r-s,0),Math.min(this.length,n)-s,i+s)===false){return false}};e.prototype.forEachInvertedInner=function t(e,r,n,i){var s=this.left.length;if(r>s&&this.right.forEachInvertedInner(e,r-s,Math.max(n,s)-s,i+s)===false){return false}if(n<s&&this.left.forEachInvertedInner(e,Math.min(r,s),n,i)===false){return false}};e.prototype.sliceInner=function t(e,r){if(e==0&&r==this.length){return this}var n=this.left.length;if(r<=n){return this.left.slice(e,r)}if(e>=n){return this.right.slice(e-n,r-n)}return this.left.slice(e,n).append(this.right.slice(0,r-n))};e.prototype.leafAppend=function t(r){var n=this.right.leafAppend(r);if(n){return new e(this.left,n)}};e.prototype.leafPrepend=function t(r){var n=this.left.leafPrepend(r);if(n){return new e(n,this.right)}};e.prototype.appendInner=function t(r){if(this.left.depth>=Math.max(this.right.depth,r.depth)+1){return new e(this.left,new e(this.right,r))}return new e(this,r)};return e}(wm);const vm=500;class ym{constructor(t,e){this.items=t;this.eventCount=e}popEvent(t,e){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--){let t=this.items.get(r-1);if(t.selection){--r;break}}let n,i;if(e){n=this.remapping(r,this.items.length);i=n.maps.length}let s=t.tr;let o,l;let u=[],a=[];this.items.forEach(((t,e)=>{if(!t.step){if(!n){n=this.remapping(r,e+1);i=n.maps.length}i--;a.push(t);return}if(n){a.push(new xm(t.map));let e=t.step.map(n.slice(i)),r;if(e&&s.maybeStep(e).doc){r=s.mapping.maps[s.mapping.maps.length-1];u.push(new xm(r,undefined,undefined,u.length+a.length))}i--;if(r)n.appendMap(r,i)}else{s.maybeStep(t.step)}if(t.selection){o=n?t.selection.map(n.slice(i)):t.selection;l=new ym(this.items.slice(0,r).append(a.reverse().concat(u)),this.eventCount-1);return false}}),this.items.length,0);return{remaining:l,transform:s,selection:o}}addTransform(t,e,r,n){let i=[],s=this.eventCount;let o=this.items,l=!n&&o.length?o.get(o.length-1):null;for(let r=0;r<t.steps.length;r++){let u=t.steps[r].invert(t.docs[r]);let a=new xm(t.mapping.maps[r],u,e),f;if(f=l&&l.merge(a)){a=f;if(r)i.pop();else o=o.slice(0,o.length-1)}i.push(a);if(e){s++;e=undefined}if(!n)l=a}let u=s-r.depth;if(u>Tm){o=Mm(o,u);s-=u}return new ym(o.append(i),s)}remapping(t,e){let r=new Wt;this.items.forEach(((e,n)=>{let i=e.mirrorOffset!=null&&n-e.mirrorOffset>=t?r.maps.length-e.mirrorOffset:undefined;r.appendMap(e.map,i)}),t,e);return r}addMaps(t){if(this.eventCount==0)return this;return new ym(this.items.append(t.map((t=>new xm(t)))),this.eventCount)}rebased(t,e){if(!this.eventCount)return this;let r=[],n=Math.max(0,this.items.length-e);let i=t.mapping;let s=t.steps.length;let o=this.eventCount;this.items.forEach((t=>{if(t.selection)o--}),n);let l=e;this.items.forEach((e=>{let n=i.getMirror(--l);if(n==null)return;s=Math.min(s,n);let u=i.maps[n];if(e.step){let s=t.steps[n].invert(t.docs[n]);let a=e.selection&&e.selection.map(i.slice(l+1,n));if(a)o++;r.push(new xm(u,s,a))}else{r.push(new xm(u))}}),n);let u=[];for(let t=e;t<s;t++)u.push(new xm(i.maps[t]));let a=this.items.slice(0,n).append(u).append(r);let f=new ym(a,o);if(f.emptyItemCount()>vm)f=f.compress(this.items.length-r.length);return f}emptyItemCount(){let t=0;this.items.forEach((e=>{if(!e.step)t++}));return t}compress(t=this.items.length){let e=this.remapping(0,t),r=e.maps.length;let n=[],i=0;this.items.forEach(((s,o)=>{if(o>=t){n.push(s);if(s.selection)i++}else if(s.step){let t=s.step.map(e.slice(r)),o=t&&t.getMap();r--;if(o)e.appendMap(o,r);if(t){let l=s.selection&&s.selection.map(e.slice(r));if(l)i++;let u=new xm(o.invert(),t,l),a,f=n.length-1;if(a=n.length&&n[f].merge(u))n[f]=a;else n.push(u)}}else if(s.map){r--}}),this.items.length,0);return new ym(wm.from(n.reverse()),i)}}ym.empty=new ym(wm.empty,0);function Mm(t,e){let r;t.forEach(((t,n)=>{if(t.selection&&e--==0){r=n;return false}}));return t.slice(r)}class xm{constructor(t,e,r,n){this.map=t;this.step=e;this.selection=r;this.mirrorOffset=n}merge(t){if(this.step&&t.step&&!t.selection){let e=t.step.merge(this.step);if(e)return new xm(e.getMap().invert(),e,this.selection)}}}class Sm{constructor(t,e,r,n,i){this.done=t;this.undone=e;this.prevRanges=r;this.prevTime=n;this.prevComposition=i}}const Tm=20;function Em(t,e,r,n){let i=r.getMeta(Pm),s;if(i)return i.historyState;if(r.getMeta(Im))t=new Sm(t.done,t.undone,null,0,-1);let o=r.getMeta("appendedTransaction");if(r.steps.length==0){return t}else if(o&&o.getMeta(Pm)){if(o.getMeta(Pm).redo)return new Sm(t.done.addTransform(r,undefined,n,Nm(e)),t.undone,Am(r.mapping.maps),t.prevTime,t.prevComposition);else return new Sm(t.done,t.undone.addTransform(r,undefined,n,Nm(e)),null,t.prevTime,t.prevComposition)}else if(r.getMeta("addToHistory")!==false&&!(o&&o.getMeta("addToHistory")===false)){let i=r.getMeta("composition");let s=t.prevTime==0||!o&&t.prevComposition!=i&&(t.prevTime<(r.time||0)-n.newGroupDelay||!$m(r,t.prevRanges));let l=o?Om(t.prevRanges,r.mapping):Am(r.mapping.maps);return new Sm(t.done.addTransform(r,s?e.selection.getBookmark():undefined,n,Nm(e)),ym.empty,l,r.time,i==null?t.prevComposition:i)}else if(s=r.getMeta("rebased")){return new Sm(t.done.rebased(r,s),t.undone.rebased(r,s),Om(t.prevRanges,r.mapping),t.prevTime,t.prevComposition)}else{return new Sm(t.done.addMaps(r.mapping.maps),t.undone.addMaps(r.mapping.maps),Om(t.prevRanges,r.mapping),t.prevTime,t.prevComposition)}}function $m(t,e){if(!e)return false;if(!t.docChanged)return true;let r=false;t.mapping.maps[0].forEach(((t,n)=>{for(let i=0;i<e.length;i+=2)if(t<=e[i+1]&&n>=e[i])r=true}));return r}function Am(t){let e=[];for(let r=t.length-1;r>=0&&e.length==0;r--)t[r].forEach(((t,r,n,i)=>e.push(n,i)));return e}function Om(t,e){if(!t)return null;let r=[];for(let n=0;n<t.length;n+=2){let i=e.map(t[n],1),s=e.map(t[n+1],-1);if(i<=s)r.push(i,s)}return r}function Rm(t,e,r){let n=Nm(e);let i=Pm.get(e).spec.config;let s=(r?t.undone:t.done).popEvent(e,n);if(!s)return null;let o=s.selection.resolve(s.transform.doc);let l=(r?t.done:t.undone).addTransform(s.transform,e.selection.getBookmark(),i,n);let u=new Sm(r?l:s.remaining,r?s.remaining:l,null,0,-1);return s.transform.setSelection(o).setMeta(Pm,{redo:r,historyState:u})}let Cm=false,Lm=null;function Nm(t){let e=t.plugins;if(Lm!=e){Cm=false;Lm=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){Cm=true;break}}return Cm}const Pm=new yr("history");const Im=new yr("closeHistory");function Dm(t={}){t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500};return new br({key:Pm,state:{init(){return new Sm(ym.empty,ym.empty,null,0,-1)},apply(e,r,n){return Em(r,n,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(t,e){let r=e.inputType;let n=r=="historyUndo"?jm:r=="historyRedo"?_m:null;if(!n)return false;e.preventDefault();return n(t.state,t.dispatch)}}}})}function Hm(t,e){return(r,n)=>{let i=Pm.getState(r);if(!i||(t?i.undone:i.done).eventCount==0)return false;if(n){let s=Rm(i,r,t);if(s)n(e?s.scrollIntoView():s)}return true}}const jm=Hm(false,true);const _m=Hm(true,true);Uf.create({name:"characterCount",addOptions(){return{limit:null,mode:"textSize",textCounter:t=>t.length,wordCounter:t=>t.split(" ").filter((t=>t!=="")).length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=t=>{const e=(t==null?void 0:t.node)||this.editor.state.doc;const r=(t==null?void 0:t.mode)||this.options.mode;if(r==="textSize"){const t=e.textBetween(0,e.content.size,void 0," ");return this.options.textCounter(t)}return e.nodeSize};this.storage.words=t=>{const e=(t==null?void 0:t.node)||this.editor.state.doc;const r=e.textBetween(0,e.content.size," "," ");return this.options.wordCounter(r)}},addProseMirrorPlugins(){let t=false;return[new br({key:new yr("characterCount"),appendTransaction:(e,r,n)=>{if(t){return}const i=this.options.limit;if(i===null||i===void 0||i===0){t=true;return}const s=this.storage.characters({node:n.doc});if(s>i){const e=s-i;const r=0;const o=e;console.warn(`[CharacterCount] Initial content exceeded limit of ${i} characters. Content was automatically trimmed.`);const l=n.tr.deleteRange(r,o);t=true;return l}t=true},filterTransaction:(t,e)=>{const r=this.options.limit;if(!t.docChanged||r===0||r===null||r===void 0){return true}const n=this.storage.characters({node:e.doc});const i=this.storage.characters({node:t.doc});if(i<=r){return true}if(n>r&&i>r&&i<=n){return true}if(n>r&&i>r&&i>n){return false}const s=t.getMeta("paste");if(!s){return false}const o=t.selection.$head.pos;const l=i-r;const u=o-l;const a=o;t.deleteRange(u,a);const f=this.storage.characters({node:t.doc});if(f>r){return false}return true}})]}});var zm=Uf.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[im(this.options)]}});Uf.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new br({key:new yr("focus"),props:{decorations:({doc:t,selection:e})=>{const{isEditable:r,isFocused:n}=this.editor;const{anchor:i}=e;const s=[];if(!r||!n){return Vo.create(t,[])}let o=0;if(this.options.mode==="deepest"){t.descendants(((t,e)=>{if(t.isText){return}const r=i>=e&&i<=e+t.nodeSize-1;if(!r){return false}o+=1}))}let l=0;t.descendants(((t,e)=>{if(t.isText){return false}const r=i>=e&&i<=e+t.nodeSize-1;if(!r){return false}l+=1;const n=this.options.mode==="deepest"&&o-l>0||this.options.mode==="shallowest"&&l>1;if(n){return this.options.mode==="deepest"}s.push(Jo.node(e,e+t.nodeSize,{class:this.options.className}))}));return Vo.create(t,s)}}})]}});var Bm=Uf.create({name:"gapCursor",addProseMirrorPlugins(){return[fm()]},extendNodeSchema(t){var e;const r={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=ka(ma(t,"allowGapCursor",r)))!=null?e:null}}});Uf.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something …",showOnlyWhenEditable:true,showOnlyCurrent:true,includeChildren:false}},addProseMirrorPlugins(){return[new br({key:new yr("placeholder"),props:{decorations:({doc:t,selection:e})=>{const r=this.editor.isEditable||!this.options.showOnlyWhenEditable;const{anchor:n}=e;const i=[];if(!r){return null}const s=this.editor.isEmpty;t.descendants(((t,e)=>{const r=n>=e&&n<=e+t.nodeSize;const o=!t.isLeaf&&Ya(t);if((r||!this.options.showOnlyCurrent)&&o){const n=[this.options.emptyNodeClass];if(s){n.push(this.options.emptyEditorClass)}const o=Jo.node(e,e+t.nodeSize,{class:n.join(" "),"data-placeholder":typeof this.options.placeholder==="function"?this.options.placeholder({editor:this.editor,node:t,pos:e,hasAnchor:r}):this.options.placeholder});i.push(o)}return this.options.includeChildren}));return Vo.create(t,i)}}})]}});Uf.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:t,options:e}=this;return[new br({key:new yr("selection"),props:{decorations(r){if(r.selection.empty||t.isFocused||!t.isEditable||tf(r.selection)||t.view.dragging){return null}return Vo.create(r.doc,[Jo.inline(r.selection.from,r.selection.to,{class:e.className})])}}})]}});function Fm({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||(e==null?void 0:e.type)===t}var Um=Uf.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var t;const e=new yr(this.name);const r=((t=this.editor.schema.topNodeType.contentMatch.defaultType)==null?void 0:t.name)||this.options.node||"paragraph";const n=Object.entries(this.editor.schema.nodes).map((([,t])=>t)).filter((t=>(this.options.notAfter||[]).concat(r).includes(t.name)));return[new br({key:e,appendTransaction:(t,n,i)=>{const{doc:s,tr:o,schema:l}=i;const u=e.getState(i);const a=s.content.size;const f=l.nodes[r];if(!u){return}return o.insert(a,f.create())},state:{init:(t,e)=>{const r=e.tr.doc.lastChild;return!Fm({node:r,types:n})},apply:(t,e)=>{if(!t.docChanged){return e}const r=t.doc.lastChild;return!Fm({node:r,types:n})}}})]}});var qm=Uf.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>jm(t,e),redo:()=>({state:t,dispatch:e})=>_m(t,e)}},addProseMirrorPlugins(){return[Dm(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}});var Jm=Uf.create({name:"starterKit",addExtensions(){var t,e,r,n;const i=[];if(this.options.bold!==false){i.push(Bh.configure(this.options.bold))}if(this.options.blockquote!==false){i.push(Dh.configure(this.options.blockquote))}if(this.options.bulletList!==false){i.push(Ep.configure(this.options.bulletList))}if(this.options.code!==false){i.push(qh.configure(this.options.code))}if(this.options.codeBlock!==false){i.push(Vh.configure(this.options.codeBlock))}if(this.options.document!==false){i.push(Gh.configure(this.options.document))}if(this.options.dropcursor!==false){i.push(zm.configure(this.options.dropcursor))}if(this.options.gapcursor!==false){i.push(Bm.configure(this.options.gapcursor))}if(this.options.hardBreak!==false){i.push(Zh.configure(this.options.hardBreak))}if(this.options.heading!==false){i.push(Qh.configure(this.options.heading))}if(this.options.undoRedo!==false){i.push(qm.configure(this.options.undoRedo))}if(this.options.horizontalRule!==false){i.push(Xh.configure(this.options.horizontalRule))}if(this.options.italic!==false){i.push(nc.configure(this.options.italic))}if(this.options.listItem!==false){i.push($p.configure(this.options.listItem))}if(this.options.listKeymap!==false){i.push(_p.configure((t=this.options)==null?void 0:t.listKeymap))}if(this.options.link!==false){i.push(kp.configure((e=this.options)==null?void 0:e.link))}if(this.options.orderedList!==false){i.push(Vp.configure(this.options.orderedList))}if(this.options.paragraph!==false){i.push(Xp.configure(this.options.paragraph))}if(this.options.strike!==false){i.push(em.configure(this.options.strike))}if(this.options.text!==false){i.push(rm.configure(this.options.text))}if(this.options.underline!==false){i.push(nm.configure((r=this.options)==null?void 0:r.underline))}if(this.options.trailingNode!==false){i.push(Um.configure((n=this.options)==null?void 0:n.trailingNode))}return i}});var Km=Jm;var Wm=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/;var Vm=vh.create({name:"image",addOptions(){return{inline:false,allowBase64:false,HTMLAttributes:{}}},inline(){return this.options.inline},group(){return this.options.inline?"inline":"block"},draggable:true,addAttributes(){return{src:{default:null},alt:{default:null},title:{default:null},width:{default:null},height:{default:null}}},parseHTML(){return[{tag:this.options.allowBase64?"img[src]":'img[src]:not([src^="data:"])'}]},renderHTML({HTMLAttributes:t}){return["img",xa(this.options.HTMLAttributes,t)]},parseMarkdown:(t,e)=>e.createNode("image",{src:t.href,title:t.title,alt:t.text}),renderMarkdown:t=>{var e,r,n,i,s,o;const l=(r=(e=t.attrs)==null?void 0:e.src)!=null?r:"";const u=(i=(n=t.attrs)==null?void 0:n.alt)!=null?i:"";const a=(o=(s=t.attrs)==null?void 0:s.title)!=null?o:"";return a?`![${u}](${l} "${a}")`:`![${u}](${l})`},addCommands(){return{setImage:t=>({commands:e})=>e.insertContent({type:this.name,attrs:t})}},addInputRules(){return[sh({find:Wm,type:this.type,getAttributes:t=>{const[,,e,r,n]=t;return{src:r,alt:e,title:n}}})]}});var Gm=Vm;const Zm=new Set(["http:","https:"]);const Qm=t=>({HTMLAttributes:e})=>{const r=document.createElement("pos-image");const n=new URL(e.src,t);if(Zm.has(n.protocol)){r.setAttribute("src",n.toString())}let i=["alt","title"];for(const t of i){if(e[t]){r.setAttribute(t,e[t])}}return{dom:r,ignoreMutation:()=>true}};const Xm=t=>Gm.extend({addNodeView(){return Qm(t)}});const Ym=new Set(["http:","https:","mailto:","tel:"]);const tg=t=>({HTMLAttributes:e})=>{const r=document.createElement("pos-rich-link");const n=new URL(e.href,t);if(Ym.has(n.protocol)){r.setAttribute("uri",n.toString())}return{dom:r,contentDOM:r,ignoreMutation:()=>true}};const eg=t=>vp.extend({addMarkView(){return tg(t)}});class rg{constructor(t,e,r){this.modifications=new l;this.editor=new nh({element:t,extensions:[Nh,Km.configure({link:false}),Xm(r),eg(r)],content:e,contentType:"markdown",editable:false});this.editor.on("update",(()=>{this.modifications.next({content:this.editor.getMarkdown()})}))}onUpdate(t){this.editor.on("update",t)}isEditable(){return this.editor.isEditable}startEditing(){this.editor.setEditable(true,false);this.editor.commands.focus()}stopEditing(){this.editor.setEditable(false,false)}getContent(){return this.editor.getMarkdown()}observeChanges(t=1e3){return this.modifications.pipe(u(t))}}const ng=":host {\n article {\n padding: 0;\n &:focus-within {\n outline: var(--pos-input-focus-outline);\n }\n\n .tiptap {\n border: none;\n outline: none;\n }\n\n line-height: 1.5;\n pos-image {\n --max-width: 100%;\n }\n\n header {\n position: sticky;\n background-color: var(--pos-background-color);\n border-bottom: var(--size-px) solid var(--pos-border-color);\n border-top-left-radius: inherit;\n border-top-right-radius: inherit;\n overflow: hidden;\n z-index: var(--layer-1);\n top: 0;\n padding: var(--size-1);\n flex-direction: row;\n justify-content: flex-end;\n button {\n background: var(--pos-primary-color);\n color: var(--pos-primary-text-color);\n outline: none;\n border: none;\n border-radius: var(--radius-xs);\n display: inline-flex;\n gap: var(--size-1);\n justify-content: center;\n align-items: center;\n height: var(--size-8);\n flex-shrink: 1;\n\n &:focus {\n outline: var(--pos-input-focus-outline);\n }\n\n &:hover {\n filter: brightness(110%);\n box-shadow: var(--shadow-md);\n }\n }\n .status {\n display: flex;\n align-content: center;\n align-items: center;\n gap: var(--size-1);\n font-size: var(--scale-00);\n\n &.pending {\n animation: pending-fade 1s ease forwards;\n }\n\n &.success {\n animation: success-flash 2s ease forwards;\n }\n\n &.error {\n animation: error-flash 2s ease infinite;\n }\n\n &.saving {\n animation: saving-flash 2s ease infinite;\n }\n }\n }\n\n .content {\n padding: var(--size-4);\n\n pre {\n code {\n display: block;\n padding: var(--size-4);\n overflow-x: auto;\n background-color: var(--color-black);\n font-family: monospace;\n color: var(--color-white);\n line-height: 1.6;\n border-radius: var(--radius-lg);\n }\n }\n\n blockquote {\n border-left: var(--size-1) solid var(--pos-primary-color);\n margin-left: var(--size-4);\n padding-left: var(--size-4);\n }\n }\n }\n}\n\n@keyframes pending-fade {\n 0% {\n opacity: 0;\n color: var(--pos-subtle-text-color);\n }\n 100% {\n opacity: 1;\n color: var(--pos-primary-color);\n }\n}\n\n@keyframes success-flash {\n 0% {\n opacity: 0;\n color: var(--pos-subtle-text-color);\n }\n 50% {\n opacity: 1;\n color: var(--color-green-500);\n }\n 100% {\n opacity: 1;\n color: var(--pos-subtle-text-color);\n }\n}\n\n@keyframes error-flash {\n 0% {\n opacity: 0;\n }\n 50% {\n opacity: 1;\n color: var(--color-red-500);\n }\n 100% {\n opacity: 0;\n }\n}\n\n@keyframes saving-flash {\n 0% {\n opacity: 0;\n }\n 50% {\n opacity: 1;\n color: var(--pos-primary-color);\n }\n 100% {\n opacity: 0;\n }\n}\n";const ig=ng;const sg="article {\n padding: var(--size-2);\n display: flex;\n flex-direction: column;\n gap: var(--size-2);\n outline: var(--pos-border-solid);\n border-radius: var(--radius-sm);\n box-shadow: var(--shadow-md);\n background-color: var(--pos-card-background);\n\n header {\n display: flex;\n flex-direction: column;\n gap: var(--size-2);\n h1 {\n margin: 0;\n }\n }\n}\n";const og=sg;const lg=class{constructor(r){t(this,r);this.documentModified=e(this,"pod-os:document-modified",7);this.saveStatus="idle";this.editable=false;this.isModified=false;this.isEditing=false;this.disconnected$=new l}async componentWillLoad(){this.markdown=await this.file.blob().text()}componentDidLoad(){this.editor=new rg(this.editorEl,this.markdown,this.file.url);this.editor.onUpdate((()=>{this.isModified=true}));this.editor.observeChanges().pipe(a(this.disconnected$),f((t=>t.content)),h((t=>{this.isModified=false;this.documentModified.emit({file:this.file,newContent:t})}))).subscribe()}disconnectedCallback(){this.disconnected$.next();this.disconnected$.unsubscribe()}async startEditing(){this.editor.startEditing();this.isEditing=true}async stopEditing(){this.editor.stopEditing();this.isEditing=false}render(){return r("article",{key:"99e920a07dfbde44c65415fac345ce183b4a6be3"},this.editable?r("header",null,this.isEditing?this.getStatus():null,this.isEditing?r("button",{onClick:()=>this.stopEditing()},r("sl-icon",{name:"eye"}),"View"):r("button",{onClick:()=>this.startEditing()},r("sl-icon",{name:"pencil-square"}),"Edit")):null,r("div",{key:"8407b452e5a17be4e1db7a61621787ddc76bd279",class:"content",ref:t=>this.editorEl=t}))}getStatus(){if(this.isModified){return r(ug,{status:"pending",message:"pending changes",icon:"clock-history"})}if(this.saveStatus==="failed"){return r(ug,{status:"error",message:"saving failed",icon:"x-octagon"})}if(this.saveStatus==="saving"){return r(ug,{status:"saving",message:"saving changes",icon:"cloud-upload"})}return r(ug,{status:"success",message:"all saved",icon:"check2-circle"})}};function ug({status:t,icon:e,message:n}){return r("span",{class:{status:true,[t]:true},role:"status","aria-live":"polite","aria-labelledby":"status-message"},r("sl-icon",{name:e,"aria-hidden":"true"}),r("span",{id:"status-message"},n))}lg.style=ig+og;export{lg as pos_markdown_document};
2
+ //# sourceMappingURL=p-08f92489.entry.js.map