@limetech/lime-elements 37.25.0 → 37.26.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (100) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/cjs/{dom-ee8ee17d.js → debounce-2e5f4b7e.js} +1 -31
  3. package/dist/cjs/debounce-2e5f4b7e.js.map +1 -0
  4. package/dist/cjs/dom-81eaa633.js +34 -0
  5. package/dist/cjs/dom-81eaa633.js.map +1 -0
  6. package/dist/cjs/lime-elements.cjs.js +1 -1
  7. package/dist/cjs/{limel-action-bar-item_2.cjs.entry.js → limel-action-bar_3.cjs.entry.js} +106 -1
  8. package/dist/cjs/limel-action-bar_3.cjs.entry.js.map +1 -0
  9. package/dist/cjs/{limel-breadcrumbs_3.cjs.entry.js → limel-breadcrumbs_4.cjs.entry.js} +519 -20
  10. package/dist/cjs/limel-breadcrumbs_4.cjs.entry.js.map +1 -0
  11. package/dist/cjs/{limel-input-field_3.cjs.entry.js → limel-dynamic-label_4.cjs.entry.js} +75 -494
  12. package/dist/cjs/limel-dynamic-label_4.cjs.entry.js.map +1 -0
  13. package/dist/cjs/limel-picker.cjs.entry.js +3 -2
  14. package/dist/cjs/limel-picker.cjs.entry.js.map +1 -1
  15. package/dist/cjs/limel-prosemirror-adapter.cjs.entry.js +153 -116
  16. package/dist/cjs/limel-prosemirror-adapter.cjs.entry.js.map +1 -1
  17. package/dist/cjs/limel-text-editor.cjs.entry.js +4 -1
  18. package/dist/cjs/limel-text-editor.cjs.entry.js.map +1 -1
  19. package/dist/cjs/loader.cjs.js +1 -1
  20. package/dist/collection/components/text-editor/prosemirror-adapter/menu/menu-commands.js +77 -0
  21. package/dist/collection/components/text-editor/prosemirror-adapter/menu/menu-commands.js.map +1 -0
  22. package/dist/collection/components/text-editor/prosemirror-adapter/menu/menu-items.js +53 -0
  23. package/dist/collection/components/text-editor/prosemirror-adapter/menu/menu-items.js.map +1 -0
  24. package/dist/collection/components/text-editor/prosemirror-adapter/prosemirror-adapter.js +34 -9
  25. package/dist/collection/components/text-editor/prosemirror-adapter/prosemirror-adapter.js.map +1 -1
  26. package/dist/collection/components/text-editor/text-editor.css +88 -0
  27. package/dist/collection/components/text-editor/text-editor.js +3 -0
  28. package/dist/collection/components/text-editor/text-editor.js.map +1 -1
  29. package/dist/esm/{dom-ae531ebc.js → debounce-9a05c91c.js} +2 -31
  30. package/dist/esm/debounce-9a05c91c.js.map +1 -0
  31. package/dist/esm/dom-0b0170a0.js +32 -0
  32. package/dist/esm/dom-0b0170a0.js.map +1 -0
  33. package/dist/esm/lime-elements.js +1 -1
  34. package/dist/esm/{limel-action-bar-item_2.entry.js → limel-action-bar_3.entry.js} +107 -3
  35. package/dist/esm/limel-action-bar_3.entry.js.map +1 -0
  36. package/dist/esm/{limel-breadcrumbs_3.entry.js → limel-breadcrumbs_4.entry.js} +501 -3
  37. package/dist/esm/limel-breadcrumbs_4.entry.js.map +1 -0
  38. package/dist/esm/{limel-input-field_3.entry.js → limel-dynamic-label_4.entry.js} +70 -490
  39. package/dist/esm/limel-dynamic-label_4.entry.js.map +1 -0
  40. package/dist/esm/limel-picker.entry.js +2 -1
  41. package/dist/esm/limel-picker.entry.js.map +1 -1
  42. package/dist/esm/limel-prosemirror-adapter.entry.js +153 -116
  43. package/dist/esm/limel-prosemirror-adapter.entry.js.map +1 -1
  44. package/dist/esm/limel-text-editor.entry.js +4 -1
  45. package/dist/esm/limel-text-editor.entry.js.map +1 -1
  46. package/dist/esm/loader.js +1 -1
  47. package/dist/lime-elements/lime-elements.esm.js +1 -1
  48. package/dist/lime-elements/lime-elements.esm.js.map +1 -1
  49. package/dist/lime-elements/p-18c97232.js +2 -0
  50. package/dist/lime-elements/p-18c97232.js.map +1 -0
  51. package/dist/lime-elements/p-2bff59a1.entry.js +2 -0
  52. package/dist/lime-elements/p-2bff59a1.entry.js.map +1 -0
  53. package/dist/lime-elements/p-3ab8d3e9.entry.js +68 -0
  54. package/dist/lime-elements/p-3ab8d3e9.entry.js.map +1 -0
  55. package/dist/lime-elements/p-5e7b7b03.js +2 -0
  56. package/dist/lime-elements/p-5e7b7b03.js.map +1 -0
  57. package/dist/lime-elements/p-5fcdb9d2.entry.js +2 -0
  58. package/dist/lime-elements/{p-3e90be0a.entry.js.map → p-5fcdb9d2.entry.js.map} +1 -1
  59. package/dist/lime-elements/p-6ebde4a2.entry.js +2 -0
  60. package/dist/lime-elements/p-6ebde4a2.entry.js.map +1 -0
  61. package/dist/lime-elements/{p-60317f5c.entry.js → p-db7ce0f8.entry.js} +2 -2
  62. package/dist/lime-elements/p-db7ce0f8.entry.js.map +1 -0
  63. package/dist/lime-elements/p-e4424368.entry.js +2 -0
  64. package/dist/lime-elements/p-e4424368.entry.js.map +1 -0
  65. package/dist/types/components/text-editor/prosemirror-adapter/menu/menu-commands.d.ts +12 -0
  66. package/dist/types/components/text-editor/prosemirror-adapter/menu/menu-items.d.ts +4 -0
  67. package/dist/types/components/text-editor/prosemirror-adapter/prosemirror-adapter.d.ts +4 -1
  68. package/package.json +2 -2
  69. package/dist/cjs/dom-ee8ee17d.js.map +0 -1
  70. package/dist/cjs/limel-action-bar-item_2.cjs.entry.js.map +0 -1
  71. package/dist/cjs/limel-action-bar.cjs.entry.js +0 -113
  72. package/dist/cjs/limel-action-bar.cjs.entry.js.map +0 -1
  73. package/dist/cjs/limel-breadcrumbs_3.cjs.entry.js.map +0 -1
  74. package/dist/cjs/limel-dynamic-label_2.cjs.entry.js +0 -91
  75. package/dist/cjs/limel-dynamic-label_2.cjs.entry.js.map +0 -1
  76. package/dist/cjs/limel-input-field_3.cjs.entry.js.map +0 -1
  77. package/dist/esm/dom-ae531ebc.js.map +0 -1
  78. package/dist/esm/limel-action-bar-item_2.entry.js.map +0 -1
  79. package/dist/esm/limel-action-bar.entry.js +0 -109
  80. package/dist/esm/limel-action-bar.entry.js.map +0 -1
  81. package/dist/esm/limel-breadcrumbs_3.entry.js.map +0 -1
  82. package/dist/esm/limel-dynamic-label_2.entry.js +0 -86
  83. package/dist/esm/limel-dynamic-label_2.entry.js.map +0 -1
  84. package/dist/esm/limel-input-field_3.entry.js.map +0 -1
  85. package/dist/lime-elements/p-3e90be0a.entry.js +0 -2
  86. package/dist/lime-elements/p-497a0b69.entry.js +0 -68
  87. package/dist/lime-elements/p-497a0b69.entry.js.map +0 -1
  88. package/dist/lime-elements/p-60317f5c.entry.js.map +0 -1
  89. package/dist/lime-elements/p-6eeb61e4.entry.js +0 -2
  90. package/dist/lime-elements/p-6eeb61e4.entry.js.map +0 -1
  91. package/dist/lime-elements/p-714d6937.js +0 -2
  92. package/dist/lime-elements/p-714d6937.js.map +0 -1
  93. package/dist/lime-elements/p-a2d19673.entry.js +0 -2
  94. package/dist/lime-elements/p-a2d19673.entry.js.map +0 -1
  95. package/dist/lime-elements/p-af964180.entry.js +0 -2
  96. package/dist/lime-elements/p-af964180.entry.js.map +0 -1
  97. package/dist/lime-elements/p-da62cd3f.entry.js +0 -2
  98. package/dist/lime-elements/p-da62cd3f.entry.js.map +0 -1
  99. package/dist/lime-elements/p-f1e1f867.entry.js +0 -2
  100. package/dist/lime-elements/p-f1e1f867.entry.js.map +0 -1
@@ -1,2 +1,2 @@
1
- import{r as t,c as e,h as r,g as i}from"./p-443111b3.js";function n(t){this.content=t}n.prototype={constructor:n,find:function(t){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===t)return e;return-1},get:function(t){var e=this.find(t);return e==-1?undefined:this.content[e+1]},update:function(t,e,r){var i=r&&r!=t?this.remove(r):this;var s=i.find(t),l=i.content.slice();if(s==-1){l.push(r||t,e)}else{l[s+1]=e;if(r)l[s]=r}return new n(l)},remove:function(t){var e=this.find(t);if(e==-1)return this;var r=this.content.slice();r.splice(e,2);return new n(r)},addToStart:function(t,e){return new n([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var r=this.remove(t).content.slice();r.push(t,e);return new n(r)},addBefore:function(t,e,r){var i=this.remove(e),s=i.content.slice();var l=i.find(t);s.splice(l==-1?s.length:l,0,e,r);return new n(s)},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=n.from(t);if(!t.size)return this;return new n(t.content.concat(this.subtract(t).content))},append:function(t){t=n.from(t);if(!t.size)return this;return new n(this.subtract(t).content.concat(t.content))},subtract:function(t){var e=this;t=n.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}};n.from=function(t){if(t instanceof n)return t;var e=[];if(t)for(var r in t)e.push(r,t[r]);return new n(e)};function s(t,e,r){for(let i=0;;i++){if(i==t.childCount||i==e.childCount)return t.childCount==e.childCount?null:r;let n=t.child(i),l=e.child(i);if(n==l){r+=n.nodeSize;continue}if(!n.sameMarkup(l))return r;if(n.isText&&n.text!=l.text){for(let t=0;n.text[t]==l.text[t];t++)r++;return r}if(n.content.size||l.content.size){let t=s(n.content,l.content,r+1);if(t!=null)return t}r+=n.nodeSize}}function l(t,e,r,i){for(let n=t.childCount,s=e.childCount;;){if(n==0||s==0)return n==s?null:{a:r,b:i};let o=t.child(--n),f=e.child(--s),u=o.nodeSize;if(o==f){r-=u;i-=u;continue}if(!o.sameMarkup(f))return{a:r,b:i};if(o.isText&&o.text!=f.text){let t=0,e=Math.min(o.text.length,f.text.length);while(t<e&&o.text[o.text.length-t-1]==f.text[f.text.length-t-1]){t++;r--;i--}return{a:r,b:i}}if(o.content.size||f.content.size){let t=l(o.content,f.content,r-1,i-1);if(t)return t}r-=u;i-=u}}class o{constructor(t,e){this.content=t;this.size=e||0;if(e==null)for(let e=0;e<t.length;e++)this.size+=t[e].nodeSize}nodesBetween(t,e,r,i=0,n){for(let s=0,l=0;l<e;s++){let o=this.content[s],f=l+o.nodeSize;if(f>t&&r(o,i+l,n||null,s)!==false&&o.content.size){let n=l+1;o.nodesBetween(Math.max(0,t-n),Math.min(o.content.size,e-n),r,i+n)}l=f}}descendants(t){this.nodesBetween(0,this.size,t)}textBetween(t,e,r,i){let n="",s=true;this.nodesBetween(t,e,((l,o)=>{let f=l.isText?l.text.slice(Math.max(t,o)-o,e-o):!l.isLeaf?"":i?typeof i==="function"?i(l):i:l.type.spec.leafText?l.type.spec.leafText(l):"";if(l.isBlock&&(l.isLeaf&&f||l.isTextblock)&&r){if(s)s=false;else n+=r}n+=f}),0);return n}append(t){if(!t.size)return this;if(!this.size)return t;let e=this.lastChild,r=t.firstChild,i=this.content.slice(),n=0;if(e.isText&&e.sameMarkup(r)){i[i.length-1]=e.withText(e.text+r.text);n=1}for(;n<t.content.length;n++)i.push(t.content[n]);return new o(i,this.size+t.size)}cut(t,e=this.size){if(t==0&&e==this.size)return this;let r=[],i=0;if(e>t)for(let n=0,s=0;s<e;n++){let l=this.content[n],o=s+l.nodeSize;if(o>t){if(s<t||o>e){if(l.isText)l=l.cut(Math.max(0,t-s),Math.min(l.text.length,e-s));else l=l.cut(Math.max(0,t-s-1),Math.min(l.content.size,e-s-1))}r.push(l);i+=l.nodeSize}s=o}return new o(r,i)}cutByIndex(t,e){if(t==e)return o.empty;if(t==0&&e==this.content.length)return this;return new o(this.content.slice(t,e))}replaceChild(t,e){let r=this.content[t];if(r==e)return this;let i=this.content.slice();let n=this.size+e.nodeSize-r.nodeSize;i[t]=e;return new o(i,n)}addToStart(t){return new o([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new o(this.content.concat(t),this.size+t.nodeSize)}eq(t){if(this.content.length!=t.content.length)return false;for(let e=0;e<this.content.length;e++)if(!this.content[e].eq(t.content[e]))return false;return true}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(t){let e=this.content[t];if(!e)throw new RangeError("Index "+t+" out of range for "+this);return e}maybeChild(t){return this.content[t]||null}forEach(t){for(let e=0,r=0;e<this.content.length;e++){let i=this.content[e];t(i,r,e);r+=i.nodeSize}}findDiffStart(t,e=0){return s(this,t,e)}findDiffEnd(t,e=this.size,r=t.size){return l(this,t,e,r)}findIndex(t,e=-1){if(t==0)return u(0,t);if(t==this.size)return u(this.content.length,t);if(t>this.size||t<0)throw new RangeError(`Position ${t} outside of fragment (${this})`);for(let r=0,i=0;;r++){let n=this.child(r),s=i+n.nodeSize;if(s>=t){if(s==t||e>0)return u(r+1,s);return u(r,i)}i=s}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map((t=>t.toJSON())):null}static fromJSON(t,e){if(!e)return o.empty;if(!Array.isArray(e))throw new RangeError("Invalid input for Fragment.fromJSON");return new o(e.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return o.empty;let e,r=0;for(let i=0;i<t.length;i++){let n=t[i];r+=n.nodeSize;if(i&&n.isText&&t[i-1].sameMarkup(n)){if(!e)e=t.slice(0,i);e[e.length-1]=n.withText(e[e.length-1].text+n.text)}else if(e){e.push(n)}}return new o(e||t,r)}static from(t){if(!t)return o.empty;if(t instanceof o)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new o([t],t.nodeSize);throw new RangeError("Can not convert "+t+" to a Fragment"+(t.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}o.empty=new o([],0);const f={index:0,offset:0};function u(t,e){f.index=t;f.offset=e;return f}function h(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(!h(t[r],e[r]))return false}else{for(let r in t)if(!(r in e)||!h(t[r],e[r]))return false;for(let r in e)if(!(r in t))return false}return true}class a{constructor(t,e){this.type=t;this.attrs=e}addToSet(t){let e,r=false;for(let i=0;i<t.length;i++){let n=t[i];if(this.eq(n))return t;if(this.type.excludes(n.type)){if(!e)e=t.slice(0,i)}else if(n.type.excludes(this.type)){return t}else{if(!r&&n.type.rank>this.type.rank){if(!e)e=t.slice(0,i);e.push(this);r=true}if(e)e.push(n)}}if(!e)e=t.slice();if(!r)e.push(this);return e}removeFromSet(t){for(let e=0;e<t.length;e++)if(this.eq(t[e]))return t.slice(0,e).concat(t.slice(e+1));return t}isInSet(t){for(let e=0;e<t.length;e++)if(this.eq(t[e]))return true;return false}eq(t){return this==t||this.type==t.type&&h(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`);return r.create(e.attrs)}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 a.none;if(t instanceof a)return[t];let e=t.slice();e.sort(((t,e)=>t.type.rank-e.type.rank));return e}}a.none=[];class c extends Error{}class d{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=m(this.content,t+this.openStart,e);return r&&new d(r,this.openStart,this.openEnd)}removeBetween(t,e){return new d(p(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 d.empty;let r=e.openStart||0,i=e.openEnd||0;if(typeof r!="number"||typeof i!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new d(o.fromJSON(t,e.content),r,i)}static maxOpen(t,e=true){let r=0,i=0;for(let i=t.firstChild;i&&!i.isLeaf&&(e||!i.type.spec.isolating);i=i.firstChild)r++;for(let r=t.lastChild;r&&!r.isLeaf&&(e||!r.type.spec.isolating);r=r.lastChild)i++;return new d(t,r,i)}}d.empty=new d(o.empty,0,0);function p(t,e,r){let{index:i,offset:n}=t.findIndex(e),s=t.maybeChild(i);let{index:l,offset:o}=t.findIndex(r);if(n==e||s.isText){if(o!=r&&!t.child(l).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(r))}if(i!=l)throw new RangeError("Removing non-flat range");return t.replaceChild(i,s.copy(p(s.content,e-n-1,r-n-1)))}function m(t,e,r,i){let{index:n,offset:s}=t.findIndex(e),l=t.maybeChild(n);if(s==e||l.isText){if(i&&!i.canReplace(n,n,r))return null;return t.cut(0,e).append(r).append(t.cut(e))}let o=m(l.content,e-s-1,r);return o&&t.replaceChild(n,l.copy(o))}function w(t,e,r){if(r.openStart>t.depth)throw new c("Inserted content deeper than insertion position");if(t.depth-r.openStart!=e.depth-r.openEnd)throw new c("Inconsistent open depths");return g(t,e,r,0)}function g(t,e,r,i){let n=t.index(i),s=t.node(i);if(n==e.index(i)&&i<t.depth-r.openStart){let l=g(t,e,r,i+1);return s.copy(s.content.replaceChild(n,l))}else if(!r.content.size){return M(s,S(t,e,i))}else if(!r.openStart&&!r.openEnd&&t.depth==i&&e.depth==i){let i=t.parent,n=i.content;return M(i,n.cut(0,t.parentOffset).append(r.content).append(n.cut(e.parentOffset)))}else{let{start:n,end:l}=O(r,t);return M(s,x(t,n,l,e,i))}}function b(t,e){if(!e.type.compatibleContent(t.type))throw new c("Cannot join "+e.type.name+" onto "+t.type.name)}function v(t,e,r){let i=t.node(r);b(i,e.node(r));return i}function k(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 y(t,e,r,i){let n=(e||t).node(r);let s=0,l=e?e.index(r):n.childCount;if(t){s=t.index(r);if(t.depth>r){s++}else if(t.textOffset){k(t.nodeAfter,i);s++}}for(let t=s;t<l;t++)k(n.child(t),i);if(e&&e.depth==r&&e.textOffset)k(e.nodeBefore,i)}function M(t,e){t.type.checkContent(e);return t.copy(e)}function x(t,e,r,i,n){let s=t.depth>n&&v(t,e,n+1);let l=i.depth>n&&v(r,i,n+1);let f=[];y(null,t,n,f);if(s&&l&&e.index(n)==r.index(n)){b(s,l);k(M(s,x(t,e,r,i,n+1)),f)}else{if(s)k(M(s,S(t,e,n+1)),f);y(e,r,n,f);if(l)k(M(l,S(r,i,n+1)),f)}y(i,null,n,f);return new o(f)}function S(t,e,r){let i=[];y(null,t,r,i);if(t.depth>r){let n=v(t,e,r+1);k(M(n,S(t,e,r+1)),i)}y(e,null,r,i);return new o(i)}function O(t,e){let r=e.depth-t.openStart,i=e.node(r);let n=i.copy(t.content);for(let t=r-1;t>=0;t--)n=e.node(t).copy(o.from(n));return{start:n.resolveNoCache(t.openStart+r),end:n.resolveNoCache(n.content.size-t.openEnd-r)}}class E{constructor(t,e,r){this.pos=t;this.path=e;this.parentOffset=r;this.depth=e.length/3-1}resolveDepth(t){if(t==null)return this.depth;if(t<0)return this.depth+t;return t}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(t){return this.path[this.resolveDepth(t)*3]}index(t){return this.path[this.resolveDepth(t)*3+1]}indexAfter(t){t=this.resolveDepth(t);return this.index(t)+(t==this.depth&&!this.textOffset?0:1)}start(t){t=this.resolveDepth(t);return t==0?0:this.path[t*3-1]+1}end(t){t=this.resolveDepth(t);return this.start(t)+this.node(t).content.size}before(t){t=this.resolveDepth(t);if(!t)throw new RangeError("There is no position before the top-level node");return t==this.depth+1?this.pos:this.path[t*3-1]}after(t){t=this.resolveDepth(t);if(!t)throw new RangeError("There is no position after the top-level node");return t==this.depth+1?this.pos:this.path[t*3-1]+this.path[t*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let t=this.parent,e=this.index(this.depth);if(e==t.childCount)return null;let r=this.pos-this.path[this.path.length-1],i=t.child(e);return r?t.child(e).cut(r):i}get nodeBefore(){let t=this.index(this.depth);let e=this.pos-this.path[this.path.length-1];if(e)return this.parent.child(t).cut(0,e);return t==0?null:this.parent.child(t-1)}posAtIndex(t,e){e=this.resolveDepth(e);let r=this.path[e*3],i=e==0?0:this.path[e*3-1]+1;for(let e=0;e<t;e++)i+=r.child(e).nodeSize;return i}marks(){let t=this.parent,e=this.index();if(t.content.size==0)return a.none;if(this.textOffset)return t.child(e).marks;let r=t.maybeChild(e-1),i=t.maybeChild(e);if(!r){let t=r;r=i;i=t}let n=r.marks;for(var s=0;s<n.length;s++)if(n[s].type.spec.inclusive===false&&(!i||!n[s].isInSet(i.marks)))n=n[s--].removeFromSet(n);return n}marksAcross(t){let e=this.parent.maybeChild(this.index());if(!e||!e.isInline)return null;let r=e.marks,i=t.parent.maybeChild(t.index());for(var n=0;n<r.length;n++)if(r[n].type.spec.inclusive===false&&(!i||!r[n].isInSet(i.marks)))r=r[n--].removeFromSet(r);return r}sharedDepth(t){for(let e=this.depth;e>0;e--)if(this.start(e)<=t&&this.end(e)>=t)return e;return 0}blockRange(t=this,e){if(t.pos<this.pos)return t.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==t.pos?1:0);r>=0;r--)if(t.pos<=this.end(r)&&(!e||e(this.node(r))))return new C(this,t,r);return null}sameParent(t){return this.pos-this.parentOffset==t.pos-t.parentOffset}max(t){return t.pos>this.pos?t:this}min(t){return t.pos<this.pos?t:this}toString(){let t="";for(let e=1;e<=this.depth;e++)t+=(t?"/":"")+this.node(e).type.name+"_"+this.index(e-1);return t+":"+this.parentOffset}static resolve(t,e){if(!(e>=0&&e<=t.content.size))throw new RangeError("Position "+e+" out of range");let r=[];let i=0,n=e;for(let e=t;;){let{index:t,offset:s}=e.content.findIndex(n);let l=n-s;r.push(e,t,i+s);if(!l)break;e=e.child(t);if(e.isText)break;n=l-1;i+=s+1}return new E(e,r,n)}static resolveCached(t,e){for(let r=0;r<D.length;r++){let i=D[r];if(i.pos==e&&i.doc==t)return i}let r=D[N]=E.resolve(t,e);N=(N+1)%R;return r}}let D=[],N=0,R=12;class C{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 P=Object.create(null);class q{constructor(t,e,r,i=a.none){this.type=t;this.attrs=e;this.marks=i;this.content=r||o.empty}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(t){return this.content.child(t)}maybeChild(t){return this.content.maybeChild(t)}forEach(t){this.content.forEach(t)}nodesBetween(t,e,r,i=0){this.content.nodesBetween(t,e,r,i,this)}descendants(t){this.nodesBetween(0,this.content.size,t)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(t,e,r,i){return this.content.textBetween(t,e,r,i)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(t){return this==t||this.sameMarkup(t)&&this.content.eq(t.content)}sameMarkup(t){return this.hasMarkup(t.type,t.attrs,t.marks)}hasMarkup(t,e,r){return this.type==t&&h(this.attrs,e||t.defaultAttrs||P)&&a.sameSet(this.marks,r||a.none)}copy(t=null){if(t==this.content)return this;return new q(this.type,this.attrs,t,this.marks)}mark(t){return t==this.marks?this:new q(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 d.empty;let i=this.resolve(t),n=this.resolve(e);let s=r?0:i.sharedDepth(e);let l=i.start(s),o=i.node(s);let f=o.content.cut(i.pos-l,n.pos-l);return new d(f,i.depth-s,n.depth-s)}replace(t,e,r){return w(this.resolve(t),this.resolve(e),r)}nodeAt(t){for(let e=this;;){let{index:r,offset:i}=e.content.findIndex(t);e=e.maybeChild(r);if(!e)return null;if(i==t||e.isText)return e;t-=i+1}}childAfter(t){let{index:e,offset:r}=this.content.findIndex(t);return{node:this.content.maybeChild(e),index:e,offset:r}}childBefore(t){if(t==0)return{node:null,index:0,offset:0};let{index:e,offset:r}=this.content.findIndex(t);if(r<t)return{node:this.content.child(e),index:e,offset:r};let i=this.content.child(e-1);return{node:i,index:e-1,offset:r-i.nodeSize}}resolve(t){return E.resolveCached(this,t)}resolveNoCache(t){return E.resolve(this,t)}rangeHasMark(t,e,r){let i=false;if(e>t)this.nodesBetween(t,e,(t=>{if(r.isInSet(t.marks))i=true;return!i}));return i}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let t=this.type.name;if(this.content.size)t+="("+this.content.toStringInner()+")";return $(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=o.empty,i=0,n=r.childCount){let s=this.contentMatchAt(t).matchFragment(r,i,n);let l=s&&s.matchFragment(this.content,e);if(!l||!l.validEnd)return false;for(let t=i;t<n;t++)if(!this.type.allowsMarks(r.child(t).marks))return false;return true}canReplaceWith(t,e,r,i){if(i&&!this.type.allowsMarks(i))return false;let n=this.contentMatchAt(t).matchType(r);let s=n&&n.matchFragment(this.content,e);return s?s.validEnd:false}canAppend(t){if(t.content.size)return this.canReplace(this.childCount,this.childCount,t.content);else return this.type.compatibleContent(t.type)}check(){this.type.checkContent(this.content);let t=a.none;for(let e=0;e<this.marks.length;e++)t=this.marks[e].addToSet(t);if(!a.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=null;if(e.marks){if(!Array.isArray(e.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=e.marks.map(t.markFromJSON)}if(e.type=="text"){if(typeof e.text!="string")throw new RangeError("Invalid text node in JSON");return t.text(e.text,r)}let i=o.fromJSON(t,e.content);return t.nodeType(e.type).create(e.attrs,i,r)}}q.prototype.text=undefined;class T extends q{constructor(t,e,r,i){super(t,e,null,i);if(!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);return $(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 T(this.type,this.attrs,this.text,t)}withText(t){if(t==this.text)return this;return new T(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 $(t,e){for(let r=t.length-1;r>=0;r--)e=t[r].type.name+"("+e+")";return e}class A{constructor(t){this.validEnd=t;this.next=[];this.wrapCache=[]}static parse(t,e){let r=new I(t,e);if(r.next==null)return A.empty;let i=z(r);if(r.next)r.err("Unexpected trailing text");let n=H(U(i));G(n,r);return n}matchType(t){for(let e=0;e<this.next.length;e++)if(this.next[e].type==t)return this.next[e].next;return null}matchFragment(t,e=0,r=t.childCount){let i=this;for(let n=e;i&&n<r;n++)i=i.matchType(t.child(n).type);return i}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let t=0;t<this.next.length;t++){let{type:e}=this.next[t];if(!(e.isText||e.hasRequiredAttrs()))return e}return null}compatible(t){for(let e=0;e<this.next.length;e++)for(let r=0;r<t.next.length;r++)if(this.next[e].type==t.next[r].type)return true;return false}fillBefore(t,e=false,r=0){let i=[this];function n(s,l){let f=s.matchFragment(t,r);if(f&&(!e||f.validEnd))return o.from(l.map((t=>t.createAndFill())));for(let t=0;t<s.next.length;t++){let{type:e,next:r}=s.next[t];if(!(e.isText||e.hasRequiredAttrs())&&i.indexOf(r)==-1){i.push(r);let t=n(r,l.concat(e));if(t)return t}}return null}return n(this,[])}findWrapping(t){for(let e=0;e<this.wrapCache.length;e+=2)if(this.wrapCache[e]==t)return this.wrapCache[e+1];let e=this.computeWrapping(t);this.wrapCache.push(t,e);return e}computeWrapping(t){let e=Object.create(null),r=[{match:this,type:null,via:null}];while(r.length){let i=r.shift(),n=i.match;if(n.matchType(t)){let t=[];for(let e=i;e.type;e=e.via)t.push(e.type);return t.reverse()}for(let t=0;t<n.next.length;t++){let{type:s,next:l}=n.next[t];if(!s.isLeaf&&!s.hasRequiredAttrs()&&!(s.name in e)&&(!i.type||l.validEnd)){r.push({match:s.contentMatch,type:s,via:i});e[s.name]=true}}}return null}get edgeCount(){return this.next.length}edge(t){if(t>=this.next.length)throw new RangeError(`There's no ${t}th edge in this content match`);return this.next[t]}toString(){let t=[];function e(r){t.push(r);for(let i=0;i<r.next.length;i++)if(t.indexOf(r.next[i].next)==-1)e(r.next[i].next)}e(this);return t.map(((e,r)=>{let i=r+(e.validEnd?"*":" ")+" ";for(let r=0;r<e.next.length;r++)i+=(r?", ":"")+e.next[r].type.name+"->"+t.indexOf(e.next[r].next);return i})).join("\n")}}A.empty=new A(true);class I{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 z(t){let e=[];do{e.push(J(t))}while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function J(t){let e=[];do{e.push(B(t))}while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function B(t){let e=W(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=F(t,e);else break}return e}function j(t){if(/\D/.test(t.next))t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);t.pos++;return e}function F(t,e){let r=j(t),i=r;if(t.eat(",")){if(t.next!="}")i=j(t);else i=-1}if(!t.eat("}"))t.err("Unclosed braced range");return{type:"range",min:r,max:i,expr:e}}function L(t,e){let r=t.nodeTypes,i=r[e];if(i)return[i];let n=[];for(let t in r){let i=r[t];if(i.groups.indexOf(e)>-1)n.push(i)}if(n.length==0)t.err("No node type or group '"+e+"' found");return n}function W(t){if(t.eat("(")){let e=z(t);if(!t.eat(")"))t.err("Missing closing paren");return e}else if(!/\W/.test(t.next)){let e=L(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 U(t){let e=[[]];n(s(t,0),r());return e;function r(){return e.push([])-1}function i(t,r,i){let n={term:i,to:r};e[t].push(n);return n}function n(t,e){t.forEach((t=>t.to=e))}function s(t,e){if(t.type=="choice"){return t.exprs.reduce(((t,r)=>t.concat(s(r,e))),[])}else if(t.type=="seq"){for(let i=0;;i++){let l=s(t.exprs[i],e);if(i==t.exprs.length-1)return l;n(l,e=r())}}else if(t.type=="star"){let l=r();i(e,l);n(s(t.expr,l),l);return[i(l)]}else if(t.type=="plus"){let l=r();n(s(t.expr,e),l);n(s(t.expr,l),l);return[i(l)]}else if(t.type=="opt"){return[i(e)].concat(s(t.expr,e))}else if(t.type=="range"){let l=e;for(let e=0;e<t.min;e++){let e=r();n(s(t.expr,l),e);l=e}if(t.max==-1){n(s(t.expr,l),l)}else{for(let e=t.min;e<t.max;e++){let e=r();i(l,e);n(s(t.expr,l),e);l=e}}return[i(l)]}else if(t.type=="name"){return[i(e,undefined,t.value)]}else{throw new Error("Unknown expr type")}}}function K(t,e){return e-t}function _(t,e){let r=[];i(e);return r.sort(K);function i(e){let n=t[e];if(n.length==1&&!n[0].term)return i(n[0].to);r.push(e);for(let t=0;t<n.length;t++){let{term:e,to:s}=n[t];if(!e&&r.indexOf(s)==-1)i(s)}}}function H(t){let e=Object.create(null);return r(_(t,0));function r(i){let n=[];i.forEach((e=>{t[e].forEach((({term:e,to:r})=>{if(!e)return;let i;for(let t=0;t<n.length;t++)if(n[t][0]==e)i=n[t][1];_(t,r).forEach((t=>{if(!i)n.push([e,i=[]]);if(i.indexOf(t)==-1)i.push(t)}))}))}));let s=e[i.join(",")]=new A(i.indexOf(t.length-1)>-1);for(let t=0;t<n.length;t++){let i=n[t][1].sort(K);s.next.push({type:n[t][0],next:e[i.join(",")]||r(i)})}return s}}function G(t,e){for(let r=0,i=[t];r<i.length;r++){let t=i[r],n=!t.validEnd,s=[];for(let e=0;e<t.next.length;e++){let{type:r,next:l}=t.next[e];s.push(r.name);if(n&&!(r.isText||r.hasRequiredAttrs()))n=false;if(i.indexOf(l)==-1)i.push(l)}if(n)e.err("Only non-generatable nodes ("+s.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function V(t){let e=Object.create(null);for(let r in t){let i=t[r];if(!i.hasDefault)return null;e[r]=i.default}return e}function X(t,e){let r=Object.create(null);for(let i in t){let n=e&&e[i];if(n===undefined){let e=t[i];if(e.hasDefault)n=e.default;else throw new RangeError("No value supplied for attribute "+i)}r[i]=n}return r}function Y(t){let e=Object.create(null);if(t)for(let r in t)e[r]=new Z(t[r]);return e}class Q{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=Y(r.attrs);this.defaultAttrs=V(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==A.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let t in this.attrs)if(this.attrs[t].isRequired)return true;return false}compatibleContent(t){return this==t||this.contentMatch.compatible(t.contentMatch)}computeAttrs(t){if(!t&&this.defaultAttrs)return this.defaultAttrs;else return X(this.attrs,t)}create(t=null,e,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new q(this,this.computeAttrs(t),o.from(e),a.setFrom(r))}createChecked(t=null,e,r){e=o.from(e);this.checkContent(e);return new q(this,this.computeAttrs(t),e,a.setFrom(r))}createAndFill(t=null,e,r){t=this.computeAttrs(t);e=o.from(e);if(e.size){let t=this.contentMatch.fillBefore(e);if(!t)return null;e=t.append(e)}let i=this.contentMatch.matchFragment(e);let n=i&&i.fillBefore(o.empty,true);if(!n)return null;return new q(this,t,e.append(n),a.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)}`)}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:a.none}static compile(t,e){let r=Object.create(null);t.forEach(((t,i)=>r[t]=new Q(t,e,i)));let i=e.spec.topNode||"doc";if(!r[i])throw new RangeError("Schema is missing its top node type ('"+i+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let t in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}}class Z{constructor(t){this.hasDefault=Object.prototype.hasOwnProperty.call(t,"default");this.default=t.default}get isRequired(){return!this.hasDefault}}class tt{constructor(t,e,r,i){this.name=t;this.rank=e;this.schema=r;this.spec=i;this.attrs=Y(i.attrs);this.excluded=null;let n=V(this.attrs);this.instance=n?new a(this,n):null}create(t=null){if(!t&&this.instance)return this.instance;return new a(this,X(this.attrs,t))}static compile(t,e){let r=Object.create(null),i=0;t.forEach(((t,n)=>r[t]=new tt(t,i++,e,n)));return r}removeFromSet(t){for(var e=0;e<t.length;e++)if(t[e].type==this){t=t.slice(0,e).concat(t.slice(e+1));e--}return t}isInSet(t){for(let e=0;e<t.length;e++)if(t[e].type==this)return t[e]}excludes(t){return this.excluded.indexOf(t)>-1}}class et{constructor(t){this.cached=Object.create(null);let e=this.spec={};for(let r in t)e[r]=t[r];e.nodes=n.from(t.nodes),e.marks=n.from(t.marks||{}),this.nodes=Q.compile(this.spec.nodes,this);this.marks=tt.compile(this.spec.marks,this);let r=Object.create(null);for(let t in this.nodes){if(t in this.marks)throw new RangeError(t+" can not be both a node and a mark");let e=this.nodes[t],i=e.spec.content||"",n=e.spec.marks;e.contentMatch=r[i]||(r[i]=A.parse(i,this.nodes));e.inlineContent=e.contentMatch.inlineContent;e.markSet=n=="_"?null:n?rt(this,n.split(" ")):n==""||!e.inlineContent?[]:null}for(let t in this.marks){let e=this.marks[t],r=e.spec.excludes;e.excluded=r==null?[e]:r==""?[]:rt(this,r.split(" "))}this.nodeFromJSON=this.nodeFromJSON.bind(this);this.markFromJSON=this.markFromJSON.bind(this);this.topNodeType=this.nodes[this.spec.topNode||"doc"];this.cached.wrappings=Object.create(null)}node(t,e=null,r,i){if(typeof t=="string")t=this.nodeType(t);else if(!(t instanceof Q))throw new RangeError("Invalid node type: "+t);else if(t.schema!=this)throw new RangeError("Node type from different schema used ("+t.name+")");return t.createChecked(e,r,i)}text(t,e){let r=this.nodes.text;return new T(r,r.defaultAttrs,t,a.setFrom(e))}mark(t,e){if(typeof t=="string")t=this.marks[t];return t.create(e)}nodeFromJSON(t){return q.fromJSON(this,t)}markFromJSON(t){return a.fromJSON(this,t)}nodeType(t){let e=this.nodes[t];if(!e)throw new RangeError("Unknown node type: "+t);return e}}function rt(t,e){let r=[];for(let i=0;i<e.length;i++){let n=e[i],s=t.marks[n],l=s;if(s){r.push(s)}else{for(let e in t.marks){let i=t.marks[e];if(n=="_"||i.spec.group&&i.spec.group.split(" ").indexOf(n)>-1)r.push(l=i)}}if(!l)throw new SyntaxError("Unknown mark type: '"+e[i]+"'")}return r}class it{constructor(t,e){this.schema=t;this.rules=e;this.tags=[];this.styles=[];e.forEach((t=>{if(t.tag)this.tags.push(t);else if(t.style)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 ct(this,e,false);r.addAll(t,e.from,e.to);return r.finish()}parseSlice(t,e={}){let r=new ct(this,e,true);r.addAll(t,e.from,e.to);return d.maxOpen(r.finish())}matchTag(t,e,r){for(let i=r?this.tags.indexOf(r)+1:0;i<this.tags.length;i++){let r=this.tags[i];if(pt(t,r.tag)&&(r.namespace===undefined||t.namespaceURI==r.namespace)&&(!r.context||e.matchesContext(r.context))){if(r.getAttrs){let e=r.getAttrs(t);if(e===false)continue;r.attrs=e||undefined}return r}}}matchStyle(t,e,r,i){for(let n=i?this.styles.indexOf(i)+1:0;n<this.styles.length;n++){let i=this.styles[n],s=i.style;if(s.indexOf(t)!=0||i.context&&!r.matchesContext(i.context)||s.length>t.length&&(s.charCodeAt(t.length)!=61||s.slice(t.length+1)!=e))continue;if(i.getAttrs){let t=i.getAttrs(e);if(t===false)continue;i.attrs=t||undefined}return i}}static schemaRules(t){let e=[];function r(t){let r=t.priority==null?50:t.priority,i=0;for(;i<e.length;i++){let t=e[i],n=t.priority==null?50:t.priority;if(n<r)break}e.splice(i,0,t)}for(let e in t.marks){let i=t.marks[e].spec.parseDOM;if(i)i.forEach((t=>{r(t=wt(t));if(!(t.mark||t.ignore||t.clearMark))t.mark=e}))}for(let e in t.nodes){let i=t.nodes[e].spec.parseDOM;if(i)i.forEach((t=>{r(t=wt(t));if(!(t.node||t.ignore||t.mark))t.node=e}))}return e}static fromSchema(t){return t.cached.domParser||(t.cached.domParser=new it(t,it.schemaRules(t)))}}const nt={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 st={head:true,noscript:true,object:true,script:true,style:true,title:true};const lt={ol:true,ul:true};const ot=1,ft=2,ut=4;function ht(t,e,r){if(e!=null)return(e?ot:0)|(e==="full"?ft:0);return t&&t.whitespace=="pre"?ot|ft:r&~ut}class at{constructor(t,e,r,i,n,s,l){this.type=t;this.attrs=e;this.marks=r;this.pendingMarks=i;this.solid=n;this.options=l;this.content=[];this.activeMarks=a.none;this.stashMarks=[];this.match=s||(l&ut?null:t.contentMatch)}findWrapping(t){if(!this.match){if(!this.type)return[];let e=this.type.contentMatch.fillBefore(o.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&ot)){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=o.from(this.content);if(!t&&this.match)e=e.append(this.match.fillBefore(o.empty,true));return this.type?this.type.create(this.attrs,e,this.marks):e}popFromStashMark(t){for(let e=this.stashMarks.length-1;e>=0;e--)if(t.eq(this.stashMarks[e]))return this.stashMarks.splice(e,1)[0]}applyPending(t){for(let e=0,r=this.pendingMarks;e<r.length;e++){let i=r[e];if((this.type?this.type.allowsMarkType(i.type):gt(i.type,t))&&!i.isInSet(this.activeMarks)){this.activeMarks=i.addToSet(this.activeMarks);this.pendingMarks=i.removeFromSet(this.pendingMarks)}}}inlineContext(t){if(this.type)return this.type.inlineContent;if(this.content.length)return this.content[0].isInline;return t.parentNode&&!nt.hasOwnProperty(t.parentNode.nodeName.toLowerCase())}}class ct{constructor(t,e,r){this.parser=t;this.options=e;this.isOpen=r;this.open=0;let i=e.topNode,n;let s=ht(null,e.preserveWhitespace,0)|(r?ut:0);if(i)n=new at(i.type,i.attrs,a.none,a.none,true,e.topMatch||i.type.contentMatch,s);else if(r)n=new at(null,null,a.none,a.none,true,null,s);else n=new at(t.schema.topNodeType,null,a.none,a.none,true,null,s);this.nodes=[n];this.find=e.findPositions;this.needsBlock=false}get top(){return this.nodes[this.open]}addDOM(t){if(t.nodeType==3)this.addTextNode(t);else if(t.nodeType==1)this.addElement(t)}withStyleRules(t,e){let r=t.getAttribute("style");if(!r)return e();let i=this.readStyles(mt(r));if(!i)return;let[n,s]=i,l=this.top;for(let t=0;t<s.length;t++)this.removePendingMark(s[t],l);for(let t=0;t<n.length;t++)this.addPendingMark(n[t]);e();for(let t=0;t<n.length;t++)this.removePendingMark(n[t],l);for(let t=0;t<s.length;t++)this.addPendingMark(s[t])}addTextNode(t){let e=t.nodeValue;let r=this.top;if(r.options&ft||r.inlineContext(t)||/[^ \t\r\n\u000c]/.test(e)){if(!(r.options&ot)){e=e.replace(/[ \t\r\n\u000c]+/g," ");if(/^[ \t\r\n\u000c]/.test(e)&&this.open==this.nodes.length-1){let i=r.content[r.content.length-1];let n=t.previousSibling;if(!i||n&&n.nodeName=="BR"||i.isText&&/[ \t\r\n\u000c]$/.test(i.text))e=e.slice(1)}}else if(!(r.options&ft)){e=e.replace(/\r?\n|\r/g," ")}else{e=e.replace(/\r\n?/g,"\n")}if(e)this.insertNode(this.parser.schema.text(e));this.findInText(t)}else{this.findInside(t)}}addElement(t,e){let r=t.nodeName.toLowerCase(),i;if(lt.hasOwnProperty(r)&&this.parser.normalizeLists)dt(t);let n=this.options.ruleFromNode&&this.options.ruleFromNode(t)||(i=this.parser.matchTag(t,this,e));if(n?n.ignore:st.hasOwnProperty(r)){this.findInside(t);this.ignoreFallback(t)}else if(!n||n.skip||n.closeParent){if(n&&n.closeParent)this.open=Math.max(0,this.open-1);else if(n&&n.skip.nodeType)t=n.skip;let e,i=this.top,s=this.needsBlock;if(nt.hasOwnProperty(r)){if(i.content.length&&i.content[0].isInline&&this.open){this.open--;i=this.top}e=true;if(!i.type)this.needsBlock=true}else if(!t.firstChild){this.leafFallback(t);return}if(n&&n.skip)this.addAll(t);else this.withStyleRules(t,(()=>this.addAll(t)));if(e)this.sync(i);this.needsBlock=s}else{this.withStyleRules(t,(()=>{this.addElementByRule(t,n,n.consuming===false?i:undefined)}))}}leafFallback(t){if(t.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent)this.addTextNode(t.ownerDocument.createTextNode("\n"))}ignoreFallback(t){if(t.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent))this.findPlace(this.parser.schema.text("-"))}readStyles(t){let e=a.none,r=a.none;for(let i=0;i<t.length;i+=2){for(let n=undefined;;){let s=this.parser.matchStyle(t[i],t[i+1],this,n);if(!s)break;if(s.ignore)return null;if(s.clearMark){this.top.pendingMarks.concat(this.top.activeMarks).forEach((t=>{if(s.clearMark(t))r=t.addToSet(r)}))}else{e=this.parser.schema.marks[s.mark].create(s.attrs).addToSet(e)}if(s.consuming===false)n=s;else break}}return[e,r]}addElementByRule(t,e,r){let i,n,s;if(e.node){n=this.parser.schema.nodes[e.node];if(!n.isLeaf){i=this.enter(n,e.attrs||null,e.preserveWhitespace)}else if(!this.insertNode(n.create(e.attrs))){this.leafFallback(t)}}else{let t=this.parser.schema.marks[e.mark];s=t.create(e.attrs);this.addPendingMark(s)}let l=this.top;if(n&&n.isLeaf){this.findInside(t)}else if(r){this.addElement(t,r)}else if(e.getContent){this.findInside(t);e.getContent(t,this.parser.schema).forEach((t=>this.insertNode(t)))}else{let r=t;if(typeof e.contentElement=="string")r=t.querySelector(e.contentElement);else if(typeof e.contentElement=="function")r=e.contentElement(t);else if(e.contentElement)r=e.contentElement;this.findAround(t,r,true);this.addAll(r)}if(i&&this.sync(l))this.open--;if(s)this.removePendingMark(s,l)}addAll(t,e,r){let i=e||0;for(let n=e?t.childNodes[e]:t.firstChild,s=r==null?null:t.childNodes[r];n!=s;n=n.nextSibling,++i){this.findAtPoint(t,i);this.addDOM(n)}this.findAtPoint(t,i)}findPlace(t){let e,r;for(let i=this.open;i>=0;i--){let n=this.nodes[i];let s=n.findWrapping(t);if(s&&(!e||e.length>s.length)){e=s;r=n;if(!s.length)break}if(n.solid)break}if(!e)return false;this.sync(r);for(let t=0;t<e.length;t++)this.enterInner(e[t],null,false);return true}insertNode(t){if(t.isInline&&this.needsBlock&&!this.top.type){let t=this.textblockFromContext();if(t)this.enterInner(t)}if(this.findPlace(t)){this.closeExtra();let e=this.top;e.applyPending(t.type);if(e.match)e.match=e.match.matchType(t.type);let r=e.activeMarks;for(let i=0;i<t.marks.length;i++)if(!e.type||e.type.allowsMarkType(t.marks[i].type))r=t.marks[i].addToSet(r);e.content.push(t.mark(r));return true}return false}enter(t,e,r){let i=this.findPlace(t.create(e));if(i)this.enterInner(t,e,true,r);return i}enterInner(t,e=null,r=false,i){this.closeExtra();let n=this.top;n.applyPending(t);n.match=n.match&&n.match.matchType(t);let s=ht(t,i,n.options);if(n.options&ut&&n.content.length==0)s|=ut;this.nodes.push(new at(t,e,n.activeMarks,n.pendingMarks,r,null,s));this.open++}closeExtra(t=false){let e=this.nodes.length-1;if(e>this.open){for(;e>this.open;e--)this.nodes[e-1].content.push(this.nodes[e].finish(t));this.nodes.length=this.open+1}}finish(){this.open=0;this.closeExtra(this.isOpen);return this.nodes[0].finish(this.isOpen||this.options.topOpen)}sync(t){for(let e=this.open;e>=0;e--)if(this.nodes[e]==t){this.open=e;return true}return false}get currentPos(){this.closeExtra();let t=0;for(let e=this.open;e>=0;e--){let r=this.nodes[e].content;for(let e=r.length-1;e>=0;e--)t+=r[e].nodeSize;if(e)t++}return t}findAtPoint(t,e){if(this.find)for(let r=0;r<this.find.length;r++){if(this.find[r].node==t&&this.find[r].offset==e)this.find[r].pos=this.currentPos}}findInside(t){if(this.find)for(let e=0;e<this.find.length;e++){if(this.find[e].pos==null&&t.nodeType==1&&t.contains(this.find[e].node))this.find[e].pos=this.currentPos}}findAround(t,e,r){if(t!=e&&this.find)for(let i=0;i<this.find.length;i++){if(this.find[i].pos==null&&t.nodeType==1&&t.contains(this.find[i].node)){let t=e.compareDocumentPosition(this.find[i].node);if(t&(r?2:4))this.find[i].pos=this.currentPos}}}findInText(t){if(this.find)for(let e=0;e<this.find.length;e++){if(this.find[e].node==t)this.find[e].pos=this.currentPos-(t.nodeValue.length-this.find[e].offset)}}matchesContext(t){if(t.indexOf("|")>-1)return t.split(/\s*\|\s*/).some(this.matchesContext,this);let e=t.split("/");let r=this.options.context;let i=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type);let n=-(r?r.depth+1:0)+(i?0:1);let s=(t,l)=>{for(;t>=0;t--){let o=e[t];if(o==""){if(t==e.length-1||t==0)continue;for(;l>=n;l--)if(s(t-1,l))return true;return false}else{let t=l>0||l==0&&i?this.nodes[l].type:r&&l>=n?r.node(l-n).type:null;if(!t||t.name!=o&&t.groups.indexOf(o)==-1)return false;l--}}return true};return s(e.length-1,this.open)}textblockFromContext(){let t=this.options.context;if(t)for(let e=t.depth;e>=0;e--){let r=t.node(e).contentMatchAt(t.indexAfter(e)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let t in this.parser.schema.nodes){let e=this.parser.schema.nodes[t];if(e.isTextblock&&e.defaultAttrs)return e}}addPendingMark(t){let e=bt(t,this.top.pendingMarks);if(e)this.top.stashMarks.push(e);this.top.pendingMarks=t.addToSet(this.top.pendingMarks)}removePendingMark(t,e){for(let r=this.open;r>=0;r--){let i=this.nodes[r];let n=i.pendingMarks.lastIndexOf(t);if(n>-1){i.pendingMarks=t.removeFromSet(i.pendingMarks)}else{i.activeMarks=t.removeFromSet(i.activeMarks);let e=i.popFromStashMark(t);if(e&&i.type&&i.type.allowsMarkType(e.type))i.activeMarks=e.addToSet(i.activeMarks)}if(i==e)break}}}function dt(t){for(let e=t.firstChild,r=null;e;e=e.nextSibling){let t=e.nodeType==1?e.nodeName.toLowerCase():null;if(t&&lt.hasOwnProperty(t)&&r){r.appendChild(e);e=r}else if(t=="li"){r=e}else if(t){r=null}}}function pt(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function mt(t){let e=/\s*([\w-]+)\s*:\s*([^;]+)/g,r,i=[];while(r=e.exec(t))i.push(r[1],r[2].trim());return i}function wt(t){let e={};for(let r in t)e[r]=t[r];return e}function gt(t,e){let r=e.schema.nodes;for(let i in r){let n=r[i];if(!n.allowsMarkType(t))continue;let s=[],l=t=>{s.push(t);for(let r=0;r<t.edgeCount;r++){let{type:i,next:n}=t.edge(r);if(i==e)return true;if(s.indexOf(n)<0&&l(n))return true}};if(l(n.contentMatch))return true}}function bt(t,e){for(let r=0;r<e.length;r++){if(t.eq(e[r]))return e[r]}}class vt{constructor(t,e){this.nodes=t;this.marks=e}serializeFragment(t,e={},r){if(!r)r=yt(e).createDocumentFragment();let i=r,n=[];t.forEach((t=>{if(n.length||t.marks.length){let r=0,s=0;while(r<n.length&&s<t.marks.length){let e=t.marks[s];if(!this.marks[e.type.name]){s++;continue}if(!e.eq(n[r][0])||e.type.spec.spanning===false)break;r++;s++}while(r<n.length)i=n.pop()[1];while(s<t.marks.length){let r=t.marks[s++];let l=this.serializeMark(r,t.isInline,e);if(l){n.push([r,i]);i.appendChild(l.dom);i=l.contentDOM||l.dom}}}i.appendChild(this.serializeNodeInner(t,e))}));return r}serializeNodeInner(t,e){let{dom:r,contentDOM:i}=vt.renderSpec(yt(e),this.nodes[t.type.name](t));if(i){if(t.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(t.content,e,i)}return r}serializeNode(t,e={}){let r=this.serializeNodeInner(t,e);for(let i=t.marks.length-1;i>=0;i--){let n=this.serializeMark(t.marks[i],t.isInline,e);if(n){(n.contentDOM||n.dom).appendChild(r);r=n.dom}}return r}serializeMark(t,e,r={}){let i=this.marks[t.type.name];return i&&vt.renderSpec(yt(r),i(t,e))}static renderSpec(t,e,r=null){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],n=i.indexOf(" ");if(n>0){r=i.slice(0,n);i=i.slice(n+1)}let s;let l=r?t.createElementNS(r,i):t.createElement(i);let o=e[1],f=1;if(o&&typeof o=="object"&&o.nodeType==null&&!Array.isArray(o)){f=2;for(let t in o)if(o[t]!=null){let e=t.indexOf(" ");if(e>0)l.setAttributeNS(t.slice(0,e),t.slice(e+1),o[t]);else l.setAttribute(t,o[t])}}for(let i=f;i<e.length;i++){let n=e[i];if(n===0){if(i<e.length-1||i>f)throw new RangeError("Content hole must be the only child of its parent node");return{dom:l,contentDOM:l}}else{let{dom:e,contentDOM:i}=vt.renderSpec(t,n,r);l.appendChild(e);if(i){if(s)throw new RangeError("Multiple content holes");s=i}}}return{dom:l,contentDOM:s}}static fromSchema(t){return t.cached.domSerializer||(t.cached.domSerializer=new vt(this.nodesFromSchema(t),this.marksFromSchema(t)))}static nodesFromSchema(t){let e=kt(t.nodes);if(!e.text)e.text=t=>t.text;return e}static marksFromSchema(t){return kt(t.marks)}}function kt(t){let e={};for(let r in t){let i=t[r].spec.toDOM;if(i)e[r]=i}return e}function yt(t){return t.document||window.document}const Mt=65535;const xt=Math.pow(2,16);function St(t,e){return t+e*xt}function Ot(t){return t&Mt}function Et(t){return(t-(t&Mt))/xt}const Dt=1,Nt=2,Rt=4,Ct=8;class Pt{constructor(t,e,r){this.pos=t;this.delInfo=e;this.recover=r}get deleted(){return(this.delInfo&Ct)>0}get deletedBefore(){return(this.delInfo&(Dt|Rt))>0}get deletedAfter(){return(this.delInfo&(Nt|Rt))>0}get deletedAcross(){return(this.delInfo&Rt)>0}}class qt{constructor(t,e=false){this.ranges=t;this.inverted=e;if(!t.length&&qt.empty)return qt.empty}recover(t){let e=0,r=Ot(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+Et(t)}mapResult(t,e=1){return this._map(t,e,false)}map(t,e=1){return this._map(t,e,true)}_map(t,e,r){let i=0,n=this.inverted?2:1,s=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let o=this.ranges[l]-(this.inverted?i:0);if(o>t)break;let f=this.ranges[l+n],u=this.ranges[l+s],h=o+f;if(t<=h){let n=!f?e:t==o?-1:t==h?1:e;let s=o+i+(n<0?0:u);if(r)return s;let a=t==(e<0?o:h)?null:St(l/3,t-o);let c=t==o?Nt:t==h?Dt:Rt;if(e<0?t!=o:t!=h)c|=Ct;return new Pt(s,c,a)}i+=u-f}return r?t+i:new Pt(t+i,0,null)}touches(t,e){let r=0,i=Ot(e);let n=this.inverted?2:1,s=this.inverted?1:2;for(let e=0;e<this.ranges.length;e+=3){let l=this.ranges[e]-(this.inverted?r:0);if(l>t)break;let o=this.ranges[e+n],f=l+o;if(t<=f&&e==i*3)return true;r+=this.ranges[e+s]-o}return false}forEach(t){let e=this.inverted?2:1,r=this.inverted?1:2;for(let i=0,n=0;i<this.ranges.length;i+=3){let s=this.ranges[i],l=s-(this.inverted?n:0),o=s+(this.inverted?0:n);let f=this.ranges[i+e],u=this.ranges[i+r];t(l,l+f,o,o+u);n+=u-f}}invert(){return new qt(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(t){return t==0?qt.empty:new qt(t<0?[0,-t,0]:[0,0,t])}}qt.empty=new qt([]);class Tt{constructor(t=[],e,r=0,i=t.length){this.maps=t;this.mirror=e;this.from=r;this.to=i}slice(t=0,e=this.maps.length){return new Tt(this.maps,this.mirror,t,e)}copy(){return new Tt(this.maps.slice(),this.mirror&&this.mirror.slice(),this.from,this.to)}appendMap(t,e){this.to=this.maps.push(t);if(e!=null)this.setMirror(this.maps.length-1,e)}appendMapping(t){for(let e=0,r=this.maps.length;e<t.maps.length;e++){let i=t.getMirror(e);this.appendMap(t.maps[e],i!=null&&i<e?r+i:undefined)}}getMirror(t){if(this.mirror)for(let e=0;e<this.mirror.length;e++)if(this.mirror[e]==t)return this.mirror[e+(e%2?-1:1)]}setMirror(t,e){if(!this.mirror)this.mirror=[];this.mirror.push(t,e)}appendMappingInverted(t){for(let e=t.maps.length-1,r=this.maps.length+t.maps.length;e>=0;e--){let i=t.getMirror(e);this.appendMap(t.maps[e].invert(),i!=null&&i>e?r-i-1:undefined)}}invert(){let t=new Tt;t.appendMappingInverted(this);return t}map(t,e=1){if(this.mirror)return this._map(t,e,true);for(let r=this.from;r<this.to;r++)t=this.maps[r].map(t,e);return t}mapResult(t,e=1){return this._map(t,e,false)}_map(t,e,r){let i=0;for(let r=this.from;r<this.to;r++){let n=this.maps[r],s=n.mapResult(t,e);if(s.recover!=null){let e=this.getMirror(r);if(e!=null&&e>r&&e<this.to){r=e;t=this.maps[e].recover(s.recover);continue}}i|=s.delInfo;t=s.pos}return r?t:new Pt(t,i,null)}}const $t=Object.create(null);class At{getMap(){return qt.empty}merge(t){return null}static fromJSON(t,e){if(!e||!e.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=$t[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 $t)throw new RangeError("Duplicate use of step JSON ID "+t);$t[t]=e;e.prototype.jsonID=t;return e}}class It{constructor(t,e){this.doc=t;this.failed=e}static ok(t){return new It(t,null)}static fail(t){return new It(null,t)}static fromReplace(t,e,r,i){try{return It.ok(t.replace(e,r,i))}catch(t){if(t instanceof c)return It.fail(t.message);throw t}}}function zt(t,e,r){let i=[];for(let n=0;n<t.childCount;n++){let s=t.child(n);if(s.content.size)s=s.copy(zt(s.content,e,s));if(s.isInline)s=e(s,r,n);i.push(s)}return o.fromArray(i)}class Jt extends At{constructor(t,e,r){super();this.from=t;this.to=e;this.mark=r}apply(t){let e=t.slice(this.from,this.to),r=t.resolve(this.from);let i=r.node(r.sharedDepth(this.to));let n=new d(zt(e.content,((t,e)=>{if(!t.isAtom||!e.type.allowsMarkType(this.mark.type))return t;return t.mark(this.mark.addToSet(t.marks))}),i),e.openStart,e.openEnd);return It.fromReplace(t,this.from,this.to,n)}invert(){return new Bt(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 Jt(e.pos,r.pos,this.mark)}merge(t){if(t instanceof Jt&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from)return new Jt(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 Jt(e.from,e.to,t.markFromJSON(e.mark))}}At.jsonID("addMark",Jt);class Bt extends At{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 d(zt(e.content,(t=>t.mark(this.mark.removeFromSet(t.marks))),t),e.openStart,e.openEnd);return It.fromReplace(t,this.from,this.to,r)}invert(){return new Jt(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 Bt(e.pos,r.pos,this.mark)}merge(t){if(t instanceof Bt&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from)return new Bt(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 Bt(e.from,e.to,t.markFromJSON(e.mark))}}At.jsonID("removeMark",Bt);class jt extends At{constructor(t,e){super();this.pos=t;this.mark=e}apply(t){let e=t.nodeAt(this.pos);if(!e)return It.fail("No node at mark step's position");let r=e.type.create(e.attrs,null,this.mark.addToSet(e.marks));return It.fromReplace(t,this.pos,this.pos+1,new d(o.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 jt(this.pos,e.marks[r]);return new jt(this.pos,this.mark)}}return new Ft(this.pos,this.mark)}map(t){let e=t.mapResult(this.pos,1);return e.deletedAfter?null:new jt(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 jt(e.pos,t.markFromJSON(e.mark))}}At.jsonID("addNodeMark",jt);class Ft extends At{constructor(t,e){super();this.pos=t;this.mark=e}apply(t){let e=t.nodeAt(this.pos);if(!e)return It.fail("No node at mark step's position");let r=e.type.create(e.attrs,null,this.mark.removeFromSet(e.marks));return It.fromReplace(t,this.pos,this.pos+1,new d(o.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 jt(this.pos,this.mark)}map(t){let e=t.mapResult(this.pos,1);return e.deletedAfter?null:new Ft(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 Ft(e.pos,t.markFromJSON(e.mark))}}At.jsonID("removeNodeMark",Ft);class Lt extends At{constructor(t,e,r,i=false){super();this.from=t;this.to=e;this.slice=r;this.structure=i}apply(t){if(this.structure&&Ut(t,this.from,this.to))return It.fail("Structure replace would overwrite content");return It.fromReplace(t,this.from,this.to,this.slice)}getMap(){return new qt([this.from,this.to-this.from,this.slice.size])}invert(t){return new Lt(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 Lt(e.pos,Math.max(e.pos,r.pos),this.slice)}merge(t){if(!(t instanceof Lt)||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?d.empty:new d(this.slice.content.append(t.slice.content),this.slice.openStart,t.slice.openEnd);return new Lt(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?d.empty:new d(t.slice.content.append(this.slice.content),t.slice.openStart,this.slice.openEnd);return new Lt(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 Lt(e.from,e.to,d.fromJSON(t,e.slice),!!e.structure)}}At.jsonID("replace",Lt);class Wt extends At{constructor(t,e,r,i,n,s,l=false){super();this.from=t;this.to=e;this.gapFrom=r;this.gapTo=i;this.slice=n;this.insert=s;this.structure=l}apply(t){if(this.structure&&(Ut(t,this.from,this.gapFrom)||Ut(t,this.gapTo,this.to)))return It.fail("Structure gap-replace would overwrite content");let e=t.slice(this.gapFrom,this.gapTo);if(e.openStart||e.openEnd)return It.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,e.content);if(!r)return It.fail("Content does not fit in gap");return It.fromReplace(t,this.from,this.to,r)}getMap(){return new qt([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 Wt(this.from,this.from+this.slice.size+e,this.from+this.insert,this.from+this.insert+e,t.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(t){let e=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);let i=t.map(this.gapFrom,-1),n=t.map(this.gapTo,1);if(e.deletedAcross&&r.deletedAcross||i<e.pos||n>r.pos)return null;return new Wt(e.pos,r.pos,i,n,this.slice,this.insert,this.structure)}toJSON(){let t={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};if(this.slice.size)t.slice=this.slice.toJSON();if(this.structure)t.structure=true;return t}static fromJSON(t,e){if(typeof e.from!="number"||typeof e.to!="number"||typeof e.gapFrom!="number"||typeof e.gapTo!="number"||typeof e.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new Wt(e.from,e.to,e.gapFrom,e.gapTo,d.fromJSON(t,e.slice),e.insert,!!e.structure)}}At.jsonID("replaceAround",Wt);function Ut(t,e,r){let i=t.resolve(e),n=r-e,s=i.depth;while(n>0&&s>0&&i.indexAfter(s)==i.node(s).childCount){s--;n--}if(n>0){let t=i.node(s).maybeChild(i.indexAfter(s));while(n>0){if(!t||t.isLeaf)return true;t=t.firstChild;n--}}return false}function Kt(t,e,r,i){let n=[],s=[];let l,o;t.doc.nodesBetween(e,r,((t,f,u)=>{if(!t.isInline)return;let h=t.marks;if(!i.isInSet(h)&&u.type.allowsMarkType(i.type)){let u=Math.max(f,e),a=Math.min(f+t.nodeSize,r);let c=i.addToSet(h);for(let t=0;t<h.length;t++){if(!h[t].isInSet(c)){if(l&&l.to==u&&l.mark.eq(h[t]))l.to=a;else n.push(l=new Bt(u,a,h[t]))}}if(o&&o.to==u)o.to=a;else s.push(o=new Jt(u,a,i))}}));n.forEach((e=>t.step(e)));s.forEach((e=>t.step(e)))}function _t(t,e,r,i){let n=[],s=0;t.doc.nodesBetween(e,r,((t,l)=>{if(!t.isInline)return;s++;let o=null;if(i instanceof tt){let e=t.marks,r;while(r=i.isInSet(e)){(o||(o=[])).push(r);e=r.removeFromSet(e)}}else if(i){if(i.isInSet(t.marks))o=[i]}else{o=t.marks}if(o&&o.length){let i=Math.min(l+t.nodeSize,r);for(let t=0;t<o.length;t++){let r=o[t],f;for(let t=0;t<n.length;t++){let e=n[t];if(e.step==s-1&&r.eq(n[t].style))f=e}if(f){f.to=i;f.step=s}else{n.push({style:r,from:Math.max(l,e),to:i,step:s})}}}}));n.forEach((e=>t.step(new Bt(e.from,e.to,e.style))))}function Ht(t,e,r,i=r.contentMatch){let n=t.doc.nodeAt(e);let s=[],l=e+1;for(let e=0;e<n.childCount;e++){let f=n.child(e),u=l+f.nodeSize;let h=i.matchType(f.type);if(!h){s.push(new Lt(l,u,d.empty))}else{i=h;for(let e=0;e<f.marks.length;e++)if(!r.allowsMarkType(f.marks[e].type))t.step(new Bt(l,u,f.marks[e]));if(f.isText&&!r.spec.code){let t,e=/\r?\n|\r/g,i;while(t=e.exec(f.text)){if(!i)i=new d(o.from(r.schema.text(" ",r.allowedMarks(f.marks))),0,0);s.push(new Lt(l+t.index,l+t.index+t[0].length,i))}}}l=u}if(!i.validEnd){let e=i.fillBefore(o.empty,true);t.replace(l,l,new d(e,0,0))}for(let e=s.length-1;e>=0;e--)t.step(s[e])}function Gt(t,e,r){return(e==0||t.canReplace(e,t.childCount))&&(r==t.childCount||t.canReplace(0,r))}function Vt(t){let e=t.parent;let r=e.content.cutByIndex(t.startIndex,t.endIndex);for(let e=t.depth;;--e){let i=t.$from.node(e);let n=t.$from.index(e),s=t.$to.indexAfter(e);if(e<t.depth&&i.canReplace(n,s,r))return e;if(e==0||i.type.spec.isolating||!Gt(i,n,s))break}return null}function Xt(t,e,r){let{$from:i,$to:n,depth:s}=e;let l=i.before(s+1),f=n.after(s+1);let u=l,h=f;let a=o.empty,c=0;for(let t=s,e=false;t>r;t--)if(e||i.index(t)>0){e=true;a=o.from(i.node(t).copy(a));c++}else{u--}let p=o.empty,m=0;for(let t=s,e=false;t>r;t--)if(e||n.after(t+1)<n.end(t)){e=true;p=o.from(n.node(t).copy(p));m++}else{h++}t.step(new Wt(u,h,l,f,new d(a.append(p),c,m),a.size-c,true))}function Yt(t,e,r=null,i=t){let n=Zt(t,e);let s=n&&te(i,e);if(!s)return null;return n.map(Qt).concat({type:e,attrs:r}).concat(s.map(Qt))}function Qt(t){return{type:t,attrs:null}}function Zt(t,e){let{parent:r,startIndex:i,endIndex:n}=t;let s=r.contentMatchAt(i).findWrapping(e);if(!s)return null;let l=s.length?s[0]:e;return r.canReplaceWith(i,n,l)?s:null}function te(t,e){let{parent:r,startIndex:i,endIndex:n}=t;let s=r.child(i);let l=e.contentMatch.findWrapping(s.type);if(!l)return null;let o=l.length?l[l.length-1]:e;let f=o.contentMatch;for(let t=i;f&&t<n;t++)f=f.matchType(r.child(t).type);if(!f||!f.validEnd)return null;return l}function ee(t,e,r){let i=o.empty;for(let t=r.length-1;t>=0;t--){if(i.size){let e=r[t].type.contentMatch.matchFragment(i);if(!e||!e.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}i=o.from(r[t].type.create(r[t].attrs,i))}let n=e.start,s=e.end;t.step(new Wt(n,s,n,s,new d(i,0,0),r.length,true))}function re(t,e,r,i,n){if(!i.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let s=t.steps.length;t.doc.nodesBetween(e,r,((e,r)=>{if(e.isTextblock&&!e.hasMarkup(i,n)&&ie(t.doc,t.mapping.slice(s).map(r),i)){t.clearIncompatible(t.mapping.slice(s).map(r,1),i);let l=t.mapping.slice(s);let f=l.map(r,1),u=l.map(r+e.nodeSize,1);t.step(new Wt(f,u,f+1,u-1,new d(o.from(i.create(n,null,e.marks)),0,0),1,true));return false}}))}function ie(t,e,r){let i=t.resolve(e),n=i.index();return i.parent.canReplaceWith(n,n+1,r)}function ne(t,e,r,i,n){let s=t.doc.nodeAt(e);if(!s)throw new RangeError("No node at given position");if(!r)r=s.type;let l=r.create(i,null,n||s.marks);if(s.isLeaf)return t.replaceWith(e,e+s.nodeSize,l);if(!r.validContent(s.content))throw new RangeError("Invalid content for node type "+r.name);t.step(new Wt(e,e+s.nodeSize,e+1,e+s.nodeSize-1,new d(o.from(l),0,0),1,true))}function se(t,e,r=1,i){let n=t.resolve(e),s=n.depth-r;let l=i&&i[i.length-1]||n.parent;if(s<0||n.parent.type.spec.isolating||!n.parent.canReplace(n.index(),n.parent.childCount)||!l.type.validContent(n.parent.content.cutByIndex(n.index(),n.parent.childCount)))return false;for(let t=n.depth-1,e=r-2;t>s;t--,e--){let r=n.node(t),s=n.index(t);if(r.type.spec.isolating)return false;let l=r.content.cutByIndex(s,r.childCount);let o=i&&i[e+1];if(o)l=l.replaceChild(0,o.type.create(o.attrs));let f=i&&i[e]||r;if(!r.canReplace(s+1,r.childCount)||!f.type.validContent(l))return false}let o=n.indexAfter(s);let f=i&&i[0];return n.node(s).canReplaceWith(o,o,f?f.type:n.node(s+1).type)}function le(t,e,r=1,i){let n=t.doc.resolve(e),s=o.empty,l=o.empty;for(let t=n.depth,e=n.depth-r,f=r-1;t>e;t--,f--){s=o.from(n.node(t).copy(s));let e=i&&i[f];l=o.from(e?e.type.create(e.attrs,l):n.node(t).copy(l))}t.step(new Lt(e,e,new d(s.append(l),r,r),true))}function oe(t,e){let r=t.resolve(e),i=r.index();return fe(r.nodeBefore,r.nodeAfter)&&r.parent.canReplace(i,i+1)}function fe(t,e){return!!(t&&e&&!t.isLeaf&&t.canAppend(e))}function ue(t,e,r=-1){let i=t.resolve(e);for(let t=i.depth;;t--){let n,s,l=i.index(t);if(t==i.depth){n=i.nodeBefore;s=i.nodeAfter}else if(r>0){n=i.node(t+1);l++;s=i.node(t).maybeChild(l)}else{n=i.node(t).maybeChild(l-1);s=i.node(t+1)}if(n&&!n.isTextblock&&fe(n,s)&&i.node(t).canReplace(l,l+1))return e;if(t==0)break;e=r<0?i.before(t):i.after(t)}}function he(t,e,r){let i=new Lt(e-r,e+r,d.empty,true);t.step(i)}function ae(t,e,r){let i=t.resolve(e);if(i.parent.canReplaceWith(i.index(),i.index(),r))return e;if(i.parentOffset==0)for(let t=i.depth-1;t>=0;t--){let e=i.index(t);if(i.node(t).canReplaceWith(e,e,r))return i.before(t+1);if(e>0)return null}if(i.parentOffset==i.parent.content.size)for(let t=i.depth-1;t>=0;t--){let e=i.indexAfter(t);if(i.node(t).canReplaceWith(e,e,r))return i.after(t+1);if(e<i.node(t).childCount)return null}return null}function ce(t,e,r){let i=t.resolve(e);if(!r.content.size)return e;let n=r.content;for(let t=0;t<r.openStart;t++)n=n.firstChild.content;for(let t=1;t<=(r.openStart==0&&r.size?2:1);t++){for(let e=i.depth;e>=0;e--){let r=e==i.depth?0:i.pos<=(i.start(e+1)+i.end(e+1))/2?-1:1;let s=i.index(e)+(r>0?1:0);let l=i.node(e),o=false;if(t==1){o=l.canReplace(s,s,n)}else{let t=l.contentMatchAt(s).findWrapping(n.firstChild.type);o=t&&l.canReplaceWith(s,s,t[0])}if(o)return r==0?i.pos:r<0?i.before(e+1):i.after(e+1)}}return null}function de(t,e,r=e,i=d.empty){if(e==r&&!i.size)return null;let n=t.resolve(e),s=t.resolve(r);if(pe(n,s,i))return new Lt(e,r,i);return new me(n,s,i).fit()}function pe(t,e,r){return!r.openStart&&!r.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),r.content)}class me{constructor(t,e,r){this.$from=t;this.$to=e;this.unplaced=r;this.frontier=[];this.placed=o.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=o.from(t.node(e).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){while(this.unplaced.size){let t=this.findFittable();if(t)this.placeNodes(t);else this.openMore()||this.dropNode()}let t=this.mustMoveInline(),e=this.placed.size-this.depth-this.$from.depth;let r=this.$from,i=this.close(t<0?this.$to:r.doc.resolve(t));if(!i)return null;let n=this.placed,s=r.depth,l=i.depth;while(s&&l&&n.childCount==1){n=n.firstChild.content;s--;l--}let o=new d(n,s,l);if(t>-1)return new Wt(r.pos,t,this.$to.pos,this.$to.end(),o,e);if(o.size||r.pos!=this.$to.pos)return new Lt(r.pos,i.pos,o);return null}findFittable(){let t=this.unplaced.openStart;for(let e=this.unplaced.content,r=0,i=this.unplaced.openEnd;r<t;r++){let n=e.firstChild;if(e.childCount>1)i=0;if(n.type.spec.isolating&&i<=r){t=r;break}e=n.content}for(let e=1;e<=2;e++){for(let r=e==1?t:this.unplaced.openStart;r>=0;r--){let t,i=null;if(r){i=be(this.unplaced.content,r-1).firstChild;t=i.content}else{t=this.unplaced.content}let n=t.firstChild;for(let t=this.depth;t>=0;t--){let{type:s,match:l}=this.frontier[t],f,u=null;if(e==1&&(n?l.matchType(n.type)||(u=l.fillBefore(o.from(n),false)):i&&s.compatibleContent(i.type)))return{sliceDepth:r,frontierDepth:t,parent:i,inject:u};else if(e==2&&n&&(f=l.findWrapping(n.type)))return{sliceDepth:r,frontierDepth:t,parent:i,wrap:f};if(i&&l.matchType(i.type))break}}}}openMore(){let{content:t,openStart:e,openEnd:r}=this.unplaced;let i=be(t,e);if(!i.childCount||i.firstChild.isLeaf)return false;this.unplaced=new d(t,e+1,Math.max(r,i.size+e>=t.size-r?e+1:0));return true}dropNode(){let{content:t,openStart:e,openEnd:r}=this.unplaced;let i=be(t,e);if(i.childCount<=1&&e>0){let n=t.size-e<=e+i.size;this.unplaced=new d(we(t,e-1,1),e-1,n?e-1:r)}else{this.unplaced=new d(we(t,e,1),e,r)}}placeNodes({sliceDepth:t,frontierDepth:e,parent:r,inject:i,wrap:n}){while(this.depth>e)this.closeFrontierNode();if(n)for(let t=0;t<n.length;t++)this.openFrontierNode(n[t]);let s=this.unplaced,l=r?r.content:s.content;let f=s.openStart-t;let u=0,h=[];let{match:a,type:c}=this.frontier[e];if(i){for(let t=0;t<i.childCount;t++)h.push(i.child(t));a=a.matchFragment(i)}let p=l.size+t-(s.content.size-s.openEnd);while(u<l.childCount){let t=l.child(u),e=a.matchType(t.type);if(!e)break;u++;if(u>1||f==0||t.content.size){a=e;h.push(ve(t.mark(c.allowedMarks(t.marks)),u==1?f:0,u==l.childCount?p:-1))}}let m=u==l.childCount;if(!m)p=-1;this.placed=ge(this.placed,e,o.from(h));this.frontier[e].match=a;if(m&&p<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1)this.closeFrontierNode();for(let t=0,e=l;t<p;t++){let t=e.lastChild;this.frontier.push({type:t.type,match:t.contentMatchAt(t.childCount)});e=t.content}this.unplaced=!m?new d(we(s.content,t,u),s.openStart,s.openEnd):t==0?d.empty:new d(we(s.content,t-1,1),t-1,p<0?s.openEnd:t-1)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let t=this.frontier[this.depth],e;if(!t.type.isTextblock||!ke(this.$to,this.$to.depth,t.type,t.match,false)||this.$to.depth==this.depth&&(e=this.findCloseLevel(this.$to))&&e.depth==this.depth)return-1;let{depth:r}=this.$to,i=this.$to.after(r);while(r>1&&i==this.$to.end(--r))++i;return i}findCloseLevel(t){t:for(let e=Math.min(this.depth,t.depth);e>=0;e--){let{match:r,type:i}=this.frontier[e];let n=e<t.depth&&t.end(e+1)==t.pos+(t.depth-(e+1));let s=ke(t,e,i,r,n);if(!s)continue;for(let r=e-1;r>=0;r--){let{match:e,type:i}=this.frontier[r];let n=ke(t,r,i,e,true);if(!n||n.childCount)continue t}return{depth:e,fit:s,move:n?t.doc.resolve(t.after(e+1)):t}}}close(t){let e=this.findCloseLevel(t);if(!e)return null;while(this.depth>e.depth)this.closeFrontierNode();if(e.fit.childCount)this.placed=ge(this.placed,e.depth,e.fit);t=e.move;for(let r=e.depth+1;r<=t.depth;r++){let e=t.node(r),i=e.type.contentMatch.fillBefore(e.content,true,t.index(r));this.openFrontierNode(e.type,e.attrs,i)}return t}openFrontierNode(t,e=null,r){let i=this.frontier[this.depth];i.match=i.match.matchType(t);this.placed=ge(this.placed,this.depth,o.from(t.create(e,r)));this.frontier.push({type:t,match:t.contentMatch})}closeFrontierNode(){let t=this.frontier.pop();let e=t.match.fillBefore(o.empty,true);if(e.childCount)this.placed=ge(this.placed,this.frontier.length,e)}}function we(t,e,r){if(e==0)return t.cutByIndex(r,t.childCount);return t.replaceChild(0,t.firstChild.copy(we(t.firstChild.content,e-1,r)))}function ge(t,e,r){if(e==0)return t.append(r);return t.replaceChild(t.childCount-1,t.lastChild.copy(ge(t.lastChild.content,e-1,r)))}function be(t,e){for(let r=0;r<e;r++)t=t.firstChild.content;return t}function ve(t,e,r){if(e<=0)return t;let i=t.content;if(e>1)i=i.replaceChild(0,ve(i.firstChild,e-1,i.childCount==1?r-1:0));if(e>0){i=t.type.contentMatch.fillBefore(i).append(i);if(r<=0)i=i.append(t.type.contentMatch.matchFragment(i).fillBefore(o.empty,true))}return t.copy(i)}function ke(t,e,r,i,n){let s=t.node(e),l=n?t.indexAfter(e):t.index(e);if(l==s.childCount&&!r.compatibleContent(s.type))return null;let o=i.fillBefore(s.content,true,l);return o&&!ye(r,s.content,l)?o:null}function ye(t,e,r){for(let i=r;i<e.childCount;i++)if(!t.allowsMarks(e.child(i).marks))return true;return false}function Me(t){return t.spec.defining||t.spec.definingForContent}function xe(t,e,r,i){if(!i.size)return t.deleteRange(e,r);let n=t.doc.resolve(e),s=t.doc.resolve(r);if(pe(n,s,i))return t.step(new Lt(e,r,i));let l=De(n,t.doc.resolve(r));if(l[l.length-1]==0)l.pop();let o=-(n.depth+1);l.unshift(o);for(let t=n.depth,e=n.pos-1;t>0;t--,e--){let r=n.node(t).type.spec;if(r.defining||r.definingAsContext||r.isolating)break;if(l.indexOf(t)>-1)o=t;else if(n.before(t)==e)l.splice(1,0,-t)}let f=l.indexOf(o);let u=[],h=i.openStart;for(let t=i.content,e=0;;e++){let r=t.firstChild;u.push(r);if(e==i.openStart)break;t=r.content}for(let t=h-1;t>=0;t--){let e=u[t],r=Me(e.type);if(r&&!e.sameMarkup(n.node(Math.abs(o)-1)))h=t;else if(r||!e.type.isTextblock)break}for(let e=i.openStart;e>=0;e--){let o=(e+h+1)%(i.openStart+1);let a=u[o];if(!a)continue;for(let e=0;e<l.length;e++){let u=l[(e+f)%l.length],h=true;if(u<0){h=false;u=-u}let c=n.node(u-1),p=n.index(u-1);if(c.canReplaceWith(p,p,a.type,a.marks))return t.replace(n.before(u),h?s.after(u):r,new d(Se(i.content,0,i.openStart,o),o,i.openEnd))}}let a=t.steps.length;for(let o=l.length-1;o>=0;o--){t.replace(e,r,i);if(t.steps.length>a)break;let f=l[o];if(f<0)continue;e=n.before(f);r=s.after(f)}}function Se(t,e,r,i,n){if(e<r){let n=t.firstChild;t=t.replaceChild(0,n.copy(Se(n.content,e+1,r,i,n)))}if(e>i){let e=n.contentMatchAt(0);let r=e.fillBefore(t).append(t);t=r.append(e.matchFragment(r).fillBefore(o.empty,true))}return t}function Oe(t,e,r,i){if(!i.isInline&&e==r&&t.doc.resolve(e).parent.content.size){let n=ae(t.doc,e,i.type);if(n!=null)e=r=n}t.replaceRange(e,r,new d(o.from(i),0,0))}function Ee(t,e,r){let i=t.doc.resolve(e),n=t.doc.resolve(r);let s=De(i,n);for(let e=0;e<s.length;e++){let r=s[e],l=e==s.length-1;if(l&&r==0||i.node(r).type.contentMatch.validEnd)return t.delete(i.start(r),n.end(r));if(r>0&&(l||i.node(r-1).canReplace(i.index(r-1),n.indexAfter(r-1))))return t.delete(i.before(r),n.after(r))}for(let s=1;s<=i.depth&&s<=n.depth;s++){if(e-i.start(s)==i.depth-s&&r>i.end(s)&&n.end(s)-r!=n.depth-s)return t.delete(i.before(s),r)}t.delete(e,r)}function De(t,e){let r=[],i=Math.min(t.depth,e.depth);for(let n=i;n>=0;n--){let i=t.start(n);if(i<t.pos-(t.depth-n)||e.end(n)>e.pos+(e.depth-n)||t.node(n).type.spec.isolating||e.node(n).type.spec.isolating)break;if(i==e.start(n)||n==t.depth&&n==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&n&&e.start(n-1)==i-1)r.push(n)}return r}class Ne extends At{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 It.fail("No node at attribute step's position");let r=Object.create(null);for(let t in e.attrs)r[t]=e.attrs[t];r[this.attr]=this.value;let i=e.type.create(r,null,e.marks);return It.fromReplace(t,this.pos,this.pos+1,new d(o.from(i),0,e.isLeaf?0:1))}getMap(){return qt.empty}invert(t){return new Ne(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 Ne(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 Ne(e.pos,e.attr,e.value)}}At.jsonID("attr",Ne);class Re extends At{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 It.ok(r)}getMap(){return qt.empty}invert(t){return new Re(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 Re(e.attr,e.value)}}At.jsonID("docAttr",Re);let Ce=class extends Error{};Ce=function t(e){let r=Error.call(this,e);r.__proto__=t.prototype;return r};Ce.prototype=Object.create(Error.prototype);Ce.prototype.constructor=Ce;Ce.prototype.name="TransformError";class Pe{constructor(t){this.doc=t;this.steps=[];this.docs=[];this.mapping=new Tt}get before(){return this.docs.length?this.docs[0]:this.doc}step(t){let e=this.maybeStep(t);if(e.failed)throw new Ce(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=d.empty){let i=de(this.doc,t,e,r);if(i)this.step(i);return this}replaceWith(t,e,r){return this.replace(t,e,new d(o.from(r),0,0))}delete(t,e){return this.replace(t,e,d.empty)}insert(t,e){return this.replaceWith(t,t,e)}replaceRange(t,e,r){xe(this,t,e,r);return this}replaceRangeWith(t,e,r){Oe(this,t,e,r);return this}deleteRange(t,e){Ee(this,t,e);return this}lift(t,e){Xt(this,t,e);return this}join(t,e=1){he(this,t,e);return this}wrap(t,e){ee(this,t,e);return this}setBlockType(t,e=t,r,i=null){re(this,t,e,r,i);return this}setNodeMarkup(t,e,r=null,i){ne(this,t,e,r,i);return this}setNodeAttribute(t,e,r){this.step(new Ne(t,e,r));return this}setDocAttribute(t,e){this.step(new Re(t,e));return this}addNodeMark(t,e){this.step(new jt(t,e));return this}removeNodeMark(t,e){if(!(e instanceof a)){let r=this.doc.nodeAt(t);if(!r)throw new RangeError("No node at position "+t);e=e.isInSet(r.marks);if(!e)return this}this.step(new Ft(t,e));return this}split(t,e=1,r){le(this,t,e,r);return this}addMark(t,e,r){Kt(this,t,e,r);return this}removeMark(t,e,r){_t(this,t,e,r);return this}clearIncompatible(t,e,r){Ht(this,t,e,r);return this}}const qe=Object.create(null);class Te{constructor(t,e,r){this.$anchor=t;this.$head=e;this.ranges=r||[new $e(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=d.empty){let r=e.content.lastChild,i=null;for(let t=0;t<e.openEnd;t++){i=r;r=r.lastChild}let n=t.steps.length,s=this.ranges;for(let l=0;l<s.length;l++){let{$from:o,$to:f}=s[l],u=t.mapping.slice(n);t.replaceRange(u.map(o.pos),u.map(f.pos),l?d.empty:e);if(l==0)Ue(t,n,(r?r.isInline:i&&i.isTextblock)?-1:1)}}replaceWith(t,e){let r=t.steps.length,i=this.ranges;for(let n=0;n<i.length;n++){let{$from:s,$to:l}=i[n],o=t.mapping.slice(r);let f=o.map(s.pos),u=o.map(l.pos);if(n){t.deleteRange(f,u)}else{t.replaceRangeWith(f,u,e);Ue(t,r,e.isInline?-1:1)}}}static findFrom(t,e,r=false){let i=t.parent.inlineContent?new ze(t):We(t.node(0),t.parent,t.pos,t.index(),e,r);if(i)return i;for(let i=t.depth-1;i>=0;i--){let n=e<0?We(t.node(0),t.node(i),t.before(i+1),t.index(i),e,r):We(t.node(0),t.node(i),t.after(i+1),t.index(i)+1,e,r);if(n)return n}return null}static near(t,e=1){return this.findFrom(t,e)||this.findFrom(t,-e)||new Fe(t.node(0))}static atStart(t){return We(t,t,0,0,1)||new Fe(t)}static atEnd(t){return We(t,t,t.content.size,t.childCount,-1)||new Fe(t)}static fromJSON(t,e){if(!e||!e.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=qe[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 qe)throw new RangeError("Duplicate use of selection JSON ID "+t);qe[t]=e;e.prototype.jsonID=t;return e}getBookmark(){return ze.between(this.$anchor,this.$head).getBookmark()}}Te.prototype.visible=true;class $e{constructor(t,e){this.$from=t;this.$to=e}}let Ae=false;function Ie(t){if(!Ae&&!t.parent.inlineContent){Ae=true;console["warn"]("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")")}}class ze extends Te{constructor(t,e=t){Ie(t);Ie(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 Te.near(r);let i=t.resolve(e.map(this.anchor));return new ze(i.parent.inlineContent?i:r,r)}replace(t,e=d.empty){super.replace(t,e);if(e==d.empty){let e=this.$from.marksAcross(this.$to);if(e)t.ensureMarks(e)}}eq(t){return t instanceof ze&&t.anchor==this.anchor&&t.head==this.head}getBookmark(){return new Je(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 ze(t.resolve(e.anchor),t.resolve(e.head))}static create(t,e,r=e){let i=t.resolve(e);return new this(i,r==e?i:t.resolve(r))}static between(t,e,r){let i=t.pos-e.pos;if(!r||i)r=i>=0?1:-1;if(!e.parent.inlineContent){let t=Te.findFrom(e,r,true)||Te.findFrom(e,-r,true);if(t)e=t.$head;else return Te.near(e,r)}if(!t.parent.inlineContent){if(i==0){t=e}else{t=(Te.findFrom(t,-r,true)||Te.findFrom(t,r,true)).$anchor;if(t.pos<e.pos!=i<0)t=e}}return new ze(t,e)}}Te.jsonID("text",ze);class Je{constructor(t,e){this.anchor=t;this.head=e}map(t){return new Je(t.map(this.anchor),t.map(this.head))}resolve(t){return ze.between(t.resolve(this.anchor),t.resolve(this.head))}}class Be extends Te{constructor(t){let e=t.nodeAfter;let r=t.node(0).resolve(t.pos+e.nodeSize);super(t,r);this.node=e}map(t,e){let{deleted:r,pos:i}=e.mapResult(this.anchor);let n=t.resolve(i);if(r)return Te.near(n);return new Be(n)}content(){return new d(o.from(this.node),0,0)}eq(t){return t instanceof Be&&t.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new je(this.anchor)}static fromJSON(t,e){if(typeof e.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new Be(t.resolve(e.anchor))}static create(t,e){return new Be(t.resolve(e))}static isSelectable(t){return!t.isText&&t.type.spec.selectable!==false}}Be.prototype.visible=false;Te.jsonID("node",Be);class je{constructor(t){this.anchor=t}map(t){let{deleted:e,pos:r}=t.mapResult(this.anchor);return e?new Je(r,r):new je(r)}resolve(t){let e=t.resolve(this.anchor),r=e.nodeAfter;if(r&&Be.isSelectable(r))return new Be(e);return Te.near(e)}}class Fe extends Te{constructor(t){super(t.resolve(0),t.resolve(t.content.size))}replace(t,e=d.empty){if(e==d.empty){t.delete(0,t.doc.content.size);let e=Te.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 Fe(t)}map(t){return new Fe(t)}eq(t){return t instanceof Fe}getBookmark(){return Le}}Te.jsonID("all",Fe);const Le={map(){return this},resolve(t){return new Fe(t)}};function We(t,e,r,i,n,s=false){if(e.inlineContent)return ze.create(t,r);for(let l=i-(n>0?0:1);n>0?l<e.childCount:l>=0;l+=n){let i=e.child(l);if(!i.isAtom){let e=We(t,i,r+n,n<0?i.childCount:0,n,s);if(e)return e}else if(!s&&Be.isSelectable(i)){return Be.create(t,r-(n<0?i.nodeSize:0))}r+=i.nodeSize*n}return null}function Ue(t,e,r){let i=t.steps.length-1;if(i<e)return;let n=t.steps[i];if(!(n instanceof Lt||n instanceof Wt))return;let s=t.mapping.maps[i],l;s.forEach(((t,e,r,i)=>{if(l==null)l=i}));t.setSelection(Te.near(t.doc.resolve(l),r))}const Ke=1,_e=2,He=4;class Ge extends Pe{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|Ke)&~_e;this.storedMarks=null;return this}get selectionSet(){return(this.updated&Ke)>0}setStoredMarks(t){this.storedMarks=t;this.updated|=_e;return this}ensureMarks(t){if(!a.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&_e)>0}addStep(t,e){super.addStep(t,e);this.updated=this.updated&~_e;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)||a.none));r.replaceWith(this,t);return this}deleteSelection(){this.selection.replace(this);return this}insertText(t,e,r){let i=this.doc.type.schema;if(e==null){if(!t)return this.deleteSelection();return this.replaceSelectionWith(i.text(t),true)}else{if(r==null)r=e;r=r==null?e:r;if(!t)return this.deleteRange(e,r);let n=this.storedMarks;if(!n){let t=this.doc.resolve(e);n=r==e?t.marks():t.marksAcross(this.doc.resolve(r))}this.replaceRangeWith(e,r,i.text(t,n));if(!this.selection.empty)this.setSelection(Te.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|=He;return this}get scrolledIntoView(){return(this.updated&He)>0}}function Ve(t,e){return!e||!t?t:t.bind(e)}class Xe{constructor(t,e,r){this.name=t;this.init=Ve(e.init,r);this.apply=Ve(e.apply,r)}}const Ye=[new Xe("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new Xe("selection",{init(t,e){return t.selection||Te.atStart(e.doc)},apply(t){return t.selection}}),new Xe("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,r,i){return i.selection.$cursor?t.storedMarks:null}}),new Xe("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class Qe{constructor(t,e){this.schema=t;this.plugins=[];this.pluginsByKey=Object.create(null);this.fields=Ye.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 Xe(t.key,t.spec.state,t))}))}}class Ze{constructor(t){this.config=t}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(t){return this.applyTransaction(t).state}filterTransaction(t,e=-1){for(let r=0;r<this.config.plugins.length;r++)if(r!=e){let e=this.config.plugins[r];if(e.spec.filterTransaction&&!e.spec.filterTransaction.call(e,t,this))return false}return true}applyTransaction(t){if(!this.filterTransaction(t))return{state:this,transactions:[]};let e=[t],r=this.applyInner(t),i=null;for(;;){let n=false;for(let s=0;s<this.config.plugins.length;s++){let l=this.config.plugins[s];if(l.spec.appendTransaction){let o=i?i[s].n:0,f=i?i[s].state:this;let u=o<e.length&&l.spec.appendTransaction.call(l,o?e.slice(o):e,f,r);if(u&&r.filterTransaction(u,s)){u.setMeta("appendedTransaction",t);if(!i){i=[];for(let t=0;t<this.config.plugins.length;t++)i.push(t<s?{state:r,n:e.length}:{state:this,n:0})}e.push(u);r=r.applyInner(u);n=true}if(i)i[s]={state:r,n:e.length}}}if(!n)return{state:r,transactions:e}}}applyInner(t){if(!t.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let e=new Ze(this.config),r=this.config.fields;for(let i=0;i<r.length;i++){let n=r[i];e[n.name]=n.apply(t,this[n.name],this,e)}return e}get tr(){return new Ge(this)}static create(t){let e=new Qe(t.doc?t.doc.type.schema:t.schema,t.plugins);let r=new Ze(e);for(let i=0;i<e.fields.length;i++)r[e.fields[i].name]=e.fields[i].init(t,r);return r}reconfigure(t){let e=new Qe(this.schema,t.plugins);let r=e.fields,i=new Ze(e);for(let e=0;e<r.length;e++){let n=r[e].name;i[n]=this.hasOwnProperty(n)?this[n]:r[e].init(t,i)}return i}toJSON(t){let e={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks)e.storedMarks=this.storedMarks.map((t=>t.toJSON()));if(t&&typeof t=="object")for(let r in t){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let i=t[r],n=i.spec.state;if(n&&n.toJSON)e[r]=n.toJSON.call(i,this[i.key])}return e}static fromJSON(t,e,r){if(!e)throw new RangeError("Invalid input for EditorState.fromJSON");if(!t.schema)throw new RangeError("Required config field 'schema' missing");let i=new Qe(t.schema,t.plugins);let n=new Ze(i);i.fields.forEach((i=>{if(i.name=="doc"){n.doc=q.fromJSON(t.schema,e.doc)}else if(i.name=="selection"){n.selection=Te.fromJSON(n.doc,e.selection)}else if(i.name=="storedMarks"){if(e.storedMarks)n.storedMarks=e.storedMarks.map(t.schema.markFromJSON)}else{if(r)for(let s in r){let l=r[s],o=l.spec.state;if(l.key==i.name&&o&&o.fromJSON&&Object.prototype.hasOwnProperty.call(e,s)){n[i.name]=o.fromJSON.call(l,t,e[s],n);return}}n[i.name]=i.init(t,n)}}));return n}}function tr(t,e,r){for(let i in t){let n=t[i];if(n instanceof Function)n=n.bind(e);else if(i=="handleDOMEvents")n=tr(n,e,{});r[i]=n}return r}class er{constructor(t){this.spec=t;this.props={};if(t.props)tr(t.props,this,this.props);this.key=t.key?t.key.key:ir("plugin")}getState(t){return t[this.key]}}const rr=Object.create(null);function ir(t){if(t in rr)return t+"$"+ ++rr[t];rr[t]=0;return t+"$"}class nr{constructor(t="key"){this.key=ir(t)}get(t){return t.config.pluginsByKey[this.key]}getState(t){return t[this.key]}}const sr=function(t){for(var e=0;;e++){t=t.previousSibling;if(!t)return e}};const lr=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let or=null;const fr=function(t,e,r){let i=or||(or=document.createRange());i.setEnd(t,r==null?t.nodeValue.length:r);i.setStart(t,e||0);return i};const ur=function(t,e,r,i){return r&&(ar(t,e,r,i,-1)||ar(t,e,r,i,1))};const hr=/^(img|br|input|textarea|hr)$/i;function ar(t,e,r,i,n){for(;;){if(t==r&&e==i)return true;if(e==(n<0?0:cr(t))){let r=t.parentNode;if(!r||r.nodeType!=1||pr(t)||hr.test(t.nodeName)||t.contentEditable=="false")return false;e=sr(t)+(n<0?0:1);t=r}else if(t.nodeType==1){t=t.childNodes[e+(n<0?-1:0)];if(t.contentEditable=="false")return false;e=n<0?cr(t):0}else{return false}}}function cr(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function dr(t,e,r){for(let i=e==0,n=e==cr(t);i||n;){if(t==r)return true;let e=sr(t);t=t.parentNode;if(!t)return false;i=i&&e==0;n=n&&e==cr(t)}}function pr(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 mr=function(t){return t.focusNode&&ur(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function wr(t,e){let r=document.createEvent("Event");r.initEvent("keydown",true,true);r.keyCode=t;r.key=r.code=e;return r}function gr(t){let e=t.activeElement;while(e&&e.shadowRoot)e=e.shadowRoot.activeElement;return e}function br(t,e,r){if(t.caretPositionFromPoint){try{let i=t.caretPositionFromPoint(e,r);if(i)return{node:i.offsetNode,offset:i.offset}}catch(t){}}if(t.caretRangeFromPoint){let i=t.caretRangeFromPoint(e,r);if(i)return{node:i.startContainer,offset:i.startOffset}}}const vr=typeof navigator!="undefined"?navigator:null;const kr=typeof document!="undefined"?document:null;const yr=vr&&vr.userAgent||"";const Mr=/Edge\/(\d+)/.exec(yr);const xr=/MSIE \d/.exec(yr);const Sr=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(yr);const Or=!!(xr||Sr||Mr);const Er=xr?document.documentMode:Sr?+Sr[1]:Mr?+Mr[1]:0;const Dr=!Or&&/gecko\/(\d+)/i.test(yr);Dr&&+(/Firefox\/(\d+)/.exec(yr)||[0,0])[1];const Nr=!Or&&/Chrome\/(\d+)/.exec(yr);const Rr=!!Nr;const Cr=Nr?+Nr[1]:0;const Pr=!Or&&!!vr&&/Apple Computer/.test(vr.vendor);const qr=Pr&&(/Mobile\/\w+/.test(yr)||!!vr&&vr.maxTouchPoints>2);const Tr=qr||(vr?/Mac/.test(vr.platform):false);const $r=vr?/Win/.test(vr.platform):false;const Ar=/Android \d/.test(yr);const Ir=!!kr&&"webkitFontSmoothing"in kr.documentElement.style;const zr=Ir?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Jr(t){return{left:0,right:t.documentElement.clientWidth,top:0,bottom:t.documentElement.clientHeight}}function Br(t,e){return typeof t=="number"?t:t[e]}function jr(t){let e=t.getBoundingClientRect();let r=e.width/t.offsetWidth||1;let i=e.height/t.offsetHeight||1;return{left:e.left,right:e.left+t.clientWidth*r,top:e.top,bottom:e.top+t.clientHeight*i}}function Fr(t,e,r){let i=t.someProp("scrollThreshold")||0,n=t.someProp("scrollMargin")||5;let s=t.dom.ownerDocument;for(let l=r||t.dom;;l=lr(l)){if(!l)break;if(l.nodeType!=1)continue;let t=l;let r=t==s.body;let o=r?Jr(s):jr(t);let f=0,u=0;if(e.top<o.top+Br(i,"top"))u=-(o.top-e.top+Br(n,"top"));else if(e.bottom>o.bottom-Br(i,"bottom"))u=e.bottom-e.top>o.bottom-o.top?e.top+Br(n,"top")-o.top:e.bottom-o.bottom+Br(n,"bottom");if(e.left<o.left+Br(i,"left"))f=-(o.left-e.left+Br(n,"left"));else if(e.right>o.right-Br(i,"right"))f=e.right-o.right+Br(n,"right");if(f||u){if(r){s.defaultView.scrollBy(f,u)}else{let r=t.scrollLeft,i=t.scrollTop;if(u)t.scrollTop+=u;if(f)t.scrollLeft+=f;let n=t.scrollLeft-r,s=t.scrollTop-i;e={left:e.left-n,top:e.top-s,right:e.right-n,bottom:e.bottom-s}}}if(r||/^(fixed|sticky)$/.test(getComputedStyle(l).position))break}}function Lr(t){let e=t.dom.getBoundingClientRect(),r=Math.max(0,e.top);let i,n;for(let s=(e.left+e.right)/2,l=r+1;l<Math.min(innerHeight,e.bottom);l+=5){let e=t.root.elementFromPoint(s,l);if(!e||e==t.dom||!t.dom.contains(e))continue;let o=e.getBoundingClientRect();if(o.top>=r-20){i=e;n=o.top;break}}return{refDOM:i,refTop:n,stack:Wr(t.dom)}}function Wr(t){let e=[],r=t.ownerDocument;for(let i=t;i;i=lr(i)){e.push({dom:i,top:i.scrollTop,left:i.scrollLeft});if(t==r)break}return e}function Ur({refDOM:t,refTop:e,stack:r}){let i=t?t.getBoundingClientRect().top:0;Kr(r,i==0?0:i-e)}function Kr(t,e){for(let r=0;r<t.length;r++){let{dom:i,top:n,left:s}=t[r];if(i.scrollTop!=n+e)i.scrollTop=n+e;if(i.scrollLeft!=s)i.scrollLeft=s}}let _r=null;function Hr(t){if(t.setActive)return t.setActive();if(_r)return t.focus(_r);let e=Wr(t);t.focus(_r==null?{get preventScroll(){_r={preventScroll:true};return true}}:undefined);if(!_r){_r=false;Kr(e,0)}}function Gr(t,e){let r,i=2e8,n,s=0;let l=e.top,o=e.top;let f,u;for(let h=t.firstChild,a=0;h;h=h.nextSibling,a++){let t;if(h.nodeType==1)t=h.getClientRects();else if(h.nodeType==3)t=fr(h).getClientRects();else continue;for(let c=0;c<t.length;c++){let d=t[c];if(d.top<=l&&d.bottom>=o){l=Math.max(d.bottom,l);o=Math.min(d.top,o);let t=d.left>e.left?d.left-e.left:d.right<e.left?e.left-d.right:0;if(t<i){r=h;i=t;n=t&&r.nodeType==3?{left:d.right<e.left?d.right:d.left,top:e.top}:e;if(h.nodeType==1&&t)s=a+(e.left>=(d.left+d.right)/2?1:0);continue}}else if(d.top>e.top&&!f&&d.left<=e.left&&d.right>=e.left){f=h;u={left:Math.max(d.left,Math.min(d.right,e.left)),top:d.top}}if(!r&&(e.left>=d.right&&e.top>=d.top||e.left>=d.left&&e.top>=d.bottom))s=a+1}}if(!r&&f){r=f;n=u;i=0}if(r&&r.nodeType==3)return Vr(r,n);if(!r||i&&r.nodeType==1)return{node:t,offset:s};return Gr(r,n)}function Vr(t,e){let r=t.nodeValue.length;let i=document.createRange();for(let n=0;n<r;n++){i.setEnd(t,n+1);i.setStart(t,n);let r=ii(i,1);if(r.top==r.bottom)continue;if(Xr(e,r))return{node:t,offset:n+(e.left>=(r.left+r.right)/2?1:0)}}return{node:t,offset:0}}function Xr(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function Yr(t,e){let r=t.parentNode;if(r&&/^li$/i.test(r.nodeName)&&e.left<t.getBoundingClientRect().left)return r;return t}function Qr(t,e,r){let{node:i,offset:n}=Gr(e,r),s=-1;if(i.nodeType==1&&!i.firstChild){let t=i.getBoundingClientRect();s=t.left!=t.right&&r.left>(t.left+t.right)/2?1:-1}return t.docView.posFromDOM(i,n,s)}function Zr(t,e,r,i){let n=-1;for(let r=e,s=false;;){if(r==t.dom)break;let e=t.docView.nearestDesc(r,true);if(!e)return null;if(e.dom.nodeType==1&&(e.node.isBlock&&e.parent&&!s||!e.contentDOM)){let t=e.dom.getBoundingClientRect();if(e.node.isBlock&&e.parent&&!s){s=true;if(t.left>i.left||t.top>i.top)n=e.posBefore;else if(t.right<i.left||t.bottom<i.top)n=e.posAfter}if(!e.contentDOM&&n<0&&!e.node.isText){let r=e.node.isBlock?i.top<(t.top+t.bottom)/2:i.left<(t.left+t.right)/2;return r?e.posBefore:e.posAfter}}r=e.dom.parentNode}return n>-1?n:t.docView.posFromDOM(e,r,-1)}function ti(t,e,r){let i=t.childNodes.length;if(i&&r.top<r.bottom){for(let n=Math.max(0,Math.min(i-1,Math.floor(i*(e.top-r.top)/(r.bottom-r.top))-2)),s=n;;){let r=t.childNodes[s];if(r.nodeType==1){let t=r.getClientRects();for(let i=0;i<t.length;i++){let n=t[i];if(Xr(e,n))return ti(r,e,n)}}if((s=(s+1)%i)==n)break}}return t}function ei(t,e){let r=t.dom.ownerDocument,i,n=0;let s=br(r,e.left,e.top);if(s)({node:i,offset:n}=s);let l=(t.root.elementFromPoint?t.root:r).elementFromPoint(e.left,e.top);let o;if(!l||!t.dom.contains(l.nodeType!=1?l.parentNode:l)){let r=t.dom.getBoundingClientRect();if(!Xr(e,r))return null;l=ti(t.dom,e,r);if(!l)return null}if(Pr){for(let t=l;i&&t;t=lr(t))if(t.draggable)i=undefined}l=Yr(l,e);if(i){if(Dr&&i.nodeType==1){n=Math.min(n,i.childNodes.length);if(n<i.childNodes.length){let t=i.childNodes[n],r;if(t.nodeName=="IMG"&&(r=t.getBoundingClientRect()).right<=e.left&&r.bottom>e.top)n++}}let r;if(Ir&&n&&i.nodeType==1&&(r=i.childNodes[n-1]).nodeType==1&&r.contentEditable=="false"&&r.getBoundingClientRect().top>=e.top)n--;if(i==t.dom&&n==i.childNodes.length-1&&i.lastChild.nodeType==1&&e.top>i.lastChild.getBoundingClientRect().bottom)o=t.state.doc.content.size;else if(n==0||i.nodeType!=1||i.childNodes[n-1].nodeName!="BR")o=Zr(t,i,n,e)}if(o==null)o=Qr(t,l,e);let f=t.docView.nearestDesc(l,true);return{pos:o,inside:f?f.posAtStart-f.border:-1}}function ri(t){return t.top<t.bottom||t.left<t.right}function ii(t,e){let r=t.getClientRects();if(r.length){let t=r[e<0?0:r.length-1];if(ri(t))return t}return Array.prototype.find.call(r,ri)||t.getBoundingClientRect()}const ni=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function si(t,e,r){let{node:i,offset:n,atom:s}=t.docView.domFromPos(e,r<0?-1:1);let l=Ir||Dr;if(i.nodeType==3){if(l&&(ni.test(i.nodeValue)||(r<0?!n:n==i.nodeValue.length))){let t=ii(fr(i,n,n),r);if(Dr&&n&&/\s/.test(i.nodeValue[n-1])&&n<i.nodeValue.length){let e=ii(fr(i,n-1,n-1),-1);if(e.top==t.top){let r=ii(fr(i,n,n+1),-1);if(r.top!=t.top)return li(r,r.left<e.left)}}return t}else{let t=n,e=n,s=r<0?1:-1;if(r<0&&!n){e++;s=-1}else if(r>=0&&n==i.nodeValue.length){t--;s=1}else if(r<0){t--}else{e++}return li(ii(fr(i,t,e),s),s<0)}}let o=t.state.doc.resolve(e-(s||0));if(!o.parent.inlineContent){if(s==null&&n&&(r<0||n==cr(i))){let t=i.childNodes[n-1];if(t.nodeType==1)return oi(t.getBoundingClientRect(),false)}if(s==null&&n<cr(i)){let t=i.childNodes[n];if(t.nodeType==1)return oi(t.getBoundingClientRect(),true)}return oi(i.getBoundingClientRect(),r>=0)}if(s==null&&n&&(r<0||n==cr(i))){let t=i.childNodes[n-1];let e=t.nodeType==3?fr(t,cr(t)-(l?0:1)):t.nodeType==1&&(t.nodeName!="BR"||!t.nextSibling)?t:null;if(e)return li(ii(e,1),false)}if(s==null&&n<cr(i)){let t=i.childNodes[n];while(t.pmViewDesc&&t.pmViewDesc.ignoreForCoords)t=t.nextSibling;let e=!t?null:t.nodeType==3?fr(t,0,l?0:1):t.nodeType==1?t:null;if(e)return li(ii(e,-1),true)}return li(ii(i.nodeType==3?fr(i):i,-r),r>=0)}function li(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 oi(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 fi(t,e,r){let i=t.state,n=t.root.activeElement;if(i!=e)t.updateState(e);if(n!=t.dom)t.focus();try{return r()}finally{if(i!=e)t.updateState(i);if(n!=t.dom&&n)n.focus()}}function ui(t,e,r){let i=e.selection;let n=r=="up"?i.$from:i.$to;return fi(t,e,(()=>{let{node:e}=t.docView.domFromPos(n.pos,r=="up"?-1:1);for(;;){let r=t.docView.nearestDesc(e,true);if(!r)break;if(r.node.isBlock){e=r.contentDOM||r.dom;break}e=r.dom.parentNode}let i=si(t,n.pos,1);for(let t=e.firstChild;t;t=t.nextSibling){let e;if(t.nodeType==1)e=t.getClientRects();else if(t.nodeType==3)e=fr(t,0,t.nodeValue.length).getClientRects();else continue;for(let t=0;t<e.length;t++){let n=e[t];if(n.bottom>n.top+1&&(r=="up"?i.top-n.top>(n.bottom-i.top)*2:n.bottom-i.bottom>(i.bottom-n.top)*2))return false}}return true}))}const hi=/[\u0590-\u08ac]/;function ai(t,e,r){let{$head:i}=e.selection;if(!i.parent.isTextblock)return false;let n=i.parentOffset,s=!n,l=n==i.parent.content.size;let o=t.domSelection();if(!hi.test(i.parent.textContent)||!o.modify)return r=="left"||r=="backward"?s:l;return fi(t,e,(()=>{let{focusNode:e,focusOffset:n,anchorNode:s,anchorOffset:l}=t.domSelectionRange();let f=o.caretBidiLevel;o.modify("move",r,"character");let u=i.depth?t.docView.domAfterPos(i.before()):t.dom;let{focusNode:h,focusOffset:a}=t.domSelectionRange();let c=h&&!u.contains(h.nodeType==1?h:h.parentNode)||e==h&&n==a;try{o.collapse(s,l);if(e&&(e!=s||n!=l)&&o.extend)o.extend(e,n)}catch(t){}if(f!=null)o.caretBidiLevel=f;return c}))}let ci=null;let di=null;let pi=false;function mi(t,e,r){if(ci==e&&di==r)return pi;ci=e;di=r;return pi=r=="up"||r=="down"?ui(t,e,r):ai(t,e,r)}const wi=0,gi=1,bi=2,vi=3;class ki{constructor(t,e,r,i){this.parent=t;this.children=e;this.dom=r;this.contentDOM=i;this.dirty=wi;r.pmViewDesc=this}matchesWidget(t){return false}matchesMark(t){return false}matchesNode(t,e,r){return false}matchesHack(t){return false}parseRule(){return null}stopEvent(t){return false}get size(){let t=0;for(let e=0;e<this.children.length;e++)t+=this.children[e].size;return t}get border(){return 0}destroy(){this.parent=undefined;if(this.dom.pmViewDesc==this)this.dom.pmViewDesc=undefined;for(let t=0;t<this.children.length;t++)this.children[t].destroy()}posBeforeChild(t){for(let e=0,r=this.posAtStart;;e++){let i=this.children[e];if(i==t)return r;r+=i.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(t,e,r){if(this.contentDOM&&this.contentDOM.contains(t.nodeType==1?t:t.parentNode)){if(r<0){let r,i;if(t==this.contentDOM){r=t.childNodes[e-1]}else{while(t.parentNode!=this.contentDOM)t=t.parentNode;r=t.previousSibling}while(r&&!((i=r.pmViewDesc)&&i.parent==this))r=r.previousSibling;return r?this.posBeforeChild(i)+i.size:this.posAtStart}else{let r,i;if(t==this.contentDOM){r=t.childNodes[e]}else{while(t.parentNode!=this.contentDOM)t=t.parentNode;r=t.nextSibling}while(r&&!((i=r.pmViewDesc)&&i.parent==this))r=r.nextSibling;return r?this.posBeforeChild(i):this.posAtEnd}}let i;if(t==this.dom&&this.contentDOM){i=e>sr(this.contentDOM)}else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM)){i=t.compareDocumentPosition(this.contentDOM)&2}else if(this.dom.firstChild){if(e==0)for(let e=t;;e=e.parentNode){if(e==this.dom){i=false;break}if(e.previousSibling)break}if(i==null&&e==t.childNodes.length)for(let e=t;;e=e.parentNode){if(e==this.dom){i=true;break}if(e.nextSibling)break}}return(i==null?r>0:i)?this.posAtEnd:this.posAtStart}nearestDesc(t,e=false){for(let r=true,i=t;i;i=i.parentNode){let n=this.getDesc(i),s;if(n&&(!e||n.node)){if(r&&(s=n.nodeDOM)&&!(s.nodeType==1?s.contains(t.nodeType==1?t:t.parentNode):s==t))r=false;else return n}}}getDesc(t){let e=t.pmViewDesc;for(let t=e;t;t=t.parent)if(t==this)return e}posFromDOM(t,e,r){for(let i=t;i;i=i.parentNode){let n=this.getDesc(i);if(n)return n.localPosFromDOM(t,e,r)}return-1}descAt(t){for(let e=0,r=0;e<this.children.length;e++){let i=this.children[e],n=r+i.size;if(r==t&&n!=r){while(!i.border&&i.children.length)i=i.children[0];return i}if(t<n)return i.descAt(t-r-i.border);r=n}}domFromPos(t,e){if(!this.contentDOM)return{node:this.dom,offset:0,atom:t+1};let r=0,i=0;for(let e=0;r<this.children.length;r++){let n=this.children[r],s=e+n.size;if(s>t||n instanceof Di){i=t-e;break}e=s}if(i)return this.children[r].domFromPos(i-this.children[r].border,e);for(let t;r&&!(t=this.children[r-1]).size&&t instanceof yi&&t.side>=0;r--){}if(e<=0){let t,i=true;for(;;r--,i=false){t=r?this.children[r-1]:null;if(!t||t.dom.parentNode==this.contentDOM)break}if(t&&e&&i&&!t.border&&!t.domAtom)return t.domFromPos(t.size,e);return{node:this.contentDOM,offset:t?sr(t.dom)+1:0}}else{let t,i=true;for(;;r++,i=false){t=r<this.children.length?this.children[r]:null;if(!t||t.dom.parentNode==this.contentDOM)break}if(t&&i&&!t.border&&!t.domAtom)return t.domFromPos(0,e);return{node:this.contentDOM,offset:t?sr(t.dom):this.contentDOM.childNodes.length}}}parseRange(t,e,r=0){if(this.children.length==0)return{node:this.contentDOM,from:t,to:e,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let i=-1,n=-1;for(let s=r,l=0;;l++){let r=this.children[l],o=s+r.size;if(i==-1&&t<=o){let n=s+r.border;if(t>=n&&e<=o-r.border&&r.node&&r.contentDOM&&this.contentDOM.contains(r.contentDOM))return r.parseRange(t,e,n);t=s;for(let e=l;e>0;e--){let r=this.children[e-1];if(r.size&&r.dom.parentNode==this.contentDOM&&!r.emptyChildAt(1)){i=sr(r.dom)+1;break}t-=r.size}if(i==-1)i=0}if(i>-1&&(o>e||l==this.children.length-1)){e=o;for(let t=l+1;t<this.children.length;t++){let r=this.children[t];if(r.size&&r.dom.parentNode==this.contentDOM&&!r.emptyChildAt(-1)){n=sr(r.dom);break}e+=r.size}if(n==-1)n=this.contentDOM.childNodes.length;break}s=o}return{node:this.contentDOM,from:t,to:e,fromOffset:i,toOffset:n}}emptyChildAt(t){if(this.border||!this.contentDOM||!this.children.length)return false;let e=this.children[t<0?0:this.children.length-1];return e.size==0||e.emptyChildAt(t)}domAfterPos(t){let{node:e,offset:r}=this.domFromPos(t,0);if(e.nodeType!=1||r==e.childNodes.length)throw new RangeError("No node after pos "+t);return e.childNodes[r]}setSelection(t,e,r,i=false){let n=Math.min(t,e),s=Math.max(t,e);for(let l=0,o=0;l<this.children.length;l++){let f=this.children[l],u=o+f.size;if(n>o&&s<u)return f.setSelection(t-o-f.border,e-o-f.border,r,i);o=u}let l=this.domFromPos(t,t?-1:1);let o=e==t?l:this.domFromPos(e,e?-1:1);let f=r.getSelection();let u=false;if((Dr||Pr)&&t==e){let{node:t,offset:e}=l;if(t.nodeType==3){u=!!(e&&t.nodeValue[e-1]=="\n");if(u&&e==t.nodeValue.length){for(let e=t,r;e;e=e.parentNode){if(r=e.nextSibling){if(r.nodeName=="BR")l=o={node:r.parentNode,offset:sr(r)+1};break}let t=e.pmViewDesc;if(t&&t.node&&t.node.isBlock)break}}}else{let r=t.childNodes[e-1];u=r&&(r.nodeName=="BR"||r.contentEditable=="false")}}if(Dr&&f.focusNode&&f.focusNode!=o.node&&f.focusNode.nodeType==1){let t=f.focusNode.childNodes[f.focusOffset];if(t&&t.contentEditable=="false")i=true}if(!(i||u&&Pr)&&ur(l.node,l.offset,f.anchorNode,f.anchorOffset)&&ur(o.node,o.offset,f.focusNode,f.focusOffset))return;let h=false;if((f.extend||t==e)&&!u){f.collapse(l.node,l.offset);try{if(t!=e)f.extend(o.node,o.offset);h=true}catch(t){}}if(!h){if(t>e){let t=l;l=o;o=t}let r=document.createRange();r.setEnd(o.node,o.offset);r.setStart(l.node,l.offset);f.removeAllRanges();f.addRange(r)}}ignoreMutation(t){return!this.contentDOM&&t.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(t,e){for(let r=0,i=0;i<this.children.length;i++){let n=this.children[i],s=r+n.size;if(r==s?t<=s&&e>=r:t<s&&e>r){let i=r+n.border,l=s-n.border;if(t>=i&&e<=l){this.dirty=t==r||e==s?bi:gi;if(t==i&&e==l&&(n.contentLost||n.dom.parentNode!=this.contentDOM))n.dirty=vi;else n.markDirty(t-i,e-i);return}else{n.dirty=n.dom==n.contentDOM&&n.dom.parentNode==this.contentDOM&&!n.children.length?bi:vi}}r=s}this.dirty=bi}markParentsDirty(){let t=1;for(let e=this.parent;e;e=e.parent,t++){let r=t==1?bi:gi;if(e.dirty<r)e.dirty=r}}get domAtom(){return false}get ignoreForCoords(){return false}}class yi extends ki{constructor(t,e,r,i){let n,s=e.type.toDOM;if(typeof s=="function")s=s(r,(()=>{if(!n)return i;if(n.parent)return n.parent.posBeforeChild(n)}));if(!e.type.spec.raw){if(s.nodeType!=1){let t=document.createElement("span");t.appendChild(s);s=t}s.contentEditable="false";s.classList.add("ProseMirror-widget")}super(t,[],s,null);this.widget=e;this.widget=e;n=this}matchesWidget(t){return this.dirty==wi&&t.type.eq(this.widget.type)}parseRule(){return{ignore:true}}stopEvent(t){let e=this.widget.spec.stopEvent;return e?e(t):false}ignoreMutation(t){return t.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom);super.destroy()}get domAtom(){return true}get side(){return this.widget.type.side}}class Mi extends ki{constructor(t,e,r,i){super(t,[],e,null);this.textDOM=r;this.text=i}get size(){return this.text.length}localPosFromDOM(t,e){if(t!=this.textDOM)return this.posAtStart+(e?this.size:0);return this.posAtStart+e}domFromPos(t){return{node:this.textDOM,offset:t}}ignoreMutation(t){return t.type==="characterData"&&t.target.nodeValue==t.oldValue}}class xi extends ki{constructor(t,e,r,i){super(t,[],r,i);this.mark=e}static create(t,e,r,i){let n=i.nodeViews[e.type.name];let s=n&&n(e,i,r);if(!s||!s.dom)s=vt.renderSpec(document,e.type.spec.toDOM(e,r));return new xi(t,e,s.dom,s.contentDOM||s.dom)}parseRule(){if(this.dirty&vi||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!=vi&&this.mark.eq(t)}markDirty(t,e){super.markDirty(t,e);if(this.dirty!=wi){let t=this.parent;while(!t.node)t=t.parent;if(t.dirty<this.dirty)t.dirty=this.dirty;this.dirty=wi}}slice(t,e,r){let i=xi.create(this.parent,this.mark,true,r);let n=this.children,s=this.size;if(e<s)n=Ki(n,e,s,r);if(t>0)n=Ki(n,0,t,r);for(let t=0;t<n.length;t++)n[t].parent=i;i.children=n;return i}}class Si extends ki{constructor(t,e,r,i,n,s,l,o,f){super(t,[],n,s);this.node=e;this.outerDeco=r;this.innerDeco=i;this.nodeDOM=l}static create(t,e,r,i,n,s){let l=n.nodeViews[e.type.name],o;let f=l&&l(e,n,(()=>{if(!o)return s;if(o.parent)return o.parent.posBeforeChild(o)}),r,i);let u=f&&f.dom,h=f&&f.contentDOM;if(e.isText){if(!u)u=document.createTextNode(e.text);else if(u.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else if(!u){({dom:u,contentDOM:h}=vt.renderSpec(document,e.type.spec.toDOM(e)))}if(!h&&!e.isText&&u.nodeName!="BR"){if(!u.hasAttribute("contenteditable"))u.contentEditable="false";if(e.type.spec.draggable)u.draggable=true}let a=u;u=Ai(u,r,e);if(f)return o=new Ni(t,e,r,i,u,h||null,a,f,n,s+1);else if(e.isText)return new Ei(t,e,r,i,u,a,n);else return new Si(t,e,r,i,u,h||null,a,n,s+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let t={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre")t.preserveWhitespace="full";if(!this.contentDOM){t.getContent=()=>this.node.content}else if(!this.contentLost){t.contentElement=this.contentDOM}else{for(let e=this.children.length-1;e>=0;e--){let r=this.children[e];if(this.dom.contains(r.dom.parentNode)){t.contentElement=r.dom.parentNode;break}}if(!t.contentElement)t.getContent=()=>o.empty}return t}matchesNode(t,e,r){return this.dirty==wi&&t.eq(this.node)&&Ii(e,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(t,e){let r=this.node.inlineContent,i=e;let n=t.composing?this.localCompositionInfo(t,e):null;let s=n&&n.pos>-1?n:null;let l=n&&n.pos<0;let o=new Ji(this,s&&s.node,t);Fi(this.node,this.innerDeco,((e,n,s)=>{if(e.spec.marks)o.syncToMarks(e.spec.marks,r,t);else if(e.type.side>=0&&!s)o.syncToMarks(n==this.node.childCount?a.none:this.node.child(n).marks,r,t);o.placeWidget(e,t,i)}),((e,s,f,u)=>{o.syncToMarks(e.marks,r,t);let h;if(o.findNodeMatch(e,s,f,u));else if(l&&t.state.selection.from>i&&t.state.selection.to<i+e.nodeSize&&(h=o.findIndexWithChild(n.node))>-1&&o.updateNodeAt(e,s,f,h,t));else if(o.updateNextNode(e,s,f,t,u,i));else{o.addNode(e,s,f,t,i)}i+=e.nodeSize}));o.syncToMarks([],r,t);if(this.node.isTextblock)o.addTextblockHacks();o.destroyRest();if(o.changed||this.dirty==bi){if(s)this.protectLocalComposition(t,s);Ri(this.contentDOM,this.children,t);if(qr)Li(this.dom)}}localCompositionInfo(t,e){let{from:r,to:i}=t.state.selection;if(!(t.state.selection instanceof ze)||r<e||i>e+this.node.content.size)return null;let n=t.domSelectionRange();let s=Wi(n.focusNode,n.focusOffset);if(!s||!this.dom.contains(s.parentNode))return null;if(this.node.inlineContent){let t=s.nodeValue;let n=Ui(this.node.content,t,r-e,i-e);return n<0?null:{node:s,pos:n,text:t}}else{return{node:s,pos:-1,text:""}}}protectLocalComposition(t,{node:e,pos:r,text:i}){if(this.getDesc(e))return;let n=e;for(;;n=n.parentNode){if(n.parentNode==this.contentDOM)break;while(n.previousSibling)n.parentNode.removeChild(n.previousSibling);while(n.nextSibling)n.parentNode.removeChild(n.nextSibling);if(n.pmViewDesc)n.pmViewDesc=undefined}let s=new Mi(this,n,e,i);t.input.compositionNodes.push(s);this.children=Ki(this.children,r,r+i.length,t,s)}update(t,e,r,i){if(this.dirty==vi||!t.sameMarkup(this.node))return false;this.updateInner(t,e,r,i);return true}updateInner(t,e,r,i){this.updateOuterDeco(e);this.node=t;this.innerDeco=r;if(this.contentDOM)this.updateChildren(i,this.posAtStart);this.dirty=wi}updateOuterDeco(t){if(Ii(t,this.outerDeco))return;let e=this.nodeDOM.nodeType!=1;let r=this.dom;this.dom=Ti(this.dom,this.nodeDOM,qi(this.outerDeco,this.node,e),qi(t,this.node,e));if(this.dom!=r){r.pmViewDesc=undefined;this.dom.pmViewDesc=this}this.outerDeco=t}selectNode(){if(this.nodeDOM.nodeType==1)this.nodeDOM.classList.add("ProseMirror-selectednode");if(this.contentDOM||!this.node.type.spec.draggable)this.dom.draggable=true}deselectNode(){if(this.nodeDOM.nodeType==1)this.nodeDOM.classList.remove("ProseMirror-selectednode");if(this.contentDOM||!this.node.type.spec.draggable)this.dom.removeAttribute("draggable")}get domAtom(){return this.node.isAtom}}function Oi(t,e,r,i,n){Ai(i,e,t);let s=new Si(undefined,t,e,r,i,i,i,n,0);if(s.contentDOM)s.updateChildren(n,0);return s}class Ei extends Si{constructor(t,e,r,i,n,s,l){super(t,e,r,i,n,null,s,l,0)}parseRule(){let t=this.nodeDOM.parentNode;while(t&&t!=this.dom&&!t.pmIsDeco)t=t.parentNode;return{skip:t||true}}update(t,e,r,i){if(this.dirty==vi||this.dirty!=wi&&!this.inParent()||!t.sameMarkup(this.node))return false;this.updateOuterDeco(e);if((this.dirty!=wi||t.text!=this.node.text)&&t.text!=this.nodeDOM.nodeValue){this.nodeDOM.nodeValue=t.text;if(i.trackWrites==this.nodeDOM)i.trackWrites=null}this.node=t;this.dirty=wi;return true}inParent(){let t=this.parent.contentDOM;for(let e=this.nodeDOM;e;e=e.parentNode)if(e==t)return true;return false}domFromPos(t){return{node:this.nodeDOM,offset:t}}localPosFromDOM(t,e,r){if(t==this.nodeDOM)return this.posAtStart+Math.min(e,this.node.text.length);return super.localPosFromDOM(t,e,r)}ignoreMutation(t){return t.type!="characterData"&&t.type!="selection"}slice(t,e,r){let i=this.node.cut(t,e),n=document.createTextNode(i.text);return new Ei(this.parent,i,this.outerDeco,this.innerDeco,n,n,r)}markDirty(t,e){super.markDirty(t,e);if(this.dom!=this.nodeDOM&&(t==0||e==this.nodeDOM.nodeValue.length))this.dirty=vi}get domAtom(){return false}}class Di extends ki{parseRule(){return{ignore:true}}matchesHack(t){return this.dirty==wi&&this.dom.nodeName==t}get domAtom(){return true}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class Ni extends Si{constructor(t,e,r,i,n,s,l,o,f,u){super(t,e,r,i,n,s,l,f,u);this.spec=o}update(t,e,r,i){if(this.dirty==vi)return false;if(this.spec.update){let n=this.spec.update(t,e,r);if(n)this.updateInner(t,e,r,i);return n}else if(!this.contentDOM&&!t.isLeaf){return false}else{return super.update(t,e,r,i)}}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(t,e,r,i){this.spec.setSelection?this.spec.setSelection(t,e,r):super.setSelection(t,e,r,i)}destroy(){if(this.spec.destroy)this.spec.destroy();super.destroy()}stopEvent(t){return this.spec.stopEvent?this.spec.stopEvent(t):false}ignoreMutation(t){return this.spec.ignoreMutation?this.spec.ignoreMutation(t):super.ignoreMutation(t)}}function Ri(t,e,r){let i=t.firstChild,n=false;for(let s=0;s<e.length;s++){let l=e[s],o=l.dom;if(o.parentNode==t){while(o!=i){i=zi(i);n=true}i=i.nextSibling}else{n=true;t.insertBefore(o,i)}if(l instanceof xi){let e=i?i.previousSibling:t.lastChild;Ri(l.contentDOM,l.children,r);i=e?e.nextSibling:t.firstChild}}while(i){i=zi(i);n=true}if(n&&r.trackWrites==t)r.trackWrites=null}const Ci=function(t){if(t)this.nodeName=t};Ci.prototype=Object.create(null);const Pi=[new Ci];function qi(t,e,r){if(t.length==0)return Pi;let i=r?Pi[0]:new Ci,n=[i];for(let s=0;s<t.length;s++){let l=t[s].type.attrs;if(!l)continue;if(l.nodeName)n.push(i=new Ci(l.nodeName));for(let t in l){let s=l[t];if(s==null)continue;if(r&&n.length==1)n.push(i=new Ci(e.isInline?"span":"div"));if(t=="class")i.class=(i.class?i.class+" ":"")+s;else if(t=="style")i.style=(i.style?i.style+";":"")+s;else if(t!="nodeName")i[t]=s}}return n}function Ti(t,e,r,i){if(r==Pi&&i==Pi)return e;let n=e;for(let e=0;e<i.length;e++){let s=i[e],l=r[e];if(e){let e;if(l&&l.nodeName==s.nodeName&&n!=t&&(e=n.parentNode)&&e.nodeName.toLowerCase()==s.nodeName){n=e}else{e=document.createElement(s.nodeName);e.pmIsDeco=true;e.appendChild(n);l=Pi[0];n=e}}$i(n,l||Pi[0],s)}return n}function $i(t,e,r){for(let i in e)if(i!="class"&&i!="style"&&i!="nodeName"&&!(i in r))t.removeAttribute(i);for(let i in r)if(i!="class"&&i!="style"&&i!="nodeName"&&r[i]!=e[i])t.setAttribute(i,r[i]);if(e.class!=r.class){let i=e.class?e.class.split(" ").filter(Boolean):[];let n=r.class?r.class.split(" ").filter(Boolean):[];for(let e=0;e<i.length;e++)if(n.indexOf(i[e])==-1)t.classList.remove(i[e]);for(let e=0;e<n.length;e++)if(i.indexOf(n[e])==-1)t.classList.add(n[e]);if(t.classList.length==0)t.removeAttribute("class")}if(e.style!=r.style){if(e.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,i;while(i=r.exec(e.style))t.style.removeProperty(i[1])}if(r.style)t.style.cssText+=r.style}}function Ai(t,e,r){return Ti(t,t,Pi,qi(e,r,t.nodeType!=1))}function Ii(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 zi(t){let e=t.nextSibling;t.parentNode.removeChild(t);return e}class Ji{constructor(t,e,r){this.lock=e;this.view=r;this.index=0;this.stack=[];this.changed=false;this.top=t;this.preMatch=Bi(t.node.content,t)}destroyBetween(t,e){if(t==e)return;for(let r=t;r<e;r++)this.top.children[r].destroy();this.top.children.splice(t,e-t);this.changed=true}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(t,e,r){let i=0,n=this.stack.length>>1;let s=Math.min(n,t.length);while(i<s&&(i==n-1?this.top:this.stack[i+1<<1]).matchesMark(t[i])&&t[i].type.spec.spanning!==false)i++;while(i<n){this.destroyRest();this.top.dirty=wi;this.index=this.stack.pop();this.top=this.stack.pop();n--}while(n<t.length){this.stack.push(this.top,this.index+1);let i=-1;for(let e=this.index;e<Math.min(this.index+3,this.top.children.length);e++){let r=this.top.children[e];if(r.matchesMark(t[n])&&!this.isLocked(r.dom)){i=e;break}}if(i>-1){if(i>this.index){this.changed=true;this.destroyBetween(this.index,i)}this.top=this.top.children[this.index]}else{let i=xi.create(this.top,t[n],e,r);this.top.children.splice(this.index,0,i);this.top=i;this.changed=true}this.index=0;n++}}findNodeMatch(t,e,r,i){let n=-1,s;if(i>=this.preMatch.index&&(s=this.preMatch.matches[i-this.preMatch.index]).parent==this.top&&s.matchesNode(t,e,r)){n=this.top.children.indexOf(s,this.index)}else{for(let i=this.index,s=Math.min(this.top.children.length,i+5);i<s;i++){let s=this.top.children[i];if(s.matchesNode(t,e,r)&&!this.preMatch.matched.has(s)){n=i;break}}}if(n<0)return false;this.destroyBetween(this.index,n);this.index++;return true}updateNodeAt(t,e,r,i,n){let s=this.top.children[i];if(s.dirty==vi&&s.dom==s.contentDOM)s.dirty=bi;if(!s.update(t,e,r,n))return false;this.destroyBetween(this.index,i);this.index++;return true}findIndexWithChild(t){for(;;){let e=t.parentNode;if(!e)return-1;if(e==this.top.contentDOM){let e=t.pmViewDesc;if(e)for(let t=this.index;t<this.top.children.length;t++){if(this.top.children[t]==e)return t}return-1}t=e}}updateNextNode(t,e,r,i,n,s){for(let l=this.index;l<this.top.children.length;l++){let o=this.top.children[l];if(o instanceof Si){let f=this.preMatch.matched.get(o);if(f!=null&&f!=n)return false;let u=o.dom,h;let a=this.isLocked(u)&&!(t.isText&&o.node&&o.node.isText&&o.nodeDOM.nodeValue==t.text&&o.dirty!=vi&&Ii(e,o.outerDeco));if(!a&&o.update(t,e,r,i)){this.destroyBetween(this.index,l);if(o.dom!=u)this.changed=true;this.index++;return true}else if(!a&&(h=this.recreateWrapper(o,t,e,r,i,s))){this.top.children[this.index]=h;if(h.contentDOM){h.dirty=bi;h.updateChildren(i,s+1);h.dirty=wi}this.changed=true;this.index++;return true}break}}return false}recreateWrapper(t,e,r,i,n,s){if(t.dirty||e.isAtom||!t.children.length||!t.node.content.eq(e.content))return null;let l=Si.create(this.top,e,r,i,n,s);if(l.contentDOM){l.children=t.children;t.children=[];for(let t of l.children)t.parent=l}t.destroy();return l}addNode(t,e,r,i,n){let s=Si.create(this.top,t,e,r,i,n);if(s.contentDOM)s.updateChildren(i,n+1);this.top.children.splice(this.index++,0,s);this.changed=true}placeWidget(t,e,r){let i=this.index<this.top.children.length?this.top.children[this.index]:null;if(i&&i.matchesWidget(t)&&(t==i.widget||!i.widget.type.toDOM.parentNode)){this.index++}else{let i=new yi(this.top,t,e,r);this.top.children.splice(this.index++,0,i);this.changed=true}}addTextblockHacks(){let t=this.top.children[this.index-1],e=this.top;while(t instanceof xi){e=t;t=e.children[e.children.length-1]}if(!t||!(t instanceof Ei)||/\n$/.test(t.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(t.node.text)){if((Pr||Rr)&&t&&t.dom.contentEditable=="false")this.addHackNode("IMG",e);this.addHackNode("BR",this.top)}}addHackNode(t,e){if(e==this.top&&this.index<e.children.length&&e.children[this.index].matchesHack(t)){this.index++}else{let r=document.createElement(t);if(t=="IMG"){r.className="ProseMirror-separator";r.alt=""}if(t=="BR")r.className="ProseMirror-trailingBreak";let i=new Di(this.top,[],r,null);if(e!=this.top)e.children.push(i);else e.children.splice(this.index++,0,i);this.changed=true}}isLocked(t){return this.lock&&(t==this.lock||t.nodeType==1&&t.contains(this.lock.parentNode))}}function Bi(t,e){let r=e,i=r.children.length;let n=t.childCount,s=new Map,l=[];t:while(n>0){let o;for(;;){if(i){let t=r.children[i-1];if(t instanceof xi){r=t;i=t.children.length}else{o=t;i--;break}}else if(r==e){break t}else{i=r.parent.children.indexOf(r);r=r.parent}}let f=o.node;if(!f)continue;if(f!=t.child(n-1))break;--n;s.set(o,n);l.push(o)}return{index:n,matched:s,matches:l.reverse()}}function ji(t,e){return t.type.side-e.type.side}function Fi(t,e,r,i){let n=e.locals(t),s=0;if(n.length==0){for(let r=0;r<t.childCount;r++){let l=t.child(r);i(l,n,e.forChild(s,l),r);s+=l.nodeSize}return}let l=0,o=[],f=null;for(let u=0;;){let h,a;while(l<n.length&&n[l].to==s){let t=n[l++];if(t.widget){if(!h)h=t;else(a||(a=[h])).push(t)}}if(h){if(a){a.sort(ji);for(let t=0;t<a.length;t++)r(a[t],u,!!f)}else{r(h,u,!!f)}}let c,d;if(f){d=-1;c=f;f=null}else if(u<t.childCount){d=u;c=t.child(u++)}else{break}for(let t=0;t<o.length;t++)if(o[t].to<=s)o.splice(t--,1);while(l<n.length&&n[l].from<=s&&n[l].to>s)o.push(n[l++]);let p=s+c.nodeSize;if(c.isText){let t=p;if(l<n.length&&n[l].from<t)t=n[l].from;for(let e=0;e<o.length;e++)if(o[e].to<t)t=o[e].to;if(t<p){f=c.cut(t-s);c=c.cut(0,t-s);p=t;d=-1}}else{while(l<n.length&&n[l].to<p)l++}let m=c.isInline&&!c.isLeaf?o.filter((t=>!t.inline)):o.slice();i(c,m,e.forChild(s,c),d);s=p}}function Li(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 Wi(t,e){for(;;){if(t.nodeType==3)return t;if(t.nodeType==1&&e>0){if(t.childNodes.length>e&&t.childNodes[e].nodeType==3)return t.childNodes[e];t=t.childNodes[e-1];e=cr(t)}else if(t.nodeType==1&&e<t.childNodes.length){t=t.childNodes[e];e=0}else{return null}}}function Ui(t,e,r,i){for(let n=0,s=0;n<t.childCount&&s<=i;){let l=t.child(n++),o=s;s+=l.nodeSize;if(!l.isText)continue;let f=l.text;while(n<t.childCount){let e=t.child(n++);s+=e.nodeSize;if(!e.isText)break;f+=e.text}if(s>=r){if(s>=i&&f.slice(i-e.length-o,i-o)==e)return i-e.length;let t=o<i?f.lastIndexOf(e,i-o-1):-1;if(t>=0&&t+e.length+o>=r)return o+t;if(r==i&&f.length>=i+e.length-o&&f.slice(i-o,i-o+e.length)==e)return i}}return-1}function Ki(t,e,r,i,n){let s=[];for(let l=0,o=0;l<t.length;l++){let f=t[l],u=o,h=o+=f.size;if(u>=r||h<=e){s.push(f)}else{if(u<e)s.push(f.slice(0,e-u,i));if(n){s.push(n);n=undefined}if(h>r)s.push(f.slice(r-u,f.size,i))}}return s}function _i(t,e=null){let r=t.domSelectionRange(),i=t.state.doc;if(!r.focusNode)return null;let n=t.docView.nearestDesc(r.focusNode),s=n&&n.size==0;let l=t.docView.posFromDOM(r.focusNode,r.focusOffset,1);if(l<0)return null;let o=i.resolve(l),f,u;if(mr(r)){f=o;while(n&&!n.node)n=n.parent;let t=n.node;if(n&&t.isAtom&&Be.isSelectable(t)&&n.parent&&!(t.isInline&&dr(r.focusNode,r.focusOffset,n.dom))){let t=n.posBefore;u=new Be(l==t?o:i.resolve(t))}}else{let e=t.docView.posFromDOM(r.anchorNode,r.anchorOffset,1);if(e<0)return null;f=i.resolve(e)}if(!u){let r=e=="pointer"||t.state.selection.head<o.pos&&!s?1:-1;u=nn(t,f,o,r)}return u}function Hi(t){return t.editable?t.hasFocus():ln(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function Gi(t,e=false){let r=t.state.selection;en(t,r);if(!Hi(t))return;if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&Rr){let e=t.domSelectionRange(),r=t.domObserver.currentSelection;if(e.anchorNode&&r.anchorNode&&ur(e.anchorNode,e.anchorOffset,r.anchorNode,r.anchorOffset)){t.input.mouseDown.delayedSelectionSync=true;t.domObserver.setCurSelection();return}}t.domObserver.disconnectSelection();if(t.cursorWrapper){tn(t)}else{let{anchor:i,head:n}=r,s,l;if(Vi&&!(r instanceof ze)){if(!r.$from.parent.inlineContent)s=Xi(t,r.from);if(!r.empty&&!r.$from.parent.inlineContent)l=Xi(t,r.to)}t.docView.setSelection(i,n,t.root,e);if(Vi){if(s)Qi(s);if(l)Qi(l)}if(r.visible){t.dom.classList.remove("ProseMirror-hideselection")}else{t.dom.classList.add("ProseMirror-hideselection");if("onselectionchange"in document)Zi(t)}}t.domObserver.setCurSelection();t.domObserver.connectSelection()}const Vi=Pr||Rr&&Cr<63;function Xi(t,e){let{node:r,offset:i}=t.docView.domFromPos(e,0);let n=i<r.childNodes.length?r.childNodes[i]:null;let s=i?r.childNodes[i-1]:null;if(Pr&&n&&n.contentEditable=="false")return Yi(n);if((!n||n.contentEditable=="false")&&(!s||s.contentEditable=="false")){if(n)return Yi(n);else if(s)return Yi(s)}}function Yi(t){t.contentEditable="true";if(Pr&&t.draggable){t.draggable=false;t.wasDraggable=true}return t}function Qi(t){t.contentEditable="false";if(t.wasDraggable){t.draggable=true;t.wasDraggable=null}}function Zi(t){let e=t.dom.ownerDocument;e.removeEventListener("selectionchange",t.input.hideSelectionGuard);let r=t.domSelectionRange();let i=r.anchorNode,n=r.anchorOffset;e.addEventListener("selectionchange",t.input.hideSelectionGuard=()=>{if(r.anchorNode!=i||r.anchorOffset!=n){e.removeEventListener("selectionchange",t.input.hideSelectionGuard);setTimeout((()=>{if(!Hi(t)||t.state.selection.visible)t.dom.classList.remove("ProseMirror-hideselection")}),20)}})}function tn(t){let e=t.domSelection(),r=document.createRange();let i=t.cursorWrapper.dom,n=i.nodeName=="IMG";if(n)r.setEnd(i.parentNode,sr(i)+1);else r.setEnd(i,0);r.collapse(false);e.removeAllRanges();e.addRange(r);if(!n&&!t.state.selection.visible&&Or&&Er<=11){i.disabled=true;i.disabled=false}}function en(t,e){if(e instanceof Be){let r=t.docView.descAt(e.from);if(r!=t.lastSelectedViewDesc){rn(t);if(r)r.selectNode();t.lastSelectedViewDesc=r}}else{rn(t)}}function rn(t){if(t.lastSelectedViewDesc){if(t.lastSelectedViewDesc.parent)t.lastSelectedViewDesc.deselectNode();t.lastSelectedViewDesc=undefined}}function nn(t,e,r,i){return t.someProp("createSelectionBetween",(i=>i(t,e,r)))||ze.between(e,r,i)}function sn(t){if(t.editable&&!t.hasFocus())return false;return ln(t)}function ln(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 on(t){let e=t.docView.domFromPos(t.state.selection.anchor,0);let r=t.domSelectionRange();return ur(e.node,e.offset,r.anchorNode,r.anchorOffset)}function fn(t,e){let{$anchor:r,$head:i}=t.selection;let n=e>0?r.max(i):r.min(i);let s=!n.parent.inlineContent?n:n.depth?t.doc.resolve(e>0?n.after():n.before()):null;return s&&Te.findFrom(s,e)}function un(t,e){t.dispatch(t.state.tr.setSelection(e).scrollIntoView());return true}function hn(t,e,r){let i=t.state.selection;if(i instanceof ze){if(r.indexOf("s")>-1){let{$head:r}=i,n=r.textOffset?null:e<0?r.nodeBefore:r.nodeAfter;if(!n||n.isText||!n.isLeaf)return false;let s=t.state.doc.resolve(r.pos+n.nodeSize*(e<0?-1:1));return un(t,new ze(i.$anchor,s))}else if(!i.empty){return false}else if(t.endOfTextblock(e>0?"forward":"backward")){let r=fn(t.state,e);if(r&&r instanceof Be)return un(t,r);return false}else if(!(Tr&&r.indexOf("m")>-1)){let r=i.$head,n=r.textOffset?null:e<0?r.nodeBefore:r.nodeAfter,s;if(!n||n.isText)return false;let l=e<0?r.pos-n.nodeSize:r.pos;if(!(n.isAtom||(s=t.docView.descAt(l))&&!s.contentDOM))return false;if(Be.isSelectable(n)){return un(t,new Be(e<0?t.state.doc.resolve(r.pos-n.nodeSize):r))}else if(Ir){return un(t,new ze(t.state.doc.resolve(e<0?l:l+n.nodeSize)))}else{return false}}}else if(i instanceof Be&&i.node.isInline){return un(t,new ze(e>0?i.$to:i.$from))}else{let r=fn(t.state,e);if(r)return un(t,r);return false}}function an(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function cn(t,e){let r=t.pmViewDesc;return r&&r.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function dn(t,e){return e<0?pn(t):mn(t)}function pn(t){let e=t.domSelectionRange();let r=e.focusNode,i=e.focusOffset;if(!r)return;let n,s,l=false;if(Dr&&r.nodeType==1&&i<an(r)&&cn(r.childNodes[i],-1))l=true;for(;;){if(i>0){if(r.nodeType!=1){break}else{let t=r.childNodes[i-1];if(cn(t,-1)){n=r;s=--i}else if(t.nodeType==3){r=t;i=r.nodeValue.length}else break}}else if(wn(r)){break}else{let e=r.previousSibling;while(e&&cn(e,-1)){n=r.parentNode;s=sr(e);e=e.previousSibling}if(!e){r=r.parentNode;if(r==t.dom)break;i=0}else{r=e;i=an(r)}}}if(l)vn(t,r,i);else if(n)vn(t,n,s)}function mn(t){let e=t.domSelectionRange();let r=e.focusNode,i=e.focusOffset;if(!r)return;let n=an(r);let s,l;for(;;){if(i<n){if(r.nodeType!=1)break;let t=r.childNodes[i];if(cn(t,1)){s=r;l=++i}else break}else if(wn(r)){break}else{let e=r.nextSibling;while(e&&cn(e,1)){s=e.parentNode;l=sr(e)+1;e=e.nextSibling}if(!e){r=r.parentNode;if(r==t.dom)break;i=n=0}else{r=e;i=0;n=an(r)}}}if(s)vn(t,s,l)}function wn(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function gn(t,e){while(t&&e==t.childNodes.length&&!pr(t)){e=sr(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 bn(t,e){while(t&&!e&&!pr(t)){e=sr(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 vn(t,e,r){if(e.nodeType!=3){let t,i;if(i=gn(e,r)){e=i;r=0}else if(t=bn(e,r)){e=t;r=t.nodeValue.length}}let i=t.domSelection();if(mr(i)){let t=document.createRange();t.setEnd(e,r);t.setStart(e,r);i.removeAllRanges();i.addRange(t)}else if(i.extend){i.extend(e,r)}t.domObserver.setCurSelection();let{state:n}=t;setTimeout((()=>{if(t.state==n)Gi(t)}),50)}function kn(t,e){let r=t.state.doc.resolve(e);if(!(Rr||$r)&&r.parent.inlineContent){let i=t.coordsAtPos(e);if(e>r.start()){let r=t.coordsAtPos(e-1);let n=(r.top+r.bottom)/2;if(n>i.top&&n<i.bottom&&Math.abs(r.left-i.left)>1)return r.left<i.left?"ltr":"rtl"}if(e<r.end()){let r=t.coordsAtPos(e+1);let n=(r.top+r.bottom)/2;if(n>i.top&&n<i.bottom&&Math.abs(r.left-i.left)>1)return r.left>i.left?"ltr":"rtl"}}let i=getComputedStyle(t.dom).direction;return i=="rtl"?"rtl":"ltr"}function yn(t,e,r){let i=t.state.selection;if(i instanceof ze&&!i.empty||r.indexOf("s")>-1)return false;if(Tr&&r.indexOf("m")>-1)return false;let{$from:n,$to:s}=i;if(!n.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let r=fn(t.state,e);if(r&&r instanceof Be)return un(t,r)}if(!n.parent.inlineContent){let r=e<0?n:s;let l=i instanceof Fe?Te.near(r,e):Te.findFrom(r,e);return l?un(t,l):false}return false}function Mn(t,e){if(!(t.state.selection instanceof ze))return true;let{$head:r,$anchor:i,empty:n}=t.state.selection;if(!r.sameParent(i))return true;if(!n)return false;if(t.endOfTextblock(e>0?"forward":"backward"))return true;let s=!r.textOffset&&(e<0?r.nodeBefore:r.nodeAfter);if(s&&!s.isText){let i=t.state.tr;if(e<0)i.delete(r.pos-s.nodeSize,r.pos);else i.delete(r.pos,r.pos+s.nodeSize);t.dispatch(i);return true}return false}function xn(t,e,r){t.domObserver.stop();e.contentEditable=r;t.domObserver.start()}function Sn(t){if(!Pr||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;xn(t,r,"true");setTimeout((()=>xn(t,r,"false")),20)}return false}function On(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 En(t,e){let r=e.keyCode,i=On(e);if(r==8||Tr&&r==72&&i=="c"){return Mn(t,-1)||dn(t,-1)}else if(r==46&&!e.shiftKey||Tr&&r==68&&i=="c"){return Mn(t,1)||dn(t,1)}else if(r==13||r==27){return true}else if(r==37||Tr&&r==66&&i=="c"){let e=r==37?kn(t,t.state.selection.from)=="ltr"?-1:1:-1;return hn(t,e,i)||dn(t,e)}else if(r==39||Tr&&r==70&&i=="c"){let e=r==39?kn(t,t.state.selection.from)=="ltr"?1:-1:1;return hn(t,e,i)||dn(t,e)}else if(r==38||Tr&&r==80&&i=="c"){return yn(t,-1,i)||dn(t,-1)}else if(r==40||Tr&&r==78&&i=="c"){return Sn(t)||yn(t,1,i)||dn(t,1)}else if(i==(Tr?"m":"c")&&(r==66||r==73||r==89||r==90)){return true}return false}function Dn(t,e){t.someProp("transformCopied",(r=>{e=r(e,t)}));let r=[],{content:i,openStart:n,openEnd:s}=e;while(n>1&&s>1&&i.childCount==1&&i.firstChild.childCount==1){n--;s--;let t=i.firstChild;r.push(t.type.name,t.attrs!=t.type.defaultAttrs?t.attrs:null);i=t.content}let l=t.someProp("clipboardSerializer")||vt.fromSchema(t.state.schema);let o=Jn(),f=o.createElement("div");f.appendChild(l.serializeFragment(i,{document:o}));let u=f.firstChild,h,a=0;while(u&&u.nodeType==1&&(h=In[u.nodeName.toLowerCase()])){for(let t=h.length-1;t>=0;t--){let e=o.createElement(h[t]);while(f.firstChild)e.appendChild(f.firstChild);f.appendChild(e);a++}u=f.firstChild}if(u&&u.nodeType==1)u.setAttribute("data-pm-slice",`${n} ${s}${a?` -${a}`:""} ${JSON.stringify(r)}`);let c=t.someProp("clipboardTextSerializer",(r=>r(e,t)))||e.content.textBetween(0,e.content.size,"\n\n");return{dom:f,text:c}}function Nn(t,e,r,i,n){let s=n.parent.type.spec.code;let l,f;if(!r&&!e)return null;let u=e&&(i||s||!r);if(u){t.someProp("transformPastedText",(r=>{e=r(e,s||i,t)}));if(s)return e?new d(o.from(t.state.schema.text(e.replace(/\r\n?/g,"\n"))),0,0):d.empty;let r=t.someProp("clipboardTextParser",(r=>r(e,n,i,t)));if(r){f=r}else{let r=n.marks();let{schema:i}=t.state,s=vt.fromSchema(i);l=document.createElement("div");e.split(/(?:\r\n?|\n)+/).forEach((t=>{let e=l.appendChild(document.createElement("p"));if(t)e.appendChild(s.serializeNode(i.text(t,r)))}))}}else{t.someProp("transformPastedHTML",(e=>{r=e(r,t)}));l=Bn(r);if(Ir)jn(l)}let h=l&&l.querySelector("[data-pm-slice]");let a=h&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(h.getAttribute("data-pm-slice")||"");if(a&&a[3])for(let t=+a[3];t>0;t--){let t=l.firstChild;while(t&&t.nodeType!=1)t=t.nextSibling;if(!t)break;l=t}if(!f){let e=t.someProp("clipboardParser")||t.someProp("domParser")||it.fromSchema(t.state.schema);f=e.parseSlice(l,{preserveWhitespace:!!(u||a),context:n,ruleFromNode(t){if(t.nodeName=="BR"&&!t.nextSibling&&t.parentNode&&!Rn.test(t.parentNode.nodeName))return{ignore:true};return null}})}if(a){f=Fn(An(f,+a[1],+a[2]),a[4])}else{f=d.maxOpen(Cn(f.content,n),true);if(f.openStart||f.openEnd){let t=0,e=0;for(let e=f.content.firstChild;t<f.openStart&&!e.type.spec.isolating;t++,e=e.firstChild){}for(let t=f.content.lastChild;e<f.openEnd&&!t.type.spec.isolating;e++,t=t.lastChild){}f=An(f,t,e)}}t.someProp("transformPasted",(e=>{f=e(f,t)}));return f}const Rn=/^(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 Cn(t,e){if(t.childCount<2)return t;for(let r=e.depth;r>=0;r--){let i=e.node(r);let n=i.contentMatchAt(e.index(r));let s,l=[];t.forEach((t=>{if(!l)return;let e=n.findWrapping(t.type),r;if(!e)return l=null;if(r=l.length&&s.length&&qn(e,s,t,l[l.length-1],0)){l[l.length-1]=r}else{if(l.length)l[l.length-1]=Tn(l[l.length-1],s.length);let r=Pn(t,e);l.push(r);n=n.matchType(r.type);s=e}}));if(l)return o.from(l)}return t}function Pn(t,e,r=0){for(let i=e.length-1;i>=r;i--)t=e[i].create(null,o.from(t));return t}function qn(t,e,r,i,n){if(n<t.length&&n<e.length&&t[n]==e[n]){let s=qn(t,e,r,i.lastChild,n+1);if(s)return i.copy(i.content.replaceChild(i.childCount-1,s));let l=i.contentMatchAt(i.childCount);if(l.matchType(n==t.length-1?r.type:t[n+1]))return i.copy(i.content.append(o.from(Pn(r,t,n+1))))}}function Tn(t,e){if(e==0)return t;let r=t.content.replaceChild(t.childCount-1,Tn(t.lastChild,e-1));let i=t.contentMatchAt(t.childCount).fillBefore(o.empty,true);return t.copy(r.append(i))}function $n(t,e,r,i,n,s){let l=e<0?t.firstChild:t.lastChild,f=l.content;if(t.childCount>1)s=0;if(n<i-1)f=$n(f,e,r,i,n+1,s);if(n>=r)f=e<0?l.contentMatchAt(0).fillBefore(f,s<=n).append(f):f.append(l.contentMatchAt(l.childCount).fillBefore(o.empty,true));return t.replaceChild(e<0?0:t.childCount-1,l.copy(f))}function An(t,e,r){if(e<t.openStart)t=new d($n(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd);if(r<t.openEnd)t=new d($n(t.content,1,r,t.openEnd,0,0),t.openStart,r);return t}const In={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 zn=null;function Jn(){return zn||(zn=document.implementation.createHTMLDocument("title"))}function Bn(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);if(e)t=t.slice(e[0].length);let r=Jn().createElement("div");let i=/<([a-z][^>\s]+)/i.exec(t),n;if(n=i&&In[i[1].toLowerCase()])t=n.map((t=>"<"+t+">")).join("")+t+n.map((t=>"</"+t+">")).reverse().join("");r.innerHTML=t;if(n)for(let t=0;t<n.length;t++)r=r.querySelector(n[t])||r;return r}function jn(t){let e=t.querySelectorAll(Rr?"span:not([class]):not([style])":"span.Apple-converted-space");for(let r=0;r<e.length;r++){let i=e[r];if(i.childNodes.length==1&&i.textContent==" "&&i.parentNode)i.parentNode.replaceChild(t.ownerDocument.createTextNode(" "),i)}}function Fn(t,e){if(!t.size)return t;let r=t.content.firstChild.type.schema,i;try{i=JSON.parse(e)}catch(e){return t}let{content:n,openStart:s,openEnd:l}=t;for(let t=i.length-2;t>=0;t-=2){let e=r.nodes[i[t]];if(!e||e.hasRequiredAttrs())break;n=o.from(e.create(i[t+1],n));s++;l++}return new d(n,s,l)}const Ln={};const Wn={};const Un={touchstart:true,touchmove:true};class Kn{constructor(){this.shiftKey=false;this.mouseDown=null;this.lastKeyCode=null;this.lastKeyCodeTime=0;this.lastClick={time:0,x:0,y:0,type:""};this.lastSelectionOrigin=null;this.lastSelectionTime=0;this.lastIOSEnter=0;this.lastIOSEnterFallbackTimeout=-1;this.lastFocus=0;this.lastTouch=0;this.lastAndroidDelete=0;this.composing=false;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 _n(t){for(let e in Ln){let r=Ln[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=e=>{if(Yn(t,e)&&!Xn(t,e)&&(t.editable||!(e.type in Wn)))r(t,e)},Un[e]?{passive:true}:undefined)}if(Pr)t.dom.addEventListener("input",(()=>null));Vn(t)}function Hn(t,e){t.input.lastSelectionOrigin=e;t.input.lastSelectionTime=Date.now()}function Gn(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 Vn(t){t.someProp("handleDOMEvents",(e=>{for(let r in e)if(!t.input.eventHandlers[r])t.dom.addEventListener(r,t.input.eventHandlers[r]=e=>Xn(t,e))}))}function Xn(t,e){return t.someProp("handleDOMEvents",(r=>{let i=r[e.type];return i?i(t,e)||e.defaultPrevented:false}))}function Yn(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 Qn(t,e){if(!Xn(t,e)&&Ln[e.type]&&(t.editable||!(e.type in Wn)))Ln[e.type](t,e)}Wn.keydown=(t,e)=>{let r=e;t.input.shiftKey=r.keyCode==16||r.shiftKey;if(ds(t,r))return;t.input.lastKeyCode=r.keyCode;t.input.lastKeyCodeTime=Date.now();if(Ar&&Rr&&r.keyCode==13)return;if(r.keyCode!=229)t.domObserver.forceFlush();if(qr&&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,wr(13,"Enter"))));t.input.lastIOSEnter=0}}),200)}else if(t.someProp("handleKeyDown",(e=>e(t,r)))||En(t,r)){r.preventDefault()}else{Hn(t,"key")}};Wn.keyup=(t,e)=>{if(e.keyCode==16)t.input.shiftKey=false};Wn.keypress=(t,e)=>{let r=e;if(ds(t,r)||!r.charCode||r.ctrlKey&&!r.altKey||Tr&&r.metaKey)return;if(t.someProp("handleKeyPress",(e=>e(t,r)))){r.preventDefault();return}let i=t.state.selection;if(!(i instanceof ze)||!i.$from.sameParent(i.$to)){let e=String.fromCharCode(r.charCode);if(!/[\r\n]/.test(e)&&!t.someProp("handleTextInput",(r=>r(t,i.$from.pos,i.$to.pos,e))))t.dispatch(t.state.tr.insertText(e).scrollIntoView());r.preventDefault()}};function Zn(t){return{left:t.clientX,top:t.clientY}}function ts(t,e){let r=e.x-t.clientX,i=e.y-t.clientY;return r*r+i*i<100}function es(t,e,r,i,n){if(i==-1)return false;let s=t.state.doc.resolve(i);for(let i=s.depth+1;i>0;i--){if(t.someProp(e,(e=>i>s.depth?e(t,r,s.nodeAfter,s.before(i),n,true):e(t,r,s.node(i),s.before(i),n,false))))return true}return false}function rs(t,e,r){if(!t.focused)t.focus();let i=t.state.tr.setSelection(e);if(r=="pointer")i.setMeta("pointer",true);t.dispatch(i)}function is(t,e){if(e==-1)return false;let r=t.state.doc.resolve(e),i=r.nodeAfter;if(i&&i.isAtom&&Be.isSelectable(i)){rs(t,new Be(r),"pointer");return true}return false}function ns(t,e){if(e==-1)return false;let r=t.state.selection,i,n;if(r instanceof Be)i=r.node;let s=t.state.doc.resolve(e);for(let t=s.depth+1;t>0;t--){let e=t>s.depth?s.nodeAfter:s.node(t);if(Be.isSelectable(e)){if(i&&r.$from.depth>0&&t>=r.$from.depth&&s.before(r.$from.depth+1)==r.$from.pos)n=s.before(r.$from.depth);else n=s.before(t);break}}if(n!=null){rs(t,Be.create(t.state.doc,n),"pointer");return true}else{return false}}function ss(t,e,r,i,n){return es(t,"handleClickOn",e,r,i)||t.someProp("handleClick",(r=>r(t,e,i)))||(n?ns(t,r):is(t,r))}function ls(t,e,r,i){return es(t,"handleDoubleClickOn",e,r,i)||t.someProp("handleDoubleClick",(r=>r(t,e,i)))}function fs(t,e,r,i){return es(t,"handleTripleClickOn",e,r,i)||t.someProp("handleTripleClick",(r=>r(t,e,i)))||us(t,r,i)}function us(t,e,r){if(r.button!=0)return false;let i=t.state.doc;if(e==-1){if(i.inlineContent){rs(t,ze.create(i,0,i.content.size),"pointer");return true}return false}let n=i.resolve(e);for(let e=n.depth+1;e>0;e--){let r=e>n.depth?n.nodeAfter:n.node(e);let s=n.before(e);if(r.inlineContent)rs(t,ze.create(i,s+1,s+1+r.content.size),"pointer");else if(Be.isSelectable(r))rs(t,Be.create(i,s),"pointer");else continue;return true}}function hs(t){return bs(t)}const as=Tr?"metaKey":"ctrlKey";Ln.mousedown=(t,e)=>{let r=e;t.input.shiftKey=r.shiftKey;let i=hs(t);let n=Date.now(),s="singleClick";if(n-t.input.lastClick.time<500&&ts(r,t.input.lastClick)&&!r[as]){if(t.input.lastClick.type=="singleClick")s="doubleClick";else if(t.input.lastClick.type=="doubleClick")s="tripleClick"}t.input.lastClick={time:n,x:r.clientX,y:r.clientY,type:s};let l=t.posAtCoords(Zn(r));if(!l)return;if(s=="singleClick"){if(t.input.mouseDown)t.input.mouseDown.done();t.input.mouseDown=new cs(t,l,r,!!i)}else if((s=="doubleClick"?ls:fs)(t,l.pos,l.inside,r)){r.preventDefault()}else{Hn(t,"pointer")}};class cs{constructor(t,e,r,i){this.view=t;this.pos=e;this.event=r;this.flushed=i;this.delayedSelectionSync=false;this.mightDrag=null;this.startDoc=t.state.doc;this.selectNode=!!r[as];this.allowDefault=r.shiftKey;let n,s;if(e.inside>-1){n=t.state.doc.nodeAt(e.inside);s=e.inside}else{let r=t.state.doc.resolve(e.pos);n=r.parent;s=r.depth?r.before():0}const l=i?null:r.target;const o=l?t.docView.nearestDesc(l,true):null;this.target=o?o.dom:null;let{selection:f}=t.state;if(r.button==0&&n.type.spec.draggable&&n.type.spec.selectable!==false||f instanceof Be&&f.from<=s&&f.to>s)this.mightDrag={node:n,pos:s,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Dr&&!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));Hn(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((()=>Gi(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(Zn(t));this.updateAllowDefault(t);if(this.allowDefault||!e){Hn(this.view,"pointer")}else if(ss(this.view,e.pos,e.inside,t,this.selectNode)){t.preventDefault()}else if(t.button==0&&(this.flushed||Pr&&this.mightDrag&&!this.mightDrag.node.isAtom||Rr&&!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)){rs(this.view,Te.near(this.view.state.doc.resolve(e.pos)),"pointer");t.preventDefault()}else{Hn(this.view,"pointer")}}move(t){this.updateAllowDefault(t);Hn(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}}Ln.touchstart=t=>{t.input.lastTouch=Date.now();hs(t);Hn(t,"pointer")};Ln.touchmove=t=>{t.input.lastTouch=Date.now();Hn(t,"pointer")};Ln.contextmenu=t=>hs(t);function ds(t,e){if(t.composing)return true;if(Pr&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500){t.input.compositionEndedAt=-2e8;return true}return false}const ps=Ar?5e3:-1;Wn.compositionstart=Wn.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,r=e.selection.$from;if(e.selection.empty&&(e.storedMarks||!r.textOffset&&r.parentOffset&&r.nodeBefore.marks.some((t=>t.type.spec.inclusive===false)))){t.markCursor=t.state.storedMarks||r.marks();bs(t,true);t.markCursor=null}else{bs(t);if(Dr&&e.selection.empty&&r.parentOffset&&!r.textOffset&&r.nodeBefore.marks.length){let e=t.domSelectionRange();for(let r=e.focusNode,i=e.focusOffset;r&&r.nodeType==1&&i!=0;){let e=i<0?r.lastChild:r.childNodes[i-1];if(!e)break;if(e.nodeType==3){t.domSelection().collapse(e,e.nodeValue.length);break}else{r=e;i=-1}}}}t.input.composing=true}ms(t,ps)};Wn.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;if(t.input.compositionPendingChanges)Promise.resolve().then((()=>t.domObserver.flush()));t.input.compositionID++;ms(t,20)}};function ms(t,e){clearTimeout(t.input.composingTimeout);if(e>-1)t.input.composingTimeout=setTimeout((()=>bs(t)),e)}function ws(t){if(t.composing){t.input.composing=false;t.input.compositionEndedAt=gs()}while(t.input.compositionNodes.length>0)t.input.compositionNodes.pop().markParentsDirty()}function gs(){let t=document.createEvent("Event");t.initEvent("event",true,true);return t.timeStamp}function bs(t,e=false){if(Ar&&t.domObserver.flushingSoon>=0)return;t.domObserver.forceFlush();ws(t);if(e||t.docView&&t.docView.dirty){let e=_i(t);if(e&&!e.eq(t.state.selection))t.dispatch(t.state.tr.setSelection(e));else t.updateState(t.state);return true}return false}function vs(t,e){if(!t.dom.parentNode)return;let r=t.dom.parentNode.appendChild(document.createElement("div"));r.appendChild(e);r.style.cssText="position: fixed; left: -10000px; top: 10px";let i=getSelection(),n=document.createRange();n.selectNodeContents(e);t.dom.blur();i.removeAllRanges();i.addRange(n);setTimeout((()=>{if(r.parentNode)r.parentNode.removeChild(r);t.focus()}),50)}const ks=Or&&Er<15||qr&&zr<604;Ln.copy=Wn.cut=(t,e)=>{let r=e;let i=t.state.selection,n=r.type=="cut";if(i.empty)return;let s=ks?null:r.clipboardData;let l=i.content(),{dom:o,text:f}=Dn(t,l);if(s){r.preventDefault();s.clearData();s.setData("text/html",o.innerHTML);s.setData("text/plain",f)}else{vs(t,o)}if(n)t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function ys(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function Ms(t,e){if(!t.dom.parentNode)return;let r=t.input.shiftKey||t.state.selection.$from.parent.type.spec.code;let i=t.dom.parentNode.appendChild(document.createElement(r?"textarea":"div"));if(!r)i.contentEditable="true";i.style.cssText="position: fixed; left: -10000px; top: 10px";i.focus();let n=t.input.shiftKey&&t.input.lastKeyCode!=45;setTimeout((()=>{t.focus();if(i.parentNode)i.parentNode.removeChild(i);if(r)xs(t,i.value,null,n,e);else xs(t,i.textContent,i.innerHTML,n,e)}),50)}function xs(t,e,r,i,n){let s=Nn(t,e,r,i,t.state.selection.$from);if(t.someProp("handlePaste",(e=>e(t,n,s||d.empty))))return true;if(!s)return false;let l=ys(s);let o=l?t.state.tr.replaceSelectionWith(l,i):t.state.tr.replaceSelection(s);t.dispatch(o.scrollIntoView().setMeta("paste",true).setMeta("uiEvent","paste"));return true}function Ss(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," "):""}Wn.paste=(t,e)=>{let r=e;if(t.composing&&!Ar)return;let i=ks?null:r.clipboardData;let n=t.input.shiftKey&&t.input.lastKeyCode!=45;if(i&&xs(t,Ss(i),i.getData("text/html"),n,r))r.preventDefault();else Ms(t,r)};class Os{constructor(t,e,r){this.slice=t;this.move=e;this.node=r}}const Es=Tr?"altKey":"ctrlKey";Ln.dragstart=(t,e)=>{let r=e;let i=t.input.mouseDown;if(i)i.done();if(!r.dataTransfer)return;let n=t.state.selection;let s=n.empty?null:t.posAtCoords(Zn(r));let l;if(s&&s.pos>=n.from&&s.pos<=(n instanceof Be?n.to-1:n.to));else if(i&&i.mightDrag){l=Be.create(t.state.doc,i.mightDrag.pos)}else if(r.target&&r.target.nodeType==1){let e=t.docView.nearestDesc(r.target,true);if(e&&e.node.type.spec.draggable&&e!=t.docView)l=Be.create(t.state.doc,e.posBefore)}let o=(l||t.state.selection).content(),{dom:f,text:u}=Dn(t,o);r.dataTransfer.clearData();r.dataTransfer.setData(ks?"Text":"text/html",f.innerHTML);r.dataTransfer.effectAllowed="copyMove";if(!ks)r.dataTransfer.setData("text/plain",u);t.dragging=new Os(o,!r[Es],l)};Ln.dragend=t=>{let e=t.dragging;window.setTimeout((()=>{if(t.dragging==e)t.dragging=null}),50)};Wn.dragover=Wn.dragenter=(t,e)=>e.preventDefault();Wn.drop=(t,e)=>{let r=e;let i=t.dragging;t.dragging=null;if(!r.dataTransfer)return;let n=t.posAtCoords(Zn(r));if(!n)return;let s=t.state.doc.resolve(n.pos);let l=i&&i.slice;if(l){t.someProp("transformPasted",(e=>{l=e(l,t)}))}else{l=Nn(t,Ss(r.dataTransfer),ks?null:r.dataTransfer.getData("text/html"),false,s)}let o=!!(i&&!r[Es]);if(t.someProp("handleDrop",(e=>e(t,r,l||d.empty,o)))){r.preventDefault();return}if(!l)return;r.preventDefault();let f=l?ce(t.state.doc,s.pos,l):s.pos;if(f==null)f=s.pos;let u=t.state.tr;if(o){let{node:t}=i;if(t)t.replace(u);else u.deleteSelection()}let h=u.mapping.map(f);let a=l.openStart==0&&l.openEnd==0&&l.content.childCount==1;let c=u.doc;if(a)u.replaceRangeWith(h,h,l.content.firstChild);else u.replaceRange(h,h,l);if(u.doc.eq(c))return;let p=u.doc.resolve(h);if(a&&Be.isSelectable(l.content.firstChild)&&p.nodeAfter&&p.nodeAfter.sameMarkup(l.content.firstChild)){u.setSelection(new Be(p))}else{let e=u.mapping.map(f);u.mapping.maps[u.mapping.maps.length-1].forEach(((t,r,i,n)=>e=n));u.setSelection(nn(t,p,u.doc.resolve(e)))}t.focus();t.dispatch(u.setMeta("uiEvent","drop"))};Ln.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()))Gi(t)}),20)}};Ln.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}};Ln.beforeinput=(t,e)=>{let r=e;if(Rr&&Ar&&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,wr(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 Wn)Ln[t]=Wn[t];function Ds(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 Ns{constructor(t,e){this.toDOM=t;this.spec=e||Ts;this.side=this.spec.side||0}map(t,e,r,i){let{pos:n,deleted:s}=t.mapResult(e.from+i,this.side<0?-1:1);return s?null:new Ps(n-r,n-r,this)}valid(){return true}eq(t){return this==t||t instanceof Ns&&(this.spec.key&&this.spec.key==t.spec.key||this.toDOM==t.toDOM&&Ds(this.spec,t.spec))}destroy(t){if(this.spec.destroy)this.spec.destroy(t)}}class Rs{constructor(t,e){this.attrs=t;this.spec=e||Ts}map(t,e,r,i){let n=t.map(e.from+i,this.spec.inclusiveStart?-1:1)-r;let s=t.map(e.to+i,this.spec.inclusiveEnd?1:-1)-r;return n>=s?null:new Ps(n,s,this)}valid(t,e){return e.from<e.to}eq(t){return this==t||t instanceof Rs&&Ds(this.attrs,t.attrs)&&Ds(this.spec,t.spec)}static is(t){return t.type instanceof Rs}destroy(){}}class Cs{constructor(t,e){this.attrs=t;this.spec=e||Ts}map(t,e,r,i){let n=t.mapResult(e.from+i,1);if(n.deleted)return null;let s=t.mapResult(e.to+i,-1);if(s.deleted||s.pos<=n.pos)return null;return new Ps(n.pos-r,s.pos-r,this)}valid(t,e){let{index:r,offset:i}=t.content.findIndex(e.from),n;return i==e.from&&!(n=t.child(r)).isText&&i+n.nodeSize==e.to}eq(t){return this==t||t instanceof Cs&&Ds(this.attrs,t.attrs)&&Ds(this.spec,t.spec)}destroy(){}}class Ps{constructor(t,e,r){this.from=t;this.to=e;this.type=r}copy(t,e){return new Ps(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 Ps(t,t,new Ns(e,r))}static inline(t,e,r,i){return new Ps(t,e,new Rs(r,i))}static node(t,e,r,i){return new Ps(t,e,new Cs(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof Rs}get widget(){return this.type instanceof Ns}}const qs=[],Ts={};class $s{constructor(t,e){this.local=t.length?t:qs;this.children=e.length?e:qs}static create(t,e){return e.length?Ls(e,t,0,Ts):As}find(t,e,r){let i=[];this.findInner(t==null?0:t,e==null?1e9:e,i,0,r);return i}findInner(t,e,r,i,n){for(let s=0;s<this.local.length;s++){let l=this.local[s];if(l.from<=e&&l.to>=t&&(!n||n(l.spec)))r.push(l.copy(l.from+i,l.to+i))}for(let s=0;s<this.children.length;s+=3){if(this.children[s]<e&&this.children[s+1]>t){let l=this.children[s]+1;this.children[s+2].findInner(t-l,e-l,r,i+l,n)}}}map(t,e,r){if(this==As||t.maps.length==0)return this;return this.mapInner(t,e,0,0,r||Ts)}mapInner(t,e,r,i,n){let s;for(let l=0;l<this.local.length;l++){let o=this.local[l].map(t,r,i);if(o&&o.type.valid(e,o))(s||(s=[])).push(o);else if(n.onRemove)n.onRemove(this.local[l].spec)}if(this.children.length)return zs(this.children,s||[],t,e,r,i,n);else return s?new $s(s.sort(Ws),qs):As}add(t,e){if(!e.length)return this;if(this==As)return $s.create(t,e);return this.addInner(t,e,0)}addInner(t,e,r){let i,n=0;t.forEach(((t,s)=>{let l=s+r,o;if(!(o=js(e,t,l)))return;if(!i)i=this.children.slice();while(n<i.length&&i[n]<s)n+=3;if(i[n]==s)i[n+2]=i[n+2].addInner(t,o,l+1);else i.splice(n,0,s,s+t.nodeSize,Ls(o,t,l+1,Ts));n+=3}));let s=Js(n?Fs(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 $s(s.length?this.local.concat(s).sort(Ws):this.local,i||this.children)}remove(t){if(t.length==0||this==As)return this;return this.removeInner(t,0)}removeInner(t,e){let r=this.children,i=this.local;for(let i=0;i<r.length;i+=3){let n;let s=r[i]+e,l=r[i+1]+e;for(let e=0,r;e<t.length;e++)if(r=t[e]){if(r.from>s&&r.to<l){t[e]=null;(n||(n=[])).push(r)}}if(!n)continue;if(r==this.children)r=this.children.slice();let o=r[i+2].removeInner(n,s+1);if(o!=As){r[i+2]=o}else{r.splice(i,3);i-=3}}if(i.length)for(let r=0,n;r<t.length;r++)if(n=t[r]){for(let t=0;t<i.length;t++)if(i[t].eq(n,e)){if(i==this.local)i=this.local.slice();i.splice(t--,1)}}if(r==this.children&&i==this.local)return this;return i.length||r.length?new $s(i,r):As}forChild(t,e){if(this==As)return this;if(e.isLeaf)return $s.empty;let r,i;for(let e=0;e<this.children.length;e+=3)if(this.children[e]>=t){if(this.children[e]==t)r=this.children[e+2];break}let n=t+1,s=n+e.content.size;for(let t=0;t<this.local.length;t++){let e=this.local[t];if(e.from<s&&e.to>n&&e.type instanceof Rs){let t=Math.max(n,e.from)-n,r=Math.min(s,e.to)-n;if(t<r)(i||(i=[])).push(e.copy(t,r))}}if(i){let t=new $s(i.sort(Ws),qs);return r?new Is([t,r]):t}return r||As}eq(t){if(this==t)return true;if(!(t instanceof $s)||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 Us(this.localsInner(t))}localsInner(t){if(this==As)return qs;if(t.inlineContent||!this.local.some(Rs.is))return this.local;let e=[];for(let t=0;t<this.local.length;t++){if(!(this.local[t].type instanceof Rs))e.push(this.local[t])}return e}}$s.empty=new $s([],[]);$s.removeOverlap=Us;const As=$s.empty;class Is{constructor(t){this.members=t}map(t,e){const r=this.members.map((r=>r.map(t,e,Ts)));return Is.from(r)}forChild(t,e){if(e.isLeaf)return $s.empty;let r=[];for(let i=0;i<this.members.length;i++){let n=this.members[i].forChild(t,e);if(n==As)continue;if(n instanceof Is)r=r.concat(n.members);else r.push(n)}return Is.from(r)}eq(t){if(!(t instanceof Is)||t.members.length!=this.members.length)return false;for(let e=0;e<this.members.length;e++)if(!this.members[e].eq(t.members[e]))return false;return true}locals(t){let e,r=true;for(let i=0;i<this.members.length;i++){let n=this.members[i].localsInner(t);if(!n.length)continue;if(!e){e=n}else{if(r){e=e.slice();r=false}for(let t=0;t<n.length;t++)e.push(n[t])}}return e?Us(r?e:e.sort(Ws)):qs}static from(t){switch(t.length){case 0:return As;case 1:return t[0];default:return new Is(t.every((t=>t instanceof $s))?t:t.reduce(((t,e)=>t.concat(e instanceof $s?e:e.members)),[]))}}}function zs(t,e,r,i,n,s,l){let o=t.slice();for(let t=0,e=s;t<r.maps.length;t++){let i=0;r.maps[t].forEach(((t,r,n,s)=>{let l=s-n-(r-t);for(let n=0;n<o.length;n+=3){let s=o[n+1];if(s<0||t>s+e-i)continue;let f=o[n]+e-i;if(r>=f){o[n+1]=t<=f?-2:-1}else if(t>=e&&l){o[n]+=l;o[n+1]+=l}}i+=l}));e=r.maps[t].map(e,-1)}let f=false;for(let e=0;e<o.length;e+=3)if(o[e+1]<0){if(o[e+1]==-2){f=true;o[e+1]=-1;continue}let u=r.map(t[e]+s),h=u-n;if(h<0||h>=i.content.size){f=true;continue}let a=r.map(t[e+1]+s,-1),c=a-n;let{index:d,offset:p}=i.content.findIndex(h);let m=i.maybeChild(d);if(m&&p==h&&p+m.nodeSize==c){let i=o[e+2].mapInner(r,m,u+1,t[e]+s+1,l);if(i!=As){o[e]=h;o[e+1]=c;o[e+2]=i}else{o[e+1]=-2;f=true}}else{f=true}}if(f){let f=Bs(o,t,e,r,n,s,l);let u=Ls(f,i,0,l);e=u.local;for(let t=0;t<o.length;t+=3)if(o[t+1]<0){o.splice(t,3);t-=3}for(let t=0,e=0;t<u.children.length;t+=3){let r=u.children[t];while(e<o.length&&o[e]<r)e+=3;o.splice(e,0,u.children[t],u.children[t+1],u.children[t+2])}}return new $s(e.sort(Ws),o)}function Js(t,e){if(!e||!t.length)return t;let r=[];for(let i=0;i<t.length;i++){let n=t[i];r.push(new Ps(n.from+e,n.to+e,n.type))}return r}function Bs(t,e,r,i,n,s,l){function o(t,e){for(let s=0;s<t.local.length;s++){let o=t.local[s].map(i,n,e);if(o)r.push(o);else if(l.onRemove)l.onRemove(t.local[s].spec)}for(let r=0;r<t.children.length;r+=3)o(t.children[r+2],t.children[r]+e+1)}for(let r=0;r<t.length;r+=3)if(t[r+1]==-1)o(t[r+2],e[r]+s+1);return r}function js(t,e,r){if(e.isLeaf)return null;let i=r+e.nodeSize,n=null;for(let e=0,s;e<t.length;e++){if((s=t[e])&&s.from>r&&s.to<i){(n||(n=[])).push(s);t[e]=null}}return n}function Fs(t){let e=[];for(let r=0;r<t.length;r++)if(t[r]!=null)e.push(t[r]);return e}function Ls(t,e,r,i){let n=[],s=false;e.forEach(((e,l)=>{let o=js(t,e,l+r);if(o){s=true;let t=Ls(o,e,r+l+1,i);if(t!=As)n.push(l,l+e.nodeSize,t)}}));let l=Js(s?Fs(t):t,-r).sort(Ws);for(let t=0;t<l.length;t++)if(!l[t].type.valid(e,l[t])){if(i.onRemove)i.onRemove(l[t].spec);l.splice(t--,1)}return l.length||n.length?new $s(l,n):As}function Ws(t,e){return t.from-e.from||t.to-e.to}function Us(t){let e=t;for(let r=0;r<e.length-1;r++){let i=e[r];if(i.from!=i.to)for(let n=r+1;n<e.length;n++){let s=e[n];if(s.from==i.from){if(s.to!=i.to){if(e==t)e=t.slice();e[n]=s.copy(s.from,i.to);Ks(e,n+1,s.copy(i.to,s.to))}continue}else{if(s.from<i.to){if(e==t)e=t.slice();e[r]=i.copy(i.from,s.from);Ks(e,n,i.copy(s.from,i.to))}break}}}return e}function Ks(t,e,r){while(e<t.length&&Ws(r,t[e])>0)e++;t.splice(e,0,r)}function _s(t){let e=[];t.someProp("decorations",(r=>{let i=r(t.state);if(i&&i!=As)e.push(i)}));if(t.cursorWrapper)e.push($s.create(t.state.doc,[t.cursorWrapper.deco]));return Is.from(e)}const Hs={childList:true,characterData:true,characterDataOldValue:true,attributes:true,attributeOldValue:true,subtree:true};const Gs=Or&&Er<=11;class Vs{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 Xs{constructor(t,e){this.view=t;this.handleDOMChange=e;this.queue=[];this.flushingSoon=-1;this.observer=null;this.currentSelection=new Vs;this.onCharData=null;this.suppressingSelectionUpdates=false;this.observer=window.MutationObserver&&new window.MutationObserver((t=>{for(let e=0;e<t.length;e++)this.queue.push(t[e]);if(Or&&Er<=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(Gs){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,Hs)}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(!sn(this.view))return;if(this.suppressingSelectionUpdates)return Gi(this.view);if(Or&&Er<=11&&!this.view.state.selection.empty){let t=this.view.domSelectionRange();if(t.focusNode&&ur(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=lr(r))e.add(r);for(let i=t.anchorNode;i;i=lr(i))if(e.has(i)){r=i;break}let i=r&&this.view.docView.nearestDesc(r);if(i&&i.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r})){this.setCurSelection();return true}}pendingRecords(){if(this.observer)for(let t of this.observer.takeRecords())this.queue.push(t);return this.queue}flush(){let{view:t}=this;if(!t.docView||this.flushingSoon>-1)return;let e=this.pendingRecords();if(e.length)this.queue=[];let r=t.domSelectionRange();let i=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&sn(t)&&!this.ignoreSelectionChange(r);let n=-1,s=-1,l=false,o=[];if(t.editable){for(let t=0;t<e.length;t++){let r=this.registerMutation(e[t],o);if(r){n=n<0?r.from:Math.min(r.from,n);s=s<0?r.to:Math.max(r.to,s);if(r.typeOver)l=true}}}if(Dr&&o.length>1){let t=o.filter((t=>t.nodeName=="BR"));if(t.length==2){let e=t[0],r=t[1];if(e.parentNode&&e.parentNode.parentNode==r.parentNode)r.remove();else e.remove()}}let f=null;if(n<0&&i&&t.input.lastFocus>Date.now()-200&&Math.max(t.input.lastTouch,t.input.lastClick.time)<Date.now()-300&&mr(r)&&(f=_i(t))&&f.eq(Te.near(t.state.doc.resolve(0),1))){t.input.lastFocus=0;Gi(t);this.currentSelection.set(r);t.scrollToSelection()}else if(n>-1||i){if(n>-1){t.docView.markDirty(n,s);Zs(t)}this.handleDOMChange(n,s,l,o);if(t.docView&&t.docView.dirty)t.updateState(t.state);else if(!this.currentSelection.eq(r))Gi(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++)e.push(t.addedNodes[r]);if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(t.target))return{from:r.posBefore,to:r.posAfter};let i=t.previousSibling,n=t.nextSibling;if(Or&&Er<=11&&t.addedNodes.length){for(let e=0;e<t.addedNodes.length;e++){let{previousSibling:r,nextSibling:s}=t.addedNodes[e];if(!r||Array.prototype.indexOf.call(t.addedNodes,r)<0)i=r;if(!s||Array.prototype.indexOf.call(t.addedNodes,s)<0)n=s}}let s=i&&i.parentNode==t.target?sr(i)+1:0;let l=r.localPosFromDOM(t.target,s,-1);let o=n&&n.parentNode==t.target?sr(n):t.target.childNodes.length;let f=r.localPosFromDOM(t.target,o,1);return{from:l,to:f}}else if(t.type=="attributes"){return{from:r.posAtStart-r.border,to:r.posAtEnd+r.border}}else{return{from:r.posAtStart,to:r.posAtEnd,typeOver:t.target.nodeValue==t.oldValue}}}}let Ys=new WeakMap;let Qs=false;function Zs(t){if(Ys.has(t))return;Ys.set(t,null);if(["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace)!==-1){t.requiresGeckoHackNode=Dr;if(Qs)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.");Qs=true}}function tl(t){let e;function r(t){t.preventDefault();t.stopImmediatePropagation();e=t.getTargetRanges()[0]}t.dom.addEventListener("beforeinput",r,true);document.execCommand("indent");t.dom.removeEventListener("beforeinput",r,true);let i=e.startContainer,n=e.startOffset;let s=e.endContainer,l=e.endOffset;let o=t.domAtPos(t.state.selection.anchor);if(ur(o.node,o.offset,s,l))[i,n,s,l]=[s,l,i,n];return{anchorNode:i,anchorOffset:n,focusNode:s,focusOffset:l}}function el(t,e,r){let{node:i,fromOffset:n,toOffset:s,from:l,to:o}=t.docView.parseRange(e,r);let f=t.domSelectionRange();let u;let h=f.anchorNode;if(h&&t.dom.contains(h.nodeType==1?h:h.parentNode)){u=[{node:h,offset:f.anchorOffset}];if(!mr(f))u.push({node:f.focusNode,offset:f.focusOffset})}if(Rr&&t.input.lastKeyCode===8){for(let t=s;t>n;t--){let e=i.childNodes[t-1],r=e.pmViewDesc;if(e.nodeName=="BR"&&!r){s=t;break}if(!r||r.size)break}}let a=t.state.doc;let c=t.someProp("domParser")||it.fromSchema(t.state.schema);let d=a.resolve(l);let p=null,m=c.parse(i,{topNode:d.parent,topMatch:d.parent.contentMatchAt(d.index()),topOpen:true,from:n,to:s,preserveWhitespace:d.parent.type.whitespace=="pre"?"full":true,findPositions:u,ruleFromNode:rl,context:d});if(u&&u[0].pos!=null){let t=u[0].pos,e=u[1]&&u[1].pos;if(e==null)e=t;p={anchor:t+l,head:e+l}}return{doc:m,sel:p,from:l,to:o}}function rl(t){let e=t.pmViewDesc;if(e){return e.parseRule()}else if(t.nodeName=="BR"&&t.parentNode){if(Pr&&/^(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||Pr&&/^(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 il=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function nl(t,e,r,i,n){let s=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);t.input.compositionPendingChanges=0;if(e<0){let e=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null;let r=_i(t,e);if(r&&!t.state.selection.eq(r)){if(Rr&&Ar&&t.input.lastKeyCode===13&&Date.now()-100<t.input.lastKeyCodeTime&&t.someProp("handleKeyDown",(e=>e(t,wr(13,"Enter")))))return;let i=t.state.tr.setSelection(r);if(e=="pointer")i.setMeta("pointer",true);else if(e=="key")i.scrollIntoView();if(s)i.setMeta("composition",s);t.dispatch(i)}return}let l=t.state.doc.resolve(e);let o=l.sharedDepth(r);e=l.before(o+1);r=t.state.doc.resolve(r).after(o+1);let f=t.state.selection;let u=el(t,e,r);let h=t.state.doc,a=h.slice(u.from,u.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=ul(a.content,u.doc.content,u.from,c,d);if((qr&&t.input.lastIOSEnter>Date.now()-225||Ar)&&n.some((t=>t.nodeType==1&&!il.test(t.nodeName)))&&(!p||p.endA>=p.endB)&&t.someProp("handleKeyDown",(e=>e(t,wr(13,"Enter"))))){t.input.lastIOSEnter=0;return}if(!p){if(i&&f instanceof ze&&!f.empty&&f.$head.sameParent(f.$anchor)&&!t.composing&&!(u.sel&&u.sel.anchor!=u.sel.head)){p={start:f.from,endA:f.to,endB:f.to}}else{if(u.sel){let e=sl(t,t.state.doc,u.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(Rr&&t.cursorWrapper&&u.sel&&u.sel.anchor==t.cursorWrapper.deco.from&&u.sel.head==u.sel.anchor){let t=p.endB-p.start;u.sel={anchor:u.sel.anchor+t,head:u.sel.anchor+t}}t.input.domChangeCount++;if(t.state.selection.from<t.state.selection.to&&p.start==p.endB&&t.state.selection instanceof ze){if(p.start>t.state.selection.from&&p.start<=t.state.selection.from+2&&t.state.selection.from>=u.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<=u.to){p.endB+=t.state.selection.to-p.endA;p.endA=t.state.selection.to}}if(Or&&Er<=11&&p.endB==p.start+1&&p.endA==p.start&&p.start>u.from&&u.doc.textBetween(p.start-u.from-1,p.start-u.from+1)=="  "){p.start--;p.endA--;p.endB--}let m=u.doc.resolveNoCache(p.start-u.from);let w=u.doc.resolveNoCache(p.endB-u.from);let g=h.resolve(p.start);let b=m.sameParent(w)&&m.parent.inlineContent&&g.end()>=p.endA;let v;if((qr&&t.input.lastIOSEnter>Date.now()-225&&(!b||n.some((t=>t.nodeName=="DIV"||t.nodeName=="P")))||!b&&m.pos<u.doc.content.size&&!m.sameParent(w)&&(v=Te.findFrom(u.doc.resolve(m.pos+1),1,true))&&v.head==w.pos)&&t.someProp("handleKeyDown",(e=>e(t,wr(13,"Enter"))))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>p.start&&ol(h,p.start,p.endA,m,w)&&t.someProp("handleKeyDown",(e=>e(t,wr(8,"Backspace"))))){if(Ar&&Rr)t.domObserver.suppressSelectionUpdates();return}if(Rr&&Ar&&p.endB==p.start)t.input.lastAndroidDelete=Date.now();if(Ar&&!b&&m.start()!=w.start()&&w.parentOffset==0&&m.depth==w.depth&&u.sel&&u.sel.anchor==u.sel.head&&u.sel.head==p.endA){p.endB-=2;w=u.doc.resolveNoCache(p.endB-u.from);setTimeout((()=>{t.someProp("handleKeyDown",(function(e){return e(t,wr(13,"Enter"))}))}),20)}let k=p.start,y=p.endA;let M,x,S;if(b){if(m.pos==w.pos){if(Or&&Er<=11&&m.parentOffset==0){t.domObserver.suppressSelectionUpdates();setTimeout((()=>Gi(t)),20)}M=t.state.tr.delete(k,y);x=h.resolve(p.start).marksAcross(h.resolve(p.endA))}else if(p.endA==p.endB&&(S=ll(m.parent.content.cut(m.parentOffset,w.parentOffset),g.parent.content.cut(g.parentOffset,p.endA-g.start())))){M=t.state.tr;if(S.type=="add")M.addMark(k,y,S.mark);else M.removeMark(k,y,S.mark)}else if(m.parent.child(m.index()).isText&&m.index()==w.index()-(w.textOffset?0:1)){let e=m.parent.textBetween(m.parentOffset,w.parentOffset);if(t.someProp("handleTextInput",(r=>r(t,k,y,e))))return;M=t.state.tr.insertText(e,k,y)}}if(!M)M=t.state.tr.replace(k,y,u.doc.slice(p.start-u.from,p.endB-u.from));if(u.sel){let e=sl(t,M.doc,u.sel);if(e&&!(Rr&&Ar&&t.composing&&e.empty&&(p.start!=p.endB||t.input.lastAndroidDelete<Date.now()-100)&&(e.head==k||e.head==M.mapping.map(y)-1)||Or&&e.empty&&e.head==k))M.setSelection(e)}if(x)M.ensureMarks(x);if(s)M.setMeta("composition",s);t.dispatch(M.scrollIntoView())}function sl(t,e,r){if(Math.max(r.anchor,r.head)>e.content.size)return null;return nn(t,e.resolve(r.anchor),e.resolve(r.head))}function ll(t,e){let r=t.firstChild.marks,i=e.firstChild.marks;let n=r,s=i,l,f,u;for(let t=0;t<i.length;t++)n=i[t].removeFromSet(n);for(let t=0;t<r.length;t++)s=r[t].removeFromSet(s);if(n.length==1&&s.length==0){f=n[0];l="add";u=t=>t.mark(f.addToSet(t.marks))}else if(n.length==0&&s.length==1){f=s[0];l="remove";u=t=>t.mark(f.removeFromSet(t.marks))}else{return null}let h=[];for(let t=0;t<e.childCount;t++)h.push(u(e.child(t)));if(o.from(h).eq(t))return{mark:f,type:l}}function ol(t,e,r,i,n){if(!i.parent.isTextblock||r-e<=n.pos-i.pos||fl(i,true,false)<n.pos)return false;let s=t.resolve(e);if(s.parentOffset<s.parent.content.size||!s.parent.isTextblock)return false;let l=t.resolve(fl(s,true,true));if(!l.parent.isTextblock||l.pos>r||fl(l,true,false)<r)return false;return i.parent.content.cut(i.parentOffset).eq(l.parent.content)}function fl(t,e,r){let i=t.depth,n=e?t.end():t.pos;while(i>0&&(e||t.indexAfter(i)==t.node(i).childCount)){i--;n++;e=false}if(r){let e=t.node(i).maybeChild(t.indexAfter(i));while(e&&!e.isLeaf){e=e.firstChild;n++}}return n}function ul(t,e,r,i,n){let s=t.findDiffStart(e,r);if(s==null)return null;let{a:l,b:o}=t.findDiffEnd(e,r+t.size,r+e.size);if(n=="end"){let t=Math.max(0,s-Math.min(l,o));i-=l+t-s}if(l<s&&t.size<e.size){let t=i<=s&&i>=l?s-i:0;s-=t;if(s&&s<e.size&&hl(e.textBetween(s-1,s+1)))s+=t?1:-1;o=s+(o-l);l=s}else if(o<s){let e=i<=s&&i>=o?s-i:0;s-=e;if(s&&s<t.size&&hl(t.textBetween(s-1,s+1)))s+=e?1:-1;l=s+(l-o);o=s}return{start:s,endA:l,endB:o}}function hl(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 al{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 Kn;this.prevDirectPlugins=[];this.pluginViews=[];this.requiresGeckoHackNode=false;this.dragging=null;this._props=e;this.state=e.state;this.directPlugins=e.plugins||[];this.directPlugins.forEach(bl);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=pl(this);dl(this);this.nodeViews=wl(this);this.docView=Oi(this.state.doc,cl(this),_s(this),this.dom,this);this.domObserver=new Xs(this,((t,e,r,i)=>nl(this,t,e,r,i)));this.domObserver.start();_n(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)Vn(this);let e=this._props;this._props=t;if(t.plugins){t.plugins.forEach(bl);this.directPlugins=t.plugins}this.updateStateInner(t.state,e)}setProps(t){let e={};for(let t in this._props)e[t]=this._props[t];e.state=this.state;for(let r in t)e[r]=t[r];this.update(e)}updateState(t){this.updateStateInner(t,this._props)}updateStateInner(t,e){var r;let i=this.state,n=false,s=false;if(t.storedMarks&&this.composing){ws(this);s=true}this.state=t;let l=i.plugins!=t.plugins||this._props.plugins!=e.plugins;if(l||this._props.plugins!=e.plugins||this._props.nodeViews!=e.nodeViews){let t=wl(this);if(gl(t,this.nodeViews)){this.nodeViews=t;n=true}}if(l||e.handleDOMEvents!=this._props.handleDOMEvents){Vn(this)}this.editable=pl(this);dl(this);let o=_s(this),f=cl(this);let u=i.plugins!=t.plugins&&!i.doc.eq(t.doc)?"reset":t.scrollToSelection>i.scrollToSelection?"to selection":"preserve";let h=n||!this.docView.matchesNode(t.doc,f,o);if(h||!t.selection.eq(i.selection))s=true;let a=u=="preserve"&&s&&this.dom.style.overflowAnchor==null&&Lr(this);if(s){this.domObserver.stop();let e=h&&(Or||Rr)&&!this.composing&&!i.selection.empty&&!t.selection.empty&&ml(i.selection,t.selection);if(h){let r=Rr?this.trackWrites=this.domSelectionRange().focusNode:null;if(n||!this.docView.update(t.doc,f,o,this)){this.docView.updateOuterDeco([]);this.docView.destroy();this.docView=Oi(t.doc,f,o,this.dom,this)}if(r&&!this.trackWrites)e=true}if(e||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&on(this))){Gi(this,e)}else{en(this,t.selection);this.domObserver.setCurSelection()}this.domObserver.start()}this.updatePluginViews(i);if(((r=this.dragging)===null||r===void 0?void 0:r.node)&&!i.doc.eq(t.doc))this.updateDraggedNode(this.dragging,i);if(u=="reset"){this.dom.scrollTop=0}else if(u=="to selection"){this.scrollToSelection()}else if(a){Ur(a)}}scrollToSelection(){let t=this.domSelectionRange().focusNode;if(this.someProp("handleScrollToSelection",(t=>t(this))));else if(this.state.selection instanceof Be){let e=this.docView.domAfterPos(this.state.selection.from);if(e.nodeType==1)Fr(this,e.getBoundingClientRect(),t)}else{Fr(this,this.coordsAtPos(this.state.selection.head,1),t)}}destroyPluginViews(){let t;while(t=this.pluginViews.pop())if(t.destroy)t.destroy()}updatePluginViews(t){if(!t||t.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins;this.destroyPluginViews();for(let t=0;t<this.directPlugins.length;t++){let e=this.directPlugins[t];if(e.spec.view)this.pluginViews.push(e.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let e=this.state.plugins[t];if(e.spec.view)this.pluginViews.push(e.spec.view(this))}}else{for(let e=0;e<this.pluginViews.length;e++){let r=this.pluginViews[e];if(r.update)r.update(this,t)}}}updateDraggedNode(t,e){let r=t.node,i=-1;if(this.state.doc.nodeAt(r.from)==r.node){i=r.from}else{let t=r.from+(this.state.doc.content.size-e.doc.content.size);let n=t>0&&this.state.doc.nodeAt(t);if(n==r.node)i=t}this.dragging=new Os(t.slice,t.move,i<0?undefined:Be.create(this.state.doc,i))}someProp(t,e){let r=this._props&&this._props[t],i;if(r!=null&&(i=e?e(r):r))return i;for(let r=0;r<this.directPlugins.length;r++){let n=this.directPlugins[r].props[t];if(n!=null&&(i=e?e(n):n))return i}let n=this.state.plugins;if(n)for(let r=0;r<n.length;r++){let s=n[r].props[t];if(s!=null&&(i=e?e(s):s))return i}}hasFocus(){if(Or){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)Hr(this.dom);Gi(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 ei(this,t)}coordsAtPos(t,e=1){return si(this,t,e)}domAtPos(t,e=0){return this.docView.domFromPos(t,e)}nodeDOM(t){let e=this.docView.descAt(t);return e?e.nodeDOM:null}posAtDOM(t,e,r=-1){let i=this.docView.posFromDOM(t,e,r);if(i==null)throw new RangeError("DOM position not inside the editor");return i}endOfTextblock(t,e){return mi(this,e||this.state,t)}pasteHTML(t,e){return xs(this,"",t,false,e||new ClipboardEvent("paste"))}pasteText(t,e){return xs(this,t,null,true,e||new ClipboardEvent("paste"))}destroy(){if(!this.docView)return;Gn(this);this.destroyPluginViews();if(this.mounted){this.docView.update(this.state.doc,[],_s(this),this);this.dom.textContent=""}else if(this.dom.parentNode){this.dom.parentNode.removeChild(this.dom)}this.docView.destroy();this.docView=null}get isDestroyed(){return this.docView==null}dispatchEvent(t){return Qn(this,t)}dispatch(t){let e=this._props.dispatchTransaction;if(e)e.call(this,t);else this.updateState(this.state.apply(t))}domSelectionRange(){return Pr&&this.root.nodeType===11&&gr(this.dom.ownerDocument)==this.dom?tl(this):this.domSelection()}domSelection(){return this.root.getSelection()}}function cl(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[Ps.node(0,t.state.doc.content.size,e)]}function dl(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:Ps.widget(t.state.selection.head,e,{raw:true,marks:t.markCursor})}}else{t.cursorWrapper=null}}function pl(t){return!t.someProp("editable",(e=>e(t.state)===false))}function ml(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 wl(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 gl(t,e){let r=0,i=0;for(let i in t){if(t[i]!=e[i])return true;r++}for(let t in e)i++;return r!=i}function bl(t){if(t.spec.state||t.spec.filterTransaction||t.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}const vl=["p",0],kl=["blockquote",0],yl=["hr"],Ml=["pre",["code",0]],xl=["br"];const Sl={doc:{content:"block+"},paragraph:{content:"inline*",group:"block",parseDOM:[{tag:"p"}],toDOM(){return vl}},blockquote:{content:"block+",group:"block",defining:true,parseDOM:[{tag:"blockquote"}],toDOM(){return kl}},horizontal_rule:{group:"block",parseDOM:[{tag:"hr"}],toDOM(){return yl}},heading:{attrs:{level:{default:1}},content:"inline*",group:"block",defining:true,parseDOM:[{tag:"h1",attrs:{level:1}},{tag:"h2",attrs:{level:2}},{tag:"h3",attrs:{level:3}},{tag:"h4",attrs:{level:4}},{tag:"h5",attrs:{level:5}},{tag:"h6",attrs:{level:6}}],toDOM(t){return["h"+t.attrs.level,0]}},code_block:{content:"text*",marks:"",group:"block",code:true,defining:true,parseDOM:[{tag:"pre",preserveWhitespace:"full"}],toDOM(){return Ml}},text:{group:"inline"},image:{inline:true,attrs:{src:{},alt:{default:null},title:{default:null}},group:"inline",draggable:true,parseDOM:[{tag:"img[src]",getAttrs(t){return{src:t.getAttribute("src"),title:t.getAttribute("title"),alt:t.getAttribute("alt")}}}],toDOM(t){let{src:e,alt:r,title:i}=t.attrs;return["img",{src:e,alt:r,title:i}]}},hard_break:{inline:true,group:"inline",selectable:false,parseDOM:[{tag:"br"}],toDOM(){return xl}}};const Ol=["em",0],El=["strong",0],Dl=["code",0];const Nl={link:{attrs:{href:{},title:{default:null}},inclusive:false,parseDOM:[{tag:"a[href]",getAttrs(t){return{href:t.getAttribute("href"),title:t.getAttribute("title")}}}],toDOM(t){let{href:e,title:r}=t.attrs;return["a",{href:e,title:r},0]}},em:{parseDOM:[{tag:"i"},{tag:"em"},{style:"font-style=italic"},{style:"font-style=normal",clearMark:t=>t.type.name=="em"}],toDOM(){return Ol}},strong:{parseDOM:[{tag:"strong"},{tag:"b",getAttrs:t=>t.style.fontWeight!="normal"&&null},{style:"font-weight=400",clearMark:t=>t.type.name=="strong"},{style:"font-weight",getAttrs:t=>/^(bold(er)?|[5-9]\d{2,})$/.test(t)&&null}],toDOM(){return El}},code:{parseDOM:[{tag:"code"}],toDOM(){return Dl}}};const Rl=new et({nodes:Sl,marks:Nl});const Cl=["ol",0],Pl=["ul",0],ql=["li",0];const Tl={attrs:{order:{default:1}},parseDOM:[{tag:"ol",getAttrs(t){return{order:t.hasAttribute("start")?+t.getAttribute("start"):1}}}],toDOM(t){return t.attrs.order==1?Cl:["ol",{start:t.attrs.order},0]}};const $l={parseDOM:[{tag:"ul"}],toDOM(){return Pl}};const Al={parseDOM:[{tag:"li"}],toDOM(){return ql},defining:true};function Il(t,e){let r={};for(let e in t)r[e]=t[e];for(let t in e)r[t]=e[t];return r}function zl(t,e,r){return t.append({ordered_list:Il(Tl,{content:"list_item+",group:r}),bullet_list:Il($l,{content:"list_item+",group:r}),list_item:Il(Al,{content:e})})}function Jl(t,e=null){return function(r,i){let{$from:n,$to:s}=r.selection;let l=n.blockRange(s),o=false,f=l;if(!l)return false;if(l.depth>=2&&n.node(l.depth-1).type.compatibleContent(t)&&l.startIndex==0){if(n.index(l.depth-1)==0)return false;let t=r.doc.resolve(l.start-2);f=new C(t,t,l.depth);if(l.endIndex<l.parent.childCount)l=new C(n,r.doc.resolve(s.end(l.depth)),l.depth);o=true}let u=Yt(f,t,e,l);if(!u)return false;if(i)i(Bl(r.tr,l,u,o,t).scrollIntoView());return true}}function Bl(t,e,r,i,n){let s=o.empty;for(let t=r.length-1;t>=0;t--)s=o.from(r[t].type.create(r[t].attrs,s));t.step(new Wt(e.start-(i?2:0),e.end,e.start,e.end,new d(s,0,0),r.length,true));let l=0;for(let t=0;t<r.length;t++)if(r[t].type==n)l=t+1;let f=r.length-l;let u=e.start+r.length-(i?2:0),h=e.parent;for(let r=e.startIndex,i=e.endIndex,n=true;r<i;r++,n=false){if(!n&&se(t.doc,u,f)){t.split(u,f);u+=2*f}u+=h.child(r).nodeSize}return t}function jl(t,e){return function(r,i){let{$from:n,$to:s,node:l}=r.selection;if(l&&l.isBlock||n.depth<2||!n.sameParent(s))return false;let f=n.node(-1);if(f.type!=t)return false;if(n.parent.content.size==0&&n.node(-1).childCount==n.indexAfter(-1)){if(n.depth==3||n.node(-3).type!=t||n.index(-2)!=n.node(-2).childCount-1)return false;if(i){let e=o.empty;let s=n.index(-1)?1:n.index(-2)?2:3;for(let t=n.depth-s;t>=n.depth-3;t--)e=o.from(n.node(t).copy(e));let l=n.indexAfter(-1)<n.node(-2).childCount?1:n.indexAfter(-2)<n.node(-3).childCount?2:3;e=e.append(o.from(t.createAndFill()));let f=n.before(n.depth-(s-1));let u=r.tr.replace(f,n.after(-l),new d(e,4-s,0));let h=-1;u.doc.nodesBetween(f,u.doc.content.size,((t,e)=>{if(h>-1)return false;if(t.isTextblock&&t.content.size==0)h=e+1}));if(h>-1)u.setSelection(Te.near(u.doc.resolve(h)));i(u.scrollIntoView())}return true}let u=s.pos==n.end()?f.contentMatchAt(0).defaultType:null;let h=r.tr.delete(n.pos,s.pos);let a=u?[e?{type:t,attrs:e}:null,{type:u}]:undefined;if(!se(h.doc,n.pos,2,a))return false;if(i)i(h.split(n.pos,2,a).scrollIntoView());return true}}function Fl(t){return function(e,r){let{$from:i,$to:n}=e.selection;let s=i.blockRange(n,(e=>e.childCount>0&&e.firstChild.type==t));if(!s)return false;if(!r)return true;if(i.node(s.depth-1).type==t)return Ll(e,r,t,s);else return Wl(e,r,s)}}function Ll(t,e,r,i){let n=t.tr,s=i.end,l=i.$to.end(i.depth);if(s<l){n.step(new Wt(s-1,l,s,l,new d(o.from(r.create(null,i.parent.copy())),1,0),1,true));i=new C(n.doc.resolve(i.$from.pos),n.doc.resolve(l),i.depth)}const f=Vt(i);if(f==null)return false;n.lift(i,f);let u=n.mapping.map(s,-1)-1;if(oe(n.doc,u))n.join(u);e(n.scrollIntoView());return true}function Wl(t,e,r){let i=t.tr,n=r.parent;for(let t=r.end,e=r.endIndex-1,s=r.startIndex;e>s;e--){t-=n.child(e).nodeSize;i.delete(t-1,t+1)}let s=i.doc.resolve(r.start),l=s.nodeAfter;if(i.mapping.map(r.end)!=r.start+s.nodeAfter.nodeSize)return false;let f=r.startIndex==0,u=r.endIndex==n.childCount;let h=s.node(-1),a=s.index(-1);if(!h.canReplace(a+(f?0:1),a+1,l.content.append(u?o.empty:o.from(n))))return false;let c=s.pos,p=c+l.nodeSize;i.step(new Wt(c-(f?1:0),p+(u?1:0),c+1,p-1,new d((f?o.empty:o.from(n.copy(o.empty))).append(u?o.empty:o.from(n.copy(o.empty))),f?0:1,u?0:1),f?0:1));e(i.scrollIntoView());return true}function Ul(t){return function(e,r){let{$from:i,$to:n}=e.selection;let s=i.blockRange(n,(e=>e.childCount>0&&e.firstChild.type==t));if(!s)return false;let l=s.startIndex;if(l==0)return false;let f=s.parent,u=f.child(l-1);if(u.type!=t)return false;if(r){let i=u.lastChild&&u.lastChild.type==f.type;let n=o.from(i?t.create():null);let l=new d(o.from(t.create(null,o.from(f.type.create(null,n)))),i?3:1,0);let h=s.start,a=s.end;r(e.tr.step(new Wt(h-(i?3:1),a,h,a,l,1,true)).scrollIntoView())}return true}}var Kl={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 _l={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 Gl=typeof navigator!="undefined"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var Vl=0;Vl<10;Vl++)Kl[48+Vl]=Kl[96+Vl]=String(Vl);for(var Vl=1;Vl<=24;Vl++)Kl[Vl+111]="F"+Vl;for(var Vl=65;Vl<=90;Vl++){Kl[Vl]=String.fromCharCode(Vl+32);_l[Vl]=String.fromCharCode(Vl)}for(var Xl in Kl)if(!_l.hasOwnProperty(Xl))_l[Xl]=Kl[Xl];function Yl(t){var e=Hl&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||Gl&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified";var r=!e&&t.key||(t.shiftKey?_l:Kl)[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 Ql=typeof navigator!="undefined"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):false;function Zl(t){let e=t.split(/-(?!$)/),r=e[e.length-1];if(r=="Space")r=" ";let i,n,s,l;for(let t=0;t<e.length-1;t++){let r=e[t];if(/^(cmd|meta|m)$/i.test(r))l=true;else if(/^a(lt)?$/i.test(r))i=true;else if(/^(c|ctrl|control)$/i.test(r))n=true;else if(/^s(hift)?$/i.test(r))s=true;else if(/^mod$/i.test(r)){if(Ql)l=true;else n=true}else throw new Error("Unrecognized modifier name: "+r)}if(i)r="Alt-"+r;if(n)r="Ctrl-"+r;if(l)r="Meta-"+r;if(s)r="Shift-"+r;return r}function to(t){let e=Object.create(null);for(let r in t)e[Zl(r)]=t[r];return e}function eo(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 ro(t){return new er({props:{handleKeyDown:io(t)}})}function io(t){let e=to(t);return function(t,r){let i=Yl(r),n,s=e[eo(i,r)];if(s&&s(t.state,t.dispatch,t))return true;if(i.length==1&&i!=" "){if(r.shiftKey){let n=e[eo(i,r,false)];if(n&&n(t.state,t.dispatch,t))return true}if((r.shiftKey||r.altKey||r.metaKey||i.charCodeAt(0)>127)&&(n=Kl[r.keyCode])&&n!=i){let i=e[eo(n,r)];if(i&&i(t.state,t.dispatch,t))return true}}return false}}var no=200;var so=function t(){};so.prototype.append=function t(e){if(!e.length){return this}e=so.from(e);return!this.length&&e||e.length<no&&this.leafAppend(e)||this.length<no&&e.leafPrepend(this)||this.appendInner(e)};so.prototype.prepend=function t(e){if(!e.length){return this}return so.from(e).append(this)};so.prototype.appendInner=function t(e){return new oo(this,e)};so.prototype.slice=function t(e,r){if(e===void 0)e=0;if(r===void 0)r=this.length;if(e>=r){return so.empty}return this.sliceInner(Math.max(0,e),Math.min(this.length,r))};so.prototype.get=function t(e){if(e<0||e>=this.length){return undefined}return this.getInner(e)};so.prototype.forEach=function t(e,r,i){if(r===void 0)r=0;if(i===void 0)i=this.length;if(r<=i){this.forEachInner(e,r,i,0)}else{this.forEachInvertedInner(e,r,i,0)}};so.prototype.map=function t(e,r,i){if(r===void 0)r=0;if(i===void 0)i=this.length;var n=[];this.forEach((function(t,r){return n.push(e(t,r))}),r,i);return n};so.from=function t(e){if(e instanceof so){return e}return e&&e.length?new lo(e):so.empty};var lo=function(t){function e(e){t.call(this);this.values=e}if(t)e.__proto__=t;e.prototype=Object.create(t&&t.prototype);e.prototype.constructor=e;var r={length:{configurable:true},depth:{configurable:true}};e.prototype.flatten=function t(){return this.values};e.prototype.sliceInner=function t(r,i){if(r==0&&i==this.length){return this}return new e(this.values.slice(r,i))};e.prototype.getInner=function t(e){return this.values[e]};e.prototype.forEachInner=function t(e,r,i,n){for(var s=r;s<i;s++){if(e(this.values[s],n+s)===false){return false}}};e.prototype.forEachInvertedInner=function t(e,r,i,n){for(var s=r-1;s>=i;s--){if(e(this.values[s],n+s)===false){return false}}};e.prototype.leafAppend=function t(r){if(this.length+r.length<=no){return new e(this.values.concat(r.flatten()))}};e.prototype.leafPrepend=function t(r){if(this.length+r.length<=no){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}(so);so.empty=new lo([]);var oo=function(t){function e(e,r){t.call(this);this.left=e;this.right=r;this.length=e.length+r.length;this.depth=Math.max(e.depth,r.depth)+1}if(t)e.__proto__=t;e.prototype=Object.create(t&&t.prototype);e.prototype.constructor=e;e.prototype.flatten=function t(){return this.left.flatten().concat(this.right.flatten())};e.prototype.getInner=function t(e){return e<this.left.length?this.left.get(e):this.right.get(e-this.left.length)};e.prototype.forEachInner=function t(e,r,i,n){var s=this.left.length;if(r<s&&this.left.forEachInner(e,r,Math.min(i,s),n)===false){return false}if(i>s&&this.right.forEachInner(e,Math.max(r-s,0),Math.min(this.length,i)-s,n+s)===false){return false}};e.prototype.forEachInvertedInner=function t(e,r,i,n){var s=this.left.length;if(r>s&&this.right.forEachInvertedInner(e,r-s,Math.max(i,s)-s,n+s)===false){return false}if(i<s&&this.left.forEachInvertedInner(e,Math.min(r,s),i,n)===false){return false}};e.prototype.sliceInner=function t(e,r){if(e==0&&r==this.length){return this}var i=this.left.length;if(r<=i){return this.left.slice(e,r)}if(e>=i){return this.right.slice(e-i,r-i)}return this.left.slice(e,i).append(this.right.slice(0,r-i))};e.prototype.leafAppend=function t(r){var i=this.right.leafAppend(r);if(i){return new e(this.left,i)}};e.prototype.leafPrepend=function t(r){var i=this.left.leafPrepend(r);if(i){return new e(i,this.right)}};e.prototype.appendInner=function t(r){if(this.left.depth>=Math.max(this.right.depth,r.depth)+1){return new e(this.left,new e(this.right,r))}return new e(this,r)};return e}(so);const fo=500;class uo{constructor(t,e){this.items=t;this.eventCount=e}popEvent(t,e){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--){let t=this.items.get(r-1);if(t.selection){--r;break}}let i,n;if(e){i=this.remapping(r,this.items.length);n=i.maps.length}let s=t.tr;let l,o;let f=[],u=[];this.items.forEach(((t,e)=>{if(!t.step){if(!i){i=this.remapping(r,e+1);n=i.maps.length}n--;u.push(t);return}if(i){u.push(new ao(t.map));let e=t.step.map(i.slice(n)),r;if(e&&s.maybeStep(e).doc){r=s.mapping.maps[s.mapping.maps.length-1];f.push(new ao(r,undefined,undefined,f.length+u.length))}n--;if(r)i.appendMap(r,n)}else{s.maybeStep(t.step)}if(t.selection){l=i?t.selection.map(i.slice(n)):t.selection;o=new uo(this.items.slice(0,r).append(u.reverse().concat(f)),this.eventCount-1);return false}}),this.items.length,0);return{remaining:o,transform:s,selection:l}}addTransform(t,e,r,i){let n=[],s=this.eventCount;let l=this.items,o=!i&&l.length?l.get(l.length-1):null;for(let r=0;r<t.steps.length;r++){let f=t.steps[r].invert(t.docs[r]);let u=new ao(t.mapping.maps[r],f,e),h;if(h=o&&o.merge(u)){u=h;if(r)n.pop();else l=l.slice(0,l.length-1)}n.push(u);if(e){s++;e=undefined}if(!i)o=u}let f=s-r.depth;if(f>po){l=ho(l,f);s-=f}return new uo(l.append(n),s)}remapping(t,e){let r=new Tt;this.items.forEach(((e,i)=>{let n=e.mirrorOffset!=null&&i-e.mirrorOffset>=t?r.maps.length-e.mirrorOffset:undefined;r.appendMap(e.map,n)}),t,e);return r}addMaps(t){if(this.eventCount==0)return this;return new uo(this.items.append(t.map((t=>new ao(t)))),this.eventCount)}rebased(t,e){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-e);let n=t.mapping;let s=t.steps.length;let l=this.eventCount;this.items.forEach((t=>{if(t.selection)l--}),i);let o=e;this.items.forEach((e=>{let i=n.getMirror(--o);if(i==null)return;s=Math.min(s,i);let f=n.maps[i];if(e.step){let s=t.steps[i].invert(t.docs[i]);let u=e.selection&&e.selection.map(n.slice(o+1,i));if(u)l++;r.push(new ao(f,s,u))}else{r.push(new ao(f))}}),i);let f=[];for(let t=e;t<s;t++)f.push(new ao(n.maps[t]));let u=this.items.slice(0,i).append(f).append(r);let h=new uo(u,l);if(h.emptyItemCount()>fo)h=h.compress(this.items.length-r.length);return h}emptyItemCount(){let t=0;this.items.forEach((e=>{if(!e.step)t++}));return t}compress(t=this.items.length){let e=this.remapping(0,t),r=e.maps.length;let i=[],n=0;this.items.forEach(((s,l)=>{if(l>=t){i.push(s);if(s.selection)n++}else if(s.step){let t=s.step.map(e.slice(r)),l=t&&t.getMap();r--;if(l)e.appendMap(l,r);if(t){let o=s.selection&&s.selection.map(e.slice(r));if(o)n++;let f=new ao(l.invert(),t,o),u,h=i.length-1;if(u=i.length&&i[h].merge(f))i[h]=u;else i.push(f)}}else if(s.map){r--}}),this.items.length,0);return new uo(so.from(i.reverse()),n)}}uo.empty=new uo(so.empty,0);function ho(t,e){let r;t.forEach(((t,i)=>{if(t.selection&&e--==0){r=i;return false}}));return t.slice(r)}class ao{constructor(t,e,r,i){this.map=t;this.step=e;this.selection=r;this.mirrorOffset=i}merge(t){if(this.step&&t.step&&!t.selection){let e=t.step.merge(this.step);if(e)return new ao(e.getMap().invert(),e,this.selection)}}}class co{constructor(t,e,r,i,n){this.done=t;this.undone=e;this.prevRanges=r;this.prevTime=i;this.prevComposition=n}}const po=20;function mo(t,e,r,i){let n=r.getMeta(xo),s;if(n)return n.historyState;if(r.getMeta(So))t=new co(t.done,t.undone,null,0,-1);let l=r.getMeta("appendedTransaction");if(r.steps.length==0){return t}else if(l&&l.getMeta(xo)){if(l.getMeta(xo).redo)return new co(t.done.addTransform(r,undefined,i,Mo(e)),t.undone,go(r.mapping.maps[r.steps.length-1]),t.prevTime,t.prevComposition);else return new co(t.done,t.undone.addTransform(r,undefined,i,Mo(e)),null,t.prevTime,t.prevComposition)}else if(r.getMeta("addToHistory")!==false&&!(l&&l.getMeta("addToHistory")===false)){let n=r.getMeta("composition");let s=t.prevTime==0||!l&&t.prevComposition!=n&&(t.prevTime<(r.time||0)-i.newGroupDelay||!wo(r,t.prevRanges));let o=l?bo(t.prevRanges,r.mapping):go(r.mapping.maps[r.steps.length-1]);return new co(t.done.addTransform(r,s?e.selection.getBookmark():undefined,i,Mo(e)),uo.empty,o,r.time,n==null?t.prevComposition:n)}else if(s=r.getMeta("rebased")){return new co(t.done.rebased(r,s),t.undone.rebased(r,s),bo(t.prevRanges,r.mapping),t.prevTime,t.prevComposition)}else{return new co(t.done.addMaps(r.mapping.maps),t.undone.addMaps(r.mapping.maps),bo(t.prevRanges,r.mapping),t.prevTime,t.prevComposition)}}function wo(t,e){if(!e)return false;if(!t.docChanged)return true;let r=false;t.mapping.maps[0].forEach(((t,i)=>{for(let n=0;n<e.length;n+=2)if(t<=e[n+1]&&i>=e[n])r=true}));return r}function go(t){let e=[];t.forEach(((t,r,i,n)=>e.push(i,n)));return e}function bo(t,e){if(!t)return null;let r=[];for(let i=0;i<t.length;i+=2){let n=e.map(t[i],1),s=e.map(t[i+1],-1);if(n<=s)r.push(n,s)}return r}function vo(t,e,r,i){let n=Mo(e);let s=xo.get(e).spec.config;let l=(i?t.undone:t.done).popEvent(e,n);if(!l)return;let o=l.selection.resolve(l.transform.doc);let f=(i?t.done:t.undone).addTransform(l.transform,e.selection.getBookmark(),s,n);let u=new co(i?f:l.remaining,i?l.remaining:f,null,0,-1);r(l.transform.setSelection(o).setMeta(xo,{redo:i,historyState:u}).scrollIntoView())}let ko=false,yo=null;function Mo(t){let e=t.plugins;if(yo!=e){ko=false;yo=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){ko=true;break}}return ko}const xo=new nr("history");const So=new nr("closeHistory");function Oo(t={}){t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500};return new er({key:xo,state:{init(){return new co(uo.empty,uo.empty,null,0,-1)},apply(e,r,i){return mo(r,i,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(t,e){let r=e.inputType;let i=r=="historyUndo"?Eo:r=="historyRedo"?Do:null;if(!i)return false;e.preventDefault();return i(t.state,t.dispatch)}}}})}const Eo=(t,e)=>{let r=xo.getState(t);if(!r||r.done.eventCount==0)return false;if(e)vo(r,t,e,false);return true};const Do=(t,e)=>{let r=xo.getState(t);if(!r||r.undone.eventCount==0)return false;if(e)vo(r,t,e,true);return true};const No=(t,e)=>{if(t.selection.empty)return false;if(e)e(t.tr.deleteSelection().scrollIntoView());return true};function Ro(t,e){let{$cursor:r}=t.selection;if(!r||(e?!e.endOfTextblock("backward",t):r.parentOffset>0))return null;return r}const Co=(t,e,r)=>{let i=Ro(t,r);if(!i)return false;let n=To(i);if(!n){let r=i.blockRange(),n=r&&Vt(r);if(n==null)return false;if(e)e(t.tr.lift(r,n).scrollIntoView());return true}let s=n.nodeBefore;if(!s.type.spec.isolating&&Yo(t,n,e))return true;if(i.parent.content.size==0&&(Po(s,"end")||Be.isSelectable(s))){let r=de(t.doc,i.before(),i.after(),d.empty);if(r&&r.slice.size<r.to-r.from){if(e){let i=t.tr.step(r);i.setSelection(Po(s,"end")?Te.findFrom(i.doc.resolve(i.mapping.map(n.pos,-1)),-1):Be.create(i.doc,n.pos-s.nodeSize));e(i.scrollIntoView())}return true}}if(s.isAtom&&n.depth==i.depth-1){if(e)e(t.tr.delete(n.pos-s.nodeSize,n.pos).scrollIntoView());return true}return false};function Po(t,e,r=false){for(let i=t;i;i=e=="start"?i.firstChild:i.lastChild){if(i.isTextblock)return true;if(r&&i.childCount!=1)return false}return false}const qo=(t,e,r)=>{let{$head:i,empty:n}=t.selection,s=i;if(!n)return false;if(i.parent.isTextblock){if(r?!r.endOfTextblock("backward",t):i.parentOffset>0)return false;s=To(i)}let l=s&&s.nodeBefore;if(!l||!Be.isSelectable(l))return false;if(e)e(t.tr.setSelection(Be.create(t.doc,s.pos-l.nodeSize)).scrollIntoView());return true};function To(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 $o(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 Ao=(t,e,r)=>{let i=$o(t,r);if(!i)return false;let n=zo(i);if(!n)return false;let s=n.nodeAfter;if(Yo(t,n,e))return true;if(i.parent.content.size==0&&(Po(s,"start")||Be.isSelectable(s))){let r=de(t.doc,i.before(),i.after(),d.empty);if(r&&r.slice.size<r.to-r.from){if(e){let i=t.tr.step(r);i.setSelection(Po(s,"start")?Te.findFrom(i.doc.resolve(i.mapping.map(n.pos)),1):Be.create(i.doc,i.mapping.map(n.pos)));e(i.scrollIntoView())}return true}}if(s.isAtom&&n.depth==i.depth-1){if(e)e(t.tr.delete(n.pos,n.pos+s.nodeSize).scrollIntoView());return true}return false};const Io=(t,e,r)=>{let{$head:i,empty:n}=t.selection,s=i;if(!n)return false;if(i.parent.isTextblock){if(r?!r.endOfTextblock("forward",t):i.parentOffset<i.parent.content.size)return false;s=zo(i)}let l=s&&s.nodeAfter;if(!l||!Be.isSelectable(l))return false;if(e)e(t.tr.setSelection(Be.create(t.doc,s.pos)).scrollIntoView());return true};function zo(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 Jo=(t,e)=>{let r=t.selection,i=r instanceof Be,n;if(i){if(r.node.isTextblock||!oe(t.doc,r.from))return false;n=r.from}else{n=ue(t.doc,r.from,-1);if(n==null)return false}if(e){let r=t.tr.join(n);if(i)r.setSelection(Be.create(r.doc,n-t.doc.resolve(n).nodeBefore.nodeSize));e(r.scrollIntoView())}return true};const Bo=(t,e)=>{let r=t.selection,i;if(r instanceof Be){if(r.node.isTextblock||!oe(t.doc,r.to))return false;i=r.to}else{i=ue(t.doc,r.to,1);if(i==null)return false}if(e)e(t.tr.join(i).scrollIntoView());return true};const jo=(t,e)=>{let{$from:r,$to:i}=t.selection;let n=r.blockRange(i),s=n&&Vt(n);if(s==null)return false;if(e)e(t.tr.lift(n,s).scrollIntoView());return true};const Fo=(t,e)=>{let{$head:r,$anchor:i}=t.selection;if(!r.parent.type.spec.code||!r.sameParent(i))return false;if(e)e(t.tr.insertText("\n").scrollIntoView());return true};function Lo(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 Wo=(t,e)=>{let{$head:r,$anchor:i}=t.selection;if(!r.parent.type.spec.code||!r.sameParent(i))return false;let n=r.node(-1),s=r.indexAfter(-1),l=Lo(n.contentMatchAt(s));if(!l||!n.canReplaceWith(s,s,l))return false;if(e){let i=r.after(),n=t.tr.replaceWith(i,i,l.createAndFill());n.setSelection(Te.near(n.doc.resolve(i),1));e(n.scrollIntoView())}return true};const Uo=(t,e)=>{let r=t.selection,{$from:i,$to:n}=r;if(r instanceof Fe||i.parent.inlineContent||n.parent.inlineContent)return false;let s=Lo(n.parent.contentMatchAt(n.indexAfter()));if(!s||!s.isTextblock)return false;if(e){let r=(!i.parentOffset&&n.index()<n.parent.childCount?i:n).pos;let l=t.tr.insert(r,s.createAndFill());l.setSelection(ze.create(l.doc,r+1));e(l.scrollIntoView())}return true};const Ko=(t,e)=>{let{$cursor:r}=t.selection;if(!r||r.parent.content.size)return false;if(r.depth>1&&r.after()!=r.end(-1)){let i=r.before();if(se(t.doc,i)){if(e)e(t.tr.split(i).scrollIntoView());return true}}let i=r.blockRange(),n=i&&Vt(i);if(n==null)return false;if(e)e(t.tr.lift(i,n).scrollIntoView());return true};function _o(t){return(e,r)=>{let{$from:i,$to:n}=e.selection;if(e.selection instanceof Be&&e.selection.node.isBlock){if(!i.parentOffset||!se(e.doc,i.pos))return false;if(r)r(e.tr.split(i.pos).scrollIntoView());return true}if(!i.parent.isBlock)return false;if(r){let s=n.parentOffset==n.parent.content.size;let l=e.tr;if(e.selection instanceof ze||e.selection instanceof Fe)l.deleteSelection();let o=i.depth==0?null:Lo(i.node(-1).contentMatchAt(i.indexAfter(-1)));let f=t&&t(n.parent,s);let u=f?[f]:s&&o?[{type:o}]:undefined;let h=se(l.doc,l.mapping.map(i.pos),1,u);if(!u&&!h&&se(l.doc,l.mapping.map(i.pos),1,o?[{type:o}]:undefined)){if(o)u=[{type:o}];h=true}if(h){l.split(l.mapping.map(i.pos),1,u);if(!s&&!i.parentOffset&&i.parent.type!=o){let t=l.mapping.map(i.before()),e=l.doc.resolve(t);if(o&&i.node(-1).canReplaceWith(e.index(),e.index()+1,o))l.setNodeMarkup(l.mapping.map(i.before()),o)}}r(l.scrollIntoView())}return true}}const Ho=_o();const Go=(t,e)=>{let{$from:r,to:i}=t.selection,n;let s=r.sharedDepth(i);if(s==0)return false;n=r.before(s);if(e)e(t.tr.setSelection(Be.create(t.doc,n)));return true};const Vo=(t,e)=>{if(e)e(t.tr.setSelection(new Fe(t.doc)));return true};function Xo(t,e,r){let i=e.nodeBefore,n=e.nodeAfter,s=e.index();if(!i||!n||!i.type.compatibleContent(n.type))return false;if(!i.content.size&&e.parent.canReplace(s-1,s)){if(r)r(t.tr.delete(e.pos-i.nodeSize,e.pos).scrollIntoView());return true}if(!e.parent.canReplace(s,s+1)||!(n.isTextblock||oe(t.doc,e.pos)))return false;if(r)r(t.tr.clearIncompatible(e.pos,i.type,i.contentMatchAt(i.childCount)).join(e.pos).scrollIntoView());return true}function Yo(t,e,r){let i=e.nodeBefore,n=e.nodeAfter,s,l;if(i.type.spec.isolating||n.type.spec.isolating)return false;if(Xo(t,e,r))return true;let f=e.parent.canReplace(e.index(),e.index()+1);if(f&&(s=(l=i.contentMatchAt(i.childCount)).findWrapping(n.type))&&l.matchType(s[0]||n.type).validEnd){if(r){let l=e.pos+n.nodeSize,f=o.empty;for(let t=s.length-1;t>=0;t--)f=o.from(s[t].create(null,f));f=o.from(i.copy(f));let u=t.tr.step(new Wt(e.pos-1,l,e.pos,l,new d(f,1,0),s.length,true));let h=l+2*s.length;if(oe(u.doc,h))u.join(h);r(u.scrollIntoView())}return true}let u=Te.findFrom(e,1);let h=u&&u.$from.blockRange(u.$to),a=h&&Vt(h);if(a!=null&&a>=e.depth){if(r)r(t.tr.lift(h,a).scrollIntoView());return true}if(f&&Po(n,"start",true)&&Po(i,"end")){let s=i,l=[];for(;;){l.push(s);if(s.isTextblock)break;s=s.lastChild}let f=n,u=1;for(;!f.isTextblock;f=f.firstChild)u++;if(s.canReplace(s.childCount,s.childCount,f.content)){if(r){let i=o.empty;for(let t=l.length-1;t>=0;t--)i=o.from(l[t].copy(i));let s=t.tr.step(new Wt(e.pos-l.length,e.pos+n.nodeSize,e.pos+u,e.pos+n.nodeSize-u,new d(i,l.length,0),0,true));r(s.scrollIntoView())}return true}}return false}function Qo(t){return function(e,r){let i=e.selection,n=t<0?i.$from:i.$to;let s=n.depth;while(n.node(s).isInline){if(!s)return false;s--}if(!n.node(s).isTextblock)return false;if(r)r(e.tr.setSelection(ze.create(e.doc,t<0?n.start(s):n.end(s))));return true}}const Zo=Qo(-1);const tf=Qo(1);function ef(t,e=null){return function(r,i){let{$from:n,$to:s}=r.selection;let l=n.blockRange(s),o=l&&Yt(l,t,e);if(!o)return false;if(i)i(r.tr.wrap(l,o).scrollIntoView());return true}}function rf(t,e=null){return function(r,i){let n=false;for(let i=0;i<r.selection.ranges.length&&!n;i++){let{$from:{pos:s},$to:{pos:l}}=r.selection.ranges[i];r.doc.nodesBetween(s,l,((i,s)=>{if(n)return false;if(!i.isTextblock||i.hasMarkup(t,e))return;if(i.type==t){n=true}else{let e=r.doc.resolve(s),i=e.index();n=e.parent.canReplaceWith(i,i+1,t)}}))}if(!n)return false;if(i){let n=r.tr;for(let i=0;i<r.selection.ranges.length;i++){let{$from:{pos:s},$to:{pos:l}}=r.selection.ranges[i];n.setBlockType(s,l,t,e)}i(n.scrollIntoView())}return true}}function nf(t,e,r){for(let i=0;i<e.length;i++){let{$from:n,$to:s}=e[i];let l=n.depth==0?t.inlineContent&&t.type.allowsMarkType(r):false;t.nodesBetween(n.pos,s.pos,(t=>{if(l)return false;l=t.inlineContent&&t.type.allowsMarkType(r)}));if(l)return true}return false}function sf(t,e=null){return function(r,i){let{empty:n,$cursor:s,ranges:l}=r.selection;if(n&&!s||!nf(r.doc,l,t))return false;if(i){if(s){if(t.isInSet(r.storedMarks||s.marks()))i(r.tr.removeStoredMark(t));else i(r.tr.addStoredMark(t.create(e)))}else{let n=false,s=r.tr;for(let e=0;!n&&e<l.length;e++){let{$from:i,$to:s}=l[e];n=r.doc.rangeHasMark(i.pos,s.pos,t)}for(let r=0;r<l.length;r++){let{$from:i,$to:o}=l[r];if(n){s.removeMark(i.pos,o.pos,t)}else{let r=i.pos,n=o.pos,l=i.nodeAfter,f=o.nodeBefore;let u=l&&l.isText?/^\s*/.exec(l.text)[0].length:0;let h=f&&f.isText?/\s*$/.exec(f.text)[0].length:0;if(r+u<n){r+=u;n-=h}s.addMark(r,n,t.create(e))}}i(s.scrollIntoView())}}return true}}function lf(...t){return function(e,r,i){for(let n=0;n<t.length;n++)if(t[n](e,r,i))return true;return false}}let of=lf(No,Co,qo);let ff=lf(No,Ao,Io);const uf={Enter:lf(Fo,Uo,Ko,Ho),"Mod-Enter":Wo,Backspace:of,"Mod-Backspace":of,"Shift-Backspace":of,Delete:ff,"Mod-Delete":ff,"Mod-a":Vo};const hf={"Ctrl-h":uf["Backspace"],"Alt-Backspace":uf["Mod-Backspace"],"Ctrl-d":uf["Delete"],"Ctrl-Alt-Backspace":uf["Mod-Delete"],"Alt-Delete":uf["Mod-Delete"],"Alt-d":uf["Mod-Delete"],"Ctrl-a":Zo,"Ctrl-e":tf};for(let t in uf)hf[t]=uf[t];const af=typeof navigator!="undefined"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os!="undefined"&&os.platform?os.platform()=="darwin":false;const cf=af?hf:uf;function df(t={}){return new er({view(e){return new pf(e,t)}})}class pf{constructor(t,e){var r;this.editorView=t;this.cursorPos=null;this.element=null;this.timeout=-1;this.width=(r=e.width)!==null&&r!==void 0?r:1;this.color=e.color===false?undefined:e.color||"black";this.class=e.class;this.handlers=["dragover","dragend","drop","dragleave"].map((e=>{let r=t=>{this[e](t)};t.dom.addEventListener(e,r);return{name:e,handler:r}}))}destroy(){this.handlers.forEach((({name:t,handler:e})=>this.editorView.dom.removeEventListener(t,e)))}update(t,e){if(this.cursorPos!=null&&e.doc!=t.state.doc){if(this.cursorPos>t.state.doc.content.size)this.setCursor(null);else this.updateOverlay()}}setCursor(t){if(t==this.cursorPos)return;this.cursorPos=t;if(t==null){this.element.parentNode.removeChild(this.element);this.element=null}else{this.updateOverlay()}}updateOverlay(){let t=this.editorView.state.doc.resolve(this.cursorPos);let e=!t.parent.inlineContent,r;if(e){let e=t.nodeBefore,i=t.nodeAfter;if(e||i){let t=this.editorView.nodeDOM(this.cursorPos-(e?e.nodeSize:0));if(t){let n=t.getBoundingClientRect();let s=e?n.bottom:n.top;if(e&&i)s=(s+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2;r={left:n.left,right:n.right,top:s-this.width/2,bottom:s+this.width/2}}}}if(!r){let t=this.editorView.coordsAtPos(this.cursorPos);r={left:t.left-this.width/2,right:t.left+this.width/2,top:t.top,bottom:t.bottom}}let i=this.editorView.dom.offsetParent;if(!this.element){this.element=i.appendChild(document.createElement("div"));if(this.class)this.element.className=this.class;this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;";if(this.color){this.element.style.backgroundColor=this.color}}this.element.classList.toggle("prosemirror-dropcursor-block",e);this.element.classList.toggle("prosemirror-dropcursor-inline",!e);let n,s;if(!i||i==document.body&&getComputedStyle(i).position=="static"){n=-pageXOffset;s=-pageYOffset}else{let t=i.getBoundingClientRect();n=t.left-i.scrollLeft;s=t.top-i.scrollTop}this.element.style.left=r.left-n+"px";this.element.style.top=r.top-s+"px";this.element.style.width=r.right-r.left+"px";this.element.style.height=r.bottom-r.top+"px"}scheduleRemoval(t){clearTimeout(this.timeout);this.timeout=setTimeout((()=>this.setCursor(null)),t)}dragover(t){if(!this.editorView.editable)return;let e=this.editorView.posAtCoords({left:t.clientX,top:t.clientY});let r=e&&e.inside>=0&&this.editorView.state.doc.nodeAt(e.inside);let i=r&&r.type.spec.disableDropCursor;let n=typeof i=="function"?i(this.editorView,e,t):i;if(e&&!n){let t=e.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let e=ce(this.editorView.state.doc,t,this.editorView.dragging.slice);if(e!=null)t=e}this.setCursor(t);this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(t){if(t.target==this.editorView.dom||!this.editorView.dom.contains(t.relatedTarget))this.setCursor(null)}}class mf extends Te{constructor(t){super(t,t)}map(t,e){let r=t.resolve(e.map(this.head));return mf.valid(r)?new mf(r):Te.near(r)}content(){return d.empty}eq(t){return t instanceof mf&&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 mf(t.resolve(e.pos))}getBookmark(){return new wf(this.anchor)}static valid(t){let e=t.parent;if(e.isTextblock||!gf(t)||!bf(t))return false;let r=e.type.spec.allowGapCursor;if(r!=null)return r;let i=e.contentMatchAt(t.index()).defaultType;return i&&i.isTextblock}static findGapCursorFrom(t,e,r=false){t:for(;;){if(!r&&mf.valid(t))return t;let i=t.pos,n=null;for(let r=t.depth;;r--){let s=t.node(r);if(e>0?t.indexAfter(r)<s.childCount:t.index(r)>0){n=s.child(e>0?t.indexAfter(r):t.index(r)-1);break}else if(r==0){return null}i+=e;let l=t.doc.resolve(i);if(mf.valid(l))return l}for(;;){let s=e>0?n.firstChild:n.lastChild;if(!s){if(n.isAtom&&!n.isText&&!Be.isSelectable(n)){t=t.doc.resolve(i+n.nodeSize*e);r=false;continue t}break}n=s;i+=e;let l=t.doc.resolve(i);if(mf.valid(l))return l}return null}}}mf.prototype.visible=false;mf.findFrom=mf.findGapCursorFrom;Te.jsonID("gapcursor",mf);class wf{constructor(t){this.pos=t}map(t){return new wf(t.map(this.pos))}resolve(t){let e=t.resolve(this.pos);return mf.valid(e)?new mf(e):Te.near(e)}}function gf(t){for(let e=t.depth;e>=0;e--){let r=t.index(e),i=t.node(e);if(r==0){if(i.type.spec.isolating)return true;continue}for(let t=i.child(r-1);;t=t.lastChild){if(t.childCount==0&&!t.inlineContent||t.isAtom||t.type.spec.isolating)return true;if(t.inlineContent)return false}}return true}function bf(t){for(let e=t.depth;e>=0;e--){let r=t.indexAfter(e),i=t.node(e);if(r==i.childCount){if(i.type.spec.isolating)return true;continue}for(let t=i.child(r);;t=t.firstChild){if(t.childCount==0&&!t.inlineContent||t.isAtom||t.type.spec.isolating)return true;if(t.inlineContent)return false}}return true}function vf(){return new er({props:{decorations:Sf,createSelectionBetween(t,e,r){return e.pos==r.pos&&mf.valid(r)?new mf(r):null},handleClick:Mf,handleKeyDown:kf,handleDOMEvents:{beforeinput:xf}}})}const kf=io({ArrowLeft:yf("horiz",-1),ArrowRight:yf("horiz",1),ArrowUp:yf("vert",-1),ArrowDown:yf("vert",1)});function yf(t,e){const r=t=="vert"?e>0?"down":"up":e>0?"right":"left";return function(t,i,n){let s=t.selection;let l=e>0?s.$to:s.$from,o=s.empty;if(s instanceof ze){if(!n.endOfTextblock(r)||l.depth==0)return false;o=false;l=t.doc.resolve(e>0?l.after():l.before())}let f=mf.findGapCursorFrom(l,e,o);if(!f)return false;if(i)i(t.tr.setSelection(new mf(f)));return true}}function Mf(t,e,r){if(!t||!t.editable)return false;let i=t.state.doc.resolve(e);if(!mf.valid(i))return false;let n=t.posAtCoords({left:r.clientX,top:r.clientY});if(n&&n.inside>-1&&Be.isSelectable(t.state.doc.nodeAt(n.inside)))return false;t.dispatch(t.state.tr.setSelection(new mf(i)));return true}function xf(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof mf))return false;let{$from:r}=t.state.selection;let i=r.parent.contentMatchAt(r.index()).findWrapping(t.state.schema.nodes.text);if(!i)return false;let n=o.empty;for(let t=i.length-1;t>=0;t--)n=o.from(i[t].createAndFill(null,n));let s=t.state.tr.replace(r.pos,r.pos,new d(n,0,0));s.setSelection(ze.near(s.doc.resolve(r.pos+1)));t.dispatch(s);return false}function Sf(t){if(!(t.selection instanceof mf))return null;let e=document.createElement("div");e.className="ProseMirror-gapcursor";return $s.create(t.doc,[Ps.widget(t.selection.head,e,{key:"gapcursor"})])}function Of(){var t=arguments[0];if(typeof t=="string")t=document.createElement(t);var e=1,r=arguments[1];if(r&&typeof r=="object"&&r.nodeType==null&&!Array.isArray(r)){for(var i in r)if(Object.prototype.hasOwnProperty.call(r,i)){var n=r[i];if(typeof n=="string")t.setAttribute(i,n);else if(n!=null)t[i]=n}e++}for(;e<arguments.length;e++)Ef(t,arguments[e]);return t}function Ef(t,e){if(typeof e=="string"){t.appendChild(document.createTextNode(e))}else if(e==null);else if(e.nodeType!=null){t.appendChild(e)}else if(Array.isArray(e)){for(var r=0;r<e.length;r++)Ef(t,e[r])}else{throw new RangeError("Unsupported child node: "+e)}}const Df="http://www.w3.org/2000/svg";const Nf="http://www.w3.org/1999/xlink";const Rf="ProseMirror-icon";function Cf(t){let e=0;for(let r=0;r<t.length;r++)e=(e<<5)-e+t.charCodeAt(r)|0;return e}function Pf(t,e){let r=(t.nodeType==9?t:t.ownerDocument)||document;let i=r.createElement("div");i.className=Rf;if(e.path){let{path:n,width:s,height:l}=e;let o="pm-icon-"+Cf(n).toString(16);if(!r.getElementById(o))qf(t,o,e);let f=i.appendChild(r.createElementNS(Df,"svg"));f.style.width=s/l+"em";let u=f.appendChild(r.createElementNS(Df,"use"));u.setAttributeNS(Nf,"href",/([^#]*)/.exec(r.location.toString())[1]+"#"+o)}else if(e.dom){i.appendChild(e.dom.cloneNode(true))}else{let{text:t,css:n}=e;i.appendChild(r.createElement("span")).textContent=t||"";if(n)i.firstChild.style.cssText=n}return i}function qf(t,e,r){let[i,n]=t.nodeType==9?[t,t.body]:[t.ownerDocument||document,t];let s=i.getElementById(Rf+"-collection");if(!s){s=i.createElementNS(Df,"svg");s.id=Rf+"-collection";s.style.display="none";n.insertBefore(s,n.firstChild)}let l=i.createElementNS(Df,"symbol");l.id=e;l.setAttribute("viewBox","0 0 "+r.width+" "+r.height);let o=l.appendChild(i.createElementNS(Df,"path"));o.setAttribute("d",r.path);s.appendChild(l)}const Tf="ProseMirror-menu";class $f{constructor(t){this.spec=t}render(t){let e=this.spec;let r=e.render?e.render(t):e.icon?Pf(t.root,e.icon):e.label?Of("div",null,Af(t,e.label)):null;if(!r)throw new RangeError("MenuItem without icon or label property");if(e.title){const i=typeof e.title==="function"?e.title(t.state):e.title;r.setAttribute("title",Af(t,i))}if(e.class)r.classList.add(e.class);if(e.css)r.style.cssText+=e.css;r.addEventListener("mousedown",(i=>{i.preventDefault();if(!r.classList.contains(Tf+"-disabled"))e.run(t.state,t.dispatch,t,i)}));function i(t){if(e.select){let i=e.select(t);r.style.display=i?"":"none";if(!i)return false}let i=true;if(e.enable){i=e.enable(t)||false;Zf(r,Tf+"-disabled",!i)}if(e.active){let n=i&&e.active(t)||false;Zf(r,Tf+"-active",n)}return true}return{dom:r,update:i}}}function Af(t,e){return t._props.translate?t._props.translate(e):e}let If={time:0,node:null};function zf(t){If.time=Date.now();If.node=t.target}function Jf(t){return Date.now()-100<If.time&&If.node&&t.contains(If.node)}class Bf{constructor(t,e={}){this.options=e;this.options=e||{};this.content=Array.isArray(t)?t:[t]}render(t){let e=jf(this.content,t);let r=t.dom.ownerDocument.defaultView||window;let i=Of("div",{class:Tf+"-dropdown "+(this.options.class||""),style:this.options.css},Af(t,this.options.label||""));if(this.options.title)i.setAttribute("title",Af(t,this.options.title));let n=Of("div",{class:Tf+"-dropdown-wrap"},i);let s=null;let l=null;let o=()=>{if(s&&s.close()){s=null;r.removeEventListener("mousedown",l)}};i.addEventListener("mousedown",(t=>{t.preventDefault();zf(t);if(s){o()}else{s=this.expand(n,e.dom);r.addEventListener("mousedown",l=()=>{if(!Jf(n))o()})}}));function f(t){let r=e.update(t);n.style.display=r?"":"none";return r}return{dom:n,update:f}}expand(t,e){let r=Of("div",{class:Tf+"-dropdown-menu "+(this.options.class||"")},e);let i=false;function n(){if(i)return false;i=true;t.removeChild(r);return true}t.appendChild(r);return{close:n,node:r}}}function jf(t,e){let r=[],i=[];for(let n=0;n<t.length;n++){let{dom:s,update:l}=t[n].render(e);r.push(Of("div",{class:Tf+"-dropdown-item"},s));i.push(l)}return{dom:r,update:Ff(i,r)}}function Ff(t,e){return r=>{let i=false;for(let n=0;n<t.length;n++){let s=t[n](r);e[n].style.display=s?"":"none";if(s)i=true}return i}}class Lf{constructor(t,e={}){this.options=e;this.content=Array.isArray(t)?t:[t]}render(t){let e=jf(this.content,t);let r=t.dom.ownerDocument.defaultView||window;let i=Of("div",{class:Tf+"-submenu-label"},Af(t,this.options.label||""));let n=Of("div",{class:Tf+"-submenu-wrap"},i,Of("div",{class:Tf+"-submenu"},e.dom));let s=null;i.addEventListener("mousedown",(t=>{t.preventDefault();zf(t);Zf(n,Tf+"-submenu-wrap-active",false);if(!s)r.addEventListener("mousedown",s=()=>{if(!Jf(n)){n.classList.remove(Tf+"-submenu-wrap-active");r.removeEventListener("mousedown",s);s=null}})}));function l(t){let r=e.update(t);n.style.display=r?"":"none";return r}return{dom:n,update:l}}}function Wf(t,e){let r=document.createDocumentFragment();let i=[],n=[];for(let s=0;s<e.length;s++){let l=e[s],o=[],f=[];for(let e=0;e<l.length;e++){let{dom:i,update:n}=l[e].render(t);let s=Of("span",{class:Tf+"item"},i);r.appendChild(s);f.push(s);o.push(n)}if(o.length){i.push(Ff(o,f));if(s<e.length-1)n.push(r.appendChild(Uf()))}}function s(t){let e=false,r=false;for(let s=0;s<i.length;s++){let l=i[s](t);if(s)n[s-1].style.display=r&&l?"":"none";r=l;if(l)e=true}return e}return{dom:r,update:s}}function Uf(){return Of("span",{class:Tf+"separator"})}const Kf={join:{width:800,height:900,path:"M0 75h800v125h-800z M0 825h800v-125h-800z M250 400h100v-100h100v100h100v100h-100v100h-100v-100h-100z"},lift:{width:1024,height:1024,path:"M219 310v329q0 7-5 12t-12 5q-8 0-13-5l-164-164q-5-5-5-13t5-13l164-164q5-5 13-5 7 0 12 5t5 12zM1024 749v109q0 7-5 12t-12 5h-987q-7 0-12-5t-5-12v-109q0-7 5-12t12-5h987q7 0 12 5t5 12zM1024 530v109q0 7-5 12t-12 5h-621q-7 0-12-5t-5-12v-109q0-7 5-12t12-5h621q7 0 12 5t5 12zM1024 310v109q0 7-5 12t-12 5h-621q-7 0-12-5t-5-12v-109q0-7 5-12t12-5h621q7 0 12 5t5 12zM1024 91v109q0 7-5 12t-12 5h-987q-7 0-12-5t-5-12v-109q0-7 5-12t12-5h987q7 0 12 5t5 12z"},selectParentNode:{text:"⬚",css:"font-weight: bold"},undo:{width:1024,height:1024,path:"M761 1024c113-206 132-520-313-509v253l-384-384 384-384v248c534-13 594 472 313 775z"},redo:{width:1024,height:1024,path:"M576 248v-248l384 384-384 384v-253c-446-10-427 303-313 509-280-303-221-789 313-775z"},strong:{width:805,height:1024,path:"M317 869q42 18 80 18 214 0 214-191 0-65-23-102-15-25-35-42t-38-26-46-14-48-6-54-1q-41 0-57 5 0 30-0 90t-0 90q0 4-0 38t-0 55 2 47 6 38zM309 442q24 4 62 4 46 0 81-7t62-25 42-51 14-81q0-40-16-70t-45-46-61-24-70-8q-28 0-74 7 0 28 2 86t2 86q0 15-0 45t-0 45q0 26 0 39zM0 950l1-53q8-2 48-9t60-15q4-6 7-15t4-19 3-18 1-21 0-19v-37q0-561-12-585-2-4-12-8t-25-6-28-4-27-2-17-1l-2-47q56-1 194-6t213-5q13 0 39 0t38 0q40 0 78 7t73 24 61 40 42 59 16 78q0 29-9 54t-22 41-36 32-41 25-48 22q88 20 146 76t58 141q0 57-20 102t-53 74-78 48-93 27-100 8q-25 0-75-1t-75-1q-60 0-175 6t-132 6z"},em:{width:585,height:1024,path:"M0 949l9-48q3-1 46-12t63-21q16-20 23-57 0-4 35-165t65-310 29-169v-14q-13-7-31-10t-39-4-33-3l10-58q18 1 68 3t85 4 68 1q27 0 56-1t69-4 56-3q-2 22-10 50-17 5-58 16t-62 19q-4 10-8 24t-5 22-4 26-3 24q-15 84-50 239t-44 203q-1 5-7 33t-11 51-9 47-3 32l0 10q9 2 105 17-1 25-9 56-6 0-18 0t-18 0q-16 0-49-5t-49-5q-78-1-117-1-29 0-81 5t-69 6z"},code:{width:896,height:1024,path:"M608 192l-96 96 224 224-224 224 96 96 288-320-288-320zM288 192l-288 320 288 320 96-96-224-224 224-224-96-96z"},link:{width:951,height:1024,path:"M832 694q0-22-16-38l-118-118q-16-16-38-16-24 0-41 18 1 1 10 10t12 12 8 10 7 14 2 15q0 22-16 38t-38 16q-8 0-15-2t-14-7-10-8-12-12-10-10q-18 17-18 41 0 22 16 38l117 118q15 15 38 15 22 0 38-14l84-83q16-16 16-38zM430 292q0-22-16-38l-117-118q-16-16-38-16-22 0-38 15l-84 83q-16 16-16 38 0 22 16 38l118 118q15 15 38 15 24 0 41-17-1-1-10-10t-12-12-8-10-7-14-2-15q0-22 16-38t38-16q8 0 15 2t14 7 10 8 12 12 10 10q18-17 18-41zM941 694q0 68-48 116l-84 83q-47 47-116 47-69 0-116-48l-117-118q-47-47-47-116 0-70 50-119l-50-50q-49 50-118 50-68 0-116-48l-118-118q-48-48-48-116t48-116l84-83q47-47 116-47 69 0 116 48l117 118q47 47 47 116 0 70-50 119l50 50q49-50 118-50 68 0 116 48l118 118q48 48 48 116z"},bulletList:{width:768,height:896,path:"M0 512h128v-128h-128v128zM0 256h128v-128h-128v128zM0 768h128v-128h-128v128zM256 512h512v-128h-512v128zM256 256h512v-128h-512v128zM256 768h512v-128h-512v128z"},orderedList:{width:768,height:896,path:"M320 512h448v-128h-448v128zM320 768h448v-128h-448v128zM320 128v128h448v-128h-448zM79 384h78v-256h-36l-85 23v50l43-2v185zM189 590c0-36-12-78-96-78-33 0-64 6-83 16l1 66c21-10 42-15 67-15s32 11 32 28c0 26-30 58-110 112v50h192v-67l-91 2c49-30 87-66 87-113l1-1z"},blockquote:{width:640,height:896,path:"M0 448v256h256v-256h-128c0 0 0-128 128-128v-128c0 0-256 0-256 256zM640 320v-128c0 0-256 0-256 256v256h256v-256h-128c0 0 0-128 128-128z"}};const _f=new $f({title:"Join with above block",run:Jo,select:t=>Jo(t),icon:Kf.join});const Hf=new $f({title:"Lift out of enclosing block",run:jo,select:t=>jo(t),icon:Kf.lift});const Gf=new $f({title:"Select parent node",run:Go,select:t=>Go(t),icon:Kf.selectParentNode});let Vf=new $f({title:"Undo last change",run:Eo,enable:t=>Eo(t),icon:Kf.undo});let Xf=new $f({title:"Redo last undone change",run:Do,enable:t=>Do(t),icon:Kf.redo});function Yf(t,e){let r={run(r,i){return ef(t,e.attrs)(r,i)},select(r){return ef(t,e.attrs)(r)}};for(let t in e)r[t]=e[t];return new $f(r)}function Qf(t,e){let r=rf(t,e.attrs);let i={run:r,enable(t){return r(t)},active(r){let{$from:i,to:n,node:s}=r.selection;if(s)return s.hasMarkup(t,e.attrs);return n<=i.end()&&i.parent.hasMarkup(t,e.attrs)}};for(let t in e)i[t]=e[t];return new $f(i)}function Zf(t,e,r){if(r)t.classList.add(e);else t.classList.remove(e)}const tu="ProseMirror-menubar";function eu(){if(typeof navigator=="undefined")return false;let t=navigator.userAgent;return!/Edge\/\d/.test(t)&&/AppleWebKit/.test(t)&&/Mobile\/\w+/.test(t)}function ru(t){return new er({view(e){return new iu(e,t)}})}class iu{constructor(t,e){this.editorView=t;this.options=e;this.spacer=null;this.maxHeight=0;this.widthForMaxHeight=0;this.floating=false;this.scrollHandler=null;this.wrapper=Of("div",{class:tu+"-wrapper"});this.menu=this.wrapper.appendChild(Of("div",{class:tu}));this.menu.className=tu;if(t.dom.parentNode)t.dom.parentNode.replaceChild(this.wrapper,t.dom);this.wrapper.appendChild(t.dom);let{dom:r,update:i}=Wf(this.editorView,this.options.content);this.contentUpdate=i;this.menu.appendChild(r);this.update();if(e.floating&&!eu()){this.updateFloat();let t=lu(this.wrapper);this.scrollHandler=e=>{let r=this.editorView.root;if(!(r.body||r).contains(this.wrapper))t.forEach((t=>t.removeEventListener("scroll",this.scrollHandler)));else this.updateFloat(e.target.getBoundingClientRect?e.target:undefined)};t.forEach((t=>t.addEventListener("scroll",this.scrollHandler)))}}update(){this.contentUpdate(this.editorView.state);if(this.floating){this.updateScrollCursor()}else{if(this.menu.offsetWidth!=this.widthForMaxHeight){this.widthForMaxHeight=this.menu.offsetWidth;this.maxHeight=0}if(this.menu.offsetHeight>this.maxHeight){this.maxHeight=this.menu.offsetHeight;this.menu.style.minHeight=this.maxHeight+"px"}}}updateScrollCursor(){let t=this.editorView.root.getSelection();if(!t.focusNode)return;let e=t.getRangeAt(0).getClientRects();let r=e[nu(t)?0:e.length-1];if(!r)return;let i=this.menu.getBoundingClientRect();if(r.top<i.bottom&&r.bottom>i.top){let t=su(this.wrapper);if(t)t.scrollTop-=i.bottom-r.top}}updateFloat(t){let e=this.wrapper,r=e.getBoundingClientRect(),i=t?Math.max(0,t.getBoundingClientRect().top):0;if(this.floating){if(r.top>=i||r.bottom<this.menu.offsetHeight+10){this.floating=false;this.menu.style.position=this.menu.style.left=this.menu.style.top=this.menu.style.width="";this.menu.style.display="";this.spacer.parentNode.removeChild(this.spacer);this.spacer=null}else{let n=(e.offsetWidth-e.clientWidth)/2;this.menu.style.left=r.left+n+"px";this.menu.style.display=r.top>(this.editorView.dom.ownerDocument.defaultView||window).innerHeight?"none":"";if(t)this.menu.style.top=i+"px"}}else{if(r.top<i&&r.bottom>=this.menu.offsetHeight+10){this.floating=true;let r=this.menu.getBoundingClientRect();this.menu.style.left=r.left+"px";this.menu.style.width=r.width+"px";if(t)this.menu.style.top=i+"px";this.menu.style.position="fixed";this.spacer=Of("div",{class:tu+"-spacer",style:`height: ${r.height}px`});e.insertBefore(this.spacer,this.menu)}}}destroy(){if(this.wrapper.parentNode)this.wrapper.parentNode.replaceChild(this.editorView.dom,this.wrapper)}}function nu(t){if(t.anchorNode==t.focusNode)return t.anchorOffset>t.focusOffset;return t.anchorNode.compareDocumentPosition(t.focusNode)==Node.DOCUMENT_POSITION_FOLLOWING}function su(t){for(let e=t.parentNode;e;e=e.parentNode)if(e.scrollHeight>e.clientHeight)return e}function lu(t){let e=[t.ownerDocument.defaultView||window];for(let r=t.parentNode;r;r=r.parentNode)e.push(r);return e}class ou{constructor(t,e,r={}){this.match=t;this.match=t;this.handler=typeof e=="string"?fu(e):e;this.undoable=r.undoable!==false;this.inCode=r.inCode||false}}function fu(t){return function(e,r,i,n){let s=t;if(r[1]){let t=r[0].lastIndexOf(r[1]);s+=r[0].slice(t+r[1].length);i+=t;let e=i-n;if(e>0){s=r[0].slice(t-e,t)+s;i=n}}return e.tr.insertText(s,i,n)}}const uu=500;function hu({rules:t}){let e=new er({state:{init(){return null},apply(t,e){let r=t.getMeta(this);if(r)return r;return t.selectionSet||t.docChanged?null:e}},props:{handleTextInput(r,i,n,s){return au(r,i,n,s,t,e)},handleDOMEvents:{compositionend:r=>{setTimeout((()=>{let{$cursor:i}=r.state.selection;if(i)au(r,i.pos,i.pos,"",t,e)}))}}},isInputRules:true});return e}function au(t,e,r,i,n,s){if(t.composing)return false;let l=t.state,o=l.doc.resolve(e);let f=o.parent.textBetween(Math.max(0,o.parentOffset-uu),o.parentOffset,null,"")+i;for(let u=0;u<n.length;u++){let h=n[u];if(o.parent.type.spec.code){if(!h.inCode)continue}else if(h.inCode==="only"){continue}let a=h.match.exec(f);let c=a&&h.handler(l,a,e-(a[0].length-i.length),r);if(!c)continue;if(h.undoable)c.setMeta(s,{transform:c,from:e,to:r,text:i});t.dispatch(c);return true}return false}const cu=(t,e)=>{let r=t.plugins;for(let i=0;i<r.length;i++){let n=r[i],s;if(n.spec.isInputRules&&(s=n.getState(t))){if(e){let r=t.tr,i=s.transform;for(let t=i.steps.length-1;t>=0;t--)r.step(i.steps[t].invert(i.docs[t]));if(s.text){let e=r.doc.resolve(s.from).marks();r.replaceWith(s.from,s.to,t.schema.text(s.text,e))}else{r.delete(s.from,s.to)}e(r)}return true}}return false};const du=new ou(/--$/,"—");const pu=new ou(/\.\.\.$/,"…");const mu=new ou(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,"“");const wu=new ou(/"$/,"”");const gu=new ou(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,"‘");const bu=new ou(/'$/,"’");const vu=[mu,wu,gu,bu];function ku(t,e,r=null,i){return new ou(t,((t,n,s,l)=>{let o=r instanceof Function?r(n):r;let f=t.tr.delete(s,l);let u=f.doc.resolve(s),h=u.blockRange(),a=h&&Yt(h,e,o);if(!a)return null;f.wrap(h,a);let c=f.doc.resolve(s-1).nodeBefore;if(c&&c.type==e&&oe(f.doc,s-1)&&(!i||i(n,c)))f.join(s-1);return f}))}function yu(t,e,r=null){return new ou(t,((t,i,n,s)=>{let l=t.doc.resolve(n);let o=r instanceof Function?r(i):r;if(!l.node(-1).canReplaceWith(l.index(-1),l.indexAfter(-1),e))return null;return t.tr.delete(n,s).setBlockType(n,n,e,o)}))}const Mu="ProseMirror-prompt";function xu(t){let e=document.body.appendChild(document.createElement("div"));e.className=Mu;let r=t=>{if(!e.contains(t.target))i()};setTimeout((()=>window.addEventListener("mousedown",r)),50);let i=()=>{window.removeEventListener("mousedown",r);if(e.parentNode)e.parentNode.removeChild(e)};let n=[];for(let e in t.fields)n.push(t.fields[e].render());let s=document.createElement("button");s.type="submit";s.className=Mu+"-submit";s.textContent="OK";let l=document.createElement("button");l.type="button";l.className=Mu+"-cancel";l.textContent="Cancel";l.addEventListener("click",i);let o=e.appendChild(document.createElement("form"));if(t.title)o.appendChild(document.createElement("h5")).textContent=t.title;n.forEach((t=>{o.appendChild(document.createElement("div")).appendChild(t)}));let f=o.appendChild(document.createElement("div"));f.className=Mu+"-buttons";f.appendChild(s);f.appendChild(document.createTextNode(" "));f.appendChild(l);let u=e.getBoundingClientRect();e.style.top=(window.innerHeight-u.height)/2+"px";e.style.left=(window.innerWidth-u.width)/2+"px";let h=()=>{let e=Su(t.fields,n);if(e){i();t.callback(e)}};o.addEventListener("submit",(t=>{t.preventDefault();h()}));o.addEventListener("keydown",(t=>{if(t.keyCode==27){t.preventDefault();i()}else if(t.keyCode==13&&!(t.ctrlKey||t.metaKey||t.shiftKey)){t.preventDefault();h()}else if(t.keyCode==9){window.setTimeout((()=>{if(!e.contains(document.activeElement))i()}),500)}}));let a=o.elements[0];if(a)a.focus()}function Su(t,e){let r=Object.create(null),i=0;for(let n in t){let s=t[n],l=e[i++];let o=s.read(l),f=s.validate(o);if(f){Ou(l,f);return null}r[n]=s.clean(o)}return r}function Ou(t,e){let r=t.parentNode;let i=r.appendChild(document.createElement("div"));i.style.left=t.offsetLeft+t.offsetWidth+2+"px";i.style.top=t.offsetTop-5+"px";i.className="ProseMirror-invalid";i.textContent=e;setTimeout((()=>r.removeChild(i)),1500)}class Eu{constructor(t){this.options=t}read(t){return t.value}validateType(t){return null}validate(t){if(!t&&this.options.required)return"Required field";return this.validateType(t)||(this.options.validate?this.options.validate(t):null)}clean(t){return this.options.clean?this.options.clean(t):t}}class Du extends Eu{render(){let t=document.createElement("input");t.type="text";t.placeholder=this.options.label;t.value=this.options.value||"";t.autocomplete="off";return t}}function Nu(t,e){let r=t.selection.$from;for(let t=r.depth;t>=0;t--){let i=r.index(t);if(r.node(t).canReplaceWith(i,i,e))return true}return false}function Ru(t){return new $f({title:"Insert image",label:"Image",enable(e){return Nu(e,t)},run(e,r,i){let{from:n,to:s}=e.selection,l=null;if(e.selection instanceof Be&&e.selection.node.type==t)l=e.selection.node.attrs;xu({title:"Insert image",fields:{src:new Du({label:"Location",required:true,value:l&&l.src}),title:new Du({label:"Title",value:l&&l.title}),alt:new Du({label:"Description",value:l?l.alt:e.doc.textBetween(n,s," ")})},callback(e){i.dispatch(i.state.tr.replaceSelectionWith(t.createAndFill(e)));i.focus()}})}})}function Cu(t,e){let r={label:e.title,run:t};for(let t in e)r[t]=e[t];if(!e.enable&&!e.select)r[e.enable?"enable":"select"]=e=>t(e);return new $f(r)}function Pu(t,e){let{from:r,$from:i,to:n,empty:s}=t.selection;if(s)return!!e.isInSet(t.storedMarks||i.marks());else return t.doc.rangeHasMark(r,n,e)}function qu(t,e){let r={active(e){return Pu(e,t)}};for(let t in e)r[t]=e[t];return Cu(sf(t),r)}function Tu(t){return new $f({title:"Add or remove link",icon:Kf.link,active(e){return Pu(e,t)},enable(t){return!t.selection.empty},run(e,r,i){if(Pu(e,t)){sf(t)(e,r);return true}xu({title:"Create a link",fields:{href:new Du({label:"Link target",required:true}),title:new Du({label:"Title"})},callback(e){sf(t,e)(i.state,i.dispatch);i.focus()}})}})}function $u(t,e){return Cu(Jl(t,e.attrs),e)}function Au(t){let e={};let r;if(r=t.marks.strong)e.toggleStrong=qu(r,{title:"Toggle strong style",icon:Kf.strong});if(r=t.marks.em)e.toggleEm=qu(r,{title:"Toggle emphasis",icon:Kf.em});if(r=t.marks.code)e.toggleCode=qu(r,{title:"Toggle code font",icon:Kf.code});if(r=t.marks.link)e.toggleLink=Tu(r);let i;if(i=t.nodes.image)e.insertImage=Ru(i);if(i=t.nodes.bullet_list)e.wrapBulletList=$u(i,{title:"Wrap in bullet list",icon:Kf.bulletList});if(i=t.nodes.ordered_list)e.wrapOrderedList=$u(i,{title:"Wrap in ordered list",icon:Kf.orderedList});if(i=t.nodes.blockquote)e.wrapBlockQuote=Yf(i,{title:"Wrap in block quote",icon:Kf.blockquote});if(i=t.nodes.paragraph)e.makeParagraph=Qf(i,{title:"Change to paragraph",label:"Plain"});if(i=t.nodes.code_block)e.makeCodeBlock=Qf(i,{title:"Change to code block",label:"Code"});if(i=t.nodes.heading)for(let t=1;t<=10;t++)e["makeHead"+t]=Qf(i,{title:"Change to heading "+t,label:"Level "+t,attrs:{level:t}});if(i=t.nodes.horizontal_rule){let t=i;e.insertHorizontalRule=new $f({title:"Insert horizontal rule",label:"Horizontal rule",enable(e){return Nu(e,t)},run(e,r){r(e.tr.replaceSelectionWith(t.create()))}})}let n=t=>t.filter((t=>t));e.insertMenu=new Bf(n([e.insertImage,e.insertHorizontalRule]),{label:"Insert"});e.typeMenu=new Bf(n([e.makeParagraph,e.makeCodeBlock,e.makeHead1&&new Lf(n([e.makeHead1,e.makeHead2,e.makeHead3,e.makeHead4,e.makeHead5,e.makeHead6]),{label:"Heading"})]),{label:"Type..."});e.inlineMenu=[n([e.toggleStrong,e.toggleEm,e.toggleCode,e.toggleLink])];e.blockMenu=[n([e.wrapBulletList,e.wrapOrderedList,e.wrapBlockQuote,_f,Hf,Gf])];e.fullMenu=e.inlineMenu.concat([[e.insertMenu,e.typeMenu]],[[Vf,Xf]],e.blockMenu);return e}const Iu=typeof navigator!="undefined"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):false;function zu(t,e){let r={},i;function n(t,i){if(e){let r=e[t];if(r===false)return;if(r)t=r}r[t]=i}n("Mod-z",Eo);n("Shift-Mod-z",Do);n("Backspace",cu);if(!Iu)n("Mod-y",Do);n("Alt-ArrowUp",Jo);n("Alt-ArrowDown",Bo);n("Mod-BracketLeft",jo);n("Escape",Go);if(i=t.marks.strong){n("Mod-b",sf(i));n("Mod-B",sf(i))}if(i=t.marks.em){n("Mod-i",sf(i));n("Mod-I",sf(i))}if(i=t.marks.code)n("Mod-`",sf(i));if(i=t.nodes.bullet_list)n("Shift-Ctrl-8",Jl(i));if(i=t.nodes.ordered_list)n("Shift-Ctrl-9",Jl(i));if(i=t.nodes.blockquote)n("Ctrl->",ef(i));if(i=t.nodes.hard_break){let t=i,e=lf(Wo,((e,r)=>{if(r)r(e.tr.replaceSelectionWith(t.create()).scrollIntoView());return true}));n("Mod-Enter",e);n("Shift-Enter",e);if(Iu)n("Ctrl-Enter",e)}if(i=t.nodes.list_item){n("Enter",jl(i));n("Mod-[",Fl(i));n("Mod-]",Ul(i))}if(i=t.nodes.paragraph)n("Shift-Ctrl-0",rf(i));if(i=t.nodes.code_block)n("Shift-Ctrl-\\",rf(i));if(i=t.nodes.heading)for(let t=1;t<=6;t++)n("Shift-Ctrl-"+t,rf(i,{level:t}));if(i=t.nodes.horizontal_rule){let t=i;n("Mod-_",((e,r)=>{if(r)r(e.tr.replaceSelectionWith(t.create()).scrollIntoView());return true}))}return r}function Ju(t){return ku(/^\s*>\s$/,t)}function Bu(t){return ku(/^(\d+)\.\s$/,t,(t=>({order:+t[1]})),((t,e)=>e.childCount+e.attrs.order==+t[1]))}function ju(t){return ku(/^\s*([-+*])\s$/,t)}function Fu(t){return yu(/^```$/,t)}function Lu(t,e){return yu(new RegExp("^(#{1,"+e+"})\\s$"),t,(t=>({level:t[1].length})))}function Wu(t){let e=vu.concat(pu,du),r;if(r=t.nodes.blockquote)e.push(Ju(r));if(r=t.nodes.ordered_list)e.push(Bu(r));if(r=t.nodes.bullet_list)e.push(ju(r));if(r=t.nodes.code_block)e.push(Fu(r));if(r=t.nodes.heading)e.push(Lu(r,6));return hu({rules:e})}function Uu(t){let e=[Wu(t.schema),ro(zu(t.schema,t.mapKeys)),ro(cf),df(),vf()];if(t.menuBar!==false)e.push(ru({floating:t.floatingMenu!==false,content:t.menuContent||Au(t.schema).fullMenu}));if(t.history!==false)e.push(Oo());return e.concat(new er({props:{attributes:{class:"ProseMirror-example-setup-style"}}}))}const Ku=t=>{const e=Au(t);const{inlineMenu:r,insertHorizontalRule:i}=e;const n=_u(e.typeMenu);const s=new $f(Object.assign(Object.assign({},i.spec),{title:"hr",label:"hr"}));const l=e.fullMenu[2];const o=Hu(e.blockMenu);return[r[0],[s],...n,l,o]};const _u=t=>{const e=new Bf(t.content[2].content,{label:"H"});return[[t.content[0],t.content[1]],[e]]};const Hu=t=>[...t[0].slice(0,5)];const Gu={strong:"Toggle strong style",emphasis:"Toggle emphasis",code:"Toggle code font",link:"Add or remove link","horizontal rule":"hr",paragraph:"Change to paragraph","code block":"Change to code block","heading 1":"Change to heading 1","heading 2":"Change to heading 2","heading 3":"Change to heading 3","heading 4":"Change to heading 4","heading 5":"Change to heading 5","heading 6":"Change to heading 6",undo:"Undo last change",redo:"Redo last undone change","bullet list":"Wrap in bullet list","ordered list":"Wrap in ordered list","block quote":"Wrap in block quote","join above":"Join with above block","lift out":"Lift out of enclosing block"};const Vu=["strong","emphasis","link","heading 1","heading 2","heading 3","heading 4","heading 5","heading 6","block quote","bullet list","ordered list"];const Xu=(t,e)=>{let r=Vu.map((t=>Gu[t]));if(e!==undefined){r=r.concat(e.map((t=>Gu[t])))}return t.filter((t=>{if(Qu(t)){return Object.values(r).includes(t.spec.title)}else if(Zu(t)){return true}return false})).filter(Boolean).map(Yu(e))};const Yu=t=>e=>{if(Zu(e)){return new Bf(Xu(e.content,t),{label:e.label})}return e};const Qu=t=>t.spec!==undefined;const Zu=t=>t.content!==undefined;const th='@charset "UTF-8";:host(limel-prosemirror-adapter){isolation:isolate;display:block}*{box-sizing:border-box}.ProseMirror-menubar-wrapper{display:grid;grid-template-rows:auto 1fr}.ProseMirror-textblock-dropdown{min-width:3em}.ProseMirror-tooltip .ProseMirror-menu{width:-webkit-fit-content;width:fit-content;white-space:pre}.ProseMirror{position:relative;word-wrap:break-word;white-space:pre-wrap;white-space:break-spaces;-webkit-font-variant-ligatures:none;font-variant-ligatures:none;font-feature-settings:"liga" 0;padding-top:0.75rem}.ProseMirror [draggable][contenteditable=false]{user-select:text}.ProseMirror:focus-visible{outline:none}.ProseMirror-hideselection{caret-color:transparent}.ProseMirror-hideselection *::selection{background:transparent}.ProseMirror-hideselection *::-moz-selection{background:transparent}.ProseMirror-selectednode{outline:0.125rem solid rgb(var(--color-sky-light))}li.ProseMirror-selectednode{outline:none}li.ProseMirror-selectednode:after{content:"";position:absolute;left:-2rem;right:-0.125rem;top:-0.125rem;bottom:-0.125rem;border:0.125rem solid rgb(var(--color-sky-light));pointer-events:none}img.ProseMirror-separator{display:inline !important;border:none !important;margin:0 !important}:host{--mdc-theme-primary:var(\n --lime-primary-color,\n rgb(var(--color-teal-default))\n );--mdc-theme-secondary:var(\n --lime-secondary-color,\n rgb(var(--contrast-1100))\n );--mdc-theme-on-primary:var(\n --lime-on-primary-color,\n rgb(var(--contrast-100))\n );--mdc-theme-on-secondary:var(\n --lime-on-secondary-color,\n rgb(var(--contrast-100))\n );--mdc-theme-text-disabled-on-background:var(\n --lime-text-disabled-on-background-color,\n rgba(var(--contrast-1700), 0.38)\n );--mdc-theme-text-primary-on-background:var(\n --lime-text-primary-on-background-color,\n rgba(var(--contrast-1700), 0.87)\n );--mdc-theme-text-secondary-on-background:var(\n --lime-text-secondary-on-background-color,\n rgba(var(--contrast-1700), 0.54)\n );--mdc-theme-error:var(\n --lime-error-background-color,\n rgb(var(--color-red-dark))\n );--lime-error-text-color:rgb(var(--color-red-darker));--mdc-theme-surface:var(\n --lime-surface-background-color,\n rgb(var(--contrast-100))\n );--mdc-theme-on-surface:var(\n --lime-on-surface-color,\n rgb(var(--contrast-1500))\n )}div#editor .ProseMirror-menubar{position:sticky !important;z-index:1;top:0;margin-left:-0.75rem;margin-right:-0.75rem;background-color:rgba(var(--contrast-200), 0.5);backdrop-filter:blur(0.25rem);-webkit-backdrop-filter:blur(0.25rem)}div#editor .ProseMirror-menubar[style*="position: fixed"]{box-shadow:0 0.25rem 0.5rem -0.5rem rgb(var(--color-black), 0.8)}div#editor .ProseMirror-menubar-spacer{display:none}.ProseMirror-menubar{position:relative;z-index:1;display:flex;flex-wrap:wrap;gap:0.25rem;align-items:center;padding:0.125rem;border-top-left-radius:0.5rem;border-top-right-radius:0.5rem}.ProseMirror-menuitem{position:relative;flex-shrink:0;display:flex;align-items:center;justify-content:center;white-space:nowrap;line-height:1;height:1.5rem;min-width:1.5rem;border-radius:0.25rem;color:rgb(var(--contrast-1100));font-size:0.8125rem}.ProseMirror-menuitem:not(:has(.ProseMirror-menu-disabled)){transition:color 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease, transform 0.1s ease-out;cursor:pointer;color:var(--mdc-theme-on-surface);background-color:transparent}.ProseMirror-menuitem:not(:has(.ProseMirror-menu-disabled)):hover{color:var(--mdc-theme-on-surface);background-color:var(--lime-elevated-surface-background-color);box-shadow:var(--button-shadow-hovered)}.ProseMirror-menuitem:not(:has(.ProseMirror-menu-disabled)):active{box-shadow:var(--button-shadow-pressed);transform:translate3d(0, 0.08rem, 0)}.ProseMirror-menuitem:has(.ProseMirror-menu-active){box-shadow:var(--button-shadow-inset);color:var(--mdc-theme-primary)}.ProseMirror-menuitem:has(.ProseMirror-menu-active) svg{color:var(--mdc-theme-primary)}.ProseMirror-menuitem:has(.ProseMirror-menu-dropdown-menu){box-shadow:var(--button-shadow-inset)}.ProseMirror-menuitem svg{fill:currentColor;height:1rem;color:rgb(var(--contrast-1100))}.ProseMirror-menuseparator{border-radius:1rem;background-color:rgb(var(--contrast-600));width:0.125rem;height:1rem}.ProseMirror-menu-dropdown{position:relative;display:flex;align-items:center;gap:0.5rem;padding:0 0.5rem}.ProseMirror-menu-dropdown:after{content:"";border-left:0.25rem solid transparent;border-right:0.25rem solid transparent;border-top:0.25rem solid currentColor}.ProseMirror-menu-dropdown-menu,.ProseMirror-menu-submenu{box-shadow:0px 5px 5px -3px rgba(0, 0, 0, 0.2), 0px 8px 10px 1px rgba(0, 0, 0, 0.14), 0px 3px 14px 2px rgba(0, 0, 0, 0.12)}.ProseMirror-menu-dropdown-menu{position:absolute;top:100%;background:rgb(var(--contrast-100));border-radius:0.25rem;padding:0.125rem}.ProseMirror-menu-submenu{position:absolute;background:rgb(var(--contrast-100));border-radius:0.25rem;padding:0.125rem;display:none;min-width:4em;left:100%;top:-0.75rem}.ProseMirror-menu-dropdown-item{transition:background-color 0.2s ease;cursor:pointer;border-radius:0.375rem;min-height:2.5rem;display:flex;align-items:center;width:100%}.ProseMirror-menu-dropdown-item>div{padding:0 1rem;width:100%}.ProseMirror-menu-dropdown-item:not(:has(.ProseMirror-menu-disabled)):hover{background-color:rgb(var(--contrast-300))}.ProseMirror-menu-submenu-wrap{position:relative;margin-right:-0.25rem}.ProseMirror-menu-submenu-wrap:hover .ProseMirror-menu-submenu{display:block}.ProseMirror-menu-submenu-label{position:relative;display:flex;align-items:center;justify-content:space-between;gap:0.5rem}.ProseMirror-menu-submenu-label:after{content:"";border-top:0.25rem solid transparent;border-bottom:0.25rem solid transparent;border-left:0.25rem solid currentColor}.ProseMirror-menu-disabled{opacity:0.3;cursor:default}.ProseMirror-menu-submenu-wrap-active .ProseMirror-menu-submenu{display:block}blockquote{position:relative;font-weight:100;font-size:0.875rem;max-width:100%;line-height:1.4;margin:0;padding:0.5rem 1.25rem;border-radius:0.05rem 0.75rem;background-color:rgb(var(--contrast-300))}blockquote:before,blockquote:after{position:absolute;font-size:2.75rem;opacity:0.4}blockquote:before{content:"“";left:0;top:-0.75rem}blockquote:after{content:"”";right:0;bottom:-2rem}:host(limel-markdown.truncate-paragraphs) p{overflow:hidden;white-space:nowrap;text-overflow:ellipsis}p,li{font-size:0.875rem;word-break:break-word;hyphens:auto;-webkit-hyphens:auto}a{word-break:break-all}p{margin-top:0;margin-bottom:0.5rem}p:only-child{margin-bottom:0}a{transition:color 0.2s ease;color:var(--markdown-hyperlink-color, rgb(var(--color-blue-dark)));text-decoration:none}a:hover{color:var(--markdown-hyperlink-color--hovered, rgb(var(--color-blue-default)))}hr{margin:1.75rem 0 2rem 0;border-width:0;border-top:1px solid rgb(var(--contrast-500))}dl{display:grid;grid-template-columns:1fr 2fr;grid-template-rows:1fr;margin-bottom:2rem;border:1px solid rgb(var(--contrast-400));border-radius:0.375rem;background-color:rgb(var(--contrast-200))}dl dt,dl dd{padding:0.375rem 0.5rem;font-size:0.875rem;margin:0}dl dt:nth-of-type(even),dl dd:nth-of-type(even){background-color:rgb(var(--contrast-300))}dl dt:first-child{border-top-left-radius:0.375rem}dl dt:last-child{border-bottom-left-radius:0.375rem}dl dd:first-child{border-top-right-radius:0.375rem}dl dd:last-child{border-bottom-right-radius:0.375rem}h1{font-size:1.5rem}h2{font-size:1.25rem}h3{font-size:1.125rem}h4{font-size:1rem}h5{font-size:0.875rem}h6{font-size:0.75rem}h1,h2{margin-top:0.5rem;margin-bottom:0.5rem;letter-spacing:-0.03125rem;font-weight:500}h3,h4{margin-top:0.75rem;margin-bottom:0.25rem;font-weight:600}h5,h6{margin-top:0.5rem;margin-bottom:0.125rem;font-weight:600}h1,h2,h3,h4,h5,h6{word-break:break-word;hyphens:auto;-webkit-hyphens:auto}:not([contenteditable=true]) h1,:not([contenteditable=true]) h2,:not([contenteditable=true]) h3,:not([contenteditable=true]) h4,:not([contenteditable=true]) h5,:not([contenteditable=true]) h6{text-wrap:balance}[contenteditable=true] h1,[contenteditable=true] h2,[contenteditable=true] h3,[contenteditable=true] h4,[contenteditable=true] h5,[contenteditable=true] h6{text-wrap:initial}ul{list-style:none}ul li{position:relative;margin-left:0.75rem}ul li:before{content:"";position:absolute;left:-0.5rem;top:0.5rem;width:0.25rem;height:0.25rem;border-radius:50%;background-color:rgb(var(--contrast-700));display:block}ol{margin-top:0.25rem;padding-left:1rem}ul{margin-top:0.25rem;padding-left:0}ul ul,ul ol,ol ol,ol ul{margin-left:0}li{margin-bottom:0.25rem}code{font-family:ui-monospace, "Cascadia Code", "Source Code Pro", Menlo, Consolas, "DejaVu Sans Mono", monospace;font-size:0.8125rem;letter-spacing:-0.0125rem;color:rgb(var(--contrast-1300));-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none;display:inline-block;border-radius:0.25rem;padding:0.03125rem 0.25rem;background-color:rgb(var(--contrast-600))}pre>code{display:block;margin:0.5rem 0;padding:0.5rem 0.75rem;overflow:auto;white-space:pre-wrap}:host(limel-markdown:not(.no-table-styles)) table{table-layout:auto;min-width:100%;border-collapse:collapse;border-spacing:0;background:transparent;margin:0.75rem 0;border:1px solid rgb(var(--contrast-400))}:host(limel-markdown:not(.no-table-styles)) th,:host(limel-markdown:not(.no-table-styles)) td{text-align:left;vertical-align:top;transition:background-color 0.2s ease;font-size:0.875rem}:host(limel-markdown:not(.no-table-styles)) td{padding:0.5rem 0.375rem 0.75rem 0.375rem}:host(limel-markdown:not(.no-table-styles)) tr th{background-color:rgb(var(--contrast-400));padding:0.25rem 0.375rem;font-weight:normal}:host(limel-markdown:not(.no-table-styles)) tr th:only-child{text-align:center}:host(limel-markdown:not(.no-table-styles)) tbody tr:nth-child(odd) td{background-color:rgb(var(--contrast-200))}:host(limel-markdown:not(.no-table-styles)) tbody tr:hover td{background-color:rgb(var(--contrast-300))}';const eh=class{constructor(r){t(this,r);this.change=e(this,"change",7);this.getHTML=()=>{if(this.view.dom.textContent===""){return""}else{return this.view.dom.innerHTML}};this.value=undefined;this.view=undefined}componentWillLoad(){}render(){return r("div",{id:"editor"})}componentDidLoad(){const t=new et({nodes:zl(Rl.spec.nodes,"paragraph block*","block"),marks:Rl.spec.marks});const e=Ku(t).map((t=>Xu(t,undefined))).filter((t=>t.length));this.view=new al(this.host.shadowRoot.querySelector("#editor"),{state:Ze.create({doc:it.fromSchema(t).parse(this.host.shadowRoot.querySelector("#editor")),plugins:Uu({schema:t,menuContent:e})}),dispatchTransaction:t=>{const e=this.view.state.apply(t);this.view.updateState(e);this.change.emit(this.getHTML())}});if(this.value){this.view.dom.innerHTML=this.value}}get host(){return i(this)}};eh.style=th;export{eh as limel_prosemirror_adapter};
2
- //# sourceMappingURL=p-60317f5c.entry.js.map
1
+ import{r as t,c as e,h as r,g as i}from"./p-443111b3.js";function n(t){this.content=t}n.prototype={constructor:n,find:function(t){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===t)return e;return-1},get:function(t){var e=this.find(t);return e==-1?undefined:this.content[e+1]},update:function(t,e,r){var i=r&&r!=t?this.remove(r):this;var s=i.find(t),l=i.content.slice();if(s==-1){l.push(r||t,e)}else{l[s+1]=e;if(r)l[s]=r}return new n(l)},remove:function(t){var e=this.find(t);if(e==-1)return this;var r=this.content.slice();r.splice(e,2);return new n(r)},addToStart:function(t,e){return new n([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var r=this.remove(t).content.slice();r.push(t,e);return new n(r)},addBefore:function(t,e,r){var i=this.remove(e),s=i.content.slice();var l=i.find(t);s.splice(l==-1?s.length:l,0,e,r);return new n(s)},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=n.from(t);if(!t.size)return this;return new n(t.content.concat(this.subtract(t).content))},append:function(t){t=n.from(t);if(!t.size)return this;return new n(this.subtract(t).content.concat(t.content))},subtract:function(t){var e=this;t=n.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}};n.from=function(t){if(t instanceof n)return t;var e=[];if(t)for(var r in t)e.push(r,t[r]);return new n(e)};function s(t,e,r){for(let i=0;;i++){if(i==t.childCount||i==e.childCount)return t.childCount==e.childCount?null:r;let n=t.child(i),l=e.child(i);if(n==l){r+=n.nodeSize;continue}if(!n.sameMarkup(l))return r;if(n.isText&&n.text!=l.text){for(let t=0;n.text[t]==l.text[t];t++)r++;return r}if(n.content.size||l.content.size){let t=s(n.content,l.content,r+1);if(t!=null)return t}r+=n.nodeSize}}function l(t,e,r,i){for(let n=t.childCount,s=e.childCount;;){if(n==0||s==0)return n==s?null:{a:r,b:i};let o=t.child(--n),f=e.child(--s),u=o.nodeSize;if(o==f){r-=u;i-=u;continue}if(!o.sameMarkup(f))return{a:r,b:i};if(o.isText&&o.text!=f.text){let t=0,e=Math.min(o.text.length,f.text.length);while(t<e&&o.text[o.text.length-t-1]==f.text[f.text.length-t-1]){t++;r--;i--}return{a:r,b:i}}if(o.content.size||f.content.size){let t=l(o.content,f.content,r-1,i-1);if(t)return t}r-=u;i-=u}}class o{constructor(t,e){this.content=t;this.size=e||0;if(e==null)for(let e=0;e<t.length;e++)this.size+=t[e].nodeSize}nodesBetween(t,e,r,i=0,n){for(let s=0,l=0;l<e;s++){let o=this.content[s],f=l+o.nodeSize;if(f>t&&r(o,i+l,n||null,s)!==false&&o.content.size){let n=l+1;o.nodesBetween(Math.max(0,t-n),Math.min(o.content.size,e-n),r,i+n)}l=f}}descendants(t){this.nodesBetween(0,this.size,t)}textBetween(t,e,r,i){let n="",s=true;this.nodesBetween(t,e,((l,o)=>{let f=l.isText?l.text.slice(Math.max(t,o)-o,e-o):!l.isLeaf?"":i?typeof i==="function"?i(l):i:l.type.spec.leafText?l.type.spec.leafText(l):"";if(l.isBlock&&(l.isLeaf&&f||l.isTextblock)&&r){if(s)s=false;else n+=r}n+=f}),0);return n}append(t){if(!t.size)return this;if(!this.size)return t;let e=this.lastChild,r=t.firstChild,i=this.content.slice(),n=0;if(e.isText&&e.sameMarkup(r)){i[i.length-1]=e.withText(e.text+r.text);n=1}for(;n<t.content.length;n++)i.push(t.content[n]);return new o(i,this.size+t.size)}cut(t,e=this.size){if(t==0&&e==this.size)return this;let r=[],i=0;if(e>t)for(let n=0,s=0;s<e;n++){let l=this.content[n],o=s+l.nodeSize;if(o>t){if(s<t||o>e){if(l.isText)l=l.cut(Math.max(0,t-s),Math.min(l.text.length,e-s));else l=l.cut(Math.max(0,t-s-1),Math.min(l.content.size,e-s-1))}r.push(l);i+=l.nodeSize}s=o}return new o(r,i)}cutByIndex(t,e){if(t==e)return o.empty;if(t==0&&e==this.content.length)return this;return new o(this.content.slice(t,e))}replaceChild(t,e){let r=this.content[t];if(r==e)return this;let i=this.content.slice();let n=this.size+e.nodeSize-r.nodeSize;i[t]=e;return new o(i,n)}addToStart(t){return new o([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new o(this.content.concat(t),this.size+t.nodeSize)}eq(t){if(this.content.length!=t.content.length)return false;for(let e=0;e<this.content.length;e++)if(!this.content[e].eq(t.content[e]))return false;return true}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(t){let e=this.content[t];if(!e)throw new RangeError("Index "+t+" out of range for "+this);return e}maybeChild(t){return this.content[t]||null}forEach(t){for(let e=0,r=0;e<this.content.length;e++){let i=this.content[e];t(i,r,e);r+=i.nodeSize}}findDiffStart(t,e=0){return s(this,t,e)}findDiffEnd(t,e=this.size,r=t.size){return l(this,t,e,r)}findIndex(t,e=-1){if(t==0)return u(0,t);if(t==this.size)return u(this.content.length,t);if(t>this.size||t<0)throw new RangeError(`Position ${t} outside of fragment (${this})`);for(let r=0,i=0;;r++){let n=this.child(r),s=i+n.nodeSize;if(s>=t){if(s==t||e>0)return u(r+1,s);return u(r,i)}i=s}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map((t=>t.toJSON())):null}static fromJSON(t,e){if(!e)return o.empty;if(!Array.isArray(e))throw new RangeError("Invalid input for Fragment.fromJSON");return new o(e.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return o.empty;let e,r=0;for(let i=0;i<t.length;i++){let n=t[i];r+=n.nodeSize;if(i&&n.isText&&t[i-1].sameMarkup(n)){if(!e)e=t.slice(0,i);e[e.length-1]=n.withText(e[e.length-1].text+n.text)}else if(e){e.push(n)}}return new o(e||t,r)}static from(t){if(!t)return o.empty;if(t instanceof o)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new o([t],t.nodeSize);throw new RangeError("Can not convert "+t+" to a Fragment"+(t.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}o.empty=new o([],0);const f={index:0,offset:0};function u(t,e){f.index=t;f.offset=e;return f}function h(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(!h(t[r],e[r]))return false}else{for(let r in t)if(!(r in e)||!h(t[r],e[r]))return false;for(let r in e)if(!(r in t))return false}return true}class a{constructor(t,e){this.type=t;this.attrs=e}addToSet(t){let e,r=false;for(let i=0;i<t.length;i++){let n=t[i];if(this.eq(n))return t;if(this.type.excludes(n.type)){if(!e)e=t.slice(0,i)}else if(n.type.excludes(this.type)){return t}else{if(!r&&n.type.rank>this.type.rank){if(!e)e=t.slice(0,i);e.push(this);r=true}if(e)e.push(n)}}if(!e)e=t.slice();if(!r)e.push(this);return e}removeFromSet(t){for(let e=0;e<t.length;e++)if(this.eq(t[e]))return t.slice(0,e).concat(t.slice(e+1));return t}isInSet(t){for(let e=0;e<t.length;e++)if(this.eq(t[e]))return true;return false}eq(t){return this==t||this.type==t.type&&h(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`);return r.create(e.attrs)}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 a.none;if(t instanceof a)return[t];let e=t.slice();e.sort(((t,e)=>t.type.rank-e.type.rank));return e}}a.none=[];class c extends Error{}class d{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=m(this.content,t+this.openStart,e);return r&&new d(r,this.openStart,this.openEnd)}removeBetween(t,e){return new d(p(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 d.empty;let r=e.openStart||0,i=e.openEnd||0;if(typeof r!="number"||typeof i!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new d(o.fromJSON(t,e.content),r,i)}static maxOpen(t,e=true){let r=0,i=0;for(let i=t.firstChild;i&&!i.isLeaf&&(e||!i.type.spec.isolating);i=i.firstChild)r++;for(let r=t.lastChild;r&&!r.isLeaf&&(e||!r.type.spec.isolating);r=r.lastChild)i++;return new d(t,r,i)}}d.empty=new d(o.empty,0,0);function p(t,e,r){let{index:i,offset:n}=t.findIndex(e),s=t.maybeChild(i);let{index:l,offset:o}=t.findIndex(r);if(n==e||s.isText){if(o!=r&&!t.child(l).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(r))}if(i!=l)throw new RangeError("Removing non-flat range");return t.replaceChild(i,s.copy(p(s.content,e-n-1,r-n-1)))}function m(t,e,r,i){let{index:n,offset:s}=t.findIndex(e),l=t.maybeChild(n);if(s==e||l.isText){if(i&&!i.canReplace(n,n,r))return null;return t.cut(0,e).append(r).append(t.cut(e))}let o=m(l.content,e-s-1,r);return o&&t.replaceChild(n,l.copy(o))}function w(t,e,r){if(r.openStart>t.depth)throw new c("Inserted content deeper than insertion position");if(t.depth-r.openStart!=e.depth-r.openEnd)throw new c("Inconsistent open depths");return g(t,e,r,0)}function g(t,e,r,i){let n=t.index(i),s=t.node(i);if(n==e.index(i)&&i<t.depth-r.openStart){let l=g(t,e,r,i+1);return s.copy(s.content.replaceChild(n,l))}else if(!r.content.size){return M(s,S(t,e,i))}else if(!r.openStart&&!r.openEnd&&t.depth==i&&e.depth==i){let i=t.parent,n=i.content;return M(i,n.cut(0,t.parentOffset).append(r.content).append(n.cut(e.parentOffset)))}else{let{start:n,end:l}=O(r,t);return M(s,x(t,n,l,e,i))}}function b(t,e){if(!e.type.compatibleContent(t.type))throw new c("Cannot join "+e.type.name+" onto "+t.type.name)}function v(t,e,r){let i=t.node(r);b(i,e.node(r));return i}function y(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 k(t,e,r,i){let n=(e||t).node(r);let s=0,l=e?e.index(r):n.childCount;if(t){s=t.index(r);if(t.depth>r){s++}else if(t.textOffset){y(t.nodeAfter,i);s++}}for(let t=s;t<l;t++)y(n.child(t),i);if(e&&e.depth==r&&e.textOffset)y(e.nodeBefore,i)}function M(t,e){t.type.checkContent(e);return t.copy(e)}function x(t,e,r,i,n){let s=t.depth>n&&v(t,e,n+1);let l=i.depth>n&&v(r,i,n+1);let f=[];k(null,t,n,f);if(s&&l&&e.index(n)==r.index(n)){b(s,l);y(M(s,x(t,e,r,i,n+1)),f)}else{if(s)y(M(s,S(t,e,n+1)),f);k(e,r,n,f);if(l)y(M(l,S(r,i,n+1)),f)}k(i,null,n,f);return new o(f)}function S(t,e,r){let i=[];k(null,t,r,i);if(t.depth>r){let n=v(t,e,r+1);y(M(n,S(t,e,r+1)),i)}k(e,null,r,i);return new o(i)}function O(t,e){let r=e.depth-t.openStart,i=e.node(r);let n=i.copy(t.content);for(let t=r-1;t>=0;t--)n=e.node(t).copy(o.from(n));return{start:n.resolveNoCache(t.openStart+r),end:n.resolveNoCache(n.content.size-t.openEnd-r)}}class E{constructor(t,e,r){this.pos=t;this.path=e;this.parentOffset=r;this.depth=e.length/3-1}resolveDepth(t){if(t==null)return this.depth;if(t<0)return this.depth+t;return t}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(t){return this.path[this.resolveDepth(t)*3]}index(t){return this.path[this.resolveDepth(t)*3+1]}indexAfter(t){t=this.resolveDepth(t);return this.index(t)+(t==this.depth&&!this.textOffset?0:1)}start(t){t=this.resolveDepth(t);return t==0?0:this.path[t*3-1]+1}end(t){t=this.resolveDepth(t);return this.start(t)+this.node(t).content.size}before(t){t=this.resolveDepth(t);if(!t)throw new RangeError("There is no position before the top-level node");return t==this.depth+1?this.pos:this.path[t*3-1]}after(t){t=this.resolveDepth(t);if(!t)throw new RangeError("There is no position after the top-level node");return t==this.depth+1?this.pos:this.path[t*3-1]+this.path[t*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let t=this.parent,e=this.index(this.depth);if(e==t.childCount)return null;let r=this.pos-this.path[this.path.length-1],i=t.child(e);return r?t.child(e).cut(r):i}get nodeBefore(){let t=this.index(this.depth);let e=this.pos-this.path[this.path.length-1];if(e)return this.parent.child(t).cut(0,e);return t==0?null:this.parent.child(t-1)}posAtIndex(t,e){e=this.resolveDepth(e);let r=this.path[e*3],i=e==0?0:this.path[e*3-1]+1;for(let e=0;e<t;e++)i+=r.child(e).nodeSize;return i}marks(){let t=this.parent,e=this.index();if(t.content.size==0)return a.none;if(this.textOffset)return t.child(e).marks;let r=t.maybeChild(e-1),i=t.maybeChild(e);if(!r){let t=r;r=i;i=t}let n=r.marks;for(var s=0;s<n.length;s++)if(n[s].type.spec.inclusive===false&&(!i||!n[s].isInSet(i.marks)))n=n[s--].removeFromSet(n);return n}marksAcross(t){let e=this.parent.maybeChild(this.index());if(!e||!e.isInline)return null;let r=e.marks,i=t.parent.maybeChild(t.index());for(var n=0;n<r.length;n++)if(r[n].type.spec.inclusive===false&&(!i||!r[n].isInSet(i.marks)))r=r[n--].removeFromSet(r);return r}sharedDepth(t){for(let e=this.depth;e>0;e--)if(this.start(e)<=t&&this.end(e)>=t)return e;return 0}blockRange(t=this,e){if(t.pos<this.pos)return t.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==t.pos?1:0);r>=0;r--)if(t.pos<=this.end(r)&&(!e||e(this.node(r))))return new C(this,t,r);return null}sameParent(t){return this.pos-this.parentOffset==t.pos-t.parentOffset}max(t){return t.pos>this.pos?t:this}min(t){return t.pos<this.pos?t:this}toString(){let t="";for(let e=1;e<=this.depth;e++)t+=(t?"/":"")+this.node(e).type.name+"_"+this.index(e-1);return t+":"+this.parentOffset}static resolve(t,e){if(!(e>=0&&e<=t.content.size))throw new RangeError("Position "+e+" out of range");let r=[];let i=0,n=e;for(let e=t;;){let{index:t,offset:s}=e.content.findIndex(n);let l=n-s;r.push(e,t,i+s);if(!l)break;e=e.child(t);if(e.isText)break;n=l-1;i+=s+1}return new E(e,r,n)}static resolveCached(t,e){for(let r=0;r<D.length;r++){let i=D[r];if(i.pos==e&&i.doc==t)return i}let r=D[N]=E.resolve(t,e);N=(N+1)%R;return r}}let D=[],N=0,R=12;class C{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 q=Object.create(null);class P{constructor(t,e,r,i=a.none){this.type=t;this.attrs=e;this.marks=i;this.content=r||o.empty}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(t){return this.content.child(t)}maybeChild(t){return this.content.maybeChild(t)}forEach(t){this.content.forEach(t)}nodesBetween(t,e,r,i=0){this.content.nodesBetween(t,e,r,i,this)}descendants(t){this.nodesBetween(0,this.content.size,t)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(t,e,r,i){return this.content.textBetween(t,e,r,i)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(t){return this==t||this.sameMarkup(t)&&this.content.eq(t.content)}sameMarkup(t){return this.hasMarkup(t.type,t.attrs,t.marks)}hasMarkup(t,e,r){return this.type==t&&h(this.attrs,e||t.defaultAttrs||q)&&a.sameSet(this.marks,r||a.none)}copy(t=null){if(t==this.content)return this;return new P(this.type,this.attrs,t,this.marks)}mark(t){return t==this.marks?this:new P(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 d.empty;let i=this.resolve(t),n=this.resolve(e);let s=r?0:i.sharedDepth(e);let l=i.start(s),o=i.node(s);let f=o.content.cut(i.pos-l,n.pos-l);return new d(f,i.depth-s,n.depth-s)}replace(t,e,r){return w(this.resolve(t),this.resolve(e),r)}nodeAt(t){for(let e=this;;){let{index:r,offset:i}=e.content.findIndex(t);e=e.maybeChild(r);if(!e)return null;if(i==t||e.isText)return e;t-=i+1}}childAfter(t){let{index:e,offset:r}=this.content.findIndex(t);return{node:this.content.maybeChild(e),index:e,offset:r}}childBefore(t){if(t==0)return{node:null,index:0,offset:0};let{index:e,offset:r}=this.content.findIndex(t);if(r<t)return{node:this.content.child(e),index:e,offset:r};let i=this.content.child(e-1);return{node:i,index:e-1,offset:r-i.nodeSize}}resolve(t){return E.resolveCached(this,t)}resolveNoCache(t){return E.resolve(this,t)}rangeHasMark(t,e,r){let i=false;if(e>t)this.nodesBetween(t,e,(t=>{if(r.isInSet(t.marks))i=true;return!i}));return i}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let t=this.type.name;if(this.content.size)t+="("+this.content.toStringInner()+")";return T(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=o.empty,i=0,n=r.childCount){let s=this.contentMatchAt(t).matchFragment(r,i,n);let l=s&&s.matchFragment(this.content,e);if(!l||!l.validEnd)return false;for(let t=i;t<n;t++)if(!this.type.allowsMarks(r.child(t).marks))return false;return true}canReplaceWith(t,e,r,i){if(i&&!this.type.allowsMarks(i))return false;let n=this.contentMatchAt(t).matchType(r);let s=n&&n.matchFragment(this.content,e);return s?s.validEnd:false}canAppend(t){if(t.content.size)return this.canReplace(this.childCount,this.childCount,t.content);else return this.type.compatibleContent(t.type)}check(){this.type.checkContent(this.content);let t=a.none;for(let e=0;e<this.marks.length;e++)t=this.marks[e].addToSet(t);if(!a.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=null;if(e.marks){if(!Array.isArray(e.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=e.marks.map(t.markFromJSON)}if(e.type=="text"){if(typeof e.text!="string")throw new RangeError("Invalid text node in JSON");return t.text(e.text,r)}let i=o.fromJSON(t,e.content);return t.nodeType(e.type).create(e.attrs,i,r)}}P.prototype.text=undefined;class $ extends P{constructor(t,e,r,i){super(t,e,null,i);if(!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);return T(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 $(this.type,this.attrs,this.text,t)}withText(t){if(t==this.text)return this;return new $(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 T(t,e){for(let r=t.length-1;r>=0;r--)e=t[r].type.name+"("+e+")";return e}class A{constructor(t){this.validEnd=t;this.next=[];this.wrapCache=[]}static parse(t,e){let r=new I(t,e);if(r.next==null)return A.empty;let i=z(r);if(r.next)r.err("Unexpected trailing text");let n=K(_(i));G(n,r);return n}matchType(t){for(let e=0;e<this.next.length;e++)if(this.next[e].type==t)return this.next[e].next;return null}matchFragment(t,e=0,r=t.childCount){let i=this;for(let n=e;i&&n<r;n++)i=i.matchType(t.child(n).type);return i}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let t=0;t<this.next.length;t++){let{type:e}=this.next[t];if(!(e.isText||e.hasRequiredAttrs()))return e}return null}compatible(t){for(let e=0;e<this.next.length;e++)for(let r=0;r<t.next.length;r++)if(this.next[e].type==t.next[r].type)return true;return false}fillBefore(t,e=false,r=0){let i=[this];function n(s,l){let f=s.matchFragment(t,r);if(f&&(!e||f.validEnd))return o.from(l.map((t=>t.createAndFill())));for(let t=0;t<s.next.length;t++){let{type:e,next:r}=s.next[t];if(!(e.isText||e.hasRequiredAttrs())&&i.indexOf(r)==-1){i.push(r);let t=n(r,l.concat(e));if(t)return t}}return null}return n(this,[])}findWrapping(t){for(let e=0;e<this.wrapCache.length;e+=2)if(this.wrapCache[e]==t)return this.wrapCache[e+1];let e=this.computeWrapping(t);this.wrapCache.push(t,e);return e}computeWrapping(t){let e=Object.create(null),r=[{match:this,type:null,via:null}];while(r.length){let i=r.shift(),n=i.match;if(n.matchType(t)){let t=[];for(let e=i;e.type;e=e.via)t.push(e.type);return t.reverse()}for(let t=0;t<n.next.length;t++){let{type:s,next:l}=n.next[t];if(!s.isLeaf&&!s.hasRequiredAttrs()&&!(s.name in e)&&(!i.type||l.validEnd)){r.push({match:s.contentMatch,type:s,via:i});e[s.name]=true}}}return null}get edgeCount(){return this.next.length}edge(t){if(t>=this.next.length)throw new RangeError(`There's no ${t}th edge in this content match`);return this.next[t]}toString(){let t=[];function e(r){t.push(r);for(let i=0;i<r.next.length;i++)if(t.indexOf(r.next[i].next)==-1)e(r.next[i].next)}e(this);return t.map(((e,r)=>{let i=r+(e.validEnd?"*":" ")+" ";for(let r=0;r<e.next.length;r++)i+=(r?", ":"")+e.next[r].type.name+"->"+t.indexOf(e.next[r].next);return i})).join("\n")}}A.empty=new A(true);class I{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 z(t){let e=[];do{e.push(J(t))}while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function J(t){let e=[];do{e.push(B(t))}while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function B(t){let e=W(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=F(t,e);else break}return e}function j(t){if(/\D/.test(t.next))t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);t.pos++;return e}function F(t,e){let r=j(t),i=r;if(t.eat(",")){if(t.next!="}")i=j(t);else i=-1}if(!t.eat("}"))t.err("Unclosed braced range");return{type:"range",min:r,max:i,expr:e}}function L(t,e){let r=t.nodeTypes,i=r[e];if(i)return[i];let n=[];for(let t in r){let i=r[t];if(i.groups.indexOf(e)>-1)n.push(i)}if(n.length==0)t.err("No node type or group '"+e+"' found");return n}function W(t){if(t.eat("(")){let e=z(t);if(!t.eat(")"))t.err("Missing closing paren");return e}else if(!/\W/.test(t.next)){let e=L(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 _(t){let e=[[]];n(s(t,0),r());return e;function r(){return e.push([])-1}function i(t,r,i){let n={term:i,to:r};e[t].push(n);return n}function n(t,e){t.forEach((t=>t.to=e))}function s(t,e){if(t.type=="choice"){return t.exprs.reduce(((t,r)=>t.concat(s(r,e))),[])}else if(t.type=="seq"){for(let i=0;;i++){let l=s(t.exprs[i],e);if(i==t.exprs.length-1)return l;n(l,e=r())}}else if(t.type=="star"){let l=r();i(e,l);n(s(t.expr,l),l);return[i(l)]}else if(t.type=="plus"){let l=r();n(s(t.expr,e),l);n(s(t.expr,l),l);return[i(l)]}else if(t.type=="opt"){return[i(e)].concat(s(t.expr,e))}else if(t.type=="range"){let l=e;for(let e=0;e<t.min;e++){let e=r();n(s(t.expr,l),e);l=e}if(t.max==-1){n(s(t.expr,l),l)}else{for(let e=t.min;e<t.max;e++){let e=r();i(l,e);n(s(t.expr,l),e);l=e}}return[i(l)]}else if(t.type=="name"){return[i(e,undefined,t.value)]}else{throw new Error("Unknown expr type")}}}function U(t,e){return e-t}function H(t,e){let r=[];i(e);return r.sort(U);function i(e){let n=t[e];if(n.length==1&&!n[0].term)return i(n[0].to);r.push(e);for(let t=0;t<n.length;t++){let{term:e,to:s}=n[t];if(!e&&r.indexOf(s)==-1)i(s)}}}function K(t){let e=Object.create(null);return r(H(t,0));function r(i){let n=[];i.forEach((e=>{t[e].forEach((({term:e,to:r})=>{if(!e)return;let i;for(let t=0;t<n.length;t++)if(n[t][0]==e)i=n[t][1];H(t,r).forEach((t=>{if(!i)n.push([e,i=[]]);if(i.indexOf(t)==-1)i.push(t)}))}))}));let s=e[i.join(",")]=new A(i.indexOf(t.length-1)>-1);for(let t=0;t<n.length;t++){let i=n[t][1].sort(U);s.next.push({type:n[t][0],next:e[i.join(",")]||r(i)})}return s}}function G(t,e){for(let r=0,i=[t];r<i.length;r++){let t=i[r],n=!t.validEnd,s=[];for(let e=0;e<t.next.length;e++){let{type:r,next:l}=t.next[e];s.push(r.name);if(n&&!(r.isText||r.hasRequiredAttrs()))n=false;if(i.indexOf(l)==-1)i.push(l)}if(n)e.err("Only non-generatable nodes ("+s.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function V(t){let e=Object.create(null);for(let r in t){let i=t[r];if(!i.hasDefault)return null;e[r]=i.default}return e}function X(t,e){let r=Object.create(null);for(let i in t){let n=e&&e[i];if(n===undefined){let e=t[i];if(e.hasDefault)n=e.default;else throw new RangeError("No value supplied for attribute "+i)}r[i]=n}return r}function Y(t){let e=Object.create(null);if(t)for(let r in t)e[r]=new Z(t[r]);return e}class Q{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=Y(r.attrs);this.defaultAttrs=V(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==A.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let t in this.attrs)if(this.attrs[t].isRequired)return true;return false}compatibleContent(t){return this==t||this.contentMatch.compatible(t.contentMatch)}computeAttrs(t){if(!t&&this.defaultAttrs)return this.defaultAttrs;else return X(this.attrs,t)}create(t=null,e,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new P(this,this.computeAttrs(t),o.from(e),a.setFrom(r))}createChecked(t=null,e,r){e=o.from(e);this.checkContent(e);return new P(this,this.computeAttrs(t),e,a.setFrom(r))}createAndFill(t=null,e,r){t=this.computeAttrs(t);e=o.from(e);if(e.size){let t=this.contentMatch.fillBefore(e);if(!t)return null;e=t.append(e)}let i=this.contentMatch.matchFragment(e);let n=i&&i.fillBefore(o.empty,true);if(!n)return null;return new P(this,t,e.append(n),a.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)}`)}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:a.none}static compile(t,e){let r=Object.create(null);t.forEach(((t,i)=>r[t]=new Q(t,e,i)));let i=e.spec.topNode||"doc";if(!r[i])throw new RangeError("Schema is missing its top node type ('"+i+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let t in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}}class Z{constructor(t){this.hasDefault=Object.prototype.hasOwnProperty.call(t,"default");this.default=t.default}get isRequired(){return!this.hasDefault}}class tt{constructor(t,e,r,i){this.name=t;this.rank=e;this.schema=r;this.spec=i;this.attrs=Y(i.attrs);this.excluded=null;let n=V(this.attrs);this.instance=n?new a(this,n):null}create(t=null){if(!t&&this.instance)return this.instance;return new a(this,X(this.attrs,t))}static compile(t,e){let r=Object.create(null),i=0;t.forEach(((t,n)=>r[t]=new tt(t,i++,e,n)));return r}removeFromSet(t){for(var e=0;e<t.length;e++)if(t[e].type==this){t=t.slice(0,e).concat(t.slice(e+1));e--}return t}isInSet(t){for(let e=0;e<t.length;e++)if(t[e].type==this)return t[e]}excludes(t){return this.excluded.indexOf(t)>-1}}class et{constructor(t){this.cached=Object.create(null);let e=this.spec={};for(let r in t)e[r]=t[r];e.nodes=n.from(t.nodes),e.marks=n.from(t.marks||{}),this.nodes=Q.compile(this.spec.nodes,this);this.marks=tt.compile(this.spec.marks,this);let r=Object.create(null);for(let t in this.nodes){if(t in this.marks)throw new RangeError(t+" can not be both a node and a mark");let e=this.nodes[t],i=e.spec.content||"",n=e.spec.marks;e.contentMatch=r[i]||(r[i]=A.parse(i,this.nodes));e.inlineContent=e.contentMatch.inlineContent;e.markSet=n=="_"?null:n?rt(this,n.split(" ")):n==""||!e.inlineContent?[]:null}for(let t in this.marks){let e=this.marks[t],r=e.spec.excludes;e.excluded=r==null?[e]:r==""?[]:rt(this,r.split(" "))}this.nodeFromJSON=this.nodeFromJSON.bind(this);this.markFromJSON=this.markFromJSON.bind(this);this.topNodeType=this.nodes[this.spec.topNode||"doc"];this.cached.wrappings=Object.create(null)}node(t,e=null,r,i){if(typeof t=="string")t=this.nodeType(t);else if(!(t instanceof Q))throw new RangeError("Invalid node type: "+t);else if(t.schema!=this)throw new RangeError("Node type from different schema used ("+t.name+")");return t.createChecked(e,r,i)}text(t,e){let r=this.nodes.text;return new $(r,r.defaultAttrs,t,a.setFrom(e))}mark(t,e){if(typeof t=="string")t=this.marks[t];return t.create(e)}nodeFromJSON(t){return P.fromJSON(this,t)}markFromJSON(t){return a.fromJSON(this,t)}nodeType(t){let e=this.nodes[t];if(!e)throw new RangeError("Unknown node type: "+t);return e}}function rt(t,e){let r=[];for(let i=0;i<e.length;i++){let n=e[i],s=t.marks[n],l=s;if(s){r.push(s)}else{for(let e in t.marks){let i=t.marks[e];if(n=="_"||i.spec.group&&i.spec.group.split(" ").indexOf(n)>-1)r.push(l=i)}}if(!l)throw new SyntaxError("Unknown mark type: '"+e[i]+"'")}return r}class it{constructor(t,e){this.schema=t;this.rules=e;this.tags=[];this.styles=[];e.forEach((t=>{if(t.tag)this.tags.push(t);else if(t.style)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 ct(this,e,false);r.addAll(t,e.from,e.to);return r.finish()}parseSlice(t,e={}){let r=new ct(this,e,true);r.addAll(t,e.from,e.to);return d.maxOpen(r.finish())}matchTag(t,e,r){for(let i=r?this.tags.indexOf(r)+1:0;i<this.tags.length;i++){let r=this.tags[i];if(pt(t,r.tag)&&(r.namespace===undefined||t.namespaceURI==r.namespace)&&(!r.context||e.matchesContext(r.context))){if(r.getAttrs){let e=r.getAttrs(t);if(e===false)continue;r.attrs=e||undefined}return r}}}matchStyle(t,e,r,i){for(let n=i?this.styles.indexOf(i)+1:0;n<this.styles.length;n++){let i=this.styles[n],s=i.style;if(s.indexOf(t)!=0||i.context&&!r.matchesContext(i.context)||s.length>t.length&&(s.charCodeAt(t.length)!=61||s.slice(t.length+1)!=e))continue;if(i.getAttrs){let t=i.getAttrs(e);if(t===false)continue;i.attrs=t||undefined}return i}}static schemaRules(t){let e=[];function r(t){let r=t.priority==null?50:t.priority,i=0;for(;i<e.length;i++){let t=e[i],n=t.priority==null?50:t.priority;if(n<r)break}e.splice(i,0,t)}for(let e in t.marks){let i=t.marks[e].spec.parseDOM;if(i)i.forEach((t=>{r(t=wt(t));if(!(t.mark||t.ignore||t.clearMark))t.mark=e}))}for(let e in t.nodes){let i=t.nodes[e].spec.parseDOM;if(i)i.forEach((t=>{r(t=wt(t));if(!(t.node||t.ignore||t.mark))t.node=e}))}return e}static fromSchema(t){return t.cached.domParser||(t.cached.domParser=new it(t,it.schemaRules(t)))}}const nt={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 st={head:true,noscript:true,object:true,script:true,style:true,title:true};const lt={ol:true,ul:true};const ot=1,ft=2,ut=4;function ht(t,e,r){if(e!=null)return(e?ot:0)|(e==="full"?ft:0);return t&&t.whitespace=="pre"?ot|ft:r&~ut}class at{constructor(t,e,r,i,n,s,l){this.type=t;this.attrs=e;this.marks=r;this.pendingMarks=i;this.solid=n;this.options=l;this.content=[];this.activeMarks=a.none;this.stashMarks=[];this.match=s||(l&ut?null:t.contentMatch)}findWrapping(t){if(!this.match){if(!this.type)return[];let e=this.type.contentMatch.fillBefore(o.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&ot)){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=o.from(this.content);if(!t&&this.match)e=e.append(this.match.fillBefore(o.empty,true));return this.type?this.type.create(this.attrs,e,this.marks):e}popFromStashMark(t){for(let e=this.stashMarks.length-1;e>=0;e--)if(t.eq(this.stashMarks[e]))return this.stashMarks.splice(e,1)[0]}applyPending(t){for(let e=0,r=this.pendingMarks;e<r.length;e++){let i=r[e];if((this.type?this.type.allowsMarkType(i.type):gt(i.type,t))&&!i.isInSet(this.activeMarks)){this.activeMarks=i.addToSet(this.activeMarks);this.pendingMarks=i.removeFromSet(this.pendingMarks)}}}inlineContext(t){if(this.type)return this.type.inlineContent;if(this.content.length)return this.content[0].isInline;return t.parentNode&&!nt.hasOwnProperty(t.parentNode.nodeName.toLowerCase())}}class ct{constructor(t,e,r){this.parser=t;this.options=e;this.isOpen=r;this.open=0;let i=e.topNode,n;let s=ht(null,e.preserveWhitespace,0)|(r?ut:0);if(i)n=new at(i.type,i.attrs,a.none,a.none,true,e.topMatch||i.type.contentMatch,s);else if(r)n=new at(null,null,a.none,a.none,true,null,s);else n=new at(t.schema.topNodeType,null,a.none,a.none,true,null,s);this.nodes=[n];this.find=e.findPositions;this.needsBlock=false}get top(){return this.nodes[this.open]}addDOM(t){if(t.nodeType==3)this.addTextNode(t);else if(t.nodeType==1)this.addElement(t)}withStyleRules(t,e){let r=t.getAttribute("style");if(!r)return e();let i=this.readStyles(mt(r));if(!i)return;let[n,s]=i,l=this.top;for(let t=0;t<s.length;t++)this.removePendingMark(s[t],l);for(let t=0;t<n.length;t++)this.addPendingMark(n[t]);e();for(let t=0;t<n.length;t++)this.removePendingMark(n[t],l);for(let t=0;t<s.length;t++)this.addPendingMark(s[t])}addTextNode(t){let e=t.nodeValue;let r=this.top;if(r.options&ft||r.inlineContext(t)||/[^ \t\r\n\u000c]/.test(e)){if(!(r.options&ot)){e=e.replace(/[ \t\r\n\u000c]+/g," ");if(/^[ \t\r\n\u000c]/.test(e)&&this.open==this.nodes.length-1){let i=r.content[r.content.length-1];let n=t.previousSibling;if(!i||n&&n.nodeName=="BR"||i.isText&&/[ \t\r\n\u000c]$/.test(i.text))e=e.slice(1)}}else if(!(r.options&ft)){e=e.replace(/\r?\n|\r/g," ")}else{e=e.replace(/\r\n?/g,"\n")}if(e)this.insertNode(this.parser.schema.text(e));this.findInText(t)}else{this.findInside(t)}}addElement(t,e){let r=t.nodeName.toLowerCase(),i;if(lt.hasOwnProperty(r)&&this.parser.normalizeLists)dt(t);let n=this.options.ruleFromNode&&this.options.ruleFromNode(t)||(i=this.parser.matchTag(t,this,e));if(n?n.ignore:st.hasOwnProperty(r)){this.findInside(t);this.ignoreFallback(t)}else if(!n||n.skip||n.closeParent){if(n&&n.closeParent)this.open=Math.max(0,this.open-1);else if(n&&n.skip.nodeType)t=n.skip;let e,i=this.top,s=this.needsBlock;if(nt.hasOwnProperty(r)){if(i.content.length&&i.content[0].isInline&&this.open){this.open--;i=this.top}e=true;if(!i.type)this.needsBlock=true}else if(!t.firstChild){this.leafFallback(t);return}if(n&&n.skip)this.addAll(t);else this.withStyleRules(t,(()=>this.addAll(t)));if(e)this.sync(i);this.needsBlock=s}else{this.withStyleRules(t,(()=>{this.addElementByRule(t,n,n.consuming===false?i:undefined)}))}}leafFallback(t){if(t.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent)this.addTextNode(t.ownerDocument.createTextNode("\n"))}ignoreFallback(t){if(t.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent))this.findPlace(this.parser.schema.text("-"))}readStyles(t){let e=a.none,r=a.none;for(let i=0;i<t.length;i+=2){for(let n=undefined;;){let s=this.parser.matchStyle(t[i],t[i+1],this,n);if(!s)break;if(s.ignore)return null;if(s.clearMark){this.top.pendingMarks.concat(this.top.activeMarks).forEach((t=>{if(s.clearMark(t))r=t.addToSet(r)}))}else{e=this.parser.schema.marks[s.mark].create(s.attrs).addToSet(e)}if(s.consuming===false)n=s;else break}}return[e,r]}addElementByRule(t,e,r){let i,n,s;if(e.node){n=this.parser.schema.nodes[e.node];if(!n.isLeaf){i=this.enter(n,e.attrs||null,e.preserveWhitespace)}else if(!this.insertNode(n.create(e.attrs))){this.leafFallback(t)}}else{let t=this.parser.schema.marks[e.mark];s=t.create(e.attrs);this.addPendingMark(s)}let l=this.top;if(n&&n.isLeaf){this.findInside(t)}else if(r){this.addElement(t,r)}else if(e.getContent){this.findInside(t);e.getContent(t,this.parser.schema).forEach((t=>this.insertNode(t)))}else{let r=t;if(typeof e.contentElement=="string")r=t.querySelector(e.contentElement);else if(typeof e.contentElement=="function")r=e.contentElement(t);else if(e.contentElement)r=e.contentElement;this.findAround(t,r,true);this.addAll(r)}if(i&&this.sync(l))this.open--;if(s)this.removePendingMark(s,l)}addAll(t,e,r){let i=e||0;for(let n=e?t.childNodes[e]:t.firstChild,s=r==null?null:t.childNodes[r];n!=s;n=n.nextSibling,++i){this.findAtPoint(t,i);this.addDOM(n)}this.findAtPoint(t,i)}findPlace(t){let e,r;for(let i=this.open;i>=0;i--){let n=this.nodes[i];let s=n.findWrapping(t);if(s&&(!e||e.length>s.length)){e=s;r=n;if(!s.length)break}if(n.solid)break}if(!e)return false;this.sync(r);for(let t=0;t<e.length;t++)this.enterInner(e[t],null,false);return true}insertNode(t){if(t.isInline&&this.needsBlock&&!this.top.type){let t=this.textblockFromContext();if(t)this.enterInner(t)}if(this.findPlace(t)){this.closeExtra();let e=this.top;e.applyPending(t.type);if(e.match)e.match=e.match.matchType(t.type);let r=e.activeMarks;for(let i=0;i<t.marks.length;i++)if(!e.type||e.type.allowsMarkType(t.marks[i].type))r=t.marks[i].addToSet(r);e.content.push(t.mark(r));return true}return false}enter(t,e,r){let i=this.findPlace(t.create(e));if(i)this.enterInner(t,e,true,r);return i}enterInner(t,e=null,r=false,i){this.closeExtra();let n=this.top;n.applyPending(t);n.match=n.match&&n.match.matchType(t);let s=ht(t,i,n.options);if(n.options&ut&&n.content.length==0)s|=ut;this.nodes.push(new at(t,e,n.activeMarks,n.pendingMarks,r,null,s));this.open++}closeExtra(t=false){let e=this.nodes.length-1;if(e>this.open){for(;e>this.open;e--)this.nodes[e-1].content.push(this.nodes[e].finish(t));this.nodes.length=this.open+1}}finish(){this.open=0;this.closeExtra(this.isOpen);return this.nodes[0].finish(this.isOpen||this.options.topOpen)}sync(t){for(let e=this.open;e>=0;e--)if(this.nodes[e]==t){this.open=e;return true}return false}get currentPos(){this.closeExtra();let t=0;for(let e=this.open;e>=0;e--){let r=this.nodes[e].content;for(let e=r.length-1;e>=0;e--)t+=r[e].nodeSize;if(e)t++}return t}findAtPoint(t,e){if(this.find)for(let r=0;r<this.find.length;r++){if(this.find[r].node==t&&this.find[r].offset==e)this.find[r].pos=this.currentPos}}findInside(t){if(this.find)for(let e=0;e<this.find.length;e++){if(this.find[e].pos==null&&t.nodeType==1&&t.contains(this.find[e].node))this.find[e].pos=this.currentPos}}findAround(t,e,r){if(t!=e&&this.find)for(let i=0;i<this.find.length;i++){if(this.find[i].pos==null&&t.nodeType==1&&t.contains(this.find[i].node)){let t=e.compareDocumentPosition(this.find[i].node);if(t&(r?2:4))this.find[i].pos=this.currentPos}}}findInText(t){if(this.find)for(let e=0;e<this.find.length;e++){if(this.find[e].node==t)this.find[e].pos=this.currentPos-(t.nodeValue.length-this.find[e].offset)}}matchesContext(t){if(t.indexOf("|")>-1)return t.split(/\s*\|\s*/).some(this.matchesContext,this);let e=t.split("/");let r=this.options.context;let i=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type);let n=-(r?r.depth+1:0)+(i?0:1);let s=(t,l)=>{for(;t>=0;t--){let o=e[t];if(o==""){if(t==e.length-1||t==0)continue;for(;l>=n;l--)if(s(t-1,l))return true;return false}else{let t=l>0||l==0&&i?this.nodes[l].type:r&&l>=n?r.node(l-n).type:null;if(!t||t.name!=o&&t.groups.indexOf(o)==-1)return false;l--}}return true};return s(e.length-1,this.open)}textblockFromContext(){let t=this.options.context;if(t)for(let e=t.depth;e>=0;e--){let r=t.node(e).contentMatchAt(t.indexAfter(e)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let t in this.parser.schema.nodes){let e=this.parser.schema.nodes[t];if(e.isTextblock&&e.defaultAttrs)return e}}addPendingMark(t){let e=bt(t,this.top.pendingMarks);if(e)this.top.stashMarks.push(e);this.top.pendingMarks=t.addToSet(this.top.pendingMarks)}removePendingMark(t,e){for(let r=this.open;r>=0;r--){let i=this.nodes[r];let n=i.pendingMarks.lastIndexOf(t);if(n>-1){i.pendingMarks=t.removeFromSet(i.pendingMarks)}else{i.activeMarks=t.removeFromSet(i.activeMarks);let e=i.popFromStashMark(t);if(e&&i.type&&i.type.allowsMarkType(e.type))i.activeMarks=e.addToSet(i.activeMarks)}if(i==e)break}}}function dt(t){for(let e=t.firstChild,r=null;e;e=e.nextSibling){let t=e.nodeType==1?e.nodeName.toLowerCase():null;if(t&&lt.hasOwnProperty(t)&&r){r.appendChild(e);e=r}else if(t=="li"){r=e}else if(t){r=null}}}function pt(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function mt(t){let e=/\s*([\w-]+)\s*:\s*([^;]+)/g,r,i=[];while(r=e.exec(t))i.push(r[1],r[2].trim());return i}function wt(t){let e={};for(let r in t)e[r]=t[r];return e}function gt(t,e){let r=e.schema.nodes;for(let i in r){let n=r[i];if(!n.allowsMarkType(t))continue;let s=[],l=t=>{s.push(t);for(let r=0;r<t.edgeCount;r++){let{type:i,next:n}=t.edge(r);if(i==e)return true;if(s.indexOf(n)<0&&l(n))return true}};if(l(n.contentMatch))return true}}function bt(t,e){for(let r=0;r<e.length;r++){if(t.eq(e[r]))return e[r]}}class vt{constructor(t,e){this.nodes=t;this.marks=e}serializeFragment(t,e={},r){if(!r)r=kt(e).createDocumentFragment();let i=r,n=[];t.forEach((t=>{if(n.length||t.marks.length){let r=0,s=0;while(r<n.length&&s<t.marks.length){let e=t.marks[s];if(!this.marks[e.type.name]){s++;continue}if(!e.eq(n[r][0])||e.type.spec.spanning===false)break;r++;s++}while(r<n.length)i=n.pop()[1];while(s<t.marks.length){let r=t.marks[s++];let l=this.serializeMark(r,t.isInline,e);if(l){n.push([r,i]);i.appendChild(l.dom);i=l.contentDOM||l.dom}}}i.appendChild(this.serializeNodeInner(t,e))}));return r}serializeNodeInner(t,e){let{dom:r,contentDOM:i}=vt.renderSpec(kt(e),this.nodes[t.type.name](t));if(i){if(t.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(t.content,e,i)}return r}serializeNode(t,e={}){let r=this.serializeNodeInner(t,e);for(let i=t.marks.length-1;i>=0;i--){let n=this.serializeMark(t.marks[i],t.isInline,e);if(n){(n.contentDOM||n.dom).appendChild(r);r=n.dom}}return r}serializeMark(t,e,r={}){let i=this.marks[t.type.name];return i&&vt.renderSpec(kt(r),i(t,e))}static renderSpec(t,e,r=null){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],n=i.indexOf(" ");if(n>0){r=i.slice(0,n);i=i.slice(n+1)}let s;let l=r?t.createElementNS(r,i):t.createElement(i);let o=e[1],f=1;if(o&&typeof o=="object"&&o.nodeType==null&&!Array.isArray(o)){f=2;for(let t in o)if(o[t]!=null){let e=t.indexOf(" ");if(e>0)l.setAttributeNS(t.slice(0,e),t.slice(e+1),o[t]);else l.setAttribute(t,o[t])}}for(let i=f;i<e.length;i++){let n=e[i];if(n===0){if(i<e.length-1||i>f)throw new RangeError("Content hole must be the only child of its parent node");return{dom:l,contentDOM:l}}else{let{dom:e,contentDOM:i}=vt.renderSpec(t,n,r);l.appendChild(e);if(i){if(s)throw new RangeError("Multiple content holes");s=i}}}return{dom:l,contentDOM:s}}static fromSchema(t){return t.cached.domSerializer||(t.cached.domSerializer=new vt(this.nodesFromSchema(t),this.marksFromSchema(t)))}static nodesFromSchema(t){let e=yt(t.nodes);if(!e.text)e.text=t=>t.text;return e}static marksFromSchema(t){return yt(t.marks)}}function yt(t){let e={};for(let r in t){let i=t[r].spec.toDOM;if(i)e[r]=i}return e}function kt(t){return t.document||window.document}const Mt=65535;const xt=Math.pow(2,16);function St(t,e){return t+e*xt}function Ot(t){return t&Mt}function Et(t){return(t-(t&Mt))/xt}const Dt=1,Nt=2,Rt=4,Ct=8;class qt{constructor(t,e,r){this.pos=t;this.delInfo=e;this.recover=r}get deleted(){return(this.delInfo&Ct)>0}get deletedBefore(){return(this.delInfo&(Dt|Rt))>0}get deletedAfter(){return(this.delInfo&(Nt|Rt))>0}get deletedAcross(){return(this.delInfo&Rt)>0}}class Pt{constructor(t,e=false){this.ranges=t;this.inverted=e;if(!t.length&&Pt.empty)return Pt.empty}recover(t){let e=0,r=Ot(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+Et(t)}mapResult(t,e=1){return this._map(t,e,false)}map(t,e=1){return this._map(t,e,true)}_map(t,e,r){let i=0,n=this.inverted?2:1,s=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let o=this.ranges[l]-(this.inverted?i:0);if(o>t)break;let f=this.ranges[l+n],u=this.ranges[l+s],h=o+f;if(t<=h){let n=!f?e:t==o?-1:t==h?1:e;let s=o+i+(n<0?0:u);if(r)return s;let a=t==(e<0?o:h)?null:St(l/3,t-o);let c=t==o?Nt:t==h?Dt:Rt;if(e<0?t!=o:t!=h)c|=Ct;return new qt(s,c,a)}i+=u-f}return r?t+i:new qt(t+i,0,null)}touches(t,e){let r=0,i=Ot(e);let n=this.inverted?2:1,s=this.inverted?1:2;for(let e=0;e<this.ranges.length;e+=3){let l=this.ranges[e]-(this.inverted?r:0);if(l>t)break;let o=this.ranges[e+n],f=l+o;if(t<=f&&e==i*3)return true;r+=this.ranges[e+s]-o}return false}forEach(t){let e=this.inverted?2:1,r=this.inverted?1:2;for(let i=0,n=0;i<this.ranges.length;i+=3){let s=this.ranges[i],l=s-(this.inverted?n:0),o=s+(this.inverted?0:n);let f=this.ranges[i+e],u=this.ranges[i+r];t(l,l+f,o,o+u);n+=u-f}}invert(){return new Pt(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(t){return t==0?Pt.empty:new Pt(t<0?[0,-t,0]:[0,0,t])}}Pt.empty=new Pt([]);class $t{constructor(t=[],e,r=0,i=t.length){this.maps=t;this.mirror=e;this.from=r;this.to=i}slice(t=0,e=this.maps.length){return new $t(this.maps,this.mirror,t,e)}copy(){return new $t(this.maps.slice(),this.mirror&&this.mirror.slice(),this.from,this.to)}appendMap(t,e){this.to=this.maps.push(t);if(e!=null)this.setMirror(this.maps.length-1,e)}appendMapping(t){for(let e=0,r=this.maps.length;e<t.maps.length;e++){let i=t.getMirror(e);this.appendMap(t.maps[e],i!=null&&i<e?r+i:undefined)}}getMirror(t){if(this.mirror)for(let e=0;e<this.mirror.length;e++)if(this.mirror[e]==t)return this.mirror[e+(e%2?-1:1)]}setMirror(t,e){if(!this.mirror)this.mirror=[];this.mirror.push(t,e)}appendMappingInverted(t){for(let e=t.maps.length-1,r=this.maps.length+t.maps.length;e>=0;e--){let i=t.getMirror(e);this.appendMap(t.maps[e].invert(),i!=null&&i>e?r-i-1:undefined)}}invert(){let t=new $t;t.appendMappingInverted(this);return t}map(t,e=1){if(this.mirror)return this._map(t,e,true);for(let r=this.from;r<this.to;r++)t=this.maps[r].map(t,e);return t}mapResult(t,e=1){return this._map(t,e,false)}_map(t,e,r){let i=0;for(let r=this.from;r<this.to;r++){let n=this.maps[r],s=n.mapResult(t,e);if(s.recover!=null){let e=this.getMirror(r);if(e!=null&&e>r&&e<this.to){r=e;t=this.maps[e].recover(s.recover);continue}}i|=s.delInfo;t=s.pos}return r?t:new qt(t,i,null)}}const Tt=Object.create(null);class At{getMap(){return Pt.empty}merge(t){return null}static fromJSON(t,e){if(!e||!e.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=Tt[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 Tt)throw new RangeError("Duplicate use of step JSON ID "+t);Tt[t]=e;e.prototype.jsonID=t;return e}}class It{constructor(t,e){this.doc=t;this.failed=e}static ok(t){return new It(t,null)}static fail(t){return new It(null,t)}static fromReplace(t,e,r,i){try{return It.ok(t.replace(e,r,i))}catch(t){if(t instanceof c)return It.fail(t.message);throw t}}}function zt(t,e,r){let i=[];for(let n=0;n<t.childCount;n++){let s=t.child(n);if(s.content.size)s=s.copy(zt(s.content,e,s));if(s.isInline)s=e(s,r,n);i.push(s)}return o.fromArray(i)}class Jt extends At{constructor(t,e,r){super();this.from=t;this.to=e;this.mark=r}apply(t){let e=t.slice(this.from,this.to),r=t.resolve(this.from);let i=r.node(r.sharedDepth(this.to));let n=new d(zt(e.content,((t,e)=>{if(!t.isAtom||!e.type.allowsMarkType(this.mark.type))return t;return t.mark(this.mark.addToSet(t.marks))}),i),e.openStart,e.openEnd);return It.fromReplace(t,this.from,this.to,n)}invert(){return new Bt(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 Jt(e.pos,r.pos,this.mark)}merge(t){if(t instanceof Jt&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from)return new Jt(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 Jt(e.from,e.to,t.markFromJSON(e.mark))}}At.jsonID("addMark",Jt);class Bt extends At{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 d(zt(e.content,(t=>t.mark(this.mark.removeFromSet(t.marks))),t),e.openStart,e.openEnd);return It.fromReplace(t,this.from,this.to,r)}invert(){return new Jt(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 Bt(e.pos,r.pos,this.mark)}merge(t){if(t instanceof Bt&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from)return new Bt(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 Bt(e.from,e.to,t.markFromJSON(e.mark))}}At.jsonID("removeMark",Bt);class jt extends At{constructor(t,e){super();this.pos=t;this.mark=e}apply(t){let e=t.nodeAt(this.pos);if(!e)return It.fail("No node at mark step's position");let r=e.type.create(e.attrs,null,this.mark.addToSet(e.marks));return It.fromReplace(t,this.pos,this.pos+1,new d(o.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 jt(this.pos,e.marks[r]);return new jt(this.pos,this.mark)}}return new Ft(this.pos,this.mark)}map(t){let e=t.mapResult(this.pos,1);return e.deletedAfter?null:new jt(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 jt(e.pos,t.markFromJSON(e.mark))}}At.jsonID("addNodeMark",jt);class Ft extends At{constructor(t,e){super();this.pos=t;this.mark=e}apply(t){let e=t.nodeAt(this.pos);if(!e)return It.fail("No node at mark step's position");let r=e.type.create(e.attrs,null,this.mark.removeFromSet(e.marks));return It.fromReplace(t,this.pos,this.pos+1,new d(o.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 jt(this.pos,this.mark)}map(t){let e=t.mapResult(this.pos,1);return e.deletedAfter?null:new Ft(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 Ft(e.pos,t.markFromJSON(e.mark))}}At.jsonID("removeNodeMark",Ft);class Lt extends At{constructor(t,e,r,i=false){super();this.from=t;this.to=e;this.slice=r;this.structure=i}apply(t){if(this.structure&&_t(t,this.from,this.to))return It.fail("Structure replace would overwrite content");return It.fromReplace(t,this.from,this.to,this.slice)}getMap(){return new Pt([this.from,this.to-this.from,this.slice.size])}invert(t){return new Lt(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 Lt(e.pos,Math.max(e.pos,r.pos),this.slice)}merge(t){if(!(t instanceof Lt)||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?d.empty:new d(this.slice.content.append(t.slice.content),this.slice.openStart,t.slice.openEnd);return new Lt(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?d.empty:new d(t.slice.content.append(this.slice.content),t.slice.openStart,this.slice.openEnd);return new Lt(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 Lt(e.from,e.to,d.fromJSON(t,e.slice),!!e.structure)}}At.jsonID("replace",Lt);class Wt extends At{constructor(t,e,r,i,n,s,l=false){super();this.from=t;this.to=e;this.gapFrom=r;this.gapTo=i;this.slice=n;this.insert=s;this.structure=l}apply(t){if(this.structure&&(_t(t,this.from,this.gapFrom)||_t(t,this.gapTo,this.to)))return It.fail("Structure gap-replace would overwrite content");let e=t.slice(this.gapFrom,this.gapTo);if(e.openStart||e.openEnd)return It.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,e.content);if(!r)return It.fail("Content does not fit in gap");return It.fromReplace(t,this.from,this.to,r)}getMap(){return new Pt([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 Wt(this.from,this.from+this.slice.size+e,this.from+this.insert,this.from+this.insert+e,t.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(t){let e=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);let i=t.map(this.gapFrom,-1),n=t.map(this.gapTo,1);if(e.deletedAcross&&r.deletedAcross||i<e.pos||n>r.pos)return null;return new Wt(e.pos,r.pos,i,n,this.slice,this.insert,this.structure)}toJSON(){let t={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};if(this.slice.size)t.slice=this.slice.toJSON();if(this.structure)t.structure=true;return t}static fromJSON(t,e){if(typeof e.from!="number"||typeof e.to!="number"||typeof e.gapFrom!="number"||typeof e.gapTo!="number"||typeof e.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new Wt(e.from,e.to,e.gapFrom,e.gapTo,d.fromJSON(t,e.slice),e.insert,!!e.structure)}}At.jsonID("replaceAround",Wt);function _t(t,e,r){let i=t.resolve(e),n=r-e,s=i.depth;while(n>0&&s>0&&i.indexAfter(s)==i.node(s).childCount){s--;n--}if(n>0){let t=i.node(s).maybeChild(i.indexAfter(s));while(n>0){if(!t||t.isLeaf)return true;t=t.firstChild;n--}}return false}function Ut(t,e,r,i){let n=[],s=[];let l,o;t.doc.nodesBetween(e,r,((t,f,u)=>{if(!t.isInline)return;let h=t.marks;if(!i.isInSet(h)&&u.type.allowsMarkType(i.type)){let u=Math.max(f,e),a=Math.min(f+t.nodeSize,r);let c=i.addToSet(h);for(let t=0;t<h.length;t++){if(!h[t].isInSet(c)){if(l&&l.to==u&&l.mark.eq(h[t]))l.to=a;else n.push(l=new Bt(u,a,h[t]))}}if(o&&o.to==u)o.to=a;else s.push(o=new Jt(u,a,i))}}));n.forEach((e=>t.step(e)));s.forEach((e=>t.step(e)))}function Ht(t,e,r,i){let n=[],s=0;t.doc.nodesBetween(e,r,((t,l)=>{if(!t.isInline)return;s++;let o=null;if(i instanceof tt){let e=t.marks,r;while(r=i.isInSet(e)){(o||(o=[])).push(r);e=r.removeFromSet(e)}}else if(i){if(i.isInSet(t.marks))o=[i]}else{o=t.marks}if(o&&o.length){let i=Math.min(l+t.nodeSize,r);for(let t=0;t<o.length;t++){let r=o[t],f;for(let t=0;t<n.length;t++){let e=n[t];if(e.step==s-1&&r.eq(n[t].style))f=e}if(f){f.to=i;f.step=s}else{n.push({style:r,from:Math.max(l,e),to:i,step:s})}}}}));n.forEach((e=>t.step(new Bt(e.from,e.to,e.style))))}function Kt(t,e,r,i=r.contentMatch){let n=t.doc.nodeAt(e);let s=[],l=e+1;for(let e=0;e<n.childCount;e++){let f=n.child(e),u=l+f.nodeSize;let h=i.matchType(f.type);if(!h){s.push(new Lt(l,u,d.empty))}else{i=h;for(let e=0;e<f.marks.length;e++)if(!r.allowsMarkType(f.marks[e].type))t.step(new Bt(l,u,f.marks[e]));if(f.isText&&!r.spec.code){let t,e=/\r?\n|\r/g,i;while(t=e.exec(f.text)){if(!i)i=new d(o.from(r.schema.text(" ",r.allowedMarks(f.marks))),0,0);s.push(new Lt(l+t.index,l+t.index+t[0].length,i))}}}l=u}if(!i.validEnd){let e=i.fillBefore(o.empty,true);t.replace(l,l,new d(e,0,0))}for(let e=s.length-1;e>=0;e--)t.step(s[e])}function Gt(t,e,r){return(e==0||t.canReplace(e,t.childCount))&&(r==t.childCount||t.canReplace(0,r))}function Vt(t){let e=t.parent;let r=e.content.cutByIndex(t.startIndex,t.endIndex);for(let e=t.depth;;--e){let i=t.$from.node(e);let n=t.$from.index(e),s=t.$to.indexAfter(e);if(e<t.depth&&i.canReplace(n,s,r))return e;if(e==0||i.type.spec.isolating||!Gt(i,n,s))break}return null}function Xt(t,e,r){let{$from:i,$to:n,depth:s}=e;let l=i.before(s+1),f=n.after(s+1);let u=l,h=f;let a=o.empty,c=0;for(let t=s,e=false;t>r;t--)if(e||i.index(t)>0){e=true;a=o.from(i.node(t).copy(a));c++}else{u--}let p=o.empty,m=0;for(let t=s,e=false;t>r;t--)if(e||n.after(t+1)<n.end(t)){e=true;p=o.from(n.node(t).copy(p));m++}else{h++}t.step(new Wt(u,h,l,f,new d(a.append(p),c,m),a.size-c,true))}function Yt(t,e,r=null,i=t){let n=Zt(t,e);let s=n&&te(i,e);if(!s)return null;return n.map(Qt).concat({type:e,attrs:r}).concat(s.map(Qt))}function Qt(t){return{type:t,attrs:null}}function Zt(t,e){let{parent:r,startIndex:i,endIndex:n}=t;let s=r.contentMatchAt(i).findWrapping(e);if(!s)return null;let l=s.length?s[0]:e;return r.canReplaceWith(i,n,l)?s:null}function te(t,e){let{parent:r,startIndex:i,endIndex:n}=t;let s=r.child(i);let l=e.contentMatch.findWrapping(s.type);if(!l)return null;let o=l.length?l[l.length-1]:e;let f=o.contentMatch;for(let t=i;f&&t<n;t++)f=f.matchType(r.child(t).type);if(!f||!f.validEnd)return null;return l}function ee(t,e,r){let i=o.empty;for(let t=r.length-1;t>=0;t--){if(i.size){let e=r[t].type.contentMatch.matchFragment(i);if(!e||!e.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}i=o.from(r[t].type.create(r[t].attrs,i))}let n=e.start,s=e.end;t.step(new Wt(n,s,n,s,new d(i,0,0),r.length,true))}function re(t,e,r,i,n){if(!i.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let s=t.steps.length;t.doc.nodesBetween(e,r,((e,r)=>{if(e.isTextblock&&!e.hasMarkup(i,n)&&ie(t.doc,t.mapping.slice(s).map(r),i)){t.clearIncompatible(t.mapping.slice(s).map(r,1),i);let l=t.mapping.slice(s);let f=l.map(r,1),u=l.map(r+e.nodeSize,1);t.step(new Wt(f,u,f+1,u-1,new d(o.from(i.create(n,null,e.marks)),0,0),1,true));return false}}))}function ie(t,e,r){let i=t.resolve(e),n=i.index();return i.parent.canReplaceWith(n,n+1,r)}function ne(t,e,r,i,n){let s=t.doc.nodeAt(e);if(!s)throw new RangeError("No node at given position");if(!r)r=s.type;let l=r.create(i,null,n||s.marks);if(s.isLeaf)return t.replaceWith(e,e+s.nodeSize,l);if(!r.validContent(s.content))throw new RangeError("Invalid content for node type "+r.name);t.step(new Wt(e,e+s.nodeSize,e+1,e+s.nodeSize-1,new d(o.from(l),0,0),1,true))}function se(t,e,r=1,i){let n=t.resolve(e),s=n.depth-r;let l=i&&i[i.length-1]||n.parent;if(s<0||n.parent.type.spec.isolating||!n.parent.canReplace(n.index(),n.parent.childCount)||!l.type.validContent(n.parent.content.cutByIndex(n.index(),n.parent.childCount)))return false;for(let t=n.depth-1,e=r-2;t>s;t--,e--){let r=n.node(t),s=n.index(t);if(r.type.spec.isolating)return false;let l=r.content.cutByIndex(s,r.childCount);let o=i&&i[e+1];if(o)l=l.replaceChild(0,o.type.create(o.attrs));let f=i&&i[e]||r;if(!r.canReplace(s+1,r.childCount)||!f.type.validContent(l))return false}let o=n.indexAfter(s);let f=i&&i[0];return n.node(s).canReplaceWith(o,o,f?f.type:n.node(s+1).type)}function le(t,e,r=1,i){let n=t.doc.resolve(e),s=o.empty,l=o.empty;for(let t=n.depth,e=n.depth-r,f=r-1;t>e;t--,f--){s=o.from(n.node(t).copy(s));let e=i&&i[f];l=o.from(e?e.type.create(e.attrs,l):n.node(t).copy(l))}t.step(new Lt(e,e,new d(s.append(l),r,r),true))}function oe(t,e){let r=t.resolve(e),i=r.index();return fe(r.nodeBefore,r.nodeAfter)&&r.parent.canReplace(i,i+1)}function fe(t,e){return!!(t&&e&&!t.isLeaf&&t.canAppend(e))}function ue(t,e,r=-1){let i=t.resolve(e);for(let t=i.depth;;t--){let n,s,l=i.index(t);if(t==i.depth){n=i.nodeBefore;s=i.nodeAfter}else if(r>0){n=i.node(t+1);l++;s=i.node(t).maybeChild(l)}else{n=i.node(t).maybeChild(l-1);s=i.node(t+1)}if(n&&!n.isTextblock&&fe(n,s)&&i.node(t).canReplace(l,l+1))return e;if(t==0)break;e=r<0?i.before(t):i.after(t)}}function he(t,e,r){let i=new Lt(e-r,e+r,d.empty,true);t.step(i)}function ae(t,e,r){let i=t.resolve(e);if(i.parent.canReplaceWith(i.index(),i.index(),r))return e;if(i.parentOffset==0)for(let t=i.depth-1;t>=0;t--){let e=i.index(t);if(i.node(t).canReplaceWith(e,e,r))return i.before(t+1);if(e>0)return null}if(i.parentOffset==i.parent.content.size)for(let t=i.depth-1;t>=0;t--){let e=i.indexAfter(t);if(i.node(t).canReplaceWith(e,e,r))return i.after(t+1);if(e<i.node(t).childCount)return null}return null}function ce(t,e,r){let i=t.resolve(e);if(!r.content.size)return e;let n=r.content;for(let t=0;t<r.openStart;t++)n=n.firstChild.content;for(let t=1;t<=(r.openStart==0&&r.size?2:1);t++){for(let e=i.depth;e>=0;e--){let r=e==i.depth?0:i.pos<=(i.start(e+1)+i.end(e+1))/2?-1:1;let s=i.index(e)+(r>0?1:0);let l=i.node(e),o=false;if(t==1){o=l.canReplace(s,s,n)}else{let t=l.contentMatchAt(s).findWrapping(n.firstChild.type);o=t&&l.canReplaceWith(s,s,t[0])}if(o)return r==0?i.pos:r<0?i.before(e+1):i.after(e+1)}}return null}function de(t,e,r=e,i=d.empty){if(e==r&&!i.size)return null;let n=t.resolve(e),s=t.resolve(r);if(pe(n,s,i))return new Lt(e,r,i);return new me(n,s,i).fit()}function pe(t,e,r){return!r.openStart&&!r.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),r.content)}class me{constructor(t,e,r){this.$from=t;this.$to=e;this.unplaced=r;this.frontier=[];this.placed=o.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=o.from(t.node(e).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){while(this.unplaced.size){let t=this.findFittable();if(t)this.placeNodes(t);else this.openMore()||this.dropNode()}let t=this.mustMoveInline(),e=this.placed.size-this.depth-this.$from.depth;let r=this.$from,i=this.close(t<0?this.$to:r.doc.resolve(t));if(!i)return null;let n=this.placed,s=r.depth,l=i.depth;while(s&&l&&n.childCount==1){n=n.firstChild.content;s--;l--}let o=new d(n,s,l);if(t>-1)return new Wt(r.pos,t,this.$to.pos,this.$to.end(),o,e);if(o.size||r.pos!=this.$to.pos)return new Lt(r.pos,i.pos,o);return null}findFittable(){let t=this.unplaced.openStart;for(let e=this.unplaced.content,r=0,i=this.unplaced.openEnd;r<t;r++){let n=e.firstChild;if(e.childCount>1)i=0;if(n.type.spec.isolating&&i<=r){t=r;break}e=n.content}for(let e=1;e<=2;e++){for(let r=e==1?t:this.unplaced.openStart;r>=0;r--){let t,i=null;if(r){i=be(this.unplaced.content,r-1).firstChild;t=i.content}else{t=this.unplaced.content}let n=t.firstChild;for(let t=this.depth;t>=0;t--){let{type:s,match:l}=this.frontier[t],f,u=null;if(e==1&&(n?l.matchType(n.type)||(u=l.fillBefore(o.from(n),false)):i&&s.compatibleContent(i.type)))return{sliceDepth:r,frontierDepth:t,parent:i,inject:u};else if(e==2&&n&&(f=l.findWrapping(n.type)))return{sliceDepth:r,frontierDepth:t,parent:i,wrap:f};if(i&&l.matchType(i.type))break}}}}openMore(){let{content:t,openStart:e,openEnd:r}=this.unplaced;let i=be(t,e);if(!i.childCount||i.firstChild.isLeaf)return false;this.unplaced=new d(t,e+1,Math.max(r,i.size+e>=t.size-r?e+1:0));return true}dropNode(){let{content:t,openStart:e,openEnd:r}=this.unplaced;let i=be(t,e);if(i.childCount<=1&&e>0){let n=t.size-e<=e+i.size;this.unplaced=new d(we(t,e-1,1),e-1,n?e-1:r)}else{this.unplaced=new d(we(t,e,1),e,r)}}placeNodes({sliceDepth:t,frontierDepth:e,parent:r,inject:i,wrap:n}){while(this.depth>e)this.closeFrontierNode();if(n)for(let t=0;t<n.length;t++)this.openFrontierNode(n[t]);let s=this.unplaced,l=r?r.content:s.content;let f=s.openStart-t;let u=0,h=[];let{match:a,type:c}=this.frontier[e];if(i){for(let t=0;t<i.childCount;t++)h.push(i.child(t));a=a.matchFragment(i)}let p=l.size+t-(s.content.size-s.openEnd);while(u<l.childCount){let t=l.child(u),e=a.matchType(t.type);if(!e)break;u++;if(u>1||f==0||t.content.size){a=e;h.push(ve(t.mark(c.allowedMarks(t.marks)),u==1?f:0,u==l.childCount?p:-1))}}let m=u==l.childCount;if(!m)p=-1;this.placed=ge(this.placed,e,o.from(h));this.frontier[e].match=a;if(m&&p<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1)this.closeFrontierNode();for(let t=0,e=l;t<p;t++){let t=e.lastChild;this.frontier.push({type:t.type,match:t.contentMatchAt(t.childCount)});e=t.content}this.unplaced=!m?new d(we(s.content,t,u),s.openStart,s.openEnd):t==0?d.empty:new d(we(s.content,t-1,1),t-1,p<0?s.openEnd:t-1)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let t=this.frontier[this.depth],e;if(!t.type.isTextblock||!ye(this.$to,this.$to.depth,t.type,t.match,false)||this.$to.depth==this.depth&&(e=this.findCloseLevel(this.$to))&&e.depth==this.depth)return-1;let{depth:r}=this.$to,i=this.$to.after(r);while(r>1&&i==this.$to.end(--r))++i;return i}findCloseLevel(t){t:for(let e=Math.min(this.depth,t.depth);e>=0;e--){let{match:r,type:i}=this.frontier[e];let n=e<t.depth&&t.end(e+1)==t.pos+(t.depth-(e+1));let s=ye(t,e,i,r,n);if(!s)continue;for(let r=e-1;r>=0;r--){let{match:e,type:i}=this.frontier[r];let n=ye(t,r,i,e,true);if(!n||n.childCount)continue t}return{depth:e,fit:s,move:n?t.doc.resolve(t.after(e+1)):t}}}close(t){let e=this.findCloseLevel(t);if(!e)return null;while(this.depth>e.depth)this.closeFrontierNode();if(e.fit.childCount)this.placed=ge(this.placed,e.depth,e.fit);t=e.move;for(let r=e.depth+1;r<=t.depth;r++){let e=t.node(r),i=e.type.contentMatch.fillBefore(e.content,true,t.index(r));this.openFrontierNode(e.type,e.attrs,i)}return t}openFrontierNode(t,e=null,r){let i=this.frontier[this.depth];i.match=i.match.matchType(t);this.placed=ge(this.placed,this.depth,o.from(t.create(e,r)));this.frontier.push({type:t,match:t.contentMatch})}closeFrontierNode(){let t=this.frontier.pop();let e=t.match.fillBefore(o.empty,true);if(e.childCount)this.placed=ge(this.placed,this.frontier.length,e)}}function we(t,e,r){if(e==0)return t.cutByIndex(r,t.childCount);return t.replaceChild(0,t.firstChild.copy(we(t.firstChild.content,e-1,r)))}function ge(t,e,r){if(e==0)return t.append(r);return t.replaceChild(t.childCount-1,t.lastChild.copy(ge(t.lastChild.content,e-1,r)))}function be(t,e){for(let r=0;r<e;r++)t=t.firstChild.content;return t}function ve(t,e,r){if(e<=0)return t;let i=t.content;if(e>1)i=i.replaceChild(0,ve(i.firstChild,e-1,i.childCount==1?r-1:0));if(e>0){i=t.type.contentMatch.fillBefore(i).append(i);if(r<=0)i=i.append(t.type.contentMatch.matchFragment(i).fillBefore(o.empty,true))}return t.copy(i)}function ye(t,e,r,i,n){let s=t.node(e),l=n?t.indexAfter(e):t.index(e);if(l==s.childCount&&!r.compatibleContent(s.type))return null;let o=i.fillBefore(s.content,true,l);return o&&!ke(r,s.content,l)?o:null}function ke(t,e,r){for(let i=r;i<e.childCount;i++)if(!t.allowsMarks(e.child(i).marks))return true;return false}function Me(t){return t.spec.defining||t.spec.definingForContent}function xe(t,e,r,i){if(!i.size)return t.deleteRange(e,r);let n=t.doc.resolve(e),s=t.doc.resolve(r);if(pe(n,s,i))return t.step(new Lt(e,r,i));let l=De(n,t.doc.resolve(r));if(l[l.length-1]==0)l.pop();let o=-(n.depth+1);l.unshift(o);for(let t=n.depth,e=n.pos-1;t>0;t--,e--){let r=n.node(t).type.spec;if(r.defining||r.definingAsContext||r.isolating)break;if(l.indexOf(t)>-1)o=t;else if(n.before(t)==e)l.splice(1,0,-t)}let f=l.indexOf(o);let u=[],h=i.openStart;for(let t=i.content,e=0;;e++){let r=t.firstChild;u.push(r);if(e==i.openStart)break;t=r.content}for(let t=h-1;t>=0;t--){let e=u[t],r=Me(e.type);if(r&&!e.sameMarkup(n.node(Math.abs(o)-1)))h=t;else if(r||!e.type.isTextblock)break}for(let e=i.openStart;e>=0;e--){let o=(e+h+1)%(i.openStart+1);let a=u[o];if(!a)continue;for(let e=0;e<l.length;e++){let u=l[(e+f)%l.length],h=true;if(u<0){h=false;u=-u}let c=n.node(u-1),p=n.index(u-1);if(c.canReplaceWith(p,p,a.type,a.marks))return t.replace(n.before(u),h?s.after(u):r,new d(Se(i.content,0,i.openStart,o),o,i.openEnd))}}let a=t.steps.length;for(let o=l.length-1;o>=0;o--){t.replace(e,r,i);if(t.steps.length>a)break;let f=l[o];if(f<0)continue;e=n.before(f);r=s.after(f)}}function Se(t,e,r,i,n){if(e<r){let n=t.firstChild;t=t.replaceChild(0,n.copy(Se(n.content,e+1,r,i,n)))}if(e>i){let e=n.contentMatchAt(0);let r=e.fillBefore(t).append(t);t=r.append(e.matchFragment(r).fillBefore(o.empty,true))}return t}function Oe(t,e,r,i){if(!i.isInline&&e==r&&t.doc.resolve(e).parent.content.size){let n=ae(t.doc,e,i.type);if(n!=null)e=r=n}t.replaceRange(e,r,new d(o.from(i),0,0))}function Ee(t,e,r){let i=t.doc.resolve(e),n=t.doc.resolve(r);let s=De(i,n);for(let e=0;e<s.length;e++){let r=s[e],l=e==s.length-1;if(l&&r==0||i.node(r).type.contentMatch.validEnd)return t.delete(i.start(r),n.end(r));if(r>0&&(l||i.node(r-1).canReplace(i.index(r-1),n.indexAfter(r-1))))return t.delete(i.before(r),n.after(r))}for(let s=1;s<=i.depth&&s<=n.depth;s++){if(e-i.start(s)==i.depth-s&&r>i.end(s)&&n.end(s)-r!=n.depth-s)return t.delete(i.before(s),r)}t.delete(e,r)}function De(t,e){let r=[],i=Math.min(t.depth,e.depth);for(let n=i;n>=0;n--){let i=t.start(n);if(i<t.pos-(t.depth-n)||e.end(n)>e.pos+(e.depth-n)||t.node(n).type.spec.isolating||e.node(n).type.spec.isolating)break;if(i==e.start(n)||n==t.depth&&n==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&n&&e.start(n-1)==i-1)r.push(n)}return r}class Ne extends At{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 It.fail("No node at attribute step's position");let r=Object.create(null);for(let t in e.attrs)r[t]=e.attrs[t];r[this.attr]=this.value;let i=e.type.create(r,null,e.marks);return It.fromReplace(t,this.pos,this.pos+1,new d(o.from(i),0,e.isLeaf?0:1))}getMap(){return Pt.empty}invert(t){return new Ne(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 Ne(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 Ne(e.pos,e.attr,e.value)}}At.jsonID("attr",Ne);class Re extends At{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 It.ok(r)}getMap(){return Pt.empty}invert(t){return new Re(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 Re(e.attr,e.value)}}At.jsonID("docAttr",Re);let Ce=class extends Error{};Ce=function t(e){let r=Error.call(this,e);r.__proto__=t.prototype;return r};Ce.prototype=Object.create(Error.prototype);Ce.prototype.constructor=Ce;Ce.prototype.name="TransformError";class qe{constructor(t){this.doc=t;this.steps=[];this.docs=[];this.mapping=new $t}get before(){return this.docs.length?this.docs[0]:this.doc}step(t){let e=this.maybeStep(t);if(e.failed)throw new Ce(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=d.empty){let i=de(this.doc,t,e,r);if(i)this.step(i);return this}replaceWith(t,e,r){return this.replace(t,e,new d(o.from(r),0,0))}delete(t,e){return this.replace(t,e,d.empty)}insert(t,e){return this.replaceWith(t,t,e)}replaceRange(t,e,r){xe(this,t,e,r);return this}replaceRangeWith(t,e,r){Oe(this,t,e,r);return this}deleteRange(t,e){Ee(this,t,e);return this}lift(t,e){Xt(this,t,e);return this}join(t,e=1){he(this,t,e);return this}wrap(t,e){ee(this,t,e);return this}setBlockType(t,e=t,r,i=null){re(this,t,e,r,i);return this}setNodeMarkup(t,e,r=null,i){ne(this,t,e,r,i);return this}setNodeAttribute(t,e,r){this.step(new Ne(t,e,r));return this}setDocAttribute(t,e){this.step(new Re(t,e));return this}addNodeMark(t,e){this.step(new jt(t,e));return this}removeNodeMark(t,e){if(!(e instanceof a)){let r=this.doc.nodeAt(t);if(!r)throw new RangeError("No node at position "+t);e=e.isInSet(r.marks);if(!e)return this}this.step(new Ft(t,e));return this}split(t,e=1,r){le(this,t,e,r);return this}addMark(t,e,r){Ut(this,t,e,r);return this}removeMark(t,e,r){Ht(this,t,e,r);return this}clearIncompatible(t,e,r){Kt(this,t,e,r);return this}}const Pe=Object.create(null);class $e{constructor(t,e,r){this.$anchor=t;this.$head=e;this.ranges=r||[new Te(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=d.empty){let r=e.content.lastChild,i=null;for(let t=0;t<e.openEnd;t++){i=r;r=r.lastChild}let n=t.steps.length,s=this.ranges;for(let l=0;l<s.length;l++){let{$from:o,$to:f}=s[l],u=t.mapping.slice(n);t.replaceRange(u.map(o.pos),u.map(f.pos),l?d.empty:e);if(l==0)_e(t,n,(r?r.isInline:i&&i.isTextblock)?-1:1)}}replaceWith(t,e){let r=t.steps.length,i=this.ranges;for(let n=0;n<i.length;n++){let{$from:s,$to:l}=i[n],o=t.mapping.slice(r);let f=o.map(s.pos),u=o.map(l.pos);if(n){t.deleteRange(f,u)}else{t.replaceRangeWith(f,u,e);_e(t,r,e.isInline?-1:1)}}}static findFrom(t,e,r=false){let i=t.parent.inlineContent?new ze(t):We(t.node(0),t.parent,t.pos,t.index(),e,r);if(i)return i;for(let i=t.depth-1;i>=0;i--){let n=e<0?We(t.node(0),t.node(i),t.before(i+1),t.index(i),e,r):We(t.node(0),t.node(i),t.after(i+1),t.index(i)+1,e,r);if(n)return n}return null}static near(t,e=1){return this.findFrom(t,e)||this.findFrom(t,-e)||new Fe(t.node(0))}static atStart(t){return We(t,t,0,0,1)||new Fe(t)}static atEnd(t){return We(t,t,t.content.size,t.childCount,-1)||new Fe(t)}static fromJSON(t,e){if(!e||!e.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Pe[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 Pe)throw new RangeError("Duplicate use of selection JSON ID "+t);Pe[t]=e;e.prototype.jsonID=t;return e}getBookmark(){return ze.between(this.$anchor,this.$head).getBookmark()}}$e.prototype.visible=true;class Te{constructor(t,e){this.$from=t;this.$to=e}}let Ae=false;function Ie(t){if(!Ae&&!t.parent.inlineContent){Ae=true;console["warn"]("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")")}}class ze extends $e{constructor(t,e=t){Ie(t);Ie(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 $e.near(r);let i=t.resolve(e.map(this.anchor));return new ze(i.parent.inlineContent?i:r,r)}replace(t,e=d.empty){super.replace(t,e);if(e==d.empty){let e=this.$from.marksAcross(this.$to);if(e)t.ensureMarks(e)}}eq(t){return t instanceof ze&&t.anchor==this.anchor&&t.head==this.head}getBookmark(){return new Je(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 ze(t.resolve(e.anchor),t.resolve(e.head))}static create(t,e,r=e){let i=t.resolve(e);return new this(i,r==e?i:t.resolve(r))}static between(t,e,r){let i=t.pos-e.pos;if(!r||i)r=i>=0?1:-1;if(!e.parent.inlineContent){let t=$e.findFrom(e,r,true)||$e.findFrom(e,-r,true);if(t)e=t.$head;else return $e.near(e,r)}if(!t.parent.inlineContent){if(i==0){t=e}else{t=($e.findFrom(t,-r,true)||$e.findFrom(t,r,true)).$anchor;if(t.pos<e.pos!=i<0)t=e}}return new ze(t,e)}}$e.jsonID("text",ze);class Je{constructor(t,e){this.anchor=t;this.head=e}map(t){return new Je(t.map(this.anchor),t.map(this.head))}resolve(t){return ze.between(t.resolve(this.anchor),t.resolve(this.head))}}class Be extends $e{constructor(t){let e=t.nodeAfter;let r=t.node(0).resolve(t.pos+e.nodeSize);super(t,r);this.node=e}map(t,e){let{deleted:r,pos:i}=e.mapResult(this.anchor);let n=t.resolve(i);if(r)return $e.near(n);return new Be(n)}content(){return new d(o.from(this.node),0,0)}eq(t){return t instanceof Be&&t.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new je(this.anchor)}static fromJSON(t,e){if(typeof e.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new Be(t.resolve(e.anchor))}static create(t,e){return new Be(t.resolve(e))}static isSelectable(t){return!t.isText&&t.type.spec.selectable!==false}}Be.prototype.visible=false;$e.jsonID("node",Be);class je{constructor(t){this.anchor=t}map(t){let{deleted:e,pos:r}=t.mapResult(this.anchor);return e?new Je(r,r):new je(r)}resolve(t){let e=t.resolve(this.anchor),r=e.nodeAfter;if(r&&Be.isSelectable(r))return new Be(e);return $e.near(e)}}class Fe extends $e{constructor(t){super(t.resolve(0),t.resolve(t.content.size))}replace(t,e=d.empty){if(e==d.empty){t.delete(0,t.doc.content.size);let e=$e.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 Fe(t)}map(t){return new Fe(t)}eq(t){return t instanceof Fe}getBookmark(){return Le}}$e.jsonID("all",Fe);const Le={map(){return this},resolve(t){return new Fe(t)}};function We(t,e,r,i,n,s=false){if(e.inlineContent)return ze.create(t,r);for(let l=i-(n>0?0:1);n>0?l<e.childCount:l>=0;l+=n){let i=e.child(l);if(!i.isAtom){let e=We(t,i,r+n,n<0?i.childCount:0,n,s);if(e)return e}else if(!s&&Be.isSelectable(i)){return Be.create(t,r-(n<0?i.nodeSize:0))}r+=i.nodeSize*n}return null}function _e(t,e,r){let i=t.steps.length-1;if(i<e)return;let n=t.steps[i];if(!(n instanceof Lt||n instanceof Wt))return;let s=t.mapping.maps[i],l;s.forEach(((t,e,r,i)=>{if(l==null)l=i}));t.setSelection($e.near(t.doc.resolve(l),r))}const Ue=1,He=2,Ke=4;class Ge extends qe{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|Ue)&~He;this.storedMarks=null;return this}get selectionSet(){return(this.updated&Ue)>0}setStoredMarks(t){this.storedMarks=t;this.updated|=He;return this}ensureMarks(t){if(!a.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&He)>0}addStep(t,e){super.addStep(t,e);this.updated=this.updated&~He;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)||a.none));r.replaceWith(this,t);return this}deleteSelection(){this.selection.replace(this);return this}insertText(t,e,r){let i=this.doc.type.schema;if(e==null){if(!t)return this.deleteSelection();return this.replaceSelectionWith(i.text(t),true)}else{if(r==null)r=e;r=r==null?e:r;if(!t)return this.deleteRange(e,r);let n=this.storedMarks;if(!n){let t=this.doc.resolve(e);n=r==e?t.marks():t.marksAcross(this.doc.resolve(r))}this.replaceRangeWith(e,r,i.text(t,n));if(!this.selection.empty)this.setSelection($e.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|=Ke;return this}get scrolledIntoView(){return(this.updated&Ke)>0}}function Ve(t,e){return!e||!t?t:t.bind(e)}class Xe{constructor(t,e,r){this.name=t;this.init=Ve(e.init,r);this.apply=Ve(e.apply,r)}}const Ye=[new Xe("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new Xe("selection",{init(t,e){return t.selection||$e.atStart(e.doc)},apply(t){return t.selection}}),new Xe("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,r,i){return i.selection.$cursor?t.storedMarks:null}}),new Xe("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class Qe{constructor(t,e){this.schema=t;this.plugins=[];this.pluginsByKey=Object.create(null);this.fields=Ye.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 Xe(t.key,t.spec.state,t))}))}}class Ze{constructor(t){this.config=t}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(t){return this.applyTransaction(t).state}filterTransaction(t,e=-1){for(let r=0;r<this.config.plugins.length;r++)if(r!=e){let e=this.config.plugins[r];if(e.spec.filterTransaction&&!e.spec.filterTransaction.call(e,t,this))return false}return true}applyTransaction(t){if(!this.filterTransaction(t))return{state:this,transactions:[]};let e=[t],r=this.applyInner(t),i=null;for(;;){let n=false;for(let s=0;s<this.config.plugins.length;s++){let l=this.config.plugins[s];if(l.spec.appendTransaction){let o=i?i[s].n:0,f=i?i[s].state:this;let u=o<e.length&&l.spec.appendTransaction.call(l,o?e.slice(o):e,f,r);if(u&&r.filterTransaction(u,s)){u.setMeta("appendedTransaction",t);if(!i){i=[];for(let t=0;t<this.config.plugins.length;t++)i.push(t<s?{state:r,n:e.length}:{state:this,n:0})}e.push(u);r=r.applyInner(u);n=true}if(i)i[s]={state:r,n:e.length}}}if(!n)return{state:r,transactions:e}}}applyInner(t){if(!t.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let e=new Ze(this.config),r=this.config.fields;for(let i=0;i<r.length;i++){let n=r[i];e[n.name]=n.apply(t,this[n.name],this,e)}return e}get tr(){return new Ge(this)}static create(t){let e=new Qe(t.doc?t.doc.type.schema:t.schema,t.plugins);let r=new Ze(e);for(let i=0;i<e.fields.length;i++)r[e.fields[i].name]=e.fields[i].init(t,r);return r}reconfigure(t){let e=new Qe(this.schema,t.plugins);let r=e.fields,i=new Ze(e);for(let e=0;e<r.length;e++){let n=r[e].name;i[n]=this.hasOwnProperty(n)?this[n]:r[e].init(t,i)}return i}toJSON(t){let e={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks)e.storedMarks=this.storedMarks.map((t=>t.toJSON()));if(t&&typeof t=="object")for(let r in t){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let i=t[r],n=i.spec.state;if(n&&n.toJSON)e[r]=n.toJSON.call(i,this[i.key])}return e}static fromJSON(t,e,r){if(!e)throw new RangeError("Invalid input for EditorState.fromJSON");if(!t.schema)throw new RangeError("Required config field 'schema' missing");let i=new Qe(t.schema,t.plugins);let n=new Ze(i);i.fields.forEach((i=>{if(i.name=="doc"){n.doc=P.fromJSON(t.schema,e.doc)}else if(i.name=="selection"){n.selection=$e.fromJSON(n.doc,e.selection)}else if(i.name=="storedMarks"){if(e.storedMarks)n.storedMarks=e.storedMarks.map(t.schema.markFromJSON)}else{if(r)for(let s in r){let l=r[s],o=l.spec.state;if(l.key==i.name&&o&&o.fromJSON&&Object.prototype.hasOwnProperty.call(e,s)){n[i.name]=o.fromJSON.call(l,t,e[s],n);return}}n[i.name]=i.init(t,n)}}));return n}}function tr(t,e,r){for(let i in t){let n=t[i];if(n instanceof Function)n=n.bind(e);else if(i=="handleDOMEvents")n=tr(n,e,{});r[i]=n}return r}class er{constructor(t){this.spec=t;this.props={};if(t.props)tr(t.props,this,this.props);this.key=t.key?t.key.key:ir("plugin")}getState(t){return t[this.key]}}const rr=Object.create(null);function ir(t){if(t in rr)return t+"$"+ ++rr[t];rr[t]=0;return t+"$"}class nr{constructor(t="key"){this.key=ir(t)}get(t){return t.config.pluginsByKey[this.key]}getState(t){return t[this.key]}}const sr=function(t){for(var e=0;;e++){t=t.previousSibling;if(!t)return e}};const lr=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let or=null;const fr=function(t,e,r){let i=or||(or=document.createRange());i.setEnd(t,r==null?t.nodeValue.length:r);i.setStart(t,e||0);return i};const ur=function(t,e,r,i){return r&&(ar(t,e,r,i,-1)||ar(t,e,r,i,1))};const hr=/^(img|br|input|textarea|hr)$/i;function ar(t,e,r,i,n){for(;;){if(t==r&&e==i)return true;if(e==(n<0?0:cr(t))){let r=t.parentNode;if(!r||r.nodeType!=1||pr(t)||hr.test(t.nodeName)||t.contentEditable=="false")return false;e=sr(t)+(n<0?0:1);t=r}else if(t.nodeType==1){t=t.childNodes[e+(n<0?-1:0)];if(t.contentEditable=="false")return false;e=n<0?cr(t):0}else{return false}}}function cr(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function dr(t,e,r){for(let i=e==0,n=e==cr(t);i||n;){if(t==r)return true;let e=sr(t);t=t.parentNode;if(!t)return false;i=i&&e==0;n=n&&e==cr(t)}}function pr(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 mr=function(t){return t.focusNode&&ur(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function wr(t,e){let r=document.createEvent("Event");r.initEvent("keydown",true,true);r.keyCode=t;r.key=r.code=e;return r}function gr(t){let e=t.activeElement;while(e&&e.shadowRoot)e=e.shadowRoot.activeElement;return e}function br(t,e,r){if(t.caretPositionFromPoint){try{let i=t.caretPositionFromPoint(e,r);if(i)return{node:i.offsetNode,offset:i.offset}}catch(t){}}if(t.caretRangeFromPoint){let i=t.caretRangeFromPoint(e,r);if(i)return{node:i.startContainer,offset:i.startOffset}}}const vr=typeof navigator!="undefined"?navigator:null;const yr=typeof document!="undefined"?document:null;const kr=vr&&vr.userAgent||"";const Mr=/Edge\/(\d+)/.exec(kr);const xr=/MSIE \d/.exec(kr);const Sr=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(kr);const Or=!!(xr||Sr||Mr);const Er=xr?document.documentMode:Sr?+Sr[1]:Mr?+Mr[1]:0;const Dr=!Or&&/gecko\/(\d+)/i.test(kr);Dr&&+(/Firefox\/(\d+)/.exec(kr)||[0,0])[1];const Nr=!Or&&/Chrome\/(\d+)/.exec(kr);const Rr=!!Nr;const Cr=Nr?+Nr[1]:0;const qr=!Or&&!!vr&&/Apple Computer/.test(vr.vendor);const Pr=qr&&(/Mobile\/\w+/.test(kr)||!!vr&&vr.maxTouchPoints>2);const $r=Pr||(vr?/Mac/.test(vr.platform):false);const Tr=vr?/Win/.test(vr.platform):false;const Ar=/Android \d/.test(kr);const Ir=!!yr&&"webkitFontSmoothing"in yr.documentElement.style;const zr=Ir?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Jr(t){return{left:0,right:t.documentElement.clientWidth,top:0,bottom:t.documentElement.clientHeight}}function Br(t,e){return typeof t=="number"?t:t[e]}function jr(t){let e=t.getBoundingClientRect();let r=e.width/t.offsetWidth||1;let i=e.height/t.offsetHeight||1;return{left:e.left,right:e.left+t.clientWidth*r,top:e.top,bottom:e.top+t.clientHeight*i}}function Fr(t,e,r){let i=t.someProp("scrollThreshold")||0,n=t.someProp("scrollMargin")||5;let s=t.dom.ownerDocument;for(let l=r||t.dom;;l=lr(l)){if(!l)break;if(l.nodeType!=1)continue;let t=l;let r=t==s.body;let o=r?Jr(s):jr(t);let f=0,u=0;if(e.top<o.top+Br(i,"top"))u=-(o.top-e.top+Br(n,"top"));else if(e.bottom>o.bottom-Br(i,"bottom"))u=e.bottom-e.top>o.bottom-o.top?e.top+Br(n,"top")-o.top:e.bottom-o.bottom+Br(n,"bottom");if(e.left<o.left+Br(i,"left"))f=-(o.left-e.left+Br(n,"left"));else if(e.right>o.right-Br(i,"right"))f=e.right-o.right+Br(n,"right");if(f||u){if(r){s.defaultView.scrollBy(f,u)}else{let r=t.scrollLeft,i=t.scrollTop;if(u)t.scrollTop+=u;if(f)t.scrollLeft+=f;let n=t.scrollLeft-r,s=t.scrollTop-i;e={left:e.left-n,top:e.top-s,right:e.right-n,bottom:e.bottom-s}}}if(r||/^(fixed|sticky)$/.test(getComputedStyle(l).position))break}}function Lr(t){let e=t.dom.getBoundingClientRect(),r=Math.max(0,e.top);let i,n;for(let s=(e.left+e.right)/2,l=r+1;l<Math.min(innerHeight,e.bottom);l+=5){let e=t.root.elementFromPoint(s,l);if(!e||e==t.dom||!t.dom.contains(e))continue;let o=e.getBoundingClientRect();if(o.top>=r-20){i=e;n=o.top;break}}return{refDOM:i,refTop:n,stack:Wr(t.dom)}}function Wr(t){let e=[],r=t.ownerDocument;for(let i=t;i;i=lr(i)){e.push({dom:i,top:i.scrollTop,left:i.scrollLeft});if(t==r)break}return e}function _r({refDOM:t,refTop:e,stack:r}){let i=t?t.getBoundingClientRect().top:0;Ur(r,i==0?0:i-e)}function Ur(t,e){for(let r=0;r<t.length;r++){let{dom:i,top:n,left:s}=t[r];if(i.scrollTop!=n+e)i.scrollTop=n+e;if(i.scrollLeft!=s)i.scrollLeft=s}}let Hr=null;function Kr(t){if(t.setActive)return t.setActive();if(Hr)return t.focus(Hr);let e=Wr(t);t.focus(Hr==null?{get preventScroll(){Hr={preventScroll:true};return true}}:undefined);if(!Hr){Hr=false;Ur(e,0)}}function Gr(t,e){let r,i=2e8,n,s=0;let l=e.top,o=e.top;let f,u;for(let h=t.firstChild,a=0;h;h=h.nextSibling,a++){let t;if(h.nodeType==1)t=h.getClientRects();else if(h.nodeType==3)t=fr(h).getClientRects();else continue;for(let c=0;c<t.length;c++){let d=t[c];if(d.top<=l&&d.bottom>=o){l=Math.max(d.bottom,l);o=Math.min(d.top,o);let t=d.left>e.left?d.left-e.left:d.right<e.left?e.left-d.right:0;if(t<i){r=h;i=t;n=t&&r.nodeType==3?{left:d.right<e.left?d.right:d.left,top:e.top}:e;if(h.nodeType==1&&t)s=a+(e.left>=(d.left+d.right)/2?1:0);continue}}else if(d.top>e.top&&!f&&d.left<=e.left&&d.right>=e.left){f=h;u={left:Math.max(d.left,Math.min(d.right,e.left)),top:d.top}}if(!r&&(e.left>=d.right&&e.top>=d.top||e.left>=d.left&&e.top>=d.bottom))s=a+1}}if(!r&&f){r=f;n=u;i=0}if(r&&r.nodeType==3)return Vr(r,n);if(!r||i&&r.nodeType==1)return{node:t,offset:s};return Gr(r,n)}function Vr(t,e){let r=t.nodeValue.length;let i=document.createRange();for(let n=0;n<r;n++){i.setEnd(t,n+1);i.setStart(t,n);let r=ii(i,1);if(r.top==r.bottom)continue;if(Xr(e,r))return{node:t,offset:n+(e.left>=(r.left+r.right)/2?1:0)}}return{node:t,offset:0}}function Xr(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function Yr(t,e){let r=t.parentNode;if(r&&/^li$/i.test(r.nodeName)&&e.left<t.getBoundingClientRect().left)return r;return t}function Qr(t,e,r){let{node:i,offset:n}=Gr(e,r),s=-1;if(i.nodeType==1&&!i.firstChild){let t=i.getBoundingClientRect();s=t.left!=t.right&&r.left>(t.left+t.right)/2?1:-1}return t.docView.posFromDOM(i,n,s)}function Zr(t,e,r,i){let n=-1;for(let r=e,s=false;;){if(r==t.dom)break;let e=t.docView.nearestDesc(r,true);if(!e)return null;if(e.dom.nodeType==1&&(e.node.isBlock&&e.parent&&!s||!e.contentDOM)){let t=e.dom.getBoundingClientRect();if(e.node.isBlock&&e.parent&&!s){s=true;if(t.left>i.left||t.top>i.top)n=e.posBefore;else if(t.right<i.left||t.bottom<i.top)n=e.posAfter}if(!e.contentDOM&&n<0&&!e.node.isText){let r=e.node.isBlock?i.top<(t.top+t.bottom)/2:i.left<(t.left+t.right)/2;return r?e.posBefore:e.posAfter}}r=e.dom.parentNode}return n>-1?n:t.docView.posFromDOM(e,r,-1)}function ti(t,e,r){let i=t.childNodes.length;if(i&&r.top<r.bottom){for(let n=Math.max(0,Math.min(i-1,Math.floor(i*(e.top-r.top)/(r.bottom-r.top))-2)),s=n;;){let r=t.childNodes[s];if(r.nodeType==1){let t=r.getClientRects();for(let i=0;i<t.length;i++){let n=t[i];if(Xr(e,n))return ti(r,e,n)}}if((s=(s+1)%i)==n)break}}return t}function ei(t,e){let r=t.dom.ownerDocument,i,n=0;let s=br(r,e.left,e.top);if(s)({node:i,offset:n}=s);let l=(t.root.elementFromPoint?t.root:r).elementFromPoint(e.left,e.top);let o;if(!l||!t.dom.contains(l.nodeType!=1?l.parentNode:l)){let r=t.dom.getBoundingClientRect();if(!Xr(e,r))return null;l=ti(t.dom,e,r);if(!l)return null}if(qr){for(let t=l;i&&t;t=lr(t))if(t.draggable)i=undefined}l=Yr(l,e);if(i){if(Dr&&i.nodeType==1){n=Math.min(n,i.childNodes.length);if(n<i.childNodes.length){let t=i.childNodes[n],r;if(t.nodeName=="IMG"&&(r=t.getBoundingClientRect()).right<=e.left&&r.bottom>e.top)n++}}let r;if(Ir&&n&&i.nodeType==1&&(r=i.childNodes[n-1]).nodeType==1&&r.contentEditable=="false"&&r.getBoundingClientRect().top>=e.top)n--;if(i==t.dom&&n==i.childNodes.length-1&&i.lastChild.nodeType==1&&e.top>i.lastChild.getBoundingClientRect().bottom)o=t.state.doc.content.size;else if(n==0||i.nodeType!=1||i.childNodes[n-1].nodeName!="BR")o=Zr(t,i,n,e)}if(o==null)o=Qr(t,l,e);let f=t.docView.nearestDesc(l,true);return{pos:o,inside:f?f.posAtStart-f.border:-1}}function ri(t){return t.top<t.bottom||t.left<t.right}function ii(t,e){let r=t.getClientRects();if(r.length){let t=r[e<0?0:r.length-1];if(ri(t))return t}return Array.prototype.find.call(r,ri)||t.getBoundingClientRect()}const ni=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function si(t,e,r){let{node:i,offset:n,atom:s}=t.docView.domFromPos(e,r<0?-1:1);let l=Ir||Dr;if(i.nodeType==3){if(l&&(ni.test(i.nodeValue)||(r<0?!n:n==i.nodeValue.length))){let t=ii(fr(i,n,n),r);if(Dr&&n&&/\s/.test(i.nodeValue[n-1])&&n<i.nodeValue.length){let e=ii(fr(i,n-1,n-1),-1);if(e.top==t.top){let r=ii(fr(i,n,n+1),-1);if(r.top!=t.top)return li(r,r.left<e.left)}}return t}else{let t=n,e=n,s=r<0?1:-1;if(r<0&&!n){e++;s=-1}else if(r>=0&&n==i.nodeValue.length){t--;s=1}else if(r<0){t--}else{e++}return li(ii(fr(i,t,e),s),s<0)}}let o=t.state.doc.resolve(e-(s||0));if(!o.parent.inlineContent){if(s==null&&n&&(r<0||n==cr(i))){let t=i.childNodes[n-1];if(t.nodeType==1)return oi(t.getBoundingClientRect(),false)}if(s==null&&n<cr(i)){let t=i.childNodes[n];if(t.nodeType==1)return oi(t.getBoundingClientRect(),true)}return oi(i.getBoundingClientRect(),r>=0)}if(s==null&&n&&(r<0||n==cr(i))){let t=i.childNodes[n-1];let e=t.nodeType==3?fr(t,cr(t)-(l?0:1)):t.nodeType==1&&(t.nodeName!="BR"||!t.nextSibling)?t:null;if(e)return li(ii(e,1),false)}if(s==null&&n<cr(i)){let t=i.childNodes[n];while(t.pmViewDesc&&t.pmViewDesc.ignoreForCoords)t=t.nextSibling;let e=!t?null:t.nodeType==3?fr(t,0,l?0:1):t.nodeType==1?t:null;if(e)return li(ii(e,-1),true)}return li(ii(i.nodeType==3?fr(i):i,-r),r>=0)}function li(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 oi(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 fi(t,e,r){let i=t.state,n=t.root.activeElement;if(i!=e)t.updateState(e);if(n!=t.dom)t.focus();try{return r()}finally{if(i!=e)t.updateState(i);if(n!=t.dom&&n)n.focus()}}function ui(t,e,r){let i=e.selection;let n=r=="up"?i.$from:i.$to;return fi(t,e,(()=>{let{node:e}=t.docView.domFromPos(n.pos,r=="up"?-1:1);for(;;){let r=t.docView.nearestDesc(e,true);if(!r)break;if(r.node.isBlock){e=r.contentDOM||r.dom;break}e=r.dom.parentNode}let i=si(t,n.pos,1);for(let t=e.firstChild;t;t=t.nextSibling){let e;if(t.nodeType==1)e=t.getClientRects();else if(t.nodeType==3)e=fr(t,0,t.nodeValue.length).getClientRects();else continue;for(let t=0;t<e.length;t++){let n=e[t];if(n.bottom>n.top+1&&(r=="up"?i.top-n.top>(n.bottom-i.top)*2:n.bottom-i.bottom>(i.bottom-n.top)*2))return false}}return true}))}const hi=/[\u0590-\u08ac]/;function ai(t,e,r){let{$head:i}=e.selection;if(!i.parent.isTextblock)return false;let n=i.parentOffset,s=!n,l=n==i.parent.content.size;let o=t.domSelection();if(!hi.test(i.parent.textContent)||!o.modify)return r=="left"||r=="backward"?s:l;return fi(t,e,(()=>{let{focusNode:e,focusOffset:n,anchorNode:s,anchorOffset:l}=t.domSelectionRange();let f=o.caretBidiLevel;o.modify("move",r,"character");let u=i.depth?t.docView.domAfterPos(i.before()):t.dom;let{focusNode:h,focusOffset:a}=t.domSelectionRange();let c=h&&!u.contains(h.nodeType==1?h:h.parentNode)||e==h&&n==a;try{o.collapse(s,l);if(e&&(e!=s||n!=l)&&o.extend)o.extend(e,n)}catch(t){}if(f!=null)o.caretBidiLevel=f;return c}))}let ci=null;let di=null;let pi=false;function mi(t,e,r){if(ci==e&&di==r)return pi;ci=e;di=r;return pi=r=="up"||r=="down"?ui(t,e,r):ai(t,e,r)}const wi=0,gi=1,bi=2,vi=3;class yi{constructor(t,e,r,i){this.parent=t;this.children=e;this.dom=r;this.contentDOM=i;this.dirty=wi;r.pmViewDesc=this}matchesWidget(t){return false}matchesMark(t){return false}matchesNode(t,e,r){return false}matchesHack(t){return false}parseRule(){return null}stopEvent(t){return false}get size(){let t=0;for(let e=0;e<this.children.length;e++)t+=this.children[e].size;return t}get border(){return 0}destroy(){this.parent=undefined;if(this.dom.pmViewDesc==this)this.dom.pmViewDesc=undefined;for(let t=0;t<this.children.length;t++)this.children[t].destroy()}posBeforeChild(t){for(let e=0,r=this.posAtStart;;e++){let i=this.children[e];if(i==t)return r;r+=i.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(t,e,r){if(this.contentDOM&&this.contentDOM.contains(t.nodeType==1?t:t.parentNode)){if(r<0){let r,i;if(t==this.contentDOM){r=t.childNodes[e-1]}else{while(t.parentNode!=this.contentDOM)t=t.parentNode;r=t.previousSibling}while(r&&!((i=r.pmViewDesc)&&i.parent==this))r=r.previousSibling;return r?this.posBeforeChild(i)+i.size:this.posAtStart}else{let r,i;if(t==this.contentDOM){r=t.childNodes[e]}else{while(t.parentNode!=this.contentDOM)t=t.parentNode;r=t.nextSibling}while(r&&!((i=r.pmViewDesc)&&i.parent==this))r=r.nextSibling;return r?this.posBeforeChild(i):this.posAtEnd}}let i;if(t==this.dom&&this.contentDOM){i=e>sr(this.contentDOM)}else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM)){i=t.compareDocumentPosition(this.contentDOM)&2}else if(this.dom.firstChild){if(e==0)for(let e=t;;e=e.parentNode){if(e==this.dom){i=false;break}if(e.previousSibling)break}if(i==null&&e==t.childNodes.length)for(let e=t;;e=e.parentNode){if(e==this.dom){i=true;break}if(e.nextSibling)break}}return(i==null?r>0:i)?this.posAtEnd:this.posAtStart}nearestDesc(t,e=false){for(let r=true,i=t;i;i=i.parentNode){let n=this.getDesc(i),s;if(n&&(!e||n.node)){if(r&&(s=n.nodeDOM)&&!(s.nodeType==1?s.contains(t.nodeType==1?t:t.parentNode):s==t))r=false;else return n}}}getDesc(t){let e=t.pmViewDesc;for(let t=e;t;t=t.parent)if(t==this)return e}posFromDOM(t,e,r){for(let i=t;i;i=i.parentNode){let n=this.getDesc(i);if(n)return n.localPosFromDOM(t,e,r)}return-1}descAt(t){for(let e=0,r=0;e<this.children.length;e++){let i=this.children[e],n=r+i.size;if(r==t&&n!=r){while(!i.border&&i.children.length)i=i.children[0];return i}if(t<n)return i.descAt(t-r-i.border);r=n}}domFromPos(t,e){if(!this.contentDOM)return{node:this.dom,offset:0,atom:t+1};let r=0,i=0;for(let e=0;r<this.children.length;r++){let n=this.children[r],s=e+n.size;if(s>t||n instanceof Di){i=t-e;break}e=s}if(i)return this.children[r].domFromPos(i-this.children[r].border,e);for(let t;r&&!(t=this.children[r-1]).size&&t instanceof ki&&t.side>=0;r--){}if(e<=0){let t,i=true;for(;;r--,i=false){t=r?this.children[r-1]:null;if(!t||t.dom.parentNode==this.contentDOM)break}if(t&&e&&i&&!t.border&&!t.domAtom)return t.domFromPos(t.size,e);return{node:this.contentDOM,offset:t?sr(t.dom)+1:0}}else{let t,i=true;for(;;r++,i=false){t=r<this.children.length?this.children[r]:null;if(!t||t.dom.parentNode==this.contentDOM)break}if(t&&i&&!t.border&&!t.domAtom)return t.domFromPos(0,e);return{node:this.contentDOM,offset:t?sr(t.dom):this.contentDOM.childNodes.length}}}parseRange(t,e,r=0){if(this.children.length==0)return{node:this.contentDOM,from:t,to:e,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let i=-1,n=-1;for(let s=r,l=0;;l++){let r=this.children[l],o=s+r.size;if(i==-1&&t<=o){let n=s+r.border;if(t>=n&&e<=o-r.border&&r.node&&r.contentDOM&&this.contentDOM.contains(r.contentDOM))return r.parseRange(t,e,n);t=s;for(let e=l;e>0;e--){let r=this.children[e-1];if(r.size&&r.dom.parentNode==this.contentDOM&&!r.emptyChildAt(1)){i=sr(r.dom)+1;break}t-=r.size}if(i==-1)i=0}if(i>-1&&(o>e||l==this.children.length-1)){e=o;for(let t=l+1;t<this.children.length;t++){let r=this.children[t];if(r.size&&r.dom.parentNode==this.contentDOM&&!r.emptyChildAt(-1)){n=sr(r.dom);break}e+=r.size}if(n==-1)n=this.contentDOM.childNodes.length;break}s=o}return{node:this.contentDOM,from:t,to:e,fromOffset:i,toOffset:n}}emptyChildAt(t){if(this.border||!this.contentDOM||!this.children.length)return false;let e=this.children[t<0?0:this.children.length-1];return e.size==0||e.emptyChildAt(t)}domAfterPos(t){let{node:e,offset:r}=this.domFromPos(t,0);if(e.nodeType!=1||r==e.childNodes.length)throw new RangeError("No node after pos "+t);return e.childNodes[r]}setSelection(t,e,r,i=false){let n=Math.min(t,e),s=Math.max(t,e);for(let l=0,o=0;l<this.children.length;l++){let f=this.children[l],u=o+f.size;if(n>o&&s<u)return f.setSelection(t-o-f.border,e-o-f.border,r,i);o=u}let l=this.domFromPos(t,t?-1:1);let o=e==t?l:this.domFromPos(e,e?-1:1);let f=r.getSelection();let u=false;if((Dr||qr)&&t==e){let{node:t,offset:e}=l;if(t.nodeType==3){u=!!(e&&t.nodeValue[e-1]=="\n");if(u&&e==t.nodeValue.length){for(let e=t,r;e;e=e.parentNode){if(r=e.nextSibling){if(r.nodeName=="BR")l=o={node:r.parentNode,offset:sr(r)+1};break}let t=e.pmViewDesc;if(t&&t.node&&t.node.isBlock)break}}}else{let r=t.childNodes[e-1];u=r&&(r.nodeName=="BR"||r.contentEditable=="false")}}if(Dr&&f.focusNode&&f.focusNode!=o.node&&f.focusNode.nodeType==1){let t=f.focusNode.childNodes[f.focusOffset];if(t&&t.contentEditable=="false")i=true}if(!(i||u&&qr)&&ur(l.node,l.offset,f.anchorNode,f.anchorOffset)&&ur(o.node,o.offset,f.focusNode,f.focusOffset))return;let h=false;if((f.extend||t==e)&&!u){f.collapse(l.node,l.offset);try{if(t!=e)f.extend(o.node,o.offset);h=true}catch(t){}}if(!h){if(t>e){let t=l;l=o;o=t}let r=document.createRange();r.setEnd(o.node,o.offset);r.setStart(l.node,l.offset);f.removeAllRanges();f.addRange(r)}}ignoreMutation(t){return!this.contentDOM&&t.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(t,e){for(let r=0,i=0;i<this.children.length;i++){let n=this.children[i],s=r+n.size;if(r==s?t<=s&&e>=r:t<s&&e>r){let i=r+n.border,l=s-n.border;if(t>=i&&e<=l){this.dirty=t==r||e==s?bi:gi;if(t==i&&e==l&&(n.contentLost||n.dom.parentNode!=this.contentDOM))n.dirty=vi;else n.markDirty(t-i,e-i);return}else{n.dirty=n.dom==n.contentDOM&&n.dom.parentNode==this.contentDOM&&!n.children.length?bi:vi}}r=s}this.dirty=bi}markParentsDirty(){let t=1;for(let e=this.parent;e;e=e.parent,t++){let r=t==1?bi:gi;if(e.dirty<r)e.dirty=r}}get domAtom(){return false}get ignoreForCoords(){return false}}class ki extends yi{constructor(t,e,r,i){let n,s=e.type.toDOM;if(typeof s=="function")s=s(r,(()=>{if(!n)return i;if(n.parent)return n.parent.posBeforeChild(n)}));if(!e.type.spec.raw){if(s.nodeType!=1){let t=document.createElement("span");t.appendChild(s);s=t}s.contentEditable="false";s.classList.add("ProseMirror-widget")}super(t,[],s,null);this.widget=e;this.widget=e;n=this}matchesWidget(t){return this.dirty==wi&&t.type.eq(this.widget.type)}parseRule(){return{ignore:true}}stopEvent(t){let e=this.widget.spec.stopEvent;return e?e(t):false}ignoreMutation(t){return t.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom);super.destroy()}get domAtom(){return true}get side(){return this.widget.type.side}}class Mi extends yi{constructor(t,e,r,i){super(t,[],e,null);this.textDOM=r;this.text=i}get size(){return this.text.length}localPosFromDOM(t,e){if(t!=this.textDOM)return this.posAtStart+(e?this.size:0);return this.posAtStart+e}domFromPos(t){return{node:this.textDOM,offset:t}}ignoreMutation(t){return t.type==="characterData"&&t.target.nodeValue==t.oldValue}}class xi extends yi{constructor(t,e,r,i){super(t,[],r,i);this.mark=e}static create(t,e,r,i){let n=i.nodeViews[e.type.name];let s=n&&n(e,i,r);if(!s||!s.dom)s=vt.renderSpec(document,e.type.spec.toDOM(e,r));return new xi(t,e,s.dom,s.contentDOM||s.dom)}parseRule(){if(this.dirty&vi||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!=vi&&this.mark.eq(t)}markDirty(t,e){super.markDirty(t,e);if(this.dirty!=wi){let t=this.parent;while(!t.node)t=t.parent;if(t.dirty<this.dirty)t.dirty=this.dirty;this.dirty=wi}}slice(t,e,r){let i=xi.create(this.parent,this.mark,true,r);let n=this.children,s=this.size;if(e<s)n=Ui(n,e,s,r);if(t>0)n=Ui(n,0,t,r);for(let t=0;t<n.length;t++)n[t].parent=i;i.children=n;return i}}class Si extends yi{constructor(t,e,r,i,n,s,l,o,f){super(t,[],n,s);this.node=e;this.outerDeco=r;this.innerDeco=i;this.nodeDOM=l}static create(t,e,r,i,n,s){let l=n.nodeViews[e.type.name],o;let f=l&&l(e,n,(()=>{if(!o)return s;if(o.parent)return o.parent.posBeforeChild(o)}),r,i);let u=f&&f.dom,h=f&&f.contentDOM;if(e.isText){if(!u)u=document.createTextNode(e.text);else if(u.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else if(!u){({dom:u,contentDOM:h}=vt.renderSpec(document,e.type.spec.toDOM(e)))}if(!h&&!e.isText&&u.nodeName!="BR"){if(!u.hasAttribute("contenteditable"))u.contentEditable="false";if(e.type.spec.draggable)u.draggable=true}let a=u;u=Ai(u,r,e);if(f)return o=new Ni(t,e,r,i,u,h||null,a,f,n,s+1);else if(e.isText)return new Ei(t,e,r,i,u,a,n);else return new Si(t,e,r,i,u,h||null,a,n,s+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let t={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre")t.preserveWhitespace="full";if(!this.contentDOM){t.getContent=()=>this.node.content}else if(!this.contentLost){t.contentElement=this.contentDOM}else{for(let e=this.children.length-1;e>=0;e--){let r=this.children[e];if(this.dom.contains(r.dom.parentNode)){t.contentElement=r.dom.parentNode;break}}if(!t.contentElement)t.getContent=()=>o.empty}return t}matchesNode(t,e,r){return this.dirty==wi&&t.eq(this.node)&&Ii(e,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(t,e){let r=this.node.inlineContent,i=e;let n=t.composing?this.localCompositionInfo(t,e):null;let s=n&&n.pos>-1?n:null;let l=n&&n.pos<0;let o=new Ji(this,s&&s.node,t);Fi(this.node,this.innerDeco,((e,n,s)=>{if(e.spec.marks)o.syncToMarks(e.spec.marks,r,t);else if(e.type.side>=0&&!s)o.syncToMarks(n==this.node.childCount?a.none:this.node.child(n).marks,r,t);o.placeWidget(e,t,i)}),((e,s,f,u)=>{o.syncToMarks(e.marks,r,t);let h;if(o.findNodeMatch(e,s,f,u));else if(l&&t.state.selection.from>i&&t.state.selection.to<i+e.nodeSize&&(h=o.findIndexWithChild(n.node))>-1&&o.updateNodeAt(e,s,f,h,t));else if(o.updateNextNode(e,s,f,t,u,i));else{o.addNode(e,s,f,t,i)}i+=e.nodeSize}));o.syncToMarks([],r,t);if(this.node.isTextblock)o.addTextblockHacks();o.destroyRest();if(o.changed||this.dirty==bi){if(s)this.protectLocalComposition(t,s);Ri(this.contentDOM,this.children,t);if(Pr)Li(this.dom)}}localCompositionInfo(t,e){let{from:r,to:i}=t.state.selection;if(!(t.state.selection instanceof ze)||r<e||i>e+this.node.content.size)return null;let n=t.domSelectionRange();let s=Wi(n.focusNode,n.focusOffset);if(!s||!this.dom.contains(s.parentNode))return null;if(this.node.inlineContent){let t=s.nodeValue;let n=_i(this.node.content,t,r-e,i-e);return n<0?null:{node:s,pos:n,text:t}}else{return{node:s,pos:-1,text:""}}}protectLocalComposition(t,{node:e,pos:r,text:i}){if(this.getDesc(e))return;let n=e;for(;;n=n.parentNode){if(n.parentNode==this.contentDOM)break;while(n.previousSibling)n.parentNode.removeChild(n.previousSibling);while(n.nextSibling)n.parentNode.removeChild(n.nextSibling);if(n.pmViewDesc)n.pmViewDesc=undefined}let s=new Mi(this,n,e,i);t.input.compositionNodes.push(s);this.children=Ui(this.children,r,r+i.length,t,s)}update(t,e,r,i){if(this.dirty==vi||!t.sameMarkup(this.node))return false;this.updateInner(t,e,r,i);return true}updateInner(t,e,r,i){this.updateOuterDeco(e);this.node=t;this.innerDeco=r;if(this.contentDOM)this.updateChildren(i,this.posAtStart);this.dirty=wi}updateOuterDeco(t){if(Ii(t,this.outerDeco))return;let e=this.nodeDOM.nodeType!=1;let r=this.dom;this.dom=$i(this.dom,this.nodeDOM,Pi(this.outerDeco,this.node,e),Pi(t,this.node,e));if(this.dom!=r){r.pmViewDesc=undefined;this.dom.pmViewDesc=this}this.outerDeco=t}selectNode(){if(this.nodeDOM.nodeType==1)this.nodeDOM.classList.add("ProseMirror-selectednode");if(this.contentDOM||!this.node.type.spec.draggable)this.dom.draggable=true}deselectNode(){if(this.nodeDOM.nodeType==1)this.nodeDOM.classList.remove("ProseMirror-selectednode");if(this.contentDOM||!this.node.type.spec.draggable)this.dom.removeAttribute("draggable")}get domAtom(){return this.node.isAtom}}function Oi(t,e,r,i,n){Ai(i,e,t);let s=new Si(undefined,t,e,r,i,i,i,n,0);if(s.contentDOM)s.updateChildren(n,0);return s}class Ei extends Si{constructor(t,e,r,i,n,s,l){super(t,e,r,i,n,null,s,l,0)}parseRule(){let t=this.nodeDOM.parentNode;while(t&&t!=this.dom&&!t.pmIsDeco)t=t.parentNode;return{skip:t||true}}update(t,e,r,i){if(this.dirty==vi||this.dirty!=wi&&!this.inParent()||!t.sameMarkup(this.node))return false;this.updateOuterDeco(e);if((this.dirty!=wi||t.text!=this.node.text)&&t.text!=this.nodeDOM.nodeValue){this.nodeDOM.nodeValue=t.text;if(i.trackWrites==this.nodeDOM)i.trackWrites=null}this.node=t;this.dirty=wi;return true}inParent(){let t=this.parent.contentDOM;for(let e=this.nodeDOM;e;e=e.parentNode)if(e==t)return true;return false}domFromPos(t){return{node:this.nodeDOM,offset:t}}localPosFromDOM(t,e,r){if(t==this.nodeDOM)return this.posAtStart+Math.min(e,this.node.text.length);return super.localPosFromDOM(t,e,r)}ignoreMutation(t){return t.type!="characterData"&&t.type!="selection"}slice(t,e,r){let i=this.node.cut(t,e),n=document.createTextNode(i.text);return new Ei(this.parent,i,this.outerDeco,this.innerDeco,n,n,r)}markDirty(t,e){super.markDirty(t,e);if(this.dom!=this.nodeDOM&&(t==0||e==this.nodeDOM.nodeValue.length))this.dirty=vi}get domAtom(){return false}}class Di extends yi{parseRule(){return{ignore:true}}matchesHack(t){return this.dirty==wi&&this.dom.nodeName==t}get domAtom(){return true}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class Ni extends Si{constructor(t,e,r,i,n,s,l,o,f,u){super(t,e,r,i,n,s,l,f,u);this.spec=o}update(t,e,r,i){if(this.dirty==vi)return false;if(this.spec.update){let n=this.spec.update(t,e,r);if(n)this.updateInner(t,e,r,i);return n}else if(!this.contentDOM&&!t.isLeaf){return false}else{return super.update(t,e,r,i)}}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(t,e,r,i){this.spec.setSelection?this.spec.setSelection(t,e,r):super.setSelection(t,e,r,i)}destroy(){if(this.spec.destroy)this.spec.destroy();super.destroy()}stopEvent(t){return this.spec.stopEvent?this.spec.stopEvent(t):false}ignoreMutation(t){return this.spec.ignoreMutation?this.spec.ignoreMutation(t):super.ignoreMutation(t)}}function Ri(t,e,r){let i=t.firstChild,n=false;for(let s=0;s<e.length;s++){let l=e[s],o=l.dom;if(o.parentNode==t){while(o!=i){i=zi(i);n=true}i=i.nextSibling}else{n=true;t.insertBefore(o,i)}if(l instanceof xi){let e=i?i.previousSibling:t.lastChild;Ri(l.contentDOM,l.children,r);i=e?e.nextSibling:t.firstChild}}while(i){i=zi(i);n=true}if(n&&r.trackWrites==t)r.trackWrites=null}const Ci=function(t){if(t)this.nodeName=t};Ci.prototype=Object.create(null);const qi=[new Ci];function Pi(t,e,r){if(t.length==0)return qi;let i=r?qi[0]:new Ci,n=[i];for(let s=0;s<t.length;s++){let l=t[s].type.attrs;if(!l)continue;if(l.nodeName)n.push(i=new Ci(l.nodeName));for(let t in l){let s=l[t];if(s==null)continue;if(r&&n.length==1)n.push(i=new Ci(e.isInline?"span":"div"));if(t=="class")i.class=(i.class?i.class+" ":"")+s;else if(t=="style")i.style=(i.style?i.style+";":"")+s;else if(t!="nodeName")i[t]=s}}return n}function $i(t,e,r,i){if(r==qi&&i==qi)return e;let n=e;for(let e=0;e<i.length;e++){let s=i[e],l=r[e];if(e){let e;if(l&&l.nodeName==s.nodeName&&n!=t&&(e=n.parentNode)&&e.nodeName.toLowerCase()==s.nodeName){n=e}else{e=document.createElement(s.nodeName);e.pmIsDeco=true;e.appendChild(n);l=qi[0];n=e}}Ti(n,l||qi[0],s)}return n}function Ti(t,e,r){for(let i in e)if(i!="class"&&i!="style"&&i!="nodeName"&&!(i in r))t.removeAttribute(i);for(let i in r)if(i!="class"&&i!="style"&&i!="nodeName"&&r[i]!=e[i])t.setAttribute(i,r[i]);if(e.class!=r.class){let i=e.class?e.class.split(" ").filter(Boolean):[];let n=r.class?r.class.split(" ").filter(Boolean):[];for(let e=0;e<i.length;e++)if(n.indexOf(i[e])==-1)t.classList.remove(i[e]);for(let e=0;e<n.length;e++)if(i.indexOf(n[e])==-1)t.classList.add(n[e]);if(t.classList.length==0)t.removeAttribute("class")}if(e.style!=r.style){if(e.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,i;while(i=r.exec(e.style))t.style.removeProperty(i[1])}if(r.style)t.style.cssText+=r.style}}function Ai(t,e,r){return $i(t,t,qi,Pi(e,r,t.nodeType!=1))}function Ii(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 zi(t){let e=t.nextSibling;t.parentNode.removeChild(t);return e}class Ji{constructor(t,e,r){this.lock=e;this.view=r;this.index=0;this.stack=[];this.changed=false;this.top=t;this.preMatch=Bi(t.node.content,t)}destroyBetween(t,e){if(t==e)return;for(let r=t;r<e;r++)this.top.children[r].destroy();this.top.children.splice(t,e-t);this.changed=true}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(t,e,r){let i=0,n=this.stack.length>>1;let s=Math.min(n,t.length);while(i<s&&(i==n-1?this.top:this.stack[i+1<<1]).matchesMark(t[i])&&t[i].type.spec.spanning!==false)i++;while(i<n){this.destroyRest();this.top.dirty=wi;this.index=this.stack.pop();this.top=this.stack.pop();n--}while(n<t.length){this.stack.push(this.top,this.index+1);let i=-1;for(let e=this.index;e<Math.min(this.index+3,this.top.children.length);e++){let r=this.top.children[e];if(r.matchesMark(t[n])&&!this.isLocked(r.dom)){i=e;break}}if(i>-1){if(i>this.index){this.changed=true;this.destroyBetween(this.index,i)}this.top=this.top.children[this.index]}else{let i=xi.create(this.top,t[n],e,r);this.top.children.splice(this.index,0,i);this.top=i;this.changed=true}this.index=0;n++}}findNodeMatch(t,e,r,i){let n=-1,s;if(i>=this.preMatch.index&&(s=this.preMatch.matches[i-this.preMatch.index]).parent==this.top&&s.matchesNode(t,e,r)){n=this.top.children.indexOf(s,this.index)}else{for(let i=this.index,s=Math.min(this.top.children.length,i+5);i<s;i++){let s=this.top.children[i];if(s.matchesNode(t,e,r)&&!this.preMatch.matched.has(s)){n=i;break}}}if(n<0)return false;this.destroyBetween(this.index,n);this.index++;return true}updateNodeAt(t,e,r,i,n){let s=this.top.children[i];if(s.dirty==vi&&s.dom==s.contentDOM)s.dirty=bi;if(!s.update(t,e,r,n))return false;this.destroyBetween(this.index,i);this.index++;return true}findIndexWithChild(t){for(;;){let e=t.parentNode;if(!e)return-1;if(e==this.top.contentDOM){let e=t.pmViewDesc;if(e)for(let t=this.index;t<this.top.children.length;t++){if(this.top.children[t]==e)return t}return-1}t=e}}updateNextNode(t,e,r,i,n,s){for(let l=this.index;l<this.top.children.length;l++){let o=this.top.children[l];if(o instanceof Si){let f=this.preMatch.matched.get(o);if(f!=null&&f!=n)return false;let u=o.dom,h;let a=this.isLocked(u)&&!(t.isText&&o.node&&o.node.isText&&o.nodeDOM.nodeValue==t.text&&o.dirty!=vi&&Ii(e,o.outerDeco));if(!a&&o.update(t,e,r,i)){this.destroyBetween(this.index,l);if(o.dom!=u)this.changed=true;this.index++;return true}else if(!a&&(h=this.recreateWrapper(o,t,e,r,i,s))){this.top.children[this.index]=h;if(h.contentDOM){h.dirty=bi;h.updateChildren(i,s+1);h.dirty=wi}this.changed=true;this.index++;return true}break}}return false}recreateWrapper(t,e,r,i,n,s){if(t.dirty||e.isAtom||!t.children.length||!t.node.content.eq(e.content))return null;let l=Si.create(this.top,e,r,i,n,s);if(l.contentDOM){l.children=t.children;t.children=[];for(let t of l.children)t.parent=l}t.destroy();return l}addNode(t,e,r,i,n){let s=Si.create(this.top,t,e,r,i,n);if(s.contentDOM)s.updateChildren(i,n+1);this.top.children.splice(this.index++,0,s);this.changed=true}placeWidget(t,e,r){let i=this.index<this.top.children.length?this.top.children[this.index]:null;if(i&&i.matchesWidget(t)&&(t==i.widget||!i.widget.type.toDOM.parentNode)){this.index++}else{let i=new ki(this.top,t,e,r);this.top.children.splice(this.index++,0,i);this.changed=true}}addTextblockHacks(){let t=this.top.children[this.index-1],e=this.top;while(t instanceof xi){e=t;t=e.children[e.children.length-1]}if(!t||!(t instanceof Ei)||/\n$/.test(t.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(t.node.text)){if((qr||Rr)&&t&&t.dom.contentEditable=="false")this.addHackNode("IMG",e);this.addHackNode("BR",this.top)}}addHackNode(t,e){if(e==this.top&&this.index<e.children.length&&e.children[this.index].matchesHack(t)){this.index++}else{let r=document.createElement(t);if(t=="IMG"){r.className="ProseMirror-separator";r.alt=""}if(t=="BR")r.className="ProseMirror-trailingBreak";let i=new Di(this.top,[],r,null);if(e!=this.top)e.children.push(i);else e.children.splice(this.index++,0,i);this.changed=true}}isLocked(t){return this.lock&&(t==this.lock||t.nodeType==1&&t.contains(this.lock.parentNode))}}function Bi(t,e){let r=e,i=r.children.length;let n=t.childCount,s=new Map,l=[];t:while(n>0){let o;for(;;){if(i){let t=r.children[i-1];if(t instanceof xi){r=t;i=t.children.length}else{o=t;i--;break}}else if(r==e){break t}else{i=r.parent.children.indexOf(r);r=r.parent}}let f=o.node;if(!f)continue;if(f!=t.child(n-1))break;--n;s.set(o,n);l.push(o)}return{index:n,matched:s,matches:l.reverse()}}function ji(t,e){return t.type.side-e.type.side}function Fi(t,e,r,i){let n=e.locals(t),s=0;if(n.length==0){for(let r=0;r<t.childCount;r++){let l=t.child(r);i(l,n,e.forChild(s,l),r);s+=l.nodeSize}return}let l=0,o=[],f=null;for(let u=0;;){let h,a;while(l<n.length&&n[l].to==s){let t=n[l++];if(t.widget){if(!h)h=t;else(a||(a=[h])).push(t)}}if(h){if(a){a.sort(ji);for(let t=0;t<a.length;t++)r(a[t],u,!!f)}else{r(h,u,!!f)}}let c,d;if(f){d=-1;c=f;f=null}else if(u<t.childCount){d=u;c=t.child(u++)}else{break}for(let t=0;t<o.length;t++)if(o[t].to<=s)o.splice(t--,1);while(l<n.length&&n[l].from<=s&&n[l].to>s)o.push(n[l++]);let p=s+c.nodeSize;if(c.isText){let t=p;if(l<n.length&&n[l].from<t)t=n[l].from;for(let e=0;e<o.length;e++)if(o[e].to<t)t=o[e].to;if(t<p){f=c.cut(t-s);c=c.cut(0,t-s);p=t;d=-1}}else{while(l<n.length&&n[l].to<p)l++}let m=c.isInline&&!c.isLeaf?o.filter((t=>!t.inline)):o.slice();i(c,m,e.forChild(s,c),d);s=p}}function Li(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 Wi(t,e){for(;;){if(t.nodeType==3)return t;if(t.nodeType==1&&e>0){if(t.childNodes.length>e&&t.childNodes[e].nodeType==3)return t.childNodes[e];t=t.childNodes[e-1];e=cr(t)}else if(t.nodeType==1&&e<t.childNodes.length){t=t.childNodes[e];e=0}else{return null}}}function _i(t,e,r,i){for(let n=0,s=0;n<t.childCount&&s<=i;){let l=t.child(n++),o=s;s+=l.nodeSize;if(!l.isText)continue;let f=l.text;while(n<t.childCount){let e=t.child(n++);s+=e.nodeSize;if(!e.isText)break;f+=e.text}if(s>=r){if(s>=i&&f.slice(i-e.length-o,i-o)==e)return i-e.length;let t=o<i?f.lastIndexOf(e,i-o-1):-1;if(t>=0&&t+e.length+o>=r)return o+t;if(r==i&&f.length>=i+e.length-o&&f.slice(i-o,i-o+e.length)==e)return i}}return-1}function Ui(t,e,r,i,n){let s=[];for(let l=0,o=0;l<t.length;l++){let f=t[l],u=o,h=o+=f.size;if(u>=r||h<=e){s.push(f)}else{if(u<e)s.push(f.slice(0,e-u,i));if(n){s.push(n);n=undefined}if(h>r)s.push(f.slice(r-u,f.size,i))}}return s}function Hi(t,e=null){let r=t.domSelectionRange(),i=t.state.doc;if(!r.focusNode)return null;let n=t.docView.nearestDesc(r.focusNode),s=n&&n.size==0;let l=t.docView.posFromDOM(r.focusNode,r.focusOffset,1);if(l<0)return null;let o=i.resolve(l),f,u;if(mr(r)){f=o;while(n&&!n.node)n=n.parent;let t=n.node;if(n&&t.isAtom&&Be.isSelectable(t)&&n.parent&&!(t.isInline&&dr(r.focusNode,r.focusOffset,n.dom))){let t=n.posBefore;u=new Be(l==t?o:i.resolve(t))}}else{let e=t.docView.posFromDOM(r.anchorNode,r.anchorOffset,1);if(e<0)return null;f=i.resolve(e)}if(!u){let r=e=="pointer"||t.state.selection.head<o.pos&&!s?1:-1;u=nn(t,f,o,r)}return u}function Ki(t){return t.editable?t.hasFocus():ln(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function Gi(t,e=false){let r=t.state.selection;en(t,r);if(!Ki(t))return;if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&Rr){let e=t.domSelectionRange(),r=t.domObserver.currentSelection;if(e.anchorNode&&r.anchorNode&&ur(e.anchorNode,e.anchorOffset,r.anchorNode,r.anchorOffset)){t.input.mouseDown.delayedSelectionSync=true;t.domObserver.setCurSelection();return}}t.domObserver.disconnectSelection();if(t.cursorWrapper){tn(t)}else{let{anchor:i,head:n}=r,s,l;if(Vi&&!(r instanceof ze)){if(!r.$from.parent.inlineContent)s=Xi(t,r.from);if(!r.empty&&!r.$from.parent.inlineContent)l=Xi(t,r.to)}t.docView.setSelection(i,n,t.root,e);if(Vi){if(s)Qi(s);if(l)Qi(l)}if(r.visible){t.dom.classList.remove("ProseMirror-hideselection")}else{t.dom.classList.add("ProseMirror-hideselection");if("onselectionchange"in document)Zi(t)}}t.domObserver.setCurSelection();t.domObserver.connectSelection()}const Vi=qr||Rr&&Cr<63;function Xi(t,e){let{node:r,offset:i}=t.docView.domFromPos(e,0);let n=i<r.childNodes.length?r.childNodes[i]:null;let s=i?r.childNodes[i-1]:null;if(qr&&n&&n.contentEditable=="false")return Yi(n);if((!n||n.contentEditable=="false")&&(!s||s.contentEditable=="false")){if(n)return Yi(n);else if(s)return Yi(s)}}function Yi(t){t.contentEditable="true";if(qr&&t.draggable){t.draggable=false;t.wasDraggable=true}return t}function Qi(t){t.contentEditable="false";if(t.wasDraggable){t.draggable=true;t.wasDraggable=null}}function Zi(t){let e=t.dom.ownerDocument;e.removeEventListener("selectionchange",t.input.hideSelectionGuard);let r=t.domSelectionRange();let i=r.anchorNode,n=r.anchorOffset;e.addEventListener("selectionchange",t.input.hideSelectionGuard=()=>{if(r.anchorNode!=i||r.anchorOffset!=n){e.removeEventListener("selectionchange",t.input.hideSelectionGuard);setTimeout((()=>{if(!Ki(t)||t.state.selection.visible)t.dom.classList.remove("ProseMirror-hideselection")}),20)}})}function tn(t){let e=t.domSelection(),r=document.createRange();let i=t.cursorWrapper.dom,n=i.nodeName=="IMG";if(n)r.setEnd(i.parentNode,sr(i)+1);else r.setEnd(i,0);r.collapse(false);e.removeAllRanges();e.addRange(r);if(!n&&!t.state.selection.visible&&Or&&Er<=11){i.disabled=true;i.disabled=false}}function en(t,e){if(e instanceof Be){let r=t.docView.descAt(e.from);if(r!=t.lastSelectedViewDesc){rn(t);if(r)r.selectNode();t.lastSelectedViewDesc=r}}else{rn(t)}}function rn(t){if(t.lastSelectedViewDesc){if(t.lastSelectedViewDesc.parent)t.lastSelectedViewDesc.deselectNode();t.lastSelectedViewDesc=undefined}}function nn(t,e,r,i){return t.someProp("createSelectionBetween",(i=>i(t,e,r)))||ze.between(e,r,i)}function sn(t){if(t.editable&&!t.hasFocus())return false;return ln(t)}function ln(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 on(t){let e=t.docView.domFromPos(t.state.selection.anchor,0);let r=t.domSelectionRange();return ur(e.node,e.offset,r.anchorNode,r.anchorOffset)}function fn(t,e){let{$anchor:r,$head:i}=t.selection;let n=e>0?r.max(i):r.min(i);let s=!n.parent.inlineContent?n:n.depth?t.doc.resolve(e>0?n.after():n.before()):null;return s&&$e.findFrom(s,e)}function un(t,e){t.dispatch(t.state.tr.setSelection(e).scrollIntoView());return true}function hn(t,e,r){let i=t.state.selection;if(i instanceof ze){if(r.indexOf("s")>-1){let{$head:r}=i,n=r.textOffset?null:e<0?r.nodeBefore:r.nodeAfter;if(!n||n.isText||!n.isLeaf)return false;let s=t.state.doc.resolve(r.pos+n.nodeSize*(e<0?-1:1));return un(t,new ze(i.$anchor,s))}else if(!i.empty){return false}else if(t.endOfTextblock(e>0?"forward":"backward")){let r=fn(t.state,e);if(r&&r instanceof Be)return un(t,r);return false}else if(!($r&&r.indexOf("m")>-1)){let r=i.$head,n=r.textOffset?null:e<0?r.nodeBefore:r.nodeAfter,s;if(!n||n.isText)return false;let l=e<0?r.pos-n.nodeSize:r.pos;if(!(n.isAtom||(s=t.docView.descAt(l))&&!s.contentDOM))return false;if(Be.isSelectable(n)){return un(t,new Be(e<0?t.state.doc.resolve(r.pos-n.nodeSize):r))}else if(Ir){return un(t,new ze(t.state.doc.resolve(e<0?l:l+n.nodeSize)))}else{return false}}}else if(i instanceof Be&&i.node.isInline){return un(t,new ze(e>0?i.$to:i.$from))}else{let r=fn(t.state,e);if(r)return un(t,r);return false}}function an(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function cn(t,e){let r=t.pmViewDesc;return r&&r.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function dn(t,e){return e<0?pn(t):mn(t)}function pn(t){let e=t.domSelectionRange();let r=e.focusNode,i=e.focusOffset;if(!r)return;let n,s,l=false;if(Dr&&r.nodeType==1&&i<an(r)&&cn(r.childNodes[i],-1))l=true;for(;;){if(i>0){if(r.nodeType!=1){break}else{let t=r.childNodes[i-1];if(cn(t,-1)){n=r;s=--i}else if(t.nodeType==3){r=t;i=r.nodeValue.length}else break}}else if(wn(r)){break}else{let e=r.previousSibling;while(e&&cn(e,-1)){n=r.parentNode;s=sr(e);e=e.previousSibling}if(!e){r=r.parentNode;if(r==t.dom)break;i=0}else{r=e;i=an(r)}}}if(l)vn(t,r,i);else if(n)vn(t,n,s)}function mn(t){let e=t.domSelectionRange();let r=e.focusNode,i=e.focusOffset;if(!r)return;let n=an(r);let s,l;for(;;){if(i<n){if(r.nodeType!=1)break;let t=r.childNodes[i];if(cn(t,1)){s=r;l=++i}else break}else if(wn(r)){break}else{let e=r.nextSibling;while(e&&cn(e,1)){s=e.parentNode;l=sr(e)+1;e=e.nextSibling}if(!e){r=r.parentNode;if(r==t.dom)break;i=n=0}else{r=e;i=0;n=an(r)}}}if(s)vn(t,s,l)}function wn(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function gn(t,e){while(t&&e==t.childNodes.length&&!pr(t)){e=sr(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 bn(t,e){while(t&&!e&&!pr(t)){e=sr(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 vn(t,e,r){if(e.nodeType!=3){let t,i;if(i=gn(e,r)){e=i;r=0}else if(t=bn(e,r)){e=t;r=t.nodeValue.length}}let i=t.domSelection();if(mr(i)){let t=document.createRange();t.setEnd(e,r);t.setStart(e,r);i.removeAllRanges();i.addRange(t)}else if(i.extend){i.extend(e,r)}t.domObserver.setCurSelection();let{state:n}=t;setTimeout((()=>{if(t.state==n)Gi(t)}),50)}function yn(t,e){let r=t.state.doc.resolve(e);if(!(Rr||Tr)&&r.parent.inlineContent){let i=t.coordsAtPos(e);if(e>r.start()){let r=t.coordsAtPos(e-1);let n=(r.top+r.bottom)/2;if(n>i.top&&n<i.bottom&&Math.abs(r.left-i.left)>1)return r.left<i.left?"ltr":"rtl"}if(e<r.end()){let r=t.coordsAtPos(e+1);let n=(r.top+r.bottom)/2;if(n>i.top&&n<i.bottom&&Math.abs(r.left-i.left)>1)return r.left>i.left?"ltr":"rtl"}}let i=getComputedStyle(t.dom).direction;return i=="rtl"?"rtl":"ltr"}function kn(t,e,r){let i=t.state.selection;if(i instanceof ze&&!i.empty||r.indexOf("s")>-1)return false;if($r&&r.indexOf("m")>-1)return false;let{$from:n,$to:s}=i;if(!n.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let r=fn(t.state,e);if(r&&r instanceof Be)return un(t,r)}if(!n.parent.inlineContent){let r=e<0?n:s;let l=i instanceof Fe?$e.near(r,e):$e.findFrom(r,e);return l?un(t,l):false}return false}function Mn(t,e){if(!(t.state.selection instanceof ze))return true;let{$head:r,$anchor:i,empty:n}=t.state.selection;if(!r.sameParent(i))return true;if(!n)return false;if(t.endOfTextblock(e>0?"forward":"backward"))return true;let s=!r.textOffset&&(e<0?r.nodeBefore:r.nodeAfter);if(s&&!s.isText){let i=t.state.tr;if(e<0)i.delete(r.pos-s.nodeSize,r.pos);else i.delete(r.pos,r.pos+s.nodeSize);t.dispatch(i);return true}return false}function xn(t,e,r){t.domObserver.stop();e.contentEditable=r;t.domObserver.start()}function Sn(t){if(!qr||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;xn(t,r,"true");setTimeout((()=>xn(t,r,"false")),20)}return false}function On(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 En(t,e){let r=e.keyCode,i=On(e);if(r==8||$r&&r==72&&i=="c"){return Mn(t,-1)||dn(t,-1)}else if(r==46&&!e.shiftKey||$r&&r==68&&i=="c"){return Mn(t,1)||dn(t,1)}else if(r==13||r==27){return true}else if(r==37||$r&&r==66&&i=="c"){let e=r==37?yn(t,t.state.selection.from)=="ltr"?-1:1:-1;return hn(t,e,i)||dn(t,e)}else if(r==39||$r&&r==70&&i=="c"){let e=r==39?yn(t,t.state.selection.from)=="ltr"?1:-1:1;return hn(t,e,i)||dn(t,e)}else if(r==38||$r&&r==80&&i=="c"){return kn(t,-1,i)||dn(t,-1)}else if(r==40||$r&&r==78&&i=="c"){return Sn(t)||kn(t,1,i)||dn(t,1)}else if(i==($r?"m":"c")&&(r==66||r==73||r==89||r==90)){return true}return false}function Dn(t,e){t.someProp("transformCopied",(r=>{e=r(e,t)}));let r=[],{content:i,openStart:n,openEnd:s}=e;while(n>1&&s>1&&i.childCount==1&&i.firstChild.childCount==1){n--;s--;let t=i.firstChild;r.push(t.type.name,t.attrs!=t.type.defaultAttrs?t.attrs:null);i=t.content}let l=t.someProp("clipboardSerializer")||vt.fromSchema(t.state.schema);let o=Jn(),f=o.createElement("div");f.appendChild(l.serializeFragment(i,{document:o}));let u=f.firstChild,h,a=0;while(u&&u.nodeType==1&&(h=In[u.nodeName.toLowerCase()])){for(let t=h.length-1;t>=0;t--){let e=o.createElement(h[t]);while(f.firstChild)e.appendChild(f.firstChild);f.appendChild(e);a++}u=f.firstChild}if(u&&u.nodeType==1)u.setAttribute("data-pm-slice",`${n} ${s}${a?` -${a}`:""} ${JSON.stringify(r)}`);let c=t.someProp("clipboardTextSerializer",(r=>r(e,t)))||e.content.textBetween(0,e.content.size,"\n\n");return{dom:f,text:c}}function Nn(t,e,r,i,n){let s=n.parent.type.spec.code;let l,f;if(!r&&!e)return null;let u=e&&(i||s||!r);if(u){t.someProp("transformPastedText",(r=>{e=r(e,s||i,t)}));if(s)return e?new d(o.from(t.state.schema.text(e.replace(/\r\n?/g,"\n"))),0,0):d.empty;let r=t.someProp("clipboardTextParser",(r=>r(e,n,i,t)));if(r){f=r}else{let r=n.marks();let{schema:i}=t.state,s=vt.fromSchema(i);l=document.createElement("div");e.split(/(?:\r\n?|\n)+/).forEach((t=>{let e=l.appendChild(document.createElement("p"));if(t)e.appendChild(s.serializeNode(i.text(t,r)))}))}}else{t.someProp("transformPastedHTML",(e=>{r=e(r,t)}));l=Bn(r);if(Ir)jn(l)}let h=l&&l.querySelector("[data-pm-slice]");let a=h&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(h.getAttribute("data-pm-slice")||"");if(a&&a[3])for(let t=+a[3];t>0;t--){let t=l.firstChild;while(t&&t.nodeType!=1)t=t.nextSibling;if(!t)break;l=t}if(!f){let e=t.someProp("clipboardParser")||t.someProp("domParser")||it.fromSchema(t.state.schema);f=e.parseSlice(l,{preserveWhitespace:!!(u||a),context:n,ruleFromNode(t){if(t.nodeName=="BR"&&!t.nextSibling&&t.parentNode&&!Rn.test(t.parentNode.nodeName))return{ignore:true};return null}})}if(a){f=Fn(An(f,+a[1],+a[2]),a[4])}else{f=d.maxOpen(Cn(f.content,n),true);if(f.openStart||f.openEnd){let t=0,e=0;for(let e=f.content.firstChild;t<f.openStart&&!e.type.spec.isolating;t++,e=e.firstChild){}for(let t=f.content.lastChild;e<f.openEnd&&!t.type.spec.isolating;e++,t=t.lastChild){}f=An(f,t,e)}}t.someProp("transformPasted",(e=>{f=e(f,t)}));return f}const Rn=/^(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 Cn(t,e){if(t.childCount<2)return t;for(let r=e.depth;r>=0;r--){let i=e.node(r);let n=i.contentMatchAt(e.index(r));let s,l=[];t.forEach((t=>{if(!l)return;let e=n.findWrapping(t.type),r;if(!e)return l=null;if(r=l.length&&s.length&&Pn(e,s,t,l[l.length-1],0)){l[l.length-1]=r}else{if(l.length)l[l.length-1]=$n(l[l.length-1],s.length);let r=qn(t,e);l.push(r);n=n.matchType(r.type);s=e}}));if(l)return o.from(l)}return t}function qn(t,e,r=0){for(let i=e.length-1;i>=r;i--)t=e[i].create(null,o.from(t));return t}function Pn(t,e,r,i,n){if(n<t.length&&n<e.length&&t[n]==e[n]){let s=Pn(t,e,r,i.lastChild,n+1);if(s)return i.copy(i.content.replaceChild(i.childCount-1,s));let l=i.contentMatchAt(i.childCount);if(l.matchType(n==t.length-1?r.type:t[n+1]))return i.copy(i.content.append(o.from(qn(r,t,n+1))))}}function $n(t,e){if(e==0)return t;let r=t.content.replaceChild(t.childCount-1,$n(t.lastChild,e-1));let i=t.contentMatchAt(t.childCount).fillBefore(o.empty,true);return t.copy(r.append(i))}function Tn(t,e,r,i,n,s){let l=e<0?t.firstChild:t.lastChild,f=l.content;if(t.childCount>1)s=0;if(n<i-1)f=Tn(f,e,r,i,n+1,s);if(n>=r)f=e<0?l.contentMatchAt(0).fillBefore(f,s<=n).append(f):f.append(l.contentMatchAt(l.childCount).fillBefore(o.empty,true));return t.replaceChild(e<0?0:t.childCount-1,l.copy(f))}function An(t,e,r){if(e<t.openStart)t=new d(Tn(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd);if(r<t.openEnd)t=new d(Tn(t.content,1,r,t.openEnd,0,0),t.openStart,r);return t}const In={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 zn=null;function Jn(){return zn||(zn=document.implementation.createHTMLDocument("title"))}function Bn(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);if(e)t=t.slice(e[0].length);let r=Jn().createElement("div");let i=/<([a-z][^>\s]+)/i.exec(t),n;if(n=i&&In[i[1].toLowerCase()])t=n.map((t=>"<"+t+">")).join("")+t+n.map((t=>"</"+t+">")).reverse().join("");r.innerHTML=t;if(n)for(let t=0;t<n.length;t++)r=r.querySelector(n[t])||r;return r}function jn(t){let e=t.querySelectorAll(Rr?"span:not([class]):not([style])":"span.Apple-converted-space");for(let r=0;r<e.length;r++){let i=e[r];if(i.childNodes.length==1&&i.textContent==" "&&i.parentNode)i.parentNode.replaceChild(t.ownerDocument.createTextNode(" "),i)}}function Fn(t,e){if(!t.size)return t;let r=t.content.firstChild.type.schema,i;try{i=JSON.parse(e)}catch(e){return t}let{content:n,openStart:s,openEnd:l}=t;for(let t=i.length-2;t>=0;t-=2){let e=r.nodes[i[t]];if(!e||e.hasRequiredAttrs())break;n=o.from(e.create(i[t+1],n));s++;l++}return new d(n,s,l)}const Ln={};const Wn={};const _n={touchstart:true,touchmove:true};class Un{constructor(){this.shiftKey=false;this.mouseDown=null;this.lastKeyCode=null;this.lastKeyCodeTime=0;this.lastClick={time:0,x:0,y:0,type:""};this.lastSelectionOrigin=null;this.lastSelectionTime=0;this.lastIOSEnter=0;this.lastIOSEnterFallbackTimeout=-1;this.lastFocus=0;this.lastTouch=0;this.lastAndroidDelete=0;this.composing=false;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 Hn(t){for(let e in Ln){let r=Ln[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=e=>{if(Yn(t,e)&&!Xn(t,e)&&(t.editable||!(e.type in Wn)))r(t,e)},_n[e]?{passive:true}:undefined)}if(qr)t.dom.addEventListener("input",(()=>null));Vn(t)}function Kn(t,e){t.input.lastSelectionOrigin=e;t.input.lastSelectionTime=Date.now()}function Gn(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 Vn(t){t.someProp("handleDOMEvents",(e=>{for(let r in e)if(!t.input.eventHandlers[r])t.dom.addEventListener(r,t.input.eventHandlers[r]=e=>Xn(t,e))}))}function Xn(t,e){return t.someProp("handleDOMEvents",(r=>{let i=r[e.type];return i?i(t,e)||e.defaultPrevented:false}))}function Yn(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 Qn(t,e){if(!Xn(t,e)&&Ln[e.type]&&(t.editable||!(e.type in Wn)))Ln[e.type](t,e)}Wn.keydown=(t,e)=>{let r=e;t.input.shiftKey=r.keyCode==16||r.shiftKey;if(ds(t,r))return;t.input.lastKeyCode=r.keyCode;t.input.lastKeyCodeTime=Date.now();if(Ar&&Rr&&r.keyCode==13)return;if(r.keyCode!=229)t.domObserver.forceFlush();if(Pr&&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,wr(13,"Enter"))));t.input.lastIOSEnter=0}}),200)}else if(t.someProp("handleKeyDown",(e=>e(t,r)))||En(t,r)){r.preventDefault()}else{Kn(t,"key")}};Wn.keyup=(t,e)=>{if(e.keyCode==16)t.input.shiftKey=false};Wn.keypress=(t,e)=>{let r=e;if(ds(t,r)||!r.charCode||r.ctrlKey&&!r.altKey||$r&&r.metaKey)return;if(t.someProp("handleKeyPress",(e=>e(t,r)))){r.preventDefault();return}let i=t.state.selection;if(!(i instanceof ze)||!i.$from.sameParent(i.$to)){let e=String.fromCharCode(r.charCode);if(!/[\r\n]/.test(e)&&!t.someProp("handleTextInput",(r=>r(t,i.$from.pos,i.$to.pos,e))))t.dispatch(t.state.tr.insertText(e).scrollIntoView());r.preventDefault()}};function Zn(t){return{left:t.clientX,top:t.clientY}}function ts(t,e){let r=e.x-t.clientX,i=e.y-t.clientY;return r*r+i*i<100}function es(t,e,r,i,n){if(i==-1)return false;let s=t.state.doc.resolve(i);for(let i=s.depth+1;i>0;i--){if(t.someProp(e,(e=>i>s.depth?e(t,r,s.nodeAfter,s.before(i),n,true):e(t,r,s.node(i),s.before(i),n,false))))return true}return false}function rs(t,e,r){if(!t.focused)t.focus();let i=t.state.tr.setSelection(e);if(r=="pointer")i.setMeta("pointer",true);t.dispatch(i)}function is(t,e){if(e==-1)return false;let r=t.state.doc.resolve(e),i=r.nodeAfter;if(i&&i.isAtom&&Be.isSelectable(i)){rs(t,new Be(r),"pointer");return true}return false}function ns(t,e){if(e==-1)return false;let r=t.state.selection,i,n;if(r instanceof Be)i=r.node;let s=t.state.doc.resolve(e);for(let t=s.depth+1;t>0;t--){let e=t>s.depth?s.nodeAfter:s.node(t);if(Be.isSelectable(e)){if(i&&r.$from.depth>0&&t>=r.$from.depth&&s.before(r.$from.depth+1)==r.$from.pos)n=s.before(r.$from.depth);else n=s.before(t);break}}if(n!=null){rs(t,Be.create(t.state.doc,n),"pointer");return true}else{return false}}function ss(t,e,r,i,n){return es(t,"handleClickOn",e,r,i)||t.someProp("handleClick",(r=>r(t,e,i)))||(n?ns(t,r):is(t,r))}function ls(t,e,r,i){return es(t,"handleDoubleClickOn",e,r,i)||t.someProp("handleDoubleClick",(r=>r(t,e,i)))}function fs(t,e,r,i){return es(t,"handleTripleClickOn",e,r,i)||t.someProp("handleTripleClick",(r=>r(t,e,i)))||us(t,r,i)}function us(t,e,r){if(r.button!=0)return false;let i=t.state.doc;if(e==-1){if(i.inlineContent){rs(t,ze.create(i,0,i.content.size),"pointer");return true}return false}let n=i.resolve(e);for(let e=n.depth+1;e>0;e--){let r=e>n.depth?n.nodeAfter:n.node(e);let s=n.before(e);if(r.inlineContent)rs(t,ze.create(i,s+1,s+1+r.content.size),"pointer");else if(Be.isSelectable(r))rs(t,Be.create(i,s),"pointer");else continue;return true}}function hs(t){return bs(t)}const as=$r?"metaKey":"ctrlKey";Ln.mousedown=(t,e)=>{let r=e;t.input.shiftKey=r.shiftKey;let i=hs(t);let n=Date.now(),s="singleClick";if(n-t.input.lastClick.time<500&&ts(r,t.input.lastClick)&&!r[as]){if(t.input.lastClick.type=="singleClick")s="doubleClick";else if(t.input.lastClick.type=="doubleClick")s="tripleClick"}t.input.lastClick={time:n,x:r.clientX,y:r.clientY,type:s};let l=t.posAtCoords(Zn(r));if(!l)return;if(s=="singleClick"){if(t.input.mouseDown)t.input.mouseDown.done();t.input.mouseDown=new cs(t,l,r,!!i)}else if((s=="doubleClick"?ls:fs)(t,l.pos,l.inside,r)){r.preventDefault()}else{Kn(t,"pointer")}};class cs{constructor(t,e,r,i){this.view=t;this.pos=e;this.event=r;this.flushed=i;this.delayedSelectionSync=false;this.mightDrag=null;this.startDoc=t.state.doc;this.selectNode=!!r[as];this.allowDefault=r.shiftKey;let n,s;if(e.inside>-1){n=t.state.doc.nodeAt(e.inside);s=e.inside}else{let r=t.state.doc.resolve(e.pos);n=r.parent;s=r.depth?r.before():0}const l=i?null:r.target;const o=l?t.docView.nearestDesc(l,true):null;this.target=o?o.dom:null;let{selection:f}=t.state;if(r.button==0&&n.type.spec.draggable&&n.type.spec.selectable!==false||f instanceof Be&&f.from<=s&&f.to>s)this.mightDrag={node:n,pos:s,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Dr&&!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));Kn(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((()=>Gi(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(Zn(t));this.updateAllowDefault(t);if(this.allowDefault||!e){Kn(this.view,"pointer")}else if(ss(this.view,e.pos,e.inside,t,this.selectNode)){t.preventDefault()}else if(t.button==0&&(this.flushed||qr&&this.mightDrag&&!this.mightDrag.node.isAtom||Rr&&!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)){rs(this.view,$e.near(this.view.state.doc.resolve(e.pos)),"pointer");t.preventDefault()}else{Kn(this.view,"pointer")}}move(t){this.updateAllowDefault(t);Kn(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}}Ln.touchstart=t=>{t.input.lastTouch=Date.now();hs(t);Kn(t,"pointer")};Ln.touchmove=t=>{t.input.lastTouch=Date.now();Kn(t,"pointer")};Ln.contextmenu=t=>hs(t);function ds(t,e){if(t.composing)return true;if(qr&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500){t.input.compositionEndedAt=-2e8;return true}return false}const ps=Ar?5e3:-1;Wn.compositionstart=Wn.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,r=e.selection.$from;if(e.selection.empty&&(e.storedMarks||!r.textOffset&&r.parentOffset&&r.nodeBefore.marks.some((t=>t.type.spec.inclusive===false)))){t.markCursor=t.state.storedMarks||r.marks();bs(t,true);t.markCursor=null}else{bs(t);if(Dr&&e.selection.empty&&r.parentOffset&&!r.textOffset&&r.nodeBefore.marks.length){let e=t.domSelectionRange();for(let r=e.focusNode,i=e.focusOffset;r&&r.nodeType==1&&i!=0;){let e=i<0?r.lastChild:r.childNodes[i-1];if(!e)break;if(e.nodeType==3){t.domSelection().collapse(e,e.nodeValue.length);break}else{r=e;i=-1}}}}t.input.composing=true}ms(t,ps)};Wn.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;if(t.input.compositionPendingChanges)Promise.resolve().then((()=>t.domObserver.flush()));t.input.compositionID++;ms(t,20)}};function ms(t,e){clearTimeout(t.input.composingTimeout);if(e>-1)t.input.composingTimeout=setTimeout((()=>bs(t)),e)}function ws(t){if(t.composing){t.input.composing=false;t.input.compositionEndedAt=gs()}while(t.input.compositionNodes.length>0)t.input.compositionNodes.pop().markParentsDirty()}function gs(){let t=document.createEvent("Event");t.initEvent("event",true,true);return t.timeStamp}function bs(t,e=false){if(Ar&&t.domObserver.flushingSoon>=0)return;t.domObserver.forceFlush();ws(t);if(e||t.docView&&t.docView.dirty){let e=Hi(t);if(e&&!e.eq(t.state.selection))t.dispatch(t.state.tr.setSelection(e));else t.updateState(t.state);return true}return false}function vs(t,e){if(!t.dom.parentNode)return;let r=t.dom.parentNode.appendChild(document.createElement("div"));r.appendChild(e);r.style.cssText="position: fixed; left: -10000px; top: 10px";let i=getSelection(),n=document.createRange();n.selectNodeContents(e);t.dom.blur();i.removeAllRanges();i.addRange(n);setTimeout((()=>{if(r.parentNode)r.parentNode.removeChild(r);t.focus()}),50)}const ys=Or&&Er<15||Pr&&zr<604;Ln.copy=Wn.cut=(t,e)=>{let r=e;let i=t.state.selection,n=r.type=="cut";if(i.empty)return;let s=ys?null:r.clipboardData;let l=i.content(),{dom:o,text:f}=Dn(t,l);if(s){r.preventDefault();s.clearData();s.setData("text/html",o.innerHTML);s.setData("text/plain",f)}else{vs(t,o)}if(n)t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function ks(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function Ms(t,e){if(!t.dom.parentNode)return;let r=t.input.shiftKey||t.state.selection.$from.parent.type.spec.code;let i=t.dom.parentNode.appendChild(document.createElement(r?"textarea":"div"));if(!r)i.contentEditable="true";i.style.cssText="position: fixed; left: -10000px; top: 10px";i.focus();let n=t.input.shiftKey&&t.input.lastKeyCode!=45;setTimeout((()=>{t.focus();if(i.parentNode)i.parentNode.removeChild(i);if(r)xs(t,i.value,null,n,e);else xs(t,i.textContent,i.innerHTML,n,e)}),50)}function xs(t,e,r,i,n){let s=Nn(t,e,r,i,t.state.selection.$from);if(t.someProp("handlePaste",(e=>e(t,n,s||d.empty))))return true;if(!s)return false;let l=ks(s);let o=l?t.state.tr.replaceSelectionWith(l,i):t.state.tr.replaceSelection(s);t.dispatch(o.scrollIntoView().setMeta("paste",true).setMeta("uiEvent","paste"));return true}function Ss(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," "):""}Wn.paste=(t,e)=>{let r=e;if(t.composing&&!Ar)return;let i=ys?null:r.clipboardData;let n=t.input.shiftKey&&t.input.lastKeyCode!=45;if(i&&xs(t,Ss(i),i.getData("text/html"),n,r))r.preventDefault();else Ms(t,r)};class Os{constructor(t,e,r){this.slice=t;this.move=e;this.node=r}}const Es=$r?"altKey":"ctrlKey";Ln.dragstart=(t,e)=>{let r=e;let i=t.input.mouseDown;if(i)i.done();if(!r.dataTransfer)return;let n=t.state.selection;let s=n.empty?null:t.posAtCoords(Zn(r));let l;if(s&&s.pos>=n.from&&s.pos<=(n instanceof Be?n.to-1:n.to));else if(i&&i.mightDrag){l=Be.create(t.state.doc,i.mightDrag.pos)}else if(r.target&&r.target.nodeType==1){let e=t.docView.nearestDesc(r.target,true);if(e&&e.node.type.spec.draggable&&e!=t.docView)l=Be.create(t.state.doc,e.posBefore)}let o=(l||t.state.selection).content(),{dom:f,text:u}=Dn(t,o);r.dataTransfer.clearData();r.dataTransfer.setData(ys?"Text":"text/html",f.innerHTML);r.dataTransfer.effectAllowed="copyMove";if(!ys)r.dataTransfer.setData("text/plain",u);t.dragging=new Os(o,!r[Es],l)};Ln.dragend=t=>{let e=t.dragging;window.setTimeout((()=>{if(t.dragging==e)t.dragging=null}),50)};Wn.dragover=Wn.dragenter=(t,e)=>e.preventDefault();Wn.drop=(t,e)=>{let r=e;let i=t.dragging;t.dragging=null;if(!r.dataTransfer)return;let n=t.posAtCoords(Zn(r));if(!n)return;let s=t.state.doc.resolve(n.pos);let l=i&&i.slice;if(l){t.someProp("transformPasted",(e=>{l=e(l,t)}))}else{l=Nn(t,Ss(r.dataTransfer),ys?null:r.dataTransfer.getData("text/html"),false,s)}let o=!!(i&&!r[Es]);if(t.someProp("handleDrop",(e=>e(t,r,l||d.empty,o)))){r.preventDefault();return}if(!l)return;r.preventDefault();let f=l?ce(t.state.doc,s.pos,l):s.pos;if(f==null)f=s.pos;let u=t.state.tr;if(o){let{node:t}=i;if(t)t.replace(u);else u.deleteSelection()}let h=u.mapping.map(f);let a=l.openStart==0&&l.openEnd==0&&l.content.childCount==1;let c=u.doc;if(a)u.replaceRangeWith(h,h,l.content.firstChild);else u.replaceRange(h,h,l);if(u.doc.eq(c))return;let p=u.doc.resolve(h);if(a&&Be.isSelectable(l.content.firstChild)&&p.nodeAfter&&p.nodeAfter.sameMarkup(l.content.firstChild)){u.setSelection(new Be(p))}else{let e=u.mapping.map(f);u.mapping.maps[u.mapping.maps.length-1].forEach(((t,r,i,n)=>e=n));u.setSelection(nn(t,p,u.doc.resolve(e)))}t.focus();t.dispatch(u.setMeta("uiEvent","drop"))};Ln.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()))Gi(t)}),20)}};Ln.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}};Ln.beforeinput=(t,e)=>{let r=e;if(Rr&&Ar&&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,wr(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 Wn)Ln[t]=Wn[t];function Ds(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 Ns{constructor(t,e){this.toDOM=t;this.spec=e||$s;this.side=this.spec.side||0}map(t,e,r,i){let{pos:n,deleted:s}=t.mapResult(e.from+i,this.side<0?-1:1);return s?null:new qs(n-r,n-r,this)}valid(){return true}eq(t){return this==t||t instanceof Ns&&(this.spec.key&&this.spec.key==t.spec.key||this.toDOM==t.toDOM&&Ds(this.spec,t.spec))}destroy(t){if(this.spec.destroy)this.spec.destroy(t)}}class Rs{constructor(t,e){this.attrs=t;this.spec=e||$s}map(t,e,r,i){let n=t.map(e.from+i,this.spec.inclusiveStart?-1:1)-r;let s=t.map(e.to+i,this.spec.inclusiveEnd?1:-1)-r;return n>=s?null:new qs(n,s,this)}valid(t,e){return e.from<e.to}eq(t){return this==t||t instanceof Rs&&Ds(this.attrs,t.attrs)&&Ds(this.spec,t.spec)}static is(t){return t.type instanceof Rs}destroy(){}}class Cs{constructor(t,e){this.attrs=t;this.spec=e||$s}map(t,e,r,i){let n=t.mapResult(e.from+i,1);if(n.deleted)return null;let s=t.mapResult(e.to+i,-1);if(s.deleted||s.pos<=n.pos)return null;return new qs(n.pos-r,s.pos-r,this)}valid(t,e){let{index:r,offset:i}=t.content.findIndex(e.from),n;return i==e.from&&!(n=t.child(r)).isText&&i+n.nodeSize==e.to}eq(t){return this==t||t instanceof Cs&&Ds(this.attrs,t.attrs)&&Ds(this.spec,t.spec)}destroy(){}}class qs{constructor(t,e,r){this.from=t;this.to=e;this.type=r}copy(t,e){return new qs(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 qs(t,t,new Ns(e,r))}static inline(t,e,r,i){return new qs(t,e,new Rs(r,i))}static node(t,e,r,i){return new qs(t,e,new Cs(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof Rs}get widget(){return this.type instanceof Ns}}const Ps=[],$s={};class Ts{constructor(t,e){this.local=t.length?t:Ps;this.children=e.length?e:Ps}static create(t,e){return e.length?Ls(e,t,0,$s):As}find(t,e,r){let i=[];this.findInner(t==null?0:t,e==null?1e9:e,i,0,r);return i}findInner(t,e,r,i,n){for(let s=0;s<this.local.length;s++){let l=this.local[s];if(l.from<=e&&l.to>=t&&(!n||n(l.spec)))r.push(l.copy(l.from+i,l.to+i))}for(let s=0;s<this.children.length;s+=3){if(this.children[s]<e&&this.children[s+1]>t){let l=this.children[s]+1;this.children[s+2].findInner(t-l,e-l,r,i+l,n)}}}map(t,e,r){if(this==As||t.maps.length==0)return this;return this.mapInner(t,e,0,0,r||$s)}mapInner(t,e,r,i,n){let s;for(let l=0;l<this.local.length;l++){let o=this.local[l].map(t,r,i);if(o&&o.type.valid(e,o))(s||(s=[])).push(o);else if(n.onRemove)n.onRemove(this.local[l].spec)}if(this.children.length)return zs(this.children,s||[],t,e,r,i,n);else return s?new Ts(s.sort(Ws),Ps):As}add(t,e){if(!e.length)return this;if(this==As)return Ts.create(t,e);return this.addInner(t,e,0)}addInner(t,e,r){let i,n=0;t.forEach(((t,s)=>{let l=s+r,o;if(!(o=js(e,t,l)))return;if(!i)i=this.children.slice();while(n<i.length&&i[n]<s)n+=3;if(i[n]==s)i[n+2]=i[n+2].addInner(t,o,l+1);else i.splice(n,0,s,s+t.nodeSize,Ls(o,t,l+1,$s));n+=3}));let s=Js(n?Fs(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 Ts(s.length?this.local.concat(s).sort(Ws):this.local,i||this.children)}remove(t){if(t.length==0||this==As)return this;return this.removeInner(t,0)}removeInner(t,e){let r=this.children,i=this.local;for(let i=0;i<r.length;i+=3){let n;let s=r[i]+e,l=r[i+1]+e;for(let e=0,r;e<t.length;e++)if(r=t[e]){if(r.from>s&&r.to<l){t[e]=null;(n||(n=[])).push(r)}}if(!n)continue;if(r==this.children)r=this.children.slice();let o=r[i+2].removeInner(n,s+1);if(o!=As){r[i+2]=o}else{r.splice(i,3);i-=3}}if(i.length)for(let r=0,n;r<t.length;r++)if(n=t[r]){for(let t=0;t<i.length;t++)if(i[t].eq(n,e)){if(i==this.local)i=this.local.slice();i.splice(t--,1)}}if(r==this.children&&i==this.local)return this;return i.length||r.length?new Ts(i,r):As}forChild(t,e){if(this==As)return this;if(e.isLeaf)return Ts.empty;let r,i;for(let e=0;e<this.children.length;e+=3)if(this.children[e]>=t){if(this.children[e]==t)r=this.children[e+2];break}let n=t+1,s=n+e.content.size;for(let t=0;t<this.local.length;t++){let e=this.local[t];if(e.from<s&&e.to>n&&e.type instanceof Rs){let t=Math.max(n,e.from)-n,r=Math.min(s,e.to)-n;if(t<r)(i||(i=[])).push(e.copy(t,r))}}if(i){let t=new Ts(i.sort(Ws),Ps);return r?new Is([t,r]):t}return r||As}eq(t){if(this==t)return true;if(!(t instanceof Ts)||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 _s(this.localsInner(t))}localsInner(t){if(this==As)return Ps;if(t.inlineContent||!this.local.some(Rs.is))return this.local;let e=[];for(let t=0;t<this.local.length;t++){if(!(this.local[t].type instanceof Rs))e.push(this.local[t])}return e}}Ts.empty=new Ts([],[]);Ts.removeOverlap=_s;const As=Ts.empty;class Is{constructor(t){this.members=t}map(t,e){const r=this.members.map((r=>r.map(t,e,$s)));return Is.from(r)}forChild(t,e){if(e.isLeaf)return Ts.empty;let r=[];for(let i=0;i<this.members.length;i++){let n=this.members[i].forChild(t,e);if(n==As)continue;if(n instanceof Is)r=r.concat(n.members);else r.push(n)}return Is.from(r)}eq(t){if(!(t instanceof Is)||t.members.length!=this.members.length)return false;for(let e=0;e<this.members.length;e++)if(!this.members[e].eq(t.members[e]))return false;return true}locals(t){let e,r=true;for(let i=0;i<this.members.length;i++){let n=this.members[i].localsInner(t);if(!n.length)continue;if(!e){e=n}else{if(r){e=e.slice();r=false}for(let t=0;t<n.length;t++)e.push(n[t])}}return e?_s(r?e:e.sort(Ws)):Ps}static from(t){switch(t.length){case 0:return As;case 1:return t[0];default:return new Is(t.every((t=>t instanceof Ts))?t:t.reduce(((t,e)=>t.concat(e instanceof Ts?e:e.members)),[]))}}}function zs(t,e,r,i,n,s,l){let o=t.slice();for(let t=0,e=s;t<r.maps.length;t++){let i=0;r.maps[t].forEach(((t,r,n,s)=>{let l=s-n-(r-t);for(let n=0;n<o.length;n+=3){let s=o[n+1];if(s<0||t>s+e-i)continue;let f=o[n]+e-i;if(r>=f){o[n+1]=t<=f?-2:-1}else if(t>=e&&l){o[n]+=l;o[n+1]+=l}}i+=l}));e=r.maps[t].map(e,-1)}let f=false;for(let e=0;e<o.length;e+=3)if(o[e+1]<0){if(o[e+1]==-2){f=true;o[e+1]=-1;continue}let u=r.map(t[e]+s),h=u-n;if(h<0||h>=i.content.size){f=true;continue}let a=r.map(t[e+1]+s,-1),c=a-n;let{index:d,offset:p}=i.content.findIndex(h);let m=i.maybeChild(d);if(m&&p==h&&p+m.nodeSize==c){let i=o[e+2].mapInner(r,m,u+1,t[e]+s+1,l);if(i!=As){o[e]=h;o[e+1]=c;o[e+2]=i}else{o[e+1]=-2;f=true}}else{f=true}}if(f){let f=Bs(o,t,e,r,n,s,l);let u=Ls(f,i,0,l);e=u.local;for(let t=0;t<o.length;t+=3)if(o[t+1]<0){o.splice(t,3);t-=3}for(let t=0,e=0;t<u.children.length;t+=3){let r=u.children[t];while(e<o.length&&o[e]<r)e+=3;o.splice(e,0,u.children[t],u.children[t+1],u.children[t+2])}}return new Ts(e.sort(Ws),o)}function Js(t,e){if(!e||!t.length)return t;let r=[];for(let i=0;i<t.length;i++){let n=t[i];r.push(new qs(n.from+e,n.to+e,n.type))}return r}function Bs(t,e,r,i,n,s,l){function o(t,e){for(let s=0;s<t.local.length;s++){let o=t.local[s].map(i,n,e);if(o)r.push(o);else if(l.onRemove)l.onRemove(t.local[s].spec)}for(let r=0;r<t.children.length;r+=3)o(t.children[r+2],t.children[r]+e+1)}for(let r=0;r<t.length;r+=3)if(t[r+1]==-1)o(t[r+2],e[r]+s+1);return r}function js(t,e,r){if(e.isLeaf)return null;let i=r+e.nodeSize,n=null;for(let e=0,s;e<t.length;e++){if((s=t[e])&&s.from>r&&s.to<i){(n||(n=[])).push(s);t[e]=null}}return n}function Fs(t){let e=[];for(let r=0;r<t.length;r++)if(t[r]!=null)e.push(t[r]);return e}function Ls(t,e,r,i){let n=[],s=false;e.forEach(((e,l)=>{let o=js(t,e,l+r);if(o){s=true;let t=Ls(o,e,r+l+1,i);if(t!=As)n.push(l,l+e.nodeSize,t)}}));let l=Js(s?Fs(t):t,-r).sort(Ws);for(let t=0;t<l.length;t++)if(!l[t].type.valid(e,l[t])){if(i.onRemove)i.onRemove(l[t].spec);l.splice(t--,1)}return l.length||n.length?new Ts(l,n):As}function Ws(t,e){return t.from-e.from||t.to-e.to}function _s(t){let e=t;for(let r=0;r<e.length-1;r++){let i=e[r];if(i.from!=i.to)for(let n=r+1;n<e.length;n++){let s=e[n];if(s.from==i.from){if(s.to!=i.to){if(e==t)e=t.slice();e[n]=s.copy(s.from,i.to);Us(e,n+1,s.copy(i.to,s.to))}continue}else{if(s.from<i.to){if(e==t)e=t.slice();e[r]=i.copy(i.from,s.from);Us(e,n,i.copy(s.from,i.to))}break}}}return e}function Us(t,e,r){while(e<t.length&&Ws(r,t[e])>0)e++;t.splice(e,0,r)}function Hs(t){let e=[];t.someProp("decorations",(r=>{let i=r(t.state);if(i&&i!=As)e.push(i)}));if(t.cursorWrapper)e.push(Ts.create(t.state.doc,[t.cursorWrapper.deco]));return Is.from(e)}const Ks={childList:true,characterData:true,characterDataOldValue:true,attributes:true,attributeOldValue:true,subtree:true};const Gs=Or&&Er<=11;class Vs{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 Xs{constructor(t,e){this.view=t;this.handleDOMChange=e;this.queue=[];this.flushingSoon=-1;this.observer=null;this.currentSelection=new Vs;this.onCharData=null;this.suppressingSelectionUpdates=false;this.observer=window.MutationObserver&&new window.MutationObserver((t=>{for(let e=0;e<t.length;e++)this.queue.push(t[e]);if(Or&&Er<=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(Gs){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,Ks)}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(!sn(this.view))return;if(this.suppressingSelectionUpdates)return Gi(this.view);if(Or&&Er<=11&&!this.view.state.selection.empty){let t=this.view.domSelectionRange();if(t.focusNode&&ur(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=lr(r))e.add(r);for(let i=t.anchorNode;i;i=lr(i))if(e.has(i)){r=i;break}let i=r&&this.view.docView.nearestDesc(r);if(i&&i.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r})){this.setCurSelection();return true}}pendingRecords(){if(this.observer)for(let t of this.observer.takeRecords())this.queue.push(t);return this.queue}flush(){let{view:t}=this;if(!t.docView||this.flushingSoon>-1)return;let e=this.pendingRecords();if(e.length)this.queue=[];let r=t.domSelectionRange();let i=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&sn(t)&&!this.ignoreSelectionChange(r);let n=-1,s=-1,l=false,o=[];if(t.editable){for(let t=0;t<e.length;t++){let r=this.registerMutation(e[t],o);if(r){n=n<0?r.from:Math.min(r.from,n);s=s<0?r.to:Math.max(r.to,s);if(r.typeOver)l=true}}}if(Dr&&o.length>1){let t=o.filter((t=>t.nodeName=="BR"));if(t.length==2){let e=t[0],r=t[1];if(e.parentNode&&e.parentNode.parentNode==r.parentNode)r.remove();else e.remove()}}let f=null;if(n<0&&i&&t.input.lastFocus>Date.now()-200&&Math.max(t.input.lastTouch,t.input.lastClick.time)<Date.now()-300&&mr(r)&&(f=Hi(t))&&f.eq($e.near(t.state.doc.resolve(0),1))){t.input.lastFocus=0;Gi(t);this.currentSelection.set(r);t.scrollToSelection()}else if(n>-1||i){if(n>-1){t.docView.markDirty(n,s);Zs(t)}this.handleDOMChange(n,s,l,o);if(t.docView&&t.docView.dirty)t.updateState(t.state);else if(!this.currentSelection.eq(r))Gi(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++)e.push(t.addedNodes[r]);if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(t.target))return{from:r.posBefore,to:r.posAfter};let i=t.previousSibling,n=t.nextSibling;if(Or&&Er<=11&&t.addedNodes.length){for(let e=0;e<t.addedNodes.length;e++){let{previousSibling:r,nextSibling:s}=t.addedNodes[e];if(!r||Array.prototype.indexOf.call(t.addedNodes,r)<0)i=r;if(!s||Array.prototype.indexOf.call(t.addedNodes,s)<0)n=s}}let s=i&&i.parentNode==t.target?sr(i)+1:0;let l=r.localPosFromDOM(t.target,s,-1);let o=n&&n.parentNode==t.target?sr(n):t.target.childNodes.length;let f=r.localPosFromDOM(t.target,o,1);return{from:l,to:f}}else if(t.type=="attributes"){return{from:r.posAtStart-r.border,to:r.posAtEnd+r.border}}else{return{from:r.posAtStart,to:r.posAtEnd,typeOver:t.target.nodeValue==t.oldValue}}}}let Ys=new WeakMap;let Qs=false;function Zs(t){if(Ys.has(t))return;Ys.set(t,null);if(["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace)!==-1){t.requiresGeckoHackNode=Dr;if(Qs)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.");Qs=true}}function tl(t){let e;function r(t){t.preventDefault();t.stopImmediatePropagation();e=t.getTargetRanges()[0]}t.dom.addEventListener("beforeinput",r,true);document.execCommand("indent");t.dom.removeEventListener("beforeinput",r,true);let i=e.startContainer,n=e.startOffset;let s=e.endContainer,l=e.endOffset;let o=t.domAtPos(t.state.selection.anchor);if(ur(o.node,o.offset,s,l))[i,n,s,l]=[s,l,i,n];return{anchorNode:i,anchorOffset:n,focusNode:s,focusOffset:l}}function el(t,e,r){let{node:i,fromOffset:n,toOffset:s,from:l,to:o}=t.docView.parseRange(e,r);let f=t.domSelectionRange();let u;let h=f.anchorNode;if(h&&t.dom.contains(h.nodeType==1?h:h.parentNode)){u=[{node:h,offset:f.anchorOffset}];if(!mr(f))u.push({node:f.focusNode,offset:f.focusOffset})}if(Rr&&t.input.lastKeyCode===8){for(let t=s;t>n;t--){let e=i.childNodes[t-1],r=e.pmViewDesc;if(e.nodeName=="BR"&&!r){s=t;break}if(!r||r.size)break}}let a=t.state.doc;let c=t.someProp("domParser")||it.fromSchema(t.state.schema);let d=a.resolve(l);let p=null,m=c.parse(i,{topNode:d.parent,topMatch:d.parent.contentMatchAt(d.index()),topOpen:true,from:n,to:s,preserveWhitespace:d.parent.type.whitespace=="pre"?"full":true,findPositions:u,ruleFromNode:rl,context:d});if(u&&u[0].pos!=null){let t=u[0].pos,e=u[1]&&u[1].pos;if(e==null)e=t;p={anchor:t+l,head:e+l}}return{doc:m,sel:p,from:l,to:o}}function rl(t){let e=t.pmViewDesc;if(e){return e.parseRule()}else if(t.nodeName=="BR"&&t.parentNode){if(qr&&/^(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||qr&&/^(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 il=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function nl(t,e,r,i,n){let s=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);t.input.compositionPendingChanges=0;if(e<0){let e=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null;let r=Hi(t,e);if(r&&!t.state.selection.eq(r)){if(Rr&&Ar&&t.input.lastKeyCode===13&&Date.now()-100<t.input.lastKeyCodeTime&&t.someProp("handleKeyDown",(e=>e(t,wr(13,"Enter")))))return;let i=t.state.tr.setSelection(r);if(e=="pointer")i.setMeta("pointer",true);else if(e=="key")i.scrollIntoView();if(s)i.setMeta("composition",s);t.dispatch(i)}return}let l=t.state.doc.resolve(e);let o=l.sharedDepth(r);e=l.before(o+1);r=t.state.doc.resolve(r).after(o+1);let f=t.state.selection;let u=el(t,e,r);let h=t.state.doc,a=h.slice(u.from,u.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=ul(a.content,u.doc.content,u.from,c,d);if((Pr&&t.input.lastIOSEnter>Date.now()-225||Ar)&&n.some((t=>t.nodeType==1&&!il.test(t.nodeName)))&&(!p||p.endA>=p.endB)&&t.someProp("handleKeyDown",(e=>e(t,wr(13,"Enter"))))){t.input.lastIOSEnter=0;return}if(!p){if(i&&f instanceof ze&&!f.empty&&f.$head.sameParent(f.$anchor)&&!t.composing&&!(u.sel&&u.sel.anchor!=u.sel.head)){p={start:f.from,endA:f.to,endB:f.to}}else{if(u.sel){let e=sl(t,t.state.doc,u.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(Rr&&t.cursorWrapper&&u.sel&&u.sel.anchor==t.cursorWrapper.deco.from&&u.sel.head==u.sel.anchor){let t=p.endB-p.start;u.sel={anchor:u.sel.anchor+t,head:u.sel.anchor+t}}t.input.domChangeCount++;if(t.state.selection.from<t.state.selection.to&&p.start==p.endB&&t.state.selection instanceof ze){if(p.start>t.state.selection.from&&p.start<=t.state.selection.from+2&&t.state.selection.from>=u.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<=u.to){p.endB+=t.state.selection.to-p.endA;p.endA=t.state.selection.to}}if(Or&&Er<=11&&p.endB==p.start+1&&p.endA==p.start&&p.start>u.from&&u.doc.textBetween(p.start-u.from-1,p.start-u.from+1)=="  "){p.start--;p.endA--;p.endB--}let m=u.doc.resolveNoCache(p.start-u.from);let w=u.doc.resolveNoCache(p.endB-u.from);let g=h.resolve(p.start);let b=m.sameParent(w)&&m.parent.inlineContent&&g.end()>=p.endA;let v;if((Pr&&t.input.lastIOSEnter>Date.now()-225&&(!b||n.some((t=>t.nodeName=="DIV"||t.nodeName=="P")))||!b&&m.pos<u.doc.content.size&&!m.sameParent(w)&&(v=$e.findFrom(u.doc.resolve(m.pos+1),1,true))&&v.head==w.pos)&&t.someProp("handleKeyDown",(e=>e(t,wr(13,"Enter"))))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>p.start&&ol(h,p.start,p.endA,m,w)&&t.someProp("handleKeyDown",(e=>e(t,wr(8,"Backspace"))))){if(Ar&&Rr)t.domObserver.suppressSelectionUpdates();return}if(Rr&&Ar&&p.endB==p.start)t.input.lastAndroidDelete=Date.now();if(Ar&&!b&&m.start()!=w.start()&&w.parentOffset==0&&m.depth==w.depth&&u.sel&&u.sel.anchor==u.sel.head&&u.sel.head==p.endA){p.endB-=2;w=u.doc.resolveNoCache(p.endB-u.from);setTimeout((()=>{t.someProp("handleKeyDown",(function(e){return e(t,wr(13,"Enter"))}))}),20)}let y=p.start,k=p.endA;let M,x,S;if(b){if(m.pos==w.pos){if(Or&&Er<=11&&m.parentOffset==0){t.domObserver.suppressSelectionUpdates();setTimeout((()=>Gi(t)),20)}M=t.state.tr.delete(y,k);x=h.resolve(p.start).marksAcross(h.resolve(p.endA))}else if(p.endA==p.endB&&(S=ll(m.parent.content.cut(m.parentOffset,w.parentOffset),g.parent.content.cut(g.parentOffset,p.endA-g.start())))){M=t.state.tr;if(S.type=="add")M.addMark(y,k,S.mark);else M.removeMark(y,k,S.mark)}else if(m.parent.child(m.index()).isText&&m.index()==w.index()-(w.textOffset?0:1)){let e=m.parent.textBetween(m.parentOffset,w.parentOffset);if(t.someProp("handleTextInput",(r=>r(t,y,k,e))))return;M=t.state.tr.insertText(e,y,k)}}if(!M)M=t.state.tr.replace(y,k,u.doc.slice(p.start-u.from,p.endB-u.from));if(u.sel){let e=sl(t,M.doc,u.sel);if(e&&!(Rr&&Ar&&t.composing&&e.empty&&(p.start!=p.endB||t.input.lastAndroidDelete<Date.now()-100)&&(e.head==y||e.head==M.mapping.map(k)-1)||Or&&e.empty&&e.head==y))M.setSelection(e)}if(x)M.ensureMarks(x);if(s)M.setMeta("composition",s);t.dispatch(M.scrollIntoView())}function sl(t,e,r){if(Math.max(r.anchor,r.head)>e.content.size)return null;return nn(t,e.resolve(r.anchor),e.resolve(r.head))}function ll(t,e){let r=t.firstChild.marks,i=e.firstChild.marks;let n=r,s=i,l,f,u;for(let t=0;t<i.length;t++)n=i[t].removeFromSet(n);for(let t=0;t<r.length;t++)s=r[t].removeFromSet(s);if(n.length==1&&s.length==0){f=n[0];l="add";u=t=>t.mark(f.addToSet(t.marks))}else if(n.length==0&&s.length==1){f=s[0];l="remove";u=t=>t.mark(f.removeFromSet(t.marks))}else{return null}let h=[];for(let t=0;t<e.childCount;t++)h.push(u(e.child(t)));if(o.from(h).eq(t))return{mark:f,type:l}}function ol(t,e,r,i,n){if(!i.parent.isTextblock||r-e<=n.pos-i.pos||fl(i,true,false)<n.pos)return false;let s=t.resolve(e);if(s.parentOffset<s.parent.content.size||!s.parent.isTextblock)return false;let l=t.resolve(fl(s,true,true));if(!l.parent.isTextblock||l.pos>r||fl(l,true,false)<r)return false;return i.parent.content.cut(i.parentOffset).eq(l.parent.content)}function fl(t,e,r){let i=t.depth,n=e?t.end():t.pos;while(i>0&&(e||t.indexAfter(i)==t.node(i).childCount)){i--;n++;e=false}if(r){let e=t.node(i).maybeChild(t.indexAfter(i));while(e&&!e.isLeaf){e=e.firstChild;n++}}return n}function ul(t,e,r,i,n){let s=t.findDiffStart(e,r);if(s==null)return null;let{a:l,b:o}=t.findDiffEnd(e,r+t.size,r+e.size);if(n=="end"){let t=Math.max(0,s-Math.min(l,o));i-=l+t-s}if(l<s&&t.size<e.size){let t=i<=s&&i>=l?s-i:0;s-=t;if(s&&s<e.size&&hl(e.textBetween(s-1,s+1)))s+=t?1:-1;o=s+(o-l);l=s}else if(o<s){let e=i<=s&&i>=o?s-i:0;s-=e;if(s&&s<t.size&&hl(t.textBetween(s-1,s+1)))s+=e?1:-1;l=s+(l-o);o=s}return{start:s,endA:l,endB:o}}function hl(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 al{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 Un;this.prevDirectPlugins=[];this.pluginViews=[];this.requiresGeckoHackNode=false;this.dragging=null;this._props=e;this.state=e.state;this.directPlugins=e.plugins||[];this.directPlugins.forEach(bl);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=pl(this);dl(this);this.nodeViews=wl(this);this.docView=Oi(this.state.doc,cl(this),Hs(this),this.dom,this);this.domObserver=new Xs(this,((t,e,r,i)=>nl(this,t,e,r,i)));this.domObserver.start();Hn(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)Vn(this);let e=this._props;this._props=t;if(t.plugins){t.plugins.forEach(bl);this.directPlugins=t.plugins}this.updateStateInner(t.state,e)}setProps(t){let e={};for(let t in this._props)e[t]=this._props[t];e.state=this.state;for(let r in t)e[r]=t[r];this.update(e)}updateState(t){this.updateStateInner(t,this._props)}updateStateInner(t,e){var r;let i=this.state,n=false,s=false;if(t.storedMarks&&this.composing){ws(this);s=true}this.state=t;let l=i.plugins!=t.plugins||this._props.plugins!=e.plugins;if(l||this._props.plugins!=e.plugins||this._props.nodeViews!=e.nodeViews){let t=wl(this);if(gl(t,this.nodeViews)){this.nodeViews=t;n=true}}if(l||e.handleDOMEvents!=this._props.handleDOMEvents){Vn(this)}this.editable=pl(this);dl(this);let o=Hs(this),f=cl(this);let u=i.plugins!=t.plugins&&!i.doc.eq(t.doc)?"reset":t.scrollToSelection>i.scrollToSelection?"to selection":"preserve";let h=n||!this.docView.matchesNode(t.doc,f,o);if(h||!t.selection.eq(i.selection))s=true;let a=u=="preserve"&&s&&this.dom.style.overflowAnchor==null&&Lr(this);if(s){this.domObserver.stop();let e=h&&(Or||Rr)&&!this.composing&&!i.selection.empty&&!t.selection.empty&&ml(i.selection,t.selection);if(h){let r=Rr?this.trackWrites=this.domSelectionRange().focusNode:null;if(n||!this.docView.update(t.doc,f,o,this)){this.docView.updateOuterDeco([]);this.docView.destroy();this.docView=Oi(t.doc,f,o,this.dom,this)}if(r&&!this.trackWrites)e=true}if(e||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&on(this))){Gi(this,e)}else{en(this,t.selection);this.domObserver.setCurSelection()}this.domObserver.start()}this.updatePluginViews(i);if(((r=this.dragging)===null||r===void 0?void 0:r.node)&&!i.doc.eq(t.doc))this.updateDraggedNode(this.dragging,i);if(u=="reset"){this.dom.scrollTop=0}else if(u=="to selection"){this.scrollToSelection()}else if(a){_r(a)}}scrollToSelection(){let t=this.domSelectionRange().focusNode;if(this.someProp("handleScrollToSelection",(t=>t(this))));else if(this.state.selection instanceof Be){let e=this.docView.domAfterPos(this.state.selection.from);if(e.nodeType==1)Fr(this,e.getBoundingClientRect(),t)}else{Fr(this,this.coordsAtPos(this.state.selection.head,1),t)}}destroyPluginViews(){let t;while(t=this.pluginViews.pop())if(t.destroy)t.destroy()}updatePluginViews(t){if(!t||t.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins;this.destroyPluginViews();for(let t=0;t<this.directPlugins.length;t++){let e=this.directPlugins[t];if(e.spec.view)this.pluginViews.push(e.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let e=this.state.plugins[t];if(e.spec.view)this.pluginViews.push(e.spec.view(this))}}else{for(let e=0;e<this.pluginViews.length;e++){let r=this.pluginViews[e];if(r.update)r.update(this,t)}}}updateDraggedNode(t,e){let r=t.node,i=-1;if(this.state.doc.nodeAt(r.from)==r.node){i=r.from}else{let t=r.from+(this.state.doc.content.size-e.doc.content.size);let n=t>0&&this.state.doc.nodeAt(t);if(n==r.node)i=t}this.dragging=new Os(t.slice,t.move,i<0?undefined:Be.create(this.state.doc,i))}someProp(t,e){let r=this._props&&this._props[t],i;if(r!=null&&(i=e?e(r):r))return i;for(let r=0;r<this.directPlugins.length;r++){let n=this.directPlugins[r].props[t];if(n!=null&&(i=e?e(n):n))return i}let n=this.state.plugins;if(n)for(let r=0;r<n.length;r++){let s=n[r].props[t];if(s!=null&&(i=e?e(s):s))return i}}hasFocus(){if(Or){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)Kr(this.dom);Gi(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 ei(this,t)}coordsAtPos(t,e=1){return si(this,t,e)}domAtPos(t,e=0){return this.docView.domFromPos(t,e)}nodeDOM(t){let e=this.docView.descAt(t);return e?e.nodeDOM:null}posAtDOM(t,e,r=-1){let i=this.docView.posFromDOM(t,e,r);if(i==null)throw new RangeError("DOM position not inside the editor");return i}endOfTextblock(t,e){return mi(this,e||this.state,t)}pasteHTML(t,e){return xs(this,"",t,false,e||new ClipboardEvent("paste"))}pasteText(t,e){return xs(this,t,null,true,e||new ClipboardEvent("paste"))}destroy(){if(!this.docView)return;Gn(this);this.destroyPluginViews();if(this.mounted){this.docView.update(this.state.doc,[],Hs(this),this);this.dom.textContent=""}else if(this.dom.parentNode){this.dom.parentNode.removeChild(this.dom)}this.docView.destroy();this.docView=null}get isDestroyed(){return this.docView==null}dispatchEvent(t){return Qn(this,t)}dispatch(t){let e=this._props.dispatchTransaction;if(e)e.call(this,t);else this.updateState(this.state.apply(t))}domSelectionRange(){return qr&&this.root.nodeType===11&&gr(this.dom.ownerDocument)==this.dom?tl(this):this.domSelection()}domSelection(){return this.root.getSelection()}}function cl(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[qs.node(0,t.state.doc.content.size,e)]}function dl(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:qs.widget(t.state.selection.head,e,{raw:true,marks:t.markCursor})}}else{t.cursorWrapper=null}}function pl(t){return!t.someProp("editable",(e=>e(t.state)===false))}function ml(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 wl(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 gl(t,e){let r=0,i=0;for(let i in t){if(t[i]!=e[i])return true;r++}for(let t in e)i++;return r!=i}function bl(t){if(t.spec.state||t.spec.filterTransaction||t.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}const vl=["p",0],yl=["blockquote",0],kl=["hr"],Ml=["pre",["code",0]],xl=["br"];const Sl={doc:{content:"block+"},paragraph:{content:"inline*",group:"block",parseDOM:[{tag:"p"}],toDOM(){return vl}},blockquote:{content:"block+",group:"block",defining:true,parseDOM:[{tag:"blockquote"}],toDOM(){return yl}},horizontal_rule:{group:"block",parseDOM:[{tag:"hr"}],toDOM(){return kl}},heading:{attrs:{level:{default:1}},content:"inline*",group:"block",defining:true,parseDOM:[{tag:"h1",attrs:{level:1}},{tag:"h2",attrs:{level:2}},{tag:"h3",attrs:{level:3}},{tag:"h4",attrs:{level:4}},{tag:"h5",attrs:{level:5}},{tag:"h6",attrs:{level:6}}],toDOM(t){return["h"+t.attrs.level,0]}},code_block:{content:"text*",marks:"",group:"block",code:true,defining:true,parseDOM:[{tag:"pre",preserveWhitespace:"full"}],toDOM(){return Ml}},text:{group:"inline"},image:{inline:true,attrs:{src:{},alt:{default:null},title:{default:null}},group:"inline",draggable:true,parseDOM:[{tag:"img[src]",getAttrs(t){return{src:t.getAttribute("src"),title:t.getAttribute("title"),alt:t.getAttribute("alt")}}}],toDOM(t){let{src:e,alt:r,title:i}=t.attrs;return["img",{src:e,alt:r,title:i}]}},hard_break:{inline:true,group:"inline",selectable:false,parseDOM:[{tag:"br"}],toDOM(){return xl}}};const Ol=["em",0],El=["strong",0],Dl=["code",0];const Nl={link:{attrs:{href:{},title:{default:null}},inclusive:false,parseDOM:[{tag:"a[href]",getAttrs(t){return{href:t.getAttribute("href"),title:t.getAttribute("title")}}}],toDOM(t){let{href:e,title:r}=t.attrs;return["a",{href:e,title:r},0]}},em:{parseDOM:[{tag:"i"},{tag:"em"},{style:"font-style=italic"},{style:"font-style=normal",clearMark:t=>t.type.name=="em"}],toDOM(){return Ol}},strong:{parseDOM:[{tag:"strong"},{tag:"b",getAttrs:t=>t.style.fontWeight!="normal"&&null},{style:"font-weight=400",clearMark:t=>t.type.name=="strong"},{style:"font-weight",getAttrs:t=>/^(bold(er)?|[5-9]\d{2,})$/.test(t)&&null}],toDOM(){return El}},code:{parseDOM:[{tag:"code"}],toDOM(){return Dl}}};const Rl=new et({nodes:Sl,marks:Nl});const Cl=["ol",0],ql=["ul",0],Pl=["li",0];const $l={attrs:{order:{default:1}},parseDOM:[{tag:"ol",getAttrs(t){return{order:t.hasAttribute("start")?+t.getAttribute("start"):1}}}],toDOM(t){return t.attrs.order==1?Cl:["ol",{start:t.attrs.order},0]}};const Tl={parseDOM:[{tag:"ul"}],toDOM(){return ql}};const Al={parseDOM:[{tag:"li"}],toDOM(){return Pl},defining:true};function Il(t,e){let r={};for(let e in t)r[e]=t[e];for(let t in e)r[t]=e[t];return r}function zl(t,e,r){return t.append({ordered_list:Il($l,{content:"list_item+",group:r}),bullet_list:Il(Tl,{content:"list_item+",group:r}),list_item:Il(Al,{content:e})})}function Jl(t,e=null){return function(r,i){let{$from:n,$to:s}=r.selection;let l=n.blockRange(s),o=false,f=l;if(!l)return false;if(l.depth>=2&&n.node(l.depth-1).type.compatibleContent(t)&&l.startIndex==0){if(n.index(l.depth-1)==0)return false;let t=r.doc.resolve(l.start-2);f=new C(t,t,l.depth);if(l.endIndex<l.parent.childCount)l=new C(n,r.doc.resolve(s.end(l.depth)),l.depth);o=true}let u=Yt(f,t,e,l);if(!u)return false;if(i)i(Bl(r.tr,l,u,o,t).scrollIntoView());return true}}function Bl(t,e,r,i,n){let s=o.empty;for(let t=r.length-1;t>=0;t--)s=o.from(r[t].type.create(r[t].attrs,s));t.step(new Wt(e.start-(i?2:0),e.end,e.start,e.end,new d(s,0,0),r.length,true));let l=0;for(let t=0;t<r.length;t++)if(r[t].type==n)l=t+1;let f=r.length-l;let u=e.start+r.length-(i?2:0),h=e.parent;for(let r=e.startIndex,i=e.endIndex,n=true;r<i;r++,n=false){if(!n&&se(t.doc,u,f)){t.split(u,f);u+=2*f}u+=h.child(r).nodeSize}return t}function jl(t,e){return function(r,i){let{$from:n,$to:s,node:l}=r.selection;if(l&&l.isBlock||n.depth<2||!n.sameParent(s))return false;let f=n.node(-1);if(f.type!=t)return false;if(n.parent.content.size==0&&n.node(-1).childCount==n.indexAfter(-1)){if(n.depth==3||n.node(-3).type!=t||n.index(-2)!=n.node(-2).childCount-1)return false;if(i){let e=o.empty;let s=n.index(-1)?1:n.index(-2)?2:3;for(let t=n.depth-s;t>=n.depth-3;t--)e=o.from(n.node(t).copy(e));let l=n.indexAfter(-1)<n.node(-2).childCount?1:n.indexAfter(-2)<n.node(-3).childCount?2:3;e=e.append(o.from(t.createAndFill()));let f=n.before(n.depth-(s-1));let u=r.tr.replace(f,n.after(-l),new d(e,4-s,0));let h=-1;u.doc.nodesBetween(f,u.doc.content.size,((t,e)=>{if(h>-1)return false;if(t.isTextblock&&t.content.size==0)h=e+1}));if(h>-1)u.setSelection($e.near(u.doc.resolve(h)));i(u.scrollIntoView())}return true}let u=s.pos==n.end()?f.contentMatchAt(0).defaultType:null;let h=r.tr.delete(n.pos,s.pos);let a=u?[e?{type:t,attrs:e}:null,{type:u}]:undefined;if(!se(h.doc,n.pos,2,a))return false;if(i)i(h.split(n.pos,2,a).scrollIntoView());return true}}function Fl(t){return function(e,r){let{$from:i,$to:n}=e.selection;let s=i.blockRange(n,(e=>e.childCount>0&&e.firstChild.type==t));if(!s)return false;if(!r)return true;if(i.node(s.depth-1).type==t)return Ll(e,r,t,s);else return Wl(e,r,s)}}function Ll(t,e,r,i){let n=t.tr,s=i.end,l=i.$to.end(i.depth);if(s<l){n.step(new Wt(s-1,l,s,l,new d(o.from(r.create(null,i.parent.copy())),1,0),1,true));i=new C(n.doc.resolve(i.$from.pos),n.doc.resolve(l),i.depth)}const f=Vt(i);if(f==null)return false;n.lift(i,f);let u=n.mapping.map(s,-1)-1;if(oe(n.doc,u))n.join(u);e(n.scrollIntoView());return true}function Wl(t,e,r){let i=t.tr,n=r.parent;for(let t=r.end,e=r.endIndex-1,s=r.startIndex;e>s;e--){t-=n.child(e).nodeSize;i.delete(t-1,t+1)}let s=i.doc.resolve(r.start),l=s.nodeAfter;if(i.mapping.map(r.end)!=r.start+s.nodeAfter.nodeSize)return false;let f=r.startIndex==0,u=r.endIndex==n.childCount;let h=s.node(-1),a=s.index(-1);if(!h.canReplace(a+(f?0:1),a+1,l.content.append(u?o.empty:o.from(n))))return false;let c=s.pos,p=c+l.nodeSize;i.step(new Wt(c-(f?1:0),p+(u?1:0),c+1,p-1,new d((f?o.empty:o.from(n.copy(o.empty))).append(u?o.empty:o.from(n.copy(o.empty))),f?0:1,u?0:1),f?0:1));e(i.scrollIntoView());return true}function _l(t){return function(e,r){let{$from:i,$to:n}=e.selection;let s=i.blockRange(n,(e=>e.childCount>0&&e.firstChild.type==t));if(!s)return false;let l=s.startIndex;if(l==0)return false;let f=s.parent,u=f.child(l-1);if(u.type!=t)return false;if(r){let i=u.lastChild&&u.lastChild.type==f.type;let n=o.from(i?t.create():null);let l=new d(o.from(t.create(null,o.from(f.type.create(null,n)))),i?3:1,0);let h=s.start,a=s.end;r(e.tr.step(new Wt(h-(i?3:1),a,h,a,l,1,true)).scrollIntoView())}return true}}var Ul={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 Hl={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 Kl=typeof navigator!="undefined"&&/Mac/.test(navigator.platform);var Gl=typeof navigator!="undefined"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var Vl=0;Vl<10;Vl++)Ul[48+Vl]=Ul[96+Vl]=String(Vl);for(var Vl=1;Vl<=24;Vl++)Ul[Vl+111]="F"+Vl;for(var Vl=65;Vl<=90;Vl++){Ul[Vl]=String.fromCharCode(Vl+32);Hl[Vl]=String.fromCharCode(Vl)}for(var Xl in Ul)if(!Hl.hasOwnProperty(Xl))Hl[Xl]=Ul[Xl];function Yl(t){var e=Kl&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||Gl&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified";var r=!e&&t.key||(t.shiftKey?Hl:Ul)[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 Ql=typeof navigator!="undefined"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):false;function Zl(t){let e=t.split(/-(?!$)/),r=e[e.length-1];if(r=="Space")r=" ";let i,n,s,l;for(let t=0;t<e.length-1;t++){let r=e[t];if(/^(cmd|meta|m)$/i.test(r))l=true;else if(/^a(lt)?$/i.test(r))i=true;else if(/^(c|ctrl|control)$/i.test(r))n=true;else if(/^s(hift)?$/i.test(r))s=true;else if(/^mod$/i.test(r)){if(Ql)l=true;else n=true}else throw new Error("Unrecognized modifier name: "+r)}if(i)r="Alt-"+r;if(n)r="Ctrl-"+r;if(l)r="Meta-"+r;if(s)r="Shift-"+r;return r}function to(t){let e=Object.create(null);for(let r in t)e[Zl(r)]=t[r];return e}function eo(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 ro(t){return new er({props:{handleKeyDown:io(t)}})}function io(t){let e=to(t);return function(t,r){let i=Yl(r),n,s=e[eo(i,r)];if(s&&s(t.state,t.dispatch,t))return true;if(i.length==1&&i!=" "){if(r.shiftKey){let n=e[eo(i,r,false)];if(n&&n(t.state,t.dispatch,t))return true}if((r.shiftKey||r.altKey||r.metaKey||i.charCodeAt(0)>127)&&(n=Ul[r.keyCode])&&n!=i){let i=e[eo(n,r)];if(i&&i(t.state,t.dispatch,t))return true}}return false}}var no=200;var so=function t(){};so.prototype.append=function t(e){if(!e.length){return this}e=so.from(e);return!this.length&&e||e.length<no&&this.leafAppend(e)||this.length<no&&e.leafPrepend(this)||this.appendInner(e)};so.prototype.prepend=function t(e){if(!e.length){return this}return so.from(e).append(this)};so.prototype.appendInner=function t(e){return new oo(this,e)};so.prototype.slice=function t(e,r){if(e===void 0)e=0;if(r===void 0)r=this.length;if(e>=r){return so.empty}return this.sliceInner(Math.max(0,e),Math.min(this.length,r))};so.prototype.get=function t(e){if(e<0||e>=this.length){return undefined}return this.getInner(e)};so.prototype.forEach=function t(e,r,i){if(r===void 0)r=0;if(i===void 0)i=this.length;if(r<=i){this.forEachInner(e,r,i,0)}else{this.forEachInvertedInner(e,r,i,0)}};so.prototype.map=function t(e,r,i){if(r===void 0)r=0;if(i===void 0)i=this.length;var n=[];this.forEach((function(t,r){return n.push(e(t,r))}),r,i);return n};so.from=function t(e){if(e instanceof so){return e}return e&&e.length?new lo(e):so.empty};var lo=function(t){function e(e){t.call(this);this.values=e}if(t)e.__proto__=t;e.prototype=Object.create(t&&t.prototype);e.prototype.constructor=e;var r={length:{configurable:true},depth:{configurable:true}};e.prototype.flatten=function t(){return this.values};e.prototype.sliceInner=function t(r,i){if(r==0&&i==this.length){return this}return new e(this.values.slice(r,i))};e.prototype.getInner=function t(e){return this.values[e]};e.prototype.forEachInner=function t(e,r,i,n){for(var s=r;s<i;s++){if(e(this.values[s],n+s)===false){return false}}};e.prototype.forEachInvertedInner=function t(e,r,i,n){for(var s=r-1;s>=i;s--){if(e(this.values[s],n+s)===false){return false}}};e.prototype.leafAppend=function t(r){if(this.length+r.length<=no){return new e(this.values.concat(r.flatten()))}};e.prototype.leafPrepend=function t(r){if(this.length+r.length<=no){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}(so);so.empty=new lo([]);var oo=function(t){function e(e,r){t.call(this);this.left=e;this.right=r;this.length=e.length+r.length;this.depth=Math.max(e.depth,r.depth)+1}if(t)e.__proto__=t;e.prototype=Object.create(t&&t.prototype);e.prototype.constructor=e;e.prototype.flatten=function t(){return this.left.flatten().concat(this.right.flatten())};e.prototype.getInner=function t(e){return e<this.left.length?this.left.get(e):this.right.get(e-this.left.length)};e.prototype.forEachInner=function t(e,r,i,n){var s=this.left.length;if(r<s&&this.left.forEachInner(e,r,Math.min(i,s),n)===false){return false}if(i>s&&this.right.forEachInner(e,Math.max(r-s,0),Math.min(this.length,i)-s,n+s)===false){return false}};e.prototype.forEachInvertedInner=function t(e,r,i,n){var s=this.left.length;if(r>s&&this.right.forEachInvertedInner(e,r-s,Math.max(i,s)-s,n+s)===false){return false}if(i<s&&this.left.forEachInvertedInner(e,Math.min(r,s),i,n)===false){return false}};e.prototype.sliceInner=function t(e,r){if(e==0&&r==this.length){return this}var i=this.left.length;if(r<=i){return this.left.slice(e,r)}if(e>=i){return this.right.slice(e-i,r-i)}return this.left.slice(e,i).append(this.right.slice(0,r-i))};e.prototype.leafAppend=function t(r){var i=this.right.leafAppend(r);if(i){return new e(this.left,i)}};e.prototype.leafPrepend=function t(r){var i=this.left.leafPrepend(r);if(i){return new e(i,this.right)}};e.prototype.appendInner=function t(r){if(this.left.depth>=Math.max(this.right.depth,r.depth)+1){return new e(this.left,new e(this.right,r))}return new e(this,r)};return e}(so);const fo=500;class uo{constructor(t,e){this.items=t;this.eventCount=e}popEvent(t,e){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--){let t=this.items.get(r-1);if(t.selection){--r;break}}let i,n;if(e){i=this.remapping(r,this.items.length);n=i.maps.length}let s=t.tr;let l,o;let f=[],u=[];this.items.forEach(((t,e)=>{if(!t.step){if(!i){i=this.remapping(r,e+1);n=i.maps.length}n--;u.push(t);return}if(i){u.push(new ao(t.map));let e=t.step.map(i.slice(n)),r;if(e&&s.maybeStep(e).doc){r=s.mapping.maps[s.mapping.maps.length-1];f.push(new ao(r,undefined,undefined,f.length+u.length))}n--;if(r)i.appendMap(r,n)}else{s.maybeStep(t.step)}if(t.selection){l=i?t.selection.map(i.slice(n)):t.selection;o=new uo(this.items.slice(0,r).append(u.reverse().concat(f)),this.eventCount-1);return false}}),this.items.length,0);return{remaining:o,transform:s,selection:l}}addTransform(t,e,r,i){let n=[],s=this.eventCount;let l=this.items,o=!i&&l.length?l.get(l.length-1):null;for(let r=0;r<t.steps.length;r++){let f=t.steps[r].invert(t.docs[r]);let u=new ao(t.mapping.maps[r],f,e),h;if(h=o&&o.merge(u)){u=h;if(r)n.pop();else l=l.slice(0,l.length-1)}n.push(u);if(e){s++;e=undefined}if(!i)o=u}let f=s-r.depth;if(f>po){l=ho(l,f);s-=f}return new uo(l.append(n),s)}remapping(t,e){let r=new $t;this.items.forEach(((e,i)=>{let n=e.mirrorOffset!=null&&i-e.mirrorOffset>=t?r.maps.length-e.mirrorOffset:undefined;r.appendMap(e.map,n)}),t,e);return r}addMaps(t){if(this.eventCount==0)return this;return new uo(this.items.append(t.map((t=>new ao(t)))),this.eventCount)}rebased(t,e){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-e);let n=t.mapping;let s=t.steps.length;let l=this.eventCount;this.items.forEach((t=>{if(t.selection)l--}),i);let o=e;this.items.forEach((e=>{let i=n.getMirror(--o);if(i==null)return;s=Math.min(s,i);let f=n.maps[i];if(e.step){let s=t.steps[i].invert(t.docs[i]);let u=e.selection&&e.selection.map(n.slice(o+1,i));if(u)l++;r.push(new ao(f,s,u))}else{r.push(new ao(f))}}),i);let f=[];for(let t=e;t<s;t++)f.push(new ao(n.maps[t]));let u=this.items.slice(0,i).append(f).append(r);let h=new uo(u,l);if(h.emptyItemCount()>fo)h=h.compress(this.items.length-r.length);return h}emptyItemCount(){let t=0;this.items.forEach((e=>{if(!e.step)t++}));return t}compress(t=this.items.length){let e=this.remapping(0,t),r=e.maps.length;let i=[],n=0;this.items.forEach(((s,l)=>{if(l>=t){i.push(s);if(s.selection)n++}else if(s.step){let t=s.step.map(e.slice(r)),l=t&&t.getMap();r--;if(l)e.appendMap(l,r);if(t){let o=s.selection&&s.selection.map(e.slice(r));if(o)n++;let f=new ao(l.invert(),t,o),u,h=i.length-1;if(u=i.length&&i[h].merge(f))i[h]=u;else i.push(f)}}else if(s.map){r--}}),this.items.length,0);return new uo(so.from(i.reverse()),n)}}uo.empty=new uo(so.empty,0);function ho(t,e){let r;t.forEach(((t,i)=>{if(t.selection&&e--==0){r=i;return false}}));return t.slice(r)}class ao{constructor(t,e,r,i){this.map=t;this.step=e;this.selection=r;this.mirrorOffset=i}merge(t){if(this.step&&t.step&&!t.selection){let e=t.step.merge(this.step);if(e)return new ao(e.getMap().invert(),e,this.selection)}}}class co{constructor(t,e,r,i,n){this.done=t;this.undone=e;this.prevRanges=r;this.prevTime=i;this.prevComposition=n}}const po=20;function mo(t,e,r,i){let n=r.getMeta(xo),s;if(n)return n.historyState;if(r.getMeta(So))t=new co(t.done,t.undone,null,0,-1);let l=r.getMeta("appendedTransaction");if(r.steps.length==0){return t}else if(l&&l.getMeta(xo)){if(l.getMeta(xo).redo)return new co(t.done.addTransform(r,undefined,i,Mo(e)),t.undone,go(r.mapping.maps[r.steps.length-1]),t.prevTime,t.prevComposition);else return new co(t.done,t.undone.addTransform(r,undefined,i,Mo(e)),null,t.prevTime,t.prevComposition)}else if(r.getMeta("addToHistory")!==false&&!(l&&l.getMeta("addToHistory")===false)){let n=r.getMeta("composition");let s=t.prevTime==0||!l&&t.prevComposition!=n&&(t.prevTime<(r.time||0)-i.newGroupDelay||!wo(r,t.prevRanges));let o=l?bo(t.prevRanges,r.mapping):go(r.mapping.maps[r.steps.length-1]);return new co(t.done.addTransform(r,s?e.selection.getBookmark():undefined,i,Mo(e)),uo.empty,o,r.time,n==null?t.prevComposition:n)}else if(s=r.getMeta("rebased")){return new co(t.done.rebased(r,s),t.undone.rebased(r,s),bo(t.prevRanges,r.mapping),t.prevTime,t.prevComposition)}else{return new co(t.done.addMaps(r.mapping.maps),t.undone.addMaps(r.mapping.maps),bo(t.prevRanges,r.mapping),t.prevTime,t.prevComposition)}}function wo(t,e){if(!e)return false;if(!t.docChanged)return true;let r=false;t.mapping.maps[0].forEach(((t,i)=>{for(let n=0;n<e.length;n+=2)if(t<=e[n+1]&&i>=e[n])r=true}));return r}function go(t){let e=[];t.forEach(((t,r,i,n)=>e.push(i,n)));return e}function bo(t,e){if(!t)return null;let r=[];for(let i=0;i<t.length;i+=2){let n=e.map(t[i],1),s=e.map(t[i+1],-1);if(n<=s)r.push(n,s)}return r}function vo(t,e,r,i){let n=Mo(e);let s=xo.get(e).spec.config;let l=(i?t.undone:t.done).popEvent(e,n);if(!l)return;let o=l.selection.resolve(l.transform.doc);let f=(i?t.done:t.undone).addTransform(l.transform,e.selection.getBookmark(),s,n);let u=new co(i?f:l.remaining,i?l.remaining:f,null,0,-1);r(l.transform.setSelection(o).setMeta(xo,{redo:i,historyState:u}).scrollIntoView())}let yo=false,ko=null;function Mo(t){let e=t.plugins;if(ko!=e){yo=false;ko=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){yo=true;break}}return yo}const xo=new nr("history");const So=new nr("closeHistory");function Oo(t={}){t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500};return new er({key:xo,state:{init(){return new co(uo.empty,uo.empty,null,0,-1)},apply(e,r,i){return mo(r,i,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(t,e){let r=e.inputType;let i=r=="historyUndo"?Eo:r=="historyRedo"?Do:null;if(!i)return false;e.preventDefault();return i(t.state,t.dispatch)}}}})}const Eo=(t,e)=>{let r=xo.getState(t);if(!r||r.done.eventCount==0)return false;if(e)vo(r,t,e,false);return true};const Do=(t,e)=>{let r=xo.getState(t);if(!r||r.undone.eventCount==0)return false;if(e)vo(r,t,e,true);return true};const No=(t,e)=>{if(t.selection.empty)return false;if(e)e(t.tr.deleteSelection().scrollIntoView());return true};function Ro(t,e){let{$cursor:r}=t.selection;if(!r||(e?!e.endOfTextblock("backward",t):r.parentOffset>0))return null;return r}const Co=(t,e,r)=>{let i=Ro(t,r);if(!i)return false;let n=$o(i);if(!n){let r=i.blockRange(),n=r&&Vt(r);if(n==null)return false;if(e)e(t.tr.lift(r,n).scrollIntoView());return true}let s=n.nodeBefore;if(!s.type.spec.isolating&&Yo(t,n,e))return true;if(i.parent.content.size==0&&(qo(s,"end")||Be.isSelectable(s))){let r=de(t.doc,i.before(),i.after(),d.empty);if(r&&r.slice.size<r.to-r.from){if(e){let i=t.tr.step(r);i.setSelection(qo(s,"end")?$e.findFrom(i.doc.resolve(i.mapping.map(n.pos,-1)),-1):Be.create(i.doc,n.pos-s.nodeSize));e(i.scrollIntoView())}return true}}if(s.isAtom&&n.depth==i.depth-1){if(e)e(t.tr.delete(n.pos-s.nodeSize,n.pos).scrollIntoView());return true}return false};function qo(t,e,r=false){for(let i=t;i;i=e=="start"?i.firstChild:i.lastChild){if(i.isTextblock)return true;if(r&&i.childCount!=1)return false}return false}const Po=(t,e,r)=>{let{$head:i,empty:n}=t.selection,s=i;if(!n)return false;if(i.parent.isTextblock){if(r?!r.endOfTextblock("backward",t):i.parentOffset>0)return false;s=$o(i)}let l=s&&s.nodeBefore;if(!l||!Be.isSelectable(l))return false;if(e)e(t.tr.setSelection(Be.create(t.doc,s.pos-l.nodeSize)).scrollIntoView());return true};function $o(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 To(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 Ao=(t,e,r)=>{let i=To(t,r);if(!i)return false;let n=zo(i);if(!n)return false;let s=n.nodeAfter;if(Yo(t,n,e))return true;if(i.parent.content.size==0&&(qo(s,"start")||Be.isSelectable(s))){let r=de(t.doc,i.before(),i.after(),d.empty);if(r&&r.slice.size<r.to-r.from){if(e){let i=t.tr.step(r);i.setSelection(qo(s,"start")?$e.findFrom(i.doc.resolve(i.mapping.map(n.pos)),1):Be.create(i.doc,i.mapping.map(n.pos)));e(i.scrollIntoView())}return true}}if(s.isAtom&&n.depth==i.depth-1){if(e)e(t.tr.delete(n.pos,n.pos+s.nodeSize).scrollIntoView());return true}return false};const Io=(t,e,r)=>{let{$head:i,empty:n}=t.selection,s=i;if(!n)return false;if(i.parent.isTextblock){if(r?!r.endOfTextblock("forward",t):i.parentOffset<i.parent.content.size)return false;s=zo(i)}let l=s&&s.nodeAfter;if(!l||!Be.isSelectable(l))return false;if(e)e(t.tr.setSelection(Be.create(t.doc,s.pos)).scrollIntoView());return true};function zo(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 Jo=(t,e)=>{let r=t.selection,i=r instanceof Be,n;if(i){if(r.node.isTextblock||!oe(t.doc,r.from))return false;n=r.from}else{n=ue(t.doc,r.from,-1);if(n==null)return false}if(e){let r=t.tr.join(n);if(i)r.setSelection(Be.create(r.doc,n-t.doc.resolve(n).nodeBefore.nodeSize));e(r.scrollIntoView())}return true};const Bo=(t,e)=>{let r=t.selection,i;if(r instanceof Be){if(r.node.isTextblock||!oe(t.doc,r.to))return false;i=r.to}else{i=ue(t.doc,r.to,1);if(i==null)return false}if(e)e(t.tr.join(i).scrollIntoView());return true};const jo=(t,e)=>{let{$from:r,$to:i}=t.selection;let n=r.blockRange(i),s=n&&Vt(n);if(s==null)return false;if(e)e(t.tr.lift(n,s).scrollIntoView());return true};const Fo=(t,e)=>{let{$head:r,$anchor:i}=t.selection;if(!r.parent.type.spec.code||!r.sameParent(i))return false;if(e)e(t.tr.insertText("\n").scrollIntoView());return true};function Lo(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 Wo=(t,e)=>{let{$head:r,$anchor:i}=t.selection;if(!r.parent.type.spec.code||!r.sameParent(i))return false;let n=r.node(-1),s=r.indexAfter(-1),l=Lo(n.contentMatchAt(s));if(!l||!n.canReplaceWith(s,s,l))return false;if(e){let i=r.after(),n=t.tr.replaceWith(i,i,l.createAndFill());n.setSelection($e.near(n.doc.resolve(i),1));e(n.scrollIntoView())}return true};const _o=(t,e)=>{let r=t.selection,{$from:i,$to:n}=r;if(r instanceof Fe||i.parent.inlineContent||n.parent.inlineContent)return false;let s=Lo(n.parent.contentMatchAt(n.indexAfter()));if(!s||!s.isTextblock)return false;if(e){let r=(!i.parentOffset&&n.index()<n.parent.childCount?i:n).pos;let l=t.tr.insert(r,s.createAndFill());l.setSelection(ze.create(l.doc,r+1));e(l.scrollIntoView())}return true};const Uo=(t,e)=>{let{$cursor:r}=t.selection;if(!r||r.parent.content.size)return false;if(r.depth>1&&r.after()!=r.end(-1)){let i=r.before();if(se(t.doc,i)){if(e)e(t.tr.split(i).scrollIntoView());return true}}let i=r.blockRange(),n=i&&Vt(i);if(n==null)return false;if(e)e(t.tr.lift(i,n).scrollIntoView());return true};function Ho(t){return(e,r)=>{let{$from:i,$to:n}=e.selection;if(e.selection instanceof Be&&e.selection.node.isBlock){if(!i.parentOffset||!se(e.doc,i.pos))return false;if(r)r(e.tr.split(i.pos).scrollIntoView());return true}if(!i.parent.isBlock)return false;if(r){let s=n.parentOffset==n.parent.content.size;let l=e.tr;if(e.selection instanceof ze||e.selection instanceof Fe)l.deleteSelection();let o=i.depth==0?null:Lo(i.node(-1).contentMatchAt(i.indexAfter(-1)));let f=t&&t(n.parent,s);let u=f?[f]:s&&o?[{type:o}]:undefined;let h=se(l.doc,l.mapping.map(i.pos),1,u);if(!u&&!h&&se(l.doc,l.mapping.map(i.pos),1,o?[{type:o}]:undefined)){if(o)u=[{type:o}];h=true}if(h){l.split(l.mapping.map(i.pos),1,u);if(!s&&!i.parentOffset&&i.parent.type!=o){let t=l.mapping.map(i.before()),e=l.doc.resolve(t);if(o&&i.node(-1).canReplaceWith(e.index(),e.index()+1,o))l.setNodeMarkup(l.mapping.map(i.before()),o)}}r(l.scrollIntoView())}return true}}const Ko=Ho();const Go=(t,e)=>{let{$from:r,to:i}=t.selection,n;let s=r.sharedDepth(i);if(s==0)return false;n=r.before(s);if(e)e(t.tr.setSelection(Be.create(t.doc,n)));return true};const Vo=(t,e)=>{if(e)e(t.tr.setSelection(new Fe(t.doc)));return true};function Xo(t,e,r){let i=e.nodeBefore,n=e.nodeAfter,s=e.index();if(!i||!n||!i.type.compatibleContent(n.type))return false;if(!i.content.size&&e.parent.canReplace(s-1,s)){if(r)r(t.tr.delete(e.pos-i.nodeSize,e.pos).scrollIntoView());return true}if(!e.parent.canReplace(s,s+1)||!(n.isTextblock||oe(t.doc,e.pos)))return false;if(r)r(t.tr.clearIncompatible(e.pos,i.type,i.contentMatchAt(i.childCount)).join(e.pos).scrollIntoView());return true}function Yo(t,e,r){let i=e.nodeBefore,n=e.nodeAfter,s,l;if(i.type.spec.isolating||n.type.spec.isolating)return false;if(Xo(t,e,r))return true;let f=e.parent.canReplace(e.index(),e.index()+1);if(f&&(s=(l=i.contentMatchAt(i.childCount)).findWrapping(n.type))&&l.matchType(s[0]||n.type).validEnd){if(r){let l=e.pos+n.nodeSize,f=o.empty;for(let t=s.length-1;t>=0;t--)f=o.from(s[t].create(null,f));f=o.from(i.copy(f));let u=t.tr.step(new Wt(e.pos-1,l,e.pos,l,new d(f,1,0),s.length,true));let h=l+2*s.length;if(oe(u.doc,h))u.join(h);r(u.scrollIntoView())}return true}let u=$e.findFrom(e,1);let h=u&&u.$from.blockRange(u.$to),a=h&&Vt(h);if(a!=null&&a>=e.depth){if(r)r(t.tr.lift(h,a).scrollIntoView());return true}if(f&&qo(n,"start",true)&&qo(i,"end")){let s=i,l=[];for(;;){l.push(s);if(s.isTextblock)break;s=s.lastChild}let f=n,u=1;for(;!f.isTextblock;f=f.firstChild)u++;if(s.canReplace(s.childCount,s.childCount,f.content)){if(r){let i=o.empty;for(let t=l.length-1;t>=0;t--)i=o.from(l[t].copy(i));let s=t.tr.step(new Wt(e.pos-l.length,e.pos+n.nodeSize,e.pos+u,e.pos+n.nodeSize-u,new d(i,l.length,0),0,true));r(s.scrollIntoView())}return true}}return false}function Qo(t){return function(e,r){let i=e.selection,n=t<0?i.$from:i.$to;let s=n.depth;while(n.node(s).isInline){if(!s)return false;s--}if(!n.node(s).isTextblock)return false;if(r)r(e.tr.setSelection(ze.create(e.doc,t<0?n.start(s):n.end(s))));return true}}const Zo=Qo(-1);const tf=Qo(1);function ef(t,e=null){return function(r,i){let{$from:n,$to:s}=r.selection;let l=n.blockRange(s),o=l&&Yt(l,t,e);if(!o)return false;if(i)i(r.tr.wrap(l,o).scrollIntoView());return true}}function rf(t,e=null){return function(r,i){let n=false;for(let i=0;i<r.selection.ranges.length&&!n;i++){let{$from:{pos:s},$to:{pos:l}}=r.selection.ranges[i];r.doc.nodesBetween(s,l,((i,s)=>{if(n)return false;if(!i.isTextblock||i.hasMarkup(t,e))return;if(i.type==t){n=true}else{let e=r.doc.resolve(s),i=e.index();n=e.parent.canReplaceWith(i,i+1,t)}}))}if(!n)return false;if(i){let n=r.tr;for(let i=0;i<r.selection.ranges.length;i++){let{$from:{pos:s},$to:{pos:l}}=r.selection.ranges[i];n.setBlockType(s,l,t,e)}i(n.scrollIntoView())}return true}}function nf(t,e,r){for(let i=0;i<e.length;i++){let{$from:n,$to:s}=e[i];let l=n.depth==0?t.inlineContent&&t.type.allowsMarkType(r):false;t.nodesBetween(n.pos,s.pos,(t=>{if(l)return false;l=t.inlineContent&&t.type.allowsMarkType(r)}));if(l)return true}return false}function sf(t,e=null){return function(r,i){let{empty:n,$cursor:s,ranges:l}=r.selection;if(n&&!s||!nf(r.doc,l,t))return false;if(i){if(s){if(t.isInSet(r.storedMarks||s.marks()))i(r.tr.removeStoredMark(t));else i(r.tr.addStoredMark(t.create(e)))}else{let n=false,s=r.tr;for(let e=0;!n&&e<l.length;e++){let{$from:i,$to:s}=l[e];n=r.doc.rangeHasMark(i.pos,s.pos,t)}for(let r=0;r<l.length;r++){let{$from:i,$to:o}=l[r];if(n){s.removeMark(i.pos,o.pos,t)}else{let r=i.pos,n=o.pos,l=i.nodeAfter,f=o.nodeBefore;let u=l&&l.isText?/^\s*/.exec(l.text)[0].length:0;let h=f&&f.isText?/\s*$/.exec(f.text)[0].length:0;if(r+u<n){r+=u;n-=h}s.addMark(r,n,t.create(e))}}i(s.scrollIntoView())}}return true}}function lf(...t){return function(e,r,i){for(let n=0;n<t.length;n++)if(t[n](e,r,i))return true;return false}}let of=lf(No,Co,Po);let ff=lf(No,Ao,Io);const uf={Enter:lf(Fo,_o,Uo,Ko),"Mod-Enter":Wo,Backspace:of,"Mod-Backspace":of,"Shift-Backspace":of,Delete:ff,"Mod-Delete":ff,"Mod-a":Vo};const hf={"Ctrl-h":uf["Backspace"],"Alt-Backspace":uf["Mod-Backspace"],"Ctrl-d":uf["Delete"],"Ctrl-Alt-Backspace":uf["Mod-Delete"],"Alt-Delete":uf["Mod-Delete"],"Alt-d":uf["Mod-Delete"],"Ctrl-a":Zo,"Ctrl-e":tf};for(let t in uf)hf[t]=uf[t];const af=typeof navigator!="undefined"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os!="undefined"&&os.platform?os.platform()=="darwin":false;const cf=af?hf:uf;function df(t={}){return new er({view(e){return new pf(e,t)}})}class pf{constructor(t,e){var r;this.editorView=t;this.cursorPos=null;this.element=null;this.timeout=-1;this.width=(r=e.width)!==null&&r!==void 0?r:1;this.color=e.color===false?undefined:e.color||"black";this.class=e.class;this.handlers=["dragover","dragend","drop","dragleave"].map((e=>{let r=t=>{this[e](t)};t.dom.addEventListener(e,r);return{name:e,handler:r}}))}destroy(){this.handlers.forEach((({name:t,handler:e})=>this.editorView.dom.removeEventListener(t,e)))}update(t,e){if(this.cursorPos!=null&&e.doc!=t.state.doc){if(this.cursorPos>t.state.doc.content.size)this.setCursor(null);else this.updateOverlay()}}setCursor(t){if(t==this.cursorPos)return;this.cursorPos=t;if(t==null){this.element.parentNode.removeChild(this.element);this.element=null}else{this.updateOverlay()}}updateOverlay(){let t=this.editorView.state.doc.resolve(this.cursorPos);let e=!t.parent.inlineContent,r;if(e){let e=t.nodeBefore,i=t.nodeAfter;if(e||i){let t=this.editorView.nodeDOM(this.cursorPos-(e?e.nodeSize:0));if(t){let n=t.getBoundingClientRect();let s=e?n.bottom:n.top;if(e&&i)s=(s+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2;r={left:n.left,right:n.right,top:s-this.width/2,bottom:s+this.width/2}}}}if(!r){let t=this.editorView.coordsAtPos(this.cursorPos);r={left:t.left-this.width/2,right:t.left+this.width/2,top:t.top,bottom:t.bottom}}let i=this.editorView.dom.offsetParent;if(!this.element){this.element=i.appendChild(document.createElement("div"));if(this.class)this.element.className=this.class;this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;";if(this.color){this.element.style.backgroundColor=this.color}}this.element.classList.toggle("prosemirror-dropcursor-block",e);this.element.classList.toggle("prosemirror-dropcursor-inline",!e);let n,s;if(!i||i==document.body&&getComputedStyle(i).position=="static"){n=-pageXOffset;s=-pageYOffset}else{let t=i.getBoundingClientRect();n=t.left-i.scrollLeft;s=t.top-i.scrollTop}this.element.style.left=r.left-n+"px";this.element.style.top=r.top-s+"px";this.element.style.width=r.right-r.left+"px";this.element.style.height=r.bottom-r.top+"px"}scheduleRemoval(t){clearTimeout(this.timeout);this.timeout=setTimeout((()=>this.setCursor(null)),t)}dragover(t){if(!this.editorView.editable)return;let e=this.editorView.posAtCoords({left:t.clientX,top:t.clientY});let r=e&&e.inside>=0&&this.editorView.state.doc.nodeAt(e.inside);let i=r&&r.type.spec.disableDropCursor;let n=typeof i=="function"?i(this.editorView,e,t):i;if(e&&!n){let t=e.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let e=ce(this.editorView.state.doc,t,this.editorView.dragging.slice);if(e!=null)t=e}this.setCursor(t);this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(t){if(t.target==this.editorView.dom||!this.editorView.dom.contains(t.relatedTarget))this.setCursor(null)}}class mf extends $e{constructor(t){super(t,t)}map(t,e){let r=t.resolve(e.map(this.head));return mf.valid(r)?new mf(r):$e.near(r)}content(){return d.empty}eq(t){return t instanceof mf&&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 mf(t.resolve(e.pos))}getBookmark(){return new wf(this.anchor)}static valid(t){let e=t.parent;if(e.isTextblock||!gf(t)||!bf(t))return false;let r=e.type.spec.allowGapCursor;if(r!=null)return r;let i=e.contentMatchAt(t.index()).defaultType;return i&&i.isTextblock}static findGapCursorFrom(t,e,r=false){t:for(;;){if(!r&&mf.valid(t))return t;let i=t.pos,n=null;for(let r=t.depth;;r--){let s=t.node(r);if(e>0?t.indexAfter(r)<s.childCount:t.index(r)>0){n=s.child(e>0?t.indexAfter(r):t.index(r)-1);break}else if(r==0){return null}i+=e;let l=t.doc.resolve(i);if(mf.valid(l))return l}for(;;){let s=e>0?n.firstChild:n.lastChild;if(!s){if(n.isAtom&&!n.isText&&!Be.isSelectable(n)){t=t.doc.resolve(i+n.nodeSize*e);r=false;continue t}break}n=s;i+=e;let l=t.doc.resolve(i);if(mf.valid(l))return l}return null}}}mf.prototype.visible=false;mf.findFrom=mf.findGapCursorFrom;$e.jsonID("gapcursor",mf);class wf{constructor(t){this.pos=t}map(t){return new wf(t.map(this.pos))}resolve(t){let e=t.resolve(this.pos);return mf.valid(e)?new mf(e):$e.near(e)}}function gf(t){for(let e=t.depth;e>=0;e--){let r=t.index(e),i=t.node(e);if(r==0){if(i.type.spec.isolating)return true;continue}for(let t=i.child(r-1);;t=t.lastChild){if(t.childCount==0&&!t.inlineContent||t.isAtom||t.type.spec.isolating)return true;if(t.inlineContent)return false}}return true}function bf(t){for(let e=t.depth;e>=0;e--){let r=t.indexAfter(e),i=t.node(e);if(r==i.childCount){if(i.type.spec.isolating)return true;continue}for(let t=i.child(r);;t=t.firstChild){if(t.childCount==0&&!t.inlineContent||t.isAtom||t.type.spec.isolating)return true;if(t.inlineContent)return false}}return true}function vf(){return new er({props:{decorations:Sf,createSelectionBetween(t,e,r){return e.pos==r.pos&&mf.valid(r)?new mf(r):null},handleClick:Mf,handleKeyDown:yf,handleDOMEvents:{beforeinput:xf}}})}const yf=io({ArrowLeft:kf("horiz",-1),ArrowRight:kf("horiz",1),ArrowUp:kf("vert",-1),ArrowDown:kf("vert",1)});function kf(t,e){const r=t=="vert"?e>0?"down":"up":e>0?"right":"left";return function(t,i,n){let s=t.selection;let l=e>0?s.$to:s.$from,o=s.empty;if(s instanceof ze){if(!n.endOfTextblock(r)||l.depth==0)return false;o=false;l=t.doc.resolve(e>0?l.after():l.before())}let f=mf.findGapCursorFrom(l,e,o);if(!f)return false;if(i)i(t.tr.setSelection(new mf(f)));return true}}function Mf(t,e,r){if(!t||!t.editable)return false;let i=t.state.doc.resolve(e);if(!mf.valid(i))return false;let n=t.posAtCoords({left:r.clientX,top:r.clientY});if(n&&n.inside>-1&&Be.isSelectable(t.state.doc.nodeAt(n.inside)))return false;t.dispatch(t.state.tr.setSelection(new mf(i)));return true}function xf(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof mf))return false;let{$from:r}=t.state.selection;let i=r.parent.contentMatchAt(r.index()).findWrapping(t.state.schema.nodes.text);if(!i)return false;let n=o.empty;for(let t=i.length-1;t>=0;t--)n=o.from(i[t].createAndFill(null,n));let s=t.state.tr.replace(r.pos,r.pos,new d(n,0,0));s.setSelection(ze.near(s.doc.resolve(r.pos+1)));t.dispatch(s);return false}function Sf(t){if(!(t.selection instanceof mf))return null;let e=document.createElement("div");e.className="ProseMirror-gapcursor";return Ts.create(t.doc,[qs.widget(t.selection.head,e,{key:"gapcursor"})])}function Of(){var t=arguments[0];if(typeof t=="string")t=document.createElement(t);var e=1,r=arguments[1];if(r&&typeof r=="object"&&r.nodeType==null&&!Array.isArray(r)){for(var i in r)if(Object.prototype.hasOwnProperty.call(r,i)){var n=r[i];if(typeof n=="string")t.setAttribute(i,n);else if(n!=null)t[i]=n}e++}for(;e<arguments.length;e++)Ef(t,arguments[e]);return t}function Ef(t,e){if(typeof e=="string"){t.appendChild(document.createTextNode(e))}else if(e==null);else if(e.nodeType!=null){t.appendChild(e)}else if(Array.isArray(e)){for(var r=0;r<e.length;r++)Ef(t,e[r])}else{throw new RangeError("Unsupported child node: "+e)}}const Df="http://www.w3.org/2000/svg";const Nf="http://www.w3.org/1999/xlink";const Rf="ProseMirror-icon";function Cf(t){let e=0;for(let r=0;r<t.length;r++)e=(e<<5)-e+t.charCodeAt(r)|0;return e}function qf(t,e){let r=(t.nodeType==9?t:t.ownerDocument)||document;let i=r.createElement("div");i.className=Rf;if(e.path){let{path:n,width:s,height:l}=e;let o="pm-icon-"+Cf(n).toString(16);if(!r.getElementById(o))Pf(t,o,e);let f=i.appendChild(r.createElementNS(Df,"svg"));f.style.width=s/l+"em";let u=f.appendChild(r.createElementNS(Df,"use"));u.setAttributeNS(Nf,"href",/([^#]*)/.exec(r.location.toString())[1]+"#"+o)}else if(e.dom){i.appendChild(e.dom.cloneNode(true))}else{let{text:t,css:n}=e;i.appendChild(r.createElement("span")).textContent=t||"";if(n)i.firstChild.style.cssText=n}return i}function Pf(t,e,r){let[i,n]=t.nodeType==9?[t,t.body]:[t.ownerDocument||document,t];let s=i.getElementById(Rf+"-collection");if(!s){s=i.createElementNS(Df,"svg");s.id=Rf+"-collection";s.style.display="none";n.insertBefore(s,n.firstChild)}let l=i.createElementNS(Df,"symbol");l.id=e;l.setAttribute("viewBox","0 0 "+r.width+" "+r.height);let o=l.appendChild(i.createElementNS(Df,"path"));o.setAttribute("d",r.path);s.appendChild(l)}const $f="ProseMirror-menu";class Tf{constructor(t){this.spec=t}render(t){let e=this.spec;let r=e.render?e.render(t):e.icon?qf(t.root,e.icon):e.label?Of("div",null,Af(t,e.label)):null;if(!r)throw new RangeError("MenuItem without icon or label property");if(e.title){const i=typeof e.title==="function"?e.title(t.state):e.title;r.setAttribute("title",Af(t,i))}if(e.class)r.classList.add(e.class);if(e.css)r.style.cssText+=e.css;r.addEventListener("mousedown",(i=>{i.preventDefault();if(!r.classList.contains($f+"-disabled"))e.run(t.state,t.dispatch,t,i)}));function i(t){if(e.select){let i=e.select(t);r.style.display=i?"":"none";if(!i)return false}let i=true;if(e.enable){i=e.enable(t)||false;Zf(r,$f+"-disabled",!i)}if(e.active){let n=i&&e.active(t)||false;Zf(r,$f+"-active",n)}return true}return{dom:r,update:i}}}function Af(t,e){return t._props.translate?t._props.translate(e):e}let If={time:0,node:null};function zf(t){If.time=Date.now();If.node=t.target}function Jf(t){return Date.now()-100<If.time&&If.node&&t.contains(If.node)}class Bf{constructor(t,e={}){this.options=e;this.options=e||{};this.content=Array.isArray(t)?t:[t]}render(t){let e=jf(this.content,t);let r=t.dom.ownerDocument.defaultView||window;let i=Of("div",{class:$f+"-dropdown "+(this.options.class||""),style:this.options.css},Af(t,this.options.label||""));if(this.options.title)i.setAttribute("title",Af(t,this.options.title));let n=Of("div",{class:$f+"-dropdown-wrap"},i);let s=null;let l=null;let o=()=>{if(s&&s.close()){s=null;r.removeEventListener("mousedown",l)}};i.addEventListener("mousedown",(t=>{t.preventDefault();zf(t);if(s){o()}else{s=this.expand(n,e.dom);r.addEventListener("mousedown",l=()=>{if(!Jf(n))o()})}}));function f(t){let r=e.update(t);n.style.display=r?"":"none";return r}return{dom:n,update:f}}expand(t,e){let r=Of("div",{class:$f+"-dropdown-menu "+(this.options.class||"")},e);let i=false;function n(){if(i)return false;i=true;t.removeChild(r);return true}t.appendChild(r);return{close:n,node:r}}}function jf(t,e){let r=[],i=[];for(let n=0;n<t.length;n++){let{dom:s,update:l}=t[n].render(e);r.push(Of("div",{class:$f+"-dropdown-item"},s));i.push(l)}return{dom:r,update:Ff(i,r)}}function Ff(t,e){return r=>{let i=false;for(let n=0;n<t.length;n++){let s=t[n](r);e[n].style.display=s?"":"none";if(s)i=true}return i}}class Lf{constructor(t,e={}){this.options=e;this.content=Array.isArray(t)?t:[t]}render(t){let e=jf(this.content,t);let r=t.dom.ownerDocument.defaultView||window;let i=Of("div",{class:$f+"-submenu-label"},Af(t,this.options.label||""));let n=Of("div",{class:$f+"-submenu-wrap"},i,Of("div",{class:$f+"-submenu"},e.dom));let s=null;i.addEventListener("mousedown",(t=>{t.preventDefault();zf(t);Zf(n,$f+"-submenu-wrap-active",false);if(!s)r.addEventListener("mousedown",s=()=>{if(!Jf(n)){n.classList.remove($f+"-submenu-wrap-active");r.removeEventListener("mousedown",s);s=null}})}));function l(t){let r=e.update(t);n.style.display=r?"":"none";return r}return{dom:n,update:l}}}function Wf(t,e){let r=document.createDocumentFragment();let i=[],n=[];for(let s=0;s<e.length;s++){let l=e[s],o=[],f=[];for(let e=0;e<l.length;e++){let{dom:i,update:n}=l[e].render(t);let s=Of("span",{class:$f+"item"},i);r.appendChild(s);f.push(s);o.push(n)}if(o.length){i.push(Ff(o,f));if(s<e.length-1)n.push(r.appendChild(_f()))}}function s(t){let e=false,r=false;for(let s=0;s<i.length;s++){let l=i[s](t);if(s)n[s-1].style.display=r&&l?"":"none";r=l;if(l)e=true}return e}return{dom:r,update:s}}function _f(){return Of("span",{class:$f+"separator"})}const Uf={join:{width:800,height:900,path:"M0 75h800v125h-800z M0 825h800v-125h-800z M250 400h100v-100h100v100h100v100h-100v100h-100v-100h-100z"},lift:{width:1024,height:1024,path:"M219 310v329q0 7-5 12t-12 5q-8 0-13-5l-164-164q-5-5-5-13t5-13l164-164q5-5 13-5 7 0 12 5t5 12zM1024 749v109q0 7-5 12t-12 5h-987q-7 0-12-5t-5-12v-109q0-7 5-12t12-5h987q7 0 12 5t5 12zM1024 530v109q0 7-5 12t-12 5h-621q-7 0-12-5t-5-12v-109q0-7 5-12t12-5h621q7 0 12 5t5 12zM1024 310v109q0 7-5 12t-12 5h-621q-7 0-12-5t-5-12v-109q0-7 5-12t12-5h621q7 0 12 5t5 12zM1024 91v109q0 7-5 12t-12 5h-987q-7 0-12-5t-5-12v-109q0-7 5-12t12-5h987q7 0 12 5t5 12z"},selectParentNode:{text:"⬚",css:"font-weight: bold"},undo:{width:1024,height:1024,path:"M761 1024c113-206 132-520-313-509v253l-384-384 384-384v248c534-13 594 472 313 775z"},redo:{width:1024,height:1024,path:"M576 248v-248l384 384-384 384v-253c-446-10-427 303-313 509-280-303-221-789 313-775z"},strong:{width:805,height:1024,path:"M317 869q42 18 80 18 214 0 214-191 0-65-23-102-15-25-35-42t-38-26-46-14-48-6-54-1q-41 0-57 5 0 30-0 90t-0 90q0 4-0 38t-0 55 2 47 6 38zM309 442q24 4 62 4 46 0 81-7t62-25 42-51 14-81q0-40-16-70t-45-46-61-24-70-8q-28 0-74 7 0 28 2 86t2 86q0 15-0 45t-0 45q0 26 0 39zM0 950l1-53q8-2 48-9t60-15q4-6 7-15t4-19 3-18 1-21 0-19v-37q0-561-12-585-2-4-12-8t-25-6-28-4-27-2-17-1l-2-47q56-1 194-6t213-5q13 0 39 0t38 0q40 0 78 7t73 24 61 40 42 59 16 78q0 29-9 54t-22 41-36 32-41 25-48 22q88 20 146 76t58 141q0 57-20 102t-53 74-78 48-93 27-100 8q-25 0-75-1t-75-1q-60 0-175 6t-132 6z"},em:{width:585,height:1024,path:"M0 949l9-48q3-1 46-12t63-21q16-20 23-57 0-4 35-165t65-310 29-169v-14q-13-7-31-10t-39-4-33-3l10-58q18 1 68 3t85 4 68 1q27 0 56-1t69-4 56-3q-2 22-10 50-17 5-58 16t-62 19q-4 10-8 24t-5 22-4 26-3 24q-15 84-50 239t-44 203q-1 5-7 33t-11 51-9 47-3 32l0 10q9 2 105 17-1 25-9 56-6 0-18 0t-18 0q-16 0-49-5t-49-5q-78-1-117-1-29 0-81 5t-69 6z"},code:{width:896,height:1024,path:"M608 192l-96 96 224 224-224 224 96 96 288-320-288-320zM288 192l-288 320 288 320 96-96-224-224 224-224-96-96z"},link:{width:951,height:1024,path:"M832 694q0-22-16-38l-118-118q-16-16-38-16-24 0-41 18 1 1 10 10t12 12 8 10 7 14 2 15q0 22-16 38t-38 16q-8 0-15-2t-14-7-10-8-12-12-10-10q-18 17-18 41 0 22 16 38l117 118q15 15 38 15 22 0 38-14l84-83q16-16 16-38zM430 292q0-22-16-38l-117-118q-16-16-38-16-22 0-38 15l-84 83q-16 16-16 38 0 22 16 38l118 118q15 15 38 15 24 0 41-17-1-1-10-10t-12-12-8-10-7-14-2-15q0-22 16-38t38-16q8 0 15 2t14 7 10 8 12 12 10 10q18-17 18-41zM941 694q0 68-48 116l-84 83q-47 47-116 47-69 0-116-48l-117-118q-47-47-47-116 0-70 50-119l-50-50q-49 50-118 50-68 0-116-48l-118-118q-48-48-48-116t48-116l84-83q47-47 116-47 69 0 116 48l117 118q47 47 47 116 0 70-50 119l50 50q49-50 118-50 68 0 116 48l118 118q48 48 48 116z"},bulletList:{width:768,height:896,path:"M0 512h128v-128h-128v128zM0 256h128v-128h-128v128zM0 768h128v-128h-128v128zM256 512h512v-128h-512v128zM256 256h512v-128h-512v128zM256 768h512v-128h-512v128z"},orderedList:{width:768,height:896,path:"M320 512h448v-128h-448v128zM320 768h448v-128h-448v128zM320 128v128h448v-128h-448zM79 384h78v-256h-36l-85 23v50l43-2v185zM189 590c0-36-12-78-96-78-33 0-64 6-83 16l1 66c21-10 42-15 67-15s32 11 32 28c0 26-30 58-110 112v50h192v-67l-91 2c49-30 87-66 87-113l1-1z"},blockquote:{width:640,height:896,path:"M0 448v256h256v-256h-128c0 0 0-128 128-128v-128c0 0-256 0-256 256zM640 320v-128c0 0-256 0-256 256v256h256v-256h-128c0 0 0-128 128-128z"}};const Hf=new Tf({title:"Join with above block",run:Jo,select:t=>Jo(t),icon:Uf.join});const Kf=new Tf({title:"Lift out of enclosing block",run:jo,select:t=>jo(t),icon:Uf.lift});const Gf=new Tf({title:"Select parent node",run:Go,select:t=>Go(t),icon:Uf.selectParentNode});let Vf=new Tf({title:"Undo last change",run:Eo,enable:t=>Eo(t),icon:Uf.undo});let Xf=new Tf({title:"Redo last undone change",run:Do,enable:t=>Do(t),icon:Uf.redo});function Yf(t,e){let r={run(r,i){return ef(t,e.attrs)(r,i)},select(r){return ef(t,e.attrs)(r)}};for(let t in e)r[t]=e[t];return new Tf(r)}function Qf(t,e){let r=rf(t,e.attrs);let i={run:r,enable(t){return r(t)},active(r){let{$from:i,to:n,node:s}=r.selection;if(s)return s.hasMarkup(t,e.attrs);return n<=i.end()&&i.parent.hasMarkup(t,e.attrs)}};for(let t in e)i[t]=e[t];return new Tf(i)}function Zf(t,e,r){if(r)t.classList.add(e);else t.classList.remove(e)}const tu="ProseMirror-menubar";function eu(){if(typeof navigator=="undefined")return false;let t=navigator.userAgent;return!/Edge\/\d/.test(t)&&/AppleWebKit/.test(t)&&/Mobile\/\w+/.test(t)}function ru(t){return new er({view(e){return new iu(e,t)}})}class iu{constructor(t,e){this.editorView=t;this.options=e;this.spacer=null;this.maxHeight=0;this.widthForMaxHeight=0;this.floating=false;this.scrollHandler=null;this.wrapper=Of("div",{class:tu+"-wrapper"});this.menu=this.wrapper.appendChild(Of("div",{class:tu}));this.menu.className=tu;if(t.dom.parentNode)t.dom.parentNode.replaceChild(this.wrapper,t.dom);this.wrapper.appendChild(t.dom);let{dom:r,update:i}=Wf(this.editorView,this.options.content);this.contentUpdate=i;this.menu.appendChild(r);this.update();if(e.floating&&!eu()){this.updateFloat();let t=lu(this.wrapper);this.scrollHandler=e=>{let r=this.editorView.root;if(!(r.body||r).contains(this.wrapper))t.forEach((t=>t.removeEventListener("scroll",this.scrollHandler)));else this.updateFloat(e.target.getBoundingClientRect?e.target:undefined)};t.forEach((t=>t.addEventListener("scroll",this.scrollHandler)))}}update(){this.contentUpdate(this.editorView.state);if(this.floating){this.updateScrollCursor()}else{if(this.menu.offsetWidth!=this.widthForMaxHeight){this.widthForMaxHeight=this.menu.offsetWidth;this.maxHeight=0}if(this.menu.offsetHeight>this.maxHeight){this.maxHeight=this.menu.offsetHeight;this.menu.style.minHeight=this.maxHeight+"px"}}}updateScrollCursor(){let t=this.editorView.root.getSelection();if(!t.focusNode)return;let e=t.getRangeAt(0).getClientRects();let r=e[nu(t)?0:e.length-1];if(!r)return;let i=this.menu.getBoundingClientRect();if(r.top<i.bottom&&r.bottom>i.top){let t=su(this.wrapper);if(t)t.scrollTop-=i.bottom-r.top}}updateFloat(t){let e=this.wrapper,r=e.getBoundingClientRect(),i=t?Math.max(0,t.getBoundingClientRect().top):0;if(this.floating){if(r.top>=i||r.bottom<this.menu.offsetHeight+10){this.floating=false;this.menu.style.position=this.menu.style.left=this.menu.style.top=this.menu.style.width="";this.menu.style.display="";this.spacer.parentNode.removeChild(this.spacer);this.spacer=null}else{let n=(e.offsetWidth-e.clientWidth)/2;this.menu.style.left=r.left+n+"px";this.menu.style.display=r.top>(this.editorView.dom.ownerDocument.defaultView||window).innerHeight?"none":"";if(t)this.menu.style.top=i+"px"}}else{if(r.top<i&&r.bottom>=this.menu.offsetHeight+10){this.floating=true;let r=this.menu.getBoundingClientRect();this.menu.style.left=r.left+"px";this.menu.style.width=r.width+"px";if(t)this.menu.style.top=i+"px";this.menu.style.position="fixed";this.spacer=Of("div",{class:tu+"-spacer",style:`height: ${r.height}px`});e.insertBefore(this.spacer,this.menu)}}}destroy(){if(this.wrapper.parentNode)this.wrapper.parentNode.replaceChild(this.editorView.dom,this.wrapper)}}function nu(t){if(t.anchorNode==t.focusNode)return t.anchorOffset>t.focusOffset;return t.anchorNode.compareDocumentPosition(t.focusNode)==Node.DOCUMENT_POSITION_FOLLOWING}function su(t){for(let e=t.parentNode;e;e=e.parentNode)if(e.scrollHeight>e.clientHeight)return e}function lu(t){let e=[t.ownerDocument.defaultView||window];for(let r=t.parentNode;r;r=r.parentNode)e.push(r);return e}class ou{constructor(t,e,r={}){this.match=t;this.match=t;this.handler=typeof e=="string"?fu(e):e;this.undoable=r.undoable!==false;this.inCode=r.inCode||false}}function fu(t){return function(e,r,i,n){let s=t;if(r[1]){let t=r[0].lastIndexOf(r[1]);s+=r[0].slice(t+r[1].length);i+=t;let e=i-n;if(e>0){s=r[0].slice(t-e,t)+s;i=n}}return e.tr.insertText(s,i,n)}}const uu=500;function hu({rules:t}){let e=new er({state:{init(){return null},apply(t,e){let r=t.getMeta(this);if(r)return r;return t.selectionSet||t.docChanged?null:e}},props:{handleTextInput(r,i,n,s){return au(r,i,n,s,t,e)},handleDOMEvents:{compositionend:r=>{setTimeout((()=>{let{$cursor:i}=r.state.selection;if(i)au(r,i.pos,i.pos,"",t,e)}))}}},isInputRules:true});return e}function au(t,e,r,i,n,s){if(t.composing)return false;let l=t.state,o=l.doc.resolve(e);let f=o.parent.textBetween(Math.max(0,o.parentOffset-uu),o.parentOffset,null,"")+i;for(let u=0;u<n.length;u++){let h=n[u];if(o.parent.type.spec.code){if(!h.inCode)continue}else if(h.inCode==="only"){continue}let a=h.match.exec(f);let c=a&&h.handler(l,a,e-(a[0].length-i.length),r);if(!c)continue;if(h.undoable)c.setMeta(s,{transform:c,from:e,to:r,text:i});t.dispatch(c);return true}return false}const cu=(t,e)=>{let r=t.plugins;for(let i=0;i<r.length;i++){let n=r[i],s;if(n.spec.isInputRules&&(s=n.getState(t))){if(e){let r=t.tr,i=s.transform;for(let t=i.steps.length-1;t>=0;t--)r.step(i.steps[t].invert(i.docs[t]));if(s.text){let e=r.doc.resolve(s.from).marks();r.replaceWith(s.from,s.to,t.schema.text(s.text,e))}else{r.delete(s.from,s.to)}e(r)}return true}}return false};const du=new ou(/--$/,"—");const pu=new ou(/\.\.\.$/,"…");const mu=new ou(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,"“");const wu=new ou(/"$/,"”");const gu=new ou(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,"‘");const bu=new ou(/'$/,"’");const vu=[mu,wu,gu,bu];function yu(t,e,r=null,i){return new ou(t,((t,n,s,l)=>{let o=r instanceof Function?r(n):r;let f=t.tr.delete(s,l);let u=f.doc.resolve(s),h=u.blockRange(),a=h&&Yt(h,e,o);if(!a)return null;f.wrap(h,a);let c=f.doc.resolve(s-1).nodeBefore;if(c&&c.type==e&&oe(f.doc,s-1)&&(!i||i(n,c)))f.join(s-1);return f}))}function ku(t,e,r=null){return new ou(t,((t,i,n,s)=>{let l=t.doc.resolve(n);let o=r instanceof Function?r(i):r;if(!l.node(-1).canReplaceWith(l.index(-1),l.indexAfter(-1),e))return null;return t.tr.delete(n,s).setBlockType(n,n,e,o)}))}const Mu="ProseMirror-prompt";function xu(t){let e=document.body.appendChild(document.createElement("div"));e.className=Mu;let r=t=>{if(!e.contains(t.target))i()};setTimeout((()=>window.addEventListener("mousedown",r)),50);let i=()=>{window.removeEventListener("mousedown",r);if(e.parentNode)e.parentNode.removeChild(e)};let n=[];for(let e in t.fields)n.push(t.fields[e].render());let s=document.createElement("button");s.type="submit";s.className=Mu+"-submit";s.textContent="OK";let l=document.createElement("button");l.type="button";l.className=Mu+"-cancel";l.textContent="Cancel";l.addEventListener("click",i);let o=e.appendChild(document.createElement("form"));if(t.title)o.appendChild(document.createElement("h5")).textContent=t.title;n.forEach((t=>{o.appendChild(document.createElement("div")).appendChild(t)}));let f=o.appendChild(document.createElement("div"));f.className=Mu+"-buttons";f.appendChild(s);f.appendChild(document.createTextNode(" "));f.appendChild(l);let u=e.getBoundingClientRect();e.style.top=(window.innerHeight-u.height)/2+"px";e.style.left=(window.innerWidth-u.width)/2+"px";let h=()=>{let e=Su(t.fields,n);if(e){i();t.callback(e)}};o.addEventListener("submit",(t=>{t.preventDefault();h()}));o.addEventListener("keydown",(t=>{if(t.keyCode==27){t.preventDefault();i()}else if(t.keyCode==13&&!(t.ctrlKey||t.metaKey||t.shiftKey)){t.preventDefault();h()}else if(t.keyCode==9){window.setTimeout((()=>{if(!e.contains(document.activeElement))i()}),500)}}));let a=o.elements[0];if(a)a.focus()}function Su(t,e){let r=Object.create(null),i=0;for(let n in t){let s=t[n],l=e[i++];let o=s.read(l),f=s.validate(o);if(f){Ou(l,f);return null}r[n]=s.clean(o)}return r}function Ou(t,e){let r=t.parentNode;let i=r.appendChild(document.createElement("div"));i.style.left=t.offsetLeft+t.offsetWidth+2+"px";i.style.top=t.offsetTop-5+"px";i.className="ProseMirror-invalid";i.textContent=e;setTimeout((()=>r.removeChild(i)),1500)}class Eu{constructor(t){this.options=t}read(t){return t.value}validateType(t){return null}validate(t){if(!t&&this.options.required)return"Required field";return this.validateType(t)||(this.options.validate?this.options.validate(t):null)}clean(t){return this.options.clean?this.options.clean(t):t}}class Du extends Eu{render(){let t=document.createElement("input");t.type="text";t.placeholder=this.options.label;t.value=this.options.value||"";t.autocomplete="off";return t}}function Nu(t,e){let r=t.selection.$from;for(let t=r.depth;t>=0;t--){let i=r.index(t);if(r.node(t).canReplaceWith(i,i,e))return true}return false}function Ru(t){return new Tf({title:"Insert image",label:"Image",enable(e){return Nu(e,t)},run(e,r,i){let{from:n,to:s}=e.selection,l=null;if(e.selection instanceof Be&&e.selection.node.type==t)l=e.selection.node.attrs;xu({title:"Insert image",fields:{src:new Du({label:"Location",required:true,value:l&&l.src}),title:new Du({label:"Title",value:l&&l.title}),alt:new Du({label:"Description",value:l?l.alt:e.doc.textBetween(n,s," ")})},callback(e){i.dispatch(i.state.tr.replaceSelectionWith(t.createAndFill(e)));i.focus()}})}})}function Cu(t,e){let r={label:e.title,run:t};for(let t in e)r[t]=e[t];if(!e.enable&&!e.select)r[e.enable?"enable":"select"]=e=>t(e);return new Tf(r)}function qu(t,e){let{from:r,$from:i,to:n,empty:s}=t.selection;if(s)return!!e.isInSet(t.storedMarks||i.marks());else return t.doc.rangeHasMark(r,n,e)}function Pu(t,e){let r={active(e){return qu(e,t)}};for(let t in e)r[t]=e[t];return Cu(sf(t),r)}function $u(t){return new Tf({title:"Add or remove link",icon:Uf.link,active(e){return qu(e,t)},enable(t){return!t.selection.empty},run(e,r,i){if(qu(e,t)){sf(t)(e,r);return true}xu({title:"Create a link",fields:{href:new Du({label:"Link target",required:true}),title:new Du({label:"Title"})},callback(e){sf(t,e)(i.state,i.dispatch);i.focus()}})}})}function Tu(t,e){return Cu(Jl(t,e.attrs),e)}function Au(t){let e={};let r;if(r=t.marks.strong)e.toggleStrong=Pu(r,{title:"Toggle strong style",icon:Uf.strong});if(r=t.marks.em)e.toggleEm=Pu(r,{title:"Toggle emphasis",icon:Uf.em});if(r=t.marks.code)e.toggleCode=Pu(r,{title:"Toggle code font",icon:Uf.code});if(r=t.marks.link)e.toggleLink=$u(r);let i;if(i=t.nodes.image)e.insertImage=Ru(i);if(i=t.nodes.bullet_list)e.wrapBulletList=Tu(i,{title:"Wrap in bullet list",icon:Uf.bulletList});if(i=t.nodes.ordered_list)e.wrapOrderedList=Tu(i,{title:"Wrap in ordered list",icon:Uf.orderedList});if(i=t.nodes.blockquote)e.wrapBlockQuote=Yf(i,{title:"Wrap in block quote",icon:Uf.blockquote});if(i=t.nodes.paragraph)e.makeParagraph=Qf(i,{title:"Change to paragraph",label:"Plain"});if(i=t.nodes.code_block)e.makeCodeBlock=Qf(i,{title:"Change to code block",label:"Code"});if(i=t.nodes.heading)for(let t=1;t<=10;t++)e["makeHead"+t]=Qf(i,{title:"Change to heading "+t,label:"Level "+t,attrs:{level:t}});if(i=t.nodes.horizontal_rule){let t=i;e.insertHorizontalRule=new Tf({title:"Insert horizontal rule",label:"Horizontal rule",enable(e){return Nu(e,t)},run(e,r){r(e.tr.replaceSelectionWith(t.create()))}})}let n=t=>t.filter((t=>t));e.insertMenu=new Bf(n([e.insertImage,e.insertHorizontalRule]),{label:"Insert"});e.typeMenu=new Bf(n([e.makeParagraph,e.makeCodeBlock,e.makeHead1&&new Lf(n([e.makeHead1,e.makeHead2,e.makeHead3,e.makeHead4,e.makeHead5,e.makeHead6]),{label:"Heading"})]),{label:"Type..."});e.inlineMenu=[n([e.toggleStrong,e.toggleEm,e.toggleCode,e.toggleLink])];e.blockMenu=[n([e.wrapBulletList,e.wrapOrderedList,e.wrapBlockQuote,Hf,Kf,Gf])];e.fullMenu=e.inlineMenu.concat([[e.insertMenu,e.typeMenu]],[[Vf,Xf]],e.blockMenu);return e}const Iu=typeof navigator!="undefined"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):false;function zu(t,e){let r={},i;function n(t,i){if(e){let r=e[t];if(r===false)return;if(r)t=r}r[t]=i}n("Mod-z",Eo);n("Shift-Mod-z",Do);n("Backspace",cu);if(!Iu)n("Mod-y",Do);n("Alt-ArrowUp",Jo);n("Alt-ArrowDown",Bo);n("Mod-BracketLeft",jo);n("Escape",Go);if(i=t.marks.strong){n("Mod-b",sf(i));n("Mod-B",sf(i))}if(i=t.marks.em){n("Mod-i",sf(i));n("Mod-I",sf(i))}if(i=t.marks.code)n("Mod-`",sf(i));if(i=t.nodes.bullet_list)n("Shift-Ctrl-8",Jl(i));if(i=t.nodes.ordered_list)n("Shift-Ctrl-9",Jl(i));if(i=t.nodes.blockquote)n("Ctrl->",ef(i));if(i=t.nodes.hard_break){let t=i,e=lf(Wo,((e,r)=>{if(r)r(e.tr.replaceSelectionWith(t.create()).scrollIntoView());return true}));n("Mod-Enter",e);n("Shift-Enter",e);if(Iu)n("Ctrl-Enter",e)}if(i=t.nodes.list_item){n("Enter",jl(i));n("Mod-[",Fl(i));n("Mod-]",_l(i))}if(i=t.nodes.paragraph)n("Shift-Ctrl-0",rf(i));if(i=t.nodes.code_block)n("Shift-Ctrl-\\",rf(i));if(i=t.nodes.heading)for(let t=1;t<=6;t++)n("Shift-Ctrl-"+t,rf(i,{level:t}));if(i=t.nodes.horizontal_rule){let t=i;n("Mod-_",((e,r)=>{if(r)r(e.tr.replaceSelectionWith(t.create()).scrollIntoView());return true}))}return r}function Ju(t){return yu(/^\s*>\s$/,t)}function Bu(t){return yu(/^(\d+)\.\s$/,t,(t=>({order:+t[1]})),((t,e)=>e.childCount+e.attrs.order==+t[1]))}function ju(t){return yu(/^\s*([-+*])\s$/,t)}function Fu(t){return ku(/^```$/,t)}function Lu(t,e){return ku(new RegExp("^(#{1,"+e+"})\\s$"),t,(t=>({level:t[1].length})))}function Wu(t){let e=vu.concat(pu,du),r;if(r=t.nodes.blockquote)e.push(Ju(r));if(r=t.nodes.ordered_list)e.push(Bu(r));if(r=t.nodes.bullet_list)e.push(ju(r));if(r=t.nodes.code_block)e.push(Fu(r));if(r=t.nodes.heading)e.push(Lu(r,6));return hu({rules:e})}function _u(t){let e=[Wu(t.schema),ro(zu(t.schema,t.mapKeys)),ro(cf),df(),vf()];if(t.menuBar!==false)e.push(ru({floating:t.floatingMenu!==false,content:t.menuContent||Au(t.schema).fullMenu}));if(t.history!==false)e.push(Oo());return e.concat(new er({props:{attributes:{class:"ProseMirror-example-setup-style"}}}))}class Uu{constructor(t){this.markNames={bold:"strong",italic:"em",underline:"underline",blockquote:"blockquote",headerlevel1:"headerlevel1",headerlevel2:"headerlevel2",headerlevel3:"headerlevel3",addorremovelink:"link",numberedlist:"ordered_list",list:"bullet_list"};this.schema=t}createCommand(t){if(this.markNames[t]){t=this.markNames[t]}switch(t){case"strong":case"em":case"underline":return this.createToggleMarkCommand(t);case"paragraph":return this.createSetNodeTypeCommand(t);case"headerlevel1":case"headerlevel2":case"headerlevel3":return this.createSetNodeTypeCommand("heading",parseInt(t[t.length-1],10));case"blockquote":return this.createWrapInCommand(t);case"ordered_list":case"bullet_list":return this.createListCommand(t);default:throw new Error(`The Mark "${t}" is not supported`)}}createToggleMarkCommand(t){const e=this.schema.marks[t];if(!e){throw new Error(`Mark "${t}" not found in schema`)}return sf(e)}createSetNodeTypeCommand(t,e){const r=this.schema.nodes[t];if(!r){throw new Error(`Node type "${t}" not found in schema`)}if(t==="heading"&&e){return rf(r,{level:e})}else{return rf(r)}}createWrapInCommand(t){const e=this.schema.nodes[t];if(!e){throw new Error(`Node type "${t}" not found in schema`)}return ef(e)}createListCommand(t){const e=this.schema.nodes[t];if(!e){throw new Error(`List type "${t}" not found in schema`)}return Jl(e)}}const Hu=[{text:"Bold",commandText:"⌘ B",icon:"bold",iconOnly:true},{text:"Italic",commandText:"⌘ I",icon:"italic",iconOnly:true},{text:"Add or remove link",commandText:"⌘ shift U",icon:"link",iconOnly:true},{separator:true},{text:"Header Level 1",icon:"header_1",iconOnly:true},{text:"Header Level 2",icon:"header_2",iconOnly:true},{text:"Header Level 3",icon:"header_3",iconOnly:true},{separator:true},{text:"List",icon:"list",iconOnly:true},{text:"Numbered list",icon:"numbered_list",iconOnly:true},{text:"Blockquote",icon:"quote_right",iconOnly:true}];const Ku='@charset "UTF-8";:host(limel-prosemirror-adapter){isolation:isolate;display:block}*{box-sizing:border-box}.ProseMirror-menubar-wrapper{display:grid;grid-template-rows:auto 1fr}.ProseMirror-textblock-dropdown{min-width:3em}.ProseMirror-tooltip .ProseMirror-menu{width:-webkit-fit-content;width:fit-content;white-space:pre}.ProseMirror{position:relative;word-wrap:break-word;white-space:pre-wrap;white-space:break-spaces;-webkit-font-variant-ligatures:none;font-variant-ligatures:none;font-feature-settings:"liga" 0;padding-top:0.75rem}.ProseMirror [draggable][contenteditable=false]{user-select:text}.ProseMirror:focus-visible{outline:none}.ProseMirror-hideselection{caret-color:transparent}.ProseMirror-hideselection *::selection{background:transparent}.ProseMirror-hideselection *::-moz-selection{background:transparent}.ProseMirror-selectednode{outline:0.125rem solid rgb(var(--color-sky-light))}li.ProseMirror-selectednode{outline:none}li.ProseMirror-selectednode:after{content:"";position:absolute;left:-2rem;right:-0.125rem;top:-0.125rem;bottom:-0.125rem;border:0.125rem solid rgb(var(--color-sky-light));pointer-events:none}img.ProseMirror-separator{display:inline !important;border:none !important;margin:0 !important}:host{--mdc-theme-primary:var(\n --lime-primary-color,\n rgb(var(--color-teal-default))\n );--mdc-theme-secondary:var(\n --lime-secondary-color,\n rgb(var(--contrast-1100))\n );--mdc-theme-on-primary:var(\n --lime-on-primary-color,\n rgb(var(--contrast-100))\n );--mdc-theme-on-secondary:var(\n --lime-on-secondary-color,\n rgb(var(--contrast-100))\n );--mdc-theme-text-disabled-on-background:var(\n --lime-text-disabled-on-background-color,\n rgba(var(--contrast-1700), 0.38)\n );--mdc-theme-text-primary-on-background:var(\n --lime-text-primary-on-background-color,\n rgba(var(--contrast-1700), 0.87)\n );--mdc-theme-text-secondary-on-background:var(\n --lime-text-secondary-on-background-color,\n rgba(var(--contrast-1700), 0.54)\n );--mdc-theme-error:var(\n --lime-error-background-color,\n rgb(var(--color-red-dark))\n );--lime-error-text-color:rgb(var(--color-red-darker));--mdc-theme-surface:var(\n --lime-surface-background-color,\n rgb(var(--contrast-100))\n );--mdc-theme-on-surface:var(\n --lime-on-surface-color,\n rgb(var(--contrast-1500))\n )}div#editor .ProseMirror-menubar{position:sticky !important;z-index:1;top:0;margin-left:-0.75rem;margin-right:-0.75rem;background-color:rgba(var(--contrast-200), 0.5);backdrop-filter:blur(0.25rem);-webkit-backdrop-filter:blur(0.25rem)}div#editor .ProseMirror-menubar[style*="position: fixed"]{box-shadow:0 0.25rem 0.5rem -0.5rem rgb(var(--color-black), 0.8)}div#editor .ProseMirror-menubar-spacer{display:none}.ProseMirror-menubar{position:relative;z-index:1;display:flex;flex-wrap:wrap;gap:0.25rem;align-items:center;padding:0.125rem;border-top-left-radius:0.5rem;border-top-right-radius:0.5rem}.ProseMirror-menuitem{position:relative;flex-shrink:0;display:flex;align-items:center;justify-content:center;white-space:nowrap;line-height:1;height:1.5rem;min-width:1.5rem;border-radius:0.25rem;color:rgb(var(--contrast-1100));font-size:0.8125rem}.ProseMirror-menuitem:not(:has(.ProseMirror-menu-disabled)){transition:color 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease, transform 0.1s ease-out;cursor:pointer;color:var(--mdc-theme-on-surface);background-color:transparent}.ProseMirror-menuitem:not(:has(.ProseMirror-menu-disabled)):hover{color:var(--mdc-theme-on-surface);background-color:var(--lime-elevated-surface-background-color);box-shadow:var(--button-shadow-hovered)}.ProseMirror-menuitem:not(:has(.ProseMirror-menu-disabled)):active{box-shadow:var(--button-shadow-pressed);transform:translate3d(0, 0.08rem, 0)}.ProseMirror-menuitem:has(.ProseMirror-menu-active){box-shadow:var(--button-shadow-inset);color:var(--mdc-theme-primary)}.ProseMirror-menuitem:has(.ProseMirror-menu-active) svg{color:var(--mdc-theme-primary)}.ProseMirror-menuitem:has(.ProseMirror-menu-dropdown-menu){box-shadow:var(--button-shadow-inset)}.ProseMirror-menuitem svg{fill:currentColor;height:1rem;color:rgb(var(--contrast-1100))}.ProseMirror-menuseparator{border-radius:1rem;background-color:rgb(var(--contrast-600));width:0.125rem;height:1rem}.ProseMirror-menu-dropdown{position:relative;display:flex;align-items:center;gap:0.5rem;padding:0 0.5rem}.ProseMirror-menu-dropdown:after{content:"";border-left:0.25rem solid transparent;border-right:0.25rem solid transparent;border-top:0.25rem solid currentColor}.ProseMirror-menu-dropdown-menu,.ProseMirror-menu-submenu{box-shadow:0px 5px 5px -3px rgba(0, 0, 0, 0.2), 0px 8px 10px 1px rgba(0, 0, 0, 0.14), 0px 3px 14px 2px rgba(0, 0, 0, 0.12)}.ProseMirror-menu-dropdown-menu{position:absolute;top:100%;background:rgb(var(--contrast-100));border-radius:0.25rem;padding:0.125rem}.ProseMirror-menu-submenu{position:absolute;background:rgb(var(--contrast-100));border-radius:0.25rem;padding:0.125rem;display:none;min-width:4em;left:100%;top:-0.75rem}.ProseMirror-menu-dropdown-item{transition:background-color 0.2s ease;cursor:pointer;border-radius:0.375rem;min-height:2.5rem;display:flex;align-items:center;width:100%}.ProseMirror-menu-dropdown-item>div{padding:0 1rem;width:100%}.ProseMirror-menu-dropdown-item:not(:has(.ProseMirror-menu-disabled)):hover{background-color:rgb(var(--contrast-300))}.ProseMirror-menu-submenu-wrap{position:relative;margin-right:-0.25rem}.ProseMirror-menu-submenu-wrap:hover .ProseMirror-menu-submenu{display:block}.ProseMirror-menu-submenu-label{position:relative;display:flex;align-items:center;justify-content:space-between;gap:0.5rem}.ProseMirror-menu-submenu-label:after{content:"";border-top:0.25rem solid transparent;border-bottom:0.25rem solid transparent;border-left:0.25rem solid currentColor}.ProseMirror-menu-disabled{opacity:0.3;cursor:default}.ProseMirror-menu-submenu-wrap-active .ProseMirror-menu-submenu{display:block}blockquote{position:relative;font-weight:100;font-size:0.875rem;max-width:100%;line-height:1.4;margin:0;padding:0.5rem 1.25rem;border-radius:0.05rem 0.75rem;background-color:rgb(var(--contrast-300))}blockquote:before,blockquote:after{position:absolute;font-size:2.75rem;opacity:0.4}blockquote:before{content:"“";left:0;top:-0.75rem}blockquote:after{content:"”";right:0;bottom:-2rem}:host(limel-markdown.truncate-paragraphs) p{overflow:hidden;white-space:nowrap;text-overflow:ellipsis}p,li{font-size:0.875rem;word-break:break-word;hyphens:auto;-webkit-hyphens:auto}a{word-break:break-all}p{margin-top:0;margin-bottom:0.5rem}p:only-child{margin-bottom:0}a{transition:color 0.2s ease;color:var(--markdown-hyperlink-color, rgb(var(--color-blue-dark)));text-decoration:none}a:hover{color:var(--markdown-hyperlink-color--hovered, rgb(var(--color-blue-default)))}hr{margin:1.75rem 0 2rem 0;border-width:0;border-top:1px solid rgb(var(--contrast-500))}dl{display:grid;grid-template-columns:1fr 2fr;grid-template-rows:1fr;margin-bottom:2rem;border:1px solid rgb(var(--contrast-400));border-radius:0.375rem;background-color:rgb(var(--contrast-200))}dl dt,dl dd{padding:0.375rem 0.5rem;font-size:0.875rem;margin:0}dl dt:nth-of-type(even),dl dd:nth-of-type(even){background-color:rgb(var(--contrast-300))}dl dt:first-child{border-top-left-radius:0.375rem}dl dt:last-child{border-bottom-left-radius:0.375rem}dl dd:first-child{border-top-right-radius:0.375rem}dl dd:last-child{border-bottom-right-radius:0.375rem}h1{font-size:1.5rem}h2{font-size:1.25rem}h3{font-size:1.125rem}h4{font-size:1rem}h5{font-size:0.875rem}h6{font-size:0.75rem}h1,h2{margin-top:0.5rem;margin-bottom:0.5rem;letter-spacing:-0.03125rem;font-weight:500}h3,h4{margin-top:0.75rem;margin-bottom:0.25rem;font-weight:600}h5,h6{margin-top:0.5rem;margin-bottom:0.125rem;font-weight:600}h1,h2,h3,h4,h5,h6{word-break:break-word;hyphens:auto;-webkit-hyphens:auto}:not([contenteditable=true]) h1,:not([contenteditable=true]) h2,:not([contenteditable=true]) h3,:not([contenteditable=true]) h4,:not([contenteditable=true]) h5,:not([contenteditable=true]) h6{text-wrap:balance}[contenteditable=true] h1,[contenteditable=true] h2,[contenteditable=true] h3,[contenteditable=true] h4,[contenteditable=true] h5,[contenteditable=true] h6{text-wrap:initial}ul{list-style:none}ul li{position:relative;margin-left:0.75rem}ul li:before{content:"";position:absolute;left:-0.5rem;top:0.5rem;width:0.25rem;height:0.25rem;border-radius:50%;background-color:rgb(var(--contrast-700));display:block}ol{margin-top:0.25rem;padding-left:1rem}ul{margin-top:0.25rem;padding-left:0}ul ul,ul ol,ol ol,ol ul{margin-left:0}li{margin-bottom:0.25rem}code{font-family:ui-monospace, "Cascadia Code", "Source Code Pro", Menlo, Consolas, "DejaVu Sans Mono", monospace;font-size:0.8125rem;letter-spacing:-0.0125rem;color:rgb(var(--contrast-1300));-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none;display:inline-block;border-radius:0.25rem;padding:0.03125rem 0.25rem;background-color:rgb(var(--contrast-600))}pre>code{display:block;margin:0.5rem 0;padding:0.5rem 0.75rem;overflow:auto;white-space:pre-wrap}:host(limel-markdown:not(.no-table-styles)) table{table-layout:auto;min-width:100%;border-collapse:collapse;border-spacing:0;background:transparent;margin:0.75rem 0;border:1px solid rgb(var(--contrast-400))}:host(limel-markdown:not(.no-table-styles)) th,:host(limel-markdown:not(.no-table-styles)) td{text-align:left;vertical-align:top;transition:background-color 0.2s ease;font-size:0.875rem}:host(limel-markdown:not(.no-table-styles)) td{padding:0.5rem 0.375rem 0.75rem 0.375rem}:host(limel-markdown:not(.no-table-styles)) tr th{background-color:rgb(var(--contrast-400));padding:0.25rem 0.375rem;font-weight:normal}:host(limel-markdown:not(.no-table-styles)) tr th:only-child{text-align:center}:host(limel-markdown:not(.no-table-styles)) tbody tr:nth-child(odd) td{background-color:rgb(var(--contrast-200))}:host(limel-markdown:not(.no-table-styles)) tbody tr:hover td{background-color:rgb(var(--contrast-300))}';const Gu=class{constructor(r){t(this,r);this.change=e(this,"change",7);this.getHTML=()=>{if(this.view.dom.textContent===""){return""}else{return this.view.dom.innerHTML}};this.handleActionBarItem=t=>{t.preventDefault();const{text:e}=t.detail;const r=e.replace(/\s/g,"").toLowerCase();try{const t=this.menuCommandFactory.createCommand(r);this.executeCommand(t)}catch(t){throw new Error(`Error executing command: ${t}`)}};this.value=undefined;this.view=undefined;this.actionBarItems=[]}render(){return r("div",null,r("limel-action-bar",{accessibleLabel:"Toolbar",actions:this.actionBarItems,layout:"fullWidth",onItemSelected:this.handleActionBarItem}),r("div",{id:"editor"}))}componentDidLoad(){this.actionBarItems=Hu;const t=new et({nodes:zl(Rl.spec.nodes,"paragraph block*","block"),marks:Rl.spec.marks});this.view=new al(this.host.shadowRoot.querySelector("#editor"),{state:Ze.create({doc:it.fromSchema(t).parse(this.host.shadowRoot.querySelector("#editor")),plugins:_u({schema:t,menuBar:false})}),dispatchTransaction:t=>{const e=this.view.state.apply(t);this.view.updateState(e);this.change.emit(this.getHTML())}});this.menuCommandFactory=new Uu(t);if(this.value){this.view.dom.innerHTML=this.value}}executeCommand(t){const{state:e}=this.view;const r=e.selection;let i=e.tr;if(!r.empty){i.setSelection(r)}t(e,(t=>{i=t}));this.view.dispatch(i);this.view.focus()}get host(){return i(this)}};Gu.style=Ku;export{Gu as limel_prosemirror_adapter};
2
+ //# sourceMappingURL=p-db7ce0f8.entry.js.map