verso-cms 0.0.0-stage → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +168 -2
- package/bin/verso.js +16 -0
- package/editor/door.js +139 -0
- package/editor/editor.js +1880 -0
- package/editor/elevate.css +2158 -0
- package/editor/ext-attrs.js +87 -0
- package/editor/ext-blocks.js +422 -0
- package/editor/ext-builder.js +819 -0
- package/editor/ext-channels.js +574 -0
- package/editor/ext-components.js +160 -0
- package/editor/ext-history.js +242 -0
- package/editor/ext-palette.js +307 -0
- package/editor/ext-people.js +345 -0
- package/editor/ext-repeaters.js +143 -0
- package/editor/ext-screens.js +94 -0
- package/editor/ext-site-settings.js +318 -0
- package/editor/ext-site-view.js +632 -0
- package/editor/ext-tokens.js +1195 -0
- package/editor/new-page.js +252 -0
- package/editor/rich.js +23 -0
- package/package.json +69 -4
- package/src/blocks.js +269 -0
- package/src/box.js +339 -0
- package/src/build.js +210 -0
- package/src/cli.js +161 -0
- package/src/color.js +137 -0
- package/src/components.js +223 -0
- package/src/elevate.js +74 -0
- package/src/errors.js +46 -0
- package/src/extensions/README.md +70 -0
- package/src/extensions/blocks.js +294 -0
- package/src/extensions/builder.js +734 -0
- package/src/extensions/channels.js +341 -0
- package/src/extensions/components.js +141 -0
- package/src/extensions/history.js +169 -0
- package/src/extensions/palette.js +31 -0
- package/src/extensions/people.js +113 -0
- package/src/extensions/site-settings.js +251 -0
- package/src/extensions/site-view.js +381 -0
- package/src/extensions/tags.js +15 -0
- package/src/extensions/tokens.js +587 -0
- package/src/fonts.js +139 -0
- package/src/git.js +419 -0
- package/src/html-edit.js +942 -0
- package/src/images.js +116 -0
- package/src/people.js +286 -0
- package/src/rich.js +124 -0
- package/src/scaffold.js +185 -0
- package/src/screens.js +65 -0
- package/src/server.js +693 -0
- package/src/site.js +618 -0
- package/src/template.js +915 -0
- package/src/video.js +29 -0
- package/starter/Dockerfile +20 -0
- package/starter/README.md +49 -0
- package/starter/blocks/call-to-action.html +6 -0
- package/starter/blocks/features.html +15 -0
- package/starter/blocks/hero.html +8 -0
- package/starter/blocks/image-and-text.html +8 -0
- package/starter/blocks/latest-posts.html +20 -0
- package/starter/blocks/post-index.html +30 -0
- package/starter/blocks/quote.html +9 -0
- package/starter/blocks/site-footer.html +8 -0
- package/starter/blocks/site-nav.html +8 -0
- package/starter/blocks/tag-list.html +10 -0
- package/starter/blocks/tagged-posts.html +19 -0
- package/starter/blocks/team.html +15 -0
- package/starter/blocks/text.html +4 -0
- package/starter/content/404/page.json +21 -0
- package/starter/content/about/page.json +65 -0
- package/starter/content/journal/designing-for-the-morning-shift/body.html +22 -0
- package/starter/content/journal/designing-for-the-morning-shift/checklist.jpg +0 -0
- package/starter/content/journal/designing-for-the-morning-shift/cover.jpg +0 -0
- package/starter/content/journal/designing-for-the-morning-shift/page.json +17 -0
- package/starter/content/journal/page.json +19 -0
- package/starter/content/journal/the-first-week/body.html +17 -0
- package/starter/content/journal/the-first-week/cover.jpg +0 -0
- package/starter/content/journal/the-first-week/page.json +17 -0
- package/starter/content/journal/the-first-week/wall-of-cards.jpg +0 -0
- package/starter/content/page.json +94 -0
- package/starter/content/site.json +88 -0
- package/starter/content/studio-table.jpg +0 -0
- package/starter/content/topics/page.json +27 -0
- package/starter/dockerignore +5 -0
- package/starter/elevate/config/design.ts +30 -0
- package/starter/elevate/config/elevate.ts +16 -0
- package/starter/elevate/config/syntax.ts +6 -0
- package/starter/elevate/design/site.ts +9 -0
- package/starter/elevate/design/tokens.json +20 -0
- package/starter/elevate/extend/fonts.css +1 -0
- package/starter/gitignore +6 -0
- package/starter/netlify.toml +5 -0
- package/starter/parts/.gitkeep +0 -0
- package/starter/public/favicon.svg +1 -0
- package/starter/templates/page.html +20 -0
- package/starter/templates/page.layout.json +23 -0
- package/starter/templates/post.html +65 -0
- package/starter/verso.defaults.json +33 -0
- package/starter-blank/blocks/site-footer.html +3 -0
- package/starter-blank/blocks/site-nav.html +8 -0
- package/starter-blank/blocks/text.html +4 -0
- package/starter-blank/content/404/page.json +18 -0
- package/starter-blank/content/page.json +18 -0
- package/starter-blank/content/site.json +36 -0
- package/starter-blank/elevate/design/tokens.json +10 -0
- package/starter-blank/templates/page.html +17 -0
- package/starter-blank/verso.defaults.json +26 -0
package/editor/rich.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
function Z(r){this.content=r}Z.prototype={constructor:Z,find:function(r){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===r)return e;return-1},get:function(r){var e=this.find(r);return e==-1?void 0:this.content[e+1]},update:function(r,e,t){var n=t&&t!=r?this.remove(t):this,i=n.find(r),o=n.content.slice();return i==-1?o.push(t||r,e):(o[i+1]=e,t&&(o[i]=t)),new Z(o)},remove:function(r){var e=this.find(r);if(e==-1)return this;var t=this.content.slice();return t.splice(e,2),new Z(t)},addToStart:function(r,e){return new Z([r,e].concat(this.remove(r).content))},addToEnd:function(r,e){var t=this.remove(r).content.slice();return t.push(r,e),new Z(t)},addBefore:function(r,e,t){var n=this.remove(e),i=n.content.slice(),o=n.find(r);return i.splice(o==-1?i.length:o,0,e,t),new Z(i)},forEach:function(r){for(var e=0;e<this.content.length;e+=2)r(this.content[e],this.content[e+1])},prepend:function(r){return r=Z.from(r),r.size?new Z(r.content.concat(this.subtract(r).content)):this},append:function(r){return r=Z.from(r),r.size?new Z(this.subtract(r).content.concat(r.content)):this},subtract:function(r){var e=this;r=Z.from(r);for(var t=0;t<r.content.length;t+=2)e=e.remove(r.content[t]);return e},toObject:function(){var r={};return this.forEach(function(e,t){r[e]=t}),r},get size(){return this.content.length>>1}};Z.from=function(r){if(r instanceof Z)return r;var e=[];if(r)for(var t in r)e.push(t,r[t]);return new Z(e)};var jn=Z;function Ci(r,e,t){for(let n=0;;n++){if(n==r.childCount||n==e.childCount)return r.childCount==e.childCount?null:t;let i=r.child(n),o=e.child(n);if(i==o){t+=i.nodeSize;continue}if(!i.sameMarkup(o))return t;if(i.isText&&i.text!=o.text){let s=i.text,l=o.text,a=0;for(;s[a]==l[a];a++)t++;return a&&a<s.length&&a<l.length&&Oi(s.charCodeAt(a-1))&&Mi(s.charCodeAt(a))&&t--,t}if(i.content.size||o.content.size){let s=Ci(i.content,o.content,t+1);if(s!=null)return s}t+=i.nodeSize}}function wi(r,e,t,n){for(let i=r.childCount,o=e.childCount;;){if(i==0||o==0)return i==o?null:{a:t,b:n};let s=r.child(--i),l=e.child(--o),a=s.nodeSize;if(s==l){t-=a,n-=a;continue}if(!s.sameMarkup(l))return{a:t,b:n};if(s.isText&&s.text!=l.text){let c=s.text,f=l.text,h=c.length,d=f.length;for(;h>0&&d>0&&c[h-1]==f[d-1];)h--,d--,t--,n--;return h&&d&&h<c.length&&Oi(c.charCodeAt(h-1))&&Mi(c.charCodeAt(h))&&(t++,n++),{a:t,b:n}}if(s.content.size||l.content.size){let c=wi(s.content,l.content,t-1,n-1);if(c)return c}t-=a,n-=a}}function Mi(r){return r>=56320&&r<57344}function Oi(r){return r>=55296&&r<56320}var S=class r{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let n=0;n<e.length;n++)this.size+=e[n].nodeSize}nodesBetween(e,t,n,i=0,o){for(let s=0,l=0;l<t;s++){let a=this.content[s],c=l+a.nodeSize;if(c>e&&n(a,i+l,o||null,s)!==!1&&a.content.size){let f=l+1;a.nodesBetween(Math.max(0,e-f),Math.min(a.content.size,t-f),n,i+f)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,n,i){let o="",s=!0;return this.nodesBetween(e,t,(l,a)=>{let c=l.isText?l.text.slice(Math.max(e,a)-a,t-a):l.isLeaf?i?typeof i=="function"?i(l):i:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&n&&(s?s=!1:o+=n),o+=c},0),o}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,n=e.firstChild,i=this.content.slice(),o=0;for(t.isText&&t.sameMarkup(n)&&(i[i.length-1]=t.withText(t.text+n.text),o=1);o<e.content.length;o++)i.push(e.content[o]);return new r(i,this.size+e.size)}cut(e,t=this.size){if(e==0&&t==this.size)return this;let n=[],i=0;if(t>e)for(let o=0,s=0;s<t;o++){let l=this.content[o],a=s+l.nodeSize;a>e&&((s<e||a>t)&&(l.isText?l=l.cut(Math.max(0,e-s),Math.min(l.text.length,t-s)):l=l.cut(Math.max(0,e-s-1),Math.min(l.content.size,t-s-1))),n.push(l),i+=l.nodeSize),s=a}return new r(n,i)}cutByIndex(e,t){return e==t?r.empty:e==0&&t==this.content.length?this:new r(this.content.slice(e,t))}replaceChild(e,t){let n=this.content[e];if(n==t)return this;let i=this.content.slice(),o=this.size+t.nodeSize-n.nodeSize;return i[e]=t,new r(i,o)}addToStart(e){return new r([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new r(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw new RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,n=0;t<this.content.length;t++){let i=this.content[t];e(i,n,t),n+=i.nodeSize}}findDiffStart(e,t=0){return Ci(this,e,t)}findDiffEnd(e,t=this.size,n=e.size){return wi(this,e,t,n)}findIndex(e){if(e==0)return nn(0,e);if(e==this.size)return nn(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,n=0;;t++){let i=this.child(t),o=n+i.nodeSize;if(o>=e)return o==e?nn(t+1,o):nn(t,n);n=o}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,t){if(!t)return r.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return r.fromArray(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return r.empty;let t,n=0;for(let i=0;i<e.length;i++){let o=e[i];n+=o.nodeSize,i&&o.isText&&e[i-1].sameMarkup(o)?(t||(t=e.slice(0,i)),t[t.length-1]=o.withText(t[t.length-1].text+o.text)):t&&t.push(o)}return new r(t||e,n)}static from(e){if(!e)return r.empty;if(e instanceof r)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new r([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}};S.empty=new S([],0);var Un={index:0,offset:0};function nn(r,e){return Un.index=r,Un.offset=e,Un}function sn(r,e){if(r===e)return!0;if(!(r&&typeof r=="object")||!(e&&typeof e=="object"))return!1;let t=Array.isArray(r);if(Array.isArray(e)!=t)return!1;if(t){if(r.length!=e.length)return!1;for(let n=0;n<r.length;n++)if(!sn(r[n],e[n]))return!1}else{for(let n in r)if(!(n in e)||!sn(r[n],e[n]))return!1;for(let n in e)if(!(n in r))return!1}return!0}var z=class r{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,n=!1;for(let i=0;i<e.length;i++){let o=e[i];if(this.eq(o))return e;if(this.type.excludes(o.type))t||(t=e.slice(0,i));else{if(o.type.excludes(this.type))return e;!n&&o.type.rank>this.type.rank&&(t||(t=e.slice(0,i)),t.push(this),n=!0),t&&t.push(o)}}return t||(t=e.slice()),n||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&sn(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Mark.fromJSON");let n=e.marks[t.type];if(!n)throw new RangeError(`There is no mark type ${t.type} in this schema`);return n.create(t.attrs)}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].eq(t[n]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return r.none;if(e instanceof r)return[e];let t=e.slice();return t.sort((n,i)=>n.type.rank-i.type.rank),t}};z.none=[];var Pe=class extends Error{},k=class r{constructor(e,t,n){this.content=e,this.openStart=t,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let n=Di(this.content,e+this.openStart,t,this.openStart+1,this.openEnd+1);return n&&new r(n,this.openStart,this.openEnd)}removeBetween(e,t){return new r(Ni(this.content,e+this.openStart,t+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,t){if(!t)return r.empty;let n=t.openStart||0,i=t.openEnd||0;if(typeof n!="number"||typeof i!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new r(S.fromJSON(e,t.content),n,i)}static maxOpen(e,t=!0){let n=0,i=0;for(let o=e.firstChild;o&&!o.isLeaf&&(t||!o.type.spec.isolating);o=o.firstChild)n++;for(let o=e.lastChild;o&&!o.isLeaf&&(t||!o.type.spec.isolating);o=o.lastChild)i++;return new r(e,n,i)}};k.empty=new k(S.empty,0,0);function Ni(r,e,t){let{index:n,offset:i}=r.findIndex(e),o=r.maybeChild(n),{index:s,offset:l}=r.findIndex(t);if(i==e||o.isText){if(l!=t&&!r.child(s).isText)throw new RangeError("Removing non-flat range");return r.cut(0,e).append(r.cut(t))}if(n!=s)throw new RangeError("Removing non-flat range");return r.replaceChild(n,o.copy(Ni(o.content,e-i-1,t-i-1)))}function Di(r,e,t,n,i,o){let{index:s,offset:l}=r.findIndex(e),a=r.maybeChild(s);if(l==e||a.isText)return o&&n<=0&&i<=0&&!o.canReplace(s,s,t)?null:r.cut(0,e).append(t).append(r.cut(e));let c=Di(a.content,e-l-1,t,s==0?n-1:0,s==r.childCount-1?i-1:0,a);return c&&r.replaceChild(s,a.copy(c))}function fl(r,e,t){if(t.openStart>r.depth)throw new Pe("Inserted content deeper than insertion position");if(r.depth-t.openStart!=e.depth-t.openEnd)throw new Pe("Inconsistent open depths");return Ai(r,e,t,0)}function Ai(r,e,t,n){let i=r.index(n),o=r.node(n);if(i==e.index(n)&&n<r.depth-t.openStart){let s=Ai(r,e,t,n+1);return o.copy(o.content.replaceChild(i,s))}else if(t.content.size)if(!t.openStart&&!t.openEnd&&r.depth==n&&e.depth==n){let s=r.parent,l=s.content;return Ke(s,l.cut(0,r.parentOffset).append(t.content).append(l.cut(e.parentOffset)))}else{let{start:s,end:l}=hl(t,r);return Ke(o,Ei(r,s,l,e,n))}else return Ke(o,ln(r,e,n))}function Ti(r,e){if(!e.type.compatibleContent(r.type))throw new Pe("Cannot join "+e.type.name+" onto "+r.type.name)}function Gn(r,e,t){let n=r.node(t);return Ti(n,e.node(t)),n}function He(r,e){let t=e.length-1;t>=0&&r.isText&&r.sameMarkup(e[t])?e[t]=r.withText(e[t].text+r.text):e.push(r)}function Ot(r,e,t,n){let i=(e||r).node(t),o=0,s=e?e.index(t):i.childCount;r&&(o=r.index(t),r.depth>t?o++:r.textOffset&&(He(r.nodeAfter,n),o++));for(let l=o;l<s;l++)He(i.child(l),n);e&&e.depth==t&&e.textOffset&&He(e.nodeBefore,n)}function Ke(r,e){if(!r.type.validContent(e))throw new Pe("Invalid content for node "+r.type.name);return r.copy(e)}function Ei(r,e,t,n,i){let o=r.depth>i&&Gn(r,e,i+1),s=n.depth>i&&Gn(t,n,i+1),l=[];return Ot(null,r,i,l),o&&s&&e.index(i)==t.index(i)?(Ti(o,s),He(Ke(o,Ei(r,e,t,n,i+1)),l)):(o&&He(Ke(o,ln(r,e,i+1)),l),Ot(e,t,i,l),s&&He(Ke(s,ln(t,n,i+1)),l)),Ot(n,null,i,l),new S(l)}function ln(r,e,t){let n=[];if(Ot(null,r,t,n),r.depth>t){let i=Gn(r,e,t+1);He(Ke(i,ln(r,e,t+1)),n)}return Ot(e,null,t,n),new S(n)}function hl(r,e){let t=e.depth-r.openStart,i=e.node(t).copy(r.content);for(let o=t-1;o>=0;o--)i=e.node(o).copy(S.from(i));return{start:i.resolveNoCache(r.openStart+t),end:i.resolveNoCache(i.content.size-r.openEnd-t)}}var an=class r{constructor(e,t,n){this.pos=e,this.path=t,this.parentOffset=n,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let n=this.pos-this.path[this.path.length-1],i=e.child(t);return n?e.child(t).cut(n):i}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let n=this.path[t*3],i=t==0?0:this.path[t*3-1]+1;for(let o=0;o<e;o++)i+=n.child(o).nodeSize;return i}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return z.none;if(this.textOffset)return e.child(t).marks;let n=e.maybeChild(t-1),i=e.maybeChild(t);if(!n){let l=n;n=i,i=l}let o=n.marks;for(var s=0;s<o.length;s++)o[s].type.spec.inclusive===!1&&(!i||!o[s].isInSet(i.marks))&&(o=o[s--].removeFromSet(o));return o}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let n=t.marks,i=e.parent.maybeChild(e.index());for(var o=0;o<n.length;o++)n[o].type.spec.inclusive===!1&&(!i||!n[o].isInSet(i.marks))&&(n=n[o--].removeFromSet(n));return n}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let n=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);n>=0;n--)if(e.pos<=this.end(n)&&(!t||t(this.node(n))))return new Xn(this,e,n);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset}static resolve(e,t){if(!(t>=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let n=[],i=0,o=t;for(let s=e;;){let{index:l,offset:a}=s.content.findIndex(o),c=o-a;if(n.push(s,l,i+a),!c||(s=s.child(l),s.isText))break;o=c-1,i+=a+1}return new r(t,n,o)}static resolveCached(e,t){let n=hi.get(e);if(n)for(let o=0;o<n.elts.length;o++){let s=n.elts[o];if(s.pos==t)return s}else hi.set(e,n=new Yn);let i=n.elts[n.i]=r.resolve(e,t);return n.i=(n.i+1)%ul,i}},Yn=class{constructor(){this.elts=[],this.i=0}},ul=12,hi=new WeakMap,Xn=class{constructor(e,t,n){this.$from=e,this.$to=t,this.depth=n}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)}},dl=Object.create(null),be=class r{constructor(e,t,n,i=z.none){this.type=e,this.attrs=t,this.marks=i,this.content=n||S.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,n,i=0){this.content.nodesBetween(e,t,n,i,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,t,n,i){return this.content.textBetween(e,t,n,i)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,n){return this.type==e&&sn(this.attrs,t||e.defaultAttrs||dl)&&z.sameSet(this.marks,n||z.none)}copy(e=null){return e==this.content?this:new r(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new r(this.type,this.attrs,this.content,e)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,n=!1){if(e==t)return k.empty;let i=this.resolve(e),o=this.resolve(t),s=n?0:i.sharedDepth(t),l=i.start(s),c=i.node(s).content.cut(i.pos-l,o.pos-l);return new k(c,i.depth-s,o.depth-s)}replace(e,t,n){return fl(this.resolve(e),this.resolve(t),n)}nodeAt(e){for(let t=this;;){let{index:n,offset:i}=t.content.findIndex(e);if(t=t.maybeChild(n),!t)return null;if(i==e||t.isText)return t;e-=i+1}}childAfter(e){let{index:t,offset:n}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:n}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:n}=this.content.findIndex(e);if(n<e)return{node:this.content.child(t),index:t,offset:n};let i=this.content.child(t-1);return{node:i,index:t-1,offset:n-i.nodeSize}}resolve(e){return an.resolveCached(this,e)}resolveNoCache(e){return an.resolve(this,e)}rangeHasMark(e,t,n){let i=!1;return t>e&&this.nodesBetween(e,t,o=>(n.isInSet(o.marks)&&(i=!0),!i)),i}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),Ri(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,n=S.empty,i=0,o=n.childCount){let s=this.contentMatchAt(e).matchFragment(n,i,o),l=s&&s.matchFragment(this.content,t);if(!l||!l.validEnd)return!1;for(let a=i;a<o;a++)if(!this.type.allowsMarks(n.child(a).marks))return!1;return!0}canReplaceWith(e,t,n,i){if(i&&!this.type.allowsMarks(i))return!1;let o=this.contentMatchAt(e).matchType(n),s=o&&o.matchFragment(this.content,t);return s?s.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),di(this.type.attrs,this.attrs,"node",this.type.name);let e=z.none;for(let t=0;t<this.marks.length;t++){let n=this.marks[t];di(n.type.attrs,n.attrs,"mark",n.type.name),e=n.addToSet(e)}if(!z.sameSet(e,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 e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(t=>t.toJSON())),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let n;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");n=t.marks.map(e.markFromJSON)}if(t.type=="text"){if(typeof t.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(t.text,n)}let i=S.fromJSON(e,t.content);return e.nodeType(t.type).create(t.attrs,i,n)}};be.prototype.text=void 0;var ui=(()=>{let{stack:r}=new Error("/");if(!r||!/\n\s*at\s/.test(r))return t=>t;let e=Object.create(null);return t=>(e[t],t)})(),Qn=class r extends be{constructor(e,t,n,i){if(super(e,t,null,i),!n)throw new RangeError("Empty text nodes are not allowed");this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Ri(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return ui(this.text.slice(e,t))}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new r(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new r(this.type,this.attrs,e,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(ui(this.text.slice(e,t)))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}};function Ri(r,e){for(let t=r.length-1;t>=0;t--)e=r[t].type.name+"("+e+")";return e}function di(r,e,t,n){for(let i in e)if(!(i in r))throw new RangeError(`Unsupported attribute ${i} for ${t} of type ${n}`);for(let i in r)r[i].validate&&r[i].validate(e[i])}var _e=class r{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let n=new Zn(e,t);if(n.next==null)return r.empty;let i=Ii(n);n.next&&n.err("Unexpected trailing text");let o=kl(Sl(i));return xl(o,n),o}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,n=e.childCount){let i=this;for(let o=t;i&&o<n;o++)i=i.matchType(e.child(o).type);return i}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let n=0;n<e.next.length;n++)if(this.next[t].type==e.next[n].type)return!0;return!1}fillBefore(e,t=!1,n=0){let i=[this];function o(s,l){let a=s.matchFragment(e,n);if(a&&(!t||a.validEnd))return S.from(l.map(c=>c.createAndFill()));for(let c=0;c<s.next.length;c++){let{type:f,next:h}=s.next[c];if(!(f.isText||f.hasRequiredAttrs())&&i.indexOf(h)==-1){i.push(h);let d=o(h,l.concat(f));if(d)return d}}return null}return o(this,[])}findWrapping(e){for(let n=0;n<this.wrapCache.length;n+=2)if(this.wrapCache[n]==e)return this.wrapCache[n+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),n=[{match:this,type:null,via:null}];for(;n.length;){let i=n.shift(),o=i.match;if(o.matchType(e)){let s=[];for(let l=i;l.type;l=l.via)s.push(l.type);return s.reverse()}for(let s=0;s<o.next.length;s++){let{type:l,next:a}=o.next[s];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in t)&&(!i.type||a.validEnd)&&(n.push({match:l.contentMatch,type:l,via:i}),t[l.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(n){e.push(n);for(let i=0;i<n.next.length;i++)e.indexOf(n.next[i].next)==-1&&t(n.next[i].next)}return t(this),e.map((n,i)=>{let o=i+(n.validEnd?"*":" ")+" ";for(let s=0;s<n.next.length;s++)o+=(s?", ":"")+n.next[s].type.name+"->"+e.indexOf(n.next[s].next);return o}).join(`
|
|
2
|
+
`)}};_e.empty=new _e(!0);var Zn=class{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}};function Ii(r){let e=[];do e.push(pl(r));while(r.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function pl(r){let e=[];do e.push(ml(r));while(r.next&&r.next!=")"&&r.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function ml(r){let e=bl(r);for(;;)if(r.eat("+"))e={type:"plus",expr:e};else if(r.eat("*"))e={type:"star",expr:e};else if(r.eat("?"))e={type:"opt",expr:e};else if(r.eat("{"))e=gl(r,e);else break;return e}function pi(r){/\D/.test(r.next)&&r.err("Expected number, got '"+r.next+"'");let e=Number(r.next);return r.pos++,e}function gl(r,e){let t=pi(r),n=t;return r.eat(",")&&(r.next!="}"?n=pi(r):n=-1),r.eat("}")||r.err("Unclosed braced range"),{type:"range",min:t,max:n,expr:e}}function yl(r,e){let t=r.nodeTypes,n=t[e];if(n)return[n];let i=[];for(let o in t){let s=t[o];s.isInGroup(e)&&i.push(s)}return i.length==0&&r.err("No node type or group '"+e+"' found"),i}function bl(r){if(r.eat("(")){let e=Ii(r);return r.eat(")")||r.err("Missing closing paren"),e}else if(/\W/.test(r.next))r.err("Unexpected token '"+r.next+"'");else{let e=yl(r,r.next).map(t=>(r.inline==null?r.inline=t.isInline:r.inline!=t.isInline&&r.err("Mixing inline and block content"),{type:"name",value:t}));return r.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function Sl(r){let e=[[]];return i(o(r,0),t()),e;function t(){return e.push([])-1}function n(s,l,a){let c={term:a,to:l};return e[s].push(c),c}function i(s,l){s.forEach(a=>a.to=l)}function o(s,l){if(s.type=="choice")return s.exprs.reduce((a,c)=>a.concat(o(c,l)),[]);if(s.type=="seq")for(let a=0;;a++){let c=o(s.exprs[a],l);if(a==s.exprs.length-1)return c;i(c,l=t())}else if(s.type=="star"){let a=t();return n(l,a),i(o(s.expr,a),a),[n(a)]}else if(s.type=="plus"){let a=t();return i(o(s.expr,l),a),i(o(s.expr,a),a),[n(a)]}else{if(s.type=="opt")return[n(l)].concat(o(s.expr,l));if(s.type=="range"){let a=l;for(let c=0;c<s.min;c++){let f=t();i(o(s.expr,a),f),a=f}if(s.max==-1)i(o(s.expr,a),a);else for(let c=s.min;c<s.max;c++){let f=t();n(a,f),i(o(s.expr,a),f),a=f}return[n(a)]}else{if(s.type=="name")return[n(l,void 0,s.value)];throw new Error("Unknown expr type")}}}}function vi(r,e){return e-r}function mi(r,e){let t=[];return n(e),t.sort(vi);function n(i){let o=r[i];if(o.length==1&&!o[0].term)return n(o[0].to);t.push(i);for(let s=0;s<o.length;s++){let{term:l,to:a}=o[s];!l&&t.indexOf(a)==-1&&n(a)}}}function kl(r){let e=Object.create(null);return t(mi(r,0));function t(n){let i=[];n.forEach(s=>{r[s].forEach(({term:l,to:a})=>{if(!l)return;let c;for(let f=0;f<i.length;f++)i[f][0]==l&&(c=i[f][1]);mi(r,a).forEach(f=>{c||i.push([l,c=[]]),c.indexOf(f)==-1&&c.push(f)})})});let o=e[n.join(",")]=new _e(n.indexOf(r.length-1)>-1);for(let s=0;s<i.length;s++){let l=i[s][1].sort(vi);o.next.push({type:i[s][0],next:e[l.join(",")]||t(l)})}return o}}function xl(r,e){for(let t=0,n=[r];t<n.length;t++){let i=n[t],o=!i.validEnd,s=[];for(let l=0;l<i.next.length;l++){let{type:a,next:c}=i.next[l];s.push(a.name),o&&!(a.isText||a.hasRequiredAttrs())&&(o=!1),n.indexOf(c)==-1&&n.push(c)}o&&e.err("Only non-generatable nodes ("+s.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function zi(r){let e=Object.create(null);for(let t in r){let n=r[t];if(!n.hasDefault)return null;e[t]=n.default}return e}function Pi(r,e){let t=Object.create(null);for(let n in r){let i=r[n],o=e&&e[n];if(o===void 0)if(i.hasDefault)o=i.default;else throw new RangeError("No value supplied for attribute "+n);else i.validate&&i.validate(o);t[n]=o}return t}function Bi(r,e){let t=Object.create(null);if(e)for(let n in e)t[n]=new er(r,n,e[n]);return t}var je=class r{constructor(e,t,n){this.name=e,this.schema=t,this.spec=n,this.markSet=null,this.groups=n.group?n.group.split(" "):[],this.attrs=Bi(e,n.attrs),this.defaultAttrs=zi(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(n.inline||e=="text"),this.isText=e=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==_e.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:Pi(this.attrs,e)}create(e=null,t,n){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new be(this,this.computeAttrs(e),S.from(t),z.setFrom(n))}createChecked(e=null,t,n){return t=S.from(t),this.checkContent(t),new be(this,this.computeAttrs(e),t,z.setFrom(n))}createAndFill(e=null,t,n){if(e=this.computeAttrs(e),t=S.from(t),t.size){let s=this.contentMatch.fillBefore(t);if(!s)return null;t=s.append(t)}let i=this.contentMatch.matchFragment(t),o=i&&i.fillBefore(S.empty,!0);return o?new be(this,e,t.append(o),z.setFrom(n)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let n=0;n<e.childCount;n++)if(!this.allowsMarks(e.child(n).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let t;for(let n=0;n<e.length;n++)this.allowsMarkType(e[n].type)?t&&t.push(e[n]):t||(t=e.slice(0,n));return t?t.length?t:z.none:e}static compile(e,t){let n=Object.create(null);e.forEach((o,s)=>n[o]=new r(o,t,s));let i=t.spec.topNode||"doc";if(!n[i])throw new RangeError("Schema is missing its top node type ('"+i+"')");if(!n.text)throw new RangeError("Every schema needs a 'text' type");for(let o in n.text.attrs)throw new RangeError("The text node type should not have attributes");return n}};function Cl(r,e,t){let n=t.split("|");return i=>{let o=i===null?"null":typeof i;if(n.indexOf(o)<0)throw new RangeError(`Expected value of type ${n} for attribute ${e} on type ${r}, got ${o}`)}}var er=class{constructor(e,t,n){this.hasDefault=Object.prototype.hasOwnProperty.call(n,"default"),this.default=n.default,this.validate=typeof n.validate=="string"?Cl(e,t,n.validate):n.validate}get isRequired(){return!this.hasDefault}},Dt=class r{constructor(e,t,n,i){this.name=e,this.rank=t,this.schema=n,this.spec=i,this.attrs=Bi(e,i.attrs),this.excluded=null;let o=zi(this.attrs);this.instance=o?new z(this,o):null}create(e=null){return!e&&this.instance?this.instance:new z(this,Pi(this.attrs,e))}static compile(e,t){let n=Object.create(null),i=0;return e.forEach((o,s)=>n[o]=new r(o,i++,t,s)),n}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}excludes(e){return this.excluded.indexOf(e)>-1}},cn=class{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let i in e)t[i]=e[i];t.nodes=jn.from(e.nodes),t.marks=jn.from(e.marks||{}),this.nodes=je.compile(this.spec.nodes,this),this.marks=Dt.compile(this.spec.marks,this);let n=Object.create(null);for(let i in this.nodes){if(i in this.marks)throw new RangeError(i+" can not be both a node and a mark");let o=this.nodes[i],s=o.spec.content||"",l=o.spec.marks;if(o.contentMatch=n[s]||(n[s]=_e.parse(s,this.nodes)),o.inlineContent=o.contentMatch.inlineContent,o.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!o.isInline||!o.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=o}o.markSet=l=="_"?null:l?gi(this,l.split(" ")):l==""||!o.inlineContent?[]:null}for(let i in this.marks){let o=this.marks[i],s=o.spec.excludes;o.excluded=s==null?[o]:s==""?[]:gi(this,s.split(" "))}this.nodeFromJSON=i=>be.fromJSON(this,i),this.markFromJSON=i=>z.fromJSON(this,i),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,n,i){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof je){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(t,n,i)}text(e,t){let n=this.nodes.text;return new Qn(n,n.defaultAttrs,e,z.setFrom(t))}mark(e,t){return typeof e=="string"&&(e=this.marks[e]),e.create(t)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}};function gi(r,e){let t=[];for(let n=0;n<e.length;n++){let i=e[n],o=r.marks[i],s=o;if(o)t.push(o);else for(let l in r.marks){let a=r.marks[l];(i=="_"||a.spec.group&&a.spec.group.split(" ").indexOf(i)>-1)&&t.push(s=a)}if(!s)throw new SyntaxError("Unknown mark type: '"+e[n]+"'")}return t}function wl(r){return r.tag!=null}function Ml(r){return r.style!=null}var Ue=class r{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let n=this.matchedStyles=[];t.forEach(i=>{if(wl(i))this.tags.push(i);else if(Ml(i)){let o=/[^=]*/.exec(i.style)[0];n.indexOf(o)<0&&n.push(o),this.styles.push(i)}}),this.normalizeLists=!this.tags.some(i=>{if(!/^(ul|ol)\b/.test(i.tag)||!i.node)return!1;let o=e.nodes[i.node];return o.contentMatch.matchType(o)})}parse(e,t={}){let n=new fn(this,t,!1);return n.addAll(e,z.none,t.from,t.to),n.finish()}parseSlice(e,t={}){let n=new fn(this,t,!0);return n.addAll(e,z.none,t.from,t.to),k.maxOpen(n.finish())}matchTag(e,t,n){for(let i=n?this.tags.indexOf(n)+1:0;i<this.tags.length;i++){let o=this.tags[i];if(Dl(e,o.tag)&&(o.namespace===void 0||e.namespaceURI==o.namespace)&&(!o.context||t.matchesContext(o.context))){if(o.getAttrs){let s=o.getAttrs(e);if(s===!1)continue;o.attrs=s||void 0}return o}}}matchStyle(e,t,n,i){for(let o=i?this.styles.indexOf(i)+1:0;o<this.styles.length;o++){let s=this.styles[o],l=s.style;if(!(l.indexOf(e)!=0||s.context&&!n.matchesContext(s.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=t))){if(s.getAttrs){let a=s.getAttrs(t);if(a===!1)continue;s.attrs=a||void 0}return s}}}static schemaRules(e){let t=[];function n(i){let o=i.priority==null?50:i.priority,s=0;for(;s<t.length;s++){let l=t[s];if((l.priority==null?50:l.priority)<o)break}t.splice(s,0,i)}for(let i in e.marks){let o=e.marks[i].spec.parseDOM;o&&o.forEach(s=>{n(s=bi(s)),s.mark||s.ignore||s.clearMark||(s.mark=i)})}for(let i in e.nodes){let o=e.nodes[i].spec.parseDOM;o&&o.forEach(s=>{n(s=bi(s)),s.node||s.ignore||s.mark||(s.node=i)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new r(e,r.schemaRules(e)))}},Fi={address:!0,article:!0,aside:!0,blockquote:!0,body:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},Ol={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Vi={ol:!0,ul:!0},At=1,tr=2,Nt=4;function yi(r,e,t){return e!=null?(e?At:0)|(e==="full"?tr:0):r&&r.whitespace=="pre"?At|tr:t&~Nt}var ct=class{constructor(e,t,n,i,o,s){this.type=e,this.attrs=t,this.marks=n,this.solid=i,this.options=s,this.content=[],this.activeMarks=z.none,this.match=o||(s&Nt?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(S.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let n=this.type.contentMatch,i;return(i=n.findWrapping(e.type))?(this.match=n,i):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&At)){let n=this.content[this.content.length-1],i;if(n&&n.isText&&(i=/[ \t\r\n\u000c]+$/.exec(n.text))){let o=n;n.text.length==i[0].length?this.content.pop():this.content[this.content.length-1]=o.withText(o.text.slice(0,o.text.length-i[0].length))}}let t=S.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(S.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!Fi.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}},fn=class{constructor(e,t,n){this.parser=e,this.options=t,this.isOpen=n,this.open=0,this.localPreserveWS=!1;let i=t.topNode,o,s=yi(null,t.preserveWhitespace,0)|(n?Nt:0);i?o=new ct(i.type,i.attrs,z.none,!0,t.topMatch||i.type.contentMatch,s):n?o=new ct(null,null,z.none,!0,null,s):o=new ct(e.schema.topNodeType,null,z.none,!0,null,s),this.nodes=[o],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){e.nodeType==3?this.addTextNode(e,t):e.nodeType==1&&this.addElement(e,t)}addTextNode(e,t){let n=e.nodeValue,i=this.top,o=i.options&tr?"full":this.localPreserveWS||(i.options&At)>0,{schema:s}=this.parser;if(o==="full"||i.inlineContext(e)||/[^ \t\r\n\u000c]/.test(n)){if(o)if(o==="full")n=n.replace(/\r\n?/g,`
|
|
3
|
+
`);else if(s.linebreakReplacement&&/[\r\n]/.test(n)&&this.top.findWrapping(s.linebreakReplacement.create())){let l=n.split(/\r?\n|\r/);for(let a=0;a<l.length;a++)a&&this.insertNode(s.linebreakReplacement.create(),t,!0),l[a]&&this.insertNode(s.text(l[a]),t,!/\S/.test(l[a]));n=""}else n=n.replace(/\r?\n|\r/g," ");else if(n=n.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(n)&&this.open==this.nodes.length-1){let l=i.content[i.content.length-1],a=e.previousSibling;(!l||a&&a.nodeName=="BR"||l.isText&&/[ \t\r\n\u000c]$/.test(l.text))&&(n=n.slice(1))}n&&this.insertNode(s.text(n),t,!/\S/.test(n)),this.findInText(e)}else this.findInside(e)}addElement(e,t,n){let i=this.localPreserveWS,o=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let s=e.nodeName.toLowerCase(),l;Vi.hasOwnProperty(s)&&this.parser.normalizeLists&&Nl(e);let a=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,n));e:if(a?a.ignore:Ol.hasOwnProperty(s))this.findInside(e),this.ignoreFallback(e,t);else if(!a||a.skip||a.closeParent){a&&a.closeParent?this.open=Math.max(0,this.open-1):a&&a.skip.nodeType&&(e=a.skip);let c,f=this.needsBlock;if(Fi.hasOwnProperty(s))o.content.length&&o.content[0].isInline&&this.open&&(this.open--,o=this.top),c=!0,o.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break e}let h=a&&a.skip?t:this.readStyles(e,t);h&&this.addAll(e,h),c&&this.sync(o),this.needsBlock=f}else{let c=this.readStyles(e,t);c&&this.addElementByRule(e,a,c,a.consuming===!1?l:void 0)}this.localPreserveWS=i}leafFallback(e,t){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
|
|
4
|
+
`),t)}ignoreFallback(e,t){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),t,!0)}readStyles(e,t){let n=e.style;if(n&&n.length)for(let i=0;i<this.parser.matchedStyles.length;i++){let o=this.parser.matchedStyles[i],s=n.getPropertyValue(o);if(s)for(let l=void 0;;){let a=this.parser.matchStyle(o,s,this,l);if(!a)break;if(a.ignore)return null;if(a.clearMark?t=t.filter(c=>!a.clearMark(c)):t=t.concat(this.parser.schema.marks[a.mark].create(a.attrs)),a.consuming===!1)l=a;else break}}return t}addElementByRule(e,t,n,i){let o,s;if(t.node)if(s=this.parser.schema.nodes[t.node],s.isLeaf)this.insertNode(s.create(t.attrs),n,e.nodeName=="BR")||this.leafFallback(e,n);else{let a=this.enter(s,t.attrs||null,n,t.preserveWhitespace);a&&(o=!0,n=a)}else{let a=this.parser.schema.marks[t.mark];n=n.concat(a.create(t.attrs))}let l=this.top;if(s&&s.isLeaf)this.findInside(e);else if(i)this.addElement(e,n,i);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a,n,!1));else{let a=e;typeof t.contentElement=="string"?a=e.querySelector(t.contentElement):typeof t.contentElement=="function"?a=t.contentElement(e):t.contentElement&&(a=t.contentElement),this.findAround(e,a,!0),this.addAll(a,n),this.findAround(e,a,!1)}o&&this.sync(l)&&this.open--}addAll(e,t,n,i){let o=n||0;for(let s=n?e.childNodes[n]:e.firstChild,l=i==null?null:e.childNodes[i];s!=l;s=s.nextSibling,++o)this.findAtPoint(e,o),this.addDOM(s,t);this.findAtPoint(e,o)}findPlace(e,t,n){let i,o;for(let s=this.open,l=0;s>=0;s--){let a=this.nodes[s],c=a.findWrapping(e);if(c&&(!i||i.length>c.length+l)&&(i=c,o=a,!c.length))break;if(a.solid){if(n)break;l+=2}}if(!i)return null;this.sync(o);for(let s=0;s<i.length;s++)t=this.enterInner(i[s],null,t,!1);return t}insertNode(e,t,n){if(e.isInline&&this.needsBlock&&!this.top.type){let o=this.textblockFromContext();o&&(t=this.enterInner(o,null,t))}let i=this.findPlace(e,t,n);if(i){this.closeExtra();let o=this.top;o.match&&(o.match=o.match.matchType(e.type));let s=z.none;for(let l of i.concat(e.marks))(o.type?o.type.allowsMarkType(l.type):Si(l.type,e.type))&&(s=l.addToSet(s));return o.content.push(e.mark(s)),!0}return!1}enter(e,t,n,i){let o=this.findPlace(e.create(t),n,!1);return o&&(o=this.enterInner(e,t,n,!0,i)),o}enterInner(e,t,n,i=!1,o){this.closeExtra();let s=this.top;s.match=s.match&&s.match.matchType(e);let l=yi(e,o,s.options);s.options&Nt&&s.content.length==0&&(l|=Nt);let a=z.none;return n=n.filter(c=>(s.type?s.type.allowsMarkType(c.type):Si(c.type,e))?(a=c.addToSet(a),!1):!0),this.nodes.push(new ct(e,t,a,i,null,l)),this.open++,n}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let t=this.open;t>=0;t--){if(this.nodes[t]==e)return this.open=t,!0;this.localPreserveWS&&(this.nodes[t].options|=At)}return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let n=this.nodes[t].content;for(let i=n.length-1;i>=0;i--)e+=n[i].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&this.find[n].offset==t&&(this.find[n].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].pos==null&&e.nodeType==1&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,n){if(e!=t&&this.find)for(let i=0;i<this.find.length;i++)this.find[i].pos==null&&e.nodeType==1&&e.contains(this.find[i].node)&&t.compareDocumentPosition(this.find[i].node)&(n?2:4)&&(this.find[i].pos=this.currentPos)}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),n=this.options.context,i=!this.isOpen&&(!n||n.parent.type==this.nodes[0].type),o=-(n?n.depth+1:0)+(i?0:1),s=(l,a)=>{for(;l>=0;l--){let c=t[l];if(c==""){if(l==t.length-1||l==0)continue;for(;a>=o;a--)if(s(l-1,a))return!0;return!1}else{let f=a>0||a==0&&i?this.nodes[a].type:n&&a>=o?n.node(a-o).type:null;if(!f||f.name!=c&&!f.isInGroup(c))return!1;a--}}return!0};return s(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let n=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(let t in this.parser.schema.nodes){let n=this.parser.schema.nodes[t];if(n.isTextblock&&n.defaultAttrs)return n}}};function Nl(r){for(let e=r.firstChild,t=null;e;e=e.nextSibling){let n=e.nodeType==1?e.nodeName.toLowerCase():null;n&&Vi.hasOwnProperty(n)&&t?(t.appendChild(e),e=t):n=="li"?t=e:n&&(t=null)}}function Dl(r,e){return(r.matches||r.msMatchesSelector||r.webkitMatchesSelector||r.mozMatchesSelector).call(r,e)}function bi(r){let e={};for(let t in r)e[t]=r[t];return e}function Si(r,e){let t=e.schema.nodes;for(let n in t){let i=t[n];if(!i.allowsMarkType(r))continue;let o=[],s=l=>{o.push(l);for(let a=0;a<l.edgeCount;a++){let{type:c,next:f}=l.edge(a);if(c==e||o.indexOf(f)<0&&s(f))return!0}};if(s(i.contentMatch))return!0}}var Me=class r{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},n){n||(n=rn(t).createDocumentFragment());let i=n,o=[];return e.forEach(s=>{if(o.length||s.marks.length){let l=0,a=0;for(;l<o.length&&a<s.marks.length;){let c=s.marks[a];if(!this.marks[c.type.name]){a++;continue}if(!c.eq(o[l][0])||c.type.spec.spanning===!1)break;l++,a++}for(;l<o.length;)i=o.pop()[1];for(;a<s.marks.length;){let c=s.marks[a++],f=this.serializeMark(c,s.isInline,t);f&&(o.push([c,i]),i.appendChild(f.dom),i=f.contentDOM||f.dom)}}i.appendChild(this.serializeNodeInner(s,t))}),n}serializeNodeInner(e,t){if(e.isText)return rn(t).createTextNode(e.text);let{dom:n,contentDOM:i}=on(rn(t),this.nodes[e.type.name](e),null,e.attrs);if(i){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,i)}return n}serializeNode(e,t={}){let n=this.serializeNodeInner(e,t);for(let i=e.marks.length-1;i>=0;i--){let o=this.serializeMark(e.marks[i],e.isInline,t);o&&((o.contentDOM||o.dom).appendChild(n),n=o.dom)}return n}serializeMark(e,t,n={}){let i=this.marks[e.type.name];return i&&on(rn(n),i(e,t),null,e.attrs)}static renderSpec(e,t,n=null,i){return typeof t=="string"?{dom:e.createTextNode(t)}:on(e,t,n,i)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new r(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=ki(e.nodes);return t.text||(t.text=n=>n.text),t}static marksFromSchema(e){return ki(e.marks)}};function ki(r){let e={};for(let t in r){let n=r[t].spec.toDOM;n&&(e[t]=n)}return e}function rn(r){return r.document||window.document}var xi=new WeakMap;function Al(r){let e=xi.get(r);return e===void 0&&xi.set(r,e=Tl(r)),e}function Tl(r){let e=null;function t(n){if(n&&typeof n=="object")if(Array.isArray(n))if(typeof n[0]=="string")e||(e=[]),e.push(n);else for(let i=0;i<n.length;i++)t(n[i]);else for(let i in n)t(n[i])}return t(r),e}function on(r,e,t,n){if(e.nodeType==1)return{dom:e};if(e.dom&&e.dom.nodeType==1)return e;let i=e[0],o;if(typeof i!="string")throw new RangeError("Invalid array passed to renderSpec");if(n&&(o=Al(n))&&o.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let s=i.indexOf(" ");s>0&&(t=i.slice(0,s),i=i.slice(s+1));let l,a=t?r.createElementNS(t,i):r.createElement(i),c=e[1],f=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){f=2;for(let h in c)if(c[h]!=null){let d=h.indexOf(" ");d>0?a.setAttributeNS(h.slice(0,d),h.slice(d+1),c[h]):h=="style"&&a.style?a.style.cssText=c[h]:a.setAttribute(h,c[h])}}for(let h=f;h<e.length;h++){let d=e[h];if(d===0){if(h<e.length-1||h>f)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}else if(typeof d=="string")a.appendChild(r.createTextNode(d));else{let{dom:p,contentDOM:u}=on(r,d,t,n);if(a.appendChild(p),u){if(l)throw new RangeError("Multiple content holes");l=u}}}return{dom:a,contentDOM:l}}var qi=65535,Hi=Math.pow(2,16);function El(r,e){return r+e*Hi}function Li(r){return r&qi}function Rl(r){return(r-(r&qi))/Hi}var Ki=1,_i=2,hn=4,ji=8,Rt=class{constructor(e,t,n){this.pos=e,this.delInfo=t,this.recover=n}get deleted(){return(this.delInfo&ji)>0}get deletedBefore(){return(this.delInfo&(Ki|hn))>0}get deletedAfter(){return(this.delInfo&(_i|hn))>0}get deletedAcross(){return(this.delInfo&hn)>0}},Oe=class r{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&r.empty)return r.empty}recover(e){let t=0,n=Li(e);if(!this.inverted)for(let i=0;i<n;i++)t+=this.ranges[i*3+2]-this.ranges[i*3+1];return this.ranges[n*3]+t+Rl(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,n){let i=0,o=this.inverted?2:1,s=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?i:0);if(a>e)break;let c=this.ranges[l+o],f=this.ranges[l+s],h=a+c;if(e<=h){let d=c?e==a?-1:e==h?1:t:t,p=a+i+(d<0?0:f);if(n)return p;let u=e==(t<0?a:h)?null:El(l/3,e-a),m=0;return c&&(m|=e==a?_i:e==h?Ki:hn,(t<0?e!=a:e!=h)&&(m|=ji)),new Rt(p,m,u)}i+=f-c}return n?e+i:new Rt(e+i,0,null)}touches(e,t){let n=0,i=Li(t),o=this.inverted?2:1,s=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?n:0);if(a>e)break;let c=this.ranges[l+o],f=a+c;if(e<=f&&l==i*3)return!0;n+=this.ranges[l+s]-c}return!1}forEach(e){let t=this.inverted?2:1,n=this.inverted?1:2;for(let i=0,o=0;i<this.ranges.length;i+=3){let s=this.ranges[i],l=s-(this.inverted?o:0),a=s+(this.inverted?0:o),c=this.ranges[i+t],f=this.ranges[i+n];e(l,l+c,a,a+f),o+=f-c}}invert(){return new r(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?r.empty:new r(e<0?[0,-e,0]:[0,0,e])}};Oe.empty=new Oe([]);var It=class r{constructor(e,t,n=0,i=e?e.length:0){this.mirror=t,this.from=n,this.to=i,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(e=0,t=this.maps.length){return new r(this._maps,this.mirror,e,t)}appendMap(e,t){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),t!=null&&this.setMirror(this._maps.length-1,t)}appendMapping(e){for(let t=0,n=this._maps.length;t<e._maps.length;t++){let i=e.getMirror(t);this.appendMap(e._maps[t],i!=null&&i<t?n+i:void 0)}}getMirror(e){if(this.mirror){for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}}setMirror(e,t){this.mirror||(this.mirror=[]),this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,n=this._maps.length+e._maps.length;t>=0;t--){let i=e.getMirror(t);this.appendMap(e._maps[t].invert(),i!=null&&i>t?n-i-1:void 0)}}invert(){let e=new r;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let n=this.from;n<this.to;n++)e=this._maps[n].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,n){let i=0;for(let o=this.from;o<this.to;o++){let s=this._maps[o],l=s.mapResult(e,t);if(l.recover!=null){let a=this.getMirror(o);if(a!=null&&a>o&&a<this.to){o=a,e=this._maps[a].recover(l.recover);continue}}i|=l.delInfo,e=l.pos}return n?e:new Rt(e,i,null)}},nr=Object.create(null),L=class{getMap(){return Oe.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let n=nr[t.stepType];if(!n)throw new RangeError(`No step type ${t.stepType} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in nr)throw new RangeError("Duplicate use of step JSON ID "+e);return nr[e]=t,t.prototype.jsonID=e,t}},q=class r{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new r(e,null)}static fail(e){return new r(null,e)}static fromReplace(e,t,n,i){try{return r.ok(e.replace(t,n,i))}catch(o){if(o instanceof Pe)return r.fail(o.message);throw o}}};function sr(r,e,t){let n=[];for(let i=0;i<r.childCount;i++){let o=r.child(i);o.content.size&&(o=o.copy(sr(o.content,e,o))),o.isInline&&(o=e(o,t,i)),n.push(o)}return S.fromArray(n)}var vt=class r extends L{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=e.resolve(this.from),i=n.node(n.sharedDepth(this.to)),o=new k(sr(t.content,(s,l)=>!s.isAtom||!l.type.allowsMarkType(this.mark.type)?s:s.mark(this.mark.addToSet(s.marks)),i),t.openStart,t.openEnd);return q.fromReplace(e,this.from,this.to,o)}invert(e){let t=[];return e.nodesBetween(this.from,this.to,(n,i)=>{if(n.isInline&&n.isAtom){let o=this.mark.addToSet(n.marks);if(!z.sameSet(o,n.marks)){let s=Math.max(this.from,i),l=Math.min(this.to,i+n.nodeSize);un(ft,s,l,this.mark,t);for(let a of n.marks)a.isInSet(o)||un(r,s,l,a,t)}}}),t.length==1?t[0]:new zt(t)}map(e){let t=e.map(this.from,1),n=e.map(this.to,-1);return t>=n?null:new r(t,n,this.mark)}merge(e){return e instanceof r&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new r(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new r(t.from,t.to,e.markFromJSON(t.mark))}};L.jsonID("addMark",vt);var ft=class r extends L{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=new k(sr(t.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),t.openStart,t.openEnd);return q.fromReplace(e,this.from,this.to,n)}invert(e){let t=[];return e.nodesBetween(this.from,this.to,(n,i)=>{n.isInline&&n.isAtom&&this.mark.isInSet(n.marks)&&un(vt,Math.max(this.from,i),Math.min(this.to,i+n.nodeSize),this.mark,t)}),t.length==1?t[0]:new zt(t)}map(e){let t=e.map(this.from,1),n=e.map(this.to,-1);return t>=n?null:new r(t,n,this.mark)}merge(e){return e instanceof r&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new r(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new r(t.from,t.to,e.markFromJSON(t.mark))}};L.jsonID("removeMark",ft);function un(r,e,t,n,i){let o=i.length?i[i.length-1]:null;o&&o instanceof r&&o.to==e&&o.mark.eq(n)?i[i.length-1]=new r(o.from,t,n):i.push(new r(e,t,n))}var zt=class r extends L{constructor(e){super(),this.steps=e}apply(e){for(let t of this.steps){let n=t.apply(e);if(!n.doc)return n;e=n.doc}return new q(e,null)}invert(e){return new r(this.steps.map(t=>t.invert(e)))}map(e){let t=[];for(let n of this.steps){let i=n.map(e);i&&t.push(i)}return t.length?new r(t):null}toJSON(){return{stepType:"markSet",steps:this.steps.map(e=>e.toJSON())}}static fromJSON(e,t){if(!Array.isArray(t.steps)||!t.steps.every(n=>n.stepType=="addMark"||n.stepType=="removeMark"))throw new RangeError("Invalid JSON for MarkSetStep");return new r(t.steps.map(n=>L.fromJSON(e,n)))}};L.jsonID("markSet",zt);var Pt=class r extends L{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return q.fail("No node at mark step's position");let n=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return q.fromReplace(e,this.pos,this.pos+1,new k(S.from(n),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let n=this.mark.addToSet(t.marks);if(n.length==t.marks.length){for(let i=0;i<t.marks.length;i++)if(!t.marks[i].isInSet(n))return new r(this.pos,t.marks[i]);return new r(this.pos,this.mark)}}return new ht(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new r(t.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new r(t.pos,e.markFromJSON(t.mark))}};L.jsonID("addNodeMark",Pt);var ht=class r extends L{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return q.fail("No node at mark step's position");let n=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return q.fromReplace(e,this.pos,this.pos+1,new k(S.from(n),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new Pt(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new r(t.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new r(t.pos,e.markFromJSON(t.mark))}};L.jsonID("removeNodeMark",ht);var se=class r extends L{constructor(e,t,n,i=!1){super(),this.from=e,this.to=t,this.slice=n,this.structure=i}apply(e){return this.structure&&ir(e,this.from,this.to)?q.fail("Structure replace would overwrite content"):q.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Oe([this.from,this.to-this.from,this.slice.size])}invert(e){return new r(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.to,-1),n=this.from==this.to&&r.MAP_BIAS<0?t:e.mapResult(this.from,1);return n.deletedAcross&&t.deletedAcross?null:new r(n.pos,Math.max(n.pos,t.pos),this.slice,this.structure)}merge(e){if(!(e instanceof r)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let t=this.slice.size+e.slice.size==0?k.empty:new k(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new r(this.from,this.to+(e.to-e.from),t,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let t=this.slice.size+e.slice.size==0?k.empty:new k(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new r(e.from,this.to,t,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new r(t.from,t.to,k.fromJSON(e,t.slice),!!t.structure)}};se.MAP_BIAS=1;L.jsonID("replace",se);var fe=class r extends L{constructor(e,t,n,i,o,s,l=!1){super(),this.from=e,this.to=t,this.gapFrom=n,this.gapTo=i,this.slice=o,this.insert=s,this.structure=l}apply(e){if(this.structure&&(ir(e,this.from,this.gapFrom)||ir(e,this.gapTo,this.to)))return q.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return q.fail("Gap is not a flat range");let n=this.slice.insertAt(this.insert,t.content);return n?q.fromReplace(e,this.from,this.to,n):q.fail("Content does not fit in gap")}getMap(){return new Oe([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let t=this.gapTo-this.gapFrom;return new r(this.from,this.from+this.slice.size+t,this.from+this.insert,this.from+this.insert+t,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1),i=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),o=this.to==this.gapTo?n.pos:e.map(this.gapTo,1);return t.deletedAcross&&n.deletedAcross||i<t.pos||o>n.pos||i>o?null:new r(t.pos,n.pos,i,o,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number"||typeof t.gapFrom!="number"||typeof t.gapTo!="number"||typeof t.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new r(t.from,t.to,t.gapFrom,t.gapTo,k.fromJSON(e,t.slice),t.insert,!!t.structure)}};L.jsonID("replaceAround",fe);function ir(r,e,t){let n=r.resolve(e),i=t-e,o=n.depth;for(;i>0&&o>0&&n.indexAfter(o)==n.node(o).childCount;)o--,i--;if(i>0){let s=n.node(o).maybeChild(n.indexAfter(o));for(;i>0;){if(!s||s.isLeaf)return!0;s=s.firstChild,i--}}return!1}function Il(r,e,t,n){let i=[];r.doc.nodesBetween(e,t,(o,s,l)=>{if(!o.isInline)return;let a=o.marks;if(!n.isInSet(a)&&l.type.allowsMarkType(n.type)){let c=Math.max(s,e),f=Math.min(s+o.nodeSize,t);un(vt,c,f,n,i)}}),i.forEach(o=>r.step(o))}function vl(r,e,t,n){let i=[],o=0;r.doc.nodesBetween(e,t,(s,l)=>{if(!s.isInline||!s.isAtom)return;o++;let a=null;if(n instanceof Dt){let c=s.marks,f;for(;f=n.isInSet(c);)(a||(a=[])).push(f),c=f.removeFromSet(c)}else n?n.isInSet(s.marks)&&(a=[n]):a=s.marks;if(a&&a.length){let c=Math.min(l+s.nodeSize,t);for(let f=0;f<a.length;f++){let h=a[f],d;for(let p=0;p<i.length;p++){let u=i[p];u.step==o-1&&h.eq(i[p].style)&&(d=u)}d?(d.to=c,d.step=o):i.push({style:h,from:Math.max(l,e),to:c,step:o})}}}),i.forEach(s=>r.step(new ft(s.from,s.to,s.style)))}function lr(r,e,t,n=t.contentMatch,i=!0){let o=r.doc.nodeAt(e),s=[],l=e+1;for(let a=0;a<o.childCount;a++){let c=o.child(a),f=l+c.nodeSize,h=n.matchType(c.type);if(!h)s.push(new se(l,f,k.empty));else{n=h;for(let d=0;d<c.marks.length;d++)t.allowsMarkType(c.marks[d].type)||r.step(new ft(l,f,c.marks[d]));if(i&&c.isText&&t.whitespace!="pre"){let d,p=/\r?\n|\r/g,u;for(;d=p.exec(c.text);)u||(u=new k(S.from(t.schema.text(" ",t.allowedMarks(c.marks))),0,0)),s.push(new se(l+d.index,l+d.index+d[0].length,u))}}l=f}if(!n.validEnd){let a=n.fillBefore(S.empty,!0);r.replace(l,l,new k(a,0,0))}for(let a=s.length-1;a>=0;a--)r.step(s[a])}function zl(r,e,t){return(e==0||r.canReplace(e,r.childCount))&&(t==r.childCount||r.canReplace(0,t))}function Bt(r){let t=r.parent.content.cutByIndex(r.startIndex,r.endIndex);for(let n=r.depth,i=0,o=0;;--n){let s=r.$from.node(n),l=r.$from.index(n)+i,a=r.$to.indexAfter(n)-o;if(n<r.depth&&s.canReplace(l,a,t))return n;if(n==0||s.type.spec.isolating||!zl(s,l,a))break;l&&(i=1),a<s.childCount&&(o=1)}return null}function Pl(r,e,t){let{$from:n,$to:i,depth:o}=e,s=n.before(o+1),l=i.after(o+1),a=s,c=l,f=S.empty,h=0;for(let u=o,m=!1;u>t;u--)m||n.index(u)>0?(m=!0,f=S.from(n.node(u).copy(f)),h++):a--;let d=S.empty,p=0;for(let u=o,m=!1;u>t;u--)m||i.after(u+1)<i.end(u)?(m=!0,d=S.from(i.node(u).copy(d)),p++):c++;r.step(new fe(a,c,s,l,new k(f.append(d),h,p),f.size-h,!0))}function mn(r,e,t=null,n=r){let i=Bl(r,e),o=i&&Fl(n,e);return o?i.map($i).concat({type:e,attrs:t}).concat(o.map($i)):null}function $i(r){return{type:r,attrs:null}}function Bl(r,e){let{parent:t,startIndex:n,endIndex:i}=r,o=t.contentMatchAt(n).findWrapping(e);if(!o)return null;let s=o.length?o[0]:e;return t.canReplaceWith(n,i,s)?o:null}function Fl(r,e){let{parent:t,startIndex:n,endIndex:i}=r,o=t.child(n),s=e.contentMatch.findWrapping(o.type);if(!s)return null;let a=(s.length?s[s.length-1]:e).contentMatch;for(let c=n;a&&c<i;c++)a=a.matchType(t.child(c).type);return!a||!a.validEnd?null:s}function Vl(r,e,t){let n=S.empty;for(let s=t.length-1;s>=0;s--){if(n.size){let l=t[s].type.contentMatch.matchFragment(n);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}n=S.from(t[s].type.create(t[s].attrs,n))}let i=e.start,o=e.end;r.step(new fe(i,o,i,o,new k(n,0,0),t.length,!0))}function Ll(r,e,t,n,i){if(!n.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let o=r.steps.length;r.doc.nodesBetween(e,t,(s,l)=>{let a=typeof i=="function"?i(s):i;if(s.isTextblock&&!s.hasMarkup(n,a)&&$l(r.doc,r.mapping.slice(o).map(l),n)){let c=null;if(n.schema.linebreakReplacement){let p=n.whitespace=="pre",u=!!n.contentMatch.matchType(n.schema.linebreakReplacement);p&&!u?c=!1:!p&&u&&(c=!0)}c===!1&&Gi(r,s,l,o),lr(r,r.mapping.slice(o).map(l,1),n,void 0,c===null);let f=r.mapping.slice(o),h=f.map(l,1),d=f.map(l+s.nodeSize,1);return r.step(new fe(h,d,h+1,d-1,new k(S.from(n.create(a,null,s.marks)),0,0),1,!0)),c===!0&&Ui(r,s,l,o),!1}})}function Ui(r,e,t,n){e.forEach((i,o)=>{if(i.isText){let s,l=/\r?\n|\r/g;for(;s=l.exec(i.text);){let a=r.mapping.slice(n).map(t+1+o+s.index);r.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function Gi(r,e,t,n){e.forEach((i,o)=>{if(i.type==i.type.schema.linebreakReplacement){let s=r.mapping.slice(n).map(t+1+o);r.replaceWith(s,s+1,e.type.schema.text(`
|
|
5
|
+
`))}})}function $l(r,e,t){let n=r.resolve(e),i=n.index();return n.parent.canReplaceWith(i,i+1,t)}function Wl(r,e,t,n,i){let o=r.doc.nodeAt(e);if(!o)throw new RangeError("No node at given position");t||(t=o.type);let s=t.create(n,null,i||o.marks);if(o.isLeaf)return r.replaceWith(e,e+o.nodeSize,s);if(!t.validContent(o.content))throw new RangeError("Invalid content for node type "+t.name);r.step(new fe(e,e+o.nodeSize,e+1,e+o.nodeSize-1,new k(S.from(s),0,0),1,!0))}function Ft(r,e,t=1,n){let i=r.resolve(e),o=i.depth-t,s=n&&n[n.length-1]||i.parent;if(o<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!s.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let c=i.depth-1,f=t-2;c>o;c--,f--){let h=i.node(c),d=i.index(c);if(h.type.spec.isolating)return!1;let p=h.content.cutByIndex(d,h.childCount),u=n&&n[f+1];u&&(p=p.replaceChild(0,u.type.create(u.attrs)));let m=n&&n[f]||h;if(!h.canReplace(d+1,h.childCount)||!m.type.validContent(p))return!1}let l=i.indexAfter(o),a=n&&n[0];return i.node(o).canReplaceWith(l,l,a?a.type:i.node(o+1).type)}function Jl(r,e,t=1,n){let i=r.doc.resolve(e),o=S.empty,s=S.empty;for(let l=i.depth,a=i.depth-t,c=t-1;l>a;l--,c--){o=S.from(i.node(l).copy(o));let f=n&&n[c];s=S.from(f?f.type.create(f.attrs,s):i.node(l).copy(s))}r.step(new se(e,e,new k(o.append(s),t,t),!0))}function Vt(r,e){let t=r.resolve(e),n=t.index();return Hl(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(n,n+1)}function ql(r,e){e.content.size||r.type.compatibleContent(e.type);let t=r.contentMatchAt(r.childCount),{linebreakReplacement:n}=r.type.schema;for(let i=0;i<e.childCount;i++){let o=e.child(i),s=o.type==n?r.type.schema.nodes.text:o.type;if(t=t.matchType(s),!t||!r.type.allowsMarks(o.marks))return!1}return t.validEnd}function Hl(r,e){return!!(r&&e&&!r.isLeaf&&ql(r,e))}function Kl(r,e,t){let n=null,{linebreakReplacement:i}=r.doc.type.schema,o=r.doc.resolve(e-t),s=o.node().type;if(i&&s.inlineContent){let f=s.whitespace=="pre",h=!!s.contentMatch.matchType(i);f&&!h?n=!1:!f&&h&&(n=!0)}let l=r.steps.length;if(n===!1){let f=r.doc.resolve(e+t);Gi(r,f.node(),f.before(),l)}s.inlineContent&&lr(r,e+t-1,s,o.node().contentMatchAt(o.index()),n==null);let a=r.mapping.slice(l),c=a.map(e-t);if(r.step(new se(c,a.map(e+t,-1),k.empty,!0)),n===!0){let f=r.doc.resolve(c);Ui(r,f.node(),f.before(),r.steps.length)}return r}function _l(r,e,t){let n=r.resolve(e);if(n.parent.canReplaceWith(n.index(),n.index(),t))return e;if(n.parentOffset==0)for(let i=n.depth-1;i>=0;i--){let o=n.index(i);if(n.node(i).canReplaceWith(o,o,t))return n.before(i+1);if(o>0)return null}if(n.parentOffset==n.parent.content.size)for(let i=n.depth-1;i>=0;i--){let o=n.indexAfter(i);if(n.node(i).canReplaceWith(o,o,t))return n.after(i+1);if(o<n.node(i).childCount)return null}return null}function gn(r,e,t){let n=r.resolve(e);if(!t.content.size)return e;let i=t.content;for(let o=0;o<t.openStart;o++)i=i.firstChild.content;for(let o=1;o<=(t.openStart==0&&t.size?2:1);o++)for(let s=n.depth;s>=0;s--){let l=s==n.depth?0:n.pos<=(n.start(s+1)+n.end(s+1))/2?-1:1;for(let a=0;a<2;a++){if(a){if(!l)break;l=-l}let c=n.index(s)+(l>0?1:0),f=n.node(s),h=!1;if(o==1)h=f.canReplace(c,c,i);else{let d=f.contentMatchAt(c).findWrapping(i.firstChild.type);h=d&&f.canReplaceWith(c,c,d[0])}if(h)return l==0?n.pos:l<0?n.before(s+1):n.after(s+1)}}return null}function yn(r,e,t=e,n=k.empty){if(e==t&&!n.size)return null;let i=r.resolve(e),o=r.resolve(t);return Yi(i,o,n)?new se(e,t,n):new or(i,o,n).fit()}function Yi(r,e,t){return!t.openStart&&!t.openEnd&&r.start()==e.start()&&r.parent.canReplace(r.index(),e.index(),t.content)}var or=class{constructor(e,t,n){this.$from=e,this.$to=t,this.unplaced=n,this.frontier=[],this.placed=S.empty;for(let i=0;i<=e.depth;i++){let o=e.node(i);this.frontier.push({type:o.type,match:o.contentMatchAt(e.indexAfter(i))})}for(let i=e.depth;i>0;i--)this.placed=S.from(e.node(i).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let c=this.findFittable();c?this.placeNodes(c):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,n=this.$from,i=this.close(e<0?this.$to:n.doc.resolve(e));if(!i)return null;let o=this.placed,s=n.depth,l=i.depth;for(;s&&l&&o.childCount==1;)o=o.firstChild.content,s--,l--;let a=new k(o,s,l);return e>-1?new fe(n.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||n.pos!=this.$to.pos?new se(n.pos,i.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,n=0,i=this.unplaced.openEnd;n<e;n++){let o=t.firstChild;if(t.childCount>1&&(i=0),o.type.spec.isolating&&i<=n){e=n;break}t=o.content}for(let t=1;t<=2;t++)for(let n=t==1?e:this.unplaced.openStart;n>=0;n--){let i,o=null;n?(o=Wi(this.unplaced.content,n-1).firstChild,i=o.content):i=this.unplaced.content;let s=i.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:c}=this.frontier[l],f,h=null;if(t==1&&(s?c.matchType(s.type)||(h=c.fillBefore(S.from(s),!1)):o&&a.compatibleContent(o.type)))return{sliceDepth:n,frontierDepth:l,parent:o,inject:h};if(t==2&&s&&(f=c.findWrapping(s.type)))return{sliceDepth:n,frontierDepth:l,parent:o,wrap:f};if(o&&c.matchType(o.type))break}}}openMore(){let{content:e,openStart:t,openEnd:n}=this.unplaced;return Ji(e,-1)<=t?!1:(this.unplaced.size>1&&Ji(e,1)>n&&n++,this.unplaced=new k(e,t+1,n),!0)}dropNode(){let{content:e,openStart:t,openEnd:n}=this.unplaced,i=Wi(e,t);if(i.childCount<=1&&t>0){let o=e.size-t<=t+i.size;this.unplaced=new k(Tt(e,t-1,1),t-1,o?t-1:n)}else this.unplaced=new k(Tt(e,t,1),t,n)}placeNodes({sliceDepth:e,frontierDepth:t,parent:n,inject:i,wrap:o}){for(;this.depth>t;)this.closeFrontierNode();if(o)for(let m=0;m<o.length;m++)this.openFrontierNode(o[m]);let s=this.unplaced,l=n?n.content:s.content,a=s.openStart-e,c=0,f=[],{match:h,type:d}=this.frontier[t];if(i){for(let m=0;m<i.childCount;m++)f.push(i.child(m));h=h.matchFragment(i)}let p=l.size+e-(s.content.size-s.openEnd);for(;c<l.childCount;){let m=l.child(c),g=h.matchType(m.type);if(!g)break;c++,(c>1||a==0||m.content.size)&&(h=g,f.push(Xi(m.mark(d.allowedMarks(m.marks)),c==1?a:0,c==l.childCount?p:-1)))}let u=c==l.childCount;u||(p=-1),this.placed=Et(this.placed,t,S.from(f)),this.frontier[t].match=h,u&&p<0&&n&&n.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let m=0,g=f[f.length-1];g&&m<p;m++)this.frontier.push({type:g.type,match:g.contentMatchAt(g.childCount)}),g=g.lastChild;this.unplaced=u?e==0?k.empty:new k(Tt(s.content,e-1,1),e-1,p<0?s.openEnd:e-1):new k(Tt(s.content,e,c),e,s.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!rr(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(t=this.findCloseLevel(this.$to))&&t.depth==this.depth)return-1;let{depth:n}=this.$to,i=this.$to.after(n);for(;n>1&&i==this.$to.end(--n);)++i;return i}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:n,type:i}=this.frontier[t],o=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),s=rr(e,t,i,n,o);if(s){for(let l=t-1;l>=0;l--){let{match:a,type:c}=this.frontier[l],f=rr(e,l,c,a,!0);if(!f||f.childCount)continue e}return{depth:t,fit:s,move:o?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=Et(this.placed,t.depth,t.fit)),e=t.move;for(let n=t.depth+1;n<=e.depth;n++){let i=e.node(n),o=i.type.contentMatch.fillBefore(i.content,!0,e.index(n));this.openFrontierNode(i.type,i.attrs,o)}return e}openFrontierNode(e,t=null,n){let i=this.frontier[this.depth];i.match=i.match.matchType(e),this.placed=Et(this.placed,this.depth,S.from(e.create(t,n))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(S.empty,!0);t.childCount&&(this.placed=Et(this.placed,this.frontier.length,t))}};function Tt(r,e,t){return e==0?r.cutByIndex(t,r.childCount):r.replaceChild(0,r.firstChild.copy(Tt(r.firstChild.content,e-1,t)))}function Et(r,e,t){return e==0?r.append(t):r.replaceChild(r.childCount-1,r.lastChild.copy(Et(r.lastChild.content,e-1,t)))}function Wi(r,e){for(let t=0;t<e;t++)r=r.firstChild.content;return r}function Xi(r,e,t){if(e<=0)return r;let n=r.content;return e>1&&(n=n.replaceChild(0,Xi(n.firstChild,e-1,n.childCount==1?t-1:0))),e>0&&(n=r.type.contentMatch.fillBefore(n).append(n),t<=0&&(n=n.append(r.type.contentMatch.matchFragment(n).fillBefore(S.empty,!0)))),r.copy(n)}function rr(r,e,t,n,i){let o=r.node(e),s=i?r.indexAfter(e):r.index(e);if(s==o.childCount&&!t.compatibleContent(o.type))return null;let l=n.fillBefore(o.content,!0,s);return l&&!jl(t,o.content,s)?l:null}function jl(r,e,t){for(let n=t;n<e.childCount;n++)if(!r.allowsMarks(e.child(n).marks))return!0;return!1}function Ul(r){return r.spec.defining||r.spec.definingForContent}function Ji(r,e){for(let t=0;;t++){let n=e<0?r.firstChild:r.lastChild;if(!n||n.isAtom)return t;r=n.content}}function Gl(r,e,t,n){if(!n.size)return r.deleteRange(e,t);let i=r.doc.resolve(e),o=r.doc.resolve(t);if(Yi(i,o,n))return r.step(new se(e,t,n));let s=Zi(i,o);s[s.length-1]==0&&s.pop();let l=-(i.depth+1);s.unshift(l);for(let d=i.depth,p=i.pos-1;d>0;d--,p--){let u=i.node(d).type.spec;if(u.defining||u.definingAsContext||u.isolating)break;s.indexOf(d)>-1?l=d:i.before(d)==p&&s.splice(1,0,-d)}let a=s.indexOf(l),c=[],f=n.openStart;for(let d=n.content,p=0;;p++){let u=d.firstChild;if(c.push(u),p==n.openStart)break;d=u.content}for(let d=f-1;d>=0;d--){let p=c[d],u=Ul(p.type);if(u&&!p.sameMarkup(i.node(Math.abs(l)-1)))f=d;else if(u||!p.type.isTextblock)break}for(let d=n.openStart;d>=0;d--){let p=(d+f+1)%(n.openStart+1),u=c[p];if(u)for(let m=0;m<s.length;m++){let g=s[(m+a)%s.length],b=!0;g<0&&(b=!1,g=-g);let I=i.node(g-1),C=i.index(g-1);if(I.canReplaceWith(C,C,u.type,u.marks))return r.replace(i.before(g),b?o.after(g):t,new k(Qi(n.content,0,n.openStart,p),p,n.openEnd))}}let h=r.steps.length;for(let d=s.length-1;d>=0&&(r.replace(e,t,n),!(r.steps.length>h));d--){let p=s[d];p<0||(e=i.before(p),t=o.after(p))}}function Qi(r,e,t,n,i){if(e<t){let o=r.firstChild;r=r.replaceChild(0,o.copy(Qi(o.content,e+1,t,n,o)))}if(e>n){let o=i.contentMatchAt(0),s=o.fillBefore(r).append(r);r=s.append(o.matchFragment(s).fillBefore(S.empty,!0))}return r}function Yl(r,e,t,n){if(!n.isInline&&e==t&&r.doc.resolve(e).parent.content.size){let i=_l(r.doc,e,n.type);i!=null&&(e=t=i)}r.replaceRange(e,t,new k(S.from(n),0,0))}function Xl(r,e,t){let n=r.doc.resolve(e),i=r.doc.resolve(t);if(n.parent.isTextblock&&i.parent.isTextblock&&n.start()!=i.start()&&n.parentOffset==0&&i.parentOffset==0){let s=n.sharedDepth(t),l=!1;for(let a=n.depth;a>s;a--)n.node(a).type.spec.isolating&&(l=!0);for(let a=i.depth;a>s;a--)i.node(a).type.spec.isolating&&(l=!0);if(!l){for(let a=n.depth;a>0&&e==n.start(a);a--)e=n.before(a);for(let a=i.depth;a>0&&t==i.start(a);a--)t=i.before(a);n=r.doc.resolve(e),i=r.doc.resolve(t)}}let o=Zi(n,i);for(let s=0;s<o.length;s++){let l=o[s],a=s==o.length-1;if(a&&l==0||n.node(l).type.contentMatch.validEnd)return r.delete(n.start(l),i.end(l));if(l>0&&(a||n.node(l-1).canReplace(n.index(l-1),i.indexAfter(l-1))))return r.delete(n.before(l),i.after(l))}for(let s=1;s<=n.depth&&s<=i.depth;s++)if(e-n.start(s)==n.depth-s&&t>n.end(s)&&i.end(s)-t!=i.depth-s&&n.start(s-1)==i.start(s-1)&&n.node(s-1).canReplace(n.index(s-1),i.index(s-1)))return r.delete(n.before(s),t);r.delete(e,t)}function Zi(r,e){let t=[],n=Math.min(r.depth,e.depth);for(let i=n;i>=0;i--){let o=r.start(i);if(o<r.pos-(r.depth-i)||e.end(i)>e.pos+(e.depth-i)||r.node(i).type.spec.isolating||e.node(i).type.spec.isolating)break;(o==e.start(i)||i==r.depth&&i==e.depth&&r.parent.inlineContent&&e.parent.inlineContent&&i&&e.start(i-1)==o-1)&&t.push(i)}return t}var dn=class r extends L{constructor(e,t,n){super(),this.pos=e,this.attr=t,this.value=n}apply(e){let t=e.nodeAt(this.pos);if(!t)return q.fail("No node at attribute step's position");let n=Object.create(null);for(let o in t.attrs)n[o]=t.attrs[o];n[this.attr]=this.value;let i=t.type.create(n,null,t.marks);return q.fromReplace(e,this.pos,this.pos+1,new k(S.from(i),0,t.isLeaf?0:1))}getMap(){return Oe.empty}invert(e){return new r(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new r(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.pos!="number"||typeof t.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new r(t.pos,t.attr,t.value)}};L.jsonID("attr",dn);var pn=class r extends L{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let i in e.attrs)t[i]=e.attrs[i];t[this.attr]=this.value;let n=e.type.create(t,e.content,e.marks);return q.ok(n)}getMap(){return Oe.empty}invert(e){return new r(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new r(t.attr,t.value)}};L.jsonID("docAttr",pn);var ut=class extends Error{};ut=function r(e){let t=Error.call(this,e);return t.__proto__=r.prototype,t};ut.prototype=Object.create(Error.prototype);ut.prototype.constructor=ut;ut.prototype.name="TransformError";var dt=class{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new It}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new ut(t.failed);return this}maybeStep(e){let t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}get docChanged(){return this.steps.length>0}changedRange(){let e=1e9,t=-1e9;for(let n=0;n<this.mapping.maps.length;n++){let i=this.mapping.maps[n];n&&(e=i.map(e,1),t=i.map(t,-1)),i.forEach((o,s,l,a)=>{e=Math.min(e,l),t=Math.max(t,a)})}return e==1e9?null:{from:e,to:t}}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,n=k.empty){let i=yn(this.doc,e,t,n);return i&&this.step(i),this}replaceWith(e,t,n){return this.replace(e,t,new k(S.from(n),0,0))}delete(e,t){return this.replace(e,t,k.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,n){return Gl(this,e,t,n),this}replaceRangeWith(e,t,n){return Yl(this,e,t,n),this}deleteRange(e,t){return Xl(this,e,t),this}lift(e,t){return Pl(this,e,t),this}join(e,t=1){return Kl(this,e,t),this}wrap(e,t){return Vl(this,e,t),this}setBlockType(e,t=e,n,i=null){return Ll(this,e,t,n,i),this}setNodeMarkup(e,t,n=null,i){return Wl(this,e,t,n,i),this}setNodeAttribute(e,t,n){return this.step(new dn(e,t,n)),this}setDocAttribute(e,t){return this.step(new pn(e,t)),this}addNodeMark(e,t){return this.step(new Pt(e,t)),this}removeNodeMark(e,t){let n=this.doc.nodeAt(e);if(!n)throw new RangeError("No node at position "+e);if(t instanceof z)t.isInSet(n.marks)&&this.step(new ht(e,t));else{let i=n.marks,o,s=[];for(;o=t.isInSet(i);)s.push(new ht(e,o)),i=o.removeFromSet(i);for(let l=s.length-1;l>=0;l--)this.step(s[l])}return this}split(e,t=1,n){return Jl(this,e,t,n),this}addMark(e,t,n){return Il(this,e,t,n),this}removeMark(e,t,n){return vl(this,e,t,n),this}clearIncompatible(e,t,n){return lr(this,e,t,n),this}};var ar=Object.create(null),D=class{constructor(e,t,n){this.$anchor=e,this.$head=t,this.ranges=n||[new Be(e.min(t),e.max(t))]}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 e=this.ranges;for(let t=0;t<e.length;t++)if(e[t].$from.pos!=e[t].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,t=k.empty){let n=t.content.lastChild,i=null;for(let l=0;l<t.openEnd;l++)i=n,n=n.lastChild;let o=e.steps.length,s=this.ranges;for(let l=0;l<s.length;l++){let{$from:a,$to:c}=s[l],f=e.mapping.slice(o);e.replaceRange(f.map(a.pos),f.map(c.pos),l?k.empty:t),l==0&&no(e,o,(n?n.isInline:i&&i.isTextblock)?-1:1)}}replaceWith(e,t){let n=e.steps.length,i=this.ranges;for(let o=0;o<i.length;o++){let{$from:s,$to:l}=i[o],a=e.mapping.slice(n),c=a.map(s.pos),f=a.map(l.pos);o?e.deleteRange(c,f):(e.replaceRangeWith(c,f,t),no(e,n,t.isInline?-1:1))}}static findFrom(e,t,n=!1){let i=e.parent.inlineContent?new T(e):pt(e.node(0),e.parent,e.pos,e.index(),t,n);if(i)return i;for(let o=e.depth-1;o>=0;o--){let s=t<0?pt(e.node(0),e.node(o),e.before(o+1),e.index(o),t,n):pt(e.node(0),e.node(o),e.after(o+1),e.index(o)+1,t,n);if(s)return s}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new he(e.node(0))}static atStart(e){return pt(e,e,0,0,1)||new he(e)}static atEnd(e){return pt(e,e,e.content.size,e.childCount,-1)||new he(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let n=ar[t.type];if(!n)throw new RangeError(`No selection type ${t.type} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in ar)throw new RangeError("Duplicate use of selection JSON ID "+e);return ar[e]=t,t.prototype.jsonID=e,t}getBookmark(){return T.between(this.$anchor,this.$head).getBookmark()}};D.prototype.visible=!0;var Be=class{constructor(e,t){this.$from=e,this.$to=t}},eo=!1;function to(r){!eo&&!r.parent.inlineContent&&(eo=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+r.parent.type.name+")"))}var T=class r extends D{constructor(e,t=e){to(e),to(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let n=e.resolve(t.map(this.head));if(!n.parent.inlineContent)return D.near(n);let i=e.resolve(t.map(this.anchor));return new r(i.parent.inlineContent?i:n,n)}replace(e,t=k.empty){if(super.replace(e,t),t==k.empty){let n=this.$from.marksAcross(this.$to);n&&e.ensureMarks(n)}}eq(e){return e instanceof r&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Sn(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if(typeof t.anchor!="number"||typeof t.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new r(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,n=t){let i=e.resolve(t);return new this(i,n==t?i:e.resolve(n))}static between(e,t,n){let i=e.pos-t.pos;if((!n||i)&&(n=i>=0?1:-1),!t.parent.inlineContent){let o=D.findFrom(t,n,!0)||D.findFrom(t,-n,!0);if(o)t=o.$head;else return D.near(t,n)}return e.parent.inlineContent||(i==0?e=t:(e=(D.findFrom(e,-n,!0)||D.findFrom(e,n,!0)).$anchor,e.pos<t.pos!=i<0&&(e=t))),new r(e,t)}};D.jsonID("text",T);var Sn=class r{constructor(e,t){this.anchor=e,this.head=t}map(e){return new r(e.map(this.anchor),e.map(this.head))}resolve(e){return T.between(e.resolve(this.anchor),e.resolve(this.head))}},w=class r extends D{constructor(e){let t=e.nodeAfter,n=e.node(0).resolve(e.pos+t.nodeSize);super(e,n),this.node=t}map(e,t){let{deleted:n,pos:i}=t.mapResult(this.anchor),o=e.resolve(i);return n?D.near(o):new r(o)}content(){return new k(S.from(this.node),0,0)}eq(e){return e instanceof r&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new fr(this.anchor)}static fromJSON(e,t){if(typeof t.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new r(e.resolve(t.anchor))}static create(e,t){return new r(e.resolve(t))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}};w.prototype.visible=!1;D.jsonID("node",w);var fr=class r{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:n}=e.mapResult(this.anchor);return t?new Sn(n,n):new r(n)}resolve(e){let t=e.resolve(this.anchor),n=t.nodeAfter;return n&&w.isSelectable(n)?new w(t):D.near(t)}},he=class r extends D{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=k.empty){if(t==k.empty){e.delete(0,e.doc.content.size);let n=D.atStart(e.doc);n.eq(e.selection)||e.setSelection(n)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new r(e)}map(e){return new r(e)}eq(e){return e instanceof r}getBookmark(){return Ql}};D.jsonID("all",he);var Ql={map(){return this},resolve(r){return new he(r)}};function pt(r,e,t,n,i,o=!1){if(e.inlineContent)return T.create(r,t);for(let s=n-(i>0?0:1);i>0?s<e.childCount:s>=0;s+=i){let l=e.child(s);if(l.isAtom){if(!o&&w.isSelectable(l))return w.create(r,t-(i<0?l.nodeSize:0))}else{let a=pt(r,l,t+i,i<0?l.childCount:0,i,o);if(a)return a}t+=l.nodeSize*i}return null}function no(r,e,t){let n=r.steps.length-1;if(n<e)return;let i=r.steps[n];if(!(i instanceof se||i instanceof fe))return;let o=r.mapping.maps[n],s;o.forEach((l,a,c,f)=>{s==null&&(s=f)}),r.setSelection(D.near(r.doc.resolve(s),t))}var ro=1,bn=2,io=4,hr=class extends dt{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(e){if(e.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=(this.updated|ro)&~bn,this.storedMarks=null,this}get selectionSet(){return(this.updated&ro)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=bn,this}ensureMarks(e){return z.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&bn)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&~bn,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let n=this.selection;return t&&(e=e.mark(this.storedMarks||(n.empty?n.$from.marks():n.$from.marksAcross(n.$to)||z.none))),n.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,n){let i=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(i.text(e),!0):this.deleteSelection();{if(n==null&&(n=t),!e)return this.deleteRange(t,n);let o=this.storedMarks;if(!o){let s=this.doc.resolve(t);o=n==t?s.marks():s.marksAcross(this.doc.resolve(n))}return this.replaceRangeWith(t,n,i.text(e,o)),!this.selection.empty&&this.selection.to==t+e.length&&this.setSelection(D.near(this.selection.$to)),this}}setMeta(e,t){return this.meta[typeof e=="string"?e:e.key]=t,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=io,this}get scrolledIntoView(){return(this.updated&io)>0}};function oo(r,e){return!e||!r?r:r.bind(e)}var Ge=class{constructor(e,t,n){this.name=e,this.init=oo(t.init,n),this.apply=oo(t.apply,n)}},Zl=[new Ge("doc",{init(r){return r.doc||r.schema.topNodeType.createAndFill()},apply(r){return r.doc}}),new Ge("selection",{init(r,e){return r.selection||D.atStart(e.doc)},apply(r){return r.selection}}),new Ge("storedMarks",{init(r){return r.storedMarks||null},apply(r,e,t,n){return n.selection.$cursor?r.storedMarks:null}}),new Ge("scrollToSelection",{init(){return 0},apply(r,e){return r.scrolledIntoView?e+1:e}})],Lt=class{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=Zl.slice(),t&&t.forEach(n=>{if(this.pluginsByKey[n.key])throw new RangeError("Adding different instances of a keyed plugin ("+n.key+")");this.plugins.push(n),this.pluginsByKey[n.key]=n,n.spec.state&&this.fields.push(new Ge(n.key,n.spec.state,n))})}},kn=class r{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,t=-1){for(let n=0;n<this.config.plugins.length;n++)if(n!=t){let i=this.config.plugins[n];if(i.spec.filterTransaction&&!i.spec.filterTransaction.call(i,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],n=this.applyInner(e),i=null;for(;;){let o=!1;for(let s=0;s<this.config.plugins.length;s++){let l=this.config.plugins[s];if(l.spec.appendTransaction){let a=i?i[s].n:0,c=i?i[s].state:this,f=a<t.length&&l.spec.appendTransaction.call(l,a?t.slice(a):t,c,n);if(f&&n.filterTransaction(f,s)){if(f.setMeta("appendedTransaction",e),!i){i=[];for(let h=0;h<this.config.plugins.length;h++)i.push(h<s?{state:n,n:t.length}:{state:this,n:0})}t.push(f),n=n.applyInner(f),o=!0}i&&(i[s]={state:n,n:t.length})}}if(!o)return{state:n,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let t=new r(this.config),n=this.config.fields;for(let i=0;i<n.length;i++){let o=n[i];t[o.name]=o.apply(e,this[o.name],this,t)}return t}get tr(){return new hr(this)}static create(e){let t=new Lt(e.doc?e.doc.type.schema:e.schema,e.plugins),n=new r(t);for(let i=0;i<t.fields.length;i++)n[t.fields[i].name]=t.fields[i].init(e,n);return n}reconfigure(e){let t=new Lt(this.schema,e.plugins),n=t.fields,i=new r(t);for(let o=0;o<n.length;o++){let s=n[o].name;i[s]=this.hasOwnProperty(s)?this[s]:n[o].init(e,i)}return i}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map(n=>n.toJSON())),e&&typeof e=="object")for(let n in e){if(n=="doc"||n=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let i=e[n],o=i.spec.state;o&&o.toJSON&&(t[n]=o.toJSON.call(i,this[i.key]))}return t}static fromJSON(e,t,n){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let i=new Lt(e.schema,e.plugins),o=new r(i);return i.fields.forEach(s=>{if(s.name=="doc")o.doc=be.fromJSON(e.schema,t.doc);else if(s.name=="selection")o.selection=D.fromJSON(o.doc,t.selection);else if(s.name=="storedMarks")t.storedMarks&&(o.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(n)for(let l in n){let a=n[l],c=a.spec.state;if(a.key==s.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(t,l)){o[s.name]=c.fromJSON.call(a,e,t[l],o);return}}o[s.name]=s.init(e,o)}}),o}};function so(r,e,t){for(let n in r){let i=r[n];i instanceof Function?i=i.bind(e):n=="handleDOMEvents"&&(i=so(i,e,{})),t[n]=i}return t}var H=class{constructor(e){this.spec=e,this.props={},e.props&&so(e.props,this,this.props),this.key=e.key?e.key.key:lo("plugin")}getState(e){return e[this.key]}},cr=Object.create(null);function lo(r){return r in cr?r+"$"+ ++cr[r]:(cr[r]=0,r+"$")}var me=class{constructor(e="key"){this.key=lo(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}};var U=function(r){for(var e=0;;e++)if(r=r.previousSibling,!r)return e},bt=function(r){let e=r.assignedSlot||r.parentNode;return e&&e.nodeType==11?e.host:e},gr=null,De=function(r,e,t){let n=gr||(gr=document.createRange());return n.setEnd(r,t??r.nodeValue.length),n.setStart(r,e||0),n},ea=function(){gr=null},nt=function(r,e,t,n){return t&&(ao(r,e,t,n,-1)||ao(r,e,t,n,1))},ta=/^(img|br|input|textarea|hr)$/i;function ao(r,e,t,n,i){for(var o;;){if(r==t&&e==n)return!0;if(e==(i<0?0:te(r))){let s=r.parentNode;if(!s||!M(s)||Gt(r)||ta.test(r.nodeName)||r.contentEditable=="false")return!1;e=U(r)+(i<0?0:1),r=s}else if(M(r)){let s=r.childNodes[e+(i<0?-1:0)];if(M(s)&&s.contentEditable=="false")if(!((o=s.pmViewDesc)===null||o===void 0)&&o.ignoreForSelection)e+=i;else return!1;else r=s,e=i<0?te(r):0}else return!1}}function te(r){return r.nodeType==3?r.nodeValue.length:r.childNodes.length}function M(r){return r.nodeType==1}function W(r){return r.nodeType==3}function rt(r,e){return e?r.contains(M(e)?e:e.parentNode):!1}function na(r,e){for(;;){if(W(r)&&e)return r;if(M(r)&&e>0){if(r.contentEditable=="false")return null;r=r.childNodes[e-1],e=te(r)}else if(r.parentNode&&!Gt(r))e=U(r),r=r.parentNode;else return null}}function ra(r,e){for(;;){if(W(r)&&e<r.nodeValue.length)return r;if(M(r)&&e<r.childNodes.length){if(r.contentEditable=="false")return null;r=r.childNodes[e],e=0}else if(r.parentNode&&!Gt(r))e=U(r)+1,r=r.parentNode;else return null}}function ia(r,e,t){for(let n=e==0,i=e==te(r);n||i;){if(r==t)return!0;let o=U(r);if(r=r.parentNode,!r)return!1;n=n&&o==0,i=i&&o==te(r)}}function Gt(r){let e;for(let t=r;t&&!(e=t.pmViewDesc);t=t.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==r||e.contentDOM==r)}var Rn=function(r){return r.focusNode&&nt(r.focusNode,r.focusOffset,r.anchorNode,r.anchorOffset)};function oa(r,e){let t=document.createEvent("Event");return t.initEvent("keydown",!0,!0),t.keyCode=r,t.key=t.code=e,t}function sa(r){let e=r.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function la(r,e,t){if(r.caretPositionFromPoint)try{let n=r.caretPositionFromPoint(e,t);if(n)return{node:n.offsetNode,offset:Math.min(te(n.offsetNode),n.offset)}}catch{}if(r.caretRangeFromPoint){let n=r.caretRangeFromPoint(e,t);if(n)return{node:n.startContainer,offset:Math.min(te(n.startContainer),n.startOffset)}}}var Se=typeof navigator<"u"?navigator:null,co=typeof document<"u"?document:null,Je=Se&&Se.userAgent||"",yr=/Edge\/(\d+)/.exec(Je),Lo=/MSIE \d/.exec(Je),br=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Je),le=!!(Lo||br||yr),$e=Lo?document.documentMode:br?+br[1]:yr?+yr[1]:0,ue=!le&&/gecko\/(\d+)/i.test(Je);ue&&+(/Firefox\/(\d+)/.exec(Je)||[0,0])[1];var Sr=!le&&/Chrome\/(\d+)/.exec(Je),G=!!Sr,$o=Sr?+Sr[1]:0,ne=!le&&!!Se&&/Apple Computer/.test(Se.vendor),St=ne&&(/Mobile\/\w+/.test(Je)||!!Se&&Se.maxTouchPoints>2),de=St||(Se?/Mac/.test(Se.platform):!1),Wo=Se?/Win/.test(Se.platform):!1,Ae=/Android \d/.test(Je),In=!!co&&"webkitFontSmoothing"in co.documentElement.style,aa=In?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function ca(r){let e=r.defaultView&&r.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:r.documentElement.clientWidth,top:0,bottom:r.documentElement.clientHeight}}function Ne(r,e){return typeof r=="number"?r:r[e]}function fa(r){let e=r.getBoundingClientRect(),t=e.width/r.offsetWidth||1,n=e.height/r.offsetHeight||1;return{left:e.left,right:e.left+r.clientWidth*t,top:e.top,bottom:e.top+r.clientHeight*n}}function fo(r,e,t){if(!kr(e)&&e.left==0)return;let n=r.someProp("scrollThreshold")||0,i=r.someProp("scrollMargin")||5,o=r.dom.ownerDocument;for(let s=t||r.dom;s;){if(!M(s)){s=bt(s);continue}let l=s==o.body,a=l?ca(o):fa(s),c=0,f=0;if(e.top<a.top+Ne(n,"top")?f=-(a.top-e.top+Ne(i,"top")):e.bottom>a.bottom-Ne(n,"bottom")&&(f=e.bottom-e.top>a.bottom-a.top?e.top+Ne(i,"top")-a.top:e.bottom-a.bottom+Ne(i,"bottom")),e.left<a.left+Ne(n,"left")?c=-(a.left-e.left+Ne(i,"left")):e.right>a.right-Ne(n,"right")&&(c=e.right-a.right+Ne(i,"right")),c||f)if(l)o.defaultView.scrollBy(c,f);else{let d=s.scrollLeft,p=s.scrollTop;f&&(s.scrollTop+=f),c&&(s.scrollLeft+=c);let u=s.scrollLeft-d,m=s.scrollTop-p;e={left:e.left-u,top:e.top-m,right:e.right-u,bottom:e.bottom-m}}let h=l?"fixed":getComputedStyle(s).position;if(/^(fixed|sticky)$/.test(h))break;s=h=="absolute"?s.offsetParent:bt(s)}}function ha(r){let e=r.dom.getBoundingClientRect(),t=Math.max(0,e.top),n,i;for(let o=(e.left+e.right)/2,s=t+1;s<Math.min(innerHeight,e.bottom);s+=5){let l=r.root.elementFromPoint(o,s);if(!l||l==r.dom||!r.dom.contains(l))continue;let a=l.getBoundingClientRect();if(a.top>=t-20){n=l,i=a.top;break}}return{refDOM:n,refTop:i,stack:Jo(r.dom)}}function Jo(r){let e=[],t=r.ownerDocument;for(let n=r;n&&(e.push({dom:n,top:n.scrollTop,left:n.scrollLeft}),r!=t);n=bt(n));return e}function ua({refDOM:r,refTop:e,stack:t}){let n=r?r.getBoundingClientRect().top:0;qo(t,n==0?0:n-e)}function qo(r,e){for(let t=0;t<r.length;t++){let{dom:n,top:i,left:o}=r[t];n.scrollTop!=i+e&&(n.scrollTop=i+e),n.scrollLeft!=o&&(n.scrollLeft=o)}}var mt=null;function da(r){if(r.setActive)return r.setActive();if(mt)return r.focus(mt);let e=Jo(r);r.focus(mt==null?{get preventScroll(){return mt={preventScroll:!0},!0}}:void 0),mt||(mt=!1,qo(e,0))}function Ho(r,e){let t,n=2e8,i,o=0,s=e.top,l=e.top,a,c;for(let f=r.firstChild,h=0;f;f=f.nextSibling,h++){let d;if(M(f))d=f.getClientRects();else if(W(f))d=De(f).getClientRects();else continue;for(let p=0;p<d.length;p++){let u=d[p];if(u.top<=s&&u.bottom>=l){s=Math.max(u.bottom,s),l=Math.min(u.top,l);let m=u.left>e.left?u.left-e.left:u.right<e.left?e.left-u.right:0;if(m<n){t=f,n=m,i=m&&W(t)?{left:u.right<e.left?u.right:u.left,top:e.top}:e,M(f)&&m&&(o=h+(e.left>=(u.left+u.right)/2?1:0));continue}}else u.top>e.top&&!a&&u.left<=e.left&&u.right>=e.left&&(a=f,c={left:Math.max(u.left,Math.min(u.right,e.left)),top:u.top});!t&&(e.left>=u.right&&e.top>=u.top||e.left>=u.left&&e.top>=u.bottom)&&(o=h+1)}}return!t&&a&&(t=a,i=c,n=0),t&&W(t)?pa(t,i):!t||n?{node:r,offset:o}:Ho(t,i)}function pa(r,e){let t=r.nodeValue.length,n=document.createRange(),i;for(let o=0;o<t;o++){n.setEnd(r,o+1),n.setStart(r,o);let s=Fe(n,1);if(s.top!=s.bottom&&Br(e,s)){i={node:r,offset:o+(e.left>=(s.left+s.right)/2?1:0)};break}}return n.detach(),i||{node:r,offset:0}}function Br(r,e){return r.left>=e.left-1&&r.left<=e.right+1&&r.top>=e.top-1&&r.top<=e.bottom+1}function ma(r,e){let t=r.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left<r.getBoundingClientRect().left?t:r}function ga(r,e,t){let{node:n,offset:i}=Ho(e,t),o=-1;if(M(n)&&!n.firstChild){let s=n.getBoundingClientRect();o=s.left!=s.right&&t.left>(s.left+s.right)/2?1:-1}return r.docView.posFromDOM(n,i,o)}function ya(r,e,t,n){let i=-1;for(let o=e,s=!1;o!=r.dom;){let l=r.docView.nearestDesc(o,!0),a;if(!l)return null;if(M(l.dom)&&(l.node.isBlock&&l.parent||!l.contentDOM)&&((a=l.dom.getBoundingClientRect()).width||a.height)&&(l.node.isBlock&&l.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(l.dom.nodeName)&&(!s&&a.left>n.left||a.top>n.top?i=l.posBefore:(!s&&a.right<n.left||a.bottom<n.top)&&(i=l.posAfter),s=!0),!l.contentDOM&&i<0&&!l.node.isText))return(l.node.isBlock?n.top<(a.top+a.bottom)/2:n.left<(a.left+a.right)/2)?l.posBefore:l.posAfter;o=l.dom.parentNode}return i>-1?i:r.docView.posFromDOM(e,t,-1)}function Ko(r,e,t){let n=r.childNodes.length;if(n&&t.top<t.bottom)for(let i=Math.max(0,Math.min(n-1,Math.floor(n*(e.top-t.top)/(t.bottom-t.top))-2)),o=i;;){let s=r.childNodes[o];if(M(s)){let l=s.getClientRects();for(let a=0;a<l.length;a++){let c=l[a];if(Br(e,c))return Ko(s,e,c)}}if((o=(o+1)%n)==i)break}return r}function ba(r,e){let t=r.dom.ownerDocument,n,i=0,o=la(t,e.left,e.top);o&&({node:n,offset:i}=o);let s=(r.root.elementFromPoint?r.root:t).elementFromPoint(e.left,e.top),l;if(!s||!r.dom.contains(s)){let c=r.dom.getBoundingClientRect();if(!Br(e,c)||(s=Ko(r.dom,e,c),!s))return null}if(ne)for(let c=s;n&&c;c=bt(c))c.draggable&&(n=void 0);if(s=ma(s,e),n){if(ue&&M(n)&&(i=Math.min(i,n.childNodes.length),i<n.childNodes.length)){let f=n.childNodes[i],h;f.nodeName=="IMG"&&(h=f.getBoundingClientRect()).right<=e.left&&h.bottom>e.top&&i++}let c;In&&i&&M(n)&&M(c=n.childNodes[i-1])&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=e.top&&i--,n==r.dom&&i==n.childNodes.length-1&&M(n.lastChild)&&e.top>n.lastChild.getBoundingClientRect().bottom?l=r.state.doc.content.size:(i==0||!M(n)||n.childNodes[i-1].nodeName!="BR")&&(l=ya(r,n,i,e))}l==null&&(l=ga(r,s,e));let a=r.docView.nearestDesc(s,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function kr(r){return r.top<r.bottom||r.left<r.right}function Fe(r,e){let t=r.getClientRects();if(t.length){let n=t[e<0?0:t.length-1];if(kr(n))return n}return Array.prototype.find.call(t,kr)||r.getBoundingClientRect()}var Sa=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function _o(r,e,t){let{node:n,offset:i,atom:o}=r.docView.domFromPos(e,t<0?-1:1),s=In||ue;if(W(n))if(s&&(Sa.test(n.nodeValue)||(t<0?!i:i==n.nodeValue.length))){let a=Fe(De(n,i,i),t);if(ue&&i&&/\s/.test(n.nodeValue[i-1])&&i<n.nodeValue.length){let c=Fe(De(n,i-1,i-1),-1);if(c.top==a.top){let f=Fe(De(n,i,i+1),-1);if(f.top!=a.top)return $t(f,f.left<c.left)}}return a}else{let a=i,c=i,f=t<0?1:-1;return t<0&&!i?(c++,f=-1):t>=0&&i==n.nodeValue.length?(a--,f=1):t<0?a--:c++,$t(Fe(De(n,a,c),f),f<0)}if(!r.state.doc.resolve(e-(o||0)).parent.inlineContent){if(o==null&&i&&(t<0||i==te(n))){let a=n.childNodes[i-1];if(M(a))return ur(a.getBoundingClientRect(),!1)}if(o==null&&i<te(n)){let a=n.childNodes[i];if(M(a))return ur(a.getBoundingClientRect(),!0)}return ur(n.getBoundingClientRect(),t>=0)}if(o==null&&i&&(t<0||i==te(n))){let a=n.childNodes[i-1],c=W(a)?De(a,te(a)-(s?0:1)):M(a)&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(c)return $t(Fe(c,1),!1)}if(o==null&&i<te(n)){let a=n.childNodes[i];for(;a.pmViewDesc&&a.pmViewDesc.ignoreForCoords;)a=a.nextSibling;let c=a?W(a)?De(a,0,s?0:1):M(a)?a:null:null;if(c)return $t(Fe(c,-1),!0)}return $t(Fe(W(n)?De(n):n,-t),t>=0)}function $t(r,e){if(r.width==0)return r;let t=e?r.left:r.right;return{top:r.top,bottom:r.bottom,left:t,right:t}}function ur(r,e){if(r.height==0)return r;let t=e?r.top:r.bottom;return{top:t,bottom:t,left:r.left,right:r.right}}function jo(r,e,t){let n=r.state,i=r.root.activeElement;n!=e&&r.updateState(e),i!=r.dom&&r.focus();try{return t()}finally{n!=e&&r.updateState(n),i!=r.dom&&i&&i.focus()}}function ka(r,e,t){let n=e.selection,i=t=="up"?n.$from:n.$to;return jo(r,e,()=>{let{node:o}=r.docView.domFromPos(i.pos,t=="up"?-1:1);for(;;){let l=r.docView.nearestDesc(o,!0);if(!l)break;if(l.node.isBlock){o=l.contentDOM||l.dom;break}o=l.dom.parentNode}let s=_o(r,i.pos,1);for(let l=o.firstChild;l;l=l.nextSibling){let a;if(M(l))a=l.getClientRects();else if(W(l))a=De(l,0,l.nodeValue.length).getClientRects();else continue;for(let c=0;c<a.length;c++){let f=a[c];if(f.bottom>f.top+1&&(t=="up"?s.top-f.top>(f.bottom-s.top)*2:f.bottom-s.bottom>(s.bottom-f.top)*2))return!1}}return!0})}var xa=/[\u0590-\u08ac]/;function Ca(r,e,t){let{$head:n}=e.selection;if(!n.parent.isTextblock)return!1;let i=n.parentOffset,o=!i,s=i==n.parent.content.size,l=r.domSelection();return l?!xa.test(n.parent.textContent)||!l.modify?t=="left"||t=="backward"?o:s:jo(r,e,()=>{let{focusNode:a,focusOffset:c,anchorNode:f,anchorOffset:h}=r.domSelectionRange(),d=l.caretBidiLevel;l.modify("move",t,"character");let p=n.depth?r.docView.domAfterPos(n.before()):r.dom,{focusNode:u,focusOffset:m}=r.domSelectionRange(),g=u&&!rt(p,u)||a==u&&c==m;try{l.collapse(f,h),a&&(a!=f||c!=h)&&l.extend&&l.extend(a,c)}catch{}return d!=null&&(l.caretBidiLevel=d),g}):n.pos==n.start()||n.pos==n.end()}var ho=null,uo=null,po=!1;function wa(r,e,t){return ho==e&&uo==t?po:(ho=e,uo=t,po=t=="up"||t=="down"?ka(r,e,t):Ca(r,e,t))}var pe=0,mo=1,Ye=2,ge=3,it=class{constructor(e,t,n,i){this.parent=e,this.children=t,this.dom=n,this.contentDOM=i,this.dirty=pe,n.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,n){return!1}matchesHack(e){return!1}parseRule(e){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;t<this.children.length;t++)e+=this.children[t].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let t=0,n=this.posAtStart;;t++){let i=this.children[t];if(i==e)return n;n+=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(e,t,n){if(this.contentDOM&&rt(this.contentDOM,e))if(n<0){let o,s;if(e==this.contentDOM)o=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;o=e.previousSibling}for(;o&&!((s=o.pmViewDesc)&&s.parent==this);)o=o.previousSibling;return o?this.posBeforeChild(s)+s.size:this.posAtStart}else{let o,s;if(e==this.contentDOM)o=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;o=e.nextSibling}for(;o&&!((s=o.pmViewDesc)&&s.parent==this);)o=o.nextSibling;return o?this.posBeforeChild(s):this.posAtEnd}let i;if(e==this.dom&&this.contentDOM)i=t>U(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM)){let o=e.compareDocumentPosition(this.contentDOM);o&16?i=t>Array.from(e.childNodes).findIndex(s=>s.contains(this.contentDOM)):i=!(o&4)}else if(this.dom.firstChild){if(t==0)for(let o=e;;o=o.parentNode){if(o==this.dom){i=!1;break}if(o.previousSibling)break}if(i==null&&t==e.childNodes.length)for(let o=e;;o=o.parentNode){if(o==this.dom){i=!0;break}if(o.nextSibling)break}}return i??n>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let n=!0,i=e;i;i=i.parentNode){let o=this.getDesc(i),s;if(o&&(!t||o.node))if(n&&(s=o.nodeDOM)&&!(M(s)?rt(s,e):s==e))n=!1;else return o}}getDesc(e){let t=e.pmViewDesc;for(let n=t;n;n=n.parent)if(n==this)return t}posFromDOM(e,t,n){for(let i=e;i;i=i.parentNode){let o=this.getDesc(i);if(o)return o.localPosFromDOM(e,t,n)}return-1}descAt(e){for(let t=0,n=0;t<this.children.length;t++){let i=this.children[t],o=n+i.size;if(n==e&&o!=n){for(;!i.border&&i.children.length;)for(let s=0;s<i.children.length;s++){let l=i.children[s];if(l.size){i=l;break}}return i}if(e<o)return i.descAt(e-n-i.border);n=o}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let n=0,i=0;for(let o=0;n<this.children.length;n++){let s=this.children[n],l=o+s.size;if(l>e){i=e-o;break}o=l}if(i)return this.children[n].domFromPos(i-this.children[n].border,t);for(;n>0;n--){let o=this.children[n-1];if(o.size||!(o instanceof wn||o instanceof xn&&o.side>=0))break}if(t<=0){let o,s=!0;for(;o=n?this.children[n-1]:null,!(!o||o.dom.parentNode==this.contentDOM);n--,s=!1);return o&&t&&s&&!o.border&&!o.domAtom?o.domFromPos(o.size,t):{node:this.contentDOM,offset:o?U(o.dom)+1:0}}else{let o,s=!0;for(;o=n<this.children.length?this.children[n]:null,!(!o||o.dom.parentNode==this.contentDOM);n++,s=!1);return o&&s&&!o.border&&!o.domAtom?o.domFromPos(0,t):{node:this.contentDOM,offset:o?U(o.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,n=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let i=-1,o=-1;for(let s=n,l=0;;l++){let a=this.children[l],c=s+a.size;if(i==-1&&e<=c){let f=s+a.border;if(e>=f&&t<=c-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,t,f);e=s;for(let h=l;h>0;h--){let d=this.children[h-1];if(d.size&&d.dom.parentNode==this.contentDOM&&!d.emptyChildAt(1)){i=U(d.dom)+1;break}e-=d.size}i==-1&&(i=0)}if(i>-1&&(c>t||l==this.children.length-1)){t=c;for(let f=l+1;f<this.children.length;f++){let h=this.children[f];if(h.size&&h.dom.parentNode==this.contentDOM&&!h.emptyChildAt(-1)){o=U(h.dom);break}t+=h.size}o==-1&&(o=this.contentDOM.childNodes.length);break}s=c}return{node:this.contentDOM,from:e,to:t,fromOffset:i,toOffset:o}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let t=this.children[e<0?0:this.children.length-1];return t.size==0||t.emptyChildAt(e)}domAfterPos(e){let{node:t,offset:n}=this.domFromPos(e,0);if(!M(t)||n==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[n]}setSelection(e,t,n,i=!1){let o=Math.min(e,t),s=Math.max(e,t);for(let p=0,u=0;p<this.children.length;p++){let m=this.children[p],g=u+m.size;if(o>u&&s<g)return m.setSelection(e-u-m.border,t-u-m.border,n,i);u=g}let l=this.domFromPos(e,e?-1:1),a=t==e?l:this.domFromPos(t,t?-1:1),c=n.root.getSelection(),f=n.domSelectionRange(),h=!1;if((ue||ne)&&e==t){let{node:p,offset:u}=l;if(W(p)){if(h=!!(u&&p.nodeValue[u-1]==`
|
|
6
|
+
`),h&&u==p.nodeValue.length)for(let m=p,g;m;m=m.parentNode){if(g=m.nextSibling){g.nodeName=="BR"&&(l=a={node:g.parentNode,offset:U(g)+1});break}let b=m.pmViewDesc;if(b&&b.node&&b.node.isBlock)break}}else{let m=p.childNodes[u-1];h=m&&(m.nodeName=="BR"||m.contentEditable=="false")}}if(ue&&f.focusNode&&f.focusNode!=a.node&&M(f.focusNode)){let p=f.focusNode.childNodes[f.focusOffset];p&&p.contentEditable=="false"&&(i=!0)}if(!(i||h&&ne)&&nt(l.node,l.offset,f.anchorNode,f.anchorOffset)&&nt(a.node,a.offset,f.focusNode,f.focusOffset))return;let d=!1;if((c.extend||e==t)&&!(h&&ue)){c.collapse(l.node,l.offset);try{e!=t&&c.extend(a.node,a.offset),d=!0}catch{}}if(!d){if(e>t){let u=l;l=a,a=u}let p=document.createRange();p.setEnd(a.node,a.offset),p.setStart(l.node,l.offset),c.removeAllRanges(),c.addRange(p)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let n=0,i=0;i<this.children.length;i++){let o=this.children[i],s=n+o.size;if(n==s?e<=s&&t>=n:e<s&&t>n){let l=n+o.border,a=s-o.border;if(e>=l&&t<=a){this.dirty=e==n||t==s?Ye:mo,e==l&&t==a&&(o.contentLost||o.dom.parentNode!=this.contentDOM)?o.dirty=ge:o.markDirty(e-l,t-l);return}else o.dirty=o.dom==o.contentDOM&&o.dom.parentNode==this.contentDOM&&!o.children.length?Ye:ge}n=s}this.dirty=Ye}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let n=e==1?Ye:mo;t.dirty<n&&(t.dirty=n)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}},xn=class extends it{constructor(e,t,n,i){let o,s=t.type.toDOM;if(typeof s=="function"&&(s=s(n,()=>{if(!o)return i;if(o.parent)return o.parent.posBeforeChild(o)})),!t.type.spec.raw){let l=M(s)?s:document.createElement("span");l!=s&&(l.appendChild(s),s=l),l.hasAttribute("contenteditable")||(l.contentEditable="false"),l.classList.add("ProseMirror-widget")}super(e,[],s,null),this.widget=t,this.widget=t,o=this}matchesWidget(e){return this.dirty==pe&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return t?t(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}},xr=class extends it{constructor(e,t,n,i){super(e,[],t,null),this.textDOM=n,this.text=i}get size(){return this.text.length}localPosFromDOM(e,t){return e!=this.textDOM?this.posAtStart+(t?this.size:0):this.posAtStart+t}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}},Qe=class r extends it{constructor(e,t,n,i,o){super(e,[],n,i),this.mark=t,this.spec=o}static create(e,t,n,i){let o=i.nodeViews[t.type.name],s=o&&o(t,i,n);return(!s||!s.dom)&&(s=Me.renderSpec(document,t.type.spec.toDOM(t,n),null,t.attrs)),new r(e,t,s.dom,s.contentDOM||s.dom,s)}parseRule(){return this.dirty&ge||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=ge&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=pe){let n=this.parent;for(;!n.node;)n=n.parent;n.dirty<this.dirty&&(n.dirty=this.dirty),this.dirty=pe}}slice(e,t,n){let i=r.create(this.parent,this.mark,!0,n),o=this.children,s=this.size;t<s&&(o=Or(o,t,s,n)),e>0&&(o=Or(o,0,e,n));for(let l=0;l<o.length;l++)o[l].parent=i;return i.children=o,i}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}},We=class r extends it{constructor(e,t,n,i,o,s,l){super(e,[],o,s),this.node=t,this.outerDeco=n,this.innerDeco=i,this.nodeDOM=l}static create(e,t,n,i,o,s){let l=o.nodeViews[t.type.name],a,c=l&&l(t,o,()=>{if(!a)return s;if(a.parent)return a.parent.posBeforeChild(a)},n,i),f=c&&c.dom,h=c&&c.contentDOM;if(t.isText){if(!f)f=document.createTextNode(t.text);else if(!W(f))throw new RangeError("Text must be rendered as a DOM text node")}else f||({dom:f,contentDOM:h}=Me.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs));!h&&!t.isText&&f.nodeName!="BR"&&(f.hasAttribute("contenteditable")||(f.contentEditable="false"),t.type.spec.draggable&&(f.draggable=!0));let d=f;return f=Yo(f,n,t),c?a=new Cr(e,t,n,i,f,h||null,d,c):t.isText?new Cn(e,t,n,i,f,d):new r(e,t,n,i,f,h||null,d)}parseRule(e){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"),!this.contentDOM)t.getContent=()=>this.node.content;else if(!this.contentLost)t.contentElement=this.contentDOM;else{for(let n=this.children.length-1;n>=0;n--){let i=this.children[n];if(this.dom.contains(i.dom.parentNode)){t.contentElement=i.dom.parentNode;break}}if(!t.contentElement){let n=e&&e.find(i=>M(i)&&e.indexOf(i.parentNode)<0&&this.dom.contains(i));n?t.contentElement=n:t.getContent=()=>S.empty}}return t}matchesNode(e,t,n){return this.dirty==pe&&e.eq(this.node)&&Mn(t,this.outerDeco)&&n.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let n=this.node.inlineContent,i=t,o=e.composing?this.localCompositionInfo(e,t):null,s=o&&o.pos>-1?o:null,l=o&&o.pos<0,a=new Mr(this,s&&s.node,e),c=this.node.inlineContent,f=c&&this.node.isBlock;Da(this.node,this.innerDeco,(h,d,p)=>{h.spec.marks?a.syncToMarks(h.spec.marks,n,e,d):h.type.side>=0&&!p&&a.syncToMarks(d==this.node.childCount?z.none:this.node.child(d).marks,n,e,d),a.placeWidget(h,e,i)},(h,d,p,u)=>{a.syncToMarks(h.marks,n,e,u),f&&h.isAtom&&!h.isText&&a.addHackNode("IMG",a.top);let m;a.findNodeMatch(h,d,p,u)||l&&e.state.selection.from>i&&e.state.selection.to<i+h.nodeSize&&(m=a.findIndexWithChild(o.node))>-1&&a.updateNodeAt(h,d,p,m,e)||a.updateNextNode(h,d,p,e,u,i)||a.addNode(h,d,p,e,i),i+=h.nodeSize,c&&(f=h.isAtom&&!h.isText)}),a.syncToMarks([],n,e,0),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==Ye)&&(s&&this.protectLocalComposition(e,s),Uo(this.contentDOM,this.children,e),St&&Aa(this.dom))}localCompositionInfo(e,t){let{from:n,to:i}=e.state.selection;if(!(e.state.selection instanceof T)||n<t||i>t+this.node.content.size)return null;let o=e.input.compositionNode;if(!o||!this.dom.contains(o.parentNode))return null;if(this.node.inlineContent){let s=o.nodeValue,l=Ta(this.node.content,s,n-t,i-t);return l<0?null:{node:o,pos:l,text:s}}else return{node:o,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:n,text:i}){if(this.getDesc(t))return;let o=t;for(;o.parentNode!=this.contentDOM;o=o.parentNode){for(;o.previousSibling;)o.parentNode.removeChild(o.previousSibling);for(;o.nextSibling;)o.parentNode.removeChild(o.nextSibling);o.pmViewDesc&&(o.pmViewDesc=void 0)}let s=new xr(this,o,t,i);e.input.compositionNodes.push(s),this.children=Or(this.children,n,n+i.length,e,s)}update(e,t,n,i){return this.dirty==ge||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,n,i),!0)}updateInner(e,t,n,i){this.updateOuterDeco(t),this.node=e,this.innerDeco=n,this.contentDOM&&this.updateChildren(i,this.posAtStart),this.dirty=pe}updateOuterDeco(e){if(Mn(e,this.outerDeco))return;let t=!M(this.nodeDOM),n=this.dom;this.dom=Go(this.dom,this.nodeDOM,wr(this.outerDeco,this.node,t),wr(e,this.node,t)),this.dom!=n&&(n.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){M(this.nodeDOM)&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){M(this.nodeDOM)&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}};function go(r,e,t,n,i){Yo(n,e,r);let o=new We(void 0,r,e,t,n,n,n);return o.contentDOM&&o.updateChildren(i,0),o}var Cn=class r extends We{constructor(e,t,n,i,o,s){super(e,t,n,i,o,null,s)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,n,i){return this.dirty==ge||this.dirty!=pe&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=pe||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,i.trackWrites==this.nodeDOM&&(i.trackWrites=null)),this.node=e,this.dirty=pe,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,n){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,n)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,t,n){let i=this.node.cut(e,t),o=document.createTextNode(i.text);return new r(this.parent,i,this.outerDeco,this.innerDeco,o,o)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=ge)}get domAtom(){return!1}isText(e){return this.node.text==e}},wn=class extends it{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==pe&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}},Cr=class extends We{constructor(e,t,n,i,o,s,l,a){super(e,t,n,i,o,s,l),this.spec=a}update(e,t,n,i){if(this.dirty==ge)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let o=this.spec.update(e,t,n);return o&&this.updateInner(e,t,n,i),o}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,n,i)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,n,i){this.spec.setSelection?this.spec.setSelection(e,t,n.root):super.setSelection(e,t,n,i)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}};function Uo(r,e,t){let n=r.firstChild,i=!1;for(let o=0;o<e.length;o++){let s=e[o],l=s.dom;if(l.parentNode==r){for(;l!=n;)n=yo(n),i=!0;n=n.nextSibling}else i=!0,r.insertBefore(l,n);if(s instanceof Qe){let a=n?n.previousSibling:r.lastChild;Uo(s.contentDOM,s.children,t),n=a?a.nextSibling:r.firstChild}}for(;n;)n=yo(n),i=!0;i&&t.trackWrites==r&&(t.trackWrites=null)}var Jt=function(r){r&&(this.nodeName=r)};Jt.prototype=Object.create(null);var Xe=[new Jt];function wr(r,e,t){if(r.length==0)return Xe;let n=t?Xe[0]:new Jt,i=[n];for(let o=0;o<r.length;o++){let s=r[o].type.attrs;if(s){s.nodeName&&i.push(n=new Jt(s.nodeName));for(let l in s){let a=s[l];a!=null&&(t&&i.length==1&&i.push(n=new Jt(e.isInline?"span":"div")),l=="class"?n.class=(n.class?n.class+" ":"")+a:l=="style"?n.style=(n.style?n.style+";":"")+a:l!="nodeName"&&(n[l]=a))}}}return i}function Go(r,e,t,n){if(t==Xe&&n==Xe)return e;let i=e;for(let o=0;o<n.length;o++){let s=n[o],l=t[o];if(o){let a;l&&l.nodeName==s.nodeName&&i!=r&&(a=i.parentNode)&&a.nodeName.toLowerCase()==s.nodeName||(a=document.createElement(s.nodeName),a.pmIsDeco=!0,a.appendChild(i),l=Xe[0]),i=a}Ma(i,l||Xe[0],s)}return i}function Ma(r,e,t){for(let n in e)n!="class"&&n!="style"&&n!="nodeName"&&!(n in t)&&r.removeAttribute(n);for(let n in t)n!="class"&&n!="style"&&n!="nodeName"&&t[n]!=e[n]&&r.setAttribute(n,t[n]);if(e.class!=t.class){let n=e.class?e.class.split(" ").filter(Boolean):[],i=t.class?t.class.split(" ").filter(Boolean):[];for(let o=0;o<n.length;o++)i.indexOf(n[o])==-1&&r.classList.remove(n[o]);for(let o=0;o<i.length;o++)n.indexOf(i[o])==-1&&r.classList.add(i[o]);r.classList.length==0&&r.removeAttribute("class")}if(e.style!=t.style){if(e.style){let n=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,i;for(;i=n.exec(e.style);)r.style.removeProperty(i[1])}t.style&&(r.style.cssText+=t.style)}}function Yo(r,e,t){return Go(r,r,Xe,wr(e,t,!M(r)))}function Mn(r,e){if(r.length!=e.length)return!1;for(let t=0;t<r.length;t++)if(!r[t].type.eq(e[t].type))return!1;return!0}function yo(r){let e=r.nextSibling;return r.parentNode.removeChild(r),e}var Mr=class{constructor(e,t,n){this.lock=t,this.view=n,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=Oa(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let n=e;n<t;n++)this.top.children[n].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,n,i){let o=0,s=this.stack.length>>1,l=Math.min(s,e.length);for(;o<l&&(o==s-1?this.top:this.stack[o+1<<1]).matchesMark(e[o])&&e[o].type.spec.spanning!==!1;)o++;for(;o<s;)this.destroyRest(),this.top.dirty=pe,this.index=this.stack.pop(),this.top=this.stack.pop(),s--;for(;s<e.length;){this.stack.push(this.top,this.index+1);let a=-1,c=this.top.children.length;i<this.preMatch.index&&(c=Math.min(this.index+3,c));for(let f=this.index;f<c;f++){let h=this.top.children[f];if(h.matchesMark(e[s])&&!this.isLocked(h.dom)){a=f;break}}if(a<0&&this.index<this.top.children.length){let f=this.top.children[this.index];f instanceof Qe&&f.dirty!=ge&&f.mark.type==e[s].type&&f.spec.update&&!this.isLocked(f.dom)&&f.spec.update(e[s])&&(f.mark=e[s],a=this.index,this.changed=!0)}if(a>-1)a>this.index&&(this.changed=!0,this.destroyBetween(this.index,a)),this.top=this.top.children[this.index];else{let f=Qe.create(this.top,e[s],t,n);this.top.children.splice(this.index,0,f),this.top=f,this.changed=!0}this.index=0,s++}}findNodeMatch(e,t,n,i){let o=-1,s;if(i>=this.preMatch.index&&(s=this.preMatch.matches[i-this.preMatch.index]).parent==this.top&&s.matchesNode(e,t,n))o=this.top.children.indexOf(s,this.index);else for(let l=this.index,a=Math.min(this.top.children.length,l+5);l<a;l++){let c=this.top.children[l];if(c.matchesNode(e,t,n)&&!this.preMatch.matched.has(c)){o=l;break}}return o<0?!1:(this.destroyBetween(this.index,o),this.index++,!0)}updateNodeAt(e,t,n,i,o){let s=this.top.children[i];return s.dirty==ge&&s.dom==s.contentDOM&&(s.dirty=Ye),s.update(e,t,n,o)?(this.destroyBetween(this.index,i),this.index++,!0):!1}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let n=e.pmViewDesc;if(n){for(let i=this.index;i<this.top.children.length;i++)if(this.top.children[i]==n)return i}return-1}e=t}}updateNextNode(e,t,n,i,o,s){for(let l=this.index;l<this.top.children.length;l++){let a=this.top.children[l];if(a instanceof We){let c=this.preMatch.matched.get(a);if(c!=null&&c!=o)return!1;let f=a.dom,h,d=this.isLocked(f)&&!(e.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==e.text&&a.dirty!=ge&&Mn(t,a.outerDeco));if(!d&&a.update(e,t,n,i))return this.destroyBetween(this.index,l),a.dom!=f&&(this.changed=!0),this.index++,!0;if(!d&&(h=this.recreateWrapper(a,e,t,n,i,s)))return this.destroyBetween(this.index,l),this.top.children[this.index]=h,h.contentDOM&&(h.dirty=Ye,h.updateChildren(i,s+1),h.dirty=pe),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,n,i,o,s){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!Mn(n,e.outerDeco)||!i.eq(e.innerDeco))return null;let l=We.create(this.top,t,n,i,o,s);if(l.contentDOM){l.children=e.children,e.children=[];for(let a of l.children)a.parent=l}return e.destroy(),l}addNode(e,t,n,i,o){let s=We.create(this.top,e,t,n,i,o);s.contentDOM&&s.updateChildren(i,o+1),this.top.children.splice(this.index++,0,s),this.changed=!0}placeWidget(e,t,n){let i=this.index<this.top.children.length?this.top.children[this.index]:null;if(i&&i.matchesWidget(e)&&(e==i.widget||!i.widget.type.toDOM.parentNode))this.index++;else{let o=new xn(this.top,e,t,n);this.top.children.splice(this.index++,0,o),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof Qe;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof Cn)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((ne||G)&&e&&e.dom.contentEditable=="false"&&this.addHackNode("IMG",t),this.addHackNode("BR",this.top))}addHackNode(e,t){if(t==this.top&&this.index<t.children.length&&t.children[this.index].matchesHack(e))this.index++;else{let n=document.createElement(e);e=="IMG"&&(n.className="ProseMirror-separator",n.alt=""),e=="BR"&&(n.className="ProseMirror-trailingBreak");let i=new wn(this.top,[],n,null);t!=this.top?t.children.push(i):t.children.splice(this.index++,0,i),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||M(e)&&e.contains(this.lock.parentNode))}};function Oa(r,e){let t=e,n=t.children.length,i=r.childCount,o=new Map,s=[];e:for(;i>0;){let l;for(;;)if(n){let c=t.children[n-1];if(c instanceof Qe)t=c,n=c.children.length;else{l=c,n--;break}}else{if(t==e)break e;n=t.parent.children.indexOf(t),t=t.parent}let a=l.node;if(a){if(a!=r.child(i-1))break;--i,o.set(l,i),s.push(l)}}return{index:i,matched:o,matches:s.reverse()}}function Na(r,e){return r.type.side-e.type.side}function Da(r,e,t,n){let i=e.locals(r),o=0;if(i.length==0){for(let c=0;c<r.childCount;c++){let f=r.child(c);n(f,i,e.forChild(o,f),c),o+=f.nodeSize}return}let s=0,l=[],a=null;for(let c=0;;){let f,h;for(;s<i.length&&i[s].to==o;){let g=i[s++];g.widget&&(f?(h||(h=[f])).push(g):f=g)}if(f)if(h){h.sort(Na);for(let g=0;g<h.length;g++)t(h[g],c,!!a)}else t(f,c,!!a);let d,p;if(a)p=-1,d=a,a=null;else if(c<r.childCount)p=c,d=r.child(c++);else break;for(let g=0;g<l.length;g++)l[g].to<=o&&l.splice(g--,1);for(;s<i.length&&i[s].from<=o&&i[s].to>o;)l.push(i[s++]);let u=o+d.nodeSize;if(d.isText){let g=u;s<i.length&&i[s].from<g&&(g=i[s].from);for(let b=0;b<l.length;b++)l[b].to<g&&(g=l[b].to);g<u&&(a=d.cut(g-o),d=d.cut(0,g-o),u=g,p=-1)}else for(;s<i.length&&i[s].to<u;)s++;let m=d.isInline&&!d.isLeaf?l.filter(g=>!g.inline):l.slice();n(d,m,e.forChild(o,d),p),o=u}}function Aa(r){if(r.nodeName=="UL"||r.nodeName=="OL"){let e=r.style.cssText;r.style.cssText=e+"; list-style: square !important",window.getComputedStyle(r).listStyle,r.style.cssText=e}}function Ta(r,e,t,n){for(let i=0,o=0;i<r.childCount&&o<=n;){let s=r.child(i++),l=o;if(o+=s.nodeSize,!s.isText)continue;let a=s.text;for(;i<r.childCount;){let c=r.child(i++);if(o+=c.nodeSize,!c.isText)break;a+=c.text}if(o>=t){if(o>=n&&a.slice(n-e.length-l,n-l)==e)return n-e.length;let c=l<n?a.lastIndexOf(e,n-l-1):-1;if(c>=0&&c+e.length+l>=t)return l+c;if(t==n&&a.length>=n+e.length-l&&a.slice(n-l,n-l+e.length)==e)return n}}return-1}function Or(r,e,t,n,i){let o=[];for(let s=0,l=0;s<r.length;s++){let a=r[s],c=l,f=l+=a.size;c>=t||f<=e?o.push(a):(c<e&&o.push(a.slice(0,e-c,n)),i&&(o.push(i),i=void 0),f>t&&o.push(a.slice(t-c,a.size,n)))}return o}function Fr(r,e=null){let t=r.domSelectionRange(),n=r.state.doc;if(!t.focusNode)return null;let i=r.docView.nearestDesc(t.focusNode),o=i&&i.size==0,s=r.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(s<0)return null;let l=n.resolve(s),a,c;if(Rn(t)){for(a=s;i&&!i.node;)i=i.parent;if(i&&i.node.isAtom&&w.isSelectable(i.node)&&i.parent&&!(i.node.isInline&&ia(t.focusNode,t.focusOffset,i.dom))){let h=i.posBefore;c=new w(s==h?l:n.resolve(h))}else if(ue&&e=="key"&&s>r.state.selection.to&&M(t.focusNode)&&t.focusOffset==t.focusNode.childNodes.length&&i&&i.posAtStart>r.state.selection.to)for(let h=t.focusNode;;h=h.parentNode){if(getComputedStyle(h).overflow!="visible"){c=D.findFrom(n.resolve(i.posAtStart),1);break}if(h==i.dom||h.nextSibling||!h.parentNode||!M(h.parentNode))break}}else{if(t instanceof r.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let h=s,d=s;for(let p=0;p<t.rangeCount;p++){let u=t.getRangeAt(p);h=Math.min(h,r.docView.posFromDOM(u.startContainer,u.startOffset,1)),d=Math.max(d,r.docView.posFromDOM(u.endContainer,u.endOffset,-1))}if(h<0)return null;[a,s]=d==r.state.selection.anchor?[d,h]:[h,d],l=n.resolve(s)}else a=r.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(a<0)return null}let f=n.resolve(a);if(!c){let h=e=="pointer"||r.state.selection.head<l.pos&&!o?1:-1;c=Vr(r,f,l,h)}return c}function Xo(r){return r.editable?r.hasFocus():Zo(r)&&document.activeElement&&document.activeElement.contains(r.dom)}function Ee(r,e=!1){let t=r.state.selection;if(Qo(r,t),!Xo(r))return;let n=r.input.mouseDown;if(!e&&G&&n){let i=r.domSelectionRange(),o=r.domObserver.currentSelection;if(i.anchorNode&&o.anchorNode&&nt(i.anchorNode,i.anchorOffset,o.anchorNode,o.anchorOffset)&&n.delaySelUpdate()){r.domObserver.setCurSelection();return}}if(r.domObserver.disconnectSelection(),r.cursorWrapper)Ra(r);else{let{anchor:i,head:o}=t,s,l;bo&&!(t instanceof T)&&(t.$from.parent.inlineContent||(s=So(r,t.from)),!t.empty&&!t.$from.parent.inlineContent&&(l=So(r,t.to))),r.docView.setSelection(i,o,r,e),bo&&(s&&ko(s),l&&ko(l)),t.visible?r.dom.classList.remove("ProseMirror-hideselection"):(r.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&Ea(r))}r.domObserver.setCurSelection(),r.domObserver.connectSelection()}var bo=ne||G&&$o<63;function So(r,e){let{node:t,offset:n}=r.docView.domFromPos(e,0),i=n<t.childNodes.length?t.childNodes[n]:null,o=n?t.childNodes[n-1]:null;if(ne&&i&&i.contentEditable=="false")return dr(i);if((!i||i.contentEditable=="false")&&(!o||o.contentEditable=="false")){if(i)return dr(i);if(o)return dr(o)}}function dr(r){return r.contentEditable="true",ne&&r.draggable&&(r.draggable=!1,r.wasDraggable=!0),r}function ko(r){r.contentEditable="false",r.wasDraggable&&(r.draggable=!0,r.wasDraggable=null)}function Ea(r){let e=r.dom.ownerDocument;e.removeEventListener("selectionchange",r.input.hideSelectionGuard);let t=r.domSelectionRange(),n=t.anchorNode,i=t.anchorOffset;e.addEventListener("selectionchange",r.input.hideSelectionGuard=()=>{(t.anchorNode!=n||t.anchorOffset!=i)&&(e.removeEventListener("selectionchange",r.input.hideSelectionGuard),setTimeout(()=>{(!Xo(r)||r.state.selection.visible)&&r.dom.classList.remove("ProseMirror-hideselection")},20))})}function Ra(r){let e=r.domSelection();if(!e)return;let t=r.cursorWrapper.dom,n=t.nodeName=="IMG";n?e.collapse(t.parentNode,U(t)+1):e.collapse(t,0),!n&&!r.state.selection.visible&&le&&$e<=11&&(t.disabled=!0,t.disabled=!1)}function Qo(r,e){if(e instanceof w){let t=r.docView.descAt(e.from);t!=r.lastSelectedViewDesc&&(xo(r),t&&t.selectNode(),r.lastSelectedViewDesc=t)}else xo(r)}function xo(r){r.lastSelectedViewDesc&&(r.lastSelectedViewDesc.parent&&r.lastSelectedViewDesc.deselectNode(),r.lastSelectedViewDesc=void 0)}function Vr(r,e,t,n){return r.someProp("createSelectionBetween",i=>i(r,e,t))||T.between(e,t,n)}function Co(r){return r.editable&&!r.hasFocus()?!1:Zo(r)}function Zo(r){let e=r.domSelectionRange();if(!e.anchorNode)return!1;try{return rt(r.dom,e.anchorNode)&&(r.editable||rt(r.dom,e.focusNode))}catch{return!1}}function Ia(r){let e=r.docView.domFromPos(r.state.selection.anchor,0),t=r.domSelectionRange();return nt(e.node,e.offset,t.anchorNode,t.anchorOffset)}function Nr(r,e){let{$anchor:t,$head:n}=r.selection,i=e>0?t.max(n):t.min(n),o=i.parent.inlineContent?i.depth?r.doc.resolve(e>0?i.after():i.before()):null:i;return o&&D.findFrom(o,e)}function Ve(r,e){return r.dispatch(r.state.tr.setSelection(e).scrollIntoView()),!0}function wo(r,e,t){let n=r.state.selection;if(n instanceof T)if(t.indexOf("s")>-1){let{$head:i}=n,o=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter;if(!o||o.isText||!o.isLeaf)return!1;let s=r.state.doc.resolve(i.pos+o.nodeSize*(e<0?-1:1));return Ve(r,new T(n.$anchor,s))}else if(n.empty){if(r.endOfTextblock(e>0?"forward":"backward")){let i=Nr(r.state,e);return i&&i instanceof w?Ve(r,i):!1}else if(!de||t.indexOf("m")<0){let i=n.$head,o=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter,s;if(!o||o.isText)return!1;let l=e<0?i.pos-o.nodeSize:i.pos;return o.isAtom||(s=r.docView.descAt(l))&&!s.contentDOM?w.isSelectable(o)?Ve(r,new w(e<0?r.state.doc.resolve(i.pos-o.nodeSize):i)):Ve(r,new T(r.state.doc.resolve(e<0?l:l+o.nodeSize))):!1}}else return!1;else{if(n instanceof w&&n.node.isInline)return Ve(r,new T(e>0?n.$to:n.$from));{let i=Nr(r.state,e);return i?Ve(r,i):!1}}}function qt(r,e){let t=r.pmViewDesc;return t?t.size==0&&(e<0||r.nextSibling||r.nodeName!="BR"):M(r)&&r.contentEditable=="false"}function gt(r,e){return e<0?va(r):za(r)}function va(r){let e=r.domSelectionRange(),t=e.focusNode,n=e.focusOffset;if(!t)return;let i,o,s=!1;for(ue&&M(t)&&n<te(t)&&qt(t.childNodes[n],-1)&&(s=!0);;)if(n>0){if(!M(t))break;let l=t.childNodes[n-1];if(qt(l,-1))i=t,o=--n;else if(W(l))t=l,n=t.nodeValue.length;else break}else{if(es(t))break;{let l=t.previousSibling;for(;l&&qt(l,-1);)i=t.parentNode,o=U(l),l=l.previousSibling;if(l)t=l,n=te(t);else{if(t=t.parentNode,t==r.dom)break;n=0}}}s?Dr(r,t,n):i&&Dr(r,i,o)}function za(r){let e=r.domSelectionRange(),t=e.focusNode,n=e.focusOffset;if(!t)return;let i=te(t),o,s;for(;;)if(n<i){if(!M(t))break;let l=t.childNodes[n];if(qt(l,1))o=t,s=++n;else break}else{if(es(t))break;{let l=t.nextSibling;for(;l&&qt(l,1);)o=l.parentNode,s=U(l)+1,l=l.nextSibling;if(l)t=l,n=0,i=te(t);else{if(t=t.parentNode,t==r.dom)break;n=i=0}}}o&&Dr(r,o,s)}function es(r){let e=r.pmViewDesc;return e&&e.node&&e.node.isBlock}function Pa(r,e){for(;r&&e==r.childNodes.length&&!Gt(r);)e=U(r)+1,r=r.parentNode;for(;r&&e<r.childNodes.length;){let t=r.childNodes[e];if(W(t))return t;if(M(t)&&t.contentEditable=="false")break;r=t,e=0}}function Ba(r,e){for(;r&&!e&&!Gt(r);)e=U(r),r=r.parentNode;for(;r&&e;){let t=r.childNodes[e-1];if(W(t))return t;if(M(t)&&t.contentEditable=="false")break;r=t,e=r.childNodes.length}}function Dr(r,e,t){if(!W(e)){let s,l;(l=Pa(e,t))?(e=l,t=0):(s=Ba(e,t))&&(e=s,t=s.nodeValue.length)}let n=r.domSelection(),i=r.domSelectionRange();if(!n)return;Rn(i)?n.collapse(e,t):n.extend&&(n.collapse(i.anchorNode,i.anchorOffset),n.extend(e,t)),r.domObserver.setCurSelection();let{state:o}=r;setTimeout(()=>{r.state==o&&Ee(r)},50)}function Mo(r,e){let t=r.state.doc.resolve(e);if(!(G||Wo)&&t.parent.inlineContent){let o=r.coordsAtPos(e);if(e>t.start()){let s=r.coordsAtPos(e-1),l=(s.top+s.bottom)/2;if(l>o.top&&l<o.bottom&&Math.abs(s.left-o.left)>1)return s.left<o.left?"ltr":"rtl"}if(e<t.end()){let s=r.coordsAtPos(e+1),l=(s.top+s.bottom)/2;if(l>o.top&&l<o.bottom&&Math.abs(s.left-o.left)>1)return s.left>o.left?"ltr":"rtl"}}let n=r.dom;for(let o=t.depth;o>0;o--)if(t.node(o).isBlock){n=r.nodeDOM(t.before(o))||n;break}return getComputedStyle(n).direction=="rtl"?"rtl":"ltr"}function Oo(r,e,t){let n=r.state.selection;if(n instanceof T&&!n.empty||t.indexOf("s")>-1||de&&t.indexOf("m")>-1)return!1;let{$from:i,$to:o}=n;if(!i.parent.inlineContent||r.endOfTextblock(e<0?"up":"down")){let s=Nr(r.state,e);if(s&&s instanceof w)return Ve(r,s)}if(!i.parent.inlineContent){let s=e<0?i:o,l=n instanceof he?D.near(s,e):D.findFrom(s,e);return l?Ve(r,l):!1}return!1}function No(r,e){if(!(r.state.selection instanceof T))return!0;let{$head:t,$anchor:n,empty:i}=r.state.selection;if(!t.sameParent(n))return!0;if(!i)return!1;if(r.endOfTextblock(e>0?"forward":"backward"))return!0;let o=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(o&&!o.isText){let s=r.state.tr;return e<0?s.delete(t.pos-o.nodeSize,t.pos):s.delete(t.pos,t.pos+o.nodeSize),r.dispatch(s),!0}return!1}function Do(r,e,t){r.domObserver.stop(),e.contentEditable=t,r.domObserver.start()}function Fa(r){if(!ne||r.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:t}=r.domSelectionRange();if(e&&M(e)&&t==0&&e.firstChild&&M(e.firstChild)&&e.firstChild.contentEditable=="false"){let n=e.firstChild;Do(r,n,"true"),setTimeout(()=>Do(r,n,"false"),20)}return!1}function Va(r){let e="";return r.ctrlKey&&(e+="c"),r.metaKey&&(e+="m"),r.altKey&&(e+="a"),r.shiftKey&&(e+="s"),e}function La(r,e){let t=e.keyCode,n=Va(e);if(t==8||de&&t==72&&n=="c")return No(r,-1)||gt(r,-1);if(t==46&&!e.shiftKey||de&&t==68&&n=="c")return No(r,1)||gt(r,1);if(t==13||t==27)return!0;if(t==37||de&&t==66&&n=="c"){let i=t==37?Mo(r,r.state.selection.from)=="ltr"?-1:1:-1;return wo(r,i,n)||gt(r,i)}else if(t==39||de&&t==70&&n=="c"){let i=t==39?Mo(r,r.state.selection.from)=="ltr"?1:-1:1;return wo(r,i,n)||gt(r,i)}else{if(t==38||de&&t==80&&n=="c")return Oo(r,-1,n)||gt(r,-1);if(t==40||de&&t==78&&n=="c")return Fa(r)||Oo(r,1,n)||gt(r,1);if(n==(de?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function Lr(r,e){r.someProp("transformCopied",p=>{e=p(e,r)});let t=[],{content:n,openStart:i,openEnd:o}=e;for(;i>1&&o>1&&n.childCount==1&&n.firstChild.childCount==1;){i--,o--;let p=n.firstChild;t.push(p.type.name,p.attrs!=p.type.defaultAttrs?p.attrs:null),n=p.content}let s=r.someProp("clipboardSerializer")||Me.fromSchema(r.state.schema),l=ls(),a=l.createElement("div");a.appendChild(s.serializeFragment(n,{document:l}));let c=a.firstChild,f,h=0;for(;c&&M(c)&&(f=ss[c.nodeName.toLowerCase()]);){for(let p=f.length-1;p>=0;p--){let u=l.createElement(f[p]);for(;a.firstChild;)u.appendChild(a.firstChild);a.appendChild(u),h++}c=a.firstChild}c&&M(c)&&c.setAttribute("data-pm-slice",`${i} ${o}${h?` -${h}`:""} ${JSON.stringify(t)}`);let d=r.someProp("clipboardTextSerializer",p=>p(e,r))||e.content.textBetween(0,e.content.size,`
|
|
7
|
+
|
|
8
|
+
`);return{dom:a,text:d,slice:e}}function ts(r,e,t,n,i){let o=i.parent.type.spec.code,s,l;if(!t&&!e)return null;let a=!!e&&(n||o||!t);if(a){if(r.someProp("transformPastedText",d=>{e=d(e,o||n,r)}),o)return l=new k(S.from(r.state.schema.text(e.replace(/\r\n?/g,`
|
|
9
|
+
`))),0,0),r.someProp("transformPasted",d=>{l=d(l,r,!0)}),l;let h=r.someProp("clipboardTextParser",d=>d(e,i,n,r));if(h)l=h;else{let d=i.marks(),{schema:p}=r.state,u=Me.fromSchema(p);s=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(m=>{let g=s.appendChild(document.createElement("p"));m&&g.appendChild(u.serializeNode(p.text(m,d)))})}}else r.someProp("transformPastedHTML",h=>{t=h(t,r)}),s=qa(t),In&&Ha(s);let c=s&&s.querySelector("[data-pm-slice]"),f=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(f&&f[3])for(let h=+f[3];h>0;h--){let d=s.firstChild;for(;d&&!M(d);)d=d.nextSibling;if(!d)break;s=d}if(l||(l=(r.someProp("clipboardParser")||r.someProp("domParser")||Ue.fromSchema(r.state.schema)).parseSlice(s,{preserveWhitespace:!!(a||f),context:i,ruleFromNode(d){return d.nodeName=="BR"&&!d.nextSibling&&d.parentNode&&!$a.test(d.parentNode.nodeName)?{ignore:!0}:null}})),f)l=Ka(Ao(l,+f[1],+f[2]),f[4]);else if(l=k.maxOpen(Wa(l.content,i),!0),l.openStart||l.openEnd){let h=0,d=0;for(let p=l.content.firstChild;h<l.openStart&&!p.type.spec.isolating;h++,p=p.firstChild);for(let p=l.content.lastChild;d<l.openEnd&&!p.type.spec.isolating;d++,p=p.lastChild);l=Ao(l,h,d)}return r.someProp("transformPasted",h=>{l=h(l,r,a)}),l}var $a=/^(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 Wa(r,e){if(r.childCount<2)return r;for(let t=e.depth;t>=0;t--){let i=e.node(t).contentMatchAt(e.index(t)),o,s=[];if(r.forEach(l=>{if(!s)return;let a=i.findWrapping(l.type),c;if(!a)return s=null;if(c=s.length&&o.length&&rs(a,o,l,s[s.length-1],0))s[s.length-1]=c;else{s.length&&(s[s.length-1]=is(s[s.length-1],o.length));let f=ns(l,a);s.push(f),i=i.matchType(f.type),o=a}}),s)return S.from(s)}return r}function ns(r,e,t=0){for(let n=e.length-1;n>=t;n--)r=e[n].create(null,S.from(r));return r}function rs(r,e,t,n,i){if(i<r.length&&i<e.length&&r[i]==e[i]){let o=rs(r,e,t,n.lastChild,i+1);if(o)return n.copy(n.content.replaceChild(n.childCount-1,o));if(n.contentMatchAt(n.childCount).matchType(i==r.length-1?t.type:r[i+1]))return n.copy(n.content.append(S.from(ns(t,r,i+1))))}}function is(r,e){if(e==0)return r;let t=r.content.replaceChild(r.childCount-1,is(r.lastChild,e-1)),n=r.contentMatchAt(r.childCount).fillBefore(S.empty,!0);return r.copy(t.append(n))}function Ar(r,e,t,n,i,o){let s=e<0?r.firstChild:r.lastChild,l=s.content;return r.childCount>1&&(o=0),i<n-1&&(l=Ar(l,e,t,n,i+1,o)),i>=t&&(l=e<0?s.contentMatchAt(0).fillBefore(l,o<=i).append(l):l.append(s.contentMatchAt(s.childCount).fillBefore(S.empty,!0))),r.replaceChild(e<0?0:r.childCount-1,s.copy(l))}function Ao(r,e,t){return e<r.openStart&&(r=new k(Ar(r.content,-1,e,r.openStart,0,r.openEnd),e,r.openEnd)),t<r.openEnd&&(r=new k(Ar(r.content,1,t,r.openEnd,0,0),r.openStart,t)),r}var ss={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};function ls(){return document.implementation.createHTMLDocument("title")}var Wt=null;function Ja(r){let e=window.trustedTypes;if(!e)return r;if(!Wt){if(Wt=e.defaultPolicy)try{return Wt.createHTML(r)}catch{}Wt=e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})}return Wt.createHTML(r)}function qa(r){let e=/^(\s*<meta [^>]*>)*/.exec(r);e&&(r=r.slice(e[0].length));let t=ls(),n=t.body,i=/<([a-z][^>\s]+)/i.exec(r),o;if((o=i&&ss[i[1].toLowerCase()])&&(r=o.map(s=>"<"+s+">").join("")+r+o.map(s=>"</"+s+">").reverse().join("")),n.innerHTML=Ja(r),o)for(let s=0;s<o.length;s++)n=n.querySelector(o[s])||n;for(let s=0;s<t.styleSheets.length;s++){let l=t.styleSheets[s];for(let a=0;a<l.rules.length;a++){let c=l.rules[a];if(c instanceof CSSStyleRule){let f=n.querySelectorAll(c.selectorText);for(let h=0;h<f.length;h++)f[h].style.cssText+=c.style.cssText}}}return n}function Ha(r){let e=r.querySelectorAll(G?"span:not([class]):not([style])":"span.Apple-converted-space");for(let t=0;t<e.length;t++){let n=e[t];n.childNodes.length==1&&n.textContent=="\xA0"&&n.parentNode&&n.parentNode.replaceChild(r.ownerDocument.createTextNode(" "),n)}}function Ka(r,e){if(!r.size)return r;let t=r.content.firstChild.type.schema,n;try{n=JSON.parse(e)}catch{return r}let{content:i,openStart:o,openEnd:s}=r;for(let l=n.length-2;l>=0;l-=2){let a=t.nodes[n[l]];if(!a||a.hasRequiredAttrs())break;try{i=S.from(a.create(n[l+1],i))}catch{break}o++,s++}return new k(i,o,s)}var ie={},oe={},_a={touchstart:!0,touchmove:!0},Tr=class{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastKeyDispatched=!1,this.lastClick={time:0,x:0,y:0,type:"",button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.badSafariComposition=!1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}};function ja(r){for(let e in ie){let t=ie[e];r.dom.addEventListener(e,r.input.eventHandlers[e]=n=>{Ga(r,n)&&!$r(r,n)&&(r.editable||!(n.type in oe))&&t(r,n)},_a[e]?{passive:!0}:void 0)}ne&&r.dom.addEventListener("input",()=>null),Er(r)}function Te(r,e){r.input.lastSelectionOrigin=e,r.input.lastSelectionTime=Date.now()}function Ua(r){r.input.mouseDown&&r.input.mouseDown.done(),r.domObserver.stop();for(let e in r.input.eventHandlers)r.dom.removeEventListener(e,r.input.eventHandlers[e]);clearTimeout(r.input.composingTimeout),clearTimeout(r.input.lastIOSEnterFallbackTimeout)}function Er(r){r.someProp("handleDOMEvents",e=>{for(let t in e)r.input.eventHandlers[t]||r.dom.addEventListener(t,r.input.eventHandlers[t]=n=>$r(r,n))})}function $r(r,e){return r.someProp("handleDOMEvents",t=>{let n=t[e.type];return n?n(r,e)||e.defaultPrevented:!1})}function Ga(r,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target;t!=r.dom;t=t.parentNode)if(!t||t.nodeType==11||t.pmViewDesc&&t.pmViewDesc.stopEvent(e))return!1;return!0}function Ya(r,e){!$r(r,e)&&ie[e.type]&&(r.editable||!(e.type in oe))&&ie[e.type](r,e)}function Le(r,e){let{input:t}=r;return t.lastKeyDispatched||r.composing?!1:(t.lastKeyDispatched=!0,typeof e=="string"&&(e=oa(e=="Backspace"?8:13,e)),r.someProp("handleKeyDown",n=>n(r,e)))}oe.keydown=(r,e)=>{let t=e;if(r.input.shiftKey=t.keyCode==16||t.shiftKey,!fs(r)&&(r.input.lastKeyCode=t.keyCode,r.input.lastKeyCodeTime=Date.now(),r.input.lastKeyDispatched=!1,!(Ae&&G&&t.keyCode==13)))if(t.keyCode!=229&&r.domObserver.forceFlush(),St&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let n=Date.now();r.input.lastIOSEnter=n,r.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{r.input.lastIOSEnter==n&&(Le(r,"Enter"),r.input.lastIOSEnter=0)},200)}else Le(r,t)||La(r,t)?t.preventDefault():Te(r,"key")};oe.keyup=(r,e)=>{e.keyCode==16&&(r.input.shiftKey=!1)};oe.keypress=(r,e)=>{let t=e;if(fs(r)||!t.charCode||t.ctrlKey&&!t.altKey||de&&t.metaKey)return;if(r.someProp("handleKeyPress",i=>i(r,t))){t.preventDefault();return}let n=r.state.selection;if(!(n instanceof T)||!n.$from.sameParent(n.$to)){let i=String.fromCharCode(t.charCode),o=()=>r.state.tr.insertText(i).scrollIntoView();!/[\r\n]/.test(i)&&!r.someProp("handleTextInput",s=>s(r,n.$from.pos,n.$to.pos,i,o))&&r.dispatch(o()),t.preventDefault()}};function Yt(r){return{left:r.clientX,top:r.clientY}}function Xa(r,e){let t=e.x-r.clientX,n=e.y-r.clientY;return t*t+n*n<100}function Wr(r,e,t,n,i){if(n==-1)return!1;let o=r.state.doc.resolve(n);for(let s=o.depth+1;s>0;s--)if(r.someProp(e,l=>s>o.depth?l(r,t,o.nodeAfter,o.before(s),i,!0):l(r,t,o.node(s),o.before(s),i,!1)))return!0;return!1}function Xt(r,e,t){if(r.focused||r.focus(),r.state.selection.eq(e))return;let n=r.state.tr.setSelection(e);n.setMeta("pointer",!0),r.dispatch(n)}function Qa(r,e){if(e==-1)return!1;let t=r.state.doc.resolve(e),n=t.nodeAfter;return n&&n.isAtom&&w.isSelectable(n)?(Xt(r,new w(t)),!0):!1}function Za(r,e){if(e==-1)return!1;let t=r.state.selection,n,i;t instanceof w&&(n=t.node);let o=r.state.doc.resolve(e);for(let s=o.depth+1;s>0;s--){let l=s>o.depth?o.nodeAfter:o.node(s);if(w.isSelectable(l)){n&&t.$from.depth>0&&s>=t.$from.depth&&o.before(t.$from.depth+1)==t.$from.pos?i=o.before(t.$from.depth):i=o.before(s);break}}return i!=null?(Xt(r,w.create(r.state.doc,i)),!0):!1}function ec(r,e,t,n,i){return Wr(r,"handleClickOn",e,t,n)||r.someProp("handleClick",o=>o(r,e,n))||(i?Za(r,t):Qa(r,t))}function tc(r,e,t,n){return Wr(r,"handleDoubleClickOn",e,t,n)||r.someProp("handleDoubleClick",i=>i(r,e,n))}function nc(r,e,t,n){return Wr(r,"handleTripleClickOn",e,t,n)||r.someProp("handleTripleClick",i=>i(r,e,n))||rc(r,t,n)}function rc(r,e,t){if(t.button!=0)return!1;let n=as(r,e,!0),i=r.state.doc;return n?(Xt(r,n),n instanceof T&&i.eq(r.state.doc)&&(r.input.mouseDown=new Ir(r,n)),!0):!1}function as(r,e,t){let n=r.state.doc;if(e==-1)return n.inlineContent?T.create(n,0,n.content.size):null;let i=n.resolve(e);for(let o=i.depth+1;o>0;o--){let s=o>i.depth?i.nodeAfter:i.node(o),l=i.before(o);if(s.inlineContent)return T.create(n,l+1,l+1+s.content.size);if(t&&w.isSelectable(s))return w.create(n,l)}return null}function Jr(r){return Nn(r)}var cs=de?"metaKey":"ctrlKey";ie.mousedown=(r,e)=>{let t=e;r.input.shiftKey=t.shiftKey;let n=Jr(r),i=Date.now(),o="singleClick";i-r.input.lastClick.time<500&&Xa(t,r.input.lastClick)&&!t[cs]&&r.input.lastClick.button==t.button&&(r.input.lastClick.type=="singleClick"?o="doubleClick":r.input.lastClick.type=="doubleClick"&&(o="tripleClick")),r.input.lastClick={time:i,x:t.clientX,y:t.clientY,type:o,button:t.button},r.input.mouseDown&&r.input.mouseDown.done();let s=r.posAtCoords(Yt(t));s&&(o=="singleClick"?r.input.mouseDown=new Rr(r,s,t,!!n):(o=="doubleClick"?tc:nc)(r,s.pos,s.inside,t)?t.preventDefault():Te(r,"pointer"))};var On=class{constructor(e){this.view=e,this.mightDrag=null,e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this))}up(e){this.done()}move(e){e.buttons==0&&this.done()}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.view.input.mouseDown==this&&(this.view.input.mouseDown=null)}delaySelUpdate(){return!1}},Rr=class extends On{constructor(e,t,n,i){super(e),this.pos=t,this.event=n,this.flushed=i,this.delayedSelectionSync=!1,this.startDoc=e.state.doc,this.selectNode=!!n[cs],this.allowDefault=n.shiftKey;let o,s;if(t.inside>-1)o=e.state.doc.nodeAt(t.inside),s=t.inside;else{let f=e.state.doc.resolve(t.pos);o=f.parent,s=f.depth?f.before():0}let l=i?null:n.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a&&M(a.nodeDOM)?a.nodeDOM:null;let{selection:c}=e.state;n.button==0&&(o.type.spec.draggable&&o.type.spec.selectable!==!1||c instanceof w&&c.from<=s&&c.to>s)&&(this.mightDrag={node:o,pos:s,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&ue&&!this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),Te(e,"pointer")}done(){super.done(),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>{this.view.isDestroyed||Ee(this.view)})}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(Yt(e))),this.updateAllowDefault(e),this.allowDefault||!t?Te(this.view,"pointer"):ec(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||ne&&this.mightDrag&&!this.mightDrag.node.isAtom||G&&!this.view.state.selection.visible&&Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2)?(Xt(this.view,D.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):Te(this.view,"pointer")}move(e){this.updateAllowDefault(e),Te(this.view,"pointer"),super.move(e)}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}delaySelUpdate(){return this.allowDefault?(this.delayedSelectionSync=!0,!0):!1}},Ir=class extends On{constructor(e,t){super(e),this.startSelection=t,this.startDoc=e.state.doc}move(e){if(e.buttons==0||this.view.isDestroyed||!this.view.state.doc.eq(this.startDoc)){this.done();return}e.preventDefault(),Te(this.view,"pointer");let t=this.view.posAtCoords(Yt(e)),n=t&&as(this.view,t.inside,!1);if(!n)return;let{doc:i}=this.view.state,o=this.startSelection,[s,l]=n.from<o.from?[o.to,n.from]:[o.from,n.to];Xt(this.view,T.create(i,s,l))}};ie.touchstart=r=>{r.input.lastTouch=Date.now(),Jr(r),Te(r,"pointer")};ie.touchmove=r=>{r.input.lastTouch=Date.now(),Te(r,"pointer")};ie.contextmenu=r=>Jr(r);function fs(r,e){return r.composing?!0:ne&&Math.abs(Date.now()-r.input.compositionEndedAt)<500?(r.input.compositionEndedAt=-2e8,!0):!1}var ic=Ae?5e3:-1;oe.compositionstart=oe.compositionupdate=r=>{if(!r.composing){r.domObserver.flush();let{state:e}=r,t=e.selection.$to;if(e.selection instanceof T&&e.selection.empty&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(n=>n.type.spec.inclusive===!1)||G&&Wo&&oc(r)))r.markCursor=r.state.storedMarks||t.marks(),Nn(r,!0),r.markCursor=null;else if(Nn(r,!e.selection.empty),ue&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let n=r.domSelectionRange();for(let i=n.focusNode,o=n.focusOffset;i&&M(i)&&o!=0;){let s=o<0?i.lastChild:i.childNodes[o-1];if(!s)break;if(W(s)){let l=r.domSelection();l&&l.collapse(s,s.nodeValue.length);break}else i=s,o=-1}}r.input.composing=!0}hs(r,ic)};function oc(r){let{focusNode:e,focusOffset:t}=r.domSelectionRange();if(!e||!M(e)||t>=e.childNodes.length)return!1;let n=e.childNodes[t];return M(n)&&n.contentEditable=="false"}oe.compositionend=(r,e)=>{r.composing&&(r.input.composing=!1,r.input.compositionEndedAt=Date.now(),r.input.compositionPendingChanges=r.domObserver.pendingRecords().length?r.input.compositionID:0,r.input.compositionNode=null,r.input.badSafariComposition?r.domObserver.forceFlush():r.input.compositionPendingChanges&&Promise.resolve().then(()=>r.domObserver.flush()),r.input.compositionID++,hs(r,20))};function hs(r,e){clearTimeout(r.input.composingTimeout),e>-1&&(r.input.composingTimeout=setTimeout(()=>Nn(r),e))}function us(r){for(r.composing&&(r.input.composing=!1,r.input.compositionEndedAt=Date.now());r.input.compositionNodes.length>0;)r.input.compositionNodes.pop().markParentsDirty()}function sc(r){let e=r.domSelectionRange();if(!e.focusNode)return null;let t=na(e.focusNode,e.focusOffset),n=ra(e.focusNode,e.focusOffset);if(t&&n&&t!=n){let i=n.pmViewDesc,o=r.domObserver.lastChangedTextNode;if(t==o||n==o)return o;if(!i||!i.isText(n.nodeValue))return n;if(r.input.compositionNode==n){let s=t.pmViewDesc;if(!(!s||!s.isText(t.nodeValue)))return n}}return t||n}function Nn(r,e=!1){if(!(Ae&&r.domObserver.flushingSoon>=0)){if(r.domObserver.forceFlush(),us(r),e||r.docView&&r.docView.dirty){let t=Fr(r),n=r.state.selection;return t&&!t.eq(n)?r.dispatch(r.state.tr.setSelection(t)):(r.markCursor||e)&&!n.$from.node(n.$from.sharedDepth(n.to)).inlineContent?r.dispatch(r.state.tr.deleteSelection()):r.updateState(r.state),!0}return!1}}function lc(r,e){if(!r.dom.parentNode)return;let t=r.dom.parentNode.appendChild(document.createElement("div"));t.appendChild(e),t.style.cssText="position: fixed; left: -10000px; top: 10px";let n=getSelection(),i=document.createRange();i.selectNodeContents(e),r.dom.blur(),n.removeAllRanges(),n.addRange(i),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),r.focus()},50)}var Ht=le&&$e<15||St&&aa<604;ie.copy=oe.cut=(r,e)=>{let t=e,n=r.state.selection,i=t.type=="cut";if(n.empty)return;let o=Ht?null:t.clipboardData,s=n.content(),{dom:l,text:a}=Lr(r,s);o?(t.preventDefault(),o.clearData(),o.setData("text/html",l.innerHTML),o.setData("text/plain",a)):lc(r,l),i&&r.dispatch(r.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function ac(r){return r.openStart==0&&r.openEnd==0&&r.content.childCount==1?r.content.firstChild:null}function cc(r,e){if(!r.dom.parentNode)return;let t=r.input.shiftKey||r.state.selection.$from.parent.type.spec.code,n=r.dom.parentNode.appendChild(document.createElement(t?"textarea":"div"));t||(n.contentEditable="true"),n.style.cssText="position: fixed; left: -10000px; top: 10px",n.focus();let i=r.input.shiftKey&&r.input.lastKeyCode!=45;setTimeout(()=>{r.focus(),n.parentNode&&n.parentNode.removeChild(n),t?Kt(r,n.value,null,i,e):Kt(r,n.textContent,n.innerHTML,i,e)},50)}function Kt(r,e,t,n,i){let o=ts(r,e,t,n,r.state.selection.$from);if(r.someProp("handlePaste",a=>a(r,i,o||k.empty)))return!0;if(!o)return!1;let s=ac(o),l=s?r.state.tr.replaceSelectionWith(s,n):r.state.tr.replaceSelection(o);return r.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function ds(r){let e=r.getData("text/plain")||r.getData("Text");if(e)return e;let t=r.getData("text/uri-list");return t?t.replace(/\r?\n/g," "):""}oe.paste=(r,e)=>{let t=e;if(r.composing&&!Ae)return;let n=Ht?null:t.clipboardData,i=r.input.shiftKey&&r.input.lastKeyCode!=45;n&&Kt(r,ds(n),n.getData("text/html"),i,t)?t.preventDefault():cc(r,t)};var Dn=class{constructor(e,t,n){this.slice=e,this.move=t,this.node=n}},fc=de?"altKey":"ctrlKey";function ps(r,e){let t;return r.someProp("dragCopies",n=>{t=t||n(e)}),t!=null?!t:!e[fc]}ie.dragstart=(r,e)=>{let t=e,n=r.input.mouseDown;if(n&&n.done(),!t.dataTransfer)return;let i=r.state.selection,o=i.empty?null:r.posAtCoords(Yt(t)),s;if(!(o&&o.pos>=i.from&&o.pos<=(i instanceof w?i.to-1:i.to))){if(n&&n.mightDrag)s=w.create(r.state.doc,n.mightDrag.pos);else if(t.target&&M(t.target)){let h=r.docView.nearestDesc(t.target,!0);h&&h.node.type.spec.draggable&&h!=r.docView&&(s=w.create(r.state.doc,h.posBefore))}}let l=(s||r.state.selection).content(),{dom:a,text:c,slice:f}=Lr(r,l);(!t.dataTransfer.files.length||!G||$o>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(Ht?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",Ht||t.dataTransfer.setData("text/plain",c),r.dragging=new Dn(f,ps(r,t),s)};ie.dragend=r=>{let e=r.dragging;window.setTimeout(()=>{r.dragging==e&&(r.dragging=null)},50)};oe.dragover=oe.dragenter=(r,e)=>e.preventDefault();oe.drop=(r,e)=>{try{hc(r,e,r.dragging)}finally{r.dragging=null}};function hc(r,e,t){if(!e.dataTransfer)return;let n=r.posAtCoords(Yt(e));if(!n)return;let i=r.state.doc.resolve(n.pos),o=t&&t.slice;o?r.someProp("transformPasted",p=>{o=p(o,r,!1)}):o=ts(r,ds(e.dataTransfer),Ht?null:e.dataTransfer.getData("text/html"),!1,i);let s=!!(t&&ps(r,e));if(r.someProp("handleDrop",p=>p(r,e,o||k.empty,s))){e.preventDefault();return}if(!o)return;e.preventDefault();let l=o?gn(r.state.doc,i.pos,o):i.pos;l==null&&(l=i.pos);let a=r.state.tr;if(s){let{node:p}=t;p?p.replace(a):a.deleteSelection()}let c=a.mapping.map(l),f=o.openStart==0&&o.openEnd==0&&o.content.childCount==1,h=a.doc;if(f?a.replaceRangeWith(c,c,o.content.firstChild):a.replaceRange(c,c,o),a.doc.eq(h))return;let d=a.doc.resolve(c);if(f&&w.isSelectable(o.content.firstChild)&&d.nodeAfter&&d.nodeAfter.sameMarkup(o.content.firstChild))a.setSelection(new w(d));else{let p=a.mapping.map(l);a.mapping.maps[a.mapping.maps.length-1].forEach((u,m,g,b)=>p=b),a.setSelection(Vr(r,d,a.doc.resolve(p)))}r.focus(),r.dispatch(a.setMeta("uiEvent","drop"))}ie.focus=r=>{if(r.input.lastFocus=Date.now(),!r.focused){r.domObserver.stop(),r.dom.classList.add("ProseMirror-focused"),r.domObserver.start(),r.focused=!0;let e=r.domSelectionRange();if(!r.domObserver.currentSelection.eq(e)){let{focusNode:t,focusOffset:n}=e;setTimeout(()=>{let i=r.domSelectionRange();i.focusNode==t&&i.focusOffset==n&&r.docView&&r.hasFocus()&&Ee(r)},20)}}};ie.blur=(r,e)=>{let t=e;r.focused&&(r.domObserver.stop(),r.dom.classList.remove("ProseMirror-focused"),r.domObserver.start(),t.relatedTarget&&r.dom.contains(t.relatedTarget)&&r.domObserver.currentSelection.clear(),r.focused=!1)};ie.beforeinput=(r,e)=>{if(Ae&&e.inputType=="deleteContentBackward"){r.domObserver.flushSoon();let{domChangeCount:n}=r.input;setTimeout(()=>{if(r.input.domChangeCount!=n||r.domObserver.pendingRecords().length||(r.dom.blur(),r.focus(),Le(r,"Backspace")))return;let{$cursor:i}=r.state.selection;i&&i.pos>0&&r.dispatch(r.state.tr.delete(i.pos-1,i.pos).scrollIntoView())},50)}};for(let r in oe)ie[r]=oe[r];function _t(r,e){if(r==e)return!0;for(let t in r)if(r[t]!==e[t])return!1;for(let t in e)if(!(t in r))return!1;return!0}var jt=class{constructor(e){this.frag=e,this.index=0,this.off=0}nodeAt(e){for(;this.off<=e&&this.index<this.frag.childCount;){let t=this.frag.child(this.index);if(this.off==e)return t;this.off+=t.nodeSize,this.index++}return null}},An=class r{constructor(e,t){this.toDOM=e,this.spec=t||et,this.side=this.spec.side||0}map(e,t,n,i){let{pos:o,deleted:s}=e.mapResult(t.from+i,this.side<0?-1:1);return s?null:new Y(o-n,o-n,this)}valid(){return!0}eq(e){return this==e||e instanceof r&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&_t(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}},Ze=class r{constructor(e,t){this.attrs=e,this.spec=t||et}map(e,t,n,i){let o=e.map(t.from+i,this.spec.inclusiveStart?-1:1)-n,s=e.map(t.to+i,this.spec.inclusiveEnd?1:-1)-n;return o>=s?null:new Y(o,s,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof r&&_t(this.attrs,e.attrs)&&_t(this.spec,e.spec)}static is(e){return e.type instanceof r}destroy(){}},vr=class r{constructor(e,t){this.attrs=e,this.spec=t||et}map(e,t,n,i){let o=e.mapResult(t.from+i,1);if(o.deleted)return null;let s=e.mapResult(t.to+i,-1);return s.deleted||s.pos<=o.pos?null:new Y(o.pos-n,s.pos-n,this)}valid(e,t,n){let i=n.nodeAt(t.from);return!!i&&!i.isText&&t.from+i.nodeSize==t.to}eq(e){return this==e||e instanceof r&&_t(this.attrs,e.attrs)&&_t(this.spec,e.spec)}destroy(){}},Y=class r{constructor(e,t,n){this.from=e,this.to=t,this.type=n}copy(e,t){return new r(e,t,this.type)}eq(e,t=0){return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}map(e,t,n){return this.type.map(e,this,t,n)}static widget(e,t,n){return new r(e,e,new An(t,n))}static inline(e,t,n,i){return new r(e,t,new Ze(n,i))}static node(e,t,n,i){return new r(e,t,new vr(n,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof Ze}get widget(){return this.type instanceof An}},yt=[],et={},K=class r{constructor(e,t){this.local=e.length?e:yt,this.children=t.length?t:yt}static create(e,t){return t.length?En(t,e,0,et):ee}find(e,t,n){let i=[];return this.findInner(e??0,t??1e9,i,0,n),i}findInner(e,t,n,i,o){for(let s=0;s<this.local.length;s++){let l=this.local[s];l.from<=t&&l.to>=e&&(!o||o(l.spec))&&n.push(l.copy(l.from+i,l.to+i))}for(let s=0;s<this.children.length;s+=3)if(this.children[s]<t&&this.children[s+1]>e){let l=this.children[s]+1;this.children[s+2].findInner(e-l,t-l,n,i+l,o)}}map(e,t,n){return this==ee||e.maps.length==0?this:this.mapInner(e,t,0,0,n||et)}mapInner(e,t,n,i,o){let s;if(this.local.length){let l=new jt(t.content);for(let a=0;a<this.local.length;a++){let c=this.local[a].map(e,n,i);c&&c.type.valid(t,c,l)?(s||(s=[])).push(c):o.onRemove&&o.onRemove(this.local[a].spec)}}return this.children.length?uc(this.children,s||[],e,t,n,i,o):s?new r(s.sort(tt),yt):ee}add(e,t){return t.length?this==ee?r.create(e,t):this.addInner(e,t,0):this}addInner(e,t,n){let i,o=0;e.forEach((l,a)=>{let c=a+n,f;if(f=gs(t,l,c)){for(i||(i=this.children.slice());o<i.length&&i[o]<a;)o+=3;i[o]==a?i[o+2]=i[o+2].addInner(l,f,c+1):i.splice(o,0,a,a+l.nodeSize,En(f,l,c+1,et)),o+=3}});let s=ms(o?ys(t):t,-n);if(s.length){let l=new jt(e.content);for(let a=0;a<s.length;a++)s[a].type.valid(e,s[a],l)||s.splice(a--,1)}return new r(s.length?this.local.concat(s).sort(tt):this.local,i||this.children)}remove(e){return e.length==0||this==ee?this:this.removeInner(e,0)}removeInner(e,t){let n=this.children,i=this.local;for(let o=0;o<n.length;o+=3){let s,l=n[o]+t,a=n[o+1]+t;for(let f=0,h;f<e.length;f++)(h=e[f])&&h.from>l&&h.to<a&&(e[f]=null,(s||(s=[])).push(h));if(!s)continue;n==this.children&&(n=this.children.slice());let c=n[o+2].removeInner(s,l+1);c!=ee?n[o+2]=c:(n.splice(o,3),o-=3)}if(i.length){for(let o=0,s;o<e.length;o++)if(s=e[o])for(let l=0;l<i.length;l++)i[l].eq(s,t)&&(i==this.local&&(i=this.local.slice()),i.splice(l--,1))}return n==this.children&&i==this.local?this:i.length||n.length?new r(i,n):ee}forChild(e,t){if(this==ee)return this;if(t.isLeaf)return r.empty;let n,i;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(n=this.children[l+2]);break}let o=e+1,s=o+t.content.size;for(let l=0;l<this.local.length;l++){let a=this.local[l];if(a.from<s&&a.to>o&&a.type instanceof Ze){let c=Math.max(o,a.from)-o,f=Math.min(s,a.to)-o;c<f&&(i||(i=[])).push(a.copy(c,f))}}if(i){let l=new r(i.sort(tt),yt);return n?new Tn([l,n]):l}return n||ee}eq(e){if(this==e)return!0;if(!(e instanceof r)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let t=0;t<this.local.length;t++)if(!this.local[t].eq(e.local[t]))return!1;for(let t=0;t<this.children.length;t+=3)if(this.children[t]!=e.children[t]||this.children[t+1]!=e.children[t+1]||!this.children[t+2].eq(e.children[t+2]))return!1;return!0}locals(e){return qr(this.localsInner(e))}localsInner(e){if(this==ee)return yt;if(e.inlineContent||!this.local.some(Ze.is))return this.local;let t=[];for(let n=0;n<this.local.length;n++)this.local[n].type instanceof Ze||t.push(this.local[n]);return t}forEachSet(e){e(this)}};K.empty=new K([],[]);K.removeOverlap=qr;var ee=K.empty,Tn=class r{constructor(e){this.members=e}map(e,t){let n=this.members.map(i=>i.map(e,t,et));return r.from(n)}forChild(e,t){if(t.isLeaf)return K.empty;let n=[];for(let i=0;i<this.members.length;i++){let o=this.members[i].forChild(e,t);o!=ee&&(o instanceof r?n=n.concat(o.members):n.push(o))}return r.from(n)}eq(e){if(!(e instanceof r)||e.members.length!=this.members.length)return!1;for(let t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0}locals(e){let t,n=!0;for(let i=0;i<this.members.length;i++){let o=this.members[i].localsInner(e);if(o.length)if(!t)t=o;else{n&&(t=t.slice(),n=!1);for(let s=0;s<o.length;s++)t.push(o[s])}}return t?qr(n?t:t.sort(tt)):yt}static from(e){switch(e.length){case 0:return ee;case 1:return e[0];default:return new r(e.every(t=>t instanceof K)?e:e.reduce((t,n)=>t.concat(n instanceof K?n:n.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}};function uc(r,e,t,n,i,o,s){let l=r.slice();for(let c=0,f=o;c<t.maps.length;c++){let h=0;t.maps[c].forEach((d,p,u,m)=>{let g=m-u-(p-d);for(let b=0;b<l.length;b+=3){let I=l[b+1];if(I<0||d>I+f-h)continue;let C=l[b]+f-h;p>=C?l[b+1]=d<=C?-2:-1:d>=f&&g&&(l[b]+=g,l[b+1]+=g)}h+=g}),f=t.maps[c].map(f,-1)}let a=!1;for(let c=0;c<l.length;c+=3)if(l[c+1]<0){if(l[c+1]==-2){a=!0,l[c+1]=-1;continue}let f=t.map(r[c]+o),h=f-i;if(h<0||h>=n.content.size){a=!0;continue}let d=t.map(r[c+1]+o,-1),p=d-i,{index:u,offset:m}=n.content.findIndex(h),g=n.maybeChild(u);if(g&&m==h&&m+g.nodeSize==p){let b=l[c+2].mapInner(t,g,f+1,r[c]+o+1,s);b!=ee?(l[c]=h,l[c+1]=p,l[c+2]=b):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=dc(l,r,e,t,i,o,s),f=En(c,n,0,s);e=f.local;for(let h=0;h<l.length;h+=3)l[h+1]<0&&(l.splice(h,3),h-=3);for(let h=0,d=0;h<f.children.length;h+=3){let p=f.children[h];for(;d<l.length&&l[d]<p;)d+=3;l.splice(d,0,f.children[h],f.children[h+1],f.children[h+2])}}return new K(e.sort(tt),l)}function ms(r,e){if(!e||!r.length)return r;let t=[];for(let n=0;n<r.length;n++){let i=r[n];t.push(new Y(i.from+e,i.to+e,i.type))}return t}function dc(r,e,t,n,i,o,s){function l(a,c){for(let f=0;f<a.local.length;f++){let h=a.local[f].map(n,i,c);h?t.push(h):s.onRemove&&s.onRemove(a.local[f].spec)}for(let f=0;f<a.children.length;f+=3)l(a.children[f+2],a.children[f]+c+1)}for(let a=0;a<r.length;a+=3)r[a+1]==-1&&l(r[a+2],e[a]+o+1);return t}function gs(r,e,t){if(e.isLeaf)return null;let n=t+e.nodeSize,i=null;for(let o=0,s;o<r.length;o++)(s=r[o])&&s.from>t&&s.to<n&&((i||(i=[])).push(s),r[o]=null);return i}function ys(r){let e=[];for(let t=0;t<r.length;t++)r[t]!=null&&e.push(r[t]);return e}function En(r,e,t,n){let i=[],o=!1;e.forEach((l,a)=>{let c=gs(r,l,a+t);if(c){o=!0;let f=En(c,l,t+a+1,n);f!=ee&&i.push(a,a+l.nodeSize,f)}});let s=ms(o?ys(r):r,-t).sort(tt);if(s.length){let l=new jt(e.content);for(let a=0;a<s.length;a++)s[a].type.valid(e,s[a],l)||(n.onRemove&&n.onRemove(s[a].spec),s.splice(a--,1))}return s.length||i.length?new K(s,i):ee}function tt(r,e){return r.from-e.from||r.to-e.to}function qr(r){let e=r;for(let t=0;t<e.length-1;t++){let n=e[t];if(n.from!=n.to)for(let i=t+1;i<e.length;i++){let o=e[i];if(o.from==n.from){o.to!=n.to&&(e==r&&(e=r.slice()),e[i]=o.copy(o.from,n.to),To(e,i+1,o.copy(n.to,o.to)));continue}else{o.from<n.to&&(e==r&&(e=r.slice()),e[t]=n.copy(n.from,o.from),To(e,i,n.copy(o.from,n.to)));break}}}return e}function To(r,e,t){for(;e<r.length&&tt(t,r[e])>0;)e++;r.splice(e,0,t)}function pr(r){let e=[];return r.someProp("decorations",t=>{let n=t(r.state);n&&n!=ee&&e.push(n)}),r.cursorWrapper&&e.push(K.create(r.state.doc,[r.cursorWrapper.deco])),Tn.from(e)}var pc={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},mc=le&&$e<=11,zr=class{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}},Pr=class{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new zr,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(n=>{for(let i=0;i<n.length;i++)this.queue.push(n[i]);le&&$e<=11&&n.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():ne&&e.composing&&n.some(i=>i.type=="childList"&&i.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),mc&&(this.onCharData=n=>{this.queue.push({target:n.target,type:"characterData",oldValue:n.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,pc)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let t=0;t<e.length;t++)this.queue.push(e[t]);window.setTimeout(()=>this.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(Co(this.view)){if(this.suppressingSelectionUpdates)return Ee(this.view);if(le&&$e<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&nt(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t=new Set,n;for(let o=e.focusNode;o;o=bt(o))t.add(o);for(let o=e.anchorNode;o;o=bt(o))if(t.has(o)){n=o;break}let i=n&&this.view.docView.nearestDesc(n);if(i&&i.ignoreMutation({type:"selection",target:W(n)?n.parentNode:n}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let n,i=!1;!this.suppressingSelectionUpdates&&Co(e)&&(n=e.domSelectionRange(),i=!this.currentSelection.eq(n)&&!this.ignoreSelectionChange(n));let o=-1,s=-1,l=!1,a=[];if(e.editable)for(let f=0;f<t.length;f++){let h=this.registerMutation(t[f],a);h&&(o=o<0?h.from:Math.min(h.from,o),s=s<0?h.to:Math.max(h.to,s),h.typeOver&&(l=!0))}if(a.some(f=>f.nodeName=="BR")&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46||G&&(e.composing||e.input.compositionEndedAt>Date.now()-50)&&t.some(f=>f.type=="childList"&&f.removedNodes.length))){for(let f of a)if(f.nodeName=="BR"&&f.parentNode){let h=f.nextSibling;for(;h&&M(h);){if(h.contentEditable=="false"){f.parentNode.removeChild(f);break}h=h.firstChild}}}else if(ue&&a.length){let f=a.filter(h=>h.nodeName=="BR");if(f.length==2){let[h,d]=f;h.parentNode&&h.parentNode.parentNode==d.parentNode?d.remove():h.remove()}else{let{focusNode:h}=this.currentSelection;for(let d of f){let p=d.parentNode;p&&p.nodeName=="LI"&&(!h||bc(e,h)!=p)&&d.remove()}}}let c=null;o<0&&i&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&Rn(n)&&(c=Fr(e))&&c.eq(D.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,Ee(e),this.currentSelection.set(n),e.scrollToSelection()):(o>-1||i)&&(o>-1&&(e.docView.markDirty(o,s),gc(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,Sc(e,a)),this.handleDOMChange(o,s,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):n&&!this.currentSelection.eq(n)&&Ee(e),n&&this.currentSelection.set(n))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let n=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(n==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!n||n.ignoreMutation(e))return null;if(e.type=="childList"){for(let f=0;f<e.addedNodes.length;f++){let h=e.addedNodes[f];t.push(h),W(h)&&(this.lastChangedTextNode=h)}if(n.contentDOM&&n.contentDOM!=n.dom&&!n.contentDOM.contains(e.target))return{from:n.posBefore,to:n.posAfter};let i=e.previousSibling,o=e.nextSibling;if(le&&$e<=11&&e.addedNodes.length)for(let f=0;f<e.addedNodes.length;f++){let{previousSibling:h,nextSibling:d}=e.addedNodes[f];(!h||Array.prototype.indexOf.call(e.addedNodes,h)<0)&&(i=h),(!d||Array.prototype.indexOf.call(e.addedNodes,d)<0)&&(o=d)}let s=i&&i.parentNode==e.target?U(i)+1:0,l=n.localPosFromDOM(e.target,s,-1),a=o&&o.parentNode==e.target?U(o):e.target.childNodes.length,c=n.localPosFromDOM(e.target,a,1);return{from:l,to:c}}else return e.type=="attributes"?{from:n.posAtStart-n.border,to:n.posAtEnd+n.border}:(this.lastChangedTextNode=e.target,{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}},Eo=new WeakMap,Ro=!1;function gc(r){if(!Eo.has(r)&&(Eo.set(r,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(r.dom).whiteSpace)!==-1)){if(r.requiresGeckoHackNode=ue,Ro)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."),Ro=!0}}function Io(r,e){let t=e.startContainer,n=e.startOffset,i=e.endContainer,o=e.endOffset,s=r.domAtPos(r.state.selection.anchor);return nt(s.node,s.offset,i,o)&&([t,n,i,o]=[i,o,t,n]),{anchorNode:t,anchorOffset:n,focusNode:i,focusOffset:o}}function yc(r,e){if(e.getComposedRanges){let i=e.getComposedRanges(r.root)[0];if(i)return Io(r,i)}let t;function n(i){i.preventDefault(),i.stopImmediatePropagation(),t=i.getTargetRanges()[0]}return r.dom.addEventListener("beforeinput",n,!0),document.execCommand("indent"),r.dom.removeEventListener("beforeinput",n,!0),t?Io(r,t):null}function bc(r,e){for(let t=e.parentNode;t&&t!=r.dom;t=t.parentNode){let n=r.docView.nearestDesc(t,!0);if(n&&n.node.isBlock)return t}return null}function Sc(r,e){var t;let{focusNode:n,focusOffset:i}=r.domSelectionRange();for(let o of e)if(((t=o.parentNode)===null||t===void 0?void 0:t.nodeName)=="TR"){let s=o.nextSibling;for(;s&&s.nodeName!="TD"&&s.nodeName!="TH";)s=s.nextSibling;if(s){let l=s;for(;;){let a=l.firstChild;if(!a||!M(a)||a.contentEditable=="false"||/^(BR|IMG)$/.test(a.nodeName))break;l=a}l.insertBefore(o,l.firstChild),n==o&&r.domSelection().collapse(o,i)}else o.parentNode.removeChild(o)}}function kc(r,e,t,n){let{node:i,fromOffset:o,toOffset:s,from:l,to:a}=r.docView.parseRange(e,t),c=r.domSelectionRange(),f,h=c.anchorNode;if(h&&rt(r.dom,h)&&(f=[{node:h,offset:c.anchorOffset}],Rn(c)||f.push({node:c.focusNode,offset:c.focusOffset})),G&&r.input.lastKeyCode===8)for(let b=s;b>o;b--){let I=i.childNodes[b-1],C=I.pmViewDesc;if(I.nodeName=="BR"&&!C){s=b;break}if(!C||C.size)break}let d=r.state.doc,p=r.someProp("domParser")||Ue.fromSchema(r.state.schema),u=d.resolve(l),m=null,g=p.parse(i,{topNode:u.parent,topMatch:u.parent.contentMatchAt(u.index()),topOpen:!0,from:o,to:s,preserveWhitespace:u.parent.type.whitespace=="pre"?"full":!0,findPositions:f,ruleFromNode:xc(n),context:u});if(f&&f[0].pos!=null){let b=f[0].pos,I=f[1]&&f[1].pos;I==null&&(I=b),m={anchor:b+l,head:I+l}}return{doc:g,sel:m,from:l,to:a}}var xc=r=>e=>{let t=e.pmViewDesc;if(t)return t.parseRule(r);if(e.nodeName=="BR"&&e.parentNode){if(ne&&/^(ul|ol)$/i.test(e.parentNode.nodeName)){let n=document.createElement("div");return n.appendChild(document.createElement("li")),{skip:n}}else if(e.parentNode.lastChild==e||ne&&/^(tr|table)$/i.test(e.parentNode.nodeName))return{ignore:!0}}else if(e.nodeName=="IMG"&&e.getAttribute("mark-placeholder"))return{ignore:!0};return null},Cc=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function wc(r,e,t,n,i){let o=r.input.compositionPendingChanges||(r.composing?r.input.compositionID:0);if(r.input.compositionPendingChanges=0,e<0){let O=r.input.lastSelectionTime>Date.now()-50?r.input.lastSelectionOrigin:null,F=Fr(r,O);if(F&&!r.state.selection.eq(F)){if(G&&Ae&&r.input.lastKeyCode===13&&Date.now()-100<r.input.lastKeyCodeTime&&Le(r,"Enter"))return;let y=r.state.tr.setSelection(F);O=="pointer"?y.setMeta("pointer",!0):O=="key"&&y.scrollIntoView(),o&&y.setMeta("composition",o),r.dispatch(y)}return}let s=r.state.doc.resolve(e),l=s.sharedDepth(t);e=s.before(l+1),t=r.state.doc.resolve(t).after(l+1);let a=r.state.selection,c=kc(r,e,t,i),f=r.state.doc,h=f.slice(c.from,c.to),d,p;r.input.lastKeyCode===8&&Date.now()-100<r.input.lastKeyCodeTime?(d=r.state.selection.to,p="end"):(d=r.state.selection.from,p="start"),r.input.lastKeyCode=null;let u=Dc(h.content,c.doc.content,c.from,d,p);if(u&&r.input.domChangeCount++,(St&&r.input.lastIOSEnter>Date.now()-225||Ae)&&i.some(O=>M(O)&&!Cc.test(O.nodeName))&&(!u||u.endA>=u.endB)&&Le(r,"Enter")){r.input.lastIOSEnter=0;return}if(!u)if(n&&a instanceof T&&!a.empty&&a.$head.sameParent(a.$anchor)&&!r.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))u={start:a.from,endA:a.to,endB:a.to};else{if(c.sel){let O=vo(r,r.state.doc,c.sel);if(O&&!O.eq(r.state.selection)){let F=r.state.tr.setSelection(O);o&&F.setMeta("composition",o),r.dispatch(F)}}return}r.state.selection.from<r.state.selection.to&&u.start==u.endB&&r.state.selection instanceof T&&(u.start>r.state.selection.from&&u.start<=r.state.selection.from+2&&r.state.selection.from>=c.from?u.start=r.state.selection.from:u.endA<r.state.selection.to&&u.endA>=r.state.selection.to-2&&r.state.selection.to<=c.to&&(u.endB+=r.state.selection.to-u.endA,u.endA=r.state.selection.to)),le&&$e<=11&&u.endB==u.start+1&&u.endA==u.start&&u.start>c.from&&c.doc.textBetween(u.start-c.from-1,u.start-c.from+1)==" \xA0"&&(u.start--,u.endA--,u.endB--);let m=c.doc.resolveNoCache(u.start-c.from),g=c.doc.resolveNoCache(u.endB-c.from),b=f.resolve(u.start),I=m.sameParent(g)&&m.parent.inlineContent&&b.end()>=u.endA;if((St&&r.input.lastIOSEnter>Date.now()-225&&(!I||i.some(O=>O.nodeName=="DIV"||O.nodeName=="P"))||!I&&Nc(c.doc,m.pos,g.pos))&&Le(r,"Enter")){r.input.lastIOSEnter=0;return}if(r.state.selection.anchor>u.start&&(I?u.endA>u.start&&u.endB==u.start:Oc(f,u.start,u.endA,m,g))&&Le(r,"Backspace")){Ae&&G&&r.domObserver.suppressSelectionUpdates();return}G&&u.endB==u.start&&(r.input.lastChromeDelete=Date.now()),Ae&&!I&&m.start()!=g.start()&&g.parentOffset==0&&m.depth==g.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==u.endA&&(u.endB-=2,g=c.doc.resolveNoCache(u.endB-c.from),setTimeout(()=>Le(r,"Enter"),20));let C=u.start,V=u.endA,J=O=>{let F=O||r.state.tr.replace(C,V,c.doc.slice(u.start-c.from,u.endB-c.from));if(c.sel){let y=vo(r,F.doc,c.sel);y&&!(G&&r.composing&&y.empty&&(u.start!=u.endB||r.input.lastChromeDelete<Date.now()-100)&&(y.head==C||y.head==F.mapping.map(V)-1)||le&&y.empty&&y.head==C)&&F.setSelection(y)}return o&&F.setMeta("composition",o),F.scrollIntoView()},N;if(I)if(m.pos==g.pos){le&&$e<=11&&m.parentOffset==0&&(r.domObserver.suppressSelectionUpdates(),setTimeout(()=>Ee(r),20));let O=J(r.state.tr.delete(C,V)),F=f.resolve(u.start).marksAcross(f.resolve(u.endA));F&&O.ensureMarks(F),r.dispatch(O)}else if(u.endA==u.endB&&(N=Mc(m.parent.content.cut(m.parentOffset,g.parentOffset),b.parent.content.cut(b.parentOffset,u.endA-b.start())))){let O=J(r.state.tr);N.type=="add"?O.addMark(C,V,N.mark):O.removeMark(C,V,N.mark),r.dispatch(O)}else if(m.parent.child(m.index()).isText&&m.index()==g.index()-(g.textOffset?0:1)){let O=m.parent.textBetween(m.parentOffset,g.parentOffset),F=()=>J(r.state.tr.insertText(O,C,V));r.someProp("handleTextInput",y=>y(r,C,V,O,F))||r.dispatch(F())}else r.dispatch(J());else r.dispatch(J())}function vo(r,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:Vr(r,e.resolve(t.anchor),e.resolve(t.head))}function Mc(r,e){let t=r.firstChild.marks,n=e.firstChild.marks,i=t,o=n,s,l,a;for(let f=0;f<n.length;f++)i=n[f].removeFromSet(i);for(let f=0;f<t.length;f++)o=t[f].removeFromSet(o);if(i.length==1&&o.length==0)l=i[0],s="add",a=f=>f.mark(l.addToSet(f.marks));else if(i.length==0&&o.length==1)l=o[0],s="remove",a=f=>f.mark(l.removeFromSet(f.marks));else return null;let c=[];for(let f=0;f<e.childCount;f++)c.push(a(e.child(f)));if(S.from(c).eq(r))return{mark:l,type:s}}function Oc(r,e,t,n,i){if(t-e<=i.pos-n.pos||mr(n,!0,!1)<i.pos)return!1;let o=r.resolve(e);if(!n.parent.inlineContent){let l=o.nodeAfter;return l!=null&&t==e+l.nodeSize}if(o.parentOffset<o.parent.content.size||!o.parent.isTextblock)return!1;let s=r.resolve(mr(o,!0,!0));return!s.parent.isTextblock||s.pos>t||mr(s,!0,!1)<t?!1:n.parent.content.cut(n.parentOffset).eq(s.parent.content)}function Nc(r,e,t){let n=0,i=0;return r.nodesBetween(e,t,(o,s)=>{o.isTextblock&&s>=e&&s<t?n++:(o.isText?/\S/.test(o.text.slice(Math.max(0,e-s),Math.min(o.nodeSize,t-s))):o.isLeaf)&&i++}),i==0&&n==1}function mr(r,e,t){let n=r.depth,i=e?r.end():r.pos;for(;n>0&&(e||r.indexAfter(n)==r.node(n).childCount);)n--,i++,e=!1;if(t){let o=r.node(n).maybeChild(r.indexAfter(n));for(;o&&!o.isLeaf;)o=o.firstChild,i++}return i}function Dc(r,e,t,n,i){let o=r.findDiffStart(e,t),s=t+r.size,l=t+e.size;if(o==null)return null;let{a,b:c}=r.findDiffEnd(e,s,l);if(i=="end"){let f=Math.max(0,o-Math.min(a,c));n-=a+f-o}if(a<o&&s<l){let f=n<=o&&n>=a?o-n:0;o-=f,c=o+(c-a),a=o}else if(c<o){let f=n<=o&&n>=c?o-n:0;o-=f,a=o+(a-c),c=o}return{start:o,endA:a,endB:c}}var Ut=class{constructor(e,t){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new Tr,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(Vo),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):typeof e=="function"?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=Bo(this),Po(this),this.nodeViews=Fo(this),this.docView=go(this.state.doc,zo(this),pr(this),this.dom,this),this.domObserver=new Pr(this,(n,i,o,s)=>wc(this,n,i,o,s)),this.domObserver.start(),ja(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let t in e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&Er(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Vo),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let n in this._props)t[n]=this._props[n];t.state=this.state;for(let n in e)t[n]=e[n];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var n;let i=this.state,o=!1,s=!1;e.storedMarks&&this.composing&&(us(this),s=!0),this.state=e;let l=i.plugins!=e.plugins||this._props.plugins!=t.plugins;if(l||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let p=Fo(this);Tc(p,this.nodeViews)&&(this.nodeViews=p,o=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&Er(this),this.editable=Bo(this),Po(this);let a=pr(this),c=zo(this),f=i.plugins!=e.plugins&&!i.doc.eq(e.doc)?"reset":e.scrollToSelection>i.scrollToSelection?"to selection":"preserve",h=o||!this.docView.matchesNode(e.doc,c,a);(h||!e.selection.eq(i.selection))&&(s=!0);let d=f=="preserve"&&s&&this.dom.style.overflowAnchor==null&&ha(this);if(s){this.domObserver.stop();let p=h&&(le||G)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&Ac(i.selection,e.selection);if(h){let m=G?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=sc(this)),(o||!this.docView.update(e.doc,c,a,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=go(e.doc,c,a,this.dom,this)),m&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(p=!0)}let u=this.input.mouseDown;p||!(u&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&Ia(this)&&u.delaySelUpdate())?Ee(this,p):(Qo(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(i),!((n=this.dragging)===null||n===void 0)&&n.node&&!i.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,i),f=="reset"?this.dom.scrollTop=0:f=="to selection"?this.scrollToSelection():d&&ua(d)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!rt(this.dom,e))){if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof w){let t=this.docView.domAfterPos(this.state.selection.from);M(t)&&fo(this,t.getBoundingClientRect(),e)}else fo(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let t=0;t<this.directPlugins.length;t++){let n=this.directPlugins[t];n.spec.view&&this.pluginViews.push(n.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let n=this.state.plugins[t];n.spec.view&&this.pluginViews.push(n.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let n=this.pluginViews[t];n.update&&n.update(this,e)}}updateDraggedNode(e,t){let n=e.node,i=-1;if(n.from<this.state.doc.content.size&&this.state.doc.nodeAt(n.from)==n.node)i=n.from;else{let o=n.from+(this.state.doc.content.size-t.doc.content.size);(o>0&&o<this.state.doc.content.size&&this.state.doc.nodeAt(o))==n.node&&(i=o)}this.dragging=new Dn(e.slice,e.move,i<0?void 0:w.create(this.state.doc,i))}someProp(e,t){let n=this._props&&this._props[e],i;if(n!=null&&(i=t?t(n):n))return i;for(let s=0;s<this.directPlugins.length;s++){let l=this.directPlugins[s].props[e];if(l!=null&&(i=t?t(l):l))return i}let o=this.state.plugins;if(o)for(let s=0;s<o.length;s++){let l=o[s].props[e];if(l!=null&&(i=t?t(l):l))return i}}hasFocus(){if(le){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if(e.contentEditable=="false")return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&da(this.dom),Ee(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let t=this.dom.parentNode;t;t=t.parentNode)if(t.nodeType==9||t.nodeType==11&&t.host)return t.getSelection||(Object.getPrototypeOf(t).getSelection=()=>t.ownerDocument.getSelection()),this._root=t}return e||document}updateRoot(){this._root=null}posAtCoords(e){return ba(this,e)}coordsAtPos(e,t=1){return _o(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,n=-1){let i=this.docView.posFromDOM(e,t,n);if(i==null)throw new RangeError("DOM position not inside the editor");return i}endOfTextblock(e,t){return wa(this,t||this.state,e)}pasteHTML(e,t){return Kt(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return Kt(this,e,null,!0,t||new ClipboardEvent("paste"))}serializeForClipboard(e){return Lr(this,e)}destroy(){this.docView&&(Ua(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],pr(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,ea())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return Ya(this,e)}domSelectionRange(){let e=this.dom.isConnected!==!1&&this.domSelection();return e?ne&&this.root.nodeType===11&&sa(this.dom.ownerDocument)==this.dom&&yc(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}};Ut.prototype.dispatch=function(r){let e=this._props.dispatchTransaction;e?e.call(this,r):this.updateState(this.state.apply(r))};function zo(r){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(r.editable),r.someProp("attributes",t=>{if(typeof t=="function"&&(t=t(r.state)),t)for(let n in t)n=="class"?e.class+=" "+t[n]:n=="style"?e.style=(e.style?e.style+";":"")+t[n]:!e[n]&&n!="contenteditable"&&n!="nodeName"&&(e[n]=String(t[n]))}),e.translate||(e.translate="no"),[Y.node(0,r.state.doc.content.size,e)]}function Po(r){if(r.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),r.cursorWrapper={dom:e,deco:Y.widget(r.state.selection.from,e,{raw:!0,marks:r.markCursor})}}else r.cursorWrapper=null}function Bo(r){return!r.someProp("editable",e=>e(r.state)===!1)}function Ac(r,e){let t=Math.min(r.$anchor.sharedDepth(r.head),e.$anchor.sharedDepth(e.head));return r.$anchor.start(t)!=e.$anchor.start(t)}function Fo(r){let e=Object.create(null);function t(n){for(let i in n)Object.prototype.hasOwnProperty.call(e,i)||(e[i]=n[i])}return r.someProp("nodeViews",t),r.someProp("markViews",t),e}function Tc(r,e){let t=0,n=0;for(let i in r){if(r[i]!=e[i])return!0;t++}for(let i in e)n++;return t!=n}function Vo(r){if(r.spec.state||r.spec.filterTransaction||r.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var vn=200,X=function(){};X.prototype.append=function(e){return e.length?(e=X.from(e),!this.length&&e||e.length<vn&&this.leafAppend(e)||this.length<vn&&e.leafPrepend(this)||this.appendInner(e)):this};X.prototype.prepend=function(e){return e.length?X.from(e).append(this):this};X.prototype.appendInner=function(e){return new Ec(this,e)};X.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?X.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))};X.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};X.prototype.forEach=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length),t<=n?this.forEachInner(e,t,n,0):this.forEachInvertedInner(e,t,n,0)};X.prototype.map=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length);var i=[];return this.forEach(function(o,s){return i.push(e(o,s))},t,n),i};X.from=function(e){return e instanceof X?e:e&&e.length?new bs(e):X.empty};var bs=(function(r){function e(n){r.call(this),this.values=n}r&&(e.__proto__=r),e.prototype=Object.create(r&&r.prototype),e.prototype.constructor=e;var t={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(i,o){return i==0&&o==this.length?this:new e(this.values.slice(i,o))},e.prototype.getInner=function(i){return this.values[i]},e.prototype.forEachInner=function(i,o,s,l){for(var a=o;a<s;a++)if(i(this.values[a],l+a)===!1)return!1},e.prototype.forEachInvertedInner=function(i,o,s,l){for(var a=o-1;a>=s;a--)if(i(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(i){if(this.length+i.length<=vn)return new e(this.values.concat(i.flatten()))},e.prototype.leafPrepend=function(i){if(this.length+i.length<=vn)return new e(i.flatten().concat(this.values))},t.length.get=function(){return this.values.length},t.depth.get=function(){return 0},Object.defineProperties(e.prototype,t),e})(X);X.empty=new bs([]);var Ec=(function(r){function e(t,n){r.call(this),this.left=t,this.right=n,this.length=t.length+n.length,this.depth=Math.max(t.depth,n.depth)+1}return r&&(e.__proto__=r),e.prototype=Object.create(r&&r.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(n){return n<this.left.length?this.left.get(n):this.right.get(n-this.left.length)},e.prototype.forEachInner=function(n,i,o,s){var l=this.left.length;if(i<l&&this.left.forEachInner(n,i,Math.min(o,l),s)===!1||o>l&&this.right.forEachInner(n,Math.max(i-l,0),Math.min(this.length,o)-l,s+l)===!1)return!1},e.prototype.forEachInvertedInner=function(n,i,o,s){var l=this.left.length;if(i>l&&this.right.forEachInvertedInner(n,i-l,Math.max(o,l)-l,s+l)===!1||o<l&&this.left.forEachInvertedInner(n,Math.min(i,l),o,s)===!1)return!1},e.prototype.sliceInner=function(n,i){if(n==0&&i==this.length)return this;var o=this.left.length;return i<=o?this.left.slice(n,i):n>=o?this.right.slice(n-o,i-o):this.left.slice(n,o).append(this.right.slice(0,i-o))},e.prototype.leafAppend=function(n){var i=this.right.leafAppend(n);if(i)return new e(this.left,i)},e.prototype.leafPrepend=function(n){var i=this.left.leafPrepend(n);if(i)return new e(i,this.right)},e.prototype.appendInner=function(n){return this.left.depth>=Math.max(this.right.depth,n.depth)+1?new e(this.left,new e(this.right,n)):new e(this,n)},e})(X),Hr=X;var Rc=500,ot=class r{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(this.eventCount==0)return null;let n=this.items.length;for(;;n--)if(this.items.get(n-1).selection){--n;break}let i,o;t&&(i=this.remapping(n,this.items.length),o=i.maps.length);let s=e.tr,l,a,c=[],f=[];return this.items.forEach((h,d)=>{if(!h.step){i||(i=this.remapping(n,d+1),o=i.maps.length),o--,f.push(h);return}if(i){f.push(new ke(h.map));let p=h.step.map(i.slice(o)),u;p&&s.maybeStep(p).doc&&(u=s.mapping.maps[s.mapping.maps.length-1],c.push(new ke(u,void 0,void 0,c.length+f.length))),o--,u&&i.appendMap(u,o)}else s.maybeStep(h.step);if(h.selection)return l=i?h.selection.map(i.slice(o)):h.selection,a=new r(this.items.slice(0,n).append(f.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:s,selection:l}}addTransform(e,t,n,i){let o=[],s=this.eventCount,l=this.items,a=!i&&l.length?l.get(l.length-1):null;for(let f=0;f<e.steps.length;f++){let h=e.steps[f].invert(e.docs[f]),d=new ke(e.mapping.maps[f],h,t),p;(p=a&&a.merge(d))&&(d=p,f?o.pop():l=l.slice(0,l.length-1)),o.push(d),t&&(s++,t=void 0),i||(a=d)}let c=s-n.depth;return c>vc&&(l=Ic(l,c),s-=c),new r(l.append(o),s)}remapping(e,t){let n=new It;return this.items.forEach((i,o)=>{let s=i.mirrorOffset!=null&&o-i.mirrorOffset>=e?n.maps.length-i.mirrorOffset:void 0;n.appendMap(i.map,s)},e,t),n}addMaps(e){return this.eventCount==0?this:new r(this.items.append(e.map(t=>new ke(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;t=Math.min(this.items.length,t);let n=[],i=this.items.length-t,o=e.mapping,s=e.steps.length,l=this.eventCount;this.items.forEach(d=>{d.selection&&l--},i);let a=t;this.items.forEach(d=>{let p=o.getMirror(--a);if(p==null)return;s=Math.min(s,p);let u=o.maps[p];if(d.step){let m=e.steps[p].invert(e.docs[p]),g=d.selection&&d.selection.map(o.slice(a+1,p));g&&l++,n.push(new ke(u,m,g))}else n.push(new ke(u))},i);let c=[];for(let d=t;d<s;d++)c.push(new ke(o.maps[d]));let f=this.items.slice(0,i).append(c).append(n),h=new r(f,l);return h.emptyItemCount()>Rc&&(h=h.compress(this.items.length-n.length)),h}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),n=t.maps.length,i=[],o=0;return this.items.forEach((s,l)=>{if(l>=e)i.push(s),s.selection&&o++;else if(s.step){let a=s.step.map(t.slice(n)),c=a&&a.getMap();if(n--,c&&t.appendMap(c,n),a){let f=s.selection&&s.selection.map(t.slice(n));f&&o++;let h=new ke(c.invert(),a,f),d,p=i.length-1;(d=i.length&&i[p].merge(h))?i[p]=d:i.push(h)}}else s.map&&n--},this.items.length,0),new r(Hr.from(i.reverse()),o)}};ot.empty=new ot(Hr.empty,0);function Ic(r,e){let t;return r.forEach((n,i)=>{if(n.selection&&e--==0)return t=i,!1}),r.slice(t)}var ke=class r{constructor(e,t,n,i){this.map=e,this.step=t,this.selection=n,this.mirrorOffset=i}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new r(t.getMap().invert(),t,this.selection)}}},xe=class{constructor(e,t,n,i,o){this.done=e,this.undone=t,this.prevRanges=n,this.prevTime=i,this.prevComposition=o}},vc=20;function zc(r,e,t,n){let i=t.getMeta(Re),o;if(i)return i.historyState;t.getMeta(Fc)&&(r=new xe(r.done,r.undone,null,0,-1));let s=t.getMeta("appendedTransaction");if(t.steps.length==0)return r;if(s&&s.getMeta(Re))return s.getMeta(Re).redo?new xe(r.done.addTransform(t,void 0,n,zn(e)),r.undone,Ss(t.mapping.maps),r.prevTime,r.prevComposition):new xe(r.done,r.undone.addTransform(t,void 0,n,zn(e)),null,r.prevTime,r.prevComposition);if(t.getMeta("addToHistory")!==!1&&!(s&&s.getMeta("addToHistory")===!1)){let l=t.getMeta("composition"),a=r.prevTime==0||!s&&r.prevComposition!=l&&(r.prevTime<(t.time||0)-n.newGroupDelay||!Pc(t,r.prevRanges)),c=s?Kr(r.prevRanges,t.mapping):Ss(t.mapping.maps);return new xe(r.done.addTransform(t,a?e.selection.getBookmark():void 0,n,zn(e)),ot.empty,c,t.time,l??r.prevComposition)}else return(o=t.getMeta("rebased"))?new xe(r.done.rebased(t,o),r.undone.rebased(t,o),Kr(r.prevRanges,t.mapping),r.prevTime,r.prevComposition):new xe(r.done.addMaps(t.mapping.maps),r.undone.addMaps(t.mapping.maps),Kr(r.prevRanges,t.mapping),r.prevTime,r.prevComposition)}function Pc(r,e){if(!e)return!1;if(!r.docChanged)return!0;let t=!1;return r.mapping.maps[0].forEach((n,i)=>{for(let o=0;o<e.length;o+=2)n<=e[o+1]&&i>=e[o]&&(t=!0)}),t}function Ss(r){let e=[];for(let t=r.length-1;t>=0&&e.length==0;t--)r[t].forEach((n,i,o,s)=>e.push(o,s));return e}function Kr(r,e){if(!r)return null;let t=[];for(let n=0;n<r.length;n+=2){let i=e.map(r[n],1),o=e.map(r[n+1],-1);i<=o&&t.push(i,o)}return t}function Bc(r,e,t){let n=zn(e),i=Re.get(e).spec.config,o=(t?r.undone:r.done).popEvent(e,n);if(!o)return null;let s=o.selection.resolve(o.transform.doc),l=(t?r.done:r.undone).addTransform(o.transform,e.selection.getBookmark(),i,n),a=new xe(t?l:o.remaining,t?o.remaining:l,null,0,-1);return o.transform.setSelection(s).setMeta(Re,{redo:t,historyState:a})}var _r=!1,ks=null;function zn(r){let e=r.plugins;if(ks!=e){_r=!1,ks=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){_r=!0;break}}return _r}var Re=new me("history"),Fc=new me("closeHistory");function xs(r={}){return r={depth:r.depth||100,newGroupDelay:r.newGroupDelay||500},new H({key:Re,state:{init(){return new xe(ot.empty,ot.empty,null,0,-1)},apply(e,t,n){return zc(t,n,e,r)}},config:r,props:{handleDOMEvents:{beforeinput(e,t){let n=t.inputType,i=n=="historyUndo"?Bn:n=="historyRedo"?Qt:null;return!i||!e.editable?!1:(t.preventDefault(),i(e.state,e.dispatch))}}}})}function Pn(r,e){return(t,n)=>{let i=Re.getState(t);if(!i||(r?i.undone:i.done).eventCount==0)return!1;if(n){let o=Bc(i,t,r);o&&n(e?o.scrollIntoView():o)}return!0}}var Bn=Pn(!1,!0),Qt=Pn(!0,!0),kh=Pn(!1,!1),xh=Pn(!0,!1);function Cs(r){let e=Re.getState(r);return e?e.done.eventCount:0}function ws(r){let e=Re.getState(r);return e?e.undone.eventCount:0}var Ie={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:"'"},Vn={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Vc=typeof navigator<"u"&&/Mac/.test(navigator.platform),Lc=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for($=0;$<10;$++)Ie[48+$]=Ie[96+$]=String($);var $;for($=1;$<=24;$++)Ie[$+111]="F"+$;var $;for($=65;$<=90;$++)Ie[$]=String.fromCharCode($+32),Vn[$]=String.fromCharCode($);var $;for(Fn in Ie)Vn.hasOwnProperty(Fn)||(Vn[Fn]=Ie[Fn]);var Fn;function Ms(r){var e=Vc&&r.metaKey&&r.shiftKey&&!r.ctrlKey&&!r.altKey||Lc&&r.shiftKey&&r.key&&r.key.length==1||r.key=="Unidentified",t=!e&&r.key||(r.shiftKey?Vn:Ie)[r.keyCode]||r.key||"Unidentified";return t=="Esc"&&(t="Escape"),t=="Del"&&(t="Delete"),t=="Left"&&(t="ArrowLeft"),t=="Up"&&(t="ArrowUp"),t=="Right"&&(t="ArrowRight"),t=="Down"&&(t="ArrowDown"),t}var $c=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),Wc=typeof navigator<"u"&&/Win/.test(navigator.platform);function Jc(r){let e=r.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let n,i,o,s;for(let l=0;l<e.length-1;l++){let a=e[l];if(/^(cmd|meta|m)$/i.test(a))s=!0;else if(/^a(lt)?$/i.test(a))n=!0;else if(/^(c|ctrl|control)$/i.test(a))i=!0;else if(/^s(hift)?$/i.test(a))o=!0;else if(/^mod$/i.test(a))$c?s=!0:i=!0;else throw new Error("Unrecognized modifier name: "+a)}return n&&(t="Alt-"+t),i&&(t="Ctrl-"+t),s&&(t="Meta-"+t),o&&(t="Shift-"+t),t}function qc(r){let e=Object.create(null);for(let t in r)e[Jc(t)]=r[t];return e}function jr(r,e,t=!0){return e.altKey&&(r="Alt-"+r),e.ctrlKey&&(r="Ctrl-"+r),e.metaKey&&(r="Meta-"+r),t&&e.shiftKey&&(r="Shift-"+r),r}function Ur(r){return new H({props:{handleKeyDown:Zt(r)}})}function Zt(r){let e=qc(r);return function(t,n){let i=Ms(n),o,s=e[jr(i,n)];if(s&&s(t.state,t.dispatch,t))return!0;if(i.length==1&&i!=" "){if(n.shiftKey){let l=e[jr(i,n,!1)];if(l&&l(t.state,t.dispatch,t))return!0}if((n.altKey||n.metaKey||n.ctrlKey)&&!(Wc&&n.ctrlKey&&n.altKey)&&(o=Ie[n.keyCode])&&o!=i){let l=e[jr(o,n)];if(l&&l(t.state,t.dispatch,t))return!0}}return!1}}var Ns=(r,e)=>r.selection.empty?!1:(e&&e(r.tr.deleteSelection().scrollIntoView()),!0);function Hc(r,e){let{$cursor:t}=r.selection;return!t||(e?!e.endOfTextblock("backward",r):t.parentOffset>0)?null:t}var Kc=(r,e,t)=>{let n=Hc(r,t);if(!n)return!1;let i=Ds(n);if(!i){let s=n.blockRange(),l=s&&Bt(s);return l==null?!1:(e&&e(r.tr.lift(s,l).scrollIntoView()),!0)}let o=i.nodeBefore;if(Es(r,i,e,-1))return!0;if(n.parent.content.size==0&&(kt(o,"end")||w.isSelectable(o)))for(let s=n.depth;;s--){let l=yn(r.doc,n.before(s),n.after(s),k.empty);if(l&&l.slice.size<l.to-l.from){if(e){let a=r.tr.step(l);a.setSelection(kt(o,"end")?D.findFrom(a.doc.resolve(a.mapping.map(i.pos,-1)),-1):w.create(a.doc,i.pos-o.nodeSize)),e(a.scrollIntoView())}return!0}if(s==1||n.node(s-1).childCount>1)break}return o.isAtom&&i.depth==n.depth-1?(e&&e(r.tr.delete(i.pos-o.nodeSize,i.pos).scrollIntoView()),!0):!1};function kt(r,e,t=!1){for(let n=r;n;n=e=="start"?n.firstChild:n.lastChild){if(n.isTextblock)return!0;if(t&&n.childCount!=1)return!1}return!1}var _c=(r,e,t)=>{let{$head:n,empty:i}=r.selection,o=n;if(!i)return!1;if(n.parent.isTextblock){if(t?!t.endOfTextblock("backward",r):n.parentOffset>0)return!1;o=Ds(n)}let s=o&&o.nodeBefore;return!s||!w.isSelectable(s)?!1:(e&&e(r.tr.setSelection(w.create(r.doc,o.pos-s.nodeSize)).scrollIntoView()),!0)};function Ds(r){if(!r.parent.type.spec.isolating)for(let e=r.depth-1;e>=0;e--){if(r.index(e)>0)return r.doc.resolve(r.before(e+1));if(r.node(e).type.spec.isolating)break}return null}function jc(r,e){let{$cursor:t}=r.selection;return!t||(e?!e.endOfTextblock("forward",r):t.parentOffset<t.parent.content.size)?null:t}var Uc=(r,e,t)=>{let n=jc(r,t);if(!n)return!1;let i=As(n);if(!i)return!1;let o=i.nodeAfter;if(Es(r,i,e,1))return!0;if(n.parent.content.size==0&&(kt(o,"start")||w.isSelectable(o))){let s=yn(r.doc,n.before(),n.after(),k.empty);if(s&&s.slice.size<s.to-s.from){if(e){let l=r.tr.step(s);l.setSelection(kt(o,"start")?D.findFrom(l.doc.resolve(l.mapping.map(i.pos)),1):w.create(l.doc,l.mapping.map(i.pos))),e(l.scrollIntoView())}return!0}}return o.isAtom&&i.depth==n.depth-1?(e&&e(r.tr.delete(i.pos,i.pos+o.nodeSize).scrollIntoView()),!0):!1},Gc=(r,e,t)=>{let{$head:n,empty:i}=r.selection,o=n;if(!i)return!1;if(n.parent.isTextblock){if(t?!t.endOfTextblock("forward",r):n.parentOffset<n.parent.content.size)return!1;o=As(n)}let s=o&&o.nodeAfter;return!s||!w.isSelectable(s)?!1:(e&&e(r.tr.setSelection(w.create(r.doc,o.pos)).scrollIntoView()),!0)};function As(r){if(!r.parent.type.spec.isolating)for(let e=r.depth-1;e>=0;e--){let t=r.node(e);if(r.index(e)+1<t.childCount)return r.doc.resolve(r.after(e+1));if(t.type.spec.isolating)break}return null}var Ts=(r,e)=>{let{$from:t,$to:n}=r.selection,i=t.blockRange(n),o=i&&Bt(i);return o==null?!1:(e&&e(r.tr.lift(i,o).scrollIntoView()),!0)},Yc=(r,e)=>{let{$head:t,$anchor:n}=r.selection;return!t.parent.type.spec.code||!t.sameParent(n)?!1:(e&&e(r.tr.insertText(`
|
|
10
|
+
`).scrollIntoView()),!0)};function Yr(r){for(let e=0;e<r.edgeCount;e++){let{type:t}=r.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}var Ln=(r,e)=>{let{$head:t,$anchor:n}=r.selection;if(!t.parent.type.spec.code||!t.sameParent(n))return!1;let i=t.node(-1),o=t.indexAfter(-1),s=Yr(i.contentMatchAt(o));if(!s||!i.canReplaceWith(o,o,s))return!1;if(e){let l=t.after(),a=r.tr.replaceWith(l,l,s.createAndFill());a.setSelection(D.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},Xc=(r,e)=>{let t=r.selection,{$from:n,$to:i}=t;if(t instanceof he||n.parent.inlineContent||i.parent.inlineContent)return!1;let o=Yr(i.parent.contentMatchAt(i.indexAfter()));if(!o||!o.isTextblock)return!1;if(e){let s=(!n.parentOffset&&i.index()<i.parent.childCount?n:i).pos,l=r.tr.insert(s,o.createAndFill());l.setSelection(T.create(l.doc,s+1)),e(l.scrollIntoView())}return!0},Qc=(r,e)=>{let{$cursor:t}=r.selection;if(!t||t.parent.content.size)return!1;if(t.depth>1&&t.after()!=t.end(-1)){let o=t.before();if(Ft(r.doc,o))return e&&e(r.tr.split(o).scrollIntoView()),!0}let n=t.blockRange(),i=n&&Bt(n);return i==null?!1:(e&&e(r.tr.lift(n,i).scrollIntoView()),!0)};function Zc(r){return(e,t)=>{if(e.selection instanceof w&&e.selection.node.isBlock){let{$from:p}=e.selection;return!p.parentOffset||!Ft(e.doc,p.pos)?!1:(t&&t(e.tr.split(p.pos).scrollIntoView()),!0)}if(!e.selection.$from.depth)return!1;let n=e.tr;!e.selection.empty&&(e.selection instanceof T||e.selection instanceof he)&&n.deleteSelection();let{$from:i}=n.selection,o=n.steps.length,s=[],l,a,c=!1,f=!1;for(let p=i.depth;;p--)if(i.node(p).isBlock){c=i.end(p)==i.pos+(i.depth-p),f=i.start(p)==i.pos-(i.depth-p),a=Yr(i.node(p-1).contentMatchAt(i.indexAfter(p-1)));let m=r&&r(i.parent,c,i);s.unshift(m||(c&&a?{type:a}:null)),l=p;break}else{if(p==1)return!1;s.unshift(null)}let h=i.pos,d=Ft(n.doc,h,s.length,s);if(d||(s[0]=a?{type:a}:null,d=Ft(n.doc,h,s.length,s)),!d)return!1;if(n.split(h,s.length,s),!c&&f&&i.node(l).type!=a){let p=n.mapping.slice(o),u=p.map(i.before(l)),m=n.doc.resolve(u);a&&i.node(l-1).canReplaceWith(m.index(),m.index()+1,a)&&n.setNodeMarkup(p.map(i.before(l)),a)}return t&&t(n.scrollIntoView()),!0}}var ef=Zc();var tf=(r,e)=>(e&&e(r.tr.setSelection(new he(r.doc))),!0);function nf(r,e,t){let n=e.nodeBefore,i=e.nodeAfter,o=e.index();return!n||!i||!n.type.compatibleContent(i.type)?!1:!n.content.size&&e.parent.canReplace(o-1,o)?(t&&t(r.tr.delete(e.pos-n.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(o,o+1)||!(i.isTextblock||Vt(r.doc,e.pos))?!1:(t&&t(r.tr.join(e.pos).scrollIntoView()),!0)}function Es(r,e,t,n){let i=e.nodeBefore,o=e.nodeAfter,s,l,a=i.type.spec.isolating||o.type.spec.isolating;if(!a&&nf(r,e,t))return!0;let c=!a&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(s=(l=i.contentMatchAt(i.childCount)).findWrapping(o.type))&&l.matchType(s[0]||o.type).validEnd){if(t){let p=e.pos+o.nodeSize,u=S.empty;for(let b=s.length-1;b>=0;b--)u=S.from(s[b].create(null,u));u=S.from(i.copy(u));let m=r.tr.step(new fe(e.pos-1,p,e.pos,p,new k(u,1,0),s.length,!0)),g=m.doc.resolve(p+2*s.length);g.nodeAfter&&g.nodeAfter.type==i.type&&Vt(m.doc,g.pos)&&m.join(g.pos),t(m.scrollIntoView())}return!0}let f=o.type.spec.isolating||n>0&&a?null:D.findFrom(e,1),h=f&&f.$from.blockRange(f.$to),d=h&&Bt(h);if(d!=null&&d>=e.depth)return t&&t(r.tr.lift(h,d).scrollIntoView()),!0;if(c&&kt(o,"start",!0)&&kt(i,"end")){let p=i,u=[];for(;u.push(p),!p.isTextblock;)p=p.lastChild;let m=o,g=1;for(;!m.isTextblock;m=m.firstChild)g++;if(p.canReplace(p.childCount,p.childCount,m.content)){if(t){let b=S.empty;for(let C=u.length-1;C>=0;C--)b=S.from(u[C].copy(b));let I=r.tr.step(new fe(e.pos-u.length,e.pos+o.nodeSize,e.pos+g,e.pos+o.nodeSize-g,new k(b,u.length,0),0,!0));t(I.scrollIntoView())}return!0}}return!1}function Rs(r){return function(e,t){let n=e.selection,i=r<0?n.$from:n.$to,o=i.depth;for(;i.node(o).isInline;){if(!o)return!1;o--}return i.node(o).isTextblock?(t&&t(e.tr.setSelection(T.create(e.doc,r<0?i.start(o):i.end(o)))),!0):!1}}var rf=Rs(-1),of=Rs(1);function Is(r,e=null){return function(t,n){let{$from:i,$to:o}=t.selection,s=i.blockRange(o),l=s&&mn(s,r,e);return l?(n&&n(t.tr.wrap(s,l).scrollIntoView()),!0):!1}}function xt(r,e=null){return function(t,n){let i=!1;for(let o=0;o<t.selection.ranges.length&&!i;o++){let{$from:{pos:s},$to:{pos:l}}=t.selection.ranges[o];t.doc.nodesBetween(s,l,(a,c)=>{if(i)return!1;if(!(!a.isTextblock||a.hasMarkup(r,e)))if(a.type==r)i=!0;else{let f=t.doc.resolve(c),h=f.index();i=f.parent.canReplaceWith(h,h+1,r)}})}if(!i)return!1;if(n){let o=t.tr;for(let s=0;s<t.selection.ranges.length;s++){let{$from:{pos:l},$to:{pos:a}}=t.selection.ranges[s];o.setBlockType(l,a,r,e)}n(o.scrollIntoView())}return!0}}function sf(r,e,t,n){for(let i=0;i<e.length;i++){let{$from:o,$to:s}=e[i],l=o.depth==0?r.inlineContent&&r.type.allowsMarkType(t):!1;if(r.nodesBetween(o.pos,s.pos,(a,c)=>{if(l||!n&&a.isAtom&&a.isInline&&c>=o.pos&&c+a.nodeSize<=s.pos)return!1;l=a.inlineContent&&a.type.allowsMarkType(t)}),l)return!0}return!1}function lf(r){let e=[];for(let t=0;t<r.length;t++){let{$from:n,$to:i}=r[t];n.doc.nodesBetween(n.pos,i.pos,(o,s)=>{if(o.isAtom&&o.content.size&&o.isInline&&s>=n.pos&&s+o.nodeSize<=i.pos)return s+1>n.pos&&e.push(new Be(n,n.doc.resolve(s+1))),n=n.doc.resolve(s+1+o.content.size),!1}),n.pos<i.pos&&e.push(new Be(n,i))}return e}function st(r,e=null,t){let n=(t&&t.removeWhenPresent)!==!1,i=(t&&t.enterInlineAtoms)!==!1,o=!(t&&t.includeWhitespace);return function(s,l){let{empty:a,$cursor:c,ranges:f}=s.selection;if(a&&!c||!sf(s.doc,f,r,i))return!1;if(l)if(c)r.isInSet(s.storedMarks||c.marks())?l(s.tr.removeStoredMark(r)):l(s.tr.addStoredMark(r.create(e)));else{let h,d=s.tr;i||(f=lf(f)),n?h=!f.some(p=>s.doc.rangeHasMark(p.$from.pos,p.$to.pos,r)):h=!f.every(p=>{let u=!1;return d.doc.nodesBetween(p.$from.pos,p.$to.pos,(m,g,b)=>{if(u)return!1;u=!r.isInSet(m.marks)&&!!b&&b.type.allowsMarkType(r)&&!(m.isText&&/^\s*$/.test(m.textBetween(Math.max(0,p.$from.pos-g),Math.min(m.nodeSize,p.$to.pos-g))))}),!u});for(let p=0;p<f.length;p++){let{$from:u,$to:m}=f[p];if(!h)d.removeMark(u.pos,m.pos,r);else{let g=u.pos,b=m.pos,I=u.nodeAfter,C=m.nodeBefore,V=o&&I&&I.isText?/^\s*/.exec(I.text)[0].length:0,J=o&&C&&C.isText?/\s*$/.exec(C.text)[0].length:0;g+V<b&&(g+=V,b-=J),d.addMark(g,b,r.create(e))}}l(d.scrollIntoView())}return!0}}function lt(...r){return function(e,t,n){for(let i=0;i<r.length;i++)if(r[i](e,t,n))return!0;return!1}}var Gr=lt(Ns,Kc,_c),Os=lt(Ns,Uc,Gc),ve={Enter:lt(Yc,Xc,Qc,ef),"Mod-Enter":Ln,Backspace:Gr,"Mod-Backspace":Gr,"Shift-Backspace":Gr,Delete:Os,"Mod-Delete":Os,"Mod-a":tf},vs={"Ctrl-h":ve.Backspace,"Alt-Backspace":ve["Mod-Backspace"],"Ctrl-d":ve.Delete,"Ctrl-Alt-Backspace":ve["Mod-Delete"],"Alt-Delete":ve["Mod-Delete"],"Alt-d":ve["Mod-Delete"],"Ctrl-a":rf,"Ctrl-e":of};for(let r in ve)vs[r]=ve[r];var af=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform?os.platform()=="darwin":!1,zs=af?vs:ve;var Qr,Zr;if(typeof WeakMap<"u"){let r=new WeakMap;Qr=e=>r.get(e),Zr=(e,t)=>(r.set(e,t),t)}else{let r=[],t=0;Qr=n=>{for(let i=0;i<r.length;i+=2)if(r[i]==n)return r[i+1]},Zr=(n,i)=>(t==10&&(t=0),r[t++]=n,r[t++]=i)}var Q=class{constructor(r,e,t,n){this.width=r,this.height=e,this.map=t,this.problems=n}findCell(r){for(let e=0;e<this.map.length;e++){let t=this.map[e];if(t!=r)continue;let n=e%this.width,i=e/this.width|0,o=n+1,s=i+1;for(let l=1;o<this.width&&this.map[e+l]==t;l++)o++;for(let l=1;s<this.height&&this.map[e+this.width*l]==t;l++)s++;return{left:n,top:i,right:o,bottom:s}}throw new RangeError(`No cell with offset ${r} found`)}colCount(r){for(let e=0;e<this.map.length;e++)if(this.map[e]==r)return e%this.width;throw new RangeError(`No cell with offset ${r} found`)}nextCell(r,e,t){let{left:n,right:i,top:o,bottom:s}=this.findCell(r);return e=="horiz"?(t<0?n==0:i==this.width)?null:this.map[o*this.width+(t<0?n-1:i)]:(t<0?o==0:s==this.height)?null:this.map[n+this.width*(t<0?o-1:s)]}rectBetween(r,e){let{left:t,right:n,top:i,bottom:o}=this.findCell(r),{left:s,right:l,top:a,bottom:c}=this.findCell(e);return{left:Math.min(t,s),top:Math.min(i,a),right:Math.max(n,l),bottom:Math.max(o,c)}}cellsInRect(r){let e=[],t={};for(let n=r.top;n<r.bottom;n++)for(let i=r.left;i<r.right;i++){let o=n*this.width+i,s=this.map[o];t[s]||(t[s]=!0,!(i==r.left&&i&&this.map[o-1]==s||n==r.top&&n&&this.map[o-this.width]==s)&&e.push(s))}return e}positionAt(r,e,t){for(let n=0,i=0;;n++){let o=i+t.child(n).nodeSize;if(n==r){let s=e+r*this.width,l=(r+1)*this.width;for(;s<l&&this.map[s]<i;)s++;return s==l?o-1:this.map[s]}i=o}}static get(r){return Qr(r)||Zr(r,cf(r))}};function cf(r){if(r.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+r.type.name);let e=ff(r),t=r.childCount,n=[],i=0,o=null,s=[];for(let c=0,f=e*t;c<f;c++)n[c]=0;for(let c=0,f=0;c<t;c++){let h=r.child(c);f++;for(let u=0;;u++){for(;i<n.length&&n[i]!=0;)i++;if(u==h.childCount)break;let m=h.child(u),{colspan:g,rowspan:b,colwidth:I}=m.attrs;for(let C=0;C<b;C++){if(C+c>=t){(o||(o=[])).push({type:"overlong_rowspan",pos:f,n:b-C});break}let V=i+C*e;for(let J=0;J<g;J++){n[V+J]==0?n[V+J]=f:(o||(o=[])).push({type:"collision",row:c,pos:f,n:g-J});let N=I&&I[J];if(N){let O=(V+J)%e*2,F=s[O];F==null||F!=N&&s[O+1]==1?(s[O]=N,s[O+1]=1):F==N&&s[O+1]++}}}i+=g,f+=m.nodeSize}let d=(c+1)*e,p=0;for(;i<d;)n[i++]==0&&p++;p&&(o||(o=[])).push({type:"missing",row:c,n:p}),f++}(e===0||t===0)&&(o||(o=[])).push({type:"zero_sized"});let l=new Q(e,t,n,o),a=!1;for(let c=0;!a&&c<s.length;c+=2)s[c]!=null&&s[c+1]<t&&(a=!0);return a&&hf(l,s,r),l}function ff(r){let e=-1,t=!1;for(let n=0;n<r.childCount;n++){let i=r.child(n),o=0;if(t)for(let s=0;s<n;s++){let l=r.child(s);for(let a=0;a<l.childCount;a++){let c=l.child(a);s+c.attrs.rowspan>n&&(o+=c.attrs.colspan)}}for(let s=0;s<i.childCount;s++){let l=i.child(s);o+=l.attrs.colspan,l.attrs.rowspan>1&&(t=!0)}e==-1?e=o:e!=o&&(e=Math.max(e,o))}return e}function hf(r,e,t){r.problems||(r.problems=[]);let n={};for(let i=0;i<r.map.length;i++){let o=r.map[i];if(n[o])continue;n[o]=!0;let s=t.nodeAt(o);if(!s)throw new RangeError(`No cell with offset ${o} found`);let l=null,a=s.attrs;for(let c=0;c<a.colspan;c++){let f=e[(i+c)%r.width*2];f!=null&&(!a.colwidth||a.colwidth[c]!=f)&&((l||(l=uf(a)))[c]=f)}l&&r.problems.unshift({type:"colwidth mismatch",pos:o,colwidth:l})}}function uf(r){if(r.colwidth)return r.colwidth.slice();let e=[];for(let t=0;t<r.colspan;t++)e.push(0);return e}function Ps(r,e){if(typeof r=="string")return{};let t=r.getAttribute("data-colwidth"),n=t&&/^\d+(,\d+)*$/.test(t)?t.split(",").map(s=>Number(s)):null,i=Number(r.getAttribute("colspan")||1),o={colspan:i,rowspan:Number(r.getAttribute("rowspan")||1),colwidth:n&&n.length==i?n:null};for(let s in e){let l=e[s].getFromDOM,a=l&&l(r);a!=null&&(o[s]=a)}return o}function Bs(r,e){let t={};r.attrs.colspan!=1&&(t.colspan=r.attrs.colspan),r.attrs.rowspan!=1&&(t.rowspan=r.attrs.rowspan),r.attrs.colwidth&&(t["data-colwidth"]=r.attrs.colwidth.join(","));for(let n in e){let i=e[n].setDOMAttr;i&&i(r.attrs[n],t)}return t}function df(r){if(r!==null){if(!Array.isArray(r))throw new TypeError("colwidth must be null or an array");for(let e of r)if(typeof e!="number")throw new TypeError("colwidth must be null or an array of numbers")}}function qs(r){let e=r.cellAttributes||{},t={colspan:{default:1,validate:"number"},rowspan:{default:1,validate:"number"},colwidth:{default:null,validate:df}};for(let n in e)t[n]={default:e[n].default,validate:e[n].validate};return{table:{content:"table_row+",tableRole:"table",isolating:!0,group:r.tableGroup,parseDOM:[{tag:"table"}],toDOM(){return["table",["tbody",0]]}},table_row:{content:"(table_cell | table_header)*",tableRole:"row",parseDOM:[{tag:"tr"}],toDOM(){return["tr",0]}},table_cell:{content:r.cellContent,attrs:t,tableRole:"cell",isolating:!0,parseDOM:[{tag:"td",getAttrs:n=>Ps(n,e)}],toDOM(n){return["td",Bs(n,e),0]}},table_header:{content:r.cellContent,attrs:t,tableRole:"header_cell",isolating:!0,parseDOM:[{tag:"th",getAttrs:n=>Ps(n,e)}],toDOM(n){return["th",Bs(n,e),0]}}}}function ae(r){let e=r.cached.tableNodeTypes;if(!e){e=r.cached.tableNodeTypes={};for(let t in r.nodes){let n=r.nodes[t],i=n.spec.tableRole;i&&(e[i]=n)}}return e}var qe=new me("selectingCells");function en(r){for(let e=r.depth-1;e>0;e--)if(r.node(e).type.spec.tableRole=="row")return r.node(0).resolve(r.before(e+1));return null}function Ce(r){let e=r.selection.$head;for(let t=e.depth;t>0;t--)if(e.node(t).type.spec.tableRole=="row")return!0;return!1}function ti(r){let e=r.selection;if("$anchorCell"in e&&e.$anchorCell)return e.$anchorCell.pos>e.$headCell.pos?e.$anchorCell:e.$headCell;if("node"in e&&e.node&&e.node.type.spec.tableRole=="cell")return e.$anchor;let t=en(e.$head)||pf(e.$head);if(t)return t;throw new RangeError(`No cell found around position ${e.head}`)}function pf(r){for(let e=r.nodeAfter,t=r.pos;e;e=e.firstChild,t++){let n=e.type.spec.tableRole;if(n=="cell"||n=="header_cell")return r.doc.resolve(t)}for(let e=r.nodeBefore,t=r.pos;e;e=e.lastChild,t--){let n=e.type.spec.tableRole;if(n=="cell"||n=="header_cell")return r.doc.resolve(t-e.nodeSize)}}function Fs(r){return r.parent.type.spec.tableRole=="row"&&!!r.nodeAfter}function mf(r){return r.node(0).resolve(r.pos+r.nodeAfter.nodeSize)}function ni(r,e){return r.depth==e.depth&&r.pos>=e.start(-1)&&r.pos<=e.end(-1)}function Hs(r,e,t){let n=r.node(-1),i=Q.get(n),o=r.start(-1),s=i.nextCell(r.pos-o,e,t);return s==null?null:r.node(0).resolve(o+s)}function at(r,e,t=1){let n={...r,colspan:r.colspan-t};return n.colwidth&&(n.colwidth=n.colwidth.slice(),n.colwidth.splice(e,t),n.colwidth.some(i=>i>0)||(n.colwidth=null)),n}function gf(r,e,t=1){let n={...r,colspan:r.colspan+t};if(n.colwidth){n.colwidth=n.colwidth.slice();for(let i=0;i<t;i++)n.colwidth.splice(e,0,0)}return n}function yf(r,e,t){let n=ae(e.type.schema).header_cell;for(let i=0;i<r.height;i++)if(e.nodeAt(r.map[t+i*r.width]).type!=n)return!1;return!0}var _=class ze extends D{constructor(e,t=e){let n=e.node(-1),i=Q.get(n),o=e.start(-1),s=i.rectBetween(e.pos-o,t.pos-o),l=e.node(0),a=i.cellsInRect(s).filter(f=>f!=t.pos-o);a.unshift(t.pos-o);let c=a.map(f=>{let h=n.nodeAt(f);if(!h)throw new RangeError(`No cell with offset ${f} found`);let d=o+f+1;return new Be(l.resolve(d),l.resolve(d+h.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=t}map(e,t){let n=e.resolve(t.map(this.$anchorCell.pos)),i=e.resolve(t.map(this.$headCell.pos));if(Fs(n)&&Fs(i)&&ni(n,i)){let o=this.$anchorCell.node(-1)!=n.node(-1);return o&&this.isRowSelection()?ze.rowSelection(n,i):o&&this.isColSelection()?ze.colSelection(n,i):new ze(n,i)}return T.between(n,i)}content(){let e=this.$anchorCell.node(-1),t=Q.get(e),n=this.$anchorCell.start(-1),i=t.rectBetween(this.$anchorCell.pos-n,this.$headCell.pos-n),o={},s=[];for(let a=i.top;a<i.bottom;a++){let c=[];for(let f=a*t.width+i.left,h=i.left;h<i.right;h++,f++){let d=t.map[f];if(o[d])continue;o[d]=!0;let p=t.findCell(d),u=e.nodeAt(d);if(!u)throw new RangeError(`No cell with offset ${d} found`);let m=i.left-p.left,g=p.right-i.right;if(m>0||g>0){let b=u.attrs;if(m>0&&(b=at(b,0,m)),g>0&&(b=at(b,b.colspan-g,g)),p.left<i.left){if(u=u.type.createAndFill(b),!u)throw new RangeError(`Could not create cell with attrs ${JSON.stringify(b)}`)}else u=u.type.create(b,u.content)}if(p.top<i.top||p.bottom>i.bottom){let b={...u.attrs,rowspan:Math.min(p.bottom,i.bottom)-Math.max(p.top,i.top)};p.top<i.top?u=u.type.createAndFill(b):u=u.type.create(b,u.content)}c.push(u)}s.push(e.child(a).copy(S.from(c)))}let l=this.isColSelection()&&this.isRowSelection()?e:s;return new k(S.from(l),1,1)}replace(e,t=k.empty){let n=e.steps.length,i=this.ranges;for(let s=0;s<i.length;s++){let{$from:l,$to:a}=i[s],c=e.mapping.slice(n);e.replace(c.map(l.pos),c.map(a.pos),s?k.empty:t)}let o=D.findFrom(e.doc.resolve(e.mapping.slice(n).map(this.to)),-1);o&&e.setSelection(o)}replaceWith(e,t){this.replace(e,new k(S.from(t),0,0))}forEachCell(e){let t=this.$anchorCell.node(-1),n=Q.get(t),i=this.$anchorCell.start(-1),o=n.cellsInRect(n.rectBetween(this.$anchorCell.pos-i,this.$headCell.pos-i));for(let s=0;s<o.length;s++)e(t.nodeAt(o[s]),i+o[s])}isColSelection(){let e=this.$anchorCell.index(-1),t=this.$headCell.index(-1);if(Math.min(e,t)>0)return!1;let n=e+this.$anchorCell.nodeAfter.attrs.rowspan,i=t+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(n,i)==this.$headCell.node(-1).childCount}static colSelection(e,t=e){let n=e.node(-1),i=Q.get(n),o=e.start(-1),s=i.findCell(e.pos-o),l=i.findCell(t.pos-o),a=e.node(0);return s.top<=l.top?(s.top>0&&(e=a.resolve(o+i.map[s.left])),l.bottom<i.height&&(t=a.resolve(o+i.map[i.width*(i.height-1)+l.right-1]))):(l.top>0&&(t=a.resolve(o+i.map[l.left])),s.bottom<i.height&&(e=a.resolve(o+i.map[i.width*(i.height-1)+s.right-1]))),new ze(e,t)}isRowSelection(){let e=this.$anchorCell.node(-1),t=Q.get(e),n=this.$anchorCell.start(-1),i=t.colCount(this.$anchorCell.pos-n),o=t.colCount(this.$headCell.pos-n);if(Math.min(i,o)>0)return!1;let s=i+this.$anchorCell.nodeAfter.attrs.colspan,l=o+this.$headCell.nodeAfter.attrs.colspan;return Math.max(s,l)==t.width}eq(e){return e instanceof ze&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,t=e){let n=e.node(-1),i=Q.get(n),o=e.start(-1),s=i.findCell(e.pos-o),l=i.findCell(t.pos-o),a=e.node(0);return s.left<=l.left?(s.left>0&&(e=a.resolve(o+i.map[s.top*i.width])),l.right<i.width&&(t=a.resolve(o+i.map[i.width*(l.top+1)-1]))):(l.left>0&&(t=a.resolve(o+i.map[l.top*i.width])),s.right<i.width&&(e=a.resolve(o+i.map[i.width*(s.top+1)-1]))),new ze(e,t)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,t){return new ze(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,n=t){return new ze(e.resolve(t),e.resolve(n))}getBookmark(){return new bf(this.$anchorCell.pos,this.$headCell.pos)}};_.prototype.visible=!1;D.jsonID("cell",_);var bf=class Ks{constructor(e,t){this.anchor=e,this.head=t}map(e){return new Ks(e.map(this.anchor),e.map(this.head))}resolve(e){let t=e.resolve(this.anchor),n=e.resolve(this.head);return t.parent.type.spec.tableRole=="row"&&n.parent.type.spec.tableRole=="row"&&t.index()<t.parent.childCount&&n.index()<n.parent.childCount&&ni(t,n)?new _(t,n):D.near(n,1)}};function Sf(r){if(!(r.selection instanceof _))return null;let e=[];return r.selection.forEachCell((t,n)=>{e.push(Y.node(n,n+t.nodeSize,{class:"selectedCell"}))}),K.create(r.doc,e)}function kf({$from:r,$to:e}){if(r.pos==e.pos||r.pos<e.pos-6)return!1;let t=r.pos,n=e.pos,i=r.depth;for(;i>=0&&!(r.after(i+1)<r.end(i));i--,t++);for(let o=e.depth;o>=0&&!(e.before(o+1)>e.start(o));o--,n--);return t==n&&/row|table/.test(r.node(i).type.spec.tableRole)}function xf({$from:r,$to:e}){let t,n;for(let i=r.depth;i>0;i--){let o=r.node(i);if(o.type.spec.tableRole==="cell"||o.type.spec.tableRole==="header_cell"){t=o;break}}for(let i=e.depth;i>0;i--){let o=e.node(i);if(o.type.spec.tableRole==="cell"||o.type.spec.tableRole==="header_cell"){n=o;break}}return t!==n&&e.parentOffset===0}function Cf(r,e,t){let n=(e||r).selection,i=(e||r).doc,o,s;if(n instanceof w&&(s=n.node.type.spec.tableRole)){if(s=="cell"||s=="header_cell")o=_.create(i,n.from);else if(s=="row"){let l=i.resolve(n.from+1);o=_.rowSelection(l,l)}else if(!t){let l=Q.get(n.node),a=n.from+1,c=a+l.map[l.width*l.height-1];o=_.create(i,a+1,c)}}else n instanceof T&&kf(n)?o=T.create(i,n.from):n instanceof T&&xf(n)&&(o=T.create(i,n.$from.start(),n.$from.end()));return o&&(e||(e=r.tr)).setSelection(o),e}var wf=new me("fix-tables");function _s(r,e,t,n){let i=r.childCount,o=e.childCount;e:for(let s=0,l=0;s<o;s++){let a=e.child(s);for(let c=l,f=Math.min(i,s+3);c<f;c++)if(r.child(c)==a){l=c+1,t+=a.nodeSize;continue e}n(a,t),l<i&&r.child(l).sameMarkup(a)?_s(r.child(l),a,t+1,n):a.nodesBetween(0,a.content.size,n,t+1),t+=a.nodeSize}}function Mf(r,e){let t,n=(i,o)=>{i.type.spec.tableRole=="table"&&(t=Of(r,i,o,t))};return e?e.doc!=r.doc&&_s(e.doc,r.doc,0,n):r.doc.descendants(n),t}function Of(r,e,t,n){let i=Q.get(e);if(!i.problems)return n;n||(n=r.tr);let o=[];for(let a=0;a<i.height;a++)o.push(0);for(let a=0;a<i.problems.length;a++){let c=i.problems[a];if(c.type=="collision"){let f=e.nodeAt(c.pos);if(!f)continue;let h=f.attrs;for(let d=0;d<h.rowspan;d++)o[c.row+d]+=c.n;n.setNodeMarkup(n.mapping.map(t+1+c.pos),null,at(h,h.colspan-c.n,c.n))}else if(c.type=="missing")o[c.row]+=c.n;else if(c.type=="overlong_rowspan"){let f=e.nodeAt(c.pos);if(!f)continue;n.setNodeMarkup(n.mapping.map(t+1+c.pos),null,{...f.attrs,rowspan:f.attrs.rowspan-c.n})}else if(c.type=="colwidth mismatch"){let f=e.nodeAt(c.pos);if(!f)continue;n.setNodeMarkup(n.mapping.map(t+1+c.pos),null,{...f.attrs,colwidth:c.colwidth})}else if(c.type=="zero_sized"){let f=n.mapping.map(t);n.delete(f,f+e.nodeSize)}}let s,l;for(let a=0;a<o.length;a++)o[a]&&(s==null&&(s=a),l=a);for(let a=0,c=t+1;a<i.height;a++){let f=e.child(a),h=c+f.nodeSize,d=o[a];if(d>0){let p="cell";f.firstChild&&(p=f.firstChild.type.spec.tableRole);let u=[];for(let g=0;g<d;g++){let b=ae(r.schema)[p].createAndFill();b&&u.push(b)}let m=(a==0||s==a-1)&&l==a?c+1:h-1;n.insert(n.mapping.map(m),u)}c=h}return n.setMeta(wf,{fixTables:!0})}function Ct(r){let e=r.selection,t=ti(r),n=t.node(-1),i=t.start(-1),o=Q.get(n);return{...e instanceof _?o.rectBetween(e.$anchorCell.pos-i,e.$headCell.pos-i):o.findCell(t.pos-i),tableStart:i,map:o,table:n}}function Nf(r,{map:e,tableStart:t,table:n},i){let o=i>0?-1:0;yf(e,n,i+o)&&(o=i==0||i==e.width?null:0);for(let s=0;s<e.height;s++){let l=s*e.width+i;if(i>0&&i<e.width&&e.map[l-1]==e.map[l]){let a=e.map[l],c=n.nodeAt(a);r.setNodeMarkup(r.mapping.map(t+a),null,gf(c.attrs,i-e.colCount(a))),s+=c.attrs.rowspan-1}else{let a=o==null?ae(n.type.schema).cell:n.nodeAt(e.map[l+o]).type,c=e.positionAt(s,i,n);r.insert(r.mapping.map(t+c),a.createAndFill())}}return r}function js(r,e){if(!Ce(r))return!1;if(e){let t=Ct(r);e(Nf(r.tr,t,t.right))}return!0}function Df(r,{map:e,table:t,tableStart:n},i){let o=r.mapping.maps.length;for(let s=0;s<e.height;){let l=s*e.width+i,a=e.map[l],c=t.nodeAt(a),f=c.attrs;if(i>0&&e.map[l-1]==a||i<e.width-1&&e.map[l+1]==a)r.setNodeMarkup(r.mapping.slice(o).map(n+a),null,at(f,i-e.colCount(a)));else{let h=r.mapping.slice(o).map(n+a);r.delete(h,h+c.nodeSize)}s+=f.rowspan}}function Us(r,e){if(!Ce(r))return!1;if(e){let t=Ct(r),n=r.tr;if(t.left==0&&t.right==t.map.width)return!1;for(let i=t.right-1;Df(n,t,i),i!=t.left;i--){let o=t.tableStart?n.doc.nodeAt(t.tableStart-1):n.doc;if(!o)throw new RangeError("No table found");t.table=o,t.map=Q.get(o)}e(n)}return!0}function Af(r,e,t){var n;let i=ae(e.type.schema).header_cell;for(let o=0;o<r.width;o++)if(((n=e.nodeAt(r.map[o+t*r.width]))===null||n===void 0?void 0:n.type)!=i)return!1;return!0}function Tf(r,{map:e,tableStart:t,table:n},i){let o=t;for(let c=0;c<i;c++)o+=n.child(c).nodeSize;let s=[],l=i>0?-1:0;Af(e,n,i+l)&&(l=i==0||i==e.height?null:0);for(let c=0,f=e.width*i;c<e.width;c++,f++)if(i>0&&i<e.height&&e.map[f]==e.map[f-e.width]){let h=e.map[f],d=n.nodeAt(h).attrs;r.setNodeMarkup(t+h,null,{...d,rowspan:d.rowspan+1}),c+=d.colspan-1}else{var a;let h=l==null?ae(n.type.schema).cell:(a=n.nodeAt(e.map[f+l*e.width]))===null||a===void 0?void 0:a.type,d=h?.createAndFill();d&&s.push(d)}return r.insert(o,ae(n.type.schema).row.create(null,s)),r}function Gs(r,e){if(!Ce(r))return!1;if(e){let t=Ct(r);e(Tf(r.tr,t,t.bottom))}return!0}function Ef(r,{map:e,table:t,tableStart:n},i){let o=0;for(let c=0;c<i;c++)o+=t.child(c).nodeSize;let s=o+t.child(i).nodeSize,l=r.mapping.maps.length;r.delete(o+n,s+n);let a=new Set;for(let c=0,f=i*e.width;c<e.width;c++,f++){let h=e.map[f];if(!a.has(h)){if(a.add(h),i>0&&h==e.map[f-e.width]){let d=t.nodeAt(h).attrs;r.setNodeMarkup(r.mapping.slice(l).map(h+n),null,{...d,rowspan:d.rowspan-1}),c+=d.colspan-1}else if(i<e.height&&h==e.map[f+e.width]){let d=t.nodeAt(h),p=d.attrs,u=d.type.create({...p,rowspan:d.attrs.rowspan-1},d.content),m=e.positionAt(i+1,c,t);r.insert(r.mapping.slice(l).map(n+m),u),c+=p.colspan-1}}}}function Ys(r,e){if(!Ce(r))return!1;if(e){let t=Ct(r),n=r.tr;if(t.top==0&&t.bottom==t.map.height)return!1;for(let i=t.bottom-1;Ef(n,t,i),i!=t.top;i--){let o=t.tableStart?n.doc.nodeAt(t.tableStart-1):n.doc;if(!o)throw new RangeError("No table found");t.table=o,t.map=Q.get(t.table)}e(n)}return!0}function Rf(r){return function(e,t){if(!Ce(e))return!1;if(t){let n=ae(e.schema),i=Ct(e),o=e.tr,s=i.map.cellsInRect(r=="column"?{left:i.left,top:0,right:i.right,bottom:i.map.height}:r=="row"?{left:0,top:i.top,right:i.map.width,bottom:i.bottom}:i),l=s.map(a=>i.table.nodeAt(a));for(let a=0;a<s.length;a++)l[a].type==n.header_cell&&o.setNodeMarkup(i.tableStart+s[a],n.cell,l[a].attrs);if(o.steps.length===0)for(let a=0;a<s.length;a++)o.setNodeMarkup(i.tableStart+s[a],n.header_cell,l[a].attrs);t(o)}return!0}}function Vs(r,e,t){let n=e.map.cellsInRect({left:0,top:0,right:r=="row"?e.map.width:1,bottom:r=="column"?e.map.height:1});for(let i=0;i<n.length;i++){let o=e.table.nodeAt(n[i]);if(o&&o.type!==t.header_cell)return!1}return!0}function ri(r,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?Rf(r):function(t,n){if(!Ce(t))return!1;if(n){let i=ae(t.schema),o=Ct(t),s=t.tr,l=Vs("row",o,i),a=Vs("column",o,i),c=(r==="column"?l:r==="row"&&a)?1:0,f=r=="column"?{left:0,top:c,right:1,bottom:o.map.height}:r=="row"?{left:c,top:0,right:o.map.width,bottom:1}:o,h=r=="column"?a?i.cell:i.header_cell:r=="row"?l?i.cell:i.header_cell:i.cell;o.map.cellsInRect(f).forEach(d=>{let p=d+o.tableStart,u=s.doc.nodeAt(p);u&&s.setNodeMarkup(p,h,u.attrs)}),n(s)}return!0}}var Fh=ri("row",{useDeprecatedLogic:!0}),Vh=ri("column",{useDeprecatedLogic:!0}),Lh=ri("cell",{useDeprecatedLogic:!0});function If(r,e){if(e<0){let t=r.nodeBefore;if(t)return r.pos-t.nodeSize;for(let n=r.index(-1)-1,i=r.before();n>=0;n--){let o=r.node(-1).child(n),s=o.lastChild;if(s)return i-1-s.nodeSize;i-=o.nodeSize}}else{if(r.index()<r.parent.childCount-1)return r.pos+r.nodeAfter.nodeSize;let t=r.node(-1);for(let n=r.indexAfter(-1),i=r.after();n<t.childCount;n++){let o=t.child(n);if(o.childCount)return i+1;i+=o.nodeSize}}return null}function ii(r){return function(e,t){if(!Ce(e))return!1;let n=If(ti(e),r);if(n==null)return!1;if(t){let i=e.doc.resolve(n);t(e.tr.setSelection(T.between(i,mf(i))).scrollIntoView())}return!0}}function Xs(r,e){let t=r.selection.$anchor;for(let n=t.depth;n>0;n--)if(t.node(n).type.spec.tableRole=="table")return e&&e(r.tr.delete(t.before(n),t.after(n)).scrollIntoView()),!0;return!1}function $n(r,e){let t=r.selection;if(!(t instanceof _))return!1;if(e){let n=r.tr,i=ae(r.schema).cell.createAndFill().content;t.forEachCell((o,s)=>{o.content.eq(i)||n.replace(n.mapping.map(s+1),n.mapping.map(s+o.nodeSize-1),new k(i,0,0))}),n.docChanged&&e(n)}return!0}function vf(r){if(r.size===0)return null;let{content:e,openStart:t,openEnd:n}=r;for(;e.childCount==1&&(t>0&&n>0||e.child(0).type.spec.tableRole=="table");)t--,n--,e=e.child(0).content;let i=e.child(0),o=i.type.spec.tableRole,s=i.type.schema,l=[];if(o=="row")for(let a=0;a<e.childCount;a++){let c=e.child(a).content,f=a?0:Math.max(0,t-1),h=a<e.childCount-1?0:Math.max(0,n-1);(f||h)&&(c=ei(ae(s).row,new k(c,f,h)).content),l.push(c)}else if(o=="cell"||o=="header_cell")l.push(t||n?ei(ae(s).row,new k(e,t,n)).content:e);else return null;return zf(s,l)}function zf(r,e){let t=[];for(let i=0;i<e.length;i++){let o=e[i];for(let s=o.childCount-1;s>=0;s--){let{rowspan:l,colspan:a}=o.child(s).attrs;for(let c=i;c<i+l;c++)t[c]=(t[c]||0)+a}}let n=0;for(let i=0;i<t.length;i++)n=Math.max(n,t[i]);for(let i=0;i<t.length;i++)if(i>=e.length&&e.push(S.empty),t[i]<n){let o=ae(r).cell.createAndFill(),s=[];for(let l=t[i];l<n;l++)s.push(o);e[i]=e[i].append(S.from(s))}return{height:e.length,width:n,rows:e}}function ei(r,e){let t=r.createAndFill();return new dt(t).replace(0,t.content.size,e).doc}function Pf({width:r,height:e,rows:t},n,i){if(r!=n){let o=[],s=[];for(let l=0;l<t.length;l++){let a=t[l],c=[];for(let f=o[l]||0,h=0;f<n;h++){let d=a.child(h%a.childCount);f+d.attrs.colspan>n&&(d=d.type.createChecked(at(d.attrs,d.attrs.colspan,f+d.attrs.colspan-n),d.content)),c.push(d),f+=d.attrs.colspan;for(let p=1;p<d.attrs.rowspan;p++)o[l+p]=(o[l+p]||0)+d.attrs.colspan}s.push(S.from(c))}t=s,r=n}if(e!=i){let o=[];for(let s=0,l=0;s<i;s++,l++){let a=[],c=t[l%e];for(let f=0;f<c.childCount;f++){let h=c.child(f);s+h.attrs.rowspan>i&&(h=h.type.create({...h.attrs,rowspan:Math.max(1,i-h.attrs.rowspan)},h.content)),a.push(h)}o.push(S.from(a))}t=o,e=i}return{width:r,height:e,rows:t}}function Bf(r,e,t,n,i,o,s){let l=r.doc.type.schema,a=ae(l),c,f;if(i>e.width)for(let h=0,d=0;h<e.height;h++){let p=t.child(h);d+=p.nodeSize;let u=[],m;p.lastChild==null||p.lastChild.type==a.cell?m=c||(c=a.cell.createAndFill()):m=f||(f=a.header_cell.createAndFill());for(let g=e.width;g<i;g++)u.push(m);r.insert(r.mapping.slice(s).map(d-1+n),u)}if(o>e.height){let h=[];for(let u=0,m=(e.height-1)*e.width;u<Math.max(e.width,i);u++){let g=u>=e.width?!1:t.nodeAt(e.map[m+u]).type==a.header_cell;h.push(g?f||(f=a.header_cell.createAndFill()):c||(c=a.cell.createAndFill()))}let d=a.row.create(null,S.from(h)),p=[];for(let u=e.height;u<o;u++)p.push(d);r.insert(r.mapping.slice(s).map(n+t.nodeSize-2),p)}return!!(c||f)}function Ls(r,e,t,n,i,o,s,l){if(s==0||s==e.height)return!1;let a=!1;for(let c=i;c<o;c++){let f=s*e.width+c,h=e.map[f];if(e.map[f-e.width]==h){a=!0;let d=t.nodeAt(h),{top:p,left:u}=e.findCell(h);r.setNodeMarkup(r.mapping.slice(l).map(h+n),null,{...d.attrs,rowspan:s-p}),r.insert(r.mapping.slice(l).map(e.positionAt(s,u,t)),d.type.createAndFill({...d.attrs,rowspan:p+d.attrs.rowspan-s})),c+=d.attrs.colspan-1}}return a}function $s(r,e,t,n,i,o,s,l){if(s==0||s==e.width)return!1;let a=!1;for(let c=i;c<o;c++){let f=c*e.width+s,h=e.map[f];if(e.map[f-1]==h){a=!0;let d=t.nodeAt(h),p=e.colCount(h),u=r.mapping.slice(l).map(h+n);r.setNodeMarkup(u,null,at(d.attrs,s-p,d.attrs.colspan-(s-p))),r.insert(u+d.nodeSize,d.type.createAndFill(at(d.attrs,0,s-p))),c+=d.attrs.rowspan-1}}return a}function Ws(r,e,t,n,i){let o=t?r.doc.nodeAt(t-1):r.doc;if(!o)throw new Error("No table found");let s=Q.get(o),{top:l,left:a}=n,c=a+i.width,f=l+i.height,h=r.tr,d=0;function p(){if(o=t?h.doc.nodeAt(t-1):h.doc,!o)throw new Error("No table found");s=Q.get(o),d=h.mapping.maps.length}Bf(h,s,o,t,c,f,d)&&p(),Ls(h,s,o,t,a,c,l,d)&&p(),Ls(h,s,o,t,a,c,f,d)&&p(),$s(h,s,o,t,l,f,a,d)&&p(),$s(h,s,o,t,l,f,c,d)&&p();for(let u=l;u<f;u++){let m=s.positionAt(u,a,o),g=s.positionAt(u,c,o);h.replace(h.mapping.slice(d).map(m+t),h.mapping.slice(d).map(g+t),new k(i.rows[u-l],0,0))}p(),h.setSelection(new _(h.doc.resolve(t+s.positionAt(l,a,o)),h.doc.resolve(t+s.positionAt(f-1,c-1,o)))),e(h)}var Ff=Zt({ArrowLeft:Wn("horiz",-1),ArrowRight:Wn("horiz",1),ArrowUp:Wn("vert",-1),ArrowDown:Wn("vert",1),"Shift-ArrowLeft":Jn("horiz",-1),"Shift-ArrowRight":Jn("horiz",1),"Shift-ArrowUp":Jn("vert",-1),"Shift-ArrowDown":Jn("vert",1),Backspace:$n,"Mod-Backspace":$n,Delete:$n,"Mod-Delete":$n});function qn(r,e,t){return t.eq(r.selection)?!1:(e&&e(r.tr.setSelection(t).scrollIntoView()),!0)}function Wn(r,e){return(t,n,i)=>{if(!i)return!1;let o=t.selection;if(o instanceof _)return qn(t,n,D.near(o.$headCell,e));if(r!="horiz"&&!o.empty)return!1;let s=Qs(i,r,e);if(s==null)return!1;if(r=="horiz")return qn(t,n,D.near(t.doc.resolve(o.head+e),e));{let l=t.doc.resolve(s),a=Hs(l,r,e),c;return a?c=D.near(a,1):e<0?c=D.near(t.doc.resolve(l.before(-1)),-1):c=D.near(t.doc.resolve(l.after(-1)),1),qn(t,n,c)}}}function Jn(r,e){return(t,n,i)=>{if(!i)return!1;let o=t.selection,s;if(o instanceof _)s=o;else{let a=Qs(i,r,e);if(a==null)return!1;s=new _(t.doc.resolve(a))}let l=Hs(s.$headCell,r,e);return l?qn(t,n,new _(s.$anchorCell,l)):!1}}function Vf(r,e){let t=r.state.doc,n=en(t.resolve(e));return n?(r.dispatch(r.state.tr.setSelection(new _(n))),!0):!1}function Lf(r,e,t){if(!Ce(r.state))return!1;let n=vf(t),i=r.state.selection;if(i instanceof _){n||(n={width:1,height:1,rows:[S.from(ei(ae(r.state.schema).cell,t))]});let o=i.$anchorCell.node(-1),s=i.$anchorCell.start(-1),l=Q.get(o).rectBetween(i.$anchorCell.pos-s,i.$headCell.pos-s);return n=Pf(n,l.right-l.left,l.bottom-l.top),Ws(r.state,r.dispatch,s,l,n),!0}else if(n){let o=ti(r.state),s=o.start(-1);return Ws(r.state,r.dispatch,s,Q.get(o.node(-1)).findCell(o.pos-s),n),!0}else return!1}function $f(r,e){var t;if(e.button!=0||e.ctrlKey||e.metaKey)return;let n=Js(r,e.target),i;if(e.shiftKey&&r.state.selection instanceof _)o(r.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&n&&(i=en(r.state.selection.$anchor))!=null&&((t=Xr(r,e))===null||t===void 0?void 0:t.pos)!=i.pos)o(i,e),e.preventDefault();else if(!n)return;function o(a,c){let f=Xr(r,c),h=qe.getState(r.state)==null;if(!f||!ni(a,f))if(h)f=a;else return;let d=new _(a,f);if(h||!r.state.selection.eq(d)){let p=r.state.tr.setSelection(d);h&&p.setMeta(qe,a.pos),r.dispatch(p)}}function s(){r.root.removeEventListener("mouseup",s),r.root.removeEventListener("dragstart",s),r.root.removeEventListener("mousemove",l),qe.getState(r.state)!=null&&r.dispatch(r.state.tr.setMeta(qe,-1))}function l(a){let c=a,f=qe.getState(r.state),h;if(f!=null)h=r.state.doc.resolve(f);else if(Js(r,c.target)!=n&&(h=Xr(r,e),!h))return s();h&&o(h,c)}r.root.addEventListener("mouseup",s),r.root.addEventListener("dragstart",s),r.root.addEventListener("mousemove",l)}function Qs(r,e,t){if(!(r.state.selection instanceof T))return null;let{$head:n}=r.state.selection;for(let i=n.depth-1;i>=0;i--){let o=n.node(i);if((t<0?n.index(i):n.indexAfter(i))!=(t<0?0:o.childCount))return null;if(o.type.spec.tableRole=="cell"||o.type.spec.tableRole=="header_cell"){let s=n.before(i),l=e=="vert"?t>0?"down":"up":t>0?"right":"left";return r.endOfTextblock(l)?s:null}}return null}function Js(r,e){for(;e&&e!=r.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function Xr(r,e){let t=r.posAtCoords({left:e.clientX,top:e.clientY});if(!t)return null;let{inside:n,pos:i}=t;return n>=0&&en(r.state.doc.resolve(n))||en(r.state.doc.resolve(i))}var $h=new me("tableColumnResizing");function Zs({allowTableNodeSelection:r=!1}={}){return new H({key:qe,state:{init(){return null},apply(e,t){let n=e.getMeta(qe);if(n!=null)return n==-1?null:n;if(t==null||!e.docChanged)return t;let{deleted:i,pos:o}=e.mapping.mapResult(t);return i?null:o}},props:{decorations:Sf,handleDOMEvents:{mousedown:$f},createSelectionBetween(e){return qe.getState(e.state)!=null?e.state.selection:null},handleTripleClick:Vf,handleKeyDown:Ff,handlePaste:Lf},appendTransaction(e,t,n){return Cf(n,Mf(n,t),r)}})}function el(r={}){return new H({view(e){return new oi(e,r)}})}var oi=class{constructor(e,t){var n;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.lastDragEvent=null,this.width=(n=t.width)!==null&&n!==void 0?n:1,this.color=t.color===!1?void 0:t.color||"black",this.class=t.class,this.handlers=["dragover","dragend","drop","dragleave"].map(i=>{let o=s=>{this[i](s)};return e.dom.addEventListener(i,o),{name:i,handler:o}})}destroy(){this.setCursor(null),this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){if(this.cursorPos!=null&&t.doc!=e.state.doc)if(this.lastDragEvent){let n=this.computeTarget(this.lastDragEvent);n==this.cursorPos?this.updateOverlay():this.setCursor(n)}else this.updateOverlay()}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),t=!e.parent.inlineContent,n,i=this.editorView.dom,o=i.getBoundingClientRect(),s=o.width/i.offsetWidth,l=o.height/i.offsetHeight;if(t){let h=e.nodeBefore,d=e.nodeAfter;if(h||d){let p=this.editorView.nodeDOM(this.cursorPos-(h?h.nodeSize:0));if(p){let u=p.getBoundingClientRect(),m=h?u.bottom:u.top;h&&d&&(m=(m+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let g=this.width/2*l;n={left:u.left,right:u.right,top:m-g,bottom:m+g}}}}if(!n){let h=this.editorView.coordsAtPos(this.cursorPos),d=this.width/2*s;n={left:h.left-d,right:h.left+d,top:h.top,bottom:h.bottom}}let a=this.editorView.dom.offsetParent;this.element||(this.element=a.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",t),this.element.classList.toggle("prosemirror-dropcursor-inline",!t);let c,f;if(!a||a==document.body&&getComputedStyle(a).position=="static")c=-pageXOffset,f=-pageYOffset;else{let h=a.getBoundingClientRect(),d=h.width/a.offsetWidth,p=h.height/a.offsetHeight;c=h.left-a.scrollLeft*d,f=h.top-a.scrollTop*p}this.element.style.left=(n.left-c)/s+"px",this.element.style.top=(n.top-f)/l+"px",this.element.style.width=(n.right-n.left)/s+"px",this.element.style.height=(n.bottom-n.top)/l+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}computeTarget(e){let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),n=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),i=n&&n.type.spec.disableDropCursor,o=typeof i=="function"?i(this.editorView,t,e):i;if(!t||o)return null;let s=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=gn(this.editorView.state.doc,s,this.editorView.dragging.slice);l!=null&&(s=l)}return s}dragover(e){if(!this.editorView.editable)return;this.lastDragEvent=e;let t=this.computeTarget(e);t!=null&&(this.setCursor(t),this.scheduleRemoval(5e3))}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}};var re=class r extends D{constructor(e){super(e,e)}map(e,t){let n=e.resolve(t.map(this.head));return r.valid(n)?new r(n):D.near(n)}content(){return k.empty}eq(e){return e instanceof r&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new r(e.resolve(t.pos))}getBookmark(){return new si(this.anchor)}static valid(e){let t=e.parent;if(t.inlineContent||!Wf(e)||!Jf(e))return!1;let n=t.type.spec.allowGapCursor;if(n!=null)return n;let i=t.contentMatchAt(e.index()).defaultType;return i&&i.isTextblock}static findGapCursorFrom(e,t,n=!1){e:for(;;){if(!n&&r.valid(e))return e;let i=e.pos,o=null;for(let s=e.depth;;s--){let l=e.node(s);if(t>0?e.indexAfter(s)<l.childCount:e.index(s)>0){o=l.child(t>0?e.indexAfter(s):e.index(s)-1);break}else if(s==0)return null;i+=t;let a=e.doc.resolve(i);if(r.valid(a))return a}for(;;){let s=t>0?o.firstChild:o.lastChild;if(!s){if(o.isAtom&&!o.isText&&!w.isSelectable(o)){e=e.doc.resolve(i+o.nodeSize*t),n=!1;continue e}break}o=s,i+=t;let l=e.doc.resolve(i);if(r.valid(l))return l}return null}}};re.prototype.visible=!1;re.findFrom=re.findGapCursorFrom;D.jsonID("gapcursor",re);var si=class r{constructor(e){this.pos=e}map(e){return new r(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return re.valid(t)?new re(t):D.near(t)}};function tl(r){return r.isAtom||r.spec.isolating||r.spec.createGapCursor}function Wf(r){for(let e=r.depth;e>=0;e--){let t=r.index(e),n=r.node(e);if(t==0){if(n.type.spec.isolating)return!0;continue}for(let i=n.child(t-1);;i=i.lastChild){if(i.childCount==0&&!i.inlineContent||tl(i.type))return!0;if(i.inlineContent)return!1}}return!0}function Jf(r){for(let e=r.depth;e>=0;e--){let t=r.indexAfter(e),n=r.node(e);if(t==n.childCount){if(n.type.spec.isolating)return!0;continue}for(let i=n.child(t);;i=i.firstChild){if(i.childCount==0&&!i.inlineContent||tl(i.type))return!0;if(i.inlineContent)return!1}}return!0}function nl(){return new H({props:{decorations:_f,createSelectionBetween(r,e,t){return e.pos==t.pos&&re.valid(t)?new re(t):null},handleClick:Hf,handleKeyDown:qf,handleDOMEvents:{beforeinput:Kf}}})}var qf=Zt({ArrowLeft:Hn("horiz",-1),ArrowRight:Hn("horiz",1),ArrowUp:Hn("vert",-1),ArrowDown:Hn("vert",1)});function Hn(r,e){let t=r=="vert"?e>0?"down":"up":e>0?"right":"left";return function(n,i,o){let s=n.selection,l=e>0?s.$to:s.$from,a=s.empty;if(s instanceof T){if(!o.endOfTextblock(t)||l.depth==0)return!1;a=!1,l=n.doc.resolve(e>0?l.after():l.before())}let c=re.findGapCursorFrom(l,e,a);return c?(i&&i(n.tr.setSelection(new re(c))),!0):!1}}function Hf(r,e,t){if(!r||!r.editable)return!1;let n=r.state.doc.resolve(e);if(!re.valid(n))return!1;let i=r.posAtCoords({left:t.clientX,top:t.clientY});return i&&i.inside>-1&&w.isSelectable(r.state.doc.nodeAt(i.inside))?!1:(r.dispatch(r.state.tr.setSelection(new re(n))),!0)}function Kf(r,e){if(e.inputType!="insertCompositionText"||!(r.state.selection instanceof re))return!1;let{$from:t}=r.state.selection,n=t.parent.contentMatchAt(t.index()).findWrapping(r.state.schema.nodes.text);if(!n)return!1;let i=S.empty;for(let s=n.length-1;s>=0;s--)i=S.from(n[s].createAndFill(null,i));let o=r.state.tr.replace(t.pos,t.pos,new k(i,0,0));return o.setSelection(T.near(o.doc.resolve(t.pos+1))),r.dispatch(o),!1}function _f(r){if(!(r.selection instanceof re))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",K.create(r.doc,[Y.widget(r.selection.head,e,{key:"gapcursor"})])}var ce=class{constructor(e,t,n={}){this.match=e,this.match=e,this.handler=typeof t=="string"?jf(t):t,this.undoable=n.undoable!==!1,this.inCode=n.inCode||!1,this.inCodeMark=n.inCodeMark!==!1}};function jf(r){return function(e,t,n,i){let o=r;if(t[1]){let s=t[0].lastIndexOf(t[1]);o+=t[0].slice(s+t[1].length),n+=s;let l=n-i;l>0&&(o=t[0].slice(s-l,s)+o,n=i)}return e.tr.insertText(o,n,i)}}var Uf=500;function il({rules:r}){let e=new H({state:{init(){return null},apply(t,n){let i=t.getMeta(this);return i||(t.selectionSet||t.docChanged?null:n)}},props:{handleTextInput(t,n,i,o){return rl(t,n,i,o,r,e)},handleDOMEvents:{compositionend:t=>{setTimeout(()=>{let{$cursor:n}=t.state.selection;n&&rl(t,n.pos,n.pos,"",r,e)})}}},isInputRules:!0});return e}function rl(r,e,t,n,i,o){if(r.composing)return!1;let s=r.state,l=s.doc.resolve(e),a=r.state.selection,c=l.parent.textBetween(Math.max(0,l.parentOffset-Uf),l.parentOffset,null,"\uFFFC")+n,f=e==a.from&&t==a.to&&r.state.storedMarks||(e==t?l.marks():l.marksAcross(s.doc.resolve(t))||[]);for(let h=0;h<i.length;h++){let d=i[h];if(!d.inCodeMark&&f.some(g=>g.type.spec.code))continue;if(l.parent.type.spec.code){if(!d.inCode)continue}else if(d.inCode==="only")continue;let p=d.match.exec(c);if(!p||p[0].length<n.length)continue;let u=e-(p[0].length-n.length);if(!d.inCodeMark){let g=!1;if(s.doc.nodesBetween(u,l.pos,b=>{b.isInline&&b.marks.some(I=>I.type.spec.code)&&(g=!0)}),g)continue}let m=d.handler(s,p,u,t);if(m)return d.undoable&&m.setMeta(o,{transform:m,from:e,to:t,text:n}),r.dispatch(m),!0}return!1}var eu=new ce(/--$/,"\u2014",{inCodeMark:!1}),tu=new ce(/\.\.\.$/,"\u2026",{inCodeMark:!1}),nu=new ce(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,"\u201C",{inCodeMark:!1}),ru=new ce(/"$/,"\u201D",{inCodeMark:!1}),iu=new ce(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,"\u2018",{inCodeMark:!1}),ou=new ce(/'$/,"\u2019",{inCodeMark:!1});function ol(r,e,t,n){let i,o;return e instanceof je?o=e:(i=e,o=e.nodeType,t=e.getAttrs,n=e.joinPredicate),new ce(r,(s,l,a,c)=>{let f=t instanceof Function?t(l):t,h=s.tr.delete(a,c),d=h.doc.resolve(a),p=d.blockRange(),u=p&&mn(p,o,f);if(!u)return null;h.wrap(p,u);let m=h.doc.resolve(a-1).nodeBefore;return m&&m.type==o&&Vt(h.doc,a-1)&&(!n||n(l,m))&&h.join(a-1),h},i)}function li(r,e,t){let n,i;return e instanceof je?i=e:(n=e,i=e.nodeType,t=e.getAttrs),new ce(r,(o,s,l,a)=>{let c=o.doc.resolve(l),f=t instanceof Function?t(s):t;return c.node(-1).canReplaceWith(c.index(-1),c.indexAfter(-1),i)?o.tr.delete(l,a).setBlockType(l,l,i,f):null},n)}function Kn(r){let e;try{e=new URL(String(r||"").trim())}catch{return null}if(!/^https?:$/.test(e.protocol))return null;let t=e.hostname.replace(/^(www\.|m\.)/,""),n=i=>/^[A-Za-z0-9_-]{11}$/.test(i||"")?`https://www.youtube-nocookie.com/embed/${i}`:null;if(t==="youtu.be")return n(e.pathname.slice(1).split("/")[0]);if(t==="youtube.com"||t==="youtube-nocookie.com"||t==="music.youtube.com"){if(e.pathname==="/watch")return n(e.searchParams.get("v"));let i=/^\/(embed|shorts|live|v)\/([^/?#]+)/.exec(e.pathname);return i?n(i[2]):null}if(t==="vimeo.com"||t==="player.vimeo.com"){let i=/^\/(?:video\/)?(\d{1,12})(?:\/|$)/.exec(e.pathname);return i?`https://player.vimeo.com/video/${i[1]}`:null}return null}var Gf=`
|
|
11
|
+
.ProseMirror{position:relative;word-wrap:break-word;white-space:pre-wrap;white-space:break-spaces;font-variant-ligatures:none;font-feature-settings:"liga" 0;outline:none}
|
|
12
|
+
.ProseMirror pre{white-space:pre-wrap}.ProseMirror li{position:relative}
|
|
13
|
+
.ProseMirror-hideselection *::selection{background:transparent}.ProseMirror-hideselection{caret-color:transparent}
|
|
14
|
+
.ProseMirror [draggable][contenteditable=false]{user-select:text}
|
|
15
|
+
.ProseMirror-selectednode{outline:2px solid #FF4F2B;outline-offset:3px}
|
|
16
|
+
.ProseMirror-gapcursor{display:none;pointer-events:none;position:absolute}
|
|
17
|
+
.ProseMirror-gapcursor:after{content:"";display:block;position:absolute;top:-2px;width:20px;border-top:1px solid currentColor;animation:ProseMirror-cursor-blink 1.1s steps(2,start) infinite}
|
|
18
|
+
@keyframes ProseMirror-cursor-blink{to{visibility:hidden}}
|
|
19
|
+
.ProseMirror-focused .ProseMirror-gapcursor{display:block}
|
|
20
|
+
.ProseMirror .selectedCell:after{z-index:2;position:absolute;content:"";inset:0;background:rgba(255,79,43,.12);pointer-events:none}
|
|
21
|
+
.ProseMirror td,.ProseMirror th{position:relative}
|
|
22
|
+
.ProseMirror figure img{cursor:pointer}
|
|
23
|
+
`,tn=!1,Yf=r=>{try{return decodeURIComponent(String(r||"").split("?")[0].split("/").pop())}catch{return""}};function Xf(r,e,t){let n=l=>r.includes(l),i=l=>!tn&&e[l]?{class:e[l]}:{},o={doc:{content:"block+"},paragraph:{group:"block",content:"inline*",parseDOM:[{tag:"p"}],toDOM:()=>["p",i("p"),0]},text:{group:"inline"},hard_break:{inline:!0,group:"inline",selectable:!1,parseDOM:[{tag:"br"}],toDOM:()=>["br"]}};if(n("headings")&&(o.heading={attrs:{level:{default:2}},content:"inline*",group:"block",defining:!0,parseDOM:[2,3,4].map(l=>({tag:`h${l}`,attrs:{level:l}})),toDOM:l=>[`h${l.attrs.level}`,i(`h${l.attrs.level}`),0]}),n("quotes")&&(o.blockquote={content:"paragraph+",group:"block",defining:!0,parseDOM:[{tag:"blockquote"}],toDOM:()=>["blockquote",i("blockquote"),0]}),n("callouts")&&(o.callout={content:"paragraph+",group:"block",defining:!0,parseDOM:[{tag:"aside"}],toDOM:()=>["aside",i("aside"),0]}),n("lists")&&(o.bullet_list={content:"list_item+",group:"block",parseDOM:[{tag:"ul"}],toDOM:()=>["ul",i("ul"),0]},o.ordered_list={content:"list_item+",group:"block",parseDOM:[{tag:"ol"}],toDOM:()=>["ol",i("ol"),0]},o.list_item={content:"inline*",defining:!0,parseDOM:[{tag:"li"}],toDOM:()=>["li",i("li"),0]}),n("images")||n("embeds")){let l=[n("images")&&"image",n("embeds")&&"embed"].filter(Boolean).join(" | ");o.figure={content:`(${l}) figcaption`,group:"block",isolating:!0,parseDOM:[{tag:"figure"}],toDOM:()=>["figure",i("figure"),0]},o.figcaption={content:"inline*",parseDOM:[{tag:"figcaption"}],toDOM:()=>["figcaption",i("figcaption"),0]}}if(n("images")&&(o.image={attrs:{src:{default:""},alt:{default:""}},atom:!0,selectable:!0,draggable:!1,parseDOM:[{tag:"img[src]",getAttrs:l=>({src:Yf(l.getAttribute("src")),alt:l.getAttribute("alt")||""})}],toDOM:l=>["img",{src:tn?l.attrs.src:t+encodeURIComponent(l.attrs.src),alt:l.attrs.alt,...i("img")}]}),n("embeds")&&(o.embed={attrs:{src:{default:""},title:{default:"Video"}},atom:!0,selectable:!0,draggable:!1,parseDOM:[{tag:"iframe[src]",getAttrs:l=>{let a=Kn(l.getAttribute("src"));return a?{src:a,title:l.getAttribute("title")||"Video"}:!1}}],toDOM:l=>["iframe",{src:l.attrs.src,title:l.attrs.title,loading:"lazy",allowfullscreen:"",...i("iframe"),...tn?{}:{style:`pointer-events:none;${e.iframe?"":"display:block;width:100%;height:auto;aspect-ratio:16/9;border:0;"}`}}]}),n("tables")){let l=qs({tableGroup:"block",cellContent:"inline*",cellAttributes:{}});l.table.toDOM=()=>["table",i("table"),["tbody",i("tbody"),0]],l.table_row.toDOM=()=>["tr",i("tr"),0],["table_cell","table_header"].forEach(a=>{let c=a==="table_cell"?"td":"th";l[a].toDOM=f=>{let h={};return f.attrs.colspan!==1&&(h.colspan=f.attrs.colspan),f.attrs.rowspan!==1&&(h.rowspan=f.attrs.rowspan),[c,{...h,...i(c)},0]}}),Object.assign(o,l)}n("code")&&(o.code_block={attrs:{lang:{default:""}},content:"text*",marks:"",group:"block",code:!0,defining:!0,parseDOM:[{tag:"pre",preserveWhitespace:"full",getAttrs:l=>({lang:l.querySelector("code")?.getAttribute("data-lang")||""})}],toDOM:l=>["pre",i("pre"),["code",{...i("pre code"),...l.attrs.lang?{"data-lang":l.attrs.lang}:{}},0]]});let s={strong:{parseDOM:[{tag:"strong"},{tag:"b"}],toDOM:()=>["strong",i("strong"),0]},em:{parseDOM:[{tag:"em"},{tag:"i"}],toDOM:()=>["em",i("em"),0]}};return n("code")&&(s.code={excludes:"_",parseDOM:[{tag:"code",priority:40}],toDOM:()=>["code",i("code"),0]}),n("links")&&(s.link={attrs:{href:{}},inclusive:!1,parseDOM:[{tag:"a[href]",getAttrs:l=>({href:l.getAttribute("href")})}],toDOM:l=>["a",{href:l.attrs.href,...i("a")},0]}),new cn({nodes:o,marks:s})}var _n=new me("verso-hold");function Qf(){return new H({key:_n,state:{init:()=>null,apply(r,e){let t=r.getMeta(_n);return t!==void 0?t:e&&{from:r.mapping.map(e.from),to:r.mapping.map(e.to)}}}})}function Zf(){let r=document.createElement("span");return r.textContent="No description",r.title="Select the picture to describe it",r.setAttribute("contenteditable","false"),r.style.cssText="display:inline-block;margin:.35em 0;padding:.1em .6em;border-radius:999px;background:#FFEDE7;color:#D93A1A;font:600 12px/1.6 ui-sans-serif,system-ui,sans-serif;pointer-events:none;user-select:none",r}function eh(r){let e=t=>{let n=document.createElement("span");return n.textContent=t,n.setAttribute("contenteditable","false"),n.style.cssText="opacity:.4;pointer-events:none;user-select:none",n};return new H({props:{decorations(t){let n=[],{doc:i}=t;i.childCount===1&&i.firstChild.isTextblock&&i.firstChild.content.size===0&&n.push(Y.widget(1,()=>e(r),{side:1})),i.descendants((s,l)=>{s.type.name==="figcaption"&&s.content.size===0&&n.push(Y.widget(l+1,()=>e("Caption (optional)"),{side:1})),s.type.name==="image"&&!s.attrs.alt&&n.push(Y.widget(l+s.nodeSize,Zf,{side:-1,key:"no-desc"}))});let o=_n.getState(t);return o&&o.to>o.from&&n.push(Y.inline(o.from,o.to,{style:"background:rgba(255,79,43,.22);border-radius:2px"})),K.create(i,n)}}})}function th(r){let{list_item:e,paragraph:t}=r.nodes,n=[r.nodes.bullet_list,r.nodes.ordered_list],i=(a,c)=>{let{$from:f}=a.selection;if(f.parent.type!==e)return!1;if(c){let h=f.depth,d=f.node(h-1),p=f.index(h-1),u=f.before(h-1),m=[];p>0&&m.push(d.type.create(d.attrs,d.content.cut(0,wt(d,p)))),m.push(t.create(null,f.parent.content)),p<d.childCount-1&&m.push(d.type.create(d.attrs,d.content.cut(wt(d,p+1))));let g=a.tr.replaceWith(u,u+d.nodeSize,S.from(m)),b=u+(p>0?m[0].nodeSize:0)+1;g.setSelection(T.create(g.doc,b+f.parentOffset)),c(g.scrollIntoView())}return!0};return{enter:(a,c)=>{let{$from:f,empty:h}=a.selection;return f.parent.type!==e?!1:h&&f.parent.content.size===0?i(a,c):(c&&c(a.tr.split(f.pos,1,[{type:e}]).scrollIntoView()),!0)},backspace:(a,c)=>{let{$from:f,empty:h}=a.selection;return!h||f.parent.type!==e||f.parentOffset>0?!1:i(a,c)},toggle:a=>(c,f)=>{let{$from:h,$to:d}=c.selection;if(h.parent.type===e){let g=h.node(h.depth-1);if(g.type===a){if(f){let b=h.before(h.depth-1),I=[];g.forEach(V=>I.push(t.create(null,V.content)));let C=c.tr.replaceWith(b,b+g.nodeSize,S.from(I));f(C.setSelection(T.near(C.doc.resolve(Math.min(b+1,C.doc.content.size)))).scrollIntoView())}return!0}return f&&f(c.tr.setNodeMarkup(h.before(h.depth-1),a)),!0}let p=h.index(0),u=d.index(0),m=[];for(let g=p;g<=u;g++){let b=c.doc.child(g);if(!b.isTextblock)return!1;m.push(b)}if(f){let g=wt(c.doc,p),b=wt(c.doc,u)+c.doc.child(u).nodeSize,I=a.create(null,m.map(V=>e.create(null,V.content))),C=c.tr.replaceWith(g,b,I);f(C.setSelection(T.create(C.doc,g+2+h.parentOffset)).scrollIntoView())}return!0},lists:n}}var wt=(r,e)=>{let t=0;for(let n=0;n<e;n++)t+=r.child(n).nodeSize;return t};function sl(r,e){let t=r.parent,n=r.start(),i=r.index(),o=i<t.childCount?e.isInSet(t.child(i).marks):null;if(!o&&i>0&&(i-=1,o=e.isInSet(t.child(i).marks)),!o)return null;let s=i,l=i+1;for(;s>0&&o.isInSet(t.child(s-1).marks);)s-=1;for(;l<t.childCount&&o.isInSet(t.child(l).marks);)l+=1;return{from:n+wt(t,s),to:n+wt(t,l),mark:o}}var al=(r,e)=>r&&(r.type===e.image||r.type===e.embed);function nh(r){return new H({filterTransaction(e){if(!e.docChanged||!r.figure)return!0;let t=!0;return e.doc.descendants(n=>t?(al(n,r)&&!n.attrs.src&&(t=!1),!0):!1),t}})}function cl(r,e){let t=r.selection;if(!(t instanceof w)||!al(t.node,e))return null;let n=r.doc.resolve(t.from);return n.parent.type===e.figure?{start:n.before(n.depth),node:n.parent}:null}var ai=r=>(e,t)=>{let n=cl(e,r);return n?(t&&t(e.tr.delete(n.start,n.start+n.node.nodeSize).scrollIntoView()),!0):!1};function ll(r,e,t){let n=null;return r.doc.descendants((i,o)=>{if(i.type===e.figure&&i.firstChild?.type===e.embed&&i.firstChild.attrs.src===t&&i.lastChild.content.size===0){let s=o+1+i.firstChild.nodeSize+1;(n==null||Math.abs(s-r.selection.from)<Math.abs(n-r.selection.from))&&(n=s)}}),n!=null&&r.setSelection(T.create(r.doc,n)),r}function Su(r,{tools:e=[],classes:t={},base:n="/",label:i="Text",onChange:o,onState:s,onExit:l,onHint:a,upload:c}){if(!document.getElementById("verso-pm-css")){let y=document.createElement("style");y.id="verso-pm-css",y.textContent=Gf,document.head.appendChild(y)}let f=Xf(e,t,n),h=Ue.fromSchema(f),p=r.hasAttribute("data-verso-empty")?f.topNodeType.createAndFill():h.parse(r),u=f.nodes,m=u.list_item?th(f):null,g=[];u.heading&&g.push(li(/^(#{2,4})\s$/,u.heading,y=>({level:y[1].length}))),u.blockquote&&g.push(ol(/^>\s$/,u.blockquote)),u.code_block?g.push(li(/^```([a-z0-9-]*)\s$/,u.code_block,y=>({lang:y[1]||""}))):g.push(new ce(/^```$/,()=>(a?.("Code blocks aren't available in this field."),null))),f.marks.code&&g.push(new ce(/`([^`]+)`$/,(y,x,A,E)=>y.tr.replaceWith(A,E,f.text(x[1],[f.marks.code.create()])).removeStoredMark(f.marks.code)));let b=(y,x)=>new ce(y,(A,E,R,v)=>{let P=A.tr.delete(R,v),B=A.apply(P),j=null;return m.toggle(x)(B,we=>{j=we}),j?(j.steps.forEach(we=>P.step(we)),P.setSelection(j.selection.map(P.doc,P.mapping.slice(P.steps.length-j.steps.length)))):null});m&&(g.push(b(/^\s*([-+*])\s$/,u.bullet_list)),g.push(b(/^\s*1[.)]\s$/,u.ordered_list)));let I=lt(Ln,(y,x)=>(x&&x(y.tr.replaceSelectionWith(u.hard_break.create()).scrollIntoView()),!0)),C={"Mod-z":Bn,"Shift-Mod-z":Qt,"Mod-y":Qt,"Mod-b":st(f.marks.strong),"Mod-i":st(f.marks.em),"Shift-Enter":I,Escape:()=>(l?.(),!0)};if(m&&(C.Enter=m.enter,C.Backspace=m.backspace),u.figure&&(C.Backspace=C.Backspace?lt(ai(u),C.Backspace):ai(u),C.Delete=ai(u)),f.marks.code&&(C["Mod-e"]=st(f.marks.code)),u.code_block&&(C.Tab=(y,x)=>y.selection.$from.parent.type!==u.code_block?!1:(x&&x(y.tr.insertText(" ")),!0),C["Mod-Enter"]=Ln),u.table){let y=ii(1);C.Tab=C.Tab?lt(C.Tab,y):y,C["Shift-Tab"]=ii(-1)}let V=async(y,x)=>{for(let A of y){let E=await c(A);if(!E?.file)continue;let R=u.figure.create(null,[u.image.create({src:E.file,alt:""}),u.figcaption.create()]),{state:v}=N,P;if(x==null)P=v.tr.replaceSelectionWith(R);else{let B=v.doc.resolve(Math.min(x,v.doc.content.size));P=v.tr.insert(B.depth>=1?B.after(1):B.pos,R)}N.dispatch(P.scrollIntoView())}},J=y=>[...y||[]].filter(x=>/^image\/(jpeg|png|gif|webp|avif)$/.test(x.type)),N=new Ut({mount:r},{state:kn.create({doc:p,plugins:[il({rules:g}),Ur(C),Ur(zs),xs(),el({color:"#FF4F2B",width:2}),nl(),...u.table?[Zs()]:[],Qf(),eh(i),nh(u)]}),dispatchTransaction(y){N.updateState(N.state.apply(y)),y.docChanged&&o?.(),s?.()},handleDrop(y,x){let A=J(x.dataTransfer?.files);if(!A.length)return!1;if(x.preventDefault(),!u.image)return!0;let E=y.posAtCoords({left:x.clientX,top:x.clientY});return V(A,E?E.pos:null),!0},handlePaste(y,x){try{y.domObserver.flush()}catch{}let A=cl(y.state,u);if(A){let P=A.start+A.node.nodeSize,B=y.state.tr.insert(P,u.paragraph.create());y.dispatch(B.setSelection(T.create(B.doc,P+1)))}let E=(x.clipboardData?.getData("text/plain")||"").trim(),{$from:R}=y.state.selection;if(u.embed&&E&&!/\s/.test(E)&&R.parent.type===u.paragraph&&R.parent.content.size===0){let P=Kn(E);if(P){let B=u.figure.create(null,[u.embed.create({src:P,title:P.includes("vimeo")?"Vimeo video":"YouTube video"}),u.figcaption.create()]);return y.dispatch(ll(y.state.tr.replaceWith(R.before(),R.after(),B),u,P).scrollIntoView()),!0}}let v=J(x.clipboardData?.files);return v.length?(u.image&&V(v,null),!0):!1},handleDOMEvents:{blur:()=>(s?.(),!1),focus:()=>(s?.(),!1)}});r.removeAttribute("data-verso-empty"),r.style.opacity="";let O=y=>{y(N.state,N.dispatch,N),N.focus()};return{view:N,focus:()=>N.focus(),html(){tn=!0;try{let y=document.createElement("div");return y.appendChild(Me.fromSchema(f).serializeFragment(N.state.doc.content)),y.innerHTML}finally{tn=!1}},setHTML(y){let x=document.createElement("div");x.innerHTML=y||"",x.querySelectorAll("img").forEach(E=>E.setAttribute("src",E.getAttribute("src")||""));let A=h.parse(x);N.dispatch(N.state.tr.replaceWith(0,N.state.doc.content.size,A.content))},state(){let{state:y}=N,{$from:x,from:A,to:E,empty:R}=y.selection,v=R?y.storedMarks||x.marks():null,P=ye=>ye?R?!!ye.isInSet(v):y.doc.rangeHasMark(A,E,ye):!1,B="p",j=x.parent;j.type===u.heading&&(B=`h${j.attrs.level}`);for(let ye=x.depth;ye>0;ye--){let Mt=x.node(ye);if(Mt.type===u.bullet_list){B="ul";break}if(Mt.type===u.ordered_list){B="ol";break}if(Mt.type===u.blockquote){B="quote";break}if(Mt.type===u.callout){B="callout";break}if(Mt.type===u.figure){B="figure";break}}j.type===u.code_block&&(B="pre");let we=y.selection instanceof w&&y.selection.node.type===u.image?y.selection.node:null,ci=u.embed&&y.selection instanceof w&&y.selection.node.type===u.embed?y.selection.node:null,fi=null;if(f.marks.link){let ye=sl(x,f.marks.link);ye&&(fi=ye.mark.attrs.href)}return{bold:P(f.marks.strong),italic:P(f.marks.em),link:fi,code:P(f.marks.code),block:B,inTable:u.table?Ce(y):!1,image:we&&{alt:we.attrs.alt,src:we.attrs.src},embed:ci&&{src:ci.attrs.src},canUndo:Cs(y)>0,canRedo:ws(y)>0,focused:N.hasFocus()}},bold:()=>O(st(f.marks.strong)),italic:()=>O(st(f.marks.em)),code:()=>{f.marks.code&&O(st(f.marks.code))},codeBlock(){u.code_block&&O(N.state.selection.$from.parent.type===u.code_block?xt(u.paragraph):xt(u.code_block))},undo:()=>O(Bn),redo:()=>O(Qt),block(y){if(y==="p")O(xt(u.paragraph));else if(/^h[234]$/.test(y)&&u.heading){let x=Number(y[1]);O(N.state.selection.$from.parent.type===u.heading&&N.state.selection.$from.parent.attrs.level===x?xt(u.paragraph):xt(u.heading,{level:x}))}},list(y){m&&O(m.toggle(y==="ol"?u.ordered_list:u.bullet_list))},wrap(y){let x=y==="quote"?u.blockquote:u.callout;if(!x)return;let{$from:A}=N.state.selection;for(let E=A.depth;E>0;E--)if(A.node(E).type===x)return O(Ts);O(Is(x))},link(y){let x=f.marks.link;if(!x)return;let{state:A}=N,{from:E,to:R}=A.selection;if(E===R){let P=sl(A.selection.$from,x);P&&({from:E,to:R}=P)}let v=A.tr;y?E===R?v=v.insertText(y,E).addMark(E,E+y.length,x.create({href:y})):v=v.removeMark(E,R,x).addMark(E,R,x.create({href:y})):E!==R&&(v=v.removeMark(E,R,x)),N.dispatch(v),N.focus()},images:y=>V(y,null),embed(y){let x=u.embed?Kn(y):null;if(!x)return!1;let A=u.figure.create(null,[u.embed.create({src:x,title:x.includes("vimeo")?"Vimeo video":"YouTube video"}),u.figcaption.create()]),{state:E}=N,{$from:R}=E.selection,v=R.parent.type===u.paragraph&&R.parent.content.size===0&&R.depth===1?E.tr.replaceWith(R.before(),R.after(),A):E.tr.replaceSelectionWith(A);return N.dispatch(ll(v,u,x).scrollIntoView()),N.focus(),!0},alt(y){let x=N.state.selection;if(x instanceof w&&x.node.type===u.image){let A=N.state.tr.setNodeMarkup(x.from,null,{...x.node.attrs,alt:y});A.setSelection(w.create(A.doc,x.from)),N.dispatch(A)}},removeImage(){let{$from:y}=N.state.selection;for(let A=y.depth;A>=0;A--)if(y.node(A).type===u.figure){let E=y.before(A);return O((R,v)=>(v(R.tr.delete(E,E+y.node(A).nodeSize)),!0))}let x=N.state.selection;if(x instanceof w&&x.node.type===u.image){let A=N.state.doc.resolve(x.from),E=A.before(A.depth);O((R,v)=>(v(R.tr.delete(E,E+A.parent.nodeSize)),!0))}},table(){if(!u.table)return;let y=j=>j.createAndFill(),x=j=>u.table_row.create(null,[y(j),y(j),y(j)]),A=u.table.create(null,[x(u.table_header),x(u.table_cell),x(u.table_cell)]),{state:E}=N,{$from:R}=E.selection,v,P;R.depth>=1&&R.parent.type===u.paragraph&&R.parent.content.size===0&&R.depth===1?(P=R.before(1),v=E.tr.replaceWith(P,R.after(1),A)):(P=R.depth>=1?R.after(1):R.pos,v=E.tr.insert(P,A));let B=null;v.doc.nodesBetween(P,Math.min(v.doc.content.size,P+A.nodeSize),(j,we)=>{B==null&&j.type===u.table_header&&(B=we+1)}),B!=null&&v.setSelection(T.create(v.doc,B)),N.dispatch(v.scrollIntoView()),N.focus()},row:()=>O(Gs),column:()=>O(js),deleteRow:()=>O(Ys),deleteColumn:()=>O(Us),deleteTable:()=>O(Xs),hold(y){let{from:x,to:A}=N.state.selection;N.dispatch(N.state.tr.setMeta(_n,y?{from:x,to:A}:null).setMeta("addToHistory",!1))},destroy:()=>N.destroy()}}export{Su as mountRich};
|